diff --git a/about.po b/about.po index 0ebe85514ff..1549810962b 100644 --- a/about.po +++ b/about.po @@ -13,7 +13,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-01 00:15+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-05-12 00:11+0800\n" "Last-Translator: hsiao yi \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -83,13 +83,15 @@ msgstr "Python 文件的貢獻者們" #: ../../about.rst:34 msgid "" "Many people have contributed to the Python language, the Python standard " -"library, and the Python documentation. See :source:`Misc/ACKS` in the " -"Python source distribution for a partial list of contributors." +"library, and the Python documentation. See the `CPython GitHub repository " +"`__ for a partial " +"list of contributors." msgstr "" -"許多人都曾為 Python 這門語言、Python 標準函式庫和 Python 說明文件貢獻過。" -"Python 所發佈的原始碼中含有部份貢獻者的清單,請見 :source:`Misc/ACKS` 。" +"許多人都曾為 Python 這門語言、Python 標準函式庫和 Python 說明文件貢獻過。部份" +"貢獻者的清單請見 `CPython GitHub 儲存庫 `__。" -#: ../../about.rst:38 +#: ../../about.rst:39 msgid "" "It is only with the input and contributions of the Python community that " "Python has such wonderful documentation -- Thank You!" diff --git a/bugs.po b/bugs.po index 9a7e8cfa43f..e9f8dce4c0c 100644 --- a/bugs.po +++ b/bugs.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-18 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-08-31 12:34+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -47,11 +47,11 @@ msgstr "" "而且不會困擾到太多人。學習如何\\ :ref:`貢獻給 Python `。" -#: ../../bugs.rst:16 +#: ../../bugs.rst:19 msgid "Documentation bugs" msgstr "說明文件的錯誤" -#: ../../bugs.rst:18 +#: ../../bugs.rst:21 msgid "" "If you find a bug in this documentation or would like to propose an " "improvement, please submit a bug report on the :ref:`issue tracker `_。" -#: ../../bugs.rst:28 +#: ../../bugs.rst:31 msgid "" "You can also open a discussion item on our `Documentation Discourse forum " "`_." @@ -80,7 +80,7 @@ msgstr "" "你也可以在我們的\\ `說明文件 Discourse 討論區 `_\\ 中新增一個討論事項。" -#: ../../bugs.rst:31 +#: ../../bugs.rst:34 msgid "" "If you find a bug in the theme (HTML / CSS / JavaScript) of the " "documentation, please submit a bug report on the `python-doc-theme issue " @@ -90,26 +90,26 @@ msgstr "" "theme 問題追蹤系統 `_\\ 上提交錯" "誤報告。" -#: ../../bugs.rst:37 +#: ../../bugs.rst:40 msgid "`Documentation bugs`_" msgstr "`說明文件錯誤`_" -#: ../../bugs.rst:38 +#: ../../bugs.rst:41 msgid "" "A list of documentation bugs that have been submitted to the Python issue " "tracker." msgstr "一系列已被提交至 Python 問題追蹤系統的有關說明文件的錯誤。" -#: ../../bugs.rst:40 +#: ../../bugs.rst:43 msgid "`Issue Tracking `_" msgstr "`問題追蹤系統 `_" -#: ../../bugs.rst:41 +#: ../../bugs.rst:44 msgid "" "Overview of the process involved in reporting an improvement on the tracker." msgstr "在追蹤系統上回報改進建議的過程簡介。" -#: ../../bugs.rst:43 +#: ../../bugs.rst:46 msgid "" "`Helping with Documentation `_" @@ -117,32 +117,33 @@ msgstr "" "`貢獻說明文件 `_" -#: ../../bugs.rst:44 +#: ../../bugs.rst:47 msgid "" "Comprehensive guide for individuals that are interested in contributing to " "Python documentation." msgstr "給有意成為 Python 說明文件貢獻者的綜合指南。" -#: ../../bugs.rst:46 +#: ../../bugs.rst:49 msgid "" "`Documentation Translations `_" +"translations/translating/#translation-coordinators>`_" msgstr "" -"`說明文件翻譯 `_" +"`Documentation Translations `_" -#: ../../bugs.rst:47 +#: ../../bugs.rst:50 msgid "" -"A list of GitHub pages for documentation translation and their primary " -"contacts." +"A list of GitHub pages for documentation translation and their coordination " +"teams." msgstr "" -"一份 GitHub 網頁的清單,裡面有各個說明文件翻譯團隊的連結,以及他們的主要聯絡" -"人。" +"一份 GitHub 網頁的清單,裡面有各個說明文件翻譯團隊的連結,以及他們的協調團" +"隊。" -#: ../../bugs.rst:53 +#: ../../bugs.rst:56 msgid "Using the Python issue tracker" msgstr "使用 Python 問題追蹤系統" -#: ../../bugs.rst:55 +#: ../../bugs.rst:58 msgid "" "Issue reports for Python itself should be submitted via the GitHub issues " "tracker (https://github.com/python/cpython/issues). The GitHub issues " @@ -153,7 +154,7 @@ msgstr "" "python/cpython/issues) 提交。這個 GitHub 問題追蹤系統提供了一個網頁表單,可以" "輸入並提交相關資訊給開發者。" -#: ../../bugs.rst:60 +#: ../../bugs.rst:63 msgid "" "The first step in filing a report is to determine whether the problem has " "already been reported. The advantage in doing so, aside from saving the " @@ -168,7 +169,7 @@ msgstr "" "本中修正了這個問題,也有可能需要更詳細的資訊(在這種情況下,如果可以,非常歡" "迎你提供資訊!)。要確認是否重複回報,請使用頁面頂端的搜尋框來搜尋追蹤系統。" -#: ../../bugs.rst:67 +#: ../../bugs.rst:70 msgid "" "If the problem you're reporting is not already in the list, log in to " "GitHub. If you don't already have a GitHub account, create a new account " @@ -178,7 +179,7 @@ msgstr "" "如果你想回報的問題還沒有在問題列表出現過,請登入 GitHub。如果你還沒有 GitHub " "帳戶,請點選「Sign up」連結來建立一個新的帳戶。你無法以匿名方式提交錯誤報告。" -#: ../../bugs.rst:72 +#: ../../bugs.rst:75 msgid "" "Being now logged in, you can submit an issue. Click on the \"New issue\" " "button in the top bar to report a new issue." @@ -186,18 +187,18 @@ msgstr "" "如果已經登入,那你就可以提交問題了。請點選列表頂端區域的「New issue」按鈕,來" "回報一個新的問題。" -#: ../../bugs.rst:75 +#: ../../bugs.rst:78 msgid "The submission form has two fields, \"Title\" and \"Comment\"." msgstr "提交的表單中有兩個欄位,「Title」及「Comment」。" -#: ../../bugs.rst:77 +#: ../../bugs.rst:80 msgid "" "For the \"Title\" field, enter a *very* short description of the problem; " "fewer than ten words is good." msgstr "" "在「Title」欄位,輸入對該問題\\ *非常*\\ 簡短的描述;最好少於十個單字。" -#: ../../bugs.rst:80 +#: ../../bugs.rst:83 msgid "" "In the \"Comment\" field, describe the problem in detail, including what you " "expected to happen and what did happen. Be sure to include whether any " @@ -208,7 +209,7 @@ msgstr "" "確定說明中包含了涉及到的任何擴充模組,以及你當時所使用的硬體和軟體平台(視情" "況而定,可以附上版本資訊)。" -#: ../../bugs.rst:85 +#: ../../bugs.rst:88 msgid "" "Each issue report will be reviewed by a developer who will determine what " "needs to be done to correct the problem. You will receive an update each " @@ -217,7 +218,7 @@ msgstr "" "每一份問題報告都會被一位開發人員查核,並由他決定要做出什麼變更來修正這個問" "題。每當該問題有修正動作時,你會收到更新回報。" -#: ../../bugs.rst:92 +#: ../../bugs.rst:95 msgid "" "`How to Report Bugs Effectively `_" @@ -225,7 +226,7 @@ msgstr "" "`如何有效地回報錯誤 `_" -#: ../../bugs.rst:93 +#: ../../bugs.rst:96 msgid "" "Article which goes into some detail about how to create a useful bug report. " "This describes what kind of information is useful and why it is useful." @@ -233,14 +234,14 @@ msgstr "" "這篇文章詳細說明如何建立一份有用的錯誤報告。它描述了什麼樣的資訊是有用的,以" "及這些資訊為什麼有用。" -#: ../../bugs.rst:96 +#: ../../bugs.rst:99 msgid "" "`Bug Writing Guidelines `_" msgstr "" "`錯誤撰寫指南 `_" -#: ../../bugs.rst:97 +#: ../../bugs.rst:100 msgid "" "Information about writing a good bug report. Some of this is specific to " "the Mozilla project, but describes general good practices." @@ -248,11 +249,11 @@ msgstr "" "撰寫一份優良錯誤報告的相關資訊。部分的文章內容是針對 Mozilla 專案,但它也描述" "了通用的好習慣。" -#: ../../bugs.rst:103 +#: ../../bugs.rst:106 msgid "Getting started contributing to Python yourself" msgstr "開始讓自己貢獻 Python" -#: ../../bugs.rst:105 +#: ../../bugs.rst:108 msgid "" "Beyond just reporting bugs that you find, you are also welcome to submit " "patches to fix them. You can find more information on how to get started " diff --git a/builtins/exceptions.po b/builtins/exceptions.po index 9428e9ba90b..182ac344aff 100644 --- a/builtins/exceptions.po +++ b/builtins/exceptions.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-14 00:21+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-12-20 16:57+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -408,7 +408,13 @@ msgstr "" ":exc:`ImportError` 的子類別,當模組不能被定位的時候會被 :keyword:`import` 所" "引發。當在 :data:`sys.modules` 裡找到 ``None`` 時也會被引發。" -#: ../../builtins/exceptions.rst:272 +#: ../../builtins/exceptions.rst:271 +msgid "" +"A subclass of :exc:`ImportError` which is raised when a lazy import fails " +"because it (directly or indirectly) tries to import itself." +msgstr "" + +#: ../../builtins/exceptions.rst:278 msgid "" "Raised when a sequence subscript is out of range. (Slice indices are " "silently truncated to fall in the allowed range; if an index is not an " @@ -417,13 +423,13 @@ msgstr "" "當序列的索引超出範圍的時候會被引發。(切片索引 (slice indices) 會默默地被截短" "使其能落在允許的範圍內;如果索引不是整數,:exc:`TypeError` 會被引發。)" -#: ../../builtins/exceptions.rst:281 +#: ../../builtins/exceptions.rst:287 msgid "" "Raised when a mapping (dictionary) key is not found in the set of existing " "keys." msgstr "當對映(字典)的鍵無法在已存在的鍵的集合中被找到時會被引發。" -#: ../../builtins/exceptions.rst:288 +#: ../../builtins/exceptions.rst:294 msgid "" "Raised when the user hits the interrupt key (normally :kbd:`Control-C` " "or :kbd:`Delete`). During execution, a check for interrupts is made " @@ -436,7 +442,7 @@ msgstr "" "承自 :exc:`BaseException` 以防止意外地被捕捉 :exc:`Exception` 的程式碼所捕" "捉,而因此讓直譯器無法結束。" -#: ../../builtins/exceptions.rst:296 +#: ../../builtins/exceptions.rst:302 msgid "" "Catching a :exc:`KeyboardInterrupt` requires special consideration. Because " "it can be raised at unpredictable points, it may, in some circumstances, " @@ -449,7 +455,7 @@ msgstr "" "讓 :exc:`KeyboardInterrupt` 越快結束程式越好,或者完全避免引發它。(參" "考 :ref:`handlers-and-exceptions`。)" -#: ../../builtins/exceptions.rst:306 +#: ../../builtins/exceptions.rst:312 msgid "" "Raised when an operation runs out of memory but the situation may still be " "rescued (by deleting some objects). The associated value is a string " @@ -466,7 +472,7 @@ msgstr "" "整地從該情況中修復;僅管如此,它還是引發例外以讓堆疊回溯可以被印出,以防原因" "出在失控的程式。" -#: ../../builtins/exceptions.rst:317 +#: ../../builtins/exceptions.rst:323 msgid "" "Raised when a local or global name is not found. This applies only to " "unqualified names. The associated value is an error message that includes " @@ -475,19 +481,19 @@ msgstr "" "當找不到本地或全域的名稱時會被引發。這只應用在不合格的名稱 (unqualified " "name) 上。關聯值是一個錯誤訊息,包含那個無法被找到的名稱。" -#: ../../builtins/exceptions.rst:321 +#: ../../builtins/exceptions.rst:327 msgid "The optional *name* keyword-only argument sets the attribute:" msgstr "可選的僅限關鍵字引數 *name* 設定對應的屬性:" -#: ../../builtins/exceptions.rst:325 +#: ../../builtins/exceptions.rst:331 msgid "The name of the variable that was attempted to be accessed." msgstr "嘗試被存取的變數名稱。" -#: ../../builtins/exceptions.rst:327 +#: ../../builtins/exceptions.rst:333 msgid "Added the :attr:`name` attribute." msgstr "新增 :attr:`name` 屬性。" -#: ../../builtins/exceptions.rst:333 +#: ../../builtins/exceptions.rst:339 msgid "" "This exception is derived from :exc:`RuntimeError`. In user defined base " "classes, abstract methods should raise this exception when they require " @@ -498,7 +504,7 @@ msgstr "" "生類別覆寫該方法時應該要引發此例外,或者當類別正在開發中,可用此例外表示還需" "要加入真正的實作。" -#: ../../builtins/exceptions.rst:340 +#: ../../builtins/exceptions.rst:346 msgid "" "It should not be used to indicate that an operator or method is not meant to " "be supported at all -- in that case either leave the operator / method " @@ -507,7 +513,7 @@ msgstr "" "此例外不應該用來表示根本沒有要支援的運算子或方法 ── 在這個情況下可以讓該運算" "子或方法保持未定義,或者如果是子類別的話將其設成 :data:`None`。" -#: ../../builtins/exceptions.rst:346 +#: ../../builtins/exceptions.rst:352 msgid "" ":exc:`!NotImplementedError` and :data:`!NotImplemented` are not " "interchangeable. This exception should only be used as described above; " @@ -518,7 +524,7 @@ msgstr "" "外只能用在上面描述的情況;參考 :data:`NotImplemented` 裡關於內建常數正確使用" "方法的細節。" -#: ../../builtins/exceptions.rst:357 +#: ../../builtins/exceptions.rst:363 msgid "" "This exception is raised when a system function returns a system-related " "error, including I/O failures such as \"file not found\" or \"disk full\" " @@ -527,7 +533,7 @@ msgstr "" "當系統函式回傳系統相關錯誤,包含像\"找不到檔案\"或\"硬碟已滿\"的 I/O 失敗會引" "發此例外(而非不合法的引數或其他次要的錯誤)。" -#: ../../builtins/exceptions.rst:361 +#: ../../builtins/exceptions.rst:367 msgid "" "The second form of the constructor sets the corresponding attributes, " "described below. The attributes default to :const:`None` if not specified. " @@ -540,7 +546,7 @@ msgstr "" "數,:attr:`~BaseException.args` 屬性只會是包含建構函式前兩個引數的雙元素元" "組。" -#: ../../builtins/exceptions.rst:367 +#: ../../builtins/exceptions.rst:373 msgid "" "The constructor often actually returns a subclass of :exc:`OSError`, as " "described in `OS exceptions`_ below. The particular subclass depends on the " @@ -553,11 +559,11 @@ msgstr "" "個行為只發生在直接建構 :exc:`OSError` 或透過別名,且產生子類別的時候不會被繼" "承。" -#: ../../builtins/exceptions.rst:375 +#: ../../builtins/exceptions.rst:381 msgid "A numeric error code from the C variable :c:data:`errno`." msgstr "從 C 變數 :c:data:`errno` 而來的數值錯誤代碼。" -#: ../../builtins/exceptions.rst:379 +#: ../../builtins/exceptions.rst:385 msgid "" "Under Windows, this gives you the native Windows error code. " "The :attr:`.errno` attribute is then an approximate translation, in POSIX " @@ -566,7 +572,7 @@ msgstr "" "在 Windows 下,這會提供你原生的 Windows 錯誤代碼。而 :attr:`.errno` 屬性是一" "個該原生錯誤代碼對於 POSIX 來說的近似翻譯。" -#: ../../builtins/exceptions.rst:383 +#: ../../builtins/exceptions.rst:389 msgid "" "Under Windows, if the *winerror* constructor argument is an integer, " "the :attr:`.errno` attribute is determined from the Windows error code, and " @@ -577,7 +583,7 @@ msgstr "" "據該 Windows 錯誤代碼來決定,且 *errno* 引數會被忽略。在其他平台上," "*winerror* 引數會被忽略,而 :attr:`winerror` 屬性會不存在。" -#: ../../builtins/exceptions.rst:391 +#: ../../builtins/exceptions.rst:397 msgid "" "The corresponding error message, as provided by the operating system. It is " "formatted by the C functions :c:func:`!perror` under POSIX, and :c:func:`!" @@ -586,7 +592,7 @@ msgstr "" "作業系統提供的對應錯誤訊息。在 POSIX 下會使用 C 函式 :c:func:`!perror` 做格式" "化,而在 Windows 下會使用 :c:func:`!FormatMessage`。" -#: ../../builtins/exceptions.rst:399 +#: ../../builtins/exceptions.rst:405 msgid "" "For exceptions that involve a file system path (such as :func:`open` " "or :func:`os.unlink`), :attr:`filename` is the file name passed to the " @@ -599,7 +605,7 @@ msgstr "" "案系統路徑的函式(像是 :func:`os.rename`),:attr:`filename2` 對應到傳入函式" "的第二個檔案名稱。" -#: ../../builtins/exceptions.rst:406 +#: ../../builtins/exceptions.rst:412 msgid "" ":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket.error`, :exc:`select.error` " "and :exc:`!mmap.error` have been merged into :exc:`OSError`, and the " @@ -608,7 +614,7 @@ msgstr "" ":exc:`EnvironmentError`、:exc:`IOError`、:exc:`WindowsError`、:exc:`socket.error`、:exc:`select.error` " "及 :exc:`!mmap.error` 已合併進 :exc:`OSError`,而建構函式可能會回傳子類別。" -#: ../../builtins/exceptions.rst:412 +#: ../../builtins/exceptions.rst:418 msgid "" "The :attr:`filename` attribute is now the original file name passed to the " "function, instead of the name encoded to or decoded from " @@ -619,7 +625,7 @@ msgstr "" "和錯誤處理函式 `\\ 編碼或解碼過的名" "稱。並且新增 *filename2* 建構函式引數與屬性。" -#: ../../builtins/exceptions.rst:421 +#: ../../builtins/exceptions.rst:427 msgid "" "Raised when the result of an arithmetic operation is too large to be " "represented. This cannot occur for integers (which would rather " @@ -633,7 +639,7 @@ msgstr "" "有時候會因為整數在要求範圍之外而引發。因為在 C 裡面缺乏浮點數例外處理的標準" "化,大部分的浮點數運算都沒有被檢查。" -#: ../../builtins/exceptions.rst:431 +#: ../../builtins/exceptions.rst:437 msgid "" "This exception is derived from :exc:`RuntimeError`. It is raised when an " "operation is blocked during interpreter shutdown also known as :term:`Python " @@ -643,7 +649,7 @@ msgstr "" "作 :term:`Python 最終化 (Python finalization) `)期間" "被阻塞會引發此例外。" -#: ../../builtins/exceptions.rst:435 +#: ../../builtins/exceptions.rst:441 msgid "" "Examples of operations which can be blocked with " "a :exc:`PythonFinalizationError` during the Python finalization:" @@ -651,31 +657,43 @@ msgstr "" "在 Python 最終化期間,能夠以 :exc:`PythonFinalizationError` 被阻塞的操作範" "例:" -#: ../../builtins/exceptions.rst:438 +#: ../../builtins/exceptions.rst:444 msgid "Creating a new Python thread." msgstr "建立新的 Python 執行緒。" -#: ../../builtins/exceptions.rst:439 +#: ../../builtins/exceptions.rst:445 msgid ":meth:`Joining ` a running daemon thread." msgstr ":meth:`Join ` 一個執行中的常駐執行緒。" -#: ../../builtins/exceptions.rst:440 -msgid ":func:`os.fork`." -msgstr ":func:`os.fork`。" +#: ../../builtins/exceptions.rst:446 +msgid ":func:`os.fork`," +msgstr ":func:`os.fork`," + +#: ../../builtins/exceptions.rst:447 +msgid "" +"acquiring a lock such as :class:`threading.Lock`, when it is known that the " +"operation would otherwise deadlock." +msgstr "" -#: ../../builtins/exceptions.rst:442 +#: ../../builtins/exceptions.rst:450 msgid "See also the :func:`sys.is_finalizing` function." msgstr "也可以參閱 :func:`sys.is_finalizing` 函式。" -#: ../../builtins/exceptions.rst:444 ../../builtins/exceptions.rst:457 +#: ../../builtins/exceptions.rst:452 ../../builtins/exceptions.rst:470 msgid "Previously, a plain :exc:`RuntimeError` was raised." msgstr "在之前,會引發一般的 :exc:`RuntimeError`。" -#: ../../builtins/exceptions.rst:449 +#: ../../builtins/exceptions.rst:457 msgid ":meth:`threading.Thread.join` can now raise this exception." msgstr ":meth:`threading.Thread.join` 現在可以引發此例外。" -#: ../../builtins/exceptions.rst:453 +#: ../../builtins/exceptions.rst:461 +msgid "" +"This exception may be raised when acquiring :meth:`threading.Lock` or :meth:" +"`threading.RLock`." +msgstr "" + +#: ../../builtins/exceptions.rst:466 msgid "" "This exception is derived from :exc:`RuntimeError`. It is raised when the " "interpreter detects that the maximum recursion depth " @@ -684,7 +702,7 @@ msgstr "" "此例外衍生自 :exc:`RuntimeError`。當直譯器偵測到超過最大的遞迴深度(參" "考 :func:`sys.getrecursionlimit`)時會引發此例外。" -#: ../../builtins/exceptions.rst:463 +#: ../../builtins/exceptions.rst:476 msgid "" "This exception is raised when a weak reference proxy, created by " "the :func:`weakref.proxy` function, is used to access an attribute of the " @@ -695,7 +713,7 @@ msgstr "" "用來存取已經被垃圾回收 (garbage collected) 的參照物屬性時會引發此例外。更多關" "於弱參照的資訊參考 :mod:`weakref` 模組。" -#: ../../builtins/exceptions.rst:471 +#: ../../builtins/exceptions.rst:484 msgid "" "Raised when an error is detected that doesn't fall in any of the other " "categories. The associated value is a string indicating what precisely went " @@ -704,7 +722,7 @@ msgstr "" "當偵測到一個不屬於任何其他種類的錯誤時會引發此例外。關聯值是一個表示確切什麼" "地方出錯的字串。" -#: ../../builtins/exceptions.rst:478 +#: ../../builtins/exceptions.rst:491 msgid "" "Raised by built-in function :func:`next` and " "an :term:`iterator`\\'s :meth:`~iterator.__next__` method to signal that " @@ -713,7 +731,7 @@ msgstr "" "會被內建函式 :func:`next` 及 :term:`iterator` 的 :meth:`~iterator.__next__` " "方法引發,用來表示疊代器沒有更多項目可以產生。" -#: ../../builtins/exceptions.rst:484 +#: ../../builtins/exceptions.rst:497 msgid "" "The exception object has a single attribute :attr:`!value`, which is given " "as an argument when constructing the exception, and defaults " @@ -722,7 +740,7 @@ msgstr "" "此例外物件有單一屬性 :attr:`!value`,當建構此例外時會以引數給定,預設" "為 :const:`None`。" -#: ../../builtins/exceptions.rst:488 +#: ../../builtins/exceptions.rst:501 msgid "" "When a :term:`generator` or :term:`coroutine` function returns, a " "new :exc:`StopIteration` instance is raised, and the value returned by the " @@ -733,7 +751,7 @@ msgstr "" "的 :exc:`StopIteration` 實例會被引發,而該函式的回傳值會被用來當作此例外建構" "函式的 :attr:`value` 參數。" -#: ../../builtins/exceptions.rst:493 +#: ../../builtins/exceptions.rst:506 msgid "" "If a generator code directly or indirectly raises :exc:`StopIteration`, it " "is converted into a :exc:`RuntimeError` (retaining the :exc:`StopIteration` " @@ -742,13 +760,13 @@ msgstr "" "如果產生器程式直接或間接引發 :exc:`StopIteration`,則其會被轉換" "成 :exc:`RuntimeError`\\ (保留 :exc:`StopIteration` 作為新例外的成因)。" -#: ../../builtins/exceptions.rst:497 +#: ../../builtins/exceptions.rst:510 msgid "" "Added ``value`` attribute and the ability for generator functions to use it " "to return a value." msgstr "新增 ``value`` 屬性且產生器函式可以用它來回傳值。" -#: ../../builtins/exceptions.rst:501 +#: ../../builtins/exceptions.rst:514 msgid "" "Introduced the RuntimeError transformation via ``from __future__ import " "generator_stop``, see :pep:`479`." @@ -756,7 +774,7 @@ msgstr "" "透過 ``from __future__ import generator_stop`` 引入 RuntimeError 的轉換,參" "考 :pep:`479`。" -#: ../../builtins/exceptions.rst:505 +#: ../../builtins/exceptions.rst:518 msgid "" "Enable :pep:`479` for all code by default: a :exc:`StopIteration` error " "raised in a generator is transformed into a :exc:`RuntimeError`." @@ -764,7 +782,7 @@ msgstr "" "預設對所有程式啟用 :pep:`479`:在產生器引發的 :exc:`StopIteration` 錯誤會轉換" "成 :exc:`RuntimeError`。" -#: ../../builtins/exceptions.rst:511 +#: ../../builtins/exceptions.rst:524 msgid "" "Must be raised by :meth:`~object.__anext__` method of an :term:`asynchronous " "iterator` object to stop the iteration." @@ -772,7 +790,7 @@ msgstr "" "此例外必須被 :term:`asynchronous iterator` 物件的 :meth:`~object.__anext__` " "方法引發來停止疊代。" -#: ../../builtins/exceptions.rst:518 +#: ../../builtins/exceptions.rst:531 msgid "" "Raised when the parser encounters a syntax error. This may occur in " "an :keyword:`import` statement, in a call to the built-in " @@ -783,7 +801,7 @@ msgstr "" "呼叫內建函式 :func:`compile`、:func:`exec` 或 :func:`eval` 的時候,或者在讀取" "初始腳本或標準輸入(也包含互動式)的時候。" -#: ../../builtins/exceptions.rst:524 +#: ../../builtins/exceptions.rst:537 msgid "" "The :func:`str` of the exception instance returns only the error message. " "Details is a tuple whose members are also available as separate attributes." @@ -791,18 +809,18 @@ msgstr "" "例外實例的 :func:`str` 只回傳錯誤訊息。Details 是個元組,其成員也能夠以分開的" "屬性取得。" -#: ../../builtins/exceptions.rst:529 +#: ../../builtins/exceptions.rst:542 msgid "The name of the file the syntax error occurred in." msgstr "發生語法錯誤所在的檔案名稱。" -#: ../../builtins/exceptions.rst:533 +#: ../../builtins/exceptions.rst:546 msgid "" "Which line number in the file the error occurred in. This is 1-indexed: the " "first line in the file has a ``lineno`` of 1." msgstr "" "發生錯誤所在檔案的列號。這是以 1 開始的索引:檔案第一列的 ``lineno`` 是 1。" -#: ../../builtins/exceptions.rst:538 +#: ../../builtins/exceptions.rst:551 msgid "" "The column in the line where the error occurred. This is 1-indexed: the " "first character in the line has an ``offset`` of 1." @@ -810,11 +828,11 @@ msgstr "" "發生錯誤所在該列的欄號 (column)。這是以 1 開始的索引:該列第一個字元的 " "``offset`` 是 1。" -#: ../../builtins/exceptions.rst:543 +#: ../../builtins/exceptions.rst:556 msgid "The source code text involved in the error." msgstr "涉及該錯誤的原始程式碼文字。" -#: ../../builtins/exceptions.rst:547 +#: ../../builtins/exceptions.rst:560 msgid "" "Which line number in the file the error occurred ends in. This is 1-indexed: " "the first line in the file has a ``lineno`` of 1." @@ -822,7 +840,7 @@ msgstr "" "發生錯誤所在檔案的結束列號。這是以 1 開始的索引:檔案第一列的 ``lineno`` 是 " "1。" -#: ../../builtins/exceptions.rst:552 +#: ../../builtins/exceptions.rst:565 msgid "" "The column in the end line where the error occurred finishes. This is 1-" "indexed: the first character in the line has an ``offset`` of 1." @@ -830,7 +848,7 @@ msgstr "" "發生錯誤所在該結束列的欄號。這是以 1 開始的索引:該列第一個字元的 ``offset`` " "是 1。" -#: ../../builtins/exceptions.rst:555 +#: ../../builtins/exceptions.rst:568 msgid "" "For errors in f-string fields, the message is prefixed by \"f-string: \" and " "the offsets are offsets in a text constructed from the replacement " @@ -841,18 +859,18 @@ msgstr "" "(offset) 是從替代運算式建構的文字的偏移量。例如編譯 f'Bad {a b} field' 會得到" "這個 args 屬性:('f-string: ...', ('', 1, 2, '(a b)\\n', 1, 5))。" -#: ../../builtins/exceptions.rst:560 +#: ../../builtins/exceptions.rst:573 msgid "Added the :attr:`end_lineno` and :attr:`end_offset` attributes." msgstr "新增 :attr:`end_lineno` 與 :attr:`end_offset` 屬性。" -#: ../../builtins/exceptions.rst:565 +#: ../../builtins/exceptions.rst:578 msgid "" "Base class for syntax errors related to incorrect indentation. This is a " "subclass of :exc:`SyntaxError`." msgstr "" "與不正確的縮排有關的語法錯誤的基礎類別。這是 :exc:`SyntaxError` 的子類別。" -#: ../../builtins/exceptions.rst:571 +#: ../../builtins/exceptions.rst:584 msgid "" "Raised when indentation contains an inconsistent use of tabs and spaces. " "This is a subclass of :exc:`IndentationError`." @@ -860,7 +878,7 @@ msgstr "" "當縮排包含製表符號 (tab) 和空白的不一致用法時會引發此例外。這" "是 :exc:`IndentationError` 的子類別。" -#: ../../builtins/exceptions.rst:577 +#: ../../builtins/exceptions.rst:590 msgid "" "Raised when the interpreter finds an internal error, but the situation does " "not look so serious to cause it to abandon all hope. The associated value is " @@ -873,7 +891,7 @@ msgstr "" "在 :term:`CPython` 中,這可能是因為錯誤地使用 Python 的 C API,例如回傳一個 " "``NULL`` 值而沒有設定例外。" -#: ../../builtins/exceptions.rst:583 +#: ../../builtins/exceptions.rst:596 msgid "" "If you're confident that this exception wasn't your fault, or the fault of a " "package you're using, you should report this to the author or maintainer of " @@ -888,7 +906,7 @@ msgstr "" "互動式 Python 會話的開頭被印出)、確切的錯誤訊息(該例外的關聯值)及如果可能" "的話,觸發此錯誤的程式來源。" -#: ../../builtins/exceptions.rst:594 +#: ../../builtins/exceptions.rst:607 msgid "" "This exception is raised by the :func:`sys.exit` function. It inherits " "from :exc:`BaseException` instead of :exc:`Exception` so that it is not " @@ -909,7 +927,7 @@ msgstr "" "``None``,結束狀態會是 0;如果它是其他型別(例如字串),則物件的值會被印出而" "結束狀態是 1。" -#: ../../builtins/exceptions.rst:605 +#: ../../builtins/exceptions.rst:618 msgid "" "A call to :func:`sys.exit` is translated into an exception so that clean-up " "handlers (:keyword:`finally` clauses of :keyword:`try` statements) can be " @@ -923,13 +941,13 @@ msgstr "" "風險下執行腳本。如果在絕對有必要立即結束的情況(例如在子行程呼叫" "完 :func:`os.fork` 之後 )可以使用 :func:`os._exit` 函式。" -#: ../../builtins/exceptions.rst:614 +#: ../../builtins/exceptions.rst:627 msgid "" "The exit status or error message that is passed to the constructor. " "(Defaults to ``None``.)" msgstr "傳入建構函式的結束狀態或錯誤訊息。(預設是 ``None``。 )" -#: ../../builtins/exceptions.rst:620 +#: ../../builtins/exceptions.rst:633 msgid "" "Raised when an operation or function is applied to an object of " "inappropriate type. The associated value is a string giving details about " @@ -938,7 +956,7 @@ msgstr "" "當一個操作或函式被用在不適合的型別的物件時會引發此例外。關聯值是一個字串,提" "供關於不相符型別的細節。" -#: ../../builtins/exceptions.rst:623 +#: ../../builtins/exceptions.rst:636 msgid "" "This exception may be raised by user code to indicate that an attempted " "operation on an object is not supported, and is not meant to be. If an " @@ -949,7 +967,7 @@ msgstr "" "這樣做。如果一個物件有意要支援某個給定的操作但尚未提供實作,該引發的正確例外" "是 :exc:`NotImplementedError`。" -#: ../../builtins/exceptions.rst:628 +#: ../../builtins/exceptions.rst:641 msgid "" "Passing arguments of the wrong type (e.g. passing a :class:`list` when " "an :class:`int` is expected) should result in a :exc:`TypeError`, but " @@ -960,7 +978,7 @@ msgstr "" "導致 :exc:`TypeError`,但傳入帶有錯誤值的引數(例如超出預期範圍的數值)應該要" "導致 :exc:`ValueError`。" -#: ../../builtins/exceptions.rst:635 +#: ../../builtins/exceptions.rst:648 msgid "" "Raised when a reference is made to a local variable in a function or method, " "but no value has been bound to that variable. This is a subclass " @@ -969,7 +987,7 @@ msgstr "" "當在函式或方法裡引用某個區域變數,但該變數尚未被繫結到任何值的時候會引發此例" "外。這是 :exc:`NameError` 的子類別。" -#: ../../builtins/exceptions.rst:642 +#: ../../builtins/exceptions.rst:655 msgid "" "Raised when a Unicode-related encoding or decoding error occurs. It is a " "subclass of :exc:`ValueError`." @@ -977,7 +995,7 @@ msgstr "" "當 Unicode 相關的編碼或解碼錯誤發生時會引發此例外。這是 :exc:`ValueError` 的" "子類別。" -#: ../../builtins/exceptions.rst:645 +#: ../../builtins/exceptions.rst:658 msgid "" ":exc:`UnicodeError` has attributes that describe the encoding or decoding " "error. For example, ``err.object[err.start:err.end]`` gives the particular " @@ -986,34 +1004,34 @@ msgstr "" ":exc:`UnicodeError` 有屬性描述編碼或解碼錯誤。例如 " "``err.object[err.start:err.end]`` 會提供讓編解碼器失敗的具體無效輸入。" -#: ../../builtins/exceptions.rst:651 +#: ../../builtins/exceptions.rst:664 msgid "The name of the encoding that raised the error." msgstr "引發錯誤的編碼名稱。" -#: ../../builtins/exceptions.rst:655 +#: ../../builtins/exceptions.rst:668 msgid "A string describing the specific codec error." msgstr "描述特定編解碼器錯誤的字串。" -#: ../../builtins/exceptions.rst:659 +#: ../../builtins/exceptions.rst:672 msgid "The object the codec was attempting to encode or decode." msgstr "編解碼器嘗試編碼或解碼的物件。" -#: ../../builtins/exceptions.rst:663 +#: ../../builtins/exceptions.rst:676 msgid "The first index of invalid data in :attr:`object`." msgstr "在 :attr:`object` 中無效資料的開始索引。" -#: ../../builtins/exceptions.rst:665 ../../builtins/exceptions.rst:672 +#: ../../builtins/exceptions.rst:678 ../../builtins/exceptions.rst:685 msgid "" "This value should not be negative as it is interpreted as an absolute offset " "but this constraint is not enforced at runtime." msgstr "" "此值不應為負,因為它被直譯為絕對偏移量,但此約束在 runtime 中不會被強制執行。" -#: ../../builtins/exceptions.rst:670 +#: ../../builtins/exceptions.rst:683 msgid "The index after the last invalid data in :attr:`object`." msgstr "在 :attr:`object` 中最後的無效資料後的索引。" -#: ../../builtins/exceptions.rst:678 +#: ../../builtins/exceptions.rst:691 msgid "" "Raised when a Unicode-related error occurs during encoding. It is a " "subclass of :exc:`UnicodeError`." @@ -1021,7 +1039,7 @@ msgstr "" "在編碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../builtins/exceptions.rst:684 +#: ../../builtins/exceptions.rst:697 msgid "" "Raised when a Unicode-related error occurs during decoding. It is a " "subclass of :exc:`UnicodeError`." @@ -1029,7 +1047,7 @@ msgstr "" "在解碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../builtins/exceptions.rst:690 +#: ../../builtins/exceptions.rst:703 msgid "" "Raised when a Unicode-related error occurs during translating. It is a " "subclass of :exc:`UnicodeError`." @@ -1037,7 +1055,7 @@ msgstr "" "在轉譯當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../builtins/exceptions.rst:696 +#: ../../builtins/exceptions.rst:709 msgid "" "Raised when an operation or function receives an argument that has the right " "type but an inappropriate value, and the situation is not described by a " @@ -1046,7 +1064,7 @@ msgstr "" "當一個操作或函式收到引數是正確型別但是不適合的值,且該情況無法被更精確的例外" "例如 :exc:`IndexError` 所描述時會引發此例外。" -#: ../../builtins/exceptions.rst:703 +#: ../../builtins/exceptions.rst:716 msgid "" "Raised when the second argument of a division or modulo operation is zero. " "The associated value is a string indicating the type of the operands and the " @@ -1055,7 +1073,7 @@ msgstr "" "當除法或模數運算 (modulo operation) 的第二個引數是 0 的時候會引發此例外。關聯" "值是一個字串,表示運算元及運算的類型。" -#: ../../builtins/exceptions.rst:708 +#: ../../builtins/exceptions.rst:721 msgid "" "The following exceptions are kept for compatibility with previous versions; " "starting from Python 3.3, they are aliases of :exc:`OSError`." @@ -1063,21 +1081,21 @@ msgstr "" "以下例外是為了相容於之前版本而保留;從 Python 3.3 開始,它們" "是 :exc:`OSError` 的別名。" -#: ../../builtins/exceptions.rst:717 +#: ../../builtins/exceptions.rst:730 msgid "Only available on Windows." msgstr "僅限於在 Windows 中使用。" -#: ../../builtins/exceptions.rst:721 +#: ../../builtins/exceptions.rst:734 msgid "OS exceptions" msgstr "作業系統例外" -#: ../../builtins/exceptions.rst:723 +#: ../../builtins/exceptions.rst:736 msgid "" "The following exceptions are subclasses of :exc:`OSError`, they get raised " "depending on the system error code." msgstr "以下的例外是 :exc:`OSError` 的子類別,它們根據系統錯誤代碼來引發。" -#: ../../builtins/exceptions.rst:728 +#: ../../builtins/exceptions.rst:741 msgid "" "Raised when an operation would block on an object (e.g. socket) set for non-" "blocking operation. Corresponds " @@ -1088,14 +1106,14 @@ msgstr "" "到 :c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:py:const:`~errno.EWOULDBLOCK` " "及 :py:const:`~errno.EINPROGRESS`。" -#: ../../builtins/exceptions.rst:733 +#: ../../builtins/exceptions.rst:746 msgid "" "In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have one " "more attribute:" msgstr "" "除了 :exc:`OSError` 的那些屬性之外,:exc:`BlockingIOError` 有多一個屬性:" -#: ../../builtins/exceptions.rst:738 +#: ../../builtins/exceptions.rst:751 msgid "" "An integer containing the number of **bytes** written to the stream before " "it blocked. This attribute is available when using the buffered I/O classes " @@ -1104,7 +1122,7 @@ msgstr "" "一個整數,內容為在其阻塞之前,已寫進串流的\\ **位元組**\\ 數。當使" "用 :mod:`io` 模組裡的緩衝 I/O 類別時這個屬性是可用的。" -#: ../../builtins/exceptions.rst:744 +#: ../../builtins/exceptions.rst:757 msgid "" "Raised when an operation on a child process failed. Corresponds " "to :c:data:`errno` :py:const:`~errno.ECHILD`." @@ -1112,11 +1130,11 @@ msgstr "" "當子行程上的操作失敗時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.ECHILD`。" -#: ../../builtins/exceptions.rst:749 +#: ../../builtins/exceptions.rst:762 msgid "A base class for connection-related issues." msgstr "連線相關問題的基礎類別。" -#: ../../builtins/exceptions.rst:751 +#: ../../builtins/exceptions.rst:764 msgid "" "Subclasses " "are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:`ConnectionRefusedError` " @@ -1126,7 +1144,7 @@ msgstr "" "有 :exc:`BrokenPipeError`、:exc:`ConnectionAbortedError`、:exc:`ConnectionRefusedError` " "及 :exc:`ConnectionResetError`。" -#: ../../builtins/exceptions.rst:756 +#: ../../builtins/exceptions.rst:769 msgid "" "A subclass of :exc:`ConnectionError`, raised when trying to write on a pipe " "while the other end has been closed, or trying to write on a socket which " @@ -1137,7 +1155,7 @@ msgstr "" "會引發此例外,或者當嘗試寫入已關閉寫入的 socket 時也會引發。對應" "到 :c:data:`errno` :py:const:`~errno.EPIPE` 及 :py:const:`~errno.ESHUTDOWN`。" -#: ../../builtins/exceptions.rst:763 +#: ../../builtins/exceptions.rst:776 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " "aborted by the peer. Corresponds " @@ -1146,7 +1164,7 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點 (peer) 中斷時會引" "發此例外。對應到 :c:data:`errno` :py:const:`~errno.ECONNABORTED`。" -#: ../../builtins/exceptions.rst:769 +#: ../../builtins/exceptions.rst:782 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " "refused by the peer. Corresponds " @@ -1155,7 +1173,7 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點拒絕時會引發此例" "外。對應到 :c:data:`errno` :py:const:`~errno.ECONNREFUSED`。" -#: ../../builtins/exceptions.rst:775 +#: ../../builtins/exceptions.rst:788 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection is reset by " "the peer. Corresponds to :c:data:`errno` :py:const:`~errno.ECONNRESET`." @@ -1163,7 +1181,7 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線被對等端點重置時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.ECONNRESET`。" -#: ../../builtins/exceptions.rst:781 +#: ../../builtins/exceptions.rst:794 msgid "" "Raised when trying to create a file or directory which already exists. " "Corresponds to :c:data:`errno` :py:const:`~errno.EEXIST`." @@ -1171,7 +1189,7 @@ msgstr "" "當嘗試建立已存在的檔案或目錄時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.EEXIST`。" -#: ../../builtins/exceptions.rst:786 +#: ../../builtins/exceptions.rst:799 msgid "" "Raised when a file or directory is requested but doesn't exist. Corresponds " "to :c:data:`errno` :py:const:`~errno.ENOENT`." @@ -1179,7 +1197,7 @@ msgstr "" "當請求不存在的檔案或目錄時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.ENOENT`。" -#: ../../builtins/exceptions.rst:791 +#: ../../builtins/exceptions.rst:804 msgid "" "Raised when a system call is interrupted by an incoming signal. Corresponds " "to :c:data:`errno` :py:const:`~errno.EINTR`." @@ -1187,7 +1205,7 @@ msgstr "" "當系統呼叫被傳入的信號中斷時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.EINTR`。" -#: ../../builtins/exceptions.rst:794 +#: ../../builtins/exceptions.rst:807 msgid "" "Python now retries system calls when a syscall is interrupted by a signal, " "except if the signal handler raises an exception (see :pep:`475` for the " @@ -1196,7 +1214,7 @@ msgstr "" "現在當 syscall 被信號中斷時 Python 會重試系統呼叫而不會引" "發 :exc:`InterruptedError`,除非信號處理器引發例外(理由可參考 :pep:`475`)。" -#: ../../builtins/exceptions.rst:801 +#: ../../builtins/exceptions.rst:814 msgid "" "Raised when a file operation (such as :func:`os.remove`) is requested on a " "directory. Corresponds to :c:data:`errno` :py:const:`~errno.EISDIR`." @@ -1204,7 +1222,7 @@ msgstr "" "當在目錄上請求檔案操作(例如 :func:`os.remove`)時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.EISDIR`。" -#: ../../builtins/exceptions.rst:807 +#: ../../builtins/exceptions.rst:820 msgid "" "Raised when a directory operation (such as :func:`os.listdir`) is requested " "on something which is not a directory. On most POSIX platforms, it may also " @@ -1216,7 +1234,7 @@ msgstr "" "外。在大多數的 POSIX 平台上,如果嘗試操作開啟或遍歷一個當作目錄的非目錄檔案也" "會引發此例外。對應到 :c:data:`errno` :py:const:`~errno.ENOTDIR`。" -#: ../../builtins/exceptions.rst:815 +#: ../../builtins/exceptions.rst:828 msgid "" "Raised when trying to run an operation without the adequate access rights - " "for example filesystem permissions. Corresponds " @@ -1227,14 +1245,14 @@ msgstr "" "到 :c:data:`errno` :py:const:`~errno.EACCES`、:py:const:`~errno.EPERM` " "及 :py:const:`~errno.ENOTCAPABLE`。" -#: ../../builtins/exceptions.rst:820 +#: ../../builtins/exceptions.rst:833 msgid "" "WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped " "to :exc:`PermissionError`." msgstr "" "WASI 的 :py:const:`~errno.ENOTCAPABLE` 現在對應到 :exc:`PermissionError`。" -#: ../../builtins/exceptions.rst:826 +#: ../../builtins/exceptions.rst:839 msgid "" "Raised when a given process doesn't exist. Corresponds " "to :c:data:`errno` :py:const:`~errno.ESRCH`." @@ -1242,7 +1260,7 @@ msgstr "" "當給定的行程不存在時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.ESRCH`。" -#: ../../builtins/exceptions.rst:831 +#: ../../builtins/exceptions.rst:844 msgid "" "Raised when a system function timed out at the system level. Corresponds " "to :c:data:`errno` :py:const:`~errno.ETIMEDOUT`." @@ -1250,40 +1268,40 @@ msgstr "" "當系統函式在系統層級超時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.ETIMEDOUT`。" -#: ../../builtins/exceptions.rst:834 +#: ../../builtins/exceptions.rst:847 msgid "All the above :exc:`OSError` subclasses were added." msgstr "加入以上所有的 :exc:`OSError` 子類別。" -#: ../../builtins/exceptions.rst:840 +#: ../../builtins/exceptions.rst:853 msgid ":pep:`3151` - Reworking the OS and IO exception hierarchy" msgstr ":pep:`3151` — 改寫作業系統與 IO 例外階層" -#: ../../builtins/exceptions.rst:846 +#: ../../builtins/exceptions.rst:859 msgid "Warnings" msgstr "警告" -#: ../../builtins/exceptions.rst:848 +#: ../../builtins/exceptions.rst:861 msgid "" "The following exceptions are used as warning categories; see " "the :ref:`warning-categories` documentation for more details." msgstr "" "以下的例外是當作警告的種類使用;更多細節參考 :ref:`warning-categories` 文件。" -#: ../../builtins/exceptions.rst:853 +#: ../../builtins/exceptions.rst:866 msgid "Base class for warning categories." msgstr "警告種類的基礎類別。" -#: ../../builtins/exceptions.rst:858 +#: ../../builtins/exceptions.rst:871 msgid "Base class for warnings generated by user code." msgstr "使用者程式碼產生的警告的基礎類別。" -#: ../../builtins/exceptions.rst:863 +#: ../../builtins/exceptions.rst:876 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for other Python developers." msgstr "關於已棄用功能的警告的基礎類別,且當那些警告是針對其他 Python 開發者。" -#: ../../builtins/exceptions.rst:866 +#: ../../builtins/exceptions.rst:879 msgid "" "Ignored by the default warning filters, except in the ``__main__`` module " "(:pep:`565`). Enabling the :ref:`Python Development Mode ` shows " @@ -1292,17 +1310,17 @@ msgstr "" "會被預設的警告過濾器忽略,在 ``__main__`` 模組裡除外 (:pep:`565`)。啟" "用 :ref:`Python 開發模式 `\\ 會顯示此警告。" -#: ../../builtins/exceptions.rst:870 ../../builtins/exceptions.rst:886 +#: ../../builtins/exceptions.rst:883 ../../builtins/exceptions.rst:899 msgid "The deprecation policy is described in :pep:`387`." msgstr "棄用原則描述在 :pep:`387` 裡。" -#: ../../builtins/exceptions.rst:875 +#: ../../builtins/exceptions.rst:888 msgid "" "Base class for warnings about features which are obsolete and expected to be " "deprecated in the future, but are not deprecated at the moment." msgstr "關於過時且預期未來要被棄用,但目前尚未被棄用的功能的警告的基礎類別。" -#: ../../builtins/exceptions.rst:879 +#: ../../builtins/exceptions.rst:892 msgid "" "This class is rarely used as emitting a warning about a possible upcoming " "deprecation is unusual, and :exc:`DeprecationWarning` is preferred for " @@ -1311,8 +1329,8 @@ msgstr "" "因為發出關於可能即將被棄用的警告是不尋常的,此類別很少被使用,而對已經被棄用" "的情況會優先使用 :exc:`DeprecationWarning`。" -#: ../../builtins/exceptions.rst:883 ../../builtins/exceptions.rst:912 -#: ../../builtins/exceptions.rst:939 +#: ../../builtins/exceptions.rst:896 ../../builtins/exceptions.rst:925 +#: ../../builtins/exceptions.rst:952 msgid "" "Ignored by the default warning filters. Enabling the :ref:`Python " "Development Mode ` shows this warning." @@ -1320,11 +1338,11 @@ msgstr "" "會被預設的警告過濾器忽略。啟用 :ref:`Python 開發模式 `\\ 會顯示此警" "告。" -#: ../../builtins/exceptions.rst:891 +#: ../../builtins/exceptions.rst:904 msgid "Base class for warnings about dubious syntax." msgstr "關於可疑語法的警告的基礎類別。" -#: ../../builtins/exceptions.rst:893 +#: ../../builtins/exceptions.rst:906 msgid "" "This warning is typically emitted when compiling Python source code, and " "usually won't be reported when running already compiled code." @@ -1332,11 +1350,11 @@ msgstr "" "此警告通常在編譯 Python 原始碼時發出,且通常不會在執行已編譯的程式碼時被回" "報。" -#: ../../builtins/exceptions.rst:899 +#: ../../builtins/exceptions.rst:912 msgid "Base class for warnings about dubious runtime behavior." msgstr "關於可疑執行環境行為的警告的基礎類別。" -#: ../../builtins/exceptions.rst:904 +#: ../../builtins/exceptions.rst:917 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for end users of applications that are written in Python." @@ -1344,36 +1362,36 @@ msgstr "" "關於已棄用功能的警告的基礎類別,且當那些警告是針對以 Python 寫的應用程式的終" "端使用者。" -#: ../../builtins/exceptions.rst:910 +#: ../../builtins/exceptions.rst:923 msgid "Base class for warnings about probable mistakes in module imports." msgstr "關於在模組引入的可能錯誤的警告的基礎類別。" -#: ../../builtins/exceptions.rst:918 +#: ../../builtins/exceptions.rst:931 msgid "Base class for warnings related to Unicode." msgstr "Unicode 相關警告的基礎類別。" -#: ../../builtins/exceptions.rst:923 +#: ../../builtins/exceptions.rst:936 msgid "Base class for warnings related to encodings." msgstr "編碼相關警告的基礎類別。" -#: ../../builtins/exceptions.rst:925 +#: ../../builtins/exceptions.rst:938 msgid "See :ref:`io-encoding-warning` for details." msgstr "細節參考\\ :ref:`io-encoding-warning`。" -#: ../../builtins/exceptions.rst:932 +#: ../../builtins/exceptions.rst:945 msgid "" "Base class for warnings related to :class:`bytes` and :class:`bytearray`." msgstr ":class:`bytes` 及 :class:`bytearray` 相關警告的基礎類別。" -#: ../../builtins/exceptions.rst:937 +#: ../../builtins/exceptions.rst:950 msgid "Base class for warnings related to resource usage." msgstr "資源用法相關警告的基礎類別。" -#: ../../builtins/exceptions.rst:948 +#: ../../builtins/exceptions.rst:961 msgid "Exception groups" msgstr "例外群組" -#: ../../builtins/exceptions.rst:950 +#: ../../builtins/exceptions.rst:963 msgid "" "The following are used when it is necessary to raise multiple unrelated " "exceptions. They are part of the exception hierarchy so they can be handled " @@ -1385,7 +1403,7 @@ msgstr "" "所有其他例外一樣使用 :keyword:`except` 來處理。此外,它們會以包含的例外型別為" "基礎來比對其子群組而被 :keyword:`except*` 辨認出來。" -#: ../../builtins/exceptions.rst:959 +#: ../../builtins/exceptions.rst:972 msgid "" "Both of these exception types wrap the exceptions in the sequence ``excs``. " "The ``msg`` parameter must be a string. The difference between the two " @@ -1401,7 +1419,7 @@ msgstr "" "裝 :exc:`Exception` 的子類別。這個設計使得 ``except Exception`` 可以捕" "捉 :exc:`ExceptionGroup` 但不能捕捉 :exc:`BaseExceptionGroup`。" -#: ../../builtins/exceptions.rst:967 +#: ../../builtins/exceptions.rst:980 msgid "" "The :exc:`BaseExceptionGroup` constructor returns an :exc:`ExceptionGroup` " "rather than a :exc:`BaseExceptionGroup` if all contained exceptions " @@ -1416,30 +1434,30 @@ msgstr "" "是 :exc:`Exception` 的子類別,:exc:`ExceptionGroup` 建構函式會引" "發 :exc:`TypeError`。" -#: ../../builtins/exceptions.rst:974 +#: ../../builtins/exceptions.rst:987 msgid "" "Exception groups are :ref:`generic ` over the type of their " "contained exceptions." msgstr "" -#: ../../builtins/exceptions.rst:979 +#: ../../builtins/exceptions.rst:992 msgid "" "The ``excs`` parameter may be any sequence, but lists and tuples are " "specifically processed more efficiently here. For optimal performance, pass " "a tuple as ``excs``." msgstr "" -#: ../../builtins/exceptions.rst:985 +#: ../../builtins/exceptions.rst:998 msgid "The ``msg`` argument to the constructor. This is a read-only attribute." msgstr "建構函式的 ``msg`` 引數。這是一個唯讀的屬性。" -#: ../../builtins/exceptions.rst:989 +#: ../../builtins/exceptions.rst:1002 msgid "" "A tuple of the exceptions in the ``excs`` sequence given to the constructor. " "This is a read-only attribute." msgstr "指定給建構函式 ``excs`` 序列中的例外組成的元組。這是一個唯讀的屬性。" -#: ../../builtins/exceptions.rst:994 +#: ../../builtins/exceptions.rst:1007 msgid "" "Returns an exception group that contains only the exceptions from the " "current group that match *condition*, or ``None`` if the result is empty." @@ -1447,7 +1465,7 @@ msgstr "" "回傳只包含從現有群組比對到 *condition* 的例外的例外群組,或者當結果為空時回" "傳 ``None``。" -#: ../../builtins/exceptions.rst:997 +#: ../../builtins/exceptions.rst:1010 msgid "" "The condition can be an exception type or tuple of exception types, in which " "case each exception is checked for a match using the same check that is used " @@ -1460,7 +1478,7 @@ msgstr "" "物件(除了型別物件之外),其接受一個例外作為單一引數,而如果該例外應該在子群" "組中就回傳 true。" -#: ../../builtins/exceptions.rst:1003 +#: ../../builtins/exceptions.rst:1016 msgid "" "The nesting structure of the current exception is preserved in the result, " "as are the values of " @@ -1473,7 +1491,7 @@ msgstr "" "及 :attr:`~BaseException.__notes__` 欄位的值也一樣。空的巢狀群組會從結果裡排" "除。" -#: ../../builtins/exceptions.rst:1010 +#: ../../builtins/exceptions.rst:1023 msgid "" "The condition is checked for all exceptions in the nested exception group, " "including the top-level and any nested exception groups. If the condition is " @@ -1482,11 +1500,11 @@ msgstr "" "條件會對巢狀例外群組裡的所有例外做檢查,包括頂層及任何巢狀的例外群組。如果條" "件對這樣的例外群組為 true,它會被完整包含在結果裡。" -#: ../../builtins/exceptions.rst:1014 +#: ../../builtins/exceptions.rst:1027 msgid "``condition`` can be any callable which is not a type object." msgstr "``condition`` 可以是任何不是型別物件的可呼叫物件。" -#: ../../builtins/exceptions.rst:1019 +#: ../../builtins/exceptions.rst:1032 msgid "" "Like :meth:`subgroup`, but returns the pair ``(match, rest)`` where " "``match`` is ``subgroup(condition)`` and ``rest`` is the remaining non-" @@ -1495,13 +1513,13 @@ msgstr "" "像 :meth:`subgroup` 一樣,但回傳一對 ``(match, rest)``,其中 ``match`` 是 " "``subgroup(condition)`` 而 ``rest`` 是剩下沒有比對到的部分。" -#: ../../builtins/exceptions.rst:1025 +#: ../../builtins/exceptions.rst:1038 msgid "" "Returns an exception group with the same :attr:`message`, but which wraps " "the exceptions in ``excs``." msgstr "回傳有相同 :attr:`message` 但將例外包裝在 ``excs`` 的例外群組。" -#: ../../builtins/exceptions.rst:1028 +#: ../../builtins/exceptions.rst:1041 msgid "" "This method is used by :meth:`subgroup` and :meth:`split`, which are used in " "various contexts to break up an exception group. A subclass needs to " @@ -1512,7 +1530,7 @@ msgstr "" "組。子類別需要覆寫它來讓 :meth:`subgroup` 及 :meth:`split` 回傳子類別而不" "是 :exc:`ExceptionGroup` 的實例。" -#: ../../builtins/exceptions.rst:1034 +#: ../../builtins/exceptions.rst:1047 msgid "" ":meth:`subgroup` and :meth:`split` copy " "the :attr:`~BaseException.__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException.__context__` " @@ -1525,7 +1543,7 @@ msgstr "" "和 :attr:`~BaseException.__notes__` 欄位到 :meth:`derive` 所回傳的例外群組" "上,因此這些欄位不需要被 :meth:`derive` 更新。" -#: ../../builtins/exceptions.rst:1041 +#: ../../builtins/exceptions.rst:1054 msgid "" ">>> class MyGroup(ExceptionGroup):\n" "... def derive(self, excs):\n" @@ -1579,7 +1597,7 @@ msgstr "" ">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" "True" -#: ../../builtins/exceptions.rst:1067 +#: ../../builtins/exceptions.rst:1080 msgid "" "Note that :exc:`BaseExceptionGroup` defines :meth:`~object.__new__`, so " "subclasses that need a different constructor signature need to override that " @@ -1591,7 +1609,7 @@ msgstr "" "建構函式簽名的子類別需要覆寫它而不是 :meth:`~object.__init__`。例如下面定義了" "一個例外群組子類別接受 exit_code 並從中建構群組的訊息。: ::" -#: ../../builtins/exceptions.rst:1073 +#: ../../builtins/exceptions.rst:1086 msgid "" "class Errors(ExceptionGroup):\n" " def __new__(cls, errors, exit_code):\n" @@ -1611,7 +1629,7 @@ msgstr "" " def derive(self, excs):\n" " return Errors(excs, self.exit_code)" -#: ../../builtins/exceptions.rst:1082 +#: ../../builtins/exceptions.rst:1095 msgid "" "Like :exc:`ExceptionGroup`, any subclass of :exc:`BaseExceptionGroup` which " "is also a subclass of :exc:`Exception` can only wrap instances " @@ -1620,15 +1638,15 @@ msgstr "" "像 :exc:`ExceptionGroup` 一樣,任何 :exc:`BaseExceptionGroup` 的子類別且也" "是 :exc:`Exception` 的子類別只能包裝 :exc:`Exception` 的實例。" -#: ../../builtins/exceptions.rst:1090 +#: ../../builtins/exceptions.rst:1103 msgid "Exception hierarchy" msgstr "例外階層" -#: ../../builtins/exceptions.rst:1092 +#: ../../builtins/exceptions.rst:1105 msgid "The class hierarchy for built-in exceptions is:" msgstr "內建例外的類別階層如下:" -#: ../../builtins/exceptions.rst:1094 +#: ../../builtins/exceptions.rst:1107 msgid "" "BaseException\n" " ├── BaseExceptionGroup\n" @@ -1646,6 +1664,7 @@ msgid "" " ├── EOFError\n" " ├── ExceptionGroup [BaseExceptionGroup]\n" " ├── ImportError\n" +" │ └── ImportCycleError\n" " │ └── ModuleNotFoundError\n" " ├── LookupError\n" " │ ├── IndexError\n" @@ -1715,6 +1734,7 @@ msgstr "" " ├── EOFError\n" " ├── ExceptionGroup [BaseExceptionGroup]\n" " ├── ImportError\n" +" │ └── ImportCycleError\n" " │ └── ModuleNotFoundError\n" " ├── LookupError\n" " │ ├── IndexError\n" @@ -1809,10 +1829,10 @@ msgstr "__suppress_context__(例外屬性)" msgid "assert" msgstr "assert" -#: ../../builtins/exceptions.rst:355 +#: ../../builtins/exceptions.rst:361 msgid "module" msgstr "module(模組)" -#: ../../builtins/exceptions.rst:355 +#: ../../builtins/exceptions.rst:361 msgid "errno" msgstr "errno" diff --git a/builtins/functions.po b/builtins/functions.po index 3559ef7dff0..624306eba4f 100644 --- a/builtins/functions.po +++ b/builtins/functions.po @@ -11,7 +11,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-25 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-07-28 21:38+0800\n" "Last-Translator: Weilin Du <1372449351@qq.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,8 +21,8 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../../builtins/functions.rst:5 ../../builtins/functions.rst:11 -msgid "Built-in Functions" +#: ../../builtins/functions.rst:5 +msgid "Built-in functions" msgstr "內建函式" #: ../../builtins/functions.rst:7 @@ -32,6 +32,10 @@ msgid "" msgstr "" "Python 直譯器有內建多個可隨時使用的函式和型別。以下按照英文字母排序列出。" +#: ../../builtins/functions.rst:11 +msgid "Built-in Functions" +msgstr "內建函式" + #: ../../builtins/functions.rst:0 msgid "**A**" msgstr "**A**" @@ -160,6 +164,10 @@ msgstr ":func:`float`" msgid ":func:`format`" msgstr ":func:`format`" +#: ../../builtins/functions.rst:0 +msgid "|func-frozendict|_" +msgstr "|func-frozendict|_" + #: ../../builtins/functions.rst:0 msgid "|func-frozenset|_" msgstr "|func-frozenset|_" @@ -336,6 +344,10 @@ msgstr "|func-set|_" msgid ":func:`setattr`" msgstr ":func:`setattr`" +#: ../../builtins/functions.rst:0 +msgid ":func:`sentinel`" +msgstr ":func:`sentinel`" + #: ../../builtins/functions.rst:0 msgid ":func:`slice`" msgstr ":func:`slice`" @@ -396,7 +408,7 @@ msgstr "**_**" msgid ":func:`__import__`" msgstr ":func:`__import__`" -#: ../../builtins/functions.rst:59 +#: ../../builtins/functions.rst:61 msgid "" "Return the absolute value of a number. The argument may be an integer, a " "floating-point number, or an object implementing :meth:`~object.__abs__`. If " @@ -405,7 +417,7 @@ msgstr "" "回傳一個數的絕對值,引數可以是整數、浮點數或有實現 :meth:`~object.__abs__` 的" "物件。如果引數是一個複數,回傳它的純量(大小)。" -#: ../../builtins/functions.rst:67 +#: ../../builtins/functions.rst:69 msgid "" "Return an :term:`asynchronous iterator` for an :term:`asynchronous " "iterable`. Equivalent to calling ``x.__aiter__()``." @@ -413,11 +425,11 @@ msgstr "" "回傳 :term:`非同步疊代器 ` 做為 :term:`非同步可疊代物" "件 `。相當於呼叫 x.__aiter__()。" -#: ../../builtins/functions.rst:70 +#: ../../builtins/functions.rst:72 msgid "Note: Unlike :func:`iter`, :func:`aiter` has no 2-argument variant." msgstr "注意:與 :func:`iter` 不同,:func:`aiter` 沒有兩個引數的變體。" -#: ../../builtins/functions.rst:76 +#: ../../builtins/functions.rst:78 msgid "" "Return ``True`` if all elements of the *iterable* are true (or if the " "iterable is empty). Equivalent to::" @@ -425,7 +437,7 @@ msgstr "" "如果 *iterable* 的所有元素皆為真(或 iterable 為空)則回傳 ``True``。等價" "於: ::" -#: ../../builtins/functions.rst:79 +#: ../../builtins/functions.rst:81 msgid "" "def all(iterable):\n" " for element in iterable:\n" @@ -439,18 +451,18 @@ msgstr "" " return False\n" " return True" -#: ../../builtins/functions.rst:89 +#: ../../builtins/functions.rst:91 msgid "" "When awaited, return the next item from the given :term:`asynchronous " "iterator`, or *default* if given and the iterator is :term:`exhausted`." msgstr "" -#: ../../builtins/functions.rst:92 +#: ../../builtins/functions.rst:94 msgid "" "This is the async variant of the :func:`next` builtin, and behaves similarly." msgstr "這是內建函式 :func:`next` 的非同步版本,其行為類似於:" -#: ../../builtins/functions.rst:95 +#: ../../builtins/functions.rst:97 msgid "" "This calls the :meth:`~object.__anext__` method of *async_iterator*, " "returning an :term:`awaitable`. Awaiting this returns the next value of the " @@ -461,7 +473,7 @@ msgstr "" "傳 :term:`awaitable`。等待回傳疊代器的下一個值。如果指定 *default*,當疊代器" "結束時會回傳該值,否則會引發 :exc:`StopAsyncIteration` 。" -#: ../../builtins/functions.rst:104 +#: ../../builtins/functions.rst:106 msgid "" "Return ``True`` if any element of the *iterable* is true. If the iterable " "is empty, return ``False``. Equivalent to::" @@ -469,7 +481,7 @@ msgstr "" "如果 *iterable* 的任一元素為真,回傳 ``True``。如果 iterable 是空的,則回傳 " "``False``。等價於: ::" -#: ../../builtins/functions.rst:107 +#: ../../builtins/functions.rst:109 msgid "" "def any(iterable):\n" " for element in iterable:\n" @@ -483,7 +495,7 @@ msgstr "" " return True\n" " return False" -#: ../../builtins/functions.rst:116 +#: ../../builtins/functions.rst:118 msgid "" "As :func:`repr`, return a string containing a printable representation of an " "object, but escape the non-ASCII characters in the string returned " @@ -494,7 +506,7 @@ msgstr "" "非 ASCII 編碼的字元會被跳脫 (escape),像是 ``\\x``、``\\u`` 和 ``\\U``。這個" "函式生成的字串和 Python 2 的 :func:`repr` 回傳的結果相似。" -#: ../../builtins/functions.rst:124 +#: ../../builtins/functions.rst:126 msgid "" "Convert an integer number to a binary string prefixed with \"0b\". The " "result is a valid Python expression. If *integer* is not a " @@ -505,23 +517,23 @@ msgstr "" "算式。如果 *integer* 不是 Python 的 :class:`int` 物件,那它需要定" "義 :meth:`~object.__index__` method 回傳一個整數。舉例來說:" -#: ../../builtins/functions.rst:134 +#: ../../builtins/functions.rst:136 msgid "" "If the prefix \"0b\" is desired or not, you can use either of the following " "ways." msgstr "如果不一定需要 \"0b\" 前綴,還可以使用如下的方法。" -#: ../../builtins/functions.rst:141 +#: ../../builtins/functions.rst:143 msgid "" "See also :func:`enum.bin` to represent negative values as twos-complement." msgstr "也請參閱 :func:`enum.bin` 以二補數表示負數。" -#: ../../builtins/functions.rst:143 ../../builtins/functions.rst:966 -#: ../../builtins/functions.rst:1350 +#: ../../builtins/functions.rst:145 ../../builtins/functions.rst:1000 +#: ../../builtins/functions.rst:1384 msgid "See also :func:`format` for more information." msgstr "可參考 :func:`format` 取得更多資訊。" -#: ../../builtins/functions.rst:148 +#: ../../builtins/functions.rst:150 msgid "" "Return a Boolean value, i.e. one of ``True`` or ``False``. The argument is " "converted using the standard :ref:`truth testing procedure `. If the " @@ -536,11 +548,11 @@ msgstr "" "(參見 :ref:`typesnumeric`),其他 class 不能繼承自它。它只有 ``False`` 和 " "``True`` 兩個實例(參見 :ref:`typebool`)。" -#: ../../builtins/functions.rst:158 ../../builtins/functions.rst:831 +#: ../../builtins/functions.rst:160 ../../builtins/functions.rst:850 msgid "The parameter is now positional-only." msgstr "現在為僅限位置參數。" -#: ../../builtins/functions.rst:163 +#: ../../builtins/functions.rst:165 msgid "" "This function drops you into the debugger at the call site. Specifically, " "it calls :func:`sys.breakpointhook`, passing ``args`` and ``kws`` straight " @@ -560,7 +572,7 @@ msgstr "" "且 :func:`breakpoint` 將自動呼叫該函式,讓你進入所選擇的除錯器。如果無法存" "取 :func:`sys.breakpointhook` 這個函式,則此函式將引發 :exc:`RuntimeError`。" -#: ../../builtins/functions.rst:175 +#: ../../builtins/functions.rst:177 msgid "" "By default, the behavior of :func:`breakpoint` can be changed with " "the :envvar:`PYTHONBREAKPOINT` environment variable. " @@ -569,13 +581,13 @@ msgstr "" "預設情況下,:func:`breakpoint` 的行為可以透過 :envvar:`PYTHONBREAKPOINT` 環境" "變數來更改。有關使用詳情,請參考 :func:`sys.breakpointhook`。" -#: ../../builtins/functions.rst:179 +#: ../../builtins/functions.rst:181 msgid "" "Note that this is not guaranteed if :func:`sys.breakpointhook` has been " "replaced." msgstr "請注意,如果 :func:`sys.breakpointhook` 被替換了,則無法保證此功能。" -#: ../../builtins/functions.rst:182 +#: ../../builtins/functions.rst:184 msgid "" "Raises an :ref:`auditing event ` ``builtins.breakpoint`` with " "argument ``breakpointhook``." @@ -583,7 +595,7 @@ msgstr "" "引發一個附帶引數 ``breakpointhook`` 的\\ :ref:`稽核事件 ` " "``builtins.breakpoint``。" -#: ../../builtins/functions.rst:191 +#: ../../builtins/functions.rst:193 msgid "" "Return a new array of bytes. The :class:`bytearray` class is a mutable " "sequence of integers in the range 0 <= x < 256. It has most of the usual " @@ -595,13 +607,13 @@ msgstr "" "在 :ref:`typesseq-mutable` 中所述),同時也有 :class:`bytes` 型別大部分的 " "method,參見 :ref:`bytes-methods`。" -#: ../../builtins/functions.rst:196 +#: ../../builtins/functions.rst:198 msgid "" "The optional *source* parameter can be used to initialize the array in a few " "different ways:" msgstr "選擇性參數 *source* 可以被用來以不同的方式初始化陣列:" -#: ../../builtins/functions.rst:199 +#: ../../builtins/functions.rst:201 msgid "" "If it is a *string*, you must also give the *encoding* (and optionally, " "*errors*) parameters; :func:`bytearray` then converts the string to bytes " @@ -611,14 +623,14 @@ msgstr "" "*errors* );:func:`bytearray` 會使用 :meth:`str.encode` method 來將 string " "轉變成 bytes。" -#: ../../builtins/functions.rst:203 +#: ../../builtins/functions.rst:205 msgid "" "If it is an *integer*, the array will have that size and will be initialized " "with null bytes." msgstr "" "如果是一個 *integer*,陣列則會有該數值的長度,並以 null bytes 來當作初始值。" -#: ../../builtins/functions.rst:206 +#: ../../builtins/functions.rst:208 msgid "" "If it is an object conforming to the :ref:`buffer interface " "`, a read-only buffer of the object will be used to " @@ -627,7 +639,7 @@ msgstr "" "如果是一個符合 :ref:`buffer 介面 `\\ 的物件,該物件的唯讀 " "buffer 會被用來初始化 bytes 陣列。" -#: ../../builtins/functions.rst:209 +#: ../../builtins/functions.rst:211 msgid "" "If it is an *iterable*, it must be an iterable of integers in the range ``0 " "<= x < 256``, which are used as the initial contents of the array." @@ -635,15 +647,15 @@ msgstr "" "如果是一個 *iterable*,它的元素必須是範圍為 ``0 <= x < 256`` 的整數,並且會被" "用作陣列的初始值。" -#: ../../builtins/functions.rst:212 +#: ../../builtins/functions.rst:214 msgid "Without an argument, an array of size 0 is created." msgstr "如果沒有引數,則建立長度為 0 的陣列。" -#: ../../builtins/functions.rst:214 +#: ../../builtins/functions.rst:216 msgid "See also :ref:`binaryseq` and :ref:`typebytearray`." msgstr "可參考 :ref:`binaryseq` 和 :ref:`typebytearray`。" -#: ../../builtins/functions.rst:222 +#: ../../builtins/functions.rst:224 msgid "" "Return a new \"bytes\" object which is an immutable sequence of integers in " "the range ``0 <= x < 256``. :class:`bytes` is an immutable version " @@ -654,20 +666,20 @@ msgstr "" "變序列。:class:`bytes` 是 :class:`bytearray` 的不可變版本 — 它的同樣具備不改" "變物件的 method,也有相同的索引和切片操作。" -#: ../../builtins/functions.rst:227 +#: ../../builtins/functions.rst:229 msgid "" "Accordingly, constructor arguments are interpreted as for :func:`bytearray`." msgstr "因此,建構函式的引數和 :func:`bytearray` 相同。" -#: ../../builtins/functions.rst:229 +#: ../../builtins/functions.rst:231 msgid "Bytes objects can also be created with literals, see :ref:`strings`." msgstr "Bytes 物件還可以用文字建立,參見 :ref:`strings`。" -#: ../../builtins/functions.rst:231 +#: ../../builtins/functions.rst:233 msgid "See also :ref:`binaryseq`, :ref:`typebytes`, and :ref:`bytes-methods`." msgstr "可參考 :ref:`binaryseq`、:ref:`typebytes` 和 :ref:`bytes-methods`。" -#: ../../builtins/functions.rst:236 +#: ../../builtins/functions.rst:238 msgid "" "Return :const:`True` if the *object* argument appears " "callable, :const:`False` if not. If this returns ``True``, it is still " @@ -681,13 +693,13 @@ msgstr "" "會失敗。注意 class 是可呼叫的(呼叫 class 會回傳一個新的實例);如果實例的 " "class 有定義 :meth:`~object.__call__` method,則它是可呼叫的。" -#: ../../builtins/functions.rst:242 +#: ../../builtins/functions.rst:244 msgid "" "This function was first removed in Python 3.0 and then brought back in " "Python 3.2." msgstr "這個函式一開始在 Python 3.0 被移除,但在 Python 3.2 又被重新加入。" -#: ../../builtins/functions.rst:249 +#: ../../builtins/functions.rst:251 msgid "" "Return the string representing a character with the specified Unicode code " "point. For example, ``chr(97)`` returns the string ``'a'``, while " @@ -696,7 +708,7 @@ msgstr "" "回傳代表有特定 Unicode 編碼位置字元的字串。例如,``chr(97)`` 回傳字串 " "``'a'``,而 ``chr(8364)`` 回傳字串 ``'€'``。這是 :func:`ord` 的逆函式。" -#: ../../builtins/functions.rst:253 +#: ../../builtins/functions.rst:255 msgid "" "The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in " "base 16). :exc:`ValueError` will be raised if it is outside that range." @@ -704,11 +716,11 @@ msgstr "" "引數的有效範圍是 0 到 1,114,111(16 進制表示為 0x10FFFF)。如果它超過這個範" "圍,會引發 :exc:`ValueError`。" -#: ../../builtins/functions.rst:259 +#: ../../builtins/functions.rst:261 msgid "Transform a method into a class method." msgstr "把一個 method 封裝成 class method(類別方法)。" -#: ../../builtins/functions.rst:261 +#: ../../builtins/functions.rst:263 msgid "" "A class method receives the class as an implicit first argument, just like " "an instance method receives the instance. To declare a class method, use " @@ -717,7 +729,7 @@ msgstr "" "一個 class method 把自己的 class 作為第一個引數,就像一個實例 method 把實例自" "己作為第一個引數。請用以下慣例來宣告 class method: ::" -#: ../../builtins/functions.rst:265 +#: ../../builtins/functions.rst:267 msgid "" "class C:\n" " @classmethod\n" @@ -727,7 +739,7 @@ msgstr "" " @classmethod\n" " def f(cls, arg1, arg2): ..." -#: ../../builtins/functions.rst:269 +#: ../../builtins/functions.rst:271 msgid "" "The ``@classmethod`` form is a function :term:`decorator` -- " "see :ref:`function` for details." @@ -735,7 +747,7 @@ msgstr "" "``@classmethod`` 語法是一個函式 :term:`decorator` — 參見 :ref:`function` 中關" "於函式定義的詳細介紹。" -#: ../../builtins/functions.rst:272 +#: ../../builtins/functions.rst:274 msgid "" "A class method can be called either on the class (such as ``C.f()``) or on " "an instance (such as ``C().f()``). The instance is ignored except for its " @@ -746,7 +758,7 @@ msgstr "" "叫。實例除了它的 class 資訊,其他都會被忽略。如果一個 class method 在 " "subclass 上呼叫,subclass 會作為第一個引數傳入。" -#: ../../builtins/functions.rst:277 +#: ../../builtins/functions.rst:279 msgid "" "Class methods are different than C++ or Java static methods. If you want " "those, see :func:`staticmethod` in this section. For more information on " @@ -756,7 +768,7 @@ msgstr "" "method,請看本節的 :func:`staticmethod`。關於 class method 的更多資訊,請參考" "\\ :ref:`types`。" -#: ../../builtins/functions.rst:281 +#: ../../builtins/functions.rst:283 msgid "" "Class methods can now wrap other :term:`descriptors ` such " "as :func:`property`." @@ -764,7 +776,7 @@ msgstr "" "Class methods 現在可以包裝其他\\ :term:`描述器 `,例" "如 :func:`property`" -#: ../../builtins/functions.rst:285 +#: ../../builtins/functions.rst:287 msgid "" "Class methods now inherit the method attributes " "(:attr:`~function.__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__` " @@ -775,7 +787,7 @@ msgstr "" "(:attr:`~function.__module__`、:attr:`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function.__doc__` " "和 :attr:`~function.__annotations__`),並擁有一個新的 ``__wrapped__`` 屬性。" -#: ../../builtins/functions.rst:292 +#: ../../builtins/functions.rst:294 msgid "" "Class methods can no longer wrap other :term:`descriptors ` such " "as :func:`property`." @@ -783,7 +795,7 @@ msgstr "" "Class methods 不能再包裝其他的\\ :term:`描述器 `,例" "如 :func:`property`。" -#: ../../builtins/functions.rst:299 +#: ../../builtins/functions.rst:303 msgid "" "Compile the *source* into a code or AST object. Code objects can be " "executed by :func:`exec` or :func:`eval`. *source* can either be a normal " @@ -794,7 +806,7 @@ msgstr "" "或 :func:`eval` 執行。*source* 可以是一般的字串、bytes 字串、或者 AST 物件。" "參見 :mod:`ast` module(模組)的說明文件瞭解如何使用 AST 物件。" -#: ../../builtins/functions.rst:304 +#: ../../builtins/functions.rst:308 msgid "" "The *filename* argument should give the file from which the code was read; " "pass some recognizable value if it wasn't read from a file (``''`` " @@ -803,7 +815,7 @@ msgstr "" "*filename* 引數必須是程式碼的檔名;如果程式碼不是從檔案中讀取,可以傳入一些可" "辨識的值(經常會使用 ``''`` 來替代)。" -#: ../../builtins/functions.rst:308 +#: ../../builtins/functions.rst:312 msgid "" "The *mode* argument specifies what kind of code must be compiled; it can be " "``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if " @@ -816,7 +828,7 @@ msgstr "" "式,可以是 ``'single'``\\ (在最後一種情況下,如果運算式執行結果不是 " "``None`` 則會被印出來)。" -#: ../../builtins/functions.rst:314 +#: ../../builtins/functions.rst:318 msgid "" "The optional arguments *flags* and *dont_inherit* control " "which :ref:`compiler options ` should be activated and " @@ -837,7 +849,7 @@ msgstr "" "數,則使用 *flags* 引數 -- 周圍程式碼中的旗標(未來功能和編譯器選項)將被忽" "略。" -#: ../../builtins/functions.rst:325 +#: ../../builtins/functions.rst:329 msgid "" "Compiler options and future statements are specified by bits which can be " "bitwise ORed together to specify multiple options. The bitfield required to " @@ -854,7 +866,7 @@ msgstr "" "`\\ 可以在 :mod:`ast` module 中搜尋有 ``PyCF_`` 前綴的名" "稱。" -#: ../../builtins/functions.rst:333 +#: ../../builtins/functions.rst:337 msgid "" "The argument *optimize* specifies the optimization level of the compiler; " "the default value of ``-1`` selects the optimization level of the " @@ -867,7 +879,13 @@ msgstr "" "``__debug__`` 為真值)、``1``\\ (assert 被刪除,``__debug__`` 為假值)或 " "``2``\\ (說明字串 (docstring) 也被刪除)。" -#: ../../builtins/functions.rst:339 +#: ../../builtins/functions.rst:343 +msgid "" +"The optional argument *module* specifies the module name. It is needed to " +"unambiguous :ref:`filter ` syntax warnings by module name." +msgstr "" + +#: ../../builtins/functions.rst:347 msgid "" "This function raises :exc:`SyntaxError` if the compiled source is invalid, " "including a *source* containing a null character or that cannot be " @@ -878,13 +896,13 @@ msgid "" "and :exc:`OverflowError` if *source* is too large." msgstr "" -#: ../../builtins/functions.rst:348 +#: ../../builtins/functions.rst:356 msgid "" "If you want to parse Python code into its AST representation, " "see :func:`ast.parse`." msgstr "如果你想解析 Python 程式碼為 AST 運算式,請參閱 :func:`ast.parse`。" -#: ../../builtins/functions.rst:351 ../../builtins/functions.rst:353 +#: ../../builtins/functions.rst:359 ../../builtins/functions.rst:361 msgid "" "Raises an :ref:`auditing event ` ``compile`` with arguments " "``source`` and ``filename``. This event may also be raised by implicit " @@ -893,7 +911,7 @@ msgstr "" "引發一個附帶引數 ``source``、``filename`` 的\\ :ref:`稽核事件 ` " "``compile``。此事件也可能由隱式編譯 (implicit compilation) 所引發。" -#: ../../builtins/functions.rst:359 +#: ../../builtins/functions.rst:367 msgid "" "When compiling a string with multi-line code in ``'single'`` or ``'eval'`` " "mode, input must be terminated by at least one newline character. This is " @@ -903,7 +921,7 @@ msgstr "" "在 ``'single'`` 或 ``'eval'`` 模式編譯多行程式碼時,輸入必須以至少一個換行符" "結尾。這使 :mod:`code` module 更容易檢測陳述式的完整性。" -#: ../../builtins/functions.rst:366 +#: ../../builtins/functions.rst:374 msgid "" "It is possible to crash the Python interpreter with a sufficiently large/" "complex string when compiling to an AST object due to stack depth " @@ -912,7 +930,7 @@ msgstr "" "如果編譯足夠大或者足夠複雜的字串成 AST 物件時,Python 直譯器會因為 Python " "AST 編譯器的 stack 深度限制而崩潰。" -#: ../../builtins/functions.rst:370 +#: ../../builtins/functions.rst:378 msgid "" "Allowed use of Windows and Mac newlines. Also, input in ``'exec'`` mode " "does not have to end in a newline anymore. Added the *optimize* parameter." @@ -920,13 +938,13 @@ msgstr "" "允許使用 Windows 和 Mac 的換行符號。此外,在 ``'exec'`` 模式不需要以換行符號" "結尾。增加了 *optimize* 參數。" -#: ../../builtins/functions.rst:374 +#: ../../builtins/functions.rst:382 msgid "" "Previously, :exc:`TypeError` was raised when null bytes were encountered in " "*source*." msgstr "在之前的版本,*source* 中包含 null bytes 會引發 :exc:`TypeError`。" -#: ../../builtins/functions.rst:378 +#: ../../builtins/functions.rst:386 msgid "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable " "support for top-level ``await``, ``async for``, and ``async with``." @@ -934,24 +952,28 @@ msgstr "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` 現在可以傳遞旗標以啟用對頂層 ``await``、" "``async for`` 和 ``async with`` 的支援。" -#: ../../builtins/functions.rst:382 +#: ../../builtins/functions.rst:390 msgid "" ":exc:`SyntaxError` is raised instead of :exc:`ValueError` when null bytes " "are encountered in *source*." msgstr "" -#: ../../builtins/functions.rst:391 +#: ../../builtins/functions.rst:394 +msgid "Added the *module* parameter." +msgstr "新增 *module* 參數。" + +#: ../../builtins/functions.rst:402 msgid "" "Convert a single string or number to a complex number, or create a complex " "number from real and imaginary parts." msgstr "將單一字串或數字轉換為複數,或從實部和虛部建立複數。" -#: ../../builtins/functions.rst:394 ../../builtins/functions.rst:774 -#: ../../builtins/functions.rst:1022 +#: ../../builtins/functions.rst:405 ../../builtins/functions.rst:793 +#: ../../builtins/functions.rst:1056 msgid "Examples:" msgstr "例如: ::" -#: ../../builtins/functions.rst:396 +#: ../../builtins/functions.rst:407 msgid "" ">>> complex('+1.23')\n" "(1.23+0j)\n" @@ -987,7 +1009,7 @@ msgstr "" ">>> complex(-1.23, 4.5)\n" "(-1.23+4.5j)" -#: ../../builtins/functions.rst:415 +#: ../../builtins/functions.rst:426 msgid "" "If the argument is a string, it must contain either a real part (in the same " "format as for :func:`float`) or an imaginary part (in the same format but " @@ -1010,7 +1032,7 @@ msgstr "" "文法中的 :token:`~float:complexvalue` 產生規則,在去除括號和前後空白字元之" "後:" -#: ../../builtins/functions.rst:434 +#: ../../builtins/functions.rst:445 msgid "" "If the argument is a number, the constructor serves as a numeric conversion " "like :class:`int` and :class:`float`. For a general Python object ``x``, " @@ -1025,7 +1047,7 @@ msgstr "" "back) 到 :meth:`~object.__float__`。如果 :meth:`!__float__` 未定義,則會再回" "退到 :meth:`~object.__index__`。" -#: ../../builtins/functions.rst:443 +#: ../../builtins/functions.rst:454 msgid "" "If two arguments are provided or keyword arguments are used, each argument " "may be any numeric type (including complex). If both arguments are real " @@ -1041,26 +1063,26 @@ msgstr "" "量 ``real.imag+imag.real`` 的複數。如果其中一個引數是實數,則在上述運算式中只" "使用其實數分量。" -#: ../../builtins/functions.rst:453 +#: ../../builtins/functions.rst:464 msgid "" "See also :meth:`complex.from_number` which only accepts a single numeric " "argument." msgstr "也請參閱 :meth:`complex.from_number`,它只接受單一數值引數。" -#: ../../builtins/functions.rst:455 +#: ../../builtins/functions.rst:466 msgid "If all arguments are omitted, returns ``0j``." msgstr "如果省略所有引數,則回傳 ``0j``。" -#: ../../builtins/functions.rst:457 +#: ../../builtins/functions.rst:468 msgid "The complex type is described in :ref:`typesnumeric`." msgstr "複數型別在 :ref:`typesnumeric` 中有相關描述。" -#: ../../builtins/functions.rst:459 ../../builtins/functions.rst:828 -#: ../../builtins/functions.rst:1070 +#: ../../builtins/functions.rst:470 ../../builtins/functions.rst:847 +#: ../../builtins/functions.rst:1104 msgid "Grouping digits with underscores as in code literals is allowed." msgstr "可以使用底線將程式碼文字中的數字進行分組。" -#: ../../builtins/functions.rst:462 +#: ../../builtins/functions.rst:473 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` " "and :meth:`~object.__float__` are not defined." @@ -1068,14 +1090,14 @@ msgstr "" "如果 :meth:`~object.__complex__` 和 :meth:`~object.__float__` 未定義,則會回" "退到 :meth:`~object.__index__`。" -#: ../../builtins/functions.rst:466 +#: ../../builtins/functions.rst:477 msgid "" "Passing a complex number as the *real* or *imag* argument is now deprecated; " "it should only be passed as a single positional argument." msgstr "" "傳遞複數作為 *real* 或 *imag* 引數現已被棄用;它只應作為單一位置引數傳遞。" -#: ../../builtins/functions.rst:473 +#: ../../builtins/functions.rst:484 msgid "" "This is a relative of :func:`setattr`. The arguments are an object and a " "string. The string must be the name of one of the object's attributes. The " @@ -1088,7 +1110,7 @@ msgstr "" "'foobar')`` 等價於 ``del x.foobar``。*name* 不必是個 Python 識別符 " "(identifier)(請見 :func:`setattr`)。" -#: ../../builtins/functions.rst:486 +#: ../../builtins/functions.rst:497 msgid "" "Create a new dictionary. The :class:`dict` object is the dictionary class. " "See also :ref:`typesmapping` for documentation about this class." @@ -1096,15 +1118,16 @@ msgstr "" "建立一個新的字典。:class:`dict` 物件是字典類別。關於此類別的說明文件,亦請參" "閱 :ref:`typesmapping`。" -#: ../../builtins/functions.rst:489 +#: ../../builtins/functions.rst:500 msgid "" -"For other containers see the built-in :class:`list`, :class:`set`, " -"and :class:`tuple` classes, as well as the :mod:`collections` module." +"For other containers see the built-in :class:`frozendict`, :class:`list`, :" +"class:`set`, and :class:`tuple` classes, as well as the :mod:`collections` " +"module." msgstr "" -"其他容器型別,請參見內建的 :class:`list`、:class:`set` 和 :class:`tuple` " -"class,以及 :mod:`collections` module。" +"關於其他容器,請參閱內建的 :class:`frozendict`、:class:`list`、:class:`set` " +"和 :class:`tuple` 類別,以及 :mod:`collections` 模組。" -#: ../../builtins/functions.rst:496 +#: ../../builtins/functions.rst:507 msgid "" "Without arguments, return the list of names in the current local scope. " "With an argument, attempt to return a list of valid attributes for that " @@ -1113,7 +1136,7 @@ msgstr "" "如果沒有引數,則回傳目前區域作用域 (local scope) 中的名稱列表。如果有引數,它" "會嘗試回傳該物件的有效屬性列表。" -#: ../../builtins/functions.rst:499 +#: ../../builtins/functions.rst:510 msgid "" "If the object has a method named :meth:`~object.__dir__`, this method will " "be called and must return the list of attributes. This allows objects that " @@ -1126,7 +1149,7 @@ msgstr "" "或 :func:`~object.__getattribute__` 函式的物件能夠自訂 :func:`dir` 來報告它們" "的屬性。" -#: ../../builtins/functions.rst:506 +#: ../../builtins/functions.rst:517 msgid "" "If the object does not provide :meth:`~object.__dir__`, the function tries " "its best to gather information from the object's :attr:`~object.__dict__` " @@ -1138,7 +1161,7 @@ msgstr "" "的 :attr:`~object.__dict__` 屬性和型別物件收集資訊。結果列表並不總是完整的," "如果物件有自訂 :func:`~object.__getattr__`,那結果可能不準確。" -#: ../../builtins/functions.rst:512 +#: ../../builtins/functions.rst:523 msgid "" "The default :func:`dir` mechanism behaves differently with different types " "of objects, as it attempts to produce the most relevant, rather than " @@ -1147,13 +1170,13 @@ msgstr "" "預設的 :func:`dir` 機制對不同型別的物件有不同行為,它會試圖回傳最相關而非最完" "整的資訊:" -#: ../../builtins/functions.rst:516 +#: ../../builtins/functions.rst:527 msgid "" "If the object is a module object, the list contains the names of the " "module's attributes." msgstr "如果物件是 module 物件,則列表包含 module 的屬性名稱。" -#: ../../builtins/functions.rst:519 +#: ../../builtins/functions.rst:530 msgid "" "If the object is a type or class object, the list contains the names of its " "attributes, and recursively of the attributes of its bases." @@ -1161,7 +1184,7 @@ msgstr "" "如果物件是型別或 class 物件,則列表包含它們的屬性名稱,並且遞迴查詢其基礎的所" "有屬性。" -#: ../../builtins/functions.rst:522 +#: ../../builtins/functions.rst:533 msgid "" "Otherwise, the list contains the object's attributes' names, the names of " "its class's attributes, and recursively of the attributes of its class's " @@ -1170,11 +1193,11 @@ msgstr "" "否則,包含物件的屬性名稱列表、它的 class 屬性名稱,並且遞迴查詢它的 class 的" "所有基礎 class 的屬性。" -#: ../../builtins/functions.rst:526 +#: ../../builtins/functions.rst:537 msgid "The resulting list is sorted alphabetically. For example:" msgstr "回傳的列表按字母表排序,例如:" -#: ../../builtins/functions.rst:546 +#: ../../builtins/functions.rst:557 msgid "" "Because :func:`dir` is supplied primarily as a convenience for use at an " "interactive prompt, it tries to supply an interesting set of names more than " @@ -1187,7 +1210,7 @@ msgstr "" "版本之間改變。例如,當引數是一個 class 時,metaclass 的屬性不包含在結果列表" "中。" -#: ../../builtins/functions.rst:556 +#: ../../builtins/functions.rst:567 msgid "" "Take two (non-complex) numbers as arguments and return a pair of numbers " "consisting of their quotient and remainder when using integer division. " @@ -1205,7 +1228,7 @@ msgstr "" "*a* 基本相等,如果 ``a % b`` 非零,則它的符號和 *b* 一樣,且 ``0 <= abs(a % " "b) < abs(b)``。" -#: ../../builtins/functions.rst:568 +#: ../../builtins/functions.rst:579 msgid "" "Return an enumerate object. *iterable* must be a sequence, " "an :term:`iterator`, or some other object which supports iteration. " @@ -1218,11 +1241,11 @@ msgstr "" "的 :meth:`~iterator.__next__` method 回傳一個 tuple(元組),裡面包含一個計數" "值(從 *start* 開始,預設為 0)和透過疊代 *iterable* 獲得的值。" -#: ../../builtins/functions.rst:580 +#: ../../builtins/functions.rst:591 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../builtins/functions.rst:582 +#: ../../builtins/functions.rst:593 msgid "" "def enumerate(iterable, start=0):\n" " n = start\n" @@ -1240,15 +1263,15 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../builtins/functions.rst:592 +#: ../../builtins/functions.rst:603 msgid "A Python expression." msgstr "一個 Python 運算式。" -#: ../../builtins/functions.rst:596 +#: ../../builtins/functions.rst:607 msgid "The global namespace (default: ``None``)." msgstr "全域命名空間(預設值:``None``)。" -#: ../../builtins/functions.rst:600 +#: ../../builtins/functions.rst:611 msgid "The local namespace (default: ``None``)." msgstr "區域命名空間(預設:``None``)。" @@ -1256,7 +1279,7 @@ msgstr "區域命名空間(預設:``None``)。" msgid "Returns" msgstr "回傳值" -#: ../../builtins/functions.rst:604 +#: ../../builtins/functions.rst:615 msgid "The result of the evaluated expression." msgstr "被求值的運算式之結果。" @@ -1264,18 +1287,18 @@ msgstr "被求值的運算式之結果。" msgid "raises" msgstr "引發" -#: ../../builtins/functions.rst:605 +#: ../../builtins/functions.rst:616 msgid "Syntax errors are reported as exceptions." msgstr "語法錯誤會報告為例外。" -#: ../../builtins/functions.rst:609 ../../builtins/functions.rst:675 +#: ../../builtins/functions.rst:620 ../../builtins/functions.rst:690 msgid "" "This function executes arbitrary code. Calling it with untrusted user-" "supplied input will lead to security vulnerabilities." msgstr "" "此函式會執行任意程式碼。以不受信任的使用者提供的輸入來呼叫它將導致安全漏洞。" -#: ../../builtins/functions.rst:612 +#: ../../builtins/functions.rst:623 msgid "" "The *source* argument is parsed and evaluated as a Python expression " "(technically speaking, an :ref:`expression list `) using the " @@ -1294,11 +1317,11 @@ msgid "" "a :keyword:`nonlocal` statement)." msgstr "" -#: ../../builtins/functions.rst:630 +#: ../../builtins/functions.rst:641 msgid "Example:" msgstr "範例:" -#: ../../builtins/functions.rst:639 +#: ../../builtins/functions.rst:650 msgid "" "This function can also be used to execute arbitrary code objects (such as " "those created by :func:`compile`). In this case, pass a code object instead " @@ -1309,7 +1332,7 @@ msgstr "" "情況下,傳入的引數是程式碼物件而不是字串。如果編譯該物件時的 *mode* 引數是 " "``'exec'``,那麼 :func:`eval` 回傳值為 ``None``。" -#: ../../builtins/functions.rst:644 +#: ../../builtins/functions.rst:655 msgid "" "Hints: dynamic execution of statements is supported by the :func:`exec` " "function. The :func:`globals` and :func:`locals` functions return the " @@ -1320,13 +1343,13 @@ msgstr "" "函式分別回傳目前的全域性和局部性 dictionary,它們對於將引數傳遞" "給 :func:`eval` 或 :func:`exec` 可能會方便許多。" -#: ../../builtins/functions.rst:649 +#: ../../builtins/functions.rst:660 msgid "" "If the given source is a string, then leading and trailing spaces and tabs " "are stripped." msgstr "如果給定來源是一個字串,那麼其前後的空格和定位字元會被移除。" -#: ../../builtins/functions.rst:652 +#: ../../builtins/functions.rst:663 msgid "" "See :func:`ast.literal_eval` for a function to evaluate strings with " "expressions containing only literals." @@ -1334,8 +1357,8 @@ msgstr "" "另外可以參閱 :func:`ast.literal_eval`,該函式可用來執行僅包含文字的運算式字" "串。" -#: ../../builtins/functions.rst:655 ../../builtins/functions.rst:657 -#: ../../builtins/functions.rst:718 ../../builtins/functions.rst:720 +#: ../../builtins/functions.rst:666 ../../builtins/functions.rst:668 +#: ../../builtins/functions.rst:733 ../../builtins/functions.rst:735 msgid "" "Raises an :ref:`auditing event ` ``exec`` with the code object as " "the argument. Code compilation events may also be raised." @@ -1343,17 +1366,21 @@ msgstr "" "引發一個附帶程式碼物件為引數的\\ :ref:`稽核事件 ` ``exec``。也可能" "會引發程式碼編譯事件。" -#: ../../builtins/functions.rst:662 ../../builtins/functions.rst:740 +#: ../../builtins/functions.rst:673 ../../builtins/functions.rst:755 msgid "The *globals* and *locals* arguments can now be passed as keywords." msgstr "*globals* 和 *locals* 引數現在可以作為關鍵字傳遞。" -#: ../../builtins/functions.rst:666 ../../builtins/functions.rst:744 +#: ../../builtins/functions.rst:677 ../../builtins/functions.rst:759 msgid "" "The semantics of the default *locals* namespace have been adjusted as " "described for the :func:`locals` builtin." msgstr "如 :func:`locals` 內建物件所述,已調整預設 *locals* 命名空間的語意。" -#: ../../builtins/functions.rst:678 +#: ../../builtins/functions.rst:682 ../../builtins/functions.rst:764 +msgid "*globals* can now be a :class:`frozendict`." +msgstr "" + +#: ../../builtins/functions.rst:693 msgid "" "This function supports dynamic execution of Python code. *source* must be " "either a string or a code object. If it is a string, the string is parsed " @@ -1373,7 +1400,7 @@ msgstr "" "中,:keyword:`nonlocal`、:keyword:`yield` 和 :keyword:`return` 陳述式也不能在" "函式之外使用。該函式回傳值是 ``None``。" -#: ../../builtins/functions.rst:689 +#: ../../builtins/functions.rst:704 msgid "" "In all cases, if the optional parts are omitted, the code is executed in the " "current scope. If only *globals* is provided, it must be a dictionary (and " @@ -1389,7 +1416,7 @@ msgstr "" "用作全域和區域變數。如果提供了 *locals*,則它可以是任何對映物件。請記住在 " "module 層級中全域和區域變數是相同的 dictionary。" -#: ../../builtins/functions.rst:699 +#: ../../builtins/functions.rst:714 msgid "" "When ``exec`` gets two separate objects as *globals* and *locals*, the code " "will be executed as if it were embedded in a class definition. This means " @@ -1401,7 +1428,7 @@ msgstr "" "像它被嵌入在類別定義中一樣。這表示在執行的程式碼中定義的函式和類別將無法存取" "在頂層指定的變數(因為在類別定義中,「頂層」變數被視為類別變數)。" -#: ../../builtins/functions.rst:705 +#: ../../builtins/functions.rst:720 msgid "" "If the *globals* dictionary does not contain a value for the key " "``__builtins__``, a reference to the dictionary of the built-in " @@ -1415,7 +1442,7 @@ msgstr "" "制或更改可用的名稱,但這\\ **不是**\\ 一種安全機制:被執行的程式碼仍然可以存" "取所有內建名稱。" -#: ../../builtins/functions.rst:712 +#: ../../builtins/functions.rst:727 msgid "" "The *closure* argument specifies a closure--a tuple of cellvars. It's only " "valid when the *object* is a code object containing :term:`free (closure) " @@ -1427,7 +1454,7 @@ msgstr "" "variables) ` 的程式碼物件時,它才有效。Tuple 的長度必須與程" "式碼物件的 :attr:`~codeobject.co_freevars` 屬性完全匹配。" -#: ../../builtins/functions.rst:725 +#: ../../builtins/functions.rst:740 msgid "" "The built-in functions :func:`globals` and :func:`locals` return the current " "global and local namespace, respectively, which may be useful to pass around " @@ -1436,7 +1463,7 @@ msgstr "" "內建 :func:`globals` 和 :func:`locals` 函式各自回傳目前的全域和區域命名空間," "因此可以將它們傳遞給 :func:`exec` 的第二個和第三個引數以供後續使用。" -#: ../../builtins/functions.rst:731 +#: ../../builtins/functions.rst:746 msgid "" "The default *locals* act as described for function :func:`locals` below. " "Pass an explicit *locals* dictionary if you need to see effects of the code " @@ -1446,11 +1473,11 @@ msgstr "" "在 :func:`exec` 函式回傳時知道程式碼對 *locals* 的變動,請明確地傳遞 " "*locals* dictionary 。" -#: ../../builtins/functions.rst:735 +#: ../../builtins/functions.rst:750 msgid "Added the *closure* parameter." msgstr "增加了 *closure* 參數。" -#: ../../builtins/functions.rst:750 +#: ../../builtins/functions.rst:769 msgid "" "Construct an iterator from those elements of *iterable* for which *function* " "is true. *iterable* may be either a sequence, a container which supports " @@ -1462,7 +1489,7 @@ msgstr "" "*function* 是 ``None``,則會假設它是一個識別性函式,即 *iterable* 中所有假值" "元素會被移除。" -#: ../../builtins/functions.rst:756 +#: ../../builtins/functions.rst:775 msgid "" "Note that ``filter(function, iterable)`` is equivalent to the generator " "expression ``(item for item in iterable if function(item))`` if function is " @@ -1473,7 +1500,7 @@ msgstr "" "是 ``None`` 的時候為 ``(item for item in iterable if function(item))``;" "function 是 ``None`` 的時候為 ``(item for item in iterable if item)``。" -#: ../../builtins/functions.rst:761 +#: ../../builtins/functions.rst:780 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." @@ -1481,11 +1508,11 @@ msgstr "" "請參閱 :func:`itertools.filterfalse`,只有 *function* 為 false 時才選取 " "*iterable* 中元素的互補函式。" -#: ../../builtins/functions.rst:772 +#: ../../builtins/functions.rst:791 msgid "Return a floating-point number constructed from a number or a string." msgstr "回傳從數字或字串生成的浮點數。" -#: ../../builtins/functions.rst:776 +#: ../../builtins/functions.rst:795 msgid "" ">>> float('+1.23')\n" "1.23\n" @@ -1509,7 +1536,7 @@ msgstr "" ">>> float('-Infinity')\n" "-inf" -#: ../../builtins/functions.rst:789 +#: ../../builtins/functions.rst:808 msgid "" "If the argument is a string, it should contain a decimal number, optionally " "preceded by a sign, and optionally embedded in whitespace. The optional " @@ -1524,7 +1551,7 @@ msgstr "" "數也可以是 NaN(非數字)或正負無窮大的字串。確切地說,除去首尾的空格後,輸入" "必須遵循以下語法中 :token:`~float:floatvalue` 的生成規則:" -#: ../../builtins/functions.rst:810 +#: ../../builtins/functions.rst:829 msgid "" "Case is not significant, so, for example, \"inf\", \"Inf\", \"INFINITY\", " "and \"iNfINity\" are all acceptable spellings for positive infinity." @@ -1532,7 +1559,7 @@ msgstr "" "字母大小寫不影響,例如,\"inf\"、\"Inf\"、\"INFINITY\"、\"iNfINity\" 都可以表" "示正無窮大。" -#: ../../builtins/functions.rst:813 +#: ../../builtins/functions.rst:832 msgid "" "Otherwise, if the argument is an integer or a floating-point number, a " "floating-point number with the same value (within Python's floating-point " @@ -1542,7 +1569,7 @@ msgstr "" "否則,如果引數是整數或浮點數,則回傳具有相同值(在 Python 浮點精度範圍內)的" "浮點數。如果引數在 Python 浮點精度範圍外,則會引發 :exc:`OverflowError`。" -#: ../../builtins/functions.rst:818 +#: ../../builtins/functions.rst:837 msgid "" "For a general Python object ``x``, ``float(x)`` delegates to " "``x.__float__()``. If :meth:`~object.__float__` is not defined then it " @@ -1551,27 +1578,27 @@ msgstr "" "對於一般的 Python 物件 ``x``,``float(x)`` 會委派給 ``x.__float__()``。如果未" "定義 :meth:`~object.__float__` 則會回退到 :meth:`~object.__index__`。" -#: ../../builtins/functions.rst:822 +#: ../../builtins/functions.rst:841 msgid "" "See also :meth:`float.from_number` which only accepts a numeric argument." msgstr "也請參閱 :meth:`float.from_number`,它只接受一個數值引數。" -#: ../../builtins/functions.rst:824 +#: ../../builtins/functions.rst:843 msgid "If no argument is given, ``0.0`` is returned." msgstr "如果沒有引數,則回傳 ``0.0``。" -#: ../../builtins/functions.rst:826 +#: ../../builtins/functions.rst:845 msgid "The float type is described in :ref:`typesnumeric`." msgstr ":ref:`typesnumeric` 描述了浮點數型別。" -#: ../../builtins/functions.rst:834 +#: ../../builtins/functions.rst:853 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not " "defined." msgstr "" "如果 :meth:`~object.__float__` 未定義,則會回退到 :meth:`~object.__index__`。" -#: ../../builtins/functions.rst:844 +#: ../../builtins/functions.rst:863 msgid "" "Convert a *value* to a \"formatted\" representation, as controlled by " "*format_spec*. The interpretation of *format_spec* will depend on the type " @@ -1582,7 +1609,7 @@ msgstr "" "取決於 *value* 引數的型別,但是大多數內建型別使用標準格式化語" "法::ref:`formatspec`。" -#: ../../builtins/functions.rst:849 +#: ../../builtins/functions.rst:868 msgid "" "The default *format_spec* is an empty string which usually gives the same " "effect as calling :func:`str(value) `." @@ -1590,7 +1617,7 @@ msgstr "" "預設的 *format_spec* 是一個空字串,它通常和呼叫 :func:`str(value) ` 的效" "果相同。" -#: ../../builtins/functions.rst:852 +#: ../../builtins/functions.rst:871 msgid "" "A call to ``format(value, format_spec)`` is translated to " "``type(value).__format__(value, format_spec)`` which bypasses the instance " @@ -1604,7 +1631,7 @@ msgstr "" "實例中的字典。如果搜尋到 :mod:`object` 這個 method 但 *format_spec* 不為空," "或是 *format_spec* 或回傳值不是字串,則會引發 :exc:`TypeError`。" -#: ../../builtins/functions.rst:859 +#: ../../builtins/functions.rst:878 msgid "" "``object().__format__(format_spec)`` raises :exc:`TypeError` if " "*format_spec* is not an empty string." @@ -1612,7 +1639,23 @@ msgstr "" "當 *format_spec* 不是空字串時,``object().__format__(format_spec)`` 會引" "發 :exc:`TypeError`。" -#: ../../builtins/functions.rst:868 +#: ../../builtins/functions.rst:889 +msgid "" +"Create a new frozen dictionary. The :class:`frozendict` object is a built-" +"in class. See also :ref:`typesmapping` for documentation about this class." +msgstr "" +"建立一個新的凍結字典。:class:`frozendict` 物件是一個內建類別。關於此類別的說" +"明文件,亦請參閱 :ref:`typesmapping`。" + +#: ../../builtins/functions.rst:892 +msgid "" +"For other containers see the built-in :class:`dict`, :class:`list`, :class:" +"`set`, and :class:`tuple` classes, as well as the :mod:`collections` module." +msgstr "" +"關於其他容器,請參閱內建的 :class:`dict`、:class:`list`、:class:`set` " +"和 :class:`tuple` 類別,以及 :mod:`collections` 模組。" + +#: ../../builtins/functions.rst:902 msgid "" "Return a new :class:`frozenset` object, optionally with elements taken from " "*iterable*. :class:`frozenset` is a built-in class. See also :ref:`types-" @@ -1622,7 +1665,7 @@ msgstr "" "素。:class:`frozenset` 是一個內建類別。關於此類別的說明文件亦請參" "閱 :ref:`types-set`。" -#: ../../builtins/functions.rst:872 +#: ../../builtins/functions.rst:906 msgid "" "For other containers see the built-" "in :class:`set`, :class:`list`, :class:`tuple`, and :class:`dict` classes, " @@ -1631,7 +1674,7 @@ msgstr "" "請參閱內建的 :class:`set`、:class:`list`、:class:`tuple` 和 :class:`dict` " "class,以及 :mod:`collections` module 來了解其它的容器。" -#: ../../builtins/functions.rst:880 +#: ../../builtins/functions.rst:914 msgid "" "Return the value of the named attribute of *object*. *name* must be a " "string. If the string is the name of one of the object's attributes, the " @@ -1646,7 +1689,7 @@ msgstr "" "發 :exc:`AttributeError`。*name* 不必是個 Python 識別符 (identifier)(請" "見 :func:`setattr`)。" -#: ../../builtins/functions.rst:889 +#: ../../builtins/functions.rst:923 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " @@ -1657,7 +1700,7 @@ msgstr "" "發生在編譯期,因此你必須手動改編私有屬性(有兩個前導底線的屬性)的名稱,才能" "使用 :func:`getattr` 來取得它。" -#: ../../builtins/functions.rst:897 +#: ../../builtins/functions.rst:931 msgid "" "Return the dictionary implementing the current module namespace. For code " "within functions, this is set when the function is defined and remains the " @@ -1666,7 +1709,7 @@ msgstr "" "回傳代表目前 module 命名空間的 dictionary。對於在函式中的程式碼來說,這在定義" "函式時設定且不論該函式是在何處呼叫都會保持相同。" -#: ../../builtins/functions.rst:904 +#: ../../builtins/functions.rst:938 msgid "" "The arguments are an object and a string. The result is ``True`` if the " "string is the name of one of the object's attributes, ``False`` if not. " @@ -1677,7 +1720,7 @@ msgstr "" "則回傳 ``False``。(此功能是透過呼叫 ``getattr(object, name)`` 並檢查是否引" "發 :exc:`AttributeError` 來實作的。)" -#: ../../builtins/functions.rst:912 +#: ../../builtins/functions.rst:946 msgid "" "Return the hash value of the object (if it has one). Hash values are " "integers. They are used to quickly compare dictionary keys during a " @@ -1688,7 +1731,7 @@ msgstr "" "時用來快速比較 dictionary 的鍵。相同大小的數字數值有相同的雜湊值(即使它們型" "別不同,如 1 和 1.0)。" -#: ../../builtins/functions.rst:919 +#: ../../builtins/functions.rst:953 msgid "" "For objects with custom :meth:`~object.__hash__` methods, note " "that :func:`hash` truncates the return value based on the bit width of the " @@ -1697,7 +1740,7 @@ msgstr "" "請注意,如果物件帶有自訂的 :meth:`~object.__hash__` 方法,:func:`hash` 將根據" "運行機器的位元長度來截斷回傳值。" -#: ../../builtins/functions.rst:926 +#: ../../builtins/functions.rst:960 msgid "" "Invoke the built-in help system. (This function is intended for interactive " "use.) If no argument is given, the interactive help system starts on the " @@ -1711,7 +1754,7 @@ msgstr "" "關鍵字或說明文件主題中搜尋該字串,並在控制台上列印幫助資訊。如果引數是其他任" "意物件,則會生成該物件的幫助頁。" -#: ../../builtins/functions.rst:933 +#: ../../builtins/functions.rst:967 msgid "" "Note that if a slash(/) appears in the parameter list of a function when " "invoking :func:`help`, it means that the parameters prior to the slash are " @@ -1722,12 +1765,12 @@ msgstr "" "前面的參數是僅限位置 (positional-only) 參數。有關更多資訊,請參閱\\ :ref:`常" "見問答集中的僅限位置參數條目 `。" -#: ../../builtins/functions.rst:938 +#: ../../builtins/functions.rst:972 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." msgstr "此函式會被 :mod:`site` module 加入到內建命名空間。" -#: ../../builtins/functions.rst:940 +#: ../../builtins/functions.rst:974 msgid "" "Changes to :mod:`pydoc` and :mod:`inspect` mean that the reported signatures " "for callables are now more comprehensive and consistent." @@ -1735,7 +1778,7 @@ msgstr "" "對於 :mod:`pydoc` 和 :mod:`inspect` 的變更,使得可呼叫物件回報的的簽名 " "(signature) 更加全面和一致。" -#: ../../builtins/functions.rst:947 +#: ../../builtins/functions.rst:981 msgid "" "Convert an integer number to a lowercase hexadecimal string prefixed with " "\"0x\". If *integer* is not a Python :class:`int` object, it has to define " @@ -1745,7 +1788,7 @@ msgstr "" "Python :class:`int` 物件,則必須定義一個 :meth:`~object.__index__` method 並" "且回傳一個整數。舉例來說:" -#: ../../builtins/functions.rst:956 +#: ../../builtins/functions.rst:990 msgid "" "If you want to convert an integer number to an uppercase or lower " "hexadecimal string with prefix or not, you can use either of the following " @@ -1754,20 +1797,20 @@ msgstr "" "如果要將整數轉換為大寫或小寫的十六進位制字串,並可選擇有無 \"0x\" 前綴,則可" "以使用如下方法:" -#: ../../builtins/functions.rst:968 +#: ../../builtins/functions.rst:1002 msgid "" "See also :func:`int` for converting a hexadecimal string to an integer using " "a base of 16." msgstr "另請參閱 :func:`int` 將十六進位制字串轉換為以 16 為基數的整數。" -#: ../../builtins/functions.rst:973 +#: ../../builtins/functions.rst:1007 msgid "" "To obtain a hexadecimal string representation for a float, use " "the :meth:`float.hex` method." msgstr "" "如果要取得浮點數的十六進位制字串形式,請使用 :meth:`float.hex` method。" -#: ../../builtins/functions.rst:979 +#: ../../builtins/functions.rst:1013 msgid "" "Return the \"identity\" of an object. This is an integer which is " "guaranteed to be unique and constant for this object during its lifetime. " @@ -1777,18 +1820,18 @@ msgstr "" "回傳物件的 \"識別性\" 。該值是一個整數,在此物件的生命週期中保證是唯一且恆定" "的。兩個生命期不重疊的物件可能具有相同的 :func:`id` 值。" -#: ../../builtins/functions.rst:984 +#: ../../builtins/functions.rst:1018 msgid "This is the address of the object in memory." msgstr "這是該物件在記憶體中的位址。" -#: ../../builtins/functions.rst:986 +#: ../../builtins/functions.rst:1020 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." msgstr "" "引發一個附帶引數 ``id`` 的\\ :ref:`稽核事件 ` ``builtins.id``。" -#: ../../builtins/functions.rst:992 +#: ../../builtins/functions.rst:1026 msgid "" "If the *prompt* argument is present, it is written to standard output " "without a trailing newline. The function then reads a line from input, " @@ -1799,7 +1842,7 @@ msgstr "" "從輸入中讀取一行,將其轉換為字串(去除末尾的換行符)並回傳。當讀取到 EOF 時," "則引發 :exc:`EOFError`。例如: ::" -#: ../../builtins/functions.rst:997 +#: ../../builtins/functions.rst:1031 msgid "" ">>> s = input('--> ')\n" "--> Monty Python's Flying Circus\n" @@ -1811,7 +1854,7 @@ msgstr "" ">>> s\n" "\"Monty Python's Flying Circus\"" -#: ../../builtins/functions.rst:1002 +#: ../../builtins/functions.rst:1036 msgid "" "If the :mod:`readline` module was loaded, then :func:`input` will use it to " "provide elaborate line editing and history features." @@ -1819,7 +1862,7 @@ msgstr "" "如果載入了 :mod:`readline` module,:func:`input` 將使用它來提供複雜的行編輯和" "歷史記錄功能。" -#: ../../builtins/functions.rst:1005 ../../builtins/functions.rst:1007 +#: ../../builtins/functions.rst:1039 ../../builtins/functions.rst:1041 msgid "" "Raises an :ref:`auditing event ` ``builtins.input`` with argument " "``prompt`` before reading input" @@ -1827,7 +1870,7 @@ msgstr "" "引發一個附帶讀取輸入前的引數 ``prompt`` 的\\ :ref:`稽核事件 ` " "``builtins.input``。" -#: ../../builtins/functions.rst:1010 ../../builtins/functions.rst:1012 +#: ../../builtins/functions.rst:1044 ../../builtins/functions.rst:1046 msgid "" "Raises an :ref:`auditing event ` ``builtins.input/result`` with " "the result after successfully reading input." @@ -1835,13 +1878,13 @@ msgstr "" "引發一個附帶成功讀取結果的\\ :ref:`稽核事件 ` ``builtins.input/" "result``。" -#: ../../builtins/functions.rst:1019 +#: ../../builtins/functions.rst:1053 msgid "" "Return an integer object constructed from a number or a string, or return " "``0`` if no arguments are given." msgstr "回傳一個由數字或字串所構成的整數物件,若沒有給引數則回傳 ``0``。" -#: ../../builtins/functions.rst:1024 +#: ../../builtins/functions.rst:1058 msgid "" ">>> int(123.45)\n" "123\n" @@ -1869,7 +1912,7 @@ msgstr "" ">>> int('01110011', base=2)\n" "115" -#: ../../builtins/functions.rst:1039 +#: ../../builtins/functions.rst:1073 msgid "" "If the argument defines :meth:`~object.__int__`, ``int(x)`` returns " "``x.__int__()``. If the argument defines :meth:`~object.__index__`, it " @@ -1880,7 +1923,7 @@ msgstr "" "``x.__int__()``。如果引數定義了 :meth:`~object.__index__` 則回傳 " "``x.__index__()``。對於浮點數,則會向零的方向無條件捨去。" -#: ../../builtins/functions.rst:1044 +#: ../../builtins/functions.rst:1078 msgid "" "If the argument is not a number or if *base* is given, then it must be a " "string, :class:`bytes`, or :class:`bytearray` instance representing an " @@ -1893,7 +1936,7 @@ msgstr "" "前可以有 ``+`` 或 ``-``\\ (中間沒有空格)、可有個前導的零、也可被空格包圍、" "或在數字間有單一底線。" -#: ../../builtins/functions.rst:1050 +#: ../../builtins/functions.rst:1084 msgid "" "A base-n integer string contains digits, each representing a value from 0 to " "n-1. The values 0--9 can be represented by any Unicode decimal digit. The " @@ -1915,11 +1958,11 @@ msgstr "" "進制中的一個,所以 ``int('010', 0)`` 是非法的,但 ``int('010')`` 和 " "``int('010', 8)`` 是有效的。" -#: ../../builtins/functions.rst:1061 +#: ../../builtins/functions.rst:1095 msgid "The integer type is described in :ref:`typesnumeric`." msgstr "整數型別定義請參閱\\ :ref:`typesnumeric`。" -#: ../../builtins/functions.rst:1063 +#: ../../builtins/functions.rst:1097 msgid "" "If *base* is not an instance of :class:`int` and the *base* object has " "a :meth:`base.__index__ ` method, that method is called to " @@ -1931,18 +1974,18 @@ msgstr "" "的版本使用 :meth:`base.__int__ ` 而不" "是 :meth:`base.__index__ `。" -#: ../../builtins/functions.rst:1073 +#: ../../builtins/functions.rst:1107 msgid "The first parameter is now positional-only." msgstr "第一個參數為僅限位置參數。" -#: ../../builtins/functions.rst:1076 +#: ../../builtins/functions.rst:1110 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not " "defined." msgstr "" "如果未定義 :meth:`~object.__int__` 則會回退到 :meth:`~object.__index__`。" -#: ../../builtins/functions.rst:1079 +#: ../../builtins/functions.rst:1113 msgid "" ":class:`int` string inputs and string representations can be limited to help " "avoid denial of service attacks. A :exc:`ValueError` is raised when the " @@ -1956,12 +1999,12 @@ msgstr "" "在 :class:`int` 轉換為字串時將會超出限制時,會引發 :exc:`ValueError`。請參閱" "\\ :ref:`整數字串轉換的長度限制 `\\ 說明文件。" -#: ../../builtins/functions.rst:1087 +#: ../../builtins/functions.rst:1121 msgid "" ":func:`int` no longer delegates to the :meth:`~object.__trunc__` method." msgstr ":func:`int` 不再委派給 :meth:`~object.__trunc__` method。" -#: ../../builtins/functions.rst:1092 +#: ../../builtins/functions.rst:1126 msgid "" "Return ``True`` if the *object* argument is an instance of the *classinfo* " "argument, or of a (direct, indirect, or :term:`virtual `) of *classinfo*. A class is " -"considered a subclass of itself. *classinfo* may be a tuple of class objects " -"(or recursively, other such tuples) or a :ref:`types-union`, in which case " -"return ``True`` if *class* is a subclass of any entry in *classinfo*. In " -"any other case, a :exc:`TypeError` exception is raised." +"Return ``True`` if *cls* is a subclass (direct, indirect, or :term:`virtual " +"`) of *classinfo*. A class is considered a subclass of " +"itself. *classinfo* may be a tuple of class objects (or recursively, other " +"such tuples) or a :ref:`types-union`, in which case return ``True`` if *cls* " +"is a subclass of any entry in *classinfo*. In any other case, a :exc:" +"`TypeError` exception is raised." msgstr "" -"如果 *class* 是 *classinfo* 的 subclass(直接、間接或 :term:`virtual " -"`),則回傳 ``True``。*classinfo* 可以是 class 物件的 " -"tuple(或遞迴地其他類似 tuple)或是一個 :ref:`types-union`,此時若 *class* " -"是 *classinfo* 中任一元素的 subclass 時則回傳 ``True``。其他情況,會引" -"發 :exc:`TypeError`。" +"如果 *cls* 是 *classinfo* 的 subclass(直接、間接或 :term:`virtual `),則回傳 ``True``。一個 class 會被視為自己的 subclass。" +"*classinfo* 可以是 class 物件的 tuple(或遞迴地其他類似 tuple)或是一" +"個 :ref:`types-union`,此時若 *cls* 是 *classinfo* 中任一元素的 subclass 時則" +"回傳 ``True``。其他情況,會引發 :exc:`TypeError`。" -#: ../../builtins/functions.rst:1124 +#: ../../builtins/functions.rst:1158 msgid "" "Return an :term:`iterator` object. The first argument is interpreted very " "differently depending on the presence of the second argument. Without a " @@ -2026,11 +2069,11 @@ msgstr "" "叫 :meth:`~iterator.__next__` 時會不帶引數地呼叫 *callable*;如果回傳的結果" "是 *sentinel* 則引發 :exc:`StopIteration`,否則回傳呼叫結果。" -#: ../../builtins/functions.rst:1138 +#: ../../builtins/functions.rst:1172 msgid "See also :ref:`typeiter`." msgstr "另請參閱 :ref:`typeiter`。" -#: ../../builtins/functions.rst:1140 +#: ../../builtins/functions.rst:1174 msgid "" "One useful application of the second form of :func:`iter` is to build a " "block-reader. For example, reading fixed-width blocks from a binary database " @@ -2039,7 +2082,7 @@ msgstr "" ":func:`iter` 的第二種形式有一個好用的應用,是能夠建立一個區塊閱讀器 (block-" "reader)。例如,從二進位資料庫檔案中讀取固定寬度的區塊,直到檔案的結尾: ::" -#: ../../builtins/functions.rst:1144 +#: ../../builtins/functions.rst:1178 msgid "" "from functools import partial\n" "with open('mydata.db', 'rb') as f:\n" @@ -2051,7 +2094,7 @@ msgstr "" " for block in iter(partial(f.read, 64), b''):\n" " process_block(block)" -#: ../../builtins/functions.rst:1152 +#: ../../builtins/functions.rst:1186 msgid "" "Return the length (the number of items) of an object. The argument may be a " "sequence (such as a string, bytes, tuple, list, or range) or a collection " @@ -2060,7 +2103,7 @@ msgstr "" "回傳物件的長度(元素個數)。引數可以是序列(如 string、bytes、tuple、list 或 " "range)或集合(如 dictionary、set 或 frozen set)。" -#: ../../builtins/functions.rst:1158 +#: ../../builtins/functions.rst:1192 msgid "" "``len`` raises :exc:`OverflowError` on lengths larger " "than :data:`sys.maxsize`, such as :class:`range(2 ** 100) `." @@ -2068,7 +2111,7 @@ msgstr "" "如果物件長度大於 :data:`sys.maxsize`,像是 :class:`range(2 ** 100) `," "則 ``len`` 會引發 :exc:`OverflowError`。" -#: ../../builtins/functions.rst:1166 +#: ../../builtins/functions.rst:1200 msgid "" "Rather than being a function, :class:`list` is actually a mutable sequence " "type, as documented in :ref:`typesseq-list` and :ref:`typesseq`." @@ -2076,14 +2119,14 @@ msgstr "" "除了是函式,:class:`list` 也是可變序列型別,詳情請參閱 :ref:`typesseq-list` " "和 :ref:`typesseq`。" -#: ../../builtins/functions.rst:1172 +#: ../../builtins/functions.rst:1206 msgid "" "Return a mapping object representing the current local symbol table, with " "variable names as the keys, and their currently bound references as the " "values." msgstr "回傳代表目前區域符號表的對映物件,變數名稱為鍵,目前綁定的參照為值。" -#: ../../builtins/functions.rst:1176 +#: ../../builtins/functions.rst:1210 msgid "" "At module scope, as well as when using :func:`exec` or :func:`eval` with a " "single namespace, this function returns the same namespace " @@ -2092,14 +2135,14 @@ msgstr "" "在模組作用域,以及使用 :func:`exec` 或 :func:`eval` 單一命名空間時,此函式會" "回傳與 :func:`globals` 相同的命名空間。" -#: ../../builtins/functions.rst:1180 +#: ../../builtins/functions.rst:1214 msgid "" "At class scope, it returns the namespace that will be passed to the " "metaclass constructor." msgstr "" "在類別作用域中,它會回傳將傳遞給元類別 (metaclass) 建構函式的命名空間。" -#: ../../builtins/functions.rst:1183 +#: ../../builtins/functions.rst:1217 msgid "" "When using ``exec()`` or ``eval()`` with separate local and global " "arguments, it returns the local namespace passed in to the function call." @@ -2107,7 +2150,7 @@ msgstr "" "當使用 ``exec()`` 或 ``eval()``,並分別使用本機和全局參數時,它會回傳傳入函式" "呼叫的本機命名空間。" -#: ../../builtins/functions.rst:1186 +#: ../../builtins/functions.rst:1220 msgid "" "In all of the above cases, each call to ``locals()`` in a given frame of " "execution will return the *same* mapping object. Changes made through the " @@ -2121,7 +2164,7 @@ msgstr "" "指派或刪除的區域變數的形式顯示,而指派、重新指派或刪除區域變數會立即影響回傳" "的對映物件的內容。" -#: ../../builtins/functions.rst:1193 +#: ../../builtins/functions.rst:1227 msgid "" "In an :term:`optimized scope` (including functions, generators, and " "coroutines), each call to ``locals()`` instead returns a fresh dictionary " @@ -2138,7 +2181,7 @@ msgstr "" "寫回對應的區域變數或非區域 cell 參照,而且指派、重新指派或刪除區域變數和非區" "域 cell 參照,\\ **不會**\\ 影響先前回傳字典的內容。" -#: ../../builtins/functions.rst:1202 +#: ../../builtins/functions.rst:1236 msgid "" "Calling ``locals()`` as part of a comprehension in a function, generator, or " "coroutine is equivalent to calling it in the containing scope, except that " @@ -2150,7 +2193,7 @@ msgstr "" "用域中呼叫它,但綜合運算已初始化的疊代變數將被包含在內。在其他作用域中,它的" "行為就像綜合運算作為巢狀函式運行一樣。" -#: ../../builtins/functions.rst:1208 +#: ../../builtins/functions.rst:1242 msgid "" "Calling ``locals()`` as part of a generator expression is equivalent to " "calling it in a nested generator function." @@ -2158,13 +2201,13 @@ msgstr "" "呼叫 ``locals()`` 作為產生器運算式的一部分,等同於在巢狀的產生器函式中呼叫" "它。" -#: ../../builtins/functions.rst:1211 +#: ../../builtins/functions.rst:1245 msgid "" "The behaviour of ``locals()`` in a comprehension has been updated as " "described in :pep:`709`." msgstr "如 :pep:`709` 所述,更新了綜合運算中 ``locals()`` 的行為。" -#: ../../builtins/functions.rst:1215 +#: ../../builtins/functions.rst:1249 msgid "" "As part of :pep:`667`, the semantics of mutating the mapping objects " "returned from this function are now defined. The behavior " @@ -2176,7 +2219,7 @@ msgstr "" "在 :term:`optimized scopes ` 中的行為現在如上所述。除了被定" "義外,其他作用域中的行為與先前版本保持不變。" -#: ../../builtins/functions.rst:1225 +#: ../../builtins/functions.rst:1259 msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " @@ -2188,17 +2231,17 @@ msgid "" "argument tuples, see :func:`itertools.starmap`." msgstr "" -#: ../../builtins/functions.rst:1234 +#: ../../builtins/functions.rst:1268 msgid "Added the *strict* parameter." msgstr "增加了 *strict* 參數。" -#: ../../builtins/functions.rst:1242 +#: ../../builtins/functions.rst:1276 msgid "" "Return the largest item in an iterable or the largest of two or more " "arguments." msgstr "回傳 iterable 中最大的元素,或者回傳兩個以上的引數中最大的。" -#: ../../builtins/functions.rst:1245 +#: ../../builtins/functions.rst:1279 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The largest item in the iterable is returned. If two or more positional " @@ -2207,7 +2250,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是個 :term:`iterable`,iterable 中最大的元素" "會被回傳。如果提供了兩個或以上的位置引數,則回傳最大的位置引數。" -#: ../../builtins/functions.rst:1250 ../../builtins/functions.rst:1288 +#: ../../builtins/functions.rst:1284 ../../builtins/functions.rst:1322 msgid "" "There are two optional keyword-only arguments. The *key* argument specifies " "a one-argument ordering function like that used for :meth:`list.sort`. The " @@ -2220,7 +2263,7 @@ msgstr "" "的物件。如果 iterable 為空,並且沒有提供 *default*,則會引" "發 :exc:`ValueError`。" -#: ../../builtins/functions.rst:1256 +#: ../../builtins/functions.rst:1290 msgid "" "If multiple items are maximal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2231,15 +2274,15 @@ msgstr "" "``sorted(iterable, key=keyfunc, reverse=True)[0]`` 和 ``heapq.nlargest(1, " "iterable, key=keyfunc)`` 一致。" -#: ../../builtins/functions.rst:1261 ../../builtins/functions.rst:1299 +#: ../../builtins/functions.rst:1295 ../../builtins/functions.rst:1333 msgid "Added the *default* keyword-only parameter." msgstr "新增 *default* 僅限關鍵字參數。" -#: ../../builtins/functions.rst:1264 ../../builtins/functions.rst:1302 +#: ../../builtins/functions.rst:1298 ../../builtins/functions.rst:1336 msgid "The *key* can be ``None``." msgstr "*key* 可以為 ``None``。" -#: ../../builtins/functions.rst:1272 +#: ../../builtins/functions.rst:1306 msgid "" "Return a \"memory view\" object created from the given argument. " "See :ref:`typememoryview` for more information." @@ -2247,13 +2290,13 @@ msgstr "" "回傳由給定的引數所建立之「memory view(記憶體檢視)」物件。有關詳細資訊,請參" "閱\\ :ref:`typememoryview`。" -#: ../../builtins/functions.rst:1280 +#: ../../builtins/functions.rst:1314 msgid "" "Return the smallest item in an iterable or the smallest of two or more " "arguments." msgstr "回傳 iterable 中最小的元素,或者回傳兩個以上的引數中最小的。" -#: ../../builtins/functions.rst:1283 +#: ../../builtins/functions.rst:1317 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The smallest item in the iterable is returned. If two or more positional " @@ -2262,7 +2305,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是 :term:`iterable`,iterable 中最小的元素會" "被回傳。如果提供了兩個以上的位置引數,則回傳最小的位置引數。" -#: ../../builtins/functions.rst:1294 +#: ../../builtins/functions.rst:1328 msgid "" "If multiple items are minimal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2273,7 +2316,7 @@ msgstr "" "``sorted(iterable, key=keyfunc)[0]`` 和 ``heapq.nsmallest(1, iterable, " "key=keyfunc)`` 一致。" -#: ../../builtins/functions.rst:1309 +#: ../../builtins/functions.rst:1343 msgid "" "Retrieve the next item from the :term:`iterator` by calling " "its :meth:`~iterator.__next__` method. If *default* is given, it is " @@ -2281,7 +2324,7 @@ msgid "" "otherwise :exc:`StopIteration` is raised." msgstr "" -#: ../../builtins/functions.rst:1316 +#: ../../builtins/functions.rst:1350 msgid "" "This is the ultimate base class of all other classes. It has methods that " "are common to all instances of Python classes. When the constructor is " @@ -2292,7 +2335,7 @@ msgstr "" "函式被呼叫時,它會回傳一個新的沒有特徵 (featureless) 的物件。這個建構函式不接" "受任何引數。" -#: ../../builtins/functions.rst:1323 +#: ../../builtins/functions.rst:1357 msgid "" ":class:`object` instances do *not* have :attr:`~object.__dict__` attributes, " "so you can't assign arbitrary attributes to an instance of :class:`object`." @@ -2300,7 +2343,7 @@ msgstr "" "由於 :class:`object` 實例\\ *沒有* :attr:`~object.__dict__` 屬性,因此無法將" "任意屬性賦給 :class:`object` 的實例。" -#: ../../builtins/functions.rst:1330 +#: ../../builtins/functions.rst:1364 msgid "" "Convert an integer number to an octal string prefixed with \"0o\". The " "result is a valid Python expression. If *integer* is not a " @@ -2311,7 +2354,7 @@ msgstr "" "Python 運算式。如果 *integer* 不是 Python 的 :class:`int` 物件,那它需要定" "義 :meth:`~object.__index__` method 回傳一個整數。舉例來說:" -#: ../../builtins/functions.rst:1340 +#: ../../builtins/functions.rst:1374 msgid "" "If you want to convert an integer number to an octal string either with the " "prefix \"0o\" or not, you can use either of the following ways." @@ -2319,7 +2362,7 @@ msgstr "" "如果要將整數轉換為八進位制字串,不論是否具備 \"0o\" 前綴,都可以使用下面的方" "法。" -#: ../../builtins/functions.rst:1357 +#: ../../builtins/functions.rst:1391 msgid "" "Open *file* and return a corresponding :term:`file object`. If the file " "cannot be opened, an :exc:`OSError` is raised. See :ref:`tut-files` for more " @@ -2329,7 +2372,7 @@ msgstr "" "啟,則引發 :exc:`OSError`。關於使用此函式的更多方法,請參閱\\ :ref:`tut-" "files`。" -#: ../../builtins/functions.rst:1361 +#: ../../builtins/functions.rst:1395 msgid "" "*file* is a :term:`path-like object` giving the pathname (absolute or " "relative to the current working directory) of the file to be opened or an " @@ -2342,7 +2385,7 @@ msgstr "" "器 (file descriptor)。(如果有給定檔案描述器,它會隨著回傳的 I/O 物件關閉而關" "閉,除非 *closefd* 被設為 ``False``。)" -#: ../../builtins/functions.rst:1367 +#: ../../builtins/functions.rst:1401 msgid "" "*mode* is an optional string that specifies the mode in which the file is " "opened. It defaults to ``'r'`` which means open for reading in text mode. " @@ -2350,84 +2393,85 @@ msgid "" "already exists), ``'x'`` for exclusive creation, and ``'a'`` for appending " "(which on *some* Unix systems, means that *all* writes append to the end of " "the file regardless of the current seek position). In text mode, if " -"*encoding* is not specified the encoding used is platform-" -"dependent: :func:`locale.getencoding` is called to get the current locale " -"encoding. (For reading and writing raw bytes use binary mode and leave " -"*encoding* unspecified.) The available modes are:" +"*encoding* is not specified, UTF-8 is used by default; if :ref:`Python UTF-8 " +"Mode ` is disabled, :func:`locale.getencoding` is called to get " +"the current locale encoding. (For reading and writing raw bytes use binary " +"mode and leave *encoding* unspecified.) The available modes are:" msgstr "" "*mode* 是一個選擇性字串,用於指定開啟檔案的模式。預設值是 ``'r'``,這意味著它" "以文字模式開啟並讀取。其他常見模式有:寫入 ``'w'``\\ (會捨去已經存在的檔" "案)、唯一性建立 ``'x'``、追加寫入 ``'a'``\\ (在\\ *一些* Unix 系統上,無論" "目前的檔案指標在什麼位置,*所有* 寫入都會追加到檔案末尾)。在文字模式,如果沒" -"有指定 *encoding*,則根據電腦平臺來決定使用的編碼:呼" -"叫 :func:`locale.getencoding` 來取得目前的本地編碼。(要讀取和寫入原始 " -"bytes,請使用二進位制模式且不要指定 *encoding*。)可用的模式有:" +"有指定 *encoding*,預設會使用 UTF-8;如果停用了 :ref:`Python UTF-8 模式 " +"`,則會呼叫 :func:`locale.getencoding` 來取得目前的本地編碼。(要" +"讀取和寫入原始 bytes,請使用二進位制模式且不要指定 *encoding*。)可用的模式" +"有:" -#: ../../builtins/functions.rst:1384 +#: ../../builtins/functions.rst:1419 msgid "Character" msgstr "字元" -#: ../../builtins/functions.rst:1384 +#: ../../builtins/functions.rst:1419 msgid "Meaning" msgstr "意義" -#: ../../builtins/functions.rst:1386 +#: ../../builtins/functions.rst:1421 msgid "``'r'``" msgstr "``'r'``" -#: ../../builtins/functions.rst:1386 +#: ../../builtins/functions.rst:1421 msgid "open for reading (default)" msgstr "讀取(預設)" -#: ../../builtins/functions.rst:1387 +#: ../../builtins/functions.rst:1422 msgid "``'w'``" msgstr "``'w'``" -#: ../../builtins/functions.rst:1387 +#: ../../builtins/functions.rst:1422 msgid "open for writing, truncating the file first" msgstr "寫入,會先清除檔案內容" -#: ../../builtins/functions.rst:1388 +#: ../../builtins/functions.rst:1423 msgid "``'x'``" msgstr "``'x'``" -#: ../../builtins/functions.rst:1388 +#: ../../builtins/functions.rst:1423 msgid "open for exclusive creation, failing if the file already exists" msgstr "唯一性建立,如果文件已存在則會失敗" -#: ../../builtins/functions.rst:1389 +#: ../../builtins/functions.rst:1424 msgid "``'a'``" msgstr "``'a'``" -#: ../../builtins/functions.rst:1389 +#: ../../builtins/functions.rst:1424 msgid "open for writing, appending to the end of file if it exists" msgstr "寫入,如果檔案存在則在其末端附加內容" -#: ../../builtins/functions.rst:1390 +#: ../../builtins/functions.rst:1425 msgid "``'b'``" msgstr "``'b'``" -#: ../../builtins/functions.rst:1390 ../../builtins/functions.rst:1534 +#: ../../builtins/functions.rst:1425 ../../builtins/functions.rst:1543 msgid "binary mode" msgstr "二進制模式" -#: ../../builtins/functions.rst:1391 +#: ../../builtins/functions.rst:1426 msgid "``'t'``" msgstr "``'t'``" -#: ../../builtins/functions.rst:1391 +#: ../../builtins/functions.rst:1426 msgid "text mode (default)" msgstr "文字模式(預設)" -#: ../../builtins/functions.rst:1392 +#: ../../builtins/functions.rst:1427 msgid "``'+'``" msgstr "``'+'``" -#: ../../builtins/functions.rst:1392 +#: ../../builtins/functions.rst:1427 msgid "open for updating (reading and writing)" msgstr "更新(讀取並寫入)" -#: ../../builtins/functions.rst:1395 +#: ../../builtins/functions.rst:1430 msgid "" "The default mode is ``'r'`` (open for reading text, a synonym of ``'rt'``). " "Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and " @@ -2437,23 +2481,23 @@ msgstr "" "``'w+b'`` 模式會開啟並清除檔案。``'r+'`` 和 ``'r+b'`` 模式會開啟且保留檔案內" "容。" -#: ../../builtins/functions.rst:1399 +#: ../../builtins/functions.rst:1434 msgid "" "As mentioned in the :ref:`io-overview`, Python distinguishes between binary " "and text I/O. Files opened in binary mode (including ``'b'`` in the *mode* " "argument) return contents as :class:`bytes` objects without any decoding. " "In text mode (the default, or when ``'t'`` is included in the *mode* " "argument), the contents of the file are returned as :class:`str`, the bytes " -"having been first decoded using a platform-dependent encoding or using the " -"specified *encoding* if given." +"having been first decoded using the default encoding or using the specified " +"*encoding* if given." msgstr "" "如\\ :ref:`io-overview`\\ 中所述,Python 能區分二進制和文字的 I/O。在二進制模" "式下開啟的檔案(*mode* 引數中含有 ``'b'``)會將其內容以 :class:`bytes` 物件回" "傳,而不進行任何解碼。在文字模式(預設情況,或當 *mode* 引數中含有 " -"``'t'``),檔案的內容會以 :class:`str` 回傳,其位元組已經先被解碼,使用的是取" -"決於平台的編碼系統或是給定的 *encoding*。" +"``'t'``),檔案的內容會以 :class:`str` 回傳,其位元組已經先被解碼,使用的是預" +"設的編碼系統或是給定的 *encoding*。" -#: ../../builtins/functions.rst:1409 +#: ../../builtins/functions.rst:1444 msgid "" "Python doesn't depend on the underlying operating system's notion of text " "files; all the processing is done by Python itself, and is therefore " @@ -2462,7 +2506,7 @@ msgstr "" "Python 不會使用底層作業系統對於文字檔案的操作概念;所有的處理都是由 Python 獨" "自完成的,因此能獨立於不同平台。" -#: ../../builtins/functions.rst:1413 +#: ../../builtins/functions.rst:1448 msgid "" "*buffering* is an optional integer used to set the buffering policy. Pass 0 " "to switch buffering off (only allowed in binary mode), 1 to select line " @@ -2483,7 +2527,7 @@ msgstr "" "``write_through`` 旗標。若未給定 *buffering* 引數,則預設的緩衝策略會運作如" "下:" -#: ../../builtins/functions.rst:1423 +#: ../../builtins/functions.rst:1458 msgid "" "Binary files are buffered in fixed-size chunks; the size of the buffer is " "``max(min(blocksize, 8 MiB), DEFAULT_BUFFER_SIZE)`` when the device block " @@ -2494,7 +2538,7 @@ msgstr "" "MiB), DEFAULT_BUFFER_SIZE)``,當裝置區塊大小可用時。在大多數系統上,緩衝區的" "長度通常為 128 KB。" -#: ../../builtins/functions.rst:1428 +#: ../../builtins/functions.rst:1463 msgid "" "\"Interactive\" text files (files for which :meth:`~io.IOBase.isatty` " "returns ``True``) use line buffering. Other text files use the policy " @@ -2503,93 +2547,37 @@ msgstr "" "「互動式」文字檔(:meth:`~io.IOBase.isatty` 回傳 ``True`` 的檔案)會使用列緩" "衝。其他文字檔則使用上述的二進制檔案緩衝策略。" -#: ../../builtins/functions.rst:1432 +#: ../../builtins/functions.rst:1467 msgid "" "*encoding* is the name of the encoding used to decode or encode the file. " -"This should only be used in text mode. The default encoding is platform " -"dependent (whatever :func:`locale.getencoding` returns), but any :term:`text " -"encoding` supported by Python can be used. See the :mod:`codecs` module for " -"the list of supported encodings." +"This should only be used in text mode. The default encoding is UTF-8; if :" +"ref:`Python UTF-8 Mode ` is disabled, the default is platform-" +"dependent (whatever :func:`locale.getencoding` returns). Any :term:`text " +"encoding` supported by Python can be used, and ``encoding=\"locale\"`` " +"specifies the current locale encoding explicitly. See the :mod:`codecs` " +"module for the list of supported encodings." msgstr "" "*encoding* 是用於解碼或編碼檔案的編碼系統之名稱。它只應該在文字模式下使用。預" -"設的編碼系統會取決於平台(根據 :func:`locale.getencoding` 回傳的內容),但 " -"Python 支援的任何 :term:`text encoding`\\ (文字編碼)都是可以使用的。關於支" -"援的編碼系統清單,請參閱 :mod:`codecs` module。" +"設的編碼系統是 UTF-8;如果停用了 :ref:`Python UTF-8 模式 `,預設的" +"編碼系統會取決於平台(根據 :func:`locale.getencoding` 回傳的內容)。Python 支" +"援的任何 :term:`text encoding`\\ (文字編碼)都是可以使用的,而 " +"``encoding=\"locale\"`` 會明確指定使用目前的本地編碼。關於支援的編碼系統清" +"單,請參閱 :mod:`codecs` module。" -#: ../../builtins/functions.rst:1438 +#: ../../builtins/functions.rst:1475 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled—this cannot be used in binary mode. A variety of " -"standard error handlers are available (listed under :ref:`error-handlers`), " -"though any error handling name that has been registered " -"with :func:`codecs.register_error` is also valid. The standard names " -"include:" +"standard error handlers are available, though any error handling name that " +"has been registered with :func:`codecs.register_error` is also valid. The " +"standard names can be found in :ref:`error-handlers`." msgstr "" "*errors* 是一個選擇性的字串,用於指定要如何處理編碼和解碼的錯誤——它不能在二進" -"制模式下使用。有許多不同的標準錯誤處理程式(error handler,在\\ :ref:`error-" -"handlers`\\ 有列出清單),不過任何已註冊到 :func:`codecs.register_error` 的錯" -"誤處理程式名稱也都是有效的。標準的名稱包括:" - -#: ../../builtins/functions.rst:1446 -msgid "" -"``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding " -"error. The default value of ``None`` has the same effect." -msgstr "" -"``'strict'`` 如果發生編碼錯誤,則引發 :exc:`ValueError` 例外。預設值 " -"``None`` 也有相同的效果。" - -#: ../../builtins/functions.rst:1450 -msgid "" -"``'ignore'`` ignores errors. Note that ignoring encoding errors can lead to " -"data loss." -msgstr "``'ignore'`` 忽略錯誤。請注意,忽略編碼錯誤可能導致資料遺失。" - -#: ../../builtins/functions.rst:1453 -msgid "" -"``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted " -"where there is malformed data." -msgstr "" -"``'replace'`` 會在格式不正確的資料位置插入一個替換標誌(像是 ``'?'``)。" +"制模式下使用。有許多不同的標準錯誤處理程式 (error handler),不過任何已註冊" +"到 :func:`codecs.register_error` 的錯誤處理程式名稱也都是有效的。標準的名稱可" +"以在\\ :ref:`error-handlers`\\ 中找到。" -#: ../../builtins/functions.rst:1456 -msgid "" -"``'surrogateescape'`` will represent any incorrect bytes as low surrogate " -"code units ranging from U+DC80 to U+DCFF. These surrogate code units will " -"then be turned back into the same bytes when the ``surrogateescape`` error " -"handler is used when writing data. This is useful for processing files in " -"an unknown encoding." -msgstr "" -"``'surrogateescape'`` 會將任何不正確的位元組表示為低位代理碼元 (low " -"surrogate code unit),範圍從 U+DC80 到 U+DCFF。在寫入資料時,這些代理碼元將會" -"被還原回 ``surrogateescape`` 錯誤處理程式當時所處理的那些相同位元組。這對於處" -"理未知編碼方式的檔案會很好用。" - -#: ../../builtins/functions.rst:1463 -msgid "" -"``'xmlcharrefreplace'`` is only supported when writing to a file. Characters " -"not supported by the encoding are replaced with the appropriate XML " -"character reference :samp:`&#{nnn};`." -msgstr "" -"``'xmlcharrefreplace'`` 僅在寫入檔案時可支援。編碼系統不支援的字元會被替換為" -"適當的 XML 字元參考 (character reference) ``&#nnn;``。" - -#: ../../builtins/functions.rst:1467 -msgid "" -"``'backslashreplace'`` replaces malformed data by Python's backslashed " -"escape sequences." -msgstr "" -"``'backslashreplace'`` 會用 Python 的反斜線跳脫序列 (backslashed escape " -"sequence) 替換格式不正確的資料。" - -#: ../../builtins/functions.rst:1470 -msgid "" -"``'namereplace'`` (also only supported when writing) replaces unsupported " -"characters with ``\\N{...}`` escape sequences." -msgstr "" -"``'namereplace'``\\ (也僅在寫入時支援)會將不支援的字元替換為 ``\\N{...}`` " -"跳脫序列。" - -#: ../../builtins/functions.rst:1478 +#: ../../builtins/functions.rst:1487 msgid "" "*newline* determines how to parse newline characters from the stream. It can " "be ``None``, ``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as " @@ -2598,7 +2586,7 @@ msgstr "" "*newline* 會決定如何剖析資料串流 (stream) 中的換行字元。它可以是 ``None``、" "``''``、``'\\n'``、``'\\r'`` 或 ``'\\r\\n'``。它的運作規則如下:" -#: ../../builtins/functions.rst:1482 +#: ../../builtins/functions.rst:1491 msgid "" "When reading input from the stream, if *newline* is ``None``, universal " "newlines mode is enabled. Lines in the input can end in ``'\\n'``, " @@ -2614,7 +2602,7 @@ msgstr "" "傳給呼叫方時,行尾符號不會被轉換。如果它是任何其他有效的值,則輸入資料的行只" "會由給定的字串做結尾,且在回傳給呼叫方時,行尾符號不會被轉換。" -#: ../../builtins/functions.rst:1490 +#: ../../builtins/functions.rst:1499 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " "characters written are translated to the system default line " @@ -2627,7 +2615,7 @@ msgstr "" "``''`` 或 ``'\\n'``,則不做任何轉換。如果 *newline* 是任何其他有效的值,則寫" "入的任何 ``'\\n'`` 字元都將轉換為給定的字串。" -#: ../../builtins/functions.rst:1496 +#: ../../builtins/functions.rst:1505 msgid "" "If *closefd* is ``False`` and a file descriptor rather than a filename was " "given, the underlying file descriptor will be kept open when the file is " @@ -2638,7 +2626,7 @@ msgstr "" "則當檔案關閉時,底層的檔案描述器會保持開啟狀態。如果有給定一個檔名,則 " "*closefd* 必須是 ``True``\\ (預設值);否則將引發錯誤。" -#: ../../builtins/functions.rst:1501 +#: ../../builtins/functions.rst:1510 msgid "" "A custom opener can be used by passing a callable as *opener*. The " "underlying file descriptor for the file object is then obtained by calling " @@ -2651,11 +2639,11 @@ msgstr "" "必須回傳一個開啟的檔案描述器(將 :mod:`os.open` 作為 *opener* 傳入,在功能上" "的結果會相當於傳入 ``None``)。" -#: ../../builtins/functions.rst:1507 +#: ../../builtins/functions.rst:1516 msgid "The newly created file is :ref:`non-inheritable `." msgstr "新建立的檔案是\\ :ref:`不可繼承的 `。" -#: ../../builtins/functions.rst:1509 +#: ../../builtins/functions.rst:1518 msgid "" "The following example uses the :ref:`dir_fd ` parameter of " "the :func:`os.open` function to open a file relative to a given directory::" @@ -2663,7 +2651,7 @@ msgstr "" "下面的範例使用 :func:`os.open` 函式回傳值當作 :ref:`dir_fd ` 的參數," "從給定的目錄中用相對路徑開啟檔案: ::" -#: ../../builtins/functions.rst:1512 +#: ../../builtins/functions.rst:1521 msgid "" ">>> import os\n" ">>> dir_fd = os.open('somedir', os.O_RDONLY)\n" @@ -2685,7 +2673,7 @@ msgstr "" "...\n" ">>> os.close(dir_fd) # don't leak a file descriptor" -#: ../../builtins/functions.rst:1522 +#: ../../builtins/functions.rst:1531 msgid "" "The type of :term:`file object` returned by the :func:`open` function " "depends on the mode. When :func:`open` is used to open a file in a text " @@ -2709,7 +2697,7 @@ msgstr "" "傳 :class:`io.BufferedRandom`。當緩衝被停用時,會回傳原始資料串" "流 :class:`io.FileIO`,它是 :class:`io.RawIOBase` 的一個 subclass。" -#: ../../builtins/functions.rst:1543 +#: ../../builtins/functions.rst:1552 msgid "" "See also the file handling modules, such as :mod:`fileinput`, :mod:`io` " "(where :func:`open` is " @@ -2719,7 +2707,7 @@ msgstr "" "了 :func:`open` 的 module )、:mod:`os`、:mod:`os.path`、:mod:`tempfile` 以" "及 :mod:`shutil`。" -#: ../../builtins/functions.rst:1547 +#: ../../builtins/functions.rst:1556 msgid "" "Raises an :ref:`auditing event ` ``open`` with arguments ``path``, " "``mode``, ``flags``." @@ -2727,25 +2715,25 @@ msgstr "" "引發一個附帶引數 ``path``、``mode``、``flags`` 的\\ :ref:`稽核事件 " "` ``open``。" -#: ../../builtins/functions.rst:1549 +#: ../../builtins/functions.rst:1558 msgid "" "The ``mode`` and ``flags`` arguments may have been modified or inferred from " "the original call." msgstr "``mode`` 和 ``flags`` 引數可能會被原始的呼叫所修改或推論 (infer)。" -#: ../../builtins/functions.rst:1554 +#: ../../builtins/functions.rst:1563 msgid "The *opener* parameter was added." msgstr "新增 *opener* 參數。" -#: ../../builtins/functions.rst:1555 +#: ../../builtins/functions.rst:1564 msgid "The ``'x'`` mode was added." msgstr "新增 ``'x'`` 模式。" -#: ../../builtins/functions.rst:1556 +#: ../../builtins/functions.rst:1565 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." msgstr "過去引發的 :exc:`IOError`,現在是 :exc:`OSError` 的別名。" -#: ../../builtins/functions.rst:1557 +#: ../../builtins/functions.rst:1566 msgid "" ":exc:`FileExistsError` is now raised if the file opened in exclusive " "creation mode (``'x'``) already exists." @@ -2753,11 +2741,11 @@ msgstr "" "如果檔案已存在但使用了唯一性建立模式 (``'x'``),現在會引" "發 :exc:`FileExistsError`。" -#: ../../builtins/functions.rst:1562 +#: ../../builtins/functions.rst:1571 msgid "The file is now non-inheritable." msgstr "檔案在此版本開始是不可繼承的。" -#: ../../builtins/functions.rst:1566 +#: ../../builtins/functions.rst:1575 msgid "" "If the system call is interrupted and the signal handler does not raise an " "exception, the function now retries the system call instead of raising " @@ -2766,15 +2754,15 @@ msgstr "" "如果系統呼叫被中斷,但訊號處理程式沒有引發例外,此函式現在會重試系統呼叫,而" "不是引發 :exc:`InterruptedError` 例外(原因詳見 :pep:`475`)。" -#: ../../builtins/functions.rst:1569 +#: ../../builtins/functions.rst:1578 msgid "The ``'namereplace'`` error handler was added." msgstr "增加了 ``'namereplace'`` 錯誤處理程式。" -#: ../../builtins/functions.rst:1573 +#: ../../builtins/functions.rst:1582 msgid "Support added to accept objects implementing :class:`os.PathLike`." msgstr "增加對於實作 :class:`os.PathLike` 物件的支援。" -#: ../../builtins/functions.rst:1574 +#: ../../builtins/functions.rst:1583 msgid "" "On Windows, opening a console buffer may return a subclass " "of :class:`io.RawIOBase` other than :class:`io.FileIO`." @@ -2782,15 +2770,21 @@ msgstr "" "在 Windows 上,開啟一個控制臺緩衝區可能會回傳 :class:`io.RawIOBase` 的 " "subclass,而不是 :class:`io.FileIO`。" -#: ../../builtins/functions.rst:1577 +#: ../../builtins/functions.rst:1586 msgid "The ``'U'`` mode has been removed." msgstr "``'U'`` 模式被移除。" -#: ../../builtins/functions.rst:1582 +#: ../../builtins/functions.rst:1589 +msgid "" +"UTF-8 is now the default encoding, instead of the platform-dependent locale " +"encoding (:pep:`686`)." +msgstr "" + +#: ../../builtins/functions.rst:1595 msgid "Return the ordinal value of a character." msgstr "回傳一個字元的序數值。" -#: ../../builtins/functions.rst:1584 +#: ../../builtins/functions.rst:1597 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 " @@ -2801,7 +2795,7 @@ msgstr "" "整數 ``97``、``ord('€')``\\ (歐元符號)回傳 ``8364``。這是 :func:`chr` 的逆" "函式。" -#: ../../builtins/functions.rst:1589 +#: ../../builtins/functions.rst:1602 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 " @@ -2810,7 +2804,7 @@ msgstr "" "如果引數是長度為 1 的 :class:`bytes` 或 :class:`bytearray` 物件,則回傳其單一" "位元組值。例如 ``ord(b'a')`` 回傳整數 ``97``。" -#: ../../builtins/functions.rst:1596 +#: ../../builtins/functions.rst:1609 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) % " @@ -2821,7 +2815,7 @@ msgstr "" "*mod* 取餘數(比直接呼叫 ``pow(base, exp) % mod`` 計算更高效)。兩個引數形式" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" -#: ../../builtins/functions.rst:1601 +#: ../../builtins/functions.rst:1614 msgid "" "When arguments are builtin numeric types with mixed operand types, the " "coercion rules for binary arithmetic operators apply. For :class:`int` " @@ -2845,7 +2839,7 @@ msgstr "" "或 :class:`float` 的負數且指數為整數,則會傳回浮點數結果。例如 ``pow(-9, " "2.0)`` 會回傳 ``81.0``。" -#: ../../builtins/functions.rst:1613 +#: ../../builtins/functions.rst:1626 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 " @@ -2858,11 +2852,11 @@ msgstr "" "與 *mod* 互質。在這種情況下,會回傳 ``pow(inv_base, -exp, mod)``,其中 " "*inv_base* 是 *base* 對 *mod* 的模倒數 (inverse modulo)。" -#: ../../builtins/functions.rst:1619 +#: ../../builtins/functions.rst:1632 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" msgstr "以下是一個計算 ``38`` 對 ``97`` 取模倒數的範例: ::" -#: ../../builtins/functions.rst:1621 +#: ../../builtins/functions.rst:1634 msgid "" ">>> pow(38, -1, mod=97)\n" "23\n" @@ -2874,7 +2868,7 @@ msgstr "" ">>> 23 * 38 % 97 == 1\n" "True" -#: ../../builtins/functions.rst:1626 +#: ../../builtins/functions.rst:1639 msgid "" "For :class:`int` operands, the three-argument form of ``pow`` now allows the " "second argument to be negative, permitting computation of modular inverses." @@ -2882,12 +2876,12 @@ msgstr "" "對於 :class:`int` 運算元,現在 ``pow`` 的三引數形式允許第二個引數為負數,也容" "許模倒數的計算。" -#: ../../builtins/functions.rst:1631 +#: ../../builtins/functions.rst:1644 msgid "" "Allow keyword arguments. Formerly, only positional arguments were supported." msgstr "允許關鍵字引數。在此之前只支援位置引數。" -#: ../../builtins/functions.rst:1638 +#: ../../builtins/functions.rst:1651 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 " @@ -2896,7 +2890,7 @@ msgstr "" "將 *objects* 列印到文字資料串流 *file*,用 *sep* 分隔並以 *end* 結尾。如果有" "給定 *sep*、*end*、*file* 和 *flush*,那麼它們必須是關鍵字引數的形式。" -#: ../../builtins/functions.rst:1642 +#: ../../builtins/functions.rst:1655 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* " @@ -2909,7 +2903,7 @@ msgstr "" "以是 ``None``,這表示使用預設值。如果沒有給定 *objects*,:func:`print` 就只會" "寫入 *end*。" -#: ../../builtins/functions.rst:1648 +#: ../../builtins/functions.rst:1661 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 " @@ -2921,7 +2915,7 @@ msgstr "" "串,所以 :func:`print` 不能用於二進位模式的檔案物件。對於此類物件,請改用 " "``file.write(...)``。" -#: ../../builtins/functions.rst:1653 +#: ../../builtins/functions.rst:1666 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." @@ -2929,15 +2923,15 @@ msgstr "" "輸出緩衝通常會由 *file* 決定。但是如果 *flush* 為 true,則資料串流會被強制清" "除。" -#: ../../builtins/functions.rst:1657 +#: ../../builtins/functions.rst:1670 msgid "Added the *flush* keyword argument." msgstr "增加了 *flush* 關鍵字引數。" -#: ../../builtins/functions.rst:1663 +#: ../../builtins/functions.rst:1676 msgid "Return a property attribute." msgstr "回傳 property 屬性。" -#: ../../builtins/functions.rst:1665 +#: ../../builtins/functions.rst:1678 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 " @@ -2946,11 +2940,11 @@ msgstr "" "*fget* 是一個用於取得屬性值的函式,*fset* 是一個用於設定屬性值的函式,*fdel* " "是一個用於刪除屬性值的函式,而 *doc* 會為該屬性建立一個說明字串。" -#: ../../builtins/functions.rst:1669 +#: ../../builtins/functions.rst:1682 msgid "A typical use is to define a managed attribute ``x``::" msgstr "一個典型的用途是定義一個受管理的屬性 ``x``: ::" -#: ../../builtins/functions.rst:1671 +#: ../../builtins/functions.rst:1684 msgid "" "class C:\n" " def __init__(self):\n" @@ -2982,7 +2976,7 @@ msgstr "" "\n" " x = property(getx, setx, delx, \"我是 'x' 屬性。\")" -#: ../../builtins/functions.rst:1686 +#: ../../builtins/functions.rst:1699 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." @@ -2990,7 +2984,7 @@ msgstr "" "如果 *c* 是 *C* 的一個實例,則 ``c.x`` 將會叫用取得器 (getter),``c.x = " "value`` 會呼叫設定器 (setter),而 ``del c.x`` 會叫用刪除器 (deleter)。" -#: ../../builtins/functions.rst:1689 +#: ../../builtins/functions.rst:1702 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 " @@ -2998,7 +2992,7 @@ msgid "" "a :term:`decorator`::" msgstr "" -#: ../../builtins/functions.rst:1693 +#: ../../builtins/functions.rst:1706 msgid "" "class Parrot:\n" " def __init__(self):\n" @@ -3018,7 +3012,7 @@ msgstr "" " \"\"\"取得目前的電壓。\"\"\"\n" " return self._voltage" -#: ../../builtins/functions.rst:1702 +#: ../../builtins/functions.rst:1715 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 " @@ -3027,7 +3021,7 @@ msgstr "" "``@property`` 裝飾器將 :meth:`!voltage` 方法變成同名唯讀屬性的 \"getter\",並" "將 *voltage* 的說明字串設成 \"Get the current voltage\"。" -#: ../../builtins/functions.rst:1710 +#: ../../builtins/functions.rst:1723 msgid "" "A property object has ``getter``, ``setter``, and ``deleter`` methods usable " "as decorators that create a copy of the property with the corresponding " @@ -3038,7 +3032,7 @@ msgstr "" "器使用,建立一個屬性的副本,並將相應的存取函式設定為被裝飾的函式。最好用一個" "範例來說明:" -#: ../../builtins/functions.rst:1715 +#: ../../builtins/functions.rst:1728 msgid "" "class C:\n" " def __init__(self):\n" @@ -3074,7 +3068,7 @@ msgstr "" " def x(self):\n" " del self._x" -#: ../../builtins/functions.rst:1734 +#: ../../builtins/functions.rst:1747 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 " @@ -3083,24 +3077,24 @@ msgstr "" "此程式碼與第一個範例完全相等。請務必賦予附加函式與原始屬性相同的名稱(在此例" "中為 ``x``)。" -#: ../../builtins/functions.rst:1738 +#: ../../builtins/functions.rst:1751 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." msgstr "" "回傳的屬性物件也有對應於建構函式引數的屬性 ``fget``、``fset`` 和 ``fdel``。" -#: ../../builtins/functions.rst:1741 +#: ../../builtins/functions.rst:1754 msgid "The docstrings of property objects are now writeable." msgstr "屬性物件的 docstrings 現在可以寫入。" -#: ../../builtins/functions.rst:1746 +#: ../../builtins/functions.rst:1759 msgid "" "Attribute holding the name of the property. The name of the property can be " "changed at runtime." msgstr "持有屬性名稱的屬性。屬性名稱可在 runtime 變更。" -#: ../../builtins/functions.rst:1757 +#: ../../builtins/functions.rst:1770 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." @@ -3108,7 +3102,7 @@ msgstr "" "與其說是函式,:class:`range` 實際上是一個不可變的序列型別,如 :ref:`typesseq-" "range` 和 :ref:`typesseq` 所述。" -#: ../../builtins/functions.rst:1763 +#: ../../builtins/functions.rst:1776 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 " @@ -3127,11 +3121,11 @@ msgstr "" "式對其實例的回傳值。如果 :func:`sys.displayhook` 不可存取,這個函式會引" "發 :exc:`RuntimeError`。" -#: ../../builtins/functions.rst:1774 +#: ../../builtins/functions.rst:1787 msgid "This class has a custom representation that can be evaluated::" msgstr "這個類別有一個自訂的表示,可以被求值: ::" -#: ../../builtins/functions.rst:1776 +#: ../../builtins/functions.rst:1789 msgid "" "class Person:\n" " def __init__(self, name, age):\n" @@ -3139,7 +3133,7 @@ msgid "" " self.age = age\n" "\n" " def __repr__(self):\n" -" return f\"Person('{self.name}', {self.age})\"" +" return f\"Person({self.name!r}, {self.age!r})\"" msgstr "" "class Person:\n" " def __init__(self, name, age):\n" @@ -3147,9 +3141,9 @@ msgstr "" " self.age = age\n" "\n" " def __repr__(self):\n" -" return f\"Person('{self.name}', {self.age})\"" +" return f\"Person({self.name!r}, {self.age!r})\"" -#: ../../builtins/functions.rst:1787 +#: ../../builtins/functions.rst:1800 msgid "" "Return a reverse :term:`iterator`. The argument must be an object which has " "a :meth:`~object.__reversed__` method or supports the sequence protocol " @@ -3161,7 +3155,7 @@ msgstr "" "(即 :meth:`~object.__len__` 方法和以 ``0`` 開始的整數引數" "的 :meth:`~object.__getitem__` 方法)的物件。" -#: ../../builtins/functions.rst:1795 +#: ../../builtins/functions.rst:1808 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 " @@ -3170,7 +3164,7 @@ msgstr "" "回傳小數點後四捨五入到 *ndigits* 精度的 *number*。如果省略 *ndigits* 或為 " "``None``,則會回傳最接近其輸入的整數。" -#: ../../builtins/functions.rst:1799 +#: ../../builtins/functions.rst:1812 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 " @@ -3186,14 +3180,14 @@ msgstr "" "*ndigits* 的任何整數值都是有效的(正數、零或負數)。如果省略 *ndigits* 或為 " "``None``,則回傳值是整數。否則回傳值與 *number* 有相同的型別。" -#: ../../builtins/functions.rst:1808 +#: ../../builtins/functions.rst:1821 msgid "" "For a general Python object ``number``, ``round`` delegates to " "``number.__round__``." msgstr "" "對於一般的 Python 物件 ``number``,``round`` 會委派給 ``number.__round__``。" -#: ../../builtins/functions.rst:1813 +#: ../../builtins/functions.rst:1826 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 " @@ -3205,7 +3199,7 @@ msgstr "" "``2.67`` 而非預期的 ``2.68``。這不是一個 bug:這是因為大多數十進位小數無法精" "確地表示為浮點數。更多資訊請參閱 :ref:`tut-fp-issues`。" -#: ../../builtins/functions.rst:1824 +#: ../../builtins/functions.rst:1837 msgid "" "Return a new :class:`set` object, optionally with elements taken from " "*iterable*. :class:`set` is a built-in class. See also :ref:`types-set` " @@ -3215,7 +3209,7 @@ msgstr "" "素。:class:`set` 是一個內建類別。關於此類別的說明文件亦請參閱 :ref:`types-" "set`。" -#: ../../builtins/functions.rst:1828 +#: ../../builtins/functions.rst:1841 msgid "" "For other containers see the built-" "in :class:`frozenset`, :class:`list`, :class:`tuple`, and :class:`dict` " @@ -3224,7 +3218,7 @@ msgstr "" "關於其他容器,請參閱內建的 :class:`frozenset`、:class:`list`、:class:`tuple` " "和 :class:`dict` 類別,以及 :mod:`collections` 模組。" -#: ../../builtins/functions.rst:1835 +#: ../../builtins/functions.rst:1848 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 " @@ -3236,7 +3230,7 @@ msgstr "" "可以指定一個現有屬性或一個新的屬性。此函式會將值賦予該屬性,前提是該物件允許" "這麼做。例如 ``setattr(x, 'foobar', 123)`` 等效於 ``x.foobar = 123``。" -#: ../../builtins/functions.rst:1841 +#: ../../builtins/functions.rst:1854 msgid "" "*name* need not be a Python identifier as defined in :ref:`identifiers` " "unless the object chooses to enforce that, for example in a " @@ -3249,7 +3243,7 @@ msgstr "" "過 :attr:`~object.__slots__`。名稱不是識別字的屬性將無法使用點記法存取,但可" "以透過 :func:`getattr` 等方式存取。" -#: ../../builtins/functions.rst:1849 +#: ../../builtins/functions.rst:1862 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " @@ -3259,7 +3253,125 @@ msgstr "" "用 :func:`setattr` 設定私有屬性(名稱以兩個底線開頭的屬性),必須手動修飾其名" "稱。" -#: ../../builtins/functions.rst:1858 +#: ../../builtins/functions.rst:1870 +msgid "" +"Return a new unique sentinel object. *name* must be a :class:`str`, and is " +"used by default as the returned object's representation::" +msgstr "" + +#: ../../builtins/functions.rst:1873 +msgid "" +">>> MISSING = sentinel(\"MISSING\")\n" +">>> MISSING\n" +"MISSING" +msgstr "" +">>> MISSING = sentinel(\"MISSING\")\n" +">>> MISSING\n" +"MISSING" + +#: ../../builtins/functions.rst:1877 +msgid "" +"The optional *repr* argument can be used to specify a different " +"representation::" +msgstr "選擇性引數 *repr* 可以被用來指定不同的表示法: ::" + +#: ../../builtins/functions.rst:1879 +msgid "" +">>> MISSING = sentinel(\"MISSING\", repr=\"\")\n" +">>> MISSING\n" +"" +msgstr "" +">>> MISSING = sentinel(\"MISSING\", repr=\"\")\n" +">>> MISSING\n" +"" + +#: ../../builtins/functions.rst:1883 +msgid "" +"Sentinel objects are truthy and compare equal only to themselves. They are " +"intended to be compared with the :keyword:`is` operator." +msgstr "" + +#: ../../builtins/functions.rst:1886 +msgid "``sentinel`` does not support subclassing." +msgstr "" + +#: ../../builtins/functions.rst:1888 +msgid "Shallow and deep copies of a sentinel object return the object itself." +msgstr "" + +#: ../../builtins/functions.rst:1890 +msgid "" +"Sentinels are conventionally assigned to a variable with a matching name. " +"Sentinels defined in this way can be used in :term:`type hints `::" +msgstr "" + +#: ../../builtins/functions.rst:1893 +msgid "" +"MISSING = sentinel(\"MISSING\")\n" +"\n" +"def next_value(default: int | MISSING = MISSING):\n" +" ..." +msgstr "" +"MISSING = sentinel(\"MISSING\")\n" +"\n" +"def next_value(default: int | MISSING = MISSING):\n" +" ..." + +#: ../../builtins/functions.rst:1898 +msgid "" +"Sentinel objects support the :ref:`| ` operator for use in type " +"expressions." +msgstr "" + +#: ../../builtins/functions.rst:1900 +msgid "" +":mod:`Pickling ` is supported for sentinel objects that are placed " +"in the global scope of a module under a name matching the sentinel's name, " +"and for sentinels placed in class scopes with a name matching the :term:" +"`qualified name` of the sentinel. Other sentinels, such as those defined in " +"a function scope, are not picklable. The identity of the sentinel is " +"preserved after pickling::" +msgstr "" + +#: ../../builtins/functions.rst:1907 +msgid "" +"import pickle\n" +"\n" +"PICKLABLE = sentinel(\"PICKLABLE\")\n" +"\n" +"assert pickle.loads(pickle.dumps(PICKLABLE)) is PICKLABLE\n" +"\n" +"class Cls:\n" +" PICKLABLE = sentinel(\"Cls.PICKLABLE\")\n" +"\n" +"assert pickle.loads(pickle.dumps(Cls.PICKLABLE)) is Cls.PICKLABLE" +msgstr "" +"import pickle\n" +"\n" +"PICKLABLE = sentinel(\"PICKLABLE\")\n" +"\n" +"assert pickle.loads(pickle.dumps(PICKLABLE)) is PICKLABLE\n" +"\n" +"class Cls:\n" +" PICKLABLE = sentinel(\"Cls.PICKLABLE\")\n" +"\n" +"assert pickle.loads(pickle.dumps(Cls.PICKLABLE)) is Cls.PICKLABLE" + +#: ../../builtins/functions.rst:1918 +msgid "Sentinel objects have the following attributes:" +msgstr "" + +#: ../../builtins/functions.rst:1922 +msgid "The sentinel's name." +msgstr "" + +#: ../../builtins/functions.rst:1926 +msgid "" +"The name of the module where the sentinel was created. This attribute is " +"writable." +msgstr "" + +#: ../../builtins/functions.rst:1934 msgid "" "Return a :term:`slice` object representing the set of indices specified by " "``range(start, stop, step)``. The *start* and *step* arguments default to " @@ -3268,7 +3380,7 @@ msgstr "" "回傳一個 :term:`slice` 物件,表示由 ``range(start, stop, step)`` 指定的索引集" "合。*start* 和 *step* 引數預設為 ``None``。" -#: ../../builtins/functions.rst:1862 +#: ../../builtins/functions.rst:1938 msgid "" "Slice objects are also generated when :ref:`slicing syntax ` is " "used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``." @@ -3276,7 +3388,7 @@ msgstr "" "Slice 物件也會在使用\\ :ref:`切片語法 `\\ 時產生。例如:" "``a[start:stop:step]`` 或 ``a[start:stop, i]``。" -#: ../../builtins/functions.rst:1865 +#: ../../builtins/functions.rst:1941 msgid "" "See :func:`itertools.islice` for an alternate version that returns " "an :term:`iterator`." @@ -3284,7 +3396,7 @@ msgstr "" "請參閱 :func:`itertools.islice` 以取得回傳\\ :term:`疊代器 `\\ 的替" "代版本。" -#: ../../builtins/functions.rst:1872 +#: ../../builtins/functions.rst:1948 msgid "" "These read-only attributes are set to the argument values (or their " "default). They have no other explicit functionality; however, they are used " @@ -3293,7 +3405,7 @@ msgstr "" "這些唯讀屬性被設定為引數值(或其預設值)。它們沒有其他明確的功能;然而,它們" "會被 NumPy 和其他第三方套件使用。" -#: ../../builtins/functions.rst:1876 +#: ../../builtins/functions.rst:1952 msgid "" "Slice objects are now :term:`hashable` " "(provided :attr:`~slice.start`, :attr:`~slice.stop`, and :attr:`~slice.step` " @@ -3303,16 +3415,16 @@ msgstr "" "是 :attr:`~slice.start`、:attr:`~slice.stop` 和 :attr:`~slice.step` 都是可雜" "湊的)。" -#: ../../builtins/functions.rst:1882 +#: ../../builtins/functions.rst:1958 msgid "Return a new sorted list from the items in *iterable*." msgstr "從 *iterable* 中的項目回傳一個新的已排序 list。" -#: ../../builtins/functions.rst:1884 +#: ../../builtins/functions.rst:1960 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "有兩個選擇性引數,只能使用關鍵字引數來指定。" -#: ../../builtins/functions.rst:1886 +#: ../../builtins/functions.rst:1962 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each element in *iterable* (for example, " @@ -3322,7 +3434,7 @@ msgstr "" "*key* 指定一個具有一個引數的函式,用於從 *iterable* 中的每個元素提取比較鍵" "(例如 ``key=str.lower``)。預設值為 ``None``\\(直接比較元素)。" -#: ../../builtins/functions.rst:1890 +#: ../../builtins/functions.rst:1966 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." @@ -3330,14 +3442,14 @@ msgstr "" "*reverse* 是一個布林值。如果設為 ``True``,則 list 元素的排序方式如同每次比較" "都被反轉一樣。" -#: ../../builtins/functions.rst:1893 +#: ../../builtins/functions.rst:1969 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." msgstr "" "使用 :func:`functools.cmp_to_key` 將舊式的 *cmp* 函式轉換為 *key* 函式。" -#: ../../builtins/functions.rst:1896 +#: ../../builtins/functions.rst:1972 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 " @@ -3348,7 +3460,7 @@ msgstr "" "等的元素之間的相對順序,就是穩定的 --- 這對於多次排序很有幫助(例如,先按部門" "排序,再按薪資等級排序)。" -#: ../../builtins/functions.rst:1901 +#: ../../builtins/functions.rst:1977 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3365,23 +3477,23 @@ msgstr "" "的 :func:`max`)時產生錯誤。實作全部六個比較也有助於避免混合型別比較時的混" "淆,因為這種比較可能會呼叫被反映的 :meth:`~object.__gt__` 方法。" -#: ../../builtins/functions.rst:1910 +#: ../../builtins/functions.rst:1986 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "有關排序的範例和簡要的排序教學,請參閱 :ref:`sortinghowto`。" -#: ../../builtins/functions.rst:1914 +#: ../../builtins/functions.rst:1990 msgid "Transform a method into a static method." msgstr "將一個方法轉換為靜態方法 (static method)。" -#: ../../builtins/functions.rst:1916 +#: ../../builtins/functions.rst:1992 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" "靜態方法不會接收隱含的第一個引數。要宣告一個靜態方法,請使用以下慣用寫法: ::" -#: ../../builtins/functions.rst:1919 +#: ../../builtins/functions.rst:1995 msgid "" "class C:\n" " @staticmethod\n" @@ -3391,7 +3503,7 @@ msgstr "" " @staticmethod\n" " def f(arg1, arg2, argN): ..." -#: ../../builtins/functions.rst:1923 +#: ../../builtins/functions.rst:1999 msgid "" "The ``@staticmethod`` form is a function :term:`decorator` -- " "see :ref:`function` for details." @@ -3399,7 +3511,7 @@ msgstr "" "``@staticmethod`` 語法是一個函式 :term:`decorator` - 參見 :ref:`function` 中" "的詳細介紹。" -#: ../../builtins/functions.rst:1926 +#: ../../builtins/functions.rst:2002 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 " @@ -3410,14 +3522,14 @@ msgstr "" "``C().f()``)。此外,靜態方法的\\ :term:`描述器 `\\ 也是可呼叫" "的,因此可以在類別定義中使用(例如 ``f()``)。" -#: ../../builtins/functions.rst:1931 +#: ../../builtins/functions.rst:2007 msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :deco:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" -#: ../../builtins/functions.rst:1935 +#: ../../builtins/functions.rst:2011 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 " @@ -3429,7 +3541,7 @@ msgstr "" "作。這在某些情況下是必要的,例如當你需要從類別主體中引用一個函式,且希望避免" "自動轉換為實例方法時。對於這些情況,請使用以下慣用寫法: ::" -#: ../../builtins/functions.rst:1941 +#: ../../builtins/functions.rst:2017 msgid "" "def regular_function():\n" " ...\n" @@ -3443,11 +3555,11 @@ msgstr "" "class C:\n" " method = staticmethod(regular_function)" -#: ../../builtins/functions.rst:1947 +#: ../../builtins/functions.rst:2023 msgid "For more information on static methods, see :ref:`types`." msgstr "關於 static method 的更多資訊,請參考 :ref:`types`。" -#: ../../builtins/functions.rst:1949 +#: ../../builtins/functions.rst:2025 msgid "" "Static methods now inherit the method attributes " "(:attr:`~function.__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__` " @@ -3459,12 +3571,12 @@ msgstr "" "和 :attr:`~function.__annotations__`),並擁有一個新的 ``__wrapped__`` 屬性," "且為如一般函式的可呼叫物件。" -#: ../../builtins/functions.rst:1967 +#: ../../builtins/functions.rst:2043 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." msgstr "回傳 *object* 的 :class:`str` 版本。詳細資訊請參閱 :func:`str`。" -#: ../../builtins/functions.rst:1969 +#: ../../builtins/functions.rst:2045 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." @@ -3472,7 +3584,7 @@ msgstr "" "``str`` 是內建的字串\\ :term:`類別 `。有關字串的一般資訊,請參" "閱 :ref:`textseq`。" -#: ../../builtins/functions.rst:1975 +#: ../../builtins/functions.rst:2051 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 " @@ -3481,7 +3593,7 @@ msgstr "" "從左到右加總 *start* 和一個 *iterable* 的項目並回傳總和。*iterable* 的項目通" "常是數字,且 start 值不允許為字串。" -#: ../../builtins/functions.rst:1979 +#: ../../builtins/functions.rst:2055 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 " @@ -3494,24 +3606,24 @@ msgstr "" "閱 :func:`math.fsum`。要串接一系列可疊代物件,請考慮使" "用 :func:`itertools.chain`。" -#: ../../builtins/functions.rst:1985 +#: ../../builtins/functions.rst:2061 msgid "The *start* parameter can be specified as a keyword argument." msgstr "*start* 參數可被指定為關鍵字引數。" -#: ../../builtins/functions.rst:1988 +#: ../../builtins/functions.rst:2064 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" "浮點數的加總已切換到一個在大多數建置上提供更高精確度和更好交換律的演算法。" -#: ../../builtins/functions.rst:1991 +#: ../../builtins/functions.rst:2067 msgid "" "Added specialization for summation of complexes, using same algorithm as for " "summation of floats." msgstr "新增了複數加總的特化處理,使用與浮點數加總相同的演算法。" -#: ../../builtins/functions.rst:1999 +#: ../../builtins/functions.rst:2075 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 " @@ -3520,7 +3632,7 @@ msgstr "" "回傳一個代理物件,該物件會將方法呼叫委派給 *type* 的父類別或兄弟類別。這對於" "存取在類別中被覆寫的繼承方法很有用。" -#: ../../builtins/functions.rst:2003 +#: ../../builtins/functions.rst:2079 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." @@ -3528,7 +3640,7 @@ msgstr "" "*object_or_type* 決定了要搜尋的\\ :term:`方法解析順序 `。搜尋從 *type* 之後的類別開始。" -#: ../../builtins/functions.rst:2007 +#: ../../builtins/functions.rst:2083 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` " @@ -3538,7 +3650,7 @@ msgstr "" "A -> object``,且 *type* 的值是 ``B``,則 :func:`super` 會搜尋 ``C -> A -> " "object``。" -#: ../../builtins/functions.rst:2011 +#: ../../builtins/functions.rst:2087 msgid "" "The :attr:`~type.__mro__` attribute of the class corresponding to " "*object_or_type* lists the method resolution search order used by " @@ -3549,7 +3661,7 @@ msgstr "" "了 :func:`getattr` 和 :func:`super` 所使用的方法解析搜尋順序。該屬性是動態" "的,每當繼承階層被更新時就可能改變。" -#: ../../builtins/functions.rst:2016 +#: ../../builtins/functions.rst:2092 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. " @@ -3560,7 +3672,7 @@ msgstr "" "``isinstance(obj, type)`` 必須為真。如果第二個引數是一個型別," "``issubclass(type2, type)`` 必須為真(這對類別方法很有用)。" -#: ../../builtins/functions.rst:2021 +#: ../../builtins/functions.rst:2097 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 " @@ -3574,7 +3686,7 @@ msgstr "" "一個引數(通常是 ``self``)。(這意味著零引數 :func:`!super` 在巢狀函式中將無" "法如預期般運作,包括隱式建立巢狀函式的產生器運算式。)" -#: ../../builtins/functions.rst:2028 +#: ../../builtins/functions.rst:2104 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 " @@ -3585,7 +3697,7 @@ msgstr "" "照父類別而不需要明確命名它們,從而使程式碼更易於維護。這種用法與 *super* 在其" "他程式語言中的用法非常相似。" -#: ../../builtins/functions.rst:2033 +#: ../../builtins/functions.rst:2109 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 " @@ -3603,11 +3715,11 @@ msgstr "" "這些實作在每種情況下都有相同的呼叫簽名(因為呼叫順序是在執行期決定的,因為該" "順序會適應類別階層的變化,也因為該順序可以包含在執行期之前未知的兄弟類別)。" -#: ../../builtins/functions.rst:2043 +#: ../../builtins/functions.rst:2119 msgid "For both use cases, a typical superclass call looks like this::" msgstr "對於這兩種使用情境,一個典型的超類別呼叫如下: ::" -#: ../../builtins/functions.rst:2045 +#: ../../builtins/functions.rst:2121 msgid "" "class C(B):\n" " def method(self, arg):\n" @@ -3619,7 +3731,7 @@ msgstr "" " super().method(arg) # 這和以下做法相同:\n" " # super(C, self).method(arg)" -#: ../../builtins/functions.rst:2050 +#: ../../builtins/functions.rst:2126 msgid "" "In addition to method lookups, :func:`super` also works for attribute " "lookups. One possible use case for this is calling :term:`descriptors " @@ -3628,7 +3740,7 @@ msgstr "" "除了方法查找之外,:func:`super` 也適用於屬性查找。這個功能的一個可能使用情境" "是在父類別或兄弟類別中呼叫\\ :term:`描述器 `。" -#: ../../builtins/functions.rst:2054 +#: ../../builtins/functions.rst:2130 msgid "" "Note that :func:`super` is implemented as part of the binding process for " "explicit dotted attribute lookups such as ``super().__getitem__(name)``. It " @@ -3643,7 +3755,7 @@ msgstr "" "式多重繼承。因此,:func:`super` 對於使用陳述式或運算子的隱式查找(例如 " "``super()[name]``)是未定義的。" -#: ../../builtins/functions.rst:2062 +#: ../../builtins/functions.rst:2138 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 " @@ -3657,7 +3769,7 @@ msgstr "" "編譯器會填入必要的細節以正確地取得正在被定義的類別,以及存取一般方法的目前實" "例。" -#: ../../builtins/functions.rst:2069 +#: ../../builtins/functions.rst:2145 msgid "" "For practical suggestions on how to design cooperative classes " "using :func:`super`, see `guide to using super() `_。" -#: ../../builtins/functions.rst:2073 +#: ../../builtins/functions.rst:2149 msgid "" ":class:`super` objects are now :mod:`pickleable ` " "and :mod:`copyable `." @@ -3675,7 +3787,7 @@ msgstr "" ":class:`super` 物件現在可以使用 :mod:`pickle ` 序列化以及使" "用 :mod:`copy ` 複製。" -#: ../../builtins/functions.rst:2082 +#: ../../builtins/functions.rst:2158 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." @@ -3683,7 +3795,7 @@ msgstr "" ":class:`tuple` 實際上不是一個函式,而是一個不可變的序列型別," "如 :ref:`typesseq-tuple` 和 :ref:`typesseq` 中所述。" -#: ../../builtins/functions.rst:2091 +#: ../../builtins/functions.rst:2167 msgid "" "With one argument, return the type of an *object*. The return value is a " "type object and generally the same object as returned " @@ -3692,7 +3804,7 @@ msgstr "" "傳入一個引數時,回傳一個 *object* 的型別。回傳值是一個型別物件,通常" "與 :attr:`object.__class__` 所回傳的物件相同。" -#: ../../builtins/functions.rst:2095 +#: ../../builtins/functions.rst:2171 msgid "" "The :func:`isinstance` built-in function is recommended for testing the type " "of an object, because it takes subclasses into account." @@ -3700,7 +3812,7 @@ msgstr "" "建議使用內建函式 :func:`isinstance` 來測試物件的型別,因為它會將子類別納入考" "量。" -#: ../../builtins/functions.rst:2098 +#: ../../builtins/functions.rst:2174 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 " @@ -3719,21 +3831,21 @@ msgstr "" "義;它可能會被複製或包裝後才成為 :attr:`~type.__dict__` 屬性。以下兩個陳述式" "會建立相同的 :class:`!type` 物件:" -#: ../../builtins/functions.rst:2113 +#: ../../builtins/functions.rst:2189 msgid "See also:" msgstr "另請參閱:" -#: ../../builtins/functions.rst:2115 +#: ../../builtins/functions.rst:2191 msgid "" ":ref:`Documentation on attributes and methods on classes `." msgstr ":ref:`類別的屬性和方法的文件 `。" -#: ../../builtins/functions.rst:2116 +#: ../../builtins/functions.rst:2192 msgid ":ref:`bltin-type-objects`" msgstr ":ref:`bltin-type-objects`" -#: ../../builtins/functions.rst:2118 +#: ../../builtins/functions.rst:2194 msgid "" "Keyword arguments provided to the three argument form are passed to the " "appropriate metaclass machinery (usually :meth:`~object.__init_subclass__`) " @@ -3744,7 +3856,7 @@ msgstr "" "相同的方式,傳遞給適當的元類別機制(通常" "是 :meth:`~object.__init_subclass__`)。" -#: ../../builtins/functions.rst:2123 +#: ../../builtins/functions.rst:2199 msgid "" "Unlike a :keyword:`class` statement, the three argument form does not call " "the metaclass ``__prepare__`` method (see :ref:`prepare`). " @@ -3752,11 +3864,11 @@ msgid "" "appropriate metaclass." msgstr "" -#: ../../builtins/functions.rst:2128 +#: ../../builtins/functions.rst:2204 msgid "See also :ref:`class-customization`." msgstr "另請參閱 :ref:`class-customization`。" -#: ../../builtins/functions.rst:2130 +#: ../../builtins/functions.rst:2206 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." @@ -3764,7 +3876,11 @@ msgstr "" "沒有覆寫 ``type.__new__`` 的 :class:`!type` 子類別不能再使用單引數形式來取得" "物件的型別。" -#: ../../builtins/functions.rst:2137 +#: ../../builtins/functions.rst:2212 +msgid "*dict* can now be a :class:`frozendict`." +msgstr "" + +#: ../../builtins/functions.rst:2217 msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " "or any other object with a :attr:`!__dict__` attribute." @@ -3772,7 +3888,7 @@ msgstr "" "回傳模組、類別、實例或任何其他具有 :attr:`!__dict__` 屬性的物件" "的 :attr:`~object.__dict__` 屬性。" -#: ../../builtins/functions.rst:2140 +#: ../../builtins/functions.rst:2220 msgid "" "Objects such as modules and instances have an " "updateable :attr:`~object.__dict__` attribute; however, other objects may " @@ -3784,11 +3900,11 @@ msgstr "" "物件的 :attr:`!__dict__` 屬性可能有寫入限制(例如,類別使" "用 :class:`types.MappingProxyType` 來防止直接更新字典)。" -#: ../../builtins/functions.rst:2145 +#: ../../builtins/functions.rst:2225 msgid "Without an argument, :func:`vars` acts like :func:`locals`." msgstr "不帶引數時,:func:`vars` 的行為與 :func:`locals` 相同。" -#: ../../builtins/functions.rst:2147 +#: ../../builtins/functions.rst:2227 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 " @@ -3797,23 +3913,23 @@ msgstr "" "如果指定了一個物件但它沒有 :attr:`~object.__dict__` 屬性(例如,如果它的類別" "定義了 :attr:`~object.__slots__` 屬性),則會引發 :exc:`TypeError` 例外。" -#: ../../builtins/functions.rst:2153 +#: ../../builtins/functions.rst:2233 msgid "" "The result of calling this function without an argument has been updated as " "described for the :func:`locals` builtin." msgstr "不帶引數呼叫此函式的結果已按照內建函式 :func:`locals` 的說明進行更新。" -#: ../../builtins/functions.rst:2159 +#: ../../builtins/functions.rst:2239 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." msgstr "平行疊代多個可疊代物件,產生包含每個可疊代物件中一個項目的 tuple。" -#: ../../builtins/functions.rst:2162 +#: ../../builtins/functions.rst:2242 msgid "Example::" msgstr "例如: ::" -#: ../../builtins/functions.rst:2164 +#: ../../builtins/functions.rst:2244 msgid "" ">>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" "... print(item)\n" @@ -3829,7 +3945,7 @@ msgstr "" "(2, 'spice')\n" "(3, 'everything nice')" -#: ../../builtins/functions.rst:2171 +#: ../../builtins/functions.rst:2251 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." @@ -3837,7 +3953,7 @@ msgstr "" "更正式地說::func:`zip` 回傳一個由 tuple 組成的疊代器,其中第 *i* 個 tuple 包" "含來自每個引數可疊代物件的第 *i* 個元素。" -#: ../../builtins/functions.rst:2174 +#: ../../builtins/functions.rst:2254 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 `_。" -#: ../../builtins/functions.rst:2178 +#: ../../builtins/functions.rst:2258 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 " @@ -3855,7 +3971,7 @@ msgstr "" ":func:`zip` 是惰性的 (lazy):元素在可疊代物件被疊代之前不會被處理,例如透過一" "個 :keyword:`!for` 迴圈或包裝在一個 :class:`list` 中。" -#: ../../builtins/functions.rst:2182 +#: ../../builtins/functions.rst:2262 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 " @@ -3866,14 +3982,14 @@ msgstr "" "刻意設計的,有時候是因為準備這些可疊代物件的程式碼中的錯誤。Python 提供三種不" "同的方式來處理這個問題:" -#: ../../builtins/functions.rst:2187 +#: ../../builtins/functions.rst:2267 msgid "" "By default, :func:`zip` stops when the shortest iterable " "is :term:`exhausted`. It will ignore the remaining items in the longer " "iterables, cutting off the result to the length of the shortest iterable::" msgstr "" -#: ../../builtins/functions.rst:2191 +#: ../../builtins/functions.rst:2271 msgid "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" @@ -3881,7 +3997,7 @@ msgstr "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" -#: ../../builtins/functions.rst:2194 +#: ../../builtins/functions.rst:2274 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`` " @@ -3890,7 +4006,7 @@ msgstr "" ":func:`zip` 常常用於可疊代物件被假設等長的情況。在這種情況下,建議使用 " "``strict=True`` 選項。它的輸出與一般的 :func:`zip` 相同: ::" -#: ../../builtins/functions.rst:2198 +#: ../../builtins/functions.rst:2278 msgid "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" @@ -3898,13 +4014,13 @@ msgstr "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" -#: ../../builtins/functions.rst:2201 +#: ../../builtins/functions.rst:2281 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is :term:`exhausted` before the others:" msgstr "" -#: ../../builtins/functions.rst:2219 +#: ../../builtins/functions.rst:2299 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 " @@ -3913,7 +4029,7 @@ msgstr "" "如果沒有 ``strict=True`` 引數,任何導致可疊代物件長度不同的 bug 都會被隱藏," "可能會在程式的其他部分表現為難以發現的 bug。" -#: ../../builtins/functions.rst:2223 +#: ../../builtins/functions.rst:2303 msgid "" "Shorter iterables can be padded with a constant value to make all the " "iterables have the same length. This is done " @@ -3922,7 +4038,7 @@ msgstr "" "較短的可疊代物件可以填充常數值,使所有可疊代物件的長度相同。這可以透" "過 :func:`itertools.zip_longest` 來完成。" -#: ../../builtins/functions.rst:2227 +#: ../../builtins/functions.rst:2307 msgid "" "Edge cases: With a single iterable argument, :func:`zip` returns an iterator " "of 1-tuples. With no arguments, it returns an empty iterator." @@ -3930,11 +4046,11 @@ msgstr "" "邊界情況:對於單一可疊代引數,:func:`zip` 會回傳一個 1-tuple 的疊代器。如果沒" "有引數,它會回傳一個空的疊代器。" -#: ../../builtins/functions.rst:2230 +#: ../../builtins/functions.rst:2310 msgid "Tips and tricks:" msgstr "秘訣與技巧:" -#: ../../builtins/functions.rst:2232 +#: ../../builtins/functions.rst:2312 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 " @@ -3947,13 +4063,13 @@ msgstr "" "同的*\\ 疊代器 ``n`` 次,因此每個輸出 tuple 會有 ``n`` 次呼叫疊代器的結果。這" "樣做的效果是將輸入分割成 n 個長度的區塊。" -#: ../../builtins/functions.rst:2238 +#: ../../builtins/functions.rst:2318 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr ":func:`zip` 與 ``*`` 運算子結合可以用來解壓縮 (unzip) 一個 list: ::" -#: ../../builtins/functions.rst:2241 +#: ../../builtins/functions.rst:2321 msgid "" ">>> x = [1, 2, 3]\n" ">>> y = [4, 5, 6]\n" @@ -3971,11 +4087,11 @@ msgstr "" ">>> x == list(x2) and y == list(y2)\n" "True" -#: ../../builtins/functions.rst:2249 +#: ../../builtins/functions.rst:2329 msgid "Added the ``strict`` argument." msgstr "增加了 ``strict`` 引數。" -#: ../../builtins/functions.rst:2261 +#: ../../builtins/functions.rst:2341 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." @@ -3983,7 +4099,7 @@ msgstr "" "這是一個進階的函式,不像 :func:`importlib.import_module`,這在日常 Python 程" "式設計中並不需要。" -#: ../../builtins/functions.rst:2264 +#: ../../builtins/functions.rst:2344 msgid "" "This function is invoked by the :keyword:`import` statement. It can be " "replaced (by importing the :mod:`builtins` module and assigning to " @@ -4001,7 +4117,7 @@ msgstr "" "import 實作的程式碼問題。我們也不鼓勵直接使用 :func:`__import__`,而應改" "用 :func:`importlib.import_module`。" -#: ../../builtins/functions.rst:2273 +#: ../../builtins/functions.rst:2353 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -4015,7 +4131,7 @@ msgstr "" "模組的名稱。標準的實作完全不使用 *locals* 引數,而只使用 *globals* 來決" "定 :keyword:`import` 陳述式的套件情境。" -#: ../../builtins/functions.rst:2280 +#: ../../builtins/functions.rst:2360 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -4027,7 +4143,7 @@ msgstr "" "正值表示相對於呼叫 :func:`__import__` 的模組目錄要搜尋的父目錄數目(參" "見 :pep:`328` 以了解詳情)。" -#: ../../builtins/functions.rst:2286 +#: ../../builtins/functions.rst:2366 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 " @@ -4038,26 +4154,26 @@ msgstr "" "一個點為止的名稱),而\\ *不是* *name* 所命名的模組。然而,當給予一個非空的 " "*fromlist* 引數時,會回傳以 *name* 命名的模組。" -#: ../../builtins/functions.rst:2291 +#: ../../builtins/functions.rst:2371 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" msgstr "" "例如,陳述式 ``import spam`` 會產生類似以下程式碼的位元組碼 (bytecode): ::" -#: ../../builtins/functions.rst:2294 +#: ../../builtins/functions.rst:2374 msgid "spam = __import__('spam', globals(), locals(), [], 0)" msgstr "spam = __import__('spam', globals(), locals(), [], 0)" -#: ../../builtins/functions.rst:2296 +#: ../../builtins/functions.rst:2376 msgid "The statement ``import spam.ham`` results in this call::" msgstr "陳述式 ``import spam.ham`` 的結果是這樣的呼叫: ::" -#: ../../builtins/functions.rst:2298 +#: ../../builtins/functions.rst:2378 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" -#: ../../builtins/functions.rst:2300 +#: ../../builtins/functions.rst:2380 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." @@ -4065,14 +4181,14 @@ msgstr "" "請注意 :func:`__import__` 在這裡如何回傳頂層模組(toplevel module),因為這是" "由 :keyword:`import` 陳述式綁定名稱的物件。" -#: ../../builtins/functions.rst:2303 +#: ../../builtins/functions.rst:2383 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" msgstr "" "另一方面,陳述式 ``from spam.ham import eggs, sausage as saus`` 結果是: ::" -#: ../../builtins/functions.rst:2306 +#: ../../builtins/functions.rst:2386 msgid "" "_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" "eggs = _temp.eggs\n" @@ -4082,7 +4198,7 @@ msgstr "" "eggs = _temp.eggs\n" "saus = _temp.sausage" -#: ../../builtins/functions.rst:2310 +#: ../../builtins/functions.rst:2390 msgid "" "Here, the ``spam.ham`` module is returned from :func:`__import__`. From " "this object, the names to import are retrieved and assigned to their " @@ -4091,7 +4207,7 @@ msgstr "" "這裡,``spam.ham`` 模組會從 :func:`__import__` 回傳。從這個物件中,要引入的名" "稱會被擷取並指定給它們各自的名稱。" -#: ../../builtins/functions.rst:2314 +#: ../../builtins/functions.rst:2394 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." @@ -4099,13 +4215,13 @@ msgstr "" "如果你只想依名稱引入一個模組(可能在套件中),請使" "用 :func:`importlib.import_module`。" -#: ../../builtins/functions.rst:2317 +#: ../../builtins/functions.rst:2397 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." msgstr "不再支援 *level* 的負值(這也將預設值變為 0)。" -#: ../../builtins/functions.rst:2321 +#: ../../builtins/functions.rst:2401 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." @@ -4113,11 +4229,11 @@ msgstr "" "當使用命令列選項 :option:`-E` 或 :option:`-I` 時,環境變" "數 :envvar:`PYTHONCASEOK` 現在會被忽略。" -#: ../../builtins/functions.rst:2326 +#: ../../builtins/functions.rst:2406 msgid "Footnotes" msgstr "註腳" -#: ../../builtins/functions.rst:2327 +#: ../../builtins/functions.rst:2407 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 " @@ -4126,110 +4242,162 @@ msgstr "" "剖析器只接受 Unix 風格的行結束符。如果你從檔案中讀取程式碼,請確保用換行符號" "轉換模式轉換 Windows 或 Mac 風格的換行符號。" -#: ../../builtins/functions.rst:156 +#: ../../builtins/functions.rst:158 msgid "Boolean" msgstr "Boolean(布林值)" -#: ../../builtins/functions.rst:156 ../../builtins/functions.rst:2089 +#: ../../builtins/functions.rst:158 ../../builtins/functions.rst:2165 msgid "type" msgstr "type(型別)" -#: ../../builtins/functions.rst:669 +#: ../../builtins/functions.rst:684 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../builtins/functions.rst:669 +#: ../../builtins/functions.rst:684 msgid "exec" msgstr "exec" -#: ../../builtins/functions.rst:768 +#: ../../builtins/functions.rst:787 msgid "NaN" msgstr "NaN" -#: ../../builtins/functions.rst:768 +#: ../../builtins/functions.rst:787 msgid "Infinity" msgstr "Infinity(無窮)" -#: ../../builtins/functions.rst:838 +#: ../../builtins/functions.rst:857 msgid "__format__" msgstr "__format__" -#: ../../builtins/functions.rst:838 ../../builtins/functions.rst:1957 +#: ../../builtins/functions.rst:857 ../../builtins/functions.rst:2033 msgid "string" msgstr "string(字串)" -#: ../../builtins/functions.rst:838 +#: ../../builtins/functions.rst:857 msgid "format() (built-in function)" msgstr "format()(內建函式)" -#: ../../builtins/functions.rst:1352 +#: ../../builtins/functions.rst:1386 msgid "file object" msgstr "file object(檔案物件)" -#: ../../builtins/functions.rst:1352 ../../builtins/functions.rst:1473 +#: ../../builtins/functions.rst:1386 ../../builtins/functions.rst:1482 msgid "open() built-in function" msgstr "open() 內建函式" -#: ../../builtins/functions.rst:1380 +#: ../../builtins/functions.rst:1415 msgid "file" msgstr "file(檔案)" -#: ../../builtins/functions.rst:1380 +#: ../../builtins/functions.rst:1415 msgid "modes" msgstr "modes(模式)" -#: ../../builtins/functions.rst:1473 +#: ../../builtins/functions.rst:1482 msgid "universal newlines" msgstr "universal newlines" -#: ../../builtins/functions.rst:1534 +#: ../../builtins/functions.rst:1543 msgid "line-buffered I/O" msgstr "line-buffered I/O(行緩衝 I/O)" -#: ../../builtins/functions.rst:1534 +#: ../../builtins/functions.rst:1543 msgid "unbuffered I/O" msgstr "unbuffered I/O(非緩衝 I/O)" -#: ../../builtins/functions.rst:1534 +#: ../../builtins/functions.rst:1543 msgid "buffer size, I/O" msgstr "buffer size, I/O(緩衝區大小、I/O)" -#: ../../builtins/functions.rst:1534 +#: ../../builtins/functions.rst:1543 msgid "I/O control" msgstr "I/O control(I/O 控制)" -#: ../../builtins/functions.rst:1534 +#: ../../builtins/functions.rst:1543 msgid "buffering" msgstr "buffering(緩衝)" -#: ../../builtins/functions.rst:1534 +#: ../../builtins/functions.rst:1543 msgid "text mode" msgstr "text mode(文字模式)" -#: ../../builtins/functions.rst:1534 ../../builtins/functions.rst:2255 +#: ../../builtins/functions.rst:1543 ../../builtins/functions.rst:2335 msgid "module" msgstr "module(模組)" -#: ../../builtins/functions.rst:1534 +#: ../../builtins/functions.rst:1543 msgid "sys" msgstr "sys" -#: ../../builtins/functions.rst:1957 +#: ../../builtins/functions.rst:2033 msgid "str() (built-in function)" msgstr "str() (內建函式)" -#: ../../builtins/functions.rst:2089 +#: ../../builtins/functions.rst:2165 msgid "object" msgstr "object(物件)" -#: ../../builtins/functions.rst:2255 +#: ../../builtins/functions.rst:2335 msgid "statement" msgstr "statement(陳述式)" -#: ../../builtins/functions.rst:2255 +#: ../../builtins/functions.rst:2335 msgid "import" msgstr "import(引入)" -#: ../../builtins/functions.rst:2255 +#: ../../builtins/functions.rst:2335 msgid "builtins" msgstr "builtins(內建)" + +#~ msgid "" +#~ "``'strict'`` to raise a :exc:`ValueError` exception if there is an " +#~ "encoding error. The default value of ``None`` has the same effect." +#~ msgstr "" +#~ "``'strict'`` 如果發生編碼錯誤,則引發 :exc:`ValueError` 例外。預設值 " +#~ "``None`` 也有相同的效果。" + +#~ msgid "" +#~ "``'ignore'`` ignores errors. Note that ignoring encoding errors can lead " +#~ "to data loss." +#~ msgstr "``'ignore'`` 忽略錯誤。請注意,忽略編碼錯誤可能導致資料遺失。" + +#~ msgid "" +#~ "``'replace'`` causes a replacement marker (such as ``'?'``) to be " +#~ "inserted where there is malformed data." +#~ msgstr "" +#~ "``'replace'`` 會在格式不正確的資料位置插入一個替換標誌(像是 ``'?'``)。" + +#~ msgid "" +#~ "``'surrogateescape'`` will represent any incorrect bytes as low surrogate " +#~ "code units ranging from U+DC80 to U+DCFF. These surrogate code units will " +#~ "then be turned back into the same bytes when the ``surrogateescape`` " +#~ "error handler is used when writing data. This is useful for processing " +#~ "files in an unknown encoding." +#~ msgstr "" +#~ "``'surrogateescape'`` 會將任何不正確的位元組表示為低位代理碼元 (low " +#~ "surrogate code unit),範圍從 U+DC80 到 U+DCFF。在寫入資料時,這些代理碼元" +#~ "將會被還原回 ``surrogateescape`` 錯誤處理程式當時所處理的那些相同位元組。" +#~ "這對於處理未知編碼方式的檔案會很好用。" + +#~ msgid "" +#~ "``'xmlcharrefreplace'`` is only supported when writing to a file. " +#~ "Characters not supported by the encoding are replaced with the " +#~ "appropriate XML character reference :samp:`&#{nnn};`." +#~ msgstr "" +#~ "``'xmlcharrefreplace'`` 僅在寫入檔案時可支援。編碼系統不支援的字元會被替換" +#~ "為適當的 XML 字元參考 (character reference) ``&#nnn;``。" + +#~ msgid "" +#~ "``'backslashreplace'`` replaces malformed data by Python's backslashed " +#~ "escape sequences." +#~ msgstr "" +#~ "``'backslashreplace'`` 會用 Python 的反斜線跳脫序列 (backslashed escape " +#~ "sequence) 替換格式不正確的資料。" + +#~ msgid "" +#~ "``'namereplace'`` (also only supported when writing) replaces unsupported " +#~ "characters with ``\\N{...}`` escape sequences." +#~ msgstr "" +#~ "``'namereplace'``\\ (也僅在寫入時支援)會將不支援的字元替換為 ``\\N{...}" +#~ "`` 跳脫序列。" diff --git a/builtins/stdtypes.po b/builtins/stdtypes.po index d6a317fee56..978a98a5b8a 100644 --- a/builtins/stdtypes.po +++ b/builtins/stdtypes.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-14 00:21+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-06-12 15:22+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -126,21 +126,21 @@ msgstr "下方為 Boolean 運算,按優先順序排序:" #: ../../builtins/stdtypes.rst:88 ../../builtins/stdtypes.rst:146 #: ../../builtins/stdtypes.rst:292 ../../builtins/stdtypes.rst:382 -#: ../../builtins/stdtypes.rst:432 ../../builtins/stdtypes.rst:1018 -#: ../../builtins/stdtypes.rst:1242 +#: ../../builtins/stdtypes.rst:432 ../../builtins/stdtypes.rst:1289 +#: ../../builtins/stdtypes.rst:1513 msgid "Operation" msgstr "運算" #: ../../builtins/stdtypes.rst:88 ../../builtins/stdtypes.rst:292 #: ../../builtins/stdtypes.rst:382 ../../builtins/stdtypes.rst:432 -#: ../../builtins/stdtypes.rst:1018 ../../builtins/stdtypes.rst:1242 +#: ../../builtins/stdtypes.rst:1289 ../../builtins/stdtypes.rst:1513 msgid "Result" msgstr "結果" #: ../../builtins/stdtypes.rst:88 ../../builtins/stdtypes.rst:292 -#: ../../builtins/stdtypes.rst:432 ../../builtins/stdtypes.rst:1018 -#: ../../builtins/stdtypes.rst:1242 ../../builtins/stdtypes.rst:3201 -#: ../../builtins/stdtypes.rst:4475 +#: ../../builtins/stdtypes.rst:432 ../../builtins/stdtypes.rst:1289 +#: ../../builtins/stdtypes.rst:1513 ../../builtins/stdtypes.rst:3484 +#: ../../builtins/stdtypes.rst:4786 msgid "Notes" msgstr "註解" @@ -152,9 +152,9 @@ msgstr "``x or y``" msgid "if *x* is true, then *x*, else *y*" msgstr "假如 *x* 為真,則 *x*,否則 *y*" -#: ../../builtins/stdtypes.rst:90 ../../builtins/stdtypes.rst:1020 -#: ../../builtins/stdtypes.rst:1023 ../../builtins/stdtypes.rst:1257 -#: ../../builtins/stdtypes.rst:3207 ../../builtins/stdtypes.rst:4481 +#: ../../builtins/stdtypes.rst:90 ../../builtins/stdtypes.rst:1291 +#: ../../builtins/stdtypes.rst:1294 ../../builtins/stdtypes.rst:1528 +#: ../../builtins/stdtypes.rst:3490 ../../builtins/stdtypes.rst:4792 msgid "\\(1)" msgstr "\\(1)" @@ -167,9 +167,9 @@ msgid "if *x* is false, then *x*, else *y*" msgstr "假如 *x* 為假,則 *x*,否則 *y*" #: ../../builtins/stdtypes.rst:93 ../../builtins/stdtypes.rst:305 -#: ../../builtins/stdtypes.rst:325 ../../builtins/stdtypes.rst:1268 -#: ../../builtins/stdtypes.rst:3211 ../../builtins/stdtypes.rst:3213 -#: ../../builtins/stdtypes.rst:4485 ../../builtins/stdtypes.rst:4487 +#: ../../builtins/stdtypes.rst:325 ../../builtins/stdtypes.rst:1539 +#: ../../builtins/stdtypes.rst:3494 ../../builtins/stdtypes.rst:3496 +#: ../../builtins/stdtypes.rst:4796 ../../builtins/stdtypes.rst:4798 msgid "\\(2)" msgstr "\\(2)" @@ -181,18 +181,18 @@ msgstr "``not x``" msgid "if *x* is false, then ``True``, else ``False``" msgstr "假如 *x* 為假,則 ``True``,否則 ``False``" -#: ../../builtins/stdtypes.rst:96 ../../builtins/stdtypes.rst:3215 -#: ../../builtins/stdtypes.rst:3217 ../../builtins/stdtypes.rst:3219 -#: ../../builtins/stdtypes.rst:3221 ../../builtins/stdtypes.rst:4489 -#: ../../builtins/stdtypes.rst:4491 ../../builtins/stdtypes.rst:4493 -#: ../../builtins/stdtypes.rst:4495 +#: ../../builtins/stdtypes.rst:96 ../../builtins/stdtypes.rst:3498 +#: ../../builtins/stdtypes.rst:3500 ../../builtins/stdtypes.rst:3502 +#: ../../builtins/stdtypes.rst:3504 ../../builtins/stdtypes.rst:4800 +#: ../../builtins/stdtypes.rst:4802 ../../builtins/stdtypes.rst:4804 +#: ../../builtins/stdtypes.rst:4806 msgid "\\(3)" msgstr "\\(3)" #: ../../builtins/stdtypes.rst:105 ../../builtins/stdtypes.rst:336 -#: ../../builtins/stdtypes.rst:450 ../../builtins/stdtypes.rst:1062 -#: ../../builtins/stdtypes.rst:1272 ../../builtins/stdtypes.rst:3251 -#: ../../builtins/stdtypes.rst:4525 +#: ../../builtins/stdtypes.rst:450 ../../builtins/stdtypes.rst:1333 +#: ../../builtins/stdtypes.rst:1543 ../../builtins/stdtypes.rst:3534 +#: ../../builtins/stdtypes.rst:4836 msgid "Notes:" msgstr "註解:" @@ -239,9 +239,9 @@ msgstr "" msgid "This table summarizes the comparison operations:" msgstr "這個表格統整所有比較運算:" -#: ../../builtins/stdtypes.rst:146 ../../builtins/stdtypes.rst:3178 -#: ../../builtins/stdtypes.rst:3201 ../../builtins/stdtypes.rst:4452 -#: ../../builtins/stdtypes.rst:4475 +#: ../../builtins/stdtypes.rst:146 ../../builtins/stdtypes.rst:3461 +#: ../../builtins/stdtypes.rst:3484 ../../builtins/stdtypes.rst:4763 +#: ../../builtins/stdtypes.rst:4786 msgid "Meaning" msgstr "含義" @@ -593,8 +593,8 @@ msgid "" "zero." msgstr "一個複數,其實部為 *re*,虛部為 *im*。*im* 預設為零。" -#: ../../builtins/stdtypes.rst:318 ../../builtins/stdtypes.rst:3209 -#: ../../builtins/stdtypes.rst:4512 +#: ../../builtins/stdtypes.rst:318 ../../builtins/stdtypes.rst:3492 +#: ../../builtins/stdtypes.rst:4823 msgid "\\(6)" msgstr "\\(6)" @@ -631,9 +631,9 @@ msgid "*x* to the power *y*" msgstr "*x* 的 *y* 次方" #: ../../builtins/stdtypes.rst:327 ../../builtins/stdtypes.rst:329 -#: ../../builtins/stdtypes.rst:3234 ../../builtins/stdtypes.rst:3237 -#: ../../builtins/stdtypes.rst:3240 ../../builtins/stdtypes.rst:4508 -#: ../../builtins/stdtypes.rst:4515 +#: ../../builtins/stdtypes.rst:3517 ../../builtins/stdtypes.rst:3520 +#: ../../builtins/stdtypes.rst:3523 ../../builtins/stdtypes.rst:4819 +#: ../../builtins/stdtypes.rst:4826 msgid "\\(5)" msgstr "\\(5)" @@ -791,9 +791,9 @@ msgid "bitwise :dfn:`or` of *x* and *y*" msgstr "*x* 及 *y* 的位元 :dfn:`或`" #: ../../builtins/stdtypes.rst:434 ../../builtins/stdtypes.rst:437 -#: ../../builtins/stdtypes.rst:440 ../../builtins/stdtypes.rst:3223 -#: ../../builtins/stdtypes.rst:3227 ../../builtins/stdtypes.rst:4497 -#: ../../builtins/stdtypes.rst:4501 +#: ../../builtins/stdtypes.rst:440 ../../builtins/stdtypes.rst:3506 +#: ../../builtins/stdtypes.rst:3510 ../../builtins/stdtypes.rst:4808 +#: ../../builtins/stdtypes.rst:4812 msgid "\\(4)" msgstr "\\(4)" @@ -1572,11 +1572,11 @@ msgstr "" "值情境中,``False`` 和 ``True`` 分別像整數 0 和 1 一樣。然而,不鼓勵依賴這一" "點;請使用 :func:`int` 進行顯式轉換。" -#: ../../builtins/stdtypes.rst:897 -msgid "Iterator Types" -msgstr "疊代器型別" +#: ../../builtins/stdtypes.rst:899 +msgid "Iteration-related types" +msgstr "與疊代相關的型別" -#: ../../builtins/stdtypes.rst:905 +#: ../../builtins/stdtypes.rst:907 msgid "" "Python supports a concept of iteration over containers. This is implemented " "using two distinct methods; these are used to allow user-defined classes to " @@ -1587,14 +1587,18 @@ msgstr "" "用者定義的 classes 以支援疊代。序列則總是支援這些疊代 methods,在下方有更詳細" "的描述。" -#: ../../builtins/stdtypes.rst:910 +#: ../../builtins/stdtypes.rst:913 +msgid "Iterables" +msgstr "可疊代物件" + +#: ../../builtins/stdtypes.rst:915 msgid "" "One method needs to be defined for container objects to " "provide :term:`iterable` support:" msgstr "" "需要為容器物件定義一個 method 來提供\\ :term:`可疊代物件 `\\ 支援:" -#: ../../builtins/stdtypes.rst:917 +#: ../../builtins/stdtypes.rst:922 msgid "" "Return an :term:`iterator` object. The object is required to support the " "iterator protocol described below. If a container supports different types " @@ -1611,14 +1615,18 @@ msgstr "" "樹結構。)此 method 對應 Python/C API 中 Python 物件的型別結構" "的 :c:member:`~PyTypeObject.tp_iter` 插槽。" -#: ../../builtins/stdtypes.rst:926 +#: ../../builtins/stdtypes.rst:934 +msgid "Iterators" +msgstr "疊代器" + +#: ../../builtins/stdtypes.rst:936 msgid "" "The iterator objects themselves are required to support the following two " "methods, which together form the :dfn:`iterator protocol`:" msgstr "" "疊代器物件本身需要支援下列兩個 methods,他們一起形成了 :dfn:`疊代器協定`:" -#: ../../builtins/stdtypes.rst:932 +#: ../../builtins/stdtypes.rst:941 msgid "" "Return the :term:`iterator` object itself. This is required to allow both " "containers and iterators to be used with the :keyword:`for` " @@ -1630,7 +1638,7 @@ msgstr "" "與 :keyword:`for` 和 :keyword:`in` 在陳述式中使用。此 method 對應於 Python/C " "API 中 Python 物件的型別結構的 :c:member:`~PyTypeObject.tp_iter` 插槽。" -#: ../../builtins/stdtypes.rst:941 +#: ../../builtins/stdtypes.rst:950 msgid "" "Return the next item from the :term:`iterator`. If there are no further " "items, raise the :exc:`StopIteration` exception. This method corresponds to " @@ -1641,7 +1649,7 @@ msgstr "" "發 :exc:`StopIteration` 例外。此 method 對應於 Python/C API 中Python 物件的型" "別結構的 :c:member:`~PyTypeObject.tp_iternext` 插槽。" -#: ../../builtins/stdtypes.rst:946 +#: ../../builtins/stdtypes.rst:955 msgid "" "Python defines several iterator objects to support iteration over general " "and specific sequence types, dictionaries, and other more specialized " @@ -1651,7 +1659,7 @@ msgstr "" "Python 定義了幾個疊代器物件來支援對一般和特定序列型別、字典和其他更專門的形式" "的疊代。這些特定型別除了實作疊代器協定外並不重要。" -#: ../../builtins/stdtypes.rst:951 +#: ../../builtins/stdtypes.rst:960 msgid "" "Once an iterator's :meth:`~iterator.__next__` method " "raises :exc:`StopIteration`, it must continue to do so on subsequent calls. " @@ -1660,26 +1668,373 @@ msgstr "" "一旦疊代器的 :meth:`~iterator.__next__` method 引發 :exc:`StopIteration`,則" "它必須在後續呼叫中繼續這樣做。不遵守此屬性的實作被認為是有問題的。" -#: ../../builtins/stdtypes.rst:959 -msgid "Generator Types" +#: ../../builtins/stdtypes.rst:968 +msgid "Generator types" +msgstr "產生器型別" + +#: ../../builtins/stdtypes.rst:970 +msgid "" +"Python's :term:`generators ` -- or more precisely, :term:" +"`generator functions ` and :term:`generator iterators " +"` -- provide a convenient way to implement the iterator " +"protocol." +msgstr "" + +#: ../../builtins/stdtypes.rst:975 +msgid "" +"A function that contains one or more :ref:`yield expressions ` is " +"a :term:`generator function`. For example::" +msgstr "" + +#: ../../builtins/stdtypes.rst:979 +msgid "" +">>> def count_to_three():\n" +"... yield 0\n" +"... yield 1\n" +"... yield 2\n" +"... yield 3" +msgstr "" +">>> def count_to_three():\n" +"... yield 0\n" +"... yield 1\n" +"... yield 2\n" +"... yield 3" + +#: ../../builtins/stdtypes.rst:985 +msgid "" +"Generator functions behave as regular :ref:`user-defined functions ` (for example, they have the same attributes), except that " +"calling a generator function returns a :ref:`generator iterator `::" +msgstr "" + +#: ../../builtins/stdtypes.rst:990 +msgid "" +">>> count_to_three()\n" +"" +msgstr "" +">>> count_to_three()\n" +"" + +#: ../../builtins/stdtypes.rst:993 +msgid "" +"Iterating a generator iterator executes code of the underlying generator " +"function, producing each :keyword:`yield`\\ed value in turn::" +msgstr "" + +#: ../../builtins/stdtypes.rst:996 +msgid "" +">>> for number in count_to_three():\n" +"... print(number)\n" +"0\n" +"1\n" +"2\n" +"3\n" +"\n" +">>> list(count_to_three())\n" +"[0, 1, 2, 3]" +msgstr "" +">>> for number in count_to_three():\n" +"... print(number)\n" +"0\n" +"1\n" +"2\n" +"3\n" +"\n" +">>> list(count_to_three())\n" +"[0, 1, 2, 3]" + +#: ../../builtins/stdtypes.rst:1006 +msgid "" +"One common use for generator functions is implementing the :meth:`~object." +"__iter__` method of custom iterable objects. For example::" +msgstr "" + +#: ../../builtins/stdtypes.rst:1010 +msgid "" +">>> class CardDeck:\n" +"... def __iter__(self):\n" +"... yield 'three of clubs'\n" +"... yield 'ace of hearts'\n" +"\n" +">>> list(CardDeck())\n" +"['three of clubs', 'ace of hearts']" +msgstr "" +">>> class CardDeck:\n" +"... def __iter__(self):\n" +"... yield 'three of clubs'\n" +"... yield 'ace of hearts'\n" +"\n" +">>> list(CardDeck())\n" +"['three of clubs', 'ace of hearts']" + +#: ../../builtins/stdtypes.rst:1023 +msgid "Generator iterators" +msgstr "產生器疊代器" + +#: ../../builtins/stdtypes.rst:1025 +msgid "" +"Generator iterators implement the :ref:`iterator protocol `. Iterating them drives execution of the underlying generator " +"function." +msgstr "" + +#: ../../builtins/stdtypes.rst:1033 +msgid "" +"Starts the execution of a generator function or resumes it at the :ref:" +"`yield expression ` where the function is currently suspended. " +"When a generator function is resumed with a :meth:`~generator.__next__` " +"method, the current yield expression always evaluates to :const:`None`. The " +"execution then continues to the next yield expression, where the generator " +"is suspended again, and the value of the expression after the :keyword:" +"`yield` keyword is returned to :meth:`~generator.__next__`'s caller. If the " +"generator exits without yielding another value, :meth:`~generator.__next__` " +"raises a :exc:`StopIteration` exception, signalling that iteration has " +"completed." +msgstr "" + +#: ../../builtins/stdtypes.rst:1045 +msgid "" +"This method is normally called implicitly, for example by a :keyword:`for` " +"loop, or by the built-in :func:`next` function." +msgstr "" + +#: ../../builtins/stdtypes.rst:1048 +msgid "" +"Generator iterators have a few more methods than generic iterators, which " +"can be used to control the execution of the underlying generator function:" +msgstr "" + +#: ../../builtins/stdtypes.rst:1053 +msgid "" +"\"Sends\" a value into the generator function: the *value* argument becomes " +"the result of the current yield expression." +msgstr "" + +#: ../../builtins/stdtypes.rst:1056 +msgid "" +"Otherwise, this method behaves like :meth:`~generator.__next__`: it resumes " +"the underlying function and either returns the next yielded value or raises :" +"exc:`StopIteration`." +msgstr "" + +#: ../../builtins/stdtypes.rst:1060 +msgid "" +"When :meth:`send` is called to start the generator, it must be called with :" +"const:`None` as the argument, because there is no current yield expression " +"that could receive the value." +msgstr "" + +#: ../../builtins/stdtypes.rst:1068 +msgid "" +"Raises an exception at the point where the generator is currently suspended." +msgstr "" + +#: ../../builtins/stdtypes.rst:1070 +msgid "" +"Otherwise, this method behaves like :meth:`~generator.__next__`: it resumes " +"the underlying function and either returns the next yielded value or raises :" +"exc:`StopIteration`. If the generator function does not catch the passed-in " +"exception, or raises a different exception, then that exception propagates " +"to the caller." +msgstr "" + +#: ../../builtins/stdtypes.rst:1076 +msgid "" +"When :meth:`throw` is called to start the generator, the generator " +"immediately exits (that is, subsequent calls to :meth:`~generator.__next__` " +"will raise :exc:`StopIteration`) and the thrown exception is propagated to :" +"meth:`throw`'s caller." +msgstr "" + +#: ../../builtins/stdtypes.rst:1081 ../../builtins/stdtypes.rst:1202 +msgid "" +"In typical use, this is called with a single argument, an exception " +"instance, similar to the way the :keyword:`raise` keyword is used." +msgstr "" + +#: ../../builtins/stdtypes.rst:1084 +msgid "" +"For backwards compatibility, however, the second signature is supported, " +"following a convention from older versions of Python. The *type* argument " +"should be an exception class, and *value* should be an exception instance. " +"If the *value* is not provided, the *type* constructor is called to get an " +"instance. If *traceback* is provided, it is set on the exception, otherwise " +"any existing :attr:`~BaseException.__traceback__` attribute stored in " +"*value* may be cleared." +msgstr "" + +#: ../../builtins/stdtypes.rst:1095 ../../builtins/stdtypes.rst:1212 +msgid "" +"The second signature \\(type\\[, value\\[, traceback\\]\\]\\) is deprecated " +"and may be removed in a future version of Python." +msgstr "" + +#: ../../builtins/stdtypes.rst:1102 +msgid "" +"Raises a :exc:`GeneratorExit` exception at the point where the generator " +"function is currently suspended (equivalent to calling " +"``throw(GeneratorExit)``)." +msgstr "" + +#: ../../builtins/stdtypes.rst:1105 +msgid "" +"If the generator function has already exited (due to an exception or normal " +"return), or raises :exc:`GeneratorExit` (by not catching the exception), :" +"meth:`close` returns :const:`None`. If the generator yields a value, a :exc:" +"`RuntimeError` is raised. If the generator raises any other exception, it is " +"propagated to the caller. If a generator returns a value upon being closed, " +"that value is returned by :meth:`close`." +msgstr "" + +#: ../../builtins/stdtypes.rst:1113 +msgid "" +"When a generator iterator is garbage collected before it has exited, :meth:" +"`~generator.close` is called automatically." msgstr "" -#: ../../builtins/stdtypes.rst:961 +#: ../../builtins/stdtypes.rst:1118 msgid "" -"Python's :term:`generator`\\s provide a convenient way to implement the " -"iterator protocol. If a container object's :meth:`~object.__iter__` method " -"is implemented as a generator, it will automatically return an iterator " -"object (technically, a generator object) supplying " -"the :meth:`~iterator.__iter__` and :meth:`~generator.__next__` methods. More " -"information about generators can be found in :ref:`the documentation for the " -"yield expression `." +"If a generator returns a value upon being closed, the value is returned by :" +"meth:`close`. Previously, it returned ``None``." msgstr "" -#: ../../builtins/stdtypes.rst:973 +#: ../../builtins/stdtypes.rst:1123 +msgid "" +"Calling any of the generator methods (:meth:`~generator.__next__`, :meth:" +"`~generator.send`, :meth:`~generator.throw`, :meth:`~generator.close`) while " +"one of these methods is already executing raises a :exc:`ValueError` " +"exception." +msgstr "" + +#: ../../builtins/stdtypes.rst:1133 +msgid "Asynchronous generator iterators" +msgstr "" + +#: ../../builtins/stdtypes.rst:1135 +msgid "" +"This subsection describes the methods of an asynchronous generator iterator, " +"which are used to control the execution of an asynchronous generator " +"function." +msgstr "" + +#: ../../builtins/stdtypes.rst:1144 +msgid "" +"Returns an :term:`awaitable` which when run starts to execute the " +"asynchronous generator function or resumes it at the :ref:`yield expression " +"` where the function is currently suspended. When an asynchronous " +"generator function is resumed with an :meth:`~agen.__anext__` method, the " +"current yield expression always evaluates to :const:`None` in the returned " +"awaitable, which when run will continue to the next yield expression. The " +"value of the expression after the :keyword:`yield` keyword is the value of " +"the :exc:`StopIteration` exception raised by the completing coroutine. If " +"the asynchronous generator exits without yielding another value, the " +"awaitable instead raises a :exc:`StopAsyncIteration` exception, signalling " +"that the asynchronous iteration has completed." +msgstr "" + +#: ../../builtins/stdtypes.rst:1157 +msgid "" +"This method is normally called implicitly by an :keyword:`async for` loop, " +"or by the built-in :func:`anext` function." +msgstr "" + +#: ../../builtins/stdtypes.rst:1161 +msgid "" +"Asynchronous generator-iterators have a few more methods than generic " +"asynchronous iterators, which can be used to control the execution of the " +"underlying generator function:" +msgstr "" + +#: ../../builtins/stdtypes.rst:1168 +msgid "" +"Returns an awaitable which, when run, \"sends\" a value into the underlying " +"asynchronous generator function: the *value* argument becomes the result of " +"the current yield expression." +msgstr "" + +#: ../../builtins/stdtypes.rst:1172 +msgid "" +"Otherwise, this method behaves like :meth:`~agen.__anext__`: when the " +"returned awaitable runs, it resumes the underlying function and either " +"returns the next yielded value as the value of the raised :exc:" +"`StopIteration`, or raises :exc:`StopAsyncIteration`." +msgstr "" + +#: ../../builtins/stdtypes.rst:1177 +msgid "" +"When :meth:`asend` is called to start the asynchronous generator, it must be " +"called with :const:`None` as the argument, because there is no yield " +"expression that could receive the value." +msgstr "" + +#: ../../builtins/stdtypes.rst:1186 +msgid "" +"Returns an awaitable that, when run, raises an exception at the point where " +"the underlying asynchronous generator function is currently suspended." +msgstr "" + +#: ../../builtins/stdtypes.rst:1189 +msgid "" +"Otherwise, this method behaves like :meth:`~agen.__anext__`: when the " +"returned awaitable runs, it resumes the underlying function (with an " +"exception raised) and either returns the next yielded value as the value of " +"the raised :exc:`StopIteration`, or raises :exc:`StopAsyncIteration`. If the " +"underlying function does not catch the passed-in exception, or raises a " +"different exception, then when the awaitable is run, that exception " +"propagates to the caller of the awaitable." +msgstr "" + +#: ../../builtins/stdtypes.rst:1197 +msgid "" +"When :meth:`~agen.athrow` is called to start the generator, the generator " +"exits when the awaitable runs (that is, subsequent results from :meth:`~agen." +"__anext__` will raise :exc:`StopAsyncIteration` when run) and the thrown " +"exception is propagated to the awaitable's caller." +msgstr "" + +#: ../../builtins/stdtypes.rst:1205 +msgid "" +"For backwards compatibility, however, the second signature is supported. An " +"exception instance is created from three arguments in the same way as in :" +"meth:`generator.throw`." +msgstr "" + +#: ../../builtins/stdtypes.rst:1221 +msgid "" +"Returns an awaitable that when run will throw a :exc:`GeneratorExit` into " +"the underlying asynchronous generator function at the point where it is " +"currently suspended (equivalent to calling ``athrow(GeneratorExit)``)." +msgstr "" + +#: ../../builtins/stdtypes.rst:1225 +msgid "" +"If the asynchronous generator function then exits gracefully, is already " +"closed, or raises :exc:`GeneratorExit` (by not catching the exception), then " +"the returned awaitable will raise a :exc:`StopIteration` exception. Any " +"further awaitables returned by subsequent calls to the asynchronous " +"generator will raise a :exc:`StopAsyncIteration` exception." +msgstr "" + +#: ../../builtins/stdtypes.rst:1231 +msgid "" +"If the asynchronous generator yields a value, a :exc:`RuntimeError` is " +"raised by the awaitable. If the asynchronous generator raises any other " +"exception, that exception is propagated to the caller of the awaitable." +msgstr "" + +#: ../../builtins/stdtypes.rst:1236 +msgid "" +"If the asynchronous generator has already exited due to an exception or " +"normal exit, then further calls to :meth:`aclose` will return an awaitable " +"that does nothing." +msgstr "" + +#: ../../builtins/stdtypes.rst:1244 msgid "Sequence Types --- :class:`list`, :class:`tuple`, :class:`range`" msgstr "" -#: ../../builtins/stdtypes.rst:975 +#: ../../builtins/stdtypes.rst:1246 msgid "" "There are three basic sequence types: lists, tuples, and range objects. " "Additional sequence types tailored for processing of :ref:`binary data " @@ -1687,11 +2042,11 @@ msgid "" "sections." msgstr "" -#: ../../builtins/stdtypes.rst:984 +#: ../../builtins/stdtypes.rst:1255 msgid "Common Sequence Operations" msgstr "" -#: ../../builtins/stdtypes.rst:988 +#: ../../builtins/stdtypes.rst:1259 msgid "" "The operations in the following table are supported by most sequence types, " "both mutable and immutable. The :class:`collections.abc.Sequence` ABC is " @@ -1699,7 +2054,7 @@ msgid "" "sequence types." msgstr "" -#: ../../builtins/stdtypes.rst:993 +#: ../../builtins/stdtypes.rst:1264 msgid "" "This table lists the sequence operations sorted in ascending priority. In " "the table, *s* and *t* are sequences of the same type, *n*, *i*, *j* and *k* " @@ -1707,7 +2062,7 @@ msgid "" "restrictions imposed by *s*." msgstr "" -#: ../../builtins/stdtypes.rst:998 +#: ../../builtins/stdtypes.rst:1269 msgid "" "The ``in`` and ``not in`` operations have the same priorities as the " "comparison operations. The ``+`` (concatenation) and ``*`` (repetition) " @@ -1715,112 +2070,112 @@ msgid "" "[3]_" msgstr "" -#: ../../builtins/stdtypes.rst:1002 +#: ../../builtins/stdtypes.rst:1273 msgid "" "See :ref:`time-complexity` for the costs of the various sequence operations." msgstr "" -#: ../../builtins/stdtypes.rst:1020 +#: ../../builtins/stdtypes.rst:1291 msgid "``x in s``" msgstr "``x in s``" -#: ../../builtins/stdtypes.rst:1020 +#: ../../builtins/stdtypes.rst:1291 msgid "``True`` if an item of *s* is equal to *x*, else ``False``" msgstr "如果 *s* 的一個項目等於 *x* 則為 ``True``,否則為 ``False``" -#: ../../builtins/stdtypes.rst:1023 +#: ../../builtins/stdtypes.rst:1294 msgid "``x not in s``" msgstr "``x not in s``" -#: ../../builtins/stdtypes.rst:1023 +#: ../../builtins/stdtypes.rst:1294 msgid "``False`` if an item of *s* is equal to *x*, else ``True``" msgstr "如果 *s* 的一個項目等於 *x* 則為 ``False``,否則為 ``True``" -#: ../../builtins/stdtypes.rst:1026 +#: ../../builtins/stdtypes.rst:1297 msgid "``s + t``" msgstr "``s + t``" -#: ../../builtins/stdtypes.rst:1026 +#: ../../builtins/stdtypes.rst:1297 msgid "the concatenation of *s* and *t*" msgstr "*s* 和 *t* 的串接" -#: ../../builtins/stdtypes.rst:1026 +#: ../../builtins/stdtypes.rst:1297 msgid "(6)(7)" msgstr "(6)(7)" -#: ../../builtins/stdtypes.rst:1029 +#: ../../builtins/stdtypes.rst:1300 msgid "``s * n`` or ``n * s``" msgstr "``s * n`` 或 ``n * s``" -#: ../../builtins/stdtypes.rst:1029 +#: ../../builtins/stdtypes.rst:1300 msgid "equivalent to adding *s* to itself *n* times" msgstr "等同於將 *s* 加到自己 *n* 次" -#: ../../builtins/stdtypes.rst:1029 +#: ../../builtins/stdtypes.rst:1300 msgid "(2)(7)" msgstr "(2)(7)" -#: ../../builtins/stdtypes.rst:1032 +#: ../../builtins/stdtypes.rst:1303 msgid "``s[i]``" msgstr "``s[i]``" -#: ../../builtins/stdtypes.rst:1032 +#: ../../builtins/stdtypes.rst:1303 msgid "*i*\\ th item of *s*, origin 0" msgstr "*s* 的第 *i* 項,起始為 0" -#: ../../builtins/stdtypes.rst:1032 +#: ../../builtins/stdtypes.rst:1303 msgid "(3)(8)" msgstr "(3)(8)" -#: ../../builtins/stdtypes.rst:1034 +#: ../../builtins/stdtypes.rst:1305 msgid "``s[i:j]``" msgstr "``s[i:j]``" -#: ../../builtins/stdtypes.rst:1034 +#: ../../builtins/stdtypes.rst:1305 msgid "slice of *s* from *i* to *j*" msgstr "" -#: ../../builtins/stdtypes.rst:1034 +#: ../../builtins/stdtypes.rst:1305 msgid "(3)(4)" msgstr "(3)(4)" -#: ../../builtins/stdtypes.rst:1036 +#: ../../builtins/stdtypes.rst:1307 msgid "``s[i:j:k]``" msgstr "``s[i:j:k]``" -#: ../../builtins/stdtypes.rst:1036 +#: ../../builtins/stdtypes.rst:1307 msgid "slice of *s* from *i* to *j* with step *k*" msgstr "" -#: ../../builtins/stdtypes.rst:1036 +#: ../../builtins/stdtypes.rst:1307 msgid "(3)(5)" msgstr "(3)(5)" -#: ../../builtins/stdtypes.rst:1039 +#: ../../builtins/stdtypes.rst:1310 msgid "``len(s)``" msgstr "``len(s)``" -#: ../../builtins/stdtypes.rst:1039 +#: ../../builtins/stdtypes.rst:1310 msgid "length of *s*" msgstr "*s* 的長度" -#: ../../builtins/stdtypes.rst:1041 +#: ../../builtins/stdtypes.rst:1312 msgid "``min(s)``" msgstr "``min(s)``" -#: ../../builtins/stdtypes.rst:1041 +#: ../../builtins/stdtypes.rst:1312 msgid "smallest item of *s*" msgstr "*s* 中最小的項目" -#: ../../builtins/stdtypes.rst:1043 +#: ../../builtins/stdtypes.rst:1314 msgid "``max(s)``" msgstr "``max(s)``" -#: ../../builtins/stdtypes.rst:1043 +#: ../../builtins/stdtypes.rst:1314 msgid "largest item of *s*" msgstr "*s* 中最大的項目" -#: ../../builtins/stdtypes.rst:1046 +#: ../../builtins/stdtypes.rst:1317 msgid "" "Sequences of the same type also support comparisons. In particular, tuples " "and lists are compared lexicographically by comparing corresponding " @@ -1829,7 +2184,7 @@ msgid "" "(For full details see :ref:`comparisons` in the language reference.)" msgstr "" -#: ../../builtins/stdtypes.rst:1056 +#: ../../builtins/stdtypes.rst:1327 msgid "" "Forward and reversed iterators over mutable sequences access values using an " "index. That index will continue to march forward (or backward) even if the " @@ -1838,7 +2193,7 @@ msgid "" "index drops below zero)." msgstr "" -#: ../../builtins/stdtypes.rst:1065 +#: ../../builtins/stdtypes.rst:1336 msgid "" "While the ``in`` and ``not in`` operations are used only for simple " "containment testing in the general case, some specialised sequences (such " @@ -1846,7 +2201,7 @@ msgid "" "subsequence testing::" msgstr "" -#: ../../builtins/stdtypes.rst:1070 +#: ../../builtins/stdtypes.rst:1341 msgid "" ">>> \"gg\" in \"eggs\"\n" "True" @@ -1854,7 +2209,7 @@ msgstr "" ">>> \"gg\" in \"eggs\"\n" "True" -#: ../../builtins/stdtypes.rst:1074 +#: ../../builtins/stdtypes.rst:1345 msgid "" "Values of *n* less than ``0`` are treated as ``0`` (which yields an empty " "sequence of the same type as *s*). Note that items in the sequence *s* are " @@ -1862,7 +2217,7 @@ msgid "" "Python programmers; consider::" msgstr "" -#: ../../builtins/stdtypes.rst:1079 +#: ../../builtins/stdtypes.rst:1350 msgid "" ">>> lists = [[]] * 3\n" ">>> lists\n" @@ -1878,7 +2233,7 @@ msgstr "" ">>> lists\n" "[[3], [3], [3]]" -#: ../../builtins/stdtypes.rst:1086 +#: ../../builtins/stdtypes.rst:1357 msgid "" "What has happened is that ``[[]]`` is a one-element list containing an empty " "list, so all three elements of ``[[]] * 3`` are references to this single " @@ -1886,7 +2241,7 @@ msgid "" "list. You can create a list of different lists this way::" msgstr "" -#: ../../builtins/stdtypes.rst:1091 +#: ../../builtins/stdtypes.rst:1362 msgid "" ">>> lists = [[] for i in range(3)]\n" ">>> lists[0].append(3)\n" @@ -1902,46 +2257,46 @@ msgstr "" ">>> lists\n" "[[3], [5], [7]]" -#: ../../builtins/stdtypes.rst:1098 +#: ../../builtins/stdtypes.rst:1369 msgid "" "Further explanation is available in the FAQ entry :ref:`faq-multidimensional-" "list`." msgstr "" -#: ../../builtins/stdtypes.rst:1102 +#: ../../builtins/stdtypes.rst:1373 msgid "" "If *i* or *j* is negative, the index is relative to the end of sequence *s*: " "``len(s) + i`` or ``len(s) + j`` is substituted. But note that ``-0`` is " "still ``0``." msgstr "" -#: ../../builtins/stdtypes.rst:1107 +#: ../../builtins/stdtypes.rst:1378 msgid "" "The slice of *s* from *i* to *j* is defined as the sequence of items with " "index *k* such that ``i <= k < j``." msgstr "" -#: ../../builtins/stdtypes.rst:1110 +#: ../../builtins/stdtypes.rst:1381 msgid "If *i* is omitted or ``None``, use ``0``." msgstr "假如 *i* 被省略或為 ``None``,則使用 ``0``。" -#: ../../builtins/stdtypes.rst:1111 +#: ../../builtins/stdtypes.rst:1382 msgid "If *j* is omitted or ``None``, use ``len(s)``." msgstr "假如 *j* 被省略或為 ``None``,則使用 ``len(s)``。" -#: ../../builtins/stdtypes.rst:1112 +#: ../../builtins/stdtypes.rst:1383 msgid "If *i* or *j* is less than ``-len(s)``, use ``0``." msgstr "假如 *i* 或 *j* 小於 ``-len(s)``,則使用 ``0``。" -#: ../../builtins/stdtypes.rst:1113 +#: ../../builtins/stdtypes.rst:1384 msgid "If *i* or *j* is greater than ``len(s)``, use ``len(s)``." msgstr "假如 *i* 或 *j* 大於 ``len(s)``,則使用 ``len(s)``。" -#: ../../builtins/stdtypes.rst:1114 +#: ../../builtins/stdtypes.rst:1385 msgid "If *i* is greater than or equal to *j*, the slice is empty." msgstr "假如 *i* 大於或等於 *j*,則該切片為空。" -#: ../../builtins/stdtypes.rst:1117 +#: ../../builtins/stdtypes.rst:1388 msgid "" "The slice of *s* from *i* to *j* with step *k* is defined as the sequence of " "items with index ``x = i + n*k`` such that ``0 <= n < (j-i)/k``. In other " @@ -1954,7 +2309,7 @@ msgid "" "``None``, it is treated like ``1``." msgstr "" -#: ../../builtins/stdtypes.rst:1130 +#: ../../builtins/stdtypes.rst:1401 msgid "" "Concatenating immutable sequences always results in a new object. This " "means that building up a sequence by repeated concatenation will have a " @@ -1962,14 +2317,14 @@ msgid "" "runtime cost, you must switch to one of the alternatives below:" msgstr "" -#: ../../builtins/stdtypes.rst:1135 +#: ../../builtins/stdtypes.rst:1406 msgid "" "if concatenating :class:`str` objects, you can build a list and " "use :meth:`str.join` at the end or else write to an :class:`io.StringIO` " "instance and retrieve its value when complete" msgstr "" -#: ../../builtins/stdtypes.rst:1139 +#: ../../builtins/stdtypes.rst:1410 msgid "" "if concatenating :class:`bytes` objects, you can similarly " "use :meth:`bytes.join` or :class:`io.BytesIO`, or you can do in-place " @@ -1977,46 +2332,46 @@ msgid "" "are mutable and have an efficient overallocation mechanism" msgstr "" -#: ../../builtins/stdtypes.rst:1144 +#: ../../builtins/stdtypes.rst:1415 msgid "if concatenating :class:`tuple` objects, extend a :class:`list` instead" msgstr "" -#: ../../builtins/stdtypes.rst:1146 +#: ../../builtins/stdtypes.rst:1417 msgid "for other types, investigate the relevant class documentation" msgstr "" -#: ../../builtins/stdtypes.rst:1150 +#: ../../builtins/stdtypes.rst:1421 msgid "" "Some sequence types (such as :class:`range`) only support item sequences " "that follow specific patterns, and hence don't support sequence " "concatenation or repetition." msgstr "" -#: ../../builtins/stdtypes.rst:1155 +#: ../../builtins/stdtypes.rst:1426 msgid "An :exc:`IndexError` is raised if *i* is outside the sequence range." msgstr "" -#: ../../builtins/stdtypes.rst:1158 +#: ../../builtins/stdtypes.rst:1429 msgid "Sequence Methods" msgstr "序列方法" -#: ../../builtins/stdtypes.rst:1159 +#: ../../builtins/stdtypes.rst:1430 msgid "Sequence types also support the following methods:" msgstr "序列型別也支援以下方法:" -#: ../../builtins/stdtypes.rst:1169 +#: ../../builtins/stdtypes.rst:1440 msgid "Return the total number of occurrences of *value* in *sequence*." msgstr "回傳 *sequence* 中 *value* 出現的總次數。" -#: ../../builtins/stdtypes.rst:1179 +#: ../../builtins/stdtypes.rst:1450 msgid "Return the index of the first occurrence of *value* in *sequence*." msgstr "回傳 *sequence* 中 *value* 首次出現的索引。" -#: ../../builtins/stdtypes.rst:1181 ../../builtins/stdtypes.rst:1365 +#: ../../builtins/stdtypes.rst:1452 ../../builtins/stdtypes.rst:1636 msgid "Raises :exc:`ValueError` if *value* is not found in *sequence*." msgstr "當 *value* 不在 *sequence* 中時引發 :exc:`ValueError`。" -#: ../../builtins/stdtypes.rst:1183 +#: ../../builtins/stdtypes.rst:1454 msgid "" "The *start* or *stop* arguments allow for efficient searching of subsections " "of the sequence, beginning at *start* and ending at *stop*. This is roughly " @@ -2024,47 +2379,47 @@ msgid "" "copying any data." msgstr "" -#: ../../builtins/stdtypes.rst:1189 +#: ../../builtins/stdtypes.rst:1460 msgid "" "Not all sequence types support passing the *start* and *stop* arguments." msgstr "" -#: ../../builtins/stdtypes.rst:1195 +#: ../../builtins/stdtypes.rst:1466 msgid "Immutable Sequence Types" msgstr "不可變序列型別" -#: ../../builtins/stdtypes.rst:1202 +#: ../../builtins/stdtypes.rst:1473 msgid "" "The only operation that immutable sequence types generally implement that is " "not also implemented by mutable sequence types is support for " "the :func:`hash` built-in." msgstr "" -#: ../../builtins/stdtypes.rst:1206 +#: ../../builtins/stdtypes.rst:1477 msgid "" "This support allows immutable sequences, such as :class:`tuple` instances, " "to be used as :class:`dict` keys and stored in :class:`set` " "and :class:`frozenset` instances." msgstr "" -#: ../../builtins/stdtypes.rst:1210 +#: ../../builtins/stdtypes.rst:1481 msgid "" "Attempting to hash an immutable sequence that contains unhashable values " "will result in :exc:`TypeError`." msgstr "" -#: ../../builtins/stdtypes.rst:1217 +#: ../../builtins/stdtypes.rst:1488 msgid "Mutable Sequence Types" msgstr "可變序列型別" -#: ../../builtins/stdtypes.rst:1224 +#: ../../builtins/stdtypes.rst:1495 msgid "" "The operations in the following table are defined on mutable sequence types. " "The :class:`collections.abc.MutableSequence` ABC is provided to make it " "easier to correctly implement these operations on custom sequence types." msgstr "" -#: ../../builtins/stdtypes.rst:1228 +#: ../../builtins/stdtypes.rst:1499 msgid "" "In the table *s* is an instance of a mutable sequence type, *t* is any " "iterable object and *x* is an arbitrary object that meets any type and value " @@ -2072,81 +2427,81 @@ msgid "" "integers that meet the value restriction ``0 <= x <= 255``)." msgstr "" -#: ../../builtins/stdtypes.rst:1244 +#: ../../builtins/stdtypes.rst:1515 msgid "``s[i] = x``" msgstr "``s[i] = x``" -#: ../../builtins/stdtypes.rst:1244 +#: ../../builtins/stdtypes.rst:1515 msgid "item *i* of *s* is replaced by *x*" msgstr "" -#: ../../builtins/stdtypes.rst:1247 +#: ../../builtins/stdtypes.rst:1518 msgid "``del s[i]``" msgstr "``del s[i]``" -#: ../../builtins/stdtypes.rst:1247 +#: ../../builtins/stdtypes.rst:1518 msgid "removes item *i* of *s*" msgstr "移除 *s* 中的項目 *i*" -#: ../../builtins/stdtypes.rst:1249 +#: ../../builtins/stdtypes.rst:1520 msgid "``s[i:j] = t``" msgstr "``s[i:j] = t``" -#: ../../builtins/stdtypes.rst:1249 +#: ../../builtins/stdtypes.rst:1520 msgid "" "slice of *s* from *i* to *j* is replaced by the contents of the iterable *t*" msgstr "" -#: ../../builtins/stdtypes.rst:1253 +#: ../../builtins/stdtypes.rst:1524 msgid "``del s[i:j]``" msgstr "``del s[i:j]``" -#: ../../builtins/stdtypes.rst:1253 +#: ../../builtins/stdtypes.rst:1524 msgid "" "removes the elements of ``s[i:j]`` from the list (same as ``s[i:j] = []``)" msgstr "移除串列中 ``s[i:j]`` 的元素(和 ``s[i:j] = []`` 相同)" -#: ../../builtins/stdtypes.rst:1257 +#: ../../builtins/stdtypes.rst:1528 msgid "``s[i:j:k] = t``" msgstr "``s[i:j:k] = t``" -#: ../../builtins/stdtypes.rst:1257 +#: ../../builtins/stdtypes.rst:1528 msgid "the elements of ``s[i:j:k]`` are replaced by those of *t*" msgstr "``s[i:j:k]`` 的元素被 *t* 的元素取代" -#: ../../builtins/stdtypes.rst:1260 +#: ../../builtins/stdtypes.rst:1531 msgid "``del s[i:j:k]``" msgstr "``del s[i:j:k]``" -#: ../../builtins/stdtypes.rst:1260 +#: ../../builtins/stdtypes.rst:1531 msgid "removes the elements of ``s[i:j:k]`` from the list" msgstr "移除串列中 ``s[i:j:k]`` 的元素" -#: ../../builtins/stdtypes.rst:1263 +#: ../../builtins/stdtypes.rst:1534 msgid "``s += t``" msgstr "``s += t``" -#: ../../builtins/stdtypes.rst:1263 +#: ../../builtins/stdtypes.rst:1534 msgid "" "extends *s* with the contents of *t* (for the most part the same as " "``s[len(s):len(s)] = t``)" msgstr "" -#: ../../builtins/stdtypes.rst:1268 +#: ../../builtins/stdtypes.rst:1539 msgid "``s *= n``" msgstr "``s *= n``" -#: ../../builtins/stdtypes.rst:1268 +#: ../../builtins/stdtypes.rst:1539 msgid "updates *s* with its contents repeated *n* times" msgstr "" -#: ../../builtins/stdtypes.rst:1275 +#: ../../builtins/stdtypes.rst:1546 msgid "" "If *k* is not equal to ``1``, *t* must have the same length as the slice it " "is replacing." msgstr "" -#: ../../builtins/stdtypes.rst:1278 +#: ../../builtins/stdtypes.rst:1549 msgid "" "The value *n* is an integer, or an object " "implementing :meth:`~object.__index__`. Zero and negative values of *n* " @@ -2155,102 +2510,102 @@ msgid "" "common`." msgstr "" -#: ../../builtins/stdtypes.rst:1284 +#: ../../builtins/stdtypes.rst:1555 msgid "Mutable Sequence Methods" msgstr "可變序列方法" -#: ../../builtins/stdtypes.rst:1285 +#: ../../builtins/stdtypes.rst:1556 msgid "Mutable sequence types also support the following methods:" msgstr "可變序列型別也支援以下方法:" -#: ../../builtins/stdtypes.rst:1294 +#: ../../builtins/stdtypes.rst:1565 msgid "" "Append *value* to the end of the sequence. This is equivalent to writing " "``seq[len(seq):len(seq)] = [value]``." msgstr "" "將 *value* 附加到序列末尾,這和 ``seq[len(seq):len(seq)] = [value]`` 相同。" -#: ../../builtins/stdtypes.rst:1306 +#: ../../builtins/stdtypes.rst:1577 msgid "" "Remove all items from *sequence*. This is equivalent to writing ``del " "sequence[:]``." msgstr "移除 *sequence* 中的所有項目,這和 ``del sequence[:]`` 相同。" -#: ../../builtins/stdtypes.rst:1318 +#: ../../builtins/stdtypes.rst:1589 msgid "" "Create a shallow copy of *sequence*. This is equivalent to writing " "``sequence[:]``." msgstr "建立 *sequence* 的淺層複製,這和 ``sequence[:]`` 相同。" -#: ../../builtins/stdtypes.rst:1321 +#: ../../builtins/stdtypes.rst:1592 msgid "" "The :meth:`!copy` method is not part of " "the :class:`~collections.abc.MutableSequence` :class:`~abc.ABC`, but most " "concrete mutable sequence types provide it." msgstr "" -#: ../../builtins/stdtypes.rst:1332 +#: ../../builtins/stdtypes.rst:1603 msgid "" "Extend *sequence* with the contents of *iterable*. For the most part, this " "is the same as writing ``seq[len(seq):len(seq)] = iterable``." msgstr "" -#: ../../builtins/stdtypes.rst:1343 +#: ../../builtins/stdtypes.rst:1614 msgid "" "Insert *value* into *sequence* at the given *index*. This is equivalent to " "writing ``sequence[index:index] = [value]``." msgstr "" -#: ../../builtins/stdtypes.rst:1353 +#: ../../builtins/stdtypes.rst:1624 msgid "" "Retrieve the item at *index* and also remove it from *sequence*. By default, " "the last item in *sequence* is removed and returned." msgstr "" -#: ../../builtins/stdtypes.rst:1363 +#: ../../builtins/stdtypes.rst:1634 msgid "Remove the first item from *sequence* where ``sequence[i] == value``." msgstr "" -#: ../../builtins/stdtypes.rst:1374 +#: ../../builtins/stdtypes.rst:1645 msgid "" "Reverse the items of *sequence* in place. This method maintains economy of " "space when reversing a large sequence. To remind users that it operates by " "side-effect, it returns ``None``." msgstr "" -#: ../../builtins/stdtypes.rst:1382 +#: ../../builtins/stdtypes.rst:1653 msgid "Lists" msgstr "List(串列)" -#: ../../builtins/stdtypes.rst:1386 +#: ../../builtins/stdtypes.rst:1657 msgid "" "Lists are mutable sequences, typically used to store collections of " "homogeneous items (where the precise degree of similarity will vary by " "application)." msgstr "" -#: ../../builtins/stdtypes.rst:1392 +#: ../../builtins/stdtypes.rst:1663 msgid "Lists may be constructed in several ways:" msgstr "" -#: ../../builtins/stdtypes.rst:1394 +#: ../../builtins/stdtypes.rst:1665 msgid "Using a pair of square brackets to denote the empty list: ``[]``" msgstr "" -#: ../../builtins/stdtypes.rst:1395 +#: ../../builtins/stdtypes.rst:1666 msgid "" "Using square brackets, separating items with commas: ``[a]``, ``[a, b, c]``" msgstr "" -#: ../../builtins/stdtypes.rst:1396 +#: ../../builtins/stdtypes.rst:1667 msgid "Using a list comprehension: ``[x for x in iterable]``" msgstr "使用串列綜合運算式:``[x for x in iterable]``" -#: ../../builtins/stdtypes.rst:1397 +#: ../../builtins/stdtypes.rst:1668 msgid "Using the type constructor: ``list()`` or ``list(iterable)``" msgstr "使用型別建構函式:``list()`` 或 ``list(iterable)``" -#: ../../builtins/stdtypes.rst:1399 +#: ../../builtins/stdtypes.rst:1670 msgid "" "The constructor builds a list whose items are the same and in the same order " "as *iterable*'s items. *iterable* may be either a sequence, a container " @@ -2261,24 +2616,24 @@ msgid "" "new empty list, ``[]``." msgstr "" -#: ../../builtins/stdtypes.rst:1408 +#: ../../builtins/stdtypes.rst:1679 msgid "" "Many other operations also produce lists, including the :func:`sorted` built-" "in." msgstr "" -#: ../../builtins/stdtypes.rst:1411 +#: ../../builtins/stdtypes.rst:1682 msgid "Lists are :ref:`generic ` over the types of their items." msgstr "" -#: ../../builtins/stdtypes.rst:1413 +#: ../../builtins/stdtypes.rst:1684 msgid "" "Lists implement all of the :ref:`common ` and :ref:`mutable " "` sequence operations. Lists also provide the following " "additional method:" msgstr "" -#: ../../builtins/stdtypes.rst:1419 +#: ../../builtins/stdtypes.rst:1690 msgid "" "This method sorts the list in place, using only ``<`` comparisons between " "items. Exceptions are not suppressed - if any comparison operations fail, " @@ -2286,13 +2641,13 @@ msgid "" "partially modified state)." msgstr "" -#: ../../builtins/stdtypes.rst:1424 +#: ../../builtins/stdtypes.rst:1695 msgid "" ":meth:`sort` accepts two arguments that can only be passed by keyword " "(:ref:`keyword-only arguments `):" msgstr "" -#: ../../builtins/stdtypes.rst:1427 +#: ../../builtins/stdtypes.rst:1698 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each list element (for example, ``key=str.lower``). The " @@ -2301,19 +2656,19 @@ msgid "" "list items are sorted directly without calculating a separate key value." msgstr "" -#: ../../builtins/stdtypes.rst:1434 +#: ../../builtins/stdtypes.rst:1705 msgid "" "The :func:`functools.cmp_to_key` utility is available to convert a 2.x style " "*cmp* function to a *key* function." msgstr "" -#: ../../builtins/stdtypes.rst:1437 +#: ../../builtins/stdtypes.rst:1708 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" -#: ../../builtins/stdtypes.rst:1440 +#: ../../builtins/stdtypes.rst:1711 msgid "" "This method modifies the sequence in place for economy of space when sorting " "a large sequence. To remind users that it operates by side effect, it does " @@ -2321,7 +2676,7 @@ msgid "" "new sorted list instance)." msgstr "" -#: ../../builtins/stdtypes.rst:1445 +#: ../../builtins/stdtypes.rst:1716 msgid "" "The :meth:`sort` method is guaranteed to be stable. A sort is stable if it " "guarantees not to change the relative order of elements that compare equal " @@ -2329,12 +2684,12 @@ msgid "" "department, then by salary grade)." msgstr "" -#: ../../builtins/stdtypes.rst:1450 +#: ../../builtins/stdtypes.rst:1721 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" -#: ../../builtins/stdtypes.rst:1454 +#: ../../builtins/stdtypes.rst:1725 msgid "" "While a list is being sorted, the effect of attempting to mutate, or even " "inspect, the list is undefined. The C implementation of Python makes the " @@ -2342,17 +2697,17 @@ msgid "" "detect that the list has been mutated during a sort." msgstr "" -#: ../../builtins/stdtypes.rst:1461 +#: ../../builtins/stdtypes.rst:1732 msgid "" "For detailed information on thread-safety guarantees for :class:`list` " "objects, see :ref:`thread-safety-list`." msgstr "" -#: ../../builtins/stdtypes.rst:1468 +#: ../../builtins/stdtypes.rst:1739 msgid "Tuples" msgstr "Tuple(元組)" -#: ../../builtins/stdtypes.rst:1472 +#: ../../builtins/stdtypes.rst:1743 msgid "" "Tuples are immutable sequences, typically used to store collections of " "heterogeneous data (such as the 2-tuples produced by the :func:`enumerate` " @@ -2361,27 +2716,27 @@ msgid "" "or :class:`dict` instance)." msgstr "" -#: ../../builtins/stdtypes.rst:1480 +#: ../../builtins/stdtypes.rst:1751 msgid "Tuples may be constructed in a number of ways:" msgstr "元組可以以多種方式建構:" -#: ../../builtins/stdtypes.rst:1482 +#: ../../builtins/stdtypes.rst:1753 msgid "Using a pair of parentheses to denote the empty tuple: ``()``" msgstr "使用一對圓括號表示空元組:``()``" -#: ../../builtins/stdtypes.rst:1483 +#: ../../builtins/stdtypes.rst:1754 msgid "Using a trailing comma for a singleton tuple: ``a,`` or ``(a,)``" msgstr "使用末尾的逗號表示單元素元組:``a,`` 或 ``(a,)``" -#: ../../builtins/stdtypes.rst:1484 +#: ../../builtins/stdtypes.rst:1755 msgid "Separating items with commas: ``a, b, c`` or ``(a, b, c)``" msgstr "使用逗號分隔項目:``a, b, c`` 或 ``(a, b, c)``" -#: ../../builtins/stdtypes.rst:1485 +#: ../../builtins/stdtypes.rst:1756 msgid "Using the :func:`tuple` built-in: ``tuple()`` or ``tuple(iterable)``" msgstr "" -#: ../../builtins/stdtypes.rst:1487 +#: ../../builtins/stdtypes.rst:1758 msgid "" "The constructor builds a tuple whose items are the same and in the same " "order as *iterable*'s items. *iterable* may be either a sequence, a " @@ -2392,7 +2747,7 @@ msgid "" "``()``." msgstr "" -#: ../../builtins/stdtypes.rst:1495 +#: ../../builtins/stdtypes.rst:1766 msgid "" "Note that it is actually the comma which makes a tuple, not the parentheses. " "The parentheses are optional, except in the empty tuple case, or when they " @@ -2401,37 +2756,37 @@ msgid "" "call with a 3-tuple as the sole argument." msgstr "" -#: ../../builtins/stdtypes.rst:1501 +#: ../../builtins/stdtypes.rst:1772 msgid "" "Tuples implement all of the :ref:`common ` sequence " "operations." msgstr "" -#: ../../builtins/stdtypes.rst:1504 +#: ../../builtins/stdtypes.rst:1775 msgid "" "Tuples are :ref:`generic ` over the types of their contents. For " "more information, refer to :ref:`the typing documentation on annotating " "tuples `." msgstr "" -#: ../../builtins/stdtypes.rst:1508 +#: ../../builtins/stdtypes.rst:1779 msgid "" "For heterogeneous collections of data where access by name is clearer than " "access by index, :func:`collections.namedtuple` may be a more appropriate " "choice than a simple tuple object." msgstr "" -#: ../../builtins/stdtypes.rst:1516 +#: ../../builtins/stdtypes.rst:1787 msgid "Ranges" msgstr "" -#: ../../builtins/stdtypes.rst:1520 +#: ../../builtins/stdtypes.rst:1791 msgid "" "The :class:`range` type represents an immutable sequence of numbers and is " "commonly used for looping a specific number of times in :keyword:`for` loops." msgstr "" -#: ../../builtins/stdtypes.rst:1527 +#: ../../builtins/stdtypes.rst:1798 msgid "" "The arguments to the range constructor must be integers (either built-" "in :class:`int` or any object that implements the :meth:`~object.__index__` " @@ -2440,38 +2795,38 @@ msgid "" "zero, :exc:`ValueError` is raised." msgstr "" -#: ../../builtins/stdtypes.rst:1533 +#: ../../builtins/stdtypes.rst:1804 msgid "" "For a positive *step*, the contents of a range ``r`` are determined by the " "formula ``r[i] = start + step*i`` where ``i >= 0`` and ``r[i] < stop``." msgstr "" -#: ../../builtins/stdtypes.rst:1537 +#: ../../builtins/stdtypes.rst:1808 msgid "" "For a negative *step*, the contents of the range are still determined by the " "formula ``r[i] = start + step*i``, but the constraints are ``i >= 0`` and " "``r[i] > stop``." msgstr "" -#: ../../builtins/stdtypes.rst:1541 +#: ../../builtins/stdtypes.rst:1812 msgid "" "A range object will be empty if ``r[0]`` does not meet the value constraint. " "Ranges do support negative indices, but these are interpreted as indexing " "from the end of the sequence determined by the positive indices." msgstr "" -#: ../../builtins/stdtypes.rst:1546 +#: ../../builtins/stdtypes.rst:1817 msgid "" "Ranges containing absolute values larger than :data:`sys.maxsize` are " "permitted but some features (such as :func:`len`) may " "raise :exc:`OverflowError`." msgstr "" -#: ../../builtins/stdtypes.rst:1550 +#: ../../builtins/stdtypes.rst:1821 msgid "Range examples::" msgstr "" -#: ../../builtins/stdtypes.rst:1552 +#: ../../builtins/stdtypes.rst:1823 msgid "" ">>> list(range(10))\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" @@ -2503,7 +2858,7 @@ msgstr "" ">>> list(range(1, 0))\n" "[]" -#: ../../builtins/stdtypes.rst:1567 +#: ../../builtins/stdtypes.rst:1838 msgid "" "Ranges implement all of the :ref:`common ` sequence " "operations except concatenation and repetition (due to the fact that range " @@ -2511,23 +2866,23 @@ msgid "" "repetition and concatenation will usually violate that pattern)." msgstr "" -#: ../../builtins/stdtypes.rst:1574 +#: ../../builtins/stdtypes.rst:1845 msgid "" "The value of the *start* parameter (or ``0`` if the parameter was not " "supplied)" msgstr "" -#: ../../builtins/stdtypes.rst:1579 +#: ../../builtins/stdtypes.rst:1850 msgid "The value of the *stop* parameter" msgstr "" -#: ../../builtins/stdtypes.rst:1583 +#: ../../builtins/stdtypes.rst:1854 msgid "" "The value of the *step* parameter (or ``1`` if the parameter was not " "supplied)" msgstr "" -#: ../../builtins/stdtypes.rst:1586 +#: ../../builtins/stdtypes.rst:1857 msgid "" "The advantage of the :class:`range` type over a regular :class:`list` " "or :class:`tuple` is that a :class:`range` object will always take the same " @@ -2536,14 +2891,14 @@ msgid "" "individual items and subranges as needed)." msgstr "" -#: ../../builtins/stdtypes.rst:1592 +#: ../../builtins/stdtypes.rst:1863 msgid "" "Range objects implement the :class:`collections.abc.Sequence` ABC, and " "provide features such as containment tests, element index lookup, slicing " "and support for negative indices (see :ref:`typesseq`):" msgstr "" -#: ../../builtins/stdtypes.rst:1612 +#: ../../builtins/stdtypes.rst:1883 msgid "" "Testing range objects for equality with ``==`` and ``!=`` compares them as " "sequences. That is, two range objects are considered equal if they " @@ -2553,505 +2908,505 @@ msgid "" "3)`` or ``range(0, 3, 2) == range(0, 4, 2)``.)" msgstr "" -#: ../../builtins/stdtypes.rst:1619 +#: ../../builtins/stdtypes.rst:1890 msgid "" "Implement the Sequence ABC. Support slicing and negative indices. " "Test :class:`int` objects for membership in constant time instead of " "iterating through all items." msgstr "" -#: ../../builtins/stdtypes.rst:1625 +#: ../../builtins/stdtypes.rst:1896 msgid "" "Define '==' and '!=' to compare range objects based on the sequence of " "values they define (instead of comparing based on object identity)." msgstr "" -#: ../../builtins/stdtypes.rst:1630 +#: ../../builtins/stdtypes.rst:1901 msgid "" "Added the :attr:`~range.start`, :attr:`~range.stop` and :attr:`~range.step` " "attributes." msgstr "" -#: ../../builtins/stdtypes.rst:1635 +#: ../../builtins/stdtypes.rst:1906 msgid "" "The `linspace recipe `_ shows how to implement a lazy version of range " "suitable for floating-point applications." msgstr "" -#: ../../builtins/stdtypes.rst:1647 +#: ../../builtins/stdtypes.rst:1918 msgid "Text and Binary Sequence Type Methods Summary" msgstr "" -#: ../../builtins/stdtypes.rst:1648 +#: ../../builtins/stdtypes.rst:1919 msgid "" "The following table summarizes the text and binary sequence types methods by " "category." msgstr "" -#: ../../builtins/stdtypes.rst:1653 +#: ../../builtins/stdtypes.rst:1924 msgid "Category" msgstr "分類" -#: ../../builtins/stdtypes.rst:1653 +#: ../../builtins/stdtypes.rst:1924 msgid ":class:`str` methods" msgstr ":class:`str` 方法" -#: ../../builtins/stdtypes.rst:1653 +#: ../../builtins/stdtypes.rst:1924 msgid ":class:`bytes` and :class:`bytearray` methods" msgstr ":class:`bytes` 和 :class:`bytearray` 方法" -#: ../../builtins/stdtypes.rst:1655 +#: ../../builtins/stdtypes.rst:1926 msgid "Formatting" msgstr "格式化" -#: ../../builtins/stdtypes.rst:1655 +#: ../../builtins/stdtypes.rst:1926 msgid ":meth:`str.format`" msgstr ":meth:`str.format`" -#: ../../builtins/stdtypes.rst:1657 +#: ../../builtins/stdtypes.rst:1928 msgid ":meth:`str.format_map`" msgstr ":meth:`str.format_map`" -#: ../../builtins/stdtypes.rst:1659 +#: ../../builtins/stdtypes.rst:1930 msgid ":ref:`f-strings`" msgstr ":ref:`f-strings`" -#: ../../builtins/stdtypes.rst:1661 +#: ../../builtins/stdtypes.rst:1932 msgid ":ref:`old-string-formatting`" msgstr ":ref:`old-string-formatting`" -#: ../../builtins/stdtypes.rst:1661 +#: ../../builtins/stdtypes.rst:1932 msgid ":ref:`bytes-formatting`" msgstr ":ref:`bytes-formatting`" -#: ../../builtins/stdtypes.rst:1663 +#: ../../builtins/stdtypes.rst:1934 msgid "Searching and Replacing" msgstr "搜尋和取代" -#: ../../builtins/stdtypes.rst:1663 +#: ../../builtins/stdtypes.rst:1934 msgid ":meth:`str.find`" msgstr ":meth:`str.find`" -#: ../../builtins/stdtypes.rst:1663 +#: ../../builtins/stdtypes.rst:1934 msgid ":meth:`str.rfind`" msgstr ":meth:`str.rfind`" -#: ../../builtins/stdtypes.rst:1663 +#: ../../builtins/stdtypes.rst:1934 msgid ":meth:`bytes.find`" msgstr ":meth:`bytes.find`" -#: ../../builtins/stdtypes.rst:1663 +#: ../../builtins/stdtypes.rst:1934 msgid ":meth:`bytes.rfind`" msgstr ":meth:`bytes.rfind`" -#: ../../builtins/stdtypes.rst:1665 +#: ../../builtins/stdtypes.rst:1936 msgid ":meth:`str.index`" msgstr ":meth:`str.index`" -#: ../../builtins/stdtypes.rst:1665 +#: ../../builtins/stdtypes.rst:1936 msgid ":meth:`str.rindex`" msgstr ":meth:`str.rindex`" -#: ../../builtins/stdtypes.rst:1665 +#: ../../builtins/stdtypes.rst:1936 msgid ":meth:`bytes.index`" msgstr ":meth:`bytes.index`" -#: ../../builtins/stdtypes.rst:1665 +#: ../../builtins/stdtypes.rst:1936 msgid ":meth:`bytes.rindex`" msgstr ":meth:`bytes.rindex`" -#: ../../builtins/stdtypes.rst:1667 +#: ../../builtins/stdtypes.rst:1938 msgid ":meth:`str.startswith`" msgstr ":meth:`str.startswith`" -#: ../../builtins/stdtypes.rst:1667 +#: ../../builtins/stdtypes.rst:1938 msgid ":meth:`bytes.startswith`" msgstr ":meth:`bytes.startswith`" -#: ../../builtins/stdtypes.rst:1669 +#: ../../builtins/stdtypes.rst:1940 msgid ":meth:`str.endswith`" msgstr ":meth:`str.endswith`" -#: ../../builtins/stdtypes.rst:1669 +#: ../../builtins/stdtypes.rst:1940 msgid ":meth:`bytes.endswith`" msgstr ":meth:`bytes.endswith`" -#: ../../builtins/stdtypes.rst:1671 +#: ../../builtins/stdtypes.rst:1942 msgid ":meth:`str.count`" msgstr ":meth:`str.count`" -#: ../../builtins/stdtypes.rst:1671 +#: ../../builtins/stdtypes.rst:1942 msgid ":meth:`bytes.count`" msgstr ":meth:`bytes.count`" -#: ../../builtins/stdtypes.rst:1673 +#: ../../builtins/stdtypes.rst:1944 msgid ":meth:`str.replace`" msgstr ":meth:`str.replace`" -#: ../../builtins/stdtypes.rst:1673 +#: ../../builtins/stdtypes.rst:1944 msgid ":meth:`bytes.replace`" msgstr ":meth:`bytes.replace`" -#: ../../builtins/stdtypes.rst:1675 +#: ../../builtins/stdtypes.rst:1946 msgid "Splitting and Joining" msgstr "分割和連接" -#: ../../builtins/stdtypes.rst:1675 +#: ../../builtins/stdtypes.rst:1946 msgid ":meth:`str.split`" msgstr ":meth:`str.split`" -#: ../../builtins/stdtypes.rst:1675 +#: ../../builtins/stdtypes.rst:1946 msgid ":meth:`str.rsplit`" msgstr ":meth:`str.rsplit`" -#: ../../builtins/stdtypes.rst:1675 +#: ../../builtins/stdtypes.rst:1946 msgid ":meth:`bytes.split`" msgstr ":meth:`bytes.split`" -#: ../../builtins/stdtypes.rst:1675 +#: ../../builtins/stdtypes.rst:1946 msgid ":meth:`bytes.rsplit`" msgstr ":meth:`bytes.rsplit`" -#: ../../builtins/stdtypes.rst:1677 +#: ../../builtins/stdtypes.rst:1948 msgid ":meth:`str.splitlines`" msgstr ":meth:`str.splitlines`" -#: ../../builtins/stdtypes.rst:1677 +#: ../../builtins/stdtypes.rst:1948 msgid ":meth:`bytes.splitlines`" msgstr ":meth:`bytes.splitlines`" -#: ../../builtins/stdtypes.rst:1679 +#: ../../builtins/stdtypes.rst:1950 msgid ":meth:`str.partition`" msgstr ":meth:`str.partition`" -#: ../../builtins/stdtypes.rst:1679 +#: ../../builtins/stdtypes.rst:1950 msgid ":meth:`bytes.partition`" msgstr ":meth:`bytes.partition`" -#: ../../builtins/stdtypes.rst:1681 +#: ../../builtins/stdtypes.rst:1952 msgid ":meth:`str.rpartition`" msgstr ":meth:`str.rpartition`" -#: ../../builtins/stdtypes.rst:1681 +#: ../../builtins/stdtypes.rst:1952 msgid ":meth:`bytes.rpartition`" msgstr ":meth:`bytes.rpartition`" -#: ../../builtins/stdtypes.rst:1683 +#: ../../builtins/stdtypes.rst:1954 msgid ":meth:`str.join`" msgstr ":meth:`str.join`" -#: ../../builtins/stdtypes.rst:1683 +#: ../../builtins/stdtypes.rst:1954 msgid ":meth:`bytes.join`" msgstr ":meth:`bytes.join`" -#: ../../builtins/stdtypes.rst:1685 +#: ../../builtins/stdtypes.rst:1956 msgid "String Classification" msgstr "字串分類" -#: ../../builtins/stdtypes.rst:1685 +#: ../../builtins/stdtypes.rst:1956 msgid ":meth:`str.isalpha`" msgstr ":meth:`str.isalpha`" -#: ../../builtins/stdtypes.rst:1685 +#: ../../builtins/stdtypes.rst:1956 msgid ":meth:`bytes.isalpha`" msgstr ":meth:`bytes.isalpha`" -#: ../../builtins/stdtypes.rst:1687 +#: ../../builtins/stdtypes.rst:1958 msgid ":meth:`str.isdecimal`" msgstr ":meth:`str.isdecimal`" -#: ../../builtins/stdtypes.rst:1689 +#: ../../builtins/stdtypes.rst:1960 msgid ":meth:`str.isdigit`" msgstr ":meth:`str.isdigit`" -#: ../../builtins/stdtypes.rst:1689 +#: ../../builtins/stdtypes.rst:1960 msgid ":meth:`bytes.isdigit`" msgstr ":meth:`bytes.isdigit`" -#: ../../builtins/stdtypes.rst:1691 +#: ../../builtins/stdtypes.rst:1962 msgid ":meth:`str.isnumeric`" msgstr ":meth:`str.isnumeric`" -#: ../../builtins/stdtypes.rst:1693 +#: ../../builtins/stdtypes.rst:1964 msgid ":meth:`str.isalnum`" msgstr ":meth:`str.isalnum`" -#: ../../builtins/stdtypes.rst:1693 +#: ../../builtins/stdtypes.rst:1964 msgid ":meth:`bytes.isalnum`" msgstr ":meth:`bytes.isalnum`" -#: ../../builtins/stdtypes.rst:1695 +#: ../../builtins/stdtypes.rst:1966 msgid ":meth:`str.isidentifier`" msgstr ":meth:`str.isidentifier`" -#: ../../builtins/stdtypes.rst:1697 +#: ../../builtins/stdtypes.rst:1968 msgid ":meth:`str.islower`" msgstr ":meth:`str.islower`" -#: ../../builtins/stdtypes.rst:1697 +#: ../../builtins/stdtypes.rst:1968 msgid ":meth:`bytes.islower`" msgstr ":meth:`bytes.islower`" -#: ../../builtins/stdtypes.rst:1699 +#: ../../builtins/stdtypes.rst:1970 msgid ":meth:`str.isupper`" msgstr ":meth:`str.isupper`" -#: ../../builtins/stdtypes.rst:1699 +#: ../../builtins/stdtypes.rst:1970 msgid ":meth:`bytes.isupper`" msgstr ":meth:`bytes.isupper`" -#: ../../builtins/stdtypes.rst:1701 +#: ../../builtins/stdtypes.rst:1972 msgid ":meth:`str.istitle`" msgstr ":meth:`str.istitle`" -#: ../../builtins/stdtypes.rst:1701 +#: ../../builtins/stdtypes.rst:1972 msgid ":meth:`bytes.istitle`" msgstr ":meth:`bytes.istitle`" -#: ../../builtins/stdtypes.rst:1703 +#: ../../builtins/stdtypes.rst:1974 msgid ":meth:`str.isspace`" msgstr ":meth:`str.isspace`" -#: ../../builtins/stdtypes.rst:1703 +#: ../../builtins/stdtypes.rst:1974 msgid ":meth:`bytes.isspace`" msgstr ":meth:`bytes.isspace`" -#: ../../builtins/stdtypes.rst:1705 +#: ../../builtins/stdtypes.rst:1976 msgid ":meth:`str.isprintable`" msgstr ":meth:`str.isprintable`" -#: ../../builtins/stdtypes.rst:1707 +#: ../../builtins/stdtypes.rst:1978 msgid "Case Manipulation" msgstr "大小寫操作" -#: ../../builtins/stdtypes.rst:1707 +#: ../../builtins/stdtypes.rst:1978 msgid ":meth:`str.lower`" msgstr ":meth:`str.lower`" -#: ../../builtins/stdtypes.rst:1707 +#: ../../builtins/stdtypes.rst:1978 msgid ":meth:`bytes.lower`" msgstr ":meth:`bytes.lower`" -#: ../../builtins/stdtypes.rst:1709 +#: ../../builtins/stdtypes.rst:1980 msgid ":meth:`str.upper`" msgstr ":meth:`str.upper`" -#: ../../builtins/stdtypes.rst:1709 +#: ../../builtins/stdtypes.rst:1980 msgid ":meth:`bytes.upper`" msgstr ":meth:`bytes.upper`" -#: ../../builtins/stdtypes.rst:1711 +#: ../../builtins/stdtypes.rst:1982 msgid ":meth:`str.casefold`" msgstr ":meth:`str.casefold`" -#: ../../builtins/stdtypes.rst:1713 +#: ../../builtins/stdtypes.rst:1984 msgid ":meth:`str.capitalize`" msgstr ":meth:`str.capitalize`" -#: ../../builtins/stdtypes.rst:1713 +#: ../../builtins/stdtypes.rst:1984 msgid ":meth:`bytes.capitalize`" msgstr ":meth:`bytes.capitalize`" -#: ../../builtins/stdtypes.rst:1715 +#: ../../builtins/stdtypes.rst:1986 msgid ":meth:`str.title`" msgstr ":meth:`str.title`" -#: ../../builtins/stdtypes.rst:1715 +#: ../../builtins/stdtypes.rst:1986 msgid ":meth:`bytes.title`" msgstr ":meth:`bytes.title`" -#: ../../builtins/stdtypes.rst:1717 +#: ../../builtins/stdtypes.rst:1988 msgid ":meth:`str.swapcase`" msgstr ":meth:`str.swapcase`" -#: ../../builtins/stdtypes.rst:1717 +#: ../../builtins/stdtypes.rst:1988 msgid ":meth:`bytes.swapcase`" msgstr ":meth:`bytes.swapcase`" -#: ../../builtins/stdtypes.rst:1719 +#: ../../builtins/stdtypes.rst:1990 msgid "Padding and Stripping" msgstr "填充和去除空白" -#: ../../builtins/stdtypes.rst:1719 +#: ../../builtins/stdtypes.rst:1990 msgid ":meth:`str.ljust`" msgstr ":meth:`str.ljust`" -#: ../../builtins/stdtypes.rst:1719 +#: ../../builtins/stdtypes.rst:1990 msgid ":meth:`str.rjust`" msgstr ":meth:`str.rjust`" -#: ../../builtins/stdtypes.rst:1719 +#: ../../builtins/stdtypes.rst:1990 msgid ":meth:`bytes.ljust`" msgstr ":meth:`bytes.ljust`" -#: ../../builtins/stdtypes.rst:1719 +#: ../../builtins/stdtypes.rst:1990 msgid ":meth:`bytes.rjust`" msgstr ":meth:`bytes.rjust`" -#: ../../builtins/stdtypes.rst:1721 +#: ../../builtins/stdtypes.rst:1992 msgid ":meth:`str.center`" msgstr ":meth:`str.center`" -#: ../../builtins/stdtypes.rst:1721 +#: ../../builtins/stdtypes.rst:1992 msgid ":meth:`bytes.center`" msgstr ":meth:`bytes.center`" -#: ../../builtins/stdtypes.rst:1723 +#: ../../builtins/stdtypes.rst:1994 msgid ":meth:`str.expandtabs`" msgstr ":meth:`str.expandtabs`" -#: ../../builtins/stdtypes.rst:1723 +#: ../../builtins/stdtypes.rst:1994 msgid ":meth:`bytes.expandtabs`" msgstr ":meth:`bytes.expandtabs`" -#: ../../builtins/stdtypes.rst:1725 +#: ../../builtins/stdtypes.rst:1996 msgid ":meth:`str.strip`" msgstr ":meth:`str.strip`" -#: ../../builtins/stdtypes.rst:1725 +#: ../../builtins/stdtypes.rst:1996 msgid ":meth:`bytes.strip`" msgstr ":meth:`bytes.strip`" -#: ../../builtins/stdtypes.rst:1727 +#: ../../builtins/stdtypes.rst:1998 msgid ":meth:`str.lstrip`" msgstr ":meth:`str.lstrip`" -#: ../../builtins/stdtypes.rst:1727 +#: ../../builtins/stdtypes.rst:1998 msgid ":meth:`str.rstrip`" msgstr ":meth:`str.rstrip`" -#: ../../builtins/stdtypes.rst:1727 +#: ../../builtins/stdtypes.rst:1998 msgid ":meth:`bytes.lstrip`" msgstr ":meth:`bytes.lstrip`" -#: ../../builtins/stdtypes.rst:1727 +#: ../../builtins/stdtypes.rst:1998 msgid ":meth:`bytes.rstrip`" msgstr ":meth:`bytes.rstrip`" -#: ../../builtins/stdtypes.rst:1729 +#: ../../builtins/stdtypes.rst:2000 msgid ":meth:`str.removeprefix`" msgstr ":meth:`str.removeprefix`" -#: ../../builtins/stdtypes.rst:1729 +#: ../../builtins/stdtypes.rst:2000 msgid ":meth:`bytes.removeprefix`" msgstr ":meth:`bytes.removeprefix`" -#: ../../builtins/stdtypes.rst:1731 +#: ../../builtins/stdtypes.rst:2002 msgid ":meth:`str.removesuffix`" msgstr ":meth:`str.removesuffix`" -#: ../../builtins/stdtypes.rst:1731 +#: ../../builtins/stdtypes.rst:2002 msgid ":meth:`bytes.removesuffix`" msgstr ":meth:`bytes.removesuffix`" -#: ../../builtins/stdtypes.rst:1733 +#: ../../builtins/stdtypes.rst:2004 msgid "Translation and Encoding" msgstr "翻譯和編碼" -#: ../../builtins/stdtypes.rst:1733 +#: ../../builtins/stdtypes.rst:2004 msgid ":meth:`str.translate`" msgstr ":meth:`str.translate`" -#: ../../builtins/stdtypes.rst:1733 +#: ../../builtins/stdtypes.rst:2004 msgid ":meth:`bytes.translate`" msgstr ":meth:`bytes.translate`" -#: ../../builtins/stdtypes.rst:1735 +#: ../../builtins/stdtypes.rst:2006 msgid ":meth:`str.maketrans`" msgstr ":meth:`str.maketrans`" -#: ../../builtins/stdtypes.rst:1735 +#: ../../builtins/stdtypes.rst:2006 msgid ":meth:`bytes.maketrans`" msgstr ":meth:`bytes.maketrans`" -#: ../../builtins/stdtypes.rst:1737 +#: ../../builtins/stdtypes.rst:2008 msgid ":meth:`str.encode`" msgstr ":meth:`str.encode`" -#: ../../builtins/stdtypes.rst:1739 +#: ../../builtins/stdtypes.rst:2010 msgid ":meth:`bytes.decode`" msgstr ":meth:`bytes.decode`" -#: ../../builtins/stdtypes.rst:1745 +#: ../../builtins/stdtypes.rst:2016 msgid "Text Sequence Type --- :class:`str`" msgstr "" -#: ../../builtins/stdtypes.rst:1747 +#: ../../builtins/stdtypes.rst:2018 msgid "" "Textual data in Python is handled with :class:`str` objects, " "or :dfn:`strings`. Strings are immutable :ref:`sequences ` of " "Unicode code points. String literals are written in a variety of ways:" msgstr "" -#: ../../builtins/stdtypes.rst:1752 +#: ../../builtins/stdtypes.rst:2023 msgid "Single quotes: ``'allows embedded \"double\" quotes'``" msgstr "" -#: ../../builtins/stdtypes.rst:1753 +#: ../../builtins/stdtypes.rst:2024 msgid "Double quotes: ``\"allows embedded 'single' quotes\"``" msgstr "" -#: ../../builtins/stdtypes.rst:1754 +#: ../../builtins/stdtypes.rst:2025 msgid "" "Triple quoted: ``'''Three single quotes'''``, ``\"\"\"Three double " "quotes\"\"\"``" msgstr "" -#: ../../builtins/stdtypes.rst:1756 +#: ../../builtins/stdtypes.rst:2027 msgid "" "Triple quoted strings may span multiple lines - all associated whitespace " "will be included in the string literal." msgstr "" -#: ../../builtins/stdtypes.rst:1759 +#: ../../builtins/stdtypes.rst:2030 msgid "" "String literals that are part of a single expression and have only " "whitespace between them will be implicitly converted to a single string " "literal. That is, ``(\"spam \" \"eggs\") == \"spam eggs\"``." msgstr "" -#: ../../builtins/stdtypes.rst:1763 +#: ../../builtins/stdtypes.rst:2034 msgid "" "See :ref:`strings` for more about the various forms of string literal, " "including supported :ref:`escape sequences `, and the " "``r`` (\"raw\") prefix that disables most escape sequence processing." msgstr "" -#: ../../builtins/stdtypes.rst:1767 +#: ../../builtins/stdtypes.rst:2038 msgid "" "Strings may also be created from other objects using the :class:`str` " "constructor." msgstr "" -#: ../../builtins/stdtypes.rst:1770 +#: ../../builtins/stdtypes.rst:2041 msgid "" "Since there is no separate \"character\" type, indexing a string produces " "strings of length 1. That is, for a non-empty string *s*, ``s[0] == s[0:1]``." msgstr "" -#: ../../builtins/stdtypes.rst:1776 +#: ../../builtins/stdtypes.rst:2047 msgid "" "There is also no mutable string type, but :meth:`str.join` " "or :class:`io.StringIO` can be used to efficiently construct strings from " "multiple fragments." msgstr "" -#: ../../builtins/stdtypes.rst:1780 +#: ../../builtins/stdtypes.rst:2051 msgid "" "For backwards compatibility with the Python 2 series, the ``u`` prefix is " "once again permitted on string literals. It has no effect on the meaning of " "string literals and cannot be combined with the ``r`` prefix." msgstr "" -#: ../../builtins/stdtypes.rst:1794 +#: ../../builtins/stdtypes.rst:2065 msgid "" "Return a :ref:`string ` version of *object*. If *object* is not " "provided, returns the empty string. Otherwise, the behavior of ``str()`` " "depends on whether *encoding* or *errors* is given, as follows." msgstr "" -#: ../../builtins/stdtypes.rst:1798 +#: ../../builtins/stdtypes.rst:2069 msgid "" "If neither *encoding* nor *errors* is given, ``str(object)`` " "returns :meth:`type(object).__str__(object) `, which is the " @@ -3061,7 +3416,7 @@ msgid "" "returning :func:`repr(object) `." msgstr "" -#: ../../builtins/stdtypes.rst:1810 +#: ../../builtins/stdtypes.rst:2081 msgid "" "If at least one of *encoding* or *errors* is given, *object* should be " "a :term:`bytes-like object` (e.g. :class:`bytes` or :class:`bytearray`). In " @@ -3073,7 +3428,7 @@ msgid "" "for information on buffer objects." msgstr "" -#: ../../builtins/stdtypes.rst:1819 +#: ../../builtins/stdtypes.rst:2090 msgid "" "Passing a :class:`bytes` object to :func:`str` without the *encoding* or " "*errors* arguments falls under the first case of returning the informal " @@ -3081,7 +3436,7 @@ msgid "" "Python). For example::" msgstr "" -#: ../../builtins/stdtypes.rst:1824 +#: ../../builtins/stdtypes.rst:2095 msgid "" ">>> str(b'Zoot!')\n" "\"b'Zoot!'\"" @@ -3089,7 +3444,7 @@ msgstr "" ">>> str(b'Zoot!')\n" "\"b'Zoot!'\"" -#: ../../builtins/stdtypes.rst:1827 +#: ../../builtins/stdtypes.rst:2098 msgid "" "For more information on the ``str`` class and its methods, " "see :ref:`textseq` and the :ref:`string-methods` section below. To output " @@ -3097,17 +3452,17 @@ msgid "" "sections. In addition, see the :ref:`stringservices` section." msgstr "" -#: ../../builtins/stdtypes.rst:1839 +#: ../../builtins/stdtypes.rst:2110 msgid "String Methods" msgstr "字串方法" -#: ../../builtins/stdtypes.rst:1844 +#: ../../builtins/stdtypes.rst:2115 msgid "" "Strings implement all of the :ref:`common ` sequence " "operations, along with the additional methods described below." msgstr "" -#: ../../builtins/stdtypes.rst:1847 +#: ../../builtins/stdtypes.rst:2118 msgid "" "Strings also support two styles of string formatting, one providing a large " "degree of flexibility and customization " @@ -3117,33 +3472,33 @@ msgid "" "for the cases it can handle (:ref:`old-string-formatting`)." msgstr "" -#: ../../builtins/stdtypes.rst:1854 +#: ../../builtins/stdtypes.rst:2125 msgid "" "The :ref:`textservices` section of the standard library covers a number of " "other modules that provide various text related utilities (including regular " "expression support in the :mod:`re` module)." msgstr "" -#: ../../builtins/stdtypes.rst:1860 +#: ../../builtins/stdtypes.rst:2131 msgid "" "Return a copy of the string with its first character capitalized and the " "rest lowercased." msgstr "" -#: ../../builtins/stdtypes.rst:1863 +#: ../../builtins/stdtypes.rst:2134 msgid "" "The first character is now put into titlecase rather than uppercase. This " "means that characters like digraphs will only have their first letter " "capitalized, instead of the full character." msgstr "" -#: ../../builtins/stdtypes.rst:1870 +#: ../../builtins/stdtypes.rst:2141 msgid "" "Return a casefolded copy of the string. Casefolded strings may be used for " "caseless matching." msgstr "" -#: ../../builtins/stdtypes.rst:1873 +#: ../../builtins/stdtypes.rst:2144 msgid "" "Casefolding is similar to lowercasing but more aggressive because it is " "intended to remove all case distinctions in a string. For example, the " @@ -3152,7 +3507,7 @@ msgid "" "``'ß'``; :meth:`casefold` converts it to ``\"ss\"``. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:1880 +#: ../../builtins/stdtypes.rst:2151 msgid "" ">>> 'straße'.lower()\n" "'straße'\n" @@ -3164,21 +3519,21 @@ msgstr "" ">>> 'straße'.casefold()\n" "'strasse'" -#: ../../builtins/stdtypes.rst:1887 +#: ../../builtins/stdtypes.rst:2158 msgid "" -"The casefolding algorithm is `described in section 3.13 'Default Case " +"The casefolding algorithm is `described in section 3.13.3 'Default Case " "Folding' of the Unicode Standard `__." +"Unicode17.0.0/core-spec/chapter-3/#G53253>`__." msgstr "" -#: ../../builtins/stdtypes.rst:1896 +#: ../../builtins/stdtypes.rst:2167 msgid "" "Return centered in a string of length *width*. Padding is done using the " "specified *fillchar* (default is an ASCII space). The original string is " "returned if *width* is less than or equal to ``len(s)``. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:1900 +#: ../../builtins/stdtypes.rst:2171 msgid "" ">>> 'Python'.center(10)\n" "' Python '\n" @@ -3194,20 +3549,20 @@ msgstr "" ">>> 'Python'.center(4)\n" "'Python'" -#: ../../builtins/stdtypes.rst:1910 +#: ../../builtins/stdtypes.rst:2181 msgid "" "Return the number of non-overlapping occurrences of substring *sub* in the " "range [*start*, *end*]. Optional arguments *start* and *end* are " "interpreted as in slice notation." msgstr "" -#: ../../builtins/stdtypes.rst:1914 +#: ../../builtins/stdtypes.rst:2185 msgid "" "If *sub* is empty, returns the number of empty strings between characters " "which is the length of the string plus one. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:1917 +#: ../../builtins/stdtypes.rst:2188 msgid "" ">>> 'spam, spam, spam'.count('spam')\n" "3\n" @@ -3231,17 +3586,17 @@ msgstr "" ">>> 'spam, spam, spam'.count('')\n" "17" -#: ../../builtins/stdtypes.rst:1930 +#: ../../builtins/stdtypes.rst:2201 msgid "Return the string encoded to :class:`bytes`." msgstr "" -#: ../../builtins/stdtypes.rst:1932 ../../builtins/stdtypes.rst:3646 +#: ../../builtins/stdtypes.rst:2203 ../../builtins/stdtypes.rst:3953 msgid "" "*encoding* defaults to ``'utf-8'``; see :ref:`standard-encodings` for " "possible values." msgstr "" -#: ../../builtins/stdtypes.rst:1935 +#: ../../builtins/stdtypes.rst:2206 msgid "" "*errors* controls how encoding errors are handled. If ``'strict'`` (the " "default), a :exc:`UnicodeError` exception is raised. Other possible values " @@ -3250,14 +3605,14 @@ msgid "" "via :func:`codecs.register_error`. See :ref:`error-handlers` for details." msgstr "" -#: ../../builtins/stdtypes.rst:1942 +#: ../../builtins/stdtypes.rst:2213 msgid "" "For performance reasons, the value of *errors* is not checked for validity " "unless an encoding error actually occurs, :ref:`devmode` is enabled or " "a :ref:`debug build ` is used. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:1948 +#: ../../builtins/stdtypes.rst:2219 msgid "" ">>> encoded_str_to_bytes = 'Python'.encode()\n" ">>> type(encoded_str_to_bytes)\n" @@ -3271,17 +3626,17 @@ msgstr "" ">>> encoded_str_to_bytes\n" "b'Python'" -#: ../../builtins/stdtypes.rst:1955 ../../builtins/stdtypes.rst:3665 +#: ../../builtins/stdtypes.rst:2226 ../../builtins/stdtypes.rst:3972 msgid "Added support for keyword arguments." msgstr "新增關鍵字引數的支援。" -#: ../../builtins/stdtypes.rst:1958 ../../builtins/stdtypes.rst:3668 +#: ../../builtins/stdtypes.rst:2229 ../../builtins/stdtypes.rst:3975 msgid "" "The value of the *errors* argument is now checked in :ref:`devmode` and " "in :ref:`debug mode `." msgstr "" -#: ../../builtins/stdtypes.rst:1965 +#: ../../builtins/stdtypes.rst:2236 msgid "" "Return ``True`` if the string ends with the specified *suffix*, otherwise " "return ``False``. *suffix* can also be a tuple of suffixes to look for. " @@ -3290,7 +3645,7 @@ msgid "" "equivalent to ``str[start:end].endswith(suffix)``. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:1971 +#: ../../builtins/stdtypes.rst:2242 msgid "" ">>> 'Python'.endswith('on')\n" "True\n" @@ -3310,11 +3665,11 @@ msgstr "" ">>> 'Python is amazing'.endswith('is', 0, 9)\n" "True" -#: ../../builtins/stdtypes.rst:1980 +#: ../../builtins/stdtypes.rst:2251 msgid "See also :meth:`startswith` and :meth:`removesuffix`." msgstr "另請參閱 :meth:`startswith` 和 :meth:`removesuffix`。" -#: ../../builtins/stdtypes.rst:1985 +#: ../../builtins/stdtypes.rst:2256 msgid "" "Return a copy of the string where all tab characters are replaced by one or " "more spaces, depending on the current column and the given tab size. Tab " @@ -3330,7 +3685,7 @@ msgid "" "printed. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:1998 +#: ../../builtins/stdtypes.rst:2269 msgid "" ">>> '01\\t012\\t0123\\t01234'.expandtabs()\n" "'01 012 0123 01234'\n" @@ -3348,7 +3703,7 @@ msgstr "" "01 012\n" "0123 01234" -#: ../../builtins/stdtypes.rst:2009 +#: ../../builtins/stdtypes.rst:2280 msgid "" "Return the lowest index in the string where substring *sub* is found within " "the slice ``s[start:end]``. Optional arguments *start* and *end* are " @@ -3356,7 +3711,7 @@ msgid "" "example::" msgstr "" -#: ../../builtins/stdtypes.rst:2014 +#: ../../builtins/stdtypes.rst:2285 msgid "" ">>> 'spam, spam, spam'.find('sp')\n" "0\n" @@ -3368,18 +3723,18 @@ msgstr "" ">>> 'spam, spam, spam'.find('sp', 5)\n" "6" -#: ../../builtins/stdtypes.rst:2019 +#: ../../builtins/stdtypes.rst:2290 msgid "See also :meth:`rfind` and :meth:`index`." msgstr "另請參閱 :meth:`rfind` 和 :meth:`index`。" -#: ../../builtins/stdtypes.rst:2023 +#: ../../builtins/stdtypes.rst:2294 msgid "" "The :meth:`~str.find` method should be used only if you need to know the " "position of *sub*. To check if *sub* is a substring or not, use " "the :keyword:`in` operator::" msgstr "" -#: ../../builtins/stdtypes.rst:2027 +#: ../../builtins/stdtypes.rst:2298 msgid "" ">>> 'Py' in 'Python'\n" "True" @@ -3387,7 +3742,7 @@ msgstr "" ">>> 'Py' in 'Python'\n" "True" -#: ../../builtins/stdtypes.rst:2033 +#: ../../builtins/stdtypes.rst:2304 msgid "" "Perform a string formatting operation. The string on which this method is " "called can contain literal text or replacement fields delimited by braces " @@ -3397,7 +3752,7 @@ msgid "" "the corresponding argument. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2040 +#: ../../builtins/stdtypes.rst:2311 msgid "" ">>> \"The sum of 1 + 2 is {0}\".format(1+2)\n" "'The sum of 1 + 2 is 3'\n" @@ -3407,13 +3762,13 @@ msgid "" "'Nobody expects the Spanish Inquisition!'" msgstr "" -#: ../../builtins/stdtypes.rst:2049 +#: ../../builtins/stdtypes.rst:2320 msgid "" "See :ref:`formatstrings` for a description of the various formatting options " "that can be specified in format strings." msgstr "" -#: ../../builtins/stdtypes.rst:2053 +#: ../../builtins/stdtypes.rst:2324 msgid "" "When formatting a number " "(:class:`int`, :class:`float`, :class:`complex`, :class:`decimal.Decimal` " @@ -3425,26 +3780,26 @@ msgid "" "temporary change affects other threads." msgstr "" -#: ../../builtins/stdtypes.rst:2062 +#: ../../builtins/stdtypes.rst:2333 msgid "" "When formatting a number with the ``n`` type, the function sets temporarily " "the ``LC_CTYPE`` locale to the ``LC_NUMERIC`` locale in some cases." msgstr "" -#: ../../builtins/stdtypes.rst:2070 +#: ../../builtins/stdtypes.rst:2341 msgid "" "Similar to ``str.format(**mapping)``, except that ``mapping`` is used " "directly and not copied to a :class:`dict`. This is useful if for example " "``mapping`` is a dict subclass:" msgstr "" -#: ../../builtins/stdtypes.rst:2086 +#: ../../builtins/stdtypes.rst:2357 msgid "" "Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is " "not found. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2089 +#: ../../builtins/stdtypes.rst:2360 msgid "" ">>> 'spam, spam, spam'.index('spam')\n" "0\n" @@ -3464,11 +3819,11 @@ msgstr "" " ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" "ValueError: substring not found" -#: ../../builtins/stdtypes.rst:2100 +#: ../../builtins/stdtypes.rst:2371 msgid "See also :meth:`rindex`." msgstr "另請參閱 :meth:`rindex`。" -#: ../../builtins/stdtypes.rst:2105 +#: ../../builtins/stdtypes.rst:2376 msgid "" "Return ``True`` if all characters in the string are alphanumeric and there " "is at least one character, ``False`` otherwise. A character ``c`` is " @@ -3476,7 +3831,7 @@ msgid "" "``c.isdecimal()``, ``c.isdigit()``, or ``c.isnumeric()``. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2110 +#: ../../builtins/stdtypes.rst:2381 msgid "" ">>> 'abc123'.isalnum()\n" "True\n" @@ -3496,19 +3851,19 @@ msgstr "" ">>> ' '.isalnum()\n" "False" -#: ../../builtins/stdtypes.rst:2124 +#: ../../builtins/stdtypes.rst:2395 msgid "" "Return ``True`` if all characters in the string are alphabetic and there is " "at least one character, ``False`` otherwise. Alphabetic characters are " -"those characters defined in the Unicode character database as \"Letter\", " -"i.e., those with general category property being one of \"Lm\", \"Lt\", " +"those characters defined in the Unicode character database as \"Letter\", i." +"e., those with general category property being one of \"Lm\", \"Lt\", " "\"Lu\", \"Ll\", or \"Lo\". Note that this is different from the `Alphabetic " "property defined in section 4.10 'Letters, Alphabetic, and Ideographic' of " -"the Unicode Standard `_. For example:" +"the Unicode Standard `__. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2133 +#: ../../builtins/stdtypes.rst:2404 msgid "" ">>> 'Letters and spaces'.isalpha()\n" "False\n" @@ -3525,18 +3880,18 @@ msgstr "" ">>> 'µ'.isalpha() # 非 ASCII 字元也可以被視為字母\n" "True" -#: ../../builtins/stdtypes.rst:2142 +#: ../../builtins/stdtypes.rst:2413 msgid "See :ref:`unicode-properties`." msgstr "請參閱 :ref:`unicode-properties`。" -#: ../../builtins/stdtypes.rst:2147 +#: ../../builtins/stdtypes.rst:2418 msgid "" "Return ``True`` if the string is empty or all characters in the string are " "ASCII, ``False`` otherwise. ASCII characters have code points in the range " "U+0000-U+007F. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2151 +#: ../../builtins/stdtypes.rst:2422 msgid "" ">>> 'ASCII characters'.isascii()\n" "True\n" @@ -3548,7 +3903,7 @@ msgstr "" ">>> 'µ'.isascii()\n" "False" -#: ../../builtins/stdtypes.rst:2163 +#: ../../builtins/stdtypes.rst:2434 msgid "" "Return ``True`` if all characters in the string are decimal characters and " "there is at least one character, ``False`` otherwise. Decimal characters are " @@ -3557,7 +3912,7 @@ msgid "" "Unicode General Category \"Nd\". For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2170 +#: ../../builtins/stdtypes.rst:2441 msgid "" ">>> '0123456789'.isdecimal()\n" "True\n" @@ -3573,7 +3928,7 @@ msgstr "" ">>> 'alphabetic'.isdecimal()\n" "False" -#: ../../builtins/stdtypes.rst:2182 +#: ../../builtins/stdtypes.rst:2453 msgid "" "Return ``True`` if all characters in the string are digits and there is at " "least one character, ``False`` otherwise. Digits include decimal characters " @@ -3584,18 +3939,18 @@ msgid "" "property value Numeric_Type=Digit or Numeric_Type=Decimal." msgstr "" -#: ../../builtins/stdtypes.rst:2190 ../../builtins/stdtypes.rst:2271 -#: ../../builtins/stdtypes.rst:2288 ../../builtins/stdtypes.rst:2315 -#: ../../builtins/stdtypes.rst:2370 ../../builtins/stdtypes.rst:2443 -#: ../../builtins/stdtypes.rst:2554 ../../builtins/stdtypes.rst:2575 -#: ../../builtins/stdtypes.rst:2640 ../../builtins/stdtypes.rst:2661 -#: ../../builtins/stdtypes.rst:2675 ../../builtins/stdtypes.rst:2762 -#: ../../builtins/stdtypes.rst:2786 ../../builtins/stdtypes.rst:2800 -#: ../../builtins/stdtypes.rst:2907 +#: ../../builtins/stdtypes.rst:2461 ../../builtins/stdtypes.rst:2542 +#: ../../builtins/stdtypes.rst:2559 ../../builtins/stdtypes.rst:2586 +#: ../../builtins/stdtypes.rst:2641 ../../builtins/stdtypes.rst:2718 +#: ../../builtins/stdtypes.rst:2829 ../../builtins/stdtypes.rst:2850 +#: ../../builtins/stdtypes.rst:2915 ../../builtins/stdtypes.rst:2936 +#: ../../builtins/stdtypes.rst:2950 ../../builtins/stdtypes.rst:3037 +#: ../../builtins/stdtypes.rst:3061 ../../builtins/stdtypes.rst:3075 +#: ../../builtins/stdtypes.rst:3190 msgid "For example:" msgstr "舉例來說:" -#: ../../builtins/stdtypes.rst:2192 +#: ../../builtins/stdtypes.rst:2463 msgid "" ">>> '0123456789'.isdigit()\n" "True\n" @@ -3615,27 +3970,27 @@ msgstr "" ">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" "(False, True, True)" -#: ../../builtins/stdtypes.rst:2203 +#: ../../builtins/stdtypes.rst:2474 msgid "See also :meth:`isdecimal` and :meth:`isnumeric`." msgstr "另請參閱 :meth:`isdecimal` 和 :meth:`isnumeric`。" -#: ../../builtins/stdtypes.rst:2208 +#: ../../builtins/stdtypes.rst:2479 msgid "" "Return ``True`` if the string is a valid identifier according to the " "language definition, section :ref:`identifiers`." msgstr "" -#: ../../builtins/stdtypes.rst:2211 +#: ../../builtins/stdtypes.rst:2482 msgid "" ":func:`keyword.iskeyword` can be used to test whether string ``s`` is a " "reserved identifier, such as :keyword:`def` and :keyword:`class`." msgstr "" -#: ../../builtins/stdtypes.rst:2214 +#: ../../builtins/stdtypes.rst:2485 msgid "Example: ::" msgstr "範例: ::" -#: ../../builtins/stdtypes.rst:2217 +#: ../../builtins/stdtypes.rst:2488 msgid "" ">>> from keyword import iskeyword\n" "\n" @@ -3651,13 +4006,13 @@ msgstr "" ">>> 'def'.isidentifier(), iskeyword('def')\n" "(True, True)" -#: ../../builtins/stdtypes.rst:2227 +#: ../../builtins/stdtypes.rst:2498 msgid "" "Return ``True`` if all cased characters [4]_ in the string are lowercase and " "there is at least one cased character, ``False`` otherwise." msgstr "" -#: ../../builtins/stdtypes.rst:2233 +#: ../../builtins/stdtypes.rst:2504 msgid "" "Return ``True`` if all characters in the string are numeric characters, and " "there is at least one character, ``False`` otherwise. Numeric characters " @@ -3667,7 +4022,7 @@ msgid "" "Numeric_Type=Decimal or Numeric_Type=Numeric. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2241 +#: ../../builtins/stdtypes.rst:2512 msgid "" ">>> '0123456789'.isnumeric()\n" "True\n" @@ -3687,17 +4042,17 @@ msgstr "" ">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" "(False, True, True)" -#: ../../builtins/stdtypes.rst:2252 +#: ../../builtins/stdtypes.rst:2523 msgid "See also :meth:`isdecimal` and :meth:`isdigit`." msgstr "另請參閱 :meth:`isdecimal` 和 :meth:`isdigit`。" -#: ../../builtins/stdtypes.rst:2257 +#: ../../builtins/stdtypes.rst:2528 msgid "" "Return ``True`` if all characters in the string are printable, ``False`` if " "it contains at least one non-printable character." msgstr "" -#: ../../builtins/stdtypes.rst:2260 +#: ../../builtins/stdtypes.rst:2531 msgid "" "Here \"printable\" means the character is suitable for :func:`repr` to use " "in its output; \"non-printable\" means that :func:`repr` on built-in types " @@ -3705,7 +4060,7 @@ msgid "" "written to :data:`sys.stdout` or :data:`sys.stderr`." msgstr "" -#: ../../builtins/stdtypes.rst:2265 +#: ../../builtins/stdtypes.rst:2536 msgid "" "The printable characters are those which in the Unicode character database " "(see :mod:`unicodedata`) have a general category in group Letter, Mark, " @@ -3714,7 +4069,7 @@ msgid "" "C), except the ASCII space." msgstr "" -#: ../../builtins/stdtypes.rst:2273 +#: ../../builtins/stdtypes.rst:2544 msgid "" ">>> ''.isprintable(), ' '.isprintable()\n" "(True, True)\n" @@ -3726,17 +4081,17 @@ msgstr "" ">>> '\\t'.isprintable(), '\\n'.isprintable()\n" "(False, False)" -#: ../../builtins/stdtypes.rst:2280 +#: ../../builtins/stdtypes.rst:2551 msgid "See also :meth:`isspace`." msgstr "另請參閱 :meth:`isspace`。" -#: ../../builtins/stdtypes.rst:2285 +#: ../../builtins/stdtypes.rst:2556 msgid "" "Return ``True`` if there are only whitespace characters in the string and " "there is at least one character, ``False`` otherwise." msgstr "" -#: ../../builtins/stdtypes.rst:2290 +#: ../../builtins/stdtypes.rst:2561 msgid "" ">>> ''.isspace()\n" "False\n" @@ -3748,7 +4103,7 @@ msgid "" "True" msgstr "" -#: ../../builtins/stdtypes.rst:2301 +#: ../../builtins/stdtypes.rst:2572 msgid "" "A character is *whitespace* if in the Unicode character database " "(see :mod:`unicodedata`), either its general category is ``Zs`` " @@ -3756,11 +4111,11 @@ msgid "" "or ``S``." msgstr "" -#: ../../builtins/stdtypes.rst:2306 +#: ../../builtins/stdtypes.rst:2577 msgid "See also :meth:`isprintable`." msgstr "另請參閱 :meth:`isprintable`。" -#: ../../builtins/stdtypes.rst:2311 +#: ../../builtins/stdtypes.rst:2582 msgid "" "Return ``True`` if the string is a titlecased string and there is at least " "one character, for example uppercase characters may only follow uncased " @@ -3768,7 +4123,7 @@ msgid "" "otherwise." msgstr "" -#: ../../builtins/stdtypes.rst:2317 +#: ../../builtins/stdtypes.rst:2588 msgid "" ">>> 'Spam, Spam, Spam'.istitle()\n" "True\n" @@ -3784,17 +4139,17 @@ msgstr "" ">>> 'SPAM, SPAM, SPAM'.istitle()\n" "False" -#: ../../builtins/stdtypes.rst:2326 +#: ../../builtins/stdtypes.rst:2597 msgid "See also :meth:`title`." msgstr "另請參閱 :meth:`title`。" -#: ../../builtins/stdtypes.rst:2331 +#: ../../builtins/stdtypes.rst:2602 msgid "" "Return ``True`` if all cased characters [4]_ in the string are uppercase and " "there is at least one cased character, ``False`` otherwise." msgstr "" -#: ../../builtins/stdtypes.rst:2349 +#: ../../builtins/stdtypes.rst:2620 msgid "" "Return a string which is the concatenation of the strings in *iterable*. " "A :exc:`TypeError` will be raised if there are any non-string values in " @@ -3802,7 +4157,7 @@ msgid "" "elements is the string providing this method. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2354 +#: ../../builtins/stdtypes.rst:2625 msgid "" ">>> ', '.join(['spam', 'spam', 'spam'])\n" "'spam, spam, spam'\n" @@ -3814,18 +4169,18 @@ msgstr "" ">>> '-'.join('Python')\n" "'P-y-t-h-o-n'" -#: ../../builtins/stdtypes.rst:2361 +#: ../../builtins/stdtypes.rst:2632 msgid "See also :meth:`split`." msgstr "另請參閱 :meth:`split`。" -#: ../../builtins/stdtypes.rst:2366 +#: ../../builtins/stdtypes.rst:2637 msgid "" "Return the string left justified in a string of length *width*. Padding is " "done using the specified *fillchar* (default is an ASCII space). The " "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../builtins/stdtypes.rst:2372 +#: ../../builtins/stdtypes.rst:2643 msgid "" ">>> 'Python'.ljust(10)\n" "'Python '\n" @@ -3841,17 +4196,17 @@ msgstr "" ">>> 'Monty Python'.ljust(10, '.')\n" "'Monty Python'" -#: ../../builtins/stdtypes.rst:2381 ../../builtins/stdtypes.rst:2916 +#: ../../builtins/stdtypes.rst:2652 ../../builtins/stdtypes.rst:3199 msgid "See also :meth:`rjust`." msgstr "另請參閱 :meth:`rjust`。" -#: ../../builtins/stdtypes.rst:2386 +#: ../../builtins/stdtypes.rst:2657 msgid "" "Return a copy of the string with all the cased characters [4]_ converted to " "lowercase. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2389 +#: ../../builtins/stdtypes.rst:2660 msgid "" ">>> 'Lower Method Example'.lower()\n" "'lower method example'" @@ -3859,14 +4214,14 @@ msgstr "" ">>> 'Lower Method Example'.lower()\n" "'lower method example'" -#: ../../builtins/stdtypes.rst:2394 +#: ../../builtins/stdtypes.rst:2665 msgid "" -"The lowercasing algorithm used is `described in section 3.13 'Default Case " -"Folding' of the Unicode Standard `__." +"The lowercasing algorithm used is `described in section 3.13.2 'Default Case " +"Conversion' of the Unicode Standard `__." msgstr "" -#: ../../builtins/stdtypes.rst:2401 +#: ../../builtins/stdtypes.rst:2672 msgid "" "Return a copy of the string with leading characters removed. The *chars* " "argument is a string specifying the set of characters to be removed. If " @@ -3875,7 +4230,7 @@ msgid "" "are stripped::" msgstr "" -#: ../../builtins/stdtypes.rst:2406 +#: ../../builtins/stdtypes.rst:2677 msgid "" ">>> ' spacious '.lstrip()\n" "'spacious '\n" @@ -3887,13 +4242,13 @@ msgstr "" ">>> 'www.example.com'.lstrip('cmowz.')\n" "'example.com'" -#: ../../builtins/stdtypes.rst:2411 +#: ../../builtins/stdtypes.rst:2682 msgid "" "See :meth:`str.removeprefix` for a method that will remove a single prefix " "string rather than all of a set of characters. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:2414 +#: ../../builtins/stdtypes.rst:2685 msgid "" ">>> 'Arthur: three!'.lstrip('Arthur: ')\n" "'ee!'\n" @@ -3905,13 +4260,13 @@ msgstr "" ">>> 'Arthur: three!'.removeprefix('Arthur: ')\n" "'three!'" -#: ../../builtins/stdtypes.rst:2423 +#: ../../builtins/stdtypes.rst:2694 msgid "" "This static method returns a translation table usable " "for :meth:`str.translate`." msgstr "" -#: ../../builtins/stdtypes.rst:2425 +#: ../../builtins/stdtypes.rst:2696 msgid "" "If there is only one argument, it must be a dictionary mapping Unicode " "ordinals (integers) or characters (strings of length 1) to Unicode ordinals, " @@ -3919,7 +4274,7 @@ msgid "" "converted to ordinals." msgstr "" -#: ../../builtins/stdtypes.rst:2430 +#: ../../builtins/stdtypes.rst:2701 msgid "" "If there are two arguments, they must be strings of equal length, and in the " "resulting dictionary, each character in *from* will be mapped to the " @@ -3927,7 +4282,11 @@ msgid "" "must be a string, whose characters will be mapped to ``None`` in the result." msgstr "" -#: ../../builtins/stdtypes.rst:2438 +#: ../../builtins/stdtypes.rst:2708 +msgid "*dict* can now be a :class:`frozendict`." +msgstr "" + +#: ../../builtins/stdtypes.rst:2713 msgid "" "Split the string at the first occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself, and the part " @@ -3935,7 +4294,7 @@ msgid "" "containing the string itself, followed by two empty strings." msgstr "" -#: ../../builtins/stdtypes.rst:2445 +#: ../../builtins/stdtypes.rst:2720 msgid "" ">>> 'Monty Python'.partition(' ')\n" "('Monty', ' ', 'Python')\n" @@ -3951,17 +4310,17 @@ msgstr "" ">>> 'Monty Python'.partition('-')\n" "('Monty Python', '', '')" -#: ../../builtins/stdtypes.rst:2454 +#: ../../builtins/stdtypes.rst:2729 msgid "See also :meth:`rpartition`." msgstr "另請參閱 :meth:`rpartition`。" -#: ../../builtins/stdtypes.rst:2459 +#: ../../builtins/stdtypes.rst:2734 msgid "" "If the string starts with the *prefix* string, return " "``string[len(prefix):]``. Otherwise, return a copy of the original string:" msgstr "" -#: ../../builtins/stdtypes.rst:2463 +#: ../../builtins/stdtypes.rst:2738 msgid "" ">>> 'TestHook'.removeprefix('Test')\n" "'Hook'\n" @@ -3973,18 +4332,18 @@ msgstr "" ">>> 'BaseTestCase'.removeprefix('Test')\n" "'BaseTestCase'" -#: ../../builtins/stdtypes.rst:2472 +#: ../../builtins/stdtypes.rst:2747 msgid "See also :meth:`removesuffix` and :meth:`startswith`." msgstr "另請參閱 :meth:`removesuffix` 和 :meth:`startswith`。" -#: ../../builtins/stdtypes.rst:2477 +#: ../../builtins/stdtypes.rst:2752 msgid "" "If the string ends with the *suffix* string and that *suffix* is not empty, " "return ``string[:-len(suffix)]``. Otherwise, return a copy of the original " "string:" msgstr "" -#: ../../builtins/stdtypes.rst:2481 +#: ../../builtins/stdtypes.rst:2756 msgid "" ">>> 'MiscTests'.removesuffix('Tests')\n" "'Misc'\n" @@ -3996,11 +4355,11 @@ msgstr "" ">>> 'TmpDirMixin'.removesuffix('Tests')\n" "'TmpDirMixin'" -#: ../../builtins/stdtypes.rst:2490 +#: ../../builtins/stdtypes.rst:2765 msgid "See also :meth:`removeprefix` and :meth:`endswith`." msgstr "另請參閱 :meth:`removeprefix` 和 :meth:`endswith`。" -#: ../../builtins/stdtypes.rst:2495 +#: ../../builtins/stdtypes.rst:2770 msgid "" "Return a copy of the string with all occurrences of substring *old* replaced " "by *new*. If *count* is given, only the first *count* occurrences are " @@ -4008,7 +4367,7 @@ msgid "" "replaced. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2500 +#: ../../builtins/stdtypes.rst:2775 msgid "" ">>> 'spam, spam, spam'.replace('spam', 'eggs')\n" "'eggs, eggs, eggs'\n" @@ -4020,11 +4379,11 @@ msgstr "" ">>> 'spam, spam, spam'.replace('spam', 'eggs', 1)\n" "'eggs, spam, spam'" -#: ../../builtins/stdtypes.rst:2507 +#: ../../builtins/stdtypes.rst:2782 ../../builtins/stdtypes.rst:4079 msgid "*count* is now supported as a keyword argument." msgstr "*count* 現在作為關鍵字引數被支援。" -#: ../../builtins/stdtypes.rst:2513 +#: ../../builtins/stdtypes.rst:2788 msgid "" "Return the highest index in the string where substring *sub* is found, such " "that *sub* is contained within ``s[start:end]``. Optional arguments *start* " @@ -4032,7 +4391,7 @@ msgid "" "For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2518 +#: ../../builtins/stdtypes.rst:2793 msgid "" ">>> 'spam, spam, spam'.rfind('sp')\n" "12\n" @@ -4044,17 +4403,17 @@ msgstr "" ">>> 'spam, spam, spam'.rfind('sp', 0, 10)\n" "6" -#: ../../builtins/stdtypes.rst:2525 +#: ../../builtins/stdtypes.rst:2800 msgid "See also :meth:`find` and :meth:`rindex`." msgstr "另請參閱 :meth:`find` 和 :meth:`rindex`。" -#: ../../builtins/stdtypes.rst:2530 +#: ../../builtins/stdtypes.rst:2805 msgid "" "Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is " "not found. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2534 +#: ../../builtins/stdtypes.rst:2809 msgid "" ">>> 'spam, spam, spam'.rindex('spam')\n" "12\n" @@ -4074,18 +4433,18 @@ msgstr "" " ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" "ValueError: substring not found" -#: ../../builtins/stdtypes.rst:2545 +#: ../../builtins/stdtypes.rst:2820 msgid "See also :meth:`index` and :meth:`find`." msgstr "另請參閱 :meth:`index` 和 :meth:`find`。" -#: ../../builtins/stdtypes.rst:2550 +#: ../../builtins/stdtypes.rst:2825 msgid "" "Return the string right justified in a string of length *width*. Padding is " "done using the specified *fillchar* (default is an ASCII space). The " "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../builtins/stdtypes.rst:2556 +#: ../../builtins/stdtypes.rst:2831 msgid "" ">>> 'Python'.rjust(10)\n" "' Python'\n" @@ -4101,11 +4460,11 @@ msgstr "" ">>> 'Monty Python'.rjust(10, '.')\n" "'Monty Python'" -#: ../../builtins/stdtypes.rst:2565 +#: ../../builtins/stdtypes.rst:2840 msgid "See also :meth:`ljust` and :meth:`zfill`." msgstr "另請參閱 :meth:`ljust` 和 :meth:`zfill`。" -#: ../../builtins/stdtypes.rst:2570 +#: ../../builtins/stdtypes.rst:2845 msgid "" "Split the string at the last occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself, and the part " @@ -4113,7 +4472,7 @@ msgid "" "containing two empty strings, followed by the string itself." msgstr "" -#: ../../builtins/stdtypes.rst:2577 +#: ../../builtins/stdtypes.rst:2852 msgid "" ">>> 'Monty Python'.rpartition(' ')\n" "('Monty', ' ', 'Python')\n" @@ -4129,11 +4488,11 @@ msgstr "" ">>> 'Monty Python'.rpartition('-')\n" "('', '', 'Monty Python')" -#: ../../builtins/stdtypes.rst:2586 +#: ../../builtins/stdtypes.rst:2861 msgid "See also :meth:`partition`." msgstr "另請參閱 :meth:`partition`。" -#: ../../builtins/stdtypes.rst:2591 +#: ../../builtins/stdtypes.rst:2866 msgid "" "Return a list of the words in the string, using *sep* as the delimiter " "string. If *maxsplit* is given, at most *maxsplit* splits are done, the " @@ -4143,7 +4502,7 @@ msgid "" "described in detail below." msgstr "" -#: ../../builtins/stdtypes.rst:2601 +#: ../../builtins/stdtypes.rst:2876 msgid "" "Return a copy of the string with trailing characters removed. The *chars* " "argument is a string specifying the set of characters to be removed. If " @@ -4152,7 +4511,7 @@ msgid "" "are stripped. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2607 +#: ../../builtins/stdtypes.rst:2882 msgid "" ">>> ' spacious '.rstrip()\n" "' spacious'\n" @@ -4164,13 +4523,13 @@ msgstr "" ">>> 'mississippi'.rstrip('ipz')\n" "'mississ'" -#: ../../builtins/stdtypes.rst:2614 +#: ../../builtins/stdtypes.rst:2889 msgid "" "See :meth:`removesuffix` for a method that will remove a single suffix " "string rather than all of a set of characters. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:2617 +#: ../../builtins/stdtypes.rst:2892 msgid "" ">>> 'Monty Python'.rstrip(' Python')\n" "'M'\n" @@ -4182,11 +4541,11 @@ msgstr "" ">>> 'Monty Python'.removesuffix(' Python')\n" "'Monty'" -#: ../../builtins/stdtypes.rst:2622 +#: ../../builtins/stdtypes.rst:2897 msgid "See also :meth:`strip`." msgstr "另請參閱 :meth:`strip`。" -#: ../../builtins/stdtypes.rst:2627 +#: ../../builtins/stdtypes.rst:2902 msgid "" "Return a list of the words in the string, using *sep* as the delimiter " "string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, " @@ -4195,7 +4554,7 @@ msgid "" "possible splits are made)." msgstr "" -#: ../../builtins/stdtypes.rst:2633 +#: ../../builtins/stdtypes.rst:2908 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns " @@ -4205,7 +4564,7 @@ msgid "" "returns ``['']``." msgstr "" -#: ../../builtins/stdtypes.rst:2642 +#: ../../builtins/stdtypes.rst:2917 msgid "" ">>> '1,2,3'.split(',')\n" "['1', '2', '3']\n" @@ -4225,7 +4584,7 @@ msgstr "" ">>> '1<>2<>3<4'.split('<>')\n" "['1', '2', '3<4']" -#: ../../builtins/stdtypes.rst:2653 +#: ../../builtins/stdtypes.rst:2928 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive :meth:`whitespace ` are regarded " @@ -4235,7 +4594,7 @@ msgid "" "whitespace with a ``None`` separator returns ``[]``." msgstr "" -#: ../../builtins/stdtypes.rst:2663 +#: ../../builtins/stdtypes.rst:2938 msgid "" ">>> '1 2 3'.split()\n" "['1', '2', '3']\n" @@ -4251,13 +4610,13 @@ msgstr "" ">>> ' 1 2 3 '.split()\n" "['1', '2', '3']" -#: ../../builtins/stdtypes.rst:2672 +#: ../../builtins/stdtypes.rst:2947 msgid "" "If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only " "leading runs of consecutive whitespace are considered." msgstr "" -#: ../../builtins/stdtypes.rst:2677 +#: ../../builtins/stdtypes.rst:2952 msgid "" ">>> \"\".split(None, 0)\n" "[]\n" @@ -4273,136 +4632,136 @@ msgstr "" ">>> \" foo \".split(maxsplit=0)\n" "['foo ']" -#: ../../builtins/stdtypes.rst:2686 +#: ../../builtins/stdtypes.rst:2961 msgid "See also :meth:`join` and :meth:`rsplit`." msgstr "另請參閱 :meth:`join` 和 :meth:`rsplit`。" -#: ../../builtins/stdtypes.rst:2694 +#: ../../builtins/stdtypes.rst:2969 msgid "" "Return a list of the lines in the string, breaking at line boundaries. Line " "breaks are not included in the resulting list unless *keepends* is given and " "true." msgstr "" -#: ../../builtins/stdtypes.rst:2698 +#: ../../builtins/stdtypes.rst:2973 msgid "" "This method splits on the following line boundaries. In particular, the " "boundaries are a superset of :term:`universal newlines`." msgstr "" -#: ../../builtins/stdtypes.rst:2702 +#: ../../builtins/stdtypes.rst:2977 msgid "Representation" msgstr "" -#: ../../builtins/stdtypes.rst:2702 +#: ../../builtins/stdtypes.rst:2977 msgid "Description" msgstr "描述" -#: ../../builtins/stdtypes.rst:2704 +#: ../../builtins/stdtypes.rst:2979 msgid "``\\n``" msgstr "``\\n``" -#: ../../builtins/stdtypes.rst:2704 +#: ../../builtins/stdtypes.rst:2979 msgid "Line Feed" msgstr "" -#: ../../builtins/stdtypes.rst:2706 +#: ../../builtins/stdtypes.rst:2981 msgid "``\\r``" msgstr "``\\r``" -#: ../../builtins/stdtypes.rst:2706 +#: ../../builtins/stdtypes.rst:2981 msgid "Carriage Return" msgstr "" -#: ../../builtins/stdtypes.rst:2708 +#: ../../builtins/stdtypes.rst:2983 msgid "``\\r\\n``" msgstr "``\\r\\n``" -#: ../../builtins/stdtypes.rst:2708 +#: ../../builtins/stdtypes.rst:2983 msgid "Carriage Return + Line Feed" msgstr "" -#: ../../builtins/stdtypes.rst:2710 +#: ../../builtins/stdtypes.rst:2985 msgid "``\\v`` or ``\\x0b``" msgstr "``\\v`` 或 ``\\x0b``" -#: ../../builtins/stdtypes.rst:2710 +#: ../../builtins/stdtypes.rst:2985 msgid "Line Tabulation" msgstr "" -#: ../../builtins/stdtypes.rst:2712 +#: ../../builtins/stdtypes.rst:2987 msgid "``\\f`` or ``\\x0c``" msgstr "``\\f`` 或 ``\\x0c``" -#: ../../builtins/stdtypes.rst:2712 +#: ../../builtins/stdtypes.rst:2987 msgid "Form Feed" msgstr "" -#: ../../builtins/stdtypes.rst:2714 +#: ../../builtins/stdtypes.rst:2989 msgid "``\\x1c``" msgstr "``\\x1c``" -#: ../../builtins/stdtypes.rst:2714 +#: ../../builtins/stdtypes.rst:2989 msgid "File Separator" msgstr "" -#: ../../builtins/stdtypes.rst:2716 +#: ../../builtins/stdtypes.rst:2991 msgid "``\\x1d``" msgstr "``\\x1d``" -#: ../../builtins/stdtypes.rst:2716 +#: ../../builtins/stdtypes.rst:2991 msgid "Group Separator" msgstr "" -#: ../../builtins/stdtypes.rst:2718 +#: ../../builtins/stdtypes.rst:2993 msgid "``\\x1e``" msgstr "``\\x1e``" -#: ../../builtins/stdtypes.rst:2718 +#: ../../builtins/stdtypes.rst:2993 msgid "Record Separator" msgstr "" -#: ../../builtins/stdtypes.rst:2720 +#: ../../builtins/stdtypes.rst:2995 msgid "``\\x85``" msgstr "``\\x85``" -#: ../../builtins/stdtypes.rst:2720 +#: ../../builtins/stdtypes.rst:2995 msgid "Next Line (C1 Control Code)" msgstr "" -#: ../../builtins/stdtypes.rst:2722 +#: ../../builtins/stdtypes.rst:2997 msgid "``\\u2028``" msgstr "``\\u2028``" -#: ../../builtins/stdtypes.rst:2722 +#: ../../builtins/stdtypes.rst:2997 msgid "Line Separator" msgstr "" -#: ../../builtins/stdtypes.rst:2724 +#: ../../builtins/stdtypes.rst:2999 msgid "``\\u2029``" msgstr "``\\u2029``" -#: ../../builtins/stdtypes.rst:2724 +#: ../../builtins/stdtypes.rst:2999 msgid "Paragraph Separator" msgstr "" -#: ../../builtins/stdtypes.rst:2729 +#: ../../builtins/stdtypes.rst:3004 msgid "``\\v`` and ``\\f`` added to list of line boundaries." msgstr "" -#: ../../builtins/stdtypes.rst:2731 ../../builtins/stdtypes.rst:2837 -#: ../../builtins/stdtypes.rst:3006 ../../builtins/stdtypes.rst:3984 -#: ../../builtins/stdtypes.rst:4003 ../../builtins/stdtypes.rst:4094 -#: ../../builtins/stdtypes.rst:4110 ../../builtins/stdtypes.rst:4135 -#: ../../builtins/stdtypes.rst:4149 ../../builtins/stdtypes.rst:4177 -#: ../../builtins/stdtypes.rst:4191 ../../builtins/stdtypes.rst:4209 -#: ../../builtins/stdtypes.rst:4236 ../../builtins/stdtypes.rst:4259 -#: ../../builtins/stdtypes.rst:4286 ../../builtins/stdtypes.rst:4328 -#: ../../builtins/stdtypes.rst:4352 +#: ../../builtins/stdtypes.rst:3006 ../../builtins/stdtypes.rst:3112 +#: ../../builtins/stdtypes.rst:3289 ../../builtins/stdtypes.rst:4295 +#: ../../builtins/stdtypes.rst:4314 ../../builtins/stdtypes.rst:4405 +#: ../../builtins/stdtypes.rst:4421 ../../builtins/stdtypes.rst:4446 +#: ../../builtins/stdtypes.rst:4460 ../../builtins/stdtypes.rst:4488 +#: ../../builtins/stdtypes.rst:4502 ../../builtins/stdtypes.rst:4520 +#: ../../builtins/stdtypes.rst:4547 ../../builtins/stdtypes.rst:4570 +#: ../../builtins/stdtypes.rst:4597 ../../builtins/stdtypes.rst:4639 +#: ../../builtins/stdtypes.rst:4663 msgid "For example::" msgstr "舉例來說: ::" -#: ../../builtins/stdtypes.rst:2733 +#: ../../builtins/stdtypes.rst:3008 msgid "" ">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" "['ab c', '', 'de fg', 'kl']\n" @@ -4414,14 +4773,14 @@ msgstr "" ">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']" -#: ../../builtins/stdtypes.rst:2738 +#: ../../builtins/stdtypes.rst:3013 msgid "" "Unlike :meth:`~str.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -#: ../../builtins/stdtypes.rst:2742 +#: ../../builtins/stdtypes.rst:3017 msgid "" ">>> \"\".splitlines()\n" "[]\n" @@ -4433,11 +4792,11 @@ msgstr "" ">>> \"One line\\n\".splitlines()\n" "['One line']" -#: ../../builtins/stdtypes.rst:2747 +#: ../../builtins/stdtypes.rst:3022 msgid "For comparison, ``split('\\n')`` gives::" msgstr "" -#: ../../builtins/stdtypes.rst:2749 +#: ../../builtins/stdtypes.rst:3024 msgid "" ">>> ''.split('\\n')\n" "['']\n" @@ -4449,7 +4808,7 @@ msgstr "" ">>> 'Two lines\\n'.split('\\n')\n" "['Two lines', '']" -#: ../../builtins/stdtypes.rst:2757 +#: ../../builtins/stdtypes.rst:3032 msgid "" "Return ``True`` if string starts with the *prefix*, otherwise return " "``False``. *prefix* can also be a tuple of prefixes to look for. With " @@ -4457,7 +4816,7 @@ msgid "" "*end*, stop comparing string at that position." msgstr "" -#: ../../builtins/stdtypes.rst:2764 +#: ../../builtins/stdtypes.rst:3039 msgid "" ">>> 'Python'.startswith('Py')\n" "True\n" @@ -4473,11 +4832,11 @@ msgstr "" ">>> 'Python is amazing'.startswith('is', 7)\n" "True" -#: ../../builtins/stdtypes.rst:2773 +#: ../../builtins/stdtypes.rst:3048 msgid "See also :meth:`endswith` and :meth:`removeprefix`." msgstr "另請參閱 :meth:`endswith` 和 :meth:`removeprefix`。" -#: ../../builtins/stdtypes.rst:2778 +#: ../../builtins/stdtypes.rst:3053 msgid "" "Return a copy of the string with the leading and trailing characters " "removed. The *chars* argument is a string specifying the set of characters " @@ -4486,11 +4845,11 @@ msgid "" "all combinations of its values are stripped." msgstr "" -#: ../../builtins/stdtypes.rst:2784 +#: ../../builtins/stdtypes.rst:3059 msgid "Whitespace characters are defined by :meth:`str.isspace`." msgstr "" -#: ../../builtins/stdtypes.rst:2788 +#: ../../builtins/stdtypes.rst:3063 msgid "" ">>> ' spacious '.strip()\n" "'spacious'\n" @@ -4502,7 +4861,7 @@ msgstr "" ">>> 'www.example.com'.strip('cmowz.')\n" "'example'" -#: ../../builtins/stdtypes.rst:2795 +#: ../../builtins/stdtypes.rst:3070 msgid "" "The outermost leading and trailing *chars* argument values are stripped from " "the string. Characters are removed from the leading end until reaching a " @@ -4510,7 +4869,7 @@ msgid "" "A similar action takes place on the trailing end." msgstr "" -#: ../../builtins/stdtypes.rst:2802 +#: ../../builtins/stdtypes.rst:3077 msgid "" ">>> comment_string = '#....... Section 3.2.1 Issue #32 .......'\n" ">>> comment_string.strip('.#! ')\n" @@ -4520,17 +4879,17 @@ msgstr "" ">>> comment_string.strip('.#! ')\n" "'Section 3.2.1 Issue #32'" -#: ../../builtins/stdtypes.rst:2808 +#: ../../builtins/stdtypes.rst:3083 msgid "See also :meth:`rstrip`." msgstr "另請參閱 :meth:`rstrip`。" -#: ../../builtins/stdtypes.rst:2813 +#: ../../builtins/stdtypes.rst:3088 msgid "" "Return a copy of the string with uppercase characters converted to lowercase " "and vice versa. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2816 +#: ../../builtins/stdtypes.rst:3091 msgid "" ">>> 'Hello World'.swapcase()\n" "'hELLO wORLD'" @@ -4538,13 +4897,13 @@ msgstr "" ">>> 'Hello World'.swapcase()\n" "'hELLO wORLD'" -#: ../../builtins/stdtypes.rst:2821 +#: ../../builtins/stdtypes.rst:3096 msgid "" "Note that it is not necessarily true that ``s.swapcase().swapcase() == s``. " "For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2824 +#: ../../builtins/stdtypes.rst:3099 msgid "" ">>> 'straße'.swapcase().swapcase()\n" "'strasse'" @@ -4552,17 +4911,17 @@ msgstr "" ">>> 'straße'.swapcase().swapcase()\n" "'strasse'" -#: ../../builtins/stdtypes.rst:2829 +#: ../../builtins/stdtypes.rst:3104 msgid "See also :meth:`str.lower` and :meth:`str.upper`." msgstr "另請參閱 :meth:`str.lower` 和 :meth:`str.upper`。" -#: ../../builtins/stdtypes.rst:2834 +#: ../../builtins/stdtypes.rst:3109 msgid "" "Return a titlecased version of the string where words start with an " "uppercase character and the remaining characters are lowercase." msgstr "" -#: ../../builtins/stdtypes.rst:2839 +#: ../../builtins/stdtypes.rst:3114 msgid "" ">>> 'Hello world'.title()\n" "'Hello World'" @@ -4570,7 +4929,7 @@ msgstr "" ">>> 'Hello world'.title()\n" "'Hello World'" -#: ../../builtins/stdtypes.rst:2842 ../../builtins/stdtypes.rst:4296 +#: ../../builtins/stdtypes.rst:3117 ../../builtins/stdtypes.rst:4607 msgid "" "The algorithm uses a simple language-independent definition of a word as " "groups of consecutive letters. The definition works in many contexts but it " @@ -4578,7 +4937,7 @@ msgid "" "which may not be the desired result::" msgstr "" -#: ../../builtins/stdtypes.rst:2847 +#: ../../builtins/stdtypes.rst:3122 msgid "" ">>> \"they're bill's friends from the UK\".title()\n" "\"They'Re Bill'S Friends From The Uk\"" @@ -4586,19 +4945,19 @@ msgstr "" ">>> \"they're bill's friends from the UK\".title()\n" "\"They'Re Bill'S Friends From The Uk\"" -#: ../../builtins/stdtypes.rst:2850 +#: ../../builtins/stdtypes.rst:3125 msgid "" "The :func:`string.capwords` function does not have this problem, as it " "splits words on spaces only." msgstr "" -#: ../../builtins/stdtypes.rst:2853 +#: ../../builtins/stdtypes.rst:3128 msgid "" "Alternatively, a workaround for apostrophes can be constructed using regular " "expressions::" msgstr "" -#: ../../builtins/stdtypes.rst:2856 +#: ../../builtins/stdtypes.rst:3131 msgid "" ">>> import re\n" ">>> def titlecase(s):\n" @@ -4618,11 +4977,11 @@ msgstr "" ">>> titlecase(\"they're bill's friends.\")\n" "\"They're Bill's Friends.\"" -#: ../../builtins/stdtypes.rst:2865 +#: ../../builtins/stdtypes.rst:3140 msgid "See also :meth:`istitle`." msgstr "另請參閱 :meth:`istitle`。" -#: ../../builtins/stdtypes.rst:2870 +#: ../../builtins/stdtypes.rst:3145 msgid "" "Return a copy of the string in which each character has been mapped through " "the given translation table. The table must be an object that implements " @@ -4634,19 +4993,33 @@ msgid "" "a :exc:`LookupError` exception, to map the character to itself." msgstr "" -#: ../../builtins/stdtypes.rst:2879 +#: ../../builtins/stdtypes.rst:3154 msgid "" "You can use :meth:`str.maketrans` to create a translation map from character-" "to-character mappings in different formats." msgstr "" -#: ../../builtins/stdtypes.rst:2882 +#: ../../builtins/stdtypes.rst:3157 +msgid "" +"The following example uses a mapping to replace ``'a'`` with ``'X'``, " +"``'b'`` with ``'Y'``, and delete ``'c'``:" +msgstr "" + +#: ../../builtins/stdtypes.rst:3160 +msgid "" +">>> 'abc123'.translate({ord('a'): 'X', ord('b'): 'Y', ord('c'): None})\n" +"'XY123'" +msgstr "" +">>> 'abc123'.translate({ord('a'): 'X', ord('b'): 'Y', ord('c'): None})\n" +"'XY123'" + +#: ../../builtins/stdtypes.rst:3165 msgid "" "See also the :mod:`codecs` module for a more flexible approach to custom " "character mappings." msgstr "" -#: ../../builtins/stdtypes.rst:2888 +#: ../../builtins/stdtypes.rst:3171 msgid "" "Return a copy of the string with all the cased characters [4]_ converted to " "uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s`` " @@ -4655,14 +5028,14 @@ msgid "" "titlecase)." msgstr "" -#: ../../builtins/stdtypes.rst:2894 +#: ../../builtins/stdtypes.rst:3177 msgid "" -"The uppercasing algorithm used is `described in section 3.13 'Default Case " -"Folding' of the Unicode Standard `__." +"The uppercasing algorithm used is `described in section 3.13.2 'Default Case " +"Conversion' of the Unicode Standard `__." msgstr "" -#: ../../builtins/stdtypes.rst:2901 +#: ../../builtins/stdtypes.rst:3184 msgid "" "Return a copy of the string left filled with ASCII ``'0'`` digits to make a " "string of length *width*. A leading sign prefix (``'+'``/``'-'``) is handled " @@ -4670,7 +5043,7 @@ msgid "" "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../builtins/stdtypes.rst:2909 +#: ../../builtins/stdtypes.rst:3192 msgid "" ">>> \"42\".zfill(5)\n" "'00042'\n" @@ -4682,27 +5055,27 @@ msgstr "" ">>> \"-42\".zfill(5)\n" "'-0042'" -#: ../../builtins/stdtypes.rst:2936 +#: ../../builtins/stdtypes.rst:3219 msgid "Formatted String Literals (f-strings)" msgstr "" -#: ../../builtins/stdtypes.rst:2939 +#: ../../builtins/stdtypes.rst:3222 msgid "" "The :keyword:`await` and :keyword:`async for` can be used in expressions " "within f-strings." msgstr "" -#: ../../builtins/stdtypes.rst:2942 +#: ../../builtins/stdtypes.rst:3225 msgid "Added the debug specifier (``=``)" msgstr "" -#: ../../builtins/stdtypes.rst:2944 +#: ../../builtins/stdtypes.rst:3227 msgid "" "Many restrictions on expressions within f-strings have been removed. " "Notably, nested strings, comments, and backslashes are now permitted." msgstr "" -#: ../../builtins/stdtypes.rst:2948 +#: ../../builtins/stdtypes.rst:3231 msgid "" "An :dfn:`f-string` (formally a :dfn:`formatted string literal`) is a string " "literal that is prefixed with ``f`` or ``F``. This type of string literal " @@ -4711,29 +5084,29 @@ msgid "" "replacement field must contain an expression, optionally followed by:" msgstr "" -#: ../../builtins/stdtypes.rst:2955 +#: ../../builtins/stdtypes.rst:3238 msgid "a *debug specifier* -- an equal sign (``=``);" msgstr "" -#: ../../builtins/stdtypes.rst:2956 +#: ../../builtins/stdtypes.rst:3239 msgid "a *conversion specifier* -- ``!s``, ``!r`` or ``!a``; and/or" msgstr "" -#: ../../builtins/stdtypes.rst:2957 +#: ../../builtins/stdtypes.rst:3240 msgid "a *format specifier* prefixed with a colon (``:``)." msgstr "" -#: ../../builtins/stdtypes.rst:2959 +#: ../../builtins/stdtypes.rst:3242 msgid "" "See the :ref:`Lexical Analysis section on f-strings ` for details " "on the syntax of these fields." msgstr "" -#: ../../builtins/stdtypes.rst:2963 +#: ../../builtins/stdtypes.rst:3246 msgid "Debug specifier" msgstr "" -#: ../../builtins/stdtypes.rst:2967 +#: ../../builtins/stdtypes.rst:3250 msgid "" "If a debug specifier -- an equal sign (``=``) -- appears after the " "replacement field expression, the resulting f-string will contain the " @@ -4741,7 +5114,7 @@ msgid "" "is often useful for debugging::" msgstr "" -#: ../../builtins/stdtypes.rst:2972 +#: ../../builtins/stdtypes.rst:3255 msgid "" ">>> number = 14.3\n" ">>> f'{number=}'\n" @@ -4751,13 +5124,13 @@ msgstr "" ">>> f'{number=}'\n" "'number=14.3'" -#: ../../builtins/stdtypes.rst:2976 +#: ../../builtins/stdtypes.rst:3259 msgid "" "Whitespace before, inside and after the expression, as well as whitespace " "after the equal sign, is significant --- it is retained in the result::" msgstr "" -#: ../../builtins/stdtypes.rst:2979 +#: ../../builtins/stdtypes.rst:3262 msgid "" ">>> f'{ number - 4 = }'\n" "' number - 4 = 10.3'" @@ -4765,17 +5138,17 @@ msgstr "" ">>> f'{ number - 4 = }'\n" "' number - 4 = 10.3'" -#: ../../builtins/stdtypes.rst:2984 +#: ../../builtins/stdtypes.rst:3267 msgid "Conversion specifier" msgstr "" -#: ../../builtins/stdtypes.rst:2986 +#: ../../builtins/stdtypes.rst:3269 msgid "" "By default, the value of a replacement field expression is converted to a " "string using :func:`str`::" msgstr "" -#: ../../builtins/stdtypes.rst:2989 +#: ../../builtins/stdtypes.rst:3272 msgid "" ">>> from fractions import Fraction\n" ">>> one_third = Fraction(1, 3)\n" @@ -4787,13 +5160,13 @@ msgstr "" ">>> f'{one_third}'\n" "'1/3'" -#: ../../builtins/stdtypes.rst:2994 +#: ../../builtins/stdtypes.rst:3277 msgid "" "When a debug specifier but no format specifier is used, the default " "conversion instead uses :func:`repr`::" msgstr "" -#: ../../builtins/stdtypes.rst:2997 +#: ../../builtins/stdtypes.rst:3280 msgid "" ">>> f'{one_third = }'\n" "'one_third = Fraction(1, 3)'" @@ -4801,24 +5174,24 @@ msgstr "" ">>> f'{one_third = }'\n" "'one_third = Fraction(1, 3)'" -#: ../../builtins/stdtypes.rst:3000 +#: ../../builtins/stdtypes.rst:3283 msgid "" "The conversion can be specified explicitly using one of these specifiers:" msgstr "" -#: ../../builtins/stdtypes.rst:3002 +#: ../../builtins/stdtypes.rst:3285 msgid "``!s`` for :func:`str`" msgstr "``!s`` 用於 :func:`str`" -#: ../../builtins/stdtypes.rst:3003 +#: ../../builtins/stdtypes.rst:3286 msgid "``!r`` for :func:`repr`" msgstr "``!r`` 用於 :func:`repr`" -#: ../../builtins/stdtypes.rst:3004 +#: ../../builtins/stdtypes.rst:3287 msgid "``!a`` for :func:`ascii`" msgstr "``!a`` 用於 :func:`ascii`" -#: ../../builtins/stdtypes.rst:3008 +#: ../../builtins/stdtypes.rst:3291 msgid "" ">>> str(one_third)\n" "'1/3'\n" @@ -4850,11 +5223,11 @@ msgstr "" ">>> f'{string = !a}'\n" "\"string = '\\\\xa1ko\\\\u010dka \\\\U0001f638!'\"" -#: ../../builtins/stdtypes.rst:3025 +#: ../../builtins/stdtypes.rst:3308 msgid "Format specifier" msgstr "" -#: ../../builtins/stdtypes.rst:3027 +#: ../../builtins/stdtypes.rst:3310 msgid "" "After the expression has been evaluated, and possibly converted using an " "explicit conversion specifier, it is formatted using the :func:`format` " @@ -4864,7 +5237,7 @@ msgid "" "the replacement field. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:3034 +#: ../../builtins/stdtypes.rst:3317 msgid "" ">>> from fractions import Fraction\n" ">>> one_third = Fraction(1, 3)\n" @@ -4888,29 +5261,29 @@ msgstr "" ">>> f'{one_third = :~>10}~'\n" "'one_third = ~~~~~~~1/3~'" -#: ../../builtins/stdtypes.rst:3048 +#: ../../builtins/stdtypes.rst:3331 msgid "Template String Literals (t-strings)" msgstr "模板字串字面值 (t-strings)" -#: ../../builtins/stdtypes.rst:3050 +#: ../../builtins/stdtypes.rst:3333 msgid "" "A :dfn:`t-string` (formally a :dfn:`template string literal`) is a string " "literal that is prefixed with ``t`` or ``T``." msgstr "" -#: ../../builtins/stdtypes.rst:3053 +#: ../../builtins/stdtypes.rst:3336 msgid "" "These strings follow the same syntax and evaluation rules as :ref:`formatted " "string literals `, with the following differences:" msgstr "" -#: ../../builtins/stdtypes.rst:3057 +#: ../../builtins/stdtypes.rst:3340 msgid "" "Rather than evaluating to a ``str`` object, template string literals " "evaluate to a :class:`string.templatelib.Template` object." msgstr "" -#: ../../builtins/stdtypes.rst:3060 +#: ../../builtins/stdtypes.rst:3343 msgid "" "The :func:`format` protocol is not used. Instead, the format specifier and " "conversions (if any) are passed to a " @@ -4920,7 +5293,7 @@ msgid "" "handle format specifiers and conversions." msgstr "" -#: ../../builtins/stdtypes.rst:3067 +#: ../../builtins/stdtypes.rst:3350 msgid "" "Format specifiers containing nested replacement fields are evaluated " "eagerly, prior to being passed to " @@ -4931,7 +5304,7 @@ msgid "" "would be ``'.2f'``." msgstr "" -#: ../../builtins/stdtypes.rst:3075 +#: ../../builtins/stdtypes.rst:3358 msgid "" "When the equals sign ``'='`` is provided in an interpolation expression, the " "text of the expression is appended to the literal string that precedes the " @@ -4943,18 +5316,18 @@ msgid "" "specifier is provided, this will override the default behaviour." msgstr "" -#: ../../builtins/stdtypes.rst:3089 +#: ../../builtins/stdtypes.rst:3372 msgid "``printf``-style String Formatting" msgstr "" -#: ../../builtins/stdtypes.rst:3102 +#: ../../builtins/stdtypes.rst:3385 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " "dictionaries correctly)." msgstr "" -#: ../../builtins/stdtypes.rst:3106 +#: ../../builtins/stdtypes.rst:3389 msgid "" "Using :ref:`formatted string literals `, the :meth:`str.format` " "interface, or :class:`string.Template` may help avoid these errors. Each of " @@ -4962,7 +5335,7 @@ msgid "" "flexibility, and/or extensibility." msgstr "" -#: ../../builtins/stdtypes.rst:3111 +#: ../../builtins/stdtypes.rst:3394 msgid "" "String objects have one unique built-in operation: the ``%`` operator " "(modulo). This is also known as the string *formatting* or *interpolation* " @@ -4972,7 +5345,7 @@ msgid "" "function in the C language. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:3118 +#: ../../builtins/stdtypes.rst:3401 msgid "" ">>> print('%s has %d quote types.' % ('Python', 2))\n" "Python has 2 quote types." @@ -4980,7 +5353,7 @@ msgstr "" ">>> print('%s has %d quote types.' % ('Python', 2))\n" "Python has 2 quote types." -#: ../../builtins/stdtypes.rst:3123 +#: ../../builtins/stdtypes.rst:3406 msgid "" "If *format* requires a single argument, *values* may be a single non-tuple " "object. [5]_ Otherwise, *values* must be a tuple with exactly the number of " @@ -4988,36 +5361,36 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../builtins/stdtypes.rst:3133 ../../builtins/stdtypes.rst:4407 +#: ../../builtins/stdtypes.rst:3416 ../../builtins/stdtypes.rst:4718 msgid "" "A conversion specifier contains two or more characters and has the following " "components, which must occur in this order:" msgstr "" -#: ../../builtins/stdtypes.rst:3136 ../../builtins/stdtypes.rst:4410 +#: ../../builtins/stdtypes.rst:3419 ../../builtins/stdtypes.rst:4721 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: ../../builtins/stdtypes.rst:3138 ../../builtins/stdtypes.rst:4412 +#: ../../builtins/stdtypes.rst:3421 ../../builtins/stdtypes.rst:4723 msgid "" "Mapping key (optional), consisting of a parenthesised sequence of characters " "(for example, ``(somename)``)." msgstr "" -#: ../../builtins/stdtypes.rst:3141 ../../builtins/stdtypes.rst:4415 +#: ../../builtins/stdtypes.rst:3424 ../../builtins/stdtypes.rst:4726 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: ../../builtins/stdtypes.rst:3144 ../../builtins/stdtypes.rst:4418 +#: ../../builtins/stdtypes.rst:3427 ../../builtins/stdtypes.rst:4729 msgid "" "Minimum field width (optional). If specified as an ``'*'`` (asterisk), the " "actual width is read from the next element of the tuple in *values*, and the " "object to convert comes after the minimum field width and optional precision." msgstr "" -#: ../../builtins/stdtypes.rst:3148 ../../builtins/stdtypes.rst:4422 +#: ../../builtins/stdtypes.rst:3431 ../../builtins/stdtypes.rst:4733 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. " "If specified as ``'*'`` (an asterisk), the actual precision is read from the " @@ -5025,15 +5398,15 @@ msgid "" "the precision." msgstr "" -#: ../../builtins/stdtypes.rst:3153 ../../builtins/stdtypes.rst:4427 +#: ../../builtins/stdtypes.rst:3436 ../../builtins/stdtypes.rst:4738 msgid "Length modifier (optional)." msgstr "" -#: ../../builtins/stdtypes.rst:3155 ../../builtins/stdtypes.rst:4429 +#: ../../builtins/stdtypes.rst:3438 ../../builtins/stdtypes.rst:4740 msgid "Conversion type." msgstr "" -#: ../../builtins/stdtypes.rst:3157 +#: ../../builtins/stdtypes.rst:3440 msgid "" "When the right argument is a dictionary (or other mapping type), then the " "formats in the string *must* include a parenthesised mapping key into that " @@ -5041,286 +5414,286 @@ msgid "" "selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:3166 ../../builtins/stdtypes.rst:4440 +#: ../../builtins/stdtypes.rst:3449 ../../builtins/stdtypes.rst:4751 msgid "" "In this case no ``*`` specifiers may occur in a format (since they require a " "sequential parameter list)." msgstr "" -#: ../../builtins/stdtypes.rst:3169 ../../builtins/stdtypes.rst:4443 +#: ../../builtins/stdtypes.rst:3452 ../../builtins/stdtypes.rst:4754 msgid "The conversion flag characters are:" msgstr "" -#: ../../builtins/stdtypes.rst:3178 ../../builtins/stdtypes.rst:4452 +#: ../../builtins/stdtypes.rst:3461 ../../builtins/stdtypes.rst:4763 msgid "Flag" msgstr "" -#: ../../builtins/stdtypes.rst:3180 ../../builtins/stdtypes.rst:4454 +#: ../../builtins/stdtypes.rst:3463 ../../builtins/stdtypes.rst:4765 msgid "``'#'``" msgstr "``'#'``" -#: ../../builtins/stdtypes.rst:3180 ../../builtins/stdtypes.rst:4454 +#: ../../builtins/stdtypes.rst:3463 ../../builtins/stdtypes.rst:4765 msgid "" "The value conversion will use the \"alternate form\" (where defined below)." msgstr "" -#: ../../builtins/stdtypes.rst:3183 ../../builtins/stdtypes.rst:4457 +#: ../../builtins/stdtypes.rst:3466 ../../builtins/stdtypes.rst:4768 msgid "``'0'``" msgstr "``'0'``" -#: ../../builtins/stdtypes.rst:3183 ../../builtins/stdtypes.rst:4457 +#: ../../builtins/stdtypes.rst:3466 ../../builtins/stdtypes.rst:4768 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: ../../builtins/stdtypes.rst:3185 ../../builtins/stdtypes.rst:4459 +#: ../../builtins/stdtypes.rst:3468 ../../builtins/stdtypes.rst:4770 msgid "``'-'``" msgstr "``'-'``" -#: ../../builtins/stdtypes.rst:3185 ../../builtins/stdtypes.rst:4459 +#: ../../builtins/stdtypes.rst:3468 ../../builtins/stdtypes.rst:4770 msgid "" "The converted value is left adjusted (overrides the ``'0'`` conversion if " "both are given)." msgstr "" -#: ../../builtins/stdtypes.rst:3188 ../../builtins/stdtypes.rst:4462 +#: ../../builtins/stdtypes.rst:3471 ../../builtins/stdtypes.rst:4773 msgid "``' '``" msgstr "``' '``" -#: ../../builtins/stdtypes.rst:3188 ../../builtins/stdtypes.rst:4462 +#: ../../builtins/stdtypes.rst:3471 ../../builtins/stdtypes.rst:4773 msgid "" "(a space) A blank should be left before a positive number (or empty string) " "produced by a signed conversion." msgstr "" -#: ../../builtins/stdtypes.rst:3191 ../../builtins/stdtypes.rst:4465 +#: ../../builtins/stdtypes.rst:3474 ../../builtins/stdtypes.rst:4776 msgid "``'+'``" msgstr "``'+'``" -#: ../../builtins/stdtypes.rst:3191 ../../builtins/stdtypes.rst:4465 +#: ../../builtins/stdtypes.rst:3474 ../../builtins/stdtypes.rst:4776 msgid "" "A sign character (``'+'`` or ``'-'``) will precede the conversion (overrides " "a \"space\" flag)." msgstr "" -#: ../../builtins/stdtypes.rst:3195 ../../builtins/stdtypes.rst:4469 +#: ../../builtins/stdtypes.rst:3478 ../../builtins/stdtypes.rst:4780 msgid "" "A length modifier (``h``, ``l``, or ``L``) may be present, but is ignored as " "it is not necessary for Python -- so e.g. ``%ld`` is identical to ``%d``." msgstr "" -#: ../../builtins/stdtypes.rst:3198 ../../builtins/stdtypes.rst:4472 +#: ../../builtins/stdtypes.rst:3481 ../../builtins/stdtypes.rst:4783 msgid "The conversion types are:" msgstr "" -#: ../../builtins/stdtypes.rst:3201 ../../builtins/stdtypes.rst:4475 +#: ../../builtins/stdtypes.rst:3484 ../../builtins/stdtypes.rst:4786 msgid "Conversion" msgstr "" -#: ../../builtins/stdtypes.rst:3203 ../../builtins/stdtypes.rst:4477 +#: ../../builtins/stdtypes.rst:3486 ../../builtins/stdtypes.rst:4788 msgid "``'d'``" msgstr "``'d'``" -#: ../../builtins/stdtypes.rst:3203 ../../builtins/stdtypes.rst:3205 -#: ../../builtins/stdtypes.rst:4477 ../../builtins/stdtypes.rst:4479 +#: ../../builtins/stdtypes.rst:3486 ../../builtins/stdtypes.rst:3488 +#: ../../builtins/stdtypes.rst:4788 ../../builtins/stdtypes.rst:4790 msgid "Signed integer decimal." msgstr "" -#: ../../builtins/stdtypes.rst:3205 ../../builtins/stdtypes.rst:4479 +#: ../../builtins/stdtypes.rst:3488 ../../builtins/stdtypes.rst:4790 msgid "``'i'``" msgstr "``'i'``" -#: ../../builtins/stdtypes.rst:3207 ../../builtins/stdtypes.rst:4481 +#: ../../builtins/stdtypes.rst:3490 ../../builtins/stdtypes.rst:4792 msgid "``'o'``" msgstr "``'o'``" -#: ../../builtins/stdtypes.rst:3207 ../../builtins/stdtypes.rst:4481 +#: ../../builtins/stdtypes.rst:3490 ../../builtins/stdtypes.rst:4792 msgid "Signed octal value." msgstr "" -#: ../../builtins/stdtypes.rst:3209 ../../builtins/stdtypes.rst:4483 +#: ../../builtins/stdtypes.rst:3492 ../../builtins/stdtypes.rst:4794 msgid "``'u'``" msgstr "``'u'``" -#: ../../builtins/stdtypes.rst:3209 ../../builtins/stdtypes.rst:4483 +#: ../../builtins/stdtypes.rst:3492 ../../builtins/stdtypes.rst:4794 msgid "Obsolete type -- it is identical to ``'d'``." msgstr "" -#: ../../builtins/stdtypes.rst:3211 ../../builtins/stdtypes.rst:4485 +#: ../../builtins/stdtypes.rst:3494 ../../builtins/stdtypes.rst:4796 msgid "``'x'``" msgstr "``'x'``" -#: ../../builtins/stdtypes.rst:3211 ../../builtins/stdtypes.rst:4485 +#: ../../builtins/stdtypes.rst:3494 ../../builtins/stdtypes.rst:4796 msgid "Signed hexadecimal (lowercase)." msgstr "" -#: ../../builtins/stdtypes.rst:3213 ../../builtins/stdtypes.rst:4487 +#: ../../builtins/stdtypes.rst:3496 ../../builtins/stdtypes.rst:4798 msgid "``'X'``" msgstr "``'X'``" -#: ../../builtins/stdtypes.rst:3213 ../../builtins/stdtypes.rst:4487 +#: ../../builtins/stdtypes.rst:3496 ../../builtins/stdtypes.rst:4798 msgid "Signed hexadecimal (uppercase)." msgstr "" -#: ../../builtins/stdtypes.rst:3215 ../../builtins/stdtypes.rst:4489 +#: ../../builtins/stdtypes.rst:3498 ../../builtins/stdtypes.rst:4800 msgid "``'e'``" msgstr "``'e'``" -#: ../../builtins/stdtypes.rst:3215 ../../builtins/stdtypes.rst:4489 +#: ../../builtins/stdtypes.rst:3498 ../../builtins/stdtypes.rst:4800 msgid "Floating-point exponential format (lowercase)." msgstr "" -#: ../../builtins/stdtypes.rst:3217 ../../builtins/stdtypes.rst:4491 +#: ../../builtins/stdtypes.rst:3500 ../../builtins/stdtypes.rst:4802 msgid "``'E'``" msgstr "``'E'``" -#: ../../builtins/stdtypes.rst:3217 ../../builtins/stdtypes.rst:4491 +#: ../../builtins/stdtypes.rst:3500 ../../builtins/stdtypes.rst:4802 msgid "Floating-point exponential format (uppercase)." msgstr "" -#: ../../builtins/stdtypes.rst:3219 ../../builtins/stdtypes.rst:4493 +#: ../../builtins/stdtypes.rst:3502 ../../builtins/stdtypes.rst:4804 msgid "``'f'``" msgstr "``'f'``" -#: ../../builtins/stdtypes.rst:3219 ../../builtins/stdtypes.rst:3221 -#: ../../builtins/stdtypes.rst:4493 ../../builtins/stdtypes.rst:4495 +#: ../../builtins/stdtypes.rst:3502 ../../builtins/stdtypes.rst:3504 +#: ../../builtins/stdtypes.rst:4804 ../../builtins/stdtypes.rst:4806 msgid "Floating-point decimal format." msgstr "" -#: ../../builtins/stdtypes.rst:3221 ../../builtins/stdtypes.rst:4495 +#: ../../builtins/stdtypes.rst:3504 ../../builtins/stdtypes.rst:4806 msgid "``'F'``" msgstr "``'F'``" -#: ../../builtins/stdtypes.rst:3223 ../../builtins/stdtypes.rst:4497 +#: ../../builtins/stdtypes.rst:3506 ../../builtins/stdtypes.rst:4808 msgid "``'g'``" msgstr "``'g'``" -#: ../../builtins/stdtypes.rst:3223 ../../builtins/stdtypes.rst:4497 +#: ../../builtins/stdtypes.rst:3506 ../../builtins/stdtypes.rst:4808 msgid "" "Floating-point format. Uses lowercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../builtins/stdtypes.rst:3227 ../../builtins/stdtypes.rst:4501 +#: ../../builtins/stdtypes.rst:3510 ../../builtins/stdtypes.rst:4812 msgid "``'G'``" msgstr "``'G'``" -#: ../../builtins/stdtypes.rst:3227 ../../builtins/stdtypes.rst:4501 +#: ../../builtins/stdtypes.rst:3510 ../../builtins/stdtypes.rst:4812 msgid "" "Floating-point format. Uses uppercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../builtins/stdtypes.rst:3231 ../../builtins/stdtypes.rst:4505 +#: ../../builtins/stdtypes.rst:3514 ../../builtins/stdtypes.rst:4816 msgid "``'c'``" msgstr "``'c'``" -#: ../../builtins/stdtypes.rst:3231 +#: ../../builtins/stdtypes.rst:3514 msgid "Single character (accepts integer or single character string)." msgstr "" -#: ../../builtins/stdtypes.rst:3234 ../../builtins/stdtypes.rst:4518 +#: ../../builtins/stdtypes.rst:3517 ../../builtins/stdtypes.rst:4829 msgid "``'r'``" msgstr "``'r'``" -#: ../../builtins/stdtypes.rst:3234 +#: ../../builtins/stdtypes.rst:3517 msgid "String (converts any Python object using :func:`repr`)." msgstr "" -#: ../../builtins/stdtypes.rst:3237 ../../builtins/stdtypes.rst:4512 +#: ../../builtins/stdtypes.rst:3520 ../../builtins/stdtypes.rst:4823 msgid "``'s'``" msgstr "``'s'``" -#: ../../builtins/stdtypes.rst:3237 +#: ../../builtins/stdtypes.rst:3520 msgid "String (converts any Python object using :func:`str`)." msgstr "" -#: ../../builtins/stdtypes.rst:3240 ../../builtins/stdtypes.rst:4515 +#: ../../builtins/stdtypes.rst:3523 ../../builtins/stdtypes.rst:4826 msgid "``'a'``" msgstr "``'a'``" -#: ../../builtins/stdtypes.rst:3240 +#: ../../builtins/stdtypes.rst:3523 msgid "String (converts any Python object using :func:`ascii`)." msgstr "" -#: ../../builtins/stdtypes.rst:3243 ../../builtins/stdtypes.rst:4521 +#: ../../builtins/stdtypes.rst:3526 ../../builtins/stdtypes.rst:4832 msgid "``'%'``" msgstr "``'%'``" -#: ../../builtins/stdtypes.rst:3243 ../../builtins/stdtypes.rst:4521 +#: ../../builtins/stdtypes.rst:3526 ../../builtins/stdtypes.rst:4832 msgid "No argument is converted, results in a ``'%'`` character in the result." msgstr "" -#: ../../builtins/stdtypes.rst:3247 +#: ../../builtins/stdtypes.rst:3530 msgid "" "For floating-point formats, the result should be correctly rounded to a " "given precision ``p`` of digits after the decimal point. The rounding mode " "matches that of the :func:`round` builtin." msgstr "" -#: ../../builtins/stdtypes.rst:3254 ../../builtins/stdtypes.rst:4528 +#: ../../builtins/stdtypes.rst:3537 ../../builtins/stdtypes.rst:4839 msgid "" "The alternate form causes a leading octal specifier (``'0o'``) to be " "inserted before the first digit." msgstr "" -#: ../../builtins/stdtypes.rst:3258 ../../builtins/stdtypes.rst:4532 +#: ../../builtins/stdtypes.rst:3541 ../../builtins/stdtypes.rst:4843 msgid "" "The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on " "whether the ``'x'`` or ``'X'`` format was used) to be inserted before the " "first digit." msgstr "" -#: ../../builtins/stdtypes.rst:3262 ../../builtins/stdtypes.rst:4536 +#: ../../builtins/stdtypes.rst:3545 ../../builtins/stdtypes.rst:4847 msgid "" "The alternate form causes the result to always contain a decimal point, even " "if no digits follow it." msgstr "" -#: ../../builtins/stdtypes.rst:3265 ../../builtins/stdtypes.rst:4539 +#: ../../builtins/stdtypes.rst:3548 ../../builtins/stdtypes.rst:4850 msgid "" "The precision determines the number of digits after the decimal point and " "defaults to 6." msgstr "" -#: ../../builtins/stdtypes.rst:3269 ../../builtins/stdtypes.rst:4543 +#: ../../builtins/stdtypes.rst:3552 ../../builtins/stdtypes.rst:4854 msgid "" "The alternate form causes the result to always contain a decimal point, and " "trailing zeroes are not removed as they would otherwise be." msgstr "" -#: ../../builtins/stdtypes.rst:3272 ../../builtins/stdtypes.rst:4546 +#: ../../builtins/stdtypes.rst:3555 ../../builtins/stdtypes.rst:4857 msgid "" "The precision determines the number of significant digits before and after " "the decimal point and defaults to 6." msgstr "" -#: ../../builtins/stdtypes.rst:3276 ../../builtins/stdtypes.rst:4550 +#: ../../builtins/stdtypes.rst:3559 ../../builtins/stdtypes.rst:4861 msgid "If precision is ``N``, the output is truncated to ``N`` characters." msgstr "" -#: ../../builtins/stdtypes.rst:3279 ../../builtins/stdtypes.rst:4559 +#: ../../builtins/stdtypes.rst:3562 ../../builtins/stdtypes.rst:4870 msgid "See :pep:`237`." msgstr "參閱 :pep:`237`。" -#: ../../builtins/stdtypes.rst:3281 +#: ../../builtins/stdtypes.rst:3564 msgid "" "Since Python strings have an explicit length, ``%s`` conversions do not " "assume that ``'\\0'`` is the end of the string." msgstr "" -#: ../../builtins/stdtypes.rst:3286 +#: ../../builtins/stdtypes.rst:3569 msgid "" "``%f`` conversions for numbers whose absolute value is over 1e50 are no " "longer replaced by ``%g`` conversions." msgstr "" -#: ../../builtins/stdtypes.rst:3297 +#: ../../builtins/stdtypes.rst:3580 msgid "" "Binary Sequence Types " "--- :class:`bytes`, :class:`bytearray`, :class:`memoryview`" msgstr "" -#: ../../builtins/stdtypes.rst:3305 +#: ../../builtins/stdtypes.rst:3588 msgid "" "The core built-in types for manipulating binary data are :class:`bytes` " "and :class:`bytearray`. They are supported by :class:`memoryview` which uses " @@ -5328,17 +5701,17 @@ msgid "" "binary objects without needing to make a copy." msgstr "" -#: ../../builtins/stdtypes.rst:3310 +#: ../../builtins/stdtypes.rst:3593 msgid "" "The :mod:`array` module supports efficient storage of basic data types like " "32-bit integers and IEEE754 double-precision floating values." msgstr "" -#: ../../builtins/stdtypes.rst:3316 +#: ../../builtins/stdtypes.rst:3599 msgid "Bytes Objects" msgstr "" -#: ../../builtins/stdtypes.rst:3320 +#: ../../builtins/stdtypes.rst:3603 msgid "" "Bytes objects are immutable sequences of single bytes. Since many major " "binary protocols are based on the ASCII text encoding, bytes objects offer " @@ -5346,40 +5719,40 @@ msgid "" "and are closely related to string objects in a variety of other ways." msgstr "" -#: ../../builtins/stdtypes.rst:3328 +#: ../../builtins/stdtypes.rst:3611 msgid "" "Firstly, the syntax for bytes literals is largely the same as that for " "string literals, except that a ``b`` prefix is added:" msgstr "" -#: ../../builtins/stdtypes.rst:3331 +#: ../../builtins/stdtypes.rst:3614 msgid "Single quotes: ``b'still allows embedded \"double\" quotes'``" msgstr "" -#: ../../builtins/stdtypes.rst:3332 +#: ../../builtins/stdtypes.rst:3615 msgid "Double quotes: ``b\"still allows embedded 'single' quotes\"``" msgstr "" -#: ../../builtins/stdtypes.rst:3333 +#: ../../builtins/stdtypes.rst:3616 msgid "" "Triple quoted: ``b'''3 single quotes'''``, ``b\"\"\"3 double quotes\"\"\"``" msgstr "" -#: ../../builtins/stdtypes.rst:3335 +#: ../../builtins/stdtypes.rst:3618 msgid "" "Only ASCII characters are permitted in bytes literals (regardless of the " "declared source code encoding). Any binary values over 127 must be entered " "into bytes literals using the appropriate escape sequence." msgstr "" -#: ../../builtins/stdtypes.rst:3339 +#: ../../builtins/stdtypes.rst:3622 msgid "" "As with string literals, bytes literals may also use a ``r`` prefix to " "disable processing of escape sequences. See :ref:`strings` for more about " "the various forms of bytes literal, including supported escape sequences." msgstr "" -#: ../../builtins/stdtypes.rst:3343 +#: ../../builtins/stdtypes.rst:3626 msgid "" "While bytes literals and representations are based on ASCII text, bytes " "objects actually behave like immutable sequences of integers, with each " @@ -5392,29 +5765,29 @@ msgid "" "compatible will usually lead to data corruption)." msgstr "" -#: ../../builtins/stdtypes.rst:3353 +#: ../../builtins/stdtypes.rst:3636 msgid "" "In addition to the literal forms, bytes objects can be created in a number " "of other ways:" msgstr "" -#: ../../builtins/stdtypes.rst:3356 +#: ../../builtins/stdtypes.rst:3639 msgid "A zero-filled bytes object of a specified length: ``bytes(10)``" msgstr "" -#: ../../builtins/stdtypes.rst:3357 +#: ../../builtins/stdtypes.rst:3640 msgid "From an iterable of integers: ``bytes(range(20))``" msgstr "" -#: ../../builtins/stdtypes.rst:3358 +#: ../../builtins/stdtypes.rst:3641 msgid "Copying existing binary data via the buffer protocol: ``bytes(obj)``" msgstr "" -#: ../../builtins/stdtypes.rst:3360 +#: ../../builtins/stdtypes.rst:3643 msgid "Also see the :ref:`bytes ` built-in." msgstr "另見內建的 :ref:`bytes `。" -#: ../../builtins/stdtypes.rst:3362 +#: ../../builtins/stdtypes.rst:3645 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " @@ -5422,38 +5795,38 @@ msgid "" "that format:" msgstr "" -#: ../../builtins/stdtypes.rst:3368 +#: ../../builtins/stdtypes.rst:3651 msgid "" "This :class:`bytes` class method returns a bytes object, decoding the given " "string object. The string must contain two hexadecimal digits per byte, " "with ASCII whitespace being ignored." msgstr "" -#: ../../builtins/stdtypes.rst:3375 +#: ../../builtins/stdtypes.rst:3658 msgid "" ":meth:`bytes.fromhex` now skips all ASCII whitespace in the string, not just " "spaces." msgstr "" -#: ../../builtins/stdtypes.rst:3379 +#: ../../builtins/stdtypes.rst:3662 msgid "" ":meth:`bytes.fromhex` now accepts ASCII :class:`bytes` and :term:`bytes-like " "objects ` as input." msgstr "" -#: ../../builtins/stdtypes.rst:3383 +#: ../../builtins/stdtypes.rst:3666 msgid "" "A reverse conversion function exists to transform a bytes object into its " "hexadecimal representation." msgstr "" -#: ../../builtins/stdtypes.rst:3389 ../../builtins/stdtypes.rst:3480 +#: ../../builtins/stdtypes.rst:3672 ../../builtins/stdtypes.rst:3763 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the instance." msgstr "" -#: ../../builtins/stdtypes.rst:3395 +#: ../../builtins/stdtypes.rst:3678 msgid "" "If you want to make the hex string easier to read, you can specify a single " "character separator *sep* parameter to include in the output. By default, " @@ -5462,13 +5835,13 @@ msgid "" "the separator position from the right, negative values from the left." msgstr "" -#: ../../builtins/stdtypes.rst:3412 +#: ../../builtins/stdtypes.rst:3695 msgid "" ":meth:`bytes.hex` now supports optional *sep* and *bytes_per_sep* parameters " "to insert separators between bytes in the hex output." msgstr "" -#: ../../builtins/stdtypes.rst:3416 +#: ../../builtins/stdtypes.rst:3699 msgid "" "Since bytes objects are sequences of integers (akin to a tuple), for a bytes " "object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be a bytes " @@ -5476,58 +5849,58 @@ msgid "" "and slicing will produce a string of length 1)" msgstr "" -#: ../../builtins/stdtypes.rst:3421 +#: ../../builtins/stdtypes.rst:3704 msgid "" "The representation of bytes objects uses the literal format (``b'...'``) " "since it is often more useful than e.g. ``bytes([46, 46, 46])``. You can " "always convert a bytes object into a list of integers using ``list(b)``." msgstr "" -#: ../../builtins/stdtypes.rst:3429 +#: ../../builtins/stdtypes.rst:3712 msgid "Bytearray Objects" msgstr "Bytearray 物件" -#: ../../builtins/stdtypes.rst:3433 +#: ../../builtins/stdtypes.rst:3716 msgid "" ":class:`bytearray` objects are a mutable counterpart to :class:`bytes` " "objects." msgstr "" -#: ../../builtins/stdtypes.rst:3439 +#: ../../builtins/stdtypes.rst:3722 msgid "" "There is no dedicated literal syntax for bytearray objects, instead they are " "always created by calling the constructor:" msgstr "" -#: ../../builtins/stdtypes.rst:3442 +#: ../../builtins/stdtypes.rst:3725 msgid "Creating an empty instance: ``bytearray()``" msgstr "建立一個空的實例:``bytearray()``" -#: ../../builtins/stdtypes.rst:3443 +#: ../../builtins/stdtypes.rst:3726 msgid "Creating a zero-filled instance with a given length: ``bytearray(10)``" msgstr "" -#: ../../builtins/stdtypes.rst:3444 +#: ../../builtins/stdtypes.rst:3727 msgid "From an iterable of integers: ``bytearray(range(20))``" msgstr "" -#: ../../builtins/stdtypes.rst:3445 +#: ../../builtins/stdtypes.rst:3728 msgid "" "Copying existing binary data via the buffer protocol: ``bytearray(b'Hi!')``" msgstr "" -#: ../../builtins/stdtypes.rst:3447 +#: ../../builtins/stdtypes.rst:3730 msgid "" "As bytearray objects are mutable, they support the :ref:`mutable ` sequence operations in addition to the common bytes and bytearray " "operations described in :ref:`bytes-methods`." msgstr "" -#: ../../builtins/stdtypes.rst:3451 +#: ../../builtins/stdtypes.rst:3734 msgid "Also see the :ref:`bytearray ` built-in." msgstr "另見內建的 :ref:`bytearray `。" -#: ../../builtins/stdtypes.rst:3453 +#: ../../builtins/stdtypes.rst:3736 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " @@ -5535,64 +5908,96 @@ msgid "" "in that format:" msgstr "" -#: ../../builtins/stdtypes.rst:3459 +#: ../../builtins/stdtypes.rst:3742 msgid "" "This :class:`bytearray` class method returns a bytearray object, decoding " "the given string object. The string must contain two hexadecimal digits per " "byte, with ASCII whitespace being ignored." msgstr "" -#: ../../builtins/stdtypes.rst:3466 +#: ../../builtins/stdtypes.rst:3749 msgid "" ":meth:`bytearray.fromhex` now skips all ASCII whitespace in the string, not " "just spaces." msgstr "" -#: ../../builtins/stdtypes.rst:3470 +#: ../../builtins/stdtypes.rst:3753 msgid "" ":meth:`bytearray.fromhex` now accepts ASCII :class:`bytes` and :term:`bytes-" "like objects ` as input." msgstr "" -#: ../../builtins/stdtypes.rst:3474 +#: ../../builtins/stdtypes.rst:3757 msgid "" "A reverse conversion function exists to transform a bytearray object into " "its hexadecimal representation." msgstr "" -#: ../../builtins/stdtypes.rst:3488 +#: ../../builtins/stdtypes.rst:3771 msgid "" "Similar to :meth:`bytes.hex`, :meth:`bytearray.hex` now supports optional " "*sep* and *bytes_per_sep* parameters to insert separators between bytes in " "the hex output." msgstr "" -#: ../../builtins/stdtypes.rst:3495 +#: ../../builtins/stdtypes.rst:3778 msgid "" "Resize the :class:`bytearray` to contain *size* bytes. *size* must be " "greater than or equal to 0." msgstr "" -#: ../../builtins/stdtypes.rst:3498 +#: ../../builtins/stdtypes.rst:3781 msgid "" "If the :class:`bytearray` needs to shrink, bytes beyond *size* are truncated." msgstr "" -#: ../../builtins/stdtypes.rst:3500 +#: ../../builtins/stdtypes.rst:3783 msgid "" "If the :class:`bytearray` needs to grow, all new bytes, those beyond *size*, " "will be set to null bytes." msgstr "" -#: ../../builtins/stdtypes.rst:3504 +#: ../../builtins/stdtypes.rst:3787 msgid "This is equivalent to:" msgstr "等同於:" -#: ../../builtins/stdtypes.rst:3512 +#: ../../builtins/stdtypes.rst:3795 msgid "Examples:" msgstr "範例:" -#: ../../builtins/stdtypes.rst:3525 +#: ../../builtins/stdtypes.rst:3810 +msgid "" +"Remove the first *n* bytes from the bytearray and return them as an " +"immutable :class:`bytes`. By default (if *n* is ``None``), return all bytes " +"and clear the bytearray." +msgstr "" + +#: ../../builtins/stdtypes.rst:3814 +msgid "" +"If *n* is negative, index from the end and take the first :func:`len` plus " +"*n* bytes. If *n* is out of bounds, raise :exc:`IndexError`." +msgstr "" + +#: ../../builtins/stdtypes.rst:3817 +msgid "" +"Taking less than the full length will leave remaining bytes in the :class:" +"`bytearray`, which requires a copy. If the remaining bytes should be " +"discarded, use :func:`~bytearray.resize` or :keyword:`del` to truncate then :" +"func:`~bytearray.take_bytes` without a size." +msgstr "" + +#: ../../builtins/stdtypes.rst:3824 +msgid "Taking all bytes is a zero-copy operation." +msgstr "" + +#: ../../builtins/stdtypes.rst:3828 +msgid "" +"See the :ref:`What's New ` entry for " +"common code patterns which can be optimized with :meth:`bytearray." +"take_bytes`." +msgstr "" + +#: ../../builtins/stdtypes.rst:3832 msgid "" "Since bytearray objects are sequences of integers (akin to a list), for a " "bytearray object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be " @@ -5600,7 +6005,7 @@ msgid "" "both indexing and slicing will produce a string of length 1)" msgstr "" -#: ../../builtins/stdtypes.rst:3530 +#: ../../builtins/stdtypes.rst:3837 msgid "" "The representation of bytearray objects uses the bytes literal format " "(``bytearray(b'...')``) since it is often more useful than e.g. " @@ -5608,17 +6013,17 @@ msgid "" "a list of integers using ``list(b)``." msgstr "" -#: ../../builtins/stdtypes.rst:3537 +#: ../../builtins/stdtypes.rst:3844 msgid "" "For detailed information on thread-safety guarantees for :class:`bytearray` " "objects, see :ref:`thread-safety-bytearray`." msgstr "" -#: ../../builtins/stdtypes.rst:3544 +#: ../../builtins/stdtypes.rst:3851 msgid "Bytes and Bytearray Operations" msgstr "Bytes 和 Bytearray 的操作" -#: ../../builtins/stdtypes.rst:3549 +#: ../../builtins/stdtypes.rst:3856 msgid "" "Both bytes and bytearray objects support the :ref:`common ` " "sequence operations. They interoperate not just with operands of the same " @@ -5627,14 +6032,14 @@ msgid "" "return type of the result may depend on the order of operands." msgstr "" -#: ../../builtins/stdtypes.rst:3557 +#: ../../builtins/stdtypes.rst:3864 msgid "" "The methods on bytes and bytearray objects don't accept strings as their " "arguments, just as the methods on strings don't accept bytes as their " "arguments. For example, you have to write::" msgstr "" -#: ../../builtins/stdtypes.rst:3561 +#: ../../builtins/stdtypes.rst:3868 msgid "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" @@ -5642,11 +6047,11 @@ msgstr "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" -#: ../../builtins/stdtypes.rst:3564 +#: ../../builtins/stdtypes.rst:3871 msgid "and::" msgstr "和: ::" -#: ../../builtins/stdtypes.rst:3566 +#: ../../builtins/stdtypes.rst:3873 msgid "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" @@ -5654,60 +6059,60 @@ msgstr "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" -#: ../../builtins/stdtypes.rst:3569 +#: ../../builtins/stdtypes.rst:3876 msgid "" "Some bytes and bytearray operations assume the use of ASCII compatible " "binary formats, and hence should be avoided when working with arbitrary " "binary data. These restrictions are covered below." msgstr "" -#: ../../builtins/stdtypes.rst:3574 +#: ../../builtins/stdtypes.rst:3881 msgid "" "Using these ASCII based operations to manipulate binary data that is not " "stored in an ASCII based format may lead to data corruption." msgstr "" -#: ../../builtins/stdtypes.rst:3577 +#: ../../builtins/stdtypes.rst:3884 msgid "" "The following methods on bytes and bytearray objects can be used with " "arbitrary binary data." msgstr "" -#: ../../builtins/stdtypes.rst:3583 +#: ../../builtins/stdtypes.rst:3890 msgid "" "Return the number of non-overlapping occurrences of subsequence *sub* in the " "range [*start*, *end*]. Optional arguments *start* and *end* are " "interpreted as in slice notation." msgstr "" -#: ../../builtins/stdtypes.rst:3587 ../../builtins/stdtypes.rst:3692 -#: ../../builtins/stdtypes.rst:3714 ../../builtins/stdtypes.rst:3780 -#: ../../builtins/stdtypes.rst:3793 +#: ../../builtins/stdtypes.rst:3894 ../../builtins/stdtypes.rst:3999 +#: ../../builtins/stdtypes.rst:4021 ../../builtins/stdtypes.rst:4091 +#: ../../builtins/stdtypes.rst:4104 msgid "" "The subsequence to search for may be any :term:`bytes-like object` or an " "integer in the range 0 to 255." msgstr "" -#: ../../builtins/stdtypes.rst:3590 +#: ../../builtins/stdtypes.rst:3897 msgid "" "If *sub* is empty, returns the number of empty slices between characters " "which is the length of the bytes object plus one." msgstr "" -#: ../../builtins/stdtypes.rst:3593 ../../builtins/stdtypes.rst:3704 -#: ../../builtins/stdtypes.rst:3717 ../../builtins/stdtypes.rst:3783 -#: ../../builtins/stdtypes.rst:3796 +#: ../../builtins/stdtypes.rst:3900 ../../builtins/stdtypes.rst:4011 +#: ../../builtins/stdtypes.rst:4024 ../../builtins/stdtypes.rst:4094 +#: ../../builtins/stdtypes.rst:4107 msgid "Also accept an integer in the range 0 to 255 as the subsequence." msgstr "" -#: ../../builtins/stdtypes.rst:3600 +#: ../../builtins/stdtypes.rst:3907 msgid "" "If the binary data starts with the *prefix* string, return " "``bytes[len(prefix):]``. Otherwise, return a copy of the original binary " "data::" msgstr "" -#: ../../builtins/stdtypes.rst:3604 +#: ../../builtins/stdtypes.rst:3911 msgid "" ">>> b'TestHook'.removeprefix(b'Test')\n" "b'Hook'\n" @@ -5719,32 +6124,32 @@ msgstr "" ">>> b'BaseTestCase'.removeprefix(b'Test')\n" "b'BaseTestCase'" -#: ../../builtins/stdtypes.rst:3609 +#: ../../builtins/stdtypes.rst:3916 msgid "The *prefix* may be any :term:`bytes-like object`." msgstr "*prefix* 可以是任何的 :term:`bytes-like object`。" -#: ../../builtins/stdtypes.rst:3613 ../../builtins/stdtypes.rst:3635 -#: ../../builtins/stdtypes.rst:3768 ../../builtins/stdtypes.rst:3861 -#: ../../builtins/stdtypes.rst:3875 ../../builtins/stdtypes.rst:3906 -#: ../../builtins/stdtypes.rst:3920 ../../builtins/stdtypes.rst:3963 -#: ../../builtins/stdtypes.rst:4035 ../../builtins/stdtypes.rst:4053 -#: ../../builtins/stdtypes.rst:4081 ../../builtins/stdtypes.rst:4220 -#: ../../builtins/stdtypes.rst:4275 ../../builtins/stdtypes.rst:4318 -#: ../../builtins/stdtypes.rst:4339 ../../builtins/stdtypes.rst:4361 -#: ../../builtins/stdtypes.rst:4563 +#: ../../builtins/stdtypes.rst:3920 ../../builtins/stdtypes.rst:3942 +#: ../../builtins/stdtypes.rst:4076 ../../builtins/stdtypes.rst:4172 +#: ../../builtins/stdtypes.rst:4186 ../../builtins/stdtypes.rst:4217 +#: ../../builtins/stdtypes.rst:4231 ../../builtins/stdtypes.rst:4274 +#: ../../builtins/stdtypes.rst:4346 ../../builtins/stdtypes.rst:4364 +#: ../../builtins/stdtypes.rst:4392 ../../builtins/stdtypes.rst:4531 +#: ../../builtins/stdtypes.rst:4586 ../../builtins/stdtypes.rst:4629 +#: ../../builtins/stdtypes.rst:4650 ../../builtins/stdtypes.rst:4672 +#: ../../builtins/stdtypes.rst:4874 msgid "" "The bytearray version of this method does *not* operate in place - it always " "produces a new object, even if no changes were made." msgstr "" -#: ../../builtins/stdtypes.rst:3622 +#: ../../builtins/stdtypes.rst:3929 msgid "" "If the binary data ends with the *suffix* string and that *suffix* is not " "empty, return ``bytes[:-len(suffix)]``. Otherwise, return a copy of the " "original binary data::" msgstr "" -#: ../../builtins/stdtypes.rst:3626 +#: ../../builtins/stdtypes.rst:3933 msgid "" ">>> b'MiscTests'.removesuffix(b'Tests')\n" "b'Misc'\n" @@ -5756,15 +6161,15 @@ msgstr "" ">>> b'TmpDirMixin'.removesuffix(b'Tests')\n" "b'TmpDirMixin'" -#: ../../builtins/stdtypes.rst:3631 +#: ../../builtins/stdtypes.rst:3938 msgid "The *suffix* may be any :term:`bytes-like object`." msgstr "" -#: ../../builtins/stdtypes.rst:3644 +#: ../../builtins/stdtypes.rst:3951 msgid "Return the bytes decoded to a :class:`str`." msgstr "" -#: ../../builtins/stdtypes.rst:3649 +#: ../../builtins/stdtypes.rst:3956 msgid "" "*errors* controls how decoding errors are handled. If ``'strict'`` (the " "default), a :exc:`UnicodeError` exception is raised. Other possible values " @@ -5772,21 +6177,21 @@ msgid "" "via :func:`codecs.register_error`. See :ref:`error-handlers` for details." msgstr "" -#: ../../builtins/stdtypes.rst:3655 +#: ../../builtins/stdtypes.rst:3962 msgid "" "For performance reasons, the value of *errors* is not checked for validity " "unless a decoding error actually occurs, :ref:`devmode` is enabled or " "a :ref:`debug build ` is used." msgstr "" -#: ../../builtins/stdtypes.rst:3661 +#: ../../builtins/stdtypes.rst:3968 msgid "" "Passing the *encoding* argument to :class:`str` allows decoding " "any :term:`bytes-like object` directly, without needing to make a " "temporary :class:`!bytes` or :class:`!bytearray` object." msgstr "" -#: ../../builtins/stdtypes.rst:3676 +#: ../../builtins/stdtypes.rst:3983 msgid "" "Return ``True`` if the binary data ends with the specified *suffix*, " "otherwise return ``False``. *suffix* can also be a tuple of suffixes to " @@ -5794,11 +6199,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../builtins/stdtypes.rst:3681 +#: ../../builtins/stdtypes.rst:3988 msgid "The suffix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../builtins/stdtypes.rst:3687 +#: ../../builtins/stdtypes.rst:3994 msgid "" "Return the lowest index in the data where the subsequence *sub* is found, " "such that *sub* is contained in the slice ``s[start:end]``. Optional " @@ -5806,14 +6211,14 @@ msgid "" "``-1`` if *sub* is not found." msgstr "" -#: ../../builtins/stdtypes.rst:3697 +#: ../../builtins/stdtypes.rst:4004 msgid "" "The :meth:`~bytes.find` method should be used only if you need to know the " "position of *sub*. To check if *sub* is a substring or not, use " "the :keyword:`in` operator::" msgstr "" -#: ../../builtins/stdtypes.rst:3701 +#: ../../builtins/stdtypes.rst:4008 msgid "" ">>> b'Py' in b'Python'\n" "True" @@ -5821,13 +6226,13 @@ msgstr "" ">>> b'Py' in b'Python'\n" "True" -#: ../../builtins/stdtypes.rst:3711 +#: ../../builtins/stdtypes.rst:4018 msgid "" "Like :meth:`~bytes.find`, but raise :exc:`ValueError` when the subsequence " "is not found." msgstr "" -#: ../../builtins/stdtypes.rst:3724 +#: ../../builtins/stdtypes.rst:4031 msgid "" "Return a bytes or bytearray object which is the concatenation of the binary " "data sequences in *iterable*. A :exc:`TypeError` will be raised if there " @@ -5837,7 +6242,7 @@ msgid "" "method." msgstr "" -#: ../../builtins/stdtypes.rst:3735 +#: ../../builtins/stdtypes.rst:4042 msgid "" "This static method returns a translation table usable " "for :meth:`bytes.translate` that will map each character in *from* into the " @@ -5845,7 +6250,7 @@ msgid "" "be :term:`bytes-like objects ` and have the same length." msgstr "" -#: ../../builtins/stdtypes.rst:3746 +#: ../../builtins/stdtypes.rst:4053 msgid "" "Split the sequence at the first occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -5854,24 +6259,25 @@ msgid "" "by two empty bytes or bytearray objects." msgstr "" -#: ../../builtins/stdtypes.rst:3753 ../../builtins/stdtypes.rst:3810 +#: ../../builtins/stdtypes.rst:4060 ../../builtins/stdtypes.rst:4121 msgid "The separator to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../builtins/stdtypes.rst:3759 +#: ../../builtins/stdtypes.rst:4066 msgid "" "Return a copy of the sequence with all occurrences of subsequence *old* " -"replaced by *new*. If the optional argument *count* is given, only the " -"first *count* occurrences are replaced." +"replaced by *new*. If *count* is given, only the first *count* occurrences " +"are replaced. If *count* is not specified or ``-1``, then all occurrences " +"are replaced." msgstr "" -#: ../../builtins/stdtypes.rst:3763 +#: ../../builtins/stdtypes.rst:4071 msgid "" "The subsequence to search for and its replacement may be any :term:`bytes-" "like object`." msgstr "" -#: ../../builtins/stdtypes.rst:3775 +#: ../../builtins/stdtypes.rst:4086 msgid "" "Return the highest index in the sequence where the subsequence *sub* is " "found, such that *sub* is contained within ``s[start:end]``. Optional " @@ -5879,13 +6285,13 @@ msgid "" "``-1`` on failure." msgstr "" -#: ../../builtins/stdtypes.rst:3790 +#: ../../builtins/stdtypes.rst:4101 msgid "" "Like :meth:`~bytes.rfind` but raises :exc:`ValueError` when the subsequence " "*sub* is not found." msgstr "" -#: ../../builtins/stdtypes.rst:3803 +#: ../../builtins/stdtypes.rst:4114 msgid "" "Split the sequence at the last occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -5894,7 +6300,7 @@ msgid "" "followed by a copy of the original sequence." msgstr "" -#: ../../builtins/stdtypes.rst:3816 +#: ../../builtins/stdtypes.rst:4127 msgid "" "Return ``True`` if the binary data starts with the specified *prefix*, " "otherwise return ``False``. *prefix* can also be a tuple of prefixes to " @@ -5902,11 +6308,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../builtins/stdtypes.rst:3821 +#: ../../builtins/stdtypes.rst:4132 msgid "The prefix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../builtins/stdtypes.rst:3827 +#: ../../builtins/stdtypes.rst:4138 msgid "" "Return a copy of the bytes or bytearray object where all bytes occurring in " "the optional argument *delete* are removed, and the remaining bytes have " @@ -5914,18 +6320,18 @@ msgid "" "object of length 256." msgstr "" -#: ../../builtins/stdtypes.rst:3832 +#: ../../builtins/stdtypes.rst:4143 msgid "" "You can use the :func:`bytes.maketrans` method to create a translation table." msgstr "" -#: ../../builtins/stdtypes.rst:3835 +#: ../../builtins/stdtypes.rst:4146 msgid "" "Set the *table* argument to ``None`` for translations that only delete " "characters::" msgstr "" -#: ../../builtins/stdtypes.rst:3838 +#: ../../builtins/stdtypes.rst:4149 msgid "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" @@ -5933,11 +6339,11 @@ msgstr "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" -#: ../../builtins/stdtypes.rst:3841 +#: ../../builtins/stdtypes.rst:4152 msgid "*delete* is now supported as a keyword argument." msgstr "支援 *delete* 關鍵字引數。" -#: ../../builtins/stdtypes.rst:3845 +#: ../../builtins/stdtypes.rst:4156 msgid "" "The following methods on bytes and bytearray objects have default behaviours " "that assume the use of ASCII compatible binary formats, but can still be " @@ -5946,7 +6352,7 @@ msgid "" "instead produce new objects." msgstr "" -#: ../../builtins/stdtypes.rst:3854 +#: ../../builtins/stdtypes.rst:4165 msgid "" "Return a copy of the object centered in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -5954,7 +6360,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../builtins/stdtypes.rst:3868 +#: ../../builtins/stdtypes.rst:4179 msgid "" "Return a copy of the object left justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -5962,7 +6368,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../builtins/stdtypes.rst:3882 +#: ../../builtins/stdtypes.rst:4193 msgid "" "Return a copy of the sequence with specified leading bytes removed. The " "*bytes* argument is a binary sequence specifying the set of byte values to " @@ -5971,7 +6377,7 @@ msgid "" "not a prefix; rather, all combinations of its values are stripped::" msgstr "" -#: ../../builtins/stdtypes.rst:3889 +#: ../../builtins/stdtypes.rst:4200 msgid "" ">>> b' spacious '.lstrip()\n" "b'spacious '\n" @@ -5983,14 +6389,14 @@ msgstr "" ">>> b'www.example.com'.lstrip(b'cmowz.')\n" "b'example.com'" -#: ../../builtins/stdtypes.rst:3894 +#: ../../builtins/stdtypes.rst:4205 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removeprefix` for a method that will remove a " "single prefix string rather than all of a set of characters. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:3899 +#: ../../builtins/stdtypes.rst:4210 msgid "" ">>> b'Arthur: three!'.lstrip(b'Arthur: ')\n" "b'ee!'\n" @@ -6002,7 +6408,7 @@ msgstr "" ">>> b'Arthur: three!'.removeprefix(b'Arthur: ')\n" "b'three!'" -#: ../../builtins/stdtypes.rst:3913 +#: ../../builtins/stdtypes.rst:4224 msgid "" "Return a copy of the object right justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -6010,7 +6416,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../builtins/stdtypes.rst:3927 +#: ../../builtins/stdtypes.rst:4238 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are " @@ -6020,7 +6426,7 @@ msgid "" "like :meth:`split` which is described in detail below." msgstr "" -#: ../../builtins/stdtypes.rst:3939 +#: ../../builtins/stdtypes.rst:4250 msgid "" "Return a copy of the sequence with specified trailing bytes removed. The " "*bytes* argument is a binary sequence specifying the set of byte values to " @@ -6029,7 +6435,7 @@ msgid "" "not a suffix; rather, all combinations of its values are stripped::" msgstr "" -#: ../../builtins/stdtypes.rst:3946 +#: ../../builtins/stdtypes.rst:4257 msgid "" ">>> b' spacious '.rstrip()\n" "b' spacious'\n" @@ -6041,14 +6447,14 @@ msgstr "" ">>> b'mississippi'.rstrip(b'ipz')\n" "b'mississ'" -#: ../../builtins/stdtypes.rst:3951 +#: ../../builtins/stdtypes.rst:4262 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removesuffix` for a method that will remove a " "single suffix string rather than all of a set of characters. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:3956 +#: ../../builtins/stdtypes.rst:4267 msgid "" ">>> b'Monty Python'.rstrip(b' Python')\n" "b'M'\n" @@ -6060,7 +6466,7 @@ msgstr "" ">>> b'Monty Python'.removesuffix(b' Python')\n" "b'Monty'" -#: ../../builtins/stdtypes.rst:3970 +#: ../../builtins/stdtypes.rst:4281 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given and non-negative, at most " @@ -6069,7 +6475,7 @@ msgid "" "limit on the number of splits (all possible splits are made)." msgstr "" -#: ../../builtins/stdtypes.rst:3976 +#: ../../builtins/stdtypes.rst:4287 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty subsequences (for example, ``b'1,,2'.split(b',')`` " @@ -6080,7 +6486,7 @@ msgid "" "like object`." msgstr "" -#: ../../builtins/stdtypes.rst:3986 +#: ../../builtins/stdtypes.rst:4297 msgid "" ">>> b'1,2,3'.split(b',')\n" "[b'1', b'2', b'3']\n" @@ -6100,7 +6506,7 @@ msgstr "" ">>> b'1<>2<>3<4'.split(b'<>')\n" "[b'1', b'2', b'3<4']" -#: ../../builtins/stdtypes.rst:3995 +#: ../../builtins/stdtypes.rst:4306 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive :meth:`ASCII whitespace ` are " @@ -6110,7 +6516,7 @@ msgid "" "ASCII whitespace without a specified separator returns ``[]``." msgstr "" -#: ../../builtins/stdtypes.rst:4006 +#: ../../builtins/stdtypes.rst:4317 msgid "" ">>> b'1 2 3'.split()\n" "[b'1', b'2', b'3']\n" @@ -6126,7 +6532,7 @@ msgstr "" ">>> b' 1 2 3 '.split()\n" "[b'1', b'2', b'3']" -#: ../../builtins/stdtypes.rst:4017 +#: ../../builtins/stdtypes.rst:4328 msgid "" "Return a copy of the sequence with specified leading and trailing bytes " "removed. The *bytes* argument is a binary sequence specifying the set of " @@ -6136,7 +6542,7 @@ msgid "" "are stripped::" msgstr "" -#: ../../builtins/stdtypes.rst:4025 +#: ../../builtins/stdtypes.rst:4336 msgid "" ">>> b' spacious '.strip()\n" "b'spacious'\n" @@ -6148,13 +6554,13 @@ msgstr "" ">>> b'www.example.com'.strip(b'cmowz.')\n" "b'example'" -#: ../../builtins/stdtypes.rst:4030 +#: ../../builtins/stdtypes.rst:4341 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`." msgstr "" -#: ../../builtins/stdtypes.rst:4039 +#: ../../builtins/stdtypes.rst:4350 msgid "" "The following methods on bytes and bytearray objects assume the use of ASCII " "compatible binary formats and should not be applied to arbitrary binary " @@ -6162,14 +6568,14 @@ msgid "" "operate in place, and instead produce new objects." msgstr "" -#: ../../builtins/stdtypes.rst:4047 +#: ../../builtins/stdtypes.rst:4358 msgid "" "Return a copy of the sequence with each byte interpreted as an ASCII " "character, and the first byte capitalized and the rest lowercased. Non-ASCII " "byte values are passed through unchanged." msgstr "" -#: ../../builtins/stdtypes.rst:4060 +#: ../../builtins/stdtypes.rst:4371 msgid "" "Return a copy of the sequence where all ASCII tab characters are replaced by " "one or more ASCII spaces, depending on the current column and the given tab " @@ -6185,7 +6591,7 @@ msgid "" "by one regardless of how the byte value is represented when printed::" msgstr "" -#: ../../builtins/stdtypes.rst:4074 +#: ../../builtins/stdtypes.rst:4385 msgid "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs()\n" "b'01 012 0123 01234'\n" @@ -6197,7 +6603,7 @@ msgstr "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs(4)\n" "b'01 012 0123 01234'" -#: ../../builtins/stdtypes.rst:4088 +#: ../../builtins/stdtypes.rst:4399 msgid "" "Return ``True`` if all bytes in the sequence are alphabetical ASCII " "characters or ASCII decimal digits and the sequence is not empty, ``False`` " @@ -6206,7 +6612,7 @@ msgid "" "digits are those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../builtins/stdtypes.rst:4096 +#: ../../builtins/stdtypes.rst:4407 msgid "" ">>> b'ABCabc1'.isalnum()\n" "True\n" @@ -6218,7 +6624,7 @@ msgstr "" ">>> b'ABC abc1'.isalnum()\n" "False" -#: ../../builtins/stdtypes.rst:4105 +#: ../../builtins/stdtypes.rst:4416 msgid "" "Return ``True`` if all bytes in the sequence are alphabetic ASCII characters " "and the sequence is not empty, ``False`` otherwise. Alphabetic ASCII " @@ -6226,7 +6632,7 @@ msgid "" "``b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../builtins/stdtypes.rst:4112 +#: ../../builtins/stdtypes.rst:4423 msgid "" ">>> b'ABCabc'.isalpha()\n" "True\n" @@ -6238,20 +6644,20 @@ msgstr "" ">>> b'ABCabc1'.isalpha()\n" "False" -#: ../../builtins/stdtypes.rst:4121 +#: ../../builtins/stdtypes.rst:4432 msgid "" "Return ``True`` if the sequence is empty or all bytes in the sequence are " "ASCII, ``False`` otherwise. ASCII bytes are in the range 0-0x7F." msgstr "" -#: ../../builtins/stdtypes.rst:4131 +#: ../../builtins/stdtypes.rst:4442 msgid "" "Return ``True`` if all bytes in the sequence are ASCII decimal digits and " "the sequence is not empty, ``False`` otherwise. ASCII decimal digits are " "those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../builtins/stdtypes.rst:4137 +#: ../../builtins/stdtypes.rst:4448 msgid "" ">>> b'1234'.isdigit()\n" "True\n" @@ -6263,13 +6669,13 @@ msgstr "" ">>> b'1.23'.isdigit()\n" "False" -#: ../../builtins/stdtypes.rst:4146 +#: ../../builtins/stdtypes.rst:4457 msgid "" "Return ``True`` if there is at least one lowercase ASCII character in the " "sequence and no uppercase ASCII characters, ``False`` otherwise." msgstr "" -#: ../../builtins/stdtypes.rst:4151 +#: ../../builtins/stdtypes.rst:4462 msgid "" ">>> b'hello world'.islower()\n" "True\n" @@ -6281,16 +6687,16 @@ msgstr "" ">>> b'Hello world'.islower()\n" "False" -#: ../../builtins/stdtypes.rst:4156 ../../builtins/stdtypes.rst:4198 -#: ../../builtins/stdtypes.rst:4214 ../../builtins/stdtypes.rst:4264 -#: ../../builtins/stdtypes.rst:4333 +#: ../../builtins/stdtypes.rst:4467 ../../builtins/stdtypes.rst:4509 +#: ../../builtins/stdtypes.rst:4525 ../../builtins/stdtypes.rst:4575 +#: ../../builtins/stdtypes.rst:4644 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " "values in the sequence ``b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../builtins/stdtypes.rst:4164 +#: ../../builtins/stdtypes.rst:4475 msgid "" "Return ``True`` if all bytes in the sequence are ASCII whitespace and the " "sequence is not empty, ``False`` otherwise. ASCII whitespace characters are " @@ -6298,14 +6704,14 @@ msgid "" "newline, carriage return, vertical tab, form feed)." msgstr "" -#: ../../builtins/stdtypes.rst:4173 +#: ../../builtins/stdtypes.rst:4484 msgid "" "Return ``True`` if the sequence is ASCII titlecase and the sequence is not " "empty, ``False`` otherwise. See :meth:`bytes.title` for more details on the " "definition of \"titlecase\"." msgstr "" -#: ../../builtins/stdtypes.rst:4179 +#: ../../builtins/stdtypes.rst:4490 msgid "" ">>> b'Hello World'.istitle()\n" "True\n" @@ -6317,14 +6723,14 @@ msgstr "" ">>> b'Hello world'.istitle()\n" "False" -#: ../../builtins/stdtypes.rst:4188 +#: ../../builtins/stdtypes.rst:4499 msgid "" "Return ``True`` if there is at least one uppercase alphabetic ASCII " "character in the sequence and no lowercase ASCII characters, ``False`` " "otherwise." msgstr "" -#: ../../builtins/stdtypes.rst:4193 +#: ../../builtins/stdtypes.rst:4504 msgid "" ">>> b'HELLO WORLD'.isupper()\n" "True\n" @@ -6336,13 +6742,13 @@ msgstr "" ">>> b'Hello world'.isupper()\n" "False" -#: ../../builtins/stdtypes.rst:4206 +#: ../../builtins/stdtypes.rst:4517 msgid "" "Return a copy of the sequence with all the uppercase ASCII characters " "converted to their corresponding lowercase counterpart." msgstr "" -#: ../../builtins/stdtypes.rst:4211 +#: ../../builtins/stdtypes.rst:4522 msgid "" ">>> b'Hello World'.lower()\n" "b'hello world'" @@ -6350,7 +6756,7 @@ msgstr "" ">>> b'Hello World'.lower()\n" "b'hello world'" -#: ../../builtins/stdtypes.rst:4231 +#: ../../builtins/stdtypes.rst:4542 msgid "" "Return a list of the lines in the binary sequence, breaking at ASCII line " "boundaries. This method uses the :term:`universal newlines` approach to " @@ -6358,7 +6764,7 @@ msgid "" "*keepends* is given and true." msgstr "" -#: ../../builtins/stdtypes.rst:4238 +#: ../../builtins/stdtypes.rst:4549 msgid "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" "[b'ab c', b'', b'de fg', b'kl']\n" @@ -6370,14 +6776,14 @@ msgstr "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "[b'ab c\\n', b'\\n', b'de fg\\r', b'kl\\r\\n']" -#: ../../builtins/stdtypes.rst:4243 +#: ../../builtins/stdtypes.rst:4554 msgid "" "Unlike :meth:`~bytes.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -#: ../../builtins/stdtypes.rst:4247 +#: ../../builtins/stdtypes.rst:4558 msgid "" ">>> b\"\".split(b'\\n'), b\"Two lines\\n\".split(b'\\n')\n" "([b''], [b'Two lines', b''])\n" @@ -6389,13 +6795,13 @@ msgstr "" ">>> b\"\".splitlines(), b\"One line\\n\".splitlines()\n" "([], [b'One line'])" -#: ../../builtins/stdtypes.rst:4256 +#: ../../builtins/stdtypes.rst:4567 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart and vice-versa." msgstr "" -#: ../../builtins/stdtypes.rst:4261 +#: ../../builtins/stdtypes.rst:4572 msgid "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" @@ -6403,7 +6809,7 @@ msgstr "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" -#: ../../builtins/stdtypes.rst:4268 +#: ../../builtins/stdtypes.rst:4579 msgid "" "Unlike :func:`str.swapcase`, it is always the case that " "``bin.swapcase().swapcase() == bin`` for the binary versions. Case " @@ -6411,14 +6817,14 @@ msgid "" "for arbitrary Unicode code points." msgstr "" -#: ../../builtins/stdtypes.rst:4282 +#: ../../builtins/stdtypes.rst:4593 msgid "" "Return a titlecased version of the binary sequence where words start with an " "uppercase ASCII character and the remaining characters are lowercase. " "Uncased byte values are left unmodified." msgstr "" -#: ../../builtins/stdtypes.rst:4288 +#: ../../builtins/stdtypes.rst:4599 msgid "" ">>> b'Hello world'.title()\n" "b'Hello World'" @@ -6426,7 +6832,7 @@ msgstr "" ">>> b'Hello world'.title()\n" "b'Hello World'" -#: ../../builtins/stdtypes.rst:4291 +#: ../../builtins/stdtypes.rst:4602 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " @@ -6434,7 +6840,7 @@ msgid "" "values are uncased." msgstr "" -#: ../../builtins/stdtypes.rst:4301 +#: ../../builtins/stdtypes.rst:4612 msgid "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" @@ -6442,12 +6848,12 @@ msgstr "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" -#: ../../builtins/stdtypes.rst:4304 +#: ../../builtins/stdtypes.rst:4615 msgid "" "A workaround for apostrophes can be constructed using regular expressions::" msgstr "" -#: ../../builtins/stdtypes.rst:4306 +#: ../../builtins/stdtypes.rst:4617 msgid "" ">>> import re\n" ">>> def titlecase(s):\n" @@ -6469,13 +6875,13 @@ msgstr "" ">>> titlecase(b\"they're bill's friends.\")\n" "b\"They're Bill's Friends.\"" -#: ../../builtins/stdtypes.rst:4325 +#: ../../builtins/stdtypes.rst:4636 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart." msgstr "" -#: ../../builtins/stdtypes.rst:4330 +#: ../../builtins/stdtypes.rst:4641 msgid "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" @@ -6483,7 +6889,7 @@ msgstr "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" -#: ../../builtins/stdtypes.rst:4346 +#: ../../builtins/stdtypes.rst:4657 msgid "" "Return a copy of the sequence left filled with ASCII ``b'0'`` digits to make " "a sequence of length *width*. A leading sign prefix (``b'+'``/ ``b'-'``) is " @@ -6492,7 +6898,7 @@ msgid "" "*width* is less than or equal to ``len(seq)``." msgstr "" -#: ../../builtins/stdtypes.rst:4354 +#: ../../builtins/stdtypes.rst:4665 msgid "" ">>> b\"42\".zfill(5)\n" "b'00042'\n" @@ -6504,11 +6910,11 @@ msgstr "" ">>> b\"-42\".zfill(5)\n" "b'-0042'" -#: ../../builtins/stdtypes.rst:4368 +#: ../../builtins/stdtypes.rst:4679 msgid "``printf``-style Bytes Formatting" msgstr "" -#: ../../builtins/stdtypes.rst:4385 +#: ../../builtins/stdtypes.rst:4696 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " @@ -6516,7 +6922,7 @@ msgid "" "dictionary, wrap it in a tuple." msgstr "" -#: ../../builtins/stdtypes.rst:4390 +#: ../../builtins/stdtypes.rst:4701 msgid "" "Bytes objects (``bytes``/``bytearray``) have one unique built-in operation: " "the ``%`` operator (modulo). This is also known as the bytes *formatting* or " @@ -6526,7 +6932,7 @@ msgid "" "the :c:func:`sprintf` function in the C language." msgstr "" -#: ../../builtins/stdtypes.rst:4397 +#: ../../builtins/stdtypes.rst:4708 msgid "" "If *format* requires a single argument, *values* may be a single non-tuple " "object. [5]_ Otherwise, *values* must be a tuple with exactly the number of " @@ -6534,7 +6940,7 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../builtins/stdtypes.rst:4431 +#: ../../builtins/stdtypes.rst:4742 msgid "" "When the right argument is a dictionary (or other mapping type), then the " "formats in the bytes object *must* include a parenthesised mapping key into " @@ -6542,77 +6948,77 @@ msgid "" "mapping key selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:4483 +#: ../../builtins/stdtypes.rst:4794 msgid "\\(8)" msgstr "\\(8)" -#: ../../builtins/stdtypes.rst:4505 +#: ../../builtins/stdtypes.rst:4816 msgid "Single byte (accepts integer or single byte objects)." msgstr "" -#: ../../builtins/stdtypes.rst:4508 +#: ../../builtins/stdtypes.rst:4819 msgid "``'b'``" msgstr "``'b'``" -#: ../../builtins/stdtypes.rst:4508 +#: ../../builtins/stdtypes.rst:4819 msgid "" "Bytes (any object that follows the :ref:`buffer protocol ` or " "has :meth:`~object.__bytes__`)." msgstr "" -#: ../../builtins/stdtypes.rst:4512 +#: ../../builtins/stdtypes.rst:4823 msgid "" "``'s'`` is an alias for ``'b'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../builtins/stdtypes.rst:4515 +#: ../../builtins/stdtypes.rst:4826 msgid "" "Bytes (converts any Python object using ``repr(obj).encode('ascii', " "'backslashreplace')``)." msgstr "" -#: ../../builtins/stdtypes.rst:4518 +#: ../../builtins/stdtypes.rst:4829 msgid "" "``'r'`` is an alias for ``'a'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../builtins/stdtypes.rst:4518 +#: ../../builtins/stdtypes.rst:4829 msgid "\\(7)" msgstr "\\(7)" -#: ../../builtins/stdtypes.rst:4553 +#: ../../builtins/stdtypes.rst:4864 msgid "``b'%s'`` is deprecated, but will not be removed during the 3.x series." msgstr "``b'%s'`` 已被棄用,但在 3.x 系列中不會被移除。" -#: ../../builtins/stdtypes.rst:4556 +#: ../../builtins/stdtypes.rst:4867 msgid "``b'%r'`` is deprecated, but will not be removed during the 3.x series." msgstr "``b'%r'`` 已被棄用,但在 3.x 系列中不會被移除。" -#: ../../builtins/stdtypes.rst:4568 +#: ../../builtins/stdtypes.rst:4879 msgid ":pep:`461` - Adding % formatting to bytes and bytearray" msgstr "" -#: ../../builtins/stdtypes.rst:4575 +#: ../../builtins/stdtypes.rst:4886 msgid "Memory Views" msgstr "" -#: ../../builtins/stdtypes.rst:4577 +#: ../../builtins/stdtypes.rst:4888 msgid "" ":class:`memoryview` objects allow Python code to access the internal data of " "an object that supports the :ref:`buffer protocol ` without " "copying." msgstr "" -#: ../../builtins/stdtypes.rst:4583 +#: ../../builtins/stdtypes.rst:4894 msgid "" "Create a :class:`memoryview` that references *object*. *object* must " "support the buffer protocol. Built-in objects that support the buffer " "protocol include :class:`bytes` and :class:`bytearray`." msgstr "" -#: ../../builtins/stdtypes.rst:4587 +#: ../../builtins/stdtypes.rst:4898 msgid "" "A :class:`memoryview` has the notion of an *element*, which is the atomic " "memory unit handled by the originating *object*. For many simple types such " @@ -6620,38 +7026,38 @@ msgid "" "other types such as :class:`array.array` may have bigger elements." msgstr "" -#: ../../builtins/stdtypes.rst:4592 +#: ../../builtins/stdtypes.rst:4903 msgid "" ":class:`!memoryview`\\s are :ref:`generic ` over the type of their " "underlying data." msgstr "" -#: ../../builtins/stdtypes.rst:4595 +#: ../../builtins/stdtypes.rst:4906 msgid "" "``len(view)`` is equal to the length of :meth:`~memoryview.tolist`, which is " "the nested list representation of the view. If ``view.ndim == 1``, this is " "equal to the number of elements in the view." msgstr "" -#: ../../builtins/stdtypes.rst:4599 +#: ../../builtins/stdtypes.rst:4910 msgid "" "If ``view.ndim == 0``, ``len(view)`` now raises :exc:`TypeError` instead of " "returning 1." msgstr "" -#: ../../builtins/stdtypes.rst:4602 +#: ../../builtins/stdtypes.rst:4913 msgid "" "The :class:`~memoryview.itemsize` attribute will give you the number of " "bytes in a single element." msgstr "" -#: ../../builtins/stdtypes.rst:4605 +#: ../../builtins/stdtypes.rst:4916 msgid "" "A :class:`memoryview` supports slicing and indexing to expose its data. One-" "dimensional slicing will result in a subview::" msgstr "" -#: ../../builtins/stdtypes.rst:4608 +#: ../../builtins/stdtypes.rst:4919 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> v[1]\n" @@ -6673,7 +7079,7 @@ msgstr "" ">>> bytes(v[1:4])\n" "b'bce'" -#: ../../builtins/stdtypes.rst:4618 +#: ../../builtins/stdtypes.rst:4929 msgid "" "If :class:`~memoryview.format` is one of the native format specifiers from " "the :mod:`struct` module, indexing with an integer or a tuple of integers is " @@ -6684,11 +7090,11 @@ msgid "" "memoryviews can be indexed with the empty tuple." msgstr "" -#: ../../builtins/stdtypes.rst:4627 +#: ../../builtins/stdtypes.rst:4938 msgid "Here is an example with a non-byte format::" msgstr "" -#: ../../builtins/stdtypes.rst:4629 +#: ../../builtins/stdtypes.rst:4940 msgid "" ">>> import array\n" ">>> a = array.array('l', [-11111111, 22222222, -33333333, 44444444])\n" @@ -6710,13 +7116,13 @@ msgstr "" ">>> m[::2].tolist()\n" "[-11111111, -33333333]" -#: ../../builtins/stdtypes.rst:4639 +#: ../../builtins/stdtypes.rst:4950 msgid "" "If the underlying object is writable, the memoryview supports one-" "dimensional slice assignment. Resizing is not allowed::" msgstr "" -#: ../../builtins/stdtypes.rst:4642 +#: ../../builtins/stdtypes.rst:4953 msgid "" ">>> data = bytearray(b'abcefg')\n" ">>> v = memoryview(data)\n" @@ -6756,14 +7162,14 @@ msgstr "" ">>> data\n" "bytearray(b'z1spam')" -#: ../../builtins/stdtypes.rst:4660 +#: ../../builtins/stdtypes.rst:4971 msgid "" "One-dimensional memoryviews of :term:`hashable` (read-only) types with " "formats 'B', 'b' or 'c' are also hashable. The hash is defined as ``hash(m) " "== hash(m.tobytes())``::" msgstr "" -#: ../../builtins/stdtypes.rst:4664 +#: ../../builtins/stdtypes.rst:4975 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> hash(v) == hash(b'abcefg')\n" @@ -6781,45 +7187,45 @@ msgstr "" ">>> hash(v[::-2]) == hash(b'abcefg'[::-2])\n" "True" -#: ../../builtins/stdtypes.rst:4672 +#: ../../builtins/stdtypes.rst:4983 msgid "" "One-dimensional memoryviews can now be sliced. One-dimensional memoryviews " "with formats 'B', 'b' or 'c' are now :term:`hashable`." msgstr "" -#: ../../builtins/stdtypes.rst:4676 +#: ../../builtins/stdtypes.rst:4987 msgid "" "memoryview is now registered automatically " "with :class:`collections.abc.Sequence`" msgstr "" -#: ../../builtins/stdtypes.rst:4680 +#: ../../builtins/stdtypes.rst:4991 msgid "memoryviews can now be indexed with a tuple of integers." msgstr "" -#: ../../builtins/stdtypes.rst:4683 +#: ../../builtins/stdtypes.rst:4994 msgid "memoryview is now a :term:`generic type`." msgstr "" -#: ../../builtins/stdtypes.rst:4686 +#: ../../builtins/stdtypes.rst:4997 msgid ":class:`memoryview` has several methods:" msgstr ":class:`memoryview` 有幾個方法:" -#: ../../builtins/stdtypes.rst:4690 +#: ../../builtins/stdtypes.rst:5001 msgid "" "A memoryview and a :pep:`3118` exporter are equal if their shapes are " "equivalent and if all corresponding values are equal when the operands' " "respective format codes are interpreted using :mod:`struct` syntax." msgstr "" -#: ../../builtins/stdtypes.rst:4694 +#: ../../builtins/stdtypes.rst:5005 msgid "" "For the subset of :mod:`struct` format strings currently supported " "by :meth:`tolist`, ``v`` and ``w`` are equal if ``v.tolist() == " "w.tolist()``::" msgstr "" -#: ../../builtins/stdtypes.rst:4697 +#: ../../builtins/stdtypes.rst:5008 msgid "" ">>> import array\n" ">>> a = array.array('I', [1, 2, 3, 4, 5])\n" @@ -6853,14 +7259,14 @@ msgstr "" ">>> z.tolist() == c.tolist()\n" "True" -#: ../../builtins/stdtypes.rst:4713 +#: ../../builtins/stdtypes.rst:5024 msgid "" "If either format string is not supported by the :mod:`struct` module, then " "the objects will always compare as unequal (even if the format strings and " "buffer contents are identical)::" msgstr "" -#: ../../builtins/stdtypes.rst:4717 +#: ../../builtins/stdtypes.rst:5028 msgid "" ">>> from ctypes import BigEndianStructure, c_long\n" ">>> class BEPoint(BigEndianStructure):\n" @@ -6886,25 +7292,25 @@ msgstr "" ">>> a == b\n" "False" -#: ../../builtins/stdtypes.rst:4729 +#: ../../builtins/stdtypes.rst:5040 msgid "" "Note that, as with floating-point numbers, ``v is w`` does *not* imply ``v " "== w`` for memoryview objects." msgstr "" -#: ../../builtins/stdtypes.rst:4732 +#: ../../builtins/stdtypes.rst:5043 msgid "" "Previous versions compared the raw memory disregarding the item format and " "the logical array structure." msgstr "" -#: ../../builtins/stdtypes.rst:4738 +#: ../../builtins/stdtypes.rst:5049 msgid "" "Return the data in the buffer as a bytestring. This is equivalent to " "calling the :class:`bytes` constructor on the memoryview. ::" msgstr "" -#: ../../builtins/stdtypes.rst:4741 +#: ../../builtins/stdtypes.rst:5052 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.tobytes()\n" @@ -6918,7 +7324,7 @@ msgstr "" ">>> bytes(m)\n" "b'abc'" -#: ../../builtins/stdtypes.rst:4747 +#: ../../builtins/stdtypes.rst:5058 msgid "" "For non-contiguous arrays the result is equal to the flattened list " "representation with all elements converted to bytes. :meth:`tobytes` " @@ -6926,7 +7332,7 @@ msgid "" "module syntax." msgstr "" -#: ../../builtins/stdtypes.rst:4752 +#: ../../builtins/stdtypes.rst:5063 msgid "" "*order* can be {'C', 'F', 'A'}. When *order* is 'C' or 'F', the data of the " "original array is converted to C or Fortran order. For contiguous views, 'A' " @@ -6935,13 +7341,13 @@ msgid "" "to C first. *order=None* is the same as *order='C'*." msgstr "" -#: ../../builtins/stdtypes.rst:4762 +#: ../../builtins/stdtypes.rst:5073 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the buffer. ::" msgstr "" -#: ../../builtins/stdtypes.rst:4765 +#: ../../builtins/stdtypes.rst:5076 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.hex()\n" @@ -6951,18 +7357,18 @@ msgstr "" ">>> m.hex()\n" "'616263'" -#: ../../builtins/stdtypes.rst:4771 +#: ../../builtins/stdtypes.rst:5082 msgid "" "Similar to :meth:`bytes.hex`, :meth:`memoryview.hex` now supports optional " "*sep* and *bytes_per_sep* parameters to insert separators between bytes in " "the hex output." msgstr "" -#: ../../builtins/stdtypes.rst:4778 +#: ../../builtins/stdtypes.rst:5089 msgid "Return the data in the buffer as a list of elements. ::" msgstr "" -#: ../../builtins/stdtypes.rst:4780 +#: ../../builtins/stdtypes.rst:5091 msgid "" ">>> memoryview(b'abc').tolist()\n" "[97, 98, 99]\n" @@ -6980,19 +7386,19 @@ msgstr "" ">>> m.tolist()\n" "[1.1, 2.2, 3.3]" -#: ../../builtins/stdtypes.rst:4788 +#: ../../builtins/stdtypes.rst:5099 msgid "" ":meth:`tolist` now supports all single character native formats " "in :mod:`struct` module syntax as well as multi-dimensional representations." msgstr "" -#: ../../builtins/stdtypes.rst:4795 +#: ../../builtins/stdtypes.rst:5106 msgid "" "Return a readonly version of the memoryview object. The original memoryview " "object is unchanged. ::" msgstr "" -#: ../../builtins/stdtypes.rst:4798 +#: ../../builtins/stdtypes.rst:5109 msgid "" ">>> m = memoryview(bytearray(b'abc'))\n" ">>> mm = m.toreadonly()\n" @@ -7018,7 +7424,7 @@ msgstr "" ">>> mm.tolist()\n" "[43, 98, 99]" -#: ../../builtins/stdtypes.rst:4814 +#: ../../builtins/stdtypes.rst:5125 msgid "" "Release the underlying buffer exposed by the memoryview object. Many " "objects take special actions when a view is held on them (for example, " @@ -7027,14 +7433,14 @@ msgid "" "resources) as soon as possible." msgstr "" -#: ../../builtins/stdtypes.rst:4820 +#: ../../builtins/stdtypes.rst:5131 msgid "" "After this method has been called, any further operation on the view raises " "a :class:`ValueError` (except :meth:`release` itself which can be called " "multiple times)::" msgstr "" -#: ../../builtins/stdtypes.rst:4824 +#: ../../builtins/stdtypes.rst:5135 msgid "" ">>> m = memoryview(b'abc')\n" ">>> m.release()\n" @@ -7050,13 +7456,13 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" -#: ../../builtins/stdtypes.rst:4831 +#: ../../builtins/stdtypes.rst:5142 msgid "" "The context management protocol can be used for a similar effect, using the " "``with`` statement::" msgstr "" -#: ../../builtins/stdtypes.rst:4834 +#: ../../builtins/stdtypes.rst:5145 msgid "" ">>> with memoryview(b'abc') as m:\n" "... m[0]\n" @@ -7076,7 +7482,7 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" -#: ../../builtins/stdtypes.rst:4848 +#: ../../builtins/stdtypes.rst:5159 msgid "" "Cast a memoryview to a new format or shape. *shape* defaults to " "``[byte_length//new_itemsize]``, which means that the result view will be " @@ -7085,7 +7491,7 @@ msgid "" "contiguous -> 1D." msgstr "" -#: ../../builtins/stdtypes.rst:4854 +#: ../../builtins/stdtypes.rst:5165 msgid "" "The destination format is restricted to a single element native format " "in :mod:`struct` syntax. One of the formats must be a byte format ('B', 'b' " @@ -7093,11 +7499,11 @@ msgid "" "length. Note that all byte lengths may depend on the operating system." msgstr "" -#: ../../builtins/stdtypes.rst:4860 +#: ../../builtins/stdtypes.rst:5171 msgid "Cast 1D/long to 1D/unsigned bytes::" msgstr "" -#: ../../builtins/stdtypes.rst:4862 +#: ../../builtins/stdtypes.rst:5173 msgid "" ">>> import array\n" ">>> a = array.array('l', [1,2,3])\n" @@ -7141,11 +7547,11 @@ msgstr "" ">>> y.nbytes\n" "24" -#: ../../builtins/stdtypes.rst:4883 +#: ../../builtins/stdtypes.rst:5194 msgid "Cast 1D/unsigned bytes to 1D/char::" msgstr "" -#: ../../builtins/stdtypes.rst:4885 +#: ../../builtins/stdtypes.rst:5196 msgid "" ">>> b = bytearray(b'zyz')\n" ">>> x = memoryview(b)\n" @@ -7169,11 +7575,11 @@ msgstr "" ">>> b\n" "bytearray(b'ayz')" -#: ../../builtins/stdtypes.rst:4896 +#: ../../builtins/stdtypes.rst:5207 msgid "Cast 1D/bytes to 3D/ints to 1D/signed char::" msgstr "" -#: ../../builtins/stdtypes.rst:4898 +#: ../../builtins/stdtypes.rst:5209 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"i\"*12, *list(range(12)))\n" @@ -7223,11 +7629,11 @@ msgstr "" ">>> z.nbytes\n" "48" -#: ../../builtins/stdtypes.rst:4922 +#: ../../builtins/stdtypes.rst:5233 msgid "Cast 1D/unsigned long to 2D/unsigned long::" msgstr "" -#: ../../builtins/stdtypes.rst:4924 +#: ../../builtins/stdtypes.rst:5235 msgid "" ">>> buf = struct.pack(\"L\"*6, *list(range(6)))\n" ">>> x = memoryview(buf)\n" @@ -7249,33 +7655,33 @@ msgstr "" ">>> y.tolist()\n" "[[0, 1, 2], [3, 4, 5]]" -#: ../../builtins/stdtypes.rst:4936 +#: ../../builtins/stdtypes.rst:5247 msgid "The source format is no longer restricted when casting to a byte view." msgstr "" -#: ../../builtins/stdtypes.rst:4941 +#: ../../builtins/stdtypes.rst:5252 msgid "Count the number of occurrences of *value*." msgstr "計算 *value* 的出現次數" -#: ../../builtins/stdtypes.rst:4947 +#: ../../builtins/stdtypes.rst:5258 msgid "" "Return the index of the first occurrence of *value* (at or after index " "*start* and before index *stop*)." msgstr "" -#: ../../builtins/stdtypes.rst:4950 +#: ../../builtins/stdtypes.rst:5261 msgid "Raises a :exc:`ValueError` if *value* cannot be found." msgstr "在找不到 *value* 時引發 :exc:`ValueError`。" -#: ../../builtins/stdtypes.rst:4954 +#: ../../builtins/stdtypes.rst:5265 msgid "There are also several readonly attributes available:" msgstr "" -#: ../../builtins/stdtypes.rst:4958 +#: ../../builtins/stdtypes.rst:5269 msgid "The underlying object of the memoryview::" msgstr "memoryview 的底層物件: ::" -#: ../../builtins/stdtypes.rst:4960 +#: ../../builtins/stdtypes.rst:5271 msgid "" ">>> b = bytearray(b'xyz')\n" ">>> m = memoryview(b)\n" @@ -7287,14 +7693,14 @@ msgstr "" ">>> m.obj is b\n" "True" -#: ../../builtins/stdtypes.rst:4969 +#: ../../builtins/stdtypes.rst:5280 msgid "" "``nbytes == product(shape) * itemsize == len(m.tobytes())``. This is the " "amount of space in bytes that the array would use in a contiguous " "representation. It is not necessarily equal to ``len(m)``::" msgstr "" -#: ../../builtins/stdtypes.rst:4973 +#: ../../builtins/stdtypes.rst:5284 msgid "" ">>> import array\n" ">>> a = array.array('i', [1,2,3,4,5])\n" @@ -7326,11 +7732,11 @@ msgstr "" ">>> len(y.tobytes())\n" "12" -#: ../../builtins/stdtypes.rst:4988 +#: ../../builtins/stdtypes.rst:5299 msgid "Multi-dimensional arrays::" msgstr "" -#: ../../builtins/stdtypes.rst:4990 +#: ../../builtins/stdtypes.rst:5301 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"d\"*12, *[1.5*x for x in range(12)])\n" @@ -7354,11 +7760,11 @@ msgstr "" ">>> y.nbytes\n" "96" -#: ../../builtins/stdtypes.rst:5005 +#: ../../builtins/stdtypes.rst:5316 msgid "A bool indicating whether the memory is read only." msgstr "" -#: ../../builtins/stdtypes.rst:5009 +#: ../../builtins/stdtypes.rst:5320 msgid "" "A string containing the format (in :mod:`struct` module style) for each " "element in the view. A memoryview can be created from exporters with " @@ -7366,17 +7772,17 @@ msgid "" "restricted to native single element formats." msgstr "" -#: ../../builtins/stdtypes.rst:5014 +#: ../../builtins/stdtypes.rst:5325 msgid "" "format ``'B'`` is now handled according to the struct module syntax. This " "means that ``memoryview(b'abc')[0] == b'abc'[0] == 97``." msgstr "" -#: ../../builtins/stdtypes.rst:5020 +#: ../../builtins/stdtypes.rst:5331 msgid "The size in bytes of each element of the memoryview::" msgstr "" -#: ../../builtins/stdtypes.rst:5022 +#: ../../builtins/stdtypes.rst:5333 msgid "" ">>> import array, struct\n" ">>> m = memoryview(array.array('H', [32000, 32001, 32002]))\n" @@ -7396,55 +7802,55 @@ msgstr "" ">>> struct.calcsize('H') == m.itemsize\n" "True" -#: ../../builtins/stdtypes.rst:5033 +#: ../../builtins/stdtypes.rst:5344 msgid "" "An integer indicating how many dimensions of a multi-dimensional array the " "memory represents." msgstr "" -#: ../../builtins/stdtypes.rst:5038 +#: ../../builtins/stdtypes.rst:5349 msgid "" "A tuple of integers the length of :attr:`ndim` giving the shape of the " "memory as an N-dimensional array." msgstr "" -#: ../../builtins/stdtypes.rst:5041 ../../builtins/stdtypes.rst:5049 +#: ../../builtins/stdtypes.rst:5352 ../../builtins/stdtypes.rst:5360 msgid "An empty tuple instead of ``None`` when ndim = 0." msgstr "" -#: ../../builtins/stdtypes.rst:5046 +#: ../../builtins/stdtypes.rst:5357 msgid "" "A tuple of integers the length of :attr:`ndim` giving the size in bytes to " "access each element for each dimension of the array." msgstr "" -#: ../../builtins/stdtypes.rst:5054 +#: ../../builtins/stdtypes.rst:5365 msgid "Used internally for PIL-style arrays. The value is informational only." msgstr "" -#: ../../builtins/stdtypes.rst:5058 +#: ../../builtins/stdtypes.rst:5369 msgid "A bool indicating whether the memory is C-:term:`contiguous`." msgstr "" -#: ../../builtins/stdtypes.rst:5064 +#: ../../builtins/stdtypes.rst:5375 msgid "A bool indicating whether the memory is Fortran :term:`contiguous`." msgstr "" -#: ../../builtins/stdtypes.rst:5070 +#: ../../builtins/stdtypes.rst:5381 msgid "A bool indicating whether the memory is :term:`contiguous`." msgstr "" -#: ../../builtins/stdtypes.rst:5074 +#: ../../builtins/stdtypes.rst:5385 msgid "" "For information on the thread safety of :class:`memoryview` objects in " "the :term:`free-threaded build`, see :ref:`thread-safety-memoryview`." msgstr "" -#: ../../builtins/stdtypes.rst:5081 +#: ../../builtins/stdtypes.rst:5392 msgid "Set Types --- :class:`set`, :class:`frozenset`" msgstr "" -#: ../../builtins/stdtypes.rst:5085 +#: ../../builtins/stdtypes.rst:5396 msgid "" "A :dfn:`set` object is an unordered collection of distinct :term:`hashable` " "objects. Common uses include membership testing, removing duplicates from a " @@ -7455,7 +7861,7 @@ msgid "" "the various set operations." msgstr "" -#: ../../builtins/stdtypes.rst:5093 +#: ../../builtins/stdtypes.rst:5404 msgid "" "Like other collections, sets support ``x in set``, ``len(set)``, and ``for x " "in set``. Being an unordered collection, sets do not record element " @@ -7463,7 +7869,7 @@ msgid "" "slicing, or other sequence-like behavior." msgstr "" -#: ../../builtins/stdtypes.rst:5098 +#: ../../builtins/stdtypes.rst:5409 msgid "" "There are currently two built-in set types, :class:`set` " "and :class:`frozenset`. The :class:`set` type is mutable --- the contents " @@ -7475,18 +7881,18 @@ msgid "" "of another set." msgstr "" -#: ../../builtins/stdtypes.rst:5107 +#: ../../builtins/stdtypes.rst:5418 msgid "" "Non-empty sets (not frozensets) can be created by placing a comma-separated " "list of elements within braces, for example: ``{'jack', 'sjoerd'}``, in " "addition to the :class:`set` constructor." msgstr "" -#: ../../builtins/stdtypes.rst:5111 +#: ../../builtins/stdtypes.rst:5422 msgid "The constructors for both classes work the same:" msgstr "" -#: ../../builtins/stdtypes.rst:5116 +#: ../../builtins/stdtypes.rst:5427 msgid "" "Return a new set or frozenset object whose elements are taken from " "*iterable*. The elements of a set must be :term:`hashable`. To represent " @@ -7494,92 +7900,92 @@ msgid "" "*iterable* is not specified, a new empty set is returned." msgstr "" -#: ../../builtins/stdtypes.rst:5122 +#: ../../builtins/stdtypes.rst:5433 msgid "Sets can be created by several means:" msgstr "集合可以以多種方式建立:" -#: ../../builtins/stdtypes.rst:5124 +#: ../../builtins/stdtypes.rst:5435 msgid "" "Use a comma-separated list of elements within braces: ``{'jack', 'sjoerd'}``" msgstr "" -#: ../../builtins/stdtypes.rst:5125 +#: ../../builtins/stdtypes.rst:5436 msgid "" "Use a set comprehension: ``{c for c in 'abracadabra' if c not in 'abc'}``" msgstr "" -#: ../../builtins/stdtypes.rst:5126 +#: ../../builtins/stdtypes.rst:5437 msgid "" "Use the type constructor: ``set()``, ``set('foobar')``, ``set(['a', 'b', " "'foo'])``" msgstr "" -#: ../../builtins/stdtypes.rst:5128 +#: ../../builtins/stdtypes.rst:5439 msgid "" "Instances of :class:`set` and :class:`frozenset` provide the following " "operations:" msgstr "" -#: ../../builtins/stdtypes.rst:5133 +#: ../../builtins/stdtypes.rst:5444 msgid "Return the number of elements in set *s* (cardinality of *s*)." msgstr "" -#: ../../builtins/stdtypes.rst:5137 +#: ../../builtins/stdtypes.rst:5448 msgid "Test *x* for membership in *s*." msgstr "" -#: ../../builtins/stdtypes.rst:5141 +#: ../../builtins/stdtypes.rst:5452 msgid "Test *x* for non-membership in *s*." msgstr "" -#: ../../builtins/stdtypes.rst:5146 +#: ../../builtins/stdtypes.rst:5457 msgid "" "Return ``True`` if the set has no elements in common with *other*. Sets are " "disjoint if and only if their intersection is the empty set." msgstr "" -#: ../../builtins/stdtypes.rst:5153 +#: ../../builtins/stdtypes.rst:5464 msgid "Test whether every element in the set is in *other*." msgstr "" -#: ../../builtins/stdtypes.rst:5157 +#: ../../builtins/stdtypes.rst:5468 msgid "" "Test whether the set is a proper subset of *other*, that is, ``set <= other " "and set != other``." msgstr "" -#: ../../builtins/stdtypes.rst:5164 +#: ../../builtins/stdtypes.rst:5475 msgid "Test whether every element in *other* is in the set." msgstr "" -#: ../../builtins/stdtypes.rst:5168 +#: ../../builtins/stdtypes.rst:5479 msgid "" "Test whether the set is a proper superset of *other*, that is, ``set >= " "other and set != other``." msgstr "" -#: ../../builtins/stdtypes.rst:5175 +#: ../../builtins/stdtypes.rst:5486 msgid "Return a new set with elements from the set and all others." msgstr "" -#: ../../builtins/stdtypes.rst:5181 +#: ../../builtins/stdtypes.rst:5492 msgid "Return a new set with elements common to the set and all others." msgstr "" -#: ../../builtins/stdtypes.rst:5187 +#: ../../builtins/stdtypes.rst:5498 msgid "Return a new set with elements in the set that are not in the others." msgstr "" -#: ../../builtins/stdtypes.rst:5193 +#: ../../builtins/stdtypes.rst:5504 msgid "" "Return a new set with elements in either the set or *other* but not both." msgstr "" -#: ../../builtins/stdtypes.rst:5198 +#: ../../builtins/stdtypes.rst:5509 msgid "Return a shallow copy of the set." msgstr "" -#: ../../builtins/stdtypes.rst:5201 +#: ../../builtins/stdtypes.rst:5512 msgid "" "Note, the non-operator versions " "of :meth:`~frozenset.union`, :meth:`~frozenset.intersection`, :meth:`~frozenset.difference`, :meth:`~frozenset.symmetric_difference`, :meth:`~frozenset.issubset`, " @@ -7590,7 +7996,7 @@ msgid "" "``set('abc').intersection('cbs')``." msgstr "" -#: ../../builtins/stdtypes.rst:5208 +#: ../../builtins/stdtypes.rst:5519 msgid "" "Both :class:`set` and :class:`frozenset` support set to set comparisons. Two " "sets are equal if and only if every element of each set is contained in the " @@ -7600,14 +8006,14 @@ msgid "" "set is a proper superset of the second set (is a superset, but is not equal)." msgstr "" -#: ../../builtins/stdtypes.rst:5215 +#: ../../builtins/stdtypes.rst:5526 msgid "" "Instances of :class:`set` are compared to instances of :class:`frozenset` " "based on their members. For example, ``set('abc') == frozenset('abc')`` " "returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``." msgstr "" -#: ../../builtins/stdtypes.rst:5219 +#: ../../builtins/stdtypes.rst:5530 msgid "" "The subset and equality comparisons do not generalize to a total ordering " "function. For example, any two nonempty disjoint sets are not equal and are " @@ -7615,71 +8021,71 @@ msgid "" "``ab``." msgstr "" -#: ../../builtins/stdtypes.rst:5224 +#: ../../builtins/stdtypes.rst:5535 msgid "" "Since sets only define partial ordering (subset relationships), the output " "of the :meth:`list.sort` method is undefined for lists of sets." msgstr "" -#: ../../builtins/stdtypes.rst:5227 +#: ../../builtins/stdtypes.rst:5538 msgid "Set elements, like dictionary keys, must be :term:`hashable`." msgstr "" -#: ../../builtins/stdtypes.rst:5229 +#: ../../builtins/stdtypes.rst:5540 msgid "" "Binary operations that mix :class:`set` instances with :class:`frozenset` " "return the type of the first operand. For example: ``frozenset('ab') | " "set('bc')`` returns an instance of :class:`frozenset`." msgstr "" -#: ../../builtins/stdtypes.rst:5233 +#: ../../builtins/stdtypes.rst:5544 msgid "" "The following table lists operations available for :class:`set` that do not " "apply to immutable instances of :class:`frozenset`:" msgstr "" -#: ../../builtins/stdtypes.rst:5239 +#: ../../builtins/stdtypes.rst:5550 msgid "Update the set, adding elements from all others." msgstr "" -#: ../../builtins/stdtypes.rst:5244 +#: ../../builtins/stdtypes.rst:5555 msgid "Update the set, keeping only elements found in it and all others." msgstr "" -#: ../../builtins/stdtypes.rst:5249 +#: ../../builtins/stdtypes.rst:5560 msgid "Update the set, removing elements found in others." msgstr "" -#: ../../builtins/stdtypes.rst:5254 +#: ../../builtins/stdtypes.rst:5565 msgid "" "Update the set, keeping only elements found in either set, but not in both." msgstr "" -#: ../../builtins/stdtypes.rst:5258 +#: ../../builtins/stdtypes.rst:5569 msgid "Add element *elem* to the set." msgstr "將元素 *elem* 加入集合。" -#: ../../builtins/stdtypes.rst:5262 +#: ../../builtins/stdtypes.rst:5573 msgid "" "Remove element *elem* from the set. Raises :exc:`KeyError` if *elem* is not " "contained in the set." msgstr "" -#: ../../builtins/stdtypes.rst:5267 +#: ../../builtins/stdtypes.rst:5578 msgid "Remove element *elem* from the set if it is present." msgstr "如果 *elem* 存在於集合中則將其移除。" -#: ../../builtins/stdtypes.rst:5271 +#: ../../builtins/stdtypes.rst:5582 msgid "" "Remove and return an arbitrary element from the set. Raises :exc:`KeyError` " "if the set is empty." msgstr "" -#: ../../builtins/stdtypes.rst:5276 +#: ../../builtins/stdtypes.rst:5587 msgid "Remove all elements from the set." msgstr "從集合中移除所有元素。" -#: ../../builtins/stdtypes.rst:5279 +#: ../../builtins/stdtypes.rst:5590 msgid "" "Note, the non-operator versions of " "the :meth:`~set.update`, :meth:`~set.intersection_update`, :meth:`~set.difference_update`, " @@ -7687,7 +8093,7 @@ msgid "" "iterable as an argument." msgstr "" -#: ../../builtins/stdtypes.rst:5284 +#: ../../builtins/stdtypes.rst:5595 msgid "" "Note, the *elem* argument to " "the :meth:`~object.__contains__`, :meth:`~set.remove`, " @@ -7695,33 +8101,33 @@ msgid "" "equivalent frozenset, a temporary one is created from *elem*." msgstr "" -#: ../../builtins/stdtypes.rst:5291 -msgid "" -"For detailed information on thread-safety guarantees for :class:`set` " -"objects, see :ref:`thread-safety-set`." -msgstr "" - -#: ../../builtins/stdtypes.rst:5294 +#: ../../builtins/stdtypes.rst:5600 msgid "" "Sets and frozensets are :ref:`generic ` over the type of their " "elements." msgstr "" -#: ../../builtins/stdtypes.rst:5300 -msgid "Mapping Types --- :class:`dict`" +#: ../../builtins/stdtypes.rst:5604 +msgid "" +"For detailed information on thread-safety guarantees for :class:`set` " +"objects, see :ref:`thread-safety-set`." msgstr "" -#: ../../builtins/stdtypes.rst:5310 +#: ../../builtins/stdtypes.rst:5611 +msgid "Mapping types --- :class:`!dict`, :class:`!frozendict`" +msgstr "對映型別 --- :class:`!dict`、:class:`!frozendict`" + +#: ../../builtins/stdtypes.rst:5621 msgid "" "A :term:`mapping` object maps :term:`hashable` values to arbitrary objects. " -"Mappings are mutable objects. There is currently only one standard mapping " -"type, the :dfn:`dictionary`. (For other containers see the built-" -"in :class:`list`, :class:`set`, and :class:`tuple` classes, and " -"the :mod:`collections` module.) See :ref:`time-complexity` for the costs of " -"the various dictionary operations." +"There are currently two standard mapping types, the :dfn:`dictionary` and :" +"class:`frozendict`. (For other containers see the built-in :class:`list`, :" +"class:`set`, and :class:`tuple` classes, and the :mod:`collections` module.) " +"See :ref:`time-complexity` for the costs of the various dictionary " +"operations." msgstr "" -#: ../../builtins/stdtypes.rst:5318 +#: ../../builtins/stdtypes.rst:5630 msgid "" "A dictionary's keys are *almost* arbitrary values. Values that are " "not :term:`hashable`, that is, values containing lists, dictionaries or " @@ -7731,33 +8137,33 @@ msgid "" "dictionary entry." msgstr "" -#: ../../builtins/stdtypes.rst:5329 +#: ../../builtins/stdtypes.rst:5641 msgid "" "Return a new dictionary initialized from an optional positional argument and " "a possibly empty set of keyword arguments." msgstr "" -#: ../../builtins/stdtypes.rst:5332 +#: ../../builtins/stdtypes.rst:5644 msgid "Dictionaries can be created by several means:" msgstr "字典可以用數種方式建立:" -#: ../../builtins/stdtypes.rst:5334 +#: ../../builtins/stdtypes.rst:5646 msgid "" "Use a comma-separated list of ``key: value`` pairs within braces: ``{'jack': " "4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``" msgstr "" -#: ../../builtins/stdtypes.rst:5336 +#: ../../builtins/stdtypes.rst:5648 msgid "Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}``" msgstr "" -#: ../../builtins/stdtypes.rst:5337 +#: ../../builtins/stdtypes.rst:5649 msgid "" "Use the type constructor: ``dict()``, ``dict([('foo', 100), ('bar', " "200)])``, ``dict(foo=100, bar=200)``" msgstr "" -#: ../../builtins/stdtypes.rst:5340 +#: ../../builtins/stdtypes.rst:5652 msgid "" "If no positional argument is given, an empty dictionary is created. If a " "positional argument is given and it defines a ``keys()`` method, a " @@ -7770,7 +8176,7 @@ msgid "" "that key becomes the corresponding value in the new dictionary." msgstr "" -#: ../../builtins/stdtypes.rst:5350 +#: ../../builtins/stdtypes.rst:5662 msgid "" "If keyword arguments are given, the keyword arguments and their values are " "added to the dictionary created from the positional argument. If a key " @@ -7778,7 +8184,7 @@ msgid "" "the value from the positional argument." msgstr "" -#: ../../builtins/stdtypes.rst:5355 +#: ../../builtins/stdtypes.rst:5667 msgid "" "Dictionaries compare equal if and only if they have the same ``(key, " "value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', '>=', " @@ -7787,7 +8193,7 @@ msgid "" "``{\"one\": 1, \"two\": 2, \"three\": 3}``::" msgstr "" -#: ../../builtins/stdtypes.rst:5361 +#: ../../builtins/stdtypes.rst:5673 msgid "" ">>> a = dict(one=1, two=2, three=3)\n" ">>> b = {'one': 1, 'two': 2, 'three': 3}\n" @@ -7807,19 +8213,19 @@ msgstr "" ">>> a == b == c == d == e == f\n" "True" -#: ../../builtins/stdtypes.rst:5370 +#: ../../builtins/stdtypes.rst:5682 msgid "" "Providing keyword arguments as in the first example only works for keys that " "are valid Python identifiers. Otherwise, any valid keys can be used." msgstr "" -#: ../../builtins/stdtypes.rst:5373 +#: ../../builtins/stdtypes.rst:5685 msgid "" "Dictionaries preserve insertion order. Note that updating a key does not " "affect the order. Keys added after deletion are inserted at the end. ::" msgstr "" -#: ../../builtins/stdtypes.rst:5376 +#: ../../builtins/stdtypes.rst:5688 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -7851,39 +8257,39 @@ msgstr "" ">>> d\n" "{'one': 42, 'three': 3, 'four': 4, 'two': None}" -#: ../../builtins/stdtypes.rst:5391 +#: ../../builtins/stdtypes.rst:5703 msgid "" "Dictionary order is guaranteed to be insertion order. This behavior was an " "implementation detail of CPython from 3.6." msgstr "" -#: ../../builtins/stdtypes.rst:5395 +#: ../../builtins/stdtypes.rst:5707 msgid "" "Dictionaries are :ref:`generic ` over two types, signifying " "(respectively) the types of the dictionary's keys and values." msgstr "" -#: ../../builtins/stdtypes.rst:5398 +#: ../../builtins/stdtypes.rst:5710 msgid "" "These are the operations that dictionaries support (and therefore, custom " "mapping types should support too):" msgstr "" -#: ../../builtins/stdtypes.rst:5403 +#: ../../builtins/stdtypes.rst:5715 msgid "Return a list of all the keys used in the dictionary *d*." msgstr "" -#: ../../builtins/stdtypes.rst:5407 +#: ../../builtins/stdtypes.rst:5719 msgid "Return the number of items in the dictionary *d*." msgstr "" -#: ../../builtins/stdtypes.rst:5411 +#: ../../builtins/stdtypes.rst:5723 msgid "" "Return the item of *d* with key *key*. Raises a :exc:`KeyError` if *key* is " "not in the map." msgstr "" -#: ../../builtins/stdtypes.rst:5416 +#: ../../builtins/stdtypes.rst:5728 msgid "" "If a subclass of dict defines a method :meth:`~object.__missing__` and *key* " "is not present, the ``d[key]`` operation calls that method with the key " @@ -7895,7 +8301,7 @@ msgid "" "instance variable::" msgstr "" -#: ../../builtins/stdtypes.rst:5424 +#: ../../builtins/stdtypes.rst:5736 msgid "" ">>> class Counter(dict):\n" "... def __missing__(self, key):\n" @@ -7919,51 +8325,51 @@ msgstr "" ">>> c['red']\n" "1" -#: ../../builtins/stdtypes.rst:5435 +#: ../../builtins/stdtypes.rst:5747 msgid "" "The example above shows part of the implementation " "of :class:`collections.Counter`. A different :meth:`!__missing__` method is " "used by :class:`collections.defaultdict`." msgstr "" -#: ../../builtins/stdtypes.rst:5442 +#: ../../builtins/stdtypes.rst:5754 msgid "Set ``d[key]`` to *value*." msgstr "將 ``d[key]`` 設為 *value*。" -#: ../../builtins/stdtypes.rst:5446 +#: ../../builtins/stdtypes.rst:5758 msgid "" "Remove ``d[key]`` from *d*. Raises a :exc:`KeyError` if *key* is not in the " "map." msgstr "從 *d* 中移除 ``d[key]``。若 *key* 不在對映中則引發 :exc:`KeyError`。" -#: ../../builtins/stdtypes.rst:5451 +#: ../../builtins/stdtypes.rst:5763 msgid "Return ``True`` if *d* has a key *key*, else ``False``." msgstr "若 *d* 有鍵 *key* 則回傳 ``True``,否則回傳 ``False``。" -#: ../../builtins/stdtypes.rst:5455 +#: ../../builtins/stdtypes.rst:5767 msgid "Equivalent to ``not key in d``." msgstr "等價於 ``not key in d``。" -#: ../../builtins/stdtypes.rst:5459 +#: ../../builtins/stdtypes.rst:5771 msgid "" "Return an iterator over the keys of the dictionary. This is a shortcut for " "``iter(d.keys())``." msgstr "" -#: ../../builtins/stdtypes.rst:5464 +#: ../../builtins/stdtypes.rst:5776 msgid "Remove all items from the dictionary." msgstr "從字典中移除所有項目。" -#: ../../builtins/stdtypes.rst:5468 +#: ../../builtins/stdtypes.rst:5780 msgid "Return a shallow copy of the dictionary." msgstr "" -#: ../../builtins/stdtypes.rst:5472 +#: ../../builtins/stdtypes.rst:5784 msgid "" "Create a new dictionary with keys from *iterable* and values set to *value*." msgstr "" -#: ../../builtins/stdtypes.rst:5474 +#: ../../builtins/stdtypes.rst:5786 msgid "" ":meth:`fromkeys` is a class method that returns a new dictionary. *value* " "defaults to ``None``. All of the values refer to just a single instance, so " @@ -7972,70 +8378,70 @@ msgid "" "` instead." msgstr "" -#: ../../builtins/stdtypes.rst:5482 +#: ../../builtins/stdtypes.rst:5794 msgid "" "Return the value for *key* if *key* is in the dictionary, else *default*. If " "*default* is not given, it defaults to ``None``, so that this method never " "raises a :exc:`KeyError`." msgstr "" -#: ../../builtins/stdtypes.rst:5488 +#: ../../builtins/stdtypes.rst:5800 msgid "" "Return a new view of the dictionary's items (``(key, value)`` pairs). See " "the :ref:`documentation of view objects `." msgstr "" -#: ../../builtins/stdtypes.rst:5493 +#: ../../builtins/stdtypes.rst:5805 msgid "" "Return a new view of the dictionary's keys. See the :ref:`documentation of " "view objects `." msgstr "" -#: ../../builtins/stdtypes.rst:5499 +#: ../../builtins/stdtypes.rst:5811 msgid "" "If *key* is in the dictionary, remove it and return its value, else return " "*default*. If *default* is not given and *key* is not in the dictionary, " "a :exc:`KeyError` is raised." msgstr "" -#: ../../builtins/stdtypes.rst:5505 +#: ../../builtins/stdtypes.rst:5817 msgid "" "Remove and return a ``(key, value)`` pair from the dictionary. Pairs are " "returned in :abbr:`LIFO (last-in, first-out)` order." msgstr "" -#: ../../builtins/stdtypes.rst:5508 +#: ../../builtins/stdtypes.rst:5820 msgid "" ":meth:`popitem` is useful to destructively iterate over a dictionary, as " "often used in set algorithms. If the dictionary is empty, " "calling :meth:`popitem` raises a :exc:`KeyError`." msgstr "" -#: ../../builtins/stdtypes.rst:5512 +#: ../../builtins/stdtypes.rst:5824 msgid "" "LIFO order is now guaranteed. In prior versions, :meth:`popitem` would " "return an arbitrary key/value pair." msgstr "" -#: ../../builtins/stdtypes.rst:5518 +#: ../../builtins/stdtypes.rst:5830 msgid "" "Return a reverse iterator over the keys of the dictionary. This is a " "shortcut for ``reversed(d.keys())``." msgstr "" -#: ../../builtins/stdtypes.rst:5525 +#: ../../builtins/stdtypes.rst:5837 msgid "" "If *key* is in the dictionary, return its value. If not, insert *key* with " "a value of *default* and return *default*. *default* defaults to ``None``." msgstr "" -#: ../../builtins/stdtypes.rst:5533 +#: ../../builtins/stdtypes.rst:5845 msgid "" "Update the dictionary with the key/value pairs from *mapping* or *iterable* " "and *kwargs*, overwriting existing keys. Return ``None``." msgstr "" -#: ../../builtins/stdtypes.rst:5536 +#: ../../builtins/stdtypes.rst:5848 msgid "" ":meth:`update` accepts either another object with a ``keys()`` method (in " "which case :meth:`~object.__getitem__` is called with every key returned " @@ -8044,20 +8450,20 @@ msgid "" "is then updated with those key/value pairs: ``d.update(red=1, blue=2)``." msgstr "" -#: ../../builtins/stdtypes.rst:5544 +#: ../../builtins/stdtypes.rst:5856 msgid "" "Return a new view of the dictionary's values. See the :ref:`documentation " "of view objects `." msgstr "" -#: ../../builtins/stdtypes.rst:5547 +#: ../../builtins/stdtypes.rst:5859 msgid "" "An equality comparison between one ``dict.values()`` view and another will " "always return ``False``. This also applies when comparing ``dict.values()`` " "to itself::" msgstr "" -#: ../../builtins/stdtypes.rst:5551 +#: ../../builtins/stdtypes.rst:5863 msgid "" ">>> d = {'a': 1}\n" ">>> d.values() == d.values()\n" @@ -8067,25 +8473,25 @@ msgstr "" ">>> d.values() == d.values()\n" "False" -#: ../../builtins/stdtypes.rst:5557 +#: ../../builtins/stdtypes.rst:5869 msgid "" "Create a new dictionary with the merged keys and values of *d* and *other*, " "which must both be dictionaries. The values of *other* take priority when " "*d* and *other* share keys." msgstr "" -#: ../../builtins/stdtypes.rst:5565 +#: ../../builtins/stdtypes.rst:5877 msgid "" "Update the dictionary *d* with keys and values from *other*, which may be " "either a :term:`mapping` or an :term:`iterable` of key/value pairs. The " "values of *other* take priority when *d* and *other* share keys." msgstr "" -#: ../../builtins/stdtypes.rst:5571 +#: ../../builtins/stdtypes.rst:5883 msgid "Dictionaries and dictionary views are reversible. ::" msgstr "" -#: ../../builtins/stdtypes.rst:5573 +#: ../../builtins/stdtypes.rst:5885 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -8107,27 +8513,27 @@ msgstr "" ">>> list(reversed(d.items()))\n" "[('four', 4), ('three', 3), ('two', 2), ('one', 1)]" -#: ../../builtins/stdtypes.rst:5583 +#: ../../builtins/stdtypes.rst:5895 msgid "Dictionaries are now reversible." msgstr "" -#: ../../builtins/stdtypes.rst:5588 +#: ../../builtins/stdtypes.rst:5900 msgid "" -":class:`types.MappingProxyType` can be used to create a read-only view of " -"a :class:`dict`." +":class:`frozendict` and :class:`types.MappingProxyType` can be used to " +"create a read-only view of a :class:`dict`." msgstr "" -#: ../../builtins/stdtypes.rst:5594 +#: ../../builtins/stdtypes.rst:5905 msgid "" "For detailed information on thread-safety guarantees for :class:`dict` " "objects, see :ref:`thread-safety-dict`." msgstr "" -#: ../../builtins/stdtypes.rst:5601 +#: ../../builtins/stdtypes.rst:5912 msgid "Dictionary view objects" msgstr "字典視圖物件" -#: ../../builtins/stdtypes.rst:5603 +#: ../../builtins/stdtypes.rst:5914 msgid "" "The objects returned by :meth:`dict.keys`, :meth:`dict.values` " "and :meth:`dict.items` are *view objects*. They provide a dynamic view on " @@ -8135,23 +8541,23 @@ msgid "" "view reflects these changes." msgstr "" -#: ../../builtins/stdtypes.rst:5608 +#: ../../builtins/stdtypes.rst:5919 msgid "" "Dictionary views can be iterated over to yield their respective data, and " "support membership tests:" msgstr "" -#: ../../builtins/stdtypes.rst:5613 +#: ../../builtins/stdtypes.rst:5924 msgid "Return the number of entries in the dictionary." msgstr "" -#: ../../builtins/stdtypes.rst:5617 +#: ../../builtins/stdtypes.rst:5928 msgid "" "Return an iterator over the keys, values or items (represented as tuples of " "``(key, value)``) in the dictionary." msgstr "" -#: ../../builtins/stdtypes.rst:5620 +#: ../../builtins/stdtypes.rst:5931 msgid "" "Keys and values are iterated over in insertion order. This allows the " "creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = " @@ -8159,39 +8565,39 @@ msgid "" "= [(v, k) for (k, v) in d.items()]``." msgstr "" -#: ../../builtins/stdtypes.rst:5625 +#: ../../builtins/stdtypes.rst:5936 msgid "" "Iterating views while adding or deleting entries in the dictionary may raise " "a :exc:`RuntimeError` or fail to iterate over all entries." msgstr "" -#: ../../builtins/stdtypes.rst:5628 +#: ../../builtins/stdtypes.rst:5939 msgid "Dictionary order is guaranteed to be insertion order." msgstr "" -#: ../../builtins/stdtypes.rst:5633 +#: ../../builtins/stdtypes.rst:5944 msgid "" "Return ``True`` if *x* is in the underlying dictionary's keys, values or " "items (in the latter case, *x* should be a ``(key, value)`` tuple)." msgstr "" -#: ../../builtins/stdtypes.rst:5638 +#: ../../builtins/stdtypes.rst:5949 msgid "" "Return a reverse iterator over the keys, values or items of the dictionary. " "The view will be iterated in reverse order of the insertion." msgstr "" -#: ../../builtins/stdtypes.rst:5641 +#: ../../builtins/stdtypes.rst:5952 msgid "Dictionary views are now reversible." msgstr "" -#: ../../builtins/stdtypes.rst:5646 +#: ../../builtins/stdtypes.rst:5957 msgid "" "Return a :class:`types.MappingProxyType` that wraps the original dictionary " "to which the view refers." msgstr "" -#: ../../builtins/stdtypes.rst:5651 +#: ../../builtins/stdtypes.rst:5962 msgid "" "Keys views are set-like since their entries are unique and :term:`hashable`. " "Items views also have set-like operations since the (key, value) pairs are " @@ -8205,11 +8611,11 @@ msgid "" "input." msgstr "" -#: ../../builtins/stdtypes.rst:5663 +#: ../../builtins/stdtypes.rst:5974 msgid "An example of dictionary view usage::" msgstr "" -#: ../../builtins/stdtypes.rst:5665 +#: ../../builtins/stdtypes.rst:5976 msgid "" ">>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}\n" ">>> keys = dishes.keys()\n" @@ -8287,11 +8693,90 @@ msgstr "" ">>> values.mapping['spam']\n" "500" -#: ../../builtins/stdtypes.rst:5707 +#: ../../builtins/stdtypes.rst:6016 +msgid "Frozen dictionaries" +msgstr "凍結字典" + +#: ../../builtins/stdtypes.rst:6022 +msgid "" +"Return a new frozen dictionary initialized from an optional positional " +"argument and a possibly empty set of keyword arguments." +msgstr "" + +#: ../../builtins/stdtypes.rst:6025 +msgid "" +"A :class:`!frozendict` has a similar API to the :class:`dict` API, with the " +"following differences:" +msgstr "" + +#: ../../builtins/stdtypes.rst:6028 +msgid ":class:`!dict` has more methods than :class:`!frozendict`:" +msgstr "" + +#: ../../builtins/stdtypes.rst:6030 +msgid ":meth:`!__delitem__`" +msgstr ":meth:`!__delitem__`" + +#: ../../builtins/stdtypes.rst:6031 +msgid ":meth:`!__setitem__`" +msgstr ":meth:`!__setitem__`" + +#: ../../builtins/stdtypes.rst:6032 +msgid ":meth:`~dict.clear`" +msgstr ":meth:`~dict.clear`" + +#: ../../builtins/stdtypes.rst:6033 +msgid ":meth:`~dict.pop`" +msgstr ":meth:`~dict.pop`" + +#: ../../builtins/stdtypes.rst:6034 +msgid ":meth:`~dict.popitem`" +msgstr ":meth:`~dict.popitem`" + +#: ../../builtins/stdtypes.rst:6035 +msgid ":meth:`~dict.setdefault`" +msgstr ":meth:`~dict.setdefault`" + +#: ../../builtins/stdtypes.rst:6036 +msgid ":meth:`~dict.update`" +msgstr ":meth:`~dict.update`" + +#: ../../builtins/stdtypes.rst:6038 +msgid "" +"A :class:`!frozendict` can be hashed with ``hash(frozendict)`` if all keys " +"and values can be hashed." +msgstr "" + +#: ../../builtins/stdtypes.rst:6041 +msgid "" +"``frozendict |= other`` does not modify the :class:`!frozendict` in-place " +"but creates a new frozen dictionary." +msgstr "" + +#: ../../builtins/stdtypes.rst:6044 +msgid "" +":class:`!frozendict` is not a :class:`!dict` subclass but inherits directly " +"from ``object``." +msgstr "" + +#: ../../builtins/stdtypes.rst:6047 +msgid "" +"Like dictionaries, frozendicts are :ref:`generic ` over two types, " +"signifying (respectively) the types of the frozendict's keys and values." +msgstr "" + +#: ../../builtins/stdtypes.rst:6052 +msgid "" +"Similar to :meth:`dict.fromkeys`, but call again the type constructor with " +"an initialized :class:`frozendict` if the type is a :class:`frozendict` " +"subclass or if the constructor returned a :class:`frozendict`." +msgstr "" + +#: ../../builtins/stdtypes.rst:6063 msgid "Context Manager Types" msgstr "情境管理器型別" -#: ../../builtins/stdtypes.rst:5714 +#: ../../builtins/stdtypes.rst:6070 msgid "" "Python's :keyword:`with` statement supports the concept of a runtime context " "defined by a context manager. This is implemented using a pair of methods " @@ -8302,7 +8787,7 @@ msgstr "" "要使用兩個方法來實作,該方法讓使用者定義類別能夠去定義 runtime 情境,且該情境" "在執行陳述式主體 (statement body) 之前進入、在陳述式結束時退出:" -#: ../../builtins/stdtypes.rst:5722 +#: ../../builtins/stdtypes.rst:6078 msgid "" "Enter the runtime context and return either this object or another object " "related to the runtime context. The value returned by this method is bound " @@ -8313,7 +8798,7 @@ msgstr "" "的值有被綁定到使用此情境管理器的 :keyword:`with` 陳述式的 :keyword:`!as` 子句" "中的識別字。" -#: ../../builtins/stdtypes.rst:5727 +#: ../../builtins/stdtypes.rst:6083 msgid "" "An example of a context manager that returns itself is a :term:`file " "object`. File objects return themselves from __enter__() to " @@ -8323,7 +8808,7 @@ msgstr "" "一個會回傳自己的情境管理器範例是 :term:`file object`。檔案物件從 __enter__() " "回傳自己,以允許將 :func:`open` 用作 :keyword:`with` 陳述式中的情境運算式。" -#: ../../builtins/stdtypes.rst:5731 +#: ../../builtins/stdtypes.rst:6087 msgid "" "An example of a context manager that returns a related object is the one " "returned by :func:`decimal.localcontext`. These managers set the active " @@ -8337,7 +8822,7 @@ msgstr "" "本。這允許對 :keyword:`with` 陳述式主體中的目前十進位情境進行更改,而不會影" "響 :keyword:`!with` 陳述式外部的程式碼。" -#: ../../builtins/stdtypes.rst:5741 +#: ../../builtins/stdtypes.rst:6097 msgid "" "Exit the runtime context and return a Boolean flag indicating if any " "exception that occurred should be suppressed. If an exception occurred while " @@ -8349,7 +8834,7 @@ msgstr "" "行 :keyword:`with` 陳述式主體時發生例外,則引數包含例外型別、值和回溯 " "(traceback) 資訊。否則,所有三個引數都是 ``None``。" -#: ../../builtins/stdtypes.rst:5746 +#: ../../builtins/stdtypes.rst:6102 msgid "" "Returning a true value from this method will cause the :keyword:`with` " "statement to suppress the exception and continue execution with the " @@ -8360,14 +8845,14 @@ msgstr "" "著 :keyword:`!with` 陳述式之後的陳述式。否則,該例外將在該方法執行完畢後繼續" "傳播 (propagate)。" -#: ../../builtins/stdtypes.rst:5751 +#: ../../builtins/stdtypes.rst:6107 msgid "" "If this method raises an exception while handling an earlier exception from " "the :keyword:`with` block, the new exception is raised, and the original " "exception is stored in its :attr:`~BaseException.__context__` attribute." msgstr "" -#: ../../builtins/stdtypes.rst:5755 +#: ../../builtins/stdtypes.rst:6111 msgid "" "The exception passed in should never be reraised explicitly - instead, this " "method should return a false value to indicate that the method completed " @@ -8379,7 +8864,7 @@ msgstr "" "已成功完成且不希望抑制引發的例外。這讓情境管理程式碼能輕鬆檢" "測 :meth:`~object.__exit__` 方法是否曾實際失敗過。" -#: ../../builtins/stdtypes.rst:5761 +#: ../../builtins/stdtypes.rst:6117 msgid "" "Python defines several context managers to support easy thread " "synchronisation, prompt closure of files or other objects, and simpler " @@ -8391,7 +8876,7 @@ msgstr "" "及對有效十進位算術情境的更簡單操作。除了情境管理協定的實作之外,不會對特定型" "別進行特殊處理。更多範例請參閱 :mod:`contextlib` 模組。" -#: ../../builtins/stdtypes.rst:5767 +#: ../../builtins/stdtypes.rst:6123 msgid "" "Python's :term:`generator`\\s and the :class:`contextlib.contextmanager` " "decorator provide a convenient way to implement these protocols. If a " @@ -8407,7 +8892,7 @@ msgstr "" "的 :meth:`~contextmanager.__enter__` 和 :meth:`~contextmanager.__exit__` 方法" "的情境管理器,而不是由未裝飾產生器函式產生的疊代器。" -#: ../../builtins/stdtypes.rst:5774 +#: ../../builtins/stdtypes.rst:6130 msgid "" "Note that there is no specific slot for any of these methods in the type " "structure for Python objects in the Python/C API. Extension types wanting to " @@ -8419,7 +8904,7 @@ msgstr "" "定義這些方法的擴充型別必須將它們作為普通的 Python 可存取方法提供。與設定 " "runtime 情境的開銷相比,單一類別字典查找的開銷可以忽略不計。" -#: ../../builtins/stdtypes.rst:5782 +#: ../../builtins/stdtypes.rst:6138 msgid "" "Type Annotation Types --- :ref:`Generic Alias `, :ref:`Union `" @@ -8427,7 +8912,7 @@ msgstr "" "型別註釋的型別 --- :ref:`泛型別名 (Generic Alias) `、:ref:`聯合 (Union) `" -#: ../../builtins/stdtypes.rst:5787 +#: ../../builtins/stdtypes.rst:6143 msgid "" "The core built-in types for :term:`type annotations ` " "are :ref:`Generic Alias ` and :ref:`Union `." @@ -8435,11 +8920,11 @@ msgstr "" ":term:`型別註釋 ` 的核心內建型別是\\ :ref:`泛型別名 `\\ 和\\ :ref:`聯合 `。" -#: ../../builtins/stdtypes.rst:5794 +#: ../../builtins/stdtypes.rst:6150 msgid "Generic Alias Type" msgstr "泛型別名型別" -#: ../../builtins/stdtypes.rst:5800 +#: ../../builtins/stdtypes.rst:6156 msgid "" "``GenericAlias`` objects are generally created by :ref:`subscripting " "` a class. They are most often used with :ref:`container " @@ -8455,7 +8940,7 @@ msgstr "" "立的。``GenericAlias`` 物件主要會與\\ :term:`型別註釋 ` 一起使" "用。" -#: ../../builtins/stdtypes.rst:5810 +#: ../../builtins/stdtypes.rst:6166 msgid "" "It is generally only possible to subscript a class if the class implements " "the special method :meth:`~object.__class_getitem__`." @@ -8463,7 +8948,7 @@ msgstr "" "通常只有當類別有實作特殊方法 :meth:`~object.__class_getitem__` 時才可以去下標" "該類別。" -#: ../../builtins/stdtypes.rst:5813 +#: ../../builtins/stdtypes.rst:6169 msgid "" "A ``GenericAlias`` object acts as a proxy for a :term:`generic type`, " "implementing *parameterized generics*." @@ -8471,7 +8956,7 @@ msgstr "" "將一個 ``GenericAlias`` 物件用作 :term:`generic type` 的代理,實作\\ *參數化" "泛型 (parameterized generics)*。" -#: ../../builtins/stdtypes.rst:5816 +#: ../../builtins/stdtypes.rst:6172 msgid "" "For a container class, the argument(s) supplied to a :ref:`subscription " "` of the class may indicate the type(s) of the elements an " @@ -8483,7 +8968,7 @@ msgstr "" "物件所包含元素的型別。例如 ``set[bytes]`` 可以用於型別註釋來表示一" "個 :class:`set`,其中所有元素的型別都是 :class:`bytes`。" -#: ../../builtins/stdtypes.rst:5822 +#: ../../builtins/stdtypes.rst:6178 msgid "" "For a class which defines :meth:`~object.__class_getitem__` but is not a " "container, the argument(s) supplied to a subscription of the class will " @@ -8495,7 +8980,7 @@ msgstr "" "標引數通常會指示物件上有定義的一個或多個方法的回傳型別。例如\\ :mod:`正規表示" "式 `\\ 可以用於 :class:`str` 和 :class:`bytes` 資料型別:" -#: ../../builtins/stdtypes.rst:5828 +#: ../../builtins/stdtypes.rst:6184 msgid "" "If ``x = re.search('foo', 'foo')``, ``x`` will be a :ref:`re.Match ` object where the return values of ``x.group(0)`` and ``x[0]`` will " @@ -8507,7 +8992,7 @@ msgstr "" "別。我們就可以用 ``GenericAlias`` ``re.Match[str]`` 在型別註釋中表示這種物" "件。" -#: ../../builtins/stdtypes.rst:5834 +#: ../../builtins/stdtypes.rst:6190 msgid "" "If ``y = re.search(b'bar', b'bar')``, (note the ``b`` for :class:`bytes`), " "``y`` will also be an instance of ``re.Match``, but the return values of " @@ -8520,7 +9005,7 @@ msgstr "" "別都是 :class:`bytes`。在型別註釋中,我們將用 ``re.Match[bytes]`` 來表示各" "種 :ref:`re.Match ` 物件。" -#: ../../builtins/stdtypes.rst:5840 +#: ../../builtins/stdtypes.rst:6196 msgid "" "``GenericAlias`` objects are instances of the " "class :class:`types.GenericAlias`, which can also be used to create " @@ -8533,7 +9018,7 @@ msgstr "" "classes>`\\ 的特化可能不是 :class:`types.GenericAlias` 的實例,但它們提供類似" "的功能。" -#: ../../builtins/stdtypes.rst:5847 +#: ../../builtins/stdtypes.rst:6203 msgid "" "Creates a ``GenericAlias`` representing a type ``T`` parameterized by types " "*X*, *Y*, and more depending on the ``T`` used. For example, a function " @@ -8543,7 +9028,7 @@ msgstr "" "所使用的 ``T``)來參數化。例如,一個函式需要一個包含 :class:`float` 元素" "的 :class:`list`: ::" -#: ../../builtins/stdtypes.rst:5852 +#: ../../builtins/stdtypes.rst:6208 msgid "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" @@ -8551,7 +9036,7 @@ msgstr "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" -#: ../../builtins/stdtypes.rst:5855 +#: ../../builtins/stdtypes.rst:6211 msgid "" "Another example for :term:`mapping` objects, using a :class:`dict`, which is " "a generic type expecting two type parameters representing the key type and " @@ -8562,7 +9047,7 @@ msgstr "" "別,需要兩個型別參數,分別表示鍵型別和值型別。在此範例中,函式需要一個 " "``dict``,其帶有 :class:`str` 型別的鍵和 :class:`int` 型別的值: ::" -#: ../../builtins/stdtypes.rst:5860 +#: ../../builtins/stdtypes.rst:6216 msgid "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." @@ -8570,7 +9055,7 @@ msgstr "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." -#: ../../builtins/stdtypes.rst:5863 +#: ../../builtins/stdtypes.rst:6219 msgid "" "The builtin functions :func:`isinstance` and :func:`issubclass` do not " "accept ``GenericAlias`` types for their second argument::" @@ -8578,7 +9063,7 @@ msgstr "" "內建函式 :func:`isinstance` 和 :func:`issubclass` 不接受 ``GenericAlias`` 型" "別作為第二個引數: ::" -#: ../../builtins/stdtypes.rst:5866 +#: ../../builtins/stdtypes.rst:6222 msgid "" ">>> isinstance([1, 2], list[str])\n" "Traceback (most recent call last):\n" @@ -8590,7 +9075,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: isinstance() argument 2 cannot be a parameterized generic" -#: ../../builtins/stdtypes.rst:5871 +#: ../../builtins/stdtypes.rst:6227 msgid "" "The Python runtime does not enforce :term:`type annotations `. " "This extends to generic types and their type parameters. When creating a " @@ -8602,7 +9087,7 @@ msgstr "" "及其型別參數。當從 ``GenericAlias`` 建立容器物件時,不會檢查容器中元素的型" "別。例如,不鼓勵使用以下程式碼,但 runtime 不會出現錯誤: ::" -#: ../../builtins/stdtypes.rst:5877 +#: ../../builtins/stdtypes.rst:6233 msgid "" ">>> t = list[str]\n" ">>> t([1, 2, 3])\n" @@ -8612,13 +9097,13 @@ msgstr "" ">>> t([1, 2, 3])\n" "[1, 2, 3]" -#: ../../builtins/stdtypes.rst:5881 +#: ../../builtins/stdtypes.rst:6237 msgid "" "Furthermore, parameterized generics erase type parameters during object " "creation::" msgstr "此外,參數化泛型在物件建立期間會擦除 (erase) 型別參數: ::" -#: ../../builtins/stdtypes.rst:5884 +#: ../../builtins/stdtypes.rst:6240 msgid "" ">>> t = list[str]\n" ">>> type(t)\n" @@ -8636,13 +9121,13 @@ msgstr "" ">>> type(l)\n" "" -#: ../../builtins/stdtypes.rst:5893 +#: ../../builtins/stdtypes.rst:6249 msgid "" "Instances of ``GenericAlias`` are not classes at runtime, even though they " "behave like classes (they can be instantiated and subclassed)::" msgstr "" -#: ../../builtins/stdtypes.rst:5895 +#: ../../builtins/stdtypes.rst:6251 msgid "" ">>> import inspect\n" ">>> inspect.isclass(list[int])\n" @@ -8652,18 +9137,18 @@ msgstr "" ">>> inspect.isclass(list[int])\n" "False" -#: ../../builtins/stdtypes.rst:5899 +#: ../../builtins/stdtypes.rst:6255 msgid "" "This is true for :ref:`user-defined generics ` also." msgstr "這對\\ :ref:`使用者定義泛型 `\\ 也是成立的。" -#: ../../builtins/stdtypes.rst:5901 +#: ../../builtins/stdtypes.rst:6257 msgid "" "Calling :func:`repr` or :func:`str` on a generic shows the parameterized " "type::" msgstr "在泛型上呼叫 :func:`repr` 或 :func:`str` 會顯示參數化型別: ::" -#: ../../builtins/stdtypes.rst:5903 +#: ../../builtins/stdtypes.rst:6259 msgid "" ">>> repr(list[int])\n" "'list[int]'\n" @@ -8677,7 +9162,7 @@ msgstr "" ">>> str(list[int])\n" "'list[int]'" -#: ../../builtins/stdtypes.rst:5909 +#: ../../builtins/stdtypes.rst:6265 msgid "" "The :meth:`~object.__getitem__` method of generic containers will raise an " "exception to disallow mistakes like ``dict[str][str]``::" @@ -8685,7 +9170,7 @@ msgstr "" "為防止像是 ``dict[str][str]`` 的錯誤出現,泛型容器" "的 :meth:`~object.__getitem__` 方法會在這種情況下引發例外: ::" -#: ../../builtins/stdtypes.rst:5912 +#: ../../builtins/stdtypes.rst:6268 msgid "" ">>> dict[str][str]\n" "Traceback (most recent call last):\n" @@ -8697,7 +9182,7 @@ msgstr "" " ...\n" "TypeError: dict[str] is not a generic class" -#: ../../builtins/stdtypes.rst:5917 +#: ../../builtins/stdtypes.rst:6273 msgid "" "However, such expressions are valid when :ref:`type variables ` " "are used. The index must have as many elements as there are type variable " @@ -8707,7 +9192,7 @@ msgstr "" "的。索引的元素數量必須與 ``GenericAlias`` 物件" "的 :attr:`~genericalias.__args__` 中的型別變數項目一樣多: ::" -#: ../../builtins/stdtypes.rst:5921 +#: ../../builtins/stdtypes.rst:6277 msgid "" ">>> from typing import TypeVar\n" ">>> Y = TypeVar('Y')\n" @@ -8719,253 +9204,257 @@ msgstr "" ">>> dict[str, Y][int]\n" "dict[str, int]" -#: ../../builtins/stdtypes.rst:5928 +#: ../../builtins/stdtypes.rst:6284 msgid "Standard Generic Classes" msgstr "標準泛型類別" -#: ../../builtins/stdtypes.rst:5930 +#: ../../builtins/stdtypes.rst:6286 msgid "" "The following standard library classes support parameterized generics. This " "list is non-exhaustive." msgstr "以下標準函式庫類別有支援參數化泛型。此列表並非詳盡無遺。" -#: ../../builtins/stdtypes.rst:5933 +#: ../../builtins/stdtypes.rst:6289 msgid ":class:`tuple`" msgstr ":class:`tuple`" -#: ../../builtins/stdtypes.rst:5934 +#: ../../builtins/stdtypes.rst:6290 msgid ":class:`list`" msgstr ":class:`list`" -#: ../../builtins/stdtypes.rst:5935 +#: ../../builtins/stdtypes.rst:6291 msgid ":class:`dict`" msgstr ":class:`dict`" -#: ../../builtins/stdtypes.rst:5936 +#: ../../builtins/stdtypes.rst:6292 msgid ":class:`set`" msgstr ":class:`set`" -#: ../../builtins/stdtypes.rst:5937 +#: ../../builtins/stdtypes.rst:6293 +msgid ":class:`frozendict`" +msgstr ":class:`frozendict`" + +#: ../../builtins/stdtypes.rst:6294 msgid ":class:`frozenset`" msgstr ":class:`frozenset`" -#: ../../builtins/stdtypes.rst:5938 +#: ../../builtins/stdtypes.rst:6295 msgid ":class:`type`" msgstr ":class:`type`" -#: ../../builtins/stdtypes.rst:5939 +#: ../../builtins/stdtypes.rst:6296 msgid ":class:`asyncio.Future`" msgstr ":class:`asyncio.Future`" -#: ../../builtins/stdtypes.rst:5940 +#: ../../builtins/stdtypes.rst:6297 msgid ":class:`asyncio.Task`" msgstr ":class:`asyncio.Task`" -#: ../../builtins/stdtypes.rst:5941 +#: ../../builtins/stdtypes.rst:6298 msgid ":class:`collections.deque`" msgstr ":class:`collections.deque`" -#: ../../builtins/stdtypes.rst:5942 +#: ../../builtins/stdtypes.rst:6299 msgid ":class:`collections.defaultdict`" msgstr ":class:`collections.defaultdict`" -#: ../../builtins/stdtypes.rst:5943 +#: ../../builtins/stdtypes.rst:6300 msgid ":class:`collections.OrderedDict`" msgstr ":class:`collections.OrderedDict`" -#: ../../builtins/stdtypes.rst:5944 +#: ../../builtins/stdtypes.rst:6301 msgid ":class:`collections.Counter`" msgstr ":class:`collections.Counter`" -#: ../../builtins/stdtypes.rst:5945 +#: ../../builtins/stdtypes.rst:6302 msgid ":class:`collections.ChainMap`" msgstr ":class:`collections.ChainMap`" -#: ../../builtins/stdtypes.rst:5946 +#: ../../builtins/stdtypes.rst:6303 msgid ":class:`collections.abc.Awaitable`" msgstr ":class:`collections.abc.Awaitable`" -#: ../../builtins/stdtypes.rst:5947 +#: ../../builtins/stdtypes.rst:6304 msgid ":class:`collections.abc.Coroutine`" msgstr ":class:`collections.abc.Coroutine`" -#: ../../builtins/stdtypes.rst:5948 +#: ../../builtins/stdtypes.rst:6305 msgid ":class:`collections.abc.AsyncIterable`" msgstr ":class:`collections.abc.AsyncIterable`" -#: ../../builtins/stdtypes.rst:5949 +#: ../../builtins/stdtypes.rst:6306 msgid ":class:`collections.abc.AsyncIterator`" msgstr ":class:`collections.abc.AsyncIterator`" -#: ../../builtins/stdtypes.rst:5950 +#: ../../builtins/stdtypes.rst:6307 msgid ":class:`collections.abc.AsyncGenerator`" msgstr ":class:`collections.abc.AsyncGenerator`" -#: ../../builtins/stdtypes.rst:5951 +#: ../../builtins/stdtypes.rst:6308 msgid ":class:`collections.abc.Iterable`" msgstr ":class:`collections.abc.Iterable`" -#: ../../builtins/stdtypes.rst:5952 +#: ../../builtins/stdtypes.rst:6309 msgid ":class:`collections.abc.Iterator`" msgstr ":class:`collections.abc.Iterator`" -#: ../../builtins/stdtypes.rst:5953 +#: ../../builtins/stdtypes.rst:6310 msgid ":class:`collections.abc.Generator`" msgstr ":class:`collections.abc.Generator`" -#: ../../builtins/stdtypes.rst:5954 +#: ../../builtins/stdtypes.rst:6311 msgid ":class:`collections.abc.Reversible`" msgstr ":class:`collections.abc.Reversible`" -#: ../../builtins/stdtypes.rst:5955 +#: ../../builtins/stdtypes.rst:6312 msgid ":class:`collections.abc.Container`" msgstr ":class:`collections.abc.Container`" -#: ../../builtins/stdtypes.rst:5956 +#: ../../builtins/stdtypes.rst:6313 msgid ":class:`collections.abc.Collection`" msgstr ":class:`collections.abc.Collection`" -#: ../../builtins/stdtypes.rst:5957 +#: ../../builtins/stdtypes.rst:6314 msgid ":class:`collections.abc.Callable`" msgstr ":class:`collections.abc.Callable`" -#: ../../builtins/stdtypes.rst:5958 +#: ../../builtins/stdtypes.rst:6315 msgid ":class:`collections.abc.Set`" msgstr ":class:`collections.abc.Set`" -#: ../../builtins/stdtypes.rst:5959 +#: ../../builtins/stdtypes.rst:6316 msgid ":class:`collections.abc.MutableSet`" msgstr ":class:`collections.abc.MutableSet`" -#: ../../builtins/stdtypes.rst:5960 +#: ../../builtins/stdtypes.rst:6317 msgid ":class:`collections.abc.Mapping`" msgstr ":class:`collections.abc.Mapping`" -#: ../../builtins/stdtypes.rst:5961 +#: ../../builtins/stdtypes.rst:6318 msgid ":class:`collections.abc.MutableMapping`" msgstr ":class:`collections.abc.MutableMapping`" -#: ../../builtins/stdtypes.rst:5962 +#: ../../builtins/stdtypes.rst:6319 msgid ":class:`collections.abc.Sequence`" msgstr ":class:`collections.abc.Sequence`" -#: ../../builtins/stdtypes.rst:5963 +#: ../../builtins/stdtypes.rst:6320 msgid ":class:`collections.abc.MutableSequence`" msgstr ":class:`collections.abc.MutableSequence`" -#: ../../builtins/stdtypes.rst:5964 +#: ../../builtins/stdtypes.rst:6321 msgid ":class:`collections.abc.ByteString`" msgstr ":class:`collections.abc.ByteString`" -#: ../../builtins/stdtypes.rst:5965 +#: ../../builtins/stdtypes.rst:6322 msgid ":class:`collections.abc.MappingView`" msgstr ":class:`collections.abc.MappingView`" -#: ../../builtins/stdtypes.rst:5966 +#: ../../builtins/stdtypes.rst:6323 msgid ":class:`collections.abc.KeysView`" msgstr ":class:`collections.abc.KeysView`" -#: ../../builtins/stdtypes.rst:5967 +#: ../../builtins/stdtypes.rst:6324 msgid ":class:`collections.abc.ItemsView`" msgstr ":class:`collections.abc.ItemsView`" -#: ../../builtins/stdtypes.rst:5968 +#: ../../builtins/stdtypes.rst:6325 msgid ":class:`collections.abc.ValuesView`" msgstr ":class:`collections.abc.ValuesView`" -#: ../../builtins/stdtypes.rst:5969 +#: ../../builtins/stdtypes.rst:6326 msgid ":class:`contextlib.AbstractContextManager`" msgstr ":class:`contextlib.AbstractContextManager`" -#: ../../builtins/stdtypes.rst:5970 +#: ../../builtins/stdtypes.rst:6327 msgid ":class:`contextlib.AbstractAsyncContextManager`" msgstr ":class:`contextlib.AbstractAsyncContextManager`" -#: ../../builtins/stdtypes.rst:5971 +#: ../../builtins/stdtypes.rst:6328 msgid ":class:`dataclasses.Field`" msgstr ":class:`dataclasses.Field`" -#: ../../builtins/stdtypes.rst:5972 +#: ../../builtins/stdtypes.rst:6329 msgid ":class:`functools.cached_property`" msgstr ":class:`functools.cached_property`" -#: ../../builtins/stdtypes.rst:5973 +#: ../../builtins/stdtypes.rst:6330 msgid ":class:`functools.partialmethod`" msgstr ":class:`functools.partialmethod`" -#: ../../builtins/stdtypes.rst:5974 +#: ../../builtins/stdtypes.rst:6331 msgid ":class:`os.PathLike`" msgstr ":class:`os.PathLike`" -#: ../../builtins/stdtypes.rst:5975 +#: ../../builtins/stdtypes.rst:6332 msgid ":class:`queue.LifoQueue`" msgstr ":class:`queue.LifoQueue`" -#: ../../builtins/stdtypes.rst:5976 +#: ../../builtins/stdtypes.rst:6333 msgid ":class:`queue.Queue`" msgstr ":class:`queue.Queue`" -#: ../../builtins/stdtypes.rst:5977 +#: ../../builtins/stdtypes.rst:6334 msgid ":class:`queue.PriorityQueue`" msgstr ":class:`queue.PriorityQueue`" -#: ../../builtins/stdtypes.rst:5978 +#: ../../builtins/stdtypes.rst:6335 msgid ":class:`queue.SimpleQueue`" msgstr ":class:`queue.SimpleQueue`" -#: ../../builtins/stdtypes.rst:5979 +#: ../../builtins/stdtypes.rst:6336 msgid ":ref:`re.Pattern `" msgstr ":ref:`re.Pattern `" -#: ../../builtins/stdtypes.rst:5980 +#: ../../builtins/stdtypes.rst:6337 msgid ":ref:`re.Match `" msgstr ":ref:`re.Match `" -#: ../../builtins/stdtypes.rst:5981 +#: ../../builtins/stdtypes.rst:6338 msgid ":class:`shelve.BsdDbShelf`" msgstr ":class:`shelve.BsdDbShelf`" -#: ../../builtins/stdtypes.rst:5982 +#: ../../builtins/stdtypes.rst:6339 msgid ":class:`shelve.DbfilenameShelf`" msgstr ":class:`shelve.DbfilenameShelf`" -#: ../../builtins/stdtypes.rst:5983 +#: ../../builtins/stdtypes.rst:6340 msgid ":class:`shelve.Shelf`" msgstr ":class:`shelve.Shelf`" -#: ../../builtins/stdtypes.rst:5984 +#: ../../builtins/stdtypes.rst:6341 msgid ":class:`types.MappingProxyType`" msgstr ":class:`types.MappingProxyType`" -#: ../../builtins/stdtypes.rst:5985 +#: ../../builtins/stdtypes.rst:6342 msgid ":class:`weakref.WeakKeyDictionary`" msgstr ":class:`weakref.WeakKeyDictionary`" -#: ../../builtins/stdtypes.rst:5986 +#: ../../builtins/stdtypes.rst:6343 msgid ":class:`weakref.WeakMethod`" msgstr ":class:`weakref.WeakMethod`" -#: ../../builtins/stdtypes.rst:5987 +#: ../../builtins/stdtypes.rst:6344 msgid ":class:`weakref.WeakSet`" msgstr ":class:`weakref.WeakSet`" -#: ../../builtins/stdtypes.rst:5988 +#: ../../builtins/stdtypes.rst:6345 msgid ":class:`weakref.WeakValueDictionary`" msgstr ":class:`weakref.WeakValueDictionary`" -#: ../../builtins/stdtypes.rst:5993 +#: ../../builtins/stdtypes.rst:6350 msgid "Special Attributes of ``GenericAlias`` objects" msgstr "``GenericAlias`` 物件的特殊屬性" -#: ../../builtins/stdtypes.rst:5995 +#: ../../builtins/stdtypes.rst:6352 msgid "All parameterized generics implement special read-only attributes." msgstr "所有參數化泛型都有實作特殊的唯讀屬性。" -#: ../../builtins/stdtypes.rst:5999 +#: ../../builtins/stdtypes.rst:6356 msgid "This attribute points at the non-parameterized generic class::" msgstr "此屬性指向非參數化泛型類別: ::" -#: ../../builtins/stdtypes.rst:6001 +#: ../../builtins/stdtypes.rst:6358 msgid "" ">>> list[int].__origin__\n" "" @@ -8973,7 +9462,7 @@ msgstr "" ">>> list[int].__origin__\n" "" -#: ../../builtins/stdtypes.rst:6007 +#: ../../builtins/stdtypes.rst:6364 msgid "" "This attribute is a :class:`tuple` (possibly of length 1) of generic types " "passed to the original :meth:`~object.__class_getitem__` of the generic " @@ -8982,7 +9471,7 @@ msgstr "" "此屬性是傳遞給泛型類別之原始 :meth:`~object.__class_getitem__` 的泛型型" "別 :class:`tuple`\\ (長度可以為 1): ::" -#: ../../builtins/stdtypes.rst:6011 +#: ../../builtins/stdtypes.rst:6368 msgid "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" @@ -8990,7 +9479,7 @@ msgstr "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" -#: ../../builtins/stdtypes.rst:6017 +#: ../../builtins/stdtypes.rst:6374 msgid "" "This attribute is a lazily computed tuple (possibly empty) of unique type " "variables found in ``__args__``::" @@ -8998,7 +9487,7 @@ msgstr "" "此屬性是個會被延遲計算 (lazily computed) 的元組(可能為空),包含了在 " "``__args__`` 中找得到的不重複型別變數: ::" -#: ../../builtins/stdtypes.rst:6020 +#: ../../builtins/stdtypes.rst:6377 msgid "" ">>> from typing import TypeVar\n" "\n" @@ -9012,7 +9501,7 @@ msgstr "" ">>> list[T].__parameters__\n" "(~T,)" -#: ../../builtins/stdtypes.rst:6028 +#: ../../builtins/stdtypes.rst:6385 msgid "" "A ``GenericAlias`` object with :class:`typing.ParamSpec` parameters may not " "have correct ``__parameters__`` after substitution " @@ -9023,7 +9512,7 @@ msgstr "" "有正確的 ``__parameters__``,因為 :class:`typing.ParamSpec` 主要用於靜態型別" "檢查。" -#: ../../builtins/stdtypes.rst:6035 +#: ../../builtins/stdtypes.rst:6392 msgid "" "A boolean that is true if the alias has been unpacked using the ``*`` " "operator (see :data:`~typing.TypeVarTuple`)." @@ -9031,19 +9520,19 @@ msgstr "" "如果別名已使用 ``*`` 運算子解包 (unpack) 則為 true 的布林值(請參" "閱 :data:`~typing.TypeVarTuple`\\ )。" -#: ../../builtins/stdtypes.rst:6043 +#: ../../builtins/stdtypes.rst:6400 msgid ":pep:`484` - Type Hints" msgstr ":pep:`484` - 型別提示" -#: ../../builtins/stdtypes.rst:6044 +#: ../../builtins/stdtypes.rst:6401 msgid "Introducing Python's framework for type annotations." msgstr "引入 Python 的型別註釋框架。" -#: ../../builtins/stdtypes.rst:6046 +#: ../../builtins/stdtypes.rst:6403 msgid ":pep:`585` - Type Hinting Generics In Standard Collections" msgstr ":pep:`585` - 標準集合 (Standard Collections) 中的型別提示泛型" -#: ../../builtins/stdtypes.rst:6047 +#: ../../builtins/stdtypes.rst:6404 msgid "" "Introducing the ability to natively parameterize standard-library classes, " "provided they implement the special class " @@ -9052,7 +9541,7 @@ msgstr "" "引入原生參數化標準函式庫類別的能力,前提是它們有實作特殊的類別方" "法 :meth:`~object.__class_getitem__`。" -#: ../../builtins/stdtypes.rst:6051 +#: ../../builtins/stdtypes.rst:6408 msgid "" ":ref:`Generics`, :ref:`user-defined generics ` " "and :class:`typing.Generic`" @@ -9060,18 +9549,18 @@ msgstr "" ":ref:`Generics`、:ref:`使用者定義泛型 `\\ " "和 :class:`typing.Generic`" -#: ../../builtins/stdtypes.rst:6052 +#: ../../builtins/stdtypes.rst:6409 msgid "" "Documentation on how to implement generic classes that can be parameterized " "at runtime and understood by static type-checkers." msgstr "" "有關如何實作可以在 runtime 參數化並能被靜態型別檢查器理解的泛型類別的文件。" -#: ../../builtins/stdtypes.rst:6061 +#: ../../builtins/stdtypes.rst:6418 msgid "Union Type" msgstr "聯合型別 (Union Type)" -#: ../../builtins/stdtypes.rst:6067 +#: ../../builtins/stdtypes.rst:6424 msgid "" "A union object holds the value of the ``|`` (bitwise or) operation on " "multiple :ref:`type objects `. These types are intended " @@ -9084,7 +9573,7 @@ msgstr "" "釋 (type annotation) `。與下標 :class:`typing.Union` 相比,聯合型" "別運算式可以讓型別提示語法更清晰簡潔。" -#: ../../builtins/stdtypes.rst:6074 +#: ../../builtins/stdtypes.rst:6431 msgid "" "Defines a union object which holds types *X*, *Y*, and so forth. ``X | Y`` " "means either X or Y. It is equivalent to ``typing.Union[X, Y]``. For " @@ -9095,7 +9584,7 @@ msgstr "" "``typing.Union[X, Y]``。舉例來說,下列函式需要一個型別為 :class:`int` " "或 :class:`float` 的引數: ::" -#: ../../builtins/stdtypes.rst:6079 +#: ../../builtins/stdtypes.rst:6436 msgid "" "def square(number: int | float) -> int | float:\n" " return number ** 2" @@ -9103,7 +9592,7 @@ msgstr "" "def square(number: int | float) -> int | float:\n" " return number ** 2" -#: ../../builtins/stdtypes.rst:6084 +#: ../../builtins/stdtypes.rst:6441 msgid "" "The ``|`` operator cannot be used at runtime to define unions where one or " "more members is a forward reference. For example, ``int | \"Foo\"``, where " @@ -9112,40 +9601,40 @@ msgid "" "a string, e.g. ``\"int | Foo\"``." msgstr "" -#: ../../builtins/stdtypes.rst:6092 +#: ../../builtins/stdtypes.rst:6449 msgid "" "Union objects can be tested for equality with other union objects. Details:" msgstr "聯合物件可以與其他聯合物件一起進行相等性測試。細節如下:" -#: ../../builtins/stdtypes.rst:6094 +#: ../../builtins/stdtypes.rst:6451 msgid "Unions of unions are flattened::" msgstr "聯合的聯合會被扁平化: ::" -#: ../../builtins/stdtypes.rst:6096 +#: ../../builtins/stdtypes.rst:6453 msgid "(int | str) | float == int | str | float" msgstr "(int | str) | float == int | str | float" -#: ../../builtins/stdtypes.rst:6098 +#: ../../builtins/stdtypes.rst:6455 msgid "Redundant types are removed::" msgstr "冗餘型別會被刪除: ::" -#: ../../builtins/stdtypes.rst:6100 +#: ../../builtins/stdtypes.rst:6457 msgid "int | str | int == int | str" msgstr "int | str | int == int | str" -#: ../../builtins/stdtypes.rst:6102 +#: ../../builtins/stdtypes.rst:6459 msgid "When comparing unions, the order is ignored::" msgstr "比較聯合時,順序會被忽略: ::" -#: ../../builtins/stdtypes.rst:6104 +#: ../../builtins/stdtypes.rst:6461 msgid "int | str == str | int" msgstr "int | str == str | int" -#: ../../builtins/stdtypes.rst:6106 +#: ../../builtins/stdtypes.rst:6463 msgid "It creates instances of :class:`typing.Union`::" msgstr "它會建立 :class:`typing.Union` 的實例: ::" -#: ../../builtins/stdtypes.rst:6108 +#: ../../builtins/stdtypes.rst:6465 msgid "" "int | str == typing.Union[int, str]\n" "type(int | str) is typing.Union" @@ -9153,21 +9642,21 @@ msgstr "" "int | str == typing.Union[int, str]\n" "type(int | str) is typing.Union" -#: ../../builtins/stdtypes.rst:6111 +#: ../../builtins/stdtypes.rst:6468 msgid "Optional types can be spelled as a union with ``None``::" msgstr "可選型別可以表示為與 ``None`` 的聯合: ::" -#: ../../builtins/stdtypes.rst:6113 +#: ../../builtins/stdtypes.rst:6470 msgid "str | None == typing.Optional[str]" msgstr "str | None == typing.Optional[str]" -#: ../../builtins/stdtypes.rst:6118 +#: ../../builtins/stdtypes.rst:6475 msgid "" "Calls to :func:`isinstance` and :func:`issubclass` are also supported with a " "union object::" msgstr "聯合物件也支援 :func:`isinstance` 和 :func:`issubclass` 的呼叫: ::" -#: ../../builtins/stdtypes.rst:6121 +#: ../../builtins/stdtypes.rst:6478 msgid "" ">>> isinstance(\"\", int | str)\n" "True" @@ -9175,14 +9664,14 @@ msgstr "" ">>> isinstance(\"\", int | str)\n" "True" -#: ../../builtins/stdtypes.rst:6124 +#: ../../builtins/stdtypes.rst:6481 msgid "" "However, :ref:`parameterized generics ` in union objects " "cannot be checked::" msgstr "" "然而聯合物件中的\\ :ref:`參數化泛型 `\\ 則無法被檢查: ::" -#: ../../builtins/stdtypes.rst:6127 +#: ../../builtins/stdtypes.rst:6484 msgid "" ">>> isinstance(1, int | list[int]) # short-circuit evaluation\n" "True\n" @@ -9198,7 +9687,7 @@ msgstr "" " ...\n" "TypeError: isinstance() argument 2 cannot be a parameterized generic" -#: ../../builtins/stdtypes.rst:6134 +#: ../../builtins/stdtypes.rst:6491 msgid "" "The user-exposed type for the union object can be accessed " "from :class:`typing.Union` and used for :func:`isinstance` checks::" @@ -9206,7 +9695,7 @@ msgstr "" "構成聯合物件的對使用者公開型別 (user-exposed type) 可以透" "過 :class:`typing.Union` 存取並用於 :func:`isinstance` 檢查: ::" -#: ../../builtins/stdtypes.rst:6137 +#: ../../builtins/stdtypes.rst:6494 msgid "" ">>> import typing\n" ">>> isinstance(int | str, typing.Union)\n" @@ -9224,7 +9713,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: cannot create 'typing.Union' instances" -#: ../../builtins/stdtypes.rst:6146 +#: ../../builtins/stdtypes.rst:6503 msgid "" "The :meth:`!__or__` method for type objects was added to support the syntax " "``X | Y``. If a metaclass implements :meth:`!__or__`, the Union may " @@ -9233,7 +9722,7 @@ msgstr "" "新增了型別物件的 :meth:`!__or__` 方法來支援 ``X | Y`` 語法。如果元類別有實" "作 :meth:`!__or__`,則 Union 可以覆寫 (override) 它: ::" -#: ../../builtins/stdtypes.rst:6150 +#: ../../builtins/stdtypes.rst:6507 msgid "" ">>> class M(type):\n" "... def __or__(self, other):\n" @@ -9259,32 +9748,32 @@ msgstr "" ">>> int | C\n" "int | C" -#: ../../builtins/stdtypes.rst:6166 +#: ../../builtins/stdtypes.rst:6523 msgid ":pep:`604` -- PEP proposing the ``X | Y`` syntax and the Union type." msgstr ":pep:`604` -- PEP 提出 ``X | Y`` 語法和聯合型別。" -#: ../../builtins/stdtypes.rst:6172 +#: ../../builtins/stdtypes.rst:6529 msgid "" "Union objects are now instances of :class:`typing.Union`. Previously, they " "were instances of :class:`types.UnionType`, which remains an alias " "for :class:`typing.Union`." msgstr "" -#: ../../builtins/stdtypes.rst:6179 +#: ../../builtins/stdtypes.rst:6536 msgid "Other Built-in Types" msgstr "其他內建型別" -#: ../../builtins/stdtypes.rst:6181 +#: ../../builtins/stdtypes.rst:6538 msgid "" "The interpreter supports several other kinds of objects. Most of these " "support only one or two operations." msgstr "" -#: ../../builtins/stdtypes.rst:6188 +#: ../../builtins/stdtypes.rst:6545 msgid "Modules" msgstr "模組" -#: ../../builtins/stdtypes.rst:6190 +#: ../../builtins/stdtypes.rst:6547 msgid "" "The only special operation on a module is attribute access: ``m.name``, " "where *m* is a module and *name* accesses a name defined in *m*'s symbol " @@ -9295,7 +9784,7 @@ msgid "" "*foo* somewhere.)" msgstr "" -#: ../../builtins/stdtypes.rst:6197 +#: ../../builtins/stdtypes.rst:6554 msgid "" "A special attribute of every module is :attr:`~object.__dict__`. This is the " "dictionary containing the module's symbol table. Modifying this dictionary " @@ -9306,32 +9795,32 @@ msgid "" "not recommended." msgstr "" -#: ../../builtins/stdtypes.rst:6205 +#: ../../builtins/stdtypes.rst:6562 msgid "" "Modules built into the interpreter are written like this: ````. If loaded from a file, they are written as ````." msgstr "" -#: ../../builtins/stdtypes.rst:6213 +#: ../../builtins/stdtypes.rst:6570 msgid "Classes and Class Instances" msgstr "類別與類別實例" -#: ../../builtins/stdtypes.rst:6215 +#: ../../builtins/stdtypes.rst:6572 msgid "See :ref:`objects` and :ref:`class` for these." msgstr "請見 :ref:`objects` 和 :ref:`class`。" -#: ../../builtins/stdtypes.rst:6221 +#: ../../builtins/stdtypes.rst:6578 msgid "Functions" msgstr "函式" -#: ../../builtins/stdtypes.rst:6223 +#: ../../builtins/stdtypes.rst:6580 msgid "" "Function objects are created by function definitions. The only operation on " "a function object is to call it: ``func(argument-list)``." msgstr "" -#: ../../builtins/stdtypes.rst:6226 +#: ../../builtins/stdtypes.rst:6583 msgid "" "There are really two flavors of function objects: built-in functions and " "user-defined functions. Both support the same operation (to call the " @@ -9339,15 +9828,15 @@ msgid "" "types." msgstr "" -#: ../../builtins/stdtypes.rst:6230 +#: ../../builtins/stdtypes.rst:6587 msgid "See :ref:`function` for more information." msgstr "更多資訊請見 :ref:`function`。" -#: ../../builtins/stdtypes.rst:6236 +#: ../../builtins/stdtypes.rst:6593 msgid "Methods" msgstr "方法" -#: ../../builtins/stdtypes.rst:6240 +#: ../../builtins/stdtypes.rst:6597 msgid "" "Methods are functions that are called using the attribute notation. There " "are two flavors: :ref:`built-in methods ` (such " @@ -9355,7 +9844,7 @@ msgid "" "methods>`. Built-in methods are described with the types that support them." msgstr "" -#: ../../builtins/stdtypes.rst:6246 +#: ../../builtins/stdtypes.rst:6603 msgid "" "If you access a method (a function defined in a class namespace) through an " "instance, you get a special object: a :dfn:`bound method` (also " @@ -9368,7 +9857,7 @@ msgid "" "``m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)``." msgstr "" -#: ../../builtins/stdtypes.rst:6257 +#: ../../builtins/stdtypes.rst:6614 msgid "" "Like :ref:`function objects `, bound method objects " "support getting arbitrary attributes. However, since method attributes are " @@ -9379,7 +9868,7 @@ msgid "" "underlying function object:" msgstr "" -#: ../../builtins/stdtypes.rst:6265 +#: ../../builtins/stdtypes.rst:6622 msgid "" ">>> class C:\n" "... def method(self):\n" @@ -9407,15 +9896,15 @@ msgstr "" ">>> c.method.whoami\n" "'my name is method'" -#: ../../builtins/stdtypes.rst:6280 +#: ../../builtins/stdtypes.rst:6637 msgid "See :ref:`instance-methods` for more information." msgstr "更多資訊請見 :ref:`instance-methods`。" -#: ../../builtins/stdtypes.rst:6288 +#: ../../builtins/stdtypes.rst:6645 msgid "Code Objects" msgstr "程式碼物件" -#: ../../builtins/stdtypes.rst:6294 +#: ../../builtins/stdtypes.rst:6651 msgid "" "Code objects are used by the implementation to represent \"pseudo-compiled\" " "executable Python code such as a function body. They differ from function " @@ -9425,7 +9914,7 @@ msgid "" "their :attr:`~function.__code__` attribute. See also the :mod:`code` module." msgstr "" -#: ../../builtins/stdtypes.rst:6301 +#: ../../builtins/stdtypes.rst:6658 msgid "" "Accessing :attr:`~function.__code__` raises an :ref:`auditing event " "` ``object.__getattr__`` with arguments ``obj`` and " @@ -9434,21 +9923,21 @@ msgstr "" "存取 :attr:`~function.__code__` 會引發一個附帶引數 ``obj`` 與 " "``\"__code__\"`` 的\\ :ref:`稽核事件 ` ``object.__getattr__``。" -#: ../../builtins/stdtypes.rst:6308 +#: ../../builtins/stdtypes.rst:6665 msgid "" "A code object can be executed or evaluated by passing it (instead of a " "source string) to the :func:`exec` or :func:`eval` built-in functions." msgstr "" -#: ../../builtins/stdtypes.rst:6311 +#: ../../builtins/stdtypes.rst:6668 msgid "See :ref:`types` for more information." msgstr "更多資訊請見 :ref:`types`。" -#: ../../builtins/stdtypes.rst:6317 +#: ../../builtins/stdtypes.rst:6674 msgid "Type Objects" msgstr "" -#: ../../builtins/stdtypes.rst:6323 +#: ../../builtins/stdtypes.rst:6680 msgid "" "Type objects represent the various object types. An object's type is " "accessed by the built-in function :func:`type`. There are no special " @@ -9456,30 +9945,30 @@ msgid "" "standard built-in types." msgstr "" -#: ../../builtins/stdtypes.rst:6328 +#: ../../builtins/stdtypes.rst:6685 msgid "Types are written like this: ````." msgstr "" -#: ../../builtins/stdtypes.rst:6334 +#: ../../builtins/stdtypes.rst:6691 msgid "The Null Object" msgstr "Null 物件" -#: ../../builtins/stdtypes.rst:6336 +#: ../../builtins/stdtypes.rst:6693 msgid "" "This object is returned by functions that don't explicitly return a value. " "It supports no special operations. There is exactly one null object, named " "``None`` (a built-in name). ``type(None)()`` produces the same singleton." msgstr "" -#: ../../builtins/stdtypes.rst:6340 +#: ../../builtins/stdtypes.rst:6697 msgid "It is written as ``None``." msgstr "它被寫為 ``None``。" -#: ../../builtins/stdtypes.rst:6347 +#: ../../builtins/stdtypes.rst:6704 msgid "The Ellipsis Object" msgstr "Ellipsis 物件" -#: ../../builtins/stdtypes.rst:6349 +#: ../../builtins/stdtypes.rst:6706 msgid "" "This object is commonly used to indicate that something is omitted. It " "supports no special operations. There is exactly one ellipsis object, " @@ -9487,63 +9976,63 @@ msgid "" "the :const:`Ellipsis` singleton." msgstr "" -#: ../../builtins/stdtypes.rst:6354 +#: ../../builtins/stdtypes.rst:6711 msgid "It is written as ``Ellipsis`` or ``...``." msgstr "它被寫為 ``Ellipsis`` 或 ``...``。" -#: ../../builtins/stdtypes.rst:6356 +#: ../../builtins/stdtypes.rst:6713 msgid "" "In typical use, ``...`` as the ``Ellipsis`` object appears in a few " "different places, for instance:" msgstr "" -#: ../../builtins/stdtypes.rst:6359 +#: ../../builtins/stdtypes.rst:6716 msgid "" "In type annotations, such as :ref:`callable arguments ` or :ref:`tuple elements `." msgstr "" -#: ../../builtins/stdtypes.rst:6362 +#: ../../builtins/stdtypes.rst:6719 msgid "" "As the body of a function instead of a :ref:`pass statement `." msgstr "" -#: ../../builtins/stdtypes.rst:6364 +#: ../../builtins/stdtypes.rst:6721 msgid "" "In third-party libraries, such as `Numpy's slicing and striding `_." msgstr "" -#: ../../builtins/stdtypes.rst:6367 +#: ../../builtins/stdtypes.rst:6724 msgid "" "Python also uses three dots in ways that are not ``Ellipsis`` objects, for " "instance:" msgstr "" -#: ../../builtins/stdtypes.rst:6369 +#: ../../builtins/stdtypes.rst:6726 msgid "" "Doctest's :const:`ELLIPSIS `, as a pattern for missing " "content." msgstr "" -#: ../../builtins/stdtypes.rst:6371 +#: ../../builtins/stdtypes.rst:6728 msgid "" "The default Python prompt of the :term:`interactive` shell when partial " "input is incomplete." msgstr "" -#: ../../builtins/stdtypes.rst:6373 +#: ../../builtins/stdtypes.rst:6730 msgid "" "Lastly, the Python documentation often uses three dots in conventional " "English usage to mean omitted content, even in code examples that also use " "them as the ``Ellipsis``." msgstr "" -#: ../../builtins/stdtypes.rst:6381 +#: ../../builtins/stdtypes.rst:6738 msgid "The NotImplemented Object" msgstr "NotImplemented 物件" -#: ../../builtins/stdtypes.rst:6383 +#: ../../builtins/stdtypes.rst:6740 msgid "" "This object is returned from comparisons and binary operations when they are " "asked to operate on types they don't support. See :ref:`comparisons` for " @@ -9551,64 +10040,64 @@ msgid "" "object. :code:`type(NotImplemented)()` produces the singleton instance." msgstr "" -#: ../../builtins/stdtypes.rst:6388 +#: ../../builtins/stdtypes.rst:6745 msgid "It is written as :code:`NotImplemented`." msgstr "它被寫為 :code:`NotImplemented`。" -#: ../../builtins/stdtypes.rst:6394 +#: ../../builtins/stdtypes.rst:6751 msgid "Internal Objects" msgstr "內部物件" -#: ../../builtins/stdtypes.rst:6396 +#: ../../builtins/stdtypes.rst:6753 msgid "" "See :ref:`types` for this information. It describes :ref:`stack frame " "objects `, :ref:`traceback objects `, and " "slice objects." msgstr "" -#: ../../builtins/stdtypes.rst:6404 +#: ../../builtins/stdtypes.rst:6761 msgid "Special Attributes" msgstr "特殊屬性" -#: ../../builtins/stdtypes.rst:6406 +#: ../../builtins/stdtypes.rst:6763 msgid "" "The implementation adds a few special read-only attributes to several object " "types, where they are relevant. Some of these are not reported by " "the :func:`dir` built-in function." msgstr "" -#: ../../builtins/stdtypes.rst:6413 +#: ../../builtins/stdtypes.rst:6770 msgid "" "The name of the class, function, method, descriptor, or generator instance." msgstr "" -#: ../../builtins/stdtypes.rst:6419 +#: ../../builtins/stdtypes.rst:6776 msgid "" "The :term:`qualified name` of the class, function, method, descriptor, or " "generator instance." msgstr "" -#: ../../builtins/stdtypes.rst:6427 +#: ../../builtins/stdtypes.rst:6784 msgid "The name of the module in which a class or function was defined." msgstr "" -#: ../../builtins/stdtypes.rst:6432 +#: ../../builtins/stdtypes.rst:6789 msgid "" "The documentation string of a class or function, or ``None`` if undefined." msgstr "" -#: ../../builtins/stdtypes.rst:6437 +#: ../../builtins/stdtypes.rst:6794 msgid "" "The :ref:`type parameters ` of generic classes, functions, " "and :ref:`type aliases `. For classes and functions that are " "not generic, this will be an empty tuple." msgstr "" -#: ../../builtins/stdtypes.rst:6447 +#: ../../builtins/stdtypes.rst:6804 msgid "Integer string conversion length limitation" msgstr "整數字串轉換長度限制" -#: ../../builtins/stdtypes.rst:6449 +#: ../../builtins/stdtypes.rst:6806 msgid "" "CPython has a global limit for converting between :class:`int` " "and :class:`str` to mitigate denial of service attacks. This limit *only* " @@ -9620,7 +10109,7 @@ msgstr "" "進位的數值。十六進位、八進位,還有二進位的轉換則沒有長度限制。此限制值可以被" "調整。" -#: ../../builtins/stdtypes.rst:6454 +#: ../../builtins/stdtypes.rst:6811 msgid "" "The :class:`int` type in CPython is an arbitrary length number stored in " "binary form (commonly known as a \"bignum\"). There exists no algorithm that " @@ -9630,24 +10119,24 @@ msgid "" "value such as ``int('1' * 500_000)`` can take over a second on a fast CPU." msgstr "" -#: ../../builtins/stdtypes.rst:6461 +#: ../../builtins/stdtypes.rst:6818 msgid "" "Limiting conversion size offers a practical way to avoid :cve:`2020-10735`." msgstr "" -#: ../../builtins/stdtypes.rst:6463 +#: ../../builtins/stdtypes.rst:6820 msgid "" "The limit is applied to the number of digit characters in the input or " "output string when a non-linear conversion algorithm would be involved. " "Underscores and the sign are not counted towards the limit." msgstr "" -#: ../../builtins/stdtypes.rst:6467 +#: ../../builtins/stdtypes.rst:6824 msgid "" "When an operation would exceed the limit, a :exc:`ValueError` is raised:" msgstr "" -#: ../../builtins/stdtypes.rst:6469 +#: ../../builtins/stdtypes.rst:6826 msgid "" ">>> import sys\n" ">>> sys.set_int_max_str_digits(4300) # Illustrative, this is the default.\n" @@ -9671,7 +10160,7 @@ msgid "" ">>> assert int(hex(i_squared), base=16) == i*i # Hexadecimal is unlimited." msgstr "" -#: ../../builtins/stdtypes.rst:6489 +#: ../../builtins/stdtypes.rst:6846 msgid "" "The default limit is 4300 digits as provided " "in :data:`sys.int_info.default_max_str_digits `. The lowest " @@ -9679,11 +10168,11 @@ msgid "" "in :data:`sys.int_info.str_digits_check_threshold `." msgstr "" -#: ../../builtins/stdtypes.rst:6494 +#: ../../builtins/stdtypes.rst:6851 msgid "Verification:" msgstr "" -#: ../../builtins/stdtypes.rst:6496 +#: ../../builtins/stdtypes.rst:6853 msgid "" ">>> import sys\n" ">>> assert sys.int_info.default_max_str_digits == 4300, sys.int_info\n" @@ -9701,11 +10190,11 @@ msgstr "" "... '571186405732').to_bytes(53, 'big')\n" "..." -#: ../../builtins/stdtypes.rst:6509 +#: ../../builtins/stdtypes.rst:6866 msgid "Affected APIs" msgstr "受影響的 API" -#: ../../builtins/stdtypes.rst:6511 +#: ../../builtins/stdtypes.rst:6868 msgid "" "The limitation only applies to potentially slow conversions " "between :class:`int` and :class:`str` or :class:`bytes`:" @@ -9713,74 +10202,74 @@ msgstr "" "此限制僅適用於 :class:`int` 與 :class:`str` 或 :class:`bytes` 之間可能較慢的" "轉換:" -#: ../../builtins/stdtypes.rst:6514 +#: ../../builtins/stdtypes.rst:6871 msgid "``int(string)`` with default base 10." msgstr "``int(string)`` 以預設的 10 為底。" -#: ../../builtins/stdtypes.rst:6515 +#: ../../builtins/stdtypes.rst:6872 msgid "``int(string, base)`` for all bases that are not a power of 2." msgstr "``int(string, base)`` 用於所有非 2 冪次方的底。" -#: ../../builtins/stdtypes.rst:6516 +#: ../../builtins/stdtypes.rst:6873 msgid "``str(integer)``." msgstr "``str(integer)``。" -#: ../../builtins/stdtypes.rst:6517 +#: ../../builtins/stdtypes.rst:6874 msgid "``repr(integer)``." msgstr "``repr(integer)``。" -#: ../../builtins/stdtypes.rst:6518 +#: ../../builtins/stdtypes.rst:6875 msgid "" "any other string conversion to base 10, for example ``f\"{integer}\"``, " "``\"{}\".format(integer)``, or ``b\"%d\" % integer``." msgstr "" -#: ../../builtins/stdtypes.rst:6521 +#: ../../builtins/stdtypes.rst:6878 msgid "The limitations do not apply to functions with a linear algorithm:" msgstr "" -#: ../../builtins/stdtypes.rst:6523 +#: ../../builtins/stdtypes.rst:6880 msgid "``int(string, base)`` with base 2, 4, 8, 16, or 32." msgstr "``int(string, base)`` 以 2、4、8、16 或 32 為底。" -#: ../../builtins/stdtypes.rst:6524 +#: ../../builtins/stdtypes.rst:6881 msgid ":func:`int.from_bytes` and :func:`int.to_bytes`." msgstr ":func:`int.from_bytes` 和 :func:`int.to_bytes`。" -#: ../../builtins/stdtypes.rst:6525 +#: ../../builtins/stdtypes.rst:6882 msgid ":func:`hex`, :func:`oct`, :func:`bin`." msgstr ":func:`hex`、:func:`oct`、:func:`bin`。" -#: ../../builtins/stdtypes.rst:6526 +#: ../../builtins/stdtypes.rst:6883 msgid ":ref:`formatspec` for hex, octal, and binary numbers." msgstr ":ref:`formatspec` 用於十六進位、八進位和二進位數字。" -#: ../../builtins/stdtypes.rst:6527 +#: ../../builtins/stdtypes.rst:6884 msgid ":class:`str` to :class:`float`." msgstr ":class:`str` 轉換為 :class:`float`。" -#: ../../builtins/stdtypes.rst:6528 +#: ../../builtins/stdtypes.rst:6885 msgid ":class:`str` to :class:`decimal.Decimal`." msgstr ":class:`str` 轉換為 :class:`decimal.Decimal`。" -#: ../../builtins/stdtypes.rst:6531 +#: ../../builtins/stdtypes.rst:6888 msgid "Configuring the limit" msgstr "設定限制" -#: ../../builtins/stdtypes.rst:6533 +#: ../../builtins/stdtypes.rst:6890 msgid "" "Before Python starts up you can use an environment variable or an " "interpreter command line flag to configure the limit:" msgstr "" -#: ../../builtins/stdtypes.rst:6536 +#: ../../builtins/stdtypes.rst:6893 msgid "" ":envvar:`PYTHONINTMAXSTRDIGITS`, e.g. ``PYTHONINTMAXSTRDIGITS=640 python3`` " "to set the limit to 640 or ``PYTHONINTMAXSTRDIGITS=0 python3`` to disable " "the limitation." msgstr "" -#: ../../builtins/stdtypes.rst:6539 +#: ../../builtins/stdtypes.rst:6896 msgid "" ":option:`-X int_max_str_digits <-X>`, e.g. ``python3 -X " "int_max_str_digits=640``" @@ -9788,7 +10277,7 @@ msgstr "" ":option:`-X int_max_str_digits <-X>`,例如 ``python3 -X " "int_max_str_digits=640``" -#: ../../builtins/stdtypes.rst:6541 +#: ../../builtins/stdtypes.rst:6898 msgid "" ":data:`sys.flags.int_max_str_digits` contains the value " "of :envvar:`PYTHONINTMAXSTRDIGITS` or :option:`-X int_max_str_digits <-X>`. " @@ -9798,38 +10287,38 @@ msgid "" "initialization." msgstr "" -#: ../../builtins/stdtypes.rst:6547 +#: ../../builtins/stdtypes.rst:6904 msgid "" "From code, you can inspect the current limit and set a new one using " "these :mod:`sys` APIs:" msgstr "" -#: ../../builtins/stdtypes.rst:6550 +#: ../../builtins/stdtypes.rst:6907 msgid "" ":func:`sys.get_int_max_str_digits` and :func:`sys.set_int_max_str_digits` " "are a getter and setter for the interpreter-wide limit. Subinterpreters have " "their own limit." msgstr "" -#: ../../builtins/stdtypes.rst:6554 +#: ../../builtins/stdtypes.rst:6911 msgid "" "Information about the default and minimum can be found " "in :data:`sys.int_info`:" msgstr "" -#: ../../builtins/stdtypes.rst:6556 +#: ../../builtins/stdtypes.rst:6913 msgid "" ":data:`sys.int_info.default_max_str_digits ` is the compiled-" "in default limit." msgstr "" -#: ../../builtins/stdtypes.rst:6558 +#: ../../builtins/stdtypes.rst:6915 msgid "" ":data:`sys.int_info.str_digits_check_threshold ` is the lowest " "accepted value for the limit (other than 0 which disables it)." msgstr "" -#: ../../builtins/stdtypes.rst:6565 +#: ../../builtins/stdtypes.rst:6922 msgid "" "Setting a low limit *can* lead to problems. While rare, code exists that " "contains integer constants in decimal in their source that exceed the " @@ -9841,7 +10330,7 @@ msgid "" "constants is to convert them to ``0x`` hexadecimal form as it has no limit." msgstr "" -#: ../../builtins/stdtypes.rst:6574 +#: ../../builtins/stdtypes.rst:6931 msgid "" "Test your application thoroughly if you use a low limit. Ensure your tests " "run with the limit set early via the environment or flag so that it applies " @@ -9849,11 +10338,11 @@ msgid "" "to precompile ``.py`` sources to ``.pyc`` files." msgstr "" -#: ../../builtins/stdtypes.rst:6580 +#: ../../builtins/stdtypes.rst:6937 msgid "Recommended configuration" msgstr "建議的配置" -#: ../../builtins/stdtypes.rst:6582 +#: ../../builtins/stdtypes.rst:6939 msgid "" "The default :data:`sys.int_info.default_max_str_digits` is expected to be " "reasonable for most applications. If your application requires a different " @@ -9861,11 +10350,11 @@ msgid "" "as these APIs were added in security patch releases in versions before 3.12." msgstr "" -#: ../../builtins/stdtypes.rst:6587 +#: ../../builtins/stdtypes.rst:6944 msgid "Example::" msgstr "範例: ::" -#: ../../builtins/stdtypes.rst:6589 +#: ../../builtins/stdtypes.rst:6946 msgid "" ">>> import sys\n" ">>> if hasattr(sys, \"set_int_max_str_digits\"):\n" @@ -9887,38 +10376,38 @@ msgstr "" "... elif current_limit < lower_bound:\n" "... sys.set_int_max_str_digits(lower_bound)" -#: ../../builtins/stdtypes.rst:6599 +#: ../../builtins/stdtypes.rst:6956 msgid "If you need to disable it entirely, set it to ``0``." msgstr "" -#: ../../builtins/stdtypes.rst:6603 +#: ../../builtins/stdtypes.rst:6960 msgid "Footnotes" msgstr "註腳" -#: ../../builtins/stdtypes.rst:6604 +#: ../../builtins/stdtypes.rst:6961 msgid "" "Additional information on these special methods may be found in the Python " "Reference Manual (:ref:`customization`)." msgstr "" -#: ../../builtins/stdtypes.rst:6607 +#: ../../builtins/stdtypes.rst:6964 msgid "" "As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0]``, " "and similarly for tuples." msgstr "" -#: ../../builtins/stdtypes.rst:6610 +#: ../../builtins/stdtypes.rst:6967 msgid "They must have since the parser can't tell the type of the operands." msgstr "" -#: ../../builtins/stdtypes.rst:6612 +#: ../../builtins/stdtypes.rst:6969 msgid "" "Cased characters are those with general category property being one of " "\"Lu\" (Letter, uppercase), \"Ll\" (Letter, lowercase), or \"Lt\" (Letter, " "titlecase)." msgstr "" -#: ../../builtins/stdtypes.rst:6615 +#: ../../builtins/stdtypes.rst:6972 msgid "" "To format only a tuple you should therefore provide a singleton tuple whose " "only element is the tuple to be formatted." @@ -9929,15 +10418,15 @@ msgid "built-in" msgstr "built-in(內建)" #: ../../builtins/stdtypes.rst:13 ../../builtins/stdtypes.rst:332 -#: ../../builtins/stdtypes.rst:409 ../../builtins/stdtypes.rst:1005 -#: ../../builtins/stdtypes.rst:1197 ../../builtins/stdtypes.rst:1219 -#: ../../builtins/stdtypes.rst:1234 ../../builtins/stdtypes.rst:5302 -#: ../../builtins/stdtypes.rst:6319 +#: ../../builtins/stdtypes.rst:409 ../../builtins/stdtypes.rst:1276 +#: ../../builtins/stdtypes.rst:1468 ../../builtins/stdtypes.rst:1490 +#: ../../builtins/stdtypes.rst:1505 ../../builtins/stdtypes.rst:5613 +#: ../../builtins/stdtypes.rst:6676 msgid "types" msgstr "type(型別)" -#: ../../builtins/stdtypes.rst:34 ../../builtins/stdtypes.rst:1234 -#: ../../builtins/stdtypes.rst:5302 +#: ../../builtins/stdtypes.rst:34 ../../builtins/stdtypes.rst:1505 +#: ../../builtins/stdtypes.rst:5613 msgid "statement" msgstr "statement(陳述式)" @@ -9986,7 +10475,7 @@ msgstr "False(內建物件)" #: ../../builtins/stdtypes.rst:66 ../../builtins/stdtypes.rst:100 #: ../../builtins/stdtypes.rst:125 ../../builtins/stdtypes.rst:197 #: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:409 -#: ../../builtins/stdtypes.rst:1005 +#: ../../builtins/stdtypes.rst:1276 msgid "operator" msgstr "operator(運算子)" @@ -10055,15 +10544,16 @@ msgid "is not" msgstr "is not" #: ../../builtins/stdtypes.rst:165 ../../builtins/stdtypes.rst:210 -#: ../../builtins/stdtypes.rst:986 ../../builtins/stdtypes.rst:1197 -#: ../../builtins/stdtypes.rst:1219 ../../builtins/stdtypes.rst:1384 -#: ../../builtins/stdtypes.rst:1470 ../../builtins/stdtypes.rst:1518 -#: ../../builtins/stdtypes.rst:1639 ../../builtins/stdtypes.rst:1773 -#: ../../builtins/stdtypes.rst:3299 ../../builtins/stdtypes.rst:3318 -#: ../../builtins/stdtypes.rst:3431 ../../builtins/stdtypes.rst:5083 -#: ../../builtins/stdtypes.rst:5302 ../../builtins/stdtypes.rst:5796 -#: ../../builtins/stdtypes.rst:6063 ../../builtins/stdtypes.rst:6238 -#: ../../builtins/stdtypes.rst:6283 +#: ../../builtins/stdtypes.rst:1019 ../../builtins/stdtypes.rst:1129 +#: ../../builtins/stdtypes.rst:1257 ../../builtins/stdtypes.rst:1468 +#: ../../builtins/stdtypes.rst:1490 ../../builtins/stdtypes.rst:1655 +#: ../../builtins/stdtypes.rst:1741 ../../builtins/stdtypes.rst:1789 +#: ../../builtins/stdtypes.rst:1910 ../../builtins/stdtypes.rst:2044 +#: ../../builtins/stdtypes.rst:3582 ../../builtins/stdtypes.rst:3601 +#: ../../builtins/stdtypes.rst:3714 ../../builtins/stdtypes.rst:5394 +#: ../../builtins/stdtypes.rst:5613 ../../builtins/stdtypes.rst:6152 +#: ../../builtins/stdtypes.rst:6420 ../../builtins/stdtypes.rst:6595 +#: ../../builtins/stdtypes.rst:6640 msgid "object" msgstr "object(物件)" @@ -10105,11 +10595,11 @@ msgstr "__gt__()(實例方法)" msgid "__ge__() (instance method)" msgstr "__ge__()(實例方法)" -#: ../../builtins/stdtypes.rst:197 ../../builtins/stdtypes.rst:1005 +#: ../../builtins/stdtypes.rst:197 ../../builtins/stdtypes.rst:1276 msgid "in" msgstr "in" -#: ../../builtins/stdtypes.rst:197 ../../builtins/stdtypes.rst:1005 +#: ../../builtins/stdtypes.rst:197 ../../builtins/stdtypes.rst:1276 msgid "not in" msgstr "not in" @@ -10154,10 +10644,10 @@ msgstr "binary(二進位)" msgid "arithmetic" msgstr "arithmetic(算術)" -#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:1005 -#: ../../builtins/stdtypes.rst:1197 ../../builtins/stdtypes.rst:5302 -#: ../../builtins/stdtypes.rst:6290 ../../builtins/stdtypes.rst:6304 -#: ../../builtins/stdtypes.rst:6319 +#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:1276 +#: ../../builtins/stdtypes.rst:1468 ../../builtins/stdtypes.rst:5613 +#: ../../builtins/stdtypes.rst:6647 ../../builtins/stdtypes.rst:6661 +#: ../../builtins/stdtypes.rst:6676 msgid "built-in function" msgstr "built-in function(內建函式)" @@ -10173,8 +10663,8 @@ msgstr "float" msgid "complex" msgstr "complex(複數)" -#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3171 -#: ../../builtins/stdtypes.rst:4445 +#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3454 +#: ../../builtins/stdtypes.rst:4756 msgid "+ (plus)" msgstr "+ (加號)" @@ -10186,13 +10676,13 @@ msgstr "unary operator(一元運算子)" msgid "binary operator" msgstr "binary operator(二元運算子)" -#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3171 -#: ../../builtins/stdtypes.rst:4445 +#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3454 +#: ../../builtins/stdtypes.rst:4756 msgid "- (minus)" msgstr "- (減號)" -#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3128 -#: ../../builtins/stdtypes.rst:4402 +#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3411 +#: ../../builtins/stdtypes.rst:4713 msgid "* (asterisk)" msgstr "* (星號)" @@ -10204,8 +10694,8 @@ msgstr "/ (斜線)" msgid "//" msgstr "//" -#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3091 -#: ../../builtins/stdtypes.rst:4370 +#: ../../builtins/stdtypes.rst:251 ../../builtins/stdtypes.rst:3374 +#: ../../builtins/stdtypes.rst:4681 msgid "% (percent)" msgstr "% (百分號)" @@ -10214,8 +10704,8 @@ msgid "**" msgstr "**" #: ../../builtins/stdtypes.rst:332 ../../builtins/stdtypes.rst:409 -#: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:1234 -#: ../../builtins/stdtypes.rst:5302 +#: ../../builtins/stdtypes.rst:1276 ../../builtins/stdtypes.rst:1505 +#: ../../builtins/stdtypes.rst:5613 msgid "operations on" msgstr "operations on(操作於)" @@ -10223,8 +10713,8 @@ msgstr "operations on(操作於)" msgid "conjugate() (complex number method)" msgstr "conjugate()(複數方法)" -#: ../../builtins/stdtypes.rst:351 ../../builtins/stdtypes.rst:1841 -#: ../../builtins/stdtypes.rst:3299 ../../builtins/stdtypes.rst:6319 +#: ../../builtins/stdtypes.rst:351 ../../builtins/stdtypes.rst:2112 +#: ../../builtins/stdtypes.rst:3582 ../../builtins/stdtypes.rst:6676 msgid "module" msgstr "模組" @@ -10288,402 +10778,427 @@ msgstr "~ (波浪號)" msgid "values" msgstr "values" -#: ../../builtins/stdtypes.rst:899 +#: ../../builtins/stdtypes.rst:901 msgid "iterator protocol" msgstr "iterator protocol(疊代器協定)" -#: ../../builtins/stdtypes.rst:899 ../../builtins/stdtypes.rst:5709 +#: ../../builtins/stdtypes.rst:901 ../../builtins/stdtypes.rst:6065 msgid "protocol" msgstr "protocol(協定)" -#: ../../builtins/stdtypes.rst:899 +#: ../../builtins/stdtypes.rst:901 msgid "iterator" msgstr "iterator(疊代器)" -#: ../../builtins/stdtypes.rst:899 ../../builtins/stdtypes.rst:986 -#: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:1197 -#: ../../builtins/stdtypes.rst:1219 ../../builtins/stdtypes.rst:1234 +#: ../../builtins/stdtypes.rst:901 ../../builtins/stdtypes.rst:1257 +#: ../../builtins/stdtypes.rst:1276 ../../builtins/stdtypes.rst:1468 +#: ../../builtins/stdtypes.rst:1490 ../../builtins/stdtypes.rst:1505 msgid "sequence" msgstr "sequence(序列)" -#: ../../builtins/stdtypes.rst:899 +#: ../../builtins/stdtypes.rst:901 msgid "iteration" msgstr "iteration(疊代)" -#: ../../builtins/stdtypes.rst:899 +#: ../../builtins/stdtypes.rst:901 msgid "container" msgstr "container(容器)" -#: ../../builtins/stdtypes.rst:899 +#: ../../builtins/stdtypes.rst:901 msgid "iteration over" msgstr "iteration over(疊代於)" -#: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:5302 +#: ../../builtins/stdtypes.rst:1019 +msgid "generator" +msgstr "generator(產生器)" + +#: ../../builtins/stdtypes.rst:1029 ../../builtins/stdtypes.rst:1098 +#: ../../builtins/stdtypes.rst:1139 ../../builtins/stdtypes.rst:1216 +msgid "exception" +msgstr "exception(例外)" + +#: ../../builtins/stdtypes.rst:1029 +msgid "StopIteration" +msgstr "StopIteration" + +#: ../../builtins/stdtypes.rst:1098 ../../builtins/stdtypes.rst:1216 +msgid "GeneratorExit" +msgstr "GeneratorExit" + +#: ../../builtins/stdtypes.rst:1129 +msgid "asynchronous-generator" +msgstr "asynchronous-generator(非同步產生器)" + +#: ../../builtins/stdtypes.rst:1139 +msgid "StopAsyncIteration" +msgstr "StopAsyncIteration" + +#: ../../builtins/stdtypes.rst:1276 ../../builtins/stdtypes.rst:5613 msgid "len" msgstr "len" -#: ../../builtins/stdtypes.rst:1005 +#: ../../builtins/stdtypes.rst:1276 msgid "min" msgstr "min" -#: ../../builtins/stdtypes.rst:1005 +#: ../../builtins/stdtypes.rst:1276 msgid "max" msgstr "max" -#: ../../builtins/stdtypes.rst:1005 +#: ../../builtins/stdtypes.rst:1276 msgid "concatenation" msgstr "concatenation(串接)" -#: ../../builtins/stdtypes.rst:1005 +#: ../../builtins/stdtypes.rst:1276 msgid "operation" msgstr "operation(操作)" -#: ../../builtins/stdtypes.rst:1005 +#: ../../builtins/stdtypes.rst:1276 msgid "repetition" msgstr "repetition(重複)" -#: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:1234 +#: ../../builtins/stdtypes.rst:1276 ../../builtins/stdtypes.rst:1505 msgid "subscript" msgstr "subscript(下標)" -#: ../../builtins/stdtypes.rst:1005 ../../builtins/stdtypes.rst:1234 +#: ../../builtins/stdtypes.rst:1276 ../../builtins/stdtypes.rst:1505 msgid "slice" msgstr "slice(切片)" -#: ../../builtins/stdtypes.rst:1052 +#: ../../builtins/stdtypes.rst:1323 msgid "loop" msgstr "loop(迴圈)" -#: ../../builtins/stdtypes.rst:1052 +#: ../../builtins/stdtypes.rst:1323 msgid "over mutable sequence" msgstr "over mutable sequence(於可變序列)" -#: ../../builtins/stdtypes.rst:1052 +#: ../../builtins/stdtypes.rst:1323 msgid "mutable sequence" msgstr "mutable sequence(可變序列)" -#: ../../builtins/stdtypes.rst:1052 +#: ../../builtins/stdtypes.rst:1323 msgid "loop over" msgstr "loop over(迴圈)" -#: ../../builtins/stdtypes.rst:1197 +#: ../../builtins/stdtypes.rst:1468 msgid "immutable" msgstr "immutable(不可變)" -#: ../../builtins/stdtypes.rst:1197 ../../builtins/stdtypes.rst:1470 +#: ../../builtins/stdtypes.rst:1468 ../../builtins/stdtypes.rst:1741 msgid "tuple" msgstr "tuple(元組)" -#: ../../builtins/stdtypes.rst:1197 +#: ../../builtins/stdtypes.rst:1468 msgid "hash" msgstr "hash(雜湊)" -#: ../../builtins/stdtypes.rst:1219 +#: ../../builtins/stdtypes.rst:1490 msgid "mutable" msgstr "mutable(可變)" -#: ../../builtins/stdtypes.rst:1219 ../../builtins/stdtypes.rst:1234 -#: ../../builtins/stdtypes.rst:1384 +#: ../../builtins/stdtypes.rst:1490 ../../builtins/stdtypes.rst:1505 +#: ../../builtins/stdtypes.rst:1655 msgid "list" msgstr "list(串列)" -#: ../../builtins/stdtypes.rst:1219 ../../builtins/stdtypes.rst:3299 -#: ../../builtins/stdtypes.rst:3431 ../../builtins/stdtypes.rst:3546 -#: ../../builtins/stdtypes.rst:4370 +#: ../../builtins/stdtypes.rst:1490 ../../builtins/stdtypes.rst:3582 +#: ../../builtins/stdtypes.rst:3714 ../../builtins/stdtypes.rst:3853 +#: ../../builtins/stdtypes.rst:4681 msgid "bytearray" msgstr "bytearray(位元組陣列)" -#: ../../builtins/stdtypes.rst:1234 ../../builtins/stdtypes.rst:5302 -#: ../../builtins/stdtypes.rst:6063 ../../builtins/stdtypes.rst:6319 +#: ../../builtins/stdtypes.rst:1505 ../../builtins/stdtypes.rst:5613 +#: ../../builtins/stdtypes.rst:6420 ../../builtins/stdtypes.rst:6676 msgid "type" msgstr "type(型別)" -#: ../../builtins/stdtypes.rst:1234 +#: ../../builtins/stdtypes.rst:1505 msgid "assignment" msgstr "assignment(賦值)" -#: ../../builtins/stdtypes.rst:1234 ../../builtins/stdtypes.rst:5302 +#: ../../builtins/stdtypes.rst:1505 ../../builtins/stdtypes.rst:5613 msgid "del" msgstr "del" -#: ../../builtins/stdtypes.rst:1518 +#: ../../builtins/stdtypes.rst:1789 msgid "range" msgstr "range" -#: ../../builtins/stdtypes.rst:1639 ../../builtins/stdtypes.rst:1786 -#: ../../builtins/stdtypes.rst:1833 ../../builtins/stdtypes.rst:2919 -#: ../../builtins/stdtypes.rst:3091 +#: ../../builtins/stdtypes.rst:1910 ../../builtins/stdtypes.rst:2057 +#: ../../builtins/stdtypes.rst:2104 ../../builtins/stdtypes.rst:3202 +#: ../../builtins/stdtypes.rst:3374 msgid "string" msgstr "string(字串)" -#: ../../builtins/stdtypes.rst:1639 +#: ../../builtins/stdtypes.rst:1910 msgid "text sequence type" msgstr "text sequence type(文字序列型別)" -#: ../../builtins/stdtypes.rst:1639 ../../builtins/stdtypes.rst:1786 -#: ../../builtins/stdtypes.rst:1806 +#: ../../builtins/stdtypes.rst:1910 ../../builtins/stdtypes.rst:2057 +#: ../../builtins/stdtypes.rst:2077 msgid "str (built-in class)" msgstr "str(內建類別)" -#: ../../builtins/stdtypes.rst:1639 +#: ../../builtins/stdtypes.rst:1910 msgid "(see also string)" msgstr "(亦請見 string)" -#: ../../builtins/stdtypes.rst:1773 +#: ../../builtins/stdtypes.rst:2044 msgid "io.StringIO" msgstr "io.StringIO" -#: ../../builtins/stdtypes.rst:1806 ../../builtins/stdtypes.rst:3291 +#: ../../builtins/stdtypes.rst:2077 ../../builtins/stdtypes.rst:3574 msgid "buffer protocol" msgstr "buffer protocol(緩衝區協定)" -#: ../../builtins/stdtypes.rst:1806 ../../builtins/stdtypes.rst:3299 -#: ../../builtins/stdtypes.rst:3318 ../../builtins/stdtypes.rst:3546 -#: ../../builtins/stdtypes.rst:4370 +#: ../../builtins/stdtypes.rst:2077 ../../builtins/stdtypes.rst:3582 +#: ../../builtins/stdtypes.rst:3601 ../../builtins/stdtypes.rst:3853 +#: ../../builtins/stdtypes.rst:4681 msgid "bytes" msgstr "bytes(位元組)" -#: ../../builtins/stdtypes.rst:1833 ../../builtins/stdtypes.rst:3546 +#: ../../builtins/stdtypes.rst:2104 ../../builtins/stdtypes.rst:3853 msgid "methods" msgstr "methods(方法)" -#: ../../builtins/stdtypes.rst:1841 +#: ../../builtins/stdtypes.rst:2112 msgid "re" msgstr "re" -#: ../../builtins/stdtypes.rst:2689 ../../builtins/stdtypes.rst:4224 +#: ../../builtins/stdtypes.rst:2964 ../../builtins/stdtypes.rst:4535 msgid "universal newlines" msgstr "universal newlines" -#: ../../builtins/stdtypes.rst:2689 +#: ../../builtins/stdtypes.rst:2964 msgid "str.splitlines method" msgstr "str.splitlines 方法" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "! formatted string literal" msgstr "! formatted string literals(! 格式化字串常數)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "formatted string literals" msgstr "formatted string literals(格式化字串常數)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "! f-string" msgstr "! f-string(! f 字串)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "f-strings" msgstr "f-string(f 字串)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "fstring" msgstr "fstring(f 字串)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "interpolated string literal" msgstr "interpolated string literal(插值字串常數)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "formatted literal" msgstr "formatted literal(格式化常數)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "interpolated literal" msgstr "interpolated literal(插值常數)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "{} (curly brackets)" msgstr "{} (花括號)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "in formatted string literal" msgstr "於格式化字串常數中" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "! (exclamation mark)" msgstr "! (驚嘆號)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid ": (colon)" msgstr ": (冒號)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "= (equals)" msgstr "= (等號)" -#: ../../builtins/stdtypes.rst:2919 +#: ../../builtins/stdtypes.rst:3202 msgid "for help in debugging using string literals" msgstr "" -#: ../../builtins/stdtypes.rst:3091 +#: ../../builtins/stdtypes.rst:3374 msgid "formatting, string (%)" msgstr "formatting(格式化)、字串 (%)" -#: ../../builtins/stdtypes.rst:3091 +#: ../../builtins/stdtypes.rst:3374 msgid "interpolation, string (%)" msgstr "interpolation(插值)、字串 (%)" -#: ../../builtins/stdtypes.rst:3091 +#: ../../builtins/stdtypes.rst:3374 msgid "formatting, printf" msgstr "formatting(格式化)、printf" -#: ../../builtins/stdtypes.rst:3091 +#: ../../builtins/stdtypes.rst:3374 msgid "interpolation, printf" msgstr "interpolation(插值)、printf" -#: ../../builtins/stdtypes.rst:3091 ../../builtins/stdtypes.rst:4370 +#: ../../builtins/stdtypes.rst:3374 ../../builtins/stdtypes.rst:4681 msgid "printf-style formatting" msgstr "printf 風格格式化" -#: ../../builtins/stdtypes.rst:3091 ../../builtins/stdtypes.rst:4370 +#: ../../builtins/stdtypes.rst:3374 ../../builtins/stdtypes.rst:4681 msgid "sprintf-style formatting" msgstr "sprintf 風格格式化" -#: ../../builtins/stdtypes.rst:3128 ../../builtins/stdtypes.rst:4402 +#: ../../builtins/stdtypes.rst:3411 ../../builtins/stdtypes.rst:4713 msgid "() (parentheses)" msgstr "() (圓括號)" -#: ../../builtins/stdtypes.rst:3128 ../../builtins/stdtypes.rst:3171 -#: ../../builtins/stdtypes.rst:4402 ../../builtins/stdtypes.rst:4445 +#: ../../builtins/stdtypes.rst:3411 ../../builtins/stdtypes.rst:3454 +#: ../../builtins/stdtypes.rst:4713 ../../builtins/stdtypes.rst:4756 msgid "in printf-style formatting" msgstr "於 printf 風格格式化" -#: ../../builtins/stdtypes.rst:3128 ../../builtins/stdtypes.rst:4402 +#: ../../builtins/stdtypes.rst:3411 ../../builtins/stdtypes.rst:4713 msgid ". (dot)" msgstr ". (點)" -#: ../../builtins/stdtypes.rst:3171 ../../builtins/stdtypes.rst:4445 +#: ../../builtins/stdtypes.rst:3454 ../../builtins/stdtypes.rst:4756 msgid "# (hash)" msgstr "# (井字號)" -#: ../../builtins/stdtypes.rst:3171 ../../builtins/stdtypes.rst:4445 +#: ../../builtins/stdtypes.rst:3454 ../../builtins/stdtypes.rst:4756 msgid "space" msgstr "space(空白)" -#: ../../builtins/stdtypes.rst:3291 +#: ../../builtins/stdtypes.rst:3574 msgid "binary sequence types" msgstr "binary sequence types(二進位序列型別)" -#: ../../builtins/stdtypes.rst:3299 +#: ../../builtins/stdtypes.rst:3582 msgid "memoryview" msgstr "memoryview(記憶體視圖)" -#: ../../builtins/stdtypes.rst:3299 +#: ../../builtins/stdtypes.rst:3582 msgid "array" msgstr "array(陣列)" -#: ../../builtins/stdtypes.rst:4224 +#: ../../builtins/stdtypes.rst:4535 msgid "bytes.splitlines method" msgstr "bytes.splitlines 方法" -#: ../../builtins/stdtypes.rst:4224 +#: ../../builtins/stdtypes.rst:4535 msgid "bytearray.splitlines method" msgstr "bytearray.splitlines 方法" -#: ../../builtins/stdtypes.rst:4370 +#: ../../builtins/stdtypes.rst:4681 msgid "formatting" msgstr "formatting(格式化)" -#: ../../builtins/stdtypes.rst:4370 +#: ../../builtins/stdtypes.rst:4681 msgid "bytes (%)" msgstr "bytes (%)" -#: ../../builtins/stdtypes.rst:4370 +#: ../../builtins/stdtypes.rst:4681 msgid "bytearray (%)" msgstr "bytearray (%)" -#: ../../builtins/stdtypes.rst:4370 +#: ../../builtins/stdtypes.rst:4681 msgid "interpolation" msgstr "interpolation(插值)" -#: ../../builtins/stdtypes.rst:5083 +#: ../../builtins/stdtypes.rst:5394 msgid "set" msgstr "set(集合)" -#: ../../builtins/stdtypes.rst:5302 +#: ../../builtins/stdtypes.rst:5613 msgid "mapping" msgstr "mapping(對映)" -#: ../../builtins/stdtypes.rst:5302 +#: ../../builtins/stdtypes.rst:5613 msgid "dictionary" msgstr "dictionary(字典)" -#: ../../builtins/stdtypes.rst:5414 +#: ../../builtins/stdtypes.rst:5726 msgid "__missing__()" msgstr "__missing__()" -#: ../../builtins/stdtypes.rst:5709 +#: ../../builtins/stdtypes.rst:6065 msgid "context manager" msgstr "context manager(情境管理器)" -#: ../../builtins/stdtypes.rst:5709 +#: ../../builtins/stdtypes.rst:6065 msgid "context management protocol" msgstr "context management protocol(情境管理協定)" -#: ../../builtins/stdtypes.rst:5709 +#: ../../builtins/stdtypes.rst:6065 msgid "context management" msgstr "context management(情境管理)" -#: ../../builtins/stdtypes.rst:5784 +#: ../../builtins/stdtypes.rst:6140 msgid "annotation" msgstr "annotation(註記)" -#: ../../builtins/stdtypes.rst:5784 +#: ../../builtins/stdtypes.rst:6140 msgid "type annotation; type hint" msgstr "type annotation(型別註記);type hint(型別提示)" -#: ../../builtins/stdtypes.rst:5796 +#: ../../builtins/stdtypes.rst:6152 msgid "GenericAlias" msgstr "GenericAlias(泛型別名)" -#: ../../builtins/stdtypes.rst:5796 +#: ../../builtins/stdtypes.rst:6152 msgid "Generic" msgstr "Generic(泛型)" -#: ../../builtins/stdtypes.rst:5796 +#: ../../builtins/stdtypes.rst:6152 msgid "Alias" msgstr "Alias(別名)" -#: ../../builtins/stdtypes.rst:6063 +#: ../../builtins/stdtypes.rst:6420 msgid "Union" msgstr "Union(聯合)" -#: ../../builtins/stdtypes.rst:6063 +#: ../../builtins/stdtypes.rst:6420 msgid "union" msgstr "union(聯集)" -#: ../../builtins/stdtypes.rst:6238 +#: ../../builtins/stdtypes.rst:6595 msgid "method" msgstr "method(方法)" -#: ../../builtins/stdtypes.rst:6283 +#: ../../builtins/stdtypes.rst:6640 msgid "code" msgstr "code(程式碼)" -#: ../../builtins/stdtypes.rst:6283 +#: ../../builtins/stdtypes.rst:6640 msgid "code object" msgstr "code object(程式碼物件)" -#: ../../builtins/stdtypes.rst:6290 +#: ../../builtins/stdtypes.rst:6647 msgid "compile" msgstr "compile(編譯)" -#: ../../builtins/stdtypes.rst:6290 +#: ../../builtins/stdtypes.rst:6647 msgid "__code__ (function object attribute)" msgstr "__code__(函式物件屬性)" -#: ../../builtins/stdtypes.rst:6304 +#: ../../builtins/stdtypes.rst:6661 msgid "exec" msgstr "exec" -#: ../../builtins/stdtypes.rst:6304 +#: ../../builtins/stdtypes.rst:6661 msgid "eval" msgstr "eval" -#: ../../builtins/stdtypes.rst:6343 +#: ../../builtins/stdtypes.rst:6700 msgid "..." msgstr "..." -#: ../../builtins/stdtypes.rst:6343 +#: ../../builtins/stdtypes.rst:6700 msgid "ellipsis literal" msgstr "ellipsis literal(刪節號字面值)" diff --git a/builtins/time-complexity.po b/builtins/time-complexity.po index 331f7352523..26acf818495 100644 --- a/builtins/time-complexity.po +++ b/builtins/time-complexity.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-14 00:21+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -52,20 +52,20 @@ msgid "" msgstr "" #: ../../builtins/time-complexity.rst:34 ../../builtins/time-complexity.rst:85 -#: ../../builtins/time-complexity.rst:121 -#: ../../builtins/time-complexity.rst:156 -#: ../../builtins/time-complexity.rst:199 -#: ../../builtins/time-complexity.rst:232 -#: ../../builtins/time-complexity.rst:259 +#: ../../builtins/time-complexity.rst:124 +#: ../../builtins/time-complexity.rst:159 +#: ../../builtins/time-complexity.rst:202 +#: ../../builtins/time-complexity.rst:235 +#: ../../builtins/time-complexity.rst:262 msgid "Operation" msgstr "" #: ../../builtins/time-complexity.rst:35 ../../builtins/time-complexity.rst:86 -#: ../../builtins/time-complexity.rst:122 -#: ../../builtins/time-complexity.rst:157 -#: ../../builtins/time-complexity.rst:200 -#: ../../builtins/time-complexity.rst:233 -#: ../../builtins/time-complexity.rst:260 +#: ../../builtins/time-complexity.rst:125 +#: ../../builtins/time-complexity.rst:160 +#: ../../builtins/time-complexity.rst:203 +#: ../../builtins/time-complexity.rst:236 +#: ../../builtins/time-complexity.rst:263 msgid "Complexity" msgstr "" @@ -77,17 +77,17 @@ msgstr "" #: ../../builtins/time-complexity.rst:68 ../../builtins/time-complexity.rst:70 #: ../../builtins/time-complexity.rst:98 ../../builtins/time-complexity.rst:100 #: ../../builtins/time-complexity.rst:102 -#: ../../builtins/time-complexity.rst:126 -#: ../../builtins/time-complexity.rst:136 -#: ../../builtins/time-complexity.rst:161 -#: ../../builtins/time-complexity.rst:210 -#: ../../builtins/time-complexity.rst:214 -#: ../../builtins/time-complexity.rst:216 -#: ../../builtins/time-complexity.rst:241 -#: ../../builtins/time-complexity.rst:243 -#: ../../builtins/time-complexity.rst:245 -#: ../../builtins/time-complexity.rst:270 -#: ../../builtins/time-complexity.rst:272 +#: ../../builtins/time-complexity.rst:129 +#: ../../builtins/time-complexity.rst:139 +#: ../../builtins/time-complexity.rst:164 +#: ../../builtins/time-complexity.rst:213 +#: ../../builtins/time-complexity.rst:217 +#: ../../builtins/time-complexity.rst:219 +#: ../../builtins/time-complexity.rst:244 +#: ../../builtins/time-complexity.rst:246 +#: ../../builtins/time-complexity.rst:248 +#: ../../builtins/time-complexity.rst:273 +#: ../../builtins/time-complexity.rst:275 msgid "*O*\\ (*n*)" msgstr "*O*\\ (*n*)" @@ -99,26 +99,26 @@ msgstr "" #: ../../builtins/time-complexity.rst:47 ../../builtins/time-complexity.rst:72 #: ../../builtins/time-complexity.rst:88 ../../builtins/time-complexity.rst:90 #: ../../builtins/time-complexity.rst:104 -#: ../../builtins/time-complexity.rst:124 -#: ../../builtins/time-complexity.rst:128 -#: ../../builtins/time-complexity.rst:130 -#: ../../builtins/time-complexity.rst:132 -#: ../../builtins/time-complexity.rst:138 -#: ../../builtins/time-complexity.rst:159 -#: ../../builtins/time-complexity.rst:163 -#: ../../builtins/time-complexity.rst:165 -#: ../../builtins/time-complexity.rst:183 -#: ../../builtins/time-complexity.rst:202 -#: ../../builtins/time-complexity.rst:218 -#: ../../builtins/time-complexity.rst:235 -#: ../../builtins/time-complexity.rst:237 -#: ../../builtins/time-complexity.rst:239 -#: ../../builtins/time-complexity.rst:247 -#: ../../builtins/time-complexity.rst:262 -#: ../../builtins/time-complexity.rst:264 -#: ../../builtins/time-complexity.rst:266 -#: ../../builtins/time-complexity.rst:268 -#: ../../builtins/time-complexity.rst:274 +#: ../../builtins/time-complexity.rst:127 +#: ../../builtins/time-complexity.rst:131 +#: ../../builtins/time-complexity.rst:133 +#: ../../builtins/time-complexity.rst:135 +#: ../../builtins/time-complexity.rst:141 +#: ../../builtins/time-complexity.rst:162 +#: ../../builtins/time-complexity.rst:166 +#: ../../builtins/time-complexity.rst:168 +#: ../../builtins/time-complexity.rst:186 +#: ../../builtins/time-complexity.rst:205 +#: ../../builtins/time-complexity.rst:221 +#: ../../builtins/time-complexity.rst:238 +#: ../../builtins/time-complexity.rst:240 +#: ../../builtins/time-complexity.rst:242 +#: ../../builtins/time-complexity.rst:250 +#: ../../builtins/time-complexity.rst:265 +#: ../../builtins/time-complexity.rst:267 +#: ../../builtins/time-complexity.rst:269 +#: ../../builtins/time-complexity.rst:271 +#: ../../builtins/time-complexity.rst:277 msgid "*O*\\ (1)" msgstr "*O*\\ (1)" @@ -148,8 +148,8 @@ msgid "Delete item (``del l[k]``) [2]_" msgstr "" #: ../../builtins/time-complexity.rst:50 ../../builtins/time-complexity.rst:97 -#: ../../builtins/time-complexity.rst:215 -#: ../../builtins/time-complexity.rst:269 +#: ../../builtins/time-complexity.rst:218 +#: ../../builtins/time-complexity.rst:272 msgid "Iteration" msgstr "" @@ -158,7 +158,7 @@ msgid "Get slice (``l[i:j]``)" msgstr "" #: ../../builtins/time-complexity.rst:53 ../../builtins/time-complexity.rst:92 -#: ../../builtins/time-complexity.rst:204 +#: ../../builtins/time-complexity.rst:207 msgid "*O*\\ (*j* - *i*)" msgstr "*O*\\ (*j* - *i*)" @@ -184,7 +184,7 @@ msgstr "*O*\\ (*n* - *i*)" msgid "Extend (``l.extend(t)``) [1]_ [3]_" msgstr "" -#: ../../builtins/time-complexity.rst:60 ../../builtins/time-complexity.rst:134 +#: ../../builtins/time-complexity.rst:60 ../../builtins/time-complexity.rst:137 msgid "*O*\\ (len(*t*))" msgstr "" @@ -209,7 +209,7 @@ msgid "Multiply (``l * k``)" msgstr "" #: ../../builtins/time-complexity.rst:66 ../../builtins/time-complexity.rst:96 -#: ../../builtins/time-complexity.rst:208 +#: ../../builtins/time-complexity.rst:211 msgid "*O*\\ (*nk*)" msgstr "" @@ -273,8 +273,8 @@ msgid "Get length (``len(t)``) [5]_" msgstr "" #: ../../builtins/time-complexity.rst:108 -msgid ":class:`!dict`" -msgstr ":class:`!dict`" +msgid ":class:`!dict`, :class:`!frozendict`" +msgstr ":class:`!dict`, :class:`!frozendict`" #: ../../builtins/time-complexity.rst:110 msgid "" @@ -287,43 +287,50 @@ msgid "" "on the implementation, see :ref:`how-are-dictionaries-implemented`." msgstr "" -#: ../../builtins/time-complexity.rst:123 +#: ../../builtins/time-complexity.rst:118 +msgid "" +"A :class:`frozendict` is immutable, so it does not support setting, " +"deleting, or updating items. The other operations below apply to it at the " +"same costs." +msgstr "" + +#: ../../builtins/time-complexity.rst:126 msgid "``key in d``" msgstr "``key in d``" -#: ../../builtins/time-complexity.rst:125 -msgid "Copy (``d.copy()``) [7]_" +#: ../../builtins/time-complexity.rst:128 +msgid "Copy (``d.copy()``) [6]_ [7]_" msgstr "" -#: ../../builtins/time-complexity.rst:127 +#: ../../builtins/time-complexity.rst:130 msgid "Get item (``d[key]``, ``d.get(key)``)" msgstr "" -#: ../../builtins/time-complexity.rst:129 +#: ../../builtins/time-complexity.rst:132 msgid "Set item (``d[key] = value``) [1]_" msgstr "" -#: ../../builtins/time-complexity.rst:131 +#: ../../builtins/time-complexity.rst:134 msgid "Delete item (``del d[key]``, ``d.pop(key)``)" msgstr "" -#: ../../builtins/time-complexity.rst:133 +#: ../../builtins/time-complexity.rst:136 msgid "Update (``d.update(t)``, ``d |= t``) [1]_ [3]_ [7]_" msgstr "" -#: ../../builtins/time-complexity.rst:135 +#: ../../builtins/time-complexity.rst:138 msgid "Iteration [7]_" msgstr "" -#: ../../builtins/time-complexity.rst:137 +#: ../../builtins/time-complexity.rst:140 msgid "Get length (``len(d)``) [5]_" msgstr "" -#: ../../builtins/time-complexity.rst:142 +#: ../../builtins/time-complexity.rst:145 msgid ":class:`!set`, :class:`!frozenset`" msgstr ":class:`!set`, :class:`!frozenset`" -#: ../../builtins/time-complexity.rst:144 +#: ../../builtins/time-complexity.rst:147 msgid "" "See :class:`dict` as the :class:`set` and :class:`frozenset` implementations " "are similar, and the same caveats apply. In the worst case, *O*\\ (1) " @@ -331,97 +338,97 @@ msgid "" "element degrade accordingly." msgstr "" -#: ../../builtins/time-complexity.rst:149 +#: ../../builtins/time-complexity.rst:152 msgid "" "A :class:`frozenset` is :term:`immutable`, so it does not support adding, " "discarding, or the in-place update operations. The others below apply to it " "at the same costs." msgstr "" -#: ../../builtins/time-complexity.rst:158 +#: ../../builtins/time-complexity.rst:161 msgid "``x in s``" msgstr "``x in s``" -#: ../../builtins/time-complexity.rst:160 +#: ../../builtins/time-complexity.rst:163 msgid "Copy (``s.copy()``) [6]_ [7]_" msgstr "" -#: ../../builtins/time-complexity.rst:162 +#: ../../builtins/time-complexity.rst:165 msgid "Add (``s.add(x)``) [1]_" msgstr "" -#: ../../builtins/time-complexity.rst:164 +#: ../../builtins/time-complexity.rst:167 msgid "Discard (``s.discard(x)``, ``s.remove(x)``)" msgstr "" -#: ../../builtins/time-complexity.rst:166 +#: ../../builtins/time-complexity.rst:169 msgid "Union (``s1 | s2``, ``s1.union(s2)``) [7]_" msgstr "" -#: ../../builtins/time-complexity.rst:167 -#: ../../builtins/time-complexity.rst:179 +#: ../../builtins/time-complexity.rst:170 +#: ../../builtins/time-complexity.rst:182 msgid "*O*\\ (len(*s1*) + len(*s2*))" msgstr "" -#: ../../builtins/time-complexity.rst:168 +#: ../../builtins/time-complexity.rst:171 msgid "Update (``s1 |= s2``, ``s1.update(s2)``) [1]_ [7]_" msgstr "" -#: ../../builtins/time-complexity.rst:169 -#: ../../builtins/time-complexity.rst:181 +#: ../../builtins/time-complexity.rst:172 +#: ../../builtins/time-complexity.rst:184 msgid "*O*\\ (len(*s2*))" msgstr "" -#: ../../builtins/time-complexity.rst:170 +#: ../../builtins/time-complexity.rst:173 msgid "Intersection (``s1 & s2``, ``s1.intersection(s2)``) [7]_ [8]_" msgstr "" -#: ../../builtins/time-complexity.rst:171 -#: ../../builtins/time-complexity.rst:173 -#: ../../builtins/time-complexity.rst:177 +#: ../../builtins/time-complexity.rst:174 +#: ../../builtins/time-complexity.rst:176 +#: ../../builtins/time-complexity.rst:180 msgid "*O*\\ (min(len(*s1*), len(*s2*)))" msgstr "" -#: ../../builtins/time-complexity.rst:172 +#: ../../builtins/time-complexity.rst:175 msgid "" "Intersection update (``s1 &= s2``, ``s1.intersection_update(s2)``) [1]_ [7]_ " "[8]_" msgstr "" -#: ../../builtins/time-complexity.rst:174 +#: ../../builtins/time-complexity.rst:177 msgid "Difference (``s1 - s2``, ``s1.difference(s2)``) [7]_ [9]_" msgstr "" -#: ../../builtins/time-complexity.rst:175 +#: ../../builtins/time-complexity.rst:178 msgid "*O*\\ (len(*s1*))" msgstr "" -#: ../../builtins/time-complexity.rst:176 +#: ../../builtins/time-complexity.rst:179 msgid "" "Difference update (``s1 -= s2``, ``s1.difference_update(s2)``) [1]_ [7]_ [8]_" msgstr "" -#: ../../builtins/time-complexity.rst:178 +#: ../../builtins/time-complexity.rst:181 msgid "" "Symmetric difference (``s1 ^ s2``, ``s1.symmetric_difference(s2)``) [7]_" msgstr "" -#: ../../builtins/time-complexity.rst:180 +#: ../../builtins/time-complexity.rst:183 msgid "" "Symmetric difference update (``s1 ^= s2``, " "``s1.symmetric_difference_update(s2)``) [1]_ [7]_" msgstr "" -#: ../../builtins/time-complexity.rst:182 -#: ../../builtins/time-complexity.rst:217 +#: ../../builtins/time-complexity.rst:185 +#: ../../builtins/time-complexity.rst:220 msgid "Get length (``len(s)``) [5]_" msgstr "" -#: ../../builtins/time-complexity.rst:187 +#: ../../builtins/time-complexity.rst:190 msgid ":class:`!str`, :class:`!bytes`, :class:`!bytearray`" msgstr ":class:`!str`, :class:`!bytes`, :class:`!bytearray`" -#: ../../builtins/time-complexity.rst:189 +#: ../../builtins/time-complexity.rst:192 msgid "" ":class:`str` and :class:`bytes` objects are immutable sequences of " "characters and bytes, respectively. As with tuples, copying one returns the " @@ -432,47 +439,47 @@ msgid "" "remaining bytes, and is amortized *O*\\ (1)." msgstr "" -#: ../../builtins/time-complexity.rst:201 +#: ../../builtins/time-complexity.rst:204 msgid "Get item (``s[k]``)" msgstr "" -#: ../../builtins/time-complexity.rst:203 +#: ../../builtins/time-complexity.rst:206 msgid "Get slice (``s[i:j]``)" msgstr "" -#: ../../builtins/time-complexity.rst:205 +#: ../../builtins/time-complexity.rst:208 msgid "Concatenate (``s + t``) [10]_" msgstr "" -#: ../../builtins/time-complexity.rst:206 +#: ../../builtins/time-complexity.rst:209 msgid "*O*\\ (len(*s*) + len(*t*))" msgstr "" -#: ../../builtins/time-complexity.rst:207 +#: ../../builtins/time-complexity.rst:210 msgid "Multiply (``s * k``)" msgstr "" -#: ../../builtins/time-complexity.rst:209 +#: ../../builtins/time-complexity.rst:212 msgid "Substring search (``x in s``, ``s.find(x)``, ``s.index(x)``) [11]_" msgstr "" -#: ../../builtins/time-complexity.rst:211 +#: ../../builtins/time-complexity.rst:214 msgid "Reverse substring search (``s.rfind(x)``, ``s.rindex(x)``) [11]_ [12]_" msgstr "" -#: ../../builtins/time-complexity.rst:212 +#: ../../builtins/time-complexity.rst:215 msgid "*O*\\ (*n* × len(*x*))" msgstr "" -#: ../../builtins/time-complexity.rst:213 +#: ../../builtins/time-complexity.rst:216 msgid "Encode or decode [13]_" msgstr "" -#: ../../builtins/time-complexity.rst:222 +#: ../../builtins/time-complexity.rst:225 msgid ":class:`!memoryview`" msgstr ":class:`!memoryview`" -#: ../../builtins/time-complexity.rst:224 +#: ../../builtins/time-complexity.rst:227 msgid "" ":class:`memoryview` objects allow Python code to access the internal data of " "an object that supports the :ref:`buffer protocol ` without " @@ -480,81 +487,81 @@ msgid "" "same buffer." msgstr "" -#: ../../builtins/time-complexity.rst:234 +#: ../../builtins/time-complexity.rst:237 msgid "Create (``memoryview(obj)``)" msgstr "" -#: ../../builtins/time-complexity.rst:236 +#: ../../builtins/time-complexity.rst:239 msgid "Get item (``v[k]``)" msgstr "" -#: ../../builtins/time-complexity.rst:238 +#: ../../builtins/time-complexity.rst:241 msgid "Get slice (``v[i:j]``)" msgstr "" -#: ../../builtins/time-complexity.rst:240 +#: ../../builtins/time-complexity.rst:243 msgid "Index (``v.index(x)``) [11]_ [14]_" msgstr "" -#: ../../builtins/time-complexity.rst:242 +#: ../../builtins/time-complexity.rst:245 msgid "Count (``v.count(x)``) [14]_" msgstr "" -#: ../../builtins/time-complexity.rst:244 +#: ../../builtins/time-complexity.rst:247 msgid "Convert to bytes (``v.tobytes()``, ``bytes(v)``)" msgstr "" -#: ../../builtins/time-complexity.rst:246 +#: ../../builtins/time-complexity.rst:249 msgid "Get length (``len(v)``) [5]_" msgstr "" -#: ../../builtins/time-complexity.rst:251 +#: ../../builtins/time-complexity.rst:254 msgid ":class:`!range`" msgstr ":class:`!range`" -#: ../../builtins/time-complexity.rst:253 +#: ../../builtins/time-complexity.rst:256 msgid "" "A :class:`range` object computes its items on demand from its *start*, " "*stop* and *step* values, so most operations do not depend on the length of " "the range." msgstr "" -#: ../../builtins/time-complexity.rst:261 +#: ../../builtins/time-complexity.rst:264 msgid "Get item (``r[k]``)" msgstr "" -#: ../../builtins/time-complexity.rst:263 +#: ../../builtins/time-complexity.rst:266 msgid "Get slice (``r[i:j]``)" msgstr "" -#: ../../builtins/time-complexity.rst:265 +#: ../../builtins/time-complexity.rst:268 msgid "``x in r`` [15]_" msgstr "``x in r`` [15]_" -#: ../../builtins/time-complexity.rst:267 +#: ../../builtins/time-complexity.rst:270 msgid "Index and count (``r.index(x)``, ``r.count(x)``) [15]_" msgstr "" -#: ../../builtins/time-complexity.rst:271 +#: ../../builtins/time-complexity.rst:274 msgid "``min(r)``, ``max(r)``" msgstr "``min(r)``, ``max(r)``" -#: ../../builtins/time-complexity.rst:273 +#: ../../builtins/time-complexity.rst:276 msgid "Get length (``len(r)``) [5]_" msgstr "" -#: ../../builtins/time-complexity.rst:278 +#: ../../builtins/time-complexity.rst:281 msgid "Notes" msgstr "" -#: ../../builtins/time-complexity.rst:280 +#: ../../builtins/time-complexity.rst:283 msgid "" "Amortized. An individual operation may occasionally be *O*\\ (*n*) when the " "underlying storage is resized, but this cost is spread over many operations, " "depending on the history of the container." msgstr "" -#: ../../builtins/time-complexity.rst:284 +#: ../../builtins/time-complexity.rst:287 msgid "" "Popping or deleting the element at index *k* of a list of size *n* shifts " "all elements after *k* one slot to the left, moving *n* - *k* - 1 elements; " @@ -565,31 +572,32 @@ msgid "" "the end of the list moves nothing and is *O*\\ (1)." msgstr "" -#: ../../builtins/time-complexity.rst:293 +#: ../../builtins/time-complexity.rst:296 msgid "" "Plus the cost of iterating over *t*, which may be expensive for an arbitrary " "iterable." msgstr "" -#: ../../builtins/time-complexity.rst:296 +#: ../../builtins/time-complexity.rst:299 msgid "" "This is the worst case scenario. Sorting is adaptive and input that is " "already sorted or reverse-sorted takes only *O*\\ (*n*) comparisons. " "See :source:`Objects/listsort.txt` for more information." msgstr "" -#: ../../builtins/time-complexity.rst:300 +#: ../../builtins/time-complexity.rst:303 msgid "" "The number of elements is stored in the object, so ``len()`` does not need " "to count them." msgstr "" -#: ../../builtins/time-complexity.rst:303 +#: ../../builtins/time-complexity.rst:306 msgid "" -"Copying a :class:`frozenset` is *O*\\ (1) as it returns the original object." +"Copying a :class:`frozendict` or a :class:`frozenset` is *O*\\ (1) as it " +"returns the original object." msgstr "" -#: ../../builtins/time-complexity.rst:306 +#: ../../builtins/time-complexity.rst:309 msgid "" "These operations scan the container's internal hash table, which is not " "shrunk when elements are removed. After removing most elements, they still " @@ -597,15 +605,15 @@ msgid "" "insertion triggers a resize." msgstr "" -#: ../../builtins/time-complexity.rst:311 +#: ../../builtins/time-complexity.rst:314 msgid "*O*\\ (len(*t*)) if *t* is not a set." msgstr "" -#: ../../builtins/time-complexity.rst:313 +#: ../../builtins/time-complexity.rst:316 msgid "*O*\\ (len(*s*) + len(*t*)) if *t* is not a set." msgstr "" -#: ../../builtins/time-complexity.rst:315 +#: ../../builtins/time-complexity.rst:318 msgid "" "Each concatenation builds a new object, so building a string by " "concatenating many pieces in a loop is quadratic in the total length. See " @@ -613,13 +621,13 @@ msgid "" "concatenation>` for alternatives." msgstr "" -#: ../../builtins/time-complexity.rst:320 +#: ../../builtins/time-complexity.rst:323 msgid "" "With *start* and *end* arguments, *n* is the length of the region searched " "rather than of *s*, and unlike slicing nothing is copied." msgstr "" -#: ../../builtins/time-complexity.rst:323 +#: ../../builtins/time-complexity.rst:326 msgid "" "This is the worst case. Reverse searches are *O*\\ (*n*) on typical input. " "Forward searches instead use a more elaborate algorithm with a linear worst " @@ -627,18 +635,21 @@ msgid "" "stringlib_find_two_way_notes.txt`." msgstr "" -#: ../../builtins/time-complexity.rst:328 +#: ../../builtins/time-complexity.rst:331 msgid "This assumes a codec that does a constant amount of work per character." msgstr "" -#: ../../builtins/time-complexity.rst:330 +#: ../../builtins/time-complexity.rst:333 msgid "" "These unpack and compare each element individually, so they are much slower " "than the equivalent :class:`bytes` methods." msgstr "" -#: ../../builtins/time-complexity.rst:333 +#: ../../builtins/time-complexity.rst:336 msgid "" "Assuming :class:`int` or :class:`bool` arguments. For other types, the range " "is searched like any other sequence in *O*\\ (*n*) time." msgstr "" + +#~ msgid ":class:`!dict`" +#~ msgstr ":class:`!dict`" diff --git a/c-api/apiabiversion.po b/c-api/apiabiversion.po index 385421a8f37..9b3383ba6bf 100644 --- a/c-api/apiabiversion.po +++ b/c-api/apiabiversion.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-12 12:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-01-24 22:34+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -63,11 +63,19 @@ msgstr "" "在 ``3.4.1a2`` 中的 ``a``。``0xA`` 代表 alpha 版本、``0xB`` 代表 beta 版本、" "``0xC`` 為發布候選版本、``0xF`` 則為最終版。" -#: ../../c-api/apiabiversion.rst:39 +#: ../../c-api/apiabiversion.rst:48 +msgid "" +"For completeness, the values are available as macros: :c:macro:`!" +"PY_RELEASE_LEVEL_ALPHA` (``0xA``), :c:macro:`!PY_RELEASE_LEVEL_BETA` " +"(``0xB``), :c:macro:`!PY_RELEASE_LEVEL_GAMMA` (``0xC``), and :c:macro:`!" +"PY_RELEASE_LEVEL_FINAL` (``0xF``)." +msgstr "" + +#: ../../c-api/apiabiversion.rst:56 msgid "The ``2`` in ``3.4.1a2``. Zero for final releases." msgstr "在 ``3.4.1a2`` 中的 ``2``。零則為最終發布版本。" -#: ../../c-api/apiabiversion.rst:43 +#: ../../c-api/apiabiversion.rst:60 msgid "" "The Python version number encoded in a single integer. See :c:func:" "`Py_PACK_FULL_VERSION` for the encoding details." @@ -75,20 +83,24 @@ msgstr "" "被編碼為單一整數的 Python 版本號。詳見 :c:func:`Py_PACK_FULL_VERSION` 以了解" "編碼詳細資訊。" -#: ../../c-api/apiabiversion.rst:46 +#: ../../c-api/apiabiversion.rst:63 msgid "" "Use this for numeric comparisons, for example, ``#if PY_VERSION_HEX >= ...``." msgstr "使用它進行數值比較,例如 ``#if PY_VERSION_HEX >= ...``。" -#: ../../c-api/apiabiversion.rst:49 +#: ../../c-api/apiabiversion.rst:68 +msgid "The Python version as a string, for example, ``\"3.4.1a2\"``." +msgstr "" + +#: ../../c-api/apiabiversion.rst:70 msgid "These macros are defined in :source:`Include/patchlevel.h`." msgstr "" -#: ../../c-api/apiabiversion.rst:53 +#: ../../c-api/apiabiversion.rst:74 msgid "Run-time version" msgstr "" -#: ../../c-api/apiabiversion.rst:57 +#: ../../c-api/apiabiversion.rst:78 msgid "" "The Python runtime version number encoded in a single constant integer. See :" "c:func:`Py_PACK_FULL_VERSION` for the encoding details. This contains the " @@ -98,185 +110,185 @@ msgstr "" "`Py_PACK_FULL_VERSION` 以了解編碼詳細資訊。這包含在 runtime 使用的 Python 版" "本。" -#: ../../c-api/apiabiversion.rst:61 +#: ../../c-api/apiabiversion.rst:82 msgid "" "Use this for numeric comparisons, for example, ``if (Py_Version >= ...)``." msgstr "使用它進行數值比較,例如 ``if (Py_Version >= ...)``。" -#: ../../c-api/apiabiversion.rst:67 +#: ../../c-api/apiabiversion.rst:88 msgid "Bit-packing macros" msgstr "" -#: ../../c-api/apiabiversion.rst:71 +#: ../../c-api/apiabiversion.rst:92 msgid "" "Return the given version, encoded as a single 32-bit integer with the " "following structure:" msgstr "" -#: ../../c-api/apiabiversion.rst:77 +#: ../../c-api/apiabiversion.rst:98 msgid "Argument" msgstr "引數" -#: ../../c-api/apiabiversion.rst:75 +#: ../../c-api/apiabiversion.rst:96 msgid "No. of bits" msgstr "" -#: ../../c-api/apiabiversion.rst:77 +#: ../../c-api/apiabiversion.rst:98 msgid "Bit mask" msgstr "" -#: ../../c-api/apiabiversion.rst:77 +#: ../../c-api/apiabiversion.rst:98 msgid "Bit shift" msgstr "" -#: ../../c-api/apiabiversion.rst:75 +#: ../../c-api/apiabiversion.rst:96 msgid "Example values" msgstr "" -#: ../../c-api/apiabiversion.rst:77 ../../c-api/apiabiversion.rst:95 +#: ../../c-api/apiabiversion.rst:98 ../../c-api/apiabiversion.rst:116 msgid "``3.4.1a2``" msgstr "``3.4.1a2``" -#: ../../c-api/apiabiversion.rst:77 ../../c-api/apiabiversion.rst:97 +#: ../../c-api/apiabiversion.rst:98 ../../c-api/apiabiversion.rst:118 msgid "``3.10.0``" msgstr "``3.10.0``" -#: ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:100 msgid "*major*" msgstr "*major*" -#: ../../c-api/apiabiversion.rst:79 ../../c-api/apiabiversion.rst:81 -#: ../../c-api/apiabiversion.rst:83 +#: ../../c-api/apiabiversion.rst:100 ../../c-api/apiabiversion.rst:102 +#: ../../c-api/apiabiversion.rst:104 msgid "8" msgstr "8" -#: ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:100 msgid "``0xFF000000``" msgstr "``0xFF000000``" -#: ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:100 msgid "24" msgstr "24" -#: ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:100 msgid "``0x03``" msgstr "``0x03``" -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:102 msgid "*minor*" msgstr "" -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:102 msgid "``0x00FF0000``" msgstr "``0x00FF0000``" -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:102 msgid "16" msgstr "16" -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:102 msgid "``0x04``" msgstr "``0x04``" -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:102 msgid "``0x0A``" msgstr "``0x0A``" -#: ../../c-api/apiabiversion.rst:83 +#: ../../c-api/apiabiversion.rst:104 msgid "*micro*" msgstr "*micro*" -#: ../../c-api/apiabiversion.rst:83 +#: ../../c-api/apiabiversion.rst:104 msgid "``0x0000FF00``" msgstr "``0x0000FF00``" -#: ../../c-api/apiabiversion.rst:83 +#: ../../c-api/apiabiversion.rst:104 msgid "``0x01``" msgstr "``0x01``" -#: ../../c-api/apiabiversion.rst:83 +#: ../../c-api/apiabiversion.rst:104 msgid "``0x00``" msgstr "``0x00``" -#: ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:106 msgid "*release_level*" msgstr "*release_level*" -#: ../../c-api/apiabiversion.rst:85 ../../c-api/apiabiversion.rst:87 +#: ../../c-api/apiabiversion.rst:106 ../../c-api/apiabiversion.rst:108 msgid "4" msgstr "4" -#: ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:106 msgid "``0x000000F0``" msgstr "``0x000000F0``" -#: ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:106 msgid "``0xA``" msgstr "``0xA``" -#: ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:106 msgid "``0xF``" msgstr "``0xF``" -#: ../../c-api/apiabiversion.rst:87 +#: ../../c-api/apiabiversion.rst:108 msgid "*release_serial*" msgstr "*release_serial*" -#: ../../c-api/apiabiversion.rst:87 +#: ../../c-api/apiabiversion.rst:108 msgid "``0x0000000F``" msgstr "``0x0000000F``" -#: ../../c-api/apiabiversion.rst:87 +#: ../../c-api/apiabiversion.rst:108 msgid "0" msgstr "0" -#: ../../c-api/apiabiversion.rst:87 +#: ../../c-api/apiabiversion.rst:108 msgid "``0x2``" msgstr "``0x2``" -#: ../../c-api/apiabiversion.rst:87 +#: ../../c-api/apiabiversion.rst:108 msgid "``0x0``" msgstr "``0x0``" -#: ../../c-api/apiabiversion.rst:90 +#: ../../c-api/apiabiversion.rst:111 msgid "For example:" msgstr "例如:" -#: ../../c-api/apiabiversion.rst:93 +#: ../../c-api/apiabiversion.rst:114 msgid "Version" msgstr "版本" -#: ../../c-api/apiabiversion.rst:93 +#: ../../c-api/apiabiversion.rst:114 msgid "``Py_PACK_FULL_VERSION`` arguments" msgstr "``Py_PACK_FULL_VERSION`` 引數" -#: ../../c-api/apiabiversion.rst:93 +#: ../../c-api/apiabiversion.rst:114 msgid "Encoded version" msgstr "" -#: ../../c-api/apiabiversion.rst:95 +#: ../../c-api/apiabiversion.rst:116 msgid "``(3, 4, 1, 0xA, 2)``" msgstr "``(3, 4, 1, 0xA, 2)``" -#: ../../c-api/apiabiversion.rst:95 +#: ../../c-api/apiabiversion.rst:116 msgid "``0x030401a2``" msgstr "``0x030401a2``" -#: ../../c-api/apiabiversion.rst:97 +#: ../../c-api/apiabiversion.rst:118 msgid "``(3, 10, 0, 0xF, 0)``" msgstr "``(3, 10, 0, 0xF, 0)``" -#: ../../c-api/apiabiversion.rst:97 +#: ../../c-api/apiabiversion.rst:118 msgid "``0x030a00f0``" msgstr "``0x030a00f0``" -#: ../../c-api/apiabiversion.rst:100 +#: ../../c-api/apiabiversion.rst:121 msgid "" "Out-of range bits in the arguments are ignored. That is, the macro can be " "defined as:" msgstr "" -#: ../../c-api/apiabiversion.rst:103 +#: ../../c-api/apiabiversion.rst:124 msgid "" "#ifndef Py_PACK_FULL_VERSION\n" "#define Py_PACK_FULL_VERSION(X, Y, Z, LEVEL, SERIAL) ( \\\n" @@ -296,13 +308,13 @@ msgstr "" " (((SERIAL) & 0xf) << 0))\n" "#endif" -#: ../../c-api/apiabiversion.rst:114 +#: ../../c-api/apiabiversion.rst:135 msgid "" "``Py_PACK_FULL_VERSION`` is primarily a macro, intended for use in ``#if`` " "directives, but it is also available as an exported function." msgstr "" -#: ../../c-api/apiabiversion.rst:121 +#: ../../c-api/apiabiversion.rst:142 msgid "" "Equivalent to ``Py_PACK_FULL_VERSION(major, minor, 0, 0, 0)``. The result " "does not correspond to any Python release, but is useful in numeric " diff --git a/c-api/arg.po b/c-api/arg.po index 4613bce4375..a2f2865115e 100644 --- a/c-api/arg.po +++ b/c-api/arg.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-08 00:15+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-10-16 03:21+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -178,7 +178,7 @@ msgid "" "encoding." msgstr "" -#: ../../c-api/arg.rst:113 ../../c-api/arg.rst:619 +#: ../../c-api/arg.rst:113 ../../c-api/arg.rst:648 msgid "``z`` (:class:`str` or ``None``) [const char \\*]" msgstr "``z`` (:class:`str` 或 ``None``) [const char \\*]" @@ -437,16 +437,18 @@ msgstr "" #: ../../c-api/arg.rst:238 msgid "" "For signed integer formats, :exc:`OverflowError` is raised if the value is " -"out of range for the C type. For unsigned integer formats, no range checking " -"is done --- the most significant bits are silently truncated when the " -"receiving field is too small to receive the value." +"out of range for the C type. For unsigned integer formats, the most " +"significant bits are silently truncated when the receiving field is too " +"small to receive the value, and :exc:`DeprecationWarning` is emitted when " +"the value is larger than the maximal value for the C type or less than the " +"minimal value for the corresponding signed integer type of the same size." msgstr "" -#: ../../c-api/arg.rst:244 +#: ../../c-api/arg.rst:246 msgid "``b`` (:class:`int`) [unsigned char]" msgstr "``b`` (:class:`int`) [unsigned char]" -#: ../../c-api/arg.rst:245 +#: ../../c-api/arg.rst:247 msgid "" "Convert a nonnegative Python integer to an unsigned tiny integer, stored in " "a C :c:expr:`unsigned char`." @@ -454,81 +456,73 @@ msgstr "" "將一個 Python 非負整數轉換成無符號 tiny integer(小整數),儲存在 C 的 :c:" "expr:`unsigned`" -#: ../../c-api/arg.rst:248 ../../c-api/arg.rst:653 +#: ../../c-api/arg.rst:250 ../../c-api/arg.rst:682 msgid "``B`` (:class:`int`) [unsigned char]" msgstr "``B`` (:class:`int`) [unsigned char]" -#: ../../c-api/arg.rst:249 +#: ../../c-api/arg.rst:251 msgid "" "Convert a Python integer to a tiny integer without overflow checking, stored " -"in a C :c:expr:`unsigned char`." +"in a C :c:expr:`unsigned char`. Convert a Python integer to a C :c:expr:" +"`unsigned char`." msgstr "" -"將一個 Python 整數轉換成 tiny integer,轉換過程無溢位檢查,儲存在 C 的 :c:" -"expr:`unsigned char`。" +"將一個 Python 整數轉換成 tiny integer,轉換過程無溢位檢查,儲存在 C " +"的 :c:expr:`unsigned char`。將一個 Python 整數轉換成 C 的 :c:expr:`unsigned " +"char`。" -#: ../../c-api/arg.rst:252 ../../c-api/arg.rst:647 +#: ../../c-api/arg.rst:255 ../../c-api/arg.rst:676 msgid "``h`` (:class:`int`) [short int]" msgstr "``h`` (:class:`int`) [short int]" -#: ../../c-api/arg.rst:253 +#: ../../c-api/arg.rst:256 msgid "Convert a Python integer to a C :c:expr:`short int`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`short int`。" -#: ../../c-api/arg.rst:255 ../../c-api/arg.rst:656 +#: ../../c-api/arg.rst:258 ../../c-api/arg.rst:685 msgid "``H`` (:class:`int`) [unsigned short int]" msgstr "``H`` (:class:`int`) [unsigned short int]" -#: ../../c-api/arg.rst:256 -msgid "" -"Convert a Python integer to a C :c:expr:`unsigned short int`, without " -"overflow checking." -msgstr "" -"將一個 Python 整數轉換成 C 的 :c:expr:`unsigned short int`,轉換過程無溢位檢" -"查。" +#: ../../c-api/arg.rst:259 +msgid "Convert a Python integer to a C :c:expr:`unsigned short int`." +msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned short int`。" -#: ../../c-api/arg.rst:259 ../../c-api/arg.rst:641 +#: ../../c-api/arg.rst:261 ../../c-api/arg.rst:670 msgid "``i`` (:class:`int`) [int]" msgstr "``i`` (:class:`int`) [int]" -#: ../../c-api/arg.rst:260 +#: ../../c-api/arg.rst:262 msgid "Convert a Python integer to a plain C :c:expr:`int`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`int`。" -#: ../../c-api/arg.rst:262 ../../c-api/arg.rst:659 +#: ../../c-api/arg.rst:264 ../../c-api/arg.rst:688 msgid "``I`` (:class:`int`) [unsigned int]" msgstr "``I`` (:class:`int`) [unsigned int]" -#: ../../c-api/arg.rst:263 -msgid "" -"Convert a Python integer to a C :c:expr:`unsigned int`, without overflow " -"checking." -msgstr "" -"將一個 Python 整數轉換成 C 的 :c:expr:`unsigned int`,轉換過程無溢位檢查。" +#: ../../c-api/arg.rst:265 +msgid "Convert a Python integer to a C :c:expr:`unsigned int`." +msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned int`。" -#: ../../c-api/arg.rst:266 ../../c-api/arg.rst:650 +#: ../../c-api/arg.rst:267 ../../c-api/arg.rst:679 msgid "``l`` (:class:`int`) [long int]" msgstr "``l`` (:class:`int`) [long int]" -#: ../../c-api/arg.rst:267 +#: ../../c-api/arg.rst:268 msgid "Convert a Python integer to a C :c:expr:`long int`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`long int`。" -#: ../../c-api/arg.rst:269 ../../c-api/arg.rst:662 +#: ../../c-api/arg.rst:270 ../../c-api/arg.rst:691 msgid "``k`` (:class:`int`) [unsigned long]" msgstr "``k`` (:class:`int`) [unsigned long]" -#: ../../c-api/arg.rst:270 -msgid "" -"Convert a Python integer to a C :c:expr:`unsigned long` without overflow " -"checking." -msgstr "" -"將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long`,轉換過程無溢位檢查。" +#: ../../c-api/arg.rst:271 +msgid "Convert a Python integer to a C :c:expr:`unsigned long`." +msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long`。" -#: ../../c-api/arg.rst:273 ../../c-api/arg.rst:283 +#: ../../c-api/arg.rst:273 ../../c-api/arg.rst:282 msgid "Use :meth:`~object.__index__` if available." msgstr "如有提供則使用 :meth:`~object.__index__`。" -#: ../../c-api/arg.rst:276 ../../c-api/arg.rst:665 +#: ../../c-api/arg.rst:276 ../../c-api/arg.rst:694 msgid "``L`` (:class:`int`) [long long]" msgstr "``L`` (:class:`int`) [long long]" @@ -536,83 +530,87 @@ msgstr "``L`` (:class:`int`) [long long]" msgid "Convert a Python integer to a C :c:expr:`long long`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`long long`。" -#: ../../c-api/arg.rst:279 ../../c-api/arg.rst:670 +#: ../../c-api/arg.rst:279 ../../c-api/arg.rst:699 msgid "``K`` (:class:`int`) [unsigned long long]" msgstr "``K`` (:class:`int`) [unsigned long long]" #: ../../c-api/arg.rst:280 -msgid "" -"Convert a Python integer to a C :c:expr:`unsigned long long` without " -"overflow checking." -msgstr "" -"將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long long`,轉換過程無溢位檢" -"查。" +msgid "Convert a Python integer to a C :c:expr:`unsigned long long`." +msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long long`。" -#: ../../c-api/arg.rst:286 ../../c-api/arg.rst:673 +#: ../../c-api/arg.rst:285 ../../c-api/arg.rst:702 msgid "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" msgstr "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:287 +#: ../../c-api/arg.rst:286 msgid "Convert a Python integer to a C :c:type:`Py_ssize_t`." msgstr "將一個 Python 整數轉換成 C 的 :c:type:`Py_ssize_t`。" -#: ../../c-api/arg.rst:289 +#: ../../c-api/arg.rst:288 msgid "``c`` (:class:`bytes` or :class:`bytearray` of length 1) [char]" msgstr "``c`` (:class:`bytes` 或長度為 1 的 :class:`bytearray`) [char]" -#: ../../c-api/arg.rst:290 +#: ../../c-api/arg.rst:289 msgid "" "Convert a Python byte, represented as a :class:`bytes` or :class:`bytearray` " "object of length 1, to a C :c:expr:`char`." msgstr "" -#: ../../c-api/arg.rst:293 +#: ../../c-api/arg.rst:292 msgid "Allow :class:`bytearray` objects." msgstr "允許 :class:`bytearray` 物件。" -#: ../../c-api/arg.rst:296 ../../c-api/arg.rst:691 +#: ../../c-api/arg.rst:295 ../../c-api/arg.rst:720 msgid "``C`` (:class:`str` of length 1) [int]" msgstr "``C`` (長度為 1 的 :class:`str`) [int]" -#: ../../c-api/arg.rst:297 +#: ../../c-api/arg.rst:296 msgid "" "Convert a Python character, represented as a :class:`str` object of length " "1, to a C :c:expr:`int`." msgstr "" -#: ../../c-api/arg.rst:300 ../../c-api/arg.rst:698 +#: ../../c-api/arg.rst:299 ../../c-api/arg.rst:727 msgid "``f`` (:class:`float`) [float]" msgstr "``f`` (:class:`float`) [float]" -#: ../../c-api/arg.rst:301 +#: ../../c-api/arg.rst:300 msgid "Convert a Python floating-point number to a C :c:expr:`float`." msgstr "將一個 Python 浮點數轉換成 C 的 :c:type::c:expr:`float`。" -#: ../../c-api/arg.rst:303 ../../c-api/arg.rst:695 +#: ../../c-api/arg.rst:302 ../../c-api/arg.rst:724 msgid "``d`` (:class:`float`) [double]" msgstr "``d`` (:class:`float`) [double]" -#: ../../c-api/arg.rst:304 +#: ../../c-api/arg.rst:303 msgid "Convert a Python floating-point number to a C :c:expr:`double`." msgstr "將一個 Python 浮點數轉換成 C 的 :c:type::c:expr:`double`。" -#: ../../c-api/arg.rst:306 +#: ../../c-api/arg.rst:305 msgid "``D`` (:class:`complex`) [Py_complex]" msgstr "``D`` (:class:`complex`) [Py_complex]" -#: ../../c-api/arg.rst:307 +#: ../../c-api/arg.rst:306 msgid "Convert a Python complex number to a C :c:type:`Py_complex` structure." msgstr "將一個 Python 複數轉換成 C 的 :c:type:`Py_complex` 結構。" #: ../../c-api/arg.rst:310 +msgid "" +"For unsigned integer formats ``B``, ``H``, ``I``, ``k`` and ``K``, :exc:" +"`DeprecationWarning` is emitted when the value is larger than the maximal " +"value for the C type or less than the minimal value for the corresponding " +"signed integer type of the same size." +msgstr "" + +#: ../../c-api/arg.rst:317 msgid "Other objects" msgstr "其他物件" -#: ../../c-api/arg.rst:312 ../../c-api/arg.rst:704 +#: ../../c-api/arg.rst:319 ../../c-api/arg.rst:733 msgid "``O`` (object) [PyObject \\*]" msgstr "``O`` (object) [PyObject \\*]" -#: ../../c-api/arg.rst:313 +#: ../../c-api/arg.rst:320 msgid "" "Store a Python object (without any conversion) in a C object pointer. The C " "program thus receives the actual object that was passed. A new :term:" @@ -620,11 +618,11 @@ msgid "" "not increased). The pointer stored is not ``NULL``." msgstr "" -#: ../../c-api/arg.rst:319 +#: ../../c-api/arg.rst:326 msgid "``O!`` (object) [*typeobject*, PyObject \\*]" msgstr "``O!`` (object) [*typeobject*, PyObject \\*]" -#: ../../c-api/arg.rst:320 +#: ../../c-api/arg.rst:327 msgid "" "Store a Python object in a C object pointer. This is similar to ``O``, but " "takes two C arguments: the first is the address of a Python type object, the " @@ -633,11 +631,11 @@ msgid "" "required type, :exc:`TypeError` is raised." msgstr "" -#: ../../c-api/arg.rst:328 +#: ../../c-api/arg.rst:335 msgid "``O&`` (object) [*converter*, *address*]" msgstr "``O&`` (object) [*converter*, *address*]" -#: ../../c-api/arg.rst:329 +#: ../../c-api/arg.rst:336 msgid "" "Convert a Python object to a C variable through a *converter* function. " "This takes two arguments: the first is a function, the second is the address " @@ -645,11 +643,11 @@ msgid "" "*converter* function in turn is called as follows::" msgstr "" -#: ../../c-api/arg.rst:334 +#: ../../c-api/arg.rst:341 msgid "status = converter(object, address);" msgstr "status = converter(object, address);" -#: ../../c-api/arg.rst:336 +#: ../../c-api/arg.rst:343 msgid "" "where *object* is the Python object to be converted and *address* is the :c:" "expr:`void*` argument that was passed to the ``PyArg_Parse*`` function. The " @@ -659,7 +657,7 @@ msgid "" "unmodified." msgstr "" -#: ../../c-api/arg.rst:345 +#: ../../c-api/arg.rst:352 msgid "" "If the *converter* returns :c:macro:`!Py_CLEANUP_SUPPORTED`, it may get " "called a second time if the argument parsing eventually fails, giving the " @@ -668,21 +666,21 @@ msgid "" "have the same value as in the original call." msgstr "" -#: ../../c-api/arg.rst:351 +#: ../../c-api/arg.rst:358 msgid "" "Examples of converters: :c:func:`PyUnicode_FSConverter` and :c:func:" "`PyUnicode_FSDecoder`." msgstr "" -#: ../../c-api/arg.rst:354 +#: ../../c-api/arg.rst:361 msgid ":c:macro:`!Py_CLEANUP_SUPPORTED` was added." msgstr "新增 :c:macro:`!Py_CLEANUP_SUPPORTED`。" -#: ../../c-api/arg.rst:357 ../../c-api/arg.rst:676 +#: ../../c-api/arg.rst:364 ../../c-api/arg.rst:705 msgid "``p`` (:class:`bool`) [int]" msgstr "``p`` (:class:`bool`) [int]" -#: ../../c-api/arg.rst:358 +#: ../../c-api/arg.rst:365 msgid "" "Tests the value passed in for truth (a boolean **p**\\ redicate) and " "converts the result to its equivalent C true/false integer value. Sets the " @@ -691,11 +689,11 @@ msgid "" "how Python tests values for truth." msgstr "" -#: ../../c-api/arg.rst:366 +#: ../../c-api/arg.rst:373 msgid "``(items)`` (sequence) [*matching-items*]" msgstr "``(items)`` (sequence) [*matching-items*]" -#: ../../c-api/arg.rst:367 +#: ../../c-api/arg.rst:374 msgid "" "The object must be a Python sequence (except :class:`str`, :class:`bytes` " "or :class:`bytearray`) whose length is the number of format units in " @@ -703,7 +701,7 @@ msgid "" "*items*. Format units for sequences may be nested." msgstr "" -#: ../../c-api/arg.rst:372 +#: ../../c-api/arg.rst:379 msgid "" "If *items* contains format units which store a :ref:`borrowed buffer ` (``s``, ``s#``, ``z``, ``z#``, ``y``, or ``y#``) or a :" @@ -712,28 +710,28 @@ msgid "" "*items* must not store a borrowed buffer or a borrowed reference." msgstr "" -#: ../../c-api/arg.rst:379 +#: ../../c-api/arg.rst:386 msgid "" ":class:`str` and :class:`bytearray` objects no longer accepted as a sequence." msgstr "" -#: ../../c-api/arg.rst:382 +#: ../../c-api/arg.rst:389 msgid "" "Non-tuple sequences are deprecated if *items* contains format units which " "store a borrowed buffer or a borrowed reference." msgstr "" -#: ../../c-api/arg.rst:386 +#: ../../c-api/arg.rst:393 msgid "" "A few other characters have a meaning in a format string. These may not " "occur inside nested parentheses. They are:" msgstr "" -#: ../../c-api/arg.rst:389 +#: ../../c-api/arg.rst:396 msgid "``|``" msgstr "``|``" -#: ../../c-api/arg.rst:390 +#: ../../c-api/arg.rst:397 msgid "" "Indicates that the remaining arguments in the Python argument list are " "optional. The C variables corresponding to optional arguments should be " @@ -743,11 +741,11 @@ msgid "" "corresponds to the Python signature ``f(a, b, c=None, d=None)``." msgstr "" -#: ../../c-api/arg.rst:398 +#: ../../c-api/arg.rst:405 msgid "``$``" msgstr "``$``" -#: ../../c-api/arg.rst:399 +#: ../../c-api/arg.rst:406 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` only: Indicates that the remaining " "arguments in the Python argument list are keyword-only. They are optional if " @@ -757,36 +755,36 @@ msgid "" "format string ``\"OO$OO\"`` corresponds to ``f(a, b, *, c, d)``." msgstr "" -#: ../../c-api/arg.rst:410 +#: ../../c-api/arg.rst:417 msgid "``:``" msgstr "``:``" -#: ../../c-api/arg.rst:411 +#: ../../c-api/arg.rst:418 msgid "" "The list of format units ends here; the string after the colon is used as " "the function name in error messages (the \"associated value\" of the " "exception that :c:func:`PyArg_ParseTuple` raises)." msgstr "" -#: ../../c-api/arg.rst:415 +#: ../../c-api/arg.rst:422 msgid "``;``" msgstr "``;``" -#: ../../c-api/arg.rst:416 +#: ../../c-api/arg.rst:423 msgid "" "The list of format units ends here; the string after the semicolon is used " "as the error message *instead* of the default error message. ``:`` and ``;" "`` mutually exclude each other." msgstr "" -#: ../../c-api/arg.rst:420 +#: ../../c-api/arg.rst:427 msgid "" "Note that any Python object references which are provided to the caller are " "*borrowed* references; do not release them (i.e. do not decrement their " "reference count)!" msgstr "" -#: ../../c-api/arg.rst:424 +#: ../../c-api/arg.rst:431 msgid "" "Additional arguments passed to these functions must be addresses of " "variables whose type is determined by the format string; these are used to " @@ -796,7 +794,7 @@ msgid "" "unit in that case." msgstr "" -#: ../../c-api/arg.rst:430 +#: ../../c-api/arg.rst:437 msgid "" "For the conversion to succeed, the *arg* object must match the format and " "the format must be exhausted. On success, the ``PyArg_Parse*`` functions " @@ -806,24 +804,24 @@ msgid "" "the following format units are left untouched." msgstr "" -#: ../../c-api/arg.rst:439 +#: ../../c-api/arg.rst:446 msgid "API Functions" msgstr "API 函式" -#: ../../c-api/arg.rst:443 +#: ../../c-api/arg.rst:450 msgid "" "Parse the parameters of a function that takes only positional parameters " "into local variables. Returns true on success; on failure, it returns false " "and raises the appropriate exception." msgstr "" -#: ../../c-api/arg.rst:450 +#: ../../c-api/arg.rst:457 msgid "" "Identical to :c:func:`PyArg_ParseTuple`, except that it accepts a va_list " "rather than a variable number of arguments." msgstr "" -#: ../../c-api/arg.rst:456 +#: ../../c-api/arg.rst:463 msgid "" "Parse the parameters of a function that takes both positional and keyword " "parameters into local variables. The *keywords* argument is a ``NULL``-" @@ -833,51 +831,51 @@ msgid "" "failure, it returns false and raises the appropriate exception." msgstr "" -#: ../../c-api/arg.rst:467 +#: ../../c-api/arg.rst:474 msgid "" "The *keywords* parameter declaration is :c:expr:`char * const *` in C and :c:" "expr:`const char * const *` in C++. This can be overridden with the :c:macro:" "`PY_CXX_CONST` macro." msgstr "" -#: ../../c-api/arg.rst:471 +#: ../../c-api/arg.rst:478 msgid "" "Added support for :ref:`positional-only parameters `." msgstr "新增對\\ :ref:`僅限位置參數 `\\ 的支援。" -#: ../../c-api/arg.rst:475 +#: ../../c-api/arg.rst:482 msgid "" "The *keywords* parameter has now type :c:expr:`char * const *` in C and :c:" "expr:`const char * const *` in C++, instead of :c:expr:`char **`. Added " "support for non-ASCII keyword parameter names." msgstr "" -#: ../../c-api/arg.rst:484 +#: ../../c-api/arg.rst:491 msgid "" "Identical to :c:func:`PyArg_ParseTupleAndKeywords`, except that it accepts a " "va_list rather than a variable number of arguments." msgstr "" -#: ../../c-api/arg.rst:490 +#: ../../c-api/arg.rst:497 msgid "" "Ensure that the keys in the keywords argument dictionary are strings. This " "is only needed if :c:func:`PyArg_ParseTupleAndKeywords` is not used, since " "the latter already does this check." msgstr "" -#: ../../c-api/arg.rst:499 +#: ../../c-api/arg.rst:506 msgid "" "Parse the parameter of a function that takes a single positional parameter " "into a local variable. Returns true on success; on failure, it returns " "false and raises the appropriate exception." msgstr "" -#: ../../c-api/arg.rst:503 +#: ../../c-api/arg.rst:510 msgid "Example::" msgstr "舉例來說: ::" -#: ../../c-api/arg.rst:505 +#: ../../c-api/arg.rst:512 msgid "" "// Function using METH_O calling convention\n" "static PyObject*\n" @@ -891,7 +889,24 @@ msgid "" "}" msgstr "" -#: ../../c-api/arg.rst:519 +#: ../../c-api/arg.rst:526 +msgid "" +"Parse the parameters of a function that takes only array parameters into " +"local variables (that is, a function using the :c:macro:`METH_FASTCALL` " +"calling convention). Returns true on success; on failure, it returns false " +"and raises the appropriate exception." +msgstr "" + +#: ../../c-api/arg.rst:537 +msgid "" +"Parse the parameters of a function that takes both array and keyword " +"parameters into local variables (that is, a function using the :c:macro:" +"`METH_FASTCALL` ``|`` :c:macro:`METH_KEYWORDS` calling convention). Returns " +"true on success; on failure, it returns false and raises the appropriate " +"exception." +msgstr "" + +#: ../../c-api/arg.rst:548 msgid "" "A simpler form of parameter retrieval which does not use a format string to " "specify the types of the arguments. Functions which use this method to " @@ -909,13 +924,13 @@ msgid "" "if there was a failure." msgstr "" -#: ../../c-api/arg.rst:534 +#: ../../c-api/arg.rst:563 msgid "" "This is an example of the use of this function, taken from the sources for " "the :mod:`!_weakref` helper module for weak references::" msgstr "" -#: ../../c-api/arg.rst:537 +#: ../../c-api/arg.rst:566 msgid "" "static PyObject *\n" "weakref_ref(PyObject *self, PyObject *args)\n" @@ -943,17 +958,17 @@ msgstr "" " return result;\n" "}" -#: ../../c-api/arg.rst:550 +#: ../../c-api/arg.rst:579 msgid "" "The call to :c:func:`PyArg_UnpackTuple` in this example is entirely " "equivalent to this call to :c:func:`PyArg_ParseTuple`::" msgstr "" -#: ../../c-api/arg.rst:553 +#: ../../c-api/arg.rst:582 msgid "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" msgstr "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" -#: ../../c-api/arg.rst:557 +#: ../../c-api/arg.rst:586 msgid "" "The value to be inserted, if any, before :c:expr:`char * const *` in the " "*keywords* parameter declaration of :c:func:`PyArg_ParseTupleAndKeywords` " @@ -962,11 +977,11 @@ msgid "" "to the desired value before including :file:`Python.h`." msgstr "" -#: ../../c-api/arg.rst:571 +#: ../../c-api/arg.rst:600 msgid "Building values" msgstr "建置數值" -#: ../../c-api/arg.rst:575 +#: ../../c-api/arg.rst:604 msgid "" "Create a new value based on a format string similar to those accepted by the " "``PyArg_Parse*`` family of functions and a sequence of values. Returns the " @@ -974,7 +989,7 @@ msgid "" "``NULL`` is returned." msgstr "" -#: ../../c-api/arg.rst:580 +#: ../../c-api/arg.rst:609 msgid "" ":c:func:`Py_BuildValue` does not always build a tuple. It builds a tuple " "only if its format string contains two or more format units. If the format " @@ -983,7 +998,7 @@ msgid "" "it to return a tuple of size 0 or one, parenthesize the format string." msgstr "" -#: ../../c-api/arg.rst:586 +#: ../../c-api/arg.rst:615 msgid "" "When memory buffers are passed as parameters to supply data to build " "objects, as for the ``s`` and ``s#`` formats, the required data is copied. " @@ -994,7 +1009,7 @@ msgid "" "`Py_BuildValue` returns." msgstr "" -#: ../../c-api/arg.rst:594 +#: ../../c-api/arg.rst:623 msgid "" "In the following description, the quoted form is the format unit; the entry " "in (round) parentheses is the Python object type that the format unit will " @@ -1002,155 +1017,155 @@ msgid "" "be passed." msgstr "" -#: ../../c-api/arg.rst:598 +#: ../../c-api/arg.rst:627 msgid "" "The characters space, tab, colon and comma are ignored in format strings " "(but not within format units such as ``s#``). This can be used to make long " "format strings a tad more readable." msgstr "" -#: ../../c-api/arg.rst:602 +#: ../../c-api/arg.rst:631 msgid "``s`` (:class:`str` or ``None``) [const char \\*]" msgstr "``s`` (:class:`str` 或 ``None``) [const char \\*]" -#: ../../c-api/arg.rst:603 +#: ../../c-api/arg.rst:632 msgid "" "Convert a null-terminated C string to a Python :class:`str` object using " "``'utf-8'`` encoding. If the C string pointer is ``NULL``, ``None`` is used." msgstr "" -#: ../../c-api/arg.rst:606 +#: ../../c-api/arg.rst:635 msgid "" "``s#`` (:class:`str` or ``None``) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" "``s#`` (:class:`str` 或 ``None``) [const char \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:607 +#: ../../c-api/arg.rst:636 msgid "" "Convert a C string and its length to a Python :class:`str` object using " "``'utf-8'`` encoding. If the C string pointer is ``NULL``, the length is " "ignored and ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:611 +#: ../../c-api/arg.rst:640 msgid "``y`` (:class:`bytes`) [const char \\*]" msgstr "``y`` (:class:`bytes`) [const char \\*]" -#: ../../c-api/arg.rst:612 +#: ../../c-api/arg.rst:641 msgid "" "This converts a C string to a Python :class:`bytes` object. If the C string " "pointer is ``NULL``, ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:615 +#: ../../c-api/arg.rst:644 msgid "``y#`` (:class:`bytes`) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "``y#`` (:class:`bytes`) [const char \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:616 +#: ../../c-api/arg.rst:645 msgid "" "This converts a C string and its lengths to a Python object. If the C " "string pointer is ``NULL``, ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:620 ../../c-api/arg.rst:636 +#: ../../c-api/arg.rst:649 ../../c-api/arg.rst:665 msgid "Same as ``s``." msgstr "和 ``s`` 相同。" -#: ../../c-api/arg.rst:622 +#: ../../c-api/arg.rst:651 msgid "" "``z#`` (:class:`str` or ``None``) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" "``z#`` (:class:`str` 或 ``None``) [const char \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:623 ../../c-api/arg.rst:639 +#: ../../c-api/arg.rst:652 ../../c-api/arg.rst:668 msgid "Same as ``s#``." msgstr "和 ``s#`` 相同。" -#: ../../c-api/arg.rst:625 +#: ../../c-api/arg.rst:654 msgid "``u`` (:class:`str`) [const wchar_t \\*]" msgstr "``u`` (:class:`str`) [const wchar_t \\*]" -#: ../../c-api/arg.rst:626 +#: ../../c-api/arg.rst:655 msgid "" "Convert a null-terminated :c:type:`wchar_t` buffer of Unicode (UTF-16 or " "UCS-4) data to a Python Unicode object. If the Unicode buffer pointer is " "``NULL``, ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:630 +#: ../../c-api/arg.rst:659 msgid "``u#`` (:class:`str`) [const wchar_t \\*, :c:type:`Py_ssize_t`]" msgstr "``u#`` (:class:`str`) [const wchar_t \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:631 +#: ../../c-api/arg.rst:660 msgid "" "Convert a Unicode (UTF-16 or UCS-4) data buffer and its length to a Python " "Unicode object. If the Unicode buffer pointer is ``NULL``, the length is " "ignored and ``None`` is returned." msgstr "" -#: ../../c-api/arg.rst:635 +#: ../../c-api/arg.rst:664 msgid "``U`` (:class:`str` or ``None``) [const char \\*]" msgstr "``U`` (:class:`str` 或 ``None``) [const char \\*]" -#: ../../c-api/arg.rst:638 +#: ../../c-api/arg.rst:667 msgid "" "``U#`` (:class:`str` or ``None``) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" "``U#`` (:class:`str` 或 ``None``) [const char \\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:642 +#: ../../c-api/arg.rst:671 msgid "Convert a plain C :c:expr:`int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:644 +#: ../../c-api/arg.rst:673 msgid "``b`` (:class:`int`) [char]" msgstr "``b`` (:class:`int`) [char]" -#: ../../c-api/arg.rst:645 +#: ../../c-api/arg.rst:674 msgid "Convert a plain C :c:expr:`char` to a Python integer object." msgstr "將一個 C 的 :c:expr:`char` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:648 +#: ../../c-api/arg.rst:677 msgid "Convert a plain C :c:expr:`short int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`short int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:651 +#: ../../c-api/arg.rst:680 msgid "Convert a C :c:expr:`long int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`long int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:654 +#: ../../c-api/arg.rst:683 msgid "Convert a C :c:expr:`unsigned char` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned char` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:657 +#: ../../c-api/arg.rst:686 msgid "Convert a C :c:expr:`unsigned short int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned short int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:660 +#: ../../c-api/arg.rst:689 msgid "Convert a C :c:expr:`unsigned int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:663 +#: ../../c-api/arg.rst:692 msgid "Convert a C :c:expr:`unsigned long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:666 +#: ../../c-api/arg.rst:695 msgid "Convert a C :c:expr:`long long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`long long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:671 +#: ../../c-api/arg.rst:700 msgid "Convert a C :c:expr:`unsigned long long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned long long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:674 +#: ../../c-api/arg.rst:703 msgid "Convert a C :c:type:`Py_ssize_t` to a Python integer." msgstr "將一個 C 的 :c:type:`Py_ssize_t` 轉換成 Python 整數。" -#: ../../c-api/arg.rst:677 +#: ../../c-api/arg.rst:706 msgid "Convert a C :c:expr:`int` to a Python :class:`bool` object." msgstr "將一個 C 的 :c:expr:`int` 轉換成 Python :class:`bool` 物件。" -#: ../../c-api/arg.rst:679 +#: ../../c-api/arg.rst:708 msgid "" "Be aware that this format requires an ``int`` argument. Unlike most other " "contexts in C, variadic arguments are not coerced to a suitable type " @@ -1158,11 +1173,11 @@ msgid "" "float) to a suitable ``int`` value using ``(x) ? 1 : 0`` or ``!!x``." msgstr "" -#: ../../c-api/arg.rst:687 +#: ../../c-api/arg.rst:716 msgid "``c`` (:class:`bytes` of length 1) [char]" msgstr "``c`` (長度為 1 的 :class:`bytes`) [char]" -#: ../../c-api/arg.rst:688 +#: ../../c-api/arg.rst:717 msgid "" "Convert a C :c:expr:`int` representing a byte to a Python :class:`bytes` " "object of length 1." @@ -1170,7 +1185,7 @@ msgstr "" "將一個 C 中代表一個位元組的 :c:expr:`int` 轉換成 Python 中長度為一的 :class:" "`bytes`。" -#: ../../c-api/arg.rst:692 +#: ../../c-api/arg.rst:721 msgid "" "Convert a C :c:expr:`int` representing a character to Python :class:`str` " "object of length 1." @@ -1178,23 +1193,23 @@ msgstr "" "將一個 C 中代表一個字元的 :c:expr:`int` 轉換成 Python 中長度為一的 :class:" "`str`。" -#: ../../c-api/arg.rst:696 +#: ../../c-api/arg.rst:725 msgid "Convert a C :c:expr:`double` to a Python floating-point number." msgstr "將一個 C 的 :c:expr:`double` 轉換成 Python 浮點數。" -#: ../../c-api/arg.rst:699 +#: ../../c-api/arg.rst:728 msgid "Convert a C :c:expr:`float` to a Python floating-point number." msgstr "將一個 C 的 :c:expr:`float` 轉換成 Python 浮點數。" -#: ../../c-api/arg.rst:701 +#: ../../c-api/arg.rst:730 msgid "``D`` (:class:`complex`) [Py_complex \\*]" msgstr "``D`` (:class:`complex`) [Py_complex \\*]" -#: ../../c-api/arg.rst:702 +#: ../../c-api/arg.rst:731 msgid "Convert a C :c:type:`Py_complex` structure to a Python complex number." msgstr "將一個 C 的 :c:type:`Py_complex` 結構轉換成 Python 複數。" -#: ../../c-api/arg.rst:705 +#: ../../c-api/arg.rst:734 msgid "" "Pass a Python object untouched but create a new :term:`strong reference` to " "it (i.e. its reference count is incremented by one). If the object passed in " @@ -1204,30 +1219,30 @@ msgid "" "no exception has been raised yet, :exc:`SystemError` is set." msgstr "" -#: ../../c-api/arg.rst:714 +#: ../../c-api/arg.rst:743 msgid "``S`` (object) [PyObject \\*]" msgstr "``S`` (object) [PyObject \\*]" -#: ../../c-api/arg.rst:715 +#: ../../c-api/arg.rst:744 msgid "Same as ``O``." msgstr "和 ``O`` 相同。" -#: ../../c-api/arg.rst:717 +#: ../../c-api/arg.rst:746 msgid "``N`` (object) [PyObject \\*]" msgstr "``N`` (object) [PyObject \\*]" -#: ../../c-api/arg.rst:718 +#: ../../c-api/arg.rst:747 msgid "" "Same as ``O``, except it doesn't create a new :term:`strong reference`. " "Useful when the object is created by a call to an object constructor in the " "argument list." msgstr "" -#: ../../c-api/arg.rst:722 +#: ../../c-api/arg.rst:751 msgid "``O&`` (object) [*converter*, *anything*]" msgstr "``O&`` (object) [*converter*, *anything*]" -#: ../../c-api/arg.rst:723 +#: ../../c-api/arg.rst:752 msgid "" "Convert *anything* to a Python object through a *converter* function. The " "function is called with *anything* (which should be compatible with :c:expr:" @@ -1235,45 +1250,72 @@ msgid "" "``NULL`` if an error occurred." msgstr "" -#: ../../c-api/arg.rst:728 +#: ../../c-api/arg.rst:757 msgid "``(items)`` (:class:`tuple`) [*matching-items*]" msgstr "``(items)`` (:class:`tuple`) [*matching-items*]" -#: ../../c-api/arg.rst:729 +#: ../../c-api/arg.rst:758 msgid "" "Convert a sequence of C values to a Python tuple with the same number of " "items." msgstr "" -#: ../../c-api/arg.rst:731 +#: ../../c-api/arg.rst:760 msgid "``[items]`` (:class:`list`) [*matching-items*]" msgstr "``[items]`` (:class:`list`) [*matching-items*]" -#: ../../c-api/arg.rst:732 +#: ../../c-api/arg.rst:761 msgid "" "Convert a sequence of C values to a Python list with the same number of " "items." msgstr "" -#: ../../c-api/arg.rst:734 +#: ../../c-api/arg.rst:763 msgid "``{items}`` (:class:`dict`) [*matching-items*]" msgstr "``{items}`` (:class:`dict`) [*matching-items*]" -#: ../../c-api/arg.rst:735 +#: ../../c-api/arg.rst:764 msgid "" "Convert a sequence of C values to a Python dictionary. Each pair of " "consecutive C values adds one item to the dictionary, serving as key and " "value, respectively." msgstr "" -#: ../../c-api/arg.rst:739 +#: ../../c-api/arg.rst:768 msgid "" "If there is an error in the format string, the :exc:`SystemError` exception " "is set and ``NULL`` returned." msgstr "" -#: ../../c-api/arg.rst:744 +#: ../../c-api/arg.rst:773 msgid "" "Identical to :c:func:`Py_BuildValue`, except that it accepts a va_list " "rather than a variable number of arguments." msgstr "" + +#~ msgid "" +#~ "Convert a Python integer to a C :c:expr:`unsigned short int`, without " +#~ "overflow checking." +#~ msgstr "" +#~ "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned short int`,轉換過程無溢位" +#~ "檢查。" + +#~ msgid "" +#~ "Convert a Python integer to a C :c:expr:`unsigned int`, without overflow " +#~ "checking." +#~ msgstr "" +#~ "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned int`,轉換過程無溢位檢查。" + +#~ msgid "" +#~ "Convert a Python integer to a C :c:expr:`unsigned long` without overflow " +#~ "checking." +#~ msgstr "" +#~ "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long`,轉換過程無溢位檢" +#~ "查。" + +#~ msgid "" +#~ "Convert a Python integer to a C :c:expr:`unsigned long long` without " +#~ "overflow checking." +#~ msgstr "" +#~ "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long long`,轉換過程無溢位" +#~ "檢查。" diff --git a/c-api/buffer.po b/c-api/buffer.po index ed2f994477f..f733421607b 100644 --- a/c-api/buffer.po +++ b/c-api/buffer.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-08 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:30+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,7 +21,7 @@ msgstr "" msgid "Buffer Protocol" msgstr "緩衝協定 (Buffer Protocol)" -#: ../../c-api/buffer.rst:18 +#: ../../c-api/buffer.rst:13 msgid "" "Certain objects available in Python wrap access to an underlying memory " "array or *buffer*. Such objects include the built-in :class:`bytes` and :" @@ -30,7 +30,7 @@ msgid "" "image processing or numeric analysis." msgstr "" -#: ../../c-api/buffer.rst:24 +#: ../../c-api/buffer.rst:19 msgid "" "While each of these types have their own semantics, they share the common " "characteristic of being backed by a possibly large memory buffer. It is " @@ -38,13 +38,13 @@ msgid "" "without intermediate copying." msgstr "" -#: ../../c-api/buffer.rst:29 +#: ../../c-api/buffer.rst:24 msgid "" "Python provides such a facility at the C and Python level in the form of " "the :ref:`buffer protocol `. This protocol has two sides:" msgstr "" -#: ../../c-api/buffer.rst:34 +#: ../../c-api/buffer.rst:29 msgid "" "on the producer side, a type can export a \"buffer interface\" which allows " "objects of that type to expose information about their underlying buffer. " @@ -52,14 +52,14 @@ msgid "" "see :ref:`python-buffer-protocol`." msgstr "" -#: ../../c-api/buffer.rst:39 +#: ../../c-api/buffer.rst:34 msgid "" "on the consumer side, several means are available to obtain a pointer to the " "raw underlying data of an object (for example a method parameter). For " "Python see :class:`memoryview`." msgstr "" -#: ../../c-api/buffer.rst:43 +#: ../../c-api/buffer.rst:38 msgid "" "Simple objects such as :class:`bytes` and :class:`bytearray` expose their " "underlying buffer in byte-oriented form. Other forms are possible; for " @@ -67,7 +67,7 @@ msgid "" "values." msgstr "" -#: ../../c-api/buffer.rst:47 +#: ../../c-api/buffer.rst:42 msgid "" "An example consumer of the buffer interface is the :meth:`~io.BufferedIOBase." "write` method of file objects: any object that can export a series of bytes " @@ -79,40 +79,40 @@ msgid "" "buffers." msgstr "" -#: ../../c-api/buffer.rst:55 +#: ../../c-api/buffer.rst:50 msgid "" "There are two ways for a consumer of the buffer interface to acquire a " "buffer over a target object:" msgstr "" -#: ../../c-api/buffer.rst:58 +#: ../../c-api/buffer.rst:53 msgid "call :c:func:`PyObject_GetBuffer` with the right parameters;" msgstr "以適當的參數呼叫 :c:func:`PyObject_GetBuffer`;" -#: ../../c-api/buffer.rst:60 +#: ../../c-api/buffer.rst:55 msgid "" "call :c:func:`PyArg_ParseTuple` (or one of its siblings) with one of the " "``y*``, ``w*`` or ``s*`` :ref:`format codes `." msgstr "" -#: ../../c-api/buffer.rst:63 +#: ../../c-api/buffer.rst:58 msgid "" "In both cases, :c:func:`PyBuffer_Release` must be called when the buffer " "isn't needed anymore. Failure to do so could lead to various issues such as " "resource leaks." msgstr "" -#: ../../c-api/buffer.rst:69 +#: ../../c-api/buffer.rst:64 msgid "" "The buffer protocol is now accessible in Python, see :ref:`python-buffer-" "protocol` and :class:`memoryview`." msgstr "" -#: ../../c-api/buffer.rst:75 +#: ../../c-api/buffer.rst:70 msgid "Buffer structure" msgstr "緩衝區結構" -#: ../../c-api/buffer.rst:77 +#: ../../c-api/buffer.rst:72 msgid "" "Buffer structures (or simply \"buffers\") are useful as a way to expose the " "binary data from another object to the Python programmer. They can also be " @@ -124,7 +124,7 @@ msgid "" "in its native, in-memory format." msgstr "" -#: ../../c-api/buffer.rst:86 +#: ../../c-api/buffer.rst:81 msgid "" "Contrary to most data types exposed by the Python interpreter, buffers are " "not :c:type:`PyObject` pointers but rather simple C structures. This allows " @@ -133,14 +133,14 @@ msgid "" "created." msgstr "" -#: ../../c-api/buffer.rst:92 +#: ../../c-api/buffer.rst:87 msgid "" "For short instructions how to write an exporting object, see :ref:`Buffer " "Object Structures `. For obtaining a buffer, see :c:func:" "`PyObject_GetBuffer`." msgstr "" -#: ../../c-api/buffer.rst:100 +#: ../../c-api/buffer.rst:95 msgid "" "A pointer to the start of the logical structure described by the buffer " "fields. This can be any location within the underlying physical memory block " @@ -148,13 +148,13 @@ msgid "" "the value may point to the end of the memory block." msgstr "" -#: ../../c-api/buffer.rst:105 +#: ../../c-api/buffer.rst:100 msgid "" "For :term:`contiguous` arrays, the value points to the beginning of the " "memory block." msgstr "" -#: ../../c-api/buffer.rst:110 +#: ../../c-api/buffer.rst:105 msgid "" "A new reference to the exporting object. The reference is owned by the " "consumer and automatically released (i.e. reference count decremented) and " @@ -162,14 +162,14 @@ msgid "" "of the return value of any standard C-API function." msgstr "" -#: ../../c-api/buffer.rst:117 +#: ../../c-api/buffer.rst:112 msgid "" "As a special case, for *temporary* buffers that are wrapped by :c:func:" "`PyMemoryView_FromBuffer` or :c:func:`PyBuffer_FillInfo` this field is " "``NULL``. In general, exporting objects MUST NOT use this scheme." msgstr "" -#: ../../c-api/buffer.rst:124 +#: ../../c-api/buffer.rst:119 msgid "" "``product(shape) * itemsize``. For contiguous arrays, this is the length of " "the underlying memory block. For non-contiguous arrays, it is the length " @@ -177,7 +177,7 @@ msgid "" "representation." msgstr "" -#: ../../c-api/buffer.rst:129 +#: ../../c-api/buffer.rst:124 msgid "" "Accessing ``((char *)buf)[0] up to ((char *)buf)[len-1]`` is only valid if " "the buffer has been obtained by a request that guarantees contiguity. In " @@ -185,19 +185,19 @@ msgid "" "`PyBUF_WRITABLE`." msgstr "" -#: ../../c-api/buffer.rst:135 +#: ../../c-api/buffer.rst:130 msgid "" "An indicator of whether the buffer is read-only. This field is controlled by " "the :c:macro:`PyBUF_WRITABLE` flag." msgstr "" -#: ../../c-api/buffer.rst:140 +#: ../../c-api/buffer.rst:135 msgid "" "Item size in bytes of a single element. Same as the value of :func:`struct." "calcsize` called on non-``NULL`` :c:member:`~Py_buffer.format` values." msgstr "" -#: ../../c-api/buffer.rst:143 +#: ../../c-api/buffer.rst:138 msgid "" "Important exception: If a consumer requests a buffer without the :c:macro:" "`PyBUF_FORMAT` flag, :c:member:`~Py_buffer.format` will be set to " @@ -205,32 +205,32 @@ msgid "" "original format." msgstr "" -#: ../../c-api/buffer.rst:148 +#: ../../c-api/buffer.rst:143 msgid "" "If :c:member:`~Py_buffer.shape` is present, the equality ``product(shape) * " "itemsize == len`` still holds and the consumer can use :c:member:`~Py_buffer." "itemsize` to navigate the buffer." msgstr "" -#: ../../c-api/buffer.rst:152 +#: ../../c-api/buffer.rst:147 msgid "" "If :c:member:`~Py_buffer.shape` is ``NULL`` as a result of a :c:macro:" "`PyBUF_SIMPLE` or a :c:macro:`PyBUF_WRITABLE` request, the consumer must " "disregard :c:member:`~Py_buffer.itemsize` and assume ``itemsize == 1``." msgstr "" -#: ../../c-api/buffer.rst:158 +#: ../../c-api/buffer.rst:153 msgid "" "A *NULL* terminated string in :mod:`struct` module style syntax describing " "the contents of a single item. If this is ``NULL``, ``\"B\"`` (unsigned " "bytes) is assumed." msgstr "" -#: ../../c-api/buffer.rst:162 +#: ../../c-api/buffer.rst:157 msgid "This field is controlled by the :c:macro:`PyBUF_FORMAT` flag." msgstr "此欄位受 :c:macro:`PyBUF_FORMAT` 旗標控制。" -#: ../../c-api/buffer.rst:166 +#: ../../c-api/buffer.rst:161 msgid "" "The number of dimensions the memory represents as an n-dimensional array. If " "it is ``0``, :c:member:`~Py_buffer.buf` points to a single item representing " @@ -239,7 +239,7 @@ msgid "" "number of dimensions is given by :c:macro:`PyBUF_MAX_NDIM`." msgstr "" -#: ../../c-api/buffer.rst:174 +#: ../../c-api/buffer.rst:169 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim` " "indicating the shape of the memory as an n-dimensional array. Note that " @@ -247,34 +247,34 @@ msgid "" "`~Py_buffer.len`." msgstr "" -#: ../../c-api/buffer.rst:179 +#: ../../c-api/buffer.rst:174 msgid "" "Shape values are restricted to ``shape[n] >= 0``. The case ``shape[n] == 0`` " "requires special attention. See `complex arrays`_ for further information." msgstr "" -#: ../../c-api/buffer.rst:183 +#: ../../c-api/buffer.rst:178 msgid "The shape array is read-only for the consumer." msgstr "" -#: ../../c-api/buffer.rst:187 +#: ../../c-api/buffer.rst:182 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim` " "giving the number of bytes to skip to get to a new element in each dimension." msgstr "" -#: ../../c-api/buffer.rst:191 +#: ../../c-api/buffer.rst:186 msgid "" "Stride values can be any integer. For regular arrays, strides are usually " "positive, but a consumer MUST be able to handle the case ``strides[n] <= " "0``. See `complex arrays`_ for further information." msgstr "" -#: ../../c-api/buffer.rst:195 +#: ../../c-api/buffer.rst:190 msgid "The strides array is read-only for the consumer." msgstr "" -#: ../../c-api/buffer.rst:199 +#: ../../c-api/buffer.rst:194 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim`. If " "``suboffsets[n] >= 0``, the values stored along the nth dimension are " @@ -283,24 +283,24 @@ msgid "" "that no de-referencing should occur (striding in a contiguous memory block)." msgstr "" -#: ../../c-api/buffer.rst:206 +#: ../../c-api/buffer.rst:201 msgid "" "If all suboffsets are negative (i.e. no de-referencing is needed), then this " "field must be ``NULL`` (the default value)." msgstr "" -#: ../../c-api/buffer.rst:209 +#: ../../c-api/buffer.rst:204 msgid "" "This type of array representation is used by the Python Imaging Library " "(PIL). See `complex arrays`_ for further information how to access elements " "of such an array." msgstr "" -#: ../../c-api/buffer.rst:213 +#: ../../c-api/buffer.rst:208 msgid "The suboffsets array is read-only for the consumer." msgstr "" -#: ../../c-api/buffer.rst:217 +#: ../../c-api/buffer.rst:212 msgid "" "This is for use internally by the exporting object. For example, this might " "be re-cast as an integer by the exporter and used to store flags about " @@ -308,22 +308,22 @@ msgid "" "the buffer is released. The consumer MUST NOT alter this value." msgstr "" -#: ../../c-api/buffer.rst:224 +#: ../../c-api/buffer.rst:219 msgid "Constants:" msgstr "常數:" -#: ../../c-api/buffer.rst:228 +#: ../../c-api/buffer.rst:223 msgid "" "The maximum number of dimensions the memory represents. Exporters MUST " "respect this limit, consumers of multi-dimensional buffers SHOULD be able to " "handle up to :c:macro:`!PyBUF_MAX_NDIM` dimensions. Currently set to 64." msgstr "" -#: ../../c-api/buffer.rst:237 +#: ../../c-api/buffer.rst:232 msgid "Buffer request types" msgstr "" -#: ../../c-api/buffer.rst:239 +#: ../../c-api/buffer.rst:234 msgid "" "Buffers are usually obtained by sending a buffer request to an exporting " "object via :c:func:`PyObject_GetBuffer`. Since the complexity of the logical " @@ -331,16 +331,16 @@ msgid "" "argument to specify the exact buffer type it can handle." msgstr "" -#: ../../c-api/buffer.rst:244 +#: ../../c-api/buffer.rst:239 msgid "" "All :c:type:`Py_buffer` fields are unambiguously defined by the request type." msgstr "" -#: ../../c-api/buffer.rst:248 +#: ../../c-api/buffer.rst:243 msgid "request-independent fields" msgstr "" -#: ../../c-api/buffer.rst:249 +#: ../../c-api/buffer.rst:244 msgid "" "The following fields are not influenced by *flags* and must always be filled " "in with the correct values: :c:member:`~Py_buffer.obj`, :c:member:" @@ -348,11 +348,11 @@ msgid "" "itemsize`, :c:member:`~Py_buffer.ndim`." msgstr "" -#: ../../c-api/buffer.rst:254 +#: ../../c-api/buffer.rst:249 msgid "readonly, format" msgstr "" -#: ../../c-api/buffer.rst:258 +#: ../../c-api/buffer.rst:253 msgid "" "Controls the :c:member:`~Py_buffer.readonly` field. If set, the exporter " "MUST provide a writable buffer or else report failure. Otherwise, the " @@ -361,17 +361,17 @@ msgid "" "PyBUF_WRITABLE` can be used to request a simple writable buffer." msgstr "" -#: ../../c-api/buffer.rst:266 +#: ../../c-api/buffer.rst:261 msgid "This is an alias to :c:macro:`PyBUF_WRITABLE`." msgstr "這是 :c:macro:`PyBUF_WRITABLE` 的別名。" -#: ../../c-api/buffer.rst:272 +#: ../../c-api/buffer.rst:267 msgid "" "Controls the :c:member:`~Py_buffer.format` field. If set, this field MUST be " "filled in correctly. Otherwise, this field MUST be ``NULL``." msgstr "" -#: ../../c-api/buffer.rst:276 +#: ../../c-api/buffer.rst:271 msgid "" ":c:macro:`PyBUF_WRITABLE` can be \\|'d to any of the flags in the next " "section. Since :c:macro:`PyBUF_SIMPLE` is defined as 0, :c:macro:" @@ -379,159 +379,159 @@ msgid "" "writable buffer." msgstr "" -#: ../../c-api/buffer.rst:280 +#: ../../c-api/buffer.rst:275 msgid "" ":c:macro:`PyBUF_FORMAT` must be \\|'d to any of the flags except :c:macro:" "`PyBUF_SIMPLE`, because the latter already implies format ``B`` (unsigned " "bytes). :c:macro:`!PyBUF_FORMAT` cannot be used on its own." msgstr "" -#: ../../c-api/buffer.rst:286 +#: ../../c-api/buffer.rst:281 msgid "shape, strides, suboffsets" msgstr "" -#: ../../c-api/buffer.rst:288 +#: ../../c-api/buffer.rst:283 msgid "" "The flags that control the logical structure of the memory are listed in " "decreasing order of complexity. Note that each flag contains all bits of the " "flags below it." msgstr "" -#: ../../c-api/buffer.rst:295 ../../c-api/buffer.rst:319 -#: ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:290 ../../c-api/buffer.rst:314 +#: ../../c-api/buffer.rst:339 msgid "Request" msgstr "" -#: ../../c-api/buffer.rst:295 ../../c-api/buffer.rst:319 -#: ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:290 ../../c-api/buffer.rst:314 +#: ../../c-api/buffer.rst:339 msgid "shape" msgstr "" -#: ../../c-api/buffer.rst:295 ../../c-api/buffer.rst:319 -#: ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:290 ../../c-api/buffer.rst:314 +#: ../../c-api/buffer.rst:339 msgid "strides" msgstr "" -#: ../../c-api/buffer.rst:295 ../../c-api/buffer.rst:319 -#: ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:290 ../../c-api/buffer.rst:314 +#: ../../c-api/buffer.rst:339 msgid "suboffsets" msgstr "" -#: ../../c-api/buffer.rst:297 ../../c-api/buffer.rst:299 -#: ../../c-api/buffer.rst:301 ../../c-api/buffer.rst:321 -#: ../../c-api/buffer.rst:323 ../../c-api/buffer.rst:325 -#: ../../c-api/buffer.rst:327 ../../c-api/buffer.rst:346 -#: ../../c-api/buffer.rst:348 ../../c-api/buffer.rst:350 -#: ../../c-api/buffer.rst:352 ../../c-api/buffer.rst:354 -#: ../../c-api/buffer.rst:356 ../../c-api/buffer.rst:358 -#: ../../c-api/buffer.rst:360 +#: ../../c-api/buffer.rst:292 ../../c-api/buffer.rst:294 +#: ../../c-api/buffer.rst:296 ../../c-api/buffer.rst:316 +#: ../../c-api/buffer.rst:318 ../../c-api/buffer.rst:320 +#: ../../c-api/buffer.rst:322 ../../c-api/buffer.rst:341 +#: ../../c-api/buffer.rst:343 ../../c-api/buffer.rst:345 +#: ../../c-api/buffer.rst:347 ../../c-api/buffer.rst:349 +#: ../../c-api/buffer.rst:351 ../../c-api/buffer.rst:353 +#: ../../c-api/buffer.rst:355 msgid "yes" msgstr "" -#: ../../c-api/buffer.rst:297 ../../c-api/buffer.rst:346 -#: ../../c-api/buffer.rst:348 +#: ../../c-api/buffer.rst:292 ../../c-api/buffer.rst:341 +#: ../../c-api/buffer.rst:343 msgid "if needed" msgstr "" -#: ../../c-api/buffer.rst:299 ../../c-api/buffer.rst:301 -#: ../../c-api/buffer.rst:303 ../../c-api/buffer.rst:321 -#: ../../c-api/buffer.rst:323 ../../c-api/buffer.rst:325 -#: ../../c-api/buffer.rst:327 ../../c-api/buffer.rst:350 -#: ../../c-api/buffer.rst:352 ../../c-api/buffer.rst:354 -#: ../../c-api/buffer.rst:356 ../../c-api/buffer.rst:358 -#: ../../c-api/buffer.rst:360 +#: ../../c-api/buffer.rst:294 ../../c-api/buffer.rst:296 +#: ../../c-api/buffer.rst:298 ../../c-api/buffer.rst:316 +#: ../../c-api/buffer.rst:318 ../../c-api/buffer.rst:320 +#: ../../c-api/buffer.rst:322 ../../c-api/buffer.rst:345 +#: ../../c-api/buffer.rst:347 ../../c-api/buffer.rst:349 +#: ../../c-api/buffer.rst:351 ../../c-api/buffer.rst:353 +#: ../../c-api/buffer.rst:355 msgid "NULL" msgstr "NULL" -#: ../../c-api/buffer.rst:310 +#: ../../c-api/buffer.rst:305 msgid "contiguity requests" msgstr "" -#: ../../c-api/buffer.rst:312 +#: ../../c-api/buffer.rst:307 msgid "" "C or Fortran :term:`contiguity ` can be explicitly requested, " "with and without stride information. Without stride information, the buffer " "must be C-contiguous." msgstr "" -#: ../../c-api/buffer.rst:319 ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:314 ../../c-api/buffer.rst:339 msgid "contig" msgstr "" -#: ../../c-api/buffer.rst:321 ../../c-api/buffer.rst:327 -#: ../../c-api/buffer.rst:358 ../../c-api/buffer.rst:360 +#: ../../c-api/buffer.rst:316 ../../c-api/buffer.rst:322 +#: ../../c-api/buffer.rst:353 ../../c-api/buffer.rst:355 msgid "C" msgstr "C" -#: ../../c-api/buffer.rst:323 +#: ../../c-api/buffer.rst:318 msgid "F" msgstr "F" -#: ../../c-api/buffer.rst:325 +#: ../../c-api/buffer.rst:320 msgid "C or F" msgstr "C 或 F" -#: ../../c-api/buffer.rst:327 +#: ../../c-api/buffer.rst:322 msgid ":c:macro:`PyBUF_ND`" msgstr ":c:macro:`PyBUF_ND`" -#: ../../c-api/buffer.rst:332 +#: ../../c-api/buffer.rst:327 msgid "compound requests" msgstr "" -#: ../../c-api/buffer.rst:334 +#: ../../c-api/buffer.rst:329 msgid "" "All possible requests are fully defined by some combination of the flags in " "the previous section. For convenience, the buffer protocol provides " "frequently used combinations as single flags." msgstr "" -#: ../../c-api/buffer.rst:338 +#: ../../c-api/buffer.rst:333 msgid "" "In the following table *U* stands for undefined contiguity. The consumer " "would have to call :c:func:`PyBuffer_IsContiguous` to determine contiguity." msgstr "" -#: ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:339 msgid "readonly" msgstr "" -#: ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:339 msgid "format" msgstr "" -#: ../../c-api/buffer.rst:346 ../../c-api/buffer.rst:348 -#: ../../c-api/buffer.rst:350 ../../c-api/buffer.rst:352 -#: ../../c-api/buffer.rst:354 ../../c-api/buffer.rst:356 +#: ../../c-api/buffer.rst:341 ../../c-api/buffer.rst:343 +#: ../../c-api/buffer.rst:345 ../../c-api/buffer.rst:347 +#: ../../c-api/buffer.rst:349 ../../c-api/buffer.rst:351 msgid "U" msgstr "U" -#: ../../c-api/buffer.rst:346 ../../c-api/buffer.rst:350 -#: ../../c-api/buffer.rst:354 ../../c-api/buffer.rst:358 +#: ../../c-api/buffer.rst:341 ../../c-api/buffer.rst:345 +#: ../../c-api/buffer.rst:349 ../../c-api/buffer.rst:353 msgid "0" msgstr "0" -#: ../../c-api/buffer.rst:348 ../../c-api/buffer.rst:352 -#: ../../c-api/buffer.rst:356 ../../c-api/buffer.rst:360 +#: ../../c-api/buffer.rst:343 ../../c-api/buffer.rst:347 +#: ../../c-api/buffer.rst:351 ../../c-api/buffer.rst:355 msgid "1 or 0" msgstr "1 或 0" -#: ../../c-api/buffer.rst:365 +#: ../../c-api/buffer.rst:360 msgid "Complex arrays" msgstr "" -#: ../../c-api/buffer.rst:368 +#: ../../c-api/buffer.rst:363 msgid "NumPy-style: shape and strides" msgstr "NumPy 風格:形狀與步幅" -#: ../../c-api/buffer.rst:370 +#: ../../c-api/buffer.rst:365 msgid "" "The logical structure of NumPy-style arrays is defined by :c:member:" "`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`, :c:member:`~Py_buffer." "shape` and :c:member:`~Py_buffer.strides`." msgstr "" -#: ../../c-api/buffer.rst:373 +#: ../../c-api/buffer.rst:368 msgid "" "If ``ndim == 0``, the memory location pointed to by :c:member:`~Py_buffer." "buf` is interpreted as a scalar of size :c:member:`~Py_buffer.itemsize`. In " @@ -539,14 +539,14 @@ msgid "" "strides` are ``NULL``." msgstr "" -#: ../../c-api/buffer.rst:377 +#: ../../c-api/buffer.rst:372 msgid "" "If :c:member:`~Py_buffer.strides` is ``NULL``, the array is interpreted as a " "standard n-dimensional C-array. Otherwise, the consumer must access an n-" "dimensional array as follows:" msgstr "" -#: ../../c-api/buffer.rst:381 +#: ../../c-api/buffer.rst:376 msgid "" "ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * " "strides[n-1];\n" @@ -556,14 +556,14 @@ msgstr "" "strides[n-1];\n" "item = *((typeof(item) *)ptr);" -#: ../../c-api/buffer.rst:387 +#: ../../c-api/buffer.rst:382 msgid "" "As noted above, :c:member:`~Py_buffer.buf` can point to any location within " "the actual memory block. An exporter can check the validity of a buffer with " "this function:" msgstr "" -#: ../../c-api/buffer.rst:391 +#: ../../c-api/buffer.rst:386 msgid "" "def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n" " \"\"\"Verify that the parameters represent a valid array within\n" @@ -592,11 +592,11 @@ msgid "" " return 0 <= offset+imin and offset+imax+itemsize <= memlen" msgstr "" -#: ../../c-api/buffer.rst:421 +#: ../../c-api/buffer.rst:416 msgid "PIL-style: shape, strides and suboffsets" msgstr "" -#: ../../c-api/buffer.rst:423 +#: ../../c-api/buffer.rst:418 msgid "" "In addition to the regular items, PIL-style arrays can contain pointers that " "must be followed in order to get to the next element in a dimension. For " @@ -607,14 +607,14 @@ msgid "" "x[2][3]`` arrays that can be located anywhere in memory." msgstr "" -#: ../../c-api/buffer.rst:432 +#: ../../c-api/buffer.rst:427 msgid "" "Here is a function that returns a pointer to the element in an N-D array " "pointed to by an N-dimensional index when there are both non-``NULL`` " "strides and suboffsets::" msgstr "" -#: ../../c-api/buffer.rst:436 +#: ../../c-api/buffer.rst:431 msgid "" "void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n" " Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n" @@ -642,25 +642,25 @@ msgstr "" " return (void*)pointer;\n" "}" -#: ../../c-api/buffer.rst:451 +#: ../../c-api/buffer.rst:446 msgid "Buffer-related functions" msgstr "與緩衝相關的函式" -#: ../../c-api/buffer.rst:455 +#: ../../c-api/buffer.rst:450 msgid "" "Return ``1`` if *obj* supports the buffer interface otherwise ``0``. When " "``1`` is returned, it doesn't guarantee that :c:func:`PyObject_GetBuffer` " "will succeed. This function always succeeds." msgstr "" -#: ../../c-api/buffer.rst:462 +#: ../../c-api/buffer.rst:457 msgid "" "Send a request to *exporter* to fill in *view* as specified by *flags*. If " "the exporter cannot provide a buffer of the exact type, it MUST raise :exc:" "`BufferError`, set ``view->obj`` to ``NULL`` and return ``-1``." msgstr "" -#: ../../c-api/buffer.rst:467 +#: ../../c-api/buffer.rst:462 msgid "" "On success, fill in *view*, set ``view->obj`` to a new reference to " "*exporter* and return 0. In the case of chained buffer providers that " @@ -668,7 +668,7 @@ msgid "" "instead of *exporter* (See :ref:`Buffer Object Structures `)." msgstr "" -#: ../../c-api/buffer.rst:472 +#: ../../c-api/buffer.rst:467 msgid "" "Successful calls to :c:func:`PyObject_GetBuffer` must be paired with calls " "to :c:func:`PyBuffer_Release`, similar to :c:func:`malloc` and :c:func:" @@ -676,7 +676,7 @@ msgid "" "`PyBuffer_Release` must be called exactly once." msgstr "" -#: ../../c-api/buffer.rst:480 +#: ../../c-api/buffer.rst:475 msgid "" "Release the buffer *view* and release the :term:`strong reference` (i.e. " "decrement the reference count) to the view's supporting object, ``view-" @@ -684,19 +684,19 @@ msgid "" "used, otherwise reference leaks may occur." msgstr "" -#: ../../c-api/buffer.rst:485 +#: ../../c-api/buffer.rst:480 msgid "" "It is an error to call this function on a buffer that was not obtained via :" "c:func:`PyObject_GetBuffer`." msgstr "" -#: ../../c-api/buffer.rst:491 +#: ../../c-api/buffer.rst:486 msgid "" "Return the implied :c:member:`~Py_buffer.itemsize` from :c:member:" "`~Py_buffer.format`. On error, raise an exception and return -1." msgstr "" -#: ../../c-api/buffer.rst:499 +#: ../../c-api/buffer.rst:494 msgid "" "Return ``1`` if the memory defined by the *view* is C-style (*order* is " "``'C'``) or Fortran-style (*order* is ``'F'``) :term:`contiguous` or either " @@ -704,69 +704,69 @@ msgid "" "succeeds." msgstr "" -#: ../../c-api/buffer.rst:506 +#: ../../c-api/buffer.rst:501 msgid "" "Get the memory area pointed to by the *indices* inside the given *view*. " "*indices* must point to an array of ``view->ndim`` indices." msgstr "" -#: ../../c-api/buffer.rst:512 +#: ../../c-api/buffer.rst:507 msgid "" -"Copy contiguous *len* bytes from *buf* to *view*. *fort* can be ``'C'`` or " -"``'F'`` (for C-style or Fortran-style ordering). ``0`` is returned on " -"success, ``-1`` on error." +"Copy contiguous *len* bytes from *buf* to *view*. *order* can be ``'C'`` or " +"``'F'`` or ``'A'`` (for C-style or Fortran-style ordering or either one). " +"``0`` is returned on success, ``-1`` on error." msgstr "" -#: ../../c-api/buffer.rst:519 +#: ../../c-api/buffer.rst:515 msgid "" "Copy *len* bytes from *src* to its contiguous representation in *buf*. " "*order* can be ``'C'`` or ``'F'`` or ``'A'`` (for C-style or Fortran-style " "ordering or either one). ``0`` is returned on success, ``-1`` on error." msgstr "" -#: ../../c-api/buffer.rst:523 +#: ../../c-api/buffer.rst:519 msgid "This function fails if *len* != *src->len*." msgstr "此函式在 *len* != *src->len* 時失敗。" -#: ../../c-api/buffer.rst:528 +#: ../../c-api/buffer.rst:524 msgid "" "Copy data from *src* to *dest* buffer. Can convert between C-style and or " "Fortran-style buffers." msgstr "" -#: ../../c-api/buffer.rst:531 +#: ../../c-api/buffer.rst:527 msgid "``0`` is returned on success, ``-1`` on error." msgstr "成功時回傳 ``0``,錯誤時回傳 ``-1``。" -#: ../../c-api/buffer.rst:535 +#: ../../c-api/buffer.rst:531 msgid "" "Fill the *strides* array with byte-strides of a :term:`contiguous` (C-style " "if *order* is ``'C'`` or Fortran-style if *order* is ``'F'``) array of the " "given shape with the given number of bytes per element." msgstr "" -#: ../../c-api/buffer.rst:542 +#: ../../c-api/buffer.rst:538 msgid "" "Handle buffer requests for an exporter that wants to expose *buf* of size " "*len* with writability set according to *readonly*. *buf* is interpreted as " "a sequence of unsigned bytes." msgstr "" -#: ../../c-api/buffer.rst:546 +#: ../../c-api/buffer.rst:542 msgid "" "The *flags* argument indicates the request type. This function always fills " "in *view* as specified by flags, unless *buf* has been designated as read-" "only and :c:macro:`PyBUF_WRITABLE` is set in *flags*." msgstr "" -#: ../../c-api/buffer.rst:550 +#: ../../c-api/buffer.rst:546 msgid "" "On success, set ``view->obj`` to a new reference to *exporter* and return 0. " "Otherwise, raise :exc:`BufferError`, set ``view->obj`` to ``NULL`` and " "return ``-1``;" msgstr "" -#: ../../c-api/buffer.rst:554 +#: ../../c-api/buffer.rst:550 msgid "" "If this function is used as part of a :ref:`getbufferproc `, " "*exporter* MUST be set to the exporting object and *flags* must be passed " @@ -789,18 +789,18 @@ msgstr "(請見緩衝協定)" msgid "buffer object" msgstr "buffer object(緩衝物件)" -#: ../../c-api/buffer.rst:32 +#: ../../c-api/buffer.rst:27 msgid "PyBufferProcs (C type)" msgstr "PyBufferProcs(C 型別)" -#: ../../c-api/buffer.rst:307 +#: ../../c-api/buffer.rst:302 msgid "contiguous" msgstr "contiguous(連續的)" -#: ../../c-api/buffer.rst:307 +#: ../../c-api/buffer.rst:302 msgid "C-contiguous" msgstr "C-contiguous(C 連續的)" -#: ../../c-api/buffer.rst:307 +#: ../../c-api/buffer.rst:302 msgid "Fortran contiguous" msgstr "Fortran contiguous(Fortran 連續的)" diff --git a/c-api/bytes.po b/c-api/bytes.po index 66499d06ff0..ea99b778248 100644 --- a/c-api/bytes.po +++ b/c-api/bytes.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-16 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:04+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -71,7 +71,13 @@ msgid "" "of the bytes object are uninitialized." msgstr "" -#: ../../c-api/bytes.rst:60 +#: ../../c-api/bytes.rst:57 +msgid "" +"Use the :c:type:`PyBytesWriter` API instead of " +"``PyBytes_FromStringAndSize(NULL, len)``." +msgstr "" + +#: ../../c-api/bytes.rst:64 msgid "" "Take a C :c:func:`printf`\\ -style *format* string and a variable number of " "arguments, calculate the size of the resulting Python bytes object and " @@ -81,193 +87,193 @@ msgid "" "allowed:" msgstr "" -#: ../../c-api/bytes.rst:72 +#: ../../c-api/bytes.rst:76 msgid "Format Characters" msgstr "" -#: ../../c-api/bytes.rst:72 +#: ../../c-api/bytes.rst:76 msgid "Type" msgstr "" -#: ../../c-api/bytes.rst:72 +#: ../../c-api/bytes.rst:76 msgid "Comment" msgstr "" -#: ../../c-api/bytes.rst:74 +#: ../../c-api/bytes.rst:78 msgid "``%%``" msgstr "``%%``" -#: ../../c-api/bytes.rst:74 +#: ../../c-api/bytes.rst:78 msgid "*n/a*" msgstr "*n/a*" -#: ../../c-api/bytes.rst:74 +#: ../../c-api/bytes.rst:78 msgid "The literal % character." msgstr "" -#: ../../c-api/bytes.rst:76 +#: ../../c-api/bytes.rst:80 msgid "``%c``" msgstr "``%c``" -#: ../../c-api/bytes.rst:76 ../../c-api/bytes.rst:79 ../../c-api/bytes.rst:97 -#: ../../c-api/bytes.rst:100 +#: ../../c-api/bytes.rst:80 ../../c-api/bytes.rst:83 ../../c-api/bytes.rst:101 +#: ../../c-api/bytes.rst:104 msgid "int" msgstr "int" -#: ../../c-api/bytes.rst:76 +#: ../../c-api/bytes.rst:80 msgid "A single byte, represented as a C int." msgstr "" -#: ../../c-api/bytes.rst:79 +#: ../../c-api/bytes.rst:83 msgid "``%d``" msgstr "``%d``" -#: ../../c-api/bytes.rst:79 +#: ../../c-api/bytes.rst:83 msgid "Equivalent to ``printf(\"%d\")``. [1]_" msgstr "等價於 ``printf(\"%d\")``. [1]_" -#: ../../c-api/bytes.rst:82 +#: ../../c-api/bytes.rst:86 msgid "``%u``" msgstr "``%u``" -#: ../../c-api/bytes.rst:82 +#: ../../c-api/bytes.rst:86 msgid "unsigned int" msgstr "unsigned int" -#: ../../c-api/bytes.rst:82 +#: ../../c-api/bytes.rst:86 msgid "Equivalent to ``printf(\"%u\")``. [1]_" msgstr "等價於 ``printf(\"%u\")``. [1]_" -#: ../../c-api/bytes.rst:85 +#: ../../c-api/bytes.rst:89 msgid "``%ld``" msgstr "``%ld``" -#: ../../c-api/bytes.rst:85 +#: ../../c-api/bytes.rst:89 msgid "long" msgstr "long" -#: ../../c-api/bytes.rst:85 +#: ../../c-api/bytes.rst:89 msgid "Equivalent to ``printf(\"%ld\")``. [1]_" msgstr "等價於 ``printf(\"%ld\")``. [1]_" -#: ../../c-api/bytes.rst:88 +#: ../../c-api/bytes.rst:92 msgid "``%lu``" msgstr "``%lu``" -#: ../../c-api/bytes.rst:88 +#: ../../c-api/bytes.rst:92 msgid "unsigned long" msgstr "unsigned long" -#: ../../c-api/bytes.rst:88 +#: ../../c-api/bytes.rst:92 msgid "Equivalent to ``printf(\"%lu\")``. [1]_" msgstr "等價於 ``printf(\"%lu\")``. [1]_" -#: ../../c-api/bytes.rst:91 +#: ../../c-api/bytes.rst:95 msgid "``%zd``" msgstr "``%zd``" -#: ../../c-api/bytes.rst:91 +#: ../../c-api/bytes.rst:95 msgid ":c:type:`\\ Py_ssize_t`" msgstr ":c:type:`\\ Py_ssize_t`" -#: ../../c-api/bytes.rst:91 +#: ../../c-api/bytes.rst:95 msgid "Equivalent to ``printf(\"%zd\")``. [1]_" msgstr "等價於 ``printf(\"%zd\")``. [1]_" -#: ../../c-api/bytes.rst:94 +#: ../../c-api/bytes.rst:98 msgid "``%zu``" msgstr "``%zu``" -#: ../../c-api/bytes.rst:94 +#: ../../c-api/bytes.rst:98 msgid "size_t" msgstr "size_t" -#: ../../c-api/bytes.rst:94 +#: ../../c-api/bytes.rst:98 msgid "Equivalent to ``printf(\"%zu\")``. [1]_" msgstr "等價於 ``printf(\"%zu\")``. [1]_" -#: ../../c-api/bytes.rst:97 +#: ../../c-api/bytes.rst:101 msgid "``%i``" msgstr "``%i``" -#: ../../c-api/bytes.rst:97 +#: ../../c-api/bytes.rst:101 msgid "Equivalent to ``printf(\"%i\")``. [1]_" msgstr "等價於 ``printf(\"%i\")``. [1]_" -#: ../../c-api/bytes.rst:100 +#: ../../c-api/bytes.rst:104 msgid "``%x``" msgstr "``%x``" -#: ../../c-api/bytes.rst:100 +#: ../../c-api/bytes.rst:104 msgid "Equivalent to ``printf(\"%x\")``. [1]_" msgstr "等價於 ``printf(\"%x\")``. [1]_" -#: ../../c-api/bytes.rst:103 +#: ../../c-api/bytes.rst:107 msgid "``%s``" msgstr "``%s``" -#: ../../c-api/bytes.rst:103 +#: ../../c-api/bytes.rst:107 msgid "const char\\*" msgstr "const char\\*" -#: ../../c-api/bytes.rst:103 +#: ../../c-api/bytes.rst:107 msgid "A null-terminated C character array." msgstr "" -#: ../../c-api/bytes.rst:106 +#: ../../c-api/bytes.rst:110 msgid "``%p``" msgstr "``%p``" -#: ../../c-api/bytes.rst:106 +#: ../../c-api/bytes.rst:110 msgid "const void\\*" msgstr "const void\\*" -#: ../../c-api/bytes.rst:106 +#: ../../c-api/bytes.rst:110 msgid "" "The hex representation of a C pointer. Mostly equivalent to " "``printf(\"%p\")`` except that it is guaranteed to start with the literal " "``0x`` regardless of what the platform's ``printf`` yields." msgstr "" -#: ../../c-api/bytes.rst:115 +#: ../../c-api/bytes.rst:119 msgid "" "An unrecognized format character causes all the rest of the format string to " "be copied as-is to the result object, and any extra arguments discarded." msgstr "" -#: ../../c-api/bytes.rst:118 +#: ../../c-api/bytes.rst:122 msgid "" "For integer specifiers (d, u, ld, lu, zd, zu, i, x): the 0-conversion flag " "has effect even when a precision is given." msgstr "" -#: ../../c-api/bytes.rst:124 +#: ../../c-api/bytes.rst:128 msgid "" "Identical to :c:func:`PyBytes_FromFormat` except that it takes exactly two " "arguments." msgstr "" -#: ../../c-api/bytes.rst:130 +#: ../../c-api/bytes.rst:134 msgid "" "Return the bytes representation of object *o* that implements the buffer " "protocol." msgstr "" -#: ../../c-api/bytes.rst:134 +#: ../../c-api/bytes.rst:138 msgid "" "If the object implements the buffer protocol, then the buffer must not be " "mutated while the bytes object is being created." msgstr "" -#: ../../c-api/bytes.rst:140 +#: ../../c-api/bytes.rst:144 msgid "Return the length of the bytes in bytes object *o*." msgstr "" -#: ../../c-api/bytes.rst:145 +#: ../../c-api/bytes.rst:149 msgid "Similar to :c:func:`PyBytes_Size`, but without error checking." msgstr "和 :c:func:`PyBytes_Size` 類似,但不進行錯誤檢查。" -#: ../../c-api/bytes.rst:150 +#: ../../c-api/bytes.rst:154 msgid "" "Return a pointer to the contents of *o*. The pointer refers to the internal " "buffer of *o*, which consists of ``len(o) + 1`` bytes. The last byte in the " @@ -278,24 +284,24 @@ msgid "" "`PyBytes_AsString` returns ``NULL`` and raises :exc:`TypeError`." msgstr "" -#: ../../c-api/bytes.rst:162 +#: ../../c-api/bytes.rst:166 msgid "Similar to :c:func:`PyBytes_AsString`, but without error checking." msgstr "和 :c:func:`PyBytes_AsString` 類似,但不進行錯誤檢查。" -#: ../../c-api/bytes.rst:167 +#: ../../c-api/bytes.rst:171 msgid "" "Return the null-terminated contents of the object *obj* through the output " "variables *buffer* and *length*. Returns ``0`` on success." msgstr "" -#: ../../c-api/bytes.rst:171 +#: ../../c-api/bytes.rst:175 msgid "" "If *length* is ``NULL``, the bytes object may not contain embedded null " "bytes; if it does, the function returns ``-1`` and a :exc:`ValueError` is " "raised." msgstr "" -#: ../../c-api/bytes.rst:175 +#: ../../c-api/bytes.rst:179 msgid "" "The buffer refers to an internal buffer of *obj*, which includes an " "additional null byte at the end (not counted in *length*). The data must " @@ -305,13 +311,13 @@ msgid "" "returns ``-1`` and raises :exc:`TypeError`." msgstr "" -#: ../../c-api/bytes.rst:182 +#: ../../c-api/bytes.rst:186 msgid "" "Previously, :exc:`TypeError` was raised when embedded null bytes were " "encountered in the bytes object." msgstr "" -#: ../../c-api/bytes.rst:189 +#: ../../c-api/bytes.rst:193 msgid "" "Create a new bytes object in *\\*bytes* containing the contents of *newpart* " "appended to *bytes*; the caller will own the new reference. The reference to " @@ -321,49 +327,49 @@ msgid "" "appropriate exception will be set." msgstr "" -#: ../../c-api/bytes.rst:197 ../../c-api/bytes.rst:207 +#: ../../c-api/bytes.rst:201 ../../c-api/bytes.rst:211 msgid "" "If *newpart* implements the buffer protocol, then the buffer must not be " "mutated while the new bytes object is being created." msgstr "" -#: ../../c-api/bytes.rst:202 +#: ../../c-api/bytes.rst:206 msgid "" "Create a new bytes object in *\\*bytes* containing the contents of *newpart* " "appended to *bytes*. This version releases the :term:`strong reference` to " "*newpart* (i.e. decrements its reference count)." msgstr "" -#: ../../c-api/bytes.rst:213 +#: ../../c-api/bytes.rst:217 msgid "Similar to ``sep.join(iterable)`` in Python." msgstr "類似 Python 中的 ``sep.join(iterable)``。" -#: ../../c-api/bytes.rst:215 +#: ../../c-api/bytes.rst:219 msgid "" "*sep* must be Python :class:`bytes` object. (Note that :c:func:" "`PyUnicode_Join` accepts ``NULL`` separator and treats it as a space, " "whereas :c:func:`PyBytes_Join` doesn't accept ``NULL`` separator.)" msgstr "" -#: ../../c-api/bytes.rst:220 +#: ../../c-api/bytes.rst:224 msgid "" "*iterable* must be an iterable object yielding objects that implement the :" "ref:`buffer protocol `." msgstr "" -#: ../../c-api/bytes.rst:223 +#: ../../c-api/bytes.rst:227 msgid "" "On success, return a new :class:`bytes` object. On error, set an exception " "and return ``NULL``." msgstr "" -#: ../../c-api/bytes.rst:229 +#: ../../c-api/bytes.rst:233 msgid "" "If *iterable* objects implement the buffer protocol, then the buffers must " "not be mutated while the new bytes object is being created." msgstr "" -#: ../../c-api/bytes.rst:234 +#: ../../c-api/bytes.rst:238 msgid "" "Resize a bytes object. *newsize* will be the new length of the bytes object. " "You can think of it as creating a new bytes object and destroying the old " @@ -375,19 +381,23 @@ msgid "" "``NULL``, :exc:`MemoryError` is set, and ``-1`` is returned." msgstr "" -#: ../../c-api/bytes.rst:248 +#: ../../c-api/bytes.rst:249 +msgid "Use the :c:type:`PyBytesWriter` API instead." +msgstr "" + +#: ../../c-api/bytes.rst:255 msgid "" "Get the string representation of *bytes*. This function is currently used to " "implement :meth:`!bytes.__repr__` in Python." msgstr "" -#: ../../c-api/bytes.rst:251 +#: ../../c-api/bytes.rst:258 msgid "" "This function does not do type checking; it is undefined behavior to pass " "*bytes* as a non-bytes object or ``NULL``." msgstr "" -#: ../../c-api/bytes.rst:254 +#: ../../c-api/bytes.rst:261 msgid "" "If *smartquotes* is true, the representation will use a double-quoted string " "instead of single-quoted string when single-quotes are present in *bytes*. " @@ -396,36 +406,475 @@ msgid "" "is false." msgstr "" -#: ../../c-api/bytes.rst:260 +#: ../../c-api/bytes.rst:267 msgid "" "On success, this function returns a :term:`strong reference` to a :class:" "`str` object containing the representation. On failure, this returns " "``NULL`` with an exception set." msgstr "" -#: ../../c-api/bytes.rst:267 +#: ../../c-api/bytes.rst:274 msgid "" "Unescape a backslash-escaped string *s*. *s* must not be ``NULL``. *len* " "must be the size of *s*." msgstr "" -#: ../../c-api/bytes.rst:270 +#: ../../c-api/bytes.rst:277 msgid "" "*errors* must be one of ``\"strict\"``, ``\"replace\"``, or ``\"ignore\"``. " "If *errors* is ``NULL``, then ``\"strict\"`` is used by default." msgstr "" -#: ../../c-api/bytes.rst:273 +#: ../../c-api/bytes.rst:280 msgid "" "On success, this function returns a :term:`strong reference` to a Python :" "class:`bytes` object containing the unescaped string. On failure, this " "function returns ``NULL`` with an exception set." msgstr "" -#: ../../c-api/bytes.rst:277 +#: ../../c-api/bytes.rst:284 msgid "*unicode* and *recode_encoding* are now unused." msgstr "" +#: ../../c-api/bytes.rst:291 +msgid "PyBytesWriter" +msgstr "" + +#: ../../c-api/bytes.rst:293 +msgid "" +"The :c:type:`PyBytesWriter` API can be used to create a Python :class:" +"`bytes` object." +msgstr "" + +#: ../../c-api/bytes.rst:300 +msgid "A bytes writer instance." +msgstr "" + +#: ../../c-api/bytes.rst:302 +msgid "" +"The API is **not thread safe**: a writer should only be used by a single " +"thread at the same time." +msgstr "" + +#: ../../c-api/bytes.rst:305 +msgid "" +"The instance must be destroyed by :c:func:`PyBytesWriter_Finish` on success, " +"or :c:func:`PyBytesWriter_Discard` on error." +msgstr "" + +#: ../../c-api/bytes.rst:310 +msgid "Create, Finish, Discard" +msgstr "" + +#: ../../c-api/bytes.rst:314 +msgid "Create a :c:type:`PyBytesWriter` to write *size* bytes." +msgstr "" + +#: ../../c-api/bytes.rst:316 +msgid "" +"If *size* is greater than zero, allocate *size* bytes, and set the writer " +"size to *size*. The caller is responsible to write *size* bytes using :c:" +"func:`PyBytesWriter_GetData`. This function does not overallocate." +msgstr "" + +#: ../../c-api/bytes.rst:321 ../../c-api/bytes.rst:450 +msgid "On error, set an exception and return ``NULL``." +msgstr "錯誤時設定一個例外並回傳 ``NULL``。" + +#: ../../c-api/bytes.rst:323 ../../c-api/bytes.rst:426 +msgid "*size* must be positive or zero." +msgstr "" + +#: ../../c-api/bytes.rst:327 +msgid "" +"Finish a :c:type:`PyBytesWriter` created by :c:func:`PyBytesWriter_Create`." +msgstr "" + +#: ../../c-api/bytes.rst:330 +msgid "" +"On success, return a Python :class:`bytes` object. On error, set an " +"exception and return ``NULL``." +msgstr "" + +#: ../../c-api/bytes.rst:333 +msgid "" +"The writer instance is invalid after the call in any case. No API can be " +"called on the writer after :c:func:`PyBytesWriter_Finish`." +msgstr "" + +#: ../../c-api/bytes.rst:338 +msgid "" +"Similar to :c:func:`PyBytesWriter_Finish`, but resize the writer to *size* " +"bytes before creating the :class:`bytes` object." +msgstr "" + +#: ../../c-api/bytes.rst:343 +msgid "" +"Similar to :c:func:`PyBytesWriter_Finish`, but resize the writer using *buf* " +"pointer before creating the :class:`bytes` object." +msgstr "" + +#: ../../c-api/bytes.rst:346 +msgid "" +"Set an exception and return ``NULL`` if *buf* pointer is outside the " +"internal buffer bounds." +msgstr "" + +#: ../../c-api/bytes.rst:349 ../../c-api/bytes.rst:454 +msgid "Function pseudo-code::" +msgstr "" + +#: ../../c-api/bytes.rst:351 +msgid "" +"Py_ssize_t size = (char*)buf - (char*)PyBytesWriter_GetData(writer);\n" +"return PyBytesWriter_FinishWithSize(writer, size);" +msgstr "" +"Py_ssize_t size = (char*)buf - (char*)PyBytesWriter_GetData(writer);\n" +"return PyBytesWriter_FinishWithSize(writer, size);" + +#: ../../c-api/bytes.rst:356 +msgid "" +"Discard a :c:type:`PyBytesWriter` created by :c:func:`PyBytesWriter_Create`." +msgstr "" + +#: ../../c-api/bytes.rst:358 +msgid "Do nothing if *writer* is ``NULL``." +msgstr "" + +#: ../../c-api/bytes.rst:360 +msgid "" +"The writer instance is invalid after the call. No API can be called on the " +"writer after :c:func:`PyBytesWriter_Discard`." +msgstr "" + +#: ../../c-api/bytes.rst:364 +msgid "High-level API" +msgstr "" + +#: ../../c-api/bytes.rst:368 +msgid "" +"Grow the *writer* internal buffer by *size* bytes, write *size* bytes of " +"*bytes* at the *writer* end, and add *size* to the *writer* size." +msgstr "" + +#: ../../c-api/bytes.rst:372 +msgid "" +"If *size* is equal to ``-1``, call ``strlen(bytes)`` to get the string " +"length." +msgstr "" + +#: ../../c-api/bytes.rst:375 ../../c-api/bytes.rst:384 +#: ../../c-api/bytes.rst:423 ../../c-api/bytes.rst:436 +msgid "On success, return ``0``. On error, set an exception and return ``-1``." +msgstr "" + +#: ../../c-api/bytes.rst:380 +msgid "" +"Similar to :c:func:`PyBytes_FromFormat`, but write the output directly at " +"the writer end. Grow the writer internal buffer on demand. Then add the " +"written size to the writer size." +msgstr "" + +#: ../../c-api/bytes.rst:389 +msgid "Getters" +msgstr "" + +#: ../../c-api/bytes.rst:393 +msgid "Get the writer size." +msgstr "" + +#: ../../c-api/bytes.rst:395 +msgid "" +"The function does not invalidate pointers returned by :c:func:" +"`PyBytesWriter_GetData`." +msgstr "" + +#: ../../c-api/bytes.rst:398 ../../c-api/bytes.rst:408 +msgid "The function cannot fail." +msgstr "" + +#: ../../c-api/bytes.rst:402 +msgid "Get the writer data: start of the internal buffer." +msgstr "" + +#: ../../c-api/bytes.rst:404 +msgid "" +"The pointer remains valid until a :c:type:`PyBytesWriter` function other " +"than :c:func:`PyBytesWriter_GetData` or :c:func:`PyBytesWriter_GetSize` is " +"called on *writer*." +msgstr "" + +#: ../../c-api/bytes.rst:412 +msgid "Low-level API" +msgstr "" + +#: ../../c-api/bytes.rst:416 +msgid "" +"Resize the writer to *size* bytes. It can be used to enlarge or to shrink " +"the writer. This function typically overallocates to achieve amortized " +"performance when resizing multiple times." +msgstr "" + +#: ../../c-api/bytes.rst:421 ../../c-api/bytes.rst:434 +msgid "Newly allocated bytes are left uninitialized." +msgstr "" + +#: ../../c-api/bytes.rst:430 +msgid "" +"Resize the writer by adding *grow* bytes to the current writer size. This " +"function typically overallocates to achieve amortized performance when " +"resizing multiple times." +msgstr "" + +#: ../../c-api/bytes.rst:439 +msgid "*size* can be negative to shrink the writer." +msgstr "" + +#: ../../c-api/bytes.rst:443 +msgid "" +"Similar to :c:func:`PyBytesWriter_Grow`, but update also the *buf* pointer." +msgstr "和 :c:func:`PyBytesWriter_Grow` 類似,但也會更新 *buf* 指標。" + +#: ../../c-api/bytes.rst:446 +msgid "" +"The *buf* pointer is moved if the internal buffer is moved in memory. The " +"*buf* relative position within the internal buffer is left unchanged." +msgstr "" + +#: ../../c-api/bytes.rst:452 +msgid "*buf* must not be ``NULL``." +msgstr "" + +#: ../../c-api/bytes.rst:456 +msgid "" +"Py_ssize_t pos = (char*)buf - (char*)PyBytesWriter_GetData(writer);\n" +"if (PyBytesWriter_Grow(writer, size) < 0) {\n" +" return NULL;\n" +"}\n" +"return (char*)PyBytesWriter_GetData(writer) + pos;" +msgstr "" +"Py_ssize_t pos = (char*)buf - (char*)PyBytesWriter_GetData(writer);\n" +"if (PyBytesWriter_Grow(writer, size) < 0) {\n" +" return NULL;\n" +"}\n" +"return (char*)PyBytesWriter_GetData(writer) + pos;" + +#: ../../c-api/bytes.rst:464 +msgid "Example creating the string ``b'abc'``" +msgstr "" + +#: ../../c-api/bytes.rst:466 +msgid "" +"Example creating the bytes string ``b\"abc\"``, with a fixed size of 3 " +"bytes::" +msgstr "" + +#: ../../c-api/bytes.rst:468 +msgid "" +"PyObject* create_abc(void)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(3);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +"\n" +" char *str = PyBytesWriter_GetData(writer);\n" +" memcpy(str, \"abc\", 3);\n" +" return PyBytesWriter_Finish(writer);\n" +"}" +msgstr "" +"PyObject* create_abc(void)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(3);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +"\n" +" char *str = PyBytesWriter_GetData(writer);\n" +" memcpy(str, \"abc\", 3);\n" +" return PyBytesWriter_Finish(writer);\n" +"}" + +#: ../../c-api/bytes.rst:480 +msgid "Variant using a pointer to compute the final size::" +msgstr "" + +#: ../../c-api/bytes.rst:482 +msgid "" +"PyObject* create_abc_ptr(void)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(3);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +"\n" +" char *str = PyBytesWriter_GetData(writer);\n" +" memcpy(str, \"abc\", 3);\n" +" str += 1;\n" +" return PyBytesWriter_FinishWithPointer(writer, str);\n" +"}" +msgstr "" +"PyObject* create_abc_ptr(void)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(3);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +"\n" +" char *str = PyBytesWriter_GetData(writer);\n" +" memcpy(str, \"abc\", 3);\n" +" str += 1;\n" +" return PyBytesWriter_FinishWithPointer(writer, str);\n" +"}" + +#: ../../c-api/bytes.rst:497 +msgid "Update ``PyBytes_FromStringAndSize()`` code" +msgstr "" + +#: ../../c-api/bytes.rst:499 +msgid "" +"Example of code using the soft deprecated ``PyBytes_FromStringAndSize(NULL, " +"size)`` API::" +msgstr "" + +#: ../../c-api/bytes.rst:502 +msgid "" +"int copy_bytes(char *dest, const char *src, Py_ssize_t num_bytes)\n" +"{\n" +" ...\n" +"}\n" +"\n" +"PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n" +"{\n" +" PyObject *result = PyBytes_FromStringAndSize(NULL, num_bytes);\n" +" if (result == NULL) {\n" +" return NULL;\n" +" }\n" +" if (copy_bytes(PyBytes_AS_STRING(result), start, num_bytes) < 0) {\n" +" Py_CLEAR(result);\n" +" }\n" +" return result;\n" +"}" +msgstr "" +"int copy_bytes(char *dest, const char *src, Py_ssize_t num_bytes)\n" +"{\n" +" ...\n" +"}\n" +"\n" +"PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n" +"{\n" +" PyObject *result = PyBytes_FromStringAndSize(NULL, num_bytes);\n" +" if (result == NULL) {\n" +" return NULL;\n" +" }\n" +" if (copy_bytes(PyBytes_AS_STRING(result), start, num_bytes) < 0) {\n" +" Py_CLEAR(result);\n" +" }\n" +" return result;\n" +"}" + +#: ../../c-api/bytes.rst:519 ../../c-api/bytes.rst:556 +msgid "It can now be updated to::" +msgstr "" + +#: ../../c-api/bytes.rst:521 +msgid "" +"PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(num_bytes);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +" if (copy_bytes(PyBytesWriter_GetData(writer), start, num_bytes) < 0) {\n" +" PyBytesWriter_Discard(writer);\n" +" return NULL;\n" +" }\n" +" return PyBytesWriter_Finish(writer);\n" +"}" +msgstr "" +"PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(num_bytes);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +" if (copy_bytes(PyBytesWriter_GetData(writer), start, num_bytes) < 0) {\n" +" PyBytesWriter_Discard(writer);\n" +" return NULL;\n" +" }\n" +" return PyBytesWriter_Finish(writer);\n" +"}" + +#: ../../c-api/bytes.rst:536 +msgid "Update ``_PyBytes_Resize()`` code" +msgstr "" + +#: ../../c-api/bytes.rst:538 +msgid "Example of code using the soft deprecated ``_PyBytes_Resize()`` API::" +msgstr "" + +#: ../../c-api/bytes.rst:540 +msgid "" +"void create_string(Py_ssize_t size)\n" +"{\n" +" PyObject *bytes = PyBytes_FromStringAndSize(NULL, size);\n" +" if (bytes == NULL) {\n" +" return NULL;\n" +" }\n" +" char *str = PyBytes_AS_STRING(bytes);\n" +"\n" +" // ... write data into str ...\n" +"\n" +" if (_PyBytes_Resize(&bytes, (str - PyBytes_AS_STRING(bytes)))) {\n" +" return NULL;\n" +" }\n" +" return bytes;\n" +"}" +msgstr "" +"void create_string(Py_ssize_t size)\n" +"{\n" +" PyObject *bytes = PyBytes_FromStringAndSize(NULL, size);\n" +" if (bytes == NULL) {\n" +" return NULL;\n" +" }\n" +" char *str = PyBytes_AS_STRING(bytes);\n" +"\n" +" // ... 將資料寫入 str ...\n" +"\n" +" if (_PyBytes_Resize(&bytes, (str - PyBytes_AS_STRING(bytes)))) {\n" +" return NULL;\n" +" }\n" +" return bytes;\n" +"}" + +#: ../../c-api/bytes.rst:558 +msgid "" +"void create_string(Py_ssize_t size)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(size);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +" char *str = PyBytesWriter_GetData(writer);\n" +"\n" +" // ... write data into str ...\n" +"\n" +" return PyBytesWriter_FinishWithPointer(writer, str);\n" +"}" +msgstr "" +"void create_string(Py_ssize_t size)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(size);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +" char *str = PyBytesWriter_GetData(writer);\n" +"\n" +" // ... 將資料寫入 str ...\n" +"\n" +" return PyBytesWriter_FinishWithPointer(writer, str);\n" +"}" + #: ../../c-api/bytes.rst:18 msgid "object" msgstr "object(物件)" diff --git a/c-api/code.po b/c-api/code.po index 05252c66c12..c17d9ba48e4 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-08 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,7 +21,7 @@ msgstr "" msgid "Code Objects" msgstr "程式碼物件" -#: ../../c-api/code.rst:12 +#: ../../c-api/code.rst:10 msgid "" "Code objects are a low-level detail of the CPython implementation. Each one " "represents a chunk of executable code that hasn't yet been bound into a " @@ -30,13 +30,13 @@ msgstr "" "程式碼物件是 CPython 實作的低階細節。每個程式碼物件都代表一段尚未綁定到函式的" "可執行程式碼。" -#: ../../c-api/code.rst:18 +#: ../../c-api/code.rst:16 msgid "" "The C structure of the objects used to describe code objects. The fields of " "this type are subject to change at any time." msgstr "用於描述程式碼物件的 C 結構。此型別的欄位隨時可能變更。" -#: ../../c-api/code.rst:24 +#: ../../c-api/code.rst:22 msgid "" "This is an instance of :c:type:`PyTypeObject` representing the Python :ref:" "`code object `." @@ -44,7 +44,7 @@ msgstr "" "這是 :c:type:`PyTypeObject` 的一個實例,代表 Python 的\\ :ref:`程式碼物件 " "`。" -#: ../../c-api/code.rst:30 +#: ../../c-api/code.rst:28 msgid "" "Return true if *co* is a :ref:`code object `. This function " "always succeeds." @@ -52,14 +52,14 @@ msgstr "" "如果 *co* 是\\ :ref:`程式碼物件 `,則回傳 true。此函式總會成功" "執行。" -#: ../../c-api/code.rst:35 +#: ../../c-api/code.rst:33 msgid "" "Return the number of :term:`free (closure) variables ` in " "a code object." msgstr "" "回傳程式碼物件中\\ :term:`自由(閉包)變數 `\\ 的數量。" -#: ../../c-api/code.rst:40 +#: ../../c-api/code.rst:38 msgid "" "Return the position of the first :term:`free (closure) variable ` in a code object." @@ -67,58 +67,58 @@ msgstr "" "回傳程式碼物件中第一個\\ :term:`自由(閉包)變數 `\\ 的位" "置。" -#: ../../c-api/code.rst:45 +#: ../../c-api/code.rst:43 msgid "" "Renamed from ``PyCode_GetFirstFree`` as part of :ref:`unstable-c-api`. The " "old name is deprecated, but will remain available until the signature " "changes again." msgstr "" -#: ../../c-api/code.rst:51 +#: ../../c-api/code.rst:49 msgid "" "Return a new code object. If you need a dummy code object to create a " "frame, use :c:func:`PyCode_NewEmpty` instead." msgstr "" -#: ../../c-api/code.rst:54 +#: ../../c-api/code.rst:52 msgid "" "Since the definition of the bytecode changes often, calling :c:func:" "`PyUnstable_Code_New` directly can bind you to a precise Python version." msgstr "" -#: ../../c-api/code.rst:57 +#: ../../c-api/code.rst:55 msgid "" "The many arguments of this function are inter-dependent in complex ways, " "meaning that subtle changes to values are likely to result in incorrect " "execution or VM crashes. Use this function only with extreme care." msgstr "" -#: ../../c-api/code.rst:61 +#: ../../c-api/code.rst:59 msgid "Added ``qualname`` and ``exceptiontable`` parameters." msgstr "新增 ``qualname`` 和 ``exceptiontable`` 參數。" -#: ../../c-api/code.rst:68 +#: ../../c-api/code.rst:66 msgid "" "Renamed from ``PyCode_New`` as part of :ref:`unstable-c-api`. The old name " "is deprecated, but will remain available until the signature changes again." msgstr "" -#: ../../c-api/code.rst:77 +#: ../../c-api/code.rst:75 msgid "" "Similar to :c:func:`PyUnstable_Code_New`, but with an extra " "\"posonlyargcount\" for positional-only arguments. The same caveats that " "apply to ``PyUnstable_Code_New`` also apply to this function." msgstr "" -#: ../../c-api/code.rst:80 +#: ../../c-api/code.rst:78 msgid "as ``PyCode_NewWithPosOnlyArgs``" msgstr "名為 ``PyCode_NewWithPosOnlyArgs``" -#: ../../c-api/code.rst:82 +#: ../../c-api/code.rst:80 msgid "Added ``qualname`` and ``exceptiontable`` parameters." msgstr "新增 ``qualname`` 和 ``exceptiontable`` 參數。" -#: ../../c-api/code.rst:87 +#: ../../c-api/code.rst:85 msgid "" "Renamed to ``PyUnstable_Code_NewWithPosOnlyArgs``. The old name is " "deprecated, but will remain available until the signature changes again." @@ -126,59 +126,59 @@ msgstr "" "重新命名為 ``PyUnstable_Code_NewWithPosOnlyArgs``。舊的名稱已被棄用,但在簽名" "再次變更前仍可使用。" -#: ../../c-api/code.rst:93 +#: ../../c-api/code.rst:91 msgid "" "Return a new empty code object with the specified filename, function name, " "and first line number. The resulting code object will raise an ``Exception`` " "if executed." msgstr "" -#: ../../c-api/code.rst:99 +#: ../../c-api/code.rst:97 msgid "" "Return the line number of the instruction that occurs on or before " "``byte_offset`` and ends after it. If you just need the line number of a " "frame, use :c:func:`PyFrame_GetLineNumber` instead." msgstr "" -#: ../../c-api/code.rst:102 +#: ../../c-api/code.rst:100 msgid "" "For efficiently iterating over the line numbers in a code object, use :pep:" "`the API described in PEP 626 <0626#out-of-process-debuggers-and-profilers>`." msgstr "" -#: ../../c-api/code.rst:107 +#: ../../c-api/code.rst:105 msgid "" "Sets the passed ``int`` pointers to the source code line and column numbers " "for the instruction at ``byte_offset``. Sets the value to ``0`` when " "information is not available for any particular element." msgstr "" -#: ../../c-api/code.rst:111 +#: ../../c-api/code.rst:109 msgid "Returns ``1`` if the function succeeds and 0 otherwise." msgstr "如果函式成功則回傳 ``1``,否則回傳 ``0``。" -#: ../../c-api/code.rst:117 +#: ../../c-api/code.rst:115 msgid "" "Equivalent to the Python code ``getattr(co, 'co_code')``. Returns a strong " "reference to a :c:type:`PyBytesObject` representing the bytecode in a code " "object. On error, ``NULL`` is returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:122 +#: ../../c-api/code.rst:120 msgid "" "This ``PyBytesObject`` may be created on-demand by the interpreter and does " "not necessarily represent the bytecode actually executed by CPython. The " "primary use case for this function is debuggers and profilers." msgstr "" -#: ../../c-api/code.rst:130 +#: ../../c-api/code.rst:128 msgid "" "Equivalent to the Python code ``getattr(co, 'co_varnames')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " "variables. On error, ``NULL`` is returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:139 +#: ../../c-api/code.rst:137 msgid "" "Equivalent to the Python code ``getattr(co, 'co_cellvars')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " @@ -186,7 +186,7 @@ msgid "" "returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:148 +#: ../../c-api/code.rst:146 msgid "" "Equivalent to the Python code ``getattr(co, 'co_freevars')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the :term:" @@ -194,7 +194,7 @@ msgid "" "returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:157 +#: ../../c-api/code.rst:155 msgid "" "Register *callback* as a code object watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyCode_ClearWatcher`. In case " @@ -202,7 +202,7 @@ msgid "" "exception." msgstr "" -#: ../../c-api/code.rst:166 +#: ../../c-api/code.rst:164 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyCode_AddWatcher` for the current interpreter. Return ``0`` on success, or " @@ -210,17 +210,17 @@ msgid "" "never registered.)" msgstr "" -#: ../../c-api/code.rst:175 +#: ../../c-api/code.rst:173 msgid "" "Enumeration of possible code object watcher events: - " "``PY_CODE_EVENT_CREATE`` - ``PY_CODE_EVENT_DESTROY``" msgstr "" -#: ../../c-api/code.rst:183 +#: ../../c-api/code.rst:181 msgid "Type of a code object watcher callback function." msgstr "" -#: ../../c-api/code.rst:185 +#: ../../c-api/code.rst:183 msgid "" "If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked after " "*co* has been fully initialized. Otherwise, the callback is invoked before " @@ -228,7 +228,7 @@ msgid "" "inspected." msgstr "" -#: ../../c-api/code.rst:190 +#: ../../c-api/code.rst:188 msgid "" "If *event* is ``PY_CODE_EVENT_DESTROY``, taking a reference in the callback " "to the about-to-be-destroyed code object will resurrect it and prevent it " @@ -236,7 +236,7 @@ msgid "" "later, any watcher callbacks active at that time will be called again." msgstr "" -#: ../../c-api/code.rst:195 +#: ../../c-api/code.rst:193 msgid "" "Users of this API should not rely on internal runtime implementation " "details. Such details may include, but are not limited to, the exact order " @@ -246,14 +246,14 @@ msgid "" "the Python code being executed." msgstr "" -#: ../../c-api/code.rst:202 +#: ../../c-api/code.rst:200 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/code.rst:206 +#: ../../c-api/code.rst:204 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " @@ -262,25 +262,25 @@ msgid "" "it before returning." msgstr "" -#: ../../c-api/code.rst:217 +#: ../../c-api/code.rst:215 msgid "This is a function that does nothing." msgstr "" -#: ../../c-api/code.rst:219 +#: ../../c-api/code.rst:217 msgid "" "Prior to Python 3.10, this function would perform basic optimizations to a " "code object." msgstr "" -#: ../../c-api/code.rst:222 +#: ../../c-api/code.rst:220 msgid "This function now does nothing." msgstr "" -#: ../../c-api/code.rst:231 +#: ../../c-api/code.rst:229 msgid "Code Object Flags" msgstr "程式碼物件旗標" -#: ../../c-api/code.rst:233 +#: ../../c-api/code.rst:231 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:" @@ -288,7 +288,7 @@ msgid "" "`PyUnstable_Code_New` and similar functions." msgstr "" -#: ../../c-api/code.rst:238 +#: ../../c-api/code.rst:236 msgid "" "Flags whose names start with ``CO_FUTURE_`` correspond to features normally " "selectable by :ref:`future statements `. These flags can be used in :" @@ -296,133 +296,133 @@ msgid "" "mandatory in current versions of Python, and setting them has no effect." msgstr "" -#: ../../c-api/code.rst:244 +#: ../../c-api/code.rst:242 msgid "" "The following flags are available. For their meaning, see the linked " "documentation of their Python equivalents." msgstr "" -#: ../../c-api/code.rst:252 +#: ../../c-api/code.rst:250 msgid "Flag" msgstr "旗標" -#: ../../c-api/code.rst:253 +#: ../../c-api/code.rst:251 msgid "Meaning" msgstr "意義" -#: ../../c-api/code.rst:255 +#: ../../c-api/code.rst:253 msgid ":py:data:`inspect.CO_OPTIMIZED`" msgstr ":py:data:`inspect.CO_OPTIMIZED`" -#: ../../c-api/code.rst:257 +#: ../../c-api/code.rst:255 msgid ":py:data:`inspect.CO_NEWLOCALS`" msgstr ":py:data:`inspect.CO_NEWLOCALS`" -#: ../../c-api/code.rst:259 +#: ../../c-api/code.rst:257 msgid ":py:data:`inspect.CO_VARARGS`" msgstr ":py:data:`inspect.CO_VARARGS`" -#: ../../c-api/code.rst:261 +#: ../../c-api/code.rst:259 msgid ":py:data:`inspect.CO_VARKEYWORDS`" msgstr ":py:data:`inspect.CO_VARKEYWORDS`" -#: ../../c-api/code.rst:263 +#: ../../c-api/code.rst:261 msgid ":py:data:`inspect.CO_NESTED`" msgstr ":py:data:`inspect.CO_NESTED`" -#: ../../c-api/code.rst:265 +#: ../../c-api/code.rst:263 msgid ":py:data:`inspect.CO_GENERATOR`" msgstr ":py:data:`inspect.CO_GENERATOR`" -#: ../../c-api/code.rst:267 +#: ../../c-api/code.rst:265 msgid ":py:data:`inspect.CO_COROUTINE`" msgstr ":py:data:`inspect.CO_COROUTINE`" -#: ../../c-api/code.rst:269 +#: ../../c-api/code.rst:267 msgid ":py:data:`inspect.CO_ITERABLE_COROUTINE`" msgstr ":py:data:`inspect.CO_ITERABLE_COROUTINE`" -#: ../../c-api/code.rst:271 +#: ../../c-api/code.rst:269 msgid ":py:data:`inspect.CO_ASYNC_GENERATOR`" msgstr ":py:data:`inspect.CO_ASYNC_GENERATOR`" -#: ../../c-api/code.rst:273 +#: ../../c-api/code.rst:271 msgid ":py:data:`inspect.CO_HAS_DOCSTRING`" msgstr ":py:data:`inspect.CO_HAS_DOCSTRING`" -#: ../../c-api/code.rst:275 +#: ../../c-api/code.rst:273 msgid ":py:data:`inspect.CO_METHOD`" msgstr ":py:data:`inspect.CO_METHOD`" -#: ../../c-api/code.rst:278 +#: ../../c-api/code.rst:276 msgid "no effect (:py:data:`__future__.division`)" msgstr "無效果(:py:data:`__future__.division`)" -#: ../../c-api/code.rst:280 +#: ../../c-api/code.rst:278 msgid "no effect (:py:data:`__future__.absolute_import`)" msgstr "無效果(:py:data:`__future__.absolute_import`)" -#: ../../c-api/code.rst:282 +#: ../../c-api/code.rst:280 msgid "no effect (:py:data:`__future__.with_statement`)" msgstr "無效果(:py:data:`__future__.with_statement`)" -#: ../../c-api/code.rst:284 +#: ../../c-api/code.rst:282 msgid "no effect (:py:data:`__future__.print_function`)" msgstr "無效果(:py:data:`__future__.print_function`)" -#: ../../c-api/code.rst:286 +#: ../../c-api/code.rst:284 msgid "no effect (:py:data:`__future__.unicode_literals`)" msgstr "無效果(:py:data:`__future__.unicode_literals`)" -#: ../../c-api/code.rst:288 +#: ../../c-api/code.rst:286 msgid "no effect (:py:data:`__future__.generator_stop`)" msgstr "無效果(:py:data:`__future__.generator_stop`)" -#: ../../c-api/code.rst:290 +#: ../../c-api/code.rst:288 msgid ":py:data:`__future__.annotations`" msgstr ":py:data:`__future__.annotations`" -#: ../../c-api/code.rst:294 +#: ../../c-api/code.rst:292 msgid "Extra information" msgstr "額外資訊" -#: ../../c-api/code.rst:296 +#: ../../c-api/code.rst:294 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:300 +#: ../../c-api/code.rst:298 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:309 +#: ../../c-api/code.rst:307 msgid "Return a new opaque index value used to adding data to code objects." msgstr "" -#: ../../c-api/code.rst:311 +#: ../../c-api/code.rst:309 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:315 +#: ../../c-api/code.rst:313 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:319 +#: ../../c-api/code.rst:317 msgid "as ``_PyEval_RequestCodeExtraIndex``" msgstr "名為 ``_PyEval_RequestCodeExtraIndex``" -#: ../../c-api/code.rst:323 +#: ../../c-api/code.rst:321 msgid "" "Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``. The old private name " "is deprecated, but will be available until the API changes." @@ -430,23 +430,23 @@ msgstr "" "重新命名為 ``PyUnstable_Eval_RequestCodeExtraIndex``。舊的私有名稱已被棄用," "但在 API 變更前仍可使用。" -#: ../../c-api/code.rst:332 +#: ../../c-api/code.rst:330 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:335 +#: ../../c-api/code.rst:333 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:338 +#: ../../c-api/code.rst:336 msgid "as ``_PyCode_GetExtra``" msgstr "名為 ``_PyCode_GetExtra``" -#: ../../c-api/code.rst:342 +#: ../../c-api/code.rst:340 msgid "" "Renamed to ``PyUnstable_Code_GetExtra``. The old private name is deprecated, " "but will be available until the API changes." @@ -454,17 +454,17 @@ msgstr "" "重新命名為 ``PyUnstable_Code_GetExtra``。舊的私有名稱已被棄用,但在 API 變更" "前仍可使用。" -#: ../../c-api/code.rst:351 +#: ../../c-api/code.rst:349 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:354 +#: ../../c-api/code.rst:352 msgid "as ``_PyCode_SetExtra``" msgstr "名為 ``_PyCode_SetExtra``" -#: ../../c-api/code.rst:358 +#: ../../c-api/code.rst:356 msgid "" "Renamed to ``PyUnstable_Code_SetExtra``. The old private name is deprecated, " "but will be available until the API changes." @@ -484,6 +484,6 @@ msgstr "code(程式碼)" msgid "code object" msgstr "code object(程式碼物件)" -#: ../../c-api/code.rst:64 +#: ../../c-api/code.rst:62 msgid "PyCode_New (C function)" msgstr "PyCode_New(C 函式)" diff --git a/c-api/complex.po b/c-api/complex.po index 6246d71782b..de647134735 100644 --- a/c-api/complex.po +++ b/c-api/complex.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,125 +22,24 @@ msgstr "" msgid "Complex Number Objects" msgstr "複數物件" -#: ../../c-api/complex.rst:10 +#: ../../c-api/complex.rst:13 msgid "" -"Python's complex number objects are implemented as two distinct types when " -"viewed from the C API: one is the Python object exposed to Python programs, " -"and the other is a C structure which represents the actual complex number " -"value. The API provides functions for working with both." -msgstr "" -"從 C API 來看,Python 的複數物件被實作為兩種不同的型別:一種是公開給 Python " -"程式的 Python 物件,另一種是表示實際複數值的 C 結構。API 提供了與兩者一起作用" -"的函式。" +"This subtype of :c:type:`PyObject` represents a Python complex number object." +msgstr "這個 :c:type:`PyObject` 的子型別代表一個 Python 複數物件。" #: ../../c-api/complex.rst:17 -msgid "Complex Numbers as C Structures" -msgstr "作為 C 結構的複數" - -#: ../../c-api/complex.rst:19 -msgid "" -"Note that the functions which accept these structures as parameters and " -"return them as results do so *by value* rather than dereferencing them " -"through pointers. This is consistent throughout the API." -msgstr "" -"請注意,接受這些結構作為參數並將它們作為結果回傳的函式是\\ *按值 (by value)* " -"執行的,而不是透過指標取消參照 (dereference) 它們。這在整個 API 中都是一致" -"的。" - -#: ../../c-api/complex.rst:26 -msgid "" -"The C structure which corresponds to the value portion of a Python complex " -"number object. Most of the functions for dealing with complex number " -"objects use structures of this type as input or output values, as " -"appropriate." -msgstr "" -"相對於 Python 複數物件之數值部分的 C 結構。大多數處理複數物件的函式根據需求會" -"使用這種型別的結構作為輸入或輸出值。" - -#: ../../c-api/complex.rst:33 -msgid "The structure is defined as::" -msgstr "該結構被定義為: ::" - -#: ../../c-api/complex.rst:35 -msgid "" -"typedef struct {\n" -" double real;\n" -" double imag;\n" -"} Py_complex;" -msgstr "" -"typedef struct {\n" -" double real;\n" -" double imag;\n" -"} Py_complex;" - -#: ../../c-api/complex.rst:43 -msgid "" -"Return the sum of two complex numbers, using the C :c:type:`Py_complex` " -"representation." -msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數之和。" - -#: ../../c-api/complex.rst:49 -msgid "" -"Return the difference between two complex numbers, using the " -"C :c:type:`Py_complex` representation." -msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數間的差。" - -#: ../../c-api/complex.rst:55 -msgid "" -"Return the negation of the complex number *num*, using the " -"C :c:type:`Py_complex` representation." -msgstr "" -"以 C 的 :c:type:`Py_complex` 表示形式來回傳複數 *num* 的相反數 (negation)。" - -#: ../../c-api/complex.rst:61 msgid "" -"Return the product of two complex numbers, using the C :c:type:`Py_complex` " -"representation." -msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數的乘積。" +"The complex number value, using the C :c:type:`Py_complex` representation." +msgstr "使用 C 的 :c:type:`Py_complex` 表示形式的複數值。" -#: ../../c-api/complex.rst:67 +#: ../../c-api/complex.rst:19 msgid "" -"Return the quotient of two complex numbers, using the C :c:type:`Py_complex` " +"Use :c:func:`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex` to " +"convert a Python complex number to/from the C :c:type:`Py_complex` " "representation." -msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數的商。" - -#: ../../c-api/complex.rst:70 -msgid "" -"If *divisor* is null, this method returns zero and sets :c:data:`errno` " -"to :c:macro:`!EDOM`." msgstr "" -"如果 *divisor* 為 null,則此方法會回傳零並將 :c:data:`errno` 設定" -"為 :c:macro:`!EDOM`。" -#: ../../c-api/complex.rst:76 -msgid "" -"Return the exponentiation of *num* by *exp*, using the " -"C :c:type:`Py_complex` representation." -msgstr "" -"以 C 的 :c:type:`Py_complex` 表示形式來回傳 *num* 的 *exp* 次方的結果。" - -#: ../../c-api/complex.rst:79 -msgid "" -"If *num* is null and *exp* is not a positive real number, this method " -"returns zero and sets :c:data:`errno` to :c:macro:`!EDOM`." -msgstr "" -"如果 *num* 為 null 且 *exp* 不是正實數,則此方法會回傳零並將 :c:data:`errno` " -"設定為 :c:macro:`!EDOM`。" - -#: ../../c-api/complex.rst:82 -msgid "Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows." -msgstr "" - -#: ../../c-api/complex.rst:86 -msgid "Complex Numbers as Python Objects" -msgstr "作為 Python 物件的複數" - -#: ../../c-api/complex.rst:91 -msgid "" -"This subtype of :c:type:`PyObject` represents a Python complex number object." -msgstr "這個 :c:type:`PyObject` 的子型別代表一個 Python 複數物件。" - -#: ../../c-api/complex.rst:96 +#: ../../c-api/complex.rst:28 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python complex number " "type. It is the same object as :class:`complex` in the Python layer." @@ -148,7 +47,7 @@ msgstr "" "這個 :c:type:`PyTypeObject` 的實例代表 Python 複數型別。它與 Python 層中" "的 :class:`complex` 是同一個物件。" -#: ../../c-api/complex.rst:102 +#: ../../c-api/complex.rst:34 msgid "" "Return true if its argument is a :c:type:`PyComplexObject` or a subtype " "of :c:type:`PyComplexObject`. This function always succeeds." @@ -156,7 +55,7 @@ msgstr "" "如果其引數是一個 :c:type:`PyComplexObject` 或者是 :c:type:`PyComplexObject` " "的子型別,則會回傳 true。這個函式不會失敗。" -#: ../../c-api/complex.rst:108 +#: ../../c-api/complex.rst:40 msgid "" "Return true if its argument is a :c:type:`PyComplexObject`, but not a " "subtype of :c:type:`PyComplexObject`. This function always succeeds." @@ -164,15 +63,7 @@ msgstr "" "如果其引數是一個 :c:type:`PyComplexObject`,但不是 :c:type:`PyComplexObject` " "的子型別,則會回傳 true。這個函式不會失敗。" -#: ../../c-api/complex.rst:114 -msgid "" -"Create a new Python complex number object from a C :c:type:`Py_complex` " -"value. Return ``NULL`` with an exception set on error." -msgstr "" -"從 C 的 :c:type:`Py_complex` 值建立一個新的 Python 複數物件。在錯誤時回傳 " -"``NULL`` 並設定例外。" - -#: ../../c-api/complex.rst:120 +#: ../../c-api/complex.rst:46 msgid "" "Return a new :c:type:`PyComplexObject` object from *real* and *imag*. Return " "``NULL`` with an exception set on error." @@ -180,11 +71,11 @@ msgstr "" "從 *real* 和 *imag* 回傳一個新的 :c:type:`PyComplexObject` 物件。在錯誤時回" "傳 ``NULL`` 並設定例外。" -#: ../../c-api/complex.rst:126 +#: ../../c-api/complex.rst:52 msgid "Return the real part of *op* as a C :c:expr:`double`." msgstr "以 C 的 :c:expr:`double` 形式回傳 *op* 的實部。" -#: ../../c-api/complex.rst:128 +#: ../../c-api/complex.rst:54 msgid "" "If *op* is not a Python complex number object but has " "a :meth:`~object.__complex__` method, this method will first be called to " @@ -196,7 +87,7 @@ msgstr "" "首先會呼叫該方法將 *op* 轉換為 Python 複數物件。如果 :meth:`!__complex__` 並" "未定義,那麼它會回退到呼叫 :c:func:`PyFloat_AsDouble` 並回傳其結果。" -#: ../../c-api/complex.rst:134 ../../c-api/complex.rst:150 +#: ../../c-api/complex.rst:60 ../../c-api/complex.rst:76 msgid "" "Upon failure, this method returns ``-1.0`` with an exception set, so one " "should call :c:func:`PyErr_Occurred` to check for errors." @@ -204,15 +95,15 @@ msgstr "" "失敗時,此方法回傳 ``-1.0`` 並設定例外,因此應該呼" "叫 :c:func:`PyErr_Occurred` 來檢查錯誤。" -#: ../../c-api/complex.rst:137 ../../c-api/complex.rst:153 +#: ../../c-api/complex.rst:63 ../../c-api/complex.rst:79 msgid "Use :meth:`~object.__complex__` if available." msgstr "如果可用則使用 :meth:`~object.__complex__`。" -#: ../../c-api/complex.rst:142 +#: ../../c-api/complex.rst:68 msgid "Return the imaginary part of *op* as a C :c:expr:`double`." msgstr "將 *op* 的虛部作為 C 的 :c:expr:`double` 回傳。" -#: ../../c-api/complex.rst:144 +#: ../../c-api/complex.rst:70 msgid "" "If *op* is not a Python complex number object but has " "a :meth:`~object.__complex__` method, this method will first be called to " @@ -224,11 +115,40 @@ msgstr "" "首先會呼叫該方法將 *op* 轉換為 Python 複數物件。如果 :meth:`!__complex__` 並" "未定義,那麼它會回退到呼叫 :c:func:`PyFloat_AsDouble` 並於成功時回傳 ``0.0``。" -#: ../../c-api/complex.rst:158 +#: ../../c-api/complex.rst:85 +msgid "" +"This C structure defines an export format for a Python complex number object." +msgstr "這個 C 結構定義了 Python 複數物件的匯出格式。" + +#: ../../c-api/complex.rst:91 +msgid "The structure is defined as::" +msgstr "該結構被定義為: ::" + +#: ../../c-api/complex.rst:93 +msgid "" +"typedef struct {\n" +" double real;\n" +" double imag;\n" +"} Py_complex;" +msgstr "" +"typedef struct {\n" +" double real;\n" +" double imag;\n" +"} Py_complex;" + +#: ../../c-api/complex.rst:101 +msgid "" +"Create a new Python complex number object from a C :c:type:`Py_complex` " +"value. Return ``NULL`` with an exception set on error." +msgstr "" +"從 C 的 :c:type:`Py_complex` 值建立一個新的 Python 複數物件。在錯誤時回傳 " +"``NULL`` 並設定例外。" + +#: ../../c-api/complex.rst:107 msgid "Return the :c:type:`Py_complex` value of the complex number *op*." msgstr "回傳複數 *op* 的 :c:type:`Py_complex` 值。" -#: ../../c-api/complex.rst:160 +#: ../../c-api/complex.rst:109 msgid "" "If *op* is not a Python complex number object but has " "a :meth:`~object.__complex__` method, this method will first be called to " @@ -241,7 +161,7 @@ msgstr "" "未定義,那麼它會回退到 :meth:`~object.__float__`。如果 :meth:`!__float__` 未" "定義,則它將繼續回退為 :meth:`~object.__index__`。" -#: ../../c-api/complex.rst:166 +#: ../../c-api/complex.rst:115 msgid "" "Upon failure, this method returns :c:type:`Py_complex` " "with :c:member:`~Py_complex.real` set to ``-1.0`` and with an exception set, " @@ -250,10 +170,95 @@ msgstr "" "失敗時,此方法回傳 :c:type:`Py_complex` 並將 :c:member:`~Py_complex.real` 設" "為 ``-1.0``,並設定例外,因此應該呼叫 :c:func:`PyErr_Occurred` 來檢查錯誤。" -#: ../../c-api/complex.rst:170 +#: ../../c-api/complex.rst:119 msgid "Use :meth:`~object.__index__` if available." msgstr "如果可用則使用 :meth:`~object.__index__`。" +#: ../../c-api/complex.rst:124 +msgid "Complex Numbers as C Structures" +msgstr "作為 C 結構的複數" + +#: ../../c-api/complex.rst:126 +msgid "" +"The API also provides functions for working with complex numbers, using the :" +"c:type:`Py_complex` representation. Note that the functions which accept " +"these structures as parameters and return them as results do so *by value* " +"rather than dereferencing them through pointers." +msgstr "" +"此 API 也提供了使用 :c:type:`Py_complex` 表示形式來處理複數的函式。請注意,接" +"受這些結構作為參數並將它們作為結果回傳的函式是\\ *按值 (by value)* 執行的,而" +"不是透過指標取消參照 (dereference) 它們。" + +#: ../../c-api/complex.rst:131 +msgid "" +"Please note, that these functions are :term:`soft deprecated` since Python " +"3.15. Avoid using this API in a new code to do complex arithmetic: either " +"use the :ref:`Number Protocol ` API or use native complex types, " +"like :c:expr:`double complex`." +msgstr "" + +#: ../../c-api/complex.rst:139 +msgid "" +"Return the sum of two complex numbers, using the C :c:type:`Py_complex` " +"representation." +msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數之和。" + +#: ../../c-api/complex.rst:147 +msgid "" +"Return the difference between two complex numbers, using the " +"C :c:type:`Py_complex` representation." +msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數間的差。" + +#: ../../c-api/complex.rst:155 +msgid "" +"Return the negation of the complex number *num*, using the " +"C :c:type:`Py_complex` representation." +msgstr "" +"以 C 的 :c:type:`Py_complex` 表示形式來回傳複數 *num* 的相反數 (negation)。" + +#: ../../c-api/complex.rst:163 +msgid "" +"Return the product of two complex numbers, using the C :c:type:`Py_complex` " +"representation." +msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數的乘積。" + +#: ../../c-api/complex.rst:171 +msgid "" +"Return the quotient of two complex numbers, using the C :c:type:`Py_complex` " +"representation." +msgstr "以 C 的 :c:type:`Py_complex` 表示形式來回傳兩個複數的商。" + +#: ../../c-api/complex.rst:174 +msgid "" +"If *divisor* is null, this method returns zero and sets :c:data:`errno` " +"to :c:macro:`!EDOM`." +msgstr "" +"如果 *divisor* 為 null,則此方法會回傳零並將 :c:data:`errno` 設定" +"為 :c:macro:`!EDOM`。" + +#: ../../c-api/complex.rst:182 +msgid "" +"Return the exponentiation of *num* by *exp*, using the " +"C :c:type:`Py_complex` representation." +msgstr "" +"以 C 的 :c:type:`Py_complex` 表示形式來回傳 *num* 的 *exp* 次方的結果。" + +#: ../../c-api/complex.rst:185 +msgid "" +"If *num* is null and *exp* is not a positive real number, this method " +"returns zero and sets :c:data:`errno` to :c:macro:`!EDOM`." +msgstr "" +"如果 *num* 為 null 且 *exp* 不是正實數,則此方法會回傳零並將 :c:data:`errno` " +"設定為 :c:macro:`!EDOM`。" + +#: ../../c-api/complex.rst:188 ../../c-api/complex.rst:197 +msgid "Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows." +msgstr "" + +#: ../../c-api/complex.rst:195 +msgid "Return the absolute value of the complex number *num*." +msgstr "回傳複數 *num* 的絕對值。" + #: ../../c-api/complex.rst:8 msgid "object" msgstr "object(物件)" @@ -261,3 +266,25 @@ msgstr "object(物件)" #: ../../c-api/complex.rst:8 msgid "complex number" msgstr "complex number(複數)" + +#~ msgid "" +#~ "Python's complex number objects are implemented as two distinct types " +#~ "when viewed from the C API: one is the Python object exposed to Python " +#~ "programs, and the other is a C structure which represents the actual " +#~ "complex number value. The API provides functions for working with both." +#~ msgstr "" +#~ "從 C API 來看,Python 的複數物件被實作為兩種不同的型別:一種是公開給 " +#~ "Python 程式的 Python 物件,另一種是表示實際複數值的 C 結構。API 提供了與兩" +#~ "者一起作用的函式。" + +#~ msgid "" +#~ "The C structure which corresponds to the value portion of a Python " +#~ "complex number object. Most of the functions for dealing with complex " +#~ "number objects use structures of this type as input or output values, as " +#~ "appropriate." +#~ msgstr "" +#~ "相對於 Python 複數物件之數值部分的 C 結構。大多數處理複數物件的函式根據需" +#~ "求會使用這種型別的結構作為輸入或輸出值。" + +#~ msgid "Complex Numbers as Python Objects" +#~ msgstr "作為 Python 物件的複數" diff --git a/c-api/concrete.po b/c-api/concrete.po index cfa7d8a04ea..127ceaad3ed 100644 --- a/c-api/concrete.po +++ b/c-api/concrete.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-17 00:14+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-11-13 20:37+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -86,7 +86,7 @@ msgstr "函式物件" msgid "Other Objects" msgstr "其他物件" -#: ../../c-api/concrete.rst:123 +#: ../../c-api/concrete.rst:124 msgid "C API for extension modules" msgstr "擴充模組的 C API" diff --git a/c-api/conversion.po b/c-api/conversion.po index a40fe9adb16..955c84ad150 100644 --- a/c-api/conversion.po +++ b/c-api/conversion.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-22 16:08+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-12-11 18:26+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -205,15 +205,15 @@ msgstr "" msgid "" "If ``s`` represents a value that is too large to store in a float (for " "example, ``\"1e500\"`` is such a string on many platforms) then if " -"``overflow_exception`` is ``NULL`` return ``Py_INFINITY`` (with an " +"``overflow_exception`` is ``NULL`` return :c:macro:`!INFINITY` (with an " "appropriate sign) and don't set any exception. Otherwise, " "``overflow_exception`` must point to a Python exception object; raise that " "exception and return ``-1.0``. In both cases, set ``*endptr`` to point to " "the first character after the converted value." msgstr "" "如果 ``s`` 表示的值太大而無法儲存在浮點數中(例如 ``\"1e500\"`` 在許多平台上" -"都是這樣的字串),如果 ``overflow_exception`` 為 ``NULL`` 則回傳 " -"``Py_INFINITY``\\ (會帶有適當的符號)並且不設定任何例外。否則, " +"都是這樣的字串),如果 ``overflow_exception`` 為 ``NULL`` 則回傳 :c:macro:`!" +"INFINITY`\\ (會帶有適當的符號)並且不設定任何例外。否則," "``overflow_exception`` 必須指向一個 Python 例外物件;引發該例外並回傳 " "``-1.0``。在這兩種情況下,將 ``*endptr`` 設定為指向轉換後的值之後的第一個字" "元。" diff --git a/c-api/datetime.po b/c-api/datetime.po index 9a62a3dbf6f..095487dbca0 100644 --- a/c-api/datetime.po +++ b/c-api/datetime.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-20 17:54+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-10-14 20:39+0800\n" "Last-Translator: Yorkxe \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -69,45 +69,55 @@ msgid "This is not compatible with subinterpreters." msgstr "這和子直譯器 (subinterpreters) 不相容。" #: ../../c-api/datetime.rst:35 +msgid "This macro is now thread safe." +msgstr "" + +#: ../../c-api/datetime.rst:39 msgid "Structure containing the fields for the datetime C API." msgstr "包含 datetime C API 欄位的結構。" -#: ../../c-api/datetime.rst:37 +#: ../../c-api/datetime.rst:41 msgid "The fields of this structure are private and subject to change." msgstr "此結構的欄位為私有且可能會變動。" -#: ../../c-api/datetime.rst:39 +#: ../../c-api/datetime.rst:43 msgid "Do not use this directly; prefer ``PyDateTime_*`` APIs instead." msgstr "不要直接使用這個;請改用 ``PyDateTime_*`` API。" -#: ../../c-api/datetime.rst:43 +#: ../../c-api/datetime.rst:47 msgid "Dynamically allocated object containing the datetime C API." msgstr "動態配置的物件,包含 datetime C API。" -#: ../../c-api/datetime.rst:45 +#: ../../c-api/datetime.rst:49 msgid "" "This variable is only available once :c:macro:`PyDateTime_IMPORT` succeeds." msgstr "此變數僅在 :c:macro:`PyDateTime_IMPORT` 成功後可用。" -#: ../../c-api/datetime.rst:49 +#: ../../c-api/datetime.rst:53 +msgid "" +"This variable should not be accessed directly as direct access is not thread-" +"safe. Use :c:func:`PyDateTime_IMPORT` instead." +msgstr "" + +#: ../../c-api/datetime.rst:58 msgid "This subtype of :c:type:`PyObject` represents a Python date object." msgstr "此 :c:type:`PyObject` 子型別代表 Python date 物件" -#: ../../c-api/datetime.rst:53 +#: ../../c-api/datetime.rst:62 msgid "This subtype of :c:type:`PyObject` represents a Python datetime object." msgstr "此 :c:type:`PyObject` 子型別代表 Python datetime 物件" -#: ../../c-api/datetime.rst:57 +#: ../../c-api/datetime.rst:66 msgid "This subtype of :c:type:`PyObject` represents a Python time object." msgstr "此 :c:type:`PyObject` 子型別代表 Python time 物件" -#: ../../c-api/datetime.rst:61 +#: ../../c-api/datetime.rst:70 msgid "" "This subtype of :c:type:`PyObject` represents the difference between two " "datetime values." msgstr "此 :c:type:`PyObject` 子型別代表兩個 datetime 物件的差值" -#: ../../c-api/datetime.rst:65 +#: ../../c-api/datetime.rst:74 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python date type; it " "is the same object as :class:`datetime.date` in the Python layer." @@ -115,7 +125,7 @@ msgstr "" "此 :c:type:`PyTypeObject` 實例代表 Python date 型別,與 Python layer 中的 :" "class:`datetime.date` 是同一物件" -#: ../../c-api/datetime.rst:70 +#: ../../c-api/datetime.rst:79 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python datetime type; " "it is the same object as :class:`datetime.datetime` in the Python layer." @@ -123,7 +133,7 @@ msgstr "" "此 :c:type:`PyTypeObject` 實例代表 Python datetime 型別,與 Python layer 中" "的 :class:`datetime.datetime` 是同一物件" -#: ../../c-api/datetime.rst:75 +#: ../../c-api/datetime.rst:84 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python time type; it " "is the same object as :class:`datetime.time` in the Python layer." @@ -131,7 +141,7 @@ msgstr "" "此 :c:type:`PyTypeObject` 實例代表 Python time 型別,與 Python layer 中的 :" "class:`datetime.time` 是同一物件" -#: ../../c-api/datetime.rst:80 +#: ../../c-api/datetime.rst:89 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python type for the " "difference between two datetime values; it is the same object as :class:" @@ -140,7 +150,7 @@ msgstr "" "此 :c:type:`PyTypeObject` 實例代表 Python 兩個 datetime 物件的型別,與 " "Python layer 中的 :class:`datetime.timedelta` 是同一物件" -#: ../../c-api/datetime.rst:86 +#: ../../c-api/datetime.rst:95 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python time zone info " "type; it is the same object as :class:`datetime.tzinfo` in the Python layer." @@ -148,22 +158,22 @@ msgstr "" "此 :c:type:`PyTypeObject` 實例代表 Python 時區資訊型別,與 Python layer 中" "的 :class:`datetime.tzinfo` 是同一物件" -#: ../../c-api/datetime.rst:90 +#: ../../c-api/datetime.rst:99 msgid "Macro for access to the UTC singleton:" msgstr "用於存取 UTC 單例 (singleton) 的巨集:" -#: ../../c-api/datetime.rst:94 +#: ../../c-api/datetime.rst:103 msgid "" "Returns the time zone singleton representing UTC, the same object as :attr:" "`datetime.timezone.utc`." msgstr "" "回傳表示 UTC 的時區單例,是與 :attr:`datetime.timezone.utc` 相同的物件。" -#: ../../c-api/datetime.rst:100 +#: ../../c-api/datetime.rst:109 msgid "Type-check macros:" msgstr "型別檢查巨集:" -#: ../../c-api/datetime.rst:104 +#: ../../c-api/datetime.rst:113 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_DateType` or a subtype " "of :c:data:`!PyDateTime_DateType`. *ob* must not be ``NULL``. This " @@ -173,7 +183,7 @@ msgstr "" "PyDateTime_DateType` 的子型別,則回傳 true。 *ob* 不得為 ``NULL``。這個函式一" "定會執行成功。" -#: ../../c-api/datetime.rst:111 +#: ../../c-api/datetime.rst:120 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_DateType`. *ob* must not " "be ``NULL``. This function always succeeds." @@ -181,7 +191,7 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_DateType`,則回傳 true。 *ob* 不得為 " "``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:117 +#: ../../c-api/datetime.rst:126 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType` or a " "subtype of :c:data:`!PyDateTime_DateTimeType`. *ob* must not be ``NULL``. " @@ -191,7 +201,7 @@ msgstr "" "PyDateTime_DateTimeType` 的子型別,則回傳 true。*ob* 不得為 ``NULL``。這個函" "式一定會執行成功。" -#: ../../c-api/datetime.rst:124 +#: ../../c-api/datetime.rst:133 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType`. *ob* must " "not be ``NULL``. This function always succeeds." @@ -199,7 +209,7 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_DateTimeType`,則回傳 true。*ob* 不得" "為 ``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:130 +#: ../../c-api/datetime.rst:139 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_TimeType` or a subtype " "of :c:data:`!PyDateTime_TimeType`. *ob* must not be ``NULL``. This " @@ -209,7 +219,7 @@ msgstr "" "PyDateTime_TimeType` 的子型別,則回傳 true。*ob* 不得為 ``NULL``。這個函式一" "定會執行成功。" -#: ../../c-api/datetime.rst:137 +#: ../../c-api/datetime.rst:146 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_TimeType`. *ob* must not " "be ``NULL``. This function always succeeds." @@ -217,7 +227,7 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_TimeType`,則回傳 true。*ob* 不得為 " "``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:143 +#: ../../c-api/datetime.rst:152 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_DeltaType` or a subtype " "of :c:data:`!PyDateTime_DeltaType`. *ob* must not be ``NULL``. This " @@ -227,7 +237,7 @@ msgstr "" "PyDateTime_DeltaType` 的子型別,則回傳 true。*ob* 不得為 ``NULL``。這個函式一" "定會執行成功。" -#: ../../c-api/datetime.rst:150 +#: ../../c-api/datetime.rst:159 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_DeltaType`. *ob* must not " "be ``NULL``. This function always succeeds." @@ -235,7 +245,7 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_DeltaType`,則回傳 true。*ob* 不得為 " "``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:156 +#: ../../c-api/datetime.rst:165 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType` or a subtype " "of :c:data:`!PyDateTime_TZInfoType`. *ob* must not be ``NULL``. This " @@ -245,7 +255,7 @@ msgstr "" "PyDateTime_TZInfoType` 的子型別,則回傳 true。*ob* 不得為 ``NULL``。這個函式" "一定會執行成功。" -#: ../../c-api/datetime.rst:163 +#: ../../c-api/datetime.rst:172 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType`. *ob* must " "not be ``NULL``. This function always succeeds." @@ -253,24 +263,24 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_TZInfoType`,則回傳 true。 *ob* 不得" "為 ``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:167 +#: ../../c-api/datetime.rst:176 msgid "Macros to create objects:" msgstr "建立物件的巨集:" -#: ../../c-api/datetime.rst:171 +#: ../../c-api/datetime.rst:180 msgid "" "Return a :class:`datetime.date` object with the specified year, month and " "day." msgstr "回傳一個有特定年、月、日的物件 :class:`datetime.date`。" -#: ../../c-api/datetime.rst:176 +#: ../../c-api/datetime.rst:185 msgid "" "Return a :class:`datetime.datetime` object with the specified year, month, " "day, hour, minute, second and microsecond." msgstr "" "回傳一個有特定年、月、日、時、分、秒、微秒的物件 :class:`datetime.datetime`。" -#: ../../c-api/datetime.rst:182 +#: ../../c-api/datetime.rst:191 msgid "" "Return a :class:`datetime.datetime` object with the specified year, month, " "day, hour, minute, second, microsecond and fold." @@ -278,13 +288,13 @@ msgstr "" "回傳一個有特定年、月、日、時、分、秒、微秒與 fold(時間折疊)的物件 :class:" "`datetime.datetime`。" -#: ../../c-api/datetime.rst:190 +#: ../../c-api/datetime.rst:199 msgid "" "Return a :class:`datetime.time` object with the specified hour, minute, " "second and microsecond." msgstr "回傳一個有特定時、分、秒、微秒的物件 :class:`datetime.time`。" -#: ../../c-api/datetime.rst:196 +#: ../../c-api/datetime.rst:205 msgid "" "Return a :class:`datetime.time` object with the specified hour, minute, " "second, microsecond and fold." @@ -292,7 +302,7 @@ msgstr "" "回傳一個有特定時、分、秒、微秒與 fold(時間折疊)的物件 :class:`datetime." "time`。" -#: ../../c-api/datetime.rst:204 +#: ../../c-api/datetime.rst:213 msgid "" "Return a :class:`datetime.timedelta` object representing the given number of " "days, seconds and microseconds. Normalization is performed so that the " @@ -303,7 +313,7 @@ msgstr "" "標準化 (normalization) 以便生成的微秒數和秒數位於 :class:`datetime." "timedelta` 物件記錄的範圍內。" -#: ../../c-api/datetime.rst:212 +#: ../../c-api/datetime.rst:221 msgid "" "Return a :class:`datetime.timezone` object with an unnamed fixed offset " "represented by the *offset* argument." @@ -311,7 +321,7 @@ msgstr "" "回傳一個 :class:`datetime.timezone` 物件,其未命名的固定偏移量由 *offset* 引" "數表示。" -#: ../../c-api/datetime.rst:220 +#: ../../c-api/datetime.rst:229 msgid "" "Return a :class:`datetime.timezone` object with a fixed offset represented " "by the *offset* argument and with tzname *name*." @@ -319,7 +329,7 @@ msgstr "" "回傳一個 :class:`datetime.timezone` 物件,其固定偏移量由 *offset* 引數表示," "並帶有 tzname *name*。" -#: ../../c-api/datetime.rst:226 +#: ../../c-api/datetime.rst:235 msgid "" "Macros to extract fields from date objects. The argument must be an " "instance of :c:type:`PyDateTime_Date`, including subclasses (such as :c:type:" @@ -330,19 +340,19 @@ msgstr "" "包括子類別(例如 :c:type:`PyDateTime_DateTime`)。引數不得為 ``NULL``,並且不" "會檢查型別:" -#: ../../c-api/datetime.rst:233 +#: ../../c-api/datetime.rst:242 msgid "Return the year, as a positive int." msgstr "回傳年份,為正整數。" -#: ../../c-api/datetime.rst:238 +#: ../../c-api/datetime.rst:247 msgid "Return the month, as an int from 1 through 12." msgstr "回傳月份,為正整數,從 1 到 12。" -#: ../../c-api/datetime.rst:243 +#: ../../c-api/datetime.rst:252 msgid "Return the day, as an int from 1 through 31." msgstr "回傳日期,為正整數,從 1 到 31。" -#: ../../c-api/datetime.rst:246 +#: ../../c-api/datetime.rst:255 msgid "" "Macros to extract fields from datetime objects. The argument must be an " "instance of :c:type:`PyDateTime_DateTime`, including subclasses. The " @@ -351,31 +361,31 @@ msgstr "" "從 datetime 物件中提取欄位的巨集。引數必須是個 :c:type:`PyDateTime_DateTime` " "的實例,包括子類別。引數不得為 ``NULL``,並且不會檢查型別:" -#: ../../c-api/datetime.rst:252 ../../c-api/datetime.rst:290 +#: ../../c-api/datetime.rst:261 ../../c-api/datetime.rst:299 msgid "Return the hour, as an int from 0 through 23." msgstr "回傳小時,為正整數,從 0 到 23。" -#: ../../c-api/datetime.rst:257 ../../c-api/datetime.rst:295 +#: ../../c-api/datetime.rst:266 ../../c-api/datetime.rst:304 msgid "Return the minute, as an int from 0 through 59." msgstr "回傳分鐘,為正整數,從 0 到 59。" -#: ../../c-api/datetime.rst:262 ../../c-api/datetime.rst:300 +#: ../../c-api/datetime.rst:271 ../../c-api/datetime.rst:309 msgid "Return the second, as an int from 0 through 59." msgstr "回傳秒,為正整數,從0 到59。" -#: ../../c-api/datetime.rst:267 ../../c-api/datetime.rst:305 +#: ../../c-api/datetime.rst:276 ../../c-api/datetime.rst:314 msgid "Return the microsecond, as an int from 0 through 999999." msgstr "回傳微秒,為正整數,從 0 到 999999。" -#: ../../c-api/datetime.rst:272 ../../c-api/datetime.rst:310 +#: ../../c-api/datetime.rst:281 ../../c-api/datetime.rst:319 msgid "Return the fold, as an int from 0 through 1." msgstr "回傳 fold,為 0 或 1 的正整數。" -#: ../../c-api/datetime.rst:279 ../../c-api/datetime.rst:317 +#: ../../c-api/datetime.rst:288 ../../c-api/datetime.rst:326 msgid "Return the tzinfo (which may be ``None``)." msgstr "回傳 tzinfo(可能是 ``None``)。" -#: ../../c-api/datetime.rst:284 +#: ../../c-api/datetime.rst:293 msgid "" "Macros to extract fields from time objects. The argument must be an " "instance of :c:type:`PyDateTime_Time`, including subclasses. The argument " @@ -384,7 +394,7 @@ msgstr "" "從 time 物件中提取欄位的巨集。引數必須是個 :c:type:`PyDateTime_Time` 的實例," "包括子類別。引數不得為 ``NULL``,並且不會檢查型別:" -#: ../../c-api/datetime.rst:322 +#: ../../c-api/datetime.rst:331 msgid "" "Macros to extract fields from time delta objects. The argument must be an " "instance of :c:type:`PyDateTime_Delta`, including subclasses. The argument " @@ -393,23 +403,23 @@ msgstr "" "從 time delta 物件中提取欄位的巨集。引數必須是個 :c:type:`PyDateTime_Delta` " "的實例,包括子類別。引數不能為 ``NULL``,並且不會檢查型別:" -#: ../../c-api/datetime.rst:328 +#: ../../c-api/datetime.rst:337 msgid "Return the number of days, as an int from -999999999 to 999999999." msgstr "以 -999999999 到 999999999 之間的整數形式回傳天數。" -#: ../../c-api/datetime.rst:335 +#: ../../c-api/datetime.rst:344 msgid "Return the number of seconds, as an int from 0 through 86399." msgstr "以 0 到 86399 之間的整數形式回傳秒數。" -#: ../../c-api/datetime.rst:342 +#: ../../c-api/datetime.rst:351 msgid "Return the number of microseconds, as an int from 0 through 999999." msgstr "以 0 到 999999 之間的整數形式回傳微秒數。" -#: ../../c-api/datetime.rst:347 +#: ../../c-api/datetime.rst:356 msgid "Macros for the convenience of modules implementing the DB API:" msgstr "為了方便模組實作 DB API 的巨集:" -#: ../../c-api/datetime.rst:351 +#: ../../c-api/datetime.rst:360 msgid "" "Create and return a new :class:`datetime.datetime` object given an argument " "tuple suitable for passing to :meth:`datetime.datetime.fromtimestamp`." @@ -417,7 +427,7 @@ msgstr "" "給定一個適合傳遞給 :meth:`datetime.datetime.fromtimestamp` 的引數元組,建立並" "回傳一個新的 :class:`datetime.datetime` 物件。" -#: ../../c-api/datetime.rst:357 +#: ../../c-api/datetime.rst:366 msgid "" "Create and return a new :class:`datetime.date` object given an argument " "tuple suitable for passing to :meth:`datetime.date.fromtimestamp`." @@ -425,20 +435,20 @@ msgstr "" "給定一個適合傳遞給 :meth:`datetime.date.fromtimestamp` 的引數元組,建立並回傳" "一個新的 :class:`datetime.date` 物件。" -#: ../../c-api/datetime.rst:362 +#: ../../c-api/datetime.rst:371 msgid "Internal data" msgstr "內部資料" -#: ../../c-api/datetime.rst:364 +#: ../../c-api/datetime.rst:373 msgid "" "The following symbols are exposed by the C API but should be considered " "internal-only." msgstr "以下符號由 C API 公開,但應視為僅供內部使用。" -#: ../../c-api/datetime.rst:369 +#: ../../c-api/datetime.rst:378 msgid "Name of the datetime capsule to pass to :c:func:`PyCapsule_Import`." msgstr "傳遞給 :c:func:`PyCapsule_Import` 的 datetime capsule 名稱。" -#: ../../c-api/datetime.rst:371 +#: ../../c-api/datetime.rst:380 msgid "Internal usage only. Use :c:macro:`PyDateTime_IMPORT` instead." msgstr "僅供內部使用。請改用 :c:macro:`PyDateTime_IMPORT`。" diff --git a/c-api/descriptor.po b/c-api/descriptor.po index 09817d0e63f..6fcff1bbcbb 100644 --- a/c-api/descriptor.po +++ b/c-api/descriptor.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-16 00:27+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2021-12-09 20:56+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -34,16 +34,12 @@ msgstr "" "典)中。" #: ../../c-api/descriptor.rst:13 -msgid "The type object for the built-in descriptor types." -msgstr "內建 descriptor 型別的型別物件。" - -#: ../../c-api/descriptor.rst:18 msgid "" "Create a new get-set descriptor for extension type *type* from the :c:type:" "`PyGetSetDef` structure *getset*." msgstr "" -#: ../../c-api/descriptor.rst:21 +#: ../../c-api/descriptor.rst:16 msgid "" "Get-set descriptors expose attributes implemented by C getter and setter " "functions rather than stored directly in the instance. This is the same kind " @@ -51,21 +47,21 @@ msgid "" "and it appears in Python as a :class:`types.GetSetDescriptorType` object." msgstr "" -#: ../../c-api/descriptor.rst:26 ../../c-api/descriptor.rst:39 -#: ../../c-api/descriptor.rst:70 ../../c-api/descriptor.rst:101 -#: ../../c-api/descriptor.rst:123 +#: ../../c-api/descriptor.rst:21 ../../c-api/descriptor.rst:34 +#: ../../c-api/descriptor.rst:65 ../../c-api/descriptor.rst:96 +#: ../../c-api/descriptor.rst:118 msgid "" "On success, return a :term:`strong reference` to the descriptor. Return " "``NULL`` with an exception set on failure." msgstr "" -#: ../../c-api/descriptor.rst:31 +#: ../../c-api/descriptor.rst:26 msgid "" "Create a new member descriptor for extension type *type* from the :c:type:" "`PyMemberDef` structure *member*." msgstr "" -#: ../../c-api/descriptor.rst:34 +#: ../../c-api/descriptor.rst:29 msgid "" "Member descriptors expose fields in the type's C struct as Python " "attributes. This is the same kind of descriptor created for entries in :c:" @@ -73,7 +69,7 @@ msgid "" "`types.MemberDescriptorType` object." msgstr "" -#: ../../c-api/descriptor.rst:44 +#: ../../c-api/descriptor.rst:39 msgid "" "The type object for member descriptor objects created from :c:type:" "`PyMemberDef` structures. These descriptors expose fields of a C struct as " @@ -81,7 +77,7 @@ msgid "" "objects in Python." msgstr "" -#: ../../c-api/descriptor.rst:53 +#: ../../c-api/descriptor.rst:48 msgid "" "The type object for get/set descriptor objects created from :c:type:" "`PyGetSetDef` structures. These descriptors implement attributes whose value " @@ -90,13 +86,13 @@ msgid "" "objects in Python." msgstr "" -#: ../../c-api/descriptor.rst:62 +#: ../../c-api/descriptor.rst:57 msgid "" "Create a new method descriptor for extension type *type* from the :c:type:" "`PyMethodDef` structure *meth*." msgstr "" -#: ../../c-api/descriptor.rst:65 +#: ../../c-api/descriptor.rst:60 msgid "" "Method descriptors expose C functions as methods on a type. This is the same " "kind of descriptor created for entries in :c:member:`~PyTypeObject." @@ -104,7 +100,7 @@ msgid "" "MethodDescriptorType` object." msgstr "" -#: ../../c-api/descriptor.rst:75 +#: ../../c-api/descriptor.rst:70 msgid "" "The type object for method descriptor objects created from :c:type:" "`PyMethodDef` structures. These descriptors expose C functions as methods on " @@ -112,25 +108,25 @@ msgid "" "Python." msgstr "" -#: ../../c-api/descriptor.rst:83 +#: ../../c-api/descriptor.rst:78 msgid "Describes a slot wrapper used by :c:func:`PyDescr_NewWrapper`." msgstr "" -#: ../../c-api/descriptor.rst:85 +#: ../../c-api/descriptor.rst:80 msgid "" "Each ``wrapperbase`` record stores the Python-visible name and metadata for " "a special method implemented by a type slot, together with the wrapper " "function used to adapt that slot to Python's calling convention." msgstr "" -#: ../../c-api/descriptor.rst:91 +#: ../../c-api/descriptor.rst:86 msgid "" "Create a new wrapper descriptor for extension type *type* from the :c:struct:" "`wrapperbase` structure *base* and the wrapped slot function pointer " "*wrapped*." msgstr "" -#: ../../c-api/descriptor.rst:96 +#: ../../c-api/descriptor.rst:91 msgid "" "Wrapper descriptors expose special methods implemented by type slots. This " "is the same kind of descriptor that CPython creates for slot-based special " @@ -138,7 +134,7 @@ msgid "" "class:`types.WrapperDescriptorType` object." msgstr "" -#: ../../c-api/descriptor.rst:106 +#: ../../c-api/descriptor.rst:101 msgid "" "The type object for wrapper descriptor objects created by :c:func:" "`PyDescr_NewWrapper` and :c:func:`PyWrapper_New`. Wrapper descriptors are " @@ -147,13 +143,13 @@ msgid "" "objects." msgstr "" -#: ../../c-api/descriptor.rst:115 +#: ../../c-api/descriptor.rst:110 msgid "" "Create a new class method descriptor for extension type *type* from the :c:" "type:`PyMethodDef` structure *method*." msgstr "" -#: ../../c-api/descriptor.rst:118 +#: ../../c-api/descriptor.rst:113 msgid "" "Class method descriptors expose C methods that receive the class rather than " "an instance when accessed. This is the same kind of descriptor created for " @@ -161,7 +157,7 @@ msgid "" "appears in Python as a :class:`types.ClassMethodDescriptorType` object." msgstr "" -#: ../../c-api/descriptor.rst:128 +#: ../../c-api/descriptor.rst:123 msgid "" "Return non-zero if the descriptor object *descr* describes a data attribute, " "or ``0`` if it describes a method. *descr* must be a descriptor object; " @@ -170,13 +166,13 @@ msgstr "" "如果 descriptor 物件 *descr* 描述的是一個資料屬性則回傳非零值,或者如果它描述" "的是一個方法則回傳 ``0``。*descr* 必須為一個 descriptor 物件;沒有錯誤檢查。" -#: ../../c-api/descriptor.rst:135 +#: ../../c-api/descriptor.rst:130 msgid "" "Create a new bound wrapper object from the wrapper descriptor *d* and the " "instance *self*." msgstr "" -#: ../../c-api/descriptor.rst:138 +#: ../../c-api/descriptor.rst:133 msgid "" "This is the bound form of a wrapper descriptor created by :c:func:" "`PyDescr_NewWrapper`. CPython creates these objects when a slot wrapper is " @@ -184,29 +180,47 @@ msgid "" "MethodWrapperType` objects." msgstr "" -#: ../../c-api/descriptor.rst:143 +#: ../../c-api/descriptor.rst:138 msgid "" "On success, return a :term:`strong reference` to the wrapper object. Return " "``NULL`` with an exception set on failure." msgstr "" -#: ../../c-api/descriptor.rst:147 +#: ../../c-api/descriptor.rst:143 +msgid "This is a macro including the common fields for a descriptor object." +msgstr "" + +#: ../../c-api/descriptor.rst:146 +msgid "" +"This was included in Python's C API by mistake; do not use it in extensions. " +"For creating custom descriptor objects, create a class implementing the " +"descriptor protocol (:c:member:`~PyTypeObject.tp_descr_get` and :c:member:" +"`~PyTypeObject.tp_descr_set`)." +msgstr "" + +#: ../../c-api/descriptor.rst:155 msgid "Built-in descriptors" msgstr "內建描述器" -#: ../../c-api/descriptor.rst:151 +#: ../../c-api/descriptor.rst:159 +msgid "" +"The type object for property objects. This is the same object as :class:" +"`property` in the Python layer." +msgstr "" + +#: ../../c-api/descriptor.rst:165 msgid "" "The type object for super objects. This is the same object as :class:`super` " "in the Python layer." msgstr "" -#: ../../c-api/descriptor.rst:157 +#: ../../c-api/descriptor.rst:171 msgid "" "The type of class method objects. This is the same object as :class:" "`classmethod` in the Python layer." msgstr "" -#: ../../c-api/descriptor.rst:163 +#: ../../c-api/descriptor.rst:177 msgid "" "The type object for C-level class method descriptor objects. This is the " "type of the descriptors created for :func:`classmethod` defined in C " @@ -214,34 +228,37 @@ msgid "" "objects in Python." msgstr "" -#: ../../c-api/descriptor.rst:171 +#: ../../c-api/descriptor.rst:185 msgid "" "Create a new :class:`classmethod` object wrapping *callable*. *callable* " "must be a callable object and must not be ``NULL``." msgstr "" -#: ../../c-api/descriptor.rst:174 +#: ../../c-api/descriptor.rst:188 msgid "" "On success, this function returns a :term:`strong reference` to a new class " "method descriptor. On failure, this function returns ``NULL`` with an " "exception set." msgstr "" -#: ../../c-api/descriptor.rst:181 +#: ../../c-api/descriptor.rst:195 msgid "" "The type of static method objects. This is the same object as :class:" "`staticmethod` in the Python layer." msgstr "" -#: ../../c-api/descriptor.rst:187 +#: ../../c-api/descriptor.rst:201 msgid "" "Create a new :class:`staticmethod` object wrapping *callable*. *callable* " "must be a callable object and must not be ``NULL``." msgstr "" -#: ../../c-api/descriptor.rst:190 +#: ../../c-api/descriptor.rst:204 msgid "" "On success, this function returns a :term:`strong reference` to a new static " "method descriptor. On failure, this function returns ``NULL`` with an " "exception set." msgstr "" + +#~ msgid "The type object for the built-in descriptor types." +#~ msgstr "內建 descriptor 型別的型別物件。" diff --git a/c-api/dict.po b/c-api/dict.po index f04cedf2cae..ed69c633e4e 100644 --- a/c-api/dict.po +++ b/c-api/dict.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-02 00:39+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,7 +20,7 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/dict.rst:6 -msgid "Dictionary Objects" +msgid "Dictionary objects" msgstr "字典物件" #: ../../c-api/dict.rst:13 @@ -63,7 +63,21 @@ msgid "" "modification of the dictionary for non-dynamic class types." msgstr "" -#: ../../c-api/dict.rst:48 +#: ../../c-api/dict.rst:45 +msgid "" +"The first argument can be a :class:`dict`, a :class:`frozendict`, or a " +"mapping." +msgstr "" + +#: ../../c-api/dict.rst:48 ../../c-api/dict.rst:84 ../../c-api/dict.rst:98 +#: ../../c-api/dict.rst:165 ../../c-api/dict.rst:196 ../../c-api/dict.rst:214 +#: ../../c-api/dict.rst:239 ../../c-api/dict.rst:251 ../../c-api/dict.rst:337 +#: ../../c-api/dict.rst:347 ../../c-api/dict.rst:358 ../../c-api/dict.rst:371 +#: ../../c-api/dict.rst:379 ../../c-api/dict.rst:453 +msgid "Also accept :class:`frozendict`." +msgstr "" + +#: ../../c-api/dict.rst:54 msgid "" "The type object for mapping proxy objects created by :c:func:" "`PyDictProxy_New` and for the read-only ``__dict__`` attribute of many built-" @@ -73,37 +87,49 @@ msgid "" "operations. This corresponds to :class:`types.MappingProxyType` in Python." msgstr "" -#: ../../c-api/dict.rst:59 +#: ../../c-api/dict.rst:65 msgid "Empty an existing dictionary of all key-value pairs." msgstr "清空現有字典中的所有鍵值對。" -#: ../../c-api/dict.rst:64 +#: ../../c-api/dict.rst:67 +msgid "" +"Do nothing if the argument is not a :class:`dict` or a :class:`!dict` " +"subclass." +msgstr "" + +#: ../../c-api/dict.rst:73 msgid "" "Determine if dictionary *p* contains *key*. If an item in *p* matches " "*key*, return ``1``, otherwise return ``0``. On error, return ``-1``. This " "is equivalent to the Python expression ``key in p``." msgstr "" -#: ../../c-api/dict.rst:70 ../../c-api/dict.rst:97 ../../c-api/dict.rst:117 -#: ../../c-api/dict.rst:140 ../../c-api/dict.rst:257 ../../c-api/dict.rst:279 +#: ../../c-api/dict.rst:77 ../../c-api/dict.rst:94 ../../c-api/dict.rst:156 +#: ../../c-api/dict.rst:177 ../../c-api/dict.rst:335 ../../c-api/dict.rst:345 +#: ../../c-api/dict.rst:356 ../../c-api/dict.rst:396 +msgid "The first argument can be a :class:`dict` or a :class:`frozendict`." +msgstr "" + +#: ../../c-api/dict.rst:81 ../../c-api/dict.rst:115 ../../c-api/dict.rst:135 +#: ../../c-api/dict.rst:160 ../../c-api/dict.rst:294 ../../c-api/dict.rst:316 msgid "" "The operation is atomic on :term:`free threading ` when " "*key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:" "`bytes`." msgstr "" -#: ../../c-api/dict.rst:76 +#: ../../c-api/dict.rst:90 msgid "" "This is the same as :c:func:`PyDict_Contains`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:85 +#: ../../c-api/dict.rst:104 msgid "Return a new dictionary that contains the same key-value pairs as *p*." msgstr "回傳一個新的字典,包含與 *p* 相同的鍵值對。" -#: ../../c-api/dict.rst:90 +#: ../../c-api/dict.rst:108 msgid "" "Insert *val* into the dictionary *p* with a key of *key*. *key* must be :" "term:`hashable`; if it isn't, :exc:`TypeError` will be raised. Return ``0`` " @@ -111,14 +137,14 @@ msgid "" "a reference to *val*." msgstr "" -#: ../../c-api/dict.rst:103 +#: ../../c-api/dict.rst:121 msgid "" "This is the same as :c:func:`PyDict_SetItem`, but *key* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:110 +#: ../../c-api/dict.rst:128 msgid "" "Remove the entry in dictionary *p* with key *key*. *key* must be :term:" "`hashable`; if it isn't, :exc:`TypeError` is raised. If *key* is not in the " @@ -126,80 +152,80 @@ msgid "" "failure." msgstr "" -#: ../../c-api/dict.rst:123 +#: ../../c-api/dict.rst:141 msgid "" "This is the same as :c:func:`PyDict_DelItem`, but *key* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:130 +#: ../../c-api/dict.rst:148 msgid "" "Return a new :term:`strong reference` to the object from dictionary *p* " "which has a key *key*:" msgstr "" -#: ../../c-api/dict.rst:133 +#: ../../c-api/dict.rst:151 msgid "" "If the key is present, set *\\*result* to a new :term:`strong reference` to " "the value and return ``1``." msgstr "" -#: ../../c-api/dict.rst:135 +#: ../../c-api/dict.rst:153 msgid "If the key is missing, set *\\*result* to ``NULL`` and return ``0``." msgstr "如果鍵不存在,將 *\\*result* 設為 ``NULL`` 並回傳 ``0``。" -#: ../../c-api/dict.rst:136 +#: ../../c-api/dict.rst:154 msgid "" "On error, raise an exception, set *\\*result* to ``NULL`` and return ``-1``." msgstr "錯誤發生時,引發一個例外,將 *\\*result* 設為 ``NULL`` 並回傳 ``-1``。" -#: ../../c-api/dict.rst:145 +#: ../../c-api/dict.rst:168 msgid "See also the :c:func:`PyObject_GetItem` function." msgstr "另見 :c:func:`PyObject_GetItem` 函式。" -#: ../../c-api/dict.rst:150 +#: ../../c-api/dict.rst:173 msgid "" "Return a :term:`borrowed reference` to the object from dictionary *p* which " "has a key *key*. Return ``NULL`` if the key *key* is missing *without* " "setting an exception." msgstr "" -#: ../../c-api/dict.rst:156 +#: ../../c-api/dict.rst:181 msgid "" "Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" "`~object.__eq__` methods are silently ignored. Prefer the :c:func:" "`PyDict_GetItemWithError` function instead." msgstr "" -#: ../../c-api/dict.rst:162 ../../c-api/dict.rst:181 +#: ../../c-api/dict.rst:187 ../../c-api/dict.rst:209 msgid "" "In the :term:`free-threaded build`, the returned :term:`borrowed reference` " "may become invalid if another thread modifies the dictionary concurrently. " "Prefer :c:func:`PyDict_GetItemRef`, which returns a :term:`strong reference`." msgstr "" -#: ../../c-api/dict.rst:167 +#: ../../c-api/dict.rst:192 msgid "" "Calling this API without an :term:`attached thread state` had been allowed " "for historical reason. It is no longer allowed." msgstr "" -#: ../../c-api/dict.rst:174 +#: ../../c-api/dict.rst:202 msgid "" "Variant of :c:func:`PyDict_GetItem` that does not suppress exceptions. " "Return ``NULL`` **with** an exception set if an exception occurred. Return " "``NULL`` **without** an exception set if the key wasn't present." msgstr "" -#: ../../c-api/dict.rst:189 +#: ../../c-api/dict.rst:220 msgid "" "This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:195 +#: ../../c-api/dict.rst:226 msgid "" "Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" "`~object.__eq__` methods or while creating the temporary :class:`str` object " @@ -207,7 +233,7 @@ msgid "" "function with your own :c:func:`PyUnicode_FromString` *key* instead." msgstr "" -#: ../../c-api/dict.rst:203 +#: ../../c-api/dict.rst:234 msgid "" "In the :term:`free-threaded build`, the returned :term:`borrowed reference` " "may become invalid if another thread modifies the dictionary concurrently. " @@ -215,13 +241,13 @@ msgid "" "reference`." msgstr "" -#: ../../c-api/dict.rst:211 +#: ../../c-api/dict.rst:245 msgid "" "Similar to :c:func:`PyDict_GetItemRef`, but *key* is specified as a :c:expr:" "`const char*` UTF-8 encoded bytes string, rather than a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:220 +#: ../../c-api/dict.rst:257 msgid "" "This is the same as the Python-level :meth:`dict.setdefault`. If present, " "it returns the value corresponding to *key* from the dictionary *p*. If the " @@ -231,7 +257,7 @@ msgid "" "the insertion." msgstr "" -#: ../../c-api/dict.rst:230 +#: ../../c-api/dict.rst:267 msgid "" "In the :term:`free-threaded build`, the returned :term:`borrowed reference` " "may become invalid if another thread modifies the dictionary concurrently. " @@ -239,7 +265,7 @@ msgid "" "reference`." msgstr "" -#: ../../c-api/dict.rst:239 +#: ../../c-api/dict.rst:276 msgid "" "Inserts *default_value* into the dictionary *p* with a key of *key* if the " "key is not already present in the dictionary. If *result* is not ``NULL``, " @@ -251,7 +277,7 @@ msgid "" "exception, and sets ``*result`` to ``NULL``." msgstr "" -#: ../../c-api/dict.rst:249 +#: ../../c-api/dict.rst:286 msgid "" "For clarity: if you have a strong reference to *default_value* before " "calling this function, then after it returns, you hold a strong reference to " @@ -259,67 +285,71 @@ msgid "" "to the same object: in that case you hold two separate references to it." msgstr "" -#: ../../c-api/dict.rst:265 +#: ../../c-api/dict.rst:302 msgid "" "Remove *key* from dictionary *p* and optionally return the removed value. Do " "not raise :exc:`KeyError` if the key is missing." msgstr "" -#: ../../c-api/dict.rst:268 +#: ../../c-api/dict.rst:305 msgid "" "If the key is present, set *\\*result* to a new reference to the removed " "value if *result* is not ``NULL``, and return ``1``." msgstr "" -#: ../../c-api/dict.rst:270 +#: ../../c-api/dict.rst:307 msgid "" "If the key is missing, set *\\*result* to ``NULL`` if *result* is not " "``NULL``, and return ``0``." msgstr "" -#: ../../c-api/dict.rst:272 +#: ../../c-api/dict.rst:309 msgid "On error, raise an exception and return ``-1``." msgstr "錯誤發生時,引發一個例外並回傳 ``-1``。" -#: ../../c-api/dict.rst:274 +#: ../../c-api/dict.rst:311 msgid "" "Similar to :meth:`dict.pop`, but without the default value and not raising :" "exc:`KeyError` if the key is missing." msgstr "" -#: ../../c-api/dict.rst:287 +#: ../../c-api/dict.rst:324 msgid "" "Similar to :c:func:`PyDict_Pop`, but *key* is specified as a :c:expr:`const " "char*` UTF-8 encoded bytes string, rather than a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/dict.rst:296 +#: ../../c-api/dict.rst:333 msgid "" "Return a :c:type:`PyListObject` containing all the items from the dictionary." msgstr "回傳一個包含字典中所有項目的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:301 +#: ../../c-api/dict.rst:343 msgid "" "Return a :c:type:`PyListObject` containing all the keys from the dictionary." msgstr "回傳一個包含字典中所有鍵的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:306 +#: ../../c-api/dict.rst:353 msgid "" "Return a :c:type:`PyListObject` containing all the values from the " "dictionary *p*." msgstr "回傳一個包含字典 *p* 中所有值的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:314 +#: ../../c-api/dict.rst:366 msgid "" "Return the number of items in the dictionary. This is equivalent to " "``len(p)`` on a dictionary." msgstr "回傳字典中項目的數量。此與於字典呼叫 ``len(p)`` 等效。" -#: ../../c-api/dict.rst:320 +#: ../../c-api/dict.rst:369 +msgid "The argument can be a :class:`dict` or a :class:`frozendict`." +msgstr "" + +#: ../../c-api/dict.rst:377 msgid "Similar to :c:func:`PyDict_Size`, but without error checking." msgstr "和 :c:func:`PyDict_Size` 類似,但沒有錯誤檢查。" -#: ../../c-api/dict.rst:325 +#: ../../c-api/dict.rst:385 msgid "" "Iterate over all key-value pairs in the dictionary *p*. The :c:type:" "`Py_ssize_t` referred to by *ppos* must be initialized to ``0`` prior to the " @@ -333,11 +363,11 @@ msgid "" "structure is sparse, the offsets are not consecutive." msgstr "" -#: ../../c-api/dict.rst:336 +#: ../../c-api/dict.rst:398 msgid "For example::" msgstr "舉例來說: ::" -#: ../../c-api/dict.rst:338 +#: ../../c-api/dict.rst:400 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -355,14 +385,14 @@ msgstr "" " ...\n" "}" -#: ../../c-api/dict.rst:346 +#: ../../c-api/dict.rst:408 msgid "" "The dictionary *p* should not be mutated during iteration. It is safe to " "modify the values of the keys as you iterate over the dictionary, but only " "so long as the set of keys does not change. For example::" msgstr "" -#: ../../c-api/dict.rst:350 +#: ../../c-api/dict.rst:412 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -400,14 +430,15 @@ msgstr "" " Py_DECREF(o);\n" "}" -#: ../../c-api/dict.rst:368 +#: ../../c-api/dict.rst:430 msgid "" "The function is not thread-safe in the :term:`free-threaded ` build without external synchronization. You can use :c:macro:" -"`Py_BEGIN_CRITICAL_SECTION` to lock the dictionary while iterating over it::" +"threading>` build without external synchronization for a mutable :class:" +"`dict`. You can use :c:macro:`Py_BEGIN_CRITICAL_SECTION` to lock the " +"dictionary while iterating over it::" msgstr "" -#: ../../c-api/dict.rst:373 +#: ../../c-api/dict.rst:435 msgid "" "Py_BEGIN_CRITICAL_SECTION(self->dict);\n" "while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" @@ -421,7 +452,11 @@ msgstr "" "}\n" "Py_END_CRITICAL_SECTION();" -#: ../../c-api/dict.rst:381 +#: ../../c-api/dict.rst:441 +msgid "The function is thread-safe on a :class:`frozendict`." +msgstr "" + +#: ../../c-api/dict.rst:445 msgid "" "On the free-threaded build, this function can be used safely inside a " "critical section. However, the references returned for *pkey* and *pvalue* " @@ -432,7 +467,7 @@ msgid "" "`Py_NewRef`)." msgstr "" -#: ../../c-api/dict.rst:391 +#: ../../c-api/dict.rst:458 msgid "" "Iterate over mapping object *b* adding key-value pairs to dictionary *a*. " "*b* may be a dictionary, or any object supporting :c:func:`PyMapping_Keys` " @@ -442,7 +477,7 @@ msgid "" "or ``-1`` if an exception was raised." msgstr "" -#: ../../c-api/dict.rst:400 ../../c-api/dict.rst:416 +#: ../../c-api/dict.rst:467 ../../c-api/dict.rst:483 msgid "" "In the :term:`free-threaded build`, when *b* is a :class:`dict` (with the " "standard iterator), both *a* and *b* are locked for the duration of the " @@ -450,7 +485,7 @@ msgid "" "concurrently modified by another thread." msgstr "" -#: ../../c-api/dict.rst:408 +#: ../../c-api/dict.rst:475 msgid "" "This is the same as ``PyDict_Merge(a, b, 1)`` in C, and is similar to ``a." "update(b)`` in Python except that :c:func:`PyDict_Update` doesn't fall back " @@ -459,7 +494,7 @@ msgid "" "exception was raised." msgstr "" -#: ../../c-api/dict.rst:424 +#: ../../c-api/dict.rst:491 msgid "" "Update or merge into dictionary *a*, from the key-value pairs in *seq2*. " "*seq2* must be an iterable object producing iterable objects of length 2, " @@ -468,7 +503,7 @@ msgid "" "if an exception was raised. Equivalent Python (except for the return value)::" msgstr "" -#: ../../c-api/dict.rst:431 +#: ../../c-api/dict.rst:498 msgid "" "def PyDict_MergeFromSeq2(a, seq2, override):\n" " for key, value in seq2:\n" @@ -480,14 +515,14 @@ msgstr "" " if override or key not in a:\n" " a[key] = value" -#: ../../c-api/dict.rst:438 +#: ../../c-api/dict.rst:505 msgid "" "In the :term:`free-threaded ` build, only *a* is locked. The " "iteration over *seq2* is not synchronized; *seq2* may be concurrently " "modified by another thread." msgstr "" -#: ../../c-api/dict.rst:445 +#: ../../c-api/dict.rst:512 msgid "" "Register *callback* as a dictionary watcher. Return a non-negative integer " "id which must be passed to future calls to :c:func:`PyDict_Watch`. In case " @@ -495,28 +530,28 @@ msgid "" "exception." msgstr "" -#: ../../c-api/dict.rst:452 ../../c-api/dict.rst:467 +#: ../../c-api/dict.rst:519 ../../c-api/dict.rst:534 msgid "" "This function is not internally synchronized. In the :term:`free-threaded " "` build, callers should ensure no concurrent calls to :c:" "func:`PyDict_AddWatcher` or :c:func:`PyDict_ClearWatcher` are in progress." msgstr "" -#: ../../c-api/dict.rst:461 +#: ../../c-api/dict.rst:528 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error (e.g. if the " "given *watcher_id* was never registered.)" msgstr "" -#: ../../c-api/dict.rst:476 +#: ../../c-api/dict.rst:543 msgid "" "Mark dictionary *dict* as watched. The callback granted *watcher_id* by :c:" "func:`PyDict_AddWatcher` will be called when *dict* is modified or " "deallocated. Return ``0`` on success or ``-1`` on error." msgstr "" -#: ../../c-api/dict.rst:484 +#: ../../c-api/dict.rst:551 msgid "" "Mark dictionary *dict* as no longer watched. The callback granted " "*watcher_id* by :c:func:`PyDict_AddWatcher` will no longer be called when " @@ -524,7 +559,7 @@ msgid "" "watched by this watcher. Return ``0`` on success or ``-1`` on error." msgstr "" -#: ../../c-api/dict.rst:493 +#: ../../c-api/dict.rst:560 msgid "" "Enumeration of possible dictionary watcher events: ``PyDict_EVENT_ADDED``, " "``PyDict_EVENT_MODIFIED``, ``PyDict_EVENT_DELETED``, " @@ -532,11 +567,11 @@ msgid "" "``PyDict_EVENT_DEALLOCATED``." msgstr "" -#: ../../c-api/dict.rst:501 +#: ../../c-api/dict.rst:568 msgid "Type of a dict watcher callback function." msgstr "" -#: ../../c-api/dict.rst:503 +#: ../../c-api/dict.rst:570 msgid "" "If *event* is ``PyDict_EVENT_CLEARED`` or ``PyDict_EVENT_DEALLOCATED``, both " "*key* and *new_value* will be ``NULL``. If *event* is ``PyDict_EVENT_ADDED`` " @@ -545,7 +580,7 @@ msgid "" "dictionary and *new_value* will be ``NULL``." msgstr "" -#: ../../c-api/dict.rst:509 +#: ../../c-api/dict.rst:576 msgid "" "``PyDict_EVENT_CLONED`` occurs when *dict* was previously empty and another " "dict is merged into it. To maintain efficiency of this operation, per-key " @@ -553,14 +588,14 @@ msgid "" "``PyDict_EVENT_CLONED`` is issued, and *key* will be the source dictionary." msgstr "" -#: ../../c-api/dict.rst:515 +#: ../../c-api/dict.rst:582 msgid "" "The callback may inspect but must not modify *dict*; doing so could have " "unpredictable effects, including infinite recursion. Do not trigger Python " "code execution in the callback, as it could modify the dict as a side effect." msgstr "" -#: ../../c-api/dict.rst:519 +#: ../../c-api/dict.rst:586 msgid "" "If *event* is ``PyDict_EVENT_DEALLOCATED``, taking a new reference in the " "callback to the about-to-be-destroyed dictionary will resurrect it and " @@ -569,20 +604,20 @@ msgid "" "again." msgstr "" -#: ../../c-api/dict.rst:525 +#: ../../c-api/dict.rst:592 msgid "" "Callbacks occur before the notified modification to *dict* takes place, so " "the prior state of *dict* can be inspected." msgstr "" -#: ../../c-api/dict.rst:528 +#: ../../c-api/dict.rst:595 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/dict.rst:532 +#: ../../c-api/dict.rst:599 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " @@ -591,11 +626,11 @@ msgid "" "it before returning." msgstr "" -#: ../../c-api/dict.rst:542 -msgid "Dictionary View Objects" +#: ../../c-api/dict.rst:609 +msgid "Dictionary view objects" msgstr "字典視圖物件" -#: ../../c-api/dict.rst:546 +#: ../../c-api/dict.rst:613 msgid "" "Return true if *op* is a view of a set inside a dictionary. This is " "currently equivalent to :c:expr:`PyDictKeys_Check(op) || " @@ -604,55 +639,116 @@ msgstr "" "若 *op* 是一個字典中集合的視圖則會回傳 true。這目前等同於 :c:expr:" "`PyDictKeys_Check(op) || PyDictItems_Check(op)`。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:553 +#: ../../c-api/dict.rst:620 msgid "" "Type object for a view of dictionary keys. In Python, this is the type of " "the object returned by :meth:`dict.keys`." msgstr "" -#: ../../c-api/dict.rst:559 +#: ../../c-api/dict.rst:626 msgid "" "Return true if *op* is an instance of a dictionary keys view. This function " "always succeeds." msgstr "若 *op* 是一個字典鍵視圖的實例則會回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:565 +#: ../../c-api/dict.rst:632 msgid "" "Type object for a view of dictionary values. In Python, this is the type of " "the object returned by :meth:`dict.values`." msgstr "" -#: ../../c-api/dict.rst:571 +#: ../../c-api/dict.rst:638 msgid "" "Return true if *op* is an instance of a dictionary values view. This " "function always succeeds." msgstr "若 *op* 是一個字典值視圖的實例則會回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:577 +#: ../../c-api/dict.rst:644 msgid "" "Type object for a view of dictionary items. In Python, this is the type of " "the object returned by :meth:`dict.items`." msgstr "" -#: ../../c-api/dict.rst:583 +#: ../../c-api/dict.rst:650 msgid "" "Return true if *op* is an instance of a dictionary items view. This function " "always succeeds." msgstr "" "若 *op* 是一個字典項目視圖的實例則會回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:588 -msgid "Ordered Dictionaries" +#: ../../c-api/dict.rst:655 +msgid "Frozen dictionary objects" +msgstr "凍結字典物件" + +#: ../../c-api/dict.rst:662 +msgid "" +"This instance of :c:type:`PyTypeObject` represents the Python frozen " +"dictionary type. This is the same object as :class:`frozendict` in the " +"Python layer." +msgstr "" +"此 :c:type:`PyTypeObject` 實例代表 Python 凍結字典型別。此與 Python 層中" +"的 :class:`frozendict` 為同一個物件。" + +#: ../../c-api/dict.rst:669 +msgid "" +"Return true if *p* is a :class:`dict` object, a :class:`frozendict` object, " +"or an instance of a subtype of the :class:`!dict` or :class:`!frozendict` " +"type. This function always succeeds." +msgstr "" +"若 *p* 是一個 :class:`dict` 物件、:class:`frozendict` 物件,或 :class:`!" +"dict` 或 :class:`!frozendict` 型別之子型別的實例,則回傳 true。此函式每次都會" +"執行成功。" + +#: ../../c-api/dict.rst:677 +msgid "" +"Return true if *p* is a :class:`dict` object or a :class:`frozendict` " +"object, but not an instance of a subtype of the :class:`!dict` or :class:`!" +"frozendict` type. This function always succeeds." +msgstr "" +"若 *p* 是一個 :class:`dict` 物件或 :class:`frozendict` 物件,但不是 :class:`!" +"dict` 或 :class:`!frozendict` 型別之子型別的實例,則回傳 true。此函式每次都會" +"執行成功。" + +#: ../../c-api/dict.rst:685 +msgid "" +"Return true if *p* is a :class:`frozendict` object or an instance of a " +"subtype of the :class:`!frozendict` type. This function always succeeds." +msgstr "" +"若 *p* 是一個 :class:`frozendict` 物件或 :class:`!frozendict` 型別之子型別的" +"實例,則回傳 true。此函式每次都會執行成功。" + +#: ../../c-api/dict.rst:692 +msgid "" +"Return true if *p* is a :class:`frozendict` object, but not an instance of a " +"subtype of the :class:`!frozendict` type. This function always succeeds." +msgstr "" +"若 *p* 是一個 :class:`frozendict` 物件,但不是 :class:`!frozendict` 型別之子" +"型別的實例,則回傳 true。此函式每次都會執行成功。" + +#: ../../c-api/dict.rst:699 +msgid "" +"Return a new :class:`frozendict` from an iterable, or ``NULL`` on failure " +"with an exception set." +msgstr "" +"從一個可疊代物件回傳一個新的 :class:`frozendict`,或在失敗時回傳 ``NULL`` 並" +"設定例外。" + +#: ../../c-api/dict.rst:702 +msgid "Create an empty dictionary if *iterable* is ``NULL``." +msgstr "如果 *iterable* 為 ``NULL``,則建立一個空字典。" + +#: ../../c-api/dict.rst:706 +msgid "Ordered dictionaries" msgstr "有序字典" -#: ../../c-api/dict.rst:590 +#: ../../c-api/dict.rst:708 msgid "" "Python's C API provides interface for :class:`collections.OrderedDict` from " "C. Since Python 3.7, dictionaries are ordered by default, so there is " "usually little need for these functions; prefer ``PyDict*`` where possible." msgstr "" -#: ../../c-api/dict.rst:597 +#: ../../c-api/dict.rst:715 msgid "" "Type object for ordered dictionaries. This is the same object as :class:" "`collections.OrderedDict` in the Python layer." @@ -660,7 +756,7 @@ msgstr "" "有序字典的型別物件。此與 Python 層中的 :class:`collections.OrderedDict` 為同" "一個物件。" -#: ../../c-api/dict.rst:603 +#: ../../c-api/dict.rst:721 msgid "" "Return true if *od* is an ordered dictionary object or an instance of a " "subtype of the :class:`~collections.OrderedDict` type. This function always " @@ -669,7 +765,7 @@ msgstr "" "若 *od* 是一個有序字典物件或 :class:`~collections.OrderedDict` 的子型別實例則" "會回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:610 +#: ../../c-api/dict.rst:728 msgid "" "Return true if *od* is an ordered dictionary object, but not an instance of " "a subtype of the :class:`~collections.OrderedDict` type. This function " @@ -678,79 +774,79 @@ msgstr "" "若 *od* 是一個有序字典物件但並不是一個 :class:`~collections.OrderedDict` 子型" "別的實例,則回傳 true。此函式每次都會執行成功。" -#: ../../c-api/dict.rst:617 +#: ../../c-api/dict.rst:735 msgid "Analogous to :c:type:`PyDictKeys_Type` for ordered dictionaries." msgstr "" -#: ../../c-api/dict.rst:622 +#: ../../c-api/dict.rst:740 msgid "Analogous to :c:type:`PyDictValues_Type` for ordered dictionaries." msgstr "" -#: ../../c-api/dict.rst:627 +#: ../../c-api/dict.rst:745 msgid "Analogous to :c:type:`PyDictItems_Type` for ordered dictionaries." msgstr "" -#: ../../c-api/dict.rst:632 +#: ../../c-api/dict.rst:750 msgid "Return a new empty ordered dictionary, or ``NULL`` on failure." msgstr "回傳一個新的空有序字典,或在失敗時回傳 ``NULL``。" -#: ../../c-api/dict.rst:634 +#: ../../c-api/dict.rst:752 msgid "This is analogous to :c:func:`PyDict_New`." msgstr "這和 :c:func:`PyDict_New` 類似。" -#: ../../c-api/dict.rst:639 +#: ../../c-api/dict.rst:757 msgid "" "Insert *value* into the ordered dictionary *od* with a key of *key*. Return " "``0`` on success or ``-1`` with an exception set on failure." msgstr "" -#: ../../c-api/dict.rst:642 +#: ../../c-api/dict.rst:760 msgid "This is analogous to :c:func:`PyDict_SetItem`." msgstr "這和 :c:func:`PyDict_SetItem` 類似。" -#: ../../c-api/dict.rst:647 +#: ../../c-api/dict.rst:765 msgid "" "Remove the entry in the ordered dictionary *od* with key *key*. Return ``0`` " "on success or ``-1`` with an exception set on failure." msgstr "" -#: ../../c-api/dict.rst:650 +#: ../../c-api/dict.rst:768 msgid "This is analogous to :c:func:`PyDict_DelItem`." msgstr "這和 :c:func:`PyDict_DelItem` 類似。" -#: ../../c-api/dict.rst:653 +#: ../../c-api/dict.rst:771 msgid "These are :term:`soft deprecated` aliases to ``PyDict`` APIs:" msgstr "" -#: ../../c-api/dict.rst:660 +#: ../../c-api/dict.rst:778 msgid "``PyODict``" msgstr "``PyODict``" -#: ../../c-api/dict.rst:661 +#: ../../c-api/dict.rst:779 msgid "``PyDict``" msgstr "``PyDict``" -#: ../../c-api/dict.rst:663 +#: ../../c-api/dict.rst:781 msgid ":c:func:`PyDict_GetItem`" msgstr ":c:func:`PyDict_GetItem`" -#: ../../c-api/dict.rst:665 +#: ../../c-api/dict.rst:783 msgid ":c:func:`PyDict_GetItemWithError`" msgstr ":c:func:`PyDict_GetItemWithError`" -#: ../../c-api/dict.rst:667 +#: ../../c-api/dict.rst:785 msgid ":c:func:`PyDict_GetItemString`" msgstr ":c:func:`PyDict_GetItemString`" -#: ../../c-api/dict.rst:669 +#: ../../c-api/dict.rst:787 msgid ":c:func:`PyDict_Contains`" msgstr ":c:func:`PyDict_Contains`" -#: ../../c-api/dict.rst:671 +#: ../../c-api/dict.rst:789 msgid ":c:func:`PyDict_Size`" msgstr ":c:func:`PyDict_Size`" -#: ../../c-api/dict.rst:673 +#: ../../c-api/dict.rst:791 msgid ":c:func:`PyDict_GET_SIZE`" msgstr ":c:func:`PyDict_GET_SIZE`" @@ -762,10 +858,10 @@ msgstr "object(物件)" msgid "dictionary" msgstr "dictionary(字典)" -#: ../../c-api/dict.rst:312 +#: ../../c-api/dict.rst:364 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/dict.rst:312 +#: ../../c-api/dict.rst:364 msgid "len" msgstr "len" diff --git a/c-api/exceptions.po b/c-api/exceptions.po index 4a33dad2e16..e01e9091d49 100644 --- a/c-api/exceptions.po +++ b/c-api/exceptions.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-04 01:02+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:05+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -795,48 +795,56 @@ msgid "Executing a pending :ref:`remote debugger ` script." msgstr "" #: ../../c-api/exceptions.rst:719 +msgid "Raise the exception set by :c:func:`PyThreadState_SetAsyncExc`." +msgstr "" + +#: ../../c-api/exceptions.rst:721 msgid "" "If any handler raises an exception, immediately return ``-1`` with that " "exception set. Any remaining interruptions are left to be processed on the " "next :c:func:`PyErr_CheckSignals()` invocation, if appropriate." msgstr "" -#: ../../c-api/exceptions.rst:724 +#: ../../c-api/exceptions.rst:726 msgid "" "If all handlers finish successfully, or there are no handlers to run, return " "``0``." msgstr "" -#: ../../c-api/exceptions.rst:727 +#: ../../c-api/exceptions.rst:729 msgid "This function may now invoke the garbage collector." msgstr "" -#: ../../c-api/exceptions.rst:730 +#: ../../c-api/exceptions.rst:732 msgid "" "This function may now execute a remote debugger script, if remote debugging " "is enabled." msgstr "" -#: ../../c-api/exceptions.rst:742 +#: ../../c-api/exceptions.rst:736 +msgid "The exception set by :c:func:`PyThreadState_SetAsyncExc` is now raised." +msgstr "" + +#: ../../c-api/exceptions.rst:747 msgid "" "Simulate the effect of a :c:macro:`!SIGINT` signal arriving. This is " "equivalent to ``PyErr_SetInterruptEx(SIGINT)``." msgstr "" -#: ../../c-api/exceptions.rst:746 ../../c-api/exceptions.rst:773 +#: ../../c-api/exceptions.rst:751 ../../c-api/exceptions.rst:778 msgid "" "This function is async-signal-safe. It can be called without an :term:" "`attached thread state` and from a C signal handler." msgstr "" -#: ../../c-api/exceptions.rst:756 +#: ../../c-api/exceptions.rst:761 msgid "" "Simulate the effect of a signal arriving. The next time :c:func:" "`PyErr_CheckSignals` is called, the Python signal handler for the given " "signal number will be called." msgstr "" -#: ../../c-api/exceptions.rst:760 +#: ../../c-api/exceptions.rst:765 msgid "" "This function can be called by C code that sets up its own signal handling " "and wants Python signal handlers to be invoked as expected when an " @@ -844,27 +852,27 @@ msgid "" "interrupt an operation)." msgstr "" -#: ../../c-api/exceptions.rst:765 +#: ../../c-api/exceptions.rst:770 msgid "" "If the given signal isn't handled by Python (it was set to :py:const:`signal." "SIG_DFL` or :py:const:`signal.SIG_IGN`), it will be ignored." msgstr "" -#: ../../c-api/exceptions.rst:768 +#: ../../c-api/exceptions.rst:773 msgid "" "If *signum* is outside of the allowed range of signal numbers, ``-1`` is " "returned. Otherwise, ``0`` is returned. The error indicator is never " "changed by this function." msgstr "" -#: ../../c-api/exceptions.rst:781 +#: ../../c-api/exceptions.rst:786 msgid "" "This utility function specifies a file descriptor to which the signal number " "is written as a single byte whenever a signal is received. *fd* must be non-" "blocking. It returns the previous such file descriptor." msgstr "" -#: ../../c-api/exceptions.rst:785 +#: ../../c-api/exceptions.rst:790 msgid "" "The value ``-1`` disables the feature; this is the initial state. This is " "equivalent to :func:`signal.set_wakeup_fd` in Python, but without any error " @@ -872,15 +880,15 @@ msgid "" "be called from the main thread." msgstr "" -#: ../../c-api/exceptions.rst:790 +#: ../../c-api/exceptions.rst:795 msgid "On Windows, the function now also supports socket handles." msgstr "" -#: ../../c-api/exceptions.rst:795 +#: ../../c-api/exceptions.rst:800 msgid "Exception Classes" msgstr "例外類別" -#: ../../c-api/exceptions.rst:799 +#: ../../c-api/exceptions.rst:804 msgid "" "This utility function creates and returns a new exception class. The *name* " "argument must be the name of the new exception, a C string of the form " @@ -889,7 +897,7 @@ msgid "" "(accessible in C as :c:data:`PyExc_Exception`)." msgstr "" -#: ../../c-api/exceptions.rst:805 +#: ../../c-api/exceptions.rst:810 msgid "" "The :attr:`~type.__module__` attribute of the new class is set to the first " "part (up to the last dot) of the *name* argument, and the class name is set " @@ -899,51 +907,63 @@ msgid "" "variables and methods." msgstr "" -#: ../../c-api/exceptions.rst:814 +#: ../../c-api/exceptions.rst:819 msgid "" "Same as :c:func:`PyErr_NewException`, except that the new exception class " "can easily be given a docstring: If *doc* is non-``NULL``, it will be used " "as the docstring for the exception class." msgstr "" -#: ../../c-api/exceptions.rst:823 +#: ../../c-api/exceptions.rst:828 msgid "" "Return non-zero if *ob* is an exception class, zero otherwise. This function " "always succeeds." msgstr "" -#: ../../c-api/exceptions.rst:828 +#: ../../c-api/exceptions.rst:833 msgid "Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*." msgstr "回傳例外類別 *ob* 的 :c:member:`~PyTypeObject.tp_name`。" -#: ../../c-api/exceptions.rst:832 +#: ../../c-api/exceptions.rst:838 +msgid "This is a macro including the base fields for an exception object." +msgstr "" + +#: ../../c-api/exceptions.rst:841 +msgid "" +"This was included in Python's C API by mistake and is not designed for use " +"in extensions. For creating custom exception objects, use :c:func:" +"`PyErr_NewException` or otherwise create a class inheriting from :c:data:" +"`PyExc_BaseException`." +msgstr "" + +#: ../../c-api/exceptions.rst:850 msgid "Exception Objects" msgstr "例外物件" -#: ../../c-api/exceptions.rst:836 +#: ../../c-api/exceptions.rst:854 msgid "" "Return true if *op* is an instance of :class:`BaseException`, false " "otherwise. This function always succeeds." msgstr "" -#: ../../c-api/exceptions.rst:842 +#: ../../c-api/exceptions.rst:860 msgid "Equivalent to :c:func:`Py_TYPE(op) `." msgstr "" -#: ../../c-api/exceptions.rst:847 +#: ../../c-api/exceptions.rst:865 msgid "" "Return the traceback associated with the exception as a new reference, as " "accessible from Python through the :attr:`~BaseException.__traceback__` " "attribute. If there is no traceback associated, this returns ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:855 +#: ../../c-api/exceptions.rst:873 msgid "" "Set the traceback associated with the exception to *tb*. Use ``Py_None`` to " "clear it." msgstr "" -#: ../../c-api/exceptions.rst:861 +#: ../../c-api/exceptions.rst:879 msgid "" "Return the context (another exception instance during whose handling *ex* " "was raised) associated with the exception as a new reference, as accessible " @@ -951,14 +971,14 @@ msgid "" "there is no context associated, this returns ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:869 +#: ../../c-api/exceptions.rst:887 msgid "" "Set the context associated with the exception to *ctx*. Use ``NULL`` to " "clear it. There is no type check to make sure that *ctx* is an exception " "instance. This \":term:`steals `\" a reference to *ctx*." msgstr "" -#: ../../c-api/exceptions.rst:876 +#: ../../c-api/exceptions.rst:894 msgid "" "Return the cause (either an exception instance, or ``None``, set by " "``raise ... from ...``) associated with the exception as a new reference, as " @@ -966,7 +986,7 @@ msgid "" "attribute." msgstr "" -#: ../../c-api/exceptions.rst:884 +#: ../../c-api/exceptions.rst:902 msgid "" "Set the cause associated with the exception to *cause*. Use ``NULL`` to " "clear it. There is no type check to make sure that *cause* is either an " @@ -974,21 +994,21 @@ msgid "" "to *cause*." msgstr "" -#: ../../c-api/exceptions.rst:889 +#: ../../c-api/exceptions.rst:907 msgid "" "The :attr:`~BaseException.__suppress_context__` attribute is implicitly set " "to ``True`` by this function." msgstr "" -#: ../../c-api/exceptions.rst:895 +#: ../../c-api/exceptions.rst:913 msgid "Return :attr:`~BaseException.args` of exception *ex*." msgstr "回傳例外 *ex* 的 :attr:`~BaseException.args`。" -#: ../../c-api/exceptions.rst:900 +#: ../../c-api/exceptions.rst:918 msgid "Set :attr:`~BaseException.args` of exception *ex* to *args*." msgstr "設定例外 *ex* 的 :attr:`~BaseException.args` 為 *args*。" -#: ../../c-api/exceptions.rst:904 +#: ../../c-api/exceptions.rst:922 msgid "" "Implement part of the interpreter's implementation of :keyword:`!except*`. " "*orig* is the original exception that was caught, and *excs* is the list of " @@ -1000,98 +1020,98 @@ msgid "" "if there is nothing to reraise." msgstr "" -#: ../../c-api/exceptions.rst:918 +#: ../../c-api/exceptions.rst:936 msgid "Unicode Exception Objects" msgstr "Unicode 例外物件" -#: ../../c-api/exceptions.rst:920 +#: ../../c-api/exceptions.rst:938 msgid "" "The following functions are used to create and modify Unicode exceptions " "from C." msgstr "" -#: ../../c-api/exceptions.rst:924 +#: ../../c-api/exceptions.rst:942 msgid "" "Create a :class:`UnicodeDecodeError` object with the attributes *encoding*, " "*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are " "UTF-8 encoded strings." msgstr "" -#: ../../c-api/exceptions.rst:931 +#: ../../c-api/exceptions.rst:949 msgid "Return the *encoding* attribute of the given exception object." msgstr "" -#: ../../c-api/exceptions.rst:937 +#: ../../c-api/exceptions.rst:955 msgid "Return the *object* attribute of the given exception object." msgstr "" -#: ../../c-api/exceptions.rst:943 +#: ../../c-api/exceptions.rst:961 msgid "" "Get the *start* attribute of the given exception object and place it into " "*\\*start*. *start* must not be ``NULL``. Return ``0`` on success, ``-1`` " "on failure." msgstr "" -#: ../../c-api/exceptions.rst:947 +#: ../../c-api/exceptions.rst:965 msgid "" "If the :attr:`UnicodeError.object` is an empty sequence, the resulting " "*start* is ``0``. Otherwise, it is clipped to ``[0, len(object) - 1]``." msgstr "" -#: ../../c-api/exceptions.rst:950 +#: ../../c-api/exceptions.rst:968 msgid ":attr:`UnicodeError.start`" msgstr ":attr:`UnicodeError.start`" -#: ../../c-api/exceptions.rst:956 +#: ../../c-api/exceptions.rst:974 msgid "" "Set the *start* attribute of the given exception object to *start*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:961 +#: ../../c-api/exceptions.rst:979 msgid "" "While passing a negative *start* does not raise an exception, the " "corresponding getters will not consider it as a relative offset." msgstr "" -#: ../../c-api/exceptions.rst:969 +#: ../../c-api/exceptions.rst:987 msgid "" "Get the *end* attribute of the given exception object and place it into " "*\\*end*. *end* must not be ``NULL``. Return ``0`` on success, ``-1`` on " "failure." msgstr "" -#: ../../c-api/exceptions.rst:973 +#: ../../c-api/exceptions.rst:991 msgid "" "If the :attr:`UnicodeError.object` is an empty sequence, the resulting *end* " "is ``0``. Otherwise, it is clipped to ``[1, len(object)]``." msgstr "" -#: ../../c-api/exceptions.rst:980 +#: ../../c-api/exceptions.rst:998 msgid "" "Set the *end* attribute of the given exception object to *end*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:983 +#: ../../c-api/exceptions.rst:1001 msgid ":attr:`UnicodeError.end`" msgstr ":attr:`UnicodeError.end`" -#: ../../c-api/exceptions.rst:989 +#: ../../c-api/exceptions.rst:1007 msgid "Return the *reason* attribute of the given exception object." msgstr "回傳給定例外物件的 *reason* 屬性。" -#: ../../c-api/exceptions.rst:995 +#: ../../c-api/exceptions.rst:1013 msgid "" "Set the *reason* attribute of the given exception object to *reason*. " "Return ``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:1002 +#: ../../c-api/exceptions.rst:1020 msgid "Recursion Control" msgstr "遞迴控制" -#: ../../c-api/exceptions.rst:1004 +#: ../../c-api/exceptions.rst:1022 msgid "" "These two functions provide a way to perform safe recursive calls at the C " "level, both in the core and in extension modules. They are needed if the " @@ -1101,54 +1121,54 @@ msgid "" "recursion handling." msgstr "" -#: ../../c-api/exceptions.rst:1013 +#: ../../c-api/exceptions.rst:1031 msgid "Marks a point where a recursive C-level call is about to be performed." msgstr "" -#: ../../c-api/exceptions.rst:1015 +#: ../../c-api/exceptions.rst:1033 msgid "" "The function then checks if the stack limit is reached. If this is the " "case, a :exc:`RecursionError` is set and a nonzero value is returned. " "Otherwise, zero is returned." msgstr "" -#: ../../c-api/exceptions.rst:1019 +#: ../../c-api/exceptions.rst:1037 msgid "" "The check is based on the remaining C stack space of the current thread, not " "on a count of calls, so it is unaffected by :c:func:`Py_SetRecursionLimit` " "and :func:`sys.setrecursionlimit`." msgstr "" -#: ../../c-api/exceptions.rst:1023 +#: ../../c-api/exceptions.rst:1041 msgid "" "*where* should be a UTF-8 encoded string such as ``\" in instance check\"`` " "to be concatenated to the :exc:`RecursionError` message caused by the " "recursion depth limit." msgstr "" -#: ../../c-api/exceptions.rst:1028 +#: ../../c-api/exceptions.rst:1046 msgid "The :c:func:`PyUnstable_ThreadState_SetStackProtection` function." msgstr "" -#: ../../c-api/exceptions.rst:1030 ../../c-api/exceptions.rst:1042 +#: ../../c-api/exceptions.rst:1048 ../../c-api/exceptions.rst:1060 msgid "" "This function is now also available in the :ref:`limited API `." msgstr "" -#: ../../c-api/exceptions.rst:1033 +#: ../../c-api/exceptions.rst:1051 msgid "" "The check is based on the remaining C stack space. Previously, a separate " "counter of C-level calls was used." msgstr "" -#: ../../c-api/exceptions.rst:1039 +#: ../../c-api/exceptions.rst:1057 msgid "" "Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each " "*successful* invocation of :c:func:`Py_EnterRecursiveCall`." msgstr "" -#: ../../c-api/exceptions.rst:1045 +#: ../../c-api/exceptions.rst:1063 msgid "" "Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types " "requires special recursion handling. In addition to protecting the stack, :" @@ -1157,13 +1177,13 @@ msgid "" "Effectively, these are the C equivalent to :deco:`reprlib.recursive_repr`." msgstr "" -#: ../../c-api/exceptions.rst:1053 +#: ../../c-api/exceptions.rst:1071 msgid "" "Called at the beginning of the :c:member:`~PyTypeObject.tp_repr` " "implementation to detect cycles." msgstr "" -#: ../../c-api/exceptions.rst:1056 +#: ../../c-api/exceptions.rst:1074 msgid "" "If the object has already been processed, the function returns a positive " "integer. In that case the :c:member:`~PyTypeObject.tp_repr` implementation " @@ -1171,301 +1191,305 @@ msgid "" "`dict` objects return ``{...}`` and :class:`list` objects return ``[...]``." msgstr "" -#: ../../c-api/exceptions.rst:1062 +#: ../../c-api/exceptions.rst:1080 msgid "" "The function will return a negative integer if the recursion limit is " "reached. In that case the :c:member:`~PyTypeObject.tp_repr` implementation " "should typically return ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:1066 +#: ../../c-api/exceptions.rst:1084 msgid "" "Otherwise, the function returns zero and the :c:member:`~PyTypeObject." "tp_repr` implementation can continue normally." msgstr "" -#: ../../c-api/exceptions.rst:1071 +#: ../../c-api/exceptions.rst:1089 msgid "" "Ends a :c:func:`Py_ReprEnter`. Must be called once for each invocation of :" "c:func:`Py_ReprEnter` that returns zero." msgstr "" -#: ../../c-api/exceptions.rst:1076 +#: ../../c-api/exceptions.rst:1094 msgid "" "Get the recursion limit for the current interpreter. It can be set with :c:" "func:`Py_SetRecursionLimit`. The recursion limit prevents the Python " "interpreter stack from growing infinitely." msgstr "" -#: ../../c-api/exceptions.rst:1080 ../../c-api/exceptions.rst:1090 +#: ../../c-api/exceptions.rst:1098 ../../c-api/exceptions.rst:1108 msgid "" "This function cannot fail, and the caller must hold an :term:`attached " "thread state`." msgstr "" -#: ../../c-api/exceptions.rst:1084 +#: ../../c-api/exceptions.rst:1102 msgid ":py:func:`sys.getrecursionlimit`" msgstr ":py:func:`sys.getrecursionlimit`" -#: ../../c-api/exceptions.rst:1088 +#: ../../c-api/exceptions.rst:1106 msgid "Set the recursion limit for the current interpreter." msgstr "" -#: ../../c-api/exceptions.rst:1094 +#: ../../c-api/exceptions.rst:1112 msgid ":py:func:`sys.setrecursionlimit`" msgstr ":py:func:`sys.setrecursionlimit`" -#: ../../c-api/exceptions.rst:1099 +#: ../../c-api/exceptions.rst:1117 msgid "Exception and warning types" msgstr "例外和警告型別" -#: ../../c-api/exceptions.rst:1101 +#: ../../c-api/exceptions.rst:1119 msgid "" "All standard Python exceptions and warning categories are available as " "global variables whose names are ``PyExc_`` followed by the Python exception " "name. These have the type :c:expr:`PyObject*`; they are all class objects." msgstr "" -#: ../../c-api/exceptions.rst:1105 +#: ../../c-api/exceptions.rst:1123 msgid "For completeness, here are all the variables:" msgstr "" -#: ../../c-api/exceptions.rst:1108 +#: ../../c-api/exceptions.rst:1126 msgid "Exception types" msgstr "例外型別" -#: ../../c-api/exceptions.rst:1115 ../../c-api/exceptions.rst:1261 -#: ../../c-api/exceptions.rst:1291 +#: ../../c-api/exceptions.rst:1133 ../../c-api/exceptions.rst:1281 +#: ../../c-api/exceptions.rst:1311 msgid "C name" msgstr "C 名稱" -#: ../../c-api/exceptions.rst:1116 ../../c-api/exceptions.rst:1262 -#: ../../c-api/exceptions.rst:1292 +#: ../../c-api/exceptions.rst:1134 ../../c-api/exceptions.rst:1282 +#: ../../c-api/exceptions.rst:1312 msgid "Python name" msgstr "Python 名稱" -#: ../../c-api/exceptions.rst:1118 +#: ../../c-api/exceptions.rst:1136 msgid ":exc:`BaseException`" msgstr ":exc:`BaseException`" -#: ../../c-api/exceptions.rst:1120 +#: ../../c-api/exceptions.rst:1138 msgid ":exc:`BaseExceptionGroup`" msgstr ":exc:`BaseExceptionGroup`" -#: ../../c-api/exceptions.rst:1122 +#: ../../c-api/exceptions.rst:1140 msgid ":exc:`Exception`" msgstr ":exc:`Exception`" -#: ../../c-api/exceptions.rst:1124 +#: ../../c-api/exceptions.rst:1142 msgid ":exc:`ArithmeticError`" msgstr ":exc:`ArithmeticError`" -#: ../../c-api/exceptions.rst:1126 +#: ../../c-api/exceptions.rst:1144 msgid ":exc:`AssertionError`" msgstr ":exc:`AssertionError`" -#: ../../c-api/exceptions.rst:1128 +#: ../../c-api/exceptions.rst:1146 msgid ":exc:`AttributeError`" msgstr ":exc:`AttributeError`" -#: ../../c-api/exceptions.rst:1130 +#: ../../c-api/exceptions.rst:1148 msgid ":exc:`BlockingIOError`" msgstr ":exc:`BlockingIOError`" -#: ../../c-api/exceptions.rst:1132 +#: ../../c-api/exceptions.rst:1150 msgid ":exc:`BrokenPipeError`" msgstr ":exc:`BrokenPipeError`" -#: ../../c-api/exceptions.rst:1134 +#: ../../c-api/exceptions.rst:1152 msgid ":exc:`BufferError`" msgstr ":exc:`BufferError`" -#: ../../c-api/exceptions.rst:1136 +#: ../../c-api/exceptions.rst:1154 msgid ":exc:`ChildProcessError`" msgstr ":exc:`ChildProcessError`" -#: ../../c-api/exceptions.rst:1138 +#: ../../c-api/exceptions.rst:1156 msgid ":exc:`ConnectionAbortedError`" msgstr ":exc:`ConnectionAbortedError`" -#: ../../c-api/exceptions.rst:1140 +#: ../../c-api/exceptions.rst:1158 msgid ":exc:`ConnectionError`" msgstr ":exc:`ConnectionError`" -#: ../../c-api/exceptions.rst:1142 +#: ../../c-api/exceptions.rst:1160 msgid ":exc:`ConnectionRefusedError`" msgstr ":exc:`ConnectionRefusedError`" -#: ../../c-api/exceptions.rst:1144 +#: ../../c-api/exceptions.rst:1162 msgid ":exc:`ConnectionResetError`" msgstr ":exc:`ConnectionResetError`" -#: ../../c-api/exceptions.rst:1146 +#: ../../c-api/exceptions.rst:1164 msgid ":exc:`EOFError`" msgstr ":exc:`EOFError`" -#: ../../c-api/exceptions.rst:1148 +#: ../../c-api/exceptions.rst:1166 msgid ":exc:`FileExistsError`" msgstr ":exc:`FileExistsError`" -#: ../../c-api/exceptions.rst:1150 +#: ../../c-api/exceptions.rst:1168 msgid ":exc:`FileNotFoundError`" msgstr ":exc:`FileNotFoundError`" -#: ../../c-api/exceptions.rst:1152 +#: ../../c-api/exceptions.rst:1170 msgid ":exc:`FloatingPointError`" msgstr ":exc:`FloatingPointError`" -#: ../../c-api/exceptions.rst:1154 +#: ../../c-api/exceptions.rst:1172 msgid ":exc:`GeneratorExit`" msgstr ":exc:`GeneratorExit`" -#: ../../c-api/exceptions.rst:1156 +#: ../../c-api/exceptions.rst:1174 +msgid ":exc:`ImportCycleError`" +msgstr ":exc:`ImportCycleError`" + +#: ../../c-api/exceptions.rst:1176 msgid ":exc:`ImportError`" msgstr ":exc:`ImportError`" -#: ../../c-api/exceptions.rst:1158 +#: ../../c-api/exceptions.rst:1178 msgid ":exc:`IndentationError`" msgstr ":exc:`IndentationError`" -#: ../../c-api/exceptions.rst:1160 +#: ../../c-api/exceptions.rst:1180 msgid ":exc:`IndexError`" msgstr ":exc:`IndexError`" -#: ../../c-api/exceptions.rst:1162 +#: ../../c-api/exceptions.rst:1182 msgid ":exc:`InterruptedError`" msgstr ":exc:`InterruptedError`" -#: ../../c-api/exceptions.rst:1164 +#: ../../c-api/exceptions.rst:1184 msgid ":exc:`IsADirectoryError`" msgstr ":exc:`IsADirectoryError`" -#: ../../c-api/exceptions.rst:1166 +#: ../../c-api/exceptions.rst:1186 msgid ":exc:`KeyError`" msgstr ":exc:`KeyError`" -#: ../../c-api/exceptions.rst:1168 +#: ../../c-api/exceptions.rst:1188 msgid ":exc:`KeyboardInterrupt`" msgstr ":exc:`KeyboardInterrupt`" -#: ../../c-api/exceptions.rst:1170 +#: ../../c-api/exceptions.rst:1190 msgid ":exc:`LookupError`" msgstr ":exc:`LookupError`" -#: ../../c-api/exceptions.rst:1172 +#: ../../c-api/exceptions.rst:1192 msgid ":exc:`MemoryError`" msgstr ":exc:`MemoryError`" -#: ../../c-api/exceptions.rst:1174 +#: ../../c-api/exceptions.rst:1194 msgid ":exc:`ModuleNotFoundError`" msgstr ":exc:`ModuleNotFoundError`" -#: ../../c-api/exceptions.rst:1176 +#: ../../c-api/exceptions.rst:1196 msgid ":exc:`NameError`" msgstr ":exc:`NameError`" -#: ../../c-api/exceptions.rst:1178 +#: ../../c-api/exceptions.rst:1198 msgid ":exc:`NotADirectoryError`" msgstr ":exc:`NotADirectoryError`" -#: ../../c-api/exceptions.rst:1180 +#: ../../c-api/exceptions.rst:1200 msgid ":exc:`NotImplementedError`" msgstr ":exc:`NotImplementedError`" -#: ../../c-api/exceptions.rst:1182 ../../c-api/exceptions.rst:1265 -#: ../../c-api/exceptions.rst:1268 ../../c-api/exceptions.rst:1271 +#: ../../c-api/exceptions.rst:1202 ../../c-api/exceptions.rst:1285 +#: ../../c-api/exceptions.rst:1288 ../../c-api/exceptions.rst:1291 msgid ":exc:`OSError`" msgstr ":exc:`OSError`" -#: ../../c-api/exceptions.rst:1184 +#: ../../c-api/exceptions.rst:1204 msgid ":exc:`OverflowError`" msgstr ":exc:`OverflowError`" -#: ../../c-api/exceptions.rst:1186 +#: ../../c-api/exceptions.rst:1206 msgid ":exc:`PermissionError`" msgstr ":exc:`PermissionError`" -#: ../../c-api/exceptions.rst:1188 +#: ../../c-api/exceptions.rst:1208 msgid ":exc:`ProcessLookupError`" msgstr ":exc:`ProcessLookupError`" -#: ../../c-api/exceptions.rst:1190 +#: ../../c-api/exceptions.rst:1210 msgid ":exc:`PythonFinalizationError`" msgstr ":exc:`PythonFinalizationError`" -#: ../../c-api/exceptions.rst:1192 +#: ../../c-api/exceptions.rst:1212 msgid ":exc:`RecursionError`" msgstr ":exc:`RecursionError`" -#: ../../c-api/exceptions.rst:1194 +#: ../../c-api/exceptions.rst:1214 msgid ":exc:`ReferenceError`" msgstr ":exc:`ReferenceError`" -#: ../../c-api/exceptions.rst:1196 +#: ../../c-api/exceptions.rst:1216 msgid ":exc:`RuntimeError`" msgstr ":exc:`RuntimeError`" -#: ../../c-api/exceptions.rst:1198 +#: ../../c-api/exceptions.rst:1218 msgid ":exc:`StopAsyncIteration`" msgstr ":exc:`StopAsyncIteration`" -#: ../../c-api/exceptions.rst:1200 +#: ../../c-api/exceptions.rst:1220 msgid ":exc:`StopIteration`" msgstr ":exc:`StopIteration`" -#: ../../c-api/exceptions.rst:1202 +#: ../../c-api/exceptions.rst:1222 msgid ":exc:`SyntaxError`" msgstr ":exc:`SyntaxError`" -#: ../../c-api/exceptions.rst:1204 +#: ../../c-api/exceptions.rst:1224 msgid ":exc:`SystemError`" msgstr ":exc:`SystemError`" -#: ../../c-api/exceptions.rst:1206 +#: ../../c-api/exceptions.rst:1226 msgid ":exc:`SystemExit`" msgstr ":exc:`SystemExit`" -#: ../../c-api/exceptions.rst:1208 +#: ../../c-api/exceptions.rst:1228 msgid ":exc:`TabError`" msgstr ":exc:`TabError`" -#: ../../c-api/exceptions.rst:1210 +#: ../../c-api/exceptions.rst:1230 msgid ":exc:`TimeoutError`" msgstr ":exc:`TimeoutError`" -#: ../../c-api/exceptions.rst:1212 +#: ../../c-api/exceptions.rst:1232 msgid ":exc:`TypeError`" msgstr ":exc:`TypeError`" -#: ../../c-api/exceptions.rst:1214 +#: ../../c-api/exceptions.rst:1234 msgid ":exc:`UnboundLocalError`" msgstr ":exc:`UnboundLocalError`" -#: ../../c-api/exceptions.rst:1216 +#: ../../c-api/exceptions.rst:1236 msgid ":exc:`UnicodeDecodeError`" msgstr ":exc:`UnicodeDecodeError`" -#: ../../c-api/exceptions.rst:1218 +#: ../../c-api/exceptions.rst:1238 msgid ":exc:`UnicodeEncodeError`" msgstr ":exc:`UnicodeEncodeError`" -#: ../../c-api/exceptions.rst:1220 +#: ../../c-api/exceptions.rst:1240 msgid ":exc:`UnicodeError`" msgstr ":exc:`UnicodeError`" -#: ../../c-api/exceptions.rst:1222 +#: ../../c-api/exceptions.rst:1242 msgid ":exc:`UnicodeTranslateError`" msgstr ":exc:`UnicodeTranslateError`" -#: ../../c-api/exceptions.rst:1224 +#: ../../c-api/exceptions.rst:1244 msgid ":exc:`ValueError`" msgstr ":exc:`ValueError`" -#: ../../c-api/exceptions.rst:1226 +#: ../../c-api/exceptions.rst:1246 msgid ":exc:`ZeroDivisionError`" msgstr ":exc:`ZeroDivisionError`" -#: ../../c-api/exceptions.rst:1228 +#: ../../c-api/exceptions.rst:1248 msgid "" ":c:data:`PyExc_BlockingIOError`, :c:data:`PyExc_BrokenPipeError`, :c:data:" "`PyExc_ChildProcessError`, :c:data:`PyExc_ConnectionError`, :c:data:" @@ -1485,164 +1509,253 @@ msgstr "" "`PyExc_PermissionError`, :c:data:`PyExc_ProcessLookupError` 和 :c:data:" "`PyExc_TimeoutError` 是在 :pep:`3151` 被引入。" -#: ../../c-api/exceptions.rst:1238 +#: ../../c-api/exceptions.rst:1258 msgid ":c:data:`PyExc_StopAsyncIteration` and :c:data:`PyExc_RecursionError`." msgstr ":c:data:`PyExc_StopAsyncIteration` 和 :c:data:`PyExc_RecursionError`。" -#: ../../c-api/exceptions.rst:1241 +#: ../../c-api/exceptions.rst:1261 msgid ":c:data:`PyExc_ModuleNotFoundError`." msgstr ":c:data:`PyExc_ModuleNotFoundError`。" -#: ../../c-api/exceptions.rst:1244 +#: ../../c-api/exceptions.rst:1264 msgid ":c:data:`PyExc_BaseExceptionGroup`." msgstr ":c:data:`PyExc_BaseExceptionGroup`" -#: ../../c-api/exceptions.rst:1249 +#: ../../c-api/exceptions.rst:1269 msgid "OSError aliases" msgstr "OSError 別名" -#: ../../c-api/exceptions.rst:1251 +#: ../../c-api/exceptions.rst:1271 msgid "The following are a compatibility aliases to :c:data:`PyExc_OSError`." msgstr "" -#: ../../c-api/exceptions.rst:1253 +#: ../../c-api/exceptions.rst:1273 msgid "These aliases used to be separate exception types." msgstr "" -#: ../../c-api/exceptions.rst:1263 +#: ../../c-api/exceptions.rst:1283 msgid "Notes" msgstr "註解" -#: ../../c-api/exceptions.rst:1272 +#: ../../c-api/exceptions.rst:1292 msgid "[win]_" msgstr "[win]_" -#: ../../c-api/exceptions.rst:1274 +#: ../../c-api/exceptions.rst:1294 msgid "Notes:" msgstr "註解:" -#: ../../c-api/exceptions.rst:1277 +#: ../../c-api/exceptions.rst:1297 msgid "" ":c:var:`!PyExc_WindowsError` is only defined on Windows; protect code that " "uses this by testing that the preprocessor macro ``MS_WINDOWS`` is defined." msgstr "" -#: ../../c-api/exceptions.rst:1284 +#: ../../c-api/exceptions.rst:1304 msgid "Warning types" msgstr "警告型別" -#: ../../c-api/exceptions.rst:1294 +#: ../../c-api/exceptions.rst:1314 msgid ":exc:`Warning`" msgstr ":exc:`Warning`" -#: ../../c-api/exceptions.rst:1296 +#: ../../c-api/exceptions.rst:1316 msgid ":exc:`BytesWarning`" msgstr ":exc:`BytesWarning`" -#: ../../c-api/exceptions.rst:1298 +#: ../../c-api/exceptions.rst:1318 msgid ":exc:`DeprecationWarning`" msgstr ":exc:`DeprecationWarning`" -#: ../../c-api/exceptions.rst:1300 +#: ../../c-api/exceptions.rst:1320 msgid ":exc:`EncodingWarning`" msgstr ":exc:`EncodingWarning`" -#: ../../c-api/exceptions.rst:1302 +#: ../../c-api/exceptions.rst:1322 msgid ":exc:`FutureWarning`" msgstr ":exc:`FutureWarning`" -#: ../../c-api/exceptions.rst:1304 +#: ../../c-api/exceptions.rst:1324 msgid ":exc:`ImportWarning`" msgstr ":exc:`ImportWarning`" -#: ../../c-api/exceptions.rst:1306 +#: ../../c-api/exceptions.rst:1326 msgid ":exc:`PendingDeprecationWarning`" msgstr ":exc:`PendingDeprecationWarning`" -#: ../../c-api/exceptions.rst:1308 +#: ../../c-api/exceptions.rst:1328 msgid ":exc:`ResourceWarning`" msgstr ":exc:`ResourceWarning`" -#: ../../c-api/exceptions.rst:1310 +#: ../../c-api/exceptions.rst:1330 msgid ":exc:`RuntimeWarning`" msgstr ":exc:`RuntimeWarning`" -#: ../../c-api/exceptions.rst:1312 +#: ../../c-api/exceptions.rst:1332 msgid ":exc:`SyntaxWarning`" msgstr ":exc:`SyntaxWarning`" -#: ../../c-api/exceptions.rst:1314 +#: ../../c-api/exceptions.rst:1334 msgid ":exc:`UnicodeWarning`" msgstr ":exc:`UnicodeWarning`" -#: ../../c-api/exceptions.rst:1316 +#: ../../c-api/exceptions.rst:1336 msgid ":exc:`UserWarning`" msgstr ":exc:`UserWarning`" -#: ../../c-api/exceptions.rst:1318 +#: ../../c-api/exceptions.rst:1338 msgid ":c:data:`PyExc_ResourceWarning`." msgstr ":c:data:`PyExc_ResourceWarning`。" -#: ../../c-api/exceptions.rst:1321 +#: ../../c-api/exceptions.rst:1341 msgid ":c:data:`PyExc_EncodingWarning`." msgstr ":c:data:`PyExc_EncodingWarning`。" -#: ../../c-api/exceptions.rst:1326 +#: ../../c-api/exceptions.rst:1346 msgid "Tracebacks" msgstr "" -#: ../../c-api/exceptions.rst:1330 +#: ../../c-api/exceptions.rst:1350 msgid "" "Type object for traceback objects. This is available as :class:`types." "TracebackType` in the Python layer." msgstr "" -#: ../../c-api/exceptions.rst:1336 +#: ../../c-api/exceptions.rst:1356 msgid "" "Return true if *op* is a traceback object, false otherwise. This function " "does not account for subtypes." msgstr "" -#: ../../c-api/exceptions.rst:1342 +#: ../../c-api/exceptions.rst:1362 msgid "" "Replace the :attr:`~BaseException.__traceback__` attribute on the current " "exception with a new traceback prepending *f* to the existing chain." msgstr "" -#: ../../c-api/exceptions.rst:1345 +#: ../../c-api/exceptions.rst:1365 msgid "Calling this function without an exception set is undefined behavior." msgstr "" -#: ../../c-api/exceptions.rst:1347 ../../c-api/exceptions.rst:1355 +#: ../../c-api/exceptions.rst:1367 ../../c-api/exceptions.rst:1375 msgid "" "This function returns ``0`` on success, and returns ``-1`` with an exception " "set on failure." msgstr "" -#: ../../c-api/exceptions.rst:1353 +#: ../../c-api/exceptions.rst:1373 msgid "Write the traceback *tb* into the file *f*." msgstr "" +#: ../../c-api/exceptions.rst:1380 +msgid "" +"Write a trace of the Python stack in *tstate* into the file *fd*. The " +"format looks like::" +msgstr "" + +#: ../../c-api/exceptions.rst:1383 +msgid "" +"Traceback (most recent call first):\n" +" File \"xxx\", line xxx in \n" +" File \"xxx\", line xxx in \n" +" ...\n" +" File \"xxx\", line xxx in " +msgstr "" +"Traceback (most recent call first):\n" +" File \"xxx\", line xxx in \n" +" File \"xxx\", line xxx in \n" +" ...\n" +" File \"xxx\", line xxx in " + +#: ../../c-api/exceptions.rst:1389 +msgid "" +"This function is meant to debug situations such as segfaults, fatal errors, " +"and similar. The file and function names it outputs are encoded to ASCII " +"with backslashreplace and truncated to 500 characters. It writes only the " +"first 100 frames; further frames are truncated with the line ``...``." +msgstr "" + +#: ../../c-api/exceptions.rst:1394 ../../c-api/exceptions.rst:1419 +msgid "" +"This function will return ``NULL`` on success, or an error message on error." +msgstr "" + +#: ../../c-api/exceptions.rst:1396 ../../c-api/exceptions.rst:1427 +msgid "" +"This function is intended for use in crash scenarios such as signal handlers " +"for SIGSEGV, where the interpreter may be in an inconsistent state. Given " +"that it reads interpreter data structures that may be partially modified, " +"the function might produce incomplete output or it may even crash itself." +msgstr "" + +#: ../../c-api/exceptions.rst:1401 +msgid "" +"The caller does not need to hold an :term:`attached thread state`, nor does " +"*tstate* need to be attached." +msgstr "" + +#: ../../c-api/exceptions.rst:1408 +msgid "Write the traces of all Python threads in *interp* into the file *fd*." +msgstr "" + +#: ../../c-api/exceptions.rst:1410 +msgid "" +"If *interp* is ``NULL`` then this function will try to identify the current " +"interpreter using thread-specific storage. If it cannot, it will return an " +"error." +msgstr "" + +#: ../../c-api/exceptions.rst:1414 +msgid "" +"If *current_tstate* is not ``NULL`` then it will be used to identify what " +"the current thread is in the written output. If it is ``NULL`` then this " +"function will identify the current thread using thread-specific storage. It " +"is not an error if the function is unable to get the current Python thread " +"state." +msgstr "" + +#: ../../c-api/exceptions.rst:1421 +msgid "" +"This function is meant to debug situations such as segfaults, fatal errors, " +"and similar. It calls :c:func:`PyUnstable_DumpTraceback` for each thread. It " +"only writes the tracebacks of the first *max_threads* threads, further " +"output is truncated with the line ``...``. If *max_threads* is 0, the " +"function will use a default value of 100 for the argument." +msgstr "" + +#: ../../c-api/exceptions.rst:1432 +msgid "" +"The caller does not need to hold an :term:`attached thread state`, nor does " +"*current_tstate* need to be attached." +msgstr "" + +#: ../../c-api/exceptions.rst:1436 +msgid "" +"On the :term:`free-threaded build`, this function is not thread-safe. If " +"another thread deletes its :term:`thread state` while this function is being " +"called, the process will likely crash." +msgstr "" + #: ../../c-api/exceptions.rst:198 msgid "strerror (C function)" msgstr "strerror(C 函式)" -#: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:737 -#: ../../c-api/exceptions.rst:752 +#: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:742 +#: ../../c-api/exceptions.rst:757 msgid "module" msgstr "module(模組)" -#: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:737 -#: ../../c-api/exceptions.rst:752 +#: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:742 +#: ../../c-api/exceptions.rst:757 msgid "signal" msgstr "signal(訊號)" -#: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:737 +#: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:742 msgid "SIGINT (C macro)" msgstr "SIGINT(C 巨集)" -#: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:737 -#: ../../c-api/exceptions.rst:752 +#: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:742 +#: ../../c-api/exceptions.rst:757 msgid "KeyboardInterrupt (built-in exception)" msgstr "KeyboardInterrupt(內建例外)" diff --git a/c-api/extension-modules.po b/c-api/extension-modules.po index 948a918e06d..055bf7c3029 100644 --- a/c-api/extension-modules.po +++ b/c-api/extension-modules.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -26,10 +26,11 @@ msgid "" "A C extension for CPython is a shared library (for example, a ``.so`` file " "on Linux, ``.pyd`` DLL on Windows), which is loadable into the Python " "process (for example, it is compiled with compatible compiler settings), and " -"which exports an :ref:`initialization function `." +"which exports an :dfn:`export hook` function (or an old-style :ref:" +"`initialization function `)." msgstr "" -#: ../../c-api/extension-modules.rst:13 +#: ../../c-api/extension-modules.rst:14 msgid "" "To be importable by default (that is, " "by :py:class:`importlib.machinery.ExtensionFileLoader`), the shared library " @@ -38,7 +39,7 @@ msgid "" "in :py:attr:`importlib.machinery.EXTENSION_SUFFIXES`." msgstr "" -#: ../../c-api/extension-modules.rst:21 +#: ../../c-api/extension-modules.rst:22 msgid "" "Building, packaging and distributing extension modules is best done with " "third-party tools, and is out of scope of this document. One suitable tool " @@ -46,60 +47,278 @@ msgid "" "setuptools.pypa.io/en/latest/setuptools.html." msgstr "" -#: ../../c-api/extension-modules.rst:26 +#: ../../c-api/extension-modules.rst:30 +msgid "Extension export hook" +msgstr "" + +#: ../../c-api/extension-modules.rst:34 msgid "" -"Normally, the initialization function returns a module definition " -"initialized using :c:func:`PyModuleDef_Init`. This allows splitting the " -"creation process into several phases:" +"Support for the :samp:`PyModExport_{}` export hook was added in Python " +"3.15. The older way of defining modules is still available: consult either " +"the :ref:`extension-pyinit` section or earlier versions of this " +"documentation if you plan to support earlier Python versions." msgstr "" -#: ../../c-api/extension-modules.rst:30 +#: ../../c-api/extension-modules.rst:39 +msgid "" +"The export hook must be an exported function with the following signature:" +msgstr "" + +#: ../../c-api/extension-modules.rst:43 +msgid "" +"For modules with ASCII-only names, the :ref:`export hook ` must be named :samp:`PyModExport_{}`, with ```` replaced " +"by the module's name." +msgstr "" + +#: ../../c-api/extension-modules.rst:47 +msgid "" +"For non-ASCII module names, the export hook must instead be named :samp:" +"`PyModExportU_{}` (note the ``U``), with ```` encoded using " +"Python's *punycode* encoding with hyphens replaced by underscores. In Python:" +msgstr "" + +#: ../../c-api/extension-modules.rst:51 +msgid "" +"def hook_name(name):\n" +" try:\n" +" suffix = b'_' + name.encode('ascii')\n" +" except UnicodeEncodeError:\n" +" suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n" +" return b'PyModExport' + suffix" +msgstr "" +"def hook_name(name):\n" +" try:\n" +" suffix = b'_' + name.encode('ascii')\n" +" except UnicodeEncodeError:\n" +" suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n" +" return b'PyModExport' + suffix" + +#: ../../c-api/extension-modules.rst:60 +msgid "" +"The export hook returns an array of :c:type:`PySlot` entries, terminated by " +"an entry with a slot ID of ``0``. These slots describe how the module should " +"be created and initialized." +msgstr "" + +#: ../../c-api/extension-modules.rst:64 +msgid "" +"This array must remain valid and constant until interpreter shutdown. " +"Typically, it should use ``static`` storage. Prefer using the :c:macro:" +"`Py_mod_create` and :c:macro:`Py_mod_exec` slots for any dynamic behavior." +msgstr "" + +#: ../../c-api/extension-modules.rst:69 +msgid "" +"The export hook may return ``NULL`` with an exception set to signal failure." +msgstr "" + +#: ../../c-api/extension-modules.rst:71 +msgid "" +"It is recommended to define the export hook function using a helper macro:" +msgstr "" + +#: ../../c-api/extension-modules.rst:75 +msgid "Declare an extension module export hook. This macro:" +msgstr "" + +#: ../../c-api/extension-modules.rst:78 +msgid "specifies the :c:expr:`PySlot*` return type," +msgstr "" + +#: ../../c-api/extension-modules.rst:79 ../../c-api/extension-modules.rst:248 +msgid "adds any special linkage declarations required by the platform, and" +msgstr "" + +#: ../../c-api/extension-modules.rst:80 ../../c-api/extension-modules.rst:249 +msgid "for C++, declares the function as ``extern \"C\"``." +msgstr "" + +#: ../../c-api/extension-modules.rst:82 ../../c-api/extension-modules.rst:279 +msgid "For example, a module called ``spam`` would be defined like this::" +msgstr "" + +#: ../../c-api/extension-modules.rst:84 +msgid "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot spam_slots[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"spam\"),\n" +" PySlot_FUNC(Py_mod_init, spam_init_function),\n" +" ...\n" +" PySlot_END\n" +"};\n" +"\n" +"PyMODEXPORT_FUNC\n" +"PyModExport_spam(void)\n" +"{\n" +" return spam_slots;\n" +"}" +msgstr "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot spam_slots[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"spam\"),\n" +" PySlot_FUNC(Py_mod_init, spam_init_function),\n" +" ...\n" +" PySlot_END\n" +"};\n" +"\n" +"PyMODEXPORT_FUNC\n" +"PyModExport_spam(void)\n" +"{\n" +" return spam_slots;\n" +"}" + +#: ../../c-api/extension-modules.rst:100 +msgid "" +"The export hook is typically the only non-\\ ``static`` item defined in the " +"module's C source." +msgstr "" + +#: ../../c-api/extension-modules.rst:105 +msgid "" +"The hook should be kept short. If it does more than ``return`` a static " +"array, several caveats apply:" +msgstr "" + +#: ../../c-api/extension-modules.rst:108 +msgid "" +"If you need to use any Python C API, it is recommended to call :c:func:" +"`PyABIInfo_Check` first to raise an exception, rather than crash, in common " +"cases of ABI mismatch." +msgstr "" + +#: ../../c-api/extension-modules.rst:111 +msgid "" +"Code in the export hook must never rely on the :term:`GIL`: :term:`free-" +"threaded builds ` of Python can only check the :c:macro:" +"`Py_mod_gil` slot (or the lack of it) after the hook returns," +msgstr "" + +#: ../../c-api/extension-modules.rst:114 +msgid "" +"Similarly, the hook may be called in any subinterpreter, since the :c:macro:" +"`Py_mod_multiple_interpreters` slot (or lack of it) is only checked after " +"the hook returns." +msgstr "" + +#: ../../c-api/extension-modules.rst:118 +msgid "For example::" +msgstr "" + +#: ../../c-api/extension-modules.rst:120 +msgid "" +"PyMODEXPORT_FUNC\n" +"PyModExport_modulename(void)\n" +"{\n" +" if (PyABIInfo_Check(&abi_info, \"modulename\") < 0) {\n" +" /* ABI mismatch. It's not safe to examine the raised exception. */\n" +" return NULL;\n" +" }\n" +"\n" +" /* use Python API (as little as possible); don't rely on GIL */\n" +"\n" +" return modulename_slots;\n" +"}" +msgstr "" +"PyMODEXPORT_FUNC\n" +"PyModExport_modulename(void)\n" +"{\n" +" if (PyABIInfo_Check(&abi_info, \"modulename\") < 0) {\n" +" /* ABI 不相符。檢查所引發的例外並不安全。 */\n" +" return NULL;\n" +" }\n" +"\n" +" /* 使用 Python API(越少越好);不要依賴 GIL */\n" +"\n" +" return modulename_slots;\n" +"}" + +#: ../../c-api/extension-modules.rst:135 +msgid "" +"It is possible to export multiple modules from a single shared library by " +"defining multiple export hooks. However, importing them requires a custom " +"importer or suitably named copies/links of the extension file, because " +"Python's import machinery only finds the function corresponding to the " +"filename. See the `Multiple modules in one library `__ section in :pep:`489` for " +"details." +msgstr "" + +#: ../../c-api/extension-modules.rst:147 +msgid "Multi-phase initialization" +msgstr "" + +#: ../../c-api/extension-modules.rst:149 +msgid "The process of creating an extension module follows several phases:" +msgstr "" + +#: ../../c-api/extension-modules.rst:151 +msgid "" +"Python finds and calls the export hook to get information on how to create " +"the module." +msgstr "" + +#: ../../c-api/extension-modules.rst:153 msgid "" "Before any substantial code is executed, Python can determine which " "capabilities the module supports, and it can adjust the environment or " -"refuse loading an incompatible extension." +"refuse loading an incompatible extension. Slots like :c:data:`Py_mod_abi`, :" +"c:data:`Py_mod_gil` and :c:data:`Py_mod_multiple_interpreters` influence " +"this step." msgstr "" -#: ../../c-api/extension-modules.rst:33 +#: ../../c-api/extension-modules.rst:158 msgid "" -"By default, Python itself creates the module object -- that is, it does the " -"equivalent of :py:meth:`object.__new__` for classes. It also sets initial " -"attributes like :attr:`~module.__package__` and :attr:`~module.__loader__`." +"By default, Python itself then creates the module object -- that is, it does " +"the equivalent of calling :py:meth:`~object.__new__` when creating an " +"object. This step can be overridden using the :c:data:`Py_mod_create` slot." msgstr "" -#: ../../c-api/extension-modules.rst:37 +#: ../../c-api/extension-modules.rst:161 msgid "" -"Afterwards, the module object is initialized using extension-specific code " -"-- the equivalent of :py:meth:`~object.__init__` on classes." +"Python sets initial module attributes like :attr:`~module.__package__` and :" +"attr:`~module.__loader__`, and inserts the module object into :py:attr:`sys." +"modules`." msgstr "" -#: ../../c-api/extension-modules.rst:40 +#: ../../c-api/extension-modules.rst:164 +msgid "" +"Afterwards, the module object is initialized in an extension-specific way -- " +"the equivalent of :py:meth:`~object.__init__` when creating an object, or of " +"executing top-level code in a Python-language module. The behavior is " +"specified using the :c:data:`Py_mod_exec` slot." +msgstr "" + +#: ../../c-api/extension-modules.rst:169 msgid "" "This is called *multi-phase initialization* to distinguish it from the " -"legacy (but still supported) *single-phase initialization* scheme, where the " -"initialization function returns a fully constructed module. See " -"the :ref:`single-phase-initialization section below ` for details." +"legacy (but still supported) :ref:`single-phase initialization `, where an initialization function returns a fully " +"constructed module." msgstr "" -#: ../../c-api/extension-modules.rst:48 +#: ../../c-api/extension-modules.rst:175 msgid "Added support for multi-phase initialization (:pep:`489`)." msgstr "" -#: ../../c-api/extension-modules.rst:52 +#: ../../c-api/extension-modules.rst:179 msgid "Multiple module instances" msgstr "" -#: ../../c-api/extension-modules.rst:54 +#: ../../c-api/extension-modules.rst:181 msgid "" -"By default, extension modules are not singletons. For example, if " -"the :py:attr:`sys.modules` entry is removed and the module is re-imported, a " -"new module object is created, and typically populated with fresh method and " +"By default, extension modules are not singletons. For example, if the :py:" +"attr:`sys.modules` entry is removed and the module is re-imported, a new " +"module object is created and, typically, populated with fresh method and " "type objects. The old module is subject to normal garbage collection. This " "mirrors the behavior of pure-Python modules." msgstr "" -#: ../../c-api/extension-modules.rst:61 +#: ../../c-api/extension-modules.rst:188 msgid "" "Additional module instances may be created in :ref:`sub-interpreters ` or after Python runtime reinitialization " @@ -108,7 +327,7 @@ msgid "" "undefined behavior." msgstr "" -#: ../../c-api/extension-modules.rst:68 +#: ../../c-api/extension-modules.rst:195 msgid "" "To avoid such issues, each instance of an extension module should be " "*isolated*: changes to one instance should not implicitly affect the others, " @@ -117,13 +336,13 @@ msgid "" "extensions-howto` for more details and a practical guide." msgstr "" -#: ../../c-api/extension-modules.rst:74 +#: ../../c-api/extension-modules.rst:201 msgid "" "A simpler way to avoid these issues is :ref:`raising an error on repeated " "initialization `." msgstr "" -#: ../../c-api/extension-modules.rst:77 +#: ../../c-api/extension-modules.rst:204 msgid "" "All modules are expected to support :ref:`sub-interpreters `, or otherwise explicitly signal a lack of support. This is usually " @@ -132,74 +351,89 @@ msgid "" "the :c:data:`Py_mod_multiple_interpreters` slot." msgstr "" -#: ../../c-api/extension-modules.rst:89 -msgid "Initialization function" +#: ../../c-api/extension-modules.rst:216 +msgid "``PyInit`` function" msgstr "" -#: ../../c-api/extension-modules.rst:91 +#: ../../c-api/extension-modules.rst:220 msgid "" -"The initialization function defined by an extension module has the following " -"signature:" +"This functionality will not get new features, but there are no plans to " +"remove it." msgstr "" -#: ../../c-api/extension-modules.rst:96 +#: ../../c-api/extension-modules.rst:223 msgid "" -"Its name should be :samp:`PyInit_{}`, with ```` replaced by the " -"name of the module." +"Instead of :c:func:`PyModExport_modulename`, an extension module can define " +"an older-style :dfn:`initialization function` with the signature:" msgstr "" -#: ../../c-api/extension-modules.rst:99 +#: ../../c-api/extension-modules.rst:228 msgid "" -"For modules with ASCII-only names, the function must instead be " -"named :samp:`PyInit_{}`, with ```` replaced by the name of the " -"module. When using :ref:`multi-phase-initialization`, non-ASCII module names " -"are allowed. In this case, the initialization function name " -"is :samp:`PyInitU_{}`, with ```` encoded using Python's " -"*punycode* encoding with hyphens replaced by underscores. In Python:" +"Its name should be :samp:`PyInit_{}`, with ```` replaced by the " +"name of the module. For non-ASCII module names, use :samp:`PyInitU_{}` " +"instead, with ```` encoded in the same way as for the :ref:`export " +"hook ` (that is, using Punycode with underscores)." msgstr "" -#: ../../c-api/extension-modules.rst:106 +#: ../../c-api/extension-modules.rst:235 msgid "" -"def initfunc_name(name):\n" -" try:\n" -" suffix = b'_' + name.encode('ascii')\n" -" except UnicodeEncodeError:\n" -" suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n" -" return b'PyInit' + suffix" +"If a module exports both :samp:`PyInit_{}` and :samp:" +"`PyModExport_{}`, the :samp:`PyInit_{}` function is ignored." msgstr "" -"def initfunc_name(name):\n" -" try:\n" -" suffix = b'_' + name.encode('ascii')\n" -" except UnicodeEncodeError:\n" -" suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n" -" return b'PyInit' + suffix" -#: ../../c-api/extension-modules.rst:115 +#: ../../c-api/extension-modules.rst:239 msgid "" -"It is recommended to define the initialization function using a helper macro:" +"Like with :c:macro:`PyMODEXPORT_FUNC`, it is recommended to define the " +"initialization function using a helper macro:" msgstr "" -#: ../../c-api/extension-modules.rst:119 +#: ../../c-api/extension-modules.rst:244 msgid "Declare an extension module initialization function. This macro:" msgstr "" -#: ../../c-api/extension-modules.rst:122 +#: ../../c-api/extension-modules.rst:247 msgid "specifies the :c:expr:`PyObject*` return type," msgstr "" -#: ../../c-api/extension-modules.rst:123 -msgid "adds any special linkage declarations required by the platform, and" +#: ../../c-api/extension-modules.rst:252 +msgid "" +"Normally, the initialization function (``PyInit_modulename``) returns a :c:" +"type:`PyModuleDef` instance with non-``NULL`` :c:member:`~PyModuleDef." +"m_slots`. This allows Python to use :ref:`multi-phase initialization `." msgstr "" -#: ../../c-api/extension-modules.rst:124 -msgid "for C++, declares the function as ``extern \"C\"``." +#: ../../c-api/extension-modules.rst:257 +msgid "" +"Before it is returned, the ``PyModuleDef`` instance must be initialized " +"using the following function:" msgstr "" -#: ../../c-api/extension-modules.rst:126 -msgid "For example, a module called ``spam`` would be defined like this::" +#: ../../c-api/extension-modules.rst:262 +msgid "" +"Ensure a module definition is a properly initialized Python object that " +"correctly reports its type and a reference count." +msgstr "" + +#: ../../c-api/extension-modules.rst:265 +msgid "Return *def* cast to ``PyObject*``, or ``NULL`` if an error occurred." +msgstr "" + +#: ../../c-api/extension-modules.rst:267 +msgid "" +"Calling this function is required before returning a :c:type:`PyModuleDef` " +"from a module initialization function. It should not be used in other " +"contexts." msgstr "" -#: ../../c-api/extension-modules.rst:128 +#: ../../c-api/extension-modules.rst:271 +msgid "" +"Note that Python assumes that ``PyModuleDef`` structures are statically " +"allocated. This function may return either a new reference or a borrowed " +"one; this reference must not be released." +msgstr "" + +#: ../../c-api/extension-modules.rst:281 msgid "" "static struct PyModuleDef spam_module = {\n" " .m_base = PyModuleDef_HEAD_INIT,\n" @@ -225,93 +459,46 @@ msgstr "" " return PyModuleDef_Init(&spam_module);\n" "}" -#: ../../c-api/extension-modules.rst:140 -msgid "" -"It is possible to export multiple modules from a single shared library by " -"defining multiple initialization functions. However, importing them requires " -"using symbolic links or a custom importer, because by default only the " -"function corresponding to the filename is found. See the `Multiple modules " -"in one library `__ section in :pep:`489` for details." -msgstr "" - -#: ../../c-api/extension-modules.rst:147 -msgid "" -"The initialization function is typically the only non-\\ ``static`` item " -"defined in the module's C source." -msgstr "" - -#: ../../c-api/extension-modules.rst:154 -msgid "Multi-phase initialization" -msgstr "" - -#: ../../c-api/extension-modules.rst:156 -msgid "" -"Normally, the :ref:`initialization function ` " -"(``PyInit_modulename``) returns a :c:type:`PyModuleDef` instance with non-" -"``NULL`` :c:member:`~PyModuleDef.m_slots`. Before it is returned, the " -"``PyModuleDef`` instance must be initialized using the following function:" -msgstr "" - -#: ../../c-api/extension-modules.rst:165 -msgid "" -"Ensure a module definition is a properly initialized Python object that " -"correctly reports its type and a reference count." -msgstr "" - -#: ../../c-api/extension-modules.rst:168 -msgid "Return *def* cast to ``PyObject*``, or ``NULL`` if an error occurred." -msgstr "" - -#: ../../c-api/extension-modules.rst:170 -msgid "" -"Calling this function is required for :ref:`multi-phase-initialization`. It " -"should not be used in other contexts." -msgstr "" - -#: ../../c-api/extension-modules.rst:173 -msgid "" -"Note that Python assumes that ``PyModuleDef`` structures are statically " -"allocated. This function may return either a new reference or a borrowed " -"one; this reference must not be released." -msgstr "" - -#: ../../c-api/extension-modules.rst:184 +#: ../../c-api/extension-modules.rst:297 msgid "Legacy single-phase initialization" msgstr "" -#: ../../c-api/extension-modules.rst:187 +#: ../../c-api/extension-modules.rst:301 msgid "" "Single-phase initialization is a legacy mechanism to initialize extension " "modules, with known drawbacks and design flaws. Extension module authors are " "encouraged to use multi-phase initialization instead." msgstr "" -#: ../../c-api/extension-modules.rst:191 +#: ../../c-api/extension-modules.rst:305 +msgid "However, there are no plans to remove support for it." +msgstr "" + +#: ../../c-api/extension-modules.rst:307 msgid "" -"In single-phase initialization, the :ref:`initialization function ` (``PyInit_modulename``) should create, populate and return a " -"module object. This is typically done using :c:func:`PyModule_Create` and " -"functions like :c:func:`PyModule_AddObjectRef`." +"In single-phase initialization, the old-style :ref:`initialization function " +"` (``PyInit_modulename``) should create, populate and " +"return a module object. This is typically done using :c:func:" +"`PyModule_Create` and functions like :c:func:`PyModule_AddObjectRef`." msgstr "" -#: ../../c-api/extension-modules.rst:197 +#: ../../c-api/extension-modules.rst:313 msgid "" "Single-phase initialization differs from the :ref:`default ` in the following ways:" msgstr "" -#: ../../c-api/extension-modules.rst:200 +#: ../../c-api/extension-modules.rst:316 msgid "Single-phase modules are, or rather *contain*, “singletons”." msgstr "" -#: ../../c-api/extension-modules.rst:202 +#: ../../c-api/extension-modules.rst:318 msgid "" "When the module is first initialized, Python saves the contents of the " "module's ``__dict__`` (that is, typically, the module's functions and types)." msgstr "" -#: ../../c-api/extension-modules.rst:206 +#: ../../c-api/extension-modules.rst:322 msgid "" "For subsequent imports, Python does not call the initialization function " "again. Instead, it creates a new module object with a new ``__dict__``, and " @@ -320,7 +507,7 @@ msgid "" "an exception class ``error``:" msgstr "" -#: ../../c-api/extension-modules.rst:214 +#: ../../c-api/extension-modules.rst:330 msgid "" ">>> import sys\n" ">>> import _testsinglephase as one\n" @@ -348,12 +535,12 @@ msgstr "" ">>> one.error is two.error\n" "True" -#: ../../c-api/extension-modules.rst:229 +#: ../../c-api/extension-modules.rst:345 msgid "" "The exact behavior should be considered a CPython implementation detail." msgstr "" -#: ../../c-api/extension-modules.rst:231 +#: ../../c-api/extension-modules.rst:347 msgid "" "To work around the fact that ``PyInit_modulename`` does not take a *spec* " "argument, some state of the import machinery is saved and applied to the " @@ -362,23 +549,27 @@ msgid "" "parent package name to the name of the module." msgstr "" -#: ../../c-api/extension-modules.rst:237 +#: ../../c-api/extension-modules.rst:353 msgid "" "A single-phase ``PyInit_modulename`` function should create “its” module " "object as soon as possible, before any other module objects can be created." msgstr "" -#: ../../c-api/extension-modules.rst:240 +#: ../../c-api/extension-modules.rst:356 msgid "Non-ASCII module names (``PyInitU_modulename``) are not supported." msgstr "" -#: ../../c-api/extension-modules.rst:242 +#: ../../c-api/extension-modules.rst:358 msgid "" "Single-phase modules support module lookup functions " "like :c:func:`PyState_FindModule`." msgstr "" -#: ../../c-api/extension-modules.rst:245 +#: ../../c-api/extension-modules.rst:361 +msgid "The module's :c:member:`PyModuleDef.m_slots` must be NULL." +msgstr "" + +#: ../../c-api/extension-modules.rst:363 msgid "" "``_testsinglephase`` is an internal module used in CPython's self-test " "suite; your installation may or may not include it." diff --git a/c-api/float.po b/c-api/float.po index 0ed7061cf46..c0dfd9a3d45 100644 --- a/c-api/float.po +++ b/c-api/float.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-17 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-11-07 05:06+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -120,13 +120,11 @@ msgstr "這個巨集會展開為一型別為 :c:expr:`double` 的常數運算式 #: ../../c-api/float.rst:86 msgid "" -"On most platforms, this is equivalent to the :c:macro:`!INFINITY` macro from " -"the C11 standard ```` header." -msgstr "" -"在大多數平台上,這相當於 C11 標準 ```` 標頭檔中的 :c:macro:`!" -"INFINITY` 巨集。" +"It is equivalent to the :c:macro:`!INFINITY` macro from the C11 standard " +"```` header." +msgstr "它相當於 C11 標準 ```` 標頭檔中的 :c:macro:`!INFINITY` 巨集。" -#: ../../c-api/float.rst:92 +#: ../../c-api/float.rst:94 msgid "" "This macro expands to a constant expression of type :c:expr:`double`, that " "represents a quiet not-a-number (qNaN) value." @@ -134,7 +132,7 @@ msgstr "" "這個巨集會展開為一型別為 :c:expr:`double` 的常數運算式,表示安靜型 NaN " "(qNaN) 值。" -#: ../../c-api/float.rst:95 +#: ../../c-api/float.rst:97 msgid "" "On most platforms, this is equivalent to the :c:macro:`!NAN` macro from the " "C11 standard ```` header." @@ -142,50 +140,46 @@ msgstr "" "在大多數平台上,這相當於 C11 標準 ```` 標頭檔中的 :c:macro:`!NAN` 巨" "集。" -#: ../../c-api/float.rst:101 +#: ../../c-api/float.rst:103 msgid "Equivalent to :c:macro:`!INFINITY`." msgstr "與 :c:macro:`!INFINITY` 等價。" -#: ../../c-api/float.rst:103 -msgid "The macro is :term:`soft deprecated`." -msgstr "這個巨集已被\\ :term:`軟性棄用 `。" - -#: ../../c-api/float.rst:109 +#: ../../c-api/float.rst:110 msgid "" "The definition (accurate for a :c:expr:`double` type) of the :data:`math.e` " "constant." msgstr ":data:`math.e` 常數的定義(對 :c:expr:`double` 型別而言是準確的)。" -#: ../../c-api/float.rst:114 +#: ../../c-api/float.rst:115 msgid "High precision (long double) definition of :data:`~math.e` constant." msgstr "高精度(long double)定義的 :data:`~math.e` 常數。" -#: ../../c-api/float.rst:119 +#: ../../c-api/float.rst:122 msgid "" "The definition (accurate for a :c:expr:`double` type) of the :data:`math.pi` " "constant." msgstr ":data:`math.pi` 常數的定義(對 :c:expr:`double` 型別而言是準確的)。" -#: ../../c-api/float.rst:124 +#: ../../c-api/float.rst:127 msgid "High precision (long double) definition of :data:`~math.pi` constant." msgstr "高精度(long double)定義的 :data:`~math.pi` 常數。" -#: ../../c-api/float.rst:129 +#: ../../c-api/float.rst:134 msgid "" "The definition (accurate for a :c:expr:`double` type) of the :data:`math." "tau` constant." msgstr ":data:`math.tau` 常數的定義(對 :c:expr:`double` 型別而言是準確的)。" -#: ../../c-api/float.rst:136 +#: ../../c-api/float.rst:141 msgid "Return :data:`math.nan` from a function." msgstr "從函式回傳 :data:`math.nan`。" -#: ../../c-api/float.rst:138 +#: ../../c-api/float.rst:143 msgid "" "On most platforms, this is equivalent to ``return PyFloat_FromDouble(NAN)``." msgstr "在大多數平台上,這相當於 ``return PyFloat_FromDouble(NAN)``。" -#: ../../c-api/float.rst:143 +#: ../../c-api/float.rst:148 msgid "" "Return :data:`math.inf` or :data:`-math.inf ` from a function, " "depending on the sign of *sign*." @@ -193,15 +187,15 @@ msgstr "" "根據 *sign* 的正負號,從函式回傳 :data:`math.inf` 或 :data:`-math.inf `。" -#: ../../c-api/float.rst:146 +#: ../../c-api/float.rst:151 msgid "On most platforms, this is equivalent to the following::" msgstr "在大多數平台上,這相當於以下內容: ::" -#: ../../c-api/float.rst:148 +#: ../../c-api/float.rst:153 msgid "return PyFloat_FromDouble(copysign(INFINITY, sign));" msgstr "return PyFloat_FromDouble(copysign(INFINITY, sign));" -#: ../../c-api/float.rst:153 +#: ../../c-api/float.rst:158 msgid "" "Return ``1`` if the given floating-point number *X* is finite, that is, it " "is normal, subnormal or zero, but not infinite or NaN. Return ``0`` " @@ -210,108 +204,106 @@ msgstr "" "如果給定的浮點數 *X* 是有限的(即為正規數 (normal)、次正規數 (subnormal) 或" "零,但不是無窮大或 NaN),則回傳 ``1``。否則回傳 ``0``。" -#: ../../c-api/float.rst:157 -msgid "" -"The macro is :term:`soft deprecated`. Use :c:macro:`!isfinite` instead." -msgstr "" -"此巨集已被\\ :term:`軟性棄用 `。請改用 :c:macro:`!" -"isfinite`。" +#: ../../c-api/float.rst:162 +msgid "Use :c:macro:`!isfinite` instead." +msgstr "請改用 :c:macro:`!isfinite`。" -#: ../../c-api/float.rst:163 +#: ../../c-api/float.rst:168 msgid "" "Return ``1`` if the given floating-point number *X* is positive or negative " "infinity. Return ``0`` otherwise." msgstr "" "如果給定的浮點數 *X* 是正無窮大或負無窮大,則回傳 ``1``。否則回傳 ``0``。" -#: ../../c-api/float.rst:166 -msgid "The macro is :term:`soft deprecated`. Use :c:macro:`!isinf` instead." -msgstr "" -"此巨集已被\\ :term:`軟性棄用 `。請改用 :c:macro:`!isinf`。" +#: ../../c-api/float.rst:171 +msgid "Use :c:macro:`!isinf` instead." +msgstr "請改用 :c:macro:`!isinf`。" -#: ../../c-api/float.rst:172 +#: ../../c-api/float.rst:177 msgid "" "Return ``1`` if the given floating-point number *X* is a not-a-number (NaN) " "value. Return ``0`` otherwise." msgstr "如果給定的浮點數 *X* 是非數值 (NaN),則回傳 ``1``。否則回傳 ``0``。" -#: ../../c-api/float.rst:175 -msgid "The macro is :term:`soft deprecated`. Use :c:macro:`!isnan` instead." -msgstr "" -"此巨集已被\\ :term:`軟性棄用 `。請改用 :c:macro:`!isnan`。" - #: ../../c-api/float.rst:180 +msgid "Use :c:macro:`!isnan` instead." +msgstr "請改用 :c:macro:`!isnan`。" + +#: ../../c-api/float.rst:185 msgid "Pack and Unpack functions" msgstr "打包和解包函式" -#: ../../c-api/float.rst:182 +#: ../../c-api/float.rst:187 msgid "" "The pack and unpack functions provide an efficient platform-independent way " "to store floating-point values as byte strings. The Pack routines produce a " "bytes string from a C :c:expr:`double`, and the Unpack routines produce a C :" "c:expr:`double` from such a bytes string. The suffix (2, 4 or 8) specifies " -"the number of bytes in the bytes string." +"the number of bytes in the bytes string:" msgstr "" "打包和解包函式提供了一種有效的跨平台方式,來將浮點數值儲存為位元組字串。打包" "例程從 C :c:expr:`double` 產生位元組字串,而解包例程則從這樣的位元組字串產生 " -"C :c:expr:`double`。後綴(2、4 或 8)標示了位元組字串中的位元組數。" +"C :c:expr:`double`。後綴(2、4 或 8)標示了位元組字串中的位元組數:" -#: ../../c-api/float.rst:188 -msgid "" -"On platforms that appear to use IEEE 754 formats these functions work by " -"copying bits. On other platforms, the 2-byte format is identical to the IEEE " -"754 binary16 half-precision format, the 4-byte format (32-bit) is identical " -"to the IEEE 754 binary32 single precision format, and the 8-byte format to " -"the IEEE 754 binary64 double precision format, although the packing of INFs " -"and NaNs (if such things exist on the platform) isn't handled correctly, and " -"attempting to unpack a bytes string containing an IEEE INF or NaN will raise " -"an exception." -msgstr "" -"在看似使用 IEEE 754 格式的平台上,這些函式是透過複製位元來運作的。在其他平台" -"上,2 位元組格式與 IEEE 754 binary16 半精度格式相同,4 位元組格式(32 位元)" -"與 IEEE 754 binary32 單精度格式相同,8 位元組格式與 IEEE 754 binary64 雙精度" -"格式相同。儘管如此,INF 和 NaN(如果這些東西在平台上存在)的打包並未正確處" -"理,並且嘗試解包包含 IEEE INF 或 NaN 的位元組字串將引發例外。" +#: ../../c-api/float.rst:193 +msgid "The 2-byte format is the IEEE 754 binary16 half-precision format." +msgstr "2 位元組格式為 IEEE 754 binary16 半精度格式。" + +#: ../../c-api/float.rst:194 +msgid "The 4-byte format is the IEEE 754 binary32 single-precision format." +msgstr "4 位元組格式為 IEEE 754 binary32 單精度格式。" + +#: ../../c-api/float.rst:195 +msgid "The 8-byte format is the IEEE 754 binary64 double-precision format." +msgstr "8 位元組格式為 IEEE 754 binary64 雙精度格式。" #: ../../c-api/float.rst:197 msgid "" -"Note that NaN type may not be preserved on IEEE platforms (signaling NaNs " -"become quiet NaNs), for example on x86 systems in 32-bit mode." +"The NaN type may not be preserved on some platforms while unpacking " +"(signaling NaNs become quiet NaNs), for example on x86 systems in 32-bit " +"mode." msgstr "" -"請注意,在 IEEE 平台上可能無法保留 NaN 型別(「訊號型 NaN (signaling NaNs)」會" -"變成「安靜型 NaN (quiet NaNs)」),例如在 32 位元模式的 x86 系統上。" +"在某些平台上解包時可能無法保留 NaN 型別(「訊號型 NaN (signaling NaNs)」會變" +"成「安靜型 NaN (quiet NaNs)」),例如在 32 位元模式的 x86 系統上。" #: ../../c-api/float.rst:200 msgid "" -"On non-IEEE platforms with more precision, or larger dynamic range, than " -"IEEE 754 supports, not all values can be packed; on non-IEEE platforms with " -"less precision, or smaller dynamic range, not all values can be unpacked. " -"What happens in such cases is partly accidental (alas)." +"It's assumed that the :c:expr:`double` type has the IEEE 754 binary64 double " +"precision format. What happens if it's not true is partly accidental " +"(alas). On non-IEEE platforms with more precision, or larger dynamic range, " +"than IEEE 754 supports, not all values can be packed; on non-IEEE platforms " +"with less precision, or smaller dynamic range, not all values can be " +"unpacked. The packing of special numbers like INFs and NaNs (if such things " +"exist on the platform) may not be handled correctly, and attempting to " +"unpack a bytes string containing an IEEE INF or NaN may raise an exception." msgstr "" -"在非 IEEE 平台上,如果精度更高或動態範圍比 IEEE 754 支援的更大,則無法打包所" -"有值;在非 IEEE 平台上,如果精度較低或動態範圍較小,則無法解包所有值。在這種" -"案例下發生的情況在某種程度上是偶然的(唉)。" - -#: ../../c-api/float.rst:208 +"此處假設 :c:expr:`double` 型別採用 IEEE 754 binary64 雙精度格式。若非如此,會" +"發生的情況在某種程度上是偶然的(唉)。在非 IEEE 平台上,如果精度更高或動態範" +"圍比 IEEE 754 支援的更大,則無法打包所有值;在非 IEEE 平台上,如果精度較低或" +"動態範圍較小,則無法解包所有值。像 INF 和 NaN 這類特殊數值(若該平台上存在的" +"話)的打包可能無法被正確處理,而嘗試解包含有 IEEE INF 或 NaN 的位元組字串可能" +"會引發例外。" + +#: ../../c-api/float.rst:212 msgid "Pack functions" msgstr "打包函式" -#: ../../c-api/float.rst:210 +#: ../../c-api/float.rst:214 msgid "" "The pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an :c:expr:" "`int` argument, non-zero if you want the bytes string in little-endian " "format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` and ``p+7``), zero if " -"you want big-endian format (exponent first, at *p*). The :c:macro:" -"`PY_BIG_ENDIAN` constant can be used to use the native endian: it is equal " -"to ``1`` on big endian processor, or ``0`` on little endian processor." +"you want big-endian format (exponent first, at *p*). Use the :c:macro:`!" +"PY_LITTLE_ENDIAN` constant to select the native endian: it is equal to ``0`` " +"on big endian processor, or ``1`` on little endian processor." msgstr "" "打包例程會從 *p* 開始寫入 2、4 或 8 位元組。*le* 是一個 :c:expr:`int` 引數," "如果你想要位元組字串為小端序格式(指數在最後,位於 ``p+1``、``p+3``、``p+6`` " "和 ``p+7``),則用非零值;如果你想要大端序格式(指數在最前,位於 *p*),則用" -"零。可以使用 :c:macro:`PY_BIG_ENDIAN` 常數來使用原生端序:在大端序處理器上它" -"等於 ``1``,在小端序處理器上它等於 ``0``。" +"零。請使用 :c:macro:`!PY_LITTLE_ENDIAN` 常數來選擇原生端序:在大端序處理器上" +"它等於 ``0``,在小端序處理器上它等於 ``1``。" -#: ../../c-api/float.rst:217 +#: ../../c-api/float.rst:221 msgid "" "Return value: ``0`` if all is OK, ``-1`` if error (and an exception is set, " "most likely :exc:`OverflowError`)." @@ -319,50 +311,38 @@ msgstr "" "回傳值:如果一切正常則為 ``0``,如果發生錯誤則為 ``-1``\\ (並且會設定一個例" "外,最有可能是 :exc:`OverflowError`)。" -#: ../../c-api/float.rst:220 -msgid "There are two problems on non-IEEE platforms:" -msgstr "在非 IEEE 平台上有兩個問題:" - -#: ../../c-api/float.rst:222 -msgid "What this does is undefined if *x* is a NaN or infinity." -msgstr "如果 *x* 是 NaN 或無窮大,則這樣做是未定義的。" - -#: ../../c-api/float.rst:223 -msgid "``-0.0`` and ``+0.0`` produce the same bytes string." -msgstr "``-0.0`` 和 ``+0.0`` 會產生同樣的位元組字串。" - -#: ../../c-api/float.rst:227 +#: ../../c-api/float.rst:226 msgid "Pack a C double as the IEEE 754 binary16 half-precision format." msgstr "將 C double 打包為 IEEE 754 binary16 半精度格式。" -#: ../../c-api/float.rst:231 +#: ../../c-api/float.rst:230 msgid "Pack a C double as the IEEE 754 binary32 single precision format." msgstr "將 C double 打包為 IEEE 754 binary32 單精度格式。" -#: ../../c-api/float.rst:235 +#: ../../c-api/float.rst:234 msgid "Pack a C double as the IEEE 754 binary64 double precision format." msgstr "將 C double 打包為 IEEE 754 binary64 雙精度格式。" -#: ../../c-api/float.rst:239 +#: ../../c-api/float.rst:238 msgid "Unpack functions" msgstr "解包函式" -#: ../../c-api/float.rst:241 +#: ../../c-api/float.rst:240 msgid "" "The unpack routines read 2, 4 or 8 bytes, starting at *p*. *le* is an :c:" "expr:`int` argument, non-zero if the bytes string is in little-endian format " "(exponent last, at ``p+1``, ``p+3`` or ``p+6`` and ``p+7``), zero if big-" -"endian (exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN` constant can " -"be used to use the native endian: it is equal to ``1`` on big endian " -"processor, or ``0`` on little endian processor." +"endian (exponent first, at *p*). Use the :c:macro:`!PY_LITTLE_ENDIAN` " +"constant to select the native endian: it is equal to ``0`` on big endian " +"processor, or ``1`` on little endian processor." msgstr "" "解包例程會從 *p* 開始讀取 2、4 或 8 位元組。*le* 是一個 :c:expr:`int` 引數," "如果位元組字串為小端序格式(指數在最後,位於 ``p+1``、``p+3``、``p+6`` 或 " -"``p+7``),則用非零值;如果為大端序格式(指數在最前,位於 *p*),則用零。可以" -"使用 :c:macro:`PY_BIG_ENDIAN` 常數來使用原生端序:在大端序處理器上它等於 " -"``1``,在小端序處理器上它等於 ``0``。" +"``p+7``),則用非零值;如果為大端序格式(指數在最前,位於 *p*),則用零。請使" +"用 :c:macro:`!PY_LITTLE_ENDIAN` 常數來選擇原生端序:在大端序處理器上它等於 " +"``0``,在小端序處理器上它等於 ``1``。" -#: ../../c-api/float.rst:248 +#: ../../c-api/float.rst:247 msgid "" "Return value: The unpacked double. On error, this is ``-1.0`` and :c:func:" "`PyErr_Occurred` is true (and an exception is set, most likely :exc:" @@ -372,22 +352,15 @@ msgstr "" "`PyErr_Occurred` 為 true(並且會設置一個例外,最有可能是 :exc:" "`OverflowError`)。" -#: ../../c-api/float.rst:252 -msgid "" -"Note that on a non-IEEE platform this will refuse to unpack a bytes string " -"that represents a NaN or infinity." -msgstr "" -"請注意,在非 IEEE 平台上,這將拒絕解包會表示為 NaN 或無窮大的位元組字串。" - -#: ../../c-api/float.rst:257 +#: ../../c-api/float.rst:253 msgid "Unpack the IEEE 754 binary16 half-precision format as a C double." msgstr "將 IEEE 754 binary16 半精度格式解包為 C double。" -#: ../../c-api/float.rst:261 +#: ../../c-api/float.rst:257 msgid "Unpack the IEEE 754 binary32 single precision format as a C double." msgstr "將 IEEE 754 binary32 單精度格式解包為 C double。" -#: ../../c-api/float.rst:265 +#: ../../c-api/float.rst:261 msgid "Unpack the IEEE 754 binary64 double precision format as a C double." msgstr "將 IEEE 754 binary64 雙精度格式解包為 C double。" @@ -398,3 +371,37 @@ msgstr "object(物件)" #: ../../c-api/float.rst:8 msgid "floating-point" msgstr "floating-point(浮點)" + +#~ msgid "The macro is :term:`soft deprecated`." +#~ msgstr "這個巨集已被\\ :term:`軟性棄用 `。" + +#~ msgid "" +#~ "On platforms that appear to use IEEE 754 formats these functions work by " +#~ "copying bits. On other platforms, the 2-byte format is identical to the " +#~ "IEEE 754 binary16 half-precision format, the 4-byte format (32-bit) is " +#~ "identical to the IEEE 754 binary32 single precision format, and the 8-" +#~ "byte format to the IEEE 754 binary64 double precision format, although " +#~ "the packing of INFs and NaNs (if such things exist on the platform) isn't " +#~ "handled correctly, and attempting to unpack a bytes string containing an " +#~ "IEEE INF or NaN will raise an exception." +#~ msgstr "" +#~ "在看似使用 IEEE 754 格式的平台上,這些函式是透過複製位元來運作的。在其他平" +#~ "台上,2 位元組格式與 IEEE 754 binary16 半精度格式相同,4 位元組格式(32 位" +#~ "元)與 IEEE 754 binary32 單精度格式相同,8 位元組格式與 IEEE 754 binary64 " +#~ "雙精度格式相同。儘管如此,INF 和 NaN(如果這些東西在平台上存在)的打包並未" +#~ "正確處理,並且嘗試解包包含 IEEE INF 或 NaN 的位元組字串將引發例外。" + +#~ msgid "There are two problems on non-IEEE platforms:" +#~ msgstr "在非 IEEE 平台上有兩個問題:" + +#~ msgid "What this does is undefined if *x* is a NaN or infinity." +#~ msgstr "如果 *x* 是 NaN 或無窮大,則這樣做是未定義的。" + +#~ msgid "``-0.0`` and ``+0.0`` produce the same bytes string." +#~ msgstr "``-0.0`` 和 ``+0.0`` 會產生同樣的位元組字串。" + +#~ msgid "" +#~ "Note that on a non-IEEE platform this will refuse to unpack a bytes " +#~ "string that represents a NaN or infinity." +#~ msgstr "" +#~ "請注意,在非 IEEE 平台上,這將拒絕解包會表示為 NaN 或無窮大的位元組字串。" diff --git a/c-api/function.po b/c-api/function.po index 61b434d12ad..329396aaa33 100644 --- a/c-api/function.po +++ b/c-api/function.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-10 00:16+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-11-12 15:45+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -238,11 +238,15 @@ msgstr "``PyFunction_EVENT_MODIFY_DEFAULTS``" msgid "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" msgstr "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" -#: ../../c-api/function.rst:190 +#: ../../c-api/function.rst:187 +msgid "``PyFunction_PYFUNC_EVENT_MODIFY_QUALNAME``" +msgstr "``PyFunction_PYFUNC_EVENT_MODIFY_QUALNAME``" + +#: ../../c-api/function.rst:193 msgid "Type of a function watcher callback function." msgstr "" -#: ../../c-api/function.rst:192 +#: ../../c-api/function.rst:195 msgid "" "If *event* is ``PyFunction_EVENT_CREATE`` or ``PyFunction_EVENT_DESTROY`` " "then *new_value* will be ``NULL``. Otherwise, *new_value* will hold a :term:" @@ -250,13 +254,13 @@ msgid "" "for the attribute that is being modified." msgstr "" -#: ../../c-api/function.rst:197 +#: ../../c-api/function.rst:200 msgid "" "The callback may inspect but must not modify *func*; doing so could have " "unpredictable effects, including infinite recursion." msgstr "" -#: ../../c-api/function.rst:200 +#: ../../c-api/function.rst:203 msgid "" "If *event* is ``PyFunction_EVENT_CREATE``, then the callback is invoked " "after *func* has been fully initialized. Otherwise, the callback is invoked " @@ -268,22 +272,22 @@ msgid "" "semantics of the Python code being executed." msgstr "" -#: ../../c-api/function.rst:209 +#: ../../c-api/function.rst:212 msgid "" -"If *event* is ``PyFunction_EVENT_DESTROY``, Taking a reference in the " +"If *event* is ``PyFunction_EVENT_DESTROY``, taking a reference in the " "callback to the about-to-be-destroyed function will resurrect it, preventing " "it from being freed at this time. When the resurrected object is destroyed " "later, any watcher callbacks active at that time will be called again." msgstr "" -#: ../../c-api/function.rst:214 +#: ../../c-api/function.rst:217 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/function.rst:218 +#: ../../c-api/function.rst:221 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " diff --git a/c-api/gcsupport.po b/c-api/gcsupport.po index a95dd47f005..10317647066 100644 --- a/c-api/gcsupport.po +++ b/c-api/gcsupport.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-12-09 00:14+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:31+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -306,94 +306,348 @@ msgstr "" #: ../../c-api/gcsupport.rst:223 msgid "" -"The :c:member:`~PyTypeObject.tp_traverse` handler must have the following " -"type:" +"The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:" +"`inquiry` type, or ``NULL`` if the object is immutable." msgstr "" -#: ../../c-api/gcsupport.rst:228 +#: ../../c-api/gcsupport.rst:229 msgid "" -"Traversal function for a container object. Implementations must call the " -"*visit* function for each object directly contained by *self*, with the " -"parameters to *visit* being the contained object and the *arg* value passed " -"to the handler. The *visit* function must not be called with a ``NULL`` " -"object argument. If *visit* returns a non-zero value that value should be " -"returned immediately." +"Drop references that may have created reference cycles. Immutable objects " +"do not have to define this method since they can never directly create " +"reference cycles. Note that the object must still be valid after calling " +"this method (don't just call :c:func:`Py_DECREF` on a reference). The " +"collector will call this method if it detects that this object is involved " +"in a reference cycle." msgstr "" -#: ../../c-api/gcsupport.rst:235 -msgid "" -"The traversal function must not have any side effects. Implementations may " -"not modify the reference counts of any Python objects nor create or destroy " -"any Python objects." +#: ../../c-api/gcsupport.rst:240 +msgid "Traversal" msgstr "" -#: ../../c-api/gcsupport.rst:239 +#: ../../c-api/gcsupport.rst:242 msgid "" -"To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:" -"func:`Py_VISIT` macro is provided. In order to use this macro, the :c:" -"member:`~PyTypeObject.tp_traverse` implementation must name its arguments " -"exactly *visit* and *arg*:" +"The :c:member:`~PyTypeObject.tp_traverse` handler must have the following " +"type:" msgstr "" #: ../../c-api/gcsupport.rst:246 msgid "" -"If the :c:expr:`PyObject *` *o* is not ``NULL``, call the *visit* callback, " -"with arguments *o* and *arg*. If *visit* returns a non-zero value, then " -"return it. Using this macro, :c:member:`~PyTypeObject.tp_traverse` handlers " -"look like::" +"Traversal function for a garbage-collected object, used by the garbage " +"collector to detect reference cycles. Implementations must call the *visit* " +"function for each object directly contained by *self*, with the parameters " +"to *visit* being the contained object and the *arg* value passed to the " +"handler. The *visit* function must not be called with a ``NULL`` object " +"argument. If *visit* returns a non-zero value, that value should be " +"returned immediately." +msgstr "" + +#: ../../c-api/gcsupport.rst:255 +msgid "" +"A typical :c:member:`!tp_traverse` function calls the :c:func:`Py_VISIT` " +"convenience macro on each of the instance's members that are Python objects " +"that the instance owns. For example, this is a (slightly outdated) traversal " +"function for the :py:class:`threading.local` class::" msgstr "" -#: ../../c-api/gcsupport.rst:251 +#: ../../c-api/gcsupport.rst:261 msgid "" "static int\n" -"my_traverse(Noddy *self, visitproc visit, void *arg)\n" +"local_traverse(PyObject *op, visitproc visit, void *arg)\n" "{\n" -" Py_VISIT(self->foo);\n" -" Py_VISIT(self->bar);\n" +" localobject *self = (localobject *) op;\n" +" Py_VISIT(Py_TYPE(self));\n" +" Py_VISIT(self->args);\n" +" Py_VISIT(self->kw);\n" +" Py_VISIT(self->dict);\n" " return 0;\n" "}" msgstr "" "static int\n" -"my_traverse(Noddy *self, visitproc visit, void *arg)\n" +"local_traverse(PyObject *op, visitproc visit, void *arg)\n" "{\n" -" Py_VISIT(self->foo);\n" -" Py_VISIT(self->bar);\n" +" localobject *self = (localobject *) op;\n" +" Py_VISIT(Py_TYPE(self));\n" +" Py_VISIT(self->args);\n" +" Py_VISIT(self->kw);\n" +" Py_VISIT(self->dict);\n" " return 0;\n" "}" -#: ../../c-api/gcsupport.rst:259 +#: ../../c-api/gcsupport.rst:273 msgid "" -"The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:" -"`inquiry` type, or ``NULL`` if the object is immutable." +":c:func:`Py_VISIT` requires the *visit* and *arg* parameters to :c:func:`!" +"local_traverse` to have these specific names; don't name them just anything." msgstr "" -#: ../../c-api/gcsupport.rst:265 +#: ../../c-api/gcsupport.rst:277 msgid "" -"Drop references that may have created reference cycles. Immutable objects " -"do not have to define this method since they can never directly create " -"reference cycles. Note that the object must still be valid after calling " -"this method (don't just call :c:func:`Py_DECREF` on a reference). The " -"collector will call this method if it detects that this object is involved " -"in a reference cycle." +"Instances of :ref:`heap-allocated types ` hold a reference to " +"their type. Their traversal function must therefore visit the type::" +msgstr "" + +#: ../../c-api/gcsupport.rst:280 +msgid "Py_VISIT(Py_TYPE(self));" +msgstr "Py_VISIT(Py_TYPE(self));" + +#: ../../c-api/gcsupport.rst:282 +msgid "" +"Alternately, the type may delegate this responsibility by calling " +"``tp_traverse`` of a heap-allocated superclass (or another heap-allocated " +"type, if applicable). If they do not, the type object may not be garbage-" +"collected." msgstr "" -#: ../../c-api/gcsupport.rst:274 +#: ../../c-api/gcsupport.rst:287 +msgid "" +"If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" +"`~PyTypeObject.tp_flags` field, the traverse function must call :c:func:" +"`PyObject_VisitManagedDict` like this::" +msgstr "" + +#: ../../c-api/gcsupport.rst:291 +msgid "" +"int err = PyObject_VisitManagedDict((PyObject*)self, visit, arg);\n" +"if (err) {\n" +" return err;\n" +"}" +msgstr "" +"int err = PyObject_VisitManagedDict((PyObject*)self, visit, arg);\n" +"if (err) {\n" +" return err;\n" +"}" + +#: ../../c-api/gcsupport.rst:296 +msgid "" +"Only the members that the instance *owns* (by having :term:`strong " +"references ` to them) must be visited. For instance, if an " +"object supports weak references via the :c:member:`~PyTypeObject." +"tp_weaklist` slot, the pointer supporting the linked list (what " +"*tp_weaklist* points to) must **not** be visited as the instance does not " +"directly own the weak references to itself." +msgstr "" + +#: ../../c-api/gcsupport.rst:303 +msgid "The traversal function has a limitation:" +msgstr "" + +#: ../../c-api/gcsupport.rst:307 +msgid "" +"The traversal function must not have any side effects. Implementations may " +"not modify the reference counts of any Python objects nor create or destroy " +"any Python objects, directly or indirectly." +msgstr "" + +#: ../../c-api/gcsupport.rst:311 +msgid "" +"This means that *most* Python C API functions may not be used, since they " +"can raise a new exception, return a new reference to a result object, have " +"internal logic that uses side effects. Also, unless documented otherwise, " +"functions that happen to not have side effects may start having them in " +"future versions, without warning." +msgstr "" + +#: ../../c-api/gcsupport.rst:317 +msgid "" +"For a list of safe functions, see a :ref:`separate section ` below." +msgstr "" + +#: ../../c-api/gcsupport.rst:322 +msgid "" +"The :c:func:`Py_VISIT` call may be skipped for those members that provably " +"cannot participate in reference cycles. In the ``local_traverse`` example " +"above, there is also a ``self->key`` member, but it can only be ``NULL`` or " +"a Python string and therefore cannot be part of a reference cycle." +msgstr "" + +#: ../../c-api/gcsupport.rst:328 +msgid "" +"On the other hand, even if you know a member can never be part of a cycle, " +"as a debugging aid you may want to visit it anyway just so the :mod:`gc` " +"module's :func:`~gc.get_referents` function will include it." +msgstr "" + +#: ../../c-api/gcsupport.rst:334 +msgid "" +"The :c:member:`~PyTypeObject.tp_traverse` function can be called from any " +"thread." +msgstr ":c:member:`~PyTypeObject.tp_traverse` 函式可以從任何執行緒呼叫。" + +#: ../../c-api/gcsupport.rst:339 +msgid "" +"Garbage collection is a \"stop-the-world\" operation: even in :term:`free " +"threading` builds, only one thread state is :term:`attached ` when :c:member:`!tp_traverse` handlers run." +msgstr "" + +#: ../../c-api/gcsupport.rst:346 +msgid "" +"Heap-allocated types are expected to visit ``Py_TYPE(self)`` in " +"``tp_traverse``. In earlier versions of Python, due to `bug 40217 `_, doing this may lead to crashes in subclasses." +msgstr "" + +#: ../../c-api/gcsupport.rst:351 +msgid "" +"To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:" +"func:`Py_VISIT` macro is provided. In order to use this macro, the :c:member:" +"`~PyTypeObject.tp_traverse` implementation must name its arguments exactly " +"*visit* and *arg*:" +msgstr "" + +#: ../../c-api/gcsupport.rst:358 +msgid "" +"If the :c:expr:`PyObject *` *o* is not ``NULL``, call the *visit* callback, " +"with arguments *o* and *arg*. If *visit* returns a non-zero value, then " +"return it." +msgstr "" + +#: ../../c-api/gcsupport.rst:362 +msgid "This corresponds roughly to::" +msgstr "" + +#: ../../c-api/gcsupport.rst:364 +msgid "" +"#define Py_VISIT(o) \\\n" +" if (op) { \\\n" +" int visit_result = visit(o, arg); \\\n" +" if (visit_result != 0) { \\\n" +" return visit_result; \\\n" +" } \\\n" +" }" +msgstr "" +"#define Py_VISIT(o) \\\n" +" if (op) { \\\n" +" int visit_result = visit(o, arg); \\\n" +" if (visit_result != 0) { \\\n" +" return visit_result; \\\n" +" } \\\n" +" }" + +#: ../../c-api/gcsupport.rst:374 +msgid "Traversal-safe functions" +msgstr "" + +#: ../../c-api/gcsupport.rst:376 +msgid "" +"The following functions and macros are safe to use in a :c:member:" +"`~PyTypeObject.tp_traverse` handler:" +msgstr "" + +#: ../../c-api/gcsupport.rst:379 +msgid "the *visit* function passed to ``tp_traverse``" +msgstr "" + +#: ../../c-api/gcsupport.rst:380 +msgid ":c:func:`Py_VISIT`" +msgstr ":c:func:`Py_VISIT`" + +#: ../../c-api/gcsupport.rst:381 +msgid ":c:func:`Py_SIZE`" +msgstr ":c:func:`Py_SIZE`" + +#: ../../c-api/gcsupport.rst:382 +msgid "" +":c:func:`Py_TYPE`: if called from a :c:member:`!tp_traverse` handler, :c:" +"func:`!Py_TYPE`'s result will be valid for the duration of the handler call" +msgstr "" + +#: ../../c-api/gcsupport.rst:384 +msgid ":c:func:`PyObject_VisitManagedDict`" +msgstr ":c:func:`PyObject_VisitManagedDict`" + +#: ../../c-api/gcsupport.rst:385 +msgid "" +":c:func:`PyObject_TypeCheck`, :c:func:`PyType_IsSubtype`, :c:func:" +"`PyType_HasFeature`" +msgstr ":c:func:`PyObject_TypeCheck`, :c:func:`PyType_IsSubtype`, :c:func:`PyType_HasFeature`" + +#: ../../c-api/gcsupport.rst:387 +msgid "" +":samp:`Py{}_Check` and :samp:`Py{}_CheckExact` -- for example, :" +"c:func:`PyTuple_Check`" +msgstr "" + +#: ../../c-api/gcsupport.rst:389 +msgid ":ref:`duringgc-functions`" +msgstr ":ref:`duringgc-functions`" + +#: ../../c-api/gcsupport.rst:394 +msgid "\"DuringGC\" functions" +msgstr "" + +#: ../../c-api/gcsupport.rst:396 +msgid "" +"The following functions should *only* be used in a :c:member:`~PyTypeObject." +"tp_traverse` handler; calling them in other contexts may have unintended " +"consequences." +msgstr "" + +#: ../../c-api/gcsupport.rst:400 +msgid "" +"These functions act like their counterparts without the ``_DuringGC`` " +"suffix, but they are guaranteed to not have side effects, they do not set an " +"exception on failure, and they return/set :term:`borrowed references " +"` as detailed in the individual documentation." +msgstr "" + +#: ../../c-api/gcsupport.rst:405 +msgid "" +"Note that these functions may fail (return ``NULL`` or ``-1``), but as they " +"do not set an exception, no error information is available. In some cases, " +"failure is not distinguishable from a successful ``NULL`` result." +msgstr "" + +#: ../../c-api/gcsupport.rst:415 ../../c-api/gcsupport.rst:430 +#: ../../c-api/gcsupport.rst:443 +msgid "See :ref:`duringgc-functions` for common information." +msgstr "" + +#: ../../c-api/gcsupport.rst:421 +msgid "" +":c:func:`PyObject_GetTypeData`, :c:func:`PyObject_GetItemData`, :c:func:" +"`PyType_GetModuleState`, :c:func:`PyModule_GetState`, :c:func:" +"`PyModule_GetToken`, :c:func:`PyType_GetBaseByToken`" +msgstr ":c:func:`PyObject_GetTypeData`, :c:func:`PyObject_GetItemData`, :c:func:`PyType_GetModuleState`, :c:func:`PyModule_GetState`, :c:func:`PyModule_GetToken`, :c:func:`PyType_GetBaseByToken`" + +#: ../../c-api/gcsupport.rst:432 +msgid "" +"Sets *\\*result* to a :term:`borrowed reference` rather than a strong one. " +"The reference is valid for the duration of the :c:member:`!tp_traverse` " +"handler call." +msgstr "" + +#: ../../c-api/gcsupport.rst:438 +msgid ":c:func:`PyType_GetBaseByToken`" +msgstr ":c:func:`PyType_GetBaseByToken`" + +#: ../../c-api/gcsupport.rst:445 +msgid "" +"These functions return a :term:`borrowed reference`, which is valid for the " +"duration of the :c:member:`!tp_traverse` handler call." +msgstr "" + +#: ../../c-api/gcsupport.rst:452 +msgid ":c:func:`PyType_GetModule`, :c:func:`PyType_GetModuleByToken`" +msgstr ":c:func:`PyType_GetModule`, :c:func:`PyType_GetModuleByToken`" + +#: ../../c-api/gcsupport.rst:457 msgid "Controlling the Garbage Collector State" msgstr "" -#: ../../c-api/gcsupport.rst:276 +#: ../../c-api/gcsupport.rst:459 msgid "" "The C-API provides the following functions for controlling garbage " "collection runs." msgstr "" -#: ../../c-api/gcsupport.rst:281 +#: ../../c-api/gcsupport.rst:464 msgid "" "Perform a full garbage collection, if the garbage collector is enabled. " "(Note that :func:`gc.collect` runs it unconditionally.)" msgstr "" -#: ../../c-api/gcsupport.rst:284 +#: ../../c-api/gcsupport.rst:467 msgid "" "Returns the number of collected + unreachable objects which cannot be " "collected. If the garbage collector is disabled or already collecting, " @@ -401,54 +655,54 @@ msgid "" "data:`sys.unraisablehook`. This function does not raise exceptions." msgstr "" -#: ../../c-api/gcsupport.rst:294 +#: ../../c-api/gcsupport.rst:477 msgid "" "Enable the garbage collector: similar to :func:`gc.enable`. Returns the " "previous state, 0 for disabled and 1 for enabled." msgstr "" -#: ../../c-api/gcsupport.rst:302 +#: ../../c-api/gcsupport.rst:485 msgid "" "Disable the garbage collector: similar to :func:`gc.disable`. Returns the " "previous state, 0 for disabled and 1 for enabled." msgstr "" -#: ../../c-api/gcsupport.rst:310 +#: ../../c-api/gcsupport.rst:493 msgid "" "Query the state of the garbage collector: similar to :func:`gc.isenabled`. " "Returns the current state, 0 for disabled and 1 for enabled." msgstr "" -#: ../../c-api/gcsupport.rst:317 +#: ../../c-api/gcsupport.rst:500 msgid "Querying Garbage Collector State" msgstr "" -#: ../../c-api/gcsupport.rst:319 +#: ../../c-api/gcsupport.rst:502 msgid "" "The C-API provides the following interface for querying information about " "the garbage collector." msgstr "" -#: ../../c-api/gcsupport.rst:324 +#: ../../c-api/gcsupport.rst:507 msgid "" "Run supplied *callback* on all live GC-capable objects. *arg* is passed " "through to all invocations of *callback*." msgstr "" -#: ../../c-api/gcsupport.rst:328 +#: ../../c-api/gcsupport.rst:511 msgid "" "If new objects are (de)allocated by the callback it is undefined if they " "will be visited." msgstr "" -#: ../../c-api/gcsupport.rst:331 +#: ../../c-api/gcsupport.rst:514 msgid "" "Garbage collection is disabled during operation. Explicitly running a " "collection in the callback may lead to undefined behaviour e.g. visiting the " "same objects multiple times or not at all." msgstr "" -#: ../../c-api/gcsupport.rst:339 +#: ../../c-api/gcsupport.rst:522 msgid "" "Type of the visitor function to be passed to :c:func:" "`PyUnstable_GC_VisitObjects`. *arg* is the same as the *arg* passed to " diff --git a/c-api/import.po b/c-api/import.po index fa6dd95b735..dba704958a2 100644 --- a/c-api/import.po +++ b/c-api/import.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-25 00:13+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-11-11 14:06+0000\n" "Last-Translator: mattwang44@gmail.com\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -31,33 +31,14 @@ msgstr "" "這是 :c:func:`PyImport_Import()` 的包裝器 (wrapper),它使用 :c:expr:`const " "char *` 作為引數,而不是 :c:expr:`PyObject *`。" -#: ../../c-api/import.rst:21 -msgid "This function is a deprecated alias of :c:func:`PyImport_ImportModule`." -msgstr "這個函式是 :c:func:`PyImport_ImportModule` 的已棄用別名。" - -#: ../../c-api/import.rst:23 -msgid "" -"This function used to fail immediately when the import lock was held by " -"another thread. In Python 3.3 though, the locking scheme switched to per-" -"module locks for most purposes, so this function's special behaviour isn't " -"needed anymore." -msgstr "" -"當引入鎖被其他執行緒持有時,這個函式過去會立即失敗。但在 Python 3.3 中,鎖機" -"制轉換成針對每個模組的鎖 (per-module lock) 來達到大多數目的,所以這個函式的特" -"殊行為就不再需要了。" - -#: ../../c-api/import.rst:29 -msgid "Use :c:func:`PyImport_ImportModule` instead." -msgstr "請改用 :c:func:`PyImport_ImportModule`。" - -#: ../../c-api/import.rst:37 +#: ../../c-api/import.rst:24 msgid "" "Import a module. This is best described by referring to the built-in Python " "function :func:`__import__`." msgstr "" "引入一個模組。這最好透過參考 Python 內建函式 :func:`__import__` 來說明。" -#: ../../c-api/import.rst:40 ../../c-api/import.rst:56 +#: ../../c-api/import.rst:27 ../../c-api/import.rst:43 msgid "" "The return value is a new reference to the imported module or top-level " "package, or ``NULL`` with an exception set on failure. Like for :func:" @@ -68,14 +49,14 @@ msgstr "" "像 :func:`__import__` 一樣,當要求一個套件的子模組時,回傳值通常是頂層套件," "除非給定一個非空的 *fromlist*。" -#: ../../c-api/import.rst:46 +#: ../../c-api/import.rst:33 msgid "" "Failing imports remove incomplete module objects, like with :c:func:" "`PyImport_ImportModule`." msgstr "" "失敗的引入會移除不完整的模組物件,就像 :c:func:`PyImport_ImportModule` 一樣。" -#: ../../c-api/import.rst:52 +#: ../../c-api/import.rst:39 msgid "" "Import a module. This is best described by referring to the built-in Python " "function :func:`__import__`, as the standard :func:`__import__` function " @@ -84,7 +65,7 @@ msgstr "" "引入一個模組。這最好透過參考內建的 Python 函式 :func:`__import__` 來說明,因" "為標準的 :func:`__import__` 函式會直接呼叫這個函式。" -#: ../../c-api/import.rst:66 +#: ../../c-api/import.rst:53 msgid "" "Similar to :c:func:`PyImport_ImportModuleLevelObject`, but the name is a " "UTF-8 encoded string instead of a Unicode object." @@ -92,11 +73,11 @@ msgstr "" "類似於 :c:func:`PyImport_ImportModuleLevelObject`,但名稱是 UTF-8 編碼字串," "而不是 Unicode 物件。" -#: ../../c-api/import.rst:69 +#: ../../c-api/import.rst:56 msgid "Negative values for *level* are no longer accepted." msgstr "不再接受負的 *level* 值。" -#: ../../c-api/import.rst:74 +#: ../../c-api/import.rst:61 msgid "" "This is a higher-level interface that calls the current \"import hook " "function\" (with an explicit *level* of 0, meaning absolute import). It " @@ -109,11 +90,11 @@ msgstr "" "``__builtins__`` 中呼叫 :func:`__import__` 函式。這表示引入是使用目前環境所安" "裝的引入掛勾來完成的。" -#: ../../c-api/import.rst:80 +#: ../../c-api/import.rst:67 msgid "This function always uses absolute imports." msgstr "此函式總是使用絕對引入。" -#: ../../c-api/import.rst:85 +#: ../../c-api/import.rst:72 msgid "" "Reload a module. Return a new reference to the reloaded module, or ``NULL`` " "with an exception set on failure (the module still exists in this case)." @@ -121,11 +102,11 @@ msgstr "" "重新載入一個模組。回傳重新載入模組的新參照,或在失敗時回傳 ``NULL`` 並設定例" "外(在這種情況下模組仍然存在)。" -#: ../../c-api/import.rst:91 +#: ../../c-api/import.rst:78 msgid "Return the module object corresponding to a module name." msgstr "回傳與模組名稱對應的模組物件。" -#: ../../c-api/import.rst:93 +#: ../../c-api/import.rst:80 msgid "" "The *name* argument may be of the form ``package.module``. First check the " "modules dictionary if there's one there, and if not, create a new one and " @@ -134,7 +115,7 @@ msgstr "" "*name* 引數的形式可以是 ``package.module``。首先檢查模組字典中是否有,如果沒" "有,則建立新的模組並插入模組字典中。" -#: ../../c-api/import.rst:97 +#: ../../c-api/import.rst:84 msgid "" "Return a :term:`strong reference` to the module on success. Return ``NULL`` " "with an exception set on failure." @@ -142,11 +123,11 @@ msgstr "" "成功時回傳模組的\\ :term:`強參照 `。失敗時回傳 ``NULL`` 並" "設定例外。" -#: ../../c-api/import.rst:100 +#: ../../c-api/import.rst:87 msgid "The module name *name* is decoded from UTF-8." msgstr "模組名稱 *name* 是以 UTF-8 解碼。" -#: ../../c-api/import.rst:102 +#: ../../c-api/import.rst:89 msgid "" "This function does not load or import the module; if the module wasn't " "already loaded, you will get an empty module object. Use :c:func:" @@ -158,7 +139,7 @@ msgstr "" "用 :c:func:`PyImport_ImportModule` 或其變體來引入一個模組。如果尚未存在,則不" "會建立由 *name* 的點名稱 (dotted name) 所隱含的套件結構。" -#: ../../c-api/import.rst:113 +#: ../../c-api/import.rst:100 msgid "" "Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " "reference` and *name* is a Python :class:`str` object." @@ -166,7 +147,7 @@ msgstr "" "類似於 :c:func:`PyImport_AddModuleRef`,但是會回傳一個\\ :term:`借用參照 " "`\\ 且 *name* 為 Python 的 :class:`str` 物件。" -#: ../../c-api/import.rst:121 +#: ../../c-api/import.rst:108 msgid "" "Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " "reference`." @@ -174,7 +155,7 @@ msgstr "" "類似於 :c:func:`PyImport_AddModuleRef`,但是會回傳一個\\ :term:`借用參照 " "`。" -#: ../../c-api/import.rst:129 +#: ../../c-api/import.rst:116 msgid "" "Given a module name (possibly of the form ``package.module``) and a code " "object read from a Python bytecode file or obtained from the built-in " @@ -195,7 +176,7 @@ msgstr "" "modules` 中留下未完全初始化的模組是很危險的,因為這種模組的引入無法知道模組物" "件處於未知狀態(且相對於模組作者的意圖,很可能已經損壞)。" -#: ../../c-api/import.rst:139 +#: ../../c-api/import.rst:126 msgid "" "The module's :attr:`~module.__spec__` and :attr:`~module.__loader__` will be " "set, if not set already, with the appropriate values. The spec's loader " @@ -207,16 +188,15 @@ msgstr "" "果有設定),否則將被設定為 :class:`~importlib.machinery.SourceFileLoader` 的" "實例。" -#: ../../c-api/import.rst:144 +#: ../../c-api/import.rst:131 msgid "" "The module's :attr:`~module.__file__` attribute will be set to the code " -"object's :attr:`~codeobject.co_filename`. If applicable, :attr:`~module." -"__cached__` will also be set." +"object's :attr:`~codeobject.co_filename`." msgstr "" -"模組的 :attr:`~module.__file__` 屬性將會設定為程式碼物件的 :attr:" -"`~codeobject.co_filename`。如果適用,:attr:`~module.__cached__` 也會被設定。" +"模組的 :attr:`~module.__file__` 屬性將會設定為程式碼物件" +"的 :attr:`~codeobject.co_filename`。" -#: ../../c-api/import.rst:148 +#: ../../c-api/import.rst:134 msgid "" "This function will reload the module if it was already imported. See :c:" "func:`PyImport_ReloadModule` for the intended way to reload a module." @@ -224,7 +204,7 @@ msgstr "" "如果模組已經被引入,這個函式會重新載入模組。請參閱 :c:func:" "`PyImport_ReloadModule` 以取得重新載入模組的預期方法。" -#: ../../c-api/import.rst:151 +#: ../../c-api/import.rst:137 msgid "" "If *name* points to a dotted name of the form ``package.module``, any " "package structures not already created will still not be created." @@ -232,7 +212,7 @@ msgstr "" "如果 *name* 指向形式為 ``package.module`` 的點名稱,則任何尚未建立的套件結構" "仍不會被建立。" -#: ../../c-api/import.rst:154 +#: ../../c-api/import.rst:140 msgid "" "See also :c:func:`PyImport_ExecCodeModuleEx` and :c:func:" "`PyImport_ExecCodeModuleWithPathnames`." @@ -240,15 +220,19 @@ msgstr "" "另請參閱 :c:func:`PyImport_ExecCodeModuleEx` 及 :c:func:" "`PyImport_ExecCodeModuleWithPathnames`。" -#: ../../c-api/import.rst:157 +#: ../../c-api/import.rst:143 msgid "" -"The setting of :attr:`~module.__cached__` and :attr:`~module.__loader__` is " -"deprecated. See :class:`~importlib.machinery.ModuleSpec` for alternatives." +"The setting of ``__cached__`` and :attr:`~module.__loader__` is deprecated. " +"See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" -":attr:`~module.__cached__` 和 :attr:`~module.__loader__` 的設定已被棄用。請參" +"``__cached__`` 和 :attr:`~module.__loader__` 的設定已被棄用。請參" "閱 :class:`~importlib.machinery.ModuleSpec` 以取得替代方案。" -#: ../../c-api/import.rst:165 +#: ../../c-api/import.rst:148 +msgid "The ``__cached__`` attribute is no longer set." +msgstr "不會再設定 ``__cached__`` 屬性。" + +#: ../../c-api/import.rst:154 msgid "" "Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`~module.__file__` " "attribute of the module object is set to *pathname* if it is non-``NULL``." @@ -256,29 +240,33 @@ msgstr "" "類似於 :c:func:`PyImport_ExecCodeModule`,但是如果 *pathname* 不是 ``NULL``," "模組物件的 :attr:`~module.__file__` 屬性會被設定為 *pathname*。" -#: ../../c-api/import.rst:168 +#: ../../c-api/import.rst:157 msgid "See also :c:func:`PyImport_ExecCodeModuleWithPathnames`." msgstr "另請參閱 :c:func:`PyImport_ExecCodeModuleWithPathnames`。" -#: ../../c-api/import.rst:173 +#: ../../c-api/import.rst:162 msgid "" -"Like :c:func:`PyImport_ExecCodeModuleEx`, but the :attr:`~module.__cached__` " -"attribute of the module object is set to *cpathname* if it is non-``NULL``. " -"Of the three functions, this is the preferred one to use." +"Like :c:func:`PyImport_ExecCodeModuleEx`, but the path to any compiled file " +"via *cpathname* is used appropriately when non-``NULL``. Of the three " +"functions, this is the preferred one to use." msgstr "" "類似於 :c:func:`PyImport_ExecCodeModuleEx`,但是如果 *cpathname* 不是 " -"``NULL``,模組物件的 :attr:`~module.__cached__` 屬性會被設定為 *cpathname*。" -"在這三個函式中,這是首選的函式。" +"``NULL``,會適當地使用透過 *cpathname* 給定的任何已編譯檔案路徑。在這三個函式" +"中,這是首選的函式。" -#: ../../c-api/import.rst:179 +#: ../../c-api/import.rst:168 msgid "" -"Setting :attr:`~module.__cached__` is deprecated. See :class:`~importlib." -"machinery.ModuleSpec` for alternatives." +"Setting ``__cached__`` is deprecated. See :class:`~importlib.machinery." +"ModuleSpec` for alternatives." msgstr "" -"設定 :attr:`~module.__cached__` 已被棄用。請參閱 :class:`~importlib." -"machinery.ModuleSpec` 以取得替代方案。" +"設定 ``__cached__`` 已被棄用。請參" +"閱 :class:`~importlib.machinery.ModuleSpec` 以取得替代方案。" + +#: ../../c-api/import.rst:172 +msgid "The ``__cached__`` attribute no longer set." +msgstr "不會再設定 ``__cached__`` 屬性。" -#: ../../c-api/import.rst:186 +#: ../../c-api/import.rst:178 msgid "" "Like :c:func:`PyImport_ExecCodeModuleObject`, but *name*, *pathname* and " "*cpathname* are UTF-8 encoded strings. Attempts are also made to figure out " @@ -289,7 +277,7 @@ msgstr "" "*cpathname* 是 UTF-8 編碼的字串。如果 *pathname* 被設定為 ``NULL``,也會嘗試" "從 *cpathname* 中找出 *pathname* 的值應該是什麼。" -#: ../../c-api/import.rst:192 +#: ../../c-api/import.rst:184 msgid "" "Uses :func:`!imp.source_from_cache` in calculating the source path if only " "the bytecode path is provided." @@ -297,11 +285,11 @@ msgstr "" "如果只提供了位元組碼路徑,則在計算原始碼路徑時使用 :func:`!imp." "source_from_cache`。" -#: ../../c-api/import.rst:195 +#: ../../c-api/import.rst:187 msgid "No longer uses the removed :mod:`!imp` module." msgstr "不再使用已被移除的 :mod:`!imp` 模組。" -#: ../../c-api/import.rst:201 +#: ../../c-api/import.rst:193 msgid "" "Return the magic number for Python bytecode files (a.k.a. :file:`.pyc` " "file). The magic number should be present in the first four bytes of the " @@ -311,11 +299,11 @@ msgstr "" "number)。魔術數字應該出現在位元組碼檔案的前四個位元組,以小端序(little-" "endian)位元組順序排列。錯誤時會回傳 ``-1``。" -#: ../../c-api/import.rst:205 +#: ../../c-api/import.rst:197 msgid "Return value of ``-1`` upon failure." msgstr "當失敗時回傳 ``-1``。" -#: ../../c-api/import.rst:211 +#: ../../c-api/import.rst:203 msgid "" "Return the magic tag string for :pep:`3147` format Python bytecode file " "names. Keep in mind that the value at ``sys.implementation.cache_tag`` is " @@ -324,7 +312,7 @@ msgstr "" "回傳 :pep:`3147` 格式 Python 位元組碼檔名的魔術標籤字串。請記住,``sys." "implementation.cache_tag`` 的值是權威的,應該使用它來取代這個函式。" -#: ../../c-api/import.rst:219 +#: ../../c-api/import.rst:211 msgid "" "Return the dictionary used for the module administration (a.k.a. ``sys." "modules``). Note that this is a per-interpreter variable." @@ -332,7 +320,7 @@ msgstr "" "回傳用於模組管理的字典(也稱為 ``sys.modules``)。請注意,這是一個針對每個直" "譯器的變數 (per-interpreter variable)。" -#: ../../c-api/import.rst:224 +#: ../../c-api/import.rst:216 msgid "" "Return the already imported module with the given name. If the module has " "not been imported yet then returns ``NULL`` but does not set an error. " @@ -341,7 +329,7 @@ msgstr "" "回傳已以給定名稱引入的模組。如果模組尚未引入,則會回傳 ``NULL`` 但不會設定錯" "誤。如果查找失敗,則回傳 ``NULL`` 並設定錯誤。" -#: ../../c-api/import.rst:232 +#: ../../c-api/import.rst:224 msgid "" "Return a finder object for a :data:`sys.path`/:attr:`!pkg.__path__` item " "*path*, possibly by fetching it from the :data:`sys.path_importer_cache` " @@ -358,7 +346,7 @@ msgstr "" "finder` 找不到這個路徑項的查找器。將結果快取到 :data:`sys." "path_importer_cache`。回傳查找器物件的新參照。" -#: ../../c-api/import.rst:243 +#: ../../c-api/import.rst:235 msgid "" "Load a frozen module named *name*. Return ``1`` for success, ``0`` if the " "module is not found, and ``-1`` with an exception set if the initialization " @@ -371,11 +359,11 @@ msgstr "" "func:`PyImport_ImportModule`。(請注意這個名稱並不恰當 --- 如果模組已經被引" "入,這個函式會重新載入模組)。" -#: ../../c-api/import.rst:251 +#: ../../c-api/import.rst:243 msgid "The ``__file__`` attribute is no longer set on the module." msgstr "不會再於模組設定 ``__file__`` 屬性。" -#: ../../c-api/import.rst:257 +#: ../../c-api/import.rst:249 msgid "" "Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a " "UTF-8 encoded string instead of a Unicode object." @@ -383,7 +371,7 @@ msgstr "" "類似於 :c:func:`PyImport_ImportFrozenModuleObject`,但名稱是 UTF-8 編碼字串," "而不是 Unicode 物件。" -#: ../../c-api/import.rst:265 +#: ../../c-api/import.rst:257 msgid "" "This is the structure type definition for frozen module descriptors, as " "generated by the :program:`freeze` utility (see :file:`Tools/freeze/` in the " @@ -394,7 +382,7 @@ msgstr "" "Python 原始碼發行版中的 :file:`Tools/freeze/`)。它的定義在 :file:`Include/" "import.h` 中,為: ::" -#: ../../c-api/import.rst:270 +#: ../../c-api/import.rst:262 msgid "" "struct _frozen {\n" " const char *name;\n" @@ -410,7 +398,7 @@ msgstr "" " bool is_package;\n" "};" -#: ../../c-api/import.rst:277 +#: ../../c-api/import.rst:269 msgid "" "The new ``is_package`` field indicates whether the module is a package or " "not. This replaces setting the ``size`` field to a negative value." @@ -418,7 +406,7 @@ msgstr "" "新的 ``is_package`` 欄位指出模組是否為套件。這取代了將 ``size`` 欄位設定為負" "值的方式。" -#: ../../c-api/import.rst:283 +#: ../../c-api/import.rst:275 msgid "" "This pointer is initialized to point to an array of :c:struct:`_frozen` " "records, terminated by one whose members are all ``NULL`` or zero. When a " @@ -430,7 +418,7 @@ msgstr "" "是 ``NULL`` 或 0 的記錄為結尾。當一個凍結的模組被引入時,它會在這個表格中被搜" "尋。第三方程式碼可以利用這一點來提供一個動態建立的凍結模組集合。" -#: ../../c-api/import.rst:291 +#: ../../c-api/import.rst:283 msgid "" "Add a single module to the existing table of built-in modules. This is a " "convenience wrapper around :c:func:`PyImport_ExtendInittab`, returning " @@ -444,7 +432,7 @@ msgstr "" "使用函式 *initfunc* 作為第一次嘗試引入時呼叫的初始化函式。這應該在 :c:func:" "`Py_Initialize` 之前呼叫。" -#: ../../c-api/import.rst:301 +#: ../../c-api/import.rst:293 msgid "" "Structure describing a single entry in the list of built-in modules. " "Programs which embed Python may use an array of these structures in " @@ -455,15 +443,22 @@ msgstr "" "與 :c:func:`PyImport_ExtendInittab` 結合來提供額外的內建模組。這個結構包含兩" "個成員:" -#: ../../c-api/import.rst:309 +#: ../../c-api/import.rst:301 msgid "The module name, as an ASCII encoded string." msgstr "模組名稱,為 ASCII 編碼的字串。" -#: ../../c-api/import.rst:313 +#: ../../c-api/import.rst:305 msgid "Initialization function for a module built into the interpreter." msgstr "內建於直譯器中的模組的初始化函式。" -#: ../../c-api/import.rst:318 +#: ../../c-api/import.rst:307 +msgid "" +"Note that the inittab uses \"``PyInit``\" :ref:`initialization functions " +"`; there is currently no way to include " +"\"``PyModExport_``\" :ref:`export hooks `." +msgstr "" + +#: ../../c-api/import.rst:315 msgid "" "Add a collection of modules to the table of built-in modules. The *newtab* " "array must end with a sentinel entry which contains ``NULL`` for the :c:" @@ -479,7 +474,7 @@ msgstr "" "來擴充內部表格則回傳 ``-1``。在失敗的情況下,沒有模組會被加入內部表格。這個函" "式必須在 :c:func:`Py_Initialize` 之前呼叫。" -#: ../../c-api/import.rst:325 +#: ../../c-api/import.rst:322 msgid "" "If Python is initialized multiple times, :c:func:`PyImport_AppendInittab` " "or :c:func:`PyImport_ExtendInittab` must be called before each Python " @@ -488,7 +483,7 @@ msgstr "" "如果 Python 被多次初始化,:c:func:`PyImport_AppendInittab` 或 :c:func:" "`PyImport_ExtendInittab` 必須在每次 Python 初始化之前被呼叫。" -#: ../../c-api/import.rst:332 +#: ../../c-api/import.rst:329 msgid "" "The table of built-in modules used by Python initialization. Do not use this " "directly; use :c:func:`PyImport_AppendInittab` and :c:func:" @@ -498,15 +493,15 @@ msgstr "" "請改用 :c:func:`PyImport_AppendInittab` 與 :c:func:" "`PyImport_ExtendInittab`。" -#: ../../c-api/import.rst:339 +#: ../../c-api/import.rst:336 msgid "Import the module *mod_name* and get its attribute *attr_name*." msgstr "引入模組 *mod_name* 並取得其屬性 *attr_name*。" -#: ../../c-api/import.rst:341 +#: ../../c-api/import.rst:338 msgid "Names must be Python :class:`str` objects." msgstr "名稱必須是 Python :class:`str` 物件。" -#: ../../c-api/import.rst:343 +#: ../../c-api/import.rst:340 msgid "" "Helper function combining :c:func:`PyImport_Import` and :c:func:" "`PyObject_GetAttr`. For example, it can raise :exc:`ImportError` if the " @@ -517,7 +512,7 @@ msgstr "" "如,如果找不到模組,它會引發 :exc:`ImportError`,如果屬性不存在,則會引發 :" "exc:`AttributeError`。" -#: ../../c-api/import.rst:352 +#: ../../c-api/import.rst:349 ../../c-api/import.rst:369 msgid "" "Similar to :c:func:`PyImport_ImportModuleAttr`, but names are UTF-8 encoded " "strings instead of Python :class:`str` objects." @@ -525,6 +520,84 @@ msgstr "" "類似於 :c:func:`PyImport_ImportModuleAttr`,但名稱是 UTF-8 編碼字串,而不是 " "Python :class:`str` 物件。" +#: ../../c-api/import.rst:356 +msgid "Gets the current lazy imports mode." +msgstr "" + +#: ../../c-api/import.rst:362 +msgid "" +"Return a :term:`strong reference` to the current lazy imports filter, or " +"``NULL`` if none exists. This function always succeeds." +msgstr "" +"回傳目前延遲引入過濾器的\\ :term:`強參照 `,如果不存在則回" +"傳 ``NULL``。此函式總是會成功。" + +#: ../../c-api/import.rst:372 +msgid "This function always returns ``0``." +msgstr "此函式總是回傳 ``0``。" + +#: ../../c-api/import.rst:378 +msgid "" +"Sets the current lazy imports filter. The *filter* should be a callable that " +"will receive ``(importing_module_name, imported_module_name, [fromlist])`` " +"when an import can potentially be lazy. The ``imported_module_name`` value " +"is the resolved module name, so ``lazy from .spam import eggs`` passes " +"``package.spam``. The callable must return ``True`` if the import should be " +"lazy and ``False`` otherwise." +msgstr "" + +#: ../../c-api/import.rst:385 +msgid "Return ``0`` on success and ``-1`` with an exception set otherwise." +msgstr "成功時回傳 ``0``,否則回傳 ``-1`` 並設定例外。" + +#: ../../c-api/import.rst:391 +msgid "Enumeration of possible lazy import modes." +msgstr "" + +#: ../../c-api/import.rst:395 +msgid "Respect the ``lazy`` keyword in source code. This is the default mode." +msgstr "" + +#: ../../c-api/import.rst:399 +msgid "Make all imports lazy by default." +msgstr "" + +#: ../../c-api/import.rst:405 +msgid "" +"This function is a building block that enables embedders to implement the :" +"py:meth:`~importlib.abc.Loader.create_module` step of custom static " +"extension importers (e.g. of statically-linked extensions)." +msgstr "" + +#: ../../c-api/import.rst:409 +msgid "*spec* must be a :class:`~importlib.machinery.ModuleSpec` object." +msgstr "*spec* 必須是一個 :class:`~importlib.machinery.ModuleSpec` 物件。" + +#: ../../c-api/import.rst:411 +msgid "" +"*initfunc* must be an :ref:`initialization function `, the same as for :c:func:`PyImport_AppendInittab`." +msgstr "" + +#: ../../c-api/import.rst:414 +msgid "" +"On success, create and return a module object. This module will not be " +"initialized; call :c:func:`PyModule_Exec` to initialize it. (Custom " +"importers should do this in their :py:meth:`~importlib.abc.Loader." +"exec_module` method.)" +msgstr "" + +#: ../../c-api/import.rst:420 +msgid "" +"If the spec's name is dotted and *initfunc* creates the module using only " +"the last component of the name, the module's :attr:`~module.__name__` is set " +"to the full name from the spec." +msgstr "" + +#: ../../c-api/import.rst:424 +msgid "On error, return NULL with an exception set." +msgstr "" + #: ../../c-api/import.rst:11 msgid "package variable" msgstr "package variable(套件變數)" @@ -541,18 +614,35 @@ msgstr "__all__(套件變數)" msgid "modules (in module sys)" msgstr "modules(sys 模組中)" -#: ../../c-api/import.rst:35 ../../c-api/import.rst:127 +#: ../../c-api/import.rst:22 ../../c-api/import.rst:114 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/import.rst:35 +#: ../../c-api/import.rst:22 msgid "__import__" msgstr "__import__" -#: ../../c-api/import.rst:127 +#: ../../c-api/import.rst:114 msgid "compile" msgstr "compile(編譯)" -#: ../../c-api/import.rst:263 +#: ../../c-api/import.rst:255 msgid "freeze utility" msgstr "freeze utility(凍結工具程式)" + +#~ msgid "" +#~ "This function is a deprecated alias of :c:func:`PyImport_ImportModule`." +#~ msgstr "這個函式是 :c:func:`PyImport_ImportModule` 的已棄用別名。" + +#~ msgid "" +#~ "This function used to fail immediately when the import lock was held by " +#~ "another thread. In Python 3.3 though, the locking scheme switched to per-" +#~ "module locks for most purposes, so this function's special behaviour " +#~ "isn't needed anymore." +#~ msgstr "" +#~ "當引入鎖被其他執行緒持有時,這個函式過去會立即失敗。但在 Python 3.3 中,鎖" +#~ "機制轉換成針對每個模組的鎖 (per-module lock) 來達到大多數目的,所以這個函" +#~ "式的特殊行為就不再需要了。" + +#~ msgid "Use :c:func:`PyImport_ImportModule` instead." +#~ msgstr "請改用 :c:func:`PyImport_ImportModule`。" diff --git a/c-api/init_config.po b/c-api/init_config.po index cdffc9a77ec..2f0b7b3a9fe 100644 --- a/c-api/init_config.po +++ b/c-api/init_config.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-31 00:31+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -1208,7 +1208,7 @@ msgid "*index* must be greater than or equal to ``0``." msgstr "" #: ../../c-api/init_config.rst:735 ../../c-api/init_config.rst:755 -#: ../../c-api/init_config.rst:862 ../../c-api/init_config.rst:1181 +#: ../../c-api/init_config.rst:862 ../../c-api/init_config.rst:1179 msgid "Structure fields:" msgstr "" @@ -1463,7 +1463,7 @@ msgid "See the :term:`locale encoding`." msgstr "請見 :term:`locale encoding`。" #: ../../c-api/init_config.rst:911 ../../c-api/init_config.rst:966 -#: ../../c-api/init_config.rst:1337 +#: ../../c-api/init_config.rst:1340 msgid "Default: ``1`` in Python config, ``0`` in isolated config." msgstr "" @@ -1490,8 +1490,8 @@ msgid "" ":ref:`Python Development Mode `: see :c:member:`PyConfig.dev_mode`." msgstr "" -#: ../../c-api/init_config.rst:935 ../../c-api/init_config.rst:1346 -#: ../../c-api/init_config.rst:1402 ../../c-api/init_config.rst:1896 +#: ../../c-api/init_config.rst:935 ../../c-api/init_config.rst:1349 +#: ../../c-api/init_config.rst:1405 ../../c-api/init_config.rst:1899 msgid "Default: ``-1`` in Python mode, ``0`` in isolated mode." msgstr "" @@ -1499,7 +1499,7 @@ msgstr "" msgid "Isolated mode: see :c:member:`PyConfig.isolated`." msgstr "" -#: ../../c-api/init_config.rst:941 ../../c-api/init_config.rst:1573 +#: ../../c-api/init_config.rst:941 ../../c-api/init_config.rst:1576 msgid "Default: ``0`` in Python mode, ``1`` in isolated mode." msgstr "" @@ -1525,20 +1525,20 @@ msgid "" "variable value." msgstr "" -#: ../../c-api/init_config.rst:954 ../../c-api/init_config.rst:1587 +#: ../../c-api/init_config.rst:954 ../../c-api/init_config.rst:1590 msgid "" "Only available on Windows. ``#ifdef MS_WINDOWS`` macro can be used for " "Windows specific code." msgstr "" -#: ../../c-api/init_config.rst:957 ../../c-api/init_config.rst:1285 -#: ../../c-api/init_config.rst:1292 ../../c-api/init_config.rst:1359 -#: ../../c-api/init_config.rst:1491 ../../c-api/init_config.rst:1509 -#: ../../c-api/init_config.rst:1523 ../../c-api/init_config.rst:1590 -#: ../../c-api/init_config.rst:1604 ../../c-api/init_config.rst:1664 -#: ../../c-api/init_config.rst:1716 ../../c-api/init_config.rst:1778 -#: ../../c-api/init_config.rst:1832 ../../c-api/init_config.rst:1861 -#: ../../c-api/init_config.rst:1975 ../../c-api/init_config.rst:2021 +#: ../../c-api/init_config.rst:957 ../../c-api/init_config.rst:1283 +#: ../../c-api/init_config.rst:1295 ../../c-api/init_config.rst:1362 +#: ../../c-api/init_config.rst:1494 ../../c-api/init_config.rst:1512 +#: ../../c-api/init_config.rst:1526 ../../c-api/init_config.rst:1593 +#: ../../c-api/init_config.rst:1607 ../../c-api/init_config.rst:1667 +#: ../../c-api/init_config.rst:1719 ../../c-api/init_config.rst:1781 +#: ../../c-api/init_config.rst:1835 ../../c-api/init_config.rst:1864 +#: ../../c-api/init_config.rst:1978 ../../c-api/init_config.rst:2024 msgid "Default: ``0``." msgstr "預設:``0``。" @@ -1556,7 +1556,7 @@ msgid "" "use_environment`." msgstr "" -#: ../../c-api/init_config.rst:973 ../../c-api/init_config.rst:1937 +#: ../../c-api/init_config.rst:973 ../../c-api/init_config.rst:1940 msgid "Default: ``1`` in Python config and ``0`` in isolated config." msgstr "" @@ -1570,75 +1570,73 @@ msgid "" "the :envvar:`PYTHONUTF8` environment variable." msgstr "" -#: ../../c-api/init_config.rst:982 -msgid "Also set to ``1`` if the ``LC_CTYPE`` locale is ``C`` or ``POSIX``." -msgstr "" - -#: ../../c-api/init_config.rst:984 -msgid "Default: ``-1`` in Python config and ``0`` in isolated config." -msgstr "" +#: ../../c-api/init_config.rst:982 ../../c-api/init_config.rst:1270 +#: ../../c-api/init_config.rst:1308 ../../c-api/init_config.rst:1852 +#: ../../c-api/init_config.rst:2009 +msgid "Default: ``1``." +msgstr "預設值:``1``。" -#: ../../c-api/init_config.rst:990 +#: ../../c-api/init_config.rst:988 msgid "Preinitialize Python with PyPreConfig" msgstr "" -#: ../../c-api/init_config.rst:992 +#: ../../c-api/init_config.rst:990 msgid "The preinitialization of Python:" msgstr "" -#: ../../c-api/init_config.rst:994 +#: ../../c-api/init_config.rst:992 msgid "Set the Python memory allocators (:c:member:`PyPreConfig.allocator`)" msgstr "" -#: ../../c-api/init_config.rst:995 +#: ../../c-api/init_config.rst:993 msgid "Configure the LC_CTYPE locale (:term:`locale encoding`)" msgstr "" -#: ../../c-api/init_config.rst:996 +#: ../../c-api/init_config.rst:994 msgid "" "Set the :ref:`Python UTF-8 Mode ` (:c:member:`PyPreConfig." "utf8_mode`)" msgstr "" -#: ../../c-api/init_config.rst:999 +#: ../../c-api/init_config.rst:997 msgid "" "The current preconfiguration (``PyPreConfig`` type) is stored in " "``_PyRuntime.preconfig``." msgstr "" -#: ../../c-api/init_config.rst:1002 +#: ../../c-api/init_config.rst:1000 msgid "Functions to preinitialize Python:" msgstr "" -#: ../../c-api/init_config.rst:1006 ../../c-api/init_config.rst:1012 -#: ../../c-api/init_config.rst:1021 +#: ../../c-api/init_config.rst:1004 ../../c-api/init_config.rst:1010 +#: ../../c-api/init_config.rst:1019 msgid "Preinitialize Python from *preconfig* preconfiguration." msgstr "" -#: ../../c-api/init_config.rst:1008 ../../c-api/init_config.rst:1017 -#: ../../c-api/init_config.rst:1026 +#: ../../c-api/init_config.rst:1006 ../../c-api/init_config.rst:1015 +#: ../../c-api/init_config.rst:1024 msgid "*preconfig* must not be ``NULL``." msgstr "*preconfig* 不可為 ``NULL``。" -#: ../../c-api/init_config.rst:1014 +#: ../../c-api/init_config.rst:1012 msgid "" "Parse *argv* command line arguments (bytes strings) if :c:member:" "`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" -#: ../../c-api/init_config.rst:1023 +#: ../../c-api/init_config.rst:1021 msgid "" "Parse *argv* command line arguments (wide strings) if :c:member:" "`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" -#: ../../c-api/init_config.rst:1028 ../../c-api/init_config.rst:2044 +#: ../../c-api/init_config.rst:1026 ../../c-api/init_config.rst:2047 msgid "" "The caller is responsible to handle exceptions (error or exit) using :c:func:" "`PyStatus_Exception` and :c:func:`Py_ExitStatusException`." msgstr "" -#: ../../c-api/init_config.rst:1031 +#: ../../c-api/init_config.rst:1029 msgid "" "For :ref:`Python Configuration ` (:c:func:" "`PyPreConfig_InitPythonConfig`), if Python is initialized with command line " @@ -1648,7 +1646,7 @@ msgid "" "`Python UTF-8 Mode `." msgstr "" -#: ../../c-api/init_config.rst:1038 +#: ../../c-api/init_config.rst:1036 msgid "" "``PyMem_SetAllocator()`` can be called after :c:func:`Py_PreInitialize` and " "before :c:func:`Py_InitializeFromConfig` to install a custom memory " @@ -1656,7 +1654,7 @@ msgid "" "`PyPreConfig.allocator` is set to ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "" -#: ../../c-api/init_config.rst:1043 +#: ../../c-api/init_config.rst:1041 msgid "" "Python memory allocation functions like :c:func:`PyMem_RawMalloc` must not " "be used before the Python preinitialization, whereas calling directly " @@ -1664,13 +1662,13 @@ msgid "" "not be called before the Python preinitialization." msgstr "" -#: ../../c-api/init_config.rst:1048 +#: ../../c-api/init_config.rst:1046 msgid "" "Example using the preinitialization to enable the :ref:`Python UTF-8 Mode " "`::" msgstr "" -#: ../../c-api/init_config.rst:1051 +#: ../../c-api/init_config.rst:1049 msgid "" "PyStatus status;\n" "PyPreConfig preconfig;\n" @@ -1690,84 +1688,84 @@ msgid "" "Py_Finalize();" msgstr "" -#: ../../c-api/init_config.rst:1070 +#: ../../c-api/init_config.rst:1068 msgid "PyConfig" msgstr "PyConfig" -#: ../../c-api/init_config.rst:1074 +#: ../../c-api/init_config.rst:1072 msgid "Structure containing most parameters to configure Python." msgstr "" -#: ../../c-api/init_config.rst:1076 +#: ../../c-api/init_config.rst:1074 msgid "" "When done, the :c:func:`PyConfig_Clear` function must be used to release the " "configuration memory." msgstr "" -#: ../../c-api/init_config.rst:1081 +#: ../../c-api/init_config.rst:1079 msgid "Structure methods:" msgstr "" -#: ../../c-api/init_config.rst:1085 +#: ../../c-api/init_config.rst:1083 msgid "" "Initialize configuration with the :ref:`Python Configuration `." msgstr "" -#: ../../c-api/init_config.rst:1090 +#: ../../c-api/init_config.rst:1088 msgid "" "Initialize configuration with the :ref:`Isolated Configuration `." msgstr "" -#: ../../c-api/init_config.rst:1095 +#: ../../c-api/init_config.rst:1093 msgid "Copy the wide character string *str* into ``*config_str``." msgstr "" -#: ../../c-api/init_config.rst:1097 ../../c-api/init_config.rst:1104 -#: ../../c-api/init_config.rst:1111 ../../c-api/init_config.rst:1119 -#: ../../c-api/init_config.rst:1125 ../../c-api/init_config.rst:1142 +#: ../../c-api/init_config.rst:1095 ../../c-api/init_config.rst:1102 +#: ../../c-api/init_config.rst:1109 ../../c-api/init_config.rst:1117 +#: ../../c-api/init_config.rst:1123 ../../c-api/init_config.rst:1140 msgid ":ref:`Preinitialize Python ` if needed." msgstr "" -#: ../../c-api/init_config.rst:1101 +#: ../../c-api/init_config.rst:1099 msgid "" "Decode *str* using :c:func:`Py_DecodeLocale` and set the result into " "``*config_str``." msgstr "" -#: ../../c-api/init_config.rst:1108 +#: ../../c-api/init_config.rst:1106 msgid "" "Set command line arguments (:c:member:`~PyConfig.argv` member of *config*) " "from the *argv* list of wide character strings." msgstr "" -#: ../../c-api/init_config.rst:1115 +#: ../../c-api/init_config.rst:1113 msgid "" "Set command line arguments (:c:member:`~PyConfig.argv` member of *config*) " "from the *argv* list of bytes strings. Decode bytes using :c:func:" "`Py_DecodeLocale`." msgstr "" -#: ../../c-api/init_config.rst:1123 +#: ../../c-api/init_config.rst:1121 msgid "Set the list of wide strings *list* to *length* and *items*." msgstr "" -#: ../../c-api/init_config.rst:1129 +#: ../../c-api/init_config.rst:1127 msgid "Read all Python configuration." msgstr "讀取所有 Python 配置。" -#: ../../c-api/init_config.rst:1131 +#: ../../c-api/init_config.rst:1129 msgid "Fields which are already initialized are left unchanged." msgstr "已經初始化的欄位將保持不變。" -#: ../../c-api/init_config.rst:1133 +#: ../../c-api/init_config.rst:1131 msgid "" "Fields for :ref:`path configuration ` are no longer " "calculated or modified when calling this function, as of Python 3.11." msgstr "" -#: ../../c-api/init_config.rst:1136 ../../c-api/init_config.rst:1693 +#: ../../c-api/init_config.rst:1134 ../../c-api/init_config.rst:1696 msgid "" "The :c:func:`PyConfig_Read` function only parses :c:member:`PyConfig.argv` " "arguments once: :c:member:`PyConfig.parse_argv` is set to ``2`` after " @@ -1776,25 +1774,25 @@ msgid "" "as Python options." msgstr "" -#: ../../c-api/init_config.rst:1144 +#: ../../c-api/init_config.rst:1142 msgid "" "The :c:member:`PyConfig.argv` arguments are now only parsed once, :c:member:" "`PyConfig.parse_argv` is set to ``2`` after arguments are parsed, and " "arguments are only parsed if :c:member:`PyConfig.parse_argv` equals ``1``." msgstr "" -#: ../../c-api/init_config.rst:1150 +#: ../../c-api/init_config.rst:1148 msgid "" ":c:func:`PyConfig_Read` no longer calculates all paths, and so fields listed " "under :ref:`Python Path Configuration ` may no longer be " "updated until :c:func:`Py_InitializeFromConfig` is called." msgstr "" -#: ../../c-api/init_config.rst:1158 +#: ../../c-api/init_config.rst:1156 msgid "Release configuration memory." msgstr "" -#: ../../c-api/init_config.rst:1160 +#: ../../c-api/init_config.rst:1158 msgid "" "Most ``PyConfig`` methods :ref:`preinitialize Python ` if needed. " "In that case, the Python preinitialization configuration (:c:type:" @@ -1803,23 +1801,23 @@ msgid "" "before calling a :c:type:`PyConfig` method:" msgstr "" -#: ../../c-api/init_config.rst:1166 +#: ../../c-api/init_config.rst:1164 msgid ":c:member:`PyConfig.dev_mode`" msgstr ":c:member:`PyConfig.dev_mode`" -#: ../../c-api/init_config.rst:1167 +#: ../../c-api/init_config.rst:1165 msgid ":c:member:`PyConfig.isolated`" msgstr ":c:member:`PyConfig.isolated`" -#: ../../c-api/init_config.rst:1168 +#: ../../c-api/init_config.rst:1166 msgid ":c:member:`PyConfig.parse_argv`" msgstr ":c:member:`PyConfig.parse_argv`" -#: ../../c-api/init_config.rst:1169 +#: ../../c-api/init_config.rst:1167 msgid ":c:member:`PyConfig.use_environment`" msgstr ":c:member:`PyConfig.use_environment`" -#: ../../c-api/init_config.rst:1171 +#: ../../c-api/init_config.rst:1169 msgid "" "Moreover, if :c:func:`PyConfig_SetArgv` or :c:func:`PyConfig_SetBytesArgv` " "is used, this method must be called before other methods, since the " @@ -1827,13 +1825,13 @@ msgid "" "member:`~PyConfig.parse_argv` is non-zero)." msgstr "" -#: ../../c-api/init_config.rst:1176 +#: ../../c-api/init_config.rst:1174 msgid "" "The caller of these methods is responsible to handle exceptions (error or " "exit) using ``PyStatus_Exception()`` and ``Py_ExitStatusException()``." msgstr "" -#: ../../c-api/init_config.rst:1189 +#: ../../c-api/init_config.rst:1187 msgid "" "Set :data:`sys.argv` command line arguments based on :c:member:`~PyConfig." "argv`. These parameters are similar to those passed to the program's :c:" @@ -1843,434 +1841,435 @@ msgid "" "entry in :c:member:`~PyConfig.argv` can be an empty string." msgstr "" -#: ../../c-api/init_config.rst:1197 +#: ../../c-api/init_config.rst:1195 msgid "" "Set :c:member:`~PyConfig.parse_argv` to ``1`` to parse :c:member:`~PyConfig." "argv` the same way the regular Python parses Python command line arguments " "and then to strip Python arguments from :c:member:`~PyConfig.argv`." msgstr "" -#: ../../c-api/init_config.rst:1202 +#: ../../c-api/init_config.rst:1200 msgid "" "If :c:member:`~PyConfig.argv` is empty, an empty string is added to ensure " "that :data:`sys.argv` always exists and is never empty." msgstr "" -#: ../../c-api/init_config.rst:1205 ../../c-api/init_config.rst:1232 -#: ../../c-api/init_config.rst:1246 ../../c-api/init_config.rst:1256 -#: ../../c-api/init_config.rst:1367 ../../c-api/init_config.rst:1376 -#: ../../c-api/init_config.rst:1387 ../../c-api/init_config.rst:1478 -#: ../../c-api/init_config.rst:1634 ../../c-api/init_config.rst:1735 -#: ../../c-api/init_config.rst:1754 ../../c-api/init_config.rst:1769 -#: ../../c-api/init_config.rst:1786 ../../c-api/init_config.rst:1799 -#: ../../c-api/init_config.rst:1807 ../../c-api/init_config.rst:1821 -#: ../../c-api/init_config.rst:1924 +#: ../../c-api/init_config.rst:1203 ../../c-api/init_config.rst:1230 +#: ../../c-api/init_config.rst:1244 ../../c-api/init_config.rst:1254 +#: ../../c-api/init_config.rst:1370 ../../c-api/init_config.rst:1379 +#: ../../c-api/init_config.rst:1390 ../../c-api/init_config.rst:1481 +#: ../../c-api/init_config.rst:1637 ../../c-api/init_config.rst:1738 +#: ../../c-api/init_config.rst:1757 ../../c-api/init_config.rst:1772 +#: ../../c-api/init_config.rst:1789 ../../c-api/init_config.rst:1802 +#: ../../c-api/init_config.rst:1810 ../../c-api/init_config.rst:1824 +#: ../../c-api/init_config.rst:1927 msgid "Default: ``NULL``." msgstr "預設值:``NULL``。" -#: ../../c-api/init_config.rst:1207 +#: ../../c-api/init_config.rst:1205 msgid "See also the :c:member:`~PyConfig.orig_argv` member." msgstr "另請參閱 :c:member:`~PyConfig.orig_argv` 成員。" -#: ../../c-api/init_config.rst:1211 +#: ../../c-api/init_config.rst:1209 msgid "" "If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe path to :" "data:`sys.path` at startup:" msgstr "" -#: ../../c-api/init_config.rst:1214 +#: ../../c-api/init_config.rst:1212 msgid "" "If :c:member:`argv[0] ` is equal to ``L\"-m\"`` (``python -m " "module``), prepend the current working directory." msgstr "" -#: ../../c-api/init_config.rst:1216 +#: ../../c-api/init_config.rst:1214 msgid "" "If running a script (``python script.py``), prepend the script's directory. " "If it's a symbolic link, resolve symbolic links." msgstr "" -#: ../../c-api/init_config.rst:1218 +#: ../../c-api/init_config.rst:1216 msgid "" "Otherwise (``python -c code`` and ``python``), prepend an empty string, " "which means the current working directory." msgstr "" -#: ../../c-api/init_config.rst:1221 +#: ../../c-api/init_config.rst:1219 msgid "" "Set to ``1`` by the :option:`-P` command line option and the :envvar:" "`PYTHONSAFEPATH` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1224 +#: ../../c-api/init_config.rst:1222 msgid "Default: ``0`` in Python config, ``1`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:1230 +#: ../../c-api/init_config.rst:1228 msgid ":data:`sys.base_exec_prefix`." msgstr ":data:`sys.base_exec_prefix`。" -#: ../../c-api/init_config.rst:1234 ../../c-api/init_config.rst:1248 -#: ../../c-api/init_config.rst:1258 ../../c-api/init_config.rst:1378 -#: ../../c-api/init_config.rst:1389 ../../c-api/init_config.rst:1651 -#: ../../c-api/init_config.rst:1737 +#: ../../c-api/init_config.rst:1232 ../../c-api/init_config.rst:1246 +#: ../../c-api/init_config.rst:1256 ../../c-api/init_config.rst:1381 +#: ../../c-api/init_config.rst:1392 ../../c-api/init_config.rst:1654 +#: ../../c-api/init_config.rst:1740 msgid "Part of the :ref:`Python Path Configuration ` output." msgstr "" -#: ../../c-api/init_config.rst:1236 +#: ../../c-api/init_config.rst:1234 msgid "See also :c:member:`PyConfig.exec_prefix`." msgstr "也請見 :c:member:`PyConfig.exec_prefix`" -#: ../../c-api/init_config.rst:1240 +#: ../../c-api/init_config.rst:1238 msgid "Python base executable: ``sys._base_executable``." msgstr "Python 基礎可執行檔:``sys._base_executable``。" -#: ../../c-api/init_config.rst:1242 +#: ../../c-api/init_config.rst:1240 msgid "Set by the ``__PYVENV_LAUNCHER__`` environment variable." msgstr "由 ``__PYVENV_LAUNCHER__`` 環境變數設定。" -#: ../../c-api/init_config.rst:1244 +#: ../../c-api/init_config.rst:1242 msgid "Set from :c:member:`PyConfig.executable` if ``NULL``." msgstr "如果為 ``NULL``,則從 :c:member:`PyConfig.executable` 設定。" -#: ../../c-api/init_config.rst:1250 +#: ../../c-api/init_config.rst:1248 msgid "See also :c:member:`PyConfig.executable`." msgstr "也請見 :c:member:`PyConfig.executable`" -#: ../../c-api/init_config.rst:1254 +#: ../../c-api/init_config.rst:1252 msgid ":data:`sys.base_prefix`." msgstr ":data:`sys.base_prefix`。" -#: ../../c-api/init_config.rst:1260 +#: ../../c-api/init_config.rst:1258 msgid "See also :c:member:`PyConfig.prefix`." msgstr "也請見 :c:member:`PyConfig.prefix`" -#: ../../c-api/init_config.rst:1264 +#: ../../c-api/init_config.rst:1262 msgid "" "If equals to ``0`` and :c:member:`~PyConfig.configure_c_stdio` is non-zero, " "disable buffering on the C streams stdout and stderr." msgstr "" -#: ../../c-api/init_config.rst:1267 +#: ../../c-api/init_config.rst:1265 msgid "" "Set to ``0`` by the :option:`-u` command line option and the :envvar:" "`PYTHONUNBUFFERED` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1270 +#: ../../c-api/init_config.rst:1268 msgid "stdin is always opened in buffered mode." msgstr "" -#: ../../c-api/init_config.rst:1272 ../../c-api/init_config.rst:1305 -#: ../../c-api/init_config.rst:1849 ../../c-api/init_config.rst:2006 -msgid "Default: ``1``." -msgstr "預設值:``1``。" - -#: ../../c-api/init_config.rst:1276 +#: ../../c-api/init_config.rst:1274 msgid "" "If equals to ``1``, issue a warning when comparing :class:`bytes` or :class:" "`bytearray` with :class:`str`, or comparing :class:`bytes` with :class:`int`." msgstr "" -#: ../../c-api/init_config.rst:1280 +#: ../../c-api/init_config.rst:1278 msgid "" "If equal or greater to ``2``, raise a :exc:`BytesWarning` exception in these " "cases." msgstr "" -#: ../../c-api/init_config.rst:1283 +#: ../../c-api/init_config.rst:1281 msgid "Incremented by the :option:`-b` command line option." msgstr "" -#: ../../c-api/init_config.rst:1289 +#: ../../c-api/init_config.rst:1287 +msgid "" +"The :option:`-b` and :option:`!-bb` options will become no-op in 3.17. :c:" +"member:`~PyConfig.bytes_warning` member will be removed in 3.17." +msgstr "" + +#: ../../c-api/init_config.rst:1292 msgid "" "If non-zero, emit a :exc:`EncodingWarning` warning when :class:`io." "TextIOWrapper` uses its default encoding. See :ref:`io-encoding-warning` for " "details." msgstr "" -#: ../../c-api/init_config.rst:1298 +#: ../../c-api/init_config.rst:1301 msgid "" "If equals to ``0``, disables the inclusion of the end line and column " "mappings in code objects. Also disables traceback printing carets to " "specific error locations." msgstr "" -#: ../../c-api/init_config.rst:1302 +#: ../../c-api/init_config.rst:1305 msgid "" "Set to ``0`` by the :envvar:`PYTHONNODEBUGRANGES` environment variable and " "by the :option:`-X no_debug_ranges <-X>` command line option." msgstr "" -#: ../../c-api/init_config.rst:1311 +#: ../../c-api/init_config.rst:1314 msgid "" "Control the validation behavior of hash-based ``.pyc`` files: value of the :" "option:`--check-hash-based-pycs` command line option." msgstr "" -#: ../../c-api/init_config.rst:1314 +#: ../../c-api/init_config.rst:1317 msgid "Valid values:" msgstr "有效值:" -#: ../../c-api/init_config.rst:1316 +#: ../../c-api/init_config.rst:1319 msgid "" "``L\"always\"``: Hash the source file for invalidation regardless of value " "of the 'check_source' flag." msgstr "" -#: ../../c-api/init_config.rst:1318 +#: ../../c-api/init_config.rst:1321 msgid "``L\"never\"``: Assume that hash-based pycs always are valid." msgstr "" -#: ../../c-api/init_config.rst:1319 +#: ../../c-api/init_config.rst:1322 msgid "" "``L\"default\"``: The 'check_source' flag in hash-based pycs determines " "invalidation." msgstr "" -#: ../../c-api/init_config.rst:1322 +#: ../../c-api/init_config.rst:1325 msgid "Default: ``L\"default\"``." msgstr "預設:``L\"default\"``。" -#: ../../c-api/init_config.rst:1324 +#: ../../c-api/init_config.rst:1327 msgid "See also :pep:`552` \"Deterministic pycs\"." msgstr "" -#: ../../c-api/init_config.rst:1328 +#: ../../c-api/init_config.rst:1331 msgid "If non-zero, configure C standard streams:" msgstr "" -#: ../../c-api/init_config.rst:1330 +#: ../../c-api/init_config.rst:1333 msgid "" "On Windows, set the binary mode (``O_BINARY``) on stdin, stdout and stderr." msgstr "" -#: ../../c-api/init_config.rst:1332 +#: ../../c-api/init_config.rst:1335 msgid "" "If :c:member:`~PyConfig.buffered_stdio` equals zero, disable buffering of " "stdin, stdout and stderr streams." msgstr "" -#: ../../c-api/init_config.rst:1334 +#: ../../c-api/init_config.rst:1337 msgid "" "If :c:member:`~PyConfig.interactive` is non-zero, enable stream buffering on " "stdin and stdout (only stdout on Windows)." msgstr "" -#: ../../c-api/init_config.rst:1341 +#: ../../c-api/init_config.rst:1344 msgid "If non-zero, enable the :ref:`Python Development Mode `." msgstr "" -#: ../../c-api/init_config.rst:1343 +#: ../../c-api/init_config.rst:1346 msgid "" "Set to ``1`` by the :option:`-X dev <-X>` option and the :envvar:" "`PYTHONDEVMODE` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1350 +#: ../../c-api/init_config.rst:1353 msgid "Dump Python references?" msgstr "" -#: ../../c-api/init_config.rst:1352 +#: ../../c-api/init_config.rst:1355 msgid "If non-zero, dump all objects which are still alive at exit." msgstr "" -#: ../../c-api/init_config.rst:1354 +#: ../../c-api/init_config.rst:1357 msgid "Set to ``1`` by the :envvar:`PYTHONDUMPREFS` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1356 +#: ../../c-api/init_config.rst:1359 msgid "" "Needs a special build of Python with the ``Py_TRACE_REFS`` macro defined: " "see the :option:`configure --with-trace-refs option <--with-trace-refs>`." msgstr "" -#: ../../c-api/init_config.rst:1363 +#: ../../c-api/init_config.rst:1366 msgid "Filename where to dump Python references." msgstr "" -#: ../../c-api/init_config.rst:1365 +#: ../../c-api/init_config.rst:1368 msgid "Set by the :envvar:`PYTHONDUMPREFSFILE` environment variable." msgstr "由 :envvar:`PYTHONDUMPREFSFILE` 環境變數設定。" -#: ../../c-api/init_config.rst:1373 +#: ../../c-api/init_config.rst:1376 msgid "" "The site-specific directory prefix where the platform-dependent Python files " "are installed: :data:`sys.exec_prefix`." msgstr "" -#: ../../c-api/init_config.rst:1380 +#: ../../c-api/init_config.rst:1383 msgid "See also :c:member:`PyConfig.base_exec_prefix`." msgstr "也請見 :c:member:`PyConfig.base_exec_prefix`" -#: ../../c-api/init_config.rst:1384 +#: ../../c-api/init_config.rst:1387 msgid "" "The absolute path of the executable binary for the Python interpreter: :data:" "`sys.executable`." msgstr "" -#: ../../c-api/init_config.rst:1391 +#: ../../c-api/init_config.rst:1394 msgid "See also :c:member:`PyConfig.base_executable`." msgstr "也請見 :c:member:`PyConfig.base_executable`" -#: ../../c-api/init_config.rst:1395 +#: ../../c-api/init_config.rst:1398 msgid "Enable faulthandler?" msgstr "啟用 faulthandler?" -#: ../../c-api/init_config.rst:1397 +#: ../../c-api/init_config.rst:1400 msgid "If non-zero, call :func:`faulthandler.enable` at startup." msgstr "如果非零,則在啟動時呼叫 :func:`faulthandler.enable`。" -#: ../../c-api/init_config.rst:1399 +#: ../../c-api/init_config.rst:1402 msgid "" "Set to ``1`` by :option:`-X faulthandler <-X>` and the :envvar:" "`PYTHONFAULTHANDLER` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1406 +#: ../../c-api/init_config.rst:1409 msgid "" ":term:`Filesystem encoding `: :func:" "`sys.getfilesystemencoding`." msgstr "" -#: ../../c-api/init_config.rst:1409 +#: ../../c-api/init_config.rst:1412 msgid "On macOS, Android and VxWorks: use ``\"utf-8\"`` by default." msgstr "" -#: ../../c-api/init_config.rst:1411 +#: ../../c-api/init_config.rst:1414 msgid "" "On Windows: use ``\"utf-8\"`` by default, or ``\"mbcs\"`` if :c:member:" "`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig` is non-" "zero." msgstr "" -#: ../../c-api/init_config.rst:1415 +#: ../../c-api/init_config.rst:1418 msgid "Default encoding on other platforms:" msgstr "其他平台的預設編碼:" -#: ../../c-api/init_config.rst:1417 +#: ../../c-api/init_config.rst:1420 msgid "``\"utf-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." msgstr "如果 :c:member:`PyPreConfig.utf8_mode` 非零,則為 ``\"utf-8\"``。" -#: ../../c-api/init_config.rst:1418 +#: ../../c-api/init_config.rst:1421 msgid "" "``\"ascii\"`` if Python detects that ``nl_langinfo(CODESET)`` announces the " "ASCII encoding, whereas the ``mbstowcs()`` function decodes from a different " "encoding (usually Latin1)." msgstr "" -#: ../../c-api/init_config.rst:1421 +#: ../../c-api/init_config.rst:1424 msgid "``\"utf-8\"`` if ``nl_langinfo(CODESET)`` returns an empty string." msgstr "" -#: ../../c-api/init_config.rst:1422 +#: ../../c-api/init_config.rst:1425 msgid "" "Otherwise, use the :term:`locale encoding`: ``nl_langinfo(CODESET)`` result." msgstr "" -#: ../../c-api/init_config.rst:1425 +#: ../../c-api/init_config.rst:1428 msgid "" "At Python startup, the encoding name is normalized to the Python codec name. " "For example, ``\"ANSI_X3.4-1968\"`` is replaced with ``\"ascii\"``." msgstr "" -#: ../../c-api/init_config.rst:1428 +#: ../../c-api/init_config.rst:1431 msgid "See also the :c:member:`~PyConfig.filesystem_errors` member." msgstr "另請參閱 :c:member:`~PyConfig.filesystem_errors` 成員。" -#: ../../c-api/init_config.rst:1432 +#: ../../c-api/init_config.rst:1435 msgid "" ":term:`Filesystem error handler `: :" "func:`sys.getfilesystemencodeerrors`." msgstr "" -#: ../../c-api/init_config.rst:1435 +#: ../../c-api/init_config.rst:1438 msgid "" "On Windows: use ``\"surrogatepass\"`` by default, or ``\"replace\"`` if :c:" "member:`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig` is " "non-zero." msgstr "" -#: ../../c-api/init_config.rst:1439 +#: ../../c-api/init_config.rst:1442 msgid "On other platforms: use ``\"surrogateescape\"`` by default." msgstr "其他平台:預設使用 ``\"surrogateescape\"``。" -#: ../../c-api/init_config.rst:1441 +#: ../../c-api/init_config.rst:1444 msgid "Supported error handlers:" msgstr "支援的錯誤處理器:" -#: ../../c-api/init_config.rst:1443 +#: ../../c-api/init_config.rst:1446 msgid "``\"strict\"``" msgstr "``\"strict\"``" -#: ../../c-api/init_config.rst:1444 +#: ../../c-api/init_config.rst:1447 msgid "``\"surrogateescape\"``" msgstr "``\"surrogateescape\"``" -#: ../../c-api/init_config.rst:1445 +#: ../../c-api/init_config.rst:1448 msgid "``\"surrogatepass\"`` (only supported with the UTF-8 encoding)" msgstr "``\"surrogatepass\"``\\ (僅支援 UTF-8 編碼)" -#: ../../c-api/init_config.rst:1447 +#: ../../c-api/init_config.rst:1450 msgid "See also the :c:member:`~PyConfig.filesystem_encoding` member." msgstr "另請參閱 :c:member:`~PyConfig.filesystem_encoding` 成員。" -#: ../../c-api/init_config.rst:1451 +#: ../../c-api/init_config.rst:1454 msgid "If non-zero, use frozen modules." msgstr "如果非零,則使用凍結模組。" -#: ../../c-api/init_config.rst:1453 +#: ../../c-api/init_config.rst:1456 msgid "Set by the :envvar:`PYTHON_FROZEN_MODULES` environment variable." msgstr "由 :envvar:`PYTHON_FROZEN_MODULES` 環境變數設定。" -#: ../../c-api/init_config.rst:1455 +#: ../../c-api/init_config.rst:1458 msgid "" "Default: ``1`` in a release build, or ``0`` in a :ref:`debug build `." msgstr "" -#: ../../c-api/init_config.rst:1461 +#: ../../c-api/init_config.rst:1464 msgid "Randomized hash function seed." msgstr "" -#: ../../c-api/init_config.rst:1463 +#: ../../c-api/init_config.rst:1466 msgid "" "If :c:member:`~PyConfig.use_hash_seed` is zero, a seed is chosen randomly at " "Python startup, and :c:member:`~PyConfig.hash_seed` is ignored." msgstr "" -#: ../../c-api/init_config.rst:1466 +#: ../../c-api/init_config.rst:1469 msgid "Set by the :envvar:`PYTHONHASHSEED` environment variable." msgstr "由 :envvar:`PYTHONHASHSEED` 環境變數設定。" -#: ../../c-api/init_config.rst:1468 +#: ../../c-api/init_config.rst:1471 msgid "" "Default *use_hash_seed* value: ``-1`` in Python mode, ``0`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:1473 +#: ../../c-api/init_config.rst:1476 msgid "" "Set the default Python \"home\" directory, that is, the location of the " "standard Python libraries (see :envvar:`PYTHONHOME`)." msgstr "" -#: ../../c-api/init_config.rst:1476 +#: ../../c-api/init_config.rst:1479 msgid "Set by the :envvar:`PYTHONHOME` environment variable." msgstr "由 :envvar:`PYTHONHOME` 環境變數設定。" -#: ../../c-api/init_config.rst:1480 ../../c-api/init_config.rst:1616 -#: ../../c-api/init_config.rst:1636 ../../c-api/init_config.rst:1725 -#: ../../c-api/init_config.rst:1756 +#: ../../c-api/init_config.rst:1483 ../../c-api/init_config.rst:1619 +#: ../../c-api/init_config.rst:1639 ../../c-api/init_config.rst:1728 +#: ../../c-api/init_config.rst:1759 msgid "Part of the :ref:`Python Path Configuration ` input." msgstr "" -#: ../../c-api/init_config.rst:1484 +#: ../../c-api/init_config.rst:1487 msgid "" "If ``1``, profile import time. If ``2``, include additional output that " "indicates when an imported module has already been loaded." msgstr "" -#: ../../c-api/init_config.rst:1488 +#: ../../c-api/init_config.rst:1491 msgid "" "Set by the :option:`-X importtime <-X>` option and the :envvar:" "`PYTHONPROFILEIMPORTTIME` environment variable." @@ -2278,15 +2277,15 @@ msgstr "" "由 :option:`-X importtime <-X>` 選項與 :envvar:`PYTHONPROFILEIMPORTTIME` 環境" "變數設定。" -#: ../../c-api/init_config.rst:1495 +#: ../../c-api/init_config.rst:1498 msgid "Added support for ``import_time = 2``" msgstr "新增對 ``import_time = 2`` 的支援" -#: ../../c-api/init_config.rst:1499 +#: ../../c-api/init_config.rst:1502 msgid "Enter interactive mode after executing a script or a command." msgstr "在執行腳本或命令後進入互動模式。" -#: ../../c-api/init_config.rst:1501 +#: ../../c-api/init_config.rst:1504 msgid "" "If greater than ``0``, enable inspect: when a script is passed as first " "argument or the -c option is used, enter interactive mode after executing " @@ -2294,30 +2293,30 @@ msgid "" "a terminal." msgstr "" -#: ../../c-api/init_config.rst:1506 +#: ../../c-api/init_config.rst:1509 msgid "" "Incremented by the :option:`-i` command line option. Set to ``1`` if the :" "envvar:`PYTHONINSPECT` environment variable is non-empty." msgstr "" -#: ../../c-api/init_config.rst:1513 +#: ../../c-api/init_config.rst:1516 msgid "Install Python signal handlers?" msgstr "" -#: ../../c-api/init_config.rst:1515 ../../c-api/init_config.rst:1699 -#: ../../c-api/init_config.rst:1723 ../../c-api/init_config.rst:1959 +#: ../../c-api/init_config.rst:1518 ../../c-api/init_config.rst:1702 +#: ../../c-api/init_config.rst:1726 ../../c-api/init_config.rst:1962 msgid "Default: ``1`` in Python mode, ``0`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:1519 +#: ../../c-api/init_config.rst:1522 msgid "If greater than ``0``, enable the interactive mode (REPL)." msgstr "" -#: ../../c-api/init_config.rst:1521 +#: ../../c-api/init_config.rst:1524 msgid "Incremented by the :option:`-i` command line option." msgstr "" -#: ../../c-api/init_config.rst:1527 +#: ../../c-api/init_config.rst:1530 msgid "" "Configures the :ref:`integer string conversion length limitation " "`. An initial value of ``-1`` means the value will be " @@ -2327,47 +2326,47 @@ msgid "" "str_digits_check_threshold`) are unsupported and will produce an error." msgstr "" -#: ../../c-api/init_config.rst:1535 +#: ../../c-api/init_config.rst:1538 msgid "" "Configured by the :option:`-X int_max_str_digits <-X>` command line flag or " "the :envvar:`PYTHONINTMAXSTRDIGITS` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1538 +#: ../../c-api/init_config.rst:1541 msgid "" "Default: ``-1`` in Python mode. 4300 (:data:`sys.int_info." "default_max_str_digits`) in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:1545 +#: ../../c-api/init_config.rst:1548 msgid "" "If the value of :c:member:`~PyConfig.cpu_count` is not ``-1`` then it will " "override the return values of :func:`os.cpu_count`, :func:`os." "process_cpu_count`, and :func:`multiprocessing.cpu_count`." msgstr "" -#: ../../c-api/init_config.rst:1549 +#: ../../c-api/init_config.rst:1552 msgid "" "Configured by the :samp:`-X cpu_count={n|default}` command line flag or the :" "envvar:`PYTHON_CPU_COUNT` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1552 ../../c-api/init_config.rst:1913 +#: ../../c-api/init_config.rst:1555 ../../c-api/init_config.rst:1916 msgid "Default: ``-1``." msgstr "預設值:``1``。" -#: ../../c-api/init_config.rst:1558 +#: ../../c-api/init_config.rst:1561 msgid "If greater than ``0``, enable isolated mode:" msgstr "" -#: ../../c-api/init_config.rst:1560 +#: ../../c-api/init_config.rst:1563 msgid "" "Set :c:member:`~PyConfig.safe_path` to ``1``: don't prepend a potentially " "unsafe path to :data:`sys.path` at Python startup, such as the current " "directory, the script's directory or an empty string." msgstr "" -#: ../../c-api/init_config.rst:1564 +#: ../../c-api/init_config.rst:1567 msgid "" "Set :c:member:`~PyConfig.use_environment` to ``0``: ignore ``PYTHON`` " "environment variables." @@ -2375,77 +2374,77 @@ msgstr "" "將 :c:member:`~PyConfig.use_environment` 設定為 ``0``:忽略 ``PYTHON`` 環境變" "數。" -#: ../../c-api/init_config.rst:1566 +#: ../../c-api/init_config.rst:1569 msgid "" "Set :c:member:`~PyConfig.user_site_directory` to ``0``: don't add the user " "site directory to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1568 +#: ../../c-api/init_config.rst:1571 msgid "" "Python REPL doesn't import :mod:`readline` nor enable default readline " "configuration on interactive prompts." msgstr "" -#: ../../c-api/init_config.rst:1571 +#: ../../c-api/init_config.rst:1574 msgid "Set to ``1`` by the :option:`-I` command line option." msgstr "" -#: ../../c-api/init_config.rst:1575 +#: ../../c-api/init_config.rst:1578 msgid "" "See also the :ref:`Isolated Configuration ` and :c:" "member:`PyPreConfig.isolated`." msgstr "" -#: ../../c-api/init_config.rst:1580 +#: ../../c-api/init_config.rst:1583 msgid "" "If non-zero, use :class:`io.FileIO` instead of :class:`!io." "_WindowsConsoleIO` for :data:`sys.stdin`, :data:`sys.stdout` and :data:`sys." "stderr`." msgstr "" -#: ../../c-api/init_config.rst:1584 +#: ../../c-api/init_config.rst:1587 msgid "" "Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSSTDIO` environment variable " "is set to a non-empty string." msgstr "" -#: ../../c-api/init_config.rst:1592 +#: ../../c-api/init_config.rst:1595 msgid "See also the :pep:`528` (Change Windows console encoding to UTF-8)." msgstr "" -#: ../../c-api/init_config.rst:1596 +#: ../../c-api/init_config.rst:1599 msgid "" "If non-zero, dump statistics on :ref:`Python pymalloc memory allocator " "` at exit." msgstr "" -#: ../../c-api/init_config.rst:1599 +#: ../../c-api/init_config.rst:1602 msgid "Set to ``1`` by the :envvar:`PYTHONMALLOCSTATS` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1601 +#: ../../c-api/init_config.rst:1604 msgid "" "The option is ignored if Python is :option:`configured using the --without-" "pymalloc option <--without-pymalloc>`." msgstr "" -#: ../../c-api/init_config.rst:1608 +#: ../../c-api/init_config.rst:1611 msgid "Platform library directory name: :data:`sys.platlibdir`." msgstr "" -#: ../../c-api/init_config.rst:1610 +#: ../../c-api/init_config.rst:1613 msgid "Set by the :envvar:`PYTHONPLATLIBDIR` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1612 +#: ../../c-api/init_config.rst:1615 msgid "" "Default: value of the ``PLATLIBDIR`` macro which is set by the :option:" "`configure --with-platlibdir option <--with-platlibdir>` (default: " "``\"lib\"``, or ``\"DLLs\"`` on Windows)." msgstr "" -#: ../../c-api/init_config.rst:1620 +#: ../../c-api/init_config.rst:1623 msgid "" "This macro is now used on Windows to locate the standard library extension " "modules, typically under ``DLLs``. However, for compatibility, note that " @@ -2453,21 +2452,21 @@ msgid "" "and virtual environments." msgstr "" -#: ../../c-api/init_config.rst:1629 +#: ../../c-api/init_config.rst:1632 msgid "" "Module search paths (:data:`sys.path`) as a string separated by ``DELIM`` (:" "data:`os.pathsep`)." msgstr "" -#: ../../c-api/init_config.rst:1632 +#: ../../c-api/init_config.rst:1635 msgid "Set by the :envvar:`PYTHONPATH` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1641 +#: ../../c-api/init_config.rst:1644 msgid "Module search paths: :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1643 +#: ../../c-api/init_config.rst:1646 msgid "" "If :c:member:`~PyConfig.module_search_paths_set` is equal to ``0``, :c:func:" "`Py_InitializeFromConfig` will replace :c:member:`~PyConfig." @@ -2475,41 +2474,41 @@ msgid "" "to ``1``." msgstr "" -#: ../../c-api/init_config.rst:1648 +#: ../../c-api/init_config.rst:1651 msgid "" "Default: empty list (``module_search_paths``) and ``0`` " "(``module_search_paths_set``)." msgstr "" -#: ../../c-api/init_config.rst:1655 +#: ../../c-api/init_config.rst:1658 msgid "Compilation optimization level:" msgstr "" -#: ../../c-api/init_config.rst:1657 +#: ../../c-api/init_config.rst:1660 msgid "``0``: Peephole optimizer, set ``__debug__`` to ``True``." msgstr "" -#: ../../c-api/init_config.rst:1658 +#: ../../c-api/init_config.rst:1661 msgid "``1``: Level 0, remove assertions, set ``__debug__`` to ``False``." msgstr "" -#: ../../c-api/init_config.rst:1659 +#: ../../c-api/init_config.rst:1662 msgid "``2``: Level 1, strip docstrings." msgstr "" -#: ../../c-api/init_config.rst:1661 +#: ../../c-api/init_config.rst:1664 msgid "" "Incremented by the :option:`-O` command line option. Set to the :envvar:" "`PYTHONOPTIMIZE` environment variable value." msgstr "" -#: ../../c-api/init_config.rst:1668 +#: ../../c-api/init_config.rst:1671 msgid "" "The list of the original command line arguments passed to the Python " "executable: :data:`sys.orig_argv`." msgstr "" -#: ../../c-api/init_config.rst:1671 +#: ../../c-api/init_config.rst:1674 msgid "" "If :c:member:`~PyConfig.orig_argv` list is empty and :c:member:`~PyConfig." "argv` is not a list only containing an empty string, :c:func:`PyConfig_Read` " @@ -2518,441 +2517,443 @@ msgid "" "parse_argv` is non-zero)." msgstr "" -#: ../../c-api/init_config.rst:1678 +#: ../../c-api/init_config.rst:1681 msgid "" "See also the :c:member:`~PyConfig.argv` member and the :c:func:" "`Py_GetArgcArgv` function." msgstr "" -#: ../../c-api/init_config.rst:1681 ../../c-api/init_config.rst:1993 -#: ../../c-api/init_config.rst:2012 +#: ../../c-api/init_config.rst:1684 ../../c-api/init_config.rst:1996 +#: ../../c-api/init_config.rst:2015 msgid "Default: empty list." msgstr "" -#: ../../c-api/init_config.rst:1687 +#: ../../c-api/init_config.rst:1690 msgid "Parse command line arguments?" msgstr "" -#: ../../c-api/init_config.rst:1689 +#: ../../c-api/init_config.rst:1692 msgid "" "If equals to ``1``, parse :c:member:`~PyConfig.argv` the same way the " "regular Python parses :ref:`command line arguments `, and " "strip Python arguments from :c:member:`~PyConfig.argv`." msgstr "" -#: ../../c-api/init_config.rst:1701 +#: ../../c-api/init_config.rst:1704 msgid "" "The :c:member:`PyConfig.argv` arguments are now only parsed if :c:member:" "`PyConfig.parse_argv` equals to ``1``." msgstr "" -#: ../../c-api/init_config.rst:1707 +#: ../../c-api/init_config.rst:1710 msgid "" "Parser debug mode. If greater than ``0``, turn on parser debugging output " "(for expert only, depending on compilation options)." msgstr "" -#: ../../c-api/init_config.rst:1710 +#: ../../c-api/init_config.rst:1713 msgid "" "Incremented by the :option:`-d` command line option. Set to the :envvar:" "`PYTHONDEBUG` environment variable value." msgstr "" -#: ../../c-api/init_config.rst:1713 ../../c-api/init_config.rst:1818 +#: ../../c-api/init_config.rst:1716 ../../c-api/init_config.rst:1821 msgid "" "Needs a :ref:`debug build of Python ` (the ``Py_DEBUG`` macro " "must be defined)." msgstr "" -#: ../../c-api/init_config.rst:1720 +#: ../../c-api/init_config.rst:1723 msgid "" "If non-zero, calculation of path configuration is allowed to log warnings " "into ``stderr``. If equals to ``0``, suppress these warnings." msgstr "" -#: ../../c-api/init_config.rst:1727 +#: ../../c-api/init_config.rst:1730 msgid "Now also applies on Windows." msgstr "現在也適用於 Windows。" -#: ../../c-api/init_config.rst:1732 +#: ../../c-api/init_config.rst:1735 msgid "" "The site-specific directory prefix where the platform independent Python " "files are installed: :data:`sys.prefix`." msgstr "" -#: ../../c-api/init_config.rst:1739 +#: ../../c-api/init_config.rst:1742 msgid "See also :c:member:`PyConfig.base_prefix`." msgstr "也請見 :c:member:`PyConfig.base_prefix`" -#: ../../c-api/init_config.rst:1743 +#: ../../c-api/init_config.rst:1746 msgid "" "Program name used to initialize :c:member:`~PyConfig.executable` and in " "early error messages during Python initialization." msgstr "" -#: ../../c-api/init_config.rst:1746 +#: ../../c-api/init_config.rst:1749 msgid "On macOS, use :envvar:`PYTHONEXECUTABLE` environment variable if set." msgstr "" -#: ../../c-api/init_config.rst:1747 +#: ../../c-api/init_config.rst:1750 msgid "" "If the ``WITH_NEXT_FRAMEWORK`` macro is defined, use ``__PYVENV_LAUNCHER__`` " "environment variable if set." msgstr "" -#: ../../c-api/init_config.rst:1749 +#: ../../c-api/init_config.rst:1752 msgid "" "Use ``argv[0]`` of :c:member:`~PyConfig.argv` if available and non-empty." msgstr "" -#: ../../c-api/init_config.rst:1751 +#: ../../c-api/init_config.rst:1754 msgid "" "Otherwise, use ``L\"python\"`` on Windows, or ``L\"python3\"`` on other " "platforms." msgstr "" -#: ../../c-api/init_config.rst:1760 +#: ../../c-api/init_config.rst:1763 msgid "" "Directory where cached ``.pyc`` files are written: :data:`sys." "pycache_prefix`." msgstr "" -#: ../../c-api/init_config.rst:1763 +#: ../../c-api/init_config.rst:1766 msgid "" "Set by the :option:`-X pycache_prefix=PATH <-X>` command line option and " "the :envvar:`PYTHONPYCACHEPREFIX` environment variable. The command-line " "option takes precedence." msgstr "" -#: ../../c-api/init_config.rst:1767 +#: ../../c-api/init_config.rst:1770 msgid "If ``NULL``, :data:`sys.pycache_prefix` is set to ``None``." msgstr "" -#: ../../c-api/init_config.rst:1773 +#: ../../c-api/init_config.rst:1776 msgid "" "Quiet mode. If greater than ``0``, don't display the copyright and version " "at Python startup in interactive mode." msgstr "" -#: ../../c-api/init_config.rst:1776 +#: ../../c-api/init_config.rst:1779 msgid "Incremented by the :option:`-q` command line option." msgstr "" -#: ../../c-api/init_config.rst:1782 +#: ../../c-api/init_config.rst:1785 msgid "Value of the :option:`-c` command line option." msgstr "" -#: ../../c-api/init_config.rst:1784 ../../c-api/init_config.rst:1805 +#: ../../c-api/init_config.rst:1787 ../../c-api/init_config.rst:1808 msgid "Used by :c:func:`Py_RunMain`." msgstr "被 :c:func:`Py_RunMain` 使用。" -#: ../../c-api/init_config.rst:1790 +#: ../../c-api/init_config.rst:1793 msgid "" "Filename passed on the command line: trailing command line argument without :" "option:`-c` or :option:`-m`. It is used by the :c:func:`Py_RunMain` function." msgstr "" -#: ../../c-api/init_config.rst:1794 +#: ../../c-api/init_config.rst:1797 msgid "" "For example, it is set to ``script.py`` by the ``python3 script.py arg`` " "command line." msgstr "" -#: ../../c-api/init_config.rst:1797 +#: ../../c-api/init_config.rst:1800 msgid "See also the :c:member:`PyConfig.skip_source_first_line` option." msgstr "也請見 :c:member:`PyConfig.skip_source_first_line` 選項。" -#: ../../c-api/init_config.rst:1803 +#: ../../c-api/init_config.rst:1806 msgid "Value of the :option:`-m` command line option." msgstr "" -#: ../../c-api/init_config.rst:1811 +#: ../../c-api/init_config.rst:1814 msgid "" -"``package.module`` path to module that should be imported before ``site.py`` " -"is run." +"``module`` or ``module:func`` entry point that should be executed before " +"the :mod:`site` module is imported." msgstr "" -#: ../../c-api/init_config.rst:1814 +#: ../../c-api/init_config.rst:1817 msgid "" -"Set by the :option:`-X presite=package.module <-X>` command-line option and " +"Set by the :option:`-X presite=module:func <-X>` command-line option and " "the :envvar:`PYTHON_PRESITE` environment variable. The command-line option " "takes precedence." msgstr "" +"由 :option:`-X presite=module:func <-X>` 命令列選項" +"與 :envvar:`PYTHON_PRESITE` 環境變數設定。命令列選項優先。" -#: ../../c-api/init_config.rst:1825 +#: ../../c-api/init_config.rst:1828 msgid "" "Show total reference count at exit (excluding :term:`immortal` objects)?" msgstr "" -#: ../../c-api/init_config.rst:1827 +#: ../../c-api/init_config.rst:1830 msgid "Set to ``1`` by :option:`-X showrefcount <-X>` command line option." msgstr "" -#: ../../c-api/init_config.rst:1829 +#: ../../c-api/init_config.rst:1832 msgid "" "Needs a :ref:`debug build of Python ` (the ``Py_REF_DEBUG`` " "macro must be defined)." msgstr "" -#: ../../c-api/init_config.rst:1836 +#: ../../c-api/init_config.rst:1839 msgid "Import the :mod:`site` module at startup?" msgstr "" -#: ../../c-api/init_config.rst:1838 +#: ../../c-api/init_config.rst:1841 msgid "" "If equal to zero, disable the import of the module site and the site-" "dependent manipulations of :data:`sys.path` that it entails." msgstr "" -#: ../../c-api/init_config.rst:1841 +#: ../../c-api/init_config.rst:1844 msgid "" "Also disable these manipulations if the :mod:`site` module is explicitly " "imported later (call :func:`site.main` if you want them to be triggered)." msgstr "" -#: ../../c-api/init_config.rst:1844 +#: ../../c-api/init_config.rst:1847 msgid "Set to ``0`` by the :option:`-S` command line option." msgstr "" -#: ../../c-api/init_config.rst:1846 +#: ../../c-api/init_config.rst:1849 msgid "" ":data:`sys.flags.no_site ` is set to the inverted value of :c:" "member:`~PyConfig.site_import`." msgstr "" -#: ../../c-api/init_config.rst:1853 +#: ../../c-api/init_config.rst:1856 msgid "" "If non-zero, skip the first line of the :c:member:`PyConfig.run_filename` " "source." msgstr "" -#: ../../c-api/init_config.rst:1856 +#: ../../c-api/init_config.rst:1859 msgid "" "It allows the usage of non-Unix forms of ``#!cmd``. This is intended for a " "DOS specific hack only." msgstr "" -#: ../../c-api/init_config.rst:1859 +#: ../../c-api/init_config.rst:1862 msgid "Set to ``1`` by the :option:`-x` command line option." msgstr "" -#: ../../c-api/init_config.rst:1866 +#: ../../c-api/init_config.rst:1869 msgid "" "Encoding and encoding errors of :data:`sys.stdin`, :data:`sys.stdout` and :" "data:`sys.stderr` (but :data:`sys.stderr` always uses " "``\"backslashreplace\"`` error handler)." msgstr "" -#: ../../c-api/init_config.rst:1870 +#: ../../c-api/init_config.rst:1873 msgid "" "Use the :envvar:`PYTHONIOENCODING` environment variable if it is non-empty." msgstr "" -#: ../../c-api/init_config.rst:1873 +#: ../../c-api/init_config.rst:1876 msgid "Default encoding:" msgstr "預設編碼:" -#: ../../c-api/init_config.rst:1875 +#: ../../c-api/init_config.rst:1878 msgid "``\"UTF-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." msgstr "如果 :c:member:`PyPreConfig.utf8_mode` 非零,則為 ``\"UTF-8\"``。" -#: ../../c-api/init_config.rst:1876 +#: ../../c-api/init_config.rst:1879 msgid "Otherwise, use the :term:`locale encoding`." msgstr "否則使用 :term:`locale encoding`。" -#: ../../c-api/init_config.rst:1878 +#: ../../c-api/init_config.rst:1881 msgid "Default error handler:" msgstr "" -#: ../../c-api/init_config.rst:1880 +#: ../../c-api/init_config.rst:1883 msgid "On Windows: use ``\"surrogateescape\"``." msgstr "在 Windows 上:使用 ``\"surrogateescape\"``。" -#: ../../c-api/init_config.rst:1881 +#: ../../c-api/init_config.rst:1884 msgid "" "``\"surrogateescape\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero, or " "if the LC_CTYPE locale is \"C\" or \"POSIX\"." msgstr "" -#: ../../c-api/init_config.rst:1883 +#: ../../c-api/init_config.rst:1886 msgid "``\"strict\"`` otherwise." msgstr "" -#: ../../c-api/init_config.rst:1885 +#: ../../c-api/init_config.rst:1888 msgid "See also :c:member:`PyConfig.legacy_windows_stdio`." msgstr "也請見 :c:member:`PyConfig.legacy_windows_stdio`。" -#: ../../c-api/init_config.rst:1889 +#: ../../c-api/init_config.rst:1892 msgid "Enable tracemalloc?" msgstr "" -#: ../../c-api/init_config.rst:1891 +#: ../../c-api/init_config.rst:1894 msgid "If non-zero, call :func:`tracemalloc.start` at startup." msgstr "" -#: ../../c-api/init_config.rst:1893 +#: ../../c-api/init_config.rst:1896 msgid "" "Set by :option:`-X tracemalloc=N <-X>` command line option and by the :" "envvar:`PYTHONTRACEMALLOC` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1900 +#: ../../c-api/init_config.rst:1903 msgid "Enable the Linux ``perf`` profiler support?" msgstr "要啟用 Linux ``perf`` 分析器支援嗎?" -#: ../../c-api/init_config.rst:1902 +#: ../../c-api/init_config.rst:1905 msgid "If equals to ``1``, enable support for the Linux ``perf`` profiler." msgstr "如果等於 ``1``,則啟用對 Linux ``perf`` 分析器的支援。" -#: ../../c-api/init_config.rst:1904 +#: ../../c-api/init_config.rst:1907 msgid "" "If equals to ``2``, enable support for the Linux ``perf`` profiler with " "DWARF JIT support." msgstr "" "如果等於 ``2``,則啟用有 DWARF JIT 支援的 Linux ``perf`` 分析器的支援。" -#: ../../c-api/init_config.rst:1907 +#: ../../c-api/init_config.rst:1910 msgid "" "Set to ``1`` by :option:`-X perf <-X>` command-line option and the :envvar:" "`PYTHONPERFSUPPORT` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1910 +#: ../../c-api/init_config.rst:1913 msgid "" "Set to ``2`` by the :option:`-X perf_jit <-X>` command-line option and the :" "envvar:`PYTHON_PERF_JIT_SUPPORT` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1916 +#: ../../c-api/init_config.rst:1919 msgid "See :ref:`perf_profiling` for more information." msgstr "更多資訊請參見 :ref:`perf_profiling`。" -#: ../../c-api/init_config.rst:1922 +#: ../../c-api/init_config.rst:1925 msgid "Directory of the Python standard library." msgstr "" -#: ../../c-api/init_config.rst:1930 +#: ../../c-api/init_config.rst:1933 msgid "Use :ref:`environment variables `?" msgstr "" -#: ../../c-api/init_config.rst:1932 +#: ../../c-api/init_config.rst:1935 msgid "" "If equals to zero, ignore the :ref:`environment variables `." msgstr "" -#: ../../c-api/init_config.rst:1935 +#: ../../c-api/init_config.rst:1938 msgid "Set to ``0`` by the :option:`-E` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1941 +#: ../../c-api/init_config.rst:1944 msgid "" "If non-zero, ``stdout`` and ``stderr`` will be redirected to the system log." msgstr "" -#: ../../c-api/init_config.rst:1944 +#: ../../c-api/init_config.rst:1947 msgid "Only available on macOS 10.12 and later, and on iOS." msgstr "" -#: ../../c-api/init_config.rst:1946 +#: ../../c-api/init_config.rst:1949 msgid "" "Default: ``0`` (don't use the system log) on macOS; ``1`` on iOS (use the " "system log)." msgstr "" -#: ../../c-api/init_config.rst:1953 +#: ../../c-api/init_config.rst:1956 msgid "If non-zero, add the user site directory to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1955 +#: ../../c-api/init_config.rst:1958 msgid "Set to ``0`` by the :option:`-s` and :option:`-I` command line options." msgstr "" -#: ../../c-api/init_config.rst:1957 +#: ../../c-api/init_config.rst:1960 msgid "Set to ``0`` by the :envvar:`PYTHONNOUSERSITE` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1963 +#: ../../c-api/init_config.rst:1966 msgid "" "Verbose mode. If greater than ``0``, print a message each time a module is " "imported, showing the place (filename or built-in module) from which it is " "loaded." msgstr "" -#: ../../c-api/init_config.rst:1967 +#: ../../c-api/init_config.rst:1970 msgid "" "If greater than or equal to ``2``, print a message for each file that is " "checked for when searching for a module. Also provides information on module " "cleanup at exit." msgstr "" -#: ../../c-api/init_config.rst:1971 +#: ../../c-api/init_config.rst:1974 msgid "Incremented by the :option:`-v` command line option." msgstr "" -#: ../../c-api/init_config.rst:1973 +#: ../../c-api/init_config.rst:1976 msgid "Set by the :envvar:`PYTHONVERBOSE` environment variable value." msgstr "" -#: ../../c-api/init_config.rst:1979 +#: ../../c-api/init_config.rst:1982 msgid "" "Options of the :mod:`warnings` module to build warnings filters, lowest to " "highest priority: :data:`sys.warnoptions`." msgstr "" -#: ../../c-api/init_config.rst:1982 +#: ../../c-api/init_config.rst:1985 msgid "" "The :mod:`warnings` module adds :data:`sys.warnoptions` in the reverse " "order: the last :c:member:`PyConfig.warnoptions` item becomes the first item " "of ``warnings.filters`` which is checked first (highest priority)." msgstr "" -#: ../../c-api/init_config.rst:1986 +#: ../../c-api/init_config.rst:1989 msgid "" "The :option:`-W` command line options adds its value to :c:member:`~PyConfig." "warnoptions`, it can be used multiple times." msgstr "" -#: ../../c-api/init_config.rst:1989 +#: ../../c-api/init_config.rst:1992 msgid "" "The :envvar:`PYTHONWARNINGS` environment variable can also be used to add " "warning options. Multiple options can be specified, separated by commas (``," "``)." msgstr "" -#: ../../c-api/init_config.rst:1997 +#: ../../c-api/init_config.rst:2000 msgid "" "If equal to ``0``, Python won't try to write ``.pyc`` files on the import of " "source modules." msgstr "" -#: ../../c-api/init_config.rst:2000 +#: ../../c-api/init_config.rst:2003 msgid "" "Set to ``0`` by the :option:`-B` command line option and the :envvar:" "`PYTHONDONTWRITEBYTECODE` environment variable." msgstr "" -#: ../../c-api/init_config.rst:2003 +#: ../../c-api/init_config.rst:2006 msgid "" ":data:`sys.dont_write_bytecode` is initialized to the inverted value of :c:" "member:`~PyConfig.write_bytecode`." msgstr "" -#: ../../c-api/init_config.rst:2010 +#: ../../c-api/init_config.rst:2013 msgid "Values of the :option:`-X` command line options: :data:`sys._xoptions`." msgstr "" -#: ../../c-api/init_config.rst:2016 +#: ../../c-api/init_config.rst:2019 msgid "If non-zero, write performance statistics at Python exit." msgstr "" -#: ../../c-api/init_config.rst:2018 +#: ../../c-api/init_config.rst:2021 msgid "" "Need a special build with the ``Py_STATS`` macro: see :option:`--enable-" "pystats`." msgstr "" -#: ../../c-api/init_config.rst:2023 +#: ../../c-api/init_config.rst:2026 msgid "" "If :c:member:`~PyConfig.parse_argv` is non-zero, :c:member:`~PyConfig.argv` " "arguments are parsed the same way the regular Python parses :ref:`command " @@ -2960,27 +2961,27 @@ msgid "" "c:member:`~PyConfig.argv`." msgstr "" -#: ../../c-api/init_config.rst:2028 +#: ../../c-api/init_config.rst:2031 msgid "" "The :c:member:`~PyConfig.xoptions` options are parsed to set other options: " "see the :option:`-X` command line option." msgstr "" -#: ../../c-api/init_config.rst:2033 +#: ../../c-api/init_config.rst:2036 msgid "The ``show_alloc_count`` field has been removed." msgstr "" -#: ../../c-api/init_config.rst:2039 +#: ../../c-api/init_config.rst:2042 msgid "Initialization with PyConfig" msgstr "" -#: ../../c-api/init_config.rst:2041 +#: ../../c-api/init_config.rst:2044 msgid "" "Initializing the interpreter from a populated configuration struct is " "handled by calling :c:func:`Py_InitializeFromConfig`." msgstr "" -#: ../../c-api/init_config.rst:2047 +#: ../../c-api/init_config.rst:2050 msgid "" "If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` or :c:" "func:`PyImport_ExtendInittab` are used, they must be set or called after " @@ -2989,17 +2990,17 @@ msgid "" "`PyImport_ExtendInittab` must be called before each Python initialization." msgstr "" -#: ../../c-api/init_config.rst:2054 +#: ../../c-api/init_config.rst:2057 msgid "" "The current configuration (``PyConfig`` type) is stored in " "``PyInterpreterState.config``." msgstr "" -#: ../../c-api/init_config.rst:2057 +#: ../../c-api/init_config.rst:2060 msgid "Example setting the program name::" msgstr "" -#: ../../c-api/init_config.rst:2059 +#: ../../c-api/init_config.rst:2062 msgid "" "void init_python(void)\n" "{\n" @@ -3053,7 +3054,7 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../c-api/init_config.rst:2085 +#: ../../c-api/init_config.rst:2088 msgid "" "More complete example modifying the default configuration, read the " "configuration, and then override some parameters. Note that since 3.11, many " @@ -3062,7 +3063,7 @@ msgid "" "called will be left unchanged by initialization::" msgstr "" -#: ../../c-api/init_config.rst:2092 +#: ../../c-api/init_config.rst:2095 msgid "" "PyStatus init_python(const char *program_name)\n" "{\n" @@ -3089,7 +3090,7 @@ msgid "" "\n" " /* Specify sys.path explicitly */\n" " /* If you want to modify the default set of paths, finish\n" -" initialization first and then use PySys_GetObject(\"path\") */\n" +" initialization first and then use PySys_GetAttrString(\"path\") */\n" " config.module_search_paths_set = 1;\n" " status = PyWideStringList_Append(&config.module_search_paths,\n" " L\"/path/to/stdlib\");\n" @@ -3116,19 +3117,70 @@ msgid "" " return status;\n" "}" msgstr "" +"PyStatus init_python(const char *program_name)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +"\n" +" /* 在讀取設定之前設定程式名稱\n" +" (以地區設定編碼解碼位元組字串)。\n" +"\n" +" 隱式地預初始化 Python。 */\n" +" status = PyConfig_SetBytesString(&config, &config.program_name,\n" +" program_name);\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +"\n" +" /* 一次讀取所有設定 */\n" +" status = PyConfig_Read(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +"\n" +" /* 明確指定 sys.path */\n" +" /* 如果你想修改預設的路徑集合,請先完成\n" +" 初始化,然後再使用 PySys_GetAttrString(\"path\") */\n" +" config.module_search_paths_set = 1;\n" +" status = PyWideStringList_Append(&config.module_search_paths,\n" +" L\"/path/to/stdlib\");\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +" status = PyWideStringList_Append(&config.module_search_paths,\n" +" L\"/path/to/more/modules\");\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +"\n" +" /* 覆寫由 PyConfig_Read() 計算出的 executable */\n" +" status = PyConfig_SetString(&config, &config.executable,\n" +" L\"/path/to/my_executable\");\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +"\n" +"done:\n" +" PyConfig_Clear(&config);\n" +" return status;\n" +"}" -#: ../../c-api/init_config.rst:2148 +#: ../../c-api/init_config.rst:2151 msgid "Isolated Configuration" msgstr "" -#: ../../c-api/init_config.rst:2150 +#: ../../c-api/init_config.rst:2153 msgid "" ":c:func:`PyPreConfig_InitIsolatedConfig` and :c:func:" "`PyConfig_InitIsolatedConfig` functions create a configuration to isolate " "Python from the system. For example, to embed Python into an application." msgstr "" -#: ../../c-api/init_config.rst:2155 +#: ../../c-api/init_config.rst:2158 msgid "" "This configuration ignores global configuration variables, environment " "variables, command line arguments (:c:member:`PyConfig.argv` is not parsed) " @@ -3136,115 +3188,115 @@ msgid "" "LC_CTYPE locale are left unchanged. Signal handlers are not installed." msgstr "" -#: ../../c-api/init_config.rst:2160 +#: ../../c-api/init_config.rst:2163 msgid "" "Configuration files are still used with this configuration to determine " "paths that are unspecified. Ensure :c:member:`PyConfig.home` is specified to " "avoid computing the default path configuration." msgstr "" -#: ../../c-api/init_config.rst:2168 +#: ../../c-api/init_config.rst:2171 msgid "Python Configuration" msgstr "" -#: ../../c-api/init_config.rst:2170 +#: ../../c-api/init_config.rst:2173 msgid "" ":c:func:`PyPreConfig_InitPythonConfig` and :c:func:" "`PyConfig_InitPythonConfig` functions create a configuration to build a " "customized Python which behaves as the regular Python." msgstr "" -#: ../../c-api/init_config.rst:2174 +#: ../../c-api/init_config.rst:2177 msgid "" "Environments variables and command line arguments are used to configure " "Python, whereas global configuration variables are ignored." msgstr "" -#: ../../c-api/init_config.rst:2177 +#: ../../c-api/init_config.rst:2180 msgid "" "This function enables C locale coercion (:pep:`538`) and :ref:`Python UTF-8 " "Mode ` (:pep:`540`) depending on the LC_CTYPE locale, :envvar:" "`PYTHONUTF8` and :envvar:`PYTHONCOERCECLOCALE` environment variables." msgstr "" -#: ../../c-api/init_config.rst:2186 +#: ../../c-api/init_config.rst:2189 msgid "Python Path Configuration" msgstr "Python 路徑配置" -#: ../../c-api/init_config.rst:2188 +#: ../../c-api/init_config.rst:2191 msgid ":c:type:`PyConfig` contains multiple fields for the path configuration:" msgstr "" -#: ../../c-api/init_config.rst:2190 +#: ../../c-api/init_config.rst:2193 msgid "Path configuration inputs:" msgstr "" -#: ../../c-api/init_config.rst:2192 +#: ../../c-api/init_config.rst:2195 msgid ":c:member:`PyConfig.home`" msgstr ":c:member:`PyConfig.home`" -#: ../../c-api/init_config.rst:2193 +#: ../../c-api/init_config.rst:2196 msgid ":c:member:`PyConfig.platlibdir`" msgstr ":c:member:`PyConfig.platlibdir`" -#: ../../c-api/init_config.rst:2194 +#: ../../c-api/init_config.rst:2197 msgid ":c:member:`PyConfig.pathconfig_warnings`" msgstr ":c:member:`PyConfig.pathconfig_warnings`" -#: ../../c-api/init_config.rst:2195 +#: ../../c-api/init_config.rst:2198 msgid ":c:member:`PyConfig.program_name`" msgstr ":c:member:`PyConfig.program_name`" -#: ../../c-api/init_config.rst:2196 +#: ../../c-api/init_config.rst:2199 msgid ":c:member:`PyConfig.pythonpath_env`" msgstr ":c:member:`PyConfig.pythonpath_env`" -#: ../../c-api/init_config.rst:2197 +#: ../../c-api/init_config.rst:2200 msgid "current working directory: to get absolute paths" msgstr "" -#: ../../c-api/init_config.rst:2198 +#: ../../c-api/init_config.rst:2201 msgid "" "``PATH`` environment variable to get the program full path (from :c:member:" "`PyConfig.program_name`)" msgstr "" -#: ../../c-api/init_config.rst:2200 +#: ../../c-api/init_config.rst:2203 msgid "``__PYVENV_LAUNCHER__`` environment variable" msgstr "``__PYVENV_LAUNCHER__`` 環境變數" -#: ../../c-api/init_config.rst:2201 +#: ../../c-api/init_config.rst:2204 msgid "" "(Windows only) Application paths in the registry under " "\"Software\\Python\\PythonCore\\X.Y\\PythonPath\" of HKEY_CURRENT_USER and " "HKEY_LOCAL_MACHINE (where X.Y is the Python version)." msgstr "" -#: ../../c-api/init_config.rst:2205 +#: ../../c-api/init_config.rst:2208 msgid "Path configuration output fields:" msgstr "" -#: ../../c-api/init_config.rst:2207 +#: ../../c-api/init_config.rst:2210 msgid ":c:member:`PyConfig.base_exec_prefix`" msgstr ":c:member:`PyConfig.base_exec_prefix`" -#: ../../c-api/init_config.rst:2208 +#: ../../c-api/init_config.rst:2211 msgid ":c:member:`PyConfig.base_executable`" msgstr ":c:member:`PyConfig.base_executable`" -#: ../../c-api/init_config.rst:2209 +#: ../../c-api/init_config.rst:2212 msgid ":c:member:`PyConfig.base_prefix`" msgstr ":c:member:`PyConfig.base_prefix`" -#: ../../c-api/init_config.rst:2210 +#: ../../c-api/init_config.rst:2213 msgid ":c:member:`PyConfig.exec_prefix`" msgstr ":c:member:`PyConfig.exec_prefix`" -#: ../../c-api/init_config.rst:2211 +#: ../../c-api/init_config.rst:2214 msgid ":c:member:`PyConfig.executable`" msgstr ":c:member:`PyConfig.executable`" -#: ../../c-api/init_config.rst:2212 +#: ../../c-api/init_config.rst:2215 msgid "" ":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig." "module_search_paths`" @@ -3252,11 +3304,11 @@ msgstr "" ":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig." "module_search_paths`" -#: ../../c-api/init_config.rst:2214 +#: ../../c-api/init_config.rst:2217 msgid ":c:member:`PyConfig.prefix`" msgstr ":c:member:`PyConfig.prefix`" -#: ../../c-api/init_config.rst:2216 +#: ../../c-api/init_config.rst:2219 msgid "" "If at least one \"output field\" is not set, Python calculates the path " "configuration to fill unset fields. If :c:member:`~PyConfig." @@ -3265,7 +3317,7 @@ msgid "" "module_search_paths_set` is set to ``1``." msgstr "" -#: ../../c-api/init_config.rst:2222 +#: ../../c-api/init_config.rst:2225 msgid "" "It is possible to completely ignore the function calculating the default " "path configuration by setting explicitly all path configuration output " @@ -3275,52 +3327,52 @@ msgid "" "modification." msgstr "" -#: ../../c-api/init_config.rst:2229 +#: ../../c-api/init_config.rst:2232 msgid "" "Set :c:member:`~PyConfig.pathconfig_warnings` to ``0`` to suppress warnings " "when calculating the path configuration (Unix only, Windows does not log any " "warning)." msgstr "" -#: ../../c-api/init_config.rst:2232 +#: ../../c-api/init_config.rst:2235 msgid "" "If :c:member:`~PyConfig.base_prefix` or :c:member:`~PyConfig." "base_exec_prefix` fields are not set, they inherit their value from :c:" "member:`~PyConfig.prefix` and :c:member:`~PyConfig.exec_prefix` respectively." msgstr "" -#: ../../c-api/init_config.rst:2236 +#: ../../c-api/init_config.rst:2239 msgid ":c:func:`Py_RunMain` and :c:func:`Py_Main` modify :data:`sys.path`:" msgstr ":c:func:`Py_RunMain` 和 :c:func:`Py_Main` 會修改 :data:`sys.path`:" -#: ../../c-api/init_config.rst:2238 +#: ../../c-api/init_config.rst:2241 msgid "" "If :c:member:`~PyConfig.run_filename` is set and is a directory which " "contains a ``__main__.py`` script, prepend :c:member:`~PyConfig." "run_filename` to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:2241 +#: ../../c-api/init_config.rst:2244 msgid "If :c:member:`~PyConfig.isolated` is zero:" msgstr "如果 :c:member:`~PyConfig.isolated` 為零:" -#: ../../c-api/init_config.rst:2243 +#: ../../c-api/init_config.rst:2246 msgid "" "If :c:member:`~PyConfig.run_module` is set, prepend the current directory " "to :data:`sys.path`. Do nothing if the current directory cannot be read." msgstr "" -#: ../../c-api/init_config.rst:2245 +#: ../../c-api/init_config.rst:2248 msgid "" "If :c:member:`~PyConfig.run_filename` is set, prepend the directory of the " "filename to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:2247 +#: ../../c-api/init_config.rst:2250 msgid "Otherwise, prepend an empty string to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:2249 +#: ../../c-api/init_config.rst:2252 msgid "" "If :c:member:`~PyConfig.site_import` is non-zero, :data:`sys.path` can be " "modified by the :mod:`site` module. If :c:member:`~PyConfig." @@ -3329,43 +3381,48 @@ msgid "" "data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:2255 +#: ../../c-api/init_config.rst:2258 msgid "The following configuration files are used by the path configuration:" msgstr "" -#: ../../c-api/init_config.rst:2257 +#: ../../c-api/init_config.rst:2260 msgid "``pyvenv.cfg``" msgstr "``pyvenv.cfg``" -#: ../../c-api/init_config.rst:2258 +#: ../../c-api/init_config.rst:2261 msgid "``._pth`` file (ex: ``python._pth``)" msgstr "" -#: ../../c-api/init_config.rst:2259 +#: ../../c-api/init_config.rst:2262 msgid "``pybuilddir.txt`` (Unix only)" msgstr "``pybuilddir.txt``\\ (僅限 Unix)" -#: ../../c-api/init_config.rst:2261 +#: ../../c-api/init_config.rst:2264 msgid "If a ``._pth`` file is present:" msgstr "" -#: ../../c-api/init_config.rst:2263 +#: ../../c-api/init_config.rst:2266 msgid "Set :c:member:`~PyConfig.isolated` to ``1``." msgstr "將 :c:member:`~PyConfig.isolated` 設定為 ``1``。" -#: ../../c-api/init_config.rst:2264 +#: ../../c-api/init_config.rst:2267 msgid "Set :c:member:`~PyConfig.use_environment` to ``0``." msgstr "將 :c:member:`~PyConfig.use_environment` 設定為 ``0``。" -#: ../../c-api/init_config.rst:2265 +#: ../../c-api/init_config.rst:2268 msgid "Set :c:member:`~PyConfig.site_import` to ``0``." msgstr "將 :c:member:`~PyConfig.site_import` 設定為 ``0``。" -#: ../../c-api/init_config.rst:2266 +#: ../../c-api/init_config.rst:2269 +msgid "Set :c:member:`~PyConfig.user_site_directory` to ``0`` (since 3.15)." +msgstr "" +"將 :c:member:`~PyConfig.user_site_directory` 設定為 ``0``\\ (自 3.15 起)。" + +#: ../../c-api/init_config.rst:2270 msgid "Set :c:member:`~PyConfig.safe_path` to ``1``." msgstr "將 :c:member:`~PyConfig.safe_path` 設定為 ``1``。" -#: ../../c-api/init_config.rst:2268 +#: ../../c-api/init_config.rst:2272 msgid "" "If :c:member:`~PyConfig.home` is not set and a ``pyvenv.cfg`` file is " "present in the same directory as :c:member:`~PyConfig.executable`, or its " @@ -3376,53 +3433,223 @@ msgid "" "more information." msgstr "" -#: ../../c-api/init_config.rst:2276 +#: ../../c-api/init_config.rst:2280 msgid "" "The ``__PYVENV_LAUNCHER__`` environment variable is used to set :c:member:" "`PyConfig.base_executable`." msgstr "" -#: ../../c-api/init_config.rst:2281 +#: ../../c-api/init_config.rst:2285 msgid "" ":c:member:`~PyConfig.prefix`, and :c:member:`~PyConfig.exec_prefix`, are now " "set to the ``pyvenv.cfg`` directory. This was previously done by :mod:" "`site`, therefore affected by :option:`-S`." msgstr "" -#: ../../c-api/init_config.rst:2287 +#: ../../c-api/init_config.rst:2292 +msgid "" +":c:member:`~PyConfig.user_site_directory` is now set to ``0`` when a ``." +"_pth`` file is present." +msgstr "" + +#: ../../c-api/init_config.rst:2297 msgid "Py_GetArgcArgv()" msgstr "Py_GetArgcArgv()" -#: ../../c-api/init_config.rst:2291 +#: ../../c-api/init_config.rst:2301 msgid "Get the original command line arguments, before Python modified them." msgstr "" -#: ../../c-api/init_config.rst:2293 +#: ../../c-api/init_config.rst:2303 msgid "See also :c:member:`PyConfig.orig_argv` member." msgstr "也請參與 :c:member:`PyConfig.orig_argv` 成員。" -#: ../../c-api/init_config.rst:2296 -msgid "Delaying main module execution" +#: ../../c-api/init_config.rst:2307 +msgid "Multi-Phase Initialization Private Provisional API" msgstr "" -#: ../../c-api/init_config.rst:2298 +#: ../../c-api/init_config.rst:2309 msgid "" -"In some embedding use cases, it may be desirable to separate interpreter " -"initialization from the execution of the main module." +"This section is a private provisional API introducing multi-phase " +"initialization, the core feature of :pep:`432`:" msgstr "" -#: ../../c-api/init_config.rst:2301 +#: ../../c-api/init_config.rst:2312 +msgid "\"Core\" initialization phase, \"bare minimum Python\":" +msgstr "" + +#: ../../c-api/init_config.rst:2314 +msgid "Builtin types;" +msgstr "" + +#: ../../c-api/init_config.rst:2315 +msgid "Builtin exceptions;" +msgstr "" + +#: ../../c-api/init_config.rst:2316 +msgid "Builtin and frozen modules;" +msgstr "" + +#: ../../c-api/init_config.rst:2317 +msgid "" +"The :mod:`sys` module is only partially initialized (ex: :data:`sys.path` " +"doesn't exist yet)." +msgstr "" + +#: ../../c-api/init_config.rst:2320 +msgid "\"Main\" initialization phase, Python is fully initialized:" +msgstr "" + +#: ../../c-api/init_config.rst:2322 +msgid "Install and configure :mod:`importlib`;" +msgstr "" + +#: ../../c-api/init_config.rst:2323 +msgid "Apply the :ref:`Path Configuration `;" +msgstr "" + +#: ../../c-api/init_config.rst:2324 +msgid "Install signal handlers;" +msgstr "安裝訊號處理程式;" + +#: ../../c-api/init_config.rst:2325 +msgid "" +"Finish :mod:`sys` module initialization (ex: create :data:`sys.stdout` and :" +"data:`sys.path`);" +msgstr "" + +#: ../../c-api/init_config.rst:2327 +msgid "" +"Enable optional features like :mod:`faulthandler` and :mod:`tracemalloc`;" +msgstr "" + +#: ../../c-api/init_config.rst:2328 +msgid "Import the :mod:`site` module;" +msgstr "" + +#: ../../c-api/init_config.rst:2329 +msgid "etc." +msgstr "" + +#: ../../c-api/init_config.rst:2331 +msgid "Private provisional API:" +msgstr "" + +#: ../../c-api/init_config.rst:2335 msgid "" -"This separation can be achieved by setting ``PyConfig.run_command`` to the " -"empty string during initialization (to prevent the interpreter from dropping " -"into the interactive prompt), and then subsequently executing the desired " -"main module code using ``__main__.__dict__`` as the global namespace." +"If set to ``0``, :c:func:`Py_InitializeFromConfig` stops at the \"Core\" " +"initialization phase." +msgstr "" + +#: ../../c-api/init_config.rst:2340 +msgid "" +"Move to the \"Main\" initialization phase, finish the Python initialization." +msgstr "" + +#: ../../c-api/init_config.rst:2342 +msgid "" +"No module is imported during the \"Core\" phase and the ``importlib`` module " +"is not configured: the :ref:`Path Configuration ` is only " +"applied during the \"Main\" phase. It may allow to customize Python in " +"Python to override or tune the :ref:`Path Configuration `, " +"maybe install a custom :data:`sys.meta_path` importer or an import hook, etc." +msgstr "" + +#: ../../c-api/init_config.rst:2348 +msgid "" +"It may become possible to calculate the :ref:`Path Configuration ` in Python, after the Core phase and before the Main phase, which is " +"one of the :pep:`432` motivation." +msgstr "" + +#: ../../c-api/init_config.rst:2352 +msgid "" +"The \"Core\" phase is not properly defined: what should be and what should " +"not be available at this phase is not specified yet. The API is marked as " +"private and provisional: the API can be modified or even be removed anytime " +"until a proper public API is designed." +msgstr "" + +#: ../../c-api/init_config.rst:2357 +msgid "" +"Example running Python code between \"Core\" and \"Main\" initialization " +"phases::" +msgstr "" + +#: ../../c-api/init_config.rst:2360 +msgid "" +"void init_python(void)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +" config._init_main = 0;\n" +"\n" +" /* ... customize 'config' configuration ... */\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" PyConfig_Clear(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +" }\n" +"\n" +" /* Use sys.stderr because sys.stdout is only created\n" +" by _Py_InitializeMain() */\n" +" int res = PyRun_SimpleString(\n" +" \"import sys; \"\n" +" \"print('Run Python code before _Py_InitializeMain', \"\n" +" \"file=sys.stderr)\");\n" +" if (res < 0) {\n" +" exit(1);\n" +" }\n" +"\n" +" /* ... put more configuration code here ... */\n" +"\n" +" status = _Py_InitializeMain();\n" +" if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +" }\n" +"}" msgstr "" +"void init_python(void)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +" config._init_main = 0;\n" +"\n" +" /* ... 自訂 'config' 設定 ... */\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" PyConfig_Clear(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +" }\n" +"\n" +" /* 使用 sys.stderr,因為 sys.stdout 只會\n" +" 由 _Py_InitializeMain() 建立 */\n" +" int res = PyRun_SimpleString(\n" +" \"import sys; \"\n" +" \"print('Run Python code before _Py_InitializeMain', \"\n" +" \"file=sys.stderr)\");\n" +" if (res < 0) {\n" +" exit(1);\n" +" }\n" +"\n" +" /* ... 在此放入更多設定程式碼 ... */\n" +"\n" +" status = _Py_InitializeMain();\n" +" if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +" }\n" +"}" -#: ../../c-api/init_config.rst:1185 +#: ../../c-api/init_config.rst:1183 msgid "main()" msgstr "main()" -#: ../../c-api/init_config.rst:1185 +#: ../../c-api/init_config.rst:1183 msgid "argv (in module sys)" msgstr "" diff --git a/c-api/interp-lifecycle.po b/c-api/interp-lifecycle.po index 461fff3d79b..937144e8bc9 100644 --- a/c-api/interp-lifecycle.po +++ b/c-api/interp-lifecycle.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-26 18:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -599,13 +599,20 @@ msgid "" "false until :c:func:`Py_Initialize` is called again." msgstr "" -#: ../../c-api/interp-lifecycle.rst:416 +#: ../../c-api/interp-lifecycle.rst:413 +msgid "" +"This function no longer returns true until initialization has fully " +"completed, including import of the :mod:`site` module. Previously it could " +"return true while :c:func:`Py_Initialize` was still running." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:421 msgid "" "Return true (non-zero) if the main Python interpreter is :term:`shutting " "down `. Return false (zero) otherwise." msgstr "" -#: ../../c-api/interp-lifecycle.rst:424 +#: ../../c-api/interp-lifecycle.rst:429 msgid "" "Undo all initializations made by :c:func:`Py_Initialize` and subsequent use " "of Python/C API functions, and destroy all sub-interpreters (see :c:func:" @@ -614,7 +621,7 @@ msgid "" "second time (without calling :c:func:`Py_Initialize` again first)." msgstr "" -#: ../../c-api/interp-lifecycle.rst:430 +#: ../../c-api/interp-lifecycle.rst:435 msgid "" "Since this is the reverse of :c:func:`Py_Initialize`, it should be called in " "the same thread with the same interpreter active. That means the main " @@ -622,13 +629,13 @@ msgid "" "`Py_RunMain` is running." msgstr "" -#: ../../c-api/interp-lifecycle.rst:435 +#: ../../c-api/interp-lifecycle.rst:440 msgid "" "Normally the return value is ``0``. If there were errors during finalization " "(flushing buffered data), ``-1`` is returned." msgstr "" -#: ../../c-api/interp-lifecycle.rst:439 +#: ../../c-api/interp-lifecycle.rst:444 msgid "" "Note that Python will do a best effort at freeing all memory allocated by " "the Python interpreter. Therefore, any C-Extension should make sure to " @@ -637,7 +644,7 @@ msgid "" "introduce vulnerabilities and incorrect behavior." msgstr "" -#: ../../c-api/interp-lifecycle.rst:445 +#: ../../c-api/interp-lifecycle.rst:450 msgid "" "This function is provided for a number of reasons. An embedding application " "might want to restart Python without having to restart the application " @@ -648,7 +655,7 @@ msgid "" "Python before exiting from the application." msgstr "" -#: ../../c-api/interp-lifecycle.rst:453 +#: ../../c-api/interp-lifecycle.rst:458 msgid "" "**Bugs and caveats:** The destruction of modules and objects in modules is " "done in random order; this may cause destructors (:meth:`~object.__del__` " @@ -668,7 +675,7 @@ msgid "" "stdout and stderr files." msgstr "" -#: ../../c-api/interp-lifecycle.rst:469 +#: ../../c-api/interp-lifecycle.rst:474 msgid "" "Raises an :ref:`auditing event ` ``cpython." "_PySys_ClearAuditHooks`` with no arguments." @@ -676,20 +683,20 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "_PySys_ClearAuditHooks``。" -#: ../../c-api/interp-lifecycle.rst:476 +#: ../../c-api/interp-lifecycle.rst:481 msgid "" "This is a backwards-compatible version of :c:func:`Py_FinalizeEx` that " "disregards the return value." msgstr "" -#: ../../c-api/interp-lifecycle.rst:482 +#: ../../c-api/interp-lifecycle.rst:487 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/interp-lifecycle.rst:491 +#: ../../c-api/interp-lifecycle.rst:496 msgid "" "The main program for the standard interpreter, encapsulating a full " "initialization/finalization cycle, as well as additional behaviour to " @@ -698,14 +705,14 @@ msgid "" "cmdline`." msgstr "" -#: ../../c-api/interp-lifecycle.rst:497 +#: ../../c-api/interp-lifecycle.rst:502 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/interp-lifecycle.rst:501 +#: ../../c-api/interp-lifecycle.rst:506 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 " @@ -715,20 +722,20 @@ msgid "" "pointed to by the argument list are not modified)." msgstr "" -#: ../../c-api/interp-lifecycle.rst:508 +#: ../../c-api/interp-lifecycle.rst:513 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/interp-lifecycle.rst:511 +#: ../../c-api/interp-lifecycle.rst:516 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/interp-lifecycle.rst:515 +#: ../../c-api/interp-lifecycle.rst:520 msgid "" "PyConfig config;\n" "PyConfig_InitPythonConfig(&config);\n" @@ -739,7 +746,7 @@ msgid "" "Py_RunMain();" msgstr "" -#: ../../c-api/interp-lifecycle.rst:523 +#: ../../c-api/interp-lifecycle.rst:528 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:" @@ -752,11 +759,11 @@ msgid "" "first initialized)." msgstr "" -#: ../../c-api/interp-lifecycle.rst:536 +#: ../../c-api/interp-lifecycle.rst:541 msgid "Executes the main module in a fully configured CPython runtime." msgstr "" -#: ../../c-api/interp-lifecycle.rst:538 +#: ../../c-api/interp-lifecycle.rst:543 msgid "" "Executes the command (:c:member:`PyConfig.run_command`), the script (:c:" "member:`PyConfig.run_filename`) or the module (:c:member:`PyConfig." @@ -765,7 +772,7 @@ msgid "" "``__main__`` module's global namespace." msgstr "" -#: ../../c-api/interp-lifecycle.rst:544 +#: ../../c-api/interp-lifecycle.rst:549 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 " @@ -773,7 +780,7 @@ msgid "" "any other unhandled exception." msgstr "" -#: ../../c-api/interp-lifecycle.rst:549 +#: ../../c-api/interp-lifecycle.rst:554 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 " @@ -784,239 +791,319 @@ msgid "" "status of a :exc:`SystemExit`, as specified above." msgstr "" -#: ../../c-api/interp-lifecycle.rst:557 +#: ../../c-api/interp-lifecycle.rst:562 msgid "" "This function always finalizes the Python interpreter before it returns." msgstr "" -#: ../../c-api/interp-lifecycle.rst:559 +#: ../../c-api/interp-lifecycle.rst:564 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/interp-lifecycle.rst:565 +#: ../../c-api/interp-lifecycle.rst:570 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/interp-lifecycle.rst:569 +#: ../../c-api/interp-lifecycle.rst:574 msgid "There must be an :term:`attached thread state` for *interp*." msgstr "" -#: ../../c-api/interp-lifecycle.rst:577 -msgid "Cautions regarding runtime finalization" +#: ../../c-api/interp-lifecycle.rst:582 +msgid "Cautions regarding interpreter finalization" msgstr "" -#: ../../c-api/interp-lifecycle.rst:579 +#: ../../c-api/interp-lifecycle.rst:584 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`." +"marked as finalizing, meaning that :c:func:`Py_IsFinalizing` and :func:`sys." +"is_finalizing` return true. At this point, only the finalization thread " +"(the thread that initiated finalization; this is typically the main thread) " +"is allowed to :term:`attach ` a thread state." msgstr "" -#: ../../c-api/interp-lifecycle.rst:587 +#: ../../c-api/interp-lifecycle.rst:592 msgid "" -"If any thread, other than the finalization thread, attempts to attach a :" -"term:`thread state` during finalization, either explicitly or implicitly, " -"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." +"Other threads that attempt to attach during finalization, either explicitly " +"(such as via :c:func:`PyThreadState_Ensure` or :c:macro:" +"`Py_END_ALLOW_THREADS`) or implicitly (such as in-between bytecode " +"instructions), will enter a **permanently blocked state**. Generally, this " +"is harmless, but this can result in deadlocks. For example, a thread may be " +"permanently blocked while holding a lock, meaning that the finalization " +"thread can never acquire that lock." msgstr "" -#: ../../c-api/interp-lifecycle.rst:594 +#: ../../c-api/interp-lifecycle.rst:600 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 and earlier. The CPython runtime :term:`thread " -"state` C APIs have never had any error reporting or handling expectations " -"at :term:`thread state` attachment 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." +"Prior to CPython 3.13, the thread would exit instead of hanging, which led " +"to other issues (see the warning note at :c:func:`PyThread_exit_thread`)." msgstr "" #: ../../c-api/interp-lifecycle.rst:604 -msgid "Process-wide parameters" +msgid "" +"Gross? Yes. Starting in Python 3.15, there are a number of C APIs that make " +"it possible to avoid these issues by temporarily preventing finalization:" msgstr "" -#: ../../c-api/interp-lifecycle.rst:613 +#: ../../c-api/interp-lifecycle.rst:611 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"program_name` should be used instead, see :ref:`Python Initialization " -"Configuration `." +":pep:`788` explains the design, motivation and rationale for these APIs." msgstr "" -#: ../../c-api/interp-lifecycle.rst:617 +#: ../../c-api/interp-lifecycle.rst:616 +msgid "An opaque interpreter guard structure." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:618 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 " -"of the ``argv[0]`` argument to the :c:func:`main` function of the program " -"(converted to wide characters). This is used by :c:func:`Py_GetPath` and " -"some other functions below to find the Python run-time libraries relative to " -"the interpreter executable. The default value is ``'python'``. The " -"argument should point to a zero-terminated wide character string in static " -"storage whose contents will not change for the duration of the program's " -"execution. No code in the Python interpreter will change the contents of " -"this storage." +"By holding an interpreter guard, the caller can ensure that the interpreter " +"will not finalize until the guard is closed (through :c:func:" +"`PyInterpreterGuard_Close`)." msgstr "" -#: ../../c-api/interp-lifecycle.rst:628 ../../c-api/interp-lifecycle.rst:877 -#: ../../c-api/interp-lifecycle.rst:910 ../../c-api/interp-lifecycle.rst:936 +#: ../../c-api/interp-lifecycle.rst:622 msgid "" -"Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" -"`wchar_t*` string." +"When a guard is held, a thread attempting to finalize the interpreter will " +"block until the guard is closed before starting finalization. After " +"finalization has started, threads are forever unable to acquire guards for " +"that interpreter. This means that if you forget to close an interpreter " +"guard, the process will **permanently hang** during finalization!" +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:629 +msgid "" +"Holding a guard for an interpreter is similar to holding a :term:`strong " +"reference` to a Python object, except finalization does not happen " +"automatically after all guards are released: it requires an explicit :c:func:" +"`Py_EndInterpreter` call." msgstr "" -#: ../../c-api/interp-lifecycle.rst:636 +#: ../../c-api/interp-lifecycle.rst:639 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." +"Create a finalization guard for the current interpreter. This will prevent " +"finalization until the guard is closed." msgstr "" -#: ../../c-api/interp-lifecycle.rst:640 ../../c-api/interp-lifecycle.rst:663 -#: ../../c-api/interp-lifecycle.rst:711 ../../c-api/interp-lifecycle.rst:736 -#: ../../c-api/interp-lifecycle.rst:763 ../../c-api/interp-lifecycle.rst:948 +#: ../../c-api/interp-lifecycle.rst:642 +msgid "For example:" +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:644 msgid "" -"This function should not be called before :c:func:`Py_Initialize`, otherwise " -"it returns ``NULL``." -msgstr "此函式不應該在 :c:func:`Py_Initialize` 之前呼叫,否則會回傳 ``NULL``。" +"// Temporarily prevent finalization.\n" +"PyInterpreterGuard *guard = PyInterpreterGuard_FromCurrent();\n" +"if (guard == NULL) {\n" +" // Finalization has already started or we're out of memory.\n" +" return NULL;\n" +"}\n" +"\n" +"Py_BEGIN_ALLOW_THREADS;\n" +"// Do some critical processing here. For example, we can safely acquire\n" +"// locks that might be acquired by the finalization thread.\n" +"Py_END_ALLOW_THREADS;\n" +"\n" +"// Now that we're done with our critical processing, the interpreter is\n" +"// allowed to finalize again.\n" +"PyInterpreterGuard_Close(guard);" +msgstr "" +"// 暫時阻止最終化。\n" +"PyInterpreterGuard *guard = PyInterpreterGuard_FromCurrent();\n" +"if (guard == NULL) {\n" +" // 最終化已經開始,或記憶體不足。\n" +" return NULL;\n" +"}\n" +"\n" +"Py_BEGIN_ALLOW_THREADS;\n" +"// 在此進行一些關鍵處理。例如,我們可以安全地取得\n" +"// 可能會被最終化執行緒取得的鎖。\n" +"Py_END_ALLOW_THREADS;\n" +"\n" +"// 現在關鍵處理已經完成,直譯器\n" +"// 又可以被最終化了。\n" +"PyInterpreterGuard_Close(guard);" -#: ../../c-api/interp-lifecycle.rst:643 ../../c-api/interp-lifecycle.rst:666 -#: ../../c-api/interp-lifecycle.rst:714 ../../c-api/interp-lifecycle.rst:739 -#: ../../c-api/interp-lifecycle.rst:768 ../../c-api/interp-lifecycle.rst:951 -msgid "It now returns ``NULL`` if called before :c:func:`Py_Initialize`." -msgstr "如果在 :c:func:`Py_Initialize` 之前呼叫,現在會回傳 ``NULL``。" +#: ../../c-api/interp-lifecycle.rst:662 +msgid "" +"On success, this function returns a guard for the current interpreter; on " +"failure, it returns ``NULL`` with an exception set." +msgstr "" -#: ../../c-api/interp-lifecycle.rst:646 ../../c-api/interp-lifecycle.rst:742 +#: ../../c-api/interp-lifecycle.rst:665 msgid "" -"Use :c:func:`PyConfig_Get(\"executable\") ` (:data:`sys." -"executable`) instead." +"This function will fail only if the current interpreter has already started " +"finalizing, or if the process is out of memory." msgstr "" -#: ../../c-api/interp-lifecycle.rst:653 +#: ../../c-api/interp-lifecycle.rst:668 msgid "" -"Return the *prefix* for installed platform-independent files. This is " -"derived through a number of complicated rules from the program name set " -"with :c:member:`PyConfig.program_name` and some environment variables; for " -"example, if the program name is ``'/usr/local/bin/python'``, the prefix is " -"``'/usr/local'``. The returned string points into static storage; the caller " -"should not modify its value. This corresponds to the :makevar:`prefix` " -"variable in the top-level :file:`Makefile` and the :option:`--prefix` " -"argument to the :program:`configure` script at build time. The value is " -"available to Python code as ``sys.base_prefix``. It is only useful on Unix. " -"See also the next function." +"The guard pointer returned by this function must be eventually closed with :" +"c:func:`PyInterpreterGuard_Close`; failing to do so will result in the " +"Python process infinitely hanging." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:672 ../../c-api/interp-lifecycle.rst:739 +msgid "The caller must hold an :term:`attached thread state`." +msgstr "呼叫者必須擁有一個 :term:`attached thread state`。" + +#: ../../c-api/interp-lifecycle.rst:679 +msgid "Create a finalization guard for an interpreter through a view." msgstr "" -#: ../../c-api/interp-lifecycle.rst:669 +#: ../../c-api/interp-lifecycle.rst:681 msgid "" -"Use :c:func:`PyConfig_Get(\"base_prefix\") ` (:data:`sys." -"base_prefix`) instead. Use :c:func:`PyConfig_Get(\"prefix\") ` " -"(:data:`sys.prefix`) if :ref:`virtual environments ` need to be " -"handled." +"On success, this function returns a guard to the interpreter represented by " +"*view*. The view is still valid after calling this function. The guard must " +"eventually be closed with :c:func:`PyInterpreterGuard_Close`." msgstr "" -#: ../../c-api/interp-lifecycle.rst:678 +#: ../../c-api/interp-lifecycle.rst:686 msgid "" -"Return the *exec-prefix* for installed platform-*dependent* files. This is " -"derived through a number of complicated rules from the program name set " -"with :c:member:`PyConfig.program_name` and some environment variables; for " -"example, if the program name is ``'/usr/local/bin/python'``, the exec-prefix " -"is ``'/usr/local'``. The returned string points into static storage; the " -"caller should not modify its value. This corresponds to the :makevar:" -"`exec_prefix` variable in the top-level :file:`Makefile` and the ``--exec-" -"prefix`` argument to the :program:`configure` script at build time. The " -"value is available to Python code as ``sys.base_exec_prefix``. It is only " -"useful on Unix." +"If the interpreter no longer exists, is already finalizing, or out of " +"memory, then this function returns ``NULL`` without setting an exception." msgstr "" -#: ../../c-api/interp-lifecycle.rst:689 +#: ../../c-api/interp-lifecycle.rst:689 ../../c-api/interp-lifecycle.rst:775 +msgid "The caller does not need to hold an :term:`attached thread state`." +msgstr "呼叫者不需擁有一個 :term:`attached thread state`。" + +#: ../../c-api/interp-lifecycle.rst:696 msgid "" -"Background: The exec-prefix differs from the prefix when platform dependent " -"files (such as executables and shared libraries) are installed in a " -"different directory tree. In a typical installation, platform dependent " -"files may be installed in the :file:`/usr/local/plat` subtree while platform " -"independent may be installed in :file:`/usr/local`." +"Close an interpreter guard, allowing the interpreter to start finalization " +"if no other guards remain. If an interpreter guard is never closed, the " +"interpreter will infinitely wait when trying to enter finalization!" msgstr "" -#: ../../c-api/interp-lifecycle.rst:695 +#: ../../c-api/interp-lifecycle.rst:701 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 " -"considered the same platform, but Intel machines running Solaris 2.x are " -"another platform, and Intel machines running Linux are yet another " -"platform. Different major revisions of the same operating system generally " -"also form different platforms. Non-Unix operating systems are a different " -"story; the installation strategies on those systems are so different that " -"the prefix and exec-prefix are meaningless, and set to the empty string. " -"Note that compiled Python bytecode files are platform independent (but not " -"independent from the Python version by which they were compiled!)." +"After an interpreter guard is closed, it may not be used in :c:func:" +"`PyThreadState_Ensure`. Doing so will result in undefined behavior." msgstr "" -#: ../../c-api/interp-lifecycle.rst:706 +#: ../../c-api/interp-lifecycle.rst:705 ../../c-api/interp-lifecycle.rst:752 msgid "" -"System administrators will know how to configure the :program:`mount` or :" -"program:`automount` programs to share :file:`/usr/local` between platforms " -"while having :file:`/usr/local/plat` be a different filesystem for each " -"platform." +"This function cannot fail, and the caller doesn't need to hold an :term:" +"`attached thread state`." msgstr "" -#: ../../c-api/interp-lifecycle.rst:717 +#: ../../c-api/interp-lifecycle.rst:714 +msgid "Interpreter views" +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:716 msgid "" -"Use :c:func:`PyConfig_Get(\"base_exec_prefix\") ` (:data:`sys." -"base_exec_prefix`) instead. Use :c:func:`PyConfig_Get(\"exec_prefix\") " -"` (:data:`sys.exec_prefix`) if :ref:`virtual environments " -"` need to be handled." +"In some cases, it may be necessary to access an interpreter that may have " +"been deleted. This can be done using interpreter views." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:721 +msgid "An opaque view of an interpreter." msgstr "" -#: ../../c-api/interp-lifecycle.rst:730 +#: ../../c-api/interp-lifecycle.rst:723 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 " -"name (set by :c:member:`PyConfig.program_name`). The returned string points " -"into static storage; the caller should not modify its value. The value is " -"available to Python code as ``sys.executable``." +"This is a thread-safe way to access an interpreter that may have be " +"finalizing or already destroyed." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:731 +msgid "Create a view to the current interpreter." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:733 +msgid "" +"This function is generally meant to be used alongside :c:func:" +"`PyInterpreterGuard_FromView` or :c:func:`PyThreadState_EnsureFromView`." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:736 +msgid "" +"On success, this function returns a view to the current interpreter; on " +"failure, it returns ``NULL`` with an exception set." msgstr "" -#: ../../c-api/interp-lifecycle.rst:753 +#: ../../c-api/interp-lifecycle.rst:746 +msgid "Close an interpreter view." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:748 msgid "" -"Return the default module search path; this is computed from the program " -"name (set by :c:member:`PyConfig.program_name`) and some environment " -"variables. The returned string consists of a series of directory names " -"separated by a platform dependent delimiter character. The delimiter " -"character is ``':'`` on Unix and macOS, ``';'`` on Windows. The returned " -"string points into static storage; the caller should not modify its value. " -"The list :data:`sys.path` is initialized with this value on interpreter " -"startup; it can be (and usually is) modified later to change the search path " -"for loading modules." +"If an interpreter view is never closed, the view's memory will never be " +"freed, but there are no other consequences. (In contrast, forgetting to " +"close a guard will infinitely hang the main thread during finalization.)" +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:760 +msgid "" +"Create a view for the main interpreter (the first and default interpreter in " +"a Python process; see :c:func:`PyInterpreterState_Main`)." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:764 +msgid "" +"On success, this function returns a view to the main interpreter; on " +"failure, it returns ``NULL`` without an exception set. Failure indicates " +"that the process is out of memory." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:768 +msgid "" +"Use this function when an interpreter pointer or view cannot be supplied by " +"the caller, such as when a native threading library does not provide a " +"``void *arg`` parameter that could carry a :c:type:`PyInterpreterGuard` or :" +"c:type:`PyInterpreterView`. In code that supports subinterpreters, prefer :c:" +"func:`PyInterpreterView_FromCurrent` so the guard tracks the calling " +"interpreter rather than the main one." +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:781 +msgid "Process-wide parameters" +msgstr "" + +#: ../../c-api/interp-lifecycle.rst:789 +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/interp-lifecycle.rst:793 +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 " +"of the ``argv[0]`` argument to the :c:func:`main` function of the program " +"(converted to wide characters). This is used by some other functions below " +"to find the Python run-time libraries relative to the interpreter " +"executable. The default value is ``'python'``. The argument should point " +"to a zero-terminated wide character string in static storage whose contents " +"will not change for the duration of the program's execution. No code in the " +"Python interpreter will change the contents of this storage." msgstr "" -#: ../../c-api/interp-lifecycle.rst:771 +#: ../../c-api/interp-lifecycle.rst:804 ../../c-api/interp-lifecycle.rst:912 +#: ../../c-api/interp-lifecycle.rst:945 ../../c-api/interp-lifecycle.rst:971 msgid "" -"Use :c:func:`PyConfig_Get(\"module_search_paths\") ` (:data:" -"`sys.path`) instead." +"Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" +"`wchar_t*` string." msgstr "" -#: ../../c-api/interp-lifecycle.rst:777 +#: ../../c-api/interp-lifecycle.rst:812 msgid "" "Return the version of this Python interpreter. This is a string that looks " "something like ::" msgstr "" -#: ../../c-api/interp-lifecycle.rst:780 +#: ../../c-api/interp-lifecycle.rst:815 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/interp-lifecycle.rst:784 +#: ../../c-api/interp-lifecycle.rst:819 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 " @@ -1025,11 +1112,11 @@ msgid "" "version`." msgstr "" -#: ../../c-api/interp-lifecycle.rst:789 +#: ../../c-api/interp-lifecycle.rst:824 msgid "See also the :c:var:`Py_Version` constant." msgstr "另請參閱 :c:var:`Py_Version` 常數。" -#: ../../c-api/interp-lifecycle.rst:796 +#: ../../c-api/interp-lifecycle.rst:831 msgid "" "Return the platform identifier for the current platform. On Unix, this is " "formed from the \"official\" name of the operating system, converted to " @@ -1040,50 +1127,50 @@ msgid "" "available to Python code as ``sys.platform``." msgstr "" -#: ../../c-api/interp-lifecycle.rst:807 +#: ../../c-api/interp-lifecycle.rst:842 msgid "" "Return the official copyright string for the current Python version, for " "example" msgstr "" -#: ../../c-api/interp-lifecycle.rst:809 +#: ../../c-api/interp-lifecycle.rst:844 msgid "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" msgstr "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" -#: ../../c-api/interp-lifecycle.rst:813 +#: ../../c-api/interp-lifecycle.rst:848 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/interp-lifecycle.rst:819 +#: ../../c-api/interp-lifecycle.rst:854 msgid "" "Return an indication of the compiler used to build the current Python " "version, in square brackets, for example::" msgstr "" -#: ../../c-api/interp-lifecycle.rst:822 +#: ../../c-api/interp-lifecycle.rst:857 msgid "\"[GCC 2.7.2.2]\"" msgstr "\"[GCC 2.7.2.2]\"" -#: ../../c-api/interp-lifecycle.rst:826 ../../c-api/interp-lifecycle.rst:840 +#: ../../c-api/interp-lifecycle.rst:861 ../../c-api/interp-lifecycle.rst:875 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/interp-lifecycle.rst:833 +#: ../../c-api/interp-lifecycle.rst:868 msgid "" "Return information about the sequence number and build date and time of the " "current Python interpreter instance, for example ::" msgstr "" -#: ../../c-api/interp-lifecycle.rst:836 +#: ../../c-api/interp-lifecycle.rst:871 msgid "\"#67, Aug 1 1997, 22:34:28\"" msgstr "\"#67, Aug 1 1997, 22:34:28\"" -#: ../../c-api/interp-lifecycle.rst:852 +#: ../../c-api/interp-lifecycle.rst:887 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv`, :c:member:`PyConfig.parse_argv` and :c:member:`PyConfig.safe_path` " @@ -1091,7 +1178,7 @@ msgid "" "config>`." msgstr "" -#: ../../c-api/interp-lifecycle.rst:857 +#: ../../c-api/interp-lifecycle.rst:892 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 " @@ -1102,84 +1189,84 @@ msgid "" "fatal condition is signalled using :c:func:`Py_FatalError`." msgstr "" -#: ../../c-api/interp-lifecycle.rst:865 +#: ../../c-api/interp-lifecycle.rst:900 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/interp-lifecycle.rst:869 +#: ../../c-api/interp-lifecycle.rst:904 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/interp-lifecycle.rst:872 +#: ../../c-api/interp-lifecycle.rst:907 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/interp-lifecycle.rst:880 ../../c-api/interp-lifecycle.rst:913 +#: ../../c-api/interp-lifecycle.rst:915 ../../c-api/interp-lifecycle.rst:948 msgid "" "See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv` " "members of the :ref:`Python Initialization Configuration `." msgstr "" -#: ../../c-api/interp-lifecycle.rst:884 +#: ../../c-api/interp-lifecycle.rst:919 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/interp-lifecycle.rst:889 +#: ../../c-api/interp-lifecycle.rst:924 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/interp-lifecycle.rst:893 +#: ../../c-api/interp-lifecycle.rst:928 msgid "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" msgstr "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" -#: ../../c-api/interp-lifecycle.rst:902 +#: ../../c-api/interp-lifecycle.rst:937 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/interp-lifecycle.rst:906 +#: ../../c-api/interp-lifecycle.rst:941 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/interp-lifecycle.rst:916 +#: ../../c-api/interp-lifecycle.rst:951 msgid "The *updatepath* value depends on :option:`-I`." msgstr "" -#: ../../c-api/interp-lifecycle.rst:923 +#: ../../c-api/interp-lifecycle.rst:958 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/interp-lifecycle.rst:927 +#: ../../c-api/interp-lifecycle.rst:962 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/interp-lifecycle.rst:931 +#: ../../c-api/interp-lifecycle.rst:966 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 " @@ -1187,19 +1274,6 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/interp-lifecycle.rst:944 -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/interp-lifecycle.rst:954 -msgid "" -"Use :c:func:`PyConfig_Get(\"home\") ` or the :envvar:" -"`PYTHONHOME` environment variable instead." -msgstr "" - #: ../../c-api/interp-lifecycle.rst:357 msgid "PyEval_InitThreads()" msgstr "PyEval_InitThreads()" @@ -1208,11 +1282,11 @@ msgstr "PyEval_InitThreads()" msgid "modules (in module sys)" msgstr "modules(sys 模組中)" -#: ../../c-api/interp-lifecycle.rst:357 ../../c-api/interp-lifecycle.rst:749 +#: ../../c-api/interp-lifecycle.rst:357 msgid "path (in module sys)" msgstr "path(sys 模組中)" -#: ../../c-api/interp-lifecycle.rst:357 ../../c-api/interp-lifecycle.rst:749 +#: ../../c-api/interp-lifecycle.rst:357 msgid "module" msgstr "模組" @@ -1228,11 +1302,11 @@ msgstr "__main__" msgid "sys" msgstr "sys" -#: ../../c-api/interp-lifecycle.rst:357 ../../c-api/interp-lifecycle.rst:749 +#: ../../c-api/interp-lifecycle.rst:357 msgid "search" msgstr "search(搜尋)" -#: ../../c-api/interp-lifecycle.rst:357 ../../c-api/interp-lifecycle.rst:749 +#: ../../c-api/interp-lifecycle.rst:357 msgid "path" msgstr "path(路徑)" @@ -1240,39 +1314,46 @@ msgstr "path(路徑)" msgid "Py_FinalizeEx (C function)" msgstr "Py_FinalizeEx(C 函式)" -#: ../../c-api/interp-lifecycle.rst:608 +#: ../../c-api/interp-lifecycle.rst:785 msgid "Py_Initialize()" msgstr "Py_Initialize()" -#: ../../c-api/interp-lifecycle.rst:608 ../../c-api/interp-lifecycle.rst:847 +#: ../../c-api/interp-lifecycle.rst:785 ../../c-api/interp-lifecycle.rst:882 msgid "main()" msgstr "main()" -#: ../../c-api/interp-lifecycle.rst:608 -msgid "Py_GetPath()" -msgstr "Py_GetPath()" - -#: ../../c-api/interp-lifecycle.rst:727 -msgid "executable (in module sys)" -msgstr "executable(sys 模組中)" - -#: ../../c-api/interp-lifecycle.rst:782 ../../c-api/interp-lifecycle.rst:824 -#: ../../c-api/interp-lifecycle.rst:838 +#: ../../c-api/interp-lifecycle.rst:817 ../../c-api/interp-lifecycle.rst:859 +#: ../../c-api/interp-lifecycle.rst:873 msgid "version (in module sys)" msgstr "version(sys 模組中)" -#: ../../c-api/interp-lifecycle.rst:794 +#: ../../c-api/interp-lifecycle.rst:829 msgid "platform (in module sys)" msgstr "platform(sys 模組中)" -#: ../../c-api/interp-lifecycle.rst:811 +#: ../../c-api/interp-lifecycle.rst:846 msgid "copyright (in module sys)" msgstr "copyright(sys 模組中)" -#: ../../c-api/interp-lifecycle.rst:847 +#: ../../c-api/interp-lifecycle.rst:882 msgid "Py_FatalError()" msgstr "Py_FatalError()" -#: ../../c-api/interp-lifecycle.rst:847 +#: ../../c-api/interp-lifecycle.rst:882 msgid "argv (in module sys)" msgstr "argv(sys 模組中)" + +#~ msgid "" +#~ "This function should not be called before :c:func:`Py_Initialize`, " +#~ "otherwise it returns ``NULL``." +#~ msgstr "" +#~ "此函式不應該在 :c:func:`Py_Initialize` 之前呼叫,否則會回傳 ``NULL``。" + +#~ msgid "It now returns ``NULL`` if called before :c:func:`Py_Initialize`." +#~ msgstr "如果在 :c:func:`Py_Initialize` 之前呼叫,現在會回傳 ``NULL``。" + +#~ msgid "Py_GetPath()" +#~ msgstr "Py_GetPath()" + +#~ msgid "executable (in module sys)" +#~ msgstr "executable(sys 模組中)" diff --git a/c-api/intro.po b/c-api/intro.po index 98c0667f940..d594adabcb7 100644 --- a/c-api/intro.po +++ b/c-api/intro.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-31 00:31+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-04-25 18:01+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -125,7 +125,7 @@ msgstr "" "這意味著會引入以下標準標頭:````、````、````、" "````、```` 和 ````\\ (如果可用)。" -#: ../../c-api/intro.rst:70 +#: ../../c-api/intro.rst:70 ../../c-api/intro.rst:145 msgid "" "Since Python may define some pre-processor definitions which affect the " "standard headers on some systems, you *must* include :file:`Python.h` before " @@ -206,11 +206,90 @@ msgstr "" "C++ 使用者應注意,儘管 API 完全使用 C 來定義,但標頭檔適當地將入口點聲明為 " "``extern \"C\"``。因此,無需執行任何特殊操作即可使用 C++ 中的 API。" -#: ../../c-api/intro.rst:111 +#: ../../c-api/intro.rst:113 +msgid "System includes" +msgstr "" + +#: ../../c-api/intro.rst:115 +msgid "" +":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. The implicit includes are:" +msgstr "" + +#: ../../c-api/intro.rst:120 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:121 +msgid "```` (on Windows)" +msgstr "````\\ (在 Windows 上)" + +#: ../../c-api/intro.rst:122 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:123 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:124 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:125 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:126 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:127 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:128 +msgid "```` (if present)" +msgstr "````\\ (如果存在)" + +#: ../../c-api/intro.rst:130 +msgid "" +"The following are included for backwards compatibility, unless using :ref:" +"`Limited API ` 3.13 or newer:" +msgstr "" + +#: ../../c-api/intro.rst:133 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:134 +msgid "```` (on POSIX)" +msgstr "````\\ (在 POSIX 上)" + +#: ../../c-api/intro.rst:136 +msgid "" +"The following are included for backwards compatibility, unless using :ref:" +"`Limited API ` 3.11 or newer:" +msgstr "" + +#: ../../c-api/intro.rst:139 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:140 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:141 +msgid "````" +msgstr "````" + +#: ../../c-api/intro.rst:151 msgid "Useful macros" msgstr "有用的巨集" -#: ../../c-api/intro.rst:113 +#: ../../c-api/intro.rst:153 msgid "" "Several useful macros are defined in the Python header files. Many are " "defined closer to where they are useful (for example, :c:macro:" @@ -221,18 +300,18 @@ msgstr "" "macro:`Py_RETURN_NONE`、:c:macro:`PyMODINIT_FUNC`),其他是更通用的工具程式。" "以下並不一定是完整的列表。" -#: ../../c-api/intro.rst:121 +#: ../../c-api/intro.rst:161 msgid "" "If this macro is defined, then the current system is able to start threads." msgstr "如果有定義此巨集,則目前系統就能夠啟動執行緒。" -#: ../../c-api/intro.rst:123 +#: ../../c-api/intro.rst:163 msgid "" "Currently, all systems supported by CPython (per :pep:`11`), with the " "exception of some WebAssembly platforms, support starting threads." msgstr "" -#: ../../c-api/intro.rst:130 +#: ../../c-api/intro.rst:170 msgid "" "Like :samp:`getenv({s})`, but returns ``NULL`` if :option:`-E` was passed on " "the command line (see :c:member:`PyConfig.use_environment`)." @@ -240,11 +319,11 @@ msgstr "" "類似於 :samp:`getenv({s})`,但如果在命令列上傳遞了 :option:`-E` 則回傳 " "``NULL`` (請見 :c:member:`PyConfig.use_environment`)。" -#: ../../c-api/intro.rst:135 +#: ../../c-api/intro.rst:175 msgid "Docstring macros" msgstr "文件字串巨集" -#: ../../c-api/intro.rst:139 +#: ../../c-api/intro.rst:179 msgid "" "Creates a variable with name *name* that can be used in docstrings. If " "Python is built without docstrings (:option:`--without-doc-strings`), the " @@ -253,12 +332,12 @@ msgstr "" "建立一個名為 *name* 的變數,可以在文件字串中使用。如果 Python 是在沒有文件字" "串的情況下建置 (:option:`--without-doc-strings`),則該值將為空字串。" -#: ../../c-api/intro.rst:143 ../../c-api/intro.rst:160 -#: ../../c-api/intro.rst:428 +#: ../../c-api/intro.rst:183 ../../c-api/intro.rst:200 +#: ../../c-api/intro.rst:468 msgid "Example::" msgstr "範例: ::" -#: ../../c-api/intro.rst:145 +#: ../../c-api/intro.rst:185 msgid "" "PyDoc_STRVAR(pop_doc, \"Remove and return the rightmost element.\");\n" "\n" @@ -276,11 +355,11 @@ msgstr "" " // ...\n" "}" -#: ../../c-api/intro.rst:153 +#: ../../c-api/intro.rst:193 msgid "Expands to :samp:`PyDoc_VAR({name}) = PyDoc_STR({str})`." msgstr "" -#: ../../c-api/intro.rst:157 +#: ../../c-api/intro.rst:197 msgid "" "Expands to the given input string, or an empty string if docstrings are " "disabled (:option:`--without-doc-strings`)." @@ -288,7 +367,7 @@ msgstr "" "擴展至給定的輸入字串,或如果文件字串被禁用 (:option:`--without-doc-strings`) " "則建立空字串。" -#: ../../c-api/intro.rst:162 +#: ../../c-api/intro.rst:202 msgid "" "static PyMethodDef pysqlite_row_methods[] = {\n" " {\"keys\", (PyCFunction)pysqlite_row_keys, METH_NOARGS,\n" @@ -302,33 +381,33 @@ msgstr "" " {NULL, NULL}\n" "};" -#: ../../c-api/intro.rst:170 +#: ../../c-api/intro.rst:210 msgid "" "Declares a static character array variable with the given *name*. Expands " "to :samp:`static const char {name}[]`" msgstr "" -#: ../../c-api/intro.rst:173 ../../c-api/intro.rst:314 -#: ../../c-api/intro.rst:325 +#: ../../c-api/intro.rst:213 ../../c-api/intro.rst:354 +#: ../../c-api/intro.rst:365 msgid "For example::" msgstr "範例: ::" -#: ../../c-api/intro.rst:175 +#: ../../c-api/intro.rst:215 msgid "" "PyDoc_VAR(python_doc) = PyDoc_STR(\n" " \"A genus of constricting snakes in the Pythonidae family native \"\n" " \"to the tropics and subtropics of the Eastern Hemisphere.\");" msgstr "" -#: ../../c-api/intro.rst:181 +#: ../../c-api/intro.rst:221 msgid "General utility macros" msgstr "" -#: ../../c-api/intro.rst:183 +#: ../../c-api/intro.rst:223 msgid "The following macros are for common tasks not specific to Python." msgstr "" -#: ../../c-api/intro.rst:187 +#: ../../c-api/intro.rst:227 msgid "" "Use this for unused arguments in a function definition to silence compiler " "warnings. Example: ``int func(int a, int Py_UNUSED(b)) { return a; }``." @@ -336,72 +415,72 @@ msgstr "" "將此用於函式定義中未使用的參數以消除編譯器警告。例如:``int func(int a, int " "Py_UNUSED(b)) { return a; }``。" -#: ../../c-api/intro.rst:194 +#: ../../c-api/intro.rst:234 msgid "" "Use a GCC attribute *name*, hiding it from compilers that don't support GCC " "attributes (such as MSVC)." msgstr "" -#: ../../c-api/intro.rst:197 +#: ../../c-api/intro.rst:237 msgid "" "This expands to :samp:`__attribute__(({name)})` on a GCC compiler, and " "expands to nothing on compilers that don't support GCC attributes." msgstr "" -#: ../../c-api/intro.rst:202 +#: ../../c-api/intro.rst:242 msgid "Numeric utilities" msgstr "" -#: ../../c-api/intro.rst:206 +#: ../../c-api/intro.rst:246 msgid "Return the absolute value of ``x``." msgstr "回傳 ``x`` 的絕對值。" -#: ../../c-api/intro.rst:208 +#: ../../c-api/intro.rst:248 msgid "" "The argument may be evaluated more than once. Consequently, do not pass an " "expression with side-effects directly to this macro." msgstr "" -#: ../../c-api/intro.rst:212 +#: ../../c-api/intro.rst:252 msgid "" "If the result cannot be represented (for example, if ``x`` has :c:macro:`!" "INT_MIN` value for :c:expr:`int` type), the behavior is undefined." msgstr "" -#: ../../c-api/intro.rst:216 +#: ../../c-api/intro.rst:256 msgid "Corresponds roughly to :samp:`(({x}) < 0 ? -({x}) : ({x}))`" msgstr "" -#: ../../c-api/intro.rst:223 +#: ../../c-api/intro.rst:263 msgid "Return the larger or smaller of the arguments, respectively." msgstr "" -#: ../../c-api/intro.rst:225 +#: ../../c-api/intro.rst:265 msgid "" "Any arguments may be evaluated more than once. Consequently, do not pass an " "expression with side-effects directly to this macro." msgstr "" -#: ../../c-api/intro.rst:229 +#: ../../c-api/intro.rst:269 msgid "" ":c:macro:`!Py_MAX` corresponds roughly to :samp:`((({x}) > ({y})) ? ({x}) : " "({y}))`." msgstr "" -#: ../../c-api/intro.rst:236 +#: ../../c-api/intro.rst:276 msgid "" "Similar to :samp:`{integer} >> {positions}`, but forces sign extension, as " "the C standard does not define whether a right-shift of a signed integer " "will perform sign extension or a zero-fill." msgstr "" -#: ../../c-api/intro.rst:240 +#: ../../c-api/intro.rst:280 msgid "" "*integer* should be any signed integer type. *positions* is the number of " "positions to shift to the right." msgstr "" -#: ../../c-api/intro.rst:243 +#: ../../c-api/intro.rst:283 msgid "" "Both *integer* and *positions* can be evaluated more than once; " "consequently, avoid directly passing a function call or some other operation " @@ -409,19 +488,19 @@ msgid "" "then pass it." msgstr "" -#: ../../c-api/intro.rst:248 +#: ../../c-api/intro.rst:288 msgid "" "*type* is unused and only kept for backwards compatibility. Historically, " "*type* was used to cast *integer*." msgstr "" -#: ../../c-api/intro.rst:253 +#: ../../c-api/intro.rst:293 msgid "" "This macro is now valid for all signed integer types, not just those for " "which ``unsigned type`` is legal. As a result, *type* is no longer used." msgstr "" -#: ../../c-api/intro.rst:259 +#: ../../c-api/intro.rst:299 msgid "" "Argument must be a character or an integer in the range [-128, 127] or [0, " "255]. This macro returns ``c`` cast to an ``unsigned char``." @@ -429,11 +508,11 @@ msgstr "" "引數必須是 [-128, 127] 或 [0, 255] 範圍內的字元或整數。這個巨集會將 ``c`` 轉" "換為 ``unsigned char`` 並回傳。" -#: ../../c-api/intro.rst:264 +#: ../../c-api/intro.rst:304 msgid "Assertion utilities" msgstr "" -#: ../../c-api/intro.rst:268 +#: ../../c-api/intro.rst:308 msgid "" "Use this when you have a code path that cannot be reached by design. For " "example, in the ``default:`` clause in a ``switch`` statement for which all " @@ -444,7 +523,7 @@ msgstr "" "蓋了所有可能值的 ``switch`` 陳述式中的 ``default:`` 子句。在你可能想要呼叫 " "``assert(0)`` 或 ``abort()`` 的地方使用它。" -#: ../../c-api/intro.rst:273 +#: ../../c-api/intro.rst:313 msgid "" "In release mode, the macro helps the compiler to optimize the code, and " "avoids a warning about unreachable code. For example, the macro is " @@ -454,13 +533,13 @@ msgstr "" "程式碼的警告。例如該巨集是在發布模式下於 GCC 使用 " "``__builtin_unreachable()`` 來實作。" -#: ../../c-api/intro.rst:277 +#: ../../c-api/intro.rst:317 msgid "" "In debug mode, and on unsupported compilers, the macro expands to a call to :" "c:func:`Py_FatalError`." msgstr "" -#: ../../c-api/intro.rst:280 +#: ../../c-api/intro.rst:320 msgid "" "A use for ``Py_UNREACHABLE()`` is following a call to a function that never " "returns but that is not declared ``_Noreturn``." @@ -468,7 +547,7 @@ msgstr "" "``Py_UNREACHABLE()`` 的一個用途是,在對一個永不回傳但並未聲明為 " "``_Noreturn`` 的函式之呼叫後使用。" -#: ../../c-api/intro.rst:283 +#: ../../c-api/intro.rst:323 msgid "" "If a code path is very unlikely code but can be reached under exceptional " "case, this macro must not be used. For example, under low memory condition " @@ -480,54 +559,54 @@ msgstr "" "憶體條件下或系統呼叫回傳了超出預期範圍的值。在這種情況下,最好將錯誤回報給呼" "叫者。如果無法回報錯誤則可以使用 :c:func:`Py_FatalError`。" -#: ../../c-api/intro.rst:293 +#: ../../c-api/intro.rst:333 msgid "" "Cast *value* to type *smaller* from type *larger*, validating that no " "information was lost." msgstr "" -#: ../../c-api/intro.rst:296 +#: ../../c-api/intro.rst:336 msgid "" "On release builds of Python, this is roughly equivalent to :samp:" "`(({smaller}) {value})` (in C++, :samp:`static_cast<{smaller}>({value})` " "will be used instead)." msgstr "" -#: ../../c-api/intro.rst:300 +#: ../../c-api/intro.rst:340 msgid "" "On debug builds (implying that :c:macro:`Py_DEBUG` is defined), this asserts " "that no information was lost with the cast from *larger* to *smaller*." msgstr "" -#: ../../c-api/intro.rst:303 +#: ../../c-api/intro.rst:343 msgid "" "*value*, *larger*, and *smaller* may all be evaluated more than once in the " "expression; consequently, do not pass an expression with side-effects " "directly to this macro." msgstr "" -#: ../../c-api/intro.rst:309 +#: ../../c-api/intro.rst:349 msgid "" "Asserts a compile-time condition *cond*, as a statement. The build will fail " "if the condition is false or cannot be evaluated at compile time." msgstr "" -#: ../../c-api/intro.rst:312 +#: ../../c-api/intro.rst:352 msgid "Corresponds roughly to :samp:`static_assert({cond})` on C23 and above." msgstr "" -#: ../../c-api/intro.rst:316 +#: ../../c-api/intro.rst:356 msgid "Py_BUILD_ASSERT(sizeof(PyTime_t) == sizeof(int64_t));" msgstr "Py_BUILD_ASSERT(sizeof(PyTime_t) == sizeof(int64_t));" -#: ../../c-api/intro.rst:322 +#: ../../c-api/intro.rst:362 msgid "" "Asserts a compile-time condition *cond*, as an expression that evaluates to " "``0``. The build will fail if the condition is false or cannot be evaluated " "at compile time." msgstr "" -#: ../../c-api/intro.rst:327 +#: ../../c-api/intro.rst:367 msgid "" "#define foo_to_char(foo) \\\n" " ((char *)(foo) + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))" @@ -535,15 +614,15 @@ msgstr "" "#define foo_to_char(foo) \\\n" " ((char *)(foo) + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))" -#: ../../c-api/intro.rst:334 +#: ../../c-api/intro.rst:374 msgid "Type size utilities" msgstr "" -#: ../../c-api/intro.rst:338 +#: ../../c-api/intro.rst:378 msgid "Compute the length of a statically allocated C array at compile time." msgstr "" -#: ../../c-api/intro.rst:340 +#: ../../c-api/intro.rst:380 msgid "" "The *array* argument must be a C array with a size known at compile time. " "Passing an array with an unknown size, such as a heap-allocated array, will " @@ -551,45 +630,45 @@ msgid "" "incorrect results." msgstr "" -#: ../../c-api/intro.rst:345 +#: ../../c-api/intro.rst:385 msgid "This is roughly equivalent to::" msgstr "這大致上相當於: ::" -#: ../../c-api/intro.rst:347 +#: ../../c-api/intro.rst:387 msgid "sizeof(array) / sizeof((array)[0])" msgstr "sizeof(array) / sizeof((array)[0])" -#: ../../c-api/intro.rst:351 +#: ../../c-api/intro.rst:391 msgid "Return the size of a structure (*type*) *member* in bytes." msgstr "以位元組為單位回傳結構 (*type*) *member* 的大小。" -#: ../../c-api/intro.rst:353 +#: ../../c-api/intro.rst:393 msgid "Corresponds roughly to :samp:`sizeof((({type} *)NULL)->{member})`." msgstr "" -#: ../../c-api/intro.rst:359 +#: ../../c-api/intro.rst:399 msgid "Macro definition utilities" msgstr "" -#: ../../c-api/intro.rst:363 +#: ../../c-api/intro.rst:403 msgid "" "This is equivalent to :samp:`{X}`, which is useful for token-pasting in " "macros, as macro expansions in *X* are forcefully evaluated by the " "preprocessor." msgstr "" -#: ../../c-api/intro.rst:369 +#: ../../c-api/intro.rst:409 msgid "" "Convert ``x`` to a C string. For example, ``Py_STRINGIFY(123)`` returns " "``\"123\"``." msgstr "" "將 ``x`` 轉換為 C 字串。例如 ``Py_STRINGIFY(123)`` 會回傳 ``\"123\"``。" -#: ../../c-api/intro.rst:376 +#: ../../c-api/intro.rst:416 msgid "Declaration utilities" msgstr "" -#: ../../c-api/intro.rst:378 +#: ../../c-api/intro.rst:418 msgid "" "The following macros can be used in declarations. They are most useful for " "defining the C API itself, and have limited use for extension authors. Most " @@ -597,7 +676,7 @@ msgid "" "language." msgstr "" -#: ../../c-api/intro.rst:386 +#: ../../c-api/intro.rst:426 msgid "" "Ask the compiler to always inline a static inline function. The compiler can " "ignore it and decide to not inline the function." @@ -605,13 +684,13 @@ msgstr "" "要求編譯器總是嵌入靜態行內函式 (static inline function),編譯器可以忽略它並決" "定不嵌入該函式。" -#: ../../c-api/intro.rst:389 +#: ../../c-api/intro.rst:429 msgid "" "Corresponds to ``always_inline`` attribute in GCC and ``__forceinline`` in " "MSVC." msgstr "" -#: ../../c-api/intro.rst:392 +#: ../../c-api/intro.rst:432 msgid "" "It can be used to inline performance critical static inline functions when " "building Python in debug mode with function inlining disabled. For example, " @@ -620,7 +699,7 @@ msgstr "" "在禁用函式嵌入的除錯模式下建置 Python 時,它可用於嵌入有性能要求的靜態行內函" "式。例如,MSC 在除錯模式下建置時禁用函式嵌入。" -#: ../../c-api/intro.rst:396 +#: ../../c-api/intro.rst:436 msgid "" "Marking blindly a static inline function with Py_ALWAYS_INLINE can result in " "worse performances (due to increased code size for example). The compiler is " @@ -629,7 +708,7 @@ msgstr "" "盲目地使用 Py_ALWAYS_INLINE 標記靜態行內函式可能會導致更差的性能(例如程式碼" "大小增加)。在成本/收益分析方面,編譯器通常比開發人員更聰明。" -#: ../../c-api/intro.rst:400 +#: ../../c-api/intro.rst:440 msgid "" "If Python is :ref:`built in debug mode ` (if the :c:macro:" "`Py_DEBUG` macro is defined), the :c:macro:`Py_ALWAYS_INLINE` macro does " @@ -638,15 +717,15 @@ msgstr "" "如果 Python 是\\ :ref:`在除錯模式下建置 `\\ (如果 :c:macro:" "`Py_DEBUG` 巨集有被定義),:c:macro:`Py_ALWAYS_INLINE` 巨集就什麼都不會做。" -#: ../../c-api/intro.rst:403 +#: ../../c-api/intro.rst:443 msgid "It must be specified before the function return type. Usage::" msgstr "它必須在函式回傳型別之前被指定。用法: ::" -#: ../../c-api/intro.rst:405 +#: ../../c-api/intro.rst:445 msgid "static inline Py_ALWAYS_INLINE int random(void) { return 4; }" msgstr "static inline Py_ALWAYS_INLINE int random(void) { return 4; }" -#: ../../c-api/intro.rst:411 +#: ../../c-api/intro.rst:451 msgid "" "Disable inlining on a function. For example, it reduces the C stack " "consumption: useful on LTO+PGO builds which heavily inline code (see :issue:" @@ -655,59 +734,59 @@ msgstr "" "禁用函式的嵌入。例如,它減少了 C 堆疊的消耗:對大量嵌入程式碼的 LTO+PGO 建置" "很有用(請參閱 :issue:`33720`)。" -#: ../../c-api/intro.rst:415 +#: ../../c-api/intro.rst:455 msgid "" "Corresponds to the ``noinline`` attribute/specification on GCC and MSVC." msgstr "" -#: ../../c-api/intro.rst:417 +#: ../../c-api/intro.rst:457 msgid "Usage::" msgstr "用法: ::" -#: ../../c-api/intro.rst:419 +#: ../../c-api/intro.rst:459 msgid "Py_NO_INLINE static int random(void) { return 4; }" msgstr "Py_NO_INLINE static int random(void) { return 4; }" -#: ../../c-api/intro.rst:425 +#: ../../c-api/intro.rst:465 msgid "" "Use this to declare APIs that were deprecated in a specific CPython version. " "The macro must be placed before the symbol name." msgstr "" -#: ../../c-api/intro.rst:430 +#: ../../c-api/intro.rst:470 msgid "Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);" msgstr "Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);" -#: ../../c-api/intro.rst:432 +#: ../../c-api/intro.rst:472 msgid "MSVC support was added." msgstr "新增了 MSVC 支援。" -#: ../../c-api/intro.rst:437 +#: ../../c-api/intro.rst:477 msgid "" "Declare a function returning the specified *type* using a fast-calling " "qualifier for functions that are local to the current file. Semantically, " "this is equivalent to :samp:`static {type}`." msgstr "" -#: ../../c-api/intro.rst:443 +#: ../../c-api/intro.rst:483 msgid "" "Equivalent to :c:macro:`Py_LOCAL` but additionally requests the function be " "inlined." msgstr "" -#: ../../c-api/intro.rst:448 +#: ../../c-api/intro.rst:488 msgid "" "Macro used to declare a symbol as local to the shared library (hidden). On " "supported platforms, it ensures the symbol is not exported." msgstr "" -#: ../../c-api/intro.rst:451 +#: ../../c-api/intro.rst:491 msgid "" "On compatible versions of GCC/Clang, it expands to " "``__attribute__((visibility(\"hidden\")))``." msgstr "" -#: ../../c-api/intro.rst:456 +#: ../../c-api/intro.rst:496 msgid "" "Macro used to declare a symbol (function or data) as exported. On Windows, " "this expands to ``__declspec(dllexport)``. On compatible versions of GCC/" @@ -715,14 +794,14 @@ msgid "" "macro is for defining the C API itself; extension modules should not use it." msgstr "" -#: ../../c-api/intro.rst:465 +#: ../../c-api/intro.rst:505 msgid "" "Macro used to declare a symbol as imported. On Windows, this expands to " "``__declspec(dllimport)``. This macro is for defining the C API itself; " "extension modules should not use it." msgstr "" -#: ../../c-api/intro.rst:472 +#: ../../c-api/intro.rst:512 msgid "" "Macro used by CPython to declare a function as part of the C API. Its " "expansion depends on the platform and build configuration. This macro is " @@ -730,7 +809,7 @@ msgid "" "use it for their own symbols." msgstr "" -#: ../../c-api/intro.rst:480 +#: ../../c-api/intro.rst:520 msgid "" "Macro used by CPython to declare a public global variable as part of the C " "API. Its expansion depends on the platform and build configuration. This " @@ -738,67 +817,113 @@ msgid "" "should not use it for their own symbols." msgstr "" -#: ../../c-api/intro.rst:487 +#: ../../c-api/intro.rst:527 msgid "Outdated macros" msgstr "" -#: ../../c-api/intro.rst:489 +#: ../../c-api/intro.rst:529 msgid "" -"The following macros have been used to features that have been standardized " -"in C11." +"The following :term:`soft deprecated` macros have been used to features that " +"have been standardized in C11 (or previous standards)." msgstr "" -#: ../../c-api/intro.rst:494 -msgid "Specify alignment to *num* bytes on compilers that support it." +#: ../../c-api/intro.rst:534 +msgid "" +"On some GCC-like compilers, specify alignment to *num* bytes. This does " +"nothing on other compilers." msgstr "" -#: ../../c-api/intro.rst:496 -msgid "Consider using the C11 standard ``_Alignas`` specifier over this macro." +#: ../../c-api/intro.rst:537 +msgid "Use the standard ``alignas`` specifier rather than this macro." msgstr "" -#: ../../c-api/intro.rst:501 +#: ../../c-api/intro.rst:543 +msgid "" +"The :c:func:`printf` formatting modifier for :c:type:`size_t`. Use ``\"z\"`` " +"directly instead." +msgstr "" + +#: ../../c-api/intro.rst:551 msgid "" "Use *number* as a ``long long`` or ``unsigned long long`` integer literal, " "respectively." msgstr "" -#: ../../c-api/intro.rst:504 +#: ../../c-api/intro.rst:554 msgid "" "Expands to *number* followed by ``LL`` or ``LLU``, respectively, but will " "expand to some compiler-specific suffixes on some older compilers." msgstr "" -#: ../../c-api/intro.rst:507 +#: ../../c-api/intro.rst:557 msgid "Consider using the C99 standard suffixes ``LL`` and ``LLU`` directly." msgstr "" -#: ../../c-api/intro.rst:511 +#: ../../c-api/intro.rst:567 +msgid "" +"Aliases for the types :c:type:`!long long`, :c:type:`!int32_t`, :c:type:`!" +"uint32_t`. :c:type:`!int64_t` and :c:type:`!uint64_t`, respectively. " +"Historically, these types needed compiler-specific extensions." +msgstr "" + +#: ../../c-api/intro.rst:579 +msgid "" +"Aliases for the values :c:macro:`!LLONG_MIN`, :c:macro:`!LLONG_MAX`, :c:" +"macro:`!ULLONG_MAX`, and :c:macro:`!SIZE_MAX`, respectively. Use these " +"standard names instead." +msgstr "" + +#: ../../c-api/intro.rst:583 +msgid "" +"The required header, ````, :ref:`is included ` in ``Python.h``." +msgstr "" + +#: ../../c-api/intro.rst:590 msgid "This is an alias to :c:func:`!memcpy`." msgstr "這是 :c:func:`!memcpy` 的別名。" -#: ../../c-api/intro.rst:513 +#: ../../c-api/intro.rst:592 msgid "Use :c:func:`!memcpy` directly instead." msgstr "" -#: ../../c-api/intro.rst:518 +#: ../../c-api/intro.rst:597 +msgid "" +"Size of the :c:type:`!wchar_t` type. Use ``sizeof(wchar_t)`` or " +"``WCHAR_WIDTH/8`` instead." +msgstr "" + +#: ../../c-api/intro.rst:600 +msgid "" +"The required header for the latter, ````, :ref:`is included ` in ``Python.h``." +msgstr "" + +#: ../../c-api/intro.rst:607 +msgid "" +"Defined if ``wchar_t`` can hold a Unicode character (UCS-4). Use " +"``sizeof(wchar_t) >= 4`` instead" +msgstr "" + +#: ../../c-api/intro.rst:614 msgid "This is an alias to the C99-standard ``va_copy`` function." msgstr "這是 C99 標準 ``va_copy`` 函式的別名。" -#: ../../c-api/intro.rst:520 +#: ../../c-api/intro.rst:616 msgid "" "Historically, this would use a compiler-specific method to copy a " "``va_list``." msgstr "" -#: ../../c-api/intro.rst:522 +#: ../../c-api/intro.rst:618 msgid "This is now an alias to ``va_copy``." msgstr "這現在是 ``va_copy`` 的別名。" -#: ../../c-api/intro.rst:531 +#: ../../c-api/intro.rst:627 msgid "Objects, Types and Reference Counts" msgstr "物件、型別和參照計數" -#: ../../c-api/intro.rst:535 +#: ../../c-api/intro.rst:631 msgid "" "Most Python/C API functions have one or more arguments as well as a return " "value of type :c:expr:`PyObject*`. This type is a pointer to an opaque data " @@ -821,7 +946,7 @@ msgstr "" "別物件;由於它們絕不能被釋放,因此它們通常是靜態 :c:type:`PyTypeObject` 物" "件。" -#: ../../c-api/intro.rst:546 +#: ../../c-api/intro.rst:642 msgid "" "All Python objects (even Python integers) have a :dfn:`type` and a :dfn:" "`reference count`. An object's type determines what kind of object it is (e." @@ -837,11 +962,11 @@ msgstr "" "`types`\\ )。對於每個眾所周知的型別,都有一個巨集來檢查物件是否屬於該型別;" "例如,若(且唯若)*a* 指向的物件是 Python list 時,``PyList_Check(a)`` 為真。" -#: ../../c-api/intro.rst:557 +#: ../../c-api/intro.rst:653 msgid "Reference Counts" msgstr "參照計數" -#: ../../c-api/intro.rst:559 +#: ../../c-api/intro.rst:655 msgid "" "The reference count is important because today's computers have a finite " "(and often severely limited) memory size; it counts how many different " @@ -864,7 +989,7 @@ msgstr "" "則可以依次為那些其他物件解除配置,依此類推。(此處相互參照物件的存在是個明顯" "的問題;目前,解決方案是「就不要那樣做」。)" -#: ../../c-api/intro.rst:576 +#: ../../c-api/intro.rst:672 msgid "" "Reference counts are always manipulated explicitly. The normal way is to " "use the macro :c:func:`Py_INCREF` to take a new reference to an object (i.e. " @@ -892,7 +1017,7 @@ msgstr "" "元會被使用(假設 ``sizeof(Py_ssize_t) >= sizeof(void*)``)。因此參照計數增加" "是一個簡單的操作。" -#: ../../c-api/intro.rst:592 +#: ../../c-api/intro.rst:688 msgid "" "It is not necessary to hold a :term:`strong reference` (i.e. increment the " "reference count) for every local variable that contains a pointer to an " @@ -918,7 +1043,7 @@ msgstr "" "種情況的一個重要情況是在從 Python 呼叫的擴充模組中作為引數傳遞給 C 函式的物" "件;呼叫機制保證在呼叫期間保持對每個參數的參照。" -#: ../../c-api/intro.rst:608 +#: ../../c-api/intro.rst:704 msgid "" "However, a common pitfall is to extract an object from a list and hold on to " "it for a while without taking a new reference. Some other operation might " @@ -934,7 +1059,7 @@ msgstr "" "程式碼路徑允許控制權從 :c:func:`Py_DECREF` 回歸使用者,因此幾乎任何操作都有潛" "在危險。" -#: ../../c-api/intro.rst:616 +#: ../../c-api/intro.rst:712 msgid "" "A safe approach is to always use the generic operations (functions whose " "name begins with ``PyObject_``, ``PyNumber_``, ``PySequence_`` or " @@ -949,11 +1074,11 @@ msgstr "" "計數)。這讓呼叫者有責任在處理完結果後呼叫 :c:func:`Py_DECREF`;這就成為第二" "本質。" -#: ../../c-api/intro.rst:627 +#: ../../c-api/intro.rst:723 msgid "Reference Count Details" msgstr "參照計數詳細資訊" -#: ../../c-api/intro.rst:629 +#: ../../c-api/intro.rst:725 msgid "" "The reference count behavior of functions in the Python/C API is best " "explained in terms of *ownership of references*. Ownership pertains to " @@ -978,7 +1103,7 @@ msgstr "" "照。當沒有所有權轉移時,呼叫者被稱為\\ *借用*\\ 參照。如果是\\ :term:`借用參" "照 `\\ 就不需要做任何事情。" -#: ../../c-api/intro.rst:642 +#: ../../c-api/intro.rst:738 msgid "" "Conversely, when a calling function passes in a reference to an object, " "there are two possibilities: the function *steals* a reference to the " @@ -987,7 +1112,7 @@ msgstr "" "相反地,當呼叫的函式傳入物件的參照時,有兩種可能性:函式\\ *竊取 (steal)*\\ " "物件的參照,或者沒有。" -#: ../../c-api/intro.rst:646 +#: ../../c-api/intro.rst:742 msgid "" "*Stealing a reference* means that when you pass a reference to a function, " "that function assumes that it now owns that reference. Since the new owner " @@ -995,7 +1120,7 @@ msgid "" "use that reference after the call." msgstr "" -#: ../../c-api/intro.rst:655 +#: ../../c-api/intro.rst:751 msgid "" "Few functions steal references; the two notable exceptions are :c:func:" "`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which steal a reference to " @@ -1012,7 +1137,7 @@ msgstr "" "慣,這些函式旨在竊取參照;例如,建立 tuple ``(1, 2, \"three\")`` 的程式碼可以" "如下所示(先暫時忘記錯誤處理;更好的編寫方式如下所示):" -#: ../../c-api/intro.rst:663 +#: ../../c-api/intro.rst:759 msgid "" "PyObject *t;\n" "\n" @@ -1028,7 +1153,7 @@ msgstr "" "PyTuple_SetItem(t, 1, PyLong_FromLong(2L));\n" "PyTuple_SetItem(t, 2, PyUnicode_FromString(\"three\"));" -#: ../../c-api/intro.rst:670 +#: ../../c-api/intro.rst:766 msgid "" "Here, :c:func:`PyLong_FromLong` returns a new reference which is immediately " "stolen by :c:func:`PyTuple_SetItem`. When you want to keep using an object " @@ -1039,7 +1164,7 @@ msgstr "" "`PyTuple_SetItem` 竊取。如果你想繼續使用一個物件,儘管對它的參照將被竊取,請" "在呼叫參照竊取函式之前使用 :c:func:`Py_INCREF` 來取得另一個參照。" -#: ../../c-api/intro.rst:675 +#: ../../c-api/intro.rst:771 msgid "" "Incidentally, :c:func:`PyTuple_SetItem` is the *only* way to set tuple " "items; :c:func:`PySequence_SetItem` and :c:func:`PyObject_SetItem` refuse to " @@ -1051,7 +1176,7 @@ msgstr "" "tuple 是一種不可變 (immutable) 的資料型別。你應該只對你自己建立的 tuple 使" "用 :c:func:`PyTuple_SetItem`。" -#: ../../c-api/intro.rst:680 +#: ../../c-api/intro.rst:776 msgid "" "Equivalent code for populating a list can be written using :c:func:" "`PyList_New` and :c:func:`PyList_SetItem`." @@ -1059,7 +1184,7 @@ msgstr "" "可以使用 :c:func:`PyList_New` 和 :c:func:`PyList_SetItem` 編寫用於填充列表的" "等效程式碼。" -#: ../../c-api/intro.rst:683 +#: ../../c-api/intro.rst:779 msgid "" "However, in practice, you will rarely use these ways of creating and " "populating a tuple or list. There's a generic function, :c:func:" @@ -1072,7 +1197,7 @@ msgstr "" "string` 引導。例如上面的兩個程式碼可以用以下程式碼替換(它還負責了錯誤檢" "查): ::" -#: ../../c-api/intro.rst:689 +#: ../../c-api/intro.rst:785 msgid "" "PyObject *tuple, *list;\n" "\n" @@ -1084,7 +1209,7 @@ msgstr "" "tuple = Py_BuildValue(\"(iis)\", 1, 2, \"three\");\n" "list = Py_BuildValue(\"[iis]\", 1, 2, \"three\");" -#: ../../c-api/intro.rst:694 +#: ../../c-api/intro.rst:790 msgid "" "It is much more common to use :c:func:`PyObject_SetItem` and friends with " "items whose references you are only borrowing, like arguments that were " @@ -1099,7 +1224,7 @@ msgstr "" "穩健,因為你不取得新的一個參照就可以放棄參照(「讓它被竊取」)。例如,此函式" "將 list(實際上是任何可變序列)的所有項目設定於給定項目:" -#: ../../c-api/intro.rst:701 +#: ../../c-api/intro.rst:797 msgid "" "int\n" "set_all(PyObject *target, PyObject *item)\n" @@ -1143,7 +1268,7 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/intro.rst:724 +#: ../../c-api/intro.rst:820 msgid "" "The situation is slightly different for function return values. While " "passing a reference to most functions does not change your ownership " @@ -1161,7 +1286,7 @@ msgstr "" "照的通用函式,如 :c:func:`PyObject_GetItem` 和 :c:func:`PySequence_GetItem`," "總是回傳一個新的參照(呼叫者成為參照的所有者)。" -#: ../../c-api/intro.rst:733 +#: ../../c-api/intro.rst:829 msgid "" "It is important to realize that whether you own a reference returned by a " "function depends on which function you call only --- *the plumage* (the type " @@ -1177,7 +1302,7 @@ msgstr "" "但如果你使用 :c:func:`PySequence_GetItem` 從同一 list 中取得相同的項目(且恰" "好使用完全相同的引數),你確實會擁有對回傳物件的參照。" -#: ../../c-api/intro.rst:745 +#: ../../c-api/intro.rst:841 msgid "" "Here is an example of how you could write a function that computes the sum " "of the items in a list of integers; once using :c:func:`PyList_GetItem`, " @@ -1186,7 +1311,7 @@ msgstr "" "以下是一個範例,說明如何編寫函式來計算一個整數 list 中項目的總和;一次使用 :" "c:func:`PyList_GetItem`,一次使用 :c:func:`PySequence_GetItem`: ::" -#: ../../c-api/intro.rst:749 +#: ../../c-api/intro.rst:845 msgid "" "long\n" "sum_list(PyObject *list)\n" @@ -1232,7 +1357,7 @@ msgstr "" " return total;\n" "}" -#: ../../c-api/intro.rst:775 +#: ../../c-api/intro.rst:871 msgid "" "long\n" "sum_sequence(PyObject *sequence)\n" @@ -1290,11 +1415,11 @@ msgstr "" " return total;\n" "}" -#: ../../c-api/intro.rst:809 +#: ../../c-api/intro.rst:905 msgid "Types" msgstr "型別" -#: ../../c-api/intro.rst:811 +#: ../../c-api/intro.rst:907 msgid "" "There are few other data types that play a significant role in the Python/C " "API; most are simple C types such as :c:expr:`int`, :c:expr:`long`, :c:expr:" @@ -1309,7 +1434,7 @@ msgstr "" "一些結構型別被用於描述用於列出模組所匯出的函式或新物件型別的資料屬性的靜態" "表,其他則用於描述複數的值。這些將與使用它們的函式一起討論。" -#: ../../c-api/intro.rst:821 +#: ../../c-api/intro.rst:917 msgid "" "A signed integral type such that ``sizeof(Py_ssize_t) == sizeof(size_t)``. " "C99 doesn't define such a thing directly (size_t is an unsigned integral " @@ -1320,11 +1445,11 @@ msgstr "" "有直接定義這樣的東西(size_t 是無符號整數型別)。有關詳細資訊,請參閱 :pep:" "`353`。 ``PY_SSIZE_T_MAX`` 是 :c:type:`Py_ssize_t` 型別的最大正值。" -#: ../../c-api/intro.rst:830 +#: ../../c-api/intro.rst:926 msgid "Exceptions" msgstr "例外" -#: ../../c-api/intro.rst:832 +#: ../../c-api/intro.rst:928 msgid "" "The Python programmer only needs to deal with exceptions if specific error " "handling is required; unhandled exceptions are automatically propagated to " @@ -1336,7 +1461,7 @@ msgstr "" "給呼叫者,然後傳遞給呼叫者的呼叫者,依此類推,直到它們到達頂層直譯器,在那裡" "它們透過堆疊回溯 (stack trace) 回報給使用者。" -#: ../../c-api/intro.rst:840 +#: ../../c-api/intro.rst:936 msgid "" "For C programmers, however, error checking always has to be explicit. All " "functions in the Python/C API can raise exceptions, unless an explicit claim " @@ -1358,7 +1483,7 @@ msgstr "" "確的錯誤指示器或者有不明確的回傳值,而需要使用 :c:func:`PyErr_Occurred` 明確" "測試錯誤。這些例外都會被明確地記錄於文件。" -#: ../../c-api/intro.rst:855 +#: ../../c-api/intro.rst:951 msgid "" "Exception state is maintained in per-thread storage (this is equivalent to " "using global storage in an unthreaded application). A thread can be in one " @@ -1377,7 +1502,7 @@ msgstr "" "func:`PyErr_SetString` 是最常見的(儘管不是最通用的)設定例外狀態的函式,而 :" "c:func:`PyErr_Clear` 是用來清除例外狀態。" -#: ../../c-api/intro.rst:865 +#: ../../c-api/intro.rst:961 msgid "" "The full exception state consists of three objects (all of which can be " "``NULL``): the exception type, the corresponding exception value, and the " @@ -1396,7 +1521,7 @@ msgstr "" "達 Python 位元組碼直譯器的主迴圈,該迴圈負責將它傳遞給 ``sys.exc_info()`` 和" "其系列函式。" -#: ../../c-api/intro.rst:877 +#: ../../c-api/intro.rst:973 msgid "" "Note that starting with Python 1.5, the preferred, thread-safe way to access " "the exception state from Python code is to call the function :func:`sys." @@ -1416,7 +1541,7 @@ msgstr "" "式碼中的常見錯誤,這些錯誤是由看似無辜的函式覆蓋了正在處理的例外而引起的;它" "還替回溯中被堆疊框 (stack frame) 參照的物件減少了通常不需要的生命週期延長。" -#: ../../c-api/intro.rst:888 +#: ../../c-api/intro.rst:984 msgid "" "As a general principle, a function that calls another function to perform " "some task should check whether the called function raised an exception, and " @@ -1431,7 +1556,7 @@ msgstr "" "並回傳一個錯誤指示符,但它\\ *不應該*\\ 設定另一個例外 --- 這將覆蓋剛剛引發的" "例外,並丟失關於錯誤確切原因的重要資訊。" -#: ../../c-api/intro.rst:897 +#: ../../c-api/intro.rst:993 msgid "" "A simple example of detecting exceptions and passing them on is shown in " "the :c:func:`!sum_sequence` example above. It so happens that this example " @@ -1443,7 +1568,7 @@ msgstr "" "巧這個例子在檢測到錯誤時不需要清理任何擁有的參照。以下範例函式展示了一些錯誤" "清理。首先,為了提醒你為什麼喜歡 Python,我們展示了等效的 Python 程式碼: ::" -#: ../../c-api/intro.rst:903 +#: ../../c-api/intro.rst:999 msgid "" "def incr_item(dict, key):\n" " try:\n" @@ -1459,11 +1584,11 @@ msgstr "" " item = 0\n" " dict[key] = item + 1" -#: ../../c-api/intro.rst:912 +#: ../../c-api/intro.rst:1008 msgid "Here is the corresponding C code, in all its glory::" msgstr "這是相應的 C 程式碼:" -#: ../../c-api/intro.rst:914 +#: ../../c-api/intro.rst:1010 msgid "" "int\n" "incr_item(PyObject *dict, PyObject *key)\n" @@ -1509,7 +1634,7 @@ msgid "" "}" msgstr "" -#: ../../c-api/intro.rst:964 +#: ../../c-api/intro.rst:1060 msgid "" "This example represents an endorsed use of the ``goto`` statement in C! It " "illustrates the use of :c:func:`PyErr_ExceptionMatches` and :c:func:" @@ -1528,11 +1653,11 @@ msgstr "" "於保存擁有的參照的變數被初始化為 ``NULL`` 以使其能夠順利作用;同樣地,回傳值" "被初始化為 ``-1``\\ (失敗),並且僅在最後一次呼叫成功後才設定為成功。" -#: ../../c-api/intro.rst:978 +#: ../../c-api/intro.rst:1074 msgid "Embedding Python" msgstr "嵌入式Python" -#: ../../c-api/intro.rst:980 +#: ../../c-api/intro.rst:1076 msgid "" "The one important task that only embedders (as opposed to extension writers) " "of the Python interpreter have to worry about is the initialization, and " @@ -1542,7 +1667,7 @@ msgstr "" "只有 Python 直譯器的嵌入者(而不是擴充編寫者)需要擔心的一項重要任務是 " "Python 直譯器的初始化與完成階段。直譯器的大部分功能只能在直譯器初始化後使用。" -#: ../../c-api/intro.rst:993 +#: ../../c-api/intro.rst:1089 msgid "" "The basic initialization function is :c:func:`Py_Initialize`. This " "initializes the table of loaded modules, and creates the fundamental " @@ -1553,7 +1678,7 @@ msgstr "" "立基礎模組 :mod:`builtins`、:mod:`__main__` 和 :mod:`sys`。它還會初始化模組搜" "索路徑 (``sys.path``)。" -#: ../../c-api/intro.rst:998 +#: ../../c-api/intro.rst:1094 msgid "" ":c:func:`Py_Initialize` does not set the \"script argument list\" (``sys." "argv``). If this variable is needed by Python code that will be executed " @@ -1565,7 +1690,7 @@ msgstr "" "`PyConfig.argv` 和 :c:member:`PyConfig.parse_argv`,請見 :ref:`Python 初始化" "配置 `。" -#: ../../c-api/intro.rst:1003 +#: ../../c-api/intro.rst:1099 msgid "" "On most systems (in particular, on Unix and Windows, although the details " "are slightly different), :c:func:`Py_Initialize` calculates the module " @@ -1583,7 +1708,7 @@ msgstr "" "file:`python` 的可執行檔案,並在其父目錄中查找一個名為 :file:`lib/python{X.Y}" "` 的目錄的相對位置。" -#: ../../c-api/intro.rst:1012 +#: ../../c-api/intro.rst:1108 msgid "" "For instance, if the Python executable is found in :file:`/usr/local/bin/" "python`, it will assume that the libraries are in :file:`/usr/local/lib/" @@ -1600,24 +1725,18 @@ msgstr "" "`PYTHONHOME`,或者透過設定 :envvar:`PYTHONPATH` 在標準路徑前面插入額外的目" "錄。" -#: ../../c-api/intro.rst:1026 +#: ../../c-api/intro.rst:1116 msgid "" "The embedding application can steer the search by setting :c:member:" "`PyConfig.program_name` *before* calling :c:func:`Py_InitializeFromConfig`. " "Note that :envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` " -"is still inserted in front of the standard path. An application that " -"requires total control has to provide its own implementation of :c:func:" -"`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and :c:" -"func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`)." +"is still inserted in front of the standard path." msgstr "" "嵌入的應用程式可以透過在呼叫 :c:func:`Py_InitializeFromConfig` *之前*\\ 設" "定 :c:member:`PyConfig.program_name` 來引導搜尋。請注意 :envvar:`PYTHONHOME` " -"仍然覆蓋它並且 :envvar:`PYTHONPATH` 仍然插入在標準路徑的前面。需要完全控制權" -"的應用程式必須實作自己的 :c:func:`Py_GetPath`、:c:func:`Py_GetPrefix`、:c:" -"func:`Py_GetExecPrefix` 和 :c:func:`Py_GetProgramFullPath`\\(全部定義在 :" -"file:`Modules/getpath.c`)。" +"仍然覆蓋它並且 :envvar:`PYTHONPATH` 仍然插入在標準路徑的前面。" -#: ../../c-api/intro.rst:1037 +#: ../../c-api/intro.rst:1124 msgid "" "Sometimes, it is desirable to \"uninitialize\" Python. For instance, the " "application may want to start over (make another call to :c:func:" @@ -1638,11 +1757,11 @@ msgstr "" "`Py_FinalizeEx` *不會*\\ 釋放由 Python 直譯器分配的所有記憶體,例如目前無法釋" "放被擴充模組所分配的記憶體。" -#: ../../c-api/intro.rst:1051 +#: ../../c-api/intro.rst:1138 msgid "Debugging Builds" msgstr "除錯建置" -#: ../../c-api/intro.rst:1053 +#: ../../c-api/intro.rst:1140 msgid "" "Python can be built with several macros to enable extra checks of the " "interpreter and extension modules. These checks tend to add a large amount " @@ -1651,7 +1770,7 @@ msgstr "" "Python 可以在建置時使用多個巨集來啟用對直譯器和擴充模組的額外檢查,這些檢查往" "往會在執行環境 (runtime) 增加大量開銷 (overhead),因此預設情況下不啟用它們。" -#: ../../c-api/intro.rst:1057 +#: ../../c-api/intro.rst:1144 msgid "" "A full list of the various types of debugging builds is in the file :file:" "`Misc/SpecialBuilds.txt` in the Python source distribution. Builds are " @@ -1664,31 +1783,38 @@ msgstr "" "錯構置的完整列表,為支援追蹤參照計數、為記憶體分配器除錯或對主直譯器迴圈進行" "低階分析的建置。本節的其餘部分將僅描述最常用的建置。" -#: ../../c-api/intro.rst:1065 +#: ../../c-api/intro.rst:1152 msgid "" "Compiling the interpreter with the :c:macro:`!Py_DEBUG` macro defined " "produces what is generally meant by :ref:`a debug build of Python `. :c:macro:`!Py_DEBUG` is enabled in the Unix build by adding :option:" -"`--with-pydebug` to the :file:`./configure` command. It is also implied by " -"the presence of the not-Python-specific :c:macro:`!_DEBUG` macro. When :c:" -"macro:`!Py_DEBUG` is enabled in the Unix build, compiler optimization is " -"disabled." +"build>`." msgstr "" -"使用定義的 :c:macro:`!Py_DEBUG` 巨集編譯直譯器會生成 :ref:`Python 的除錯建置 " -"`。 :c:macro:`!Py_DEBUG` 在 Unix 建置中要透過在 :file:`./" -"configure` 命令中加入 :option:`--with-pydebug` 來啟用。非 Python 限定的 :c:" -"macro:`!_DEBUG` 巨集的存在也暗示了這一點。當 :c:macro:`!Py_DEBUG` 在 Unix 建" -"置中啟用時,編譯器最佳化會被禁用。" -#: ../../c-api/intro.rst:1073 +#: ../../c-api/intro.rst:1155 +msgid "" +"On Unix, :c:macro:`!Py_DEBUG` can be enabled by adding :option:`--with-" +"pydebug` to the :file:`./configure` command. This will also disable compiler " +"optimization." +msgstr "" + +#: ../../c-api/intro.rst:1158 +msgid "" +"On Windows, selecting a debug build (e.g., by passing the :option:`-d` " +"option to :file:`PCbuild/build.bat`) automatically enables :c:macro:`!" +"Py_DEBUG`. Additionally, the presence of the not-Python-specific :c:macro:`!" +"_DEBUG` macro, when defined by the compiler, will also implicitly enable :c:" +"macro:`!Py_DEBUG`." +msgstr "" + +#: ../../c-api/intro.rst:1163 msgid "" "In addition to the reference count debugging described below, extra checks " -"are performed, see :ref:`Python Debug Build `." +"are performed. See :ref:`Python Debug Build ` for more details." msgstr "" -"除了下面描述的參照計數除錯之外,還會執行額外的檢查,請參閱 :ref:`Python 除錯" -"建置 `。" +"除了下面描述的參照計數除錯之外,還會執行額外的檢查。更多細節請參" +"閱 :ref:`Python 除錯建置 `。" -#: ../../c-api/intro.rst:1076 +#: ../../c-api/intro.rst:1166 msgid "" "Defining ``Py_TRACE_REFS`` enables reference tracing (see the :option:" "`configure --with-trace-refs option <--with-trace-refs>`). When defined, a " @@ -1703,7 +1829,7 @@ msgstr "" "list)。總配置量也會被追蹤。退出時將印出所有現存的參照。(在互動模式下,這會發" "生在直譯器執行的每個陳述式之後。)" -#: ../../c-api/intro.rst:1083 +#: ../../c-api/intro.rst:1173 msgid "" "Please refer to :file:`Misc/SpecialBuilds.txt` in the Python source " "distribution for more detailed information." @@ -1711,11 +1837,11 @@ msgstr "" "有關更多詳細資訊,請參閱 Python 原始碼發布版中的 :file:`Misc/SpecialBuilds." "txt`。" -#: ../../c-api/intro.rst:1090 +#: ../../c-api/intro.rst:1180 msgid "Recommended third party tools" msgstr "建議的第三方工具" -#: ../../c-api/intro.rst:1092 +#: ../../c-api/intro.rst:1182 msgid "" "The following third party tools offer both simpler and more sophisticated " "approaches to creating C, C++ and Rust extensions for Python:" @@ -1723,39 +1849,39 @@ msgstr "" "以下第三方工具提供了更簡單且更細緻的方法來為 Python 建立 C、C++ 和 Rust 擴充" "模組:" -#: ../../c-api/intro.rst:1095 +#: ../../c-api/intro.rst:1185 msgid "`Cython `_" msgstr "`Cython `_" -#: ../../c-api/intro.rst:1096 +#: ../../c-api/intro.rst:1186 msgid "`cffi `_" msgstr "`cffi `_" -#: ../../c-api/intro.rst:1097 +#: ../../c-api/intro.rst:1187 msgid "`HPy `_" msgstr "`HPy `_" -#: ../../c-api/intro.rst:1098 +#: ../../c-api/intro.rst:1188 msgid "`nanobind `_ (C++)" msgstr "`nanobind `_ (C++)" -#: ../../c-api/intro.rst:1099 +#: ../../c-api/intro.rst:1189 msgid "`Numba `_" msgstr "`Numba `_" -#: ../../c-api/intro.rst:1100 +#: ../../c-api/intro.rst:1190 msgid "`pybind11 `_ (C++)" msgstr "`pybind11 `_ (C++)" -#: ../../c-api/intro.rst:1101 +#: ../../c-api/intro.rst:1191 msgid "`PyO3 `_ (Rust)" msgstr "`PyO3 `_ (Rust)" -#: ../../c-api/intro.rst:1102 +#: ../../c-api/intro.rst:1192 msgid "`SWIG `_" msgstr "`SWIG `_" -#: ../../c-api/intro.rst:1104 +#: ../../c-api/intro.rst:1194 msgid "" "Using tools such as these can help avoid writing code that is tightly bound " "to a particular version of CPython, avoid reference counting errors, and " @@ -1766,7 +1892,7 @@ msgid "" "sources." msgstr "" -#: ../../c-api/intro.rst:1111 +#: ../../c-api/intro.rst:1201 msgid "" "These projects are not supported by the same people who maintain Python, and " "issues need to be raised with the projects directly. Remember to check that " @@ -1774,142 +1900,153 @@ msgid "" "outdated." msgstr "" -#: ../../c-api/intro.rst:1118 +#: ../../c-api/intro.rst:1208 msgid "" "`Python Packaging User Guide: Binary Extensions `_" msgstr "" -#: ../../c-api/intro.rst:1119 +#: ../../c-api/intro.rst:1209 msgid "" "The Python Packaging User Guide not only covers several available tools that " "simplify the creation of binary extensions, but also discusses the various " "reasons why creating an extension module may be desirable in the first place." msgstr "" -#: ../../c-api/intro.rst:533 +#: ../../c-api/intro.rst:629 msgid "object" msgstr "object(物件)" -#: ../../c-api/intro.rst:533 +#: ../../c-api/intro.rst:629 msgid "type" msgstr "type(型別)" -#: ../../c-api/intro.rst:572 +#: ../../c-api/intro.rst:668 msgid "Py_INCREF (C function)" msgstr "Py_INCREF(C 函式)" -#: ../../c-api/intro.rst:572 +#: ../../c-api/intro.rst:668 msgid "Py_DECREF (C function)" msgstr "Py_DECREF(C 函式)" -#: ../../c-api/intro.rst:651 +#: ../../c-api/intro.rst:747 msgid "PyList_SetItem (C function)" msgstr "PyList_SetItem(C 函式)" -#: ../../c-api/intro.rst:651 +#: ../../c-api/intro.rst:747 msgid "PyTuple_SetItem (C function)" msgstr "PyTuple_SetItem(C 函式)" -#: ../../c-api/intro.rst:722 +#: ../../c-api/intro.rst:818 msgid "set_all()" msgstr "set_all()" -#: ../../c-api/intro.rst:741 +#: ../../c-api/intro.rst:837 msgid "PyList_GetItem (C function)" msgstr "PyList_GetItem(C 函式)" -#: ../../c-api/intro.rst:741 +#: ../../c-api/intro.rst:837 msgid "PySequence_GetItem (C function)" msgstr "PySequence_GetItem(C 函式)" -#: ../../c-api/intro.rst:771 +#: ../../c-api/intro.rst:867 msgid "sum_list()" msgstr "sum_list()" -#: ../../c-api/intro.rst:803 ../../c-api/intro.rst:895 +#: ../../c-api/intro.rst:899 ../../c-api/intro.rst:991 msgid "sum_sequence()" msgstr "sum_sequence()" -#: ../../c-api/intro.rst:838 +#: ../../c-api/intro.rst:934 msgid "PyErr_Occurred (C function)" msgstr "PyErr_Occurred(C 函式)" -#: ../../c-api/intro.rst:851 +#: ../../c-api/intro.rst:947 msgid "PyErr_SetString (C function)" msgstr "PyErr_SetString(C 函式)" -#: ../../c-api/intro.rst:851 ../../c-api/intro.rst:959 +#: ../../c-api/intro.rst:947 ../../c-api/intro.rst:1055 msgid "PyErr_Clear (C function)" msgstr "PyErr_Clear(C 函式)" -#: ../../c-api/intro.rst:875 +#: ../../c-api/intro.rst:971 msgid "exc_info (in module sys)" msgstr "exc_info (sys 模組中)" -#: ../../c-api/intro.rst:910 ../../c-api/intro.rst:957 +#: ../../c-api/intro.rst:1006 ../../c-api/intro.rst:1053 msgid "incr_item()" msgstr "incr_item()" -#: ../../c-api/intro.rst:959 +#: ../../c-api/intro.rst:1055 msgid "PyErr_ExceptionMatches (C function)" msgstr "PyErr_ExceptionMatches(C 函式)" -#: ../../c-api/intro.rst:959 +#: ../../c-api/intro.rst:1055 msgid "Py_XDECREF (C function)" msgstr "Py_XDECREF(C 函式)" -#: ../../c-api/intro.rst:985 +#: ../../c-api/intro.rst:1081 msgid "Py_Initialize (C function)" msgstr "Py_Initialize(C 函式)" -#: ../../c-api/intro.rst:985 +#: ../../c-api/intro.rst:1081 msgid "module" msgstr "module(模組)" -#: ../../c-api/intro.rst:985 +#: ../../c-api/intro.rst:1081 msgid "builtins" msgstr "builtins(內建)" -#: ../../c-api/intro.rst:985 +#: ../../c-api/intro.rst:1081 msgid "__main__" msgstr "__main__" -#: ../../c-api/intro.rst:985 +#: ../../c-api/intro.rst:1081 msgid "sys" msgstr "sys" -#: ../../c-api/intro.rst:985 +#: ../../c-api/intro.rst:1081 msgid "search" msgstr "search(搜尋)" -#: ../../c-api/intro.rst:985 +#: ../../c-api/intro.rst:1081 msgid "path" msgstr "path(路徑)" -#: ../../c-api/intro.rst:985 +#: ../../c-api/intro.rst:1081 msgid "path (in module sys)" msgstr "path(sys 模組中)" -#: ../../c-api/intro.rst:1020 -msgid "Py_GetPath (C function)" -msgstr "Py_GetPath(C 函式)" +#: ../../c-api/intro.rst:1122 +msgid "Py_IsInitialized (C function)" +msgstr "Py_IsInitialized(C 函式)" + +#~ msgid "" +#~ "Compiling the interpreter with the :c:macro:`!Py_DEBUG` macro defined " +#~ "produces what is generally meant by :ref:`a debug build of Python `. :c:macro:`!Py_DEBUG` is enabled in the Unix build by adding :" +#~ "option:`--with-pydebug` to the :file:`./configure` command. It is also " +#~ "implied by the presence of the not-Python-specific :c:macro:`!_DEBUG` " +#~ "macro. When :c:macro:`!Py_DEBUG` is enabled in the Unix build, compiler " +#~ "optimization is disabled." +#~ msgstr "" +#~ "使用定義的 :c:macro:`!Py_DEBUG` 巨集編譯直譯器會生成 :ref:`Python 的除錯建" +#~ "置 `。 :c:macro:`!Py_DEBUG` 在 Unix 建置中要透過在 :file:`./" +#~ "configure` 命令中加入 :option:`--with-pydebug` 來啟用。非 Python 限定的 :" +#~ "c:macro:`!_DEBUG` 巨集的存在也暗示了這一點。當 :c:macro:`!Py_DEBUG` 在 " +#~ "Unix 建置中啟用時,編譯器最佳化會被禁用。" -#: ../../c-api/intro.rst:1020 -msgid "Py_GetPrefix (C function)" -msgstr "Py_GetPrefix(C 函式)" +#~ msgid "Py_GetPath (C function)" +#~ msgstr "Py_GetPath(C 函式)" -#: ../../c-api/intro.rst:1020 -msgid "Py_GetExecPrefix (C function)" -msgstr "Py_GetExecPrefix(C 函式)" +#~ msgid "Py_GetPrefix (C function)" +#~ msgstr "Py_GetPrefix(C 函式)" -#: ../../c-api/intro.rst:1020 -msgid "Py_GetProgramFullPath (C function)" -msgstr "Py_GetProgramFullPath(C 函式)" +#~ msgid "Py_GetExecPrefix (C function)" +#~ msgstr "Py_GetExecPrefix(C 函式)" -#: ../../c-api/intro.rst:1035 -msgid "Py_IsInitialized (C function)" -msgstr "Py_IsInitialized(C 函式)" +#~ msgid "Py_GetProgramFullPath (C function)" +#~ msgstr "Py_GetProgramFullPath(C 函式)" #~ msgid "" #~ "This is a :term:`soft deprecated` alias to :c:func:`!memcpy`. Use :c:func:" diff --git a/c-api/iter.po b/c-api/iter.po index 37c2a713c78..886acb0c3df 100644 --- a/c-api/iter.po +++ b/c-api/iter.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-07-01 03:44+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -94,6 +94,6 @@ msgstr "" #: ../../c-api/iter.rst:57 msgid "" -"``PYGEN_ERROR`` if iterator has raised and exception. *presult* is set to " +"``PYGEN_ERROR`` if iterator has raised an exception. *presult* is set to " "``NULL``." -msgstr "如果疊代器引發例外則為 ``PYGEN_ERROR``。 *presult* 被設定為 ``NULL``。" +msgstr "如果疊代器引發例外則為 ``PYGEN_ERROR``。 *presult* 被設定為 ``NULL``。" \ No newline at end of file diff --git a/c-api/long.po b/c-api/long.po index 468517062a5..7de46ac953b 100644 --- a/c-api/long.po +++ b/c-api/long.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-06 15:51+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:06+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -64,7 +64,7 @@ msgstr "" #: ../../c-api/long.rst:45 msgid "" "CPython keeps an array of integer objects for all integers between ``-5`` " -"and ``256``. When you create an int in that range you actually just get " +"and ``1024``. When you create an int in that range you actually just get " "back a reference to the existing object." msgstr "" @@ -819,8 +819,8 @@ msgid "Get the native layout of Python :class:`int` objects." msgstr "" #: ../../c-api/long.rst:728 -msgid "See the :c:struct:`PyLongLayout` structure." -msgstr "請見 :c:struct:`PyLongLayout` 結構。" +msgid "See the :c:type:`PyLongLayout` structure." +msgstr "請見 :c:type:`PyLongLayout` 結構。" #: ../../c-api/long.rst:730 msgid "" @@ -877,8 +877,8 @@ msgstr "" #: ../../c-api/long.rst:770 msgid "" -"*export_long* must point to a :c:struct:`PyLongExport` structure allocated " -"by the caller. It must not be ``NULL``." +"*export_long* must point to a :c:type:`PyLongExport` structure allocated by " +"the caller. It must not be ``NULL``." msgstr "" #: ../../c-api/long.rst:773 @@ -962,8 +962,8 @@ msgstr "" #: ../../c-api/long.rst:827 msgid "" "Digits must be in the range [``0``; ``(1 << bits_per_digit) - 1``] (where " -"the :c:struct:`~PyLongLayout.bits_per_digit` is the number of bits per " -"digit). Any unused most significant digits must be set to ``0``." +"the :c:type:`~PyLongLayout.bits_per_digit` is the number of bits per digit). " +"Any unused most significant digits must be set to ``0``." msgstr "" #: ../../c-api/long.rst:832 diff --git a/c-api/memory.po b/c-api/memory.po index 7686b4d1332..54a18cd1707 100644 --- a/c-api/memory.po +++ b/c-api/memory.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-11 00:43+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:06+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,11 +22,11 @@ msgstr "" msgid "Memory Management" msgstr "記憶體管理" -#: ../../c-api/memory.rst:17 +#: ../../c-api/memory.rst:13 msgid "Overview" msgstr "總覽" -#: ../../c-api/memory.rst:19 +#: ../../c-api/memory.rst:15 msgid "" "Memory management in Python involves a private heap containing all Python " "objects and data structures. The management of this private heap is ensured " @@ -35,7 +35,7 @@ msgid "" "aspects, like sharing, segmentation, preallocation or caching." msgstr "" -#: ../../c-api/memory.rst:25 +#: ../../c-api/memory.rst:21 msgid "" "At the lowest level, a raw memory allocator ensures that there is enough " "room in the private heap for storing all Python-related data by interacting " @@ -49,7 +49,7 @@ msgid "" "but ensures that the latter operate within the bounds of the private heap." msgstr "" -#: ../../c-api/memory.rst:36 +#: ../../c-api/memory.rst:32 msgid "" "It is important to understand that the management of the Python heap is " "performed by the interpreter itself and that the user has no control over " @@ -59,7 +59,7 @@ msgid "" "the Python/C API functions listed in this document." msgstr "" -#: ../../c-api/memory.rst:49 +#: ../../c-api/memory.rst:45 msgid "" "To avoid memory corruption, extension writers should never try to operate on " "Python objects with the functions exported by the C library: :c:func:" @@ -71,7 +71,7 @@ msgid "" "in the following example::" msgstr "" -#: ../../c-api/memory.rst:58 +#: ../../c-api/memory.rst:54 msgid "" "PyObject *res;\n" "char *buf = (char *) malloc(BUFSIZ); /* for I/O */\n" @@ -84,14 +84,14 @@ msgid "" "return res;" msgstr "" -#: ../../c-api/memory.rst:68 +#: ../../c-api/memory.rst:64 msgid "" "In this example, the memory request for the I/O buffer is handled by the C " "library allocator. The Python memory manager is involved only in the " "allocation of the bytes object returned as a result." msgstr "" -#: ../../c-api/memory.rst:72 +#: ../../c-api/memory.rst:68 msgid "" "In most situations, however, it is recommended to allocate memory from the " "Python heap specifically because the latter is under control of the Python " @@ -109,24 +109,24 @@ msgid "" "escapes the Python memory manager." msgstr "" -#: ../../c-api/memory.rst:88 +#: ../../c-api/memory.rst:84 msgid "" "The :envvar:`PYTHONMALLOC` environment variable can be used to configure the " "memory allocators used by Python." msgstr "" -#: ../../c-api/memory.rst:91 +#: ../../c-api/memory.rst:87 msgid "" "The :envvar:`PYTHONMALLOCSTATS` environment variable can be used to print " "statistics of the :ref:`pymalloc memory allocator ` every time a " "new pymalloc object arena is created, and on shutdown." msgstr "" -#: ../../c-api/memory.rst:96 +#: ../../c-api/memory.rst:92 msgid "Allocator Domains" msgstr "" -#: ../../c-api/memory.rst:100 +#: ../../c-api/memory.rst:96 msgid "" "All allocating functions belong to one of three different \"domains\" (see " "also :c:type:`PyMemAllocatorDomain`). These domains represent different " @@ -139,11 +139,11 @@ msgid "" "memory allocated using :c:func:`PyMem_Malloc`." msgstr "" -#: ../../c-api/memory.rst:109 +#: ../../c-api/memory.rst:105 msgid "The three allocation domains are:" msgstr "" -#: ../../c-api/memory.rst:111 +#: ../../c-api/memory.rst:107 msgid "" "Raw domain: intended for allocating memory for general-purpose memory " "buffers where the allocation *must* go to the system allocator or where the " @@ -152,7 +152,7 @@ msgid "" "memoryinterface>`." msgstr "" -#: ../../c-api/memory.rst:116 +#: ../../c-api/memory.rst:112 msgid "" "\"Mem\" domain: intended for allocating memory for Python buffers and " "general-purpose memory buffers where the allocation must be performed with " @@ -160,14 +160,14 @@ msgid "" "private heap. See :ref:`Memory Interface `." msgstr "" -#: ../../c-api/memory.rst:121 +#: ../../c-api/memory.rst:117 msgid "" "Object domain: intended for allocating memory for Python objects. The memory " "is taken from the Python private heap. See :ref:`Object allocators " "`." msgstr "" -#: ../../c-api/memory.rst:126 +#: ../../c-api/memory.rst:122 msgid "" "The :term:`free-threaded ` build requires that only Python " "objects are allocated using the \"object\" domain and that all Python " @@ -175,29 +175,29 @@ msgid "" "versions, where this was only a best practice and not a hard requirement." msgstr "" -#: ../../c-api/memory.rst:130 +#: ../../c-api/memory.rst:126 msgid "" "For example, buffers (non-Python objects) should be allocated using :c:func:" "`PyMem_Malloc`, :c:func:`PyMem_RawMalloc`, or :c:func:`malloc`, but not :c:" "func:`PyObject_Malloc`." msgstr "" -#: ../../c-api/memory.rst:133 +#: ../../c-api/memory.rst:129 msgid "See :ref:`Memory Allocation APIs `." msgstr "" -#: ../../c-api/memory.rst:139 +#: ../../c-api/memory.rst:135 msgid "Raw Memory Interface" msgstr "" -#: ../../c-api/memory.rst:141 +#: ../../c-api/memory.rst:137 msgid "" "The following function sets are wrappers to the system allocator. These " "functions are thread-safe, so a :term:`thread state` does not need to be :" "term:`attached `." msgstr "" -#: ../../c-api/memory.rst:145 +#: ../../c-api/memory.rst:141 msgid "" "The :ref:`default raw memory allocator ` uses the " "following functions: :c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` " @@ -205,63 +205,63 @@ msgid "" "requesting zero bytes." msgstr "" -#: ../../c-api/memory.rst:154 ../../c-api/memory.rst:232 -#: ../../c-api/memory.rst:365 +#: ../../c-api/memory.rst:150 ../../c-api/memory.rst:228 +#: ../../c-api/memory.rst:361 msgid "" "Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the " "allocated memory, or ``NULL`` if the request fails." msgstr "" -#: ../../c-api/memory.rst:157 +#: ../../c-api/memory.rst:153 msgid "" "Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, " "as if ``PyMem_RawMalloc(1)`` had been called instead. The memory will not " "have been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:164 ../../c-api/memory.rst:242 -#: ../../c-api/memory.rst:375 +#: ../../c-api/memory.rst:160 ../../c-api/memory.rst:238 +#: ../../c-api/memory.rst:371 msgid "" "Allocates *nelem* elements each of size *elsize* bytes and returns a pointer " "of type :c:expr:`void*` to the allocated memory, or ``NULL`` if the request " "fails. The memory is initialized to zeros." msgstr "" -#: ../../c-api/memory.rst:168 +#: ../../c-api/memory.rst:164 msgid "" "Requesting zero elements or elements of size zero bytes returns a distinct " "non-``NULL`` pointer if possible, as if ``PyMem_RawCalloc(1, 1)`` had been " "called instead." msgstr "" -#: ../../c-api/memory.rst:177 ../../c-api/memory.rst:255 -#: ../../c-api/memory.rst:388 +#: ../../c-api/memory.rst:173 ../../c-api/memory.rst:251 +#: ../../c-api/memory.rst:384 msgid "" "Resizes the memory block pointed to by *p* to *n* bytes. The contents will " "be unchanged to the minimum of the old and the new sizes." msgstr "" -#: ../../c-api/memory.rst:180 +#: ../../c-api/memory.rst:176 msgid "" "If *p* is ``NULL``, the call is equivalent to ``PyMem_RawMalloc(n)``; else " "if *n* is equal to zero, the memory block is resized but is not freed, and " "the returned pointer is non-``NULL``." msgstr "" -#: ../../c-api/memory.rst:184 +#: ../../c-api/memory.rst:180 msgid "" "Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" "func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` or :c:func:" "`PyMem_RawCalloc`." msgstr "" -#: ../../c-api/memory.rst:188 +#: ../../c-api/memory.rst:184 msgid "" "If the request fails, :c:func:`PyMem_RawRealloc` returns ``NULL`` and *p* " "remains a valid pointer to the previous memory area." msgstr "" -#: ../../c-api/memory.rst:194 +#: ../../c-api/memory.rst:190 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " "previous call to :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` or :c:" @@ -269,23 +269,23 @@ msgid "" "called before, undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:199 ../../c-api/memory.rst:276 -#: ../../c-api/memory.rst:409 +#: ../../c-api/memory.rst:195 ../../c-api/memory.rst:272 +#: ../../c-api/memory.rst:405 msgid "If *p* is ``NULL``, no operation is performed." msgstr "" -#: ../../c-api/memory.rst:205 +#: ../../c-api/memory.rst:201 msgid "Memory Interface" msgstr "記憶體介面" -#: ../../c-api/memory.rst:207 ../../c-api/memory.rst:344 +#: ../../c-api/memory.rst:203 ../../c-api/memory.rst:340 msgid "" "The following function sets, modeled after the ANSI C standard, but " "specifying behavior when requesting zero bytes, are available for allocating " "and releasing memory from the Python heap." msgstr "" -#: ../../c-api/memory.rst:211 +#: ../../c-api/memory.rst:207 msgid "" "In the GIL-enabled build (default build) the :ref:`default memory allocator " "` uses the :ref:`pymalloc memory allocator " @@ -293,56 +293,56 @@ msgid "" "ref:`mimalloc memory allocator ` instead." msgstr "" -#: ../../c-api/memory.rst:219 ../../c-api/memory.rst:361 +#: ../../c-api/memory.rst:215 ../../c-api/memory.rst:357 msgid "" "There must be an :term:`attached thread state` when using these functions." msgstr "" -#: ../../c-api/memory.rst:223 +#: ../../c-api/memory.rst:219 msgid "" "The default allocator is now pymalloc instead of system :c:func:`malloc`." msgstr "" -#: ../../c-api/memory.rst:227 +#: ../../c-api/memory.rst:223 msgid "" "In the :term:`free-threaded ` build, the default allocator " "is now :ref:`mimalloc `." msgstr "" -#: ../../c-api/memory.rst:235 +#: ../../c-api/memory.rst:231 msgid "" "Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, " "as if ``PyMem_Malloc(1)`` had been called instead. The memory will not have " "been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:246 +#: ../../c-api/memory.rst:242 msgid "" "Requesting zero elements or elements of size zero bytes returns a distinct " "non-``NULL`` pointer if possible, as if ``PyMem_Calloc(1, 1)`` had been " "called instead." msgstr "" -#: ../../c-api/memory.rst:258 +#: ../../c-api/memory.rst:254 msgid "" "If *p* is ``NULL``, the call is equivalent to ``PyMem_Malloc(n)``; else if " "*n* is equal to zero, the memory block is resized but is not freed, and the " "returned pointer is non-``NULL``." msgstr "" -#: ../../c-api/memory.rst:262 +#: ../../c-api/memory.rst:258 msgid "" "Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" "func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:`PyMem_Calloc`." msgstr "" -#: ../../c-api/memory.rst:265 +#: ../../c-api/memory.rst:261 msgid "" "If the request fails, :c:func:`PyMem_Realloc` returns ``NULL`` and *p* " "remains a valid pointer to the previous memory area." msgstr "" -#: ../../c-api/memory.rst:271 +#: ../../c-api/memory.rst:267 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " "previous call to :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:" @@ -350,20 +350,20 @@ msgid "" "undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:278 +#: ../../c-api/memory.rst:274 msgid "" "The following type-oriented macros are provided for convenience. Note that " "*TYPE* refers to any C type." msgstr "" -#: ../../c-api/memory.rst:284 +#: ../../c-api/memory.rst:280 msgid "" "Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes " "of memory. Returns a pointer cast to ``TYPE*``. The memory will not have " "been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:291 +#: ../../c-api/memory.rst:287 msgid "" "Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n * " "sizeof(TYPE))`` bytes. Returns a pointer cast to ``TYPE*``. On return, *p* " @@ -371,67 +371,67 @@ msgid "" "failure." msgstr "" -#: ../../c-api/memory.rst:296 +#: ../../c-api/memory.rst:292 msgid "" "This is a C preprocessor macro; *p* is always reassigned. Save the original " "value of *p* to avoid losing memory when handling errors." msgstr "" -#: ../../c-api/memory.rst:302 +#: ../../c-api/memory.rst:298 msgid "Same as :c:func:`PyMem_Free`." msgstr "和 :c:func:`PyMem_Free` 相同。" -#: ../../c-api/memory.rst:306 +#: ../../c-api/memory.rst:302 msgid "Deprecated aliases" msgstr "已棄用的別名" -#: ../../c-api/memory.rst:308 +#: ../../c-api/memory.rst:304 msgid "" "These are :term:`soft deprecated` aliases to existing functions and macros. " "They exist solely for backwards compatibility." msgstr "" -#: ../../c-api/memory.rst:315 +#: ../../c-api/memory.rst:311 msgid "Deprecated alias" msgstr "已棄用的別名" -#: ../../c-api/memory.rst:316 +#: ../../c-api/memory.rst:312 msgid "Corresponding function or macro" msgstr "對應的函式或巨集" -#: ../../c-api/memory.rst:318 +#: ../../c-api/memory.rst:314 msgid ":c:func:`PyMem_Malloc`" msgstr ":c:func:`PyMem_Malloc`" -#: ../../c-api/memory.rst:320 +#: ../../c-api/memory.rst:316 msgid ":c:macro:`PyMem_New`" msgstr ":c:macro:`PyMem_New`" -#: ../../c-api/memory.rst:322 ../../c-api/memory.rst:511 +#: ../../c-api/memory.rst:318 ../../c-api/memory.rst:507 msgid ":c:func:`PyMem_Realloc`" msgstr ":c:func:`PyMem_Realloc`" -#: ../../c-api/memory.rst:324 +#: ../../c-api/memory.rst:320 msgid ":c:macro:`PyMem_Resize`" msgstr ":c:macro:`PyMem_Resize`" -#: ../../c-api/memory.rst:326 ../../c-api/memory.rst:328 -#: ../../c-api/memory.rst:513 +#: ../../c-api/memory.rst:322 ../../c-api/memory.rst:324 +#: ../../c-api/memory.rst:509 msgid ":c:func:`PyMem_Free`" msgstr ":c:func:`PyMem_Free`" -#: ../../c-api/memory.rst:332 +#: ../../c-api/memory.rst:328 msgid "" "The macros are now aliases of the corresponding functions and macros. " "Previously, their behavior was the same, but their use did not necessarily " "preserve binary compatibility across Python versions." msgstr "" -#: ../../c-api/memory.rst:342 +#: ../../c-api/memory.rst:338 msgid "Object allocators" msgstr "" -#: ../../c-api/memory.rst:349 +#: ../../c-api/memory.rst:345 msgid "" "There is no guarantee that the memory returned by these allocators can be " "successfully cast to a Python object when intercepting the allocating " @@ -439,7 +439,7 @@ msgid "" "Memory Allocators ` section." msgstr "" -#: ../../c-api/memory.rst:354 +#: ../../c-api/memory.rst:350 msgid "" "The :ref:`default object allocator ` uses the :" "ref:`pymalloc memory allocator `. In the :term:`free-threaded " @@ -447,41 +447,41 @@ msgid "" "` instead." msgstr "" -#: ../../c-api/memory.rst:368 +#: ../../c-api/memory.rst:364 msgid "" "Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, " "as if ``PyObject_Malloc(1)`` had been called instead. The memory will not " "have been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:379 +#: ../../c-api/memory.rst:375 msgid "" "Requesting zero elements or elements of size zero bytes returns a distinct " "non-``NULL`` pointer if possible, as if ``PyObject_Calloc(1, 1)`` had been " "called instead." msgstr "" -#: ../../c-api/memory.rst:391 +#: ../../c-api/memory.rst:387 msgid "" "If *p* is ``NULL``, the call is equivalent to ``PyObject_Malloc(n)``; else " "if *n* is equal to zero, the memory block is resized but is not freed, and " "the returned pointer is non-``NULL``." msgstr "" -#: ../../c-api/memory.rst:395 +#: ../../c-api/memory.rst:391 msgid "" "Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" "func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or :c:func:" "`PyObject_Calloc`." msgstr "" -#: ../../c-api/memory.rst:398 +#: ../../c-api/memory.rst:394 msgid "" "If the request fails, :c:func:`PyObject_Realloc` returns ``NULL`` and *p* " "remains a valid pointer to the previous memory area." msgstr "" -#: ../../c-api/memory.rst:404 +#: ../../c-api/memory.rst:400 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " "previous call to :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or :c:" @@ -489,331 +489,331 @@ msgid "" "called before, undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:411 +#: ../../c-api/memory.rst:407 msgid "" "Do not call this directly to free an object's memory; call the type's :c:" "member:`~PyTypeObject.tp_free` slot instead." msgstr "" -#: ../../c-api/memory.rst:414 +#: ../../c-api/memory.rst:410 msgid "" "Do not use this for memory allocated by :c:macro:`PyObject_GC_New` or :c:" "macro:`PyObject_GC_NewVar`; use :c:func:`PyObject_GC_Del` instead." msgstr "" -#: ../../c-api/memory.rst:419 +#: ../../c-api/memory.rst:415 msgid "" ":c:func:`PyObject_GC_Del` is the equivalent of this function for memory " "allocated by types that support garbage collection." msgstr "" -#: ../../c-api/memory.rst:421 ../../c-api/memory.rst:519 +#: ../../c-api/memory.rst:417 ../../c-api/memory.rst:515 msgid ":c:func:`PyObject_Malloc`" msgstr ":c:func:`PyObject_Malloc`" -#: ../../c-api/memory.rst:422 ../../c-api/memory.rst:520 +#: ../../c-api/memory.rst:418 ../../c-api/memory.rst:516 msgid ":c:func:`PyObject_Realloc`" msgstr ":c:func:`PyObject_Realloc`" -#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:521 +#: ../../c-api/memory.rst:419 ../../c-api/memory.rst:517 msgid ":c:func:`PyObject_Calloc`" msgstr ":c:func:`PyObject_Calloc`" -#: ../../c-api/memory.rst:424 +#: ../../c-api/memory.rst:420 msgid ":c:macro:`PyObject_New`" msgstr ":c:macro:`PyObject_New`" -#: ../../c-api/memory.rst:425 +#: ../../c-api/memory.rst:421 msgid ":c:macro:`PyObject_NewVar`" msgstr ":c:macro:`PyObject_NewVar`" -#: ../../c-api/memory.rst:426 +#: ../../c-api/memory.rst:422 msgid ":c:func:`PyType_GenericAlloc`" msgstr ":c:func:`PyType_GenericAlloc`" -#: ../../c-api/memory.rst:427 +#: ../../c-api/memory.rst:423 msgid ":c:member:`~PyTypeObject.tp_free`" msgstr ":c:member:`~PyTypeObject.tp_free`" -#: ../../c-api/memory.rst:433 +#: ../../c-api/memory.rst:429 msgid "Default Memory Allocators" msgstr "" -#: ../../c-api/memory.rst:435 +#: ../../c-api/memory.rst:431 msgid "Default memory allocators:" msgstr "" -#: ../../c-api/memory.rst:438 +#: ../../c-api/memory.rst:434 msgid "Configuration" msgstr "配置" -#: ../../c-api/memory.rst:438 +#: ../../c-api/memory.rst:434 msgid "Name" msgstr "名稱" -#: ../../c-api/memory.rst:438 +#: ../../c-api/memory.rst:434 msgid "PyMem_RawMalloc" msgstr "PyMem_RawMalloc" -#: ../../c-api/memory.rst:438 +#: ../../c-api/memory.rst:434 msgid "PyMem_Malloc" msgstr "PyMem_Malloc" -#: ../../c-api/memory.rst:438 +#: ../../c-api/memory.rst:434 msgid "PyObject_Malloc" msgstr "PyObject_Malloc" -#: ../../c-api/memory.rst:440 +#: ../../c-api/memory.rst:436 msgid "Release build" msgstr "" -#: ../../c-api/memory.rst:440 +#: ../../c-api/memory.rst:436 msgid "``\"pymalloc\"``" msgstr "``\"pymalloc\"``" -#: ../../c-api/memory.rst:440 ../../c-api/memory.rst:442 +#: ../../c-api/memory.rst:436 ../../c-api/memory.rst:438 msgid "``malloc``" msgstr "``malloc``" -#: ../../c-api/memory.rst:440 +#: ../../c-api/memory.rst:436 msgid "``pymalloc``" msgstr "``pymalloc``" -#: ../../c-api/memory.rst:441 +#: ../../c-api/memory.rst:437 msgid "Debug build" msgstr "" -#: ../../c-api/memory.rst:441 +#: ../../c-api/memory.rst:437 msgid "``\"pymalloc_debug\"``" msgstr "``\"pymalloc_debug\"``" -#: ../../c-api/memory.rst:441 ../../c-api/memory.rst:443 +#: ../../c-api/memory.rst:437 ../../c-api/memory.rst:439 msgid "``malloc`` + debug" msgstr "" -#: ../../c-api/memory.rst:441 +#: ../../c-api/memory.rst:437 msgid "``pymalloc`` + debug" msgstr "" -#: ../../c-api/memory.rst:442 +#: ../../c-api/memory.rst:438 msgid "Release build, without pymalloc" msgstr "" -#: ../../c-api/memory.rst:442 +#: ../../c-api/memory.rst:438 msgid "``\"malloc\"``" msgstr "``\"malloc\"``" -#: ../../c-api/memory.rst:443 +#: ../../c-api/memory.rst:439 msgid "Debug build, without pymalloc" msgstr "" -#: ../../c-api/memory.rst:443 +#: ../../c-api/memory.rst:439 msgid "``\"malloc_debug\"``" msgstr "``\"malloc_debug\"``" -#: ../../c-api/memory.rst:444 +#: ../../c-api/memory.rst:440 msgid "Free-threaded build" msgstr "" -#: ../../c-api/memory.rst:444 +#: ../../c-api/memory.rst:440 msgid "``\"mimalloc\"``" msgstr "``\"mimalloc\"``" -#: ../../c-api/memory.rst:444 +#: ../../c-api/memory.rst:440 msgid "``mimalloc``" msgstr "``mimalloc``" -#: ../../c-api/memory.rst:445 +#: ../../c-api/memory.rst:441 msgid "Free-threaded debug build" msgstr "" -#: ../../c-api/memory.rst:445 +#: ../../c-api/memory.rst:441 msgid "``\"mimalloc_debug\"``" msgstr "``\"mimalloc_debug\"``" -#: ../../c-api/memory.rst:445 +#: ../../c-api/memory.rst:441 msgid "``mimalloc`` + debug" msgstr "``mimalloc`` + debug" -#: ../../c-api/memory.rst:448 +#: ../../c-api/memory.rst:444 msgid "Legend:" msgstr "" -#: ../../c-api/memory.rst:450 +#: ../../c-api/memory.rst:446 msgid "Name: value for :envvar:`PYTHONMALLOC` environment variable." msgstr "" -#: ../../c-api/memory.rst:451 +#: ../../c-api/memory.rst:447 msgid "" "``malloc``: system allocators from the standard C library, C functions: :c:" "func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`." msgstr "" -#: ../../c-api/memory.rst:453 +#: ../../c-api/memory.rst:449 msgid "``pymalloc``: :ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:454 +#: ../../c-api/memory.rst:450 msgid "``mimalloc``: :ref:`mimalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:455 +#: ../../c-api/memory.rst:451 msgid "" "\"+ debug\": with :ref:`debug hooks on the Python memory allocators `." msgstr "" -#: ../../c-api/memory.rst:457 +#: ../../c-api/memory.rst:453 msgid "\"Debug build\": :ref:`Python build in debug mode `." msgstr "" -#: ../../c-api/memory.rst:462 +#: ../../c-api/memory.rst:458 msgid "Customize Memory Allocators" msgstr "" -#: ../../c-api/memory.rst:468 +#: ../../c-api/memory.rst:464 msgid "" "Structure used to describe a memory block allocator. The structure has the " "following fields:" msgstr "" -#: ../../c-api/memory.rst:472 ../../c-api/memory.rst:723 +#: ../../c-api/memory.rst:468 ../../c-api/memory.rst:723 msgid "Field" msgstr "欄位" -#: ../../c-api/memory.rst:472 ../../c-api/memory.rst:723 +#: ../../c-api/memory.rst:468 ../../c-api/memory.rst:723 msgid "Meaning" msgstr "意義" -#: ../../c-api/memory.rst:474 ../../c-api/memory.rst:725 +#: ../../c-api/memory.rst:470 ../../c-api/memory.rst:725 msgid "``void *ctx``" msgstr "``void *ctx``" -#: ../../c-api/memory.rst:474 ../../c-api/memory.rst:725 +#: ../../c-api/memory.rst:470 ../../c-api/memory.rst:725 msgid "user context passed as first argument" msgstr "" -#: ../../c-api/memory.rst:476 +#: ../../c-api/memory.rst:472 msgid "``void* malloc(void *ctx, size_t size)``" msgstr "``void* malloc(void *ctx, size_t size)``" -#: ../../c-api/memory.rst:476 +#: ../../c-api/memory.rst:472 msgid "allocate a memory block" msgstr "" -#: ../../c-api/memory.rst:478 +#: ../../c-api/memory.rst:474 msgid "``void* calloc(void *ctx, size_t nelem, size_t elsize)``" msgstr "``void* calloc(void *ctx, size_t nelem, size_t elsize)``" -#: ../../c-api/memory.rst:478 +#: ../../c-api/memory.rst:474 msgid "allocate a memory block initialized with zeros" msgstr "" -#: ../../c-api/memory.rst:481 +#: ../../c-api/memory.rst:477 msgid "``void* realloc(void *ctx, void *ptr, size_t new_size)``" msgstr "``void* realloc(void *ctx, void *ptr, size_t new_size)``" -#: ../../c-api/memory.rst:481 +#: ../../c-api/memory.rst:477 msgid "allocate or resize a memory block" msgstr "" -#: ../../c-api/memory.rst:483 +#: ../../c-api/memory.rst:479 msgid "``void free(void *ctx, void *ptr)``" msgstr "``void free(void *ctx, void *ptr)``" -#: ../../c-api/memory.rst:483 +#: ../../c-api/memory.rst:479 msgid "free a memory block" msgstr "" -#: ../../c-api/memory.rst:486 +#: ../../c-api/memory.rst:482 msgid "" "The :c:type:`!PyMemAllocator` structure was renamed to :c:type:" "`PyMemAllocatorEx` and a new ``calloc`` field was added." msgstr "" -#: ../../c-api/memory.rst:493 +#: ../../c-api/memory.rst:489 msgid "Enum used to identify an allocator domain. Domains:" msgstr "" -#: ../../c-api/memory.rst:499 ../../c-api/memory.rst:508 -#: ../../c-api/memory.rst:517 +#: ../../c-api/memory.rst:495 ../../c-api/memory.rst:504 +#: ../../c-api/memory.rst:513 msgid "Functions:" msgstr "函式:" -#: ../../c-api/memory.rst:501 +#: ../../c-api/memory.rst:497 msgid ":c:func:`PyMem_RawMalloc`" msgstr ":c:func:`PyMem_RawMalloc`" -#: ../../c-api/memory.rst:502 +#: ../../c-api/memory.rst:498 msgid ":c:func:`PyMem_RawRealloc`" msgstr ":c:func:`PyMem_RawRealloc`" -#: ../../c-api/memory.rst:503 +#: ../../c-api/memory.rst:499 msgid ":c:func:`PyMem_RawCalloc`" msgstr ":c:func:`PyMem_RawCalloc`" -#: ../../c-api/memory.rst:504 +#: ../../c-api/memory.rst:500 msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../c-api/memory.rst:510 +#: ../../c-api/memory.rst:506 msgid ":c:func:`PyMem_Malloc`," msgstr ":c:func:`PyMem_Malloc`," -#: ../../c-api/memory.rst:512 +#: ../../c-api/memory.rst:508 msgid ":c:func:`PyMem_Calloc`" msgstr ":c:func:`PyMem_Calloc`" -#: ../../c-api/memory.rst:522 +#: ../../c-api/memory.rst:518 msgid ":c:func:`PyObject_Free`" msgstr ":c:func:`PyObject_Free`" -#: ../../c-api/memory.rst:526 +#: ../../c-api/memory.rst:522 msgid "Get the memory block allocator of the specified domain." msgstr "" -#: ../../c-api/memory.rst:531 +#: ../../c-api/memory.rst:527 msgid "Set the memory block allocator of the specified domain." msgstr "" -#: ../../c-api/memory.rst:533 +#: ../../c-api/memory.rst:529 msgid "" "The new allocator must return a distinct non-``NULL`` pointer when " "requesting zero bytes." msgstr "" -#: ../../c-api/memory.rst:536 +#: ../../c-api/memory.rst:532 msgid "" "For the :c:macro:`PYMEM_DOMAIN_RAW` domain, the allocator must be thread-" "safe: a :term:`thread state` is not :term:`attached ` " "when the allocator is called." msgstr "" -#: ../../c-api/memory.rst:540 +#: ../../c-api/memory.rst:536 msgid "" "For the remaining domains, the allocator must also be thread-safe: the " "allocator may be called in different interpreters that do not share a :term:" "`GIL`." msgstr "" -#: ../../c-api/memory.rst:544 +#: ../../c-api/memory.rst:540 msgid "" "If the new allocator is not a hook (does not call the previous allocator), " "the :c:func:`PyMem_SetupDebugHooks` function must be called to reinstall the " "debug hooks on top on the new allocator." msgstr "" -#: ../../c-api/memory.rst:548 +#: ../../c-api/memory.rst:544 msgid "" "See also :c:member:`PyPreConfig.allocator` and :ref:`Preinitialize Python " "with PyPreConfig `." msgstr "" -#: ../../c-api/memory.rst:553 +#: ../../c-api/memory.rst:549 msgid ":c:func:`PyMem_SetAllocator` does have the following contract:" msgstr "" -#: ../../c-api/memory.rst:555 +#: ../../c-api/memory.rst:551 msgid "" "It can be called after :c:func:`Py_PreInitialize` and before :c:func:" "`Py_InitializeFromConfig` to install a custom memory allocator. There are no " @@ -823,7 +823,7 @@ msgid "" "allocator domains ` for more information." msgstr "" -#: ../../c-api/memory.rst:563 +#: ../../c-api/memory.rst:559 msgid "" "If called after Python has finish initializing (after :c:func:" "`Py_InitializeFromConfig` has been called) the allocator **must** wrap the " @@ -831,21 +831,21 @@ msgid "" "arbitrary one is **not supported**." msgstr "" -#: ../../c-api/memory.rst:568 +#: ../../c-api/memory.rst:564 msgid "All allocators must be thread-safe." msgstr "" -#: ../../c-api/memory.rst:574 +#: ../../c-api/memory.rst:570 msgid "" "Setup :ref:`debug hooks in the Python memory allocators ` " "to detect memory errors." msgstr "" -#: ../../c-api/memory.rst:581 +#: ../../c-api/memory.rst:577 msgid "Debug hooks on the Python memory allocators" msgstr "" -#: ../../c-api/memory.rst:583 +#: ../../c-api/memory.rst:579 msgid "" "When :ref:`Python is built in debug mode `, the :c:func:" "`PyMem_SetupDebugHooks` function is called at the :ref:`Python " @@ -853,19 +853,19 @@ msgid "" "allocators to detect memory errors." msgstr "" -#: ../../c-api/memory.rst:588 +#: ../../c-api/memory.rst:584 msgid "" "The :envvar:`PYTHONMALLOC` environment variable can be used to install debug " "hooks on a Python compiled in release mode (ex: ``PYTHONMALLOC=debug``)." msgstr "" -#: ../../c-api/memory.rst:591 +#: ../../c-api/memory.rst:587 msgid "" "The :c:func:`PyMem_SetupDebugHooks` function can be used to set debug hooks " "after calling :c:func:`PyMem_SetAllocator`." msgstr "" -#: ../../c-api/memory.rst:594 +#: ../../c-api/memory.rst:590 msgid "" "These debug hooks fill dynamically allocated memory blocks with special, " "recognizable bit patterns. Newly allocated memory is filled with the byte " @@ -875,25 +875,25 @@ msgid "" "these bytes are unlikely to be valid addresses, floats, or ASCII strings." msgstr "" -#: ../../c-api/memory.rst:601 +#: ../../c-api/memory.rst:597 msgid "Runtime checks:" msgstr "Runtime 檢查:" -#: ../../c-api/memory.rst:603 +#: ../../c-api/memory.rst:599 msgid "" "Detect API violations. For example, detect if :c:func:`PyObject_Free` is " "called on a memory block allocated by :c:func:`PyMem_Malloc`." msgstr "" -#: ../../c-api/memory.rst:605 +#: ../../c-api/memory.rst:601 msgid "Detect write before the start of the buffer (buffer underflow)." msgstr "" -#: ../../c-api/memory.rst:606 +#: ../../c-api/memory.rst:602 msgid "Detect write after the end of the buffer (buffer overflow)." msgstr "" -#: ../../c-api/memory.rst:607 +#: ../../c-api/memory.rst:603 msgid "" "Check that there is an :term:`attached thread state` when allocator " "functions of :c:macro:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) " @@ -901,7 +901,7 @@ msgid "" "called." msgstr "" -#: ../../c-api/memory.rst:612 +#: ../../c-api/memory.rst:608 msgid "" "On error, the debug hooks use the :mod:`tracemalloc` module to get the " "traceback where a memory block was allocated. The traceback is only " @@ -909,7 +909,7 @@ msgid "" "memory block was traced." msgstr "" -#: ../../c-api/memory.rst:617 +#: ../../c-api/memory.rst:613 msgid "" "Let *S* = ``sizeof(size_t)``. ``2*S`` bytes are added at each end of each " "block of *N* bytes requested. The memory layout is like so, where p " @@ -919,49 +919,49 @@ msgid "" "from a Python slice):" msgstr "" -#: ../../c-api/memory.rst:623 +#: ../../c-api/memory.rst:619 msgid "``p[-2*S:-S]``" msgstr "``p[-2*S:-S]``" -#: ../../c-api/memory.rst:624 +#: ../../c-api/memory.rst:620 msgid "" "Number of bytes originally asked for. This is a size_t, big-endian (easier " "to read in a memory dump)." msgstr "" -#: ../../c-api/memory.rst:626 +#: ../../c-api/memory.rst:622 msgid "``p[-S]``" msgstr "``p[-S]``" -#: ../../c-api/memory.rst:627 +#: ../../c-api/memory.rst:623 msgid "API identifier (ASCII character):" msgstr "" -#: ../../c-api/memory.rst:629 +#: ../../c-api/memory.rst:625 msgid "``'r'`` for :c:macro:`PYMEM_DOMAIN_RAW`." msgstr "``'r'`` 代表 :c:macro:`PYMEM_DOMAIN_RAW`。" -#: ../../c-api/memory.rst:630 +#: ../../c-api/memory.rst:626 msgid "``'m'`` for :c:macro:`PYMEM_DOMAIN_MEM`." msgstr "``'m'`` 代表 :c:macro:`PYMEM_DOMAIN_MEM`。" -#: ../../c-api/memory.rst:631 +#: ../../c-api/memory.rst:627 msgid "``'o'`` for :c:macro:`PYMEM_DOMAIN_OBJ`." msgstr "``'o'`` 代表 :c:macro:`PYMEM_DOMAIN_OBJ`。" -#: ../../c-api/memory.rst:633 +#: ../../c-api/memory.rst:629 msgid "``p[-S+1:0]``" msgstr "``p[-S+1:0]``" -#: ../../c-api/memory.rst:634 +#: ../../c-api/memory.rst:630 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch under- writes and reads." msgstr "" -#: ../../c-api/memory.rst:636 +#: ../../c-api/memory.rst:632 msgid "``p[0:N]``" msgstr "``p[0:N]``" -#: ../../c-api/memory.rst:637 +#: ../../c-api/memory.rst:633 msgid "" "The requested memory, filled with copies of PYMEM_CLEANBYTE, used to catch " "reference to uninitialized memory. When a realloc-like function is called " @@ -972,25 +972,25 @@ msgid "" "bytes are also filled with PYMEM_DEADBYTE." msgstr "" -#: ../../c-api/memory.rst:645 +#: ../../c-api/memory.rst:641 msgid "``p[N:N+S]``" msgstr "``p[N:N+S]``" -#: ../../c-api/memory.rst:646 +#: ../../c-api/memory.rst:642 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch over- writes and reads." msgstr "" -#: ../../c-api/memory.rst:648 +#: ../../c-api/memory.rst:644 msgid "``p[N+S:N+2*S]``" msgstr "``p[N+S:N+2*S]``" -#: ../../c-api/memory.rst:649 +#: ../../c-api/memory.rst:645 msgid "" "Only used if the ``PYMEM_DEBUG_SERIALNO`` macro is defined (not defined by " "default)." msgstr "" -#: ../../c-api/memory.rst:652 +#: ../../c-api/memory.rst:648 msgid "" "A serial number, incremented by 1 on each call to a malloc-like or realloc-" "like function. Big-endian :c:type:`size_t`. If \"bad memory\" is detected " @@ -1000,7 +1000,7 @@ msgid "" "number is incremented, and exists so you can set such a breakpoint easily." msgstr "" -#: ../../c-api/memory.rst:659 +#: ../../c-api/memory.rst:655 msgid "" "A realloc-like or free-like function first checks that the " "PYMEM_FORBIDDENBYTE bytes at each end are intact. If they've been altered, " @@ -1013,7 +1013,7 @@ msgid "" "getting used)." msgstr "" -#: ../../c-api/memory.rst:668 +#: ../../c-api/memory.rst:664 msgid "" "The :c:func:`PyMem_SetupDebugHooks` function now also works on Python " "compiled in release mode. On error, the debug hooks now use :mod:" @@ -1023,7 +1023,7 @@ msgid "" "domains are called." msgstr "" -#: ../../c-api/memory.rst:676 +#: ../../c-api/memory.rst:672 msgid "" "Byte patterns ``0xCB`` (``PYMEM_CLEANBYTE``), ``0xDB`` (``PYMEM_DEADBYTE``) " "and ``0xFB`` (``PYMEM_FORBIDDENBYTE``) have been replaced with ``0xCD``, " @@ -1031,17 +1031,22 @@ msgid "" "``malloc()`` and ``free()``." msgstr "" -#: ../../c-api/memory.rst:686 +#: ../../c-api/memory.rst:682 msgid "The pymalloc allocator" msgstr "" -#: ../../c-api/memory.rst:688 +#: ../../c-api/memory.rst:684 msgid "" "Python has a *pymalloc* allocator optimized for small objects (smaller or " "equal to 512 bytes) with a short lifetime. It uses memory mappings called " "\"arenas\" with a fixed size of either 256 KiB on 32-bit platforms or 1 MiB " -"on 64-bit platforms. It falls back to :c:func:`PyMem_RawMalloc` and :c:func:" -"`PyMem_RawRealloc` for allocations larger than 512 bytes." +"on 64-bit platforms. When Python is configured with :option:`--with-pymalloc-" +"hugepages`, the arena size on 64-bit platforms is increased to 2 MiB to " +"match the huge page size, and arena allocation will attempt to use huge " +"pages (``MAP_HUGETLB`` on Linux, ``MEM_LARGE_PAGES`` on Windows) with " +"automatic fallback to regular pages. It falls back to :c:func:" +"`PyMem_RawMalloc` and :c:func:`PyMem_RawRealloc` for allocations larger than " +"512 bytes." msgstr "" #: ../../c-api/memory.rst:694 @@ -1256,18 +1261,18 @@ msgid "" "object types in C." msgstr "" -#: ../../c-api/memory.rst:43 +#: ../../c-api/memory.rst:39 msgid "malloc (C function)" msgstr "malloc(C 函式)" -#: ../../c-api/memory.rst:43 +#: ../../c-api/memory.rst:39 msgid "calloc (C function)" msgstr "calloc(C 函式)" -#: ../../c-api/memory.rst:43 +#: ../../c-api/memory.rst:39 msgid "realloc (C function)" msgstr "realloc(C 函式)" -#: ../../c-api/memory.rst:43 +#: ../../c-api/memory.rst:39 msgid "free (C function)" msgstr "free(C 函式)" diff --git a/c-api/module.po b/c-api/module.po index 98b8bf24286..1f5c51a8852 100644 --- a/c-api/module.po +++ b/c-api/module.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-02 00:39+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:32+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,25 +22,25 @@ msgstr "" msgid "Module Objects" msgstr "模組物件" -#: ../../c-api/module.rst:15 +#: ../../c-api/module.rst:14 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python module type. " "This is exposed to Python programs as :py:class:`types.ModuleType`." msgstr "" -#: ../../c-api/module.rst:21 +#: ../../c-api/module.rst:20 msgid "" "Return true if *p* is a module object, or a subtype of a module object. This " "function always succeeds." msgstr "" -#: ../../c-api/module.rst:27 +#: ../../c-api/module.rst:26 msgid "" "Return true if *p* is a module object, but not a subtype of :c:data:" "`PyModule_Type`. This function always succeeds." msgstr "" -#: ../../c-api/module.rst:40 +#: ../../c-api/module.rst:39 msgid "" "Return a new module object with :attr:`module.__name__` set to *name*. The " "module's :attr:`!__name__`, :attr:`~module.__doc__`, :attr:`~module." @@ -49,12 +49,12 @@ msgid "" "setting a :attr:`~module.__file__` attribute." msgstr "" -#: ../../c-api/module.rst:46 ../../c-api/module.rst:439 -#: ../../c-api/module.rst:466 +#: ../../c-api/module.rst:45 ../../c-api/module.rst:836 +#: ../../c-api/module.rst:867 msgid "Return ``NULL`` with an exception set on error." msgstr "在失敗時回傳 ``NULL`` 並設定例外。" -#: ../../c-api/module.rst:50 +#: ../../c-api/module.rst:49 msgid "" ":attr:`~module.__package__` and :attr:`~module.__loader__` are now set to " "``None``." @@ -62,7 +62,7 @@ msgstr "" ":attr:`~module.__package__` 和 :attr:`~module.__loader__` 現在被設為 " "``None``。" -#: ../../c-api/module.rst:57 +#: ../../c-api/module.rst:56 msgid "" "Similar to :c:func:`PyModule_NewObject`, but the name is a UTF-8 encoded " "string instead of a Unicode object." @@ -70,7 +70,7 @@ msgstr "" "類似於 :c:func:`PyModule_NewObject`,但名稱是以 UTF-8 編碼的字串,而非 " "Unicode 物件。" -#: ../../c-api/module.rst:65 +#: ../../c-api/module.rst:64 msgid "" "Return the dictionary object that implements *module*'s namespace; this " "object is the same as the :attr:`~object.__dict__` attribute of the module " @@ -78,61 +78,54 @@ msgid "" "object), :exc:`SystemError` is raised and ``NULL`` is returned." msgstr "" -#: ../../c-api/module.rst:70 +#: ../../c-api/module.rst:69 msgid "" "It is recommended extensions use other ``PyModule_*`` and ``PyObject_*`` " "functions rather than directly manipulate a module's :attr:`~object." "__dict__`." msgstr "" -#: ../../c-api/module.rst:74 +#: ../../c-api/module.rst:73 msgid "" "The returned reference is borrowed from the module; it is valid until the " "module is destroyed." msgstr "" -#: ../../c-api/module.rst:84 +#: ../../c-api/module.rst:83 msgid "" "Return *module*'s :attr:`~module.__name__` value. If the module does not " "provide one, or if it is not a string, :exc:`SystemError` is raised and " "``NULL`` is returned." msgstr "" -#: ../../c-api/module.rst:93 +#: ../../c-api/module.rst:92 msgid "" "Similar to :c:func:`PyModule_GetNameObject` but return the name encoded to " "``'utf-8'``." msgstr "" "類似於 :c:func:`PyModule_GetNameObject`,但回傳以 ``'utf-8'`` 編碼的名稱。" -#: ../../c-api/module.rst:96 +#: ../../c-api/module.rst:95 msgid "" "The returned buffer is only valid until the module is renamed or destroyed. " "Note that Python code may rename a module by setting its :py:attr:`~module." "__name__` attribute." msgstr "" -#: ../../c-api/module.rst:102 -msgid "" -"Return the \"state\" of the module, that is, a pointer to the block of " -"memory allocated at module creation time, or ``NULL``. See :c:member:" -"`PyModuleDef.m_size`." -msgstr "" - -#: ../../c-api/module.rst:109 +#: ../../c-api/module.rst:101 msgid "" "Return a pointer to the :c:type:`PyModuleDef` struct from which the module " "was created, or ``NULL`` if the module wasn't created from a definition." msgstr "" -#: ../../c-api/module.rst:112 +#: ../../c-api/module.rst:104 msgid "" "On error, return ``NULL`` with an exception set. Use :c:func:" "`PyErr_Occurred` to tell this case apart from a missing :c:type:`!" "PyModuleDef`." msgstr "" -#: ../../c-api/module.rst:123 +#: ../../c-api/module.rst:115 msgid "" "Return the name of the file from which *module* was loaded using *module*'s :" "attr:`~module.__file__` attribute. If this is not defined, or if it is not " @@ -140,7 +133,7 @@ msgid "" "reference to a Unicode object." msgstr "" -#: ../../c-api/module.rst:133 +#: ../../c-api/module.rst:125 msgid "" "Similar to :c:func:`PyModule_GetFilenameObject` but return the filename " "encoded to 'utf-8'." @@ -148,215 +141,254 @@ msgstr "" "類似於 :c:func:`PyModule_GetFilenameObject`,但回傳以 'utf-8' 編碼的檔案名" "稱。" -#: ../../c-api/module.rst:136 +#: ../../c-api/module.rst:128 msgid "" "The returned buffer is only valid until the module's :py:attr:`~module." "__file__` attribute is reassigned or the module is destroyed." msgstr "" -#: ../../c-api/module.rst:139 +#: ../../c-api/module.rst:131 msgid "" ":c:func:`PyModule_GetFilename` raises :exc:`UnicodeEncodeError` on " "unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead." msgstr "" -#: ../../c-api/module.rst:147 -msgid "Module definitions" +#: ../../c-api/module.rst:140 +msgid "Module definition" msgstr "模組定義" -#: ../../c-api/module.rst:149 +#: ../../c-api/module.rst:142 msgid "" -"The functions in the previous section work on any module object, including " -"modules imported from Python code." +"Modules created using the C API are typically defined using an array of :c:" +"type:`PySlot` structs, which provides a \"description\" of how a module " +"should be created. See :ref:`capi-slots` for more information on slots in " +"general." msgstr "" -#: ../../c-api/module.rst:152 +#: ../../c-api/module.rst:149 msgid "" -"Modules defined using the C API typically use a *module definition*, :c:type:" -"`PyModuleDef` -- a statically allocated, constant “description\" of how a " -"module should be created." +"Previously, a :c:type:`PyModuleDef` struct was necessary to define modules. " +"The older way of defining modules is still available: consult either the :" +"ref:`pymoduledef` section or earlier versions of this documentation if you " +"plan to support earlier Python versions." msgstr "" -#: ../../c-api/module.rst:156 +#: ../../c-api/module.rst:154 msgid "" -"The definition is usually used to define an extension's “main” module object " -"(see :ref:`extension-modules` for details). It is also used to :ref:`create " -"extension modules dynamically `." +"The slots array is usually used to define an extension module's “main” " +"module object (see :ref:`extension-modules` for details). It can also be " +"used to :ref:`create extension modules dynamically `." msgstr "" -#: ../../c-api/module.rst:161 +#: ../../c-api/module.rst:159 msgid "" -"Unlike :c:func:`PyModule_New`, the definition allows management of *module " -"state* -- a piece of memory that is allocated and cleared together with the " -"module object. Unlike the module's Python attributes, Python code cannot " -"replace or delete data stored in module state." +"Unless specified otherwise, the same slot ID may not be repeated in an array " +"of slots." msgstr "" -#: ../../c-api/module.rst:169 +#: ../../c-api/module.rst:164 +msgid "Metadata slots" +msgstr "元資料插槽 (Metadata slots)" + +#: ../../c-api/module.rst:168 msgid "" -"The module definition struct, which holds all information needed to create a " -"module object. This structure must be statically allocated (or be otherwise " -"guaranteed to be valid while any modules created from it exist). Usually, " -"there is only one variable of this type for each extension module." +":c:member:`Slot ID ` for the name of the new module, as a NUL-" +"terminated UTF8-encoded ``const char *``." msgstr "" -#: ../../c-api/module.rst:177 -msgid "Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`." +#: ../../c-api/module.rst:171 +msgid "" +"Note that modules are typically created using a :py:class:`~importlib." +"machinery.ModuleSpec`, and when they are, the name from the spec will be " +"used instead of :c:data:`!Py_mod_name`. However, it is still recommended to " +"include this slot for introspection and debugging purposes." msgstr "" -#: ../../c-api/module.rst:181 -msgid "Name for the new module." +#: ../../c-api/module.rst:179 +msgid "" +"Use :c:member:`PyModuleDef.m_name` instead to support previous versions." msgstr "" -#: ../../c-api/module.rst:185 +#: ../../c-api/module.rst:183 msgid "" -"Docstring for the module; usually a docstring variable created with :c:macro:" -"`PyDoc_STRVAR` is used." +":c:type:`Slot ID ` for the docstring of the new module, as a " +"NUL-terminated UTF8-encoded ``const char *``." +msgstr "" + +#: ../../c-api/module.rst:186 +msgid "Usually it is set to a variable created with :c:macro:`PyDoc_STRVAR`." msgstr "" #: ../../c-api/module.rst:190 -msgid "" -"Module state may be kept in a per-module memory area that can be retrieved " -"with :c:func:`PyModule_GetState`, rather than in static globals. This makes " -"modules safe for use in multiple sub-interpreters." +msgid "Use :c:member:`PyModuleDef.m_doc` instead to support previous versions." msgstr "" #: ../../c-api/module.rst:194 -msgid "" -"This memory area is allocated based on *m_size* on module creation, and " -"freed when the module object is deallocated, after the :c:member:" -"`~PyModuleDef.m_free` function has been called, if present." -msgstr "" +msgid "Feature slots" +msgstr "功能插槽 (Feature slots)" #: ../../c-api/module.rst:198 msgid "" -"Setting it to a non-negative value means that the module can be re-" -"initialized and specifies the additional amount of memory it requires for " -"its state." +":c:member:`Slot ID ` whose value points to a :c:struct:" +"`PyABIInfo` structure describing the ABI that the extension is using." msgstr "" #: ../../c-api/module.rst:202 msgid "" -"Setting ``m_size`` to ``-1`` means that the module does not support sub-" -"interpreters, because it has global state. Negative ``m_size`` is only " -"allowed when using :ref:`legacy single-phase initialization ` or when :ref:`creating modules dynamically `." +"A suitable :c:struct:`!PyABIInfo` variable can be defined using the :c:macro:" +"`PyABIInfo_VAR` macro, as in:" msgstr "" -#: ../../c-api/module.rst:208 -msgid "See :PEP:`3121` for more details." -msgstr "更多詳情請見 :pep:`3121`。" +#: ../../c-api/module.rst:205 +msgid "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot mymodule_slots[] = {\n" +" PySlot_DATA(Py_mod_abi, &abi_info),\n" +" ...\n" +"};" +msgstr "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot mymodule_slots[] = {\n" +" PySlot_DATA(Py_mod_abi, &abi_info),\n" +" ...\n" +"};" -#: ../../c-api/module.rst:212 +#: ../../c-api/module.rst:214 msgid "" -"A pointer to a table of module-level functions, described by :c:type:" -"`PyMethodDef` values. Can be ``NULL`` if no functions are present." +"When creating a module, Python checks the value of this slot using :c:func:" +"`PyABIInfo_Check`." msgstr "" #: ../../c-api/module.rst:217 msgid "" -"An array of slot definitions for multi-phase initialization, terminated by a " -"``{0, NULL}`` entry. When using legacy single-phase initialization, " -"*m_slots* must be ``NULL``." +"This slot is required, except for modules created from :c:struct:" +"`PyModuleDef`." msgstr "" -#: ../../c-api/module.rst:223 -msgid "" -"Prior to version 3.5, this member was always set to ``NULL``, and was " -"defined as:" -msgstr "在 3.5 版本之前,這個成員總是被設為 ``NULL``,並被定義為:" +#: ../../c-api/module.rst:224 ../../c-api/module.rst:263 +msgid ":c:member:`Slot ID ` whose value is one of:" +msgstr "" #: ../../c-api/module.rst:230 +msgid "The module does not support being imported in subinterpreters." +msgstr "" + +#: ../../c-api/module.rst:234 msgid "" -"A traversal function to call during GC traversal of the module object, or " -"``NULL`` if not needed." +"The module supports being imported in subinterpreters, but only when they " +"share the main interpreter's GIL. (See :ref:`isolating-extensions-howto`.)" msgstr "" -#: ../../c-api/module.rst:233 ../../c-api/module.rst:248 -#: ../../c-api/module.rst:269 +#: ../../c-api/module.rst:240 msgid "" -"This function is not called if the module state was requested but is not " -"allocated yet. This is the case immediately after the module is created and " -"before the module is executed (:c:data:`Py_mod_exec` function). More " -"precisely, this function is not called if :c:member:`~PyModuleDef.m_size` is " -"greater than 0 and the module state (as returned by :c:func:" -"`PyModule_GetState`) is ``NULL``." +"The module supports being imported in subinterpreters, even when they have " +"their own GIL. (See :ref:`isolating-extensions-howto`.)" msgstr "" -#: ../../c-api/module.rst:240 ../../c-api/module.rst:261 -#: ../../c-api/module.rst:276 -msgid "No longer called before the module state is allocated." +#: ../../c-api/module.rst:244 +msgid "" +"This slot determines whether or not importing this module in a " +"subinterpreter will fail." msgstr "" -#: ../../c-api/module.rst:245 +#: ../../c-api/module.rst:247 msgid "" -"A clear function to call during GC clearing of the module object, or " -"``NULL`` if not needed." +"If ``Py_mod_multiple_interpreters`` is not specified, the import machinery " +"defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``." msgstr "" -#: ../../c-api/module.rst:255 +#: ../../c-api/module.rst:250 msgid "" -"Like :c:member:`PyTypeObject.tp_clear`, this function is not *always* called " -"before a module is deallocated. For example, when reference counting is " -"enough to determine that an object is no longer used, the cyclic garbage " -"collector is not involved and :c:member:`~PyModuleDef.m_free` is called " -"directly." +"For historical reasons, the values are declared as pointers (``void *``). " +"When using :c:type:`PySlot` arrays, use :c:macro:`PySlot_DATA` for :c:macro:" +"`!Py_mod_multiple_interpreters`:" msgstr "" -#: ../../c-api/module.rst:266 +#: ../../c-api/module.rst:254 msgid "" -"A function to call during deallocation of the module object, or ``NULL`` if " -"not needed." +"PySlot_DATA(Py_mod_multiple_interpreters,\n" +" Py_MOD_PER_INTERPRETER_GIL_SUPPORTED)" msgstr "" +"PySlot_DATA(Py_mod_multiple_interpreters,\n" +" Py_MOD_PER_INTERPRETER_GIL_SUPPORTED)" -#: ../../c-api/module.rst:282 -msgid "The type of ``PyModuleDef`` objects." +#: ../../c-api/module.rst:269 +msgid "" +"The module depends on the presence of the global interpreter lock (GIL), and " +"may access global state without synchronization." msgstr "" -#: ../../c-api/module.rst:286 -msgid "Module slots" -msgstr "模組槽 (Module slots)" +#: ../../c-api/module.rst:274 +msgid "The module is safe to run without an active GIL." +msgstr "" -#: ../../c-api/module.rst:292 -msgid "A slot ID, chosen from the available values explained below." +#: ../../c-api/module.rst:276 +msgid "" +"This slot is ignored by Python builds not configured with :option:`--disable-" +"gil`. Otherwise, it determines whether or not importing this module will " +"cause the GIL to be automatically enabled. See :ref:`whatsnew313-free-" +"threaded-cpython` for more detail." +msgstr "" + +#: ../../c-api/module.rst:281 +msgid "" +"If ``Py_mod_gil`` is not specified, the import machinery defaults to " +"``Py_MOD_GIL_USED``." msgstr "" +#: ../../c-api/module.rst:284 +msgid "" +"For historical reasons, the values are declared as pointers (``void *``). " +"When using :c:type:`PySlot` arrays, use :c:macro:`PySlot_DATA` for :c:macro:" +"`!Py_mod_gil`:" +msgstr "" + +#: ../../c-api/module.rst:288 +msgid "PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED)" +msgstr "PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED)" + #: ../../c-api/module.rst:296 -msgid "Value of the slot, whose meaning depends on the slot ID." +msgid "Creation and initialization slots" msgstr "" #: ../../c-api/module.rst:300 -msgid "The available slot types are:" +msgid "" +":c:member:`Slot ID ` for a function that creates the module " +"object itself. The function must have the signature:" msgstr "" -#: ../../c-api/module.rst:304 +#: ../../c-api/module.rst:308 +msgid "The function will be called with:" +msgstr "" + +#: ../../c-api/module.rst:310 msgid "" -"Specifies a function that is called to create the module object itself. The " -"*value* pointer of this slot must point to a function of the signature:" +"*spec*: a ``ModuleSpec``-like object, meaning that any attributes defined " +"for :py:class:`importlib.machinery.ModuleSpec` have matching semantics. " +"However, any of the attributes may be missing." msgstr "" -#: ../../c-api/module.rst:311 +#: ../../c-api/module.rst:313 msgid "" -"The function receives a :py:class:`~importlib.machinery.ModuleSpec` " -"instance, as defined in :PEP:`451`, and the module definition. It should " -"return a new module object, or set an error and return ``NULL``." +"*def*: ``NULL``, or the module definition if the module is created from one." msgstr "" -#: ../../c-api/module.rst:316 +#: ../../c-api/module.rst:315 msgid "" -"This function should be kept minimal. In particular, it should not call " -"arbitrary Python code, as trying to import the same module again may result " -"in an infinite loop." +"The function should return a new module object, or set an error and return " +"``NULL``." msgstr "" -#: ../../c-api/module.rst:320 +#: ../../c-api/module.rst:318 msgid "" -"Multiple ``Py_mod_create`` slots may not be specified in one module " -"definition." +"This function should be kept minimal. In particular, it should not call " +"arbitrary Python code, as trying to import the same module again may result " +"in an infinite loop." msgstr "" -#: ../../c-api/module.rst:323 +#: ../../c-api/module.rst:322 msgid "" "If ``Py_mod_create`` is not specified, the import machinery will create a " "normal module object using :c:func:`PyModule_New`. The name is taken from " @@ -365,110 +397,630 @@ msgid "" "through symlinks, all while sharing a single module definition." msgstr "" -#: ../../c-api/module.rst:329 +#: ../../c-api/module.rst:328 msgid "" "There is no requirement for the returned object to be an instance of :c:type:" -"`PyModule_Type`. Any type can be used, as long as it supports setting and " -"getting import-related attributes. However, only ``PyModule_Type`` instances " -"may be returned if the ``PyModuleDef`` has non-``NULL`` ``m_traverse``, " -"``m_clear``, ``m_free``; non-zero ``m_size``; or slots other than " -"``Py_mod_create``." +"`PyModule_Type`. However, some slots may only be used with :c:type:`!" +"PyModule_Type` instances; in particular:" msgstr "" -#: ../../c-api/module.rst:340 +#: ../../c-api/module.rst:333 +msgid ":c:macro:`Py_mod_exec`," +msgstr ":c:macro:`Py_mod_exec`," + +#: ../../c-api/module.rst:334 msgid "" -"Specifies a function that is called to *execute* the module. This is " -"equivalent to executing the code of a Python module: typically, this " -"function adds classes and constants to the module. The signature of the " -"function is:" +":ref:`module state slots ` (``Py_mod_state_*``)," msgstr "" +":ref:`module state slots ` (``Py_mod_state_*``)," + +#: ../../c-api/module.rst:335 +msgid ":c:macro:`Py_mod_token`." +msgstr ":c:macro:`Py_mod_token`." -#: ../../c-api/module.rst:349 +#: ../../c-api/module.rst:341 msgid "" -"If multiple ``Py_mod_exec`` slots are specified, they are processed in the " -"order they appear in the *m_slots* array." +"The *slots* argument may be a ``ModuleSpec``-like object, rather than a " +"true :py:class:`~importlib.machinery.ModuleSpec` instance. Note that " +"previous versions of CPython did not enforce this." msgstr "" -#: ../../c-api/module.rst:356 ../../c-api/module.rst:389 -msgid "Specifies one of the following values:" +#: ../../c-api/module.rst:345 +msgid "" +"The *def* argument may now be ``NULL``, since modules are not necessarily " +"made from definitions." msgstr "" -#: ../../c-api/module.rst:362 -msgid "The module does not support being imported in subinterpreters." +#: ../../c-api/module.rst:350 +msgid "" +":c:member:`Slot ID ` for a function that will :dfn:`execute`, " +"or initialize, the module. This function does the equivalent to executing " +"the code of a Python module: typically, it adds classes and constants to the " +"module. The signature of the function is:" msgstr "" -#: ../../c-api/module.rst:366 +#: ../../c-api/module.rst:360 msgid "" -"The module supports being imported in subinterpreters, but only when they " -"share the main interpreter's GIL. (See :ref:`isolating-extensions-howto`.)" +"See the :ref:`capi-module-support-functions` section for some useful " +"functions to call." msgstr "" -#: ../../c-api/module.rst:372 +#: ../../c-api/module.rst:363 msgid "" -"The module supports being imported in subinterpreters, even when they have " -"their own GIL. (See :ref:`isolating-extensions-howto`.)" +"For backwards compatibility, the :c:type:`PyModuleDef.m_slots` array may " +"contain multiple :c:macro:`!Py_mod_exec` slots; these are processed in the " +"order they appear in the array. Elsewhere (that is, in arguments to :c:func:" +"`PyModule_FromSlotsAndSpec` and in return values of :samp:" +"`PyModExport_{}`), repeating the slot is not allowed." msgstr "" -#: ../../c-api/module.rst:376 +#: ../../c-api/module.rst:374 msgid "" -"This slot determines whether or not importing this module in a " -"subinterpreter will fail." +"Repeated ``Py_mod_exec`` slots are disallowed, except in :c:type:" +"`PyModuleDef.m_slots`." msgstr "" #: ../../c-api/module.rst:379 msgid "" -"Multiple ``Py_mod_multiple_interpreters`` slots may not be specified in one " -"module definition." +":c:member:`Slot ID ` for a table of module-level functions, as " +"an array of :c:type:`PyMethodDef` values suitable as the *functions* " +"argument to :c:func:`PyModule_AddFunctions`." msgstr "" -#: ../../c-api/module.rst:382 +#: ../../c-api/module.rst:383 msgid "" -"If ``Py_mod_multiple_interpreters`` is not specified, the import machinery " -"defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``." +"Like other slot IDs, a slots array may only contain one :c:macro:`!" +"Py_mod_methods` entry. To add functions from multiple :c:type:`PyMethodDef` " +"arrays, call :c:func:`PyModule_AddFunctions` in the :c:macro:`Py_mod_exec` " +"function." msgstr "" -#: ../../c-api/module.rst:395 +#: ../../c-api/module.rst:388 msgid "" -"The module depends on the presence of the global interpreter lock (GIL), and " -"may access global state without synchronization." +"The table must be statically allocated (or otherwise guaranteed to outlive " +"the module object)." +msgstr "" + +#: ../../c-api/module.rst:393 +msgid "" +"Use :c:member:`PyModuleDef.m_methods` instead to support previous versions." msgstr "" +#: ../../c-api/module.rst:398 +msgid "Module state" +msgstr "模組狀態" + #: ../../c-api/module.rst:400 -msgid "The module is safe to run without an active GIL." +msgid "" +"Extension modules can have *module state* -- a piece of memory that is " +"allocated on module creation, and freed when the module object is " +"deallocated. The module state is specified using :ref:`dedicated slots `." msgstr "" -#: ../../c-api/module.rst:402 +#: ../../c-api/module.rst:405 msgid "" -"This slot is ignored by Python builds not configured with :option:`--disable-" -"gil`. Otherwise, it determines whether or not importing this module will " -"cause the GIL to be automatically enabled. See :ref:`whatsnew313-free-" -"threaded-cpython` for more detail." +"A typical use of module state is storing an exception type -- or indeed " +"*any* type object defined by the module --" msgstr "" -#: ../../c-api/module.rst:407 +#: ../../c-api/module.rst:408 msgid "" -"Multiple ``Py_mod_gil`` slots may not be specified in one module definition." +"Unlike the module's Python attributes, Python code cannot replace or delete " +"data stored in module state." msgstr "" -#: ../../c-api/module.rst:409 +#: ../../c-api/module.rst:411 msgid "" -"If ``Py_mod_gil`` is not specified, the import machinery defaults to " -"``Py_MOD_GIL_USED``." +"Keeping per-module information in attributes and module state, rather than " +"in static globals, makes module objects *isolated* and safer for use in " +"multiple sub-interpreters. It also helps Python do an orderly clean-up when " +"it shuts down." msgstr "" -#: ../../c-api/module.rst:418 -msgid "Creating extension modules dynamically" +#: ../../c-api/module.rst:416 +msgid "" +"Extensions that keep references to Python objects as part of module state " +"must implement :c:macro:`Py_mod_state_traverse` and :c:macro:" +"`Py_mod_state_clear` functions to avoid reference leaks." msgstr "" #: ../../c-api/module.rst:420 +msgid "To retrieve the state from a given module, use the following functions:" +msgstr "" + +#: ../../c-api/module.rst:424 msgid "" -"The following functions may be used to create a module outside of an " -"extension's :ref:`initialization function `. They are " -"also used in :ref:`single-phase initialization `." +"Return the \"state\" of the module, that is, a pointer to the block of " +"memory allocated at module creation time, or ``NULL``. See :c:macro:" +"`Py_mod_state_size`." +msgstr "" + +#: ../../c-api/module.rst:428 +msgid "" +"On error, return ``NULL`` with an exception set. Use :c:func:" +"`PyErr_Occurred` to tell this case apart from missing module state." msgstr "" -#: ../../c-api/module.rst:427 +#: ../../c-api/module.rst:435 +msgid "" +"Set *\\*result* to the size of *module*'s state, as specified using :c:macro:" +"`Py_mod_state_size` (or :c:member:`PyModuleDef.m_size`), and return 0." +msgstr "" + +#: ../../c-api/module.rst:439 +msgid "On error, set *\\*result* to -1, and return -1 with an exception set." +msgstr "" + +#: ../../c-api/module.rst:448 +msgid "Slots for defining module state" +msgstr "" + +#: ../../c-api/module.rst:450 +msgid "" +"The following :c:member:`slot IDs ` are available for " +"defining the module state." +msgstr "" + +#: ../../c-api/module.rst:455 +msgid "" +":c:member:`Slot ID ` for the size of the module state, in " +"bytes." +msgstr "" + +#: ../../c-api/module.rst:458 +msgid "" +"Setting the value to a non-negative value means that the module can be re-" +"initialized and specifies the additional amount of memory it requires for " +"its state." +msgstr "" + +#: ../../c-api/module.rst:462 +msgid "See :PEP:`3121` for more details." +msgstr "更多詳情請見 :pep:`3121`。" + +#: ../../c-api/module.rst:464 +msgid "" +"Use :c:func:`PyModule_GetStateSize` to retrieve the size of a given module." +msgstr "" + +#: ../../c-api/module.rst:468 +msgid "" +"Use :c:member:`PyModuleDef.m_size` instead to support previous versions." +msgstr "" + +#: ../../c-api/module.rst:472 +msgid "" +":c:member:`Slot ID ` for a traversal function to call during " +"GC traversal of the module object." +msgstr "" + +#: ../../c-api/module.rst:475 +msgid "" +"The signature of the function, and meanings of the arguments, is similar as " +"for :c:member:`PyTypeObject.tp_traverse`:" +msgstr "" + +#: ../../c-api/module.rst:482 ../../c-api/module.rst:504 +#: ../../c-api/module.rst:532 +msgid "" +"This function is not called if the module state was requested but is not " +"allocated yet. This is the case immediately after the module is created and " +"before the module is executed (:c:data:`Py_mod_exec` function). More " +"precisely, this function is not called if the state size (:c:data:" +"`Py_mod_state_size`) is greater than 0 and the module state (as returned by :" +"c:func:`PyModule_GetState`) is ``NULL``." +msgstr "" + +#: ../../c-api/module.rst:491 +msgid "" +"Use :c:member:`PyModuleDef.m_traverse` instead to support previous versions." +msgstr "" + +#: ../../c-api/module.rst:495 +msgid "" +":c:member:`Slot ID ` for a clear function to call during GC " +"clearing of the module object." +msgstr "" + +#: ../../c-api/module.rst:498 ../../c-api/module.rst:526 +msgid "The signature of the function is:" +msgstr "" + +#: ../../c-api/module.rst:511 +msgid "" +"Like :c:member:`PyTypeObject.tp_clear`, this function is not *always* called " +"before a module is deallocated. For example, when reference counting is " +"enough to determine that an object is no longer used, the cyclic garbage " +"collector is not involved and the :c:macro:`Py_mod_state_free` function is " +"called directly." +msgstr "" + +#: ../../c-api/module.rst:519 +msgid "" +"Use :c:member:`PyModuleDef.m_clear` instead to support previous versions." +msgstr "" + +#: ../../c-api/module.rst:523 +msgid "" +":c:member:`Slot ID ` for a function to call during " +"deallocation of the module object." +msgstr "" + +#: ../../c-api/module.rst:541 +msgid "" +"Use :c:member:`PyModuleDef.m_free` instead to support previous versions." +msgstr "" + +#: ../../c-api/module.rst:547 +msgid "Module token" +msgstr "模組 token" + +#: ../../c-api/module.rst:549 +msgid "" +"Each module may have an associated *token*: a pointer-sized value intended " +"to identify of the module state's memory layout. This means that if you have " +"a module object, but you are not sure if it “belongs” to your extension, you " +"can check using code like this:" +msgstr "" + +#: ../../c-api/module.rst:554 +msgid "" +"PyObject *module = \n" +"\n" +"void *module_token;\n" +"if (PyModule_GetToken(module, &module_token) < 0) {\n" +" return NULL;\n" +"}\n" +"if (module_token != your_token) {\n" +" PyErr_SetString(PyExc_ValueError, \"unexpected module\")\n" +" return NULL;\n" +"}\n" +"\n" +"// This module's state has the expected memory layout; it's safe to cast\n" +"struct my_state state = (struct my_state*)PyModule_GetState(module)" +msgstr "" +"PyObject *module = \n" +"\n" +"void *module_token;\n" +"if (PyModule_GetToken(module, &module_token) < 0) {\n" +" return NULL;\n" +"}\n" +"if (module_token != your_token) {\n" +" PyErr_SetString(PyExc_ValueError, \"unexpected module\")\n" +" return NULL;\n" +"}\n" +"\n" +"// 此模組的狀態具有預期的記憶體配置;可以安全地進行轉型\n" +"struct my_state state = (struct my_state*)PyModule_GetState(module)" + +#: ../../c-api/module.rst:570 +msgid "" +"A module's token -- and the *your_token* value to use in the above code -- " +"is:" +msgstr "" + +#: ../../c-api/module.rst:572 +msgid "" +"For modules created with :c:type:`PyModuleDef`: the address of that :c:type:" +"`PyModuleDef`;" +msgstr "" + +#: ../../c-api/module.rst:574 +msgid "" +"For modules defined with the :c:macro:`Py_mod_token` slot: the value of that " +"slot;" +msgstr "" + +#: ../../c-api/module.rst:576 +msgid "" +"For modules created from an ``PyModExport_*`` :ref:`export hook `: the slots array that the export hook returned (unless " +"overridden with :c:macro:`Py_mod_token`)." +msgstr "" + +#: ../../c-api/module.rst:582 +msgid ":c:member:`Slot ID ` for the module token." +msgstr "" + +#: ../../c-api/module.rst:584 +msgid "" +"If you use this slot to set the module token (rather than rely on the " +"default), you must ensure that:" +msgstr "" + +#: ../../c-api/module.rst:587 +msgid "" +"The pointer outlives the class, so it's not reused for something else while " +"the class exists." +msgstr "" + +#: ../../c-api/module.rst:589 +msgid "" +"It \"belongs\" to the extension module where the class lives, so it will not " +"clash with other extensions." +msgstr "" + +#: ../../c-api/module.rst:591 +msgid "" +"If the token points to a :c:type:`PyModuleDef` struct, the module should " +"behave as if it was created from that :c:type:`PyModuleDef`. In particular, " +"the module state must have matching layout and semantics." +msgstr "" + +#: ../../c-api/module.rst:595 +msgid "" +"Modules created from :c:type:`PyModuleDef` always use the address of the :c:" +"type:`PyModuleDef` as the token. This means that :c:macro:`!Py_mod_token` " +"cannot be used in :c:member:`PyModuleDef.m_slots`." +msgstr "" + +#: ../../c-api/module.rst:604 +msgid "Set *\\*result* to the module token for *module* and return 0." +msgstr "" + +#: ../../c-api/module.rst:606 +msgid "On error, set *\\*result* to NULL, and return -1 with an exception set." +msgstr "" + +#: ../../c-api/module.rst:610 +msgid "See also :c:func:`PyType_GetModuleByToken`." +msgstr "" + +#: ../../c-api/module.rst:616 +msgid "Creating extension modules dynamically" +msgstr "" + +#: ../../c-api/module.rst:618 +msgid "" +"The following functions may be used to create an extension module " +"dynamically, rather than from an extension's :ref:`export hook `." +msgstr "" + +#: ../../c-api/module.rst:623 +msgid "" +"Create a new module object, given an array of :ref:`slots " +"` and the :py:class:`~importlib.machinery.ModuleSpec` " +"*spec*." +msgstr "" + +#: ../../c-api/module.rst:626 +msgid "" +"The *slots* argument must point to an array of :c:type:`PySlot` structures, " +"terminated by an entry with slot ID of 0 (typically written as :c:macro:" +"`PySlot_END`). The array must include a :c:data:`Py_mod_abi` entry." +msgstr "" + +#: ../../c-api/module.rst:631 +msgid "" +"The *spec* argument may be any ``ModuleSpec``-like object, as described in :" +"c:macro:`Py_mod_create` documentation. Currently, the *spec* must have a " +"``name`` attribute." +msgstr "" + +#: ../../c-api/module.rst:635 +msgid "" +"On success, return the new module. On error, return ``NULL`` with an " +"exception set." +msgstr "成功時回傳新的模組。在失敗時回傳 ``NULL`` 並設定例外。" + +#: ../../c-api/module.rst:638 +msgid "" +"Note that this does not process the module's execution slot (:c:data:" +"`Py_mod_exec`). Both :c:func:`!PyModule_FromSlotsAndSpec` and :c:func:" +"`PyModule_Exec` must be called to fully initialize a module. (See also :ref:" +"`multi-phase-initialization`.)" +msgstr "" + +#: ../../c-api/module.rst:648 +msgid "Execute the :c:data:`Py_mod_exec` slot(s) of *module*." +msgstr "" + +#: ../../c-api/module.rst:650 +msgid "On success, return 0. On error, return -1 with an exception set." +msgstr "成功時回傳 0。在失敗時回傳 -1 並設定例外。" + +#: ../../c-api/module.rst:653 +msgid "" +"For clarity: If *module* has no slots, for example if it uses :ref:`legacy " +"single-phase initialization `, this function " +"does nothing and returns 0." +msgstr "" + +#: ../../c-api/module.rst:664 +msgid "Module definition struct" +msgstr "模組定義結構" + +#: ../../c-api/module.rst:666 +msgid "" +"Traditionally, extension modules were defined using a *module definition* as " +"the “description\" of how a module should be created. Rather than using an " +"array of :ref:`slots ` directly, the definition has " +"dedicated members for most common functionality, and allows additional slots " +"as an extension mechanism." +msgstr "" + +#: ../../c-api/module.rst:672 +msgid "" +"This way of defining modules is still available and there are no plans to " +"remove it." +msgstr "" + +#: ../../c-api/module.rst:677 +msgid "" +"The module definition struct, which holds information needed to create a " +"module object." +msgstr "" + +#: ../../c-api/module.rst:680 +msgid "" +"This structure must be statically allocated (or be otherwise guaranteed to " +"be valid while any modules created from it exist). Usually, there is only " +"one variable of this type for each extension module defined this way." +msgstr "" + +#: ../../c-api/module.rst:685 +msgid "" +"The struct, including all members, is part of the :ref:`Stable ABI ` for non-free-threaded builds (``abi3``). In the Stable ABI for free-" +"threaded builds (``abi3t``), this struct is opaque, and unusable in " +"practice; see :ref:`pymoduledef_slot` for a replacement." +msgstr "" + +#: ../../c-api/module.rst:693 +msgid "Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`:" +msgstr "" + +#: ../../c-api/module.rst:699 +msgid "The type of :c:member:`!PyModuleDef.m_base`." +msgstr "" + +#: ../../c-api/module.rst:701 +msgid "" +"The struct is part of the :ref:`Stable ABI ` for non-free-" +"threaded builds (``abi3``). In the Stable ABI for Free-Threaded Builds " +"(``abi3t``), this struct is opaque, and unusable in practice." +msgstr "" + +#: ../../c-api/module.rst:708 +msgid "The required initial value for :c:member:`!PyModuleDef.m_base`." +msgstr "" + +#: ../../c-api/module.rst:712 +msgid "Corresponds to the :c:macro:`Py_mod_name` slot." +msgstr "" + +#: ../../c-api/module.rst:716 +msgid "" +"These members correspond to the :c:macro:`Py_mod_doc` slot. Setting this to " +"NULL is equivalent to omitting the slot." +msgstr "" + +#: ../../c-api/module.rst:721 +msgid "" +"Corresponds to the :c:macro:`Py_mod_state_size` slot. Setting this to zero " +"is equivalent to omitting the slot." +msgstr "" + +#: ../../c-api/module.rst:724 +msgid "" +"When using :ref:`legacy single-phase initialization ` or when creating modules dynamically using :c:func:" +"`PyModule_Create` or :c:func:`PyModule_Create2`, :c:member:`!m_size` may be " +"set to -1. This indicates that the module does not support sub-interpreters, " +"because it has global state." +msgstr "" + +#: ../../c-api/module.rst:732 +msgid "" +"Corresponds to the :c:macro:`Py_mod_methods` slot. Setting this to NULL is " +"equivalent to omitting the slot." +msgstr "" + +#: ../../c-api/module.rst:737 +msgid "" +"An array of additional slots, terminated by a ``{0, NULL}`` entry. Note that " +"the entries use the older :c:type:`PyModuleDef_Slot` structure, rather than :" +"c:type:`PySlot`." +msgstr "" + +#: ../../c-api/module.rst:741 +msgid "" +"If the array contains slots corresponding to :c:type:`PyModuleDef` members, " +"the values must match. For example, if you use :c:macro:`Py_mod_name` in :c:" +"member:`!m_slots`, :c:member:`PyModuleDef.m_name` must be set to the same " +"pointer (not just an equal string)." +msgstr "" + +#: ../../c-api/module.rst:749 +msgid "" +"Prior to version 3.5, this member was always set to ``NULL``, and was " +"defined as:" +msgstr "在 3.5 版本之前,這個成員總是被設為 ``NULL``,並被定義為:" + +#: ../../c-api/module.rst:758 +msgid "Older structure defining additional slots of a module." +msgstr "" + +#: ../../c-api/module.rst:760 +msgid "" +"Note that a :c:type:`!PyModuleDef_Slot` array may be included in a :c:type:`!" +"PySlot` array using :c:macro:`Py_mod_slots`, and vice versa using :c:macro:" +"`Py_slot_subslots`." +msgstr "" + +#: ../../c-api/module.rst:764 +msgid "" +"Each :c:type:`!PyModuleDef_Slot` structure ``modslot`` is interpreted as the " +"following :c:type:`PySlot` structure::" +msgstr "" + +#: ../../c-api/module.rst:767 +msgid "" +"(PySlot){\n" +" .sl_id=modslot.slot,\n" +" .sl_flags=PySlot_INTPTR | sub_static,\n" +" .sl_ptr=modslot.value\n" +"}" +msgstr "" +"(PySlot){\n" +" .sl_id=modslot.slot,\n" +" .sl_flags=PySlot_INTPTR | sub_static,\n" +" .sl_ptr=modslot.value\n" +"}" + +#: ../../c-api/module.rst:773 +msgid "" +"where ``sub_static`` is ``PySlot_STATIC`` if the slot requires the flag " +"(such as for :c:macro:`Py_mod_methods`), or if this flag is present on the " +"\"parent\" :c:macro:`!Py_mod_slots` slot (if any)." +msgstr "" + +#: ../../c-api/module.rst:779 +msgid "Corresponds to :c:member:`PySlot.sl_id`." +msgstr "" + +#: ../../c-api/module.rst:783 +msgid "Corresponds to :c:member:`PySlot.sl_ptr`." +msgstr "" + +#: ../../c-api/module.rst:791 +msgid "" +"These members correspond to the :c:macro:`Py_mod_state_traverse`, :c:macro:" +"`Py_mod_state_clear`, and :c:macro:`Py_mod_state_free` slots, respectively." +msgstr "" + +#: ../../c-api/module.rst:795 +msgid "" +"Setting these members to NULL is equivalent to omitting the corresponding " +"slots." +msgstr "" + +#: ../../c-api/module.rst:800 +msgid "" +":c:member:`m_traverse`, :c:member:`m_clear` and :c:member:`m_free` functions " +"are no longer called before the module state is allocated." +msgstr "" + +#: ../../c-api/module.rst:806 +msgid "The type of ``PyModuleDef`` objects." +msgstr "" + +#: ../../c-api/module.rst:811 +msgid "" +":c:member:`Slot ID ` that works like :c:macro:" +"`Py_slot_subslots`, except it specifies an array of :c:type:" +"`PyModuleDef_Slot` structures." +msgstr "" + +#: ../../c-api/module.rst:819 +msgid "" +"The following API can be used to create modules from a :c:type:`!" +"PyModuleDef` struct:" +msgstr "" + +#: ../../c-api/module.rst:824 msgid "" "Create a new module object, given the definition in *def*. This is a macro " "that calls :c:func:`PyModule_Create2` with *module_api_version* set to :c:" @@ -476,33 +1028,37 @@ msgid "" "the :ref:`limited API `." msgstr "" -#: ../../c-api/module.rst:435 +#: ../../c-api/module.rst:832 msgid "" "Create a new module object, given the definition in *def*, assuming the API " "version *module_api_version*. If that version does not match the version of " "the running interpreter, a :exc:`RuntimeWarning` is emitted." msgstr "" -#: ../../c-api/module.rst:441 +#: ../../c-api/module.rst:838 msgid "" "This function does not support slots. The :c:member:`~PyModuleDef.m_slots` " "member of *def* must be ``NULL``." msgstr "" -#: ../../c-api/module.rst:447 +#: ../../c-api/module.rst:844 msgid "" "Most uses of this function should be using :c:func:`PyModule_Create` " "instead; only use this if you are sure you need it." msgstr "" -#: ../../c-api/module.rst:452 +#: ../../c-api/module.rst:849 msgid "" "This macro calls :c:func:`PyModule_FromDefAndSpec2` with " "*module_api_version* set to :c:macro:`PYTHON_API_VERSION`, or to :c:macro:" "`PYTHON_ABI_VERSION` if using the :ref:`limited API `." msgstr "" -#: ../../c-api/module.rst:461 +#: ../../c-api/module.rst:858 ../../c-api/module.rst:882 +msgid "Prefer :c:func:`PyModule_FromSlotsAndSpec` in new code." +msgstr "" + +#: ../../c-api/module.rst:862 msgid "" "Create a new module object, given the definition in *def* and the ModuleSpec " "*spec*, assuming the API version *module_api_version*. If that version does " @@ -510,66 +1066,76 @@ msgid "" "emitted." msgstr "" -#: ../../c-api/module.rst:468 +#: ../../c-api/module.rst:869 msgid "" "Note that this does not process execution slots (:c:data:`Py_mod_exec`). " "Both ``PyModule_FromDefAndSpec`` and ``PyModule_ExecDef`` must be called to " "fully initialize a module." msgstr "" -#: ../../c-api/module.rst:474 +#: ../../c-api/module.rst:875 msgid "" "Most uses of this function should be using :c:func:`PyModule_FromDefAndSpec` " "instead; only use this if you are sure you need it." msgstr "" -#: ../../c-api/module.rst:481 +#: ../../c-api/module.rst:886 msgid "Process any execution slots (:c:data:`Py_mod_exec`) given in *def*." msgstr "" -#: ../../c-api/module.rst:487 -msgid "The C API version. Defined for backwards compatibility." +#: ../../c-api/module.rst:892 +msgid "" +"To run a module's own execution slots, prefer :c:func:`PyModule_Exec`, which " +"works on modules that were not created from a :c:type:`PyModuleDef` " +"structure." +msgstr "" + +#: ../../c-api/module.rst:899 +msgid "" +"The C API version, as an integer (``1013``) and string (``\"1013\"``), " +"respectively. Defined for backwards compatibility." msgstr "" -#: ../../c-api/module.rst:489 ../../c-api/module.rst:496 +#: ../../c-api/module.rst:902 ../../c-api/module.rst:910 msgid "" "Currently, this constant is not updated in new Python versions, and is not " "useful for versioning. This may change in the future." msgstr "" -#: ../../c-api/module.rst:494 -msgid "Defined as ``3`` for backwards compatibility." +#: ../../c-api/module.rst:908 +msgid "" +"Defined as ``3`` and ``\"3\"``, respectively, for backwards compatibility." msgstr "" -#: ../../c-api/module.rst:501 +#: ../../c-api/module.rst:917 msgid "Support functions" msgstr "支援的函式" -#: ../../c-api/module.rst:503 +#: ../../c-api/module.rst:919 msgid "" -"The following functions are provided to help initialize a module state. They " -"are intended for a module's execution slots (:c:data:`Py_mod_exec`), the " +"The following functions are provided to help initialize a module object. " +"They are intended for a module's execution slot (:c:data:`Py_mod_exec`), the " "initialization function for legacy :ref:`single-phase initialization `, or code that creates modules dynamically." msgstr "" -#: ../../c-api/module.rst:511 +#: ../../c-api/module.rst:926 msgid "" "Add an object to *module* as *name*. This is a convenience function which " "can be used from the module's initialization function." msgstr "" -#: ../../c-api/module.rst:514 +#: ../../c-api/module.rst:929 msgid "" "On success, return ``0``. On error, raise an exception and return ``-1``." msgstr "" -#: ../../c-api/module.rst:516 ../../c-api/module.rst:567 -#: ../../c-api/module.rst:594 +#: ../../c-api/module.rst:931 ../../c-api/module.rst:982 +#: ../../c-api/module.rst:1009 msgid "Example usage::" msgstr "用法範例: ::" -#: ../../c-api/module.rst:518 +#: ../../c-api/module.rst:933 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -595,20 +1161,20 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:530 +#: ../../c-api/module.rst:945 msgid "" "To be convenient, the function accepts ``NULL`` *value* with an exception " "set. In this case, return ``-1`` and just leave the raised exception " "unchanged." msgstr "" -#: ../../c-api/module.rst:534 +#: ../../c-api/module.rst:949 msgid "" "The example can also be written without checking explicitly if *obj* is " "``NULL``::" msgstr "" -#: ../../c-api/module.rst:537 +#: ../../c-api/module.rst:952 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -628,13 +1194,13 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:546 +#: ../../c-api/module.rst:961 msgid "" "Note that ``Py_XDECREF()`` should be used instead of ``Py_DECREF()`` in this " "case, since *obj* can be ``NULL``." msgstr "" -#: ../../c-api/module.rst:549 +#: ../../c-api/module.rst:964 msgid "" "The number of different *name* strings passed to this function should be " "kept small, usually by only using statically allocated strings as *name*. " @@ -644,7 +1210,7 @@ msgid "" "internally to create a key object." msgstr "" -#: ../../c-api/module.rst:562 +#: ../../c-api/module.rst:977 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but \":term:`steals `\" a " "reference to *value* (even on error). It can be called with a result of " @@ -652,7 +1218,7 @@ msgid "" "or even saving it to a variable." msgstr "" -#: ../../c-api/module.rst:569 +#: ../../c-api/module.rst:984 msgid "" "if (PyModule_Add(module, \"spam\", PyBytes_FromString(value)) < 0) {\n" " goto error;\n" @@ -662,7 +1228,7 @@ msgstr "" " goto error;\n" "}" -#: ../../c-api/module.rst:578 +#: ../../c-api/module.rst:993 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but :term:`steals ` a " "reference to *value* on success (if it returns ``0``)." @@ -670,26 +1236,26 @@ msgstr "" "類似於 :c:func:`PyModule_AddObjectRef`,但在成功時(如果回傳 ``0``)會" "「:term:`竊取 `」對 *value* 的參照。" -#: ../../c-api/module.rst:581 +#: ../../c-api/module.rst:996 msgid "" "The new :c:func:`PyModule_Add` or :c:func:`PyModule_AddObjectRef` functions " "are recommended, since it is easy to introduce reference leaks by misusing " "the :c:func:`PyModule_AddObject` function." msgstr "" -#: ../../c-api/module.rst:588 +#: ../../c-api/module.rst:1003 msgid "" "Unlike other functions that steal references, ``PyModule_AddObject()`` only " "releases the reference to *value* **on success**." msgstr "" -#: ../../c-api/module.rst:591 +#: ../../c-api/module.rst:1006 msgid "" "This means that its return value must be checked, and calling code must :c:" "func:`Py_XDECREF` *value* manually on error." msgstr "" -#: ../../c-api/module.rst:596 +#: ../../c-api/module.rst:1011 msgid "" "PyObject *obj = PyBytes_FromString(value);\n" "if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" @@ -703,20 +1269,20 @@ msgid "" "// Py_XDECREF(obj) is not needed here." msgstr "" -#: ../../c-api/module.rst:612 +#: ../../c-api/module.rst:1027 msgid "" "Add an integer constant to *module* as *name*. This convenience function " "can be used from the module's initialization function. Return ``-1`` with an " "exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:616 +#: ../../c-api/module.rst:1031 msgid "" "This is a convenience function that calls :c:func:`PyLong_FromLong` and :c:" "func:`PyModule_AddObjectRef`; see their documentation for details." msgstr "" -#: ../../c-api/module.rst:622 +#: ../../c-api/module.rst:1037 msgid "" "Add a string constant to *module* as *name*. This convenience function can " "be used from the module's initialization function. The string *value* must " @@ -724,14 +1290,14 @@ msgid "" "on success." msgstr "" -#: ../../c-api/module.rst:627 +#: ../../c-api/module.rst:1042 msgid "" "This is a convenience function that calls :c:func:" "`PyUnicode_InternFromString` and :c:func:`PyModule_AddObjectRef`; see their " "documentation for details." msgstr "" -#: ../../c-api/module.rst:634 +#: ../../c-api/module.rst:1049 msgid "" "Add an int constant to *module*. The name and the value are taken from " "*macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int " @@ -739,11 +1305,11 @@ msgid "" "with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:642 +#: ../../c-api/module.rst:1057 msgid "Add a string constant to *module*." msgstr "將字串常數加入到 *module* 中。" -#: ../../c-api/module.rst:646 +#: ../../c-api/module.rst:1061 msgid "" "Add a type object to *module*. The type object is finalized by calling " "internally :c:func:`PyType_Ready`. The name of the type object is taken from " @@ -751,7 +1317,7 @@ msgid "" "``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:656 +#: ../../c-api/module.rst:1071 msgid "" "Add the functions from the ``NULL`` terminated *functions* array to " "*module*. Refer to the :c:type:`PyMethodDef` documentation for details on " @@ -760,7 +1326,7 @@ msgid "" "first parameter, making them similar to instance methods on Python classes)." msgstr "" -#: ../../c-api/module.rst:662 +#: ../../c-api/module.rst:1077 msgid "" "This function is called automatically when creating a module from " "``PyModuleDef`` (such as when using :ref:`multi-phase-initialization`, " @@ -769,13 +1335,13 @@ msgid "" "that case they should call this function directly." msgstr "" -#: ../../c-api/module.rst:669 +#: ../../c-api/module.rst:1084 msgid "" "The *functions* array must be statically allocated (or otherwise guaranteed " "to outlive the module object)." msgstr "" -#: ../../c-api/module.rst:676 +#: ../../c-api/module.rst:1091 msgid "" "Set the docstring for *module* to *docstring*. This function is called " "automatically when creating a module from ``PyModuleDef`` (such as when " @@ -783,11 +1349,11 @@ msgid "" "``PyModule_FromDefAndSpec``)." msgstr "" -#: ../../c-api/module.rst:681 +#: ../../c-api/module.rst:1096 msgid "Return ``0`` on success. Return ``-1`` with an exception set on error." msgstr "成功時回傳 ``0``。在失敗時回傳 ``-1`` 並設定例外。" -#: ../../c-api/module.rst:688 +#: ../../c-api/module.rst:1103 msgid "" "Indicate that *module* does or does not support running without the global " "interpreter lock (GIL), using one of the values from :c:macro:`Py_mod_gil`. " @@ -799,11 +1365,11 @@ msgid "" "on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:702 +#: ../../c-api/module.rst:1117 msgid "Module lookup (single-phase initialization)" msgstr "" -#: ../../c-api/module.rst:704 +#: ../../c-api/module.rst:1119 msgid "" "The legacy :ref:`single-phase initialization ` " "initialization scheme creates singleton modules that can be looked up in the " @@ -811,14 +1377,14 @@ msgid "" "retrieved later with only a reference to the module definition." msgstr "" -#: ../../c-api/module.rst:709 +#: ../../c-api/module.rst:1124 msgid "" "These functions will not work on modules created using multi-phase " "initialization, since multiple such modules can be created from a single " "definition." msgstr "" -#: ../../c-api/module.rst:714 +#: ../../c-api/module.rst:1129 msgid "" "Returns the module object that was created from *def* for the current " "interpreter. This method requires that the module object has been attached " @@ -827,18 +1393,18 @@ msgid "" "to the interpreter state yet, it returns ``NULL``." msgstr "" -#: ../../c-api/module.rst:721 +#: ../../c-api/module.rst:1136 msgid "" "Attaches the module object passed to the function to the interpreter state. " "This allows the module object to be accessible via :c:func:" "`PyState_FindModule`." msgstr "" -#: ../../c-api/module.rst:724 +#: ../../c-api/module.rst:1139 msgid "Only effective on modules created using single-phase initialization." msgstr "" -#: ../../c-api/module.rst:726 +#: ../../c-api/module.rst:1141 msgid "" "Python calls ``PyState_AddModule`` automatically after importing a module " "that uses :ref:`single-phase initialization `, " @@ -850,21 +1416,21 @@ msgid "" "state updates)." msgstr "" -#: ../../c-api/module.rst:735 +#: ../../c-api/module.rst:1150 msgid "" "If a module was attached previously using the same *def*, it is replaced by " "the new *module*." msgstr "" -#: ../../c-api/module.rst:738 ../../c-api/module.rst:749 +#: ../../c-api/module.rst:1153 ../../c-api/module.rst:1164 msgid "The caller must have an :term:`attached thread state`." msgstr "" -#: ../../c-api/module.rst:740 +#: ../../c-api/module.rst:1155 msgid "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "成功時回傳 ``0``,在失敗時回傳 ``-1`` 並設定例外。" -#: ../../c-api/module.rst:746 +#: ../../c-api/module.rst:1161 msgid "" "Removes the module object created from *def* from the interpreter state. " "Return ``-1`` with an exception set on error, ``0`` on success." @@ -878,35 +1444,35 @@ msgstr "object(模組)" msgid "module" msgstr "module(模組)" -#: ../../c-api/module.rst:13 +#: ../../c-api/module.rst:12 msgid "ModuleType (in module types)" msgstr "MethodType(types 模組中)" -#: ../../c-api/module.rst:33 ../../c-api/module.rst:80 +#: ../../c-api/module.rst:32 ../../c-api/module.rst:79 msgid "__name__ (module attribute)" msgstr "__name__(模組屬性)" -#: ../../c-api/module.rst:33 +#: ../../c-api/module.rst:32 msgid "__doc__ (module attribute)" msgstr "__doc__(模組屬性)" -#: ../../c-api/module.rst:33 ../../c-api/module.rst:119 +#: ../../c-api/module.rst:32 ../../c-api/module.rst:111 msgid "__file__ (module attribute)" msgstr "__file__(模組屬性)" -#: ../../c-api/module.rst:33 +#: ../../c-api/module.rst:32 msgid "__package__ (module attribute)" msgstr "__package__(模組屬性)" -#: ../../c-api/module.rst:33 +#: ../../c-api/module.rst:32 msgid "__loader__ (module attribute)" msgstr "__loader__(模組屬性)" -#: ../../c-api/module.rst:63 +#: ../../c-api/module.rst:62 msgid "__dict__ (module attribute)" msgstr "__dict__(模組屬性)" -#: ../../c-api/module.rst:80 ../../c-api/module.rst:119 +#: ../../c-api/module.rst:79 ../../c-api/module.rst:111 msgid "SystemError (built-in exception)" msgstr "SystemError(內建例外)" diff --git a/c-api/object.po b/c-api/object.po index dafc388c923..6a298379d98 100644 --- a/c-api/object.po +++ b/c-api/object.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-23 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:32+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -174,25 +174,81 @@ msgstr "" #: ../../c-api/object.rst:90 msgid "" +"Dump an object *op* to ``stderr``. This should only be used for debugging." +msgstr "" + +#: ../../c-api/object.rst:92 +msgid "" +"The output is intended to try dumping objects even after memory corruption:" +msgstr "" + +#: ../../c-api/object.rst:94 +msgid "" +"Information is written starting with fields that are the least likely to " +"crash when accessed." +msgstr "" + +#: ../../c-api/object.rst:96 +msgid "" +"This function can be called without an :term:`attached thread state`, but " +"it's not recommended to do so: it can cause deadlocks." +msgstr "" + +#: ../../c-api/object.rst:98 +msgid "" +"An object that does not belong to the current interpreter may be dumped, but " +"this may also cause crashes or unintended behavior." +msgstr "" + +#: ../../c-api/object.rst:100 +msgid "" +"Implement a heuristic to detect if the object memory has been freed. Don't " +"display the object contents in this case, only its memory address." +msgstr "" + +#: ../../c-api/object.rst:102 +msgid "The output format may change at any time." +msgstr "" + +#: ../../c-api/object.rst:104 +msgid "Example of output:" +msgstr "" + +#: ../../c-api/object.rst:106 +msgid "" +"object address : 0x7f80124702c0\n" +"object refcount : 2\n" +"object type : 0x9902e0\n" +"object type name: str\n" +"object repr : 'abcdef'" +msgstr "" +"object address : 0x7f80124702c0\n" +"object refcount : 2\n" +"object type : 0x9902e0\n" +"object type name: str\n" +"object repr : 'abcdef'" + +#: ../../c-api/object.rst:119 +msgid "" "Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. " "This is equivalent to the Python expression ``hasattr(o, attr_name)``. On " "failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:99 +#: ../../c-api/object.rst:128 msgid "" "This is the same as :c:func:`PyObject_HasAttrWithError`, but *attr_name* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/object.rst:108 +#: ../../c-api/object.rst:137 msgid "" "Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. " "This function always succeeds." msgstr "" -#: ../../c-api/object.rst:113 +#: ../../c-api/object.rst:142 msgid "" "Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" "`~object.__getattribute__` methods aren't propagated, but instead given to :" @@ -201,14 +257,14 @@ msgid "" "`PyObject_GetAttr` instead." msgstr "" -#: ../../c-api/object.rst:122 +#: ../../c-api/object.rst:151 msgid "" "This is the same as :c:func:`PyObject_HasAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/object.rst:128 +#: ../../c-api/object.rst:157 msgid "" "Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" "`~object.__getattribute__` methods or while creating the temporary :class:" @@ -217,39 +273,39 @@ msgid "" "or :c:func:`PyObject_GetAttrString` instead." msgstr "" -#: ../../c-api/object.rst:138 +#: ../../c-api/object.rst:167 msgid "" "Retrieve an attribute named *attr_name* from object *o*. Returns the " "attribute value on success, or ``NULL`` on failure. This is the equivalent " "of the Python expression ``o.attr_name``." msgstr "" -#: ../../c-api/object.rst:142 +#: ../../c-api/object.rst:171 msgid "" "If the missing attribute should not be treated as a failure, you can use :c:" "func:`PyObject_GetOptionalAttr` instead." msgstr "" -#: ../../c-api/object.rst:148 +#: ../../c-api/object.rst:177 msgid "" "This is the same as :c:func:`PyObject_GetAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/object.rst:152 +#: ../../c-api/object.rst:181 msgid "" "If the missing attribute should not be treated as a failure, you can use :c:" "func:`PyObject_GetOptionalAttrString` instead." msgstr "" -#: ../../c-api/object.rst:158 +#: ../../c-api/object.rst:187 msgid "" "Variant of :c:func:`PyObject_GetAttr` which doesn't raise :exc:" "`AttributeError` if the attribute is not found." msgstr "" -#: ../../c-api/object.rst:161 +#: ../../c-api/object.rst:190 msgid "" "If the attribute is found, return ``1`` and set *\\*result* to a new :term:" "`strong reference` to the attribute. If the attribute is not found, return " @@ -258,14 +314,14 @@ msgid "" "``-1`` and set *\\*result* to ``NULL``." msgstr "" -#: ../../c-api/object.rst:173 +#: ../../c-api/object.rst:202 msgid "" "This is the same as :c:func:`PyObject_GetOptionalAttr`, but *attr_name* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/object.rst:181 +#: ../../c-api/object.rst:210 msgid "" "Generic attribute getter function that is meant to be put into a type " "object's ``tp_getattro`` slot. It looks for a descriptor in the dictionary " @@ -275,34 +331,45 @@ msgid "" "descriptors don't. Otherwise, an :exc:`AttributeError` is raised." msgstr "" -#: ../../c-api/object.rst:191 +#: ../../c-api/object.rst:220 msgid "" "Set the value of the attribute named *attr_name*, for object *o*, to the " "value *v*. Raise an exception and return ``-1`` on failure; return ``0`` on " "success. This is the equivalent of the Python statement ``o.attr_name = v``." msgstr "" -#: ../../c-api/object.rst:196 +#: ../../c-api/object.rst:225 msgid "" "If *v* is ``NULL``, the attribute is deleted. This behaviour is deprecated " "in favour of using :c:func:`PyObject_DelAttr`, but there are currently no " "plans to remove it." msgstr "" -#: ../../c-api/object.rst:203 +#: ../../c-api/object.rst:229 ../../c-api/object.rst:246 +msgid "" +"The function must not be called with a ``NULL`` *v* and an exception set. " +"This case can arise from forgetting ``NULL`` checks and would delete the " +"attribute." +msgstr "" + +#: ../../c-api/object.rst:233 ../../c-api/object.rst:258 +msgid "Must not be called with NULL value if an exception is set." +msgstr "" + +#: ../../c-api/object.rst:239 msgid "" "This is the same as :c:func:`PyObject_SetAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/object.rst:207 +#: ../../c-api/object.rst:243 msgid "" "If *v* is ``NULL``, the attribute is deleted, but this feature is deprecated " "in favour of using :c:func:`PyObject_DelAttrString`." msgstr "" -#: ../../c-api/object.rst:210 +#: ../../c-api/object.rst:250 msgid "" "The number of different attribute names passed to this function should be " "kept small, usually by using a statically allocated string as *attr_name*. " @@ -312,7 +379,7 @@ msgid "" "internally to create a key object." msgstr "" -#: ../../c-api/object.rst:220 +#: ../../c-api/object.rst:264 msgid "" "Generic attribute setter and deleter function that is meant to be put into a " "type object's :c:member:`~PyTypeObject.tp_setattro` slot. It looks for a " @@ -324,20 +391,20 @@ msgid "" "returned." msgstr "" -#: ../../c-api/object.rst:232 +#: ../../c-api/object.rst:276 msgid "" "Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on " "failure. This is the equivalent of the Python statement ``del o.attr_name``." msgstr "" -#: ../../c-api/object.rst:238 +#: ../../c-api/object.rst:282 msgid "" "This is the same as :c:func:`PyObject_DelAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/object.rst:242 +#: ../../c-api/object.rst:286 msgid "" "The number of different attribute names passed to this function should be " "kept small, usually by using a statically allocated string as *attr_name*. " @@ -347,13 +414,13 @@ msgid "" "internally to create a key object for lookup." msgstr "" -#: ../../c-api/object.rst:253 +#: ../../c-api/object.rst:297 msgid "" "A generic implementation for the getter of a ``__dict__`` descriptor. It " "creates the dictionary if necessary." msgstr "" -#: ../../c-api/object.rst:256 +#: ../../c-api/object.rst:300 msgid "" "This function may also be called to get the :py:attr:`~object.__dict__` of " "the object *o*. Pass ``NULL`` for *context* when calling it. Since this " @@ -362,30 +429,30 @@ msgid "" "the object." msgstr "" -#: ../../c-api/object.rst:262 +#: ../../c-api/object.rst:306 msgid "On failure, returns ``NULL`` with an exception set." msgstr "在失敗時,會回傳 ``NULL`` 並設定例外。" -#: ../../c-api/object.rst:269 +#: ../../c-api/object.rst:313 msgid "" "A generic implementation for the setter of a ``__dict__`` descriptor. This " "implementation does not allow the dictionary to be deleted." msgstr "" -#: ../../c-api/object.rst:277 +#: ../../c-api/object.rst:321 msgid "" "Return a pointer to :py:attr:`~object.__dict__` of the object *obj*. If " "there is no ``__dict__``, return ``NULL`` without setting an exception." msgstr "" -#: ../../c-api/object.rst:280 +#: ../../c-api/object.rst:324 msgid "" "This function may need to allocate memory for the dictionary, so it may be " "more efficient to call :c:func:`PyObject_GetAttr` when accessing an " "attribute on the object." msgstr "" -#: ../../c-api/object.rst:287 +#: ../../c-api/object.rst:331 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " "which must be one of :c:macro:`Py_LT`, :c:macro:`Py_LE`, :c:macro:`Py_EQ`, :" @@ -396,33 +463,33 @@ msgid "" "success, or ``NULL`` on failure." msgstr "" -#: ../../c-api/object.rst:297 +#: ../../c-api/object.rst:341 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " "like :c:func:`PyObject_RichCompare`, but returns ``-1`` on error, ``0`` if " "the result is false, ``1`` otherwise." msgstr "" -#: ../../c-api/object.rst:302 +#: ../../c-api/object.rst:346 msgid "" "If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool` " "will always return ``1`` for :c:macro:`Py_EQ` and ``0`` for :c:macro:`Py_NE`." msgstr "" -#: ../../c-api/object.rst:307 +#: ../../c-api/object.rst:351 msgid "" "Format *obj* using *format_spec*. This is equivalent to the Python " "expression ``format(obj, format_spec)``." msgstr "" -#: ../../c-api/object.rst:310 +#: ../../c-api/object.rst:354 msgid "" "*format_spec* may be ``NULL``. In this case the call is equivalent to " "``format(obj)``. Returns the formatted string on success, ``NULL`` on " "failure." msgstr "" -#: ../../c-api/object.rst:318 +#: ../../c-api/object.rst:362 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -430,18 +497,18 @@ msgid "" "function." msgstr "" -#: ../../c-api/object.rst:322 ../../c-api/object.rst:338 -#: ../../c-api/object.rst:350 +#: ../../c-api/object.rst:366 ../../c-api/object.rst:382 +#: ../../c-api/object.rst:394 msgid "If argument is ``NULL``, return the string ``''``." msgstr "" -#: ../../c-api/object.rst:324 ../../c-api/object.rst:352 +#: ../../c-api/object.rst:368 ../../c-api/object.rst:396 msgid "" "This function now includes a debug assertion to help ensure that it does not " "silently discard an active exception." msgstr "" -#: ../../c-api/object.rst:332 +#: ../../c-api/object.rst:376 msgid "" "As :c:func:`PyObject_Repr`, compute a string representation of object *o*, " "but escape the non-ASCII characters in the string returned by :c:func:" @@ -450,7 +517,7 @@ msgid "" "Called by the :func:`ascii` built-in function." msgstr "" -#: ../../c-api/object.rst:345 +#: ../../c-api/object.rst:389 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -458,7 +525,7 @@ msgid "" "function and, therefore, by the :func:`print` function." msgstr "" -#: ../../c-api/object.rst:361 +#: ../../c-api/object.rst:405 msgid "" "Compute a bytes representation of object *o*. ``NULL`` is returned on " "failure and a bytes object on success. This is equivalent to the Python " @@ -467,25 +534,25 @@ msgid "" "bytes object." msgstr "" -#: ../../c-api/object.rst:367 +#: ../../c-api/object.rst:411 msgid "" "If argument is ``NULL``, return the :class:`bytes` object ``b''``." msgstr "" -#: ../../c-api/object.rst:372 +#: ../../c-api/object.rst:416 msgid "" "Return ``1`` if the class *derived* is identical to or derived from the " "class *cls*, otherwise return ``0``. In case of an error, return ``-1``." msgstr "" -#: ../../c-api/object.rst:375 ../../c-api/object.rst:394 +#: ../../c-api/object.rst:419 ../../c-api/object.rst:438 msgid "" "If *cls* is a tuple, the check will be done against every entry in *cls*. " "The result will be ``1`` when at least one of the checks returns ``1``, " "otherwise it will be ``0``." msgstr "" -#: ../../c-api/object.rst:379 +#: ../../c-api/object.rst:423 msgid "" "If *cls* has a :meth:`~type.__subclasscheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " @@ -493,52 +560,52 @@ msgid "" "e. contained in :attr:`cls.__mro__ `." msgstr "" -#: ../../c-api/object.rst:384 +#: ../../c-api/object.rst:428 msgid "" "Normally only class objects, i.e. instances of :class:`type` or a derived " "class, are considered classes. However, objects can override this by having " "a :attr:`~type.__bases__` attribute (which must be a tuple of base classes)." msgstr "" -#: ../../c-api/object.rst:391 +#: ../../c-api/object.rst:435 msgid "" "Return ``1`` if *inst* is an instance of the class *cls* or a subclass of " "*cls*, or ``0`` if not. On error, returns ``-1`` and sets an exception." msgstr "" -#: ../../c-api/object.rst:398 +#: ../../c-api/object.rst:442 msgid "" "If *cls* has a :meth:`~type.__instancecheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " "*inst* is an instance of *cls* if its class is a subclass of *cls*." msgstr "" -#: ../../c-api/object.rst:402 +#: ../../c-api/object.rst:446 msgid "" "An instance *inst* can override what is considered its class by having a :" "attr:`~object.__class__` attribute." msgstr "" -#: ../../c-api/object.rst:405 +#: ../../c-api/object.rst:449 msgid "" "An object *cls* can override if it is considered a class, and what its base " "classes are, by having a :attr:`~type.__bases__` attribute (which must be a " "tuple of base classes)." msgstr "" -#: ../../c-api/object.rst:414 +#: ../../c-api/object.rst:458 msgid "" "Compute and return the hash value of an object *o*. On failure, return " "``-1``. This is the equivalent of the Python expression ``hash(o)``." msgstr "" -#: ../../c-api/object.rst:417 +#: ../../c-api/object.rst:461 msgid "" "The return type is now Py_hash_t. This is a signed integer the same size " "as :c:type:`Py_ssize_t`." msgstr "" -#: ../../c-api/object.rst:424 +#: ../../c-api/object.rst:468 msgid "" "Set a :exc:`TypeError` indicating that ``type(o)`` is not :term:`hashable` " "and return ``-1``. This function receives special treatment when stored in a " @@ -546,21 +613,21 @@ msgid "" "that it is not hashable." msgstr "" -#: ../../c-api/object.rst:432 +#: ../../c-api/object.rst:476 msgid "" "Returns ``1`` if the object *o* is considered to be true, and ``0`` " "otherwise. This is equivalent to the Python expression ``not not o``. On " "failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:439 +#: ../../c-api/object.rst:483 msgid "" "Returns ``0`` if the object *o* is considered to be true, and ``1`` " "otherwise. This is equivalent to the Python expression ``not o``. On " "failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:448 +#: ../../c-api/object.rst:492 msgid "" "When *o* is non-``NULL``, returns a type object corresponding to the object " "type of object *o*. On failure, raises :exc:`SystemError` and returns " @@ -571,13 +638,13 @@ msgid "" "when a new :term:`strong reference` is needed." msgstr "" -#: ../../c-api/object.rst:460 +#: ../../c-api/object.rst:504 msgid "" "Return non-zero if the object *o* is of type *type* or a subtype of *type*, " "and ``0`` otherwise. Both parameters must be non-``NULL``." msgstr "" -#: ../../c-api/object.rst:469 +#: ../../c-api/object.rst:513 msgid "" "Return the length of object *o*. If the object *o* provides either the " "sequence and mapping protocols, the sequence length is returned. On error, " @@ -585,7 +652,7 @@ msgid "" "``len(o)``." msgstr "" -#: ../../c-api/object.rst:476 +#: ../../c-api/object.rst:520 msgid "" "Return an estimated length for the object *o*. First try to return its " "actual length, then an estimate using :meth:`~object.__length_hint__`, and " @@ -594,33 +661,33 @@ msgid "" "defaultvalue)``." msgstr "" -#: ../../c-api/object.rst:486 +#: ../../c-api/object.rst:530 msgid "" "Return element of *o* corresponding to the object *key* or ``NULL`` on " "failure. This is the equivalent of the Python expression ``o[key]``." msgstr "" -#: ../../c-api/object.rst:492 +#: ../../c-api/object.rst:536 msgid "" "Map the object *key* to the value *v*. Raise an exception and return ``-1`` " "on failure; return ``0`` on success. This is the equivalent of the Python " "statement ``o[key] = v``. This function *does not* steal a reference to *v*." msgstr "" -#: ../../c-api/object.rst:500 +#: ../../c-api/object.rst:544 msgid "" "Remove the mapping for the object *key* from the object *o*. Return ``-1`` " "on failure. This is equivalent to the Python statement ``del o[key]``." msgstr "" -#: ../../c-api/object.rst:506 +#: ../../c-api/object.rst:550 msgid "" "This is the same as :c:func:`PyObject_DelItem`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" -#: ../../c-api/object.rst:513 +#: ../../c-api/object.rst:557 msgid "" "This is equivalent to the Python expression ``dir(o)``, returning a " "(possibly empty) list of strings appropriate for the object argument, or " @@ -630,7 +697,7 @@ msgid "" "`PyErr_Occurred` will return false." msgstr "" -#: ../../c-api/object.rst:522 +#: ../../c-api/object.rst:566 msgid "" "This is equivalent to the Python expression ``iter(o)``. It returns a new " "iterator for the object argument, or the object itself if the object is " @@ -638,14 +705,14 @@ msgid "" "object cannot be iterated." msgstr "" -#: ../../c-api/object.rst:530 +#: ../../c-api/object.rst:574 msgid "" "This is equivalent to the Python ``__iter__(self): return self`` method. It " "is intended for :term:`iterator` types, to be used in the :c:member:" "`PyTypeObject.tp_iter` slot." msgstr "" -#: ../../c-api/object.rst:536 +#: ../../c-api/object.rst:580 msgid "" "This is the equivalent to the Python expression ``aiter(o)``. Takes an :" "class:`AsyncIterable` object and returns an :class:`AsyncIterator` for it. " @@ -654,51 +721,51 @@ msgid "" "``NULL`` if the object cannot be iterated." msgstr "" -#: ../../c-api/object.rst:546 +#: ../../c-api/object.rst:590 msgid "Get a pointer to subclass-specific data reserved for *cls*." msgstr "" -#: ../../c-api/object.rst:548 +#: ../../c-api/object.rst:592 msgid "" "The object *o* must be an instance of *cls*, and *cls* must have been " "created using negative :c:member:`PyType_Spec.basicsize`. Python does not " "check this." msgstr "" -#: ../../c-api/object.rst:552 +#: ../../c-api/object.rst:596 msgid "On error, set an exception and return ``NULL``." msgstr "錯誤時設定一個例外並回傳 ``NULL``。" -#: ../../c-api/object.rst:558 +#: ../../c-api/object.rst:602 msgid "" "Return the size of the instance memory space reserved for *cls*, i.e. the " "size of the memory :c:func:`PyObject_GetTypeData` returns." msgstr "" -#: ../../c-api/object.rst:561 +#: ../../c-api/object.rst:605 msgid "" "This may be larger than requested using :c:member:`-PyType_Spec.basicsize " "`; it is safe to use this larger size (e.g. with :c:" "func:`!memset`)." msgstr "" -#: ../../c-api/object.rst:564 +#: ../../c-api/object.rst:608 msgid "" "The type *cls* **must** have been created using negative :c:member:" "`PyType_Spec.basicsize`. Python does not check this." msgstr "" -#: ../../c-api/object.rst:568 +#: ../../c-api/object.rst:612 msgid "On error, set an exception and return a negative value." msgstr "錯誤時設定一個例外並回傳一個負值。" -#: ../../c-api/object.rst:574 +#: ../../c-api/object.rst:618 msgid "" "Get a pointer to per-item data for a class with :c:macro:" "`Py_TPFLAGS_ITEMS_AT_END`." msgstr "" -#: ../../c-api/object.rst:577 +#: ../../c-api/object.rst:621 msgid "" "On error, set an exception and return ``NULL``. :py:exc:`TypeError` is " "raised if *o* does not have :c:macro:`Py_TPFLAGS_ITEMS_AT_END` set." @@ -706,27 +773,27 @@ msgstr "" "錯誤時設定一個例外並回傳 ``NULL``。如果 *o* 沒有設定 :c:macro:" "`Py_TPFLAGS_ITEMS_AT_END`,則會引發 :py:exc:`TypeError`。" -#: ../../c-api/object.rst:585 +#: ../../c-api/object.rst:629 msgid "Visit the managed dictionary of *obj*." msgstr "" -#: ../../c-api/object.rst:587 +#: ../../c-api/object.rst:631 msgid "" "This function must only be called in a traverse function of the type which " "has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set." msgstr "" -#: ../../c-api/object.rst:594 +#: ../../c-api/object.rst:638 msgid "Clear the managed dictionary of *obj*." msgstr "" -#: ../../c-api/object.rst:596 +#: ../../c-api/object.rst:640 msgid "" "This function must only be called in a clear function of the type which has " "the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set." msgstr "" -#: ../../c-api/object.rst:603 +#: ../../c-api/object.rst:647 msgid "" "Enable `deferred reference counting `_ on *obj*, if supported by the runtime. In " @@ -737,7 +804,7 @@ msgid "" "no longer has any references to it." msgstr "" -#: ../../c-api/object.rst:610 +#: ../../c-api/object.rst:654 msgid "" "This function returns ``1`` if deferred reference counting is enabled on " "*obj*, and ``0`` if deferred reference counting is not supported or if the " @@ -746,7 +813,7 @@ msgid "" "cannot fail." msgstr "" -#: ../../c-api/object.rst:615 +#: ../../c-api/object.rst:659 msgid "" "This function does nothing on builds with the :term:`GIL` enabled, which do " "not support deferred reference counting. This also does nothing if *obj* is " @@ -754,14 +821,14 @@ msgid "" "and :c:func:`PyObject_GC_IsTracked`)." msgstr "" -#: ../../c-api/object.rst:620 +#: ../../c-api/object.rst:664 msgid "" "This function is intended to be used soon after *obj* is created, by the " "code that creates it, such as in the object's :c:member:`~PyTypeObject." "tp_new` slot." msgstr "" -#: ../../c-api/object.rst:628 +#: ../../c-api/object.rst:672 msgid "" "Check if *obj* is a unique temporary object. Returns ``1`` if *obj* is known " "to be a unique temporary object, and ``0`` otherwise. This function cannot " @@ -769,7 +836,7 @@ msgid "" "if *obj* is a unique temporary object." msgstr "" -#: ../../c-api/object.rst:634 +#: ../../c-api/object.rst:678 msgid "" "If an object is a unique temporary, it is guaranteed that the current code " "has the only reference to the object. For arguments to C functions, this " @@ -781,23 +848,23 @@ msgid "" "argument uniquely referenced." msgstr "" -#: ../../c-api/object.rst:643 +#: ../../c-api/object.rst:687 msgid "" "In the example below, ``my_func`` is called with a unique temporary object " "as its argument::" msgstr "" -#: ../../c-api/object.rst:646 +#: ../../c-api/object.rst:690 msgid "my_func([1, 2, 3])" msgstr "my_func([1, 2, 3])" -#: ../../c-api/object.rst:648 +#: ../../c-api/object.rst:692 msgid "" "In the example below, ``my_func`` is **not** called with a unique temporary " "object as its argument, even if its refcount is ``1``::" msgstr "" -#: ../../c-api/object.rst:651 +#: ../../c-api/object.rst:695 msgid "" "my_list = [1, 2, 3]\n" "my_func(my_list)" @@ -805,43 +872,43 @@ msgstr "" "my_list = [1, 2, 3]\n" "my_func(my_list)" -#: ../../c-api/object.rst:654 +#: ../../c-api/object.rst:698 msgid "See also the function :c:func:`Py_REFCNT`." msgstr "另請參閱 :c:func:`Py_REFCNT` 函式。" -#: ../../c-api/object.rst:660 +#: ../../c-api/object.rst:704 msgid "" "This function returns non-zero if *obj* is :term:`immortal`, and zero " "otherwise. This function cannot fail." msgstr "" -#: ../../c-api/object.rst:665 +#: ../../c-api/object.rst:709 msgid "" "Objects that are immortal in one CPython version are not guaranteed to be " "immortal in another." msgstr "" -#: ../../c-api/object.rst:672 +#: ../../c-api/object.rst:716 msgid "" "Increments the reference count of *obj* if it is not zero. Returns ``1`` if " "the object's reference count was successfully incremented. Otherwise, this " "function returns ``0``." msgstr "" -#: ../../c-api/object.rst:676 +#: ../../c-api/object.rst:720 msgid "" ":c:func:`PyUnstable_EnableTryIncRef` must have been called earlier on *obj* " "or this function may spuriously return ``0`` in the :term:`free-threaded " "build`." msgstr "" -#: ../../c-api/object.rst:680 +#: ../../c-api/object.rst:724 msgid "" "This function is logically equivalent to the following C code, except that " "it behaves atomically in the :term:`free-threaded build`::" msgstr "" -#: ../../c-api/object.rst:683 +#: ../../c-api/object.rst:727 msgid "" "if (Py_REFCNT(op) > 0) {\n" " Py_INCREF(op);\n" @@ -855,13 +922,13 @@ msgstr "" "}\n" "return 0;" -#: ../../c-api/object.rst:689 +#: ../../c-api/object.rst:733 msgid "" "This is intended as a building block for managing weak references without " "the overhead of a Python :ref:`weak reference object `." msgstr "" -#: ../../c-api/object.rst:692 +#: ../../c-api/object.rst:736 msgid "" "Typically, correct use of this function requires support from *obj*'s " "deallocator (:c:member:`~PyTypeObject.tp_dealloc`). For example, the " @@ -869,7 +936,7 @@ msgid "" "a :py:class:`~weakref.WeakValueDictionary` for a specific type:" msgstr "" -#: ../../c-api/object.rst:698 +#: ../../c-api/object.rst:742 msgid "" "PyMutex mutex;\n" "\n" @@ -914,23 +981,23 @@ msgid "" "}" msgstr "" -#: ../../c-api/object.rst:746 +#: ../../c-api/object.rst:790 msgid "" "Enables subsequent uses of :c:func:`PyUnstable_TryIncRef` on *obj*. The " "caller must hold a :term:`strong reference` to *obj* when calling this." msgstr "" -#: ../../c-api/object.rst:753 +#: ../../c-api/object.rst:797 msgid "Determine if *op* only has one reference." msgstr "" -#: ../../c-api/object.rst:755 +#: ../../c-api/object.rst:799 msgid "" "On GIL-enabled builds, this function is equivalent to :c:expr:`Py_REFCNT(op) " "== 1`." msgstr "" -#: ../../c-api/object.rst:758 +#: ../../c-api/object.rst:802 msgid "" "On a :term:`free-threaded build`, this checks if *op*'s :term:`reference " "count` is equal to one and additionally checks if *op* is only used by this " @@ -938,47 +1005,71 @@ msgid "" "builds; prefer this function." msgstr "" -#: ../../c-api/object.rst:763 +#: ../../c-api/object.rst:807 msgid "" "The caller must hold an :term:`attached thread state`, despite the fact that " "this function doesn't call into the Python interpreter. This function cannot " "fail." msgstr "" -#: ../../c-api/object.rst:316 ../../c-api/object.rst:330 -#: ../../c-api/object.rst:359 ../../c-api/object.rst:412 -#: ../../c-api/object.rst:446 ../../c-api/object.rst:467 +#: ../../c-api/object.rst:815 +msgid "" +"Marks the object *op* :term:`immortal`. The argument should be uniquely " +"referenced by the calling thread. This is intended to be used for reducing " +"reference counting contention in the :term:`free-threaded build` for objects " +"which are shared across threads." +msgstr "" + +#: ../../c-api/object.rst:819 +msgid "" +"This is a one-way process: objects can only be made immortal; they cannot be " +"made mortal once again. Immortal objects do not participate in reference " +"counting and will never be garbage collected. If the object is GC-tracked, " +"it is untracked." +msgstr "" + +#: ../../c-api/object.rst:823 +msgid "" +"This function is intended to be used soon after *op* is created, by the code " +"that creates it, such as in the object's :c:member:`~PyTypeObject.tp_new` " +"slot. Returns 1 if the object was made immortal and returns 0 if it was not. " +"This function cannot fail." +msgstr "" + +#: ../../c-api/object.rst:360 ../../c-api/object.rst:374 +#: ../../c-api/object.rst:403 ../../c-api/object.rst:456 +#: ../../c-api/object.rst:490 ../../c-api/object.rst:511 msgid "built-in function" msgstr "bulit-in function(內建函式)" -#: ../../c-api/object.rst:316 +#: ../../c-api/object.rst:360 msgid "repr" msgstr "repr" -#: ../../c-api/object.rst:330 +#: ../../c-api/object.rst:374 msgid "ascii" msgstr "ascii" -#: ../../c-api/object.rst:340 +#: ../../c-api/object.rst:384 msgid "string" msgstr "string(字串)" -#: ../../c-api/object.rst:340 +#: ../../c-api/object.rst:384 msgid "PyObject_Str (C function)" msgstr "PyObject_Str(C 函式)" -#: ../../c-api/object.rst:359 +#: ../../c-api/object.rst:403 msgid "bytes" msgstr "bytes(位元組)" -#: ../../c-api/object.rst:412 +#: ../../c-api/object.rst:456 msgid "hash" msgstr "hash(雜湊)" -#: ../../c-api/object.rst:446 +#: ../../c-api/object.rst:490 msgid "type" msgstr "type(型別)" -#: ../../c-api/object.rst:467 +#: ../../c-api/object.rst:511 msgid "len" msgstr "len" diff --git a/c-api/perfmaps.po b/c-api/perfmaps.po index 3484611fcd0..41d02091fb5 100644 --- a/c-api/perfmaps.po +++ b/c-api/perfmaps.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-19 00:28+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-05-11 14:42+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,24 +23,25 @@ msgstr "對 Perf Map 的支援" #: ../../c-api/perfmaps.rst:8 msgid "" -"On supported platforms (as of this writing, only Linux), the runtime can " -"take advantage of *perf map files* to make Python functions visible to an " -"external profiling tool (such as `perf `_). A running process may create a file in the ``/tmp`` " -"directory, which contains entries that can map a section of executable code " -"to a name. This interface is described in the `documentation of the Linux " -"Perf tool `_." -msgstr "" -"在支援的平台上(截至撰寫本文時,僅限 Linux),runtime 可以利用 *perf map 檔案" -"*\\ 使得外部分析工具(例如 `perf `_)可以見到 Python 函式。正在運行的行程可能會在 ``/tmp`` 目錄中建" -"立一個檔案,其中包含可以將一段可執行程式碼對映到名稱的各個條目。此介面在 " -"`Linux Perf 工具的文件 `_\\ 中有" -"被描述。" - -#: ../../c-api/perfmaps.rst:16 +"On supported platforms (Linux and macOS), the runtime can take advantage of " +"*perf map files* to make Python functions visible to an external profiling " +"tool (such as `perf `_ or " +"`samply `_). A running process may " +"create a file in the ``/tmp`` directory, which contains entries that can map " +"a section of executable code to a name. This interface is described in the " +"`documentation of the Linux Perf tool `_." +msgstr "" +"在支援的平台上(Linux 和 macOS),runtime 可以利用 *perf map 檔案*\\ 使得外部" +"分析工具(例如 `perf `_ 或 " +"`samply `_)可以見到 Python 函式。正在運" +"行的行程可能會在 ``/tmp`` 目錄中建立一個檔案,其中包含可以將一段可執行程式碼" +"對映到名稱的各個條目。此介面在 `Linux Perf 工具的文件 `_\\ 中有被描述。" + +#: ../../c-api/perfmaps.rst:17 msgid "" "In Python, these helper APIs can be used by libraries and features that rely " "on generating machine code on the fly." @@ -48,13 +49,13 @@ msgstr "" "在 Python 中,這些輔助 API 可以被依賴於運行期間 (on the fly) 產生機器碼的函式" "庫和功能所使用。" -#: ../../c-api/perfmaps.rst:19 +#: ../../c-api/perfmaps.rst:20 msgid "" "Note that holding an :term:`attached thread state` is not required for these " "APIs." msgstr "請注意,這些 API 不需要持有 :term:`attached thread state`。" -#: ../../c-api/perfmaps.rst:23 +#: ../../c-api/perfmaps.rst:24 msgid "" "Open the ``/tmp/perf-$pid.map`` file, unless it's already opened, and create " "a lock to ensure thread-safe writes to the file (provided the writes are " @@ -68,7 +69,7 @@ msgstr "" "`PyUnstable_WritePerfMapEntry` 完成的)。通常不需要明確地呼叫它;只需使用 :c:" "func:`PyUnstable_WritePerfMapEntry` 它就會在首次呼叫時初始化狀態。" -#: ../../c-api/perfmaps.rst:29 +#: ../../c-api/perfmaps.rst:30 msgid "" "Returns ``0`` on success, ``-1`` on failure to create/open the perf map " "file, or ``-2`` on failure to create a lock. Check ``errno`` for more " @@ -77,7 +78,7 @@ msgstr "" "建立/打開 perf map 檔案成功時回傳 ``0``,失敗時回傳 ``-1``,建立鎖時失敗則回" "傳 ``-2``。檢查 ``errno`` 以取得更多造成失敗的資訊。" -#: ../../c-api/perfmaps.rst:35 +#: ../../c-api/perfmaps.rst:36 msgid "" "Write one single entry to the ``/tmp/perf-$pid.map`` file. This function is " "thread safe. Here is what an example entry looks like::" @@ -85,7 +86,7 @@ msgstr "" "將單一條目寫入 ``/tmp/perf-$pid.map`` 檔案。此函式是執行緒安全的。以下是一個" "條目的範例:" -#: ../../c-api/perfmaps.rst:38 +#: ../../c-api/perfmaps.rst:39 msgid "" "# address size name\n" "7f3529fcf759 b py::bar:/run/t.py" @@ -93,7 +94,7 @@ msgstr "" "# 位址 大小 名稱\n" "7f3529fcf759 b py::bar:/run/t.py" -#: ../../c-api/perfmaps.rst:41 +#: ../../c-api/perfmaps.rst:42 msgid "" "Will call :c:func:`PyUnstable_PerfMapState_Init` before writing the entry, " "if the perf map file is not already opened. Returns ``0`` on success, or the " @@ -103,7 +104,7 @@ msgstr "" "`PyUnstable_PerfMapState_Init`。成功時回傳 ``0``,失敗時回傳與 :c:func:" "`PyUnstable_PerfMapState_Init` 失敗時相同的錯誤碼。" -#: ../../c-api/perfmaps.rst:47 +#: ../../c-api/perfmaps.rst:48 msgid "" "Close the perf map file opened by :c:func:`PyUnstable_PerfMapState_Init`. " "This is called by the runtime itself during interpreter shut-down. In " @@ -114,30 +115,30 @@ msgstr "" "譯器關閉期間由 runtime 本身呼叫的。一般來說,除了處理 forking 等特定場景外," "不應該明確地呼叫它。" -#: ../../c-api/perfmaps.rst:54 +#: ../../c-api/perfmaps.rst:55 msgid "" "Open the ``/tmp/perf-$pid.map`` file and append the content of " "*parent_filename* to it." msgstr "" -#: ../../c-api/perfmaps.rst:57 +#: ../../c-api/perfmaps.rst:58 msgid "" "This function is available on all platforms but only generates output on " "platforms that support perf maps (currently only Linux). On other platforms, " "it does nothing." msgstr "" -#: ../../c-api/perfmaps.rst:64 +#: ../../c-api/perfmaps.rst:65 msgid "Compile the given code object using the current perf trampoline." msgstr "" -#: ../../c-api/perfmaps.rst:66 +#: ../../c-api/perfmaps.rst:67 msgid "" "The \"current\" trampoline is the one set by the runtime or the most recent :" "c:func:`PyUnstable_PerfTrampoline_SetPersistAfterFork` call." msgstr "" -#: ../../c-api/perfmaps.rst:69 +#: ../../c-api/perfmaps.rst:70 msgid "" "If no trampoline is set, falls back to normal compilation (no perf map " "entry)." @@ -147,7 +148,7 @@ msgstr "" msgid "Parameters" msgstr "" -#: ../../c-api/perfmaps.rst:71 +#: ../../c-api/perfmaps.rst:72 msgid "The code object to compile." msgstr "" @@ -155,30 +156,30 @@ msgstr "" msgid "Returns" msgstr "" -#: ../../c-api/perfmaps.rst:72 ../../c-api/perfmaps.rst:88 +#: ../../c-api/perfmaps.rst:73 ../../c-api/perfmaps.rst:89 msgid "0 on success, -1 on failure." msgstr "" -#: ../../c-api/perfmaps.rst:78 +#: ../../c-api/perfmaps.rst:79 msgid "Set whether the perf trampoline should persist after a fork." msgstr "" -#: ../../c-api/perfmaps.rst:80 +#: ../../c-api/perfmaps.rst:81 msgid "" "If ``enable`` is true (non-zero): perf map file remains open/valid post-" "fork. Child process inherits all existing perf map entries." msgstr "" -#: ../../c-api/perfmaps.rst:82 +#: ../../c-api/perfmaps.rst:83 msgid "" "If ``enable`` is false (zero): perf map closes post-fork. Child process gets " "empty perf map." msgstr "" -#: ../../c-api/perfmaps.rst:85 +#: ../../c-api/perfmaps.rst:86 msgid "Default: false (clears on fork)." msgstr "" -#: ../../c-api/perfmaps.rst:87 +#: ../../c-api/perfmaps.rst:88 msgid "1 to enable, 0 to disable." msgstr "" diff --git a/c-api/sentinel.po b/c-api/sentinel.po new file mode 100644 index 00000000000..92cf15154c8 --- /dev/null +++ b/c-api/sentinel.po @@ -0,0 +1,60 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../c-api/sentinel.rst:6 +msgid "Sentinel objects" +msgstr "" + +#: ../../c-api/sentinel.rst:10 +msgid "" +"This instance of :c:type:`PyTypeObject` represents the Python :class:" +"`sentinel` type. This is the same object as :class:`sentinel`." +msgstr "" + +#: ../../c-api/sentinel.rst:17 +msgid "" +"Return true if *o* is a :class:`sentinel` object or a subtype. The :class:" +"`sentinel` type does not currently allow subclasses, so this check is exact. " +"Future Python versions may choose to allow subtyping. This function always " +"succeeds." +msgstr "" + +#: ../../c-api/sentinel.rst:27 +msgid "" +"Return true if *o* is a :class:`sentinel` object, but not a subtype. The :" +"class:`sentinel` type does not currently allow subclasses. Future Python " +"versions may choose to allow subtyping. This function always succeeds." +msgstr "" + +#: ../../c-api/sentinel.rst:36 +msgid "" +"Return a new :class:`sentinel` object with :attr:`~sentinel.__name__` set to " +"*name* and :attr:`~sentinel.__module__` set to *module_name*. *name* must " +"not be ``NULL``. If *module_name* is ``NULL``, :attr:`~sentinel.__module__` " +"is set to ``None``. If *repr* is ``NULL``, ``repr()`` returns :attr:" +"`~sentinel.__name__`. Return ``NULL`` with an exception set on failure." +msgstr "" + +#: ../../c-api/sentinel.rst:42 +msgid "" +"For pickling to work, *module_name* must be the name of an importable " +"module, and the sentinel must be accessible from that module under a path " +"matching *name*. Pickle treats *name* as a global variable name in " +"*module_name* (see :meth:`object.__reduce__`)." +msgstr "" diff --git a/c-api/set.po b/c-api/set.po index 2669ebacadf..62da4b80641 100644 --- a/c-api/set.po +++ b/c-api/set.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-08 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,7 +21,7 @@ msgstr "" msgid "Set Objects" msgstr "集合物件" -#: ../../c-api/set.rst:15 +#: ../../c-api/set.rst:12 msgid "" "This section details the public API for :class:`set` and :class:`frozenset` " "objects. Any functionality not listed below is best accessed using either " @@ -35,7 +35,7 @@ msgid "" "`PyNumber_InPlaceXor`)." msgstr "" -#: ../../c-api/set.rst:29 +#: ../../c-api/set.rst:26 msgid "" "This subtype of :c:type:`PyObject` is used to hold the internal data for " "both :class:`set` and :class:`frozenset` objects. It is like a :c:type:" @@ -47,25 +47,25 @@ msgid "" "manipulating the values in the structure." msgstr "" -#: ../../c-api/set.rst:40 +#: ../../c-api/set.rst:37 msgid "" "This is an instance of :c:type:`PyTypeObject` representing the Python :class:" "`set` type." msgstr "" -#: ../../c-api/set.rst:46 +#: ../../c-api/set.rst:43 msgid "" "This is an instance of :c:type:`PyTypeObject` representing the Python :class:" "`frozenset` type." msgstr "" -#: ../../c-api/set.rst:49 +#: ../../c-api/set.rst:46 msgid "" "The following type check macros work on pointers to any Python object. " "Likewise, the constructor functions work with any iterable Python object." msgstr "" -#: ../../c-api/set.rst:55 +#: ../../c-api/set.rst:52 msgid "" "Return true if *p* is a :class:`set` object or an instance of a subtype. " "This function always succeeds." @@ -73,7 +73,7 @@ msgstr "" "如果 *p* 是 :class:`set` 物件或是子類別的實例,則回傳 true。此函式總會成功執" "行。" -#: ../../c-api/set.rst:60 +#: ../../c-api/set.rst:57 msgid "" "Return true if *p* is a :class:`frozenset` object or an instance of a " "subtype. This function always succeeds." @@ -81,7 +81,7 @@ msgstr "" "如果 *p* 是 :class:`frozenset` 物件或是子類別的實例,則回傳 true。此函式總會" "成功執行。" -#: ../../c-api/set.rst:65 +#: ../../c-api/set.rst:62 msgid "" "Return true if *p* is a :class:`set` object, a :class:`frozenset` object, or " "an instance of a subtype. This function always succeeds." @@ -89,7 +89,7 @@ msgstr "" "如果 *p* 是 :class:`set` 物件、:class:`frozenset` 物件,或是子類別的實例,則" "回傳 true。此函式總會成功執行。" -#: ../../c-api/set.rst:70 +#: ../../c-api/set.rst:67 msgid "" "Return true if *p* is a :class:`set` object but not an instance of a " "subtype. This function always succeeds." @@ -97,7 +97,7 @@ msgstr "" "如果 *p* 是 :class:`set` 物件但不是子類別的實例,則回傳 true。此函式總會成功" "執行。" -#: ../../c-api/set.rst:77 +#: ../../c-api/set.rst:74 msgid "" "Return true if *p* is a :class:`set` object or a :class:`frozenset` object " "but not an instance of a subtype. This function always succeeds." @@ -105,7 +105,7 @@ msgstr "" "如果 *p* 是 :class:`set` 物件或 :class:`frozenset` 物件但不是子類別的實例,則" "回傳 true。此函式總會成功執行。" -#: ../../c-api/set.rst:83 +#: ../../c-api/set.rst:80 msgid "" "Return true if *p* is a :class:`frozenset` object but not an instance of a " "subtype. This function always succeeds." @@ -113,7 +113,7 @@ msgstr "" "如果 *p* 是 :class:`frozenset` 物件但不是子類別的實例,則回傳 true。此函式總" "會成功執行。" -#: ../../c-api/set.rst:89 +#: ../../c-api/set.rst:86 msgid "" "Return a new :class:`set` containing objects returned by the *iterable*. " "The *iterable* may be ``NULL`` to create a new empty set. Return the new " @@ -122,13 +122,14 @@ msgid "" "(``c=set(s)``)." msgstr "" -#: ../../c-api/set.rst:97 ../../c-api/set.rst:110 +#: ../../c-api/set.rst:94 ../../c-api/set.rst:107 msgid "" "The operation is atomic on :term:`free threading ` when " -"*iterable* is a :class:`set`, :class:`frozenset` or :class:`dict`." +"*iterable* is a :class:`set`, :class:`frozenset`, :class:`dict` or :class:" +"`frozendict`." msgstr "" -#: ../../c-api/set.rst:103 +#: ../../c-api/set.rst:100 msgid "" "Return a new :class:`frozenset` containing objects returned by the " "*iterable*. The *iterable* may be ``NULL`` to create a new empty frozenset. " @@ -136,24 +137,24 @@ msgid "" "`TypeError` if *iterable* is not actually iterable." msgstr "" -#: ../../c-api/set.rst:114 +#: ../../c-api/set.rst:111 msgid "" "The following functions and macros are available for instances of :class:" "`set` or :class:`frozenset` or instances of their subtypes." msgstr "" -#: ../../c-api/set.rst:122 +#: ../../c-api/set.rst:119 msgid "" "Return the length of a :class:`set` or :class:`frozenset` object. Equivalent " "to ``len(anyset)``. Raises a :exc:`SystemError` if *anyset* is not a :class:" "`set`, :class:`frozenset`, or an instance of a subtype." msgstr "" -#: ../../c-api/set.rst:129 +#: ../../c-api/set.rst:126 msgid "Macro form of :c:func:`PySet_Size` without error checking." msgstr "" -#: ../../c-api/set.rst:134 +#: ../../c-api/set.rst:131 msgid "" "Return ``1`` if found, ``0`` if not found, and ``-1`` if an error is " "encountered. Unlike the Python :meth:`~object.__contains__` method, this " @@ -163,14 +164,14 @@ msgid "" "instance of a subtype." msgstr "" -#: ../../c-api/set.rst:142 ../../c-api/set.rst:157 ../../c-api/set.rst:177 +#: ../../c-api/set.rst:139 ../../c-api/set.rst:154 ../../c-api/set.rst:174 msgid "" "The operation is atomic on :term:`free threading ` when " "*key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:" "`bytes`." msgstr "" -#: ../../c-api/set.rst:147 +#: ../../c-api/set.rst:144 msgid "" "Add *key* to a :class:`set` instance. Also works with :class:`frozenset` " "instances (like :c:func:`PyTuple_SetItem` it can be used to fill in the " @@ -181,13 +182,13 @@ msgid "" "`set` or its subtype." msgstr "" -#: ../../c-api/set.rst:162 +#: ../../c-api/set.rst:159 msgid "" "The following functions are available for instances of :class:`set` or its " "subtypes but not for instances of :class:`frozenset` or its subtypes." msgstr "" -#: ../../c-api/set.rst:168 +#: ../../c-api/set.rst:165 msgid "" "Return ``1`` if found and removed, ``0`` if not found (no action taken), and " "``-1`` if an error is encountered. Does not raise :exc:`KeyError` for " @@ -197,7 +198,7 @@ msgid "" "if *set* is not an instance of :class:`set` or its subtype." msgstr "" -#: ../../c-api/set.rst:183 +#: ../../c-api/set.rst:180 msgid "" "Return a new reference to an arbitrary object in the *set*, and removes the " "object from the *set*. Return ``NULL`` on failure. Raise :exc:`KeyError` " @@ -205,31 +206,31 @@ msgid "" "of :class:`set` or its subtype." msgstr "" -#: ../../c-api/set.rst:191 +#: ../../c-api/set.rst:188 msgid "" "Empty an existing set of all elements. Return ``0`` on success. Return " "``-1`` and raise :exc:`SystemError` if *set* is not an instance of :class:" "`set` or its subtype." msgstr "" -#: ../../c-api/set.rst:197 +#: ../../c-api/set.rst:194 msgid "" "In the :term:`free-threaded build`, the set is emptied before its entries " "are cleared, so other threads will observe an empty set rather than " "intermediate states." msgstr "" -#: ../../c-api/set.rst:203 +#: ../../c-api/set.rst:200 msgid "Deprecated API" msgstr "已棄用的 API" -#: ../../c-api/set.rst:207 +#: ../../c-api/set.rst:204 msgid "" "A constant representing the size of an internal preallocated table inside :c:" "type:`PySetObject` instances." msgstr "一個代表 :c:type:`PySetObject` 實例內部預分配表格大小的常數。" -#: ../../c-api/set.rst:210 +#: ../../c-api/set.rst:207 msgid "" "This is documented solely for completeness, as there are no guarantees that " "a given version of CPython uses preallocated tables with a fixed size. In " @@ -240,26 +241,26 @@ msgstr "" "的預分配表格。在不處理不穩定集合內部結構的程式碼中,:c:macro:`!" "PySet_MINSIZE` 可以替換為像 ``8`` 這樣的小常數。" -#: ../../c-api/set.rst:216 +#: ../../c-api/set.rst:213 msgid "If looking for the size of a set, use :c:func:`PySet_Size` instead." msgstr "如果要查詢集合的大小,請使用 :c:func:`PySet_Size`。" -#: ../../c-api/set.rst:11 +#: ../../c-api/set.rst:8 msgid "object" msgstr "object(物件)" -#: ../../c-api/set.rst:11 +#: ../../c-api/set.rst:8 msgid "set" msgstr "set(集合)" -#: ../../c-api/set.rst:11 +#: ../../c-api/set.rst:8 msgid "frozenset" msgstr "frozenset(凍結集合)" -#: ../../c-api/set.rst:120 +#: ../../c-api/set.rst:117 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/set.rst:120 +#: ../../c-api/set.rst:117 msgid "len" msgstr "len" diff --git a/c-api/slots.po b/c-api/slots.po new file mode 100644 index 00000000000..7cca3e925f0 --- /dev/null +++ b/c-api/slots.po @@ -0,0 +1,336 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../c-api/slots.rst:6 +msgid "Definition slots" +msgstr "" + +#: ../../c-api/slots.rst:8 +msgid "" +"To define :ref:`module objects ` and :ref:`classes ` using the C API, you may use an array of *slots* -- " +"essentially, key-value pairs that describe features of the object to create. " +"This decouples the data from the structures used at runtime, allowing " +"CPython -- and other Python C API implementations -- to update the " +"structures without breaking backwards compatibility." +msgstr "" + +#: ../../c-api/slots.rst:16 +msgid "" +"This section documents slots in general. For object-specific behavior and " +"slot values, see documentation for functions that apply slots:" +msgstr "" + +#: ../../c-api/slots.rst:20 +msgid ":c:func:`PyType_FromSlots` for types;" +msgstr "" + +#: ../../c-api/slots.rst:21 +msgid "" +":c:func:`PyModule_FromSlotsAndSpec` and :ref:`extension-export-hook` for " +"modules." +msgstr "" + +#: ../../c-api/slots.rst:24 +msgid "" +"When slots are passed to a function that applies them, the function will not " +"modify the slot array, nor any data it points to (recursively). After the " +"function is done, the caller is allowed to modify or deallocate the array " +"and any data it points to (recursively), except data explicitly marked with :" +"c:macro:`PySlot_STATIC`." +msgstr "" + +#: ../../c-api/slots.rst:30 +msgid "" +"Except when documented otherwise, multiple slots with the same ID (:c:member:" +"`~PySlot.sl_id`) may not occur in a single slots array." +msgstr "" + +#: ../../c-api/slots.rst:35 +msgid "" +"Slot arrays generalize an earlier way of defining objects: using :c:type:" +"`PyType_Spec` with :c:type:`PyType_Slot` for types, and :c:type:" +"`PyModuleDef` with :c:type:`PyModuleDef_Slot` for modules. The earlier API " +"is :term:`soft deprecated`; there are no plans to remove it." +msgstr "" + +#: ../../c-api/slots.rst:40 +msgid "Entries of the slots array use the following structure:" +msgstr "" + +#: ../../c-api/slots.rst:44 +msgid "An entry in a slots array. Defined as:" +msgstr "" + +#: ../../c-api/slots.rst:46 +msgid "" +"typedef struct {\n" +" uint16_t sl_id;\n" +" uint16_t sl_flags;\n" +" uint32_t _reserved; // must be 0\n" +" union {\n" +" void *sl_ptr;\n" +" void (*sl_func)(void);\n" +" Py_ssize_t sl_size;\n" +" int64_t sl_int64;\n" +" uint64_t sl_uint64;\n" +" };\n" +"} PySlot;" +msgstr "" +"typedef struct {\n" +" uint16_t sl_id;\n" +" uint16_t sl_flags;\n" +" uint32_t _reserved; // 必須為 0\n" +" union {\n" +" void *sl_ptr;\n" +" void (*sl_func)(void);\n" +" Py_ssize_t sl_size;\n" +" int64_t sl_int64;\n" +" uint64_t sl_uint64;\n" +" };\n" +"} PySlot;" + +#: ../../c-api/slots.rst:63 +msgid "A slot ID, chosen from:" +msgstr "" + +#: ../../c-api/slots.rst:65 +msgid "``Py_slot_*`` values documented in :ref:`pyslot-common-ids` below;" +msgstr "" + +#: ../../c-api/slots.rst:66 +msgid "" +"``Py_mod_*`` values for modules, as documented in :ref:`c_module_slots`;" +msgstr "" + +#: ../../c-api/slots.rst:67 +msgid "Values for types, as documented in :ref:`pyslot_type_slot_ids`." +msgstr "" + +#: ../../c-api/slots.rst:69 +msgid "" +"A :c:member:`!sl_id` of zero (:c:macro:`Py_slot_end`) marks the end of a " +"slots array." +msgstr "" + +#: ../../c-api/slots.rst:78 +msgid "" +"The data for the slot. These members are part of an anonymous union; the " +"member to use depends on which data type is required by the slot ID: data " +"pointer, function pointer, size, signed or unsigned integer, respectively." +msgstr "" + +#: ../../c-api/slots.rst:84 +msgid "" +"Except when documented otherwise for a specific slot ID, pointers (that is :" +"c:member:`!sl_ptr` and :c:member:`!sl_func`) may not be NULL." +msgstr "" + +#: ../../c-api/slots.rst:89 +msgid "Zero or more of the following flags, OR-ed together:" +msgstr "" + +#: ../../c-api/slots.rst:95 +msgid "" +"All data the slot points to is statically allocated and constant. Thus, the " +"interpreter does not need to copy the information." +msgstr "" + +#: ../../c-api/slots.rst:98 +msgid "This flag is implied for function pointers." +msgstr "" + +#: ../../c-api/slots.rst:100 +msgid "" +"The flag applies even to data the slot points to “indirectly”, except for " +"slots nested via :c:macro:`Py_slot_subslots` which may have their own :c:" +"macro:`!PySlot_STATIC` flags. For example, if applied to a :c:macro:" +"`Py_tp_members` slot that points to an array of :c:type:`PyMemberDef` " +"structures, then the entire array, as well as the name and doc strings in " +"its elements, must be static and constant." +msgstr "" + +#: ../../c-api/slots.rst:110 +msgid "" +"The data is stored in ``sl_ptr``; CPython will cast it to the appropriate " +"type." +msgstr "" + +#: ../../c-api/slots.rst:113 +msgid "" +"This flag can simplify porting from the older :c:type:`PyType_Slot` and :c:" +"type:`PyModuleDef_Slot` structures." +msgstr "" + +#: ../../c-api/slots.rst:118 +msgid "" +"If the slot ID is unknown, the interpreter should ignore the slot, rather " +"than fail." +msgstr "" + +#: ../../c-api/slots.rst:121 +msgid "" +"For example, if Python 3.16 adds a new feature with a new slot ID,attr the " +"corresponding slot may be marked :c:macro:`!PySlot_OPTIONAL` so that Python " +"3.15 ignores it." +msgstr "" + +#: ../../c-api/slots.rst:125 +msgid "" +"Note that the \"optionality\" only applies to unknown slot IDs. This flag " +"does not make Python skip invalid values of known slots." +msgstr "" + +#: ../../c-api/slots.rst:132 +msgid "Convenience macros" +msgstr "" + +#: ../../c-api/slots.rst:141 +msgid "" +"Convenience macros to define :c:type:`!PySlot` structures with :c:member:" +"`~PySlot.sl_id` and a particular union member set." +msgstr "" + +#: ../../c-api/slots.rst:144 +msgid "" +":c:macro:`!PySlot_STATIC_DATA` sets the :c:macro:`PySlot_STATIC` flag; " +"others set no flags." +msgstr "" + +#: ../../c-api/slots.rst:147 +msgid "" +"Note that these macros use *designated initializers*, a C language feature " +"that C++ added in the 2020 version of the standard. If your code needs to be " +"compatible with C++11 or older, use :c:macro:`PySlot_PTR` instead." +msgstr "" + +#: ../../c-api/slots.rst:152 ../../c-api/slots.rst:178 +#: ../../c-api/slots.rst:192 +msgid "Defined as::" +msgstr "" + +#: ../../c-api/slots.rst:154 +msgid "" +"#define PySlot_DATA(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_ptr=(void*)(VALUE)}\n" +"\n" +"#define PySlot_FUNC(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_func=(VALUE)}\n" +"\n" +"#define PySlot_SIZE(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_size=(VALUE)}\n" +"\n" +"#define PySlot_INT64(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_int64=(VALUE)}\n" +"\n" +"#define PySlot_UINT64(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_uint64=(VALUE)}\n" +"\n" +"#define PySlot_STATIC_DATA(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_flags=PySlot_STATIC, .sl_ptr=(VALUE)}" +msgstr "" +"#define PySlot_DATA(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_ptr=(void*)(VALUE)}\n" +"\n" +"#define PySlot_FUNC(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_func=(VALUE)}\n" +"\n" +"#define PySlot_SIZE(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_size=(VALUE)}\n" +"\n" +"#define PySlot_INT64(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_int64=(VALUE)}\n" +"\n" +"#define PySlot_UINT64(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_uint64=(VALUE)}\n" +"\n" +"#define PySlot_STATIC_DATA(NAME, VALUE) \\\n" +" {.sl_id=NAME, .sl_flags=PySlot_STATIC, .sl_ptr=(VALUE)}" + +#: ../../c-api/slots.rst:176 +msgid "Convenience macro to mark the end of a :c:type:`!PySlot` array." +msgstr "" + +#: ../../c-api/slots.rst:180 +msgid "#define PySlot_END {0}" +msgstr "#define PySlot_END {0}" + +#: ../../c-api/slots.rst:187 +msgid "" +"Convenience macros for use in C++11-compatible code. This version of C++ " +"does not allow setting arbitrary union members in literals; instead, these " +"macros set the :c:macro:`PySlot_INTPTR` flag and cast the value to " +"``(void*)``." +msgstr "" + +#: ../../c-api/slots.rst:194 +msgid "" +"#define PySlot_PTR(NAME, VALUE) \\\n" +" {NAME, PySlot_INTPTR, {0}, {(void*)(VALUE)}}\n" +"\n" +"#define PySlot_PTR_STATIC(NAME, VALUE) \\\n" +" {NAME, PySlot_INTPTR|Py_SLOT_STATIC, {0}, {(void*)(VALUE)}}" +msgstr "" +"#define PySlot_PTR(NAME, VALUE) \\\n" +" {NAME, PySlot_INTPTR, {0}, {(void*)(VALUE)}}\n" +"\n" +"#define PySlot_PTR_STATIC(NAME, VALUE) \\\n" +" {NAME, PySlot_INTPTR|Py_SLOT_STATIC, {0}, {(void*)(VALUE)}}" + +#: ../../c-api/slots.rst:205 +msgid "Common slot IDs" +msgstr "" + +#: ../../c-api/slots.rst:207 +msgid "The following slot IDs may be used in both type and module definitions." +msgstr "" + +#: ../../c-api/slots.rst:211 +msgid "Marks the end of a slots array. Defined as zero." +msgstr "" + +#: ../../c-api/slots.rst:218 +msgid "Nested slots array." +msgstr "" + +#: ../../c-api/slots.rst:220 +msgid "" +"The value (:c:member:`~PySlot.sl_ptr`) should point to an array of :c:type:" +"`PySlot` structures. The slots in the array (up to but not including the " +"zero-ID terminator) will be treated as if they were inserted if the current " +"slot array, at the point :c:macro:`!Py_slot_subslots` appears." +msgstr "" + +#: ../../c-api/slots.rst:226 +msgid "" +"Slot nesting depth is limited to 5 levels. This restriction may be lifted in " +"the future." +msgstr "" + +#: ../../c-api/slots.rst:233 +msgid "" +"Reserved; will always be treated as an unknown slot ID. Defined as " +"``UINT16_MAX`` (``0xFFFF``)." +msgstr "" + +#: ../../c-api/slots.rst:236 +msgid "" +"When used with the :c:macro:`PySlot_OPTIONAL` flag, defines a slot with no " +"effect. Without the flag, processing a slot with this ID will fail." +msgstr "" diff --git a/c-api/stable.po b/c-api/stable.po index 805c537ea6f..d0699d472be 100644 --- a/c-api/stable.po +++ b/c-api/stable.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-01-24 21:07+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,8 +20,8 @@ msgstr "" "X-Generator: Poedit 3.2.2\n" #: ../../c-api/stable.rst:7 -msgid "C API Stability" -msgstr "C API 穩定性" +msgid "C API and ABI Stability" +msgstr "C API 與 ABI 穩定性" #: ../../c-api/stable.rst:9 msgid "" @@ -113,229 +113,311 @@ msgstr "" "使用此 API 的專案應該要遵循 CPython 開發細節,並花費額外的力氣來針對這些變動" "來做調整。" -#: ../../c-api/stable.rst:57 -msgid "Stable Application Binary Interface" +#: ../../c-api/stable.rst:58 +msgid "Stable Application Binary Interfaces" msgstr "穩定的應用程式二進位介面" -#: ../../c-api/stable.rst:59 +#: ../../c-api/stable.rst:60 msgid "" -"For simplicity, this document talks about *extensions*, but the Limited API " -"and Stable ABI work the same way for all uses of the API – for example, " -"embedding Python." +"Python's :dfn:`Stable ABI` allows extensions to be compatible with multiple " +"versions of Python, without recompilation." msgstr "" -"為簡單起見,本文件討論\\ *擴充 (extension)*,但受限 API 和穩定 ABI 在所有 " -"API 使用方式中都以相同的方式運作 -- 例如在嵌入式 Python (embedding Python) " -"中。" -#: ../../c-api/stable.rst:66 -msgid "Limited C API" -msgstr "受限 C API" +#: ../../c-api/stable.rst:65 +msgid "" +"For simplicity, this document talks about *extensions*, but Stable ABI works " +"the same way for all uses of the API – for example, embedding Python." +msgstr "" +"為簡單起見,本文件討論\\ *擴充 (extension)*,但穩定 ABI 在所有 API 使用方式中" +"都以相同的方式運作 -- 例如在嵌入式 Python (embedding Python) 中。" #: ../../c-api/stable.rst:68 +msgid "There are two Stable ABIs:" +msgstr "" + +#: ../../c-api/stable.rst:70 msgid "" -"Python 3.2 introduced the *Limited API*, a subset of Python's C API. " -"Extensions that only use the Limited API can be compiled once and be loaded " -"on multiple versions of Python. Contents of the Limited API are :ref:`listed " -"below `." +"``abi3``, introduced in Python 3.2, is compatible with **non**-:term:`free-" +"threaded ` builds of CPython." msgstr "" -"Python 3.2 引入了\\ *受限 API (Limited API)*,它是 Python C API 的一個子集。" -"僅使用受限 API 的擴充可以只編譯一次就被載入於多個版本的 Python。受限 API 的內" -"容\\ :ref:`列在下方 `。" -#: ../../c-api/stable.rst:75 +#: ../../c-api/stable.rst:73 msgid "" -"Define this macro before including ``Python.h`` to opt in to only use the " -"Limited API, and to select the Limited API version." +"``abi3t``, introduced in Python 3.15, is compatible with :term:`free-" +"threaded ` builds of CPython. It has stricter API " +"limitations than ``abi3``." +msgstr "" + +#: ../../c-api/stable.rst:79 +msgid "``abi3t`` was added in :pep:`803`" msgstr "" -"在包含 ``Python.h`` 之前定義此巨集以選擇只使用受限 API,並挑選受限 API 版本。" -#: ../../c-api/stable.rst:78 +#: ../../c-api/stable.rst:81 msgid "" -"Define ``Py_LIMITED_API`` to the value of :c:macro:`PY_VERSION_HEX` " -"corresponding to the lowest Python version your extension supports. The " -"extension will be ABI-compatible with all Python 3 releases from the " -"specified one onward, and can use Limited API introduced up to that version." +"It is possible for an extension to be compiled for *both* ``abi3`` and " +"``abi3t`` at the same time; the result will be compatible with both free-" +"threaded and non-free-threaded builds of Python. Currently, this has no " +"downsides compared to compiling for ``abi3t`` only." msgstr "" -"將 ``Py_LIMITED_API`` 定義為對應於你的擴充有支援的最低 Python 版本" -"的 :c:macro:`PY_VERSION_HEX` 值。該擴充與從指定版本開始的所有 Python 3 版本" -"之 ABI 相容,並且可以使用過去版本有引入的受限 API。" -#: ../../c-api/stable.rst:84 +#: ../../c-api/stable.rst:86 msgid "" -"Rather than using the ``PY_VERSION_HEX`` macro directly, hardcode a minimum " -"minor version (e.g. ``0x030A0000`` for Python 3.10) for stability when " -"compiling with future Python versions." +"Each Stable ABI is versioned using the first two numbers of the Python " +"version. For example, Stable ABI 3.14 corresponds to Python 3.14. An " +"extension compiled for Stable ABI 3.x is ABI-compatible with Python 3.x and " +"above." msgstr "" -"與其直接使用 ``PY_VERSION_HEX`` 巨集,不如寫死 (hardcode) 最小次要版本(例如" -"代表 Python 3.10 的 ``0x030A0000``\\ ),以便在使用未來的 Python 版本進行編譯" -"時仍保持穩定性。" -#: ../../c-api/stable.rst:88 +#: ../../c-api/stable.rst:91 msgid "" -"You can also define ``Py_LIMITED_API`` to ``3``. This works the same as " -"``0x03020000`` (Python 3.2, the version that introduced Limited API)." +"Extensions that target a stable ABI must only use a limited subset of the C " +"API. This subset is known as the :dfn:`Limited API`; its contents are :ref:" +"`listed below `." msgstr "" -"你還可以將 ``Py_LIMITED_API`` 定義為 ``3``,這與 ``0x03020000``\\ (Python " -"3.2,引入了受限 API 的版本)相同。" #: ../../c-api/stable.rst:95 -msgid "Stable ABI" -msgstr "穩定 ABI" +msgid "" +"On Windows, extensions that use a Stable ABI should be linked against " +"``python3.dll`` rather than a version-specific library such as ``python39." +"dll``. This library only exposes the relevant symbols." +msgstr "" +"在 Windows 上,使用穩定 ABI 的擴充應該連接到 ``python3.dll`` 而不是特定版本的" +"函式庫,例如 ``python39.dll``。此函式庫只會公開相關的符號。" -#: ../../c-api/stable.rst:97 +#: ../../c-api/stable.rst:100 msgid "" -"To enable this, Python provides a *Stable ABI*: a set of symbols that will " -"remain ABI-compatible across Python 3.x versions." +"On some platforms, Python will look for and load shared library files named " +"with the ``abi3`` or ``abi3t`` tag (for example, ``mymodule.abi3.so``). :" +"term:`Free-threaded ` interpreters only recognize the " +"``abi3t`` tag, while non-free-threaded ones will prefer ``abi3`` but fall " +"back to ``abi3t``. Thus, extensions compatible with both ABIs should use the " +"``abi3t`` tag." msgstr "" -"為了實現它,Python 提供了一個\\ *穩定 ABI (Stable ABI)*:一組將在各個 Python " -"3.x 版本之間保持 ABI 相容的符號。" -#: ../../c-api/stable.rst:102 +#: ../../c-api/stable.rst:107 msgid "" -"The Stable ABI prevents ABI issues, like linker errors due to missing " -"symbols or data corruption due to changes in structure layouts or function " -"signatures. However, other changes in Python can change the *behavior* of " -"extensions. See Python's Backwards Compatibility Policy (:pep:`387`) for " -"details." +"Python does not necessarily check that extensions it loads have compatible " +"ABI. Extension authors are encouraged to add a check using the :c:macro:" +"`Py_mod_abi` slot or the :c:func:`PyABIInfo_Check` function, but the user " +"(or their packaging tool) is ultimately responsible for ensuring that, for " +"example, extensions built for Stable ABI 3.10 are not installed for lower " +"versions of Python." msgstr "" -"穩定 ABI 可以防止 ABI 問題,例如由於結構布局或函式簽名變化導致缺少符號或數據" -"損壞的鏈接器 (linker) 錯誤。然而,Python 的其他變化可能會改變 *行為* 的擴充。" -"有關詳細資訊,請參閱 Python 的向後相容性政策 (:pep:`387`)。" -#: ../../c-api/stable.rst:108 +#: ../../c-api/stable.rst:115 msgid "" -"The Stable ABI contains symbols exposed in the :ref:`Limited API `, but also other ones – for example, functions necessary to support " -"older versions of the Limited API." +"All functions in Stable ABI are present as functions in Python's shared " +"library, not solely as macros. This makes them usable in languages that " +"don't use the C preprocessor, including Python's :py:mod:`ctypes`." +msgstr "" +"穩定 ABI 中的所有函式都作為函式存在於 Python 的共享函式庫中,而不僅是作為巨" +"集。這使得它們可被用於不使用 C 預處理器 (preprocessor) 的語言,包括 Python " +"的 :py:mod:`ctypes`。" + +#: ../../c-api/stable.rst:124 +msgid "Compiling for Stable ABI" msgstr "" -"穩定 ABI 被包含在\\ :ref:`受限 API ` 中開放的符號,但也包含其" -"他符號 - 例如,支援舊版受限 API 所必需的函式。" -#: ../../c-api/stable.rst:112 +#: ../../c-api/stable.rst:128 msgid "" -"On Windows, extensions that use the Stable ABI should be linked against " -"``python3.dll`` rather than a version-specific library such as " -"``python39.dll``." +"Build tools (such as, for example, meson-python, scikit-build-core, or " +"Setuptools) often have a mechanism for setting macros and synchronizing them " +"with extension filenames and other metadata. Prefer using such a mechanism, " +"if it exists, over defining the macros manually." msgstr "" -"在 Windows 上,使用穩定 ABI 的擴充應該連接到 ``python3.dll`` 而不是特定版本的" -"函式庫,例如 ``python39.dll``。" -#: ../../c-api/stable.rst:116 +#: ../../c-api/stable.rst:134 msgid "" -"On some platforms, Python will look for and load shared library files named " -"with the ``abi3`` tag (e.g. ``mymodule.abi3.so``). It does not check if such " -"extensions conform to a Stable ABI. The user (or their packaging tools) need " -"to ensure that, for example, extensions built with the 3.10+ Limited API are " -"not installed for lower versions of Python." +"The rest of this section is mainly relevant for tool authors, and for people " +"who compile extensions manually." +msgstr "" + +#: ../../c-api/stable.rst:137 +msgid "`list of recommended tools`_ in the Python Packaging User Guide" msgstr "" -"在某些平台上,Python 將查找並加載以 ``abi3`` 標籤命名的共享函式庫檔案(例如 " -"``mymodule.abi3.so``\\ )。它不檢查此類擴充是否符合穩定的 ABI。確保的責任在使" -"用者(或者打包工具)身上,例如使用 3.10+ 受限 API 建置的擴充不會為較低版本的 " -"Python 所安裝。" -#: ../../c-api/stable.rst:123 +#: ../../c-api/stable.rst:141 msgid "" -"All functions in the Stable ABI are present as functions in Python's shared " -"library, not solely as macros. This makes them usable from languages that " -"don't use the C preprocessor." +"To compile for a Stable ABI, define one or both of the following macros to " +"the lowest Python version your extension should support, in :c:macro:" +"`Py_PACK_VERSION` format. Typically, you should choose a specific value " +"rather than the version of the Python headers you are compiling against." msgstr "" -"穩定 ABI 中的所有函式都作為函式存在於 Python 的共享函式庫中,而不僅是作為巨" -"集。這使得它們可被用於不使用 C 預處理器 (preprocessor) 的語言。" -#: ../../c-api/stable.rst:129 -msgid "Limited API Scope and Performance" -msgstr "受限 API 範圍和性能" +#: ../../c-api/stable.rst:147 +msgid "" +"The macros must be defined before including ``Python.h``. Since :c:macro:" +"`Py_PACK_VERSION` is not available at this point, you will need to use the " +"numeric value directly. For reference, the values for a few recent Python " +"versions are:" +msgstr "" -#: ../../c-api/stable.rst:131 +#: ../../c-api/stable.rst:1 msgid "" -"The goal for the Limited API is to allow everything that is possible with " -"the full C API, but possibly with a performance penalty." +"0x30a0000 /* Py_PACK_VERSION(3,10) */\n" +"0x30b0000 /* Py_PACK_VERSION(3,11) */\n" +"0x30c0000 /* Py_PACK_VERSION(3,12) */\n" +"0x30d0000 /* Py_PACK_VERSION(3,13) */\n" +"0x30e0000 /* Py_PACK_VERSION(3,14) */\n" +"0x30f0000 /* Py_PACK_VERSION(3,15) */" msgstr "" -"受限 API 的目標是允許使用完整的 C API 進行所有可能的操作,但可能會降低性能。" -#: ../../c-api/stable.rst:134 +#: ../../c-api/stable.rst:154 msgid "" -"For example, while :c:func:`PyList_GetItem` is available, its “unsafe” macro " -"variant :c:func:`PyList_GET_ITEM` is not. The macro can be faster because it " -"can rely on version-specific implementation details of the list object." +"When one of the macros is defined, ``Python.h`` will only expose API that is " +"compatible with the given Stable ABI -- that is, the :ref:`Limited API " +"` plus some definitions that need to be visible to the " +"compiler but should not be used directly. When both are defined, ``Python." +"h`` will only expose API compatible with both Stable ABIs." msgstr "" -"例如,雖然 :c:func:`PyList_GetItem` 可用,但它的「不安全」巨集變" -"體 :c:func:`PyList_GET_ITEM` 為不可用。巨集運行可以更快,因為它可以依賴 list " -"物件的特定版本實作細節。" -#: ../../c-api/stable.rst:139 +#: ../../c-api/stable.rst:163 msgid "" -"Without ``Py_LIMITED_API`` defined, some C API functions are inlined or " -"replaced by macros. Defining ``Py_LIMITED_API`` disables this inlining, " -"allowing stability as Python's data structures are improved, but possibly " -"reducing performance." +"Target ``abi3``, that is, non-:term:`free-threaded builds ` of CPython. See :ref:`above ` for common information." msgstr "" -"如果沒有定義 ``Py_LIMITED_API``,一些 C API 函式將被嵌入或被替換為巨集。定義 " -"``Py_LIMITED_API`` 會禁用嵌入,從而隨著 Python 資料結構的改進而提高穩定性,但" -"可能會降低性能。" -#: ../../c-api/stable.rst:144 +#: ../../c-api/stable.rst:169 msgid "" -"By leaving out the ``Py_LIMITED_API`` definition, it is possible to compile " -"a Limited API extension with a version-specific ABI. This can improve " -"performance for that Python version, but will limit compatibility. Compiling " -"with ``Py_LIMITED_API`` will then yield an extension that can be distributed " -"where a version-specific one is not available – for example, for prereleases " -"of an upcoming Python version." +"Target ``abi3t``, that is, :term:`free-threaded builds ` of CPython. See :ref:`above ` for common information." msgstr "" -"透過省略 ``Py_LIMITED_API`` 定義,可以使用特定版本的 ABI 編譯受限 API 擴充。" -"這可以提高該 Python 版本的性能,但會限制相容性。使用 ``Py_LIMITED_API`` 編譯" -"將產生一個擴充,可以在特定版本的擴充不可用的地方發布 — 例如,用於即將發布的 " -"Python 版本的預發布版本 (prerelease)。" -#: ../../c-api/stable.rst:153 -msgid "Limited API Caveats" -msgstr "受限 API 注意事項" +#: ../../c-api/stable.rst:175 +msgid "" +"Both macros specify a target ABI; the different naming style is due to " +"backwards compatibility." +msgstr "" + +#: ../../c-api/stable.rst:178 +msgid "Historical note" +msgstr "" -#: ../../c-api/stable.rst:155 +#: ../../c-api/stable.rst:180 msgid "" -"Note that compiling with ``Py_LIMITED_API`` is *not* a complete guarantee " -"that code conforms to the :ref:`Limited API ` or " -"the :ref:`Stable ABI `. ``Py_LIMITED_API`` only covers " -"definitions, but an API also includes other issues, such as expected " -"semantics." +"You can also define ``Py_LIMITED_API`` as ``3``. This works the same as " +"``0x03020000`` (Python 3.2, the version that introduced Stable ABI)." msgstr "" -"請注意,使用 ``Py_LIMITED_API`` 進行編譯\\ *不*\\ 完全保證程式碼符合\\ :ref:`" -"受限 API ` 或\\ :ref:`穩定 ABI `。" -"``Py_LIMITED_API`` 僅涵蓋定義,但 API 還包括其他議題,例如預期的語義 " -"(semantic)。" +"你還可以將 ``Py_LIMITED_API`` 定義為 ``3``,這與 ``0x03020000``\\ (Python " +"3.2,引入了穩定 ABI 的版本)相同。" -#: ../../c-api/stable.rst:160 +#: ../../c-api/stable.rst:183 msgid "" -"One issue that ``Py_LIMITED_API`` does not guard against is calling a " -"function with arguments that are invalid in a lower Python version. For " -"example, consider a function that starts accepting ``NULL`` for an argument. " -"In Python 3.9, ``NULL`` now selects a default behavior, but in Python 3.8, " -"the argument will be used directly, causing a ``NULL`` dereference and " -"crash. A similar argument works for fields of structs." +"When both are defined, ``Python.h`` may, or may not, redefine :c:macro:`!" +"Py_LIMITED_API` to match :c:macro:`!Py_TARGET_ABI3T`." msgstr "" -"``Py_LIMITED_API`` 無法防範的一個問題是使用在較低 Python 版本中無效的引數來呼" -"叫函式。例如一個開始接受 ``NULL`` 作為引數的函式。在 Python 3.9 中,``NULL`` " -"現在代表選擇預設行為,但在 Python 3.8 中,引數將被直接使用,導致 ``NULL`` 取" -"消參照 (dereference) 且崩潰 (crash)。類似的引數適用於結構 (struct) 的欄位。" -#: ../../c-api/stable.rst:167 +#: ../../c-api/stable.rst:186 msgid "" -"Another issue is that some struct fields are currently not hidden when " -"``Py_LIMITED_API`` is defined, even though they're part of the Limited API." +"On a :term:`free-threaded build` -- that is, when :c:macro:`Py_GIL_DISABLED` " +"is defined -- :c:macro:`!Py_TARGET_ABI3T` defaults to the value of :c:macro:" +"`!Py_LIMITED_API`. This means that there are two ways to build for both " +"``abi3`` and ``abi3t``:" msgstr "" -"另一個問題是,當有定義 ``Py_LIMITED_API`` 時,一些結構欄位目前不會被隱藏,即" -"使它們是受限 API 的一部分。" -#: ../../c-api/stable.rst:170 +#: ../../c-api/stable.rst:191 +msgid "" +"define both :c:macro:`!Py_LIMITED_API` and :c:macro:`!Py_TARGET_ABI3T`, or" +msgstr "" + +#: ../../c-api/stable.rst:192 +msgid "define only :c:macro:`!Py_LIMITED_API` and:" +msgstr "" + +#: ../../c-api/stable.rst:194 +msgid "on Windows, define :c:macro:`!Py_GIL_DISABLED`;" +msgstr "" + +#: ../../c-api/stable.rst:195 +msgid "on other systems, use the headers of free-threaded build of Python." +msgstr "" + +#: ../../c-api/stable.rst:201 +msgid "Stable ABI Scope and Performance" +msgstr "穩定 ABI 範圍和效能" + +#: ../../c-api/stable.rst:203 +msgid "" +"The goal for Stable ABI is to allow everything that is possible with the " +"full C API, but possibly with a performance penalty. Generally, " +"compatibility with Stable ABI will require some changes to an extension's " +"source code." +msgstr "" +"穩定 ABI 的目標是允許使用完整的 C API 進行所有可能的操作,但可能會降低效能。" +"一般來說,要與穩定 ABI 相容,會需要對擴充的原始碼做一些修改。" + +#: ../../c-api/stable.rst:208 +msgid "" +"For example, while :c:func:`PyList_GetItem` is available, its \"unsafe\" " +"macro variant :c:func:`PyList_GET_ITEM` is not. The macro can be faster " +"because it can rely on version-specific implementation details of the list " +"object." +msgstr "" +"例如,雖然 :c:func:`PyList_GetItem` 可用,但它的「不安全」巨集變" +"體 :c:func:`PyList_GET_ITEM` 為不可用。巨集運行可以更快,因為它可以依賴 list " +"物件的特定版本實作細節。" + +#: ../../c-api/stable.rst:213 +msgid "" +"For another example, when *not* compiling for Stable ABI, some C API " +"functions are inlined or replaced by macros. Compiling for Stable ABI " +"disables this inlining, allowing stability as Python's data structures are " +"improved, but possibly reducing performance." +msgstr "" +"另一個例子是,如果\\ *不是*\\ 針對穩定 ABI 進行編譯,一些 C API 函式將被嵌入" +"或被替換為巨集。針對穩定 ABI 進行編譯會禁用嵌入,從而隨著 Python 資料結構的改" +"進而提高穩定性,但可能會降低效能。" + +#: ../../c-api/stable.rst:218 +msgid "" +"By leaving out the :c:macro:`!Py_LIMITED_API` or :c:macro:`!Py_TARGET_ABI3T` " +"definition, it is possible to compile Stable-ABI-compatible source for a " +"version-specific ABI. A potentially faster version-specific extension can " +"then be distributed alongside a version compiled for Stable ABI -- a slower " +"but more compatible fallback." +msgstr "" + +#: ../../c-api/stable.rst:229 +msgid "Stable ABI Caveats" +msgstr "穩定 ABI 注意事項" + +#: ../../c-api/stable.rst:231 +msgid "" +"Note that compiling for Stable ABI is *not* a complete guarantee that code " +"will be compatible with the expected Python versions. Stable ABI prevents " +"*ABI* issues, like linker errors due to missing symbols or data corruption " +"due to changes in structure layouts or function signatures. However, other " +"changes in Python can change the *behavior* of extensions." +msgstr "" +"請注意,針對穩定 ABI 進行編譯\\ *並不*\\ 完全保證程式碼會與預期的 Python 版本" +"相容。穩定 ABI 可以防止 *ABI* 問題,例如因缺少符號而導致的連結器 (linker) 錯" +"誤,或因結構布局或函式簽名變更而導致的資料損壞。然而,Python 的其他變化可能會" +"改變擴充的\\ *行為*。" + +#: ../../c-api/stable.rst:238 +msgid "" +"One issue that the :c:macro:`Py_TARGET_ABI3T` and :c:macro:`Py_LIMITED_API` " +"macros do not guard against is calling a function with arguments that are " +"invalid in a lower Python version. For example, consider a function that " +"starts accepting ``NULL`` for an argument. In Python 3.9, ``NULL`` now " +"selects a default behavior, but in Python 3.8, the argument will be used " +"directly, causing a ``NULL`` dereference and crash. A similar argument works " +"for fields of structs." +msgstr "" +":c:macro:`Py_TARGET_ABI3T` 和 :c:macro:`Py_LIMITED_API` 巨集無法防範的一個問" +"題是使用在較低 Python 版本中無效的引數來呼叫函式。例如一個開始接受 ``NULL`` " +"作為引數的函式。在 Python 3.9 中,``NULL`` 現在代表選擇預設行為,但在 Python " +"3.8 中,引數將被直接使用,導致 ``NULL`` 取消參照 (dereference) 且崩潰 " +"(crash)。類似的論點也適用於結構 (struct) 的欄位。" + +#: ../../c-api/stable.rst:246 msgid "" "For these reasons, we recommend testing an extension with *all* minor Python " -"versions it supports, and preferably to build with the *lowest* such version." +"versions it supports." msgstr "" -"出於這些原因,我們建議要以它支援的\\ *所有*\\ 次要 Python 版本來測試擴充,並" -"且最好使用\\ *最低*\\ 版本進行建置。" +"出於這些原因,我們建議要以它支援的\\ *所有*\\ 次要 Python 版本來測試擴充。" -#: ../../c-api/stable.rst:173 +#: ../../c-api/stable.rst:249 msgid "" "We also recommend reviewing documentation of all used API to check if it is " "explicitly part of the Limited API. Even with ``Py_LIMITED_API`` defined, a " @@ -346,54 +428,371 @@ msgstr "" "義 ``Py_LIMITED_API``,一些私有聲明也會因為技術原因(或者甚至是無意地,例如臭" "蟲)而被公開出來。" -#: ../../c-api/stable.rst:178 +#: ../../c-api/stable.rst:254 msgid "" -"Also note that the Limited API is not necessarily stable: compiling with " -"``Py_LIMITED_API`` with Python 3.8 means that the extension will run with " -"Python 3.12, but it will not necessarily *compile* with Python 3.12. In " -"particular, parts of the Limited API may be deprecated and removed, provided " -"that the Stable ABI stays stable." +"Also note that while compiling with ``Py_LIMITED_API`` 3.8 means that the " +"extension should *load* on Python 3.12, and *compile* with Python 3.12, the " +"same source will not necessarily compile with ``Py_LIMITED_API`` set to " +"3.12. In general, parts of the Limited API may be deprecated and removed, " +"provided that Stable ABI stays stable." msgstr "" -"另請注意,受限 API 不一定是穩定的:在 Python 3.8 中使用 ``Py_LIMITED_API`` 進" -"行編譯意味著擴充將能以 Python 3.12 運行,但不一定能以 Python 3.12 *編譯*。特" -"別是如果穩定 ABI 保持穩定,部分受限 API 可能會被棄用和刪除。" +"另請注意,雖然使用 ``Py_LIMITED_API`` 3.8 進行編譯意味著擴充應該能在 Python " +"3.12 上\\ *載入*,並能以 Python 3.12 *編譯*,但同樣的原始碼不一定能在 " +"``Py_LIMITED_API`` 設為 3.12 時編譯。一般來說,只要穩定 ABI 保持穩定,部分受" +"限 API 可能會被棄用和刪除。" -#: ../../c-api/stable.rst:188 +#: ../../c-api/stable.rst:265 msgid "Platform Considerations" msgstr "平台注意事項" -#: ../../c-api/stable.rst:190 +#: ../../c-api/stable.rst:267 msgid "" "ABI stability depends not only on Python, but also on the compiler used, " -"lower-level libraries and compiler options. For the purposes of " -"the :ref:`Stable ABI `, these details define a “platform”. They " -"usually depend on the OS type and processor architecture" +"lower-level libraries and compiler options. For the purposes of the :ref:" +"`Stable ABIs `, these details define a “platform”. They usually " +"depend on the OS type and processor architecture" msgstr "" "ABI 穩定性不僅取決於 Python,還取決於使用的編譯器、低階函式庫和編譯器選項。出" "於\\ :ref:`穩定 ABI ` 的目的,這些細節定義了一個「平台」。它們通" "常取決於作業系統種類和處理器架構" -#: ../../c-api/stable.rst:195 +#: ../../c-api/stable.rst:272 msgid "" "It is the responsibility of each particular distributor of Python to ensure " "that all Python versions on a particular platform are built in a way that " -"does not break the Stable ABI. This is the case with Windows and macOS " -"releases from ``python.org`` and many third-party distributors." +"does not break the Stable ABIs, or the version-specific ABIs. This is the " +"case with Windows and macOS releases from ``python.org`` and many third-" +"party distributors." msgstr "" "每個特定的 Python 發布者都有責任確保特定平台上的所有 Python 版本都以不破壞穩" -"定 ABI 的方式建置。``python.org`` 和許多第三方發布者發布的 Windows 和 macOS " -"版本就是這種情況。" +"定 ABI 或特定版本 ABI 的方式建置。``python.org`` 和許多第三方發布者發布的 " +"Windows 和 macOS 版本就是這種情況。" + +#: ../../c-api/stable.rst:280 +msgid "ABI Checking" +msgstr "" + +#: ../../c-api/stable.rst:284 +msgid "Python includes a rudimentary check for ABI compatibility." +msgstr "" + +#: ../../c-api/stable.rst:286 +msgid "" +"This check is not comprehensive. It only guards against common cases of " +"incompatible modules being installed for the wrong interpreter. It also does " +"not take :ref:`platform incompatibilities ` into " +"account. It can only be done after an extension is successfully loaded." +msgstr "" + +#: ../../c-api/stable.rst:293 +msgid "" +"Despite these limitations, it is recommended that extension modules use this " +"mechanism, so that detectable incompatibilities raise exceptions rather than " +"crash." +msgstr "" + +#: ../../c-api/stable.rst:297 +msgid "" +"Most modules can use this check via the :c:data:`Py_mod_abi` slot and the :c:" +"macro:`PyABIInfo_VAR` macro, for example like this:" +msgstr "" -#: ../../c-api/stable.rst:205 +#: ../../c-api/stable.rst:300 +msgid "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PyModuleDef_Slot mymodule_slots[] = {\n" +" {Py_mod_abi, &abi_info},\n" +" ...\n" +"};" +msgstr "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PyModuleDef_Slot mymodule_slots[] = {\n" +" {Py_mod_abi, &abi_info},\n" +" ...\n" +"};" + +#: ../../c-api/stable.rst:310 +msgid "The full API is described below for advanced use cases." +msgstr "" + +#: ../../c-api/stable.rst:314 +msgid "" +"Verify that the given *info* is compatible with the currently running " +"interpreter." +msgstr "" + +#: ../../c-api/stable.rst:317 +msgid "Return 0 on success. On failure, raise an exception and return -1." +msgstr "" + +#: ../../c-api/stable.rst:319 +msgid "" +"If the ABI is incompatible, the raised exception will be :py:exc:" +"`ImportError`." +msgstr "" + +#: ../../c-api/stable.rst:321 +msgid "" +"The *module_name* argument can be ``NULL``, or point to a NUL-terminated " +"UTF-8-encoded string used for error messages." +msgstr "" + +#: ../../c-api/stable.rst:324 +msgid "" +"Note that if *info* describes the ABI that the current code uses (as defined " +"by :c:macro:`PyABIInfo_VAR`, for example), using any other Python C API may " +"lead to crashes. In particular, it is not safe to examine the raised " +"exception." +msgstr "" + +#: ../../c-api/stable.rst:333 +msgid "" +"Define a static :c:struct:`PyABIInfo` variable with the given *NAME* that " +"describes the ABI that the current code will use. This macro expands to:" +msgstr "" + +#: ../../c-api/stable.rst:337 +msgid "" +"static PyABIInfo NAME = {\n" +" 1, 0,\n" +" PyABIInfo_DEFAULT_FLAGS,\n" +" PY_VERSION_HEX,\n" +" PyABIInfo_DEFAULT_ABI_VERSION\n" +"}" +msgstr "" +"static PyABIInfo NAME = {\n" +" 1, 0,\n" +" PyABIInfo_DEFAULT_FLAGS,\n" +" PY_VERSION_HEX,\n" +" PyABIInfo_DEFAULT_ABI_VERSION\n" +"}" + +#: ../../c-api/stable.rst:352 +msgid "The major version of :c:struct:`PyABIInfo`. Can be set to:" +msgstr "" + +#: ../../c-api/stable.rst:354 +msgid "``0`` to skip all checking, or" +msgstr "" + +#: ../../c-api/stable.rst:355 +msgid "``1`` to specify this version of :c:struct:`!PyABIInfo`." +msgstr "" + +#: ../../c-api/stable.rst:359 +msgid "" +"The minor version of :c:struct:`PyABIInfo`. Must be set to ``0``; larger " +"values are reserved for backwards-compatible future versions of :c:struct:`!" +"PyABIInfo`." +msgstr "" + +#: ../../c-api/stable.rst:367 +msgid "This field is usually set to the following macro:" +msgstr "" + +#: ../../c-api/stable.rst:371 +msgid "" +"Default flags, based on current values of macros such as :c:macro:" +"`Py_LIMITED_API` and :c:macro:`Py_GIL_DISABLED`." +msgstr "" + +#: ../../c-api/stable.rst:374 +msgid "" +"Alternately, the field can be set to the following flags, combined by " +"bitwise OR. Unused bits must be set to zero." +msgstr "" + +#: ../../c-api/stable.rst:378 +msgid "ABI variant -- one of:" +msgstr "" + +#: ../../c-api/stable.rst:382 +msgid "Specifies that Stable ABI is used." +msgstr "" + +#: ../../c-api/stable.rst:386 +msgid "" +"Specifies ABI specific to a particular build of CPython. Internal use only." +msgstr "" + +#: ../../c-api/stable.rst:389 +msgid "Free-threading compatibility -- one of:" +msgstr "" + +#: ../../c-api/stable.rst:393 +msgid "" +"Specifies ABI compatible with :term:`free-threaded builds ` of CPython. (That is, ones compiled with :option:`--disable-gil`; " +"with ``t`` in :py:data:`sys.abiflags`)" +msgstr "" + +#: ../../c-api/stable.rst:400 +msgid "" +"Specifies ABI compatible with non-free-threaded builds of CPython (ones " +"compiled *without* :option:`--disable-gil`)." +msgstr "" + +#: ../../c-api/stable.rst:405 +msgid "" +"Specifies ABI compatible with both free-threaded and non-free-threaded " +"builds of CPython, that is, both ``abi3`` and ``abi3t``." +msgstr "" + +#: ../../c-api/stable.rst:411 +msgid "" +"The version of the Python headers used to build the code, in the format used " +"by :c:macro:`PY_VERSION_HEX`." +msgstr "" + +#: ../../c-api/stable.rst:414 +msgid "" +"This can be set to ``0`` to skip any checks related to this field. This " +"option is meant mainly for projects that do not use the CPython headers " +"directly, and do not emulate a specific version of them." +msgstr "" + +#: ../../c-api/stable.rst:420 +msgid "The ABI version." +msgstr "" + +#: ../../c-api/stable.rst:422 +msgid "" +"For Stable ABI, this field should be the value of :c:macro:`Py_LIMITED_API` " +"or :c:macro:`Py_TARGET_ABI3T`. If both are defined, use the smaller value. " +"(If :c:macro:`Py_LIMITED_API` is ``3``; use :c:expr:`Py_PACK_VERSION(3, 2)` " +"instead of ``3``.)" +msgstr "" + +#: ../../c-api/stable.rst:428 +msgid "Otherwise, it should be set to :c:macro:`PY_VERSION_HEX`." +msgstr "" + +#: ../../c-api/stable.rst:430 +msgid "It can also be set to ``0`` to skip any checks related to this field." +msgstr "" + +#: ../../c-api/stable.rst:436 +msgid "" +"The value that should be used for this field, based on current values of " +"macros such as :c:macro:`Py_LIMITED_API`, :c:macro:`PY_VERSION_HEX` and :c:" +"macro:`Py_GIL_DISABLED`." +msgstr "" + +#: ../../c-api/stable.rst:447 msgid "Contents of Limited API" msgstr "受限 API 的內容" -#: ../../c-api/stable.rst:208 +#: ../../c-api/stable.rst:449 msgid "" -"Currently, the :ref:`Limited API ` includes the following " -"items:" -msgstr "目前,:ref:`受限 API ` 包括以下項目:" +"This is the definitive list of :ref:`Limited API ` for Python " +"|version|:" +msgstr "" +"這是 Python |version| 的\\ :ref:`受限 API ` 的權威清單:" #: ../../c-api/stable.rst:42 msgid "PyUnstable" msgstr "PyUnstable" + +#~ msgid "Limited C API" +#~ msgstr "受限 C API" + +#~ msgid "" +#~ "Python 3.2 introduced the *Limited API*, a subset of Python's C API. " +#~ "Extensions that only use the Limited API can be compiled once and be " +#~ "loaded on multiple versions of Python. Contents of the Limited API are :" +#~ "ref:`listed below `." +#~ msgstr "" +#~ "Python 3.2 引入了\\ *受限 API (Limited API)*,它是 Python C API 的一個子" +#~ "集。僅使用受限 API 的擴充可以只編譯一次就被載入於多個版本的 Python。受限 " +#~ "API 的內容\\ :ref:`列在下方 `。" + +#~ msgid "" +#~ "Define this macro before including ``Python.h`` to opt in to only use the " +#~ "Limited API, and to select the Limited API version." +#~ msgstr "" +#~ "在包含 ``Python.h`` 之前定義此巨集以選擇只使用受限 API,並挑選受限 API 版" +#~ "本。" + +#~ msgid "" +#~ "Define ``Py_LIMITED_API`` to the value of :c:macro:`PY_VERSION_HEX` " +#~ "corresponding to the lowest Python version your extension supports. The " +#~ "extension will be ABI-compatible with all Python 3 releases from the " +#~ "specified one onward, and can use Limited API introduced up to that " +#~ "version." +#~ msgstr "" +#~ "將 ``Py_LIMITED_API`` 定義為對應於你的擴充有支援的最低 Python 版本的 :c:" +#~ "macro:`PY_VERSION_HEX` 值。該擴充與從指定版本開始的所有 Python 3 版本之 " +#~ "ABI 相容,並且可以使用過去版本有引入的受限 API。" + +#~ msgid "" +#~ "Rather than using the ``PY_VERSION_HEX`` macro directly, hardcode a " +#~ "minimum minor version (e.g. ``0x030A0000`` for Python 3.10) for stability " +#~ "when compiling with future Python versions." +#~ msgstr "" +#~ "與其直接使用 ``PY_VERSION_HEX`` 巨集,不如寫死 (hardcode) 最小次要版本(例" +#~ "如代表 Python 3.10 的 ``0x030A0000``\\ ),以便在使用未來的 Python 版本進" +#~ "行編譯時仍保持穩定性。" + +#~ msgid "" +#~ "To enable this, Python provides a *Stable ABI*: a set of symbols that " +#~ "will remain ABI-compatible across Python 3.x versions." +#~ msgstr "" +#~ "為了實現它,Python 提供了一個\\ *穩定 ABI (Stable ABI)*:一組將在各個 " +#~ "Python 3.x 版本之間保持 ABI 相容的符號。" + +#~ msgid "" +#~ "The Stable ABI contains symbols exposed in the :ref:`Limited API `, but also other ones – for example, functions necessary to " +#~ "support older versions of the Limited API." +#~ msgstr "" +#~ "穩定 ABI 被包含在\\ :ref:`受限 API ` 中開放的符號,但也包含" +#~ "其他符號 - 例如,支援舊版受限 API 所必需的函式。" + +#~ msgid "" +#~ "On some platforms, Python will look for and load shared library files " +#~ "named with the ``abi3`` tag (e.g. ``mymodule.abi3.so``). It does not " +#~ "check if such extensions conform to a Stable ABI. The user (or their " +#~ "packaging tools) need to ensure that, for example, extensions built with " +#~ "the 3.10+ Limited API are not installed for lower versions of Python." +#~ msgstr "" +#~ "在某些平台上,Python 將查找並加載以 ``abi3`` 標籤命名的共享函式庫檔案(例" +#~ "如 ``mymodule.abi3.so``\\ )。它不檢查此類擴充是否符合穩定的 ABI。確保的責" +#~ "任在使用者(或者打包工具)身上,例如使用 3.10+ 受限 API 建置的擴充不會為較" +#~ "低版本的 Python 所安裝。" + +#~ msgid "" +#~ "By leaving out the ``Py_LIMITED_API`` definition, it is possible to " +#~ "compile a Limited API extension with a version-specific ABI. This can " +#~ "improve performance for that Python version, but will limit " +#~ "compatibility. Compiling with ``Py_LIMITED_API`` will then yield an " +#~ "extension that can be distributed where a version-specific one is not " +#~ "available – for example, for prereleases of an upcoming Python version." +#~ msgstr "" +#~ "透過省略 ``Py_LIMITED_API`` 定義,可以使用特定版本的 ABI 編譯受限 API 擴" +#~ "充。這可以提高該 Python 版本的性能,但會限制相容性。使用 " +#~ "``Py_LIMITED_API`` 編譯將產生一個擴充,可以在特定版本的擴充不可用的地方發" +#~ "布 — 例如,用於即將發布的 Python 版本的預發布版本 (prerelease)。" + +#~ msgid "Limited API Caveats" +#~ msgstr "受限 API 注意事項" + +#~ msgid "" +#~ "Note that compiling with ``Py_LIMITED_API`` is *not* a complete guarantee " +#~ "that code conforms to the :ref:`Limited API ` or the :ref:" +#~ "`Stable ABI `. ``Py_LIMITED_API`` only covers definitions, " +#~ "but an API also includes other issues, such as expected semantics." +#~ msgstr "" +#~ "請注意,使用 ``Py_LIMITED_API`` 進行編譯\\ *不*\\ 完全保證程式碼符合\\ :" +#~ "ref:`受限 API ` 或\\ :ref:`穩定 ABI `。" +#~ "``Py_LIMITED_API`` 僅涵蓋定義,但 API 還包括其他議題,例如預期的語義 " +#~ "(semantic)。" + +#~ msgid "" +#~ "Another issue is that some struct fields are currently not hidden when " +#~ "``Py_LIMITED_API`` is defined, even though they're part of the Limited " +#~ "API." +#~ msgstr "" +#~ "另一個問題是,當有定義 ``Py_LIMITED_API`` 時,一些結構欄位目前不會被隱藏," +#~ "即使它們是受限 API 的一部分。" diff --git a/c-api/structures.po b/c-api/structures.po index 00e204a1b00..d0613e29600 100644 --- a/c-api/structures.po +++ b/c-api/structures.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -60,50 +60,90 @@ msgid "" "macro:`Py_REFCNT` and :c:macro:`Py_TYPE`." msgstr "" -#: ../../c-api/structures.rst:38 +#: ../../c-api/structures.rst:36 +msgid "" +"In the :ref:`Stable ABI ` for Free-Threaded Builds (``abi3t``), " +"this struct is opaque; its size and layout may change between Python " +"versions. In Stable ABI for non-free-threaded builds (``abi3``), the :c:" +"member:`!ob_refcnt` and :c:member:`!ob_type` fields are available, but using " +"them directly is discouraged." +msgstr "" + +#: ../../c-api/structures.rst:45 msgid "" "The object's reference count, as returned by :c:macro:`Py_REFCNT`. Do not " "use this field directly; instead use functions and macros such as :c:macro:`!" "Py_REFCNT`, :c:func:`Py_INCREF` and :c:func:`Py_DecRef`." msgstr "" -#: ../../c-api/structures.rst:42 +#: ../../c-api/structures.rst:49 msgid "" "The field type may be different from ``Py_ssize_t``, depending on build " "configuration and platform." msgstr "" -#: ../../c-api/structures.rst:47 +#: ../../c-api/structures.rst:54 msgid "" "The object's type. Do not use this field directly; use :c:macro:`Py_TYPE` " "and :c:func:`Py_SET_TYPE` instead." msgstr "" -#: ../../c-api/structures.rst:54 +#: ../../c-api/structures.rst:60 +msgid "" +"A :ref:`per-object lock `, present only in the :term:`free-" +"threaded ` build (when :c:macro:`Py_GIL_DISABLED` is " +"defined)." +msgstr "" + +#: ../../c-api/structures.rst:63 +msgid "" +"This field is **reserved for use by the critical section API** (:c:macro:" +"`Py_BEGIN_CRITICAL_SECTION` / :c:macro:`Py_END_CRITICAL_SECTION`). Do " +"**not** lock it directly with ``PyMutex_Lock``; doing so can cause " +"deadlocks. If you need your own lock, add a separate :c:type:`PyMutex` " +"field to your object struct." +msgstr "" + +#: ../../c-api/structures.rst:74 msgid "" "An extension of :c:type:`PyObject` that adds the :c:member:`~PyVarObject." "ob_size` field. This is intended for objects that have some notion of " "*length*." msgstr "" -#: ../../c-api/structures.rst:58 +#: ../../c-api/structures.rst:78 msgid "" "As with :c:type:`!PyObject`, the members must not be accessed directly; " "instead use macros such as :c:macro:`Py_SIZE`, :c:macro:`Py_REFCNT` and :c:" "macro:`Py_TYPE`." msgstr "" -#: ../../c-api/structures.rst:64 +#: ../../c-api/structures.rst:82 +msgid "" +"In the :ref:`Stable ABI ` for Free-Threaded Builds (``abi3t``), " +"this struct is opaque; its size and layout may change between Python " +"versions. In Stable ABI for non-free-threaded builds (``abi3``), the :c:" +"member:`!ob_base` and :c:member:`!ob_size` fields are available, but using " +"them directly is discouraged." +msgstr "" + +#: ../../c-api/structures.rst:91 +msgid "" +"Common object header. Typically, this field is not accessed directly; " +"instead :c:type:`!PyVarObject` can be cast to :c:type:`PyObject`." +msgstr "" + +#: ../../c-api/structures.rst:97 msgid "" "A size field, whose contents should be considered an object's internal " "implementation detail." msgstr "" -#: ../../c-api/structures.rst:67 +#: ../../c-api/structures.rst:100 msgid "Do not use this field directly; use :c:macro:`Py_SIZE` instead." msgstr "" -#: ../../c-api/structures.rst:69 +#: ../../c-api/structures.rst:102 msgid "" "Object creation functions such as :c:func:`PyObject_NewVar` will generally " "set this field to the requested size (number of items). After creation, " @@ -111,137 +151,137 @@ msgid "" "`Py_SET_SIZE`." msgstr "" -#: ../../c-api/structures.rst:74 +#: ../../c-api/structures.rst:107 msgid "" "To get an object's publicly exposed length, as returned by the Python " "function :py:func:`len`, use :c:func:`PyObject_Length` instead." msgstr "" -#: ../../c-api/structures.rst:81 +#: ../../c-api/structures.rst:114 msgid "" "This is a macro used when declaring new types which represent objects " "without a varying length. The PyObject_HEAD macro expands to::" msgstr "" -#: ../../c-api/structures.rst:84 +#: ../../c-api/structures.rst:117 msgid "PyObject ob_base;" msgstr "PyObject ob_base;" -#: ../../c-api/structures.rst:86 +#: ../../c-api/structures.rst:119 msgid "See documentation of :c:type:`PyObject` above." msgstr "請見上面 :c:type:`PyObject` 的文件。" -#: ../../c-api/structures.rst:91 +#: ../../c-api/structures.rst:124 msgid "" "This is a macro used when declaring new types which represent objects with a " "length that varies from instance to instance. The PyObject_VAR_HEAD macro " "expands to::" msgstr "" -#: ../../c-api/structures.rst:95 +#: ../../c-api/structures.rst:128 msgid "PyVarObject ob_base;" msgstr "PyVarObject ob_base;" -#: ../../c-api/structures.rst:97 +#: ../../c-api/structures.rst:130 msgid "See documentation of :c:type:`PyVarObject` above." msgstr "請見上面 :c:type:`PyVarObject` 的文件。" -#: ../../c-api/structures.rst:102 +#: ../../c-api/structures.rst:135 msgid "" "The base class of all other objects, the same as :class:`object` in Python." msgstr "" -#: ../../c-api/structures.rst:107 +#: ../../c-api/structures.rst:140 msgid "" "Test if the *x* object is the *y* object, the same as ``x is y`` in Python." msgstr "" -#: ../../c-api/structures.rst:114 +#: ../../c-api/structures.rst:147 msgid "" "Test if an object is the ``None`` singleton, the same as ``x is None`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:122 +#: ../../c-api/structures.rst:155 msgid "" "Test if an object is the ``True`` singleton, the same as ``x is True`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:130 +#: ../../c-api/structures.rst:163 msgid "" "Test if an object is the ``False`` singleton, the same as ``x is False`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:138 +#: ../../c-api/structures.rst:171 msgid "Get the type of the Python object *o*." msgstr "" -#: ../../c-api/structures.rst:140 +#: ../../c-api/structures.rst:173 msgid "" "The returned reference is :term:`borrowed ` from *o*. Do " "not release it with :c:func:`Py_DECREF` or similar." msgstr "" -#: ../../c-api/structures.rst:143 +#: ../../c-api/structures.rst:176 msgid "" ":c:func:`Py_TYPE()` is changed to an inline static function. The parameter " "type is no longer :c:expr:`const PyObject*`." msgstr "" -#: ../../c-api/structures.rst:150 +#: ../../c-api/structures.rst:183 msgid "" "Return non-zero if the object *o* type is *type*. Return zero otherwise. " "Equivalent to: ``Py_TYPE(o) == type``." msgstr "" -#: ../../c-api/structures.rst:158 +#: ../../c-api/structures.rst:191 msgid "" "Set the type of object *o* to *type*, without any checking or reference " "counting." msgstr "" -#: ../../c-api/structures.rst:161 +#: ../../c-api/structures.rst:194 msgid "" "This is a very low-level operation. Consider instead setting the Python " "attribute :attr:`~object.__class__` using :c:func:`PyObject_SetAttrString` " "or similar." msgstr "" -#: ../../c-api/structures.rst:165 +#: ../../c-api/structures.rst:198 msgid "" "Note that assigning an incompatible type can lead to undefined behavior." msgstr "" -#: ../../c-api/structures.rst:167 +#: ../../c-api/structures.rst:200 msgid "" "If *type* is a :ref:`heap type `, the caller must create a new " "reference to it. Similarly, if the old type of *o* is a heap type, the " "caller must release a reference to that type." msgstr "" -#: ../../c-api/structures.rst:177 +#: ../../c-api/structures.rst:210 msgid "Get the :c:member:`~PyVarObject.ob_size` field of *o*." msgstr "" -#: ../../c-api/structures.rst:179 +#: ../../c-api/structures.rst:212 msgid "" ":c:func:`Py_SIZE()` is changed to an inline static function. The parameter " "type is no longer :c:expr:`const PyVarObject*`." msgstr "" -#: ../../c-api/structures.rst:186 +#: ../../c-api/structures.rst:219 msgid "Set the :c:member:`~PyVarObject.ob_size` field of *o* to *size*." msgstr "" -#: ../../c-api/structures.rst:193 +#: ../../c-api/structures.rst:226 msgid "" "This is a macro which expands to initialization values for a new :c:type:" "`PyObject` type. This macro expands to::" msgstr "" -#: ../../c-api/structures.rst:196 +#: ../../c-api/structures.rst:229 msgid "" "_PyObject_EXTRA_INIT\n" "1, type," @@ -249,14 +289,14 @@ msgstr "" "_PyObject_EXTRA_INIT\n" "1, type," -#: ../../c-api/structures.rst:202 +#: ../../c-api/structures.rst:235 msgid "" "This is a macro which expands to initialization values for a new :c:type:" "`PyVarObject` type, including the :c:member:`~PyVarObject.ob_size` field. " "This macro expands to::" msgstr "" -#: ../../c-api/structures.rst:206 +#: ../../c-api/structures.rst:239 msgid "" "_PyObject_EXTRA_INIT\n" "1, type, size," @@ -264,11 +304,11 @@ msgstr "" "_PyObject_EXTRA_INIT\n" "1, type, size," -#: ../../c-api/structures.rst:211 +#: ../../c-api/structures.rst:244 msgid "Implementing functions and methods" msgstr "實作函式與方法" -#: ../../c-api/structures.rst:215 +#: ../../c-api/structures.rst:248 msgid "" "Type of the functions used to implement most Python callables in C. " "Functions of this type take two :c:expr:`PyObject*` parameters and return " @@ -278,11 +318,11 @@ msgid "" "reference." msgstr "" -#: ../../c-api/structures.rst:222 +#: ../../c-api/structures.rst:255 msgid "The function signature is::" msgstr "" -#: ../../c-api/structures.rst:224 +#: ../../c-api/structures.rst:257 msgid "" "PyObject *PyCFunction(PyObject *self,\n" " PyObject *args);" @@ -290,14 +330,14 @@ msgstr "" "PyObject *PyCFunction(PyObject *self,\n" " PyObject *args);" -#: ../../c-api/structures.rst:229 +#: ../../c-api/structures.rst:262 msgid "" "Type of the functions used to implement Python callables in C with " "signature :ref:`METH_VARARGS | METH_KEYWORDS `. " "The function signature is::" msgstr "" -#: ../../c-api/structures.rst:233 +#: ../../c-api/structures.rst:266 msgid "" "PyObject *PyCFunctionWithKeywords(PyObject *self,\n" " PyObject *args,\n" @@ -307,13 +347,13 @@ msgstr "" " PyObject *args,\n" " PyObject *kwargs);" -#: ../../c-api/structures.rst:240 +#: ../../c-api/structures.rst:273 msgid "" "Type of the functions used to implement Python callables in C with " "signature :c:macro:`METH_FASTCALL`. The function signature is::" msgstr "" -#: ../../c-api/structures.rst:244 +#: ../../c-api/structures.rst:277 msgid "" "PyObject *PyCFunctionFast(PyObject *self,\n" " PyObject *const *args,\n" @@ -323,14 +363,14 @@ msgstr "" " PyObject *const *args,\n" " Py_ssize_t nargs);" -#: ../../c-api/structures.rst:250 +#: ../../c-api/structures.rst:283 msgid "" "Type of the functions used to implement Python callables in C with " "signature :ref:`METH_FASTCALL | METH_KEYWORDS `. The function signature is::" msgstr "" -#: ../../c-api/structures.rst:254 +#: ../../c-api/structures.rst:287 msgid "" "PyObject *PyCFunctionFastWithKeywords(PyObject *self,\n" " PyObject *const *args,\n" @@ -342,14 +382,14 @@ msgstr "" " Py_ssize_t nargs,\n" " PyObject *kwnames);" -#: ../../c-api/structures.rst:261 +#: ../../c-api/structures.rst:294 msgid "" "Type of the functions used to implement Python callables in C with " "signature :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS `. The function signature is::" msgstr "" -#: ../../c-api/structures.rst:265 +#: ../../c-api/structures.rst:298 msgid "" "PyObject *PyCMethod(PyObject *self,\n" " PyTypeObject *defining_class,\n" @@ -363,29 +403,33 @@ msgstr "" " Py_ssize_t nargs,\n" " PyObject *kwnames)" -#: ../../c-api/structures.rst:276 +#: ../../c-api/structures.rst:309 msgid "" "Structure used to describe a method of an extension type. This structure " "has four fields:" msgstr "" -#: ../../c-api/structures.rst:281 +#: ../../c-api/structures.rst:314 msgid "Name of the method." msgstr "" -#: ../../c-api/structures.rst:285 +#: ../../c-api/structures.rst:316 +msgid "A ``NULL`` *ml_name* marks the end of a :c:type:`!PyMethodDef` array." +msgstr "" + +#: ../../c-api/structures.rst:320 msgid "Pointer to the C implementation." msgstr "" -#: ../../c-api/structures.rst:289 +#: ../../c-api/structures.rst:324 msgid "Flags bits indicating how the call should be constructed." msgstr "" -#: ../../c-api/structures.rst:293 +#: ../../c-api/structures.rst:328 msgid "Points to the contents of the docstring." msgstr "" -#: ../../c-api/structures.rst:295 +#: ../../c-api/structures.rst:330 msgid "" "The :c:member:`~PyMethodDef.ml_meth` is a C function pointer. The functions " "may be of different types, but they always return :c:expr:`PyObject*`. If " @@ -395,18 +439,18 @@ msgid "" "implementation uses the specific C type of the *self* object." msgstr "" -#: ../../c-api/structures.rst:303 +#: ../../c-api/structures.rst:338 msgid "" "The :c:member:`~PyMethodDef.ml_flags` field is a bitfield which can include " "the following flags. The individual flags indicate either a calling " "convention or a binding convention." msgstr "" -#: ../../c-api/structures.rst:308 +#: ../../c-api/structures.rst:343 msgid "There are these calling conventions:" msgstr "" -#: ../../c-api/structures.rst:312 +#: ../../c-api/structures.rst:347 msgid "" "This is the typical calling convention, where the methods have the type :c:" "type:`PyCFunction`. The function expects two :c:expr:`PyObject*` values. The " @@ -416,7 +460,7 @@ msgid "" "func:`PyArg_ParseTuple` or :c:func:`PyArg_UnpackTuple`." msgstr "" -#: ../../c-api/structures.rst:322 +#: ../../c-api/structures.rst:357 msgid "" "Can only be used in certain combinations with other flags: :ref:" "`METH_VARARGS | METH_KEYWORDS `, :ref:" @@ -425,11 +469,11 @@ msgid "" "METH_KEYWORDS>`." msgstr "" -#: ../../c-api/structures.rst:330 +#: ../../c-api/structures.rst:365 msgid ":c:expr:`METH_VARARGS | METH_KEYWORDS`" msgstr ":c:expr:`METH_VARARGS | METH_KEYWORDS`" -#: ../../c-api/structures.rst:331 +#: ../../c-api/structures.rst:366 msgid "" "Methods with these flags must be of type :c:type:`PyCFunctionWithKeywords`. " "The function expects three parameters: *self*, *args*, *kwargs* where " @@ -438,7 +482,7 @@ msgid "" "using :c:func:`PyArg_ParseTupleAndKeywords`." msgstr "" -#: ../../c-api/structures.rst:340 +#: ../../c-api/structures.rst:375 msgid "" "Fast calling convention supporting only positional arguments. The methods " "have the type :c:type:`PyCFunctionFast`. The first parameter is *self*, the " @@ -447,15 +491,15 @@ msgid "" "the array)." msgstr "" -#: ../../c-api/structures.rst:350 +#: ../../c-api/structures.rst:385 msgid "``METH_FASTCALL`` is now part of the :ref:`stable ABI `." msgstr "" -#: ../../c-api/structures.rst:355 +#: ../../c-api/structures.rst:390 msgid ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" msgstr ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:356 +#: ../../c-api/structures.rst:391 msgid "" "Extension of :c:macro:`METH_FASTCALL` supporting also keyword arguments, " "with methods of type :c:type:`PyCFunctionFastWithKeywords`. Keyword " @@ -467,17 +511,17 @@ msgid "" "the positional arguments." msgstr "" -#: ../../c-api/structures.rst:371 +#: ../../c-api/structures.rst:406 msgid "" "Can only be used in the combination with other flags: :ref:`METH_METHOD | " "METH_FASTCALL | METH_KEYWORDS `." msgstr "" -#: ../../c-api/structures.rst:377 +#: ../../c-api/structures.rst:412 msgid ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" msgstr ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:378 +#: ../../c-api/structures.rst:413 msgid "" "Extension of :ref:`METH_FASTCALL | METH_KEYWORDS ` supporting the *defining class*, that is, the class that " @@ -485,14 +529,14 @@ msgid "" "``Py_TYPE(self)``." msgstr "" -#: ../../c-api/structures.rst:383 +#: ../../c-api/structures.rst:418 msgid "" "The method needs to be of type :c:type:`PyCMethod`, the same as for " "``METH_FASTCALL | METH_KEYWORDS`` with ``defining_class`` argument added " "after ``self``." msgstr "" -#: ../../c-api/structures.rst:392 +#: ../../c-api/structures.rst:427 msgid "" "Methods without parameters don't need to check whether arguments are given " "if they are listed with the :c:macro:`METH_NOARGS` flag. They need to be of " @@ -501,13 +545,13 @@ msgid "" "the second parameter will be ``NULL``." msgstr "" -#: ../../c-api/structures.rst:398 +#: ../../c-api/structures.rst:433 msgid "" "The function must have 2 parameters. Since the second parameter is unused, :" "c:macro:`Py_UNUSED` can be used to prevent a compiler warning." msgstr "" -#: ../../c-api/structures.rst:404 +#: ../../c-api/structures.rst:439 msgid "" "Methods with a single object argument can be listed with the :c:macro:" "`METH_O` flag, instead of invoking :c:func:`PyArg_ParseTuple` with a " @@ -516,7 +560,7 @@ msgid "" "single argument." msgstr "" -#: ../../c-api/structures.rst:410 +#: ../../c-api/structures.rst:445 msgid "" "These two constants are not used to indicate the calling convention but the " "binding when used with methods of classes. These may not be used for " @@ -524,27 +568,27 @@ msgid "" "any given method." msgstr "" -#: ../../c-api/structures.rst:420 +#: ../../c-api/structures.rst:455 msgid "" "The method will be passed the type object as the first parameter rather than " "an instance of the type. This is used to create *class methods*, similar to " "what is created when using the :deco:`classmethod` built-in decorator." msgstr "" -#: ../../c-api/structures.rst:430 +#: ../../c-api/structures.rst:465 msgid "" "The method will be passed ``NULL`` as the first parameter rather than an " "instance of the type. This is used to create *static methods*, similar to " "what is created when using the :deco:`staticmethod` built-in decorator." msgstr "" -#: ../../c-api/structures.rst:434 +#: ../../c-api/structures.rst:469 msgid "" "One other constant controls whether a method is loaded in place of another " "definition with the same method name." msgstr "" -#: ../../c-api/structures.rst:440 +#: ../../c-api/structures.rst:475 msgid "" "The method will be loaded in place of existing definitions. Without " "*METH_COEXIST*, the default is to skip repeated definitions. Since slot " @@ -557,38 +601,38 @@ msgid "" "wrapper object calls." msgstr "" -#: ../../c-api/structures.rst:453 +#: ../../c-api/structures.rst:488 msgid "" "The type object corresponding to Python C method objects. This is available " "as :class:`types.BuiltinMethodType` in the Python layer." msgstr "" -#: ../../c-api/structures.rst:459 +#: ../../c-api/structures.rst:494 msgid "" "Return true if *op* is an instance of the :c:type:`PyCMethod_Type` type or a " "subtype of it. This function always succeeds." msgstr "" -#: ../../c-api/structures.rst:465 +#: ../../c-api/structures.rst:500 msgid "" "This is the same as :c:func:`PyCMethod_Check`, but does not account for " "subtypes." msgstr "" -#: ../../c-api/structures.rst:471 +#: ../../c-api/structures.rst:506 msgid "" "Turn *ml* into a Python :term:`callable` object. The caller must ensure that " "*ml* outlives the :term:`callable`. Typically, *ml* is defined as a static " "variable." msgstr "" -#: ../../c-api/structures.rst:475 +#: ../../c-api/structures.rst:510 msgid "" "The *self* parameter will be passed as the *self* argument to the C function " "in ``ml->ml_meth`` when invoked. *self* can be ``NULL``." msgstr "" -#: ../../c-api/structures.rst:479 +#: ../../c-api/structures.rst:514 msgid "" "The :term:`callable` object's ``__module__`` attribute can be set from the " "given *module* argument. *module* should be a Python string, which will be " @@ -596,86 +640,86 @@ msgid "" "can be set to :const:`None` or ``NULL``." msgstr "" -#: ../../c-api/structures.rst:485 +#: ../../c-api/structures.rst:520 msgid ":attr:`function.__module__`" msgstr ":attr:`function.__module__`" -#: ../../c-api/structures.rst:487 +#: ../../c-api/structures.rst:522 msgid "" "The *cls* parameter will be passed as the *defining_class* argument to the C " "function. Must be set if :c:macro:`METH_METHOD` is set on ``ml->ml_flags``." msgstr "" -#: ../../c-api/structures.rst:496 +#: ../../c-api/structures.rst:531 msgid "" "The type object corresponding to Python C function objects. This is " "available as :class:`types.BuiltinFunctionType` in the Python layer." msgstr "" -#: ../../c-api/structures.rst:502 +#: ../../c-api/structures.rst:537 msgid "" "Return true if *op* is an instance of the :c:type:`PyCFunction_Type` type or " "a subtype of it. This function always succeeds." msgstr "" -#: ../../c-api/structures.rst:508 +#: ../../c-api/structures.rst:543 msgid "" "This is the same as :c:func:`PyCFunction_Check`, but does not account for " "subtypes." msgstr "" -#: ../../c-api/structures.rst:514 +#: ../../c-api/structures.rst:549 msgid "Equivalent to ``PyCMethod_New(ml, self, module, NULL)``." msgstr "等價於 ``PyCMethod_New(ml, self, module, NULL)``。" -#: ../../c-api/structures.rst:519 +#: ../../c-api/structures.rst:554 msgid "Equivalent to ``PyCMethod_New(ml, self, NULL, NULL)``." msgstr "等價於 ``PyCMethod_New(ml, self, NULL, NULL)``。" -#: ../../c-api/structures.rst:524 +#: ../../c-api/structures.rst:559 msgid "" "Get the function's flags on *func* as they were passed to :c:member:" "`~PyMethodDef.ml_flags`." msgstr "" -#: ../../c-api/structures.rst:527 ../../c-api/structures.rst:545 -#: ../../c-api/structures.rst:565 +#: ../../c-api/structures.rst:562 ../../c-api/structures.rst:580 +#: ../../c-api/structures.rst:600 msgid "" "If *func* is not a C function object, this fails with an exception. *func* " "must not be ``NULL``." msgstr "" -#: ../../c-api/structures.rst:530 +#: ../../c-api/structures.rst:565 msgid "" "This function returns the function's flags on success, and ``-1`` with an " "exception set on failure." msgstr "" -#: ../../c-api/structures.rst:536 +#: ../../c-api/structures.rst:571 msgid "" "This is the same as :c:func:`PyCFunction_GetFlags`, but without error or " "type checking." msgstr "" -#: ../../c-api/structures.rst:542 +#: ../../c-api/structures.rst:577 msgid "" "Get the function pointer on *func* as it was passed to :c:member:" "`~PyMethodDef.ml_meth`." msgstr "" -#: ../../c-api/structures.rst:548 +#: ../../c-api/structures.rst:583 msgid "" "This function returns the function pointer on success, and ``NULL`` with an " "exception set on failure." msgstr "" -#: ../../c-api/structures.rst:554 +#: ../../c-api/structures.rst:589 msgid "" "This is the same as :c:func:`PyCFunction_GetFunction`, but without error or " "type checking." msgstr "" -#: ../../c-api/structures.rst:560 +#: ../../c-api/structures.rst:595 msgid "" "Get the \"self\" object on *func*. This is the object that would be passed " "to the first argument of a :c:type:`PyCFunction`. For C function objects " @@ -683,65 +727,65 @@ msgid "" "the resulting module object." msgstr "" -#: ../../c-api/structures.rst:568 +#: ../../c-api/structures.rst:603 msgid "" "This function returns a :term:`borrowed reference` to the \"self\" object on " "success, and ``NULL`` with an exception set on failure." msgstr "" -#: ../../c-api/structures.rst:574 +#: ../../c-api/structures.rst:609 msgid "" "This is the same as :c:func:`PyCFunction_GetSelf`, but without error or type " "checking." msgstr "" -#: ../../c-api/structures.rst:579 +#: ../../c-api/structures.rst:614 msgid "Accessing attributes of extension types" msgstr "" -#: ../../c-api/structures.rst:583 +#: ../../c-api/structures.rst:618 msgid "" "Structure which describes an attribute of a type which corresponds to a C " "struct member. When defining a class, put a NULL-terminated array of these " "structures in the :c:member:`~PyTypeObject.tp_members` slot." msgstr "" -#: ../../c-api/structures.rst:588 +#: ../../c-api/structures.rst:623 msgid "Its fields are, in order:" msgstr "" -#: ../../c-api/structures.rst:592 +#: ../../c-api/structures.rst:627 msgid "" "Name of the member. A NULL value marks the end of a ``PyMemberDef[]`` array." msgstr "" -#: ../../c-api/structures.rst:595 +#: ../../c-api/structures.rst:630 msgid "The string should be static, no copy is made of it." msgstr "" -#: ../../c-api/structures.rst:599 +#: ../../c-api/structures.rst:634 msgid "" "The type of the member in the C struct. See :ref:`PyMemberDef-types` for the " "possible values." msgstr "" -#: ../../c-api/structures.rst:604 +#: ../../c-api/structures.rst:639 msgid "" "The offset in bytes that the member is located on the type’s object struct." msgstr "" -#: ../../c-api/structures.rst:608 +#: ../../c-api/structures.rst:643 msgid "" "Zero or more of the :ref:`PyMemberDef-flags`, combined using bitwise OR." msgstr "" -#: ../../c-api/structures.rst:612 +#: ../../c-api/structures.rst:647 msgid "" "The docstring, or NULL. The string should be static, no copy is made of it. " "Typically, it is defined using :c:macro:`PyDoc_STR`." msgstr "" -#: ../../c-api/structures.rst:616 +#: ../../c-api/structures.rst:651 msgid "" "By default (when :c:member:`~PyMemberDef.flags` is ``0``), members allow " "both read and write access. Use the :c:macro:`Py_READONLY` flag for read-" @@ -750,7 +794,7 @@ msgid "" "`T_OBJECT`) members can be deleted." msgstr "" -#: ../../c-api/structures.rst:625 +#: ../../c-api/structures.rst:660 msgid "" "For heap-allocated types (created using :c:func:`PyType_FromSpec` or " "similar), ``PyMemberDef`` may contain a definition for the special member " @@ -760,7 +804,7 @@ msgid "" "Py_RELATIVE_OFFSET``. For example::" msgstr "" -#: ../../c-api/structures.rst:632 +#: ../../c-api/structures.rst:667 msgid "" "static PyMemberDef spam_type_members[] = {\n" " {\"__vectorcalloffset__\", Py_T_PYSSIZET,\n" @@ -774,11 +818,11 @@ msgstr "" " {NULL} /* Sentinel */\n" "};" -#: ../../c-api/structures.rst:638 +#: ../../c-api/structures.rst:673 msgid "(You may need to ``#include `` for :c:func:`!offsetof`.)" msgstr "" -#: ../../c-api/structures.rst:640 +#: ../../c-api/structures.rst:675 msgid "" "The legacy offsets :c:member:`~PyTypeObject.tp_dictoffset` and :c:member:" "`~PyTypeObject.tp_weaklistoffset` can be defined similarly using " @@ -787,70 +831,70 @@ msgid "" "and :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead." msgstr "" -#: ../../c-api/structures.rst:648 +#: ../../c-api/structures.rst:683 msgid "" "``PyMemberDef`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:653 +#: ../../c-api/structures.rst:688 msgid "" ":c:macro:`Py_RELATIVE_OFFSET` is now allowed for " "``\"__vectorcalloffset__\"``, ``\"__dictoffset__\"`` and " "``\"__weaklistoffset__\"``." msgstr "" -#: ../../c-api/structures.rst:659 +#: ../../c-api/structures.rst:694 msgid "" "Get an attribute belonging to the object at address *obj_addr*. The " "attribute is described by ``PyMemberDef`` *m*. Returns ``NULL`` on error." msgstr "" -#: ../../c-api/structures.rst:665 +#: ../../c-api/structures.rst:700 msgid "" "``PyMember_GetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:670 +#: ../../c-api/structures.rst:705 msgid "" "Set an attribute belonging to the object at address *obj_addr* to object " "*o*. The attribute to set is described by ``PyMemberDef`` *m*. Returns " "``0`` if successful and a negative value on failure." msgstr "" -#: ../../c-api/structures.rst:676 +#: ../../c-api/structures.rst:711 msgid "" "``PyMember_SetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:682 +#: ../../c-api/structures.rst:717 msgid "Member flags" msgstr "" -#: ../../c-api/structures.rst:684 +#: ../../c-api/structures.rst:719 msgid "The following flags can be used with :c:member:`PyMemberDef.flags`:" msgstr "" -#: ../../c-api/structures.rst:688 +#: ../../c-api/structures.rst:723 msgid "Not writable." msgstr "不可寫入。" -#: ../../c-api/structures.rst:692 +#: ../../c-api/structures.rst:727 msgid "" "Emit an ``object.__getattr__`` :ref:`audit event ` before " "reading." msgstr "" -#: ../../c-api/structures.rst:697 +#: ../../c-api/structures.rst:732 msgid "" "Indicates that the :c:member:`~PyMemberDef.offset` of this ``PyMemberDef`` " "entry indicates an offset from the subclass-specific data, rather than from " "``PyObject``." msgstr "" -#: ../../c-api/structures.rst:701 +#: ../../c-api/structures.rst:736 msgid "" "Can only be used as part of the :c:data:`Py_tp_members` :c:type:`slot " "` when creating a class using negative :c:member:`~PyType_Spec." @@ -860,7 +904,7 @@ msgid "" "the ``PyObject`` struct." msgstr "" -#: ../../c-api/structures.rst:716 +#: ../../c-api/structures.rst:751 msgid "" "The :c:macro:`!RESTRICTED`, :c:macro:`!READ_RESTRICTED` and :c:macro:`!" "WRITE_RESTRICTED` macros available with ``#include \"structmember.h\"`` are " @@ -869,7 +913,7 @@ msgid "" "nothing." msgstr "" -#: ../../c-api/structures.rst:727 +#: ../../c-api/structures.rst:762 msgid "" "The :c:macro:`!READONLY` macro was renamed to :c:macro:`Py_READONLY`. The :c:" "macro:`!PY_AUDIT_READ` macro was renamed with the ``Py_`` prefix. The new " @@ -878,11 +922,11 @@ msgid "" "names." msgstr "" -#: ../../c-api/structures.rst:736 +#: ../../c-api/structures.rst:771 msgid "Member types" msgstr "" -#: ../../c-api/structures.rst:738 +#: ../../c-api/structures.rst:773 msgid "" ":c:member:`PyMemberDef.type` can be one of the following macros " "corresponding to various C types. When the member is accessed in Python, it " @@ -891,147 +935,147 @@ msgid "" "exception such as :exc:`TypeError` or :exc:`ValueError` is raised." msgstr "" -#: ../../c-api/structures.rst:746 +#: ../../c-api/structures.rst:781 msgid "" "Unless marked (D), attributes defined this way cannot be deleted using e.g. :" "keyword:`del` or :py:func:`delattr`." msgstr "" -#: ../../c-api/structures.rst:750 +#: ../../c-api/structures.rst:785 msgid "Macro name" msgstr "巨集名稱" -#: ../../c-api/structures.rst:750 +#: ../../c-api/structures.rst:785 msgid "C type" msgstr "" -#: ../../c-api/structures.rst:750 +#: ../../c-api/structures.rst:785 msgid "Python type" msgstr "" -#: ../../c-api/structures.rst:752 +#: ../../c-api/structures.rst:787 msgid ":c:expr:`char`" msgstr ":c:expr:`char`" -#: ../../c-api/structures.rst:752 ../../c-api/structures.rst:753 -#: ../../c-api/structures.rst:754 ../../c-api/structures.rst:755 -#: ../../c-api/structures.rst:756 ../../c-api/structures.rst:757 -#: ../../c-api/structures.rst:758 ../../c-api/structures.rst:759 -#: ../../c-api/structures.rst:760 ../../c-api/structures.rst:761 -#: ../../c-api/structures.rst:762 +#: ../../c-api/structures.rst:787 ../../c-api/structures.rst:788 +#: ../../c-api/structures.rst:789 ../../c-api/structures.rst:790 +#: ../../c-api/structures.rst:791 ../../c-api/structures.rst:792 +#: ../../c-api/structures.rst:793 ../../c-api/structures.rst:794 +#: ../../c-api/structures.rst:795 ../../c-api/structures.rst:796 +#: ../../c-api/structures.rst:797 msgid ":py:class:`int`" msgstr ":py:class:`int`" -#: ../../c-api/structures.rst:753 +#: ../../c-api/structures.rst:788 msgid ":c:expr:`short`" msgstr ":c:expr:`short`" -#: ../../c-api/structures.rst:754 +#: ../../c-api/structures.rst:789 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../c-api/structures.rst:755 +#: ../../c-api/structures.rst:790 msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../c-api/structures.rst:756 +#: ../../c-api/structures.rst:791 msgid ":c:expr:`long long`" msgstr ":c:expr:`long long`" -#: ../../c-api/structures.rst:757 +#: ../../c-api/structures.rst:792 msgid ":c:expr:`unsigned char`" msgstr ":c:expr:`unsigned char`" -#: ../../c-api/structures.rst:758 +#: ../../c-api/structures.rst:793 msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../c-api/structures.rst:759 +#: ../../c-api/structures.rst:794 msgid ":c:expr:`unsigned short`" msgstr ":c:expr:`unsigned short`" -#: ../../c-api/structures.rst:760 +#: ../../c-api/structures.rst:795 msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../c-api/structures.rst:761 +#: ../../c-api/structures.rst:796 msgid ":c:expr:`unsigned long long`" msgstr ":c:expr:`unsigned long long`" -#: ../../c-api/structures.rst:762 +#: ../../c-api/structures.rst:797 msgid ":c:expr:`Py_ssize_t`" msgstr ":c:expr:`Py_ssize_t`" -#: ../../c-api/structures.rst:763 +#: ../../c-api/structures.rst:798 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../c-api/structures.rst:763 ../../c-api/structures.rst:764 +#: ../../c-api/structures.rst:798 ../../c-api/structures.rst:799 msgid ":py:class:`float`" msgstr ":py:class:`float`" -#: ../../c-api/structures.rst:764 +#: ../../c-api/structures.rst:799 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../c-api/structures.rst:765 +#: ../../c-api/structures.rst:800 msgid ":c:expr:`char` (written as 0 or 1)" msgstr ":c:expr:`char` (寫成 0 或 1)" -#: ../../c-api/structures.rst:765 +#: ../../c-api/structures.rst:800 msgid ":py:class:`bool`" msgstr ":py:class:`bool`" -#: ../../c-api/structures.rst:767 +#: ../../c-api/structures.rst:802 msgid ":c:expr:`const char *` (*)" msgstr ":c:expr:`const char *` (*)" -#: ../../c-api/structures.rst:767 ../../c-api/structures.rst:768 +#: ../../c-api/structures.rst:802 ../../c-api/structures.rst:803 msgid ":py:class:`str` (RO)" msgstr ":py:class:`str` (RO)" -#: ../../c-api/structures.rst:768 +#: ../../c-api/structures.rst:803 msgid ":c:expr:`const char[]` (*)" msgstr ":c:expr:`const char[]` (*)" -#: ../../c-api/structures.rst:769 +#: ../../c-api/structures.rst:804 msgid ":c:expr:`char` (0-127)" msgstr ":c:expr:`char` (0-127)" -#: ../../c-api/structures.rst:769 +#: ../../c-api/structures.rst:804 msgid ":py:class:`str` (**)" msgstr ":py:class:`str` (**)" -#: ../../c-api/structures.rst:770 +#: ../../c-api/structures.rst:805 msgid ":c:expr:`PyObject *`" msgstr ":c:expr:`PyObject *`" -#: ../../c-api/structures.rst:770 +#: ../../c-api/structures.rst:805 msgid ":py:class:`object` (D)" msgstr ":py:class:`object` (D)" -#: ../../c-api/structures.rst:773 +#: ../../c-api/structures.rst:808 msgid "" "(*): Zero-terminated, UTF8-encoded C string. With :c:macro:`!Py_T_STRING` " "the C representation is a pointer; with :c:macro:`!Py_T_STRING_INPLACE` the " "string is stored directly in the structure." msgstr "" -#: ../../c-api/structures.rst:778 +#: ../../c-api/structures.rst:813 msgid "(**): String of length 1. Only ASCII is accepted." msgstr "" -#: ../../c-api/structures.rst:780 +#: ../../c-api/structures.rst:815 msgid "(RO): Implies :c:macro:`Py_READONLY`." msgstr "" -#: ../../c-api/structures.rst:782 +#: ../../c-api/structures.rst:817 msgid "" "(D): Can be deleted, in which case the pointer is set to ``NULL``. Reading a " "``NULL`` pointer raises :py:exc:`AttributeError`." msgstr "" -#: ../../c-api/structures.rst:808 +#: ../../c-api/structures.rst:843 msgid "" "In previous versions, the macros were only available with ``#include " "\"structmember.h\"`` and were named without the ``Py_`` prefix (e.g. as " @@ -1039,175 +1083,175 @@ msgid "" "with the following deprecated types:" msgstr "" -#: ../../c-api/structures.rst:816 +#: ../../c-api/structures.rst:851 msgid "" "Like ``Py_T_OBJECT_EX``, but ``NULL`` is converted to ``None``. This results " "in surprising behavior in Python: deleting the attribute effectively sets it " "to ``None``." msgstr "" -#: ../../c-api/structures.rst:822 +#: ../../c-api/structures.rst:857 msgid "Always ``None``. Must be used with :c:macro:`Py_READONLY`." msgstr "" -#: ../../c-api/structures.rst:825 +#: ../../c-api/structures.rst:860 msgid "Defining Getters and Setters" msgstr "" -#: ../../c-api/structures.rst:829 +#: ../../c-api/structures.rst:864 msgid "" "Structure to define property-like access for a type. See also description of " "the :c:member:`PyTypeObject.tp_getset` slot." msgstr "" -#: ../../c-api/structures.rst:834 +#: ../../c-api/structures.rst:869 msgid "attribute name" msgstr "屬性名稱" -#: ../../c-api/structures.rst:838 +#: ../../c-api/structures.rst:873 msgid "C function to get the attribute." msgstr "" -#: ../../c-api/structures.rst:842 +#: ../../c-api/structures.rst:877 msgid "" "Optional C function to set or delete the attribute. If ``NULL``, the " "attribute is read-only." msgstr "" -#: ../../c-api/structures.rst:847 +#: ../../c-api/structures.rst:882 msgid "optional docstring" msgstr "可選的文件字串" -#: ../../c-api/structures.rst:851 +#: ../../c-api/structures.rst:886 msgid "" "Optional user data pointer, providing additional data for getter and setter." msgstr "" -#: ../../c-api/structures.rst:855 +#: ../../c-api/structures.rst:890 msgid "" "The ``get`` function takes one :c:expr:`PyObject*` parameter (the instance) " "and a user data pointer (the associated ``closure``):" msgstr "" -#: ../../c-api/structures.rst:858 +#: ../../c-api/structures.rst:893 msgid "" "It should return a new reference on success or ``NULL`` with a set exception " "on failure." msgstr "" -#: ../../c-api/structures.rst:863 +#: ../../c-api/structures.rst:898 msgid "" "``set`` functions take two :c:expr:`PyObject*` parameters (the instance and " "the value to be set) and a user data pointer (the associated ``closure``):" msgstr "" -#: ../../c-api/structures.rst:866 +#: ../../c-api/structures.rst:901 msgid "" "In case the attribute should be deleted the second parameter is ``NULL``. " "Should return ``0`` on success or ``-1`` with a set exception on failure." msgstr "" -#: ../../c-api/structures.rst:418 ../../c-api/structures.rst:428 +#: ../../c-api/structures.rst:453 ../../c-api/structures.rst:463 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/structures.rst:418 +#: ../../c-api/structures.rst:453 msgid "classmethod" msgstr "classmethod" -#: ../../c-api/structures.rst:428 +#: ../../c-api/structures.rst:463 msgid "staticmethod" msgstr "staticmethod" -#: ../../c-api/structures.rst:709 +#: ../../c-api/structures.rst:744 msgid "READ_RESTRICTED (C macro)" msgstr "READ_RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:709 +#: ../../c-api/structures.rst:744 msgid "WRITE_RESTRICTED (C macro)" msgstr "WRITE_RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:709 +#: ../../c-api/structures.rst:744 msgid "RESTRICTED (C macro)" msgstr "RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:722 +#: ../../c-api/structures.rst:757 msgid "READONLY (C macro)" msgstr "READONLY(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_BYTE (C macro)" msgstr "T_BYTE(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_SHORT (C macro)" msgstr "T_SHORT(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_INT (C macro)" msgstr "T_INT(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_LONG (C macro)" msgstr "T_LONG(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_LONGLONG (C macro)" msgstr "T_LONGLONG(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_UBYTE (C macro)" msgstr "T_UBYTE(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_USHORT (C macro)" msgstr "T_USHORT(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_UINT (C macro)" msgstr "T_UINT(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_ULONG (C macro)" msgstr "T_ULONG(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_ULONGULONG (C macro)" msgstr "T_ULONGULONG(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_PYSSIZET (C macro)" msgstr "T_PYSSIZET(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_FLOAT (C macro)" msgstr "T_FLOAT(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_DOUBLE (C macro)" msgstr "T_DOUBLE(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_BOOL (C macro)" msgstr "T_BOOL(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_CHAR (C macro)" msgstr "T_CHAR(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_STRING (C macro)" msgstr "T_STRING(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_STRING_INPLACE (C macro)" msgstr "T_STRING_INPLACE(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "T_OBJECT_EX (C macro)" msgstr "T_OBJECT_EX(C 巨集)" -#: ../../c-api/structures.rst:785 +#: ../../c-api/structures.rst:820 msgid "structmember.h" msgstr "structmember.h" diff --git a/c-api/subinterpreters.po b/c-api/subinterpreters.po index 259fd5a27c8..caf76e1ff45 100644 --- a/c-api/subinterpreters.po +++ b/c-api/subinterpreters.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-24 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -479,47 +479,69 @@ msgid "Set the frame evaluation function." msgstr "" #: ../../c-api/subinterpreters.rst:404 +msgid "" +"Enables or disables specialization why a custom frame evaluator is in place." +msgstr "" + +#: ../../c-api/subinterpreters.rst:406 +msgid "" +"If *allow_specialization* is non-zero, the adaptive specializer will " +"continue to specialize bytecodes even though a custom eval frame function is " +"set. When *allow_specialization* is zero, setting a custom eval frame " +"disables specialization. The standard interpreter loop will continue to " +"deopt while a frame evaluation API is in place - the frame evaluation " +"function needs to handle the specialized opcodes to take advantage of this." +msgstr "" + +#: ../../c-api/subinterpreters.rst:417 +msgid "" +"Return non-zero if adaptive specialization is enabled for the interpreter. " +"Specialization is enabled when no custom eval frame function is set, or when " +"one is set with *allow_specialization* enabled." +msgstr "" + +#: ../../c-api/subinterpreters.rst:425 msgid "Low-level APIs" msgstr "低階 API" -#: ../../c-api/subinterpreters.rst:406 +#: ../../c-api/subinterpreters.rst:427 msgid "" "All of the following functions must be called after :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/subinterpreters.rst:408 +#: ../../c-api/subinterpreters.rst:429 msgid "" ":c:func:`Py_Initialize()` now initializes the :term:`GIL` and sets an :term:" "`attached thread state`." msgstr "" -#: ../../c-api/subinterpreters.rst:415 +#: ../../c-api/subinterpreters.rst:436 msgid "" "Create a new interpreter state object. An :term:`attached thread state` is " "not needed, but may optionally exist if it is necessary to serialize calls " "to this function." msgstr "" -#: ../../c-api/subinterpreters.rst:419 +#: ../../c-api/subinterpreters.rst:440 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_New`` with no arguments." msgstr "" -#: ../../c-api/subinterpreters.rst:424 +#: ../../c-api/subinterpreters.rst:445 msgid "" "Reset all information in an interpreter state object. There must be an :" "term:`attached thread state` for the interpreter." msgstr "" -#: ../../c-api/subinterpreters.rst:427 +#: ../../c-api/subinterpreters.rst:448 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_Clear`` with no arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython.PyInterpreterState_Clear``。" -#: ../../c-api/subinterpreters.rst:432 +#: ../../c-api/subinterpreters.rst:453 msgid "" "Destroy an interpreter state object. There **should not** be an :term:" "`attached thread state` for the target interpreter. The interpreter state " @@ -527,38 +549,38 @@ msgid "" "`PyInterpreterState_Clear`." msgstr "" -#: ../../c-api/subinterpreters.rst:440 +#: ../../c-api/subinterpreters.rst:461 msgid "Advanced debugger support" msgstr "進階偵錯器支援" -#: ../../c-api/subinterpreters.rst:442 +#: ../../c-api/subinterpreters.rst:463 msgid "" "These functions are only intended to be used by advanced debugging tools." msgstr "" -#: ../../c-api/subinterpreters.rst:447 +#: ../../c-api/subinterpreters.rst:468 msgid "" "Return the interpreter state object at the head of the list of all such " "objects." msgstr "" -#: ../../c-api/subinterpreters.rst:452 +#: ../../c-api/subinterpreters.rst:473 msgid "Return the main interpreter state object." msgstr "" -#: ../../c-api/subinterpreters.rst:457 +#: ../../c-api/subinterpreters.rst:478 msgid "" "Return the next interpreter state object after *interp* from the list of all " "such objects." msgstr "" -#: ../../c-api/subinterpreters.rst:463 +#: ../../c-api/subinterpreters.rst:484 msgid "" "Return the pointer to the first :c:type:`PyThreadState` object in the list " "of threads associated with the interpreter *interp*." msgstr "" -#: ../../c-api/subinterpreters.rst:469 +#: ../../c-api/subinterpreters.rst:490 msgid "" "Return the next thread state object after *tstate* from the list of all such " "objects belonging to the same :c:type:`PyInterpreterState` object." diff --git a/c-api/synchronization.po b/c-api/synchronization.po index 7aba53bfbeb..0c04e948a30 100644 --- a/c-api/synchronization.po +++ b/c-api/synchronization.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-24 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -115,15 +115,7 @@ msgid "" "needs to call into the C API in a manner that might lead to deadlocks." msgstr "" -#: ../../c-api/synchronization.rst:87 -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 " -"expansions. Note that the sizes and contents of the structures may change in " -"future Python versions." -msgstr "" - -#: ../../c-api/synchronization.rst:94 +#: ../../c-api/synchronization.rst:89 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 " @@ -132,11 +124,11 @@ msgid "" "lock more than two objects at once." msgstr "" -#: ../../c-api/synchronization.rst:100 +#: ../../c-api/synchronization.rst:95 msgid "Example usage::" msgstr "範例用法: ::" -#: ../../c-api/synchronization.rst:102 +#: ../../c-api/synchronization.rst:97 msgid "" "static PyObject *\n" "set_field(MyObject *self, PyObject *value)\n" @@ -156,7 +148,7 @@ msgstr "" " Py_RETURN_NONE;\n" "}" -#: ../../c-api/synchronization.rst:111 +#: ../../c-api/synchronization.rst:106 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 " @@ -166,19 +158,20 @@ msgid "" "`PyEval_SaveThread`." msgstr "" -#: ../../c-api/synchronization.rst:119 +#: ../../c-api/synchronization.rst:116 msgid "" "Acquires the per-object lock for the object *op* and begins a critical " "section." msgstr "" -#: ../../c-api/synchronization.rst:122 ../../c-api/synchronization.rst:136 -#: ../../c-api/synchronization.rst:153 ../../c-api/synchronization.rst:168 -#: ../../c-api/synchronization.rst:182 ../../c-api/synchronization.rst:199 -msgid "In the free-threaded build, this macro expands to::" +#: ../../c-api/synchronization.rst:119 ../../c-api/synchronization.rst:151 +#: ../../c-api/synchronization.rst:181 ../../c-api/synchronization.rst:199 +msgid "" +"In the free-threaded build, and when building for the :ref:`Stable ABI " +"`, this macro expands to::" msgstr "" -#: ../../c-api/synchronization.rst:124 +#: ../../c-api/synchronization.rst:122 msgid "" "{\n" " PyCriticalSection _py_cs;\n" @@ -188,15 +181,19 @@ msgstr "" " PyCriticalSection _py_cs;\n" " PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" -#: ../../c-api/synchronization.rst:128 ../../c-api/synchronization.rst:174 +#: ../../c-api/synchronization.rst:126 ../../c-api/synchronization.rst:173 msgid "In the default build, this macro expands to ``{``." msgstr "" -#: ../../c-api/synchronization.rst:134 +#: ../../c-api/synchronization.rst:132 msgid "Locks the mutex *m* and begins a critical section." msgstr "" -#: ../../c-api/synchronization.rst:138 +#: ../../c-api/synchronization.rst:134 ../../c-api/synchronization.rst:167 +msgid "In the free-threaded build, this macro expands to::" +msgstr "" + +#: ../../c-api/synchronization.rst:136 msgid "" "{\n" " PyCriticalSection _py_cs;\n" @@ -206,21 +203,21 @@ msgstr "" " PyCriticalSection _py_cs;\n" " PyCriticalSection_BeginMutex(&_py_cs, m)" -#: ../../c-api/synchronization.rst:142 +#: ../../c-api/synchronization.rst:140 msgid "" "Note that unlike :c:macro:`Py_BEGIN_CRITICAL_SECTION`, there is no cast for " "the argument of the macro - it must be a :c:type:`PyMutex` pointer." msgstr "" -#: ../../c-api/synchronization.rst:145 ../../c-api/synchronization.rst:191 +#: ../../c-api/synchronization.rst:143 ../../c-api/synchronization.rst:191 msgid "On the default build, this macro expands to ``{``." msgstr "" -#: ../../c-api/synchronization.rst:151 +#: ../../c-api/synchronization.rst:149 msgid "Ends the critical section and releases the per-object lock." msgstr "" -#: ../../c-api/synchronization.rst:155 +#: ../../c-api/synchronization.rst:154 msgid "" " PyCriticalSection_End(&_py_cs);\n" "}" @@ -228,18 +225,18 @@ msgstr "" " PyCriticalSection_End(&_py_cs);\n" "}" -#: ../../c-api/synchronization.rst:158 ../../c-api/synchronization.rst:204 +#: ../../c-api/synchronization.rst:157 ../../c-api/synchronization.rst:205 msgid "In the default build, this macro expands to ``}``." msgstr "" -#: ../../c-api/synchronization.rst:164 +#: ../../c-api/synchronization.rst:163 msgid "" "Acquires the per-object 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/synchronization.rst:170 +#: ../../c-api/synchronization.rst:169 msgid "" "{\n" " PyCriticalSection2 _py_cs2;\n" @@ -249,7 +246,7 @@ msgstr "" " PyCriticalSection2 _py_cs2;\n" " PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" -#: ../../c-api/synchronization.rst:180 +#: ../../c-api/synchronization.rst:179 msgid "Locks the mutexes *m1* and *m2* and begins a critical section." msgstr "" @@ -273,7 +270,7 @@ msgstr "" msgid "Ends the critical section and releases the per-object locks." msgstr "" -#: ../../c-api/synchronization.rst:201 +#: ../../c-api/synchronization.rst:202 msgid "" " PyCriticalSection2_End(&_py_cs2);\n" "}" @@ -282,61 +279,100 @@ msgstr "" "}" #: ../../c-api/synchronization.rst:210 -msgid "Legacy locking APIs" +msgid "Low-level critical section API" msgstr "" #: ../../c-api/synchronization.rst:212 msgid "" +"The following functions and structs are exposed for cases where C macros are " +"not available." +msgstr "" + +#: ../../c-api/synchronization.rst:220 ../../c-api/synchronization.rst:243 +msgid "" +"To be used only as in the macro expansions listed :ref:`earlier in this " +"section `." +msgstr "" + +#: ../../c-api/synchronization.rst:223 ../../c-api/synchronization.rst:246 +msgid "" +"In non-:term:`free-threaded ` builds of CPython, these " +"functions do nothing." +msgstr "" + +#: ../../c-api/synchronization.rst:231 +msgid "" +"To be used only as in the macro expansions listed :ref:`earlier in this " +"section `. Note that the contents of the structures " +"are private and their meaning may change in future Python versions." +msgstr "" + +#: ../../c-api/synchronization.rst:253 +msgid "Legacy locking APIs" +msgstr "" + +#: ../../c-api/synchronization.rst:255 +msgid "" "These APIs are obsolete since Python 3.13 with the introduction of :c:type:" "`PyMutex`." msgstr "" -#: ../../c-api/synchronization.rst:218 +#: ../../c-api/synchronization.rst:258 +msgid "These APIs are now a simple wrapper around ``PyMutex``." +msgstr "" + +#: ../../c-api/synchronization.rst:264 msgid "A pointer to a mutual exclusion lock." msgstr "" -#: ../../c-api/synchronization.rst:223 +#: ../../c-api/synchronization.rst:269 msgid "The result of acquiring a lock with a timeout." msgstr "" -#: ../../c-api/synchronization.rst:229 +#: ../../c-api/synchronization.rst:275 msgid "Failed to acquire the lock." msgstr "" -#: ../../c-api/synchronization.rst:233 +#: ../../c-api/synchronization.rst:279 msgid "The lock was successfully acquired." msgstr "" -#: ../../c-api/synchronization.rst:237 +#: ../../c-api/synchronization.rst:283 msgid "The lock was interrupted by a signal." msgstr "" -#: ../../c-api/synchronization.rst:242 +#: ../../c-api/synchronization.rst:288 msgid "Allocate a new lock." msgstr "" -#: ../../c-api/synchronization.rst:244 +#: ../../c-api/synchronization.rst:290 msgid "" "On success, this function returns a lock; on failure, this function returns " "``0`` without an exception set." msgstr "" -#: ../../c-api/synchronization.rst:247 ../../c-api/synchronization.rst:255 -#: ../../c-api/synchronization.rst:275 ../../c-api/synchronization.rst:293 -#: ../../c-api/synchronization.rst:301 +#: ../../c-api/synchronization.rst:293 ../../c-api/synchronization.rst:305 +#: ../../c-api/synchronization.rst:325 ../../c-api/synchronization.rst:343 +#: ../../c-api/synchronization.rst:351 msgid "The caller does not need to hold an :term:`attached thread state`." msgstr "呼叫者不需擁有一個 :term:`attached thread state`。" -#: ../../c-api/synchronization.rst:252 +#: ../../c-api/synchronization.rst:295 +msgid "" +"This function now always uses :c:type:`PyMutex`. In prior versions, this " +"would use a lock provided by the operating system." +msgstr "" + +#: ../../c-api/synchronization.rst:302 msgid "" "Destroy *lock*. The lock should not be held by any thread when calling this." msgstr "" -#: ../../c-api/synchronization.rst:260 +#: ../../c-api/synchronization.rst:310 msgid "Acquire *lock* with a timeout." msgstr "" -#: ../../c-api/synchronization.rst:262 +#: ../../c-api/synchronization.rst:312 msgid "" "This will wait for *microseconds* microseconds to acquire the lock. If the " "timeout expires, this function returns :c:enumerator:`PY_LOCK_FAILURE`. If " @@ -344,7 +380,7 @@ msgid "" "been released." msgstr "" -#: ../../c-api/synchronization.rst:267 +#: ../../c-api/synchronization.rst:317 msgid "" "If *intr_flag* is ``1``, acquiring the lock may be interrupted by a signal, " "in which case this function returns :c:enumerator:`PY_LOCK_INTR`. Upon " @@ -352,37 +388,37 @@ msgid "" "func:`Py_MakePendingCalls` to propagate an exception to Python code." msgstr "" -#: ../../c-api/synchronization.rst:272 +#: ../../c-api/synchronization.rst:322 msgid "" "If the lock is successfully acquired, this function returns :c:enumerator:" "`PY_LOCK_ACQUIRED`." msgstr "" -#: ../../c-api/synchronization.rst:280 +#: ../../c-api/synchronization.rst:330 msgid "Acquire *lock*." msgstr "" -#: ../../c-api/synchronization.rst:282 +#: ../../c-api/synchronization.rst:332 msgid "" "If *waitflag* is ``1`` and another thread currently holds the lock, this " "function will wait until the lock can be acquired and will always return " "``1``." msgstr "" -#: ../../c-api/synchronization.rst:286 +#: ../../c-api/synchronization.rst:336 msgid "" "If *waitflag* is ``0`` and another thread holds the lock, this function will " "not wait and instead return ``0``. If the lock is not held by any other " "thread, then this function will acquire it and return ``1``." msgstr "" -#: ../../c-api/synchronization.rst:290 +#: ../../c-api/synchronization.rst:340 msgid "" "Unlike :c:func:`PyThread_acquire_lock_timed`, acquiring the lock cannot be " "interrupted by a signal." msgstr "" -#: ../../c-api/synchronization.rst:298 +#: ../../c-api/synchronization.rst:348 msgid "" "Release *lock*. If *lock* is not held, then this function issues a fatal " "error." diff --git a/c-api/sys.po b/c-api/sys.po index 40e4b155f5a..28cf3b6cac4 100644 --- a/c-api/sys.po +++ b/c-api/sys.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-14 19:37+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -332,34 +332,85 @@ msgstr "" #: ../../c-api/sys.rst:281 msgid "" -"Return the object *name* from the :mod:`sys` module or ``NULL`` if it does " -"not exist, without setting an exception." +"Get the attribute *name* of the :mod:`sys` module. Return a :term:`strong " +"reference`. Raise :exc:`RuntimeError` and return ``NULL`` if it does not " +"exist or if the :mod:`sys` module cannot be found." msgstr "" #: ../../c-api/sys.rst:286 msgid "" -"Set *name* in the :mod:`sys` module to *v* unless *v* is ``NULL``, in which " -"case *name* is deleted from the sys module. Returns ``0`` on success, ``-1`` " -"on error." +"If the non-existing object should not be treated as a failure, you can use :" +"c:func:`PySys_GetOptionalAttr` instead." +msgstr "" + +#: ../../c-api/sys.rst:293 +msgid "" +"This is the same as :c:func:`PySys_GetAttr`, but *name* is specified as a :c:" +"expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" +"`PyObject*`." +msgstr "" + +#: ../../c-api/sys.rst:297 +msgid "" +"If the non-existing object should not be treated as a failure, you can use :" +"c:func:`PySys_GetOptionalAttrString` instead." +msgstr "" + +#: ../../c-api/sys.rst:304 +msgid "" +"Variant of :c:func:`PySys_GetAttr` which doesn't raise exception if the " +"object does not exist." +msgstr "" + +#: ../../c-api/sys.rst:307 +msgid "" +"Set *\\*result* to a new :term:`strong reference` to the object and return " +"``1`` if the object exists." +msgstr "" + +#: ../../c-api/sys.rst:309 +msgid "" +"Set *\\*result* to ``NULL`` and return ``0`` without setting an exception if " +"the object does not exist." +msgstr "" + +#: ../../c-api/sys.rst:311 +msgid "" +"Set an exception, set *\\*result* to ``NULL``, and return ``-1``, if an " +"error occurred." +msgstr "" + +#: ../../c-api/sys.rst:318 +msgid "" +"This is the same as :c:func:`PySys_GetOptionalAttr`, but *name* is specified " +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" +"`PyObject*`." msgstr "" -#: ../../c-api/sys.rst:292 +#: ../../c-api/sys.rst:326 msgid "" -"Reset :data:`sys.warnoptions` to an empty list. This function may be called " -"prior to :c:func:`Py_Initialize`." +"Similar to :c:func:`PySys_GetAttrString`, but return a :term:`borrowed " +"reference` and return ``NULL`` *without* setting exception on failure." msgstr "" -#: ../../c-api/sys.rst:295 -msgid "Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead." +#: ../../c-api/sys.rst:329 +msgid "Preserves exception that was set before the call." +msgstr "" + +#: ../../c-api/sys.rst:333 +msgid "" +"Set *name* in the :mod:`sys` module to *v* unless *v* is ``NULL``, in which " +"case *name* is deleted from the sys module. Returns ``0`` on success, ``-1`` " +"on error." msgstr "" -#: ../../c-api/sys.rst:300 +#: ../../c-api/sys.rst:339 msgid "" "Write the output string described by *format* to :data:`sys.stdout`. No " "exceptions are raised, even if truncation occurs (see below)." msgstr "" -#: ../../c-api/sys.rst:303 +#: ../../c-api/sys.rst:342 msgid "" "*format* should limit the total size of the formatted output string to 1000 " "bytes or less -- after 1000 bytes, the output string is truncated. In " @@ -370,48 +421,48 @@ msgid "" "of digits for very large numbers." msgstr "" -#: ../../c-api/sys.rst:311 +#: ../../c-api/sys.rst:350 msgid "" "If a problem occurs, or :data:`sys.stdout` is unset, the formatted message " "is written to the real (C level) *stdout*." msgstr "" -#: ../../c-api/sys.rst:316 +#: ../../c-api/sys.rst:355 msgid "" "As :c:func:`PySys_WriteStdout`, but write to :data:`sys.stderr` or *stderr* " "instead." msgstr "" -#: ../../c-api/sys.rst:321 +#: ../../c-api/sys.rst:360 msgid "" "Function similar to PySys_WriteStdout() but format the message using :c:func:" "`PyUnicode_FromFormatV` and don't truncate the message to an arbitrary " "length." msgstr "" -#: ../../c-api/sys.rst:329 +#: ../../c-api/sys.rst:368 msgid "" "As :c:func:`PySys_FormatStdout`, but write to :data:`sys.stderr` or *stderr* " "instead." msgstr "" -#: ../../c-api/sys.rst:336 +#: ../../c-api/sys.rst:375 msgid "" "Return the current dictionary of :option:`-X` options, similarly to :data:" "`sys._xoptions`. On error, ``NULL`` is returned and an exception is set." msgstr "" -#: ../../c-api/sys.rst:345 +#: ../../c-api/sys.rst:384 msgid "" "Raise an auditing event with any active hooks. Return zero for success and " "non-zero with an exception set on failure." msgstr "" -#: ../../c-api/sys.rst:348 +#: ../../c-api/sys.rst:387 msgid "The *event* string argument must not be *NULL*." msgstr "" -#: ../../c-api/sys.rst:350 +#: ../../c-api/sys.rst:389 msgid "" "If any hooks have been added, *format* and other arguments will be used to " "construct a tuple to pass. Apart from ``N``, the same format characters as " @@ -419,40 +470,40 @@ msgid "" "tuple, it will be added into a single-element tuple." msgstr "" -#: ../../c-api/sys.rst:355 +#: ../../c-api/sys.rst:394 msgid "" "The ``N`` format option must not be used. It consumes a reference, but since " "there is no way to know whether arguments to this function will be consumed, " "using it may cause reference leaks." msgstr "" -#: ../../c-api/sys.rst:359 +#: ../../c-api/sys.rst:398 msgid "" "Note that ``#`` format characters should always be treated as :c:type:" "`Py_ssize_t`, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined." msgstr "" -#: ../../c-api/sys.rst:362 +#: ../../c-api/sys.rst:401 msgid ":func:`sys.audit` performs the same function from Python code." msgstr "" -#: ../../c-api/sys.rst:364 +#: ../../c-api/sys.rst:403 msgid "See also :c:func:`PySys_AuditTuple`." msgstr "請參閱 :c:func:`PySys_AuditTuple`。" -#: ../../c-api/sys.rst:370 +#: ../../c-api/sys.rst:409 msgid "" "Require :c:type:`Py_ssize_t` for ``#`` format characters. Previously, an " "unavoidable deprecation warning was raised." msgstr "" -#: ../../c-api/sys.rst:376 +#: ../../c-api/sys.rst:415 msgid "" "Similar to :c:func:`PySys_Audit`, but pass arguments as a Python object. " "*args* must be a :class:`tuple`. To pass no arguments, *args* can be *NULL*." msgstr "" -#: ../../c-api/sys.rst:384 +#: ../../c-api/sys.rst:423 msgid "" "Append the callable *hook* to the list of active auditing hooks. Return zero " "on success and non-zero on failure. If the runtime has been initialized, " @@ -460,14 +511,14 @@ msgid "" "all interpreters created by the runtime." msgstr "" -#: ../../c-api/sys.rst:390 +#: ../../c-api/sys.rst:429 msgid "" "The *userData* pointer is passed into the hook function. Since hook " "functions may be called from different runtimes, this pointer should not " "refer directly to Python state." msgstr "" -#: ../../c-api/sys.rst:394 +#: ../../c-api/sys.rst:433 msgid "" "This function is safe to call before :c:func:`Py_Initialize`. When called " "after runtime initialization, existing audit hooks are notified and may " @@ -475,20 +526,20 @@ msgid "" "`Exception` (other errors will not be silenced)." msgstr "" -#: ../../c-api/sys.rst:399 +#: ../../c-api/sys.rst:438 msgid "" "The hook function is always called with an :term:`attached thread state` by " "the Python interpreter that raised the event." msgstr "" -#: ../../c-api/sys.rst:402 +#: ../../c-api/sys.rst:441 msgid "" "See :pep:`578` for a detailed description of auditing. Functions in the " "runtime and standard library that raise events are listed in the :ref:`audit " "events table `. Details are in each function's documentation." msgstr "" -#: ../../c-api/sys.rst:407 ../../c-api/sys.rst:409 +#: ../../c-api/sys.rst:446 ../../c-api/sys.rst:448 msgid "" "If the interpreter is initialized, this function raises an auditing event " "``sys.addaudithook`` with no arguments. If any existing hooks raise an " @@ -497,7 +548,7 @@ msgid "" "hook has been added unless they control all existing hooks." msgstr "" -#: ../../c-api/sys.rst:418 +#: ../../c-api/sys.rst:457 msgid "" "The type of the hook function. *event* is the C string event argument passed " "to :c:func:`PySys_Audit` or :c:func:`PySys_AuditTuple`. *args* is guaranteed " @@ -505,11 +556,11 @@ msgid "" "PySys_AddAuditHook()." msgstr "" -#: ../../c-api/sys.rst:430 +#: ../../c-api/sys.rst:469 msgid "Process Control" msgstr "行程控制" -#: ../../c-api/sys.rst:437 +#: ../../c-api/sys.rst:476 msgid "" "Print a fatal error message and kill the process. No cleanup is performed. " "This function should only be invoked when a condition is detected that would " @@ -519,29 +570,29 @@ msgid "" "file:`core` file." msgstr "" -#: ../../c-api/sys.rst:444 +#: ../../c-api/sys.rst:483 msgid "" "The ``Py_FatalError()`` function is replaced with a macro which logs " "automatically the name of the current function, unless the " "``Py_LIMITED_API`` macro is defined." msgstr "" -#: ../../c-api/sys.rst:448 +#: ../../c-api/sys.rst:487 msgid "Log the function name automatically." msgstr "" -#: ../../c-api/sys.rst:458 +#: ../../c-api/sys.rst:497 msgid "" "Exit the current process. This calls :c:func:`Py_FinalizeEx` and then calls " "the standard C library function ``exit(status)``. If :c:func:" "`Py_FinalizeEx` indicates an error, the exit status is set to 120." msgstr "" -#: ../../c-api/sys.rst:462 +#: ../../c-api/sys.rst:501 msgid "Errors from finalization no longer ignored." msgstr "" -#: ../../c-api/sys.rst:472 +#: ../../c-api/sys.rst:511 msgid "" "Register a cleanup function to be called by :c:func:`Py_FinalizeEx`. The " "cleanup function will be called with no arguments and should return no " @@ -553,7 +604,7 @@ msgid "" "should be called by *func*." msgstr "" -#: ../../c-api/sys.rst:482 +#: ../../c-api/sys.rst:521 msgid ":c:func:`PyUnstable_AtExit` for passing a ``void *data`` argument." msgstr "" @@ -561,18 +612,18 @@ msgstr "" msgid "USE_STACKCHECK (C macro)" msgstr "USE_STACKCHECK(C 巨集)" -#: ../../c-api/sys.rst:435 +#: ../../c-api/sys.rst:474 msgid "abort (C function)" msgstr "abort(C 函式)" -#: ../../c-api/sys.rst:454 ../../c-api/sys.rst:468 +#: ../../c-api/sys.rst:493 ../../c-api/sys.rst:507 msgid "Py_FinalizeEx (C function)" msgstr "Py_FinalizeEx(C 函式)" -#: ../../c-api/sys.rst:454 +#: ../../c-api/sys.rst:493 msgid "exit (C function)" msgstr "exit(C 函式)" -#: ../../c-api/sys.rst:468 +#: ../../c-api/sys.rst:507 msgid "cleanup functions" msgstr "cleanup functions(清理函式)" diff --git a/c-api/threads.po b/c-api/threads.po index 13f8ab939f7..489b1306675 100644 --- a/c-api/threads.po +++ b/c-api/threads.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-02 00:39+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -92,9 +92,9 @@ msgstr "" #: ../../c-api/threads.rst:64 msgid "" -"If it turns out that you do need to create a thread state, call :c:func:" -"`PyThreadState_New` followed by :c:func:`PyThreadState_Swap`, or use the " -"dangerous :c:func:`PyGILState_Ensure` function." +"If it turns out that you do need to create a thread state, it is recommended " +"to use :c:func:`PyThreadState_Ensure` or :c:func:" +"`PyThreadState_EnsureFromView`, which will manage the thread state for you." msgstr "" #: ../../c-api/threads.rst:72 @@ -236,11 +236,11 @@ msgid "" "declaration." msgstr "" -#: ../../c-api/threads.rst:182 -msgid "Non-Python created threads" +#: ../../c-api/threads.rst:186 +msgid "Using the C API from foreign threads" msgstr "" -#: ../../c-api/threads.rst:184 +#: ../../c-api/threads.rst:188 msgid "" "When threads are created using the dedicated Python APIs (such as the :mod:" "`threading` module), a thread state is automatically associated with them, " @@ -249,7 +249,7 @@ msgid "" "thread state." msgstr "" -#: ../../c-api/threads.rst:190 +#: ../../c-api/threads.rst:194 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 " @@ -257,284 +257,339 @@ msgid "" "thread state and attaching it." msgstr "" -#: ../../c-api/threads.rst:195 +#: ../../c-api/threads.rst:199 msgid "" -"The most robust way to do this is through :c:func:`PyThreadState_New` " -"followed by :c:func:`PyThreadState_Swap`." +"The easiest way to do this is through :c:func:`PyThreadState_Ensure` or :c:" +"func:`PyThreadState_EnsureFromView`." msgstr "" -#: ../../c-api/threads.rst:199 +#: ../../c-api/threads.rst:203 msgid "" -"``PyThreadState_New`` requires an argument pointing to the desired " -"interpreter; such a pointer can be acquired via a call to :c:func:" -"`PyInterpreterState_Get` from the code where the thread was created." +"These functions require an argument pointing to the desired interpreter; " +"such a pointer can be acquired via a call to :c:func:" +"`PyInterpreterGuard_FromCurrent` (for ``PyThreadState_Ensure``) or :c:func:" +"`PyInterpreterView_FromCurrent` (for ``PyThreadState_EnsureFromView``) from " +"the function that creates the thread. If no pointer is available (such as " +"when the given native thread library doesn't provide a data argument), :c:" +"func:`PyInterpreterView_FromMain` can be used to get a view for the main " +"interpreter, but note that this will make the code incompatible with " +"subinterpreters." msgstr "" -#: ../../c-api/threads.rst:204 +#: ../../c-api/threads.rst:214 msgid "For example::" msgstr "" -#: ../../c-api/threads.rst:206 +#: ../../c-api/threads.rst:216 msgid "" -"/* The return value of PyInterpreterState_Get() from the\n" -" function that created this thread. */\n" -"PyInterpreterState *interp = thread_data->interp;\n" +"// The return value of PyInterpreterGuard_FromCurrent() from the\n" +"// function that created this thread.\n" +"PyInterpreterGuard *guard = thread_data->guard;\n" +"\n" +"// Create a new thread state for the interpreter.\n" +"PyThreadStateToken *token = PyThreadState_Ensure(guard);\n" +"if (token == NULL) {\n" +" PyInterpreterGuard_Close(guard);\n" +" return;\n" +"}\n" +"\n" +"// We have a valid thread state -- perform Python actions here.\n" +"result = CallSomeFunction();\n" +"// Evaluate result or handle exceptions.\n" "\n" -"/* Create a new thread state for the interpreter. It does not start out\n" -" attached. */\n" -"PyThreadState *tstate = PyThreadState_New(interp);\n" +"// Release the thread state. No calls to the C API are allowed beyond this\n" +"// point.\n" +"PyThreadState_Release(token);\n" +"PyInterpreterGuard_Close(guard);" +msgstr "" +"// 建立此執行緒的函式中\n" +"// PyInterpreterGuard_FromCurrent() 的回傳值。\n" +"PyInterpreterGuard *guard = thread_data->guard;\n" "\n" -"/* Attach the thread state, which will acquire the GIL. */\n" -"PyThreadState_Swap(tstate);\n" +"// 為直譯器建立新的執行緒狀態。\n" +"PyThreadStateToken *token = PyThreadState_Ensure(guard);\n" +"if (token == NULL) {\n" +" PyInterpreterGuard_Close(guard);\n" +" return;\n" +"}\n" "\n" -"/* Perform Python actions here. */\n" +"// 我們有一個有效的執行緒狀態 —— 在此執行 Python 操作。\n" "result = CallSomeFunction();\n" -"/* evaluate result or handle exception */\n" +"// 評估結果或處理例外。\n" "\n" -"/* Destroy the thread state. No Python API allowed beyond this point. */\n" -"PyThreadState_Clear(tstate);\n" -"PyThreadState_DeleteCurrent();" -msgstr "" +"// 釋放執行緒狀態。在此之後\n" +"// 不允許呼叫任何 C API。\n" +"PyThreadState_Release(token);\n" +"PyInterpreterGuard_Close(guard);" -#: ../../c-api/threads.rst:227 +#: ../../c-api/threads.rst:237 msgid "" -"If the interpreter finalized before ``PyThreadState_Swap`` was called, then " -"``interp`` will be a dangling pointer!" +"Keep in mind that calling ``PyThreadState_Ensure`` might not always create a " +"new thread state, and calling ``PyThreadState_Release`` might not always " +"detach it. These functions may reuse an existing attached thread state, or " +"may re-attach a thread state that was previously attached for the current " +"thread." msgstr "" -#: ../../c-api/threads.rst:233 -msgid "Legacy API" +#: ../../c-api/threads.rst:243 +msgid ":pep:`788`" +msgstr ":pep:`788`" + +#: ../../c-api/threads.rst:248 +msgid "Reusing a thread state across repeated calls" msgstr "" -#: ../../c-api/threads.rst:235 +#: ../../c-api/threads.rst:250 msgid "" -"Another common pattern to call Python code from a non-Python thread is to " -"use :c:func:`PyGILState_Ensure` followed by a call to :c:func:" -"`PyGILState_Release`." +"Creating and destroying a :c:type:`PyThreadState` is not free, and is more " +"expensive on a :term:`free-threaded build`. A foreign thread that calls " +"into the interpreter many times -- for example, a worker thread in a native " +"thread pool -- should avoid creating a fresh thread state on every entry and " +"destroying it on every exit. Instead, set up one thread state when the " +"thread starts (or lazily on its first call into Python), attach and detach " +"it around each call, and tear it down once when the thread exits." msgstr "" -#: ../../c-api/threads.rst:238 +#: ../../c-api/threads.rst:258 msgid "" -"These functions do not work well when multiple interpreters exist in the " -"Python process. If no Python interpreter has ever been used in the current " -"thread (which is common for threads created outside Python), " -"``PyGILState_Ensure`` will create and attach a thread state for the \"main\" " -"interpreter (the first interpreter in the Python process)." +"Manage the thread state explicitly with :c:func:`PyThreadState_New`, " +"attaching and detaching it with :c:func:`PyEval_RestoreThread` and :c:func:" +"`PyEval_SaveThread`. This happens in three distinct phases, at different " +"points in the thread's life." msgstr "" -#: ../../c-api/threads.rst:244 +#: ../../c-api/threads.rst:263 msgid "" -"Additionally, these functions have thread-safety issues during interpreter " -"finalization. Using ``PyGILState_Ensure`` during finalization will likely " -"crash the process." +"When the thread starts, create one thread state for it. ``interp`` is the " +"target interpreter, captured by the code that created this thread while it " +"held an attached thread state (for example via :c:func:" +"`PyInterpreterState_Get`)::" msgstr "" -#: ../../c-api/threads.rst:248 -msgid "Usage of these functions look like such::" +#: ../../c-api/threads.rst:267 +msgid "PyThreadState *tstate = PyThreadState_New(interp);" +msgstr "PyThreadState *tstate = PyThreadState_New(interp);" + +#: ../../c-api/threads.rst:269 +msgid "" +"Then, on each call into Python -- which may happen many times over the " +"thread's life -- attach the thread state, make the Python C API calls that " +"require it, and detach again so the thread does not hold the GIL while off " +"doing non-Python work::" msgstr "" -#: ../../c-api/threads.rst:250 +#: ../../c-api/threads.rst:274 msgid "" -"PyGILState_STATE gstate;\n" -"gstate = PyGILState_Ensure();\n" -"\n" -"/* Perform Python actions here. */\n" -"result = CallSomeFunction();\n" -"/* evaluate result or handle exception */\n" -"\n" -"/* Release the thread. No Python API allowed beyond this point. */\n" -"PyGILState_Release(gstate);" +"PyEval_RestoreThread(tstate);\n" +"result = CallSomeFunction(); /* your Python C API calls go here */\n" +"PyEval_SaveThread();" msgstr "" +"PyEval_RestoreThread(tstate);\n" +"result = CallSomeFunction(); /* 你的 Python C API 呼叫放在這裡 */\n" +"PyEval_SaveThread();" -#: ../../c-api/threads.rst:264 -msgid "Cautions about fork()" +#: ../../c-api/threads.rst:278 +msgid "" +"When the thread is finished calling into Python, destroy the thread state " +"once::" msgstr "" -#: ../../c-api/threads.rst:266 +#: ../../c-api/threads.rst:280 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 " -"process forks only the thread that issued the fork will exist. This has a " -"concrete impact both on how locks must be handled and on all stored state in " -"CPython's runtime." +"PyEval_RestoreThread(tstate);\n" +"PyThreadState_Clear(tstate);\n" +"PyThreadState_DeleteCurrent();" msgstr "" +"PyEval_RestoreThread(tstate);\n" +"PyThreadState_Clear(tstate);\n" +"PyThreadState_DeleteCurrent();" -#: ../../c-api/threads.rst:272 +#: ../../c-api/threads.rst:284 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` " -"by acquiring the locks it uses internally before the fork, and releasing " -"them afterwards. In addition, it resets any :ref:`lock-objects` in the " -"child. When extending or embedding Python, there is no way to inform Python " -"of additional (non-Python) locks that need to be acquired before or reset " -"after a fork. OS facilities such as :c:func:`!pthread_atfork` would need to " -"be used to accomplish the same thing. Additionally, when extending or " -"embedding Python, calling :c:func:`fork` directly rather than through :func:" -"`os.fork` (and returning to or calling into Python) may result in a deadlock " -"by one of Python's internal locks being held by a thread that is defunct " -"after the fork. :c:func:`PyOS_AfterFork_Child` tries to reset the necessary " -"locks, but is not always able to." +"The general-purpose entry points for calling in from a foreign thread -- :c:" +"func:`PyThreadState_Ensure` and the older :c:func:`PyGILState_Ensure` -- do " +"*not* guarantee a persistent thread state: their thread-state lifetime is " +"deliberately implementation-defined, so a matched acquire/release pair may " +"create and destroy a thread state each time. Use :c:func:" +"`PyThreadState_New`, as shown here, whenever you specifically want to reuse " +"one thread state across calls." msgstr "" -#: ../../c-api/threads.rst:287 +#: ../../c-api/threads.rst:292 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 " -"means finalizing all other :c:type:`PyThreadState` objects belonging to the " -"current interpreter and all other :c:type:`PyInterpreterState` objects. Due " -"to this and the special nature of the :ref:`\"main\" interpreter `, :c:func:`fork` should only be called in that " -"interpreter's \"main\" thread, where the CPython global runtime was " -"originally initialized. The only exception is if :c:func:`exec` will be " -"called immediately after." +"The code that created the foreign thread must arrange for the shutdown " +"sequence to run before the thread exits, and before :c:func:`Py_FinalizeEx` " +"is called. If interpreter finalization begins first, the shutdown :c:func:" +"`PyEval_RestoreThread` call will hang the thread rather than return (see :" +"ref:`cautions-regarding-runtime-finalization`). If the thread exits without " +"running the shutdown sequence, the thread state is leaked for the remainder " +"of the process." msgstr "" -#: ../../c-api/threads.rst:300 -msgid "High-level APIs" +#: ../../c-api/threads.rst:303 +msgid "Attaching/detaching thread states" msgstr "" -#: ../../c-api/threads.rst:302 +#: ../../c-api/threads.rst:307 msgid "" -"These are the most commonly used types and functions when writing multi-" -"threaded C extensions." +"Ensure that the thread has an attached thread state for the interpreter " +"protected by *guard*, and thus can safely invoke that interpreter." msgstr "" -#: ../../c-api/threads.rst:308 +#: ../../c-api/threads.rst:311 msgid "" -"This data structure represents the state of a single thread. The only " -"public data member is:" +"It is OK to call this function if the thread already has an attached thread " +"state, as long as there is a subsequent call to :c:func:" +"`PyThreadState_Release` that matches this one (meaning that \"nested\" calls " +"to this function are permitted)." msgstr "" -#: ../../c-api/threads.rst:313 -msgid "This thread's interpreter state." -msgstr "這個執行緒的直譯器狀態。" +#: ../../c-api/threads.rst:316 +msgid "" +"The function's effect (if any) will be reversed by the matching call to :c:" +"func:`PyThreadState_Release`." +msgstr "" -#: ../../c-api/threads.rst:324 -msgid "Deprecated function which does nothing." -msgstr "已棄用的函式,什麼也不做。" +#: ../../c-api/threads.rst:319 +msgid "" +"On error, this function returns ``NULL`` *without* an exception set. Do not " +"call :c:func:`!PyThreadState_Release` in this case." +msgstr "" -#: ../../c-api/threads.rst:326 +#: ../../c-api/threads.rst:322 msgid "" -"In Python 3.6 and older, this function created the GIL if it didn't exist." +"On success, this function returns a pointer value that must be passed to the " +"matching call to :c:func:`!PyThreadState_Release`." msgstr "" -#: ../../c-api/threads.rst:328 -msgid "The function now does nothing." -msgstr "此函式現在不會做任何事情。" +#: ../../c-api/threads.rst:325 +msgid "" +"The conditions in which this function creates a new :term:`thread state` are " +"considered unstable and implementation-dependent. If you need to control the " +"exact lifetime of a thread state, consider using :c:func:" +"`PyThreadState_New`. However, do not avoid this function solely on the basis " +"that the lifetime of the thread state may be inconsistent across versions; " +"changes to this function will be done with caution and in a backwards-" +"compatible manner. In particular, the saving of thread-local variables and " +"similar state will be retained across Python versions." +msgstr "" -#: ../../c-api/threads.rst:331 +#: ../../c-api/threads.rst:336 msgid "" -"This function is now called by :c:func:`Py_Initialize()`, so you don't have " -"to call it yourself anymore." +"The exact behavior of whether this function creates a new thread state is " +"described below, but be aware that this may change in the future." msgstr "" -#: ../../c-api/threads.rst:335 +#: ../../c-api/threads.rst:339 msgid "" -"This function cannot be called before :c:func:`Py_Initialize()` anymore." +"First, this function checks if an attached thread state is present. If there " +"is, this function then checks if the interpreter of that thread state " +"matches the interpreter guarded by *guard*. If that is the case, this " +"function simply marks the thread state as being used by a " +"``PyThreadState_Ensure`` call and returns." msgstr "" #: ../../c-api/threads.rst:345 msgid "" -"Detach the :term:`attached thread state` and return it. The thread will have " -"no :term:`thread state` upon returning." +"If there is no attached thread state, then this function checks if any " +"thread state has been used by the current OS thread. (This is returned by :c:" +"func:`PyGILState_GetThisThreadState`.) If there was, then this function " +"checks if that thread state's interpreter matches *guard*. If it does, it is " +"re-attached and marked as used." msgstr "" #: ../../c-api/threads.rst:351 msgid "" -"Set the :term:`attached thread state` to *tstate*. The passed :term:`thread " -"state` **should not** be :term:`attached `, otherwise " -"deadlock ensues. *tstate* will be attached upon returning." +"Otherwise, if both of the above cases fail, a new thread state is created " +"for *guard*. It is then attached and marked as owned by " +"``PyThreadState_Ensure``." msgstr "" -#: ../../c-api/threads.rst:356 ../../c-api/threads.rst:640 -msgid "" -"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." +#: ../../c-api/threads.rst:359 +msgid "Get an attached thread state for the interpreter referenced by *view*." msgstr "" -#: ../../c-api/threads.rst:361 ../../c-api/threads.rst:448 -#: ../../c-api/threads.rst:650 +#: ../../c-api/threads.rst:361 msgid "" -"Hangs the current thread, rather than terminating it, if called while the " -"interpreter is finalizing." +"The behavior and return value are the same as for :c:func:" +"`PyThreadState_Ensure`; additionally, if the function succeeds, the " +"interpreter referenced by *view* will be implicitly guarded. The guard will " +"be released upon the corresponding :c:func:`PyThreadState_Release` call." msgstr "" -#: ../../c-api/threads.rst:367 +#: ../../c-api/threads.rst:371 msgid "" -"Return the :term:`attached thread state`. If the thread has no attached " -"thread state, (such as when inside of :c:macro:`Py_BEGIN_ALLOW_THREADS` " -"block), then this issues a fatal error (so that the caller needn't check for " -"``NULL``)." +"Undo a :c:func:`PyThreadState_Ensure` or :c:func:" +"`PyThreadState_EnsureFromView` call." msgstr "" -#: ../../c-api/threads.rst:372 -msgid "See also :c:func:`PyThreadState_GetUnchecked`." -msgstr "也請見 :c:func:`PyThreadState_GetUnchecked`。" +#: ../../c-api/threads.rst:374 +msgid "" +"This must be called exactly once for each successful *Ensure* call, with " +"*token* set to that call's return value." +msgstr "" -#: ../../c-api/threads.rst:376 +#: ../../c-api/threads.rst:377 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." +"The state that was attached before the corresponding *Ensure* call (if any) " +"will be attached when :c:func:`PyThreadState_Release` returns." msgstr "" #: ../../c-api/threads.rst:380 msgid "" -"In Python 3.5 to 3.12, the function was private and known as " -"``_PyThreadState_UncheckedGet()``." +"The exact behavior of whether this function deletes a thread state is " +"considered unstable and implementation-dependent." msgstr "" -"在 Python 3.5 到 3.12 中,此函式是私有的,被稱為 " -"``_PyThreadState_UncheckedGet()``。" -#: ../../c-api/threads.rst:387 +#: ../../c-api/threads.rst:385 msgid "" -"Set the :term:`attached thread state` to *tstate*, and return the :term:" -"`thread state` that was attached prior to calling." +"Currently, this function will decrement an internal counter on the attached " +"thread state. If this counter ever reaches below zero, this function emits a " +"fatal error (via :c:func:`Py_FatalError`)." msgstr "" -#: ../../c-api/threads.rst:390 +#: ../../c-api/threads.rst:389 msgid "" -"This function is safe to call without an :term:`attached thread state`; it " -"will simply return ``NULL`` indicating that there was no prior thread state." +"If the attached thread state is owned by ``PyThreadState_Ensure``, then the " +"attached thread state will be deallocated and deleted upon the internal " +"counter reaching zero. Otherwise, nothing happens when the counter reaches " +"zero." msgstr "" -#: ../../c-api/threads.rst:394 -msgid ":c:func:`PyEval_ReleaseThread`" -msgstr ":c:func:`PyEval_ReleaseThread`" - #: ../../c-api/threads.rst:397 msgid "" -"Similar to :c:func:`PyGILState_Ensure`, this function will hang the thread " -"if the runtime is finalizing." +"An opaque token retrieved from a :c:func:`PyThreadState_Ensure` call and " +"passed to a corresponding :c:func:`PyThreadState_Release` call." msgstr "" -#: ../../c-api/threads.rst:402 +#: ../../c-api/threads.rst:405 msgid "GIL-state APIs" msgstr "GIL 狀態 API" -#: ../../c-api/threads.rst:404 +#: ../../c-api/threads.rst:407 msgid "" -"The following functions use thread-local storage, and are not compatible " -"with sub-interpreters:" +"The following APIs are generally not compatible with subinterpreters and " +"will hang the process during interpreter finalization (see :ref:`cautions-" +"regarding-runtime-finalization`). As such, these APIs were :term:`soft " +"deprecated` in Python 3.15 in favor of the :ref:`new APIs `." msgstr "" -#: ../../c-api/threads.rst:409 +#: ../../c-api/threads.rst:416 msgid "" "The type of the value returned by :c:func:`PyGILState_Ensure` and passed to :" "c:func:`PyGILState_Release`." msgstr "" -#: ../../c-api/threads.rst:414 +#: ../../c-api/threads.rst:421 msgid "The GIL was already held when :c:func:`PyGILState_Ensure` was called." msgstr "" -#: ../../c-api/threads.rst:418 +#: ../../c-api/threads.rst:425 msgid "The GIL was not held when :c:func:`PyGILState_Ensure` was called." msgstr "" -#: ../../c-api/threads.rst:422 +#: ../../c-api/threads.rst:430 msgid "" "Ensure that the current thread is ready to call the Python C API regardless " "of the current state of Python, or of the :term:`attached thread state`. " @@ -547,7 +602,7 @@ msgid "" "is acceptable." msgstr "" -#: ../../c-api/threads.rst:432 +#: ../../c-api/threads.rst:440 msgid "" "The return value is an opaque \"handle\" to the :term:`attached thread " "state` when :c:func:`PyGILState_Ensure` was called, and must be passed to :c:" @@ -557,180 +612,381 @@ msgid "" "to :c:func:`PyGILState_Release`." msgstr "" -#: ../../c-api/threads.rst:439 +#: ../../c-api/threads.rst:447 msgid "" "When the function returns, there will be an :term:`attached thread state` " -"and the thread will be able to call arbitrary Python code. Failure is a " -"fatal error." +"and the thread will be able to call arbitrary Python code." msgstr "" -#: ../../c-api/threads.rst:443 +#: ../../c-api/threads.rst:450 msgid "" -"Calling this function when the runtime is finalizing is unsafe. Doing so " -"will either hang the thread until the program ends, or fully crash the " -"interpreter in rare cases. Refer to :ref:`cautions-regarding-runtime-" +"This function has no way to return an error. As such, errors are either " +"fatal (that is, they send ``SIGABRT`` and crash the process; see :c:func:" +"`Py_FatalError`), or the thread will be permanently blocked (such as during " +"interpreter finalization)." +msgstr "" + +#: ../../c-api/threads.rst:456 +msgid "" +"Calling this function when the interpreter is finalizing will infinitely " +"hang the thread, which may cause deadlocks. :ref:`cautions-regarding-runtime-" "finalization` for more details." msgstr "" -#: ../../c-api/threads.rst:454 +#: ../../c-api/threads.rst:460 +msgid "" +"In addition, this function generally does not work with subinterpreters when " +"used from foreign threads, because this function has no way of knowing which " +"interpreter created the thread (and as such, will implicitly pick the main " +"interpreter)." +msgstr "" + +#: ../../c-api/threads.rst:465 ../../c-api/threads.rst:625 +#: ../../c-api/threads.rst:819 +msgid "" +"Hangs the current thread, rather than terminating it, if called while the " +"interpreter is finalizing." +msgstr "" + +#: ../../c-api/threads.rst:469 +msgid "" +"Use :c:func:`PyThreadState_Ensure` or :c:func:`PyThreadState_EnsureFromView` " +"instead." +msgstr "" + +#: ../../c-api/threads.rst:476 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:" "`PyGILState_Ensure` call (but generally this state will be unknown to the " -"caller, hence the use of the GILState API)." +"caller, hence the use of the GIL-state API)." msgstr "" -#: ../../c-api/threads.rst:459 +#: ../../c-api/threads.rst:481 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/threads.rst:464 +#: ../../c-api/threads.rst:484 +msgid "Use :c:func:`PyThreadState_Release` instead." +msgstr "請改用 :c:func:`PyThreadState_Release`。" + +#: ../../c-api/threads.rst:490 msgid "" -"Get the :term:`attached thread state` for this thread. May return ``NULL`` " -"if no GILState API has been used on the current thread. Note that the main " -"thread always has such a thread-state, even if no auto-thread-state call has " -"been made on the main thread. This is mainly a helper/diagnostic function." +"Get the :term:`thread state` that was most recently :term:`attached " +"` for this thread. (If the most recent thread state " +"has been deleted, this returns ``NULL``.)" msgstr "" -#: ../../c-api/threads.rst:470 +#: ../../c-api/threads.rst:494 +msgid "If the caller has an attached thread state, it is returned." +msgstr "如果呼叫者擁有一個 attached thread state,則回傳該狀態。" + +#: ../../c-api/threads.rst:496 msgid "" -"This function may return non-``NULL`` even when the :term:`thread state` is " -"detached. Prefer :c:func:`PyThreadState_Get` or :c:func:" -"`PyThreadState_GetUnchecked` for most cases." +"In other terms, this function returns the thread state that will be used by :" +"c:func:`PyGILState_Ensure`. If this returns ``NULL``, then " +"``PyGILState_Ensure`` will create a new thread state." msgstr "" -#: ../../c-api/threads.rst:475 -msgid ":c:func:`PyThreadState_Get`" -msgstr ":c:func:`PyThreadState_Get`" +#: ../../c-api/threads.rst:500 +msgid "This function cannot fail." +msgstr "此函式不會失敗。" -#: ../../c-api/threads.rst:479 +#: ../../c-api/threads.rst:502 msgid "" -"Return ``1`` if the current thread is holding the :term:`GIL` and ``0`` " -"otherwise. This function can be called from any thread at any time. Only if " -"it has had its :term:`thread state ` initialized via :" -"c:func:`PyGILState_Ensure` will it return ``1``. This is mainly a helper/" -"diagnostic function. It can be useful for example in callback contexts or " -"memory allocation functions when knowing that the :term:`GIL` is locked can " -"allow the caller to perform sensitive actions or otherwise behave " -"differently." +"Use :c:func:`PyThreadState_Get` or :c:func:`PyThreadState_GetUnchecked` " +"instead." msgstr "" +"請改用 :c:func:`PyThreadState_Get` 或 :c:func:`PyThreadState_GetUnchecked`。" -#: ../../c-api/threads.rst:489 +#: ../../c-api/threads.rst:509 +msgid "" +"Return ``1`` if the current thread has an :term:`attached thread state` that " +"matches the thread state returned by :c:func:" +"`PyGILState_GetThisThreadState`. If the caller has no attached thread state " +"or it otherwise doesn't match, then this returns ``0``." +msgstr "" + +#: ../../c-api/threads.rst:514 msgid "" "If the current Python process has ever created a subinterpreter, this " -"function will *always* return ``1``. Prefer :c:func:" -"`PyThreadState_GetUnchecked` for most cases." +"function will *always* return ``1``." msgstr "" -#: ../../c-api/threads.rst:497 +#: ../../c-api/threads.rst:517 +msgid "This is mainly a helper/diagnostic function." +msgstr "" + +#: ../../c-api/threads.rst:521 +msgid "Use ``PyThreadState_GetUnchecked() != NULL`` instead." +msgstr "請改用 ``PyThreadState_GetUnchecked() != NULL``。" + +#: ../../c-api/threads.rst:528 +msgid "Cautions about fork()" +msgstr "" + +#: ../../c-api/threads.rst:530 +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 " +"process forks only the thread that issued the fork will exist. This has a " +"concrete impact both on how locks must be handled and on all stored state in " +"CPython's runtime." +msgstr "" + +#: ../../c-api/threads.rst:536 +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` " +"by acquiring the locks it uses internally before the fork, and releasing " +"them afterwards. In addition, it resets any :ref:`lock-objects` in the " +"child. When extending or embedding Python, there is no way to inform Python " +"of additional (non-Python) locks that need to be acquired before or reset " +"after a fork. OS facilities such as :c:func:`!pthread_atfork` would need to " +"be used to accomplish the same thing. Additionally, when extending or " +"embedding Python, calling :c:func:`fork` directly rather than through :func:" +"`os.fork` (and returning to or calling into Python) may result in a deadlock " +"by one of Python's internal locks being held by a thread that is defunct " +"after the fork. :c:func:`PyOS_AfterFork_Child` tries to reset the necessary " +"locks, but is not always able to." +msgstr "" + +#: ../../c-api/threads.rst:551 +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 " +"means finalizing all other :c:type:`PyThreadState` objects belonging to the " +"current interpreter and all other :c:type:`PyInterpreterState` objects. Due " +"to this and the special nature of the :ref:`\"main\" interpreter `, :c:func:`fork` should only be called in that " +"interpreter's \"main\" thread, where the CPython global runtime was " +"originally initialized. The only exception is if :c:func:`exec` will be " +"called immediately after." +msgstr "" + +#: ../../c-api/threads.rst:564 +msgid "High-level APIs" +msgstr "" + +#: ../../c-api/threads.rst:566 +msgid "" +"These are the most commonly used types and functions when writing multi-" +"threaded C extensions." +msgstr "" + +#: ../../c-api/threads.rst:572 +msgid "" +"This data structure represents the state of a single thread. The only " +"public data member is:" +msgstr "" + +#: ../../c-api/threads.rst:577 +msgid "This thread's interpreter state." +msgstr "這個執行緒的直譯器狀態。" + +#: ../../c-api/threads.rst:588 +msgid "Deprecated function which does nothing." +msgstr "已棄用的函式,什麼也不做。" + +#: ../../c-api/threads.rst:590 +msgid "" +"In Python 3.6 and older, this function created the GIL if it didn't exist." +msgstr "" + +#: ../../c-api/threads.rst:592 +msgid "The function now does nothing." +msgstr "此函式現在不會做任何事情。" + +#: ../../c-api/threads.rst:595 +msgid "" +"This function is now called by :c:func:`Py_Initialize()`, so you don't have " +"to call it yourself anymore." +msgstr "" + +#: ../../c-api/threads.rst:599 +msgid "" +"This function cannot be called before :c:func:`Py_Initialize()` anymore." +msgstr "" + +#: ../../c-api/threads.rst:609 +msgid "" +"Detach the :term:`attached thread state` and return it. The thread will have " +"no :term:`thread state` upon returning." +msgstr "" + +#: ../../c-api/threads.rst:615 +msgid "" +"Set the :term:`attached thread state` to *tstate*. The passed :term:`thread " +"state` **should not** be :term:`attached `, otherwise " +"deadlock ensues. *tstate* will be attached upon returning." +msgstr "" + +#: ../../c-api/threads.rst:620 ../../c-api/threads.rst:809 +msgid "" +"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/threads.rst:631 +msgid "" +"Return the :term:`attached thread state`. If the thread has no attached " +"thread state, (such as when inside of :c:macro:`Py_BEGIN_ALLOW_THREADS` " +"block), then this issues a fatal error (so that the caller needn't check for " +"``NULL``)." +msgstr "" + +#: ../../c-api/threads.rst:636 +msgid "See also :c:func:`PyThreadState_GetUnchecked`." +msgstr "也請見 :c:func:`PyThreadState_GetUnchecked`。" + +#: ../../c-api/threads.rst:640 +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/threads.rst:644 +msgid "" +"In Python 3.5 to 3.12, the function was private and known as " +"``_PyThreadState_UncheckedGet()``." +msgstr "" +"在 Python 3.5 到 3.12 中,此函式是私有的,被稱為 " +"``_PyThreadState_UncheckedGet()``。" + +#: ../../c-api/threads.rst:651 +msgid "" +"Set the :term:`attached thread state` to *tstate*, and return the :term:" +"`thread state` that was attached prior to calling." +msgstr "" + +#: ../../c-api/threads.rst:654 +msgid "" +"This function is safe to call without an :term:`attached thread state`; it " +"will simply return ``NULL`` indicating that there was no prior thread state." +msgstr "" + +#: ../../c-api/threads.rst:658 +msgid ":c:func:`PyEval_ReleaseThread`" +msgstr ":c:func:`PyEval_ReleaseThread`" + +#: ../../c-api/threads.rst:661 +msgid "" +"Similar to :c:func:`PyGILState_Ensure`, this function will hang the thread " +"if the runtime is finalizing." +msgstr "" + +#: ../../c-api/threads.rst:666 msgid "Low-level APIs" msgstr "低階 API" -#: ../../c-api/threads.rst:501 +#: ../../c-api/threads.rst:670 msgid "" "Create a new thread state object belonging to the given interpreter object. " "An :term:`attached thread state` is not needed." msgstr "" -#: ../../c-api/threads.rst:506 +#: ../../c-api/threads.rst:675 msgid "" "Reset all information in a :term:`thread state` object. *tstate* must be :" "term:`attached `" msgstr "" -#: ../../c-api/threads.rst:509 +#: ../../c-api/threads.rst:678 msgid "" "This function now calls the :c:member:`!PyThreadState.on_delete` callback. " "Previously, that happened in :c:func:`PyThreadState_Delete`." msgstr "" -#: ../../c-api/threads.rst:513 +#: ../../c-api/threads.rst:682 msgid "The :c:member:`!PyThreadState.on_delete` callback was removed." msgstr ":c:member:`!PyThreadState.on_delete` 回呼已被移除。" -#: ../../c-api/threads.rst:519 +#: ../../c-api/threads.rst:688 msgid "" "Destroy a :term:`thread state` object. *tstate* should not be :term:" "`attached ` to any thread. *tstate* must have been " "reset with a previous call to :c:func:`PyThreadState_Clear`." msgstr "" -#: ../../c-api/threads.rst:527 +#: ../../c-api/threads.rst:696 msgid "" "Detach the :term:`attached thread state` (which must have been reset with a " "previous call to :c:func:`PyThreadState_Clear`) and then destroy it." msgstr "" -#: ../../c-api/threads.rst:530 +#: ../../c-api/threads.rst:699 msgid "" "No :term:`thread state` will be :term:`attached ` " "upon returning." msgstr "" -#: ../../c-api/threads.rst:535 +#: ../../c-api/threads.rst:704 msgid "Get the current frame of the Python thread state *tstate*." msgstr "" -#: ../../c-api/threads.rst:537 +#: ../../c-api/threads.rst:706 msgid "" "Return a :term:`strong reference`. Return ``NULL`` if no frame is currently " "executing." msgstr "" -#: ../../c-api/threads.rst:540 +#: ../../c-api/threads.rst:709 msgid "See also :c:func:`PyEval_GetFrame`." msgstr "也請見 :c:func:`PyEval_GetFrame`。" -#: ../../c-api/threads.rst:542 ../../c-api/threads.rst:551 -#: ../../c-api/threads.rst:560 +#: ../../c-api/threads.rst:711 ../../c-api/threads.rst:720 +#: ../../c-api/threads.rst:729 msgid "" "*tstate* must not be ``NULL``, and must be :term:`attached `." msgstr "" -#: ../../c-api/threads.rst:549 +#: ../../c-api/threads.rst:718 msgid "" "Get the unique :term:`thread state` identifier of the Python thread state " "*tstate*." msgstr "" -#: ../../c-api/threads.rst:558 +#: ../../c-api/threads.rst:727 msgid "Get the interpreter of the Python thread state *tstate*." msgstr "" -#: ../../c-api/threads.rst:567 +#: ../../c-api/threads.rst:736 msgid "Suspend tracing and profiling in the Python thread state *tstate*." msgstr "" -#: ../../c-api/threads.rst:569 +#: ../../c-api/threads.rst:738 msgid "Resume them using the :c:func:`PyThreadState_LeaveTracing` function." msgstr "" -#: ../../c-api/threads.rst:576 +#: ../../c-api/threads.rst:745 msgid "" "Resume tracing and profiling in the Python thread state *tstate* suspended " "by the :c:func:`PyThreadState_EnterTracing` function." msgstr "" -#: ../../c-api/threads.rst:579 +#: ../../c-api/threads.rst:748 msgid "" "See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile` functions." msgstr "" -#: ../../c-api/threads.rst:587 +#: ../../c-api/threads.rst:756 msgid "" "Set the stack protection start address and stack protection size of a Python " "thread state." msgstr "" -#: ../../c-api/threads.rst:590 +#: ../../c-api/threads.rst:759 msgid "" "On success, return ``0``. On failure, set an exception and return ``-1``." msgstr "" -#: ../../c-api/threads.rst:593 +#: ../../c-api/threads.rst:762 msgid "" "CPython implements :ref:`recursion control ` for C code by " "raising :py:exc:`RecursionError` when it notices that the machine execution " @@ -743,14 +999,14 @@ msgid "" "change." msgstr "" -#: ../../c-api/threads.rst:602 +#: ../../c-api/threads.rst:771 msgid "" "Call :c:func:`~PyUnstable_ThreadState_SetStackProtection` either before or " "after changing the stack. Do not call any other Python C API between the " "call and the stack change." msgstr "" -#: ../../c-api/threads.rst:607 +#: ../../c-api/threads.rst:776 msgid "" "See :c:func:`PyUnstable_ThreadState_ResetStackProtection` for undoing this " "operation." @@ -758,18 +1014,18 @@ msgstr "" "若要撤銷此操作,請參見 :c:func:" "`PyUnstable_ThreadState_ResetStackProtection`。" -#: ../../c-api/threads.rst:614 +#: ../../c-api/threads.rst:783 msgid "" "Reset the stack protection start address and stack protection size of a " "Python thread state to the operating system defaults." msgstr "" -#: ../../c-api/threads.rst:617 +#: ../../c-api/threads.rst:786 msgid "" "See :c:func:`PyUnstable_ThreadState_SetStackProtection` for an explanation." msgstr "請參見 :c:func:`PyUnstable_ThreadState_SetStackProtection` 的說明。" -#: ../../c-api/threads.rst:624 +#: ../../c-api/threads.rst:793 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 " @@ -779,62 +1035,62 @@ msgid "" "thread state is attached." msgstr "" -#: ../../c-api/threads.rst:634 +#: ../../c-api/threads.rst:803 msgid "" ":term:`Attach ` *tstate* to the current thread, which " "must not be ``NULL`` or already :term:`attached `." msgstr "" -#: ../../c-api/threads.rst:637 +#: ../../c-api/threads.rst:806 msgid "" "The calling thread must not already have an :term:`attached thread state`." msgstr "" -#: ../../c-api/threads.rst:645 +#: ../../c-api/threads.rst:814 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/threads.rst:654 +#: ../../c-api/threads.rst:823 msgid "" ":c:func:`PyEval_RestoreThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: ../../c-api/threads.rst:660 +#: ../../c-api/threads.rst:829 msgid "" "Detach the :term:`attached thread state`. The *tstate* argument, which must " "not be ``NULL``, is only used to check that it represents the :term:" "`attached thread state` --- if it isn't, a fatal error is reported." msgstr "" -#: ../../c-api/threads.rst:665 +#: ../../c-api/threads.rst:834 msgid "" ":c:func:`PyEval_SaveThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: ../../c-api/threads.rst:670 +#: ../../c-api/threads.rst:839 msgid "Asynchronous notifications" msgstr "" -#: ../../c-api/threads.rst:672 +#: ../../c-api/threads.rst:841 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/threads.rst:679 +#: ../../c-api/threads.rst:848 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/threads.rst:683 +#: ../../c-api/threads.rst:852 msgid "" "When successfully queued, *func* will be *eventually* called from the main " "interpreter thread with the argument *arg*. It will be called " @@ -842,17 +1098,17 @@ msgid "" "these conditions met:" msgstr "" -#: ../../c-api/threads.rst:688 +#: ../../c-api/threads.rst:857 msgid "on a :term:`bytecode` boundary;" msgstr "" -#: ../../c-api/threads.rst:689 +#: ../../c-api/threads.rst:858 msgid "" "with the main thread holding an :term:`attached thread state` (*func* can " "therefore use the full C API)." msgstr "" -#: ../../c-api/threads.rst:692 +#: ../../c-api/threads.rst:861 msgid "" "*func* must return ``0`` on success, or ``-1`` on failure with an exception " "set. *func* won't be interrupted to perform another asynchronous " @@ -860,7 +1116,7 @@ msgid "" "if the :term:`thread state ` is detached." msgstr "" -#: ../../c-api/threads.rst:697 +#: ../../c-api/threads.rst:866 msgid "" "This function doesn't need an :term:`attached thread state`. However, to " "call this function in a subinterpreter, the caller must have an :term:" @@ -868,17 +1124,17 @@ msgid "" "be called from the wrong interpreter." msgstr "" -#: ../../c-api/threads.rst:702 +#: ../../c-api/threads.rst:871 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 " "thread is busy executing a system call, *func* won't be called before the " "system call returns. This function is generally **not** suitable for " -"calling Python code from arbitrary C threads. Instead, use the :ref:" -"`PyGILState API`." +"calling Python code from arbitrary C threads. Instead, use :c:func:" +"`PyThreadState_EnsureFromView`." msgstr "" -#: ../../c-api/threads.rst:711 +#: ../../c-api/threads.rst:880 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 " @@ -886,149 +1142,168 @@ msgid "" "scheduled calls." msgstr "" -#: ../../c-api/threads.rst:717 +#: ../../c-api/threads.rst:886 msgid "" "This function now always schedules *func* to be run in the main interpreter." msgstr "" -#: ../../c-api/threads.rst:724 +#: ../../c-api/threads.rst:893 msgid "" "Execute all pending calls. This is usually executed automatically by the " "interpreter." msgstr "" -#: ../../c-api/threads.rst:727 +#: ../../c-api/threads.rst:896 msgid "" "This function returns ``0`` on success, and returns ``-1`` with an exception " "set on failure." msgstr "" -#: ../../c-api/threads.rst:730 +#: ../../c-api/threads.rst:899 msgid "" "If this is not called in the main thread of the main interpreter, this " "function does nothing and returns ``0``. The caller must hold an :term:" "`attached thread state`." msgstr "" -#: ../../c-api/threads.rst:736 +#: ../../c-api/threads.rst:905 msgid "This function only runs pending calls in the main interpreter." msgstr "" -#: ../../c-api/threads.rst:742 +#: ../../c-api/threads.rst:911 +msgid "" +"Schedule an exception to be raised asynchronously in a thread. If the thread " +"has a previously scheduled exception, it is overwritten." +msgstr "" + +#: ../../c-api/threads.rst:914 +msgid "" +"The *id* argument is the thread id of the target thread, as returned by :c:" +"func:`PyThread_get_thread_ident`. *exc* is the class of the exception to be " +"raised, or ``NULL`` to clear the pending exception (if any)." +msgstr "" + +#: ../../c-api/threads.rst:919 +msgid "" +"Return the number of affected thread states. This is normally ``1`` if *id* " +"is found, even when no change was made (the given *exc* was already pending, " +"or *exc* is ``NULL`` but no exception is pending). If the thread id isn't " +"found, return ``0``. This raises no exceptions." +msgstr "" + +#: ../../c-api/threads.rst:925 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. " -"This function does not :term:`steal` any references to *exc*. To prevent " -"naive misuse, you must write your own C extension to call this. Must be " -"called with an :term:`attached thread state`. Returns the number of thread " -"states modified; this is normally one, but will be zero if the thread id " -"isn't found. If *exc* is ``NULL``, the pending exception (if any) for the " -"thread is cleared. This raises no exceptions." +"To prevent naive misuse, you must write your own C extension to call this. " +"This function must be called with an :term:`attached thread state`. This " +"function does not :term:`steal` any references to *exc*. This function does " +"not necessarily interrupt system calls such as :py:func:`~time.sleep`." msgstr "" -#: ../../c-api/threads.rst:750 +#: ../../c-api/threads.rst:931 msgid "" "The type of the *id* parameter changed from :c:expr:`long` to :c:expr:" "`unsigned long`." msgstr "" -#: ../../c-api/threads.rst:756 +#: ../../c-api/threads.rst:937 msgid "Operating system thread APIs" msgstr "作業系統執行緒 API" -#: ../../c-api/threads.rst:760 +#: ../../c-api/threads.rst:941 msgid "Sentinel value for an invalid thread ID." msgstr "" -#: ../../c-api/threads.rst:762 +#: ../../c-api/threads.rst:943 msgid "This is currently equivalent to ``(unsigned long)-1``." msgstr "目前等同於 ``(unsigned long)-1``。" -#: ../../c-api/threads.rst:767 +#: ../../c-api/threads.rst:948 msgid "" "Start function *func* in a new thread with argument *arg*. The resulting " "thread is not intended to be joined." msgstr "" -#: ../../c-api/threads.rst:770 +#: ../../c-api/threads.rst:951 msgid "*func* must not be ``NULL``, but *arg* may be ``NULL``." msgstr "*func* 不能是 ``NULL``,但 *arg* 可以是 ``NULL``。" -#: ../../c-api/threads.rst:772 +#: ../../c-api/threads.rst:953 msgid "" "On success, this function returns the identifier of the new thread; on " "failure, this returns :c:macro:`PYTHREAD_INVALID_THREAD_ID`." msgstr "" -#: ../../c-api/threads.rst:775 ../../c-api/threads.rst:859 -#: ../../c-api/threads.rst:867 +#: ../../c-api/threads.rst:956 ../../c-api/threads.rst:1041 +#: ../../c-api/threads.rst:1049 msgid "The caller does not need to hold an :term:`attached thread state`." msgstr "呼叫者不需擁有一個 :term:`attached thread state`。" -#: ../../c-api/threads.rst:780 +#: ../../c-api/threads.rst:961 msgid "Return the identifier of the current thread, which will never be zero." msgstr "" -#: ../../c-api/threads.rst:782 ../../c-api/threads.rst:814 +#: ../../c-api/threads.rst:963 ../../c-api/threads.rst:996 msgid "" "This function cannot fail, and the caller does not need to hold an :term:" "`attached thread state`." msgstr "" -#: ../../c-api/threads.rst:786 -msgid ":py:func:`threading.get_ident`" -msgstr ":py:func:`threading.get_ident`" +#: ../../c-api/threads.rst:967 +msgid "" +":py:func:`threading.get_ident` and :py:attr:`threading.Thread.ident` expose " +"this identifier to Python." +msgstr "" -#: ../../c-api/threads.rst:791 +#: ../../c-api/threads.rst:973 msgid "" "Get general information about the current thread in the form of a :ref:" "`struct sequence ` object. This information is " "accessible as :py:attr:`sys.thread_info` in Python." msgstr "" -#: ../../c-api/threads.rst:795 +#: ../../c-api/threads.rst:977 msgid "" "On success, this returns a new :term:`strong reference` to the thread " "information; on failure, this returns ``NULL`` with an exception set." msgstr "" -#: ../../c-api/threads.rst:798 +#: ../../c-api/threads.rst:980 msgid "The caller must hold an :term:`attached thread state`." msgstr "呼叫者必須擁有一個 :term:`attached thread state`。" -#: ../../c-api/threads.rst:803 +#: ../../c-api/threads.rst:985 msgid "This macro is defined when the system supports native thread IDs." msgstr "" -#: ../../c-api/threads.rst:808 +#: ../../c-api/threads.rst:990 msgid "" "Get the native identifier of the current thread as it was assigned by the " "operating system's kernel, which will never be less than zero." msgstr "" -#: ../../c-api/threads.rst:811 +#: ../../c-api/threads.rst:993 msgid "" "This function is only available when :c:macro:`PY_HAVE_THREAD_NATIVE_ID` is " "defined." msgstr "" -#: ../../c-api/threads.rst:818 +#: ../../c-api/threads.rst:1000 msgid ":py:func:`threading.get_native_id`" msgstr ":py:func:`threading.get_native_id`" -#: ../../c-api/threads.rst:823 +#: ../../c-api/threads.rst:1005 msgid "" "Terminate the current thread. This function is generally considered unsafe " "and should be avoided. It is kept solely for backwards compatibility." msgstr "" -#: ../../c-api/threads.rst:826 +#: ../../c-api/threads.rst:1008 msgid "" "This function is only safe to call if all functions in the full call stack " "are written to safely allow it." msgstr "" -#: ../../c-api/threads.rst:831 +#: ../../c-api/threads.rst:1013 msgid "" "If the current system uses POSIX threads (also known as \"pthreads\"), this " "calls :manpage:`pthread_exit(3)`, which attempts to unwind the stack and " @@ -1037,34 +1312,34 @@ msgid "" "systems, such as macOS, do unwinding." msgstr "" -#: ../../c-api/threads.rst:837 +#: ../../c-api/threads.rst:1019 msgid "" "On Windows, this function calls ``_endthreadex()``, which kills the thread " "without calling C++ destructors." msgstr "" -#: ../../c-api/threads.rst:840 +#: ../../c-api/threads.rst:1022 msgid "In any case, there is a risk of corruption on the thread's stack." msgstr "" -#: ../../c-api/threads.rst:847 +#: ../../c-api/threads.rst:1029 msgid "" "Initialize ``PyThread*`` APIs. Python executes this function automatically, " "so there's little need to call it from an extension module." msgstr "" -#: ../../c-api/threads.rst:853 +#: ../../c-api/threads.rst:1035 msgid "Set the stack size of the current thread to *size* bytes." msgstr "" -#: ../../c-api/threads.rst:855 +#: ../../c-api/threads.rst:1037 msgid "" "This function returns ``0`` on success, ``-1`` if *size* is invalid, or " "``-2`` if the system does not support changing the stack size. This function " "does not set exceptions." msgstr "" -#: ../../c-api/threads.rst:864 +#: ../../c-api/threads.rst:1046 msgid "" "Return the stack size of the current thread in bytes, or ``0`` if the " "system's default stack size is in use." @@ -1106,26 +1381,29 @@ msgstr "PyEval_RestoreThread(C 函式)" msgid "PyEval_SaveThread (C function)" msgstr "PyEval_SaveThread(C 函式)" -#: ../../c-api/threads.rst:318 +#: ../../c-api/threads.rst:582 msgid "PyEval_AcquireThread()" msgstr "PyEval_AcquireThread()" -#: ../../c-api/threads.rst:318 +#: ../../c-api/threads.rst:582 msgid "PyEval_ReleaseThread()" msgstr "PyEval_ReleaseThread()" -#: ../../c-api/threads.rst:318 +#: ../../c-api/threads.rst:582 msgid "PyEval_SaveThread()" msgstr "PyEval_SaveThread()" -#: ../../c-api/threads.rst:318 +#: ../../c-api/threads.rst:582 msgid "PyEval_RestoreThread()" msgstr "PyEval_RestoreThread()" -#: ../../c-api/threads.rst:340 +#: ../../c-api/threads.rst:604 msgid "module" msgstr "模組" -#: ../../c-api/threads.rst:340 +#: ../../c-api/threads.rst:604 msgid "_thread" msgstr "_thread" + +#~ msgid ":py:func:`threading.get_ident`" +#~ msgstr ":py:func:`threading.get_ident`" diff --git a/c-api/tuple.po b/c-api/tuple.po index 59be2fc2407..16024e7e0b2 100644 --- a/c-api/tuple.po +++ b/c-api/tuple.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-02 00:39+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-11-13 21:53+0000\n" "Last-Translator: Yorkxe \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -58,6 +58,22 @@ msgstr "回傳一個長度為 *len* 的新元組物件,失敗會時回傳 ``NU #: ../../c-api/tuple.rst:42 msgid "" +"Create a tuple of *size* items and copy references from *array* to the new " +"tuple." +msgstr "" + +#: ../../c-api/tuple.rst:45 +msgid "*array* can be NULL if *size* is ``0``." +msgstr "" + +#: ../../c-api/tuple.rst:47 +msgid "" +"On success, return a new reference. On error, set an exception and return " +"``NULL``." +msgstr "" + +#: ../../c-api/tuple.rst:55 +msgid "" "Return a new tuple object of size *n*, or ``NULL`` with an exception set on " "failure. The tuple values are initialized to the subsequent *n* C arguments " "pointing to Python objects. ``PyTuple_Pack(2, a, b)`` is equivalent to " @@ -67,7 +83,7 @@ msgstr "" "始化為指向 Python 物件的接續 *n* 個 C 引數。``PyTuple_Pack(2, a, b)`` 等價於 " "``Py_BuildValue(\"(OO)\", a, b)``。" -#: ../../c-api/tuple.rst:50 +#: ../../c-api/tuple.rst:63 msgid "" "Take a pointer to a tuple object, and return the size of that tuple. On " "error, return ``-1`` with an exception set." @@ -75,11 +91,11 @@ msgstr "" "拿取一個元組物件的指標,然後回傳此元組的大小。錯誤發生時,回傳 ``-1`` 並設定" "例外。" -#: ../../c-api/tuple.rst:56 +#: ../../c-api/tuple.rst:69 msgid "Like :c:func:`PyTuple_Size`, but without error checking." msgstr "就像 :c:func:`PyTuple_Size` 但沒有錯誤檢查。" -#: ../../c-api/tuple.rst:61 +#: ../../c-api/tuple.rst:74 msgid "" "Return the object at position *pos* in the tuple pointed to by *p*. If " "*pos* is negative or out of bounds, return ``NULL`` and set an :exc:" @@ -88,7 +104,7 @@ msgstr "" "回傳 *p* 指向的元組中位置 *pos* 處的物件。如果 *pos* 為負數或超出範圍,回傳 " "``NULL`` 並設定 :exc:`IndexError` 例外。" -#: ../../c-api/tuple.rst:64 +#: ../../c-api/tuple.rst:77 msgid "" "The returned reference is borrowed from the tuple *p* (that is: it is only " "valid as long as you hold a reference to *p*). To get a :term:`strong " @@ -100,11 +116,11 @@ msgstr "" "`Py_NewRef(PyTuple_GetItem(...)) ` 或 :c:func:" "`PySequence_GetItem`。" -#: ../../c-api/tuple.rst:73 +#: ../../c-api/tuple.rst:86 msgid "Like :c:func:`PyTuple_GetItem`, but does no checking of its arguments." msgstr "與 :c:func:`PyTuple_GetItem` 相似,但不檢查其引數。" -#: ../../c-api/tuple.rst:78 +#: ../../c-api/tuple.rst:91 msgid "" "Return the slice of the tuple pointed to by *p* between *low* and *high*, or " "``NULL`` with an exception set on failure." @@ -112,22 +128,24 @@ msgstr "" "回傳由 *p* 指向的元組中介於 *low* 和 *high* 之間的切片或在錯誤時回傳 " "``NULL`` 並設定例外。" -#: ../../c-api/tuple.rst:81 +#: ../../c-api/tuple.rst:94 msgid "" "This is the equivalent of the Python expression ``p[low:high]``. Indexing " "from the end of the tuple is not supported." msgstr "這與 Python ``p[low:high]`` 運算式等價。但不支援從元組末端開始索引。" -#: ../../c-api/tuple.rst:87 +#: ../../c-api/tuple.rst:100 msgid "" "Insert a reference to object *o* at position *pos* of the tuple pointed to " "by *p*. Return ``0`` on success. If *pos* is out of bounds, return ``-1`` " -"and set an :exc:`IndexError` exception." +"and set an :exc:`IndexError` exception. This function should only be used to " +"fill in brand new tuples; using it on an existing tuple is thread-unsafe." msgstr "" "於 *p* 指向的元組 *pos* 位置處插入對物件 *o* 的參照。成功時回傳 ``0``,如果 " -"*pos* 超出邊界則回傳 ``-1``,並設定 :exc:`IndexError` 例外。" +"*pos* 超出邊界則回傳 ``-1``,並設定 :exc:`IndexError` 例外。此函式只應用於填" +"充全新的元組;在既有的元組上使用它不是執行緒安全的。" -#: ../../c-api/tuple.rst:93 +#: ../../c-api/tuple.rst:107 msgid "" "This function \":term:`steals `\" a reference to *o* and discards a " "reference to an item already in the tuple at the affected position (unless " @@ -136,16 +154,17 @@ msgstr "" "此函式「:term:`竊取 `」對 *o* 的參照,並丟棄元組中該受影響位置上已存在" "項目的參照(除非該參照為 NULL)。" -#: ../../c-api/tuple.rst:100 +#: ../../c-api/tuple.rst:114 msgid "" "Like :c:func:`PyTuple_SetItem`, but does no error checking, and should " -"*only* be used to fill in brand new tuples." +"*only* be used to fill in brand new tuples, using it on an existing tuple is " +"thread-unsafe." msgstr "" -"與 :c:func:`PyTuple_SetItem` 相似,但不進行錯誤檢查,且應 *只* 用於填充全新的" -"元組。" +"與 :c:func:`PyTuple_SetItem` 相似,但不進行錯誤檢查,且應\\ *只*\\ 用於填充全" +"新的元組,在既有的元組上使用它不是執行緒安全的。" -#: ../../c-api/tuple.rst:103 ../../c-api/tuple.rst:225 -#: ../../c-api/tuple.rst:243 +#: ../../c-api/tuple.rst:117 ../../c-api/tuple.rst:244 +#: ../../c-api/tuple.rst:262 msgid "" "Bounds checking is performed as an assertion if Python is built in :ref:" "`debug mode ` or :option:`with assertions <--with-assertions>`." @@ -153,7 +172,7 @@ msgstr "" "若 Python 以 :ref:`debug mode ` 或 :option:`with assertions <--" "with-assertions>` 建置,則會進行作為斷言(asserting)的邊界檢查。" -#: ../../c-api/tuple.rst:108 +#: ../../c-api/tuple.rst:122 msgid "" "This function \":term:`steals `\" a reference to *o*, and, unlike :c:" "func:`PyTuple_SetItem`, does *not* discard a reference to any item that is " @@ -163,7 +182,7 @@ msgstr "" "不同的是,此函式並\\ *不*\\ 丟棄任何被替換項目的參照;元組中 *pos* 位置的所有" "參照皆會被洩漏。" -#: ../../c-api/tuple.rst:115 +#: ../../c-api/tuple.rst:129 msgid "" "This macro should *only* be used on tuples that are newly created. Using " "this macro on a tuple that is already in use (or in other words, has a " @@ -172,7 +191,7 @@ msgstr "" "此巨集應 *僅* 用於新建立的元組。在正被使用中的元組(或換句話說,參照計數大於 " "1 的元組)上使用此巨集可能會導致未定義行為。" -#: ../../c-api/tuple.rst:122 +#: ../../c-api/tuple.rst:136 msgid "" "Can be used to resize a tuple. *newsize* will be the new length of the " "tuple. Because tuples are *supposed* to be immutable, this should only be " @@ -194,22 +213,26 @@ msgstr "" "原始的 ``*p`` 將被銷毀。失敗時,回傳 ``-1``,並將 ``*p`` 設定為 ``NULL``,並" "引發 :exc:`MemoryError` 或 :exc:`SystemError` 例外。" -#: ../../c-api/tuple.rst:137 +#: ../../c-api/tuple.rst:151 msgid "Struct Sequence Objects" msgstr "結構序列物件" -#: ../../c-api/tuple.rst:139 +#: ../../c-api/tuple.rst:153 msgid "" -"Struct sequence objects are the C equivalent of :func:`~collections." -"namedtuple` objects, i.e. a sequence whose items can also be accessed " -"through attributes. To create a struct sequence, you first have to create a " -"specific struct sequence type." +"A struct sequence object is a :term:`named tuple`, that is, a sequence whose " +"items can also be accessed through attributes. It is similar to :func:" +"`collections.namedtuple`, but provides a slightly different interface." msgstr "" -"結構序列物件是 :func:`~collections.namedtuple` 物件在 C 語言中的等價,換言" -"之,一個序列的元素也可以透過屬性存取。要建立結構序列,首先需要建立特定的結構" -"序列型別。" +"結構序列物件是一個\\ :term:`附名元組 `,也就是元素也可以透過屬性" +"存取的序列。它類似於 :func:`collections.namedtuple`,但提供稍微不同的介面。" -#: ../../c-api/tuple.rst:146 +#: ../../c-api/tuple.rst:158 +msgid "" +"To create a struct sequence, you first have to create a specific struct " +"sequence type." +msgstr "" + +#: ../../c-api/tuple.rst:163 msgid "" "Create a new struct sequence type from the data in *desc*, described below. " "Instances of the resulting type can be created with :c:func:" @@ -218,15 +241,15 @@ msgstr "" "從 *desc* 中的資料建立一個新的結構序列型別,如下所述。可以使用 :c:func:" "`PyStructSequence_New` 以建立產生結構序列型別的實例。" -#: ../../c-api/tuple.rst:149 ../../c-api/tuple.rst:218 +#: ../../c-api/tuple.rst:166 ../../c-api/tuple.rst:235 msgid "Return ``NULL`` with an exception set on failure." msgstr "失敗時回傳 ``NULL`` 並設定例外。" -#: ../../c-api/tuple.rst:154 +#: ../../c-api/tuple.rst:171 msgid "Initializes a struct sequence type *type* from *desc* in place." msgstr "從 *desc* 原地(in place)初始化結構序列型別 *type*。" -#: ../../c-api/tuple.rst:159 +#: ../../c-api/tuple.rst:176 msgid "" "Like :c:func:`PyStructSequence_InitType`, but returns ``0`` on success and " "``-1`` with an exception set on failure." @@ -234,11 +257,11 @@ msgstr "" "與 :c:func:`PyStructSequence_InitType` 相似,但運行成功時回傳 ``0``,運行失敗" "時回傳 ``-1`` 並設定例外。" -#: ../../c-api/tuple.rst:167 +#: ../../c-api/tuple.rst:184 msgid "Contains the meta information of a struct sequence type to create." msgstr "包含要建立的結構序列化型別的中介資訊(meta information)。" -#: ../../c-api/tuple.rst:171 +#: ../../c-api/tuple.rst:188 msgid "" "Fully qualified name of the type; null-terminated UTF-8 encoded. The name " "must contain the module name." @@ -246,19 +269,19 @@ msgstr "" "型別的完整限定名稱(Fully qualified name);以 UTF-8 編碼並以空字元結尾。名稱" "必須包含完整的模組名稱。" -#: ../../c-api/tuple.rst:176 +#: ../../c-api/tuple.rst:193 msgid "Pointer to docstring for the type or ``NULL`` to omit." msgstr "指向型別說明文件(docstring)的指標或使用 ``NULL`` 表示忽略。" -#: ../../c-api/tuple.rst:180 +#: ../../c-api/tuple.rst:197 msgid "Pointer to ``NULL``-terminated array with field names of the new type." msgstr "指向一個以 ``NULL`` 結尾的陣列指標,其包含新型別的欄位名稱。" -#: ../../c-api/tuple.rst:184 +#: ../../c-api/tuple.rst:201 msgid "Number of fields visible to the Python side (if used as tuple)." msgstr "Python 端可以看到欄位的數目(如果作為元組使用)。" -#: ../../c-api/tuple.rst:189 +#: ../../c-api/tuple.rst:206 msgid "" "Describes a field of a struct sequence. As a struct sequence is modeled as a " "tuple, all fields are typed as :c:expr:`PyObject*`. The index in the :c:" @@ -271,7 +294,7 @@ msgstr "" "`~PyStructSequence_Desc.fields` 陣列中的索引決定了描述的是結構序列的哪個欄" "位。" -#: ../../c-api/tuple.rst:197 +#: ../../c-api/tuple.rst:214 msgid "" "Name for the field or ``NULL`` to end the list of named fields, set to :c:" "data:`PyStructSequence_UnnamedField` to leave unnamed." @@ -279,38 +302,40 @@ msgstr "" "欄位名稱,或 ``NULL`` 表示命名欄位串列結束,設定為 :c:data:" "`PyStructSequence_UnnamedField` 表示該欄位不命名。" -#: ../../c-api/tuple.rst:202 +#: ../../c-api/tuple.rst:219 msgid "Field docstring or ``NULL`` to omit." msgstr "欄位說明字串或為 ``NULL`` 表示忽略。" -#: ../../c-api/tuple.rst:207 +#: ../../c-api/tuple.rst:224 msgid "Special value for a field name to leave it unnamed." msgstr "給定欄位名稱一個特別值,表示該欄位不命名。" -#: ../../c-api/tuple.rst:209 +#: ../../c-api/tuple.rst:226 msgid "The type was changed from ``char *``." msgstr "型別原本是 ``char *``,現已被修改。" -#: ../../c-api/tuple.rst:215 +#: ../../c-api/tuple.rst:232 msgid "" "Creates an instance of *type*, which must have been created with :c:func:" "`PyStructSequence_NewType`." msgstr "建立 *type* 的實例,必須以 :c:func:`PyStructSequence_NewType` 建立。" -#: ../../c-api/tuple.rst:223 +#: ../../c-api/tuple.rst:240 msgid "" -"Return the object at position *pos* in the struct sequence pointed to by *p*." -msgstr "回傳結構序列中由 *p* 指向 *pos* 處的物件。" +"Return the object at position *pos* in the struct sequence pointed to by " +"*p*. The returned reference is borrowed from the struct sequence *p* (that " +"is: it is only valid as long as you hold a reference to *p*)." +msgstr "" -#: ../../c-api/tuple.rst:231 +#: ../../c-api/tuple.rst:250 msgid "Alias to :c:func:`PyStructSequence_GetItem`." msgstr ":c:func:`PyStructSequence_GetItem` 的別名。" -#: ../../c-api/tuple.rst:233 +#: ../../c-api/tuple.rst:252 msgid "Now implemented as an alias to :c:func:`PyStructSequence_GetItem`." msgstr "現在是被實作為 :c:func:`PyStructSequence_GetItem` 的一個別名。" -#: ../../c-api/tuple.rst:239 +#: ../../c-api/tuple.rst:258 msgid "" "Sets the field at index *pos* of the struct sequence *p* to value *o*. " "Like :c:func:`PyTuple_SET_ITEM`, this should only be used to fill in brand " @@ -319,15 +344,15 @@ msgstr "" "將結構序列 *p* 中索引 *pos* 處的欄位值設為 *o*。與 :c:func:" "`PyTuple_SET_ITEM` 類似,此函式僅套用於填充全新實例。" -#: ../../c-api/tuple.rst:248 +#: ../../c-api/tuple.rst:267 msgid "This function \":term:`steals `\" a reference to *o*." msgstr "此函式「:term:`竊取 `」對 *o* 的參照。" -#: ../../c-api/tuple.rst:253 +#: ../../c-api/tuple.rst:272 msgid "Alias to :c:func:`PyStructSequence_SetItem`." msgstr ":c:func:`PyStructSequence_SetItem` 的別名。" -#: ../../c-api/tuple.rst:255 +#: ../../c-api/tuple.rst:274 msgid "Now implemented as an alias to :c:func:`PyStructSequence_SetItem`." msgstr "現在是被實作為 :c:func:`PyStructSequence_SetItem` 的一個別名。" @@ -338,3 +363,8 @@ msgstr "object(物件)" #: ../../c-api/tuple.rst:8 msgid "tuple" msgstr "tuple(元組)" + +#~ msgid "" +#~ "Return the object at position *pos* in the struct sequence pointed to by " +#~ "*p*." +#~ msgstr "回傳結構序列中由 *p* 指向 *pos* 處的物件。" diff --git a/c-api/type.po b/c-api/type.po index 968d140b99b..34075e1191a 100644 --- a/c-api/type.po +++ b/c-api/type.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-02 00:39+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -129,34 +129,43 @@ msgid "" msgstr "" #: ../../c-api/type.rst:113 +msgid "The callback is also invoked when a watched heap type is deallocated." +msgstr "" + +#: ../../c-api/type.rst:115 msgid "" "An extension should never call ``PyType_Watch`` with a *watcher_id* that was " "not returned to it by a previous call to :c:func:`PyType_AddWatcher`." msgstr "" -#: ../../c-api/type.rst:121 +#: ../../c-api/type.rst:120 +msgid "" +"The callback is now also invoked when a watched heap type is deallocated." +msgstr "" + +#: ../../c-api/type.rst:126 msgid "" "Mark *type* as not watched. This undoes a previous call to :c:func:" "`PyType_Watch`. *type* must not be ``NULL``." msgstr "" -#: ../../c-api/type.rst:124 +#: ../../c-api/type.rst:129 msgid "" "An extension should never call this function with a *watcher_id* that was " "not returned to it by a previous call to :c:func:`PyType_AddWatcher`." msgstr "" -#: ../../c-api/type.rst:127 +#: ../../c-api/type.rst:132 msgid "" "On success, this function returns ``0``. On failure, this function returns " "``-1`` with an exception set." msgstr "成功時此函式會回傳 ``0``。失敗時此函式回傳 ``-1`` 並設定例外。" -#: ../../c-api/type.rst:135 +#: ../../c-api/type.rst:140 msgid "Type of a type-watcher callback function." msgstr "" -#: ../../c-api/type.rst:137 +#: ../../c-api/type.rst:142 msgid "" "The callback must not modify *type* or cause :c:func:`PyType_Modified` to be " "called on *type* or any type in its MRO; violating this rule could cause " @@ -165,11 +174,25 @@ msgstr "" #: ../../c-api/type.rst:146 msgid "" +"The callback may be called during type deallocation. In this case, the type " +"object is temporarily resurrected (its reference count is at least 1) and " +"all its attributes are still valid. However, the callback should not store " +"new strong references to the type, as this would resurrect the object and " +"prevent its deallocation." +msgstr "" + +#: ../../c-api/type.rst:154 +msgid "" +"The callback may now be called during deallocation of a watched heap type." +msgstr "" + +#: ../../c-api/type.rst:160 +msgid "" "Return non-zero if the type object *o* sets the feature *feature*. Type " "features are denoted by single bit flags." msgstr "" -#: ../../c-api/type.rst:152 +#: ../../c-api/type.rst:166 msgid "" "Return non-zero if the type object *type* sets the subclass flag *flag*. " "Subclass flags are denoted by :c:macro:`Py_TPFLAGS_*_SUBCLASS " @@ -177,30 +200,30 @@ msgid "" "functions for common types." msgstr "" -#: ../../c-api/type.rst:158 +#: ../../c-api/type.rst:172 msgid "" ":c:func:`PyObject_TypeCheck`, which is used as a slower alternative in " "``_Check`` functions for types that don't come with subclass flags." msgstr "" -#: ../../c-api/type.rst:164 +#: ../../c-api/type.rst:178 msgid "" "Return true if the type object includes support for the cycle detector; this " "tests the type flag :c:macro:`Py_TPFLAGS_HAVE_GC`." msgstr "" -#: ../../c-api/type.rst:170 +#: ../../c-api/type.rst:184 msgid "Return true if *a* is a subtype of *b*." msgstr "如果 *a* 是 *b* 的子類別則回傳 true。" -#: ../../c-api/type.rst:172 +#: ../../c-api/type.rst:186 msgid "" "This function only checks for actual subtypes, which means that :meth:`~type." "__subclasscheck__` is not called on *b*. Call :c:func:`PyObject_IsSubclass` " "to do the same check that :func:`issubclass` would do." msgstr "" -#: ../../c-api/type.rst:180 +#: ../../c-api/type.rst:194 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_alloc` slot of a type " "object. Uses Python's default memory allocation mechanism to allocate " @@ -208,13 +231,13 @@ msgid "" "if by calling :c:func:`PyObject_Init` or :c:func:`PyObject_InitVar`." msgstr "" -#: ../../c-api/type.rst:185 +#: ../../c-api/type.rst:199 msgid "" "Do not call this directly to allocate memory for an object; call the type's :" "c:member:`~PyTypeObject.tp_alloc` slot instead." msgstr "" -#: ../../c-api/type.rst:188 +#: ../../c-api/type.rst:202 msgid "" "For types that support garbage collection (i.e., the :c:macro:" "`Py_TPFLAGS_HAVE_GC` flag is set), this function behaves like :c:macro:" @@ -226,14 +249,14 @@ msgid "" "paired with :c:func:`PyObject_Free` in :c:member:`~PyTypeObject.tp_free`." msgstr "" -#: ../../c-api/type.rst:201 +#: ../../c-api/type.rst:215 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_new` slot of a type " "object. Creates a new instance using the type's :c:member:`~PyTypeObject." "tp_alloc` slot and returns the resulting object." msgstr "" -#: ../../c-api/type.rst:208 +#: ../../c-api/type.rst:222 msgid "" "Finalize a type object. This should be called on all type objects to finish " "their initialization. This function is responsible for adding inherited " @@ -241,7 +264,7 @@ msgid "" "and sets an exception on error." msgstr "" -#: ../../c-api/type.rst:214 +#: ../../c-api/type.rst:228 msgid "" "If some of the base classes implements the GC protocol and the provided type " "does not include the :c:macro:`Py_TPFLAGS_HAVE_GC` in its flags, then the GC " @@ -252,32 +275,32 @@ msgid "" "handle." msgstr "" -#: ../../c-api/type.rst:225 +#: ../../c-api/type.rst:239 msgid "" "Return the type's name. Equivalent to getting the type's :attr:`~type." "__name__` attribute." msgstr "" -#: ../../c-api/type.rst:233 +#: ../../c-api/type.rst:247 msgid "" "Return the type's qualified name. Equivalent to getting the type's :attr:" "`~type.__qualname__` attribute." msgstr "" -#: ../../c-api/type.rst:240 +#: ../../c-api/type.rst:254 msgid "" "Return the type's fully qualified name. Equivalent to ``f\"{type.__module__}." "{type.__qualname__}\"``, or :attr:`type.__qualname__` if :attr:`type." "__module__` is not a string or is equal to ``\"builtins\"``." msgstr "" -#: ../../c-api/type.rst:249 +#: ../../c-api/type.rst:263 msgid "" "Return the type's module name. Equivalent to getting the :attr:`type." "__module__` attribute." msgstr "" -#: ../../c-api/type.rst:257 +#: ../../c-api/type.rst:271 msgid "" "Return the function pointer stored in the given slot. If the result is " "``NULL``, this indicates that either the slot is ``NULL``, or that the " @@ -285,72 +308,72 @@ msgid "" "result pointer into the appropriate function type." msgstr "" -#: ../../c-api/type.rst:263 +#: ../../c-api/type.rst:277 msgid "" "See :c:member:`PyType_Slot.slot` for possible values of the *slot* argument." msgstr "" -#: ../../c-api/type.rst:267 +#: ../../c-api/type.rst:281 msgid "" ":c:func:`PyType_GetSlot` can now accept all types. Previously, it was " "limited to :ref:`heap types `." msgstr "" -#: ../../c-api/type.rst:274 +#: ../../c-api/type.rst:288 msgid "" "Return the module object associated with the given type when the type was " "created using :c:func:`PyType_FromModuleAndSpec`." msgstr "" -#: ../../c-api/type.rst:277 ../../c-api/type.rst:324 +#: ../../c-api/type.rst:291 ../../c-api/type.rst:355 msgid "" "The returned reference is :term:`borrowed ` from *type*, " "and will be valid as long as you hold a reference to *type*. Do not release " "it with :c:func:`Py_DECREF` or similar." msgstr "" -#: ../../c-api/type.rst:281 ../../c-api/type.rst:302 +#: ../../c-api/type.rst:295 ../../c-api/type.rst:316 msgid "" "If no module is associated with the given type, sets :py:class:`TypeError` " "and returns ``NULL``." msgstr "" -#: ../../c-api/type.rst:284 +#: ../../c-api/type.rst:298 msgid "" "This function is usually used to get the module in which a method is " "defined. Note that in such a method, ``PyType_GetModule(Py_TYPE(self))`` may " "not return the intended result. ``Py_TYPE(self)`` may be a *subclass* of the " "intended class, and subclasses are not necessarily defined in the same " "module as their superclass. See :c:type:`PyCMethod` to get the class that " -"defines the method. See :c:func:`PyType_GetModuleByDef` for cases when :c:" +"defines the method. See :c:func:`PyType_GetModuleByToken` for cases when :c:" "type:`!PyCMethod` cannot be used." msgstr "" -#: ../../c-api/type.rst:298 +#: ../../c-api/type.rst:312 msgid "" "Return the state of the module object associated with the given type. This " "is a shortcut for calling :c:func:`PyModule_GetState()` on the result of :c:" "func:`PyType_GetModule`." msgstr "" -#: ../../c-api/type.rst:305 +#: ../../c-api/type.rst:319 msgid "" "If the *type* has an associated module but its state is ``NULL``, returns " "``NULL`` without setting an exception." msgstr "" -#: ../../c-api/type.rst:313 +#: ../../c-api/type.rst:327 msgid "" -"Find the first superclass whose module was created from the given :c:type:" -"`PyModuleDef` *def*, and return that module." +"Find the first superclass whose module has the given :ref:`module token `, and return that module." msgstr "" -#: ../../c-api/type.rst:316 +#: ../../c-api/type.rst:330 msgid "" "If no module is found, raises a :py:class:`TypeError` and returns ``NULL``." msgstr "" -#: ../../c-api/type.rst:318 +#: ../../c-api/type.rst:332 msgid "" "This function is intended to be used together with :c:func:" "`PyModule_GetState()` to get module state from slot methods (such as :c:" @@ -359,30 +382,53 @@ msgid "" "type:`PyCMethod` calling convention." msgstr "" -#: ../../c-api/type.rst:333 +#: ../../c-api/type.rst:343 +msgid "" +"Find the first superclass whose module was created from the given :c:type:" +"`PyModuleDef` *def*, or whose :ref:`module token ` is " +"equal to *def*, and return that module." +msgstr "" + +#: ../../c-api/type.rst:347 +msgid "" +"Note that modules created from a :c:type:`PyModuleDef` always have their " +"token set to the :c:type:`PyModuleDef`'s address. In other words, this " +"function is equivalent to :c:func:`PyType_GetModuleByToken`, except that it:" +msgstr "" + +#: ../../c-api/type.rst:352 +msgid "returns a borrowed reference, and" +msgstr "" + +#: ../../c-api/type.rst:353 +msgid "" +"has a non-``void*`` argument type (which is a cosmetic difference in C)." +msgstr "" + +#: ../../c-api/type.rst:364 msgid "" "Find the first superclass in *type*'s :term:`method resolution order` whose :" -"c:macro:`Py_tp_token` token is equal to the given one." +"c:macro:`Py_tp_token` token is equal to *tp_token*." msgstr "" -#: ../../c-api/type.rst:336 +#: ../../c-api/type.rst:367 msgid "" "If found, set *\\*result* to a new :term:`strong reference` to it and return " "``1``." msgstr "" -#: ../../c-api/type.rst:338 +#: ../../c-api/type.rst:369 msgid "If not found, set *\\*result* to ``NULL`` and return ``0``." msgstr "如果沒找到,則將 *\\*result* 設為 ``NULL`` 並回傳 ``0``。" -#: ../../c-api/type.rst:339 +#: ../../c-api/type.rst:370 msgid "" "On error, set *\\*result* to ``NULL`` and return ``-1`` with an exception " "set." msgstr "" "在發生錯誤時,將 *\\*result* 設為 ``NULL`` 並回傳 ``-1``,同時設定例外。" -#: ../../c-api/type.rst:342 +#: ../../c-api/type.rst:373 msgid "" "The *result* argument may be ``NULL``, in which case *\\*result* is not set. " "Use this if you need only the return value." @@ -390,86 +436,55 @@ msgstr "" "如果 *result* 引數為 ``NULL``,則不會設定 *\\*result*。如果你只需要回傳值,請" "使用此選項。" -#: ../../c-api/type.rst:345 -msgid "The *token* argument may not be ``NULL``." -msgstr "*token* 引數不可為 ``NULL``。" +#: ../../c-api/type.rst:376 +msgid "The *tp_token* argument may not be ``NULL``." +msgstr "*tp_token* 引數不可為 ``NULL``。" -#: ../../c-api/type.rst:352 +#: ../../c-api/type.rst:383 msgid "Attempt to assign a version tag to the given type." msgstr "" -#: ../../c-api/type.rst:354 +#: ../../c-api/type.rst:385 msgid "" "Returns 1 if the type already had a valid version tag or a new one was " "assigned, or 0 if a new tag could not be assigned." msgstr "" -#: ../../c-api/type.rst:362 +#: ../../c-api/type.rst:393 msgid "" "Return true if instances of *type* support creating weak references, false " "otherwise. This function always succeeds. *type* must not be ``NULL``." msgstr "" -#: ../../c-api/type.rst:366 +#: ../../c-api/type.rst:397 msgid ":ref:`weakrefobjects`" msgstr ":ref:`weakrefobjects`" -#: ../../c-api/type.rst:367 +#: ../../c-api/type.rst:398 msgid ":py:mod:`weakref`" msgstr ":py:mod:`weakref`" -#: ../../c-api/type.rst:371 +#: ../../c-api/type.rst:404 msgid "Creating Heap-Allocated Types" msgstr "" -#: ../../c-api/type.rst:373 -msgid "" -"The following functions and structs are used to create :ref:`heap types " -"`." -msgstr "" - -#: ../../c-api/type.rst:378 -msgid "" -"Create and return a :ref:`heap type ` from the *spec* (see :c:" -"macro:`Py_TPFLAGS_HEAPTYPE`)." -msgstr "" - -#: ../../c-api/type.rst:381 -msgid "" -"The metaclass *metaclass* is used to construct the resulting type object. " -"When *metaclass* is ``NULL``, the metaclass is derived from *bases* (or " -"*Py_tp_base[s]* slots if *bases* is ``NULL``, see below)." -msgstr "" - -#: ../../c-api/type.rst:385 -msgid "" -"Metaclasses that override :c:member:`~PyTypeObject.tp_new` are not " -"supported, except if ``tp_new`` is ``NULL``." -msgstr "" - -#: ../../c-api/type.rst:388 +#: ../../c-api/type.rst:406 msgid "" -"The *bases* argument can be used to specify base classes; it can either be " -"only one class or a tuple of classes. If *bases* is ``NULL``, the :c:data:" -"`Py_tp_bases` slot is used instead. If that also is ``NULL``, the :c:data:" -"`Py_tp_base` slot is used instead. If that also is ``NULL``, the new type " -"derives from :class:`object`." +"The following function is used to create :ref:`heap types `:" msgstr "" -#: ../../c-api/type.rst:394 +#: ../../c-api/type.rst:410 msgid "" -"The *module* argument can be used to record the module in which the new " -"class is defined. It must be a module object or ``NULL``. If not ``NULL``, " -"the module is associated with the new type and can later be retrieved with :" -"c:func:`PyType_GetModule`. The associated module is not inherited by " -"subclasses; it must be specified for each class individually." +"Create and return a :ref:`heap type ` from a :c:type:`!PySlot` " +"array. See :ref:`capi-slots` for general information on slots, and :ref:" +"`pyslot_type_slot_ids` for slots specific to type creation." msgstr "" -#: ../../c-api/type.rst:401 +#: ../../c-api/type.rst:415 ../../c-api/type.rst:819 msgid "This function calls :c:func:`PyType_Ready` on the new type." msgstr "" -#: ../../c-api/type.rst:403 +#: ../../c-api/type.rst:417 msgid "" "Note that this function does *not* fully match the behavior of calling :py:" "class:`type() ` or using the :keyword:`class` statement. With user-" @@ -478,7 +493,7 @@ msgid "" "Specifically:" msgstr "" -#: ../../c-api/type.rst:410 +#: ../../c-api/type.rst:424 msgid "" ":py:meth:`~object.__new__` is not called on the new class (and it must be " "set to ``type.__new__``)." @@ -486,320 +501,521 @@ msgstr "" ":py:meth:`~object.__new__` 不會在新類別上被呼叫(且它必須被設為 ``type." "__new__``)。" -#: ../../c-api/type.rst:412 +#: ../../c-api/type.rst:426 msgid ":py:meth:`~object.__init__` is not called on the new class." msgstr ":py:meth:`~object.__init__` 不會在新類別上被呼叫。" -#: ../../c-api/type.rst:413 +#: ../../c-api/type.rst:427 msgid ":py:meth:`~object.__init_subclass__` is not called on any bases." msgstr ":py:meth:`~object.__init_subclass__` 不會在任何基底上被呼叫。" -#: ../../c-api/type.rst:414 +#: ../../c-api/type.rst:428 msgid ":py:meth:`~object.__set_name__` is not called on new descriptors." msgstr ":py:meth:`~object.__set_name__` 不會在新的描述器上被呼叫。" -#: ../../c-api/type.rst:421 -msgid "Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``." -msgstr "等價於 ``PyType_FromMetaclass(NULL, module, spec, bases)``。" - -#: ../../c-api/type.rst:427 +#: ../../c-api/type.rst:430 +msgid "" +"Slots are typically defined as a global static constant arrays. However, " +"sometimes slot values are not statically known at compile time. For example, " +"slots like :c:data:`Py_tp_bases`, :c:data:`Py_tp_metaclass` and :c:data:" +"`Py_tp_module` require live Python objects. In this case, it is recommended " +"to put such slots on the stack, and use :c:macro:`Py_slot_subslots` to refer " +"to an array of static slots. For example::" +msgstr "" + +#: ../../c-api/type.rst:438 +msgid "" +"static const PySlot my_slots[] = {\n" +" PySlot_STATIC_DATA(Py_tp_name, \"MyClass\"),\n" +" PySlot_FUNC(Py_tp_repr, my_repr_func),\n" +" ...\n" +" PySlot_END\n" +"};\n" +"\n" +"PyObject *make_my_class(PyObject *module) {\n" +" PySlot all_slots[] = {\n" +" PySlot_STATIC_DATA(Py_slot_subslots, my_slots),\n" +" PySlot_DATA(Py_tp_module, module),\n" +" PySlot_END\n" +" };\n" +" return PyType_FromSlots(all_slots);\n" +"}" +msgstr "" +"static const PySlot my_slots[] = {\n" +" PySlot_STATIC_DATA(Py_tp_name, \"MyClass\"),\n" +" PySlot_FUNC(Py_tp_repr, my_repr_func),\n" +" ...\n" +" PySlot_END\n" +"};\n" +"\n" +"PyObject *make_my_class(PyObject *module) {\n" +" PySlot all_slots[] = {\n" +" PySlot_STATIC_DATA(Py_slot_subslots, my_slots),\n" +" PySlot_DATA(Py_tp_module, module),\n" +" PySlot_END\n" +" };\n" +" return PyType_FromSlots(all_slots);\n" +"}" + +#: ../../c-api/type.rst:454 +msgid "" +"Heap types created without the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag may " +"be modified, for example by setting attributes on them, as with classes " +"defined in Python code. Sometimes, such modifications are necessary to fully " +"initialize a type, but you may wish to prevent users from changing the type " +"after the initialization is done:" +msgstr "" + +#: ../../c-api/type.rst:463 msgid "" -"The function now accepts a single class as the *bases* argument and ``NULL`` " -"as the ``tp_doc`` slot." +"Make a type immutable: set the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag." msgstr "" -#: ../../c-api/type.rst:432 ../../c-api/type.rst:454 -msgid "" -"The function now finds and uses a metaclass corresponding to the provided " -"base classes. Previously, only :class:`type` instances were returned." +#: ../../c-api/type.rst:465 +msgid "All base classes of *type* must be immutable." +msgstr "所有 *type* 的基底類別都必須是不可變的。" + +#: ../../c-api/type.rst:467 +msgid "On success, return ``0``. On error, set an exception and return ``-1``." msgstr "" -#: ../../c-api/type.rst:435 ../../c-api/type.rst:457 ../../c-api/type.rst:478 +#: ../../c-api/type.rst:470 msgid "" -"The :c:member:`~PyTypeObject.tp_new` of the metaclass is *ignored*. which " -"may result in incomplete initialization. Creating classes whose metaclass " -"overrides :c:member:`~PyTypeObject.tp_new` is deprecated." +"The type must not be used before it's made immutable. For example, type " +"instances must not be created before the type is made immutable." msgstr "" -#: ../../c-api/type.rst:442 ../../c-api/type.rst:464 ../../c-api/type.rst:485 +#: ../../c-api/type.rst:479 +msgid "Type slot IDs" +msgstr "" + +#: ../../c-api/type.rst:481 msgid "" -"Creating classes whose metaclass overrides :c:member:`~PyTypeObject.tp_new` " -"is no longer allowed." +"Most type slot IDs are named like the field names of the structures :c:type:" +"`PyTypeObject`, :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, :c:" +"type:`PyMappingMethods` and :c:type:`PyAsyncMethods` with an added ``Py_`` " +"prefix. For example, use:" msgstr "" -#: ../../c-api/type.rst:448 -msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``." -msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, bases)``。" +#: ../../c-api/type.rst:487 +msgid ":c:data:`Py_tp_dealloc` to set :c:member:`PyTypeObject.tp_dealloc`" +msgstr ":c:data:`Py_tp_dealloc` 以設定 :c:member:`PyTypeObject.tp_dealloc`" -#: ../../c-api/type.rst:470 -msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``." -msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``。" +#: ../../c-api/type.rst:488 +msgid ":c:data:`Py_nb_add` to set :c:member:`PyNumberMethods.nb_add`" +msgstr ":c:data:`Py_nb_add` 以設定 :c:member:`PyNumberMethods.nb_add`" -#: ../../c-api/type.rst:474 -msgid "" -"The function now finds and uses a metaclass corresponding to the base " -"classes provided in *Py_tp_base[s]* slots. Previously, only :class:`type` " -"instances were returned." -msgstr "" +#: ../../c-api/type.rst:489 +msgid ":c:data:`Py_sq_length` to set :c:member:`PySequenceMethods.sq_length`" +msgstr ":c:data:`Py_sq_length` 以設定 :c:member:`PySequenceMethods.sq_length`" #: ../../c-api/type.rst:491 msgid "" -"Make a type immutable: set the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag." +"The following slots need additional considerations when specified as slots:" msgstr "" #: ../../c-api/type.rst:493 -msgid "All base classes of *type* must be immutable." -msgstr "所有 *type* 的基底類別都必須是不可變的。" +msgid ":c:data:`Py_tp_name`" +msgstr ":c:data:`Py_tp_name`" -#: ../../c-api/type.rst:495 -msgid "On success, return ``0``. On error, set an exception and return ``-1``." +#: ../../c-api/type.rst:494 +msgid ":c:data:`Py_tp_basicsize` and :c:data:`Py_tp_extra_basicsize`" msgstr "" +#: ../../c-api/type.rst:495 +msgid ":c:data:`Py_tp_itemsize`" +msgstr ":c:data:`Py_tp_itemsize`" + +#: ../../c-api/type.rst:496 +msgid ":c:data:`Py_tp_flags`" +msgstr ":c:data:`Py_tp_flags`" + #: ../../c-api/type.rst:498 msgid "" -"The type must not be used before it's made immutable. For example, type " -"instances must not be created before the type is made immutable." +"Additional slots do not directly correspond to a :c:type:`!PyTypeObject` " +"struct field:" msgstr "" -#: ../../c-api/type.rst:514 -msgid "Structure defining a type's behavior." +#: ../../c-api/type.rst:501 +msgid ":c:data:`Py_tp_token`" +msgstr ":c:data:`Py_tp_token`" + +#: ../../c-api/type.rst:502 +msgid ":c:data:`Py_tp_metaclass`" +msgstr ":c:data:`Py_tp_metaclass`" + +#: ../../c-api/type.rst:503 +msgid ":c:data:`Py_tp_module`" +msgstr ":c:data:`Py_tp_module`" + +#: ../../c-api/type.rst:505 +msgid "" +"The following “offset” fields cannot be set using :c:type:`PyType_Slot`:" msgstr "" -#: ../../c-api/type.rst:518 -msgid "Name of the type, used to set :c:member:`PyTypeObject.tp_name`." +#: ../../c-api/type.rst:507 +msgid "" +":c:member:`~PyTypeObject.tp_weaklistoffset` (use :c:macro:" +"`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)" msgstr "" +":c:member:`~PyTypeObject.tp_weaklistoffset`\\ (如果可能,請改用 :c:macro:" +"`Py_TPFLAGS_MANAGED_WEAKREF`)" -#: ../../c-api/type.rst:522 +#: ../../c-api/type.rst:509 msgid "" -"If positive, specifies the size of the instance in bytes. It is used to set :" -"c:member:`PyTypeObject.tp_basicsize`." +":c:member:`~PyTypeObject.tp_dictoffset` (use :c:macro:" +"`Py_TPFLAGS_MANAGED_DICT` instead if possible)" msgstr "" +":c:member:`~PyTypeObject.tp_dictoffset`\\ (如果可能,請改用 :c:macro:" +"`Py_TPFLAGS_MANAGED_DICT`)" -#: ../../c-api/type.rst:525 +#: ../../c-api/type.rst:511 msgid "" -"If zero, specifies that :c:member:`~PyTypeObject.tp_basicsize` should be " -"inherited." +":c:member:`~PyTypeObject.tp_vectorcall_offset` (use " +"``\"__vectorcalloffset__\"`` in :ref:`PyMemberDef `)" msgstr "" +":c:member:`~PyTypeObject.tp_vectorcall_offset`\\ (請用 :ref:`PyMemberDef " +"` 中的 ``\"__vectorcalloffset__\"``)" -#: ../../c-api/type.rst:528 +#: ../../c-api/type.rst:514 msgid "" -"If negative, the absolute value specifies how much space instances of the " -"class need *in addition* to the superclass. Use :c:func:" -"`PyObject_GetTypeData` to get a pointer to subclass-specific memory reserved " -"this way. For negative :c:member:`!basicsize`, Python will insert padding " -"when needed to meet :c:member:`~PyTypeObject.tp_basicsize`'s alignment " -"requirements." +"If it is not possible to switch to a ``MANAGED`` flag (for example, for " +"vectorcall or to support Python older than 3.12), specify the offset in :c:" +"data:`Py_tp_members`. See :ref:`PyMemberDef documentation ` for details." msgstr "" -#: ../../c-api/type.rst:538 -msgid "Previously, this field could not be negative." -msgstr "在過去此欄位不可為負值。" +#: ../../c-api/type.rst:520 +msgid "" +"The following internal fields cannot be set at all when creating a heap type:" +msgstr "" -#: ../../c-api/type.rst:542 +#: ../../c-api/type.rst:523 msgid "" -"Size of one element of a variable-size type, in bytes. Used to set :c:member:" -"`PyTypeObject.tp_itemsize`. See ``tp_itemsize`` documentation for caveats." +":c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject.tp_mro`, :c:" +"member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject.tp_subclasses`, " +"and :c:member:`~PyTypeObject.tp_weaklist`." msgstr "" -#: ../../c-api/type.rst:546 +#: ../../c-api/type.rst:529 msgid "" -"If zero, :c:member:`~PyTypeObject.tp_itemsize` is inherited. Extending " -"arbitrary variable-sized classes is dangerous, since some types use a fixed " -"offset for variable-sized memory, which can then overlap fixed-sized memory " -"used by a subclass. To help prevent mistakes, inheriting ``itemsize`` is " -"only possible in the following situations:" +"The :c:data:`Py_tp_base` slot is equivalent to :c:data:`Py_tp_bases`; both " +"may be set either to a type or a tuple of types. If both are specified, the " +"value of :c:data:`Py_tp_bases` is used." msgstr "" -#: ../../c-api/type.rst:553 +#: ../../c-api/type.rst:534 +msgid "Slot values may not be ``NULL``, except for the following:" +msgstr "" + +#: ../../c-api/type.rst:536 +msgid ":c:data:`Py_tp_doc`" +msgstr ":c:data:`Py_tp_doc`" + +#: ../../c-api/type.rst:537 msgid "" -"The base is not variable-sized (its :c:member:`~PyTypeObject.tp_itemsize` is " -"zero)." +":c:data:`Py_tp_token` (for clarity, prefer :c:data:`Py_TP_USE_SPEC` rather " +"than ``NULL``)" msgstr "" -#: ../../c-api/type.rst:555 +#: ../../c-api/type.rst:540 +msgid "Slots in :c:type:`PyBufferProcs` may be set in the unlimited API." +msgstr "" + +#: ../../c-api/type.rst:543 msgid "" -"The requested :c:member:`PyType_Spec.basicsize` is positive, suggesting that " -"the memory layout of the base class is known." +":c:member:`~PyBufferProcs.bf_getbuffer` and :c:member:`~PyBufferProcs." +"bf_releasebuffer` are now available under the :ref:`limited API `." msgstr "" -#: ../../c-api/type.rst:557 +#: ../../c-api/type.rst:548 msgid "" -"The requested :c:member:`PyType_Spec.basicsize` is zero, suggesting that the " -"subclass does not access the instance's memory directly." +"The field :c:member:`~PyTypeObject.tp_vectorcall` can now be set using :c:" +"data:`Py_tp_vectorcall`. See the field's documentation for details." msgstr "" -#: ../../c-api/type.rst:560 -msgid "With the :c:macro:`Py_TPFLAGS_ITEMS_AT_END` flag." +#: ../../c-api/type.rst:553 +msgid "" +"The :c:data:`Py_tp_bases` slot may be set to a single type object, making it " +"equivalent to the :c:data:`Py_tp_base` slot. Previously, a tuple of types " +"was required." msgstr "" -#: ../../c-api/type.rst:564 -msgid "Type flags, used to set :c:member:`PyTypeObject.tp_flags`." +#: ../../c-api/type.rst:558 +msgid "" +"The following slots correspond to fields in the underlying type structure, " +"but need extra remarks for use as slots:" +msgstr "" + +#: ../../c-api/type.rst:563 +msgid "" +":c:member:`Slot ID ` for the name of the type, used to set :c:" +"member:`PyTypeObject.tp_name`." msgstr "" #: ../../c-api/type.rst:566 msgid "" -"If the ``Py_TPFLAGS_HEAPTYPE`` flag is not set, :c:func:" -"`PyType_FromSpecWithBases` sets it automatically." +"This slot (or :c:member:`PyType_Spec.name`) is required to create a type." msgstr "" -"如果未設定 ``Py_TPFLAGS_HEAPTYPE`` 旗標,則 :c:func:" -"`PyType_FromSpecWithBases` 會自動設定它。" -#: ../../c-api/type.rst:571 +#: ../../c-api/type.rst:568 msgid "" -"Array of :c:type:`PyType_Slot` structures. Terminated by the special slot " -"value ``{0, NULL}``." +"This may not be used in :c:member:`PyType_Spec.slots`. Use :c:member:" +"`PyType_Spec.name` instead." msgstr "" -#: ../../c-api/type.rst:574 -msgid "Each slot ID should be specified at most once." +#: ../../c-api/type.rst:573 +msgid "" +"CPython processes slots in order. It is recommended to put ``Py_tp_name`` at " +"the beginning of the slots array, so that if processing of a later slots " +"fails, error messages can include the name." msgstr "" -#: ../../c-api/type.rst:584 +#: ../../c-api/type.rst:582 msgid "" -"Structure defining optional functionality of a type, containing a slot ID " -"and a value pointer." +":c:member:`Slot ID ` for the size of the instance in bytes. It " +"is used to set :c:member:`PyTypeObject.tp_basicsize`." msgstr "" -#: ../../c-api/type.rst:589 -msgid "A slot ID." +#: ../../c-api/type.rst:585 ../../c-api/type.rst:632 +msgid "The value must be positive." msgstr "" -#: ../../c-api/type.rst:591 +#: ../../c-api/type.rst:587 msgid "" -"Slot IDs are named like the field names of the structures :c:type:" -"`PyTypeObject`, :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, :c:" -"type:`PyMappingMethods` and :c:type:`PyAsyncMethods` with an added ``Py_`` " -"prefix. For example, use:" +"This may not be used in :c:member:`PyType_Spec.slots`. Use :c:member:" +"`PyType_Spec.basicsize` instead." msgstr "" -#: ../../c-api/type.rst:597 -msgid ":c:data:`Py_tp_dealloc` to set :c:member:`PyTypeObject.tp_dealloc`" -msgstr ":c:data:`Py_tp_dealloc` 以設定 :c:member:`PyTypeObject.tp_dealloc`" +#: ../../c-api/type.rst:590 +msgid "" +"This slot may not be used with :c:func:`PyType_GetSlot`. Use :c:member:" +"`PyTypeObject.tp_basicsize` instead if needed, but be aware that a type's " +"size is often considered an implementation detail." +msgstr "" #: ../../c-api/type.rst:598 -msgid ":c:data:`Py_nb_add` to set :c:member:`PyNumberMethods.nb_add`" -msgstr ":c:data:`Py_nb_add` 以設定 :c:member:`PyNumberMethods.nb_add`" +msgid "" +":c:member:`Slot ID ` for type data size in bytes, that is, how " +"much space instances of the class need *in addition* to space needed for " +"superclasses." +msgstr "" -#: ../../c-api/type.rst:599 -msgid ":c:data:`Py_sq_length` to set :c:member:`PySequenceMethods.sq_length`" -msgstr ":c:data:`Py_sq_length` 以設定 :c:member:`PySequenceMethods.sq_length`" +#: ../../c-api/type.rst:602 +msgid "" +"The value is used, together with the size of superclasses, to set :c:member:" +"`PyTypeObject.tp_basicsize`. Python will insert padding as needed to meet :c:" +"member:`!tp_basicsize`'s alignment requirements." +msgstr "" -#: ../../c-api/type.rst:601 +#: ../../c-api/type.rst:607 msgid "" -"An additional slot is supported that does not correspond to a :c:type:`!" -"PyTypeObject` struct field:" +"Use :c:func:`PyObject_GetTypeData` to get a pointer to subclass-specific " +"memory reserved this way." msgstr "" -#: ../../c-api/type.rst:604 -msgid ":c:data:`Py_tp_token`" -msgstr ":c:data:`Py_tp_token`" +#: ../../c-api/type.rst:610 +msgid "" +"The value must be positive. To specify that instances need no additional " +"size (that is, size should be inherited), omit the :c:macro:`!" +"Py_tp_extra_basicsize` slot rather than set it to zero." +msgstr "" -#: ../../c-api/type.rst:606 +#: ../../c-api/type.rst:615 msgid "" -"The following “offset” fields cannot be set using :c:type:`PyType_Slot`:" +"Specifying both :c:macro:`Py_tp_basicsize` and :c:macro:`!" +"Py_tp_extra_basicsize` is an error." msgstr "" -#: ../../c-api/type.rst:608 +#: ../../c-api/type.rst:618 ../../c-api/type.rst:665 msgid "" -":c:member:`~PyTypeObject.tp_weaklistoffset` (use :c:macro:" -"`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)" +"This may not be used in :c:member:`PyType_Spec.slots`. Use negative :c:" +"member:`PyType_Spec.basicsize` instead." msgstr "" -":c:member:`~PyTypeObject.tp_weaklistoffset`\\ (如果可能,請改用 :c:macro:" -"`Py_TPFLAGS_MANAGED_WEAKREF`)" -#: ../../c-api/type.rst:610 +#: ../../c-api/type.rst:621 ../../c-api/type.rst:653 +msgid "This slot may not be used with :c:func:`PyType_GetSlot`." +msgstr "" + +#: ../../c-api/type.rst:627 msgid "" -":c:member:`~PyTypeObject.tp_dictoffset` (use :c:macro:" -"`Py_TPFLAGS_MANAGED_DICT` instead if possible)" +":c:member:`Slot ID ` for the size of one element of a variable-" +"size type, in bytes. Used to set :c:member:`PyTypeObject.tp_itemsize`. See :" +"c:member:`!tp_itemsize` documentation for caveats." msgstr "" -":c:member:`~PyTypeObject.tp_dictoffset`\\ (如果可能,請改用 :c:macro:" -"`Py_TPFLAGS_MANAGED_DICT`)" -#: ../../c-api/type.rst:612 +#: ../../c-api/type.rst:634 msgid "" -":c:member:`~PyTypeObject.tp_vectorcall_offset` (use " -"``\"__vectorcalloffset__\"`` in :ref:`PyMemberDef `)" +"If this slot is missing, :c:member:`~PyTypeObject.tp_itemsize` is inherited. " +"Extending arbitrary variable-sized classes is dangerous, since some types " +"use a fixed offset for variable-sized memory, which can then overlap fixed-" +"sized memory used by a subclass. To help prevent mistakes, inheriting " +"``itemsize`` is only possible in the following situations:" msgstr "" -":c:member:`~PyTypeObject.tp_vectorcall_offset`\\ (請用 :ref:`PyMemberDef " -"` 中的 ``\"__vectorcalloffset__\"``)" -#: ../../c-api/type.rst:616 +#: ../../c-api/type.rst:641 msgid "" -"If it is not possible to switch to a ``MANAGED`` flag (for example, for " -"vectorcall or to support Python older than 3.12), specify the offset in :c:" -"data:`Py_tp_members`. See :ref:`PyMemberDef documentation ` for details." +"The base is not variable-sized (its :c:member:`~PyTypeObject.tp_itemsize` is " +"zero)." msgstr "" -#: ../../c-api/type.rst:622 +#: ../../c-api/type.rst:643 msgid "" -"The following internal fields cannot be set at all when creating a heap type:" +"The requested :c:member:`PyType_Spec.basicsize` is positive, suggesting that " +"the memory layout of the base class is known." msgstr "" -#: ../../c-api/type.rst:625 +#: ../../c-api/type.rst:645 msgid "" -":c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject.tp_mro`, :c:" -"member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject.tp_subclasses`, " -"and :c:member:`~PyTypeObject.tp_weaklist`." +"The requested :c:member:`PyType_Spec.basicsize` is zero, suggesting that the " +"subclass does not access the instance's memory directly." +msgstr "" + +#: ../../c-api/type.rst:648 +msgid "With the :c:macro:`Py_TPFLAGS_ITEMS_AT_END` flag." msgstr "" -#: ../../c-api/type.rst:631 +#: ../../c-api/type.rst:650 msgid "" -"Setting :c:data:`Py_tp_bases` or :c:data:`Py_tp_base` may be problematic on " -"some platforms. To avoid issues, use the *bases* argument of :c:func:" -"`PyType_FromSpecWithBases` instead." +"This may not be used in :c:member:`PyType_Spec.slots`. Use :c:member:" +"`PyType_Spec.itemsize` instead." msgstr "" -#: ../../c-api/type.rst:636 -msgid "Slots in :c:type:`PyBufferProcs` may be set in the unlimited API." +#: ../../c-api/type.rst:659 +msgid "" +":c:member:`Slot ID ` for type flags, used to set :c:member:" +"`PyTypeObject.tp_flags`." msgstr "" +"用於型別旗標的 :c:member:`Slot ID `,用來設" +"定 :c:member:`PyTypeObject.tp_flags`。" -#: ../../c-api/type.rst:639 +#: ../../c-api/type.rst:662 msgid "" -":c:member:`~PyBufferProcs.bf_getbuffer` and :c:member:`~PyBufferProcs." -"bf_releasebuffer` are now available under the :ref:`limited API `." +"The ``Py_TPFLAGS_HEAPTYPE`` flag is not set, :c:func:" +"`PyType_FromSpecWithBases` sets it automatically." msgstr "" +"不需設定 ``Py_TPFLAGS_HEAPTYPE`` 旗標,:c:func:`PyType_FromSpecWithBases` 會" +"自動設定它。" -#: ../../c-api/type.rst:644 +#: ../../c-api/type.rst:668 msgid "" -"The field :c:member:`~PyTypeObject.tp_vectorcall` can now be set using :c:" -"data:`Py_tp_vectorcall`. See the field's documentation for details." +"This slot may not be used with :c:func:`PyType_GetSlot`. Use :c:func:" +"`PyType_GetFlags` instead." msgstr "" -#: ../../c-api/type.rst:651 +#: ../../c-api/type.rst:675 msgid "" -"The desired value of the slot. In most cases, this is a pointer to a " -"function." +":c:member:`Slot ID ` for type flags, used to set :c:member:" +"`PyTypeObject.tp_bases`." msgstr "" +"用於型別旗標的 :c:member:`Slot ID `,用來設" +"定 :c:member:`PyTypeObject.tp_bases`。" -#: ../../c-api/type.rst:654 -msgid "*pfunc* values may not be ``NULL``, except for the following slots:" +#: ../../c-api/type.rst:678 +msgid "" +"The slot can be set to a tuple of type objects which the newly created type " +"should inherit from, like the \"positional arguments\" of a Python :ref:" +"`class definition `." msgstr "" -#: ../../c-api/type.rst:656 -msgid ":c:data:`Py_tp_doc`" -msgstr ":c:data:`Py_tp_doc`" +#: ../../c-api/type.rst:682 +msgid "" +"Alternately, the slot can be set to a single type object to specify a single " +"base. The effect is the same as specifying a one-element tuple." +msgstr "" + +#: ../../c-api/type.rst:688 +msgid "Previously, :c:macro:`!Py_tp_bases` required a tuple of types." +msgstr "" -#: ../../c-api/type.rst:657 +#: ../../c-api/type.rst:692 msgid "" -":c:data:`Py_tp_token` (for clarity, prefer :c:data:`Py_TP_USE_SPEC` rather " -"than ``NULL``)" +"Equivalent to :c:macro:`Py_tp_bases` (with ``s`` at the end). If both are " +"specified, :c:macro:`!Py_tp_bases` takes priority and this slot is ignored." +msgstr "" + +#: ../../c-api/type.rst:698 +msgid "Previously, :c:macro:`!Py_tp_base` required a single type, not a tuple." +msgstr "" + +#: ../../c-api/type.rst:702 +msgid "" +"When not targeting older Python versions, prefer :c:macro:`!Py_tp_bases`." msgstr "" -#: ../../c-api/type.rst:663 +#: ../../c-api/type.rst:704 msgid "" -"A :c:member:`~PyType_Slot.slot` that records a static memory layout ID for a " -"class." +"The following slots do not correspond to public fields in the underlying " +"structures:" msgstr "" -#: ../../c-api/type.rst:666 +#: ../../c-api/type.rst:709 msgid "" -"If the :c:type:`PyType_Spec` of the class is statically allocated, the token " -"can be set to the spec using the special value :c:data:`Py_TP_USE_SPEC`:" +":c:member:`Slot ID ` for the metaclass used to construct the " +"resulting type object. When omitted the metaclass is derived from bases (:c:" +"macro:`Py_tp_bases` or the *bases* argument of :c:func:" +"`PyType_FromMetaclass`)." msgstr "" -#: ../../c-api/type.rst:670 +#: ../../c-api/type.rst:715 +msgid "" +"Metaclasses that override :c:member:`~PyTypeObject.tp_new` are not " +"supported, except if ``tp_new`` is ``NULL``." +msgstr "" + +#: ../../c-api/type.rst:718 +msgid "" +"This may not be used in :c:member:`PyType_Spec.slots`. Use :c:func:" +"`PyType_FromMetaclass` to specify a metaclass with :c:type:`!PyType_Spec`." +msgstr "" + +#: ../../c-api/type.rst:722 +msgid "" +"This slot may not be used with :c:func:`PyType_GetSlot`. Use :c:func:" +"`Py_TYPE` on the type object instead." +msgstr "" + +#: ../../c-api/type.rst:729 +msgid "" +":c:member:`Slot ID ` for recording the module in which the new " +"class is defined." +msgstr "" + +#: ../../c-api/type.rst:732 +msgid "" +"The value must be a module object. The module is associated with the new " +"type and can later be retrieved with :c:func:`PyType_GetModule`. The " +"associated module is not inherited by subclasses; it must be specified for " +"each class individually." +msgstr "" + +#: ../../c-api/type.rst:738 +msgid "" +"This may not be used in :c:member:`PyType_Spec.slots`. Use :c:func:" +"`PyType_FromMetaclass` to specify a module with :c:type:`!PyType_Spec`." +msgstr "" + +#: ../../c-api/type.rst:742 +msgid "" +"This slot may not be used with :c:func:`PyType_GetSlot`. Use :c:func:" +"`PyType_GetModule` instead." +msgstr "" + +#: ../../c-api/type.rst:749 +msgid "" +":c:member:`Slot ID ` for recording a static memory layout ID " +"for a class." +msgstr "" + +#: ../../c-api/type.rst:752 +msgid "" +"If the class is defined using a :c:type:`PyType_Spec`, and that spec is " +"statically allocated, the token can be set to the spec using the special " +"value :c:data:`Py_TP_USE_SPEC`:" +msgstr "" + +#: ../../c-api/type.rst:756 msgid "" "static PyType_Slot foo_slots[] = {\n" " {Py_tp_token, Py_TP_USE_SPEC}," @@ -807,38 +1023,239 @@ msgstr "" "static PyType_Slot foo_slots[] = {\n" " {Py_tp_token, Py_TP_USE_SPEC}," -#: ../../c-api/type.rst:675 +#: ../../c-api/type.rst:761 msgid "It can also be set to an arbitrary pointer, but you must ensure that:" msgstr "" -#: ../../c-api/type.rst:677 +#: ../../c-api/type.rst:763 msgid "" "The pointer outlives the class, so it's not reused for something else while " "the class exists." msgstr "" -#: ../../c-api/type.rst:679 +#: ../../c-api/type.rst:765 msgid "" "It \"belongs\" to the extension module where the class lives, so it will not " "clash with other extensions." msgstr "" -#: ../../c-api/type.rst:682 +#: ../../c-api/type.rst:768 msgid "" "Use :c:func:`PyType_GetBaseByToken` to check if a class's superclass has a " "given token -- that is, check whether the memory layout is compatible." msgstr "" -#: ../../c-api/type.rst:685 +#: ../../c-api/type.rst:771 msgid "" "To get the token for a given class (without considering superclasses), use :" "c:func:`PyType_GetSlot` with ``Py_tp_token``." msgstr "" -#: ../../c-api/type.rst:694 +#: ../../c-api/type.rst:780 msgid "" "Used as a value with :c:data:`Py_tp_token` to set the token to the class's :" -"c:type:`PyType_Spec`. Expands to ``NULL``." +"c:type:`PyType_Spec`. May only be used for classes defined using :c:type:`!" +"PyType_Spec`." +msgstr "" + +#: ../../c-api/type.rst:784 +msgid "Expands to ``NULL``." +msgstr "" + +#: ../../c-api/type.rst:790 +msgid "" +":c:member:`Slot ID ` that works like :c:macro:" +"`Py_slot_subslots`, except it specifies an array of :c:type:`PyType_Slot` " +"structures." +msgstr "" + +#: ../../c-api/type.rst:798 +msgid "Soft-deprecated API" +msgstr "軟性棄用的 API" + +#: ../../c-api/type.rst:800 +msgid "" +"The following functions are :term:`soft deprecated`. They will continue to " +"work, but new features will be added as slots for :c:func:" +"`PyType_FromSlots`, not as arguments to new ``PyType_From*`` functions." +msgstr "" + +#: ../../c-api/type.rst:806 +msgid "" +"Create and return a :ref:`heap type ` from the *spec* (see :c:" +"macro:`Py_TPFLAGS_HEAPTYPE`)." +msgstr "" + +#: ../../c-api/type.rst:809 +msgid "" +"A non-``NULL`` *metaclass* argument corresponds to the :c:macro:" +"`Py_tp_metaclass` slot." +msgstr "" + +#: ../../c-api/type.rst:812 +msgid "" +"A non-``NULL`` *bases* argument corresponds to the :c:data:`Py_tp_bases` " +"slot, and takes precedence over :c:data:`Py_tp_bases` and :c:data:" +"`Py_tp_bases` slots." +msgstr "" + +#: ../../c-api/type.rst:816 +msgid "" +"A non-``NULL`` *module* argument corresponds to the :c:macro:`Py_tp_module` " +"slot." +msgstr "" + +#: ../../c-api/type.rst:821 +msgid "" +"Note that this function does *not* fully match the behavior of calling :py:" +"class:`type() ` or using the :keyword:`class` statement. See the note " +"in :c:func:`PyType_FromSlots` documentation for details." +msgstr "" + +#: ../../c-api/type.rst:829 ../../c-api/type.rst:860 ../../c-api/type.rst:886 +#: ../../c-api/type.rst:911 +msgid "Prefer :c:func:`PyType_FromSlots` in new code." +msgstr "" + +#: ../../c-api/type.rst:834 +msgid "Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``." +msgstr "等價於 ``PyType_FromMetaclass(NULL, module, spec, bases)``。" + +#: ../../c-api/type.rst:840 +msgid "" +"The function now accepts a single class as the *bases* argument and ``NULL`` " +"as the ``tp_doc`` slot." +msgstr "" + +#: ../../c-api/type.rst:845 ../../c-api/type.rst:871 +msgid "" +"The function now finds and uses a metaclass corresponding to the provided " +"base classes. Previously, only :class:`type` instances were returned." +msgstr "" + +#: ../../c-api/type.rst:848 ../../c-api/type.rst:874 ../../c-api/type.rst:899 +msgid "" +"The :c:member:`~PyTypeObject.tp_new` of the metaclass is *ignored*. which " +"may result in incomplete initialization. Creating classes whose metaclass " +"overrides :c:member:`~PyTypeObject.tp_new` is deprecated." +msgstr "" + +#: ../../c-api/type.rst:855 ../../c-api/type.rst:881 ../../c-api/type.rst:906 +msgid "" +"Creating classes whose metaclass overrides :c:member:`~PyTypeObject.tp_new` " +"is no longer allowed." +msgstr "" + +#: ../../c-api/type.rst:865 +msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``." +msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, bases)``。" + +#: ../../c-api/type.rst:891 +msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``." +msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``。" + +#: ../../c-api/type.rst:895 +msgid "" +"The function now finds and uses a metaclass corresponding to the base " +"classes provided in *Py_tp_base[s]* slots. Previously, only :class:`type` " +"instances were returned." +msgstr "" + +#: ../../c-api/type.rst:924 +msgid "" +"Structure defining a type's behavior, used for soft-deprecated functions " +"like :c:func:`PyType_FromMetaclass`." +msgstr "" + +#: ../../c-api/type.rst:927 +msgid "" +"This structure contains several members that can instead be specified as :" +"ref:`slots ` for :c:func:`PyType_FromSlots`, and an " +"array of slot entries with a simpler structure." +msgstr "" + +#: ../../c-api/type.rst:933 +msgid "Corresponds to :c:macro:`Py_tp_name`." +msgstr "" + +#: ../../c-api/type.rst:937 +msgid "If positive, corresponds to :c:macro:`Py_tp_basicsize`." +msgstr "" + +#: ../../c-api/type.rst:939 +msgid "" +"If negative, corresponds to :c:macro:`Py_tp_extra_basicsize` set to the " +"absolute value." +msgstr "" + +#: ../../c-api/type.rst:944 +msgid "Previously, this field could not be negative." +msgstr "在過去此欄位不可為負值。" + +#: ../../c-api/type.rst:948 +msgid "Corresponds to :c:macro:`Py_tp_itemsize`." +msgstr "" + +#: ../../c-api/type.rst:952 +msgid "Corresponds to :c:macro:`Py_tp_flags`." +msgstr "" + +#: ../../c-api/type.rst:956 +msgid "Array of :c:type:`PyType_Slot` (not :c:type:`PySlot`) structures." +msgstr "" + +#: ../../c-api/type.rst:958 +msgid "" +"Terminated by the special slot value ``{0, NULL}``. Each slot ID should be " +"specified at most once." +msgstr "" + +#: ../../c-api/type.rst:971 +msgid "" +"Structure defining optional functionality of a type, used for soft-" +"deprecated functions like :c:func:`PyType_FromMetaclass`." +msgstr "" + +#: ../../c-api/type.rst:974 +msgid "" +"Note that a :c:type:`!PyType_Slot` array may be included in a :c:type:`!" +"PySlot` array using :c:macro:`Py_tp_slots`, and vice versa using :c:macro:" +"`Py_slot_subslots`." +msgstr "" + +#: ../../c-api/type.rst:978 +msgid "" +"Each :c:type:`!PyType_Slot` structure ``tpslot`` is interpreted as the " +"following :c:type:`PySlot` structure::" +msgstr "" + +#: ../../c-api/type.rst:981 +msgid "" +"(PySlot){\n" +" .sl_id=tpslot.slot,\n" +" .sl_flags=PySlot_INTPTR | sub_static,\n" +" .sl_ptr=tpslot.func\n" +"}" +msgstr "" +"(PySlot){\n" +" .sl_id=tpslot.slot,\n" +" .sl_flags=PySlot_INTPTR | sub_static,\n" +" .sl_ptr=tpslot.func\n" +"}" + +#: ../../c-api/type.rst:987 +msgid "" +"where ``sub_static`` is ``PySlot_STATIC`` if the slot requires the flag " +"(such as for :c:macro:`Py_tp_methods`), or if this flag is present on the " +"\"parent\" :c:macro:`!Py_tp_slots` slot (if any)." +msgstr "" + +#: ../../c-api/type.rst:993 +msgid "Corresponds to :c:member:`PySlot.sl_id`." +msgstr "" + +#: ../../c-api/type.rst:997 +msgid "Corresponds to :c:member:`PySlot.sl_ptr`." msgstr "" #: ../../c-api/type.rst:8 diff --git a/c-api/typeobj.po b/c-api/typeobj.po index 6645ee2b964..83f150dcf13 100644 --- a/c-api/typeobj.po +++ b/c-api/typeobj.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:33+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1313,43 +1313,43 @@ msgid "" msgstr "" #: ../../c-api/typeobj.rst:504 ../../c-api/typeobj.rst:527 -#: ../../c-api/typeobj.rst:543 ../../c-api/typeobj.rst:587 -#: ../../c-api/typeobj.rst:665 ../../c-api/typeobj.rst:809 -#: ../../c-api/typeobj.rst:854 ../../c-api/typeobj.rst:873 -#: ../../c-api/typeobj.rst:892 ../../c-api/typeobj.rst:910 -#: ../../c-api/typeobj.rst:936 ../../c-api/typeobj.rst:953 -#: ../../c-api/typeobj.rst:965 ../../c-api/typeobj.rst:977 -#: ../../c-api/typeobj.rst:1012 ../../c-api/typeobj.rst:1036 -#: ../../c-api/typeobj.rst:1058 ../../c-api/typeobj.rst:1081 -#: ../../c-api/typeobj.rst:1109 ../../c-api/typeobj.rst:1128 -#: ../../c-api/typeobj.rst:1144 ../../c-api/typeobj.rst:1184 -#: ../../c-api/typeobj.rst:1195 ../../c-api/typeobj.rst:1205 -#: ../../c-api/typeobj.rst:1215 ../../c-api/typeobj.rst:1229 -#: ../../c-api/typeobj.rst:1247 ../../c-api/typeobj.rst:1270 -#: ../../c-api/typeobj.rst:1288 ../../c-api/typeobj.rst:1301 -#: ../../c-api/typeobj.rst:1323 ../../c-api/typeobj.rst:1370 -#: ../../c-api/typeobj.rst:1396 ../../c-api/typeobj.rst:1415 -#: ../../c-api/typeobj.rst:1445 ../../c-api/typeobj.rst:1467 -#: ../../c-api/typeobj.rst:1505 ../../c-api/typeobj.rst:1517 -#: ../../c-api/typeobj.rst:1543 ../../c-api/typeobj.rst:1641 -#: ../../c-api/typeobj.rst:1787 ../../c-api/typeobj.rst:1854 -#: ../../c-api/typeobj.rst:1890 ../../c-api/typeobj.rst:1917 -#: ../../c-api/typeobj.rst:1943 ../../c-api/typeobj.rst:1958 -#: ../../c-api/typeobj.rst:1975 ../../c-api/typeobj.rst:1991 -#: ../../c-api/typeobj.rst:2023 ../../c-api/typeobj.rst:2055 -#: ../../c-api/typeobj.rst:2083 ../../c-api/typeobj.rst:2103 -#: ../../c-api/typeobj.rst:2132 ../../c-api/typeobj.rst:2178 -#: ../../c-api/typeobj.rst:2197 ../../c-api/typeobj.rst:2239 -#: ../../c-api/typeobj.rst:2264 ../../c-api/typeobj.rst:2304 -#: ../../c-api/typeobj.rst:2334 ../../c-api/typeobj.rst:2347 -#: ../../c-api/typeobj.rst:2357 ../../c-api/typeobj.rst:2374 -#: ../../c-api/typeobj.rst:2391 ../../c-api/typeobj.rst:2407 -#: ../../c-api/typeobj.rst:2551 ../../c-api/typeobj.rst:2611 +#: ../../c-api/typeobj.rst:543 ../../c-api/typeobj.rst:590 +#: ../../c-api/typeobj.rst:672 ../../c-api/typeobj.rst:816 +#: ../../c-api/typeobj.rst:861 ../../c-api/typeobj.rst:880 +#: ../../c-api/typeobj.rst:899 ../../c-api/typeobj.rst:917 +#: ../../c-api/typeobj.rst:943 ../../c-api/typeobj.rst:960 +#: ../../c-api/typeobj.rst:972 ../../c-api/typeobj.rst:984 +#: ../../c-api/typeobj.rst:1019 ../../c-api/typeobj.rst:1043 +#: ../../c-api/typeobj.rst:1065 ../../c-api/typeobj.rst:1088 +#: ../../c-api/typeobj.rst:1116 ../../c-api/typeobj.rst:1135 +#: ../../c-api/typeobj.rst:1154 ../../c-api/typeobj.rst:1194 +#: ../../c-api/typeobj.rst:1205 ../../c-api/typeobj.rst:1215 +#: ../../c-api/typeobj.rst:1225 ../../c-api/typeobj.rst:1239 +#: ../../c-api/typeobj.rst:1257 ../../c-api/typeobj.rst:1280 +#: ../../c-api/typeobj.rst:1298 ../../c-api/typeobj.rst:1313 +#: ../../c-api/typeobj.rst:1348 ../../c-api/typeobj.rst:1395 +#: ../../c-api/typeobj.rst:1421 ../../c-api/typeobj.rst:1440 +#: ../../c-api/typeobj.rst:1470 ../../c-api/typeobj.rst:1492 +#: ../../c-api/typeobj.rst:1530 ../../c-api/typeobj.rst:1542 +#: ../../c-api/typeobj.rst:1568 ../../c-api/typeobj.rst:1582 +#: ../../c-api/typeobj.rst:1728 ../../c-api/typeobj.rst:1795 +#: ../../c-api/typeobj.rst:1831 ../../c-api/typeobj.rst:1858 +#: ../../c-api/typeobj.rst:1884 ../../c-api/typeobj.rst:1899 +#: ../../c-api/typeobj.rst:1916 ../../c-api/typeobj.rst:1932 +#: ../../c-api/typeobj.rst:1964 ../../c-api/typeobj.rst:1996 +#: ../../c-api/typeobj.rst:2024 ../../c-api/typeobj.rst:2044 +#: ../../c-api/typeobj.rst:2073 ../../c-api/typeobj.rst:2119 +#: ../../c-api/typeobj.rst:2138 ../../c-api/typeobj.rst:2180 +#: ../../c-api/typeobj.rst:2205 ../../c-api/typeobj.rst:2245 +#: ../../c-api/typeobj.rst:2270 ../../c-api/typeobj.rst:2283 +#: ../../c-api/typeobj.rst:2293 ../../c-api/typeobj.rst:2310 +#: ../../c-api/typeobj.rst:2327 ../../c-api/typeobj.rst:2343 +#: ../../c-api/typeobj.rst:2487 ../../c-api/typeobj.rst:2547 msgid "**Inheritance:**" msgstr "" #: ../../c-api/typeobj.rst:506 ../../c-api/typeobj.rst:545 -#: ../../c-api/typeobj.rst:589 +#: ../../c-api/typeobj.rst:592 msgid "This field is not inherited by subtypes." msgstr "" @@ -1381,12 +1381,12 @@ msgid "" "class. :c:func:`PyType_Ready` will not change this field if it is non-zero." msgstr "" -#: ../../c-api/typeobj.rst:529 ../../c-api/typeobj.rst:811 -#: ../../c-api/typeobj.rst:938 ../../c-api/typeobj.rst:1038 -#: ../../c-api/typeobj.rst:1060 ../../c-api/typeobj.rst:1919 -#: ../../c-api/typeobj.rst:1945 ../../c-api/typeobj.rst:2085 -#: ../../c-api/typeobj.rst:2105 ../../c-api/typeobj.rst:2180 -#: ../../c-api/typeobj.rst:2306 ../../c-api/typeobj.rst:2553 +#: ../../c-api/typeobj.rst:529 ../../c-api/typeobj.rst:818 +#: ../../c-api/typeobj.rst:945 ../../c-api/typeobj.rst:1045 +#: ../../c-api/typeobj.rst:1067 ../../c-api/typeobj.rst:1860 +#: ../../c-api/typeobj.rst:1886 ../../c-api/typeobj.rst:2026 +#: ../../c-api/typeobj.rst:2046 ../../c-api/typeobj.rst:2121 +#: ../../c-api/typeobj.rst:2247 ../../c-api/typeobj.rst:2489 msgid "This field is inherited by subtypes." msgstr "" @@ -1423,6 +1423,12 @@ msgstr "" #: ../../c-api/typeobj.rst:558 msgid "" +"See :c:macro:`Py_tp_name` for the corresponding :c:member:`Slot ID `." +msgstr "" + +#: ../../c-api/typeobj.rst:561 +msgid "" "Pointer to a NUL-terminated string containing the name of the type. For " "types that are accessible as module globals, the string should be the full " "module name, followed by a dot, followed by the type name; for built-in " @@ -1433,14 +1439,14 @@ msgid "" "tp_name` initializer ``\"P.Q.M.T\"``." msgstr "" -#: ../../c-api/typeobj.rst:566 +#: ../../c-api/typeobj.rst:569 msgid "" "For :ref:`dynamically allocated type objects `, this should just " "be the type name, and the module name explicitly stored in the type dict as " "the value for key ``'__module__'``." msgstr "" -#: ../../c-api/typeobj.rst:571 +#: ../../c-api/typeobj.rst:574 msgid "" "For :ref:`statically allocated type objects `, the *tp_name* " "field should contain a dot. Everything before the last dot is made " @@ -1448,7 +1454,7 @@ msgid "" "the last dot is made accessible as the :attr:`~type.__name__` attribute." msgstr "" -#: ../../c-api/typeobj.rst:577 +#: ../../c-api/typeobj.rst:580 msgid "" "If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is " "made accessible as the :attr:`~type.__name__` attribute, and the :attr:" @@ -1458,19 +1464,26 @@ msgid "" "created with pydoc." msgstr "" -#: ../../c-api/typeobj.rst:583 +#: ../../c-api/typeobj.rst:586 msgid "" "This field must not be ``NULL``. It is the only required field in :c:func:" "`PyTypeObject` (other than potentially :c:member:`~PyTypeObject." "tp_itemsize`)." msgstr "" -#: ../../c-api/typeobj.rst:595 +#: ../../c-api/typeobj.rst:598 msgid "" "These fields allow calculating the size in bytes of instances of the type." msgstr "" -#: ../../c-api/typeobj.rst:597 +#: ../../c-api/typeobj.rst:600 +msgid "" +"See :c:macro:`Py_tp_basicsize`, :c:macro:`Py_tp_extra_basicsize` and :c:" +"macro:`Py_tp_itemsize` for the corresponding :c:member:`Slot IDs `." +msgstr "" + +#: ../../c-api/typeobj.rst:604 msgid "" "There are two kinds of types: types with fixed-length instances have a zero :" "c:member:`!tp_itemsize` field, types with variable-length instances have a " @@ -1480,7 +1493,7 @@ msgid "" "`PyUnstable_Object_GC_NewWithExtraData`.)" msgstr "" -#: ../../c-api/typeobj.rst:604 +#: ../../c-api/typeobj.rst:611 msgid "" "For a type with variable-length instances, the instances must have an :c:" "member:`~PyVarObject.ob_size` field, and the instance size is :c:member:`!" @@ -1488,7 +1501,7 @@ msgid "" "\"length\" of the object." msgstr "" -#: ../../c-api/typeobj.rst:609 +#: ../../c-api/typeobj.rst:616 msgid "" "Functions like :c:func:`PyObject_NewVar` will take the value of N as an " "argument, and store in the instance's :c:member:`~PyVarObject.ob_size` " @@ -1499,13 +1512,13 @@ msgid "" "`PyLong_Export`." msgstr "" -#: ../../c-api/typeobj.rst:619 +#: ../../c-api/typeobj.rst:626 msgid "" "The :c:member:`~PyVarObject.ob_size` field should be accessed using the :c:" "func:`Py_SIZE()` and :c:func:`Py_SET_SIZE()` macros." msgstr "" -#: ../../c-api/typeobj.rst:622 +#: ../../c-api/typeobj.rst:629 msgid "" "Also, the presence of an :c:member:`~PyVarObject.ob_size` field in the " "instance layout doesn't mean that the instance structure is variable-length. " @@ -1515,13 +1528,13 @@ msgid "" "`PyList_Size` instead.)" msgstr "" -#: ../../c-api/typeobj.rst:629 +#: ../../c-api/typeobj.rst:636 msgid "" "The :c:member:`!tp_basicsize` includes size needed for data of the type's :c:" "member:`~PyTypeObject.tp_base`, plus any extra data needed by each instance." msgstr "" -#: ../../c-api/typeobj.rst:633 +#: ../../c-api/typeobj.rst:640 msgid "" "The correct way to set :c:member:`!tp_basicsize` is to use the ``sizeof`` " "operator on the struct used to declare the instance layout. This struct must " @@ -1530,7 +1543,7 @@ msgid "" "tp_basicsize`." msgstr "" -#: ../../c-api/typeobj.rst:639 +#: ../../c-api/typeobj.rst:646 msgid "" "Since every type is a subtype of :py:type:`object`, this struct must " "include :c:type:`PyObject` or :c:type:`PyVarObject` (depending on whether :c:" @@ -1539,23 +1552,23 @@ msgid "" "respectively." msgstr "" -#: ../../c-api/typeobj.rst:645 +#: ../../c-api/typeobj.rst:652 msgid "" "The basic size does not include the GC header size, as that header is not " "part of :c:macro:`PyObject_HEAD`." msgstr "" -#: ../../c-api/typeobj.rst:648 +#: ../../c-api/typeobj.rst:655 msgid "" "For cases where struct used to declare the base type is unknown, see :c:" "member:`PyType_Spec.basicsize` and :c:func:`PyType_FromMetaclass`." msgstr "" -#: ../../c-api/typeobj.rst:651 +#: ../../c-api/typeobj.rst:658 msgid "Notes about alignment:" msgstr "" -#: ../../c-api/typeobj.rst:653 +#: ../../c-api/typeobj.rst:660 msgid "" ":c:member:`!tp_basicsize` must be a multiple of ``_Alignof(PyObject)``. When " "using ``sizeof`` on a ``struct`` that includes :c:macro:`PyObject_HEAD`, as " @@ -1564,7 +1577,7 @@ msgid "" "you." msgstr "" -#: ../../c-api/typeobj.rst:658 +#: ../../c-api/typeobj.rst:665 msgid "" "If the variable items require a particular alignment, :c:member:`!" "tp_basicsize` and :c:member:`!tp_itemsize` must each be a multiple of that " @@ -1572,14 +1585,14 @@ msgid "" "your responsibility that both fields are a multiple of ``_Alignof(double)``." msgstr "" -#: ../../c-api/typeobj.rst:667 +#: ../../c-api/typeobj.rst:674 msgid "" "These fields are inherited separately by subtypes. (That is, if the field is " "set to zero, :c:func:`PyType_Ready` will copy the value from the base type, " "indicating that the instances do not need additional storage.)" msgstr "" -#: ../../c-api/typeobj.rst:672 +#: ../../c-api/typeobj.rst:679 msgid "" "If the base type has a non-zero :c:member:`~PyTypeObject.tp_itemsize`, it is " "generally not safe to set :c:member:`~PyTypeObject.tp_itemsize` to a " @@ -1587,16 +1600,16 @@ msgid "" "implementation of the base type)." msgstr "" -#: ../../c-api/typeobj.rst:681 +#: ../../c-api/typeobj.rst:688 msgid "" "A pointer to the instance destructor function. The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:683 +#: ../../c-api/typeobj.rst:690 msgid "void tp_dealloc(PyObject *self);" msgstr "void tp_dealloc(PyObject *self);" -#: ../../c-api/typeobj.rst:685 +#: ../../c-api/typeobj.rst:692 msgid "" "The destructor function should remove all references which the instance owns " "(e.g., call :c:func:`Py_CLEAR`), free all memory buffers owned by the " @@ -1604,7 +1617,7 @@ msgid "" "free the object itself." msgstr "" -#: ../../c-api/typeobj.rst:690 +#: ../../c-api/typeobj.rst:697 msgid "" "If you may call functions that may set the error indicator, you must use :c:" "func:`PyErr_GetRaisedException` and :c:func:`PyErr_SetRaisedException` to " @@ -1612,7 +1625,7 @@ msgid "" "could have occurred while processing a different error):" msgstr "" -#: ../../c-api/typeobj.rst:695 +#: ../../c-api/typeobj.rst:702 msgid "" "static void\n" "foo_dealloc(foo_object *self)\n" @@ -1624,53 +1637,53 @@ msgid "" "}" msgstr "" -#: ../../c-api/typeobj.rst:706 +#: ../../c-api/typeobj.rst:713 msgid "" "The dealloc handler itself must not raise an exception; if it hits an error " "case it should call :c:func:`PyErr_FormatUnraisable` to log (and clear) an " "unraisable exception." msgstr "" -#: ../../c-api/typeobj.rst:710 +#: ../../c-api/typeobj.rst:717 msgid "No guarantees are made about when an object is destroyed, except:" msgstr "" -#: ../../c-api/typeobj.rst:712 +#: ../../c-api/typeobj.rst:719 msgid "" "Python will destroy an object immediately or some time after the final " "reference to the object is deleted, unless its finalizer (:c:member:" "`~PyTypeObject.tp_finalize`) subsequently resurrects the object." msgstr "" -#: ../../c-api/typeobj.rst:716 +#: ../../c-api/typeobj.rst:723 msgid "" "An object will not be destroyed while it is being automatically finalized (:" "c:member:`~PyTypeObject.tp_finalize`) or automatically cleared (:c:member:" "`~PyTypeObject.tp_clear`)." msgstr "" -#: ../../c-api/typeobj.rst:720 +#: ../../c-api/typeobj.rst:727 msgid "" "CPython currently destroys an object immediately from :c:func:`Py_DECREF` " "when the new reference count is zero, but this may change in a future " "version." msgstr "" -#: ../../c-api/typeobj.rst:724 +#: ../../c-api/typeobj.rst:731 msgid "" "It is recommended to call :c:func:`PyObject_CallFinalizerFromDealloc` at the " "beginning of :c:member:`!tp_dealloc` to guarantee that the object is always " "finalized before destruction." msgstr "" -#: ../../c-api/typeobj.rst:728 +#: ../../c-api/typeobj.rst:735 msgid "" "If the type supports garbage collection (the :c:macro:`Py_TPFLAGS_HAVE_GC` " "flag is set), the destructor should call :c:func:`PyObject_GC_UnTrack` " "before clearing any member fields." msgstr "" -#: ../../c-api/typeobj.rst:732 +#: ../../c-api/typeobj.rst:739 msgid "" "It is permissible to call :c:member:`~PyTypeObject.tp_clear` from :c:member:" "`!tp_dealloc` to reduce code duplication and to guarantee that the object is " @@ -1678,7 +1691,7 @@ msgid "" "have already been called." msgstr "" -#: ../../c-api/typeobj.rst:737 +#: ../../c-api/typeobj.rst:744 msgid "" "If the type is heap allocated (:c:macro:`Py_TPFLAGS_HEAPTYPE`), the " "deallocator should release the owned reference to its type object (via :c:" @@ -1686,7 +1699,7 @@ msgid "" "below.::" msgstr "" -#: ../../c-api/typeobj.rst:742 +#: ../../c-api/typeobj.rst:749 msgid "" "static void\n" "foo_dealloc(PyObject *op)\n" @@ -1706,7 +1719,7 @@ msgstr "" " Py_TYPE(self)->tp_free(self);\n" "}" -#: ../../c-api/typeobj.rst:751 +#: ../../c-api/typeobj.rst:758 msgid "" ":c:member:`!tp_dealloc` must leave the exception status unchanged. If it " "needs to call something that might raise an exception, the exception state " @@ -1714,11 +1727,11 @@ msgid "" "with :c:func:`PyErr_WriteUnraisable`)." msgstr "" -#: ../../c-api/typeobj.rst:756 +#: ../../c-api/typeobj.rst:763 msgid "Example::" msgstr "範例: ::" -#: ../../c-api/typeobj.rst:758 +#: ../../c-api/typeobj.rst:765 msgid "" "static void\n" "foo_dealloc(PyObject *self)\n" @@ -1760,7 +1773,7 @@ msgid "" "}" msgstr "" -#: ../../c-api/typeobj.rst:797 +#: ../../c-api/typeobj.rst:804 msgid "" ":c:member:`!tp_dealloc` may be called from any Python thread, not just the " "thread which created the object (if the object becomes part of a refcount " @@ -1773,34 +1786,34 @@ msgid "" "violate any assumptions of the library." msgstr "" -#: ../../c-api/typeobj.rst:815 ../../c-api/typeobj.rst:1798 -#: ../../c-api/typeobj.rst:2566 +#: ../../c-api/typeobj.rst:822 ../../c-api/typeobj.rst:1739 +#: ../../c-api/typeobj.rst:2502 msgid "" ":ref:`life-cycle` for details about how this slot relates to other slots." msgstr "" -#: ../../c-api/typeobj.rst:820 +#: ../../c-api/typeobj.rst:827 msgid "" "An optional offset to a per-instance function that implements calling the " "object using the :ref:`vectorcall protocol `, a more efficient " "alternative of the simpler :c:member:`~PyTypeObject.tp_call`." msgstr "" -#: ../../c-api/typeobj.rst:825 +#: ../../c-api/typeobj.rst:832 msgid "" "This field is only used if the flag :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` is " "set. If so, this must be a positive integer containing the offset in the " "instance of a :c:type:`vectorcallfunc` pointer." msgstr "" -#: ../../c-api/typeobj.rst:829 +#: ../../c-api/typeobj.rst:836 msgid "" "The *vectorcallfunc* pointer may be ``NULL``, in which case the instance " "behaves as if :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` was not set: calling the " "instance falls back to :c:member:`~PyTypeObject.tp_call`." msgstr "" -#: ../../c-api/typeobj.rst:833 +#: ../../c-api/typeobj.rst:840 msgid "" "Any class that sets ``Py_TPFLAGS_HAVE_VECTORCALL`` must also set :c:member:" "`~PyTypeObject.tp_call` and make sure its behaviour is consistent with the " @@ -1808,13 +1821,13 @@ msgid "" "`PyVectorcall_Call`." msgstr "" -#: ../../c-api/typeobj.rst:840 +#: ../../c-api/typeobj.rst:847 msgid "" "Before version 3.8, this slot was named ``tp_print``. In Python 2.x, it was " "used for printing to a file. In Python 3.0 to 3.7, it was unused." msgstr "" -#: ../../c-api/typeobj.rst:846 +#: ../../c-api/typeobj.rst:853 msgid "" "Before version 3.12, it was not recommended for :ref:`mutable heap types " "` to implement the vectorcall protocol. When a user sets :attr:" @@ -1824,7 +1837,7 @@ msgid "" "`Py_TPFLAGS_HAVE_VECTORCALL` flag." msgstr "" -#: ../../c-api/typeobj.rst:856 +#: ../../c-api/typeobj.rst:863 msgid "" "This field is always inherited. However, the :c:macro:" "`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If it's not set, " @@ -1832,11 +1845,11 @@ msgid "" "func:`PyVectorcall_Call` is explicitly called." msgstr "" -#: ../../c-api/typeobj.rst:867 +#: ../../c-api/typeobj.rst:874 msgid "An optional pointer to the get-attribute-string function." msgstr "" -#: ../../c-api/typeobj.rst:869 +#: ../../c-api/typeobj.rst:876 msgid "" "This field is deprecated. When it is defined, it should point to a function " "that acts the same as the :c:member:`~PyTypeObject.tp_getattro` function, " @@ -1846,7 +1859,7 @@ msgstr "" "此欄位已被棄用。當它被定義時,它應該指向一個與 :c:member:`~PyTypeObject." "tp_getattro` 行為相同但使用 C 字串而非 Python 字串物件來提供屬性名稱的函式。" -#: ../../c-api/typeobj.rst:875 ../../c-api/typeobj.rst:1083 +#: ../../c-api/typeobj.rst:882 ../../c-api/typeobj.rst:1090 msgid "" "Group: :c:member:`~PyTypeObject.tp_getattr`, :c:member:`~PyTypeObject." "tp_getattro`" @@ -1854,7 +1867,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_getattr`、:c:member:`~PyTypeObject." "tp_getattro`" -#: ../../c-api/typeobj.rst:877 +#: ../../c-api/typeobj.rst:884 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_getattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " @@ -1863,12 +1876,12 @@ msgid "" "tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:886 ../../c-api/typeobj.rst:1098 +#: ../../c-api/typeobj.rst:893 ../../c-api/typeobj.rst:1105 msgid "" "An optional pointer to the function for setting and deleting attributes." msgstr "" -#: ../../c-api/typeobj.rst:888 +#: ../../c-api/typeobj.rst:895 msgid "" "This field is deprecated. When it is defined, it should point to a function " "that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, " @@ -1878,7 +1891,7 @@ msgstr "" "此欄位已被棄用。當它被定義時,它應該指向一個與 :c:member:`~PyTypeObject." "tp_setattro` 行為相同但使用 C 字串而非 Python 字串物件來提供屬性名稱的函式。" -#: ../../c-api/typeobj.rst:894 ../../c-api/typeobj.rst:1111 +#: ../../c-api/typeobj.rst:901 ../../c-api/typeobj.rst:1118 msgid "" "Group: :c:member:`~PyTypeObject.tp_setattr`, :c:member:`~PyTypeObject." "tp_setattro`" @@ -1886,7 +1899,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_setattr`、:c:member:`~PyTypeObject." "tp_setattro`" -#: ../../c-api/typeobj.rst:896 +#: ../../c-api/typeobj.rst:903 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_setattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " @@ -1895,38 +1908,38 @@ msgid "" "tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:903 +#: ../../c-api/typeobj.rst:910 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement :term:`awaitable` and :term:`asynchronous iterator` " "protocols at the C-level. See :ref:`async-structs` for details." msgstr "" -#: ../../c-api/typeobj.rst:907 +#: ../../c-api/typeobj.rst:914 msgid "Formerly known as ``tp_compare`` and ``tp_reserved``." msgstr "以前稱為 ``tp_compare`` 和 ``tp_reserved``。" -#: ../../c-api/typeobj.rst:912 +#: ../../c-api/typeobj.rst:919 msgid "" "The :c:member:`~PyTypeObject.tp_as_async` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:922 +#: ../../c-api/typeobj.rst:929 msgid "" "An optional pointer to a function that implements the built-in function :" "func:`repr`." msgstr "" -#: ../../c-api/typeobj.rst:925 +#: ../../c-api/typeobj.rst:932 msgid "The signature is the same as for :c:func:`PyObject_Repr`::" msgstr "函式簽名與 :c:func:`PyObject_Repr` 相同: ::" -#: ../../c-api/typeobj.rst:927 +#: ../../c-api/typeobj.rst:934 msgid "PyObject *tp_repr(PyObject *self);" msgstr "PyObject *tp_repr(PyObject *self);" -#: ../../c-api/typeobj.rst:929 +#: ../../c-api/typeobj.rst:936 msgid "" "The function must return a string or a Unicode object. Ideally, this " "function should return a string that, when passed to :func:`eval`, given a " @@ -1935,85 +1948,85 @@ msgid "" "``'>'`` from which both the type and the value of the object can be deduced." msgstr "" -#: ../../c-api/typeobj.rst:940 ../../c-api/typeobj.rst:1021 -#: ../../c-api/typeobj.rst:1062 ../../c-api/typeobj.rst:1089 -#: ../../c-api/typeobj.rst:1117 ../../c-api/typeobj.rst:1159 -#: ../../c-api/typeobj.rst:1863 ../../c-api/typeobj.rst:1897 -#: ../../c-api/typeobj.rst:2027 ../../c-api/typeobj.rst:2060 -#: ../../c-api/typeobj.rst:2139 ../../c-api/typeobj.rst:2182 -#: ../../c-api/typeobj.rst:2204 ../../c-api/typeobj.rst:2245 -#: ../../c-api/typeobj.rst:2275 ../../c-api/typeobj.rst:2308 +#: ../../c-api/typeobj.rst:947 ../../c-api/typeobj.rst:1028 +#: ../../c-api/typeobj.rst:1069 ../../c-api/typeobj.rst:1096 +#: ../../c-api/typeobj.rst:1124 ../../c-api/typeobj.rst:1169 +#: ../../c-api/typeobj.rst:1804 ../../c-api/typeobj.rst:1838 +#: ../../c-api/typeobj.rst:1968 ../../c-api/typeobj.rst:2001 +#: ../../c-api/typeobj.rst:2080 ../../c-api/typeobj.rst:2123 +#: ../../c-api/typeobj.rst:2145 ../../c-api/typeobj.rst:2186 +#: ../../c-api/typeobj.rst:2216 ../../c-api/typeobj.rst:2249 msgid "**Default:**" msgstr "**預設:**" -#: ../../c-api/typeobj.rst:942 +#: ../../c-api/typeobj.rst:949 msgid "" "When this field is not set, a string of the form ``<%s object at %p>`` is " "returned, where ``%s`` is replaced by the type name, and ``%p`` by the " "object's memory address." msgstr "" -#: ../../c-api/typeobj.rst:949 +#: ../../c-api/typeobj.rst:956 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the number protocol. These fields are documented " "in :ref:`number-structs`." msgstr "" -#: ../../c-api/typeobj.rst:955 +#: ../../c-api/typeobj.rst:962 msgid "" "The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:961 +#: ../../c-api/typeobj.rst:968 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the sequence protocol. These fields are documented " "in :ref:`sequence-structs`." msgstr "" -#: ../../c-api/typeobj.rst:967 +#: ../../c-api/typeobj.rst:974 msgid "" "The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:973 +#: ../../c-api/typeobj.rst:980 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the mapping protocol. These fields are documented " "in :ref:`mapping-structs`." msgstr "" -#: ../../c-api/typeobj.rst:979 +#: ../../c-api/typeobj.rst:986 msgid "" "The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:989 +#: ../../c-api/typeobj.rst:996 msgid "" "An optional pointer to a function that implements the built-in function :" "func:`hash`." msgstr "" -#: ../../c-api/typeobj.rst:992 +#: ../../c-api/typeobj.rst:999 msgid "The signature is the same as for :c:func:`PyObject_Hash`::" msgstr "函式簽名與 :c:func:`PyObject_Hash` 相同: ::" -#: ../../c-api/typeobj.rst:994 +#: ../../c-api/typeobj.rst:1001 msgid "Py_hash_t tp_hash(PyObject *);" msgstr "Py_hash_t tp_hash(PyObject *);" -#: ../../c-api/typeobj.rst:996 +#: ../../c-api/typeobj.rst:1003 msgid "" "The value ``-1`` should not be returned as a normal return value; when an " "error occurs during the computation of the hash value, the function should " "set an exception and return ``-1``." msgstr "" -#: ../../c-api/typeobj.rst:1000 +#: ../../c-api/typeobj.rst:1007 msgid "" "When this field is not set (*and* :c:member:`~PyTypeObject.tp_richcompare` " "is not set), an attempt to take the hash of the object raises :exc:" @@ -2021,7 +2034,7 @@ msgid "" "`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:1004 +#: ../../c-api/typeobj.rst:1011 msgid "" "This field can be set explicitly to :c:func:`PyObject_HashNotImplemented` to " "block inheritance of the hash method from a parent type. This is interpreted " @@ -2032,7 +2045,7 @@ msgid "" "`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:1014 ../../c-api/typeobj.rst:1856 +#: ../../c-api/typeobj.rst:1021 ../../c-api/typeobj.rst:1797 msgid "" "Group: :c:member:`~PyTypeObject.tp_hash`, :c:member:`~PyTypeObject." "tp_richcompare`" @@ -2040,7 +2053,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_hash`、:c:member:`~PyTypeObject." "tp_richcompare`" -#: ../../c-api/typeobj.rst:1016 +#: ../../c-api/typeobj.rst:1023 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_richcompare`: a subtype inherits both of :c:member:`~PyTypeObject." @@ -2049,22 +2062,22 @@ msgid "" "are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1023 +#: ../../c-api/typeobj.rst:1030 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericHash`." msgstr ":c:data:`PyBaseObject_Type` 會使用 :c:func:`PyObject_GenericHash`。" -#: ../../c-api/typeobj.rst:1030 +#: ../../c-api/typeobj.rst:1037 msgid "" "An optional pointer to a function that implements calling the object. This " "should be ``NULL`` if the object is not callable. The signature is the same " "as for :c:func:`PyObject_Call`::" msgstr "" -#: ../../c-api/typeobj.rst:1034 +#: ../../c-api/typeobj.rst:1041 msgid "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" msgstr "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" -#: ../../c-api/typeobj.rst:1045 +#: ../../c-api/typeobj.rst:1052 msgid "" "An optional pointer to a function that implements the built-in operation :" "func:`str`. (Note that :class:`str` is a type now, and :func:`str` calls " @@ -2073,15 +2086,15 @@ msgid "" "this handler.)" msgstr "" -#: ../../c-api/typeobj.rst:1050 +#: ../../c-api/typeobj.rst:1057 msgid "The signature is the same as for :c:func:`PyObject_Str`::" msgstr "函式簽名與 :c:func:`PyObject_Str` 相同: ::" -#: ../../c-api/typeobj.rst:1052 +#: ../../c-api/typeobj.rst:1059 msgid "PyObject *tp_str(PyObject *self);" msgstr "PyObject *tp_str(PyObject *self);" -#: ../../c-api/typeobj.rst:1054 +#: ../../c-api/typeobj.rst:1061 msgid "" "The function must return a string or a Unicode object. It should be a " "\"friendly\" string representation of the object, as this is the " @@ -2089,32 +2102,32 @@ msgid "" "function." msgstr "" -#: ../../c-api/typeobj.rst:1064 +#: ../../c-api/typeobj.rst:1071 msgid "" "When this field is not set, :c:func:`PyObject_Repr` is called to return a " "string representation." msgstr "" -#: ../../c-api/typeobj.rst:1072 +#: ../../c-api/typeobj.rst:1079 msgid "An optional pointer to the get-attribute function." msgstr "" -#: ../../c-api/typeobj.rst:1074 +#: ../../c-api/typeobj.rst:1081 msgid "The signature is the same as for :c:func:`PyObject_GetAttr`::" msgstr "函式簽名與 :c:func:`PyObject_GetAttr` 相同: ::" -#: ../../c-api/typeobj.rst:1076 +#: ../../c-api/typeobj.rst:1083 msgid "PyObject *tp_getattro(PyObject *self, PyObject *attr);" msgstr "PyObject *tp_getattro(PyObject *self, PyObject *attr);" -#: ../../c-api/typeobj.rst:1078 +#: ../../c-api/typeobj.rst:1085 msgid "" "It is usually convenient to set this field to :c:func:" "`PyObject_GenericGetAttr`, which implements the normal way of looking for " "object attributes." msgstr "" -#: ../../c-api/typeobj.rst:1085 +#: ../../c-api/typeobj.rst:1092 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_getattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " @@ -2123,19 +2136,19 @@ msgid "" "tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1091 +#: ../../c-api/typeobj.rst:1098 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericGetAttr`." msgstr ":c:data:`PyBaseObject_Type` 會使用 :c:func:`PyObject_GenericGetAttr`。" -#: ../../c-api/typeobj.rst:1100 +#: ../../c-api/typeobj.rst:1107 msgid "The signature is the same as for :c:func:`PyObject_SetAttr`::" msgstr "函式簽名與 :c:func:`PyObject_SetAttr` 相同: ::" -#: ../../c-api/typeobj.rst:1102 +#: ../../c-api/typeobj.rst:1109 msgid "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" msgstr "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" -#: ../../c-api/typeobj.rst:1104 +#: ../../c-api/typeobj.rst:1111 msgid "" "In addition, setting *value* to ``NULL`` to delete an attribute must be " "supported. It is usually convenient to set this field to :c:func:" @@ -2143,7 +2156,7 @@ msgid "" "attributes." msgstr "" -#: ../../c-api/typeobj.rst:1113 +#: ../../c-api/typeobj.rst:1120 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_setattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " @@ -2152,24 +2165,30 @@ msgid "" "tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1119 +#: ../../c-api/typeobj.rst:1126 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericSetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:1124 +#: ../../c-api/typeobj.rst:1131 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the buffer interface. These fields are documented " "in :ref:`buffer-structs`." msgstr "" -#: ../../c-api/typeobj.rst:1130 +#: ../../c-api/typeobj.rst:1137 msgid "" "The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:1136 +#: ../../c-api/typeobj.rst:1143 +msgid "" +"See :c:macro:`Py_tp_flags` for the corresponding :c:member:`Slot ID `." +msgstr "" + +#: ../../c-api/typeobj.rst:1146 msgid "" "This field is a bit mask of various flags. Some flags indicate variant " "semantics for certain situations; others are used to indicate that certain " @@ -2181,7 +2200,7 @@ msgid "" "accessed and must be considered to have a zero or ``NULL`` value instead." msgstr "" -#: ../../c-api/typeobj.rst:1146 +#: ../../c-api/typeobj.rst:1156 msgid "" "Inheritance of this field is complicated. Most flag bits are inherited " "individually, i.e. if the base type has a flag bit set, the subtype inherits " @@ -2196,7 +2215,7 @@ msgid "" "the subtype exist and have ``NULL`` values." msgstr "" -#: ../../c-api/typeobj.rst:1161 +#: ../../c-api/typeobj.rst:1171 msgid "" ":c:data:`PyBaseObject_Type` uses ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``." @@ -2204,11 +2223,11 @@ msgstr "" ":c:data:`PyBaseObject_Type` 使用 ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``。" -#: ../../c-api/typeobj.rst:1164 +#: ../../c-api/typeobj.rst:1174 msgid "**Bit Masks:**" msgstr "" -#: ../../c-api/typeobj.rst:1168 +#: ../../c-api/typeobj.rst:1178 msgid "" "The following bit masks are currently defined; these can be ORed together " "using the ``|`` operator to form the value of the :c:member:`~PyTypeObject." @@ -2217,7 +2236,7 @@ msgid "" "zero." msgstr "" -#: ../../c-api/typeobj.rst:1175 +#: ../../c-api/typeobj.rst:1185 msgid "" "This bit is set when the type object itself is allocated on the heap, for " "example, types created dynamically using :c:func:`PyType_FromSpec`. In this " @@ -2230,32 +2249,32 @@ msgid "" "reference cycle with their own module object." msgstr "" -#: ../../c-api/typeobj.rst:1186 ../../c-api/typeobj.rst:1197 -#: ../../c-api/typeobj.rst:1207 ../../c-api/typeobj.rst:1217 -#: ../../c-api/typeobj.rst:1249 +#: ../../c-api/typeobj.rst:1196 ../../c-api/typeobj.rst:1207 +#: ../../c-api/typeobj.rst:1217 ../../c-api/typeobj.rst:1227 +#: ../../c-api/typeobj.rst:1259 msgid "???" msgstr "???" -#: ../../c-api/typeobj.rst:1191 +#: ../../c-api/typeobj.rst:1201 msgid "" "This bit is set when the type can be used as the base type of another type. " "If this bit is clear, the type cannot be subtyped (similar to a \"final\" " "class in Java)." msgstr "" -#: ../../c-api/typeobj.rst:1202 +#: ../../c-api/typeobj.rst:1212 msgid "" "This bit is set when the type object has been fully initialized by :c:func:" "`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:1212 +#: ../../c-api/typeobj.rst:1222 msgid "" "This bit is set while :c:func:`PyType_Ready` is in the process of " "initializing the type object." msgstr "" -#: ../../c-api/typeobj.rst:1222 +#: ../../c-api/typeobj.rst:1232 msgid "" "This bit is set when the object supports garbage collection. If this bit is " "set, memory for new instances (see :c:member:`~PyTypeObject.tp_alloc`) must " @@ -2265,14 +2284,14 @@ msgid "" "`supporting-cycle-detection`." msgstr "" -#: ../../c-api/typeobj.rst:1231 ../../c-api/typeobj.rst:1643 -#: ../../c-api/typeobj.rst:1789 +#: ../../c-api/typeobj.rst:1241 ../../c-api/typeobj.rst:1584 +#: ../../c-api/typeobj.rst:1730 msgid "" "Group: :c:macro:`Py_TPFLAGS_HAVE_GC`, :c:member:`~PyTypeObject." "tp_traverse`, :c:member:`~PyTypeObject.tp_clear`" msgstr "" -#: ../../c-api/typeobj.rst:1233 +#: ../../c-api/typeobj.rst:1243 msgid "" "The :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is inherited together with the :c:" "member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` " @@ -2282,22 +2301,22 @@ msgid "" "values." msgstr "" -#: ../../c-api/typeobj.rst:1243 +#: ../../c-api/typeobj.rst:1253 msgid "" "This is a bitmask of all the bits that pertain to the existence of certain " "fields in the type object and its extension structures. Currently, it " "includes the following bits: :c:macro:`Py_TPFLAGS_HAVE_STACKLESS_EXTENSION`." msgstr "" -#: ../../c-api/typeobj.rst:1254 +#: ../../c-api/typeobj.rst:1264 msgid "This bit indicates that objects behave like unbound methods." msgstr "" -#: ../../c-api/typeobj.rst:1256 +#: ../../c-api/typeobj.rst:1266 msgid "If this flag is set for ``type(meth)``, then:" msgstr "如果此旗標為 ``type(meth)`` 所設定,則:" -#: ../../c-api/typeobj.rst:1258 +#: ../../c-api/typeobj.rst:1268 msgid "" "``meth.__get__(obj, cls)(*args, **kwds)`` (with ``obj`` not None) must be " "equivalent to ``meth(obj, *args, **kwds)``." @@ -2305,7 +2324,7 @@ msgstr "" "``meth.__get__(obj, cls)(*args, **kwds)``\\(其中 ``obj`` 並非 None)必須等價" "於 ``meth(obj, *args, **kwds)``。" -#: ../../c-api/typeobj.rst:1261 +#: ../../c-api/typeobj.rst:1271 msgid "" "``meth.__get__(None, cls)(*args, **kwds)`` must be equivalent to " "``meth(*args, **kwds)``." @@ -2313,79 +2332,93 @@ msgstr "" "``meth.__get__(None, cls)(*args, **kwds)`` 必須等價於 ``meth(*args, " "**kwds)``。" -#: ../../c-api/typeobj.rst:1264 +#: ../../c-api/typeobj.rst:1274 msgid "" "This flag enables an optimization for typical method calls like ``obj." "meth()``: it avoids creating a temporary \"bound method\" object for ``obj." "meth``." msgstr "" -#: ../../c-api/typeobj.rst:1272 +#: ../../c-api/typeobj.rst:1282 msgid "" "This flag is never inherited by types without the :c:macro:" "`Py_TPFLAGS_IMMUTABLETYPE` flag set. For extension types, it is inherited " "whenever :c:member:`~PyTypeObject.tp_descr_get` is inherited." msgstr "" -#: ../../c-api/typeobj.rst:1278 +#: ../../c-api/typeobj.rst:1288 msgid "" "This bit indicates that instances of the class have a :attr:`~object." "__dict__` attribute, and that the space for the dictionary is managed by the " "VM." msgstr "" -#: ../../c-api/typeobj.rst:1281 -msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set." -msgstr "如果有設定此旗標,則也應該設定 :c:macro:`Py_TPFLAGS_HAVE_GC`。" +#: ../../c-api/typeobj.rst:1291 ../../c-api/typeobj.rst:1309 +msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` must also be set." +msgstr "如果有設定此旗標,則也必須設定 :c:macro:`Py_TPFLAGS_HAVE_GC`。" -#: ../../c-api/typeobj.rst:1283 +#: ../../c-api/typeobj.rst:1293 msgid "" "The type traverse function must call :c:func:`PyObject_VisitManagedDict` and " "its clear function must call :c:func:`PyObject_ClearManagedDict`." msgstr "" -#: ../../c-api/typeobj.rst:1290 +#: ../../c-api/typeobj.rst:1300 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject.tp_dictoffset` " "field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1296 +#: ../../c-api/typeobj.rst:1306 msgid "" "This bit indicates that instances of the class should be weakly " "referenceable." msgstr "" -#: ../../c-api/typeobj.rst:1303 +#: ../../c-api/typeobj.rst:1315 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject." "tp_weaklistoffset` field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1309 +#: ../../c-api/typeobj.rst:1321 +msgid "" +"These bits indicate that the VM will manage some fields by storing them " +"before the object. Currently, this macro is equivalent to :c:expr:" +"`Py_TPFLAGS_MANAGED_DICT | Py_TPFLAGS_MANAGED_WEAKREF`." +msgstr "" + +#: ../../c-api/typeobj.rst:1325 +msgid "" +"This macro value relies on the implementation of the VM, so its value is not " +"stable and may change in a future version. Prefer using individual flags " +"instead." +msgstr "" + +#: ../../c-api/typeobj.rst:1334 msgid "" "Only usable with variable-size types, i.e. ones with non-zero :c:member:" "`~PyTypeObject.tp_itemsize`." msgstr "" -#: ../../c-api/typeobj.rst:1312 +#: ../../c-api/typeobj.rst:1337 msgid "" "Indicates that the variable-sized portion of an instance of this type is at " "the end of the instance's memory area, at an offset of ``Py_TYPE(obj)-" ">tp_basicsize`` (which may be different in each subclass)." msgstr "" -#: ../../c-api/typeobj.rst:1317 +#: ../../c-api/typeobj.rst:1342 msgid "" "When setting this flag, be sure that all superclasses either use this memory " "layout, or are not variable-sized. Python does not check this." msgstr "" -#: ../../c-api/typeobj.rst:1325 +#: ../../c-api/typeobj.rst:1350 msgid "This flag is inherited." msgstr "" -#: ../../c-api/typeobj.rst:1339 +#: ../../c-api/typeobj.rst:1364 msgid "" "Functions such as :c:func:`PyLong_Check` will call :c:func:" "`PyType_FastSubclass` with one of these flags to quickly determine if a type " @@ -2396,35 +2429,35 @@ msgid "" "differently depending on what kind of check is used." msgstr "" -#: ../../c-api/typeobj.rst:1350 +#: ../../c-api/typeobj.rst:1375 msgid "" "This bit is set when the :c:member:`~PyTypeObject.tp_finalize` slot is " "present in the type structure." msgstr "" -#: ../../c-api/typeobj.rst:1355 +#: ../../c-api/typeobj.rst:1380 msgid "" "This flag isn't necessary anymore, as the interpreter assumes the :c:member:" "`~PyTypeObject.tp_finalize` slot is always present in the type structure." msgstr "" -#: ../../c-api/typeobj.rst:1366 +#: ../../c-api/typeobj.rst:1391 msgid "" "This bit is set when the class implements the :ref:`vectorcall protocol " "`. See :c:member:`~PyTypeObject.tp_vectorcall_offset` for " "details." msgstr "" -#: ../../c-api/typeobj.rst:1372 +#: ../../c-api/typeobj.rst:1397 msgid "" "This bit is inherited if :c:member:`~PyTypeObject.tp_call` is also inherited." msgstr "" -#: ../../c-api/typeobj.rst:1375 +#: ../../c-api/typeobj.rst:1400 msgid "as ``_Py_TPFLAGS_HAVE_VECTORCALL``" msgstr "名為 ``_Py_TPFLAGS_HAVE_VECTORCALL``" -#: ../../c-api/typeobj.rst:1379 +#: ../../c-api/typeobj.rst:1404 msgid "" "Renamed to the current name, without the leading underscore. The old " "provisional name is :term:`soft deprecated`." @@ -2432,67 +2465,67 @@ msgstr "" "重新命名為目前的名稱,沒有前導底線。舊的臨時名稱已被 :term:`軟性棄用 `。" -#: ../../c-api/typeobj.rst:1384 +#: ../../c-api/typeobj.rst:1409 msgid "" "This flag is now removed from a class when the class's :py:meth:`~object." "__call__` method is reassigned." msgstr "" -#: ../../c-api/typeobj.rst:1387 +#: ../../c-api/typeobj.rst:1412 msgid "This flag can now be inherited by mutable classes." msgstr "" -#: ../../c-api/typeobj.rst:1391 +#: ../../c-api/typeobj.rst:1416 msgid "" "This bit is set for type objects that are immutable: type attributes cannot " "be set nor deleted." msgstr "" -#: ../../c-api/typeobj.rst:1393 +#: ../../c-api/typeobj.rst:1418 msgid "" ":c:func:`PyType_Ready` automatically applies this flag to :ref:`static types " "`." msgstr "" -#: ../../c-api/typeobj.rst:1398 ../../c-api/typeobj.rst:1507 -#: ../../c-api/typeobj.rst:1519 +#: ../../c-api/typeobj.rst:1423 ../../c-api/typeobj.rst:1532 +#: ../../c-api/typeobj.rst:1544 msgid "This flag is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:1404 +#: ../../c-api/typeobj.rst:1429 msgid "" "Disallow creating instances of the type: set :c:member:`~PyTypeObject." "tp_new` to NULL and don't create the ``__new__`` key in the type dictionary." msgstr "" -#: ../../c-api/typeobj.rst:1408 +#: ../../c-api/typeobj.rst:1433 msgid "" "The flag must be set before creating the type, not after. For example, it " "must be set before :c:func:`PyType_Ready` is called on the type." msgstr "" -#: ../../c-api/typeobj.rst:1411 +#: ../../c-api/typeobj.rst:1436 msgid "" "The flag is set automatically on :ref:`static types ` if :c:" "member:`~PyTypeObject.tp_base` is NULL or ``&PyBaseObject_Type`` and :c:" "member:`~PyTypeObject.tp_new` is NULL." msgstr "" -#: ../../c-api/typeobj.rst:1417 +#: ../../c-api/typeobj.rst:1442 msgid "" "This flag is not inherited. However, subclasses will not be instantiable " "unless they provide a non-NULL :c:member:`~PyTypeObject.tp_new` (which is " "only possible via the C API)." msgstr "" -#: ../../c-api/typeobj.rst:1424 +#: ../../c-api/typeobj.rst:1449 msgid "" "To disallow instantiating a class directly but allow instantiating its " "subclasses (e.g. for an :term:`abstract base class`), do not use this flag. " "Instead, make :c:member:`~PyTypeObject.tp_new` only succeed for subclasses." msgstr "" -#: ../../c-api/typeobj.rst:1435 +#: ../../c-api/typeobj.rst:1460 msgid "" "This bit indicates that instances of the class may match mapping patterns " "when used as the subject of a :keyword:`match` block. It is automatically " @@ -2500,23 +2533,23 @@ msgid "" "unset when registering :class:`collections.abc.Sequence`." msgstr "" -#: ../../c-api/typeobj.rst:1442 ../../c-api/typeobj.rst:1464 +#: ../../c-api/typeobj.rst:1467 ../../c-api/typeobj.rst:1489 msgid "" ":c:macro:`Py_TPFLAGS_MAPPING` and :c:macro:`Py_TPFLAGS_SEQUENCE` are " "mutually exclusive; it is an error to enable both flags simultaneously." msgstr "" -#: ../../c-api/typeobj.rst:1447 +#: ../../c-api/typeobj.rst:1472 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_SEQUENCE`." msgstr "" -#: ../../c-api/typeobj.rst:1450 ../../c-api/typeobj.rst:1472 +#: ../../c-api/typeobj.rst:1475 ../../c-api/typeobj.rst:1497 msgid ":pep:`634` -- Structural Pattern Matching: Specification" msgstr "" -#: ../../c-api/typeobj.rst:1457 +#: ../../c-api/typeobj.rst:1482 msgid "" "This bit indicates that instances of the class may match sequence patterns " "when used as the subject of a :keyword:`match` block. It is automatically " @@ -2524,224 +2557,85 @@ msgid "" "unset when registering :class:`collections.abc.Mapping`." msgstr "" -#: ../../c-api/typeobj.rst:1469 +#: ../../c-api/typeobj.rst:1494 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_MAPPING`." msgstr "" -#: ../../c-api/typeobj.rst:1479 +#: ../../c-api/typeobj.rst:1504 msgid "" "Internal. Do not set or unset this flag. To indicate that a class has " "changed call :c:func:`PyType_Modified`" msgstr "" -#: ../../c-api/typeobj.rst:1483 +#: ../../c-api/typeobj.rst:1508 msgid "" "This flag is present in header files, but is not be used. It will be removed " "in a future version of CPython" msgstr "" -#: ../../c-api/typeobj.rst:1489 +#: ../../c-api/typeobj.rst:1514 msgid "" "This macro does nothing. Historically, this would indicate that the :c:" "member:`~PyTypeObject.tp_version_tag` field was available and initialized." msgstr "" -#: ../../c-api/typeobj.rst:1499 +#: ../../c-api/typeobj.rst:1524 msgid "" "This bit indicates that instances of this type will have an \"inline " "values\" array (containing the object's attributes) placed directly after " "the end of the object." msgstr "" -#: ../../c-api/typeobj.rst:1503 +#: ../../c-api/typeobj.rst:1528 msgid "This requires that :c:macro:`Py_TPFLAGS_HAVE_GC` is set." msgstr "這要求必須設定 :c:macro:`Py_TPFLAGS_HAVE_GC`。" -#: ../../c-api/typeobj.rst:1514 +#: ../../c-api/typeobj.rst:1539 msgid "" "This bit indicates that this is an abstract type and therefore cannot be " "instantiated." msgstr "" -#: ../../c-api/typeobj.rst:1522 +#: ../../c-api/typeobj.rst:1547 msgid ":mod:`abc`" msgstr "" -#: ../../c-api/typeobj.rst:1527 +#: ../../c-api/typeobj.rst:1552 msgid "" "Internal. Do not set or unset this flag. Historically, this was a reserved " "flag for use in Stackless Python." msgstr "" -#: ../../c-api/typeobj.rst:1531 +#: ../../c-api/typeobj.rst:1556 msgid "" "This flag is present in header files, but is not be used. This may be " "removed in a future version of CPython." msgstr "" -#: ../../c-api/typeobj.rst:1539 +#: ../../c-api/typeobj.rst:1564 msgid "" "An optional pointer to a NUL-terminated C string giving the docstring for " "this type object. This is exposed as the :attr:`~type.__doc__` attribute on " "the type and instances of the type." msgstr "" -#: ../../c-api/typeobj.rst:1545 +#: ../../c-api/typeobj.rst:1570 msgid "This field is *not* inherited by subtypes." msgstr "此欄位不會被子型別繼承。" -#: ../../c-api/typeobj.rst:1552 +#: ../../c-api/typeobj.rst:1577 msgid "" "An optional pointer to a traversal function for the garbage collector. This " -"is only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set. The " -"signature is::" -msgstr "" - -#: ../../c-api/typeobj.rst:1555 -msgid "int tp_traverse(PyObject *self, visitproc visit, void *arg);" -msgstr "int tp_traverse(PyObject *self, visitproc visit, void *arg);" - -#: ../../c-api/typeobj.rst:1557 ../../c-api/typeobj.rst:1784 -msgid "" -"More information about Python's garbage collection scheme can be found in " -"section :ref:`supporting-cycle-detection`." -msgstr "" - -#: ../../c-api/typeobj.rst:1560 -msgid "" -"The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage " -"collector to detect reference cycles. A typical implementation of a :c:" -"member:`~PyTypeObject.tp_traverse` function simply calls :c:func:`Py_VISIT` " -"on each of the instance's members that are Python objects that the instance " -"owns. For example, this is function :c:func:`!local_traverse` from the :mod:" -"`!_thread` extension module::" -msgstr "" - -#: ../../c-api/typeobj.rst:1566 -msgid "" -"static int\n" -"local_traverse(PyObject *op, visitproc visit, void *arg)\n" -"{\n" -" localobject *self = (localobject *) op;\n" -" Py_VISIT(self->args);\n" -" Py_VISIT(self->kw);\n" -" Py_VISIT(self->dict);\n" -" return 0;\n" -"}" -msgstr "" -"static int\n" -"local_traverse(PyObject *op, visitproc visit, void *arg)\n" -"{\n" -" localobject *self = (localobject *) op;\n" -" Py_VISIT(self->args);\n" -" Py_VISIT(self->kw);\n" -" Py_VISIT(self->dict);\n" -" return 0;\n" -"}" - -#: ../../c-api/typeobj.rst:1576 -msgid "" -"Note that :c:func:`Py_VISIT` is called only on those members that can " -"participate in reference cycles. Although there is also a ``self->key`` " -"member, it can only be ``NULL`` or a Python string and therefore cannot be " -"part of a reference cycle." +"is only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set." msgstr "" #: ../../c-api/typeobj.rst:1580 -msgid "" -"On the other hand, even if you know a member can never be part of a cycle, " -"as a debugging aid you may want to visit it anyway just so the :mod:`gc` " -"module's :func:`~gc.get_referents` function will include it." -msgstr "" - -#: ../../c-api/typeobj.rst:1584 -msgid "" -"Heap types (:c:macro:`Py_TPFLAGS_HEAPTYPE`) must visit their type with::" +msgid "See :ref:`gc-traversal` for documentation." msgstr "" #: ../../c-api/typeobj.rst:1586 -msgid "Py_VISIT(Py_TYPE(self));" -msgstr "Py_VISIT(Py_TYPE(self));" - -#: ../../c-api/typeobj.rst:1588 -msgid "" -"It is only needed since Python 3.9. To support Python 3.8 and older, this " -"line must be conditional::" -msgstr "" - -#: ../../c-api/typeobj.rst:1591 -msgid "" -"#if PY_VERSION_HEX >= 0x03090000\n" -" Py_VISIT(Py_TYPE(self));\n" -"#endif" -msgstr "" -"#if PY_VERSION_HEX >= 0x03090000\n" -" Py_VISIT(Py_TYPE(self));\n" -"#endif" - -#: ../../c-api/typeobj.rst:1595 -msgid "" -"If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" -"`~PyTypeObject.tp_flags` field, the traverse function must call :c:func:" -"`PyObject_VisitManagedDict` like this::" -msgstr "" - -#: ../../c-api/typeobj.rst:1599 -msgid "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" -msgstr "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" - -#: ../../c-api/typeobj.rst:1602 -msgid "" -"When implementing :c:member:`~PyTypeObject.tp_traverse`, only the members " -"that the instance *owns* (by having :term:`strong references ` to them) must be visited. For instance, if an object supports " -"weak references via the :c:member:`~PyTypeObject.tp_weaklist` slot, the " -"pointer supporting the linked list (what *tp_weaklist* points to) must " -"**not** be visited as the instance does not directly own the weak references " -"to itself (the weakreference list is there to support the weak reference " -"machinery, but the instance has no strong reference to the elements inside " -"it, as they are allowed to be removed even if the instance is still alive)." -msgstr "" - -#: ../../c-api/typeobj.rst:1614 -msgid "" -"The traversal function must not have any side effects. It must not modify " -"the reference counts of any Python objects nor create or destroy any Python " -"objects." -msgstr "" - -#: ../../c-api/typeobj.rst:1618 -msgid "" -"Note that :c:func:`Py_VISIT` requires the *visit* and *arg* parameters to :c:" -"func:`!local_traverse` to have these specific names; don't name them just " -"anything." -msgstr "" - -#: ../../c-api/typeobj.rst:1622 -msgid "" -"Instances of :ref:`heap-allocated types ` hold a reference to " -"their type. Their traversal function must therefore either visit :c:func:" -"`Py_TYPE(self) `, or delegate this responsibility by calling " -"``tp_traverse`` of another heap-allocated type (such as a heap-allocated " -"superclass). If they do not, the type object may not be garbage-collected." -msgstr "" - -#: ../../c-api/typeobj.rst:1631 -msgid "" -"The :c:member:`~PyTypeObject.tp_traverse` function can be called from any " -"thread." -msgstr ":c:member:`~PyTypeObject.tp_traverse` 函式可以從任何執行緒呼叫。" - -#: ../../c-api/typeobj.rst:1636 -msgid "" -"Heap-allocated types are expected to visit ``Py_TYPE(self)`` in " -"``tp_traverse``. In earlier versions of Python, due to `bug 40217 `_, doing this may lead to crashes in subclasses." -msgstr "" - -#: ../../c-api/typeobj.rst:1645 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_clear` and the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:" @@ -2749,15 +2643,15 @@ msgid "" "are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1655 +#: ../../c-api/typeobj.rst:1596 msgid "An optional pointer to a clear function. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1657 +#: ../../c-api/typeobj.rst:1598 msgid "int tp_clear(PyObject *);" msgstr "int tp_clear(PyObject *);" -#: ../../c-api/typeobj.rst:1659 +#: ../../c-api/typeobj.rst:1600 msgid "" "The purpose of this function is to break reference cycles that are causing " "a :term:`cyclic isolate` so that the objects can be safely destroyed. A " @@ -2765,7 +2659,7 @@ msgid "" "to satisfy design invariants held during normal use." msgstr "" -#: ../../c-api/typeobj.rst:1664 +#: ../../c-api/typeobj.rst:1605 msgid "" ":c:member:`!tp_clear` does not need to delete references to objects that " "can't participate in reference cycles, such as Python strings or Python " @@ -2776,44 +2670,44 @@ msgid "" "func:`Py_CLEAR`.)" msgstr "" -#: ../../c-api/typeobj.rst:1672 +#: ../../c-api/typeobj.rst:1613 msgid "" "Any non-trivial cleanup should be performed in :c:member:`~PyTypeObject." "tp_finalize` instead of :c:member:`!tp_clear`." msgstr "" -#: ../../c-api/typeobj.rst:1677 +#: ../../c-api/typeobj.rst:1618 msgid "" "If :c:member:`!tp_clear` fails to break a reference cycle then the objects " "in the :term:`cyclic isolate` may remain indefinitely uncollectable " "(\"leak\"). See :data:`gc.garbage`." msgstr "" -#: ../../c-api/typeobj.rst:1683 +#: ../../c-api/typeobj.rst:1624 msgid "" "Referents (direct and indirect) might have already been cleared; they are " "not guaranteed to be in a consistent state." msgstr "" -#: ../../c-api/typeobj.rst:1688 +#: ../../c-api/typeobj.rst:1629 msgid "" "The :c:member:`~PyTypeObject.tp_clear` function can be called from any " "thread." msgstr ":c:member:`~PyTypeObject.tp_clear` 函式可以從任何執行緒呼叫。" -#: ../../c-api/typeobj.rst:1693 +#: ../../c-api/typeobj.rst:1634 msgid "" "An object is not guaranteed to be automatically cleared before its " "destructor (:c:member:`~PyTypeObject.tp_dealloc`) is called." msgstr "" -#: ../../c-api/typeobj.rst:1696 +#: ../../c-api/typeobj.rst:1637 msgid "" "This function differs from the destructor (:c:member:`~PyTypeObject." "tp_dealloc`) in the following ways:" msgstr "" -#: ../../c-api/typeobj.rst:1699 +#: ../../c-api/typeobj.rst:1640 msgid "" "The purpose of clearing an object is to remove references to other objects " "that might participate in a reference cycle. The purpose of the destructor, " @@ -2823,7 +2717,7 @@ msgid "" "`~PyTypeObject.tp_free`)." msgstr "" -#: ../../c-api/typeobj.rst:1705 +#: ../../c-api/typeobj.rst:1646 msgid "" "When :c:member:`!tp_clear` is called, other objects might still hold " "references to the object being cleared. Because of this, :c:member:`!" @@ -2833,7 +2727,7 @@ msgid "" "object itself by deallocating it." msgstr "" -#: ../../c-api/typeobj.rst:1711 +#: ../../c-api/typeobj.rst:1652 msgid "" ":c:member:`!tp_clear` might never be automatically called. An object's " "destructor, on the other hand, will be automatically called some time after " @@ -2841,20 +2735,20 @@ msgid "" "object or the object is a member of a :term:`cyclic isolate`)." msgstr "" -#: ../../c-api/typeobj.rst:1716 +#: ../../c-api/typeobj.rst:1657 msgid "" "No guarantees are made about when, if, or how often Python automatically " "clears an object, except:" msgstr "" -#: ../../c-api/typeobj.rst:1719 +#: ../../c-api/typeobj.rst:1660 msgid "" "Python will not automatically clear an object if it is reachable, i.e., " "there is a reference to it and it is not a member of a :term:`cyclic " "isolate`." msgstr "" -#: ../../c-api/typeobj.rst:1722 +#: ../../c-api/typeobj.rst:1663 msgid "" "Python will not automatically clear an object if it has not been " "automatically finalized (see :c:member:`~PyTypeObject.tp_finalize`). (If " @@ -2862,14 +2756,14 @@ msgid "" "automatically finalized again before it is cleared.)" msgstr "" -#: ../../c-api/typeobj.rst:1726 +#: ../../c-api/typeobj.rst:1667 msgid "" "If an object is a member of a :term:`cyclic isolate`, Python will not " "automatically clear it if any member of the cyclic isolate has not yet been " "automatically finalized (:c:member:`~PyTypeObject.tp_finalize`)." msgstr "" -#: ../../c-api/typeobj.rst:1729 +#: ../../c-api/typeobj.rst:1670 msgid "" "Python will not destroy an object until after any automatic calls to its :c:" "member:`!tp_clear` function have returned. This ensures that the act of " @@ -2877,20 +2771,20 @@ msgid "" "member:`!tp_clear` is still executing." msgstr "" -#: ../../c-api/typeobj.rst:1733 +#: ../../c-api/typeobj.rst:1674 msgid "" "Python will not automatically call :c:member:`!tp_clear` multiple times " "concurrently." msgstr "" -#: ../../c-api/typeobj.rst:1736 +#: ../../c-api/typeobj.rst:1677 msgid "" "CPython currently only automatically clears objects as needed to break " "reference cycles in a :term:`cyclic isolate`, but future versions might " "clear objects regularly before their destruction." msgstr "" -#: ../../c-api/typeobj.rst:1740 +#: ../../c-api/typeobj.rst:1681 msgid "" "Taken together, all :c:member:`~PyTypeObject.tp_clear` functions in the " "system must combine to break all reference cycles. This is subtle, and if " @@ -2903,7 +2797,7 @@ msgid "" "good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../c-api/typeobj.rst:1751 +#: ../../c-api/typeobj.rst:1692 msgid "" "Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the " "instance's references to those of its members that may be Python objects, " @@ -2911,7 +2805,7 @@ msgid "" "example::" msgstr "" -#: ../../c-api/typeobj.rst:1755 +#: ../../c-api/typeobj.rst:1696 msgid "" "static int\n" "local_clear(PyObject *op)\n" @@ -2935,7 +2829,7 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/typeobj.rst:1766 +#: ../../c-api/typeobj.rst:1707 msgid "" "The :c:func:`Py_CLEAR` macro should be used, because clearing references is " "delicate: the reference to the contained object must not be released (via :" @@ -2950,18 +2844,24 @@ msgid "" "performs the operations in a safe order." msgstr "" -#: ../../c-api/typeobj.rst:1778 +#: ../../c-api/typeobj.rst:1719 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, the clear function must call :c:func:" "`PyObject_ClearManagedDict` like this::" msgstr "" -#: ../../c-api/typeobj.rst:1782 +#: ../../c-api/typeobj.rst:1723 msgid "PyObject_ClearManagedDict((PyObject*)self);" msgstr "PyObject_ClearManagedDict((PyObject*)self);" -#: ../../c-api/typeobj.rst:1791 +#: ../../c-api/typeobj.rst:1725 +msgid "" +"More information about Python's garbage collection scheme can be found in " +"section :ref:`supporting-cycle-detection`." +msgstr "" + +#: ../../c-api/typeobj.rst:1732 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_traverse` and the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :" @@ -2969,22 +2869,22 @@ msgid "" "are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1805 +#: ../../c-api/typeobj.rst:1746 msgid "" "An optional pointer to the rich comparison function, whose signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1807 +#: ../../c-api/typeobj.rst:1748 msgid "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" msgstr "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" -#: ../../c-api/typeobj.rst:1809 +#: ../../c-api/typeobj.rst:1750 msgid "" "The first parameter is guaranteed to be an instance of the type that is " "defined by :c:type:`PyTypeObject`." msgstr "" -#: ../../c-api/typeobj.rst:1812 +#: ../../c-api/typeobj.rst:1753 msgid "" "The function should return the result of the comparison (usually ``Py_True`` " "or ``Py_False``). If the comparison is undefined, it must return " @@ -2992,50 +2892,50 @@ msgid "" "set an exception condition." msgstr "" -#: ../../c-api/typeobj.rst:1817 +#: ../../c-api/typeobj.rst:1758 msgid "" "The following constants are defined to be used as the third argument for :c:" "member:`~PyTypeObject.tp_richcompare` and for :c:func:`PyObject_RichCompare`:" msgstr "" -#: ../../c-api/typeobj.rst:1823 +#: ../../c-api/typeobj.rst:1764 msgid "Constant" msgstr "常數" -#: ../../c-api/typeobj.rst:1823 +#: ../../c-api/typeobj.rst:1764 msgid "Comparison" msgstr "" -#: ../../c-api/typeobj.rst:1825 +#: ../../c-api/typeobj.rst:1766 msgid "``<``" msgstr "``<``" -#: ../../c-api/typeobj.rst:1827 +#: ../../c-api/typeobj.rst:1768 msgid "``<=``" msgstr "``<=``" -#: ../../c-api/typeobj.rst:1829 +#: ../../c-api/typeobj.rst:1770 msgid "``==``" msgstr "``==``" -#: ../../c-api/typeobj.rst:1831 +#: ../../c-api/typeobj.rst:1772 msgid "``!=``" msgstr "``!=``" -#: ../../c-api/typeobj.rst:1833 +#: ../../c-api/typeobj.rst:1774 msgid "``>``" msgstr "``>``" -#: ../../c-api/typeobj.rst:1835 +#: ../../c-api/typeobj.rst:1776 msgid "``>=``" msgstr "``>=``" -#: ../../c-api/typeobj.rst:1838 +#: ../../c-api/typeobj.rst:1779 msgid "" "The following macro is defined to ease writing rich comparison functions:" msgstr "" -#: ../../c-api/typeobj.rst:1842 +#: ../../c-api/typeobj.rst:1783 msgid "" "Return ``Py_True`` or ``Py_False`` from the function, depending on the " "result of a comparison. VAL_A and VAL_B must be orderable by C comparison " @@ -3043,15 +2943,15 @@ msgid "" "specifies the requested operation, as for :c:func:`PyObject_RichCompare`." msgstr "" -#: ../../c-api/typeobj.rst:1848 +#: ../../c-api/typeobj.rst:1789 msgid "The returned value is a new :term:`strong reference`." msgstr "" -#: ../../c-api/typeobj.rst:1850 +#: ../../c-api/typeobj.rst:1791 msgid "On error, sets an exception and returns ``NULL`` from the function." msgstr "" -#: ../../c-api/typeobj.rst:1858 +#: ../../c-api/typeobj.rst:1799 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_hash`: a subtype inherits :c:member:`~PyTypeObject.tp_richcompare` and :c:" @@ -3059,7 +2959,7 @@ msgid "" "tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1865 +#: ../../c-api/typeobj.rst:1806 msgid "" ":c:data:`PyBaseObject_Type` provides a :c:member:`~PyTypeObject." "tp_richcompare` implementation, which may be inherited. However, if only :c:" @@ -3068,13 +2968,13 @@ msgid "" "comparisons." msgstr "" -#: ../../c-api/typeobj.rst:1874 +#: ../../c-api/typeobj.rst:1815 msgid "" "While this field is still supported, :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` " "should be used instead, if at all possible." msgstr "" -#: ../../c-api/typeobj.rst:1877 +#: ../../c-api/typeobj.rst:1818 msgid "" "If the instances of this type are weakly referenceable, this field is " "greater than zero and contains the offset in the instance structure of the " @@ -3084,19 +2984,19 @@ msgid "" "`PyObject*` which is initialized to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1884 +#: ../../c-api/typeobj.rst:1825 msgid "" "Do not confuse this field with :c:member:`~PyTypeObject.tp_weaklist`; that " "is the list head for weak references to the type object itself." msgstr "" -#: ../../c-api/typeobj.rst:1887 +#: ../../c-api/typeobj.rst:1828 msgid "" "It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit " "and :c:member:`~PyTypeObject.tp_weaklistoffset`." msgstr "" -#: ../../c-api/typeobj.rst:1892 +#: ../../c-api/typeobj.rst:1833 msgid "" "This field is inherited by subtypes, but see the rules listed below. A " "subtype may override this offset; this means that the subtype uses a " @@ -3105,7 +3005,7 @@ msgid "" "not be a problem." msgstr "" -#: ../../c-api/typeobj.rst:1899 +#: ../../c-api/typeobj.rst:1840 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, then :c:member:`~PyTypeObject." @@ -3113,32 +3013,32 @@ msgid "" "unsafe to use this field." msgstr "" -#: ../../c-api/typeobj.rst:1909 +#: ../../c-api/typeobj.rst:1850 msgid "" "An optional pointer to a function that returns an :term:`iterator` for the " "object. Its presence normally signals that the instances of this type are :" "term:`iterable` (although sequences may be iterable without this function)." msgstr "" -#: ../../c-api/typeobj.rst:1913 +#: ../../c-api/typeobj.rst:1854 msgid "This function has the same signature as :c:func:`PyObject_GetIter`::" msgstr "" -#: ../../c-api/typeobj.rst:1915 +#: ../../c-api/typeobj.rst:1856 msgid "PyObject *tp_iter(PyObject *self);" msgstr "PyObject *tp_iter(PyObject *self);" -#: ../../c-api/typeobj.rst:1926 +#: ../../c-api/typeobj.rst:1867 msgid "" "An optional pointer to a function that returns the next item in an :term:" "`iterator`. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1929 +#: ../../c-api/typeobj.rst:1870 msgid "PyObject *tp_iternext(PyObject *self);" msgstr "PyObject *tp_iternext(PyObject *self);" -#: ../../c-api/typeobj.rst:1931 +#: ../../c-api/typeobj.rst:1872 msgid "" "When the iterator is :term:`exhausted`, the ``tp_iternext`` function must " "return ``NULL``; a :exc:`StopIteration` exception may or may not be set. " @@ -3146,74 +3046,74 @@ msgid "" "``tp_iternext`` signals that the instances of this type are iterators." msgstr "" -#: ../../c-api/typeobj.rst:1937 +#: ../../c-api/typeobj.rst:1878 msgid "" "Iterator types should also define the :c:member:`~PyTypeObject.tp_iter` " "function, and that function should return the iterator instance itself (not " "a new iterator instance)." msgstr "" -#: ../../c-api/typeobj.rst:1941 +#: ../../c-api/typeobj.rst:1882 msgid "This function has the same signature as :c:func:`PyIter_Next`." msgstr "" -#: ../../c-api/typeobj.rst:1952 +#: ../../c-api/typeobj.rst:1893 msgid "" "An optional pointer to a static ``NULL``-terminated array of :c:type:" "`PyMethodDef` structures, declaring regular methods of this type." msgstr "" -#: ../../c-api/typeobj.rst:1955 +#: ../../c-api/typeobj.rst:1896 msgid "" "For each entry in the array, an entry is added to the type's dictionary " "(see :c:member:`~PyTypeObject.tp_dict` below) containing a method descriptor." msgstr "" -#: ../../c-api/typeobj.rst:1960 +#: ../../c-api/typeobj.rst:1901 msgid "" "This field is not inherited by subtypes (methods are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1968 +#: ../../c-api/typeobj.rst:1909 msgid "" "An optional pointer to a static ``NULL``-terminated array of :c:type:" "`PyMemberDef` structures, declaring regular data members (fields or slots) " "of instances of this type." msgstr "" -#: ../../c-api/typeobj.rst:1972 +#: ../../c-api/typeobj.rst:1913 msgid "" "For each entry in the array, an entry is added to the type's dictionary " "(see :c:member:`~PyTypeObject.tp_dict` below) containing a member descriptor." msgstr "" -#: ../../c-api/typeobj.rst:1977 +#: ../../c-api/typeobj.rst:1918 msgid "" "This field is not inherited by subtypes (members are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1985 +#: ../../c-api/typeobj.rst:1926 msgid "" "An optional pointer to a static ``NULL``-terminated array of :c:type:" "`PyGetSetDef` structures, declaring computed attributes of instances of this " "type." msgstr "" -#: ../../c-api/typeobj.rst:1988 +#: ../../c-api/typeobj.rst:1929 msgid "" "For each entry in the array, an entry is added to the type's dictionary " "(see :c:member:`~PyTypeObject.tp_dict` below) containing a getset descriptor." msgstr "" -#: ../../c-api/typeobj.rst:1993 +#: ../../c-api/typeobj.rst:1934 msgid "" "This field is not inherited by subtypes (computed attributes are inherited " "through a different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:2001 +#: ../../c-api/typeobj.rst:1940 msgid "" "An optional pointer to a base type from which type properties are " "inherited. At this level, only single inheritance is supported; multiple " @@ -3221,7 +3121,11 @@ msgid "" "metatype." msgstr "" -#: ../../c-api/typeobj.rst:2009 +#: ../../c-api/typeobj.rst:1944 +msgid "For the corresponding slot ID, see :c:macro:`Py_tp_base`." +msgstr "" + +#: ../../c-api/typeobj.rst:1950 msgid "" "Slot initialization is subject to the rules of initializing globals. C99 " "requires the initializers to be \"address constants\". Function designators " @@ -3229,7 +3133,7 @@ msgid "" "valid C99 address constants." msgstr "" -#: ../../c-api/typeobj.rst:2014 +#: ../../c-api/typeobj.rst:1955 msgid "" "However, the unary '&' operator applied to a non-static variable like :c:" "data:`PyBaseObject_Type` is not required to produce an address constant. " @@ -3237,27 +3141,27 @@ msgid "" "strictly standard conforming in this particular behavior." msgstr "" -#: ../../c-api/typeobj.rst:2020 +#: ../../c-api/typeobj.rst:1961 msgid "" "Consequently, :c:member:`~PyTypeObject.tp_base` should be set in the " "extension module's init function." msgstr "" -#: ../../c-api/typeobj.rst:2025 +#: ../../c-api/typeobj.rst:1966 msgid "This field is not inherited by subtypes (obviously)." msgstr "" -#: ../../c-api/typeobj.rst:2029 +#: ../../c-api/typeobj.rst:1970 msgid "" "This field defaults to ``&PyBaseObject_Type`` (which to Python programmers " "is known as the type :class:`object`)." msgstr "" -#: ../../c-api/typeobj.rst:2035 +#: ../../c-api/typeobj.rst:1976 msgid "The type's dictionary is stored here by :c:func:`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:2037 +#: ../../c-api/typeobj.rst:1978 msgid "" "This field should normally be initialized to ``NULL`` before PyType_Ready is " "called; it may also be initialized to a dictionary containing initial " @@ -3268,73 +3172,73 @@ msgid "" "be treated as read-only." msgstr "" -#: ../../c-api/typeobj.rst:2045 +#: ../../c-api/typeobj.rst:1986 msgid "" "Some types may not store their dictionary in this slot. Use :c:func:" "`PyType_GetDict` to retrieve the dictionary for an arbitrary type." msgstr "" -#: ../../c-api/typeobj.rst:2051 +#: ../../c-api/typeobj.rst:1992 msgid "" "Internals detail: For static builtin types, this is always ``NULL``. " "Instead, the dict for such types is stored on ``PyInterpreterState``. Use :c:" "func:`PyType_GetDict` to get the dict for an arbitrary type." msgstr "" -#: ../../c-api/typeobj.rst:2057 +#: ../../c-api/typeobj.rst:1998 msgid "" "This field is not inherited by subtypes (though the attributes defined in " "here are inherited through a different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:2062 +#: ../../c-api/typeobj.rst:2003 msgid "" "If this field is ``NULL``, :c:func:`PyType_Ready` will assign a new " "dictionary to it." msgstr "" -#: ../../c-api/typeobj.rst:2067 +#: ../../c-api/typeobj.rst:2008 msgid "" "It is not safe to use :c:func:`PyDict_SetItem` on or otherwise modify :c:" "member:`~PyTypeObject.tp_dict` with the dictionary C-API." msgstr "" -#: ../../c-api/typeobj.rst:2075 +#: ../../c-api/typeobj.rst:2016 msgid "An optional pointer to a \"descriptor get\" function." msgstr "" -#: ../../c-api/typeobj.rst:2077 ../../c-api/typeobj.rst:2095 -#: ../../c-api/typeobj.rst:2161 ../../c-api/typeobj.rst:2193 -#: ../../c-api/typeobj.rst:2218 +#: ../../c-api/typeobj.rst:2018 ../../c-api/typeobj.rst:2036 +#: ../../c-api/typeobj.rst:2102 ../../c-api/typeobj.rst:2134 +#: ../../c-api/typeobj.rst:2159 msgid "The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:2079 +#: ../../c-api/typeobj.rst:2020 msgid "PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);" msgstr "" "PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);" -#: ../../c-api/typeobj.rst:2092 +#: ../../c-api/typeobj.rst:2033 msgid "" "An optional pointer to a function for setting and deleting a descriptor's " "value." msgstr "" -#: ../../c-api/typeobj.rst:2097 +#: ../../c-api/typeobj.rst:2038 msgid "int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value);" msgstr "int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value);" -#: ../../c-api/typeobj.rst:2099 +#: ../../c-api/typeobj.rst:2040 msgid "The *value* argument is set to ``NULL`` to delete the value." msgstr "" -#: ../../c-api/typeobj.rst:2110 +#: ../../c-api/typeobj.rst:2051 msgid "" "While this field is still supported, :c:macro:`Py_TPFLAGS_MANAGED_DICT` " "should be used instead, if at all possible." msgstr "" -#: ../../c-api/typeobj.rst:2113 +#: ../../c-api/typeobj.rst:2054 msgid "" "If the instances of this type have a dictionary containing instance " "variables, this field is non-zero and contains the offset in the instances " @@ -3342,19 +3246,19 @@ msgid "" "func:`PyObject_GenericGetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:2118 +#: ../../c-api/typeobj.rst:2059 msgid "" "Do not confuse this field with :c:member:`~PyTypeObject.tp_dict`; that is " "the dictionary for attributes of the type object itself." msgstr "" -#: ../../c-api/typeobj.rst:2121 +#: ../../c-api/typeobj.rst:2062 msgid "" "The value specifies the offset of the dictionary from the start of the " "instance structure." msgstr "" -#: ../../c-api/typeobj.rst:2123 +#: ../../c-api/typeobj.rst:2064 msgid "" "The :c:member:`~PyTypeObject.tp_dictoffset` should be regarded as write-" "only. To get the pointer to the dictionary call :c:func:" @@ -3363,13 +3267,13 @@ msgid "" "to call :c:func:`PyObject_GetAttr` when accessing an attribute on the object." msgstr "" -#: ../../c-api/typeobj.rst:2129 +#: ../../c-api/typeobj.rst:2070 msgid "" "It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit and :c:" "member:`~PyTypeObject.tp_dictoffset`." msgstr "" -#: ../../c-api/typeobj.rst:2134 +#: ../../c-api/typeobj.rst:2075 msgid "" "This field is inherited by subtypes. A subtype should not override this " "offset; doing so could be unsafe, if C code tries to access the dictionary " @@ -3377,25 +3281,25 @@ msgid "" "`Py_TPFLAGS_MANAGED_DICT`." msgstr "" -#: ../../c-api/typeobj.rst:2141 +#: ../../c-api/typeobj.rst:2082 msgid "" "This slot has no default. For :ref:`static types `, if the " "field is ``NULL`` then no :attr:`~object.__dict__` gets created for " "instances." msgstr "" -#: ../../c-api/typeobj.rst:2144 +#: ../../c-api/typeobj.rst:2085 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, then :c:member:`~PyTypeObject.tp_dictoffset` " "will be set to ``-1``, to indicate that it is unsafe to use this field." msgstr "" -#: ../../c-api/typeobj.rst:2154 +#: ../../c-api/typeobj.rst:2095 msgid "An optional pointer to an instance initialization function." msgstr "" -#: ../../c-api/typeobj.rst:2156 +#: ../../c-api/typeobj.rst:2097 msgid "" "This function corresponds to the :meth:`~object.__init__` method of " "classes. Like :meth:`!__init__`, it is possible to create an instance " @@ -3403,18 +3307,18 @@ msgid "" "instance by calling its :meth:`!__init__` method again." msgstr "" -#: ../../c-api/typeobj.rst:2163 +#: ../../c-api/typeobj.rst:2104 msgid "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" msgstr "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:2165 +#: ../../c-api/typeobj.rst:2106 msgid "" "The self argument is the instance to be initialized; the *args* and *kwds* " "arguments represent positional and keyword arguments of the call to :meth:" "`~object.__init__`." msgstr "" -#: ../../c-api/typeobj.rst:2169 +#: ../../c-api/typeobj.rst:2110 msgid "" "The :c:member:`~PyTypeObject.tp_init` function, if not ``NULL``, is called " "when an instance is created normally by calling its type, after the type's :" @@ -3426,53 +3330,53 @@ msgid "" "subtype's :c:member:`~PyTypeObject.tp_init` is called." msgstr "" -#: ../../c-api/typeobj.rst:2176 +#: ../../c-api/typeobj.rst:2117 msgid "Returns ``0`` on success, ``-1`` and sets an exception on error." msgstr "" -#: ../../c-api/typeobj.rst:2184 +#: ../../c-api/typeobj.rst:2125 msgid "" "For :ref:`static types ` this field does not have a default." msgstr "" -#: ../../c-api/typeobj.rst:2191 +#: ../../c-api/typeobj.rst:2132 msgid "An optional pointer to an instance allocation function." msgstr "" -#: ../../c-api/typeobj.rst:2195 +#: ../../c-api/typeobj.rst:2136 msgid "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" msgstr "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" -#: ../../c-api/typeobj.rst:2199 +#: ../../c-api/typeobj.rst:2140 msgid "" "Static subtypes inherit this slot, which will be :c:func:" "`PyType_GenericAlloc` if inherited from :class:`object`." msgstr "" -#: ../../c-api/typeobj.rst:2202 ../../c-api/typeobj.rst:2273 +#: ../../c-api/typeobj.rst:2143 ../../c-api/typeobj.rst:2214 msgid ":ref:`Heap subtypes ` do not inherit this slot." msgstr "" -#: ../../c-api/typeobj.rst:2206 +#: ../../c-api/typeobj.rst:2147 msgid "" "For heap subtypes, this field is always set to :c:func:`PyType_GenericAlloc`." msgstr "" -#: ../../c-api/typeobj.rst:2209 ../../c-api/typeobj.rst:2281 +#: ../../c-api/typeobj.rst:2150 ../../c-api/typeobj.rst:2222 msgid "For static subtypes, this slot is inherited (see above)." msgstr "" -#: ../../c-api/typeobj.rst:2216 +#: ../../c-api/typeobj.rst:2157 msgid "An optional pointer to an instance creation function." msgstr "" -#: ../../c-api/typeobj.rst:2220 +#: ../../c-api/typeobj.rst:2161 msgid "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" msgstr "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:2222 +#: ../../c-api/typeobj.rst:2163 msgid "" "The *subtype* argument is the type of the object being created; the *args* " "and *kwds* arguments represent positional and keyword arguments of the call " @@ -3481,7 +3385,7 @@ msgid "" "that type (but not an unrelated type)." msgstr "" -#: ../../c-api/typeobj.rst:2228 +#: ../../c-api/typeobj.rst:2169 msgid "" "The :c:member:`~PyTypeObject.tp_new` function should call ``subtype-" ">tp_alloc(subtype, nitems)`` to allocate space for the object, and then do " @@ -3493,20 +3397,20 @@ msgid "" "be deferred to :c:member:`~PyTypeObject.tp_init`." msgstr "" -#: ../../c-api/typeobj.rst:2236 +#: ../../c-api/typeobj.rst:2177 msgid "" "Set the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag to disallow " "creating instances of the type in Python." msgstr "" -#: ../../c-api/typeobj.rst:2241 +#: ../../c-api/typeobj.rst:2182 msgid "" "This field is inherited by subtypes, except it is not inherited by :ref:" "`static types ` whose :c:member:`~PyTypeObject.tp_base` is " "``NULL`` or ``&PyBaseObject_Type``." msgstr "" -#: ../../c-api/typeobj.rst:2247 +#: ../../c-api/typeobj.rst:2188 msgid "" "For :ref:`static types ` this field has no default. This means " "if the slot is defined as ``NULL``, the type cannot be called to create new " @@ -3514,22 +3418,22 @@ msgid "" "factory function." msgstr "" -#: ../../c-api/typeobj.rst:2257 +#: ../../c-api/typeobj.rst:2198 msgid "" "An optional pointer to an instance deallocation function. Its signature is::" msgstr "" -#: ../../c-api/typeobj.rst:2259 +#: ../../c-api/typeobj.rst:2200 msgid "void tp_free(void *self);" msgstr "void tp_free(void *self);" -#: ../../c-api/typeobj.rst:2261 +#: ../../c-api/typeobj.rst:2202 msgid "" "This function must free the memory allocated by :c:member:`~PyTypeObject." "tp_alloc`." msgstr "" -#: ../../c-api/typeobj.rst:2266 +#: ../../c-api/typeobj.rst:2207 msgid "" "Static subtypes inherit this slot, which will be :c:func:`PyObject_Free` if " "inherited from :class:`object`. Exception: If the type supports garbage " @@ -3538,18 +3442,18 @@ msgid "" "this slot is not inherited but instead defaults to :c:func:`PyObject_GC_Del`." msgstr "" -#: ../../c-api/typeobj.rst:2277 +#: ../../c-api/typeobj.rst:2218 msgid "" "For :ref:`heap subtypes `, this slot defaults to a deallocator " "suitable to match :c:func:`PyType_GenericAlloc` and the value of the :c:" "macro:`Py_TPFLAGS_HAVE_GC` flag." msgstr "" -#: ../../c-api/typeobj.rst:2288 +#: ../../c-api/typeobj.rst:2229 msgid "An optional pointer to a function called by the garbage collector." msgstr "" -#: ../../c-api/typeobj.rst:2290 +#: ../../c-api/typeobj.rst:2231 msgid "" "The garbage collector needs to know whether a particular object is " "collectible or not. Normally, it is sufficient to look at the object's " @@ -3561,93 +3465,90 @@ msgid "" "instance. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:2298 +#: ../../c-api/typeobj.rst:2239 msgid "int tp_is_gc(PyObject *self);" msgstr "int tp_is_gc(PyObject *self);" -#: ../../c-api/typeobj.rst:2300 +#: ../../c-api/typeobj.rst:2241 msgid "" "(The only example of this are types themselves. The metatype, :c:data:" "`PyType_Type`, defines this function to distinguish between statically and :" "ref:`dynamically allocated types `.)" msgstr "" -#: ../../c-api/typeobj.rst:2310 +#: ../../c-api/typeobj.rst:2251 msgid "" "This slot has no default. If this field is ``NULL``, :c:macro:" "`Py_TPFLAGS_HAVE_GC` is used as the functional equivalent." msgstr "" -#: ../../c-api/typeobj.rst:2318 +#: ../../c-api/typeobj.rst:2257 msgid "Tuple of base types." msgstr "" -#: ../../c-api/typeobj.rst:2320 ../../c-api/typeobj.rst:2344 +#: ../../c-api/typeobj.rst:2259 ../../c-api/typeobj.rst:2280 msgid "" "This field should be set to ``NULL`` and treated as read-only. Python will " "fill it in when the type is :c:func:`initialized `." msgstr "" -#: ../../c-api/typeobj.rst:2323 -msgid "" -"For dynamically created classes, the :c:data:`Py_tp_bases` :c:type:`slot " -"` can be used instead of the *bases* argument of :c:func:" -"`PyType_FromSpecWithBases`. The argument form is preferred." +#: ../../c-api/typeobj.rst:2262 +msgid "For the corresponding slot ID, see :c:macro:`Py_tp_bases`." msgstr "" -#: ../../c-api/typeobj.rst:2330 +#: ../../c-api/typeobj.rst:2266 msgid "" "Multiple inheritance does not work well for statically defined types. If you " "set ``tp_bases`` to a tuple, Python will not raise an error, but some slots " "will only be inherited from the first base." msgstr "" -#: ../../c-api/typeobj.rst:2336 ../../c-api/typeobj.rst:2359 -#: ../../c-api/typeobj.rst:2376 ../../c-api/typeobj.rst:2393 -#: ../../c-api/typeobj.rst:2409 +#: ../../c-api/typeobj.rst:2272 ../../c-api/typeobj.rst:2295 +#: ../../c-api/typeobj.rst:2312 ../../c-api/typeobj.rst:2329 +#: ../../c-api/typeobj.rst:2345 msgid "This field is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:2341 +#: ../../c-api/typeobj.rst:2277 msgid "" "Tuple containing the expanded set of base types, starting with the type " "itself and ending with :class:`object`, in Method Resolution Order." msgstr "" -#: ../../c-api/typeobj.rst:2349 +#: ../../c-api/typeobj.rst:2285 msgid "" "This field is not inherited; it is calculated fresh by :c:func:" "`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:2355 +#: ../../c-api/typeobj.rst:2291 msgid "Unused. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2364 +#: ../../c-api/typeobj.rst:2300 msgid "" "A collection of subclasses. Internal use only. May be an invalid pointer." msgstr "" -#: ../../c-api/typeobj.rst:2366 +#: ../../c-api/typeobj.rst:2302 msgid "" "To get a list of subclasses, call the Python method :py:meth:`~type." "__subclasses__`." msgstr "" -#: ../../c-api/typeobj.rst:2371 +#: ../../c-api/typeobj.rst:2307 msgid "" "For some types, this field does not hold a valid :c:expr:`PyObject*`. The " "type was changed to :c:expr:`void*` to indicate this." msgstr "" -#: ../../c-api/typeobj.rst:2381 +#: ../../c-api/typeobj.rst:2317 msgid "" "Weak reference list head, for weak references to this type object. Not " "inherited. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2386 +#: ../../c-api/typeobj.rst:2322 msgid "" "Internals detail: For the static builtin types this is always ``NULL``, even " "if weakrefs are added. Instead, the weakrefs for each are stored on " @@ -3655,27 +3556,27 @@ msgid "" "``_PyObject_GET_WEAKREFS_LISTPTR()`` macro to avoid the distinction." msgstr "" -#: ../../c-api/typeobj.rst:2400 +#: ../../c-api/typeobj.rst:2336 msgid "" "This field is deprecated. Use :c:member:`~PyTypeObject.tp_finalize` instead." msgstr "此欄位已被棄用。請改用 :c:member:`~PyTypeObject.tp_finalize`。" -#: ../../c-api/typeobj.rst:2405 +#: ../../c-api/typeobj.rst:2341 msgid "Used to index into the method cache. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2416 +#: ../../c-api/typeobj.rst:2352 msgid "" "An optional pointer to an instance finalization function. This is the C " "implementation of the :meth:`~object.__del__` special method. Its signature " "is::" msgstr "" -#: ../../c-api/typeobj.rst:2420 +#: ../../c-api/typeobj.rst:2356 msgid "void tp_finalize(PyObject *self);" msgstr "void tp_finalize(PyObject *self);" -#: ../../c-api/typeobj.rst:2422 +#: ../../c-api/typeobj.rst:2358 msgid "" "The primary purpose of finalization is to perform any non-trivial cleanup " "that must be performed before the object is destroyed, while the object and " @@ -3683,7 +3584,7 @@ msgid "" "consistent state. The finalizer is allowed to execute arbitrary Python code." msgstr "" -#: ../../c-api/typeobj.rst:2428 +#: ../../c-api/typeobj.rst:2364 msgid "" "Before Python automatically finalizes an object, some of the object's direct " "or indirect referents might have themselves been automatically finalized. " @@ -3691,14 +3592,14 @@ msgid "" "member:`~PyTypeObject.tp_clear`) yet." msgstr "" -#: ../../c-api/typeobj.rst:2433 +#: ../../c-api/typeobj.rst:2369 msgid "" "Other non-finalized objects might still be using a finalized object, so the " "finalizer must leave the object in a sane state (e.g., invariants are still " "met)." msgstr "" -#: ../../c-api/typeobj.rst:2439 +#: ../../c-api/typeobj.rst:2375 msgid "" "After Python automatically finalizes an object, Python might start " "automatically clearing (:c:member:`~PyTypeObject.tp_clear`) the object and " @@ -3707,7 +3608,7 @@ msgid "" "cleared referents." msgstr "" -#: ../../c-api/typeobj.rst:2447 +#: ../../c-api/typeobj.rst:2383 msgid "" "An object is not guaranteed to be automatically finalized before its " "destructor (:c:member:`~PyTypeObject.tp_dealloc`) is called. It is " @@ -3716,25 +3617,25 @@ msgid "" "finalized before destruction." msgstr "" -#: ../../c-api/typeobj.rst:2455 +#: ../../c-api/typeobj.rst:2391 msgid "" "The :c:member:`~PyTypeObject.tp_finalize` function can be called from any " "thread, although the :term:`GIL` will be held." msgstr "" -#: ../../c-api/typeobj.rst:2460 +#: ../../c-api/typeobj.rst:2396 msgid "" "The :c:member:`!tp_finalize` function can be called during shutdown, after " "some global variables have been deleted. See the documentation of the :meth:" "`~object.__del__` method for details." msgstr "" -#: ../../c-api/typeobj.rst:2464 +#: ../../c-api/typeobj.rst:2400 msgid "" "When Python finalizes an object, it behaves like the following algorithm:" msgstr "" -#: ../../c-api/typeobj.rst:2466 +#: ../../c-api/typeobj.rst:2402 msgid "" "Python might mark the object as *finalized*. Currently, Python always marks " "objects whose type supports garbage collection (i.e., the :c:macro:" @@ -3742,13 +3643,13 @@ msgid "" "never marks other types of objects; this might change in a future version." msgstr "" -#: ../../c-api/typeobj.rst:2471 +#: ../../c-api/typeobj.rst:2407 msgid "" "If the object is not marked as *finalized* and its :c:member:`!tp_finalize` " "finalizer function is non-``NULL``, the finalizer function is called." msgstr "" -#: ../../c-api/typeobj.rst:2474 +#: ../../c-api/typeobj.rst:2410 msgid "" "If the finalizer function was called and the finalizer made the object " "reachable (i.e., there is a reference to the object and it is not a member " @@ -3758,7 +3659,7 @@ msgid "" "make it reachable, i.e., the object is (still) a member of a cyclic isolate." msgstr "" -#: ../../c-api/typeobj.rst:2481 +#: ../../c-api/typeobj.rst:2417 msgid "" "If the finalizer resurrected the object, the object's pending destruction is " "canceled and the object's *finalized* mark might be removed if present. " @@ -3766,7 +3667,7 @@ msgid "" "future version." msgstr "" -#: ../../c-api/typeobj.rst:2486 +#: ../../c-api/typeobj.rst:2422 msgid "" "*Automatic finalization* refers to any finalization performed by Python " "except via calls to :c:func:`PyObject_CallFinalizer` or :c:func:" @@ -3774,14 +3675,14 @@ msgid "" "or how often an object is automatically finalized, except:" msgstr "" -#: ../../c-api/typeobj.rst:2491 +#: ../../c-api/typeobj.rst:2427 msgid "" "Python will not automatically finalize an object if it is reachable, i.e., " "there is a reference to it and it is not a member of a :term:`cyclic " "isolate`." msgstr "" -#: ../../c-api/typeobj.rst:2494 +#: ../../c-api/typeobj.rst:2430 msgid "" "Python will not automatically finalize an object if finalizing it would not " "mark the object as *finalized*. Currently, this applies to objects whose " @@ -3791,53 +3692,53 @@ msgid "" "`PyObject_CallFinalizerFromDealloc`." msgstr "" -#: ../../c-api/typeobj.rst:2500 +#: ../../c-api/typeobj.rst:2436 msgid "" "Python will not automatically finalize any two members of a :term:`cyclic " "isolate` concurrently." msgstr "" -#: ../../c-api/typeobj.rst:2502 +#: ../../c-api/typeobj.rst:2438 msgid "" "Python will not automatically finalize an object after it has automatically " "cleared (:c:member:`~PyTypeObject.tp_clear`) the object." msgstr "" -#: ../../c-api/typeobj.rst:2504 +#: ../../c-api/typeobj.rst:2440 msgid "" "If an object is a member of a :term:`cyclic isolate`, Python will not " "automatically finalize it after automatically clearing (see :c:member:" "`~PyTypeObject.tp_clear`) any other member." msgstr "" -#: ../../c-api/typeobj.rst:2507 +#: ../../c-api/typeobj.rst:2443 msgid "" "Python will automatically finalize every member of a :term:`cyclic isolate` " "before it automatically clears (see :c:member:`~PyTypeObject.tp_clear`) any " "of them." msgstr "" -#: ../../c-api/typeobj.rst:2510 +#: ../../c-api/typeobj.rst:2446 msgid "" "If Python is going to automatically clear an object (:c:member:" "`~PyTypeObject.tp_clear`), it will automatically finalize the object first." msgstr "" -#: ../../c-api/typeobj.rst:2514 +#: ../../c-api/typeobj.rst:2450 msgid "" "Python currently only automatically finalizes objects that are members of a :" "term:`cyclic isolate`, but future versions might finalize objects regularly " "before their destruction." msgstr "" -#: ../../c-api/typeobj.rst:2518 +#: ../../c-api/typeobj.rst:2454 msgid "" "To manually finalize an object, do not call this function directly; call :c:" "func:`PyObject_CallFinalizer` or :c:func:`PyObject_CallFinalizerFromDealloc` " "instead." msgstr "" -#: ../../c-api/typeobj.rst:2522 +#: ../../c-api/typeobj.rst:2458 msgid "" ":c:member:`~PyTypeObject.tp_finalize` should leave the current exception " "status unchanged. The recommended way to write a non-trivial finalizer is " @@ -3848,7 +3749,7 @@ msgid "" "`PyErr_WriteUnraisable` or :c:func:`PyErr_FormatUnraisable`. For example::" msgstr "" -#: ../../c-api/typeobj.rst:2531 +#: ../../c-api/typeobj.rst:2467 msgid "" "static void\n" "foo_finalize(PyObject *self)\n" @@ -3871,26 +3772,26 @@ msgid "" "}" msgstr "" -#: ../../c-api/typeobj.rst:2559 +#: ../../c-api/typeobj.rst:2495 msgid "" "Before version 3.8 it was necessary to set the :c:macro:" "`Py_TPFLAGS_HAVE_FINALIZE` flags bit in order for this field to be used. " "This is no longer required." msgstr "" -#: ../../c-api/typeobj.rst:2565 +#: ../../c-api/typeobj.rst:2501 msgid ":pep:`442`: \"Safe object finalization\"" msgstr "" -#: ../../c-api/typeobj.rst:2568 +#: ../../c-api/typeobj.rst:2504 msgid ":c:func:`PyObject_CallFinalizer`" msgstr ":c:func:`PyObject_CallFinalizer`" -#: ../../c-api/typeobj.rst:2569 +#: ../../c-api/typeobj.rst:2505 msgid ":c:func:`PyObject_CallFinalizerFromDealloc`" msgstr ":c:func:`PyObject_CallFinalizerFromDealloc`" -#: ../../c-api/typeobj.rst:2576 +#: ../../c-api/typeobj.rst:2512 msgid "" "A :ref:`vectorcall function ` to use for calls of this type " "object (rather than instances). In other words, ``tp_vectorcall`` can be " @@ -3898,13 +3799,13 @@ msgid "" "of *type*." msgstr "" -#: ../../c-api/typeobj.rst:2581 +#: ../../c-api/typeobj.rst:2517 msgid "" "As with any vectorcall function, if ``tp_vectorcall`` is ``NULL``, the " "*tp_call* protocol (``Py_TYPE(type)->tp_call``) is used instead." msgstr "" -#: ../../c-api/typeobj.rst:2586 +#: ../../c-api/typeobj.rst:2522 msgid "" "The :ref:`vectorcall protocol ` requires that the vectorcall " "function has the same behavior as the corresponding ``tp_call``. This means " @@ -3912,27 +3813,27 @@ msgid "" ">tp_call``." msgstr "" -#: ../../c-api/typeobj.rst:2591 +#: ../../c-api/typeobj.rst:2527 msgid "" "Specifically, if *type* uses the default metaclass, ``type->tp_vectorcall`` " "must behave the same as :c:expr:`PyType_Type->tp_call`, which:" msgstr "" -#: ../../c-api/typeobj.rst:2595 +#: ../../c-api/typeobj.rst:2531 msgid "calls ``type->tp_new``," msgstr "呼叫 ``type->tp_new``," -#: ../../c-api/typeobj.rst:2597 +#: ../../c-api/typeobj.rst:2533 msgid "" "if the result is a subclass of *type*, calls ``type->tp_init`` on the result " "of ``tp_new``, and" msgstr "" -#: ../../c-api/typeobj.rst:2600 +#: ../../c-api/typeobj.rst:2536 msgid "returns the result of ``tp_new``." msgstr "回傳 ``tp_new`` 的結果。" -#: ../../c-api/typeobj.rst:2602 +#: ../../c-api/typeobj.rst:2538 msgid "" "Typically, ``tp_vectorcall`` is overridden to optimize this process for " "specific :c:member:`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject." @@ -3941,65 +3842,65 @@ msgid "" "__init__`, respectively)." msgstr "" -#: ../../c-api/typeobj.rst:2613 +#: ../../c-api/typeobj.rst:2549 msgid "This field is never inherited." msgstr "" -#: ../../c-api/typeobj.rst:2615 +#: ../../c-api/typeobj.rst:2551 msgid "(the field exists since 3.8 but it's only used since 3.9)" msgstr "" -#: ../../c-api/typeobj.rst:2620 +#: ../../c-api/typeobj.rst:2556 msgid "Internal. Do not use." msgstr "" -#: ../../c-api/typeobj.rst:2628 +#: ../../c-api/typeobj.rst:2564 msgid "Static Types" msgstr "靜態型別" -#: ../../c-api/typeobj.rst:2630 +#: ../../c-api/typeobj.rst:2566 msgid "" "Traditionally, types defined in C code are *static*, that is, a static :c:" "type:`PyTypeObject` structure is defined directly in code and initialized " "using :c:func:`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:2634 +#: ../../c-api/typeobj.rst:2570 msgid "" "This results in types that are limited relative to types defined in Python:" msgstr "" -#: ../../c-api/typeobj.rst:2636 +#: ../../c-api/typeobj.rst:2572 msgid "" "Static types are limited to one base, i.e. they cannot use multiple " "inheritance." msgstr "" -#: ../../c-api/typeobj.rst:2638 +#: ../../c-api/typeobj.rst:2574 msgid "" "Static type objects (but not necessarily their instances) are immutable. It " "is not possible to add or modify the type object's attributes from Python." msgstr "" -#: ../../c-api/typeobj.rst:2640 +#: ../../c-api/typeobj.rst:2576 msgid "" "Static type objects are shared across :ref:`sub-interpreters `, so they should not include any subinterpreter-" "specific state." msgstr "" -#: ../../c-api/typeobj.rst:2644 +#: ../../c-api/typeobj.rst:2580 msgid "" "Also, since :c:type:`PyTypeObject` is only part of the :ref:`Limited API " "` as an opaque struct, any extension modules using static " "types must be compiled for a specific Python minor version." msgstr "" -#: ../../c-api/typeobj.rst:2652 +#: ../../c-api/typeobj.rst:2588 msgid "Heap Types" msgstr "堆積型別" -#: ../../c-api/typeobj.rst:2654 +#: ../../c-api/typeobj.rst:2590 msgid "" "An alternative to :ref:`static types ` is *heap-allocated " "types*, or *heap types* for short, which correspond closely to classes " @@ -4007,29 +3908,29 @@ msgid "" "`Py_TPFLAGS_HEAPTYPE` flag set." msgstr "" -#: ../../c-api/typeobj.rst:2659 +#: ../../c-api/typeobj.rst:2595 msgid "" "This is done by filling a :c:type:`PyType_Spec` structure and calling :c:" "func:`PyType_FromSpec`, :c:func:`PyType_FromSpecWithBases`, :c:func:" "`PyType_FromModuleAndSpec`, or :c:func:`PyType_FromMetaclass`." msgstr "" -#: ../../c-api/typeobj.rst:2667 +#: ../../c-api/typeobj.rst:2603 msgid "Number Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2674 +#: ../../c-api/typeobj.rst:2607 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the number protocol. Each function is used by the function of " "similar name documented in the :ref:`number` section." msgstr "" -#: ../../c-api/typeobj.rst:2680 ../../c-api/typeobj.rst:3164 +#: ../../c-api/typeobj.rst:2613 ../../c-api/typeobj.rst:3085 msgid "Here is the structure definition::" msgstr "" -#: ../../c-api/typeobj.rst:2682 +#: ../../c-api/typeobj.rst:2615 msgid "" "typedef struct {\n" " binaryfunc nb_add;\n" @@ -4117,7 +4018,7 @@ msgstr "" " binaryfunc nb_inplace_matrix_multiply;\n" "} PyNumberMethods;" -#: ../../c-api/typeobj.rst:2727 +#: ../../c-api/typeobj.rst:2660 msgid "" "Binary and ternary functions must check the type of all their operands, and " "implement the necessary conversions (at least one of the operands is an " @@ -4127,31 +4028,31 @@ msgid "" "and set an exception." msgstr "" -#: ../../c-api/typeobj.rst:2736 +#: ../../c-api/typeobj.rst:2669 msgid "" "The :c:member:`~PyNumberMethods.nb_reserved` field should always be " "``NULL``. It was previously called :c:member:`!nb_long`, and was renamed in " "Python 3.0.1." msgstr "" -#: ../../c-api/typeobj.rst:2887 +#: ../../c-api/typeobj.rst:2820 msgid "Mapping Object Structures" msgstr "對映物件結構" -#: ../../c-api/typeobj.rst:2894 +#: ../../c-api/typeobj.rst:2824 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the mapping protocol. It has three members:" msgstr "" -#: ../../c-api/typeobj.rst:2901 +#: ../../c-api/typeobj.rst:2831 msgid "" "This function is used by :c:func:`PyMapping_Size` and :c:func:" "`PyObject_Size`, and has the same signature. This slot may be set to " "``NULL`` if the object has no defined length." msgstr "" -#: ../../c-api/typeobj.rst:2909 +#: ../../c-api/typeobj.rst:2839 msgid "" "This function is used by :c:func:`PyObject_GetItem` and :c:func:" "`PySequence_GetSlice`, and has the same signature as :c:func:`!" @@ -4159,7 +4060,7 @@ msgid "" "`PyMapping_Check` function to return ``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2919 +#: ../../c-api/typeobj.rst:2849 msgid "" "This function is used by :c:func:`PyObject_SetItem`, :c:func:" "`PyObject_DelItem`, :c:func:`PySequence_SetSlice` and :c:func:" @@ -4169,17 +4070,17 @@ msgid "" "deletion." msgstr "" -#: ../../c-api/typeobj.rst:2930 +#: ../../c-api/typeobj.rst:2860 msgid "Sequence Object Structures" msgstr "序列物件結構" -#: ../../c-api/typeobj.rst:2937 +#: ../../c-api/typeobj.rst:2864 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the sequence protocol." msgstr "" -#: ../../c-api/typeobj.rst:2944 +#: ../../c-api/typeobj.rst:2871 msgid "" "This function is used by :c:func:`PySequence_Size` and :c:func:" "`PyObject_Size`, and has the same signature. It is also used for handling " @@ -4187,21 +4088,21 @@ msgid "" "member:`~PySequenceMethods.sq_ass_item` slots." msgstr "" -#: ../../c-api/typeobj.rst:2953 +#: ../../c-api/typeobj.rst:2880 msgid "" "This function is used by :c:func:`PySequence_Concat` and has the same " "signature. It is also used by the ``+`` operator, after trying the numeric " "addition via the :c:member:`~PyNumberMethods.nb_add` slot." msgstr "" -#: ../../c-api/typeobj.rst:2961 +#: ../../c-api/typeobj.rst:2888 msgid "" "This function is used by :c:func:`PySequence_Repeat` and has the same " "signature. It is also used by the ``*`` operator, after trying numeric " "multiplication via the :c:member:`~PyNumberMethods.nb_multiply` slot." msgstr "" -#: ../../c-api/typeobj.rst:2969 +#: ../../c-api/typeobj.rst:2896 msgid "" "This function is used by :c:func:`PySequence_GetItem` and has the same " "signature. It is also used by :c:func:`PyObject_GetItem`, after trying the " @@ -4210,7 +4111,7 @@ msgid "" "``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2975 +#: ../../c-api/typeobj.rst:2902 msgid "" "Negative indexes are handled as follows: if the :c:member:" "`~PySequenceMethods.sq_length` slot is filled, it is called and the sequence " @@ -4219,7 +4120,7 @@ msgid "" "index is passed as is to the function." msgstr "" -#: ../../c-api/typeobj.rst:2984 +#: ../../c-api/typeobj.rst:2911 msgid "" "This function is used by :c:func:`PySequence_SetItem` and has the same " "signature. It is also used by :c:func:`PyObject_SetItem` and :c:func:" @@ -4228,14 +4129,14 @@ msgid "" "``NULL`` if the object does not support item assignment and deletion." msgstr "" -#: ../../c-api/typeobj.rst:2995 +#: ../../c-api/typeobj.rst:2922 msgid "" "This function may be used by :c:func:`PySequence_Contains` and has the same " "signature. This slot may be left to ``NULL``, in this case :c:func:`!" "PySequence_Contains` simply traverses the sequence until it finds a match." msgstr "" -#: ../../c-api/typeobj.rst:3004 +#: ../../c-api/typeobj.rst:2931 msgid "" "This function is used by :c:func:`PySequence_InPlaceConcat` and has the same " "signature. It should modify its first operand, and return it. This slot " @@ -4245,7 +4146,7 @@ msgid "" "c:member:`~PyNumberMethods.nb_inplace_add` slot." msgstr "" -#: ../../c-api/typeobj.rst:3015 +#: ../../c-api/typeobj.rst:2942 msgid "" "This function is used by :c:func:`PySequence_InPlaceRepeat` and has the same " "signature. It should modify its first operand, and return it. This slot " @@ -4255,110 +4156,110 @@ msgid "" "via the :c:member:`~PyNumberMethods.nb_inplace_multiply` slot." msgstr "" -#: ../../c-api/typeobj.rst:3026 +#: ../../c-api/typeobj.rst:2953 msgid "Buffer Object Structures" msgstr "緩衝區物件結構" -#: ../../c-api/typeobj.rst:3034 +#: ../../c-api/typeobj.rst:2957 msgid "" "This structure holds pointers to the functions required by the :ref:`Buffer " "protocol `. The protocol defines how an exporter object can " "expose its internal data to consumer objects." msgstr "" -#: ../../c-api/typeobj.rst:3042 ../../c-api/typeobj.rst:3111 -#: ../../c-api/typeobj.rst:3177 ../../c-api/typeobj.rst:3190 -#: ../../c-api/typeobj.rst:3204 ../../c-api/typeobj.rst:3216 +#: ../../c-api/typeobj.rst:2965 ../../c-api/typeobj.rst:3034 +#: ../../c-api/typeobj.rst:3098 ../../c-api/typeobj.rst:3111 +#: ../../c-api/typeobj.rst:3125 ../../c-api/typeobj.rst:3137 msgid "The signature of this function is::" msgstr "函式的簽名為: ::" -#: ../../c-api/typeobj.rst:3044 +#: ../../c-api/typeobj.rst:2967 msgid "int (PyObject *exporter, Py_buffer *view, int flags);" msgstr "int (PyObject *exporter, Py_buffer *view, int flags);" -#: ../../c-api/typeobj.rst:3046 +#: ../../c-api/typeobj.rst:2969 msgid "" "Handle a request to *exporter* to fill in *view* as specified by *flags*. " "Except for point (3), an implementation of this function MUST take these " "steps:" msgstr "" -#: ../../c-api/typeobj.rst:3050 +#: ../../c-api/typeobj.rst:2973 msgid "" "Check if the request can be met. If not, raise :exc:`BufferError`, set " "``view->obj`` to ``NULL`` and return ``-1``." msgstr "" -#: ../../c-api/typeobj.rst:3053 +#: ../../c-api/typeobj.rst:2976 msgid "Fill in the requested fields." msgstr "" -#: ../../c-api/typeobj.rst:3055 +#: ../../c-api/typeobj.rst:2978 msgid "Increment an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:3057 +#: ../../c-api/typeobj.rst:2980 msgid "Set ``view->obj`` to *exporter* and increment ``view->obj``." msgstr "" -#: ../../c-api/typeobj.rst:3059 +#: ../../c-api/typeobj.rst:2982 msgid "Return ``0``." msgstr "回傳 ``0``。" -#: ../../c-api/typeobj.rst:3061 ../../c-api/typeobj.rst:3124 +#: ../../c-api/typeobj.rst:2984 ../../c-api/typeobj.rst:3047 msgid "**Thread safety:**" msgstr "" -#: ../../c-api/typeobj.rst:3063 +#: ../../c-api/typeobj.rst:2986 msgid "In the :term:`free-threaded build`, implementations must ensure:" msgstr "" -#: ../../c-api/typeobj.rst:3065 +#: ../../c-api/typeobj.rst:2988 msgid "The export counter increment in step (3) is atomic." msgstr "" -#: ../../c-api/typeobj.rst:3067 +#: ../../c-api/typeobj.rst:2990 msgid "" "The underlying buffer data remains valid and at a stable memory location for " "the lifetime of all exports." msgstr "" -#: ../../c-api/typeobj.rst:3070 +#: ../../c-api/typeobj.rst:2993 msgid "" "For objects that support resizing or reallocation (such as :class:" "`bytearray`), the export counter is checked atomically before such " "operations, and :exc:`BufferError` is raised if exports exist." msgstr "" -#: ../../c-api/typeobj.rst:3074 +#: ../../c-api/typeobj.rst:2997 msgid "The function is safe to call concurrently from multiple threads." msgstr "" -#: ../../c-api/typeobj.rst:3076 +#: ../../c-api/typeobj.rst:2999 msgid "" "See also :ref:`thread-safety-memoryview` for the Python-level thread safety " "guarantees of :class:`memoryview` objects." msgstr "" -#: ../../c-api/typeobj.rst:3079 +#: ../../c-api/typeobj.rst:3002 msgid "" "If *exporter* is part of a chain or tree of buffer providers, two main " "schemes can be used:" msgstr "" -#: ../../c-api/typeobj.rst:3082 +#: ../../c-api/typeobj.rst:3005 msgid "" "Re-export: Each member of the tree acts as the exporting object and sets " "``view->obj`` to a new reference to itself." msgstr "" -#: ../../c-api/typeobj.rst:3085 +#: ../../c-api/typeobj.rst:3008 msgid "" "Redirect: The buffer request is redirected to the root object of the tree. " "Here, ``view->obj`` will be a new reference to the root object." msgstr "" -#: ../../c-api/typeobj.rst:3089 +#: ../../c-api/typeobj.rst:3012 msgid "" "The individual fields of *view* are described in section :ref:`Buffer " "structure `, the rules how an exporter must react to " @@ -4366,7 +4267,7 @@ msgid "" "types>`." msgstr "" -#: ../../c-api/typeobj.rst:3094 +#: ../../c-api/typeobj.rst:3017 msgid "" "All memory pointed to in the :c:type:`Py_buffer` structure belongs to the " "exporter and must remain valid until there are no consumers left. :c:member:" @@ -4375,23 +4276,23 @@ msgid "" "internal` are read-only for the consumer." msgstr "" -#: ../../c-api/typeobj.rst:3101 +#: ../../c-api/typeobj.rst:3024 msgid "" ":c:func:`PyBuffer_FillInfo` provides an easy way of exposing a simple bytes " "buffer while dealing correctly with all request types." msgstr "" -#: ../../c-api/typeobj.rst:3104 +#: ../../c-api/typeobj.rst:3027 msgid "" ":c:func:`PyObject_GetBuffer` is the interface for the consumer that wraps " "this function." msgstr "" -#: ../../c-api/typeobj.rst:3113 +#: ../../c-api/typeobj.rst:3036 msgid "void (PyObject *exporter, Py_buffer *view);" msgstr "void (PyObject *exporter, Py_buffer *view);" -#: ../../c-api/typeobj.rst:3115 +#: ../../c-api/typeobj.rst:3038 msgid "" "Handle a request to release the resources of the buffer. If no resources " "need to be released, :c:member:`PyBufferProcs.bf_releasebuffer` may be " @@ -4399,30 +4300,30 @@ msgid "" "these optional steps:" msgstr "" -#: ../../c-api/typeobj.rst:3120 +#: ../../c-api/typeobj.rst:3043 msgid "Decrement an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:3122 +#: ../../c-api/typeobj.rst:3045 msgid "If the counter is ``0``, free all memory associated with *view*." msgstr "" -#: ../../c-api/typeobj.rst:3126 +#: ../../c-api/typeobj.rst:3049 msgid "In the :term:`free-threaded build`:" msgstr "" -#: ../../c-api/typeobj.rst:3128 +#: ../../c-api/typeobj.rst:3051 msgid "The export counter decrement in step (1) must be atomic." msgstr "" -#: ../../c-api/typeobj.rst:3130 +#: ../../c-api/typeobj.rst:3053 msgid "" "Resource cleanup when the counter reaches zero must be done atomically, as " "the final release may race with concurrent releases from other threads and " "deallocation must only happen once." msgstr "" -#: ../../c-api/typeobj.rst:3134 +#: ../../c-api/typeobj.rst:3057 msgid "" "The exporter MUST use the :c:member:`~Py_buffer.internal` field to keep " "track of buffer-specific resources. This field is guaranteed to remain " @@ -4430,30 +4331,30 @@ msgid "" "*view* argument." msgstr "" -#: ../../c-api/typeobj.rst:3140 +#: ../../c-api/typeobj.rst:3063 msgid "" "This function MUST NOT decrement ``view->obj``, since that is done " "automatically in :c:func:`PyBuffer_Release` (this scheme is useful for " "breaking reference cycles)." msgstr "" -#: ../../c-api/typeobj.rst:3145 +#: ../../c-api/typeobj.rst:3068 msgid "" ":c:func:`PyBuffer_Release` is the interface for the consumer that wraps this " "function." msgstr "" -#: ../../c-api/typeobj.rst:3153 +#: ../../c-api/typeobj.rst:3076 msgid "Async Object Structures" msgstr "非同步物件結構" -#: ../../c-api/typeobj.rst:3161 +#: ../../c-api/typeobj.rst:3082 msgid "" "This structure holds pointers to the functions required to implement :term:" "`awaitable` and :term:`asynchronous iterator` objects." msgstr "" -#: ../../c-api/typeobj.rst:3166 +#: ../../c-api/typeobj.rst:3087 msgid "" "typedef struct {\n" " unaryfunc am_await;\n" @@ -4469,62 +4370,62 @@ msgstr "" " sendfunc am_send;\n" "} PyAsyncMethods;" -#: ../../c-api/typeobj.rst:3179 +#: ../../c-api/typeobj.rst:3100 msgid "PyObject *am_await(PyObject *self);" msgstr "PyObject *am_await(PyObject *self);" -#: ../../c-api/typeobj.rst:3181 +#: ../../c-api/typeobj.rst:3102 msgid "" "The returned object must be an :term:`iterator`, i.e. :c:func:`PyIter_Check` " "must return ``1`` for it." msgstr "" -#: ../../c-api/typeobj.rst:3184 +#: ../../c-api/typeobj.rst:3105 msgid "" "This slot may be set to ``NULL`` if an object is not an :term:`awaitable`." msgstr "" -#: ../../c-api/typeobj.rst:3192 +#: ../../c-api/typeobj.rst:3113 msgid "PyObject *am_aiter(PyObject *self);" msgstr "PyObject *am_aiter(PyObject *self);" -#: ../../c-api/typeobj.rst:3194 +#: ../../c-api/typeobj.rst:3115 msgid "" "Must return an :term:`asynchronous iterator` object. See :meth:`~object." "__anext__` for details." msgstr "" -#: ../../c-api/typeobj.rst:3197 +#: ../../c-api/typeobj.rst:3118 msgid "" "This slot may be set to ``NULL`` if an object does not implement " "asynchronous iteration protocol." msgstr "" -#: ../../c-api/typeobj.rst:3206 +#: ../../c-api/typeobj.rst:3127 msgid "PyObject *am_anext(PyObject *self);" msgstr "PyObject *am_anext(PyObject *self);" -#: ../../c-api/typeobj.rst:3208 +#: ../../c-api/typeobj.rst:3129 msgid "" "Must return an :term:`awaitable` object. See :meth:`~object.__anext__` for " "details. This slot may be set to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:3218 +#: ../../c-api/typeobj.rst:3139 msgid "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" msgstr "" "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" -#: ../../c-api/typeobj.rst:3220 +#: ../../c-api/typeobj.rst:3141 msgid "" "See :c:func:`PyIter_Send` for details. This slot may be set to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:3229 +#: ../../c-api/typeobj.rst:3150 msgid "Slot Type typedefs" msgstr "" -#: ../../c-api/typeobj.rst:3233 +#: ../../c-api/typeobj.rst:3154 msgid "" "The purpose of this function is to separate memory allocation from memory " "initialization. It should return a pointer to a block of memory of adequate " @@ -4538,80 +4439,80 @@ msgid "" "length of the block should be :c:member:`~PyTypeObject.tp_basicsize`." msgstr "" -#: ../../c-api/typeobj.rst:3243 +#: ../../c-api/typeobj.rst:3164 msgid "" "This function should not do any other instance initialization, not even to " "allocate additional memory; that should be done by :c:member:`~PyTypeObject." "tp_new`." msgstr "" -#: ../../c-api/typeobj.rst:3250 +#: ../../c-api/typeobj.rst:3171 msgid "See :c:member:`~PyTypeObject.tp_free`." msgstr "請見 :c:member:`~PyTypeObject.tp_free`。" -#: ../../c-api/typeobj.rst:3254 +#: ../../c-api/typeobj.rst:3175 msgid "See :c:member:`~PyTypeObject.tp_new`." msgstr "請見 :c:member:`~PyTypeObject.tp_new`。" -#: ../../c-api/typeobj.rst:3258 +#: ../../c-api/typeobj.rst:3179 msgid "See :c:member:`~PyTypeObject.tp_init`." msgstr "請見 :c:member:`~PyTypeObject.tp_init`。" -#: ../../c-api/typeobj.rst:3262 +#: ../../c-api/typeobj.rst:3183 msgid "See :c:member:`~PyTypeObject.tp_repr`." msgstr "請見 :c:member:`~PyTypeObject.tp_repr`。" -#: ../../c-api/typeobj.rst:3266 ../../c-api/typeobj.rst:3275 +#: ../../c-api/typeobj.rst:3187 ../../c-api/typeobj.rst:3196 msgid "Return the value of the named attribute for the object." msgstr "" -#: ../../c-api/typeobj.rst:3270 ../../c-api/typeobj.rst:3281 +#: ../../c-api/typeobj.rst:3191 ../../c-api/typeobj.rst:3202 msgid "" "Set the value of the named attribute for the object. The value argument is " "set to ``NULL`` to delete the attribute." msgstr "" -#: ../../c-api/typeobj.rst:3277 +#: ../../c-api/typeobj.rst:3198 msgid "See :c:member:`~PyTypeObject.tp_getattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_getattro`。" -#: ../../c-api/typeobj.rst:3284 +#: ../../c-api/typeobj.rst:3205 msgid "See :c:member:`~PyTypeObject.tp_setattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_setattro`。" -#: ../../c-api/typeobj.rst:3288 +#: ../../c-api/typeobj.rst:3209 msgid "See :c:member:`~PyTypeObject.tp_descr_get`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_get`。" -#: ../../c-api/typeobj.rst:3292 +#: ../../c-api/typeobj.rst:3213 msgid "See :c:member:`~PyTypeObject.tp_descr_set`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_set`。" -#: ../../c-api/typeobj.rst:3296 +#: ../../c-api/typeobj.rst:3217 msgid "See :c:member:`~PyTypeObject.tp_hash`." msgstr "請見 :c:member:`~PyTypeObject.tp_hash`。" -#: ../../c-api/typeobj.rst:3300 +#: ../../c-api/typeobj.rst:3221 msgid "See :c:member:`~PyTypeObject.tp_richcompare`." msgstr "請見 :c:member:`~PyTypeObject.tp_richcompare`。" -#: ../../c-api/typeobj.rst:3304 +#: ../../c-api/typeobj.rst:3225 msgid "See :c:member:`~PyTypeObject.tp_iter`." msgstr "請見 :c:member:`~PyTypeObject.tp_iter`。" -#: ../../c-api/typeobj.rst:3308 +#: ../../c-api/typeobj.rst:3229 msgid "See :c:member:`~PyTypeObject.tp_iternext`." msgstr "請見 :c:member:`~PyTypeObject.tp_iternext`。" -#: ../../c-api/typeobj.rst:3322 +#: ../../c-api/typeobj.rst:3243 msgid "See :c:member:`~PyAsyncMethods.am_send`." msgstr "請見 :c:member:`~PyAsyncMethods.am_send`。" -#: ../../c-api/typeobj.rst:3338 +#: ../../c-api/typeobj.rst:3259 msgid "Examples" msgstr "範例" -#: ../../c-api/typeobj.rst:3340 +#: ../../c-api/typeobj.rst:3261 msgid "" "The following are simple examples of Python type definitions. They include " "common usage you may encounter. Some demonstrate tricky corner cases. For " @@ -4619,11 +4520,11 @@ msgid "" "and :ref:`new-types-topics`." msgstr "" -#: ../../c-api/typeobj.rst:3345 +#: ../../c-api/typeobj.rst:3266 msgid "A basic :ref:`static type `::" msgstr "" -#: ../../c-api/typeobj.rst:3347 +#: ../../c-api/typeobj.rst:3268 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4655,13 +4556,13 @@ msgstr "" " .tp_repr = (reprfunc)myobj_repr,\n" "};" -#: ../../c-api/typeobj.rst:3362 +#: ../../c-api/typeobj.rst:3283 msgid "" "You may also find older code (especially in the CPython code base) with a " "more verbose initializer::" msgstr "" -#: ../../c-api/typeobj.rst:3365 +#: ../../c-api/typeobj.rst:3286 msgid "" "static PyTypeObject MyObject_Type = {\n" " PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -4745,11 +4646,11 @@ msgstr "" " myobj_new, /* tp_new */\n" "};" -#: ../../c-api/typeobj.rst:3406 +#: ../../c-api/typeobj.rst:3327 msgid "A type that supports weakrefs, instance dicts, and hashing::" msgstr "" -#: ../../c-api/typeobj.rst:3408 +#: ../../c-api/typeobj.rst:3329 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4775,14 +4676,14 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:3431 +#: ../../c-api/typeobj.rst:3352 msgid "" "A str subclass that cannot be subclassed and cannot be called to create " "instances (e.g. uses a separate factory func) using :c:macro:" "`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag::" msgstr "" -#: ../../c-api/typeobj.rst:3435 +#: ../../c-api/typeobj.rst:3356 msgid "" "typedef struct {\n" " PyUnicodeObject raw;\n" @@ -4800,12 +4701,12 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:3450 +#: ../../c-api/typeobj.rst:3371 msgid "" "The simplest :ref:`static type ` with fixed-length instances::" msgstr "" -#: ../../c-api/typeobj.rst:3452 +#: ../../c-api/typeobj.rst:3373 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4825,13 +4726,13 @@ msgstr "" " .tp_name = \"mymod.MyObject\",\n" "};" -#: ../../c-api/typeobj.rst:3461 +#: ../../c-api/typeobj.rst:3382 msgid "" "The simplest :ref:`static type ` with variable-length " "instances::" msgstr "" -#: ../../c-api/typeobj.rst:3463 +#: ../../c-api/typeobj.rst:3384 msgid "" "typedef struct {\n" " PyObject_VAR_HEAD\n" @@ -4857,14 +4758,58 @@ msgstr "" " .tp_itemsize = sizeof(char *),\n" "};" -#: ../../c-api/typeobj.rst:920 ../../c-api/typeobj.rst:987 +#: ../../c-api/typeobj.rst:927 ../../c-api/typeobj.rst:994 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/typeobj.rst:920 +#: ../../c-api/typeobj.rst:927 msgid "repr" msgstr "repr" -#: ../../c-api/typeobj.rst:987 +#: ../../c-api/typeobj.rst:994 msgid "hash" msgstr "hash(雜湊)" + +#~ msgid "int tp_traverse(PyObject *self, visitproc visit, void *arg);" +#~ msgstr "int tp_traverse(PyObject *self, visitproc visit, void *arg);" + +#~ msgid "" +#~ "static int\n" +#~ "local_traverse(PyObject *op, visitproc visit, void *arg)\n" +#~ "{\n" +#~ " localobject *self = (localobject *) op;\n" +#~ " Py_VISIT(self->args);\n" +#~ " Py_VISIT(self->kw);\n" +#~ " Py_VISIT(self->dict);\n" +#~ " return 0;\n" +#~ "}" +#~ msgstr "" +#~ "static int\n" +#~ "local_traverse(PyObject *op, visitproc visit, void *arg)\n" +#~ "{\n" +#~ " localobject *self = (localobject *) op;\n" +#~ " Py_VISIT(self->args);\n" +#~ " Py_VISIT(self->kw);\n" +#~ " Py_VISIT(self->dict);\n" +#~ " return 0;\n" +#~ "}" + +#~ msgid "Py_VISIT(Py_TYPE(self));" +#~ msgstr "Py_VISIT(Py_TYPE(self));" + +#~ msgid "" +#~ "#if PY_VERSION_HEX >= 0x03090000\n" +#~ " Py_VISIT(Py_TYPE(self));\n" +#~ "#endif" +#~ msgstr "" +#~ "#if PY_VERSION_HEX >= 0x03090000\n" +#~ " Py_VISIT(Py_TYPE(self));\n" +#~ "#endif" + +#~ msgid "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" +#~ msgstr "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" + +#~ msgid "" +#~ "The :c:member:`~PyTypeObject.tp_traverse` function can be called from any " +#~ "thread." +#~ msgstr ":c:member:`~PyTypeObject.tp_traverse` 函式可以從任何執行緒呼叫。" diff --git a/c-api/unicode.po b/c-api/unicode.po index 3efbb868f2e..fc45ce0ada3 100644 --- a/c-api/unicode.po +++ b/c-api/unicode.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-02 00:39+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -23,11 +23,11 @@ msgstr "" msgid "Unicode Objects and Codecs" msgstr "Unicode 物件與編解碼器" -#: ../../c-api/unicode.rst:12 +#: ../../c-api/unicode.rst:9 msgid "Unicode Objects" msgstr "Unicode 物件" -#: ../../c-api/unicode.rst:14 +#: ../../c-api/unicode.rst:11 msgid "" "Since the implementation of :pep:`393` in Python 3.3, Unicode objects " "internally use a variety of representations, in order to allow handling the " @@ -37,12 +37,12 @@ msgid "" "Unicode range)." msgstr "" -#: ../../c-api/unicode.rst:20 +#: ../../c-api/unicode.rst:17 msgid "" "UTF-8 representation is created on demand and cached in the Unicode object." msgstr "UTF-8 表示法會在需要時建立並快取在 Unicode 物件中。" -#: ../../c-api/unicode.rst:23 +#: ../../c-api/unicode.rst:20 msgid "" "The :c:type:`Py_UNICODE` representation has been removed since Python 3.12 " "with deprecated APIs. See :pep:`623` for more information." @@ -50,82 +50,82 @@ msgstr "" "自 Python 3.12 起,已移除 :c:type:`Py_UNICODE` 表示法,並標示為已棄用的 API。" "更多資訊請參閱 :pep:`623`。" -#: ../../c-api/unicode.rst:29 +#: ../../c-api/unicode.rst:26 msgid "Unicode Type" msgstr "Unicode 型別" -#: ../../c-api/unicode.rst:31 +#: ../../c-api/unicode.rst:28 msgid "" "These are the basic Unicode object types used for the Unicode implementation " "in Python:" msgstr "這些是 Python 中用於 Unicode 實作的基本 Unicode 物件型別:" -#: ../../c-api/unicode.rst:36 +#: ../../c-api/unicode.rst:33 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python Unicode type. " "It is exposed to Python code as :py:class:`str`." msgstr "" -#: ../../c-api/unicode.rst:42 +#: ../../c-api/unicode.rst:39 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python Unicode " "iterator type. It is used to iterate over Unicode string objects." msgstr "" -#: ../../c-api/unicode.rst:50 +#: ../../c-api/unicode.rst:47 msgid "" "These types are typedefs for unsigned integer types wide enough to contain " "characters of 32 bits, 16 bits and 8 bits, respectively. When dealing with " "single Unicode characters, use :c:type:`Py_UCS4`." msgstr "" -#: ../../c-api/unicode.rst:61 +#: ../../c-api/unicode.rst:58 msgid "" "These subtypes of :c:type:`PyObject` represent a Python Unicode object. In " "almost all cases, they shouldn't be used directly, since all API functions " "that deal with Unicode objects take and return :c:type:`PyObject` pointers." msgstr "" -#: ../../c-api/unicode.rst:68 +#: ../../c-api/unicode.rst:65 msgid "" "The structure of a particular object can be determined using the following " "macros. The macros cannot fail; their behavior is undefined if their " "argument is not a Python Unicode object." msgstr "" -#: ../../c-api/unicode.rst:77 +#: ../../c-api/unicode.rst:74 msgid "True if *o* uses the :c:struct:`PyCompactUnicodeObject` structure." msgstr "" -#: ../../c-api/unicode.rst:84 +#: ../../c-api/unicode.rst:81 msgid "True if *o* uses the :c:struct:`PyASCIIObject` structure." msgstr "" -#: ../../c-api/unicode.rst:89 +#: ../../c-api/unicode.rst:86 msgid "" "The following APIs are C macros and static inlined functions for fast checks " "and access to internal read-only data of Unicode objects:" msgstr "" -#: ../../c-api/unicode.rst:94 +#: ../../c-api/unicode.rst:91 msgid "" "Return true if the object *obj* is a Unicode object or an instance of a " "Unicode subtype. This function always succeeds." msgstr "" -#: ../../c-api/unicode.rst:100 +#: ../../c-api/unicode.rst:97 msgid "" "Return true if the object *obj* is a Unicode object, but not an instance of " "a subtype. This function always succeeds." msgstr "" -#: ../../c-api/unicode.rst:106 +#: ../../c-api/unicode.rst:103 msgid "" "Return the length of the Unicode string, in code points. *unicode* has to " "be a Unicode object in the \"canonical\" representation (not checked)." msgstr "" -#: ../../c-api/unicode.rst:116 +#: ../../c-api/unicode.rst:113 msgid "" "Return a pointer to the canonical representation cast to UCS1, UCS2 or UCS4 " "integer types for direct character access. No checks are performed if the " @@ -133,15 +133,15 @@ msgid "" "`PyUnicode_KIND` to select the right function." msgstr "" -#: ../../c-api/unicode.rst:128 +#: ../../c-api/unicode.rst:125 msgid "Return values of the :c:func:`PyUnicode_KIND` macro." msgstr "" -#: ../../c-api/unicode.rst:132 +#: ../../c-api/unicode.rst:129 msgid "``PyUnicode_WCHAR_KIND`` has been removed." msgstr "``PyUnicode_WCHAR_KIND`` 已被移除。" -#: ../../c-api/unicode.rst:138 +#: ../../c-api/unicode.rst:135 msgid "" "Return one of the PyUnicode kind constants (see above) that indicate how " "many bytes per character this Unicode object uses to store its data. " @@ -149,18 +149,18 @@ msgid "" "(not checked)." msgstr "" -#: ../../c-api/unicode.rst:147 +#: ../../c-api/unicode.rst:144 msgid "" "Return a void pointer to the raw Unicode buffer. *unicode* has to be a " "Unicode object in the \"canonical\" representation (not checked)." msgstr "" -#: ../../c-api/unicode.rst:156 +#: ../../c-api/unicode.rst:153 msgid "" "Write the code point *value* to the given zero-based *index* in a string." msgstr "" -#: ../../c-api/unicode.rst:158 +#: ../../c-api/unicode.rst:155 msgid "" "The *kind* value and *data* pointer must have been obtained from a string " "using :c:func:`PyUnicode_KIND` and :c:func:`PyUnicode_DATA` respectively. " @@ -169,109 +169,133 @@ msgid "" "apply." msgstr "" -#: ../../c-api/unicode.rst:164 +#: ../../c-api/unicode.rst:161 msgid "" "The function performs no checks for any of its requirements, and is intended " "for usage in loops." msgstr "" -#: ../../c-api/unicode.rst:173 +#: ../../c-api/unicode.rst:170 msgid "" "Read a code point from a canonical representation *data* (as obtained with :" "c:func:`PyUnicode_DATA`). No checks or ready calls are performed." msgstr "" -#: ../../c-api/unicode.rst:181 +#: ../../c-api/unicode.rst:178 msgid "" "Read a character from a Unicode object *unicode*, which must be in the " "\"canonical\" representation. This is less efficient than :c:func:" "`PyUnicode_READ` if you do multiple consecutive reads." msgstr "" -#: ../../c-api/unicode.rst:190 +#: ../../c-api/unicode.rst:187 msgid "" "Return the maximum code point that is suitable for creating another string " "based on *unicode*, which must be in the \"canonical\" representation. This " "is always an approximation but more efficient than iterating over the string." msgstr "" -#: ../../c-api/unicode.rst:199 +#: ../../c-api/unicode.rst:196 msgid "" "Return ``1`` if the string is a valid identifier according to the language " "definition, section :ref:`identifiers`. Return ``0`` otherwise." msgstr "" -#: ../../c-api/unicode.rst:202 +#: ../../c-api/unicode.rst:199 msgid "" "The function does not call :c:func:`Py_FatalError` anymore if the string is " "not ready." msgstr "" -#: ../../c-api/unicode.rst:209 +#: ../../c-api/unicode.rst:206 msgid "" "Return true if the string only contains ASCII characters. Equivalent to :py:" "meth:`str.isascii`." msgstr "" -#: ../../c-api/unicode.rst:216 -msgid "Unicode Character Properties" +#: ../../c-api/unicode.rst:214 +msgid "" +"If the hash of *str*, as returned by :c:func:`PyObject_Hash`, has been " +"cached and is immediately available, return it. Otherwise, return ``-1`` " +"*without* setting an exception." msgstr "" #: ../../c-api/unicode.rst:218 msgid "" +"If *str* is not a string (that is, if ``PyUnicode_Check(obj)`` is false), " +"the behavior is undefined." +msgstr "" + +#: ../../c-api/unicode.rst:221 +msgid "This function never fails with an exception." +msgstr "此函式不會失敗並引發例外。" + +#: ../../c-api/unicode.rst:223 +msgid "" +"Note that there are no guarantees on when an object's hash is cached, and " +"the (non-)existence of a cached hash does not imply that the string has any " +"other properties." +msgstr "" + +#: ../../c-api/unicode.rst:229 +msgid "Unicode Character Properties" +msgstr "" + +#: ../../c-api/unicode.rst:231 +msgid "" "Unicode provides many different character properties. The most often needed " "ones are available through these macros which are mapped to C functions " "depending on the Python configuration." msgstr "" -#: ../../c-api/unicode.rst:225 +#: ../../c-api/unicode.rst:238 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a whitespace character." msgstr "根據 *ch* 是否為空白字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:230 +#: ../../c-api/unicode.rst:243 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a lowercase character." msgstr "根據 *ch* 是否為小寫字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:235 +#: ../../c-api/unicode.rst:248 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an uppercase character." msgstr "根據 *ch* 是否為大寫字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:240 +#: ../../c-api/unicode.rst:253 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a titlecase character." msgstr "根據 *ch* 是否為首字大寫字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:245 +#: ../../c-api/unicode.rst:258 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a linebreak character." msgstr "根據 *ch* 是否為換行字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:250 +#: ../../c-api/unicode.rst:263 msgid "Return ``1`` or ``0`` depending on whether *ch* is a decimal character." msgstr "根據 *ch* 是否為十進位字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:255 +#: ../../c-api/unicode.rst:268 msgid "Return ``1`` or ``0`` depending on whether *ch* is a digit character." msgstr "根據 *ch* 是否為數字 (digit) 字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:260 +#: ../../c-api/unicode.rst:273 msgid "Return ``1`` or ``0`` depending on whether *ch* is a numeric character." msgstr "根據 *ch* 是否為數值 (numeric) 字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:265 +#: ../../c-api/unicode.rst:278 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an alphabetic character." msgstr "根據 *ch* 是否為字母字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:270 +#: ../../c-api/unicode.rst:283 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an alphanumeric character." msgstr "根據 *ch* 是否為字母數字 (alphanumeric) 字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:275 +#: ../../c-api/unicode.rst:288 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a printable character, in " "the sense of :meth:`str.isprintable`." @@ -279,23 +303,23 @@ msgstr "" "根據 *ch* 是否為可列印字元(如 :meth:`str.isprintable` 所定義)來回傳 ``1`` " "或 ``0``。" -#: ../../c-api/unicode.rst:279 +#: ../../c-api/unicode.rst:292 msgid "These APIs can be used for fast direct character conversions:" msgstr "這些 API 可用於快速直接字元轉換:" -#: ../../c-api/unicode.rst:284 +#: ../../c-api/unicode.rst:297 msgid "Return the character *ch* converted to lower case." msgstr "回傳轉換為小寫的 *ch* 字元。" -#: ../../c-api/unicode.rst:289 +#: ../../c-api/unicode.rst:302 msgid "Return the character *ch* converted to upper case." msgstr "回傳轉換為大寫的 *ch* 字元。" -#: ../../c-api/unicode.rst:294 +#: ../../c-api/unicode.rst:307 msgid "Return the character *ch* converted to title case." msgstr "回傳轉換為首字大寫的 *ch* 字元。" -#: ../../c-api/unicode.rst:299 +#: ../../c-api/unicode.rst:312 msgid "" "Return the character *ch* converted to a decimal positive integer. Return " "``-1`` if this is not possible. This function does not raise exceptions." @@ -303,7 +327,7 @@ msgstr "" "回傳轉換為十進位正整數的 *ch* 字元,若無法轉換則回傳 ``-1``。此函式不會引發例" "外。" -#: ../../c-api/unicode.rst:305 +#: ../../c-api/unicode.rst:318 msgid "" "Return the character *ch* converted to a single digit integer. Return ``-1`` " "if this is not possible. This function does not raise exceptions." @@ -311,7 +335,7 @@ msgstr "" "回傳轉換為單一數字整數的 *ch* 字元,若無法轉換則回傳 ``-1``。此函式不會引發例" "外。" -#: ../../c-api/unicode.rst:311 +#: ../../c-api/unicode.rst:324 msgid "" "Return the character *ch* converted to a double. Return ``-1.0`` if this is " "not possible. This function does not raise exceptions." @@ -319,37 +343,37 @@ msgstr "" "回傳轉換為雙精度浮點數 (double) 的 *ch* 字元,若無法轉換則回傳 ``-1.0``。此函" "式不會引發例外。" -#: ../../c-api/unicode.rst:315 +#: ../../c-api/unicode.rst:328 msgid "These APIs can be used to work with surrogates:" msgstr "這些 API 可用於處理代理字元:" -#: ../../c-api/unicode.rst:319 +#: ../../c-api/unicode.rst:332 msgid "Check if *ch* is a surrogate (``0xD800 <= ch <= 0xDFFF``)." msgstr "檢查 *ch* 是否為代理字元 (surrogate, ``0xD800 <= ch <= 0xDFFF``)。" -#: ../../c-api/unicode.rst:323 +#: ../../c-api/unicode.rst:336 msgid "Check if *ch* is a high surrogate (``0xD800 <= ch <= 0xDBFF``)." msgstr "" "檢查 *ch* 是否為高代理字元 (high surrogate, ``0xD800 <= ch <= 0xDBFF``)。" -#: ../../c-api/unicode.rst:327 +#: ../../c-api/unicode.rst:340 msgid "Check if *ch* is a low surrogate (``0xDC00 <= ch <= 0xDFFF``)." msgstr "" "檢查 *ch* 是否為低代理字元 (low surrogate, ``0xDC00 <= ch <= 0xDFFF``)。" -#: ../../c-api/unicode.rst:331 +#: ../../c-api/unicode.rst:344 msgid "" "Return the high UTF-16 surrogate (``0xD800`` to ``0xDBFF``) for a Unicode " "code point in the range ``[0x10000; 0x10FFFF]``." msgstr "" -#: ../../c-api/unicode.rst:336 +#: ../../c-api/unicode.rst:349 msgid "" "Return the low UTF-16 surrogate (``0xDC00`` to ``0xDFFF``) for a Unicode " "code point in the range ``[0x10000; 0x10FFFF]``." msgstr "" -#: ../../c-api/unicode.rst:341 +#: ../../c-api/unicode.rst:354 msgid "" "Join two surrogate code points and return a single :c:type:`Py_UCS4` value. " "*high* and *low* are respectively the leading and trailing surrogates in a " @@ -357,28 +381,28 @@ msgid "" "must be in the range ``[0xDC00; 0xDFFF]``." msgstr "" -#: ../../c-api/unicode.rst:348 +#: ../../c-api/unicode.rst:361 msgid "Creating and accessing Unicode strings" msgstr "" -#: ../../c-api/unicode.rst:350 +#: ../../c-api/unicode.rst:363 msgid "" "To create Unicode objects and access their basic sequence properties, use " "these APIs:" msgstr "" -#: ../../c-api/unicode.rst:355 +#: ../../c-api/unicode.rst:368 msgid "" "Create a new Unicode object. *maxchar* should be the true maximum code " "point to be placed in the string. As an approximation, it can be rounded up " "to the nearest value in the sequence 127, 255, 65535, 1114111." msgstr "" -#: ../../c-api/unicode.rst:359 +#: ../../c-api/unicode.rst:372 msgid "On error, set an exception and return ``NULL``." msgstr "" -#: ../../c-api/unicode.rst:361 +#: ../../c-api/unicode.rst:374 msgid "" "After creation, the string can be filled by :c:func:`PyUnicode_WriteChar`, :" "c:func:`PyUnicode_CopyCharacters`, :c:func:`PyUnicode_Fill`, :c:func:" @@ -387,38 +411,38 @@ msgid "" "before it's filled with its final contents, a string:" msgstr "" -#: ../../c-api/unicode.rst:368 +#: ../../c-api/unicode.rst:381 msgid "must not be hashed," msgstr "" -#: ../../c-api/unicode.rst:369 +#: ../../c-api/unicode.rst:382 msgid "" "must not be :c:func:`converted to UTF-8 `, or " "another non-\"canonical\" representation," msgstr "" -#: ../../c-api/unicode.rst:371 +#: ../../c-api/unicode.rst:384 msgid "must not have its reference count changed," msgstr "" -#: ../../c-api/unicode.rst:372 +#: ../../c-api/unicode.rst:385 msgid "must not be shared with code that might do one of the above." msgstr "" -#: ../../c-api/unicode.rst:374 +#: ../../c-api/unicode.rst:387 msgid "" "This list is not exhaustive. Avoiding these uses is your responsibility; " "Python does not always check these requirements." msgstr "" -#: ../../c-api/unicode.rst:377 +#: ../../c-api/unicode.rst:390 msgid "" "To avoid accidentally exposing a partially-written string object, prefer " "using the :c:type:`PyUnicodeWriter` API, or one of the ``PyUnicode_From*`` " "functions below." msgstr "" -#: ../../c-api/unicode.rst:388 +#: ../../c-api/unicode.rst:401 msgid "" "Create a new Unicode object with the given *kind* (possible values are :c:" "macro:`PyUnicode_1BYTE_KIND` etc., as returned by :c:func:" @@ -426,7 +450,7 @@ msgid "" "1, 2 or 4 bytes per character, as given by the kind." msgstr "" -#: ../../c-api/unicode.rst:393 +#: ../../c-api/unicode.rst:406 msgid "" "If necessary, the input *buffer* is copied and transformed into the " "canonical representation. For example, if the *buffer* is a UCS4 string (:c:" @@ -434,7 +458,7 @@ msgid "" "range, it will be transformed into UCS1 (:c:macro:`PyUnicode_1BYTE_KIND`)." msgstr "" -#: ../../c-api/unicode.rst:404 +#: ../../c-api/unicode.rst:417 msgid "" "Create a Unicode object from the char buffer *str*. The bytes will be " "interpreted as being UTF-8 encoded. The buffer is copied into the new " @@ -442,29 +466,29 @@ msgid "" "data is not allowed." msgstr "" -#: ../../c-api/unicode.rst:410 +#: ../../c-api/unicode.rst:423 msgid "This function raises :exc:`SystemError` when:" msgstr "此函式在以下情況下會引發 :exc:`SystemError`:" -#: ../../c-api/unicode.rst:412 +#: ../../c-api/unicode.rst:425 msgid "*size* < 0," msgstr "*size* < 0," -#: ../../c-api/unicode.rst:413 +#: ../../c-api/unicode.rst:426 msgid "*str* is ``NULL`` and *size* > 0" msgstr "*str* 為 ``NULL`` 且 *size* > 0" -#: ../../c-api/unicode.rst:415 +#: ../../c-api/unicode.rst:428 msgid "*str* == ``NULL`` with *size* > 0 is not allowed anymore." msgstr "*str* == ``NULL`` 且 *size* > 0 不再被允許。" -#: ../../c-api/unicode.rst:421 +#: ../../c-api/unicode.rst:434 msgid "" "Create a Unicode object from a UTF-8 encoded null-terminated char buffer " "*str*." msgstr "" -#: ../../c-api/unicode.rst:427 +#: ../../c-api/unicode.rst:440 msgid "" "Take a C :c:func:`printf`\\ -style *format* string and a variable number of " "arguments, calculate the size of the resulting Python Unicode string and " @@ -473,23 +497,23 @@ msgid "" "*format* ASCII-encoded string." msgstr "" -#: ../../c-api/unicode.rst:433 +#: ../../c-api/unicode.rst:446 msgid "" "A conversion specifier contains two or more characters and has the following " "components, which must occur in this order:" msgstr "" -#: ../../c-api/unicode.rst:436 +#: ../../c-api/unicode.rst:449 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: ../../c-api/unicode.rst:438 +#: ../../c-api/unicode.rst:451 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: ../../c-api/unicode.rst:441 +#: ../../c-api/unicode.rst:454 msgid "" "Minimum field width (optional). If specified as an ``'*'`` (asterisk), the " "actual width is given in the next argument, which must be of type :c:expr:" @@ -497,7 +521,7 @@ msgid "" "optional precision." msgstr "" -#: ../../c-api/unicode.rst:446 +#: ../../c-api/unicode.rst:459 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. If " "specified as ``'*'`` (an asterisk), the actual precision is given in the " @@ -505,316 +529,316 @@ msgid "" "comes after the precision." msgstr "" -#: ../../c-api/unicode.rst:451 +#: ../../c-api/unicode.rst:464 msgid "Length modifier (optional)." msgstr "" -#: ../../c-api/unicode.rst:453 +#: ../../c-api/unicode.rst:466 msgid "Conversion type." msgstr "" -#: ../../c-api/unicode.rst:455 +#: ../../c-api/unicode.rst:468 msgid "The conversion flag characters are:" msgstr "" -#: ../../c-api/unicode.rst:460 +#: ../../c-api/unicode.rst:473 msgid "Flag" msgstr "旗標" -#: ../../c-api/unicode.rst:460 +#: ../../c-api/unicode.rst:473 msgid "Meaning" msgstr "含義" -#: ../../c-api/unicode.rst:462 +#: ../../c-api/unicode.rst:475 msgid "``0``" msgstr "``0``" -#: ../../c-api/unicode.rst:462 +#: ../../c-api/unicode.rst:475 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: ../../c-api/unicode.rst:464 +#: ../../c-api/unicode.rst:477 msgid "``-``" msgstr "``-``" -#: ../../c-api/unicode.rst:464 +#: ../../c-api/unicode.rst:477 msgid "" "The converted value is left adjusted (overrides the ``0`` flag if both are " "given)." msgstr "" -#: ../../c-api/unicode.rst:468 +#: ../../c-api/unicode.rst:481 msgid "" "The length modifiers for following integer conversions (``d``, ``i``, ``o``, " "``u``, ``x``, or ``X``) specify the type of the argument (:c:expr:`int` by " "default):" msgstr "" -#: ../../c-api/unicode.rst:475 +#: ../../c-api/unicode.rst:488 msgid "Modifier" msgstr "" -#: ../../c-api/unicode.rst:475 +#: ../../c-api/unicode.rst:488 msgid "Types" msgstr "" -#: ../../c-api/unicode.rst:477 +#: ../../c-api/unicode.rst:490 msgid "``l``" msgstr "``l``" -#: ../../c-api/unicode.rst:477 +#: ../../c-api/unicode.rst:490 msgid ":c:expr:`long` or :c:expr:`unsigned long`" msgstr ":c:expr:`long` 或 :c:expr:`unsigned long`" -#: ../../c-api/unicode.rst:479 +#: ../../c-api/unicode.rst:492 msgid "``ll``" msgstr "``ll``" -#: ../../c-api/unicode.rst:479 +#: ../../c-api/unicode.rst:492 msgid ":c:expr:`long long` or :c:expr:`unsigned long long`" msgstr ":c:expr:`long long` 或 :c:expr:`unsigned long long`" -#: ../../c-api/unicode.rst:481 +#: ../../c-api/unicode.rst:494 msgid "``j``" msgstr "``j``" -#: ../../c-api/unicode.rst:481 +#: ../../c-api/unicode.rst:494 msgid ":c:type:`intmax_t` or :c:type:`uintmax_t`" msgstr ":c:type:`intmax_t` 或 :c:type:`uintmax_t`" -#: ../../c-api/unicode.rst:483 +#: ../../c-api/unicode.rst:496 msgid "``z``" msgstr "``z``" -#: ../../c-api/unicode.rst:483 +#: ../../c-api/unicode.rst:496 msgid ":c:type:`size_t` or :c:type:`ssize_t`" msgstr ":c:type:`size_t` 或 :c:type:`ssize_t`" -#: ../../c-api/unicode.rst:485 +#: ../../c-api/unicode.rst:498 msgid "``t``" msgstr "``t``" -#: ../../c-api/unicode.rst:485 +#: ../../c-api/unicode.rst:498 msgid ":c:type:`ptrdiff_t`" msgstr ":c:type:`ptrdiff_t`" -#: ../../c-api/unicode.rst:488 +#: ../../c-api/unicode.rst:501 msgid "" "The length modifier ``l`` for following conversions ``s`` or ``V`` specify " "that the type of the argument is :c:expr:`const wchar_t*`." msgstr "" -#: ../../c-api/unicode.rst:491 +#: ../../c-api/unicode.rst:504 msgid "The conversion specifiers are:" msgstr "" -#: ../../c-api/unicode.rst:497 +#: ../../c-api/unicode.rst:510 msgid "Conversion Specifier" msgstr "" -#: ../../c-api/unicode.rst:498 +#: ../../c-api/unicode.rst:511 msgid "Type" msgstr "" -#: ../../c-api/unicode.rst:499 +#: ../../c-api/unicode.rst:512 msgid "Comment" msgstr "" -#: ../../c-api/unicode.rst:501 +#: ../../c-api/unicode.rst:514 msgid "``%``" msgstr "``%``" -#: ../../c-api/unicode.rst:502 +#: ../../c-api/unicode.rst:515 msgid "*n/a*" msgstr "*n/a*" -#: ../../c-api/unicode.rst:503 +#: ../../c-api/unicode.rst:516 msgid "The literal ``%`` character." msgstr "字面 ``%`` 字元。" -#: ../../c-api/unicode.rst:505 +#: ../../c-api/unicode.rst:518 msgid "``d``, ``i``" msgstr "``d``, ``i``" -#: ../../c-api/unicode.rst:506 ../../c-api/unicode.rst:510 -#: ../../c-api/unicode.rst:514 ../../c-api/unicode.rst:518 -#: ../../c-api/unicode.rst:522 +#: ../../c-api/unicode.rst:519 ../../c-api/unicode.rst:523 +#: ../../c-api/unicode.rst:527 ../../c-api/unicode.rst:531 +#: ../../c-api/unicode.rst:535 msgid "Specified by the length modifier" msgstr "" -#: ../../c-api/unicode.rst:507 +#: ../../c-api/unicode.rst:520 msgid "The decimal representation of a signed C integer." msgstr "一個有符號 C 整數的十進位表示法。" -#: ../../c-api/unicode.rst:509 +#: ../../c-api/unicode.rst:522 msgid "``u``" msgstr "``u``" -#: ../../c-api/unicode.rst:511 +#: ../../c-api/unicode.rst:524 msgid "The decimal representation of an unsigned C integer." msgstr "一個無符號 C 整數的十進位表示法。" -#: ../../c-api/unicode.rst:513 +#: ../../c-api/unicode.rst:526 msgid "``o``" msgstr "``o``" -#: ../../c-api/unicode.rst:515 +#: ../../c-api/unicode.rst:528 msgid "The octal representation of an unsigned C integer." msgstr "一個無符號 C 整數的八進位表示法。" -#: ../../c-api/unicode.rst:517 +#: ../../c-api/unicode.rst:530 msgid "``x``" msgstr "``x``" -#: ../../c-api/unicode.rst:519 +#: ../../c-api/unicode.rst:532 msgid "The hexadecimal representation of an unsigned C integer (lowercase)." msgstr "一個無符號 C 整數的十六進位表示法(小寫)。" -#: ../../c-api/unicode.rst:521 +#: ../../c-api/unicode.rst:534 msgid "``X``" msgstr "``X``" -#: ../../c-api/unicode.rst:523 +#: ../../c-api/unicode.rst:536 msgid "The hexadecimal representation of an unsigned C integer (uppercase)." msgstr "一個無符號 C 整數的十六進位表示法(大寫)。" -#: ../../c-api/unicode.rst:525 +#: ../../c-api/unicode.rst:538 msgid "``c``" msgstr "``c``" -#: ../../c-api/unicode.rst:526 +#: ../../c-api/unicode.rst:539 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../c-api/unicode.rst:527 +#: ../../c-api/unicode.rst:540 msgid "A single character." msgstr "一個單一字元。" -#: ../../c-api/unicode.rst:529 +#: ../../c-api/unicode.rst:542 msgid "``s``" msgstr "``s``" -#: ../../c-api/unicode.rst:530 +#: ../../c-api/unicode.rst:543 msgid ":c:expr:`const char*` or :c:expr:`const wchar_t*`" msgstr ":c:expr:`const char*` 或 :c:expr:`const wchar_t*`" -#: ../../c-api/unicode.rst:531 +#: ../../c-api/unicode.rst:544 msgid "A null-terminated C character array." msgstr "一個以 null 結尾的 C 字元陣列。" -#: ../../c-api/unicode.rst:533 +#: ../../c-api/unicode.rst:546 msgid "``p``" msgstr "``p``" -#: ../../c-api/unicode.rst:534 +#: ../../c-api/unicode.rst:547 msgid ":c:expr:`const void*`" msgstr ":c:expr:`const void*`" -#: ../../c-api/unicode.rst:535 +#: ../../c-api/unicode.rst:548 msgid "" "The hex representation of a C pointer. Mostly equivalent to " "``printf(\"%p\")`` except that it is guaranteed to start with the literal " "``0x`` regardless of what the platform's ``printf`` yields." msgstr "" -#: ../../c-api/unicode.rst:540 +#: ../../c-api/unicode.rst:553 msgid "``A``" msgstr "``A``" -#: ../../c-api/unicode.rst:541 ../../c-api/unicode.rst:545 -#: ../../c-api/unicode.rst:555 ../../c-api/unicode.rst:559 -#: ../../c-api/unicode.rst:563 ../../c-api/unicode.rst:568 +#: ../../c-api/unicode.rst:554 ../../c-api/unicode.rst:558 +#: ../../c-api/unicode.rst:568 ../../c-api/unicode.rst:572 +#: ../../c-api/unicode.rst:576 ../../c-api/unicode.rst:581 msgid ":c:expr:`PyObject*`" msgstr ":c:expr:`PyObject*`" -#: ../../c-api/unicode.rst:542 +#: ../../c-api/unicode.rst:555 msgid "The result of calling :func:`ascii`." msgstr "呼叫 :func:`ascii` 的結果。" -#: ../../c-api/unicode.rst:544 +#: ../../c-api/unicode.rst:557 msgid "``U``" msgstr "``U``" -#: ../../c-api/unicode.rst:546 +#: ../../c-api/unicode.rst:559 msgid "A Unicode object." msgstr "一個 Unicode 物件。" -#: ../../c-api/unicode.rst:548 +#: ../../c-api/unicode.rst:561 msgid "``V``" msgstr "``V``" -#: ../../c-api/unicode.rst:549 +#: ../../c-api/unicode.rst:562 msgid ":c:expr:`PyObject*`, :c:expr:`const char*` or :c:expr:`const wchar_t*`" msgstr ":c:expr:`PyObject*`、:c:expr:`const char*` 或 :c:expr:`const wchar_t*`" -#: ../../c-api/unicode.rst:550 +#: ../../c-api/unicode.rst:563 msgid "" "A Unicode object (which may be ``NULL``) and a null-terminated C character " "array as a second parameter (which will be used, if the first parameter is " "``NULL``)." msgstr "" -#: ../../c-api/unicode.rst:554 +#: ../../c-api/unicode.rst:567 msgid "``S``" msgstr "``S``" -#: ../../c-api/unicode.rst:556 +#: ../../c-api/unicode.rst:569 msgid "The result of calling :c:func:`PyObject_Str`." msgstr "呼叫 :c:func:`PyObject_Str` 的結果。" -#: ../../c-api/unicode.rst:558 +#: ../../c-api/unicode.rst:571 msgid "``R``" msgstr "``R``" -#: ../../c-api/unicode.rst:560 +#: ../../c-api/unicode.rst:573 msgid "The result of calling :c:func:`PyObject_Repr`." msgstr "呼叫 :c:func:`PyObject_Repr` 的結果。" -#: ../../c-api/unicode.rst:562 +#: ../../c-api/unicode.rst:575 msgid "``T``" msgstr "``T``" -#: ../../c-api/unicode.rst:564 +#: ../../c-api/unicode.rst:577 msgid "" "Get the fully qualified name of an object type; call :c:func:" "`PyType_GetFullyQualifiedName`." msgstr "" -#: ../../c-api/unicode.rst:567 +#: ../../c-api/unicode.rst:580 msgid "``#T``" msgstr "``#T``" -#: ../../c-api/unicode.rst:569 +#: ../../c-api/unicode.rst:582 msgid "" "Similar to ``T`` format, but use a colon (``:``) as separator between the " "module name and the qualified name." msgstr "" -#: ../../c-api/unicode.rst:572 +#: ../../c-api/unicode.rst:585 msgid "``N``" msgstr "``N``" -#: ../../c-api/unicode.rst:573 ../../c-api/unicode.rst:578 +#: ../../c-api/unicode.rst:586 ../../c-api/unicode.rst:591 msgid ":c:expr:`PyTypeObject*`" msgstr ":c:expr:`PyTypeObject*`" -#: ../../c-api/unicode.rst:574 +#: ../../c-api/unicode.rst:587 msgid "" "Get the fully qualified name of a type; call :c:func:" "`PyType_GetFullyQualifiedName`." msgstr "" -#: ../../c-api/unicode.rst:577 +#: ../../c-api/unicode.rst:590 msgid "``#N``" msgstr "``#N``" -#: ../../c-api/unicode.rst:579 +#: ../../c-api/unicode.rst:592 msgid "" "Similar to ``N`` format, but use a colon (``:``) as separator between the " "module name and the qualified name." msgstr "" -#: ../../c-api/unicode.rst:583 +#: ../../c-api/unicode.rst:596 msgid "" "The width formatter unit is number of characters rather than bytes. The " "precision formatter unit is number of bytes or :c:type:`wchar_t` items (if " @@ -824,22 +848,22 @@ msgid "" "``PyObject*`` argument is not ``NULL``)." msgstr "" -#: ../../c-api/unicode.rst:591 +#: ../../c-api/unicode.rst:604 msgid "" "Unlike to C :c:func:`printf` the ``0`` flag has effect even when a precision " "is given for integer conversions (``d``, ``i``, ``u``, ``o``, ``x``, or " "``X``)." msgstr "" -#: ../../c-api/unicode.rst:595 +#: ../../c-api/unicode.rst:608 msgid "Support for ``\"%lld\"`` and ``\"%llu\"`` added." msgstr "新增對 ``\"%lld\"`` 和 ``\"%llu\"`` 的支援。" -#: ../../c-api/unicode.rst:598 +#: ../../c-api/unicode.rst:611 msgid "Support for ``\"%li\"``, ``\"%lli\"`` and ``\"%zi\"`` added." msgstr "新增對 ``\"%li\"``、``\"%lli\"`` 和 ``\"%zi\"`` 的支援。" -#: ../../c-api/unicode.rst:601 +#: ../../c-api/unicode.rst:614 msgid "" "Support width and precision formatter for ``\"%s\"``, ``\"%A\"``, " "``\"%U\"``, ``\"%V\"``, ``\"%S\"``, ``\"%R\"`` added." @@ -847,7 +871,7 @@ msgstr "" "新增對 ``\"%s\"``、``\"%A\"``、``\"%U\"``、``\"%V\"``、``\"%S\"``、" "``\"%R\"`` 的寬度和精確度格式化支援。" -#: ../../c-api/unicode.rst:605 +#: ../../c-api/unicode.rst:618 msgid "" "Support for conversion specifiers ``o`` and ``X``. Support for length " "modifiers ``j`` and ``t``. Length modifiers are now applied to all integer " @@ -856,50 +880,50 @@ msgid "" "flag ``-``." msgstr "" -#: ../../c-api/unicode.rst:613 +#: ../../c-api/unicode.rst:626 msgid "" "An unrecognized format character now sets a :exc:`SystemError`. In previous " "versions it caused all the rest of the format string to be copied as-is to " "the result string, and any extra arguments discarded." msgstr "" -#: ../../c-api/unicode.rst:617 +#: ../../c-api/unicode.rst:630 msgid "Support for ``%T``, ``%#T``, ``%N`` and ``%#N`` formats added." msgstr "新增對 ``%T``、``%#T``、``%N`` 和 ``%#N`` 格式的支援。" -#: ../../c-api/unicode.rst:623 +#: ../../c-api/unicode.rst:636 msgid "" "Identical to :c:func:`PyUnicode_FromFormat` except that it takes exactly two " "arguments." msgstr "" -#: ../../c-api/unicode.rst:629 +#: ../../c-api/unicode.rst:642 msgid "" "Copy an instance of a Unicode subtype to a new true Unicode object if " "necessary. If *obj* is already a true Unicode object (not a subtype), return " "a new :term:`strong reference` to the object." msgstr "" -#: ../../c-api/unicode.rst:633 +#: ../../c-api/unicode.rst:646 msgid "" "Objects other than Unicode or its subtypes will cause a :exc:`TypeError`." msgstr "" -#: ../../c-api/unicode.rst:638 +#: ../../c-api/unicode.rst:651 msgid "Create a Unicode Object from the given Unicode code point *ordinal*." msgstr "" -#: ../../c-api/unicode.rst:640 +#: ../../c-api/unicode.rst:653 msgid "" "The ordinal must be in ``range(0x110000)``. A :exc:`ValueError` is raised in " "the case it is not." msgstr "" -#: ../../c-api/unicode.rst:647 +#: ../../c-api/unicode.rst:660 msgid "Decode an encoded object *obj* to a Unicode object." msgstr "" -#: ../../c-api/unicode.rst:649 +#: ../../c-api/unicode.rst:662 msgid "" ":class:`bytes`, :class:`bytearray` and other :term:`bytes-like objects " "` are decoded according to the given *encoding* and using " @@ -907,40 +931,40 @@ msgid "" "interface use the default values (see :ref:`builtincodecs` for details)." msgstr "" -#: ../../c-api/unicode.rst:655 +#: ../../c-api/unicode.rst:668 msgid "" "All other objects, including Unicode objects, cause a :exc:`TypeError` to be " "set." msgstr "" -#: ../../c-api/unicode.rst:658 +#: ../../c-api/unicode.rst:671 msgid "" "The API returns ``NULL`` if there was an error. The caller is responsible " "for decref'ing the returned objects." msgstr "" -#: ../../c-api/unicode.rst:664 +#: ../../c-api/unicode.rst:677 msgid "" "Append the string *right* to the end of *p_left*. *p_left* must point to a :" "term:`strong reference` to a Unicode object; :c:func:`!PyUnicode_Append` " "releases (\":term:`steals `\") this reference." msgstr "" -#: ../../c-api/unicode.rst:669 +#: ../../c-api/unicode.rst:682 msgid "On error, set *\\*p_left* to ``NULL`` and set an exception." msgstr "於錯誤發生時,將 *\\*p_left* 設為 ``NULL`` 並設定例外。" -#: ../../c-api/unicode.rst:671 +#: ../../c-api/unicode.rst:684 msgid "On success, set *\\*p_left* to a new strong reference to the result." msgstr "" -#: ../../c-api/unicode.rst:676 +#: ../../c-api/unicode.rst:689 msgid "" "The function is similar to :c:func:`PyUnicode_Append`, with the only " "difference being that it decrements the reference count of *right* by one." msgstr "" -#: ../../c-api/unicode.rst:682 +#: ../../c-api/unicode.rst:695 msgid "" "Return a mapping suitable for decoding a custom single-byte encoding. Given " "a Unicode string *string* of up to 256 characters representing an encoding " @@ -949,27 +973,27 @@ msgid "" "return ``NULL`` on invalid input." msgstr "" -#: ../../c-api/unicode.rst:693 +#: ../../c-api/unicode.rst:706 msgid "" "Return the name of the default string encoding, ``\"utf-8\"``. See :func:" "`sys.getdefaultencoding`." msgstr "" -#: ../../c-api/unicode.rst:696 +#: ../../c-api/unicode.rst:709 msgid "" "The returned string does not need to be freed, and is valid until " "interpreter shutdown." msgstr "" -#: ../../c-api/unicode.rst:702 +#: ../../c-api/unicode.rst:715 msgid "Return the length of the Unicode object, in code points." msgstr "" -#: ../../c-api/unicode.rst:704 +#: ../../c-api/unicode.rst:717 msgid "On error, set an exception and return ``-1``." msgstr "發生錯誤時,設定例外並回傳 ``-1``。" -#: ../../c-api/unicode.rst:715 +#: ../../c-api/unicode.rst:728 msgid "" "Copy characters from one Unicode object into another. This function " "performs character conversion when necessary and falls back to :c:func:`!" @@ -977,62 +1001,62 @@ msgid "" "otherwise returns the number of copied characters." msgstr "" -#: ../../c-api/unicode.rst:720 ../../c-api/unicode.rst:750 -#: ../../c-api/unicode.rst:770 +#: ../../c-api/unicode.rst:733 ../../c-api/unicode.rst:763 +#: ../../c-api/unicode.rst:783 msgid "" "The string must not have been “used” yet. See :c:func:`PyUnicode_New` for " "details." msgstr "" -#: ../../c-api/unicode.rst:728 +#: ../../c-api/unicode.rst:741 msgid "" "Resize a Unicode object *\\*unicode* to the new *length* in code points." msgstr "" -#: ../../c-api/unicode.rst:730 +#: ../../c-api/unicode.rst:743 msgid "" "Try to resize the string in place (which is usually faster than allocating a " "new string and copying characters), or create a new string." msgstr "" -#: ../../c-api/unicode.rst:733 +#: ../../c-api/unicode.rst:746 msgid "" "*\\*unicode* is modified to point to the new (resized) object and ``0`` is " "returned on success. Otherwise, ``-1`` is returned and an exception is set, " "and *\\*unicode* is left untouched." msgstr "" -#: ../../c-api/unicode.rst:737 +#: ../../c-api/unicode.rst:750 msgid "" "The function doesn't check string content, the result may not be a string in " "canonical representation." msgstr "" -#: ../../c-api/unicode.rst:744 +#: ../../c-api/unicode.rst:757 msgid "" "Fill a string with a character: write *fill_char* into ``unicode[start:" "start+length]``." msgstr "" -#: ../../c-api/unicode.rst:747 +#: ../../c-api/unicode.rst:760 msgid "" "Fail if *fill_char* is bigger than the string maximum character, or if the " "string has more than 1 reference." msgstr "" -#: ../../c-api/unicode.rst:753 +#: ../../c-api/unicode.rst:766 msgid "" "Return the number of written characters, or return ``-1`` and raise an " "exception on error." msgstr "回傳已寫入的字元數,發生錯誤時引發例外並回傳 ``-1``。" -#: ../../c-api/unicode.rst:762 +#: ../../c-api/unicode.rst:775 msgid "" "Write a *character* to the string *unicode* at the zero-based *index*. " "Return ``0`` on success, ``-1`` on error with an exception set." msgstr "" -#: ../../c-api/unicode.rst:765 +#: ../../c-api/unicode.rst:778 msgid "" "This function checks that *unicode* is a Unicode object, that the index is " "not out of bounds, and that the object's reference count is one. See :c:func:" @@ -1040,25 +1064,25 @@ msgid "" "responsibility." msgstr "" -#: ../../c-api/unicode.rst:778 +#: ../../c-api/unicode.rst:791 msgid "" "Read a character from a string. This function checks that *unicode* is a " "Unicode object and the index is not out of bounds, in contrast to :c:func:" "`PyUnicode_READ_CHAR`, which performs no error checking." msgstr "" -#: ../../c-api/unicode.rst:782 +#: ../../c-api/unicode.rst:795 msgid "Return character on success, ``-1`` on error with an exception set." msgstr "成功時回傳字元,發生錯誤時設定例外並回傳 ``-1``。" -#: ../../c-api/unicode.rst:790 +#: ../../c-api/unicode.rst:803 msgid "" "Return a substring of *unicode*, from character index *start* (included) to " "character index *end* (excluded). Negative indices are not supported. On " "error, set an exception and return ``NULL``." msgstr "" -#: ../../c-api/unicode.rst:800 +#: ../../c-api/unicode.rst:813 msgid "" "Copy the string *unicode* into a UCS4 buffer, including a null character, if " "*copy_null* is set. Returns ``NULL`` and sets an exception on error (in " @@ -1066,7 +1090,7 @@ msgid "" "*unicode*). *buffer* is returned on success." msgstr "" -#: ../../c-api/unicode.rst:810 +#: ../../c-api/unicode.rst:823 msgid "" "Copy the string *unicode* into a new UCS4 buffer that is allocated using :c:" "func:`PyMem_Malloc`. If this fails, ``NULL`` is returned with a :exc:" @@ -1074,17 +1098,17 @@ msgid "" "appended." msgstr "" -#: ../../c-api/unicode.rst:819 +#: ../../c-api/unicode.rst:832 msgid "Locale Encoding" msgstr "" -#: ../../c-api/unicode.rst:821 +#: ../../c-api/unicode.rst:834 msgid "" "The current locale encoding can be used to decode text from the operating " "system." msgstr "" -#: ../../c-api/unicode.rst:828 +#: ../../c-api/unicode.rst:841 msgid "" "Decode a string from UTF-8 on Android and VxWorks, or from the current " "locale encoding on other platforms. The supported error handlers are " @@ -1093,21 +1117,21 @@ msgid "" "null character but cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:835 +#: ../../c-api/unicode.rst:848 msgid "" "Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` to decode a string from the :" "term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:838 ../../c-api/unicode.rst:873 +#: ../../c-api/unicode.rst:851 ../../c-api/unicode.rst:886 msgid "This function ignores the :ref:`Python UTF-8 Mode `." msgstr "此函式會忽略 :ref:`Python UTF-8 模式 `。" -#: ../../c-api/unicode.rst:842 ../../c-api/unicode.rst:958 +#: ../../c-api/unicode.rst:855 ../../c-api/unicode.rst:971 msgid "The :c:func:`Py_DecodeLocale` function." msgstr ":c:func:`Py_DecodeLocale` 函式。" -#: ../../c-api/unicode.rst:846 +#: ../../c-api/unicode.rst:859 msgid "" "The function now also uses the current locale encoding for the " "``surrogateescape`` error handler, except on Android. Previously, :c:func:" @@ -1115,7 +1139,7 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:855 +#: ../../c-api/unicode.rst:868 msgid "" "Similar to :c:func:`PyUnicode_DecodeLocaleAndSize`, but compute the string " "length using :c:func:`!strlen`." @@ -1123,7 +1147,7 @@ msgstr "" "類似於 :c:func:`PyUnicode_DecodeLocaleAndSize`,但使用 :c:func:`!strlen` 計算" "字串長度。" -#: ../../c-api/unicode.rst:863 +#: ../../c-api/unicode.rst:876 msgid "" "Encode a Unicode object to UTF-8 on Android and VxWorks, or to the current " "locale encoding on other platforms. The supported error handlers are " @@ -1132,17 +1156,17 @@ msgid "" "`bytes` object. *unicode* cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:870 +#: ../../c-api/unicode.rst:883 msgid "" "Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to the :term:" "`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:877 ../../c-api/unicode.rst:989 +#: ../../c-api/unicode.rst:890 ../../c-api/unicode.rst:1002 msgid "The :c:func:`Py_EncodeLocale` function." msgstr ":c:func:`Py_EncodeLocale` 函式。" -#: ../../c-api/unicode.rst:881 +#: ../../c-api/unicode.rst:894 msgid "" "The function now also uses the current locale encoding for the " "``surrogateescape`` error handler, except on Android. Previously, :c:func:" @@ -1150,24 +1174,24 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:890 +#: ../../c-api/unicode.rst:903 msgid "File System Encoding" msgstr "檔案系統編碼" -#: ../../c-api/unicode.rst:892 +#: ../../c-api/unicode.rst:905 msgid "" "Functions encoding to and decoding from the :term:`filesystem encoding and " "error handler` (:pep:`383` and :pep:`529`)." msgstr "" -#: ../../c-api/unicode.rst:895 +#: ../../c-api/unicode.rst:908 msgid "" "To encode file names to :class:`bytes` during argument parsing, the " "``\"O&\"`` converter should be used, passing :c:func:`!" "PyUnicode_FSConverter` as the conversion function:" msgstr "" -#: ../../c-api/unicode.rst:901 +#: ../../c-api/unicode.rst:914 msgid "" ":ref:`PyArg_Parse\\* converter `: encode :class:`str` objects " "-- obtained directly or through the :class:`os.PathLike` interface -- to :" @@ -1180,24 +1204,24 @@ msgid "" "not allowed in the result. On failure, return ``0`` with an exception set." msgstr "" -#: ../../c-api/unicode.rst:913 +#: ../../c-api/unicode.rst:926 msgid "" "If *obj* is ``NULL``, the function releases a strong reference stored in the " "variable referred by *result* and returns ``1``." msgstr "" -#: ../../c-api/unicode.rst:918 ../../c-api/unicode.rst:945 +#: ../../c-api/unicode.rst:931 ../../c-api/unicode.rst:958 msgid "Accepts a :term:`path-like object`." msgstr "接受一個 :term:`path-like object`。" -#: ../../c-api/unicode.rst:921 +#: ../../c-api/unicode.rst:934 msgid "" "To decode file names to :class:`str` during argument parsing, the ``\"O&\"`` " "converter should be used, passing :c:func:`!PyUnicode_FSDecoder` as the " "conversion function:" msgstr "" -#: ../../c-api/unicode.rst:927 +#: ../../c-api/unicode.rst:940 msgid "" ":ref:`PyArg_Parse\\* converter `: decode :class:`bytes` objects " "-- obtained either directly or indirectly through the :class:`os.PathLike` " @@ -1211,63 +1235,63 @@ msgid "" "result. On failure, return ``0`` with an exception set." msgstr "" -#: ../../c-api/unicode.rst:940 +#: ../../c-api/unicode.rst:953 msgid "" "If *obj* is ``NULL``, release the strong reference to the object referred to " "by *result* and return ``1``." msgstr "" -#: ../../c-api/unicode.rst:951 +#: ../../c-api/unicode.rst:964 msgid "Decode a string from the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:953 +#: ../../c-api/unicode.rst:966 msgid "" "If you need to decode a string from the current locale encoding, use :c:func:" "`PyUnicode_DecodeLocaleAndSize`." msgstr "" -#: ../../c-api/unicode.rst:960 ../../c-api/unicode.rst:973 -#: ../../c-api/unicode.rst:993 +#: ../../c-api/unicode.rst:973 ../../c-api/unicode.rst:986 +#: ../../c-api/unicode.rst:1006 msgid "" "The :term:`filesystem error handler ` " "is now used." msgstr "" -#: ../../c-api/unicode.rst:967 +#: ../../c-api/unicode.rst:980 msgid "" "Decode a null-terminated string from the :term:`filesystem encoding and " "error handler`." msgstr "" -#: ../../c-api/unicode.rst:970 +#: ../../c-api/unicode.rst:983 msgid "" "If the string length is known, use :c:func:" "`PyUnicode_DecodeFSDefaultAndSize`." msgstr "如果字串長度已知,請使用 :c:func:`PyUnicode_DecodeFSDefaultAndSize`。" -#: ../../c-api/unicode.rst:980 +#: ../../c-api/unicode.rst:993 msgid "" "Encode a Unicode object to the :term:`filesystem encoding and error " "handler`, and return :class:`bytes`. Note that the resulting :class:`bytes` " "object can contain null bytes." msgstr "" -#: ../../c-api/unicode.rst:984 +#: ../../c-api/unicode.rst:997 msgid "" "If you need to encode a string to the current locale encoding, use :c:func:" "`PyUnicode_EncodeLocale`." msgstr "" -#: ../../c-api/unicode.rst:998 +#: ../../c-api/unicode.rst:1011 msgid "wchar_t Support" msgstr "wchar_t 支援" -#: ../../c-api/unicode.rst:1000 +#: ../../c-api/unicode.rst:1013 msgid ":c:type:`wchar_t` support for platforms which support it:" msgstr "對支援 :c:type:`wchar_t` 的平台提供支援:" -#: ../../c-api/unicode.rst:1004 +#: ../../c-api/unicode.rst:1017 msgid "" "Create a Unicode object from the :c:type:`wchar_t` buffer *wstr* of the " "given *size*. Passing ``-1`` as the *size* indicates that the function must " @@ -1275,7 +1299,7 @@ msgid "" "failure." msgstr "" -#: ../../c-api/unicode.rst:1012 +#: ../../c-api/unicode.rst:1025 msgid "" "Copy the Unicode object contents into the :c:type:`wchar_t` buffer *wstr*. " "At most *size* :c:type:`wchar_t` characters are copied (excluding a possibly " @@ -1283,13 +1307,13 @@ msgid "" "`wchar_t` characters copied or ``-1`` in case of an error." msgstr "" -#: ../../c-api/unicode.rst:1017 +#: ../../c-api/unicode.rst:1030 msgid "" "When *wstr* is ``NULL``, instead return the *size* that would be required to " "store all of *unicode* including a terminating null." msgstr "" -#: ../../c-api/unicode.rst:1020 +#: ../../c-api/unicode.rst:1033 msgid "" "Note that the resulting :c:expr:`wchar_t*` string may or may not be null-" "terminated. It is the responsibility of the caller to make sure that the :c:" @@ -1299,7 +1323,7 @@ msgid "" "most C functions." msgstr "" -#: ../../c-api/unicode.rst:1030 +#: ../../c-api/unicode.rst:1043 msgid "" "Convert the Unicode object to a wide character string. The output string " "always ends with a null character. If *size* is not ``NULL``, write the " @@ -1310,37 +1334,37 @@ msgid "" "`wchar_t*` string contains null characters a :exc:`ValueError` is raised." msgstr "" -#: ../../c-api/unicode.rst:1038 +#: ../../c-api/unicode.rst:1051 msgid "" "Returns a buffer allocated by :c:macro:`PyMem_New` (use :c:func:`PyMem_Free` " "to free it) on success. On error, returns ``NULL`` and *\\*size* is " "undefined. Raises a :exc:`MemoryError` if memory allocation is failed." msgstr "" -#: ../../c-api/unicode.rst:1045 +#: ../../c-api/unicode.rst:1058 msgid "" "Raises a :exc:`ValueError` if *size* is ``NULL`` and the :c:expr:`wchar_t*` " "string contains null characters." msgstr "" -#: ../../c-api/unicode.rst:1053 +#: ../../c-api/unicode.rst:1066 msgid "Built-in Codecs" msgstr "內建編解碼器" -#: ../../c-api/unicode.rst:1055 +#: ../../c-api/unicode.rst:1068 msgid "" "Python provides a set of built-in codecs which are written in C for speed. " "All of these codecs are directly usable via the following functions." msgstr "" -#: ../../c-api/unicode.rst:1058 +#: ../../c-api/unicode.rst:1071 msgid "" "Many of the following APIs take two arguments encoding and errors, and they " "have the same semantics as the ones of the built-in :func:`str` string " "object constructor." msgstr "" -#: ../../c-api/unicode.rst:1062 +#: ../../c-api/unicode.rst:1075 msgid "" "Setting encoding to ``NULL`` causes the default encoding to be used which is " "UTF-8. The file system calls should use :c:func:`PyUnicode_FSConverter` for " @@ -1348,42 +1372,42 @@ msgid "" "handler` internally." msgstr "" -#: ../../c-api/unicode.rst:1067 +#: ../../c-api/unicode.rst:1080 msgid "" "Error handling is set by errors which may also be set to ``NULL`` meaning to " "use the default handling defined for the codec. Default error handling for " "all built-in codecs is \"strict\" (:exc:`ValueError` is raised)." msgstr "" -#: ../../c-api/unicode.rst:1071 +#: ../../c-api/unicode.rst:1084 msgid "" "The codecs all use a similar interface. Only deviations from the following " "generic ones are documented for simplicity." msgstr "" -#: ../../c-api/unicode.rst:1076 +#: ../../c-api/unicode.rst:1089 msgid "Generic Codecs" msgstr "泛用編解碼器" -#: ../../c-api/unicode.rst:1078 +#: ../../c-api/unicode.rst:1091 msgid "The following macro is provided:" msgstr "" -#: ../../c-api/unicode.rst:1083 +#: ../../c-api/unicode.rst:1096 msgid "The Unicode code point ``U+FFFD`` (replacement character)." msgstr "" -#: ../../c-api/unicode.rst:1085 +#: ../../c-api/unicode.rst:1098 msgid "" "This Unicode character is used as the replacement character during decoding " "if the *errors* argument is set to \"replace\"." msgstr "" -#: ../../c-api/unicode.rst:1089 +#: ../../c-api/unicode.rst:1102 msgid "These are the generic codec APIs:" msgstr "這些是泛用編解碼器的 API:" -#: ../../c-api/unicode.rst:1095 +#: ../../c-api/unicode.rst:1108 msgid "" "Create a Unicode object by decoding *size* bytes of the encoded string " "*str*. *encoding* and *errors* have the same meaning as the parameters of " @@ -1392,7 +1416,7 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1105 +#: ../../c-api/unicode.rst:1118 msgid "" "Encode a Unicode object and return the result as Python bytes object. " "*encoding* and *errors* have the same meaning as the parameters of the same " @@ -1401,21 +1425,21 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1113 +#: ../../c-api/unicode.rst:1126 msgid "UTF-8 Codecs" msgstr "UTF-8 編解碼器" -#: ../../c-api/unicode.rst:1115 +#: ../../c-api/unicode.rst:1128 msgid "These are the UTF-8 codec APIs:" msgstr "這些是 UTF-8 編解碼器的 API:" -#: ../../c-api/unicode.rst:1120 +#: ../../c-api/unicode.rst:1133 msgid "" "Create a Unicode object by decoding *size* bytes of the UTF-8 encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1127 +#: ../../c-api/unicode.rst:1140 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF8`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-8 byte sequences will " @@ -1423,20 +1447,20 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1135 +#: ../../c-api/unicode.rst:1148 msgid "" "Encode a Unicode object using UTF-8 and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1139 ../../c-api/unicode.rst:1154 +#: ../../c-api/unicode.rst:1152 ../../c-api/unicode.rst:1167 msgid "" "The function fails if the string contains surrogate code points (``U+D800`` " "- ``U+DFFF``)." msgstr "" -#: ../../c-api/unicode.rst:1145 +#: ../../c-api/unicode.rst:1158 msgid "" "Return a pointer to the UTF-8 encoding of the Unicode object, and store the " "size of the encoded representation (in bytes) in *size*. The *size* " @@ -1445,7 +1469,7 @@ msgid "" "regardless of whether there are any other null code points." msgstr "" -#: ../../c-api/unicode.rst:1151 +#: ../../c-api/unicode.rst:1164 msgid "" "On error, set an exception, set *size* to ``-1`` (if it's not NULL) and " "return ``NULL``." @@ -1453,7 +1477,7 @@ msgstr "" "發生錯誤時,設定例外並將 *size* 設為 ``-1``\\ (如果不是 NULL),並回傳 " "``NULL``。" -#: ../../c-api/unicode.rst:1157 +#: ../../c-api/unicode.rst:1170 msgid "" "This caches the UTF-8 representation of the string in the Unicode object, " "and subsequent calls will return a pointer to the same buffer. The caller " @@ -1462,19 +1486,19 @@ msgid "" "collected." msgstr "" -#: ../../c-api/unicode.rst:1164 ../../c-api/unicode.rst:1186 +#: ../../c-api/unicode.rst:1177 ../../c-api/unicode.rst:1199 msgid "The return type is now ``const char *`` rather than ``char *``." msgstr "回傳型別現在是 ``const char *`` 而不是 ``char *``。" -#: ../../c-api/unicode.rst:1167 +#: ../../c-api/unicode.rst:1180 msgid "This function is a part of the :ref:`limited API `." msgstr "" -#: ../../c-api/unicode.rst:1173 +#: ../../c-api/unicode.rst:1186 msgid "As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size." msgstr "與 :c:func:`PyUnicode_AsUTF8AndSize` 類似,但不儲存大小。" -#: ../../c-api/unicode.rst:1177 +#: ../../c-api/unicode.rst:1190 msgid "" "This function does not have any special behavior for `null characters " "`_ embedded within *unicode*. " @@ -1484,35 +1508,35 @@ msgid "" "c:func:`PyUnicode_AsUTF8AndSize` instead." msgstr "" -#: ../../c-api/unicode.rst:1191 +#: ../../c-api/unicode.rst:1204 msgid "UTF-32 Codecs" msgstr "UTF-32 編解碼器" -#: ../../c-api/unicode.rst:1193 +#: ../../c-api/unicode.rst:1206 msgid "These are the UTF-32 codec APIs:" msgstr "這些是 UTF-32 編解碼器的 API:" -#: ../../c-api/unicode.rst:1199 +#: ../../c-api/unicode.rst:1212 msgid "" "Decode *size* bytes from a UTF-32 encoded buffer string and return the " "corresponding Unicode object. *errors* (if non-``NULL``) defines the error " "handling. It defaults to \"strict\"." msgstr "" -#: ../../c-api/unicode.rst:1203 ../../c-api/unicode.rst:1253 +#: ../../c-api/unicode.rst:1216 ../../c-api/unicode.rst:1266 msgid "" "If *byteorder* is non-``NULL``, the decoder starts decoding using the given " "byte order::" msgstr "" -#: ../../c-api/unicode.rst:1206 ../../c-api/unicode.rst:1256 +#: ../../c-api/unicode.rst:1219 ../../c-api/unicode.rst:1269 msgid "" "*byteorder == -1: little endian\n" "*byteorder == 0: native order\n" "*byteorder == 1: big endian" msgstr "" -#: ../../c-api/unicode.rst:1210 +#: ../../c-api/unicode.rst:1223 msgid "" "If ``*byteorder`` is zero, and the first four bytes of the input data are a " "byte order mark (BOM), the decoder switches to this byte order and the BOM " @@ -1520,21 +1544,21 @@ msgid "" "``-1`` or ``1``, any byte order mark is copied to the output." msgstr "" -#: ../../c-api/unicode.rst:1215 +#: ../../c-api/unicode.rst:1228 msgid "" "After completion, *\\*byteorder* is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1218 ../../c-api/unicode.rst:1269 +#: ../../c-api/unicode.rst:1231 ../../c-api/unicode.rst:1282 msgid "If *byteorder* is ``NULL``, the codec starts in native order mode." msgstr "" -#: ../../c-api/unicode.rst:1220 ../../c-api/unicode.rst:1271 +#: ../../c-api/unicode.rst:1233 ../../c-api/unicode.rst:1284 msgid "Return ``NULL`` if an exception was raised by the codec." msgstr "如果編解碼器引發例外則回傳 ``NULL``。" -#: ../../c-api/unicode.rst:1226 +#: ../../c-api/unicode.rst:1239 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF32`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF32Stateful` will not " @@ -1543,29 +1567,29 @@ msgid "" "number of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1235 +#: ../../c-api/unicode.rst:1248 msgid "" "Return a Python byte string using the UTF-32 encoding in native byte order. " "The string always starts with a BOM mark. Error handling is \"strict\". " "Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1241 +#: ../../c-api/unicode.rst:1254 msgid "UTF-16 Codecs" msgstr "UTF-16 編解碼器" -#: ../../c-api/unicode.rst:1243 +#: ../../c-api/unicode.rst:1256 msgid "These are the UTF-16 codec APIs:" msgstr "這些是 UTF-16 編解碼器的 API:" -#: ../../c-api/unicode.rst:1249 +#: ../../c-api/unicode.rst:1262 msgid "" "Decode *size* bytes from a UTF-16 encoded buffer string and return the " "corresponding Unicode object. *errors* (if non-``NULL``) defines the error " "handling. It defaults to \"strict\"." msgstr "" -#: ../../c-api/unicode.rst:1260 +#: ../../c-api/unicode.rst:1273 msgid "" "If ``*byteorder`` is zero, and the first two bytes of the input data are a " "byte order mark (BOM), the decoder switches to this byte order and the BOM " @@ -1574,13 +1598,13 @@ msgid "" "result in either a ``\\ufeff`` or a ``\\ufffe`` character)." msgstr "" -#: ../../c-api/unicode.rst:1266 +#: ../../c-api/unicode.rst:1279 msgid "" "After completion, ``*byteorder`` is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1277 +#: ../../c-api/unicode.rst:1290 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF16`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF16Stateful` will not " @@ -1590,28 +1614,28 @@ msgid "" "*consumed*." msgstr "" -#: ../../c-api/unicode.rst:1286 +#: ../../c-api/unicode.rst:1299 msgid "" "Return a Python byte string using the UTF-16 encoding in native byte order. " "The string always starts with a BOM mark. Error handling is \"strict\". " "Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1292 +#: ../../c-api/unicode.rst:1305 msgid "UTF-7 Codecs" msgstr "UTF-7 編解碼器" -#: ../../c-api/unicode.rst:1294 +#: ../../c-api/unicode.rst:1307 msgid "These are the UTF-7 codec APIs:" msgstr "這些是 UTF-7 編解碼器的 API:" -#: ../../c-api/unicode.rst:1299 +#: ../../c-api/unicode.rst:1312 msgid "" "Create a Unicode object by decoding *size* bytes of the UTF-7 encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1306 +#: ../../c-api/unicode.rst:1319 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF7`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-7 base-64 sections will " @@ -1619,101 +1643,101 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1313 +#: ../../c-api/unicode.rst:1326 msgid "Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1315 +#: ../../c-api/unicode.rst:1328 msgid "These are the \"Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1321 +#: ../../c-api/unicode.rst:1334 msgid "" "Create a Unicode object by decoding *size* bytes of the Unicode-Escape " "encoded string *str*. Return ``NULL`` if an exception was raised by the " "codec." msgstr "" -#: ../../c-api/unicode.rst:1327 +#: ../../c-api/unicode.rst:1340 msgid "" "Encode a Unicode object using Unicode-Escape and return the result as a " "bytes object. Error handling is \"strict\". Return ``NULL`` if an " "exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1333 +#: ../../c-api/unicode.rst:1346 msgid "Raw-Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1335 +#: ../../c-api/unicode.rst:1348 msgid "These are the \"Raw Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1341 +#: ../../c-api/unicode.rst:1354 msgid "" "Create a Unicode object by decoding *size* bytes of the Raw-Unicode-Escape " "encoded string *str*. Return ``NULL`` if an exception was raised by the " "codec." msgstr "" -#: ../../c-api/unicode.rst:1347 +#: ../../c-api/unicode.rst:1360 msgid "" "Encode a Unicode object using Raw-Unicode-Escape and return the result as a " "bytes object. Error handling is \"strict\". Return ``NULL`` if an " "exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1353 +#: ../../c-api/unicode.rst:1366 msgid "Latin-1 Codecs" msgstr "Latin-1 編解碼器" -#: ../../c-api/unicode.rst:1355 +#: ../../c-api/unicode.rst:1368 msgid "" "These are the Latin-1 codec APIs: Latin-1 corresponds to the first 256 " "Unicode ordinals and only these are accepted by the codecs during encoding." msgstr "" -#: ../../c-api/unicode.rst:1361 +#: ../../c-api/unicode.rst:1374 msgid "" "Create a Unicode object by decoding *size* bytes of the Latin-1 encoded " "string *str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1367 +#: ../../c-api/unicode.rst:1380 msgid "" "Encode a Unicode object using Latin-1 and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1373 +#: ../../c-api/unicode.rst:1386 msgid "ASCII Codecs" msgstr "ASCII 編解碼器" -#: ../../c-api/unicode.rst:1375 +#: ../../c-api/unicode.rst:1388 msgid "" "These are the ASCII codec APIs. Only 7-bit ASCII data is accepted. All " "other codes generate errors." msgstr "" -#: ../../c-api/unicode.rst:1381 +#: ../../c-api/unicode.rst:1394 msgid "" "Create a Unicode object by decoding *size* bytes of the ASCII encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1387 +#: ../../c-api/unicode.rst:1400 msgid "" "Encode a Unicode object using ASCII and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1393 +#: ../../c-api/unicode.rst:1406 msgid "Character Map Codecs" msgstr "" -#: ../../c-api/unicode.rst:1395 +#: ../../c-api/unicode.rst:1408 msgid "" "This codec is special in that it can be used to implement many different " "codecs (and this is in fact what was done to obtain most of the standard " @@ -1723,18 +1747,18 @@ msgid "" "sequences work well." msgstr "" -#: ../../c-api/unicode.rst:1401 +#: ../../c-api/unicode.rst:1414 msgid "These are the mapping codec APIs:" msgstr "這些是對映編解碼器的 API:" -#: ../../c-api/unicode.rst:1406 +#: ../../c-api/unicode.rst:1419 msgid "" "Create a Unicode object by decoding *size* bytes of the encoded string *str* " "using the given *mapping* object. Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1410 +#: ../../c-api/unicode.rst:1423 msgid "" "If *mapping* is ``NULL``, Latin-1 decoding will be applied. Else *mapping* " "must map bytes ordinals (integers in the range from 0 to 255) to Unicode " @@ -1744,14 +1768,14 @@ msgid "" "treated as undefined mappings and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1421 +#: ../../c-api/unicode.rst:1434 msgid "" "Encode a Unicode object using the given *mapping* object and return the " "result as a bytes object. Error handling is \"strict\". Return ``NULL`` if " "an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1425 +#: ../../c-api/unicode.rst:1438 msgid "" "The *mapping* object must map Unicode ordinal integers to bytes objects, " "integers in the range from 0 to 255 or ``None``. Unmapped character " @@ -1759,41 +1783,41 @@ msgid "" "``None`` are treated as \"undefined mapping\" and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1431 +#: ../../c-api/unicode.rst:1444 msgid "The following codec API is special in that maps Unicode to Unicode." msgstr "" -#: ../../c-api/unicode.rst:1435 +#: ../../c-api/unicode.rst:1448 msgid "" "Translate a string by applying a character mapping table to it and return " "the resulting Unicode object. Return ``NULL`` if an exception was raised by " "the codec." msgstr "" -#: ../../c-api/unicode.rst:1439 +#: ../../c-api/unicode.rst:1452 msgid "" "The mapping table must map Unicode ordinal integers to Unicode ordinal " "integers or ``None`` (causing deletion of the character)." msgstr "" -#: ../../c-api/unicode.rst:1442 +#: ../../c-api/unicode.rst:1455 msgid "" "Mapping tables need only provide the :meth:`~object.__getitem__` interface; " "dictionaries and sequences work well. Unmapped character ordinals (ones " "which cause a :exc:`LookupError`) are left untouched and are copied as-is." msgstr "" -#: ../../c-api/unicode.rst:1446 +#: ../../c-api/unicode.rst:1459 msgid "" "*errors* has the usual meaning for codecs. It may be ``NULL`` which " "indicates to use the default error handling." msgstr "" -#: ../../c-api/unicode.rst:1451 +#: ../../c-api/unicode.rst:1464 msgid "MBCS codecs for Windows" msgstr "Windows 的 MBCS 編解碼器" -#: ../../c-api/unicode.rst:1453 +#: ../../c-api/unicode.rst:1466 msgid "" "These are the MBCS codec APIs. They are currently only available on Windows " "and use the Win32 MBCS converters to implement the conversions. Note that " @@ -1801,13 +1825,13 @@ msgid "" "is defined by the user settings on the machine running the codec." msgstr "" -#: ../../c-api/unicode.rst:1460 +#: ../../c-api/unicode.rst:1473 msgid "" "Create a Unicode object by decoding *size* bytes of the MBCS encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1467 +#: ../../c-api/unicode.rst:1480 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeMBCS`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeMBCSStateful` will not " @@ -1815,46 +1839,46 @@ msgid "" "will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1476 +#: ../../c-api/unicode.rst:1489 msgid "" "Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except uses the code page " "specified by *code_page*." msgstr "" -#: ../../c-api/unicode.rst:1482 +#: ../../c-api/unicode.rst:1495 msgid "" "Encode a Unicode object using MBCS and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1489 +#: ../../c-api/unicode.rst:1502 msgid "" "Encode the Unicode object using the specified code page and return a Python " "bytes object. Return ``NULL`` if an exception was raised by the codec. Use :" "c:macro:`!CP_ACP` code page to get the MBCS encoder." msgstr "" -#: ../../c-api/unicode.rst:1499 +#: ../../c-api/unicode.rst:1512 msgid "Methods and Slot Functions" msgstr "" -#: ../../c-api/unicode.rst:1501 +#: ../../c-api/unicode.rst:1514 msgid "" "The following APIs are capable of handling Unicode objects and strings on " "input (we refer to them as strings in the descriptions) and return Unicode " "objects or integers as appropriate." msgstr "" -#: ../../c-api/unicode.rst:1505 +#: ../../c-api/unicode.rst:1518 msgid "They all return ``NULL`` or ``-1`` if an exception occurs." msgstr "如果發生例外,則回傳 ``NULL`` 或 ``-1``。" -#: ../../c-api/unicode.rst:1510 +#: ../../c-api/unicode.rst:1523 msgid "Concat two strings giving a new Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1515 +#: ../../c-api/unicode.rst:1528 msgid "" "Split a string giving a list of Unicode strings. If *sep* is ``NULL``, " "splitting will be done at all whitespace substrings. Otherwise, splits " @@ -1863,33 +1887,33 @@ msgid "" "list." msgstr "" -#: ../../c-api/unicode.rst:1520 ../../c-api/unicode.rst:1530 -#: ../../c-api/unicode.rst:1551 ../../c-api/unicode.rst:1564 +#: ../../c-api/unicode.rst:1533 ../../c-api/unicode.rst:1543 +#: ../../c-api/unicode.rst:1564 ../../c-api/unicode.rst:1577 msgid "On error, return ``NULL`` with an exception set." msgstr "於錯誤發生時回傳 ``NULL`` 並設定例外。" -#: ../../c-api/unicode.rst:1522 +#: ../../c-api/unicode.rst:1535 msgid "Equivalent to :py:meth:`str.split`." msgstr "等價於 :py:meth:`str.split`。" -#: ../../c-api/unicode.rst:1527 +#: ../../c-api/unicode.rst:1540 msgid "" "Similar to :c:func:`PyUnicode_Split`, but splitting will be done beginning " "at the end of the string." msgstr "" -#: ../../c-api/unicode.rst:1532 +#: ../../c-api/unicode.rst:1545 msgid "Equivalent to :py:meth:`str.rsplit`." msgstr "等價於 :py:meth:`str.rsplit`。" -#: ../../c-api/unicode.rst:1537 +#: ../../c-api/unicode.rst:1550 msgid "" "Split a Unicode string at line breaks, returning a list of Unicode strings. " "CRLF is considered to be one line break. If *keepends* is ``0``, the Line " "break characters are not included in the resulting strings." msgstr "" -#: ../../c-api/unicode.rst:1544 +#: ../../c-api/unicode.rst:1557 msgid "" "Split a Unicode string at the first occurrence of *sep*, and return a 3-" "tuple containing the part before the separator, the separator itself, and " @@ -1897,39 +1921,39 @@ msgid "" "tuple containing the string itself, followed by two empty strings." msgstr "" -#: ../../c-api/unicode.rst:1549 ../../c-api/unicode.rst:1562 +#: ../../c-api/unicode.rst:1562 ../../c-api/unicode.rst:1575 msgid "*sep* must not be empty." msgstr "*sep* 不得為空。" -#: ../../c-api/unicode.rst:1553 +#: ../../c-api/unicode.rst:1566 msgid "Equivalent to :py:meth:`str.partition`." msgstr "等價於 :py:meth:`str.partition`。" -#: ../../c-api/unicode.rst:1558 +#: ../../c-api/unicode.rst:1571 msgid "" "Similar to :c:func:`PyUnicode_Partition`, but split a Unicode string at the " "last occurrence of *sep*. If the separator is not found, return a 3-tuple " "containing two empty strings, followed by the string itself." msgstr "" -#: ../../c-api/unicode.rst:1566 +#: ../../c-api/unicode.rst:1579 msgid "Equivalent to :py:meth:`str.rpartition`." msgstr "等價於 :py:meth:`str.rpartition`。" -#: ../../c-api/unicode.rst:1571 +#: ../../c-api/unicode.rst:1584 msgid "" "Join a sequence of strings using the given *separator* and return the " "resulting Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1578 +#: ../../c-api/unicode.rst:1591 msgid "" "Return ``1`` if *substr* matches ``unicode[start:end]`` at the given tail " "end (*direction* == ``-1`` means to do a prefix match, *direction* == ``1`` " "a suffix match), ``0`` otherwise. Return ``-1`` if an error occurred." msgstr "" -#: ../../c-api/unicode.rst:1586 +#: ../../c-api/unicode.rst:1599 msgid "" "Return the first position of *substr* in ``unicode[start:end]`` using the " "given *direction* (*direction* == ``1`` means to do a forward search, " @@ -1938,7 +1962,7 @@ msgid "" "``-2`` indicates that an error occurred and an exception has been set." msgstr "" -#: ../../c-api/unicode.rst:1596 +#: ../../c-api/unicode.rst:1609 msgid "" "Return the first position of the character *ch* in ``unicode[start:end]`` " "using the given *direction* (*direction* == ``1`` means to do a forward " @@ -1948,73 +1972,73 @@ msgid "" "set." msgstr "" -#: ../../c-api/unicode.rst:1604 +#: ../../c-api/unicode.rst:1617 msgid "" "*start* and *end* are now adjusted to behave like ``unicode[start:end]``." msgstr "" -#: ../../c-api/unicode.rst:1611 +#: ../../c-api/unicode.rst:1624 msgid "" "Return the number of non-overlapping occurrences of *substr* in " "``unicode[start:end]``. Return ``-1`` if an error occurred." msgstr "" -#: ../../c-api/unicode.rst:1618 +#: ../../c-api/unicode.rst:1631 msgid "" "Replace at most *maxcount* occurrences of *substr* in *unicode* with " "*replstr* and return the resulting Unicode object. *maxcount* == ``-1`` " "means replace all occurrences." msgstr "" -#: ../../c-api/unicode.rst:1625 +#: ../../c-api/unicode.rst:1638 msgid "" "Compare two strings and return ``-1``, ``0``, ``1`` for less than, equal, " "and greater than, respectively." msgstr "" -#: ../../c-api/unicode.rst:1628 +#: ../../c-api/unicode.rst:1641 msgid "" "This function returns ``-1`` upon failure, so one should call :c:func:" "`PyErr_Occurred` to check for errors." msgstr "" -#: ../../c-api/unicode.rst:1633 +#: ../../c-api/unicode.rst:1646 msgid "The :c:func:`PyUnicode_Equal` function." msgstr ":c:func:`PyUnicode_Equal` 函式。" -#: ../../c-api/unicode.rst:1638 +#: ../../c-api/unicode.rst:1651 msgid "Test if two strings are equal:" msgstr "測試兩個字串是否相等:" -#: ../../c-api/unicode.rst:1640 +#: ../../c-api/unicode.rst:1653 msgid "Return ``1`` if *a* is equal to *b*." msgstr "如果 *a* 等於 *b*,則回傳 ``1``。" -#: ../../c-api/unicode.rst:1641 +#: ../../c-api/unicode.rst:1654 msgid "Return ``0`` if *a* is not equal to *b*." msgstr "如果 *a* 不等於 *b*,則回傳 ``0``。" -#: ../../c-api/unicode.rst:1642 +#: ../../c-api/unicode.rst:1655 msgid "" "Set a :exc:`TypeError` exception and return ``-1`` if *a* or *b* is not a :" "class:`str` object." msgstr "" -#: ../../c-api/unicode.rst:1645 +#: ../../c-api/unicode.rst:1658 msgid "The function always succeeds if *a* and *b* are :class:`str` objects." msgstr "" -#: ../../c-api/unicode.rst:1647 +#: ../../c-api/unicode.rst:1660 msgid "" "The function works for :class:`str` subclasses, but does not honor custom " "``__eq__()`` method." msgstr "" -#: ../../c-api/unicode.rst:1652 +#: ../../c-api/unicode.rst:1665 msgid "The :c:func:`PyUnicode_Compare` function." msgstr ":c:func:`PyUnicode_Compare` 函式。" -#: ../../c-api/unicode.rst:1659 +#: ../../c-api/unicode.rst:1672 msgid "" "Compare a Unicode object with a char buffer which is interpreted as being " "UTF-8 or ASCII encoded and return true (``1``) if they are equal, or false " @@ -2023,18 +2047,18 @@ msgid "" "is returned." msgstr "" -#: ../../c-api/unicode.rst:1666 ../../c-api/unicode.rst:1687 +#: ../../c-api/unicode.rst:1679 ../../c-api/unicode.rst:1700 msgid "This function does not raise exceptions." msgstr "此函式不會引發例外。" -#: ../../c-api/unicode.rst:1673 +#: ../../c-api/unicode.rst:1686 msgid "" "Similar to :c:func:`PyUnicode_EqualToUTF8AndSize`, but compute *string* " "length using :c:func:`!strlen`. If the Unicode object contains null " "characters, false (``0``) is returned." msgstr "" -#: ../../c-api/unicode.rst:1682 +#: ../../c-api/unicode.rst:1695 msgid "" "Compare a Unicode object, *unicode*, with *string* and return ``-1``, ``0``, " "``1`` for less than, equal, and greater than, respectively. It is best to " @@ -2042,47 +2066,47 @@ msgid "" "string as ISO-8859-1 if it contains non-ASCII characters." msgstr "" -#: ../../c-api/unicode.rst:1692 +#: ../../c-api/unicode.rst:1705 msgid "Rich compare two Unicode strings and return one of the following:" msgstr "" -#: ../../c-api/unicode.rst:1694 +#: ../../c-api/unicode.rst:1707 msgid "``NULL`` in case an exception was raised" msgstr "" -#: ../../c-api/unicode.rst:1695 +#: ../../c-api/unicode.rst:1708 msgid ":c:data:`Py_True` or :c:data:`Py_False` for successful comparisons" msgstr "" -#: ../../c-api/unicode.rst:1696 +#: ../../c-api/unicode.rst:1709 msgid ":c:data:`Py_NotImplemented` in case the type combination is unknown" msgstr "" -#: ../../c-api/unicode.rst:1698 +#: ../../c-api/unicode.rst:1711 msgid "" "Possible values for *op* are :c:macro:`Py_GT`, :c:macro:`Py_GE`, :c:macro:" "`Py_EQ`, :c:macro:`Py_NE`, :c:macro:`Py_LT`, and :c:macro:`Py_LE`." msgstr "" -#: ../../c-api/unicode.rst:1704 +#: ../../c-api/unicode.rst:1717 msgid "" "Return a new string object from *format* and *args*; this is analogous to " "``format % args``." msgstr "" -#: ../../c-api/unicode.rst:1710 +#: ../../c-api/unicode.rst:1723 msgid "" "Check whether *substr* is contained in *unicode* and return true or false " "accordingly." msgstr "" -#: ../../c-api/unicode.rst:1713 +#: ../../c-api/unicode.rst:1726 msgid "" "*substr* has to coerce to a one element Unicode string. ``-1`` is returned " "if there was an error." msgstr "" -#: ../../c-api/unicode.rst:1719 +#: ../../c-api/unicode.rst:1732 msgid "" "Intern the argument :c:expr:`*p_unicode` in place. The argument must be the " "address of a pointer variable pointing to a Python Unicode string object. " @@ -2093,7 +2117,7 @@ msgid "" "interns it." msgstr "" -#: ../../c-api/unicode.rst:1726 +#: ../../c-api/unicode.rst:1739 msgid "" "(Clarification: even though there is a lot of talk about references, think " "of this function as reference-neutral. You must own the object you pass in; " @@ -2101,39 +2125,39 @@ msgid "" "the result.)" msgstr "" -#: ../../c-api/unicode.rst:1731 +#: ../../c-api/unicode.rst:1744 msgid "" "This function never raises an exception. On error, it leaves its argument " "unchanged without interning it." msgstr "" -#: ../../c-api/unicode.rst:1734 +#: ../../c-api/unicode.rst:1747 msgid "" "Instances of subclasses of :py:class:`str` may not be interned, that is, :c:" "expr:`PyUnicode_CheckExact(*p_unicode)` must be true. If it is not, then -- " "as with any other error -- the argument is left unchanged." msgstr "" -#: ../../c-api/unicode.rst:1738 +#: ../../c-api/unicode.rst:1751 msgid "" "Note that interned strings are not “immortal”. You must keep a reference to " "the result to benefit from interning." msgstr "" -#: ../../c-api/unicode.rst:1744 +#: ../../c-api/unicode.rst:1757 msgid "" "A combination of :c:func:`PyUnicode_FromString` and :c:func:" "`PyUnicode_InternInPlace`, meant for statically allocated strings." msgstr "" -#: ../../c-api/unicode.rst:1747 +#: ../../c-api/unicode.rst:1760 msgid "" "Return a new (\"owned\") reference to either a new Unicode string object " "that has been interned, or an earlier interned string object with the same " "value." msgstr "" -#: ../../c-api/unicode.rst:1751 +#: ../../c-api/unicode.rst:1764 msgid "" "Python may keep a reference to the result, or make it :term:`immortal`, " "preventing it from being garbage-collected promptly. For interning an " @@ -2142,14 +2166,14 @@ msgid "" "`PyUnicode_InternInPlace` directly." msgstr "" -#: ../../c-api/unicode.rst:1760 +#: ../../c-api/unicode.rst:1773 msgid "" "Return a non-zero value if *str* is interned, zero if not. The *str* " "argument must be a string; this is not checked. This function always " "succeeds." msgstr "" -#: ../../c-api/unicode.rst:1766 +#: ../../c-api/unicode.rst:1779 msgid "" "A non-zero return value may carry additional information about *how* the " "string is interned. The meaning of such non-zero values, as well as each " @@ -2157,227 +2181,227 @@ msgid "" "versions." msgstr "" -#: ../../c-api/unicode.rst:1773 +#: ../../c-api/unicode.rst:1786 msgid "PyUnicodeWriter" msgstr "PyUnicodeWriter" -#: ../../c-api/unicode.rst:1775 +#: ../../c-api/unicode.rst:1788 msgid "" "The :c:type:`PyUnicodeWriter` API can be used to create a Python :class:" "`str` object." msgstr "" -#: ../../c-api/unicode.rst:1782 +#: ../../c-api/unicode.rst:1795 msgid "A Unicode writer instance." msgstr "一個 Unicode 寫入器實例。" -#: ../../c-api/unicode.rst:1784 +#: ../../c-api/unicode.rst:1797 msgid "" "The instance must be destroyed by :c:func:`PyUnicodeWriter_Finish` on " "success, or :c:func:`PyUnicodeWriter_Discard` on error." msgstr "" -#: ../../c-api/unicode.rst:1789 +#: ../../c-api/unicode.rst:1802 msgid "Create a Unicode writer instance." msgstr "" -#: ../../c-api/unicode.rst:1791 +#: ../../c-api/unicode.rst:1804 msgid "*length* must be greater than or equal to ``0``." msgstr "" -#: ../../c-api/unicode.rst:1793 +#: ../../c-api/unicode.rst:1806 msgid "" "If *length* is greater than ``0``, preallocate an internal buffer of " "*length* characters." msgstr "" -#: ../../c-api/unicode.rst:1796 ../../c-api/unicode.rst:1802 +#: ../../c-api/unicode.rst:1809 ../../c-api/unicode.rst:1815 msgid "Set an exception and return ``NULL`` on error." msgstr "發生錯誤時,設定例外並回傳 ``NULL``。" -#: ../../c-api/unicode.rst:1800 +#: ../../c-api/unicode.rst:1813 msgid "" "Return the final Python :class:`str` object and destroy the writer instance." msgstr "" -#: ../../c-api/unicode.rst:1804 ../../c-api/unicode.rst:1812 +#: ../../c-api/unicode.rst:1817 ../../c-api/unicode.rst:1825 msgid "The writer instance is invalid after this call." msgstr "" -#: ../../c-api/unicode.rst:1808 +#: ../../c-api/unicode.rst:1821 msgid "Discard the internal Unicode buffer and destroy the writer instance." msgstr "" -#: ../../c-api/unicode.rst:1810 +#: ../../c-api/unicode.rst:1823 msgid "If *writer* is ``NULL``, no operation is performed." msgstr "" -#: ../../c-api/unicode.rst:1816 +#: ../../c-api/unicode.rst:1829 msgid "Write the single Unicode character *ch* into *writer*." msgstr "" -#: ../../c-api/unicode.rst:1818 ../../c-api/unicode.rst:1828 -#: ../../c-api/unicode.rst:1843 ../../c-api/unicode.rst:1853 -#: ../../c-api/unicode.rst:1862 ../../c-api/unicode.rst:1869 -#: ../../c-api/unicode.rst:1882 ../../c-api/unicode.rst:1897 -#: ../../c-api/unicode.rst:1904 ../../c-api/unicode.rst:1923 +#: ../../c-api/unicode.rst:1831 ../../c-api/unicode.rst:1841 +#: ../../c-api/unicode.rst:1856 ../../c-api/unicode.rst:1866 +#: ../../c-api/unicode.rst:1875 ../../c-api/unicode.rst:1882 +#: ../../c-api/unicode.rst:1895 ../../c-api/unicode.rst:1910 +#: ../../c-api/unicode.rst:1917 ../../c-api/unicode.rst:1936 msgid "" "On success, return ``0``. On error, set an exception, leave the writer " "unchanged, and return ``-1``." msgstr "成功時回傳 ``0``,發生錯誤時設定例外、保持寫入器不變,並回傳 ``-1``。" -#: ../../c-api/unicode.rst:1823 +#: ../../c-api/unicode.rst:1836 msgid "" "Decode the string *str* from UTF-8 in strict mode and write the output into " "*writer*." msgstr "" -#: ../../c-api/unicode.rst:1825 ../../c-api/unicode.rst:1837 -#: ../../c-api/unicode.rst:1912 +#: ../../c-api/unicode.rst:1838 ../../c-api/unicode.rst:1850 +#: ../../c-api/unicode.rst:1925 msgid "" "*size* is the string length in bytes. If *size* is equal to ``-1``, call " "``strlen(str)`` to get the string length." msgstr "" -#: ../../c-api/unicode.rst:1831 +#: ../../c-api/unicode.rst:1844 msgid "See also :c:func:`PyUnicodeWriter_DecodeUTF8Stateful`." msgstr "另請參閱 :c:func:`PyUnicodeWriter_DecodeUTF8Stateful`。" -#: ../../c-api/unicode.rst:1835 +#: ../../c-api/unicode.rst:1848 msgid "Write the ASCII string *str* into *writer*." msgstr "" -#: ../../c-api/unicode.rst:1840 +#: ../../c-api/unicode.rst:1853 msgid "" "*str* must only contain ASCII characters. The behavior is undefined if *str* " "contains non-ASCII characters." msgstr "" -#: ../../c-api/unicode.rst:1848 +#: ../../c-api/unicode.rst:1861 msgid "Write the wide string *str* into *writer*." msgstr "" -#: ../../c-api/unicode.rst:1850 +#: ../../c-api/unicode.rst:1863 msgid "" "*size* is a number of wide characters. If *size* is equal to ``-1``, call " "``wcslen(str)`` to get the string length." msgstr "" -#: ../../c-api/unicode.rst:1858 +#: ../../c-api/unicode.rst:1871 msgid "Writer the UCS4 string *str* into *writer*." msgstr "" -#: ../../c-api/unicode.rst:1860 +#: ../../c-api/unicode.rst:1873 msgid "*size* is a number of UCS4 characters." msgstr "*size* 是 UCS4 字元的數量。" -#: ../../c-api/unicode.rst:1867 +#: ../../c-api/unicode.rst:1880 msgid "" "Call :c:func:`PyObject_Str` on *obj* and write the output into *writer*." msgstr "於 *obj* 上呼叫 :c:func:`PyObject_Str` 並將輸出寫入 *writer*。" -#: ../../c-api/unicode.rst:1872 +#: ../../c-api/unicode.rst:1885 msgid "" "To write a :class:`str` subclass which overrides the :meth:`~object.__str__` " "method, :c:func:`PyUnicode_FromObject` can be used to get the original " "string." msgstr "" -#: ../../c-api/unicode.rst:1878 +#: ../../c-api/unicode.rst:1891 msgid "" "Call :c:func:`PyObject_Repr` on *obj* and write the output into *writer*." msgstr "於 *obj* 上呼叫 :c:func:`PyObject_Repr` 並將輸出寫入 *writer*。" -#: ../../c-api/unicode.rst:1880 +#: ../../c-api/unicode.rst:1893 msgid "If *obj* is ``NULL``, write the string ``\"\"`` into *writer*." msgstr "" -#: ../../c-api/unicode.rst:1887 +#: ../../c-api/unicode.rst:1900 msgid "Added support for ``NULL``." msgstr "" -#: ../../c-api/unicode.rst:1891 +#: ../../c-api/unicode.rst:1904 msgid "Write the substring ``str[start:end]`` into *writer*." msgstr "" -#: ../../c-api/unicode.rst:1893 +#: ../../c-api/unicode.rst:1906 msgid "" "*str* must be Python :class:`str` object. *start* must be greater than or " "equal to 0, and less than or equal to *end*. *end* must be less than or " "equal to *str* length." msgstr "" -#: ../../c-api/unicode.rst:1902 +#: ../../c-api/unicode.rst:1915 msgid "" "Similar to :c:func:`PyUnicode_FromFormat`, but write the output directly " "into *writer*." msgstr "類似於 :c:func:`PyUnicode_FromFormat`,但是直接將輸出寫入 *writer*。" -#: ../../c-api/unicode.rst:1909 +#: ../../c-api/unicode.rst:1922 msgid "" "Decode the string *str* from UTF-8 with *errors* error handler and write the " "output into *writer*." msgstr "" -#: ../../c-api/unicode.rst:1915 +#: ../../c-api/unicode.rst:1928 msgid "" "*errors* is an :ref:`error handler ` name, such as " "``\"replace\"``. If *errors* is ``NULL``, use the strict error handler." msgstr "" -#: ../../c-api/unicode.rst:1918 +#: ../../c-api/unicode.rst:1931 msgid "" "If *consumed* is not ``NULL``, set *\\*consumed* to the number of decoded " "bytes on success. If *consumed* is ``NULL``, treat trailing incomplete UTF-8 " "byte sequences as an error." msgstr "" -#: ../../c-api/unicode.rst:1926 +#: ../../c-api/unicode.rst:1939 msgid "See also :c:func:`PyUnicodeWriter_WriteUTF8`." msgstr "另請參閱 :c:func:`PyUnicodeWriter_WriteUTF8`。" -#: ../../c-api/unicode.rst:1929 +#: ../../c-api/unicode.rst:1942 msgid "Deprecated API" msgstr "已棄用的 API" -#: ../../c-api/unicode.rst:1931 +#: ../../c-api/unicode.rst:1944 msgid "The following API is deprecated." msgstr "以下 API 已棄用。" -#: ../../c-api/unicode.rst:1935 +#: ../../c-api/unicode.rst:1948 msgid "" "This is a typedef of :c:type:`wchar_t`, which is a 16-bit type or 32-bit " "type depending on the platform. Please use :c:type:`wchar_t` directly " "instead." msgstr "" -#: ../../c-api/unicode.rst:1939 +#: ../../c-api/unicode.rst:1952 msgid "" "In previous versions, this was a 16-bit type or a 32-bit type depending on " "whether you selected a \"narrow\" or \"wide\" Unicode version of Python at " "build time." msgstr "" -#: ../../c-api/unicode.rst:1949 +#: ../../c-api/unicode.rst:1962 msgid "" "Do nothing and return ``0``. This API is kept only for backward " "compatibility, but there are no plans to remove it." msgstr "" -#: ../../c-api/unicode.rst:1955 +#: ../../c-api/unicode.rst:1968 msgid "" "This API does nothing since Python 3.12. Previously, this needed to be " "called for each string created using the old API (:c:func:`!" "PyUnicode_FromUnicode` or similar)." msgstr "" -#: ../../c-api/unicode.rst:1963 +#: ../../c-api/unicode.rst:1976 msgid "" "Do nothing and return ``1``. This API is kept only for backward " "compatibility, but there are no plans to remove it." msgstr "" -#: ../../c-api/unicode.rst:1969 +#: ../../c-api/unicode.rst:1982 msgid "" "This API does nothing since Python 3.12. Previously, this could be called to " "check if :c:func:`PyUnicode_READY` is necessary." diff --git a/c-api/weakref.po b/c-api/weakref.po index f20eee57aa5..8ae4259fdac 100644 --- a/c-api/weakref.po +++ b/c-api/weakref.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-11 00:43+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" "Last-Translator: Leon H.\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -105,51 +105,29 @@ msgstr "" #: ../../c-api/weakref.rst:84 msgid "" -"Return a :term:`borrowed reference` to the referenced object from a weak " -"reference, *ref*. If the referent is no longer live, returns ``Py_None``." -msgstr "" - -#: ../../c-api/weakref.rst:89 -msgid "" -"This function returns a :term:`borrowed reference` to the referenced object. " -"This means that you should always call :c:func:`Py_INCREF` on the object " -"except when it cannot be destroyed before the last usage of the borrowed " -"reference." -msgstr "" - -#: ../../c-api/weakref.rst:94 ../../c-api/weakref.rst:102 -msgid "Use :c:func:`PyWeakref_GetRef` instead." -msgstr "" - -#: ../../c-api/weakref.rst:100 -msgid "Similar to :c:func:`PyWeakref_GetObject`, but does no error checking." -msgstr "" - -#: ../../c-api/weakref.rst:108 -msgid "" "Test if the weak reference *ref* is dead. Returns 1 if the reference is " "dead, 0 if it is alive, and -1 with an error set if *ref* is not a weak " "reference object." msgstr "" -#: ../../c-api/weakref.rst:117 +#: ../../c-api/weakref.rst:93 msgid "" "This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler " "to clear weak references." msgstr "" -#: ../../c-api/weakref.rst:120 +#: ../../c-api/weakref.rst:96 msgid "" "This iterates through the weak references for *object* and calls callbacks " "for those references which have one. It returns when all callbacks have been " "attempted." msgstr "" -#: ../../c-api/weakref.rst:127 +#: ../../c-api/weakref.rst:103 msgid "Clears the weakrefs for *object* without calling the callbacks." msgstr "" -#: ../../c-api/weakref.rst:129 +#: ../../c-api/weakref.rst:105 msgid "" "This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler " "for types with finalizers (i.e., :meth:`~object.__del__`). The handler for " @@ -158,7 +136,7 @@ msgid "" "clear any weakrefs that may have been created by the finalizer." msgstr "" -#: ../../c-api/weakref.rst:135 +#: ../../c-api/weakref.rst:111 msgid "" "In most circumstances, it's more appropriate to use :c:func:" "`PyObject_ClearWeakRefs` to clear weakrefs instead of this function." diff --git a/deprecations/c-api-pending-removal-in-3.15.po b/deprecations/c-api-pending-removal-in-3.15.po index 34f2be4674d..c30c4ff10e9 100644 --- a/deprecations/c-api-pending-removal-in-3.15.po +++ b/deprecations/c-api-pending-removal-in-3.15.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,39 +21,31 @@ msgstr "Python 3.15 中待移除的項目" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 msgid "" -"The :c:func:`PyImport_ImportModuleNoBlock`: " -"Use :c:func:`PyImport_ImportModule` instead." +"The :c:func:`!PyImport_ImportModuleNoBlock`: Use :c:func:" +"`PyImport_ImportModule` instead." msgstr "" -":c:func:`PyImport_ImportModuleNoBlock`:請改" +":c:func:`!PyImport_ImportModuleNoBlock`:請改" "用 :c:func:`PyImport_ImportModule`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 msgid "" -":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: " -"Use :c:func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project " -"`__ can be used to " -"get :c:func:`PyWeakref_GetRef` on Python 3.12 and older." +":c:func:`!PyWeakref_GetObject` and :c:func:`!PyWeakref_GET_OBJECT`: Use :c:" +"func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project `__ can be used to get :c:func:" +"`PyWeakref_GetRef` on Python 3.12 and older." msgstr "" -":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改" +":c:func:`!PyWeakref_GetObject` 和 :c:func:`!PyWeakref_GET_OBJECT`:請改" "用 :c:func:`PyWeakref_GetRef`。可以使用 `pythoncapi-compat 專案 `__\\ 來為 Python 3.12 和更早版本取" "得 :c:func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 msgid "" -":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: " -"Use :c:type:`wchar_t` instead." -msgstr "" -":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改" -"用 :c:type:`wchar_t`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 -msgid "" ":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" ":c:func:`!PyUnicode_AsDecodedObject`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" ":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -63,13 +55,13 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`str` 的型別,例" "如 :class:`bytes`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 msgid "" ":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." msgstr "" ":c:func:`!PyUnicode_AsEncodedObject`:請改用 :c:func:`PyCodec_Encode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:19 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid "" ":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -79,70 +71,69 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`bytes` 的型別,例" "如 :class:`str`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 msgid "Python initialization functions, deprecated in Python 3.13:" msgstr "Python 初始化函式,自 Python 3.13 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 msgid "" -":c:func:`Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`) instead." msgstr "" -":c:func:`Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:27 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" -":c:func:`Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " -"` (:data:`sys.base_prefix`) instead. " -"Use :c:func:`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) " -"if :ref:`virtual environments ` need to be handled." +":c:func:`!Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " +"` (:data:`sys.base_prefix`) instead. Use :c:func:" +"`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) if :ref:" +"`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " +":c:func:`!Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`)。如果需要處理\\ :ref:`虛擬環境 " "`,請改用 :c:func:`PyConfig_Get(\"prefix\") ` " "(:data:`sys.prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:32 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:30 msgid "" -":c:func:`Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " -"` (:data:`sys.base_exec_prefix`) instead. " -"Use :c:func:`PyConfig_Get(\"exec_prefix\") ` " -"(:data:`sys.exec_prefix`) if :ref:`virtual environments ` need to " -"be handled." +":c:func:`!Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " +"` (:data:`sys.base_exec_prefix`) instead. Use :c:func:" +"`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) if :" +"ref:`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetExecPrefix`:請改" +":c:func:`!Py_GetExecPrefix`:請改" "用 :c:func:`PyConfig_Get(\"base_exec_prefix\") ` " "(:data:`sys.base_exec_prefix`)。如果需要處理\\ :ref:`虛擬環境 `,請" "改用 :c:func:`PyConfig_Get(\"exec_prefix\") ` " "(:data:`sys.exec_prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:38 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:36 msgid "" -":c:func:`Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramFullPath`:請改" +":c:func:`!Py_GetProgramFullPath`:請改" "用 :c:func:`PyConfig_Get(\"executable\") ` " "(:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:41 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:39 msgid "" -":c:func:`Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:44 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:42 msgid "" -":c:func:`Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " "` or the :envvar:`PYTHONHOME` environment variable instead." msgstr "" -":c:func:`Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " "` 或 :envvar:`PYTHONHOME` 環境變數。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:48 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:46 msgid "" "The `pythoncapi-compat project `__ can be used to get :c:func:`PyConfig_Get` on Python 3.13 and older." @@ -150,50 +141,50 @@ msgstr "" "`pythoncapi-compat 專案 `__ 可" "以用來為 Python 3.13 和更早版本取得 :c:func:`PyConfig_Get`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:50 msgid "" "Functions to configure Python's initialization, deprecated in Python 3.11:" msgstr "用於配置 Python 初始化的函式,自 Python 3.11 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgvEx()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgv()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 msgid "" ":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " "instead." msgstr "" ":c:func:`!Py_SetProgramName()`:請改用 :c:member:`PyConfig.program_name`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." msgstr ":c:func:`!Py_SetPythonHome()`:請改用 :c:member:`PyConfig.home`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:62 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 msgid "" -":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" +":c:func:`!PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" -":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` " +":c:func:`!PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` " "和 :data:`!warnings.filters`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:65 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:63 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used " "with :c:type:`PyConfig` instead." msgstr "" "應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:66 msgid "Global configuration variables:" msgstr "全域配置變數:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:70 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 msgid "" ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` " "or :c:func:`PyConfig_Get(\"parser_debug\") ` instead." @@ -201,7 +192,7 @@ msgstr "" ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug` " "或 :c:func:`PyConfig_Get(\"parser_debug\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:73 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:71 msgid "" ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` " "or :c:func:`PyConfig_Get(\"verbose\") ` instead." @@ -209,7 +200,7 @@ msgstr "" ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose` " "或 :c:func:`PyConfig_Get(\"verbose\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:76 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:74 msgid "" ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` " "or :c:func:`PyConfig_Get(\"quiet\") ` instead." @@ -217,7 +208,7 @@ msgstr "" ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet` " "或 :c:func:`PyConfig_Get(\"quiet\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:79 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:77 msgid "" ":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` " "or :c:func:`PyConfig_Get(\"interactive\") ` instead." @@ -225,7 +216,7 @@ msgstr "" ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive` " "或 :c:func:`PyConfig_Get(\"interactive\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:82 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:80 msgid "" ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` " "or :c:func:`PyConfig_Get(\"inspect\") ` instead." @@ -233,7 +224,7 @@ msgstr "" ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect` " "或 :c:func:`PyConfig_Get(\"inspect\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:85 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:83 msgid "" ":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` " "or :c:func:`PyConfig_Get(\"optimization_level\") ` instead." @@ -241,7 +232,7 @@ msgstr "" ":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level` " "或 :c:func:`PyConfig_Get(\"optimization_level\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:88 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:86 msgid "" ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` " "or :c:func:`PyConfig_Get(\"site_import\") ` instead." @@ -249,7 +240,7 @@ msgstr "" ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import` " "或 :c:func:`PyConfig_Get(\"site_import\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:91 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:89 msgid "" ":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` " "or :c:func:`PyConfig_Get(\"bytes_warning\") ` instead." @@ -257,7 +248,7 @@ msgstr "" ":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning` " "或 :c:func:`PyConfig_Get(\"bytes_warning\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:94 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:92 msgid "" ":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` " "or :c:func:`PyConfig_Get(\"pathconfig_warnings\") ` instead." @@ -265,7 +256,7 @@ msgstr "" ":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings` " "或 :c:func:`PyConfig_Get(\"pathconfig_warnings\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:97 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:95 msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "or :c:func:`PyConfig_Get(\"use_environment\") ` instead." @@ -274,7 +265,7 @@ msgstr "" "用 :c:member:`PyConfig.use_environment` " "或 :c:func:`PyConfig_Get(\"use_environment\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:100 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:98 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "or :c:func:`PyConfig_Get(\"write_bytecode\") ` instead." @@ -283,7 +274,7 @@ msgstr "" "用 :c:member:`PyConfig.write_bytecode` " "或 :c:func:`PyConfig_Get(\"write_bytecode\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:103 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:101 msgid "" ":c:var:`Py_NoUserSiteDirectory`: " "Use :c:member:`PyConfig.user_site_directory` " @@ -293,7 +284,7 @@ msgstr "" "用 :c:member:`PyConfig.user_site_directory` " "或 :c:func:`PyConfig_Get(\"user_site_directory\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:106 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:104 msgid "" ":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` " "or :c:func:`PyConfig_Get(\"buffered_stdio\") ` instead." @@ -301,7 +292,7 @@ msgstr "" ":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio` " "或 :c:func:`PyConfig_Get(\"buffered_stdio\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:109 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:107 msgid "" ":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed` or :c:func:`PyConfig_Get(\"hash_seed\") " @@ -311,7 +302,7 @@ msgstr "" "和 :c:member:`PyConfig.hash_seed` 或 :c:func:`PyConfig_Get(\"hash_seed\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:113 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:111 msgid "" ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` " "or :c:func:`PyConfig_Get(\"isolated\") ` instead." @@ -319,7 +310,7 @@ msgstr "" ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated` " "或 :c:func:`PyConfig_Get(\"isolated\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:116 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:114 msgid "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`: " "Use :c:member:`PyPreConfig.legacy_windows_fs_encoding` " @@ -330,7 +321,7 @@ msgstr "" "用 :c:member:`PyPreConfig.legacy_windows_fs_encoding` " "或 :c:func:`PyConfig_Get(\"legacy_windows_fs_encoding\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:119 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:117 msgid "" ":c:var:`Py_LegacyWindowsStdioFlag`: " "Use :c:member:`PyConfig.legacy_windows_stdio` " @@ -340,7 +331,7 @@ msgstr "" "用 :c:member:`PyConfig.legacy_windows_stdio` " "或 :c:func:`PyConfig_Get(\"legacy_windows_stdio\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:122 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:120 msgid "" ":c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!" "Py_HasFileSystemDefaultEncoding`: " @@ -352,7 +343,7 @@ msgstr "" "用 :c:member:`PyConfig.filesystem_encoding` " "或 :c:func:`PyConfig_Get(\"filesystem_encoding\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:125 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:123 msgid "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`: " "Use :c:member:`PyConfig.filesystem_errors` " @@ -362,7 +353,7 @@ msgstr "" "用 :c:member:`PyConfig.filesystem_errors` " "或 :c:func:`PyConfig_Get(\"filesystem_errors\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:128 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:126 msgid "" ":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` " "or :c:func:`PyConfig_Get(\"utf8_mode\") ` instead. " @@ -372,7 +363,7 @@ msgstr "" "或 :c:func:`PyConfig_Get(\"utf8_mode\") `。(請參" "閱 :c:func:`Py_PreInitialize`)" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:133 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:131 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used " "with :c:type:`PyConfig` to set these options. Or :c:func:`PyConfig_Get` can " @@ -380,3 +371,10 @@ msgid "" msgstr "" "應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API 來設定" "這些選項。或者也可以使用 :c:func:`PyConfig_Get` 在執行時取得這些選項。" + +#~ msgid "" +#~ ":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :" +#~ "c:type:`wchar_t` instead." +#~ msgstr "" +#~ ":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:" +#~ "type:`wchar_t`。" diff --git a/deprecations/c-api-pending-removal-in-3.19.po b/deprecations/c-api-pending-removal-in-3.19.po new file mode 100644 index 00000000000..0f9ddf22bd6 --- /dev/null +++ b/deprecations/c-api-pending-removal-in-3.19.po @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../deprecations/c-api-pending-removal-in-3.19.rst:2 +msgid "Pending removal in Python 3.19" +msgstr "Python 3.19 中待移除的項目" + +#: ../../deprecations/c-api-pending-removal-in-3.19.rst:4 +msgid ":pep:`456` embedders support for the string hashing scheme definition." +msgstr "" diff --git a/deprecations/c-api-pending-removal-in-3.20.po b/deprecations/c-api-pending-removal-in-3.20.po new file mode 100644 index 00000000000..439d82c964b --- /dev/null +++ b/deprecations/c-api-pending-removal-in-3.20.po @@ -0,0 +1,42 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../deprecations/c-api-pending-removal-in-3.20.rst:2 +msgid "Pending removal in Python 3.20" +msgstr "" + +#: ../../deprecations/c-api-pending-removal-in-3.20.rst:4 +msgid "" +":c:func:`!_PyObject_CallMethodId`, :c:func:`!_PyObject_GetAttrId` and :c:" +"func:`!_PyUnicode_FromId` are deprecated since 3.15 and will be removed in " +"3.20. Instead, use :c:func:`PyUnicode_InternFromString()` and cache the " +"result in the module state, then call :c:func:`PyObject_CallMethod` or :c:" +"func:`PyObject_GetAttr`. (Contributed by Victor Stinner in :gh:`141049`.)" +msgstr "" + +#: ../../deprecations/c-api-pending-removal-in-3.20.rst:11 +msgid "" +"The ``cval`` field in :c:type:`PyComplexObject` (:gh:`128813`). Use :c:func:" +"`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex` to convert a " +"Python complex number to/from the C :c:type:`Py_complex` representation." +msgstr "" + +#: ../../deprecations/c-api-pending-removal-in-3.20.rst:16 +msgid "Macros :c:macro:`!Py_MATH_PIl` and :c:macro:`!Py_MATH_El`." +msgstr "" diff --git a/deprecations/index.po b/deprecations/index.po index 56f11683a4b..8cb8cde05c3 100644 --- a/deprecations/index.po +++ b/deprecations/index.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -19,221 +19,15 @@ msgstr "" msgid "Deprecations" msgstr "已棄用項目" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:2 -#: ../../deprecations/pending-removal-in-3.15.rst:2 -msgid "Pending removal in Python 3.15" -msgstr "Python 3.15 中待移除的項目" +#: ../../deprecations/c-api-pending-removal-in-3.16.rst:2 +#: ../../deprecations/pending-removal-in-3.16.rst:2 +msgid "Pending removal in Python 3.16" +msgstr "Python 3.16 中待移除的項目" -#: ../../deprecations/pending-removal-in-3.15.rst:4 #: ../../deprecations/pending-removal-in-3.16.rst:4 msgid "The import system:" msgstr "引入系統 (import system):" -#: ../../deprecations/pending-removal-in-3.15.rst:6 -msgid "" -"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" -"`__spec__.cached ` is deprecated. In " -"Python 3.15, :attr:`!__cached__` will cease to be set or take into " -"consideration by the import system or standard library. (:gh:`97879`)" -msgstr "" -"在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " -"` 的做法已被棄用。在 Python 3.15 中," -"引入系統或標準函式庫將不再設定或考慮 :attr:`!__cached__`。(:gh:`97879`)" - -#: ../../deprecations/pending-removal-in-3.15.rst:11 -msgid "" -"Setting :attr:`~module.__package__` on a module while failing to set :attr:" -"`__spec__.parent ` is deprecated. In " -"Python 3.15, :attr:`!__package__` will cease to be set or take into " -"consideration by the import system or standard library. (:gh:`97879`)" -msgstr "" -"在模組上設定 :attr:`~module.__package__` 而沒有設定 :attr:`__spec__.parent " -"` 的做法已被棄用。在 Python 3.15 中," -"引入系統或標準函式庫將不再設定或考慮 :attr:`!__package__`。(:gh:`97879`)" - -#: ../../deprecations/pending-removal-in-3.15.rst:16 -#: ../../deprecations/pending-removal-in-3.19.rst:4 -msgid ":mod:`ctypes`:" -msgstr ":mod:`ctypes`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:18 -msgid "" -"The undocumented :func:`!ctypes.SetPointerType` function has been deprecated " -"since Python 3.13." -msgstr "" -"自 Python 3.13 起,未記錄的 :func:`!ctypes.SetPointerType` 函式已被棄用。" - -#: ../../deprecations/pending-removal-in-3.15.rst:21 -msgid ":mod:`http.server`:" -msgstr ":mod:`http.server`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:23 -msgid "" -"The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` has " -"been deprecated since Python 3.13. No direct replacement exists. *Anything* " -"is better than CGI to interface a web server with a request handler." -msgstr "" -"過時且很少使用的 :class:`~http.server.CGIHTTPRequestHandler` 自 Python 3.13 " -"起已被棄用。不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求" -"處理程序介接起來。" - -#: ../../deprecations/pending-removal-in-3.15.rst:29 -msgid "" -"The :option:`!--cgi` flag to the :program:`python -m http.server` command-" -"line interface has been deprecated since Python 3.13." -msgstr "" -"自 Python 3.13 起,:program:`python -m http.server` 命令列介面的 :option:`!--" -"cgi` 旗標已被棄用。" - -#: ../../deprecations/pending-removal-in-3.15.rst:32 -#: ../../deprecations/pending-removal-in-future.rst:62 -msgid ":mod:`importlib`:" -msgstr ":mod:`importlib`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:34 -msgid "``load_module()`` method: use ``exec_module()`` instead." -msgstr "``load_module()`` method:請改用 ``exec_module()``。" - -#: ../../deprecations/pending-removal-in-3.15.rst:36 -msgid ":mod:`pathlib`:" -msgstr ":mod:`pathlib`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:38 -msgid "" -":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" -"func:`os.path.isreserved` to detect reserved paths on Windows." -msgstr "" -":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os.path." -"isreserved` 來偵測 Windows 上的保留路徑。" - -#: ../../deprecations/pending-removal-in-3.15.rst:42 -msgid ":mod:`platform`:" -msgstr ":mod:`platform`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:44 -msgid "" -":func:`~platform.java_ver` has been deprecated since Python 3.13. This " -"function is only useful for Jython support, has a confusing API, and is " -"largely untested." -msgstr "" -"自 Python 3.13 起,:func:`~platform.java_ver` 已被棄用。此函式僅對 Jython 支" -"援有用,具有令人困惑的 API,基本上未經測試。" - -#: ../../deprecations/pending-removal-in-3.15.rst:48 -#: ../../deprecations/pending-removal-in-3.16.rst:96 -msgid ":mod:`sysconfig`:" -msgstr ":mod:`sysconfig`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:50 -msgid "" -"The *check_home* argument of :func:`sysconfig.is_python_build` has been " -"deprecated since Python 3.12." -msgstr "" -":func:`sysconfig.is_python_build` 的 *check_home* 引數自 Python 3.12 起已被棄" -"用。" - -#: ../../deprecations/pending-removal-in-3.15.rst:53 -msgid ":mod:`threading`:" -msgstr ":mod:`threading`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:55 -msgid "" -":func:`~threading.RLock` will take no arguments in Python 3.15. Passing any " -"arguments has been deprecated since Python 3.14, as the Python version does " -"not permit any arguments, but the C version allows any number of positional " -"or keyword arguments, ignoring every argument." -msgstr "" -":func:`~threading.RLock` 在 Python 3.15 中將不接受任何引數。自 Python 3.14 " -"起,傳遞任何引數的用法已被棄用,因為 Python 版本不允許任何引數,但 C 版本允許" -"任意數量的位置或關鍵字引數,並忽略每個引數。" - -#: ../../deprecations/pending-removal-in-3.15.rst:61 -msgid ":mod:`types`:" -msgstr ":mod:`types`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:63 -msgid "" -":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " -"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " -"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " -"in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" -msgstr "" -":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" -"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" -"exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" -"`101866` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.15.rst:70 -#: ../../deprecations/pending-removal-in-3.17.rst:26 -msgid ":mod:`typing`:" -msgstr ":mod:`typing`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:72 -msgid "" -"The undocumented keyword argument syntax for creating :class:`~typing." -"NamedTuple` classes (for example, ``Point = NamedTuple(\"Point\", x=int, " -"y=int)``) has been deprecated since Python 3.13. Use the class-based syntax " -"or the functional syntax instead." -msgstr "" -"用於建立 :class:`~typing.NamedTuple` 類別的未以文件記錄之關鍵字引數語法 " -"(``Point = NamedTuple(\"Point\", x=int, y=int)``) 已自 Python 3.13 棄用。請改" -"用基於類別的語法或函式語法 (functional syntax)。" - -#: ../../deprecations/pending-removal-in-3.15.rst:78 -msgid "" -"When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " -"to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " -"passing ``None`` (``TD = TypedDict(\"TD\", None)``) has been deprecated " -"since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " -"TypedDict(\"TD\", {})`` to create a TypedDict with zero field." -msgstr "" -"當使用 :class:`~typing.TypedDict` 的函式語法時,未傳遞值給 *fields* 參數 " -"(``TD = TypedDict(\"TD\")``) 或傳遞 ``None`` (``TD = TypedDict(\"TD\", " -"None)``) 的做法自 Python 3.13 起已被棄用。請使用 ``class TD(TypedDict): " -"pass`` 或 ``TD = TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" - -#: ../../deprecations/pending-removal-in-3.15.rst:85 -msgid "" -"The :deco:`typing.no_type_check_decorator` decorator function has been " -"deprecated since Python 3.13. After eight years in the :mod:`typing` module, " -"it has yet to be supported by any major type checker." -msgstr "" -"自 Python 3.13 起,:deco:`typing.no_type_check_decorator` 裝飾器函式已被棄" -"用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" -"援。" - -#: ../../deprecations/pending-removal-in-3.15.rst:90 -msgid ":mod:`wave`:" -msgstr ":mod:`wave`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:92 -msgid "" -"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." -"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" -"`~wave.Wave_write` classes have been deprecated since Python 3.13." -msgstr "" -"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" -"`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." -"getmarkers` 方法自 Python 3.13 被棄用。" - -#: ../../deprecations/pending-removal-in-3.15.rst:97 -msgid ":mod:`zipimport`:" -msgstr ":mod:`zipimport`:" - -#: ../../deprecations/pending-removal-in-3.15.rst:99 -msgid "" -":meth:`~zipimport.zipimporter.load_module` has been deprecated since Python " -"3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (Contributed " -"by Jiahao Li in :gh:`125746`.)" -msgstr "" -":meth:`~zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改用 :" -"meth:`~zipimport.zipimporter.exec_module`。(由 Jiahao Li 於 :gh:`125746` 貢" -"獻。)" - -#: ../../deprecations/pending-removal-in-3.16.rst:2 -msgid "Pending removal in Python 3.16" -msgstr "Python 3.16 中待移除的項目" - #: ../../deprecations/pending-removal-in-3.16.rst:6 msgid "" "Setting :attr:`~module.__loader__` on a module while failing to set :attr:" @@ -434,6 +228,10 @@ msgstr "" "自 Python 3.13 起,:func:`~sys._enablelegacywindowsfsencoding` 函式已被棄用。" "請改用 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` 環境變數。" +#: ../../deprecations/pending-removal-in-3.16.rst:96 +msgid ":mod:`sysconfig`:" +msgstr ":mod:`sysconfig`:" + #: ../../deprecations/pending-removal-in-3.16.rst:98 msgid "" "The :func:`!sysconfig.expand_makefile_vars` function has been deprecated " @@ -460,16 +258,28 @@ msgid "Pending removal in Python 3.17" msgstr "Python 3.17 中待移除的項目" #: ../../deprecations/pending-removal-in-3.17.rst:4 +#: ../../deprecations/pending-removal-in-future.rst:53 +msgid ":mod:`datetime`:" +msgstr ":mod:`datetime`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:6 +msgid "" +":meth:`~datetime.datetime.strptime` calls using a format string containing " +"``%e`` (day of month) without a year. This has been deprecated since Python " +"3.15. (Contributed by Stan Ulbrych in :gh:`70647`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:12 msgid ":mod:`collections.abc`:" msgstr ":mod:`collections.abc`:" -#: ../../deprecations/pending-removal-in-3.17.rst:6 +#: ../../deprecations/pending-removal-in-3.17.rst:14 msgid "" ":class:`collections.abc.ByteString` is scheduled for removal in Python 3.17." msgstr ":class:`collections.abc.ByteString` 預計在 Python 3.17 中移除。" -#: ../../deprecations/pending-removal-in-3.17.rst:8 -#: ../../deprecations/pending-removal-in-3.17.rst:36 +#: ../../deprecations/pending-removal-in-3.17.rst:16 +#: ../../deprecations/pending-removal-in-3.17.rst:62 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -482,8 +292,8 @@ msgstr "" "用 :class:`~collections.abc.Buffer` 或明確指定你的程式碼所支援型別的聯集(例" "如 ``bytes | bytearray | memoryview``)。" -#: ../../deprecations/pending-removal-in-3.17.rst:14 -#: ../../deprecations/pending-removal-in-3.17.rst:42 +#: ../../deprecations/pending-removal-in-3.17.rst:22 +#: ../../deprecations/pending-removal-in-3.17.rst:68 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -499,8 +309,8 @@ msgstr "" "其他常見的緩衝區型別如 :class:`memoryview` 也從未被理解為 :class:`!" "ByteString` 的子型別(無論是在 runtime 還是由靜態型別檢查器)。" -#: ../../deprecations/pending-removal-in-3.17.rst:22 -#: ../../deprecations/pending-removal-in-3.17.rst:50 +#: ../../deprecations/pending-removal-in-3.17.rst:30 +#: ../../deprecations/pending-removal-in-3.17.rst:76 msgid "" "See :pep:`PEP 688 <688#current-options>` for more details. (Contributed by " "Shantanu Jain in :gh:`91896`.)" @@ -508,7 +318,45 @@ msgstr "" "更多細節請見 :pep:`PEP 688 <688#current-options>`。(由 Shantanu Jain 於 :gh:" "`91896` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.17.rst:28 +#: ../../deprecations/pending-removal-in-3.17.rst:34 +msgid ":mod:`encodings`:" +msgstr ":mod:`encodings`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:36 +msgid "" +"Passing non-ascii *encoding* names to :func:`encodings.normalize_encoding` " +"is deprecated and scheduled for removal in Python 3.17. (Contributed by Stan " +"Ulbrych in :gh:`136702`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:40 +msgid ":mod:`profile`:" +msgstr ":mod:`profile`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:42 +msgid "" +"The :mod:`!profile` module is deprecated and will be removed in Python 3.17. " +"Use :mod:`profiling.tracing` instead, which provides a compatible API. See :" +"pep:`799` for details. (Contributed by Pablo Galindo and László Kiss Kollár " +"in :gh:`138122`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:47 +msgid ":mod:`webbrowser`:" +msgstr ":mod:`webbrowser`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:49 +msgid "" +":class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of :class:`!" +"webbrowser.MacOS`. (:gh:`137586`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:52 +#: ../../deprecations/pending-removal-in-3.20.rst:57 +msgid ":mod:`typing`:" +msgstr ":mod:`typing`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:54 msgid "" "Before Python 3.14, old-style unions were implemented using the private " "class ``typing._UnionGenericAlias``. This class is no longer needed for the " @@ -522,7 +370,7 @@ msgstr "" "除。使用者應該改用文件中記錄的內省輔助函式,例如 :func:`typing.get_origin` " "和 :func:`typing.get_args`,或者依賴私有實作細節。" -#: ../../deprecations/pending-removal-in-3.17.rst:33 +#: ../../deprecations/pending-removal-in-3.17.rst:59 msgid "" ":class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for " "removal in Python 3.17." @@ -530,16 +378,35 @@ msgstr "" ":class:`typing.ByteString` 自 Python 3.9 起已被棄用,預計在 Python 3.17 中移" "除。" +#: ../../deprecations/pending-removal-in-3.17.rst:79 +msgid ":mod:`tkinter`:" +msgstr ":mod:`tkinter`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:81 +msgid "" +"The :class:`!tkinter.Variable` methods :meth:`!trace_variable`, :meth:`!" +"trace` (an alias of :meth:`!trace_variable`), :meth:`!trace_vdelete` and :" +"meth:`!trace_vinfo`, deprecated since Python 3.14, are scheduled for removal " +"in Python 3.17. Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!" +"trace_info` instead. (Contributed by Serhiy Storchaka in :gh:`120220`.)" +msgstr "" + #: ../../deprecations/c-api-pending-removal-in-3.18.rst:2 #: ../../deprecations/pending-removal-in-3.18.rst:2 msgid "Pending removal in Python 3.18" msgstr "Python 3.18 中待移除的項目" #: ../../deprecations/pending-removal-in-3.18.rst:4 +msgid "" +"No longer accept a boolean value when a file descriptor is expected. " +"(Contributed by Serhiy Storchaka in :gh:`82626`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:7 msgid ":mod:`decimal`:" msgstr ":mod:`decimal`:" -#: ../../deprecations/pending-removal-in-3.18.rst:6 +#: ../../deprecations/pending-removal-in-3.18.rst:9 msgid "" "The non-standard and undocumented :class:`~decimal.Decimal` format specifier " "``'N'``, which is only supported in the :mod:`!decimal` module's C " @@ -550,10 +417,29 @@ msgstr "" "mod:`!decimal` 模組的 C 實作中被支援,自 Python 3.13 起已被棄用。(由 Serhiy " "Storchaka 於 :gh:`89902` 中貢獻。)" +#: ../../deprecations/pending-removal-in-3.18.rst:14 +#: ../../deprecations/pending-removal-in-3.20.rst:42 +msgid "Deprecations defined by :pep:`829`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:16 +msgid "``import`` lines in :file:`{name}.pth` files are silently ignored." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:18 +#: ../../deprecations/pending-removal-in-3.20.rst:50 +msgid "(Contributed by Barry Warsaw in :gh:`148641`.)" +msgstr "(由 Barry Warsaw 於 :gh:`148641` 貢獻。)" + +#: ../../deprecations/c-api-pending-removal-in-3.19.rst:2 #: ../../deprecations/pending-removal-in-3.19.rst:2 msgid "Pending removal in Python 3.19" msgstr "Python 3.19 中待移除的項目" +#: ../../deprecations/pending-removal-in-3.19.rst:4 +msgid ":mod:`ctypes`:" +msgstr ":mod:`ctypes`:" + #: ../../deprecations/pending-removal-in-3.19.rst:6 msgid "" "Implicitly switching to the MSVC-compatible struct layout by setting :attr:" @@ -563,6 +449,226 @@ msgstr "" "在非 Windows 平台上,透過設定 :attr:`~ctypes.Structure._pack_` 而沒有設定 :" "attr:`~ctypes.Structure._layout_` 來隱式地切換到與 MSVC 相容的結構佈局。" +#: ../../deprecations/pending-removal-in-3.19.rst:10 +msgid ":mod:`hashlib`:" +msgstr ":mod:`hashlib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:12 +msgid "" +"In hash function constructors such as :func:`~hashlib.new` or the direct " +"hash-named constructors such as :func:`~hashlib.md5` and :func:`~hashlib." +"sha256`, their optional initial data parameter could also be passed a " +"keyword argument named ``data=`` or ``string=`` in various :mod:`!hashlib` " +"implementations." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:18 +msgid "" +"Support for the ``string`` keyword argument name is now deprecated and " +"slated for removal in Python 3.19." +msgstr "" +"對 ``string`` 關鍵字引數名稱的支援現已被棄用,並計劃在 Python 3.19 中移除。" + +#: ../../deprecations/pending-removal-in-3.19.rst:21 +msgid "" +"Before Python 3.13, the ``string`` keyword parameter was not correctly " +"supported depending on the backend implementation of hash functions. Prefer " +"passing the initial data as a positional argument for maximum backwards " +"compatibility." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:26 +msgid ":mod:`http.cookies`:" +msgstr ":mod:`http.cookies`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:28 +msgid "" +":meth:`http.cookies.Morsel.js_output` is deprecated and will be removed in " +"Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:31 +msgid "" +":meth:`http.cookies.BaseCookie.js_output` is deprecated and will be removed " +"in Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:34 +msgid ":mod:`imaplib`:" +msgstr ":mod:`imaplib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:36 +msgid "" +"Altering :attr:`IMAP4.file ` is now deprecated and " +"slated for removal in Python 3.19. This property is now unused and changing " +"its value does not automatically close the current file." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:40 +msgid "" +"Before Python 3.14, this property was used to implement the corresponding " +"``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this " +"is no longer the case since then." +msgstr "" + +#: ../../deprecations/c-api-pending-removal-in-3.20.rst:2 +#: ../../deprecations/pending-removal-in-3.20.rst:2 +msgid "Pending removal in Python 3.20" +msgstr "Python 3.20 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.20.rst:4 +msgid "" +"Calling the ``__new__()`` method of :class:`struct.Struct` without the " +"*format* argument is deprecated and will be removed in Python 3.20. " +"Calling :meth:`~object.__init__` method on initialized :class:`~struct." +"Struct` objects is deprecated and will be removed in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:9 +msgid "" +"(Contributed by Sergey B Kirpichev and Serhiy Storchaka in :gh:`143715`.)" +msgstr "(由 Sergey B Kirpichev 和 Serhiy Storchaka 於 :gh:`143715` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.20.rst:11 +msgid "" +"The ``__version__``, ``version`` and ``VERSION`` attributes have been " +"deprecated in these standard library modules and will be removed in Python " +"3.20. Use :py:data:`sys.version_info` instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:15 +msgid ":mod:`argparse`" +msgstr ":mod:`argparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:16 +msgid ":mod:`csv`" +msgstr ":mod:`csv`" + +#: ../../deprecations/pending-removal-in-3.20.rst:17 +msgid ":mod:`ctypes`" +msgstr ":mod:`ctypes`" + +#: ../../deprecations/pending-removal-in-3.20.rst:18 +msgid ":mod:`!ctypes.macholib`" +msgstr ":mod:`!ctypes.macholib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:19 +msgid ":mod:`decimal` (use :data:`decimal.SPEC_VERSION` instead)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:20 +msgid ":mod:`http.server`" +msgstr ":mod:`http.server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:21 +msgid ":mod:`imaplib`" +msgstr ":mod:`imaplib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:22 +msgid ":mod:`ipaddress`" +msgstr ":mod:`ipaddress`" + +#: ../../deprecations/pending-removal-in-3.20.rst:23 +msgid ":mod:`json`" +msgstr ":mod:`json`" + +#: ../../deprecations/pending-removal-in-3.20.rst:24 +msgid ":mod:`logging` (``__date__`` also deprecated)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:25 +msgid ":mod:`optparse`" +msgstr ":mod:`optparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:26 +msgid ":mod:`pickle`" +msgstr ":mod:`pickle`" + +#: ../../deprecations/pending-removal-in-3.20.rst:27 +msgid ":mod:`platform`" +msgstr ":mod:`platform`" + +#: ../../deprecations/pending-removal-in-3.20.rst:28 +msgid ":mod:`re`" +msgstr ":mod:`re`" + +#: ../../deprecations/pending-removal-in-3.20.rst:29 +msgid ":mod:`socketserver`" +msgstr ":mod:`socketserver`" + +#: ../../deprecations/pending-removal-in-3.20.rst:30 +msgid ":mod:`tabnanny`" +msgstr ":mod:`tabnanny`" + +#: ../../deprecations/pending-removal-in-3.20.rst:31 +msgid ":mod:`tarfile`" +msgstr ":mod:`tarfile`" + +#: ../../deprecations/pending-removal-in-3.20.rst:32 +msgid ":mod:`tkinter.font`" +msgstr ":mod:`tkinter.font`" + +#: ../../deprecations/pending-removal-in-3.20.rst:33 +msgid ":mod:`tkinter.ttk`" +msgstr ":mod:`tkinter.ttk`" + +#: ../../deprecations/pending-removal-in-3.20.rst:34 +msgid ":mod:`wsgiref.simple_server`" +msgstr ":mod:`wsgiref.simple_server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:35 +msgid ":mod:`xml.etree.ElementTree`" +msgstr ":mod:`xml.etree.ElementTree`" + +#: ../../deprecations/pending-removal-in-3.20.rst:36 +msgid ":mod:`!xml.sax.expatreader`" +msgstr ":mod:`!xml.sax.expatreader`" + +#: ../../deprecations/pending-removal-in-3.20.rst:37 +msgid ":mod:`xml.sax.handler`" +msgstr ":mod:`xml.sax.handler`" + +#: ../../deprecations/pending-removal-in-3.20.rst:38 +msgid ":mod:`zlib`" +msgstr ":mod:`zlib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:40 +msgid "(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)" +msgstr "(由 Hugo van Kemenade 和 Stan Ulbrych 於 :gh:`76007` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.20.rst:44 +msgid "" +"Warnings are produced for ``import`` lines found in :file:`{name}.pth` files." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:47 +msgid "" +":file:`{name}.pth` files are no longer decoded in the locale encoding by " +"default. They **MUST** be encoded in ``utf-8-sig``." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:52 +msgid ":mod:`ast`:" +msgstr ":mod:`ast`:" + +#: ../../deprecations/pending-removal-in-3.20.rst:54 +msgid "" +"Creating instances of abstract AST nodes (such as :class:`ast.AST` or :class:" +"`!ast.expr`) is deprecated and will raise an error in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:59 +msgid "" +"It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on " +"protocol classes that were not explicitly decorated with :func:`!" +"runtime_checkable` but that inherit from a runtime-checkable protocol class. " +"This will raise a :exc:`TypeError` in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:64 +msgid "(Contributed by Bartosz Sławecki in :gh:`132604`.)" +msgstr "(由 Bartosz Sławecki 於 :gh:`132604` 貢獻。)" + #: ../../deprecations/c-api-pending-removal-in-future.rst:2 #: ../../deprecations/pending-removal-in-future.rst:2 msgid "Pending removal in future versions" @@ -678,14 +784,10 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:50 msgid "" -":attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " +":attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " "instead." msgstr "" -":attr:`codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" - -#: ../../deprecations/pending-removal-in-future.rst:53 -msgid ":mod:`datetime`:" -msgstr ":mod:`datetime`:" +":attr:`!codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" #: ../../deprecations/pending-removal-in-future.rst:55 msgid "" @@ -707,6 +809,10 @@ msgstr "" msgid ":mod:`gettext`: Plural value must be an integer." msgstr ":mod:`gettext`:複數值必須是整數。" +#: ../../deprecations/pending-removal-in-future.rst:62 +msgid ":mod:`importlib`:" +msgstr ":mod:`importlib`:" + #: ../../deprecations/pending-removal-in-future.rst:64 msgid "" ":func:`~importlib.util.cache_from_source` *debug_override* parameter is " @@ -744,18 +850,28 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:78 msgid "" -":mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process." +":mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process." msgstr ":mod:`os`:在多執行緒行程中呼叫 :func:`os.register_at_fork`。" #: ../../deprecations/pending-removal-in-future.rst:80 msgid "" +":mod:`os.path`: :func:`os.path.commonprefix` is deprecated, use :func:`os." +"path.commonpath` for path prefixes. The :func:`os.path.commonprefix` " +"function is being deprecated due to having a misleading name and module. The " +"function is not safe to use for path prefixes despite being included in a " +"module about path manipulation, meaning it is easy to accidentally introduce " +"path traversal vulnerabilities into Python programs by using this function." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:88 +msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." msgstr "" ":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" "實例。" -#: ../../deprecations/pending-removal-in-future.rst:83 +#: ../../deprecations/pending-removal-in-future.rst:91 msgid "" ":mod:`re`: More strict rules are now applied for numerical group references " "and group names in regular expressions. Only sequence of ASCII digits is " @@ -767,12 +883,7 @@ msgstr "" "有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" "包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:90 -msgid "" -":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." -msgstr ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" - -#: ../../deprecations/pending-removal-in-future.rst:92 +#: ../../deprecations/pending-removal-in-future.rst:98 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." @@ -780,15 +891,15 @@ msgstr "" ":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" "棄用;請改用 *onexc* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:95 +#: ../../deprecations/pending-removal-in-future.rst:101 msgid ":mod:`ssl` options and protocols:" msgstr ":mod:`ssl` 選項和協定:" -#: ../../deprecations/pending-removal-in-future.rst:97 +#: ../../deprecations/pending-removal-in-future.rst:103 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:98 +#: ../../deprecations/pending-removal-in-future.rst:104 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." @@ -796,51 +907,51 @@ msgstr "" ":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" "`!selected_npn_protocol` 已被棄用:請改用 ALPN。" -#: ../../deprecations/pending-removal-in-future.rst:101 +#: ../../deprecations/pending-removal-in-future.rst:107 msgid "``ssl.OP_NO_SSL*`` options" msgstr "``ssl.OP_NO_SSL*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:102 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "``ssl.OP_NO_TLS*`` options" msgstr "``ssl.OP_NO_TLS*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:103 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid "``ssl.PROTOCOL_SSLv3``" msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:104 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "``ssl.PROTOCOL_TLS``" msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:105 +#: ../../deprecations/pending-removal-in-future.rst:111 msgid "``ssl.PROTOCOL_TLSv1``" msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:106 +#: ../../deprecations/pending-removal-in-future.rst:112 msgid "``ssl.PROTOCOL_TLSv1_1``" msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:107 +#: ../../deprecations/pending-removal-in-future.rst:113 msgid "``ssl.PROTOCOL_TLSv1_2``" msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:108 +#: ../../deprecations/pending-removal-in-future.rst:114 msgid "``ssl.TLSVersion.SSLv3``" msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:109 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid "``ssl.TLSVersion.TLSv1``" msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:110 +#: ../../deprecations/pending-removal-in-future.rst:116 msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:118 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:114 +#: ../../deprecations/pending-removal-in-future.rst:120 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -848,11 +959,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:121 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" -#: ../../deprecations/pending-removal-in-future.rst:116 +#: ../../deprecations/pending-removal-in-future.rst:122 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -860,7 +971,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:118 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -868,20 +979,20 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:120 +#: ../../deprecations/pending-removal-in-future.rst:126 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:121 +#: ../../deprecations/pending-removal-in-future.rst:127 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:123 +#: ../../deprecations/pending-removal-in-future.rst:129 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:131 msgid "" "The internal class ``typing._UnionGenericAlias`` is no longer used to " "implement :class:`typing.Union`. To preserve compatibility with users using " @@ -892,7 +1003,7 @@ msgstr "" "了保持與此私有類別使用者的相容性,直到至少 Python 3.17 都將提供一個相容性 " "shim。(由 Jelle Zijlstra 於 :gh:`105499` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:130 +#: ../../deprecations/pending-removal-in-future.rst:136 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -900,64 +1011,64 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:139 msgid "" ":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " "instead" msgstr "" ":mod:`urllib.parse` 已棄用函式:請改用 :func:`~urllib.parse.urlparse`。" -#: ../../deprecations/pending-removal-in-future.rst:135 +#: ../../deprecations/pending-removal-in-future.rst:141 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:136 +#: ../../deprecations/pending-removal-in-future.rst:142 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:137 +#: ../../deprecations/pending-removal-in-future.rst:143 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:138 +#: ../../deprecations/pending-removal-in-future.rst:144 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:139 +#: ../../deprecations/pending-removal-in-future.rst:145 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:140 +#: ../../deprecations/pending-removal-in-future.rst:146 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:141 +#: ../../deprecations/pending-removal-in-future.rst:147 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:142 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:143 +#: ../../deprecations/pending-removal-in-future.rst:149 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:144 +#: ../../deprecations/pending-removal-in-future.rst:150 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:145 +#: ../../deprecations/pending-removal-in-future.rst:151 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:147 +#: ../../deprecations/pending-removal-in-future.rst:153 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:150 +#: ../../deprecations/pending-removal-in-future.rst:156 msgid "" ":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." "etree.ElementTree.Element` is deprecated. In a future release it will always " @@ -968,7 +1079,7 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:155 +#: ../../deprecations/pending-removal-in-future.rst:161 msgid "" ":func:`sys._clear_type_cache` is deprecated: use :func:`sys." "_clear_internal_caches` instead." @@ -976,45 +1087,81 @@ msgstr "" ":func:`sys._clear_type_cache` 已被棄用:請改用 :func:`sys." "_clear_internal_caches`。" -#: ../../deprecations/index.rst:17 +#: ../../deprecations/soft-deprecations.rst:2 +msgid "Soft deprecations" +msgstr "軟性棄用" + +#: ../../deprecations/soft-deprecations.rst:4 +msgid "There are no plans to remove :term:`soft deprecated` APIs." +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:6 +msgid "" +":func:`re.match` and :meth:`re.Pattern.match` are now :term:`soft " +"deprecated` in favor of the new :func:`re.prefixmatch` and :meth:`re.Pattern." +"prefixmatch` APIs, which have been added as alternate, more explicit names. " +"These are intended to be used to alleviate confusion around what *match* " +"means by following the Zen of Python's *\"Explicit is better than " +"implicit\"* mantra. Most other language regular expression libraries use an " +"API named *match* to mean what Python has always called *search*." +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:15 +msgid "" +"We **do not** plan to remove the older :func:`!match` name, as it has been " +"used in code for over 30 years. Code supporting older versions of Python " +"should continue to use :func:`!match`, while new code should prefer :func:`!" +"prefixmatch`. See :ref:`prefixmatch-vs-match`." +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:20 +msgid "" +"(Contributed by Gregory P. Smith in :gh:`86519` and Hugo van Kemenade in :gh:" +"`148100`.)" +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:23 +msgid "" +"Using ``'F'`` and ``'D'`` format type codes of the :mod:`struct` module now " +"are :term:`soft deprecated` in favor of two-letter forms ``'Zf'`` and " +"``'Zd'``. (Contributed by Sergey B Kirpichev in :gh:`121249`.)" +msgstr "" + +#: ../../deprecations/index.rst:19 msgid "C API deprecations" msgstr "C API 的棄用項目" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:2 +msgid "Pending removal in Python 3.15" +msgstr "Python 3.15 中待移除的項目" + #: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 msgid "" -"The :c:func:`PyImport_ImportModuleNoBlock`: Use :c:func:" +"The :c:func:`!PyImport_ImportModuleNoBlock`: Use :c:func:" "`PyImport_ImportModule` instead." msgstr "" -":c:func:`PyImport_ImportModuleNoBlock`:請改用 :c:func:" -"`PyImport_ImportModule`。" +":c:func:`!PyImport_ImportModuleNoBlock`:請改" +"用 :c:func:`PyImport_ImportModule`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 msgid "" -":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" +":c:func:`!PyWeakref_GetObject` and :c:func:`!PyWeakref_GET_OBJECT`: Use :c:" "func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project `__ can be used to get :c:func:" "`PyWeakref_GetRef` on Python 3.12 and older." msgstr "" -":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改用 :c:" -"func:`PyWeakref_GetRef`。可以使用 `pythoncapi-compat 專案 `__\\ 來為 Python 3.12 和更早版本取得 :c:func:" -"`PyWeakref_GetRef`。" +":c:func:`!PyWeakref_GetObject` 和 :c:func:`!PyWeakref_GET_OBJECT`:請改" +"用 :c:func:`PyWeakref_GetRef`。可以使用 `pythoncapi-compat 專案 `__\\ 來為 Python 3.12 和更早版本取" +"得 :c:func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 msgid "" -":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" -"type:`wchar_t` instead." -msgstr "" -":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:type:" -"`wchar_t`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 -msgid "" ":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" ":c:func:`!PyUnicode_AsDecodedObject`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" ":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -1024,13 +1171,13 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`str` 的型別,例如 :" "class:`bytes`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 msgid "" ":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." msgstr "" ":c:func:`!PyUnicode_AsEncodedObject`:請改用 :c:func:`PyCodec_Encode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:19 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid "" ":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -1040,68 +1187,69 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`bytes` 的型別,例如 :" "class:`str`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 msgid "Python initialization functions, deprecated in Python 3.13:" msgstr "Python 初始化函式,自 Python 3.13 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 msgid "" -":c:func:`Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`) instead." msgstr "" -":c:func:`Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:27 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" -":c:func:`Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " +":c:func:`!Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) if :ref:" "`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " +":c:func:`!Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`)。如果需要處理\\ :ref:`虛擬環境 " -"`,請改用 :c:func:`PyConfig_Get(\"prefix\") ` (:data:" -"`sys.prefix`)。" +"`,請改用 :c:func:`PyConfig_Get(\"prefix\") ` " +"(:data:`sys.prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:32 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:30 msgid "" -":c:func:`Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " +":c:func:`!Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " "` (:data:`sys.base_exec_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) if :" "ref:`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetExecPrefix`:請改用 :c:func:" -"`PyConfig_Get(\"base_exec_prefix\") ` (:data:`sys." -"base_exec_prefix`)。如果需要處理\\ :ref:`虛擬環境 `,請改用 :c:" -"func:`PyConfig_Get(\"exec_prefix\") ` (:data:`sys." -"exec_prefix`)。" +":c:func:`!Py_GetExecPrefix`:請改" +"用 :c:func:`PyConfig_Get(\"base_exec_prefix\") ` " +"(:data:`sys.base_exec_prefix`)。如果需要處理\\ :ref:`虛擬環境 `,請" +"改用 :c:func:`PyConfig_Get(\"exec_prefix\") ` " +"(:data:`sys.exec_prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:38 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:36 msgid "" -":c:func:`Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramFullPath`:請改用 :c:func:" -"`PyConfig_Get(\"executable\") ` (:data:`sys.executable`)。" +":c:func:`!Py_GetProgramFullPath`:請改" +"用 :c:func:`PyConfig_Get(\"executable\") ` " +"(:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:41 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:39 msgid "" -":c:func:`Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:44 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:42 msgid "" -":c:func:`Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " "` or the :envvar:`PYTHONHOME` environment variable instead." msgstr "" -":c:func:`Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " "` 或 :envvar:`PYTHONHOME` 環境變數。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:48 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:46 msgid "" "The `pythoncapi-compat project `__ can be used to get :c:func:`PyConfig_Get` on Python 3.13 and older." @@ -1109,50 +1257,50 @@ msgstr "" "`pythoncapi-compat 專案 `__ 可" "以用來為 Python 3.13 和更早版本取得 :c:func:`PyConfig_Get`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:50 msgid "" "Functions to configure Python's initialization, deprecated in Python 3.11:" msgstr "用於配置 Python 初始化的函式,自 Python 3.11 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgvEx()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgv()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 msgid "" ":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " "instead." msgstr "" ":c:func:`!Py_SetProgramName()`:請改用 :c:member:`PyConfig.program_name`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." msgstr ":c:func:`!Py_SetPythonHome()`:請改用 :c:member:`PyConfig.home`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:62 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 msgid "" -":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" +":c:func:`!PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" -":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" -"data:`!warnings.filters`。" +":c:func:`!PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` " +"和 :data:`!warnings.filters`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:65 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:63 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` instead." msgstr "" "應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:66 msgid "Global configuration variables:" msgstr "全域配置變數:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:70 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 msgid "" ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` or :c:func:" "`PyConfig_Get(\"parser_debug\") ` instead." @@ -1160,7 +1308,7 @@ msgstr "" ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug` 或 :c:func:" "`PyConfig_Get(\"parser_debug\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:73 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:71 msgid "" ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` or :c:func:" "`PyConfig_Get(\"verbose\") ` instead." @@ -1168,7 +1316,7 @@ msgstr "" ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose` 或 :c:func:" "`PyConfig_Get(\"verbose\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:76 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:74 msgid "" ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` or :c:func:" "`PyConfig_Get(\"quiet\") ` instead." @@ -1176,7 +1324,7 @@ msgstr "" ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet` 或 :c:func:" "`PyConfig_Get(\"quiet\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:79 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:77 msgid "" ":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` or :c:func:" "`PyConfig_Get(\"interactive\") ` instead." @@ -1184,7 +1332,7 @@ msgstr "" ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive` 或 :c:" "func:`PyConfig_Get(\"interactive\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:82 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:80 msgid "" ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` or :c:func:" "`PyConfig_Get(\"inspect\") ` instead." @@ -1192,7 +1340,7 @@ msgstr "" ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect` 或 :c:func:" "`PyConfig_Get(\"inspect\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:85 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:83 msgid "" ":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` or :c:" "func:`PyConfig_Get(\"optimization_level\") ` instead." @@ -1200,7 +1348,7 @@ msgstr "" ":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level` 或 :" "c:func:`PyConfig_Get(\"optimization_level\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:88 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:86 msgid "" ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` or :c:func:" "`PyConfig_Get(\"site_import\") ` instead." @@ -1208,7 +1356,7 @@ msgstr "" ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import` 或 :c:func:" "`PyConfig_Get(\"site_import\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:91 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:89 msgid "" ":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` or :c:" "func:`PyConfig_Get(\"bytes_warning\") ` instead." @@ -1216,7 +1364,7 @@ msgstr "" ":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning` 或 :" "c:func:`PyConfig_Get(\"bytes_warning\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:94 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:92 msgid "" ":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` or :c:" "func:`PyConfig_Get(\"pathconfig_warnings\") ` instead." @@ -1224,7 +1372,7 @@ msgstr "" ":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings` 或 :" "c:func:`PyConfig_Get(\"pathconfig_warnings\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:97 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:95 msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "or :c:func:`PyConfig_Get(\"use_environment\") ` instead." @@ -1233,7 +1381,7 @@ msgstr "" "use_environment` 或 :c:func:`PyConfig_Get(\"use_environment\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:100 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:98 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "or :c:func:`PyConfig_Get(\"write_bytecode\") ` instead." @@ -1242,7 +1390,7 @@ msgstr "" "write_bytecode` 或 :c:func:`PyConfig_Get(\"write_bytecode\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:103 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:101 msgid "" ":c:var:`Py_NoUserSiteDirectory`: Use :c:member:`PyConfig." "user_site_directory` or :c:func:`PyConfig_Get(\"user_site_directory\") " @@ -1252,7 +1400,7 @@ msgstr "" "user_site_directory` 或 :c:func:`PyConfig_Get(\"user_site_directory\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:106 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:104 msgid "" ":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` or :" "c:func:`PyConfig_Get(\"buffered_stdio\") ` instead." @@ -1260,7 +1408,7 @@ msgstr "" ":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio` " "或 :c:func:`PyConfig_Get(\"buffered_stdio\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:109 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:107 msgid "" ":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed` or :c:func:`PyConfig_Get(\"hash_seed\") " @@ -1270,7 +1418,7 @@ msgstr "" "和 :c:member:`PyConfig.hash_seed` 或 :c:func:`PyConfig_Get(\"hash_seed\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:113 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:111 msgid "" ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` or :c:func:" "`PyConfig_Get(\"isolated\") ` instead." @@ -1278,7 +1426,7 @@ msgstr "" ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated` 或 :c:func:" "`PyConfig_Get(\"isolated\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:116 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:114 msgid "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`: Use :c:member:`PyPreConfig." "legacy_windows_fs_encoding` or :c:func:" @@ -1288,7 +1436,7 @@ msgstr "" "legacy_windows_fs_encoding` 或 :c:func:" "`PyConfig_Get(\"legacy_windows_fs_encoding\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:119 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:117 msgid "" ":c:var:`Py_LegacyWindowsStdioFlag`: Use :c:member:`PyConfig." "legacy_windows_stdio` or :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " @@ -1298,7 +1446,7 @@ msgstr "" "legacy_windows_stdio` 或 :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:122 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:120 msgid "" ":c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!" "Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." @@ -1310,7 +1458,7 @@ msgstr "" "filesystem_encoding` 或 :c:func:`PyConfig_Get(\"filesystem_encoding\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:125 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:123 msgid "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." "filesystem_errors` or :c:func:`PyConfig_Get(\"filesystem_errors\") " @@ -1320,7 +1468,7 @@ msgstr "" "filesystem_errors` 或 :c:func:`PyConfig_Get(\"filesystem_errors\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:128 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:126 msgid "" ":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` or :c:func:" "`PyConfig_Get(\"utf8_mode\") ` instead. (see :c:func:" @@ -1330,7 +1478,7 @@ msgstr "" "`PyConfig_Get(\"utf8_mode\") `。(請參閱 :c:func:" "`Py_PreInitialize`)" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:133 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:131 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` to set these options. Or :c:func:`PyConfig_Get` can be used to " @@ -1339,6 +1487,10 @@ msgstr "" "應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API 來設定" "這些選項。或者也可以使用 :c:func:`PyConfig_Get` 在執行時取得這些選項。" +#: ../../deprecations/c-api-pending-removal-in-3.16.rst:4 +msgid "The bundled copy of ``libmpdec``." +msgstr "``libmpdec`` 的打包副本 (bundled copy)。" + #: ../../deprecations/c-api-pending-removal-in-3.18.rst:4 msgid "" "The following private functions are deprecated and planned for removal in " @@ -1490,6 +1642,30 @@ msgstr "" "compat/>`__ 來取得這些於 Python 3.13 及更早版本的新公開函式。(由 Victor " "Stinner 在 :gh:`128863` 貢獻)" +#: ../../deprecations/c-api-pending-removal-in-3.19.rst:4 +msgid ":pep:`456` embedders support for the string hashing scheme definition." +msgstr "" + +#: ../../deprecations/c-api-pending-removal-in-3.20.rst:4 +msgid "" +":c:func:`!_PyObject_CallMethodId`, :c:func:`!_PyObject_GetAttrId` and :c:" +"func:`!_PyUnicode_FromId` are deprecated since 3.15 and will be removed in " +"3.20. Instead, use :c:func:`PyUnicode_InternFromString()` and cache the " +"result in the module state, then call :c:func:`PyObject_CallMethod` or :c:" +"func:`PyObject_GetAttr`. (Contributed by Victor Stinner in :gh:`141049`.)" +msgstr "" + +#: ../../deprecations/c-api-pending-removal-in-3.20.rst:11 +msgid "" +"The ``cval`` field in :c:type:`PyComplexObject` (:gh:`128813`). Use :c:func:" +"`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex` to convert a " +"Python complex number to/from the C :c:type:`Py_complex` representation." +msgstr "" + +#: ../../deprecations/c-api-pending-removal-in-3.20.rst:16 +msgid "Macros :c:macro:`!Py_MATH_PIl` and :c:macro:`!Py_MATH_El`." +msgstr "" + #: ../../deprecations/c-api-pending-removal-in-future.rst:4 msgid "" "The following APIs are deprecated and will be removed, although there is " @@ -1593,6 +1769,163 @@ msgstr "" msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" +#~ msgid "" +#~ "Setting :attr:`~module.__cached__` on a module while failing to set :attr:" +#~ "`__spec__.cached ` is deprecated. " +#~ "In Python 3.15, :attr:`!__cached__` will cease to be set or take into " +#~ "consideration by the import system or standard library. (:gh:`97879`)" +#~ msgstr "" +#~ "在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " +#~ "` 的做法已被棄用。在 Python 3.15 " +#~ "中,引入系統或標準函式庫將不再設定或考慮 :attr:`!__cached__`。(:gh:" +#~ "`97879`)" + +#~ msgid "" +#~ "Setting :attr:`~module.__package__` on a module while failing to set :" +#~ "attr:`__spec__.parent ` is " +#~ "deprecated. In Python 3.15, :attr:`!__package__` will cease to be set or " +#~ "take into consideration by the import system or standard library. (:gh:" +#~ "`97879`)" +#~ msgstr "" +#~ "在模組上設定 :attr:`~module.__package__` 而沒有設定 :attr:`__spec__." +#~ "parent ` 的做法已被棄用。在 Python " +#~ "3.15 中,引入系統或標準函式庫將不再設定或考慮 :attr:`!__package__`。(:gh:" +#~ "`97879`)" + +#~ msgid "" +#~ "The undocumented :func:`!ctypes.SetPointerType` function has been " +#~ "deprecated since Python 3.13." +#~ msgstr "" +#~ "自 Python 3.13 起,未記錄的 :func:`!ctypes.SetPointerType` 函式已被棄用。" + +#~ msgid "" +#~ "The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` " +#~ "has been deprecated since Python 3.13. No direct replacement exists. " +#~ "*Anything* is better than CGI to interface a web server with a request " +#~ "handler." +#~ msgstr "" +#~ "過時且很少使用的 :class:`~http.server.CGIHTTPRequestHandler` 自 Python " +#~ "3.13 起已被棄用。不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服" +#~ "器與請求處理程序介接起來。" + +#~ msgid "" +#~ "The :option:`!--cgi` flag to the :program:`python -m http.server` command-" +#~ "line interface has been deprecated since Python 3.13." +#~ msgstr "" +#~ "自 Python 3.13 起,:program:`python -m http.server` 命令列介面的 :option:" +#~ "`!--cgi` 旗標已被棄用。" + +#~ msgid "``load_module()`` method: use ``exec_module()`` instead." +#~ msgstr "``load_module()`` method:請改用 ``exec_module()``。" + +#~ msgid "" +#~ ":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" +#~ "func:`os.path.isreserved` to detect reserved paths on Windows." +#~ msgstr "" +#~ ":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os." +#~ "path.isreserved` 來偵測 Windows 上的保留路徑。" + +#~ msgid "" +#~ ":func:`~platform.java_ver` has been deprecated since Python 3.13. This " +#~ "function is only useful for Jython support, has a confusing API, and is " +#~ "largely untested." +#~ msgstr "" +#~ "自 Python 3.13 起,:func:`~platform.java_ver` 已被棄用。此函式僅對 Jython " +#~ "支援有用,具有令人困惑的 API,基本上未經測試。" + +#~ msgid "" +#~ "The *check_home* argument of :func:`sysconfig.is_python_build` has been " +#~ "deprecated since Python 3.12." +#~ msgstr "" +#~ ":func:`sysconfig.is_python_build` 的 *check_home* 引數自 Python 3.12 起已" +#~ "被棄用。" + +#~ msgid "" +#~ ":func:`~threading.RLock` will take no arguments in Python 3.15. Passing " +#~ "any arguments has been deprecated since Python 3.14, as the Python " +#~ "version does not permit any arguments, but the C version allows any " +#~ "number of positional or keyword arguments, ignoring every argument." +#~ msgstr "" +#~ ":func:`~threading.RLock` 在 Python 3.15 中將不接受任何引數。自 Python " +#~ "3.14 起,傳遞任何引數的用法已被棄用,因為 Python 版本不允許任何引數,但 C " +#~ "版本允許任意數量的位置或關鍵字引數,並忽略每個引數。" + +#~ msgid "" +#~ ":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +#~ "deprecated in :pep:`626` since 3.10 and was planned to be removed in " +#~ "3.12, but it only got a proper :exc:`DeprecationWarning` in 3.12. May be " +#~ "removed in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" +#~ msgstr "" +#~ ":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" +#~ "在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" +#~ "exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" +#~ "`101866` 貢獻。)" + +#~ msgid "" +#~ "The undocumented keyword argument syntax for creating :class:`~typing." +#~ "NamedTuple` classes (for example, ``Point = NamedTuple(\"Point\", x=int, " +#~ "y=int)``) has been deprecated since Python 3.13. Use the class-based " +#~ "syntax or the functional syntax instead." +#~ msgstr "" +#~ "用於建立 :class:`~typing.NamedTuple` 類別的未以文件記錄之關鍵字引數語法 " +#~ "(``Point = NamedTuple(\"Point\", x=int, y=int)``) 已自 Python 3.13 棄用。" +#~ "請改用基於類別的語法或函式語法 (functional syntax)。" + +#~ msgid "" +#~ "When using the functional syntax of :class:`~typing.TypedDict`\\s, " +#~ "failing to pass a value to the *fields* parameter (``TD = " +#~ "TypedDict(\"TD\")``) or passing ``None`` (``TD = TypedDict(\"TD\", " +#~ "None)``) has been deprecated since Python 3.13. Use ``class " +#~ "TD(TypedDict): pass`` or ``TD = TypedDict(\"TD\", {})`` to create a " +#~ "TypedDict with zero field." +#~ msgstr "" +#~ "當使用 :class:`~typing.TypedDict` 的函式語法時,未傳遞值給 *fields* 參數 " +#~ "(``TD = TypedDict(\"TD\")``) 或傳遞 ``None`` (``TD = TypedDict(\"TD\", " +#~ "None)``) 的做法自 Python 3.13 起已被棄用。請使用 ``class TD(TypedDict): " +#~ "pass`` 或 ``TD = TypedDict(\"TD\", {})`` 來建立具有零個欄位的 TypedDict。" + +#~ msgid "" +#~ "The :deco:`typing.no_type_check_decorator` decorator function has been " +#~ "deprecated since Python 3.13. After eight years in the :mod:`typing` " +#~ "module, it has yet to be supported by any major type checker." +#~ msgstr "" +#~ "自 Python 3.13 起,:deco:`typing.no_type_check_decorator` 裝飾器函式已被棄" +#~ "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的" +#~ "支援。" + +#~ msgid "" +#~ "The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." +#~ "Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" +#~ "`~wave.Wave_write` classes have been deprecated since Python 3.13." +#~ msgstr "" +#~ "已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" +#~ "`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." +#~ "getmarkers` 方法自 Python 3.13 被棄用。" + +#~ msgid ":mod:`zipimport`:" +#~ msgstr ":mod:`zipimport`:" + +#~ msgid "" +#~ ":meth:`~zipimport.zipimporter.load_module` has been deprecated since " +#~ "Python 3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. " +#~ "(Contributed by Jiahao Li in :gh:`125746`.)" +#~ msgstr "" +#~ ":meth:`~zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改用 :" +#~ "meth:`~zipimport.zipimporter.exec_module`。(由 Jiahao Li 於 :gh:`125746` " +#~ "貢獻。)" + +#~ msgid "" +#~ ":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." +#~ msgstr "" +#~ ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" + +#~ msgid "" +#~ ":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :" +#~ "c:type:`wchar_t` instead." +#~ msgstr "" +#~ ":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:" +#~ "type:`wchar_t`。" + #~ msgid ":class:`locale`:" #~ msgstr ":class:`locale`:" diff --git a/deprecations/pending-removal-in-3.15.po b/deprecations/pending-removal-in-3.15.po index b02f76ac4df..77640b416b4 100644 --- a/deprecations/pending-removal-in-3.15.po +++ b/deprecations/pending-removal-in-3.15.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -25,14 +25,14 @@ msgstr "引入系統 (import system):" #: ../../deprecations/pending-removal-in-3.15.rst:6 msgid "" -"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" -"`__spec__.cached ` is deprecated. In " -"Python 3.15, :attr:`!__cached__` will cease to be set or take into " -"consideration by the import system or standard library. (:gh:`97879`)" +"Setting ``__cached__`` on a module while failing to set :attr:`__spec__." +"cached ` is deprecated. In Python " +"3.15, ``__cached__`` will cease to be set or take into consideration by the " +"import system or standard library. (:gh:`97879`)" msgstr "" -"在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " +"在模組上設定 ``__cached__`` 而沒有設定 :attr:`__spec__.cached " "` 的做法已被棄用。在 Python 3.15 中," -"引入系統或標準函式庫將不再設定或考慮 :attr:`!__cached__`。(:gh:`97879`)" +"引入系統或標準函式庫將不再設定或考慮 ``__cached__``。(:gh:`97879`)" #: ../../deprecations/pending-removal-in-3.15.rst:11 msgid "" @@ -62,13 +62,13 @@ msgstr ":mod:`http.server`:" #: ../../deprecations/pending-removal-in-3.15.rst:23 msgid "" -"The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` has " -"been deprecated since Python 3.13. No direct replacement exists. *Anything* " -"is better than CGI to interface a web server with a request handler." +"The obsolete and rarely used :class:`!CGIHTTPRequestHandler` has been " +"deprecated since Python 3.13. No direct replacement exists. *Anything* is " +"better than CGI to interface a web server with a request handler." msgstr "" -"過時且很少使用的 :class:`~http.server.CGIHTTPRequestHandler` 自 Python 3.13 " -"起已被棄用。不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求" -"處理程序介接起來。" +"過時且很少使用的 :class:`!CGIHTTPRequestHandler` 自 Python 3.13 起已被棄用。" +"不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求處理程序介接" +"起來。" #: ../../deprecations/pending-removal-in-3.15.rst:29 msgid "" @@ -92,11 +92,11 @@ msgstr ":mod:`pathlib`:" #: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" -":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" +":meth:`!.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" "func:`os.path.isreserved` to detect reserved paths on Windows." msgstr "" -":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os.path." -"isreserved` 來偵測 Windows 上的保留路徑。" +":meth:`!.PurePath.is_reserved` 已自 Python 3.13 被棄用。請" +"用 :func:`os.path.isreserved` 來偵測 Windows 上的保留路徑。" #: ../../deprecations/pending-removal-in-3.15.rst:42 msgid ":mod:`platform`:" @@ -104,11 +104,11 @@ msgstr ":mod:`platform`:" #: ../../deprecations/pending-removal-in-3.15.rst:44 msgid "" -":func:`~platform.java_ver` has been deprecated since Python 3.13. This " +":func:`!platform.java_ver` has been deprecated since Python 3.13. This " "function is only useful for Jython support, has a confusing API, and is " "largely untested." msgstr "" -"自 Python 3.13 起,:func:`~platform.java_ver` 已被棄用。此函式僅對 Jython 支" +"自 Python 3.13 起,:func:`!platform.java_ver` 已被棄用。此函式僅對 Jython 支" "援有用,具有令人困惑的 API,基本上未經測試。" #: ../../deprecations/pending-removal-in-3.15.rst:48 @@ -144,15 +144,15 @@ msgstr ":mod:`types`:" #: ../../deprecations/pending-removal-in-3.15.rst:63 msgid "" -":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +":class:`types.CodeType`: Accessing :attr:`!codeobject.co_lnotab` was " "deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " "but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " "in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" msgstr "" -":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" -"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" -"exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" -"`101866` 貢獻。)" +":class:`types.CodeType`:自 3.10 起,存取 :attr:`!codeobject.co_lnotab` 已" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但直到 3.12 才有正式" +"的 :exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev " +"於 :gh:`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:70 msgid ":mod:`typing`:" @@ -184,41 +184,43 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:85 msgid "" -"The :deco:`typing.no_type_check_decorator` decorator function has been " +"The :deco:`!typing.no_type_check_decorator` decorator function has been " "deprecated since Python 3.13. After eight years in the :mod:`typing` module, " "it has yet to be supported by any major type checker." msgstr "" -"自 Python 3.13 起,:deco:`typing.no_type_check_decorator` 裝飾器函式已被棄" +"自 Python 3.13 起,:deco:`!typing.no_type_check_decorator` 裝飾器函式已被棄" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" #: ../../deprecations/pending-removal-in-3.15.rst:90 +msgid "" +":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." +msgstr ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" + +#: ../../deprecations/pending-removal-in-3.15.rst:92 msgid ":mod:`wave`:" msgstr ":mod:`wave`:" -#: ../../deprecations/pending-removal-in-3.15.rst:92 +#: ../../deprecations/pending-removal-in-3.15.rst:94 msgid "" -"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." -"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" -"`~wave.Wave_write` classes have been deprecated since Python 3.13." +"The ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of the :class:" +"`~wave.Wave_read` and :class:`~wave.Wave_write` classes have been deprecated " +"since Python 3.13." msgstr "" -"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" -"`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." -"getmarkers` 方法自 Python 3.13 被棄用。" +":class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 ``getmark()``、" +"``setmark()`` 和 ``getmarkers()`` 方法自 Python 3.13 起已被棄用。" -#: ../../deprecations/pending-removal-in-3.15.rst:97 +#: ../../deprecations/pending-removal-in-3.15.rst:98 msgid ":mod:`zipimport`:" msgstr ":mod:`zipimport`:" -#: ../../deprecations/pending-removal-in-3.15.rst:99 +#: ../../deprecations/pending-removal-in-3.15.rst:100 msgid "" -":meth:`~zipimport.zipimporter.load_module` has been deprecated since Python " -"3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (Contributed " -"by Jiahao Li in :gh:`125746`.)" +":meth:`!zipimport.zipimporter.load_module` has been deprecated since Python " +"3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (:gh:`125746`.)" msgstr "" -":meth:`~zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改用 :" -"meth:`~zipimport.zipimporter.exec_module`。(由 Jiahao Li 於 :gh:`125746` 貢" -"獻。)" +":meth:`!zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改" +"用 :meth:`~zipimport.zipimporter.exec_module`。(:gh:`125746`。)" #~ msgid ":class:`locale`:" #~ msgstr ":class:`locale`:" diff --git a/deprecations/pending-removal-in-3.17.po b/deprecations/pending-removal-in-3.17.po index f57b821b35e..726658e51e0 100644 --- a/deprecations/pending-removal-in-3.17.po +++ b/deprecations/pending-removal-in-3.17.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-19 00:15+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -22,16 +22,27 @@ msgid "Pending removal in Python 3.17" msgstr "Python 3.17 中待移除的項目" #: ../../deprecations/pending-removal-in-3.17.rst:4 +msgid ":mod:`datetime`:" +msgstr ":mod:`datetime`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:6 +msgid "" +":meth:`~datetime.datetime.strptime` calls using a format string containing " +"``%e`` (day of month) without a year. This has been deprecated since Python " +"3.15. (Contributed by Stan Ulbrych in :gh:`70647`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:12 msgid ":mod:`collections.abc`:" msgstr ":mod:`collections.abc`:" -#: ../../deprecations/pending-removal-in-3.17.rst:6 +#: ../../deprecations/pending-removal-in-3.17.rst:14 msgid "" ":class:`collections.abc.ByteString` is scheduled for removal in Python 3.17." msgstr ":class:`collections.abc.ByteString` 預計在 Python 3.17 中移除。" -#: ../../deprecations/pending-removal-in-3.17.rst:8 -#: ../../deprecations/pending-removal-in-3.17.rst:36 +#: ../../deprecations/pending-removal-in-3.17.rst:16 +#: ../../deprecations/pending-removal-in-3.17.rst:62 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -44,8 +55,8 @@ msgstr "" "collections.abc.Buffer` 或明確指定你的程式碼所支援型別的聯集(例如 " "``bytes | bytearray | memoryview``)。" -#: ../../deprecations/pending-removal-in-3.17.rst:14 -#: ../../deprecations/pending-removal-in-3.17.rst:42 +#: ../../deprecations/pending-removal-in-3.17.rst:22 +#: ../../deprecations/pending-removal-in-3.17.rst:68 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -60,19 +71,52 @@ msgstr "" "實例從未真正告訴你任何關於該物件的有用資訊。其他常見的緩衝區型別如 :class:`memoryview` " "也從未被理解為 :class:`!ByteString` 的子型別(無論是在 runtime 還是由靜態型別檢查器)。" -#: ../../deprecations/pending-removal-in-3.17.rst:22 -#: ../../deprecations/pending-removal-in-3.17.rst:50 +#: ../../deprecations/pending-removal-in-3.17.rst:30 +#: ../../deprecations/pending-removal-in-3.17.rst:76 msgid "" "See :pep:`PEP 688 <688#current-options>` for more details. (Contributed by " "Shantanu Jain in :gh:`91896`.)" msgstr "" "更多細節請見 :pep:`PEP 688 <688#current-options>`。(由 Shantanu Jain 於 :gh:`91896` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.17.rst:26 +#: ../../deprecations/pending-removal-in-3.17.rst:34 +msgid ":mod:`encodings`:" +msgstr ":mod:`encodings`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:36 +msgid "" +"Passing non-ascii *encoding* names to :func:`encodings.normalize_encoding` " +"is deprecated and scheduled for removal in Python 3.17. (Contributed by Stan " +"Ulbrych in :gh:`136702`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:40 +msgid ":mod:`profile`:" +msgstr ":mod:`profile`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:42 +msgid "" +"The :mod:`!profile` module is deprecated and will be removed in Python 3.17. " +"Use :mod:`profiling.tracing` instead, which provides a compatible API. See :" +"pep:`799` for details. (Contributed by Pablo Galindo and László Kiss Kollár " +"in :gh:`138122`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:47 +msgid ":mod:`webbrowser`:" +msgstr ":mod:`webbrowser`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:49 +msgid "" +":class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of :class:`!" +"webbrowser.MacOS`. (:gh:`137586`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:52 msgid ":mod:`typing`:" msgstr ":mod:`typing`:" -#: ../../deprecations/pending-removal-in-3.17.rst:28 +#: ../../deprecations/pending-removal-in-3.17.rst:54 msgid "" "Before Python 3.14, old-style unions were implemented using the private " "class ``typing._UnionGenericAlias``. This class is no longer needed for the " @@ -86,9 +130,22 @@ msgstr "" "除。使用者應該改用文件中記錄的內省輔助函式,例如 :func:`typing.get_origin` " "和 :func:`typing.get_args`,或者依賴私有實作細節。" -#: ../../deprecations/pending-removal-in-3.17.rst:33 +#: ../../deprecations/pending-removal-in-3.17.rst:59 msgid "" ":class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for " "removal in Python 3.17." msgstr "" ":class:`typing.ByteString` 自 Python 3.9 起已被棄用,預計在 Python 3.17 中移除。" + +#: ../../deprecations/pending-removal-in-3.17.rst:79 +msgid ":mod:`tkinter`:" +msgstr ":mod:`tkinter`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:81 +msgid "" +"The :class:`!tkinter.Variable` methods :meth:`!trace_variable`, :meth:`!" +"trace` (an alias of :meth:`!trace_variable`), :meth:`!trace_vdelete` and :" +"meth:`!trace_vinfo`, deprecated since Python 3.14, are scheduled for removal " +"in Python 3.17. Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!" +"trace_info` instead. (Contributed by Serhiy Storchaka in :gh:`120220`.)" +msgstr "" diff --git a/deprecations/pending-removal-in-3.18.po b/deprecations/pending-removal-in-3.18.po index 2c17ebcdffe..e52ed089969 100644 --- a/deprecations/pending-removal-in-3.18.po +++ b/deprecations/pending-removal-in-3.18.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-07 00:14+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -22,10 +22,16 @@ msgid "Pending removal in Python 3.18" msgstr "Python 3.18 中待移除的項目" #: ../../deprecations/pending-removal-in-3.18.rst:4 +msgid "" +"No longer accept a boolean value when a file descriptor is expected. " +"(Contributed by Serhiy Storchaka in :gh:`82626`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:7 msgid ":mod:`decimal`:" msgstr ":mod:`decimal`:" -#: ../../deprecations/pending-removal-in-3.18.rst:6 +#: ../../deprecations/pending-removal-in-3.18.rst:9 msgid "" "The non-standard and undocumented :class:`~decimal.Decimal` format specifier " "``'N'``, which is only supported in the :mod:`!decimal` module's C " @@ -35,3 +41,15 @@ msgstr "" "非標準且無文件記載的 :class:`~decimal.Decimal` 格式說明符號 ``'N'``,僅在 :mod:" "`!decimal` 模組的 C 實作中被支援,自 Python 3.13 起已被棄用。(由 Serhiy " "Storchaka 於 :gh:`89902` 中貢獻。)" + +#: ../../deprecations/pending-removal-in-3.18.rst:14 +msgid "Deprecations defined by :pep:`829`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:16 +msgid "``import`` lines in :file:`{name}.pth` files are silently ignored." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:18 +msgid "(Contributed by Barry Warsaw in :gh:`148641`.)" +msgstr "" diff --git a/deprecations/pending-removal-in-3.19.po b/deprecations/pending-removal-in-3.19.po index 271ecde9123..38c2e08c765 100644 --- a/deprecations/pending-removal-in-3.19.po +++ b/deprecations/pending-removal-in-3.19.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -33,3 +33,64 @@ msgid "" msgstr "" "在非 Windows 平台上,透過設定 :attr:`~ctypes.Structure._pack_` 而沒有設" "定 :attr:`~ctypes.Structure._layout_` 來隱式地切換到與 MSVC 相容的結構佈局。" + +#: ../../deprecations/pending-removal-in-3.19.rst:10 +msgid ":mod:`hashlib`:" +msgstr ":mod:`hashlib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:12 +msgid "" +"In hash function constructors such as :func:`~hashlib.new` or the direct " +"hash-named constructors such as :func:`~hashlib.md5` and :func:`~hashlib." +"sha256`, their optional initial data parameter could also be passed a " +"keyword argument named ``data=`` or ``string=`` in various :mod:`!hashlib` " +"implementations." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:18 +msgid "" +"Support for the ``string`` keyword argument name is now deprecated and " +"slated for removal in Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:21 +msgid "" +"Before Python 3.13, the ``string`` keyword parameter was not correctly " +"supported depending on the backend implementation of hash functions. Prefer " +"passing the initial data as a positional argument for maximum backwards " +"compatibility." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:26 +msgid ":mod:`http.cookies`:" +msgstr ":mod:`http.cookies`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:28 +msgid "" +":meth:`http.cookies.Morsel.js_output` is deprecated and will be removed in " +"Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:31 +msgid "" +":meth:`http.cookies.BaseCookie.js_output` is deprecated and will be removed " +"in Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:34 +msgid ":mod:`imaplib`:" +msgstr ":mod:`imaplib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:36 +msgid "" +"Altering :attr:`IMAP4.file ` is now deprecated and " +"slated for removal in Python 3.19. This property is now unused and changing " +"its value does not automatically close the current file." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:40 +msgid "" +"Before Python 3.14, this property was used to implement the corresponding " +"``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this " +"is no longer the case since then." +msgstr "" diff --git a/deprecations/pending-removal-in-3.20.po b/deprecations/pending-removal-in-3.20.po new file mode 100644 index 00000000000..1c2c0de2445 --- /dev/null +++ b/deprecations/pending-removal-in-3.20.po @@ -0,0 +1,187 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../deprecations/pending-removal-in-3.20.rst:2 +msgid "Pending removal in Python 3.20" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:4 +msgid "" +"Calling the ``__new__()`` method of :class:`struct.Struct` without the " +"*format* argument is deprecated and will be removed in Python 3.20. " +"Calling :meth:`~object.__init__` method on initialized :class:`~struct." +"Struct` objects is deprecated and will be removed in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:9 +msgid "" +"(Contributed by Sergey B Kirpichev and Serhiy Storchaka in :gh:`143715`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:11 +msgid "" +"The ``__version__``, ``version`` and ``VERSION`` attributes have been " +"deprecated in these standard library modules and will be removed in Python " +"3.20. Use :py:data:`sys.version_info` instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:15 +msgid ":mod:`argparse`" +msgstr ":mod:`argparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:16 +msgid ":mod:`csv`" +msgstr ":mod:`csv`" + +#: ../../deprecations/pending-removal-in-3.20.rst:17 +msgid ":mod:`ctypes`" +msgstr ":mod:`ctypes`" + +#: ../../deprecations/pending-removal-in-3.20.rst:18 +msgid ":mod:`!ctypes.macholib`" +msgstr ":mod:`!ctypes.macholib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:19 +msgid ":mod:`decimal` (use :data:`decimal.SPEC_VERSION` instead)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:20 +msgid ":mod:`http.server`" +msgstr ":mod:`http.server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:21 +msgid ":mod:`imaplib`" +msgstr ":mod:`imaplib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:22 +msgid ":mod:`ipaddress`" +msgstr ":mod:`ipaddress`" + +#: ../../deprecations/pending-removal-in-3.20.rst:23 +msgid ":mod:`json`" +msgstr ":mod:`json`" + +#: ../../deprecations/pending-removal-in-3.20.rst:24 +msgid ":mod:`logging` (``__date__`` also deprecated)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:25 +msgid ":mod:`optparse`" +msgstr ":mod:`optparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:26 +msgid ":mod:`pickle`" +msgstr ":mod:`pickle`" + +#: ../../deprecations/pending-removal-in-3.20.rst:27 +msgid ":mod:`platform`" +msgstr ":mod:`platform`" + +#: ../../deprecations/pending-removal-in-3.20.rst:28 +msgid ":mod:`re`" +msgstr ":mod:`re`" + +#: ../../deprecations/pending-removal-in-3.20.rst:29 +msgid ":mod:`socketserver`" +msgstr ":mod:`socketserver`" + +#: ../../deprecations/pending-removal-in-3.20.rst:30 +msgid ":mod:`tabnanny`" +msgstr ":mod:`tabnanny`" + +#: ../../deprecations/pending-removal-in-3.20.rst:31 +msgid ":mod:`tarfile`" +msgstr ":mod:`tarfile`" + +#: ../../deprecations/pending-removal-in-3.20.rst:32 +msgid ":mod:`tkinter.font`" +msgstr ":mod:`tkinter.font`" + +#: ../../deprecations/pending-removal-in-3.20.rst:33 +msgid ":mod:`tkinter.ttk`" +msgstr ":mod:`tkinter.ttk`" + +#: ../../deprecations/pending-removal-in-3.20.rst:34 +msgid ":mod:`wsgiref.simple_server`" +msgstr ":mod:`wsgiref.simple_server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:35 +msgid ":mod:`xml.etree.ElementTree`" +msgstr ":mod:`xml.etree.ElementTree`" + +#: ../../deprecations/pending-removal-in-3.20.rst:36 +msgid ":mod:`!xml.sax.expatreader`" +msgstr ":mod:`!xml.sax.expatreader`" + +#: ../../deprecations/pending-removal-in-3.20.rst:37 +msgid ":mod:`xml.sax.handler`" +msgstr ":mod:`xml.sax.handler`" + +#: ../../deprecations/pending-removal-in-3.20.rst:38 +msgid ":mod:`zlib`" +msgstr ":mod:`zlib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:40 +msgid "(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:42 +msgid "Deprecations defined by :pep:`829`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:44 +msgid "" +"Warnings are produced for ``import`` lines found in :file:`{name}.pth` files." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:47 +msgid "" +":file:`{name}.pth` files are no longer decoded in the locale encoding by " +"default. They **MUST** be encoded in ``utf-8-sig``." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:50 +msgid "(Contributed by Barry Warsaw in :gh:`148641`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:52 +msgid ":mod:`ast`:" +msgstr ":mod:`ast`:" + +#: ../../deprecations/pending-removal-in-3.20.rst:54 +msgid "" +"Creating instances of abstract AST nodes (such as :class:`ast.AST` or :class:" +"`!ast.expr`) is deprecated and will raise an error in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:57 +msgid ":mod:`typing`:" +msgstr ":mod:`typing`:" + +#: ../../deprecations/pending-removal-in-3.20.rst:59 +msgid "" +"It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on " +"protocol classes that were not explicitly decorated with :func:`!" +"runtime_checkable` but that inherit from a runtime-checkable protocol class. " +"This will raise a :exc:`TypeError` in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:64 +msgid "(Contributed by Bartosz Sławecki in :gh:`132604`.)" +msgstr "" diff --git a/deprecations/pending-removal-in-future.po b/deprecations/pending-removal-in-future.po index d97372e5dd7..3f26f708959 100644 --- a/deprecations/pending-removal-in-future.po +++ b/deprecations/pending-removal-in-future.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-10 00:24+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -134,10 +134,10 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:50 msgid "" -":attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " +":attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " "instead." msgstr "" -":attr:`codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" +":attr:`!codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" #: ../../deprecations/pending-removal-in-future.rst:53 msgid ":mod:`datetime`:" @@ -204,18 +204,28 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:78 msgid "" -":mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process." +":mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process." msgstr ":mod:`os`:在多執行緒行程中呼叫 :func:`os.register_at_fork`。" #: ../../deprecations/pending-removal-in-future.rst:80 msgid "" +":mod:`os.path`: :func:`os.path.commonprefix` is deprecated, use :func:`os." +"path.commonpath` for path prefixes. The :func:`os.path.commonprefix` " +"function is being deprecated due to having a misleading name and module. The " +"function is not safe to use for path prefixes despite being included in a " +"module about path manipulation, meaning it is easy to accidentally introduce " +"path traversal vulnerabilities into Python programs by using this function." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:88 +msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." msgstr "" ":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" "實例。" -#: ../../deprecations/pending-removal-in-future.rst:83 +#: ../../deprecations/pending-removal-in-future.rst:91 msgid "" ":mod:`re`: More strict rules are now applied for numerical group references " "and group names in regular expressions. Only sequence of ASCII digits is " @@ -227,12 +237,7 @@ msgstr "" "有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" "包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:90 -msgid "" -":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." -msgstr ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" - -#: ../../deprecations/pending-removal-in-future.rst:92 +#: ../../deprecations/pending-removal-in-future.rst:98 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." @@ -240,15 +245,15 @@ msgstr "" ":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" "棄用;請改用 *onexc* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:95 +#: ../../deprecations/pending-removal-in-future.rst:101 msgid ":mod:`ssl` options and protocols:" msgstr ":mod:`ssl` 選項和協定:" -#: ../../deprecations/pending-removal-in-future.rst:97 +#: ../../deprecations/pending-removal-in-future.rst:103 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:98 +#: ../../deprecations/pending-removal-in-future.rst:104 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." @@ -256,51 +261,51 @@ msgstr "" ":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" "`!selected_npn_protocol` 已被棄用:請改用 ALPN。" -#: ../../deprecations/pending-removal-in-future.rst:101 +#: ../../deprecations/pending-removal-in-future.rst:107 msgid "``ssl.OP_NO_SSL*`` options" msgstr "``ssl.OP_NO_SSL*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:102 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "``ssl.OP_NO_TLS*`` options" msgstr "``ssl.OP_NO_TLS*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:103 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid "``ssl.PROTOCOL_SSLv3``" msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:104 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "``ssl.PROTOCOL_TLS``" msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:105 +#: ../../deprecations/pending-removal-in-future.rst:111 msgid "``ssl.PROTOCOL_TLSv1``" msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:106 +#: ../../deprecations/pending-removal-in-future.rst:112 msgid "``ssl.PROTOCOL_TLSv1_1``" msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:107 +#: ../../deprecations/pending-removal-in-future.rst:113 msgid "``ssl.PROTOCOL_TLSv1_2``" msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:108 +#: ../../deprecations/pending-removal-in-future.rst:114 msgid "``ssl.TLSVersion.SSLv3``" msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:109 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid "``ssl.TLSVersion.TLSv1``" msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:110 +#: ../../deprecations/pending-removal-in-future.rst:116 msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:118 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:114 +#: ../../deprecations/pending-removal-in-future.rst:120 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -308,11 +313,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:121 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" -#: ../../deprecations/pending-removal-in-future.rst:116 +#: ../../deprecations/pending-removal-in-future.rst:122 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -320,7 +325,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:118 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -328,20 +333,20 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:120 +#: ../../deprecations/pending-removal-in-future.rst:126 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:121 +#: ../../deprecations/pending-removal-in-future.rst:127 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:123 +#: ../../deprecations/pending-removal-in-future.rst:129 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:131 msgid "" "The internal class ``typing._UnionGenericAlias`` is no longer used to " "implement :class:`typing.Union`. To preserve compatibility with users using " @@ -352,7 +357,7 @@ msgstr "" "了保持與此私有類別使用者的相容性,直到至少 Python 3.17 都將提供一個相容性 " "shim。(由 Jelle Zijlstra 於 :gh:`105499` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:130 +#: ../../deprecations/pending-removal-in-future.rst:136 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -360,64 +365,64 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:139 msgid "" ":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " "instead" msgstr "" ":mod:`urllib.parse` 已棄用函式:請改用 :func:`~urllib.parse.urlparse`。" -#: ../../deprecations/pending-removal-in-future.rst:135 +#: ../../deprecations/pending-removal-in-future.rst:141 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:136 +#: ../../deprecations/pending-removal-in-future.rst:142 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:137 +#: ../../deprecations/pending-removal-in-future.rst:143 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:138 +#: ../../deprecations/pending-removal-in-future.rst:144 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:139 +#: ../../deprecations/pending-removal-in-future.rst:145 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:140 +#: ../../deprecations/pending-removal-in-future.rst:146 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:141 +#: ../../deprecations/pending-removal-in-future.rst:147 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:142 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:143 +#: ../../deprecations/pending-removal-in-future.rst:149 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:144 +#: ../../deprecations/pending-removal-in-future.rst:150 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:145 +#: ../../deprecations/pending-removal-in-future.rst:151 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:147 +#: ../../deprecations/pending-removal-in-future.rst:153 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:150 +#: ../../deprecations/pending-removal-in-future.rst:156 msgid "" ":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." "etree.ElementTree.Element` is deprecated. In a future release it will always " @@ -428,7 +433,7 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:155 +#: ../../deprecations/pending-removal-in-future.rst:161 msgid "" ":func:`sys._clear_type_cache` is deprecated: use :func:`sys." "_clear_internal_caches` instead." @@ -436,5 +441,10 @@ msgstr "" ":func:`sys._clear_type_cache` 已被棄用:請改用 :func:`sys." "_clear_internal_caches`。" +#~ msgid "" +#~ ":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." +#~ msgstr "" +#~ ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" + #~ msgid "Delegation of ``int()`` to ``__trunc__()`` method." #~ msgstr "將 ``int()`` 委派給 ``__trunc__()`` 方法。" diff --git a/deprecations/soft-deprecations.po b/deprecations/soft-deprecations.po new file mode 100644 index 00000000000..a128a11b435 --- /dev/null +++ b/deprecations/soft-deprecations.po @@ -0,0 +1,58 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../deprecations/soft-deprecations.rst:2 +msgid "Soft deprecations" +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:4 +msgid "There are no plans to remove :term:`soft deprecated` APIs." +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:6 +msgid "" +":func:`re.match` and :meth:`re.Pattern.match` are now :term:`soft " +"deprecated` in favor of the new :func:`re.prefixmatch` and :meth:`re.Pattern." +"prefixmatch` APIs, which have been added as alternate, more explicit names. " +"These are intended to be used to alleviate confusion around what *match* " +"means by following the Zen of Python's *\"Explicit is better than " +"implicit\"* mantra. Most other language regular expression libraries use an " +"API named *match* to mean what Python has always called *search*." +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:15 +msgid "" +"We **do not** plan to remove the older :func:`!match` name, as it has been " +"used in code for over 30 years. Code supporting older versions of Python " +"should continue to use :func:`!match`, while new code should prefer :func:`!" +"prefixmatch`. See :ref:`prefixmatch-vs-match`." +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:20 +msgid "" +"(Contributed by Gregory P. Smith in :gh:`86519` and Hugo van Kemenade in :gh:" +"`148100`.)" +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:23 +msgid "" +"Using ``'F'`` and ``'D'`` format type codes of the :mod:`struct` module now " +"are :term:`soft deprecated` in favor of two-letter forms ``'Zf'`` and " +"``'Zd'``. (Contributed by Sergey B Kirpichev in :gh:`121249`.)" +msgstr "" diff --git a/extending/extending.po b/extending/extending.po index e90b018ccd6..c597f70e6da 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-17 00:09+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,315 +21,22 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../extending/extending.rst:8 -msgid "Extending Python with C or C++" -msgstr "以 C 或 C++ 擴充 Python" - -#: ../../extending/extending.rst:10 -msgid "" -"It is quite easy to add new built-in modules to Python, if you know how to " -"program in C. Such :dfn:`extension modules` can do two things that can't be " -"done directly in Python: they can implement new built-in object types, and " -"they can call C library functions and system calls." -msgstr "" -"如果你會撰寫 C 程式語言,那要向 Python 新增內建模組就不困難。這種\\ :dfn:`擴" -"充模組 (extension modules)` 可以做兩件在 Python 中無法直接完成的事:它們可以" -"實作新的內建物件型別,並且可以呼叫 C 的函式庫函式和系統呼叫。" - -#: ../../extending/extending.rst:15 -msgid "" -"To support extensions, the Python API (Application Programmers Interface) " -"defines a set of functions, macros and variables that provide access to most " -"aspects of the Python run-time system. The Python API is incorporated in a " -"C source file by including the header ``\"Python.h\"``." -msgstr "" -"為了支援擴充,Python API (Application Programmers Interface) 定義了一組函式、" -"巨集和變數,提供對 Python run-time 系統大部分面向的存取。Python API 是透過引" -"入標頭檔 ``\"Python.h\"`` 來被納入到一個 C 原始碼檔案中。" - -#: ../../extending/extending.rst:20 -msgid "" -"The compilation of an extension module depends on its intended use as well " -"as on your system setup; details are given in later chapters." -msgstr "" -"擴充模組的編譯取決於其預期用途以及你的系統設定;詳細資訊將在後面的章節中提" -"供。" - -#: ../../extending/extending.rst:25 -msgid "" -"The C extension interface is specific to CPython, and extension modules do " -"not work on other Python implementations. In many cases, it is possible to " -"avoid writing C extensions and preserve portability to other " -"implementations. For example, if your use case is calling C library " -"functions or system calls, you should consider using the :mod:`ctypes` " -"module or the `cffi `_ library rather than " -"writing custom C code. These modules let you write Python code to interface " -"with C code and are more portable between implementations of Python than " -"writing and compiling a C extension module." -msgstr "" -"C 擴充介面是 CPython 所特有的,擴充模組在其他 Python 實作上無法運作。在許多情" -"況下,可以避免撰寫 C 擴充並保留對其他實作的可移植性。例如,如果你的用例是呼" -"叫 C 函式庫函式或系統呼叫,你應該考慮使用 :mod:`ctypes` 模組或 `cffi " -"`_ 函式庫,而不是編寫自訂的 C 程式碼。這些模組" -"讓你可以撰寫 Python 程式碼來與 C 程式碼介接,而且比起撰寫和編譯 C 擴充模組," -"這些模組在 Python 實作之間更容易移植。" - -#: ../../extending/extending.rst:40 -msgid "A Simple Example" -msgstr "一個簡單範例" - -#: ../../extending/extending.rst:42 -msgid "" -"Let's create an extension module called ``spam`` (the favorite food of Monty " -"Python fans...) and let's say we want to create a Python interface to the C " -"library function :c:func:`system` [#]_. This function takes a null-" -"terminated character string as argument and returns an integer. We want " -"this function to be callable from Python as follows:" -msgstr "" -"讓我們來建立一個叫做 ``spam``\\ (Monty Python 粉絲最愛的食物...)的擴充模" -"組。假設我們要建立一個 Python 介面給 C 函式庫的函式 :c:func:`system` [#]_ 使" -"用,這個函式接受一個以 null 終止的 (null-terminated) 字元字串做為引數,並回傳" -"一個整數。我們希望這個函式可以在 Python 中被呼叫,如下所示:" - -#: ../../extending/extending.rst:48 -msgid "" -">>> import spam\n" -">>> status = spam.system(\"ls -l\")" -msgstr "" -">>> import spam\n" -">>> status = spam.system(\"ls -l\")" - -#: ../../extending/extending.rst:53 -msgid "" -"Begin by creating a file :file:`spammodule.c`. (Historically, if a module " -"is called ``spam``, the C file containing its implementation is called :file:" -"`spammodule.c`; if the module name is very long, like ``spammify``, the " -"module name can be just :file:`spammify.c`.)" -msgstr "" -"首先建立一個檔案 :file:`spammodule.c`。(從過去歷史來看,如果一個模組叫做 " -"``spam``,包含其實作的 C 檔案就會叫做 :file:`spammodule.c`;如果模組名稱很" -"長,像是 ``spammify``,模組名稱也可以只是 :file:`spammify.c`)。" - -#: ../../extending/extending.rst:58 -msgid "The first two lines of our file can be::" -msgstr "我們檔案的前兩列可以為: ::" - -#: ../../extending/extending.rst:60 ../../extending/extending.rst:704 -msgid "" -"#define PY_SSIZE_T_CLEAN\n" -"#include " -msgstr "" -"#define PY_SSIZE_T_CLEAN\n" -"#include " - -#: ../../extending/extending.rst:63 -msgid "" -"which pulls in the Python API (you can add a comment describing the purpose " -"of the module and a copyright notice if you like)." -msgstr "" -"這會將 Python API 拉進來(你可以加入註解來說明模組的目的,也可以加入版權聲" -"明)。" - -#: ../../extending/extending.rst:68 -msgid "" -"Since Python may define some pre-processor definitions which affect the " -"standard headers on some systems, you *must* include :file:`Python.h` before " -"any standard headers are included." -msgstr "" -"由於 Python 可能定義一些影響系統上某些標準標頭檔的預處理器定義,你\\ *必須" -"*\\ 在引入任何標準標頭檔之前引入 :file:`Python.h`。" - -#: ../../extending/extending.rst:72 -msgid "" -"``#define PY_SSIZE_T_CLEAN`` was used to indicate that ``Py_ssize_t`` should " -"be used in some APIs instead of ``int``. It is not necessary since Python " -"3.13, but we keep it here for backward compatibility. See :ref:`arg-parsing-" -"string-and-buffers` for a description of this macro." -msgstr "" -"``#define PY_SSIZE_T_CLEAN`` 被用來表示在某些 API 中應該使用 ``Py_ssize_t`` " -"而不是 ``int``。自 Python 3.13 起,它就不再是必要的了,但我們在此保留它以便向" -"後相容。關於這個巨集的描述請參閱\\ :ref:`arg-parsing-string-and-buffers`。" - -#: ../../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." -msgstr "" -"所有由 :file:`Python.h` 定義的使用者可見符號都具有 ``Py`` 或 ``PY`` 的前綴," -"在標準標頭檔中定義的除外。" - -#: ../../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 "" -"為了向後相容,:file:`Python.h` 引入了數個標準標頭檔。C 擴充應該引入它們使用的" -"標準標頭檔,而不應依賴這些隱式的引入。如果使用限定 C API 版本 3.13 或更新版" -"本,隱式引入的有:" - -#: ../../extending/extending.rst:87 -msgid "````" -msgstr "````" - -#: ../../extending/extending.rst:88 -msgid "```` (on Windows)" -msgstr "````\\ (在 Windows 上)" - -#: ../../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 "" -"如果 :c:macro:`Py_LIMITED_API` 未被定義,或是被設定為版本 3.12 或更舊,則也會" -"引入以下標頭檔:" - -#: ../../extending/extending.rst:99 -msgid "````" -msgstr "````" - -#: ../../extending/extending.rst:100 -msgid "```` (on POSIX)" -msgstr "````\\ (在 POSIX 上)" - -#: ../../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 "" -"如果 :c:macro:`Py_LIMITED_API` 未被定義,或是被設定為版本 3.10 或更舊,則也會" -"引入以下標頭檔:" - -#: ../../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 " -"(we'll see shortly how it ends up being called)::" -msgstr "" -"接下來我們要加入到模組檔案的是 C 函式,當 Python 運算式 ``spam." -"system(string)`` 要被求值 (evaluated) 時就會被呼叫(我們很快就會看到它最後是" -"如何被呼叫的): ::" - -#: ../../extending/extending.rst:114 -msgid "" -"static PyObject *\n" -"spam_system(PyObject *self, PyObject *args)\n" -"{\n" -" const char *command;\n" -" int sts;\n" -"\n" -" if (!PyArg_ParseTuple(args, \"s\", &command))\n" -" return NULL;\n" -" sts = system(command);\n" -" return PyLong_FromLong(sts);\n" -"}" -msgstr "" -"static PyObject *\n" -"spam_system(PyObject *self, PyObject *args)\n" -"{\n" -" const char *command;\n" -" int sts;\n" -"\n" -" if (!PyArg_ParseTuple(args, \"s\", &command))\n" -" return NULL;\n" -" sts = system(command);\n" -" return PyLong_FromLong(sts);\n" -"}" - -#: ../../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 " -"C function. The C function always has two arguments, conventionally named " -"*self* and *args*." -msgstr "" -"可以很直觀地從 Python 的引數串列(例如單一的運算式 ``\"ls -l\"``)直接轉換成" -"傳給 C 函式的引數。C 函式總是有兩個引數,習慣上會命名為 *self* 和 *args*。" - -#: ../../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." +msgid "Using the C API: Assorted topics" msgstr "" -"對於模組層級的函式,*self* 引數會指向模組物件;而對於方法來說則是指向物件的實" -"例。" -#: ../../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 " -"call's argument list. The arguments are Python objects --- in order to do " -"anything with them in our C function we have to convert them to C values. " -"The function :c:func:`PyArg_ParseTuple` in the Python API checks the " -"argument types and converts them to C values. It uses a template string to " -"determine the required types of the arguments as well as the types of the C " -"variables into which to store the converted values. More about this later." -msgstr "" -"*args* 引數會是一個指向包含引數的 Python 元組物件的指標。元組中的每一項都對應" -"於呼叫的引數串列中的一個引數。引數是 Python 物件 --- 為了在我們的 C 函式中對" -"它們做任何事情,我們必須先將它們轉換成 C 值。Python API 中的 :c:func:" -"`PyArg_ParseTuple` 函式能夠檢查引數型別並將他們轉換為 C 值。它使用模板字串來" -"決定所需的引數型別以及儲存轉換值的 C 變數型別。稍後會再詳細說明。" - -#: ../../extending/extending.rst:143 +#: ../../extending/extending.rst:10 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 " -"addresses are passed. It returns false (zero) if an invalid argument list " -"was passed. In the latter case it also raises an appropriate exception so " -"the calling function can return ``NULL`` immediately (as we saw in the " -"example)." +"The :ref:`tutorial ` walked you through creating a C " +"API extension module, but left many areas unexplained. This document looks " +"at several concepts that you'll need to learn in order to write more complex " +"extensions." msgstr "" -"如果所有的引數都有正確的型別,且其元件已儲存在傳入位址的變數中,則 :c:func:" -"`PyArg_ParseTuple` 會回傳 true(非零)。如果傳入的是無效引數串列則回傳 false" -"(零)。在後者情況下,它也會產生適當的例外,因此呼叫函式可以立即回傳 " -"``NULL``\\ (就像我們在範例中所看到的)。" -#: ../../extending/extending.rst:153 -msgid "Intermezzo: Errors and Exceptions" -msgstr "插曲:錯誤與例外" +#: ../../extending/extending.rst:19 +msgid "Errors and Exceptions" +msgstr "錯誤和例外" -#: ../../extending/extending.rst:155 +#: ../../extending/extending.rst:21 msgid "" "An important convention throughout the Python interpreter is the following: " "when a function fails, it should set an exception condition and return an " @@ -346,13 +53,13 @@ msgstr "" "們是由 :meth:`sys.exc_info` 所回傳的 Python 元組中的 C 等效元組。它們是例外型" "別、例外實例和回溯物件。了解它們對於理解錯誤是如何傳遞是很重要的。" -#: ../../extending/extending.rst:164 +#: ../../extending/extending.rst:30 msgid "" "The Python API defines a number of functions to set various types of " "exceptions." msgstr "Python API 定義了許多能夠設定各種類型例外的函式。" -#: ../../extending/extending.rst:166 +#: ../../extending/extending.rst:32 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 " @@ -365,7 +72,7 @@ msgstr "" "指出錯誤的原因,並被轉換為 Python 字串物件且被儲存為例外的「關聯值 " "(associated value)」。" -#: ../../extending/extending.rst:172 +#: ../../extending/extending.rst:38 msgid "" "Another useful function is :c:func:`PyErr_SetFromErrno`, which only takes an " "exception argument and constructs the associated value by inspection of the " @@ -379,7 +86,7 @@ msgstr "" "`PyErr_SetObject`,它接受兩個物件引數,即例外和它的關聯值。你不需要對傳給任何" "這些函式的物件呼叫 :c:func:`Py_INCREF`。" -#: ../../extending/extending.rst:179 +#: ../../extending/extending.rst:45 msgid "" "You can test non-destructively whether an exception has been set with :c:" "func:`PyErr_Occurred`. This returns the current exception object, or " @@ -391,7 +98,7 @@ msgstr "" "回傳目前的例外物件,如果沒有例外發生則回傳 ``NULL``。你通常不需要呼叫 :c:" "func:`PyErr_Occurred` 來查看函式呼叫是否發生錯誤,因為你應可從回傳值就得知。" -#: ../../extending/extending.rst:185 +#: ../../extending/extending.rst:51 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 " @@ -410,7 +117,7 @@ msgstr "" "首先檢測到它的函式回報了。一旦錯誤到達 Python 直譯器的主要迴圈,這會中止目前" "執行的 Python 程式碼,並嘗試尋找 Python 程式設計者指定的例外處理程式。" -#: ../../extending/extending.rst:195 +#: ../../extending/extending.rst:61 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 " @@ -422,7 +129,7 @@ msgstr "" "息,在這種情況下這樣做是沒問題的。然而這一般來說並非必要,而且可能會導致錯誤" "原因資訊的遺失:大多數的操作都可能因為各種原因而失敗。)" -#: ../../extending/extending.rst:201 +#: ../../extending/extending.rst:67 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 " @@ -435,7 +142,7 @@ msgstr "" "給直譯器而想要完全是自己來處理它時(可能是要再嘗試其他東西,或者假裝什麼都沒" "出錯)。" -#: ../../extending/extending.rst:207 +#: ../../extending/extending.rst:73 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:" @@ -449,7 +156,7 @@ msgstr "" "`PyLong_FromLong`)都已經這麼做了,所以這個注意事項只和那些直接呼叫 :c:func:" "`malloc` 的函式有關。" -#: ../../extending/extending.rst:213 +#: ../../extending/extending.rst:79 msgid "" "Also note that, with the important exception of :c:func:`PyArg_ParseTuple` " "and friends, functions that return an integer status usually return a " @@ -460,7 +167,7 @@ msgstr "" "整數狀態的函式通常會回傳一個正值或 0 表示成功、回傳 ``-1`` 表示失敗,就像 " "Unix 系統呼叫一樣。" -#: ../../extending/extending.rst:217 +#: ../../extending/extending.rst:83 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 " @@ -469,7 +176,7 @@ msgstr "" "最後,在回傳錯誤指示器時要注意垃圾清理(透過對你已經建立的物件呼叫 :c:func:" "`Py_XDECREF` 或 :c:func:`Py_DECREF`)!" -#: ../../extending/extending.rst:221 +#: ../../extending/extending.rst:87 msgid "" "The choice of which exception to raise is entirely yours. There are " "predeclared C objects corresponding to all built-in Python exceptions, such " @@ -489,7 +196,7 @@ msgstr "" "的值必須在一個特定的範圍內或必須滿足其他條件,則可以使用 :c:data:" "`PyExc_ValueError`。" -#: ../../extending/extending.rst:231 +#: ../../extending/extending.rst:97 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 " @@ -498,11 +205,11 @@ msgstr "" "你也可以定義一個你的模組特有的新例外。最簡單的方式是在檔案的開頭宣告一個靜態" "全域物件變數: ::" -#: ../../extending/extending.rst:235 +#: ../../extending/extending.rst:101 msgid "static PyObject *SpamError = NULL;" msgstr "static PyObject *SpamError = NULL;" -#: ../../extending/extending.rst:237 +#: ../../extending/extending.rst:103 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`)::" @@ -510,11 +217,11 @@ msgstr "" "並透過在模組的 :c:data:`Py_mod_exec` 函式(:c:func:`!spam_module_exec`)中呼" "叫 :c:func:`PyErr_NewException` 來初始化它: ::" -#: ../../extending/extending.rst:240 +#: ../../extending/extending.rst:106 msgid "SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);" msgstr "SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);" -#: ../../extending/extending.rst:242 +#: ../../extending/extending.rst:108 msgid "" "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` " @@ -523,7 +230,7 @@ msgstr "" "由於 :c:data:`!SpamError` 是一個全域變數,每次模組被重新初始化、即 :c:data:" "`Py_mod_exec` 函式被呼叫時,它都會被覆寫。" -#: ../../extending/extending.rst:245 +#: ../../extending/extending.rst:111 msgid "" "For now, let's avoid the issue: we will block repeated initialization by " "raising an :py:exc:`ImportError`::" @@ -531,7 +238,7 @@ msgstr "" "目前,讓我們先避免這個問題:我們會透過引發 :py:exc:`ImportError` 來阻止重複初" "始化: ::" -#: ../../extending/extending.rst:248 +#: ../../extending/extending.rst:114 msgid "" "static PyObject *SpamError = NULL;\n" "\n" @@ -605,7 +312,7 @@ msgstr "" " return PyModuleDef_Init(&spam_module);\n" "}" -#: ../../extending/extending.rst:284 +#: ../../extending/extending.rst:150 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 " @@ -616,7 +323,7 @@ msgstr "" "exceptions`\\ 所述,:c:func:`PyErr_NewException` 函式可能會建立一個基底類別" "為 :exc:`Exception` 的類別(除非傳入另一個類別來代替 ``NULL``)。" -#: ../../extending/extending.rst:289 +#: ../../extending/extending.rst:155 msgid "" "Note also that the :c:data:`!SpamError` variable retains a reference to the " "newly created exception class; this is intentional! Since the exception " @@ -632,7 +339,7 @@ msgstr "" "如果它變成迷途指標,那產生例外的 C 程式碼可能會導致核心轉儲 (core dump) 或其" "他不預期的 side effect。" -#: ../../extending/extending.rst:296 +#: ../../extending/extending.rst:162 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` " @@ -643,13 +350,13 @@ msgstr "" "閉時,全域的 :c:data:`!SpamError` 變數也不會被垃圾回收。它會「洩漏」。然而," "我們確實有確保這每個行程最多只會發生一次。" -#: ../../extending/extending.rst:301 +#: ../../extending/extending.rst:167 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:304 +#: ../../extending/extending.rst:170 msgid "" "The :exc:`!spam.error` exception can be raised in your extension module " "using a call to :c:func:`PyErr_SetString` as shown below::" @@ -657,7 +364,7 @@ msgstr "" "可以在你的擴充模組中呼叫 :c:func:`PyErr_SetString` 來引發 :exc:`!spam.error` " "例外,如下所示: ::" -#: ../../extending/extending.rst:307 +#: ../../extending/extending.rst:173 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -691,410 +398,28 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:327 -msgid "Back to the Example" -msgstr "回到範例" - -#: ../../extending/extending.rst:329 -msgid "" -"Going back to our example function, you should now be able to understand " -"this statement::" -msgstr "回到我們的範例函式,現在你應該可以理解這個陳述式了: ::" - -#: ../../extending/extending.rst:332 -msgid "" -"if (!PyArg_ParseTuple(args, \"s\", &command))\n" -" return NULL;" -msgstr "" -"if (!PyArg_ParseTuple(args, \"s\", &command))\n" -" return NULL;" - -#: ../../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 " -"exception set by :c:func:`PyArg_ParseTuple`. Otherwise the string value of " -"the argument has been copied to the local variable :c:data:`!command`. This " -"is a pointer assignment and you are not supposed to modify the string to " -"which it points (so in Standard C, the variable :c:data:`!command` should " -"properly be declared as ``const char *command``)." -msgstr "" -"如果在引數串列中檢測到錯誤則會回傳 ``NULL``\\ (回傳物件指標之函式的錯誤指示" -"器),其依賴於 :c:func:`PyArg_ParseTuple` 設定的例外,否則引數的字串值會已被" -"複製到區域變數 :c:data:`!command` 中。這是一個指標賦值,你不應該修改它所指向" -"的字串(所以在標準 C 中,:c:data:`!command` 變數應該正確地被宣告為 ``const " -"char *command``)。" - -#: ../../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`::" -msgstr "" -"接下來的陳述式會呼叫 Unix 函式 :c:func:`system`,並將剛才從 :c:func:" -"`PyArg_ParseTuple` 得到的字串傳給它: ::" - -#: ../../extending/extending.rst:346 -msgid "sts = system(command);" -msgstr "sts = system(command);" - -#: ../../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:" -"`PyLong_FromLong`. ::" -msgstr "" -"我們的 :func:`!spam.system` 函式必須以 Python 物件的形式來回傳 :c:data:`!" -"sts` 的值。這是透過 :c:func:`PyLong_FromLong` 函式來達成。 ::" - -#: ../../extending/extending.rst:351 -msgid "return PyLong_FromLong(sts);" -msgstr "return PyLong_FromLong(sts);" - -#: ../../extending/extending.rst:353 -msgid "" -"In this case, it will return an integer object. (Yes, even integers are " -"objects on the heap in Python!)" -msgstr "" -"在這種情況下它會回傳一個整數物件。(是的,在 Python 中連整數也是堆積 (heap) " -"上的物件!)" - -#: ../../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 " -"``None``. You need this idiom to do so (which is implemented by the :c:" -"macro:`Py_RETURN_NONE` macro)::" -msgstr "" -"如果你有一個不回傳任何有用引數的 C 函式(一個回傳 :c:expr:`void` 的函式),對" -"應的 Python 函式必須回傳 ``None``。你需要以下這個慣例來達成(由 :c:macro:" -"`Py_RETURN_NONE` 巨集實作): ::" - -#: ../../extending/extending.rst:361 -msgid "" -"Py_INCREF(Py_None);\n" -"return Py_None;" -msgstr "" -"Py_INCREF(Py_None);\n" -"return Py_None;" - -#: ../../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 " -"\"error\" in most contexts, as we have seen." -msgstr "" -":c:data:`Py_None` 是特殊 Python 物件 ``None`` 的 C 名稱。它是一個真正的 " -"Python 物件而不是一個 ``NULL`` 指標,在大多數的情況下它的意思是「錯誤」,如我" -"們所見過的那樣。" - -#: ../../extending/extending.rst:372 -msgid "The Module's Method Table and Initialization Function" -msgstr "模組的方法表和初始化函式" - -#: ../../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\"::" -msgstr "" -"我承諾過要展示 :c:func:`!spam_system` 是如何從 Python 程式中呼叫的。首先,我" -"們需要在「方法表」中列出它的名稱和位址: ::" - -#: ../../extending/extending.rst:377 -msgid "" -"static PyMethodDef spam_methods[] = {\n" -" ...\n" -" {\"system\", spam_system, METH_VARARGS,\n" -" \"Execute a shell command.\"},\n" -" ...\n" -" {NULL, NULL, 0, NULL} /* Sentinel */\n" -"};" -msgstr "" -"static PyMethodDef spam_methods[] = {\n" -" ...\n" -" {\"system\", spam_system, METH_VARARGS,\n" -" \"Execute a shell command.\"},\n" -" ...\n" -" {NULL, NULL, 0, NULL} /* Sentinel */\n" -"};" - -#: ../../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 " -"normally always be ``METH_VARARGS`` or ``METH_VARARGS | METH_KEYWORDS``; a " -"value of ``0`` means that an obsolete variant of :c:func:`PyArg_ParseTuple` " -"is used." -msgstr "" -"請注意第三個項目 (``METH_VARARGS``)。這是一個告訴直譯器 C 函式之呼叫方式的旗" -"標。通常應該是 ``METH_VARARGS`` 或 ``METH_VARARGS | METH_KEYWORDS``;``0`` 表" -"示是使用 :c:func:`PyArg_ParseTuple` 的一個過時變體。" - -#: ../../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:" -"func:`PyArg_ParseTuple`; more information on this function is provided below." -msgstr "" -"當只使用 ``METH_VARARGS`` 時,函式應預期 Python 層級的參數是以元組形式傳入且" -"能夠接受以 :c:func:`PyArg_ParseTuple` 進行剖析;有關此函式的更多資訊將在下面" -"提供。" - -#: ../../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 " -"should accept a third ``PyObject *`` parameter which will be a dictionary of " -"keywords. Use :c:func:`PyArg_ParseTupleAndKeywords` to parse the arguments " -"to such a function." -msgstr "" -"如果要將關鍵字引數傳給函式,可以在第三個欄位設定 :c:macro:`METH_KEYWORDS` 位" -"元。在這種情況下,C 函式應該要能接受第三個 ``PyObject *`` 參數,這個參數將會" -"是關鍵字的字典。可使用 :c:func:`PyArg_ParseTupleAndKeywords` 來剖析這種函式的" -"引數。" - -#: ../../extending/extending.rst:400 -msgid "" -"The method table must be referenced in the module definition structure::" -msgstr "方法表必須在模組定義結構中被參照: ::" - -#: ../../extending/extending.rst:402 -msgid "" -"static struct PyModuleDef spam_module = {\n" -" ...\n" -" .m_methods = spam_methods,\n" -" ...\n" -"};" -msgstr "" -"static struct PyModuleDef spam_module = {\n" -" ...\n" -" .m_methods = spam_methods,\n" -" ...\n" -"};" - -#: ../../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:" -"`!PyInit_name`, where *name* is the name of the module, and should be the " -"only non-\\ ``static`` item defined in the module file::" -msgstr "" -"反過來說,這個結構必須在模組的初始化函式中被傳給直譯器。初始化函式必須被命名" -"為 :c:func:`!PyInit_name`,其中 *name* 是模組的名稱,且應該是模組檔案中唯一定" -"義的非「靜態 (``static``)」項目: ::" - -#: ../../extending/extending.rst:413 -msgid "" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" -"{\n" -" return PyModuleDef_Init(&spam_module);\n" -"}" -msgstr "" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" -"{\n" -" return PyModuleDef_Init(&spam_module);\n" -"}" - -#: ../../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 " -"platform, and for C++ declares the function as ``extern \"C\"``." -msgstr "" -"請注意,:c:macro:`PyMODINIT_FUNC` 宣告函式的回傳型別為 ``PyObject *``、宣告平" -"台所需的任何特殊連結宣告、並針對 C++ 宣告函式為 ``extern \"C\"``。" - -#: ../../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 " -"Python.) A pointer to the module definition must be returned via :c:func:" -"`PyModuleDef_Init`, so that the import machinery can create the module and " -"store it in ``sys.modules``." -msgstr "" -"當每個直譯器首次 import 其 :mod:`!spam` 模組時,就會呼叫 :c:func:`!" -"PyInit_spam`。(關於嵌入 Python 的說明請見下方。)必須透過 :c:func:" -"`PyModuleDef_Init` 回傳一個指向模組定義的指標,好讓 import 機制可以建立模組並" -"將其儲存在 ``sys.modules`` 中。" - -#: ../../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` " -"table. To add the module to the initialization table, use :c:func:" -"`PyImport_AppendInittab`, optionally followed by an import of the module::" -msgstr "" -"嵌入 Python 時,除非在 :c:data:`PyImport_Inittab` 表中有相關條目,否則不會自" -"動呼叫 :c:func:`!PyInit_spam` 函式。要將模組加入初始化表,請使用 :c:func:" -"`PyImport_AppendInittab` 並在隨後選擇性地將該模組引入: ::" - -#: ../../extending/extending.rst:433 -msgid "" -"#define PY_SSIZE_T_CLEAN\n" -"#include \n" -"\n" -"int\n" -"main(int argc, char *argv[])\n" -"{\n" -" PyStatus status;\n" -" PyConfig config;\n" -" PyConfig_InitPythonConfig(&config);\n" -"\n" -" /* Add a built-in module, before Py_Initialize */\n" -" if (PyImport_AppendInittab(\"spam\", PyInit_spam) == -1) {\n" -" fprintf(stderr, \"Error: could not extend in-built modules " -"table\\n\");\n" -" exit(1);\n" -" }\n" -"\n" -" /* Pass argv[0] to the Python interpreter */\n" -" status = PyConfig_SetBytesString(&config, &config.program_name, " -"argv[0]);\n" -" if (PyStatus_Exception(status)) {\n" -" goto exception;\n" -" }\n" -"\n" -" /* Initialize the Python interpreter. Required.\n" -" If this step fails, it will be a fatal error. */\n" -" status = Py_InitializeFromConfig(&config);\n" -" if (PyStatus_Exception(status)) {\n" -" goto exception;\n" -" }\n" -" PyConfig_Clear(&config);\n" -"\n" -" /* Optionally import the module; alternatively,\n" -" import can be deferred until the embedded script\n" -" imports it. */\n" -" PyObject *pmodule = PyImport_ImportModule(\"spam\");\n" -" if (!pmodule) {\n" -" PyErr_Print();\n" -" fprintf(stderr, \"Error: could not import module 'spam'\\n\");\n" -" }\n" -"\n" -" // ... use Python C API here ...\n" -"\n" -" return 0;\n" -"\n" -" exception:\n" -" PyConfig_Clear(&config);\n" -" Py_ExitStatusException(status);\n" -"}" -msgstr "" -"#define PY_SSIZE_T_CLEAN\n" -"#include \n" -"\n" -"int\n" -"main(int argc, char *argv[])\n" -"{\n" -" PyStatus status;\n" -" PyConfig config;\n" -" PyConfig_InitPythonConfig(&config);\n" -"\n" -" /* 在 Py_Initialize 之前加入內建模組 */\n" -" if (PyImport_AppendInittab(\"spam\", PyInit_spam) == -1) {\n" -" fprintf(stderr, \"Error: could not extend in-built modules " -"table\\n\");\n" -" exit(1);\n" -" }\n" -"\n" -" /* 將 argv[0] 傳給 Python 直譯器 */\n" -" status = PyConfig_SetBytesString(&config, &config.program_name, " -"argv[0]);\n" -" if (PyStatus_Exception(status)) {\n" -" goto exception;\n" -" }\n" -"\n" -" /* 初始化 Python 直譯器。這會是必要的。\n" -" 如果此步驟失敗就會導致嚴重錯誤。*/\n" -" status = Py_InitializeFromConfig(&config);\n" -" if (PyStatus_Exception(status)) {\n" -" goto exception;\n" -" }\n" -" PyConfig_Clear(&config);\n" -"\n" -" /* 可選擇引入模組;或者\n" -" 可以延遲引入,直至嵌入式腳本\n" -" 將其引入。*/\n" -" PyObject *pmodule = PyImport_ImportModule(\"spam\");\n" -" if (!pmodule) {\n" -" PyErr_Print();\n" -" fprintf(stderr, \"Error: could not import module 'spam'\\n\");\n" -" }\n" -"\n" -" // ... 在此使用 Python C API ...\n" -"\n" -" return 0;\n" -"\n" -" exception:\n" -" PyConfig_Clear(&config);\n" -" Py_ExitStatusException(status);\n" -"}" - -#: ../../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 " -"removing entries from ``sys.modules`` or importing compiled modules into " -"multiple interpreters within a process (or following a :c:func:`fork` " -"without an intervening :c:func:`exec`). If module state is not yet fully :" -"ref:`isolated `, authors should consider marking " -"the module as having no support for subinterpreters (via :c:macro:" -"`Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED`)." -msgstr "" -"如果你宣告了一個全域變數或區域靜態變數,模組在重新初始化時可能會遇到非預期的" -"副作用,例如從 ``sys.modules`` 中移除條目或在一個行程內將已編譯的模組引入多個" -"直譯器中(或在沒有中間 :c:func:`exec` 的情況下進行 :c:func:`fork`)。如果模組" -"狀態尚未完全被\\ :ref:`隔離 `,作者應考慮將模組標" -"記為不支援子直譯器(透過 :c:macro:" -"`Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED`)。" - -#: ../../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 " -"template or simply read as an example." -msgstr "" -"Python 原始碼發行版本中包含了一個更實質的範例模組 :file:`Modules/xxlimited." -"c`。這個檔案可以當作模板使用,也可以簡單地當作範例來閱讀。" - -#: ../../extending/extending.rst:500 -msgid "Compilation and Linkage" -msgstr "編譯與連結" - -#: ../../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 " -"loading, the details may depend on the style of dynamic loading your system " -"uses; see the chapters about building extension modules (chapter :ref:" -"`building`) and additional information that pertains only to building on " -"Windows (chapter :ref:`building-on-windows`) for more information about this." +#: ../../extending/extending.rst:193 +msgid "Embedding an extension" msgstr "" -"在你可以使用你的新擴充之前還有兩件事要做:編譯和連結它到 Python 系統。如果你" -"使用動態載入,細節可能取決於你系統所使用的動態載入方式;請參閱關於建置擴充模" -"組的章節(:ref:`building`)以及僅與在 Windows 上建置有關的額外資訊(:ref:" -"`building-on-windows`)以了解更多。" -#: ../../extending/extending.rst:509 +#: ../../extending/extending.rst:195 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 " -"configuration setup and rebuild the interpreter. Luckily, this is very " -"simple on Unix: just place your file (:file:`spammodule.c` for example) in " +"If you want to make your module a permanent part of the Python interpreter, " +"you will have to change the configuration setup and rebuild the " +"interpreter. On Unix, place your file (:file:`spammodule.c` for example) in " "the :file:`Modules/` directory of an unpacked source distribution, add a " "line to the file :file:`Modules/Setup.local` describing your file:" msgstr "" -"如果你無法使用動態載入,或者你想讓你的模組成為 Python 直譯器的永久部分,你就" -"必須更改組態設定並重新建置直譯器。幸運的是,在 Unix 上這非常簡單:只需將你的" -"檔案(例如 :file:`spammodule.c`)放在已解壓原始碼發行版本的 :file:`Modules/` " -"目錄中,在 :file:`Modules/Setup.local` 檔案中新增描述你的檔案的一列:" +"如果你想讓你的模組成為 Python 直譯器的永久部分,你就必須更改組態設定並重新建" +"置直譯器。在 Unix 上,將你的檔案(例如 :file:`spammodule.c`)放在已解壓原始碼" +"發行版本的 :file:`Modules/` 目錄中,在 :file:`Modules/Setup.local` 檔案中新增" +"描述你的檔案的一列:" -#: ../../extending/extending.rst:516 +#: ../../extending/extending.rst:202 msgid "spam spammodule.o" msgstr "spam spammodule.o" -#: ../../extending/extending.rst:520 +#: ../../extending/extending.rst:206 msgid "" "and rebuild the interpreter by running :program:`make` in the toplevel " "directory. You can also run :program:`make` in the :file:`Modules/` " @@ -1107,24 +432,24 @@ msgstr "" "`make` Makefile」來重新建置 :file:`Makefile`。(每次你修改 :file:`Setup` 檔案" "時都需要這樣做。)" -#: ../../extending/extending.rst:526 +#: ../../extending/extending.rst:212 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:529 +#: ../../extending/extending.rst:215 msgid "spam spammodule.o -lX11" msgstr "spam spammodule.o -lX11" -#: ../../extending/extending.rst:537 +#: ../../extending/extending.rst:223 msgid "Calling Python Functions from C" msgstr "從 C 呼叫 Python 函式" -#: ../../extending/extending.rst:539 +#: ../../extending/extending.rst:225 msgid "" -"So far we have concentrated on making C functions callable from Python. The " +"The tutorial concentrated on making C functions callable from Python. The " "reverse is also useful: calling Python functions from C. This is especially " "the case for libraries that support so-called \"callback\" functions. If a " "C interface makes use of callbacks, the equivalent Python often needs to " @@ -1132,12 +457,12 @@ msgid "" "will require calling the Python callback functions from a C callback. Other " "uses are also imaginable." msgstr "" -"到目前為止,我們一直專注於讓 C 函式可以從 Python 呼叫。反過來也很有用:從 C " -"呼叫 Python 函式。對於支援所謂「回呼 (callback)」函式的函式庫尤其如此。如果一" -"個 C 介面使用了回呼,等價的 Python 通常就需要為 Python 程式設計者提供一個回呼" -"機制;其實作將需要從 C 回呼中呼叫 Python 回呼函式。其他用途也是可以想像的。" +"前面的教學著重於讓 C 函式可以從 Python 呼叫。反過來也很有用:從 C 呼叫 " +"Python 函式。對於支援所謂「回呼 (callback)」函式的函式庫尤其如此。如果一個 C " +"介面使用了回呼,等價的 Python 通常就需要為 Python 程式設計者提供一個回呼機" +"制;其實作將需要從 C 回呼中呼叫 Python 回呼函式。其他用途也是可以想像的。" -#: ../../extending/extending.rst:547 +#: ../../extending/extending.rst:233 msgid "" "Fortunately, the Python interpreter is easily called recursively, and there " "is a standard interface to call a Python function. (If you're interested in " @@ -1148,7 +473,7 @@ msgstr "" "Python 函式。(如果你有興趣了解如何以特定字串作為輸入來呼叫 Python 剖析器,請" "參閱 :ref:`veryhigh`。)" -#: ../../extending/extending.rst:551 +#: ../../extending/extending.rst:237 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 " @@ -1163,7 +488,7 @@ msgstr "" "`Py_INCREF`!)--- 或任何你認為合適的地方。例如,以下函式可能是模組定義的一部" "分: ::" -#: ../../extending/extending.rst:558 +#: ../../extending/extending.rst:244 msgid "" "static PyObject *my_callback = NULL;\n" "\n" @@ -1213,18 +538,18 @@ msgstr "" " return result;\n" "}" -#: ../../extending/extending.rst:581 +#: ../../extending/extending.rst:267 msgid "" "This function must be registered with the interpreter using the :c:macro:" -"`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The :" -"c:func:`PyArg_ParseTuple` function and its arguments are documented in " -"section :ref:`parsetuple`." +"`METH_VARARGS` flag in :c:type:`PyMethodDef.ml_flags`. The :c:func:" +"`PyArg_ParseTuple` function and its arguments are documented in section :ref:" +"`parsetuple`." msgstr "" -"這個函式必須使用 :c:macro:`METH_VARARGS` 旗標向直譯器註冊;這在 :ref:" -"`methodtable` 章節中有描述。:c:func:`PyArg_ParseTuple` 函式及其引數在 :ref:" -"`parsetuple` 章節中有文件說明。" +"這個函式必須在 :c:type:`PyMethodDef.ml_flags` 中使用 :c:macro:`METH_VARARGS` " +"旗標向直譯器註冊。:c:func:`PyArg_ParseTuple` 函式及其引數" +"在 :ref:`parsetuple` 章節中有文件說明。" -#: ../../extending/extending.rst:586 +#: ../../extending/extending.rst:272 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`` " @@ -1235,7 +560,7 @@ msgstr "" "計數,而且在遇到 ``NULL`` 指標時是安全的(但請注意在這個情境中 *temp* 不會是 " "``NULL``)。更多資訊請參閱\\ :ref:`refcounts`\\ 章節。" -#: ../../extending/extending.rst:593 +#: ../../extending/extending.rst:279 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 " @@ -1253,7 +578,7 @@ msgstr "" "`Py_BuildValue` 會在其格式字串由括號之間的零個或多個格式碼組成時回傳一個元" "組。例如: ::" -#: ../../extending/extending.rst:602 +#: ../../extending/extending.rst:288 msgid "" "int arg;\n" "PyObject *arglist;\n" @@ -1277,7 +602,7 @@ msgstr "" "result = PyObject_CallObject(my_callback, arglist);\n" "Py_DECREF(arglist);" -#: ../../extending/extending.rst:613 +#: ../../extending/extending.rst:299 msgid "" ":c:func:`PyObject_CallObject` returns a Python object pointer: this is the " "return value of the Python function. :c:func:`PyObject_CallObject` is " @@ -1290,7 +615,7 @@ msgstr "" "例中,一個新的元組被建立來作為引數串列,並在 :c:func:`PyObject_CallObject` 呼" "叫之後立即被 :c:func:`Py_DECREF`。" -#: ../../extending/extending.rst:620 +#: ../../extending/extending.rst:306 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 " @@ -1303,7 +628,7 @@ msgstr "" "則你應該以某種方式對結果呼叫 :c:func:`Py_DECREF`,即使(尤其是!)你對其值不" "感興趣。" -#: ../../extending/extending.rst:626 +#: ../../extending/extending.rst:312 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 " @@ -1319,7 +644,7 @@ msgstr "" "就可以印出堆疊追蹤,或者呼叫端的 Python 程式碼可以處理例外。如果這是不可能或" "不需要的,應該呼叫 :c:func:`PyErr_Clear` 來清除例外。例如: ::" -#: ../../extending/extending.rst:634 +#: ../../extending/extending.rst:320 msgid "" "if (result == NULL)\n" " return NULL; /* Pass error back */\n" @@ -1331,7 +656,7 @@ msgstr "" "...use result...\n" "Py_DECREF(result);" -#: ../../extending/extending.rst:639 +#: ../../extending/extending.rst:325 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 " @@ -1348,7 +673,7 @@ msgstr "" "下,你可能需要建構一個新的元組來作為引數串列傳遞。最簡單的方式是呼叫 :c:func:" "`Py_BuildValue`。例如,如果你想傳遞一個整數事件碼,你可以使用以下程式碼: ::" -#: ../../extending/extending.rst:648 +#: ../../extending/extending.rst:334 msgid "" "PyObject *arglist;\n" "...\n" @@ -1370,7 +695,7 @@ msgstr "" "/* 這裡可以使用 result */\n" "Py_DECREF(result);" -#: ../../extending/extending.rst:658 +#: ../../extending/extending.rst:344 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 " @@ -1381,7 +706,7 @@ msgstr "" "意嚴格來說這段程式碼並不完整::c:func:`Py_BuildValue` 可能會耗盡記憶體,這應" "該要被檢查。" -#: ../../extending/extending.rst:662 +#: ../../extending/extending.rst:348 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 " @@ -1390,7 +715,7 @@ msgstr "" "你也可以使用 :c:func:`PyObject_Call` 來呼叫帶有關鍵字引數的函式,它支援引數和" "關鍵字引數。如同上面的範例,我們使用 :c:func:`Py_BuildValue` 來建構字典。 ::" -#: ../../extending/extending.rst:666 +#: ../../extending/extending.rst:352 msgid "" "PyObject *dict;\n" "...\n" @@ -1412,19 +737,31 @@ msgstr "" "/* 這裡可以使用 result */\n" "Py_DECREF(result);" -#: ../../extending/extending.rst:680 +#: ../../extending/extending.rst:368 msgid "Extracting Parameters in Extension Functions" msgstr "擴充函式中的參數提取" -#: ../../extending/extending.rst:684 -msgid "The :c:func:`PyArg_ParseTuple` function is declared as follows::" -msgstr ":c:func:`PyArg_ParseTuple` 函式的宣告如下: ::" +#: ../../extending/extending.rst:370 +msgid "" +"The :ref:`tutorial ` uses a \":c:data:`METH_O`\" " +"function, which is limited to a single Python argument. If you want more, " +"you can use :c:data:`METH_VARARGS` instead. With this flag, the C function " +"will receive a :py:class:`tuple` of arguments instead of a single object." +msgstr "" + +#: ../../extending/extending.rst:376 +msgid "" +"For unpacking the tuple, CPython provides the :c:func:`PyArg_ParseTuple` " +"function, declared as follows::" +msgstr "" +"為了拆解 tuple,CPython 提供了 :c:func:`PyArg_ParseTuple` 函式,其宣告如" +"下: ::" -#: ../../extending/extending.rst:686 +#: ../../extending/extending.rst:379 msgid "int PyArg_ParseTuple(PyObject *arg, const char *format, ...);" msgstr "int PyArg_ParseTuple(PyObject *arg, const char *format, ...);" -#: ../../extending/extending.rst:688 +#: ../../extending/extending.rst:381 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, " @@ -1436,7 +773,33 @@ msgstr "" "*format* 引數必須是一個格式字串,其語法在 Python/C API 參考手冊中的\\ :ref:" "`arg-parsing`\\ 有說明。其餘引數必須是變數的位址,其型別由格式字串決定。" -#: ../../extending/extending.rst:694 +#: ../../extending/extending.rst:387 +msgid "" +"For example, to receive a single Python :py:class:`str` object and turn it " +"into a C buffer, you would use ``\"s\"`` as the format string::" +msgstr "" + +#: ../../extending/extending.rst:390 +msgid "" +"const char *command;\n" +"if (!PyArg_ParseTuple(args, \"s\", &command)) {\n" +" return NULL;\n" +"}" +msgstr "" +"const char *command;\n" +"if (!PyArg_ParseTuple(args, \"s\", &command)) {\n" +" return NULL;\n" +"}" + +#: ../../extending/extending.rst:395 +msgid "" +"If an error is detected in the argument list, :c:func:`!PyArg_ParseTuple` " +"returns ``NULL`` (the error indicator for functions returning object " +"pointers); your function may return ``NULL``, relying on the exception set " +"by :c:func:`PyArg_ParseTuple`." +msgstr "" + +#: ../../extending/extending.rst:400 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 " @@ -1447,7 +810,7 @@ msgstr "" "別,但它無法檢查傳遞給呼叫的 C 變數位址是否有效:如果你在那裡犯了錯誤,你的程" "式碼可能會崩潰,或至少覆寫記憶體中的隨機位元。所以要小心!" -#: ../../extending/extending.rst:699 +#: ../../extending/extending.rst:405 msgid "" "Note that any Python object references which are provided to the caller are " "*borrowed* references; do not decrement their reference count!" @@ -1455,11 +818,15 @@ msgstr "" "請注意,提供給呼叫者的任何 Python 物件參照都是\\ *借用*\\ 參照;不要遞減它們" "的參照計數!" -#: ../../extending/extending.rst:702 +#: ../../extending/extending.rst:408 msgid "Some example calls::" msgstr "一些呼叫範例: ::" -#: ../../extending/extending.rst:709 +#: ../../extending/extending.rst:410 ../../extending/extending.rst:1003 +msgid "#include " +msgstr "#include " + +#: ../../extending/extending.rst:414 msgid "" "int ok;\n" "int i, j;\n" @@ -1479,7 +846,7 @@ msgstr "" "ok = PyArg_ParseTuple(args, \"\"); /* 沒有引數 */\n" " /* Python 呼叫:f() */" -#: ../../extending/extending.rst:720 +#: ../../extending/extending.rst:425 msgid "" "ok = PyArg_ParseTuple(args, \"s\", &s); /* A string */\n" " /* Possible Python call: f('whoops!') */" @@ -1487,7 +854,7 @@ msgstr "" "ok = PyArg_ParseTuple(args, \"s\", &s); /* 一個字串 */\n" " /* 可能的 Python 呼叫:f('whoops!') */" -#: ../../extending/extending.rst:725 +#: ../../extending/extending.rst:430 msgid "" "ok = PyArg_ParseTuple(args, \"lls\", &k, &l, &s); /* Two longs and a string " "*/\n" @@ -1497,7 +864,7 @@ msgstr "" "*/\n" " /* 可能的 Python 呼叫:f(1, 2, 'three') */" -#: ../../extending/extending.rst:730 +#: ../../extending/extending.rst:435 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" @@ -1507,7 +874,7 @@ msgstr "" " /* 一對 int 和一個字串,其大小也會被回傳 */\n" " /* 可能的 Python 呼叫:f((1, 2), 'three') */" -#: ../../extending/extending.rst:736 +#: ../../extending/extending.rst:441 msgid "" "{\n" " const char *file;\n" @@ -1533,7 +900,7 @@ msgstr "" " f('spam', 'wb', 100000) */\n" "}" -#: ../../extending/extending.rst:750 +#: ../../extending/extending.rst:455 msgid "" "{\n" " int left, top, right, bottom, h, v;\n" @@ -1553,7 +920,7 @@ msgstr "" " f(((0, 0), (400, 300)), (10, 10)) */\n" "}" -#: ../../extending/extending.rst:761 +#: ../../extending/extending.rst:466 msgid "" "{\n" " Py_complex c;\n" @@ -1569,16 +936,34 @@ msgstr "" " /* 可能的 Python 呼叫:myfunction(1+2j) */\n" "}" -#: ../../extending/extending.rst:772 +#: ../../extending/extending.rst:477 msgid "Keyword Parameters for Extension Functions" msgstr "擴充函式的關鍵字參數" -#: ../../extending/extending.rst:776 +#: ../../extending/extending.rst:479 +msgid "" +"If you also want your function to accept :term:`keyword arguments `, use the :c:data:`METH_KEYWORDS` flag in combination with :c:data:" +"`METH_VARARGS`. (:c:data:`!METH_KEYWORDS` can also be used with other flags; " +"see its documentation for the allowed combinations.)" +msgstr "" + +#: ../../extending/extending.rst:485 +msgid "" +"In this case, the C function should accept a third ``PyObject *`` parameter " +"which will be a dictionary of keywords. Use :c:func:" +"`PyArg_ParseTupleAndKeywords` to parse the arguments to such a function." +msgstr "" +"在這種情況下,C 函式應該要能接受第三個 ``PyObject *`` 參數,這個參數將會是關" +"鍵字的字典。可使用 :c:func:`PyArg_ParseTupleAndKeywords` 來剖析這種函式的引" +"數。" + +#: ../../extending/extending.rst:492 msgid "" "The :c:func:`PyArg_ParseTupleAndKeywords` function is declared as follows::" msgstr ":c:func:`PyArg_ParseTupleAndKeywords` 函式的宣告如下: ::" -#: ../../extending/extending.rst:778 +#: ../../extending/extending.rst:494 msgid "" "int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,\n" " const char *format, char * const " @@ -1588,7 +973,7 @@ msgstr "" " const char *format, char * const " "*kwlist, ...);" -#: ../../extending/extending.rst:781 +#: ../../extending/extending.rst:497 msgid "" "The *arg* and *format* parameters are identical to those of the :c:func:" "`PyArg_ParseTuple` function. The *kwdict* parameter is the dictionary of " @@ -1605,7 +990,7 @@ msgstr "" "的型別資訊進行配對。成功時,:c:func:`PyArg_ParseTupleAndKeywords` 會回傳 " "true,否則回傳 false 並引發適當的例外。" -#: ../../extending/extending.rst:791 +#: ../../extending/extending.rst:507 msgid "" "Nested tuples cannot be parsed when using keyword arguments! Keyword " "parameters passed in which are not present in the *kwlist* will cause :exc:" @@ -1614,7 +999,7 @@ msgstr "" "使用關鍵字引數時無法剖析巢狀的 tuple!傳入的關鍵字參數如果不在 *kwlist* 中," "將會引發 :exc:`TypeError`。" -#: ../../extending/extending.rst:797 +#: ../../extending/extending.rst:513 msgid "" "Here is an example module which uses keywords, based on an example by Geoff " "Philbrick (philbrick@hks.com)::" @@ -1622,7 +1007,7 @@ msgstr "" "以下是一個使用關鍵字的範例模組,基於 Geoff Philbrick (philbrick@hks.com) 的範" "例: ::" -#: ../../extending/extending.rst:800 +#: ../../extending/extending.rst:516 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1659,20 +1044,7 @@ msgid "" "METH_KEYWORDS,\n" " \"Print a lovely skit to standard output.\"},\n" " {NULL, NULL, 0, NULL} /* sentinel */\n" -"};\n" -"\n" -"static struct PyModuleDef keywdarg_module = {\n" -" .m_base = PyModuleDef_HEAD_INIT,\n" -" .m_name = \"keywdarg\",\n" -" .m_size = 0,\n" -" .m_methods = keywdarg_methods,\n" -"};\n" -"\n" -"PyMODINIT_FUNC\n" -"PyInit_keywdarg(void)\n" -"{\n" -" return PyModuleDef_Init(&keywdarg_module);\n" -"}" +"};" msgstr "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1709,36 +1081,23 @@ msgstr "" "METH_KEYWORDS,\n" " \"Print a lovely skit to standard output.\"},\n" " {NULL, NULL, 0, NULL} /* 哨兵 */\n" -"};\n" -"\n" -"static struct PyModuleDef keywdarg_module = {\n" -" .m_base = PyModuleDef_HEAD_INIT,\n" -" .m_name = \"keywdarg\",\n" -" .m_size = 0,\n" -" .m_methods = keywdarg_methods,\n" -"};\n" -"\n" -"PyMODINIT_FUNC\n" -"PyInit_keywdarg(void)\n" -"{\n" -" return PyModuleDef_Init(&keywdarg_module);\n" -"}" +"};" -#: ../../extending/extending.rst:851 +#: ../../extending/extending.rst:554 msgid "Building Arbitrary Values" msgstr "建構任意值" -#: ../../extending/extending.rst:853 +#: ../../extending/extending.rst:556 msgid "" "This function is the counterpart to :c:func:`PyArg_ParseTuple`. It is " "declared as follows::" msgstr "此函式是 :c:func:`PyArg_ParseTuple` 的對應函式。它的宣告如下: ::" -#: ../../extending/extending.rst:856 +#: ../../extending/extending.rst:559 msgid "PyObject *Py_BuildValue(const char *format, ...);" msgstr "PyObject *Py_BuildValue(const char *format, ...);" -#: ../../extending/extending.rst:858 +#: ../../extending/extending.rst:561 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, " @@ -1749,7 +1108,7 @@ msgstr "" "函式的輸入,而非輸出)不能是指標,只能是值。它會回傳一個新的 Python 物件,適" "合從被 Python 呼叫的 C 函式中回傳。" -#: ../../extending/extending.rst:863 +#: ../../extending/extending.rst:566 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 " @@ -1767,12 +1126,12 @@ msgstr "" "好包含一個格式單元,它會回傳該格式單元所描述的任何物件。要強制它回傳大小為 0 " "或 1 的 tuple,請將格式字串加上括號。" -#: ../../extending/extending.rst:871 +#: ../../extending/extending.rst:574 msgid "" "Examples (to the left the call, to the right the resulting Python value):" msgstr "範例(左邊是呼叫,右邊是結果的 Python 值):" -#: ../../extending/extending.rst:873 +#: ../../extending/extending.rst:576 msgid "" "Py_BuildValue(\"\") None\n" "Py_BuildValue(\"i\", 123) 123\n" @@ -1810,11 +1169,11 @@ msgstr "" "Py_BuildValue(\"((ii)(ii)) (ii)\",\n" " 1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))" -#: ../../extending/extending.rst:897 +#: ../../extending/extending.rst:600 msgid "Reference Counts" msgstr "參照計數" -#: ../../extending/extending.rst:899 +#: ../../extending/extending.rst:602 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 " @@ -1826,7 +1185,7 @@ msgstr "" "中,這是使用 :c:func:`malloc` 和 :c:func:`free` 函式來完成的。在 C++ 中,運算" "子 ``new`` 和 ``delete`` 的意義基本相同,我們將以下的討論限制在 C 的情況。" -#: ../../extending/extending.rst:905 +#: ../../extending/extending.rst:608 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:" @@ -1849,7 +1208,7 @@ msgstr "" "的記憶體 (using freed memory)`。它的後果和引用未初始化的資料一樣糟糕 --- " "core dump、錯誤的結果、神秘的當機。" -#: ../../extending/extending.rst:916 +#: ../../extending/extending.rst:619 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, " @@ -1874,7 +1233,7 @@ msgstr "" "長時間執行程序中才會變得明顯。因此,透過採用能最小化這類錯誤的編碼慣例或策略" "來防止洩漏發生是很重要的。" -#: ../../extending/extending.rst:929 +#: ../../extending/extending.rst:632 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. " @@ -1890,7 +1249,7 @@ msgstr "" "參照被儲存在某處時計數器遞增,當一個指向它的參照被刪除時計數器遞減。當計數器" "歸零時,表示該物件的最後一個參照已被刪除,物件便被釋放。" -#: ../../extending/extending.rst:937 +#: ../../extending/extending.rst:640 msgid "" "An alternative strategy is called :dfn:`automatic garbage collection`. " "(Sometimes, reference counting is also referred to as a garbage collection " @@ -1914,7 +1273,7 @@ msgstr "" "許有一天會有足夠可移植的 C 自動垃圾回收器可用。在那之前,我們只能與參照計數共" "存。" -#: ../../extending/extending.rst:949 +#: ../../extending/extending.rst:652 msgid "" "While Python uses the traditional reference counting implementation, it also " "offers a cycle detector that works to detect reference cycles. This allows " @@ -1934,7 +1293,7 @@ msgstr "" "的任何物件的記憶體,或從循環中的物件所參照的記憶體,即使除了循環本身之外已經" "沒有其他的參照了。" -#: ../../extending/extending.rst:960 +#: ../../extending/extending.rst:663 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." @@ -1944,11 +1303,11 @@ msgstr "" "循環偵測器能夠偵測垃圾循環並回收它們。:mod:`gc` 模組公開了一種執行偵測器的方" "式(:func:`~gc.collect` 函式),以及配置介面和在 runtime 停用偵測器的功能。" -#: ../../extending/extending.rst:969 +#: ../../extending/extending.rst:672 msgid "Reference Counting in Python" msgstr "Python 中的參照計數" -#: ../../extending/extending.rst:971 +#: ../../extending/extending.rst:674 msgid "" "There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle " "the incrementing and decrementing of the reference count. :c:func:" @@ -1963,7 +1322,7 @@ msgstr "" "c:func:`free` --- 而是透過物件的\\ :dfn:`型別物件 (type object)` 中的函式指標" "進行呼叫。為此目的(以及其他目的),每個物件也包含一個指向其型別物件的指標。" -#: ../../extending/extending.rst:978 +#: ../../extending/extending.rst:681 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 " @@ -1982,19 +1341,21 @@ msgstr "" "可以被轉移。處置一個被擁有參照有三種方式:傳遞它、儲存它、或呼叫 :c:func:" "`Py_DECREF`。忘記處置一個被擁有的參照會造成記憶體洩漏。" -#: ../../extending/extending.rst:987 +#: ../../extending/extending.rst:690 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 " -"must not hold on to the object longer than the owner from which it was " -"borrowed. Using a borrowed reference after the owner has disposed of it " -"risks using freed memory and should be avoided completely [#]_." +"It is also possible to :dfn:`borrow` [#borrow]_ a reference to an object. " +"The borrower of a reference should not call :c:func:`Py_DECREF`. The " +"borrower must not hold on to the object longer than the owner from which it " +"was borrowed. Using a borrowed reference after the owner has disposed of it " +"risks using freed memory and should be avoided completely [#dont-check-" +"refcount]_." msgstr "" -"也可以\\ :dfn:`借用 (borrow)` [#]_ 一個物件的參照。借用參照的人不應呼叫 :c:" -"func:`Py_DECREF`。借用者持有物件的時間不能超過借出參照的擁有者。在擁有者已經" -"處置了參照之後使用借用參照,會有使用已釋放記憶體的風險,應該完全避免 [#]_。" +"也可以\\ :dfn:`借用 (borrow)` [#borrow]_ 一個物件的參照。借用參照的人不應呼" +"叫 :c:func:`Py_DECREF`。借用者持有物件的時間不能超過借出參照的擁有者。在擁有" +"者已經處置了參照之後使用借用參照,會有使用已釋放記憶體的風險,應該完全避免 " +"[#dont-check-refcount]_。" -#: ../../extending/extending.rst:993 +#: ../../extending/extending.rst:696 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 " @@ -2009,7 +1370,7 @@ msgstr "" "有的缺點是,在一些微妙的情況下,看似正確的程式碼中的借用參照可能在借出它的擁" "有者實際上已經處置了它之後被使用。" -#: ../../extending/extending.rst:1001 +#: ../../extending/extending.rst:704 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 " @@ -2021,11 +1382,11 @@ msgstr "" "擁有者的狀態 --- 它建立了一個新的擁有參照,並賦予完整的擁有者責任(新的擁有者" "必須適當地處置參照,就像先前的擁有者一樣)。" -#: ../../extending/extending.rst:1011 +#: ../../extending/extending.rst:714 msgid "Ownership Rules" msgstr "擁有權規則" -#: ../../extending/extending.rst:1013 +#: ../../extending/extending.rst:716 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 " @@ -2034,7 +1395,7 @@ msgstr "" "每當一個物件參照被傳入或傳出一個函式時,擁有權是否隨參照一起轉移是該函式介面" "規格的一部分。" -#: ../../extending/extending.rst:1017 +#: ../../extending/extending.rst:720 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 " @@ -2050,7 +1411,7 @@ msgstr "" "例如,:c:func:`PyLong_FromLong` 維護了一個常用值的快取,並可以回傳指向已快取" "項目的參照。" -#: ../../extending/extending.rst:1025 +#: ../../extending/extending.rst:728 msgid "" "Many functions that extract objects from other objects also transfer " "ownership with the reference, for instance :c:func:" @@ -2066,7 +1427,7 @@ msgstr "" "`PyDict_GetItem` 和 :c:func:`PyDict_GetItemString` 都回傳你從 tuple、list 或 " "dictionary 中借用的參照。" -#: ../../extending/extending.rst:1032 +#: ../../extending/extending.rst:735 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 " @@ -2075,7 +1436,7 @@ msgstr "" "函式 :c:func:`PyImport_AddModule` 也會回傳一個借用參照,即使它可能實際上建立" "了它回傳的物件:這是可能的,因為該物件的擁有參照被儲存在 ``sys.modules`` 中。" -#: ../../extending/extending.rst:1036 +#: ../../extending/extending.rst:739 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 " @@ -2091,7 +1452,7 @@ msgstr "" "會接管傳入項目的擁有權 --- 即使它們失敗了也是!(注意 :c:func:" "`PyDict_SetItem` 和其相關函式不會接管擁有權 --- 它們是「正常的」。)" -#: ../../extending/extending.rst:1044 +#: ../../extending/extending.rst:747 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 " @@ -2103,7 +1464,7 @@ msgstr "" "的參照,所以借用參照的生命週期在函式回傳之前都是有保證的。只有當這種借用參照" "必須被儲存或傳遞時,才必須透過呼叫 :c:func:`Py_INCREF` 將它轉換為擁有的參照。" -#: ../../extending/extending.rst:1050 +#: ../../extending/extending.rst:753 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 " @@ -2112,11 +1473,11 @@ msgstr "" "從被 Python 呼叫的 C 函式回傳的物件參照必須是擁有的參照 --- 擁有權從函式轉移" "給它的呼叫者。" -#: ../../extending/extending.rst:1058 +#: ../../extending/extending.rst:761 msgid "Thin Ice" msgstr "薄冰" -#: ../../extending/extending.rst:1060 +#: ../../extending/extending.rst:763 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 " @@ -2126,7 +1487,7 @@ msgstr "" "有一些情況下,看似無害的借用參照使用可能會導致問題。這些都與直譯器的隱式叫用" "有關,它可能導致參照的擁有者處置掉該參照。" -#: ../../extending/extending.rst:1064 +#: ../../extending/extending.rst:767 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 " @@ -2135,7 +1496,7 @@ msgstr "" "需要知道的第一個也是最重要的情況是,在借用 list 項目的參照時,對一個不相關的" "物件使用 :c:func:`Py_DECREF`。例如: ::" -#: ../../extending/extending.rst:1067 +#: ../../extending/extending.rst:770 msgid "" "void\n" "bug(PyObject *list)\n" @@ -2155,7 +1516,7 @@ msgstr "" " PyObject_Print(item, stdout, 0); /* BUG! */\n" "}" -#: ../../extending/extending.rst:1076 +#: ../../extending/extending.rst:779 msgid "" "This function first borrows a reference to ``list[0]``, then replaces " "``list[1]`` with the value ``0``, and finally prints the borrowed reference. " @@ -2164,7 +1525,7 @@ msgstr "" "這個函式首先借用了 ``list[0]`` 的參照,然後將 ``list[1]`` 替換為值 ``0``,最" "後印出借用的參照。看起來無害,對吧?但事實並非如此!" -#: ../../extending/extending.rst:1080 +#: ../../extending/extending.rst:783 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 " @@ -2190,7 +1551,7 @@ msgstr "" "tp_finalize`,它對於類別實例被對映到 :meth:`!__del__` 方法(見 :pep:`442`)。" "整個序列在 :c:func:`PyList_SetItem` 呼叫中同步發生。" -#: ../../extending/extending.rst:1094 +#: ../../extending/extending.rst:797 msgid "" "Since it is written in Python, the :meth:`!__del__` method can execute " "arbitrary Python code. Could it perhaps do something to invalidate the " @@ -2206,7 +1567,7 @@ msgstr "" "以執行一個效果等同於 ``del list[0]`` 的陳述式,並且假設這是該物件的最後一個參" "照,它會釋放與其關聯的記憶體,從而使 ``item`` 失效。" -#: ../../extending/extending.rst:1102 +#: ../../extending/extending.rst:805 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::" @@ -2214,7 +1575,7 @@ msgstr "" "一旦你知道問題的根源,解決方案很簡單:暫時遞增參照計數。該函式的正確版本如" "下: ::" -#: ../../extending/extending.rst:1105 +#: ../../extending/extending.rst:808 msgid "" "void\n" "no_bug(PyObject *list)\n" @@ -2238,7 +1599,7 @@ msgstr "" " Py_DECREF(item);\n" "}" -#: ../../extending/extending.rst:1116 +#: ../../extending/extending.rst:819 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 " @@ -2247,7 +1608,7 @@ msgstr "" "這是一個真實的故事。舊版本的 Python 包含了這個 bug 的變體,有人花了大量時間" "在 C 除錯器中試圖找出為什麼他的 :meth:`!__del__` 方法會失敗......" -#: ../../extending/extending.rst:1120 +#: ../../extending/extending.rst:823 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 " @@ -2266,7 +1627,7 @@ msgstr "" "`Py_END_ALLOW_THREADS` 重新取得它。這在阻塞式 I/O 呼叫周圍很常見,讓其他執行" "緒可以在等待 I/O 完成時使用處理器。顯然,以下函式與前一個有相同的問題: ::" -#: ../../extending/extending.rst:1130 +#: ../../extending/extending.rst:833 msgid "" "void\n" "bug(PyObject *list)\n" @@ -2288,11 +1649,11 @@ msgstr "" " PyObject_Print(item, stdout, 0); /* BUG! */\n" "}" -#: ../../extending/extending.rst:1144 +#: ../../extending/extending.rst:847 msgid "NULL Pointers" msgstr "NULL 指標" -#: ../../extending/extending.rst:1146 +#: ../../extending/extending.rst:849 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 " @@ -2309,7 +1670,7 @@ msgstr "" "將它們收到的物件傳遞給其他函式──如果每個函式都測試 ``NULL``,就會有大量多餘的" "測試,而且程式碼會執行得更慢。" -#: ../../extending/extending.rst:1154 +#: ../../extending/extending.rst:857 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 " @@ -2318,7 +1679,7 @@ msgstr "" "比較好的做法是只在「源頭」測試 ``NULL``:當收到可能為 ``NULL`` 的指標時,例如" "從 :c:func:`malloc` 或從可能引發例外的函式收到時。" -#: ../../extending/extending.rst:1158 +#: ../../extending/extending.rst:861 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:" @@ -2327,7 +1688,7 @@ msgstr "" "巨集 :c:func:`Py_INCREF` 和 :c:func:`Py_DECREF` 不會檢查 ``NULL`` 指標──然" "而,它們的變體 :c:func:`Py_XINCREF` 和 :c:func:`Py_XDECREF` 會。" -#: ../../extending/extending.rst:1162 +#: ../../extending/extending.rst:865 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 " @@ -2339,26 +1700,26 @@ msgstr "" "地,有很多程式碼會連續呼叫數個這類巨集來測試一個物件是否符合各種不同的預期型" "別,這樣會產生多餘的測試。沒有帶 ``NULL`` 檢查的變體。" -#: ../../extending/extending.rst:1168 +#: ../../extending/extending.rst:871 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 [#]_." +"guarantees that it is always a tuple [#old-calling-convention]_." msgstr "" "C 函式呼叫機制保證傳遞給 C 函式的引數列表(範例中的 ``args``)永遠不會是 " -"``NULL``\\ ──事實上它保證它始終是一個 tuple [#]_。" +"``NULL``\\ ──事實上它保證它始終是一個 tuple [#old-calling-convention]_。" -#: ../../extending/extending.rst:1172 +#: ../../extending/extending.rst:875 msgid "" "It is a severe error to ever let a ``NULL`` pointer \"escape\" to the Python " "user." msgstr "讓一個 ``NULL`` 指標「逃逸」到 Python 使用者端是一個嚴重的錯誤。" -#: ../../extending/extending.rst:1183 +#: ../../extending/extending.rst:886 msgid "Writing Extensions in C++" msgstr "以 C++ 撰寫擴充" -#: ../../extending/extending.rst:1185 +#: ../../extending/extending.rst:888 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 " @@ -2377,11 +1738,11 @@ msgstr "" "``extern \"C\" {...}`` 中──如果定義了符號 ``__cplusplus``,它們已經使用了這個" "形式(所有近期的 C++ 編譯器都定義了這個符號)。" -#: ../../extending/extending.rst:1199 +#: ../../extending/extending.rst:902 msgid "Providing a C API for an Extension Module" msgstr "為擴充模組提供 C API" -#: ../../extending/extending.rst:1204 +#: ../../extending/extending.rst:904 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 " @@ -2397,7 +1758,7 @@ msgstr "" "組建立和操作 list 一樣,這個新的 collection 型別也應該有一組 C 函式供其他擴充" "模組直接操作。" -#: ../../extending/extending.rst:1212 +#: ../../extending/extending.rst:912 msgid "" "At first sight this seems easy: just write the functions (without declaring " "them ``static``, of course), provide an appropriate header file, and " @@ -2421,21 +1782,20 @@ msgstr "" "多數 Unix 系統)。即使符號是全域可見的,想要呼叫其函式的模組也可能尚未被載" "入!" -#: ../../extending/extending.rst:1224 +#: ../../extending/extending.rst:924 msgid "" "Portability therefore requires not to make any assumptions about symbol " "visibility. This means that all symbols in extension modules should be " "declared ``static``, except for the module's initialization function, in " -"order to avoid name clashes with other extension modules (as discussed in " -"section :ref:`methodtable`). And it means that symbols that *should* be " -"accessible from other extension modules must be exported in a different way." +"order to avoid name clashes with other extension modules. And it means that " +"symbols that *should* be accessible from other extension modules must be " +"exported in a different way." msgstr "" "因此,可攜性要求不對符號可見性做任何假設。這意味著擴充模組中的所有符號都應該" -"宣告為 ``static``,模組的初始化函式除外,以避免與其他擴充模組的名稱衝突(如在" -"\\ :ref:`methodtable`\\ 章節中所討論的)。而且這意味著\\ *應該*\\ 從其他擴充" -"模組存取的符號必須以不同的方式匯出。" +"宣告為 ``static``,模組的初始化函式除外,以避免與其他擴充模組的名稱衝突。而且" +"這意味著\\ *應該*\\ 從其他擴充模組存取的符號必須以不同的方式匯出。" -#: ../../extending/extending.rst:1231 +#: ../../extending/extending.rst:931 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 " @@ -2452,7 +1812,7 @@ msgstr "" "件一樣被傳遞。特別是,它們可以被指派給擴充模組命名空間中的一個名稱。其他擴充" "模組可以接著 import 這個模組、取得這個名稱的值,然後從 Capsule 中取得指標。" -#: ../../extending/extending.rst:1239 +#: ../../extending/extending.rst:939 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 " @@ -2466,7 +1826,7 @@ msgstr "" "裡。儲存和取得指標的各種任務可以在提供程式碼的模組和用戶端模組之間以不同方式" "分配。" -#: ../../extending/extending.rst:1245 +#: ../../extending/extending.rst:945 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 " @@ -2480,17 +1840,17 @@ msgstr "" "``NULL`` 名稱,但我們強烈建議你指定一個名稱。正確命名的 Capsule 提供了一定程" "度的執行期型別安全性;沒有可行的方法來區分一個未命名的 Capsule 和另一個。" -#: ../../extending/extending.rst:1252 +#: ../../extending/extending.rst:952 msgid "" "In particular, Capsules used to expose C APIs should be given a name " "following this convention::" msgstr "特別是,用於公開 C API 的 Capsule 應該依照此慣例來命名: ::" -#: ../../extending/extending.rst:1255 +#: ../../extending/extending.rst:955 msgid "modulename.attributename" msgstr "modulename.attributename" -#: ../../extending/extending.rst:1257 +#: ../../extending/extending.rst:957 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 " @@ -2501,7 +1861,7 @@ msgstr "" "易,但前提是 Capsule 的名稱符合此慣例。這個行為讓 C API 使用者對於他們載入的 " "Capsule 包含正確的 C API 有高度的確定性。" -#: ../../extending/extending.rst:1262 +#: ../../extending/extending.rst:962 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 " @@ -2517,23 +1877,23 @@ msgstr "" "個巨集,負責 import 模組並取得其 C API 指標;用戶端模組只需在存取 C API 之前" "呼叫這個巨集即可。" -#: ../../extending/extending.rst:1270 +#: ../../extending/extending.rst:970 msgid "" -"The exporting module is a modification of the :mod:`!spam` module from " -"section :ref:`extending-simpleexample`. The function :func:`!spam.system` " +"The exporting module is a modification of the :mod:`!spam` module from the :" +"ref:`tutorial `. The function :func:`!spam.system` " "does not call the C library function :c:func:`system` directly, but a " "function :c:func:`!PySpam_System`, which would of course do something more " "complicated in reality (such as adding \"spam\" to every command). This " "function :c:func:`!PySpam_System` is also exported to other extension " "modules." msgstr "" -"匯出模組是\\ :ref:`extending-simpleexample`\\ 章節中 :mod:`!spam` 模組的修改" -"版。函式 :func:`!spam.system` 不直接呼叫 C 函式庫函式 :c:func:`system`,而是" -"呼叫函式 :c:func:`!PySpam_System`,這個函式在現實中當然會做更複雜的事情(例如" -"在每個命令中加上「spam」)。這個函式 :c:func:`!PySpam_System` 也會匯出給其他" -"擴充模組。" +"匯出模組是\\ :ref:`教學 `\\ 中 :mod:`!spam` 模組的修" +"改版。函式 :func:`!spam.system` 不直接呼叫 C 函式庫函式 :c:func:`system`,而" +"是呼叫函式 :c:func:`!PySpam_System`,這個函式在現實中當然會做更複雜的事情(例" +"如在每個命令中加上「spam」)。這個函式 :c:func:`!PySpam_System` 也會匯出給其" +"他擴充模組。" -#: ../../extending/extending.rst:1277 +#: ../../extending/extending.rst:978 msgid "" "The function :c:func:`!PySpam_System` is a plain C function, declared " "``static`` like everything else::" @@ -2541,7 +1901,7 @@ msgstr "" "函式 :c:func:`!PySpam_System` 是一個普通的 C 函式,和其他所有東西一樣宣告為 " "``static``: ::" -#: ../../extending/extending.rst:1280 +#: ../../extending/extending.rst:981 msgid "" "static int\n" "PySpam_System(const char *command)\n" @@ -2555,11 +1915,11 @@ msgstr "" " return system(command);\n" "}" -#: ../../extending/extending.rst:1286 +#: ../../extending/extending.rst:987 msgid "The function :c:func:`!spam_system` is modified in a trivial way::" msgstr "函式 :c:func:`!spam_system` 做了簡單的修改: ::" -#: ../../extending/extending.rst:1288 +#: ../../extending/extending.rst:989 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -2585,19 +1945,15 @@ msgstr "" " return PyLong_FromLong(sts);\n" "}" -#: ../../extending/extending.rst:1300 +#: ../../extending/extending.rst:1001 msgid "In the beginning of the module, right after the line ::" msgstr "在模組的開頭,緊接在這一行之後: ::" -#: ../../extending/extending.rst:1302 -msgid "#include " -msgstr "#include " - -#: ../../extending/extending.rst:1304 +#: ../../extending/extending.rst:1005 msgid "two more lines must be added::" msgstr "必須再加上兩行: ::" -#: ../../extending/extending.rst:1306 +#: ../../extending/extending.rst:1007 msgid "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" @@ -2605,7 +1961,7 @@ msgstr "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" -#: ../../extending/extending.rst:1309 +#: ../../extending/extending.rst:1010 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:" @@ -2615,7 +1971,7 @@ msgstr "" "``#define`` 用來告訴標頭檔它是被引入到匯出模組中,而不是用戶端模組。最後,模" "組的 :c:data:`mod_exec ` 函式必須負責初始化 C API 指標陣列: ::" -#: ../../extending/extending.rst:1313 +#: ../../extending/extending.rst:1014 msgid "" "static int\n" "spam_module_exec(PyObject *m)\n" @@ -2657,7 +2013,7 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/extending.rst:1332 +#: ../../extending/extending.rst:1033 msgid "" "Note that ``PySpam_API`` is declared ``static``; otherwise the pointer array " "would disappear when :c:func:`!PyInit_spam` terminates!" @@ -2665,13 +2021,13 @@ msgstr "" "請注意 ``PySpam_API`` 被宣告為 ``static``;否則指標陣列會在 :c:func:`!" "PyInit_spam` 結束時消失!" -#: ../../extending/extending.rst:1335 +#: ../../extending/extending.rst:1036 msgid "" "The bulk of the work is in the header file :file:`spammodule.h`, which looks " "like this::" msgstr "大部分的工作在標頭檔 :file:`spammodule.h` 中,它看起來像這樣: ::" -#: ../../extending/extending.rst:1338 +#: ../../extending/extending.rst:1039 msgid "" "#ifndef Py_SPAMMODULE_H\n" "#define Py_SPAMMODULE_H\n" @@ -2771,7 +2127,7 @@ msgstr "" "\n" "#endif /* !defined(Py_SPAMMODULE_H) */" -#: ../../extending/extending.rst:1386 +#: ../../extending/extending.rst:1087 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:`!" @@ -2781,7 +2137,7 @@ msgstr "" "`mod_exec ` 函式中呼叫函式(或者更確切地說是巨集)\\ :c:func:`!" "import_spam`: ::" -#: ../../extending/extending.rst:1390 +#: ../../extending/extending.rst:1091 msgid "" "static int\n" "client_module_exec(PyObject *m)\n" @@ -2803,7 +2159,7 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/extending.rst:1400 +#: ../../extending/extending.rst:1101 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 " @@ -2812,7 +2168,7 @@ msgstr "" "這種方法的主要缺點是檔案 :file:`spammodule.h` 相當複雜。然而,每個被匯出的函" "式的基本結構都是相同的,所以只需要學習一次。" -#: ../../extending/extending.rst:1404 +#: ../../extending/extending.rst:1105 msgid "" "Finally it should be mentioned that Capsules offer additional functionality, " "which is especially useful for memory allocation and deallocation of the " @@ -2826,25 +2182,17 @@ msgstr "" "以及 Capsule 的實作中有描述(Python 原始碼發行版中的 :file:`Include/" "pycapsule.h` 和 :file:`Objects/capsule.c` 檔案)。" -#: ../../extending/extending.rst:1412 +#: ../../extending/extending.rst:1113 msgid "Footnotes" msgstr "註腳" -#: ../../extending/extending.rst:1413 -msgid "" -"An interface for this function already exists in the standard module :mod:" -"`os` --- it was chosen as a simple and straightforward example." -msgstr "" -"這個函式的介面已存在於標準模組 :mod:`os` 中──它被選用是因為它是一個簡單且直觀" -"的範例。" - -#: ../../extending/extending.rst:1416 +#: ../../extending/extending.rst:1114 msgid "" "The metaphor of \"borrowing\" a reference is not completely correct: the " "owner still has a copy of the reference." msgstr "「借用」參照的比喻並不完全正確:擁有者仍然持有參照的副本。" -#: ../../extending/extending.rst:1419 +#: ../../extending/extending.rst:1117 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 " @@ -2853,7 +2201,7 @@ msgstr "" "檢查參照計數是否至少為 1 是\\ **行不通的**\\ ──參照計數本身可能位於已釋放的記" "憶體中,因此可能被另一個物件重新使用!" -#: ../../extending/extending.rst:1423 +#: ../../extending/extending.rst:1122 msgid "" "These guarantees don't hold when you use the \"old\" style calling " "convention --- this is still found in much existing code." @@ -2861,18 +2209,634 @@ msgstr "" "當你使用「舊」式的呼叫慣例時,這些保證不成立──這在許多現有的程式碼中仍然可以" "找到。" -#: ../../extending/extending.rst:591 +#: ../../extending/extending.rst:277 msgid "PyObject_CallObject (C function)" msgstr "PyObject_CallObject(C 函式)" -#: ../../extending/extending.rst:682 +#: ../../extending/extending.rst:363 msgid "PyArg_ParseTuple (C function)" msgstr "PyArg_ParseTuple(C 函式)" -#: ../../extending/extending.rst:774 +#: ../../extending/extending.rst:490 msgid "PyArg_ParseTupleAndKeywords (C function)" msgstr "PyArg_ParseTupleAndKeywords(C 函式)" -#: ../../extending/extending.rst:795 +#: ../../extending/extending.rst:511 msgid "Philbrick, Geoff" msgstr "Philbrick, Geoff" + +#~ msgid "Extending Python with C or C++" +#~ msgstr "以 C 或 C++ 擴充 Python" + +#~ msgid "" +#~ "It is quite easy to add new built-in modules to Python, if you know how " +#~ "to program in C. Such :dfn:`extension modules` can do two things that " +#~ "can't be done directly in Python: they can implement new built-in object " +#~ "types, and they can call C library functions and system calls." +#~ msgstr "" +#~ "如果你會撰寫 C 程式語言,那要向 Python 新增內建模組就不困難。這種\\ :dfn:`" +#~ "擴充模組 (extension modules)` 可以做兩件在 Python 中無法直接完成的事:它們" +#~ "可以實作新的內建物件型別,並且可以呼叫 C 的函式庫函式和系統呼叫。" + +#~ msgid "" +#~ "To support extensions, the Python API (Application Programmers Interface) " +#~ "defines a set of functions, macros and variables that provide access to " +#~ "most aspects of the Python run-time system. The Python API is " +#~ "incorporated in a C source file by including the header ``\"Python.h\"``." +#~ msgstr "" +#~ "為了支援擴充,Python API (Application Programmers Interface) 定義了一組函" +#~ "式、巨集和變數,提供對 Python run-time 系統大部分面向的存取。Python API 是" +#~ "透過引入標頭檔 ``\"Python.h\"`` 來被納入到一個 C 原始碼檔案中。" + +#~ msgid "" +#~ "The compilation of an extension module depends on its intended use as " +#~ "well as on your system setup; details are given in later chapters." +#~ msgstr "" +#~ "擴充模組的編譯取決於其預期用途以及你的系統設定;詳細資訊將在後面的章節中提" +#~ "供。" + +#~ msgid "" +#~ "The C extension interface is specific to CPython, and extension modules " +#~ "do not work on other Python implementations. In many cases, it is " +#~ "possible to avoid writing C extensions and preserve portability to other " +#~ "implementations. For example, if your use case is calling C library " +#~ "functions or system calls, you should consider using the :mod:`ctypes` " +#~ "module or the `cffi `_ library rather than " +#~ "writing custom C code. These modules let you write Python code to " +#~ "interface with C code and are more portable between implementations of " +#~ "Python than writing and compiling a C extension module." +#~ msgstr "" +#~ "C 擴充介面是 CPython 所特有的,擴充模組在其他 Python 實作上無法運作。在許" +#~ "多情況下,可以避免撰寫 C 擴充並保留對其他實作的可移植性。例如,如果你的用" +#~ "例是呼叫 C 函式庫函式或系統呼叫,你應該考慮使用 :mod:`ctypes` 模組或 " +#~ "`cffi `_ 函式庫,而不是編寫自訂的 C 程式碼。" +#~ "這些模組讓你可以撰寫 Python 程式碼來與 C 程式碼介接,而且比起撰寫和編譯 C " +#~ "擴充模組,這些模組在 Python 實作之間更容易移植。" + +#~ msgid "A Simple Example" +#~ msgstr "一個簡單範例" + +#~ msgid "" +#~ "Let's create an extension module called ``spam`` (the favorite food of " +#~ "Monty Python fans...) and let's say we want to create a Python interface " +#~ "to the C library function :c:func:`system` [#]_. This function takes a " +#~ "null-terminated character string as argument and returns an integer. We " +#~ "want this function to be callable from Python as follows:" +#~ msgstr "" +#~ "讓我們來建立一個叫做 ``spam``\\ (Monty Python 粉絲最愛的食物...)的擴充模" +#~ "組。假設我們要建立一個 Python 介面給 C 函式庫的函式 :c:func:`system` [#]_ " +#~ "使用,這個函式接受一個以 null 終止的 (null-terminated) 字元字串做為引數," +#~ "並回傳一個整數。我們希望這個函式可以在 Python 中被呼叫,如下所示:" + +#~ msgid "" +#~ ">>> import spam\n" +#~ ">>> status = spam.system(\"ls -l\")" +#~ msgstr "" +#~ ">>> import spam\n" +#~ ">>> status = spam.system(\"ls -l\")" + +#~ msgid "" +#~ "Begin by creating a file :file:`spammodule.c`. (Historically, if a " +#~ "module is called ``spam``, the C file containing its implementation is " +#~ "called :file:`spammodule.c`; if the module name is very long, like " +#~ "``spammify``, the module name can be just :file:`spammify.c`.)" +#~ msgstr "" +#~ "首先建立一個檔案 :file:`spammodule.c`。(從過去歷史來看,如果一個模組叫做 " +#~ "``spam``,包含其實作的 C 檔案就會叫做 :file:`spammodule.c`;如果模組名稱很" +#~ "長,像是 ``spammify``,模組名稱也可以只是 :file:`spammify.c`)。" + +#~ msgid "The first two lines of our file can be::" +#~ msgstr "我們檔案的前兩列可以為: ::" + +#~ msgid "" +#~ "#define PY_SSIZE_T_CLEAN\n" +#~ "#include " +#~ msgstr "" +#~ "#define PY_SSIZE_T_CLEAN\n" +#~ "#include " + +#~ msgid "" +#~ "which pulls in the Python API (you can add a comment describing the " +#~ "purpose of the module and a copyright notice if you like)." +#~ msgstr "" +#~ "這會將 Python API 拉進來(你可以加入註解來說明模組的目的,也可以加入版權聲" +#~ "明)。" + +#~ msgid "" +#~ "Since Python may define some pre-processor definitions which affect the " +#~ "standard headers on some systems, you *must* include :file:`Python.h` " +#~ "before any standard headers are included." +#~ msgstr "" +#~ "由於 Python 可能定義一些影響系統上某些標準標頭檔的預處理器定義,你\\ *必須" +#~ "*\\ 在引入任何標準標頭檔之前引入 :file:`Python.h`。" + +#~ msgid "" +#~ "``#define PY_SSIZE_T_CLEAN`` was used to indicate that ``Py_ssize_t`` " +#~ "should be used in some APIs instead of ``int``. It is not necessary since " +#~ "Python 3.13, but we keep it here for backward compatibility. See :ref:" +#~ "`arg-parsing-string-and-buffers` for a description of this macro." +#~ msgstr "" +#~ "``#define PY_SSIZE_T_CLEAN`` 被用來表示在某些 API 中應該使用 " +#~ "``Py_ssize_t`` 而不是 ``int``。自 Python 3.13 起,它就不再是必要的了,但我" +#~ "們在此保留它以便向後相容。關於這個巨集的描述請參閱\\ :ref:`arg-parsing-" +#~ "string-and-buffers`。" + +#~ msgid "" +#~ "All user-visible symbols defined by :file:`Python.h` have a prefix of " +#~ "``Py`` or ``PY``, except those defined in standard header files." +#~ msgstr "" +#~ "所有由 :file:`Python.h` 定義的使用者可見符號都具有 ``Py`` 或 ``PY`` 的前" +#~ "綴,在標準標頭檔中定義的除外。" + +#~ 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 "" +#~ "為了向後相容,:file:`Python.h` 引入了數個標準標頭檔。C 擴充應該引入它們使" +#~ "用的標準標頭檔,而不應依賴這些隱式的引入。如果使用限定 C API 版本 3.13 或" +#~ "更新版本,隱式引入的有:" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "```` (on Windows)" +#~ msgstr "````\\ (在 Windows 上)" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "```` (if present)" +#~ msgstr "````\\ (如果存在)" + +#~ 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 "" +#~ "如果 :c:macro:`Py_LIMITED_API` 未被定義,或是被設定為版本 3.12 或更舊,則" +#~ "也會引入以下標頭檔:" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "```` (on POSIX)" +#~ msgstr "````\\ (在 POSIX 上)" + +#~ 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 "" +#~ "如果 :c:macro:`Py_LIMITED_API` 未被定義,或是被設定為版本 3.10 或更舊,則" +#~ "也會引入以下標頭檔:" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "````" +#~ msgstr "````" + +#~ msgid "````" +#~ msgstr "````" + +#~ 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 " +#~ "(we'll see shortly how it ends up being called)::" +#~ msgstr "" +#~ "接下來我們要加入到模組檔案的是 C 函式,當 Python 運算式 ``spam." +#~ "system(string)`` 要被求值 (evaluated) 時就會被呼叫(我們很快就會看到它最後" +#~ "是如何被呼叫的): ::" + +#~ msgid "" +#~ "static PyObject *\n" +#~ "spam_system(PyObject *self, PyObject *args)\n" +#~ "{\n" +#~ " const char *command;\n" +#~ " int sts;\n" +#~ "\n" +#~ " if (!PyArg_ParseTuple(args, \"s\", &command))\n" +#~ " return NULL;\n" +#~ " sts = system(command);\n" +#~ " return PyLong_FromLong(sts);\n" +#~ "}" +#~ msgstr "" +#~ "static PyObject *\n" +#~ "spam_system(PyObject *self, PyObject *args)\n" +#~ "{\n" +#~ " const char *command;\n" +#~ " int sts;\n" +#~ "\n" +#~ " if (!PyArg_ParseTuple(args, \"s\", &command))\n" +#~ " return NULL;\n" +#~ " sts = system(command);\n" +#~ " return PyLong_FromLong(sts);\n" +#~ "}" + +#~ 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 C function. The C function always has two arguments, " +#~ "conventionally named *self* and *args*." +#~ msgstr "" +#~ "可以很直觀地從 Python 的引數串列(例如單一的運算式 ``\"ls -l\"``)直接轉換" +#~ "成傳給 C 函式的引數。C 函式總是有兩個引數,習慣上會命名為 *self* 和 " +#~ "*args*。" + +#~ msgid "" +#~ "The *self* argument points to the module object for module-level " +#~ "functions; for a method it would point to the object instance." +#~ msgstr "" +#~ "對於模組層級的函式,*self* 引數會指向模組物件;而對於方法來說則是指向物件" +#~ "的實例。" + +#~ 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 " +#~ "call's argument list. The arguments are Python objects --- in order to " +#~ "do anything with them in our C function we have to convert them to C " +#~ "values. The function :c:func:`PyArg_ParseTuple` in the Python API checks " +#~ "the argument types and converts them to C values. It uses a template " +#~ "string to determine the required types of the arguments as well as the " +#~ "types of the C variables into which to store the converted values. More " +#~ "about this later." +#~ msgstr "" +#~ "*args* 引數會是一個指向包含引數的 Python 元組物件的指標。元組中的每一項都" +#~ "對應於呼叫的引數串列中的一個引數。引數是 Python 物件 --- 為了在我們的 C 函" +#~ "式中對它們做任何事情,我們必須先將它們轉換成 C 值。Python API 中的 :c:" +#~ "func:`PyArg_ParseTuple` 函式能夠檢查引數型別並將他們轉換為 C 值。它使用模" +#~ "板字串來決定所需的引數型別以及儲存轉換值的 C 變數型別。稍後會再詳細說明。" + +#~ 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 " +#~ "addresses are passed. It returns false (zero) if an invalid argument " +#~ "list was passed. In the latter case it also raises an appropriate " +#~ "exception so the calling function can return ``NULL`` immediately (as we " +#~ "saw in the example)." +#~ msgstr "" +#~ "如果所有的引數都有正確的型別,且其元件已儲存在傳入位址的變數中,則 :c:" +#~ "func:`PyArg_ParseTuple` 會回傳 true(非零)。如果傳入的是無效引數串列則回" +#~ "傳 false(零)。在後者情況下,它也會產生適當的例外,因此呼叫函式可以立即回" +#~ "傳 ``NULL``\\ (就像我們在範例中所看到的)。" + +#~ msgid "Back to the Example" +#~ msgstr "回到範例" + +#~ msgid "" +#~ "Going back to our example function, you should now be able to understand " +#~ "this statement::" +#~ msgstr "回到我們的範例函式,現在你應該可以理解這個陳述式了: ::" + +#~ msgid "" +#~ "It returns ``NULL`` (the error indicator for functions returning object " +#~ "pointers) if an error is detected in the argument list, relying on the " +#~ "exception set by :c:func:`PyArg_ParseTuple`. Otherwise the string value " +#~ "of the argument has been copied to the local variable :c:data:`!" +#~ "command`. This is a pointer assignment and you are not supposed to " +#~ "modify the string to which it points (so in Standard C, the variable :c:" +#~ "data:`!command` should properly be declared as ``const char *command``)." +#~ msgstr "" +#~ "如果在引數串列中檢測到錯誤則會回傳 ``NULL``\\ (回傳物件指標之函式的錯誤指" +#~ "示器),其依賴於 :c:func:`PyArg_ParseTuple` 設定的例外,否則引數的字串值會" +#~ "已被複製到區域變數 :c:data:`!command` 中。這是一個指標賦值,你不應該修改它" +#~ "所指向的字串(所以在標準 C 中,:c:data:`!command` 變數應該正確地被宣告為 " +#~ "``const char *command``)。" + +#~ 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`::" +#~ msgstr "" +#~ "接下來的陳述式會呼叫 Unix 函式 :c:func:`system`,並將剛才從 :c:func:" +#~ "`PyArg_ParseTuple` 得到的字串傳給它: ::" + +#~ msgid "sts = system(command);" +#~ msgstr "sts = system(command);" + +#~ 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:" +#~ "`PyLong_FromLong`. ::" +#~ msgstr "" +#~ "我們的 :func:`!spam.system` 函式必須以 Python 物件的形式來回傳 :c:data:`!" +#~ "sts` 的值。這是透過 :c:func:`PyLong_FromLong` 函式來達成。 ::" + +#~ msgid "return PyLong_FromLong(sts);" +#~ msgstr "return PyLong_FromLong(sts);" + +#~ msgid "" +#~ "In this case, it will return an integer object. (Yes, even integers are " +#~ "objects on the heap in Python!)" +#~ msgstr "" +#~ "在這種情況下它會回傳一個整數物件。(是的,在 Python 中連整數也是堆積 " +#~ "(heap) 上的物件!)" + +#~ msgid "" +#~ "If you have a C function that returns no useful argument (a function " +#~ "returning :c:expr:`void`), the corresponding Python function must return " +#~ "``None``. You need this idiom to do so (which is implemented by the :c:" +#~ "macro:`Py_RETURN_NONE` macro)::" +#~ msgstr "" +#~ "如果你有一個不回傳任何有用引數的 C 函式(一個回傳 :c:expr:`void` 的函" +#~ "式),對應的 Python 函式必須回傳 ``None``。你需要以下這個慣例來達成(由 :" +#~ "c:macro:`Py_RETURN_NONE` 巨集實作): ::" + +#~ msgid "" +#~ "Py_INCREF(Py_None);\n" +#~ "return Py_None;" +#~ msgstr "" +#~ "Py_INCREF(Py_None);\n" +#~ "return Py_None;" + +#~ 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 " +#~ "\"error\" in most contexts, as we have seen." +#~ msgstr "" +#~ ":c:data:`Py_None` 是特殊 Python 物件 ``None`` 的 C 名稱。它是一個真正的 " +#~ "Python 物件而不是一個 ``NULL`` 指標,在大多數的情況下它的意思是「錯誤」," +#~ "如我們所見過的那樣。" + +#~ msgid "The Module's Method Table and Initialization Function" +#~ msgstr "模組的方法表和初始化函式" + +#~ 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\"::" +#~ msgstr "" +#~ "我承諾過要展示 :c:func:`!spam_system` 是如何從 Python 程式中呼叫的。首先," +#~ "我們需要在「方法表」中列出它的名稱和位址: ::" + +#~ msgid "" +#~ "static PyMethodDef spam_methods[] = {\n" +#~ " ...\n" +#~ " {\"system\", spam_system, METH_VARARGS,\n" +#~ " \"Execute a shell command.\"},\n" +#~ " ...\n" +#~ " {NULL, NULL, 0, NULL} /* Sentinel */\n" +#~ "};" +#~ msgstr "" +#~ "static PyMethodDef spam_methods[] = {\n" +#~ " ...\n" +#~ " {\"system\", spam_system, METH_VARARGS,\n" +#~ " \"Execute a shell command.\"},\n" +#~ " ...\n" +#~ " {NULL, NULL, 0, NULL} /* Sentinel */\n" +#~ "};" + +#~ 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 normally always be ``METH_VARARGS`` or ``METH_VARARGS | " +#~ "METH_KEYWORDS``; a value of ``0`` means that an obsolete variant of :c:" +#~ "func:`PyArg_ParseTuple` is used." +#~ msgstr "" +#~ "請注意第三個項目 (``METH_VARARGS``)。這是一個告訴直譯器 C 函式之呼叫方式的" +#~ "旗標。通常應該是 ``METH_VARARGS`` 或 ``METH_VARARGS | METH_KEYWORDS``;" +#~ "``0`` 表示是使用 :c:func:`PyArg_ParseTuple` 的一個過時變體。" + +#~ 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:" +#~ "func:`PyArg_ParseTuple`; more information on this function is provided " +#~ "below." +#~ msgstr "" +#~ "當只使用 ``METH_VARARGS`` 時,函式應預期 Python 層級的參數是以元組形式傳入" +#~ "且能夠接受以 :c:func:`PyArg_ParseTuple` 進行剖析;有關此函式的更多資訊將在" +#~ "下面提供。" + +#~ msgid "" +#~ "The method table must be referenced in the module definition structure::" +#~ msgstr "方法表必須在模組定義結構中被參照: ::" + +#~ msgid "" +#~ "static struct PyModuleDef spam_module = {\n" +#~ " ...\n" +#~ " .m_methods = spam_methods,\n" +#~ " ...\n" +#~ "};" +#~ msgstr "" +#~ "static struct PyModuleDef spam_module = {\n" +#~ " ...\n" +#~ " .m_methods = spam_methods,\n" +#~ " ...\n" +#~ "};" + +#~ 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:`!PyInit_name`, where *name* is the name of the module, and " +#~ "should be the only non-\\ ``static`` item defined in the module file::" +#~ msgstr "" +#~ "反過來說,這個結構必須在模組的初始化函式中被傳給直譯器。初始化函式必須被命" +#~ "名為 :c:func:`!PyInit_name`,其中 *name* 是模組的名稱,且應該是模組檔案中" +#~ "唯一定義的非「靜態 (``static``)」項目: ::" + +#~ msgid "" +#~ "PyMODINIT_FUNC\n" +#~ "PyInit_spam(void)\n" +#~ "{\n" +#~ " return PyModuleDef_Init(&spam_module);\n" +#~ "}" +#~ msgstr "" +#~ "PyMODINIT_FUNC\n" +#~ "PyInit_spam(void)\n" +#~ "{\n" +#~ " return PyModuleDef_Init(&spam_module);\n" +#~ "}" + +#~ msgid "" +#~ "Note that :c:macro:`PyMODINIT_FUNC` declares the function as ``PyObject " +#~ "*`` return type, declares any special linkage declarations required by " +#~ "the platform, and for C++ declares the function as ``extern \"C\"``." +#~ msgstr "" +#~ "請注意,:c:macro:`PyMODINIT_FUNC` 宣告函式的回傳型別為 ``PyObject *``、宣" +#~ "告平台所需的任何特殊連結宣告、並針對 C++ 宣告函式為 ``extern \"C\"``。" + +#~ 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 Python.) A pointer to the module definition must be returned " +#~ "via :c:func:`PyModuleDef_Init`, so that the import machinery can create " +#~ "the module and store it in ``sys.modules``." +#~ msgstr "" +#~ "當每個直譯器首次 import 其 :mod:`!spam` 模組時,就會呼叫 :c:func:`!" +#~ "PyInit_spam`。(關於嵌入 Python 的說明請見下方。)必須透過 :c:func:" +#~ "`PyModuleDef_Init` 回傳一個指向模組定義的指標,好讓 import 機制可以建立模" +#~ "組並將其儲存在 ``sys.modules`` 中。" + +#~ 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` " +#~ "table. To add the module to the initialization table, use :c:func:" +#~ "`PyImport_AppendInittab`, optionally followed by an import of the module::" +#~ msgstr "" +#~ "嵌入 Python 時,除非在 :c:data:`PyImport_Inittab` 表中有相關條目,否則不會" +#~ "自動呼叫 :c:func:`!PyInit_spam` 函式。要將模組加入初始化表,請使用 :c:" +#~ "func:`PyImport_AppendInittab` 並在隨後選擇性地將該模組引入: ::" + +#~ msgid "" +#~ "#define PY_SSIZE_T_CLEAN\n" +#~ "#include \n" +#~ "\n" +#~ "int\n" +#~ "main(int argc, char *argv[])\n" +#~ "{\n" +#~ " PyStatus status;\n" +#~ " PyConfig config;\n" +#~ " PyConfig_InitPythonConfig(&config);\n" +#~ "\n" +#~ " /* Add a built-in module, before Py_Initialize */\n" +#~ " if (PyImport_AppendInittab(\"spam\", PyInit_spam) == -1) {\n" +#~ " fprintf(stderr, \"Error: could not extend in-built modules " +#~ "table\\n\");\n" +#~ " exit(1);\n" +#~ " }\n" +#~ "\n" +#~ " /* Pass argv[0] to the Python interpreter */\n" +#~ " status = PyConfig_SetBytesString(&config, &config.program_name, " +#~ "argv[0]);\n" +#~ " if (PyStatus_Exception(status)) {\n" +#~ " goto exception;\n" +#~ " }\n" +#~ "\n" +#~ " /* Initialize the Python interpreter. Required.\n" +#~ " If this step fails, it will be a fatal error. */\n" +#~ " status = Py_InitializeFromConfig(&config);\n" +#~ " if (PyStatus_Exception(status)) {\n" +#~ " goto exception;\n" +#~ " }\n" +#~ " PyConfig_Clear(&config);\n" +#~ "\n" +#~ " /* Optionally import the module; alternatively,\n" +#~ " import can be deferred until the embedded script\n" +#~ " imports it. */\n" +#~ " PyObject *pmodule = PyImport_ImportModule(\"spam\");\n" +#~ " if (!pmodule) {\n" +#~ " PyErr_Print();\n" +#~ " fprintf(stderr, \"Error: could not import module 'spam'\\n\");\n" +#~ " }\n" +#~ "\n" +#~ " // ... use Python C API here ...\n" +#~ "\n" +#~ " return 0;\n" +#~ "\n" +#~ " exception:\n" +#~ " PyConfig_Clear(&config);\n" +#~ " Py_ExitStatusException(status);\n" +#~ "}" +#~ msgstr "" +#~ "#define PY_SSIZE_T_CLEAN\n" +#~ "#include \n" +#~ "\n" +#~ "int\n" +#~ "main(int argc, char *argv[])\n" +#~ "{\n" +#~ " PyStatus status;\n" +#~ " PyConfig config;\n" +#~ " PyConfig_InitPythonConfig(&config);\n" +#~ "\n" +#~ " /* 在 Py_Initialize 之前加入內建模組 */\n" +#~ " if (PyImport_AppendInittab(\"spam\", PyInit_spam) == -1) {\n" +#~ " fprintf(stderr, \"Error: could not extend in-built modules " +#~ "table\\n\");\n" +#~ " exit(1);\n" +#~ " }\n" +#~ "\n" +#~ " /* 將 argv[0] 傳給 Python 直譯器 */\n" +#~ " status = PyConfig_SetBytesString(&config, &config.program_name, " +#~ "argv[0]);\n" +#~ " if (PyStatus_Exception(status)) {\n" +#~ " goto exception;\n" +#~ " }\n" +#~ "\n" +#~ " /* 初始化 Python 直譯器。這會是必要的。\n" +#~ " 如果此步驟失敗就會導致嚴重錯誤。*/\n" +#~ " status = Py_InitializeFromConfig(&config);\n" +#~ " if (PyStatus_Exception(status)) {\n" +#~ " goto exception;\n" +#~ " }\n" +#~ " PyConfig_Clear(&config);\n" +#~ "\n" +#~ " /* 可選擇引入模組;或者\n" +#~ " 可以延遲引入,直至嵌入式腳本\n" +#~ " 將其引入。*/\n" +#~ " PyObject *pmodule = PyImport_ImportModule(\"spam\");\n" +#~ " if (!pmodule) {\n" +#~ " PyErr_Print();\n" +#~ " fprintf(stderr, \"Error: could not import module 'spam'\\n\");\n" +#~ " }\n" +#~ "\n" +#~ " // ... 在此使用 Python C API ...\n" +#~ "\n" +#~ " return 0;\n" +#~ "\n" +#~ " exception:\n" +#~ " PyConfig_Clear(&config);\n" +#~ " Py_ExitStatusException(status);\n" +#~ "}" + +#~ 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 " +#~ "removing entries from ``sys.modules`` or importing compiled modules into " +#~ "multiple interpreters within a process (or following a :c:func:`fork` " +#~ "without an intervening :c:func:`exec`). If module state is not yet fully :" +#~ "ref:`isolated `, authors should consider " +#~ "marking the module as having no support for subinterpreters (via :c:macro:" +#~ "`Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED`)." +#~ msgstr "" +#~ "如果你宣告了一個全域變數或區域靜態變數,模組在重新初始化時可能會遇到非預期" +#~ "的副作用,例如從 ``sys.modules`` 中移除條目或在一個行程內將已編譯的模組引" +#~ "入多個直譯器中(或在沒有中間 :c:func:`exec` 的情況下進行 :c:func:" +#~ "`fork`)。如果模組狀態尚未完全被\\ :ref:`隔離 `,作者應考慮將模組標記為不支援子直譯器(透過 :c:macro:" +#~ "`Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED`)。" + +#~ 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 " +#~ "template or simply read as an example." +#~ msgstr "" +#~ "Python 原始碼發行版本中包含了一個更實質的範例模組 :file:`Modules/" +#~ "xxlimited.c`。這個檔案可以當作模板使用,也可以簡單地當作範例來閱讀。" + +#~ msgid "Compilation and Linkage" +#~ msgstr "編譯與連結" + +#~ 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 " +#~ "loading, the details may depend on the style of dynamic loading your " +#~ "system uses; see the chapters about building extension modules (chapter :" +#~ "ref:`building`) and additional information that pertains only to building " +#~ "on Windows (chapter :ref:`building-on-windows`) for more information " +#~ "about this." +#~ msgstr "" +#~ "在你可以使用你的新擴充之前還有兩件事要做:編譯和連結它到 Python 系統。如果" +#~ "你使用動態載入,細節可能取決於你系統所使用的動態載入方式;請參閱關於建置擴" +#~ "充模組的章節(:ref:`building`)以及僅與在 Windows 上建置有關的額外資訊(:" +#~ "ref:`building-on-windows`)以了解更多。" + +#~ msgid "" +#~ "An interface for this function already exists in the standard module :mod:" +#~ "`os` --- it was chosen as a simple and straightforward example." +#~ msgstr "" +#~ "這個函式的介面已存在於標準模組 :mod:`os` 中──它被選用是因為它是一個簡單且" +#~ "直觀的範例。" diff --git a/extending/first-extension-module.po b/extending/first-extension-module.po new file mode 100644 index 00000000000..f22dd711b00 --- /dev/null +++ b/extending/first-extension-module.po @@ -0,0 +1,1272 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../extending/first-extension-module.rst:9 +msgid "Your first C API extension module" +msgstr "" + +#: ../../extending/first-extension-module.rst:11 +msgid "" +"This tutorial will take you through creating a simple Python extension " +"module written in C or C++." +msgstr "" + +#: ../../extending/first-extension-module.rst:14 +msgid "" +"We will use the low-level Python C API directly. For easier ways to create " +"extension modules, see the :ref:`recommended third party tools `." +msgstr "" + +#: ../../extending/first-extension-module.rst:18 +msgid "" +"The tutorial assumes basic knowledge about Python: you should be able to " +"define functions in Python code before starting to write them in C. See :ref:" +"`tutorial-index` for an introduction to Python itself." +msgstr "" + +#: ../../extending/first-extension-module.rst:22 +msgid "" +"The tutorial should be approachable for anyone who can write a basic C " +"library. While we will mention several concepts that a C beginner would not " +"be expected to know, like ``static`` functions or linkage declarations, " +"understanding these is not necessary for success." +msgstr "" + +#: ../../extending/first-extension-module.rst:27 +msgid "" +"We will focus on giving you a \"feel\" of what Python's C API is like. It " +"will not teach you important concepts, like error handling and reference " +"counting, which are covered in later chapters." +msgstr "" + +#: ../../extending/first-extension-module.rst:31 +msgid "" +"We will assume that you use a Unix-like system (including macOS and Linux), " +"or Windows. On other systems, you might need to adjust some details -- for " +"example, a system command name." +msgstr "" + +#: ../../extending/first-extension-module.rst:36 +msgid "" +"You need to have a suitable C compiler and Python development headers " +"installed. On Linux, headers are often in a package like ``python3-dev`` or " +"``python3-devel``." +msgstr "" + +#: ../../extending/first-extension-module.rst:40 +msgid "" +"You need to be able to install Python packages. This tutorial uses `pip " +"`__ (``pip install``), but you can substitute any tool " +"that can build and install ``pyproject.toml``-based projects, like `uv " +"`_ (``uv pip install``). Preferably, have a :ref:" +"`virtual environment ` activated." +msgstr "" + +#: ../../extending/first-extension-module.rst:49 +msgid "" +"This tutorial uses APIs that were added in CPython 3.15. To create an " +"extension that's compatible with earlier versions of CPython, please follow " +"an earlier version of this documentation." +msgstr "" + +#: ../../extending/first-extension-module.rst:53 +msgid "" +"This tutorial uses C syntax added in C11 and C++20. If your extension needs " +"to be compatible with earlier standards, please follow tutorials in " +"documentation for Python 3.14 or below." +msgstr "" + +#: ../../extending/first-extension-module.rst:59 +msgid "What we'll do" +msgstr "" + +#: ../../extending/first-extension-module.rst:61 +msgid "" +"Let's create an extension module called ``spam`` [#why-spam]_, which will " +"include a Python interface to the C standard library function :c:func:" +"`system`. This function is defined in ``stdlib.h``. It takes a C string as " +"argument, runs the argument as a system command, and returns a result value " +"as an integer. A manual page for :c:func:`system` might summarize it this " +"way::" +msgstr "" + +#: ../../extending/first-extension-module.rst:69 +msgid "" +"#include \n" +"int system(const char *command);" +msgstr "" +"#include \n" +"int system(const char *command);" + +#: ../../extending/first-extension-module.rst:72 +msgid "" +"Note that like many functions in the C standard library, this function is " +"already exposed in Python. In production, use :py:func:`os.system` or :py:" +"func:`subprocess.run` rather than the module you'll write here." +msgstr "" + +#: ../../extending/first-extension-module.rst:77 +msgid "We want this function to be callable from Python as follows:" +msgstr "" + +#: ../../extending/first-extension-module.rst:79 +msgid "" +">>> import spam\n" +">>> status = spam.system(\"whoami\")\n" +"User Name\n" +">>> status\n" +"0" +msgstr "" +">>> import spam\n" +">>> status = spam.system(\"whoami\")\n" +"User Name\n" +">>> status\n" +"0" + +#: ../../extending/first-extension-module.rst:89 +msgid "" +"The system command ``whoami`` prints out your username. It's useful in " +"tutorials like this one because it has the same name on both Unix and " +"Windows." +msgstr "" + +#: ../../extending/first-extension-module.rst:95 +msgid "Start with the headers" +msgstr "" + +#: ../../extending/first-extension-module.rst:97 +msgid "" +"Begin by creating a directory for this tutorial, and switching to it on the " +"command line. Then, create a file named :file:`spammodule.c` in your " +"directory. [#why-spammodule]_" +msgstr "" + +#: ../../extending/first-extension-module.rst:102 +msgid "" +"In this file, we'll include two headers: :file:`Python.h` to pull in all " +"declarations of the Python C API, and :file:`stdlib.h` for the :c:func:" +"`system` function. [#stdlib-h]_" +msgstr "" + +#: ../../extending/first-extension-module.rst:106 +msgid "Add the following lines to :file:`spammodule.c`:" +msgstr "" + +#: ../../extending/first-extension-module.rst:108 +msgid "" +"#include \n" +"#include // for system()\n" +msgstr "" +"#include \n" +"#include // for system()\n" + +#: ../../extending/first-extension-module.rst:112 +msgid "" +"Be sure to put :file:`stdlib.h`, and any other standard library includes, " +"*after* :file:`Python.h`. On some systems, Python may define some pre-" +"processor definitions that affect the standard headers." +msgstr "" +"Be sure to put :file:`stdlib.h`, and any other standard library includes, " +"*after* :file:`Python.h`. On some systems, Python may define some pre-" +"processor definitions that affect the standard headers." + +#: ../../extending/first-extension-module.rst:119 +msgid "Running your build tool" +msgstr "" + +#: ../../extending/first-extension-module.rst:121 +msgid "" +"With only the includes in place, your extension won't do anything. Still, " +"it's a good time to compile it and try to import it. This will ensure that " +"your build tool works, so that you can make and test incremental changes as " +"you follow the rest of the text." +msgstr "" + +#: ../../extending/first-extension-module.rst:126 +msgid "" +"CPython itself does not come with a tool to build extension modules; it is " +"recommended to use a third-party project for this. In this tutorial, we'll " +"use `meson-python`_. (If you want to use another one, see :ref:`first-" +"extension-other-tools`.)" +msgstr "" + +#: ../../extending/first-extension-module.rst:135 +msgid "``meson-python`` requires defining a \"project\" using two extra files." +msgstr "" + +#: ../../extending/first-extension-module.rst:137 +msgid "First, add ``pyproject.toml`` with these contents:" +msgstr "" + +#: ../../extending/first-extension-module.rst:139 +msgid "" +"[build-system]\n" +"build-backend = 'mesonpy'\n" +"requires = ['meson-python']\n" +"\n" +"[project]\n" +"# Placeholder project information\n" +"# (change this before distributing the module)\n" +"name = 'sampleproject'\n" +"version = '0'" +msgstr "" +"[build-system]\n" +"build-backend = 'mesonpy'\n" +"requires = ['meson-python']\n" +"\n" +"[project]\n" +"# 佔位用的專案資訊\n" +"# (在發布模組之前請修改此處)\n" +"name = 'sampleproject'\n" +"version = '0'" + +#: ../../extending/first-extension-module.rst:151 +msgid "Then, create ``meson.build`` containing the following:" +msgstr "" + +#: ../../extending/first-extension-module.rst:153 +msgid "" +"project('sampleproject', 'c')\n" +"\n" +"py = import('python').find_installation(pure: false)\n" +"\n" +"py.extension_module(\n" +" 'spam', # name of the importable Python module\n" +" 'spammodule.c', # the C source file\n" +" install: true,\n" +")" +msgstr "" +"project('sampleproject', 'c')\n" +"\n" +"py = import('python').find_installation(pure: false)\n" +"\n" +"py.extension_module(\n" +" 'spam', # 可引入的 Python 模組名稱\n" +" 'spammodule.c', # C 原始檔\n" +" install: true,\n" +")" + +#: ../../extending/first-extension-module.rst:167 +msgid "" +"See the `meson-python documentation `_ for details on " +"configuration." +msgstr "" + +#: ../../extending/first-extension-module.rst:170 +msgid "" +"Now, build install the *project in the current directory* (``.``) via " +"``pip``:" +msgstr "" + +#: ../../extending/first-extension-module.rst:172 +msgid "python -m pip -v install ." +msgstr "python -m pip -v install ." + +#: ../../extending/first-extension-module.rst:176 +msgid "" +"The ``-v`` (``--verbose``) option causes ``pip`` to show the output from the " +"compiler, which is often useful during development." +msgstr "" + +#: ../../extending/first-extension-module.rst:181 +msgid "" +"If you don't have ``pip`` installed, run ``python -m ensurepip``, preferably " +"in a :ref:`virtual environment `. (Or, if you prefer another tool " +"that can build and install ``pyproject.toml``-based projects, use that.)" +msgstr "" + +#: ../../extending/first-extension-module.rst:189 +msgid "" +"Note that you will need to run this command again every time you change your " +"extension. Unlike Python, C has an explicit compilation step." +msgstr "" + +#: ../../extending/first-extension-module.rst:193 +msgid "" +"When your extension is compiled and installed, start Python and try to " +"import it. This should fail with the following exception:" +msgstr "" + +#: ../../extending/first-extension-module.rst:197 +msgid "" +">>> import spam\n" +"Traceback (most recent call last):\n" +" ...\n" +"ImportError: dynamic module does not define module export function " +"(PyModExport_spam or PyInit_spam)" +msgstr "" +">>> import spam\n" +"Traceback (most recent call last):\n" +" ...\n" +"ImportError: dynamic module does not define module export function " +"(PyModExport_spam or PyInit_spam)" + +#: ../../extending/first-extension-module.rst:206 +msgid "Module export hook" +msgstr "" + +#: ../../extending/first-extension-module.rst:208 +msgid "" +"The exception you got when you tried to import the module told you that " +"Python is looking for a \"module export function\", also known as a :ref:" +"`module export hook `. Let's define one." +msgstr "" + +#: ../../extending/first-extension-module.rst:213 +msgid "First, add a prototype below the ``#include`` lines:" +msgstr "" + +#: ../../extending/first-extension-module.rst:215 +msgid "" +"\n" +"PyMODEXPORT_FUNC PyModExport_spam(void);\n" +"\n" +msgstr "" +"\n" +"PyMODEXPORT_FUNC PyModExport_spam(void);\n" +"\n" + +#: ../../extending/first-extension-module.rst:220 +msgid "" +"The prototype is not strictly necessary, but some modern compilers emit " +"warnings without it. It's generally better to add the prototype than to " +"disable the warning." +msgstr "" + +#: ../../extending/first-extension-module.rst:224 +msgid "" +"The :c:macro:`PyMODEXPORT_FUNC` macro declares the function's return type, " +"and adds any special linkage declarations needed to make the function " +"visible and usable when CPython loads it." +msgstr "" + +#: ../../extending/first-extension-module.rst:228 +msgid "" +"After the prototype, add the function itself. For now, make it return " +"``NULL``:" +msgstr "" + +#: ../../extending/first-extension-module.rst:231 +msgid "" +"PyMODEXPORT_FUNC\n" +"PyModExport_spam(void)\n" +"{\n" +" return NULL;\n" +"}" +msgstr "" +"PyMODEXPORT_FUNC\n" +"PyModExport_spam(void)\n" +"{\n" +" return NULL;\n" +"}" + +#: ../../extending/first-extension-module.rst:239 +msgid "" +"Compile and load the module again. You should get a different error this " +"time." +msgstr "" + +#: ../../extending/first-extension-module.rst:242 +msgid "" +">>> import spam\n" +"Traceback (most recent call last):\n" +" ...\n" +"SystemError: module export hook for module 'spam' failed without setting an " +"exception" +msgstr "" +">>> import spam\n" +"Traceback (most recent call last):\n" +" ...\n" +"SystemError: module export hook for module 'spam' failed without setting an " +"exception" + +#: ../../extending/first-extension-module.rst:249 +msgid "" +"Simply returning ``NULL`` is *not* correct behavior for an export hook, and " +"CPython complains about it. That's good -- it means that CPython found the " +"function! Let's now make it do something useful." +msgstr "" + +#: ../../extending/first-extension-module.rst:256 +msgid "The slot table" +msgstr "" + +#: ../../extending/first-extension-module.rst:258 +msgid "" +"Rather than ``NULL``, the export hook should return the information needed " +"to create a module. Let's start with the basics: the name and docstring." +msgstr "" + +#: ../../extending/first-extension-module.rst:262 +msgid "" +"The information should be defined in an array of :c:type:`PySlot` entries, " +"which are essentially key-value pairs. Define this array just before your " +"export hook:" +msgstr "" + +#: ../../extending/first-extension-module.rst:266 +msgid "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot spam_slots[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"spam\"),\n" +" PySlot_STATIC_DATA(Py_mod_doc, \"A wonderful module with an example " +"function\"),\n" +" PySlot_END\n" +"};" +msgstr "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot spam_slots[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"spam\"),\n" +" PySlot_STATIC_DATA(Py_mod_doc, \"A wonderful module with an example " +"function\"),\n" +" PySlot_END\n" +"};" + +#: ../../extending/first-extension-module.rst:277 +msgid "" +"The :c:macro:`PySlot_STATIC_DATA` macro is used when the slot value (here: " +"``&abi_info``, ``\"spam\"``, and the docstring) is a pointer to constant, " +"statically allocated data." +msgstr "" + +#: ../../extending/first-extension-module.rst:281 +msgid "" +"The ``PyABIInfo_VAR(abi_info);`` macro and the :c:data:`Py_mod_abi` slot are " +"a bit of boilerplate that helps prevent extensions compiled for a different " +"version of Python from crashing the interpreter." +msgstr "" + +#: ../../extending/first-extension-module.rst:285 +msgid "" +"For both :c:data:`Py_mod_name` and :c:data:`Py_mod_doc`, the values are C " +"strings -- that is, NUL-terminated, UTF-8 encoded byte arrays." +msgstr "" + +#: ../../extending/first-extension-module.rst:288 +msgid "" +"Note ``PySlot_END`` sentinel entry at the end. This marks the end of the " +"array. If you forget it, you'll trigger undefined behavior." +msgstr "" + +#: ../../extending/first-extension-module.rst:292 +msgid "" +"The array is defined as ``static`` -- that is, not visible outside this ``." +"c`` file. This will be a common theme. CPython only needs to access the " +"export hook; all global variables and all other functions should generally " +"be ``static``, so that they don't clash with other extensions." +msgstr "" + +#: ../../extending/first-extension-module.rst:298 +msgid "Return this array from your export hook instead of ``NULL``:" +msgstr "" + +#: ../../extending/first-extension-module.rst:300 +msgid "" +"PyMODEXPORT_FUNC\n" +"PyModExport_spam(void)\n" +"{\n" +" return spam_slots;\n" +"}" +msgstr "" +"PyMODEXPORT_FUNC\n" +"PyModExport_spam(void)\n" +"{\n" +" return spam_slots;\n" +"}" + +#: ../../extending/first-extension-module.rst:309 +msgid "Now, recompile and try it out:" +msgstr "" + +#: ../../extending/first-extension-module.rst:311 +msgid "" +">>> import spam\n" +">>> print(spam)\n" +"" +msgstr "" +">>> import spam\n" +">>> print(spam)\n" +"" + +#: ../../extending/first-extension-module.rst:317 +msgid "You have an extension module! Try ``help(spam)`` to see the docstring." +msgstr "" + +#: ../../extending/first-extension-module.rst:320 +msgid "The next step will be adding a function." +msgstr "" + +#: ../../extending/first-extension-module.rst:326 +msgid "Exposing a function" +msgstr "" + +#: ../../extending/first-extension-module.rst:328 +msgid "" +"To expose the :c:func:`system` C function directly to Python, we'll need to " +"write a layer of glue code to convert arguments from Python objects to C " +"values, and the C return value back to Python." +msgstr "" + +#: ../../extending/first-extension-module.rst:332 +msgid "" +"One of the simplest ways to write glue code is a \":c:data:`METH_O`\" " +"function, which takes two Python objects and returns one. All Python objects " +"-- regardless of the Python type -- are represented in C as pointers to the :" +"c:type:`PyObject` structure." +msgstr "" + +#: ../../extending/first-extension-module.rst:337 +msgid "Add such a function above the slots array::" +msgstr "" + +#: ../../extending/first-extension-module.rst:339 +msgid "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" Py_RETURN_NONE;\n" +"}" +msgstr "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" Py_RETURN_NONE;\n" +"}" + +#: ../../extending/first-extension-module.rst:345 +msgid "" +"For now, we ignore the arguments, and use the :c:macro:`Py_RETURN_NONE` " +"macro, which expands to a ``return`` statement that properly returns a " +"Python :py:data:`None` object." +msgstr "" + +#: ../../extending/first-extension-module.rst:349 +msgid "" +"Recompile your extension to make sure you don't have syntax errors. We " +"haven't yet added ``spam_system`` to the module, so you might get a warning " +"that ``spam_system`` is unused." +msgstr "" + +#: ../../extending/first-extension-module.rst:356 +msgid "Method definitions" +msgstr "" + +#: ../../extending/first-extension-module.rst:358 +msgid "" +"To expose the C function to Python, you will need to provide several pieces " +"of information in a structure called :c:type:`PyMethodDef` [#why-" +"pymethoddef]_:" +msgstr "" + +#: ../../extending/first-extension-module.rst:362 +msgid "``ml_name``: the name of the Python function;" +msgstr "" + +#: ../../extending/first-extension-module.rst:363 +msgid "``ml_doc``: a docstring;" +msgstr "" + +#: ../../extending/first-extension-module.rst:364 +msgid "``ml_meth``: the C function to be called; and" +msgstr "" + +#: ../../extending/first-extension-module.rst:365 +msgid "" +"``ml_flags``: a set of flags describing details like how Python arguments " +"are passed to the C function. We'll use :c:data:`METH_O` here -- the flag " +"that matches our ``spam_system`` function's signature." +msgstr "" + +#: ../../extending/first-extension-module.rst:370 +msgid "" +"Because modules typically create several functions, these definitions need " +"to be collected in an array, with a zero-filled sentinel at the end. Add " +"this array just below the ``spam_system`` function:" +msgstr "" + +#: ../../extending/first-extension-module.rst:374 +msgid "" +"\n" +"static PyMethodDef spam_methods[] = {\n" +" {\n" +" .ml_name=\"system\",\n" +" .ml_meth=spam_system,\n" +" .ml_flags=METH_O,\n" +" .ml_doc=\"Execute a shell command.\",\n" +" },\n" +" {NULL, NULL, 0, NULL} /* Sentinel */\n" +"};\n" +"\n" +msgstr "" +"\n" +"static PyMethodDef spam_methods[] = {\n" +" {\n" +" .ml_name=\"system\",\n" +" .ml_meth=spam_system,\n" +" .ml_flags=METH_O,\n" +" .ml_doc=\"Execute a shell command.\",\n" +" },\n" +" {NULL, NULL, 0, NULL} /* 哨兵 */\n" +"};\n" +"\n" + +#: ../../extending/first-extension-module.rst:378 +msgid "" +"As with module slots, a zero-filled sentinel marks the end of the array." +msgstr "" +"As with module slots, a zero-filled sentinel marks the end of the array." + +#: ../../extending/first-extension-module.rst:380 +msgid "" +"Next, we'll add the method to the module. Add a :c:data:`Py_mod_methods` " +"slot to your :c:type:`PyMethodDef` array:" +msgstr "" + +#: ../../extending/first-extension-module.rst:383 +msgid "" +"\n" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot spam_slots[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"spam\"),\n" +" PySlot_STATIC_DATA(Py_mod_doc, \"A wonderful module with an example " +"function\"),\n" +" PySlot_STATIC_DATA(Py_mod_methods, spam_methods),\n" +" PySlot_END\n" +"};\n" +"\n" +msgstr "" +"\n" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot spam_slots[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"spam\"),\n" +" PySlot_STATIC_DATA(Py_mod_doc, \"A wonderful module with an example " +"function\"),\n" +" PySlot_STATIC_DATA(Py_mod_methods, spam_methods),\n" +" PySlot_END\n" +"};\n" +"\n" + +#: ../../extending/first-extension-module.rst:388 +msgid "" +"Recompile your extension again, and test it. Be sure to restart the Python " +"interpreter, so that ``import spam`` picks up the new version of the module." +msgstr "" +"Recompile your extension again, and test it. Be sure to restart the Python " +"interpreter, so that ``import spam`` picks up the new version of the module." + +#: ../../extending/first-extension-module.rst:392 +msgid "You should now be able to call the function:" +msgstr "" + +#: ../../extending/first-extension-module.rst:394 +msgid "" +">>> import spam\n" +">>> print(spam.system)\n" +"\n" +">>> print(spam.system('whoami'))\n" +"None" +msgstr "" +">>> import spam\n" +">>> print(spam.system)\n" +"\n" +">>> print(spam.system('whoami'))\n" +"None" + +#: ../../extending/first-extension-module.rst:402 +msgid "" +"Note that our ``spam.system`` does not yet run the ``whoami`` command; it " +"only returns ``None``." +msgstr "" + +#: ../../extending/first-extension-module.rst:405 +msgid "" +"Check that the function accepts exactly one argument, as specified by the :c:" +"data:`METH_O` flag:" +msgstr "" + +#: ../../extending/first-extension-module.rst:408 +msgid "" +">>> print(spam.system('too', 'many', 'arguments'))\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: spam.system() takes exactly one argument (3 given)" +msgstr "" +">>> print(spam.system('too', 'many', 'arguments'))\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: spam.system() takes exactly one argument (3 given)" + +#: ../../extending/first-extension-module.rst:417 +msgid "Returning an integer" +msgstr "" + +#: ../../extending/first-extension-module.rst:419 +msgid "" +"Now, let's take a look at the return value. Instead of ``None``, we'll want " +"``spam.system`` to return a number -- that is, a Python :py:type:`int` " +"object. Eventually this will be the exit code of a system command, but let's " +"start with a fixed value, say, ``3``." +msgstr "" + +#: ../../extending/first-extension-module.rst:425 +msgid "" +"The Python C API provides a function to create a Python :py:type:`int` " +"object from a C ``int`` value: :c:func:`PyLong_FromLong`. [#why-" +"pylongfromlong]_" +msgstr "" + +#: ../../extending/first-extension-module.rst:428 +msgid "To call it, replace the ``Py_RETURN_NONE`` with the following 3 lines:" +msgstr "" + +#: ../../extending/first-extension-module.rst:432 +msgid "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" int status = 3;\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}" +msgstr "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" int status = 3;\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}" + +#: ../../extending/first-extension-module.rst:444 +msgid "" +"Recompile, restart the Python interpreter again, and check that the function " +"now returns 3:" +msgstr "" + +#: ../../extending/first-extension-module.rst:447 +msgid "" +">>> import spam\n" +">>> spam.system('whoami')\n" +"3" +msgstr "" +">>> import spam\n" +">>> spam.system('whoami')\n" +"3" + +#: ../../extending/first-extension-module.rst:455 +msgid "Accepting a string" +msgstr "" + +#: ../../extending/first-extension-module.rst:457 +msgid "Finally, let's handle the function argument." +msgstr "" + +#: ../../extending/first-extension-module.rst:459 +msgid "" +"Our C function, :c:func:`!spam_system`, takes two arguments. The first one, " +"``PyObject *self``, will be set to the ``spam`` module object. This isn't " +"useful in our case, so we'll ignore it." +msgstr "" + +#: ../../extending/first-extension-module.rst:464 +msgid "" +"The other one, ``PyObject *arg``, will be set to the object that the user " +"passed from Python. We expect that it should be a Python string. In order to " +"use the information in it, we will need to convert it to a C value -- in " +"this case, a C string (``const char *``)." +msgstr "" + +#: ../../extending/first-extension-module.rst:470 +msgid "" +"There's a slight type mismatch here: Python's :py:class:`str` objects store " +"Unicode text, but C strings are arrays of bytes. So, we'll need to *encode* " +"the data, and we'll use the UTF-8 encoding for it. (UTF-8 might not always " +"be correct for system commands, but it's what :py:meth:`str.encode` uses by " +"default, and the C API has special support for it.)" +msgstr "" + +#: ../../extending/first-extension-module.rst:477 +msgid "" +"The function to encode a Python string into a UTF-8 buffer is named :c:func:" +"`PyUnicode_AsUTF8AndSize` [#why-pyunicodeasutf8]_. Call it like this:" +msgstr "" + +#: ../../extending/first-extension-module.rst:481 +msgid "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" const char *command = PyUnicode_AsUTF8AndSize(arg, NULL);\n" +" int status = 3;\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}" +msgstr "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" const char *command = PyUnicode_AsUTF8AndSize(arg, NULL);\n" +" int status = 3;\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}" + +#: ../../extending/first-extension-module.rst:493 +msgid "" +"If :c:func:`PyUnicode_AsUTF8AndSize` is successful, *command* will point to " +"the resulting C string -- a zero-terminated array of bytes [#embedded-nul]_. " +"This buffer is managed by the *arg* object, which means we don't need to " +"free it, but we must follow some rules:" +msgstr "" + +#: ../../extending/first-extension-module.rst:498 +msgid "" +"We should only use the buffer inside the ``spam_system`` function. After " +"``spam_system`` returns, *arg* and the buffer it manages might be garbage-" +"collected." +msgstr "" + +#: ../../extending/first-extension-module.rst:501 +msgid "We must not modify it. This is why we use ``const``." +msgstr "" + +#: ../../extending/first-extension-module.rst:503 +msgid "" +"If :c:func:`PyUnicode_AsUTF8AndSize` was *not* successful, it returns a " +"``NULL`` pointer. When calling *any* Python C API, we always need to handle " +"such error cases. The way to do this in general is left for later chapters " +"of this documentation. For now, be assured that we are already handling " +"errors from :c:func:`PyLong_FromLong` correctly." +msgstr "" + +#: ../../extending/first-extension-module.rst:510 +msgid "" +"For the :c:func:`PyUnicode_AsUTF8AndSize` call, the correct way to handle " +"errors is returning ``NULL`` from ``spam_system``. Add an ``if`` block for " +"this:" +msgstr "" + +#: ../../extending/first-extension-module.rst:515 +msgid "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" const char *command = PyUnicode_AsUTF8AndSize(arg);\n" +" if (command == NULL) {\n" +" return NULL;\n" +" }\n" +" int status = 3;\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}" +msgstr "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" const char *command = PyUnicode_AsUTF8AndSize(arg);\n" +" if (command == NULL) {\n" +" return NULL;\n" +" }\n" +" int status = 3;\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}" + +#: ../../extending/first-extension-module.rst:530 +msgid "" +"To test that error handling works, compile again, restart Python so that " +"``import spam`` picks up the new version of your module, and try passing a " +"non-string value to your function:" +msgstr "" + +#: ../../extending/first-extension-module.rst:534 +msgid "" +">>> import spam\n" +">>> spam.system(3)\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: bad argument type for built-in operation" +msgstr "" +">>> import spam\n" +">>> spam.system(3)\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: bad argument type for built-in operation" + +#: ../../extending/first-extension-module.rst:542 +msgid "" +"Now, all that is left is calling the C library function :c:func:`system` " +"with the ``char *`` buffer, and using its result instead of the ``3``:" +msgstr "" + +#: ../../extending/first-extension-module.rst:545 +msgid "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" const char *command = PyUnicode_AsUTF8AndSize(arg);\n" +" if (command == NULL) {\n" +" return NULL;\n" +" }\n" +" int status = system(command);\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}" +msgstr "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" const char *command = PyUnicode_AsUTF8AndSize(arg);\n" +" if (command == NULL) {\n" +" return NULL;\n" +" }\n" +" int status = system(command);\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}" + +#: ../../extending/first-extension-module.rst:560 +msgid "" +"Compile your module, restart Python, and test. This time, you should see " +"your username -- the output of the ``whoami`` system command:" +msgstr "" + +#: ../../extending/first-extension-module.rst:564 +msgid "" +">>> import spam\n" +">>> result = spam.system('whoami')\n" +"User Name\n" +">>> result\n" +"0" +msgstr "" +">>> import spam\n" +">>> result = spam.system('whoami')\n" +"User Name\n" +">>> result\n" +"0" + +#: ../../extending/first-extension-module.rst:572 +msgid "" +"You can also test with other commands, like ``ls``, ``dir``, or one that " +"doesn't exist:" +msgstr "" + +#: ../../extending/first-extension-module.rst:575 +msgid "" +">>> import spam\n" +">>> result = spam.system('nonexistent-command')\n" +"sh: line 1: nonexistent-command: command not found\n" +">>> result\n" +"32512" +msgstr "" +">>> import spam\n" +">>> result = spam.system('nonexistent-command')\n" +"sh: line 1: nonexistent-command: command not found\n" +">>> result\n" +"32512" + +#: ../../extending/first-extension-module.rst:585 +msgid "The result" +msgstr "" + +#: ../../extending/first-extension-module.rst:588 +msgid "" +"Congratulations! You have written a complete Python C API extension module, " +"and completed this tutorial!" +msgstr "" + +#: ../../extending/first-extension-module.rst:592 +msgid "Here is the entire source file, for your convenience:" +msgstr "" + +#: ../../extending/first-extension-module.rst:596 +msgid "" +"/// Includes\n" +"\n" +"#include \n" +"#include // for system()\n" +"\n" +"/// Implementation of spam.system\n" +"\n" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" const char *command = PyUnicode_AsUTF8AndSize(arg, NULL);\n" +" if (command == NULL) {\n" +" return NULL;\n" +" }\n" +" int status = system(command);\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}\n" +"\n" +"/// Module method table\n" +"\n" +"static PyMethodDef spam_methods[] = {\n" +" {\n" +" .ml_name=\"system\",\n" +" .ml_meth=spam_system,\n" +" .ml_flags=METH_O,\n" +" .ml_doc=\"Execute a shell command.\",\n" +" },\n" +" {NULL, NULL, 0, NULL} /* Sentinel */\n" +"};\n" +"\n" +"/// Module slot table\n" +"\n" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot spam_slots[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"spam\"),\n" +" PySlot_STATIC_DATA(Py_mod_doc, \"A wonderful module with an example " +"function\"),\n" +" PySlot_STATIC_DATA(Py_mod_methods, spam_methods),\n" +" PySlot_END\n" +"};\n" +"\n" +"/// Export hook prototype\n" +"\n" +"PyMODEXPORT_FUNC PyModExport_spam(void);\n" +"\n" +"/// Module export hook\n" +"\n" +"PyMODEXPORT_FUNC\n" +"PyModExport_spam(void)\n" +"{\n" +" return spam_slots;\n" +"}\n" +msgstr "" +"/// 引入標頭檔\n" +"\n" +"#include \n" +"#include // 為了 system()\n" +"\n" +"/// spam.system 的實作\n" +"\n" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *arg)\n" +"{\n" +" const char *command = PyUnicode_AsUTF8AndSize(arg, NULL);\n" +" if (command == NULL) {\n" +" return NULL;\n" +" }\n" +" int status = system(command);\n" +" PyObject *result = PyLong_FromLong(status);\n" +" return result;\n" +"}\n" +"\n" +"/// 模組方法表\n" +"\n" +"static PyMethodDef spam_methods[] = {\n" +" {\n" +" .ml_name=\"system\",\n" +" .ml_meth=spam_system,\n" +" .ml_flags=METH_O,\n" +" .ml_doc=\"Execute a shell command.\",\n" +" },\n" +" {NULL, NULL, 0, NULL} /* 哨兵 */\n" +"};\n" +"\n" +"/// 模組插槽表\n" +"\n" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot spam_slots[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"spam\"),\n" +" PySlot_STATIC_DATA(Py_mod_doc, \"A wonderful module with an example " +"function\"),\n" +" PySlot_STATIC_DATA(Py_mod_methods, spam_methods),\n" +" PySlot_END\n" +"};\n" +"\n" +"/// 匯出掛鉤原型\n" +"\n" +"PyMODEXPORT_FUNC PyModExport_spam(void);\n" +"\n" +"/// 模組匯出掛鉤\n" +"\n" +"PyMODEXPORT_FUNC\n" +"PyModExport_spam(void)\n" +"{\n" +" return spam_slots;\n" +"}\n" + +#: ../../extending/first-extension-module.rst:603 +msgid "Appendix: Other build tools" +msgstr "" + +#: ../../extending/first-extension-module.rst:605 +msgid "" +"You should be able to follow this tutorial -- except the *Running your build " +"tool* section itself -- with a build tool other than ``meson-python``." +msgstr "" + +#: ../../extending/first-extension-module.rst:609 +msgid "" +"The Python Packaging User Guide has a `list of recommended tools `_; be sure to choose one for the C language." +msgstr "" + +#: ../../extending/first-extension-module.rst:614 +msgid "Workaround for missing PyInit function" +msgstr "" + +#: ../../extending/first-extension-module.rst:616 +msgid "" +"If your build tool output complains about missing ``PyInit_spam``, add the " +"following function to your module for now:" +msgstr "" + +#: ../../extending/first-extension-module.rst:619 +msgid "" +"// A workaround\n" +"void *PyInit_spam(void) { return NULL; }" +msgstr "" +"// 權宜做法\n" +"void *PyInit_spam(void) { return NULL; }" + +#: ../../extending/first-extension-module.rst:624 +msgid "" +"This is a shim for an old-style :ref:`initialization function `, which was required in extension modules for CPython 3.14 and " +"below. Current CPython does not need it, but some build tools may still " +"assume that all extension modules need to define it." +msgstr "" + +#: ../../extending/first-extension-module.rst:629 +msgid "" +"If you use this workaround, you will get the exception ``SystemError: " +"initialization of spam failed without raising an exception`` instead of " +"``ImportError: dynamic module does not define module export function``." +msgstr "" + +#: ../../extending/first-extension-module.rst:636 +msgid "Compiling directly" +msgstr "" + +#: ../../extending/first-extension-module.rst:638 +msgid "" +"Using a third-party build tool is heavily recommended, as it will take care " +"of various details of your platform and Python installation, of naming the " +"resulting extension, and, later, of distributing your work." +msgstr "" + +#: ../../extending/first-extension-module.rst:643 +msgid "" +"If you are building an extension for as *specific* system, or for yourself " +"only, you might instead want to run your compiler directly. The way to do " +"this is system-specific; be prepared for issues you will need to solve " +"yourself." +msgstr "" + +#: ../../extending/first-extension-module.rst:649 +msgid "Linux" +msgstr "Linux" + +#: ../../extending/first-extension-module.rst:651 +msgid "" +"On Linux, the Python development package may include a ``python3-config`` " +"command that prints out the required compiler flags. If you use it, check " +"that it corresponds to the CPython interpreter you'll use to load the " +"module. Then, start with the following command:" +msgstr "" + +#: ../../extending/first-extension-module.rst:657 +msgid "" +"gcc --shared $(python3-config --cflags --ldflags) spammodule.c -o spam.so" +msgstr "" +"gcc --shared $(python3-config --cflags --ldflags) spammodule.c -o spam.so" + +#: ../../extending/first-extension-module.rst:661 +msgid "" +"This should generate a ``spam.so`` file that you need to put in a directory " +"on :py:attr:`sys.path`." +msgstr "" + +#: ../../extending/first-extension-module.rst:666 +msgid "Footnotes" +msgstr "" + +#: ../../extending/first-extension-module.rst:667 +msgid "``spam`` is the favorite food of Monty Python fans..." +msgstr "" + +#: ../../extending/first-extension-module.rst:668 +msgid "" +"The source file name is entirely up to you, though some tools can be picky " +"about the ``.c`` extension. This tutorial uses the traditional ``*module.c`` " +"suffix. Some people would just use :file:`spam.c` to implement a module " +"named ``spam``, projects where Python isn't the primary language might use " +"``py_spam.c``, and so on." +msgstr "" + +#: ../../extending/first-extension-module.rst:675 +msgid "" +"Including :file:`stdlib.h` is technically not necessary, since :file:`Python." +"h` includes it and :ref:`several other standard headers ` for its own use or for backwards compatibility. However, it is " +"good practice to explicitly include what you need." +msgstr "" + +#: ../../extending/first-extension-module.rst:680 +msgid "" +"The :c:type:`!PyMethodDef` structure is also used to create methods of " +"classes, so there's no separate \":c:type:`!PyFunctionDef`\"." +msgstr "" + +#: ../../extending/first-extension-module.rst:683 +msgid "" +"The name :c:func:`PyLong_FromLong` might not seem obvious. ``PyLong`` refers " +"to a the Python :py:class:`int`, which was originally called ``long``; the " +"``FromLong`` refers to the C ``long`` (or ``long int``) type." +msgstr "" + +#: ../../extending/first-extension-module.rst:688 +msgid "" +"Here, ``PyUnicode`` refers to the original name of the Python :py:class:" +"`str` class: ``unicode``." +msgstr "" + +#: ../../extending/first-extension-module.rst:691 +msgid "" +"The ``AndSize`` part of the name refers to the fact that this function can " +"also retrieve the size of the buffer, using an output argument. We don't " +"need this, so we set the second argument to NULL." +msgstr "" + +#: ../../extending/first-extension-module.rst:694 +msgid "" +"We're ignoring the fact that Python strings can also contain NUL bytes, " +"which terminate a C string. In other words, our function will treat ``spam." +"system(\"foo\\0bar\")`` as ``spam.system(\"foo\")``. This possibility can " +"lead to security issues, so the real ``os.system`` function size checks for " +"this case and raises an error." +msgstr "" diff --git a/extending/index.po b/extending/index.po index 6a8adc58215..67d804d9c5d 100644 --- a/extending/index.po +++ b/extending/index.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-14 00:21+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2021-07-06 22:18+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -26,20 +26,24 @@ msgstr "擴充和嵌入 Python 直譯器" #: ../../extending/index.rst:7 msgid "" "This document describes how to write modules in C or C++ to extend the " -"Python interpreter with new modules. Those modules can not only define new " -"functions but also new object types and their methods. The document also " -"describes how to embed the Python interpreter in another application, for " -"use as an extension language. Finally, it shows how to compile and link " -"extension modules so that they can be loaded dynamically (at run time) into " -"the interpreter, if the underlying operating system supports this feature." +"Python interpreter with new modules. Those modules can do what Python code " +"does -- define functions, object types and methods -- but also interact with " +"native libraries or achieve better performance by avoiding the overhead of " +"an interpreter. The document also describes how to embed the Python " +"interpreter in another application, for use as an extension language. " +"Finally, it shows how to compile and link extension modules so that they can " +"be loaded dynamically (at run time) into the interpreter, if the underlying " +"operating system supports this feature." msgstr "" "這份說明文件描述如何在 C 或 C++ 中編寫模組,並使用新模組來擴充 Python 直譯器" -"功能。那些模組不僅可以定義新的函式,也可以定義新的物件型別及其方法 (method)。" -"文件內容也會描述如何將 Python 直譯器嵌入另一個應用程式中,做為一種擴充語言 " -"(extension language) 使用。最後,它會展示如何編譯及連結擴充模組,使那些模組可" -"以動態地(在執行環境)被載入到直譯器中,前提是底層作業系統有支援這個功能。" +"功能。那些模組可以做到 Python 程式碼能做的事──定義函式、物件型別及方法 " +"(method)──但也能與原生函式庫互動,或藉由避免直譯器的額外負擔來達到更好的效" +"能。文件內容也會描述如何將 Python 直譯器嵌入另一個應用程式中,做為一種擴充語" +"言 (extension language) 使用。最後,它會展示如何編譯及連結擴充模組,使那些模" +"組可以動態地(在執行環境)被載入到直譯器中,前提是底層作業系統有支援這個功" +"能。" -#: ../../extending/index.rst:15 +#: ../../extending/index.rst:17 msgid "" "This document assumes basic knowledge about C and Python. For an informal " "introduction to Python, see :ref:`tutorial-index`. :ref:`reference-index` " @@ -54,32 +58,82 @@ msgstr "" "index`\\ 則記錄了賦予此語言廣泛應用範圍的模組(包含內建模組與以 Python 撰寫的" "模組)。" -#: ../../extending/index.rst:22 +#: ../../extending/index.rst:24 msgid "" "For a detailed description of the whole Python/C API, see the separate :ref:" "`c-api-index`." msgstr "關於完整的 Python/C API 詳細介紹,請參閱另外一份 :ref:`c-api-index`。" #: ../../extending/index.rst:27 +msgid "" +"To support extensions, Python's C API (Application Programmers Interface) " +"defines a set of functions, macros and variables that provide access to most " +"aspects of the Python run-time system. The Python API is incorporated in a " +"C source file by including the header ``\"Python.h\"``." +msgstr "" + +#: ../../extending/index.rst:34 +msgid "" +"The C extension interface is specific to CPython, and extension modules do " +"not work on other Python implementations. In many cases, it is possible to " +"avoid writing C extensions and preserve portability to other " +"implementations. For example, if your use case is calling C library " +"functions or system calls, you should consider using the :mod:`ctypes` " +"module or the `cffi `_ library rather than " +"writing custom C code. These modules let you write Python code to interface " +"with C code and are more portable between implementations of Python than " +"writing and compiling a C extension module." +msgstr "" +"C 擴充介面是 CPython 所特有的,擴充模組在其他 Python 實作上無法運作。在許多情" +"況下,可以避免撰寫 C 擴充並保留對其他實作的可移植性。例如,如果你的用例是呼" +"叫 C 函式庫函式或系統呼叫,你應該考慮使用 :mod:`ctypes` 模組或 `cffi " +"`_ 函式庫,而不是編寫自訂的 C 程式碼。這些模組" +"讓你可以撰寫 Python 程式碼來與 C 程式碼介接,而且比起撰寫和編譯 C 擴充模組," +"這些模組在 Python 實作之間更容易移植。" + +#: ../../extending/index.rst:59 msgid "Recommended third party tools" msgstr "推薦的第三方工具" -#: ../../extending/index.rst:29 +#: ../../extending/index.rst:61 msgid "" -"This guide only covers the basic tools for creating extensions provided as " -"part of this version of CPython. Some :ref:`third party tools ` " -"offer both simpler and more sophisticated approaches to creating C and C++ " -"extensions for Python." +"This document only covers the basic tools for creating extensions provided " +"as part of this version of CPython. Some :ref:`third party tools ` offer both simpler and more sophisticated approaches to creating C " +"and C++ extensions for Python." msgstr "" -"這份指南僅涵蓋了此 CPython 版本所提供的、用以建立擴充的基本工具。有一些\\ :" -"ref:`第三方工具 `,提供了更為簡單及更為複雜的多種方法,來為 " +"這份文件僅涵蓋了此 CPython 版本所提供的、用以建立擴充的基本工具。有一些" +"\\ :ref:`第三方工具 `,提供了更為簡單及更為複雜的多種方法,來為 " "Python 建立 C 和 C++ 擴充。" -#: ../../extending/index.rst:36 -msgid "Creating extensions without third party tools" -msgstr "不使用第三方工具建立擴充" +#: ../../extending/index.rst:66 +msgid "" +"While this document is aimed at extension authors, it should also be helpful " +"to the authors of such tools. For example, the tutorial module can serve as " +"a simple test case for a build tool or sample expected output of a code " +"generator." +msgstr "" + +#: ../../extending/index.rst:73 +msgid "C API Tutorial" +msgstr "" -#: ../../extending/index.rst:38 +#: ../../extending/index.rst:75 +msgid "" +"This tutorial describes how to write a simple module in C or C++, using the " +"Python C API -- that is, using the basic tools provided as part of this " +"version of CPython." +msgstr "" + +#: ../../extending/index.rst:80 +msgid ":ref:`first-extension-module`" +msgstr ":ref:`first-extension-module`" + +#: ../../extending/index.rst:84 +msgid "Guides for intermediate topics" +msgstr "" + +#: ../../extending/index.rst:86 msgid "" "This section of the guide covers creating C and C++ extensions without " "assistance from third party tools. It is intended primarily for creators of " @@ -89,15 +143,31 @@ msgstr "" "本指南中的這一節將說明,在沒有第三方工具的協助下,如何建立 C 和 C ++ 擴充。它" "主要是寫給使用那些工具的創作者們,而不是讓你建立自己的 C 擴充的推薦方法。" -#: ../../extending/index.rst:45 -msgid ":pep:`489` -- Multi-phase extension module initialization" -msgstr ":pep:`489` -- 多階段擴充模組初始化" +#: ../../extending/index.rst:91 +msgid ":ref:`extending-intro`" +msgstr ":ref:`extending-intro`" + +#: ../../extending/index.rst:92 +msgid ":ref:`defining-new-types`" +msgstr ":ref:`defining-new-types`" + +#: ../../extending/index.rst:93 +msgid ":ref:`new-types-topics`" +msgstr ":ref:`new-types-topics`" -#: ../../extending/index.rst:58 +#: ../../extending/index.rst:94 +msgid ":ref:`building`" +msgstr ":ref:`building`" + +#: ../../extending/index.rst:95 +msgid ":ref:`building-on-windows`" +msgstr ":ref:`building-on-windows`" + +#: ../../extending/index.rst:98 msgid "Embedding the CPython runtime in a larger application" msgstr "在更大的應用程式中嵌入 CPython 運行環境 (runtime)" -#: ../../extending/index.rst:60 +#: ../../extending/index.rst:100 msgid "" "Sometimes, rather than creating an extension that runs inside the Python " "interpreter as the main application, it is desirable to instead embed the " @@ -108,6 +178,16 @@ msgstr "" "如將 CPython 運行環境嵌入至一個更大的應用程式中更可取。本節將涵蓋一些要成功完" "成此任務所涉及的細節。" +#: ../../extending/index.rst:105 +msgid ":ref:`embedding`" +msgstr ":ref:`embedding`" + +#~ msgid "Creating extensions without third party tools" +#~ msgstr "不使用第三方工具建立擴充" + +#~ msgid ":pep:`489` -- Multi-phase extension module initialization" +#~ msgstr ":pep:`489` -- 多階段擴充模組初始化" + #~ msgid "" #~ "`Python Packaging User Guide: Binary Extensions `_" diff --git a/extending/newtypes.po b/extending/newtypes.po index 6ddb5552cfb..58b135e9ac3 100644 --- a/extending/newtypes.po +++ b/extending/newtypes.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:34+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -978,11 +978,15 @@ msgid "" msgstr "" #: ../../extending/newtypes.rst:563 +msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set." +msgstr "如果有設定此旗標,則也應該設定 :c:macro:`Py_TPFLAGS_HAVE_GC`。" + +#: ../../extending/newtypes.rst:565 msgid "" "Concretely, here is how the statically declared type object would look::" msgstr "" -#: ../../extending/newtypes.rst:565 +#: ../../extending/newtypes.rst:567 msgid "" "static PyTypeObject TrivialType = {\n" " PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -991,13 +995,13 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes.rst:572 +#: ../../extending/newtypes.rst:574 msgid "" "The only further addition is that ``tp_dealloc`` needs to clear any weak " "references (by calling :c:func:`PyObject_ClearWeakRefs`)::" msgstr "" -#: ../../extending/newtypes.rst:575 +#: ../../extending/newtypes.rst:577 msgid "" "static void\n" "Trivial_dealloc(PyObject *op)\n" @@ -1009,11 +1013,11 @@ msgid "" "}" msgstr "" -#: ../../extending/newtypes.rst:586 +#: ../../extending/newtypes.rst:588 msgid "More Suggestions" msgstr "" -#: ../../extending/newtypes.rst:588 +#: ../../extending/newtypes.rst:590 msgid "" "In order to learn how to implement any specific method for your new data " "type, get the :term:`CPython` source code. Go to the :file:`Objects` " @@ -1022,14 +1026,14 @@ msgid "" "function you want to implement." msgstr "" -#: ../../extending/newtypes.rst:594 +#: ../../extending/newtypes.rst:596 msgid "" "When you need to verify that an object is a concrete instance of the type " "you are implementing, use the :c:func:`PyObject_TypeCheck` function. A " "sample of its use might be something like the following::" msgstr "" -#: ../../extending/newtypes.rst:598 +#: ../../extending/newtypes.rst:600 msgid "" "if (!PyObject_TypeCheck(some_object, &MyType)) {\n" " PyErr_SetString(PyExc_TypeError, \"arg #1 not a mything\");\n" @@ -1037,20 +1041,20 @@ msgid "" "}" msgstr "" -#: ../../extending/newtypes.rst:604 +#: ../../extending/newtypes.rst:606 msgid "Download CPython source releases." msgstr "" -#: ../../extending/newtypes.rst:605 +#: ../../extending/newtypes.rst:607 msgid "https://www.python.org/downloads/source/" msgstr "https://www.python.org/downloads/source/" -#: ../../extending/newtypes.rst:607 +#: ../../extending/newtypes.rst:609 msgid "" "The CPython project on GitHub, where the CPython source code is developed." msgstr "" -#: ../../extending/newtypes.rst:608 +#: ../../extending/newtypes.rst:610 msgid "https://github.com/python/cpython" msgstr "https://github.com/python/cpython" diff --git a/extending/newtypes_tutorial.po b/extending/newtypes_tutorial.po index f9af9cb62f0..04cae0b9f23 100644 --- a/extending/newtypes_tutorial.po +++ b/extending/newtypes_tutorial.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -18,7 +18,7 @@ msgstr "" msgid "Defining Extension Types: Tutorial" msgstr "擴充型別定義教學" -#: ../../extending/newtypes_tutorial.rst:14 +#: ../../extending/newtypes_tutorial.rst:9 msgid "" "Python allows the writer of a C extension module to define new types that " "can be manipulated from Python code, much like the built-in :class:`str` " @@ -27,11 +27,11 @@ msgid "" "can get started. This document is a gentle introduction to the topic." msgstr "" -#: ../../extending/newtypes_tutorial.rst:24 +#: ../../extending/newtypes_tutorial.rst:19 msgid "The Basics" msgstr "" -#: ../../extending/newtypes_tutorial.rst:26 +#: ../../extending/newtypes_tutorial.rst:21 msgid "" "The :term:`CPython` runtime sees all Python objects as variables of " "type :c:expr:`PyObject*`, which serves as a \"base type\" for all Python " @@ -43,20 +43,20 @@ msgid "" "object. These C functions are called \"type methods\"." msgstr "" -#: ../../extending/newtypes_tutorial.rst:35 +#: ../../extending/newtypes_tutorial.rst:30 msgid "" "So, if you want to define a new extension type, you need to create a new " "type object." msgstr "" -#: ../../extending/newtypes_tutorial.rst:38 +#: ../../extending/newtypes_tutorial.rst:33 msgid "" "This sort of thing can only be explained by example, so here's a minimal, " "but complete, module that defines a new type named :class:`!Custom` inside a " "C extension module :mod:`!custom`:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:43 +#: ../../extending/newtypes_tutorial.rst:38 msgid "" "What we're showing here is the traditional way of defining *static* " "extension types. It should be adequate for most uses. The C API also " @@ -64,7 +64,7 @@ msgid "" "the :c:func:`PyType_FromSpec` function, which isn't covered in this tutorial." msgstr "" -#: ../../extending/newtypes_tutorial.rst:48 +#: ../../extending/newtypes_tutorial.rst:43 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -122,26 +122,26 @@ msgid "" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:50 +#: ../../extending/newtypes_tutorial.rst:45 msgid "" "Now that's quite a bit to take in at once, but hopefully bits will seem " "familiar from the previous chapter. This file defines three things:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:53 +#: ../../extending/newtypes_tutorial.rst:48 msgid "" "What a :class:`!Custom` **object** contains: this is the ``CustomObject`` " "struct, which is allocated once for each :class:`!Custom` instance." msgstr "" -#: ../../extending/newtypes_tutorial.rst:55 +#: ../../extending/newtypes_tutorial.rst:50 msgid "" "How the :class:`!Custom` **type** behaves: this is the ``CustomType`` " "struct, which defines a set of flags and function pointers that the " "interpreter inspects when specific operations are requested." msgstr "" -#: ../../extending/newtypes_tutorial.rst:58 +#: ../../extending/newtypes_tutorial.rst:53 msgid "" "How to define and execute the :mod:`!custom` module: this is the " "``PyInit_custom`` function and the associated ``custom_module`` struct for " @@ -149,11 +149,11 @@ msgid "" "fresh module object." msgstr "" -#: ../../extending/newtypes_tutorial.rst:63 +#: ../../extending/newtypes_tutorial.rst:58 msgid "The first bit is::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:65 +#: ../../extending/newtypes_tutorial.rst:60 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -163,7 +163,7 @@ msgstr "" " PyObject_HEAD\n" "} CustomObject;" -#: ../../extending/newtypes_tutorial.rst:69 +#: ../../extending/newtypes_tutorial.rst:64 msgid "" "This is what a Custom object will contain. ``PyObject_HEAD`` is mandatory " "at the start of each object struct and defines a field called ``ob_base`` of " @@ -174,20 +174,20 @@ msgid "" "builds `." msgstr "" -#: ../../extending/newtypes_tutorial.rst:78 +#: ../../extending/newtypes_tutorial.rst:73 msgid "" "There is no semicolon above after the :c:macro:`PyObject_HEAD` macro. Be " "wary of adding one by accident: some compilers will complain." msgstr "" -#: ../../extending/newtypes_tutorial.rst:81 +#: ../../extending/newtypes_tutorial.rst:76 msgid "" "Of course, objects generally store additional data besides the standard " "``PyObject_HEAD`` boilerplate; for example, here is the definition for " "standard Python floats::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:85 +#: ../../extending/newtypes_tutorial.rst:80 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -199,11 +199,11 @@ msgstr "" " double ob_fval;\n" "} PyFloatObject;" -#: ../../extending/newtypes_tutorial.rst:90 +#: ../../extending/newtypes_tutorial.rst:85 msgid "The second bit is the definition of the type object. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:92 +#: ../../extending/newtypes_tutorial.rst:87 msgid "" "static PyTypeObject CustomType = {\n" " .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -225,14 +225,14 @@ msgstr "" " .tp_new = PyType_GenericNew,\n" "};" -#: ../../extending/newtypes_tutorial.rst:103 +#: ../../extending/newtypes_tutorial.rst:98 msgid "" "We recommend using C99-style designated initializers as above, to avoid " "listing all the :c:type:`PyTypeObject` fields that you don't care about and " "also to avoid caring about the fields' declaration order." msgstr "" -#: ../../extending/newtypes_tutorial.rst:107 +#: ../../extending/newtypes_tutorial.rst:102 msgid "" "The actual definition of :c:type:`PyTypeObject` in :file:`object.h` has many " "more :ref:`fields ` than the definition above. The remaining " @@ -240,31 +240,31 @@ msgid "" "to not specify them explicitly unless you need them." msgstr "" -#: ../../extending/newtypes_tutorial.rst:112 +#: ../../extending/newtypes_tutorial.rst:107 msgid "We're going to pick it apart, one field at a time::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:114 +#: ../../extending/newtypes_tutorial.rst:109 msgid ".ob_base = PyVarObject_HEAD_INIT(NULL, 0)" msgstr ".ob_base = PyVarObject_HEAD_INIT(NULL, 0)" -#: ../../extending/newtypes_tutorial.rst:116 +#: ../../extending/newtypes_tutorial.rst:111 msgid "" "This line is mandatory boilerplate to initialize the ``ob_base`` field " "mentioned above. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:119 +#: ../../extending/newtypes_tutorial.rst:114 msgid ".tp_name = \"custom.Custom\"," msgstr ".tp_name = \"custom.Custom\"," -#: ../../extending/newtypes_tutorial.rst:121 +#: ../../extending/newtypes_tutorial.rst:116 msgid "" "The name of our type. This will appear in the default textual " "representation of our objects and in some error messages, for example:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:124 +#: ../../extending/newtypes_tutorial.rst:119 msgid "" ">>> \"\" + custom.Custom()\n" "Traceback (most recent call last):\n" @@ -276,7 +276,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: can only concatenate str (not \"custom.Custom\") to str" -#: ../../extending/newtypes_tutorial.rst:131 +#: ../../extending/newtypes_tutorial.rst:126 msgid "" "Note that the name is a dotted name that includes both the module name and " "the name of the type within the module. The module in this case is :mod:`!" @@ -286,7 +286,7 @@ msgid "" "modules. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:137 +#: ../../extending/newtypes_tutorial.rst:132 msgid "" ".tp_basicsize = sizeof(CustomObject),\n" ".tp_itemsize = 0," @@ -294,14 +294,14 @@ msgstr "" ".tp_basicsize = sizeof(CustomObject),\n" ".tp_itemsize = 0," -#: ../../extending/newtypes_tutorial.rst:140 +#: ../../extending/newtypes_tutorial.rst:135 msgid "" "This is so that Python knows how much memory to allocate when creating " "new :class:`!Custom` instances. :c:member:`~PyTypeObject.tp_itemsize` is " "only used for variable-sized objects and should otherwise be zero." msgstr "" -#: ../../extending/newtypes_tutorial.rst:146 +#: ../../extending/newtypes_tutorial.rst:141 msgid "" "If you want your type to be subclassable from Python, and your type has the " "same :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have " @@ -315,31 +315,31 @@ msgid "" "your base type, and therefore increasing its size." msgstr "" -#: ../../extending/newtypes_tutorial.rst:156 +#: ../../extending/newtypes_tutorial.rst:151 msgid "We set the class flags to :c:macro:`Py_TPFLAGS_DEFAULT`. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:158 +#: ../../extending/newtypes_tutorial.rst:153 msgid ".tp_flags = Py_TPFLAGS_DEFAULT," msgstr ".tp_flags = Py_TPFLAGS_DEFAULT," -#: ../../extending/newtypes_tutorial.rst:160 +#: ../../extending/newtypes_tutorial.rst:155 msgid "" "All types should include this constant in their flags. It enables all of " "the members defined until at least Python 3.3. If you need further members, " "you will need to OR the corresponding flags." msgstr "" -#: ../../extending/newtypes_tutorial.rst:164 +#: ../../extending/newtypes_tutorial.rst:159 msgid "" "We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:166 +#: ../../extending/newtypes_tutorial.rst:161 msgid ".tp_doc = PyDoc_STR(\"Custom objects\")," msgstr ".tp_doc = PyDoc_STR(\"Custom objects\")," -#: ../../extending/newtypes_tutorial.rst:168 +#: ../../extending/newtypes_tutorial.rst:163 msgid "" "To enable object creation, we have to provide " "a :c:member:`~PyTypeObject.tp_new` handler. This is the equivalent of the " @@ -348,17 +348,17 @@ msgid "" "function :c:func:`PyType_GenericNew`. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:173 +#: ../../extending/newtypes_tutorial.rst:168 msgid ".tp_new = PyType_GenericNew," msgstr ".tp_new = PyType_GenericNew," -#: ../../extending/newtypes_tutorial.rst:175 +#: ../../extending/newtypes_tutorial.rst:170 msgid "" "Everything else in the file should be familiar, except for some code " "in :c:func:`!custom_module_exec`::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:178 +#: ../../extending/newtypes_tutorial.rst:173 msgid "" "if (PyType_Ready(&CustomType) < 0) {\n" " return -1;\n" @@ -368,14 +368,14 @@ msgstr "" " return -1;\n" "}" -#: ../../extending/newtypes_tutorial.rst:182 +#: ../../extending/newtypes_tutorial.rst:177 msgid "" "This initializes the :class:`!Custom` type, filling in a number of members " "to the appropriate default values, including :c:member:`~PyObject.ob_type` " "that we initially set to ``NULL``. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:186 +#: ../../extending/newtypes_tutorial.rst:181 msgid "" "if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" " return -1;\n" @@ -385,13 +385,13 @@ msgstr "" " return -1;\n" "}" -#: ../../extending/newtypes_tutorial.rst:190 +#: ../../extending/newtypes_tutorial.rst:185 msgid "" "This adds the type to the module dictionary. This allows us to " "create :class:`!Custom` instances by calling the :class:`!Custom` class:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:193 +#: ../../extending/newtypes_tutorial.rst:188 msgid "" ">>> import custom\n" ">>> mycustom = custom.Custom()" @@ -399,13 +399,13 @@ msgstr "" ">>> import custom\n" ">>> mycustom = custom.Custom()" -#: ../../extending/newtypes_tutorial.rst:198 +#: ../../extending/newtypes_tutorial.rst:193 msgid "" "That's it! All that remains is to build it; put the above code in a file " "called :file:`custom.c`," msgstr "" -#: ../../extending/newtypes_tutorial.rst:201 +#: ../../extending/newtypes_tutorial.rst:196 msgid "" "[build-system]\n" "requires = [\"setuptools\"]\n" @@ -423,11 +423,11 @@ msgstr "" "name = \"custom\"\n" "version = \"1\"\n" -#: ../../extending/newtypes_tutorial.rst:203 +#: ../../extending/newtypes_tutorial.rst:198 msgid "in a file called :file:`pyproject.toml`, and" msgstr "" -#: ../../extending/newtypes_tutorial.rst:205 +#: ../../extending/newtypes_tutorial.rst:200 msgid "" "from setuptools import Extension, setup\n" "setup(ext_modules=[Extension(\"custom\", [\"custom.c\"])])" @@ -435,44 +435,44 @@ msgstr "" "from setuptools import Extension, setup\n" "setup(ext_modules=[Extension(\"custom\", [\"custom.c\"])])" -#: ../../extending/newtypes_tutorial.rst:210 +#: ../../extending/newtypes_tutorial.rst:205 msgid "in a file called :file:`setup.py`; then typing" msgstr "" -#: ../../extending/newtypes_tutorial.rst:212 -#: ../../extending/newtypes_tutorial.rst:550 +#: ../../extending/newtypes_tutorial.rst:207 +#: ../../extending/newtypes_tutorial.rst:545 msgid "$ python -m pip install ." msgstr "$ python -m pip install ." -#: ../../extending/newtypes_tutorial.rst:216 +#: ../../extending/newtypes_tutorial.rst:211 msgid "" "in a shell should produce a file :file:`custom.so` in a subdirectory and " "install it; now fire up Python --- you should be able to ``import custom`` " "and play around with ``Custom`` objects." msgstr "" -#: ../../extending/newtypes_tutorial.rst:220 +#: ../../extending/newtypes_tutorial.rst:215 msgid "That wasn't so hard, was it?" msgstr "" -#: ../../extending/newtypes_tutorial.rst:222 +#: ../../extending/newtypes_tutorial.rst:217 msgid "" "Of course, the current Custom type is pretty uninteresting. It has no data " "and doesn't do anything. It can't even be subclassed." msgstr "" -#: ../../extending/newtypes_tutorial.rst:227 +#: ../../extending/newtypes_tutorial.rst:222 msgid "Adding data and methods to the Basic example" msgstr "" -#: ../../extending/newtypes_tutorial.rst:229 +#: ../../extending/newtypes_tutorial.rst:224 msgid "" "Let's extend the basic example to add some data and methods. Let's also " "make the type usable as a base class. We'll create a new module, :mod:`!" "custom2` that adds these capabilities:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:233 +#: ../../extending/newtypes_tutorial.rst:228 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -619,11 +619,11 @@ msgid "" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:236 +#: ../../extending/newtypes_tutorial.rst:231 msgid "This version of the module has a number of changes." msgstr "" -#: ../../extending/newtypes_tutorial.rst:238 +#: ../../extending/newtypes_tutorial.rst:233 msgid "" "The :class:`!Custom` type now has three data attributes in its C struct, " "*first*, *last*, and *number*. The *first* and *last* variables are Python " @@ -631,11 +631,11 @@ msgid "" "integer." msgstr "" -#: ../../extending/newtypes_tutorial.rst:242 +#: ../../extending/newtypes_tutorial.rst:237 msgid "The object structure is updated accordingly::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:244 +#: ../../extending/newtypes_tutorial.rst:239 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -651,13 +651,13 @@ msgstr "" " int number;\n" "} CustomObject;" -#: ../../extending/newtypes_tutorial.rst:251 +#: ../../extending/newtypes_tutorial.rst:246 msgid "" "Because we now have data to manage, we have to be more careful about object " "allocation and deallocation. At a minimum, we need a deallocation method::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:254 +#: ../../extending/newtypes_tutorial.rst:249 msgid "" "static void\n" "Custom_dealloc(PyObject *op)\n" @@ -677,15 +677,15 @@ msgstr "" " Py_TYPE(self)->tp_free(self);\n" "}" -#: ../../extending/newtypes_tutorial.rst:263 +#: ../../extending/newtypes_tutorial.rst:258 msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:265 +#: ../../extending/newtypes_tutorial.rst:260 msgid ".tp_dealloc = Custom_dealloc," msgstr ".tp_dealloc = Custom_dealloc," -#: ../../extending/newtypes_tutorial.rst:267 +#: ../../extending/newtypes_tutorial.rst:262 msgid "" "This method first clears the reference counts of the two Python " "attributes. :c:func:`Py_XDECREF` correctly handles the case where its " @@ -696,7 +696,7 @@ msgid "" "be an instance of a subclass." msgstr "" -#: ../../extending/newtypes_tutorial.rst:277 +#: ../../extending/newtypes_tutorial.rst:272 msgid "" "The explicit cast to ``CustomObject *`` above is needed because we defined " "``Custom_dealloc`` to take a ``PyObject *`` argument, as the ``tp_dealloc`` " @@ -706,14 +706,14 @@ msgid "" "*)`` is safe. This is object-oriented polymorphism, in C!" msgstr "" -#: ../../extending/newtypes_tutorial.rst:285 +#: ../../extending/newtypes_tutorial.rst:280 msgid "" "In existing code, or in previous versions of this tutorial, you might see " "similar functions take a pointer to the subtype object structure " "(``CustomObject*``) directly, like this::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:289 +#: ../../extending/newtypes_tutorial.rst:284 msgid "" "Custom_dealloc(CustomObject *self)\n" "{\n" @@ -733,19 +733,19 @@ msgstr "" "...\n" ".tp_dealloc = (destructor) Custom_dealloc," -#: ../../extending/newtypes_tutorial.rst:298 +#: ../../extending/newtypes_tutorial.rst:293 msgid "" "This does the same thing on all architectures that CPython supports, but " "according to the C standard, it invokes undefined behavior." msgstr "" -#: ../../extending/newtypes_tutorial.rst:302 +#: ../../extending/newtypes_tutorial.rst:297 msgid "" "We want to make sure that the first and last names are initialized to empty " "strings, so we provide a ``tp_new`` implementation::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:305 +#: ../../extending/newtypes_tutorial.rst:300 msgid "" "static PyObject *\n" "Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" @@ -789,15 +789,15 @@ msgstr "" " return (PyObject *) self;\n" "}" -#: ../../extending/newtypes_tutorial.rst:326 +#: ../../extending/newtypes_tutorial.rst:321 msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:328 +#: ../../extending/newtypes_tutorial.rst:323 msgid ".tp_new = Custom_new," msgstr ".tp_new = Custom_new," -#: ../../extending/newtypes_tutorial.rst:330 +#: ../../extending/newtypes_tutorial.rst:325 msgid "" "The ``tp_new`` handler is responsible for creating (as opposed to " "initializing) objects of the type. It is exposed in Python as " @@ -809,7 +809,7 @@ msgid "" "default values." msgstr "" -#: ../../extending/newtypes_tutorial.rst:338 +#: ../../extending/newtypes_tutorial.rst:333 msgid "" "``tp_new`` is passed the type being instantiated (not necessarily " "``CustomType``, if a subclass is instantiated) and any arguments passed when " @@ -819,30 +819,30 @@ msgid "" "(a.k.a. ``tp_init`` in C or ``__init__`` in Python) methods." msgstr "" -#: ../../extending/newtypes_tutorial.rst:346 +#: ../../extending/newtypes_tutorial.rst:341 msgid "" "``tp_new`` shouldn't call ``tp_init`` explicitly, as the interpreter will do " "it itself." msgstr "" -#: ../../extending/newtypes_tutorial.rst:349 +#: ../../extending/newtypes_tutorial.rst:344 msgid "" "The ``tp_new`` implementation calls the :c:member:`~PyTypeObject.tp_alloc` " "slot to allocate memory::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:352 +#: ../../extending/newtypes_tutorial.rst:347 msgid "self = (CustomObject *) type->tp_alloc(type, 0);" msgstr "self = (CustomObject *) type->tp_alloc(type, 0);" -#: ../../extending/newtypes_tutorial.rst:354 +#: ../../extending/newtypes_tutorial.rst:349 msgid "" "Since memory allocation may fail, we must check " "the :c:member:`~PyTypeObject.tp_alloc` result against ``NULL`` before " "proceeding." msgstr "" -#: ../../extending/newtypes_tutorial.rst:358 +#: ../../extending/newtypes_tutorial.rst:353 msgid "" "We didn't fill the :c:member:`~PyTypeObject.tp_alloc` slot ourselves. " "Rather :c:func:`PyType_Ready` fills it for us by inheriting it from our base " @@ -850,7 +850,7 @@ msgid "" "allocation strategy." msgstr "" -#: ../../extending/newtypes_tutorial.rst:364 +#: ../../extending/newtypes_tutorial.rst:359 msgid "" "If you are creating a co-operative :c:member:`~PyTypeObject.tp_new` (one " "that calls a base type's :c:member:`~PyTypeObject.tp_new` " @@ -864,13 +864,13 @@ msgid "" "without getting a :exc:`TypeError`.)" msgstr "" -#: ../../extending/newtypes_tutorial.rst:374 +#: ../../extending/newtypes_tutorial.rst:369 msgid "" "We also define an initialization function which accepts arguments to provide " "initial values for our instance::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:377 +#: ../../extending/newtypes_tutorial.rst:372 msgid "" "static int\n" "Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" @@ -926,15 +926,15 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:404 +#: ../../extending/newtypes_tutorial.rst:399 msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:406 +#: ../../extending/newtypes_tutorial.rst:401 msgid ".tp_init = Custom_init," msgstr ".tp_init = Custom_init," -#: ../../extending/newtypes_tutorial.rst:408 +#: ../../extending/newtypes_tutorial.rst:403 msgid "" "The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as " "the :meth:`~object.__init__` method. It is used to initialize an object " @@ -942,7 +942,7 @@ msgid "" "arguments, and they should return either ``0`` on success or ``-1`` on error." msgstr "" -#: ../../extending/newtypes_tutorial.rst:413 +#: ../../extending/newtypes_tutorial.rst:408 msgid "" "Unlike the ``tp_new`` handler, there is no guarantee that ``tp_init`` is " "called at all (for example, the :mod:`pickle` module by default doesn't " @@ -953,7 +953,7 @@ msgid "" "``first`` member like this::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:421 +#: ../../extending/newtypes_tutorial.rst:416 msgid "" "if (first) {\n" " Py_XDECREF(self->first);\n" @@ -967,7 +967,7 @@ msgstr "" " self->first = first;\n" "}" -#: ../../extending/newtypes_tutorial.rst:427 +#: ../../extending/newtypes_tutorial.rst:422 msgid "" "But this would be risky. Our type doesn't restrict the type of the " "``first`` member, so it could be any kind of object. It could have a " @@ -977,38 +977,38 @@ msgid "" "accesses and modifies our object." msgstr "" -#: ../../extending/newtypes_tutorial.rst:434 +#: ../../extending/newtypes_tutorial.rst:429 msgid "" "To be paranoid and protect ourselves against this possibility, we almost " "always reassign members before decrementing their reference counts. When " "don't we have to do this?" msgstr "" -#: ../../extending/newtypes_tutorial.rst:438 +#: ../../extending/newtypes_tutorial.rst:433 msgid "when we absolutely know that the reference count is greater than 1;" msgstr "" -#: ../../extending/newtypes_tutorial.rst:440 +#: ../../extending/newtypes_tutorial.rst:435 msgid "" "when we know that deallocation of the object [#]_ will neither detach " "the :term:`thread state ` nor cause any calls back " "into our type's code;" msgstr "" -#: ../../extending/newtypes_tutorial.rst:443 +#: ../../extending/newtypes_tutorial.rst:438 msgid "" "when decrementing a reference count in " "a :c:member:`~PyTypeObject.tp_dealloc` handler on a type which doesn't " "support cyclic garbage collection [#]_." msgstr "" -#: ../../extending/newtypes_tutorial.rst:446 +#: ../../extending/newtypes_tutorial.rst:441 msgid "" "We want to expose our instance variables as attributes. There are a number " "of ways to do that. The simplest way is to define member definitions::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:449 +#: ../../extending/newtypes_tutorial.rst:444 msgid "" "static PyMemberDef Custom_members[] = {\n" " {\"first\", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,\n" @@ -1021,23 +1021,23 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:459 +#: ../../extending/newtypes_tutorial.rst:454 msgid "" "and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:461 +#: ../../extending/newtypes_tutorial.rst:456 msgid ".tp_members = Custom_members," msgstr ".tp_members = Custom_members," -#: ../../extending/newtypes_tutorial.rst:463 +#: ../../extending/newtypes_tutorial.rst:458 msgid "" "Each member definition has a member name, type, offset, access flags and " "documentation string. See the :ref:`Generic-Attribute-Management` section " "below for details." msgstr "" -#: ../../extending/newtypes_tutorial.rst:467 +#: ../../extending/newtypes_tutorial.rst:462 msgid "" "A disadvantage of this approach is that it doesn't provide a way to restrict " "the types of objects that can be assigned to the Python attributes. We " @@ -1048,13 +1048,13 @@ msgid "" "deleted." msgstr "" -#: ../../extending/newtypes_tutorial.rst:474 +#: ../../extending/newtypes_tutorial.rst:469 msgid "" "We define a single method, :meth:`!Custom.name`, that outputs the objects " "name as the concatenation of the first and last names. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:477 +#: ../../extending/newtypes_tutorial.rst:472 msgid "" "static PyObject *\n" "Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" @@ -1086,7 +1086,7 @@ msgstr "" " return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" "}" -#: ../../extending/newtypes_tutorial.rst:492 +#: ../../extending/newtypes_tutorial.rst:487 msgid "" "The method is implemented as a C function that takes a :class:`!Custom` " "(or :class:`!Custom` subclass) instance as the first argument. Methods " @@ -1096,7 +1096,7 @@ msgid "" "This method is equivalent to the Python method:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:499 +#: ../../extending/newtypes_tutorial.rst:494 msgid "" "def name(self):\n" " return \"%s %s\" % (self.first, self.last)" @@ -1104,7 +1104,7 @@ msgstr "" "def name(self):\n" " return \"%s %s\" % (self.first, self.last)" -#: ../../extending/newtypes_tutorial.rst:504 +#: ../../extending/newtypes_tutorial.rst:499 msgid "" "Note that we have to check for the possibility that our :attr:`!first` " "and :attr:`!last` members are ``NULL``. This is because they can be " @@ -1113,13 +1113,13 @@ msgid "" "be strings. We'll see how to do that in the next section." msgstr "" -#: ../../extending/newtypes_tutorial.rst:510 +#: ../../extending/newtypes_tutorial.rst:505 msgid "" "Now that we've defined the method, we need to create an array of method " "definitions::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:513 +#: ../../extending/newtypes_tutorial.rst:508 msgid "" "static PyMethodDef Custom_methods[] = {\n" " {\"name\", Custom_name, METH_NOARGS,\n" @@ -1129,21 +1129,21 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:520 +#: ../../extending/newtypes_tutorial.rst:515 msgid "" "(note that we used the :c:macro:`METH_NOARGS` flag to indicate that the " "method is expecting no arguments other than *self*)" msgstr "" -#: ../../extending/newtypes_tutorial.rst:523 +#: ../../extending/newtypes_tutorial.rst:518 msgid "and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:525 +#: ../../extending/newtypes_tutorial.rst:520 msgid ".tp_methods = Custom_methods," msgstr ".tp_methods = Custom_methods," -#: ../../extending/newtypes_tutorial.rst:527 +#: ../../extending/newtypes_tutorial.rst:522 msgid "" "Finally, we'll make our type usable as a base class for subclassing. We've " "written our methods carefully so far so that they don't make any assumptions " @@ -1151,22 +1151,22 @@ msgid "" "to add the :c:macro:`Py_TPFLAGS_BASETYPE` to our class flag definition::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:532 +#: ../../extending/newtypes_tutorial.rst:527 msgid ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE," msgstr ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE," -#: ../../extending/newtypes_tutorial.rst:534 +#: ../../extending/newtypes_tutorial.rst:529 msgid "" "We rename :c:func:`!PyInit_custom` to :c:func:`!PyInit_custom2`, update the " "module name in the :c:type:`PyModuleDef` struct, and update the full class " "name in the :c:type:`PyTypeObject` struct." msgstr "" -#: ../../extending/newtypes_tutorial.rst:538 +#: ../../extending/newtypes_tutorial.rst:533 msgid "Finally, we update our :file:`setup.py` file to include the new module," msgstr "" -#: ../../extending/newtypes_tutorial.rst:540 +#: ../../extending/newtypes_tutorial.rst:535 msgid "" "from setuptools import Extension, setup\n" "setup(ext_modules=[\n" @@ -1180,15 +1180,15 @@ msgstr "" " Extension(\"custom2\", [\"custom2.c\"]),\n" "])" -#: ../../extending/newtypes_tutorial.rst:548 +#: ../../extending/newtypes_tutorial.rst:543 msgid "and then we re-install so that we can ``import custom2``:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:555 +#: ../../extending/newtypes_tutorial.rst:550 msgid "Providing finer control over data attributes" msgstr "" -#: ../../extending/newtypes_tutorial.rst:557 +#: ../../extending/newtypes_tutorial.rst:552 msgid "" "In this section, we'll provide finer control over how the :attr:`!first` " "and :attr:`!last` attributes are set in the :class:`!Custom` example. In the " @@ -1197,7 +1197,7 @@ msgid "" "to make sure that these attributes always contain strings." msgstr "" -#: ../../extending/newtypes_tutorial.rst:563 +#: ../../extending/newtypes_tutorial.rst:558 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1391,14 +1391,14 @@ msgid "" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:566 +#: ../../extending/newtypes_tutorial.rst:561 msgid "" "To provide greater control, over the :attr:`!first` and :attr:`!last` " "attributes, we'll use custom getter and setter functions. Here are the " "functions for getting and setting the :attr:`!first` attribute::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:570 +#: ../../extending/newtypes_tutorial.rst:565 msgid "" "static PyObject *\n" "Custom_getfirst(PyObject *op, void *closure)\n" @@ -1431,7 +1431,7 @@ msgid "" "}" msgstr "" -#: ../../extending/newtypes_tutorial.rst:599 +#: ../../extending/newtypes_tutorial.rst:594 msgid "" "The getter function is passed a :class:`!Custom` object and a \"closure\", " "which is a void pointer. In this case, the closure is ignored. (The " @@ -1441,7 +1441,7 @@ msgid "" "data in the closure.)" msgstr "" -#: ../../extending/newtypes_tutorial.rst:605 +#: ../../extending/newtypes_tutorial.rst:600 msgid "" "The setter function is passed the :class:`!Custom` object, the new value, " "and the closure. The new value may be ``NULL``, in which case the attribute " @@ -1449,11 +1449,11 @@ msgid "" "deleted or if its new value is not a string." msgstr "" -#: ../../extending/newtypes_tutorial.rst:610 +#: ../../extending/newtypes_tutorial.rst:605 msgid "We create an array of :c:type:`PyGetSetDef` structures::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:612 +#: ../../extending/newtypes_tutorial.rst:607 msgid "" "static PyGetSetDef Custom_getsetters[] = {\n" " {\"first\", Custom_getfirst, Custom_setfirst,\n" @@ -1464,26 +1464,26 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:620 +#: ../../extending/newtypes_tutorial.rst:615 msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:622 +#: ../../extending/newtypes_tutorial.rst:617 msgid ".tp_getset = Custom_getsetters," msgstr ".tp_getset = Custom_getsetters," -#: ../../extending/newtypes_tutorial.rst:624 +#: ../../extending/newtypes_tutorial.rst:619 msgid "" "The last item in a :c:type:`PyGetSetDef` structure is the \"closure\" " "mentioned above. In this case, we aren't using a closure, so we just pass " "``NULL``." msgstr "" -#: ../../extending/newtypes_tutorial.rst:627 +#: ../../extending/newtypes_tutorial.rst:622 msgid "We also remove the member definitions for these attributes::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:629 +#: ../../extending/newtypes_tutorial.rst:624 msgid "" "static PyMemberDef Custom_members[] = {\n" " {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" @@ -1492,13 +1492,13 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:635 +#: ../../extending/newtypes_tutorial.rst:630 msgid "" "We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only " "allow strings [#]_ to be passed::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:638 +#: ../../extending/newtypes_tutorial.rst:633 msgid "" "static int\n" "Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" @@ -1554,7 +1554,7 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:665 +#: ../../extending/newtypes_tutorial.rst:660 msgid "" "With these changes, we can assure that the ``first`` and ``last`` members " "are never ``NULL`` so we can remove checks for ``NULL`` values in almost all " @@ -1564,25 +1564,25 @@ msgid "" "possibility that the initialization of these members failed in ``tp_new``." msgstr "" -#: ../../extending/newtypes_tutorial.rst:672 +#: ../../extending/newtypes_tutorial.rst:667 msgid "" "We also rename the module initialization function and module name in the " "initialization function, as we did before, and we add an extra definition to " "the :file:`setup.py` file." msgstr "" -#: ../../extending/newtypes_tutorial.rst:678 +#: ../../extending/newtypes_tutorial.rst:673 msgid "Supporting cyclic garbage collection" msgstr "" -#: ../../extending/newtypes_tutorial.rst:680 +#: ../../extending/newtypes_tutorial.rst:675 msgid "" "Python has a :term:`cyclic garbage collector (GC) ` that " "can identify unneeded objects even when their reference counts are not zero. " "This can happen when objects are involved in cycles. For example, consider:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:684 +#: ../../extending/newtypes_tutorial.rst:679 msgid "" ">>> l = []\n" ">>> l.append(l)\n" @@ -1592,7 +1592,7 @@ msgstr "" ">>> l.append(l)\n" ">>> del l" -#: ../../extending/newtypes_tutorial.rst:690 +#: ../../extending/newtypes_tutorial.rst:685 msgid "" "In this example, we create a list that contains itself. When we delete it, " "it still has a reference from itself. Its reference count doesn't drop to " @@ -1600,7 +1600,7 @@ msgid "" "out that the list is garbage and free it." msgstr "" -#: ../../extending/newtypes_tutorial.rst:695 +#: ../../extending/newtypes_tutorial.rst:690 msgid "" "In the second version of the :class:`!Custom` example, we allowed any kind " "of object to be stored in the :attr:`!first` or :attr:`!last` attributes " @@ -1610,7 +1610,7 @@ msgid "" "cycles:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:701 +#: ../../extending/newtypes_tutorial.rst:696 msgid "" ">>> import custom3\n" ">>> class Derived(custom3.Custom): pass\n" @@ -1624,7 +1624,7 @@ msgstr "" ">>> n = Derived()\n" ">>> n.some_attribute = n" -#: ../../extending/newtypes_tutorial.rst:709 +#: ../../extending/newtypes_tutorial.rst:704 msgid "" "To allow a :class:`!Custom` instance participating in a reference cycle to " "be properly detected and collected by the cyclic GC, our :class:`!Custom` " @@ -1632,7 +1632,7 @@ msgid "" "these slots:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:713 +#: ../../extending/newtypes_tutorial.rst:708 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1846,13 +1846,13 @@ msgid "" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:716 +#: ../../extending/newtypes_tutorial.rst:711 msgid "" "First, the traversal method lets the cyclic GC know about subobjects that " "could participate in cycles::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:719 +#: ../../extending/newtypes_tutorial.rst:714 msgid "" "static int\n" "Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" @@ -1890,7 +1890,7 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:737 +#: ../../extending/newtypes_tutorial.rst:732 msgid "" "For each subobject that can participate in cycles, we need to call " "the :c:func:`!visit` function, which is passed to the traversal method. " @@ -1899,14 +1899,14 @@ msgid "" "that must be returned if it is non-zero." msgstr "" -#: ../../extending/newtypes_tutorial.rst:743 +#: ../../extending/newtypes_tutorial.rst:738 msgid "" "Python provides a :c:func:`Py_VISIT` macro that automates calling visit " "functions. With :c:func:`Py_VISIT`, we can minimize the amount of " "boilerplate in ``Custom_traverse``::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:747 +#: ../../extending/newtypes_tutorial.rst:742 msgid "" "static int\n" "Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" @@ -1926,19 +1926,19 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:757 +#: ../../extending/newtypes_tutorial.rst:752 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` implementation must name its " "arguments exactly *visit* and *arg* in order to use :c:func:`Py_VISIT`." msgstr "" -#: ../../extending/newtypes_tutorial.rst:760 +#: ../../extending/newtypes_tutorial.rst:755 msgid "" "Second, we need to provide a method for clearing any subobjects that can " "participate in cycles::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:763 +#: ../../extending/newtypes_tutorial.rst:758 msgid "" "static int\n" "Custom_clear(PyObject *op)\n" @@ -1958,7 +1958,7 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:772 +#: ../../extending/newtypes_tutorial.rst:767 msgid "" "Notice the use of the :c:func:`Py_CLEAR` macro. It is the recommended and " "safe way to clear data attributes of arbitrary types while decrementing " @@ -1968,11 +1968,11 @@ msgid "" "again (*especially* if there is a reference cycle)." msgstr "" -#: ../../extending/newtypes_tutorial.rst:780 +#: ../../extending/newtypes_tutorial.rst:775 msgid "You could emulate :c:func:`Py_CLEAR` by writing::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:782 +#: ../../extending/newtypes_tutorial.rst:777 msgid "" "PyObject *tmp;\n" "tmp = self->first;\n" @@ -1984,14 +1984,14 @@ msgstr "" "self->first = NULL;\n" "Py_XDECREF(tmp);" -#: ../../extending/newtypes_tutorial.rst:787 +#: ../../extending/newtypes_tutorial.rst:782 msgid "" "Nevertheless, it is much easier and less error-prone to always " "use :c:func:`Py_CLEAR` when deleting an attribute. Don't try to micro-" "optimize at the expense of robustness!" msgstr "" -#: ../../extending/newtypes_tutorial.rst:791 +#: ../../extending/newtypes_tutorial.rst:786 msgid "" "The deallocator ``Custom_dealloc`` may call arbitrary code when clearing " "attributes. It means the circular GC can be triggered inside the function. " @@ -2001,7 +2001,7 @@ msgid "" "using :c:func:`PyObject_GC_UnTrack` and ``Custom_clear``::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:798 +#: ../../extending/newtypes_tutorial.rst:793 msgid "" "static void\n" "Custom_dealloc(PyObject *op)\n" @@ -2019,18 +2019,18 @@ msgstr "" " Py_TYPE(op)->tp_free(op);\n" "}" -#: ../../extending/newtypes_tutorial.rst:806 +#: ../../extending/newtypes_tutorial.rst:801 msgid "" "Finally, we add the :c:macro:`Py_TPFLAGS_HAVE_GC` flag to the class flags::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:808 +#: ../../extending/newtypes_tutorial.rst:803 msgid "" ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC," msgstr "" ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC," -#: ../../extending/newtypes_tutorial.rst:810 +#: ../../extending/newtypes_tutorial.rst:805 msgid "" "That's pretty much it. If we had written " "custom :c:member:`~PyTypeObject.tp_alloc` " @@ -2039,11 +2039,11 @@ msgid "" "automatically provided." msgstr "" -#: ../../extending/newtypes_tutorial.rst:816 +#: ../../extending/newtypes_tutorial.rst:811 msgid "Subclassing other types" msgstr "" -#: ../../extending/newtypes_tutorial.rst:818 +#: ../../extending/newtypes_tutorial.rst:813 msgid "" "It is possible to create new extension types that are derived from existing " "types. It is easiest to inherit from the built in types, since an extension " @@ -2051,7 +2051,7 @@ msgid "" "share these :c:type:`PyTypeObject` structures between extension modules." msgstr "" -#: ../../extending/newtypes_tutorial.rst:823 +#: ../../extending/newtypes_tutorial.rst:818 msgid "" "In this example we will create a :class:`!SubList` type that inherits from " "the built-in :class:`list` type. The new type will be completely compatible " @@ -2059,7 +2059,7 @@ msgid "" "that increases an internal counter:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:828 +#: ../../extending/newtypes_tutorial.rst:823 msgid "" ">>> import sublist\n" ">>> s = sublist.SubList(range(3))\n" @@ -2081,7 +2081,7 @@ msgstr "" ">>> print(s.increment())\n" "2" -#: ../../extending/newtypes_tutorial.rst:840 +#: ../../extending/newtypes_tutorial.rst:835 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -2164,14 +2164,14 @@ msgid "" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:843 +#: ../../extending/newtypes_tutorial.rst:838 msgid "" "As you can see, the source code closely resembles the :class:`!Custom` " "examples in previous sections. We will break down the main differences " "between them. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:846 +#: ../../extending/newtypes_tutorial.rst:841 msgid "" "typedef struct {\n" " PyListObject list;\n" @@ -2183,21 +2183,21 @@ msgstr "" " int state;\n" "} SubListObject;" -#: ../../extending/newtypes_tutorial.rst:851 +#: ../../extending/newtypes_tutorial.rst:846 msgid "" "The primary difference for derived type objects is that the base type's " "object structure must be the first value. The base type will already " "include the :c:func:`PyObject_HEAD` at the beginning of its structure." msgstr "" -#: ../../extending/newtypes_tutorial.rst:855 +#: ../../extending/newtypes_tutorial.rst:850 msgid "" "When a Python object is a :class:`!SubList` instance, its ``PyObject *`` " "pointer can be safely cast to both ``PyListObject *`` and ``SubListObject " "*``::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:858 +#: ../../extending/newtypes_tutorial.rst:853 msgid "" "static int\n" "SubList_init(PyObject *op, PyObject *args, PyObject *kwds)\n" @@ -2219,13 +2219,13 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:868 +#: ../../extending/newtypes_tutorial.rst:863 msgid "" "We see above how to call through to the :meth:`~object.__init__` method of " "the base type." msgstr "" -#: ../../extending/newtypes_tutorial.rst:871 +#: ../../extending/newtypes_tutorial.rst:866 msgid "" "This pattern is important when writing a type with " "custom :c:member:`~PyTypeObject.tp_new` " @@ -2235,7 +2235,7 @@ msgid "" "the base class handle it by calling its own :c:member:`~PyTypeObject.tp_new`." msgstr "" -#: ../../extending/newtypes_tutorial.rst:877 +#: ../../extending/newtypes_tutorial.rst:872 msgid "" "The :c:type:`PyTypeObject` struct supports " "a :c:member:`~PyTypeObject.tp_base` specifying the type's concrete base " @@ -2244,7 +2244,7 @@ msgid "" "the :c:data:`Py_mod_exec` function::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:883 +#: ../../extending/newtypes_tutorial.rst:878 msgid "" "static int\n" "sublist_module_exec(PyObject *m)\n" @@ -2278,7 +2278,7 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:898 +#: ../../extending/newtypes_tutorial.rst:893 msgid "" "Before calling :c:func:`PyType_Ready`, the type structure must have " "the :c:member:`~PyTypeObject.tp_base` slot filled in. When we are deriving " @@ -2287,29 +2287,29 @@ msgid "" "-- the allocation function from the base type will be inherited." msgstr "" -#: ../../extending/newtypes_tutorial.rst:904 +#: ../../extending/newtypes_tutorial.rst:899 msgid "" "After that, calling :c:func:`PyType_Ready` and adding the type object to the " "module is the same as with the basic :class:`!Custom` examples." msgstr "" -#: ../../extending/newtypes_tutorial.rst:909 +#: ../../extending/newtypes_tutorial.rst:904 msgid "Footnotes" msgstr "註腳" -#: ../../extending/newtypes_tutorial.rst:910 +#: ../../extending/newtypes_tutorial.rst:905 msgid "" "This is true when we know that the object is a basic type, like a string or " "a float." msgstr "" -#: ../../extending/newtypes_tutorial.rst:913 +#: ../../extending/newtypes_tutorial.rst:908 msgid "" "We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in " "this example, because our type doesn't support garbage collection." msgstr "" -#: ../../extending/newtypes_tutorial.rst:916 +#: ../../extending/newtypes_tutorial.rst:911 msgid "" "We now know that the first and last members are strings, so perhaps we could " "be less careful about decrementing their reference counts, however, we " @@ -2319,7 +2319,7 @@ msgid "" "objects." msgstr "" -#: ../../extending/newtypes_tutorial.rst:922 +#: ../../extending/newtypes_tutorial.rst:917 msgid "" "Also, even with our attributes restricted to strings instances, the user " "could pass arbitrary :class:`str` subclasses and therefore still create " diff --git a/extending/windows.po b/extending/windows.po index 39a4c461b15..f1881d1739e 100644 --- a/extending/windows.po +++ b/extending/windows.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -69,14 +69,14 @@ msgstr "" msgid "Differences Between Unix and Windows" msgstr "" -#: ../../extending/windows.rst:53 +#: ../../extending/windows.rst:50 msgid "" "Unix and Windows use completely different paradigms for run-time loading of " "code. Before you try to build a module that can be dynamically loaded, be " "aware of how your system works." msgstr "" -#: ../../extending/windows.rst:57 +#: ../../extending/windows.rst:54 msgid "" "In Unix, a shared object (:file:`.so`) file contains code to be used by the " "program, and also the names of functions and data that it expects to find in " @@ -86,7 +86,7 @@ msgid "" "memory. This is basically a link operation." msgstr "" -#: ../../extending/windows.rst:64 +#: ../../extending/windows.rst:61 msgid "" "In Windows, a dynamic-link library (:file:`.dll`) file has no dangling " "references. Instead, an access to functions or data goes through a lookup " @@ -96,7 +96,7 @@ msgid "" "data." msgstr "" -#: ../../extending/windows.rst:70 +#: ../../extending/windows.rst:67 msgid "" "In Unix, there is only one type of library file (:file:`.a`) which contains " "code from several object files (:file:`.o`). During the link step to create " @@ -106,7 +106,7 @@ msgid "" "that object file." msgstr "" -#: ../../extending/windows.rst:76 +#: ../../extending/windows.rst:73 msgid "" "In Windows, there are two types of library, a static library and an import " "library (both called :file:`.lib`). A static library is like a " @@ -120,7 +120,7 @@ msgid "" "the application or DLL." msgstr "" -#: ../../extending/windows.rst:86 +#: ../../extending/windows.rst:83 msgid "" "Suppose you are building two dynamic-load modules, B and C, which should " "share another block of code A. On Unix, you would *not* pass :file:`A.a` to " @@ -132,7 +132,7 @@ msgid "" "access A's code." msgstr "" -#: ../../extending/windows.rst:94 +#: ../../extending/windows.rst:91 msgid "" "In Windows, using an import library is sort of like using ``import spam``; " "it gives you access to spam's names, but does not create a separate copy. " @@ -140,28 +140,28 @@ msgid "" "create a separate copy." msgstr "" -#: ../../extending/windows.rst:101 +#: ../../extending/windows.rst:98 msgid "" "Turn off the implicit, ``#pragma``-based linkage with the Python library, " "performed inside CPython header files." msgstr "" -#: ../../extending/windows.rst:110 +#: ../../extending/windows.rst:107 msgid "Using DLLs in Practice" msgstr "" -#: ../../extending/windows.rst:115 +#: ../../extending/windows.rst:109 msgid "" "Windows Python is built in Microsoft Visual C++; using other compilers may " "or may not work. The rest of this section is MSVC++ specific." msgstr "" -#: ../../extending/windows.rst:118 +#: ../../extending/windows.rst:112 msgid "" "When creating DLLs in Windows, you can use the CPython library in two ways:" msgstr "" -#: ../../extending/windows.rst:120 +#: ../../extending/windows.rst:114 msgid "" "By default, inclusion of :file:`PC/pyconfig.h` directly or " "via :file:`Python.h` triggers an implicit, configure-aware link with the " @@ -170,13 +170,13 @@ msgid "" "with the :ref:`Limited API ` enabled." msgstr "" -#: ../../extending/windows.rst:126 ../../extending/windows.rst:144 +#: ../../extending/windows.rst:120 ../../extending/windows.rst:138 msgid "" "To build two DLLs, spam and ni (which uses C functions found in spam), you " "could use these commands::" msgstr "" -#: ../../extending/windows.rst:129 +#: ../../extending/windows.rst:123 msgid "" "cl /LD /I/python/include spam.c\n" "cl /LD /I/python/include ni.c spam.lib" @@ -184,7 +184,7 @@ msgstr "" "cl /LD /I/python/include spam.c\n" "cl /LD /I/python/include ni.c spam.lib" -#: ../../extending/windows.rst:132 +#: ../../extending/windows.rst:126 msgid "" "The first command created three files: :file:`spam.obj`, :file:`spam.dll` " "and :file:`spam.lib`. :file:`Spam.dll` does not contain any Python " @@ -192,20 +192,20 @@ msgid "" "the Python code thanks to the implicitly linked :file:`pythonXY.lib`." msgstr "" -#: ../../extending/windows.rst:137 ../../extending/windows.rst:155 +#: ../../extending/windows.rst:131 ../../extending/windows.rst:149 msgid "" "The second command created :file:`ni.dll` (and :file:`.obj` " "and :file:`.lib`), which knows how to find the necessary functions from " "spam, and also from the Python executable." msgstr "" -#: ../../extending/windows.rst:141 +#: ../../extending/windows.rst:135 msgid "" "Manually by defining :c:macro:`Py_NO_LINK_LIB` macro before " "including :file:`Python.h`. You must pass :file:`pythonXY.lib` to the linker." msgstr "" -#: ../../extending/windows.rst:147 +#: ../../extending/windows.rst:141 msgid "" "cl /LD /DPy_NO_LINK_LIB /I/python/include spam.c ../libs/pythonXY.lib\n" "cl /LD /DPy_NO_LINK_LIB /I/python/include ni.c spam.lib ../libs/pythonXY.lib" @@ -213,7 +213,7 @@ msgstr "" "cl /LD /DPy_NO_LINK_LIB /I/python/include spam.c ../libs/pythonXY.lib\n" "cl /LD /DPy_NO_LINK_LIB /I/python/include ni.c spam.lib ../libs/pythonXY.lib" -#: ../../extending/windows.rst:150 +#: ../../extending/windows.rst:144 msgid "" "The first command created three files: :file:`spam.obj`, :file:`spam.dll` " "and :file:`spam.lib`. :file:`Spam.dll` does not contain any Python " @@ -221,7 +221,7 @@ msgid "" "the Python code thanks to :file:`pythonXY.lib`." msgstr "" -#: ../../extending/windows.rst:159 +#: ../../extending/windows.rst:153 msgid "" "Not every identifier is exported to the lookup table. If you want any other " "modules (including Python) to be able to see your identifiers, you have to " @@ -229,7 +229,7 @@ msgid "" "initspam(void)`` or ``PyObject _declspec(dllexport) *NiGetSpamData(void)``." msgstr "" -#: ../../extending/windows.rst:164 +#: ../../extending/windows.rst:158 msgid "" "Developer Studio will throw in a lot of import libraries that you do not " "really need, adding about 100K to your executable. To get rid of them, use " diff --git a/faq/design.po b/faq/design.po index eeb2b627a28..e8657adbe02 100644 --- a/faq/design.po +++ b/faq/design.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-13 20:11+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-08-31 11:34+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -842,21 +842,24 @@ msgstr "" #: ../../faq/design.rst:425 msgid "" -"Tuples are immutable, meaning that once a tuple has been created, you can't " -"replace any of its elements with a new value. Lists are mutable, meaning " -"that you can always change a list's elements. Only immutable elements can " -"be used as dictionary keys, and hence only tuples and not lists can be used " -"as keys." +"Tuples are :term:`immutable`, meaning that once a tuple has been created, " +"you can't replace any of its elements with a new value. Lists are :term:" +"`mutable`, meaning that you can always change a list's elements. Only :term:" +"`hashable` objects can be used as dictionary keys. Most immutable types are " +"hashable, which is why tuples, but not lists, can be used as keys. Note, " +"however, that a tuple is only hashable if all of its elements are hashable." msgstr "" -"元組則是不可變的,代表一旦元組被建立,你就不能夠改變裡面的任何一個值。而串列" -"可變,所以你可以改變裡面的元素。只有不可變的元素可以成為字典的鍵,所以只能把" -"元組當成鍵,而串列則不行。" +"元組是\\ :term:`不可變的 `,代表一旦元組被建立,你就不能以新的值取" +"代裡面的任何一個元素。而串列是\\ :term:`可變的 `,所以你隨時可以改變" +"串列的元素。只有\\ :term:`可雜湊 ` 物件可以成為字典的鍵。大多數不可" +"變型別都是可雜湊的,這就是為什麼元組可以當成鍵,而串列則不行。不過請注意,只" +"有當元組的所有元素都是可雜湊的,該元組才是可雜湊的。" -#: ../../faq/design.rst:434 +#: ../../faq/design.rst:436 msgid "How are lists implemented in CPython?" msgstr "串列 (list) 在 CPython 中是怎麼實作的?" -#: ../../faq/design.rst:436 +#: ../../faq/design.rst:438 msgid "" "CPython's lists are really variable-length arrays, not Lisp-style linked " "lists. The implementation uses a contiguous array of references to other " @@ -867,13 +870,13 @@ msgstr "" "接串列 (linked list)。實作上,他是一個連續的物件參照 (reference) 陣列,並把指" "向此陣列的指標 (pointer) 和陣列長度存在串列的標頭結構內。" -#: ../../faq/design.rst:440 +#: ../../faq/design.rst:442 msgid "" "This makes indexing a list ``a[i]`` an operation whose cost is independent " "of the size of the list or the value of the index." msgstr "因此,用索引來找串列特定項 ``a[i]`` 的代價和串列大小或是索引值無關。" -#: ../../faq/design.rst:443 +#: ../../faq/design.rst:445 msgid "" "When items are appended or inserted, the array of references is resized. " "Some cleverness is applied to improve the performance of appending items " @@ -884,16 +887,16 @@ msgstr "" "用一些巧妙的方法,當陣列必須變大時,會多收集一些額外的空間,接下來幾次新增時" "就不需要再調整大小了。" -#: ../../faq/design.rst:448 +#: ../../faq/design.rst:450 msgid "" "See :ref:`time-complexity` for the costs of the various list operations." msgstr "各種串列操作的時間複雜度請參閱 :ref:`time-complexity`。" -#: ../../faq/design.rst:454 +#: ../../faq/design.rst:456 msgid "How are dictionaries implemented in CPython?" msgstr "字典 (dictionaries) 在 CPython 中是怎麼實作的?" -#: ../../faq/design.rst:456 +#: ../../faq/design.rst:458 msgid "" "CPython's dictionaries are implemented as resizable hash tables. Compared " "to B-trees, this gives better performance for lookup (the most common " @@ -903,7 +906,7 @@ msgstr "" "CPython 的字典是用可調整大小的雜湊表 (hash table) 實作的。比起 B 樹 (B-" "tree),在搜尋(目前為止最常見的操作)方面有更好的表現,實作上也較為簡單。" -#: ../../faq/design.rst:460 +#: ../../faq/design.rst:462 msgid "" "Dictionaries work by computing a hash code for each key stored in the " "dictionary using the :func:`hash` built-in function. The hash code varies " @@ -921,17 +924,17 @@ msgstr "" "被用來計算值在內部陣列儲存的位置。假設你存的鍵都有不同的雜湊值,那字典只需要" "常數時間 — 用大 O 表示法 (Big-O notation) 就是 *O*\\ (1) — 來找任意一個鍵。" -#: ../../faq/design.rst:469 +#: ../../faq/design.rst:471 msgid "" "See :ref:`time-complexity` for the costs of the various dictionary " "operations." msgstr "各種字典操作的時間複雜度請參閱 :ref:`time-complexity`。" -#: ../../faq/design.rst:473 +#: ../../faq/design.rst:475 msgid "Why must dictionary keys be immutable?" msgstr "為何字典的鍵一定是不可變的?" -#: ../../faq/design.rst:475 +#: ../../faq/design.rst:477 msgid "" "The hash table implementation of dictionaries uses a hash value calculated " "from the key value to find the key. If the key were a mutable object, its " @@ -949,7 +952,7 @@ msgstr "" "值不同的緣故,你找不到他。而如果你嘗試用舊的值去尋找,也一樣找不到,因為他的" "雜湊結果和原先物件不同。" -#: ../../faq/design.rst:484 +#: ../../faq/design.rst:486 msgid "" "If you want a dictionary indexed with a list, simply convert the list to a " "tuple first; the function ``tuple(L)`` creates a tuple with the same entries " @@ -959,11 +962,11 @@ msgstr "" "如果你想要用串列作為字典的索引,把他轉換成元組即可。``tuple(L)`` 函式會建立一" "個和串列 ``L`` 一樣內容的元組。而元組是不可變的,所以可以用來當成字典的鍵。" -#: ../../faq/design.rst:488 +#: ../../faq/design.rst:490 msgid "Some unacceptable solutions that have been proposed:" msgstr "也有人提出一些不能接受的方法:" -#: ../../faq/design.rst:490 +#: ../../faq/design.rst:492 msgid "" "Hash lists by their address (object ID). This doesn't work because if you " "construct a new list with the same value it won't be found; e.g.::" @@ -971,7 +974,7 @@ msgstr "" "用串列的記憶體位址(物件 id)來雜湊。這不會成功,因為你如果用同樣的值建立一個" "新的串列,是找不到的。舉例來說: ::" -#: ../../faq/design.rst:493 +#: ../../faq/design.rst:495 msgid "" "mydict = {[1, 2]: '12'}\n" "print(mydict[[1, 2]])" @@ -979,7 +982,7 @@ msgstr "" "mydict = {[1, 2]: '12'}\n" "print(mydict[[1, 2]])" -#: ../../faq/design.rst:496 +#: ../../faq/design.rst:498 msgid "" "would raise a :exc:`KeyError` exception because the id of the ``[1, 2]`` " "used in the second line differs from that in the first line. In other " @@ -989,7 +992,7 @@ msgstr "" "這將會導致 :exc:`KeyError` 例外,因為 ``[1, 2]`` 的 id 在第一行和第二行是不同" "的。換句話說,字典的鍵應該要用 ``==`` 來做比較,而不是用 :keyword:`is`。" -#: ../../faq/design.rst:500 +#: ../../faq/design.rst:502 msgid "" "Make a copy when using a list as a key. This doesn't work because the list, " "being a mutable object, could contain a reference to itself, and then the " @@ -998,7 +1001,7 @@ msgstr "" "複製一個串列作為鍵。這一樣不會成功,因為串列是可變的,他可以包含自己的參照," "所以複製會形成一個無窮迴圈。" -#: ../../faq/design.rst:504 +#: ../../faq/design.rst:506 msgid "" "Allow lists as keys but tell the user not to modify them. This would allow " "a class of hard-to-track bugs in programs when you forgot or modified a list " @@ -1009,7 +1012,7 @@ msgstr "" "產生一種難以追蹤的 bug。他同時也違背了一項字典的重要定則:在 ``d.keys()`` 的" "每個值都可以當成字典的鍵。" -#: ../../faq/design.rst:509 +#: ../../faq/design.rst:511 msgid "" "Mark lists as read-only once they are used as a dictionary key. The problem " "is that it's not just the top-level object that could change its value; you " @@ -1022,7 +1025,7 @@ msgstr "" "值,就像用元組包含串列來做為鍵。把一個物件當成鍵,需要將從他開始可以接觸到的" "所有物件都標記成只能讀取 — 所以再一次,自己參照自己的物件會導致無窮迴圈。" -#: ../../faq/design.rst:515 +#: ../../faq/design.rst:517 msgid "" "There is a trick to get around this if you need to, but use it at your own " "risk: You can wrap a mutable structure inside a class instance which has " @@ -1036,7 +1039,7 @@ msgstr "" "實例。只要這種包裝物件還存在於字典(或其他類似結構)中,你就必須確定在字典" "(或其他用雜湊為基底的結構)中他們的雜湊值會保持恆定。 ::" -#: ../../faq/design.rst:523 +#: ../../faq/design.rst:525 msgid "" "class ListWrapper:\n" " def __init__(self, the_list):\n" @@ -1072,7 +1075,7 @@ msgstr "" " result = (result % 7777777) + i * 333\n" " return result" -#: ../../faq/design.rst:540 +#: ../../faq/design.rst:542 msgid "" "Note that the hash computation is complicated by the possibility that some " "members of the list may be unhashable and also by the possibility of " @@ -1081,7 +1084,7 @@ msgstr "" "請注意,雜湊的計算可能變得複雜,因為有串列成員不可雜湊 (unhashable) 和算術溢" "位的可能性。" -#: ../../faq/design.rst:544 +#: ../../faq/design.rst:546 msgid "" "Furthermore it must always be the case that if ``o1 == o2`` (ie ``o1." "__eq__(o2) is True``) then ``hash(o1) == hash(o2)`` (ie, ``o1.__hash__() == " @@ -1094,7 +1097,7 @@ msgstr "" "__hash__()``),這個事實必須要成立。如果無法滿足這項限制,那字典和其他用雜湊" "為基底的結構會出現不正常的行為。" -#: ../../faq/design.rst:549 +#: ../../faq/design.rst:551 msgid "" "In the case of :class:`!ListWrapper`, whenever the wrapper object is in a " "dictionary the wrapped list must not change to avoid anomalies. Don't do " @@ -1105,11 +1108,11 @@ msgstr "" "變以避免不正常的事情發生。除非你已經謹慎思考過你的需求和無法滿足條件的後果," "不然請不要這麼做。請自行注意。" -#: ../../faq/design.rst:556 +#: ../../faq/design.rst:558 msgid "Why doesn't list.sort() return the sorted list?" msgstr "為何 list.sort() 不是回傳排序過的串列?" -#: ../../faq/design.rst:558 +#: ../../faq/design.rst:560 msgid "" "In situations where performance matters, making a copy of the list just to " "sort it would be wasteful. Therefore, :meth:`list.sort` sorts the list in " @@ -1122,7 +1125,7 @@ msgstr "" "列裡做排序。為了提醒你這件事,他不會回傳排序過的串列。這樣一來,當你需要排序" "過和未排序過的串列時,你就不會被誤導而不小心覆蓋掉串列。" -#: ../../faq/design.rst:564 +#: ../../faq/design.rst:566 msgid "" "If you want to return a new list, use the built-in :func:`sorted` function " "instead. This function creates a new list from a provided iterable, sorts " @@ -1133,7 +1136,7 @@ msgstr "" "物件 (iterable) 來排序建立新串列,並回傳之。例如,以下這個範例會說明如何有序" "地疊代字典的鍵: ::" -#: ../../faq/design.rst:569 +#: ../../faq/design.rst:571 msgid "" "for key in sorted(mydict):\n" " ... # do whatever with mydict[key]..." @@ -1141,11 +1144,11 @@ msgstr "" "for key in sorted(mydict):\n" " ... # do whatever with mydict[key]..." -#: ../../faq/design.rst:574 +#: ../../faq/design.rst:576 msgid "How do you specify and enforce an interface spec in Python?" msgstr "如何在 Python 中指定和強制使用一個介面規範 (interface spec)?" -#: ../../faq/design.rst:576 +#: ../../faq/design.rst:578 msgid "" "An interface specification for a module as provided by languages such as C++ " "and Java describes the prototypes for the methods and functions of the " @@ -1155,7 +1158,7 @@ msgstr "" "像是 C++ 和 Java 等語言提供了模組的介面規範,他描述了該模組的方法和函式的原" "型。很多人認為這種在編譯時強制執行的介面規範在建構大型程式時十分有幫助。" -#: ../../faq/design.rst:581 +#: ../../faq/design.rst:583 msgid "" "Python 2.6 adds an :mod:`abc` module that lets you define Abstract Base " "Classes (ABCs). You can then use :func:`isinstance` and :func:`issubclass` " @@ -1170,13 +1173,13 @@ msgstr "" "系列好用的抽象基底類別,像是 :class:`~collections.abc.Iterable`、:class:" "`~collections.abc.Container` 和 :class:`~collections.abc.MutableMapping`。" -#: ../../faq/design.rst:588 +#: ../../faq/design.rst:590 msgid "" "For Python, many of the advantages of interface specifications can be " "obtained by an appropriate test discipline for components." msgstr "對 Python 來說,很多介面規範的優點可以用對元件適當的測試規則來達到。" -#: ../../faq/design.rst:591 +#: ../../faq/design.rst:593 msgid "" "A good test suite for a module can both provide a regression test and serve " "as a module interface specification and a set of examples. Many Python " @@ -1193,7 +1196,7 @@ msgstr "" "模擬來獨立測試。:mod:`doctest` 和 :mod:`unittest` 模組或第三方的測試框架可以" "用來建構詳盡徹底的測試套件來測試模組裡的每一行程式碼。" -#: ../../faq/design.rst:599 +#: ../../faq/design.rst:601 msgid "" "An appropriate testing discipline can help build large complex applications " "in Python as well as having interface specifications would. In fact, it can " @@ -1210,7 +1213,7 @@ msgstr "" "而介面規範沒辦法測試你的 :meth:`list.append` 是不是真的有正確的實作,但這在測" "試套件裡是件很簡單的事。" -#: ../../faq/design.rst:607 +#: ../../faq/design.rst:609 msgid "" "Writing test suites is very helpful, and you might want to design your code " "to make it easily tested. One increasingly popular technique, test-driven " @@ -1222,11 +1225,11 @@ msgstr "" "(test-driven development) 是一個越來越受歡迎的設計方法,他要求先完成部分的測" "試套件,再去撰寫真的要用的程式碼。當然 Python 也允許你草率地不寫任何測試。" -#: ../../faq/design.rst:615 +#: ../../faq/design.rst:617 msgid "Why is there no goto?" msgstr "為何沒有 goto 語法?" -#: ../../faq/design.rst:617 +#: ../../faq/design.rst:619 msgid "" "In the 1970s people realized that unrestricted goto could lead to messy " "\"spaghetti\" code that was hard to understand and revise. In a high-level " @@ -1243,7 +1246,7 @@ msgstr "" "`while` 和 :keyword:`for` 陳述式,可能會有 :keyword:`continue` 和 :keyword:" "`break`)。" -#: ../../faq/design.rst:624 +#: ../../faq/design.rst:626 msgid "" "One can also use exceptions to provide a \"structured goto\" that works even " "across function calls. Many feel that exceptions can conveniently emulate " @@ -1254,7 +1257,7 @@ msgstr "" "以方便地模擬在 C、Fortran 和其他語言裡各種合理使用的 ``go`` 和 ``goto``。例" "如: ::" -#: ../../faq/design.rst:630 +#: ../../faq/design.rst:632 msgid "" "class label(Exception): pass # declare a label\n" "\n" @@ -1276,18 +1279,18 @@ msgstr "" " pass\n" "..." -#: ../../faq/design.rst:640 +#: ../../faq/design.rst:642 msgid "" "This doesn't allow you to jump into the middle of a loop, but that's usually " "considered an abuse of ``goto`` anyway. Use sparingly." msgstr "" "這依然不能讓你跳進迴圈內,這通常被認為是對 ``goto`` 的濫用。請小心使用。" -#: ../../faq/design.rst:645 +#: ../../faq/design.rst:647 msgid "Why can't raw strings (r-strings) end with a backslash?" msgstr "為何純字串 (r-string) 不能以反斜線結尾?" -#: ../../faq/design.rst:647 +#: ../../faq/design.rst:649 msgid "" "More precisely, they can't end with an odd number of backslashes: the " "unpaired backslash at the end escapes the closing quote character, leaving " @@ -1296,7 +1299,7 @@ msgstr "" "更精確地來說,他不能以奇數個反斜線結尾:尾端未配對的反斜線會使結尾的引號被轉" "義 (escapes),變成一個未結束的字串。" -#: ../../faq/design.rst:651 +#: ../../faq/design.rst:653 msgid "" "Raw strings were designed to ease creating input for processors (chiefly " "regular expression engines) that want to do their own backslash escape " @@ -1310,23 +1313,23 @@ msgstr "" "此。相對地,他讓你用一個反斜線跳脫引號。這些規則在他們預想的目的上正常地運" "作。" -#: ../../faq/design.rst:658 +#: ../../faq/design.rst:660 msgid "" "If you're trying to build Windows pathnames, note that all Windows system " "calls accept forward slashes too::" msgstr "" "如果你嘗試建立 Windows 的路徑名稱,請注意 Windows 系統指令也接受一般斜線: ::" -#: ../../faq/design.rst:661 +#: ../../faq/design.rst:663 msgid "f = open(\"/mydir/file.txt\") # works fine!" msgstr "f = open(\"/mydir/file.txt\") # 正常運作!" -#: ../../faq/design.rst:663 +#: ../../faq/design.rst:665 msgid "" "If you're trying to build a pathname for a DOS command, try e.g. one of ::" msgstr "如果你嘗試建立 DOS 指令的路徑名稱,試試看使用以下的範例: ::" -#: ../../faq/design.rst:665 +#: ../../faq/design.rst:667 msgid "" "dir = r\"\\this\\is\\my\\dos\\dir\" \"\\\\\"\n" "dir = r\"\\this\\is\\my\\dos\\dir\\ \"[:-1]\n" @@ -1336,11 +1339,11 @@ msgstr "" "dir = r\"\\this\\is\\my\\dos\\dir\\ \"[:-1]\n" "dir = \"\\\\this\\\\is\\\\my\\\\dos\\\\dir\\\\\"" -#: ../../faq/design.rst:671 +#: ../../faq/design.rst:673 msgid "Why doesn't Python have a \"with\" statement for attribute assignments?" msgstr "為何 Python 沒有屬性賦值的 with 陳述式?" -#: ../../faq/design.rst:673 +#: ../../faq/design.rst:675 msgid "" "Python has a :keyword:`with` statement that wraps the execution of a block, " "calling code on the entrance and exit from the block. Some languages have a " @@ -1349,7 +1352,7 @@ msgstr "" "Python 的 :keyword:`with` 陳述式包裝了一區塊程式的執行,在進入和離開該區塊時" "執行程式碼。一些語言會有像如下的結構: ::" -#: ../../faq/design.rst:677 +#: ../../faq/design.rst:679 msgid "" "with obj:\n" " a = 1 # equivalent to obj.a = 1\n" @@ -1359,11 +1362,11 @@ msgstr "" " a = 1 # 等同於 obj.a = 1\n" " total = total + 1 # obj.total = obj.total + 1" -#: ../../faq/design.rst:681 +#: ../../faq/design.rst:683 msgid "In Python, such a construct would be ambiguous." msgstr "但在 Python,這種結構是模糊的。" -#: ../../faq/design.rst:683 +#: ../../faq/design.rst:685 msgid "" "Other languages, such as Object Pascal, Delphi, and C++, use static types, " "so it's possible to know, in an unambiguous way, what member is being " @@ -1374,7 +1377,7 @@ msgstr "" "以清楚地知道是哪一個成員被指派值。這是靜態型別的重點 — 在編譯的時候,編譯器" "\\ *永遠*\\ 都知道每個變數的作用域 (scope)。" -#: ../../faq/design.rst:688 +#: ../../faq/design.rst:690 msgid "" "Python uses dynamic types. It is impossible to know in advance which " "attribute will be referenced at runtime. Member attributes may be added or " @@ -1386,11 +1389,11 @@ msgstr "" "員屬性可能在執行時從物件中被新增或移除。這使得如果簡單來看的話,我們無法得知" "以下哪個屬性會被使用:區域的、全域的、或是成員屬性?" -#: ../../faq/design.rst:694 +#: ../../faq/design.rst:696 msgid "For instance, take the following incomplete snippet::" msgstr "以下列不完整的程式碼為例: ::" -#: ../../faq/design.rst:696 +#: ../../faq/design.rst:698 msgid "" "def foo(a):\n" " with a:\n" @@ -1400,7 +1403,7 @@ msgstr "" " with a:\n" " print(x)" -#: ../../faq/design.rst:700 +#: ../../faq/design.rst:702 msgid "" "The snippet assumes that ``a`` must have a member attribute called ``x``. " "However, there is nothing in Python that tells the interpreter this. What " @@ -1413,7 +1416,7 @@ msgstr "" "變數稱為 ``x``,那在這個 :keyword:`with` 區塊會被使用嗎?如你所見,Python 動" "態的天性使得這種選擇更加困難。" -#: ../../faq/design.rst:706 +#: ../../faq/design.rst:708 msgid "" "The primary benefit of :keyword:`with` and similar language features " "(reduction of code volume) can, however, easily be achieved in Python by " @@ -1422,7 +1425,7 @@ msgstr "" "然而 :keyword:`with` 陳述式或類似的語言特性(減少程式碼量)的主要好處可以透過" "賦值來達成。相較於這樣寫: ::" -#: ../../faq/design.rst:709 +#: ../../faq/design.rst:711 msgid "" "function(args).mydict[index][index].a = 21\n" "function(args).mydict[index][index].b = 42\n" @@ -1432,11 +1435,11 @@ msgstr "" "function(args).mydict[index][index].b = 42\n" "function(args).mydict[index][index].c = 63" -#: ../../faq/design.rst:713 +#: ../../faq/design.rst:715 msgid "write this::" msgstr "應該寫成這樣: ::" -#: ../../faq/design.rst:715 +#: ../../faq/design.rst:717 msgid "" "ref = function(args).mydict[index][index]\n" "ref.a = 21\n" @@ -1448,7 +1451,7 @@ msgstr "" "ref.b = 42\n" "ref.c = 63" -#: ../../faq/design.rst:720 +#: ../../faq/design.rst:722 msgid "" "This also has the side-effect of increasing execution speed because name " "bindings are resolved at run-time in Python, and the second version only " @@ -1457,7 +1460,7 @@ msgstr "" "這也有提升執行速度的副作用,因為 Python 的名稱綁定解析會在執行的時候發生,而" "第二版只需要執行解析一次即可。" -#: ../../faq/design.rst:724 +#: ../../faq/design.rst:726 msgid "" "Similar proposals that would introduce syntax to further reduce code volume, " "such as using a 'leading dot', have been rejected in favour of explicitness " @@ -1467,11 +1470,11 @@ msgstr "" "dot)」,但這些提案已被捨棄,以維持程式的明確性(參閱 https://mail.python.org/" "pipermail/python-ideas/2016-May/040070.html)。" -#: ../../faq/design.rst:730 +#: ../../faq/design.rst:732 msgid "Why don't generators support the with statement?" msgstr "為何產生器 (generator) 不支援 with 陳述式?" -#: ../../faq/design.rst:732 +#: ../../faq/design.rst:734 msgid "" "For technical reasons, a generator used directly as a context manager would " "not work correctly. When, as is most common, a generator is used as an " @@ -1484,18 +1487,18 @@ msgstr "" "要的話,你可以在 :keyword:`with` 陳述式裡用 :func:`contextlib." "closing(generator) ` 來包裝他。" -#: ../../faq/design.rst:740 +#: ../../faq/design.rst:742 msgid "Why are colons required for the if/while/def/class statements?" msgstr "為何 if、while、def、class 陳述式裡需要冒號?" -#: ../../faq/design.rst:742 +#: ../../faq/design.rst:744 msgid "" "The colon is required primarily to enhance readability (one of the results " "of the experimental ABC language). Consider this::" msgstr "" "需要冒號主要是為了增加可讀性(由 ABC 語言的實驗得知)。試想如下範例: ::" -#: ../../faq/design.rst:745 +#: ../../faq/design.rst:747 msgid "" "if a == b\n" " print(a)" @@ -1503,11 +1506,11 @@ msgstr "" "if a == b\n" " print(a)" -#: ../../faq/design.rst:748 +#: ../../faq/design.rst:750 msgid "versus ::" msgstr "以及: ::" -#: ../../faq/design.rst:750 +#: ../../faq/design.rst:752 msgid "" "if a == b:\n" " print(a)" @@ -1515,7 +1518,7 @@ msgstr "" "if a == b:\n" " print(a)" -#: ../../faq/design.rst:753 +#: ../../faq/design.rst:755 msgid "" "Notice how the second one is slightly easier to read. Notice further how a " "colon sets off the example in this FAQ answer; it's a standard usage in " @@ -1524,7 +1527,7 @@ msgstr "" "注意第二個例子稍微易讀一些的原因。可以更進一步觀察,一個冒號是如何放在這個 " "FAQ 答案的例子裡的,這是標準的英文用法。" -#: ../../faq/design.rst:756 +#: ../../faq/design.rst:758 msgid "" "Another minor reason is that the colon makes it easier for editors with " "syntax highlighting; they can look for colons to decide when indentation " @@ -1534,17 +1537,17 @@ msgstr "" "另一個小原因是冒號會使編輯器更容易做語法突顯,他們只需要看冒號的位置就可以決" "定是否需要更多縮排,而不用做更多繁複精密的程式碼剖析。" -#: ../../faq/design.rst:762 +#: ../../faq/design.rst:764 msgid "Why does Python allow commas at the end of lists and tuples?" msgstr "為何 Python 允許在串列和元組末端加上逗號?" -#: ../../faq/design.rst:764 +#: ../../faq/design.rst:766 msgid "" "Python lets you add a trailing comma at the end of lists, tuples, and " "dictionaries::" msgstr "Python 允許你在串列、元組和字典的結尾加上逗號: ::" -#: ../../faq/design.rst:767 +#: ../../faq/design.rst:769 msgid "" "[1, 2, 3,]\n" "('a', 'b', 'c',)\n" @@ -1560,11 +1563,11 @@ msgstr "" " \"B\": [6, 7], # 最尾的逗號是可選的,但符合良好的規範\n" "}" -#: ../../faq/design.rst:775 +#: ../../faq/design.rst:777 msgid "There are several reasons to allow this." msgstr "這有許多原因可被允許。" -#: ../../faq/design.rst:777 +#: ../../faq/design.rst:779 msgid "" "When you have a literal value for a list, tuple, or dictionary spread across " "multiple lines, it's easier to add more elements because you don't have to " @@ -1574,13 +1577,13 @@ msgstr "" "當你要把串列、元組或字典的值寫成多行時,這樣做會讓你新增元素時較為方便,因為" "你不需要在前一行加上逗號。這幾行的值也可以被重新排序,而不會導致語法錯誤。" -#: ../../faq/design.rst:782 +#: ../../faq/design.rst:784 msgid "" "Accidentally omitting the comma can lead to errors that are hard to " "diagnose. For example::" msgstr "不小心遺漏了逗號會導致難以發現的錯誤,例如: ::" -#: ../../faq/design.rst:785 +#: ../../faq/design.rst:787 msgid "" "x = [\n" " \"fee\",\n" @@ -1596,7 +1599,7 @@ msgstr "" " \"fum\"\n" "]" -#: ../../faq/design.rst:792 +#: ../../faq/design.rst:794 msgid "" "This list looks like it has four elements, but it actually contains three: " "\"fee\", \"fiefoo\" and \"fum\". Always adding the comma avoids this source " @@ -1605,7 +1608,7 @@ msgstr "" "這個串列看起來有四個元素,但他其實只有三個:「fee」、「fiefoo」、「fum」。永" "遠記得加上逗號以避免這種錯誤。" -#: ../../faq/design.rst:795 +#: ../../faq/design.rst:797 msgid "" "Allowing the trailing comma may also make programmatic code generation " "easier." diff --git a/faq/general.po b/faq/general.po index b5ec25461db..8c8148d183c 100644 --- a/faq/general.po +++ b/faq/general.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-10-22 00:14+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-06-23 16:56+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -314,17 +314,17 @@ msgstr "" #: ../../faq/general.rst:155 msgid "" -"You may also find version numbers with a \"+\" suffix, e.g. \"2.2+\". These " -"are unreleased versions, built directly from the CPython development " -"repository. In practice, after a final minor release is made, the version " -"is incremented to the next minor version, which becomes the \"a0\" version, " -"e.g. \"2.4a0\"." +"You may also find version numbers with a \"+dev\" suffix, such as " +"\"3.15.0b3+dev\". These are unreleased versions, built directly from the " +"CPython development repository. After the first beta release is made, the " +"version is incremented to the next feature version, which becomes the \"a0\" " +"version, such as \"3.16.0a0\"." msgstr "" -"你還可以找到帶有「+」後綴的版本編號,例如「2.2+」。這些是未發布的版本,直接" -"從 CPython 的開發儲存庫被建置。實際上,在每一次的最終次要版本發布完成之後,版" -"本編號將會被增加到下一個次要版本,並成為「a0」版,例如「2.4a0」。" +"你還可以找到帶有「+dev」後綴的版本編號,例如「3.15.0b3+dev」。這些是未發布的" +"版本,直接從 CPython 的開發儲存庫被建置。在第一個 beta 版本發布之後,版本編號" +"將會被增加到下一個功能版本,並成為「a0」版,例如「3.16.0a0」。" -#: ../../faq/general.rst:160 +#: ../../faq/general.rst:161 msgid "" "See the `Developer's Guide `__ for more information about the development cycle, " @@ -337,11 +337,11 @@ msgstr "" "解更多關於 Python 的向後相容性政策。另外,也請查看 :data:`sys.version`、:" "data:`sys.hexversion` 和 :data:`sys.version_info` 的說明文件。" -#: ../../faq/general.rst:169 +#: ../../faq/general.rst:170 msgid "How do I obtain a copy of the Python source?" msgstr "我要如何得到 Python 的原始碼複本?" -#: ../../faq/general.rst:171 +#: ../../faq/general.rst:172 msgid "" "The latest Python source distribution is always available from python.org, " "at https://www.python.org/downloads/. The latest development sources can be " @@ -351,7 +351,7 @@ msgstr "" "org/downloads/。最新的開發中原始碼可以在 https://github.com/python/cpython/ " "取得。" -#: ../../faq/general.rst:175 +#: ../../faq/general.rst:176 msgid "" "The source distribution is a gzipped tar file containing the complete C " "source, Sphinx-formatted documentation, Python library modules, example " @@ -362,7 +362,7 @@ msgstr "" "說明文件、Python 函式庫模組、範例程式,以及幾個好用的可自由發行軟體。該原始碼" "在大多數 UNIX 平台上,都是可以立即編譯及運行的。" -#: ../../faq/general.rst:180 +#: ../../faq/general.rst:181 msgid "" "Consult the `Getting Started section of the Python Developer's Guide " "`__ for more information on getting the " @@ -371,11 +371,11 @@ msgstr "" "關於取得和編譯原始碼的詳細資訊,請參閱 `Python 開發人員指南中的 \"Getting " "Started\" 段落 `__。" -#: ../../faq/general.rst:186 +#: ../../faq/general.rst:187 msgid "How do I get documentation on Python?" msgstr "我要如何取得 Python 的說明文件?" -#: ../../faq/general.rst:188 +#: ../../faq/general.rst:189 msgid "" "The standard documentation for the current stable version of Python is " "available at https://docs.python.org/3/. EPUB, plain text, and downloadable " @@ -385,7 +385,7 @@ msgstr "" "純文字和可下載的 HTML 版本也可在 https://docs.python.org/3/download.html 找" "到。" -#: ../../faq/general.rst:192 +#: ../../faq/general.rst:193 msgid "" "The documentation is written in reStructuredText and processed by `the " "Sphinx documentation tool `__. The " @@ -396,17 +396,17 @@ msgstr "" "sphinx-doc.org/>`__\\ 處理。說明文件的 reStructuredText 原始碼是 Python 原始" "碼發行版的一部分。" -#: ../../faq/general.rst:198 +#: ../../faq/general.rst:199 msgid "I've never programmed before. Is there a Python tutorial?" msgstr "我從來沒有寫過程式,有沒有 Python 的教學?" -#: ../../faq/general.rst:200 +#: ../../faq/general.rst:201 msgid "" "There are numerous tutorials and books available. The standard " "documentation includes :ref:`tutorial-index`." msgstr "有許多可用的教學和書籍。標準說明文件包括 :ref:`tutorial-index`。" -#: ../../faq/general.rst:203 +#: ../../faq/general.rst:204 msgid "" "Consult `the Beginner's Guide `_ to find information for beginning Python programmers, " @@ -415,11 +415,11 @@ msgstr "" "要尋找 Python 程式設計初學者的資訊,包括教學資源列表,請參閱\\ `初學者指南 " "`_。" -#: ../../faq/general.rst:208 +#: ../../faq/general.rst:209 msgid "Is there a newsgroup or mailing list devoted to Python?" msgstr "有沒有 Python 專屬的新聞群組或郵件討論群?" -#: ../../faq/general.rst:210 +#: ../../faq/general.rst:211 msgid "" "There is a newsgroup, :newsgroup:`comp.lang.python`, and a mailing list, " "`python-list `_. The " @@ -434,7 +434,7 @@ msgstr "" "入郵件討論群。:newsgroup:`comp.lang.python` 的流量很高,每天會收到數百篇文" "章,而 Usenet 的讀者通常較能夠處理這樣的文章數量。" -#: ../../faq/general.rst:217 +#: ../../faq/general.rst:218 msgid "" "Announcements of new software releases and events can be found in comp.lang." "python.announce, a low-traffic moderated list that receives about five " @@ -446,7 +446,7 @@ msgstr "" "論群 `_\\ 的頁面中訂閱。" -#: ../../faq/general.rst:222 +#: ../../faq/general.rst:223 msgid "" "More info about other mailing lists and newsgroups can be found at https://" "www.python.org/community/lists/." @@ -454,11 +454,11 @@ msgstr "" "關於其他郵件討論群和新聞群組的更多資訊,可以在 https://www.python.org/" "community/lists/ 中找到。" -#: ../../faq/general.rst:227 +#: ../../faq/general.rst:228 msgid "How do I get a beta test version of Python?" msgstr "如何取得 Python 的 beta 測試版本?" -#: ../../faq/general.rst:229 +#: ../../faq/general.rst:230 msgid "" "Alpha and beta releases are available from https://www.python.org/" "downloads/. All releases are announced on the comp.lang.python and comp." @@ -469,7 +469,7 @@ msgstr "" "布版本都會在 comp.lang.python 和 comp.lang.python.announce 新聞群組上宣布,也" "會在 Python 首頁 https://www.python.org/ 中宣布;RSS 新聞摘要也是可使用的。" -#: ../../faq/general.rst:234 +#: ../../faq/general.rst:235 msgid "" "You can also access the development version of Python through Git. See `The " "Python Developer's Guide `_ for details." @@ -477,11 +477,11 @@ msgstr "" "你也可以藉由 Git 來存取 Python 的開發版本。更多詳細資訊,請參閱 `Python 開發" "人員指南 `_。" -#: ../../faq/general.rst:239 +#: ../../faq/general.rst:240 msgid "How do I submit bug reports and patches for Python?" msgstr "如何提交 Python 的錯誤報告和修補程式?" -#: ../../faq/general.rst:241 +#: ../../faq/general.rst:242 msgid "" "To report a bug or submit a patch, use the issue tracker at https://github." "com/python/cpython/issues." @@ -489,7 +489,7 @@ msgstr "" "要回報一個錯誤 (bug) 或提交一個修補程式 (patch),請使用於 https://github.com/" "python/cpython/issues 的問題追蹤系統。" -#: ../../faq/general.rst:244 +#: ../../faq/general.rst:245 msgid "" "For more information on how Python is developed, consult `the Python " "Developer's Guide `_." @@ -497,15 +497,15 @@ msgstr "" "關於如何開發 Python 的更多資訊,請參閱 `Python 開發人員指南 `_。" -#: ../../faq/general.rst:249 +#: ../../faq/general.rst:250 msgid "Are there any published articles about Python that I can reference?" msgstr "是否有關於 Python 的任何已出版文章可供參考?" -#: ../../faq/general.rst:251 +#: ../../faq/general.rst:252 msgid "It's probably best to cite your favorite book about Python." msgstr "也許最好是引用你最喜歡的關於 Python 的書。" -#: ../../faq/general.rst:253 +#: ../../faq/general.rst:254 msgid "" "The `very first article `_ about Python was " "written in 1991 and is now quite outdated." @@ -513,7 +513,7 @@ msgstr "" "`最早討論 Python 的文章 `_\\ 是在 1991 年寫的," "但現在來看已經過時了。" -#: ../../faq/general.rst:256 +#: ../../faq/general.rst:257 msgid "" "Guido van Rossum and Jelke de Boer, \"Interactively Testing Remote Servers " "Using the Python Programming Language\", CWI Quarterly, Volume 4, Issue 4 " @@ -523,11 +523,11 @@ msgstr "" "服器」,CWI 季刊,第 4 卷,第 4 期(1991 年 12 月),阿姆斯特丹,第 283–303 " "頁。" -#: ../../faq/general.rst:262 +#: ../../faq/general.rst:263 msgid "Are there any books on Python?" msgstr "有沒有關於 Python 的書?" -#: ../../faq/general.rst:264 +#: ../../faq/general.rst:265 msgid "" "Yes, there are many, and more are being published. See the python.org wiki " "at https://wiki.python.org/moin/PythonBooks for a list." @@ -535,7 +535,7 @@ msgstr "" "有,很多書已經出版,也有更多正在出版中的書。請參閱 python.org 的 wiki 在 " "https://wiki.python.org/moin/PythonBooks 頁面中的書目清單。" -#: ../../faq/general.rst:267 +#: ../../faq/general.rst:268 msgid "" "You can also search online bookstores for \"Python\" and filter out the " "Monty Python references; or perhaps search for \"Python\" and \"language\"." @@ -543,11 +543,11 @@ msgstr "" "你也可以在網路書店搜尋關鍵字「Python」,並過濾掉 Monty Python 的結果;或者可" "以搜尋「Python」和「語言」。" -#: ../../faq/general.rst:272 +#: ../../faq/general.rst:273 msgid "Where in the world is www.python.org located?" msgstr "www.python.org 的真實位置在哪裡?" -#: ../../faq/general.rst:274 +#: ../../faq/general.rst:275 msgid "" "The Python project's infrastructure is located all over the world and is " "managed by the Python Infrastructure Team. Details `here `__。" -#: ../../faq/general.rst:279 +#: ../../faq/general.rst:280 msgid "Why is it called Python?" msgstr "為什麼要取名為 Python?" -#: ../../faq/general.rst:281 +#: ../../faq/general.rst:282 msgid "" "When he began implementing Python, Guido van Rossum was also reading the " "published scripts from `\"Monty Python's Flying Circus\" `__\\ 的出版劇本。Van Rossum 認為他需要一個簡短、獨特且略帶神秘" "的名字,因此他決定將該語言稱為 Python。" -#: ../../faq/general.rst:289 +#: ../../faq/general.rst:290 msgid "Do I have to like \"Monty Python's Flying Circus\"?" msgstr "我需要喜歡「Monty Python 的飛行馬戲團」嗎?" -#: ../../faq/general.rst:291 +#: ../../faq/general.rst:292 msgid "No, but it helps. :)" msgstr "不需要,但它有幫助。:)" -#: ../../faq/general.rst:295 +#: ../../faq/general.rst:296 msgid "Python in the real world" msgstr "在真實世界中的 Python" -#: ../../faq/general.rst:298 +#: ../../faq/general.rst:299 msgid "How stable is Python?" msgstr "Python 的穩定性如何?" -#: ../../faq/general.rst:300 +#: ../../faq/general.rst:301 msgid "" "Very stable. New, stable releases have been coming out roughly every 6 to " "18 months since 1991, and this seems likely to continue. As of version 3.9, " @@ -599,7 +599,7 @@ msgstr "" "看起來會繼續進行。從 3.9 版開始,Python 每隔 12 個月將會釋出一個新功能發行版" "本 (:pep:`602`)。" -#: ../../faq/general.rst:304 +#: ../../faq/general.rst:305 msgid "" "The developers issue bugfix releases of older versions, so the stability of " "existing releases gradually improves. Bugfix releases, indicated by a third " @@ -613,7 +613,7 @@ msgstr "" "版本會被用於改善穩定性;在錯誤修正發布版本中,只會包含針對已知問題的修正,並" "且會保證介面在一系列的錯誤修正發布版本中維持不變。" -#: ../../faq/general.rst:311 +#: ../../faq/general.rst:312 msgid "" "The latest stable releases can always be found on the `Python download page " "`_. Python 3.x is the recommended version " @@ -624,17 +624,17 @@ msgstr "" "downloads/>`_\\ 上找到。Python 3.x 是推薦的版本,並且被大多數廣泛使用的函式庫" "所支援。Python 2.x :pep:`已不再被維護 <0373>`。" -#: ../../faq/general.rst:317 +#: ../../faq/general.rst:318 msgid "How many people are using Python?" msgstr "有多少人在使用 Python?" -#: ../../faq/general.rst:319 +#: ../../faq/general.rst:320 msgid "" "There are probably millions of users, though it's difficult to obtain an " "exact count." msgstr "可能有幾百萬個使用者,但實際的數量是難以確定的。" -#: ../../faq/general.rst:322 +#: ../../faq/general.rst:323 msgid "" "Python is available for free download, so there are no sales figures, and " "it's available from many different sites and packaged with many Linux " @@ -643,7 +643,7 @@ msgstr "" "Python 是可以免費下載的,所以不會有銷售數據,而且它可以從許多不同的網站取得," "並與許多 Linux 發行版套裝在一起,所以下載次數的統計也無法反映完整的情況。" -#: ../../faq/general.rst:326 +#: ../../faq/general.rst:327 msgid "" "The comp.lang.python newsgroup is very active, but not all Python users post " "to the group or even read it." @@ -651,11 +651,11 @@ msgstr "" "comp.lang.python 新聞群組非常活躍,但並非所有 Python 使用者都會在該群組發表文" "章或甚至閱讀它。" -#: ../../faq/general.rst:331 +#: ../../faq/general.rst:332 msgid "Have any significant projects been done in Python?" msgstr "有沒有任何重要的專案使用 Python 完成開發?" -#: ../../faq/general.rst:333 +#: ../../faq/general.rst:334 msgid "" "See https://www.python.org/about/success for a list of projects that use " "Python. Consulting the proceedings for `past Python conferences `_\\ 可以看見來自許多不同公司和組織的貢獻。" -#: ../../faq/general.rst:338 +#: ../../faq/general.rst:339 msgid "" "High-profile Python projects include `the Mailman mailing list manager " "`_ and `the Zope application server `_." @@ -706,11 +706,11 @@ msgstr "" "新的開發會在 `python-dev 郵件討論群 `_\\ 中討論。" -#: ../../faq/general.rst:360 +#: ../../faq/general.rst:361 msgid "Is it reasonable to propose incompatible changes to Python?" msgstr "對 Python 提出不相容的變更建議是否適當?" -#: ../../faq/general.rst:362 +#: ../../faq/general.rst:363 msgid "" "In general, no. There are already millions of lines of Python code around " "the world, so any change in the language that invalidates more than a very " @@ -724,7 +724,7 @@ msgstr "" "式,仍然會有需要更新全部說明文件的問題;市面上已經有很多介紹 Python 的書,而" "我們不想一下子就把它們都變為無效。" -#: ../../faq/general.rst:369 +#: ../../faq/general.rst:370 msgid "" "Providing a gradual upgrade path is necessary if a feature has to be " "changed. :pep:`5` describes the procedure followed for introducing backward-" @@ -734,15 +734,15 @@ msgstr "" "向不相容 (backward-incompatible) 的變更,同時也要對使用者的擾亂最小化,所需遵" "循的程序。" -#: ../../faq/general.rst:375 +#: ../../faq/general.rst:376 msgid "Is Python a good language for beginning programmers?" msgstr "Python 對於入門的程式設計師而言是否為好的語言?" -#: ../../faq/general.rst:377 +#: ../../faq/general.rst:378 msgid "Yes." msgstr "是的。" -#: ../../faq/general.rst:379 +#: ../../faq/general.rst:380 msgid "" "It is still common to start students with a procedural and statically typed " "language such as Pascal, C, or a subset of C++ or Java. Students may be " @@ -762,7 +762,7 @@ msgstr "" "速地向學生介紹基本觀念,例如迴圈和程序。他們甚至可能在第一堂課中就學到使用者" "自訂的物件。" -#: ../../faq/general.rst:389 +#: ../../faq/general.rst:390 msgid "" "For a student who has never programmed before, using a statically typed " "language seems unnatural. It presents additional complexity that the " @@ -778,7 +778,7 @@ msgstr "" "考、分解問題、設計一致的介面,並封裝資料。雖然從長遠來看,學習使用靜態型別語" "言很重要,但在學生的第一堂程式設計課程中,它不一定是最好的課程主題。" -#: ../../faq/general.rst:397 +#: ../../faq/general.rst:398 msgid "" "Many other aspects of Python make it a good first language. Like Java, " "Python has a large standard library so that students can be assigned " @@ -797,7 +797,7 @@ msgstr "" "用程式的滿足感。使用標準函式庫還可以教導學生程式碼再使用 (code reuse) 的課" "題。像是 PyGame 等第三方模組也有助於延伸學生的學習領域。" -#: ../../faq/general.rst:406 +#: ../../faq/general.rst:407 msgid "" "Python's interactive interpreter enables students to test language features " "while they're programming. They can keep a window with the interpreter " @@ -808,7 +808,7 @@ msgstr "" "行直譯器的視窗,同時在另一個視窗中輸入他們的程式原始碼。如果他們不記得 list" "(串列)的 method(方法),他們可以像這樣做: ::" -#: ../../faq/general.rst:411 +#: ../../faq/general.rst:412 msgid "" ">>> L = []\n" ">>> dir(L)\n" @@ -860,13 +860,13 @@ msgstr "" ">>> L\n" "[1]" -#: ../../faq/general.rst:435 +#: ../../faq/general.rst:436 msgid "" "With the interpreter, documentation is never far from the student as they " "are programming." msgstr "有了直譯器,當學生正在程式設計時,說明文件永遠都不會遠離他們。" -#: ../../faq/general.rst:438 +#: ../../faq/general.rst:439 msgid "" "There are also good IDEs for Python. IDLE is a cross-platform IDE for " "Python that is written in Python using Tkinter. Emacs users will be happy to " @@ -882,7 +882,7 @@ msgstr "" "式時存取互動式直譯器。要查看 Python 編輯環境的完整清單,請參閱 `Python wiki " "`_。" -#: ../../faq/general.rst:446 +#: ../../faq/general.rst:447 msgid "" "If you want to discuss Python's use in education, you may be interested in " "joining `the edu-sig mailing list \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -3720,7 +3720,7 @@ msgstr "" #: ../../faq/programming.rst:1925 msgid "" -"_sentinel = object()\n" +"_sentinel = sentinel('_sentinel')\n" "\n" "def pop(self, key, default=_sentinel):\n" " if key in self:\n" @@ -3731,7 +3731,7 @@ msgid "" " raise KeyError(key)\n" " return default" msgstr "" -"_sentinel = object()\n" +"_sentinel = sentinel('_sentinel')\n" "\n" "def pop(self, key, default=_sentinel):\n" " if key in self:\n" diff --git a/howto/a-conceptual-overview-of-asyncio.po b/howto/a-conceptual-overview-of-asyncio.po index 008ca2b690d..05a42fe0279 100644 --- a/howto/a-conceptual-overview-of-asyncio.po +++ b/howto/a-conceptual-overview-of-asyncio.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-16 00:27+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../howto/a-conceptual-overview-of-asyncio.rst:5 -msgid "A Conceptual Overview of :mod:`!asyncio`" +msgid "A conceptual overview of :mod:`!asyncio`" msgstr ":mod:`!asyncio` 的概念性總覽" #: ../../howto/a-conceptual-overview-of-asyncio.rst:7 @@ -83,16 +83,16 @@ msgid "" msgstr "" #: ../../howto/a-conceptual-overview-of-asyncio.rst:41 -msgid "Event Loop" +msgid "Event loop" msgstr "事件迴圈" #: ../../howto/a-conceptual-overview-of-asyncio.rst:43 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." +"star of the show, but prefers to work behind the scenes, managing and " +"coordinating resources. It's like an orchestra conductor. 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 band members." msgstr "" #: ../../howto/a-conceptual-overview-of-asyncio.rst:50 @@ -108,7 +108,8 @@ msgid "" "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." +"there's more work to be done, such as when I/O operations complete or timers " +"expire." msgstr "" #: ../../howto/a-conceptual-overview-of-asyncio.rst:64 @@ -300,15 +301,15 @@ 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`." +"discuss :keyword:`await`." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:175 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:174 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)." +"jobs). The recommended way to create tasks is via :func:`asyncio." +"create_task`." msgstr "" #: ../../howto/a-conceptual-overview-of-asyncio.rst:178 @@ -412,14 +413,18 @@ msgid "" "being awaited." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:256 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:258 +msgid "Awaiting tasks" +msgstr "" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:260 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:261 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:265 msgid "" "async def plant_a_tree():\n" " dig_the_hole_task = asyncio.create_task(dig_the_hole())\n" @@ -429,7 +434,7 @@ msgid "" " ..." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:268 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:272 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 " @@ -442,21 +447,25 @@ msgid "" "this case, a call to resume ``plant_a_tree()``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:279 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:283 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 loop's to-do list to be resumed." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:283 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:287 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:287 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:293 +msgid "Awaiting coroutines" +msgstr "await 協程" + +#: ../../howto/a-conceptual-overview-of-asyncio.rst:295 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 " @@ -464,7 +473,7 @@ msgid "" "invoking a regular, synchronous Python function. Consider this program::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:295 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:303 msgid "" "import asyncio\n" "\n" @@ -500,7 +509,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:312 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:320 msgid "" "The first statement in the coroutine ``main()`` creates ``task_b`` and " "schedules it for execution via the event loop. Then, ``coro_a()`` is " @@ -509,7 +518,7 @@ msgid "" "output:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:318 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:326 msgid "" "I am coro_a(). Hi!\n" "I am coro_a(). Hi!\n" @@ -521,7 +530,7 @@ msgstr "" "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:325 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:333 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 " @@ -530,7 +539,7 @@ msgid "" "before resuming the coroutine ``main()``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:332 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:340 msgid "" "I am coro_b(). I sure hope no one hogs the event loop...\n" "I am coro_a(). Hi!\n" @@ -542,7 +551,7 @@ msgstr "" "I am coro_a(). Hi!\n" "I am coro_a(). Hi!" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:339 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:347 msgid "" "This behavior of ``await coroutine`` can trip a lot of people up! That " "example highlights how using only ``await coroutine`` could unintentionally " @@ -553,20 +562,22 @@ msgid "" "longer." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:349 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:357 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`` statements and " -"a deep call stack, that overhead can add up to a meaningful performance drag." +"needs to be passed all the way up the call stack to the event loop. Then, " +"the event loop needs to manage its internal state and work through its " +"processing logic to resume the next job. That might sound minor, but in a " +"large program with many ``await``\\ s, that overhead can add up to a non-" +"negligible performance drag." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:358 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:368 msgid "A conceptual overview part 2: the nuts and bolts" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:360 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:370 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 " @@ -574,15 +585,16 @@ msgid "" "own asynchronous operators." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:368 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:378 msgid "The inner workings of coroutines" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:370 -msgid ":mod:`!asyncio` leverages four components to pass around control." +#: ../../howto/a-conceptual-overview-of-asyncio.rst:380 +msgid "" +":mod:`!asyncio` leverages four components of Python to pass around control." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:372 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:383 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, " @@ -591,7 +603,7 @@ msgid "" "first time (as opposed to being resumed), ``arg`` must be ``None``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:380 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:391 msgid "" "class Rock:\n" " def __await__(self):\n" @@ -645,7 +657,7 @@ msgstr "" " returned_value = e.value\n" "print(f\"Coroutine main() finished and provided value: {returned_value}.\")" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:408 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:419 msgid "" ":ref:`yield `, as usual, pauses execution and returns control to " "the caller. In the example above, the ``yield``, on line 3, is called by " @@ -656,7 +668,7 @@ msgid "" "coroutine.send(None)`` on line 16." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:418 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:429 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 " @@ -665,11 +677,11 @@ msgid "" "attached in the :attr:`~StopIteration.value` attribute." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:424 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:435 msgid "That snippet produces this output:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:426 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:437 msgid "" "Beginning coroutine main().\n" "Awaiting rock...\n" @@ -687,43 +699,43 @@ msgstr "" "Coroutine received value: 42 from rock.\n" "Coroutine main() finished and provided value: 23." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:436 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:447 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:440 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:451 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:444 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:455 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:449 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:460 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 " +"simplicity -- mandating only one way of using coroutines. Despite that, " +"``yield from`` and ``await`` effectively do the same thing. 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." +"generators." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:460 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:471 msgid "Futures" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:462 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:473 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 " @@ -731,7 +743,7 @@ msgid "" "that something." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:467 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:478 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 " @@ -741,7 +753,7 @@ msgid "" "yellow, or green) or indicator." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:474 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:485 msgid "" ":class:`asyncio.Task` subclasses :class:`asyncio.Future` in order to gain " "these various capabilities. The prior section said tasks store a list of " @@ -749,7 +761,7 @@ msgid "" "class that implements this logic, which ``Task`` inherits." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:481 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:492 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 " @@ -757,18 +769,18 @@ msgid "" "interface for you to make your own conditions for waiting and resuming." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:489 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:500 msgid "A homemade asyncio.sleep" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:491 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:502 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:495 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:506 msgid "" "This snippet registers a few tasks with the event loop and then awaits the " "task created by ``asyncio.create_task``, which wraps the ``async_sleep(3)`` " @@ -776,7 +788,7 @@ msgid "" "elapsed, but without preventing other tasks from running." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:502 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:513 msgid "" "async def other_work():\n" " print(\"I like work. Work work.\")\n" @@ -802,7 +814,7 @@ msgid "" " await asyncio.gather(*work_tasks)" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:526 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:537 msgid "" "Below, we use a future to enable custom control over when that task will be " "marked as done. If :meth:`future.set_result() ` " @@ -812,7 +824,7 @@ msgid "" "elapsed and, accordingly, call ``future.set_result()``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:537 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:548 msgid "" "async def async_sleep(seconds: float):\n" " future = asyncio.Future()\n" @@ -824,7 +836,7 @@ msgid "" " await future" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:545 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:556 msgid "" "Below, we use a rather bare ``YieldToEventLoop()`` object to ``yield`` from " "its ``__await__`` method, ceding control to the event loop. This is " @@ -833,7 +845,7 @@ msgid "" "sleep`` when showcasing how to implement it!" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:551 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:562 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``, " @@ -848,7 +860,7 @@ msgid "" "true of ``asyncio.sleep``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:567 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:578 msgid "" "class YieldToEventLoop:\n" " def __await__(self):\n" @@ -864,11 +876,11 @@ msgid "" " await YieldToEventLoop()" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:580 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:591 msgid "Here is the full program's output:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:582 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:593 msgid "" "$ python custom-async-sleep.py\n" "Beginning asynchronous sleep at time: 14:52:22.\n" @@ -884,7 +896,7 @@ msgstr "" "I like work. Work work.\n" "Done asynchronous sleep at time: 14:52:25." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:591 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:602 msgid "" "You might feel this implementation of asynchronous sleep was unnecessarily " "convoluted. And, well, it was. The example was meant to showcase the " @@ -893,7 +905,7 @@ msgid "" "so::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:598 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:609 msgid "" "async def simpler_async_sleep(seconds):\n" " time_to_wake = time.time() + seconds\n" @@ -911,7 +923,7 @@ msgstr "" " else:\n" " await YieldToEventLoop()" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:606 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:617 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 " diff --git a/howto/abi3t-migration.po b/howto/abi3t-migration.po new file mode 100644 index 00000000000..b2c4f50a1c9 --- /dev/null +++ b/howto/abi3t-migration.po @@ -0,0 +1,1262 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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/abi3t-migration.rst:7 +msgid "Migrating to Stable ABI for free threading (``abi3t``)" +msgstr "" + +#: ../../howto/abi3t-migration.rst:9 +msgid "" +"Starting with the 3.15 release, CPython supports a variant of the Stable ABI " +"that supports :term:`free-threaded ` Python: the Stable ABI " +"for Free-Threaded Builds, or ``abi3t`` for short. This document describes " +"how to adapt C API extensions to support free threading." +msgstr "" + +#: ../../howto/abi3t-migration.rst:15 +msgid "Why do this" +msgstr "" + +#: ../../howto/abi3t-migration.rst:17 +msgid "" +"The typical reason to use the Stable ABI is to reduce the number of " +"artifacts that you need to build and distribute for each version of your " +"library." +msgstr "" + +#: ../../howto/abi3t-migration.rst:20 +msgid "" +"Without the Stable ABI, you must build a separate shared library, and " +"typically a *wheel* distribution, for each feature version of CPython you " +"wish to support. For example, each tag in the following table represents a " +"separate library/wheel:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:27 ../../howto/abi3t-migration.rst:49 +#: ../../howto/abi3t-migration.rst:69 +msgid "CPython version" +msgstr "" + +#: ../../howto/abi3t-migration.rst:27 ../../howto/abi3t-migration.rst:49 +#: ../../howto/abi3t-migration.rst:69 +msgid "Non-free-threaded" +msgstr "" + +#: ../../howto/abi3t-migration.rst:27 ../../howto/abi3t-migration.rst:49 +#: ../../howto/abi3t-migration.rst:69 +msgid "Free-threaded" +msgstr "" + +#: ../../howto/abi3t-migration.rst:29 ../../howto/abi3t-migration.rst:51 +#: ../../howto/abi3t-migration.rst:71 +msgid "3.12" +msgstr "3.12" + +#: ../../howto/abi3t-migration.rst:29 +msgid "``cpython-312``" +msgstr "``cpython-312``" + +#: ../../howto/abi3t-migration.rst:29 ../../howto/abi3t-migration.rst:51 +#: ../../howto/abi3t-migration.rst:71 +msgid "---" +msgstr "---" + +#: ../../howto/abi3t-migration.rst:31 ../../howto/abi3t-migration.rst:53 +#: ../../howto/abi3t-migration.rst:73 +msgid "3.13" +msgstr "3.13" + +#: ../../howto/abi3t-migration.rst:31 +msgid "``cpython-313``" +msgstr "``cpython-313``" + +#: ../../howto/abi3t-migration.rst:31 ../../howto/abi3t-migration.rst:53 +#: ../../howto/abi3t-migration.rst:73 +msgid "``cpython-313t``" +msgstr "``cpython-313t``" + +#: ../../howto/abi3t-migration.rst:33 ../../howto/abi3t-migration.rst:55 +#: ../../howto/abi3t-migration.rst:75 +msgid "3.14" +msgstr "3.14" + +#: ../../howto/abi3t-migration.rst:33 +msgid "``cpython-314``" +msgstr "``cpython-314``" + +#: ../../howto/abi3t-migration.rst:33 ../../howto/abi3t-migration.rst:55 +#: ../../howto/abi3t-migration.rst:75 +msgid "``cpython-314t``" +msgstr "``cpython-314t``" + +#: ../../howto/abi3t-migration.rst:35 ../../howto/abi3t-migration.rst:57 +#: ../../howto/abi3t-migration.rst:77 +msgid "3.15" +msgstr "3.15" + +#: ../../howto/abi3t-migration.rst:35 +msgid "``cpython-315``" +msgstr "``cpython-315``" + +#: ../../howto/abi3t-migration.rst:35 ../../howto/abi3t-migration.rst:57 +msgid "``cpython-315t``" +msgstr "``cpython-315t``" + +#: ../../howto/abi3t-migration.rst:37 ../../howto/abi3t-migration.rst:59 +#: ../../howto/abi3t-migration.rst:79 +msgid "3.16" +msgstr "3.16" + +#: ../../howto/abi3t-migration.rst:37 +msgid "``cpython-316``" +msgstr "``cpython-316``" + +#: ../../howto/abi3t-migration.rst:37 ../../howto/abi3t-migration.rst:59 +msgid "``cpython-316t``" +msgstr "``cpython-316t``" + +#: ../../howto/abi3t-migration.rst:39 ../../howto/abi3t-migration.rst:61 +#: ../../howto/abi3t-migration.rst:81 +msgid "Later versions" +msgstr "" + +#: ../../howto/abi3t-migration.rst:39 +msgid ":samp:`cpython-3{XX}`" +msgstr ":samp:`cpython-3{XX}`" + +#: ../../howto/abi3t-migration.rst:39 ../../howto/abi3t-migration.rst:61 +msgid ":samp:`cpython-3{XX}t`" +msgstr ":samp:`cpython-3{XX}t`" + +#: ../../howto/abi3t-migration.rst:42 +msgid "" +"That's a lot of builds, especially when multiplied by the number of " +"supported platforms." +msgstr "" + +#: ../../howto/abi3t-migration.rst:45 +msgid "" +"With the Stable ABI (``abi3``, introduced in CPython 3.2), a single " +"extension (per platform) can cover all *non-free-threaded* builds of CPython:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:51 +msgid "``abi3``" +msgstr "``abi3``" + +#: ../../howto/abi3t-migration.rst:64 +msgid "" +"The Stable ABI for free-threaded builds (``abi3t``), introduced in CPython " +"3.15, does the same for free-threaded builds. And it's compatible with non-" +"free-threaded ones as well:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:71 +msgid "``abi3`` *" +msgstr "``abi3`` *" + +#: ../../howto/abi3t-migration.rst:77 +msgid "``abi3t``" +msgstr "``abi3t``" + +#: ../../howto/abi3t-migration.rst:84 +msgid "" +"\\* (As above, the ``abi3`` extension is compatible with all non-free-" +"threaded builds; even the 3.15+ ones that this table \"attributes\" to " +"``abi3t``.)" +msgstr "" + +#: ../../howto/abi3t-migration.rst:88 +msgid "Why *not* do this" +msgstr "" + +#: ../../howto/abi3t-migration.rst:90 +msgid "There are two main downsides to the Stable ABI." +msgstr "" + +#: ../../howto/abi3t-migration.rst:92 +msgid "" +"First, your extension may become slower, since the Stable ABI prioritizes " +"compatibility over performance. The difference is usually not noticeable, " +"and often can be mitigated by using the same source to build both a Stable " +"ABI build and a few version-specific ones for \"tier 1\" CPython versions." +msgstr "" + +#: ../../howto/abi3t-migration.rst:98 +msgid "" +"Second, not all of the C API is available. Extensions need to be ported to " +"build for the Stable ABI, which may be difficult or, in rare cases, " +"impossible." +msgstr "" + +#: ../../howto/abi3t-migration.rst:102 +msgid "" +"Specifically, ``abi3t`` requires APIs added in CPython 3.15. If you want to " +"build your extension for older versions of CPython from the same source, you " +"have two main options:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:106 +msgid "Use preprocessor conditionals." +msgstr "" + +#: ../../howto/abi3t-migration.rst:108 +msgid "" +"When following this guide, use ``#ifdef Py_TARGET_ABI3T`` blocks whenever " +"you are told to do a change that breaks the build on CPython versions you " +"care about. Keep the pre-existing code in ``#else`` blocks." +msgstr "" + +#: ../../howto/abi3t-migration.rst:112 +msgid "" +"For hand-written C extensions, this approach is reasonable down to CPython " +"3.12, due to additions introduced in :pep:`697`. Keeping compatibility with " +"3.11 and below may be worth it for code generators (for example, Cython)." +msgstr "" + +#: ../../howto/abi3t-migration.rst:117 +msgid "" +"Do not port to ``abi3t``, and continue building separate extensions for each " +"version of CPython, until you can drop support for the older versions." +msgstr "" + +#: ../../howto/abi3t-migration.rst:120 +msgid "" +"This is a valid approach. Not all extensions need to switch to ``abi3t`` " +"right now." +msgstr "" + +#: ../../howto/abi3t-migration.rst:125 +msgid "Prerequisites" +msgstr "先決條件" + +#: ../../howto/abi3t-migration.rst:127 +msgid "" +"This guide assumes that you have an extension written directly in C (or C+" +"+), which you want to port to ``abi3t``." +msgstr "" + +#: ../../howto/abi3t-migration.rst:130 +msgid "" +"If your extension uses a code generator (like Cython) or language binding " +"(like PyO3), it's best to wait until that tool has support for ``abi3t``. If " +"you maintain such a tool, you might be able to adapt the instructions here " +"for your tool." +msgstr "" + +#: ../../howto/abi3t-migration.rst:136 +msgid "Non-free-threaded Stable ABI" +msgstr "" + +#: ../../howto/abi3t-migration.rst:138 +msgid "" +"Your extension should support the non-free-threaded Stable ABI (``abi3``). " +"If not, either port it first, or follow this guide but be prepared to fix " +"issues it does not mention." +msgstr "" + +#: ../../howto/abi3t-migration.rst:143 +msgid "Free-threading support" +msgstr "" + +#: ../../howto/abi3t-migration.rst:145 +msgid "" +"While it's technically not a hard prerequisite, you will most likely want to " +"prepare your extension for free threading before you port it to ``abi3t``. " +"See :ref:`freethreading-extensions-howto` for instructions." +msgstr "" + +#: ../../howto/abi3t-migration.rst:151 +msgid "" +"`Porting Extension Modules to Support Free-Threading `__: A community-maintained porting guide for " +"extension authors." +msgstr "" + +#: ../../howto/abi3t-migration.rst:156 +msgid "Isolating extension modules" +msgstr "" + +#: ../../howto/abi3t-migration.rst:158 +msgid "" +"Your module should use :ref:`multi-phase initialization `, and it should either be isolated or limit itself to be " +"loaded at most once per process. If it is not your case, follow :ref:" +"`isolating-extensions-howto` first. (See the :ref:`opt-out section " +"` for a shortcut.)" +msgstr "" + +#: ../../howto/abi3t-migration.rst:165 +msgid "Avoiding variable-sized types" +msgstr "" + +#: ../../howto/abi3t-migration.rst:167 +msgid "" +"If your extension defines variable-sized types (using :c:macro:" +"`Py_tp_itemsize` or :c:member:`PyTypeObject.tp_itemsize`), it cannot be " +"ported to ``abi3t`` 3.15." +msgstr "" + +#: ../../howto/abi3t-migration.rst:175 +msgid "Setting up the build" +msgstr "" + +#: ../../howto/abi3t-migration.rst:177 +msgid "" +"If you use a build tool, search its documentation for \"``abi3t``\", and " +"follow any instructions to select the ABI. For reference, here are direct " +"links for several popular build tools:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:181 +msgid "" +"`meson-python `__" +msgstr "" +"`meson-python `__" + +#: ../../howto/abi3t-migration.rst:183 +msgid "" +"`scikit-build-core `__" +msgstr "" +"`scikit-build-core `__" + +#: ../../howto/abi3t-migration.rst:185 +msgid "`Maturin `__" +msgstr "`Maturin `__" + +#: ../../howto/abi3t-migration.rst:187 +msgid "" +"You may want to verify that the tool set the right flag by temporarily " +"adding the following just after ``#include ``::" +msgstr "" + +#: ../../howto/abi3t-migration.rst:190 +msgid "" +"#if Py_TARGET_ABI3T+0 <= 0x30f0000\n" +"#error \"abi3t define is not set!\"\n" +"#endif" +msgstr "" +"#if Py_TARGET_ABI3T+0 <= 0x30f0000\n" +"#error \"abi3t define is not set!\"\n" +"#endif" + +#: ../../howto/abi3t-migration.rst:194 +msgid "" +"This should result in a different error than \"``abi3t`` define is not set\"." +msgstr "" + +#: ../../howto/abi3t-migration.rst:198 +msgid "" +"`Building and distributing abi3t extensions `__: Build configuration and wheel testing examples in the " +"community-maintained Python Free-Threading Guide." +msgstr "" + +#: ../../howto/abi3t-migration.rst:205 +msgid "" +"If your build tool doesn't support ``abi3t`` yet, set the following macro " +"before including ``Python.h``::" +msgstr "" + +#: ../../howto/abi3t-migration.rst:208 +msgid "#define Py_TARGET_ABI3T 0x30f0000" +msgstr "#define Py_TARGET_ABI3T 0x30f0000" + +#: ../../howto/abi3t-migration.rst:210 +msgid "or specify it as a compiler flag, for example::" +msgstr "" + +#: ../../howto/abi3t-migration.rst:212 +msgid "-DPy_TARGET_ABI3T=0x30f0000" +msgstr "-DPy_TARGET_ABI3T=0x30f0000" + +#: ../../howto/abi3t-migration.rst:214 +msgid "" +"Once your extension builds with this setting, it will be compatible with " +"CPython 3.15 and above." +msgstr "" + +#: ../../howto/abi3t-migration.rst:217 +msgid "" +"If you set this macro manually, you will later need to name and tag the " +"resulting extension manually as well. This is covered in :ref:`abi3t-" +"migration-tagging` below." +msgstr "" + +#: ../../howto/abi3t-migration.rst:221 +msgid "" +"This guide will ask you to make a series of changes. After each one, verify " +"that your extension still builds in the original (non-``abi3t``) " +"configuration, and ideally run tests on all Python versions you support. " +"This will ensure that nothing breaks as you are porting." +msgstr "" + +#: ../../howto/abi3t-migration.rst:231 +msgid "Module export hook" +msgstr "" + +#: ../../howto/abi3t-migration.rst:233 +msgid "" +"Unless you've done this step already, your extension module defines a :ref:" +"`module initialization function ` named :samp:" +"`PyInit_{}` (where ``modname`` is the name of your module). You " +"will need to port it to a :ref:`module export hook `, :samp:`PyModExport_{}`, a feature added in CPython 3.15 in :" +"pep:`793`." +msgstr "" + +#: ../../howto/abi3t-migration.rst:240 +msgid "" +"Your existing init function should look like this (with your own names for " +"```` and ````):" +msgstr "" + +#: ../../howto/abi3t-migration.rst:243 +msgid "" +"PyMODINIT_FUNC\n" +"PyInit_(void)\n" +"{\n" +" return PyModuleDef_Init(&);\n" +"}" +msgstr "" +"PyMODINIT_FUNC\n" +"PyInit_(void)\n" +"{\n" +" return PyModuleDef_Init(&);\n" +"}" + +#: ../../howto/abi3t-migration.rst:252 +msgid "" +"If there is some code before the ``return``, move it to a :c:macro:" +"`Py_mod_create` or :c:macro:`Py_mod_exec` slot function. See the :ref:" +"`PyInit documentation ` for related information." +msgstr "" + +#: ../../howto/abi3t-migration.rst:256 +msgid "" +"The function references a ``PyModuleDef`` object (```` in the code " +"above). Its definition should be similar to the following, with different " +"values and perhaps some fields unnnamed or left out:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:261 +msgid "" +"static PyModuleDef = {\n" +" PyModuleDef_HEAD_INIT,\n" +" .m_name = \"my_module\",\n" +" .m_doc = \"my docstring\",\n" +" .m_size = sizeof(my_state_struct),\n" +" .m_methods = my_methods,\n" +" .m_slots = my_slots,\n" +" .m_traverse = my_traverse,\n" +" .m_clear = my_clear,\n" +" .m_free = my_free,\n" +"};" +msgstr "" +"static PyModuleDef = {\n" +" PyModuleDef_HEAD_INIT,\n" +" .m_name = \"my_module\",\n" +" .m_doc = \"my docstring\",\n" +" .m_size = sizeof(my_state_struct),\n" +" .m_methods = my_methods,\n" +" .m_slots = my_slots,\n" +" .m_traverse = my_traverse,\n" +" .m_clear = my_clear,\n" +" .m_free = my_free,\n" +"};" + +#: ../../howto/abi3t-migration.rst:276 +msgid "" +"Remove this definition and the ``PyInit`` function (or put them in an " +"``#ifndef Py_TARGET_ABI3T`` block, to retain backwards compatibility), and " +"replace them with the following:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:280 +msgid "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot my_slot_array[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"my_module\"),\n" +" PySlot_STATIC_DATA(Py_mod_doc, \"my docstring\"),\n" +" PySlot_SIZE(Py_mod_state_size, sizeof(my_state_struct)),\n" +" PySlot_STATIC_DATA(Py_mod_methods, my_methods),\n" +" PySlot_STATIC_DATA(Py_mod_slots, my_slots),\n" +" PySlot_FUNC(Py_mod_state_traverse, my_traverse),\n" +" PySlot_FUNC(Py_mod_state_clear, my_clear),\n" +" PySlot_FUNC(Py_mod_state_free, my_free),\n" +" PySlot_END\n" +"};\n" +"\n" +"PyMODEXPORT_FUNC\n" +"PyModExport_(void)\n" +"{\n" +" return my_slot_array;\n" +"}" +msgstr "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot my_slot_array[] = {\n" +" PySlot_STATIC_DATA(Py_mod_abi, &abi_info),\n" +" PySlot_STATIC_DATA(Py_mod_name, \"my_module\"),\n" +" PySlot_STATIC_DATA(Py_mod_doc, \"my docstring\"),\n" +" PySlot_SIZE(Py_mod_state_size, sizeof(my_state_struct)),\n" +" PySlot_STATIC_DATA(Py_mod_methods, my_methods),\n" +" PySlot_STATIC_DATA(Py_mod_slots, my_slots),\n" +" PySlot_FUNC(Py_mod_state_traverse, my_traverse),\n" +" PySlot_FUNC(Py_mod_state_clear, my_clear),\n" +" PySlot_FUNC(Py_mod_state_free, my_free),\n" +" PySlot_END\n" +"};\n" +"\n" +"PyMODEXPORT_FUNC\n" +"PyModExport_(void)\n" +"{\n" +" return my_slot_array;\n" +"}" + +#: ../../howto/abi3t-migration.rst:304 +msgid "" +"Leave out any fields that were missing (except the new :c:macro:" +"`Py_mod_abi`), and substitute your own values." +msgstr "" + +#: ../../howto/abi3t-migration.rst:307 +msgid "" +"See the :c:type:`PySlot` and :c:ref:`export hook ` " +"documentation for details on this API." +msgstr "" + +#: ../../howto/abi3t-migration.rst:310 +msgid "" +"As in the example, your ``PyModExport_`` function should *only* return a " +"pointer to static data. If you cannot avoid additional code, refer to the :" +"ref:`caveats in PyModExport documentation `." +msgstr "" + +#: ../../howto/abi3t-migration.rst:317 +msgid "" +"When building for Windows using the Setuptools_ build tool, removing the :" +"samp:`PyInit_{}` function may result in the linker error :samp:" +"`LINK : error LNK2001: unresolved external symbol PyInit_{}`. This " +"is caused by Setuptools passing an ``/EXPORT`` linker flag, which is " +"redundant since Python 3.15 (see :gh:`141671`). A workaround is to add a " +"dummy :samp:`PyInit_{}` function to your code. Python 3.15+ will " +"never call this function if :samp:`PyModExport_{}` is present, so " +"it can always fail:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:327 +msgid "" +"// Workaround for https://github.com/pypa/distutils/issues/387\n" +"PyMODINIT_FUNC\n" +"PyInit_(void)\n" +"{\n" +" PyErr_SetString(PyExc_SystemError,\n" +" \"PyInit_* called for module with PyModExport_*\");\n" +" return NULL;\n" +"}" +msgstr "" +"// 針對 https://github.com/pypa/distutils/issues/387 的權宜做法\n" +"PyMODINIT_FUNC\n" +"PyInit_(void)\n" +"{\n" +" PyErr_SetString(PyExc_SystemError,\n" +" \"PyInit_* called for module with PyModExport_*\");\n" +" return NULL;\n" +"}" + +#: ../../howto/abi3t-migration.rst:338 +msgid "" +"(This issue is present in Setuptools 84.0.0; it might be fixed in newer " +"versions.)" +msgstr "" + +#: ../../howto/abi3t-migration.rst:345 +msgid "Existing slots" +msgstr "" + +#: ../../howto/abi3t-migration.rst:347 +msgid "" +"If you have a ``Py_mod_slots`` slot, check the array it refers to. It should " +"be a :c:type:`PyModuleDef_Slot` array like the following:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:350 +msgid "" +"static PyObject *create_module(PyObject *spec, PyModuleDef *def) { ... }\n" +"static int my_first_module_exec(PyObject *module) { ... }\n" +"static int my_second_module_exec(PyObject *module) { ... }\n" +"\n" +"static PyModuleDef_Slot my_slots[] = {\n" +" {Py_mod_gil, Py_MOD_GIL_NOT_USED},\n" +" {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},\n" +" {Py_mod_create, my_module_create},\n" +" {Py_mod_exec, my_first_module_exec},\n" +" {Py_mod_exec, my_second_module_exec},\n" +" {0, NULL}\n" +"};" +msgstr "" +"static PyObject *create_module(PyObject *spec, PyModuleDef *def) { ... }\n" +"static int my_first_module_exec(PyObject *module) { ... }\n" +"static int my_second_module_exec(PyObject *module) { ... }\n" +"\n" +"static PyModuleDef_Slot my_slots[] = {\n" +" {Py_mod_gil, Py_MOD_GIL_NOT_USED},\n" +" {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},\n" +" {Py_mod_create, my_module_create},\n" +" {Py_mod_exec, my_first_module_exec},\n" +" {Py_mod_exec, my_second_module_exec},\n" +" {0, NULL}\n" +"};" + +#: ../../howto/abi3t-migration.rst:367 +msgid "``py_mod_create``" +msgstr "``py_mod_create``" + +#: ../../howto/abi3t-migration.rst:370 +msgid "" +"If you have a :c:macro:`Py_mod_create` entry, make sure the function can be " +"called with ``NULL`` as its second argument (instead of the :c:type:" +"`PyModuleDef`, which you are removing). Often, this argument isn't used at " +"all; you can check by renaming it:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:375 +msgid "" +"static PyObject *create_module(PyObject *spec, PyModuleDef *_unused) { ... }" +msgstr "" +"static PyObject *create_module(PyObject *spec, PyModuleDef *_unused) { ... }" + +#: ../../howto/abi3t-migration.rst:380 +msgid "" +"If the argument is used, find a different way to pass in the data. Commonly, " +"the information is static and you can refer to it directly. (If you're " +"reusing a single function for several different modules, consider defining " +"several functions instead.)" +msgstr "" + +#: ../../howto/abi3t-migration.rst:387 +msgid "Multiple ``py_mod_exec``" +msgstr "" + +#: ../../howto/abi3t-migration.rst:389 +msgid "" +"If you have *more than one* :c:macro:`Py_mod_exec` entry, consolidate them: " +"create a new function that calls the others, and replace existing slots with " +"it." +msgstr "" + +#: ../../howto/abi3t-migration.rst:393 +msgid "" +"static int my_module_exec(PyObject *module) {\n" +" if (my_first_module_exec(module) < 0) return -1;\n" +" if (my_second_module_exec(module) < 0) return -1;\n" +"}\n" +"\n" +"static PyModuleDef_Slot my_slots[] = {\n" +" ...\n" +" /* (remove other Py_mod_exec slots) */\n" +" ...\n" +" {Py_mod_exec, my_module_exec},\n" +" {0, NULL}\n" +"};" +msgstr "" +"static int my_module_exec(PyObject *module) {\n" +" if (my_first_module_exec(module) < 0) return -1;\n" +" if (my_second_module_exec(module) < 0) return -1;\n" +"}\n" +"\n" +"static PyModuleDef_Slot my_slots[] = {\n" +" ...\n" +" /* (移除其他 Py_mod_exec 插槽) */\n" +" ...\n" +" {Py_mod_exec, my_module_exec},\n" +" {0, NULL}\n" +"};" + +#: ../../howto/abi3t-migration.rst:409 +msgid "" +"If the functions aren't used elsewhere, you can combine their bodies instead." +msgstr "" + +#: ../../howto/abi3t-migration.rst:413 +msgid "Merging slot arrays" +msgstr "" + +#: ../../howto/abi3t-migration.rst:415 +msgid "" +"Optionally, when you break compatibility with Python 3.14, you may clean up " +"the code by moving slots into the :c:type:`PySlot` array, and converting the " +"definitions to :c:macro:`PySlot_DATA` and :c:macro:`PySlot_FUNC`:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:419 +msgid "" +"static PySlot my_slot_array[] = {\n" +" ...\n" +" PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED),\n" +" PySlot_DATA(Py_mod_multiple_interpreters,\n" +" Py_MOD_PER_INTERPRETER_GIL_SUPPORTED)\n" +" PySlot_FUNC(Py_mod_create, my_module_create),\n" +" PySlot_FUNC(Py_mod_exec, my_module_exec),\n" +" PySlot_END\n" +"};" +msgstr "" +"static PySlot my_slot_array[] = {\n" +" ...\n" +" PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED),\n" +" PySlot_DATA(Py_mod_multiple_interpreters,\n" +" Py_MOD_PER_INTERPRETER_GIL_SUPPORTED)\n" +" PySlot_FUNC(Py_mod_create, my_module_create),\n" +" PySlot_FUNC(Py_mod_exec, my_module_exec),\n" +" PySlot_END\n" +"};" + +#: ../../howto/abi3t-migration.rst:432 +msgid "" +"If you do this, delete the original :c:type:`PyModuleDef_Slot` array and its " +"``Py_mod_slots`` entry." +msgstr "" + +#: ../../howto/abi3t-migration.rst:437 +msgid "Associated ``PyModuleDef``" +msgstr "" + +#: ../../howto/abi3t-migration.rst:439 +msgid "" +"Since the new API does not use a :c:type:`!PyModuleDef` structure, a " +"definition will not be associated with the resulting module. This changes " +"the behavior of the following functions:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:443 +msgid ":c:func:`PyModule_GetDef`" +msgstr ":c:func:`PyModule_GetDef`" + +#: ../../howto/abi3t-migration.rst:444 +msgid ":c:func:`PyType_GetModuleByDef`" +msgstr ":c:func:`PyType_GetModuleByDef`" + +#: ../../howto/abi3t-migration.rst:446 +msgid "" +"Check your code for these. If you do not use them, you can skip this section." +msgstr "" + +#: ../../howto/abi3t-migration.rst:449 +msgid "These functions are typically used for two purposes:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:451 +msgid "" +"To get the definition the module was created with. This is no longer " +"possible using the new API. Modules no longer keep a reference to the " +"definition, so you will need to figure out a different way to pass the " +"relevant data around." +msgstr "" + +#: ../../howto/abi3t-migration.rst:458 +msgid "" +"To check if a given module object is “yours”. This use case is now served " +"by :ref:`module tokens ` -- opaque pointers that identify " +"a module. To use a token, declare (or reuse) a unique static variable, for " +"example:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:463 +msgid "static char my_token;" +msgstr "static char my_token;" + +#: ../../howto/abi3t-migration.rst:468 +msgid "" +"and add a pointer to it in a new entry to your module's ``PySlot`` array:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:470 +msgid "" +"static PySlot my_slot_array[] = {\n" +" ...\n" +" PySlot_STATIC_DATA(Py_mod_token, &my_token),\n" +" PySlot_END\n" +"}" +msgstr "" +"static PySlot my_slot_array[] = {\n" +" ...\n" +" PySlot_STATIC_DATA(Py_mod_token, &my_token),\n" +" PySlot_END\n" +"}" + +#: ../../howto/abi3t-migration.rst:480 +msgid "Then, switch from :c:func:`PyModule_GetDef` calls such as:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:482 +msgid "PyModuleDef *def = PyModule_GetDef(module);" +msgstr "PyModuleDef *def = PyModule_GetDef(module);" + +#: ../../howto/abi3t-migration.rst:487 +msgid "" +"to :c:func:`PyModule_GetToken` (which uses an output argument and may fail " +"with an exception):" +msgstr "" + +#: ../../howto/abi3t-migration.rst:490 +msgid "" +"void *token;\n" +"if (PyModule_GetToken(module, &token) < 0) {\n" +" /* handle error */\n" +"}" +msgstr "" +"void *token;\n" +"if (PyModule_GetToken(module, &token) < 0) {\n" +" /* 處理錯誤 */\n" +"}" + +#: ../../howto/abi3t-migration.rst:498 +msgid "and from :c:func:`PyType_GetModuleByDef` calls such as:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:500 +msgid "" +"PyObject *module = PyType_GetModuleByDef(type, my_def);\n" +"/* handle error; use module */" +msgstr "" +"PyObject *module = PyType_GetModuleByDef(type, my_def);\n" +"/* 處理錯誤;使用 module */" + +#: ../../howto/abi3t-migration.rst:506 +msgid "" +"to :c:func:`PyType_GetModuleByToken` (which returns a strong reference):" +msgstr "" + +#: ../../howto/abi3t-migration.rst:508 +msgid "" +"PyObject *module = PyType_GetModuleByToken(type, my_token);\n" +"/* handle error; use module */\n" +"Py_XDECREF(module);" +msgstr "" +"PyObject *module = PyType_GetModuleByToken(type, my_token);\n" +"/* 處理錯誤;使用 module */\n" +"Py_XDECREF(module);" + +#: ../../howto/abi3t-migration.rst:516 +msgid "``PyObject`` opaqueness" +msgstr "" + +#: ../../howto/abi3t-migration.rst:518 +msgid "" +"The :c:type:`PyObject` and :c:type:`PyVarObject` structures are opaque in " +"``abi3t``." +msgstr "" + +#: ../../howto/abi3t-migration.rst:521 +msgid "" +"Accessing their members is prohibited. If you do this, switch to getter/" +"setter functions mentioned in their documentation:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:525 +msgid ":c:member:`PyObject.ob_type`" +msgstr ":c:member:`PyObject.ob_type`" + +#: ../../howto/abi3t-migration.rst:526 +msgid ":c:member:`PyObject.ob_refcnt`" +msgstr ":c:member:`PyObject.ob_refcnt`" + +#: ../../howto/abi3t-migration.rst:527 +msgid ":c:member:`PyVarObject.ob_size`" +msgstr ":c:member:`PyVarObject.ob_size`" + +#: ../../howto/abi3t-migration.rst:529 +msgid "" +"Also, the *size* of the :c:type:`PyObject` structures is unknown to the " +"compiler. It can -- and *does* -- change between different CPython builds." +msgstr "" + +#: ../../howto/abi3t-migration.rst:535 +msgid "" +"While the size is available at runtime (for example as ``sys." +"getsizeof(object())`` in Python code), you should resist the temptation to " +"calculate pointer offsets from it. The object memory layout is subject to " +"change in future ``abi3t`` implementations." +msgstr "" + +#: ../../howto/abi3t-migration.rst:543 +msgid "Custom type definitions" +msgstr "" + +#: ../../howto/abi3t-migration.rst:545 +msgid "" +"Since :c:type:`!PyObject` is opaque, the traditional way of defining custom " +"types no longer works:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:548 +msgid "" +"typedef struct {\n" +" PyObject_HEAD // expands to `PyObject ob_base;` which has unknown size\n" +"\n" +" int my_data;\n" +"} CustomObject;\n" +"\n" +"static PyType_Spec CustomType_spec = {\n" +" ...\n" +" .basicsize = sizeof(CustomObject),\n" +" ...\n" +"};" +msgstr "" +"typedef struct {\n" +" PyObject_HEAD // 展開為大小未知的 `PyObject ob_base;`\n" +"\n" +" int my_data;\n" +"} CustomObject;\n" +"\n" +"static PyType_Spec CustomType_spec = {\n" +" ...\n" +" .basicsize = sizeof(CustomObject),\n" +" ...\n" +"};" + +#: ../../howto/abi3t-migration.rst:563 +msgid "" +"Most likely, all your class definitions, *and* all code that accesses your " +"classes' data, will need to be rewritten. This will probably be the biggest " +"change you need to support ``abi3t``." +msgstr "" + +#: ../../howto/abi3t-migration.rst:567 +msgid "" +"For each such type, instead of defining a ``struct`` for the entire " +"instance, define one with only the “additional” fields -- ones specific to " +"your class, not its superclasses:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:571 +msgid "" +"typedef struct {\n" +" int my_data;\n" +"} CustomObjectData;" +msgstr "" +"typedef struct {\n" +" int my_data;\n" +"} CustomObjectData;" + +#: ../../howto/abi3t-migration.rst:578 +msgid "" +"Change the name. Almost all code that uses the struct will need to change " +"(notably, pointers to the new structure cannot be cast to/from " +"``PyObject*``), and changing the name will highlight the usages as compiler " +"errors. (If you use ``typeof``, C++ ``auto``, or similar ways to avoid " +"typing the type name, this won't work. Be extra careful, and consider " +"running tools to detect undefined behavior.)" +msgstr "" + +#: ../../howto/abi3t-migration.rst:586 +msgid "" +"Then, to create the class, use *negative* ``basicsize`` to indicate “extra” " +"storage space rather than *total* instance size:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:589 +msgid "" +"static PyType_Spec CustomType_spec = {\n" +" ...\n" +" .basicsize = -sizeof(CustomObjectData), /* note the minus sign */\n" +" ...\n" +"};" +msgstr "" +"static PyType_Spec CustomType_spec = {\n" +" ...\n" +" .basicsize = -sizeof(CustomObjectData), /* 注意負號 */\n" +" ...\n" +"};" + +#: ../../howto/abi3t-migration.rst:598 +msgid "" +"If you use :c:macro:`Py_tp_members`, set the :c:macro:`Py_RELATIVE_OFFSET` " +"flag on each member and specify the :c:member:`~PyMemberDef.offset` relative " +"to your new struct." +msgstr "" + +#: ../../howto/abi3t-migration.rst:604 +msgid "Custom type data access" +msgstr "" + +#: ../../howto/abi3t-migration.rst:606 +msgid "" +"Then comes the hard part: in all code that needs to access this struct, you " +"will need an additional :c:func:`PyObject_GetTypeData` call to retrieve a " +"``CustomObjectData *`` pointer from ``PyObject *``:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:610 +msgid "" +"PyObject *obj = ...;\n" +"CustomObjectData *data = PyObject_GetTypeData(obj, cls);" +msgstr "" +"PyObject *obj = ...;\n" +"CustomObjectData *data = PyObject_GetTypeData(obj, cls);" + +#: ../../howto/abi3t-migration.rst:616 +msgid "" +"Note that this call requires the *type object* for your class (``cls``)." +msgstr "" + +#: ../../howto/abi3t-migration.rst:618 +msgid "" +"If your class is not subclassable (that is, it does not use the :c:macro:" +"`Py_TPFLAGS_BASETYPE` flag), ``cls`` will be ``Py_TYPE(obj)``. Otherwise, " +"**DO NOT USE** ``Py_TYPE`` with :c:func:`!PyObject_GetTypeData`: it might " +"return memory reserved to an unrelated subclass! For example, if a user " +"makes a subclass like this:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:624 +msgid "" +"class Sub(YourCustomClass):\n" +" __slots__ = ('a', 'b')" +msgstr "" +"class Sub(YourCustomClass):\n" +" __slots__ = ('a', 'b')" + +#: ../../howto/abi3t-migration.rst:629 +msgid "" +"then ``Py_TYPE(obj)`` is ``Sub``, and the underlying memory may look like " +"this:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:632 +msgid "" +"╭─ PyObject *obj\n" +"│ ╭─ the pointer you want\n" +"│ │ ╭─ PyObject_GetTypeData(obj, " +"Py_TYPE(obj))\n" +"▼ ▼ ▼\n" +"┌──────────┬───┬────────────────┬───┬─────────────┬───┬─────────────┐\n" +"│ PyObject │...│ CustomTypeData │...│ PyObject *a │...│ PyObject *b │\n" +"└──────────┴───┴────────────────┴───┴─────────────┴───┴─────────────┘" +msgstr "" +"╭─ PyObject *obj\n" +"│ ╭─ the pointer you want\n" +"│ │ ╭─ PyObject_GetTypeData(obj, " +"Py_TYPE(obj))\n" +"▼ ▼ ▼\n" +"┌──────────┬───┬────────────────┬───┬─────────────┬───┬─────────────┐\n" +"│ PyObject │...│ CustomTypeData │...│ PyObject *a │...│ PyObject *b │\n" +"└──────────┴───┴────────────────┴───┴─────────────┴───┴─────────────┘" + +#: ../../howto/abi3t-migration.rst:642 +msgid "" +"(Ellipses indicate possible padding. Note that this memory layout is not " +"guaranteed: future versions of Python may add different padding or even " +"switch the order of the structures.)" +msgstr "" + +#: ../../howto/abi3t-migration.rst:646 +msgid "There are two main ways to get the right class:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:648 +msgid "" +"In instance methods, your implementation may use the :c:type:`PyCMethod` " +"signature (and the :c:macro:`METH_METHOD` bit in :c:member:`PyMethodDef." +"ml_flags`), and get the class as the ``defining_class`` argument." +msgstr "" + +#: ../../howto/abi3t-migration.rst:652 +msgid "" +"Otherwise, give your class a unique static token using the :c:macro:" +"`Py_tp_token` slot, and use:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:655 +msgid "" +"PyTypeObject cls;\n" +"if (PyType_GetBaseByToken(Py_TYPE(obj), my_tp_token, &cls) < 0) {\n" +" /* handle error */\n" +"}\n" +"CustomObjectData *data = PyObject_GetTypeData(obj, cls);" +msgstr "" +"PyTypeObject cls;\n" +"if (PyType_GetBaseByToken(Py_TYPE(obj), my_tp_token, &cls) < 0) {\n" +" /* 處理錯誤 */\n" +"}\n" +"CustomObjectData *data = PyObject_GetTypeData(obj, cls);" + +#: ../../howto/abi3t-migration.rst:664 +msgid "" +"Type tokens work similarly to module tokens covered :ref:`earlier in this " +"guide `." +msgstr "" + +#: ../../howto/abi3t-migration.rst:670 +msgid "Avoid build-time conditionals" +msgstr "" + +#: ../../howto/abi3t-migration.rst:672 +msgid "" +"Check your code for API that identifies the version of Python used to " +"*build* your extension. This no longer corresponds to the Python your " +"extension runs on, so code that uses this information often needs changing. " +"The macros to check for are:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:678 +msgid "" +":c:macro:`PY_VERSION_HEX`, :c:macro:`PY_MAJOR_VERSION`, :c:macro:" +"`PY_MINOR_VERSION`:" +msgstr ":c:macro:`PY_VERSION_HEX`, :c:macro:`PY_MAJOR_VERSION`, :c:macro:`PY_MINOR_VERSION`:" + +#: ../../howto/abi3t-migration.rst:681 +msgid "to get the run-time version, use :c:data:`Py_Version`;" +msgstr "" + +#: ../../howto/abi3t-migration.rst:682 +msgid "" +"to determine what C API is available, use :c:macro:`Py_TARGET_ABI3T`. This " +"macro is set to the minimum supported version." +msgstr "" + +#: ../../howto/abi3t-migration.rst:685 +msgid "" +":c:macro:`Py_GIL_DISABLED`: under ``abi3t``, this macro is always defined. " +"Code that works with free-threaded Python *should* also work with the GIL " +"enabled (since the GIL can be enabled at run time), and usually *does* " +"(unless it, for some reason, requires more than one :term:`attached thread " +"state ` at one time)." +msgstr "" + +#: ../../howto/abi3t-migration.rst:693 +msgid "Further code changes" +msgstr "" + +#: ../../howto/abi3t-migration.rst:695 +msgid "" +"If you are still left with compiler errors or warnings, find a way to fix " +"them. Alas, this guide is limited, and cannot cover all possible code " +"changes extensions may need." +msgstr "" + +#: ../../howto/abi3t-migration.rst:699 +msgid "" +"If you find a problem that other extension authors might run into, consider :" +"ref:`reporting an issue ` (or sending a pull " +"request) for this guide." +msgstr "" + +#: ../../howto/abi3t-migration.rst:703 +msgid "" +"It is possible your issue cannot be fixed for the current version of " +"``abi3t``. In that case, reporting it may help it get prioritized for the " +"next version of CPython." +msgstr "" + +#: ../../howto/abi3t-migration.rst:711 +msgid "Tagging and distribution" +msgstr "" + +#: ../../howto/abi3t-migration.rst:713 +msgid "" +"If you are using a build tool with ``abi3t`` support, your extension is " +"ready, but you might want to check that it was built correctly." +msgstr "" + +#: ../../howto/abi3t-migration.rst:716 +msgid "Extensions built with ``abi3t`` should have the following extension:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:718 +msgid "On Windows: ``.pyd`` (like any other extension);" +msgstr "" + +#: ../../howto/abi3t-migration.rst:719 +msgid "" +"Linux, macOS, and other systems that use the ``.so`` suffix: ``.abi3t.so`` " +"(**not** ``.cpython-315t.so`` or ``.abi3.so``). Note that both free-threaded " +"and non-free-threaded builds will load ``.abi3t.so`` extensions;" +msgstr "" + +#: ../../howto/abi3t-migration.rst:723 +msgid "Other systems: consult your distributor, and perhaps update this guide." +msgstr "" + +#: ../../howto/abi3t-migration.rst:725 +msgid "If you distribute the extension as a *wheel*, use the following tags:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:727 +msgid "" +"Python tag: :samp:`cp3{XX}`, where *XX* is the minimum Python version the " +"extension is built for. (For example, ``cp315`` if you set " +"``Py_TARGET_ABI3T`` to ``0x30f0000``. See :ref:`abi3-compiling` for more " +"values.)" +msgstr "" + +#: ../../howto/abi3t-migration.rst:731 +msgid "" +"ABI tag: ``abi3.abi3t``. This is a *compressed tag set* that indicates " +"support for both non-free-threaded and free-threaded builds." +msgstr "" + +#: ../../howto/abi3t-migration.rst:734 +msgid "For example, the wheel filename may look like this:" +msgstr "" + +#: ../../howto/abi3t-migration.rst:736 +msgid "myproject-1.0-cp315-abi3.abi3t-macosx_11_0_arm64.whl" +msgstr "myproject-1.0-cp315-abi3.abi3t-macosx_11_0_arm64.whl" + +#: ../../howto/abi3t-migration.rst:740 +msgid "" +"`Platform Compatibility Tags `__ in the PyPA package " +"distribution metadata." +msgstr "" + +#: ../../howto/abi3t-migration.rst:742 +msgid "If the filename or tags are incorrect, fix them." +msgstr "" + +#: ../../howto/abi3t-migration.rst:746 +msgid "Testing" +msgstr "" + +#: ../../howto/abi3t-migration.rst:748 +msgid "" +"Note that when you build an extension compatible with multiple versions of " +"CPython, you should always *test* it with each version it supports (for " +"example, 3.15, 3.16, and so on). The Stable ABI only guarantees *ABI* " +"compatibility; there may also be behavior changes -- both intentional ones " +"(covered by :pep:`387`) and bugs." +msgstr "" + +#: ../../howto/abi3t-migration.rst:754 +msgid "" +"Be sure to run tests on both free-threaded and non-free-threaded builds of " +"CPython." +msgstr "" + +#: ../../howto/abi3t-migration.rst:757 +msgid "If they pass, congratulations! You have an ``abi3t`` extension." +msgstr "" diff --git a/howto/annotations.po b/howto/annotations.po index 452fa55ecfb..b39a07d7a52 100644 --- a/howto/annotations.po +++ b/howto/annotations.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2026-09-12 20:49+0800\n" "Last-Translator: dy1012 \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,19 +21,11 @@ msgstr "" msgid "Annotations Best Practices" msgstr "註釋 (annotation) 最佳實踐" -#: ../../howto/annotations.rst:0 -msgid "author" -msgstr "作者" - -#: ../../howto/annotations.rst:7 -msgid "Larry Hastings" -msgstr "Larry Hastings" - #: ../../howto/annotations.rst:-1 msgid "Abstract" msgstr "摘要" -#: ../../howto/annotations.rst:11 +#: ../../howto/annotations.rst:9 msgid "" "This document is designed to encapsulate the best practices for working with " "annotations dicts. If you write Python code that examines " @@ -44,7 +36,7 @@ msgstr "" "果你寫 Python 程式碼並在調查 Python 物件上的 ``__annotations__`` ,我們鼓勵你" "遵循下面描述的準則。" -#: ../../howto/annotations.rst:16 +#: ../../howto/annotations.rst:14 msgid "" "The document is organized into four sections: best practices for accessing " "the annotations of an object in Python versions 3.10 and newer, best " @@ -56,7 +48,7 @@ msgstr "" "Python 3.9 及更早版本中存取物件註釋的最佳實踐、適用於任何Python 版本 " "``__annotations__`` 的最佳實踐,以及 ``__annotations__`` 的奇異之處。" -#: ../../howto/annotations.rst:26 +#: ../../howto/annotations.rst:24 msgid "" "Note that this document is specifically about working with " "``__annotations__``, not uses *for* annotations. If you're looking for " @@ -67,11 +59,11 @@ msgstr "" "釋。如果你正在尋找如何在你的程式碼中使用「型別提示 (type hint)」的資訊,請查" "閱模組 (module) :mod:`typing`。" -#: ../../howto/annotations.rst:33 +#: ../../howto/annotations.rst:31 msgid "Accessing The Annotations Dict Of An Object In Python 3.10 And Newer" msgstr "在 Python 3.10 及更高版本中存取物件的註釋字典" -#: ../../howto/annotations.rst:35 +#: ../../howto/annotations.rst:33 msgid "" "Python 3.10 adds a new function to the standard " "library: :func:`inspect.get_annotations`. In Python versions 3.10 through " @@ -83,7 +75,7 @@ msgstr "" "在 Python 3.10 到 3.13,呼叫此函式是存取任何支援註釋的物件的註釋字典的最佳實" "踐。此函式也可以為你「取消字串化 (un-stringize)」字串化註釋。" -#: ../../howto/annotations.rst:42 +#: ../../howto/annotations.rst:40 msgid "" "In Python 3.14, there is a new :mod:`annotationlib` module with " "functionality for working with annotations. This includes " @@ -94,7 +86,7 @@ msgstr "" "功能。其中包含一個名為 :func:`annotationlib.get_annotations` 的函式,該函式已" "取代 :func:`inspect.get_annotations`。" -#: ../../howto/annotations.rst:47 +#: ../../howto/annotations.rst:45 msgid "" "If for some reason :func:`inspect.get_annotations` isn't viable for your use " "case, you may access the ``__annotations__`` data member manually. Best " @@ -110,7 +102,7 @@ msgstr "" "類別 (class) 和模組。如果你確定正在檢查的物件是這三個\\ *特定*\\ 物件之一,你" "可以簡單地使用 ``o.__annotations__`` 來取得物件的註釋字典。" -#: ../../howto/annotations.rst:57 +#: ../../howto/annotations.rst:55 msgid "" "However, other types of callables--for example, callables created " "by :func:`functools.partial`--may not have an ``__annotations__`` attribute " @@ -125,7 +117,7 @@ msgstr "" "用三個參數呼叫 :func:`getattr`,例如 ``getattr(o, '__annotations__', " "None)``。" -#: ../../howto/annotations.rst:65 +#: ../../howto/annotations.rst:63 msgid "" "Before Python 3.10, accessing ``__annotations__`` on a class that defines no " "annotations but that has a parent class with annotations would return the " @@ -136,11 +128,11 @@ msgstr "" "``__annotations__`` 將傳回父類別的 ``__annotations__``。在 Python 3.10 及更高" "版本中,子類別的註釋將會是一個空字典。" -#: ../../howto/annotations.rst:73 +#: ../../howto/annotations.rst:71 msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older" msgstr "在 Python 3.9 及更早版本中存取物件的註釋字典" -#: ../../howto/annotations.rst:75 +#: ../../howto/annotations.rst:73 msgid "" "In Python 3.9 and older, accessing the annotations dict of an object is much " "more complicated than in newer versions. The problem is a design flaw in " @@ -149,7 +141,7 @@ msgstr "" "在 Python 3.9 及更早版本中,存取物件的註釋字典比新版本複雜得多。問題出在於這" "些舊版 Python 中有設計缺陷,特別是與類別註釋有關的設計缺陷。" -#: ../../howto/annotations.rst:80 +#: ../../howto/annotations.rst:78 msgid "" "Best practice for accessing the annotations dict of other objects--" "functions, other callables, and modules--is the same as best practice for " @@ -161,7 +153,7 @@ msgstr "" "佳實踐相同,假設你沒有呼叫 :func:`inspect.get_annotations`:你應該使用三個:" "參數 :func:`getattr` 來存取物件的 ``__annotations__`` 屬性。" -#: ../../howto/annotations.rst:87 +#: ../../howto/annotations.rst:85 msgid "" "Unfortunately, this isn't best practice for classes. The problem is that, " "since ``__annotations__`` is optional on classes, and because classes can " @@ -174,7 +166,7 @@ msgstr "" "類別的 ``__annotations__`` 屬性可能會無意中回傳\\ *基底類別的註釋字典。*\\ 舉" "例來說: ::" -#: ../../howto/annotations.rst:94 +#: ../../howto/annotations.rst:92 msgid "" "class Base:\n" " a: int = 3\n" @@ -194,11 +186,11 @@ msgstr "" "\n" "print(Derived.__annotations__)" -#: ../../howto/annotations.rst:103 +#: ../../howto/annotations.rst:101 msgid "This will print the annotations dict from ``Base``, not ``Derived``." msgstr "這將印出 (print) 來自 ``Base`` 的註釋字典,而不是 ``Derived``。" -#: ../../howto/annotations.rst:106 +#: ../../howto/annotations.rst:104 msgid "" "Your code will have to have a separate code path if the object you're " "examining is a class (``isinstance(o, type)``). In that case, best practice " @@ -213,7 +205,7 @@ msgstr "" "的 :attr:`~type.__dict__` 字典中。由於類別可能定義了註釋,也可能沒有定義,因" "此最佳實踐是在類別字典上呼叫 :meth:`~dict.get` 方法。" -#: ../../howto/annotations.rst:114 +#: ../../howto/annotations.rst:112 msgid "" "To put it all together, here is some sample code that safely accesses the " "``__annotations__`` attribute on an arbitrary object in Python 3.9 and " @@ -222,7 +214,7 @@ msgstr "" "總而言之,以下是一些範例程式碼,可以安全地存取 Python 3.9 及先前版本中任意物" "件上的 ``__annotations__`` 屬性:" -#: ../../howto/annotations.rst:118 +#: ../../howto/annotations.rst:116 msgid "" "if isinstance(o, type):\n" " ann = o.__dict__.get('__annotations__', None)\n" @@ -234,7 +226,7 @@ msgstr "" "else:\n" " ann = getattr(o, '__annotations__', None)" -#: ../../howto/annotations.rst:123 +#: ../../howto/annotations.rst:121 msgid "" "After running this code, ``ann`` should be either a dictionary or ``None``. " "You're encouraged to double-check the type of ``ann`` " @@ -243,7 +235,7 @@ msgstr "" "運行此程式碼後,``ann`` 應該是字典或 ``None``。我們鼓勵你在進一步檢查之前使" "用 :func:`isinstance` 仔細檢查 ``ann`` 的型別。" -#: ../../howto/annotations.rst:128 +#: ../../howto/annotations.rst:126 msgid "" "Note that some exotic or malformed type objects may not have " "a :attr:`~type.__dict__` attribute, so for extra safety you may also wish to " @@ -253,11 +245,11 @@ msgstr "" "有 :attr:`~type.__dict__` 屬性,因此為了額外的安全,你可能還希望使" "用 :func:`getattr` 來存取 :attr:`!__dict__`。" -#: ../../howto/annotations.rst:134 +#: ../../howto/annotations.rst:132 msgid "Manually Un-Stringizing Stringized Annotations" msgstr "手動取消字串化註釋" -#: ../../howto/annotations.rst:136 +#: ../../howto/annotations.rst:134 msgid "" "In situations where some annotations may be \"stringized\", and you wish to " "evaluate those strings to produce the Python values they represent, it " @@ -267,7 +259,7 @@ msgstr "" "在某些註釋可能被「字串化」的情況下,並且你希望評估這些字串以產生它們表示的 " "Python 值,最好呼叫 :func:`inspect.get_annotations` 來為你完成這項工作。" -#: ../../howto/annotations.rst:142 +#: ../../howto/annotations.rst:140 msgid "" "If you're using Python 3.9 or older, or if for some reason you can't " "use :func:`inspect.get_annotations`, you'll need to duplicate its logic. " @@ -279,13 +271,13 @@ msgstr "" "用 :func:`inspect.get_annotations`,則需要複製其邏輯。我們鼓勵你檢查目前 " "Python 版本中 :func:`inspect.get_annotations` 的實作並遵循類似的方法。" -#: ../../howto/annotations.rst:148 +#: ../../howto/annotations.rst:146 msgid "" "In a nutshell, if you wish to evaluate a stringized annotation on an " "arbitrary object ``o``:" msgstr "簡而言之,如果你希望評估任意物件 ``o`` 上的字串化註釋: ::" -#: ../../howto/annotations.rst:151 +#: ../../howto/annotations.rst:149 msgid "" "If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when " "calling :func:`eval`." @@ -293,7 +285,7 @@ msgstr "" "如果 ``o`` 是一個模組,則在呼叫 :func:`eval` 時使用 ``o.__dict__`` 作為\\ ``" "全域變數``。" -#: ../../howto/annotations.rst:153 +#: ../../howto/annotations.rst:151 msgid "" "If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the " "``globals``, and ``dict(vars(o))`` as the ``locals``, when " @@ -303,7 +295,7 @@ msgstr "" "``sys.modules[o.__module__].__dict__`` 作為\\ ``全域變數``,使用 " "``dict(vars(o))`` 作為\\ ``區域變數``。" -#: ../../howto/annotations.rst:156 +#: ../../howto/annotations.rst:154 msgid "" "If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :deco:" "`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by " @@ -314,7 +306,7 @@ msgstr "" "或 :func:`functools.partial` 包裝的 callable,請依據需求,透過存取 " "``o.__wrapped__`` 或 ``o.func`` 來疊代解開它,直到找到根解包函式。" -#: ../../howto/annotations.rst:160 +#: ../../howto/annotations.rst:158 msgid "" "If ``o`` is a callable (but not a class), use :attr:`o.__globals__ " "` as the globals when calling :func:`eval`." @@ -322,7 +314,7 @@ msgstr "" "如果 ``o`` 是 callable(但不是類別),則在呼叫 :func:`eval` 時使" "用 :attr:`o.__globals__ ` 作為全域變數。" -#: ../../howto/annotations.rst:164 +#: ../../howto/annotations.rst:162 msgid "" "However, not all string values used as annotations can be successfully " "turned into Python values by :func:`eval`. String values could theoretically " @@ -334,21 +326,21 @@ msgstr "" "理論上,字串值可以包含任何有效的字串,並且在實踐中,型別提示存在有效的用例," "需要使用特定「無法」評估的字串值進行註釋。例如: ::" -#: ../../howto/annotations.rst:171 +#: ../../howto/annotations.rst:169 msgid "" ":pep:`604` union types using ``|``, before support for this was added to " "Python 3.10." msgstr "" "在 Python 3.10 支援 :pep:`604` 聯合型別 (union type) ``|`` 之前使用它。" -#: ../../howto/annotations.rst:173 +#: ../../howto/annotations.rst:171 msgid "" "Definitions that aren't needed at runtime, only imported " "when :const:`typing.TYPE_CHECKING` is true." msgstr "" "Runtime 中不需要的定義,僅在 :const:`typing.TYPE_CHECKING` 為 true 時匯入。" -#: ../../howto/annotations.rst:176 +#: ../../howto/annotations.rst:174 msgid "" "If :func:`eval` attempts to evaluate such values, it will fail and raise an " "exception. So, when designing a library API that works with annotations, " @@ -358,11 +350,11 @@ msgstr "" "如果 :func:`eval` 嘗試計算這類型的值,它將失敗並引發例外。因此,在設計使用註" "釋的函式庫 API 時,建議僅在呼叫者 (caller) 明確請求時嘗試評估字串值。" -#: ../../howto/annotations.rst:184 +#: ../../howto/annotations.rst:182 msgid "Best Practices For ``__annotations__`` In Any Python Version" msgstr "任何 Python 版本中 ``__annotations__`` 的最佳實踐" -#: ../../howto/annotations.rst:186 +#: ../../howto/annotations.rst:184 msgid "" "You should avoid assigning to the ``__annotations__`` member of objects " "directly. Let Python manage setting ``__annotations__``." @@ -370,7 +362,7 @@ msgstr "" "你應該避免直接指派給物件的 ``__annotations__`` 成員。讓 Python 管理設定 " "``__annotations__``。" -#: ../../howto/annotations.rst:189 +#: ../../howto/annotations.rst:187 msgid "" "If you do assign directly to the ``__annotations__`` member of an object, " "you should always set it to a ``dict`` object." @@ -378,7 +370,7 @@ msgstr "" "如果你直接指派給物件的 ``__annotations__`` 成員,則應始終將其設為 ``dict`` 物" "件。" -#: ../../howto/annotations.rst:192 +#: ../../howto/annotations.rst:190 msgid "" "You should avoid accessing ``__annotations__`` directly on any object. " "Instead, use :func:`annotationlib.get_annotations` (Python 3.14+) " @@ -388,7 +380,7 @@ msgstr "" "用 :func:`annotationlib.get_annotations` (Python 3.14+) " "或 :func:`inspect.get_annotations` (Python 3.10+)。" -#: ../../howto/annotations.rst:196 +#: ../../howto/annotations.rst:194 msgid "" "If you do directly access the ``__annotations__`` member of an object, you " "should ensure that it's a dictionary before attempting to examine its " @@ -397,20 +389,20 @@ msgstr "" "如果直接存取物件的 ``__annotations__`` 成員,則應確保它是字典,然後再嘗試檢查" "其內容。" -#: ../../howto/annotations.rst:200 +#: ../../howto/annotations.rst:198 msgid "You should avoid modifying ``__annotations__`` dicts." msgstr "你應該避免修改 ``__annotations__`` 字典。" -#: ../../howto/annotations.rst:202 +#: ../../howto/annotations.rst:200 msgid "" "You should avoid deleting the ``__annotations__`` attribute of an object." msgstr "你應該避免刪除物件的 ``__annotations__`` 屬性。" -#: ../../howto/annotations.rst:207 +#: ../../howto/annotations.rst:205 msgid "``__annotations__`` Quirks" msgstr "``__annotations__`` 奇異之處" -#: ../../howto/annotations.rst:209 +#: ../../howto/annotations.rst:207 msgid "" "In all versions of Python 3, function objects lazy-create an annotations " "dict if no annotations are defined on that object. You can delete the " @@ -428,13 +420,13 @@ msgstr "" "上的註釋將拋出 ``AttributeError``;連續兩次使用 ``del fn.__annotations__`` 保" "證總是拋出 ``AttributeError`` 。" -#: ../../howto/annotations.rst:219 +#: ../../howto/annotations.rst:217 msgid "" "Everything in the above paragraph also applies to class and module objects " "in Python 3.10 and newer." msgstr "上一段的所有內容也適用於 Python 3.10 及更高版本中的類別和模組物件。" -#: ../../howto/annotations.rst:222 +#: ../../howto/annotations.rst:220 msgid "" "In all versions of Python 3, you can set ``__annotations__`` on a function " "object to ``None``. However, subsequently accessing the annotations on that " @@ -450,7 +442,7 @@ msgstr "" "\\ *並非如此*\\;這些物件允許將 ``__annotations__`` 設定為任何 Python 值,並" "且將保留設定的任何值。" -#: ../../howto/annotations.rst:230 +#: ../../howto/annotations.rst:228 msgid "" "If Python stringizes your annotations for you (using ``from __future__ " "import annotations``), and you specify a string as an annotation, the string " @@ -461,7 +453,7 @@ msgstr "" "annotations``),並且你指定一個字串作為註釋,則該字串本身將被引用。實際上,註" "釋被引用了\\ *兩次。*\\ 例如: ::" -#: ../../howto/annotations.rst:236 +#: ../../howto/annotations.rst:234 msgid "" "from __future__ import annotations\n" "def foo(a: \"str\"): pass\n" @@ -473,7 +465,7 @@ msgstr "" "\n" "print(foo.__annotations__)" -#: ../../howto/annotations.rst:241 +#: ../../howto/annotations.rst:239 msgid "" "This prints ``{'a': \"'str'\"}``. This shouldn't really be considered a " "\"quirk\"; it's mentioned here simply because it might be surprising." @@ -481,7 +473,7 @@ msgstr "" "這會印出 ``{'a': \"'str'\"}``。這不應該被認為是一個「奇異的事」,他在這裡被簡" "單提及,因為他可能會讓人意想不到。" -#: ../../howto/annotations.rst:244 +#: ../../howto/annotations.rst:242 msgid "" "If you use a class with a custom metaclass and access ``__annotations__`` on " "the class, you may observe unexpected behavior; see :pep:`749 <749#pep749-" @@ -499,7 +491,7 @@ msgstr "" "可以存取類別的 :attr:`~type.__dict__` 來避免這些問題。(例如:" "``cls.__dict__.get('__annotations__', None)`` )。" -#: ../../howto/annotations.rst:253 +#: ../../howto/annotations.rst:251 msgid "" "In some versions of Python, instances of classes may have an " "``__annotations__`` attribute. However, this is not supported functionality. " @@ -511,3 +503,9 @@ msgstr "" "受支援的功能。如果你需要取得實例的註釋,可以用 :func:`type` 來存取實例的類別" "(例如在 Python 3.14+ 中使用 " "``annotationlib.get_annotations(type(myinstance))`` )。" + +#~ msgid "author" +#~ msgstr "作者" + +#~ msgid "Larry Hastings" +#~ msgstr "Larry Hastings" diff --git a/howto/argparse.po b/howto/argparse.po index fde89eb929b..b8bfed8ff30 100644 --- a/howto/argparse.po +++ b/howto/argparse.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-29 11:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-12-11 17:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -28,15 +28,7 @@ msgstr "" msgid "Argparse Tutorial" msgstr "Argparse 教學" -#: ../../howto/argparse.rst:0 -msgid "author" -msgstr "作者" - -#: ../../howto/argparse.rst:7 -msgid "Tshepang Mbambo" -msgstr "Tshepang Mbambo" - -#: ../../howto/argparse.rst:11 +#: ../../howto/argparse.rst:9 msgid "" "This tutorial is intended to be a gentle introduction to :mod:`argparse`, " "the recommended command-line parsing module in the Python standard library." @@ -44,7 +36,7 @@ msgstr "" "本教學旨在簡要介紹 :mod:`argparse` 這個 Python 標準函式庫中推薦的命令列剖析模" "組。" -#: ../../howto/argparse.rst:16 +#: ../../howto/argparse.rst:14 msgid "" "The standard library includes two other libraries directly related to " "command-line parameter processing: the lower level :mod:`optparse` module " @@ -64,18 +56,18 @@ msgstr "" "這些模組,但 ``argparse`` 的許多核心概念最初來自於 ``optparse``,因此本教學的" "某些部分也適用於 ``optparse`` 使用者。" -#: ../../howto/argparse.rst:29 +#: ../../howto/argparse.rst:27 msgid "Concepts" msgstr "概念" -#: ../../howto/argparse.rst:31 +#: ../../howto/argparse.rst:29 msgid "" "Let's show the sort of functionality that we are going to explore in this " "introductory tutorial by making use of the :command:`ls` command:" msgstr "" "讓我們透過使用 :command:`ls` 指令來展示我們將在本介紹教學中探索的功能類型:" -#: ../../howto/argparse.rst:34 +#: ../../howto/argparse.rst:32 msgid "" "$ ls\n" "cpython devguide prog.py pypy rm-unused-function.patch\n" @@ -111,11 +103,11 @@ msgstr "" "Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n" "..." -#: ../../howto/argparse.rst:53 +#: ../../howto/argparse.rst:51 msgid "A few concepts we can learn from the four commands:" msgstr "我們可以從這四個命令中學到一些概念:" -#: ../../howto/argparse.rst:55 +#: ../../howto/argparse.rst:53 msgid "" "The :command:`ls` command is useful when run without any options at all. It " "defaults to displaying the contents of the current directory." @@ -123,7 +115,7 @@ msgstr "" ":command:`ls` 命令即便在沒有任何選項的情況下執行仍非常有用。它預設顯示目前目" "錄的內容。" -#: ../../howto/argparse.rst:58 +#: ../../howto/argparse.rst:56 msgid "" "If we want beyond what it provides by default, we tell it a bit more. In " "this case, we want it to display a different directory, ``pypy``. What we " @@ -140,7 +132,7 @@ msgstr "" "command:`cp` 這樣的指令更相關,其最基本的用法是 ``cp SRC DEST``。第一個是\\ *" "你想要複製的位置*,第二個是\\ *你想要複製過去的位置*。" -#: ../../howto/argparse.rst:67 +#: ../../howto/argparse.rst:65 msgid "" "Now, say we want to change behaviour of the program. In our example, we " "display more info for each file instead of just showing the file names. The " @@ -149,7 +141,7 @@ msgstr "" "現在假設我們想要改變程式的行為。在我們的範例中,我們顯示每個檔案的更多資訊," "而不僅是顯示檔案名稱。在這種情況下,``-l`` 被稱為可選引數。" -#: ../../howto/argparse.rst:71 +#: ../../howto/argparse.rst:69 msgid "" "That's a snippet of the help text. It's very useful in that you can come " "across a program you have never used before, and can figure out how it works " @@ -158,15 +150,15 @@ msgstr "" "這是幫助文字的片段。它非常有用,因為當你遇到以前從未使用過的程式時,只需閱讀" "其幫助文字即可了解它的工作原理。" -#: ../../howto/argparse.rst:77 +#: ../../howto/argparse.rst:75 msgid "The basics" msgstr "基本用法" -#: ../../howto/argparse.rst:79 +#: ../../howto/argparse.rst:77 msgid "Let us start with a very simple example which does (almost) nothing::" msgstr "讓我們從一個非常簡單的例子開始,它(幾乎)什麼都不做: ::" -#: ../../howto/argparse.rst:81 +#: ../../howto/argparse.rst:79 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -176,12 +168,12 @@ msgstr "" "parser = argparse.ArgumentParser()\n" "parser.parse_args()" -#: ../../howto/argparse.rst:85 ../../howto/argparse.rst:193 -#: ../../howto/argparse.rst:214 +#: ../../howto/argparse.rst:83 ../../howto/argparse.rst:191 +#: ../../howto/argparse.rst:212 msgid "Following is a result of running the code:" msgstr "程式碼執行結果如下:" -#: ../../howto/argparse.rst:87 +#: ../../howto/argparse.rst:85 msgid "" "$ python prog.py\n" "$ python prog.py --help\n" @@ -209,18 +201,18 @@ msgstr "" "usage: prog.py [-h]\n" "prog.py: error: unrecognized arguments: foo" -#: ../../howto/argparse.rst:102 ../../howto/argparse.rst:259 -#: ../../howto/argparse.rst:303 +#: ../../howto/argparse.rst:100 ../../howto/argparse.rst:257 +#: ../../howto/argparse.rst:301 msgid "Here is what is happening:" msgstr "這是發生的事情:" -#: ../../howto/argparse.rst:104 +#: ../../howto/argparse.rst:102 msgid "" "Running the script without any options results in nothing displayed to " "stdout. Not so useful." msgstr "執行不帶任何選項的腳本不會在標準輸出中顯示任何內容。不太有用。" -#: ../../howto/argparse.rst:107 +#: ../../howto/argparse.rst:105 msgid "" "The second one starts to display the usefulness of the :mod:`argparse` " "module. We have done almost nothing, but already we get a nice help message." @@ -228,7 +220,7 @@ msgstr "" "第二個開始能夠顯現 :mod:`argparse` 模組的有用之處。我們幾乎什麼也沒做,但我們" "已經收到了一個很好的幫助訊息。" -#: ../../howto/argparse.rst:110 +#: ../../howto/argparse.rst:108 msgid "" "The ``--help`` option, which can also be shortened to ``-h``, is the only " "option we get for free (i.e. no need to specify it). Specifying anything " @@ -239,15 +231,15 @@ msgstr "" "它)。指定任何其他內容都會導致錯誤。但即便如此,我們也還是輕鬆地獲得了有用的" "使用資訊。" -#: ../../howto/argparse.rst:117 +#: ../../howto/argparse.rst:115 msgid "Introducing Positional arguments" msgstr "位置引數的介紹" -#: ../../howto/argparse.rst:119 +#: ../../howto/argparse.rst:117 msgid "An example::" msgstr "例如: ::" -#: ../../howto/argparse.rst:121 +#: ../../howto/argparse.rst:119 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -261,11 +253,11 @@ msgstr "" "args = parser.parse_args()\n" "print(args.echo)" -#: ../../howto/argparse.rst:127 +#: ../../howto/argparse.rst:125 msgid "And running the code:" msgstr "執行這段程式碼:" -#: ../../howto/argparse.rst:129 +#: ../../howto/argparse.rst:127 msgid "" "$ python prog.py\n" "usage: prog.py [-h] echo\n" @@ -295,11 +287,11 @@ msgstr "" "$ python prog.py foo\n" "foo" -#: ../../howto/argparse.rst:145 +#: ../../howto/argparse.rst:143 msgid "Here is what's happening:" msgstr "這是會發生的事情:" -#: ../../howto/argparse.rst:147 +#: ../../howto/argparse.rst:145 msgid "" "We've added the :meth:`~ArgumentParser.add_argument` method, which is what " "we use to specify which command-line options the program is willing to " @@ -309,11 +301,11 @@ msgstr "" "我們新增了 :meth:`~ArgumentParser.add_argument` 方法,我們用它來指定程式願意" "接受哪些命令列選項。在本例中,我將其命名為 ``echo``,以便與其功能一致。" -#: ../../howto/argparse.rst:151 +#: ../../howto/argparse.rst:149 msgid "Calling our program now requires us to specify an option." msgstr "現在呼叫我們的程式時需要指定一個選項。" -#: ../../howto/argparse.rst:153 +#: ../../howto/argparse.rst:151 msgid "" "The :meth:`~ArgumentParser.parse_args` method actually returns some data " "from the options specified, in this case, ``echo``." @@ -321,7 +313,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 方法實際上從指定的選項中回傳一些資料,在本" "例中為 ``echo``。" -#: ../../howto/argparse.rst:156 +#: ../../howto/argparse.rst:154 msgid "" "The variable is some form of 'magic' that :mod:`argparse` performs for free " "(i.e. no need to specify which variable that value is stored in). You will " @@ -331,7 +323,7 @@ msgstr "" "該變數是某種形式的「魔法」,:mod:`argparse` 可以自由執行(即無需指定該值儲存" "在哪個變數中)。你還會注意到,它的名稱與提供給方法 ``echo`` 的字串引數相符。" -#: ../../howto/argparse.rst:161 +#: ../../howto/argparse.rst:159 msgid "" "Note however that, although the help display looks nice and all, it " "currently is not as helpful as it can be. For example we see that we got " @@ -343,7 +335,7 @@ msgstr "" "看到 ``echo`` 作為位置引數,但除了猜測或閱讀原始程式碼之外,我們不知道它的作" "用。那麼,我們來讓它變得更有用一點: ::" -#: ../../howto/argparse.rst:166 +#: ../../howto/argparse.rst:164 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -357,11 +349,11 @@ msgstr "" "args = parser.parse_args()\n" "print(args.echo)" -#: ../../howto/argparse.rst:172 +#: ../../howto/argparse.rst:170 msgid "And we get:" msgstr "然後我們得到:" -#: ../../howto/argparse.rst:174 +#: ../../howto/argparse.rst:172 msgid "" "$ python prog.py -h\n" "usage: prog.py [-h] echo\n" @@ -381,11 +373,11 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../howto/argparse.rst:185 +#: ../../howto/argparse.rst:183 msgid "Now, how about doing something even more useful::" msgstr "現在來做一些更有用處的事情: ::" -#: ../../howto/argparse.rst:187 +#: ../../howto/argparse.rst:185 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -401,7 +393,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args.square**2)" -#: ../../howto/argparse.rst:195 +#: ../../howto/argparse.rst:193 msgid "" "$ python prog.py 4\n" "Traceback (most recent call last):\n" @@ -415,7 +407,7 @@ msgstr "" " print(args.square**2)\n" "TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'" -#: ../../howto/argparse.rst:203 +#: ../../howto/argparse.rst:201 msgid "" "That didn't go so well. That's because :mod:`argparse` treats the options we " "give it as strings, unless we tell it otherwise. So, let's tell :mod:" @@ -424,7 +416,7 @@ msgstr "" "進展不太順利。這是因為,除非我們另有說明,:mod:`argparse` 會將我們給它的選項" "視為字串。因此,讓我們告訴 :mod:`argparse` 將該輸入視為整數: ::" -#: ../../howto/argparse.rst:207 +#: ../../howto/argparse.rst:205 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -442,7 +434,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args.square**2)" -#: ../../howto/argparse.rst:216 +#: ../../howto/argparse.rst:214 msgid "" "$ python prog.py 4\n" "16\n" @@ -456,23 +448,23 @@ msgstr "" "usage: prog.py [-h] square\n" "prog.py: error: argument square: invalid int value: 'four'" -#: ../../howto/argparse.rst:224 +#: ../../howto/argparse.rst:222 msgid "" "That went well. The program now even helpfully quits on bad illegal input " "before proceeding." msgstr "順利進展。現在該程式甚至可以在繼續操作之前因錯誤的非法輸入而退出。" -#: ../../howto/argparse.rst:229 +#: ../../howto/argparse.rst:227 msgid "Introducing Optional arguments" msgstr "可選引數的介紹" -#: ../../howto/argparse.rst:231 +#: ../../howto/argparse.rst:229 msgid "" "So far we have been playing with positional arguments. Let us have a look on " "how to add optional ones::" msgstr "到目前為止,我們一直在討論位置引數。我們來看看如何新增可選引數: ::" -#: ../../howto/argparse.rst:234 +#: ../../howto/argparse.rst:232 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -488,12 +480,12 @@ msgstr "" "if args.verbosity:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:241 ../../howto/argparse.rst:287 -#: ../../howto/argparse.rst:403 ../../howto/argparse.rst:437 +#: ../../howto/argparse.rst:239 ../../howto/argparse.rst:285 +#: ../../howto/argparse.rst:401 ../../howto/argparse.rst:435 msgid "And the output:" msgstr "接者是結果:" -#: ../../howto/argparse.rst:243 +#: ../../howto/argparse.rst:241 msgid "" "$ python prog.py --verbosity 1\n" "verbosity turned on\n" @@ -523,7 +515,7 @@ msgstr "" "usage: prog.py [-h] [--verbosity VERBOSITY]\n" "prog.py: error: argument --verbosity: expected one argument" -#: ../../howto/argparse.rst:261 +#: ../../howto/argparse.rst:259 msgid "" "The program is written so as to display something when ``--verbosity`` is " "specified and display nothing when not." @@ -531,7 +523,7 @@ msgstr "" "程式被編寫為在指定 ``--verbosity`` 時顯示一些內容,並在未指定時不顯示任何內" "容。" -#: ../../howto/argparse.rst:264 +#: ../../howto/argparse.rst:262 msgid "" "To show that the option is actually optional, there is no error when running " "the program without it. Note that by default, if an optional argument isn't " @@ -543,17 +535,17 @@ msgstr "" "情況下,如果未使用可選引數,則相關變數(在本例中為 ``args.verbosity``)將被賦" "予 ``None`` 作為值,這就是它未能通過 :keyword:`if` 陳述式真值測試的原因。" -#: ../../howto/argparse.rst:270 +#: ../../howto/argparse.rst:268 msgid "The help message is a bit different." msgstr "幫助訊息有點不同。" -#: ../../howto/argparse.rst:272 +#: ../../howto/argparse.rst:270 msgid "" "When using the ``--verbosity`` option, one must also specify some value, any " "value." msgstr "當使用 ``--verbosity`` 選項時必須要指定一些值,任何值都可以。" -#: ../../howto/argparse.rst:275 +#: ../../howto/argparse.rst:273 msgid "" "The above example accepts arbitrary integer values for ``--verbosity``, but " "for our simple program, only two values are actually useful, ``True`` or " @@ -562,7 +554,7 @@ msgstr "" "在上面的例子中,``--verbosity`` 接受任意的整數,但對我們的程式來說只接受兩個" "輸入值, ``True`` 或 ``False``。所以我們來修改一下程式碼使其符合: ::" -#: ../../howto/argparse.rst:279 +#: ../../howto/argparse.rst:277 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -580,7 +572,7 @@ msgstr "" "if args.verbose:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:289 +#: ../../howto/argparse.rst:287 msgid "" "$ python prog.py --verbose\n" "verbosity turned on\n" @@ -606,7 +598,7 @@ msgstr "" " -h, --help show this help message and exit\n" " --verbose increase output verbosity" -#: ../../howto/argparse.rst:305 +#: ../../howto/argparse.rst:303 msgid "" "The option is now more of a flag than something that requires a value. We " "even changed the name of the option to match that idea. Note that we now " @@ -619,21 +611,21 @@ msgstr "" "``\"store_true\"``。這意味著,如果指定了該選項,則將值 ``True`` 指派給 " "``args.verbose``。不指定它代表為 ``False``。" -#: ../../howto/argparse.rst:312 +#: ../../howto/argparse.rst:310 msgid "" "It complains when you specify a value, in true spirit of what flags actually " "are." msgstr "當你指定一個值時,它會本著旗標的實際精神來抱怨。" -#: ../../howto/argparse.rst:315 +#: ../../howto/argparse.rst:313 msgid "Notice the different help text." msgstr "請注意不同的幫助文字。" -#: ../../howto/argparse.rst:319 +#: ../../howto/argparse.rst:317 msgid "Short options" msgstr "短選項" -#: ../../howto/argparse.rst:321 +#: ../../howto/argparse.rst:319 msgid "" "If you are familiar with command line usage, you will notice that I haven't " "yet touched on the topic of short versions of the options. It's quite " @@ -641,7 +633,7 @@ msgid "" msgstr "" "如果你熟悉命令列用法,你會注意到我尚未提及選項的簡短版本。這很簡單: ::" -#: ../../howto/argparse.rst:325 +#: ../../howto/argparse.rst:323 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -661,11 +653,11 @@ msgstr "" "if args.verbose:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:333 +#: ../../howto/argparse.rst:331 msgid "And here goes:" msgstr "而這為:" -#: ../../howto/argparse.rst:335 +#: ../../howto/argparse.rst:333 msgid "" "$ python prog.py -v\n" "verbosity turned on\n" @@ -685,19 +677,19 @@ msgstr "" " -h, --help show this help message and exit\n" " -v, --verbose increase output verbosity" -#: ../../howto/argparse.rst:346 +#: ../../howto/argparse.rst:344 msgid "Note that the new ability is also reflected in the help text." msgstr "請注意,新功能也反映在幫助文字中。" -#: ../../howto/argparse.rst:350 +#: ../../howto/argparse.rst:348 msgid "Combining Positional and Optional arguments" msgstr "組合位置引數和可選引數" -#: ../../howto/argparse.rst:352 +#: ../../howto/argparse.rst:350 msgid "Our program keeps growing in complexity::" msgstr "我們的程式的複雜性不斷增加: ::" -#: ../../howto/argparse.rst:354 +#: ../../howto/argparse.rst:352 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -725,11 +717,11 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:367 +#: ../../howto/argparse.rst:365 msgid "And now the output:" msgstr "然後現在的輸出結果:" -#: ../../howto/argparse.rst:369 +#: ../../howto/argparse.rst:367 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] square\n" @@ -751,15 +743,15 @@ msgstr "" "$ python prog.py --verbose 4\n" "the square of 4 equals 16" -#: ../../howto/argparse.rst:381 +#: ../../howto/argparse.rst:379 msgid "We've brought back a positional argument, hence the complaint." msgstr "我們帶回了位置引數,因而被抱怨。" -#: ../../howto/argparse.rst:383 +#: ../../howto/argparse.rst:381 msgid "Note that the order does not matter." msgstr "請注意,順序並不重要。" -#: ../../howto/argparse.rst:385 +#: ../../howto/argparse.rst:383 msgid "" "How about we give this program of ours back the ability to have multiple " "verbosity values, and actually get to use them::" @@ -767,7 +759,7 @@ msgstr "" "我們讓這個程式擁有多個訊息詳細級別 (verbosity) 之值的能力,並實際使用它" "們: ::" -#: ../../howto/argparse.rst:388 +#: ../../howto/argparse.rst:386 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -799,7 +791,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:405 +#: ../../howto/argparse.rst:403 msgid "" "$ python prog.py 4\n" "16\n" @@ -825,7 +817,7 @@ msgstr "" "$ python prog.py 4 -v 3\n" "16" -#: ../../howto/argparse.rst:419 +#: ../../howto/argparse.rst:417 msgid "" "These all look good except the last one, which exposes a bug in our program. " "Let's fix it by restricting the values the ``--verbosity`` option can " @@ -834,7 +826,7 @@ msgstr "" "除了最後一個外都看起來正常,它透露了我們程式中的一個錯誤。我們可透過限制 ``--" "verbosity`` 選項可以接受的值來修復它: ::" -#: ../../howto/argparse.rst:422 +#: ../../howto/argparse.rst:420 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -866,7 +858,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:439 +#: ../../howto/argparse.rst:437 msgid "" "$ python prog.py 4 -v 3\n" "usage: prog.py [-h] [-v {0,1,2}] square\n" @@ -898,13 +890,13 @@ msgstr "" " -v, --verbosity {0,1,2}\n" " increase output verbosity" -#: ../../howto/argparse.rst:455 +#: ../../howto/argparse.rst:453 msgid "" "Note that the change also reflects both in the error message as well as the " "help string." msgstr "請注意,更改也會反映在錯誤訊息和幫助字串中。" -#: ../../howto/argparse.rst:458 +#: ../../howto/argparse.rst:456 msgid "" "Now, let's use a different approach of playing with verbosity, which is " "pretty common. It also matches the way the CPython executable handles its " @@ -913,7 +905,7 @@ msgstr "" "現在,讓我們使用另一種常見方法來玩玩訊息詳細級別。它也與 CPython 執行檔處理其" "自身訊息詳細級別引數的方式相符(請見 ``python --help`` 的輸出): ::" -#: ../../howto/argparse.rst:462 +#: ../../howto/argparse.rst:460 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -945,13 +937,13 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:477 +#: ../../howto/argparse.rst:475 msgid "" "We have introduced another action, \"count\", to count the number of " "occurrences of specific options." msgstr "我們已經介紹過另一個操作 \"count\" 用來計算指定的選項出現的次數。" -#: ../../howto/argparse.rst:481 +#: ../../howto/argparse.rst:479 msgid "" "$ python prog.py 4\n" "16\n" @@ -999,7 +991,7 @@ msgstr "" "$ python prog.py 4 -vvv\n" "16" -#: ../../howto/argparse.rst:506 +#: ../../howto/argparse.rst:504 msgid "" "Yes, it's now more of a flag (similar to ``action=\"store_true\"``) in the " "previous version of our script. That should explain the complaint." @@ -1007,29 +999,29 @@ msgstr "" "是的,現在它更像是我們上一版腳本中的旗標(類似於 " "``action=\"store_true\"``),這應該可以解釋抱怨的原因。" -#: ../../howto/argparse.rst:509 +#: ../../howto/argparse.rst:507 msgid "It also behaves similar to \"store_true\" action." msgstr "它的行為也類似 \"store_true\" 操作。" -#: ../../howto/argparse.rst:511 +#: ../../howto/argparse.rst:509 msgid "" "Now here's a demonstration of what the \"count\" action gives. You've " "probably seen this sort of usage before." msgstr "現在這裡示範了 \"count\" 動作的作用。你可能以前見過這種用法。" -#: ../../howto/argparse.rst:514 +#: ../../howto/argparse.rst:512 msgid "" "And if you don't specify the ``-v`` flag, that flag is considered to have " "``None`` value." msgstr "如果你不指定 ``-v`` 旗標,則該旗標被視為具有 ``None`` 值。" -#: ../../howto/argparse.rst:517 +#: ../../howto/argparse.rst:515 msgid "" "As should be expected, specifying the long form of the flag, we should get " "the same output." msgstr "正如預期的那樣,指定長形式旗標,我們應該得到相同的輸出。" -#: ../../howto/argparse.rst:520 +#: ../../howto/argparse.rst:518 msgid "" "Sadly, our help output isn't very informative on the new ability our script " "has acquired, but that can always be fixed by improving the documentation " @@ -1038,15 +1030,15 @@ msgstr "" "遺憾的是,我們的幫助輸出對於我們腳本獲得的新功能並沒有提供太多資訊,但我們都" "可以透過改進腳本的文件來解決這個問題(例如:透過 ``help`` 關鍵字引數)。" -#: ../../howto/argparse.rst:524 +#: ../../howto/argparse.rst:522 msgid "That last output exposes a bug in our program." msgstr "最後的輸出透露了我們程式中的一個錯誤。" -#: ../../howto/argparse.rst:527 +#: ../../howto/argparse.rst:525 msgid "Let's fix::" msgstr "讓我們來解決問題: ::" -#: ../../howto/argparse.rst:529 +#: ../../howto/argparse.rst:527 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1082,11 +1074,11 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:546 +#: ../../howto/argparse.rst:544 msgid "And this is what it gives:" msgstr "這就是它給出的:" -#: ../../howto/argparse.rst:548 +#: ../../howto/argparse.rst:546 msgid "" "$ python prog.py 4 -vvv\n" "the square of 4 equals 16\n" @@ -1108,7 +1100,7 @@ msgstr "" " if args.verbosity >= 2:\n" "TypeError: '>=' not supported between instances of 'NoneType' and 'int'" -#: ../../howto/argparse.rst:561 +#: ../../howto/argparse.rst:559 msgid "" "First output went well, and fixes the bug we had before. That is, we want " "any value >= 2 to be as verbose as possible." @@ -1116,15 +1108,15 @@ msgstr "" "第一次輸出順利進行,並修復了我們之前遇到的錯誤。也就是說,我們希望任何 >= 2 " "的值都盡可能詳細。" -#: ../../howto/argparse.rst:564 +#: ../../howto/argparse.rst:562 msgid "Third output not so good." msgstr "第三個輸出不太好。" -#: ../../howto/argparse.rst:566 +#: ../../howto/argparse.rst:564 msgid "Let's fix that bug::" msgstr "我們來修復這個錯誤: ::" -#: ../../howto/argparse.rst:568 +#: ../../howto/argparse.rst:566 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1156,7 +1148,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:583 +#: ../../howto/argparse.rst:581 msgid "" "We've just introduced yet another keyword, ``default``. We've set it to " "``0`` in order to make it comparable to the other int values. Remember that " @@ -1168,11 +1160,11 @@ msgstr "" "int 值進行比較。請記住,預設情況下,如果未指定可選引數,它將獲得 ``None`` " "值,並且不能與 int 值進行比較(因此會出現 :exc:`TypeError` 例外)。" -#: ../../howto/argparse.rst:590 +#: ../../howto/argparse.rst:588 msgid "And:" msgstr "而且:" -#: ../../howto/argparse.rst:592 +#: ../../howto/argparse.rst:590 msgid "" "$ python prog.py 4\n" "16" @@ -1180,7 +1172,7 @@ msgstr "" "$ python prog.py 4\n" "16" -#: ../../howto/argparse.rst:597 +#: ../../howto/argparse.rst:595 msgid "" "You can go quite far just with what we've learned so far, and we have only " "scratched the surface. The :mod:`argparse` module is very powerful, and " @@ -1190,17 +1182,17 @@ msgstr "" "毛而已。:mod:`argparse` 模組非常強大,在結束本教學之前我們會對它進行更多探" "索。" -#: ../../howto/argparse.rst:604 +#: ../../howto/argparse.rst:602 msgid "Getting a little more advanced" msgstr "更進階一點" -#: ../../howto/argparse.rst:606 +#: ../../howto/argparse.rst:604 msgid "" "What if we wanted to expand our tiny program to perform other powers, not " "just squares::" msgstr "如果我們想擴充我們的小程式來執行其他次方的運算,而不僅是平方: ::" -#: ../../howto/argparse.rst:609 +#: ../../howto/argparse.rst:607 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1230,12 +1222,12 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:623 ../../howto/argparse.rst:661 -#: ../../howto/argparse.rst:877 +#: ../../howto/argparse.rst:621 ../../howto/argparse.rst:659 +#: ../../howto/argparse.rst:875 msgid "Output:" msgstr "結果:" -#: ../../howto/argparse.rst:625 +#: ../../howto/argparse.rst:623 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] x y\n" @@ -1269,7 +1261,7 @@ msgstr "" "$ python prog.py 4 2 -v\n" "4^2 == 16" -#: ../../howto/argparse.rst:644 +#: ../../howto/argparse.rst:642 msgid "" "Notice that so far we've been using verbosity level to *change* the text " "that gets displayed. The following example instead uses verbosity level to " @@ -1278,7 +1270,7 @@ msgstr "" "請注意,到目前為止,我們一直在使用詳細級別來\\ *更改*\\ 顯示的文字。以下範例" "使用詳細級別來顯示\\ *更多*\\ 文字: ::" -#: ../../howto/argparse.rst:648 +#: ../../howto/argparse.rst:646 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1306,7 +1298,7 @@ msgstr "" " print(f\"{args.x}^{args.y} == \", end=\"\")\n" "print(answer)" -#: ../../howto/argparse.rst:663 +#: ../../howto/argparse.rst:661 msgid "" "$ python prog.py 4 2\n" "16\n" @@ -1324,11 +1316,11 @@ msgstr "" "Running 'prog.py'\n" "4^2 == 16" -#: ../../howto/argparse.rst:677 +#: ../../howto/argparse.rst:675 msgid "Specifying ambiguous arguments" msgstr "指定不明確的引數" -#: ../../howto/argparse.rst:679 +#: ../../howto/argparse.rst:677 msgid "" "When there is ambiguity in deciding whether an argument is positional or for " "an argument, ``--`` can be used to tell :meth:`~ArgumentParser.parse_args` " @@ -1337,7 +1329,7 @@ msgstr "" "當決定一個引數是位置引數還是引數會有歧義,可以使用 ``--`` 來告訴 :meth:" "`~ArgumentParser.parse_args` 之後的所有內容都是位置引數: ::" -#: ../../howto/argparse.rst:683 +#: ../../howto/argparse.rst:681 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-n', nargs='+')\n" @@ -1377,11 +1369,11 @@ msgstr "" ">>> parser.parse_args(['-n', '1', '--', '2', '3'])\n" "Namespace(args=['2', '3'], n=['1'])" -#: ../../howto/argparse.rst:704 +#: ../../howto/argparse.rst:702 msgid "Conflicting options" msgstr "相互衝突的選項" -#: ../../howto/argparse.rst:706 +#: ../../howto/argparse.rst:704 msgid "" "So far, we have been working with two methods of an :class:`argparse." "ArgumentParser` instance. Let's introduce a third one, :meth:" @@ -1395,7 +1387,7 @@ msgstr "" "許我們指定彼此衝突的選項。我們還可以更改程式的其餘部分,以使得新功能更有意" "義:我們將引入 ``--quiet`` 選項,該選項與 ``--verbose`` 選項相反: ::" -#: ../../howto/argparse.rst:714 +#: ../../howto/argparse.rst:712 msgid "" "import argparse\n" "\n" @@ -1433,7 +1425,7 @@ msgstr "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" -#: ../../howto/argparse.rst:732 +#: ../../howto/argparse.rst:730 msgid "" "Our program is now simpler, and we've lost some functionality for the sake " "of demonstration. Anyways, here's the output:" @@ -1441,7 +1433,7 @@ msgstr "" "我們的程式現在更簡單了,我們因為功能展示失去了一些功能,但無論如何,以下這是" "輸出:" -#: ../../howto/argparse.rst:735 +#: ../../howto/argparse.rst:733 msgid "" "$ python prog.py 4 2\n" "4^2 == 16\n" @@ -1469,7 +1461,7 @@ msgstr "" "usage: prog.py [-h] [-v | -q] x y\n" "prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose" -#: ../../howto/argparse.rst:750 +#: ../../howto/argparse.rst:748 msgid "" "That should be easy to follow. I've added that last output so you can see " "the sort of flexibility you get, i.e. mixing long form options with short " @@ -1478,14 +1470,14 @@ msgstr "" "這應該很容易理解。我新增了最後一個輸出,以便看到所獲得的靈活性,即可以混合長" "形式與短形式選項。" -#: ../../howto/argparse.rst:754 +#: ../../howto/argparse.rst:752 msgid "" "Before we conclude, you probably want to tell your users the main purpose of " "your program, just in case they don't know::" msgstr "" "在我們結束之前,你可能想告訴使用者你的程式的主要目的,以防他們不知道: ::" -#: ../../howto/argparse.rst:757 +#: ../../howto/argparse.rst:755 msgid "" "import argparse\n" "\n" @@ -1525,7 +1517,7 @@ msgstr "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" -#: ../../howto/argparse.rst:775 +#: ../../howto/argparse.rst:773 msgid "" "Note that slight difference in the usage text. Note the ``[-v | -q]``, which " "tells us that we can either use ``-v`` or ``-q``, but not both at the same " @@ -1534,7 +1526,7 @@ msgstr "" "請注意用法文字中的細微差別。注意 ``[-v | -q]``,它告訴我們可以使用 ``-v`` 或 " "``-q``,但不能同時使用:" -#: ../../howto/argparse.rst:779 ../../howto/argparse.rst:806 +#: ../../howto/argparse.rst:777 ../../howto/argparse.rst:804 msgid "" "$ python prog.py --help\n" "usage: prog.py [-h] [-v | -q] x y\n" @@ -1564,11 +1556,11 @@ msgstr "" " -v, --verbose\n" " -q, --quiet" -#: ../../howto/argparse.rst:797 +#: ../../howto/argparse.rst:795 msgid "How to translate the argparse output" msgstr "如何翻譯 argparse 輸出" -#: ../../howto/argparse.rst:799 +#: ../../howto/argparse.rst:797 msgid "" "The output of the :mod:`argparse` module such as its help text and error " "messages are all made translatable using the :mod:`gettext` module. This " @@ -1579,11 +1571,11 @@ msgstr "" "`gettext` 模組進行翻譯。這允許應用程式能輕鬆在地化 :mod:`argparse` 生成的訊" "息。另請參閱 :ref:`i18n-howto`。" -#: ../../howto/argparse.rst:804 +#: ../../howto/argparse.rst:802 msgid "For instance, in this :mod:`argparse` output:" msgstr "例如,在此 :mod:`argparse` 輸出中:" -#: ../../howto/argparse.rst:822 +#: ../../howto/argparse.rst:820 msgid "" "The strings ``usage:``, ``positional arguments:``, ``options:`` and ``show " "this help message and exit`` are all translatable." @@ -1591,7 +1583,7 @@ msgstr "" "字串 ``usage:``、``positional arguments:``、``options:`` 和 ``show this help " "message and exit`` 都是可被翻譯的。" -#: ../../howto/argparse.rst:825 +#: ../../howto/argparse.rst:823 msgid "" "In order to translate these strings, they must first be extracted into a ``." "po`` file. For example, using `Babel `__, run this " @@ -1600,11 +1592,11 @@ msgstr "" "為了翻譯這些字串,必須先將它們提取到 ``.po`` 檔案中。例如,使用 `Babel " "`__ 並執行下列命令:" -#: ../../howto/argparse.rst:829 +#: ../../howto/argparse.rst:827 msgid "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" msgstr "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" -#: ../../howto/argparse.rst:833 +#: ../../howto/argparse.rst:831 msgid "" "This command will extract all translatable strings from the :mod:`argparse` " "module and output them into a file named ``messages.po``. This command " @@ -1613,13 +1605,13 @@ msgstr "" "此命令將從 :mod:`argparse` 模組中提取出所有可翻譯的字串,並將它們輸出到名為 " "``messages.po`` 的檔案中。這個指令假設你的 Python 是安裝在 ``/usr/lib`` 中。" -#: ../../howto/argparse.rst:837 +#: ../../howto/argparse.rst:835 msgid "" "You can find out the location of the :mod:`argparse` module on your system " "using this script::" msgstr "你可以使用以下腳本找到 :mod:`argparse` 模組在系統上的位置: ::" -#: ../../howto/argparse.rst:840 +#: ../../howto/argparse.rst:838 msgid "" "import argparse\n" "print(argparse.__file__)" @@ -1627,7 +1619,7 @@ msgstr "" "import argparse\n" "print(argparse.__file__)" -#: ../../howto/argparse.rst:843 +#: ../../howto/argparse.rst:841 msgid "" "Once the messages in the ``.po`` file are translated and the translations " "are installed using :mod:`gettext`, :mod:`argparse` will be able to display " @@ -1636,17 +1628,17 @@ msgstr "" "一旦翻譯了 ``.po`` 檔案中的訊息並使用 :mod:`gettext` 安裝了翻譯,:mod:" "`argparse` 將能夠顯示翻譯後的訊息。" -#: ../../howto/argparse.rst:847 +#: ../../howto/argparse.rst:845 msgid "" "To translate your own strings in the :mod:`argparse` output, use :mod:" "`gettext`." msgstr "若要在 :mod:`argparse` 輸出中翻譯你自己的字串,請使用 :mod:`gettext`。" -#: ../../howto/argparse.rst:850 +#: ../../howto/argparse.rst:848 msgid "Custom type converters" msgstr "自訂型別轉換器" -#: ../../howto/argparse.rst:852 +#: ../../howto/argparse.rst:850 msgid "" "The :mod:`argparse` module allows you to specify custom type converters for " "your command-line arguments. This allows you to modify user input before " @@ -1654,7 +1646,7 @@ msgid "" "need to pre-process the input before it is used in your program." msgstr "" -#: ../../howto/argparse.rst:857 +#: ../../howto/argparse.rst:855 msgid "" "When using a custom type converter, you can use any callable that takes a " "single string argument (the argument value) and returns the converted value. " @@ -1662,13 +1654,13 @@ msgid "" "action class with the **action** parameter instead." msgstr "" -#: ../../howto/argparse.rst:862 +#: ../../howto/argparse.rst:860 msgid "" "For example, let's say you want to handle arguments with different prefixes " "and process them accordingly::" msgstr "" -#: ../../howto/argparse.rst:865 +#: ../../howto/argparse.rst:863 msgid "" "import argparse\n" "\n" @@ -1694,7 +1686,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args)" -#: ../../howto/argparse.rst:879 +#: ../../howto/argparse.rst:877 msgid "" "$ python prog.py -a value1 +a value2\n" "Namespace(a=[('-', 'value1'), ('+', 'value2')])" @@ -1702,24 +1694,24 @@ msgstr "" "$ python prog.py -a value1 +a value2\n" "Namespace(a=[('-', 'value1'), ('+', 'value2')])" -#: ../../howto/argparse.rst:884 +#: ../../howto/argparse.rst:882 msgid "In this example, we:" msgstr "在這個範例當中,我們:" -#: ../../howto/argparse.rst:886 +#: ../../howto/argparse.rst:884 msgid "" "Created a parser with custom prefix characters using the ``prefix_chars`` " "parameter." msgstr "" -#: ../../howto/argparse.rst:889 +#: ../../howto/argparse.rst:887 msgid "" "Defined two arguments, ``-a`` and ``+a``, which used the ``type`` parameter " "to create custom type converters to store the value in a tuple with the " "prefix." msgstr "" -#: ../../howto/argparse.rst:892 +#: ../../howto/argparse.rst:890 msgid "" "Without the custom type converters, the arguments would have treated the ``-" "a`` and ``+a`` as the same argument, which would have been undesirable. By " @@ -1727,11 +1719,11 @@ msgid "" "arguments." msgstr "" -#: ../../howto/argparse.rst:897 +#: ../../howto/argparse.rst:895 msgid "Conclusion" msgstr "結論" -#: ../../howto/argparse.rst:899 +#: ../../howto/argparse.rst:897 msgid "" "The :mod:`argparse` module offers a lot more than shown here. Its docs are " "quite detailed and thorough, and full of examples. Having gone through this " @@ -1739,3 +1731,9 @@ msgid "" msgstr "" ":mod:`argparse` 模組提供的功能比此篇內容的要多得多。它的文件非常詳細與透徹並" "有很多範例。讀完本教學後,你應該可以輕鬆消化它們,而不會感到不知所措。" + +#~ msgid "author" +#~ msgstr "作者" + +#~ msgid "Tshepang Mbambo" +#~ msgstr "Tshepang Mbambo" diff --git a/howto/curses.po b/howto/curses.po index e2107990b13..f8ec647c24e 100644 --- a/howto/curses.po +++ b/howto/curses.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-04 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,37 +21,21 @@ msgstr "" msgid "Curses Programming with Python" msgstr "" -#: ../../howto/curses.rst:0 -msgid "Author" -msgstr "作者" - -#: ../../howto/curses.rst:9 -msgid "A.M. Kuchling, Eric S. Raymond" -msgstr "A.M. Kuchling, Eric S. Raymond" - -#: ../../howto/curses.rst:0 -msgid "Release" -msgstr "發佈版本" - -#: ../../howto/curses.rst:10 -msgid "2.04" -msgstr "2.04" - #: ../../howto/curses.rst:-1 msgid "Abstract" msgstr "摘要" -#: ../../howto/curses.rst:15 +#: ../../howto/curses.rst:12 msgid "" "This document describes how to use the :mod:`curses` extension module to " "control text-mode displays." msgstr "" -#: ../../howto/curses.rst:20 +#: ../../howto/curses.rst:17 msgid "What is curses?" msgstr "" -#: ../../howto/curses.rst:22 +#: ../../howto/curses.rst:19 msgid "" "The curses library supplies a terminal-independent screen-painting and " "keyboard-handling facility for text-based terminals; such terminals include " @@ -62,7 +46,7 @@ msgid "" "own minor quirks." msgstr "" -#: ../../howto/curses.rst:30 +#: ../../howto/curses.rst:27 msgid "" "In a world of graphical displays, one might ask \"why bother\"? It's true " "that character-cell display terminals are an obsolete technology, but there " @@ -72,7 +56,7 @@ msgid "" "configurators that may have to run before any graphical support is available." msgstr "" -#: ../../howto/curses.rst:38 +#: ../../howto/curses.rst:35 msgid "" "The curses library provides fairly basic functionality, providing the " "programmer with an abstraction of a display containing multiple non-" @@ -84,7 +68,7 @@ msgid "" "features, consider a user interface library such as :pypi:`Urwid`." msgstr "" -#: ../../howto/curses.rst:48 +#: ../../howto/curses.rst:45 msgid "" "The curses library was originally written for BSD Unix; the later System V " "versions of Unix from AT&T added many enhancements and new functions. BSD " @@ -97,18 +81,18 @@ msgid "" "everything, though." msgstr "" -#: ../../howto/curses.rst:58 +#: ../../howto/curses.rst:55 msgid "" "The Windows version of Python doesn't include the :mod:`curses` module. The " "third-party :pypi:`windows-curses` package provides the same interface on " "Windows." msgstr "" -#: ../../howto/curses.rst:63 +#: ../../howto/curses.rst:60 msgid "The Python curses module" msgstr "Python curses 模組" -#: ../../howto/curses.rst:65 +#: ../../howto/curses.rst:62 msgid "" "The Python module is a fairly simple wrapper over the C functions provided " "by curses; if you're already familiar with curses programming in C, it's " @@ -119,7 +103,7 @@ msgid "" "this covered in more detail later." msgstr "" -#: ../../howto/curses.rst:73 +#: ../../howto/curses.rst:70 msgid "" "This HOWTO is an introduction to writing text-mode programs with curses and " "Python. It doesn't attempt to be a complete guide to the curses API; for " @@ -127,11 +111,11 @@ msgid "" "pages for ncurses. It will, however, give you the basic ideas." msgstr "" -#: ../../howto/curses.rst:80 +#: ../../howto/curses.rst:77 msgid "Starting and ending a curses application" msgstr "" -#: ../../howto/curses.rst:82 +#: ../../howto/curses.rst:79 msgid "" "Before doing anything, curses must be initialized. This is done by calling " "the :func:`~curses.initscr` function, which will determine the terminal " @@ -141,7 +125,7 @@ msgid "" "after the name of the corresponding C variable. ::" msgstr "" -#: ../../howto/curses.rst:90 +#: ../../howto/curses.rst:87 msgid "" "import curses\n" "stdscr = curses.initscr()" @@ -149,29 +133,29 @@ msgstr "" "import curses\n" "stdscr = curses.initscr()" -#: ../../howto/curses.rst:93 +#: ../../howto/curses.rst:90 msgid "" "Usually curses applications turn off automatic echoing of keys to the " "screen, in order to be able to read keys and only display them under certain " "circumstances. This requires calling the :func:`~curses.noecho` function. ::" msgstr "" -#: ../../howto/curses.rst:98 +#: ../../howto/curses.rst:95 msgid "curses.noecho()" msgstr "curses.noecho()" -#: ../../howto/curses.rst:100 +#: ../../howto/curses.rst:97 msgid "" "Applications will also commonly need to react to keys instantly, without " "requiring the Enter key to be pressed; this is called cbreak mode, as " "opposed to the usual buffered input mode. ::" msgstr "" -#: ../../howto/curses.rst:104 +#: ../../howto/curses.rst:101 msgid "curses.cbreak()" msgstr "curses.cbreak()" -#: ../../howto/curses.rst:106 +#: ../../howto/curses.rst:103 msgid "" "Terminals usually return special keys, such as the cursor keys or navigation " "keys such as Page Up and Home, as a multibyte escape sequence. While you " @@ -181,17 +165,17 @@ msgid "" "keypad mode. ::" msgstr "" -#: ../../howto/curses.rst:113 +#: ../../howto/curses.rst:110 msgid "stdscr.keypad(True)" msgstr "stdscr.keypad(True)" -#: ../../howto/curses.rst:115 +#: ../../howto/curses.rst:112 msgid "" "Terminating a curses application is much easier than starting one. You'll " "need to call::" msgstr "" -#: ../../howto/curses.rst:118 +#: ../../howto/curses.rst:115 msgid "" "curses.nocbreak()\n" "stdscr.keypad(False)\n" @@ -201,18 +185,18 @@ msgstr "" "stdscr.keypad(False)\n" "curses.echo()" -#: ../../howto/curses.rst:122 +#: ../../howto/curses.rst:119 msgid "" "to reverse the curses-friendly terminal settings. Then call the :func:" "`~curses.endwin` function to restore the terminal to its original operating " "mode. ::" msgstr "" -#: ../../howto/curses.rst:126 +#: ../../howto/curses.rst:123 msgid "curses.endwin()" msgstr "curses.endwin()" -#: ../../howto/curses.rst:128 +#: ../../howto/curses.rst:125 msgid "" "A common problem when debugging a curses application is to get your terminal " "messed up when the application dies without restoring the terminal to its " @@ -221,13 +205,13 @@ msgid "" "you type them, for example, which makes using the shell difficult." msgstr "" -#: ../../howto/curses.rst:134 +#: ../../howto/curses.rst:131 msgid "" "In Python you can avoid these complications and make debugging much easier " "by importing the :func:`curses.wrapper` function and using it like this::" msgstr "" -#: ../../howto/curses.rst:137 +#: ../../howto/curses.rst:134 msgid "" "from curses import wrapper\n" "\n" @@ -246,7 +230,7 @@ msgid "" "wrapper(main)" msgstr "" -#: ../../howto/curses.rst:153 +#: ../../howto/curses.rst:150 msgid "" "The :func:`~curses.wrapper` function takes a callable object and does the " "initializations described above, also initializing colors if color support " @@ -259,18 +243,18 @@ msgid "" "and traceback." msgstr "" -#: ../../howto/curses.rst:165 +#: ../../howto/curses.rst:164 msgid "Windows and Pads" msgstr "" -#: ../../howto/curses.rst:167 +#: ../../howto/curses.rst:166 msgid "" "Windows are the basic abstraction in curses. A window object represents a " "rectangular area of the screen, and supports methods to display text, erase " "it, allow the user to input strings, and so forth." msgstr "" -#: ../../howto/curses.rst:171 +#: ../../howto/curses.rst:170 msgid "" "The ``stdscr`` object returned by the :func:`~curses.initscr` function is a " "window object that covers the entire screen. Many programs may need only " @@ -280,7 +264,7 @@ msgid "" "window object. ::" msgstr "" -#: ../../howto/curses.rst:178 +#: ../../howto/curses.rst:177 msgid "" "begin_x = 20; begin_y = 7\n" "height = 5; width = 40\n" @@ -290,7 +274,7 @@ msgstr "" "height = 5; width = 40\n" "win = curses.newwin(height, width, begin_y, begin_x)" -#: ../../howto/curses.rst:182 +#: ../../howto/curses.rst:181 msgid "" "Note that the coordinate system used in curses is unusual. Coordinates are " "always passed in the order *y,x*, and the top-left corner of a window is " @@ -300,7 +284,7 @@ msgid "" "curses since it was first written, and it's too late to change things now." msgstr "" -#: ../../howto/curses.rst:190 +#: ../../howto/curses.rst:189 msgid "" "Your application can determine the size of the screen by using the :data:" "`curses.LINES` and :data:`curses.COLS` variables to obtain the *y* and *x* " @@ -308,14 +292,14 @@ msgid "" "- 1, curses.COLS - 1)``." msgstr "" -#: ../../howto/curses.rst:195 +#: ../../howto/curses.rst:194 msgid "" "When you call a method to display or erase text, the effect doesn't " "immediately show up on the display. Instead you must call the :meth:" "`~curses.window.refresh` method of window objects to update the screen." msgstr "" -#: ../../howto/curses.rst:200 +#: ../../howto/curses.rst:199 msgid "" "This is because curses was originally written with slow 300-baud terminal " "connections in mind; with these terminals, minimizing the time required to " @@ -326,7 +310,7 @@ msgid "" "because they're never visible." msgstr "" -#: ../../howto/curses.rst:209 +#: ../../howto/curses.rst:208 msgid "" "In practice, explicitly telling curses to redraw a window doesn't really " "complicate programming with curses much. Most programs go into a flurry of " @@ -336,7 +320,7 @@ msgid "" "stdscr.refresh` or the :meth:`!refresh` method of some other relevant window." msgstr "" -#: ../../howto/curses.rst:217 +#: ../../howto/curses.rst:216 msgid "" "A pad is a special case of a window; it can be larger than the actual " "display screen, and only a portion of the pad displayed at a time. Creating " @@ -345,7 +329,7 @@ msgid "" "will be displayed. ::" msgstr "" -#: ../../howto/curses.rst:223 +#: ../../howto/curses.rst:222 msgid "" "pad = curses.newpad(100, 100)\n" "# These loops fill the pad with letters; addch() is\n" @@ -363,7 +347,7 @@ msgid "" "pad.refresh( 0,0, 5,5, 20,75)" msgstr "" -#: ../../howto/curses.rst:238 +#: ../../howto/curses.rst:237 msgid "" "The :meth:`!refresh` call displays a section of the pad in the rectangle " "extending from coordinate (5,5) to coordinate (20,75) on the screen; the " @@ -372,36 +356,36 @@ msgid "" "the same methods." msgstr "" -#: ../../howto/curses.rst:244 +#: ../../howto/curses.rst:243 msgid "" "If you have multiple windows and pads on screen there is a more efficient " "way to update the screen and prevent annoying screen flicker as each part of " "the screen gets updated. :meth:`!refresh` actually does two things:" msgstr "" -#: ../../howto/curses.rst:249 +#: ../../howto/curses.rst:248 msgid "" "Calls the :meth:`~curses.window.noutrefresh` method of each window to update " "an underlying data structure representing the desired state of the screen." msgstr "" -#: ../../howto/curses.rst:252 +#: ../../howto/curses.rst:251 msgid "" "Calls the function :func:`~curses.doupdate` function to change the physical " "screen to match the desired state recorded in the data structure." msgstr "" -#: ../../howto/curses.rst:255 +#: ../../howto/curses.rst:254 msgid "" "Instead you can call :meth:`!noutrefresh` on a number of windows to update " "the data structure, and then call :func:`!doupdate` to update the screen." msgstr "" -#: ../../howto/curses.rst:261 +#: ../../howto/curses.rst:260 msgid "Displaying Text" msgstr "" -#: ../../howto/curses.rst:263 +#: ../../howto/curses.rst:262 msgid "" "From a C programmer's point of view, curses may sometimes look like a twisty " "maze of functions, all subtly different. For example, :c:func:`!addstr` " @@ -413,7 +397,7 @@ msgid "" "coordinate." msgstr "" -#: ../../howto/curses.rst:272 +#: ../../howto/curses.rst:271 msgid "" "Fortunately the Python interface hides all these details. ``stdscr`` is a " "window object like any other, and methods such as :meth:`~curses.window." @@ -421,58 +405,58 @@ msgid "" "forms." msgstr "" -#: ../../howto/curses.rst:278 +#: ../../howto/curses.rst:277 msgid "Form" msgstr "" -#: ../../howto/curses.rst:278 ../../howto/curses.rst:349 +#: ../../howto/curses.rst:277 ../../howto/curses.rst:348 msgid "Description" msgstr "描述" -#: ../../howto/curses.rst:280 +#: ../../howto/curses.rst:279 msgid "*str* or *ch*" msgstr "*str* 或 *ch*" -#: ../../howto/curses.rst:280 +#: ../../howto/curses.rst:279 msgid "Display the string *str* or character *ch* at the current position" msgstr "" -#: ../../howto/curses.rst:283 +#: ../../howto/curses.rst:282 msgid "*str* or *ch*, *attr*" msgstr "" -#: ../../howto/curses.rst:283 +#: ../../howto/curses.rst:282 msgid "" "Display the string *str* or character *ch*, using attribute *attr* at the " "current position" msgstr "" -#: ../../howto/curses.rst:287 +#: ../../howto/curses.rst:286 msgid "*y*, *x*, *str* or *ch*" msgstr "*y*、*x*、*str* 或 *ch*" -#: ../../howto/curses.rst:287 +#: ../../howto/curses.rst:286 msgid "Move to position *y,x* within the window, and display *str* or *ch*" msgstr "" -#: ../../howto/curses.rst:290 +#: ../../howto/curses.rst:289 msgid "*y*, *x*, *str* or *ch*, *attr*" msgstr "*y*、*x*、*str* 或 *ch*、*attr*" -#: ../../howto/curses.rst:290 +#: ../../howto/curses.rst:289 msgid "" "Move to position *y,x* within the window, and display *str* or *ch*, using " "attribute *attr*" msgstr "" -#: ../../howto/curses.rst:294 +#: ../../howto/curses.rst:293 msgid "" "Attributes allow displaying text in highlighted forms such as boldface, " "underline, reverse code, or in color. They'll be explained in more detail " "in the next subsection." msgstr "" -#: ../../howto/curses.rst:299 +#: ../../howto/curses.rst:298 msgid "" "The :meth:`~curses.window.addstr` method takes a Python string or bytestring " "as the value to be displayed. The contents of bytestrings are sent to the " @@ -482,13 +466,13 @@ msgid "" "getencoding`." msgstr "" -#: ../../howto/curses.rst:307 +#: ../../howto/curses.rst:306 msgid "" "The :meth:`~curses.window.addch` methods take a character, which can be " "either a string of length 1, a bytestring of length 1, or an integer." msgstr "" -#: ../../howto/curses.rst:310 +#: ../../howto/curses.rst:309 msgid "" "Constants are provided for the characters of the terminal's alternate " "character set. For example, :const:`ACS_PLMINUS` is a +/- symbol, and :const:" @@ -496,7 +480,7 @@ msgid "" "borders). You can also use the appropriate Unicode character." msgstr "" -#: ../../howto/curses.rst:317 +#: ../../howto/curses.rst:316 msgid "" "Windows remember where the cursor was left after the last operation, so if " "you leave out the *y,x* coordinates, the string or character will be " @@ -507,7 +491,7 @@ msgid "" "cursor blinking at some apparently random location." msgstr "" -#: ../../howto/curses.rst:325 +#: ../../howto/curses.rst:324 msgid "" "If your application doesn't need a blinking cursor at all, you can call " "``curs_set(False)`` to make it invisible. The window method :meth:`~curses." @@ -516,11 +500,11 @@ msgid "" "to the window's cursor position." msgstr "" -#: ../../howto/curses.rst:334 +#: ../../howto/curses.rst:333 msgid "Attributes and Color" msgstr "" -#: ../../howto/curses.rst:336 +#: ../../howto/curses.rst:335 msgid "" "Characters can be displayed in different ways. Status lines in a text-based " "application are commonly shown in reverse video, or a text viewer may need " @@ -528,7 +512,7 @@ msgid "" "an attribute for each cell on the screen." msgstr "" -#: ../../howto/curses.rst:341 +#: ../../howto/curses.rst:340 msgid "" "An attribute is an integer, each bit representing a different attribute. " "You can try to display text with multiple attribute bits set, but curses " @@ -538,79 +522,79 @@ msgid "" "attributes, listed here." msgstr "" -#: ../../howto/curses.rst:349 +#: ../../howto/curses.rst:348 msgid "Attribute" msgstr "屬性" -#: ../../howto/curses.rst:351 +#: ../../howto/curses.rst:350 msgid ":const:`A_BLINK`" msgstr ":const:`A_BLINK`" -#: ../../howto/curses.rst:351 +#: ../../howto/curses.rst:350 msgid "Blinking text" msgstr "" -#: ../../howto/curses.rst:353 +#: ../../howto/curses.rst:352 msgid ":const:`A_BOLD`" msgstr ":const:`A_BOLD`" -#: ../../howto/curses.rst:353 +#: ../../howto/curses.rst:352 msgid "Extra bright or bold text" msgstr "" -#: ../../howto/curses.rst:355 +#: ../../howto/curses.rst:354 msgid ":const:`A_DIM`" msgstr ":const:`A_DIM`" -#: ../../howto/curses.rst:355 +#: ../../howto/curses.rst:354 msgid "Half bright text" msgstr "" -#: ../../howto/curses.rst:357 +#: ../../howto/curses.rst:356 msgid ":const:`A_REVERSE`" msgstr ":const:`A_REVERSE`" -#: ../../howto/curses.rst:357 +#: ../../howto/curses.rst:356 msgid "Reverse-video text" msgstr "" -#: ../../howto/curses.rst:359 +#: ../../howto/curses.rst:358 msgid ":const:`A_STANDOUT`" msgstr ":const:`A_STANDOUT`" -#: ../../howto/curses.rst:359 +#: ../../howto/curses.rst:358 msgid "The best highlighting mode available" msgstr "" -#: ../../howto/curses.rst:361 +#: ../../howto/curses.rst:360 msgid ":const:`A_UNDERLINE`" msgstr ":const:`A_UNDERLINE`" -#: ../../howto/curses.rst:361 +#: ../../howto/curses.rst:360 msgid "Underlined text" msgstr "" -#: ../../howto/curses.rst:364 +#: ../../howto/curses.rst:363 msgid "" "So, to display a reverse-video status line on the top line of the screen, " "you could code::" msgstr "" -#: ../../howto/curses.rst:367 +#: ../../howto/curses.rst:366 msgid "" "stdscr.addstr(0, 0, \"Current mode: Typing mode\",\n" " curses.A_REVERSE)\n" "stdscr.refresh()" msgstr "" -#: ../../howto/curses.rst:371 +#: ../../howto/curses.rst:370 msgid "" "The curses library also supports color on those terminals that provide it. " "The most common such terminal is probably the Linux console, followed by " "color xterms." msgstr "" -#: ../../howto/curses.rst:375 +#: ../../howto/curses.rst:374 msgid "" "To use color, you must call the :func:`~curses.start_color` function soon " "after calling :func:`~curses.initscr`, to initialize the default color set " @@ -622,7 +606,7 @@ msgid "" "for the sake of these functions.)" msgstr "" -#: ../../howto/curses.rst:385 +#: ../../howto/curses.rst:384 msgid "" "The curses library maintains a finite number of color pairs, containing a " "foreground (or text) color and a background color. You can get the " @@ -632,17 +616,17 @@ msgid "" "work on all terminals." msgstr "" -#: ../../howto/curses.rst:392 +#: ../../howto/curses.rst:391 msgid "An example, which displays a line of text using color pair 1::" msgstr "" -#: ../../howto/curses.rst:394 +#: ../../howto/curses.rst:393 msgid "" "stdscr.addstr(\"Pretty text\", curses.color_pair(1))\n" "stdscr.refresh()" msgstr "" -#: ../../howto/curses.rst:397 +#: ../../howto/curses.rst:396 msgid "" "As I said before, a color pair consists of a foreground and background " "color. The ``init_pair(n, f, b)`` function changes the definition of color " @@ -650,7 +634,7 @@ msgid "" "hard-wired to white on black, and cannot be changed." msgstr "" -#: ../../howto/curses.rst:402 +#: ../../howto/curses.rst:401 msgid "" "Colors are numbered, and :func:`start_color` initializes 8 basic colors when " "it activates color mode. They are: 0:black, 1:red, 2:green, 3:yellow, 4:" @@ -659,28 +643,28 @@ msgid "" "const:`curses.COLOR_RED`, and so forth." msgstr "" -#: ../../howto/curses.rst:408 +#: ../../howto/curses.rst:407 msgid "" "Let's put all this together. To change color 1 to red text on a white " "background, you would call::" msgstr "" -#: ../../howto/curses.rst:411 +#: ../../howto/curses.rst:410 msgid "curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)" msgstr "curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)" -#: ../../howto/curses.rst:413 +#: ../../howto/curses.rst:412 msgid "" "When you change a color pair, any text already displayed using that color " "pair will change to the new colors. You can also display new text in this " "color with::" msgstr "" -#: ../../howto/curses.rst:417 +#: ../../howto/curses.rst:416 msgid "stdscr.addstr(0,0, \"RED ALERT!\", curses.color_pair(1))" msgstr "stdscr.addstr(0,0, \"RED ALERT!\", curses.color_pair(1))" -#: ../../howto/curses.rst:419 +#: ../../howto/curses.rst:418 msgid "" "Very fancy terminals can change the definitions of the actual colors to a " "given RGB value. This lets you change color 1, which is usually red, to " @@ -692,22 +676,22 @@ msgid "" "your system's man pages for more information." msgstr "" -#: ../../howto/curses.rst:430 +#: ../../howto/curses.rst:429 msgid "User Input" msgstr "使用者輸入" -#: ../../howto/curses.rst:432 +#: ../../howto/curses.rst:431 msgid "" "The C curses library offers only very simple input mechanisms. Python's :mod:" "`curses` module adds a basic text-input widget. (Other libraries such as :" "pypi:`Urwid` have more extensive collections of widgets.)" msgstr "" -#: ../../howto/curses.rst:436 +#: ../../howto/curses.rst:435 msgid "There are three methods for getting input from a window:" msgstr "" -#: ../../howto/curses.rst:438 +#: ../../howto/curses.rst:437 msgid "" ":meth:`~curses.window.get_wch` refreshes the screen and then waits for the " "user to hit a key, displaying the key if :func:`~curses.echo` has been " @@ -715,7 +699,7 @@ msgid "" "should be moved before pausing." msgstr "" -#: ../../howto/curses.rst:443 +#: ../../howto/curses.rst:442 msgid "" ":meth:`~curses.window.getch` does the same thing but returns the code of the " "key instead of a character. With ncurses this is a single byte of the key's " @@ -723,14 +707,14 @@ msgid "" "takes several calls, one byte per call." msgstr "" -#: ../../howto/curses.rst:449 +#: ../../howto/curses.rst:448 msgid "" ":meth:`~curses.window.getkey` does the same as :meth:`!getch` but returns a " "string: an ordinary key as a 1-character string, and a special key as its " "name, such as ``KEY_UP``." msgstr "" -#: ../../howto/curses.rst:454 +#: ../../howto/curses.rst:453 msgid "" "It's possible to not wait for the user using the :meth:`~curses.window." "nodelay` window method. After ``nodelay(True)``, the reads for the window " @@ -742,7 +726,7 @@ msgid "" "way." msgstr "" -#: ../../howto/curses.rst:465 +#: ../../howto/curses.rst:464 msgid "" "Special keys such as Page Up, Home, or the cursor keys are returned by all " "three as one of the :ref:`KEY_* constants `, all " @@ -751,7 +735,7 @@ msgid "" "KEY_LEFT`. The main loop of your program may look something like this::" msgstr "" -#: ../../howto/curses.rst:473 +#: ../../howto/curses.rst:472 msgid "" "while True:\n" " c = stdscr.get_wch()\n" @@ -771,7 +755,7 @@ msgstr "" " elif c == curses.KEY_HOME:\n" " x = y = 0" -#: ../../howto/curses.rst:482 +#: ../../howto/curses.rst:481 msgid "" "The :mod:`curses.ascii` module supplies ASCII class membership functions " "that take either integer or 1-character string arguments; these may be " @@ -781,7 +765,7 @@ msgid "" "returns the control character corresponding to its argument." msgstr "" -#: ../../howto/curses.rst:489 +#: ../../howto/curses.rst:488 msgid "" "There's also a method to retrieve an entire line, :meth:`~curses.window." "getstr`. It isn't used very often, because its functionality is quite " @@ -790,7 +774,7 @@ msgid "" "can optionally be limited to a fixed number of bytes. ::" msgstr "" -#: ../../howto/curses.rst:496 +#: ../../howto/curses.rst:495 msgid "" "curses.echo() # Enable echoing of characters\n" "\n" @@ -802,7 +786,7 @@ msgstr "" "# 取得最多 15 個位元組的一行,游標位於頂端那一行\n" "s = stdscr.getstr(0,0, 15)" -#: ../../howto/curses.rst:501 +#: ../../howto/curses.rst:500 msgid "" "The :mod:`curses.textpad` module supplies a text box that supports an Emacs-" "like set of keybindings. Various methods of the :class:`~curses.textpad." @@ -810,7 +794,7 @@ msgid "" "results either with or without trailing spaces. Here's an example::" msgstr "" -#: ../../howto/curses.rst:507 +#: ../../howto/curses.rst:506 msgid "" "import curses\n" "from curses.textpad import Textbox, rectangle\n" @@ -831,16 +815,16 @@ msgid "" " message = box.gather()" msgstr "" -#: ../../howto/curses.rst:525 +#: ../../howto/curses.rst:524 msgid "" "See the library documentation on :mod:`curses.textpad` for more details." msgstr "" -#: ../../howto/curses.rst:529 +#: ../../howto/curses.rst:528 msgid "For More Information" msgstr "" -#: ../../howto/curses.rst:531 +#: ../../howto/curses.rst:530 msgid "" "This HOWTO doesn't cover some advanced topics, such as reading the contents " "of the screen or capturing mouse events from an xterm instance, but the " @@ -848,7 +832,7 @@ msgid "" "complete. You should browse it next." msgstr "" -#: ../../howto/curses.rst:536 +#: ../../howto/curses.rst:535 msgid "" "If you're in doubt about the detailed behavior of the curses functions, " "consult the manual pages for your curses implementation, whether it's " @@ -857,7 +841,7 @@ msgid "" "ref:`ACS_\\* ` characters available to you." msgstr "" -#: ../../howto/curses.rst:543 +#: ../../howto/curses.rst:542 msgid "" "Because the curses API is so large, some functions aren't supported in the " "Python interface. Often this isn't because they're difficult to implement, " @@ -867,32 +851,44 @@ msgid "" "org/>`_ to learn more about submitting patches to Python." msgstr "" -#: ../../howto/curses.rst:551 +#: ../../howto/curses.rst:550 msgid "" "`Writing Programs with NCURSES `_: a lengthy tutorial for C programmers." msgstr "" -#: ../../howto/curses.rst:553 +#: ../../howto/curses.rst:552 msgid "`The ncurses man page `_" msgstr "`ncurses 使用者手冊 `_" -#: ../../howto/curses.rst:554 +#: ../../howto/curses.rst:553 msgid "" "`The ncurses FAQ `_" msgstr "" "`ncurses 問答集 `_" -#: ../../howto/curses.rst:555 +#: ../../howto/curses.rst:554 msgid "" "`\"Use curses... don't swear\" `_: video of a PyCon 2013 talk on controlling terminals using " "curses or Urwid." msgstr "" -#: ../../howto/curses.rst:557 +#: ../../howto/curses.rst:556 msgid "" "`\"Console Applications with Urwid\" `_: video of a PyCon CA 2012 talk demonstrating some " "applications written using Urwid." msgstr "" + +#~ msgid "Author" +#~ msgstr "作者" + +#~ msgid "A.M. Kuchling, Eric S. Raymond" +#~ msgstr "A.M. Kuchling, Eric S. Raymond" + +#~ msgid "Release" +#~ msgstr "發佈版本" + +#~ msgid "2.04" +#~ msgstr "2.04" diff --git a/howto/descriptor.po b/howto/descriptor.po index 4e1ab7e6397..17c591725d9 100644 --- a/howto/descriptor.po +++ b/howto/descriptor.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,37 +22,21 @@ msgstr "" msgid "Descriptor Guide" msgstr "描述器 (Descriptor) 指南" -#: ../../howto/descriptor.rst:0 -msgid "Author" -msgstr "作者" - -#: ../../howto/descriptor.rst:7 -msgid "Raymond Hettinger" -msgstr "Raymond Hettinger" - -#: ../../howto/descriptor.rst:0 -msgid "Contact" -msgstr "聯絡方式" - #: ../../howto/descriptor.rst:8 -msgid "" -msgstr "" - -#: ../../howto/descriptor.rst:11 msgid "Contents" msgstr "目錄" -#: ../../howto/descriptor.rst:13 +#: ../../howto/descriptor.rst:10 msgid "" ":term:`Descriptors ` let objects customize attribute lookup, " "storage, and deletion." msgstr ":term:`描述器 `\\ 讓物件自訂屬性能夠被查找、儲存和刪除。" -#: ../../howto/descriptor.rst:16 +#: ../../howto/descriptor.rst:13 msgid "This guide has four major sections:" msgstr "此指南有四個主要章節:" -#: ../../howto/descriptor.rst:18 +#: ../../howto/descriptor.rst:15 msgid "" "The \"primer\" gives a basic overview, moving gently from simple examples, " "adding one feature at a time. Start here if you're new to descriptors." @@ -60,7 +44,7 @@ msgstr "" "「入門」提供基本概述,從簡單範例開始逐步介紹,一次新增一個功能。如果你是描述" "器的新手,請從這裡開始。" -#: ../../howto/descriptor.rst:21 +#: ../../howto/descriptor.rst:18 msgid "" "The second section shows a complete, practical descriptor example. If you " "already know the basics, start there." @@ -68,7 +52,7 @@ msgstr "" "第二個章節展示完整、實用的描述器範例。如果你已經了解基礎知識,可以從那裡開" "始。" -#: ../../howto/descriptor.rst:24 +#: ../../howto/descriptor.rst:21 msgid "" "The third section provides a more technical tutorial that goes into the " "detailed mechanics of how descriptors work. Most people don't need this " @@ -77,7 +61,7 @@ msgstr "" "第三個章節提供更技術性的教學,深入探討描述器運作的詳細機制。大部分的人不需要" "這種程度的細節。" -#: ../../howto/descriptor.rst:28 +#: ../../howto/descriptor.rst:25 msgid "" "The last section has pure Python equivalents for built-in descriptors that " "are written in C. Read this if you're curious about how functions turn into " @@ -89,21 +73,21 @@ msgstr "" "如 :deco:`classmethod`、:deco:`staticmethod`、:deco:`property` " "和 :term:`__slots__` 的實作方式,請閱讀此章節。" -#: ../../howto/descriptor.rst:36 +#: ../../howto/descriptor.rst:33 msgid "Primer" msgstr "入門" -#: ../../howto/descriptor.rst:38 +#: ../../howto/descriptor.rst:35 msgid "" "In this primer, we start with the most basic possible example and then we'll " "add new capabilities one by one." msgstr "在此入門教學中,我們從最基礎的範例開始,然後逐一新增新功能。" -#: ../../howto/descriptor.rst:43 +#: ../../howto/descriptor.rst:40 msgid "Simple example: A descriptor that returns a constant" msgstr "簡單範例:回傳常數的描述器" -#: ../../howto/descriptor.rst:45 +#: ../../howto/descriptor.rst:42 msgid "" "The :class:`!Ten` class is a descriptor whose :meth:`~object.__get__` method " "always returns the constant ``10``:" @@ -111,7 +95,7 @@ msgstr "" ":class:`!Ten` 類別是一個描述器,它的 :meth:`~object.__get__` 方法總是回傳常" "數 ``10``:" -#: ../../howto/descriptor.rst:48 +#: ../../howto/descriptor.rst:45 msgid "" "class Ten:\n" " def __get__(self, obj, objtype=None):\n" @@ -121,13 +105,13 @@ msgstr "" " def __get__(self, obj, objtype=None):\n" " return 10" -#: ../../howto/descriptor.rst:54 +#: ../../howto/descriptor.rst:51 msgid "" "To use the descriptor, it must be stored as a class variable in another " "class:" msgstr "要使用描述器,必須將它儲存為另一個類別的類別變數:" -#: ../../howto/descriptor.rst:56 +#: ../../howto/descriptor.rst:53 msgid "" "class A:\n" " x = 5 # Regular class attribute\n" @@ -137,13 +121,13 @@ msgstr "" " x = 5 # 一般類別屬性\n" " y = Ten() # 描述器實例" -#: ../../howto/descriptor.rst:62 +#: ../../howto/descriptor.rst:59 msgid "" "An interactive session shows the difference between normal attribute lookup " "and descriptor lookup:" msgstr "互動式工作階段顯示一般屬性查找和描述器查找之間的差異:" -#: ../../howto/descriptor.rst:65 +#: ../../howto/descriptor.rst:62 msgid "" ">>> a = A() # Make an instance of class A\n" ">>> a.x # Normal attribute lookup\n" @@ -157,7 +141,7 @@ msgstr "" ">>> a.y # 描述器查找\n" "10" -#: ../../howto/descriptor.rst:73 +#: ../../howto/descriptor.rst:70 msgid "" "In the ``a.x`` attribute lookup, the dot operator finds ``'x': 5`` in the " "class dictionary. In the ``a.y`` lookup, the dot operator finds a " @@ -168,7 +152,7 @@ msgstr "" "中,點運算子找到一個描述器實例,透過其 ``__get__`` 方法來識別。呼叫該方法回" "傳 ``10``。" -#: ../../howto/descriptor.rst:78 +#: ../../howto/descriptor.rst:75 msgid "" "Note that the value ``10`` is not stored in either the class dictionary or " "the instance dictionary. Instead, the value ``10`` is computed on demand." @@ -176,7 +160,7 @@ msgstr "" "請注意,數值 ``10`` 並不儲存在類別字典或實例字典中。相反地,數值 ``10`` 是按" "需計算的。" -#: ../../howto/descriptor.rst:81 +#: ../../howto/descriptor.rst:78 msgid "" "This example shows how a simple descriptor works, but it isn't very useful. " "For retrieving constants, normal attribute lookup would be better." @@ -184,22 +168,22 @@ msgstr "" "這個範例顯示了簡單描述器的運作方式,但它並不是很有用。對於取得常數,一般的屬" "性查找會比較好。" -#: ../../howto/descriptor.rst:84 +#: ../../howto/descriptor.rst:81 msgid "" "In the next section, we'll create something more useful, a dynamic lookup." msgstr "在下一個章節中,我們將建立更有用的東西:動態查找。" -#: ../../howto/descriptor.rst:88 +#: ../../howto/descriptor.rst:85 msgid "Dynamic lookups" msgstr "動態查找" -#: ../../howto/descriptor.rst:90 +#: ../../howto/descriptor.rst:87 msgid "" "Interesting descriptors typically run computations instead of returning " "constants:" msgstr "有趣的描述器通常執行計算而不是回傳常數:" -#: ../../howto/descriptor.rst:93 +#: ../../howto/descriptor.rst:90 msgid "" "import os\n" "\n" @@ -229,13 +213,13 @@ msgstr "" " def __init__(self, dirname):\n" " self.dirname = dirname # 一般實例屬性" -#: ../../howto/descriptor.rst:109 +#: ../../howto/descriptor.rst:106 msgid "" "An interactive session shows that the lookup is dynamic — it computes " "different, updated answers each time::" msgstr "互動式工作階段顯示查找是動態的——每次都會計算不同的更新答案: ::" -#: ../../howto/descriptor.rst:112 +#: ../../howto/descriptor.rst:109 msgid "" ">>> s = Directory('songs')\n" ">>> g = Directory('games')\n" @@ -260,7 +244,7 @@ msgstr "" ">>> g.size # 檔案數量自動更新\n" "2" -#: ../../howto/descriptor.rst:122 +#: ../../howto/descriptor.rst:119 msgid "" "Besides showing how descriptors can run computations, this example also " "reveals the purpose of the parameters to :meth:`~object.__get__`. The " @@ -274,11 +258,11 @@ msgstr "" "*s*,一個 *Directory* 的實例。正是 *obj* 參數讓 :meth:`~object.__get__` 方法" "得知目標目錄。*objtype* 參數是類別 *Directory*。" -#: ../../howto/descriptor.rst:131 +#: ../../howto/descriptor.rst:128 msgid "Managed attributes" msgstr "受管理的屬性" -#: ../../howto/descriptor.rst:133 +#: ../../howto/descriptor.rst:130 msgid "" "A popular use for descriptors is managing access to instance data. The " "descriptor is assigned to a public attribute in the class dictionary while " @@ -290,7 +274,7 @@ msgstr "" "性,而實際資料則儲存為實例字典中的私有屬性。當存取公開屬性時,會觸發描述器" "的 :meth:`~object.__get__` 和 :meth:`~object.__set__` 方法。" -#: ../../howto/descriptor.rst:139 +#: ../../howto/descriptor.rst:136 msgid "" "In the following example, *age* is the public attribute and *_age* is the " "private attribute. When the public attribute is accessed, the descriptor " @@ -299,7 +283,7 @@ msgstr "" "在以下範例中,*age* 是公開屬性,*_age* 是私有屬性。當存取公開屬性時,描述器會" "記錄查找或更新:" -#: ../../howto/descriptor.rst:143 +#: ../../howto/descriptor.rst:140 msgid "" "import logging\n" "\n" @@ -353,7 +337,7 @@ msgstr "" " def birthday(self):\n" " self.age += 1 # 同時呼叫 __get__() 和 __set__()" -#: ../../howto/descriptor.rst:172 +#: ../../howto/descriptor.rst:169 msgid "" "An interactive session shows that all access to the managed attribute *age* " "is logged, but that the regular attribute *name* is not logged:" @@ -361,7 +345,7 @@ msgstr "" "互動式工作階段顯示對受管理屬性 *age* 的所有存取都被記錄,但一般屬性 *name* 則" "不會被記錄:" -#: ../../howto/descriptor.rst:181 +#: ../../howto/descriptor.rst:178 msgid "" ">>> mary = Person('Mary M', 30) # The initial age update is logged\n" "INFO:root:Updating 'age' to 30\n" @@ -413,7 +397,7 @@ msgstr "" "INFO:root:Accessing 'age' giving 40\n" "40" -#: ../../howto/descriptor.rst:206 +#: ../../howto/descriptor.rst:203 msgid "" "One major issue with this example is that the private name *_age* is " "hardwired in the *LoggedAgeAccess* class. That means that each instance can " @@ -424,17 +408,17 @@ msgstr "" "的。這意味著每個實例只能有一個被記錄的屬性,而且它的名稱是不可變的。在下一個" "範例中,我們將修正這個問題。" -#: ../../howto/descriptor.rst:213 +#: ../../howto/descriptor.rst:210 msgid "Customized names" msgstr "自訂名稱" -#: ../../howto/descriptor.rst:215 +#: ../../howto/descriptor.rst:212 msgid "" "When a class uses descriptors, it can inform each descriptor about which " "variable name was used." msgstr "當類別使用描述器時,它可以告知每個描述器使用了哪個變數名稱。" -#: ../../howto/descriptor.rst:218 +#: ../../howto/descriptor.rst:215 msgid "" "In this example, the :class:`!Person` class has two descriptor instances, " "*name* and *age*. When the :class:`!Person` class is defined, it makes a " @@ -447,7 +431,7 @@ msgstr "" "__set_name__` 進行回呼,以便記錄欄位名稱,讓每個描述器都有自己的 " "*public_name* 和 *private_name*:" -#: ../../howto/descriptor.rst:223 +#: ../../howto/descriptor.rst:220 msgid "" "import logging\n" "\n" @@ -511,14 +495,14 @@ msgstr "" " def birthday(self):\n" " self.age += 1" -#: ../../howto/descriptor.rst:256 +#: ../../howto/descriptor.rst:253 msgid "" "An interactive session shows that the :class:`!Person` class has called :" "meth:`~object.__set_name__` so that the field names would be recorded. Here " "we call :func:`vars` to look up the descriptor without triggering it:" msgstr "" -#: ../../howto/descriptor.rst:260 +#: ../../howto/descriptor.rst:257 msgid "" ">>> vars(vars(Person)['name'])\n" "{'public_name': 'name', 'private_name': '_name'}\n" @@ -530,11 +514,11 @@ msgstr "" ">>> vars(vars(Person)['age'])\n" "{'public_name': 'age', 'private_name': '_age'}" -#: ../../howto/descriptor.rst:267 +#: ../../howto/descriptor.rst:264 msgid "The new class now logs access to both *name* and *age*:" msgstr "新類別現在記錄對 *name* 和 *age* 的存取:" -#: ../../howto/descriptor.rst:275 +#: ../../howto/descriptor.rst:272 msgid "" ">>> pete = Person('Peter P', 10)\n" "INFO:root:Updating 'name' to 'Peter P'\n" @@ -550,11 +534,11 @@ msgstr "" "INFO:root:Updating 'name' to 'Catherine C'\n" "INFO:root:Updating 'age' to 20" -#: ../../howto/descriptor.rst:284 +#: ../../howto/descriptor.rst:281 msgid "The two *Person* instances contain only the private names:" msgstr "兩個 *Person* 實例只包含私有名稱:" -#: ../../howto/descriptor.rst:286 +#: ../../howto/descriptor.rst:283 msgid "" ">>> vars(pete)\n" "{'_name': 'Peter P', '_age': 10}\n" @@ -566,11 +550,11 @@ msgstr "" ">>> vars(kate)\n" "{'_name': 'Catherine C', '_age': 20}" -#: ../../howto/descriptor.rst:295 +#: ../../howto/descriptor.rst:292 msgid "Closing thoughts" msgstr "結語" -#: ../../howto/descriptor.rst:297 +#: ../../howto/descriptor.rst:294 msgid "" "A :term:`descriptor` is what we call any object that defines :meth:`~object." "__get__`, :meth:`~object.__set__`, or :meth:`~object.__delete__`." @@ -578,7 +562,7 @@ msgstr "" ":term:`描述器 ` 是我們對任何定義了 :meth:`~object.__get__`、:" "meth:`~object.__set__` 或 :meth:`~object.__delete__` 的物件的稱呼。" -#: ../../howto/descriptor.rst:300 +#: ../../howto/descriptor.rst:297 msgid "" "Optionally, descriptors can have a :meth:`~object.__set_name__` method. " "This is only used in cases where a descriptor needs to know either the class " @@ -589,7 +573,7 @@ msgstr "" "道建立它的類別或被指派的類別變數名稱時使用。(此方法如果存在,即使類別不是描" "述器也會被呼叫。)" -#: ../../howto/descriptor.rst:305 +#: ../../howto/descriptor.rst:302 msgid "" "Descriptors get invoked by the dot operator during attribute lookup. If a " "descriptor is accessed indirectly with ``vars(some_class)" @@ -598,13 +582,13 @@ msgstr "" "描述器在屬性查找期間由點運算子呼叫。如果描述器是透過 ``vars(some_class)" "[descriptor_name]`` 間接存取,會回傳描述器實例而不呼叫它。" -#: ../../howto/descriptor.rst:309 +#: ../../howto/descriptor.rst:306 msgid "" "Descriptors only work when used as class variables. When put in instances, " "they have no effect." msgstr "描述器只有在用作類別變數時才能運作。當放在實例中時,它們沒有效果。" -#: ../../howto/descriptor.rst:312 +#: ../../howto/descriptor.rst:309 msgid "" "The main motivation for descriptors is to provide a hook allowing objects " "stored in class variables to control what happens during attribute lookup." @@ -612,7 +596,7 @@ msgstr "" "描述器的主要動機是提供一個掛鉤,讓儲存在類別變數中的物件能夠控制屬性查找期間" "發生的事情。" -#: ../../howto/descriptor.rst:315 +#: ../../howto/descriptor.rst:312 msgid "" "Traditionally, the calling class controls what happens during lookup. " "Descriptors invert that relationship and allow the data being looked-up to " @@ -621,7 +605,7 @@ msgstr "" "傳統上,呼叫的類別控制查找期間發生的事情。描述器顛倒了這種關係,讓被查找的資" "料在這件事上有發言權。" -#: ../../howto/descriptor.rst:319 +#: ../../howto/descriptor.rst:316 msgid "" "Descriptors are used throughout the language. It is how functions turn into " "bound methods. Common tools like :deco:`classmethod`, :deco:" @@ -632,11 +616,11 @@ msgstr "" "如 :deco:`classmethod`、:deco:`staticmethod`、:deco:`property` " "和 :deco:`functools.cached_property` 都是以描述器實作的。" -#: ../../howto/descriptor.rst:326 +#: ../../howto/descriptor.rst:323 msgid "Complete Practical Example" msgstr "完整實用範例" -#: ../../howto/descriptor.rst:328 +#: ../../howto/descriptor.rst:325 msgid "" "In this example, we create a practical and powerful tool for locating " "notoriously hard to find data corruption bugs." @@ -644,11 +628,11 @@ msgstr "" "在這個範例中,我們建立一個實用且強大的工具,用於找出惡名昭彰且難以發現的資料" "損壞錯誤。" -#: ../../howto/descriptor.rst:333 +#: ../../howto/descriptor.rst:330 msgid "Validator class" msgstr "驗證器類別" -#: ../../howto/descriptor.rst:335 +#: ../../howto/descriptor.rst:332 msgid "" "A validator is a descriptor for managed attribute access. Prior to storing " "any data, it verifies that the new value meets various type and range " @@ -659,7 +643,7 @@ msgstr "" "合各種型別和範圍限制。如果不符合這些限制,它會引發例外以防止資料在源頭被損" "壞。" -#: ../../howto/descriptor.rst:340 +#: ../../howto/descriptor.rst:337 msgid "" "This :class:`!Validator` class is both an :term:`abstract base class` and a " "managed attribute descriptor:" @@ -667,7 +651,7 @@ msgstr "" "這個 :class:`!Validator` 類別既是 :term:`抽象基底類別 ` " "也是受管理屬性描述器:" -#: ../../howto/descriptor.rst:343 +#: ../../howto/descriptor.rst:340 msgid "" "from abc import ABC, abstractmethod\n" "\n" @@ -705,7 +689,7 @@ msgstr "" " def validate(self, value):\n" " pass" -#: ../../howto/descriptor.rst:363 +#: ../../howto/descriptor.rst:360 msgid "" "Custom validators need to inherit from :class:`!Validator` and must supply " "a :meth:`!validate` method to test various restrictions as needed." @@ -713,20 +697,20 @@ msgstr "" "自訂驗證器需要繼承自 :class:`!Validator` 並且必須提供 :meth:`!validate` 方法" "來依需要測試各種限制。" -#: ../../howto/descriptor.rst:368 +#: ../../howto/descriptor.rst:365 msgid "Custom validators" msgstr "自訂驗證器" -#: ../../howto/descriptor.rst:370 +#: ../../howto/descriptor.rst:367 msgid "Here are three practical data validation utilities:" msgstr "以下是三個實用的資料驗證工具:" -#: ../../howto/descriptor.rst:372 +#: ../../howto/descriptor.rst:369 msgid "" ":class:`!OneOf` verifies that a value is one of a restricted set of options." msgstr ":class:`!OneOf` 驗證數值是否為限制選項集合中的其中一個。" -#: ../../howto/descriptor.rst:374 +#: ../../howto/descriptor.rst:371 msgid "" ":class:`!Number` verifies that a value is either an :class:`int` or :class:" "`float`. Optionally, it verifies that a value is between a given minimum or " @@ -735,7 +719,7 @@ msgstr "" ":class:`!Number` 驗證數值是否為 :class:`int` 或 :class:`float`。可選地,它會" "驗證數值是否在給定的最小值或最大值之間。" -#: ../../howto/descriptor.rst:378 +#: ../../howto/descriptor.rst:375 msgid "" ":class:`!String` verifies that a value is a :class:`str`. Optionally, it " "validates a given minimum or maximum length. It can validate a user-defined " @@ -746,7 +730,7 @@ msgstr "" "大長度。它還可以驗證使用者定義的 `述詞 `_。" -#: ../../howto/descriptor.rst:383 +#: ../../howto/descriptor.rst:380 msgid "" "class OneOf(Validator):\n" "\n" @@ -802,15 +786,15 @@ msgid "" " )" msgstr "" -#: ../../howto/descriptor.rst:439 +#: ../../howto/descriptor.rst:436 msgid "Practical application" msgstr "實際應用" -#: ../../howto/descriptor.rst:441 +#: ../../howto/descriptor.rst:438 msgid "Here's how the data validators can be used in a real class:" msgstr "以下展示如何在真實類別中使用資料驗證器:" -#: ../../howto/descriptor.rst:443 +#: ../../howto/descriptor.rst:440 msgid "" "class Component:\n" "\n" @@ -824,11 +808,11 @@ msgid "" " self.quantity = quantity" msgstr "" -#: ../../howto/descriptor.rst:456 +#: ../../howto/descriptor.rst:453 msgid "The descriptors prevent invalid instances from being created:" msgstr "描述器防止建立無效的實例:" -#: ../../howto/descriptor.rst:458 +#: ../../howto/descriptor.rst:455 msgid "" ">>> Component('Widget', 'metal', 5) # Blocked: 'Widget' is not all " "uppercase\n" @@ -877,21 +861,21 @@ msgstr "" "\n" ">>> c = Component('WIDGET', 'metal', 5) # 允許:輸入有效" -#: ../../howto/descriptor.rst:484 +#: ../../howto/descriptor.rst:481 msgid "Technical Tutorial" msgstr "技術教學" -#: ../../howto/descriptor.rst:486 +#: ../../howto/descriptor.rst:483 msgid "" "What follows is a more technical tutorial for the mechanics and details of " "how descriptors work." msgstr "接下來是關於描述器運作機制和細節的更技術性教學。" -#: ../../howto/descriptor.rst:491 +#: ../../howto/descriptor.rst:488 msgid "Abstract" msgstr "摘要" -#: ../../howto/descriptor.rst:493 +#: ../../howto/descriptor.rst:490 msgid "" "Defines descriptors, summarizes the protocol, and shows how descriptors are " "called. Provides an example showing how object relational mappings work." @@ -899,17 +883,17 @@ msgstr "" "定義描述器、總結協定,並展示描述器如何被呼叫。提供展示物件關聯映射如何運作的" "範例。" -#: ../../howto/descriptor.rst:496 +#: ../../howto/descriptor.rst:493 msgid "" "Learning about descriptors not only provides access to a larger toolset, it " "creates a deeper understanding of how Python works." msgstr "學習描述器不僅提供更大的工具集,還能更深入理解 Python 的運作方式。" -#: ../../howto/descriptor.rst:501 +#: ../../howto/descriptor.rst:498 msgid "Definition and introduction" msgstr "定義與介紹" -#: ../../howto/descriptor.rst:503 +#: ../../howto/descriptor.rst:500 msgid "" "In general, a descriptor is an attribute value that has one of the methods " "in the descriptor protocol. Those methods are :meth:`~object.__get__`, :" @@ -920,7 +904,7 @@ msgstr "" "`~object.__get__`、:meth:`~object.__set__` 和 :meth:`~object.__delete__`。如" "果為屬性定義了其中任何一個方法,就稱為 :term:`描述器 `。" -#: ../../howto/descriptor.rst:508 +#: ../../howto/descriptor.rst:505 msgid "" "The default behavior for attribute access is to get, set, or delete the " "attribute from an object's dictionary. For instance, ``a.x`` has a lookup " @@ -937,7 +921,7 @@ msgstr "" "件,那麼 Python 可能會覆蓋預設行為並改為呼叫描述器方法。這在優先順序鏈中發生" "的位置取決於定義了哪些描述器方法。" -#: ../../howto/descriptor.rst:517 +#: ../../howto/descriptor.rst:514 msgid "" "Descriptors are a powerful, general purpose protocol. They are the " "mechanism behind properties, methods, static methods, class methods, and :" @@ -949,23 +933,23 @@ msgstr "" "`super` 背後的機制。它們在 Python 本身中廣泛使用。描述器簡化了底層 C 程式碼," "並為日常 Python 程式提供靈活的新工具集。" -#: ../../howto/descriptor.rst:525 +#: ../../howto/descriptor.rst:522 msgid "Descriptor protocol" msgstr "描述器協定" -#: ../../howto/descriptor.rst:527 +#: ../../howto/descriptor.rst:524 msgid "``descr.__get__(self, obj, type=None)``" msgstr "``descr.__get__(self, obj, type=None)``" -#: ../../howto/descriptor.rst:529 +#: ../../howto/descriptor.rst:526 msgid "``descr.__set__(self, obj, value)``" msgstr "``descr.__set__(self, obj, value)``" -#: ../../howto/descriptor.rst:531 +#: ../../howto/descriptor.rst:528 msgid "``descr.__delete__(self, obj)``" msgstr "``descr.__delete__(self, obj)``" -#: ../../howto/descriptor.rst:533 +#: ../../howto/descriptor.rst:530 msgid "" "That is all there is to it. Define any of these methods and an object is " "considered a descriptor and can override default behavior upon being looked " @@ -974,7 +958,7 @@ msgstr "" "就是這樣而已。定義其中任何一個方法,物件就被視為描述器,並且可以在作為屬性被" "查找時覆蓋預設行為。" -#: ../../howto/descriptor.rst:537 +#: ../../howto/descriptor.rst:534 msgid "" "If an object defines :meth:`~object.__set__` or :meth:`~object.__delete__`, " "it is considered a data descriptor. Descriptors that only define :meth:" @@ -985,7 +969,7 @@ msgstr "" "為資料描述器。只定義 :meth:`~object.__get__` 的描述器稱為非資料描述器(它們通" "常用於方法,但也有其他用途)。" -#: ../../howto/descriptor.rst:542 +#: ../../howto/descriptor.rst:539 msgid "" "Data and non-data descriptors differ in how overrides are calculated with " "respect to entries in an instance's dictionary. If an instance's dictionary " @@ -997,7 +981,7 @@ msgstr "" "實例的字典有與資料描述器同名的條目,資料描述器具有優先權。如果實例的字典有與" "非資料描述器同名的條目,字典條目具有優先權。" -#: ../../howto/descriptor.rst:548 +#: ../../howto/descriptor.rst:545 msgid "" "To make a read-only data descriptor, define both :meth:`~object.__get__` " "and :meth:`~object.__set__` with the :meth:`~object.__set__` raising an :exc:" @@ -1008,11 +992,11 @@ msgstr "" "__set__`,並讓 :meth:`~object.__set__` 在被呼叫時引發 :exc:`AttributeError`。" "定義引發例外佔位符的 :meth:`~object.__set__` 方法就足以讓它成為資料描述器。" -#: ../../howto/descriptor.rst:555 +#: ../../howto/descriptor.rst:552 msgid "Overview of descriptor invocation" msgstr "描述器呼叫概觀" -#: ../../howto/descriptor.rst:557 +#: ../../howto/descriptor.rst:554 msgid "" "A descriptor can be called directly with ``desc.__get__(obj)`` or ``desc." "__get__(None, cls)``." @@ -1020,13 +1004,13 @@ msgstr "" "描述器可以直接使用 ``desc.__get__(obj)`` 或 ``desc.__get__(None, cls)`` 呼" "叫。" -#: ../../howto/descriptor.rst:560 +#: ../../howto/descriptor.rst:557 msgid "" "But it is more common for a descriptor to be invoked automatically from " "attribute access." msgstr "" -#: ../../howto/descriptor.rst:563 +#: ../../howto/descriptor.rst:560 msgid "" "The expression ``obj.x`` looks up the attribute ``x`` in the chain of " "namespaces for ``obj``. If the search finds a descriptor outside of the " @@ -1034,17 +1018,17 @@ msgid "" "invoked according to the precedence rules listed below." msgstr "" -#: ../../howto/descriptor.rst:568 +#: ../../howto/descriptor.rst:565 msgid "" "The details of invocation depend on whether ``obj`` is an object, class, or " "instance of super." msgstr "" -#: ../../howto/descriptor.rst:573 +#: ../../howto/descriptor.rst:570 msgid "Invocation from an instance" msgstr "從實例呼叫" -#: ../../howto/descriptor.rst:575 +#: ../../howto/descriptor.rst:572 msgid "" "Instance lookup scans through a chain of namespaces giving data descriptors " "the highest priority, followed by instance variables, then non-data " @@ -1054,21 +1038,21 @@ msgstr "" "實例查找掃描命名空間鏈,給予資料描述器最高優先權,接著是實例變數,然後是非資" "料描述器,再來是類別變數,最後如果有提供的話是 :meth:`~object.__getattr__`。" -#: ../../howto/descriptor.rst:580 +#: ../../howto/descriptor.rst:577 msgid "" "If a descriptor is found for ``a.x``, then it is invoked with: ``desc." "__get__(a, type(a))``." msgstr "" "如果為 ``a.x`` 找到描述器,則使用 ``desc.__get__(a, type(a))`` 呼叫它。" -#: ../../howto/descriptor.rst:583 +#: ../../howto/descriptor.rst:580 msgid "" "The logic for a dotted lookup is in :meth:`object.__getattribute__`. Here " "is a pure Python equivalent:" msgstr "" "點查找的邏輯在 :meth:`object.__getattribute__` 中。這裡是純 Python 等價實作:" -#: ../../howto/descriptor.rst:586 +#: ../../howto/descriptor.rst:583 msgid "" "def find_name_in_mro(cls, name, default):\n" " \"Emulate _PyType_Lookup() in Objects/typeobject.c\"\n" @@ -1079,7 +1063,7 @@ msgid "" "\n" "def object_getattribute(obj, name):\n" " \"Emulate PyObject_GenericGetAttr() in Objects/object.c\"\n" -" null = object()\n" +" null = sentinel('null')\n" " objtype = type(obj)\n" " cls_var = find_name_in_mro(objtype, name, null)\n" " descr_get = getattr(type(cls_var), '__get__', null)\n" @@ -1096,8 +1080,32 @@ msgid "" " return cls_var # class variable\n" " raise AttributeError(name)" msgstr "" +"def find_name_in_mro(cls, name, default):\n" +" \"Emulate _PyType_Lookup() in Objects/typeobject.c\"\n" +" for base in cls.__mro__:\n" +" if name in vars(base):\n" +" return vars(base)[name]\n" +" return default\n" +"\n" +"def object_getattribute(obj, name):\n" +" \"Emulate PyObject_GenericGetAttr() in Objects/object.c\"\n" +" null = sentinel('null')\n" +" objtype = type(obj)\n" +" cls_var = find_name_in_mro(objtype, name, null)\n" +" descr_get = getattr(type(cls_var), '__get__', null)\n" +" if descr_get is not null:\n" +" if (hasattr(type(cls_var), '__set__')\n" +" or hasattr(type(cls_var), '__delete__')):\n" +" return descr_get(cls_var, obj, objtype) # 資料描述器\n" +" if hasattr(obj, '__dict__') and name in vars(obj):\n" +" return vars(obj)[name] # 實例變數\n" +" if descr_get is not null:\n" +" return descr_get(cls_var, obj, objtype) # 非資料描述器\n" +" if cls_var is not null:\n" +" return cls_var # 類別變數\n" +" raise AttributeError(name)" -#: ../../howto/descriptor.rst:722 +#: ../../howto/descriptor.rst:719 msgid "" "Note, there is no :meth:`~object.__getattr__` hook in the :meth:`~object." "__getattribute__` code. That is why calling :meth:`~object." @@ -1105,7 +1113,7 @@ msgid "" "meth:`~object.__getattr__` entirely." msgstr "" -#: ../../howto/descriptor.rst:726 +#: ../../howto/descriptor.rst:723 msgid "" "Instead, it is the dot operator and the :func:`getattr` function that are " "responsible for invoking :meth:`~object.__getattr__` whenever :meth:`~object." @@ -1113,7 +1121,7 @@ msgid "" "encapsulated in a helper function:" msgstr "" -#: ../../howto/descriptor.rst:731 +#: ../../howto/descriptor.rst:728 msgid "" "def getattr_hook(obj, name):\n" " \"Emulate slot_tp_getattr_hook() in Objects/typeobject.c\"\n" @@ -1133,11 +1141,11 @@ msgstr "" " raise\n" " return type(obj).__getattr__(obj, name) # __getattr__" -#: ../../howto/descriptor.rst:776 +#: ../../howto/descriptor.rst:773 msgid "Invocation from a class" msgstr "從類別呼叫" -#: ../../howto/descriptor.rst:778 +#: ../../howto/descriptor.rst:775 msgid "" "The logic for a dotted lookup such as ``A.x`` is in :meth:`!type." "__getattribute__`. The steps are similar to those for :meth:`!object." @@ -1145,27 +1153,27 @@ msgid "" "through the class's :term:`method resolution order`." msgstr "" -#: ../../howto/descriptor.rst:783 +#: ../../howto/descriptor.rst:780 msgid "If a descriptor is found, it is invoked with ``desc.__get__(None, A)``." msgstr "如果找到描述器,則使用 ``desc.__get__(None, A)`` 呼叫它。" -#: ../../howto/descriptor.rst:785 +#: ../../howto/descriptor.rst:782 msgid "" "The full C implementation can be found in :c:func:`!type_getattro` and :c:" "func:`!_PyType_Lookup` in :source:`Objects/typeobject.c`." msgstr "" -#: ../../howto/descriptor.rst:790 +#: ../../howto/descriptor.rst:787 msgid "Invocation from super" msgstr "" -#: ../../howto/descriptor.rst:792 +#: ../../howto/descriptor.rst:789 msgid "" "The logic for super's dotted lookup is in the :meth:`~object." "__getattribute__` method for object returned by :func:`super`." msgstr "" -#: ../../howto/descriptor.rst:795 +#: ../../howto/descriptor.rst:792 msgid "" "A dotted lookup such as ``super(A, obj).m`` searches ``obj.__class__." "__mro__`` for the base class ``B`` immediately following ``A`` and then " @@ -1173,7 +1181,7 @@ msgid "" "returned unchanged." msgstr "" -#: ../../howto/descriptor.rst:800 +#: ../../howto/descriptor.rst:797 msgid "" "The full C implementation can be found in :c:func:`!super_getattro` in :" "source:`Objects/typeobject.c`. A pure Python equivalent can be found in " @@ -1181,38 +1189,38 @@ msgid "" "#cooperation>`_." msgstr "" -#: ../../howto/descriptor.rst:807 +#: ../../howto/descriptor.rst:804 msgid "Summary of invocation logic" msgstr "" -#: ../../howto/descriptor.rst:809 +#: ../../howto/descriptor.rst:806 msgid "" "The mechanism for descriptors is embedded in the :meth:`~object." "__getattribute__` methods for :class:`object`, :class:`type`, and :func:" "`super`." msgstr "" -#: ../../howto/descriptor.rst:812 +#: ../../howto/descriptor.rst:809 msgid "The important points to remember are:" msgstr "要記住的重點是:" -#: ../../howto/descriptor.rst:814 +#: ../../howto/descriptor.rst:811 msgid "Descriptors are invoked by the :meth:`~object.__getattribute__` method." msgstr "" -#: ../../howto/descriptor.rst:816 +#: ../../howto/descriptor.rst:813 msgid "" "Classes inherit this machinery from :class:`object`, :class:`type`, or :func:" "`super`." msgstr "" -#: ../../howto/descriptor.rst:819 +#: ../../howto/descriptor.rst:816 msgid "" "Overriding :meth:`~object.__getattribute__` prevents automatic descriptor " "calls because all the descriptor logic is in that method." msgstr "" -#: ../../howto/descriptor.rst:822 +#: ../../howto/descriptor.rst:819 msgid "" ":meth:`!object.__getattribute__` and :meth:`!type.__getattribute__` make " "different calls to :meth:`~object.__get__`. The first includes the instance " @@ -1220,19 +1228,19 @@ msgid "" "always includes the class." msgstr "" -#: ../../howto/descriptor.rst:827 +#: ../../howto/descriptor.rst:824 msgid "Data descriptors always override instance dictionaries." msgstr "" -#: ../../howto/descriptor.rst:829 +#: ../../howto/descriptor.rst:826 msgid "Non-data descriptors may be overridden by instance dictionaries." msgstr "" -#: ../../howto/descriptor.rst:833 +#: ../../howto/descriptor.rst:830 msgid "Automatic name notification" msgstr "" -#: ../../howto/descriptor.rst:835 +#: ../../howto/descriptor.rst:832 msgid "" "Sometimes it is desirable for a descriptor to know what class variable name " "it was assigned to. When a new class is created, the :class:`type` " @@ -1242,38 +1250,38 @@ msgid "" "used, and the *name* is the class variable the descriptor was assigned to." msgstr "" -#: ../../howto/descriptor.rst:842 +#: ../../howto/descriptor.rst:839 msgid "" "The implementation details are in :c:func:`!type_new` and :c:func:`!" "set_names` in :source:`Objects/typeobject.c`." msgstr "" -#: ../../howto/descriptor.rst:845 +#: ../../howto/descriptor.rst:842 msgid "" "Since the update logic is in :meth:`!type.__new__`, notifications only take " "place at the time of class creation. If descriptors are added to the class " "afterwards, :meth:`~object.__set_name__` will need to be called manually." msgstr "" -#: ../../howto/descriptor.rst:851 +#: ../../howto/descriptor.rst:848 msgid "ORM example" msgstr "ORM 範例" -#: ../../howto/descriptor.rst:853 +#: ../../howto/descriptor.rst:850 msgid "" "The following code is a simplified skeleton showing how data descriptors " "could be used to implement an `object relational mapping `_." msgstr "" -#: ../../howto/descriptor.rst:857 +#: ../../howto/descriptor.rst:854 msgid "" "The essential idea is that the data is stored in an external database. The " "Python instances only hold keys to the database's tables. Descriptors take " "care of lookups or updates:" msgstr "" -#: ../../howto/descriptor.rst:861 +#: ../../howto/descriptor.rst:858 msgid "" "class Field:\n" "\n" @@ -1305,14 +1313,14 @@ msgstr "" " conn.execute(self.store, [value, obj.key])\n" " conn.commit()" -#: ../../howto/descriptor.rst:876 +#: ../../howto/descriptor.rst:873 msgid "" "We can use the :class:`!Field` class to define `models `_ that describe the schema for each table in a " "database:" msgstr "" -#: ../../howto/descriptor.rst:880 +#: ../../howto/descriptor.rst:877 msgid "" "class Movie:\n" " table = 'Movies' # Table name\n" @@ -1334,11 +1342,11 @@ msgid "" " self.key = key" msgstr "" -#: ../../howto/descriptor.rst:901 +#: ../../howto/descriptor.rst:898 msgid "To use the models, first connect to the database::" msgstr "" -#: ../../howto/descriptor.rst:903 +#: ../../howto/descriptor.rst:900 msgid "" ">>> import sqlite3\n" ">>> conn = sqlite3.connect('entertainment.db')" @@ -1346,13 +1354,13 @@ msgstr "" ">>> import sqlite3\n" ">>> conn = sqlite3.connect('entertainment.db')" -#: ../../howto/descriptor.rst:906 +#: ../../howto/descriptor.rst:903 msgid "" "An interactive session shows how data is retrieved from the database and how " "it can be updated:" msgstr "" -#: ../../howto/descriptor.rst:934 +#: ../../howto/descriptor.rst:931 msgid "" ">>> Movie('Star Wars').director\n" "'George Lucas'\n" @@ -1380,11 +1388,11 @@ msgstr "" ">>> Movie('Star Wars').director\n" "'J.J. Abrams'" -#: ../../howto/descriptor.rst:955 +#: ../../howto/descriptor.rst:952 msgid "Pure Python Equivalents" msgstr "" -#: ../../howto/descriptor.rst:957 +#: ../../howto/descriptor.rst:954 msgid "" "The descriptor protocol is simple and offers exciting possibilities. " "Several use cases are so common that they have been prepackaged into built-" @@ -1392,27 +1400,27 @@ msgid "" "\\_\\_slots\\_\\_ are all based on the descriptor protocol." msgstr "" -#: ../../howto/descriptor.rst:964 +#: ../../howto/descriptor.rst:961 msgid "Properties" msgstr "" -#: ../../howto/descriptor.rst:966 +#: ../../howto/descriptor.rst:963 msgid "" "Calling :func:`property` is a succinct way of building a data descriptor " "that triggers a function call upon access to an attribute. Its signature " "is::" msgstr "" -#: ../../howto/descriptor.rst:969 +#: ../../howto/descriptor.rst:966 msgid "property(fget=None, fset=None, fdel=None, doc=None) -> property" msgstr "property(fget=None, fset=None, fdel=None, doc=None) -> property" -#: ../../howto/descriptor.rst:971 +#: ../../howto/descriptor.rst:968 msgid "" "The documentation shows a typical use to define a managed attribute ``x``:" msgstr "" -#: ../../howto/descriptor.rst:973 +#: ../../howto/descriptor.rst:970 msgid "" "class C:\n" " def getx(self): return self.__x\n" @@ -1426,14 +1434,14 @@ msgstr "" " def delx(self): del self.__x\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../howto/descriptor.rst:995 +#: ../../howto/descriptor.rst:992 msgid "" "To see how :func:`property` is implemented in terms of the descriptor " "protocol, here is a pure Python equivalent that implements most of the core " "functionality:" msgstr "" -#: ../../howto/descriptor.rst:998 +#: ../../howto/descriptor.rst:995 msgid "" "class Property:\n" " \"Emulate PyProperty_Type() in Objects/descrobject.c\"\n" @@ -1476,14 +1484,14 @@ msgid "" " return type(self)(self.fget, self.fset, fdel, self.__doc__)" msgstr "" -#: ../../howto/descriptor.rst:1122 +#: ../../howto/descriptor.rst:1119 msgid "" "The :func:`property` builtin helps whenever a user interface has granted " "attribute access and then subsequent changes require the intervention of a " "method." msgstr "" -#: ../../howto/descriptor.rst:1126 +#: ../../howto/descriptor.rst:1123 msgid "" "For instance, a spreadsheet class may grant access to a cell value through " "``Cell('b10').value``. Subsequent improvements to the program require the " @@ -1493,7 +1501,7 @@ msgid "" "descriptor:" msgstr "" -#: ../../howto/descriptor.rst:1132 +#: ../../howto/descriptor.rst:1129 msgid "" "class Cell:\n" " ...\n" @@ -1505,23 +1513,23 @@ msgid "" " return self._value" msgstr "" -#: ../../howto/descriptor.rst:1143 +#: ../../howto/descriptor.rst:1140 msgid "" "Either the built-in :func:`property` or our :func:`!Property` equivalent " "would work in this example." msgstr "" -#: ../../howto/descriptor.rst:1148 +#: ../../howto/descriptor.rst:1145 msgid "Functions and methods" msgstr "" -#: ../../howto/descriptor.rst:1150 +#: ../../howto/descriptor.rst:1147 msgid "" "Python's object oriented features are built upon a function based " "environment. Using non-data descriptors, the two are merged seamlessly." msgstr "" -#: ../../howto/descriptor.rst:1153 +#: ../../howto/descriptor.rst:1150 msgid "" "Functions stored in class dictionaries get turned into methods when invoked. " "Methods only differ from regular functions in that the object instance is " @@ -1529,13 +1537,13 @@ msgid "" "*self* but could be called *this* or any other variable name." msgstr "" -#: ../../howto/descriptor.rst:1158 +#: ../../howto/descriptor.rst:1155 msgid "" "Methods can be created manually with :class:`types.MethodType` which is " "roughly equivalent to:" msgstr "" -#: ../../howto/descriptor.rst:1161 +#: ../../howto/descriptor.rst:1158 msgid "" "class MethodType:\n" " \"Emulate PyMethod_Type in Objects/classobject.c\"\n" @@ -1564,7 +1572,7 @@ msgid "" " return self" msgstr "" -#: ../../howto/descriptor.rst:1189 +#: ../../howto/descriptor.rst:1186 msgid "" "To support automatic creation of methods, functions include the :meth:" "`~object.__get__` method for binding methods during attribute access. This " @@ -1572,7 +1580,7 @@ msgid "" "during dotted lookup from an instance. Here's how it works:" msgstr "" -#: ../../howto/descriptor.rst:1194 +#: ../../howto/descriptor.rst:1191 msgid "" "class Function:\n" " ...\n" @@ -1584,13 +1592,13 @@ msgid "" " return MethodType(self, obj)" msgstr "" -#: ../../howto/descriptor.rst:1205 +#: ../../howto/descriptor.rst:1202 msgid "" "Running the following class in the interpreter shows how the function " "descriptor works in practice:" msgstr "" -#: ../../howto/descriptor.rst:1208 +#: ../../howto/descriptor.rst:1205 msgid "" "class D:\n" " def f(self):\n" @@ -1606,12 +1614,12 @@ msgstr "" "class D2:\n" " pass" -#: ../../howto/descriptor.rst:1226 +#: ../../howto/descriptor.rst:1223 msgid "" "The function has a :term:`qualified name` attribute to support introspection:" msgstr "" -#: ../../howto/descriptor.rst:1228 +#: ../../howto/descriptor.rst:1225 msgid "" ">>> D.f.__qualname__\n" "'D.f'" @@ -1619,13 +1627,13 @@ msgstr "" ">>> D.f.__qualname__\n" "'D.f'" -#: ../../howto/descriptor.rst:1233 +#: ../../howto/descriptor.rst:1230 msgid "" "Accessing the function through the class dictionary does not invoke :meth:" "`~object.__get__`. Instead, it just returns the underlying function object::" msgstr "" -#: ../../howto/descriptor.rst:1236 +#: ../../howto/descriptor.rst:1233 msgid "" ">>> D.__dict__['f']\n" "" @@ -1633,13 +1641,13 @@ msgstr "" ">>> D.__dict__['f']\n" "" -#: ../../howto/descriptor.rst:1239 +#: ../../howto/descriptor.rst:1236 msgid "" "Dotted access from a class calls :meth:`~object.__get__` which just returns " "the underlying function unchanged::" msgstr "" -#: ../../howto/descriptor.rst:1242 +#: ../../howto/descriptor.rst:1239 msgid "" ">>> D.f\n" "" @@ -1647,14 +1655,14 @@ msgstr "" ">>> D.f\n" "" -#: ../../howto/descriptor.rst:1245 +#: ../../howto/descriptor.rst:1242 msgid "" "The interesting behavior occurs during dotted access from an instance. The " "dotted lookup calls :meth:`~object.__get__` which returns a bound method " "object::" msgstr "" -#: ../../howto/descriptor.rst:1248 +#: ../../howto/descriptor.rst:1245 msgid "" ">>> d = D()\n" ">>> d.f\n" @@ -1664,13 +1672,13 @@ msgstr "" ">>> d.f\n" ">" -#: ../../howto/descriptor.rst:1252 +#: ../../howto/descriptor.rst:1249 msgid "" "Internally, the bound method stores the underlying function and the bound " "instance::" msgstr "" -#: ../../howto/descriptor.rst:1255 +#: ../../howto/descriptor.rst:1252 msgid "" ">>> d.f.__func__\n" "\n" @@ -1684,23 +1692,23 @@ msgstr "" ">>> d.f.__self__\n" "<__main__.D object at 0x00B18C90>" -#: ../../howto/descriptor.rst:1261 +#: ../../howto/descriptor.rst:1258 msgid "" "If you have ever wondered where *self* comes from in regular methods or " "where *cls* comes from in class methods, this is it!" msgstr "" -#: ../../howto/descriptor.rst:1266 +#: ../../howto/descriptor.rst:1263 msgid "Kinds of methods" msgstr "" -#: ../../howto/descriptor.rst:1268 +#: ../../howto/descriptor.rst:1265 msgid "" "Non-data descriptors provide a simple mechanism for variations on the usual " "patterns of binding functions into methods." msgstr "" -#: ../../howto/descriptor.rst:1271 +#: ../../howto/descriptor.rst:1268 msgid "" "To recap, functions have a :meth:`~object.__get__` method so that they can " "be converted to a method when accessed as attributes. The non-data " @@ -1708,55 +1716,55 @@ msgid "" "Calling ``cls.f(*args)`` becomes ``f(*args)``." msgstr "" -#: ../../howto/descriptor.rst:1276 +#: ../../howto/descriptor.rst:1273 msgid "This chart summarizes the binding and its two most useful variants:" msgstr "" -#: ../../howto/descriptor.rst:1279 +#: ../../howto/descriptor.rst:1276 msgid "Transformation" msgstr "" -#: ../../howto/descriptor.rst:1279 +#: ../../howto/descriptor.rst:1276 msgid "Called from an object" msgstr "" -#: ../../howto/descriptor.rst:1279 +#: ../../howto/descriptor.rst:1276 msgid "Called from a class" msgstr "" -#: ../../howto/descriptor.rst:1282 +#: ../../howto/descriptor.rst:1279 msgid "function" msgstr "函式" -#: ../../howto/descriptor.rst:1282 +#: ../../howto/descriptor.rst:1279 msgid "f(obj, \\*args)" msgstr "f(obj, \\*args)" -#: ../../howto/descriptor.rst:1282 ../../howto/descriptor.rst:1284 +#: ../../howto/descriptor.rst:1279 ../../howto/descriptor.rst:1281 msgid "f(\\*args)" msgstr "f(\\*args)" -#: ../../howto/descriptor.rst:1284 +#: ../../howto/descriptor.rst:1281 msgid "staticmethod" msgstr "staticmethod" -#: ../../howto/descriptor.rst:1286 +#: ../../howto/descriptor.rst:1283 msgid "classmethod" msgstr "classmethod" -#: ../../howto/descriptor.rst:1286 +#: ../../howto/descriptor.rst:1283 msgid "f(type(obj), \\*args)" msgstr "f(type(obj), \\*args)" -#: ../../howto/descriptor.rst:1286 +#: ../../howto/descriptor.rst:1283 msgid "f(cls, \\*args)" msgstr "f(cls, \\*args)" -#: ../../howto/descriptor.rst:1291 +#: ../../howto/descriptor.rst:1288 msgid "Static methods" msgstr "" -#: ../../howto/descriptor.rst:1293 +#: ../../howto/descriptor.rst:1290 msgid "" "Static methods return the underlying function without changes. Calling " "either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into ``object." @@ -1765,13 +1773,13 @@ msgid "" "a class." msgstr "" -#: ../../howto/descriptor.rst:1299 +#: ../../howto/descriptor.rst:1296 msgid "" "Good candidates for static methods are methods that do not reference the " "``self`` variable." msgstr "" -#: ../../howto/descriptor.rst:1302 +#: ../../howto/descriptor.rst:1299 msgid "" "For instance, a statistics package may include a container class for " "experimental data. The class provides normal methods for computing the " @@ -1783,13 +1791,13 @@ msgid "" "``s.erf(1.5) --> 0.9332`` or ``Sample.erf(1.5) --> 0.9332``." msgstr "" -#: ../../howto/descriptor.rst:1311 +#: ../../howto/descriptor.rst:1308 msgid "" "Since static methods return the underlying function with no changes, the " "example calls are unexciting:" msgstr "" -#: ../../howto/descriptor.rst:1314 +#: ../../howto/descriptor.rst:1311 msgid "" "class E:\n" " @staticmethod\n" @@ -1801,7 +1809,7 @@ msgstr "" " def f(x):\n" " return x * 10" -#: ../../howto/descriptor.rst:1321 +#: ../../howto/descriptor.rst:1318 msgid "" ">>> E.f(3)\n" "30\n" @@ -1813,13 +1821,13 @@ msgstr "" ">>> E().f(3)\n" "30" -#: ../../howto/descriptor.rst:1328 +#: ../../howto/descriptor.rst:1325 msgid "" "Using the non-data descriptor protocol, a pure Python version of :deco:" "`staticmethod` would look like this:" msgstr "" -#: ../../howto/descriptor.rst:1331 +#: ../../howto/descriptor.rst:1328 msgid "" "import functools\n" "\n" @@ -1841,7 +1849,7 @@ msgid "" " return self.f.__annotations__" msgstr "" -#: ../../howto/descriptor.rst:1352 +#: ../../howto/descriptor.rst:1349 msgid "" "The :func:`functools.update_wrapper` call adds a ``__wrapped__`` attribute " "that refers to the underlying function. Also it carries forward the " @@ -1850,18 +1858,18 @@ msgid "" "attr:`~function.__doc__`." msgstr "" -#: ../../howto/descriptor.rst:1421 +#: ../../howto/descriptor.rst:1418 msgid "Class methods" msgstr "" -#: ../../howto/descriptor.rst:1423 +#: ../../howto/descriptor.rst:1420 msgid "" "Unlike static methods, class methods prepend the class reference to the " "argument list before calling the function. This format is the same for " "whether the caller is an object or a class:" msgstr "" -#: ../../howto/descriptor.rst:1427 +#: ../../howto/descriptor.rst:1424 msgid "" "class F:\n" " @classmethod\n" @@ -1873,7 +1881,7 @@ msgstr "" " def f(cls, x):\n" " return cls.__name__, x" -#: ../../howto/descriptor.rst:1434 +#: ../../howto/descriptor.rst:1431 msgid "" ">>> F.f(3)\n" "('F', 3)\n" @@ -1885,7 +1893,7 @@ msgstr "" ">>> F().f(3)\n" "('F', 3)" -#: ../../howto/descriptor.rst:1441 +#: ../../howto/descriptor.rst:1438 msgid "" "This behavior is useful whenever the method only needs to have a class " "reference and does not rely on data stored in a specific instance. One use " @@ -1894,7 +1902,7 @@ msgid "" "of keys. The pure Python equivalent is:" msgstr "" -#: ../../howto/descriptor.rst:1447 +#: ../../howto/descriptor.rst:1444 msgid "" "class Dict(dict):\n" " @classmethod\n" @@ -1906,11 +1914,11 @@ msgid "" " return d" msgstr "" -#: ../../howto/descriptor.rst:1458 +#: ../../howto/descriptor.rst:1455 msgid "Now a new dictionary of unique keys can be constructed like this:" msgstr "" -#: ../../howto/descriptor.rst:1460 +#: ../../howto/descriptor.rst:1457 msgid "" ">>> d = Dict.fromkeys('abracadabra')\n" ">>> type(d) is Dict\n" @@ -1924,13 +1932,13 @@ msgstr "" ">>> d\n" "{'a': None, 'b': None, 'r': None, 'c': None, 'd': None}" -#: ../../howto/descriptor.rst:1468 +#: ../../howto/descriptor.rst:1465 msgid "" "Using the non-data descriptor protocol, a pure Python version of :deco:" "`classmethod` would look like this:" msgstr "" -#: ../../howto/descriptor.rst:1471 +#: ../../howto/descriptor.rst:1468 msgid "" "import functools\n" "\n" @@ -1947,7 +1955,7 @@ msgid "" " return MethodType(self.f, cls)" msgstr "" -#: ../../howto/descriptor.rst:1533 +#: ../../howto/descriptor.rst:1530 msgid "" "The :func:`functools.update_wrapper` call in ``ClassMethod`` adds a " "``__wrapped__`` attribute that refers to the underlying function. Also it " @@ -1957,24 +1965,24 @@ msgid "" "__annotations__`." msgstr "" -#: ../../howto/descriptor.rst:1542 +#: ../../howto/descriptor.rst:1539 msgid "Member objects and __slots__" msgstr "" -#: ../../howto/descriptor.rst:1544 +#: ../../howto/descriptor.rst:1541 msgid "" "When a class defines ``__slots__``, it replaces instance dictionaries with a " "fixed-length array of slot values. From a user point of view that has " "several effects:" msgstr "" -#: ../../howto/descriptor.rst:1548 +#: ../../howto/descriptor.rst:1545 msgid "" "1. Provides immediate detection of bugs due to misspelled attribute " "assignments. Only attribute names specified in ``__slots__`` are allowed:" msgstr "" -#: ../../howto/descriptor.rst:1551 +#: ../../howto/descriptor.rst:1548 msgid "" "class Vehicle:\n" " __slots__ = ('id_number', 'make', 'model')" @@ -1982,7 +1990,7 @@ msgstr "" "class Vehicle:\n" " __slots__ = ('id_number', 'make', 'model')" -#: ../../howto/descriptor.rst:1556 +#: ../../howto/descriptor.rst:1553 msgid "" ">>> auto = Vehicle()\n" ">>> auto.id_nubmer = 'VYE483814LQEX'\n" @@ -1996,13 +2004,13 @@ msgstr "" " ...\n" "AttributeError: 'Vehicle' object has no attribute 'id_nubmer'" -#: ../../howto/descriptor.rst:1564 +#: ../../howto/descriptor.rst:1561 msgid "" "2. Helps create immutable objects where descriptors manage access to private " "attributes stored in ``__slots__``:" msgstr "" -#: ../../howto/descriptor.rst:1567 +#: ../../howto/descriptor.rst:1564 msgid "" "class Immutable:\n" "\n" @@ -2022,7 +2030,7 @@ msgid "" " return self._name" msgstr "" -#: ../../howto/descriptor.rst:1585 +#: ../../howto/descriptor.rst:1582 msgid "" ">>> mark = Immutable('Botany', 'Mark Watney')\n" ">>> mark.dept\n" @@ -2048,7 +2056,7 @@ msgstr "" " ...\n" "AttributeError: 'Immutable' object has no attribute 'location'" -#: ../../howto/descriptor.rst:1599 +#: ../../howto/descriptor.rst:1596 msgid "" "3. Saves memory. On a 64-bit Linux build, an instance with two attributes " "takes 48 bytes with ``__slots__`` and 152 bytes without. This `flyweight " @@ -2056,19 +2064,19 @@ msgid "" "only matters when a large number of instances are going to be created." msgstr "" -#: ../../howto/descriptor.rst:1604 +#: ../../howto/descriptor.rst:1601 msgid "" "4. Improves speed. Reading instance variables is 35% faster with " "``__slots__`` (as measured with Python 3.10 on an Apple M1 processor)." msgstr "" -#: ../../howto/descriptor.rst:1607 +#: ../../howto/descriptor.rst:1604 msgid "" "5. Blocks tools like :deco:`functools.cached_property` which require an " "instance dictionary to function correctly:" msgstr "" -#: ../../howto/descriptor.rst:1610 +#: ../../howto/descriptor.rst:1607 msgid "" "from functools import cached_property\n" "\n" @@ -2081,7 +2089,7 @@ msgid "" " for n in reversed(range(100_000)))" msgstr "" -#: ../../howto/descriptor.rst:1622 +#: ../../howto/descriptor.rst:1619 msgid "" ">>> CP().pi\n" "Traceback (most recent call last):\n" @@ -2093,7 +2101,7 @@ msgstr "" " ...\n" "TypeError: No '__dict__' attribute on 'CP' instance to cache 'pi' property." -#: ../../howto/descriptor.rst:1629 +#: ../../howto/descriptor.rst:1626 msgid "" "It is not possible to create an exact drop-in pure Python version of " "``__slots__`` because it requires direct access to C structures and control " @@ -2103,9 +2111,9 @@ msgid "" "managed by member descriptors:" msgstr "" -#: ../../howto/descriptor.rst:1636 +#: ../../howto/descriptor.rst:1633 msgid "" -"null = object()\n" +"null = sentinel('null')\n" "\n" "class Member:\n" "\n" @@ -2141,14 +2149,49 @@ msgid "" " 'Emulate member_repr() in Objects/descrobject.c'\n" " return f''" msgstr "" +"null = sentinel('null')\n" +"\n" +"class Member:\n" +"\n" +" def __init__(self, name, clsname, offset):\n" +" 'Emulate PyMemberDef in Include/descrobject.h'\n" +" # 另請參閱 Objects/descrobject.c 中的 descr_new()\n" +" self.name = name\n" +" self.clsname = clsname\n" +" self.offset = offset\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" 'Emulate member_get() in Objects/descrobject.c'\n" +" # 另請參閱 Python/structmember.c 中的 PyMember_GetOne()\n" +" if obj is None:\n" +" return self\n" +" value = obj._slotvalues[self.offset]\n" +" if value is null:\n" +" raise AttributeError(self.name)\n" +" return value\n" +"\n" +" def __set__(self, obj, value):\n" +" 'Emulate member_set() in Objects/descrobject.c'\n" +" obj._slotvalues[self.offset] = value\n" +"\n" +" def __delete__(self, obj):\n" +" 'Emulate member_delete() in Objects/descrobject.c'\n" +" value = obj._slotvalues[self.offset]\n" +" if value is null:\n" +" raise AttributeError(self.name)\n" +" obj._slotvalues[self.offset] = null\n" +"\n" +" def __repr__(self):\n" +" 'Emulate member_repr() in Objects/descrobject.c'\n" +" return f''" -#: ../../howto/descriptor.rst:1674 +#: ../../howto/descriptor.rst:1671 msgid "" "The :meth:`!type.__new__` method takes care of adding member objects to " "class variables:" msgstr "" -#: ../../howto/descriptor.rst:1677 +#: ../../howto/descriptor.rst:1674 msgid "" "class Type(type):\n" " 'Simulate how the type metaclass adds member objects for slots'\n" @@ -2162,14 +2205,14 @@ msgid "" " return type.__new__(mcls, clsname, bases, mapping, **kwargs)" msgstr "" -#: ../../howto/descriptor.rst:1690 +#: ../../howto/descriptor.rst:1687 msgid "" "The :meth:`object.__new__` method takes care of creating instances that have " "slots instead of an instance dictionary. Here is a rough simulation in pure " "Python:" msgstr "" -#: ../../howto/descriptor.rst:1694 +#: ../../howto/descriptor.rst:1691 msgid "" "class Object:\n" " 'Simulate how object.__new__() allocates memory for __slots__'\n" @@ -2201,13 +2244,13 @@ msgid "" " super().__delattr__(name)" msgstr "" -#: ../../howto/descriptor.rst:1725 +#: ../../howto/descriptor.rst:1722 msgid "" "To use the simulation in a real class, just inherit from :class:`!Object` " "and set the :term:`metaclass` to :class:`Type`:" msgstr "" -#: ../../howto/descriptor.rst:1728 +#: ../../howto/descriptor.rst:1725 msgid "" "class H(Object, metaclass=Type):\n" " 'Instance variables stored in slots'\n" @@ -2219,12 +2262,12 @@ msgid "" " self.y = y" msgstr "" -#: ../../howto/descriptor.rst:1739 +#: ../../howto/descriptor.rst:1736 msgid "" "At this point, the metaclass has loaded member objects for *x* and *y*::" msgstr "" -#: ../../howto/descriptor.rst:1741 +#: ../../howto/descriptor.rst:1738 msgid "" ">>> from pprint import pp\n" ">>> pp(dict(vars(H)))\n" @@ -2244,13 +2287,13 @@ msgstr "" " 'x': ,\n" " 'y': }" -#: ../../howto/descriptor.rst:1760 +#: ../../howto/descriptor.rst:1757 msgid "" "When instances are created, they have a ``slot_values`` list where the " "attributes are stored:" msgstr "" -#: ../../howto/descriptor.rst:1763 +#: ../../howto/descriptor.rst:1760 msgid "" ">>> h = H(10, 20)\n" ">>> vars(h)\n" @@ -2266,11 +2309,11 @@ msgstr "" ">>> vars(h)\n" "{'_slotvalues': [55, 20]}" -#: ../../howto/descriptor.rst:1772 +#: ../../howto/descriptor.rst:1769 msgid "Misspelled or unassigned attributes will raise an exception:" msgstr "" -#: ../../howto/descriptor.rst:1774 +#: ../../howto/descriptor.rst:1771 msgid "" ">>> h.xz\n" "Traceback (most recent call last):\n" @@ -2281,3 +2324,15 @@ msgstr "" "Traceback (most recent call last):\n" " ...\n" "AttributeError: 'H' object has no attribute 'xz'" + +#~ msgid "Author" +#~ msgstr "作者" + +#~ msgid "Raymond Hettinger" +#~ msgstr "Raymond Hettinger" + +#~ msgid "Contact" +#~ msgstr "聯絡方式" + +#~ msgid "" +#~ msgstr "" diff --git a/howto/enum.po b/howto/enum.po index cc950d0e182..18d06f7d039 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -769,9 +769,9 @@ msgstr "" #: ../../howto/enum.rst:374 msgid "" -"Comparisons against non-enumeration values will always compare not equal " -"(again, :class:`IntEnum` was explicitly designed to behave differently, see " -"below)::" +"Equality comparisons against non-enumeration values will always return " +"``False`` (again, :class:`IntEnum` was explicitly designed to behave " +"differently, see below)::" msgstr "" #: ../../howto/enum.rst:378 diff --git a/howto/free-threading-extensions.po b/howto/free-threading-extensions.po index a8c1c4f5996..37856f382a4 100644 --- a/howto/free-threading-extensions.po +++ b/howto/free-threading-extensions.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-04-24 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -79,13 +79,15 @@ msgstr "" #: ../../howto/free-threading-extensions.rst:48 msgid "" -"Extensions that use multi-phase initialization (i.e., :c:func:" -"`PyModuleDef_Init`) should add a :c:data:`Py_mod_gil` slot in the module " -"definition. If your extension supports older versions of CPython, you " +"Extensions that use :ref:`multi-phase initialization ` (functions like :c:func:`PyModuleDef_Init`, :c:func:" +"`PyModExport_* ` export hook, :c:func:" +"`PyModule_FromSlotsAndSpec`) should add a :c:data:`Py_mod_gil` slot in the " +"module definition. If your extension supports older versions of CPython, you " "should guard the slot with a :c:data:`PY_VERSION_HEX` check." msgstr "" -#: ../../howto/free-threading-extensions.rst:55 +#: ../../howto/free-threading-extensions.rst:58 msgid "" "static struct PyModuleDef_Slot module_slots[] = {\n" " ...\n" @@ -93,12 +95,6 @@ msgid "" " {Py_mod_gil, Py_MOD_GIL_NOT_USED},\n" "#endif\n" " {0, NULL}\n" -"};\n" -"\n" -"static struct PyModuleDef moduledef = {\n" -" PyModuleDef_HEAD_INIT,\n" -" .m_slots = module_slots,\n" -" ...\n" "};" msgstr "" "static struct PyModuleDef_Slot module_slots[] = {\n" @@ -107,28 +103,23 @@ msgstr "" " {Py_mod_gil, Py_MOD_GIL_NOT_USED},\n" "#endif\n" " {0, NULL}\n" -"};\n" -"\n" -"static struct PyModuleDef moduledef = {\n" -" PyModuleDef_HEAD_INIT,\n" -" .m_slots = module_slots,\n" -" ...\n" "};" -#: ../../howto/free-threading-extensions.rst:71 +#: ../../howto/free-threading-extensions.rst:68 msgid "Single-Phase Initialization" msgstr "單一階段初始化 (Single-Phase Initialization)" -#: ../../howto/free-threading-extensions.rst:73 +#: ../../howto/free-threading-extensions.rst:70 msgid "" -"Extensions that use single-phase initialization (i.e., :c:func:" -"`PyModule_Create`) should call :c:func:`PyUnstable_Module_SetGIL` to " -"indicate that they support running with the GIL disabled. The function is " -"only defined in the free-threaded build, so you should guard the call with " -"``#ifdef Py_GIL_DISABLED`` to avoid compilation errors in the regular build." +"Extensions that use legacy :ref:`single-phase initialization ` (that is, :c:func:`PyModule_Create`) should call :c:func:" +"`PyUnstable_Module_SetGIL` to indicate that they support running with the " +"GIL disabled. The function is only defined in the free-threaded build, so " +"you should guard the call with ``#ifdef Py_GIL_DISABLED`` to avoid " +"compilation errors in the regular build." msgstr "" -#: ../../howto/free-threading-extensions.rst:81 +#: ../../howto/free-threading-extensions.rst:78 msgid "" "static struct PyModuleDef moduledef = {\n" " PyModuleDef_HEAD_INIT,\n" @@ -166,21 +157,21 @@ msgstr "" " return m;\n" "}" -#: ../../howto/free-threading-extensions.rst:101 +#: ../../howto/free-threading-extensions.rst:98 msgid "General API Guidelines" msgstr "" -#: ../../howto/free-threading-extensions.rst:103 +#: ../../howto/free-threading-extensions.rst:100 msgid "Most of the C API is thread-safe, but there are some exceptions." msgstr "" -#: ../../howto/free-threading-extensions.rst:105 +#: ../../howto/free-threading-extensions.rst:102 msgid "" "**Struct Fields**: Accessing fields in Python C API objects or structs " "directly is not thread-safe if the field may be concurrently modified." msgstr "" -#: ../../howto/free-threading-extensions.rst:107 +#: ../../howto/free-threading-extensions.rst:104 msgid "" "**Macros**: Accessor macros like :c:macro:`PyList_GET_ITEM`, :c:macro:" "`PyList_SET_ITEM`, and macros like :c:macro:`PySequence_Fast_GET_SIZE` that " @@ -189,7 +180,7 @@ msgid "" "object may be modified concurrently." msgstr "" -#: ../../howto/free-threading-extensions.rst:113 +#: ../../howto/free-threading-extensions.rst:110 msgid "" "**Borrowed References**: C API functions that return :term:`borrowed " "references ` may not be thread-safe if the containing " @@ -197,11 +188,11 @@ msgid "" "references ` for more information." msgstr "" -#: ../../howto/free-threading-extensions.rst:120 +#: ../../howto/free-threading-extensions.rst:117 msgid "Container Thread Safety" msgstr "容器執行緒安全性" -#: ../../howto/free-threading-extensions.rst:122 +#: ../../howto/free-threading-extensions.rst:119 msgid "" "Containers like :c:struct:`PyListObject`, :c:struct:`PyDictObject`, and :c:" "struct:`PySetObject` perform internal locking in the free-threaded build. " @@ -209,11 +200,11 @@ msgid "" "an item." msgstr "" -#: ../../howto/free-threading-extensions.rst:130 +#: ../../howto/free-threading-extensions.rst:127 msgid "``PyDict_Next``" msgstr "``PyDict_Next``" -#: ../../howto/free-threading-extensions.rst:132 +#: ../../howto/free-threading-extensions.rst:129 msgid "" "A notable exception is :c:func:`PyDict_Next`, which does not lock the " "dictionary. You should use :c:macro:`Py_BEGIN_CRITICAL_SECTION` to protect " @@ -221,7 +212,7 @@ msgid "" "modified::" msgstr "" -#: ../../howto/free-threading-extensions.rst:137 +#: ../../howto/free-threading-extensions.rst:134 msgid "" "Py_BEGIN_CRITICAL_SECTION(dict);\n" "PyObject *key, *value;\n" @@ -239,11 +230,11 @@ msgstr "" "}\n" "Py_END_CRITICAL_SECTION();" -#: ../../howto/free-threading-extensions.rst:147 +#: ../../howto/free-threading-extensions.rst:144 msgid "Borrowed References" msgstr "借用參照" -#: ../../howto/free-threading-extensions.rst:151 +#: ../../howto/free-threading-extensions.rst:148 msgid "" "Some C API functions return :term:`borrowed references `. These APIs are not thread-safe if the containing object is " @@ -251,100 +242,100 @@ msgid "" "`PyList_GetItem` if the list may be modified concurrently." msgstr "" -#: ../../howto/free-threading-extensions.rst:156 +#: ../../howto/free-threading-extensions.rst:153 msgid "" "The following table lists some borrowed reference APIs and their " "replacements that return :term:`strong references `." msgstr "" -#: ../../howto/free-threading-extensions.rst:160 +#: ../../howto/free-threading-extensions.rst:157 msgid "Borrowed reference API" msgstr "借用參照 API" -#: ../../howto/free-threading-extensions.rst:160 +#: ../../howto/free-threading-extensions.rst:157 msgid "Strong reference API" msgstr "強參照 API" -#: ../../howto/free-threading-extensions.rst:162 +#: ../../howto/free-threading-extensions.rst:159 msgid ":c:func:`PyList_GetItem`" msgstr ":c:func:`PyList_GetItem`" -#: ../../howto/free-threading-extensions.rst:162 -#: ../../howto/free-threading-extensions.rst:164 +#: ../../howto/free-threading-extensions.rst:159 +#: ../../howto/free-threading-extensions.rst:161 msgid ":c:func:`PyList_GetItemRef`" msgstr ":c:func:`PyList_GetItemRef`" -#: ../../howto/free-threading-extensions.rst:164 +#: ../../howto/free-threading-extensions.rst:161 msgid ":c:func:`PyList_GET_ITEM`" msgstr ":c:func:`PyList_GET_ITEM`" -#: ../../howto/free-threading-extensions.rst:166 +#: ../../howto/free-threading-extensions.rst:163 msgid ":c:func:`PyDict_GetItem`" msgstr ":c:func:`PyDict_GetItem`" -#: ../../howto/free-threading-extensions.rst:166 -#: ../../howto/free-threading-extensions.rst:168 +#: ../../howto/free-threading-extensions.rst:163 +#: ../../howto/free-threading-extensions.rst:165 msgid ":c:func:`PyDict_GetItemRef`" msgstr ":c:func:`PyDict_GetItemRef`" -#: ../../howto/free-threading-extensions.rst:168 +#: ../../howto/free-threading-extensions.rst:165 msgid ":c:func:`PyDict_GetItemWithError`" msgstr ":c:func:`PyDict_GetItemWithError`" -#: ../../howto/free-threading-extensions.rst:170 +#: ../../howto/free-threading-extensions.rst:167 msgid ":c:func:`PyDict_GetItemString`" msgstr ":c:func:`PyDict_GetItemString`" -#: ../../howto/free-threading-extensions.rst:170 +#: ../../howto/free-threading-extensions.rst:167 msgid ":c:func:`PyDict_GetItemStringRef`" msgstr ":c:func:`PyDict_GetItemStringRef`" -#: ../../howto/free-threading-extensions.rst:172 +#: ../../howto/free-threading-extensions.rst:169 msgid ":c:func:`PyDict_SetDefault`" msgstr ":c:func:`PyDict_SetDefault`" -#: ../../howto/free-threading-extensions.rst:172 +#: ../../howto/free-threading-extensions.rst:169 msgid ":c:func:`PyDict_SetDefaultRef`" msgstr ":c:func:`PyDict_SetDefaultRef`" -#: ../../howto/free-threading-extensions.rst:174 +#: ../../howto/free-threading-extensions.rst:171 msgid ":c:func:`PyDict_Next`" msgstr ":c:func:`PyDict_Next`" -#: ../../howto/free-threading-extensions.rst:174 +#: ../../howto/free-threading-extensions.rst:171 msgid "none (see :ref:`PyDict_Next`)" msgstr "" -#: ../../howto/free-threading-extensions.rst:176 -msgid ":c:func:`PyWeakref_GetObject`" -msgstr ":c:func:`PyWeakref_GetObject`" +#: ../../howto/free-threading-extensions.rst:173 +msgid ":c:func:`!PyWeakref_GetObject`" +msgstr ":c:func:`!PyWeakref_GetObject`" -#: ../../howto/free-threading-extensions.rst:176 -#: ../../howto/free-threading-extensions.rst:178 +#: ../../howto/free-threading-extensions.rst:173 +#: ../../howto/free-threading-extensions.rst:175 msgid ":c:func:`PyWeakref_GetRef`" msgstr ":c:func:`PyWeakref_GetRef`" -#: ../../howto/free-threading-extensions.rst:178 -msgid ":c:func:`PyWeakref_GET_OBJECT`" -msgstr ":c:func:`PyWeakref_GET_OBJECT`" +#: ../../howto/free-threading-extensions.rst:175 +msgid ":c:func:`!PyWeakref_GET_OBJECT`" +msgstr ":c:func:`!PyWeakref_GET_OBJECT`" -#: ../../howto/free-threading-extensions.rst:180 +#: ../../howto/free-threading-extensions.rst:177 msgid ":c:func:`PyImport_AddModule`" msgstr ":c:func:`PyImport_AddModule`" -#: ../../howto/free-threading-extensions.rst:180 +#: ../../howto/free-threading-extensions.rst:177 msgid ":c:func:`PyImport_AddModuleRef`" msgstr ":c:func:`PyImport_AddModuleRef`" -#: ../../howto/free-threading-extensions.rst:182 +#: ../../howto/free-threading-extensions.rst:179 msgid ":c:func:`PyCell_GET`" msgstr ":c:func:`PyCell_GET`" -#: ../../howto/free-threading-extensions.rst:182 +#: ../../howto/free-threading-extensions.rst:179 msgid ":c:func:`PyCell_Get`" msgstr ":c:func:`PyCell_Get`" -#: ../../howto/free-threading-extensions.rst:185 +#: ../../howto/free-threading-extensions.rst:182 msgid "" "Not all APIs that return borrowed references are problematic. For example, :" "c:func:`PyTuple_GetItem` is safe because tuples are immutable. Similarly, " @@ -355,18 +346,18 @@ msgid "" "context is safe." msgstr "" -#: ../../howto/free-threading-extensions.rst:193 +#: ../../howto/free-threading-extensions.rst:190 msgid "" "Some of these functions were added in Python 3.13. You can use the " "`pythoncapi-compat `_ package " "to provide implementations of these functions for older Python versions." msgstr "" -#: ../../howto/free-threading-extensions.rst:201 +#: ../../howto/free-threading-extensions.rst:198 msgid "Memory Allocation APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:203 +#: ../../howto/free-threading-extensions.rst:200 msgid "" "Python's memory management C API provides functions in three different :ref:" "`allocation domains `: \"raw\", \"mem\", and \"object\". " @@ -376,45 +367,53 @@ msgid "" "where this was only a best practice and not a hard requirement." msgstr "" -#: ../../howto/free-threading-extensions.rst:212 +#: ../../howto/free-threading-extensions.rst:209 msgid "" "Search for uses of :c:func:`PyObject_Malloc` in your extension and check " "that the allocated memory is used for Python objects. Use :c:func:" "`PyMem_Malloc` to allocate buffers instead of :c:func:`PyObject_Malloc`." msgstr "" -#: ../../howto/free-threading-extensions.rst:219 +#: ../../howto/free-threading-extensions.rst:216 msgid "Thread State and GIL APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:221 +#: ../../howto/free-threading-extensions.rst:218 msgid "" "Python provides a set of functions and macros to manage thread state and the " "GIL, such as:" msgstr "" -#: ../../howto/free-threading-extensions.rst:224 +#: ../../howto/free-threading-extensions.rst:221 +msgid "" +":c:func:`PyThreadState_Ensure`, :c:func:`PyThreadState_EnsureFromView`, and :" +"c:func:`PyThreadState_Release`" +msgstr "" +":c:func:`PyThreadState_Ensure`、:c:func:`PyThreadState_EnsureFromView` " +"和 :c:func:`PyThreadState_Release`" + +#: ../../howto/free-threading-extensions.rst:223 msgid ":c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`" msgstr ":c:func:`PyGILState_Ensure` 和 :c:func:`PyGILState_Release`" -#: ../../howto/free-threading-extensions.rst:225 +#: ../../howto/free-threading-extensions.rst:224 msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`" msgstr ":c:func:`PyEval_SaveThread` 和 :c:func:`PyEval_RestoreThread`" -#: ../../howto/free-threading-extensions.rst:226 +#: ../../howto/free-threading-extensions.rst:225 msgid ":c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS`" msgstr ":c:macro:`Py_BEGIN_ALLOW_THREADS` 和 :c:macro:`Py_END_ALLOW_THREADS`" -#: ../../howto/free-threading-extensions.rst:228 +#: ../../howto/free-threading-extensions.rst:227 msgid "" "These functions should still be used in the free-threaded build to manage " "thread state even when the :term:`GIL` is disabled. For example, if you " -"create a thread outside of Python, you must call :c:func:`PyGILState_Ensure` " -"before calling into the Python API to ensure that the thread has a valid " -"Python thread state." +"create a thread outside of Python, you must call :c:func:" +"`PyThreadState_Ensure` before calling into the Python API to ensure that the " +"thread has a valid Python thread state." msgstr "" -#: ../../howto/free-threading-extensions.rst:234 +#: ../../howto/free-threading-extensions.rst:233 msgid "" "You should continue to call :c:func:`PyEval_SaveThread` or :c:macro:" "`Py_BEGIN_ALLOW_THREADS` around blocking operations, such as I/O or lock " @@ -422,25 +421,25 @@ msgid "" "collector `." msgstr "" -#: ../../howto/free-threading-extensions.rst:241 +#: ../../howto/free-threading-extensions.rst:240 msgid "Protecting Internal Extension State" msgstr "" -#: ../../howto/free-threading-extensions.rst:243 +#: ../../howto/free-threading-extensions.rst:242 msgid "" "Your extension may have internal state that was previously protected by the " "GIL. You may need to add locking to protect this state. The approach will " "depend on your extension, but some common patterns include:" msgstr "" -#: ../../howto/free-threading-extensions.rst:247 +#: ../../howto/free-threading-extensions.rst:246 msgid "" "**Caches**: global caches are a common source of shared state. Consider " "using a lock to protect the cache or disabling it in the free-threaded build " "if the cache is not critical for performance." msgstr "" -#: ../../howto/free-threading-extensions.rst:250 +#: ../../howto/free-threading-extensions.rst:249 msgid "" "**Global State**: global state may need to be protected by a lock or moved " "to thread local storage. C11 and C++11 provide the ``thread_local`` or " @@ -448,11 +447,11 @@ msgid "" "language/storage_duration>`_." msgstr "" -#: ../../howto/free-threading-extensions.rst:257 +#: ../../howto/free-threading-extensions.rst:256 msgid "Critical Sections" msgstr "" -#: ../../howto/free-threading-extensions.rst:261 +#: ../../howto/free-threading-extensions.rst:260 msgid "" "In the free-threaded build, CPython provides a mechanism called \"critical " "sections\" to protect data that would otherwise be protected by the GIL. " @@ -461,11 +460,11 @@ msgid "" "certain C API functions or managing shared state in the free-threaded build." msgstr "" -#: ../../howto/free-threading-extensions.rst:268 +#: ../../howto/free-threading-extensions.rst:267 msgid "What Are Critical Sections?" msgstr "" -#: ../../howto/free-threading-extensions.rst:270 +#: ../../howto/free-threading-extensions.rst:269 msgid "" "Conceptually, critical sections act as a deadlock avoidance layer built on " "top of simple mutexes. Each thread maintains a stack of active critical " @@ -475,27 +474,27 @@ msgid "" "the underlying mutex." msgstr "" -#: ../../howto/free-threading-extensions.rst:278 +#: ../../howto/free-threading-extensions.rst:277 msgid "Using Critical Sections" msgstr "" -#: ../../howto/free-threading-extensions.rst:280 +#: ../../howto/free-threading-extensions.rst:279 msgid "The primary APIs for using critical sections are:" msgstr "" -#: ../../howto/free-threading-extensions.rst:282 +#: ../../howto/free-threading-extensions.rst:281 msgid "" ":c:macro:`Py_BEGIN_CRITICAL_SECTION` and :c:macro:`Py_END_CRITICAL_SECTION` " "- For locking a single object" msgstr "" -#: ../../howto/free-threading-extensions.rst:285 +#: ../../howto/free-threading-extensions.rst:284 msgid "" ":c:macro:`Py_BEGIN_CRITICAL_SECTION2` and :c:macro:" "`Py_END_CRITICAL_SECTION2` - For locking two objects simultaneously" msgstr "" -#: ../../howto/free-threading-extensions.rst:288 +#: ../../howto/free-threading-extensions.rst:287 msgid "" "These macros must be used in matching pairs and must appear in the same C " "scope, since they establish a new local scope. These macros are no-ops in " @@ -503,7 +502,7 @@ msgid "" "support both build types." msgstr "" -#: ../../howto/free-threading-extensions.rst:293 +#: ../../howto/free-threading-extensions.rst:292 msgid "" "A common use of a critical section would be to lock an object while " "accessing an internal attribute of it. For example, if an extension type " @@ -511,7 +510,7 @@ msgid "" "or writing that field::" msgstr "" -#: ../../howto/free-threading-extensions.rst:298 +#: ../../howto/free-threading-extensions.rst:297 msgid "" "// read the count, returns new reference to internal count value\n" "PyObject *result;\n" @@ -526,11 +525,11 @@ msgid "" "Py_END_CRITICAL_SECTION();" msgstr "" -#: ../../howto/free-threading-extensions.rst:312 +#: ../../howto/free-threading-extensions.rst:311 msgid "How Critical Sections Work" msgstr "" -#: ../../howto/free-threading-extensions.rst:314 +#: ../../howto/free-threading-extensions.rst:313 msgid "" "Unlike traditional locks, critical sections do not guarantee exclusive " "access throughout their entire duration. If a thread would block while " @@ -539,51 +538,51 @@ msgid "" "then resumed when the blocking operation completes." msgstr "" -#: ../../howto/free-threading-extensions.rst:320 +#: ../../howto/free-threading-extensions.rst:319 msgid "" "This behavior is similar to what happens with the GIL when a thread makes a " "blocking call. The key differences are:" msgstr "" -#: ../../howto/free-threading-extensions.rst:323 +#: ../../howto/free-threading-extensions.rst:322 msgid "Critical sections operate on a per-object basis rather than globally" msgstr "" -#: ../../howto/free-threading-extensions.rst:325 +#: ../../howto/free-threading-extensions.rst:324 msgid "" "Critical sections follow a stack discipline within each thread (the " "\"begin\" and \"end\" macros enforce this since they must be paired and " "within the same scope)" msgstr "" -#: ../../howto/free-threading-extensions.rst:328 +#: ../../howto/free-threading-extensions.rst:327 msgid "" "Critical sections automatically release and reacquire locks around potential " "blocking operations" msgstr "" -#: ../../howto/free-threading-extensions.rst:332 +#: ../../howto/free-threading-extensions.rst:331 msgid "Deadlock Avoidance" msgstr "" -#: ../../howto/free-threading-extensions.rst:334 +#: ../../howto/free-threading-extensions.rst:333 msgid "Critical sections help avoid deadlocks in two ways:" msgstr "" -#: ../../howto/free-threading-extensions.rst:336 +#: ../../howto/free-threading-extensions.rst:335 msgid "" "If a thread tries to acquire a lock that's already held by another thread, " "it first suspends all of its active critical sections, temporarily releasing " "their locks" msgstr "" -#: ../../howto/free-threading-extensions.rst:340 +#: ../../howto/free-threading-extensions.rst:339 msgid "" "When the blocking operation completes, only the top-most critical section is " "reacquired first" msgstr "" -#: ../../howto/free-threading-extensions.rst:343 +#: ../../howto/free-threading-extensions.rst:342 msgid "" "This means you cannot rely on nested critical sections to lock multiple " "objects at once, as the inner critical section may suspend the outer ones. " @@ -591,7 +590,7 @@ msgid "" "simultaneously." msgstr "" -#: ../../howto/free-threading-extensions.rst:347 +#: ../../howto/free-threading-extensions.rst:346 msgid "" "Note that the locks described above are only :c:type:`PyMutex` based locks. " "The critical section implementation does not know about or affect other " @@ -602,18 +601,18 @@ msgid "" "not be released and therefore does not get the same deadlock avoidance." msgstr "" -#: ../../howto/free-threading-extensions.rst:356 +#: ../../howto/free-threading-extensions.rst:355 msgid "Important Considerations" msgstr "" -#: ../../howto/free-threading-extensions.rst:358 +#: ../../howto/free-threading-extensions.rst:357 msgid "" "Critical sections may temporarily release their locks, allowing other " "threads to modify the protected data. Be careful about making assumptions " "about the state of the data after operations that might block." msgstr "" -#: ../../howto/free-threading-extensions.rst:362 +#: ../../howto/free-threading-extensions.rst:361 msgid "" "Because locks can be temporarily released (suspended), entering a critical " "section does not guarantee exclusive access to the protected resource " @@ -623,34 +622,34 @@ msgid "" "This is similar to how the GIL can be released during blocking calls." msgstr "" -#: ../../howto/free-threading-extensions.rst:369 +#: ../../howto/free-threading-extensions.rst:368 msgid "" "Only the lock(s) associated with the most recently entered (top-most) " "critical section are guaranteed to be held at any given time. Locks for " "outer, nested critical sections might have been suspended." msgstr "" -#: ../../howto/free-threading-extensions.rst:373 +#: ../../howto/free-threading-extensions.rst:372 msgid "" "You can lock at most two objects simultaneously with these APIs. If you need " "to lock more objects, you'll need to restructure your code." msgstr "" -#: ../../howto/free-threading-extensions.rst:376 +#: ../../howto/free-threading-extensions.rst:375 msgid "" "While critical sections will not deadlock if you attempt to lock the same " "object twice, they are less efficient than purpose-built reentrant locks for " "this use case." msgstr "" -#: ../../howto/free-threading-extensions.rst:380 +#: ../../howto/free-threading-extensions.rst:379 msgid "" "When using :c:macro:`Py_BEGIN_CRITICAL_SECTION2`, the order of the objects " "doesn't affect correctness (the implementation handles deadlock avoidance), " "but it's good practice to always lock objects in a consistent order." msgstr "" -#: ../../howto/free-threading-extensions.rst:384 +#: ../../howto/free-threading-extensions.rst:383 msgid "" "Remember that the critical section macros are primarily for protecting " "access to *Python objects* that might be involved in internal CPython " @@ -660,32 +659,66 @@ msgid "" msgstr "" #: ../../howto/free-threading-extensions.rst:392 -msgid "Building Extensions for the Free-Threaded Build" +msgid "Per-Object Locks (``ob_mutex``)" msgstr "" #: ../../howto/free-threading-extensions.rst:394 msgid "" +"In the free-threaded build, each Python object contains a :c:member:" +"`~PyObject.ob_mutex` field of type :c:type:`PyMutex`. This mutex is " +"**reserved for use by the critical section API** (:c:macro:" +"`Py_BEGIN_CRITICAL_SECTION` / :c:macro:`Py_END_CRITICAL_SECTION`)." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:401 +msgid "" +"Do **not** lock ``ob_mutex`` directly with ``PyMutex_Lock(&obj->ob_mutex)``. " +"Mixing direct ``PyMutex_Lock`` calls with the critical section API on the " +"same mutex can cause deadlocks." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:405 +msgid "" +"Even if your own code never uses critical sections on a particular object " +"type, **CPython internals may use the critical section API on any Python " +"object**." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:408 +msgid "" +"If your extension type needs its own lock, add a separate :c:type:`PyMutex` " +"field (or another synchronization primitive) to your object struct. :c:type:" +"`PyMutex` is very lightweight, so there is negligible cost to having an " +"additional one." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:415 +msgid "Building Extensions for the Free-Threaded Build" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:417 +msgid "" "C API extensions need to be built specifically for the free-threaded build. " "The wheels, shared libraries, and binaries are indicated by a ``t`` suffix." msgstr "" -#: ../../howto/free-threading-extensions.rst:397 +#: ../../howto/free-threading-extensions.rst:420 msgid "" "`pypa/manylinux `_ supports the free-" "threaded build, with the ``t`` suffix, such as ``python3.14t``." msgstr "" -#: ../../howto/free-threading-extensions.rst:399 +#: ../../howto/free-threading-extensions.rst:422 msgid "" "`pypa/cibuildwheel `_ supports " "building wheels for the free-threaded build of Python 3.14 and newer." msgstr "" -#: ../../howto/free-threading-extensions.rst:403 +#: ../../howto/free-threading-extensions.rst:426 msgid "Limited C API and Stable ABI" msgstr "" -#: ../../howto/free-threading-extensions.rst:405 +#: ../../howto/free-threading-extensions.rst:428 msgid "" "The free-threaded build does not currently support the :ref:`Limited C API " "` or the stable ABI. If you use `setuptools `_: A community-maintained porting guide for " diff --git a/howto/functional.po b/howto/functional.po index b3782af209e..1741df86740 100644 --- a/howto/functional.po +++ b/howto/functional.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,23 +22,7 @@ msgstr "" msgid "Functional Programming HOWTO" msgstr "函式程式設計 HOWTO" -#: ../../howto/functional.rst:0 -msgid "Author" -msgstr "作者" - #: ../../howto/functional.rst:7 -msgid "\\A. M. Kuchling" -msgstr "\\A. M. Kuchling" - -#: ../../howto/functional.rst:0 -msgid "Release" -msgstr "發佈版本" - -#: ../../howto/functional.rst:8 -msgid "0.32" -msgstr "0.32" - -#: ../../howto/functional.rst:10 msgid "" "In this document, we'll take a tour of Python's features suitable for " "implementing programs in a functional style. After an introduction to the " @@ -47,30 +31,30 @@ msgid "" "such as :mod:`itertools` and :mod:`functools`." msgstr "" -#: ../../howto/functional.rst:18 +#: ../../howto/functional.rst:15 msgid "Introduction" msgstr "簡介" -#: ../../howto/functional.rst:20 +#: ../../howto/functional.rst:17 msgid "" "This section explains the basic concept of functional programming; if you're " "just interested in learning about Python language features, skip to the next " "section on :ref:`functional-howto-iterators`." msgstr "" -#: ../../howto/functional.rst:24 +#: ../../howto/functional.rst:21 msgid "" "Programming languages support decomposing problems in several different ways:" msgstr "" -#: ../../howto/functional.rst:26 +#: ../../howto/functional.rst:23 msgid "" "Most programming languages are **procedural**: programs are lists of " "instructions that tell the computer what to do with the program's input. C, " "Pascal, and even Unix shells are procedural languages." msgstr "" -#: ../../howto/functional.rst:30 +#: ../../howto/functional.rst:27 msgid "" "In **declarative** languages, you write a specification that describes the " "problem to be solved, and the language implementation figures out how to " @@ -80,7 +64,7 @@ msgid "" "indexes, which subclauses should be performed first, etc." msgstr "" -#: ../../howto/functional.rst:37 +#: ../../howto/functional.rst:34 msgid "" "**Object-oriented** programs manipulate collections of objects. Objects " "have internal state and support methods that query or modify this internal " @@ -89,7 +73,7 @@ msgid "" "force the use of object-oriented features." msgstr "" -#: ../../howto/functional.rst:43 +#: ../../howto/functional.rst:40 msgid "" "**Functional** programming decomposes a problem into a set of functions. " "Ideally, functions only take inputs and produce outputs, and don't have any " @@ -98,7 +82,7 @@ msgid "" "other variants) and Haskell." msgstr "" -#: ../../howto/functional.rst:49 +#: ../../howto/functional.rst:46 msgid "" "The designers of some computer languages choose to emphasize one particular " "approach to programming. This often makes it difficult to write programs " @@ -111,7 +95,7 @@ msgid "" "functional, for example." msgstr "" -#: ../../howto/functional.rst:60 +#: ../../howto/functional.rst:57 msgid "" "In a functional program, input flows through a set of functions. Each " "function operates on its input and produces some output. Functional style " @@ -122,7 +106,7 @@ msgid "" "runs; every function's output must only depend on its input." msgstr "" -#: ../../howto/functional.rst:68 +#: ../../howto/functional.rst:65 msgid "" "Some languages are very strict about purity and don't even have assignment " "statements such as ``a=3`` or ``c = a + b``, but it's difficult to avoid all " @@ -133,7 +117,7 @@ msgid "" "for a second." msgstr "" -#: ../../howto/functional.rst:75 +#: ../../howto/functional.rst:72 msgid "" "Python programs written in functional style usually won't go to the extreme " "of avoiding all I/O or all assignments; instead, they'll provide a " @@ -143,7 +127,7 @@ msgid "" "other side effects." msgstr "" -#: ../../howto/functional.rst:81 +#: ../../howto/functional.rst:78 msgid "" "Functional programming can be considered the opposite of object-oriented " "programming. Objects are little capsules containing some internal state " @@ -155,40 +139,40 @@ msgid "" "objects in your application (e-mail messages, transactions, etc.)." msgstr "" -#: ../../howto/functional.rst:90 +#: ../../howto/functional.rst:87 msgid "" "Functional design may seem like an odd constraint to work under. Why should " "you avoid objects and side effects? There are theoretical and practical " "advantages to the functional style:" msgstr "" -#: ../../howto/functional.rst:94 +#: ../../howto/functional.rst:91 msgid "Formal provability." msgstr "形式可證明性 (Formal provability)。" -#: ../../howto/functional.rst:95 +#: ../../howto/functional.rst:92 msgid "Modularity." msgstr "模組化 (Modularity)。" -#: ../../howto/functional.rst:96 +#: ../../howto/functional.rst:93 msgid "Composability." msgstr "可組合性 (Composability)。" -#: ../../howto/functional.rst:97 +#: ../../howto/functional.rst:94 msgid "Ease of debugging and testing." msgstr "容易除錯與測試。" -#: ../../howto/functional.rst:101 +#: ../../howto/functional.rst:98 msgid "Formal provability" msgstr "形式可證明性" -#: ../../howto/functional.rst:103 +#: ../../howto/functional.rst:100 msgid "" "A theoretical benefit is that it's easier to construct a mathematical proof " "that a functional program is correct." msgstr "" -#: ../../howto/functional.rst:106 +#: ../../howto/functional.rst:103 msgid "" "For a long time researchers have been interested in finding ways to " "mathematically prove programs correct. This is different from testing a " @@ -198,7 +182,7 @@ msgid "" "the right result for all possible inputs." msgstr "" -#: ../../howto/functional.rst:113 +#: ../../howto/functional.rst:110 msgid "" "The technique used to prove programs correct is to write down " "**invariants**, properties of the input data and of the program's variables " @@ -209,7 +193,7 @@ msgid "" "invariants should match the desired conditions on the program's output." msgstr "" -#: ../../howto/functional.rst:121 +#: ../../howto/functional.rst:118 msgid "" "Functional programming's avoidance of assignments arose because assignments " "are difficult to handle with this technique; assignments can break " @@ -217,7 +201,7 @@ msgid "" "invariants that can be propagated onward." msgstr "" -#: ../../howto/functional.rst:126 +#: ../../howto/functional.rst:123 msgid "" "Unfortunately, proving programs correct is largely impractical and not " "relevant to Python software. Even trivial programs require proofs that are " @@ -229,11 +213,11 @@ msgid "" "wrongly believe you've proved the program correct." msgstr "" -#: ../../howto/functional.rst:137 +#: ../../howto/functional.rst:134 msgid "Modularity" msgstr "模組化" -#: ../../howto/functional.rst:139 +#: ../../howto/functional.rst:136 msgid "" "A more practical benefit of functional programming is that it forces you to " "break apart your problem into small pieces. Programs are more modular as a " @@ -242,15 +226,15 @@ msgid "" "Small functions are also easier to read and to check for errors." msgstr "" -#: ../../howto/functional.rst:147 +#: ../../howto/functional.rst:144 msgid "Ease of debugging and testing" msgstr "容易除錯與測試" -#: ../../howto/functional.rst:149 +#: ../../howto/functional.rst:146 msgid "Testing and debugging a functional-style program is easier." msgstr "" -#: ../../howto/functional.rst:151 +#: ../../howto/functional.rst:148 msgid "" "Debugging is simplified because functions are generally small and clearly " "specified. When a program doesn't work, each function is an interface point " @@ -259,7 +243,7 @@ msgid "" "responsible for a bug." msgstr "" -#: ../../howto/functional.rst:156 +#: ../../howto/functional.rst:153 msgid "" "Testing is easier because each function is a potential subject for a unit " "test. Functions don't depend on system state that needs to be replicated " @@ -267,11 +251,11 @@ msgid "" "and then check that the output matches expectations." msgstr "" -#: ../../howto/functional.rst:163 +#: ../../howto/functional.rst:160 msgid "Composability" msgstr "可組合性" -#: ../../howto/functional.rst:165 +#: ../../howto/functional.rst:162 msgid "" "As you work on a functional-style program, you'll write a number of " "functions with varying inputs and outputs. Some of these functions will be " @@ -282,24 +266,24 @@ msgid "" "different situations." msgstr "" -#: ../../howto/functional.rst:172 +#: ../../howto/functional.rst:169 msgid "" "Over time you'll form a personal library of utilities. Often you'll " "assemble new programs by arranging existing functions in a new configuration " "and writing a few functions specialized for the current task." msgstr "" -#: ../../howto/functional.rst:180 +#: ../../howto/functional.rst:177 msgid "Iterators" msgstr "疊代器" -#: ../../howto/functional.rst:182 +#: ../../howto/functional.rst:179 msgid "" "I'll start by looking at a Python language feature that's an important " "foundation for writing functional-style programs: iterators." msgstr "" -#: ../../howto/functional.rst:185 +#: ../../howto/functional.rst:182 msgid "" "An iterator is an object representing a stream of data; this object returns " "the data one element at a time. A Python iterator must support a method " @@ -310,7 +294,7 @@ msgid "" "reasonable to write an iterator that produces an infinite stream of data." msgstr "" -#: ../../howto/functional.rst:193 +#: ../../howto/functional.rst:190 msgid "" "The built-in :func:`iter` function takes an arbitrary object and tries to " "return an iterator that will return the object's contents or elements, " @@ -320,11 +304,11 @@ msgid "" "an iterator for it." msgstr "" -#: ../../howto/functional.rst:200 +#: ../../howto/functional.rst:197 msgid "You can experiment with the iteration interface manually:" msgstr "" -#: ../../howto/functional.rst:218 +#: ../../howto/functional.rst:215 msgid "" "Python expects iterable objects in several different contexts, the most " "important being the :keyword:`for` statement. In the statement ``for X in " @@ -332,7 +316,7 @@ msgid "" "an iterator. These two statements are equivalent::" msgstr "" -#: ../../howto/functional.rst:224 +#: ../../howto/functional.rst:221 msgid "" "for i in iter(obj):\n" " print(i)\n" @@ -346,19 +330,19 @@ msgstr "" "for i in obj:\n" " print(i)" -#: ../../howto/functional.rst:230 +#: ../../howto/functional.rst:227 msgid "" "Iterators can be materialized as lists or tuples by using the :func:`list` " "or :func:`tuple` constructor functions:" msgstr "" -#: ../../howto/functional.rst:239 +#: ../../howto/functional.rst:236 msgid "" "Sequence unpacking also supports iterators: if you know an iterator will " "return N elements, you can unpack them into an N-tuple:" msgstr "" -#: ../../howto/functional.rst:248 +#: ../../howto/functional.rst:245 msgid "" "Built-in functions such as :func:`max` and :func:`min` can take a single " "iterator argument and will return the largest or smallest element. The " @@ -369,7 +353,7 @@ msgid "" "stream, the ``\"in\"`` and ``\"not in\"`` operators won't return either." msgstr "" -#: ../../howto/functional.rst:256 +#: ../../howto/functional.rst:253 msgid "" "Note that you can only go forward in an iterator; there's no way to get the " "previous element, reset the iterator, or make a copy of it. Iterator " @@ -380,24 +364,24 @@ msgid "" "new iterator." msgstr "" -#: ../../howto/functional.rst:266 +#: ../../howto/functional.rst:263 msgid "Data Types That Support Iterators" msgstr "" -#: ../../howto/functional.rst:268 +#: ../../howto/functional.rst:265 msgid "" "We've already seen how lists and tuples support iterators. In fact, any " "Python sequence type, such as strings, will automatically support creation " "of an iterator." msgstr "" -#: ../../howto/functional.rst:272 +#: ../../howto/functional.rst:269 msgid "" "Calling :func:`iter` on a dictionary returns an iterator that will loop over " "the dictionary's keys::" msgstr "" -#: ../../howto/functional.rst:275 +#: ../../howto/functional.rst:272 msgid "" ">>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,\n" "... 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}\n" @@ -433,14 +417,14 @@ msgstr "" "Nov 11\n" "Dec 12" -#: ../../howto/functional.rst:292 +#: ../../howto/functional.rst:289 msgid "" "Note that starting with Python 3.7, dictionary iteration order is guaranteed " "to be the same as the insertion order. In earlier versions, the behaviour " "was unspecified and could vary between implementations." msgstr "" -#: ../../howto/functional.rst:296 +#: ../../howto/functional.rst:293 msgid "" "Applying :func:`iter` to a dictionary always loops over the keys, but " "dictionaries have methods that return other iterators. If you want to " @@ -448,33 +432,33 @@ msgid "" "`~dict.values` or :meth:`~dict.items` methods to get an appropriate iterator." msgstr "" -#: ../../howto/functional.rst:302 +#: ../../howto/functional.rst:299 msgid "" "The :func:`dict` constructor can accept an iterator that returns a finite " "stream of ``(key, value)`` tuples:" msgstr "" -#: ../../howto/functional.rst:309 +#: ../../howto/functional.rst:306 msgid "" "Files also support iteration by calling the :meth:`~io.TextIOBase.readline` " "method until there are no more lines in the file. This means you can read " "each line of a file like this::" msgstr "" -#: ../../howto/functional.rst:313 +#: ../../howto/functional.rst:310 msgid "" "for line in file:\n" " # do something for each line\n" " ..." msgstr "" -#: ../../howto/functional.rst:317 +#: ../../howto/functional.rst:314 msgid "" "Sets can take their contents from an iterable and let you iterate over the " "set's elements::" msgstr "" -#: ../../howto/functional.rst:320 +#: ../../howto/functional.rst:317 msgid "" ">>> S = {2, 3, 5, 7, 11, 13}\n" ">>> for i in S:\n" @@ -496,11 +480,11 @@ msgstr "" "11\n" "13" -#: ../../howto/functional.rst:333 +#: ../../howto/functional.rst:330 msgid "Generator expressions and list comprehensions" msgstr "產生器運算式與串列綜合運算式" -#: ../../howto/functional.rst:335 +#: ../../howto/functional.rst:332 msgid "" "Two common operations on an iterator's output are 1) performing some " "operation for every element, 2) selecting a subset of elements that meet " @@ -509,7 +493,7 @@ msgid "" "containing a given substring." msgstr "" -#: ../../howto/functional.rst:341 +#: ../../howto/functional.rst:338 msgid "" "List comprehensions and generator expressions (short form: \"listcomps\" and " "\"genexps\") are a concise notation for such operations, borrowed from the " @@ -517,7 +501,7 @@ msgid "" "strip all the whitespace from a stream of strings with the following code::" msgstr "" -#: ../../howto/functional.rst:346 +#: ../../howto/functional.rst:343 msgid "" ">>> line_list = [' line 1\\n', 'line 2 \\n', ' \\n', '']\n" "\n" @@ -535,12 +519,12 @@ msgstr "" ">>> # 串列綜合運算式 -- 回傳串列\n" ">>> stripped_list = [line.strip() for line in line_list]" -#: ../../howto/functional.rst:354 +#: ../../howto/functional.rst:351 msgid "" "You can select only certain elements by adding an ``\"if\"`` condition::" msgstr "" -#: ../../howto/functional.rst:356 +#: ../../howto/functional.rst:353 msgid "" ">>> stripped_list = [line.strip() for line in line_list\n" "... if line != \"\"]" @@ -548,7 +532,7 @@ msgstr "" ">>> stripped_list = [line.strip() for line in line_list\n" "... if line != \"\"]" -#: ../../howto/functional.rst:359 +#: ../../howto/functional.rst:356 msgid "" "With a list comprehension, you get back a Python list; ``stripped_list`` is " "a list containing the resulting lines, not an iterator. Generator " @@ -559,22 +543,22 @@ msgid "" "preferable in these situations." msgstr "" -#: ../../howto/functional.rst:366 +#: ../../howto/functional.rst:363 msgid "" "Generator expressions are surrounded by parentheses (\"()\") and list " "comprehensions are surrounded by square brackets (\"[]\"). Generator " "expressions have the form::" msgstr "" -#: ../../howto/functional.rst:370 +#: ../../howto/functional.rst:367 msgid "" "( expression for expr in sequence1\n" " if condition1\n" " for expr2 in sequence2\n" " if condition2\n" " for expr3 in sequence3\n" -" ...\n" " if condition3\n" +" ...\n" " for exprN in sequenceN\n" " if conditionN )" msgstr "" @@ -583,18 +567,18 @@ msgstr "" " for expr2 in sequence2\n" " if condition2\n" " for expr3 in sequence3\n" -" ...\n" " if condition3\n" +" ...\n" " for exprN in sequenceN\n" " if conditionN )" -#: ../../howto/functional.rst:380 +#: ../../howto/functional.rst:377 msgid "" "Again, for a list comprehension only the outside brackets are different " "(square brackets instead of parentheses)." msgstr "" -#: ../../howto/functional.rst:383 +#: ../../howto/functional.rst:380 msgid "" "The elements of the generated output will be the successive values of " "``expression``. The ``if`` clauses are all optional; if present, " @@ -602,18 +586,18 @@ msgid "" "is true." msgstr "" -#: ../../howto/functional.rst:387 +#: ../../howto/functional.rst:384 msgid "" "Generator expressions always have to be written inside parentheses, but the " "parentheses signalling a function call also count. If you want to create an " "iterator that will be immediately passed to a function you can write::" msgstr "" -#: ../../howto/functional.rst:391 +#: ../../howto/functional.rst:388 msgid "obj_total = sum(obj.count for obj in list_all_objects())" msgstr "obj_total = sum(obj.count for obj in list_all_objects())" -#: ../../howto/functional.rst:393 +#: ../../howto/functional.rst:390 msgid "" "The ``for...in`` clauses contain the sequences to be iterated over. The " "sequences do not have to be the same length, because they are iterated over " @@ -623,13 +607,13 @@ msgid "" "``sequence2``." msgstr "" -#: ../../howto/functional.rst:399 +#: ../../howto/functional.rst:396 msgid "" "To put it another way, a list comprehension or generator expression is " "equivalent to the following Python code::" msgstr "" -#: ../../howto/functional.rst:402 +#: ../../howto/functional.rst:399 msgid "" "for expr1 in sequence1:\n" " if not (condition1):\n" @@ -646,7 +630,7 @@ msgid "" " # the expression." msgstr "" -#: ../../howto/functional.rst:416 +#: ../../howto/functional.rst:413 msgid "" "This means that when there are multiple ``for...in`` clauses but no ``if`` " "clauses, the length of the resulting output will be equal to the product of " @@ -654,14 +638,14 @@ msgid "" "output list is 9 elements long:" msgstr "" -#: ../../howto/functional.rst:428 +#: ../../howto/functional.rst:425 msgid "" "To avoid introducing an ambiguity into Python's grammar, if ``expression`` " "is creating a tuple, it must be surrounded with parentheses. The first list " "comprehension below is a syntax error, while the second one is correct::" msgstr "" -#: ../../howto/functional.rst:432 +#: ../../howto/functional.rst:429 msgid "" "# Syntax error\n" "[x, y for x in seq1 for y in seq2]\n" @@ -673,18 +657,18 @@ msgstr "" "# 正確\n" "[(x, y) for x in seq1 for y in seq2]" -#: ../../howto/functional.rst:439 +#: ../../howto/functional.rst:436 msgid "Generators" msgstr "產生器" -#: ../../howto/functional.rst:441 +#: ../../howto/functional.rst:438 msgid "" "Generators are a special class of functions that simplify the task of " "writing iterators. Regular functions compute a value and return it, but " "generators return an iterator that returns a stream of values." msgstr "" -#: ../../howto/functional.rst:445 +#: ../../howto/functional.rst:442 msgid "" "You're doubtless familiar with how regular function calls work in Python or " "C. When you call a function, it gets a private namespace where its local " @@ -697,18 +681,18 @@ msgid "" "thought of as resumable functions." msgstr "" -#: ../../howto/functional.rst:454 +#: ../../howto/functional.rst:451 msgid "Here's the simplest example of a generator function:" msgstr "以下是最簡單的產生器函式範例:" -#: ../../howto/functional.rst:460 +#: ../../howto/functional.rst:457 msgid "" "Any function containing a :keyword:`yield` keyword is a generator function; " "this is detected by Python's :term:`bytecode` compiler which compiles the " "function specially as a result." msgstr "" -#: ../../howto/functional.rst:464 +#: ../../howto/functional.rst:461 msgid "" "When you call a generator function, it doesn't return a single value; " "instead it returns a generator object that supports the iterator protocol. " @@ -720,17 +704,17 @@ msgid "" "method, the function will resume executing." msgstr "" -#: ../../howto/functional.rst:473 +#: ../../howto/functional.rst:470 msgid "Here's a sample usage of the ``generate_ints()`` generator:" msgstr "以下是 ``generate_ints()`` 產生器的使用範例:" -#: ../../howto/functional.rst:490 +#: ../../howto/functional.rst:487 msgid "" "You could equally write ``for i in generate_ints(5)``, or ``a, b, c = " "generate_ints(3)``." msgstr "" -#: ../../howto/functional.rst:493 +#: ../../howto/functional.rst:490 msgid "" "Inside a generator function, ``return value`` causes " "``StopIteration(value)`` to be raised from the :meth:`~generator.__next__` " @@ -738,7 +722,7 @@ msgid "" "procession of values ends and the generator cannot yield any further values." msgstr "" -#: ../../howto/functional.rst:498 +#: ../../howto/functional.rst:495 msgid "" "You could achieve the effect of generators manually by writing your own " "class and storing all the local variables of the generator as instance " @@ -748,7 +732,7 @@ msgid "" "complicated generator, writing a corresponding class can be much messier." msgstr "" -#: ../../howto/functional.rst:506 +#: ../../howto/functional.rst:503 msgid "" "The test suite included with Python's library, :source:`Lib/test/" "test_generators.py`, contains a number of more interesting examples. Here's " @@ -756,7 +740,7 @@ msgid "" "generators recursively. ::" msgstr "" -#: ../../howto/functional.rst:511 +#: ../../howto/functional.rst:508 msgid "" "# A recursive generator that generates Tree leaves in in-order.\n" "def inorder(t):\n" @@ -770,7 +754,7 @@ msgid "" " yield x" msgstr "" -#: ../../howto/functional.rst:522 +#: ../../howto/functional.rst:519 msgid "" "Two other examples in ``test_generators.py`` produce solutions for the N-" "Queens problem (placing N queens on an NxN chess board so that no queen " @@ -779,11 +763,11 @@ msgid "" "twice)." msgstr "" -#: ../../howto/functional.rst:530 +#: ../../howto/functional.rst:527 msgid "Passing values into a generator" msgstr "" -#: ../../howto/functional.rst:532 +#: ../../howto/functional.rst:529 msgid "" "In Python 2.4 and earlier, generators only produced output. Once a " "generator's code was invoked to create an iterator, there was no way to pass " @@ -793,18 +777,18 @@ msgid "" "these approaches are messy." msgstr "" -#: ../../howto/functional.rst:539 +#: ../../howto/functional.rst:536 msgid "" "In Python 2.5 there's a simple way to pass values into a generator. :keyword:" "`yield` became an expression, returning a value that can be assigned to a " "variable or otherwise operated on::" msgstr "" -#: ../../howto/functional.rst:543 +#: ../../howto/functional.rst:540 msgid "val = (yield i)" msgstr "val = (yield i)" -#: ../../howto/functional.rst:545 +#: ../../howto/functional.rst:542 msgid "" "I recommend that you **always** put parentheses around a ``yield`` " "expression when you're doing something with the returned value, as in the " @@ -812,7 +796,7 @@ msgid "" "always add them instead of having to remember when they're needed." msgstr "" -#: ../../howto/functional.rst:550 +#: ../../howto/functional.rst:547 msgid "" "(:pep:`342` explains the exact rules, which are that a ``yield``-expression " "must always be parenthesized except when it occurs at the top-level " @@ -821,7 +805,7 @@ msgid "" "operation, as in ``val = (yield i) + 12``.)" msgstr "" -#: ../../howto/functional.rst:556 +#: ../../howto/functional.rst:553 msgid "" "Values are sent into a generator by calling its :meth:`send(value) " "` method. This method resumes the generator's code and the " @@ -829,13 +813,13 @@ msgid "" "`~generator.__next__` method is called, the ``yield`` returns ``None``." msgstr "" -#: ../../howto/functional.rst:561 +#: ../../howto/functional.rst:558 msgid "" "Here's a simple counter that increments by 1 and allows changing the value " "of the internal counter." msgstr "" -#: ../../howto/functional.rst:564 +#: ../../howto/functional.rst:561 msgid "" "def counter(maximum):\n" " i = 0\n" @@ -857,11 +841,11 @@ msgstr "" " else:\n" " i += 1" -#: ../../howto/functional.rst:576 +#: ../../howto/functional.rst:573 msgid "And here's an example of changing the counter:" msgstr "" -#: ../../howto/functional.rst:593 +#: ../../howto/functional.rst:590 msgid "" "Because ``yield`` will often be returning ``None``, you should always check " "for this case. Don't just use its value in expressions unless you're sure " @@ -869,20 +853,20 @@ msgid "" "resume your generator function." msgstr "" -#: ../../howto/functional.rst:598 +#: ../../howto/functional.rst:595 msgid "" "In addition to :meth:`~generator.send`, there are two other methods on " "generators:" msgstr "" -#: ../../howto/functional.rst:601 +#: ../../howto/functional.rst:598 msgid "" ":meth:`throw(value) ` is used to raise an exception inside " "the generator; the exception is raised by the ``yield`` expression where the " "generator's execution is paused." msgstr "" -#: ../../howto/functional.rst:605 +#: ../../howto/functional.rst:602 msgid "" ":meth:`~generator.close` sends a :exc:`GeneratorExit` exception to the " "generator to terminate the iteration. On receiving this exception, the " @@ -893,20 +877,20 @@ msgid "" "collected." msgstr "" -#: ../../howto/functional.rst:613 +#: ../../howto/functional.rst:610 msgid "" "If you need to run cleanup code when a :exc:`GeneratorExit` occurs, I " "suggest using a ``try: ... finally:`` suite instead of catching :exc:" "`GeneratorExit`." msgstr "" -#: ../../howto/functional.rst:616 +#: ../../howto/functional.rst:613 msgid "" "The cumulative effect of these changes is to turn generators from one-way " "producers of information into both producers and consumers." msgstr "" -#: ../../howto/functional.rst:619 +#: ../../howto/functional.rst:616 msgid "" "Generators also become **coroutines**, a more generalized form of " "subroutines. Subroutines are entered at one point and exited at another " @@ -915,38 +899,38 @@ msgid "" "statements)." msgstr "" -#: ../../howto/functional.rst:626 +#: ../../howto/functional.rst:623 msgid "Built-in functions" msgstr "內建函式" -#: ../../howto/functional.rst:628 +#: ../../howto/functional.rst:625 msgid "" "Let's look in more detail at built-in functions often used with iterators." msgstr "" -#: ../../howto/functional.rst:630 +#: ../../howto/functional.rst:627 msgid "" "Two of Python's built-in functions, :func:`map` and :func:`filter` duplicate " "the features of generator expressions:" msgstr "" -#: ../../howto/functional.rst:633 +#: ../../howto/functional.rst:630 msgid "" ":func:`map(f, iterA, iterB, ...) ` returns an iterator over the sequence" msgstr ":func:`map(f, iterA, iterB, ...) ` 回傳一個元素為序列的疊代器" -#: ../../howto/functional.rst:634 +#: ../../howto/functional.rst:631 msgid "" "``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ...``." msgstr "" "``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ..." "``。" -#: ../../howto/functional.rst:644 +#: ../../howto/functional.rst:641 msgid "You can of course achieve the same effect with a list comprehension." msgstr "" -#: ../../howto/functional.rst:646 +#: ../../howto/functional.rst:643 msgid "" ":func:`filter(predicate, iter) ` returns an iterator over all the " "sequence elements that meet a certain condition, and is similarly duplicated " @@ -955,18 +939,18 @@ msgid "" "must take a single value." msgstr "" -#: ../../howto/functional.rst:659 +#: ../../howto/functional.rst:656 msgid "This can also be written as a list comprehension:" msgstr "" -#: ../../howto/functional.rst:665 +#: ../../howto/functional.rst:662 msgid "" ":func:`enumerate(iter, start=0) ` counts off the elements in the " "iterable returning 2-tuples containing the count (from *start*) and each " "element. ::" msgstr "" -#: ../../howto/functional.rst:669 +#: ../../howto/functional.rst:666 msgid "" ">>> for item in enumerate(['subject', 'verb', 'object']):\n" "... print(item)\n" @@ -980,13 +964,13 @@ msgstr "" "(1, 'verb')\n" "(2, 'object')" -#: ../../howto/functional.rst:675 +#: ../../howto/functional.rst:672 msgid "" ":func:`enumerate` is often used when looping through a list and recording " "the indexes at which certain conditions are met::" msgstr "" -#: ../../howto/functional.rst:678 +#: ../../howto/functional.rst:675 msgid "" "f = open('data.txt', 'r')\n" "for i, line in enumerate(f):\n" @@ -998,7 +982,7 @@ msgstr "" " if line.strip() == '':\n" " print('Blank line at line #%i' % i)" -#: ../../howto/functional.rst:683 +#: ../../howto/functional.rst:680 msgid "" ":func:`sorted(iterable, key=None, reverse=False) ` collects all the " "elements of the iterable into a list, sorts the list, and returns the sorted " @@ -1006,7 +990,7 @@ msgid "" "constructed list's :meth:`~list.sort` method. ::" msgstr "" -#: ../../howto/functional.rst:688 +#: ../../howto/functional.rst:685 msgid "" ">>> import random\n" ">>> # Generate 8 random numbers between [0, 10000)\n" @@ -1028,12 +1012,12 @@ msgstr "" ">>> sorted(rand_list, reverse=True)\n" "[9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]" -#: ../../howto/functional.rst:698 +#: ../../howto/functional.rst:695 msgid "" "(For a more detailed discussion of sorting, see the :ref:`sortinghowto`.)" msgstr "" -#: ../../howto/functional.rst:701 +#: ../../howto/functional.rst:698 msgid "" "The :func:`any(iter) ` and :func:`all(iter) ` built-ins look at " "the truth values of an iterable's contents. :func:`any` returns ``True`` if " @@ -1041,13 +1025,13 @@ msgid "" "``True`` if all of the elements are true values:" msgstr "" -#: ../../howto/functional.rst:720 +#: ../../howto/functional.rst:717 msgid "" ":func:`zip(iterA, iterB, ...) ` takes one element from each iterable " "and returns them in a tuple::" msgstr "" -#: ../../howto/functional.rst:723 +#: ../../howto/functional.rst:720 msgid "" "zip(['a', 'b', 'c'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2), ('c', 3)" @@ -1055,7 +1039,7 @@ msgstr "" "zip(['a', 'b', 'c'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2), ('c', 3)" -#: ../../howto/functional.rst:726 +#: ../../howto/functional.rst:723 msgid "" "It doesn't construct an in-memory list and :term:`exhaust ` all " "the input iterators before returning; instead tuples are constructed and " @@ -1063,14 +1047,14 @@ msgid "" "is `lazy evaluation `__.)" msgstr "" -#: ../../howto/functional.rst:732 +#: ../../howto/functional.rst:729 msgid "" "This iterator is intended to be used with iterables that are all of the same " "length. If the iterables are of different lengths, the resulting stream " "will be the same length as the shortest iterable. ::" msgstr "" -#: ../../howto/functional.rst:736 +#: ../../howto/functional.rst:733 msgid "" "zip(['a', 'b'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2)" @@ -1078,49 +1062,49 @@ msgstr "" "zip(['a', 'b'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2)" -#: ../../howto/functional.rst:739 +#: ../../howto/functional.rst:736 msgid "" "You should avoid doing this, though, because an element may be taken from " "the longer iterators and discarded. This means you can't go on to use the " "iterators further because you risk skipping a discarded element." msgstr "" -#: ../../howto/functional.rst:745 +#: ../../howto/functional.rst:742 msgid "The itertools module" msgstr "itertools 模組" -#: ../../howto/functional.rst:747 +#: ../../howto/functional.rst:744 msgid "" "The :mod:`itertools` module contains a number of commonly used iterators as " "well as functions for combining several iterators. This section will " "introduce the module's contents by showing small examples." msgstr "" -#: ../../howto/functional.rst:751 +#: ../../howto/functional.rst:748 msgid "The module's functions fall into a few broad classes:" msgstr "" -#: ../../howto/functional.rst:753 +#: ../../howto/functional.rst:750 msgid "Functions that create a new iterator based on an existing iterator." msgstr "" -#: ../../howto/functional.rst:754 +#: ../../howto/functional.rst:751 msgid "Functions for treating an iterator's elements as function arguments." msgstr "" -#: ../../howto/functional.rst:755 +#: ../../howto/functional.rst:752 msgid "Functions for selecting portions of an iterator's output." msgstr "" -#: ../../howto/functional.rst:756 +#: ../../howto/functional.rst:753 msgid "A function for grouping an iterator's output." msgstr "" -#: ../../howto/functional.rst:759 +#: ../../howto/functional.rst:756 msgid "Creating new iterators" msgstr "建立新的疊代器" -#: ../../howto/functional.rst:761 +#: ../../howto/functional.rst:758 msgid "" ":func:`itertools.count(start, step) ` returns an infinite " "stream of evenly spaced values. You can optionally supply the starting " @@ -1128,7 +1112,7 @@ msgid "" "defaults to 1::" msgstr "" -#: ../../howto/functional.rst:765 +#: ../../howto/functional.rst:762 msgid "" "itertools.count() =>\n" " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...\n" @@ -1144,7 +1128,7 @@ msgstr "" "itertools.count(10, 5) =>\n" " 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, ..." -#: ../../howto/functional.rst:772 +#: ../../howto/functional.rst:769 msgid "" ":func:`itertools.cycle(iter) ` saves a copy of the contents " "of a provided iterable and returns a new iterator that returns its elements " @@ -1152,7 +1136,7 @@ msgid "" "infinitely. ::" msgstr "" -#: ../../howto/functional.rst:776 +#: ../../howto/functional.rst:773 msgid "" "itertools.cycle([1, 2, 3, 4, 5]) =>\n" " 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ..." @@ -1160,14 +1144,14 @@ msgstr "" "itertools.cycle([1, 2, 3, 4, 5]) =>\n" " 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ..." -#: ../../howto/functional.rst:779 +#: ../../howto/functional.rst:776 msgid "" ":func:`itertools.repeat(elem, [n]) ` returns the provided " "element *n* times, or returns the element endlessly if *n* is not " "provided. ::" msgstr "" -#: ../../howto/functional.rst:782 +#: ../../howto/functional.rst:779 msgid "" "itertools.repeat('abc') =>\n" " abc, abc, abc, abc, abc, abc, abc, abc, abc, abc, ...\n" @@ -1179,7 +1163,7 @@ msgstr "" "itertools.repeat('abc', 5) =>\n" " abc, abc, abc, abc, abc" -#: ../../howto/functional.rst:787 +#: ../../howto/functional.rst:784 msgid "" ":func:`itertools.chain(iterA, iterB, ...) ` takes an " "arbitrary number of iterables as input, and returns all the elements of the " @@ -1187,7 +1171,7 @@ msgid "" "the iterables have been :term:`exhausted`. ::" msgstr "" -#: ../../howto/functional.rst:792 +#: ../../howto/functional.rst:789 msgid "" "itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>\n" " a, b, c, 1, 2, 3" @@ -1195,7 +1179,7 @@ msgstr "" "itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>\n" " a, b, c, 1, 2, 3" -#: ../../howto/functional.rst:795 +#: ../../howto/functional.rst:792 msgid "" ":func:`itertools.islice(iter, [start], stop, [step]) ` " "returns a stream that's a slice of the iterator. With a single *stop* " @@ -1206,7 +1190,7 @@ msgid "" "*step*. ::" msgstr "" -#: ../../howto/functional.rst:802 +#: ../../howto/functional.rst:799 msgid "" "itertools.islice(range(10), 8) =>\n" " 0, 1, 2, 3, 4, 5, 6, 7\n" @@ -1222,7 +1206,7 @@ msgstr "" "itertools.islice(range(10), 2, 8, 2) =>\n" " 2, 4, 6" -#: ../../howto/functional.rst:809 +#: ../../howto/functional.rst:806 msgid "" ":func:`itertools.tee(iter, [n]) ` replicates an iterator; it " "returns *n* independent iterators that will all return the contents of the " @@ -1232,7 +1216,7 @@ msgid "" "and one of the new iterators is consumed more than the others. ::" msgstr "" -#: ../../howto/functional.rst:817 +#: ../../howto/functional.rst:814 msgid "" "itertools.tee( itertools.count() ) =>\n" " iterA, iterB\n" @@ -1252,11 +1236,11 @@ msgstr "" "and iterB ->\n" " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ..." -#: ../../howto/functional.rst:828 +#: ../../howto/functional.rst:825 msgid "Calling functions on elements" msgstr "" -#: ../../howto/functional.rst:830 +#: ../../howto/functional.rst:827 msgid "" "The :mod:`operator` module contains a set of functions corresponding to " "Python's operators. Some examples are :func:`operator.add(a, b) ` assumes that the " "iterable will return a stream of tuples, and calls *func* using these tuples " "as the arguments::" msgstr "" -#: ../../howto/functional.rst:840 +#: ../../howto/functional.rst:837 msgid "" "itertools.starmap(os.path.join,\n" " [('/bin', 'python'), ('/usr', 'bin', 'java'),\n" @@ -1286,24 +1270,24 @@ msgstr "" "=>\n" " /bin/python, /usr/bin/java, /usr/bin/perl, /usr/bin/ruby" -#: ../../howto/functional.rst:848 +#: ../../howto/functional.rst:845 msgid "Selecting elements" msgstr "" -#: ../../howto/functional.rst:850 +#: ../../howto/functional.rst:847 msgid "" "Another group of functions chooses a subset of an iterator's elements based " "on a predicate." msgstr "" -#: ../../howto/functional.rst:853 +#: ../../howto/functional.rst:850 msgid "" ":func:`itertools.filterfalse(predicate, iter) ` is " "the opposite of :func:`filter`, returning all elements for which the " "predicate returns false::" msgstr "" -#: ../../howto/functional.rst:857 +#: ../../howto/functional.rst:854 msgid "" "itertools.filterfalse(is_even, itertools.count()) =>\n" " 1, 3, 5, 7, 9, 11, 13, 15, ..." @@ -1311,14 +1295,14 @@ msgstr "" "itertools.filterfalse(is_even, itertools.count()) =>\n" " 1, 3, 5, 7, 9, 11, 13, 15, ..." -#: ../../howto/functional.rst:860 +#: ../../howto/functional.rst:857 msgid "" ":func:`itertools.takewhile(predicate, iter) ` returns " "elements for as long as the predicate returns true. Once the predicate " "returns false, the iterator will signal the end of its results. ::" msgstr "" -#: ../../howto/functional.rst:864 +#: ../../howto/functional.rst:861 msgid "" "def less_than_10(x):\n" " return x < 10\n" @@ -1338,14 +1322,14 @@ msgstr "" "itertools.takewhile(is_even, itertools.count()) =>\n" " 0" -#: ../../howto/functional.rst:873 +#: ../../howto/functional.rst:870 msgid "" ":func:`itertools.dropwhile(predicate, iter) ` discards " "elements while the predicate returns true, and then returns the rest of the " "iterable's results. ::" msgstr "" -#: ../../howto/functional.rst:877 +#: ../../howto/functional.rst:874 msgid "" "itertools.dropwhile(less_than_10, itertools.count()) =>\n" " 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...\n" @@ -1359,7 +1343,7 @@ msgstr "" "itertools.dropwhile(is_even, itertools.count()) =>\n" " 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..." -#: ../../howto/functional.rst:883 +#: ../../howto/functional.rst:880 msgid "" ":func:`itertools.compress(data, selectors) ` takes two " "iterators and returns only those elements of *data* for which the " @@ -1367,7 +1351,7 @@ msgid "" "is :term:`exhausted`::" msgstr "" -#: ../../howto/functional.rst:887 +#: ../../howto/functional.rst:884 msgid "" "itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>\n" " 1, 2, 5" @@ -1375,18 +1359,18 @@ msgstr "" "itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>\n" " 1, 2, 5" -#: ../../howto/functional.rst:892 +#: ../../howto/functional.rst:889 msgid "Combinatoric functions" msgstr "" -#: ../../howto/functional.rst:894 +#: ../../howto/functional.rst:891 msgid "" "The :func:`itertools.combinations(iterable, r) ` " "returns an iterator giving all possible *r*-tuple combinations of the " "elements contained in *iterable*. ::" msgstr "" -#: ../../howto/functional.rst:898 +#: ../../howto/functional.rst:895 msgid "" "itertools.combinations([1, 2, 3, 4, 5], 2) =>\n" " (1, 2), (1, 3), (1, 4), (1, 5),\n" @@ -1410,7 +1394,7 @@ msgstr "" " (2, 3, 4), (2, 3, 5), (2, 4, 5),\n" " (3, 4, 5)" -#: ../../howto/functional.rst:909 +#: ../../howto/functional.rst:906 msgid "" "The elements within each tuple remain in the same order as *iterable* " "returned them. For example, the number 1 is always before 2, 3, 4, or 5 in " @@ -1419,7 +1403,7 @@ msgid "" "constraint on the order, returning all possible arrangements of length *r*::" msgstr "" -#: ../../howto/functional.rst:916 +#: ../../howto/functional.rst:913 msgid "" "itertools.permutations([1, 2, 3, 4, 5], 2) =>\n" " (1, 2), (1, 3), (1, 4), (1, 5),\n" @@ -1445,19 +1429,19 @@ msgstr "" " ...\n" " (5, 4, 3, 2, 1)" -#: ../../howto/functional.rst:928 +#: ../../howto/functional.rst:925 msgid "" "If you don't supply a value for *r* the length of the iterable is used, " "meaning that all the elements are permuted." msgstr "" -#: ../../howto/functional.rst:931 +#: ../../howto/functional.rst:928 msgid "" "Note that these functions produce all of the possible combinations by " "position and don't require that the contents of *iterable* are unique::" msgstr "" -#: ../../howto/functional.rst:934 +#: ../../howto/functional.rst:931 msgid "" "itertools.permutations('aba', 3) =>\n" " ('a', 'b', 'a'), ('a', 'a', 'b'), ('b', 'a', 'a'),\n" @@ -1467,13 +1451,13 @@ msgstr "" " ('a', 'b', 'a'), ('a', 'a', 'b'), ('b', 'a', 'a'),\n" " ('b', 'a', 'a'), ('a', 'a', 'b'), ('a', 'b', 'a')" -#: ../../howto/functional.rst:938 +#: ../../howto/functional.rst:935 msgid "" "The identical tuple ``('a', 'a', 'b')`` occurs twice, but the two 'a' " "strings came from different positions." msgstr "" -#: ../../howto/functional.rst:941 +#: ../../howto/functional.rst:938 msgid "" "The :func:`itertools.combinations_with_replacement(iterable, r) ` function relaxes a different constraint: " @@ -1482,7 +1466,7 @@ msgid "" "the second element is selected. ::" msgstr "" -#: ../../howto/functional.rst:947 +#: ../../howto/functional.rst:944 msgid "" "itertools.combinations_with_replacement([1, 2, 3, 4, 5], 2) =>\n" " (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),\n" @@ -1498,11 +1482,11 @@ msgstr "" " (4, 4), (4, 5),\n" " (5, 5)" -#: ../../howto/functional.rst:956 +#: ../../howto/functional.rst:953 msgid "Grouping elements" msgstr "" -#: ../../howto/functional.rst:958 +#: ../../howto/functional.rst:955 msgid "" "The last function I'll discuss, :func:`itertools.groupby(iter, " "key_func=None) `, is the most complicated. " @@ -1511,14 +1495,14 @@ msgid "" "key is simply each element itself." msgstr "" -#: ../../howto/functional.rst:963 +#: ../../howto/functional.rst:960 msgid "" ":func:`~itertools.groupby` collects all the consecutive elements from the " "underlying iterable that have the same key value, and returns a stream of 2-" "tuples containing a key value and an iterator for the elements with that key." msgstr "" -#: ../../howto/functional.rst:969 +#: ../../howto/functional.rst:966 msgid "" "city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'),\n" " ('Anchorage', 'AK'), ('Nome', 'AK'),\n" @@ -1564,7 +1548,7 @@ msgstr "" "iterator-3 =>\n" " ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')" -#: ../../howto/functional.rst:991 +#: ../../howto/functional.rst:988 msgid "" ":func:`~itertools.groupby` assumes that the underlying iterable's contents " "will already be sorted based on the key. Note that the returned iterators " @@ -1572,11 +1556,11 @@ msgid "" "iterator-1 before requesting iterator-2 and its corresponding key." msgstr "" -#: ../../howto/functional.rst:998 +#: ../../howto/functional.rst:995 msgid "The functools module" msgstr "functools 模組" -#: ../../howto/functional.rst:1000 +#: ../../howto/functional.rst:997 msgid "" "The :mod:`functools` module contains some higher-order functions. A **higher-" "order function** takes one or more functions as input and returns a new " @@ -1584,7 +1568,7 @@ msgid "" "partial` function." msgstr "" -#: ../../howto/functional.rst:1005 +#: ../../howto/functional.rst:1002 msgid "" "For programs written in a functional style, you'll sometimes want to " "construct variants of existing functions that have some of the parameters " @@ -1594,7 +1578,7 @@ msgid "" "\"partial function application\"." msgstr "" -#: ../../howto/functional.rst:1011 +#: ../../howto/functional.rst:1008 msgid "" "The constructor for :func:`~functools.partial` takes the arguments " "``(function, arg1, arg2, ..., kwarg1=value1, kwarg2=value2)``. The " @@ -1602,11 +1586,11 @@ msgid "" "with the filled-in arguments." msgstr "" -#: ../../howto/functional.rst:1016 +#: ../../howto/functional.rst:1013 msgid "Here's a small but realistic example::" msgstr "以下是個很小但實際的範例: ::" -#: ../../howto/functional.rst:1018 +#: ../../howto/functional.rst:1015 msgid "" "import functools\n" "\n" @@ -1619,7 +1603,7 @@ msgid "" "server_log('Unable to open socket')" msgstr "" -#: ../../howto/functional.rst:1028 +#: ../../howto/functional.rst:1025 msgid "" ":func:`functools.reduce(func, iter, [initial_value]) ` " "cumulatively performs an operation on all the iterable's elements and, " @@ -1634,7 +1618,7 @@ msgid "" "``func(initial_value, A)`` is the first calculation. ::" msgstr "" -#: ../../howto/functional.rst:1040 +#: ../../howto/functional.rst:1037 msgid "" ">>> import operator, functools\n" ">>> functools.reduce(operator.concat, ['A', 'BB', 'C'])\n" @@ -1660,20 +1644,20 @@ msgstr "" ">>> functools.reduce(operator.mul, [], 1)\n" "1" -#: ../../howto/functional.rst:1052 +#: ../../howto/functional.rst:1049 msgid "" "If you use :func:`operator.add` with :func:`functools.reduce`, you'll add up " "all the elements of the iterable. This case is so common that there's a " "special built-in called :func:`sum` to compute it:" msgstr "" -#: ../../howto/functional.rst:1064 +#: ../../howto/functional.rst:1061 msgid "" "For many uses of :func:`functools.reduce`, though, it can be clearer to just " "write the obvious :keyword:`for` loop::" msgstr "" -#: ../../howto/functional.rst:1067 +#: ../../howto/functional.rst:1064 msgid "" "import functools\n" "# Instead of:\n" @@ -1685,7 +1669,7 @@ msgid "" " product *= i" msgstr "" -#: ../../howto/functional.rst:1076 +#: ../../howto/functional.rst:1073 msgid "" "A related function is :func:`itertools.accumulate(iterable, func=operator." "add) `. It performs the same calculation, but instead " @@ -1693,7 +1677,7 @@ msgid "" "iterator that also yields each partial result::" msgstr "" -#: ../../howto/functional.rst:1081 +#: ../../howto/functional.rst:1078 msgid "" "itertools.accumulate([1, 2, 3, 4, 5]) =>\n" " 1, 3, 6, 10, 15\n" @@ -1707,11 +1691,11 @@ msgstr "" "itertools.accumulate([1, 2, 3, 4, 5], operator.mul) =>\n" " 1, 2, 6, 24, 120" -#: ../../howto/functional.rst:1089 +#: ../../howto/functional.rst:1086 msgid "The operator module" msgstr "operator 模組" -#: ../../howto/functional.rst:1091 +#: ../../howto/functional.rst:1088 msgid "" "The :mod:`operator` module was mentioned earlier. It contains a set of " "functions corresponding to Python's operators. These functions are often " @@ -1719,55 +1703,55 @@ msgid "" "functions that perform a single operation." msgstr "" -#: ../../howto/functional.rst:1096 +#: ../../howto/functional.rst:1093 msgid "Some of the functions in this module are:" msgstr "" -#: ../../howto/functional.rst:1098 +#: ../../howto/functional.rst:1095 msgid "" "Math operations: ``add()``, ``sub()``, ``mul()``, ``floordiv()``, " "``abs()``, ..." msgstr "" "數學運算:``add()``、``sub()``、``mul()``、``floordiv()``、``abs()``..." -#: ../../howto/functional.rst:1099 +#: ../../howto/functional.rst:1096 msgid "Logical operations: ``not_()``, ``truth()``." msgstr "" -#: ../../howto/functional.rst:1100 +#: ../../howto/functional.rst:1097 msgid "Bitwise operations: ``and_()``, ``or_()``, ``invert()``." msgstr "" -#: ../../howto/functional.rst:1101 +#: ../../howto/functional.rst:1098 msgid "" "Comparisons: ``eq()``, ``ne()``, ``lt()``, ``le()``, ``gt()``, and ``ge()``." msgstr "" -#: ../../howto/functional.rst:1102 +#: ../../howto/functional.rst:1099 msgid "Object identity: ``is_()``, ``is_not()``." msgstr "" -#: ../../howto/functional.rst:1104 +#: ../../howto/functional.rst:1101 msgid "Consult the operator module's documentation for a complete list." msgstr "" -#: ../../howto/functional.rst:1108 +#: ../../howto/functional.rst:1105 msgid "Small functions and the lambda expression" msgstr "" -#: ../../howto/functional.rst:1110 +#: ../../howto/functional.rst:1107 msgid "" "When writing functional-style programs, you'll often need little functions " "that act as predicates or that combine elements in some way." msgstr "" -#: ../../howto/functional.rst:1113 +#: ../../howto/functional.rst:1110 msgid "" "If there's a Python built-in or a module function that's suitable, you don't " "need to define a new function at all::" msgstr "" -#: ../../howto/functional.rst:1116 +#: ../../howto/functional.rst:1113 msgid "" "stripped_lines = [line.strip() for line in lines]\n" "existing_files = filter(os.path.exists, file_list)" @@ -1775,7 +1759,7 @@ msgstr "" "stripped_lines = [line.strip() for line in lines]\n" "existing_files = filter(os.path.exists, file_list)" -#: ../../howto/functional.rst:1119 +#: ../../howto/functional.rst:1116 msgid "" "If the function you need doesn't exist, you need to write it. One way to " "write small functions is to use the :keyword:`lambda` expression. " @@ -1784,7 +1768,7 @@ msgid "" "expression::" msgstr "" -#: ../../howto/functional.rst:1124 +#: ../../howto/functional.rst:1121 msgid "" "adder = lambda x, y: x+y\n" "\n" @@ -1794,13 +1778,13 @@ msgstr "" "\n" "print_assign = lambda name, value: name + '=' + str(value)" -#: ../../howto/functional.rst:1128 +#: ../../howto/functional.rst:1125 msgid "" "An alternative is to just use the ``def`` statement and define a function in " "the usual way::" msgstr "" -#: ../../howto/functional.rst:1131 +#: ../../howto/functional.rst:1128 msgid "" "def adder(x, y):\n" " return x + y\n" @@ -1814,13 +1798,13 @@ msgstr "" "def print_assign(name, value):\n" " return name + '=' + str(value)" -#: ../../howto/functional.rst:1137 +#: ../../howto/functional.rst:1134 msgid "" "Which alternative is preferable? That's a style question; my usual course " "is to avoid using ``lambda``." msgstr "" -#: ../../howto/functional.rst:1140 +#: ../../howto/functional.rst:1137 msgid "" "One reason for my preference is that ``lambda`` is quite limited in the " "functions it can define. The result has to be computable as a single " @@ -1830,7 +1814,7 @@ msgid "" "that's hard to read. Quick, what's the following code doing? ::" msgstr "" -#: ../../howto/functional.rst:1147 +#: ../../howto/functional.rst:1144 msgid "" "import functools\n" "total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]" @@ -1838,14 +1822,14 @@ msgstr "" "import functools\n" "total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]" -#: ../../howto/functional.rst:1150 +#: ../../howto/functional.rst:1147 msgid "" "You can figure it out, but it takes time to disentangle the expression to " "figure out what's going on. Using a short nested ``def`` statements makes " "things a little bit better::" msgstr "" -#: ../../howto/functional.rst:1154 +#: ../../howto/functional.rst:1151 msgid "" "import functools\n" "def combine(a, b):\n" @@ -1859,11 +1843,11 @@ msgstr "" "\n" "total = functools.reduce(combine, items)[1]" -#: ../../howto/functional.rst:1160 +#: ../../howto/functional.rst:1157 msgid "But it would be best of all if I had simply used a ``for`` loop::" msgstr "" -#: ../../howto/functional.rst:1162 +#: ../../howto/functional.rst:1159 msgid "" "total = 0\n" "for a, b in items:\n" @@ -1873,100 +1857,101 @@ msgstr "" "for a, b in items:\n" " total += b" -#: ../../howto/functional.rst:1166 +#: ../../howto/functional.rst:1163 msgid "Or the :func:`sum` built-in and a generator expression::" msgstr "" -#: ../../howto/functional.rst:1168 +#: ../../howto/functional.rst:1165 msgid "total = sum(b for a, b in items)" msgstr "total = sum(b for a, b in items)" -#: ../../howto/functional.rst:1170 +#: ../../howto/functional.rst:1167 msgid "" "Many uses of :func:`functools.reduce` are clearer when written as ``for`` " "loops." msgstr "" -#: ../../howto/functional.rst:1172 +#: ../../howto/functional.rst:1169 msgid "" "Fredrik Lundh once suggested the following set of rules for refactoring uses " "of ``lambda``:" msgstr "" -#: ../../howto/functional.rst:1175 +#: ../../howto/functional.rst:1172 msgid "Write a lambda function." msgstr "" -#: ../../howto/functional.rst:1176 +#: ../../howto/functional.rst:1173 msgid "Write a comment explaining what the heck that lambda does." msgstr "" -#: ../../howto/functional.rst:1177 +#: ../../howto/functional.rst:1174 msgid "" "Study the comment for a while, and think of a name that captures the essence " "of the comment." msgstr "" -#: ../../howto/functional.rst:1179 +#: ../../howto/functional.rst:1176 msgid "Convert the lambda to a def statement, using that name." msgstr "" -#: ../../howto/functional.rst:1180 +#: ../../howto/functional.rst:1177 msgid "Remove the comment." msgstr "" -#: ../../howto/functional.rst:1182 +#: ../../howto/functional.rst:1179 msgid "" "I really like these rules, but you're free to disagree about whether this " "lambda-free style is better." msgstr "" -#: ../../howto/functional.rst:1187 +#: ../../howto/functional.rst:1184 msgid "Revision History and Acknowledgements" msgstr "" -#: ../../howto/functional.rst:1189 +#: ../../howto/functional.rst:1186 msgid "" -"The author would like to thank the following people for offering " -"suggestions, corrections and assistance with various drafts of this article: " -"Ian Bicking, Nick Coghlan, Nick Efford, Raymond Hettinger, Jim Jewett, Mike " -"Krell, Leandro Lameiro, Jussi Salmela, Collin Winter, Blake Winton." +"This HOWTO was originally written by A. M. Kuchling. The author would like " +"to thank the following people for offering suggestions, corrections and " +"assistance with various drafts of this article: Ian Bicking, Nick Coghlan, " +"Nick Efford, Raymond Hettinger, Jim Jewett, Mike Krell, Leandro Lameiro, " +"Jussi Salmela, Collin Winter, Blake Winton." msgstr "" -#: ../../howto/functional.rst:1194 +#: ../../howto/functional.rst:1192 msgid "Version 0.1: posted June 30 2006." msgstr "" -#: ../../howto/functional.rst:1196 +#: ../../howto/functional.rst:1194 msgid "Version 0.11: posted July 1 2006. Typo fixes." msgstr "" -#: ../../howto/functional.rst:1198 +#: ../../howto/functional.rst:1196 msgid "" "Version 0.2: posted July 10 2006. Merged genexp and listcomp sections into " "one. Typo fixes." msgstr "" -#: ../../howto/functional.rst:1201 +#: ../../howto/functional.rst:1199 msgid "" "Version 0.21: Added more references suggested on the tutor mailing list." msgstr "" -#: ../../howto/functional.rst:1203 +#: ../../howto/functional.rst:1201 msgid "" "Version 0.30: Adds a section on the ``functional`` module written by Collin " "Winter; adds short section on the operator module; a few other edits." msgstr "" -#: ../../howto/functional.rst:1208 +#: ../../howto/functional.rst:1206 msgid "References" msgstr "" -#: ../../howto/functional.rst:1211 +#: ../../howto/functional.rst:1209 msgid "General" msgstr "" -#: ../../howto/functional.rst:1213 +#: ../../howto/functional.rst:1211 msgid "" "**Structure and Interpretation of Computer Programs**, by Harold Abelson and " "Gerald Jay Sussman with Julie Sussman. The book can be found at https://" @@ -1977,24 +1962,24 @@ msgid "" "functional-style Python code." msgstr "" -#: ../../howto/functional.rst:1221 +#: ../../howto/functional.rst:1219 msgid "" "https://defmacro.org/2006/06/19/fp.html: A general introduction to " "functional programming that uses Java examples and has a lengthy historical " "introduction." msgstr "" -#: ../../howto/functional.rst:1224 +#: ../../howto/functional.rst:1222 msgid "" "https://en.wikipedia.org/wiki/Functional_programming: General Wikipedia " "entry describing functional programming." msgstr "" -#: ../../howto/functional.rst:1227 +#: ../../howto/functional.rst:1225 msgid "https://en.wikipedia.org/wiki/Coroutine: Entry for coroutines." msgstr "https://en.wikipedia.org/wiki/Coroutine: 協程 (coroutines) 的條目。" -#: ../../howto/functional.rst:1229 +#: ../../howto/functional.rst:1227 msgid "" "https://en.wikipedia.org/wiki/Partial_application: Entry for the concept of " "partial function application." @@ -2002,16 +1987,16 @@ msgstr "" "https://en.wikipedia.org/wiki/Partial_application: 偏函式 (partial " "application) 概念的條目。" -#: ../../howto/functional.rst:1231 +#: ../../howto/functional.rst:1229 msgid "" "https://en.wikipedia.org/wiki/Currying: Entry for the concept of currying." msgstr "https://en.wikipedia.org/wiki/Currying: currying 概念的條目。" -#: ../../howto/functional.rst:1234 +#: ../../howto/functional.rst:1232 msgid "Python-specific" msgstr "Python 特有的" -#: ../../howto/functional.rst:1236 +#: ../../howto/functional.rst:1234 msgid "" "https://gnosis.cx/TPiP/: The first chapter of David Mertz's book :title-" "reference:`Text Processing in Python` discusses functional programming for " @@ -2019,36 +2004,50 @@ msgid "" "Text Processing\"." msgstr "" -#: ../../howto/functional.rst:1241 +#: ../../howto/functional.rst:1239 msgid "" "Mertz also wrote a 3-part series of articles on functional programming for " -"IBM's DeveloperWorks site; see `part 1 `__, `part 2 `__, and " -"`part 3 `__," +"IBM's DeveloperWorks site; see `part 1 `__, `part 2 " +"`__, and `part 3 `__." msgstr "" -#: ../../howto/functional.rst:1249 +#: ../../howto/functional.rst:1247 msgid "Python documentation" msgstr "Python 說明文件" -#: ../../howto/functional.rst:1251 +#: ../../howto/functional.rst:1249 msgid "Documentation for the :mod:`itertools` module." msgstr ":mod:`itertools` 模組的說明文件。" -#: ../../howto/functional.rst:1253 +#: ../../howto/functional.rst:1251 msgid "Documentation for the :mod:`functools` module." msgstr ":mod:`functools` 模組的說明文件。" -#: ../../howto/functional.rst:1255 +#: ../../howto/functional.rst:1253 msgid "Documentation for the :mod:`operator` module." msgstr ":mod:`operator` 模組的說明文件。" -#: ../../howto/functional.rst:1257 +#: ../../howto/functional.rst:1255 msgid ":pep:`289`: \"Generator Expressions\"" msgstr ":pep:`289`:「產生器運算式 (Generator Expressions)」" -#: ../../howto/functional.rst:1259 +#: ../../howto/functional.rst:1257 msgid "" ":pep:`342`: \"Coroutines via Enhanced Generators\" describes the new " "generator features in Python 2.5." msgstr "" + +#~ msgid "Author" +#~ msgstr "作者" + +#~ msgid "\\A. M. Kuchling" +#~ msgstr "\\A. M. Kuchling" + +#~ msgid "Release" +#~ msgstr "發佈版本" + +#~ msgid "0.32" +#~ msgstr "0.32" diff --git a/howto/gdb_helpers.po b/howto/gdb_helpers.po index 76983819c82..f9a4565b074 100644 --- a/howto/gdb_helpers.po +++ b/howto/gdb_helpers.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-06 00:14+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-05-11 14:42+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -264,8 +264,8 @@ msgid "" " {'Yuck': , '__builtins__': , '__file__': 'Lib/test/crashers/nasty_eq_vs_dict.py', " "'__package__': None, 'y': , 'dict': {0: 0, 1: " -"1, 2: 2, 3: 3}, '__cached__': None, '__name__': '__main__', 'z': , '__doc__': None}, key=\n" +"1, 2: 2, 3: 3}, '__name__': '__main__', 'z': , " +"'__doc__': None}, key=\n" " 0x5c2b8d \"__lltrace__\") at Objects/dictobject.c:2171" msgstr "" "#0 0x000000000041a6b1 in PyObject_Malloc (nbytes=Cannot access memory at " @@ -292,8 +292,8 @@ msgstr "" " {'Yuck': , '__builtins__': , '__file__': 'Lib/test/crashers/nasty_eq_vs_dict.py', " "'__package__': None, 'y': , 'dict': {0: 0, 1: " -"1, 2: 2, 3: 3}, '__cached__': None, '__name__': '__main__', 'z': , '__doc__': None}, key=\n" +"1, 2: 2, 3: 3}, '__name__': '__main__', 'z': , " +"'__doc__': None}, key=\n" " 0x5c2b8d \"__lltrace__\") at Objects/dictobject.c:2171" #: ../../howto/gdb_helpers.rst:142 diff --git a/howto/index.po b/howto/index.po index 399d00a18aa..3d8a6514742 100644 --- a/howto/index.po +++ b/howto/index.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -34,114 +34,118 @@ msgstr "" "定的主題。以 Linux 說明文件專案的 HOWTO 系列為模範,本系列的目標是提供比 " "Python 函式庫參考手冊更實用的說明文件。" -#: ../../howto/index.rst:42 +#: ../../howto/index.rst:43 msgid "General:" msgstr "一般:" -#: ../../howto/index.rst:44 +#: ../../howto/index.rst:45 msgid ":ref:`a-conceptual-overview-of-asyncio`" msgstr ":ref:`a-conceptual-overview-of-asyncio`" -#: ../../howto/index.rst:45 +#: ../../howto/index.rst:46 msgid ":ref:`annotations-howto`" msgstr ":ref:`annotations-howto`" -#: ../../howto/index.rst:46 +#: ../../howto/index.rst:47 msgid ":ref:`argparse-tutorial`" msgstr ":ref:`argparse-tutorial`" -#: ../../howto/index.rst:47 +#: ../../howto/index.rst:48 msgid ":ref:`descriptorhowto`" msgstr ":ref:`descriptorhowto`" -#: ../../howto/index.rst:48 +#: ../../howto/index.rst:49 msgid ":ref:`enum-howto`" msgstr ":ref:`enum-howto`" -#: ../../howto/index.rst:49 +#: ../../howto/index.rst:50 msgid ":ref:`functional-howto`" msgstr ":ref:`functional-howto`" -#: ../../howto/index.rst:50 +#: ../../howto/index.rst:51 msgid ":ref:`ipaddress-howto`" msgstr ":ref:`ipaddress-howto`" -#: ../../howto/index.rst:51 +#: ../../howto/index.rst:52 msgid ":ref:`logging-howto`" msgstr ":ref:`logging-howto`" -#: ../../howto/index.rst:52 +#: ../../howto/index.rst:53 msgid ":ref:`logging-cookbook`" msgstr ":ref:`logging-cookbook`" -#: ../../howto/index.rst:53 +#: ../../howto/index.rst:54 msgid ":ref:`regex-howto`" msgstr ":ref:`regex-howto`" -#: ../../howto/index.rst:54 +#: ../../howto/index.rst:55 msgid ":ref:`sortinghowto`" msgstr ":ref:`sortinghowto`" -#: ../../howto/index.rst:55 +#: ../../howto/index.rst:56 msgid ":ref:`unicode-howto`" msgstr ":ref:`unicode-howto`" -#: ../../howto/index.rst:56 +#: ../../howto/index.rst:57 msgid ":ref:`urllib-howto`" msgstr ":ref:`urllib-howto`" -#: ../../howto/index.rst:58 +#: ../../howto/index.rst:59 msgid "Advanced development:" msgstr "進階開發:" -#: ../../howto/index.rst:60 +#: ../../howto/index.rst:61 msgid ":ref:`curses-howto`" msgstr ":ref:`curses-howto`" -#: ../../howto/index.rst:61 +#: ../../howto/index.rst:62 msgid ":ref:`freethreading-python-howto`" msgstr ":ref:`freethreading-python-howto`" -#: ../../howto/index.rst:62 +#: ../../howto/index.rst:63 msgid ":ref:`freethreading-extensions-howto`" msgstr ":ref:`freethreading-extensions-howto`" -#: ../../howto/index.rst:63 +#: ../../howto/index.rst:64 msgid ":ref:`isolating-extensions-howto`" msgstr ":ref:`isolating-extensions-howto`" -#: ../../howto/index.rst:64 +#: ../../howto/index.rst:65 +msgid ":ref:`abi3t-migration-howto`" +msgstr ":ref:`abi3t-migration-howto`" + +#: ../../howto/index.rst:66 msgid ":ref:`python_2.3_mro`" msgstr ":ref:`python_2.3_mro`" -#: ../../howto/index.rst:65 +#: ../../howto/index.rst:67 msgid ":ref:`socket-howto`" msgstr ":ref:`socket-howto`" -#: ../../howto/index.rst:66 +#: ../../howto/index.rst:68 msgid ":ref:`timerfd-howto`" msgstr ":ref:`timerfd-howto`" -#: ../../howto/index.rst:67 +#: ../../howto/index.rst:69 msgid ":ref:`cporting-howto`" msgstr ":ref:`cporting-howto`" -#: ../../howto/index.rst:69 +#: ../../howto/index.rst:71 msgid "Debugging and profiling:" msgstr "偵錯與效能分析:" -#: ../../howto/index.rst:71 +#: ../../howto/index.rst:73 msgid ":ref:`gdb`" msgstr ":ref:`gdb`" -#: ../../howto/index.rst:72 +#: ../../howto/index.rst:74 msgid ":ref:`instrumentation`" msgstr ":ref:`instrumentation`" -#: ../../howto/index.rst:73 +#: ../../howto/index.rst:75 msgid ":ref:`perf_profiling`" msgstr ":ref:`perf_profiling`" -#: ../../howto/index.rst:74 +#: ../../howto/index.rst:76 msgid ":ref:`remote-debugging`" msgstr ":ref:`remote-debugging`" diff --git a/howto/instrumentation.po b/howto/instrumentation.po index c830fbb6d5b..04d7cfb2db3 100644 --- a/howto/instrumentation.po +++ b/howto/instrumentation.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-16 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-08-17 22:17+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,19 +23,7 @@ msgstr "" msgid "Instrumenting CPython with DTrace and SystemTap" msgstr "使用 DTrace 和 SystemTap 檢測 CPython" -#: ../../howto/instrumentation.rst:0 -msgid "author" -msgstr "作者" - #: ../../howto/instrumentation.rst:9 -msgid "David Malcolm" -msgstr "David Malcolm" - -#: ../../howto/instrumentation.rst:10 -msgid "Łukasz Langa" -msgstr "Łukasz Langa" - -#: ../../howto/instrumentation.rst:12 msgid "" "DTrace and SystemTap are monitoring tools, each providing a way to inspect " "what the processes on a computer system are doing. They both use domain-" @@ -45,19 +33,19 @@ msgstr "" "(process) 正在執行什麼操作的方法。它們都使用了領域限定 (domain-specific) 的語" "言,允許使用者編寫以下腳本:" -#: ../../howto/instrumentation.rst:16 +#: ../../howto/instrumentation.rst:13 msgid "filter which processes are to be observed" msgstr "過濾要觀察的行程" -#: ../../howto/instrumentation.rst:17 +#: ../../howto/instrumentation.rst:14 msgid "gather data from the processes of interest" msgstr "收集來自感興趣之行程的資料" -#: ../../howto/instrumentation.rst:18 +#: ../../howto/instrumentation.rst:15 msgid "generate reports on the data" msgstr "以這些資料產生報告" -#: ../../howto/instrumentation.rst:20 +#: ../../howto/instrumentation.rst:17 msgid "" "As of Python 3.6, CPython can be built with embedded \"markers\", also known " "as \"probes\", that can be observed by a DTrace or SystemTap script, making " @@ -67,7 +55,7 @@ msgstr "" "(probe)」)建置,可以透過 DTrace 或 SystemTap 腳本進行觀察,從而更輕鬆地監視" "系統之 CPython 行程正在執行的操作。" -#: ../../howto/instrumentation.rst:27 +#: ../../howto/instrumentation.rst:24 msgid "" "DTrace markers are implementation details of the CPython interpreter. No " "guarantees are made about probe compatibility between versions of CPython. " @@ -77,11 +65,11 @@ msgstr "" "DTrace 標記是 CPython 直譯器的實作細節。不保證 CPython 版本之間的探針相容性。" "更改 CPython 版本時,DTrace 腳本可能會停止運作或錯誤地運作,而不會發出警告。" -#: ../../howto/instrumentation.rst:34 +#: ../../howto/instrumentation.rst:31 msgid "Enabling the static markers" msgstr "啟用靜態標記" -#: ../../howto/instrumentation.rst:36 +#: ../../howto/instrumentation.rst:33 msgid "" "macOS comes with built-in support for DTrace. On Linux, in order to build " "CPython with the embedded markers for SystemTap, the SystemTap development " @@ -90,34 +78,34 @@ msgstr "" "macOS 內建了對 DTrace 的支援。在 Linux 上,為了建置帶有 SystemTap 嵌入標記的 " "CPython,必須安裝 SystemTap 開發工具。" -#: ../../howto/instrumentation.rst:40 +#: ../../howto/instrumentation.rst:37 msgid "On a Linux machine, this can be done via::" msgstr "在 Linux 機器上,這可以透過以下方式完成: ::" -#: ../../howto/instrumentation.rst:42 +#: ../../howto/instrumentation.rst:39 msgid "$ yum install systemtap-sdt-devel" msgstr "$ yum install systemtap-sdt-devel" -#: ../../howto/instrumentation.rst:44 +#: ../../howto/instrumentation.rst:41 msgid "or::" msgstr "或是: ::" -#: ../../howto/instrumentation.rst:46 +#: ../../howto/instrumentation.rst:43 msgid "$ sudo apt-get install systemtap-sdt-dev" msgstr "$ sudo apt-get install systemtap-sdt-dev" -#: ../../howto/instrumentation.rst:49 +#: ../../howto/instrumentation.rst:46 msgid "" "CPython must then be :option:`configured with the --with-dtrace option <--" "with-dtrace>`:" msgstr "" "然後 CPython 必須使用\\ :option:`配置 --with-dtrace 選項 <--with-dtrace>`:" -#: ../../howto/instrumentation.rst:52 +#: ../../howto/instrumentation.rst:49 msgid "checking for --with-dtrace... yes" msgstr "checking for --with-dtrace... yes" -#: ../../howto/instrumentation.rst:56 +#: ../../howto/instrumentation.rst:53 msgid "" "On macOS, you can list available DTrace probes by running a Python process " "in the background and listing all probes made available by the Python " @@ -126,7 +114,7 @@ msgstr "" "在 macOS 上,你可以透過在後台運行 Python 行程並列出 Python 發布者 (provider) " "所提供的所有可用探針,以列出可用的 DTrace 探針: ::" -#: ../../howto/instrumentation.rst:60 +#: ../../howto/instrumentation.rst:57 msgid "" "$ python3.6 -q &\n" "$ sudo dtrace -l -P python$! # or: dtrace -l -m python3.6\n" @@ -166,7 +154,7 @@ msgstr "" "29570 python18035 python3.6 _PyEval_EvalFrameDefault line\n" "29571 python18035 python3.6 maybe_dtrace_line line" -#: ../../howto/instrumentation.rst:73 +#: ../../howto/instrumentation.rst:70 msgid "" "On Linux, you can verify if the SystemTap static markers are present in the " "built binary by seeing if it contains a \".note.stapsdt\" section." @@ -174,7 +162,7 @@ msgstr "" "在 Linux 上,你可以透過查看二進位建置檔案中是否包含 \".note.stapsdt\" 部分來" "驗證 SystemTap 靜態標記是否存在。" -#: ../../howto/instrumentation.rst:78 +#: ../../howto/instrumentation.rst:75 msgid "" "$ readelf -S ./python | grep .note.stapsdt\n" "[30] .note.stapsdt NOTE 0000000000000000 00308d78" @@ -182,7 +170,7 @@ msgstr "" "$ readelf -S ./python | grep .note.stapsdt\n" "[30] .note.stapsdt NOTE 0000000000000000 00308d78" -#: ../../howto/instrumentation.rst:81 +#: ../../howto/instrumentation.rst:78 msgid "" "If you've built Python as a shared library (with the :option:`--enable-" "shared` configure option), you need to look instead within the shared " @@ -191,7 +179,7 @@ msgstr "" "如果你已將 Python 建置為共享函式庫(使用 :option:`--enable-shared` 配置選" "項),則需要在共享函式庫中查找。例如: ::" -#: ../../howto/instrumentation.rst:85 +#: ../../howto/instrumentation.rst:82 msgid "" "$ readelf -S libpython3.3dm.so.1.0 | grep .note.stapsdt\n" "[29] .note.stapsdt NOTE 0000000000000000 00365b68" @@ -199,11 +187,11 @@ msgstr "" "$ readelf -S libpython3.3dm.so.1.0 | grep .note.stapsdt\n" "[29] .note.stapsdt NOTE 0000000000000000 00365b68" -#: ../../howto/instrumentation.rst:88 +#: ../../howto/instrumentation.rst:85 msgid "Sufficiently modern readelf can print the metadata::" msgstr "足夠現代化的 readelf 可以印出元資料 (metadata): ::" -#: ../../howto/instrumentation.rst:90 +#: ../../howto/instrumentation.rst:87 msgid "" "$ readelf -n ./python\n" "\n" @@ -295,7 +283,7 @@ msgstr "" "0x00000000008d6bea\n" " Arguments: 8@%rbp 8@%r12 -4@%eax" -#: ../../howto/instrumentation.rst:125 +#: ../../howto/instrumentation.rst:122 msgid "" "The above metadata contains information for SystemTap describing how it can " "patch strategically placed machine code instructions to enable the tracing " @@ -304,11 +292,11 @@ msgstr "" "上述元資料包含 SystemTap 的資訊,描述了它如何修補策略性放置的機器碼指令以啟" "用 SystemTap 腳本使用的追蹤 hook。" -#: ../../howto/instrumentation.rst:131 +#: ../../howto/instrumentation.rst:128 msgid "Static DTrace probes" msgstr "靜態 DTrace 探針" -#: ../../howto/instrumentation.rst:133 +#: ../../howto/instrumentation.rst:130 msgid "" "The following example DTrace script can be used to show the call/return " "hierarchy of a Python script, only tracing within the invocation of a " @@ -318,7 +306,7 @@ msgstr "" "以下範例示範 DTrace 腳本可用於顯示 Python 腳本的呼叫/回傳階層結構,僅在名為 " "\"start\" 的函式的呼叫內進行追蹤。換句話說,引入時的函式呼叫不會被列出:" -#: ../../howto/instrumentation.rst:138 +#: ../../howto/instrumentation.rst:135 msgid "" "self int indent;\n" "\n" @@ -388,19 +376,19 @@ msgstr "" " self->trace = 0;\n" "}" -#: ../../howto/instrumentation.rst:172 ../../howto/instrumentation.rst:230 +#: ../../howto/instrumentation.rst:169 ../../howto/instrumentation.rst:227 msgid "It can be invoked like this::" msgstr "可以這樣呼叫: ::" -#: ../../howto/instrumentation.rst:174 +#: ../../howto/instrumentation.rst:171 msgid "$ sudo dtrace -q -s call_stack.d -c \"python3.6 script.py\"" msgstr "$ sudo dtrace -q -s call_stack.d -c \"python3.6 script.py\"" -#: ../../howto/instrumentation.rst:176 ../../howto/instrumentation.rst:236 +#: ../../howto/instrumentation.rst:173 ../../howto/instrumentation.rst:233 msgid "The output looks like this:" msgstr "輸出如下所示:" -#: ../../howto/instrumentation.rst:178 +#: ../../howto/instrumentation.rst:175 msgid "" "156641360502280 function-entry:call_stack.py:start:23\n" "156641360518804 function-entry: call_stack.py:function_1:1\n" @@ -440,11 +428,11 @@ msgstr "" "156641360732567 function-return: call_stack.py:function_5:21\n" "156641360747370 function-return:call_stack.py:start:28" -#: ../../howto/instrumentation.rst:201 +#: ../../howto/instrumentation.rst:198 msgid "Static SystemTap markers" msgstr "靜態 SystemTap 標記" -#: ../../howto/instrumentation.rst:203 +#: ../../howto/instrumentation.rst:200 msgid "" "The low-level way to use the SystemTap integration is to use the static " "markers directly. This requires you to explicitly state the binary file " @@ -453,13 +441,13 @@ msgstr "" "使用 SystemTap 整合的低階方法是直接使用靜態標記。這會需要你明確聲明包含它們的" "二進位檔案。" -#: ../../howto/instrumentation.rst:207 +#: ../../howto/instrumentation.rst:204 msgid "" "For example, this SystemTap script can be used to show the call/return " "hierarchy of a Python script:" msgstr "例如,此 SystemTap 腳本可用於顯示 Python 腳本的呼叫/回傳階層結構:" -#: ../../howto/instrumentation.rst:210 +#: ../../howto/instrumentation.rst:207 msgid "" "probe process(\"python\").mark(\"function__entry\") {\n" " filename = user_string($arg1);\n" @@ -497,7 +485,7 @@ msgstr "" " thread_indent(-1), funcname, filename, lineno);\n" "}" -#: ../../howto/instrumentation.rst:232 +#: ../../howto/instrumentation.rst:229 msgid "" "$ stap \\\n" " show-call-hierarchy.stp \\\n" @@ -507,7 +495,7 @@ msgstr "" " show-call-hierarchy.stp \\\n" " -c \"./python test.py\"" -#: ../../howto/instrumentation.rst:238 +#: ../../howto/instrumentation.rst:235 msgid "" "11408 python(8274): => __contains__ in Lib/_abcoll.py:362\n" "11414 python(8274): => __getitem__ in Lib/os.py:425\n" @@ -523,28 +511,28 @@ msgstr "" "11428 python(8274): <= __getitem__ in Lib/os.py:426\n" "11433 python(8274): <= __contains__ in Lib/_abcoll.py:366" -#: ../../howto/instrumentation.rst:247 +#: ../../howto/instrumentation.rst:244 msgid "where the columns are:" msgstr "其中的行 (column) 是:" -#: ../../howto/instrumentation.rst:249 +#: ../../howto/instrumentation.rst:246 msgid "time in microseconds since start of script" msgstr "自腳本開始以來的時間(以微秒為單位)" -#: ../../howto/instrumentation.rst:250 +#: ../../howto/instrumentation.rst:247 msgid "name of executable" msgstr "可執行檔案的名稱" -#: ../../howto/instrumentation.rst:251 +#: ../../howto/instrumentation.rst:248 msgid "PID of process" msgstr "行程的 PID" -#: ../../howto/instrumentation.rst:253 +#: ../../howto/instrumentation.rst:250 msgid "" "and the remainder indicates the call/return hierarchy as the script executes." msgstr "其餘部分表示腳本執行時的呼叫/回傳階層結構。" -#: ../../howto/instrumentation.rst:255 +#: ../../howto/instrumentation.rst:252 msgid "" "For a :option:`--enable-shared` build of CPython, the markers are contained " "within the libpython shared library, and the probe's dotted path needs to " @@ -554,15 +542,15 @@ msgstr "" "函式庫中,並且探針的帶點路徑 (dotted path) 需要反映這一點。例如,上面範例中的" "這一列:" -#: ../../howto/instrumentation.rst:259 +#: ../../howto/instrumentation.rst:256 msgid "probe process(\"python\").mark(\"function__entry\") {" msgstr "probe process(\"python\").mark(\"function__entry\") {" -#: ../../howto/instrumentation.rst:263 +#: ../../howto/instrumentation.rst:260 msgid "should instead read:" msgstr "應該改為讀取:" -#: ../../howto/instrumentation.rst:265 +#: ../../howto/instrumentation.rst:262 msgid "" "probe process(\"python\").library(\"libpython3.6dm.so.1.0\")." "mark(\"function__entry\") {" @@ -570,22 +558,22 @@ msgstr "" "probe process(\"python\").library(\"libpython3.6dm.so.1.0\")." "mark(\"function__entry\") {" -#: ../../howto/instrumentation.rst:269 +#: ../../howto/instrumentation.rst:266 msgid "(assuming a :ref:`debug build ` of CPython 3.6)" msgstr "(假設 CPython 3.6 的\\ :ref:`除錯建置版本 `)" -#: ../../howto/instrumentation.rst:275 +#: ../../howto/instrumentation.rst:272 msgid "Available static markers" msgstr "可用的靜態標記" -#: ../../howto/instrumentation.rst:279 +#: ../../howto/instrumentation.rst:276 msgid "" "This marker indicates that execution of a Python function has begun. It is " "only triggered for pure-Python (bytecode) functions." msgstr "" "該標記表示 Python 函式的執行已經開始。它僅針對純 Python(位元組碼)函式觸發。" -#: ../../howto/instrumentation.rst:282 +#: ../../howto/instrumentation.rst:279 msgid "" "The filename, function name, and line number are provided back to the " "tracing script as positional arguments, which must be accessed using " @@ -594,25 +582,25 @@ msgstr "" "檔案名稱、函式名稱和列號作為位置引數提供給追蹤腳本,必須使用 ``$arg1``、" "``$arg2``、``$arg3`` 來存取:" -#: ../../howto/instrumentation.rst:286 +#: ../../howto/instrumentation.rst:283 msgid "" "``$arg1`` : ``(const char *)`` filename, accessible using " "``user_string($arg1)``" msgstr "" "``$arg1`` : ``(const char *)`` 檔案名稱,可使用 ``user_string($arg1)`` 存取" -#: ../../howto/instrumentation.rst:288 +#: ../../howto/instrumentation.rst:285 msgid "" "``$arg2`` : ``(const char *)`` function name, accessible using " "``user_string($arg2)``" msgstr "" "``$arg2`` :``(const char *)`` 函式名稱,可使用 ``user_string($arg2)`` 存取" -#: ../../howto/instrumentation.rst:291 +#: ../../howto/instrumentation.rst:288 msgid "``$arg3`` : ``int`` line number" msgstr "``$arg3`` : ``int`` 列號" -#: ../../howto/instrumentation.rst:295 +#: ../../howto/instrumentation.rst:292 msgid "" "This marker is the converse of :c:func:`!function__entry`, and indicates " "that execution of a Python function has ended (either via ``return``, or via " @@ -621,11 +609,11 @@ msgstr "" "該標記與 :c:func:`!function__entry` 相反,表示 Python 函式的執行已結束(透過 " "``return`` 或透過例外)。它僅針對純 Python(位元組碼)函式觸發。" -#: ../../howto/instrumentation.rst:299 +#: ../../howto/instrumentation.rst:296 msgid "The arguments are the same as for :c:func:`!function__entry`" msgstr "引數與 :c:func:`!function__entry` 相同" -#: ../../howto/instrumentation.rst:303 +#: ../../howto/instrumentation.rst:300 msgid "" "This marker indicates a Python line is about to be executed. It is the " "equivalent of line-by-line tracing with a Python profiler. It is not " @@ -634,11 +622,11 @@ msgstr "" "該標記表示一列 Python 即將被執行。它相當於使用 Python 分析器來逐行追蹤。它不" "在 C 函式內觸發。" -#: ../../howto/instrumentation.rst:307 +#: ../../howto/instrumentation.rst:304 msgid "The arguments are the same as for :c:func:`!function__entry`." msgstr "引數與 :c:func:`!function__entry` 相同。" -#: ../../howto/instrumentation.rst:311 +#: ../../howto/instrumentation.rst:308 msgid "" "Fires when the Python interpreter starts a garbage collection cycle. " "``arg0`` is the generation to scan, like :func:`gc.collect`." @@ -646,19 +634,19 @@ msgstr "" "當 Python 直譯器開始垃圾回收 (garbage collection) 週期時觸發。``arg0`` 是要掃" "描的一代 (generation),如 :func:`gc.collect`。" -#: ../../howto/instrumentation.rst:316 +#: ../../howto/instrumentation.rst:313 msgid "" "Fires when the Python interpreter finishes a garbage collection cycle. " "``arg0`` is the number of collected objects." msgstr "當 Python 直譯器完成垃圾回收週期時觸發。``arg0`` 是收集到的物件數量。" -#: ../../howto/instrumentation.rst:321 +#: ../../howto/instrumentation.rst:318 msgid "" "Fires before :mod:`importlib` attempts to find and load the module. ``arg0`` " "is the module name." msgstr "在 :mod:`importlib` 嘗試查找並載入模組之前觸發。``arg0`` 是模組名稱。" -#: ../../howto/instrumentation.rst:328 +#: ../../howto/instrumentation.rst:325 msgid "" "Fires after :mod:`importlib`'s find_and_load function is called. ``arg0`` is " "the module name, ``arg1`` indicates if module was successfully loaded." @@ -666,7 +654,7 @@ msgstr "" "在呼叫 :mod:`importlib` 的 find_and_load 函式後觸發。 ``arg0`` 是模組名稱," "``arg1`` 代表模組是否已成功載入。" -#: ../../howto/instrumentation.rst:337 +#: ../../howto/instrumentation.rst:334 msgid "" "Fires when :func:`sys.audit` or :c:func:`PySys_Audit` is called. ``arg0`` is " "the event name as C string, ``arg1`` is a :c:type:`PyObject` pointer to a " @@ -675,110 +663,110 @@ msgstr "" "當呼叫 :func:`sys.audit` 或 :c:func:`PySys_Audit` 時觸發。``arg0`` 是 C 字串" "形式的事件名稱,``arg1`` 是指向元組 (tuple) 物件的 :c:type:`PyObject` 指標。" -#: ../../howto/instrumentation.rst:345 +#: ../../howto/instrumentation.rst:342 msgid "C Entry Points" msgstr "" -#: ../../howto/instrumentation.rst:347 +#: ../../howto/instrumentation.rst:344 msgid "" "To simplify triggering of DTrace markers, Python's C API comes with a number " "of helper functions that mirror each static marker. On builds of Python " "without DTrace enabled, these do nothing." msgstr "" -#: ../../howto/instrumentation.rst:351 +#: ../../howto/instrumentation.rst:348 msgid "" "In general, it is not necessary to call these yourself, as Python will do it " "for you." msgstr "" -#: ../../howto/instrumentation.rst:358 +#: ../../howto/instrumentation.rst:355 msgid "C API Function" msgstr "" -#: ../../howto/instrumentation.rst:359 +#: ../../howto/instrumentation.rst:356 msgid "Static Marker" msgstr "靜態標記" -#: ../../howto/instrumentation.rst:360 +#: ../../howto/instrumentation.rst:357 msgid "Notes" msgstr "" -#: ../../howto/instrumentation.rst:362 +#: ../../howto/instrumentation.rst:359 msgid ":c:func:`!line`" msgstr "" -#: ../../howto/instrumentation.rst:365 +#: ../../howto/instrumentation.rst:362 msgid ":c:func:`!function__entry`" msgstr ":c:func:`!function__entry`" -#: ../../howto/instrumentation.rst:368 +#: ../../howto/instrumentation.rst:365 msgid ":c:func:`!function__return`" msgstr "" -#: ../../howto/instrumentation.rst:371 +#: ../../howto/instrumentation.rst:368 msgid ":c:func:`!gc__start`" msgstr "" -#: ../../howto/instrumentation.rst:374 +#: ../../howto/instrumentation.rst:371 msgid ":c:func:`!gc__done`" msgstr "" -#: ../../howto/instrumentation.rst:377 +#: ../../howto/instrumentation.rst:374 msgid ":c:func:`!instance__new__start`" msgstr "" -#: ../../howto/instrumentation.rst:378 ../../howto/instrumentation.rst:381 -#: ../../howto/instrumentation.rst:384 ../../howto/instrumentation.rst:387 +#: ../../howto/instrumentation.rst:375 ../../howto/instrumentation.rst:378 +#: ../../howto/instrumentation.rst:381 ../../howto/instrumentation.rst:384 msgid "Not used by Python" msgstr "" -#: ../../howto/instrumentation.rst:380 +#: ../../howto/instrumentation.rst:377 msgid ":c:func:`!instance__new__done`" msgstr "" -#: ../../howto/instrumentation.rst:383 +#: ../../howto/instrumentation.rst:380 msgid ":c:func:`!instance__delete__start`" msgstr "" -#: ../../howto/instrumentation.rst:386 +#: ../../howto/instrumentation.rst:383 msgid ":c:func:`!instance__delete__done`" msgstr "" -#: ../../howto/instrumentation.rst:389 +#: ../../howto/instrumentation.rst:386 msgid ":c:func:`!import__find__load__start`" msgstr "" -#: ../../howto/instrumentation.rst:392 +#: ../../howto/instrumentation.rst:389 msgid ":c:func:`!import__find__load__done`" msgstr "" -#: ../../howto/instrumentation.rst:395 +#: ../../howto/instrumentation.rst:392 msgid ":c:func:`!audit`" msgstr "" -#: ../../howto/instrumentation.rst:400 +#: ../../howto/instrumentation.rst:397 msgid "C Probing Checks" msgstr "" -#: ../../howto/instrumentation.rst:415 +#: ../../howto/instrumentation.rst:412 msgid "" "All calls to ``PyDTrace`` functions must be guarded by a call to one of " "these functions. This allows Python to minimize performance impact when " "probing is disabled." msgstr "" -#: ../../howto/instrumentation.rst:419 +#: ../../howto/instrumentation.rst:416 msgid "" "On builds without DTrace enabled, these functions do nothing and return " "``0``." msgstr "" -#: ../../howto/instrumentation.rst:423 +#: ../../howto/instrumentation.rst:420 msgid "SystemTap Tapsets" msgstr "SystemTap Tapsets" -#: ../../howto/instrumentation.rst:425 +#: ../../howto/instrumentation.rst:422 msgid "" "The higher-level way to use the SystemTap integration is to use a " "\"tapset\": SystemTap's equivalent of a library, which hides some of the " @@ -787,11 +775,11 @@ msgstr "" "使用 SystemTap 整合的高階方法是使用 \"tapset\":SystemTap 相當於一個函式庫," "它隱藏了靜態標記的一些低階詳細資訊。" -#: ../../howto/instrumentation.rst:429 +#: ../../howto/instrumentation.rst:426 msgid "Here is a tapset file, based on a non-shared build of CPython:" msgstr "這是一個 tapset 檔案,是基於 CPython 的非共享建置版本:" -#: ../../howto/instrumentation.rst:431 +#: ../../howto/instrumentation.rst:428 msgid "" "/*\n" " Provide a higher-level wrapping around the function__entry and\n" @@ -832,7 +820,7 @@ msgstr "" " frameptr = $arg4\n" "}" -#: ../../howto/instrumentation.rst:452 +#: ../../howto/instrumentation.rst:449 msgid "" "If this file is installed in SystemTap's tapset directory (e.g. ``/usr/share/" "systemtap/tapset``), then these additional probepoints become available:" @@ -840,7 +828,7 @@ msgstr "" "如果此檔案是安裝在 SystemTap 的 tapset 目錄中(例如 ``/usr/share/systemtap/" "tapset``),則這些額外的探測點將可被使用:" -#: ../../howto/instrumentation.rst:458 +#: ../../howto/instrumentation.rst:455 msgid "" "This probe point indicates that execution of a Python function has begun. It " "is only triggered for pure-Python (bytecode) functions." @@ -848,7 +836,7 @@ msgstr "" "該探測點表示 Python 函式的執行已經開始。它僅針對純 Python(位元組碼)函式觸" "發。" -#: ../../howto/instrumentation.rst:463 +#: ../../howto/instrumentation.rst:460 msgid "" "This probe point is the converse of ``python.function.return``, and " "indicates that execution of a Python function has ended (either via " @@ -858,11 +846,11 @@ msgstr "" "這個探測點與 ``python.function.return`` 相反,表示 Python 函式的執行已經結束" "(透過 ``return`` 或者透過例外)。它僅針對純 Python(位元組碼)函式觸發。" -#: ../../howto/instrumentation.rst:470 +#: ../../howto/instrumentation.rst:467 msgid "Examples" msgstr "範例" -#: ../../howto/instrumentation.rst:471 +#: ../../howto/instrumentation.rst:468 msgid "" "This SystemTap script uses the tapset above to more cleanly implement the " "example given above of tracing the Python function-call hierarchy, without " @@ -871,7 +859,7 @@ msgstr "" "此 SystemTap 腳本使用上面的 tapset 來更清晰地實作上面給出的追蹤 Python 函式呼" "叫階層結構的範例,而無需直接命名靜態標記:" -#: ../../howto/instrumentation.rst:475 +#: ../../howto/instrumentation.rst:472 msgid "" "probe python.function.entry\n" "{\n" @@ -897,7 +885,7 @@ msgstr "" " thread_indent(-1), funcname, filename, lineno);\n" "}" -#: ../../howto/instrumentation.rst:490 +#: ../../howto/instrumentation.rst:487 msgid "" "The following script uses the tapset above to provide a top-like view of all " "running CPython code, showing the top 20 most frequently entered bytecode " @@ -906,7 +894,7 @@ msgstr "" "以下腳本使用上面的 tapset 來提供所有正在運行之 CPython 程式碼的近乎最高層視" "角,顯示整個系統中每秒最常被進入的 20 個位元組碼幀 (bytecode frame):" -#: ../../howto/instrumentation.rst:494 +#: ../../howto/instrumentation.rst:491 msgid "" "global fn_calls;\n" "\n" @@ -945,3 +933,12 @@ msgstr "" " }\n" " delete fn_calls;\n" "}" + +#~ msgid "author" +#~ msgstr "作者" + +#~ msgid "David Malcolm" +#~ msgstr "David Malcolm" + +#~ msgid "Łukasz Langa" +#~ msgstr "Łukasz Langa" diff --git a/howto/ipaddress.po b/howto/ipaddress.po index 08ee8de7306..4a798ca70a6 100644 --- a/howto/ipaddress.po +++ b/howto/ipaddress.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-22 16:55+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-12-26 10:42-0500\n" "Last-Translator: Chih-Chao Chang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,23 +23,11 @@ msgstr "" msgid "An introduction to the ipaddress module" msgstr "ipaddress 模組介紹" -#: ../../howto/ipaddress.rst:0 -msgid "author" -msgstr "作者" - -#: ../../howto/ipaddress.rst:11 -msgid "Peter Moody" -msgstr "Peter Moody" - -#: ../../howto/ipaddress.rst:12 -msgid "Nick Coghlan" -msgstr "Nick Coghlan" - #: ../../howto/ipaddress.rst:-1 msgid "Overview" msgstr "總攬" -#: ../../howto/ipaddress.rst:16 +#: ../../howto/ipaddress.rst:13 msgid "" "This document aims to provide a gentle introduction to the :mod:`ipaddress` " "module. It is aimed primarily at users that aren't already familiar with IP " @@ -51,11 +39,11 @@ msgstr "" "IP 網路術語的使用者,但對想要了解 :mod:`ipaddress` 模組如何表示 IP 網址概念的" "網路工程師也可能有用。" -#: ../../howto/ipaddress.rst:24 +#: ../../howto/ipaddress.rst:21 msgid "Creating Address/Network/Interface objects" msgstr "建立 Address/Network/Interface 物件" -#: ../../howto/ipaddress.rst:26 +#: ../../howto/ipaddress.rst:23 msgid "" "Since :mod:`ipaddress` is a module for inspecting and manipulating IP " "addresses, the first thing you'll want to do is create some objects. You " @@ -64,11 +52,11 @@ msgstr "" "由於 :mod:`ipaddress` 是一個用於檢查和操作 IP 位址的模組,你首先會想要做的事" "情是建立一些物件。你可以使用 :mod:`ipaddress` 從字串和整數建立物件。" -#: ../../howto/ipaddress.rst:32 +#: ../../howto/ipaddress.rst:29 msgid "A Note on IP Versions" msgstr "關於 IP 版本的說明" -#: ../../howto/ipaddress.rst:34 +#: ../../howto/ipaddress.rst:31 msgid "" "For readers that aren't particularly familiar with IP addressing, it's " "important to know that the Internet Protocol (IP) is currently in the " @@ -83,7 +71,7 @@ msgstr "" "第 4 版無法提供足夠的位址來處理全世界的需求,特別是考慮到直接連接到網際網路的" "裝置數量不斷增加。" -#: ../../howto/ipaddress.rst:41 +#: ../../howto/ipaddress.rst:38 msgid "" "Explaining the details of the differences between the two versions of the " "protocol is beyond the scope of this introduction, but readers need to at " @@ -93,11 +81,11 @@ msgstr "" "解釋這兩個版本協定之間差異的細節超出了本文介紹的範圍,但讀者至少需要知道這兩" "個版本的存在,而且有時候會需要強制使用其中一個版本。" -#: ../../howto/ipaddress.rst:48 +#: ../../howto/ipaddress.rst:45 msgid "IP Host Addresses" msgstr "IP 主機位址" -#: ../../howto/ipaddress.rst:50 +#: ../../howto/ipaddress.rst:47 msgid "" "Addresses, often referred to as \"host addresses\" are the most basic unit " "when working with IP addressing. The simplest way to create addresses is to " @@ -109,14 +97,14 @@ msgstr "" "方法是使用 :func:`ipaddress.ip_address` 工廠函式,它會根據傳入的值自動判斷要" "建立 IPv4 還是 IPv6 位址:" -#: ../../howto/ipaddress.rst:61 +#: ../../howto/ipaddress.rst:58 msgid "" "Addresses can also be created directly from integers. Values that will fit " "within 32 bits are assumed to be IPv4 addresses::" msgstr "" "位址也可以直接從整數建立。符合 32 位元以內的值會被假定為 IPv4 位址: ::" -#: ../../howto/ipaddress.rst:64 +#: ../../howto/ipaddress.rst:61 msgid "" ">>> ipaddress.ip_address(3221225985)\n" "IPv4Address('192.0.2.1')\n" @@ -128,7 +116,7 @@ msgstr "" ">>> ipaddress.ip_address(42540766411282592856903984951653826561)\n" "IPv6Address('2001:db8::1')" -#: ../../howto/ipaddress.rst:69 +#: ../../howto/ipaddress.rst:66 msgid "" "To force the use of IPv4 or IPv6 addresses, the relevant classes can be " "invoked directly. This is particularly useful to force creation of IPv6 " @@ -137,7 +125,7 @@ msgstr "" "要強制使用 IPv4 或 IPv6 位址,可以直接呼叫相關的類別。這對於強制為小整數建立 " "IPv6 位址特別有用: ::" -#: ../../howto/ipaddress.rst:73 +#: ../../howto/ipaddress.rst:70 msgid "" ">>> ipaddress.ip_address(1)\n" "IPv4Address('0.0.0.1')\n" @@ -153,11 +141,11 @@ msgstr "" ">>> ipaddress.IPv6Address(1)\n" "IPv6Address('::1')" -#: ../../howto/ipaddress.rst:82 +#: ../../howto/ipaddress.rst:79 msgid "Defining Networks" msgstr "定義網路" -#: ../../howto/ipaddress.rst:84 +#: ../../howto/ipaddress.rst:81 msgid "" "Host addresses are usually grouped together into IP networks, so :mod:" "`ipaddress` provides a way to create, inspect and manipulate network " @@ -174,13 +162,13 @@ msgstr "" "的前導位元數量,以判斷位址是否屬於該網路的一部分,而網路位址則定義了這些位元" "的預期值。" -#: ../../howto/ipaddress.rst:93 +#: ../../howto/ipaddress.rst:90 msgid "" "As for addresses, a factory function is provided that determines the correct " "IP version automatically::" msgstr "至於位址,提供了一個工廠函式可以自動判斷正確的 IP 版本: ::" -#: ../../howto/ipaddress.rst:96 +#: ../../howto/ipaddress.rst:93 msgid "" ">>> ipaddress.ip_network('192.0.2.0/24')\n" "IPv4Network('192.0.2.0/24')\n" @@ -192,7 +180,7 @@ msgstr "" ">>> ipaddress.ip_network('2001:db8::0/96')\n" "IPv6Network('2001:db8::/96')" -#: ../../howto/ipaddress.rst:101 +#: ../../howto/ipaddress.rst:98 msgid "" "Network objects cannot have any host bits set. The practical effect of this " "is that ``192.0.2.1/24`` does not describe a network. Such definitions are " @@ -204,7 +192,7 @@ msgstr "" "個網路。這類定義被稱為介面物件,因為 ip-on-a-network 標記法通常用於描述電腦在" "給定網路上的網路介面,並將在下一節中進一步說明。" -#: ../../howto/ipaddress.rst:107 +#: ../../howto/ipaddress.rst:104 msgid "" "By default, attempting to create a network object with host bits set will " "result in :exc:`ValueError` being raised. To request that the additional " @@ -214,7 +202,7 @@ msgstr "" "預設情況下,嘗試建立帶有主機位元設定的網路物件會導致引發 :exc:`ValueError`。" "若要求將額外的位元強制轉換為零,可以在建構子中傳遞旗標 ``strict=False``: ::" -#: ../../howto/ipaddress.rst:112 +#: ../../howto/ipaddress.rst:109 msgid "" ">>> ipaddress.ip_network('192.0.2.1/24')\n" "Traceback (most recent call last):\n" @@ -230,7 +218,7 @@ msgstr "" ">>> ipaddress.ip_network('192.0.2.1/24', strict=False)\n" "IPv4Network('192.0.2.0/24')" -#: ../../howto/ipaddress.rst:119 +#: ../../howto/ipaddress.rst:116 msgid "" "While the string form offers significantly more flexibility, networks can " "also be defined with integers, just like host addresses. In this case, the " @@ -241,7 +229,7 @@ msgstr "" "這種情況下,網路被認為僅包含由該整數識別的單一位址,因此網路前綴包含了整個網" "路位址: ::" -#: ../../howto/ipaddress.rst:124 +#: ../../howto/ipaddress.rst:121 msgid "" ">>> ipaddress.ip_network(3221225984)\n" "IPv4Network('192.0.2.0/32')\n" @@ -253,7 +241,7 @@ msgstr "" ">>> ipaddress.ip_network(42540766411282592856903984951653826560)\n" "IPv6Network('2001:db8::/128')" -#: ../../howto/ipaddress.rst:129 +#: ../../howto/ipaddress.rst:126 msgid "" "As with addresses, creation of a particular kind of network can be forced by " "calling the class constructor directly instead of using the factory function." @@ -261,11 +249,11 @@ msgstr "" "與位址一樣,可以透過直接呼叫類別建構子而非使用工廠函式,來強制建立特定類型的" "網路。" -#: ../../howto/ipaddress.rst:135 +#: ../../howto/ipaddress.rst:132 msgid "Host Interfaces" msgstr "主機介面" -#: ../../howto/ipaddress.rst:137 +#: ../../howto/ipaddress.rst:134 msgid "" "As mentioned just above, if you need to describe an address on a particular " "network, neither the address nor the network classes are sufficient. " @@ -283,7 +271,7 @@ msgstr "" "`ipaddress` 提供了一組混合類別,將位址與特定網路關聯起來。建立介面的方式與定" "義網路物件相同,只是位址部分不受限於必須是網路位址。" -#: ../../howto/ipaddress.rst:152 +#: ../../howto/ipaddress.rst:149 msgid "" "Integer inputs are accepted (as with networks), and use of a particular IP " "version can be forced by calling the relevant constructor directly." @@ -291,11 +279,11 @@ msgstr "" "可以接受整數輸入(如同網路一樣),並且可以透過直接呼叫相關的建構子來強制使用" "特定的 IP 版本。" -#: ../../howto/ipaddress.rst:157 +#: ../../howto/ipaddress.rst:154 msgid "Inspecting Address/Network/Interface Objects" msgstr "檢視 Address/Network/Interface 物件" -#: ../../howto/ipaddress.rst:159 +#: ../../howto/ipaddress.rst:156 msgid "" "You've gone to the trouble of creating an IPv(4|6)(Address|Network|" "Interface) object, so you probably want to get information about it. :mod:" @@ -304,11 +292,11 @@ msgstr "" "你費心建立了 IPv(4|6)(Address|Network|Interface) 物件,所以你可能想要取得關於" "它的資訊。:mod:`ipaddress` 試圖讓這件事變得簡單且直觀。" -#: ../../howto/ipaddress.rst:163 +#: ../../howto/ipaddress.rst:160 msgid "Extracting the IP version::" msgstr "提取 IP 版本: ::" -#: ../../howto/ipaddress.rst:165 +#: ../../howto/ipaddress.rst:162 msgid "" ">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" ">>> addr6 = ipaddress.ip_address('2001:db8::1')\n" @@ -324,11 +312,11 @@ msgstr "" ">>> addr4.version\n" "4" -#: ../../howto/ipaddress.rst:172 +#: ../../howto/ipaddress.rst:169 msgid "Obtaining the network from an interface::" msgstr "從介面取得網路: ::" -#: ../../howto/ipaddress.rst:174 +#: ../../howto/ipaddress.rst:171 msgid "" ">>> host4 = ipaddress.ip_interface('192.0.2.1/24')\n" ">>> host4.network\n" @@ -344,11 +332,11 @@ msgstr "" ">>> host6.network\n" "IPv6Network('2001:db8::/96')" -#: ../../howto/ipaddress.rst:181 +#: ../../howto/ipaddress.rst:178 msgid "Finding out how many individual addresses are in a network::" msgstr "找出網路中有多少個別位址: ::" -#: ../../howto/ipaddress.rst:183 +#: ../../howto/ipaddress.rst:180 msgid "" ">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" ">>> net4.num_addresses\n" @@ -364,11 +352,11 @@ msgstr "" ">>> net6.num_addresses\n" "4294967296" -#: ../../howto/ipaddress.rst:190 +#: ../../howto/ipaddress.rst:187 msgid "Iterating through the \"usable\" addresses on a network::" msgstr "迭代網路上「可用的」位址: ::" -#: ../../howto/ipaddress.rst:192 +#: ../../howto/ipaddress.rst:189 msgid "" ">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" ">>> for x in net4.hosts():\n" @@ -394,7 +382,7 @@ msgstr "" "192.0.2.253\n" "192.0.2.254" -#: ../../howto/ipaddress.rst:205 +#: ../../howto/ipaddress.rst:202 msgid "" "Obtaining the netmask (i.e. set bits corresponding to the network prefix) or " "the hostmask (any bits that are not part of the netmask):" @@ -402,11 +390,11 @@ msgstr "" "取得網路遮罩(即對應於網路前綴的設定位元)或主機遮罩(任何不屬於網路遮罩的位" "元): ::" -#: ../../howto/ipaddress.rst:220 +#: ../../howto/ipaddress.rst:217 msgid "Exploding or compressing the address::" msgstr "展開或壓縮位址: ::" -#: ../../howto/ipaddress.rst:222 +#: ../../howto/ipaddress.rst:219 msgid "" ">>> addr6.exploded\n" "'2001:0db8:0000:0000:0000:0000:0000:0001'\n" @@ -426,7 +414,7 @@ msgstr "" ">>> net6.compressed\n" "'2001:db8::/96'" -#: ../../howto/ipaddress.rst:231 +#: ../../howto/ipaddress.rst:228 msgid "" "While IPv4 doesn't support explosion or compression, the associated objects " "still provide the relevant properties so that version neutral code can " @@ -437,17 +425,17 @@ msgstr "" "式碼可以輕鬆地確保 IPv6 位址使用最簡潔或最詳細的形式,同時仍能正確處理 IPv4 " "位址。" -#: ../../howto/ipaddress.rst:238 +#: ../../howto/ipaddress.rst:235 msgid "Networks as lists of Addresses" msgstr "作為位址串列的網路" -#: ../../howto/ipaddress.rst:240 +#: ../../howto/ipaddress.rst:237 msgid "" "It's sometimes useful to treat networks as lists. This means it is possible " "to index them like this::" msgstr "有時將網路視為串列是很有用的。這意味著可以像這樣對它們進行索引: ::" -#: ../../howto/ipaddress.rst:243 +#: ../../howto/ipaddress.rst:240 msgid "" ">>> net4[1]\n" "IPv4Address('192.0.2.1')\n" @@ -467,13 +455,13 @@ msgstr "" ">>> net6[-1]\n" "IPv6Address('2001:db8::ffff:ffff')" -#: ../../howto/ipaddress.rst:253 +#: ../../howto/ipaddress.rst:250 msgid "" "It also means that network objects lend themselves to using the list " "membership test syntax like this::" msgstr "這也意味著網路物件適合使用串列成員測試語法,像這樣: ::" -#: ../../howto/ipaddress.rst:256 +#: ../../howto/ipaddress.rst:253 msgid "" "if address in network:\n" " # do something" @@ -481,11 +469,11 @@ msgstr "" "if address in network:\n" " # 做某些事情" -#: ../../howto/ipaddress.rst:259 +#: ../../howto/ipaddress.rst:256 msgid "Containment testing is done efficiently based on the network prefix::" msgstr "msgstr \"可以根據網路前綴有效率地檢查是否包含: ::\"" -#: ../../howto/ipaddress.rst:261 +#: ../../howto/ipaddress.rst:258 msgid "" ">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" ">>> addr4 in ipaddress.ip_network('192.0.2.0/24')\n" @@ -499,11 +487,11 @@ msgstr "" ">>> addr4 in ipaddress.ip_network('192.0.3.0/24')\n" "False" -#: ../../howto/ipaddress.rst:269 +#: ../../howto/ipaddress.rst:266 msgid "Comparisons" msgstr "比較" -#: ../../howto/ipaddress.rst:271 +#: ../../howto/ipaddress.rst:268 msgid "" ":mod:`ipaddress` provides some simple, hopefully intuitive ways to compare " "objects, where it makes sense::" @@ -511,7 +499,7 @@ msgstr "" ":mod:`ipaddress` 提供了一些簡單且希望是直觀的方法來比較物件,只要這樣做有道" "理: ::" -#: ../../howto/ipaddress.rst:274 +#: ../../howto/ipaddress.rst:271 msgid "" ">>> ipaddress.ip_address('192.0.2.1') < ipaddress.ip_address('192.0.2.2')\n" "True" @@ -519,17 +507,17 @@ msgstr "" ">>> ipaddress.ip_address('192.0.2.1') < ipaddress.ip_address('192.0.2.2')\n" "True" -#: ../../howto/ipaddress.rst:277 +#: ../../howto/ipaddress.rst:274 msgid "" "A :exc:`TypeError` exception is raised if you try to compare objects of " "different versions or different types." msgstr "如果你嘗試比較不同版本或不同類型的物件,會引發 :exc:`TypeError` 例外。" -#: ../../howto/ipaddress.rst:282 +#: ../../howto/ipaddress.rst:279 msgid "Using IP Addresses with other modules" msgstr "與其他模組一起使用 IP 位址" -#: ../../howto/ipaddress.rst:284 +#: ../../howto/ipaddress.rst:281 msgid "" "Other modules that use IP addresses (such as :mod:`socket`) usually won't " "accept objects from this module directly. Instead, they must be coerced to " @@ -538,7 +526,7 @@ msgstr "" "其他使用 IP 位址的模組(例如 :mod:`socket`)通常不會直接接受來自此模組的物" "件。相反地,它們必須被強制轉換為其他模組能接受的整數或字串: ::" -#: ../../howto/ipaddress.rst:288 +#: ../../howto/ipaddress.rst:285 msgid "" ">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" ">>> str(addr4)\n" @@ -552,11 +540,11 @@ msgstr "" ">>> int(addr4)\n" "3221225985" -#: ../../howto/ipaddress.rst:296 +#: ../../howto/ipaddress.rst:293 msgid "Getting more detail when instance creation fails" msgstr "在實例建立失敗時取得更多細節" -#: ../../howto/ipaddress.rst:298 +#: ../../howto/ipaddress.rst:295 msgid "" "When creating address/network/interface objects using the version-agnostic " "factory functions, any errors will be reported as :exc:`ValueError` with a " @@ -570,7 +558,7 @@ msgstr "" "型的物件。缺乏具體錯誤的原因是,為了提供更多關於為何被拒絕的細節,需要知道該" "值應該是 IPv4 還是 IPv6。" -#: ../../howto/ipaddress.rst:305 +#: ../../howto/ipaddress.rst:302 msgid "" "To support use cases where it is useful to have access to this additional " "detail, the individual class constructors actually raise the :exc:" @@ -582,13 +570,13 @@ msgstr "" "`ValueError` 的子類別 :exc:`ipaddress.AddressValueError` 和 :exc:`ipaddress." "NetmaskValueError`,以明確指出定義的哪個部分無法正確解析。" -#: ../../howto/ipaddress.rst:311 +#: ../../howto/ipaddress.rst:308 msgid "" "The error messages are significantly more detailed when using the class " "constructors directly. For example::" msgstr "當直接使用類別建構子時,錯誤訊息會詳細得多。例如: ::" -#: ../../howto/ipaddress.rst:314 +#: ../../howto/ipaddress.rst:311 msgid "" ">>> ipaddress.ip_address(\"192.168.0.256\")\n" "Traceback (most recent call last):\n" @@ -628,7 +616,7 @@ msgstr "" " ...\n" "ipaddress.NetmaskValueError: '64' is not a valid netmask" -#: ../../howto/ipaddress.rst:332 +#: ../../howto/ipaddress.rst:329 msgid "" "However, both of the module specific exceptions have :exc:`ValueError` as " "their parent class, so if you're not concerned with the particular type of " @@ -637,7 +625,7 @@ msgstr "" "然而,這兩個模組特定的例外都以 :exc:`ValueError` 作為它們的父類別,因此如果你" "不關心特定類型的錯誤,你仍然可以撰寫如下的程式碼: ::" -#: ../../howto/ipaddress.rst:336 +#: ../../howto/ipaddress.rst:333 msgid "" "try:\n" " network = ipaddress.IPv4Network(address)\n" @@ -648,3 +636,12 @@ msgstr "" " network = ipaddress.IPv4Network(address)\n" "except ValueError:\n" " print('address/netmask is invalid for IPv4:', address)" + +#~ msgid "author" +#~ msgstr "作者" + +#~ msgid "Peter Moody" +#~ msgstr "Peter Moody" + +#~ msgid "Nick Coghlan" +#~ msgstr "Nick Coghlan" diff --git a/howto/logging-cookbook.po b/howto/logging-cookbook.po index 73e609df11c..f980e8cf361 100644 --- a/howto/logging-cookbook.po +++ b/howto/logging-cookbook.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-10 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,26 +21,18 @@ msgstr "" msgid "Logging Cookbook" msgstr "" -#: ../../howto/logging-cookbook.rst:0 -msgid "Author" -msgstr "作者" - #: ../../howto/logging-cookbook.rst:7 -msgid "Vinay Sajip " -msgstr "Vinay Sajip " - -#: ../../howto/logging-cookbook.rst:9 msgid "" "This page contains a number of recipes related to logging, which have been " "found useful in the past. For links to tutorial and reference information, " "please see :ref:`cookbook-ref-links`." msgstr "" -#: ../../howto/logging-cookbook.rst:16 +#: ../../howto/logging-cookbook.rst:14 msgid "Using logging in multiple modules" msgstr "" -#: ../../howto/logging-cookbook.rst:18 +#: ../../howto/logging-cookbook.rst:16 msgid "" "Multiple calls to ``logging.getLogger('someLogger')`` return a reference to " "the same logger object. This is true not only within the same module, but " @@ -52,7 +44,7 @@ msgid "" "module::" msgstr "" -#: ../../howto/logging-cookbook.rst:26 +#: ../../howto/logging-cookbook.rst:24 msgid "" "import logging\n" "import auxiliary_module\n" @@ -86,11 +78,11 @@ msgid "" "logger.info('done with auxiliary_module.some_function()')" msgstr "" -#: ../../howto/logging-cookbook.rst:56 +#: ../../howto/logging-cookbook.rst:54 msgid "Here is the auxiliary module::" msgstr "" -#: ../../howto/logging-cookbook.rst:58 +#: ../../howto/logging-cookbook.rst:56 msgid "" "import logging\n" "\n" @@ -112,11 +104,11 @@ msgid "" " module_logger.info('received a call to \"some_function\"')" msgstr "" -#: ../../howto/logging-cookbook.rst:76 +#: ../../howto/logging-cookbook.rst:74 msgid "The output looks like this:" msgstr "" -#: ../../howto/logging-cookbook.rst:78 +#: ../../howto/logging-cookbook.rst:76 msgid "" "2005-03-23 23:47:11,663 - spam_application - INFO -\n" " creating an instance of auxiliary_module.Auxiliary\n" @@ -140,17 +132,17 @@ msgid "" " done with auxiliary_module.some_function()" msgstr "" -#: ../../howto/logging-cookbook.rst:102 +#: ../../howto/logging-cookbook.rst:100 msgid "Logging from multiple threads" msgstr "" -#: ../../howto/logging-cookbook.rst:104 +#: ../../howto/logging-cookbook.rst:102 msgid "" "Logging from multiple threads requires no special effort. The following " "example shows logging from the main (initial) thread and another thread::" msgstr "" -#: ../../howto/logging-cookbook.rst:107 +#: ../../howto/logging-cookbook.rst:105 msgid "" "import logging\n" "import threading\n" @@ -180,11 +172,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:133 +#: ../../howto/logging-cookbook.rst:131 msgid "When run, the script should print something like the following:" msgstr "" -#: ../../howto/logging-cookbook.rst:135 +#: ../../howto/logging-cookbook.rst:133 msgid "" " 0 Thread-1 Hi from myfunc\n" " 3 MainThread Hello from main\n" @@ -205,17 +197,17 @@ msgid "" "4518 Thread-1 Hi from myfunc" msgstr "" -#: ../../howto/logging-cookbook.rst:155 +#: ../../howto/logging-cookbook.rst:153 msgid "" "This shows the logging output interspersed as one might expect. This " "approach works for more threads than shown here, of course." msgstr "" -#: ../../howto/logging-cookbook.rst:159 +#: ../../howto/logging-cookbook.rst:157 msgid "Multiple handlers and formatters" msgstr "" -#: ../../howto/logging-cookbook.rst:161 +#: ../../howto/logging-cookbook.rst:159 msgid "" "Loggers are plain Python objects. The :meth:`~Logger.addHandler` method has " "no minimum or maximum quota for the number of handlers you may add. " @@ -227,7 +219,7 @@ msgid "" "example::" msgstr "" -#: ../../howto/logging-cookbook.rst:169 +#: ../../howto/logging-cookbook.rst:167 msgid "" "import logging\n" "\n" @@ -256,14 +248,14 @@ msgid "" "logger.critical('critical message')" msgstr "" -#: ../../howto/logging-cookbook.rst:194 +#: ../../howto/logging-cookbook.rst:192 msgid "" "Notice that the 'application' code does not care about multiple handlers. " "All that changed was the addition and configuration of a new handler named " "*fh*." msgstr "" -#: ../../howto/logging-cookbook.rst:197 +#: ../../howto/logging-cookbook.rst:195 msgid "" "The ability to create new handlers with higher- or lower-severity filters " "can be very helpful when writing and testing an application. Instead of " @@ -275,11 +267,11 @@ msgid "" "debug." msgstr "" -#: ../../howto/logging-cookbook.rst:208 +#: ../../howto/logging-cookbook.rst:206 msgid "Logging to multiple destinations" msgstr "" -#: ../../howto/logging-cookbook.rst:210 +#: ../../howto/logging-cookbook.rst:208 msgid "" "Let's say you want to log to console and file with different message formats " "and in differing circumstances. Say you want to log messages with levels of " @@ -288,7 +280,7 @@ msgid "" "console messages should not. Here's how you can achieve this::" msgstr "" -#: ../../howto/logging-cookbook.rst:216 +#: ../../howto/logging-cookbook.rst:214 msgid "" "import logging\n" "\n" @@ -325,11 +317,11 @@ msgid "" "logger2.error('The five boxing wizards jump quickly.')" msgstr "" -#: ../../howto/logging-cookbook.rst:248 +#: ../../howto/logging-cookbook.rst:246 msgid "When you run this, on the console you will see" msgstr "" -#: ../../howto/logging-cookbook.rst:250 +#: ../../howto/logging-cookbook.rst:248 msgid "" "root : INFO Jackdaws love my big sphinx of quartz.\n" "myapp.area1 : INFO How quickly daft jumping zebras vex.\n" @@ -337,11 +329,11 @@ msgid "" "myapp.area2 : ERROR The five boxing wizards jump quickly." msgstr "" -#: ../../howto/logging-cookbook.rst:257 +#: ../../howto/logging-cookbook.rst:255 msgid "and in the file you will see something like" msgstr "" -#: ../../howto/logging-cookbook.rst:259 +#: ../../howto/logging-cookbook.rst:257 msgid "" "10-22 22:19 root INFO Jackdaws love my big sphinx of quartz.\n" "10-22 22:19 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim.\n" @@ -351,19 +343,19 @@ msgid "" "10-22 22:19 myapp.area2 ERROR The five boxing wizards jump quickly." msgstr "" -#: ../../howto/logging-cookbook.rst:267 +#: ../../howto/logging-cookbook.rst:265 msgid "" "As you can see, the DEBUG message only shows up in the file. The other " "messages are sent to both destinations." msgstr "" -#: ../../howto/logging-cookbook.rst:270 +#: ../../howto/logging-cookbook.rst:268 msgid "" "This example uses console and file handlers, but you can use any number and " "combination of handlers you choose." msgstr "" -#: ../../howto/logging-cookbook.rst:273 +#: ../../howto/logging-cookbook.rst:271 msgid "" "Note that the above choice of log filename ``/tmp/myapp.log`` implies use of " "a standard location for temporary files on POSIX systems. On Windows, you " @@ -372,11 +364,11 @@ msgid "" "files in it." msgstr "" -#: ../../howto/logging-cookbook.rst:282 +#: ../../howto/logging-cookbook.rst:280 msgid "Custom handling of levels" msgstr "" -#: ../../howto/logging-cookbook.rst:284 +#: ../../howto/logging-cookbook.rst:282 msgid "" "Sometimes, you might want to do something slightly different from the " "standard handling of levels in handlers, where all levels above a threshold " @@ -384,23 +376,23 @@ msgid "" "at a scenario where you want to arrange things as follows:" msgstr "" -#: ../../howto/logging-cookbook.rst:289 +#: ../../howto/logging-cookbook.rst:287 msgid "Send messages of severity ``INFO`` and ``WARNING`` to ``sys.stdout``" msgstr "" -#: ../../howto/logging-cookbook.rst:290 +#: ../../howto/logging-cookbook.rst:288 msgid "Send messages of severity ``ERROR`` and above to ``sys.stderr``" msgstr "" -#: ../../howto/logging-cookbook.rst:291 +#: ../../howto/logging-cookbook.rst:289 msgid "Send messages of severity ``DEBUG`` and above to file ``app.log``" msgstr "" -#: ../../howto/logging-cookbook.rst:293 +#: ../../howto/logging-cookbook.rst:291 msgid "Suppose you configure logging with the following JSON:" msgstr "" -#: ../../howto/logging-cookbook.rst:295 +#: ../../howto/logging-cookbook.rst:293 msgid "" "{\n" " \"version\": 1,\n" @@ -441,7 +433,7 @@ msgid "" "}" msgstr "" -#: ../../howto/logging-cookbook.rst:335 +#: ../../howto/logging-cookbook.rst:333 msgid "" "This configuration does *almost* what we want, except that ``sys.stdout`` " "would show messages of severity ``ERROR`` and only events of this severity " @@ -451,7 +443,7 @@ msgid "" "section parallel to ``formatters`` and ``handlers``:" msgstr "" -#: ../../howto/logging-cookbook.rst:341 +#: ../../howto/logging-cookbook.rst:339 msgid "" "{\n" " \"filters\": {\n" @@ -463,11 +455,11 @@ msgid "" "}" msgstr "" -#: ../../howto/logging-cookbook.rst:352 +#: ../../howto/logging-cookbook.rst:350 msgid "and changing the section on the ``stdout`` handler to add it:" msgstr "" -#: ../../howto/logging-cookbook.rst:354 +#: ../../howto/logging-cookbook.rst:352 msgid "" "{\n" " \"stdout\": {\n" @@ -480,13 +472,13 @@ msgid "" "}" msgstr "" -#: ../../howto/logging-cookbook.rst:366 +#: ../../howto/logging-cookbook.rst:364 msgid "" "A filter is just a function, so we can define the ``filter_maker`` (a " "factory function) as follows:" msgstr "" -#: ../../howto/logging-cookbook.rst:369 +#: ../../howto/logging-cookbook.rst:367 msgid "" "def filter_maker(level):\n" " level = getattr(logging, level)\n" @@ -504,7 +496,7 @@ msgstr "" "\n" " return filter" -#: ../../howto/logging-cookbook.rst:379 +#: ../../howto/logging-cookbook.rst:377 msgid "" "This converts the string argument passed in to a numeric level, and returns " "a function which only returns ``True`` if the level of the passed in record " @@ -515,11 +507,11 @@ msgid "" "you define it in a different module." msgstr "" -#: ../../howto/logging-cookbook.rst:387 +#: ../../howto/logging-cookbook.rst:385 msgid "With the filter added, we can run ``main.py``, which in full is:" msgstr "" -#: ../../howto/logging-cookbook.rst:389 +#: ../../howto/logging-cookbook.rst:387 msgid "" "import json\n" "import logging\n" @@ -588,19 +580,19 @@ msgid "" "logging.critical('A CRITICAL message')" msgstr "" -#: ../../howto/logging-cookbook.rst:457 +#: ../../howto/logging-cookbook.rst:455 msgid "And after running it like this:" msgstr "" -#: ../../howto/logging-cookbook.rst:459 +#: ../../howto/logging-cookbook.rst:457 msgid "python main.py 2>stderr.log >stdout.log" msgstr "" -#: ../../howto/logging-cookbook.rst:463 +#: ../../howto/logging-cookbook.rst:461 msgid "We can see the results are as expected:" msgstr "" -#: ../../howto/logging-cookbook.rst:465 +#: ../../howto/logging-cookbook.rst:463 msgid "" "$ more *.log\n" "::::::::::::::\n" @@ -623,15 +615,15 @@ msgid "" "WARNING - A WARNING message" msgstr "" -#: ../../howto/logging-cookbook.rst:489 +#: ../../howto/logging-cookbook.rst:487 msgid "Configuration server example" msgstr "" -#: ../../howto/logging-cookbook.rst:491 +#: ../../howto/logging-cookbook.rst:489 msgid "Here is an example of a module using the logging configuration server::" msgstr "" -#: ../../howto/logging-cookbook.rst:493 +#: ../../howto/logging-cookbook.rst:491 msgid "" "import logging\n" "import logging.config\n" @@ -663,14 +655,14 @@ msgid "" " t.join()" msgstr "" -#: ../../howto/logging-cookbook.rst:522 +#: ../../howto/logging-cookbook.rst:520 msgid "" "And here is a script that takes a filename and sends that file to the " "server, properly preceded with the binary-encoded length, as the new logging " "configuration::" msgstr "" -#: ../../howto/logging-cookbook.rst:526 +#: ../../howto/logging-cookbook.rst:524 msgid "" "#!/usr/bin/env python\n" "import socket, sys, struct\n" @@ -706,18 +698,18 @@ msgstr "" "s.close()\n" "print('complete')" -#: ../../howto/logging-cookbook.rst:547 +#: ../../howto/logging-cookbook.rst:545 msgid "Dealing with handlers that block" msgstr "" -#: ../../howto/logging-cookbook.rst:551 +#: ../../howto/logging-cookbook.rst:549 msgid "" "Sometimes you have to get your logging handlers to do their work without " "blocking the thread you're logging from. This is common in web applications, " "though of course it also occurs in other scenarios." msgstr "" -#: ../../howto/logging-cookbook.rst:555 +#: ../../howto/logging-cookbook.rst:553 msgid "" "A common culprit which demonstrates sluggish behaviour is the :class:" "`SMTPHandler`: sending emails can take a long time, for a number of reasons " @@ -728,7 +720,7 @@ msgid "" "below the Python layer, and outside your control)." msgstr "" -#: ../../howto/logging-cookbook.rst:563 +#: ../../howto/logging-cookbook.rst:561 msgid "" "One solution is to use a two-part approach. For the first part, attach only " "a :class:`QueueHandler` to those loggers which are accessed from performance-" @@ -742,7 +734,7 @@ msgid "" "developers who will use your code." msgstr "" -#: ../../howto/logging-cookbook.rst:574 +#: ../../howto/logging-cookbook.rst:572 msgid "" "The second part of the solution is :class:`QueueListener`, which has been " "designed as the counterpart to :class:`QueueHandler`. A :class:" @@ -753,7 +745,7 @@ msgid "" "handlers for processing." msgstr "" -#: ../../howto/logging-cookbook.rst:582 +#: ../../howto/logging-cookbook.rst:580 msgid "" "The advantage of having a separate :class:`QueueListener` class is that you " "can use the same instance to service multiple ``QueueHandlers``. This is " @@ -762,11 +754,11 @@ msgid "" "benefit." msgstr "" -#: ../../howto/logging-cookbook.rst:587 +#: ../../howto/logging-cookbook.rst:585 msgid "An example of using these two classes follows (imports omitted)::" msgstr "" -#: ../../howto/logging-cookbook.rst:589 +#: ../../howto/logging-cookbook.rst:587 msgid "" "que = queue.Queue(-1) # no limit on size\n" "queue_handler = QueueHandler(que)\n" @@ -785,15 +777,15 @@ msgid "" "listener.stop()" msgstr "" -#: ../../howto/logging-cookbook.rst:605 +#: ../../howto/logging-cookbook.rst:603 msgid "which, when run, will produce:" msgstr "" -#: ../../howto/logging-cookbook.rst:607 +#: ../../howto/logging-cookbook.rst:605 msgid "MainThread: Look out!" msgstr "" -#: ../../howto/logging-cookbook.rst:611 +#: ../../howto/logging-cookbook.rst:609 msgid "" "Although the earlier discussion wasn't specifically talking about async " "code, but rather about slow logging handlers, it should be noted that when " @@ -804,7 +796,7 @@ msgid "" "code runs only in the ``QueueListener`` thread." msgstr "" -#: ../../howto/logging-cookbook.rst:619 +#: ../../howto/logging-cookbook.rst:617 msgid "" "Prior to Python 3.5, the :class:`QueueListener` always passed every message " "received from the queue to every handler it was initialized with. (This was " @@ -816,13 +808,13 @@ msgid "" "handler if it's appropriate to do so." msgstr "" -#: ../../howto/logging-cookbook.rst:629 +#: ../../howto/logging-cookbook.rst:627 msgid "" "The :class:`QueueListener` can be started (and stopped) via the :keyword:" "`with` statement. For example:" msgstr "" -#: ../../howto/logging-cookbook.rst:633 +#: ../../howto/logging-cookbook.rst:631 msgid "" "with QueueListener(que, handler) as listener:\n" " # The queue listener automatically starts\n" @@ -832,18 +824,18 @@ msgid "" "# the 'with' block is exited." msgstr "" -#: ../../howto/logging-cookbook.rst:645 +#: ../../howto/logging-cookbook.rst:643 msgid "Sending and receiving logging events across a network" msgstr "" -#: ../../howto/logging-cookbook.rst:647 +#: ../../howto/logging-cookbook.rst:645 msgid "" "Let's say you want to send logging events across a network, and handle them " "at the receiving end. A simple way of doing this is attaching a :class:" "`SocketHandler` instance to the root logger at the sending end::" msgstr "" -#: ../../howto/logging-cookbook.rst:651 +#: ../../howto/logging-cookbook.rst:649 msgid "" "import logging, logging.handlers\n" "\n" @@ -871,13 +863,13 @@ msgid "" "logger2.error('The five boxing wizards jump quickly.')" msgstr "" -#: ../../howto/logging-cookbook.rst:675 +#: ../../howto/logging-cookbook.rst:673 msgid "" "At the receiving end, you can set up a receiver using the :mod:" "`socketserver` module. Here is a basic working example::" msgstr "" -#: ../../howto/logging-cookbook.rst:678 +#: ../../howto/logging-cookbook.rst:676 msgid "" "import pickle\n" "import logging\n" @@ -968,13 +960,13 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:763 +#: ../../howto/logging-cookbook.rst:761 msgid "" "First run the server, and then the client. On the client side, nothing is " "printed on the console; on the server side, you should see something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:766 +#: ../../howto/logging-cookbook.rst:764 msgid "" "About to start TCP server...\n" " 59 root INFO Jackdaws love my big sphinx of quartz.\n" @@ -984,7 +976,7 @@ msgid "" " 69 myapp.area2 ERROR The five boxing wizards jump quickly." msgstr "" -#: ../../howto/logging-cookbook.rst:775 +#: ../../howto/logging-cookbook.rst:773 msgid "" "Note that there are some security issues with pickle in some scenarios. If " "these affect you, you can use an alternative serialization scheme by " @@ -993,11 +985,11 @@ msgid "" "alternative serialization." msgstr "" -#: ../../howto/logging-cookbook.rst:783 +#: ../../howto/logging-cookbook.rst:781 msgid "Running a logging socket listener in production" msgstr "" -#: ../../howto/logging-cookbook.rst:787 +#: ../../howto/logging-cookbook.rst:785 msgid "" "To run a logging listener in production, you may need to use a process-" "management tool such as `Supervisor `_. `Here is a " @@ -1005,79 +997,79 @@ msgid "" "the above functionality using Supervisor. It consists of the following files:" msgstr "" -#: ../../howto/logging-cookbook.rst:794 +#: ../../howto/logging-cookbook.rst:792 msgid "File" msgstr "檔案" -#: ../../howto/logging-cookbook.rst:794 +#: ../../howto/logging-cookbook.rst:792 msgid "Purpose" msgstr "目的" -#: ../../howto/logging-cookbook.rst:796 +#: ../../howto/logging-cookbook.rst:794 msgid ":file:`prepare.sh`" msgstr ":file:`prepare.sh`" -#: ../../howto/logging-cookbook.rst:796 +#: ../../howto/logging-cookbook.rst:794 msgid "A Bash script to prepare the environment for testing" msgstr "" -#: ../../howto/logging-cookbook.rst:799 +#: ../../howto/logging-cookbook.rst:797 msgid ":file:`supervisor.conf`" msgstr ":file:`supervisor.conf`" -#: ../../howto/logging-cookbook.rst:799 +#: ../../howto/logging-cookbook.rst:797 msgid "" "The Supervisor configuration file, which has entries for the listener and a " "multi-process web application" msgstr "" -#: ../../howto/logging-cookbook.rst:803 +#: ../../howto/logging-cookbook.rst:801 msgid ":file:`ensure_app.sh`" msgstr ":file:`ensure_app.sh`" -#: ../../howto/logging-cookbook.rst:803 +#: ../../howto/logging-cookbook.rst:801 msgid "" "A Bash script to ensure that Supervisor is running with the above " "configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:806 +#: ../../howto/logging-cookbook.rst:804 msgid ":file:`log_listener.py`" msgstr ":file:`log_listener.py`" -#: ../../howto/logging-cookbook.rst:806 +#: ../../howto/logging-cookbook.rst:804 msgid "" "The socket listener program which receives log events and records them to a " "file" msgstr "" -#: ../../howto/logging-cookbook.rst:809 +#: ../../howto/logging-cookbook.rst:807 msgid ":file:`main.py`" msgstr ":file:`main.py`" -#: ../../howto/logging-cookbook.rst:809 +#: ../../howto/logging-cookbook.rst:807 msgid "" "A simple web application which performs logging via a socket connected to " "the listener" msgstr "" -#: ../../howto/logging-cookbook.rst:812 +#: ../../howto/logging-cookbook.rst:810 msgid ":file:`webapp.json`" msgstr ":file:`webapp.json`" -#: ../../howto/logging-cookbook.rst:812 +#: ../../howto/logging-cookbook.rst:810 msgid "A JSON configuration file for the web application" msgstr "" -#: ../../howto/logging-cookbook.rst:814 +#: ../../howto/logging-cookbook.rst:812 msgid ":file:`client.py`" msgstr ":file:`client.py`" -#: ../../howto/logging-cookbook.rst:814 +#: ../../howto/logging-cookbook.rst:812 msgid "A Python script to exercise the web application" msgstr "" -#: ../../howto/logging-cookbook.rst:817 +#: ../../howto/logging-cookbook.rst:815 msgid "" "The web application uses `Gunicorn `_, which is a " "popular web application server that starts multiple worker processes to " @@ -1086,21 +1078,21 @@ msgid "" "the socket listener." msgstr "" -#: ../../howto/logging-cookbook.rst:822 +#: ../../howto/logging-cookbook.rst:820 msgid "To test these files, do the following in a POSIX environment:" msgstr "" -#: ../../howto/logging-cookbook.rst:824 +#: ../../howto/logging-cookbook.rst:822 msgid "" "Download `the Gist `__ as a ZIP archive using the :" "guilabel:`Download ZIP` button." msgstr "" -#: ../../howto/logging-cookbook.rst:827 +#: ../../howto/logging-cookbook.rst:825 msgid "Unzip the above files from the archive into a scratch directory." msgstr "" -#: ../../howto/logging-cookbook.rst:829 +#: ../../howto/logging-cookbook.rst:827 msgid "" "In the scratch directory, run ``bash prepare.sh`` to get things ready. This " "creates a :file:`run` subdirectory to contain Supervisor-related and log " @@ -1108,19 +1100,19 @@ msgid "" "which ``bottle``, ``gunicorn`` and ``supervisor`` are installed." msgstr "" -#: ../../howto/logging-cookbook.rst:834 +#: ../../howto/logging-cookbook.rst:832 msgid "" "Run ``bash ensure_app.sh`` to ensure that Supervisor is running with the " "above configuration." msgstr "" -#: ../../howto/logging-cookbook.rst:837 +#: ../../howto/logging-cookbook.rst:835 msgid "" "Run ``venv/bin/python client.py`` to exercise the web application, which " "will lead to records being written to the log." msgstr "" -#: ../../howto/logging-cookbook.rst:840 +#: ../../howto/logging-cookbook.rst:838 msgid "" "Inspect the log files in the :file:`run` subdirectory. You should see the " "most recent log lines in files matching the pattern :file:`app.log*`. They " @@ -1128,25 +1120,25 @@ msgid "" "by different worker processes in a non-deterministic way." msgstr "" -#: ../../howto/logging-cookbook.rst:845 +#: ../../howto/logging-cookbook.rst:843 msgid "" "You can shut down the listener and the web application by running ``venv/bin/" "supervisorctl -c supervisor.conf shutdown``." msgstr "" -#: ../../howto/logging-cookbook.rst:848 +#: ../../howto/logging-cookbook.rst:846 msgid "" "You may need to tweak the configuration files in the unlikely event that the " "configured ports clash with something else in your test environment." msgstr "" -#: ../../howto/logging-cookbook.rst:851 +#: ../../howto/logging-cookbook.rst:849 msgid "" "The default configuration uses a TCP socket on port 9020. You can use a Unix " "Domain socket instead of a TCP socket by doing the following:" msgstr "" -#: ../../howto/logging-cookbook.rst:854 +#: ../../howto/logging-cookbook.rst:852 msgid "" "In :file:`listener.json`, add a ``socket`` key with the path to the domain " "socket you want to use. If this key is present, the listener listens on the " @@ -1154,18 +1146,18 @@ msgid "" "ignored)." msgstr "" -#: ../../howto/logging-cookbook.rst:859 +#: ../../howto/logging-cookbook.rst:857 msgid "" "In :file:`webapp.json`, change the socket handler configuration dictionary " "so that the ``host`` value is the path to the domain socket, and set the " "``port`` value to ``null``." msgstr "" -#: ../../howto/logging-cookbook.rst:869 +#: ../../howto/logging-cookbook.rst:867 msgid "Adding contextual information to your logging output" msgstr "" -#: ../../howto/logging-cookbook.rst:871 +#: ../../howto/logging-cookbook.rst:869 msgid "" "Sometimes you want logging output to contain contextual information in " "addition to the parameters passed to the logging call. For example, in a " @@ -1181,11 +1173,11 @@ msgid "" "`Logger` instances becomes effectively unbounded." msgstr "" -#: ../../howto/logging-cookbook.rst:886 +#: ../../howto/logging-cookbook.rst:884 msgid "Using LoggerAdapters to impart contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:888 +#: ../../howto/logging-cookbook.rst:886 msgid "" "An easy way in which you can pass contextual information to be output along " "with logging event information is to use the :class:`LoggerAdapter` class. " @@ -1196,7 +1188,7 @@ msgid "" "types of instances interchangeably." msgstr "" -#: ../../howto/logging-cookbook.rst:896 +#: ../../howto/logging-cookbook.rst:894 msgid "" "When you create an instance of :class:`LoggerAdapter`, you pass it a :class:" "`Logger` instance and a dict-like object which contains your contextual " @@ -1207,7 +1199,7 @@ msgid "" "of :class:`LoggerAdapter`::" msgstr "" -#: ../../howto/logging-cookbook.rst:904 +#: ../../howto/logging-cookbook.rst:902 msgid "" "def debug(self, msg, /, *args, **kwargs):\n" " \"\"\"\n" @@ -1218,7 +1210,7 @@ msgid "" " self.logger.debug(msg, *args, **kwargs)" msgstr "" -#: ../../howto/logging-cookbook.rst:912 +#: ../../howto/logging-cookbook.rst:910 msgid "" "The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where " "the contextual information is added to the logging output. It's passed the " @@ -1231,7 +1223,7 @@ msgid "" "be silently overwritten." msgstr "" -#: ../../howto/logging-cookbook.rst:921 +#: ../../howto/logging-cookbook.rst:919 msgid "" "The advantage of using 'extra' is that the values in the dict-like object " "are merged into the :class:`LogRecord` instance's __dict__, allowing you to " @@ -1242,7 +1234,7 @@ msgid "" "`~LoggerAdapter.process` to do what you need. Here is a simple example::" msgstr "" -#: ../../howto/logging-cookbook.rst:929 +#: ../../howto/logging-cookbook.rst:927 msgid "" "class CustomAdapter(logging.LoggerAdapter):\n" " \"\"\"\n" @@ -1253,27 +1245,27 @@ msgid "" " return '[%s] %s' % (self.extra['connid'], msg), kwargs" msgstr "" -#: ../../howto/logging-cookbook.rst:937 +#: ../../howto/logging-cookbook.rst:935 msgid "which you can use like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:939 +#: ../../howto/logging-cookbook.rst:937 msgid "" "logger = logging.getLogger(__name__)\n" "adapter = CustomAdapter(logger, {'connid': some_conn_id})" msgstr "" -#: ../../howto/logging-cookbook.rst:942 +#: ../../howto/logging-cookbook.rst:940 msgid "" "Then any events that you log to the adapter will have the value of " "``some_conn_id`` prepended to the log messages." msgstr "" -#: ../../howto/logging-cookbook.rst:946 +#: ../../howto/logging-cookbook.rst:944 msgid "Using objects other than dicts to pass contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:948 +#: ../../howto/logging-cookbook.rst:946 msgid "" "You don't need to pass an actual dict to a :class:`LoggerAdapter` - you " "could pass an instance of a class which implements ``__getitem__`` and " @@ -1282,11 +1274,11 @@ msgid "" "would be constant)." msgstr "" -#: ../../howto/logging-cookbook.rst:957 +#: ../../howto/logging-cookbook.rst:955 msgid "Using Filters to impart contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:959 +#: ../../howto/logging-cookbook.rst:957 msgid "" "You can also add contextual information to log output using a user-defined :" "class:`Filter`. ``Filter`` instances are allowed to modify the " @@ -1295,7 +1287,7 @@ msgid "" "class:`Formatter`." msgstr "" -#: ../../howto/logging-cookbook.rst:964 +#: ../../howto/logging-cookbook.rst:962 msgid "" "For example in a web application, the request being processed (or at least, " "the interesting parts of it) can be stored in a threadlocal (:class:" @@ -1307,7 +1299,7 @@ msgid "" "an example script::" msgstr "" -#: ../../howto/logging-cookbook.rst:973 +#: ../../howto/logging-cookbook.rst:971 msgid "" "import logging\n" "from random import choice\n" @@ -1350,11 +1342,11 @@ msgid "" "'parameters')" msgstr "" -#: ../../howto/logging-cookbook.rst:1010 +#: ../../howto/logging-cookbook.rst:1008 msgid "which, when run, produces something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:1012 +#: ../../howto/logging-cookbook.rst:1010 msgid "" "2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A " "debug message\n" @@ -1382,11 +1374,11 @@ msgid "" "message at INFO level with 2 parameters" msgstr "" -#: ../../howto/logging-cookbook.rst:1028 +#: ../../howto/logging-cookbook.rst:1026 msgid "Use of ``contextvars``" msgstr "" -#: ../../howto/logging-cookbook.rst:1030 +#: ../../howto/logging-cookbook.rst:1028 msgid "" "Since Python 3.7, the :mod:`contextvars` module has provided context-local " "storage which works for both :mod:`threading` and :mod:`asyncio` processing " @@ -1396,7 +1388,7 @@ msgid "" "attributes handled by web applications." msgstr "" -#: ../../howto/logging-cookbook.rst:1036 +#: ../../howto/logging-cookbook.rst:1034 msgid "" "For the purposes of illustration, say that you have different web " "applications, each independent of the other but running in the same Python " @@ -1407,11 +1399,11 @@ msgid "" "information such as client IP, HTTP request method and client username?" msgstr "" -#: ../../howto/logging-cookbook.rst:1043 +#: ../../howto/logging-cookbook.rst:1041 msgid "Let's assume that the library can be simulated by the following code:" msgstr "" -#: ../../howto/logging-cookbook.rst:1045 +#: ../../howto/logging-cookbook.rst:1043 msgid "" "# webapplib.py\n" "import logging\n" @@ -1426,14 +1418,14 @@ msgid "" " time.sleep(0.01)" msgstr "" -#: ../../howto/logging-cookbook.rst:1059 +#: ../../howto/logging-cookbook.rst:1057 msgid "" "We can simulate the multiple web applications by means of two simple " "classes, ``Request`` and ``WebApp``. These simulate how real threaded web " "applications work - each request is handled by a thread:" msgstr "" -#: ../../howto/logging-cookbook.rst:1063 +#: ../../howto/logging-cookbook.rst:1061 msgid "" "# main.py\n" "import argparse\n" @@ -1588,7 +1580,7 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1203 +#: ../../howto/logging-cookbook.rst:1201 msgid "" "If you run the above, you should find that roughly half the requests go " "into :file:`app1.log` and the rest into :file:`app2.log`, and the all the " @@ -1599,7 +1591,7 @@ msgid "" "illustrated by the following shell output:" msgstr "" -#: ../../howto/logging-cookbook.rst:1210 +#: ../../howto/logging-cookbook.rst:1208 msgid "" "~/logging-contextual-webapp$ python main.py\n" "app1 processed 51 requests\n" @@ -1654,11 +1646,11 @@ msgid "" "147" msgstr "" -#: ../../howto/logging-cookbook.rst:1250 +#: ../../howto/logging-cookbook.rst:1248 msgid "Imparting contextual information in handlers" msgstr "" -#: ../../howto/logging-cookbook.rst:1252 +#: ../../howto/logging-cookbook.rst:1250 msgid "" "Each :class:`~Handler` has its own chain of filters. If you want to add " "contextual information to a :class:`LogRecord` without leaking it to other " @@ -1666,7 +1658,7 @@ msgid "" "instead of modifying it in-place, as shown in the following script::" msgstr "" -#: ../../howto/logging-cookbook.rst:1257 +#: ../../howto/logging-cookbook.rst:1255 msgid "" "import copy\n" "import logging\n" @@ -1706,11 +1698,11 @@ msgstr "" "\n" " logger.info('A log message')" -#: ../../howto/logging-cookbook.rst:1279 +#: ../../howto/logging-cookbook.rst:1277 msgid "Logging to a single file from multiple processes" msgstr "" -#: ../../howto/logging-cookbook.rst:1281 +#: ../../howto/logging-cookbook.rst:1279 msgid "" "Although logging is thread-safe, and logging to a single file from multiple " "threads in a single process *is* supported, logging to a single file from " @@ -1726,7 +1718,7 @@ msgid "" "you to adapt in your own applications." msgstr "" -#: ../../howto/logging-cookbook.rst:1294 +#: ../../howto/logging-cookbook.rst:1292 msgid "" "You could also write your own handler which uses the :class:" "`~multiprocessing.Lock` class from the :mod:`multiprocessing` module to " @@ -1734,7 +1726,7 @@ msgid "" "`FileHandler` and subclasses do not make use of :mod:`multiprocessing`." msgstr "" -#: ../../howto/logging-cookbook.rst:1301 +#: ../../howto/logging-cookbook.rst:1299 msgid "" "Alternatively, you can use a ``Queue`` and a :class:`QueueHandler` to send " "all logging events to one of the processes in your multi-process " @@ -1749,7 +1741,7 @@ msgid "" "requirements::" msgstr "" -#: ../../howto/logging-cookbook.rst:1312 +#: ../../howto/logging-cookbook.rst:1310 msgid "" "# You'll need these imports in your own code\n" "import logging\n" @@ -1869,13 +1861,13 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1417 +#: ../../howto/logging-cookbook.rst:1415 msgid "" "A variant of the above script keeps the logging in the main process, in a " "separate thread::" msgstr "" -#: ../../howto/logging-cookbook.rst:1420 +#: ../../howto/logging-cookbook.rst:1418 msgid "" "import logging\n" "import logging.config\n" @@ -1972,7 +1964,7 @@ msgid "" " lp.join()" msgstr "" -#: ../../howto/logging-cookbook.rst:1512 +#: ../../howto/logging-cookbook.rst:1510 msgid "" "This variant shows how you can e.g. apply configuration for particular " "loggers - e.g. the ``foo`` logger has a special handler which stores all " @@ -1982,36 +1974,36 @@ msgid "" "appropriate destinations." msgstr "" -#: ../../howto/logging-cookbook.rst:1519 +#: ../../howto/logging-cookbook.rst:1517 msgid "Using concurrent.futures.ProcessPoolExecutor" msgstr "使用 concurrent.futures.ProcessPoolExecutor" -#: ../../howto/logging-cookbook.rst:1521 +#: ../../howto/logging-cookbook.rst:1519 msgid "" "If you want to use :class:`concurrent.futures.ProcessPoolExecutor` to start " "your worker processes, you need to create the queue slightly differently. " "Instead of" msgstr "" -#: ../../howto/logging-cookbook.rst:1525 +#: ../../howto/logging-cookbook.rst:1523 msgid "queue = multiprocessing.Queue(-1)" msgstr "queue = multiprocessing.Queue(-1)" -#: ../../howto/logging-cookbook.rst:1529 +#: ../../howto/logging-cookbook.rst:1527 msgid "you should use" msgstr "" -#: ../../howto/logging-cookbook.rst:1531 +#: ../../howto/logging-cookbook.rst:1529 msgid "" "queue = multiprocessing.Manager().Queue(-1) # also works with the examples " "above" msgstr "" -#: ../../howto/logging-cookbook.rst:1535 +#: ../../howto/logging-cookbook.rst:1533 msgid "and you can then replace the worker creation from this::" msgstr "" -#: ../../howto/logging-cookbook.rst:1537 +#: ../../howto/logging-cookbook.rst:1535 msgid "" "workers = []\n" "for i in range(10):\n" @@ -2023,22 +2015,22 @@ msgid "" " w.join()" msgstr "" -#: ../../howto/logging-cookbook.rst:1546 +#: ../../howto/logging-cookbook.rst:1544 msgid "to this (remembering to first import :mod:`concurrent.futures`)::" msgstr "" -#: ../../howto/logging-cookbook.rst:1548 +#: ../../howto/logging-cookbook.rst:1546 msgid "" "with concurrent.futures.ProcessPoolExecutor(max_workers=10) as executor:\n" " for i in range(10):\n" " executor.submit(worker_process, queue, worker_configurer)" msgstr "" -#: ../../howto/logging-cookbook.rst:1553 +#: ../../howto/logging-cookbook.rst:1551 msgid "Deploying web applications using Gunicorn and uWSGI" msgstr "" -#: ../../howto/logging-cookbook.rst:1555 +#: ../../howto/logging-cookbook.rst:1553 msgid "" "When deploying web applications using `Gunicorn `_ or " "`uWSGI `_ (or similar), " @@ -2050,11 +2042,11 @@ msgid "" "listener in production`_ for more details." msgstr "" -#: ../../howto/logging-cookbook.rst:1565 +#: ../../howto/logging-cookbook.rst:1563 msgid "Using file rotation" msgstr "" -#: ../../howto/logging-cookbook.rst:1570 +#: ../../howto/logging-cookbook.rst:1565 msgid "" "Sometimes you want to let a log file grow to a certain size, then open a new " "file and log to that. You may want to keep a certain number of these files, " @@ -2063,7 +2055,7 @@ msgid "" "usage pattern, the logging package provides a :class:`RotatingFileHandler`::" msgstr "" -#: ../../howto/logging-cookbook.rst:1576 +#: ../../howto/logging-cookbook.rst:1571 msgid "" "import glob\n" "import logging\n" @@ -2092,13 +2084,13 @@ msgid "" " print(filename)" msgstr "" -#: ../../howto/logging-cookbook.rst:1602 +#: ../../howto/logging-cookbook.rst:1597 msgid "" "The result should be 6 separate files, each with part of the log history for " "the application:" msgstr "" -#: ../../howto/logging-cookbook.rst:1605 +#: ../../howto/logging-cookbook.rst:1600 msgid "" "logging_rotatingfile_example.out\n" "logging_rotatingfile_example.out.1\n" @@ -2108,7 +2100,7 @@ msgid "" "logging_rotatingfile_example.out.5" msgstr "" -#: ../../howto/logging-cookbook.rst:1614 +#: ../../howto/logging-cookbook.rst:1609 msgid "" "The most current file is always :file:`logging_rotatingfile_example.out`, " "and each time it reaches the size limit it is renamed with the suffix " @@ -2116,17 +2108,17 @@ msgid "" "(``.1`` becomes ``.2``, etc.) and the ``.6`` file is erased." msgstr "" -#: ../../howto/logging-cookbook.rst:1619 +#: ../../howto/logging-cookbook.rst:1614 msgid "" "Obviously this example sets the log length much too small as an extreme " "example. You would want to set *maxBytes* to an appropriate value." msgstr "" -#: ../../howto/logging-cookbook.rst:1627 +#: ../../howto/logging-cookbook.rst:1622 msgid "Use of alternative formatting styles" msgstr "" -#: ../../howto/logging-cookbook.rst:1629 +#: ../../howto/logging-cookbook.rst:1624 msgid "" "When logging was added to the Python standard library, the only way of " "formatting messages with variable content was to use the %-formatting " @@ -2135,7 +2127,7 @@ msgid "" "Python 2.6)." msgstr "" -#: ../../howto/logging-cookbook.rst:1635 +#: ../../howto/logging-cookbook.rst:1630 msgid "" "Logging (as of 3.2) provides improved support for these two additional " "formatting styles. The :class:`Formatter` class been enhanced to take an " @@ -2148,7 +2140,7 @@ msgid "" "session to show the possibilities:" msgstr "" -#: ../../howto/logging-cookbook.rst:1645 +#: ../../howto/logging-cookbook.rst:1640 msgid "" ">>> import logging\n" ">>> root = logging.getLogger()\n" @@ -2194,14 +2186,14 @@ msgstr "" "2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message\n" ">>>" -#: ../../howto/logging-cookbook.rst:1669 +#: ../../howto/logging-cookbook.rst:1664 msgid "" "Note that the formatting of logging messages for final output to logs is " "completely independent of how an individual logging message is constructed. " "That can still use %-formatting, as shown here::" msgstr "" -#: ../../howto/logging-cookbook.rst:1673 +#: ../../howto/logging-cookbook.rst:1668 msgid "" ">>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message')\n" "2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message\n" @@ -2211,7 +2203,7 @@ msgstr "" "2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message\n" ">>>" -#: ../../howto/logging-cookbook.rst:1677 +#: ../../howto/logging-cookbook.rst:1672 msgid "" "Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take " "positional parameters for the actual logging message itself, with keyword " @@ -2227,7 +2219,7 @@ msgid "" "strings." msgstr "" -#: ../../howto/logging-cookbook.rst:1690 +#: ../../howto/logging-cookbook.rst:1685 msgid "" "There is, however, a way that you can use {}- and $- formatting to construct " "your individual log messages. Recall that for a message you can use an " @@ -2236,7 +2228,7 @@ msgid "" "the following two classes::" msgstr "" -#: ../../howto/logging-cookbook.rst:1696 ../../howto/logging-cookbook.rst:2784 +#: ../../howto/logging-cookbook.rst:1691 ../../howto/logging-cookbook.rst:2779 msgid "" "class BraceMessage:\n" " def __init__(self, fmt, /, *args, **kwargs):\n" @@ -2274,7 +2266,7 @@ msgstr "" " from string import Template\n" " return Template(self.fmt).substitute(**self.kwargs)" -#: ../../howto/logging-cookbook.rst:1714 +#: ../../howto/logging-cookbook.rst:1709 msgid "" "Either of these can be used in place of a format string, to allow {}- or $-" "formatting to be used to build the actual \"message\" part which appears in " @@ -2285,14 +2277,14 @@ msgid "" "used as a synonym/alias for :func:`gettext.gettext` or its brethren)." msgstr "" -#: ../../howto/logging-cookbook.rst:1722 +#: ../../howto/logging-cookbook.rst:1717 msgid "" "The above classes are not included in Python, though they're easy enough to " "copy and paste into your own code. They can be used as follows (assuming " "that they're declared in a module called ``wherever``):" msgstr "" -#: ../../howto/logging-cookbook.rst:1726 +#: ../../howto/logging-cookbook.rst:1721 msgid "" ">>> from wherever import BraceMessage as __\n" ">>> print(__('Message with {0} {name}', 2, name='placeholders'))\n" @@ -2326,14 +2318,14 @@ msgstr "" "Message with 2 placeholders\n" ">>>" -#: ../../howto/logging-cookbook.rst:1744 +#: ../../howto/logging-cookbook.rst:1739 msgid "" "While the above examples use ``print()`` to show how the formatting works, " "you would of course use ``logger.debug()`` or similar to actually log using " "this approach." msgstr "" -#: ../../howto/logging-cookbook.rst:1748 +#: ../../howto/logging-cookbook.rst:1743 msgid "" "One thing to note is that you pay no significant performance penalty with " "this approach: the actual formatting happens not when you make the logging " @@ -2344,13 +2336,13 @@ msgid "" "sugar for a constructor call to one of the :samp:`{XXX}Message` classes." msgstr "" -#: ../../howto/logging-cookbook.rst:1756 +#: ../../howto/logging-cookbook.rst:1751 msgid "" "If you prefer, you can use a :class:`LoggerAdapter` to achieve a similar " "effect to the above, as in the following example::" msgstr "" -#: ../../howto/logging-cookbook.rst:1759 +#: ../../howto/logging-cookbook.rst:1754 msgid "" "import logging\n" "\n" @@ -2379,17 +2371,17 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1785 +#: ../../howto/logging-cookbook.rst:1780 msgid "" "The above script should log the message ``Hello, world!`` when run with " "Python 3.8 or later." msgstr "" -#: ../../howto/logging-cookbook.rst:1794 +#: ../../howto/logging-cookbook.rst:1789 msgid "Customizing ``LogRecord``" msgstr "" -#: ../../howto/logging-cookbook.rst:1796 +#: ../../howto/logging-cookbook.rst:1791 msgid "" "Every logging event is represented by a :class:`LogRecord` instance. When an " "event is logged and not filtered out by a logger's level, a :class:" @@ -2400,13 +2392,13 @@ msgid "" "was done:" msgstr "" -#: ../../howto/logging-cookbook.rst:1803 +#: ../../howto/logging-cookbook.rst:1798 msgid "" ":meth:`Logger.makeRecord`, which is called in the normal process of logging " "an event. This invoked :class:`LogRecord` directly to create an instance." msgstr "" -#: ../../howto/logging-cookbook.rst:1806 +#: ../../howto/logging-cookbook.rst:1801 msgid "" ":func:`makeLogRecord`, which is called with a dictionary containing " "attributes to be added to the LogRecord. This is typically invoked when a " @@ -2415,27 +2407,27 @@ msgid "" "`~handlers.HTTPHandler`)." msgstr "" -#: ../../howto/logging-cookbook.rst:1812 +#: ../../howto/logging-cookbook.rst:1807 msgid "" "This has usually meant that if you need to do anything special with a :class:" "`LogRecord`, you've had to do one of the following." msgstr "" -#: ../../howto/logging-cookbook.rst:1815 +#: ../../howto/logging-cookbook.rst:1810 msgid "" "Create your own :class:`Logger` subclass, which overrides :meth:`Logger." "makeRecord`, and set it using :func:`~logging.setLoggerClass` before any " "loggers that you care about are instantiated." msgstr "" -#: ../../howto/logging-cookbook.rst:1818 +#: ../../howto/logging-cookbook.rst:1813 msgid "" "Add a :class:`Filter` to a logger or handler, which does the necessary " "special manipulation you need when its :meth:`~Filter.filter` method is " "called." msgstr "" -#: ../../howto/logging-cookbook.rst:1822 +#: ../../howto/logging-cookbook.rst:1817 msgid "" "The first approach would be a little unwieldy in the scenario where (say) " "several different libraries wanted to do different things. Each would " @@ -2443,7 +2435,7 @@ msgid "" "last would win." msgstr "" -#: ../../howto/logging-cookbook.rst:1827 +#: ../../howto/logging-cookbook.rst:1822 msgid "" "The second approach works reasonably well for many cases, but does not allow " "you to e.g. use a specialized subclass of :class:`LogRecord`. Library " @@ -2452,11 +2444,11 @@ msgid "" "would do simply by adding new packages or modules and doing ::" msgstr "" -#: ../../howto/logging-cookbook.rst:1833 +#: ../../howto/logging-cookbook.rst:1828 msgid "logger = logging.getLogger(__name__)" msgstr "logger = logging.getLogger(__name__)" -#: ../../howto/logging-cookbook.rst:1835 +#: ../../howto/logging-cookbook.rst:1830 msgid "" "at module level). It's probably one too many things to think about. " "Developers could also add the filter to a :class:`~logging.NullHandler` " @@ -2466,7 +2458,7 @@ msgid "" "developer." msgstr "" -#: ../../howto/logging-cookbook.rst:1841 +#: ../../howto/logging-cookbook.rst:1836 msgid "" "In Python 3.2 and later, :class:`~logging.LogRecord` creation is done " "through a factory, which you can specify. The factory is just a callable you " @@ -2476,7 +2468,7 @@ msgid "" "`LogRecord` is the default setting for the factory." msgstr "" -#: ../../howto/logging-cookbook.rst:1848 +#: ../../howto/logging-cookbook.rst:1843 msgid "" "This approach allows a custom factory to control all aspects of LogRecord " "creation. For example, you could return a subclass, or just add some " @@ -2484,7 +2476,7 @@ msgid "" "this::" msgstr "" -#: ../../howto/logging-cookbook.rst:1852 +#: ../../howto/logging-cookbook.rst:1847 msgid "" "old_factory = logging.getLogRecordFactory()\n" "\n" @@ -2496,7 +2488,7 @@ msgid "" "logging.setLogRecordFactory(record_factory)" msgstr "" -#: ../../howto/logging-cookbook.rst:1861 +#: ../../howto/logging-cookbook.rst:1856 msgid "" "This pattern allows different libraries to chain factories together, and as " "long as they don't overwrite each other's attributes or unintentionally " @@ -2506,22 +2498,22 @@ msgid "" "used when the use of a :class:`Filter` does not provide the desired result." msgstr "" -#: ../../howto/logging-cookbook.rst:1873 +#: ../../howto/logging-cookbook.rst:1868 msgid "Subclassing QueueHandler and QueueListener- a ZeroMQ example" msgstr "" -#: ../../howto/logging-cookbook.rst:1876 ../../howto/logging-cookbook.rst:2009 +#: ../../howto/logging-cookbook.rst:1871 ../../howto/logging-cookbook.rst:2004 msgid "Subclass ``QueueHandler``" msgstr "" -#: ../../howto/logging-cookbook.rst:1878 +#: ../../howto/logging-cookbook.rst:1873 msgid "" "You can use a :class:`QueueHandler` subclass to send messages to other kinds " "of queues, for example a ZeroMQ 'publish' socket. In the example below,the " "socket is created separately and passed to the handler (as its 'queue')::" msgstr "" -#: ../../howto/logging-cookbook.rst:1882 +#: ../../howto/logging-cookbook.rst:1877 msgid "" "import zmq # using pyzmq, the Python binding for ZeroMQ\n" "import json # for serializing records portably\n" @@ -2538,13 +2530,13 @@ msgid "" "handler = ZeroMQSocketHandler(sock)" msgstr "" -#: ../../howto/logging-cookbook.rst:1897 +#: ../../howto/logging-cookbook.rst:1892 msgid "" "Of course there are other ways of organizing this, for example passing in " "the data needed by the handler to create the socket::" msgstr "" -#: ../../howto/logging-cookbook.rst:1900 +#: ../../howto/logging-cookbook.rst:1895 msgid "" "class ZeroMQSocketHandler(QueueHandler):\n" " def __init__(self, uri, socktype=zmq.PUB, ctx=None):\n" @@ -2560,17 +2552,17 @@ msgid "" " self.queue.close()" msgstr "" -#: ../../howto/logging-cookbook.rst:1915 ../../howto/logging-cookbook.rst:1945 +#: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:1940 msgid "Subclass ``QueueListener``" msgstr "" -#: ../../howto/logging-cookbook.rst:1917 +#: ../../howto/logging-cookbook.rst:1912 msgid "" "You can also subclass :class:`QueueListener` to get messages from other " "kinds of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::" msgstr "" -#: ../../howto/logging-cookbook.rst:1920 +#: ../../howto/logging-cookbook.rst:1915 msgid "" "class ZeroMQSocketListener(QueueListener):\n" " def __init__(self, uri, /, *handlers, **kwargs):\n" @@ -2586,11 +2578,11 @@ msgid "" " return logging.makeLogRecord(msg)" msgstr "" -#: ../../howto/logging-cookbook.rst:1935 +#: ../../howto/logging-cookbook.rst:1930 msgid "Subclassing QueueHandler and QueueListener- a ``pynng`` example" msgstr "" -#: ../../howto/logging-cookbook.rst:1937 +#: ../../howto/logging-cookbook.rst:1932 msgid "" "In a similar way to the above section, we can implement a listener and " "handler using :pypi:`pynng`, which is a Python binding to `NNG `_ of the Django documentation." msgstr "" -#: ../../howto/logging-cookbook.rst:2183 +#: ../../howto/logging-cookbook.rst:2178 msgid "Using a rotator and namer to customize log rotation processing" msgstr "" -#: ../../howto/logging-cookbook.rst:2185 +#: ../../howto/logging-cookbook.rst:2180 msgid "" "An example of how you can define a namer and rotator is given in the " "following runnable script, which shows gzip compression of the log file::" msgstr "" -#: ../../howto/logging-cookbook.rst:2188 +#: ../../howto/logging-cookbook.rst:2183 msgid "" "import gzip\n" "import logging\n" @@ -2973,12 +2965,12 @@ msgstr "" "for i in range(1000):\n" " root.info(f'Message no. {i + 1}')" -#: ../../howto/logging-cookbook.rst:2216 +#: ../../howto/logging-cookbook.rst:2211 msgid "" "After running this, you will see six new files, five of which are compressed:" msgstr "" -#: ../../howto/logging-cookbook.rst:2218 +#: ../../howto/logging-cookbook.rst:2213 msgid "" "$ ls rotated.log*\n" "rotated.log rotated.log.2.gz rotated.log.4.gz\n" @@ -2996,11 +2988,11 @@ msgstr "" "2023-01-20 02:28:17,767 Message no. 997\n" "2023-01-20 02:28:17,767 Message no. 998" -#: ../../howto/logging-cookbook.rst:2229 +#: ../../howto/logging-cookbook.rst:2224 msgid "A more elaborate multiprocessing example" msgstr "" -#: ../../howto/logging-cookbook.rst:2231 +#: ../../howto/logging-cookbook.rst:2226 msgid "" "The following working example shows how logging can be used with " "multiprocessing using configuration files. The configurations are fairly " @@ -3008,7 +3000,7 @@ msgid "" "in a real multiprocessing scenario." msgstr "" -#: ../../howto/logging-cookbook.rst:2236 +#: ../../howto/logging-cookbook.rst:2231 msgid "" "In the example, the main process spawns a listener process and some worker " "processes. Each of the main process, the listener and the workers have three " @@ -3021,13 +3013,13 @@ msgid "" "own scenario." msgstr "" -#: ../../howto/logging-cookbook.rst:2246 +#: ../../howto/logging-cookbook.rst:2241 msgid "" "Here's the script - the docstrings and the comments hopefully explain how it " "works::" msgstr "" -#: ../../howto/logging-cookbook.rst:2249 +#: ../../howto/logging-cookbook.rst:2244 msgid "" "import logging\n" "import logging.config\n" @@ -3250,11 +3242,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2458 +#: ../../howto/logging-cookbook.rst:2453 msgid "Inserting a BOM into messages sent to a SysLogHandler" msgstr "" -#: ../../howto/logging-cookbook.rst:2460 +#: ../../howto/logging-cookbook.rst:2455 msgid "" ":rfc:`5424` requires that a Unicode message be sent to a syslog daemon as a " "set of bytes which have the following structure: an optional pure-ASCII " @@ -3263,7 +3255,7 @@ msgid "" "<5424#section-6>`.)" msgstr "" -#: ../../howto/logging-cookbook.rst:2466 +#: ../../howto/logging-cookbook.rst:2461 msgid "" "In Python 3.1, code was added to :class:`~logging.handlers.SysLogHandler` to " "insert a BOM into the message, but unfortunately, it was implemented " @@ -3271,7 +3263,7 @@ msgid "" "hence not allowing any pure-ASCII component to appear before it." msgstr "" -#: ../../howto/logging-cookbook.rst:2472 +#: ../../howto/logging-cookbook.rst:2467 msgid "" "As this behaviour is broken, the incorrect BOM insertion code is being " "removed from Python 3.2.4 and later. However, it is not being replaced, and " @@ -3280,37 +3272,37 @@ msgid "" "encoded using UTF-8, then you need to do the following:" msgstr "" -#: ../../howto/logging-cookbook.rst:2478 +#: ../../howto/logging-cookbook.rst:2473 msgid "" "Attach a :class:`~logging.Formatter` instance to your :class:`~logging." "handlers.SysLogHandler` instance, with a format string such as::" msgstr "" -#: ../../howto/logging-cookbook.rst:2482 +#: ../../howto/logging-cookbook.rst:2477 msgid "'ASCII section\\ufeffUnicode section'" msgstr "" -#: ../../howto/logging-cookbook.rst:2484 +#: ../../howto/logging-cookbook.rst:2479 msgid "" "The Unicode code point U+FEFF, when encoded using UTF-8, will be encoded as " "a UTF-8 BOM -- the byte-string ``b'\\xef\\xbb\\xbf'``." msgstr "" -#: ../../howto/logging-cookbook.rst:2487 +#: ../../howto/logging-cookbook.rst:2482 msgid "" "Replace the ASCII section with whatever placeholders you like, but make sure " "that the data that appears in there after substitution is always ASCII (that " "way, it will remain unchanged after UTF-8 encoding)." msgstr "" -#: ../../howto/logging-cookbook.rst:2491 +#: ../../howto/logging-cookbook.rst:2486 msgid "" "Replace the Unicode section with whatever placeholders you like; if the data " "which appears there after substitution contains characters outside the ASCII " "range, that's fine -- it will be encoded using UTF-8." msgstr "" -#: ../../howto/logging-cookbook.rst:2495 +#: ../../howto/logging-cookbook.rst:2490 msgid "" "The formatted message *will* be encoded using UTF-8 encoding by " "``SysLogHandler``. If you follow the above rules, you should be able to " @@ -3319,11 +3311,11 @@ msgid "" "daemon may complain." msgstr "" -#: ../../howto/logging-cookbook.rst:2502 +#: ../../howto/logging-cookbook.rst:2497 msgid "Implementing structured logging" msgstr "" -#: ../../howto/logging-cookbook.rst:2504 +#: ../../howto/logging-cookbook.rst:2499 msgid "" "Although most logging messages are intended for reading by humans, and thus " "not readily machine-parseable, there might be circumstances where you want " @@ -3335,7 +3327,7 @@ msgid "" "machine-parseable manner::" msgstr "" -#: ../../howto/logging-cookbook.rst:2512 +#: ../../howto/logging-cookbook.rst:2507 msgid "" "import json\n" "import logging\n" @@ -3354,11 +3346,11 @@ msgid "" "logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456))" msgstr "" -#: ../../howto/logging-cookbook.rst:2528 +#: ../../howto/logging-cookbook.rst:2523 msgid "If the above script is run, it prints:" msgstr "" -#: ../../howto/logging-cookbook.rst:2530 +#: ../../howto/logging-cookbook.rst:2525 msgid "" "message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " "\"bar\"}" @@ -3366,19 +3358,19 @@ msgstr "" "message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " "\"bar\"}" -#: ../../howto/logging-cookbook.rst:2534 ../../howto/logging-cookbook.rst:2576 +#: ../../howto/logging-cookbook.rst:2529 ../../howto/logging-cookbook.rst:2571 msgid "" "Note that the order of items might be different according to the version of " "Python used." msgstr "" -#: ../../howto/logging-cookbook.rst:2537 +#: ../../howto/logging-cookbook.rst:2532 msgid "" "If you need more specialised processing, you can use a custom JSON encoder, " "as in the following complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2540 +#: ../../howto/logging-cookbook.rst:2535 msgid "" "import json\n" "import logging\n" @@ -3411,19 +3403,19 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2570 +#: ../../howto/logging-cookbook.rst:2565 msgid "When the above script is run, it prints:" msgstr "" -#: ../../howto/logging-cookbook.rst:2572 +#: ../../howto/logging-cookbook.rst:2567 msgid "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" msgstr "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" -#: ../../howto/logging-cookbook.rst:2585 +#: ../../howto/logging-cookbook.rst:2580 msgid "Customizing handlers with :func:`dictConfig`" msgstr "" -#: ../../howto/logging-cookbook.rst:2587 +#: ../../howto/logging-cookbook.rst:2582 msgid "" "There are times when you want to customize logging handlers in particular " "ways, and if you use :func:`dictConfig` you may be able to do this without " @@ -3433,7 +3425,7 @@ msgid "" "customize handler creation using a plain function such as::" msgstr "" -#: ../../howto/logging-cookbook.rst:2594 +#: ../../howto/logging-cookbook.rst:2589 msgid "" "def owned_file_handler(filename, mode='a', encoding=None, owner=None):\n" " if owner:\n" @@ -3449,13 +3441,13 @@ msgstr "" " shutil.chown(filename, *owner)\n" " return logging.FileHandler(filename, mode, encoding)" -#: ../../howto/logging-cookbook.rst:2601 +#: ../../howto/logging-cookbook.rst:2596 msgid "" "You can then specify, in a logging configuration passed to :func:" "`dictConfig`, that a logging handler be created by calling this function::" msgstr "" -#: ../../howto/logging-cookbook.rst:2604 +#: ../../howto/logging-cookbook.rst:2599 msgid "" "LOGGING = {\n" " 'version': 1,\n" @@ -3488,14 +3480,14 @@ msgid "" "}" msgstr "" -#: ../../howto/logging-cookbook.rst:2634 +#: ../../howto/logging-cookbook.rst:2629 msgid "" "In this example I am setting the ownership using the ``pulse`` user and " "group, just for the purposes of illustration. Putting it together into a " "working script, ``chowntest.py``::" msgstr "" -#: ../../howto/logging-cookbook.rst:2638 +#: ../../howto/logging-cookbook.rst:2633 msgid "" "import logging, logging.config, os, shutil\n" "\n" @@ -3541,11 +3533,11 @@ msgid "" "logger.debug('A debug message')" msgstr "" -#: ../../howto/logging-cookbook.rst:2681 +#: ../../howto/logging-cookbook.rst:2676 msgid "To run this, you will probably need to run as ``root``:" msgstr "" -#: ../../howto/logging-cookbook.rst:2683 +#: ../../howto/logging-cookbook.rst:2678 msgid "" "$ sudo python3.3 chowntest.py\n" "$ cat chowntest.log\n" @@ -3554,7 +3546,7 @@ msgid "" "-rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log" msgstr "" -#: ../../howto/logging-cookbook.rst:2691 +#: ../../howto/logging-cookbook.rst:2686 msgid "" "Note that this example uses Python 3.3 because that's where :func:`shutil." "chown` makes an appearance. This approach should work with any Python " @@ -3563,25 +3555,25 @@ msgid "" "change using e.g. :func:`os.chown`." msgstr "" -#: ../../howto/logging-cookbook.rst:2697 +#: ../../howto/logging-cookbook.rst:2692 msgid "" "In practice, the handler-creating function may be in a utility module " "somewhere in your project. Instead of the line in the configuration::" msgstr "" -#: ../../howto/logging-cookbook.rst:2700 +#: ../../howto/logging-cookbook.rst:2695 msgid "'()': owned_file_handler," msgstr "'()': owned_file_handler," -#: ../../howto/logging-cookbook.rst:2702 +#: ../../howto/logging-cookbook.rst:2697 msgid "you could use e.g.::" msgstr "" -#: ../../howto/logging-cookbook.rst:2704 +#: ../../howto/logging-cookbook.rst:2699 msgid "'()': 'ext://project.util.owned_file_handler'," msgstr "'()': 'ext://project.util.owned_file_handler'," -#: ../../howto/logging-cookbook.rst:2706 +#: ../../howto/logging-cookbook.rst:2701 msgid "" "where ``project.util`` can be replaced with the actual name of the package " "where the function resides. In the above working script, using ``'ext://" @@ -3589,25 +3581,25 @@ msgid "" "resolved by :func:`dictConfig` from the ``ext://`` specification." msgstr "" -#: ../../howto/logging-cookbook.rst:2711 +#: ../../howto/logging-cookbook.rst:2706 msgid "" "This example hopefully also points the way to how you could implement other " "types of file change - e.g. setting specific POSIX permission bits - in the " "same way, using :func:`os.chmod`." msgstr "" -#: ../../howto/logging-cookbook.rst:2715 +#: ../../howto/logging-cookbook.rst:2710 msgid "" "Of course, the approach could also be extended to types of handler other " "than a :class:`~logging.FileHandler` - for example, one of the rotating file " "handlers, or a different type of handler altogether." msgstr "" -#: ../../howto/logging-cookbook.rst:2725 +#: ../../howto/logging-cookbook.rst:2720 msgid "Using particular formatting styles throughout your application" msgstr "" -#: ../../howto/logging-cookbook.rst:2727 +#: ../../howto/logging-cookbook.rst:2722 msgid "" "In Python 3.2, the :class:`~logging.Formatter` gained a ``style`` keyword " "parameter which, while defaulting to ``%`` for backward compatibility, " @@ -3618,7 +3610,7 @@ msgid "" "is constructed." msgstr "" -#: ../../howto/logging-cookbook.rst:2734 +#: ../../howto/logging-cookbook.rst:2729 msgid "" "Logging calls (:meth:`~Logger.debug`, :meth:`~Logger.info` etc.) only take " "positional parameters for the actual logging message itself, with keyword " @@ -3633,7 +3625,7 @@ msgid "" "calls which are out there in existing code will be using %-format strings." msgstr "" -#: ../../howto/logging-cookbook.rst:2746 +#: ../../howto/logging-cookbook.rst:2741 msgid "" "There have been suggestions to associate format styles with specific " "loggers, but that approach also runs into backward compatibility problems " @@ -3641,7 +3633,7 @@ msgid "" "formatting." msgstr "" -#: ../../howto/logging-cookbook.rst:2750 +#: ../../howto/logging-cookbook.rst:2745 msgid "" "For logging to work interoperably between any third-party libraries and your " "code, decisions about formatting need to be made at the level of the " @@ -3649,11 +3641,11 @@ msgid "" "formatting styles can be accommodated." msgstr "" -#: ../../howto/logging-cookbook.rst:2757 +#: ../../howto/logging-cookbook.rst:2752 msgid "Using LogRecord factories" msgstr "" -#: ../../howto/logging-cookbook.rst:2759 +#: ../../howto/logging-cookbook.rst:2754 msgid "" "In Python 3.2, along with the :class:`~logging.Formatter` changes mentioned " "above, the logging package gained the ability to allow users to set their " @@ -3668,17 +3660,17 @@ msgid "" "implementation does." msgstr "" -#: ../../howto/logging-cookbook.rst:2770 +#: ../../howto/logging-cookbook.rst:2765 msgid "" "Refer to the reference documentation on :func:`setLogRecordFactory` and :" "class:`LogRecord` for more information." msgstr "" -#: ../../howto/logging-cookbook.rst:2775 +#: ../../howto/logging-cookbook.rst:2770 msgid "Using custom message objects" msgstr "" -#: ../../howto/logging-cookbook.rst:2777 +#: ../../howto/logging-cookbook.rst:2772 msgid "" "There is another, perhaps simpler way that you can use {}- and $- formatting " "to construct your individual log messages. You may recall (from :ref:" @@ -3688,7 +3680,7 @@ msgid "" "following two classes::" msgstr "" -#: ../../howto/logging-cookbook.rst:2802 +#: ../../howto/logging-cookbook.rst:2797 msgid "" "Either of these can be used in place of a format string, to allow {}- or $-" "formatting to be used to build the actual \"message\" part which appears in " @@ -3699,13 +3691,13 @@ msgid "" "using ``_`` for localization)." msgstr "" -#: ../../howto/logging-cookbook.rst:2810 +#: ../../howto/logging-cookbook.rst:2805 msgid "" "Examples of this approach are given below. Firstly, formatting with :meth:" "`str.format`::" msgstr "" -#: ../../howto/logging-cookbook.rst:2813 +#: ../../howto/logging-cookbook.rst:2808 msgid "" ">>> __ = BraceMessage\n" ">>> print(__('Message with {0} {1}', 2, 'placeholders'))\n" @@ -3731,11 +3723,11 @@ msgstr "" "point=p))\n" "Message with coordinates: (0.50, 0.50)" -#: ../../howto/logging-cookbook.rst:2824 +#: ../../howto/logging-cookbook.rst:2819 msgid "Secondly, formatting with :class:`string.Template`::" msgstr "" -#: ../../howto/logging-cookbook.rst:2826 +#: ../../howto/logging-cookbook.rst:2821 msgid "" ">>> __ = DollarMessage\n" ">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" @@ -3747,7 +3739,7 @@ msgstr "" "Message with 2 placeholders\n" ">>>" -#: ../../howto/logging-cookbook.rst:2831 +#: ../../howto/logging-cookbook.rst:2826 msgid "" "One thing to note is that you pay no significant performance penalty with " "this approach: the actual formatting happens not when you make the logging " @@ -3759,11 +3751,11 @@ msgid "" "shown above." msgstr "" -#: ../../howto/logging-cookbook.rst:2845 +#: ../../howto/logging-cookbook.rst:2840 msgid "Configuring filters with :func:`dictConfig`" msgstr "" -#: ../../howto/logging-cookbook.rst:2847 +#: ../../howto/logging-cookbook.rst:2842 msgid "" "You *can* configure filters using :func:`~logging.config.dictConfig`, though " "it might not be obvious at first glance how to do it (hence this recipe). " @@ -3778,7 +3770,7 @@ msgid "" "complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2858 +#: ../../howto/logging-cookbook.rst:2853 msgid "" "import logging\n" "import logging.config\n" @@ -3864,26 +3856,26 @@ msgstr "" " logging.debug('hello')\n" " logging.debug('hello - noshow')" -#: ../../howto/logging-cookbook.rst:2900 +#: ../../howto/logging-cookbook.rst:2895 msgid "" "This example shows how you can pass configuration data to the callable which " "constructs the instance, in the form of keyword parameters. When run, the " "above script will print:" msgstr "" -#: ../../howto/logging-cookbook.rst:2904 +#: ../../howto/logging-cookbook.rst:2899 msgid "changed: hello" msgstr "changed: hello" -#: ../../howto/logging-cookbook.rst:2908 +#: ../../howto/logging-cookbook.rst:2903 msgid "which shows that the filter is working as configured." msgstr "" -#: ../../howto/logging-cookbook.rst:2910 +#: ../../howto/logging-cookbook.rst:2905 msgid "A couple of extra points to note:" msgstr "" -#: ../../howto/logging-cookbook.rst:2912 +#: ../../howto/logging-cookbook.rst:2907 msgid "" "If you can't refer to the callable directly in the configuration (e.g. if it " "lives in a different module, and you can't import it directly where the " @@ -3893,7 +3885,7 @@ msgid "" "the above example." msgstr "" -#: ../../howto/logging-cookbook.rst:2919 +#: ../../howto/logging-cookbook.rst:2914 msgid "" "As well as for filters, this technique can also be used to configure custom " "handlers and formatters. See :ref:`logging-config-dict-userdef` for more " @@ -3902,11 +3894,11 @@ msgid "" "above." msgstr "" -#: ../../howto/logging-cookbook.rst:2928 +#: ../../howto/logging-cookbook.rst:2923 msgid "Customized exception formatting" msgstr "" -#: ../../howto/logging-cookbook.rst:2930 +#: ../../howto/logging-cookbook.rst:2925 msgid "" "There might be times when you want to do customized exception formatting - " "for argument's sake, let's say you want exactly one line per logged event, " @@ -3914,7 +3906,7 @@ msgid "" "formatter class, as shown in the following example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2935 +#: ../../howto/logging-cookbook.rst:2930 msgid "" "import logging\n" "\n" @@ -3953,11 +3945,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2971 +#: ../../howto/logging-cookbook.rst:2966 msgid "When run, this produces a file with exactly two lines:" msgstr "" -#: ../../howto/logging-cookbook.rst:2973 +#: ../../howto/logging-cookbook.rst:2968 msgid "" "28/01/2015 07:21:23|INFO|Sample message|\n" "28/01/2015 07:21:23|ERROR|ZeroDivisionError: division by zero|'Traceback " @@ -3969,18 +3961,18 @@ msgstr "" "(most recent call last):\\n File \"logtest7.py\", line 30, in main\\n x " "= 1 / 0\\nZeroDivisionError: division by zero'|" -#: ../../howto/logging-cookbook.rst:2978 +#: ../../howto/logging-cookbook.rst:2973 msgid "" "While the above treatment is simplistic, it points the way to how exception " "information can be formatted to your liking. The :mod:`traceback` module may " "be helpful for more specialized needs." msgstr "" -#: ../../howto/logging-cookbook.rst:2985 +#: ../../howto/logging-cookbook.rst:2980 msgid "Speaking logging messages" msgstr "" -#: ../../howto/logging-cookbook.rst:2987 +#: ../../howto/logging-cookbook.rst:2982 msgid "" "There might be situations when it is desirable to have logging messages " "rendered in an audible rather than a visible format. This is easy to do if " @@ -3997,7 +3989,7 @@ msgid "" "approach, which assumes that the ``espeak`` TTS package is available::" msgstr "" -#: ../../howto/logging-cookbook.rst:3000 +#: ../../howto/logging-cookbook.rst:2995 msgid "" "import logging\n" "import subprocess\n" @@ -4029,24 +4021,24 @@ msgid "" " sys.exit(main())" msgstr "" -#: ../../howto/logging-cookbook.rst:3029 +#: ../../howto/logging-cookbook.rst:3024 msgid "" "When run, this script should say \"Hello\" and then \"Goodbye\" in a female " "voice." msgstr "" -#: ../../howto/logging-cookbook.rst:3031 +#: ../../howto/logging-cookbook.rst:3026 msgid "" "The above approach can, of course, be adapted to other TTS systems and even " "other systems altogether which can process messages via external programs " "run from a command line." msgstr "" -#: ../../howto/logging-cookbook.rst:3039 +#: ../../howto/logging-cookbook.rst:3034 msgid "Buffering logging messages and outputting them conditionally" msgstr "" -#: ../../howto/logging-cookbook.rst:3041 +#: ../../howto/logging-cookbook.rst:3036 msgid "" "There might be situations where you want to log messages in a temporary area " "and only output them if a certain condition occurs. For example, you may " @@ -4056,7 +4048,7 @@ msgid "" "debug information to be output as well as the error." msgstr "" -#: ../../howto/logging-cookbook.rst:3048 +#: ../../howto/logging-cookbook.rst:3043 msgid "" "Here is an example which shows how you could do this using a decorator for " "your functions where you want logging to behave this way. It makes use of " @@ -4069,7 +4061,7 @@ msgid "" "subclass of ``MemoryHandler`` if you want custom flushing behavior." msgstr "" -#: ../../howto/logging-cookbook.rst:3058 +#: ../../howto/logging-cookbook.rst:3053 msgid "" "The example script has a simple function, ``foo``, which just cycles through " "all the logging levels, writing to ``sys.stderr`` to say what level it's " @@ -4078,7 +4070,7 @@ msgid "" "levels - otherwise, it only logs at DEBUG, INFO and WARNING levels." msgstr "" -#: ../../howto/logging-cookbook.rst:3064 +#: ../../howto/logging-cookbook.rst:3059 msgid "" "The script just arranges to decorate ``foo`` with a decorator which will do " "the conditional logging that's required. The decorator takes a logger as a " @@ -4090,11 +4082,11 @@ msgid "" "respectively." msgstr "" -#: ../../howto/logging-cookbook.rst:3072 +#: ../../howto/logging-cookbook.rst:3067 msgid "Here's the script::" msgstr "" -#: ../../howto/logging-cookbook.rst:3074 +#: ../../howto/logging-cookbook.rst:3069 msgid "" "import logging\n" "from logging.handlers import MemoryHandler\n" @@ -4160,11 +4152,11 @@ msgid "" " assert decorated_foo(True)" msgstr "" -#: ../../howto/logging-cookbook.rst:3135 +#: ../../howto/logging-cookbook.rst:3130 msgid "When this script is run, the following output should be observed:" msgstr "" -#: ../../howto/logging-cookbook.rst:3137 +#: ../../howto/logging-cookbook.rst:3132 msgid "" "Calling undecorated foo with False\n" "about to log at DEBUG ...\n" @@ -4193,29 +4185,29 @@ msgid "" "Actually logged at CRITICAL" msgstr "" -#: ../../howto/logging-cookbook.rst:3165 +#: ../../howto/logging-cookbook.rst:3160 msgid "" "As you can see, actual logging output only occurs when an event is logged " "whose severity is ERROR or greater, but in that case, any previous events at " "lower severities are also logged." msgstr "" -#: ../../howto/logging-cookbook.rst:3169 +#: ../../howto/logging-cookbook.rst:3164 msgid "You can of course use the conventional means of decoration::" msgstr "" -#: ../../howto/logging-cookbook.rst:3171 +#: ../../howto/logging-cookbook.rst:3166 msgid "" "@log_if_errors(logger)\n" "def foo(fail=False):\n" " ..." msgstr "" -#: ../../howto/logging-cookbook.rst:3179 +#: ../../howto/logging-cookbook.rst:3174 msgid "Sending logging messages to email, with buffering" msgstr "" -#: ../../howto/logging-cookbook.rst:3181 +#: ../../howto/logging-cookbook.rst:3176 msgid "" "To illustrate how you can send log messages via email, so that a set number " "of messages are sent per email, you can subclass :class:`~logging.handlers." @@ -4226,7 +4218,7 @@ msgid "" "argument to see the required and optional arguments.)" msgstr "" -#: ../../howto/logging-cookbook.rst:3189 +#: ../../howto/logging-cookbook.rst:3184 msgid "" "import logging\n" "import logging.handlers\n" @@ -4294,7 +4286,7 @@ msgid "" " h.close()" msgstr "" -#: ../../howto/logging-cookbook.rst:3253 +#: ../../howto/logging-cookbook.rst:3248 msgid "" "If you run this script and your SMTP server is correctly set up, you should " "find that it sends eleven emails to the addressee you specify. The first ten " @@ -4302,17 +4294,17 @@ msgid "" "messages. That makes up 102 messages as specified in the script." msgstr "" -#: ../../howto/logging-cookbook.rst:3261 +#: ../../howto/logging-cookbook.rst:3256 msgid "Formatting times using UTC (GMT) via configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:3263 +#: ../../howto/logging-cookbook.rst:3258 msgid "" "Sometimes you want to format times using UTC, which can be done using a " "class such as ``UTCFormatter``, shown below::" msgstr "" -#: ../../howto/logging-cookbook.rst:3266 +#: ../../howto/logging-cookbook.rst:3261 msgid "" "import logging\n" "import time\n" @@ -4326,7 +4318,7 @@ msgstr "" "class UTCFormatter(logging.Formatter):\n" " converter = time.gmtime" -#: ../../howto/logging-cookbook.rst:3272 +#: ../../howto/logging-cookbook.rst:3267 msgid "" "and you can then use the ``UTCFormatter`` in your code instead of :class:" "`~logging.Formatter`. If you want to do that via configuration, you can use " @@ -4334,7 +4326,7 @@ msgid "" "the following complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:3277 +#: ../../howto/logging-cookbook.rst:3272 msgid "" "import logging\n" "import logging.config\n" @@ -4412,11 +4404,11 @@ msgstr "" " logging.config.dictConfig(LOGGING)\n" " logging.warning('The local time is %s', time.asctime())" -#: ../../howto/logging-cookbook.rst:3315 +#: ../../howto/logging-cookbook.rst:3310 msgid "When this script is run, it should print something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:3317 +#: ../../howto/logging-cookbook.rst:3312 msgid "" "2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015\n" "2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015" @@ -4424,17 +4416,17 @@ msgstr "" "2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015\n" "2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015" -#: ../../howto/logging-cookbook.rst:3322 +#: ../../howto/logging-cookbook.rst:3317 msgid "" "showing how the time is formatted both as local time and UTC, one for each " "handler." msgstr "" -#: ../../howto/logging-cookbook.rst:3329 +#: ../../howto/logging-cookbook.rst:3324 msgid "Using a context manager for selective logging" msgstr "" -#: ../../howto/logging-cookbook.rst:3331 +#: ../../howto/logging-cookbook.rst:3326 msgid "" "There are times when it would be useful to temporarily change the logging " "configuration and revert it back after doing something. For this, a context " @@ -4444,7 +4436,7 @@ msgid "" "scope of the context manager::" msgstr "" -#: ../../howto/logging-cookbook.rst:3338 +#: ../../howto/logging-cookbook.rst:3333 msgid "" "import logging\n" "import sys\n" @@ -4473,7 +4465,7 @@ msgid "" " # implicit return of None => don't swallow exceptions" msgstr "" -#: ../../howto/logging-cookbook.rst:3364 +#: ../../howto/logging-cookbook.rst:3359 msgid "" "If you specify a level value, the logger's level is set to that value in the " "scope of the with block covered by the context manager. If you specify a " @@ -4482,13 +4474,13 @@ msgid "" "block exit - you could do this if you don't need the handler any more." msgstr "" -#: ../../howto/logging-cookbook.rst:3370 +#: ../../howto/logging-cookbook.rst:3365 msgid "" "To illustrate how it works, we can add the following block of code to the " "above::" msgstr "" -#: ../../howto/logging-cookbook.rst:3373 +#: ../../howto/logging-cookbook.rst:3368 msgid "" "if __name__ == '__main__':\n" " logger = logging.getLogger('foo')\n" @@ -4524,7 +4516,7 @@ msgstr "" " logger.info('6. This should appear just once on stderr.')\n" " logger.debug('7. This should not appear.')" -#: ../../howto/logging-cookbook.rst:3388 +#: ../../howto/logging-cookbook.rst:3383 msgid "" "We initially set the logger's level to ``INFO``, so message #1 appears and " "message #2 doesn't. We then change the level to ``DEBUG`` temporarily in the " @@ -4537,11 +4529,11 @@ msgid "" "(like message #1) whereas message #7 doesn't (just like message #2)." msgstr "" -#: ../../howto/logging-cookbook.rst:3398 +#: ../../howto/logging-cookbook.rst:3393 msgid "If we run the resulting script, the result is as follows:" msgstr "" -#: ../../howto/logging-cookbook.rst:3400 +#: ../../howto/logging-cookbook.rst:3395 msgid "" "$ python logctx.py\n" "1. This should appear just once on stderr.\n" @@ -4557,23 +4549,23 @@ msgstr "" "5. This should appear twice - once on stderr and once on stdout.\n" "6. This should appear just once on stderr." -#: ../../howto/logging-cookbook.rst:3409 +#: ../../howto/logging-cookbook.rst:3404 msgid "" "If we run it again, but pipe ``stderr`` to ``/dev/null``, we see the " "following, which is the only message written to ``stdout``:" msgstr "" -#: ../../howto/logging-cookbook.rst:3412 +#: ../../howto/logging-cookbook.rst:3407 msgid "" "$ python logctx.py 2>/dev/null\n" "5. This should appear twice - once on stderr and once on stdout." msgstr "" -#: ../../howto/logging-cookbook.rst:3417 +#: ../../howto/logging-cookbook.rst:3412 msgid "Once again, but piping ``stdout`` to ``/dev/null``, we get:" msgstr "" -#: ../../howto/logging-cookbook.rst:3419 +#: ../../howto/logging-cookbook.rst:3414 msgid "" "$ python logctx.py >/dev/null\n" "1. This should appear just once on stderr.\n" @@ -4587,42 +4579,42 @@ msgstr "" "5. This should appear twice - once on stderr and once on stdout.\n" "6. This should appear just once on stderr." -#: ../../howto/logging-cookbook.rst:3427 +#: ../../howto/logging-cookbook.rst:3422 msgid "" "In this case, the message #5 printed to ``stdout`` doesn't appear, as " "expected." msgstr "" -#: ../../howto/logging-cookbook.rst:3429 +#: ../../howto/logging-cookbook.rst:3424 msgid "" "Of course, the approach described here can be generalised, for example to " "attach logging filters temporarily. Note that the above code works in Python " "2 as well as Python 3." msgstr "" -#: ../../howto/logging-cookbook.rst:3437 +#: ../../howto/logging-cookbook.rst:3432 msgid "A CLI application starter template" msgstr "" -#: ../../howto/logging-cookbook.rst:3439 +#: ../../howto/logging-cookbook.rst:3434 msgid "Here's an example which shows how you can:" msgstr "" -#: ../../howto/logging-cookbook.rst:3441 +#: ../../howto/logging-cookbook.rst:3436 msgid "Use a logging level based on command-line arguments" msgstr "" -#: ../../howto/logging-cookbook.rst:3442 +#: ../../howto/logging-cookbook.rst:3437 msgid "" "Dispatch to multiple subcommands in separate files, all logging at the same " "level in a consistent way" msgstr "" -#: ../../howto/logging-cookbook.rst:3444 +#: ../../howto/logging-cookbook.rst:3439 msgid "Make use of simple, minimal configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:3446 +#: ../../howto/logging-cookbook.rst:3441 msgid "" "Suppose we have a command-line application whose job is to stop, start or " "restart some services. This could be organised for the purposes of " @@ -4633,7 +4625,7 @@ msgid "" "``logging.INFO``. Here's one way that ``app.py`` could be written::" msgstr "" -#: ../../howto/logging-cookbook.rst:3454 +#: ../../howto/logging-cookbook.rst:3449 msgid "" "import argparse\n" "import importlib\n" @@ -4680,13 +4672,13 @@ msgid "" " sys.exit(main())" msgstr "" -#: ../../howto/logging-cookbook.rst:3495 +#: ../../howto/logging-cookbook.rst:3490 msgid "" "And the ``start``, ``stop`` and ``restart`` commands can be implemented in " "separate modules, like so for starting::" msgstr "" -#: ../../howto/logging-cookbook.rst:3498 +#: ../../howto/logging-cookbook.rst:3493 msgid "" "# start.py\n" "import logging\n" @@ -4708,11 +4700,11 @@ msgstr "" " # 在這裡實際執行命令處理 ...\n" " logger.info('Started the \\'%s\\' service.', options.name)" -#: ../../howto/logging-cookbook.rst:3508 +#: ../../howto/logging-cookbook.rst:3503 msgid "and thus for stopping::" msgstr "" -#: ../../howto/logging-cookbook.rst:3510 +#: ../../howto/logging-cookbook.rst:3505 msgid "" "# stop.py\n" "import logging\n" @@ -4752,11 +4744,11 @@ msgstr "" " # 在這裡實際執行命令處理 ...\n" " logger.info('Stopped the %s service%s.', services, plural)" -#: ../../howto/logging-cookbook.rst:3529 +#: ../../howto/logging-cookbook.rst:3524 msgid "and similarly for restarting::" msgstr "" -#: ../../howto/logging-cookbook.rst:3531 +#: ../../howto/logging-cookbook.rst:3526 msgid "" "# restart.py\n" "import logging\n" @@ -4796,13 +4788,13 @@ msgstr "" " # 在這裡實際執行命令處理 ...\n" " logger.info('Restarted the %s service%s.', services, plural)" -#: ../../howto/logging-cookbook.rst:3550 +#: ../../howto/logging-cookbook.rst:3545 msgid "" "If we run this application with the default log level, we get output like " "this:" msgstr "" -#: ../../howto/logging-cookbook.rst:3552 +#: ../../howto/logging-cookbook.rst:3547 msgid "" "$ python app.py start foo\n" "INFO start Started the 'foo' service.\n" @@ -4822,19 +4814,19 @@ msgstr "" "$ python app.py restart foo bar baz\n" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." -#: ../../howto/logging-cookbook.rst:3563 +#: ../../howto/logging-cookbook.rst:3558 msgid "" "The first word is the logging level, and the second word is the module or " "package name of the place where the event was logged." msgstr "" -#: ../../howto/logging-cookbook.rst:3566 +#: ../../howto/logging-cookbook.rst:3561 msgid "" "If we change the logging level, then we can change the information sent to " "the log. For example, if we want more information:" msgstr "" -#: ../../howto/logging-cookbook.rst:3569 +#: ../../howto/logging-cookbook.rst:3564 msgid "" "$ python app.py --log-level DEBUG start foo\n" "DEBUG start About to start foo\n" @@ -4860,11 +4852,11 @@ msgstr "" "DEBUG restart About to restart 'foo', 'bar' and 'baz'\n" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." -#: ../../howto/logging-cookbook.rst:3583 +#: ../../howto/logging-cookbook.rst:3578 msgid "And if we want less:" msgstr "" -#: ../../howto/logging-cookbook.rst:3585 +#: ../../howto/logging-cookbook.rst:3580 msgid "" "$ python app.py --log-level WARNING start foo\n" "$ python app.py --log-level WARNING stop foo bar\n" @@ -4874,17 +4866,17 @@ msgstr "" "$ python app.py --log-level WARNING stop foo bar\n" "$ python app.py --log-level WARNING restart foo bar baz" -#: ../../howto/logging-cookbook.rst:3591 +#: ../../howto/logging-cookbook.rst:3586 msgid "" "In this case, the commands don't print anything to the console, since " "nothing at ``WARNING`` level or above is logged by them." msgstr "" -#: ../../howto/logging-cookbook.rst:3597 +#: ../../howto/logging-cookbook.rst:3592 msgid "A Qt GUI for logging" msgstr "" -#: ../../howto/logging-cookbook.rst:3599 +#: ../../howto/logging-cookbook.rst:3594 msgid "" "A question that comes up from time to time is about how to log to a GUI " "application. The `Qt `_ framework is a popular cross-" @@ -4892,7 +4884,7 @@ msgid "" "`PyQt5` libraries." msgstr "" -#: ../../howto/logging-cookbook.rst:3604 +#: ../../howto/logging-cookbook.rst:3599 msgid "" "The following example shows how to log to a Qt GUI. This introduces a simple " "``QtHandler`` class which takes a callable, which should be a slot in the " @@ -4902,14 +4894,14 @@ msgid "" "logging messages at random levels with random short delays in between)." msgstr "" -#: ../../howto/logging-cookbook.rst:3611 +#: ../../howto/logging-cookbook.rst:3606 msgid "" "The worker thread is implemented using Qt's ``QThread`` class rather than " "the :mod:`threading` module, as there are circumstances where one has to use " "``QThread``, which offers better integration with other ``Qt`` components." msgstr "" -#: ../../howto/logging-cookbook.rst:3615 +#: ../../howto/logging-cookbook.rst:3610 msgid "" "The code should work with recent releases of any of ``PySide6``, ``PyQt6``, " "``PySide2`` or ``PyQt5``. You should be able to adapt the approach to " @@ -4917,7 +4909,7 @@ msgid "" "more detailed information." msgstr "" -#: ../../howto/logging-cookbook.rst:3620 +#: ../../howto/logging-cookbook.rst:3615 msgid "" "import logging\n" "import random\n" @@ -5167,11 +5159,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:3851 +#: ../../howto/logging-cookbook.rst:3846 msgid "Logging to syslog with RFC5424 support" msgstr "" -#: ../../howto/logging-cookbook.rst:3853 +#: ../../howto/logging-cookbook.rst:3848 msgid "" "Although :rfc:`5424` dates from 2009, most syslog servers are configured by " "default to use the older :rfc:`3164`, which hails from 2001. When " @@ -5181,14 +5173,14 @@ msgid "" "handlers.SysLogHandler` functionality has not been updated." msgstr "" -#: ../../howto/logging-cookbook.rst:3860 +#: ../../howto/logging-cookbook.rst:3855 msgid "" "RFC 5424 contains some useful features such as support for structured data, " "and if you need to be able to log to a syslog server with support for it, " "you can do so with a subclassed handler which looks something like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:3864 +#: ../../howto/logging-cookbook.rst:3859 msgid "" "import datetime as dt\n" "import logging.handlers\n" @@ -5209,7 +5201,7 @@ msgid "" " def format(self, record):\n" " version = 1\n" " asctime = dt.datetime.fromtimestamp(record.created).isoformat()\n" -" m = self.tz_offset.match(time.strftime('%z'))\n" +" m = self.tz_offset.prefixmatch(time.strftime('%z'))\n" " has_offset = False\n" " if m and time.timezone:\n" " hrs, mins = m.groups()\n" @@ -5256,8 +5248,70 @@ msgid "" " return f'{version} {asctime} {hostname} {appname} {procid} {msgid} " "{sdata} {msg}'" msgstr "" +"import datetime as dt\n" +"import logging.handlers\n" +"import re\n" +"import socket\n" +"import time\n" +"\n" +"class SysLogHandler5424(logging.handlers.SysLogHandler):\n" +"\n" +" tz_offset = re.compile(r'([+-]\\d{2})(\\d{2})$')\n" +" escaped = re.compile(r'([\\]\"\\\\])')\n" +"\n" +" def __init__(self, *args, **kwargs):\n" +" self.msgid = kwargs.pop('msgid', None)\n" +" self.appname = kwargs.pop('appname', None)\n" +" super().__init__(*args, **kwargs)\n" +"\n" +" def format(self, record):\n" +" version = 1\n" +" asctime = dt.datetime.fromtimestamp(record.created).isoformat()\n" +" m = self.tz_offset.prefixmatch(time.strftime('%z'))\n" +" has_offset = False\n" +" if m and time.timezone:\n" +" hrs, mins = m.groups()\n" +" if int(hrs) or int(mins):\n" +" has_offset = True\n" +" if not has_offset:\n" +" asctime += 'Z'\n" +" else:\n" +" asctime += f'{hrs}:{mins}'\n" +" try:\n" +" hostname = socket.gethostname()\n" +" except Exception:\n" +" hostname = '-'\n" +" appname = self.appname or '-'\n" +" procid = record.process\n" +" msgid = '-'\n" +" msg = super().format(record)\n" +" sdata = '-'\n" +" if hasattr(record, 'structured_data'):\n" +" sd = record.structured_data\n" +" # 這應該是一個 dict,其鍵為 SD-ID,值則為一個\n" +" # 將 PARAM-NAME 對映到 PARAM-VALUE 的 dict(這些名稱的意義\n" +" # 請參閱 RFC)\n" +" # 這裡沒有任何錯誤檢查——這純粹是為了說明,你可以\n" +" # 修改這段程式碼以用於正式環境\n" +" parts = []\n" +"\n" +" def replacer(m):\n" +" g = m.groups()\n" +" return '\\\\' + g[0]\n" +"\n" +" for sdid, dv in sd.items():\n" +" part = f'[{sdid}'\n" +" for k, v in dv.items():\n" +" s = str(v)\n" +" s = self.escaped.sub(replacer, s)\n" +" part += f' {k}=\"{s}\"'\n" +" part += ']'\n" +" parts.append(part)\n" +" sdata = ''.join(parts)\n" +" return f'{version} {asctime} {hostname} {appname} {procid} {msgid} " +"{sdata} {msg}'" -#: ../../howto/logging-cookbook.rst:3926 +#: ../../howto/logging-cookbook.rst:3921 msgid "" "You'll need to be familiar with RFC 5424 to fully understand the above code, " "and it may be that you have slightly different needs (e.g. for how you pass " @@ -5266,7 +5320,7 @@ msgid "" "using something like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:3931 +#: ../../howto/logging-cookbook.rst:3926 msgid "" "sd = {\n" " 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'},\n" @@ -5284,11 +5338,11 @@ msgstr "" "i = 1\n" "logger.debug('Message %d', i, extra=extra)" -#: ../../howto/logging-cookbook.rst:3940 +#: ../../howto/logging-cookbook.rst:3935 msgid "How to treat a logger like an output stream" msgstr "" -#: ../../howto/logging-cookbook.rst:3942 +#: ../../howto/logging-cookbook.rst:3937 msgid "" "Sometimes, you need to interface to a third-party API which expects a file-" "like object to write to, but you want to direct the API's output to a " @@ -5296,7 +5350,7 @@ msgid "" "API. Here's a short script illustrating such a class:" msgstr "" -#: ../../howto/logging-cookbook.rst:3947 +#: ../../howto/logging-cookbook.rst:3942 msgid "" "import logging\n" "\n" @@ -5334,11 +5388,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:3982 +#: ../../howto/logging-cookbook.rst:3977 msgid "When this script is run, it prints" msgstr "" -#: ../../howto/logging-cookbook.rst:3984 +#: ../../howto/logging-cookbook.rst:3979 msgid "" "INFO:demo:An INFO message\n" "DEBUG:demo:A DEBUG message" @@ -5346,13 +5400,13 @@ msgstr "" "INFO:demo:An INFO message\n" "DEBUG:demo:A DEBUG message" -#: ../../howto/logging-cookbook.rst:3989 +#: ../../howto/logging-cookbook.rst:3984 msgid "" "You could also use ``LoggerWriter`` to redirect ``sys.stdout`` and ``sys." "stderr`` by doing something like this:" msgstr "" -#: ../../howto/logging-cookbook.rst:3992 +#: ../../howto/logging-cookbook.rst:3987 msgid "" "import sys\n" "\n" @@ -5364,7 +5418,7 @@ msgstr "" "sys.stdout = LoggerWriter(logger, logging.INFO)\n" "sys.stderr = LoggerWriter(logger, logging.WARNING)" -#: ../../howto/logging-cookbook.rst:3999 +#: ../../howto/logging-cookbook.rst:3994 msgid "" "You should do this *after* configuring logging for your needs. In the above " "example, the :func:`~logging.basicConfig` call does this (using the ``sys." @@ -5372,7 +5426,7 @@ msgid "" "Then, you'd get this kind of result:" msgstr "" -#: ../../howto/logging-cookbook.rst:4004 +#: ../../howto/logging-cookbook.rst:3999 msgid "" ">>> print('Foo')\n" "INFO:demo:Foo\n" @@ -5386,21 +5440,21 @@ msgstr "" "WARNING:demo:Bar\n" ">>>" -#: ../../howto/logging-cookbook.rst:4012 +#: ../../howto/logging-cookbook.rst:4007 msgid "" "Of course, the examples above show output according to the format used by :" "func:`~logging.basicConfig`, but you can use a different formatter when you " "configure logging." msgstr "" -#: ../../howto/logging-cookbook.rst:4016 +#: ../../howto/logging-cookbook.rst:4011 msgid "" "Note that with the above scheme, you are somewhat at the mercy of buffering " "and the sequence of write calls which you are intercepting. For example, " "with the definition of ``LoggerWriter`` above, if you have the snippet" msgstr "" -#: ../../howto/logging-cookbook.rst:4020 +#: ../../howto/logging-cookbook.rst:4015 msgid "" "sys.stderr = LoggerWriter(logger, logging.WARNING)\n" "1 / 0" @@ -5408,11 +5462,11 @@ msgstr "" "sys.stderr = LoggerWriter(logger, logging.WARNING)\n" "1 / 0" -#: ../../howto/logging-cookbook.rst:4025 +#: ../../howto/logging-cookbook.rst:4020 msgid "then running the script results in" msgstr "" -#: ../../howto/logging-cookbook.rst:4027 +#: ../../howto/logging-cookbook.rst:4022 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "\n" @@ -5446,7 +5500,7 @@ msgstr "" "WARNING:demo::\n" "WARNING:demo:division by zero" -#: ../../howto/logging-cookbook.rst:4043 +#: ../../howto/logging-cookbook.rst:4038 msgid "" "As you can see, this output isn't ideal. That's because the underlying code " "which writes to ``sys.stderr`` makes multiple writes, each of which results " @@ -5456,7 +5510,7 @@ msgid "" "``LoggerWriter``:" msgstr "" -#: ../../howto/logging-cookbook.rst:4049 +#: ../../howto/logging-cookbook.rst:4044 msgid "" "class BufferingLoggerWriter(LoggerWriter):\n" " def __init__(self, logger, level):\n" @@ -5492,13 +5546,13 @@ msgstr "" " for part in parts:\n" " self.logger.log(self.level, part)" -#: ../../howto/logging-cookbook.rst:4068 +#: ../../howto/logging-cookbook.rst:4063 msgid "" "This just buffers up stuff until a newline is seen, and then logs complete " "lines. With this approach, you get better output:" msgstr "" -#: ../../howto/logging-cookbook.rst:4071 +#: ../../howto/logging-cookbook.rst:4066 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 55, " @@ -5518,11 +5572,11 @@ msgstr "" "WARNING:demo: 1/0\n" "WARNING:demo:ZeroDivisionError: division by zero" -#: ../../howto/logging-cookbook.rst:4081 +#: ../../howto/logging-cookbook.rst:4076 msgid "How to uniformly handle newlines in logging output" msgstr "" -#: ../../howto/logging-cookbook.rst:4083 +#: ../../howto/logging-cookbook.rst:4078 msgid "" "Usually, messages that are logged (say to console or file) consist of a " "single line of text. However, sometimes there is a need to handle messages " @@ -5533,7 +5587,7 @@ msgid "" "handler mixin, as in the following snippet:" msgstr "" -#: ../../howto/logging-cookbook.rst:4091 +#: ../../howto/logging-cookbook.rst:4086 msgid "" "# Assume this is in a module mymixins.py\n" "import copy\n" @@ -5552,11 +5606,11 @@ msgid "" " super().emit(rec)" msgstr "" -#: ../../howto/logging-cookbook.rst:4109 +#: ../../howto/logging-cookbook.rst:4104 msgid "You can use the mixin as in the following script:" msgstr "" -#: ../../howto/logging-cookbook.rst:4111 +#: ../../howto/logging-cookbook.rst:4106 msgid "" "import logging\n" "\n" @@ -5596,11 +5650,11 @@ msgstr "" " logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " "again')" -#: ../../howto/logging-cookbook.rst:4130 +#: ../../howto/logging-cookbook.rst:4125 msgid "The script, when run, prints something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:4132 +#: ../../howto/logging-cookbook.rst:4127 msgid "" "2025-07-02 13:54:47,234 DEBUG Single line\n" "2025-07-02 13:54:47,234 DEBUG Multiple lines:\n" @@ -5618,14 +5672,14 @@ msgstr "" "2025-07-02 13:54:47,234 DEBUG fool me ...\n" "2025-07-02 13:54:47,234 DEBUG can't get fooled again" -#: ../../howto/logging-cookbook.rst:4142 +#: ../../howto/logging-cookbook.rst:4137 msgid "" "If, on the other hand, you are concerned about `log injection `_, you can use a formatter which " "escapes newlines, as per the following example:" msgstr "" -#: ../../howto/logging-cookbook.rst:4146 +#: ../../howto/logging-cookbook.rst:4141 msgid "" "import logging\n" "\n" @@ -5667,13 +5721,13 @@ msgstr "" " logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " "again')" -#: ../../howto/logging-cookbook.rst:4166 +#: ../../howto/logging-cookbook.rst:4161 msgid "" "You can, of course, use whatever escaping scheme makes the most sense for " "you. The script, when run, should produce output like this:" msgstr "" -#: ../../howto/logging-cookbook.rst:4169 +#: ../../howto/logging-cookbook.rst:4164 msgid "" "2025-07-09 06:47:33,783 DEBUG Single line\n" "2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me once ...\n" @@ -5687,17 +5741,17 @@ msgstr "" "2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me ...\\ncan't get " "fooled again" -#: ../../howto/logging-cookbook.rst:4176 +#: ../../howto/logging-cookbook.rst:4171 msgid "" "Escaping behaviour can't be the stdlib default , as it would break backwards " "compatibility." msgstr "" -#: ../../howto/logging-cookbook.rst:4182 +#: ../../howto/logging-cookbook.rst:4177 msgid "Patterns to avoid" msgstr "" -#: ../../howto/logging-cookbook.rst:4184 +#: ../../howto/logging-cookbook.rst:4179 msgid "" "Although the preceding sections have described ways of doing things you " "might need to do or deal with, it is worth mentioning some usage patterns " @@ -5705,11 +5759,11 @@ msgid "" "The following sections are in no particular order." msgstr "" -#: ../../howto/logging-cookbook.rst:4190 +#: ../../howto/logging-cookbook.rst:4185 msgid "Opening the same log file multiple times" msgstr "" -#: ../../howto/logging-cookbook.rst:4192 +#: ../../howto/logging-cookbook.rst:4187 msgid "" "On Windows, you will generally not be able to open the same file multiple " "times as this will lead to a \"file is in use by another process\" error. " @@ -5717,32 +5771,32 @@ msgid "" "file multiple times. This could be done accidentally, for example by:" msgstr "" -#: ../../howto/logging-cookbook.rst:4197 +#: ../../howto/logging-cookbook.rst:4192 msgid "" "Adding a file handler more than once which references the same file (e.g. by " "a copy/paste/forget-to-change error)." msgstr "" -#: ../../howto/logging-cookbook.rst:4200 +#: ../../howto/logging-cookbook.rst:4195 msgid "" "Opening two files that look different, as they have different names, but are " "the same because one is a symbolic link to the other." msgstr "" -#: ../../howto/logging-cookbook.rst:4203 +#: ../../howto/logging-cookbook.rst:4198 msgid "" "Forking a process, following which both parent and child have a reference to " "the same file. This might be through use of the :mod:`multiprocessing` " "module, for example." msgstr "" -#: ../../howto/logging-cookbook.rst:4207 +#: ../../howto/logging-cookbook.rst:4202 msgid "" "Opening a file multiple times might *appear* to work most of the time, but " "can lead to a number of problems in practice:" msgstr "" -#: ../../howto/logging-cookbook.rst:4210 +#: ../../howto/logging-cookbook.rst:4205 msgid "" "Logging output can be garbled because multiple threads or processes try to " "write to the same file. Although logging guards against concurrent use of " @@ -5751,7 +5805,7 @@ msgid "" "different handler instances which happen to point to the same file." msgstr "" -#: ../../howto/logging-cookbook.rst:4216 +#: ../../howto/logging-cookbook.rst:4211 msgid "" "An attempt to delete a file (e.g. during file rotation) silently fails, " "because there is another reference pointing to it. This can lead to " @@ -5761,17 +5815,17 @@ msgid "" "being supposedly in place." msgstr "" -#: ../../howto/logging-cookbook.rst:4223 +#: ../../howto/logging-cookbook.rst:4218 msgid "" "Use the techniques outlined in :ref:`multiple-processes` to circumvent such " "issues." msgstr "" -#: ../../howto/logging-cookbook.rst:4227 +#: ../../howto/logging-cookbook.rst:4222 msgid "Using loggers as attributes in a class or passing them as parameters" msgstr "" -#: ../../howto/logging-cookbook.rst:4229 +#: ../../howto/logging-cookbook.rst:4224 msgid "" "While there might be unusual cases where you'll need to do this, in general " "there is no point because loggers are singletons. Code can always access a " @@ -5782,13 +5836,13 @@ msgid "" "module (and not the class) is the unit of software decomposition." msgstr "" -#: ../../howto/logging-cookbook.rst:4238 +#: ../../howto/logging-cookbook.rst:4233 msgid "" "Adding handlers other than :class:`~logging.NullHandler` to a logger in a " "library" msgstr "" -#: ../../howto/logging-cookbook.rst:4240 +#: ../../howto/logging-cookbook.rst:4235 msgid "" "Configuring logging by adding handlers, formatters and filters is the " "responsibility of the application developer, not the library developer. If " @@ -5796,11 +5850,11 @@ msgid "" "your loggers other than a :class:`~logging.NullHandler` instance." msgstr "" -#: ../../howto/logging-cookbook.rst:4246 +#: ../../howto/logging-cookbook.rst:4241 msgid "Creating a lot of loggers" msgstr "" -#: ../../howto/logging-cookbook.rst:4248 +#: ../../howto/logging-cookbook.rst:4243 msgid "" "Loggers are singletons that are never freed during a script execution, and " "so creating lots of loggers will use up memory which can't then be freed. " @@ -5811,38 +5865,44 @@ msgid "" "occasionally slightly more fine-grained than that)." msgstr "" -#: ../../howto/logging-cookbook.rst:4259 +#: ../../howto/logging-cookbook.rst:4254 msgid "Other resources" msgstr "其他資源" -#: ../../howto/logging-cookbook.rst:4263 +#: ../../howto/logging-cookbook.rst:4258 msgid "Module :mod:`logging`" msgstr ":mod:`logging` 模組" -#: ../../howto/logging-cookbook.rst:4264 +#: ../../howto/logging-cookbook.rst:4259 msgid "API reference for the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4266 +#: ../../howto/logging-cookbook.rst:4261 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` 模組" -#: ../../howto/logging-cookbook.rst:4267 +#: ../../howto/logging-cookbook.rst:4262 msgid "Configuration API for the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4269 +#: ../../howto/logging-cookbook.rst:4264 msgid "Module :mod:`logging.handlers`" msgstr ":mod:`logging.handlers` 模組" -#: ../../howto/logging-cookbook.rst:4270 +#: ../../howto/logging-cookbook.rst:4265 msgid "Useful handlers included with the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4272 +#: ../../howto/logging-cookbook.rst:4267 msgid ":ref:`Basic Tutorial `" msgstr ":ref:`基礎教學 `" -#: ../../howto/logging-cookbook.rst:4274 +#: ../../howto/logging-cookbook.rst:4269 msgid ":ref:`Advanced Tutorial `" msgstr ":ref:`進階教學 `" + +#~ msgid "Author" +#~ msgstr "作者" + +#~ msgid "Vinay Sajip " +#~ msgstr "Vinay Sajip " diff --git a/howto/logging.po b/howto/logging.po index d22ef0a2b32..a72b5943f2b 100644 --- a/howto/logging.po +++ b/howto/logging.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-06 00:23+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,25 +22,17 @@ msgstr "" msgid "Logging HOWTO" msgstr "如何使用 Logging 模組" -#: ../../howto/logging.rst:0 -msgid "Author" -msgstr "作者" - -#: ../../howto/logging.rst:7 -msgid "Vinay Sajip " -msgstr "Vinay Sajip " - -#: ../../howto/logging.rst:13 +#: ../../howto/logging.rst:11 msgid "" "This page contains tutorial information. For links to reference information " "and a logging cookbook, please see :ref:`tutorial-ref-links`." msgstr "" -#: ../../howto/logging.rst:17 +#: ../../howto/logging.rst:15 msgid "Basic Logging Tutorial" msgstr "基礎 Logging 指南" -#: ../../howto/logging.rst:19 +#: ../../howto/logging.rst:17 msgid "" "Logging is a means of tracking events that happen when some software runs. " "The software's developer adds logging calls to their code to indicate that " @@ -55,11 +47,11 @@ msgstr "" "述。這段訊息可能包含一些因為此事件發生而改變的資料。開發者也可以指派事件的重" "要程度,重要程度有時候也會被稱作 *程度* 或是 *嚴重性* 。" -#: ../../howto/logging.rst:28 +#: ../../howto/logging.rst:26 msgid "When to use logging" msgstr "什麼時候使用 logging" -#: ../../howto/logging.rst:30 +#: ../../howto/logging.rst:28 msgid "" "You can access logging functionality by creating a logger via ``logger = " "logging.getLogger(__name__)``, and then calling the logger's :meth:`~Logger." @@ -69,158 +61,158 @@ msgid "" "each of a set of common tasks, the best tool to use for that task." msgstr "" -#: ../../howto/logging.rst:38 +#: ../../howto/logging.rst:36 msgid "Task you want to perform" msgstr "" -#: ../../howto/logging.rst:38 +#: ../../howto/logging.rst:36 msgid "The best tool for the task" msgstr "" -#: ../../howto/logging.rst:40 +#: ../../howto/logging.rst:38 msgid "" "Display console output for ordinary usage of a command line script or program" msgstr "" -#: ../../howto/logging.rst:40 +#: ../../howto/logging.rst:38 msgid ":func:`print`" msgstr ":func:`print`" -#: ../../howto/logging.rst:44 +#: ../../howto/logging.rst:42 msgid "" "Report events that occur during normal operation of a program (e.g. for " "status monitoring or fault investigation)" msgstr "" -#: ../../howto/logging.rst:44 +#: ../../howto/logging.rst:42 msgid "" "A logger's :meth:`~Logger.info` (or :meth:`~Logger.debug` method for very " "detailed output for diagnostic purposes)" msgstr "" -#: ../../howto/logging.rst:49 +#: ../../howto/logging.rst:47 msgid "Issue a warning regarding a particular runtime event" msgstr "" -#: ../../howto/logging.rst:49 +#: ../../howto/logging.rst:47 msgid "" ":func:`warnings.warn` in library code if the issue is avoidable and the " "client application should be modified to eliminate the warning" msgstr "" -#: ../../howto/logging.rst:54 +#: ../../howto/logging.rst:52 msgid "" "A logger's :meth:`~Logger.warning` method if there is nothing the client " "application can do about the situation, but the event should still be noted" msgstr "" -#: ../../howto/logging.rst:60 +#: ../../howto/logging.rst:58 msgid "Report an error regarding a particular runtime event" msgstr "" -#: ../../howto/logging.rst:60 +#: ../../howto/logging.rst:58 msgid "Raise an exception" msgstr "引發一個例外" -#: ../../howto/logging.rst:63 +#: ../../howto/logging.rst:61 msgid "" "Report suppression of an error without raising an exception (e.g. error " "handler in a long-running server process)" msgstr "" -#: ../../howto/logging.rst:63 +#: ../../howto/logging.rst:61 msgid "" "A logger's :meth:`~Logger.error`, :meth:`~Logger.exception` or :meth:" "`~Logger.critical` method as appropriate for the specific error and " "application domain" msgstr "" -#: ../../howto/logging.rst:70 +#: ../../howto/logging.rst:68 msgid "" "The logger methods are named after the level or severity of the events they " "are used to track. The standard levels and their applicability are described " "below (in increasing order of severity):" msgstr "" -#: ../../howto/logging.rst:77 ../../howto/logging.rst:875 +#: ../../howto/logging.rst:75 ../../howto/logging.rst:873 msgid "Level" msgstr "" -#: ../../howto/logging.rst:77 +#: ../../howto/logging.rst:75 msgid "When it's used" msgstr "" -#: ../../howto/logging.rst:79 ../../howto/logging.rst:885 +#: ../../howto/logging.rst:77 ../../howto/logging.rst:883 msgid "``DEBUG``" msgstr "``DEBUG``" -#: ../../howto/logging.rst:79 +#: ../../howto/logging.rst:77 msgid "" "Detailed information, typically of interest only when diagnosing problems." msgstr "" -#: ../../howto/logging.rst:82 ../../howto/logging.rst:883 +#: ../../howto/logging.rst:80 ../../howto/logging.rst:881 msgid "``INFO``" msgstr "``INFO``" -#: ../../howto/logging.rst:82 +#: ../../howto/logging.rst:80 msgid "Confirmation that things are working as expected." msgstr "" -#: ../../howto/logging.rst:85 ../../howto/logging.rst:881 +#: ../../howto/logging.rst:83 ../../howto/logging.rst:879 msgid "``WARNING``" msgstr "``WARNING``" -#: ../../howto/logging.rst:85 +#: ../../howto/logging.rst:83 msgid "" "An indication that something unexpected happened, or indicative of some " "problem in the near future (e.g. 'disk space low'). The software is still " "working as expected." msgstr "" -#: ../../howto/logging.rst:90 ../../howto/logging.rst:879 +#: ../../howto/logging.rst:88 ../../howto/logging.rst:877 msgid "``ERROR``" msgstr "``ERROR``" -#: ../../howto/logging.rst:90 +#: ../../howto/logging.rst:88 msgid "" "Due to a more serious problem, the software has not been able to perform " "some function." msgstr "" -#: ../../howto/logging.rst:93 ../../howto/logging.rst:877 +#: ../../howto/logging.rst:91 ../../howto/logging.rst:875 msgid "``CRITICAL``" msgstr "``CRITICAL``" -#: ../../howto/logging.rst:93 +#: ../../howto/logging.rst:91 msgid "" "A serious error, indicating that the program itself may be unable to " "continue running." msgstr "" -#: ../../howto/logging.rst:97 +#: ../../howto/logging.rst:95 msgid "" "The default level is ``WARNING``, which means that only events of this " "severity and higher will be tracked, unless the logging package is " "configured to do otherwise." msgstr "" -#: ../../howto/logging.rst:100 +#: ../../howto/logging.rst:98 msgid "" "Events that are tracked can be handled in different ways. The simplest way " "of handling tracked events is to print them to the console. Another common " "way is to write them to a disk file." msgstr "" -#: ../../howto/logging.rst:108 +#: ../../howto/logging.rst:106 msgid "A simple example" msgstr "一個簡單範例" -#: ../../howto/logging.rst:110 +#: ../../howto/logging.rst:108 msgid "A very simple example is::" msgstr "一個非常簡單的例子是: ::" -#: ../../howto/logging.rst:112 +#: ../../howto/logging.rst:110 msgid "" "import logging\n" "logging.warning('Watch out!') # will print a message to the console\n" @@ -230,15 +222,15 @@ msgstr "" "logging.warning('Watch out!') # 將會印出訊息至控制台\n" "logging.info('I told you so') # 不會印出任何東西" -#: ../../howto/logging.rst:116 +#: ../../howto/logging.rst:114 msgid "If you type these lines into a script and run it, you'll see:" msgstr "" -#: ../../howto/logging.rst:118 +#: ../../howto/logging.rst:116 msgid "WARNING:root:Watch out!" msgstr "WARNING:root:Watch out!" -#: ../../howto/logging.rst:122 +#: ../../howto/logging.rst:120 msgid "" "printed out on the console. The ``INFO`` message doesn't appear because the " "default level is ``WARNING``. The printed message includes the indication of " @@ -247,7 +239,7 @@ msgid "" "need that; formatting options will also be explained later." msgstr "" -#: ../../howto/logging.rst:128 +#: ../../howto/logging.rst:126 msgid "" "Notice that in this example, we use functions directly on the ``logging`` " "module, like ``logging.debug``, rather than creating a logger and calling " @@ -259,11 +251,11 @@ msgid "" "methods." msgstr "" -#: ../../howto/logging.rst:137 +#: ../../howto/logging.rst:135 msgid "Logging to a file" msgstr "" -#: ../../howto/logging.rst:139 +#: ../../howto/logging.rst:137 msgid "" "A very common situation is that of recording logging events in a file, so " "let's look at that next. Be sure to try the following in a newly started " @@ -271,7 +263,7 @@ msgid "" "above::" msgstr "" -#: ../../howto/logging.rst:143 +#: ../../howto/logging.rst:141 msgid "" "import logging\n" "logger = logging.getLogger(__name__)\n" @@ -291,7 +283,7 @@ msgstr "" "logger.warning('And this, too')\n" "logger.error('And non-ASCII stuff, too, like Øresund and Malmö')" -#: ../../howto/logging.rst:151 +#: ../../howto/logging.rst:149 msgid "" "The *encoding* argument was added. In earlier Python versions, or if not " "specified, the encoding used is the default value used by :func:`open`. " @@ -300,13 +292,13 @@ msgid "" "values and the default, see the documentation for :func:`open`." msgstr "" -#: ../../howto/logging.rst:158 +#: ../../howto/logging.rst:156 msgid "" "And now if we open the file and look at what we have, we should find the log " "messages:" msgstr "" -#: ../../howto/logging.rst:161 +#: ../../howto/logging.rst:159 msgid "" "DEBUG:__main__:This message should go to the log file\n" "INFO:__main__:So should this\n" @@ -314,40 +306,40 @@ msgid "" "ERROR:__main__:And non-ASCII stuff, too, like Øresund and Malmö" msgstr "" -#: ../../howto/logging.rst:168 +#: ../../howto/logging.rst:166 msgid "" "This example also shows how you can set the logging level which acts as the " "threshold for tracking. In this case, because we set the threshold to " "``DEBUG``, all of the messages were printed." msgstr "" -#: ../../howto/logging.rst:172 +#: ../../howto/logging.rst:170 msgid "" "If you want to set the logging level from a command-line option such as:" msgstr "" -#: ../../howto/logging.rst:174 +#: ../../howto/logging.rst:172 msgid "--log=INFO" msgstr "--log=INFO" -#: ../../howto/logging.rst:178 +#: ../../howto/logging.rst:176 msgid "" "and you have the value of the parameter passed for ``--log`` in some " "variable *loglevel*, you can use::" msgstr "" -#: ../../howto/logging.rst:181 +#: ../../howto/logging.rst:179 msgid "getattr(logging, loglevel.upper())" msgstr "getattr(logging, loglevel.upper())" -#: ../../howto/logging.rst:183 +#: ../../howto/logging.rst:181 msgid "" "to get the value which you'll pass to :func:`basicConfig` via the *level* " "argument. You may want to error check any user input value, perhaps as in " "the following example::" msgstr "" -#: ../../howto/logging.rst:187 +#: ../../howto/logging.rst:185 msgid "" "# assuming loglevel is bound to the string value obtained from the\n" "# command line argument. Convert to upper case to allow the user to\n" @@ -358,14 +350,14 @@ msgid "" "logging.basicConfig(level=numeric_level, ...)" msgstr "" -#: ../../howto/logging.rst:195 +#: ../../howto/logging.rst:193 msgid "" "The call to :func:`basicConfig` should come *before* any calls to a logger's " "methods such as :meth:`~Logger.debug`, :meth:`~Logger.info`, etc. Otherwise, " "that logging event may not be handled in the desired manner." msgstr "" -#: ../../howto/logging.rst:199 +#: ../../howto/logging.rst:197 msgid "" "If you run the above script several times, the messages from successive runs " "are appended to the file *example.log*. If you want each run to start " @@ -373,7 +365,7 @@ msgid "" "*filemode* argument, by changing the call in the above example to::" msgstr "" -#: ../../howto/logging.rst:204 +#: ../../howto/logging.rst:202 msgid "" "logging.basicConfig(filename='example.log', filemode='w', level=logging." "DEBUG)" @@ -381,23 +373,23 @@ msgstr "" "logging.basicConfig(filename='example.log', filemode='w', level=logging." "DEBUG)" -#: ../../howto/logging.rst:206 +#: ../../howto/logging.rst:204 msgid "" "The output will be the same as before, but the log file is no longer " "appended to, so the messages from earlier runs are lost." msgstr "" -#: ../../howto/logging.rst:211 +#: ../../howto/logging.rst:209 msgid "Logging variable data" msgstr "" -#: ../../howto/logging.rst:213 +#: ../../howto/logging.rst:211 msgid "" "To log variable data, use a format string for the event description message " "and append the variable data as arguments. For example::" msgstr "" -#: ../../howto/logging.rst:216 +#: ../../howto/logging.rst:214 msgid "" "import logging\n" "logging.warning('%s before you %s', 'Look', 'leap!')" @@ -405,15 +397,15 @@ msgstr "" "import logging\n" "logging.warning('%s before you %s', 'Look', 'leap!')" -#: ../../howto/logging.rst:219 +#: ../../howto/logging.rst:217 msgid "will display:" msgstr "" -#: ../../howto/logging.rst:221 +#: ../../howto/logging.rst:219 msgid "WARNING:root:Look before you leap!" msgstr "WARNING:root:Look before you leap!" -#: ../../howto/logging.rst:225 +#: ../../howto/logging.rst:223 msgid "" "As you can see, merging of variable data into the event description message " "uses the old, %-style of string formatting. This is for backwards " @@ -423,17 +415,17 @@ msgid "" "tutorial: see :ref:`formatting-styles` for more information." msgstr "" -#: ../../howto/logging.rst:234 +#: ../../howto/logging.rst:232 msgid "Changing the format of displayed messages" msgstr "" -#: ../../howto/logging.rst:236 +#: ../../howto/logging.rst:234 msgid "" "To change the format which is used to display messages, you need to specify " "the format you want to use::" msgstr "" -#: ../../howto/logging.rst:239 +#: ../../howto/logging.rst:237 msgid "" "import logging\n" "logging.basicConfig(format='%(levelname)s:%(message)s', level=logging." @@ -449,18 +441,18 @@ msgstr "" "logging.info('So should this')\n" "logging.warning('And this, too')" -#: ../../howto/logging.rst:245 +#: ../../howto/logging.rst:243 msgid "which would print:" msgstr "" -#: ../../howto/logging.rst:247 +#: ../../howto/logging.rst:245 msgid "" "DEBUG:This message should appear on the console\n" "INFO:So should this\n" "WARNING:And this, too" msgstr "" -#: ../../howto/logging.rst:253 +#: ../../howto/logging.rst:251 msgid "" "Notice that the 'root' which appeared in earlier examples has disappeared. " "For a full set of things that can appear in format strings, you can refer to " @@ -470,17 +462,17 @@ msgid "" "This is described in the next section." msgstr "" -#: ../../howto/logging.rst:262 +#: ../../howto/logging.rst:260 msgid "Displaying the date/time in messages" msgstr "" -#: ../../howto/logging.rst:264 +#: ../../howto/logging.rst:262 msgid "" "To display the date and time of an event, you would place '%(asctime)s' in " "your format string::" msgstr "" -#: ../../howto/logging.rst:267 +#: ../../howto/logging.rst:265 msgid "" "import logging\n" "logging.basicConfig(format='%(asctime)s %(message)s')\n" @@ -490,22 +482,22 @@ msgstr "" "logging.basicConfig(format='%(asctime)s %(message)s')\n" "logging.warning('is when this event was logged.')" -#: ../../howto/logging.rst:271 +#: ../../howto/logging.rst:269 msgid "which should print something like this:" msgstr "" -#: ../../howto/logging.rst:273 +#: ../../howto/logging.rst:271 msgid "2010-12-12 11:41:42,612 is when this event was logged." msgstr "" -#: ../../howto/logging.rst:277 +#: ../../howto/logging.rst:275 msgid "" "The default format for date/time display (shown above) is like ISO8601 or :" "rfc:`3339`. If you need more control over the formatting of the date/time, " "provide a *datefmt* argument to ``basicConfig``, as in this example::" msgstr "" -#: ../../howto/logging.rst:281 +#: ../../howto/logging.rst:279 msgid "" "import logging\n" "logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:" @@ -517,25 +509,25 @@ msgstr "" "%M:%S %p')\n" "logging.warning('is when this event was logged.')" -#: ../../howto/logging.rst:285 +#: ../../howto/logging.rst:283 msgid "which would display something like this:" msgstr "" -#: ../../howto/logging.rst:287 +#: ../../howto/logging.rst:285 msgid "12/12/2010 11:46:36 AM is when this event was logged." msgstr "" -#: ../../howto/logging.rst:291 +#: ../../howto/logging.rst:289 msgid "" "The format of the *datefmt* argument is the same as supported by :func:`time." "strftime`." msgstr "" -#: ../../howto/logging.rst:296 +#: ../../howto/logging.rst:294 msgid "Next Steps" msgstr "" -#: ../../howto/logging.rst:298 +#: ../../howto/logging.rst:296 msgid "" "That concludes the basic tutorial. It should be enough to get you up and " "running with logging. There's a lot more that the logging package offers, " @@ -544,7 +536,7 @@ msgid "" "of your favourite beverage and carry on." msgstr "" -#: ../../howto/logging.rst:304 +#: ../../howto/logging.rst:302 msgid "" "If your logging needs are simple, then use the above examples to incorporate " "logging into your own scripts, and if you run into problems or don't " @@ -553,50 +545,50 @@ msgid "" "should receive help before too long." msgstr "" -#: ../../howto/logging.rst:310 +#: ../../howto/logging.rst:308 msgid "" "Still here? You can carry on reading the next few sections, which provide a " "slightly more advanced/in-depth tutorial than the basic one above. After " "that, you can take a look at the :ref:`logging-cookbook`." msgstr "" -#: ../../howto/logging.rst:318 +#: ../../howto/logging.rst:316 msgid "Advanced Logging Tutorial" msgstr "" -#: ../../howto/logging.rst:320 +#: ../../howto/logging.rst:318 msgid "" "The logging library takes a modular approach and offers several categories " "of components: loggers, handlers, filters, and formatters." msgstr "" -#: ../../howto/logging.rst:323 +#: ../../howto/logging.rst:321 msgid "Loggers expose the interface that application code directly uses." msgstr "" -#: ../../howto/logging.rst:324 +#: ../../howto/logging.rst:322 msgid "" "Handlers send the log records (created by loggers) to the appropriate " "destination." msgstr "" -#: ../../howto/logging.rst:326 +#: ../../howto/logging.rst:324 msgid "" "Filters provide a finer grained facility for determining which log records " "to output." msgstr "" -#: ../../howto/logging.rst:328 +#: ../../howto/logging.rst:326 msgid "Formatters specify the layout of log records in the final output." msgstr "" -#: ../../howto/logging.rst:330 +#: ../../howto/logging.rst:328 msgid "" "Log event information is passed between loggers, handlers, filters and " "formatters in a :class:`LogRecord` instance." msgstr "" -#: ../../howto/logging.rst:333 +#: ../../howto/logging.rst:331 msgid "" "Logging is performed by calling methods on instances of the :class:`Logger` " "class (hereafter called :dfn:`loggers`). Each instance has a name, and they " @@ -607,23 +599,23 @@ msgid "" "originates." msgstr "" -#: ../../howto/logging.rst:340 +#: ../../howto/logging.rst:338 msgid "" "A good convention to use when naming loggers is to use a module-level " "logger, in each module which uses logging, named as follows::" msgstr "" -#: ../../howto/logging.rst:343 +#: ../../howto/logging.rst:341 msgid "logger = logging.getLogger(__name__)" msgstr "logger = logging.getLogger(__name__)" -#: ../../howto/logging.rst:345 +#: ../../howto/logging.rst:343 msgid "" "This means that logger names track the package/module hierarchy, and it's " "intuitively obvious where events are logged just from the logger name." msgstr "" -#: ../../howto/logging.rst:348 +#: ../../howto/logging.rst:346 msgid "" "The root of the hierarchy of loggers is called the root logger. That's the " "logger used by the functions :func:`debug`, :func:`info`, :func:`warning`, :" @@ -632,7 +624,7 @@ msgid "" "root logger's name is printed as 'root' in the logged output." msgstr "" -#: ../../howto/logging.rst:354 +#: ../../howto/logging.rst:352 msgid "" "It is, of course, possible to log messages to different destinations. " "Support is included in the package for writing log messages to files, HTTP " @@ -643,7 +635,7 @@ msgid "" "built-in handler classes." msgstr "" -#: ../../howto/logging.rst:361 +#: ../../howto/logging.rst:359 msgid "" "By default, no destination is set for any logging messages. You can specify " "a destination (such as console or file) by using :func:`basicConfig` as in " @@ -655,36 +647,36 @@ msgid "" "message output." msgstr "" -#: ../../howto/logging.rst:369 +#: ../../howto/logging.rst:367 msgid "The default format set by :func:`basicConfig` for messages is:" msgstr "" -#: ../../howto/logging.rst:371 +#: ../../howto/logging.rst:369 msgid "severity:logger name:message" msgstr "severity:logger name:message" -#: ../../howto/logging.rst:375 +#: ../../howto/logging.rst:373 msgid "" "You can change this by passing a format string to :func:`basicConfig` with " "the *format* keyword argument. For all options regarding how a format string " "is constructed, see :ref:`formatter-objects`." msgstr "" -#: ../../howto/logging.rst:380 +#: ../../howto/logging.rst:378 msgid "Logging Flow" msgstr "" -#: ../../howto/logging.rst:382 +#: ../../howto/logging.rst:380 msgid "" "The flow of log event information in loggers and handlers is illustrated in " "the following diagram." msgstr "" -#: ../../howto/logging.rst:433 +#: ../../howto/logging.rst:431 msgid "Loggers" msgstr "" -#: ../../howto/logging.rst:435 +#: ../../howto/logging.rst:433 msgid "" ":class:`Logger` objects have a threefold job. First, they expose several " "methods to application code so that applications can log messages at " @@ -694,17 +686,17 @@ msgid "" "handlers." msgstr "" -#: ../../howto/logging.rst:441 +#: ../../howto/logging.rst:439 msgid "" "The most widely used methods on logger objects fall into two categories: " "configuration and message sending." msgstr "" -#: ../../howto/logging.rst:444 +#: ../../howto/logging.rst:442 msgid "These are the most common configuration methods:" msgstr "" -#: ../../howto/logging.rst:446 +#: ../../howto/logging.rst:444 msgid "" ":meth:`Logger.setLevel` specifies the lowest-severity log message a logger " "will handle, where debug is the lowest built-in severity level and critical " @@ -713,32 +705,32 @@ msgid "" "messages and will ignore DEBUG messages." msgstr "" -#: ../../howto/logging.rst:452 +#: ../../howto/logging.rst:450 msgid "" ":meth:`Logger.addHandler` and :meth:`Logger.removeHandler` add and remove " "handler objects from the logger object. Handlers are covered in more detail " "in :ref:`handler-basic`." msgstr "" -#: ../../howto/logging.rst:456 +#: ../../howto/logging.rst:454 msgid "" ":meth:`Logger.addFilter` and :meth:`Logger.removeFilter` add and remove " "filter objects from the logger object. Filters are covered in more detail " "in :ref:`filter`." msgstr "" -#: ../../howto/logging.rst:460 +#: ../../howto/logging.rst:458 msgid "" "You don't need to always call these methods on every logger you create. See " "the last two paragraphs in this section." msgstr "" -#: ../../howto/logging.rst:463 +#: ../../howto/logging.rst:461 msgid "" "With the logger object configured, the following methods create log messages:" msgstr "" -#: ../../howto/logging.rst:465 +#: ../../howto/logging.rst:463 msgid "" ":meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, :meth:" "`Logger.error`, and :meth:`Logger.critical` all create log records with a " @@ -751,14 +743,14 @@ msgid "" "exception information." msgstr "" -#: ../../howto/logging.rst:475 +#: ../../howto/logging.rst:473 msgid "" ":meth:`Logger.exception` creates a log message similar to :meth:`Logger." "error`. The difference is that :meth:`Logger.exception` dumps a stack trace " "along with it. Call this method only from an exception handler." msgstr "" -#: ../../howto/logging.rst:479 +#: ../../howto/logging.rst:477 msgid "" ":meth:`Logger.log` takes a log level as an explicit argument. This is a " "little more verbose for logging messages than using the log level " @@ -766,7 +758,7 @@ msgid "" "levels." msgstr "" -#: ../../howto/logging.rst:483 +#: ../../howto/logging.rst:481 msgid "" ":func:`getLogger` returns a reference to a logger instance with the " "specified name if it is provided, or ``root`` if not. The names are period-" @@ -778,7 +770,7 @@ msgid "" "descendants of ``foo``." msgstr "" -#: ../../howto/logging.rst:491 +#: ../../howto/logging.rst:489 msgid "" "Loggers have a concept of *effective level*. If a level is not explicitly " "set on a logger, the level of its parent is used instead as its effective " @@ -790,7 +782,7 @@ msgid "" "handlers." msgstr "" -#: ../../howto/logging.rst:499 +#: ../../howto/logging.rst:497 msgid "" "Child loggers propagate messages up to the handlers associated with their " "ancestor loggers. Because of this, it is unnecessary to define and configure " @@ -800,11 +792,11 @@ msgid "" "attribute of a logger to ``False``.)" msgstr "" -#: ../../howto/logging.rst:510 +#: ../../howto/logging.rst:508 msgid "Handlers" msgstr "" -#: ../../howto/logging.rst:512 +#: ../../howto/logging.rst:510 msgid "" ":class:`~logging.Handler` objects are responsible for dispatching the " "appropriate log messages (based on the log messages' severity) to the " @@ -817,14 +809,14 @@ msgid "" "of a specific severity to a specific location." msgstr "" -#: ../../howto/logging.rst:522 +#: ../../howto/logging.rst:520 msgid "" "The standard library includes quite a few handler types (see :ref:`useful-" "handlers`); the tutorials use mainly :class:`StreamHandler` and :class:" "`FileHandler` in its examples." msgstr "" -#: ../../howto/logging.rst:526 +#: ../../howto/logging.rst:524 msgid "" "There are very few methods in a handler for application developers to " "concern themselves with. The only handler methods that seem relevant for " @@ -832,7 +824,7 @@ msgid "" "not creating custom handlers) are the following configuration methods:" msgstr "" -#: ../../howto/logging.rst:531 +#: ../../howto/logging.rst:529 msgid "" "The :meth:`~Handler.setLevel` method, just as in logger objects, specifies " "the lowest severity that will be dispatched to the appropriate destination. " @@ -842,19 +834,19 @@ msgid "" "send on." msgstr "" -#: ../../howto/logging.rst:537 +#: ../../howto/logging.rst:535 msgid "" ":meth:`~Handler.setFormatter` selects a Formatter object for this handler to " "use." msgstr "" -#: ../../howto/logging.rst:540 +#: ../../howto/logging.rst:538 msgid "" ":meth:`~Handler.addFilter` and :meth:`~Handler.removeFilter` respectively " "configure and deconfigure filter objects on handlers." msgstr "" -#: ../../howto/logging.rst:543 +#: ../../howto/logging.rst:541 msgid "" "Application code should not directly instantiate and use instances of :class:" "`Handler`. Instead, the :class:`Handler` class is a base class that defines " @@ -862,11 +854,11 @@ msgid "" "behavior that child classes can use (or override)." msgstr "" -#: ../../howto/logging.rst:550 +#: ../../howto/logging.rst:548 msgid "Formatters" msgstr "" -#: ../../howto/logging.rst:552 +#: ../../howto/logging.rst:550 msgid "" "Formatter objects configure the final order, structure, and contents of the " "log message. Unlike the base :class:`logging.Handler` class, application " @@ -876,24 +868,24 @@ msgid "" "string and a style indicator." msgstr "" -#: ../../howto/logging.rst:561 +#: ../../howto/logging.rst:559 msgid "" "If there is no message format string, the default is to use the raw " "message. If there is no date format string, the default date format is:" msgstr "" -#: ../../howto/logging.rst:564 +#: ../../howto/logging.rst:562 msgid "%Y-%m-%d %H:%M:%S" msgstr "%Y-%m-%d %H:%M:%S" -#: ../../howto/logging.rst:568 +#: ../../howto/logging.rst:566 msgid "" "with the milliseconds tacked on at the end. The ``style`` is one of ``'%'``, " "``'{'``, or ``'$'``. If one of these is not specified, then ``'%'`` will be " "used." msgstr "" -#: ../../howto/logging.rst:571 +#: ../../howto/logging.rst:569 msgid "" "If the ``style`` is ``'%'``, the message format string uses ``%()s`` styled string substitution; the possible keys are documented in :" @@ -903,22 +895,22 @@ msgid "" "should conform to what is expected by :meth:`string.Template.substitute`." msgstr "" -#: ../../howto/logging.rst:578 +#: ../../howto/logging.rst:576 msgid "Added the ``style`` parameter." msgstr "新增 ``style`` 參數。" -#: ../../howto/logging.rst:581 +#: ../../howto/logging.rst:579 msgid "" "The following message format string will log the time in a human-readable " "format, the severity of the message, and the contents of the message, in " "that order::" msgstr "" -#: ../../howto/logging.rst:585 +#: ../../howto/logging.rst:583 msgid "'%(asctime)s - %(levelname)s - %(message)s'" msgstr "" -#: ../../howto/logging.rst:587 +#: ../../howto/logging.rst:585 msgid "" "Formatters use a user-configurable function to convert the creation time of " "a record to a tuple. By default, :func:`time.localtime` is used; to change " @@ -929,40 +921,40 @@ msgid "" "in the Formatter class (to ``time.gmtime`` for GMT display)." msgstr "" -#: ../../howto/logging.rst:597 +#: ../../howto/logging.rst:595 msgid "Configuring Logging" msgstr "" -#: ../../howto/logging.rst:601 +#: ../../howto/logging.rst:599 msgid "Programmers can configure logging in three ways:" msgstr "" -#: ../../howto/logging.rst:603 +#: ../../howto/logging.rst:601 msgid "" "Creating loggers, handlers, and formatters explicitly using Python code that " "calls the configuration methods listed above." msgstr "" -#: ../../howto/logging.rst:605 +#: ../../howto/logging.rst:603 msgid "" "Creating a logging config file and reading it using the :func:`fileConfig` " "function." msgstr "" -#: ../../howto/logging.rst:607 +#: ../../howto/logging.rst:605 msgid "" "Creating a dictionary of configuration information and passing it to the :" "func:`dictConfig` function." msgstr "" -#: ../../howto/logging.rst:610 +#: ../../howto/logging.rst:608 msgid "" "For the reference documentation on the last two options, see :ref:`logging-" "config-api`. The following example configures a very simple logger, a " "console handler, and a simple formatter using Python code::" msgstr "" -#: ../../howto/logging.rst:614 +#: ../../howto/logging.rst:612 msgid "" "import logging\n" "\n" @@ -992,12 +984,12 @@ msgid "" "logger.critical('critical message')" msgstr "" -#: ../../howto/logging.rst:640 +#: ../../howto/logging.rst:638 msgid "" "Running this module from the command line produces the following output:" msgstr "" -#: ../../howto/logging.rst:642 +#: ../../howto/logging.rst:640 msgid "" "$ python simple_logging_module.py\n" "2005-03-19 15:10:26,618 - simple_example - DEBUG - debug message\n" @@ -1007,14 +999,14 @@ msgid "" "2005-03-19 15:10:26,773 - simple_example - CRITICAL - critical message" msgstr "" -#: ../../howto/logging.rst:651 +#: ../../howto/logging.rst:649 msgid "" "The following Python module creates a logger, handler, and formatter nearly " "identical to those in the example listed above, with the only difference " "being the names of the objects::" msgstr "" -#: ../../howto/logging.rst:655 +#: ../../howto/logging.rst:653 msgid "" "import logging\n" "import logging.config\n" @@ -1032,11 +1024,11 @@ msgid "" "logger.critical('critical message')" msgstr "" -#: ../../howto/logging.rst:670 +#: ../../howto/logging.rst:668 msgid "Here is the logging.conf file:" msgstr "" -#: ../../howto/logging.rst:672 +#: ../../howto/logging.rst:670 msgid "" "[loggers]\n" "keys=root,simpleExample\n" @@ -1067,12 +1059,12 @@ msgid "" "format=%(asctime)s - %(name)s - %(levelname)s - %(message)s" msgstr "" -#: ../../howto/logging.rst:702 +#: ../../howto/logging.rst:700 msgid "" "The output is nearly identical to that of the non-config-file-based example:" msgstr "" -#: ../../howto/logging.rst:704 +#: ../../howto/logging.rst:702 msgid "" "$ python simple_logging_config.py\n" "2005-03-19 15:38:55,977 - simpleExample - DEBUG - debug message\n" @@ -1082,14 +1074,14 @@ msgid "" "2005-03-19 15:38:56,130 - simpleExample - CRITICAL - critical message" msgstr "" -#: ../../howto/logging.rst:713 +#: ../../howto/logging.rst:711 msgid "" "You can see that the config file approach has a few advantages over the " "Python code approach, mainly separation of configuration and code and the " "ability of noncoders to easily modify the logging properties." msgstr "" -#: ../../howto/logging.rst:717 +#: ../../howto/logging.rst:715 msgid "" "The :func:`fileConfig` function takes a default parameter, " "``disable_existing_loggers``, which defaults to ``True`` for reasons of " @@ -1100,7 +1092,7 @@ msgid "" "information, and specify ``False`` for this parameter if you wish." msgstr "" -#: ../../howto/logging.rst:725 +#: ../../howto/logging.rst:723 msgid "" "The dictionary passed to :func:`dictConfig` can also specify a Boolean value " "with key ``disable_existing_loggers``, which if not specified explicitly in " @@ -1109,7 +1101,7 @@ msgid "" "want - in which case, provide the key explicitly with a value of ``False``." msgstr "" -#: ../../howto/logging.rst:735 +#: ../../howto/logging.rst:733 msgid "" "Note that the class names referenced in config files need to be either " "relative to the logging module, or absolute values which can be resolved " @@ -1120,7 +1112,7 @@ msgid "" "path)." msgstr "" -#: ../../howto/logging.rst:743 +#: ../../howto/logging.rst:741 msgid "" "In Python 3.2, a new means of configuring logging has been introduced, using " "dictionaries to hold configuration information. This provides a superset of " @@ -1135,13 +1127,13 @@ msgid "" "a socket, or use whatever approach makes sense for your application." msgstr "" -#: ../../howto/logging.rst:755 +#: ../../howto/logging.rst:753 msgid "" "Here's an example of the same configuration as above, in YAML format for the " "new dictionary-based approach:" msgstr "" -#: ../../howto/logging.rst:758 +#: ../../howto/logging.rst:756 msgid "" "version: 1\n" "formatters:\n" @@ -1163,24 +1155,24 @@ msgid "" " handlers: [console]" msgstr "" -#: ../../howto/logging.rst:779 +#: ../../howto/logging.rst:777 msgid "" "For more information about logging using a dictionary, see :ref:`logging-" "config-api`." msgstr "" -#: ../../howto/logging.rst:783 +#: ../../howto/logging.rst:781 msgid "What happens if no configuration is provided" msgstr "" -#: ../../howto/logging.rst:785 +#: ../../howto/logging.rst:783 msgid "" "If no logging configuration is provided, it is possible to have a situation " "where a logging event needs to be output, but no handlers can be found to " "output the event." msgstr "" -#: ../../howto/logging.rst:789 +#: ../../howto/logging.rst:787 msgid "" "The event is output using a 'handler of last resort', stored in :data:" "`lastResort`. This internal handler is not associated with any logger, and " @@ -1192,32 +1184,32 @@ msgid "" "severities will be output." msgstr "" -#: ../../howto/logging.rst:800 +#: ../../howto/logging.rst:798 msgid "For versions of Python prior to 3.2, the behaviour is as follows:" msgstr "" -#: ../../howto/logging.rst:802 +#: ../../howto/logging.rst:800 msgid "" "If :data:`raiseExceptions` is ``False`` (production mode), the event is " "silently dropped." msgstr "" -#: ../../howto/logging.rst:805 +#: ../../howto/logging.rst:803 msgid "" "If :data:`raiseExceptions` is ``True`` (development mode), a message 'No " "handlers could be found for logger X.Y.Z' is printed once." msgstr "" -#: ../../howto/logging.rst:808 +#: ../../howto/logging.rst:806 msgid "" "To obtain the pre-3.2 behaviour, :data:`lastResort` can be set to ``None``." msgstr "" -#: ../../howto/logging.rst:814 +#: ../../howto/logging.rst:812 msgid "Configuring Logging for a Library" msgstr "" -#: ../../howto/logging.rst:816 +#: ../../howto/logging.rst:814 msgid "" "When developing a library which uses logging, you should take care to " "document how the library uses logging - for example, the names of loggers " @@ -1228,7 +1220,7 @@ msgid "" "is regarded as the best default behaviour." msgstr "" -#: ../../howto/logging.rst:824 +#: ../../howto/logging.rst:822 msgid "" "If for some reason you *don't* want these messages printed in the absence of " "any logging configuration, you can attach a do-nothing handler to the top-" @@ -1240,7 +1232,7 @@ msgid "" "to those handlers, as normal." msgstr "" -#: ../../howto/logging.rst:833 +#: ../../howto/logging.rst:831 msgid "" "A do-nothing handler is included in the logging package: :class:`~logging." "NullHandler` (since Python 3.1). An instance of this handler could be added " @@ -1251,7 +1243,7 @@ msgid "" "etc. then the code::" msgstr "" -#: ../../howto/logging.rst:841 +#: ../../howto/logging.rst:839 msgid "" "import logging\n" "logging.getLogger('foo').addHandler(logging.NullHandler())" @@ -1259,14 +1251,14 @@ msgstr "" "import logging\n" "logging.getLogger('foo').addHandler(logging.NullHandler())" -#: ../../howto/logging.rst:844 +#: ../../howto/logging.rst:842 msgid "" "should have the desired effect. If an organisation produces a number of " "libraries, then the logger name specified can be 'orgname.foo' rather than " "just 'foo'." msgstr "" -#: ../../howto/logging.rst:848 +#: ../../howto/logging.rst:846 msgid "" "It is strongly advised that you *do not log to the root logger* in your " "library. Instead, use a logger with a unique and easily identifiable name, " @@ -1276,7 +1268,7 @@ msgid "" "library as they wish." msgstr "" -#: ../../howto/logging.rst:855 +#: ../../howto/logging.rst:853 msgid "" "It is strongly advised that you *do not add any handlers other than* :class:" "`~logging.NullHandler` *to your library's loggers*. This is because the " @@ -1287,11 +1279,11 @@ msgid "" "carry out unit tests and deliver logs which suit their requirements." msgstr "" -#: ../../howto/logging.rst:866 +#: ../../howto/logging.rst:864 msgid "Logging Levels" msgstr "" -#: ../../howto/logging.rst:868 +#: ../../howto/logging.rst:866 msgid "" "The numeric values of logging levels are given in the following table. These " "are primarily of interest if you want to define your own levels, and need " @@ -1300,39 +1292,39 @@ msgid "" "value; the predefined name is lost." msgstr "" -#: ../../howto/logging.rst:875 +#: ../../howto/logging.rst:873 msgid "Numeric value" msgstr "" -#: ../../howto/logging.rst:877 +#: ../../howto/logging.rst:875 msgid "50" msgstr "50" -#: ../../howto/logging.rst:879 +#: ../../howto/logging.rst:877 msgid "40" msgstr "40" -#: ../../howto/logging.rst:881 +#: ../../howto/logging.rst:879 msgid "30" msgstr "30" -#: ../../howto/logging.rst:883 +#: ../../howto/logging.rst:881 msgid "20" msgstr "20" -#: ../../howto/logging.rst:885 +#: ../../howto/logging.rst:883 msgid "10" msgstr "10" -#: ../../howto/logging.rst:887 +#: ../../howto/logging.rst:885 msgid "``NOTSET``" msgstr "``NOTSET``" -#: ../../howto/logging.rst:887 +#: ../../howto/logging.rst:885 msgid "0" msgstr "0" -#: ../../howto/logging.rst:890 +#: ../../howto/logging.rst:888 msgid "" "Levels can also be associated with loggers, being set either by the " "developer or through loading a saved logging configuration. When a logging " @@ -1342,14 +1334,14 @@ msgid "" "basic mechanism controlling the verbosity of logging output." msgstr "" -#: ../../howto/logging.rst:897 +#: ../../howto/logging.rst:895 msgid "" "Logging messages are encoded as instances of the :class:`~logging.LogRecord` " "class. When a logger decides to actually log an event, a :class:`~logging." "LogRecord` instance is created from the logging message." msgstr "" -#: ../../howto/logging.rst:901 +#: ../../howto/logging.rst:899 msgid "" "Logging messages are subjected to a dispatch mechanism through the use of :" "dfn:`handlers`, which are instances of subclasses of the :class:`Handler` " @@ -1366,7 +1358,7 @@ msgid "" "at which point the passing to ancestor handlers stops)." msgstr "" -#: ../../howto/logging.rst:915 +#: ../../howto/logging.rst:913 msgid "" "Just as for loggers, handlers can have levels associated with them. A " "handler's level acts as a filter in the same way as a logger's level does. " @@ -1376,11 +1368,11 @@ msgid "" "`~Handler.emit`." msgstr "" -#: ../../howto/logging.rst:924 +#: ../../howto/logging.rst:922 msgid "Custom Levels" msgstr "" -#: ../../howto/logging.rst:926 +#: ../../howto/logging.rst:924 msgid "" "Defining your own levels is possible, but should not be necessary, as the " "existing levels have been chosen on the basis of practical experience. " @@ -1393,27 +1385,27 @@ msgid "" "given numeric value might mean different things for different libraries." msgstr "" -#: ../../howto/logging.rst:939 +#: ../../howto/logging.rst:937 msgid "Useful Handlers" msgstr "" -#: ../../howto/logging.rst:941 +#: ../../howto/logging.rst:939 msgid "" "In addition to the base :class:`Handler` class, many useful subclasses are " "provided:" msgstr "" -#: ../../howto/logging.rst:944 +#: ../../howto/logging.rst:942 msgid "" ":class:`StreamHandler` instances send messages to streams (file-like " "objects)." msgstr "" -#: ../../howto/logging.rst:947 +#: ../../howto/logging.rst:945 msgid ":class:`FileHandler` instances send messages to disk files." msgstr "" -#: ../../howto/logging.rst:949 +#: ../../howto/logging.rst:947 msgid "" ":class:`~handlers.BaseRotatingHandler` is the base class for handlers that " "rotate log files at a certain point. It is not meant to be instantiated " @@ -1421,61 +1413,61 @@ msgid "" "`~handlers.TimedRotatingFileHandler`." msgstr "" -#: ../../howto/logging.rst:954 +#: ../../howto/logging.rst:952 msgid "" ":class:`~handlers.RotatingFileHandler` instances send messages to disk " "files, with support for maximum log file sizes and log file rotation." msgstr "" -#: ../../howto/logging.rst:957 +#: ../../howto/logging.rst:955 msgid "" ":class:`~handlers.TimedRotatingFileHandler` instances send messages to disk " "files, rotating the log file at certain timed intervals." msgstr "" -#: ../../howto/logging.rst:960 +#: ../../howto/logging.rst:958 msgid "" ":class:`~handlers.SocketHandler` instances send messages to TCP/IP sockets. " "Since 3.4, Unix domain sockets are also supported." msgstr "" -#: ../../howto/logging.rst:963 +#: ../../howto/logging.rst:961 msgid "" ":class:`~handlers.DatagramHandler` instances send messages to UDP sockets. " "Since 3.4, Unix domain sockets are also supported." msgstr "" -#: ../../howto/logging.rst:966 +#: ../../howto/logging.rst:964 msgid "" ":class:`~handlers.SMTPHandler` instances send messages to a designated email " "address." msgstr "" -#: ../../howto/logging.rst:969 +#: ../../howto/logging.rst:967 msgid "" ":class:`~handlers.SysLogHandler` instances send messages to a Unix syslog " "daemon, possibly on a remote machine." msgstr "" -#: ../../howto/logging.rst:972 +#: ../../howto/logging.rst:970 msgid "" ":class:`~handlers.NTEventLogHandler` instances send messages to a Windows " "NT/2000/XP event log." msgstr "" -#: ../../howto/logging.rst:975 +#: ../../howto/logging.rst:973 msgid "" ":class:`~handlers.MemoryHandler` instances send messages to a buffer in " "memory, which is flushed whenever specific criteria are met." msgstr "" -#: ../../howto/logging.rst:978 +#: ../../howto/logging.rst:976 msgid "" ":class:`~handlers.HTTPHandler` instances send messages to an HTTP server " "using either ``GET`` or ``POST`` semantics." msgstr "" -#: ../../howto/logging.rst:981 +#: ../../howto/logging.rst:979 msgid "" ":class:`~handlers.WatchedFileHandler` instances watch the file they are " "logging to. If the file changes, it is closed and reopened using the file " @@ -1483,13 +1475,13 @@ msgid "" "support the underlying mechanism used." msgstr "" -#: ../../howto/logging.rst:986 +#: ../../howto/logging.rst:984 msgid "" ":class:`~handlers.QueueHandler` instances send messages to a queue, such as " "those implemented in the :mod:`queue` or :mod:`multiprocessing` modules." msgstr "" -#: ../../howto/logging.rst:989 +#: ../../howto/logging.rst:987 msgid "" ":class:`NullHandler` instances do nothing with error messages. They are used " "by library developers who want to use logging, but want to avoid the 'No " @@ -1498,15 +1490,15 @@ msgid "" "more information." msgstr "" -#: ../../howto/logging.rst:995 +#: ../../howto/logging.rst:993 msgid "The :class:`NullHandler` class." msgstr "" -#: ../../howto/logging.rst:998 +#: ../../howto/logging.rst:996 msgid "The :class:`~handlers.QueueHandler` class." msgstr "" -#: ../../howto/logging.rst:1001 +#: ../../howto/logging.rst:999 msgid "" "The :class:`NullHandler`, :class:`StreamHandler` and :class:`FileHandler` " "classes are defined in the core logging package. The other handlers are " @@ -1514,14 +1506,14 @@ msgid "" "module, :mod:`logging.config`, for configuration functionality.)" msgstr "" -#: ../../howto/logging.rst:1006 +#: ../../howto/logging.rst:1004 msgid "" "Logged messages are formatted for presentation through instances of the :" "class:`Formatter` class. They are initialized with a format string suitable " "for use with the % operator and a dictionary." msgstr "" -#: ../../howto/logging.rst:1010 +#: ../../howto/logging.rst:1008 msgid "" "For formatting multiple messages in a batch, instances of :class:" "`BufferingFormatter` can be used. In addition to the format string (which is " @@ -1529,7 +1521,7 @@ msgid "" "trailer format strings." msgstr "" -#: ../../howto/logging.rst:1015 +#: ../../howto/logging.rst:1013 msgid "" "When filtering based on logger level and/or handler level is not enough, " "instances of :class:`Filter` can be added to both :class:`Logger` and :class:" @@ -1539,18 +1531,18 @@ msgid "" "value, the message is not processed further." msgstr "" -#: ../../howto/logging.rst:1022 +#: ../../howto/logging.rst:1020 msgid "" "The basic :class:`Filter` functionality allows filtering by specific logger " "name. If this feature is used, messages sent to the named logger and its " "children are allowed through the filter, and all others dropped." msgstr "" -#: ../../howto/logging.rst:1030 +#: ../../howto/logging.rst:1028 msgid "Exceptions raised during logging" msgstr "" -#: ../../howto/logging.rst:1032 +#: ../../howto/logging.rst:1030 msgid "" "The logging package is designed to swallow exceptions which occur while " "logging in production. This is so that errors which occur while handling " @@ -1558,7 +1550,7 @@ msgid "" "errors - do not cause the application using logging to terminate prematurely." msgstr "" -#: ../../howto/logging.rst:1037 +#: ../../howto/logging.rst:1035 msgid "" ":class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never " "swallowed. Other exceptions which occur during the :meth:`~Handler.emit` " @@ -1566,7 +1558,7 @@ msgid "" "handleError` method." msgstr "" -#: ../../howto/logging.rst:1042 +#: ../../howto/logging.rst:1040 msgid "" "The default implementation of :meth:`~Handler.handleError` in :class:" "`Handler` checks to see if a module-level variable, :data:`raiseExceptions`, " @@ -1574,7 +1566,7 @@ msgid "" "the exception is swallowed." msgstr "" -#: ../../howto/logging.rst:1048 +#: ../../howto/logging.rst:1046 msgid "" "The default value of :data:`raiseExceptions` is ``True``. This is because " "during development, you typically want to be notified of any exceptions that " @@ -1582,11 +1574,11 @@ msgid "" "production usage." msgstr "" -#: ../../howto/logging.rst:1058 +#: ../../howto/logging.rst:1056 msgid "Using arbitrary objects as messages" msgstr "" -#: ../../howto/logging.rst:1060 +#: ../../howto/logging.rst:1058 msgid "" "In the preceding sections and examples, it has been assumed that the message " "passed when logging the event is a string. However, this is not the only " @@ -1598,11 +1590,11 @@ msgid "" "the wire." msgstr "" -#: ../../howto/logging.rst:1071 +#: ../../howto/logging.rst:1069 msgid "Optimization" msgstr "最佳化" -#: ../../howto/logging.rst:1073 +#: ../../howto/logging.rst:1071 msgid "" "Formatting of message arguments is deferred until it cannot be avoided. " "However, computing the arguments passed to the logging method can also be " @@ -1613,20 +1605,20 @@ msgid "" "code like this::" msgstr "" -#: ../../howto/logging.rst:1081 +#: ../../howto/logging.rst:1079 msgid "" "if logger.isEnabledFor(logging.DEBUG):\n" " logger.debug('Message with %s, %s', expensive_func1(),\n" " expensive_func2())" msgstr "" -#: ../../howto/logging.rst:1085 +#: ../../howto/logging.rst:1083 msgid "" "so that if the logger's threshold is set above ``DEBUG``, the calls to " "``expensive_func1`` and ``expensive_func2`` are never made." msgstr "" -#: ../../howto/logging.rst:1088 +#: ../../howto/logging.rst:1086 msgid "" "In some cases, :meth:`~Logger.isEnabledFor` can itself be more expensive " "than you'd like (e.g. for deeply nested loggers where an explicit level is " @@ -1638,7 +1630,7 @@ msgid "" "while the application is running (which is not all that common)." msgstr "" -#: ../../howto/logging.rst:1097 +#: ../../howto/logging.rst:1095 msgid "" "There are other optimizations which can be made for specific applications " "which need more precise control over what logging information is collected. " @@ -1646,94 +1638,100 @@ msgid "" "you don't need:" msgstr "" -#: ../../howto/logging.rst:1103 +#: ../../howto/logging.rst:1101 msgid "What you don't want to collect" msgstr "" -#: ../../howto/logging.rst:1103 +#: ../../howto/logging.rst:1101 msgid "How to avoid collecting it" msgstr "" -#: ../../howto/logging.rst:1105 +#: ../../howto/logging.rst:1103 msgid "Information about where calls were made from." msgstr "" -#: ../../howto/logging.rst:1105 +#: ../../howto/logging.rst:1103 msgid "" "Set ``logging._srcfile`` to ``None``. This avoids calling :func:`sys." "_getframe`, which may help to speed up your code in environments like PyPy " "(which can't speed up code that uses :func:`sys._getframe`)." msgstr "" -#: ../../howto/logging.rst:1111 +#: ../../howto/logging.rst:1109 msgid "Threading information." msgstr "" -#: ../../howto/logging.rst:1111 +#: ../../howto/logging.rst:1109 msgid "Set ``logging.logThreads`` to ``False``." msgstr "將 ``logging.logThreads`` 設為 ``False``。" -#: ../../howto/logging.rst:1113 +#: ../../howto/logging.rst:1111 msgid "Current process ID (:func:`os.getpid`)" msgstr "目前的行程 ID (:func:`os.getpid`)" -#: ../../howto/logging.rst:1113 +#: ../../howto/logging.rst:1111 msgid "Set ``logging.logProcesses`` to ``False``." msgstr "將 ``logging.logProcesses`` 設為 ``False``。" -#: ../../howto/logging.rst:1115 +#: ../../howto/logging.rst:1113 msgid "" "Current process name when using ``multiprocessing`` to manage multiple " "processes." msgstr "" -#: ../../howto/logging.rst:1115 +#: ../../howto/logging.rst:1113 msgid "Set ``logging.logMultiprocessing`` to ``False``." msgstr "將 ``logging.logMultiprocessing`` 設為 ``False``。" -#: ../../howto/logging.rst:1118 +#: ../../howto/logging.rst:1116 msgid "Current :class:`asyncio.Task` name when using ``asyncio``." msgstr "" -#: ../../howto/logging.rst:1118 +#: ../../howto/logging.rst:1116 msgid "Set ``logging.logAsyncioTasks`` to ``False``." msgstr "將 ``logging.logAsyncioTasks`` 設為 ``False``。" -#: ../../howto/logging.rst:1122 +#: ../../howto/logging.rst:1120 msgid "" "Also note that the core logging module only includes the basic handlers. If " "you don't import :mod:`logging.handlers` and :mod:`logging.config`, they " "won't take up any memory." msgstr "" -#: ../../howto/logging.rst:1129 +#: ../../howto/logging.rst:1127 msgid "Other resources" msgstr "其他資源" -#: ../../howto/logging.rst:1133 +#: ../../howto/logging.rst:1131 msgid "Module :mod:`logging`" msgstr ":mod:`logging` 模組" -#: ../../howto/logging.rst:1134 +#: ../../howto/logging.rst:1132 msgid "API reference for the logging module." msgstr "" -#: ../../howto/logging.rst:1136 +#: ../../howto/logging.rst:1134 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` 模組" -#: ../../howto/logging.rst:1137 +#: ../../howto/logging.rst:1135 msgid "Configuration API for the logging module." msgstr "" -#: ../../howto/logging.rst:1139 +#: ../../howto/logging.rst:1137 msgid "Module :mod:`logging.handlers`" msgstr ":mod:`logging.handlers` 模組" -#: ../../howto/logging.rst:1140 +#: ../../howto/logging.rst:1138 msgid "Useful handlers included with the logging module." msgstr "" -#: ../../howto/logging.rst:1142 +#: ../../howto/logging.rst:1140 msgid ":ref:`A logging cookbook `" msgstr "" + +#~ msgid "Author" +#~ msgstr "作者" + +#~ msgid "Vinay Sajip " +#~ msgstr "Vinay Sajip " diff --git a/howto/perf_profiling.po b/howto/perf_profiling.po index d606afed568..47365c3aeaa 100644 --- a/howto/perf_profiling.po +++ b/howto/perf_profiling.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-19 00:14+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-12-09 17:39+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -18,70 +18,67 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../howto/perf_profiling.rst:7 -msgid "Python support for the Linux ``perf`` profiler" -msgstr "Python 對 Linux ``perf`` 分析器的支援" - -#: ../../howto/perf_profiling.rst:0 -msgid "author" -msgstr "作者" +msgid "Python support for the ``perf map`` compatible profilers" +msgstr "Python 對 ``perf map`` 相容分析器的支援" #: ../../howto/perf_profiling.rst:9 -msgid "Pablo Galindo" -msgstr "Pablo Galindo" - -#: ../../howto/perf_profiling.rst:11 msgid "" -"`The Linux perf profiler `_ is a very powerful " -"tool that allows you to profile and obtain information about the performance " -"of your application. ``perf`` also has a very vibrant ecosystem of tools " -"that aid with the analysis of the data that it produces." +"`The Linux perf profiler `_ and `samply " +"`_ are powerful tools that allow you to " +"profile and obtain information about the performance of your application. " +"Both tools have vibrant ecosystems that aid with the analysis of the data " +"they produce." msgstr "" -"`Linux 性能分析器 (Linux perf profiler) `_ 是一" -"個非常強大的工具,可讓你分析並取得有關應用程式的性能資訊。``perf`` 還擁有一個" -"非常活躍的工具生態系統,有助於分析其生成的資料。" +"`Linux 效能分析器 (Linux perf profiler) `_ 和 " +"`samply `_ 是強大的工具,可讓你分析並取得" +"有關應用程式的效能資訊。這兩個工具都擁有非常活躍的生態系統,有助於分析其生成" +"的資料。" -#: ../../howto/perf_profiling.rst:17 +#: ../../howto/perf_profiling.rst:14 msgid "" -"The main problem with using the ``perf`` profiler with Python applications " -"is that ``perf`` only gets information about native symbols, that is, the " -"names of functions and procedures written in C. This means that the names " -"and file names of Python functions in your code will not appear in the " -"output of ``perf``." +"The main problem with using these profilers with Python applications is that " +"they only get information about native symbols, that is, the names of " +"functions and procedures written in C. This means that the names and file " +"names of Python functions in your code will not appear in the profiler " +"output." msgstr "" -"在 Python 應用程式中使用 ``perf`` 分析器的主要問題是 ``perf`` 僅取得有關原生" -"符號的資訊,即用 C 編寫的函式和程式的名稱。這表示程式碼中的 Python 函式名稱和" -"檔案名稱不會出現在 ``perf`` 的輸出中。" +"在 Python 應用程式中使用這些分析器的主要問題是它們僅取得有關原生符號的資訊," +"即用 C 編寫的函式和程式的名稱。這表示程式碼中的 Python 函式名稱和檔案名稱不會" +"出現在分析器的輸出中。" -#: ../../howto/perf_profiling.rst:22 +#: ../../howto/perf_profiling.rst:19 msgid "" "Since Python 3.12, the interpreter can run in a special mode that allows " -"Python functions to appear in the output of the ``perf`` profiler. When this " +"Python functions to appear in the output of compatible profilers. When this " "mode is enabled, the interpreter will interpose a small piece of code " "compiled on the fly before the execution of every Python function and it " -"will teach ``perf`` the relationship between this piece of code and the " +"will teach the profiler the relationship between this piece of code and the " "associated Python function using :doc:`perf map files <../c-api/perfmaps>`." msgstr "" -"從 Python 3.12 開始,直譯器可以在特殊模式下執行,該模式允許 Python 函式出現" -"在 ``perf`` 分析器的輸出中。啟用此模式後,直譯器將在執行每個 Python 函式之前" -"插入 (interpose) 一小段動態編譯的程式碼,並使用 :doc:`perf map 檔案 <../c-" -"api/perfmaps>`\\ 來告訴 ``perf`` 這段程式碼與相關聯的 Python 函式間的關係。" +"從 Python 3.12 開始,直譯器可以在特殊模式下執行,該模式允許 Python 函式出現在" +"相容分析器的輸出中。啟用此模式後,直譯器將在執行每個 Python 函式之前插入 " +"(interpose) 一小段動態編譯的程式碼,並使用 :doc:`perf map 檔案 <../c-api/" +"perfmaps>`\\ 來告訴分析器這段程式碼與相關聯的 Python 函式間的關係。" -#: ../../howto/perf_profiling.rst:31 +#: ../../howto/perf_profiling.rst:28 msgid "" -"Support for the ``perf`` profiler is currently only available for Linux on " -"select architectures. Check the output of the ``configure`` build step or " -"check the output of ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE`` to " -"see if your system is supported." +"Support for profiling is available on Linux and macOS on select " +"architectures. Perf is available on Linux, while samply can be used on both " +"Linux and macOS. samply support on macOS is available starting from Python " +"3.15. Check the output of the ``configure`` build step or check the output " +"of ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE`` to see if your system " +"is supported." msgstr "" -"目前對 ``perf`` 分析器的支援僅適用於 Linux 的特定架構上。檢查 ``configure`` " -"建構步驟的輸出或檢查 ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE`` 的輸" -"出來查看你的系統是否支援。" +"分析功能的支援適用於 Linux 和 macOS 的特定架構上。perf 可在 Linux 上使用,而 " +"samply 則可在 Linux 和 macOS 上使用。macOS 上的 samply 支援從 Python 3.15 開" +"始提供。檢查 ``configure`` 建構步驟的輸出或檢查 ``python -m sysconfig | grep " +"HAVE_PERF_TRAMPOLINE`` 的輸出來查看你的系統是否支援。" -#: ../../howto/perf_profiling.rst:36 +#: ../../howto/perf_profiling.rst:35 msgid "For example, consider the following script:" msgstr "例如,參考以下腳本:" -#: ../../howto/perf_profiling.rst:38 +#: ../../howto/perf_profiling.rst:37 msgid "" "def foo(n):\n" " result = 0\n" @@ -113,19 +110,19 @@ msgstr "" "if __name__ == \"__main__\":\n" " baz(1000000)" -#: ../../howto/perf_profiling.rst:55 +#: ../../howto/perf_profiling.rst:54 msgid "We can run ``perf`` to sample CPU stack traces at 9999 hertz::" msgstr "我們可以執行 ``perf`` 以 9999 赫茲取樣 CPU 堆疊追蹤 (stack trace): ::" -#: ../../howto/perf_profiling.rst:57 +#: ../../howto/perf_profiling.rst:56 msgid "$ perf record -F 9999 -g -o perf.data python my_script.py" msgstr "$ perf record -F 9999 -g -o perf.data python my_script.py" -#: ../../howto/perf_profiling.rst:59 +#: ../../howto/perf_profiling.rst:58 msgid "Then we can use ``perf report`` to analyze the data:" msgstr "然後我們可以使用 ``perf report`` 來分析資料:" -#: ../../howto/perf_profiling.rst:61 +#: ../../howto/perf_profiling.rst:60 msgid "" "$ perf report --stdio -n -g\n" "\n" @@ -173,7 +170,7 @@ msgid "" " | | | " "| |\n" " | | | " -"| |--11.52%--_PyLong_Add\n" +"| |--11.52%--_PyCompactLong_Add\n" " | | | " "| | |\n" " | | | " @@ -226,14 +223,14 @@ msgstr "" " | | | " "| |\n" " | | | " -"| |--11.52%--_PyLong_Add\n" +"| |--11.52%--_PyCompactLong_Add\n" " | | | " "| | |\n" " | | | " "| | |--2.97%--_PyObject_Malloc\n" "..." -#: ../../howto/perf_profiling.rst:100 +#: ../../howto/perf_profiling.rst:99 msgid "" "As you can see, the Python functions are not shown in the output, only " "``_PyEval_EvalFrameDefault`` (the function that evaluates the Python " @@ -246,13 +243,13 @@ msgstr "" "有 Python 函式都使用相同的 C 函式來替位元組碼求值,因此我們無法知道哪個 " "Python 函式是對應於哪個位元組碼計算函式。" -#: ../../howto/perf_profiling.rst:105 +#: ../../howto/perf_profiling.rst:104 msgid "" "Instead, if we run the same experiment with ``perf`` support enabled we get:" msgstr "" "作為替代,如果我們在啟用 ``perf`` 支援的情況下執行相同的實驗,我們會得到:" -#: ../../howto/perf_profiling.rst:107 +#: ../../howto/perf_profiling.rst:106 msgid "" "$ perf report --stdio -n -g\n" "\n" @@ -308,7 +305,7 @@ msgid "" " | | | " "| |\n" " | | | " -"| |--13.77%--_PyLong_Add\n" +"| |--13.77%--_PyCompactLong_Add\n" " | | | " "| | |\n" " | | | " @@ -368,17 +365,57 @@ msgstr "" " | | | " "| |\n" " | | | " -"| |--13.77%--_PyLong_Add\n" +"| |--13.77%--_PyCompactLong_Add\n" " | | | " "| | |\n" " | | | " "| | |--3.26%--_PyObject_Malloc" -#: ../../howto/perf_profiling.rst:152 +#: ../../howto/perf_profiling.rst:151 +msgid "Using the samply profiler" +msgstr "" + +#: ../../howto/perf_profiling.rst:153 +msgid "" +"samply is a modern profiler that can be used as an alternative to perf. It " +"uses the same perf map files that Python generates, making it compatible " +"with Python's profiling support. samply is particularly useful on macOS " +"where perf is not available." +msgstr "" + +#: ../../howto/perf_profiling.rst:158 +msgid "" +"To use samply with Python, first install it following the instructions at " +"https://github.com/mstange/samply, then run::" +msgstr "" + +#: ../../howto/perf_profiling.rst:161 +msgid "$ samply record PYTHONPERFSUPPORT=1 python my_script.py" +msgstr "$ samply record PYTHONPERFSUPPORT=1 python my_script.py" + +#: ../../howto/perf_profiling.rst:163 +msgid "" +"This will open a web interface where you can analyze the profiling data " +"interactively. The advantage of samply is that it provides a modern web-" +"based interface for analyzing profiling data and works on both Linux and " +"macOS." +msgstr "" + +#: ../../howto/perf_profiling.rst:168 +msgid "" +"On macOS, samply support requires Python 3.15 or later. Also on macOS, " +"samply can't profile signed Python executables due to restrictions by macOS. " +"You can profile with Python binaries that you've compiled yourself, or which " +"are unsigned or locally-signed (such as anything installed by Homebrew). In " +"order to attach to running processes on macOS, run ``samply setup`` once " +"(and every time samply is updated) to self-sign the samply binary." +msgstr "" + +#: ../../howto/perf_profiling.rst:176 msgid "How to enable ``perf`` profiling support" msgstr "如何啟用 ``perf`` 分析支援" -#: ../../howto/perf_profiling.rst:154 +#: ../../howto/perf_profiling.rst:178 msgid "" "``perf`` profiling support can be enabled either from the start using the " "environment variable :envvar:`PYTHONPERFSUPPORT` or the :option:`-X perf <-" @@ -390,18 +427,18 @@ msgstr "" "用 :func:`sys.activate_stack_trampoline` " "和 :func:`sys.deactivate_stack_trampoline` 來動態啟用。" -#: ../../howto/perf_profiling.rst:160 +#: ../../howto/perf_profiling.rst:184 msgid "" "The :mod:`!sys` functions take precedence over the :option:`!-X` option, " "the :option:`!-X` option takes precedence over the environment variable." msgstr "" ":mod:`!sys` 函式優先於 :option:`!-X` 選項、:option:`!-X` 選項優先於環境變數。" -#: ../../howto/perf_profiling.rst:163 +#: ../../howto/perf_profiling.rst:187 msgid "Example, using the environment variable::" msgstr "例如,使用環境變數: ::" -#: ../../howto/perf_profiling.rst:165 +#: ../../howto/perf_profiling.rst:189 msgid "" "$ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python " "my_script.py\n" @@ -411,11 +448,11 @@ msgstr "" "my_script.py\n" "$ perf report -g -i perf.data" -#: ../../howto/perf_profiling.rst:168 +#: ../../howto/perf_profiling.rst:192 msgid "Example, using the :option:`!-X` option::" msgstr "例如,使用 :option:`!-X` 選項: ::" -#: ../../howto/perf_profiling.rst:170 +#: ../../howto/perf_profiling.rst:194 msgid "" "$ perf record -F 9999 -g -o perf.data python -X perf my_script.py\n" "$ perf report -g -i perf.data" @@ -423,11 +460,11 @@ msgstr "" "$ perf record -F 9999 -g -o perf.data python -X perf my_script.py\n" "$ perf report -g -i perf.data" -#: ../../howto/perf_profiling.rst:173 +#: ../../howto/perf_profiling.rst:197 msgid "Example, using the :mod:`sys` APIs in file :file:`example.py`:" msgstr "例如,在 :file:`example.py` 檔案中使用 :mod:`sys` API:" -#: ../../howto/perf_profiling.rst:175 +#: ../../howto/perf_profiling.rst:199 msgid "" "import sys\n" "\n" @@ -445,11 +482,11 @@ msgstr "" "\n" "non_profiled_stuff()" -#: ../../howto/perf_profiling.rst:185 +#: ../../howto/perf_profiling.rst:209 msgid "...then::" msgstr "...然後: ::" -#: ../../howto/perf_profiling.rst:187 +#: ../../howto/perf_profiling.rst:211 msgid "" "$ perf record -F 9999 -g -o perf.data python ./example.py\n" "$ perf report -g -i perf.data" @@ -457,34 +494,36 @@ msgstr "" "$ perf record -F 9999 -g -o perf.data python ./example.py\n" "$ perf report -g -i perf.data" -#: ../../howto/perf_profiling.rst:192 +#: ../../howto/perf_profiling.rst:216 msgid "How to obtain the best results" msgstr "如何獲得最佳結果" -#: ../../howto/perf_profiling.rst:194 +#: ../../howto/perf_profiling.rst:218 msgid "" -"For best results, Python should be compiled with ``CFLAGS=\"-fno-omit-frame-" -"pointer -mno-omit-leaf-frame-pointer\"`` as this allows profilers to unwind " -"using only the frame pointer and not on DWARF debug information. This is " -"because as the code that is interposed to allow ``perf`` support is " -"dynamically generated it doesn't have any DWARF debugging information " -"available." +"For best results, keep frame pointers enabled. On supported GCC-compatible " +"toolchains, CPython builds itself with ``-fno-omit-frame-pointer`` and " +"similar flags (see :option:`--without-frame-pointers` for details). These " +"flags allow profilers to unwind using only the frame pointer and not on " +"DWARF debug information. This is because as the code that is interposed to " +"allow ``perf`` support is dynamically generated it doesn't have any DWARF " +"debugging information available." msgstr "" -"為了獲得最佳結果,應使用 ``CFLAGS=\"-fno-omit-frame-pointer -mno-omit-leaf-" -"frame-pointer\"`` 來進行 Python 編譯,因為這能允許分析器僅使用 frame 指標而不" -"是 DWARF 除錯資訊來解析 (unwind)。這是因為,由於插入以允許 ``perf`` 支援的程" -"式碼是動態生成的,因此它沒有任何可用的 DWARF 除錯資訊。" +"為了獲得最佳結果,請保持啟用 frame 指標。在支援的 GCC 相容工具鏈上,CPython " +"會使用 ``-fno-omit-frame-pointer`` 和類似的旗標來建置自身(詳情請參" +"閱 :option:`--without-frame-pointers`)。這些旗標能允許分析器僅使用 frame 指" +"標而不是 DWARF 除錯資訊來解析 (unwind)。這是因為,由於插入以允許 ``perf`` 支" +"援的程式碼是動態生成的,因此它沒有任何可用的 DWARF 除錯資訊。" -#: ../../howto/perf_profiling.rst:201 +#: ../../howto/perf_profiling.rst:226 msgid "" "You can check if your system has been compiled with this flag by running::" msgstr "你可以透過執行以下指令來檢查你的系統是否已使用此旗標進行編譯: ::" -#: ../../howto/perf_profiling.rst:203 +#: ../../howto/perf_profiling.rst:228 msgid "$ python -m sysconfig | grep 'no-omit-frame-pointer'" msgstr "$ python -m sysconfig | grep 'no-omit-frame-pointer'" -#: ../../howto/perf_profiling.rst:205 +#: ../../howto/perf_profiling.rst:230 msgid "" "If you don't see any output it means that your interpreter has not been " "compiled with frame pointers and therefore it may not be able to show Python " @@ -493,11 +532,11 @@ msgstr "" "如果你沒有看到任何輸出,則表示你的直譯器尚未使用 frame 指標進行編譯,因此它可" "能無法在 ``perf`` 的輸出中顯示 Python 函式。" -#: ../../howto/perf_profiling.rst:211 +#: ../../howto/perf_profiling.rst:236 msgid "How to work without frame pointers" msgstr "" -#: ../../howto/perf_profiling.rst:213 +#: ../../howto/perf_profiling.rst:238 msgid "" "If you are working with a Python interpreter that has been compiled without " "frame pointers, you can still use the ``perf`` profiler, but the overhead " @@ -507,21 +546,21 @@ msgid "" "debugging information to unwind the stack and this is a slow process." msgstr "" -#: ../../howto/perf_profiling.rst:220 +#: ../../howto/perf_profiling.rst:245 msgid "" "To enable this mode, you can use the environment " "variable :envvar:`PYTHON_PERF_JIT_SUPPORT` or the :option:`-X perf_jit <-X>` " "option, which will enable the JIT mode for the ``perf`` profiler." msgstr "" -#: ../../howto/perf_profiling.rst:226 +#: ../../howto/perf_profiling.rst:251 msgid "" "Due to a bug in the ``perf`` tool, only ``perf`` versions higher than v6.8 " "will work with the JIT mode. The fix was also backported to the v6.7.2 " "version of the tool." msgstr "" -#: ../../howto/perf_profiling.rst:230 +#: ../../howto/perf_profiling.rst:255 msgid "" "Note that when checking the version of the ``perf`` tool (which can be done " "by running ``perf version``) you must take into account that some distros " @@ -529,14 +568,14 @@ msgid "" "that ``perf 6.7-3`` is not necessarily ``perf 6.7.3``." msgstr "" -#: ../../howto/perf_profiling.rst:235 +#: ../../howto/perf_profiling.rst:260 msgid "" "When using the perf JIT mode, you need an extra step before you can run " "``perf report``. You need to call the ``perf inject`` command to inject the " "JIT information into the ``perf.data`` file.::" msgstr "" -#: ../../howto/perf_profiling.rst:239 +#: ../../howto/perf_profiling.rst:264 msgid "" "$ perf record -F 9999 -g -k 1 --call-graph dwarf -o perf.data python " "-Xperf_jit my_script.py\n" @@ -548,11 +587,11 @@ msgstr "" "$ perf inject -i perf.data --jit --output perf.jit.data\n" "$ perf report -g -i perf.jit.data" -#: ../../howto/perf_profiling.rst:243 +#: ../../howto/perf_profiling.rst:268 msgid "or using the environment variable::" msgstr "或使用環境變數: ::" -#: ../../howto/perf_profiling.rst:245 +#: ../../howto/perf_profiling.rst:270 msgid "" "$ PYTHON_PERF_JIT_SUPPORT=1 perf record -F 9999 -g --call-graph dwarf -o " "perf.data python my_script.py\n" @@ -564,7 +603,7 @@ msgstr "" "$ perf inject -i perf.data --jit --output perf.jit.data\n" "$ perf report -g -i perf.jit.data" -#: ../../howto/perf_profiling.rst:249 +#: ../../howto/perf_profiling.rst:274 msgid "" "``perf inject --jit`` command will read ``perf.data``, automatically pick up " "the perf dump file that Python creates (in ``/tmp/perf-$PID.dump``), and " @@ -574,7 +613,7 @@ msgid "" "by Python." msgstr "" -#: ../../howto/perf_profiling.rst:257 +#: ../../howto/perf_profiling.rst:282 msgid "" "When using ``--call-graph dwarf``, the ``perf`` tool will take snapshots of " "the stack of the process being profiled and save the information in the " @@ -583,7 +622,7 @@ msgid "" "dwarf,16384``." msgstr "" -#: ../../howto/perf_profiling.rst:263 +#: ../../howto/perf_profiling.rst:288 msgid "" "The size of the stack dump is important because if the size is too small " "``perf`` will not be able to unwind the stack and the output will be " @@ -592,7 +631,7 @@ msgid "" "will be higher." msgstr "" -#: ../../howto/perf_profiling.rst:269 +#: ../../howto/perf_profiling.rst:294 msgid "" "The stack size is particularly important when profiling Python code compiled " "with low optimization levels (like ``-O0``), as these builds tend to have " @@ -601,7 +640,7 @@ msgid "" "size to 65528 bytes (the maximum)::" msgstr "" -#: ../../howto/perf_profiling.rst:275 +#: ../../howto/perf_profiling.rst:300 msgid "" "$ perf record -F 9999 -g -k 1 --call-graph dwarf,65528 -o perf.data python " "-Xperf_jit my_script.py" @@ -609,23 +648,29 @@ msgstr "" "$ perf record -F 9999 -g -k 1 --call-graph dwarf,65528 -o perf.data python " "-Xperf_jit my_script.py" -#: ../../howto/perf_profiling.rst:277 +#: ../../howto/perf_profiling.rst:302 msgid "Different compilation flags can significantly impact stack sizes:" msgstr "" -#: ../../howto/perf_profiling.rst:279 +#: ../../howto/perf_profiling.rst:304 msgid "" "Builds with ``-O0`` typically have much larger stack frames than those with " "``-O1`` or higher" msgstr "" -#: ../../howto/perf_profiling.rst:280 +#: ../../howto/perf_profiling.rst:305 msgid "" "Adding optimizations (``-O1``, ``-O2``, etc.) typically reduces stack size" msgstr "" -#: ../../howto/perf_profiling.rst:281 +#: ../../howto/perf_profiling.rst:306 msgid "" "Frame pointers (``-fno-omit-frame-pointer``) generally provide more reliable " "stack unwinding" msgstr "" + +#~ msgid "author" +#~ msgstr "作者" + +#~ msgid "Pablo Galindo" +#~ msgstr "Pablo Galindo" diff --git a/howto/pyporting.po b/howto/pyporting.po index 7220c627b30..2e5b04a752a 100644 --- a/howto/pyporting.po +++ b/howto/pyporting.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-31 00:03+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:37+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,15 +22,7 @@ msgstr "" msgid "How to port Python 2 Code to Python 3" msgstr "如何將 Python 2 的程式碼移植到 Python 3" -#: ../../howto/pyporting.rst:0 -msgid "author" -msgstr "作者" - #: ../../howto/pyporting.rst:9 -msgid "Brett Cannon" -msgstr "Brett Cannon" - -#: ../../howto/pyporting.rst:11 msgid "" "Python 2 reached its official end-of-life at the start of 2020. This means " "that no new bug reports, fixes, or changes will be made to Python 2 - it's " @@ -38,48 +30,54 @@ msgid "" "devguide.python.org/versions>`_." msgstr "" -#: ../../howto/pyporting.rst:16 +#: ../../howto/pyporting.rst:14 msgid "" "If you are looking to port an extension module instead of pure Python code, " "please see :ref:`cporting-howto`." msgstr "" -#: ../../howto/pyporting.rst:19 +#: ../../howto/pyporting.rst:17 msgid "" "The archived python-porting_ mailing list may contain some useful guidance." msgstr "" -#: ../../howto/pyporting.rst:21 +#: ../../howto/pyporting.rst:19 msgid "" "Since Python 3.11 the original porting guide was discontinued. You can find " "the old guide in the `archive `_." msgstr "" -#: ../../howto/pyporting.rst:27 +#: ../../howto/pyporting.rst:25 msgid "Third-party guides" msgstr "" -#: ../../howto/pyporting.rst:29 +#: ../../howto/pyporting.rst:27 msgid "There are also multiple third-party guides that might be useful:" msgstr "" -#: ../../howto/pyporting.rst:31 +#: ../../howto/pyporting.rst:29 msgid "`Guide by Fedora `_" msgstr "" -#: ../../howto/pyporting.rst:32 +#: ../../howto/pyporting.rst:30 msgid "`PyCon 2020 tutorial `_" msgstr "" -#: ../../howto/pyporting.rst:33 +#: ../../howto/pyporting.rst:31 msgid "" "`Guide by DigitalOcean `_" msgstr "" -#: ../../howto/pyporting.rst:34 +#: ../../howto/pyporting.rst:32 msgid "" "`Guide by ActiveState `_" msgstr "" + +#~ msgid "author" +#~ msgstr "作者" + +#~ msgid "Brett Cannon" +#~ msgstr "Brett Cannon" diff --git a/howto/regex.po b/howto/regex.po index f6be32d6bff..59e2ae3e241 100644 --- a/howto/regex.po +++ b/howto/regex.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-04-05 00:23+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:37+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,19 +23,11 @@ msgstr "" msgid "Regular expression HOWTO" msgstr "如何使用正規表示式" -#: ../../howto/regex.rst:0 -msgid "Author" -msgstr "作者" - -#: ../../howto/regex.rst:7 -msgid "A.M. Kuchling " -msgstr "A.M. Kuchling " - #: ../../howto/regex.rst:-1 msgid "Abstract" msgstr "摘要" -#: ../../howto/regex.rst:18 +#: ../../howto/regex.rst:16 msgid "" "This document is an introductory tutorial to using regular expressions in " "Python with the :mod:`re` module. It provides a gentler introduction than " @@ -44,11 +36,11 @@ msgstr "" "此文件為如何在 Python 中使用 :mod:`re` 模組來撰寫正規表示式的入門指導。進階使" "用及參考文件請見函式庫參考一章。" -#: ../../howto/regex.rst:24 +#: ../../howto/regex.rst:22 msgid "Introduction" msgstr "簡介" -#: ../../howto/regex.rst:26 +#: ../../howto/regex.rst:24 msgid "" "Regular expressions (called REs, or regexes, or regex patterns) are " "essentially a tiny, highly specialized programming language embedded inside " @@ -66,7 +58,7 @@ msgstr "" "TeX 命令或任何東西。你可以檢查如「這組字串是否匹配這個規則?」或「這組字串中" "是否有任一處匹配這個規則?」。除此之外,你也可以使用 REs 來修改或是切割字串。" -#: ../../howto/regex.rst:35 +#: ../../howto/regex.rst:33 msgid "" "Regular expression patterns are compiled into a series of bytecodes which " "are then executed by a matching engine written in C. For advanced use, it " @@ -77,7 +69,7 @@ msgid "" "internals." msgstr "" -#: ../../howto/regex.rst:42 +#: ../../howto/regex.rst:40 msgid "" "The regular expression language is relatively small and restricted, so not " "all possible string processing tasks can be done using regular expressions. " @@ -88,29 +80,29 @@ msgid "" "more understandable." msgstr "" -#: ../../howto/regex.rst:51 +#: ../../howto/regex.rst:49 msgid "Simple patterns" msgstr "" -#: ../../howto/regex.rst:53 +#: ../../howto/regex.rst:51 msgid "" "We'll start by learning about the simplest possible regular expressions. " "Since regular expressions are used to operate on strings, we'll begin with " "the most common task: matching characters." msgstr "" -#: ../../howto/regex.rst:57 +#: ../../howto/regex.rst:55 msgid "" "For a detailed explanation of the computer science underlying regular " "expressions (deterministic and non-deterministic finite automata), you can " "refer to almost any textbook on writing compilers." msgstr "" -#: ../../howto/regex.rst:63 +#: ../../howto/regex.rst:61 msgid "Matching characters" msgstr "" -#: ../../howto/regex.rst:65 +#: ../../howto/regex.rst:63 msgid "" "Most letters and characters will simply match themselves. For example, the " "regular expression ``test`` will match the string ``test`` exactly. (You " @@ -118,7 +110,7 @@ msgid "" "``TEST`` as well; more about this later.)" msgstr "" -#: ../../howto/regex.rst:70 +#: ../../howto/regex.rst:68 msgid "" "There are exceptions to this rule; some characters are special :dfn:" "`metacharacters`, and don't match themselves. Instead, they signal that " @@ -128,17 +120,17 @@ msgid "" "do." msgstr "" -#: ../../howto/regex.rst:76 +#: ../../howto/regex.rst:74 msgid "" "Here's a complete list of the metacharacters; their meanings will be " "discussed in the rest of this HOWTO." msgstr "" -#: ../../howto/regex.rst:79 +#: ../../howto/regex.rst:77 msgid ". ^ $ * + ? { } [ ] \\ | ( )" msgstr ". ^ $ * + ? { } [ ] \\ | ( )" -#: ../../howto/regex.rst:83 +#: ../../howto/regex.rst:81 msgid "" "The first metacharacters we'll look at are ``[`` and ``]``. They're used for " "specifying a character class, which is a set of characters that you wish to " @@ -150,7 +142,7 @@ msgid "" "``[a-z]``." msgstr "" -#: ../../howto/regex.rst:92 +#: ../../howto/regex.rst:90 msgid "" "Metacharacters (except ``\\``) are not active inside classes. For example, " "``[akm$]`` will match any of the characters ``'a'``, ``'k'``, ``'m'``, or " @@ -158,7 +150,7 @@ msgid "" "it's stripped of its special nature." msgstr "" -#: ../../howto/regex.rst:97 +#: ../../howto/regex.rst:95 msgid "" "You can match the characters not listed within the class by :dfn:" "`complementing` the set. This is indicated by including a ``'^'`` as the " @@ -168,7 +160,7 @@ msgid "" "``'5'`` or a ``'^'``." msgstr "" -#: ../../howto/regex.rst:103 +#: ../../howto/regex.rst:101 msgid "" "Perhaps the most important metacharacter is the backslash, ``\\``. As in " "Python string literals, the backslash can be followed by various characters " @@ -178,14 +170,14 @@ msgid "" "remove their special meaning: ``\\[`` or ``\\\\``." msgstr "" -#: ../../howto/regex.rst:110 +#: ../../howto/regex.rst:108 msgid "" "Some of the special sequences beginning with ``'\\'`` represent predefined " "sets of characters that are often useful, such as the set of digits, the set " "of letters, or the set of anything that isn't whitespace." msgstr "" -#: ../../howto/regex.rst:115 +#: ../../howto/regex.rst:113 msgid "" "Let's take an example: ``\\w`` matches any alphanumeric character. If the " "regex pattern is expressed in bytes, this is equivalent to the class ``[a-zA-" @@ -196,7 +188,7 @@ msgid "" "the regular expression." msgstr "" -#: ../../howto/regex.rst:123 +#: ../../howto/regex.rst:121 msgid "" "The following list of special sequences isn't complete. For a complete list " "of sequences and expanded class definitions for Unicode string patterns, see " @@ -205,71 +197,71 @@ msgid "" "character that's in the appropriate category in the Unicode database." msgstr "" -#: ../../howto/regex.rst:130 +#: ../../howto/regex.rst:128 msgid "``\\d``" msgstr "``\\d``" -#: ../../howto/regex.rst:131 +#: ../../howto/regex.rst:129 msgid "Matches any decimal digit; this is equivalent to the class ``[0-9]``." msgstr "" -#: ../../howto/regex.rst:133 +#: ../../howto/regex.rst:131 msgid "``\\D``" msgstr "``\\D``" -#: ../../howto/regex.rst:134 +#: ../../howto/regex.rst:132 msgid "" "Matches any non-digit character; this is equivalent to the class ``[^0-9]``." msgstr "" -#: ../../howto/regex.rst:136 +#: ../../howto/regex.rst:134 msgid "``\\s``" msgstr "``\\s``" -#: ../../howto/regex.rst:137 +#: ../../howto/regex.rst:135 msgid "" "Matches any whitespace character; this is equivalent to the class " "``[ \\t\\n\\r\\f\\v]``." msgstr "" -#: ../../howto/regex.rst:140 +#: ../../howto/regex.rst:138 msgid "``\\S``" msgstr "``\\S``" -#: ../../howto/regex.rst:141 +#: ../../howto/regex.rst:139 msgid "" "Matches any non-whitespace character; this is equivalent to the class ``[^ " "\\t\\n\\r\\f\\v]``." msgstr "" -#: ../../howto/regex.rst:144 +#: ../../howto/regex.rst:142 msgid "``\\w``" msgstr "``\\w``" -#: ../../howto/regex.rst:145 +#: ../../howto/regex.rst:143 msgid "" "Matches any alphanumeric character; this is equivalent to the class ``[a-zA-" "Z0-9_]``." msgstr "" -#: ../../howto/regex.rst:148 +#: ../../howto/regex.rst:146 msgid "``\\W``" msgstr "``\\W``" -#: ../../howto/regex.rst:149 +#: ../../howto/regex.rst:147 msgid "" "Matches any non-alphanumeric character; this is equivalent to the class " "``[^a-zA-Z0-9_]``." msgstr "" -#: ../../howto/regex.rst:152 +#: ../../howto/regex.rst:150 msgid "" "These sequences can be included inside a character class. For example, " "``[\\s,.]`` is a character class that will match any whitespace character, " "or ``','`` or ``'.'``." msgstr "" -#: ../../howto/regex.rst:156 +#: ../../howto/regex.rst:154 msgid "" "The final metacharacter in this section is ``.``. It matches anything " "except a newline character, and there's an alternate mode (:const:`re." @@ -277,11 +269,11 @@ msgid "" "want to match \"any character\"." msgstr "" -#: ../../howto/regex.rst:163 +#: ../../howto/regex.rst:161 msgid "Repeating things" msgstr "" -#: ../../howto/regex.rst:165 +#: ../../howto/regex.rst:163 msgid "" "Being able to match varying sets of characters is the first thing regular " "expressions can do that isn't already possible with the methods available on " @@ -290,7 +282,7 @@ msgid "" "specify that portions of the RE must be repeated a certain number of times." msgstr "" -#: ../../howto/regex.rst:171 +#: ../../howto/regex.rst:169 msgid "" "The first metacharacter for repeating things that we'll look at is ``*``. " "``*`` doesn't match the literal character ``'*'``; instead, it specifies " @@ -298,13 +290,13 @@ msgid "" "exactly once." msgstr "" -#: ../../howto/regex.rst:175 +#: ../../howto/regex.rst:173 msgid "" "For example, ``ca*t`` will match ``'ct'`` (0 ``'a'`` characters), ``'cat'`` " "(1 ``'a'``), ``'caaat'`` (3 ``'a'`` characters), and so forth." msgstr "" -#: ../../howto/regex.rst:178 +#: ../../howto/regex.rst:176 msgid "" "Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the " "matching engine will try to repeat it as many times as possible. If later " @@ -312,7 +304,7 @@ msgid "" "and try again with fewer repetitions." msgstr "" -#: ../../howto/regex.rst:183 +#: ../../howto/regex.rst:181 msgid "" "A step-by-step example will make this more obvious. Let's consider the " "expression ``a[bcd]*b``. This matches the letter ``'a'``, zero or more " @@ -320,103 +312,103 @@ msgid "" "imagine matching this RE against the string ``'abcbd'``." msgstr "" -#: ../../howto/regex.rst:189 +#: ../../howto/regex.rst:187 msgid "Step" msgstr "" -#: ../../howto/regex.rst:189 +#: ../../howto/regex.rst:187 msgid "Matched" msgstr "" -#: ../../howto/regex.rst:189 +#: ../../howto/regex.rst:187 msgid "Explanation" msgstr "" -#: ../../howto/regex.rst:191 +#: ../../howto/regex.rst:189 msgid "1" msgstr "1" -#: ../../howto/regex.rst:191 +#: ../../howto/regex.rst:189 msgid "``a``" msgstr "``a``" -#: ../../howto/regex.rst:191 +#: ../../howto/regex.rst:189 msgid "The ``a`` in the RE matches." msgstr "" -#: ../../howto/regex.rst:193 +#: ../../howto/regex.rst:191 msgid "2" msgstr "2" -#: ../../howto/regex.rst:193 +#: ../../howto/regex.rst:191 msgid "``abcbd``" msgstr "``abcbd``" -#: ../../howto/regex.rst:193 +#: ../../howto/regex.rst:191 msgid "" "The engine matches ``[bcd]*``, going as far as it can, which is to the end " "of the string." msgstr "" -#: ../../howto/regex.rst:197 +#: ../../howto/regex.rst:195 msgid "3" msgstr "3" -#: ../../howto/regex.rst:197 ../../howto/regex.rst:205 +#: ../../howto/regex.rst:195 ../../howto/regex.rst:203 msgid "*Failure*" msgstr "" -#: ../../howto/regex.rst:197 +#: ../../howto/regex.rst:195 msgid "" "The engine tries to match ``b``, but the current position is at the end of " "the string, so it fails." msgstr "" -#: ../../howto/regex.rst:202 +#: ../../howto/regex.rst:200 msgid "4" msgstr "4" -#: ../../howto/regex.rst:202 ../../howto/regex.rst:213 +#: ../../howto/regex.rst:200 ../../howto/regex.rst:211 msgid "``abcb``" msgstr "``abcb``" -#: ../../howto/regex.rst:202 +#: ../../howto/regex.rst:200 msgid "Back up, so that ``[bcd]*`` matches one less character." msgstr "" -#: ../../howto/regex.rst:205 +#: ../../howto/regex.rst:203 msgid "5" msgstr "5" -#: ../../howto/regex.rst:205 +#: ../../howto/regex.rst:203 msgid "" "Try ``b`` again, but the current position is at the last character, which is " "a ``'d'``." msgstr "" -#: ../../howto/regex.rst:209 +#: ../../howto/regex.rst:207 msgid "6" msgstr "6" -#: ../../howto/regex.rst:209 +#: ../../howto/regex.rst:207 msgid "``abc``" msgstr "``abc``" -#: ../../howto/regex.rst:209 +#: ../../howto/regex.rst:207 msgid "Back up again, so that ``[bcd]*`` is only matching ``bc``." msgstr "" -#: ../../howto/regex.rst:213 +#: ../../howto/regex.rst:211 msgid "7" msgstr "" -#: ../../howto/regex.rst:213 +#: ../../howto/regex.rst:211 msgid "" "Try ``b`` again. This time the character at the current position is " "``'b'``, so it succeeds." msgstr "" -#: ../../howto/regex.rst:219 +#: ../../howto/regex.rst:217 msgid "" "The end of the RE has now been reached, and it has matched ``'abcb'``. This " "demonstrates how the matching engine goes as far as it can at first, and if " @@ -426,7 +418,7 @@ msgid "" "the string doesn't match the RE at all." msgstr "" -#: ../../howto/regex.rst:226 +#: ../../howto/regex.rst:224 msgid "" "Another repeating metacharacter is ``+``, which matches one or more times. " "Pay careful attention to the difference between ``*`` and ``+``; ``*`` " @@ -436,7 +428,7 @@ msgid "" "``'a'``\\ s), but won't match ``'ct'``." msgstr "" -#: ../../howto/regex.rst:233 +#: ../../howto/regex.rst:231 msgid "" "There are two more repeating operators or quantifiers. The question mark " "character, ``?``, matches either once or zero times; you can think of it as " @@ -444,7 +436,7 @@ msgid "" "either ``'homebrew'`` or ``'home-brew'``." msgstr "" -#: ../../howto/regex.rst:238 +#: ../../howto/regex.rst:236 msgid "" "The most complicated quantifier is ``{m,n}``, where *m* and *n* are decimal " "integers. This quantifier means there must be at least *m* repetitions, and " @@ -453,20 +445,20 @@ msgid "" "b'``, which has four." msgstr "" -#: ../../howto/regex.rst:244 +#: ../../howto/regex.rst:242 msgid "" "You can omit either *m* or *n*; in that case, a reasonable value is assumed " "for the missing value. Omitting *m* is interpreted as a lower limit of 0, " "while omitting *n* results in an upper bound of infinity." msgstr "" -#: ../../howto/regex.rst:248 +#: ../../howto/regex.rst:246 msgid "" "The simplest case ``{m}`` matches the preceding item exactly *m* times. For " "example, ``a/{2}b`` will only match ``'a//b'``." msgstr "" -#: ../../howto/regex.rst:251 +#: ../../howto/regex.rst:249 msgid "" "Readers of a reductionist bent may notice that the three other quantifiers " "can all be expressed using this notation. ``{0,}`` is the same as ``*``, " @@ -475,11 +467,11 @@ msgid "" "shorter and easier to read." msgstr "" -#: ../../howto/regex.rst:259 +#: ../../howto/regex.rst:257 msgid "Using regular expressions" msgstr "使用正規表示式" -#: ../../howto/regex.rst:261 +#: ../../howto/regex.rst:259 msgid "" "Now that we've looked at some simple regular expressions, how do we actually " "use them in Python? The :mod:`re` module provides an interface to the " @@ -487,18 +479,18 @@ msgid "" "perform matches with them." msgstr "" -#: ../../howto/regex.rst:268 +#: ../../howto/regex.rst:266 msgid "Compiling regular expressions" msgstr "編譯正規表示式" -#: ../../howto/regex.rst:270 +#: ../../howto/regex.rst:268 msgid "" "Regular expressions are compiled into pattern objects, which have methods " "for various operations such as searching for pattern matches or performing " "string substitutions. ::" msgstr "" -#: ../../howto/regex.rst:274 +#: ../../howto/regex.rst:272 msgid "" ">>> import re\n" ">>> p = re.compile('ab*')\n" @@ -510,18 +502,18 @@ msgstr "" ">>> p\n" "re.compile('ab*')" -#: ../../howto/regex.rst:279 +#: ../../howto/regex.rst:277 msgid "" ":func:`re.compile` also accepts an optional *flags* argument, used to enable " "various special features and syntax variations. We'll go over the available " "settings later, but for now a single example will do::" msgstr "" -#: ../../howto/regex.rst:283 +#: ../../howto/regex.rst:281 msgid ">>> p = re.compile('ab*', re.IGNORECASE)" msgstr ">>> p = re.compile('ab*', re.IGNORECASE)" -#: ../../howto/regex.rst:285 +#: ../../howto/regex.rst:283 msgid "" "The RE is passed to :func:`re.compile` as a string. REs are handled as " "strings because regular expressions aren't part of the core Python language, " @@ -532,17 +524,17 @@ msgid "" "`socket` or :mod:`zlib` modules." msgstr "" -#: ../../howto/regex.rst:292 +#: ../../howto/regex.rst:290 msgid "" "Putting REs in strings keeps the Python language simpler, but has one " "disadvantage which is the topic of the next section." msgstr "" -#: ../../howto/regex.rst:299 +#: ../../howto/regex.rst:297 msgid "The backslash plague" msgstr "" -#: ../../howto/regex.rst:301 +#: ../../howto/regex.rst:299 msgid "" "As stated earlier, regular expressions use the backslash character " "(``'\\'``) to indicate special forms or to allow special characters to be " @@ -550,7 +542,7 @@ msgid "" "usage of the same character for the same purpose in string literals." msgstr "" -#: ../../howto/regex.rst:306 +#: ../../howto/regex.rst:304 msgid "" "Let's say you want to write a RE that matches the string ``\\section``, " "which might be found in a LaTeX file. To figure out what to write in the " @@ -562,39 +554,39 @@ msgid "" "*again*." msgstr "" -#: ../../howto/regex.rst:315 +#: ../../howto/regex.rst:313 msgid "Characters" msgstr "" -#: ../../howto/regex.rst:315 +#: ../../howto/regex.rst:313 msgid "Stage" msgstr "" -#: ../../howto/regex.rst:317 +#: ../../howto/regex.rst:315 msgid "``\\section``" msgstr "``\\section``" -#: ../../howto/regex.rst:317 +#: ../../howto/regex.rst:315 msgid "Text string to be matched" msgstr "" -#: ../../howto/regex.rst:319 +#: ../../howto/regex.rst:317 msgid "``\\\\section``" msgstr "``\\\\section``" -#: ../../howto/regex.rst:319 +#: ../../howto/regex.rst:317 msgid "Escaped backslash for :func:`re.compile`" msgstr "" -#: ../../howto/regex.rst:321 ../../howto/regex.rst:348 +#: ../../howto/regex.rst:319 ../../howto/regex.rst:346 msgid "``\"\\\\\\\\section\"``" msgstr "``\"\\\\\\\\section\"``" -#: ../../howto/regex.rst:321 +#: ../../howto/regex.rst:319 msgid "Escaped backslashes for a string literal" msgstr "" -#: ../../howto/regex.rst:324 +#: ../../howto/regex.rst:322 msgid "" "In short, to match a literal backslash, one has to write ``'\\\\\\\\'`` as " "the RE string, because the regular expression must be ``\\\\``, and each " @@ -603,7 +595,7 @@ msgid "" "repeated backslashes and makes the resulting strings difficult to understand." msgstr "" -#: ../../howto/regex.rst:330 +#: ../../howto/regex.rst:328 msgid "" "The solution is to use Python's raw string notation for regular expressions; " "backslashes are not handled in any special way in a string literal prefixed " @@ -613,7 +605,7 @@ msgid "" "raw string notation." msgstr "" -#: ../../howto/regex.rst:336 +#: ../../howto/regex.rst:334 msgid "" "In addition, special escape sequences that are valid in regular expressions, " "but not valid as Python string literals, now result in a :exc:" @@ -622,39 +614,39 @@ msgid "" "backslashes isn't used." msgstr "" -#: ../../howto/regex.rst:344 +#: ../../howto/regex.rst:342 msgid "Regular String" msgstr "" -#: ../../howto/regex.rst:344 +#: ../../howto/regex.rst:342 msgid "Raw string" msgstr "" -#: ../../howto/regex.rst:346 +#: ../../howto/regex.rst:344 msgid "``\"ab*\"``" msgstr "``\"ab*\"``" -#: ../../howto/regex.rst:346 +#: ../../howto/regex.rst:344 msgid "``r\"ab*\"``" msgstr "``r\"ab*\"``" -#: ../../howto/regex.rst:348 +#: ../../howto/regex.rst:346 msgid "``r\"\\\\section\"``" msgstr "``r\"\\\\section\"``" -#: ../../howto/regex.rst:350 +#: ../../howto/regex.rst:348 msgid "``\"\\\\w+\\\\s+\\\\1\"``" msgstr "``\"\\\\w+\\\\s+\\\\1\"``" -#: ../../howto/regex.rst:350 +#: ../../howto/regex.rst:348 msgid "``r\"\\w+\\s+\\1\"``" msgstr "``r\"\\w+\\s+\\1\"``" -#: ../../howto/regex.rst:355 +#: ../../howto/regex.rst:353 msgid "Performing matches" msgstr "" -#: ../../howto/regex.rst:357 +#: ../../howto/regex.rst:355 msgid "" "Once you have an object representing a compiled regular expression, what do " "you do with it? Pattern objects have several methods and attributes. Only " @@ -662,71 +654,73 @@ msgid "" "for a complete listing." msgstr "" -#: ../../howto/regex.rst:363 ../../howto/regex.rst:417 +#: ../../howto/regex.rst:361 ../../howto/regex.rst:416 #: ../../howto/regex.rst:1072 msgid "Method/Attribute" msgstr "方法/屬性" -#: ../../howto/regex.rst:363 ../../howto/regex.rst:417 +#: ../../howto/regex.rst:361 ../../howto/regex.rst:416 #: ../../howto/regex.rst:1072 msgid "Purpose" msgstr "" -#: ../../howto/regex.rst:365 -msgid "``match()``" -msgstr "``match()``" - -#: ../../howto/regex.rst:365 -msgid "Determine if the RE matches at the beginning of the string." -msgstr "" - -#: ../../howto/regex.rst:368 +#: ../../howto/regex.rst:363 msgid "``search()``" msgstr "``search()``" -#: ../../howto/regex.rst:368 +#: ../../howto/regex.rst:363 msgid "Scan through a string, looking for any location where this RE matches." msgstr "" -#: ../../howto/regex.rst:371 +#: ../../howto/regex.rst:366 +msgid "``prefixmatch()``" +msgstr "``prefixmatch()``" + +#: ../../howto/regex.rst:366 +msgid "" +"Determine if the RE matches at the beginning of the string. Previously " +"named :ref:`match() `." +msgstr "" + +#: ../../howto/regex.rst:370 msgid "``findall()``" msgstr "``findall()``" -#: ../../howto/regex.rst:371 +#: ../../howto/regex.rst:370 msgid "Find all substrings where the RE matches, and return them as a list." msgstr "" -#: ../../howto/regex.rst:374 +#: ../../howto/regex.rst:373 msgid "``finditer()``" msgstr "``finditer()``" -#: ../../howto/regex.rst:374 +#: ../../howto/regex.rst:373 msgid "" "Find all substrings where the RE matches, and return them as an :term:" "`iterator`." msgstr "" -#: ../../howto/regex.rst:378 +#: ../../howto/regex.rst:377 msgid "" -":meth:`~re.Pattern.match` and :meth:`~re.Pattern.search` return ``None`` if " -"no match can be found. If they're successful, a :ref:`match object ` instance is returned, containing information about the match: " -"where it starts and ends, the substring it matched, and more." +":meth:`~re.Pattern.search` and :meth:`~re.Pattern.prefixmatch` return " +"``None`` if no match can be found. If they're successful, a :ref:`match " +"object ` instance is returned, containing information about " +"the match: where it starts and ends, the substring it matched, and more." msgstr "" -#: ../../howto/regex.rst:383 +#: ../../howto/regex.rst:382 msgid "" "You can learn about this by interactively experimenting with the :mod:`re` " "module." msgstr "" -#: ../../howto/regex.rst:386 +#: ../../howto/regex.rst:385 msgid "" "This HOWTO uses the standard Python interpreter for its examples. First, run " "the Python interpreter, import the :mod:`re` module, and compile a RE::" msgstr "" -#: ../../howto/regex.rst:389 +#: ../../howto/regex.rst:388 msgid "" ">>> import re\n" ">>> p = re.compile('[a-z]+')\n" @@ -738,86 +732,87 @@ msgstr "" ">>> p\n" "re.compile('[a-z]+')" -#: ../../howto/regex.rst:394 +#: ../../howto/regex.rst:393 msgid "" "Now, you can try matching various strings against the RE ``[a-z]+``. An " "empty string shouldn't match at all, since ``+`` means 'one or more " -"repetitions'. :meth:`~re.Pattern.match` should return ``None`` in this case, " -"which will cause the interpreter to print no output. You can explicitly " -"print the result of :meth:`!match` to make this clear. ::" +"repetitions'. :meth:`~re.Pattern.search` should return ``None`` in this " +"case, which will cause the interpreter to print no output. You can " +"explicitly print the result of :meth:`!search` to make this clear. ::" msgstr "" -#: ../../howto/regex.rst:400 +#: ../../howto/regex.rst:399 msgid "" -">>> p.match(\"\")\n" -">>> print(p.match(\"\"))\n" +">>> p.search(\"\")\n" +">>> print(p.search(\"\"))\n" "None" msgstr "" -">>> p.match(\"\")\n" -">>> print(p.match(\"\"))\n" +">>> p.search(\"\")\n" +">>> print(p.search(\"\"))\n" "None" -#: ../../howto/regex.rst:404 +#: ../../howto/regex.rst:403 msgid "" "Now, let's try it on a string that it should match, such as ``tempo``. In " -"this case, :meth:`~re.Pattern.match` will return a :ref:`match object `, so you should store the result in a variable for later use. ::" +"this case, :meth:`~re.Pattern.search` will return a :ref:`match object " +"`, so you should store the result in a variable for later " +"use. ::" msgstr "" -#: ../../howto/regex.rst:408 +#: ../../howto/regex.rst:407 msgid "" -">>> m = p.match('tempo')\n" +">>> m = p.search('tempo')\n" ">>> m\n" "" msgstr "" -">>> m = p.match('tempo')\n" +">>> m = p.search('tempo')\n" ">>> m\n" "" -#: ../../howto/regex.rst:412 +#: ../../howto/regex.rst:411 msgid "" "Now you can query the :ref:`match object ` for information " "about the matching string. Match object instances also have several methods " "and attributes; the most important ones are:" msgstr "" -#: ../../howto/regex.rst:419 +#: ../../howto/regex.rst:418 msgid "``group()``" msgstr "``group()``" -#: ../../howto/regex.rst:419 +#: ../../howto/regex.rst:418 msgid "Return the string matched by the RE" msgstr "" -#: ../../howto/regex.rst:421 +#: ../../howto/regex.rst:420 msgid "``start()``" msgstr "``start()``" -#: ../../howto/regex.rst:421 +#: ../../howto/regex.rst:420 msgid "Return the starting position of the match" msgstr "" -#: ../../howto/regex.rst:423 +#: ../../howto/regex.rst:422 msgid "``end()``" msgstr "``end()``" -#: ../../howto/regex.rst:423 +#: ../../howto/regex.rst:422 msgid "Return the ending position of the match" msgstr "" -#: ../../howto/regex.rst:425 +#: ../../howto/regex.rst:424 msgid "``span()``" msgstr "``span()``" -#: ../../howto/regex.rst:425 +#: ../../howto/regex.rst:424 msgid "Return a tuple containing the (start, end) positions of the match" msgstr "" -#: ../../howto/regex.rst:429 +#: ../../howto/regex.rst:428 msgid "Trying these methods will soon clarify their meaning::" msgstr "" -#: ../../howto/regex.rst:431 +#: ../../howto/regex.rst:430 msgid "" ">>> m.group()\n" "'tempo'\n" @@ -833,37 +828,36 @@ msgstr "" ">>> m.span()\n" "(0, 5)" -#: ../../howto/regex.rst:438 +#: ../../howto/regex.rst:437 msgid "" ":meth:`~re.Match.group` returns the substring that was matched by the RE. :" "meth:`~re.Match.start` and :meth:`~re.Match.end` return the starting and " "ending index of the match. :meth:`~re.Match.span` returns both start and end " -"indexes in a single tuple. Since the :meth:`~re.Pattern.match` method only " -"checks if the RE matches at the start of a string, :meth:`!start` will " -"always be zero. However, the :meth:`~re.Pattern.search` method of patterns " -"scans through the string, so the match may not start at zero in that " -"case. ::" +"indexes in a single tuple. The :meth:`~re.Pattern.search` method of patterns " +"scans through the string, so the match may not start at zero. However, the :" +"meth:`~re.Pattern.prefixmatch` method only checks if the RE matches at the " +"start of a string, so :meth:`!start` will always be zero in that case. ::" msgstr "" #: ../../howto/regex.rst:446 msgid "" -">>> print(p.match('::: message'))\n" -"None\n" ">>> m = p.search('::: message'); print(m)\n" "\n" ">>> m.group()\n" "'message'\n" ">>> m.span()\n" -"(4, 11)" +"(4, 11)\n" +">>> print(p.prefixmatch('::: message'))\n" +"None" msgstr "" -">>> print(p.match('::: message'))\n" -"None\n" ">>> m = p.search('::: message'); print(m)\n" "\n" ">>> m.group()\n" "'message'\n" ">>> m.span()\n" -"(4, 11)" +"(4, 11)\n" +">>> print(p.prefixmatch('::: message'))\n" +"None" #: ../../howto/regex.rst:455 msgid "" @@ -875,14 +869,14 @@ msgstr "" #: ../../howto/regex.rst:459 msgid "" "p = re.compile( ... )\n" -"m = p.match( 'string goes here' )\n" +"m = p.search( 'string goes here' )\n" "if m:\n" " print('Match found: ', m.group())\n" "else:\n" " print('No match')" msgstr "" "p = re.compile( ... )\n" -"m = p.match( 'string goes here' )\n" +"m = p.search( 'string goes here' )\n" "if m:\n" " print('Match found: ', m.group())\n" "else:\n" @@ -950,8 +944,8 @@ msgstr "模組層級函式" #: ../../howto/regex.rst:497 msgid "" "You don't have to create a pattern object and call its methods; the :mod:" -"`re` module also provides top-level functions called :func:`~re.match`, :" -"func:`~re.search`, :func:`~re.findall`, :func:`~re.sub`, and so forth. " +"`re` module also provides top-level functions called :func:`~re.search`, :" +"func:`~re.prefixmatch`, :func:`~re.findall`, :func:`~re.sub`, and so forth. " "These functions take the same arguments as the corresponding pattern method " "with the RE string added as the first argument, and still return either " "``None`` or a :ref:`match object ` instance. ::" @@ -959,14 +953,14 @@ msgstr "" #: ../../howto/regex.rst:504 msgid "" -">>> print(re.match(r'From\\s+', 'Fromage amk'))\n" +">>> print(re.prefixmatch(r'From\\s+', 'Fromage amk'))\n" "None\n" -">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n" +">>> re.prefixmatch(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n" "" msgstr "" -">>> print(re.match(r'From\\s+', 'Fromage amk'))\n" +">>> print(re.prefixmatch(r'From\\s+', 'Fromage amk'))\n" "None\n" -">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n" +">>> re.prefixmatch(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n" "" #: ../../howto/regex.rst:509 @@ -1460,11 +1454,11 @@ msgstr "" #: ../../howto/regex.rst:814 msgid "" ">>> p = re.compile('(ab)*')\n" -">>> print(p.match('ababababab').span())\n" +">>> print(p.search('ababababab').span())\n" "(0, 10)" msgstr "" ">>> p = re.compile('(ab)*')\n" -">>> print(p.match('ababababab').span())\n" +">>> print(p.search('ababababab').span())\n" "(0, 10)" #: ../../howto/regex.rst:818 @@ -1482,14 +1476,14 @@ msgstr "" #: ../../howto/regex.rst:827 msgid "" ">>> p = re.compile('(a)b')\n" -">>> m = p.match('ab')\n" +">>> m = p.search('ab')\n" ">>> m.group()\n" "'ab'\n" ">>> m.group(0)\n" "'ab'" msgstr "" ">>> p = re.compile('(a)b')\n" -">>> m = p.match('ab')\n" +">>> m = p.search('ab')\n" ">>> m.group()\n" "'ab'\n" ">>> m.group(0)\n" @@ -1505,7 +1499,7 @@ msgstr "" #: ../../howto/regex.rst:838 msgid "" ">>> p = re.compile('(a(b)c)d')\n" -">>> m = p.match('abcd')\n" +">>> m = p.search('abcd')\n" ">>> m.group(0)\n" "'abcd'\n" ">>> m.group(1)\n" @@ -1514,7 +1508,7 @@ msgid "" "'b'" msgstr "" ">>> p = re.compile('(a(b)c)d')\n" -">>> m = p.match('abcd')\n" +">>> m = p.search('abcd')\n" ">>> m.group(0)\n" "'abcd'\n" ">>> m.group(1)\n" @@ -1642,17 +1636,17 @@ msgstr "" #: ../../howto/regex.rst:915 msgid "" -">>> m = re.match(\"([abc])+\", \"abc\")\n" +">>> m = re.search(\"([abc])+\", \"abc\")\n" ">>> m.groups()\n" "('c',)\n" -">>> m = re.match(\"(?:[abc])+\", \"abc\")\n" +">>> m = re.search(\"(?:[abc])+\", \"abc\")\n" ">>> m.groups()\n" "()" msgstr "" -">>> m = re.match(\"([abc])+\", \"abc\")\n" +">>> m = re.search(\"([abc])+\", \"abc\")\n" ">>> m.groups()\n" "('c',)\n" -">>> m = re.match(\"(?:[abc])+\", \"abc\")\n" +">>> m = re.search(\"(?:[abc])+\", \"abc\")\n" ">>> m.groups()\n" "()" @@ -1711,11 +1705,11 @@ msgstr "" #: ../../howto/regex.rst:952 msgid "" -">>> m = re.match(r'(?P\\w+) (?P\\w+)', 'Jane Doe')\n" +">>> m = re.search(r'(?P\\w+) (?P\\w+)', 'Jane Doe')\n" ">>> m.groupdict()\n" "{'first': 'Jane', 'last': 'Doe'}" msgstr "" -">>> m = re.match(r'(?P\\w+) (?P\\w+)', 'Jane Doe')\n" +">>> m = re.search(r'(?P\\w+) (?P\\w+)', 'Jane Doe')\n" ">>> m.groupdict()\n" "{'first': 'Jane', 'last': 'Doe'}" @@ -2273,39 +2267,44 @@ msgid "" "problem can be solved with a faster and simpler string method." msgstr "" -#: ../../howto/regex.rst:1278 -msgid "match() versus search()" +#: ../../howto/regex.rst:1280 +msgid "prefixmatch() (aka match) versus search()" msgstr "" -#: ../../howto/regex.rst:1280 +#: ../../howto/regex.rst:1282 msgid "" -"The :func:`~re.match` function only checks if the RE matches at the " -"beginning of the string while :func:`~re.search` will scan forward through " -"the string for a match. It's important to keep this distinction in mind. " -"Remember, :func:`!match` will only report a successful match which will " -"start at 0; if the match wouldn't start at zero, :func:`!match` will *not* " -"report it. ::" +":func:`~re.prefixmatch` was added in Python 3.15 as the :ref:`preferred name " +"` for :func:`~re.match`. Before this, it was only " +"known as :func:`!match` and the distinction with :func:`~re.search` was " +"often misunderstood." msgstr "" -#: ../../howto/regex.rst:1286 +#: ../../howto/regex.rst:1287 msgid "" -">>> print(re.match('super', 'superstition').span())\n" +":func:`!prefixmatch` aka :func:`!match` only checks if the RE matches at the " +"beginning of the string while :func:`!search` scans forward through the " +"string for a match. ::" +msgstr "" + +#: ../../howto/regex.rst:1291 +msgid "" +">>> print(re.prefixmatch('super', 'superstition').span())\n" "(0, 5)\n" -">>> print(re.match('super', 'insuperable'))\n" +">>> print(re.prefixmatch('super', 'insuperable'))\n" "None" msgstr "" -">>> print(re.match('super', 'superstition').span())\n" +">>> print(re.prefixmatch('super', 'superstition').span())\n" "(0, 5)\n" -">>> print(re.match('super', 'insuperable'))\n" +">>> print(re.prefixmatch('super', 'insuperable'))\n" "None" -#: ../../howto/regex.rst:1291 +#: ../../howto/regex.rst:1296 msgid "" -"On the other hand, :func:`~re.search` will scan forward through the string, " +"On the other hand, :func:`~re.search` scans forward through the string, " "reporting the first match it finds. ::" msgstr "" -#: ../../howto/regex.rst:1294 +#: ../../howto/regex.rst:1299 msgid "" ">>> print(re.search('super', 'superstition').span())\n" "(0, 5)\n" @@ -2317,30 +2316,17 @@ msgstr "" ">>> print(re.search('super', 'insuperable').span())\n" "(2, 7)" -#: ../../howto/regex.rst:1299 +#: ../../howto/regex.rst:1304 msgid "" -"Sometimes you'll be tempted to keep using :func:`re.match`, and just add ``." -"*`` to the front of your RE. Resist this temptation and use :func:`re." -"search` instead. The regular expression compiler does some analysis of REs " -"in order to speed up the process of looking for a match. One such analysis " -"figures out what the first character of a match must be; for example, a " -"pattern starting with ``Crow`` must match starting with a ``'C'``. The " -"analysis lets the engine quickly scan through the string looking for the " -"starting character, only trying the full match if a ``'C'`` is found." +"This distinction is important to remember when using the old :func:`~re." +"match` name in code requiring compatibility with older Python versions." msgstr "" -#: ../../howto/regex.rst:1308 -msgid "" -"Adding ``.*`` defeats this optimization, requiring scanning to the end of " -"the string and then backtracking to find a match for the rest of the RE. " -"Use :func:`re.search` instead." -msgstr "" - -#: ../../howto/regex.rst:1314 +#: ../../howto/regex.rst:1309 msgid "Greedy versus non-greedy" msgstr "" -#: ../../howto/regex.rst:1316 +#: ../../howto/regex.rst:1311 msgid "" "When repeating a regular expression, as in ``a*``, the resulting action is " "to consume as much of the pattern as possible. This fact often bites you " @@ -2349,25 +2335,25 @@ msgid "" "HTML tag doesn't work because of the greedy nature of ``.*``. ::" msgstr "" -#: ../../howto/regex.rst:1322 +#: ../../howto/regex.rst:1317 msgid "" ">>> s = 'Title'\n" ">>> len(s)\n" "32\n" -">>> print(re.match('<.*>', s).span())\n" +">>> print(re.prefixmatch('<.*>', s).span())\n" "(0, 32)\n" -">>> print(re.match('<.*>', s).group())\n" +">>> print(re.prefixmatch('<.*>', s).group())\n" "Title" msgstr "" ">>> s = 'Title'\n" ">>> len(s)\n" "32\n" -">>> print(re.match('<.*>', s).span())\n" +">>> print(re.prefixmatch('<.*>', s).span())\n" "(0, 32)\n" -">>> print(re.match('<.*>', s).group())\n" +">>> print(re.prefixmatch('<.*>', s).group())\n" "Title" -#: ../../howto/regex.rst:1330 +#: ../../howto/regex.rst:1325 msgid "" "The RE matches the ``'<'`` in ``''``, and the ``.*`` consumes the rest " "of the string. There's still more left in the RE, though, and the ``>`` " @@ -2377,7 +2363,7 @@ msgid "" "``''``, which isn't what you want." msgstr "" -#: ../../howto/regex.rst:1337 +#: ../../howto/regex.rst:1332 msgid "" "In this case, the solution is to use the non-greedy quantifiers ``*?``, ``+?" "``, ``??``, or ``{m,n}?``, which match as *little* text as possible. In the " @@ -2386,15 +2372,15 @@ msgid "" "retrying the ``'>'`` at every step. This produces just the right result::" msgstr "" -#: ../../howto/regex.rst:1343 +#: ../../howto/regex.rst:1338 msgid "" -">>> print(re.match('<.*?>', s).group())\n" +">>> print(re.prefixmatch('<.*?>', s).group())\n" "" msgstr "" -">>> print(re.match('<.*?>', s).group())\n" +">>> print(re.prefixmatch('<.*?>', s).group())\n" "" -#: ../../howto/regex.rst:1346 +#: ../../howto/regex.rst:1341 msgid "" "(Note that parsing HTML or XML with regular expressions is painful. Quick-" "and-dirty patterns will handle common cases, but HTML and XML have special " @@ -2404,11 +2390,11 @@ msgid "" "such tasks.)" msgstr "" -#: ../../howto/regex.rst:1354 +#: ../../howto/regex.rst:1349 msgid "Using re.VERBOSE" msgstr "" -#: ../../howto/regex.rst:1356 +#: ../../howto/regex.rst:1351 msgid "" "By now you've probably noticed that regular expressions are a very compact " "notation, but they're not terribly readable. REs of moderate complexity can " @@ -2416,14 +2402,14 @@ msgid "" "making them difficult to read and understand." msgstr "" -#: ../../howto/regex.rst:1361 +#: ../../howto/regex.rst:1356 msgid "" "For such REs, specifying the :const:`re.VERBOSE` flag when compiling the " "regular expression can be helpful, because it allows you to format the " "regular expression more clearly." msgstr "" -#: ../../howto/regex.rst:1365 +#: ../../howto/regex.rst:1360 msgid "" "The ``re.VERBOSE`` flag has several effects. Whitespace in the regular " "expression that *isn't* inside a character class is ignored. This means " @@ -2434,7 +2420,7 @@ msgid "" "quoted strings, this enables REs to be formatted more neatly::" msgstr "" -#: ../../howto/regex.rst:1373 +#: ../../howto/regex.rst:1368 msgid "" "pat = re.compile(r\"\"\"\n" " \\s* # Skip leading whitespace\n" @@ -2446,19 +2432,19 @@ msgid "" "\"\"\", re.VERBOSE)" msgstr "" -#: ../../howto/regex.rst:1382 +#: ../../howto/regex.rst:1377 msgid "This is far more readable than::" msgstr "" -#: ../../howto/regex.rst:1384 +#: ../../howto/regex.rst:1379 msgid "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" msgstr "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" -#: ../../howto/regex.rst:1388 +#: ../../howto/regex.rst:1383 msgid "Feedback" msgstr "" -#: ../../howto/regex.rst:1390 +#: ../../howto/regex.rst:1385 msgid "" "Regular expressions are a complicated topic. Did this document help you " "understand them? Were there parts that were unclear, or problems you " @@ -2466,7 +2452,7 @@ msgid "" "improvements to the :ref:`issue tracker `." msgstr "" -#: ../../howto/regex.rst:1395 +#: ../../howto/regex.rst:1390 msgid "" "The most complete book on regular expressions is almost certainly Jeffrey " "Friedl's Mastering Regular Expressions, published by O'Reilly. " @@ -2476,3 +2462,9 @@ msgid "" "edition covered Python's now-removed :mod:`!regex` module, which won't help " "you much.) Consider checking it out from your library." msgstr "" + +#~ msgid "Author" +#~ msgstr "作者" + +#~ msgid "A.M. Kuchling " +#~ msgstr "A.M. Kuchling " diff --git a/howto/sockets.po b/howto/sockets.po index c7e63d526f2..c21b1749ca3 100644 --- a/howto/sockets.po +++ b/howto/sockets.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-22 16:55+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-08-12 15:16+0800\n" "Last-Translator: Jay \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,19 +22,11 @@ msgstr "" msgid "Socket Programming HOWTO" msgstr "Socket 程式設計指南" -#: ../../howto/sockets.rst:0 -msgid "Author" -msgstr "作者" - -#: ../../howto/sockets.rst:7 -msgid "Gordon McMillan" -msgstr "Gordon McMillan" - #: ../../howto/sockets.rst:-1 msgid "Abstract" msgstr "摘要" -#: ../../howto/sockets.rst:12 +#: ../../howto/sockets.rst:9 msgid "" "Sockets are used nearly everywhere, but are one of the most severely " "misunderstood technologies around. This is a 10,000 foot overview of " @@ -48,11 +40,11 @@ msgstr "" "sockets 正常運作。這篇文章也沒有包含細節(其中有非常多的細節),但我希望這篇" "文章能夠讓你有足夠的背景知識,以便開始正確的使用 sockets 程式設計。" -#: ../../howto/sockets.rst:20 +#: ../../howto/sockets.rst:17 msgid "Sockets" msgstr "Sockets" -#: ../../howto/sockets.rst:22 +#: ../../howto/sockets.rst:19 msgid "" "I'm only going to talk about INET (i.e. IPv4) sockets, but they account for " "at least 99% of the sockets in use. And I'll only talk about STREAM (i.e. " @@ -71,7 +63,7 @@ msgstr "" "但首先我會先談論阻塞 sockets。在處理非阻塞 sockets 之前,你需要了解它們的工作" "原理。" -#: ../../howto/sockets.rst:31 +#: ../../howto/sockets.rst:28 msgid "" "Part of the trouble with understanding these things is that \"socket\" can " "mean a number of subtly different things, depending on context. So first, " @@ -88,11 +80,11 @@ msgstr "" "「用戶端」socket; 它所連接的網路伺服器則同時使用「伺服器端」socket 和 「用戶" "端」socket 來進行通訊。" -#: ../../howto/sockets.rst:40 +#: ../../howto/sockets.rst:37 msgid "History" msgstr "歷史" -#: ../../howto/sockets.rst:42 +#: ../../howto/sockets.rst:39 msgid "" "Of the various forms of :abbr:`IPC (Inter Process Communication)`, sockets " "are by far the most popular. On any given platform, there are likely to be " @@ -103,7 +95,7 @@ msgstr "" "的。在任何特定的平台上,可能會存在其他更快速的 IPC 形式,但對於跨平台通訊來" "說,sockets 是唯一的選擇。" -#: ../../howto/sockets.rst:47 +#: ../../howto/sockets.rst:44 msgid "" "They were invented in Berkeley as part of the BSD flavor of Unix. They " "spread like wildfire with the internet. With good reason --- the combination " @@ -114,18 +106,18 @@ msgstr "" "的普及而迅速蔓延開來。這是有很好的理由 — sockets 和 INET 的結合讓世界各地任何" "的機器之間的通訊變得非常簡單(至少與其它方案相比是如此)。" -#: ../../howto/sockets.rst:54 +#: ../../howto/sockets.rst:51 msgid "Creating a Socket" msgstr "建立一個 Socket" -#: ../../howto/sockets.rst:56 +#: ../../howto/sockets.rst:53 msgid "" "Roughly speaking, when you clicked on the link that brought you to this " "page, your browser did something like the following::" msgstr "" "大致上來說,當你點擊了帶你來到這個頁面的連結時,你的瀏覽器做了以下的操作: ::" -#: ../../howto/sockets.rst:59 +#: ../../howto/sockets.rst:56 msgid "" "# create an INET, STREAMing socket\n" "s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" @@ -133,7 +125,7 @@ msgid "" "s.connect((\"www.python.org\", 80))" msgstr "" -#: ../../howto/sockets.rst:64 +#: ../../howto/sockets.rst:61 msgid "" "When the ``connect`` completes, the socket ``s`` can be used to send in a " "request for the text of the page. The same socket will read the reply, and " @@ -144,7 +136,7 @@ msgstr "" "一個 socket 也會讀取回傳值,然後再被銷毀。是的,會被銷毀。用戶端 socket 通常" "只用來做一次交換(或是一小組連續交換)。" -#: ../../howto/sockets.rst:70 +#: ../../howto/sockets.rst:67 msgid "" "What happens in the web server is a bit more complex. First, the web server " "creates a \"server socket\"::" @@ -152,7 +144,7 @@ msgstr "" "網路伺服器 (web server) 的運作就稍微複雜一點。首先,網路伺服器會建立一個「伺" "服器端 socket」: ::" -#: ../../howto/sockets.rst:73 +#: ../../howto/sockets.rst:70 msgid "" "# create an INET, STREAMing socket\n" "serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" @@ -162,7 +154,7 @@ msgid "" "serversocket.listen(5)" msgstr "" -#: ../../howto/sockets.rst:80 +#: ../../howto/sockets.rst:77 msgid "" "A couple things to notice: we used ``socket.gethostname()`` so that the " "socket would be visible to the outside world. If we had used ``s." @@ -176,7 +168,7 @@ msgstr "" "bind(('127.0.0.1', 80))``,我們會得到一個「伺服器端」socket,但是只能在同一台" "機器內可見。``s.bind(('', 80))`` 指定 socket 可以透過機器的任何地址存取。" -#: ../../howto/sockets.rst:87 +#: ../../howto/sockets.rst:84 msgid "" "A second thing to note: low number ports are usually reserved for \"well " "known\" services (HTTP, SNMP etc). If you're playing around, use a nice high " @@ -185,7 +177,7 @@ msgstr "" "第二個要注意的是:數字小的連接埠 (port) 通常保留給「廣為人知的」服務(HTTP、" "SNMP等)。如果你只是想執行程式,可以使用一個數字較大的連接埠(4 位數字)。" -#: ../../howto/sockets.rst:91 +#: ../../howto/sockets.rst:88 msgid "" "Finally, the argument to ``listen`` tells the socket library that we want it " "to queue up as many as 5 connect requests (the normal max) before refusing " @@ -196,7 +188,7 @@ msgstr "" "累積達 5 個(正常的最大值)連線請求後再拒絕外部連線。如果其餘的程式碼編寫正" "確,這應該足夠了。" -#: ../../howto/sockets.rst:95 +#: ../../howto/sockets.rst:92 msgid "" "Now that we have a \"server\" socket, listening on port 80, we can enter the " "mainloop of the web server::" @@ -204,7 +196,7 @@ msgstr "" "現在我們有一個監聽 80 連接埠的「伺服器端」socket 了,我們可以進入網路伺服器的" "主迴圈了: ::" -#: ../../howto/sockets.rst:98 +#: ../../howto/sockets.rst:95 msgid "" "while True:\n" " # accept connections from outside\n" @@ -215,7 +207,7 @@ msgid "" " ct.start()" msgstr "" -#: ../../howto/sockets.rst:106 +#: ../../howto/sockets.rst:103 msgid "" "There's actually 3 general ways in which this loop could work - dispatching " "a thread to handle ``clientsocket``, create a new process to handle " @@ -241,11 +233,11 @@ msgstr "" "請求。兩個「用戶端」可以隨意的通訊 - 它們使用的是一些動態分配的連接埠,會在通" "訊結束的時候被回收並重新利用。" -#: ../../howto/sockets.rst:121 +#: ../../howto/sockets.rst:118 msgid "IPC" msgstr "IPC" -#: ../../howto/sockets.rst:123 +#: ../../howto/sockets.rst:120 msgid "" "If you need fast IPC between two processes on one machine, you should look " "into pipes or shared memory. If you do decide to use AF_INET sockets, bind " @@ -258,17 +250,17 @@ msgstr "" "請將「伺服器端」socket 綁定到 ``'localhost'``。在大多數平台上,這樣將會繞過幾" "個網路程式碼層,並且速度會更快一些。" -#: ../../howto/sockets.rst:129 +#: ../../howto/sockets.rst:126 msgid "" "The :mod:`multiprocessing` integrates cross-platform IPC into a higher-level " "API." msgstr ":mod:`multiprocessing` 將跨平台行程間通訊整合到更高層的 API 中。" -#: ../../howto/sockets.rst:134 +#: ../../howto/sockets.rst:131 msgid "Using a Socket" msgstr "使用一個 Socket" -#: ../../howto/sockets.rst:136 +#: ../../howto/sockets.rst:133 msgid "" "The first thing to note, is that the web browser's \"client\" socket and the " "web server's \"client\" socket are identical beasts. That is, this is a " @@ -284,7 +276,7 @@ msgstr "" "透過發送一個請求或者信號來開始一次通訊。但這屬於設計決策,而不是 socket 的規" "則。" -#: ../../howto/sockets.rst:143 +#: ../../howto/sockets.rst:140 msgid "" "Now there are two sets of verbs to use for communication. You can use " "``send`` and ``recv``, or you can transform your client socket into a file-" @@ -302,7 +294,7 @@ msgstr "" "容,然後直接 ``read`` 回覆。如果不使用 ``flush``,你可能會一直等待這個回覆," "因為請求可能還在你的輸出緩衝中。" -#: ../../howto/sockets.rst:152 +#: ../../howto/sockets.rst:149 msgid "" "Now we come to the major stumbling block of sockets - ``send`` and ``recv`` " "operate on the network buffers. They do not necessarily handle all the bytes " @@ -318,7 +310,7 @@ msgstr "" "(``send``) 或已清空 (``recv``) 時回傳,然後告訴你它們處理了多少位元組。*你* " "\\的責任是一直呼叫它們直到你所有的訊息處理完成。" -#: ../../howto/sockets.rst:160 +#: ../../howto/sockets.rst:157 msgid "" "When a ``recv`` returns 0 bytes, it means the other side has closed (or is " "in the process of closing) the connection. You will not receive any more " @@ -329,7 +321,7 @@ msgstr "" "閉)連線。你再也不能從這個連線上取得任何資料了。你可能還是可以成功發送資料;" "我稍後會對此進行更詳細的解釋。" -#: ../../howto/sockets.rst:165 +#: ../../howto/sockets.rst:162 msgid "" "A protocol like HTTP uses a socket for only one transfer. The client sends a " "request, then reads a reply. That's it. The socket is discarded. This means " @@ -339,7 +331,7 @@ msgstr "" "取一個回覆。就這樣,然後這個 socket 就會被銷毀。這表示者用戶端可以透過接收" "「零位元組」來檢測回覆的結束。" -#: ../../howto/sockets.rst:169 +#: ../../howto/sockets.rst:166 msgid "" "But if you plan to reuse your socket for further transfers, you need to " "realize that *there is no* :abbr:`EOT (End of Transfer)` *on a socket.* I " @@ -361,13 +353,13 @@ msgstr "" "分隔的(普通的做法),要麼是指定其長度(更好地做法),要麼透過關閉連線來結" "束。*\\ 完全由你來決定要使用哪種方式(但有些方法比其他方法來的更好)。" -#: ../../howto/sockets.rst:180 +#: ../../howto/sockets.rst:177 msgid "" "Assuming you don't want to end the connection, the simplest solution is a " "fixed length message::" msgstr "假設你不想結束連線,最簡單的方式就是使用固定長度的訊息: ::" -#: ../../howto/sockets.rst:183 +#: ../../howto/sockets.rst:180 msgid "" "class MySocket:\n" " \"\"\"demonstration class only\n" @@ -404,7 +396,7 @@ msgid "" " return b''.join(chunks)" msgstr "" -#: ../../howto/sockets.rst:217 +#: ../../howto/sockets.rst:214 msgid "" "The sending code here is usable for almost any messaging scheme - in Python " "you send strings, and you can use ``len()`` to determine its length (even if " @@ -417,7 +409,7 @@ msgstr "" "接收的程式碼變得更複雜一些。(在 C 語言中,情況沒有變得更糟,只是如果訊息中包" "含了 ``\\0`` 字元,你就不能使用 ``strlen`` 函式。)" -#: ../../howto/sockets.rst:223 +#: ../../howto/sockets.rst:220 msgid "" "The easiest enhancement is to make the first character of the message an " "indicator of message type, and have the type determine the length. Now you " @@ -433,7 +425,7 @@ msgstr "" "會以某個任意的區塊大小進行接收(4096 或 8192 通常是網路緩衝區大小的良好選" "擇),並在收到的內容中掃描分隔符號。" -#: ../../howto/sockets.rst:231 +#: ../../howto/sockets.rst:228 msgid "" "One complication to be aware of: if your conversational protocol allows " "multiple messages to be sent back to back (without some kind of reply), and " @@ -445,7 +437,7 @@ msgstr "" "應),並且你傳遞給 ``recv`` 函式一個任意的區塊大小,最後有可能讀取到下一條訊" "息的開頭。你需要將其放在一旁並保留下來,直到需要使用的時候。" -#: ../../howto/sockets.rst:237 +#: ../../howto/sockets.rst:234 msgid "" "Prefixing the message with its length (say, as 5 numeric characters) gets " "more complex, because (believe it or not), you may not get all 5 characters " @@ -463,7 +455,7 @@ msgstr "" "痛。同樣的情況也會讓你發現 ``send`` 並不總能在一次傳輸中完全清除所有內容。儘" "管已經閱讀了這篇文章,但最終還是無法解決!" -#: ../../howto/sockets.rst:246 +#: ../../howto/sockets.rst:243 msgid "" "In the interests of space, building your character, (and preserving my " "competitive position), these enhancements are left as an exercise for the " @@ -472,11 +464,11 @@ msgstr "" "為了節省篇幅、培養你的技能(並保持我的競爭優勢),這些改進方法留給讀者自行練" "習。現在讓我們開始進行清理工作。" -#: ../../howto/sockets.rst:252 +#: ../../howto/sockets.rst:249 msgid "Binary Data" msgstr "二進位資料" -#: ../../howto/sockets.rst:254 +#: ../../howto/sockets.rst:251 msgid "" "It is perfectly possible to send binary data over a socket. The major " "problem is that not all machines use the same formats for binary data. For " @@ -495,7 +487,7 @@ msgstr "" "會被表示成 ``01 00``。(譯者注:將一個多位數的低位放在較小的位址處,高位放在" "較大的位址處,則稱小端序;反之則稱大端序。)" -#: ../../howto/sockets.rst:262 +#: ../../howto/sockets.rst:259 msgid "" "Socket libraries have calls for converting 16 and 32 bit integers - ``ntohl, " "htonl, ntohs, htons`` where \"n\" means *network* and \"h\" means *host*, " @@ -509,7 +501,7 @@ msgstr "" "式不會做任何操作,但當主機的位元組順序相反時,這些函式會適當的交換位元組順" "序。" -#: ../../howto/sockets.rst:268 +#: ../../howto/sockets.rst:265 msgid "" "In these days of 64-bit machines, the ASCII representation of binary data is " "frequently smaller than the binary representation. That's because a " @@ -523,11 +515,11 @@ msgstr "" "位元組,而完整的 64 位元整數則是 8 個位元組。當然,這對固定長度的訊息來說不太" "適合,需要自行決定。" -#: ../../howto/sockets.rst:277 +#: ../../howto/sockets.rst:274 msgid "Disconnecting" msgstr "結束連線" -#: ../../howto/sockets.rst:279 +#: ../../howto/sockets.rst:276 msgid "" "Strictly speaking, you're supposed to use ``shutdown`` on a socket before " "you ``close`` it. The ``shutdown`` is an advisory to the socket at the " @@ -545,7 +537,7 @@ msgstr "" "``close`` 跟 ``shutdown(); close()`` 是一樣的。所以在大多數情況下,不需要再特" "地使用 ``shutdown`` 了。" -#: ../../howto/sockets.rst:287 +#: ../../howto/sockets.rst:284 msgid "" "One way to use ``shutdown`` effectively is in an HTTP-like exchange. The " "client sends a request and then does a ``shutdown(1)``. This tells the " @@ -560,7 +552,7 @@ msgstr "" "到完整的請求。伺服器發送回覆,如果 ``send`` 成功完成,那麼用戶端確實在持續接" "收。" -#: ../../howto/sockets.rst:294 +#: ../../howto/sockets.rst:291 msgid "" "Python takes the automatic shutdown a step further, and says that when a " "socket is garbage collected, it will automatically do a ``close`` if it's " @@ -575,11 +567,11 @@ msgstr "" "是慢了一步,而無期限的等待。*請務必* \\在使用完畢後使用 ``close`` 關閉你的 " "sockets。" -#: ../../howto/sockets.rst:302 +#: ../../howto/sockets.rst:299 msgid "When Sockets Die" msgstr "Sockets 何時銷毀" -#: ../../howto/sockets.rst:304 +#: ../../howto/sockets.rst:301 msgid "" "Probably the worst thing about using blocking sockets is what happens when " "the other side comes down hard (without doing a ``close``). Your socket is " @@ -601,11 +593,11 @@ msgstr "" "緒 - 執行緒比行程更有效的部分原因是它們避免了與自動回收資源相關的開銷。換句話" "說,如果你確實設法終止了執行緒,整個行程可能會出現問題。" -#: ../../howto/sockets.rst:318 +#: ../../howto/sockets.rst:315 msgid "Non-blocking Sockets" msgstr "非阻塞的 Sockets" -#: ../../howto/sockets.rst:320 +#: ../../howto/sockets.rst:317 msgid "" "If you've understood the preceding, you already know most of what you need " "to know about the mechanics of using sockets. You'll still use the same " @@ -616,7 +608,7 @@ msgstr "" "識,你仍然會以非常相似的方式使用相同的函式。就這樣而已,如果你做的對,你的程" "式就會是近乎完美的。" -#: ../../howto/sockets.rst:325 +#: ../../howto/sockets.rst:322 msgid "" "In Python, you use ``socket.setblocking(False)`` to make it non-blocking. In " "C, it's more complex, (for one thing, you'll need to choose between the BSD " @@ -631,7 +623,7 @@ msgstr "" "是一樣的,你要在建立 socket 後但在使用它之前執行此操作。(實際上,如果你願意" "的話,你甚至可以來回切換。)" -#: ../../howto/sockets.rst:332 +#: ../../howto/sockets.rst:329 msgid "" "The major mechanical difference is that ``send``, ``recv``, ``connect`` and " "``accept`` can return without having done anything. You have (of course) a " @@ -645,11 +637,11 @@ msgstr "" "這些操作通常會讓自己抓狂。如果你不相信我,不妨試試看。你的應用程式會變得臃" "腫、錯誤百出,並且占用 CPU。所以,讓我們跳過無腦的解決方案,使用正確的方式。" -#: ../../howto/sockets.rst:339 +#: ../../howto/sockets.rst:336 msgid "Use ``select``." msgstr "使用 ``select``。" -#: ../../howto/sockets.rst:341 +#: ../../howto/sockets.rst:338 msgid "" "In C, coding ``select`` is fairly complex. In Python, it's a piece of cake, " "but it's close enough to the C version that if you understand ``select`` in " @@ -659,7 +651,7 @@ msgstr "" "本非常類似,如果你理解了 Python 中的 ``select``,在 C 中處理它時也不會有太大" "的困難: ::" -#: ../../howto/sockets.rst:345 +#: ../../howto/sockets.rst:342 msgid "" "ready_to_read, ready_to_write, in_error = \\\n" " select.select(\n" @@ -675,7 +667,7 @@ msgstr "" " potential_errs,\n" " timeout)" -#: ../../howto/sockets.rst:352 +#: ../../howto/sockets.rst:349 msgid "" "You pass ``select`` three lists: the first contains all sockets that you " "might want to try reading; the second all the sockets you might want to try " @@ -691,7 +683,7 @@ msgstr "" "``select`` 呼叫是阻塞的,但你可以設置超時。通常這是一個明智的做法 - 除非有充" "分的理由,否則給它一個很長的超時(比如一分鐘)。" -#: ../../howto/sockets.rst:360 +#: ../../howto/sockets.rst:357 msgid "" "In return, you will get three lists. They contain the sockets that are " "actually readable, writable and in error. Each of these lists is a subset " @@ -700,7 +692,7 @@ msgstr "" "作為回傳,你將獲得三個列表。它們包含實際上可讀取、可寫入和出錯的 sockets。這" "些列表中的每一個都是你傳入的相應列表的子集(可能為空)。" -#: ../../howto/sockets.rst:364 +#: ../../howto/sockets.rst:361 msgid "" "If a socket is in the output readable list, you can be as-close-to-certain-" "as-we-ever-get-in-this-business that a ``recv`` on that socket will return " @@ -715,7 +707,7 @@ msgstr "" "容*\\ 總比什麼都沒有好。(實際上,任何比較正常的 socket 都會以可寫的方式回傳 " "- 這只是意味者「外送網路 (outbound network)」的緩衝空間是可用的。)" -#: ../../howto/sockets.rst:371 +#: ../../howto/sockets.rst:368 msgid "" "If you have a \"server\" socket, put it in the potential_readers list. If it " "comes out in the readable list, your ``accept`` will (almost certainly) " @@ -728,7 +720,7 @@ msgstr "" "新的 socket 去 ``connect`` 到其他地方,請將它放在 potential_writers 列表中," "如果它在可寫列表中出現,那麼他有可能已經連接上了。" -#: ../../howto/sockets.rst:377 +#: ../../howto/sockets.rst:374 msgid "" "Actually, ``select`` can be handy even with blocking sockets. It's one way " "of determining whether you will block - the socket returns as readable when " @@ -740,7 +732,7 @@ msgstr "" "否會被阻塞的方法之一 - 當緩衝區中有某些內容時, socket 會回傳為可讀。然而,這" "仍然無法解決判斷另一端是否完成,或者只是忙於其他事情的問題。" -#: ../../howto/sockets.rst:382 +#: ../../howto/sockets.rst:379 msgid "" "**Portability alert**: On Unix, ``select`` works both with the sockets and " "files. Don't try this on Windows. On Windows, ``select`` works with sockets " @@ -753,3 +745,9 @@ msgstr "" "注意,在 C 語言中,許多更進階的 socket 選項在 Windows 上有不同的實現方式。實" "際上,在 Windows 上,我通常會使用執行緒(這非常,非常有效)與我的 sockets 一" "起使用。" + +#~ msgid "Author" +#~ msgstr "作者" + +#~ msgid "Gordon McMillan" +#~ msgstr "Gordon McMillan" diff --git a/howto/sorting.po b/howto/sorting.po index 6cad55f6989..159187edb33 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-12-20 19:16+0800\n" "Last-Translator: Li-Hung Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,15 +23,7 @@ msgstr "" msgid "Sorting Techniques" msgstr "排序技法" -#: ../../howto/sorting.rst:0 -msgid "Author" -msgstr "作者" - #: ../../howto/sorting.rst:6 -msgid "Andrew Dalke and Raymond Hettinger" -msgstr "Andrew Dalke 和 Raymond Hettinger" - -#: ../../howto/sorting.rst:9 msgid "" "Python lists have a built-in :meth:`list.sort` method that modifies the list " "in-place. There is also a :func:`sorted` built-in function that builds a " @@ -41,17 +33,17 @@ msgstr "" "列,也有一個內建的 :func:`sorted` 函式可以排序可疊代物件 (iterable) 並建立一" "個新的排序好的串列。" -#: ../../howto/sorting.rst:13 +#: ../../howto/sorting.rst:10 msgid "" "In this document, we explore the various techniques for sorting data using " "Python." msgstr "在這份文件裡,我們探索使用 Python 排序資料的各種方法。" -#: ../../howto/sorting.rst:17 +#: ../../howto/sorting.rst:14 msgid "Sorting Basics" msgstr "基礎排序" -#: ../../howto/sorting.rst:19 +#: ../../howto/sorting.rst:16 msgid "" "A simple ascending sort is very easy: just call the :func:`sorted` function. " "It returns a new sorted list:" @@ -59,7 +51,7 @@ msgstr "" "單純的升冪排序很容易做到:只要呼叫 :func:`sorted` 函式,它會回傳一個新的串" "列:" -#: ../../howto/sorting.rst:22 +#: ../../howto/sorting.rst:19 msgid "" ">>> sorted([5, 2, 3, 1, 4])\n" "[1, 2, 3, 4, 5]" @@ -67,7 +59,7 @@ msgstr "" ">>> sorted([5, 2, 3, 1, 4])\n" "[1, 2, 3, 4, 5]" -#: ../../howto/sorting.rst:27 +#: ../../howto/sorting.rst:24 msgid "" "You can also use the :meth:`list.sort` method. It modifies the list in-place " "(and returns ``None`` to avoid confusion). Usually it's less convenient " @@ -78,7 +70,7 @@ msgstr "" "混淆)。它通常會比 :func:`sorted` 來得不方便——但如果你不需要保留原始串列的" "話,它會稍微有效率一點。" -#: ../../howto/sorting.rst:32 +#: ../../howto/sorting.rst:29 msgid "" ">>> a = [5, 2, 3, 1, 4]\n" ">>> a.sort()\n" @@ -90,7 +82,7 @@ msgstr "" ">>> a\n" "[1, 2, 3, 4, 5]" -#: ../../howto/sorting.rst:39 +#: ../../howto/sorting.rst:36 msgid "" "Another difference is that the :meth:`list.sort` method is only defined for " "lists. In contrast, the :func:`sorted` function accepts any iterable." @@ -98,7 +90,7 @@ msgstr "" "另一個差異是 :meth:`list.sort` 方法只有定義在串列上,而 :func:`sorted` 函式可" "以接受任何可疊代物件。" -#: ../../howto/sorting.rst:42 +#: ../../howto/sorting.rst:39 msgid "" ">>> sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'})\n" "[1, 2, 3, 4, 5]" @@ -106,11 +98,11 @@ msgstr "" ">>> sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'})\n" "[1, 2, 3, 4, 5]" -#: ../../howto/sorting.rst:48 +#: ../../howto/sorting.rst:45 msgid "Key Functions" msgstr "鍵函式 (key functions)" -#: ../../howto/sorting.rst:50 +#: ../../howto/sorting.rst:47 msgid "" "The :meth:`list.sort` method and the functions :func:`sorted`, :func:`min`, :" "func:`max`, :func:`heapq.nsmallest`, and :func:`heapq.nlargest` have a *key* " @@ -121,13 +113,13 @@ msgstr "" "`heapq.nsmallest` 及 :func:`heapq.nlargest` 函式都有一個參數 *key* 可以指定一" "個函式(或其它可呼叫物件 (callable)),其會在每個串列元素做比較前被呼叫。" -#: ../../howto/sorting.rst:56 +#: ../../howto/sorting.rst:53 msgid "" "For example, here's a case-insensitive string comparison using :meth:`str." "casefold`:" msgstr "例如使用 :meth:`str.casefold` 來做不區分大小寫的字串比對:" -#: ../../howto/sorting.rst:59 +#: ../../howto/sorting.rst:56 msgid "" ">>> sorted(\"This is a test string from Andrew\".split(), key=str.casefold)\n" "['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']" @@ -135,7 +127,7 @@ msgstr "" ">>> sorted(\"This is a test string from Andrew\".split(), key=str.casefold)\n" "['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']" -#: ../../howto/sorting.rst:64 +#: ../../howto/sorting.rst:61 msgid "" "The value of the *key* parameter should be a function (or other callable) " "that takes a single argument and returns a key to use for sorting purposes. " @@ -146,14 +138,14 @@ msgstr "" "傳一個用來排序的鍵。因為對每個輸入來說鍵函式只會被呼叫一次,所以這個做法是快" "速的。" -#: ../../howto/sorting.rst:69 +#: ../../howto/sorting.rst:66 msgid "" "A common pattern is to sort complex objects using some of the object's " "indices as keys. For example:" msgstr "" "一個常見的模式是在排序複雜物件的時候使用一部分物件的索引值當作鍵,例如:" -#: ../../howto/sorting.rst:72 +#: ../../howto/sorting.rst:69 msgid "" ">>> student_tuples = [\n" "... ('john', 'A', 15),\n" @@ -171,12 +163,12 @@ msgstr "" ">>> sorted(student_tuples, key=lambda student: student[2]) # 依照年齡排序\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:82 +#: ../../howto/sorting.rst:79 msgid "" "The same technique works for objects with named attributes. For example:" msgstr "相同的做法也適用在有命名屬性的物件,例如:" -#: ../../howto/sorting.rst:84 +#: ../../howto/sorting.rst:81 msgid "" ">>> class Student:\n" "... def __init__(self, name, grade, age):\n" @@ -212,7 +204,7 @@ msgstr "" "序\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:102 +#: ../../howto/sorting.rst:99 msgid "" "Objects with named attributes can be made by a regular class as shown above, " "or they can be instances of :class:`~dataclasses.dataclass` or a :term:" @@ -221,11 +213,11 @@ msgstr "" "具有命名屬性的物件可以如上方的方式使用一個常規的類別建立,或是他們可以是 :" "class:`~dataclasses.dataclass` 的實例或是一個 :term:`named tuple`。" -#: ../../howto/sorting.rst:107 +#: ../../howto/sorting.rst:104 msgid "Operator Module Functions and Partial Function Evaluation" msgstr "Operator 模組函式以及部份函式 (partial function) 評估" -#: ../../howto/sorting.rst:109 +#: ../../howto/sorting.rst:106 msgid "" "The :term:`key function` patterns shown above are very common, so Python " "provides convenience functions to make accessor functions easier and faster. " @@ -237,11 +229,11 @@ msgstr "" "itemgetter`、:func:`~operator.attrgetter` 及 :func:`~operator.methodcaller` " "函式可以使用。" -#: ../../howto/sorting.rst:114 +#: ../../howto/sorting.rst:111 msgid "Using those functions, the above examples become simpler and faster:" msgstr "使用這些函式讓上面的範例變得更簡單且快速:" -#: ../../howto/sorting.rst:116 +#: ../../howto/sorting.rst:113 msgid "" ">>> from operator import itemgetter, attrgetter\n" "\n" @@ -259,14 +251,14 @@ msgstr "" ">>> sorted(student_objects, key=attrgetter('age'))\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:126 +#: ../../howto/sorting.rst:123 msgid "" "The operator module functions allow multiple levels of sorting. For example, " "to sort by *grade* then by *age*:" msgstr "" "operator 模組的函式允許多層的排序,例如先用 *grade* 排序再用 *age* 排序:" -#: ../../howto/sorting.rst:129 +#: ../../howto/sorting.rst:126 msgid "" ">>> sorted(student_tuples, key=itemgetter(1,2))\n" "[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]\n" @@ -280,7 +272,7 @@ msgstr "" ">>> sorted(student_objects, key=attrgetter('grade', 'age'))\n" "[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]" -#: ../../howto/sorting.rst:137 +#: ../../howto/sorting.rst:134 msgid "" "The :mod:`functools` module provides another helpful tool for making key-" "functions. The :func:`~functools.partial` function can reduce the `arity " @@ -291,7 +283,7 @@ msgstr "" "partial` 函式可以減少多引數函式的\\ `引數數目 `_,使其更適合作為鍵函式使用。" -#: ../../howto/sorting.rst:142 +#: ../../howto/sorting.rst:139 msgid "" ">>> from functools import partial\n" ">>> from unicodedata import normalize\n" @@ -315,11 +307,11 @@ msgstr "" ">>> sorted(names, key=partial(normalize, 'NFC'))\n" "['Abe', 'Eloise', 'Nubia', 'Núñez', 'Zeke', 'Zoë', 'Åbjørn', 'Élana']" -#: ../../howto/sorting.rst:156 +#: ../../howto/sorting.rst:153 msgid "Ascending and Descending" msgstr "升冪與降冪" -#: ../../howto/sorting.rst:158 +#: ../../howto/sorting.rst:155 msgid "" "Both :meth:`list.sort` and :func:`sorted` accept a *reverse* parameter with " "a boolean value. This is used to flag descending sorts. For example, to get " @@ -328,7 +320,7 @@ msgstr "" ":meth:`list.sort` 和 :func:`sorted` 都有一個 boolean 參數 *reverse* 用來表示" "是否要降冪排序。例如將學生資料依據 *age* 做降冪排序:" -#: ../../howto/sorting.rst:162 +#: ../../howto/sorting.rst:159 msgid "" ">>> sorted(student_tuples, key=itemgetter(2), reverse=True)\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]\n" @@ -342,11 +334,11 @@ msgstr "" ">>> sorted(student_objects, key=attrgetter('age'), reverse=True)\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" -#: ../../howto/sorting.rst:171 +#: ../../howto/sorting.rst:168 msgid "Sort Stability and Complex Sorts" msgstr "排序穩定性與複合排序" -#: ../../howto/sorting.rst:173 +#: ../../howto/sorting.rst:170 msgid "" "Sorts are guaranteed to be `stable `_\\. That means that when multiple records have " @@ -356,7 +348,7 @@ msgstr "" "Sorting_algorithm#Stability>`_,意思是當有多筆資料有相同的鍵,它們會維持原來" "的順序。" -#: ../../howto/sorting.rst:177 +#: ../../howto/sorting.rst:174 msgid "" ">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" ">>> sorted(data, key=itemgetter(0))\n" @@ -366,7 +358,7 @@ msgstr "" ">>> sorted(data, key=itemgetter(0))\n" "[('blue', 1), ('blue', 2), ('red', 1), ('red', 2)]" -#: ../../howto/sorting.rst:183 +#: ../../howto/sorting.rst:180 msgid "" "Notice how the two records for *blue* retain their original order so that " "``('blue', 1)`` is guaranteed to precede ``('blue', 2)``." @@ -374,7 +366,7 @@ msgstr "" "可以注意到有兩筆資料的鍵都是 *blue*,它們會維持本來的順序,即 ``('blue', " "1)`` 保證在 ``('blue', 2)`` 前面。" -#: ../../howto/sorting.rst:186 +#: ../../howto/sorting.rst:183 msgid "" "This wonderful property lets you build complex sorts in a series of sorting " "steps. For example, to sort the student data by descending *grade* and then " @@ -384,7 +376,7 @@ msgstr "" "做降冪排序再用 *age* 做升冪排序,你可以先用 *age* 排序一遍再用 *grade* 排序一" "遍:" -#: ../../howto/sorting.rst:190 +#: ../../howto/sorting.rst:187 msgid "" ">>> s = sorted(student_objects, key=attrgetter('age')) # sort on " "secondary key\n" @@ -397,7 +389,7 @@ msgstr "" "冪排序\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:196 +#: ../../howto/sorting.rst:193 msgid "" "This can be abstracted out into a wrapper function that can take a list and " "tuples of field and order to sort them on multiple passes." @@ -405,7 +397,7 @@ msgstr "" "這可以抽出一個包裝函式 (wrapper function),接受一個串列及多個欄位及升降冪的元" "組為引數,來對這個串列排序多遍。" -#: ../../howto/sorting.rst:199 +#: ../../howto/sorting.rst:196 msgid "" ">>> def multisort(xs, specs):\n" "... for key, reverse in reversed(specs):\n" @@ -423,7 +415,7 @@ msgstr "" ">>> multisort(list(student_objects), (('grade', True), ('age', False)))\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:209 +#: ../../howto/sorting.rst:206 msgid "" "The `Timsort `_ algorithm used in " "Python does multiple sorts efficiently because it can take advantage of any " @@ -432,36 +424,36 @@ msgstr "" "Python 裡使用的 `Timsort `_ 演算法,因" "為能利用資料集裡已經有的順序,可以有效率地做多次排序。" -#: ../../howto/sorting.rst:214 +#: ../../howto/sorting.rst:211 msgid "Decorate-Sort-Undecorate" msgstr "裝飾-排序-移除裝飾 (decorate-sort-undecorate)" -#: ../../howto/sorting.rst:216 +#: ../../howto/sorting.rst:213 msgid "This idiom is called Decorate-Sort-Undecorate after its three steps:" msgstr "這個用語的來源是因為它做了以下三件事情:" -#: ../../howto/sorting.rst:218 +#: ../../howto/sorting.rst:215 msgid "" "First, the initial list is decorated with new values that control the sort " "order." msgstr "首先,原始串列會裝飾 (decorated) 上新的值用來控制排序的順序。" -#: ../../howto/sorting.rst:220 +#: ../../howto/sorting.rst:217 msgid "Second, the decorated list is sorted." msgstr "接下來,排序裝飾過的串列。" -#: ../../howto/sorting.rst:222 +#: ../../howto/sorting.rst:219 msgid "" "Finally, the decorations are removed, creating a list that contains only the " "initial values in the new order." msgstr "最後,裝飾會被移除,並以新的順序產生一個只包含原始值的串列。" -#: ../../howto/sorting.rst:225 +#: ../../howto/sorting.rst:222 msgid "" "For example, to sort the student data by *grade* using the DSU approach:" msgstr "例如用上面說的方式來以 *grade* 排序學生資料:" -#: ../../howto/sorting.rst:227 +#: ../../howto/sorting.rst:224 msgid "" ">>> decorated = [(student.grade, i, student) for i, student in " "enumerate(student_objects)]\n" @@ -475,7 +467,7 @@ msgstr "" ">>> [student for grade, i, student in decorated] # 移除裝飾\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" -#: ../../howto/sorting.rst:234 +#: ../../howto/sorting.rst:231 msgid "" "This idiom works because tuples are compared lexicographically; the first " "items are compared; if they are the same then the second items are compared, " @@ -484,7 +476,7 @@ msgstr "" "這個方式會有效是因為元組是依照字典順序 (lexicographically) 來比較,先比較第一" "個項目,如果一樣再比較第二個項目,並依此類推。" -#: ../../howto/sorting.rst:238 +#: ../../howto/sorting.rst:235 msgid "" "It is not strictly necessary in all cases to include the index *i* in the " "decorated list, but including it gives two benefits:" @@ -492,7 +484,7 @@ msgstr "" "在所有情況下都把索引 *i* 加入已裝飾的串列並不是絕對需要的,但這樣做會有兩個好" "處:" -#: ../../howto/sorting.rst:241 +#: ../../howto/sorting.rst:238 msgid "" "The sort is stable -- if two items have the same key, their order will be " "preserved in the sorted list." @@ -500,7 +492,7 @@ msgstr "" "排序會是穩定的 -- 如果兩個項目有相同的鍵,它們在排序好的串列中會保持原來的順" "序。" -#: ../../howto/sorting.rst:244 +#: ../../howto/sorting.rst:241 msgid "" "The original items do not have to be comparable because the ordering of the " "decorated tuples will be determined by at most the first two items. So for " @@ -510,7 +502,7 @@ msgstr "" "原始項目不需要是可以比較的,因為最多只會用到前兩個項目就能決定裝飾過的元組的" "順序。例如原始串列可以包含不能直接用來排序的複數。" -#: ../../howto/sorting.rst:249 +#: ../../howto/sorting.rst:246 msgid "" "Another name for this idiom is `Schwartzian transform `_\\, after Randal L. Schwartz, who " @@ -520,23 +512,23 @@ msgstr "" "Schwartzian_transform>`_,是由於 Randal L. Schwartz 讓這個方法在 Perl 程式設" "計師間普及。" -#: ../../howto/sorting.rst:253 +#: ../../howto/sorting.rst:250 msgid "" "Now that Python sorting provides key-functions, this technique is not often " "needed." msgstr "而因為 Python 的排序提供了鍵函式,已經不太需要用到這個方法了。" -#: ../../howto/sorting.rst:256 +#: ../../howto/sorting.rst:253 msgid "Comparison Functions" msgstr "比較函式 (comparison functions)" -#: ../../howto/sorting.rst:258 +#: ../../howto/sorting.rst:255 msgid "" "Unlike key functions that return an absolute value for sorting, a comparison " "function computes the relative ordering for two inputs." msgstr "不像鍵函式回傳一個用來排序的值,比較函式計算兩個輸入間的相對順序。" -#: ../../howto/sorting.rst:261 +#: ../../howto/sorting.rst:258 msgid "" "For example, a `balance scale `_ compares two samples giving a " @@ -549,7 +541,7 @@ msgstr "" "重。同樣地,像是 ``cmp(a, b)`` 這樣的比較函式會回傳負數代表小於、0 代表輸入相" "同或正數代表大於。" -#: ../../howto/sorting.rst:268 +#: ../../howto/sorting.rst:265 msgid "" "It is common to encounter comparison functions when translating algorithms " "from other languages. Also, some libraries provide comparison functions as " @@ -559,7 +551,7 @@ msgstr "" "當從其它語言翻譯演算法的時候常看到比較函式。有些函式庫也會提供比較函式作為其 " "API 的一部份,例如 :func:`locale.strcoll` 就是一個比較函式。" -#: ../../howto/sorting.rst:272 +#: ../../howto/sorting.rst:269 msgid "" "To accommodate those situations, Python provides :class:`functools." "cmp_to_key` to wrap the comparison function to make it usable as a key " @@ -568,25 +560,25 @@ msgstr "" "為了滿足這些情境,Python 提供 :class:`functools.cmp_to_key` 來包裝比較函式," "讓其可以當作鍵函式來使用: ::" -#: ../../howto/sorting.rst:276 +#: ../../howto/sorting.rst:273 msgid "sorted(words, key=cmp_to_key(strcoll)) # locale-aware sort order" msgstr "sorted(words, key=cmp_to_key(strcoll)) # 理解語系的排序順序" -#: ../../howto/sorting.rst:279 +#: ../../howto/sorting.rst:276 msgid "Strategies For Unorderable Types and Values" msgstr "" -#: ../../howto/sorting.rst:281 +#: ../../howto/sorting.rst:278 msgid "" "A number of type and value issues can arise when sorting. Here are some " "strategies that can help:" msgstr "" -#: ../../howto/sorting.rst:284 +#: ../../howto/sorting.rst:281 msgid "Convert non-comparable input types to strings prior to sorting:" msgstr "" -#: ../../howto/sorting.rst:286 +#: ../../howto/sorting.rst:283 msgid "" ">>> data = ['twelve', '11', 10]\n" ">>> sorted(map(str, data))\n" @@ -596,16 +588,16 @@ msgstr "" ">>> sorted(map(str, data))\n" "['10', '11', 'twelve']" -#: ../../howto/sorting.rst:292 +#: ../../howto/sorting.rst:289 msgid "" "This is needed because most cross-type comparisons raise a :exc:`TypeError`." msgstr "" -#: ../../howto/sorting.rst:295 +#: ../../howto/sorting.rst:292 msgid "Remove special values prior to sorting:" msgstr "" -#: ../../howto/sorting.rst:297 +#: ../../howto/sorting.rst:294 msgid "" ">>> from math import isnan\n" ">>> from itertools import filterfalse\n" @@ -619,18 +611,18 @@ msgstr "" ">>> sorted(filterfalse(isnan, data))\n" "[1.1, 2.2, 3.3]" -#: ../../howto/sorting.rst:305 +#: ../../howto/sorting.rst:302 msgid "" "This is needed because the `IEEE-754 standard `_ specifies that, \"Every NaN shall compare unordered with " "everything, including itself.\"" msgstr "" -#: ../../howto/sorting.rst:309 +#: ../../howto/sorting.rst:306 msgid "Likewise, ``None`` can be stripped from datasets as well:" msgstr "" -#: ../../howto/sorting.rst:311 +#: ../../howto/sorting.rst:308 msgid "" ">>> data = [3.3, None, 1.1, 2.2]\n" ">>> sorted(x for x in data if x is not None)\n" @@ -640,15 +632,15 @@ msgstr "" ">>> sorted(x for x in data if x is not None)\n" "[1.1, 2.2, 3.3]" -#: ../../howto/sorting.rst:317 +#: ../../howto/sorting.rst:314 msgid "This is needed because ``None`` is not comparable to other types." msgstr "" -#: ../../howto/sorting.rst:319 +#: ../../howto/sorting.rst:316 msgid "Convert mapping types into sorted item lists before sorting:" msgstr "" -#: ../../howto/sorting.rst:321 +#: ../../howto/sorting.rst:318 msgid "" ">>> data = [{'a': 1}, {'b': 2}]\n" ">>> sorted(data, key=lambda d: sorted(d.items()))\n" @@ -658,16 +650,16 @@ msgstr "" ">>> sorted(data, key=lambda d: sorted(d.items()))\n" "[{'a': 1}, {'b': 2}]" -#: ../../howto/sorting.rst:327 +#: ../../howto/sorting.rst:324 msgid "" "This is needed because dict-to-dict comparisons raise a :exc:`TypeError`." msgstr "" -#: ../../howto/sorting.rst:330 +#: ../../howto/sorting.rst:327 msgid "Convert set types into sorted lists before sorting:" msgstr "" -#: ../../howto/sorting.rst:332 +#: ../../howto/sorting.rst:329 msgid "" ">>> data = [{'a', 'b', 'c'}, {'b', 'c', 'd'}]\n" ">>> sorted(map(sorted, data))\n" @@ -677,18 +669,18 @@ msgstr "" ">>> sorted(map(sorted, data))\n" "[['a', 'b', 'c'], ['b', 'c', 'd']]" -#: ../../howto/sorting.rst:338 +#: ../../howto/sorting.rst:335 msgid "" "This is needed because the elements contained in set types do not have a " "deterministic order. For example, ``list({'a', 'b'})`` may produce either " "``['a', 'b']`` or ``['b', 'a']``." msgstr "" -#: ../../howto/sorting.rst:343 +#: ../../howto/sorting.rst:340 msgid "Odds and Ends" msgstr "雜項說明" -#: ../../howto/sorting.rst:345 +#: ../../howto/sorting.rst:342 msgid "" "For locale aware sorting, use :func:`locale.strxfrm` for a key function or :" "func:`locale.strcoll` for a comparison function. This is necessary because " @@ -699,7 +691,7 @@ msgstr "" "作鍵函式,或 :func:`locale.strcoll` 當作比較函式。這樣做是必要的,因為在不同" "文化中就算是相同的字母,按「字母順序」排序的結果也各不相同。" -#: ../../howto/sorting.rst:350 +#: ../../howto/sorting.rst:347 msgid "" "The *reverse* parameter still maintains sort stability (so that records with " "equal keys retain the original order). Interestingly, that effect can be " @@ -710,7 +702,7 @@ msgstr "" "是,不加這個參數也可以模擬這個效果,只要使用內建的 :func:`reversed` 函式兩" "次:" -#: ../../howto/sorting.rst:355 +#: ../../howto/sorting.rst:352 msgid "" ">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" ">>> standard_way = sorted(data, key=itemgetter(0), reverse=True)\n" @@ -728,7 +720,7 @@ msgstr "" ">>> standard_way\n" "[('red', 1), ('red', 2), ('blue', 1), ('blue', 2)]" -#: ../../howto/sorting.rst:364 +#: ../../howto/sorting.rst:361 msgid "" "The sort routines use ``<`` when making comparisons between two objects. So, " "it is easy to add a standard sort order to a class by defining an :meth:" @@ -737,7 +729,7 @@ msgstr "" "排序時會使用 ``<`` 來比較兩個物件,因此要在類別裡面加入排序順序比較規則是簡單" "的,只要透過定義 :meth:`~object.__lt__` 方法:" -#: ../../howto/sorting.rst:368 +#: ../../howto/sorting.rst:365 msgid "" ">>> Student.__lt__ = lambda self, other: self.age < other.age\n" ">>> sorted(student_objects)\n" @@ -747,7 +739,7 @@ msgstr "" ">>> sorted(student_objects)\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:374 +#: ../../howto/sorting.rst:371 msgid "" "However, note that ``<`` can fall back to using :meth:`~object.__gt__` if :" "meth:`~object.__lt__` is not implemented (see :func:`object.__lt__` for " @@ -760,7 +752,7 @@ msgstr "" "閱 :func:`object.__lt__`)。為了避免意外,:pep:`8` 建議實作全部六種比較方" "法。:deco:`~functools.total_ordering` 裝飾器可以讓這項工作更容易。" -#: ../../howto/sorting.rst:381 +#: ../../howto/sorting.rst:378 msgid "" "Key functions need not depend directly on the objects being sorted. A key " "function can also access external resources. For instance, if the student " @@ -770,7 +762,7 @@ msgstr "" "鍵函式不需要直接依賴用來排序的物件。鍵函式也可以存取外部資源,例如如果學生成" "績儲存在字典裡,它可以用來排序一個單獨的學生姓名串列:" -#: ../../howto/sorting.rst:386 +#: ../../howto/sorting.rst:383 msgid "" ">>> students = ['dave', 'john', 'jane']\n" ">>> newgrades = {'john': 'F', 'jane':'A', 'dave': 'C'}\n" @@ -782,11 +774,11 @@ msgstr "" ">>> sorted(students, key=newgrades.__getitem__)\n" "['jane', 'dave', 'john']" -#: ../../howto/sorting.rst:394 +#: ../../howto/sorting.rst:391 msgid "Partial Sorts" msgstr "部份排序" -#: ../../howto/sorting.rst:396 +#: ../../howto/sorting.rst:393 msgid "" "Some applications require only some of the data to be ordered. The standard " "library provides several tools that do less work than a full sort:" @@ -794,7 +786,7 @@ msgstr "" "有些應用程式只需要排序部份的資料。基礎函式庫提供相較做完整排序更為輕鬆的多項" "工具:" -#: ../../howto/sorting.rst:399 +#: ../../howto/sorting.rst:396 msgid "" ":func:`min` and :func:`max` return the smallest and largest values, " "respectively. These functions make a single pass over the input data and " @@ -803,7 +795,7 @@ msgstr "" ":func:`min` 以及 :func:`max` 會分別回傳最小值及最大值。這些函式會將輸入資料進" "行一次傳遞且幾乎無須輔助記憶體。" -#: ../../howto/sorting.rst:403 +#: ../../howto/sorting.rst:400 msgid "" ":func:`heapq.nsmallest` and :func:`heapq.nlargest` return the *n* smallest " "and largest values, respectively. These functions make a single pass over " @@ -815,7 +807,7 @@ msgstr "" "最大值。這些函式會將資料進行一次傳遞且一次只會保留 *n* 個元素在記憶體中。對於" "相對於輸入數量較小的 *n* 個值,這些函式進行的比較比完整排序要少得多。" -#: ../../howto/sorting.rst:409 +#: ../../howto/sorting.rst:406 msgid "" ":func:`heapq.heappush` and :func:`heapq.heappop` create and maintain a " "partially sorted arrangement of data that keeps the smallest element at " @@ -825,3 +817,9 @@ msgstr "" ":func:`heapq.heappush` 和 :func:`heapq.heappop` 會建立並維持一個部份排序的資" "料排列,將最小的元素保持在位置 ``0``。這些函式適合用來實作常用於任務排程的優" "先佇列。" + +#~ msgid "Author" +#~ msgstr "作者" + +#~ msgid "Andrew Dalke and Raymond Hettinger" +#~ msgstr "Andrew Dalke 和 Raymond Hettinger" diff --git a/howto/unicode.po b/howto/unicode.po index 2a9e35df0eb..84bdd631b20 100644 --- a/howto/unicode.po +++ b/howto/unicode.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-25 00:13+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:37+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,30 +21,22 @@ msgstr "" msgid "Unicode HOWTO" msgstr "" -#: ../../howto/unicode.rst:0 -msgid "Release" -msgstr "發佈版本" - #: ../../howto/unicode.rst:7 -msgid "1.12" -msgstr "1.12" - -#: ../../howto/unicode.rst:9 msgid "" "This HOWTO discusses Python's support for the Unicode specification for " "representing textual data, and explains various problems that people " "commonly encounter when trying to work with Unicode." msgstr "" -#: ../../howto/unicode.rst:15 +#: ../../howto/unicode.rst:13 msgid "Introduction to Unicode" msgstr "" -#: ../../howto/unicode.rst:18 +#: ../../howto/unicode.rst:16 msgid "Definitions" msgstr "定義" -#: ../../howto/unicode.rst:20 +#: ../../howto/unicode.rst:18 msgid "" "Today's programs need to be able to handle a wide variety of characters. " "Applications are often internationalized to display messages and output in a " @@ -56,7 +48,7 @@ msgid "" "different possible characters." msgstr "" -#: ../../howto/unicode.rst:30 +#: ../../howto/unicode.rst:28 msgid "" "Unicode (https://www.unicode.org/) is a specification that aims to list " "every character used by human languages and give each character its own " @@ -64,7 +56,7 @@ msgid "" "to add new languages and symbols." msgstr "" -#: ../../howto/unicode.rst:35 +#: ../../howto/unicode.rst:33 msgid "" "A **character** is the smallest possible component of a text. 'A', 'B', " "'C', etc., are all different characters. So are 'È' and 'Í'. Characters " @@ -74,7 +66,7 @@ msgid "" "two different characters that have different meanings." msgstr "" -#: ../../howto/unicode.rst:42 +#: ../../howto/unicode.rst:40 msgid "" "The Unicode standard describes how characters are represented by **code " "points**. A code point value is an integer in the range 0 to 0x10FFFF " @@ -84,13 +76,13 @@ msgid "" "the character with value ``0x265e`` (9,822 in decimal)." msgstr "" -#: ../../howto/unicode.rst:50 +#: ../../howto/unicode.rst:48 msgid "" "The Unicode standard contains a lot of tables listing characters and their " "corresponding code points:" msgstr "" -#: ../../howto/unicode.rst:53 +#: ../../howto/unicode.rst:51 msgid "" "0061 'a'; LATIN SMALL LETTER A\n" "0062 'b'; LATIN SMALL LETTER B\n" @@ -124,7 +116,7 @@ msgstr "" "1F609 '😉'; WINKING FACE\n" "..." -#: ../../howto/unicode.rst:71 +#: ../../howto/unicode.rst:69 msgid "" "Strictly, these definitions imply that it's meaningless to say 'this is " "character ``U+265E``'. ``U+265E`` is a code point, which represents some " @@ -133,7 +125,7 @@ msgid "" "and characters will sometimes be forgotten." msgstr "" -#: ../../howto/unicode.rst:78 +#: ../../howto/unicode.rst:76 msgid "" "A character is represented on a screen or on paper by a set of graphical " "elements that's called a **glyph**. The glyph for an uppercase A, for " @@ -143,11 +135,11 @@ msgid "" "generally the job of a GUI toolkit or a terminal's font renderer." msgstr "" -#: ../../howto/unicode.rst:87 +#: ../../howto/unicode.rst:85 msgid "Encodings" msgstr "" -#: ../../howto/unicode.rst:89 +#: ../../howto/unicode.rst:87 msgid "" "To summarize the previous section: a Unicode string is a sequence of code " "points, which are numbers from 0 through ``0x10FFFF`` (1,114,111 decimal). " @@ -157,14 +149,14 @@ msgid "" "**character encoding**, or just an **encoding**." msgstr "" -#: ../../howto/unicode.rst:97 +#: ../../howto/unicode.rst:95 msgid "" "The first encoding you might think of is using 32-bit integers as the code " "unit, and then using the CPU's representation of 32-bit integers. In this " "representation, the string \"Python\" might look like this:" msgstr "" -#: ../../howto/unicode.rst:101 +#: ../../howto/unicode.rst:99 msgid "" " P y t h o n\n" "0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00\n" @@ -174,17 +166,17 @@ msgstr "" "0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00\n" " 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23" -#: ../../howto/unicode.rst:107 +#: ../../howto/unicode.rst:105 msgid "" "This representation is straightforward but using it presents a number of " "problems." msgstr "" -#: ../../howto/unicode.rst:110 +#: ../../howto/unicode.rst:108 msgid "It's not portable; different processors order the bytes differently." msgstr "" -#: ../../howto/unicode.rst:112 +#: ../../howto/unicode.rst:110 msgid "" "It's very wasteful of space. In most texts, the majority of the code points " "are less than 127, or less than 255, so a lot of space is occupied by " @@ -195,19 +187,19 @@ msgid "" "factor of 4 is intolerable." msgstr "" -#: ../../howto/unicode.rst:120 +#: ../../howto/unicode.rst:118 msgid "" "It's not compatible with existing C functions such as ``strlen()``, so a new " "family of wide string functions would need to be used." msgstr "" -#: ../../howto/unicode.rst:123 +#: ../../howto/unicode.rst:121 msgid "" "Therefore this encoding isn't used very much, and people instead choose " "other encodings that are more efficient and convenient, such as UTF-8." msgstr "" -#: ../../howto/unicode.rst:126 +#: ../../howto/unicode.rst:124 msgid "" "UTF-8 is one of the most commonly used encodings, and Python often defaults " "to using it. UTF stands for \"Unicode Transformation Format\", and the '8' " @@ -216,26 +208,26 @@ msgid "" "uses the following rules:" msgstr "" -#: ../../howto/unicode.rst:132 +#: ../../howto/unicode.rst:130 msgid "" "If the code point is < 128, it's represented by the corresponding byte value." msgstr "" -#: ../../howto/unicode.rst:133 +#: ../../howto/unicode.rst:131 msgid "" "If the code point is >= 128, it's turned into a sequence of two, three, or " "four bytes, where each byte of the sequence is between 128 and 255." msgstr "" -#: ../../howto/unicode.rst:136 +#: ../../howto/unicode.rst:134 msgid "UTF-8 has several convenient properties:" msgstr "" -#: ../../howto/unicode.rst:138 +#: ../../howto/unicode.rst:136 msgid "It can handle any Unicode code point." msgstr "" -#: ../../howto/unicode.rst:139 +#: ../../howto/unicode.rst:137 msgid "" "A Unicode string is turned into a sequence of bytes that contains embedded " "zero bytes only where they represent the null character (U+0000). This means " @@ -244,24 +236,24 @@ msgid "" "end-of-string markers." msgstr "" -#: ../../howto/unicode.rst:144 +#: ../../howto/unicode.rst:142 msgid "A string of ASCII text is also valid UTF-8 text." msgstr "" -#: ../../howto/unicode.rst:145 +#: ../../howto/unicode.rst:143 msgid "" "UTF-8 is fairly compact; the majority of commonly used characters can be " "represented with one or two bytes." msgstr "" -#: ../../howto/unicode.rst:147 +#: ../../howto/unicode.rst:145 msgid "" "If bytes are corrupted or lost, it's possible to determine the start of the " "next UTF-8-encoded code point and resynchronize. It's also unlikely that " "random 8-bit data will look like valid UTF-8." msgstr "" -#: ../../howto/unicode.rst:150 +#: ../../howto/unicode.rst:148 msgid "" "UTF-8 is a byte oriented encoding. The encoding specifies that each " "character is represented by a specific sequence of one or more bytes. This " @@ -270,12 +262,12 @@ msgid "" "varies depending on the hardware on which the string was encoded." msgstr "" -#: ../../howto/unicode.rst:158 ../../howto/unicode.rst:516 -#: ../../howto/unicode.rst:737 +#: ../../howto/unicode.rst:156 ../../howto/unicode.rst:514 +#: ../../howto/unicode.rst:735 msgid "References" msgstr "" -#: ../../howto/unicode.rst:160 +#: ../../howto/unicode.rst:158 msgid "" "The `Unicode Consortium site `_ has character " "charts, a glossary, and PDF versions of the Unicode specification. Be " @@ -284,21 +276,21 @@ msgid "" "the site." msgstr "" -#: ../../howto/unicode.rst:165 +#: ../../howto/unicode.rst:163 msgid "" "On the Computerphile Youtube channel, Tom Scott briefly `discusses the " "history of Unicode and UTF-8 `_ " "(9 minutes 36 seconds)." msgstr "" -#: ../../howto/unicode.rst:169 +#: ../../howto/unicode.rst:167 msgid "" "To help understand the standard, Jukka Korpela has written `an introductory " "guide `_ to reading the Unicode " "character tables." msgstr "" -#: ../../howto/unicode.rst:173 +#: ../../howto/unicode.rst:171 msgid "" "Another `good introductory article `_\" and `UTF-8 " "`_, for example." msgstr "" -#: ../../howto/unicode.rst:184 +#: ../../howto/unicode.rst:182 msgid "Python's Unicode Support" msgstr "" -#: ../../howto/unicode.rst:186 +#: ../../howto/unicode.rst:184 msgid "" "Now that you've learned the rudiments of Unicode, we can look at Python's " "Unicode features." msgstr "" -#: ../../howto/unicode.rst:190 +#: ../../howto/unicode.rst:188 msgid "The String Type" msgstr "" -#: ../../howto/unicode.rst:192 +#: ../../howto/unicode.rst:190 msgid "" "Since Python 3.0, the language's :class:`str` type contains Unicode " "characters, meaning any string created using ``\"unicode rocks!\"``, " @@ -336,13 +328,13 @@ msgid "" "Unicode." msgstr "" -#: ../../howto/unicode.rst:196 +#: ../../howto/unicode.rst:194 msgid "" "The default encoding for Python source code is UTF-8, so you can simply " "include a Unicode character in a string literal::" msgstr "" -#: ../../howto/unicode.rst:199 +#: ../../howto/unicode.rst:197 msgid "" "try:\n" " with open('/tmp/input.txt', 'r') as f:\n" @@ -352,12 +344,12 @@ msgid "" " print(\"Fichier non trouvé\")" msgstr "" -#: ../../howto/unicode.rst:206 +#: ../../howto/unicode.rst:204 msgid "" "Side note: Python 3 also supports using Unicode characters in identifiers::" msgstr "" -#: ../../howto/unicode.rst:208 +#: ../../howto/unicode.rst:206 msgid "" "répertoire = \"/tmp/records.log\"\n" "with open(répertoire, \"w\") as f:\n" @@ -367,7 +359,7 @@ msgstr "" "with open(répertoire, \"w\") as f:\n" " f.write(\"test\\n\")" -#: ../../howto/unicode.rst:212 +#: ../../howto/unicode.rst:210 msgid "" "If you can't enter a particular character in your editor or want to keep the " "source code ASCII-only for some reason, you can also use escape sequences in " @@ -375,7 +367,7 @@ msgid "" "delta glyph instead of a \\u escape.) ::" msgstr "" -#: ../../howto/unicode.rst:217 +#: ../../howto/unicode.rst:215 msgid "" ">>> \"\\N{GREEK CAPITAL LETTER DELTA}\" # Using the character name\n" "'\\u0394'\n" @@ -385,14 +377,14 @@ msgid "" "'\\u0394'" msgstr "" -#: ../../howto/unicode.rst:224 +#: ../../howto/unicode.rst:222 msgid "" "In addition, one can create a string using the :func:`~bytes.decode` method " "of :class:`bytes`. This method takes an *encoding* argument, such as " "``UTF-8``, and optionally an *errors* argument." msgstr "" -#: ../../howto/unicode.rst:228 +#: ../../howto/unicode.rst:226 msgid "" "The *errors* argument specifies the response when the input string can't be " "converted according to the encoding's rules. Legal values for this argument " @@ -403,7 +395,7 @@ msgid "" "examples show the differences::" msgstr "" -#: ../../howto/unicode.rst:236 +#: ../../howto/unicode.rst:234 msgid "" ">>> b'\\x80abc'.decode(\"utf-8\", \"strict\")\n" "Traceback (most recent call last):\n" @@ -429,7 +421,7 @@ msgstr "" ">>> b'\\x80abc'.decode(\"utf-8\", \"ignore\")\n" "'abc'" -#: ../../howto/unicode.rst:248 +#: ../../howto/unicode.rst:246 msgid "" "Encodings are specified as strings containing the encoding's name. Python " "comes with roughly 100 different encodings; see the Python Library Reference " @@ -438,7 +430,7 @@ msgid "" "synonyms for the same encoding." msgstr "" -#: ../../howto/unicode.rst:254 +#: ../../howto/unicode.rst:252 msgid "" "One-character Unicode strings can also be created with the :func:`chr` built-" "in function, which takes integers and returns a Unicode string of length 1 " @@ -447,7 +439,7 @@ msgid "" "returns the code point value::" msgstr "" -#: ../../howto/unicode.rst:260 +#: ../../howto/unicode.rst:258 msgid "" ">>> chr(57344)\n" "'\\ue000'\n" @@ -459,18 +451,18 @@ msgstr "" ">>> ord('\\ue000')\n" "57344" -#: ../../howto/unicode.rst:266 +#: ../../howto/unicode.rst:264 msgid "Converting to Bytes" msgstr "" -#: ../../howto/unicode.rst:268 +#: ../../howto/unicode.rst:266 msgid "" "The opposite method of :meth:`bytes.decode` is :meth:`str.encode`, which " "returns a :class:`bytes` representation of the Unicode string, encoded in " "the requested *encoding*." msgstr "" -#: ../../howto/unicode.rst:272 +#: ../../howto/unicode.rst:270 msgid "" "The *errors* parameter is the same as the parameter of the :meth:`~bytes." "decode` method but supports a few more possible handlers. As well as " @@ -481,11 +473,11 @@ msgid "" "``namereplace`` (inserts a ``\\N{...}`` escape sequence)." msgstr "" -#: ../../howto/unicode.rst:280 +#: ../../howto/unicode.rst:278 msgid "The following example shows the different results::" msgstr "" -#: ../../howto/unicode.rst:282 +#: ../../howto/unicode.rst:280 msgid "" ">>> u = chr(40960) + 'abcd' + chr(1972)\n" ">>> u.encode('utf-8')\n" @@ -525,7 +517,7 @@ msgstr "" ">>> u.encode('ascii', 'namereplace')\n" "b'\\\\N{YI SYLLABLE IT}abcd\\\\u07b4'" -#: ../../howto/unicode.rst:301 +#: ../../howto/unicode.rst:299 msgid "" "The low-level routines for registering and accessing the available encodings " "are found in the :mod:`codecs` module. Implementing new encodings also " @@ -535,11 +527,11 @@ msgid "" "module won't be covered in this HOWTO." msgstr "" -#: ../../howto/unicode.rst:310 +#: ../../howto/unicode.rst:308 msgid "Unicode Literals in Python Source Code" msgstr "" -#: ../../howto/unicode.rst:312 +#: ../../howto/unicode.rst:310 msgid "" "In Python source code, specific Unicode code points can be written using the " "``\\u`` escape sequence, which is followed by four hex digits giving the " @@ -547,7 +539,7 @@ msgid "" "digits, not four::" msgstr "" -#: ../../howto/unicode.rst:317 +#: ../../howto/unicode.rst:315 msgid "" ">>> s = \"a\\xac\\u1234\\u20ac\\U00008000\"\n" "... # ^^^^ two-digit hex escape\n" @@ -563,7 +555,7 @@ msgstr "" ">>> [ord(c) for c in s]\n" "[97, 172, 4660, 8364, 32768]" -#: ../../howto/unicode.rst:324 +#: ../../howto/unicode.rst:322 msgid "" "Using escape sequences for code points greater than 127 is fine in small " "doses, but becomes an annoyance if you're using many accented characters, as " @@ -572,7 +564,7 @@ msgid "" "function, but this is even more tedious." msgstr "" -#: ../../howto/unicode.rst:330 +#: ../../howto/unicode.rst:328 msgid "" "Ideally, you'd want to be able to write literals in your language's natural " "encoding. You could then edit Python source code with your favorite editor " @@ -580,7 +572,7 @@ msgid "" "characters used at runtime." msgstr "" -#: ../../howto/unicode.rst:335 +#: ../../howto/unicode.rst:333 msgid "" "Python supports writing source code in UTF-8 by default, but you can use " "almost any encoding if you declare the encoding being used. This is done by " @@ -588,7 +580,7 @@ msgid "" "file::" msgstr "" -#: ../../howto/unicode.rst:339 +#: ../../howto/unicode.rst:337 msgid "" "#!/usr/bin/env python\n" "# -*- coding: latin-1 -*-\n" @@ -602,7 +594,7 @@ msgstr "" "u = 'abcdé'\n" "print(ord(u[-1]))" -#: ../../howto/unicode.rst:345 +#: ../../howto/unicode.rst:343 msgid "" "The syntax is inspired by Emacs's notation for specifying variables local to " "a file. Emacs supports many different variables, but Python only supports " @@ -611,17 +603,17 @@ msgid "" "looks for ``coding: name`` or ``coding=name`` in the comment." msgstr "" -#: ../../howto/unicode.rst:351 +#: ../../howto/unicode.rst:349 msgid "" "If you don't include such a comment, the default encoding used will be UTF-8 " "as already mentioned. See also :pep:`263` for more information." msgstr "" -#: ../../howto/unicode.rst:358 +#: ../../howto/unicode.rst:356 msgid "Unicode Properties" msgstr "" -#: ../../howto/unicode.rst:360 +#: ../../howto/unicode.rst:358 msgid "" "The Unicode specification includes a database of information about code " "points. For each defined code point, the information includes the " @@ -631,13 +623,13 @@ msgid "" "related properties, such as how to use the code point in bidirectional text." msgstr "" -#: ../../howto/unicode.rst:368 +#: ../../howto/unicode.rst:366 msgid "" "The following program displays some information about several characters, " "and prints the numeric value of one particular character::" msgstr "" -#: ../../howto/unicode.rst:371 +#: ../../howto/unicode.rst:369 msgid "" "import unicodedata\n" "\n" @@ -651,11 +643,11 @@ msgid "" "print(unicodedata.numeric(u[1]))" msgstr "" -#: ../../howto/unicode.rst:382 +#: ../../howto/unicode.rst:380 msgid "When run, this prints:" msgstr "" -#: ../../howto/unicode.rst:384 +#: ../../howto/unicode.rst:382 msgid "" "0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE\n" "1 0bf2 No TAMIL NUMBER ONE THOUSAND\n" @@ -671,7 +663,7 @@ msgstr "" "4 33af So SQUARE RAD OVER S SQUARED\n" "1000.0" -#: ../../howto/unicode.rst:393 +#: ../../howto/unicode.rst:391 msgid "" "The category codes are abbreviations describing the nature of the character. " "These are grouped into categories such as \"Letter\", \"Number\", " @@ -684,11 +676,11 @@ msgid "" "codes." msgstr "" -#: ../../howto/unicode.rst:404 +#: ../../howto/unicode.rst:402 msgid "Comparing Strings" msgstr "" -#: ../../howto/unicode.rst:406 +#: ../../howto/unicode.rst:404 msgid "" "Unicode adds some complication to comparing strings, because the same set of " "characters can be represented by different sequences of code points. For " @@ -698,7 +690,7 @@ msgid "" "when printed, but one is a string of length 1 and the other is of length 2." msgstr "" -#: ../../howto/unicode.rst:414 +#: ../../howto/unicode.rst:412 msgid "" "One tool for a case-insensitive comparison is the :meth:`~str.casefold` " "string method that converts a string to a case-insensitive form following an " @@ -707,7 +699,7 @@ msgid "" "which becomes the pair of lowercase letters 'ss'." msgstr "" -#: ../../howto/unicode.rst:423 +#: ../../howto/unicode.rst:421 msgid "" ">>> street = 'Gürzenichstraße'\n" ">>> street.casefold()\n" @@ -717,7 +709,7 @@ msgstr "" ">>> street.casefold()\n" "'gürzenichstrasse'" -#: ../../howto/unicode.rst:427 +#: ../../howto/unicode.rst:425 msgid "" "A second tool is the :mod:`unicodedata` module's :func:`~unicodedata." "normalize` function that converts strings to one of several normal forms, " @@ -727,7 +719,7 @@ msgid "" "combining characters differently:" msgstr "" -#: ../../howto/unicode.rst:436 +#: ../../howto/unicode.rst:434 msgid "" "import unicodedata\n" "\n" @@ -759,11 +751,11 @@ msgstr "" "print('length of second string=', len(multiple_chars))\n" "print(compare_strs(single_char, multiple_chars))" -#: ../../howto/unicode.rst:450 +#: ../../howto/unicode.rst:448 msgid "When run, this outputs:" msgstr "" -#: ../../howto/unicode.rst:452 +#: ../../howto/unicode.rst:450 msgid "" "$ python compare-strs.py\n" "length of first string= 1\n" @@ -775,18 +767,18 @@ msgstr "" "length of second string= 2\n" "True" -#: ../../howto/unicode.rst:459 +#: ../../howto/unicode.rst:457 msgid "" "The first argument to the :func:`~unicodedata.normalize` function is a " "string giving the desired normalization form, which can be one of 'NFC', " "'NFKC', 'NFD', and 'NFKD'." msgstr "" -#: ../../howto/unicode.rst:463 +#: ../../howto/unicode.rst:461 msgid "The Unicode Standard also specifies how to do caseless comparisons::" msgstr "" -#: ../../howto/unicode.rst:465 +#: ../../howto/unicode.rst:463 msgid "" "import unicodedata\n" "\n" @@ -804,7 +796,7 @@ msgid "" "print(compare_caseless(single_char, multiple_chars))" msgstr "" -#: ../../howto/unicode.rst:479 +#: ../../howto/unicode.rst:477 msgid "" "This will print ``True``. (Why is :func:`!NFD` invoked twice? Because " "there are a few characters that make :meth:`~str.casefold` return a non-" @@ -812,11 +804,11 @@ msgid "" "3.13 of the Unicode Standard for a discussion and an example.)" msgstr "" -#: ../../howto/unicode.rst:486 +#: ../../howto/unicode.rst:484 msgid "Unicode Regular Expressions" msgstr "" -#: ../../howto/unicode.rst:488 +#: ../../howto/unicode.rst:486 msgid "" "The regular expressions supported by the :mod:`re` module can be provided " "either as bytes or strings. Some of the special character sequences such as " @@ -826,13 +818,13 @@ msgid "" "in the ``'Nd'`` category." msgstr "" -#: ../../howto/unicode.rst:495 +#: ../../howto/unicode.rst:493 msgid "" "The string in this example has the number 57 written in both Thai and Arabic " "numerals::" msgstr "" -#: ../../howto/unicode.rst:498 +#: ../../howto/unicode.rst:496 msgid "" "import re\n" "p = re.compile(r'\\d+')\n" @@ -848,51 +840,51 @@ msgstr "" "m = p.search(s)\n" "print(repr(m.group()))" -#: ../../howto/unicode.rst:505 +#: ../../howto/unicode.rst:503 msgid "" "When executed, ``\\d+`` will match the Thai numerals and print them out. If " "you supply the :const:`re.ASCII` flag to :func:`~re.compile`, ``\\d+`` will " "match the substring \"57\" instead." msgstr "" -#: ../../howto/unicode.rst:509 +#: ../../howto/unicode.rst:507 msgid "" "Similarly, ``\\w`` matches a wide variety of Unicode characters but only " "``[a-zA-Z0-9_]`` in bytes or if :const:`re.ASCII` is supplied, and ``\\s`` " "will match either Unicode whitespace characters or ``[ \\t\\n\\r\\f\\v]``." msgstr "" -#: ../../howto/unicode.rst:520 +#: ../../howto/unicode.rst:518 msgid "Some good alternative discussions of Python's Unicode support are:" msgstr "" -#: ../../howto/unicode.rst:522 +#: ../../howto/unicode.rst:520 msgid "" "`Processing Text Files in Python 3 `_, by Nick Coghlan." msgstr "" -#: ../../howto/unicode.rst:523 +#: ../../howto/unicode.rst:521 msgid "" "`Pragmatic Unicode `_, a PyCon " "2012 presentation by Ned Batchelder." msgstr "" -#: ../../howto/unicode.rst:525 +#: ../../howto/unicode.rst:523 msgid "" "The :class:`str` type is described in the Python library reference at :ref:" "`textseq`." msgstr "" -#: ../../howto/unicode.rst:528 +#: ../../howto/unicode.rst:526 msgid "The documentation for the :mod:`unicodedata` module." msgstr ":mod:`unicodedata` 模組的文件。" -#: ../../howto/unicode.rst:530 +#: ../../howto/unicode.rst:528 msgid "The documentation for the :mod:`codecs` module." msgstr ":mod:`codecs` 模組的文件。" -#: ../../howto/unicode.rst:532 +#: ../../howto/unicode.rst:530 msgid "" "Marc-André Lemburg gave `a presentation titled \"Python and Unicode\" (PDF " "slides) `_ at " @@ -901,18 +893,18 @@ msgid "" "``unicode`` and literals start with ``u``)." msgstr "" -#: ../../howto/unicode.rst:540 +#: ../../howto/unicode.rst:538 msgid "Reading and Writing Unicode Data" msgstr "" -#: ../../howto/unicode.rst:542 +#: ../../howto/unicode.rst:540 msgid "" "Once you've written some code that works with Unicode data, the next problem " "is input/output. How do you get Unicode strings into your program, and how " "do you convert Unicode into a form suitable for storage or transmission?" msgstr "" -#: ../../howto/unicode.rst:546 +#: ../../howto/unicode.rst:544 msgid "" "It's possible that you may not need to do anything depending on your input " "sources and output destinations; you should check whether the libraries used " @@ -921,7 +913,7 @@ msgid "" "valued columns and can return Unicode values from an SQL query." msgstr "" -#: ../../howto/unicode.rst:552 +#: ../../howto/unicode.rst:550 msgid "" "Unicode data is usually converted to a particular encoding before it gets " "written to disk or sent over a socket. It's possible to do all the work " @@ -930,7 +922,7 @@ msgid "" "recommended." msgstr "" -#: ../../howto/unicode.rst:557 +#: ../../howto/unicode.rst:555 msgid "" "One problem is the multi-byte nature of encodings; one Unicode character can " "be represented by several bytes. If you want to read the file in arbitrary-" @@ -944,7 +936,7 @@ msgid "" "version in memory.)" msgstr "" -#: ../../howto/unicode.rst:567 +#: ../../howto/unicode.rst:565 msgid "" "The solution would be to use the low-level decoding interface to catch the " "case of partial coding sequences. The work of implementing this has already " @@ -956,11 +948,11 @@ msgid "" "meth:`str.encode` and :meth:`bytes.decode`." msgstr "" -#: ../../howto/unicode.rst:576 +#: ../../howto/unicode.rst:574 msgid "Reading Unicode from a file is therefore simple::" msgstr "" -#: ../../howto/unicode.rst:578 +#: ../../howto/unicode.rst:576 msgid "" "with open('unicode.txt', encoding='utf-8') as f:\n" " for line in f:\n" @@ -970,13 +962,13 @@ msgstr "" " for line in f:\n" " print(repr(line))" -#: ../../howto/unicode.rst:582 +#: ../../howto/unicode.rst:580 msgid "" "It's also possible to open files in update mode, allowing both reading and " "writing::" msgstr "" -#: ../../howto/unicode.rst:585 +#: ../../howto/unicode.rst:583 msgid "" "with open('test', encoding='utf-8', mode='w+') as f:\n" " f.write('\\u4500 blah blah blah\\n')\n" @@ -988,7 +980,7 @@ msgstr "" " f.seek(0)\n" " print(repr(f.readline()[:1]))" -#: ../../howto/unicode.rst:590 +#: ../../howto/unicode.rst:588 msgid "" "The Unicode character ``U+FEFF`` is used as a byte-order mark (BOM), and is " "often written as the first character of a file in order to assist with " @@ -1001,7 +993,7 @@ msgid "" "the BOM." msgstr "" -#: ../../howto/unicode.rst:599 +#: ../../howto/unicode.rst:597 msgid "" "In some areas, it is also convention to use a \"BOM\" at the start of UTF-8 " "encoded files; the name is misleading since UTF-8 is not byte-order " @@ -1010,11 +1002,11 @@ msgid "" "if present." msgstr "" -#: ../../howto/unicode.rst:606 +#: ../../howto/unicode.rst:604 msgid "Unicode filenames" msgstr "" -#: ../../howto/unicode.rst:608 +#: ../../howto/unicode.rst:606 msgid "" "Most of the operating systems in common use today support filenames that " "contain arbitrary Unicode characters. Usually this is implemented by " @@ -1027,7 +1019,7 @@ msgid "" "encoding is again UTF-8." msgstr "" -#: ../../howto/unicode.rst:618 +#: ../../howto/unicode.rst:616 msgid "" "The :func:`sys.getfilesystemencoding` function returns the encoding to use " "on your current system, in case you want to do the encoding manually, but " @@ -1036,7 +1028,7 @@ msgid "" "and it will be automatically converted to the right encoding for you::" msgstr "" -#: ../../howto/unicode.rst:624 +#: ../../howto/unicode.rst:622 msgid "" "filename = 'filename\\u4500abc'\n" "with open(filename, 'w') as f:\n" @@ -1046,13 +1038,13 @@ msgstr "" "with open(filename, 'w') as f:\n" " f.write('blah\\n')" -#: ../../howto/unicode.rst:628 +#: ../../howto/unicode.rst:626 msgid "" "Functions in the :mod:`os` module such as :func:`os.stat` will also accept " "Unicode filenames." msgstr "" -#: ../../howto/unicode.rst:631 +#: ../../howto/unicode.rst:629 msgid "" "The :func:`os.listdir` function returns filenames, which raises an issue: " "should it return the Unicode version of filenames, or should it return bytes " @@ -1065,7 +1057,7 @@ msgid "" "error handler>` is UTF-8, running the following program::" msgstr "" -#: ../../howto/unicode.rst:641 +#: ../../howto/unicode.rst:639 msgid "" "fn = 'filename\\u4500abc'\n" "f = open(fn, 'w')\n" @@ -1083,11 +1075,11 @@ msgstr "" "print(os.listdir(b'.'))\n" "print(os.listdir('.'))" -#: ../../howto/unicode.rst:649 +#: ../../howto/unicode.rst:647 msgid "will produce the following output:" msgstr "" -#: ../../howto/unicode.rst:651 +#: ../../howto/unicode.rst:649 msgid "" "$ python listdir-test.py\n" "[b'filename\\xe4\\x94\\x80abc', ...]\n" @@ -1097,13 +1089,13 @@ msgstr "" "[b'filename\\xe4\\x94\\x80abc', ...]\n" "['filename\\u4500abc', ...]" -#: ../../howto/unicode.rst:657 +#: ../../howto/unicode.rst:655 msgid "" "The first list contains UTF-8-encoded filenames, and the second list " "contains the Unicode versions." msgstr "" -#: ../../howto/unicode.rst:660 +#: ../../howto/unicode.rst:658 msgid "" "Note that on most occasions, you should can just stick with using Unicode " "with these APIs. The bytes APIs should only be used on systems where " @@ -1111,27 +1103,27 @@ msgid "" "now." msgstr "" -#: ../../howto/unicode.rst:667 +#: ../../howto/unicode.rst:665 msgid "Tips for Writing Unicode-aware Programs" msgstr "" -#: ../../howto/unicode.rst:669 +#: ../../howto/unicode.rst:667 msgid "" "This section provides some suggestions on writing software that deals with " "Unicode." msgstr "" -#: ../../howto/unicode.rst:672 +#: ../../howto/unicode.rst:670 msgid "The most important tip is:" msgstr "" -#: ../../howto/unicode.rst:674 +#: ../../howto/unicode.rst:672 msgid "" "Software should only work with Unicode strings internally, decoding the " "input data as soon as possible and encoding the output only at the end." msgstr "" -#: ../../howto/unicode.rst:677 +#: ../../howto/unicode.rst:675 msgid "" "If you attempt to write processing functions that accept both Unicode and " "byte strings, you will find your program vulnerable to bugs wherever you " @@ -1140,7 +1132,7 @@ msgid "" "raised." msgstr "" -#: ../../howto/unicode.rst:682 +#: ../../howto/unicode.rst:680 msgid "" "When using data coming from a web browser or some other untrusted source, a " "common technique is to check for illegal characters in a string before using " @@ -1152,24 +1144,24 @@ msgid "" "then choose a clever way to hide malicious text in the encoded bytestream." msgstr "" -#: ../../howto/unicode.rst:693 +#: ../../howto/unicode.rst:691 msgid "Converting Between File Encodings" msgstr "" -#: ../../howto/unicode.rst:695 +#: ../../howto/unicode.rst:693 msgid "" "The :class:`~codecs.StreamRecoder` class can transparently convert between " "encodings, taking a stream that returns data in encoding #1 and behaving " "like a stream returning data in encoding #2." msgstr "" -#: ../../howto/unicode.rst:699 +#: ../../howto/unicode.rst:697 msgid "" "For example, if you have an input file *f* that's in Latin-1, you can wrap " "it with a :class:`~codecs.StreamRecoder` to return bytes encoded in UTF-8::" msgstr "" -#: ../../howto/unicode.rst:703 +#: ../../howto/unicode.rst:701 msgid "" "new_f = codecs.StreamRecoder(f,\n" " # en/decoder: used by read() to encode its results and\n" @@ -1180,11 +1172,11 @@ msgid "" " codecs.getreader('latin-1'), codecs.getwriter('latin-1') )" msgstr "" -#: ../../howto/unicode.rst:713 +#: ../../howto/unicode.rst:711 msgid "Files in an Unknown Encoding" msgstr "" -#: ../../howto/unicode.rst:715 +#: ../../howto/unicode.rst:713 msgid "" "What can you do if you need to make a change to a file, but don't know the " "file's encoding? If you know the encoding is ASCII-compatible and only want " @@ -1192,7 +1184,7 @@ msgid "" "``surrogateescape`` error handler::" msgstr "" -#: ../../howto/unicode.rst:720 +#: ../../howto/unicode.rst:718 msgid "" "with open(fname, 'r', encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" " data = f.read()\n" @@ -1212,7 +1204,7 @@ msgstr "" " encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" " f.write(data)" -#: ../../howto/unicode.rst:729 +#: ../../howto/unicode.rst:727 msgid "" "The ``surrogateescape`` error handler will decode any non-ASCII bytes as " "code points in a special range running from U+DC80 to U+DCFF. These code " @@ -1220,14 +1212,14 @@ msgid "" "error handler is used to encode the data and write it back out." msgstr "" -#: ../../howto/unicode.rst:739 +#: ../../howto/unicode.rst:737 msgid "" "One section of `Mastering Python 3 Input/Output `_, a PyCon 2010 talk by David " "Beazley, discusses text processing and binary data handling." msgstr "" -#: ../../howto/unicode.rst:743 +#: ../../howto/unicode.rst:741 msgid "" "The `PDF slides for Marc-André Lemburg's presentation \"Writing Unicode-" "aware Applications in Python\" `_ is a PyCon 2013 talk by Benjamin Peterson that " "discusses the internal Unicode representation in Python 3.3." msgstr "" -#: ../../howto/unicode.rst:756 +#: ../../howto/unicode.rst:754 msgid "Acknowledgements" msgstr "致謝" -#: ../../howto/unicode.rst:758 +#: ../../howto/unicode.rst:756 msgid "" "The initial draft of this document was written by Andrew Kuchling. It has " "since been revised further by Alexander Belopolsky, Georg Brandl, Andrew " "Kuchling, and Ezio Melotti." msgstr "" -#: ../../howto/unicode.rst:762 +#: ../../howto/unicode.rst:760 msgid "" "Thanks to the following people who have noted errors or offered suggestions " "on this article: Éric Araujo, Nicholas Bastin, Nick Coghlan, Marius " "Gedminas, Kent Johnson, Ken Krugler, Marc-André Lemburg, Martin von Löwis, " "Terry J. Reedy, Serhiy Storchaka, Eryk Sun, Chad Whitacre, Graham Wideman." msgstr "" + +#~ msgid "Release" +#~ msgstr "發佈版本" + +#~ msgid "1.12" +#~ msgstr "1.12" diff --git a/howto/urllib2.po b/howto/urllib2.po index 2838843ae79..121d66ac5f4 100644 --- a/howto/urllib2.po +++ b/howto/urllib2.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-22 16:55+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-06-27 09:36+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,25 +23,17 @@ msgstr "" msgid "HOWTO Fetch Internet Resources Using The urllib Package" msgstr "如何使用 urllib 套件取得網路資源" -#: ../../howto/urllib2.rst:0 -msgid "Author" -msgstr "作者" - -#: ../../howto/urllib2.rst:7 -msgid "`Michael Foord `_" -msgstr "`Michael Foord `_" - -#: ../../howto/urllib2.rst:11 +#: ../../howto/urllib2.rst:8 msgid "Introduction" msgstr "簡介" -#: ../../howto/urllib2.rst:15 +#: ../../howto/urllib2.rst:12 msgid "" "You may also find useful the following article on fetching web resources " "with Python:" msgstr "以下這些與 Python 有關的文章說不定能幫到你::" -#: ../../howto/urllib2.rst:18 +#: ../../howto/urllib2.rst:15 msgid "" "`Basic Authentication `__" @@ -49,11 +41,11 @@ msgstr "" "`Basic Authentication `__" -#: ../../howto/urllib2.rst:20 +#: ../../howto/urllib2.rst:17 msgid "A tutorial on *Basic Authentication*, with examples in Python." msgstr "以 Python 為例的 *Basic Authentication* 教學。" -#: ../../howto/urllib2.rst:22 +#: ../../howto/urllib2.rst:19 msgid "" "**urllib.request** is a Python module for fetching URLs (Uniform Resource " "Locators). It offers a very simple interface, in the form of the *urlopen* " @@ -67,7 +59,7 @@ msgstr "" "也提供了較複雜的介面用於處理一些常見的狀況,例如:基本的 authentication、" "cookies、proxies 等等,這些都可以由 handler 或 opener 物件操作。" -#: ../../howto/urllib2.rst:29 +#: ../../howto/urllib2.rst:26 msgid "" "urllib.request supports fetching URLs for many \"URL schemes\" (identified " "by the string before the ``\":\"`` in URL - for example ``\"ftp\"`` is the " @@ -76,7 +68,7 @@ msgid "" "HTTP." msgstr "" -#: ../../howto/urllib2.rst:34 +#: ../../howto/urllib2.rst:31 msgid "" "For straightforward situations *urlopen* is very easy to use. But as soon as " "you encounter errors or non-trivial cases when opening HTTP URLs, you will " @@ -93,15 +85,15 @@ msgstr "" "的 HTTP 知識來幫助你使用 *urllib*。這份教學並非要取代 :mod:`urllib.request` " "這份文件,你還是會需要它。" -#: ../../howto/urllib2.rst:44 +#: ../../howto/urllib2.rst:41 msgid "Fetching URLs" msgstr "從 URL 取得資源" -#: ../../howto/urllib2.rst:46 +#: ../../howto/urllib2.rst:43 msgid "The simplest way to use urllib.request is as follows::" msgstr "以下是使用 urllib.request 最簡單的方法::" -#: ../../howto/urllib2.rst:48 +#: ../../howto/urllib2.rst:45 msgid "" "import urllib.request\n" "with urllib.request.urlopen('http://python.org/') as response:\n" @@ -111,14 +103,14 @@ msgstr "" "with urllib.request.urlopen('http://python.org/') as response:\n" " html = response.read()" -#: ../../howto/urllib2.rst:52 +#: ../../howto/urllib2.rst:49 msgid "" "If you wish to retrieve a resource via URL and store it in a temporary " "location, you can do so via the :func:`shutil.copyfileobj` and :func:" "`tempfile.NamedTemporaryFile` functions::" msgstr "" -#: ../../howto/urllib2.rst:56 +#: ../../howto/urllib2.rst:53 msgid "" "import shutil\n" "import tempfile\n" @@ -142,7 +134,7 @@ msgstr "" "with open(tmp_file.name) as html:\n" " pass" -#: ../../howto/urllib2.rst:67 +#: ../../howto/urllib2.rst:64 msgid "" "Many uses of urllib will be that simple (note that instead of an 'http:' URL " "we could have used a URL starting with 'ftp:', 'file:', etc.). However, " @@ -150,7 +142,7 @@ msgid "" "concentrating on HTTP." msgstr "" -#: ../../howto/urllib2.rst:72 +#: ../../howto/urllib2.rst:69 msgid "" "HTTP is based on requests and responses - the client makes requests and " "servers send responses. urllib.request mirrors this with a ``Request`` " @@ -161,7 +153,7 @@ msgid "" "for example call ``.read()`` on the response::" msgstr "" -#: ../../howto/urllib2.rst:80 +#: ../../howto/urllib2.rst:77 msgid "" "import urllib.request\n" "\n" @@ -175,17 +167,17 @@ msgstr "" "with urllib.request.urlopen(req) as response:\n" " the_page = response.read()" -#: ../../howto/urllib2.rst:86 +#: ../../howto/urllib2.rst:83 msgid "" "Note that urllib.request makes use of the same Request interface to handle " "all URL schemes. For example, you can make an FTP request like so::" msgstr "" -#: ../../howto/urllib2.rst:89 +#: ../../howto/urllib2.rst:86 msgid "req = urllib.request.Request('ftp://example.com/')" msgstr "req = urllib.request.Request('ftp://example.com/')" -#: ../../howto/urllib2.rst:91 +#: ../../howto/urllib2.rst:88 msgid "" "In the case of HTTP, there are two extra things that Request objects allow " "you to do: First, you can pass data to be sent to the server. Second, you " @@ -194,11 +186,11 @@ msgid "" "\"headers\". Let's look at each of these in turn." msgstr "" -#: ../../howto/urllib2.rst:98 +#: ../../howto/urllib2.rst:95 msgid "Data" msgstr "" -#: ../../howto/urllib2.rst:100 +#: ../../howto/urllib2.rst:97 msgid "" "Sometimes you want to send data to a URL (often the URL will refer to a CGI " "(Common Gateway Interface) script or other web application). With HTTP, this " @@ -211,7 +203,7 @@ msgid "" "function from the :mod:`urllib.parse` library. ::" msgstr "" -#: ../../howto/urllib2.rst:110 +#: ../../howto/urllib2.rst:107 msgid "" "import urllib.parse\n" "import urllib.request\n" @@ -241,14 +233,14 @@ msgstr "" "with urllib.request.urlopen(req) as response:\n" " the_page = response.read()" -#: ../../howto/urllib2.rst:124 +#: ../../howto/urllib2.rst:121 msgid "" "Note that other encodings are sometimes required (e.g. for file upload from " "HTML forms - see `HTML Specification, Form Submission `_ for more details)." msgstr "" -#: ../../howto/urllib2.rst:129 +#: ../../howto/urllib2.rst:126 msgid "" "If you do not pass the ``data`` argument, urllib uses a **GET** request. One " "way in which GET and POST requests differ is that POST requests often have " @@ -261,11 +253,11 @@ msgid "" "be passed in an HTTP GET request by encoding it in the URL itself." msgstr "" -#: ../../howto/urllib2.rst:139 +#: ../../howto/urllib2.rst:136 msgid "This is done as follows::" msgstr "" -#: ../../howto/urllib2.rst:141 +#: ../../howto/urllib2.rst:138 msgid "" ">>> import urllib.request\n" ">>> import urllib.parse\n" @@ -293,23 +285,23 @@ msgstr "" ">>> full_url = url + '?' + url_values\n" ">>> data = urllib.request.urlopen(full_url)" -#: ../../howto/urllib2.rst:154 +#: ../../howto/urllib2.rst:151 msgid "" "Notice that the full URL is created by adding a ``?`` to the URL, followed " "by the encoded values." msgstr "" -#: ../../howto/urllib2.rst:158 +#: ../../howto/urllib2.rst:155 msgid "Headers" msgstr "" -#: ../../howto/urllib2.rst:160 +#: ../../howto/urllib2.rst:157 msgid "" "We'll discuss here one particular HTTP header, to illustrate how to add " "headers to your HTTP request." msgstr "" -#: ../../howto/urllib2.rst:163 +#: ../../howto/urllib2.rst:160 msgid "" "Some websites [#]_ dislike being browsed by programs, or send different " "versions to different browsers [#]_. By default urllib identifies itself as " @@ -322,7 +314,7 @@ msgid "" "Explorer [#]_. ::" msgstr "" -#: ../../howto/urllib2.rst:174 +#: ../../howto/urllib2.rst:171 msgid "" "import urllib.parse\n" "import urllib.request\n" @@ -356,39 +348,39 @@ msgstr "" "with urllib.request.urlopen(req) as response:\n" " the_page = response.read()" -#: ../../howto/urllib2.rst:190 +#: ../../howto/urllib2.rst:187 msgid "" "The response also has two useful methods. See the section on `info and " "geturl`_ which comes after we have a look at what happens when things go " "wrong." msgstr "" -#: ../../howto/urllib2.rst:195 +#: ../../howto/urllib2.rst:192 msgid "Handling Exceptions" msgstr "" -#: ../../howto/urllib2.rst:197 +#: ../../howto/urllib2.rst:194 msgid "" "*urlopen* raises :exc:`~urllib.error.URLError` when it cannot handle a " "response (though as usual with Python APIs, built-in exceptions such as :exc:" "`ValueError`, :exc:`TypeError` etc. may also be raised)." msgstr "" -#: ../../howto/urllib2.rst:201 +#: ../../howto/urllib2.rst:198 msgid "" ":exc:`~urllib.error.HTTPError` is the subclass of :exc:`~urllib.error." "URLError` raised in the specific case of HTTP URLs." msgstr "" -#: ../../howto/urllib2.rst:204 +#: ../../howto/urllib2.rst:201 msgid "The exception classes are exported from the :mod:`urllib.error` module." msgstr "" -#: ../../howto/urllib2.rst:207 +#: ../../howto/urllib2.rst:204 msgid "URLError" msgstr "URLError" -#: ../../howto/urllib2.rst:209 +#: ../../howto/urllib2.rst:206 msgid "" "Often, URLError is raised because there is no network connection (no route " "to the specified server), or the specified server doesn't exist. In this " @@ -396,11 +388,11 @@ msgid "" "containing an error code and a text error message." msgstr "" -#: ../../howto/urllib2.rst:214 +#: ../../howto/urllib2.rst:211 msgid "e.g. ::" msgstr "例如: ::" -#: ../../howto/urllib2.rst:216 +#: ../../howto/urllib2.rst:213 msgid "" ">>> req = urllib.request.Request('http://www.pretend_server.org')\n" ">>> try: urllib.request.urlopen(req)\n" @@ -416,11 +408,11 @@ msgstr "" "...\n" "(4, 'getaddrinfo failed')" -#: ../../howto/urllib2.rst:225 +#: ../../howto/urllib2.rst:222 msgid "HTTPError" msgstr "HTTPError" -#: ../../howto/urllib2.rst:227 +#: ../../howto/urllib2.rst:224 msgid "" "Every HTTP response from the server contains a numeric \"status code\". " "Sometimes the status code indicates that the server is unable to fulfil the " @@ -432,36 +424,36 @@ msgid "" "forbidden), and '401' (authentication required)." msgstr "" -#: ../../howto/urllib2.rst:235 +#: ../../howto/urllib2.rst:232 msgid "" "See section 10 of :rfc:`2616` for a reference on all the HTTP error codes." msgstr "" -#: ../../howto/urllib2.rst:237 +#: ../../howto/urllib2.rst:234 msgid "" "The :exc:`~urllib.error.HTTPError` instance raised will have an integer " "'code' attribute, which corresponds to the error sent by the server." msgstr "" -#: ../../howto/urllib2.rst:241 +#: ../../howto/urllib2.rst:238 msgid "Error Codes" msgstr "" -#: ../../howto/urllib2.rst:243 +#: ../../howto/urllib2.rst:240 msgid "" "Because the default handlers handle redirects (codes in the 300 range), and " "codes in the 100--299 range indicate success, you will usually only see " "error codes in the 400--599 range." msgstr "" -#: ../../howto/urllib2.rst:247 +#: ../../howto/urllib2.rst:244 msgid "" ":attr:`http.server.BaseHTTPRequestHandler.responses` is a useful dictionary " "of response codes that shows all the response codes used by :rfc:`2616`. An " "excerpt from the dictionary is shown below ::" msgstr "" -#: ../../howto/urllib2.rst:251 +#: ../../howto/urllib2.rst:248 msgid "" "responses = {\n" " ...\n" @@ -487,7 +479,7 @@ msgid "" " }" msgstr "" -#: ../../howto/urllib2.rst:271 +#: ../../howto/urllib2.rst:268 msgid "" "When an error is raised the server responds by returning an HTTP error code " "*and* an error page. You can use the :exc:`~urllib.error.HTTPError` instance " @@ -496,7 +488,7 @@ msgid "" "``urllib.response`` module::" msgstr "" -#: ../../howto/urllib2.rst:276 +#: ../../howto/urllib2.rst:273 msgid "" ">>> req = urllib.request.Request('http://www.python.org/fish.html')\n" ">>> try:\n" @@ -528,22 +520,22 @@ msgstr "" " Page Not Found\\n\n" " ..." -#: ../../howto/urllib2.rst:291 +#: ../../howto/urllib2.rst:288 msgid "Wrapping it Up" msgstr "" -#: ../../howto/urllib2.rst:293 +#: ../../howto/urllib2.rst:290 msgid "" "So if you want to be prepared for :exc:`~urllib.error.HTTPError` *or* :exc:" "`~urllib.error.URLError` there are two basic approaches. I prefer the second " "approach." msgstr "" -#: ../../howto/urllib2.rst:297 +#: ../../howto/urllib2.rst:294 msgid "Number 1" msgstr "" -#: ../../howto/urllib2.rst:302 +#: ../../howto/urllib2.rst:299 msgid "" "from urllib.request import Request, urlopen\n" "from urllib.error import URLError, HTTPError\n" @@ -560,17 +552,17 @@ msgid "" " # everything is fine" msgstr "" -#: ../../howto/urllib2.rst:319 +#: ../../howto/urllib2.rst:316 msgid "" "The ``except HTTPError`` *must* come first, otherwise ``except URLError`` " "will *also* catch an :exc:`~urllib.error.HTTPError`." msgstr "" -#: ../../howto/urllib2.rst:323 +#: ../../howto/urllib2.rst:320 msgid "Number 2" msgstr "" -#: ../../howto/urllib2.rst:327 +#: ../../howto/urllib2.rst:324 msgid "" "from urllib.request import Request, urlopen\n" "from urllib.error import URLError\n" @@ -588,18 +580,18 @@ msgid "" " # everything is fine" msgstr "" -#: ../../howto/urllib2.rst:344 +#: ../../howto/urllib2.rst:341 msgid "info and geturl" msgstr "" -#: ../../howto/urllib2.rst:346 +#: ../../howto/urllib2.rst:343 msgid "" "The response returned by urlopen (or the :exc:`~urllib.error.HTTPError` " "instance) has two useful methods :meth:`!info` and :meth:`!geturl` and is " "defined in the module :mod:`urllib.response`." msgstr "" -#: ../../howto/urllib2.rst:350 +#: ../../howto/urllib2.rst:347 msgid "" "**geturl** - this returns the real URL of the page fetched. This is useful " "because ``urlopen`` (or the opener object used) may have followed a " @@ -607,14 +599,14 @@ msgid "" "requested." msgstr "" -#: ../../howto/urllib2.rst:354 +#: ../../howto/urllib2.rst:351 msgid "" "**info** - this returns a dictionary-like object that describes the page " "fetched, particularly the headers sent by the server. It is currently an :" "class:`http.client.HTTPMessage` instance." msgstr "" -#: ../../howto/urllib2.rst:358 +#: ../../howto/urllib2.rst:355 msgid "" "Typical headers include 'Content-length', 'Content-type', and so on. See the " "`Quick Reference to HTTP Headers `_ for a " @@ -622,11 +614,11 @@ msgid "" "use." msgstr "" -#: ../../howto/urllib2.rst:365 +#: ../../howto/urllib2.rst:362 msgid "Openers and Handlers" msgstr "" -#: ../../howto/urllib2.rst:367 +#: ../../howto/urllib2.rst:364 msgid "" "When you fetch a URL you use an opener (an instance of the perhaps " "confusingly named :class:`urllib.request.OpenerDirector`). Normally we have " @@ -637,20 +629,20 @@ msgid "" "HTTP redirections or HTTP cookies." msgstr "" -#: ../../howto/urllib2.rst:375 +#: ../../howto/urllib2.rst:372 msgid "" "You will want to create openers if you want to fetch URLs with specific " "handlers installed, for example to get an opener that handles cookies, or to " "get an opener that does not handle redirections." msgstr "" -#: ../../howto/urllib2.rst:379 +#: ../../howto/urllib2.rst:376 msgid "" "To create an opener, instantiate an ``OpenerDirector``, and then call ``." "add_handler(some_handler_instance)`` repeatedly." msgstr "" -#: ../../howto/urllib2.rst:382 +#: ../../howto/urllib2.rst:379 msgid "" "Alternatively, you can use ``build_opener``, which is a convenience function " "for creating opener objects with a single function call. ``build_opener`` " @@ -658,31 +650,31 @@ msgid "" "or override the default handlers." msgstr "" -#: ../../howto/urllib2.rst:387 +#: ../../howto/urllib2.rst:384 msgid "" "Other sorts of handlers you might want to can handle proxies, " "authentication, and other common but slightly specialised situations." msgstr "" -#: ../../howto/urllib2.rst:390 +#: ../../howto/urllib2.rst:387 msgid "" "``install_opener`` can be used to make an ``opener`` object the (global) " "default opener. This means that calls to ``urlopen`` will use the opener you " "have installed." msgstr "" -#: ../../howto/urllib2.rst:394 +#: ../../howto/urllib2.rst:391 msgid "" "Opener objects have an ``open`` method, which can be called directly to " "fetch urls in the same way as the ``urlopen`` function: there's no need to " "call ``install_opener``, except as a convenience." msgstr "" -#: ../../howto/urllib2.rst:400 +#: ../../howto/urllib2.rst:397 msgid "Basic Authentication" msgstr "" -#: ../../howto/urllib2.rst:402 +#: ../../howto/urllib2.rst:399 msgid "" "To illustrate creating and installing a handler we will use the " "``HTTPBasicAuthHandler``. For a more detailed discussion of this subject -- " @@ -691,7 +683,7 @@ msgid "" "www.voidspace.org.uk/python/articles/authentication.shtml>`__." msgstr "" -#: ../../howto/urllib2.rst:408 +#: ../../howto/urllib2.rst:405 msgid "" "When authentication is required, the server sends a header (as well as the " "401 error code) requesting authentication. This specifies the " @@ -699,15 +691,15 @@ msgid "" "Authenticate: SCHEME realm=\"REALM\"``." msgstr "" -#: ../../howto/urllib2.rst:413 +#: ../../howto/urllib2.rst:410 msgid "e.g." msgstr "例如" -#: ../../howto/urllib2.rst:415 +#: ../../howto/urllib2.rst:412 msgid "WWW-Authenticate: Basic realm=\"cPanel Users\"" msgstr "WWW-Authenticate: Basic realm=\"cPanel Users\"" -#: ../../howto/urllib2.rst:420 +#: ../../howto/urllib2.rst:417 msgid "" "The client should then retry the request with the appropriate name and " "password for the realm included as a header in the request. This is 'basic " @@ -715,7 +707,7 @@ msgid "" "of ``HTTPBasicAuthHandler`` and an opener to use this handler." msgstr "" -#: ../../howto/urllib2.rst:425 +#: ../../howto/urllib2.rst:422 msgid "" "The ``HTTPBasicAuthHandler`` uses an object called a password manager to " "handle the mapping of URLs and realms to passwords and usernames. If you " @@ -728,13 +720,13 @@ msgid "" "by providing ``None`` as the realm argument to the ``add_password`` method." msgstr "" -#: ../../howto/urllib2.rst:435 +#: ../../howto/urllib2.rst:432 msgid "" "The top-level URL is the first URL that requires authentication. URLs " "\"deeper\" than the URL you pass to .add_password() will also match. ::" msgstr "" -#: ../../howto/urllib2.rst:438 +#: ../../howto/urllib2.rst:435 msgid "" "# create a password manager\n" "password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()\n" @@ -757,7 +749,7 @@ msgid "" "urllib.request.install_opener(opener)" msgstr "" -#: ../../howto/urllib2.rst:460 +#: ../../howto/urllib2.rst:457 msgid "" "In the above example we only supplied our ``HTTPBasicAuthHandler`` to " "``build_opener``. By default openers have the handlers for normal situations " @@ -767,7 +759,7 @@ msgid "" "``FileHandler``, ``DataHandler``, ``HTTPErrorProcessor``." msgstr "" -#: ../../howto/urllib2.rst:467 +#: ../../howto/urllib2.rst:464 msgid "" "``top_level_url`` is in fact *either* a full URL (including the 'http:' " "scheme component and the hostname and optionally the port number) e.g. " @@ -778,11 +770,11 @@ msgid "" "example ``\"joe:password@example.com\"`` is not correct." msgstr "" -#: ../../howto/urllib2.rst:477 +#: ../../howto/urllib2.rst:474 msgid "Proxies" msgstr "" -#: ../../howto/urllib2.rst:479 +#: ../../howto/urllib2.rst:476 msgid "" "**urllib** will auto-detect your proxy settings and use those. This is " "through the ``ProxyHandler``, which is part of the normal handler chain when " @@ -792,7 +784,7 @@ msgid "" "similar steps to setting up a `Basic Authentication`_ handler: ::" msgstr "" -#: ../../howto/urllib2.rst:486 +#: ../../howto/urllib2.rst:483 msgid "" ">>> proxy_support = urllib.request.ProxyHandler({})\n" ">>> opener = urllib.request.build_opener(proxy_support)\n" @@ -802,30 +794,30 @@ msgstr "" ">>> opener = urllib.request.build_opener(proxy_support)\n" ">>> urllib.request.install_opener(opener)" -#: ../../howto/urllib2.rst:492 +#: ../../howto/urllib2.rst:489 msgid "" "Currently ``urllib.request`` *does not* support fetching of ``https`` " "locations through a proxy. However, this can be enabled by extending urllib." "request as shown in the recipe [#]_." msgstr "" -#: ../../howto/urllib2.rst:498 +#: ../../howto/urllib2.rst:495 msgid "" "``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set; see " "the documentation on :func:`~urllib.request.getproxies`." msgstr "" -#: ../../howto/urllib2.rst:503 +#: ../../howto/urllib2.rst:500 msgid "Sockets and Layers" msgstr "" -#: ../../howto/urllib2.rst:505 +#: ../../howto/urllib2.rst:502 msgid "" "The Python support for fetching resources from the web is layered. urllib " "uses the :mod:`http.client` library, which in turn uses the socket library." msgstr "" -#: ../../howto/urllib2.rst:508 +#: ../../howto/urllib2.rst:505 msgid "" "As of Python 2.3 you can specify how long a socket should wait for a " "response before timing out. This can be useful in applications which have to " @@ -835,7 +827,7 @@ msgid "" "sockets using ::" msgstr "" -#: ../../howto/urllib2.rst:514 +#: ../../howto/urllib2.rst:511 msgid "" "import socket\n" "import urllib.request\n" @@ -850,38 +842,38 @@ msgid "" "response = urllib.request.urlopen(req)" msgstr "" -#: ../../howto/urllib2.rst:531 +#: ../../howto/urllib2.rst:528 msgid "Footnotes" msgstr "註腳" -#: ../../howto/urllib2.rst:533 +#: ../../howto/urllib2.rst:530 msgid "This document was reviewed and revised by John Lee." msgstr "" -#: ../../howto/urllib2.rst:535 +#: ../../howto/urllib2.rst:532 msgid "Google for example." msgstr "" -#: ../../howto/urllib2.rst:536 +#: ../../howto/urllib2.rst:533 msgid "" "Browser sniffing is a very bad practice for website design - building sites " "using web standards is much more sensible. Unfortunately a lot of sites " "still send different versions to different browsers." msgstr "" -#: ../../howto/urllib2.rst:539 +#: ../../howto/urllib2.rst:536 msgid "" "The user agent for MSIE 6 is *'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT " "5.1; SV1; .NET CLR 1.1.4322)'*" msgstr "" -#: ../../howto/urllib2.rst:541 +#: ../../howto/urllib2.rst:538 msgid "" "For details of more HTTP request headers, see `Quick Reference to HTTP " "Headers`_." msgstr "" -#: ../../howto/urllib2.rst:543 +#: ../../howto/urllib2.rst:540 msgid "" "In my case I have to use a proxy to access the internet at work. If you " "attempt to fetch *localhost* URLs through this proxy it blocks them. IE is " @@ -889,9 +881,15 @@ msgid "" "with a localhost server, I have to prevent urllib from using the proxy." msgstr "" -#: ../../howto/urllib2.rst:548 +#: ../../howto/urllib2.rst:545 msgid "" "urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe `_." msgstr "" + +#~ msgid "Author" +#~ msgstr "作者" + +#~ msgid "`Michael Foord `_" +#~ msgstr "`Michael Foord `_" diff --git a/library/_thread.po b/library/_thread.po index 17f730ce714..c98108ee45f 100644 --- a/library/_thread.po +++ b/library/_thread.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-03 00:49+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -167,7 +167,7 @@ msgstr "" "的值可用於在整個系統中唯一標識此特定執行緒(直到執行緒終止後,該值可能被操作" "系統重新使用)。" -#: ../../library/_thread.rst:118 ../../library/_thread.rst:143 +#: ../../library/_thread.rst:118 ../../library/_thread.rst:146 msgid "Availability" msgstr "可用性" @@ -175,7 +175,11 @@ msgstr "可用性" msgid "Added support for GNU/kFreeBSD." msgstr "新增了對 GNU/kFreeBSD 的支援。" -#: ../../library/_thread.rst:128 +#: ../../library/_thread.rst:125 +msgid "Added support for Solaris." +msgstr "新增了對 Solaris 的支援。" + +#: ../../library/_thread.rst:131 msgid "" "Return the thread stack size used when creating new threads. The optional " "*size* argument specifies the stack size to be used for subsequently created " @@ -203,11 +207,11 @@ msgstr "" "分配。應參考平台文件以取得更多訊息(4 KiB 頁面是比較普遍的;在缺乏更具體訊息" "的情況下,建議使用 4096 的倍數作為堆疊大小)。" -#: ../../library/_thread.rst:145 +#: ../../library/_thread.rst:148 msgid "Unix platforms with POSIX threads support." msgstr "Unix 平台上支援 POSIX 執行緒。" -#: ../../library/_thread.rst:150 +#: ../../library/_thread.rst:153 msgid "" "The maximum value allowed for the *timeout* parameter of :meth:`Lock.acquire " "`. Specifying a timeout greater than this value will " @@ -216,15 +220,15 @@ msgstr "" ":meth:`Lock.acquire ` 的 *timeout* 參數所允許的最大" "值。指定超過此值的 timeout 將引發 :exc:`OverflowError` 錯誤。" -#: ../../library/_thread.rst:166 +#: ../../library/_thread.rst:169 msgid "This is the type of lock objects." msgstr "這是鎖物件的型別。" -#: ../../library/_thread.rst:168 +#: ../../library/_thread.rst:171 msgid "Lock objects have the following methods:" msgstr "鎖物件具有以下方法:" -#: ../../library/_thread.rst:172 +#: ../../library/_thread.rst:175 msgid "" "Without any optional argument, this method acquires the lock " "unconditionally, if necessary waiting until it is released by another thread " @@ -234,7 +238,7 @@ msgstr "" "沒有任何可選引數時,此方法無條件地取得鎖,必要時會等待直到被另一個執行緒釋放" "(一次只能有一個執行緒取得鎖 --- 這正是鎖存在的原因)。" -#: ../../library/_thread.rst:176 +#: ../../library/_thread.rst:179 msgid "" "If the *blocking* argument is present, the action depends on its value: if " "it is false, the lock is only acquired if it can be acquired immediately " @@ -244,7 +248,7 @@ msgstr "" "如果存在 *blocking* 引數,則根據其值執行操作:如果為 False,只有在可以立即獲" "取鎖而無需等待的情況下才取得鎖,而如果為 True,則像上面一樣無條件地取得鎖。" -#: ../../library/_thread.rst:181 +#: ../../library/_thread.rst:184 msgid "" "If the floating-point *timeout* argument is present and positive, it " "specifies the maximum wait time in seconds before returning. A negative " @@ -255,44 +259,44 @@ msgstr "" "(以秒為單位)。如果 *timeout* 引數為負值,則表示等待時間會無限期地等待。如" "果 *blocking* 為 False,則你無法指定 *timeout*。" -#: ../../library/_thread.rst:186 +#: ../../library/_thread.rst:189 msgid "" "The return value is ``True`` if the lock is acquired successfully, ``False`` " "if not." msgstr "如果成功取得鎖,回傳值為 ``True``,否則為 ``False``。" -#: ../../library/_thread.rst:189 +#: ../../library/_thread.rst:192 msgid "The *timeout* parameter is new." msgstr "新增的 *timeout* 參數。" -#: ../../library/_thread.rst:192 +#: ../../library/_thread.rst:195 msgid "Lock acquires can now be interrupted by signals on POSIX." msgstr "現在取得鎖的操作可以被 POSIX 訊號中斷。" -#: ../../library/_thread.rst:195 +#: ../../library/_thread.rst:198 msgid "Lock acquires can now be interrupted by signals on Windows." msgstr "現在取得鎖的操作可以被 Windows 訊號中斷。" -#: ../../library/_thread.rst:200 +#: ../../library/_thread.rst:203 msgid "" "Releases the lock. The lock must have been acquired earlier, but not " "necessarily by the same thread." msgstr "釋放鎖。鎖必須先前被取得,但不一定是由同一個執行緒取得的。" -#: ../../library/_thread.rst:205 +#: ../../library/_thread.rst:208 msgid "" "Return the status of the lock: ``True`` if it has been acquired by some " "thread, ``False`` if not." msgstr "" "回傳鎖的狀態:如果鎖已被某個執行緒取得,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/_thread.rst:208 +#: ../../library/_thread.rst:211 msgid "" "In addition to these methods, lock objects can also be used via the :keyword:" "`with` statement, e.g.::" msgstr "除了這些方法之外,鎖物件還可以透過 :keyword:`with` 語句來使用,例如:" -#: ../../library/_thread.rst:211 +#: ../../library/_thread.rst:214 msgid "" "import _thread\n" "\n" @@ -308,17 +312,17 @@ msgstr "" "with a_lock:\n" " print(\"a_lock 在執行這裡時被鎖定\")" -#: ../../library/_thread.rst:218 +#: ../../library/_thread.rst:221 msgid "**Caveats:**" msgstr "**注意事項:**" -#: ../../library/_thread.rst:222 +#: ../../library/_thread.rst:225 msgid "" "Interrupts always go to the main thread (the :exc:`KeyboardInterrupt` " "exception will be received by that thread.)" msgstr "中斷總會跳到主執行緒(該執行緒將接收 :exc:`KeyboardInterrupt` 例外。)" -#: ../../library/_thread.rst:225 +#: ../../library/_thread.rst:228 msgid "" "Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is " "equivalent to calling :func:`_thread.exit`." @@ -326,7 +330,7 @@ msgstr "" "呼叫 :func:`sys.exit` 函式或引發 :exc:`SystemExit` 例外等同於呼叫 :func:" "`_thread.exit` 函式。" -#: ../../library/_thread.rst:228 +#: ../../library/_thread.rst:231 msgid "" "When the main thread exits, it is system defined whether the other threads " "survive. On most systems, they are killed without executing :keyword:" @@ -364,11 +368,11 @@ msgstr "threads(執行緒)" msgid "POSIX" msgstr "POSIX" -#: ../../library/_thread.rst:220 +#: ../../library/_thread.rst:223 msgid "module" msgstr "module(模組)" -#: ../../library/_thread.rst:220 +#: ../../library/_thread.rst:223 msgid "signal" msgstr "signal(訊號)" diff --git a/library/abc.po b/library/abc.po index 32a5e77698d..a8ec5fded42 100644 --- a/library/abc.po +++ b/library/abc.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-11-16 03:29+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!abc` --- Abstract Base Classes" msgstr ":mod:`!abc` --- 抽象基底類別" -#: ../../library/abc.rst:11 +#: ../../library/abc.rst:7 msgid "**Source code:** :source:`Lib/abc.py`" msgstr "**原始碼:**\\ :source:`Lib/abc.py`" -#: ../../library/abc.rst:15 +#: ../../library/abc.rst:11 msgid "" "This module provides the infrastructure for defining :term:`abstract base " "classes ` (ABCs) in Python, as outlined in :pep:`3119`; " @@ -40,7 +40,7 @@ msgstr "" "加這個模組,請見 PEP 文件。(也請見 :pep:`3141` 以及 :mod:`numbers` 模組以瞭" "解基於 ABC 的數字型別階層關係。)" -#: ../../library/abc.rst:20 +#: ../../library/abc.rst:16 msgid "" "The :mod:`collections` module has some concrete classes that derive from " "ABCs; these can, of course, be further derived. In addition, the :mod:" @@ -53,7 +53,7 @@ msgstr "" "試一個類別或實例是否提供特定介面,例如它是否\\ :term:`可雜湊 (hashable) " "` 或它是否為\\ :term:`對映 `。" -#: ../../library/abc.rst:27 +#: ../../library/abc.rst:23 msgid "" "This module provides the metaclass :class:`ABCMeta` for defining ABCs and a " "helper class :class:`ABC` to alternatively define ABCs through inheritance:" @@ -61,7 +61,7 @@ msgstr "" "該模組提供了一個用來定義 ABC 的元類別 (metaclass) :class:`ABCMeta` 和另一個以" "繼承的方式定義 ABC 的工具類別 :class:`ABC`:" -#: ../../library/abc.rst:32 +#: ../../library/abc.rst:28 msgid "" "A helper class that has :class:`ABCMeta` as its metaclass. With this class, " "an abstract base class can be created by simply deriving from :class:`!ABC` " @@ -71,7 +71,7 @@ msgstr "" "class:`!ABC` 衍生而建立,這就避免了在某些情況下會令人混淆的元類別用法,用法如" "以下範例: ::" -#: ../../library/abc.rst:36 +#: ../../library/abc.rst:32 msgid "" "from abc import ABC\n" "\n" @@ -83,7 +83,7 @@ msgstr "" "class MyABC(ABC):\n" " pass" -#: ../../library/abc.rst:41 +#: ../../library/abc.rst:37 msgid "" "Note that the type of :class:`!ABC` is still :class:`ABCMeta`, therefore " "inheriting from :class:`!ABC` requires the usual precautions regarding " @@ -95,7 +95,7 @@ msgstr "" "需要關注使用元類別的注意事項,如多重繼承可能會導致元類別衝突。當然你也可以傳" "入元類別關鍵字並直接使用 :class:`!ABCMeta` 來定義一個抽象基底類別,例如: ::" -#: ../../library/abc.rst:47 +#: ../../library/abc.rst:43 msgid "" "from abc import ABCMeta\n" "\n" @@ -107,11 +107,11 @@ msgstr "" "class MyABC(metaclass=ABCMeta):\n" " pass" -#: ../../library/abc.rst:57 +#: ../../library/abc.rst:53 msgid "Metaclass for defining Abstract Base Classes (ABCs)." msgstr "用於定義抽象基底類別(ABC)的元類別。" -#: ../../library/abc.rst:59 +#: ../../library/abc.rst:55 msgid "" "Use this metaclass to create an ABC. An ABC can be subclassed directly, and " "then acts as a mix-in class. You can also register unrelated concrete " @@ -129,18 +129,18 @@ msgstr "" "Resolution Order,方法解析順序)中,由該 ABC 所定義的方法實作也不可呼叫(即使" "透過 :func:`super` 呼叫也不行)。[#]_" -#: ../../library/abc.rst:68 +#: ../../library/abc.rst:64 msgid "" "Classes created with a metaclass of :class:`!ABCMeta` have the following " "method:" msgstr "使用 :class:`!ABCMeta` 作為元類別建立的類別含有以下的方法:" -#: ../../library/abc.rst:72 +#: ../../library/abc.rst:68 msgid "" "Register *subclass* as a \"virtual subclass\" of this ABC. For example::" msgstr "將\\ *子類別*\\ 註冊為該 ABC 的「抽象子類別」,例如: ::" -#: ../../library/abc.rst:75 +#: ../../library/abc.rst:71 msgid "" "from abc import ABC\n" "\n" @@ -162,26 +162,26 @@ msgstr "" "assert issubclass(tuple, MyABC)\n" "assert isinstance((), MyABC)" -#: ../../library/abc.rst:85 +#: ../../library/abc.rst:81 msgid "Returns the registered subclass, to allow usage as a class decorator." msgstr "回傳已註冊的子類別,使其能夠作為類別裝飾器。" -#: ../../library/abc.rst:88 +#: ../../library/abc.rst:84 msgid "" "To detect calls to :meth:`!register`, you can use the :func:" "`get_cache_token` function." msgstr "" "你可以使用 :func:`get_cache_token` 函式來檢測對 :meth:`!register` 的呼叫。" -#: ../../library/abc.rst:92 +#: ../../library/abc.rst:88 msgid "You can also override this method in an abstract base class:" msgstr "你也可以覆寫 (override) 虛擬基底類別中的這個方法:" -#: ../../library/abc.rst:96 +#: ../../library/abc.rst:92 msgid "(Must be defined as a class method.)" msgstr "(必須定義為類別方法。)" -#: ../../library/abc.rst:98 +#: ../../library/abc.rst:94 msgid "" "Check whether *subclass* is considered a subclass of this ABC. This means " "that you can customize the behavior of :func:`issubclass` further without " @@ -194,7 +194,7 @@ msgstr "" "叫 :meth:`register` 方法。(這個類別方法是在 ABC 的 :meth:`~type." "__subclasscheck__` 方法中呼叫。)" -#: ../../library/abc.rst:104 +#: ../../library/abc.rst:100 msgid "" "This method should return ``True``, ``False`` or :data:`NotImplemented`. If " "it returns ``True``, the *subclass* is considered a subclass of this ABC. If " @@ -207,12 +207,12 @@ msgstr "" "*subclass* 就會被判定並非該 ABC 的子類別,即便正常情況應如此。如果回傳 :data:" "`!NotImplemented`,子類別檢查會按照正常機制繼續執行。" -#: ../../library/abc.rst:114 +#: ../../library/abc.rst:110 msgid "" "For a demonstration of these concepts, look at this example ABC definition::" msgstr "為了對這些概念做一演示,請見以下定義 ABC 的範例: ::" -#: ../../library/abc.rst:116 +#: ../../library/abc.rst:112 msgid "" "class Foo:\n" " def __getitem__(self, index):\n" @@ -268,7 +268,7 @@ msgstr "" "\n" "MyIterable.register(Foo)" -#: ../../library/abc.rst:143 +#: ../../library/abc.rst:139 msgid "" "The ABC ``MyIterable`` defines the standard iterable method, :meth:`~object." "__iter__`, as an abstract method. The implementation given here can still " @@ -280,7 +280,7 @@ msgstr "" "__iter__`。這裡給定的實作仍可在子類別中被呼叫。:meth:`!get_iterator` 方法也" "是 ``MyIterable`` 抽象基底類別的一部分,但它不必被非抽象衍生類別覆寫。" -#: ../../library/abc.rst:149 +#: ../../library/abc.rst:145 msgid "" "The :meth:`__subclasshook__` class method defined here says that any class " "that has an :meth:`~object.__iter__` method in its :attr:`~object.__dict__` " @@ -291,7 +291,7 @@ msgstr "" "__dict__` (或在其透過 :attr:`~type.__mro__` 列表存取的基底類別) 中具有 :meth:" "`~object.__iter__` 方法的類別也都會被視為 ``MyIterable``。" -#: ../../library/abc.rst:154 +#: ../../library/abc.rst:150 msgid "" "Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``, " "even though it does not define an :meth:`~object.__iter__` method (it uses " @@ -305,15 +305,15 @@ msgstr "" "定),最末一行使其成為 ``MyIterable`` 的一個虛擬子類別。請注意這不會使 " "``get_iterator`` 成為 ``Foo`` 的一個可用方法,所以它是需要被另外提供的。" -#: ../../library/abc.rst:163 +#: ../../library/abc.rst:159 msgid "The :mod:`!abc` module also provides the following decorator:" msgstr ":mod:`!abc` 模組也提供了這些裝飾器:" -#: ../../library/abc.rst:167 +#: ../../library/abc.rst:163 msgid "A decorator indicating abstract methods." msgstr "用於表示抽象方法的裝飾器。" -#: ../../library/abc.rst:169 +#: ../../library/abc.rst:165 msgid "" "Using this decorator requires that the class's metaclass is :class:`ABCMeta` " "or is derived from it. A class that has a metaclass derived from :class:`!" @@ -327,7 +327,7 @@ msgstr "" "性均已被覆寫。抽象方法可透過任何一般的 'super' 呼叫機制來呼叫。:deco:`!" "abstractmethod` 可用來為特性和描述器宣告抽象方法。" -#: ../../library/abc.rst:176 +#: ../../library/abc.rst:172 msgid "" "Dynamically adding abstract methods to a class, or attempting to modify the " "abstraction status of a method or class once it is created, are only " @@ -341,7 +341,7 @@ msgstr "" "只會影響使用常規繼承所衍生出的子類別;透過 ABC 的 :meth:`~ABCMeta.register` " "方法註冊的「虛擬子類別」不會受到影響。" -#: ../../library/abc.rst:183 +#: ../../library/abc.rst:179 msgid "" "When :deco:`!abstractmethod` is applied in combination with other method " "descriptors, it should be applied as the innermost decorator, as shown in " @@ -350,7 +350,7 @@ msgstr "" "當 :deco:`!abstractmethod` 與其他方法描述器 (method descriptor) 配合應用時," "它應被當作最內層的裝飾器,如以下用法範例所示: ::" -#: ../../library/abc.rst:187 +#: ../../library/abc.rst:183 msgid "" "class C(ABC):\n" " @abstractmethod\n" @@ -412,7 +412,7 @@ msgstr "" " ...\n" " x = property(_get_x, _set_x)" -#: ../../library/abc.rst:217 +#: ../../library/abc.rst:213 msgid "" "In order to correctly interoperate with the abstract base class machinery, " "the descriptor must identify itself as abstract using :attr:`!" @@ -425,7 +425,7 @@ msgstr "" "一方法是抽象的,則此屬性應當為 ``True``。例如,Python 的內" "建 :deco:`property` 所做的就等價於: ::" -#: ../../library/abc.rst:223 +#: ../../library/abc.rst:219 msgid "" "class Descriptor:\n" " ...\n" @@ -441,7 +441,7 @@ msgstr "" " return any(getattr(f, '__isabstractmethod__', False) for\n" " f in (self._fget, self._fset, self._fdel))" -#: ../../library/abc.rst:232 +#: ../../library/abc.rst:228 msgid "" "Unlike Java abstract methods, these abstract methods may have an " "implementation. This implementation can be called via the :func:`super` " @@ -453,11 +453,11 @@ msgstr "" "上透過 :func:`super` 機制來呼叫。這在使用協作多重繼承 (cooperative multiple-" "inheritance) 的框架中,可以被用作 super 呼叫的一個端點 (end-point)。" -#: ../../library/abc.rst:239 +#: ../../library/abc.rst:235 msgid "The :mod:`!abc` module also supports the following legacy decorators:" msgstr ":mod:`!abc` 模組還支援下列舊式裝飾器:" -#: ../../library/abc.rst:244 +#: ../../library/abc.rst:240 msgid "" "It is now possible to use :deco:`classmethod` with :deco:`abstractmethod`, " "making this decorator redundant." @@ -465,7 +465,7 @@ msgstr "" "現在可以讓 :deco:`classmethod` 配合 :deco:`abstractmethod` 使用,使得此裝飾器" "變得冗餘。" -#: ../../library/abc.rst:248 +#: ../../library/abc.rst:244 msgid "" "A subclass of the built-in :class:`classmethod`, indicating an abstract " "classmethod. Otherwise it is similar to :deco:`abstractmethod`." @@ -473,7 +473,7 @@ msgstr "" "內建 :class:`classmethod` 的子類別,表示為一個抽象類別方法。在其他方面它都類" "似於 :deco:`abstractmethod`。" -#: ../../library/abc.rst:251 +#: ../../library/abc.rst:247 msgid "" "This special case is deprecated, as the :deco:`classmethod` decorator is now " "correctly identified as abstract when applied to an abstract method::" @@ -481,7 +481,7 @@ msgstr "" "這個特例已被棄用,因為現在當 :deco:`classmethod` 裝飾器應用於抽象方法時已會被" "正確地標識為是抽象的: ::" -#: ../../library/abc.rst:255 +#: ../../library/abc.rst:251 msgid "" "class C(ABC):\n" " @classmethod\n" @@ -495,7 +495,7 @@ msgstr "" " def my_abstract_classmethod(cls, arg):\n" " ..." -#: ../../library/abc.rst:265 +#: ../../library/abc.rst:261 msgid "" "It is now possible to use :deco:`staticmethod` with :deco:`abstractmethod`, " "making this decorator redundant." @@ -503,7 +503,7 @@ msgstr "" "現在可以讓 :deco:`staticmethod` 配合 :deco:`abstractmethod` 使用,使得此裝飾" "器變得冗餘。" -#: ../../library/abc.rst:269 +#: ../../library/abc.rst:265 msgid "" "A subclass of the built-in :class:`staticmethod`, indicating an abstract " "staticmethod. Otherwise it is similar to :deco:`abstractmethod`." @@ -511,7 +511,7 @@ msgstr "" "內建 :class:`staticmethod` 的子類別,表示為一個抽象靜態方法。在其他方面它都類" "似於 :deco:`abstractmethod`。" -#: ../../library/abc.rst:272 +#: ../../library/abc.rst:268 msgid "" "This special case is deprecated, as the :deco:`staticmethod` decorator is " "now correctly identified as abstract when applied to an abstract method::" @@ -519,7 +519,7 @@ msgstr "" "這個特例已被棄用,因為現在當 :deco:`staticmethod` 裝飾器應用於抽象方法時已會" "被正確地標識為是抽象的: ::" -#: ../../library/abc.rst:276 +#: ../../library/abc.rst:272 msgid "" "class C(ABC):\n" " @staticmethod\n" @@ -533,7 +533,7 @@ msgstr "" " def my_abstract_staticmethod(arg):\n" " ..." -#: ../../library/abc.rst:285 +#: ../../library/abc.rst:281 msgid "" "It is now possible to use :deco:`property`, :deco:`property.getter`, :deco:" "`property.setter` and :deco:`property.deleter` with :deco:`abstractmethod`, " @@ -544,13 +544,13 @@ msgstr "" "和 :deco:`property.deleter` 配合 :deco:`abstractmethod` 使用,使得此裝飾器變" "得冗餘。" -#: ../../library/abc.rst:290 +#: ../../library/abc.rst:286 msgid "" "A subclass of the built-in :class:`property`, indicating an abstract " "property." msgstr "內建 :class:`property` 的子類別,表示為一個抽象特性。" -#: ../../library/abc.rst:293 +#: ../../library/abc.rst:289 msgid "" "This special case is deprecated, as the :deco:`property` decorator is now " "correctly identified as abstract when applied to an abstract method::" @@ -558,7 +558,7 @@ msgstr "" "這個特例已被棄用,因為現在當 :deco:`property` 裝飾器應用於抽象方法時已會被正" "確地標識為是抽象的: ::" -#: ../../library/abc.rst:297 +#: ../../library/abc.rst:293 msgid "" "class C(ABC):\n" " @property\n" @@ -572,7 +572,7 @@ msgstr "" " def my_abstract_property(self):\n" " ..." -#: ../../library/abc.rst:303 +#: ../../library/abc.rst:299 msgid "" "The above example defines a read-only property; you can also define a read-" "write abstract property by appropriately marking one or more of the " @@ -581,7 +581,7 @@ msgstr "" "上面的例子定義了一個唯讀特性;你也可以透過適當地將一個或多個底層方法標記為抽" "象的來定義可讀寫的抽象特性: ::" -#: ../../library/abc.rst:307 +#: ../../library/abc.rst:303 msgid "" "class C(ABC):\n" " @property\n" @@ -603,14 +603,14 @@ msgstr "" " def x(self, val):\n" " ..." -#: ../../library/abc.rst:317 +#: ../../library/abc.rst:313 msgid "" "If only some components are abstract, only those components need to be " "updated to create a concrete property in a subclass::" msgstr "" "如果只有某些元件是抽象的,則只需更新那些元件即可在子類別中建立具體的特性: ::" -#: ../../library/abc.rst:320 +#: ../../library/abc.rst:316 msgid "" "class D(C):\n" " @C.x.setter\n" @@ -622,15 +622,15 @@ msgstr "" " def x(self, val):\n" " ..." -#: ../../library/abc.rst:326 +#: ../../library/abc.rst:322 msgid "The :mod:`!abc` module also provides the following functions:" msgstr ":mod:`!abc` 模組也提供了這些函式:" -#: ../../library/abc.rst:330 +#: ../../library/abc.rst:326 msgid "Returns the current abstract base class cache token." msgstr "回傳目前 ABC 快取令牌 (cache token)。" -#: ../../library/abc.rst:332 +#: ../../library/abc.rst:328 msgid "" "The token is an opaque object (that supports equality testing) identifying " "the current version of the abstract base class cache for virtual subclasses. " @@ -640,7 +640,7 @@ msgstr "" "標識抽象基底類別快取的目前版本。此令牌會在任何 ABC 上每次呼叫 :meth:`ABCMeta." "register` 時發生更改。" -#: ../../library/abc.rst:340 +#: ../../library/abc.rst:336 msgid "" "A function to recalculate an abstract class's abstraction status. This " "function should be called if a class's abstract methods have been " @@ -650,26 +650,26 @@ msgstr "" "重新計算一個抽象類別之抽象狀態的函式。如果一個類別的抽象方法在建立後被實作或" "被修改,則應當呼叫此函式。通常此函式應在一個類別裝飾器內部被呼叫。" -#: ../../library/abc.rst:345 +#: ../../library/abc.rst:341 msgid "Returns *cls*, to allow usage as a class decorator." msgstr "回傳 *cls*,使其能夠用作為類別的裝飾器。" -#: ../../library/abc.rst:347 +#: ../../library/abc.rst:343 msgid "If *cls* is not an instance of :class:`ABCMeta`, does nothing." msgstr "如果 *cls* 不是 :class:`ABCMeta` 的實例則不做任何操作。" -#: ../../library/abc.rst:351 +#: ../../library/abc.rst:347 msgid "" "This function assumes that *cls*'s superclasses are already updated. It does " "not update any subclasses." msgstr "" "此函式會假定 *cls* 的超類別 (superclass) 已經被更新。它不會更新任何子類別。" -#: ../../library/abc.rst:357 +#: ../../library/abc.rst:353 msgid "Footnotes" msgstr "註腳" -#: ../../library/abc.rst:358 +#: ../../library/abc.rst:354 msgid "" "C++ programmers should note that Python's virtual base class concept is not " "the same as C++'s." diff --git a/library/annotationlib.po b/library/annotationlib.po index 89b082cc938..4ea72c7f9a1 100644 --- a/library/annotationlib.po +++ b/library/annotationlib.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-15 00:10+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -785,14 +785,14 @@ msgstr "" #: ../../library/annotationlib.rst:538 msgid "" -"Optional: A tuple of the function's positional defaults ``__kwdefaults__``, " -"if the function represented by ``__code__`` uses any positional defaults." +"Optional: A tuple of the function's positional defaults ``__defaults__``, if " +"the function represented by ``__code__`` uses any positional defaults." msgstr "" #: ../../library/annotationlib.rst:540 msgid "" -"Optional: A dict of the function's keyword defaults ``__defaults__``, if the " -"function represented by ``__code__`` uses any keyword defaults." +"Optional: A dict of the function's keyword defaults ``__kwdefaults__``, if " +"the function represented by ``__code__`` uses any keyword defaults." msgstr "" #: ../../library/annotationlib.rst:542 diff --git a/library/argparse.po b/library/argparse.po index 90b2671d6be..0ee45cd8971 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-06 00:21+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:38+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgid "" "subcommands" msgstr ":mod:`!argparse` --- 命令列選項、引數和子命令的剖析器" -#: ../../library/argparse.rst:12 +#: ../../library/argparse.rst:9 msgid "**Source code:** :source:`Lib/argparse.py`" msgstr "**原始碼:**\\ :source:`Lib/argparse.py`" -#: ../../library/argparse.rst:16 +#: ../../library/argparse.rst:13 msgid "" "While :mod:`!argparse` is the default recommended standard library module " "for implementing basic command line applications, authors with more exacting " @@ -49,7 +49,7 @@ msgstr "" msgid "Tutorial" msgstr "教學" -#: ../../library/argparse.rst:30 +#: ../../library/argparse.rst:27 msgid "" "This page contains the API reference information. For a more gentle " "introduction to Python command-line parsing, have a look at the :ref:" @@ -58,7 +58,7 @@ msgstr "" "本頁包含 API 參考資訊。如需更淺顯的 Python 命令列剖析介紹,請參閱 :ref:" "`argparse 教學 `。" -#: ../../library/argparse.rst:34 +#: ../../library/argparse.rst:31 msgid "" "The :mod:`!argparse` module makes it easy to write user-friendly command-" "line interfaces. The program defines what arguments it requires, and :mod:`!" @@ -72,7 +72,7 @@ msgstr "" "mod:`!argparse` 模組也會自動產生說明和用法訊息。當使用者向程式提供無效引數" "時,此模組也會發出錯誤。" -#: ../../library/argparse.rst:40 +#: ../../library/argparse.rst:37 msgid "" "The :mod:`!argparse` module's support for command-line interfaces is built " "around an instance of :class:`argparse.ArgumentParser`. It is a container " @@ -83,7 +83,7 @@ msgstr "" "ArgumentParser` 的實例建構的。它是引數規格的容器,並具有適用於整個剖析器的選" "項: ::" -#: ../../library/argparse.rst:44 +#: ../../library/argparse.rst:41 msgid "" "parser = argparse.ArgumentParser(\n" " prog='ProgramName',\n" @@ -95,7 +95,7 @@ msgstr "" " description='What the program does',\n" " epilog='Text at the bottom of help')" -#: ../../library/argparse.rst:49 +#: ../../library/argparse.rst:46 msgid "" "The :meth:`ArgumentParser.add_argument` method attaches individual argument " "specifications to the parser. It supports positional arguments, options " @@ -104,7 +104,7 @@ msgstr "" ":meth:`ArgumentParser.add_argument` 方法會將個別的引數規格附加到剖析器。它支" "援位置引數、接受值的選項以及開關旗標:::" -#: ../../library/argparse.rst:53 +#: ../../library/argparse.rst:50 msgid "" "parser.add_argument('filename') # positional argument\n" "parser.add_argument('-c', '--count') # option that takes a value\n" @@ -116,7 +116,7 @@ msgstr "" "parser.add_argument('-v', '--verbose',\n" " action='store_true') # 開關旗標" -#: ../../library/argparse.rst:58 +#: ../../library/argparse.rst:55 msgid "" "The :meth:`ArgumentParser.parse_args` method runs the parser and places the " "extracted data in a :class:`argparse.Namespace` object::" @@ -124,7 +124,7 @@ msgstr "" ":meth:`ArgumentParser.parse_args` 方法會執行剖析器,並將擷取的資料放入一個 :" "class:`argparse.Namespace` 物件中:::" -#: ../../library/argparse.rst:61 +#: ../../library/argparse.rst:58 msgid "" "args = parser.parse_args()\n" "print(args.filename, args.count, args.verbose)" @@ -132,7 +132,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args.filename, args.count, args.verbose)" -#: ../../library/argparse.rst:65 +#: ../../library/argparse.rst:62 msgid "" "If you're looking for a guide about how to upgrade :mod:`optparse` code to :" "mod:`!argparse`, see :ref:`Upgrading Optparse Code `。" -#: ../../library/argparse.rst:69 +#: ../../library/argparse.rst:66 msgid "ArgumentParser objects" msgstr "ArgumentParser 物件" -#: ../../library/argparse.rst:79 +#: ../../library/argparse.rst:76 msgid "" "Create a new :class:`ArgumentParser` object. All parameters should be passed " "as keyword arguments. Each parameter has its own more detailed description " @@ -154,45 +154,45 @@ msgstr "" "建立一個新的 :class:`ArgumentParser` 物件。所有參數都應該作為關鍵字引數傳入。" "每個參數在下面都有更詳細的描述,簡而言之它們是:" -#: ../../library/argparse.rst:83 +#: ../../library/argparse.rst:80 msgid "" "prog_ - The name of the program (default: generated from the ``__main__`` " "module attributes and ``sys.argv[0]``)" msgstr "" "prog_ - 程式的名稱(預設值:從 ``__main__`` 模組屬性和 ``sys.argv[0]`` 產生)" -#: ../../library/argparse.rst:86 +#: ../../library/argparse.rst:83 msgid "" "usage_ - The string describing the program usage (default: generated from " "arguments added to parser)" msgstr "usage_ - 描述程式用法的字串(預設值:從新增到剖析器的引數產生)" -#: ../../library/argparse.rst:89 +#: ../../library/argparse.rst:86 msgid "" "description_ - Text to display before the argument help (by default, no text)" msgstr "description_ - 引數說明之前要顯示的文字(預設值:無文字)" -#: ../../library/argparse.rst:92 +#: ../../library/argparse.rst:89 msgid "epilog_ - Text to display after the argument help (by default, no text)" msgstr "epilog_ - 引數說明之後要顯示的文字(預設值:無文字)" -#: ../../library/argparse.rst:94 +#: ../../library/argparse.rst:91 msgid "" "parents_ - A list of :class:`ArgumentParser` objects whose arguments should " "also be included" msgstr "parents_ - 一個 :class:`ArgumentParser` 物件的串列,其引數也應該被包含" -#: ../../library/argparse.rst:97 +#: ../../library/argparse.rst:94 msgid "formatter_class_ - A class for customizing the help output" msgstr "formatter_class_ - 用於自訂幫助說明輸出的類別" -#: ../../library/argparse.rst:99 +#: ../../library/argparse.rst:96 msgid "" "prefix_chars_ - The set of characters that prefix optional arguments " "(default: '-')" msgstr "prefix_chars_ - 前綴可選引數的字元集合(預設值:'-')" -#: ../../library/argparse.rst:102 +#: ../../library/argparse.rst:99 msgid "" "fromfile_prefix_chars_ - The set of characters that prefix files from which " "additional arguments should be read (default: ``None``)" @@ -200,31 +200,31 @@ msgstr "" "fromfile_prefix_chars_ - 前綴檔案的字元集合,額外引數將從這些檔案中讀取(預設" "值:``None``)" -#: ../../library/argparse.rst:105 +#: ../../library/argparse.rst:102 msgid "" "argument_default_ - The global default value for arguments (default: " "``None``)" msgstr "argument_default_ - 引數的全域預設值(預設值:``None``)" -#: ../../library/argparse.rst:108 +#: ../../library/argparse.rst:105 msgid "" "conflict_handler_ - The strategy for resolving conflicting optionals " "(usually unnecessary)" msgstr "conflict_handler_ - 解決衝突可選引數的策略(通常不需要)" -#: ../../library/argparse.rst:111 +#: ../../library/argparse.rst:108 msgid "" "add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)" msgstr "add_help_ - 加入一個 ``-h/--help`` 選項到剖析器(預設值:``True``)" -#: ../../library/argparse.rst:113 +#: ../../library/argparse.rst:110 msgid "" "allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is " "unambiguous (default: ``True``)" msgstr "" "allow_abbrev_ - 允許長選項被縮寫,只要縮寫是無歧義的(預設值:``True``)" -#: ../../library/argparse.rst:116 +#: ../../library/argparse.rst:113 msgid "" "exit_on_error_ - Determines whether or not :class:`!ArgumentParser` exits " "with error info when an error occurs. (default: ``True``)" @@ -232,23 +232,23 @@ msgstr "" "exit_on_error_ - 決定 :class:`!ArgumentParser` 在發生錯誤時是否帶著錯誤資訊退" "出。(預設值:``True``)" -#: ../../library/argparse.rst:119 +#: ../../library/argparse.rst:116 msgid "" "suggest_on_error_ - Enables suggestions for mistyped argument choices and " -"subparser names (default: ``False``)" +"subparser names (default: ``True``)" msgstr "" "suggest_on_error_ - 啟用對拼錯的引數選擇和子剖析器名稱的建議(預設值:" -"``False``)" +"``True``)" -#: ../../library/argparse.rst:122 +#: ../../library/argparse.rst:119 msgid "color_ - Allow color output (default: ``True``)" msgstr "color_ - 允許彩色輸出(預設值:``True``)" -#: ../../library/argparse.rst:124 +#: ../../library/argparse.rst:121 msgid "*allow_abbrev* parameter was added." msgstr "新增 *allow_abbrev* 參數。" -#: ../../library/argparse.rst:127 +#: ../../library/argparse.rst:124 msgid "" "In previous versions, *allow_abbrev* also disabled grouping of short flags " "such as ``-vv`` to mean ``-v -v``." @@ -256,15 +256,19 @@ msgstr "" "在之前的版本中,*allow_abbrev* 也會停用短旗標的分組,例如以 ``-vv`` 表示 ``-" "v -v``。" -#: ../../library/argparse.rst:131 +#: ../../library/argparse.rst:128 msgid "*exit_on_error* parameter was added." msgstr "新增 *exit_on_error* 參數。" -#: ../../library/argparse.rst:134 +#: ../../library/argparse.rst:131 msgid "*suggest_on_error* and *color* parameters were added." msgstr "新增 *suggest_on_error* 和 *color* 參數。" -#: ../../library/argparse.rst:137 ../../library/argparse.rst:695 +#: ../../library/argparse.rst:134 +msgid "*suggest_on_error* default changed to ``True``." +msgstr "" + +#: ../../library/argparse.rst:137 ../../library/argparse.rst:699 msgid "The following sections describe how each of these are used." msgstr "以下各節描述了這些參數的使用方式。" @@ -1186,26 +1190,19 @@ msgstr "suggest_on_error" #: ../../library/argparse.rst:597 msgid "" "By default, when a user passes an invalid argument choice or subparser " -"name, :class:`ArgumentParser` will exit with error info and list the " -"permissible argument choices (if specified) or subparser names as part of " -"the error message." -msgstr "" -"預設情況下,當使用者傳入無效的引數選擇或子剖析器名稱時,:class:" -"`ArgumentParser` 會帶著錯誤資訊退出,並將允許的引數選擇(如果有指定的話)或子" -"剖析器名稱列為錯誤訊息的一部分。" - -#: ../../library/argparse.rst:601 -msgid "" -"If the user would like to enable suggestions for mistyped argument choices " -"and subparser names, the feature can be enabled by setting " -"``suggest_on_error`` to ``True``. Note that this only applies for arguments " -"when the choices specified are strings::" +"name, :class:`ArgumentParser` will exit with error info and provide " +"suggestions for mistyped arguments. The error message will list the " +"permissible argument choices (if specified) or subparser names, along with a " +"\"maybe you meant\" suggestion if a close match is found. Note that this " +"only applies for arguments when the choices specified are strings::" msgstr "" -"如果使用者想要啟用對拼錯的引數選擇和子剖析器名稱的建議,可以透過將 " -"``suggest_on_error`` 設為 ``True`` 來啟用此功能。請注意,這僅適用於指定的選擇" -"皆為字串的引數: ::" +"預設情況下,當使用者傳入無效的引數選擇或子剖析器名稱" +"時,:class:`ArgumentParser` 會帶著錯誤資訊退出,並為拼錯的引數提供建議。錯誤" +"訊息會列出允許的引數選擇(如果有指定的話)或子剖析器名稱,若找到相近的項目," +"還會附上「maybe you meant」的建議。請注意,這僅適用於指定的選擇為字串的引" +"數: ::" -#: ../../library/argparse.rst:606 +#: ../../library/argparse.rst:604 msgid "" ">>> parser = argparse.ArgumentParser(suggest_on_error=True)\n" ">>> parser.add_argument('--action', choices=['debug', 'dryrun'])\n" @@ -1221,30 +1218,21 @@ msgstr "" "tester.py: error: argument --action: invalid choice: 'debugg', maybe you " "meant 'debug'? (choose from debug, dryrun)" -#: ../../library/argparse.rst:612 +#: ../../library/argparse.rst:610 msgid "" -"If you're writing code that needs to be compatible with older Python " -"versions and want to opportunistically use ``suggest_on_error`` when it's " -"available, you can set it as an attribute after initializing the parser " -"instead of using the keyword argument::" -msgstr "" -"如果你正在撰寫需要與舊版 Python 相容的程式碼,並且想要在 " -"``suggest_on_error`` 可用時伺機使用它,你可以在初始化剖析器後將其設為屬性,而" -"非使用關鍵字引數: ::" +"You can disable suggestions by setting ``suggest_on_error`` to ``False``." +msgstr "可以透過將 ``suggest_on_error`` 設為 ``False`` 來停用建議。" -#: ../../library/argparse.rst:617 +#: ../../library/argparse.rst:613 msgid "" -">>> parser = argparse.ArgumentParser(description='Process some integers.')\n" -">>> parser.suggest_on_error = True" +"Changed default value of ``suggest_on_error`` from ``False`` to ``True``." msgstr "" -">>> parser = argparse.ArgumentParser(description='Process some integers.')\n" -">>> parser.suggest_on_error = True" -#: ../../library/argparse.rst:624 +#: ../../library/argparse.rst:617 msgid "color" msgstr "color" -#: ../../library/argparse.rst:626 +#: ../../library/argparse.rst:619 msgid "" "By default, the help message is printed in color using `ANSI escape " "sequences `__. If you want " @@ -1257,7 +1245,7 @@ msgstr "" "你的本地環境中 `\\ 停用它,或是透過將 ``color`` " "設為 ``False`` 在引數剖析器本身停用: ::" -#: ../../library/argparse.rst:632 +#: ../../library/argparse.rst:625 msgid "" ">>> parser = argparse.ArgumentParser(description='Process some integers.',\n" "... color=False)\n" @@ -1273,7 +1261,7 @@ msgstr "" "... help='an integer for the accumulator')\n" ">>> parser.parse_args(['--help'])" -#: ../../library/argparse.rst:639 +#: ../../library/argparse.rst:632 msgid "" "Note that when ``color=True``, colored output depends on both environment " "variables and terminal capabilities. However, if ``color=False``, colored " @@ -1284,21 +1272,44 @@ msgstr "" "``color=False``,即使設定了 ``FORCE_COLOR`` 之類的環境變數,彩色輸出也是會被" "停用。" -#: ../../library/argparse.rst:646 +#: ../../library/argparse.rst:639 +msgid "" +"To highlight inline code in your description, epilog, or argument ``help`` " +"text, you can use single or double backticks::" +msgstr "" + +#: ../../library/argparse.rst:642 msgid "" -"Error messages will include color codes when redirecting stderr to a file. " -"To avoid this, set the |NO_COLOR|_ or :envvar:`PYTHON_COLORS` environment " -"variable (for example, ``NO_COLOR=1 python script.py 2> errors.txt``)." +">>> parser = argparse.ArgumentParser(\n" +"... formatter_class=argparse.RawDescriptionHelpFormatter,\n" +"... description='Run ``python -m myapp`` to start.',\n" +"... epilog='''Examples:\n" +"... `python -m myapp --verbose`\n" +"... ``python -m myapp --config settings.json``\n" +"... ''')\n" +">>> parser.add_argument('--foo', help='set the `foo` value')" +msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... formatter_class=argparse.RawDescriptionHelpFormatter,\n" +"... description='Run ``python -m myapp`` to start.',\n" +"... epilog='''Examples:\n" +"... `python -m myapp --verbose`\n" +"... ``python -m myapp --config settings.json``\n" +"... ''')\n" +">>> parser.add_argument('--foo', help='set the `foo` value')" + +#: ../../library/argparse.rst:651 +msgid "" +"When colors are enabled, the text inside backticks will be displayed in a " +"distinct color to help examples stand out. When colors are disabled, " +"backticks are preserved as-is, which is readable in plain text." msgstr "" -"將 stderr 重新導向到檔案時,錯誤訊息會包含顏色代碼。若要避免此情況,請設定 |" -"NO_COLOR|_ 或 :envvar:`PYTHON_COLORS` 環境變數(例如 ``NO_COLOR=1 python " -"script.py 2> errors.txt``)。" -#: ../../library/argparse.rst:655 +#: ../../library/argparse.rst:659 msgid "The add_argument() method" msgstr "add_argument() 方法" -#: ../../library/argparse.rst:661 +#: ../../library/argparse.rst:665 msgid "" "Define how a single command-line argument should be parsed. Each parameter " "has its own more detailed description below, but in short they are:" @@ -1306,7 +1317,7 @@ msgstr "" "定義單個命令列引數應如何被剖析。每個參數在下面都有更詳細的描述,簡而言之它們" "是:" -#: ../../library/argparse.rst:664 +#: ../../library/argparse.rst:668 msgid "" "`name or flags`_ - Either a name or a list of option strings, e.g. ``'foo'`` " "or ``'-f', '--foo'``." @@ -1314,69 +1325,69 @@ msgstr "" "`name or flags`_ - 一個名稱或選項字串的串列,例如 ``'foo'`` 或 ``'-f', '--" "foo'``。" -#: ../../library/argparse.rst:667 +#: ../../library/argparse.rst:671 msgid "" "action_ - The basic type of action to be taken when this argument is " "encountered at the command line." msgstr "action_ - 在命令列遇到此引數時要執行的基本 action 類型。" -#: ../../library/argparse.rst:670 +#: ../../library/argparse.rst:674 msgid "nargs_ - The number of command-line arguments that should be consumed." msgstr "nargs_ - 應消耗的命令列引數數量。" -#: ../../library/argparse.rst:672 +#: ../../library/argparse.rst:676 msgid "" "const_ - A constant value required by some action_ and nargs_ selections." msgstr "const_ - 某些 action_ 和 nargs_ 選擇所需的常數值。" -#: ../../library/argparse.rst:674 +#: ../../library/argparse.rst:678 msgid "" "default_ - The value produced if the argument is absent from the command " "line and if it is absent from the namespace object." msgstr "default_ - 如果引數不在命令列中且不在命名空間物件中時所產生的值。" -#: ../../library/argparse.rst:677 +#: ../../library/argparse.rst:681 msgid "" "type_ - The type to which the command-line argument should be converted." msgstr "type_ - 命令列引數應轉換成的型別。" -#: ../../library/argparse.rst:679 +#: ../../library/argparse.rst:683 msgid "choices_ - A sequence of the allowable values for the argument." msgstr "choices_ - 引數允許值的序列。" -#: ../../library/argparse.rst:681 +#: ../../library/argparse.rst:685 msgid "" "required_ - Whether or not the command-line option may be omitted (optionals " "only)." msgstr "required_ - 命令列選項是否可省略(僅限可選引數)。" -#: ../../library/argparse.rst:684 +#: ../../library/argparse.rst:688 msgid "help_ - A brief description of what the argument does." msgstr "help_ - 引數功能的簡短描述。" -#: ../../library/argparse.rst:686 +#: ../../library/argparse.rst:690 msgid "metavar_ - A name for the argument in usage messages." msgstr "metavar_ - 引數在用法訊息中的名稱。" -#: ../../library/argparse.rst:688 +#: ../../library/argparse.rst:692 msgid "" "dest_ - The name of the attribute to be added to the object returned by :" "meth:`parse_args`." msgstr "dest_ - 要加入到 :meth:`parse_args` 回傳物件中的屬性名稱。" -#: ../../library/argparse.rst:691 +#: ../../library/argparse.rst:695 msgid "deprecated_ - Whether or not use of the argument is deprecated." msgstr "deprecated_ - 引數的使用是否已被棄用。" -#: ../../library/argparse.rst:693 +#: ../../library/argparse.rst:697 msgid "The method returns an :class:`Action` object representing the argument." msgstr "" -#: ../../library/argparse.rst:701 +#: ../../library/argparse.rst:705 msgid "name or flags" msgstr "name or flags" -#: ../../library/argparse.rst:703 +#: ../../library/argparse.rst:707 msgid "" "The :meth:`~ArgumentParser.add_argument` method must know whether an " "optional argument, like ``-f`` or ``--foo``, or a positional argument, like " @@ -1389,23 +1400,23 @@ msgstr "" "`~ArgumentParser.add_argument` 的第一個引數必須是一系列旗標或一個簡單的引數名" "稱。" -#: ../../library/argparse.rst:709 +#: ../../library/argparse.rst:713 msgid "For example, an optional argument could be created like::" msgstr "例如,可選引數可以像這樣建立: ::" -#: ../../library/argparse.rst:711 +#: ../../library/argparse.rst:715 msgid ">>> parser.add_argument('-f', '--foo')" msgstr ">>> parser.add_argument('-f', '--foo')" -#: ../../library/argparse.rst:713 +#: ../../library/argparse.rst:717 msgid "while a positional argument could be created like::" msgstr "而位置引數可以像這樣建立: ::" -#: ../../library/argparse.rst:715 +#: ../../library/argparse.rst:719 msgid ">>> parser.add_argument('bar')" msgstr ">>> parser.add_argument('bar')" -#: ../../library/argparse.rst:717 +#: ../../library/argparse.rst:721 msgid "" "When :meth:`~ArgumentParser.parse_args` is called, optional arguments will " "be identified by the ``-`` prefix, and the remaining arguments will be " @@ -1414,7 +1425,7 @@ msgstr "" "當呼叫 :meth:`~ArgumentParser.parse_args` 時,可選引數會透過 ``-`` 前綴來辨" "識,其餘的引數則假設為位置引數: ::" -#: ../../library/argparse.rst:721 +#: ../../library/argparse.rst:725 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo')\n" @@ -1438,7 +1449,7 @@ msgstr "" "usage: PROG [-h] [-f FOO] bar\n" "PROG: error: the following arguments are required: bar" -#: ../../library/argparse.rst:732 +#: ../../library/argparse.rst:736 msgid "" "By default, :mod:`!argparse` automatically handles the internal naming and " "display names of arguments, simplifying the process without requiring " @@ -1452,7 +1463,7 @@ msgstr "" "dest_ 參數預設為引數名稱,以底線 ``_`` 取代連字號 ``-``。metavar_ 參數預設為" "大寫的名稱。例如: ::" -#: ../../library/argparse.rst:740 +#: ../../library/argparse.rst:744 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo-bar')\n" @@ -1476,11 +1487,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo-bar FOO-BAR" -#: ../../library/argparse.rst:755 +#: ../../library/argparse.rst:759 msgid "action" msgstr "action" -#: ../../library/argparse.rst:757 +#: ../../library/argparse.rst:761 msgid "" ":class:`ArgumentParser` objects associate command-line arguments with " "actions. These actions can do just about anything with the command-line " @@ -1494,13 +1505,13 @@ msgstr "" "meth:`~ArgumentParser.parse_args` 回傳的物件中。``action`` 關鍵字引數指定命令" "列引數應如何被處理。提供的 action 有:" -#: ../../library/argparse.rst:763 +#: ../../library/argparse.rst:767 msgid "" "``'store'`` - This just stores the argument's value. This is the default " "action." msgstr "``'store'`` - 這只是儲存引數的值。這是預設的 action。" -#: ../../library/argparse.rst:766 +#: ../../library/argparse.rst:770 msgid "" "``'store_const'`` - This stores the value specified by the const_ keyword " "argument; note that the const_ keyword argument defaults to ``None``. The " @@ -1511,7 +1522,7 @@ msgstr "" "引數預設為 ``None``。``'store_const'`` action 最常與指定某種旗標的可選引數一" "起使用。例如: ::" -#: ../../library/argparse.rst:771 +#: ../../library/argparse.rst:775 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_const', const=42)\n" @@ -1523,7 +1534,7 @@ msgstr "" ">>> parser.parse_args(['--foo'])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:776 +#: ../../library/argparse.rst:780 msgid "" "``'store_true'`` and ``'store_false'`` - These are special cases of " "``'store_const'`` that respectively store the values ``True`` and ``False`` " @@ -1532,7 +1543,7 @@ msgstr "" "``'store_true'`` 和 ``'store_false'`` - 這些是 ``'store_const'`` 的特殊情況," "分別儲存值 ``True`` 和 ``False``,預設值為 ``False`` 和 ``True``: ::" -#: ../../library/argparse.rst:781 +#: ../../library/argparse.rst:785 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -1548,7 +1559,7 @@ msgstr "" ">>> parser.parse_args('--foo --bar'.split())\n" "Namespace(foo=True, bar=False, baz=True)" -#: ../../library/argparse.rst:788 +#: ../../library/argparse.rst:792 msgid "" "``'append'`` - This appends each argument value to a list. It is useful for " "allowing an option to be specified multiple times. If the default value is a " @@ -1560,7 +1571,7 @@ msgstr "" "很有用。如果預設值是一個非空的串列,剖析後的值會以預設串列的元素開始,命令列" "的任何值則會附加在那些預設值之後。使用範例: ::" -#: ../../library/argparse.rst:794 +#: ../../library/argparse.rst:798 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='append', default=['0'])\n" @@ -1572,7 +1583,7 @@ msgstr "" ">>> parser.parse_args('--foo 1 --foo 2'.split())\n" "Namespace(foo=['0', '1', '2'])" -#: ../../library/argparse.rst:799 +#: ../../library/argparse.rst:803 msgid "" "``'append_const'`` - This appends the value specified by the const_ keyword " "argument to a list; note that the const_ keyword argument defaults to " @@ -1583,7 +1594,7 @@ msgstr "" "意 const_ 關鍵字引數預設為 ``None``。``'append_const'`` action 通常在多個引數" "需要將常數儲存到同一個串列時很有用。例如: ::" -#: ../../library/argparse.rst:805 +#: ../../library/argparse.rst:809 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--str', dest='types', action='append_const', " @@ -1601,7 +1612,7 @@ msgstr "" ">>> parser.parse_args('--str --int'.split())\n" "Namespace(types=[, ])" -#: ../../library/argparse.rst:811 +#: ../../library/argparse.rst:815 msgid "" "``'extend'`` - This appends each item from a multi-value argument to a list. " "The ``'extend'`` action is typically used with the nargs_ keyword argument " @@ -1614,7 +1625,7 @@ msgstr "" "``None``\\ (預設值)或 ``'?'`` 時,引數字串的每個字元都會被附加到串列中。使" "用範例: ::" -#: ../../library/argparse.rst:819 +#: ../../library/argparse.rst:823 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " @@ -1630,14 +1641,14 @@ msgstr "" "\"f4\"])\n" "Namespace(foo=['f1', 'f2', 'f3', 'f4'])" -#: ../../library/argparse.rst:826 +#: ../../library/argparse.rst:830 msgid "" "``'count'`` - This counts the number of times an argument occurs. For " "example, this is useful for increasing verbosity levels::" msgstr "" "``'count'`` - 這會計算引數出現的次數。例如,這對於增加詳細程度等級很有用: ::" -#: ../../library/argparse.rst:829 +#: ../../library/argparse.rst:833 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" @@ -1649,14 +1660,14 @@ msgstr "" ">>> parser.parse_args(['-vvv'])\n" "Namespace(verbose=3)" -#: ../../library/argparse.rst:834 +#: ../../library/argparse.rst:838 msgid "" "Unless explicitly set, the *default* will be ``None``. If the default value " "is a non-zero number, the count starts from that number rather than from " "zero." msgstr "" -#: ../../library/argparse.rst:838 +#: ../../library/argparse.rst:842 msgid "" "``'help'`` - This prints a complete help message for all the options in the " "current parser and then exits. By default a help action is automatically " @@ -1667,7 +1678,7 @@ msgstr "" "下,help action 會自動加入到剖析器。有關輸出如何建立的詳情,請參閱 :class:" "`ArgumentParser`。" -#: ../../library/argparse.rst:843 +#: ../../library/argparse.rst:847 msgid "" "``'version'`` - This expects a ``version=`` keyword argument in the :meth:" "`~ArgumentParser.add_argument` call, and prints version information and " @@ -1676,7 +1687,7 @@ msgstr "" "``'version'`` - 這預期在 :meth:`~ArgumentParser.add_argument` 呼叫中有一個 " "``version=`` 關鍵字引數,並在被呼叫時印出版本資訊並退出: ::" -#: ../../library/argparse.rst:847 +#: ../../library/argparse.rst:851 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -1692,7 +1703,7 @@ msgstr "" ">>> parser.parse_args(['--version'])\n" "PROG 2.0" -#: ../../library/argparse.rst:853 +#: ../../library/argparse.rst:857 msgid "" "You may also specify an arbitrary action by passing an :class:`Action` " "subclass (e.g. :class:`BooleanOptionalAction`) or other object that " @@ -1705,7 +1716,7 @@ msgstr "" "action(例如 ``'store'``、``'append'``、``'extend'`` 或 ``nargs`` 不為零的自" "訂 action)可用於位置引數。" -#: ../../library/argparse.rst:859 +#: ../../library/argparse.rst:863 msgid "" "The recommended way to create a custom action is to extend :class:`Action`, " "overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` " @@ -1718,11 +1729,11 @@ msgstr "" "使用 :meth:`~ArgumentParser.register` 方法註冊自訂 action,並透過它們的註冊名" "稱來參照。" -#: ../../library/argparse.rst:864 +#: ../../library/argparse.rst:868 msgid "An example of a custom action::" msgstr "自訂 action 的範例: ::" -#: ../../library/argparse.rst:866 +#: ../../library/argparse.rst:870 msgid "" ">>> class FooAction(argparse.Action):\n" "... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" @@ -1760,15 +1771,15 @@ msgstr "" ">>> args\n" "Namespace(bar='1', foo='2')" -#: ../../library/argparse.rst:884 +#: ../../library/argparse.rst:888 msgid "For more details, see :class:`Action`." msgstr "更多詳情請見 :class:`Action`。" -#: ../../library/argparse.rst:890 +#: ../../library/argparse.rst:894 msgid "nargs" msgstr "nargs" -#: ../../library/argparse.rst:892 +#: ../../library/argparse.rst:896 msgid "" ":class:`ArgumentParser` objects usually associate a single command-line " "argument with a single action to be taken. The ``nargs`` keyword argument " @@ -1780,14 +1791,14 @@ msgstr "" "來。``nargs`` 關鍵字引數會將不同數量的命令列引數與單個 action 關聯。另請參閱" "\\ :ref:`specifying-ambiguous-arguments`。支援的值有:" -#: ../../library/argparse.rst:897 +#: ../../library/argparse.rst:901 msgid "" "``N`` (an integer). ``N`` arguments from the command line will be gathered " "together into a list. For example::" msgstr "" "``N``\\ (一個整數)。命令列中的 ``N`` 個引數會被收集到一個串列中。例如: ::" -#: ../../library/argparse.rst:900 +#: ../../library/argparse.rst:904 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs=2)\n" @@ -1801,7 +1812,7 @@ msgstr "" ">>> parser.parse_args('c --foo a b'.split())\n" "Namespace(bar=['c'], foo=['a', 'b'])" -#: ../../library/argparse.rst:906 +#: ../../library/argparse.rst:910 msgid "" "Note that ``nargs=1`` produces a list of one item. This is different from " "the default, in which the item is produced by itself." @@ -1809,7 +1820,7 @@ msgstr "" "請注意 ``nargs=1`` 會產生一個只有一個項目的串列。這與預設情況不同,預設情況下" "項目會單獨產生。" -#: ../../library/argparse.rst:911 +#: ../../library/argparse.rst:915 msgid "" "``'?'``. One argument will be consumed from the command line if possible, " "and produced as a single item. If no command-line argument is present, the " @@ -1823,7 +1834,7 @@ msgstr "" "選項字串存在但後面沒有跟著命令列引數,在這種情況下會產生 const_ 的值。以下是" "這個情況的範例: ::" -#: ../../library/argparse.rst:918 +#: ../../library/argparse.rst:922 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" @@ -1845,13 +1856,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(bar='d', foo='d')" -#: ../../library/argparse.rst:928 +#: ../../library/argparse.rst:932 msgid "" "One of the more common uses of ``nargs='?'`` is to allow optional input and " "output files::" msgstr "``nargs='?'`` 比較常見的用途之一是允許可選的輸入和輸出檔案: ::" -#: ../../library/argparse.rst:931 +#: ../../library/argparse.rst:935 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', nargs='?')\n" @@ -1873,7 +1884,7 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(infile=None, outfile=None)" -#: ../../library/argparse.rst:943 +#: ../../library/argparse.rst:947 msgid "" "``'*'``. All command-line arguments present are gathered into a list. Note " "that it generally doesn't make much sense to have more than one positional " @@ -1884,7 +1895,7 @@ msgstr "" "``nargs='*'`` 的位置引數通常沒有太大意義,但多個 ``nargs='*'`` 的可選引數是可" "能的。例如: ::" -#: ../../library/argparse.rst:948 +#: ../../library/argparse.rst:952 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='*')\n" @@ -1900,7 +1911,7 @@ msgstr "" ">>> parser.parse_args('a b --foo x y --bar 1 2'.split())\n" "Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])" -#: ../../library/argparse.rst:957 +#: ../../library/argparse.rst:961 msgid "" "``'+'``. Just like ``'*'``, all command-line arguments present are gathered " "into a list. Additionally, an error message will be generated if there " @@ -1909,7 +1920,7 @@ msgstr "" "``'+'``。與 ``'*'`` 一樣,所有存在的命令列引數都會被收集到一個串列中。此外," "如果沒有至少一個命令列引數存在就會產生一個錯誤訊息。例如: ::" -#: ../../library/argparse.rst:961 +#: ../../library/argparse.rst:965 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('foo', nargs='+')\n" @@ -1927,7 +1938,7 @@ msgstr "" "usage: PROG [-h] foo [foo ...]\n" "PROG: error: the following arguments are required: foo" -#: ../../library/argparse.rst:969 +#: ../../library/argparse.rst:973 msgid "" "If the ``nargs`` keyword argument is not provided, the number of arguments " "consumed is determined by the action_. Generally this means a single " @@ -1939,11 +1950,11 @@ msgstr "" "意味著會消耗單個命令列引數並產生單個項目(而非串列)。不消耗命令列引數的 " "action(例如 ``'store_const'``)會設定 ``nargs=0``。" -#: ../../library/argparse.rst:979 +#: ../../library/argparse.rst:983 msgid "const" msgstr "const" -#: ../../library/argparse.rst:981 +#: ../../library/argparse.rst:985 msgid "" "The ``const`` argument of :meth:`~ArgumentParser.add_argument` is used to " "hold constant values that are not read from the command line but are " @@ -1953,7 +1964,7 @@ msgstr "" ":meth:`~ArgumentParser.add_argument` 的 ``const`` 引數用於保存不從命令列讀取" "但為各種 :class:`ArgumentParser` action 所需的常數值。它最常見的兩種用途是:" -#: ../../library/argparse.rst:985 +#: ../../library/argparse.rst:989 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with " "``action='store_const'`` or ``action='append_const'``. These actions add " @@ -1968,7 +1979,7 @@ msgstr "" "述。如果未向 :meth:`~ArgumentParser.add_argument` 提供 ``const``,它會接收預" "設值 ``None``。" -#: ../../library/argparse.rst:993 +#: ../../library/argparse.rst:997 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with option strings " "(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional " @@ -1982,7 +1993,7 @@ msgstr "" "數。剖析命令列時,如果遇到選項字串但後面沒有命令列引數,會使用 ``const`` 的" "值。範例請參閱 nargs_ 描述。" -#: ../../library/argparse.rst:1000 +#: ../../library/argparse.rst:1004 msgid "" "``const=None`` by default, including when ``action='append_const'`` or " "``action='store_const'``." @@ -1990,11 +2001,11 @@ msgstr "" "``const=None`` 為預設值,包括當 ``action='append_const'`` 或 " "``action='store_const'`` 時。" -#: ../../library/argparse.rst:1007 +#: ../../library/argparse.rst:1011 msgid "default" msgstr "default" -#: ../../library/argparse.rst:1009 +#: ../../library/argparse.rst:1013 msgid "" "All optional arguments and some positional arguments may be omitted at the " "command line. The ``default`` keyword argument of :meth:`~ArgumentParser." @@ -2008,7 +2019,7 @@ msgstr "" "數不存在時應使用的值。對於可選引數,當選項字串不在命令列上時會使用 " "``default`` 值: ::" -#: ../../library/argparse.rst:1016 +#: ../../library/argparse.rst:1020 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -2024,14 +2035,14 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:1023 +#: ../../library/argparse.rst:1027 msgid "" "If the target namespace already has an attribute set, the action *default* " "will not overwrite it::" msgstr "" "如果目標命名空間已經設定了一個屬性,action 的 *default* 不會覆寫它: ::" -#: ../../library/argparse.rst:1026 +#: ../../library/argparse.rst:1030 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -2043,7 +2054,7 @@ msgstr "" ">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" "Namespace(foo=101)" -#: ../../library/argparse.rst:1031 +#: ../../library/argparse.rst:1035 msgid "" "If the ``default`` value is a string, the parser parses the value as if it " "were a command-line argument. In particular, the parser applies any type_ " @@ -2054,7 +2065,7 @@ msgstr "" "果有提供 type_ 轉換引數,剖析器會在設定 :class:`Namespace` 回傳值的屬性之前先" "套用它。否則剖析器會直接使用該值: ::" -#: ../../library/argparse.rst:1036 +#: ../../library/argparse.rst:1040 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--length', default='10', type=int)\n" @@ -2068,7 +2079,7 @@ msgstr "" ">>> parser.parse_args()\n" "Namespace(length=10, width=10.5)" -#: ../../library/argparse.rst:1042 +#: ../../library/argparse.rst:1046 msgid "" "For positional arguments with nargs_ equal to ``?`` or ``*``, the " "``default`` value is used when no command-line argument was present::" @@ -2076,7 +2087,7 @@ msgstr "" "對於 nargs_ 等於 ``?`` 或 ``*`` 的位置引數,當沒有命令列引數存在時會使用 " "``default`` 值: ::" -#: ../../library/argparse.rst:1045 +#: ../../library/argparse.rst:1049 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', nargs='?', default=42)\n" @@ -2092,14 +2103,14 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:1052 +#: ../../library/argparse.rst:1056 msgid "" "Because ``nargs='*'`` gathers any supplied values into a list, an absent " "positional argument yields an empty list (``[]``). Only a non-``None`` " "*default* overrides this (so ``default=None`` still gives ``[]``)." msgstr "" -#: ../../library/argparse.rst:1056 +#: ../../library/argparse.rst:1060 msgid "" "For required_ arguments, the ``default`` value is ignored. For example, this " "applies to positional arguments with nargs_ values other than ``?`` or " @@ -2108,7 +2119,7 @@ msgstr "" "對於 required_ 引數,``default`` 值會被忽略。例如,這適用於 nargs_ 值不是 ``?" "`` 或 ``*`` 的位置引數,或是標記為 ``required=True`` 的可選引數。" -#: ../../library/argparse.rst:1060 +#: ../../library/argparse.rst:1064 msgid "" "Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if " "the command-line argument was not present::" @@ -2116,7 +2127,7 @@ msgstr "" "若有提供 ``default=argparse.SUPPRESS``,命令列引數不存在時就不會加入任何屬" "性: ::" -#: ../../library/argparse.rst:1063 +#: ../../library/argparse.rst:1067 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" @@ -2132,11 +2143,11 @@ msgstr "" ">>> parser.parse_args(['--foo', '1'])\n" "Namespace(foo='1')" -#: ../../library/argparse.rst:1074 +#: ../../library/argparse.rst:1078 msgid "type" msgstr "type" -#: ../../library/argparse.rst:1076 +#: ../../library/argparse.rst:1080 msgid "" "By default, the parser reads command-line arguments in as simple strings. " "However, quite often the command-line string should instead be interpreted " @@ -2148,7 +2159,7 @@ msgstr "" "一種型別,例如 :class:`float` 或 :class:`int`。:meth:`~ArgumentParser." "add_argument` 的 ``type`` 關鍵字允許執行任何必要的型別檢查和型別轉換。" -#: ../../library/argparse.rst:1082 +#: ../../library/argparse.rst:1086 msgid "" "If the type_ keyword is used with the default_ keyword, the type converter " "is only applied if the default is a string." @@ -2156,7 +2167,7 @@ msgstr "" "如果 type_ 關鍵字與 default_ 關鍵字一起使用,型別轉換器只會在預設值為字串時套" "用。" -#: ../../library/argparse.rst:1085 +#: ../../library/argparse.rst:1089 msgid "" "The argument to ``type`` can be a callable that accepts a single string or " "the name of a registered type (see :meth:`~ArgumentParser.register`) If the " @@ -2169,11 +2180,11 @@ msgstr "" "`ArgumentTypeError`、:exc:`TypeError` 或 :exc:`ValueError`,剖析器會捕捉例外" "並顯示格式良好的錯誤訊息。其他例外型別則不處理。" -#: ../../library/argparse.rst:1091 +#: ../../library/argparse.rst:1095 msgid "Common built-in types and functions can be used as type converters:" msgstr "常見的內建型別和函式可以作為型別轉換器使用:" -#: ../../library/argparse.rst:1093 +#: ../../library/argparse.rst:1097 msgid "" "import argparse\n" "import pathlib\n" @@ -2195,11 +2206,11 @@ msgstr "" "parser.add_argument('code_point', type=ord)\n" "parser.add_argument('datapath', type=pathlib.Path)" -#: ../../library/argparse.rst:1105 +#: ../../library/argparse.rst:1109 msgid "User defined functions can be used as well:" msgstr "也可以用那些使用者定義的函式:" -#: ../../library/argparse.rst:1107 +#: ../../library/argparse.rst:1111 msgid "" ">>> def hyphenated(string):\n" "... return '-'.join([word[:4] for word in string.casefold().split()])\n" @@ -2217,7 +2228,7 @@ msgstr "" ">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" "Namespace(short_title='\"the-tale-of-two-citi')" -#: ../../library/argparse.rst:1117 +#: ../../library/argparse.rst:1121 msgid "" "The :func:`bool` function is not recommended as a type converter. All it " "does is convert empty strings to ``False`` and non-empty strings to " @@ -2226,7 +2237,7 @@ msgstr "" "不建議使用 :func:`bool` 函式作為型別轉換器。它所做的只是將空字串轉為 " "``False``,將非空字串轉為 ``True``。這通常不是期望的行為::" -#: ../../library/argparse.rst:1121 +#: ../../library/argparse.rst:1125 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> _ = parser.add_argument('--verbose', type=bool)\n" @@ -2238,13 +2249,13 @@ msgstr "" ">>> parser.parse_args(['--verbose', 'False'])\n" "Namespace(verbose=True)" -#: ../../library/argparse.rst:1126 +#: ../../library/argparse.rst:1130 msgid "" "See :class:`BooleanOptionalAction` or ``action='store_true'`` for common " "alternatives." msgstr "" -#: ../../library/argparse.rst:1129 +#: ../../library/argparse.rst:1133 msgid "" "In general, the ``type`` keyword is a convenience that should only be used " "for simple conversions that can only raise one of the three supported " @@ -2254,7 +2265,7 @@ msgstr "" "一般而言,``type`` 關鍵字是一個便利功能,應只用於只會引發三種支援的例外之一的" "簡單轉換。任何更複雜的錯誤處理或資源管理都應在引數剖析之後的下游進行。" -#: ../../library/argparse.rst:1134 +#: ../../library/argparse.rst:1138 msgid "" "For example, JSON or YAML conversions have complex error cases that require " "better reporting than can be given by the ``type`` keyword. A :exc:`~json." @@ -2265,7 +2276,7 @@ msgstr "" "好的報告。:exc:`~json.JSONDecodeError` 無法得到良好的格式化,而 :exc:" "`FileNotFoundError` 例外則完全不會處理。" -#: ../../library/argparse.rst:1139 +#: ../../library/argparse.rst:1143 msgid "" "Even :class:`~argparse.FileType` has its limitations for use with the " "``type`` keyword. If one argument uses :class:`~argparse.FileType` and then " @@ -2279,17 +2290,17 @@ msgstr "" "報告錯誤但檔案不會自動關閉。在這種情況下,最好等到剖析器執行完畢後,再使用 :" "keyword:`with` 陳述式來管理檔案。" -#: ../../library/argparse.rst:1146 +#: ../../library/argparse.rst:1150 msgid "" "For type checkers that simply check against a fixed set of values, consider " "using the choices_ keyword instead." msgstr "對於僅檢查固定值集合的型別檢查器,請考慮改用 choices_ 關鍵字。" -#: ../../library/argparse.rst:1153 +#: ../../library/argparse.rst:1157 msgid "choices" msgstr "choices" -#: ../../library/argparse.rst:1155 +#: ../../library/argparse.rst:1159 msgid "" "Some command-line arguments should be selected from a restricted set of " "values. These can be handled by passing a sequence object as the *choices* " @@ -2301,7 +2312,7 @@ msgstr "" "字引數傳給 :meth:`~ArgumentParser.add_argument` 來處理。剖析命令列時會檢查引" "數值,如果引數不是可接受的值之一,就會顯示錯誤訊息: ::" -#: ../../library/argparse.rst:1161 +#: ../../library/argparse.rst:1165 msgid "" ">>> parser = argparse.ArgumentParser(prog='game.py')\n" ">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" @@ -2321,7 +2332,7 @@ msgstr "" "game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" "'paper', 'scissors')" -#: ../../library/argparse.rst:1170 +#: ../../library/argparse.rst:1174 msgid "" "Any sequence can be passed as the *choices* value, so :class:`list` " "objects, :class:`tuple` objects, and custom sequences are all supported." @@ -2329,14 +2340,14 @@ msgstr "" "任何序列都可以作為 *choices* 值傳入,因此 :class:`list` 物件、:class:`tuple` " "物件和自訂序列都有被支援。" -#: ../../library/argparse.rst:1173 +#: ../../library/argparse.rst:1177 msgid "" "Use of :class:`enum.Enum` is not recommended because it is difficult to " "control its appearance in usage, help, and error messages." msgstr "" "不建議使用 :class:`enum.Enum`,因為很難控制它在用法、說明和錯誤訊息中的長相。" -#: ../../library/argparse.rst:1176 +#: ../../library/argparse.rst:1180 msgid "" "Note that *choices* are checked after any type_ conversions have been " "performed, so objects in *choices* should match the type_ specified. This " @@ -2346,7 +2357,7 @@ msgstr "" "物件應符合指定的 type_。這可能使 *choices* 在用法、說明或錯誤訊息中的長相看起" "來不尋常。" -#: ../../library/argparse.rst:1181 +#: ../../library/argparse.rst:1185 msgid "" "To keep *choices* user-friendly, consider a custom type wrapper that " "converts and formats values, or omit type_ and handle conversion in your " @@ -2355,7 +2366,7 @@ msgstr "" "若要保持 *choices* 對使用者友善,請考慮使用自訂型別包裝器來轉換和格式化值,或" "是省略 type_ 並在你的應用程式碼中處理轉換。" -#: ../../library/argparse.rst:1185 +#: ../../library/argparse.rst:1189 msgid "" "Formatted choices override the default *metavar* which is normally derived " "from *dest*. This is usually what you want because the user never sees the " @@ -2366,11 +2377,11 @@ msgstr "" "使用者永遠看不到 *dest* 參數。如果此顯示不理想(也許因為有很多選擇),只需指" "定一個明確的 metavar_。" -#: ../../library/argparse.rst:1194 +#: ../../library/argparse.rst:1198 msgid "required" msgstr "required" -#: ../../library/argparse.rst:1196 +#: ../../library/argparse.rst:1200 msgid "" "In general, the :mod:`!argparse` module assumes that flags like ``-f`` and " "``--bar`` indicate *optional* arguments, which can always be omitted at the " @@ -2382,7 +2393,7 @@ msgstr "" "以為 :meth:`~ArgumentParser.add_argument` 的 ``required=`` 關鍵字引數指定 " "``True``: ::" -#: ../../library/argparse.rst:1201 +#: ../../library/argparse.rst:1205 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', required=True)\n" @@ -2400,7 +2411,7 @@ msgstr "" "usage: [-h] --foo FOO\n" ": error: the following arguments are required: --foo" -#: ../../library/argparse.rst:1209 +#: ../../library/argparse.rst:1213 msgid "" "As the example shows, if an option is marked as ``required``, :meth:" "`~ArgumentParser.parse_args` will report an error if that option is not " @@ -2409,7 +2420,7 @@ msgstr "" "如範例所示,如果一個選項被標記為 ``required``,:meth:`~ArgumentParser." "parse_args` 會在該選項不在命令列上時報告錯誤。" -#: ../../library/argparse.rst:1215 +#: ../../library/argparse.rst:1219 msgid "" "Required options are generally considered bad form because users expect " "*options* to be *optional*, and thus they should be avoided when possible." @@ -2417,11 +2428,11 @@ msgstr "" "必要選項一般認為是不良做法,因為使用者期望\\ *選項*\\ 是\\ *可選的*,因此應盡" "可能避免使用。" -#: ../../library/argparse.rst:1222 +#: ../../library/argparse.rst:1226 msgid "help" msgstr "help" -#: ../../library/argparse.rst:1224 +#: ../../library/argparse.rst:1228 msgid "" "The ``help`` value is a string containing a brief description of the " "argument. When a user requests help (usually by using ``-h`` or ``--help`` " @@ -2431,7 +2442,7 @@ msgstr "" "``help`` 值是一個包含引數簡短描述的字串。當使用者請求說明(通常是在命令列上使" "用 ``-h`` 或 ``--help``)時,這些 ``help`` 描述會與每個引數一起顯示。" -#: ../../library/argparse.rst:1229 +#: ../../library/argparse.rst:1233 msgid "" "The ``help`` strings can include various format specifiers to avoid " "repetition of things like the program name or the argument default_. The " @@ -2443,7 +2454,7 @@ msgstr "" "內容。可用的說明符號包括程式名稱 ``%(prog)s`` 以及 :meth:`~ArgumentParser." "add_argument` 的大多數關鍵字引數,例如 ``%(default)s``、``%(type)s`` 等: ::" -#: ../../library/argparse.rst:1234 +#: ../../library/argparse.rst:1238 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" @@ -2469,7 +2480,7 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1246 +#: ../../library/argparse.rst:1250 msgid "" "As the help string supports %-formatting, if you want a literal ``%`` to " "appear in the help string, you must escape it as ``%%``." @@ -2477,7 +2488,7 @@ msgstr "" "由於 help 字串支援 %-格式化,如果你想讓文字 ``%`` 出現在 help 字串中,你必須" "將它跳脫為 ``%%``。" -#: ../../library/argparse.rst:1249 +#: ../../library/argparse.rst:1253 msgid "" ":mod:`!argparse` supports silencing the help entry for certain options, by " "setting the ``help`` value to ``argparse.SUPPRESS``::" @@ -2485,7 +2496,7 @@ msgstr "" ":mod:`!argparse` 支援透過將 ``help`` 值設為 ``argparse.SUPPRESS`` 來隱藏某些" "選項的說明條目: ::" -#: ../../library/argparse.rst:1252 +#: ../../library/argparse.rst:1256 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" @@ -2503,11 +2514,11 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1264 +#: ../../library/argparse.rst:1268 msgid "metavar" msgstr "metavar" -#: ../../library/argparse.rst:1266 +#: ../../library/argparse.rst:1270 msgid "" "When :class:`ArgumentParser` generates help messages, it needs some way to " "refer to each expected argument. By default, :class:`!ArgumentParser` " @@ -2524,7 +2535,7 @@ msgstr "" "值轉為大寫。因此,一個 ``dest='bar'`` 的位置引數稱為 ``bar``。一個應後接單一" "命令列引數的 ``--foo`` 可選引數稱為 ``FOO``。範例: ::" -#: ../../library/argparse.rst:1275 +#: ../../library/argparse.rst:1279 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2556,11 +2567,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO" -#: ../../library/argparse.rst:1290 +#: ../../library/argparse.rst:1294 msgid "An alternative name can be specified with ``metavar``::" msgstr "可以用 ``metavar`` 指定替代名稱: ::" -#: ../../library/argparse.rst:1292 +#: ../../library/argparse.rst:1296 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', metavar='YYY')\n" @@ -2592,7 +2603,7 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo YYY" -#: ../../library/argparse.rst:1307 +#: ../../library/argparse.rst:1311 msgid "" "Note that ``metavar`` only changes the *displayed* name - the name of the " "attribute on the :meth:`~ArgumentParser.parse_args` object is still " @@ -2601,7 +2612,7 @@ msgstr "" "請注意 ``metavar`` 只會更改\\ *顯示*\\ 的名稱——:meth:`~ArgumentParser." "parse_args` 物件上的屬性名稱仍由 dest_ 值決定。" -#: ../../library/argparse.rst:1311 +#: ../../library/argparse.rst:1315 msgid "" "Different values of ``nargs`` may cause the metavar to be used multiple " "times. Providing a tuple to ``metavar`` specifies a different display for " @@ -2610,7 +2621,7 @@ msgstr "" "不同的 ``nargs`` 值可能導致 metavar 被多次使用。提供一個元組給 ``metavar`` 可" "以為每個引數指定不同的顯示: ::" -#: ../../library/argparse.rst:1315 +#: ../../library/argparse.rst:1319 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', nargs=2)\n" @@ -2634,11 +2645,11 @@ msgstr "" " -x X X\n" " --foo bar baz" -#: ../../library/argparse.rst:1330 +#: ../../library/argparse.rst:1334 msgid "dest" msgstr "dest" -#: ../../library/argparse.rst:1332 +#: ../../library/argparse.rst:1336 msgid "" "Most :class:`ArgumentParser` actions add some value as an attribute of the " "object returned by :meth:`~ArgumentParser.parse_args`. The name of this " @@ -2652,7 +2663,7 @@ msgstr "" "add_argument` 的 ``dest`` 關鍵字引數決定。對於位置引數 action,``dest`` 通常" "作為 :meth:`~ArgumentParser.add_argument` 的第一個引數提供: ::" -#: ../../library/argparse.rst:1339 +#: ../../library/argparse.rst:1343 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('bar')\n" @@ -2664,46 +2675,52 @@ msgstr "" ">>> parser.parse_args(['XXX'])\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1344 +#: ../../library/argparse.rst:1348 msgid "" "For optional argument actions, the value of ``dest`` is normally inferred " "from the option strings. :class:`ArgumentParser` generates the value of " -"``dest`` by taking the first long option string and stripping away the " -"initial ``--`` string. If no long option strings were supplied, ``dest`` " -"will be derived from the first short option string by stripping the initial " -"``-`` character. Any internal ``-`` characters will be converted to ``_`` " -"characters to make sure the string is a valid attribute name. The examples " -"below illustrate this behavior::" -msgstr "" -"對於可選引數 action,``dest`` 的值通常從選項字串推斷。:class:" -"`ArgumentParser` 透過取第一個長選項字串並去除開頭的 ``--`` 字串來產生 " -"``dest`` 的值。如果沒有提供長選項字串,``dest`` 會從第一個短選項字串去除開頭" -"的 ``-`` 字元來衍生。任何內部的 ``-`` 字元都會轉為 ``_`` 字元,以確保該字串是" -"有效的屬性名稱。以下範例說明了此行為: ::" +"``dest`` by taking the first double-dash long option string and stripping " +"away the initial ``-`` characters. If no double-dash long option strings " +"were supplied, ``dest`` will be derived from the first single-dash long " +"option string by stripping the initial ``-`` character. If no long option " +"strings were supplied, ``dest`` will be derived from the first short option " +"string by stripping the initial ``-`` character. Any internal ``-`` " +"characters will be converted to ``_`` characters to make sure the string is " +"a valid attribute name. The examples below illustrate this behavior::" +msgstr "" +"對於可選引數 action,``dest`` 的值通常從選項字串推" +"斷。:class:`ArgumentParser` 透過取第一個雙破折號長選項字串並去除開頭的 ``-`` " +"字元來產生 ``dest`` 的值。如果沒有提供雙破折號長選項字串,``dest`` 會從第一個" +"單破折號長選項字串去除開頭的 ``-`` 字元來衍生。如果沒有提供長選項字串," +"``dest`` 會從第一個短選項字串去除開頭的 ``-`` 字元來衍生。任何內部的 ``-`` 字" +"元都會轉為 ``_`` 字元,以確保該字串是有效的屬性名稱。以下範例說明了此行" +"為: ::" -#: ../../library/argparse.rst:1353 +#: ../../library/argparse.rst:1361 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('-f', '--foo-bar', '--foo')\n" +">>> parser.add_argument('-q', '-quz')\n" ">>> parser.add_argument('-x', '-y')\n" -">>> parser.parse_args('-f 1 -x 2'.split())\n" -"Namespace(foo_bar='1', x='2')\n" -">>> parser.parse_args('--foo 1 -y 2'.split())\n" -"Namespace(foo_bar='1', x='2')" +">>> parser.parse_args('-f 1 -q 2 -x 3'.split())\n" +"Namespace(foo_bar='1', quz='2', x='3')\n" +">>> parser.parse_args('--foo 1 -quz 2 -y 3'.split())\n" +"Namespace(foo_bar='1', quz='2', x='2')" msgstr "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('-f', '--foo-bar', '--foo')\n" +">>> parser.add_argument('-q', '-quz')\n" ">>> parser.add_argument('-x', '-y')\n" -">>> parser.parse_args('-f 1 -x 2'.split())\n" -"Namespace(foo_bar='1', x='2')\n" -">>> parser.parse_args('--foo 1 -y 2'.split())\n" -"Namespace(foo_bar='1', x='2')" +">>> parser.parse_args('-f 1 -q 2 -x 3'.split())\n" +"Namespace(foo_bar='1', quz='2', x='3')\n" +">>> parser.parse_args('--foo 1 -quz 2 -y 3'.split())\n" +"Namespace(foo_bar='1', quz='2', x='2')" -#: ../../library/argparse.rst:1361 +#: ../../library/argparse.rst:1370 msgid "``dest`` allows a custom attribute name to be provided::" msgstr "``dest`` 允許提供自訂的屬性名稱: ::" -#: ../../library/argparse.rst:1363 +#: ../../library/argparse.rst:1372 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', dest='bar')\n" @@ -2715,7 +2732,7 @@ msgstr "" ">>> parser.parse_args('--foo XXX'.split())\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1368 +#: ../../library/argparse.rst:1377 msgid "" "Multiple arguments may share the same ``dest``. By default, the value from " "the last such argument given on the command line wins. Use " @@ -2724,11 +2741,15 @@ msgid "" "conflict_handler_." msgstr "" -#: ../../library/argparse.rst:1376 +#: ../../library/argparse.rst:1382 +msgid "Single-dash long option now takes precedence over short options." +msgstr "" + +#: ../../library/argparse.rst:1389 msgid "deprecated" msgstr "deprecated" -#: ../../library/argparse.rst:1378 +#: ../../library/argparse.rst:1391 msgid "" "During a project's lifetime, some arguments may need to be removed from the " "command line. Before removing them, you should inform your users that the " @@ -2744,7 +2765,7 @@ msgstr "" "除。對於引數,如果 ``deprecated`` 為 ``True``,那麼使用該引數時會向 :data:" "`sys.stderr` 印出警告: ::" -#: ../../library/argparse.rst:1388 +#: ../../library/argparse.rst:1401 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='snake.py')\n" @@ -2764,11 +2785,11 @@ msgstr "" "snake.py: warning: option '--legs' is deprecated\n" "Namespace(legs=4)" -#: ../../library/argparse.rst:1401 +#: ../../library/argparse.rst:1414 msgid "Action classes" msgstr "Action 類別" -#: ../../library/argparse.rst:1403 +#: ../../library/argparse.rst:1416 msgid "" ":class:`!Action` classes implement the Action API, a callable which returns " "a callable which processes arguments from the command-line. Any object which " @@ -2779,7 +2800,7 @@ msgstr "" "命令列引數的可呼叫物件。任何遵循此 API 的物件都可以作為 ``action`` 參數傳給 :" "meth:`~ArgumentParser.add_argument`。" -#: ../../library/argparse.rst:1412 +#: ../../library/argparse.rst:1425 msgid "" ":class:`!Action` objects are used by an :class:`ArgumentParser` to represent " "the information needed to parse a single argument from one or more strings " @@ -2792,7 +2813,7 @@ msgstr "" "給 :meth:`ArgumentParser.add_argument` 的任何關鍵字引數(除了 ``action`` 本" "身)。" -#: ../../library/argparse.rst:1418 +#: ../../library/argparse.rst:1431 msgid "" "Instances of :class:`!Action` (or return value of any callable to the " "``action`` parameter) should have attributes :attr:`!dest`, :attr:`!" @@ -2805,7 +2826,7 @@ msgstr "" "attr:`!required`、:attr:`!help` 等屬性。確保這些屬性被定義的最簡單方式是呼" "叫 :meth:`!Action.__init__`。" -#: ../../library/argparse.rst:1426 +#: ../../library/argparse.rst:1439 msgid "" ":class:`!Action` instances should be callable, so subclasses must override " "the :meth:`!__call__` method, which should accept four parameters:" @@ -2813,12 +2834,12 @@ msgstr "" ":class:`!Action` 實例應該是可呼叫的,因此子類別必須覆寫 :meth:`!__call__` 方" "法,它應接受四個參數:" -#: ../../library/argparse.rst:1429 +#: ../../library/argparse.rst:1442 msgid "" "*parser* - The :class:`ArgumentParser` object which contains this action." msgstr "*parser* - 包含此 action 的 :class:`ArgumentParser` 物件。" -#: ../../library/argparse.rst:1431 +#: ../../library/argparse.rst:1444 msgid "" "*namespace* - The :class:`Namespace` object that will be returned by :meth:" "`~ArgumentParser.parse_args`. Most actions add an attribute to this object " @@ -2827,7 +2848,7 @@ msgstr "" "*namespace* - 將由 :meth:`~ArgumentParser.parse_args` 回傳的 :class:" "`Namespace` 物件。大多數 action 使用 :func:`setattr` 將屬性加入此物件。" -#: ../../library/argparse.rst:1435 +#: ../../library/argparse.rst:1448 msgid "" "*values* - The associated command-line arguments, with any type conversions " "applied. Type conversions are specified with the type_ keyword argument to :" @@ -2836,7 +2857,7 @@ msgstr "" "*values* - 相關聯的命令列引數,已套用任何型別轉換。型別轉換透過 :meth:" "`~ArgumentParser.add_argument` 的 type_ 關鍵字引數指定。" -#: ../../library/argparse.rst:1439 +#: ../../library/argparse.rst:1452 msgid "" "*option_string* - The option string that was used to invoke this action. The " "``option_string`` argument is optional, and will be absent if the action is " @@ -2845,7 +2866,7 @@ msgstr "" "*option_string* - 用來呼叫此 action 的選項字串。``option_string`` 引數是可選" "的,如果 action 與位置引數關聯則不會出現。" -#: ../../library/argparse.rst:1443 +#: ../../library/argparse.rst:1456 msgid "" "The :meth:`!__call__` method may perform arbitrary actions, but will " "typically set attributes on the ``namespace`` based on ``dest`` and " @@ -2854,7 +2875,7 @@ msgstr "" ":meth:`!__call__` 方法可以執行任意動作,但通常會根據 ``dest`` 和 ``values`` " "在 ``namespace`` 上設定屬性。" -#: ../../library/argparse.rst:1448 +#: ../../library/argparse.rst:1461 msgid "" ":class:`!Action` subclasses can define a :meth:`!format_usage` method that " "takes no argument and return a string which will be used when printing the " @@ -2865,7 +2886,7 @@ msgstr "" "並回傳一個字串,該字串會在印出程式用法時使用。如果未提供此方法,會使用合理的" "預設值。" -#: ../../library/argparse.rst:1454 +#: ../../library/argparse.rst:1467 msgid "" "A subclass of :class:`Action` for handling boolean flags with positive and " "negative options. Adding a single argument such as ``--foo`` automatically " @@ -2876,7 +2897,7 @@ msgstr "" "foo`` 這樣的單個引數會自動建立 ``--foo`` 和 ``--no-foo`` 選項,其分別儲存 " "``True`` 和 ``False``: ::" -#: ../../library/argparse.rst:1459 +#: ../../library/argparse.rst:1472 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -2890,18 +2911,33 @@ msgstr "" ">>> parser.parse_args(['--no-foo'])\n" "Namespace(foo=False)" -#: ../../library/argparse.rst:1469 +#: ../../library/argparse.rst:1478 +msgid "" +"Single-dash long options are also supported. For example, negative option ``-" +"nofoo`` is automatically added for positive option ``-foo``. But no " +"additional options are added for short options such as ``-f``." +msgstr "" + +#: ../../library/argparse.rst:1485 +msgid "Added support for single-dash options." +msgstr "" + +#: ../../library/argparse.rst:1488 +msgid "Added support for alternate prefix_chars_." +msgstr "" + +#: ../../library/argparse.rst:1492 msgid "The parse_args() method" msgstr "parse_args() 方法" -#: ../../library/argparse.rst:1473 +#: ../../library/argparse.rst:1496 msgid "" "Convert argument strings to objects and assign them as attributes of the " "namespace. Return the populated namespace." msgstr "" "將引數字串轉換為物件並將它們指定為命名空間的屬性。回傳填充後的命名空間。" -#: ../../library/argparse.rst:1476 +#: ../../library/argparse.rst:1499 msgid "" "Previous calls to :meth:`add_argument` determine exactly what objects are " "created and how they are assigned. See the documentation for :meth:`!" @@ -2910,24 +2946,24 @@ msgstr "" "先前對 :meth:`add_argument` 的呼叫決定了確切建立什麼物件以及如何指定它們。詳" "情請參閱 :meth:`!add_argument` 的文件。" -#: ../../library/argparse.rst:1480 +#: ../../library/argparse.rst:1503 msgid "" "args_ - List of strings to parse. The default is taken from :data:`sys." "argv`." msgstr "args_ - 要剖析的字串串列。預設值取自 :data:`sys.argv`。" -#: ../../library/argparse.rst:1483 +#: ../../library/argparse.rst:1506 msgid "" "namespace_ - An object to take the attributes. The default is a new empty :" "class:`Namespace` object." msgstr "" "namespace_ - 接收屬性的物件。預設值是一個新的空 :class:`Namespace` 物件。" -#: ../../library/argparse.rst:1488 +#: ../../library/argparse.rst:1511 msgid "Option value syntax" msgstr "選項值語法" -#: ../../library/argparse.rst:1490 +#: ../../library/argparse.rst:1513 msgid "" "The :meth:`~ArgumentParser.parse_args` method supports several ways of " "specifying the value of an option (if it takes one). In the simplest case, " @@ -2936,7 +2972,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 方法支援多種方式來指定選項的值(如果它接受" "值的話)。在最簡單的情況下,選項和它的值作為兩個獨立的引數傳入: ::" -#: ../../library/argparse.rst:1494 +#: ../../library/argparse.rst:1517 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2954,7 +2990,7 @@ msgstr "" ">>> parser.parse_args(['--foo', 'FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1502 +#: ../../library/argparse.rst:1525 msgid "" "For long options (options with names longer than a single character), the " "option and value can also be passed as a single command-line argument, using " @@ -2963,7 +2999,7 @@ msgstr "" "對於長選項(名稱長度超過一個字元的選項),選項和值也可以作為單個命令列引數傳" "入,使用 ``=`` 來分隔它們: ::" -#: ../../library/argparse.rst:1506 +#: ../../library/argparse.rst:1529 msgid "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" @@ -2971,13 +3007,13 @@ msgstr "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1509 +#: ../../library/argparse.rst:1532 msgid "" "For short options (options only one character long), the option and its " "value can be concatenated::" msgstr "對於短選項(只有一個字元長的選項),選項和它的值可以串接在一起: ::" -#: ../../library/argparse.rst:1512 +#: ../../library/argparse.rst:1535 msgid "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" @@ -2985,7 +3021,7 @@ msgstr "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" -#: ../../library/argparse.rst:1515 +#: ../../library/argparse.rst:1538 msgid "" "Several short options can be joined together, using only a single ``-`` " "prefix, as long as only the last option (or none of them) requires a value::" @@ -2993,7 +3029,7 @@ msgstr "" "如果只有最後一個選項需要值(或都不需要),多個短選項就可以被合併在一起、只使" "用一個 ``-`` 前綴: ::" -#: ../../library/argparse.rst:1518 +#: ../../library/argparse.rst:1541 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', action='store_true')\n" @@ -3009,11 +3045,11 @@ msgstr "" ">>> parser.parse_args(['-xyzZ'])\n" "Namespace(x=True, y=True, z='Z')" -#: ../../library/argparse.rst:1527 +#: ../../library/argparse.rst:1550 msgid "Invalid arguments" msgstr "無效引數" -#: ../../library/argparse.rst:1529 +#: ../../library/argparse.rst:1552 msgid "" "While parsing the command line, :meth:`~ArgumentParser.parse_args` checks " "for a variety of errors, including ambiguous options, invalid types, invalid " @@ -3024,7 +3060,7 @@ msgstr "" "的選項、無效的型別、無效的選項、錯誤的位置引數數量等。當遇到此類錯誤時,它會" "退出並印出錯誤及用法訊息: ::" -#: ../../library/argparse.rst:1534 +#: ../../library/argparse.rst:1557 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', type=int)\n" @@ -3064,11 +3100,11 @@ msgstr "" "usage: PROG [-h] [--foo FOO] [bar]\n" "PROG: error: unrecognized arguments: badger" -#: ../../library/argparse.rst:1555 +#: ../../library/argparse.rst:1578 msgid "Arguments containing ``-``" msgstr "包含 ``-`` 的引數" -#: ../../library/argparse.rst:1557 +#: ../../library/argparse.rst:1580 msgid "" "The :meth:`~ArgumentParser.parse_args` method attempts to give errors " "whenever the user has clearly made a mistake, but some situations are " @@ -3085,7 +3121,7 @@ msgstr "" "位置引數只有在看起來像負數且剖析器中沒有看起來像負數的選項時,才可以用 ``-`` " "開頭: ::" -#: ../../library/argparse.rst:1565 +#: ../../library/argparse.rst:1588 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -3147,7 +3183,7 @@ msgstr "" "usage: PROG [-h] [-1 ONE] [foo]\n" "PROG: error: argument -1: expected one argument" -#: ../../library/argparse.rst:1595 +#: ../../library/argparse.rst:1618 msgid "" "If you have positional arguments that must begin with ``-`` and don't look " "like negative numbers, you can insert the pseudo-argument ``'--'`` which " @@ -3157,7 +3193,7 @@ msgstr "" "如果你有必須以 ``-`` 開頭且不像負數的位置引數,你可以插入偽引數 ``'--'``,它" "會告訴 :meth:`~ArgumentParser.parse_args` 在此之後的所有內容都是位置引數: ::" -#: ../../library/argparse.rst:1600 +#: ../../library/argparse.rst:1623 msgid "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" @@ -3165,7 +3201,7 @@ msgstr "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" -#: ../../library/argparse.rst:1603 +#: ../../library/argparse.rst:1626 msgid "" "See also :ref:`the argparse howto on ambiguous arguments ` for more details." @@ -3173,18 +3209,18 @@ msgstr "" "更多詳情請參閱 :ref:`argparse howto 中關於有歧義引數的說明 `。" -#: ../../library/argparse.rst:1606 +#: ../../library/argparse.rst:1629 msgid "" "Negative-number matching was expanded to include numbers in scientific " "notation (``-2.5e-6``), numbers containing underscores (``-1_234.5``), and " "complex numbers (``-1.2e-3j``)." msgstr "" -#: ../../library/argparse.rst:1614 +#: ../../library/argparse.rst:1637 msgid "Argument abbreviations (prefix matching)" msgstr "引數縮寫 (前綴匹配)" -#: ../../library/argparse.rst:1616 +#: ../../library/argparse.rst:1639 msgid "" "The :meth:`~ArgumentParser.parse_args` method :ref:`by default " "` allows long options to be abbreviated to a prefix, if the " @@ -3193,7 +3229,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 方法\\ :ref:`預設 `\\ 允許長" "選項被縮寫為前綴,只要縮寫是無歧義的(前綴匹配到唯一的選項): ::" -#: ../../library/argparse.rst:1620 +#: ../../library/argparse.rst:1643 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-bacon')\n" @@ -3217,7 +3253,7 @@ msgstr "" "usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" "PROG: error: ambiguous option: -ba could match -badger, -bacon" -#: ../../library/argparse.rst:1631 +#: ../../library/argparse.rst:1654 msgid "" "An error is produced for arguments that could produce more than one options. " "This feature can be disabled by setting :ref:`allow_abbrev` to ``False``." @@ -3225,11 +3261,11 @@ msgstr "" "對於可能產生多個選項的引數會產生錯誤。可以透過將 :ref:`allow_abbrev` 設為 " "``False`` 來停用此功能。" -#: ../../library/argparse.rst:1637 +#: ../../library/argparse.rst:1660 msgid "Beyond ``sys.argv``" msgstr "``sys.argv`` 之外" -#: ../../library/argparse.rst:1639 +#: ../../library/argparse.rst:1662 msgid "" "Sometimes it may be useful to have an :class:`ArgumentParser` parse " "arguments other than those of :data:`sys.argv`. This can be accomplished by " @@ -3240,7 +3276,7 @@ msgstr "" "這可以透過將字串串列傳給 :meth:`~ArgumentParser.parse_args` 來完成。這對於在" "互動式提示中測試很有用: ::" -#: ../../library/argparse.rst:1644 +#: ../../library/argparse.rst:1667 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\n" @@ -3266,11 +3302,11 @@ msgstr "" ">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" "Namespace(accumulate=, integers=[1, 2, 3, 4])" -#: ../../library/argparse.rst:1659 +#: ../../library/argparse.rst:1682 msgid "The Namespace object" msgstr "命名空間物件" -#: ../../library/argparse.rst:1663 +#: ../../library/argparse.rst:1686 msgid "" "Simple class used by default by :meth:`~ArgumentParser.parse_args` to create " "an object holding attributes and return it." @@ -3278,7 +3314,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 預設使用的簡單類別,用來建立保存屬性的物件" "並回傳它。" -#: ../../library/argparse.rst:1666 +#: ../../library/argparse.rst:1689 msgid "" "This class is deliberately simple, just an :class:`object` subclass with a " "readable string representation. If you prefer to have dict-like view of the " @@ -3287,7 +3323,7 @@ msgstr "" "這個類別刻意保持簡單,只是一個具有可讀字串表示的 :class:`object` 子類別。如果" "你偏好以類字典的方式檢視屬性,可以使用標準 Python 慣用寫法 :func:`vars`: ::" -#: ../../library/argparse.rst:1670 +#: ../../library/argparse.rst:1693 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3301,7 +3337,7 @@ msgstr "" ">>> vars(args)\n" "{'foo': 'BAR'}" -#: ../../library/argparse.rst:1676 +#: ../../library/argparse.rst:1699 msgid "" "It may also be useful to have an :class:`ArgumentParser` assign attributes " "to an already existing object, rather than a new :class:`Namespace` object. " @@ -3311,7 +3347,7 @@ msgstr "" "`Namespace` 物件也可能很有用。這可以透過指定 ``namespace=`` 關鍵字引數來達" "成: ::" -#: ../../library/argparse.rst:1680 +#: ../../library/argparse.rst:1703 msgid "" ">>> class C:\n" "... pass\n" @@ -3333,15 +3369,15 @@ msgstr "" ">>> c.foo\n" "'BAR'" -#: ../../library/argparse.rst:1692 +#: ../../library/argparse.rst:1715 msgid "Other utilities" msgstr "其他工具" -#: ../../library/argparse.rst:1695 +#: ../../library/argparse.rst:1718 msgid "Subcommands" msgstr "子命令" -#: ../../library/argparse.rst:1702 +#: ../../library/argparse.rst:1725 msgid "" "Many programs split up their functionality into a number of subcommands, for " "example, the ``svn`` program can invoke subcommands like ``svn checkout``, " @@ -3364,11 +3400,11 @@ msgstr "" "class:`!ArgumentParser` 建構函式引數,並回傳一個可以像往常一樣修改的 :class:" "`!ArgumentParser` 物件。" -#: ../../library/argparse.rst:1714 +#: ../../library/argparse.rst:1737 msgid "Description of parameters:" msgstr "參數的解釋:" -#: ../../library/argparse.rst:1716 +#: ../../library/argparse.rst:1739 msgid "" "*title* - title for the sub-parser group in help output; by default " "\"subcommands\" if description is provided, otherwise uses title for " @@ -3377,13 +3413,13 @@ msgstr "" "*title* - 說明輸出中子剖析器群組的標題;預設情況下,若有提供 description 則" "為 \"subcommands\",否則使用位置引數的標題" -#: ../../library/argparse.rst:1720 +#: ../../library/argparse.rst:1743 msgid "" "*description* - description for the sub-parser group in help output, by " "default ``None``" msgstr "*description* - 說明輸出中子剖析器群組的描述,預設為 ``None``" -#: ../../library/argparse.rst:1723 +#: ../../library/argparse.rst:1746 msgid "" "*prog* - usage information that will be displayed with subcommand help, by " "default the name of the program and any positional arguments before the " @@ -3392,7 +3428,7 @@ msgstr "" "*prog* - 將與子命令說明一起顯示的用法資訊,預設為程式名稱和子剖析器引數之前的" "任何位置引數" -#: ../../library/argparse.rst:1727 +#: ../../library/argparse.rst:1750 msgid "" "*parser_class* - class which will be used to create sub-parser instances, by " "default the class of the current parser (e.g. :class:`ArgumentParser`)" @@ -3400,29 +3436,29 @@ msgstr "" "*parser_class* - 將用來建立子剖析器實例的類別,預設為目前剖析器的類別(例如 :" "class:`ArgumentParser`)" -#: ../../library/argparse.rst:1730 +#: ../../library/argparse.rst:1753 msgid "" "action_ - the basic type of action to be taken when this argument is " "encountered at the command line" msgstr "action_ - 在命令列遇到此引數時要執行的基本 action 類型" -#: ../../library/argparse.rst:1733 +#: ../../library/argparse.rst:1756 msgid "" "dest_ - name of the attribute under which subcommand name will be stored; by " "default ``None`` and no value is stored" msgstr "dest_ - 用於儲存子命令名稱的屬性名稱;預設為 ``None`` 且不儲存任何值" -#: ../../library/argparse.rst:1736 +#: ../../library/argparse.rst:1759 msgid "" "required_ - Whether or not a subcommand must be provided, by default " "``False`` (added in 3.7)" msgstr "required_ - 是否必須提供子命令,預設為 ``False``\\ (在 3.7 中新增)" -#: ../../library/argparse.rst:1739 +#: ../../library/argparse.rst:1762 msgid "help_ - help for sub-parser group in help output, by default ``None``" msgstr "help_ - 說明輸出中子剖析器群組的說明,預設為 ``None``" -#: ../../library/argparse.rst:1741 +#: ../../library/argparse.rst:1764 msgid "" "metavar_ - string presenting available subcommands in help; by default it is " "``None`` and presents subcommands in form {cmd1, cmd2, ..}" @@ -3430,11 +3466,11 @@ msgstr "" "metavar_ - 在說明中呈現可用子命令的字串;預設為 ``None`` 並以 {cmd1, " "cmd2, ..} 的形式呈現子命令" -#: ../../library/argparse.rst:1744 +#: ../../library/argparse.rst:1767 msgid "Some example usage::" msgstr "一些使用範例: ::" -#: ../../library/argparse.rst:1746 +#: ../../library/argparse.rst:1769 msgid "" ">>> # create the top-level parser\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -3476,21 +3512,21 @@ msgstr "" ">>> parser.parse_args(['--foo', 'b', '--baz', 'Z'])\n" "Namespace(baz='Z', foo=True)" -#: ../../library/argparse.rst:1765 +#: ../../library/argparse.rst:1788 msgid "" -"Note that the object returned by :meth:`parse_args` will only contain " -"attributes for the main parser and the subparser that was selected by the " -"command line (and not any other subparsers). So in the example above, when " -"the ``a`` command is specified, only the ``foo`` and ``bar`` attributes are " -"present, and when the ``b`` command is specified, only the ``foo`` and " -"``baz`` attributes are present." +"Note that the object returned by :meth:`~ArgumentParser.parse_args` will " +"only contain attributes for the main parser and the subparser that was " +"selected by the command line (and not any other subparsers). So in the " +"example above, when the ``a`` command is specified, only the ``foo`` and " +"``bar`` attributes are present, and when the ``b`` command is specified, " +"only the ``foo`` and ``baz`` attributes are present." msgstr "" -"請注意 :meth:`parse_args` 回傳的物件只會包含主剖析器和命令列所選子剖析器的屬" -"性(而非任何其他子剖析器)。因此在上面的範例中,當指定 ``a`` 命令時,只有 " -"``foo`` 和 ``bar`` 屬性存在;當指定 ``b`` 命令時,只有 ``foo`` 和 ``baz`` 屬" -"性存在。" +"請注意 :meth:`~ArgumentParser.parse_args` 回傳的物件只會包含主剖析器和命令列" +"所選子剖析器的屬性(而非任何其他子剖析器)。因此在上面的範例中,當指定 ``a`` " +"命令時,只有 ``foo`` 和 ``bar`` 屬性存在;當指定 ``b`` 命令時,只有 ``foo`` " +"和 ``baz`` 屬性存在。" -#: ../../library/argparse.rst:1772 +#: ../../library/argparse.rst:1795 msgid "" "If a subparser defines an argument with the same ``dest`` as the parent " "parser, the two share a single namespace attribute, so the parent's value " @@ -3498,7 +3534,7 @@ msgid "" "both." msgstr "" -#: ../../library/argparse.rst:1777 +#: ../../library/argparse.rst:1800 msgid "" "Similarly, when a help message is requested from a subparser, only the help " "for that particular parser will be printed. The help message will not " @@ -3510,7 +3546,7 @@ msgstr "" "包含父剖析器或兄弟剖析器的訊息。(然而每個子剖析器命令的說明訊息可以透過如上" "所述向 :meth:`~_SubParsersAction.add_parser` 提供 ``help=`` 引數來給定。)" -#: ../../library/argparse.rst:1785 +#: ../../library/argparse.rst:1808 msgid "" ">>> parser.parse_args(['--help'])\n" "usage: PROG [-h] [--foo] {a,b} ...\n" @@ -3568,16 +3604,18 @@ msgstr "" " -h, --help show this help message and exit\n" " --baz {X,Y,Z} baz help" -#: ../../library/argparse.rst:1813 +#: ../../library/argparse.rst:1836 msgid "" -"The :meth:`add_subparsers` method also supports ``title`` and " -"``description`` keyword arguments. When either is present, the subparser's " -"commands will appear in their own group in the help output. For example::" +"The :meth:`~ArgumentParser.add_subparsers` method also supports ``title`` " +"and ``description`` keyword arguments. When either is present, the " +"subparser's commands will appear in their own group in the help output. For " +"example::" msgstr "" -":meth:`add_subparsers` 方法也支援 ``title`` 和 ``description`` 關鍵字引數。當" -"任一者存在時,子剖析器的命令會在說明輸出中以自己的群組出現。例如: ::" +":meth:`~ArgumentParser.add_subparsers` 方法也支援 ``title`` 和 " +"``description`` 關鍵字引數。當任一者存在時,子剖析器的命令會在說明輸出中以自" +"己的群組出現。例如: ::" -#: ../../library/argparse.rst:1817 +#: ../../library/argparse.rst:1840 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(title='subcommands',\n" @@ -3613,53 +3651,18 @@ msgstr "" "\n" " {foo,bar} additional help" -#: ../../library/argparse.rst:1834 -msgid "" -"Furthermore, :meth:`~_SubParsersAction.add_parser` supports an additional " -"*aliases* argument, which allows multiple strings to refer to the same " -"subparser. This example, like ``svn``, aliases ``co`` as a shorthand for " -"``checkout``::" -msgstr "" -"此外,:meth:`~_SubParsersAction.add_parser` 支援一個額外的 *aliases* 引數,它" -"允許多個字串參照同一個子剖析器。這個範例像 ``svn`` 一樣,將 ``co`` 作為 " -"``checkout`` 的簡寫別名: ::" - -#: ../../library/argparse.rst:1839 -msgid "" -">>> parser = argparse.ArgumentParser()\n" -">>> subparsers = parser.add_subparsers()\n" -">>> checkout = subparsers.add_parser('checkout', aliases=['co'])\n" -">>> checkout.add_argument('foo')\n" -">>> parser.parse_args(['co', 'bar'])\n" -"Namespace(foo='bar')" -msgstr "" -">>> parser = argparse.ArgumentParser()\n" -">>> subparsers = parser.add_subparsers()\n" -">>> checkout = subparsers.add_parser('checkout', aliases=['co'])\n" -">>> checkout.add_argument('foo')\n" -">>> parser.parse_args(['co', 'bar'])\n" -"Namespace(foo='bar')" - -#: ../../library/argparse.rst:1846 -msgid "" -":meth:`~_SubParsersAction.add_parser` supports also an additional " -"*deprecated* argument, which allows to deprecate the subparser." -msgstr "" -":meth:`~_SubParsersAction.add_parser` 也支援一個額外的 *deprecated* 引數,它" -"允許棄用子剖析器。" - -#: ../../library/argparse.rst:1860 +#: ../../library/argparse.rst:1857 msgid "" "One particularly effective way of handling subcommands is to combine the use " -"of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` so " -"that each subparser knows which Python function it should execute. For " -"example::" +"of the :meth:`~ArgumentParser.add_subparsers` method with calls to :meth:" +"`~ArgumentParser.set_defaults` so that each subparser knows which Python " +"function it should execute. For example::" msgstr "" -"處理子命令的一個特別有效的方式是將 :meth:`add_subparsers` 方法的使用與 :meth:" -"`set_defaults` 的呼叫結合,使每個子剖析器知道它應該執行哪個 Python 函式。例" -"如: ::" +"處理子命令的一個特別有效的方式是將 :meth:`~ArgumentParser.add_subparsers` 方" +"法的使用與 :meth:`~ArgumentParser.set_defaults` 的呼叫結合,使每個子剖析器知" +"道它應該執行哪個 Python 函式。例如: ::" -#: ../../library/argparse.rst:1865 +#: ../../library/argparse.rst:1862 msgid "" ">>> # subcommand functions\n" ">>> def foo(args):\n" @@ -3725,21 +3728,23 @@ msgstr "" ">>> args.func(args)\n" "((XYZYX))" -#: ../../library/argparse.rst:1897 +#: ../../library/argparse.rst:1894 msgid "" -"This way, you can let :meth:`parse_args` do the job of calling the " -"appropriate function after argument parsing is complete. Associating " -"functions with actions like this is typically the easiest way to handle the " -"different actions for each of your subparsers. However, if it is necessary " -"to check the name of the subparser that was invoked, the ``dest`` keyword " -"argument to the :meth:`add_subparsers` call will work::" +"This way, you can let :meth:`~ArgumentParser.parse_args` do the job of " +"calling the appropriate function after argument parsing is complete. " +"Associating functions with actions like this is typically the easiest way to " +"handle the different actions for each of your subparsers. However, if it is " +"necessary to check the name of the subparser that was invoked, the ``dest`` " +"keyword argument to the :meth:`~ArgumentParser.add_subparsers` call will " +"work::" msgstr "" -"這樣你可以讓 :meth:`parse_args` 在引數剖析完成後負責呼叫適當的函式。像這樣將" -"函式與 action 關聯通常是處理每個子剖析器不同動作的最簡單方式。然而如果有必要" -"檢查被呼叫的子剖析器名稱,:meth:`add_subparsers` 呼叫的 ``dest`` 關鍵字引數可" -"以達成此目的: ::" +"這樣你可以讓 :meth:`~ArgumentParser.parse_args` 在引數剖析完成後負責呼叫適當" +"的函式。像這樣將函式與 action 關聯通常是處理每個子剖析器不同動作的最簡單方" +"式。然而如果有必要檢查被呼叫的子剖析器名" +"稱,:meth:`~ArgumentParser.add_subparsers` 呼叫的 ``dest`` 關鍵字引數可以達成" +"此目的: ::" -#: ../../library/argparse.rst:1904 +#: ../../library/argparse.rst:1901 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" @@ -3759,21 +3764,89 @@ msgstr "" ">>> parser.parse_args(['2', 'frobble'])\n" "Namespace(subparser_name='2', y='frobble')" -#: ../../library/argparse.rst:1913 +#: ../../library/argparse.rst:1910 msgid "New *required* keyword-only parameter." msgstr "新增 *required* 僅限關鍵字參數。" -#: ../../library/argparse.rst:1916 +#: ../../library/argparse.rst:1913 msgid "" "Subparser's *prog* is no longer affected by a custom usage message in the " "main parser." msgstr "子剖析器的 *prog* 不再受主剖析器中自訂用法訊息的影響。" -#: ../../library/argparse.rst:1922 +#: ../../library/argparse.rst:1921 +msgid "" +"Create and return a new :class:`ArgumentParser` object for the subcommand " +"*name*." +msgstr "為子命令 *name* 建立並回傳一個新的 :class:`ArgumentParser` 物件。" + +#: ../../library/argparse.rst:1924 +msgid "The *name* argument is the name of the sub-command." +msgstr "" + +#: ../../library/argparse.rst:1926 +msgid "The *help* argument provides a short description for this sub-command." +msgstr "" + +#: ../../library/argparse.rst:1928 +msgid "" +"The *aliases* argument allows providing alternative names for this sub-" +"command. For example::" +msgstr "" + +#: ../../library/argparse.rst:1931 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers()\n" +">>> checkout = subparsers.add_parser('checkout', aliases=['co'])\n" +">>> checkout.add_argument('foo')\n" +">>> parser.parse_args(['co', 'bar'])\n" +"Namespace(foo='bar')" +msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers()\n" +">>> checkout = subparsers.add_parser('checkout', aliases=['co'])\n" +">>> checkout.add_argument('foo')\n" +">>> parser.parse_args(['co', 'bar'])\n" +"Namespace(foo='bar')" + +#: ../../library/argparse.rst:1938 +msgid "" +"The *deprecated* argument, if ``True``, marks the sub-command as deprecated " +"and will issue a warning when used. For example::" +msgstr "" + +#: ../../library/argparse.rst:1941 +msgid "" +">>> parser = argparse.ArgumentParser(prog='chicken.py')\n" +">>> subparsers = parser.add_subparsers()\n" +">>> fly = subparsers.add_parser('fly', deprecated=True)\n" +">>> args = parser.parse_args(['fly'])\n" +"chicken.py: warning: command 'fly' is deprecated\n" +"Namespace()" +msgstr "" +">>> parser = argparse.ArgumentParser(prog='chicken.py')\n" +">>> subparsers = parser.add_subparsers()\n" +">>> fly = subparsers.add_parser('fly', deprecated=True)\n" +">>> args = parser.parse_args(['fly'])\n" +"chicken.py: warning: command 'fly' is deprecated\n" +"Namespace()" + +#: ../../library/argparse.rst:1948 +msgid "" +"All other keyword arguments are passed directly to the :class:`!" +"ArgumentParser` constructor." +msgstr "" + +#: ../../library/argparse.rst:1951 +msgid "Added the *deprecated* parameter." +msgstr "新增了 *deprecated* 參數。" + +#: ../../library/argparse.rst:1956 msgid "FileType objects" msgstr "FileType 物件" -#: ../../library/argparse.rst:1926 +#: ../../library/argparse.rst:1960 msgid "" "The :class:`FileType` factory creates objects that can be passed to the type " "argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:" @@ -3786,7 +3859,7 @@ msgstr "" "衝區大小、編碼和錯誤處理開啟命令列引數作為檔案(更多詳情請參閱 :func:`open` " "函式): ::" -#: ../../library/argparse.rst:1932 +#: ../../library/argparse.rst:1966 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" @@ -3804,7 +3877,7 @@ msgstr "" "Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, " "raw=<_io.FileIO name='raw.dat' mode='wb'>)" -#: ../../library/argparse.rst:1938 +#: ../../library/argparse.rst:1972 msgid "" "FileType objects understand the pseudo-argument ``'-'`` and automatically " "convert this into :data:`sys.stdin` for readable :class:`FileType` objects " @@ -3814,7 +3887,7 @@ msgstr "" "件的 :data:`sys.stdin` 和可寫 :class:`FileType` 物件的 :data:`sys." "stdout`: ::" -#: ../../library/argparse.rst:1942 +#: ../../library/argparse.rst:1976 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" @@ -3826,7 +3899,7 @@ msgstr "" ">>> parser.parse_args(['-'])\n" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1949 +#: ../../library/argparse.rst:1983 msgid "" "If one argument uses *FileType* and then a subsequent argument fails, an " "error is reported but the file is not automatically closed. This can also " @@ -3838,15 +3911,15 @@ msgstr "" "自動關閉。這也可能覆蓋輸出檔案。在這種情況下,最好等到剖析器執行完畢後,再使" "用 :keyword:`with` 陳述式來管理檔案。" -#: ../../library/argparse.rst:1955 +#: ../../library/argparse.rst:1989 msgid "Added the *encoding* and *errors* parameters." msgstr "新增了 *encoding* 和 *errors* 參數。" -#: ../../library/argparse.rst:1962 +#: ../../library/argparse.rst:1996 msgid "Argument groups" msgstr "引數群組" -#: ../../library/argparse.rst:1967 +#: ../../library/argparse.rst:2001 msgid "" "By default, :class:`ArgumentParser` groups command-line arguments into " "\"positional arguments\" and \"options\" when displaying help messages. When " @@ -3858,7 +3931,7 @@ msgstr "" "引數」和「選項」兩組。當引數有比此預設分組更好的概念性分組時,可以使用 :meth:" "`!add_argument_group` 方法建立適當的群組: ::" -#: ../../library/argparse.rst:1973 +#: ../../library/argparse.rst:2007 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group = parser.add_argument_group('group')\n" @@ -3882,7 +3955,7 @@ msgstr "" " bar bar help\n" " --foo FOO foo help" -#: ../../library/argparse.rst:1984 +#: ../../library/argparse.rst:2018 msgid "" "The :meth:`add_argument_group` method returns an argument group object which " "has an :meth:`~ArgumentParser.add_argument` method just like a regular :" @@ -3898,7 +3971,7 @@ msgstr "" "引數。:meth:`!add_argument_group` 方法接受 *title* 和 *description* 引數,可" "以用來自訂此顯示: ::" -#: ../../library/argparse.rst:1992 +#: ../../library/argparse.rst:2026 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" @@ -3936,7 +4009,7 @@ msgstr "" "\n" " --bar BAR bar help" -#: ../../library/argparse.rst:2010 +#: ../../library/argparse.rst:2044 msgid "" "The optional, keyword-only parameters argument_default_ and " "conflict_handler_ allow for finer-grained control of the behavior of the " @@ -3948,7 +4021,7 @@ msgstr "" "的行為進行更精細的控制。這些參數的意義與 :class:`ArgumentParser` 建構函式中的" "相同,但專門適用於引數群組而非整個剖析器。" -#: ../../library/argparse.rst:2015 +#: ../../library/argparse.rst:2049 msgid "" "Note that any arguments not in your user-defined groups will end up back in " "the usual \"positional arguments\" and \"optional arguments\" sections." @@ -3956,13 +4029,13 @@ msgstr "" "請注意,任何不在使用者定義群組中的引數會歸入一般的「位置引數」和「可選引數」" "區段。" -#: ../../library/argparse.rst:2018 +#: ../../library/argparse.rst:2052 msgid "" "Within each argument group, arguments are displayed in help output in the " "order in which they are added." msgstr "" -#: ../../library/argparse.rst:2021 +#: ../../library/argparse.rst:2055 msgid "" "Calling :meth:`add_argument_group` on an argument group now raises an " "exception. This nesting was never supported, often failed to work correctly, " @@ -3971,15 +4044,15 @@ msgstr "" "在引數群組上呼叫 :meth:`add_argument_group` 現在會引發例外。這種巢狀用法從未" "被支援,通常無法正確運作,是因為繼承而無意間被公開出來的。" -#: ../../library/argparse.rst:2026 +#: ../../library/argparse.rst:2060 msgid "Passing prefix_chars_ to :meth:`add_argument_group` is now deprecated." msgstr "將 prefix_chars_ 傳給 :meth:`add_argument_group` 的用法現在已棄用。" -#: ../../library/argparse.rst:2032 +#: ../../library/argparse.rst:2066 msgid "Mutual exclusion" msgstr "互斥" -#: ../../library/argparse.rst:2036 +#: ../../library/argparse.rst:2070 msgid "" "Create a mutually exclusive group. :mod:`!argparse` will make sure that only " "one of the arguments in the mutually exclusive group was present on the " @@ -3988,7 +4061,7 @@ msgstr "" "建立一個互斥群組。:mod:`!argparse` 會確保互斥群組中只有一個引數出現在命令列" "上: ::" -#: ../../library/argparse.rst:2040 +#: ../../library/argparse.rst:2074 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group()\n" @@ -4014,7 +4087,7 @@ msgstr "" "usage: PROG [-h] [--foo | --bar]\n" "PROG: error: argument --bar: not allowed with argument --foo" -#: ../../library/argparse.rst:2052 +#: ../../library/argparse.rst:2086 msgid "" "The :meth:`add_mutually_exclusive_group` method also accepts a *required* " "argument, to indicate that at least one of the mutually exclusive arguments " @@ -4023,7 +4096,7 @@ msgstr "" ":meth:`add_mutually_exclusive_group` 方法也接受一個 *required* 引數,用來指示" "至少需要一個互斥引數: ::" -#: ../../library/argparse.rst:2056 +#: ../../library/argparse.rst:2090 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group(required=True)\n" @@ -4041,7 +4114,7 @@ msgstr "" "usage: PROG [-h] (--foo | --bar)\n" "PROG: error: one of the arguments --foo --bar is required" -#: ../../library/argparse.rst:2064 +#: ../../library/argparse.rst:2098 msgid "" "Note that currently mutually exclusive argument groups do not support the " "*title* and *description* arguments of :meth:`~ArgumentParser." @@ -4052,7 +4125,7 @@ msgstr "" "*title* 和 *description* 引數。然而互斥群組可以加入到具有標題和描述的引數群組" "中。例如: ::" -#: ../../library/argparse.rst:2070 +#: ../../library/argparse.rst:2104 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_argument_group('Group title', 'Group description')\n" @@ -4088,7 +4161,7 @@ msgstr "" " --foo FOO foo help\n" " --bar BAR bar help" -#: ../../library/argparse.rst:2087 +#: ../../library/argparse.rst:2121 msgid "" "Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` " "on a mutually exclusive group now raises an exception. This nesting was " @@ -4099,11 +4172,11 @@ msgstr "" "`add_mutually_exclusive_group` 現在會引發例外。這種巢狀用法從未支援,通常無法" "正確運作,且是因為繼承而無意間被公開出來的。" -#: ../../library/argparse.rst:2095 +#: ../../library/argparse.rst:2129 msgid "Parser defaults" msgstr "剖析器預設值" -#: ../../library/argparse.rst:2099 +#: ../../library/argparse.rst:2133 msgid "" "Most of the time, the attributes of the object returned by :meth:" "`parse_args` will be fully determined by inspecting the command-line " @@ -4115,7 +4188,7 @@ msgstr "" "數 action 來決定。:meth:`set_defaults` 允許加入一些無需檢查命令列即可決定的額" "外屬性: ::" -#: ../../library/argparse.rst:2105 +#: ../../library/argparse.rst:2139 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', type=int)\n" @@ -4129,7 +4202,7 @@ msgstr "" ">>> parser.parse_args(['736'])\n" "Namespace(bar=42, baz='badger', foo=736)" -#: ../../library/argparse.rst:2111 +#: ../../library/argparse.rst:2145 msgid "" "Note that defaults can be set at both the parser level using :meth:" "`set_defaults` and at the argument level using :meth:`add_argument`. If both " @@ -4140,7 +4213,7 @@ msgstr "" "級使用 :meth:`add_argument` 設定。如果兩者都為同一個引數呼叫,會使用最後設定" "的預設值: ::" -#: ../../library/argparse.rst:2115 +#: ../../library/argparse.rst:2149 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='bar')\n" @@ -4154,7 +4227,7 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo='spam')" -#: ../../library/argparse.rst:2121 +#: ../../library/argparse.rst:2155 msgid "" "Parser-level defaults can be particularly useful when working with multiple " "parsers. See the :meth:`~ArgumentParser.add_subparsers` method for an " @@ -4163,7 +4236,7 @@ msgstr "" "在使用多個剖析器時,剖析器層級的預設值可能特別有用。請參閱 :meth:" "`~ArgumentParser.add_subparsers` 方法以了解這類範例。" -#: ../../library/argparse.rst:2127 +#: ../../library/argparse.rst:2161 msgid "" "Get the default value for a namespace attribute, as set by either :meth:" "`~ArgumentParser.add_argument` or by :meth:`~ArgumentParser.set_defaults`::" @@ -4171,7 +4244,7 @@ msgstr "" "取得命名空間屬性的預設值,由 :meth:`~ArgumentParser.add_argument` 或 :meth:" "`~ArgumentParser.set_defaults` 設定: ::" -#: ../../library/argparse.rst:2131 +#: ../../library/argparse.rst:2165 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='badger')\n" @@ -4183,11 +4256,11 @@ msgstr "" ">>> parser.get_default('foo')\n" "'badger'" -#: ../../library/argparse.rst:2138 +#: ../../library/argparse.rst:2172 msgid "Printing help" msgstr "印出幫助訊息" -#: ../../library/argparse.rst:2140 +#: ../../library/argparse.rst:2174 msgid "" "In most typical applications, :meth:`~ArgumentParser.parse_args` will take " "care of formatting and printing any usage or error messages. However, " @@ -4196,7 +4269,7 @@ msgstr "" "在大多數典型的應用程式中,:meth:`~ArgumentParser.parse_args` 會處理格式化和印" "出任何用法或錯誤訊息。然而,有幾個格式化方法可以使用:" -#: ../../library/argparse.rst:2146 +#: ../../library/argparse.rst:2180 msgid "" "Print a brief description of how the :class:`ArgumentParser` should be " "invoked on the command line. If *file* is ``None``, :data:`sys.stdout` is " @@ -4205,7 +4278,7 @@ msgstr "" "印出 :class:`ArgumentParser` 在命令列上呼叫方式的簡短描述。如果 *file* 為 " "``None``,則假設為 :data:`sys.stdout`。" -#: ../../library/argparse.rst:2152 +#: ../../library/argparse.rst:2186 msgid "" "Print a help message, including the program usage and information about the " "arguments registered with the :class:`ArgumentParser`. If *file* is " @@ -4214,20 +4287,20 @@ msgstr "" "印出說明訊息,包括程式用法和在 :class:`ArgumentParser` 中註冊的引數相關資訊。" "如果 *file* 為 ``None``,假設為 :data:`sys.stdout`。" -#: ../../library/argparse.rst:2156 +#: ../../library/argparse.rst:2190 msgid "" "There are also variants of these methods that simply return a string instead " "of printing it:" msgstr "這些方法也有變體,它們只回傳字串而非印出它:" -#: ../../library/argparse.rst:2161 +#: ../../library/argparse.rst:2195 msgid "" "Return a string containing a brief description of how the :class:" "`ArgumentParser` should be invoked on the command line." msgstr "" "回傳一個字串,包含 :class:`ArgumentParser` 在命令列上的呼叫方式的簡短描述。" -#: ../../library/argparse.rst:2166 +#: ../../library/argparse.rst:2200 msgid "" "Return a string containing a help message, including the program usage and " "information about the arguments registered with the :class:`ArgumentParser`." @@ -4235,11 +4308,11 @@ msgstr "" "回傳一個字串,包含說明訊息,包括程式用法和在 :class:`ArgumentParser` 中註冊的" "引數相關資訊。" -#: ../../library/argparse.rst:2171 +#: ../../library/argparse.rst:2205 msgid "Partial parsing" msgstr "部分剖析" -#: ../../library/argparse.rst:2175 +#: ../../library/argparse.rst:2209 msgid "" "Sometimes a script only needs to handle a specific set of command-line " "arguments, leaving any unrecognized arguments for another script or program. " @@ -4250,7 +4323,7 @@ msgstr "" "本或程式。在這些情況下,:meth:`~ArgumentParser.parse_known_args` 方法可能很有" "用。" -#: ../../library/argparse.rst:2180 +#: ../../library/argparse.rst:2214 msgid "" "This method works similarly to :meth:`~ArgumentParser.parse_args`, but it " "does not raise an error for extra, unrecognized arguments. Instead, it " @@ -4261,7 +4334,7 @@ msgstr "" "辨識的引數引發錯誤,而是會只剖析已知的引數並回傳一個包含填充後的命名空間和任" "何未辨識引數串列的二元素元組。" -#: ../../library/argparse.rst:2187 +#: ../../library/argparse.rst:2221 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -4275,7 +4348,7 @@ msgstr "" ">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" "(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" -#: ../../library/argparse.rst:2194 +#: ../../library/argparse.rst:2228 msgid "" ":ref:`Prefix matching ` rules apply to :meth:" "`~ArgumentParser.parse_known_args`. The parser may consume an option even if " @@ -4286,11 +4359,11 @@ msgstr "" "parse_known_args`。即使選項只是其已知選項之一的前綴,剖析器也可能消耗它,而非" "將其留在剩餘引數串列中。" -#: ../../library/argparse.rst:2201 +#: ../../library/argparse.rst:2235 msgid "Customizing file parsing" msgstr "自訂檔案剖析" -#: ../../library/argparse.rst:2205 +#: ../../library/argparse.rst:2239 msgid "" "Arguments that are read from a file (see the *fromfile_prefix_chars* keyword " "argument to the :class:`ArgumentParser` constructor) are read one argument " @@ -4301,7 +4374,7 @@ msgstr "" "*fromfile_prefix_chars* 關鍵字引數)每行讀取一個引數。可以覆寫 :meth:" "`convert_arg_line_to_args` 以進行更精細的讀取。" -#: ../../library/argparse.rst:2210 +#: ../../library/argparse.rst:2244 msgid "" "This method takes a single argument *arg_line* which is a string read from " "the argument file. It returns a list of arguments parsed from this string. " @@ -4310,7 +4383,7 @@ msgstr "" "此方法接受單個引數 *arg_line*,它是從引數檔案讀取的字串。它回傳從此字串剖析出" "的引數串列。此方法對從引數檔案讀取的每一行依序呼叫一次。" -#: ../../library/argparse.rst:2214 +#: ../../library/argparse.rst:2248 msgid "" "A useful override of this method is one that treats each space-separated " "word as an argument. The following example demonstrates how to do this::" @@ -4318,7 +4391,7 @@ msgstr "" "此方法的一個有用覆寫是將每個以空格分隔的詞作為引數。以下範例示範了如何做到這" "一點: ::" -#: ../../library/argparse.rst:2217 +#: ../../library/argparse.rst:2251 msgid "" "class MyArgumentParser(argparse.ArgumentParser):\n" " def convert_arg_line_to_args(self, arg_line):\n" @@ -4328,17 +4401,17 @@ msgstr "" " def convert_arg_line_to_args(self, arg_line):\n" " return arg_line.split()" -#: ../../library/argparse.rst:2221 +#: ../../library/argparse.rst:2255 msgid "" "Note that with this override an argument can no longer contain spaces, since " "each space-separated word becomes a separate argument." msgstr "" -#: ../../library/argparse.rst:2226 +#: ../../library/argparse.rst:2260 msgid "Exiting methods" msgstr "退出方法" -#: ../../library/argparse.rst:2230 +#: ../../library/argparse.rst:2264 msgid "" "This method terminates the program, exiting with the specified *status* and, " "if given, it prints a *message* to :data:`sys.stderr` before that. The user " @@ -4348,7 +4421,7 @@ msgstr "" "`sys.stderr` 印出一個 *message*。使用者可以覆寫此方法來以不同方式處理這些步" "驟: ::" -#: ../../library/argparse.rst:2234 +#: ../../library/argparse.rst:2268 msgid "" "class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" " def exit(self, status=0, message=None):\n" @@ -4362,7 +4435,7 @@ msgstr "" " raise Exception(f'Exiting because of an error: {message}')\n" " exit(status)" -#: ../../library/argparse.rst:2242 +#: ../../library/argparse.rst:2276 msgid "" "This method prints a usage message, including the *message*, to :data:`sys." "stderr` and terminates the program with a status code of 2." @@ -4370,11 +4443,11 @@ msgstr "" "此方法將用法訊息(包含 *message*)印出到 :data:`sys.stderr`,並以狀態碼 2 終" "止程式。" -#: ../../library/argparse.rst:2247 +#: ../../library/argparse.rst:2281 msgid "Intermixed parsing" msgstr "交錯剖析" -#: ../../library/argparse.rst:2252 +#: ../../library/argparse.rst:2286 msgid "" "A number of Unix commands allow the user to intermix optional arguments with " "positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` " @@ -4385,7 +4458,7 @@ msgstr "" "parse_intermixed_args` 和 :meth:`~ArgumentParser." "parse_known_intermixed_args` 方法支援此剖析風格。" -#: ../../library/argparse.rst:2257 +#: ../../library/argparse.rst:2291 msgid "" "These parsers do not support all the :mod:`!argparse` features, and will " "raise exceptions if unsupported features are used. In particular, " @@ -4395,7 +4468,7 @@ msgstr "" "這些剖析器不支援所有 :mod:`!argparse` 功能,如果使用了不支援的功能會引發例" "外。特別是不支援子剖析器,以及同時包含可選引數和位置引數的互斥群組。" -#: ../../library/argparse.rst:2262 +#: ../../library/argparse.rst:2296 msgid "" "The following example shows the difference between :meth:`~ArgumentParser." "parse_known_args` and :meth:`~ArgumentParser.parse_intermixed_args`: the " @@ -4406,7 +4479,7 @@ msgstr "" "`~ArgumentParser.parse_intermixed_args` 之間的差異:前者回傳 ``['2', '3']`` " "作為未剖析的引數,而後者將所有位置引數收集到 ``rest`` 中。 ::" -#: ../../library/argparse.rst:2268 +#: ../../library/argparse.rst:2302 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -4426,7 +4499,7 @@ msgstr "" ">>> parser.parse_intermixed_args('doit 1 --foo bar 2 3'.split())\n" "Namespace(cmd='doit', foo='bar', rest=[1, 2, 3])" -#: ../../library/argparse.rst:2277 +#: ../../library/argparse.rst:2311 msgid "" ":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple " "containing the populated namespace and the list of remaining argument " @@ -4437,11 +4510,11 @@ msgstr "" "填充後的命名空間和剩餘引數字串的串列。:meth:`~ArgumentParser." "parse_intermixed_args` 在有任何剩餘未剖析的引數字串時會引發錯誤。" -#: ../../library/argparse.rst:2286 +#: ../../library/argparse.rst:2320 msgid "Registering custom types or actions" msgstr "註冊自訂型別或 action" -#: ../../library/argparse.rst:2290 +#: ../../library/argparse.rst:2324 msgid "" "Sometimes it's desirable to use a custom string in error messages to provide " "more user-friendly output. In these cases, :meth:`!register` can be used to " @@ -4452,7 +4525,7 @@ msgstr "" "用 :meth:`!register` 向剖析器註冊自訂 action 或型別,讓你可以透過註冊名稱而非" "可呼叫物件名稱來參照型別。" -#: ../../library/argparse.rst:2295 +#: ../../library/argparse.rst:2329 msgid "" "The :meth:`!register` method accepts three arguments - a *registry_name*, " "specifying the internal registry where the object will be stored (e.g., " @@ -4463,12 +4536,12 @@ msgstr "" "錄檔(例如 ``action``、``type``);*value*,用於註冊物件的鍵值;以及 object," "要註冊的可呼叫物件。" -#: ../../library/argparse.rst:2300 +#: ../../library/argparse.rst:2334 msgid "" "The following example shows how to register a custom type with a parser::" msgstr "以下範例展示如何向剖析器註冊自訂型別: ::" -#: ../../library/argparse.rst:2302 +#: ../../library/argparse.rst:2336 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -4496,46 +4569,102 @@ msgstr "" "usage: PROG [-h] [--foo FOO]\n" "PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" -#: ../../library/argparse.rst:2314 +#: ../../library/argparse.rst:2348 msgid "Exceptions" msgstr "例外" -#: ../../library/argparse.rst:2318 +#: ../../library/argparse.rst:2352 msgid "An error from creating or using an argument (optional or positional)." msgstr "建立或使用引數(可選或位置引數)時的錯誤。" -#: ../../library/argparse.rst:2320 +#: ../../library/argparse.rst:2354 msgid "" "The string value of this exception is the message, augmented with " "information about the argument that caused it." msgstr "此例外的字串值是訊息,附帶了導致錯誤的引數的相關資訊。" -#: ../../library/argparse.rst:2325 +#: ../../library/argparse.rst:2359 msgid "" "Raised when something goes wrong converting a command line string to a type." msgstr "當將命令列字串轉換為型別時出錯時引發。" -#: ../../library/argparse.rst:2329 +#: ../../library/argparse.rst:2363 msgid "Guides and Tutorials" msgstr "指南與教學" -#: ../../library/argparse.rst:909 +#: ../../library/argparse.rst:913 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/argparse.rst:909 ../../library/argparse.rst:941 -#: ../../library/argparse.rst:955 +#: ../../library/argparse.rst:913 ../../library/argparse.rst:945 +#: ../../library/argparse.rst:959 msgid "in argparse module" msgstr "於 argparse 模組中" -#: ../../library/argparse.rst:941 +#: ../../library/argparse.rst:945 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/argparse.rst:955 +#: ../../library/argparse.rst:959 msgid "+ (plus)" msgstr "+ (加號)" +#~ msgid "" +#~ "If the user would like to enable suggestions for mistyped argument " +#~ "choices and subparser names, the feature can be enabled by setting " +#~ "``suggest_on_error`` to ``True``. Note that this only applies for " +#~ "arguments when the choices specified are strings::" +#~ msgstr "" +#~ "如果使用者想要啟用對拼錯的引數選擇和子剖析器名稱的建議,可以透過將 " +#~ "``suggest_on_error`` 設為 ``True`` 來啟用此功能。請注意,這僅適用於指定的" +#~ "選擇皆為字串的引數: ::" + +#~ msgid "" +#~ "If you're writing code that needs to be compatible with older Python " +#~ "versions and want to opportunistically use ``suggest_on_error`` when it's " +#~ "available, you can set it as an attribute after initializing the parser " +#~ "instead of using the keyword argument::" +#~ msgstr "" +#~ "如果你正在撰寫需要與舊版 Python 相容的程式碼,並且想要在 " +#~ "``suggest_on_error`` 可用時伺機使用它,你可以在初始化剖析器後將其設為屬" +#~ "性,而非使用關鍵字引數: ::" + +#~ msgid "" +#~ ">>> parser = argparse.ArgumentParser(description='Process some " +#~ "integers.')\n" +#~ ">>> parser.suggest_on_error = True" +#~ msgstr "" +#~ ">>> parser = argparse.ArgumentParser(description='Process some " +#~ "integers.')\n" +#~ ">>> parser.suggest_on_error = True" + +#~ msgid "" +#~ "Error messages will include color codes when redirecting stderr to a " +#~ "file. To avoid this, set the |NO_COLOR|_ or :envvar:`PYTHON_COLORS` " +#~ "environment variable (for example, ``NO_COLOR=1 python script.py 2> " +#~ "errors.txt``)." +#~ msgstr "" +#~ "將 stderr 重新導向到檔案時,錯誤訊息會包含顏色代碼。若要避免此情況,請設" +#~ "定 |NO_COLOR|_ 或 :envvar:`PYTHON_COLORS` 環境變數(例如 ``NO_COLOR=1 " +#~ "python script.py 2> errors.txt``)。" + +#~ msgid "" +#~ "Furthermore, :meth:`~_SubParsersAction.add_parser` supports an additional " +#~ "*aliases* argument, which allows multiple strings to refer to the same " +#~ "subparser. This example, like ``svn``, aliases ``co`` as a shorthand for " +#~ "``checkout``::" +#~ msgstr "" +#~ "此外,:meth:`~_SubParsersAction.add_parser` 支援一個額外的 *aliases* 引" +#~ "數,它允許多個字串參照同一個子剖析器。這個範例像 ``svn`` 一樣,將 ``co`` " +#~ "作為 ``checkout`` 的簡寫別名: ::" + +#~ msgid "" +#~ ":meth:`~_SubParsersAction.add_parser` supports also an additional " +#~ "*deprecated* argument, which allows to deprecate the subparser." +#~ msgstr "" +#~ ":meth:`~_SubParsersAction.add_parser` 也支援一個額外的 *deprecated* 引數," +#~ "它允許棄用子剖析器。" + #~ msgid "Note, the *default* will be ``None`` unless explicitly set to *0*." #~ msgstr "請注意,除非明確設為 *0*,否則 *default* 將為 ``None``。" diff --git a/library/array.po b/library/array.po index 78bb909a19d..b981fbd903f 100644 --- a/library/array.po +++ b/library/array.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-03 00:49+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -29,16 +29,16 @@ msgstr ":mod:`!array` --- 高效率的數值型陣列" #: ../../library/array.rst:11 msgid "" "This module defines an object type which can compactly represent an array of " -"basic values: characters, integers, floating-point numbers. Arrays are " -"mutable :term:`sequence` types and behave very much like lists, except that " -"the type of objects stored in them is constrained. The type is specified at " -"object creation time by using a :dfn:`type code`, which is a single " -"character. The following type codes are defined:" +"basic values: characters, integers, floating-point numbers, complex " +"numbers. Arrays are mutable :term:`sequence` types and behave very much " +"like lists, except that the type of objects stored in them is constrained. " +"The type is specified at object creation time by using a :dfn:`type code`, " +"which is a single character. The following type codes are defined:" msgstr "" "這個模組定義了一個物件型別,可以簡潔的表達一個包含基本數值的陣列:字元、整" -"數、浮點數。陣列是一個非常類似 list(串列)的\\ :term:`序列 `\\ 型" -"別,除了陣列會限制儲存的物件型別。在建立陣列時可以使用一個字元的 :dfn:`type " -"code` 來指定儲存的資料型別。以下為有被定義的 type codes:" +"數、浮點數、複數。陣列是一個非常類似 list(串列)的\\ :term:`序列 " +"`\\ 型別,除了陣列會限制儲存的物件型別。在建立陣列時可以使用一個字" +"元的 :dfn:`type code` 來指定儲存的資料型別。以下為有被定義的 type codes:" #: ../../library/array.rst:19 msgid "Type code" @@ -102,7 +102,7 @@ msgstr "Unicode character" #: ../../library/array.rst:25 ../../library/array.rst:29 #: ../../library/array.rst:31 ../../library/array.rst:33 -#: ../../library/array.rst:35 +#: ../../library/array.rst:35 ../../library/array.rst:45 msgid "2" msgstr "2" @@ -119,7 +119,7 @@ msgid "Py_UCS4" msgstr "Py_UCS4" #: ../../library/array.rst:27 ../../library/array.rst:37 -#: ../../library/array.rst:39 ../../library/array.rst:45 +#: ../../library/array.rst:39 ../../library/array.rst:47 msgid "4" msgstr "4" @@ -184,7 +184,7 @@ msgid "signed long long" msgstr "signed long long" #: ../../library/array.rst:41 ../../library/array.rst:43 -#: ../../library/array.rst:47 +#: ../../library/array.rst:49 ../../library/array.rst:51 msgid "8" msgstr "8" @@ -197,30 +197,71 @@ msgid "unsigned long long" msgstr "unsigned long long" #: ../../library/array.rst:45 -msgid "``'f'``" -msgstr "``'f'``" +msgid "``'e'``" +msgstr "``'e'``" + +#: ../../library/array.rst:45 +msgid "_Float16" +msgstr "_Float16" #: ../../library/array.rst:45 ../../library/array.rst:47 +#: ../../library/array.rst:49 msgid "float" msgstr "float" +#: ../../library/array.rst:45 +msgid "\\(3)" +msgstr "\\(3)" + #: ../../library/array.rst:47 +msgid "``'f'``" +msgstr "``'f'``" + +#: ../../library/array.rst:49 msgid "``'d'``" msgstr "``'d'``" -#: ../../library/array.rst:47 +#: ../../library/array.rst:49 msgid "double" msgstr "double" -#: ../../library/array.rst:50 +#: ../../library/array.rst:51 +msgid "``'Zf'``" +msgstr "``'Zf'``" + +#: ../../library/array.rst:51 +msgid "float complex" +msgstr "" + +#: ../../library/array.rst:51 ../../library/array.rst:53 +msgid "complex" +msgstr "" + +#: ../../library/array.rst:51 ../../library/array.rst:53 +msgid "\\(4)" +msgstr "\\(4)" + +#: ../../library/array.rst:53 +msgid "``'Zd'``" +msgstr "``'Zd'``" + +#: ../../library/array.rst:53 +msgid "double complex" +msgstr "double complex" + +#: ../../library/array.rst:53 +msgid "16" +msgstr "16" + +#: ../../library/array.rst:57 msgid "Notes:" msgstr "註解:" -#: ../../library/array.rst:53 +#: ../../library/array.rst:60 msgid "It can be 16 bits or 32 bits depending on the platform." msgstr "根據平台的不同,它有可能是 16 位元或者 32 位元。" -#: ../../library/array.rst:55 +#: ../../library/array.rst:62 msgid "" "``array('u')`` now uses :c:type:`wchar_t` as C type instead of deprecated " "``Py_UNICODE``. This change doesn't affect its behavior because " @@ -230,11 +271,28 @@ msgstr "" "C type。這個異動並沒有影響到它的作用,因為自從 Python 3.3 開始 " "``Py_UNICODE`` 即為 :c:type:`wchar_t` 的別名。" -#: ../../library/array.rst:60 +#: ../../library/array.rst:67 msgid "Please migrate to ``'w'`` typecode." msgstr "請改用 ``'w'`` typecode。" -#: ../../library/array.rst:68 +#: ../../library/array.rst:74 +msgid "" +"The IEEE 754 binary16 \"half precision\" type was introduced in the 2008 " +"revision of the `IEEE 754 standard `_. This type is not " +"widely supported by C compilers. It's available as :c:expr:`_Float16` type, " +"if the compiler supports the Annex H of the C23 standard." +msgstr "" + +#: ../../library/array.rst:83 +msgid "" +"Complex types (``Zf`` and ``Zd``) are available unconditionally, regardless " +"on support for complex types (the Annex G of the C11 standard) by the C " +"compiler. As specified in the C11 standard, each complex type is represented " +"by a two-element C array containing, respectively, the real and imaginary " +"parts." +msgstr "" + +#: ../../library/array.rst:93 msgid "" "The :ref:`ctypes ` and :ref:`struct ` modules, as well as third-party modules like `numpy `__, use similar -- but slightly different -- type codes." msgstr "" -#: ../../library/array.rst:74 +#: ../../library/array.rst:99 msgid "" "The actual representation of values is determined by the machine " "architecture (strictly speaking, by the C implementation). The actual size " @@ -251,19 +309,23 @@ msgstr "" "實際上數值的表示方法是被機器的架構所決定(更精準地說,被 C 的實作方法決定)。" "實際的大小可以透過 :attr:`array.itemsize` 屬性存取。" -#: ../../library/array.rst:78 +#: ../../library/array.rst:103 msgid "The module defines the following item:" msgstr "這個模組定義了以下項目:" -#: ../../library/array.rst:83 -msgid "A string with all available type codes." -msgstr "一個包含所有可用的 type codes 的字串。" +#: ../../library/array.rst:108 +msgid "A tuple with all available type codes." +msgstr "一個包含所有可用的 type codes 的 tuple。" + +#: ../../library/array.rst:110 +msgid "The type changed from :class:`str` to :class:`tuple`." +msgstr "" -#: ../../library/array.rst:86 +#: ../../library/array.rst:114 msgid "The module defines the following type:" msgstr "這個模組定義了下方的型別:" -#: ../../library/array.rst:91 +#: ../../library/array.rst:119 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:" @@ -274,7 +336,7 @@ msgstr "" "*initializer* 必須是一個 :class:`bytes` 或 :class:`bytearray` 物件、一個 " "Unicode 字串或包含適當型別元素的可疊代物件 (iterable)。" -#: ../../library/array.rst:96 +#: ../../library/array.rst:124 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 " @@ -287,7 +349,7 @@ msgstr "" "方法;其他情況時, 一個 initializer 的可疊代物件將被傳入 :meth:`extend` 方法" "之中來將初始項目新增至陣列。" -#: ../../library/array.rst:103 +#: ../../library/array.rst:131 msgid "" "Array objects support the ordinary :ref:`mutable ` :term:" "`sequence` operations of indexing, slicing, concatenation, and " @@ -302,11 +364,11 @@ msgstr "" "code,其他型別的數值將導致 :exc:`TypeError`。陣列同時也實作了緩衝區介面,可以" "在任何支援 :term:`bytes-like objects ` 的地方使用。" -#: ../../library/array.rst:109 +#: ../../library/array.rst:137 msgid "Arrays are :ref:`generic ` over the type of their contents." msgstr "" -#: ../../library/array.rst:111 +#: ../../library/array.rst:139 msgid "" "Raises an :ref:`auditing event ` ``array.__new__`` with arguments " "``typecode``, ``initializer``." @@ -314,19 +376,19 @@ msgstr "" "引發\\ :ref:`稽核事件 (auditing event) ` ``array.__new__`` 並附帶引" "數 ``typecode``、``initializer``。" -#: ../../library/array.rst:116 +#: ../../library/array.rst:144 msgid "The typecode character used to create the array." msgstr "typecode 字元被用在建立陣列時。" -#: ../../library/array.rst:121 +#: ../../library/array.rst:149 msgid "The length in bytes of one array item in the internal representation." msgstr "陣列當中的一個元素在內部需要的位元組長度。" -#: ../../library/array.rst:126 +#: ../../library/array.rst:154 msgid "Append a new item with the specified value to the end of the array." msgstr "新增一個指定值的新元素到陣列的最尾端。" -#: ../../library/array.rst:131 +#: ../../library/array.rst:159 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 " @@ -343,7 +405,7 @@ msgstr "" "用,例如 :c:func:`!ioctl` 指令。只要陣列存在且沒有使用任何更改長度的操作時," "回傳的數值就有效。" -#: ../../library/array.rst:141 +#: ../../library/array.rst:169 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 " @@ -355,22 +417,25 @@ msgstr "" "適當的做法是使用陣列物件支援的緩衝區介面。這個方法維護了向後兼容性,並應該在" "新的程式碼中避免。關於緩衝區介面的文件在\\ :ref:`bufferobjects`。" -#: ../../library/array.rst:150 +#: ../../library/array.rst:178 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:" +"which are 1, 2, 4, 8 or 16 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." +"written on a machine with a different byte order. Note, that for complex " +"types the order of components (the real part, followed by imaginary part) is " +"preserved." msgstr "" -"\"Byteswap\" 所有陣列中的物件。這只有支援物件長度為 1、2、4 或 8 位元組的陣" -"列,其他型別的值會導致 :exc:`RuntimeError`。這在從機器讀取位元順序不同的檔案" -"時很有用。" +"\"Byteswap\" 所有陣列中的物件。這只有支援物件長度為 1、2、4、8 或 16 位元組的" +"陣列,其他型別的值會導致 :exc:`RuntimeError`。這在從機器讀取位元順序不同的檔" +"案時很有用。注意,對於複數型別,其組成部分的順序(實部,接著是虛部)會被保" +"留。" -#: ../../library/array.rst:158 +#: ../../library/array.rst:187 msgid "Return the number of occurrences of *value* in the array." msgstr "回傳 *value* 在陣列中出現了幾次。" -#: ../../library/array.rst:163 +#: ../../library/array.rst:192 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:" @@ -382,7 +447,7 @@ msgstr "" "個陣列,它必須可以被疊代 (iterable) 且其中的元素必須是可以被加入陣列中的正確" "型別。" -#: ../../library/array.rst:171 +#: ../../library/array.rst:200 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 :" @@ -391,11 +456,11 @@ msgstr "" "從 :term:`bytes-like object` 中新增元素。讀取時會將其內容當作一個機器數值組成" "的陣列(就像從檔案中使用 :meth:`fromfile` 方法讀出的資料)。" -#: ../../library/array.rst:175 +#: ../../library/array.rst:204 msgid ":meth:`!fromstring` is renamed to :meth:`frombytes` for clarity." msgstr "將 :meth:`!fromstring` 更名為 :meth:`frombytes`,使其更加清晰易懂。" -#: ../../library/array.rst:181 +#: ../../library/array.rst:210 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, :" @@ -406,7 +471,7 @@ msgstr "" "入陣列的最尾端。如果只有少於 *n* 個有效的元素會導致 :exc:`EOFError`,但有效的" "元素仍然會被加入陣列中。" -#: ../../library/array.rst:189 +#: ../../library/array.rst:218 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." @@ -414,7 +479,7 @@ msgstr "" "從 list 中新增元素。這等價於 ``for x in list: a.append(x)``,除了有型別錯誤產" "生時,陣列會保持原狀不會被更改。" -#: ../../library/array.rst:195 +#: ../../library/array.rst:224 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. " @@ -426,7 +491,7 @@ msgstr "" "frombytes(unicodestring.encode(enc))`` 來新增 Unicode 資料到一個其他型別的陣" "列。" -#: ../../library/array.rst:203 +#: ../../library/array.rst:232 msgid "" "Return the smallest *i* such that *i* is the index of the first occurrence " "of *value* in the array. The optional arguments *start* and *stop* can be " @@ -437,18 +502,18 @@ msgstr "" "引數 *start* 及 *stop* 則可以被用來在指定的陣列空間中搜尋 *value*。如果 " "*value* 不存在將導致 :exc:`ValueError`。" -#: ../../library/array.rst:208 +#: ../../library/array.rst:237 msgid "Added optional *start* and *stop* parameters." msgstr "新增選擇性的參數 *start* 及 *stop*。" -#: ../../library/array.rst:214 +#: ../../library/array.rst:243 msgid "" "Insert a new item *value* in the array before position *index*. Negative " "values are treated as being relative to the end of the array." msgstr "" "在位置 *index* 之前插入一個元素 *value*。負數的索引值會從陣列尾端開始數。" -#: ../../library/array.rst:220 +#: ../../library/array.rst:249 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 " @@ -457,19 +522,19 @@ msgstr "" "移除並回傳陣列索引值 *i* 的元素。選擇性的引數 *i* 預設為 ``-1``,所以預設會刪" "除並回傳最後一個元素。" -#: ../../library/array.rst:227 +#: ../../library/array.rst:256 msgid "Remove the first occurrence of *value* from the array." msgstr "從陣列中刪除第一個出現的 *value*。" -#: ../../library/array.rst:232 +#: ../../library/array.rst:261 msgid "Remove all elements from the array." msgstr "從陣列中刪除所有元素。" -#: ../../library/array.rst:239 +#: ../../library/array.rst:268 msgid "Reverse the order of the items in the array." msgstr "反轉陣列中元素的順序。" -#: ../../library/array.rst:244 +#: ../../library/array.rst:273 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 " @@ -478,19 +543,19 @@ msgstr "" "將陣列轉為另一個機器數值組成的陣列並回傳它的位元組表示(跟用 :meth:`tofile` " "方法寫入檔案時的位元序列相同)。" -#: ../../library/array.rst:248 +#: ../../library/array.rst:277 msgid ":meth:`!tostring` is renamed to :meth:`tobytes` for clarity." msgstr "為了明確性,過去的 :meth:`!tostring` 已更名為 :meth:`tobytes`。" -#: ../../library/array.rst:254 +#: ../../library/array.rst:283 msgid "Write all items (as machine values) to the :term:`file object` *f*." msgstr "將所有元素(作為機器數值)寫入 :term:`file object` *f*。" -#: ../../library/array.rst:259 +#: ../../library/array.rst:288 msgid "Convert the array to an ordinary list with the same items." msgstr "不更改元素,將陣列轉為一般的 list。" -#: ../../library/array.rst:264 +#: ../../library/array.rst:293 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()." @@ -500,7 +565,7 @@ msgstr "" "列會引發 :exc:`ValueError`。請使用 ``array.tobytes().decode(enc)`` 來為其他型" "別的陣列轉為 Unicode 字串。" -#: ../../library/array.rst:269 +#: ../../library/array.rst:298 msgid "" "The string representation of array objects has the form ``array(typecode, " "initializer)``. The *initializer* is omitted if the array is empty, " @@ -519,7 +584,7 @@ msgstr "" "過 :func:`eval` 轉換回一個擁有相同型別及數值的陣列。如果它包含相應的浮點值," "``inf`` 和 ``nan`` 也必須被定義。範例: ::" -#: ../../library/array.rst:281 +#: ../../library/array.rst:310 msgid "" "array('l')\n" "array('w', 'hello \\u2641')\n" @@ -531,19 +596,19 @@ msgstr "" "array('l', [1, 2, 3, 4, 5])\n" "array('d', [1.0, 2.0, 3.14, -inf, nan])" -#: ../../library/array.rst:289 +#: ../../library/array.rst:318 msgid "Module :mod:`struct`" msgstr ":mod:`struct` 模組" -#: ../../library/array.rst:290 +#: ../../library/array.rst:319 msgid "Packing and unpacking of heterogeneous binary data." msgstr "將包含不同資料類型的二進位資料包裝與解開包裝。" -#: ../../library/array.rst:292 +#: ../../library/array.rst:321 msgid "`NumPy `_" msgstr "`NumPy `_" -#: ../../library/array.rst:293 +#: ../../library/array.rst:322 msgid "The NumPy package defines another array type." msgstr "NumPy 套件定義了另一個陣列型別" diff --git a/library/ast.po b/library/ast.po index 2698f531d13..e17df48d2ad 100644 --- a/library/ast.po +++ b/library/ast.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-01 00:23+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:38+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!ast` --- Abstract syntax trees" msgstr ":mod:`!ast` --- 抽象語法樹 (Abstract Syntax Trees)" -#: ../../library/ast.rst:14 +#: ../../library/ast.rst:11 msgid "**Source code:** :source:`Lib/ast.py`" msgstr "**原始碼:**\\ :source:`Lib/ast.py`" -#: ../../library/ast.rst:18 +#: ../../library/ast.rst:15 msgid "" "The :mod:`!ast` module helps Python applications to process trees of the " "Python abstract syntax grammar. The abstract syntax itself might change " @@ -36,7 +36,7 @@ msgstr "" "syntax grammar) 樹狀資料結構。抽象語法本身可能會隨著每個 Python 版本發布而改" "變;此模組有助於以程式化的方式來得知目前文法的面貌。" -#: ../../library/ast.rst:23 +#: ../../library/ast.rst:20 msgid "" "An abstract syntax tree can be generated by passing :data:`ast." "PyCF_ONLY_AST` as a flag to the :func:`compile` built-in function, or using " @@ -50,15 +50,15 @@ msgstr "" "個物件的樹,其類別都繼承自 :class:`ast.AST`。可以使用內建的 :func:`compile` " "函式將抽象語法樹編譯成 Python 程式碼物件。" -#: ../../library/ast.rst:33 +#: ../../library/ast.rst:30 msgid "Abstract grammar" msgstr "抽象文法 (Abstract Grammar)" -#: ../../library/ast.rst:35 +#: ../../library/ast.rst:32 msgid "The abstract grammar is currently defined as follows:" msgstr "抽象文法目前定義如下:" -#: ../../library/ast.rst:37 +#: ../../library/ast.rst:34 msgid "" "-- ASDL's 4 builtin types are:\n" "-- identifier, int, string, constant\n" @@ -113,8 +113,9 @@ msgid "" "finalbody)\n" " | Assert(expr test, expr? msg)\n" "\n" -" | Import(alias* names)\n" -" | ImportFrom(identifier? module, alias* names, int? level)\n" +" | Import(alias* names, int? is_lazy)\n" +" | ImportFrom(identifier? module, alias* names, int? level, int? " +"is_lazy)\n" "\n" " | Global(identifier* names)\n" " | Nonlocal(identifier* names)\n" @@ -137,7 +138,7 @@ msgid "" " | Set(expr* elts)\n" " | ListComp(expr elt, comprehension* generators)\n" " | SetComp(expr elt, comprehension* generators)\n" -" | DictComp(expr key, expr value, comprehension* generators)\n" +" | DictComp(expr key, expr? value, comprehension* generators)\n" " | GeneratorExp(expr elt, comprehension* generators)\n" " -- the grammar constrains where yield expressions can occur\n" " | Await(expr value)\n" @@ -287,8 +288,9 @@ msgstr "" "finalbody)\n" " | Assert(expr test, expr? msg)\n" "\n" -" | Import(alias* names)\n" -" | ImportFrom(identifier? module, alias* names, int? level)\n" +" | Import(alias* names, int? is_lazy)\n" +" | ImportFrom(identifier? module, alias* names, int? level, int? " +"is_lazy)\n" "\n" " | Global(identifier* names)\n" " | Nonlocal(identifier* names)\n" @@ -311,7 +313,7 @@ msgstr "" " | Set(expr* elts)\n" " | ListComp(expr elt, comprehension* generators)\n" " | SetComp(expr elt, comprehension* generators)\n" -" | DictComp(expr key, expr value, comprehension* generators)\n" +" | DictComp(expr key, expr? value, comprehension* generators)\n" " | GeneratorExp(expr elt, comprehension* generators)\n" " -- the grammar constrains where yield expressions can occur\n" " | Await(expr value)\n" @@ -408,22 +410,22 @@ msgstr "" "end_col_offset)\n" "}\n" -#: ../../library/ast.rst:42 +#: ../../library/ast.rst:41 msgid "Node classes" msgstr "節點 (Node) 類別" -#: ../../library/ast.rst:46 +#: ../../library/ast.rst:45 msgid "" -"This is the base of all AST node classes. The actual node classes are " -"derived from the :file:`Parser/Python.asdl` file, which is reproduced :ref:" -"`above `. They are defined in the :mod:`!_ast` C module " -"and re-exported in :mod:`!ast`." +"This is the abstract base of all AST node classes. The actual node classes " +"are derived from the :file:`Parser/Python.asdl` file, which is reproduced :" +"ref:`above `. They are defined in the :mod:`!_ast` C " +"module and re-exported in :mod:`!ast`." msgstr "" -"這是所有 AST 節點類別的基礎。實際的節點類別是衍生自 :file:`Parser/Python." -"asdl` 檔案,該檔案在\\ :ref:`上方 ` 重現。它們被定義於 :" -"mod:`!_ast` 的 C 模組中,並於 :mod:`!ast` 中重新匯出。" +"這是所有 AST 節點類別的抽象基底類別。實際的節點類別是衍生自 :file:`Parser/" +"Python.asdl` 檔案,該檔案在\\ :ref:`上方 ` 重現。它們被定義" +"於 :mod:`!_ast` 的 C 模組中,並於 :mod:`!ast` 中重新匯出。" -#: ../../library/ast.rst:51 +#: ../../library/ast.rst:50 msgid "" "There is one class defined for each left-hand side symbol in the abstract " "grammar (for example, :class:`ast.stmt` or :class:`ast.expr`). In addition, " @@ -439,13 +441,13 @@ msgstr "" "於具有替代方案(即為「和 (sums)」)的生產規則,左側類別是抽象的:僅有特定建構" "函式節點的實例會被建立。" -#: ../../library/ast.rst:64 +#: ../../library/ast.rst:63 msgid "" "Each concrete class has an attribute :attr:`!_fields` which gives the names " "of all child nodes." msgstr "每個具體類別都有一個屬性 :attr:`!_fields`,它會給出所有子節點的名稱。" -#: ../../library/ast.rst:67 +#: ../../library/ast.rst:66 msgid "" "Each instance of a concrete class has one attribute for each child node, of " "the type as defined in the grammar. For example, :class:`ast.BinOp` " @@ -454,7 +456,7 @@ msgstr "" "具體類別的每個實例對於每個子節點都有一個屬性,其型別如文法中所定義。例如,:" "class:`ast.BinOp` 實例具有型別為 :class:`ast.expr` 的屬性 :attr:`left`。" -#: ../../library/ast.rst:71 +#: ../../library/ast.rst:70 msgid "" "If these attributes are marked as optional in the grammar (using a question " "mark), the value might be ``None``. If the attributes can have zero-or-more " @@ -466,7 +468,7 @@ msgstr "" "可以有零個或多個值(用星號標記),則這些值將表示為 Python 串列。使用 :func:" "`compile` 編譯 AST 時,所有可能的屬性都必須存在並且具有有效值。" -#: ../../library/ast.rst:79 +#: ../../library/ast.rst:78 msgid "" "The :attr:`!_field_types` attribute on each concrete class is a dictionary " "mapping field names (as also listed in :attr:`_fields`) to their types." @@ -474,7 +476,7 @@ msgstr "" "每個具體類別上的 :attr:`!_field_types` 屬性是將欄位名稱(也在 :attr:" "`_fields` 中列出)對映到其型別的字典。" -#: ../../library/ast.rst:82 +#: ../../library/ast.rst:81 msgid "" ">>> ast.TypeVar._field_types\n" "{'name': , 'bound': ast.expr | None, 'default_value': ast.expr " @@ -484,7 +486,7 @@ msgstr "" "{'name': , 'bound': ast.expr | None, 'default_value': ast.expr " "| None}" -#: ../../library/ast.rst:94 +#: ../../library/ast.rst:93 msgid "" "Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses have :attr:" "`lineno`, :attr:`col_offset`, :attr:`end_lineno`, and :attr:`end_col_offset` " @@ -502,7 +504,7 @@ msgstr "" "`end_col_offset` 是生成節點的第一個和最後一個標記對應的 UTF-8 位元組偏移量。" "會記錄 UTF-8 偏移量是因為剖析器 (parser) 內部使用 UTF-8。" -#: ../../library/ast.rst:103 +#: ../../library/ast.rst:102 msgid "" "Note that the end positions are not required by the compiler and are " "therefore optional. The end offset is *after* the last symbol, for example " @@ -513,12 +515,12 @@ msgstr "" "之後*,例如可以使用 ``source_line[node.col_offset : node.end_col_offset]`` 來" "取得單列運算式節點 (expression node) 的原始片段。" -#: ../../library/ast.rst:108 +#: ../../library/ast.rst:107 msgid "" "The constructor of a class :class:`ast.T` parses its arguments as follows:" msgstr ":class:`ast.T` 類別的建構函式按以下方式剖析其引數:" -#: ../../library/ast.rst:110 +#: ../../library/ast.rst:109 msgid "" "If there are positional arguments, there must be as many as there are items " "in :attr:`T._fields`; they will be assigned as attributes of these names." @@ -526,20 +528,20 @@ msgstr "" "如果有位置引數,則必須與 :attr:`T._fields` 中的項目一樣多;它們將被賦値為這些" "名稱的屬性。" -#: ../../library/ast.rst:112 +#: ../../library/ast.rst:111 msgid "" "If there are keyword arguments, they will set the attributes of the same " "names to the given values." msgstr "如果有關鍵字引數,它們會將相同名稱的屬性設定為給定值。" -#: ../../library/ast.rst:115 +#: ../../library/ast.rst:114 msgid "" "For example, to create and populate an :class:`ast.UnaryOp` node, you could " "use ::" msgstr "" "例如,要建立並填充 (populate) :class:`ast.UnaryOp` 節點,你可以使用: ::" -#: ../../library/ast.rst:118 +#: ../../library/ast.rst:117 msgid "" "node = ast.UnaryOp(ast.USub(), ast.Constant(5, lineno=0, col_offset=0),\n" " lineno=0, col_offset=0)" @@ -547,7 +549,7 @@ msgstr "" "node = ast.UnaryOp(ast.USub(), ast.Constant(5, lineno=0, col_offset=0),\n" " lineno=0, col_offset=0)" -#: ../../library/ast.rst:121 +#: ../../library/ast.rst:120 msgid "" "If a field that is optional in the grammar is omitted from the constructor, " "it defaults to ``None``. If a list field is omitted, it defaults to the " @@ -562,17 +564,17 @@ msgstr "" "`DeprecationWarning`,且 AST 節點將沒有此欄位。在 Python 3.15 中,這種情況會" "引發錯誤。" -#: ../../library/ast.rst:130 +#: ../../library/ast.rst:129 msgid "Class :class:`ast.Constant` is now used for all constants." msgstr ":class:`ast.Constant` 類別現在用於所有常數。" -#: ../../library/ast.rst:134 +#: ../../library/ast.rst:133 msgid "" "Simple indices are represented by their value, extended slices are " "represented as tuples." msgstr "以它們的值表示簡單索引,擴充切片 (slice) 則以元組 (tuple) 表示。" -#: ../../library/ast.rst:139 +#: ../../library/ast.rst:138 msgid "" "AST node constructors were changed to provide sensible defaults for omitted " "fields: optional fields now default to ``None``, list fields default to an " @@ -581,14 +583,14 @@ msgid "" "constructed nodes (accessing them raised :exc:`AttributeError`)." msgstr "" -#: ../../library/ast.rst:147 +#: ../../library/ast.rst:146 msgid "" "The :meth:`~object.__repr__` output of :class:`~ast.AST` nodes includes the " "values of the node fields." msgstr "" ":class:`~ast.AST` 節點的 :meth:`~object.__repr__` 輸出包含節點欄位的值。" -#: ../../library/ast.rst:152 +#: ../../library/ast.rst:151 msgid "" "Previous versions of Python provided the AST classes :class:`!ast.Num`, :" "class:`!ast.Str`, :class:`!ast.Bytes`, :class:`!ast.NameConstant` and :class:" @@ -601,7 +603,7 @@ msgstr "" "些類別在 Python 3.8 中已被棄用。這些類別在 Python 3.14 中被移除,其功能已被 :" "class:`ast.Constant` 取代。" -#: ../../library/ast.rst:160 +#: ../../library/ast.rst:159 msgid "" "Old classes :class:`!ast.Index` and :class:`!ast.ExtSlice` are still " "available, but they will be removed in future Python releases. In the " @@ -610,19 +612,28 @@ msgstr "" "舊的類別 :class:`!ast.Index` 和 :class:`!ast.ExtSlice` 仍然可用,但它們將在未" "來的 Python 版本中刪除。同時,實例化它們會回傳不同類別的實例。" -#: ../../library/ast.rst:167 +#: ../../library/ast.rst:166 msgid "" "Previous versions of Python allowed the creation of AST nodes that were " "missing required fields. Similarly, AST node constructors allowed arbitrary " "keyword arguments that were set as attributes of the AST node, even if they " -"did not match any of the fields of the AST node. This behavior is deprecated " -"and will be removed in Python 3.15." +"did not match any of the fields of the AST node. These cases now raise a :" +"exc:`TypeError`." msgstr "" "先前版本的 Python 允許建立缺少必填欄位的 AST 節點。同樣地,AST 節點建構函式允" "許將任意關鍵字引數設為 AST 節點的屬性,即使它們與 AST 節點的任何欄位都不匹" -"配。此行為已被棄用,並將在 Python 3.15 中刪除。" +"配。這些情況現在會引發 :exc:`TypeError`。" -#: ../../library/ast.rst:174 +#: ../../library/ast.rst:173 +msgid "" +"In the :ref:`grammar above `, the AST node classes that " +"correspond to production rules with variants (aka \"sums\") are abstract " +"classes. Previous versions of Python allowed for the creation of direct " +"instances of these abstract node classes. This behavior is deprecated and " +"will be removed in Python 3.20." +msgstr "" + +#: ../../library/ast.rst:181 msgid "" "The descriptions of the specific node classes displayed here were initially " "adapted from the fantastic `Green Tree Snakes `__ 專案和所有貢獻者那裡改編而來" "的。" -#: ../../library/ast.rst:183 +#: ../../library/ast.rst:190 msgid "Root nodes" msgstr "根節點" -#: ../../library/ast.rst:187 +#: ../../library/ast.rst:194 msgid "" "A Python module, as with :ref:`file input `. Node type generated " "by :func:`ast.parse` in the default ``\"exec\"`` *mode*." @@ -644,11 +655,11 @@ msgstr "" "一個 Python 模組,與\\ :ref:`檔案輸入 ` 一樣。由 :func:`ast." "parse` 在預設的 ``\"exec\"`` *mode* 下生成的節點型別。" -#: ../../library/ast.rst:190 +#: ../../library/ast.rst:197 msgid "``body`` is a :class:`list` of the module's :ref:`ast-statements`." msgstr "``body`` 是模組的\\ :ref:`ast-statements` 的一個 :class:`list`。" -#: ../../library/ast.rst:192 +#: ../../library/ast.rst:199 msgid "" "``type_ignores`` is a :class:`list` of the module's type ignore comments; " "see :func:`ast.parse` for more details." @@ -656,7 +667,7 @@ msgstr "" "``type_ignores`` 是模組的忽略型別註解的 :class:`list`;有關更多詳細資訊,請參" "閱 :func:`ast.parse`。" -#: ../../library/ast.rst:195 +#: ../../library/ast.rst:202 msgid "" ">>> print(ast.dump(ast.parse('x = 1'), indent=4))\n" "Module(\n" @@ -674,7 +685,7 @@ msgstr "" " Name(id='x', ctx=Store())],\n" " value=Constant(value=1))])" -#: ../../library/ast.rst:208 +#: ../../library/ast.rst:215 msgid "" "A single Python :ref:`expression input `. Node type " "generated by :func:`ast.parse` when *mode* is ``\"eval\"``." @@ -682,14 +693,14 @@ msgstr "" "單個 Python :ref:`運算式輸入 `。當 *mode* 是 ``\"eval\"`` " "時節點型別由 :func:`ast.parse` 生成。" -#: ../../library/ast.rst:211 +#: ../../library/ast.rst:218 msgid "" "``body`` is a single node, one of the :ref:`expression types `." msgstr "" "``body`` 是單個節點,是\\ :ref:`運算式型別 `\\ 的其中之一。" -#: ../../library/ast.rst:214 +#: ../../library/ast.rst:221 msgid "" ">>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))\n" "Expression(\n" @@ -699,7 +710,7 @@ msgstr "" "Expression(\n" " body=Constant(value=123))" -#: ../../library/ast.rst:223 +#: ../../library/ast.rst:230 msgid "" "A single :ref:`interactive input `, like in :ref:`tut-interac`. " "Node type generated by :func:`ast.parse` when *mode* is ``\"single\"``." @@ -707,13 +718,13 @@ msgstr "" "單個\\ :ref:`互動式輸入 `,和\\ :ref:`tut-interac`\\ 中所述的相" "似。當 *mode* 是 ``\"single\"`` 時節點型別由 :func:`ast.parse` 生成。" -#: ../../library/ast.rst:226 +#: ../../library/ast.rst:233 msgid "``body`` is a :class:`list` of :ref:`statement nodes `." msgstr "" "``body`` 是\\ :ref:`陳述式節點 (statement nodes) ` 的 :class:" "`list`。" -#: ../../library/ast.rst:228 +#: ../../library/ast.rst:235 msgid "" ">>> print(ast.dump(ast.parse('x = 1; y = 2', mode='single'), indent=4))\n" "Interactive(\n" @@ -739,7 +750,7 @@ msgstr "" " Name(id='y', ctx=Store())],\n" " value=Constant(value=2))])" -#: ../../library/ast.rst:245 +#: ../../library/ast.rst:252 msgid "" "A representation of an old-style type comments for functions, as Python " "versions prior to 3.5 didn't support :pep:`484` annotations. Node type " @@ -748,11 +759,11 @@ msgstr "" "函式的舊式型別註解的表示法,因為 3.5 之前的 Python 版本不支援 :pep:`484` 註" "釋。當 *mode* 是 ``\"func_type\"`` 時節點型別由 :func:`ast.parse` 生成。" -#: ../../library/ast.rst:249 +#: ../../library/ast.rst:256 msgid "Such type comments would look like this::" msgstr "這種型別的註解看起來像這樣: ::" -#: ../../library/ast.rst:251 +#: ../../library/ast.rst:258 msgid "" "def sum_two_number(a, b):\n" " # type: (int, int) -> int\n" @@ -762,45 +773,43 @@ msgstr "" " # type: (int, int) -> int\n" " return a + b" -#: ../../library/ast.rst:255 +#: ../../library/ast.rst:262 msgid "" "``argtypes`` is a :class:`list` of :ref:`expression nodes `." msgstr "" "``argtypes`` 是\\ :ref:`運算式節點 `\\ 的 :class:`list`。" -#: ../../library/ast.rst:257 +#: ../../library/ast.rst:264 msgid "``returns`` is a single :ref:`expression node `." msgstr "``returns`` 是單個\\ :ref:`運算式節點 `。" -#: ../../library/ast.rst:259 +#: ../../library/ast.rst:266 msgid "" ">>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), " "indent=4))\n" "FunctionType(\n" " argtypes=[\n" -" Name(id='int', ctx=Load()),\n" -" Name(id='str', ctx=Load())],\n" +" Name(id='int'),\n" +" Name(id='str')],\n" " returns=Subscript(\n" -" value=Name(id='List', ctx=Load()),\n" -" slice=Name(id='int', ctx=Load()),\n" -" ctx=Load()))" +" value=Name(id='List'),\n" +" slice=Name(id='int')))" msgstr "" ">>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), " "indent=4))\n" "FunctionType(\n" " argtypes=[\n" -" Name(id='int', ctx=Load()),\n" -" Name(id='str', ctx=Load())],\n" +" Name(id='int'),\n" +" Name(id='str')],\n" " returns=Subscript(\n" -" value=Name(id='List', ctx=Load()),\n" -" slice=Name(id='int', ctx=Load()),\n" -" ctx=Load()))" +" value=Name(id='List'),\n" +" slice=Name(id='int')))" -#: ../../library/ast.rst:275 +#: ../../library/ast.rst:281 msgid "Literals" msgstr "文本 (Literals)" -#: ../../library/ast.rst:279 +#: ../../library/ast.rst:285 msgid "" "A constant value. The ``value`` attribute of the ``Constant`` literal " "contains the Python object it represents. The values represented can be " @@ -813,14 +822,14 @@ msgstr "" "class:`complex` 和 :class:`bool` 的實例,以及常數 :data:`None` 和 :data:" "`Ellipsis`。" -#: ../../library/ast.rst:284 +#: ../../library/ast.rst:290 msgid "" "The ``kind`` attribute is an optional string. For string literals with a " "``u`` prefix, ``kind`` is set to ``'u'``. For all other constants, ``kind`` " "is ``None``." msgstr "" -#: ../../library/ast.rst:288 +#: ../../library/ast.rst:294 msgid "" ">>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))\n" "Expression(\n" @@ -836,7 +845,7 @@ msgstr "" "Expression(\n" " body=Constant(value='hello', kind='u'))" -#: ../../library/ast.rst:300 +#: ../../library/ast.rst:306 msgid "" "Node representing a single formatting field in an f-string. If the string " "contains a single formatting field and nothing else the node can be isolated " @@ -846,33 +855,33 @@ msgstr "" "沒有其他內容,則可以隔離 (isolate) 該節點,否則它將出現在 :class:`JoinedStr` " "中。" -#: ../../library/ast.rst:304 +#: ../../library/ast.rst:310 msgid "" "``value`` is any expression node (such as a literal, a variable, or a " "function call)." msgstr "``value`` 為任何運算式節點(例如文字、變數或函式呼叫)。" -#: ../../library/ast.rst:306 ../../library/ast.rst:388 +#: ../../library/ast.rst:312 ../../library/ast.rst:394 msgid "``conversion`` is an integer:" msgstr "``conversion`` 是一個整數:" -#: ../../library/ast.rst:308 +#: ../../library/ast.rst:314 msgid "-1: no formatting" msgstr "-1: 無格式化" -#: ../../library/ast.rst:309 +#: ../../library/ast.rst:315 msgid "97 (``ord('a')``): ``!a`` :func:`ASCII ` formatting" msgstr "97 (``ord('a')``):``!a`` :func:`ASCII ` 格式化" -#: ../../library/ast.rst:310 +#: ../../library/ast.rst:316 msgid "114 (``ord('r')``): ``!r`` :func:`repr` formatting" msgstr "114 (``ord('r')``):``!r`` :func:`repr` 格式化" -#: ../../library/ast.rst:311 +#: ../../library/ast.rst:317 msgid "115 (``ord('s')``): ``!s`` :func:`string ` formatting" msgstr "115 (``ord('s')``):``!s`` :func:`string ` 格式化" -#: ../../library/ast.rst:313 +#: ../../library/ast.rst:319 msgid "" "``format_spec`` is a :class:`JoinedStr` node representing the formatting of " "the value, or ``None`` if no format was specified. Both ``conversion`` and " @@ -881,14 +890,14 @@ msgstr "" "``format_spec`` 是一個 :class:`JoinedStr` 節點,表示值的格式,若未指定格式則" "為 ``None``。``conversion`` 和 ``format_spec`` 可以同時設定。" -#: ../../library/ast.rst:320 +#: ../../library/ast.rst:326 msgid "" "An f-string, comprising a series of :class:`FormattedValue` and :class:" "`Constant` nodes." msgstr "" "一個 f 字串,包含一系列 :class:`FormattedValue` 和 :class:`Constant` 節點。" -#: ../../library/ast.rst:323 +#: ../../library/ast.rst:329 msgid "" ">>> print(ast.dump(ast.parse('f\"sin({a}) is {sin(a):.3}\"', mode='eval'), " "indent=4))\n" @@ -897,14 +906,14 @@ msgid "" " values=[\n" " Constant(value='sin('),\n" " FormattedValue(\n" -" value=Name(id='a', ctx=Load()),\n" +" value=Name(id='a'),\n" " conversion=-1),\n" " Constant(value=') is '),\n" " FormattedValue(\n" " value=Call(\n" -" func=Name(id='sin', ctx=Load()),\n" +" func=Name(id='sin'),\n" " args=[\n" -" Name(id='a', ctx=Load())]),\n" +" Name(id='a')]),\n" " conversion=-1,\n" " format_spec=JoinedStr(\n" " values=[\n" @@ -917,20 +926,20 @@ msgstr "" " values=[\n" " Constant(value='sin('),\n" " FormattedValue(\n" -" value=Name(id='a', ctx=Load()),\n" +" value=Name(id='a'),\n" " conversion=-1),\n" " Constant(value=') is '),\n" " FormattedValue(\n" " value=Call(\n" -" func=Name(id='sin', ctx=Load()),\n" +" func=Name(id='sin'),\n" " args=[\n" -" Name(id='a', ctx=Load())]),\n" +" Name(id='a')]),\n" " conversion=-1,\n" " format_spec=JoinedStr(\n" " values=[\n" " Constant(value='.3')]))]))" -#: ../../library/ast.rst:349 +#: ../../library/ast.rst:355 msgid "" "Node representing a template string literal, comprising a series of :class:" "`Interpolation` and :class:`Constant` nodes. These nodes may be any order, " @@ -939,7 +948,7 @@ msgstr "" "表示模板字串字面值的節點,由一系列 :class:`Interpolation` 和 :class:" "`Constant` 節點組成。這些節點可以是任意順序,不需要交錯排列。" -#: ../../library/ast.rst:353 +#: ../../library/ast.rst:359 msgid "" ">>> expr = ast.parse('t\"{name} finished {place:ordinal}\"', mode='eval')\n" ">>> print(ast.dump(expr, indent=4))\n" @@ -947,12 +956,12 @@ msgid "" " body=TemplateStr(\n" " values=[\n" " Interpolation(\n" -" value=Name(id='name', ctx=Load()),\n" +" value=Name(id='name'),\n" " str='name',\n" " conversion=-1),\n" " Constant(value=' finished '),\n" " Interpolation(\n" -" value=Name(id='place', ctx=Load()),\n" +" value=Name(id='place'),\n" " str='place',\n" " conversion=-1,\n" " format_spec=JoinedStr(\n" @@ -965,24 +974,24 @@ msgstr "" " body=TemplateStr(\n" " values=[\n" " Interpolation(\n" -" value=Name(id='name', ctx=Load()),\n" +" value=Name(id='name'),\n" " str='name',\n" " conversion=-1),\n" " Constant(value=' finished '),\n" " Interpolation(\n" -" value=Name(id='place', ctx=Load()),\n" +" value=Name(id='place'),\n" " str='place',\n" " conversion=-1,\n" " format_spec=JoinedStr(\n" " values=[\n" " Constant(value='ordinal')]))]))" -#: ../../library/ast.rst:377 +#: ../../library/ast.rst:383 msgid "" "Node representing a single interpolation field in a template string literal." msgstr "表示模板字串字面值中單一插值欄位的節點。" -#: ../../library/ast.rst:379 +#: ../../library/ast.rst:385 msgid "" "``value`` is any expression node (such as a literal, a variable, or a " "function call). This has the same meaning as ``FormattedValue.value``." @@ -990,12 +999,12 @@ msgstr "" "``value`` 為任何運算式節點(例如文字、變數或函式呼叫)。這和 " "``FormattedValue.value`` 的意思相同。" -#: ../../library/ast.rst:382 +#: ../../library/ast.rst:388 msgid "" "``str`` is a constant containing the text of the interpolation expression." msgstr "``str`` 是一個包含插值運算式文字的常數。" -#: ../../library/ast.rst:384 +#: ../../library/ast.rst:390 msgid "" "If ``str`` is set to ``None``, then ``value`` is used to generate code when " "calling :func:`ast.unparse`. This no longer guarantees that the generated " @@ -1005,27 +1014,27 @@ msgstr "" "``value`` 來產生程式碼。這不再保證產生的程式碼與原始程式碼相同,且適用於程式" "碼產生。" -#: ../../library/ast.rst:390 +#: ../../library/ast.rst:396 msgid "-1: no conversion" msgstr "-1:無規範" -#: ../../library/ast.rst:391 +#: ../../library/ast.rst:397 msgid "97 (``ord('a')``): ``!a`` :func:`ASCII ` conversion" msgstr "97 (``ord('a')``):``!a`` :func:`ASCII ` 轉換" -#: ../../library/ast.rst:392 +#: ../../library/ast.rst:398 msgid "114 (``ord('r')``): ``!r`` :func:`repr` conversion" msgstr "114 (``ord('r')``):``!r`` :func:`repr` 轉換" -#: ../../library/ast.rst:393 +#: ../../library/ast.rst:399 msgid "115 (``ord('s')``): ``!s`` :func:`string ` conversion" msgstr "115 (``ord('s')``):``!s`` :func:`string ` 轉換" -#: ../../library/ast.rst:395 +#: ../../library/ast.rst:401 msgid "This has the same meaning as ``FormattedValue.conversion``." msgstr "這與 ``FormattedValue.conversion`` 的意思相同。" -#: ../../library/ast.rst:396 +#: ../../library/ast.rst:402 msgid "" "``format_spec`` is a :class:`JoinedStr` node representing the formatting of " "the value, or ``None`` if no format was specified. Both ``conversion`` and " @@ -1036,7 +1045,7 @@ msgstr "" "為 ``None``。``conversion`` 和 ``format_spec`` 可以同時設定。這與 " "``FormattedValue.format_spec`` 的意思相同。" -#: ../../library/ast.rst:405 +#: ../../library/ast.rst:411 msgid "" "A list or tuple. ``elts`` holds a list of nodes representing the elements. " "``ctx`` is :class:`Store` if the container is an assignment target (i.e. " @@ -1045,7 +1054,7 @@ msgstr "" "串列或元組。``elts`` 保存表示元素的節點串列。如果容器是賦值目標(即 ``(x," "y)=something`` ),則 ``ctx`` 是 :class:`Store`,否則是 :class:`Load`。" -#: ../../library/ast.rst:409 +#: ../../library/ast.rst:415 msgid "" ">>> print(ast.dump(ast.parse('[1, 2, 3]', mode='eval'), indent=4))\n" "Expression(\n" @@ -1053,16 +1062,14 @@ msgid "" " elts=[\n" " Constant(value=1),\n" " Constant(value=2),\n" -" Constant(value=3)],\n" -" ctx=Load()))\n" +" Constant(value=3)]))\n" ">>> print(ast.dump(ast.parse('(1, 2, 3)', mode='eval'), indent=4))\n" "Expression(\n" " body=Tuple(\n" " elts=[\n" " Constant(value=1),\n" " Constant(value=2),\n" -" Constant(value=3)],\n" -" ctx=Load()))" +" Constant(value=3)]))" msgstr "" ">>> print(ast.dump(ast.parse('[1, 2, 3]', mode='eval'), indent=4))\n" "Expression(\n" @@ -1070,22 +1077,20 @@ msgstr "" " elts=[\n" " Constant(value=1),\n" " Constant(value=2),\n" -" Constant(value=3)],\n" -" ctx=Load()))\n" +" Constant(value=3)]))\n" ">>> print(ast.dump(ast.parse('(1, 2, 3)', mode='eval'), indent=4))\n" "Expression(\n" " body=Tuple(\n" " elts=[\n" " Constant(value=1),\n" " Constant(value=2),\n" -" Constant(value=3)],\n" -" ctx=Load()))" +" Constant(value=3)]))" -#: ../../library/ast.rst:431 +#: ../../library/ast.rst:435 msgid "A set. ``elts`` holds a list of nodes representing the set's elements." msgstr "一個集合。``elts`` 保存表示集合之元素的節點串列。" -#: ../../library/ast.rst:433 +#: ../../library/ast.rst:437 msgid "" ">>> print(ast.dump(ast.parse('{1, 2, 3}', mode='eval'), indent=4))\n" "Expression(\n" @@ -1103,7 +1108,7 @@ msgstr "" " Constant(value=2),\n" " Constant(value=3)]))" -#: ../../library/ast.rst:446 +#: ../../library/ast.rst:450 msgid "" "A dictionary. ``keys`` and ``values`` hold lists of nodes representing the " "keys and the values respectively, in matching order (what would be returned " @@ -1113,7 +1118,7 @@ msgstr "" "節點串列(為呼叫 :code:`dictionary.keys()` 和 :code:`dictionary.values()` 時" "將回傳的內容)。" -#: ../../library/ast.rst:450 +#: ../../library/ast.rst:454 msgid "" "When doing dictionary unpacking using dictionary literals the expression to " "be expanded goes in the ``values`` list, with a ``None`` at the " @@ -1122,7 +1127,7 @@ msgstr "" "當使用字典文本進行字典解包 (unpack) 時,要擴充的運算式位於 ``values`` 串列" "中,在 ``keys`` 中的相應位置有一個 ``None``。" -#: ../../library/ast.rst:454 +#: ../../library/ast.rst:458 msgid "" ">>> print(ast.dump(ast.parse('{\"a\":1, **d}', mode='eval'), indent=4))\n" "Expression(\n" @@ -1132,7 +1137,7 @@ msgid "" " None],\n" " values=[\n" " Constant(value=1),\n" -" Name(id='d', ctx=Load())]))" +" Name(id='d')]))" msgstr "" ">>> print(ast.dump(ast.parse('{\"a\":1, **d}', mode='eval'), indent=4))\n" "Expression(\n" @@ -1142,19 +1147,19 @@ msgstr "" " None],\n" " values=[\n" " Constant(value=1),\n" -" Name(id='d', ctx=Load())]))" +" Name(id='d')]))" -#: ../../library/ast.rst:468 +#: ../../library/ast.rst:472 msgid "Variables" msgstr "變數" -#: ../../library/ast.rst:472 +#: ../../library/ast.rst:476 msgid "" "A variable name. ``id`` holds the name as a string, and ``ctx`` is one of " "the following types." msgstr "一個變數名稱。``id`` 將名稱以字串形式保存,且 ``ctx`` 是以下型別之一。" -#: ../../library/ast.rst:480 +#: ../../library/ast.rst:484 msgid "" "Variable references can be used to load the value of a variable, to assign a " "new value to it, or to delete it. Variable references are given a context to " @@ -1163,13 +1168,13 @@ msgstr "" "變數參照可用於載入變數的值、為其分配新值或刪除它。變數參照被賦予情境 " "(context) 來區分這些情況。" -#: ../../library/ast.rst:484 +#: ../../library/ast.rst:488 msgid "" ">>> print(ast.dump(ast.parse('a'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" -" value=Name(id='a', ctx=Load()))])\n" +" value=Name(id='a'))])\n" "\n" ">>> print(ast.dump(ast.parse('a = 1'), indent=4))\n" "Module(\n" @@ -1190,7 +1195,7 @@ msgstr "" "Module(\n" " body=[\n" " Expr(\n" -" value=Name(id='a', ctx=Load()))])\n" +" value=Name(id='a'))])\n" "\n" ">>> print(ast.dump(ast.parse('a = 1'), indent=4))\n" "Module(\n" @@ -1207,7 +1212,7 @@ msgstr "" " targets=[\n" " Name(id='a', ctx=Del())])])" -#: ../../library/ast.rst:510 +#: ../../library/ast.rst:514 msgid "" "A ``*var`` variable reference. ``value`` holds the variable, typically a :" "class:`Name` node. This type must be used when building a :class:`Call` node " @@ -1216,7 +1221,7 @@ msgstr "" "一個 ``*var`` 變數參照。``value`` 保存變數,通常是一個 :class:`Name` 節點。在" "使用 ``*args`` 建置 :class:`Call` 節點時必須使用此型別。" -#: ../../library/ast.rst:514 +#: ../../library/ast.rst:518 msgid "" ">>> print(ast.dump(ast.parse('a, *b = it'), indent=4))\n" "Module(\n" @@ -1230,7 +1235,7 @@ msgid "" " value=Name(id='b', ctx=Store()),\n" " ctx=Store())],\n" " ctx=Store())],\n" -" value=Name(id='it', ctx=Load()))])" +" value=Name(id='it'))])" msgstr "" ">>> print(ast.dump(ast.parse('a, *b = it'), indent=4))\n" "Module(\n" @@ -1244,13 +1249,13 @@ msgstr "" " value=Name(id='b', ctx=Store()),\n" " ctx=Store())],\n" " ctx=Store())],\n" -" value=Name(id='it', ctx=Load()))])" +" value=Name(id='it'))])" -#: ../../library/ast.rst:534 +#: ../../library/ast.rst:538 msgid "Expressions" msgstr "運算式" -#: ../../library/ast.rst:538 +#: ../../library/ast.rst:542 msgid "" "When an expression, such as a function call, appears as a statement by " "itself with its return value not used or stored, it is wrapped in this " @@ -1263,7 +1268,7 @@ msgstr "" "`Constant`、:class:`Name`、:class:`Lambda`、:class:`Yield` 或 :class:" "`YieldFrom`" -#: ../../library/ast.rst:543 +#: ../../library/ast.rst:547 msgid "" ">>> print(ast.dump(ast.parse('-a'), indent=4))\n" "Module(\n" @@ -1271,7 +1276,7 @@ msgid "" " Expr(\n" " value=UnaryOp(\n" " op=USub(),\n" -" operand=Name(id='a', ctx=Load())))])" +" operand=Name(id='a')))])" msgstr "" ">>> print(ast.dump(ast.parse('-a'), indent=4))\n" "Module(\n" @@ -1279,16 +1284,16 @@ msgstr "" " Expr(\n" " value=UnaryOp(\n" " op=USub(),\n" -" operand=Name(id='a', ctx=Load())))])" +" operand=Name(id='a')))])" -#: ../../library/ast.rst:556 +#: ../../library/ast.rst:560 msgid "" "A unary operation. ``op`` is the operator, and ``operand`` any expression " "node." msgstr "" "一元運算 (unary operation)。``op`` 是運算子,``operand`` 是任何運算式節點。" -#: ../../library/ast.rst:565 +#: ../../library/ast.rst:569 msgid "" "Unary operator tokens. :class:`Not` is the ``not`` keyword, :class:`Invert` " "is the ``~`` operator." @@ -1296,21 +1301,21 @@ msgstr "" "一元運算子標記。 :class:`Not` 是 ``not`` 關鍵字、:class:`Invert` 是 ``~`` 運" "算子。" -#: ../../library/ast.rst:568 +#: ../../library/ast.rst:572 msgid "" ">>> print(ast.dump(ast.parse('not x', mode='eval'), indent=4))\n" "Expression(\n" " body=UnaryOp(\n" " op=Not(),\n" -" operand=Name(id='x', ctx=Load())))" +" operand=Name(id='x')))" msgstr "" ">>> print(ast.dump(ast.parse('not x', mode='eval'), indent=4))\n" "Expression(\n" " body=UnaryOp(\n" " op=Not(),\n" -" operand=Name(id='x', ctx=Load())))" +" operand=Name(id='x')))" -#: ../../library/ast.rst:579 +#: ../../library/ast.rst:583 msgid "" "A binary operation (like addition or division). ``op`` is the operator, and " "``left`` and ``right`` are any expression nodes." @@ -1318,27 +1323,27 @@ msgstr "" "二元運算 (binary operation)(如加法或除法)。 ``op`` 是運算子、``left`` 和 " "``right`` 是任意運算式節點。" -#: ../../library/ast.rst:582 +#: ../../library/ast.rst:586 msgid "" ">>> print(ast.dump(ast.parse('x + y', mode='eval'), indent=4))\n" "Expression(\n" " body=BinOp(\n" -" left=Name(id='x', ctx=Load()),\n" +" left=Name(id='x'),\n" " op=Add(),\n" -" right=Name(id='y', ctx=Load())))" +" right=Name(id='y')))" msgstr "" ">>> print(ast.dump(ast.parse('x + y', mode='eval'), indent=4))\n" "Expression(\n" " body=BinOp(\n" -" left=Name(id='x', ctx=Load()),\n" +" left=Name(id='x'),\n" " op=Add(),\n" -" right=Name(id='y', ctx=Load())))" +" right=Name(id='y')))" -#: ../../library/ast.rst:606 +#: ../../library/ast.rst:610 msgid "Binary operator tokens." msgstr "二元運算子 token。" -#: ../../library/ast.rst:611 +#: ../../library/ast.rst:615 msgid "" "A boolean operation, 'or' or 'and'. ``op`` is :class:`Or` or :class:`And`. " "``values`` are the values involved. Consecutive operations with the same " @@ -1349,33 +1354,33 @@ msgstr "" "有所涉及的值。使用同一運算子的連續操作(例如 ``a or b or c``)會被折疊為具有" "多個值的一個節點。" -#: ../../library/ast.rst:616 +#: ../../library/ast.rst:620 msgid "This doesn't include ``not``, which is a :class:`UnaryOp`." msgstr "這不包括 ``not``,它是一個 :class:`UnaryOp`。" -#: ../../library/ast.rst:618 +#: ../../library/ast.rst:622 msgid "" ">>> print(ast.dump(ast.parse('x or y', mode='eval'), indent=4))\n" "Expression(\n" " body=BoolOp(\n" " op=Or(),\n" " values=[\n" -" Name(id='x', ctx=Load()),\n" -" Name(id='y', ctx=Load())]))" +" Name(id='x'),\n" +" Name(id='y')]))" msgstr "" ">>> print(ast.dump(ast.parse('x or y', mode='eval'), indent=4))\n" "Expression(\n" " body=BoolOp(\n" " op=Or(),\n" " values=[\n" -" Name(id='x', ctx=Load()),\n" -" Name(id='y', ctx=Load())]))" +" Name(id='x'),\n" +" Name(id='y')]))" -#: ../../library/ast.rst:632 +#: ../../library/ast.rst:636 msgid "Boolean operator tokens." msgstr "布林運算子 token。" -#: ../../library/ast.rst:637 +#: ../../library/ast.rst:641 msgid "" "A comparison of two or more values. ``left`` is the first value in the " "comparison, ``ops`` the list of operators, and ``comparators`` the list of " @@ -1384,7 +1389,7 @@ msgstr "" "兩個或多個值的比較。``left`` 是比較中的第一個值、``ops`` 是運算子串列、" "``comparators`` 是要比較的第一個元素之後值的串列。" -#: ../../library/ast.rst:641 +#: ../../library/ast.rst:645 msgid "" ">>> print(ast.dump(ast.parse('1 <= a < 10', mode='eval'), indent=4))\n" "Expression(\n" @@ -1394,7 +1399,7 @@ msgid "" " LtE(),\n" " Lt()],\n" " comparators=[\n" -" Name(id='a', ctx=Load()),\n" +" Name(id='a'),\n" " Constant(value=10)]))" msgstr "" ">>> print(ast.dump(ast.parse('1 <= a < 10', mode='eval'), indent=4))\n" @@ -1405,14 +1410,14 @@ msgstr "" " LtE(),\n" " Lt()],\n" " comparators=[\n" -" Name(id='a', ctx=Load()),\n" +" Name(id='a'),\n" " Constant(value=10)]))" -#: ../../library/ast.rst:666 +#: ../../library/ast.rst:670 msgid "Comparison operator tokens." msgstr "比較運算子 token。" -#: ../../library/ast.rst:671 +#: ../../library/ast.rst:675 msgid "" "A function call. ``func`` is the function, which will often be a :class:" "`Name` or :class:`Attribute` object. Of the arguments:" @@ -1420,60 +1425,58 @@ msgstr "" "一個函式呼叫。``func`` 是該函式,通常是一個 :class:`Name` 或 :class:" "`Attribute` 物件。而在引數中:" -#: ../../library/ast.rst:674 +#: ../../library/ast.rst:678 msgid "``args`` holds a list of the arguments passed by position." msgstr "``args`` 保存按位置傳遞的引數串列。" -#: ../../library/ast.rst:675 +#: ../../library/ast.rst:679 msgid "" "``keywords`` holds a list of :class:`.keyword` objects representing " "arguments passed by keyword." msgstr "" "``keywords`` 保存一個 :class:`.keyword` 物件串列,表示透過關鍵字傳遞的引數。" -#: ../../library/ast.rst:678 +#: ../../library/ast.rst:682 msgid "" "The ``args`` and ``keywords`` arguments are optional and default to empty " "lists." msgstr "``args`` 和 ``keywords`` 引數是可選的,預設為空串列。" -#: ../../library/ast.rst:680 +#: ../../library/ast.rst:684 msgid "" ">>> print(ast.dump(ast.parse('func(a, b=c, *d, **e)', mode='eval'), " "indent=4))\n" "Expression(\n" " body=Call(\n" -" func=Name(id='func', ctx=Load()),\n" +" func=Name(id='func'),\n" " args=[\n" -" Name(id='a', ctx=Load()),\n" +" Name(id='a'),\n" " Starred(\n" -" value=Name(id='d', ctx=Load()),\n" -" ctx=Load())],\n" +" value=Name(id='d'))],\n" " keywords=[\n" " keyword(\n" " arg='b',\n" -" value=Name(id='c', ctx=Load())),\n" +" value=Name(id='c')),\n" " keyword(\n" -" value=Name(id='e', ctx=Load()))]))" +" value=Name(id='e'))]))" msgstr "" ">>> print(ast.dump(ast.parse('func(a, b=c, *d, **e)', mode='eval'), " "indent=4))\n" "Expression(\n" " body=Call(\n" -" func=Name(id='func', ctx=Load()),\n" +" func=Name(id='func'),\n" " args=[\n" -" Name(id='a', ctx=Load()),\n" +" Name(id='a'),\n" " Starred(\n" -" value=Name(id='d', ctx=Load()),\n" -" ctx=Load())],\n" +" value=Name(id='d'))],\n" " keywords=[\n" " keyword(\n" " arg='b',\n" -" value=Name(id='c', ctx=Load())),\n" +" value=Name(id='c')),\n" " keyword(\n" -" value=Name(id='e', ctx=Load()))]))" +" value=Name(id='e'))]))" -#: ../../library/ast.rst:701 +#: ../../library/ast.rst:704 msgid "" "A keyword argument to a function call or class definition. ``arg`` is a raw " "string of the parameter name, ``value`` is a node to pass in." @@ -1481,7 +1484,7 @@ msgstr "" "函式呼叫或類別定義的關鍵字引數。``arg`` 是參數名稱的原始字串,``value`` 是要" "傳入的節點。" -#: ../../library/ast.rst:707 +#: ../../library/ast.rst:710 msgid "" "An expression such as ``a if b else c``. Each field holds a single node, so " "in the following example, all three are :class:`Name` nodes." @@ -1489,23 +1492,23 @@ msgstr "" "像是 ``a if b else c`` 之類的運算式。每個欄位都保存一個節點,因此在以下範例" "中,所有三個都是 :class:`Name` 節點。" -#: ../../library/ast.rst:710 +#: ../../library/ast.rst:713 msgid "" ">>> print(ast.dump(ast.parse('a if b else c', mode='eval'), indent=4))\n" "Expression(\n" " body=IfExp(\n" -" test=Name(id='b', ctx=Load()),\n" -" body=Name(id='a', ctx=Load()),\n" -" orelse=Name(id='c', ctx=Load())))" +" test=Name(id='b'),\n" +" body=Name(id='a'),\n" +" orelse=Name(id='c')))" msgstr "" ">>> print(ast.dump(ast.parse('a if b else c', mode='eval'), indent=4))\n" "Expression(\n" " body=IfExp(\n" -" test=Name(id='b', ctx=Load()),\n" -" body=Name(id='a', ctx=Load()),\n" -" orelse=Name(id='c', ctx=Load())))" +" test=Name(id='b'),\n" +" body=Name(id='a'),\n" +" orelse=Name(id='c')))" -#: ../../library/ast.rst:722 +#: ../../library/ast.rst:725 msgid "" "Attribute access, e.g. ``d.keys``. ``value`` is a node, typically a :class:" "`Name`. ``attr`` is a bare string giving the name of the attribute, and " @@ -1516,23 +1519,21 @@ msgstr "" "``attr`` 是一個屬性名稱的字串,``ctx`` 根據屬性的作用方式可能是 :class:" "`Load`、:class:`Store` 或 :class:`Del`。" -#: ../../library/ast.rst:727 +#: ../../library/ast.rst:730 msgid "" ">>> print(ast.dump(ast.parse('snake.colour', mode='eval'), indent=4))\n" "Expression(\n" " body=Attribute(\n" -" value=Name(id='snake', ctx=Load()),\n" -" attr='colour',\n" -" ctx=Load()))" +" value=Name(id='snake'),\n" +" attr='colour'))" msgstr "" ">>> print(ast.dump(ast.parse('snake.colour', mode='eval'), indent=4))\n" "Expression(\n" " body=Attribute(\n" -" value=Name(id='snake', ctx=Load()),\n" -" attr='colour',\n" -" ctx=Load()))" +" value=Name(id='snake'),\n" +" attr='colour'))" -#: ../../library/ast.rst:739 +#: ../../library/ast.rst:741 msgid "" "A named expression. This AST node is produced by the assignment expressions " "operator (also known as the walrus operator). As opposed to the :class:" @@ -1543,7 +1544,7 @@ msgstr "" "運算子)產生。相對於 :class:`Assign` 節點之第一個引數可為多個節點,在這種情況" "下 ``target`` 和 ``value`` 都必須是單個節點。" -#: ../../library/ast.rst:744 +#: ../../library/ast.rst:746 msgid "" ">>> print(ast.dump(ast.parse('(x := 4)', mode='eval'), indent=4))\n" "Expression(\n" @@ -1557,11 +1558,11 @@ msgstr "" " target=Name(id='x', ctx=Store()),\n" " value=Constant(value=4)))" -#: ../../library/ast.rst:755 +#: ../../library/ast.rst:757 msgid "Subscripting" msgstr "下標 (Subscripting)" -#: ../../library/ast.rst:759 +#: ../../library/ast.rst:761 msgid "" "A subscript, such as ``l[1]``. ``value`` is the subscripted object (usually " "sequence or mapping). ``slice`` is an index, slice or key. It can be a :" @@ -1573,33 +1574,29 @@ msgstr "" "下標執行的操作不同,``ctx`` 可以是 :class:`Load`、:class:`Store` 或 :class:" "`Del`。" -#: ../../library/ast.rst:765 +#: ../../library/ast.rst:767 msgid "" ">>> print(ast.dump(ast.parse('l[1:2, 3]', mode='eval'), indent=4))\n" "Expression(\n" " body=Subscript(\n" -" value=Name(id='l', ctx=Load()),\n" +" value=Name(id='l'),\n" " slice=Tuple(\n" " elts=[\n" " Slice(\n" " lower=Constant(value=1),\n" " upper=Constant(value=2)),\n" -" Constant(value=3)],\n" -" ctx=Load()),\n" -" ctx=Load()))" +" Constant(value=3)])))" msgstr "" ">>> print(ast.dump(ast.parse('l[1:2, 3]', mode='eval'), indent=4))\n" "Expression(\n" " body=Subscript(\n" -" value=Name(id='l', ctx=Load()),\n" +" value=Name(id='l'),\n" " slice=Tuple(\n" " elts=[\n" " Slice(\n" " lower=Constant(value=1),\n" " upper=Constant(value=2)),\n" -" Constant(value=3)],\n" -" ctx=Load()),\n" -" ctx=Load()))" +" Constant(value=3)])))" #: ../../library/ast.rst:783 msgid "" @@ -1615,26 +1612,24 @@ msgid "" ">>> print(ast.dump(ast.parse('l[1:2]', mode='eval'), indent=4))\n" "Expression(\n" " body=Subscript(\n" -" value=Name(id='l', ctx=Load()),\n" +" value=Name(id='l'),\n" " slice=Slice(\n" " lower=Constant(value=1),\n" -" upper=Constant(value=2)),\n" -" ctx=Load()))" +" upper=Constant(value=2))))" msgstr "" ">>> print(ast.dump(ast.parse('l[1:2]', mode='eval'), indent=4))\n" "Expression(\n" " body=Subscript(\n" -" value=Name(id='l', ctx=Load()),\n" +" value=Name(id='l'),\n" " slice=Slice(\n" " lower=Constant(value=1),\n" -" upper=Constant(value=2)),\n" -" ctx=Load()))" +" upper=Constant(value=2))))" -#: ../../library/ast.rst:800 +#: ../../library/ast.rst:799 msgid "Comprehensions" msgstr "綜合運算式 (comprehensions)" -#: ../../library/ast.rst:807 +#: ../../library/ast.rst:806 msgid "" "List and set comprehensions, generator expressions, and dictionary " "comprehensions. ``elt`` (or ``key`` and ``value``) is a single node " @@ -1643,11 +1638,18 @@ msgstr "" "串列和集合綜合運算、生成器運算式和字典綜合運算。``elt``\\ (或 ``key`` 和 " "``value``)是單個節點,表示各個項目會被求值 (evaluate) 的部分。" -#: ../../library/ast.rst:811 +#: ../../library/ast.rst:810 +msgid "" +"For dictionary comprehensions using unpacking, for example ``{**item for " +"item in items}``, the expression to be expanded goes in ``key`` and " +"``value`` is ``None``." +msgstr "" + +#: ../../library/ast.rst:814 msgid "``generators`` is a list of :class:`comprehension` nodes." msgstr "``generators`` 是一個 :class:`comprehension` 節點的串列。" -#: ../../library/ast.rst:813 +#: ../../library/ast.rst:816 msgid "" ">>> print(ast.dump(\n" "... ast.parse('[x for x in numbers]', mode='eval'),\n" @@ -1655,11 +1657,11 @@ msgid "" "... ))\n" "Expression(\n" " body=ListComp(\n" -" elt=Name(id='x', ctx=Load()),\n" +" elt=Name(id='x'),\n" " generators=[\n" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" -" iter=Name(id='numbers', ctx=Load()),\n" +" iter=Name(id='numbers'),\n" " is_async=0)]))\n" ">>> print(ast.dump(\n" "... ast.parse('{x: x**2 for x in numbers}', mode='eval'),\n" @@ -1667,15 +1669,15 @@ msgid "" "... ))\n" "Expression(\n" " body=DictComp(\n" -" key=Name(id='x', ctx=Load()),\n" +" key=Name(id='x'),\n" " value=BinOp(\n" -" left=Name(id='x', ctx=Load()),\n" +" left=Name(id='x'),\n" " op=Pow(),\n" " right=Constant(value=2)),\n" " generators=[\n" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" -" iter=Name(id='numbers', ctx=Load()),\n" +" iter=Name(id='numbers'),\n" " is_async=0)]))\n" ">>> print(ast.dump(\n" "... ast.parse('{x for x in numbers}', mode='eval'),\n" @@ -1683,11 +1685,11 @@ msgid "" "... ))\n" "Expression(\n" " body=SetComp(\n" -" elt=Name(id='x', ctx=Load()),\n" +" elt=Name(id='x'),\n" " generators=[\n" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" -" iter=Name(id='numbers', ctx=Load()),\n" +" iter=Name(id='numbers'),\n" " is_async=0)]))" msgstr "" ">>> print(ast.dump(\n" @@ -1696,11 +1698,11 @@ msgstr "" "... ))\n" "Expression(\n" " body=ListComp(\n" -" elt=Name(id='x', ctx=Load()),\n" +" elt=Name(id='x'),\n" " generators=[\n" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" -" iter=Name(id='numbers', ctx=Load()),\n" +" iter=Name(id='numbers'),\n" " is_async=0)]))\n" ">>> print(ast.dump(\n" "... ast.parse('{x: x**2 for x in numbers}', mode='eval'),\n" @@ -1708,15 +1710,15 @@ msgstr "" "... ))\n" "Expression(\n" " body=DictComp(\n" -" key=Name(id='x', ctx=Load()),\n" +" key=Name(id='x'),\n" " value=BinOp(\n" -" left=Name(id='x', ctx=Load()),\n" +" left=Name(id='x'),\n" " op=Pow(),\n" " right=Constant(value=2)),\n" " generators=[\n" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" -" iter=Name(id='numbers', ctx=Load()),\n" +" iter=Name(id='numbers'),\n" " is_async=0)]))\n" ">>> print(ast.dump(\n" "... ast.parse('{x for x in numbers}', mode='eval'),\n" @@ -1724,14 +1726,14 @@ msgstr "" "... ))\n" "Expression(\n" " body=SetComp(\n" -" elt=Name(id='x', ctx=Load()),\n" +" elt=Name(id='x'),\n" " generators=[\n" " comprehension(\n" " target=Name(id='x', ctx=Store()),\n" -" iter=Name(id='numbers', ctx=Load()),\n" +" iter=Name(id='numbers'),\n" " is_async=0)]))" -#: ../../library/ast.rst:859 +#: ../../library/ast.rst:862 msgid "" "One ``for`` clause in a comprehension. ``target`` is the reference to use " "for each element - typically a :class:`Name` or :class:`Tuple` node. " @@ -1742,7 +1744,7 @@ msgstr "" "class:`Name` 或 :class:`Tuple` 節點。``iter`` 是要疊代的物件。``ifs`` 是測試" "運算式的串列:每個 ``for`` 子句可以有多個 ``ifs``。" -#: ../../library/ast.rst:864 +#: ../../library/ast.rst:867 msgid "" "``is_async`` indicates a comprehension is asynchronous (using an ``async " "for`` instead of ``for``). The value is an integer (0 or 1)." @@ -1750,7 +1752,7 @@ msgstr "" "``is_async`` 表示綜合運算式是非同步的(使用 ``async for`` 而不是 ``for`` )。" "該值為整數(0 或 1)。" -#: ../../library/ast.rst:867 +#: ../../library/ast.rst:870 msgid "" ">>> print(ast.dump(ast.parse('[ord(c) for line in file for c in line]', " "mode='eval'),\n" @@ -1758,17 +1760,17 @@ msgid "" "Expression(\n" " body=ListComp(\n" " elt=Call(\n" -" func=Name(id='ord', ctx=Load()),\n" +" func=Name(id='ord'),\n" " args=[\n" -" Name(id='c', ctx=Load())]),\n" +" Name(id='c')]),\n" " generators=[\n" " comprehension(\n" " target=Name(id='line', ctx=Store()),\n" -" iter=Name(id='file', ctx=Load()),\n" +" iter=Name(id='file'),\n" " is_async=0),\n" " comprehension(\n" " target=Name(id='c', ctx=Store()),\n" -" iter=Name(id='line', ctx=Load()),\n" +" iter=Name(id='line'),\n" " is_async=0)]))\n" "\n" ">>> print(ast.dump(ast.parse('(n**2 for n in it if n>5 if n<10)', " @@ -1777,22 +1779,22 @@ msgid "" "Expression(\n" " body=GeneratorExp(\n" " elt=BinOp(\n" -" left=Name(id='n', ctx=Load()),\n" +" left=Name(id='n'),\n" " op=Pow(),\n" " right=Constant(value=2)),\n" " generators=[\n" " comprehension(\n" " target=Name(id='n', ctx=Store()),\n" -" iter=Name(id='it', ctx=Load()),\n" +" iter=Name(id='it'),\n" " ifs=[\n" " Compare(\n" -" left=Name(id='n', ctx=Load()),\n" +" left=Name(id='n'),\n" " ops=[\n" " Gt()],\n" " comparators=[\n" " Constant(value=5)]),\n" " Compare(\n" -" left=Name(id='n', ctx=Load()),\n" +" left=Name(id='n'),\n" " ops=[\n" " Lt()],\n" " comparators=[\n" @@ -1803,11 +1805,11 @@ msgid "" "... indent=4)) # Async comprehension\n" "Expression(\n" " body=ListComp(\n" -" elt=Name(id='i', ctx=Load()),\n" +" elt=Name(id='i'),\n" " generators=[\n" " comprehension(\n" " target=Name(id='i', ctx=Store()),\n" -" iter=Name(id='soc', ctx=Load()),\n" +" iter=Name(id='soc'),\n" " is_async=1)]))" msgstr "" ">>> print(ast.dump(ast.parse('[ord(c) for line in file for c in line]', " @@ -1816,17 +1818,17 @@ msgstr "" "Expression(\n" " body=ListComp(\n" " elt=Call(\n" -" func=Name(id='ord', ctx=Load()),\n" +" func=Name(id='ord'),\n" " args=[\n" -" Name(id='c', ctx=Load())]),\n" +" Name(id='c')]),\n" " generators=[\n" " comprehension(\n" " target=Name(id='line', ctx=Store()),\n" -" iter=Name(id='file', ctx=Load()),\n" +" iter=Name(id='file'),\n" " is_async=0),\n" " comprehension(\n" " target=Name(id='c', ctx=Store()),\n" -" iter=Name(id='line', ctx=Load()),\n" +" iter=Name(id='line'),\n" " is_async=0)]))\n" "\n" ">>> print(ast.dump(ast.parse('(n**2 for n in it if n>5 if n<10)', " @@ -1835,22 +1837,22 @@ msgstr "" "Expression(\n" " body=GeneratorExp(\n" " elt=BinOp(\n" -" left=Name(id='n', ctx=Load()),\n" +" left=Name(id='n'),\n" " op=Pow(),\n" " right=Constant(value=2)),\n" " generators=[\n" " comprehension(\n" " target=Name(id='n', ctx=Store()),\n" -" iter=Name(id='it', ctx=Load()),\n" +" iter=Name(id='it'),\n" " ifs=[\n" " Compare(\n" -" left=Name(id='n', ctx=Load()),\n" +" left=Name(id='n'),\n" " ops=[\n" " Gt()],\n" " comparators=[\n" " Constant(value=5)]),\n" " Compare(\n" -" left=Name(id='n', ctx=Load()),\n" +" left=Name(id='n'),\n" " ops=[\n" " Lt()],\n" " comparators=[\n" @@ -1861,24 +1863,24 @@ msgstr "" "... indent=4)) # Async comprehension\n" "Expression(\n" " body=ListComp(\n" -" elt=Name(id='i', ctx=Load()),\n" +" elt=Name(id='i'),\n" " generators=[\n" " comprehension(\n" " target=Name(id='i', ctx=Store()),\n" -" iter=Name(id='soc', ctx=Load()),\n" +" iter=Name(id='soc'),\n" " is_async=1)]))" -#: ../../library/ast.rst:929 +#: ../../library/ast.rst:932 msgid "Statements" msgstr "陳述式" -#: ../../library/ast.rst:933 +#: ../../library/ast.rst:936 msgid "" "An assignment. ``targets`` is a list of nodes, and ``value`` is a single " "node." msgstr "一個賦值。``targets`` 是節點串列,``value`` 是單個節點。" -#: ../../library/ast.rst:935 +#: ../../library/ast.rst:938 msgid "" "Multiple nodes in ``targets`` represents assigning the same value to each. " "Unpacking is represented by putting a :class:`Tuple` or :class:`List` within " @@ -1887,13 +1889,13 @@ msgstr "" "``targets`` 中的多個節點表示為每個節點分配相同的值。解包是透過在 ``targets`` " "中放置一個 :class:`Tuple` 或 :class:`List` 來表示的。" -#: ../../library/ast.rst:941 ../../library/ast.rst:1236 -#: ../../library/ast.rst:1430 ../../library/ast.rst:1996 +#: ../../library/ast.rst:944 ../../library/ast.rst:1242 +#: ../../library/ast.rst:1436 ../../library/ast.rst:1993 msgid "" "``type_comment`` is an optional string with the type annotation as a comment." msgstr "``type_comment`` 是一個可選字串,其中的註解為型別註釋。" -#: ../../library/ast.rst:943 +#: ../../library/ast.rst:946 msgid "" ">>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # Multiple assignment\n" "Module(\n" @@ -1914,7 +1916,7 @@ msgid "" " Name(id='a', ctx=Store()),\n" " Name(id='b', ctx=Store())],\n" " ctx=Store())],\n" -" value=Name(id='c', ctx=Load()))])" +" value=Name(id='c'))])" msgstr "" ">>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # Multiple assignment\n" "Module(\n" @@ -1935,9 +1937,9 @@ msgstr "" " Name(id='a', ctx=Store()),\n" " Name(id='b', ctx=Store())],\n" " ctx=Store())],\n" -" value=Name(id='c', ctx=Load()))])" +" value=Name(id='c'))])" -#: ../../library/ast.rst:969 +#: ../../library/ast.rst:972 msgid "" "An assignment with a type annotation. ``target`` is a single node and can be " "a :class:`Name`, an :class:`Attribute` or a :class:`Subscript`. " @@ -1948,7 +1950,7 @@ msgstr "" "`Attribute` 或 :class:`Subscript`。``annotation`` 是註釋,例如 :class:" "`Constant` 或 :class:`Name` 節點。``value`` 是單個可選節點。" -#: ../../library/ast.rst:974 +#: ../../library/ast.rst:977 msgid "" "``simple`` is always either 0 (indicating a \"complex\" target) or 1 " "(indicating a \"simple\" target). A \"simple\" target consists solely of a :" @@ -1961,14 +1963,14 @@ msgstr "" "被視為是複雜的。只有簡單目標會出現在模組和類別的 :attr:`~object." "__annotations__` 字典中。" -#: ../../library/ast.rst:980 +#: ../../library/ast.rst:983 msgid "" ">>> print(ast.dump(ast.parse('c: int'), indent=4))\n" "Module(\n" " body=[\n" " AnnAssign(\n" " target=Name(id='c', ctx=Store()),\n" -" annotation=Name(id='int', ctx=Load()),\n" +" annotation=Name(id='int'),\n" " simple=1)])\n" "\n" ">>> print(ast.dump(ast.parse('(a): int = 1'), indent=4)) # Annotation with " @@ -1977,7 +1979,7 @@ msgid "" " body=[\n" " AnnAssign(\n" " target=Name(id='a', ctx=Store()),\n" -" annotation=Name(id='int', ctx=Load()),\n" +" annotation=Name(id='int'),\n" " value=Constant(value=1),\n" " simple=0)])\n" "\n" @@ -1986,10 +1988,10 @@ msgid "" " body=[\n" " AnnAssign(\n" " target=Attribute(\n" -" value=Name(id='a', ctx=Load()),\n" +" value=Name(id='a'),\n" " attr='b',\n" " ctx=Store()),\n" -" annotation=Name(id='int', ctx=Load()),\n" +" annotation=Name(id='int'),\n" " simple=0)])\n" "\n" ">>> print(ast.dump(ast.parse('a[1]: int'), indent=4)) # Subscript " @@ -1998,10 +2000,10 @@ msgid "" " body=[\n" " AnnAssign(\n" " target=Subscript(\n" -" value=Name(id='a', ctx=Load()),\n" +" value=Name(id='a'),\n" " slice=Constant(value=1),\n" " ctx=Store()),\n" -" annotation=Name(id='int', ctx=Load()),\n" +" annotation=Name(id='int'),\n" " simple=0)])" msgstr "" ">>> print(ast.dump(ast.parse('c: int'), indent=4))\n" @@ -2009,7 +2011,7 @@ msgstr "" " body=[\n" " AnnAssign(\n" " target=Name(id='c', ctx=Store()),\n" -" annotation=Name(id='int', ctx=Load()),\n" +" annotation=Name(id='int'),\n" " simple=1)])\n" "\n" ">>> print(ast.dump(ast.parse('(a): int = 1'), indent=4)) # Annotation with " @@ -2018,7 +2020,7 @@ msgstr "" " body=[\n" " AnnAssign(\n" " target=Name(id='a', ctx=Store()),\n" -" annotation=Name(id='int', ctx=Load()),\n" +" annotation=Name(id='int'),\n" " value=Constant(value=1),\n" " simple=0)])\n" "\n" @@ -2027,10 +2029,10 @@ msgstr "" " body=[\n" " AnnAssign(\n" " target=Attribute(\n" -" value=Name(id='a', ctx=Load()),\n" +" value=Name(id='a'),\n" " attr='b',\n" " ctx=Store()),\n" -" annotation=Name(id='int', ctx=Load()),\n" +" annotation=Name(id='int'),\n" " simple=0)])\n" "\n" ">>> print(ast.dump(ast.parse('a[1]: int'), indent=4)) # Subscript " @@ -2039,13 +2041,13 @@ msgstr "" " body=[\n" " AnnAssign(\n" " target=Subscript(\n" -" value=Name(id='a', ctx=Load()),\n" +" value=Name(id='a'),\n" " slice=Constant(value=1),\n" " ctx=Store()),\n" -" annotation=Name(id='int', ctx=Load()),\n" +" annotation=Name(id='int'),\n" " simple=0)])" -#: ../../library/ast.rst:1024 +#: ../../library/ast.rst:1027 msgid "" "Augmented assignment, such as ``a += 1``. In the following example, " "``target`` is a :class:`Name` node for ``x`` (with the :class:`Store` " @@ -2056,7 +2058,7 @@ msgstr "" "是 ``x`` 的 :class:`Name` 節點(帶有 :class:`Store` 情境),``op`` 是 :class:" "`Add`,``value`` 是一個值為 1 的 :class:`Constant`。" -#: ../../library/ast.rst:1029 +#: ../../library/ast.rst:1032 msgid "" "The ``target`` attribute cannot be of class :class:`Tuple` or :class:`List`, " "unlike the targets of :class:`Assign`." @@ -2064,7 +2066,7 @@ msgstr "" "與 :class:`Assign` 的目標不同,``target`` 屬性不能屬於 :class:`Tuple` 或 :" "class:`List` 類別。" -#: ../../library/ast.rst:1032 +#: ../../library/ast.rst:1035 msgid "" ">>> print(ast.dump(ast.parse('x += 2'), indent=4))\n" "Module(\n" @@ -2082,7 +2084,7 @@ msgstr "" " op=Add(),\n" " value=Constant(value=2))])" -#: ../../library/ast.rst:1045 +#: ../../library/ast.rst:1048 msgid "" "A ``raise`` statement. ``exc`` is the exception object to be raised, " "normally a :class:`Call` or :class:`Name`, or ``None`` for a standalone " @@ -2092,23 +2094,23 @@ msgstr "" "class:`Name`,若是獨立的 ``raise`` 則為 ``None``。``cause`` 是 ``raise x " "from y`` 中的可選部分 ``y``。" -#: ../../library/ast.rst:1049 +#: ../../library/ast.rst:1052 msgid "" ">>> print(ast.dump(ast.parse('raise x from y'), indent=4))\n" "Module(\n" " body=[\n" " Raise(\n" -" exc=Name(id='x', ctx=Load()),\n" -" cause=Name(id='y', ctx=Load()))])" +" exc=Name(id='x'),\n" +" cause=Name(id='y'))])" msgstr "" ">>> print(ast.dump(ast.parse('raise x from y'), indent=4))\n" "Module(\n" " body=[\n" " Raise(\n" -" exc=Name(id='x', ctx=Load()),\n" -" cause=Name(id='y', ctx=Load()))])" +" exc=Name(id='x'),\n" +" cause=Name(id='y'))])" -#: ../../library/ast.rst:1061 +#: ../../library/ast.rst:1064 msgid "" "An assertion. ``test`` holds the condition, such as a :class:`Compare` node. " "``msg`` holds the failure message." @@ -2116,23 +2118,23 @@ msgstr "" "一個斷言 (assertion)。``test`` 保存條件,例如 :class:`Compare` 節點。``msg`` " "保存失敗訊息。" -#: ../../library/ast.rst:1064 +#: ../../library/ast.rst:1067 msgid "" ">>> print(ast.dump(ast.parse('assert x,y'), indent=4))\n" "Module(\n" " body=[\n" " Assert(\n" -" test=Name(id='x', ctx=Load()),\n" -" msg=Name(id='y', ctx=Load()))])" +" test=Name(id='x'),\n" +" msg=Name(id='y'))])" msgstr "" ">>> print(ast.dump(ast.parse('assert x,y'), indent=4))\n" "Module(\n" " body=[\n" " Assert(\n" -" test=Name(id='x', ctx=Load()),\n" -" msg=Name(id='y', ctx=Load()))])" +" test=Name(id='x'),\n" +" msg=Name(id='y'))])" -#: ../../library/ast.rst:1076 +#: ../../library/ast.rst:1079 msgid "" "Represents a ``del`` statement. ``targets`` is a list of nodes, such as :" "class:`Name`, :class:`Attribute` or :class:`Subscript` nodes." @@ -2140,7 +2142,7 @@ msgstr "" "代表一個 ``del`` 陳述式。``targets`` 是節點串列,例如 :class:`Name`、:class:" "`Attribute` 或 :class:`Subscript` 節點。" -#: ../../library/ast.rst:1079 +#: ../../library/ast.rst:1082 msgid "" ">>> print(ast.dump(ast.parse('del x,y,z'), indent=4))\n" "Module(\n" @@ -2160,11 +2162,11 @@ msgstr "" " Name(id='y', ctx=Del()),\n" " Name(id='z', ctx=Del())])])" -#: ../../library/ast.rst:1093 +#: ../../library/ast.rst:1096 msgid "A ``pass`` statement." msgstr "一個 ``pass`` 陳述式。" -#: ../../library/ast.rst:1095 +#: ../../library/ast.rst:1098 msgid "" ">>> print(ast.dump(ast.parse('pass'), indent=4))\n" "Module(\n" @@ -2176,7 +2178,7 @@ msgstr "" " body=[\n" " Pass()])" -#: ../../library/ast.rst:1105 +#: ../../library/ast.rst:1108 msgid "" "A :ref:`type alias ` created through the :keyword:`type` " "statement. ``name`` is the name of the alias, ``type_params`` is a list of :" @@ -2187,37 +2189,37 @@ msgstr "" "aliases>`。``name`` 是別名的名稱、``type_params`` 是\\ :ref:`型別參數 (type " "parameter) ` 的串列、``value`` 是型別別名的值。" -#: ../../library/ast.rst:1110 +#: ../../library/ast.rst:1113 msgid "" ">>> print(ast.dump(ast.parse('type Alias = int'), indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" -" value=Name(id='int', ctx=Load()))])" +" value=Name(id='int'))])" msgstr "" ">>> print(ast.dump(ast.parse('type Alias = int'), indent=4))\n" "Module(\n" " body=[\n" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" -" value=Name(id='int', ctx=Load()))])" +" value=Name(id='int'))])" -#: ../../library/ast.rst:1121 +#: ../../library/ast.rst:1124 msgid "" "Other statements which are only applicable inside functions or loops are " "described in other sections." msgstr "其他僅適用於函式或迴圈內部的陳述式將在其他部分中描述。" -#: ../../library/ast.rst:1125 +#: ../../library/ast.rst:1128 msgid "Imports" msgstr "引入 (imports)" -#: ../../library/ast.rst:1129 +#: ../../library/ast.rst:1132 msgid "An import statement. ``names`` is a list of :class:`alias` nodes." msgstr "一個 import 陳述式。``names`` 是 :class:`alias` 節點的串列。" -#: ../../library/ast.rst:1131 +#: ../../library/ast.rst:1134 msgid "" ">>> print(ast.dump(ast.parse('import x,y,z'), indent=4))\n" "Module(\n" @@ -2226,7 +2228,8 @@ msgid "" " names=[\n" " alias(name='x'),\n" " alias(name='y'),\n" -" alias(name='z')])])" +" alias(name='z')],\n" +" is_lazy=0)])" msgstr "" ">>> print(ast.dump(ast.parse('import x,y,z'), indent=4))\n" "Module(\n" @@ -2235,9 +2238,10 @@ msgstr "" " names=[\n" " alias(name='x'),\n" " alias(name='y'),\n" -" alias(name='z')])])" +" alias(name='z')],\n" +" is_lazy=0)])" -#: ../../library/ast.rst:1145 +#: ../../library/ast.rst:1149 msgid "" "Represents ``from x import y``. ``module`` is a raw string of the 'from' " "name, without any leading dots, or ``None`` for statements such as ``from . " @@ -2248,7 +2252,7 @@ msgstr "" "點 (dot),或者對於諸如 ``from . import foo`` 之類的陳述式則為 ``None``。" "``level`` 是一個整數,保存相對引入的級別(0 表示絕對引入)。" -#: ../../library/ast.rst:1150 +#: ../../library/ast.rst:1154 msgid "" ">>> print(ast.dump(ast.parse('from y import x,y,z'), indent=4))\n" "Module(\n" @@ -2259,7 +2263,8 @@ msgid "" " alias(name='x'),\n" " alias(name='y'),\n" " alias(name='z')],\n" -" level=0)])" +" level=0,\n" +" is_lazy=0)])" msgstr "" ">>> print(ast.dump(ast.parse('from y import x,y,z'), indent=4))\n" "Module(\n" @@ -2270,9 +2275,10 @@ msgstr "" " alias(name='x'),\n" " alias(name='y'),\n" " alias(name='z')],\n" -" level=0)])" +" level=0,\n" +" is_lazy=0)])" -#: ../../library/ast.rst:1166 +#: ../../library/ast.rst:1171 msgid "" "Both parameters are raw strings of the names. ``asname`` can be ``None`` if " "the regular name is to be used." @@ -2280,7 +2286,7 @@ msgstr "" "這兩個參數都是名稱的原始字串。如果要使用常規名稱,``asname`` 可以為 " "``None``。" -#: ../../library/ast.rst:1169 +#: ../../library/ast.rst:1174 msgid "" ">>> print(ast.dump(ast.parse('from ..foo.bar import a as b, c'), indent=4))\n" "Module(\n" @@ -2290,7 +2296,8 @@ msgid "" " names=[\n" " alias(name='a', asname='b'),\n" " alias(name='c')],\n" -" level=2)])" +" level=2,\n" +" is_lazy=0)])" msgstr "" ">>> print(ast.dump(ast.parse('from ..foo.bar import a as b, c'), indent=4))\n" "Module(\n" @@ -2300,19 +2307,20 @@ msgstr "" " names=[\n" " alias(name='a', asname='b'),\n" " alias(name='c')],\n" -" level=2)])" +" level=2,\n" +" is_lazy=0)])" -#: ../../library/ast.rst:1182 +#: ../../library/ast.rst:1188 msgid "Control flow" msgstr "流程控制" -#: ../../library/ast.rst:1185 +#: ../../library/ast.rst:1191 msgid "" "Optional clauses such as ``else`` are stored as an empty list if they're not " "present." msgstr "諸如 ``else`` 之類的可選子句如果不存在,則將被儲存為空串列。" -#: ../../library/ast.rst:1190 +#: ../../library/ast.rst:1196 msgid "" "An ``if`` statement. ``test`` holds a single node, such as a :class:" "`Compare` node. ``body`` and ``orelse`` each hold a list of nodes." @@ -2320,7 +2328,7 @@ msgstr "" "一個 ``if`` 陳述式。``test`` 保存單個節點,例如 :class:`Compare` 節點。" "``body`` 和 ``orelse`` 各自保存一個節點串列。" -#: ../../library/ast.rst:1193 +#: ../../library/ast.rst:1199 msgid "" "``elif`` clauses don't have a special representation in the AST, but rather " "appear as extra :class:`If` nodes within the ``orelse`` section of the " @@ -2329,7 +2337,7 @@ msgstr "" "``elif`` 子句在 AST 中沒有特殊表示,而是在前一個子句的 ``orelse`` 部分中作為" "額外的 :class:`If` 節點出現。" -#: ../../library/ast.rst:1197 +#: ../../library/ast.rst:1203 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... if x:\n" @@ -2342,13 +2350,13 @@ msgid "" "Module(\n" " body=[\n" " If(\n" -" test=Name(id='x', ctx=Load()),\n" +" test=Name(id='x'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))],\n" " orelse=[\n" " If(\n" -" test=Name(id='y', ctx=Load()),\n" +" test=Name(id='y'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))],\n" @@ -2367,13 +2375,13 @@ msgstr "" "Module(\n" " body=[\n" " If(\n" -" test=Name(id='x', ctx=Load()),\n" +" test=Name(id='x'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))],\n" " orelse=[\n" " If(\n" -" test=Name(id='y', ctx=Load()),\n" +" test=Name(id='y'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))],\n" @@ -2381,7 +2389,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1227 +#: ../../library/ast.rst:1233 msgid "" "A ``for`` loop. ``target`` holds the variable(s) the loop assigns to, as a " "single :class:`Name`, :class:`Tuple`, :class:`List`, :class:`Attribute` or :" @@ -2396,7 +2404,7 @@ msgstr "" "行的節點串列。如果迴圈正常完成,則執行 ``orelse`` 中的內容,而不是透過 " "``break`` 陳述式執行。" -#: ../../library/ast.rst:1238 +#: ../../library/ast.rst:1244 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... for x in y:\n" @@ -2408,7 +2416,7 @@ msgid "" " body=[\n" " For(\n" " target=Name(id='x', ctx=Store()),\n" -" iter=Name(id='y', ctx=Load()),\n" +" iter=Name(id='y'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))],\n" @@ -2426,7 +2434,7 @@ msgstr "" " body=[\n" " For(\n" " target=Name(id='x', ctx=Store()),\n" -" iter=Name(id='y', ctx=Load()),\n" +" iter=Name(id='y'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))],\n" @@ -2434,13 +2442,13 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1261 +#: ../../library/ast.rst:1267 msgid "" "A ``while`` loop. ``test`` holds the condition, such as a :class:`Compare` " "node." msgstr "一個 ``while`` 迴圈。``test`` 保存條件,例如 :class:`Compare` 節點。" -#: ../../library/ast.rst:1264 +#: ../../library/ast.rst:1270 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... while x:\n" @@ -2451,7 +2459,7 @@ msgid "" "Module(\n" " body=[\n" " While(\n" -" test=Name(id='x', ctx=Load()),\n" +" test=Name(id='x'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))],\n" @@ -2468,7 +2476,7 @@ msgstr "" "Module(\n" " body=[\n" " While(\n" -" test=Name(id='x', ctx=Load()),\n" +" test=Name(id='x'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))],\n" @@ -2476,11 +2484,11 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1287 +#: ../../library/ast.rst:1293 msgid "The ``break`` and ``continue`` statements." msgstr "``break`` 和 ``continue`` 陳述式。" -#: ../../library/ast.rst:1289 +#: ../../library/ast.rst:1295 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... for a in b:\n" @@ -2494,11 +2502,11 @@ msgid "" " body=[\n" " For(\n" " target=Name(id='a', ctx=Store()),\n" -" iter=Name(id='b', ctx=Load()),\n" +" iter=Name(id='b'),\n" " body=[\n" " If(\n" " test=Compare(\n" -" left=Name(id='a', ctx=Load()),\n" +" left=Name(id='a'),\n" " ops=[\n" " Gt()],\n" " comparators=[\n" @@ -2520,11 +2528,11 @@ msgstr "" " body=[\n" " For(\n" " target=Name(id='a', ctx=Store()),\n" -" iter=Name(id='b', ctx=Load()),\n" +" iter=Name(id='b'),\n" " body=[\n" " If(\n" " test=Compare(\n" -" left=Name(id='a', ctx=Load()),\n" +" left=Name(id='a'),\n" " ops=[\n" " Gt()],\n" " comparators=[\n" @@ -2534,7 +2542,7 @@ msgstr "" " orelse=[\n" " Continue()])])])" -#: ../../library/ast.rst:1320 +#: ../../library/ast.rst:1326 msgid "" "``try`` blocks. All attributes are list of nodes to execute, except for " "``handlers``, which is a list of :class:`ExceptHandler` nodes." @@ -2542,7 +2550,7 @@ msgstr "" "``try`` 區塊。除 ``handlers`` 是 :class:`ExceptHandler` 節點的串列外,其他所" "有屬性都是要執行之節點的串列。" -#: ../../library/ast.rst:1323 +#: ../../library/ast.rst:1329 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -2564,12 +2572,12 @@ msgid "" " value=Constant(value=Ellipsis))],\n" " handlers=[\n" " ExceptHandler(\n" -" type=Name(id='Exception', ctx=Load()),\n" +" type=Name(id='Exception'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))]),\n" " ExceptHandler(\n" -" type=Name(id='OtherException', ctx=Load()),\n" +" type=Name(id='OtherException'),\n" " name='e',\n" " body=[\n" " Expr(\n" @@ -2601,12 +2609,12 @@ msgstr "" " value=Constant(value=Ellipsis))],\n" " handlers=[\n" " ExceptHandler(\n" -" type=Name(id='Exception', ctx=Load()),\n" +" type=Name(id='Exception'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))]),\n" " ExceptHandler(\n" -" type=Name(id='OtherException', ctx=Load()),\n" +" type=Name(id='OtherException'),\n" " name='e',\n" " body=[\n" " Expr(\n" @@ -2618,7 +2626,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1365 +#: ../../library/ast.rst:1371 msgid "" "``try`` blocks which are followed by ``except*`` clauses. The attributes are " "the same as for :class:`Try` but the :class:`ExceptHandler` nodes in " @@ -2628,7 +2636,7 @@ msgstr "" "``handlers`` 中的 :class:`ExceptHandler` 節點被解讀為 ``except*`` 區塊而不是 " "``except``。" -#: ../../library/ast.rst:1369 +#: ../../library/ast.rst:1375 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -2644,7 +2652,7 @@ msgid "" " value=Constant(value=Ellipsis))],\n" " handlers=[\n" " ExceptHandler(\n" -" type=Name(id='Exception', ctx=Load()),\n" +" type=Name(id='Exception'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))])])])" @@ -2663,12 +2671,12 @@ msgstr "" " value=Constant(value=Ellipsis))],\n" " handlers=[\n" " ExceptHandler(\n" -" type=Name(id='Exception', ctx=Load()),\n" +" type=Name(id='Exception'),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1394 +#: ../../library/ast.rst:1400 msgid "" "A single ``except`` clause. ``type`` is the exception type it will match, " "typically a :class:`Name` node (or ``None`` for a catch-all ``except:`` " @@ -2680,7 +2688,7 @@ msgstr "" "``name`` 是用於保存例外的名稱之原始字串,如果子句沒有 ``as foo`` ,則為 " "``None``。``body`` 是節點串列。" -#: ../../library/ast.rst:1399 +#: ../../library/ast.rst:1405 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... try:\n" @@ -2694,12 +2702,12 @@ msgid "" " body=[\n" " Expr(\n" " value=BinOp(\n" -" left=Name(id='a', ctx=Load()),\n" +" left=Name(id='a'),\n" " op=Add(),\n" " right=Constant(value=1)))],\n" " handlers=[\n" " ExceptHandler(\n" -" type=Name(id='TypeError', ctx=Load()),\n" +" type=Name(id='TypeError'),\n" " body=[\n" " Pass()])])])" msgstr "" @@ -2715,16 +2723,16 @@ msgstr "" " body=[\n" " Expr(\n" " value=BinOp(\n" -" left=Name(id='a', ctx=Load()),\n" +" left=Name(id='a'),\n" " op=Add(),\n" " right=Constant(value=1)))],\n" " handlers=[\n" " ExceptHandler(\n" -" type=Name(id='TypeError', ctx=Load()),\n" +" type=Name(id='TypeError'),\n" " body=[\n" " Pass()])])])" -#: ../../library/ast.rst:1425 +#: ../../library/ast.rst:1431 msgid "" "A ``with`` block. ``items`` is a list of :class:`withitem` nodes " "representing the context managers, and ``body`` is the indented block inside " @@ -2733,7 +2741,7 @@ msgstr "" "一個 ``with`` 區塊。``items`` 是表示情境管理器的 :class:`withitem` 節點串列," "``body`` 是情境內的縮進區塊。" -#: ../../library/ast.rst:1435 +#: ../../library/ast.rst:1441 msgid "" "A single context manager in a ``with`` block. ``context_expr`` is the " "context manager, often a :class:`Call` node. ``optional_vars`` is a :class:" @@ -2744,7 +2752,7 @@ msgstr "" "class:`Call` 節點。``Optional_vars`` 是 ``as foo`` 部分的 :class:`Name`、:" "class:`Tuple` 或 :class:`List`,或者如果不使用則為 ``None`` 。" -#: ../../library/ast.rst:1440 +#: ../../library/ast.rst:1446 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... with a as b, c as d:\n" @@ -2755,18 +2763,18 @@ msgid "" " With(\n" " items=[\n" " withitem(\n" -" context_expr=Name(id='a', ctx=Load()),\n" +" context_expr=Name(id='a'),\n" " optional_vars=Name(id='b', ctx=Store())),\n" " withitem(\n" -" context_expr=Name(id='c', ctx=Load()),\n" +" context_expr=Name(id='c'),\n" " optional_vars=Name(id='d', ctx=Store()))],\n" " body=[\n" " Expr(\n" " value=Call(\n" -" func=Name(id='something', ctx=Load()),\n" +" func=Name(id='something'),\n" " args=[\n" -" Name(id='b', ctx=Load()),\n" -" Name(id='d', ctx=Load())]))])])" +" Name(id='b'),\n" +" Name(id='d')]))])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... with a as b, c as d:\n" @@ -2777,24 +2785,24 @@ msgstr "" " With(\n" " items=[\n" " withitem(\n" -" context_expr=Name(id='a', ctx=Load()),\n" +" context_expr=Name(id='a'),\n" " optional_vars=Name(id='b', ctx=Store())),\n" " withitem(\n" -" context_expr=Name(id='c', ctx=Load()),\n" +" context_expr=Name(id='c'),\n" " optional_vars=Name(id='d', ctx=Store()))],\n" " body=[\n" " Expr(\n" " value=Call(\n" -" func=Name(id='something', ctx=Load()),\n" +" func=Name(id='something'),\n" " args=[\n" -" Name(id='b', ctx=Load()),\n" -" Name(id='d', ctx=Load())]))])])" +" Name(id='b'),\n" +" Name(id='d')]))])])" -#: ../../library/ast.rst:1466 +#: ../../library/ast.rst:1472 msgid "Pattern matching" msgstr "模式匹配 (pattern matching)" -#: ../../library/ast.rst:1471 +#: ../../library/ast.rst:1477 msgid "" "A ``match`` statement. ``subject`` holds the subject of the match (the " "object that is being matched against the cases) and ``cases`` contains an " @@ -2803,7 +2811,7 @@ msgstr "" "一個 ``match`` 陳述式。``subject`` 保存匹配的主題(與案例匹配的物件)," "``cases`` 包含具有不同案例的 :class:`match_case` 節點的可疊代物件。" -#: ../../library/ast.rst:1479 +#: ../../library/ast.rst:1485 msgid "" "A single case pattern in a ``match`` statement. ``pattern`` contains the " "match pattern that the subject will be matched against. Note that the :class:" @@ -2814,13 +2822,13 @@ msgstr "" "請注意,為模式生成的 :class:`AST` 節點與為運算式生成的節點不同,即使它們共享" "相同的語法。" -#: ../../library/ast.rst:1484 +#: ../../library/ast.rst:1490 msgid "" "The ``guard`` attribute contains an expression that will be evaluated if the " "pattern matches the subject." msgstr "``guard`` 屬性包含一個運算式,如果模式與主題匹配,則將對該運算式求值。" -#: ../../library/ast.rst:1487 +#: ../../library/ast.rst:1493 msgid "" "``body`` contains a list of nodes to execute if the pattern matches and the " "result of evaluating the guard expression is true." @@ -2828,7 +2836,7 @@ msgstr "" "``body`` 包含一個節點串列,如果模式匹配並且為防護運算式 (guard expression) 的" "求值 (evaluate) 結果為真,則會執行該節點串列。" -#: ../../library/ast.rst:1490 +#: ../../library/ast.rst:1496 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2840,14 +2848,14 @@ msgid "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchSequence(\n" " patterns=[\n" " MatchAs(name='x')]),\n" " guard=Compare(\n" -" left=Name(id='x', ctx=Load()),\n" +" left=Name(id='x'),\n" " ops=[\n" " Gt()],\n" " comparators=[\n" @@ -2857,7 +2865,7 @@ msgid "" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" " pattern=MatchClass(\n" -" cls=Name(id='tuple', ctx=Load())),\n" +" cls=Name(id='tuple')),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))])])])" @@ -2872,14 +2880,14 @@ msgstr "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchSequence(\n" " patterns=[\n" " MatchAs(name='x')]),\n" " guard=Compare(\n" -" left=Name(id='x', ctx=Load()),\n" +" left=Name(id='x'),\n" " ops=[\n" " Gt()],\n" " comparators=[\n" @@ -2889,12 +2897,12 @@ msgstr "" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" " pattern=MatchClass(\n" -" cls=Name(id='tuple', ctx=Load())),\n" +" cls=Name(id='tuple')),\n" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1528 +#: ../../library/ast.rst:1534 msgid "" "A match literal or value pattern that compares by equality. ``value`` is an " "expression node. Permitted value nodes are restricted as described in the " @@ -2904,7 +2912,7 @@ msgstr "" "以相等性進行比較的匹配文本或值的模式。``value`` 是一個運算式節點。允許值節點" "受到匹配陳述式文件中所述的限制。如果匹配主題等於求出值,則此模式成功。" -#: ../../library/ast.rst:1533 +#: ../../library/ast.rst:1539 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2914,7 +2922,7 @@ msgid "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchValue(\n" @@ -2931,7 +2939,7 @@ msgstr "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchValue(\n" @@ -2940,7 +2948,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1556 +#: ../../library/ast.rst:1562 msgid "" "A match literal pattern that compares by identity. ``value`` is the " "singleton to be compared against: ``None``, ``True``, or ``False``. This " @@ -2950,7 +2958,7 @@ msgstr "" "``True`` 或 ``False`` 進行比較的單例 (singleton)。如果匹配主題是給定的常數," "則此模式成功。" -#: ../../library/ast.rst:1560 +#: ../../library/ast.rst:1566 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2960,7 +2968,7 @@ msgid "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchSingleton(value=None),\n" @@ -2976,7 +2984,7 @@ msgstr "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchSingleton(value=None),\n" @@ -2984,7 +2992,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1582 +#: ../../library/ast.rst:1588 msgid "" "A match sequence pattern. ``patterns`` contains the patterns to be matched " "against the subject elements if the subject is a sequence. Matches a " @@ -2994,7 +3002,7 @@ msgstr "" "匹配序列模式。如果主題是一個序列,``patterns`` 包含與主題元素匹配的模式。如果" "子模式之一是 ``MatchStar`` 節點,則匹配可變長度序列,否則匹配固定長度序列。" -#: ../../library/ast.rst:1587 +#: ../../library/ast.rst:1593 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3004,7 +3012,7 @@ msgid "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchSequence(\n" @@ -3025,7 +3033,7 @@ msgstr "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchSequence(\n" @@ -3038,7 +3046,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1614 +#: ../../library/ast.rst:1620 msgid "" "Matches the rest of the sequence in a variable length match sequence " "pattern. If ``name`` is not ``None``, a list containing the remaining " @@ -3048,7 +3056,7 @@ msgstr "" "以可變長度匹配序列模式匹配序列的其餘部分。如果 ``name`` 不是 ``None``,則如果" "整體序列模式成功,則包含其餘序列元素的串列將綁定到該名稱。" -#: ../../library/ast.rst:1618 +#: ../../library/ast.rst:1624 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3060,7 +3068,7 @@ msgid "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchSequence(\n" @@ -3091,7 +3099,7 @@ msgstr "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchSequence(\n" @@ -3112,7 +3120,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1655 +#: ../../library/ast.rst:1661 msgid "" "A match mapping pattern. ``keys`` is a sequence of expression nodes. " "``patterns`` is a corresponding sequence of pattern nodes. ``rest`` is an " @@ -3124,7 +3132,7 @@ msgstr "" "列。``rest`` 是一個可選名稱,可以指定它來捕獲剩餘的對映元素。允許的鍵運算式受" "到匹配陳述式文件中所述的限制。" -#: ../../library/ast.rst:1661 +#: ../../library/ast.rst:1667 msgid "" "This pattern succeeds if the subject is a mapping, all evaluated key " "expressions are present in the mapping, and the value corresponding to each " @@ -3136,7 +3144,7 @@ msgstr "" "應的子模式匹配,則此模式成功。如果 ``rest`` 不是 ``None``,則如果整體對映模式" "成功,則包含其餘對映元素的字典將綁定到該名稱。" -#: ../../library/ast.rst:1667 +#: ../../library/ast.rst:1673 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3148,7 +3156,7 @@ msgid "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchMapping(\n" @@ -3177,7 +3185,7 @@ msgstr "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchMapping(\n" @@ -3196,7 +3204,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1702 +#: ../../library/ast.rst:1708 msgid "" "A match class pattern. ``cls`` is an expression giving the nominal class to " "be matched. ``patterns`` is a sequence of pattern nodes to be matched " @@ -3211,7 +3219,7 @@ msgstr "" "``kwd_attrs`` 是要匹配的附加屬性序列(在類別模式中指定為關鍵字引數)," "``kwd_patterns`` 是相應的模式(在類別模式中指定為關鍵字的值)。" -#: ../../library/ast.rst:1709 +#: ../../library/ast.rst:1715 msgid "" "This pattern succeeds if the subject is an instance of the nominated class, " "all positional patterns match the corresponding class-defined attributes, " @@ -3220,7 +3228,7 @@ msgstr "" "如果主題是指定類別的實例,所有位置模式都與相應的類別定義屬性匹配,並且任何指" "定的關鍵字屬性與其相應模式匹配,則此模式成功。" -#: ../../library/ast.rst:1713 +#: ../../library/ast.rst:1719 msgid "" "Note: classes may define a property that returns self in order to match a " "pattern node against the instance being matched. Several builtin types are " @@ -3229,7 +3237,7 @@ msgstr "" "注意:類別可以定義一個回傳 self 的特性 (property),以便將模式節點與正在匹配的" "實例進行匹配。一些內建型別也以這種方式匹配,如同匹配陳述式文件中所述。" -#: ../../library/ast.rst:1717 +#: ../../library/ast.rst:1723 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3241,11 +3249,11 @@ msgid "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchClass(\n" -" cls=Name(id='Point2D', ctx=Load()),\n" +" cls=Name(id='Point2D'),\n" " patterns=[\n" " MatchValue(\n" " value=Constant(value=0)),\n" @@ -3256,7 +3264,7 @@ msgid "" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" " pattern=MatchClass(\n" -" cls=Name(id='Point3D', ctx=Load()),\n" +" cls=Name(id='Point3D'),\n" " kwd_attrs=[\n" " 'x',\n" " 'y',\n" @@ -3282,11 +3290,11 @@ msgstr "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchClass(\n" -" cls=Name(id='Point2D', ctx=Load()),\n" +" cls=Name(id='Point2D'),\n" " patterns=[\n" " MatchValue(\n" " value=Constant(value=0)),\n" @@ -3297,7 +3305,7 @@ msgstr "" " value=Constant(value=Ellipsis))]),\n" " match_case(\n" " pattern=MatchClass(\n" -" cls=Name(id='Point3D', ctx=Load()),\n" +" cls=Name(id='Point3D'),\n" " kwd_attrs=[\n" " 'x',\n" " 'y',\n" @@ -3313,7 +3321,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1764 +#: ../../library/ast.rst:1770 msgid "" "A match \"as-pattern\", capture pattern or wildcard pattern. ``pattern`` " "contains the match pattern that the subject will be matched against. If the " @@ -3324,7 +3332,7 @@ msgstr "" "(wildcard pattern)。``pattern`` 包含主題將與之匹配的匹配模式。如果模式為 " "``None``,則該節點代表捕獲模式(即裸名 (bare name))並且始終會成功。" -#: ../../library/ast.rst:1769 +#: ../../library/ast.rst:1775 msgid "" "The ``name`` attribute contains the name that will be bound if the pattern " "is successful. If ``name`` is ``None``, ``pattern`` must also be ``None`` " @@ -3333,7 +3341,7 @@ msgstr "" "``name`` 屬性包含模式成功時將綁定的名稱。如果 ``name`` 為 ``None``,則 " "``pattern`` 也必須為 ``None``,並且節點代表通配模式。" -#: ../../library/ast.rst:1773 +#: ../../library/ast.rst:1779 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3345,7 +3353,7 @@ msgid "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchAs(\n" @@ -3372,7 +3380,7 @@ msgstr "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchAs(\n" @@ -3389,7 +3397,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1806 +#: ../../library/ast.rst:1812 msgid "" "A match \"or-pattern\". An or-pattern matches each of its subpatterns in " "turn to the subject, until one succeeds. The or-pattern is then deemed to " @@ -3401,7 +3409,7 @@ msgstr "" "到成功為止,然後 or 模式就會被認為是成功的。如果沒有一個子模式成功,則 or 模" "式將失敗。 ``patterns`` 屬性包含將與主題進行匹配的匹配模式節點串列。" -#: ../../library/ast.rst:1812 +#: ../../library/ast.rst:1818 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3411,7 +3419,7 @@ msgid "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchOr(\n" @@ -3432,7 +3440,7 @@ msgstr "" "Module(\n" " body=[\n" " Match(\n" -" subject=Name(id='x', ctx=Load()),\n" +" subject=Name(id='x'),\n" " cases=[\n" " match_case(\n" " pattern=MatchOr(\n" @@ -3445,11 +3453,11 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1839 +#: ../../library/ast.rst:1845 msgid "Type annotations" msgstr "型別註釋" -#: ../../library/ast.rst:1843 +#: ../../library/ast.rst:1849 msgid "" "A ``# type: ignore`` comment located at *lineno*. *tag* is the optional tag " "specified by the form ``# type: ignore ``." @@ -3457,7 +3465,7 @@ msgstr "" "位於 *lineno* 的 ``# type: ignore`` 註解。*tag* 是以 ``# type: ignore " "`` 形式指定的可選標籤。" -#: ../../library/ast.rst:1846 +#: ../../library/ast.rst:1852 msgid "" ">>> print(ast.dump(ast.parse('x = 1 # type: ignore', type_comments=True), " "indent=4))\n" @@ -3475,7 +3483,7 @@ msgid "" " body=[\n" " AnnAssign(\n" " target=Name(id='x', ctx=Store()),\n" -" annotation=Name(id='bool', ctx=Load()),\n" +" annotation=Name(id='bool'),\n" " value=Constant(value=1),\n" " simple=1)],\n" " type_ignores=[\n" @@ -3497,13 +3505,13 @@ msgstr "" " body=[\n" " AnnAssign(\n" " target=Name(id='x', ctx=Store()),\n" -" annotation=Name(id='bool', ctx=Load()),\n" +" annotation=Name(id='bool'),\n" " value=Constant(value=1),\n" " simple=1)],\n" " type_ignores=[\n" " TypeIgnore(lineno=1, tag='[assignment]')])" -#: ../../library/ast.rst:1869 +#: ../../library/ast.rst:1875 msgid "" ":class:`!TypeIgnore` nodes are not generated when the *type_comments* " "parameter is set to ``False`` (default). See :func:`ast.parse` for more " @@ -3512,17 +3520,17 @@ msgstr "" "當 *type_comments* 參數設為 ``False``\\ (預設值)時,不會產生 :class:`!" "TypeIgnore` 節點。更多細節請參閱 :func:`ast.parse`。" -#: ../../library/ast.rst:1877 +#: ../../library/ast.rst:1883 msgid "Type parameters" msgstr "型別參數 (type parameters)" -#: ../../library/ast.rst:1879 +#: ../../library/ast.rst:1885 msgid "" ":ref:`Type parameters ` can exist on classes, functions, and " "type aliases." msgstr ":ref:`型別參數 `\\ 可以存在於類別、函式和型別別名上。" -#: ../../library/ast.rst:1884 +#: ../../library/ast.rst:1890 msgid "" "A :class:`typing.TypeVar`. ``name`` is the name of the type variable. " "``bound`` is the bound or constraints, if any. If ``bound`` is a :class:" @@ -3535,7 +3543,7 @@ msgstr "" "`Tuple`,它代表約束;否則它代表界限。``default_value`` 為預設值;如果 :class:" "`!TypeVar` 沒有預設值,那此屬性會被設為 ``None``。" -#: ../../library/ast.rst:1890 +#: ../../library/ast.rst:1896 msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[T: int = bool] = list[T]\"), " "indent=4))\n" @@ -3546,12 +3554,11 @@ msgid "" " type_params=[\n" " TypeVar(\n" " name='T',\n" -" bound=Name(id='int', ctx=Load()),\n" -" default_value=Name(id='bool', ctx=Load()))],\n" +" bound=Name(id='int'),\n" +" default_value=Name(id='bool'))],\n" " value=Subscript(\n" -" value=Name(id='list', ctx=Load()),\n" -" slice=Name(id='T', ctx=Load()),\n" -" ctx=Load()))])" +" value=Name(id='list'),\n" +" slice=Name(id='T')))])" msgstr "" ">>> print(ast.dump(ast.parse(\"type Alias[T: int = bool] = list[T]\"), " "indent=4))\n" @@ -3562,19 +3569,18 @@ msgstr "" " type_params=[\n" " TypeVar(\n" " name='T',\n" -" bound=Name(id='int', ctx=Load()),\n" -" default_value=Name(id='bool', ctx=Load()))],\n" +" bound=Name(id='int'),\n" +" default_value=Name(id='bool'))],\n" " value=Subscript(\n" -" value=Name(id='list', ctx=Load()),\n" -" slice=Name(id='T', ctx=Load()),\n" -" ctx=Load()))])" +" value=Name(id='list'),\n" +" slice=Name(id='T')))])" -#: ../../library/ast.rst:1909 ../../library/ast.rst:1944 -#: ../../library/ast.rst:1976 +#: ../../library/ast.rst:1914 ../../library/ast.rst:1946 +#: ../../library/ast.rst:1973 msgid "Added the *default_value* parameter." msgstr "新增 *default_value* 參數。" -#: ../../library/ast.rst:1914 +#: ../../library/ast.rst:1919 msgid "" "A :class:`typing.ParamSpec`. ``name`` is the name of the parameter " "specification. ``default_value`` is the default value; if the :class:`!" @@ -3583,7 +3589,7 @@ msgstr "" "一個 :class:`typing.ParamSpec`。``name`` 是參數規範的名稱。``default_value`` " "是預設值;如果 :class:`!ParamSpec` 沒有預設值,則該屬性將設定為 ``None``。" -#: ../../library/ast.rst:1918 +#: ../../library/ast.rst:1923 msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[**P = [int, str]] = Callable[P, " "int]\"), indent=4))\n" @@ -3596,17 +3602,14 @@ msgid "" " name='P',\n" " default_value=List(\n" " elts=[\n" -" Name(id='int', ctx=Load()),\n" -" Name(id='str', ctx=Load())],\n" -" ctx=Load()))],\n" +" Name(id='int'),\n" +" Name(id='str')]))],\n" " value=Subscript(\n" -" value=Name(id='Callable', ctx=Load()),\n" +" value=Name(id='Callable'),\n" " slice=Tuple(\n" " elts=[\n" -" Name(id='P', ctx=Load()),\n" -" Name(id='int', ctx=Load())],\n" -" ctx=Load()),\n" -" ctx=Load()))])" +" Name(id='P'),\n" +" Name(id='int')])))])" msgstr "" ">>> print(ast.dump(ast.parse(\"type Alias[**P = [int, str]] = Callable[P, " "int]\"), indent=4))\n" @@ -3619,19 +3622,16 @@ msgstr "" " name='P',\n" " default_value=List(\n" " elts=[\n" -" Name(id='int', ctx=Load()),\n" -" Name(id='str', ctx=Load())],\n" -" ctx=Load()))],\n" +" Name(id='int'),\n" +" Name(id='str')]))],\n" " value=Subscript(\n" -" value=Name(id='Callable', ctx=Load()),\n" +" value=Name(id='Callable'),\n" " slice=Tuple(\n" " elts=[\n" -" Name(id='P', ctx=Load()),\n" -" Name(id='int', ctx=Load())],\n" -" ctx=Load()),\n" -" ctx=Load()))])" +" Name(id='P'),\n" +" Name(id='int')])))])" -#: ../../library/ast.rst:1949 +#: ../../library/ast.rst:1951 msgid "" "A :class:`typing.TypeVarTuple`. ``name`` is the name of the type variable " "tuple. ``default_value`` is the default value; if the :class:`!TypeVarTuple` " @@ -3641,7 +3641,7 @@ msgstr "" "``default_value`` 為預設值;如果 :class:`!TypeVarTuple` 沒有預設值,那此屬性" "會被設為 ``None``。" -#: ../../library/ast.rst:1953 +#: ../../library/ast.rst:1955 msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[*Ts = ()] = tuple[*Ts]\"), " "indent=4))\n" @@ -3650,18 +3650,13 @@ msgid "" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" " type_params=[\n" -" TypeVarTuple(\n" -" name='Ts',\n" -" default_value=Tuple(ctx=Load()))],\n" +" TypeVarTuple(name='Ts', default_value=Tuple())],\n" " value=Subscript(\n" -" value=Name(id='tuple', ctx=Load()),\n" +" value=Name(id='tuple'),\n" " slice=Tuple(\n" " elts=[\n" " Starred(\n" -" value=Name(id='Ts', ctx=Load()),\n" -" ctx=Load())],\n" -" ctx=Load()),\n" -" ctx=Load()))])" +" value=Name(id='Ts'))])))])" msgstr "" ">>> print(ast.dump(ast.parse(\"type Alias[*Ts = ()] = tuple[*Ts]\"), " "indent=4))\n" @@ -3670,40 +3665,35 @@ msgstr "" " TypeAlias(\n" " name=Name(id='Alias', ctx=Store()),\n" " type_params=[\n" -" TypeVarTuple(\n" -" name='Ts',\n" -" default_value=Tuple(ctx=Load()))],\n" +" TypeVarTuple(name='Ts', default_value=Tuple())],\n" " value=Subscript(\n" -" value=Name(id='tuple', ctx=Load()),\n" +" value=Name(id='tuple'),\n" " slice=Tuple(\n" " elts=[\n" " Starred(\n" -" value=Name(id='Ts', ctx=Load()),\n" -" ctx=Load())],\n" -" ctx=Load()),\n" -" ctx=Load()))])" +" value=Name(id='Ts'))])))])" -#: ../../library/ast.rst:1980 +#: ../../library/ast.rst:1977 msgid "Function and class definitions" msgstr "函式和類別定義" -#: ../../library/ast.rst:1984 +#: ../../library/ast.rst:1981 msgid "A function definition." msgstr "一個函式定義。" -#: ../../library/ast.rst:1986 +#: ../../library/ast.rst:1983 msgid "``name`` is a raw string of the function name." msgstr "``name`` 是函式名稱的原始字串。" -#: ../../library/ast.rst:1987 +#: ../../library/ast.rst:1984 msgid "``args`` is an :class:`arguments` node." msgstr "``args`` 是一個 :class:`arguments` 節點。" -#: ../../library/ast.rst:1988 +#: ../../library/ast.rst:1985 msgid "``body`` is the list of nodes inside the function." msgstr "``body`` 是函式內節點的串列。" -#: ../../library/ast.rst:1989 +#: ../../library/ast.rst:1986 msgid "" "``decorator_list`` is the list of decorators to be applied, stored outermost " "first (i.e. the first in the list will be applied last)." @@ -3711,20 +3701,20 @@ msgstr "" "``decorator_list`` 是要應用的裝飾器串列,在最外層者會被儲存在首位(即串列中首" "位將會是最後一個被應用的那個)。" -#: ../../library/ast.rst:1991 +#: ../../library/ast.rst:1988 msgid "``returns`` is the return annotation." msgstr "``returns`` 是回傳註釋。" -#: ../../library/ast.rst:1992 ../../library/ast.rst:2155 +#: ../../library/ast.rst:1989 ../../library/ast.rst:2152 msgid "``type_params`` is a list of :ref:`type parameters `." msgstr "``type_params`` 是\\ :ref:`型別參數 `\\ 的串列。" -#: ../../library/ast.rst:1998 ../../library/ast.rst:2182 -#: ../../library/ast.rst:2193 +#: ../../library/ast.rst:1995 ../../library/ast.rst:2179 +#: ../../library/ast.rst:2190 msgid "Added ``type_params``." msgstr "新增了 ``type_params``。" -#: ../../library/ast.rst:2004 +#: ../../library/ast.rst:2001 msgid "" "``lambda`` is a minimal function definition that can be used inside an " "expression. Unlike :class:`FunctionDef`, ``body`` holds a single node." @@ -3732,7 +3722,7 @@ msgstr "" "``lambda`` 是可以在運算式內使用的最小函式定義。與 :class:`FunctionDef` 不同," "``body`` 保存單個節點。" -#: ../../library/ast.rst:2007 +#: ../../library/ast.rst:2004 msgid "" ">>> print(ast.dump(ast.parse('lambda x,y: ...'), indent=4))\n" "Module(\n" @@ -3756,17 +3746,17 @@ msgstr "" " arg(arg='y')]),\n" " body=Constant(value=Ellipsis)))])" -#: ../../library/ast.rst:2023 +#: ../../library/ast.rst:2020 msgid "The arguments for a function." msgstr "函式的引數。" -#: ../../library/ast.rst:2025 +#: ../../library/ast.rst:2022 msgid "" "``posonlyargs``, ``args`` and ``kwonlyargs`` are lists of :class:`arg` nodes." msgstr "" "``posonlyargs``、``args`` 和 ``kwonlyargs`` 是 :class:`arg` 節點的串列。" -#: ../../library/ast.rst:2026 +#: ../../library/ast.rst:2023 msgid "" "``vararg`` and ``kwarg`` are single :class:`arg` nodes, referring to the " "``*args, **kwargs`` parameters." @@ -3774,7 +3764,7 @@ msgstr "" "``vararg`` 和 ``kwarg`` 是單個 :class:`arg` 節點,指的是 ``*args, **kwargs`` " "參數。" -#: ../../library/ast.rst:2028 +#: ../../library/ast.rst:2025 msgid "" "``kw_defaults`` is a list of default values for keyword-only arguments. If " "one is ``None``, the corresponding argument is required." @@ -3782,7 +3772,7 @@ msgstr "" "``kw_defaults`` 是僅限關鍵字引數的預設值串列。如果其中某個為 ``None``,則相應" "參數就會是必要的。" -#: ../../library/ast.rst:2030 +#: ../../library/ast.rst:2027 msgid "" "``defaults`` is a list of default values for arguments that can be passed " "positionally. If there are fewer defaults, they correspond to the last n " @@ -3791,7 +3781,7 @@ msgstr "" "``defaults`` 是可以按位置傳遞的引數的預設值串列。如果預設值較少,則它們對應於" "最後 n 個引數。" -#: ../../library/ast.rst:2037 +#: ../../library/ast.rst:2034 msgid "" "A single argument in a list. ``arg`` is a raw string of the argument name; " "``annotation`` is its annotation, such as a :class:`Name` node." @@ -3799,12 +3789,12 @@ msgstr "" "串列中的單個引數。``arg`` 是引數名稱的原始字串,``annotation`` 是它的註釋,例" "如 :class:`Name` 節點。" -#: ../../library/ast.rst:2042 +#: ../../library/ast.rst:2039 msgid "" "``type_comment`` is an optional string with the type annotation as a comment" msgstr "``type_comment`` 是一個可選字串,其註解為型別註釋" -#: ../../library/ast.rst:2044 +#: ../../library/ast.rst:2041 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -3838,8 +3828,8 @@ msgid "" " body=[\n" " Pass()],\n" " decorator_list=[\n" -" Name(id='decorator1', ctx=Load()),\n" -" Name(id='decorator2', ctx=Load())],\n" +" Name(id='decorator1'),\n" +" Name(id='decorator2')],\n" " returns=Constant(value='return annotation'))])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" @@ -3874,15 +3864,15 @@ msgstr "" " body=[\n" " Pass()],\n" " decorator_list=[\n" -" Name(id='decorator1', ctx=Load()),\n" -" Name(id='decorator2', ctx=Load())],\n" +" Name(id='decorator1'),\n" +" Name(id='decorator2')],\n" " returns=Constant(value='return annotation'))])" -#: ../../library/ast.rst:2084 +#: ../../library/ast.rst:2081 msgid "A ``return`` statement." msgstr "一個 ``return`` 陳述式。" -#: ../../library/ast.rst:2086 +#: ../../library/ast.rst:2083 msgid "" ">>> print(ast.dump(ast.parse('return 4'), indent=4))\n" "Module(\n" @@ -3896,7 +3886,7 @@ msgstr "" " Return(\n" " value=Constant(value=4))])" -#: ../../library/ast.rst:2098 +#: ../../library/ast.rst:2095 msgid "" "A ``yield`` or ``yield from`` expression. Because these are expressions, " "they must be wrapped in an :class:`Expr` node if the value sent back is not " @@ -3905,42 +3895,42 @@ msgstr "" "一個 ``yield`` 或 ``yield from`` 運算式。因為這些是運算式,所以如果不使用發送" "回來的值,則必須將它們包裝在 :class:`Expr` 節點中。" -#: ../../library/ast.rst:2101 +#: ../../library/ast.rst:2098 msgid "" ">>> print(ast.dump(ast.parse('yield x'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" " value=Yield(\n" -" value=Name(id='x', ctx=Load())))])\n" +" value=Name(id='x')))])\n" "\n" ">>> print(ast.dump(ast.parse('yield from x'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" " value=YieldFrom(\n" -" value=Name(id='x', ctx=Load())))])" +" value=Name(id='x')))])" msgstr "" ">>> print(ast.dump(ast.parse('yield x'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" " value=Yield(\n" -" value=Name(id='x', ctx=Load())))])\n" +" value=Name(id='x')))])\n" "\n" ">>> print(ast.dump(ast.parse('yield from x'), indent=4))\n" "Module(\n" " body=[\n" " Expr(\n" " value=YieldFrom(\n" -" value=Name(id='x', ctx=Load())))])" +" value=Name(id='x')))])" -#: ../../library/ast.rst:2121 +#: ../../library/ast.rst:2118 msgid "" "``global`` and ``nonlocal`` statements. ``names`` is a list of raw strings." msgstr "``global`` 和 ``nonlocal`` 陳述式。``names`` 是原始字串的串列。" -#: ../../library/ast.rst:2123 +#: ../../library/ast.rst:2120 msgid "" ">>> print(ast.dump(ast.parse('global x,y,z'), indent=4))\n" "Module(\n" @@ -3978,19 +3968,19 @@ msgstr "" " 'y',\n" " 'z'])])" -#: ../../library/ast.rst:2146 +#: ../../library/ast.rst:2143 msgid "A class definition." msgstr "一個類別定義。" -#: ../../library/ast.rst:2148 +#: ../../library/ast.rst:2145 msgid "``name`` is a raw string for the class name" msgstr "``name`` 是類別名稱的原始字串" -#: ../../library/ast.rst:2149 +#: ../../library/ast.rst:2146 msgid "``bases`` is a list of nodes for explicitly specified base classes." msgstr "``bases`` 是被顯式指定的基底類別節點串列。" -#: ../../library/ast.rst:2150 +#: ../../library/ast.rst:2147 msgid "" "``keywords`` is a list of :class:`.keyword` nodes, principally for " "'metaclass'. Other keywords will be passed to the metaclass, as per :pep:" @@ -3999,17 +3989,17 @@ msgstr "" "``keywords`` 是一個 :class:`.keyword` 節點的串列,主要用於 'metaclass'(元類" "別)。如 :pep:`3115` 所述,其他關鍵字將被傳遞到 metaclass。" -#: ../../library/ast.rst:2152 +#: ../../library/ast.rst:2149 msgid "" "``body`` is a list of nodes representing the code within the class " "definition." msgstr "``body`` 是表示類別定義中程式碼的節點串列。" -#: ../../library/ast.rst:2154 +#: ../../library/ast.rst:2151 msgid "``decorator_list`` is a list of nodes, as in :class:`FunctionDef`." msgstr "``decorator_list`` 是一個節點串列,如 :class:`FunctionDef` 中所示。" -#: ../../library/ast.rst:2157 +#: ../../library/ast.rst:2154 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -4022,17 +4012,17 @@ msgid "" " ClassDef(\n" " name='Foo',\n" " bases=[\n" -" Name(id='base1', ctx=Load()),\n" -" Name(id='base2', ctx=Load())],\n" +" Name(id='base1'),\n" +" Name(id='base2')],\n" " keywords=[\n" " keyword(\n" " arg='metaclass',\n" -" value=Name(id='meta', ctx=Load()))],\n" +" value=Name(id='meta'))],\n" " body=[\n" " Pass()],\n" " decorator_list=[\n" -" Name(id='decorator1', ctx=Load()),\n" -" Name(id='decorator2', ctx=Load())])])" +" Name(id='decorator1'),\n" +" Name(id='decorator2')])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -4045,29 +4035,29 @@ msgstr "" " ClassDef(\n" " name='Foo',\n" " bases=[\n" -" Name(id='base1', ctx=Load()),\n" -" Name(id='base2', ctx=Load())],\n" +" Name(id='base1'),\n" +" Name(id='base2')],\n" " keywords=[\n" " keyword(\n" " arg='metaclass',\n" -" value=Name(id='meta', ctx=Load()))],\n" +" value=Name(id='meta'))],\n" " body=[\n" " Pass()],\n" " decorator_list=[\n" -" Name(id='decorator1', ctx=Load()),\n" -" Name(id='decorator2', ctx=Load())])])" +" Name(id='decorator1'),\n" +" Name(id='decorator2')])])" -#: ../../library/ast.rst:2186 +#: ../../library/ast.rst:2183 msgid "Async and await" msgstr "async 和 await" -#: ../../library/ast.rst:2190 +#: ../../library/ast.rst:2187 msgid "" "An ``async def`` function definition. Has the same fields as :class:" "`FunctionDef`." msgstr "一個 ``async def`` 函式定義。與 :class:`FunctionDef` 具有相同的欄位。" -#: ../../library/ast.rst:2199 +#: ../../library/ast.rst:2196 msgid "" "An ``await`` expression. ``value`` is what it waits for. Only valid in the " "body of an :class:`AsyncFunctionDef`." @@ -4075,7 +4065,7 @@ msgstr "" "一個 ``await`` 運算式。``value`` 是它等待的東西。僅在 :class:" "`AsyncFunctionDef` 主體 (body) 中有效。" -#: ../../library/ast.rst:2202 +#: ../../library/ast.rst:2199 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... async def f():\n" @@ -4090,7 +4080,7 @@ msgid "" " Expr(\n" " value=Await(\n" " value=Call(\n" -" func=Name(id='other_func', ctx=Load()))))])])" +" func=Name(id='other_func'))))])])" msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... async def f():\n" @@ -4105,9 +4095,9 @@ msgstr "" " Expr(\n" " value=Await(\n" " value=Call(\n" -" func=Name(id='other_func', ctx=Load()))))])])" +" func=Name(id='other_func'))))])])" -#: ../../library/ast.rst:2223 +#: ../../library/ast.rst:2220 msgid "" "``async for`` loops and ``async with`` context managers. They have the same " "fields as :class:`For` and :class:`With`, respectively. Only valid in the " @@ -4116,7 +4106,7 @@ msgstr "" "``async for`` 迴圈和 ``async with`` 情境管理器。它們分別具有與 :class:`For` " "和 :class:`With` 相同的欄位。僅在 :class:`AsyncFunctionDef` 主體中有效。" -#: ../../library/ast.rst:2228 +#: ../../library/ast.rst:2225 msgid "" "When a string is parsed by :func:`ast.parse`, operator nodes (subclasses of :" "class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`, :class:`ast." @@ -4129,11 +4119,11 @@ msgstr "" "class:`ast.expr_context` 的子類別)將是單例。對其中之一的更改將反映在所有其他" "出現的相同值中(例如 :class:`ast.Add`)。" -#: ../../library/ast.rst:2236 +#: ../../library/ast.rst:2233 msgid ":mod:`!ast` helpers" msgstr ":mod:`!ast` 輔助程式" -#: ../../library/ast.rst:2238 +#: ../../library/ast.rst:2235 msgid "" "Apart from the node classes, the :mod:`!ast` module defines these utility " "functions and classes for traversing abstract syntax trees:" @@ -4141,18 +4131,19 @@ msgstr "" "除了節點類別之外,:mod:`!ast` 模組還定義了這些用於遍歷 (traverse) 抽象語法樹" "的實用函式和類別:" -#: ../../library/ast.rst:2243 +#: ../../library/ast.rst:2240 msgid "" "Parse the source into an AST node. Equivalent to ``compile(source, " -"filename, mode, flags=FLAGS_VALUE, optimize=optimize)``, where " -"``FLAGS_VALUE`` is ``ast.PyCF_ONLY_AST`` if ``optimize <= 0`` and ``ast." -"PyCF_OPTIMIZED_AST`` otherwise." +"filename, mode, flags=FLAGS_VALUE, optimize=optimize, module=module)``, " +"where ``FLAGS_VALUE`` is ``ast.PyCF_ONLY_AST`` if ``optimize <= 0`` and " +"``ast.PyCF_OPTIMIZED_AST`` otherwise." msgstr "" "將原始碼剖析為 AST 節點,相當於 ``compile(source, filename, mode, " -"flags=FLAGS_VALUE, optimize=optimize)``,其中 ``FLAGS_VALUE`` 在 ``optimize " -"<= 0`` 時為 ``ast.PyCF_ONLY_AST``,否則為 ``ast.PyCF_OPTIMIZED_AST``。" +"flags=FLAGS_VALUE, optimize=optimize, module=module)``,其中 ``FLAGS_VALUE`` " +"在 ``optimize <= 0`` 時為 ``ast.PyCF_ONLY_AST``,否則為 " +"``ast.PyCF_OPTIMIZED_AST``。" -#: ../../library/ast.rst:2248 +#: ../../library/ast.rst:2245 msgid "" "If ``type_comments=True`` is given, the parser is modified to check and " "return type comments as specified by :pep:`484` and :pep:`526`. This is " @@ -4171,7 +4162,7 @@ msgstr "" "``None``。此外,``# type: ignore`` 註釋的位置將作為 :class:`Module` 的 " "``type_ignores`` 屬性回傳(否則它始終是一個空串列)。" -#: ../../library/ast.rst:2258 +#: ../../library/ast.rst:2255 msgid "" "In addition, if ``mode`` is ``'func_type'``, the input syntax is modified to " "correspond to :pep:`484` \"signature type comments\", for example ``(str, " @@ -4181,7 +4172,7 @@ msgstr "" "名型別註解 (signature type comments)」而被修改,例如 ``(str, int) -> " "List[str]``。" -#: ../../library/ast.rst:2262 +#: ../../library/ast.rst:2259 msgid "" "Setting ``feature_version`` to a tuple ``(major, minor)`` will result in a " "\"best-effort\" attempt to parse using that Python version's grammar. For " @@ -4201,12 +4192,12 @@ msgstr "" "能保證剖析(或剖析的成功)與在與 ``feature_version`` 對應的 Python 版本上運行" "時相同。" -#: ../../library/ast.rst:2272 +#: ../../library/ast.rst:2269 msgid "" "If source contains a null character (``\\0``), :exc:`ValueError` is raised." msgstr "如果來源包含 null 字元 (``\\0``),則會引發 :exc:`ValueError`。" -#: ../../library/ast.rst:2275 +#: ../../library/ast.rst:2272 msgid "" "Note that successfully parsing source code into an AST object doesn't " "guarantee that the source code provided is valid Python code that can be " @@ -4220,14 +4211,14 @@ msgstr "" "原始的 ``return 42`` 為 return 陳述式生成一個有效的 AST 節點,但它不能單獨編" "譯(它需要位於函式節點內)。" -#: ../../library/ast.rst:2282 +#: ../../library/ast.rst:2279 msgid "" "In particular, :func:`ast.parse` won't do any scoping checks, which the " "compilation step does." msgstr "" "特別是 :func:`ast.parse` 不會執行任何範圍檢查,而編譯步驟才會執行此操作。" -#: ../../library/ast.rst:2286 +#: ../../library/ast.rst:2283 msgid "" "It is possible to crash the Python interpreter with a sufficiently large/" "complex string due to stack depth limitations in Python's AST compiler." @@ -4235,11 +4226,11 @@ msgstr "" "由於 Python AST 編譯器中的堆疊 (stack) 深度限制,太大或太複雜的字串可能會導" "致 Python 直譯器崩潰。" -#: ../../library/ast.rst:2290 +#: ../../library/ast.rst:2287 msgid "Added ``type_comments``, ``mode='func_type'`` and ``feature_version``." msgstr "新增 ``type_comments``、``mode='func_type'`` 與 ``feature_version``。" -#: ../../library/ast.rst:2293 +#: ../../library/ast.rst:2290 msgid "" "The minimum supported version for ``feature_version`` is now ``(3, 7)``. The " "``optimize`` argument was added." @@ -4247,6 +4238,10 @@ msgstr "" "``feature_version`` 的最低支援版本現在是 ``(3, 7)``。新增了 ``optimize`` 引" "數。" +#: ../../library/ast.rst:2294 +msgid "Added the *module* parameter." +msgstr "新增 *module* 參數。" + #: ../../library/ast.rst:2300 msgid "" "Unparse an :class:`ast.AST` object and generate a string with code that " @@ -4521,7 +4516,7 @@ msgid "" "\n" " def visit_Name(self, node):\n" " return Subscript(\n" -" value=Name(id='data', ctx=Load()),\n" +" value=Name(id='data'),\n" " slice=Constant(value=node.id),\n" " ctx=node.ctx\n" " )" @@ -4530,7 +4525,7 @@ msgstr "" "\n" " def visit_Name(self, node):\n" " return Subscript(\n" -" value=Name(id='data', ctx=Load()),\n" +" value=Name(id='data'),\n" " slice=Constant(value=node.id),\n" " ctx=node.ctx\n" " )" @@ -4598,6 +4593,13 @@ msgstr "" #: ../../library/ast.rst:2514 msgid "" +"If *color* is ``True``, the returned string is syntax highlighted using ANSI " +"escape sequences. If ``False`` (the default), colored output is always " +"disabled." +msgstr "" + +#: ../../library/ast.rst:2518 +msgid "" "If *indent* is a non-negative integer or string, then the tree will be " "pretty-printed with that indent level. An indent level of 0, negative, or " "``\"\"`` will only insert newlines. ``None`` (the default) selects the " @@ -4610,73 +4612,62 @@ msgstr "" "(預設值)代表選擇單列表示。使用正整數縮排可以在每個級別縮排相同數量的空格。" "如果 *indent* 是一個字串(例如 ``\"\\t\"``),則該字串用於縮排每個級別。" -#: ../../library/ast.rst:2521 +#: ../../library/ast.rst:2525 msgid "" -"If *show_empty* is false (the default), optional empty lists will be omitted " -"from the output. Optional ``None`` values are always omitted." +"If *show_empty* is false (the default), optional empty lists and ``Load()`` " +"values will be omitted from the output. Optional ``None`` values are always " +"omitted." msgstr "" -"如果 *show_empty* 為 false(預設值),則輸出中將省略可選的空串列。可選的 " -"``None`` 值總是會被省略。" +"如果 *show_empty* 為 false(預設值),則輸出中將省略可選的空串列和 " +"``Load()`` 值。可選的 ``None`` 值總是會被省略。" -#: ../../library/ast.rst:2525 +#: ../../library/ast.rst:2529 +msgid "" +">>> tree = ast.parse('print(None)', '?', 'eval')\n" +">>> print(ast.dump(tree, indent=4))\n" +"Expression(\n" +" body=Call(\n" +" func=Name(id='print'),\n" +" args=[\n" +" Constant(value=None)]))\n" +">>> print(ast.dump(tree, indent=4, show_empty=True))\n" +"Expression(\n" +" body=Call(\n" +" func=Name(id='print', ctx=Load()),\n" +" args=[\n" +" Constant(value=None)],\n" +" keywords=[]))" +msgstr "" +">>> tree = ast.parse('print(None)', '?', 'eval')\n" +">>> print(ast.dump(tree, indent=4))\n" +"Expression(\n" +" body=Call(\n" +" func=Name(id='print'),\n" +" args=[\n" +" Constant(value=None)]))\n" +">>> print(ast.dump(tree, indent=4, show_empty=True))\n" +"Expression(\n" +" body=Call(\n" +" func=Name(id='print', ctx=Load()),\n" +" args=[\n" +" Constant(value=None)],\n" +" keywords=[]))" + +#: ../../library/ast.rst:2546 msgid "Added the *indent* option." msgstr "新增 *indent* 選項。" -#: ../../library/ast.rst:2528 +#: ../../library/ast.rst:2549 msgid "Added the *show_empty* option." msgstr "新增 *show_empty* 選項。" -#: ../../library/ast.rst:2531 -msgid "" -">>> print(ast.dump(ast.parse(\"\"\"\\\n" -"... async def f():\n" -"... await other_func()\n" -"... \"\"\"), indent=4, show_empty=True))\n" -"Module(\n" -" body=[\n" -" AsyncFunctionDef(\n" -" name='f',\n" -" args=arguments(\n" -" posonlyargs=[],\n" -" args=[],\n" -" kwonlyargs=[],\n" -" kw_defaults=[],\n" -" defaults=[]),\n" -" body=[\n" -" Expr(\n" -" value=Await(\n" -" value=Call(\n" -" func=Name(id='other_func', ctx=Load()),\n" -" args=[],\n" -" keywords=[])))],\n" -" decorator_list=[],\n" -" type_params=[])],\n" -" type_ignores=[])" +#: ../../library/ast.rst:2552 +msgid "Omit optional ``Load()`` values by default." msgstr "" -">>> print(ast.dump(ast.parse(\"\"\"\\\n" -"... async def f():\n" -"... await other_func()\n" -"... \"\"\"), indent=4, show_empty=True))\n" -"Module(\n" -" body=[\n" -" AsyncFunctionDef(\n" -" name='f',\n" -" args=arguments(\n" -" posonlyargs=[],\n" -" args=[],\n" -" kwonlyargs=[],\n" -" kw_defaults=[],\n" -" defaults=[]),\n" -" body=[\n" -" Expr(\n" -" value=Await(\n" -" value=Call(\n" -" func=Name(id='other_func', ctx=Load()),\n" -" args=[],\n" -" keywords=[])))],\n" -" decorator_list=[],\n" -" type_params=[])],\n" -" type_ignores=[])" + +#: ../../library/ast.rst:2555 +msgid "Added the *color* parameter." +msgstr "新增 *color* 參數。" #: ../../library/ast.rst:2561 msgid "Recursively compares two ASTs." @@ -4741,57 +4732,63 @@ msgstr "命令列用法" #: ../../library/ast.rst:2615 msgid "" +"The output is now syntax highlighted by default. This can be :ref:" +"`controlled using environment variables `." +msgstr "" + +#: ../../library/ast.rst:2619 +msgid "" "The :mod:`!ast` module can be executed as a script from the command line. It " "is as simple as:" msgstr ":mod:`!ast` 模組可以作為腳本從命令列執行,可以像這樣簡單地做到:" -#: ../../library/ast.rst:2618 +#: ../../library/ast.rst:2622 msgid "python -m ast [-m ] [-a] [infile]" msgstr "python -m ast [-m ] [-a] [infile]" -#: ../../library/ast.rst:2622 +#: ../../library/ast.rst:2626 msgid "The following options are accepted:" msgstr "以下選項可被接受:" -#: ../../library/ast.rst:2628 +#: ../../library/ast.rst:2632 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/ast.rst:2633 +#: ../../library/ast.rst:2637 msgid "" "Specify what kind of code must be compiled, like the *mode* argument in :" "func:`parse`." msgstr "指定必須編譯哪種類型的程式碼,像是 :func:`parse` 中的 *mode* 引數。" -#: ../../library/ast.rst:2638 +#: ../../library/ast.rst:2642 msgid "Don't parse type comments." msgstr "不要剖析型別註解。" -#: ../../library/ast.rst:2642 +#: ../../library/ast.rst:2646 msgid "Include attributes such as line numbers and column offsets." msgstr "包括列號和行偏移量等屬性。" -#: ../../library/ast.rst:2647 +#: ../../library/ast.rst:2651 msgid "Indentation of nodes in AST (number of spaces)." msgstr "AST 中節點的縮進(空格數)。" -#: ../../library/ast.rst:2651 +#: ../../library/ast.rst:2655 msgid "" "Python version in the format 3.x (for example, 3.10). Defaults to the " "current version of the interpreter." msgstr "以 3.x 格式表示的 Python 版本(例如 3.10)。預設為直譯器的目前版本。" -#: ../../library/ast.rst:2659 +#: ../../library/ast.rst:2663 msgid "Optimization level for parser. Defaults to no optimization." msgstr "剖析器的最佳化層級。預設為不進行最佳化。" -#: ../../library/ast.rst:2665 +#: ../../library/ast.rst:2669 msgid "" "Show empty lists and fields that are ``None``. Defaults to not showing empty " "objects." msgstr "顯示空串列和值為 ``None`` 的欄位。預設為不顯示空物件。" -#: ../../library/ast.rst:2671 +#: ../../library/ast.rst:2675 msgid "" "If :file:`infile` is specified its contents are parsed to AST and dumped to " "stdout. Otherwise, the content is read from stdin." @@ -4799,7 +4796,7 @@ msgstr "" "如果指定了 :file:`infile`,則其內容將被剖析為 AST 並傾印 (dump) 到 stdout。否" "則會從 stdin 讀取內容。" -#: ../../library/ast.rst:2677 +#: ../../library/ast.rst:2681 msgid "" "`Green Tree Snakes `_, an external " "documentation resource, has good details on working with Python ASTs." @@ -4807,7 +4804,7 @@ msgstr "" "`Green Tree Snakes `_ 是一個外部文件" "資源,提供了有關使用 Python AST 的詳細資訊。" -#: ../../library/ast.rst:2680 +#: ../../library/ast.rst:2684 msgid "" "`ASTTokens `_ " "annotates Python ASTs with the positions of tokens and text in the source " @@ -4818,7 +4815,7 @@ msgstr "" "用生成它們的原始碼中的標記和文本的位置來註釋 Python AST。這對於進行原始碼轉換" "的工具很有幫助。" -#: ../../library/ast.rst:2685 +#: ../../library/ast.rst:2689 msgid "" "`leoAst.py `_ unifies the token-based and parse-tree-based views of python programs " @@ -4828,7 +4825,7 @@ msgstr "" "py>`_ 透過在 token 和 ast 節點之間插入雙向鏈結,統一了 python 程式的基於 " "token 和基於剖析樹的視圖。" -#: ../../library/ast.rst:2690 +#: ../../library/ast.rst:2694 msgid "" "`LibCST `_ parses code as a Concrete Syntax " "Tree that looks like an ast tree and keeps all formatting details. It's " @@ -4838,7 +4835,7 @@ msgstr "" "(Concrete Syntax Tree),看起來像 ast 樹並保留所有格式詳細資訊。它對於建置自動" "重構 (codemod) 應用程式和 linter 非常有用。" -#: ../../library/ast.rst:2695 +#: ../../library/ast.rst:2699 msgid "" "`Parso `_ is a Python parser that supports " "error recovery and round-trip parsing for different Python versions (in " @@ -4849,14 +4846,65 @@ msgstr "" "Python 版本的錯誤復原和往返剖析。Parso 還能夠列出 Python 檔案中的多個語法錯" "誤。" -#: ../../library/ast.rst:59 +#: ../../library/ast.rst:58 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/ast.rst:59 ../../library/ast.rst:60 +#: ../../library/ast.rst:58 ../../library/ast.rst:59 msgid "in AST grammar" msgstr "於 AST 文法中" -#: ../../library/ast.rst:60 +#: ../../library/ast.rst:59 msgid "* (asterisk)" msgstr "* (星號)" + +#~ msgid "" +#~ ">>> print(ast.dump(ast.parse(\"\"\"\\\n" +#~ "... async def f():\n" +#~ "... await other_func()\n" +#~ "... \"\"\"), indent=4, show_empty=True))\n" +#~ "Module(\n" +#~ " body=[\n" +#~ " AsyncFunctionDef(\n" +#~ " name='f',\n" +#~ " args=arguments(\n" +#~ " posonlyargs=[],\n" +#~ " args=[],\n" +#~ " kwonlyargs=[],\n" +#~ " kw_defaults=[],\n" +#~ " defaults=[]),\n" +#~ " body=[\n" +#~ " Expr(\n" +#~ " value=Await(\n" +#~ " value=Call(\n" +#~ " func=Name(id='other_func', ctx=Load()),\n" +#~ " args=[],\n" +#~ " keywords=[])))],\n" +#~ " decorator_list=[],\n" +#~ " type_params=[])],\n" +#~ " type_ignores=[])" +#~ msgstr "" +#~ ">>> print(ast.dump(ast.parse(\"\"\"\\\n" +#~ "... async def f():\n" +#~ "... await other_func()\n" +#~ "... \"\"\"), indent=4, show_empty=True))\n" +#~ "Module(\n" +#~ " body=[\n" +#~ " AsyncFunctionDef(\n" +#~ " name='f',\n" +#~ " args=arguments(\n" +#~ " posonlyargs=[],\n" +#~ " args=[],\n" +#~ " kwonlyargs=[],\n" +#~ " kw_defaults=[],\n" +#~ " defaults=[]),\n" +#~ " body=[\n" +#~ " Expr(\n" +#~ " value=Await(\n" +#~ " value=Call(\n" +#~ " func=Name(id='other_func', ctx=Load()),\n" +#~ " args=[],\n" +#~ " keywords=[])))],\n" +#~ " decorator_list=[],\n" +#~ " type_params=[])],\n" +#~ " type_ignores=[])" diff --git a/library/asyncio-task.po b/library/asyncio-task.po index 1fdf4eee3d8..ddc6f918021 100644 --- a/library/asyncio-task.po +++ b/library/asyncio-task.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-12 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -463,11 +463,11 @@ msgstr "" " for i in range(10):\n" " tg.create_task(some_coro(param=i))" -#: ../../library/asyncio-task.rst:304 ../../library/asyncio-task.rst:1275 +#: ../../library/asyncio-task.rst:304 ../../library/asyncio-task.rst:1265 msgid "Added the *name* parameter." msgstr "新增 *name* 參數。" -#: ../../library/asyncio-task.rst:307 ../../library/asyncio-task.rst:1282 +#: ../../library/asyncio-task.rst:307 ../../library/asyncio-task.rst:1272 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" @@ -538,13 +538,62 @@ msgstr "" msgid "Passes on all *kwargs* to :meth:`loop.create_task`" msgstr "" -#: ../../library/asyncio-task.rst:369 ../../library/asyncio-task.rst:575 -#: ../../library/asyncio-task.rst:748 ../../library/asyncio-task.rst:809 -#: ../../library/asyncio-task.rst:835 ../../library/asyncio-task.rst:872 +#: ../../library/asyncio-task.rst:371 +msgid "" +"Cancel the task group. This is a non-exceptional, early exit of the task " +"group's lifetime -- useful once the group's goal has been met or its " +"services no longer needed." +msgstr "" + +#: ../../library/asyncio-task.rst:375 +msgid "" +":meth:`~asyncio.Task.cancel` will be called on any tasks in the group that " +"aren't yet done, as well as the parent (body) of the group. The task group " +"context manager will exit *without* :exc:`asyncio.CancelledError` being " +"raised." +msgstr "" + +#: ../../library/asyncio-task.rst:379 +msgid "" +"If :meth:`cancel` is called before entering the task group, the group will " +"be cancelled upon entry. This is useful for patterns where one piece of " +"code passes an unused :class:`asyncio.TaskGroup` instance to another in " +"order to have the ability to cancel anything run within the group." +msgstr "" + +#: ../../library/asyncio-task.rst:384 +msgid "" +":meth:`cancel` is idempotent and may be called after the task group has " +"already exited." +msgstr "" + +#: ../../library/asyncio-task.rst:387 +msgid "Some ways to use :meth:`cancel`:" +msgstr "" + +#: ../../library/asyncio-task.rst:389 +msgid "call it from the task group body based on some condition or event" +msgstr "" + +#: ../../library/asyncio-task.rst:390 +msgid "" +"pass the task group instance to child tasks via :meth:`create_task`, " +"allowing a child task to conditionally cancel the entire group" +msgstr "" + +#: ../../library/asyncio-task.rst:392 +msgid "" +"pass the task group instance or bound :meth:`cancel` method to some other " +"task *before* opening the task group, allowing remote cancellation" +msgstr "" + +#: ../../library/asyncio-task.rst:397 ../../library/asyncio-task.rst:565 +#: ../../library/asyncio-task.rst:738 ../../library/asyncio-task.rst:799 +#: ../../library/asyncio-task.rst:825 ../../library/asyncio-task.rst:862 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-task.rst:371 +#: ../../library/asyncio-task.rst:399 msgid "" "async def main():\n" " async with asyncio.TaskGroup() as tg:\n" @@ -560,16 +609,18 @@ msgstr "" " print(f\"Both tasks have completed now: {task1.result()}, {task2." "result()}\")" -#: ../../library/asyncio-task.rst:377 +#: ../../library/asyncio-task.rst:405 msgid "" "The ``async with`` statement will wait for all tasks in the group to finish. " "While waiting, new tasks may still be added to the group (for example, by " "passing ``tg`` into one of the coroutines and calling ``tg.create_task()`` " -"in that coroutine). Once the last task has finished and the ``async with`` " -"block is exited, no new tasks may be added to the group." +"in that coroutine). There is also opportunity to request termination of the " +"entire task group with ``tg.cancel()``, based on some condition. Once the " +"last task has finished and the ``async with`` block is exited, no new tasks " +"may be added to the group." msgstr "" -#: ../../library/asyncio-task.rst:384 +#: ../../library/asyncio-task.rst:413 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 " @@ -581,7 +632,7 @@ msgid "" "bubble out of the containing ``async with`` statement." msgstr "" -#: ../../library/asyncio-task.rst:394 +#: ../../library/asyncio-task.rst:423 msgid "" "Once all tasks have finished, if any tasks have failed with an exception " "other than :exc:`asyncio.CancelledError`, those exceptions are combined in " @@ -589,7 +640,7 @@ msgid "" "their documentation) which is then raised." msgstr "" -#: ../../library/asyncio-task.rst:401 +#: ../../library/asyncio-task.rst:430 msgid "" "Two base exceptions are treated specially: If any task fails with :exc:" "`KeyboardInterrupt` or :exc:`SystemExit`, the task group still cancels the " @@ -598,7 +649,7 @@ msgid "" "`ExceptionGroup` or :exc:`BaseExceptionGroup`." msgstr "" -#: ../../library/asyncio-task.rst:407 +#: ../../library/asyncio-task.rst:436 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 " @@ -607,10 +658,13 @@ msgid "" "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." +"`KeyboardInterrupt` and :exc:`SystemExit` as in the previous paragraph. " +"There is an additional special case made only for the body of the ``async " +"with``: if it raises :exc:`GeneratorExit` and none of the other tasks raise " +"exceptions that would be reported, then the :exc:`GeneratorExit` is reraised." msgstr "" -#: ../../library/asyncio-task.rst:419 +#: ../../library/asyncio-task.rst:452 msgid "" "Task groups are careful not to mix up the internal cancellation used to " "\"wake up\" their :meth:`~object.__aexit__` with cancellation requests for " @@ -621,7 +675,7 @@ msgid "" "receive another cancellation and process its own exceptions." msgstr "" -#: ../../library/asyncio-task.rst:427 +#: ../../library/asyncio-task.rst:460 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." @@ -629,108 +683,54 @@ msgid "" "be raised at the next :keyword:`await`, so the cancellation is not lost." msgstr "" -#: ../../library/asyncio-task.rst:433 +#: ../../library/asyncio-task.rst:466 msgid "" "Task groups preserve the cancellation count reported by :meth:`asyncio.Task." "cancelling`." msgstr "" -#: ../../library/asyncio-task.rst:438 +#: ../../library/asyncio-task.rst:471 msgid "" "Improved handling of simultaneous internal and external cancellations and " "correct preservation of cancellation counts." msgstr "" -#: ../../library/asyncio-task.rst:442 -msgid "Terminating a task group" -msgstr "" - -#: ../../library/asyncio-task.rst:444 -msgid "" -"While terminating a task group is not natively supported by the standard " -"library, termination can be achieved by adding an exception-raising task to " -"the task group and ignoring the raised exception:" -msgstr "" - -#: ../../library/asyncio-task.rst:448 -msgid "" -"import asyncio\n" -"from asyncio import TaskGroup\n" -"\n" -"class TerminateTaskGroup(Exception):\n" -" \"\"\"Exception raised to terminate a task group.\"\"\"\n" -"\n" -"async def force_terminate_task_group():\n" -" \"\"\"Used to force termination of a task group.\"\"\"\n" -" raise TerminateTaskGroup()\n" -"\n" -"async def job(task_id, sleep_time):\n" -" print(f'Task {task_id}: start')\n" -" await asyncio.sleep(sleep_time)\n" -" print(f'Task {task_id}: done')\n" -"\n" -"async def main():\n" -" try:\n" -" async with TaskGroup() as group:\n" -" # spawn some tasks\n" -" group.create_task(job(1, 0.5))\n" -" group.create_task(job(2, 1.5))\n" -" # sleep for 1 second\n" -" await asyncio.sleep(1)\n" -" # add an exception-raising task to force the group to terminate\n" -" group.create_task(force_terminate_task_group())\n" -" except* TerminateTaskGroup:\n" -" pass\n" -"\n" -"asyncio.run(main())" -msgstr "" - -#: ../../library/asyncio-task.rst:480 -msgid "Expected output:" -msgstr "預期的輸出: ::" - -#: ../../library/asyncio-task.rst:482 -msgid "" -"Task 1: start\n" -"Task 2: start\n" -"Task 1: done" +#: ../../library/asyncio-task.rst:476 +msgid "Addition of the special case for :exc:`GeneratorExit`." msgstr "" -"Task 1: start\n" -"Task 2: start\n" -"Task 1: done" -#: ../../library/asyncio-task.rst:489 +#: ../../library/asyncio-task.rst:479 msgid "Sleeping" msgstr "" -#: ../../library/asyncio-task.rst:494 +#: ../../library/asyncio-task.rst:484 msgid "Block for *delay* seconds." msgstr "" -#: ../../library/asyncio-task.rst:496 +#: ../../library/asyncio-task.rst:486 msgid "" "If *result* is provided, it is returned to the caller when the coroutine " "completes." msgstr "" -#: ../../library/asyncio-task.rst:499 +#: ../../library/asyncio-task.rst:489 msgid "" "``sleep()`` always suspends the current task, allowing other tasks to run." msgstr "" -#: ../../library/asyncio-task.rst:502 +#: ../../library/asyncio-task.rst:492 msgid "" "Setting the delay to 0 provides an optimized path to allow other tasks to " "run. This can be used by long-running functions to avoid blocking the event " "loop for the full duration of the function call." msgstr "" -#: ../../library/asyncio-task.rst:508 +#: ../../library/asyncio-task.rst:498 msgid "" "Example of coroutine displaying the current date every second for 5 seconds::" msgstr "" -#: ../../library/asyncio-task.rst:511 +#: ../../library/asyncio-task.rst:501 msgid "" "import asyncio\n" "import datetime as dt\n" @@ -760,40 +760,40 @@ msgstr "" "\n" "asyncio.run(display_date())" -#: ../../library/asyncio-task.rst:526 ../../library/asyncio-task.rst:624 -#: ../../library/asyncio-task.rst:723 ../../library/asyncio-task.rst:897 -#: ../../library/asyncio-task.rst:959 ../../library/asyncio-task.rst:1020 +#: ../../library/asyncio-task.rst:516 ../../library/asyncio-task.rst:614 +#: ../../library/asyncio-task.rst:713 ../../library/asyncio-task.rst:887 +#: ../../library/asyncio-task.rst:949 ../../library/asyncio-task.rst:1010 msgid "Removed the *loop* parameter." msgstr "移除 *loop* 參數。" -#: ../../library/asyncio-task.rst:529 +#: ../../library/asyncio-task.rst:519 msgid "Raises :exc:`ValueError` if *delay* is :data:`~math.nan`." msgstr "如果 *delay* 是 :data:`~math.nan`,則引發 :exc:`ValueError`。" -#: ../../library/asyncio-task.rst:534 +#: ../../library/asyncio-task.rst:524 msgid "Running tasks concurrently" msgstr "" -#: ../../library/asyncio-task.rst:538 +#: ../../library/asyncio-task.rst:528 msgid "" "Run :ref:`awaitable objects ` in the *aws* sequence " "*concurrently*." msgstr "" -#: ../../library/asyncio-task.rst:541 +#: ../../library/asyncio-task.rst:531 msgid "" "If any awaitable in *aws* is a coroutine, it is automatically scheduled as a " "Task." msgstr "" -#: ../../library/asyncio-task.rst:544 +#: ../../library/asyncio-task.rst:534 msgid "" "If all awaitables are completed successfully, the result is an aggregate " "list of returned values. The order of result values corresponds to the " "order of awaitables in *aws*." msgstr "" -#: ../../library/asyncio-task.rst:548 +#: ../../library/asyncio-task.rst:538 msgid "" "If *return_exceptions* is ``False`` (default), the first raised exception is " "immediately propagated to the task that awaits on ``gather()``. Other " @@ -801,19 +801,19 @@ msgid "" "run." msgstr "" -#: ../../library/asyncio-task.rst:553 +#: ../../library/asyncio-task.rst:543 msgid "" "If *return_exceptions* is ``True``, exceptions are treated the same as " "successful results, and aggregated in the result list." msgstr "" -#: ../../library/asyncio-task.rst:556 +#: ../../library/asyncio-task.rst:546 msgid "" "If ``gather()`` is *cancelled*, all submitted awaitables (that have not " "completed yet) are also *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:559 +#: ../../library/asyncio-task.rst:549 msgid "" "If any Task or Future from the *aws* sequence is *cancelled*, it is treated " "as if it raised :exc:`CancelledError` -- the ``gather()`` call is **not** " @@ -821,7 +821,7 @@ msgid "" "submitted Task/Future to cause other Tasks/Futures to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:566 +#: ../../library/asyncio-task.rst:556 msgid "" "A new alternative to create and run tasks concurrently and wait for their " "completion is :class:`asyncio.TaskGroup`. *TaskGroup* provides stronger " @@ -831,7 +831,7 @@ msgid "" "tasks." msgstr "" -#: ../../library/asyncio-task.rst:577 +#: ../../library/asyncio-task.rst:567 msgid "" "import asyncio\n" "\n" @@ -870,7 +870,7 @@ msgid "" "# [2, 6, 24]" msgstr "" -#: ../../library/asyncio-task.rst:613 +#: ../../library/asyncio-task.rst:603 msgid "" "If *return_exceptions* is false, cancelling gather() after it has been " "marked done won't cancel any submitted awaitables. For instance, gather can " @@ -879,28 +879,28 @@ msgid "" "the awaitables) from gather won't cancel any other awaitables." msgstr "" -#: ../../library/asyncio-task.rst:620 +#: ../../library/asyncio-task.rst:610 msgid "" "If the *gather* itself is cancelled, the cancellation is propagated " "regardless of *return_exceptions*." msgstr "" -#: ../../library/asyncio-task.rst:627 +#: ../../library/asyncio-task.rst:617 msgid "" "Deprecation warning is emitted if no positional arguments are provided or " "not all positional arguments are Future-like objects and there is no running " "event loop." msgstr "" -#: ../../library/asyncio-task.rst:636 +#: ../../library/asyncio-task.rst:626 msgid "Eager task factory" msgstr "" -#: ../../library/asyncio-task.rst:640 +#: ../../library/asyncio-task.rst:630 msgid "A task factory for eager task execution." msgstr "" -#: ../../library/asyncio-task.rst:642 +#: ../../library/asyncio-task.rst:632 msgid "" "When using this factory (via :meth:`loop.set_task_factory(asyncio." "eager_task_factory) `), coroutines begin execution " @@ -910,13 +910,13 @@ msgid "" "synchronously." msgstr "" -#: ../../library/asyncio-task.rst:648 +#: ../../library/asyncio-task.rst:638 msgid "" "A common example where this is beneficial is coroutines which employ caching " "or memoization to avoid actual I/O when possible." msgstr "" -#: ../../library/asyncio-task.rst:653 +#: ../../library/asyncio-task.rst:643 msgid "" "Immediate execution of the coroutine is a semantic change. If the coroutine " "returns or raises, the task is never scheduled to the event loop. If the " @@ -925,46 +925,46 @@ msgid "" "the application's task execution order is likely to change." msgstr "" -#: ../../library/asyncio-task.rst:664 +#: ../../library/asyncio-task.rst:654 msgid "" "Create an eager task factory, similar to :func:`eager_task_factory`, using " "the provided *custom_task_constructor* when creating a new task instead of " "the default :class:`Task`." msgstr "" -#: ../../library/asyncio-task.rst:668 +#: ../../library/asyncio-task.rst:658 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." msgstr "" -#: ../../library/asyncio-task.rst:672 +#: ../../library/asyncio-task.rst:662 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) `)." msgstr "" -#: ../../library/asyncio-task.rst:679 +#: ../../library/asyncio-task.rst:669 msgid "Shielding from cancellation" msgstr "" -#: ../../library/asyncio-task.rst:683 +#: ../../library/asyncio-task.rst:673 msgid "" "Protect an :ref:`awaitable object ` from being :meth:" "`cancelled `." msgstr "" -#: ../../library/asyncio-task.rst:686 +#: ../../library/asyncio-task.rst:676 msgid "If *aw* is a coroutine it is automatically scheduled as a Task." msgstr "" -#: ../../library/asyncio-task.rst:688 +#: ../../library/asyncio-task.rst:678 msgid "The statement::" msgstr "" -#: ../../library/asyncio-task.rst:690 +#: ../../library/asyncio-task.rst:680 msgid "" "task = asyncio.create_task(something())\n" "res = await shield(task)" @@ -972,15 +972,15 @@ msgstr "" "task = asyncio.create_task(something())\n" "res = await shield(task)" -#: ../../library/asyncio-task.rst:693 +#: ../../library/asyncio-task.rst:683 msgid "is equivalent to::" msgstr "" -#: ../../library/asyncio-task.rst:695 +#: ../../library/asyncio-task.rst:685 msgid "res = await something()" msgstr "res = await something()" -#: ../../library/asyncio-task.rst:697 +#: ../../library/asyncio-task.rst:687 msgid "" "*except* that if the coroutine containing it is cancelled, the Task running " "in ``something()`` is not cancelled. From the point of view of " @@ -989,20 +989,20 @@ msgid "" "`CancelledError`." msgstr "" -#: ../../library/asyncio-task.rst:703 +#: ../../library/asyncio-task.rst:693 msgid "" "If ``something()`` is cancelled by other means (i.e. from within itself) " "that would also cancel ``shield()``." msgstr "" -#: ../../library/asyncio-task.rst:706 +#: ../../library/asyncio-task.rst:696 msgid "" "If it is desired to completely ignore cancellation (not recommended) the " "``shield()`` function should be combined with a try/except clause, as " "follows::" msgstr "" -#: ../../library/asyncio-task.rst:710 +#: ../../library/asyncio-task.rst:700 msgid "" "task = asyncio.create_task(something())\n" "try:\n" @@ -1016,7 +1016,7 @@ msgstr "" "except CancelledError:\n" " res = None" -#: ../../library/asyncio-task.rst:718 +#: ../../library/asyncio-task.rst:708 msgid "" "Save a reference to tasks passed to this function, to avoid a task " "disappearing mid-execution. The event loop only keeps weak references to " @@ -1024,36 +1024,36 @@ msgid "" "any time, even before it's done." msgstr "" -#: ../../library/asyncio-task.rst:726 +#: ../../library/asyncio-task.rst:716 msgid "" "Deprecation warning is emitted if *aw* is not Future-like object and there " "is no running event loop." msgstr "" -#: ../../library/asyncio-task.rst:732 +#: ../../library/asyncio-task.rst:722 msgid "Timeouts" msgstr "" -#: ../../library/asyncio-task.rst:736 +#: ../../library/asyncio-task.rst:726 msgid "" "Return an :ref:`asynchronous context manager ` that " "can be used to limit the amount of time spent waiting on something." msgstr "" -#: ../../library/asyncio-task.rst:740 +#: ../../library/asyncio-task.rst:730 msgid "" "*delay* can either be ``None``, or a float/int number of seconds to wait. If " "*delay* is ``None``, no time limit will be applied; this can be useful if " "the delay is unknown when the context manager is created." msgstr "" -#: ../../library/asyncio-task.rst:745 +#: ../../library/asyncio-task.rst:735 msgid "" "In either case, the context manager can be rescheduled after creation using :" "meth:`Timeout.reschedule`." msgstr "" -#: ../../library/asyncio-task.rst:750 +#: ../../library/asyncio-task.rst:740 msgid "" "async def main():\n" " async with asyncio.timeout(10):\n" @@ -1063,7 +1063,7 @@ msgstr "" " async with asyncio.timeout(10):\n" " await long_running_task()" -#: ../../library/asyncio-task.rst:754 +#: ../../library/asyncio-task.rst:744 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." @@ -1071,18 +1071,18 @@ msgid "" "can be caught and handled." msgstr "" -#: ../../library/asyncio-task.rst:761 +#: ../../library/asyncio-task.rst:751 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." msgstr "" -#: ../../library/asyncio-task.rst:766 +#: ../../library/asyncio-task.rst:756 msgid "Example of catching :exc:`TimeoutError`::" msgstr "" -#: ../../library/asyncio-task.rst:768 +#: ../../library/asyncio-task.rst:758 msgid "" "async def main():\n" " try:\n" @@ -1094,54 +1094,54 @@ msgid "" " print(\"This statement will run regardless.\")" msgstr "" -#: ../../library/asyncio-task.rst:777 +#: ../../library/asyncio-task.rst:767 msgid "" "The context manager produced by :func:`asyncio.timeout` can be rescheduled " "to a different deadline and inspected." msgstr "" -#: ../../library/asyncio-task.rst:782 +#: ../../library/asyncio-task.rst:772 msgid "" "An :ref:`asynchronous context manager ` for " "cancelling overdue coroutines." msgstr "" -#: ../../library/asyncio-task.rst:785 +#: ../../library/asyncio-task.rst:775 msgid "" "Prefer using :func:`asyncio.timeout` or :func:`asyncio.timeout_at` rather " "than instantiating :class:`!Timeout` directly." msgstr "" -#: ../../library/asyncio-task.rst:788 +#: ../../library/asyncio-task.rst:778 msgid "" "``when`` should be an absolute time at which the context should time out, as " "measured by the event loop's clock:" msgstr "" -#: ../../library/asyncio-task.rst:791 +#: ../../library/asyncio-task.rst:781 msgid "If ``when`` is ``None``, the timeout will never trigger." msgstr "" -#: ../../library/asyncio-task.rst:792 +#: ../../library/asyncio-task.rst:782 msgid "" "If ``when < loop.time()``, the timeout will trigger on the next iteration of " "the event loop." msgstr "" -#: ../../library/asyncio-task.rst:797 +#: ../../library/asyncio-task.rst:787 msgid "" "Return the current deadline, or ``None`` if the current deadline is not set." msgstr "" -#: ../../library/asyncio-task.rst:802 +#: ../../library/asyncio-task.rst:792 msgid "Reschedule the timeout." msgstr "" -#: ../../library/asyncio-task.rst:806 +#: ../../library/asyncio-task.rst:796 msgid "Return whether the context manager has exceeded its deadline (expired)." msgstr "" -#: ../../library/asyncio-task.rst:811 +#: ../../library/asyncio-task.rst:801 msgid "" "async def main():\n" " try:\n" @@ -1159,17 +1159,17 @@ msgid "" " print(\"Looks like we haven't finished on time.\")" msgstr "" -#: ../../library/asyncio-task.rst:826 +#: ../../library/asyncio-task.rst:816 msgid "Timeout context managers can be safely nested." msgstr "" -#: ../../library/asyncio-task.rst:832 +#: ../../library/asyncio-task.rst:822 msgid "" "Similar to :func:`asyncio.timeout`, except *when* is the absolute time to " "stop waiting, or ``None``." msgstr "" -#: ../../library/asyncio-task.rst:837 +#: ../../library/asyncio-task.rst:827 msgid "" "async def main():\n" " loop = get_running_loop()\n" @@ -1183,38 +1183,38 @@ msgid "" " print(\"This statement will run regardless.\")" msgstr "" -#: ../../library/asyncio-task.rst:853 +#: ../../library/asyncio-task.rst:843 msgid "" "Wait for the *aw* :ref:`awaitable ` to complete with a " "timeout." msgstr "" -#: ../../library/asyncio-task.rst:856 +#: ../../library/asyncio-task.rst:846 msgid "" "*timeout* can either be ``None`` or a float or int number of seconds to wait " "for. If *timeout* is ``None``, block until the future completes." msgstr "" -#: ../../library/asyncio-task.rst:860 +#: ../../library/asyncio-task.rst:850 msgid "If a timeout occurs, it cancels *aw* and raises :exc:`TimeoutError`." msgstr "" -#: ../../library/asyncio-task.rst:862 +#: ../../library/asyncio-task.rst:852 msgid "To prevent *aw* from being cancelled, wrap it in :func:`shield`." msgstr "" -#: ../../library/asyncio-task.rst:864 +#: ../../library/asyncio-task.rst:854 msgid "" "The function will wait until the future is actually cancelled, so the total " "wait time may exceed the *timeout*. If an exception happens during " "cancellation, it is propagated." msgstr "" -#: ../../library/asyncio-task.rst:868 +#: ../../library/asyncio-task.rst:858 msgid "If the wait is cancelled, the future *aw* is also cancelled." msgstr "" -#: ../../library/asyncio-task.rst:874 +#: ../../library/asyncio-task.rst:864 msgid "" "async def eternity():\n" " # Sleep for one hour\n" @@ -1235,119 +1235,119 @@ msgid "" "# timeout!" msgstr "" -#: ../../library/asyncio-task.rst:892 +#: ../../library/asyncio-task.rst:882 msgid "" "When *aw* is cancelled due to a timeout, ``wait_for`` waits for *aw* to be " "cancelled. Previously, it raised :exc:`TimeoutError` immediately." msgstr "" -#: ../../library/asyncio-task.rst:900 +#: ../../library/asyncio-task.rst:890 msgid "Raises :exc:`TimeoutError` instead of :exc:`asyncio.TimeoutError`." msgstr "引發 :exc:`TimeoutError` 而不是 :exc:`asyncio.TimeoutError`。" -#: ../../library/asyncio-task.rst:903 +#: ../../library/asyncio-task.rst:893 msgid "" "Implemented using :func:`asyncio.timeout`, a coroutine passed as *aw* is no " "longer wrapped in a :class:`Task` when *timeout* is positive." msgstr "" -#: ../../library/asyncio-task.rst:909 +#: ../../library/asyncio-task.rst:899 msgid "Waiting primitives" msgstr "" -#: ../../library/asyncio-task.rst:914 +#: ../../library/asyncio-task.rst:904 msgid "" "Run :class:`~asyncio.Future` and :class:`~asyncio.Task` instances in the " "*aws* iterable concurrently and block until the condition specified by " "*return_when*." msgstr "" -#: ../../library/asyncio-task.rst:918 +#: ../../library/asyncio-task.rst:908 msgid "The *aws* iterable must not be empty." msgstr "" -#: ../../library/asyncio-task.rst:920 +#: ../../library/asyncio-task.rst:910 msgid "Returns two sets of Tasks/Futures: ``(done, pending)``." msgstr "" -#: ../../library/asyncio-task.rst:922 +#: ../../library/asyncio-task.rst:912 msgid "Usage::" msgstr "用法: ::" -#: ../../library/asyncio-task.rst:924 +#: ../../library/asyncio-task.rst:914 msgid "done, pending = await asyncio.wait(aws)" msgstr "done, pending = await asyncio.wait(aws)" -#: ../../library/asyncio-task.rst:926 +#: ../../library/asyncio-task.rst:916 msgid "" "*timeout* (a float or int), if specified, can be used to control the maximum " "number of seconds to wait before returning." msgstr "" -#: ../../library/asyncio-task.rst:929 +#: ../../library/asyncio-task.rst:919 msgid "" "Note that this function does not raise :exc:`TimeoutError`. Futures or Tasks " "that aren't done when the timeout occurs are simply returned in the second " "set." msgstr "" -#: ../../library/asyncio-task.rst:933 +#: ../../library/asyncio-task.rst:923 msgid "" "*return_when* indicates when this function should return. It must be one of " "the following constants:" msgstr "" -#: ../../library/asyncio-task.rst:939 +#: ../../library/asyncio-task.rst:929 msgid "Constant" msgstr "常數" -#: ../../library/asyncio-task.rst:940 +#: ../../library/asyncio-task.rst:930 msgid "Description" msgstr "描述" -#: ../../library/asyncio-task.rst:943 +#: ../../library/asyncio-task.rst:933 msgid "The function will return when any future finishes or is cancelled." msgstr "" -#: ../../library/asyncio-task.rst:946 +#: ../../library/asyncio-task.rst:936 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`." msgstr "" -#: ../../library/asyncio-task.rst:951 +#: ../../library/asyncio-task.rst:941 msgid "The function will return when all futures finish or are cancelled." msgstr "" -#: ../../library/asyncio-task.rst:953 +#: ../../library/asyncio-task.rst:943 msgid "" "Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the futures " "when a timeout occurs." msgstr "" -#: ../../library/asyncio-task.rst:956 +#: ../../library/asyncio-task.rst:946 msgid "" "If ``wait()`` is cancelled, the futures in *aws* are not cancelled and " "continue to run." msgstr "" -#: ../../library/asyncio-task.rst:962 +#: ../../library/asyncio-task.rst:952 msgid "Passing coroutine objects to ``wait()`` directly is forbidden." msgstr "" -#: ../../library/asyncio-task.rst:965 ../../library/asyncio-task.rst:1027 +#: ../../library/asyncio-task.rst:955 ../../library/asyncio-task.rst:1017 msgid "Added support for generators yielding tasks." msgstr "" -#: ../../library/asyncio-task.rst:971 +#: ../../library/asyncio-task.rst:961 msgid "" "Run :ref:`awaitable objects ` in the *aws* iterable " "concurrently. The returned object can be iterated to obtain the results of " "the awaitables as they finish." msgstr "" -#: ../../library/asyncio-task.rst:975 +#: ../../library/asyncio-task.rst:965 msgid "" "The object returned by ``as_completed()`` can be iterated as an :term:" "`asynchronous iterator` or a plain :term:`iterator`. When asynchronous " @@ -1356,7 +1356,7 @@ msgid "" "tasks with their results. Example::" msgstr "" -#: ../../library/asyncio-task.rst:981 +#: ../../library/asyncio-task.rst:971 msgid "" "ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" "ipv6_connect = create_task(open_connection(\"::1\", 80))\n" @@ -1373,20 +1373,20 @@ msgid "" " print(\"IPv4 connection established.\")" msgstr "" -#: ../../library/asyncio-task.rst:995 +#: ../../library/asyncio-task.rst:985 msgid "" "During asynchronous iteration, implicitly-created tasks will be yielded for " "supplied awaitables that aren't tasks or futures." msgstr "" -#: ../../library/asyncio-task.rst:998 +#: ../../library/asyncio-task.rst:988 msgid "" "When used as a plain iterator, each iteration yields a new coroutine that " "returns the result or raises the exception of the next completed awaitable. " "This pattern is compatible with Python versions older than 3.13::" msgstr "" -#: ../../library/asyncio-task.rst:1002 +#: ../../library/asyncio-task.rst:992 msgid "" "ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" "ipv6_connect = create_task(open_connection(\"::1\", 80))\n" @@ -1399,41 +1399,41 @@ msgid "" " reader, writer = await next_connect" msgstr "" -#: ../../library/asyncio-task.rst:1012 +#: ../../library/asyncio-task.rst:1002 msgid "" "A :exc:`TimeoutError` is raised if the timeout occurs before all awaitables " "are done. This is raised by the ``async for`` loop during asynchronous " "iteration or by the coroutines yielded during plain iteration." msgstr "" -#: ../../library/asyncio-task.rst:1016 +#: ../../library/asyncio-task.rst:1006 msgid "" "``as_completed()`` does not cancel the tasks running the supplied " "awaitables: if a timeout occurs or the iteration is cancelled, the remaining " "tasks continue to run." msgstr "" -#: ../../library/asyncio-task.rst:1023 +#: ../../library/asyncio-task.rst:1013 msgid "" "Deprecation warning is emitted if not all awaitable objects in the *aws* " "iterable are Future-like objects and there is no running event loop." msgstr "" -#: ../../library/asyncio-task.rst:1030 +#: ../../library/asyncio-task.rst:1020 msgid "" "The result can now be used as either an :term:`asynchronous iterator` or as " "a plain :term:`iterator` (previously it was only a plain iterator)." msgstr "" -#: ../../library/asyncio-task.rst:1036 +#: ../../library/asyncio-task.rst:1026 msgid "Running in threads" msgstr "" -#: ../../library/asyncio-task.rst:1041 +#: ../../library/asyncio-task.rst:1031 msgid "Asynchronously run function *func* in a separate thread." msgstr "" -#: ../../library/asyncio-task.rst:1043 +#: ../../library/asyncio-task.rst:1033 msgid "" "Any \\*args and \\*\\*kwargs supplied for this function are directly passed " "to *func*. Also, the current :class:`contextvars.Context` is propagated, " @@ -1441,19 +1441,19 @@ msgid "" "separate thread." msgstr "" -#: ../../library/asyncio-task.rst:1048 +#: ../../library/asyncio-task.rst:1038 msgid "" "Return a coroutine that can be awaited to get the eventual result of *func*." msgstr "" -#: ../../library/asyncio-task.rst:1050 +#: ../../library/asyncio-task.rst:1040 msgid "" "This coroutine function is primarily intended to be used for executing IO-" "bound functions/methods that would otherwise block the event loop if they " "were run in the main thread. For example::" msgstr "" -#: ../../library/asyncio-task.rst:1054 +#: ../../library/asyncio-task.rst:1044 msgid "" "def blocking_io():\n" " print(f\"start blocking_io at {time.strftime('%X')}\")\n" @@ -1482,7 +1482,7 @@ msgid "" "# finished main at 19:50:54" msgstr "" -#: ../../library/asyncio-task.rst:1080 +#: ../../library/asyncio-task.rst:1070 msgid "" "Directly calling ``blocking_io()`` in any coroutine would block the event " "loop for its duration, resulting in an additional 1 second of run time. " @@ -1490,7 +1490,7 @@ msgid "" "thread without blocking the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1087 +#: ../../library/asyncio-task.rst:1077 msgid "" "Due to the :term:`GIL`, ``asyncio.to_thread()`` can typically only be used " "to make IO-bound functions non-blocking. However, for extension modules that " @@ -1498,27 +1498,27 @@ msgid "" "``asyncio.to_thread()`` can also be used for CPU-bound functions." msgstr "" -#: ../../library/asyncio-task.rst:1096 +#: ../../library/asyncio-task.rst:1086 msgid "Scheduling from other threads" msgstr "" -#: ../../library/asyncio-task.rst:1100 +#: ../../library/asyncio-task.rst:1090 msgid "Submit a coroutine to the given event loop. Thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:1102 +#: ../../library/asyncio-task.rst:1092 msgid "" "Return a :class:`concurrent.futures.Future` to wait for the result from " "another OS thread." msgstr "" -#: ../../library/asyncio-task.rst:1105 +#: ../../library/asyncio-task.rst:1095 msgid "" "This function is meant to be called from a different OS thread than the one " "where the event loop is running. Example::" msgstr "" -#: ../../library/asyncio-task.rst:1108 +#: ../../library/asyncio-task.rst:1098 msgid "" "def in_thread(loop: asyncio.AbstractEventLoop) -> None:\n" " # Run some blocking IO\n" @@ -1542,11 +1542,11 @@ msgid "" " await asyncio.to_thread(in_thread, loop)" msgstr "" -#: ../../library/asyncio-task.rst:1128 +#: ../../library/asyncio-task.rst:1118 msgid "It's also possible to run the other way around. Example::" msgstr "" -#: ../../library/asyncio-task.rst:1130 +#: ../../library/asyncio-task.rst:1120 msgid "" "@contextlib.contextmanager\n" "def loop_in_thread() -> Generator[asyncio.AbstractEventLoop]:\n" @@ -1582,13 +1582,13 @@ msgid "" " assert future.result(timeout=2) == 3" msgstr "" -#: ../../library/asyncio-task.rst:1162 +#: ../../library/asyncio-task.rst:1152 msgid "" "If an exception is raised in the coroutine, the returned Future will be " "notified. It can also be used to cancel the task in the event loop::" msgstr "" -#: ../../library/asyncio-task.rst:1166 +#: ../../library/asyncio-task.rst:1156 msgid "" "try:\n" " result = future.result(timeout)\n" @@ -1601,59 +1601,59 @@ msgid "" " print(f'The coroutine returned: {result!r}')" msgstr "" -#: ../../library/asyncio-task.rst:1176 +#: ../../library/asyncio-task.rst:1166 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." msgstr "" -#: ../../library/asyncio-task.rst:1179 +#: ../../library/asyncio-task.rst:1169 msgid "" "Unlike other asyncio functions this function requires the *loop* argument to " "be passed explicitly." msgstr "" -#: ../../library/asyncio-task.rst:1186 +#: ../../library/asyncio-task.rst:1176 msgid "Introspection" msgstr "" -#: ../../library/asyncio-task.rst:1191 +#: ../../library/asyncio-task.rst:1181 msgid "" "Return the currently running :class:`Task` instance, or ``None`` if no task " "is running." msgstr "" -#: ../../library/asyncio-task.rst:1194 +#: ../../library/asyncio-task.rst:1184 msgid "" "If *loop* is ``None`` :func:`get_running_loop` is used to get the current " "loop." msgstr "" -#: ../../library/asyncio-task.rst:1202 +#: ../../library/asyncio-task.rst:1192 msgid "Return a set of not yet finished :class:`Task` objects run by the loop." msgstr "" -#: ../../library/asyncio-task.rst:1205 +#: ../../library/asyncio-task.rst:1195 msgid "" "If *loop* is ``None``, :func:`get_running_loop` is used for getting current " "loop." msgstr "" -#: ../../library/asyncio-task.rst:1213 +#: ../../library/asyncio-task.rst:1203 msgid "Return ``True`` if *obj* is a coroutine object." msgstr "" -#: ../../library/asyncio-task.rst:1220 +#: ../../library/asyncio-task.rst:1210 msgid "Task object" msgstr "Task 物件" -#: ../../library/asyncio-task.rst:1224 +#: ../../library/asyncio-task.rst:1214 msgid "" "A :class:`Future-like ` object that runs a Python :ref:`coroutine " "`. Not thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:1227 +#: ../../library/asyncio-task.rst:1217 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 " @@ -1661,42 +1661,42 @@ msgid "" "wrapped coroutine resumes." msgstr "" -#: ../../library/asyncio-task.rst:1233 +#: ../../library/asyncio-task.rst:1223 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:1238 +#: ../../library/asyncio-task.rst:1228 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:1243 +#: ../../library/asyncio-task.rst:1233 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 " -"coroutine. If a coroutine is awaiting on a Future object during " -"cancellation, the Future object will be cancelled." +"coroutine. If a coroutine is awaiting on a future-like object during " +"cancellation, the awaited object will be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1248 +#: ../../library/asyncio-task.rst:1238 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." msgstr "" -#: ../../library/asyncio-task.rst:1253 +#: ../../library/asyncio-task.rst:1243 msgid "" ":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:1257 +#: ../../library/asyncio-task.rst:1247 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *coro* to run in. If no *context* is " @@ -1704,7 +1704,7 @@ msgid "" "in the copied context." msgstr "" -#: ../../library/asyncio-task.rst:1262 +#: ../../library/asyncio-task.rst:1252 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 " @@ -1714,102 +1714,102 @@ msgid "" "eagerly and will skip scheduling to the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1269 +#: ../../library/asyncio-task.rst:1259 msgid "" "Tasks are :ref:`generic ` over the return type of their wrapped " "coroutines." msgstr "" -#: ../../library/asyncio-task.rst:1272 +#: ../../library/asyncio-task.rst:1262 msgid "Added support for the :mod:`contextvars` module." msgstr "新增對 :mod:`contextvars` 模組的支援。" -#: ../../library/asyncio-task.rst:1278 +#: ../../library/asyncio-task.rst:1268 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "" -#: ../../library/asyncio-task.rst:1285 +#: ../../library/asyncio-task.rst:1275 msgid "Added the *eager_start* parameter." msgstr "新增 *eager_start* 參數。" -#: ../../library/asyncio-task.rst:1290 +#: ../../library/asyncio-task.rst:1280 msgid "Return ``True`` if the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1292 +#: ../../library/asyncio-task.rst:1282 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:1297 +#: ../../library/asyncio-task.rst:1287 msgid "Return the result of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1299 +#: ../../library/asyncio-task.rst:1289 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:1303 ../../library/asyncio-task.rst:1317 +#: ../../library/asyncio-task.rst:1293 ../../library/asyncio-task.rst:1307 msgid "" "If the Task has been *cancelled*, this method raises a :exc:`CancelledError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1306 +#: ../../library/asyncio-task.rst:1296 msgid "" "If the Task's result isn't yet available, this method raises an :exc:" "`InvalidStateError` exception." msgstr "" -#: ../../library/asyncio-task.rst:1311 +#: ../../library/asyncio-task.rst:1301 msgid "Return the exception of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1313 +#: ../../library/asyncio-task.rst:1303 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:1320 +#: ../../library/asyncio-task.rst:1310 msgid "" "If the Task isn't *done* yet, this method raises an :exc:`InvalidStateError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1325 +#: ../../library/asyncio-task.rst:1315 msgid "Add a callback to be run when the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1327 ../../library/asyncio-task.rst:1336 +#: ../../library/asyncio-task.rst:1317 ../../library/asyncio-task.rst:1326 msgid "This method should only be used in low-level callback-based code." msgstr "" -#: ../../library/asyncio-task.rst:1329 +#: ../../library/asyncio-task.rst:1319 msgid "" "See the documentation of :meth:`Future.add_done_callback` for more details." msgstr "" -#: ../../library/asyncio-task.rst:1334 +#: ../../library/asyncio-task.rst:1324 msgid "Remove *callback* from the callbacks list." msgstr "" -#: ../../library/asyncio-task.rst:1338 +#: ../../library/asyncio-task.rst:1328 msgid "" "See the documentation of :meth:`Future.remove_done_callback` for more " "details." msgstr "" -#: ../../library/asyncio-task.rst:1343 +#: ../../library/asyncio-task.rst:1333 msgid "Return the list of stack frames for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1345 +#: ../../library/asyncio-task.rst:1335 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, " @@ -1817,15 +1817,15 @@ msgid "" "this returns the list of traceback frames." msgstr "" -#: ../../library/asyncio-task.rst:1351 +#: ../../library/asyncio-task.rst:1341 msgid "The frames are always ordered from oldest to newest." msgstr "" -#: ../../library/asyncio-task.rst:1353 +#: ../../library/asyncio-task.rst:1343 msgid "Only one stack frame is returned for a suspended coroutine." msgstr "" -#: ../../library/asyncio-task.rst:1355 +#: ../../library/asyncio-task.rst:1345 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 " @@ -1834,87 +1834,87 @@ msgid "" "are returned. (This matches the behavior of the traceback module.)" msgstr "" -#: ../../library/asyncio-task.rst:1364 +#: ../../library/asyncio-task.rst:1354 msgid "Print the stack or traceback for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1366 +#: ../../library/asyncio-task.rst:1356 msgid "" "This produces output similar to that of the traceback module for the frames " "retrieved by :meth:`get_stack`." msgstr "" -#: ../../library/asyncio-task.rst:1369 +#: ../../library/asyncio-task.rst:1359 msgid "The *limit* argument is passed to :meth:`get_stack` directly." msgstr "" -#: ../../library/asyncio-task.rst:1371 +#: ../../library/asyncio-task.rst:1361 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:1376 +#: ../../library/asyncio-task.rst:1366 msgid "Return the coroutine object wrapped by the :class:`Task`." msgstr "" -#: ../../library/asyncio-task.rst:1380 +#: ../../library/asyncio-task.rst:1370 msgid "" "This will return ``None`` for Tasks which have already completed eagerly. " "See the :ref:`Eager Task Factory `." msgstr "" -#: ../../library/asyncio-task.rst:1387 +#: ../../library/asyncio-task.rst:1377 msgid "Newly added eager task execution means result may be ``None``." msgstr "" -#: ../../library/asyncio-task.rst:1391 +#: ../../library/asyncio-task.rst:1381 msgid "" "Return the :class:`contextvars.Context` object associated with the task." msgstr "" -#: ../../library/asyncio-task.rst:1398 +#: ../../library/asyncio-task.rst:1388 msgid "Return the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1400 +#: ../../library/asyncio-task.rst:1390 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:1408 +#: ../../library/asyncio-task.rst:1398 msgid "Set the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1410 +#: ../../library/asyncio-task.rst:1400 msgid "" "The *value* argument can be any object, which is then converted to a string." msgstr "" -#: ../../library/asyncio-task.rst:1413 +#: ../../library/asyncio-task.rst:1403 msgid "" "In the default Task implementation, the name will be visible in the :func:" "`repr` output of a task object." msgstr "" -#: ../../library/asyncio-task.rst:1420 +#: ../../library/asyncio-task.rst:1410 msgid "Request the Task to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1422 +#: ../../library/asyncio-task.rst:1412 msgid "" "If the Task is already *done* or *cancelled*, return ``False``, otherwise, " "return ``True``." msgstr "" -#: ../../library/asyncio-task.rst:1425 +#: ../../library/asyncio-task.rst:1415 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:1428 +#: ../../library/asyncio-task.rst:1418 msgid "" "The coroutine then has a chance to clean up or even deny the request by " "suppressing the exception with a :keyword:`try` ... ... ``except " @@ -1926,21 +1926,28 @@ msgid "" "addition to catching the exception." msgstr "" -#: ../../library/asyncio-task.rst:1438 +#: ../../library/asyncio-task.rst:1428 +msgid "" +"If the Task being cancelled is currently awaiting on a future-like object, " +"that awaited object will also be cancelled. This cancellation propagates " +"down the entire chain of awaited objects." +msgstr "" + +#: ../../library/asyncio-task.rst:1432 msgid "Added the *msg* parameter." msgstr "新增 *msg* 參數。" -#: ../../library/asyncio-task.rst:1441 +#: ../../library/asyncio-task.rst:1435 msgid "The ``msg`` parameter is propagated from cancelled task to its awaiter." msgstr "" -#: ../../library/asyncio-task.rst:1446 +#: ../../library/asyncio-task.rst:1440 msgid "" "The following example illustrates how coroutines can intercept the " "cancellation request::" msgstr "" -#: ../../library/asyncio-task.rst:1449 +#: ../../library/asyncio-task.rst:1443 msgid "" "async def cancel_me():\n" " print('cancel_me(): before sleep')\n" @@ -1977,32 +1984,32 @@ msgid "" "# main(): cancel_me is cancelled now" msgstr "" -#: ../../library/asyncio-task.rst:1485 +#: ../../library/asyncio-task.rst:1479 msgid "Return ``True`` if the Task is *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:1487 +#: ../../library/asyncio-task.rst:1481 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." msgstr "" -#: ../../library/asyncio-task.rst:1493 +#: ../../library/asyncio-task.rst:1487 msgid "Decrement the count of cancellation requests to this Task." msgstr "" -#: ../../library/asyncio-task.rst:1495 +#: ../../library/asyncio-task.rst:1489 msgid "Returns the remaining number of cancellation requests." msgstr "" -#: ../../library/asyncio-task.rst:1497 +#: ../../library/asyncio-task.rst:1491 msgid "" "Note that once execution of a cancelled task completed, further calls to :" "meth:`uncancel` are ineffective." msgstr "" -#: ../../library/asyncio-task.rst:1502 +#: ../../library/asyncio-task.rst:1496 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 " @@ -2011,7 +2018,7 @@ msgid "" "respective structured block. For example::" msgstr "" -#: ../../library/asyncio-task.rst:1509 +#: ../../library/asyncio-task.rst:1503 msgid "" "async def make_request_with_timeout():\n" " try:\n" @@ -2025,7 +2032,7 @@ msgid "" " await unrelated_code()" msgstr "" -#: ../../library/asyncio-task.rst:1520 +#: ../../library/asyncio-task.rst:1514 msgid "" "While the block with ``make_request()`` and ``make_another_request()`` might " "get cancelled due to the timeout, ``unrelated_code()`` should continue " @@ -2034,14 +2041,14 @@ msgid "" "similar fashion." msgstr "" -#: ../../library/asyncio-task.rst:1526 +#: ../../library/asyncio-task.rst:1520 msgid "" "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:1530 +#: ../../library/asyncio-task.rst:1524 msgid "" "When this method decrements the cancellation count to zero, the method " "checks if a previous :meth:`cancel` call had arranged for :exc:" @@ -2050,17 +2057,17 @@ msgid "" "``_must_cancel`` flag)." msgstr "" -#: ../../library/asyncio-task.rst:1536 +#: ../../library/asyncio-task.rst:1530 msgid "Changed to rescind pending cancellation requests upon reaching zero." msgstr "" -#: ../../library/asyncio-task.rst:1541 +#: ../../library/asyncio-task.rst:1535 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:1545 +#: ../../library/asyncio-task.rst:1539 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 " @@ -2069,12 +2076,24 @@ msgid "" "to zero." msgstr "" -#: ../../library/asyncio-task.rst:1551 +#: ../../library/asyncio-task.rst:1545 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." msgstr "" +#~ msgid "Expected output:" +#~ msgstr "預期的輸出: ::" + +#~ msgid "" +#~ "Task 1: start\n" +#~ "Task 2: start\n" +#~ "Task 1: done" +#~ msgstr "" +#~ "Task 1: start\n" +#~ "Task 2: start\n" +#~ "Task 1: done" + #~ msgid "" #~ "for coro in as_completed(aws):\n" #~ " earliest_result = await coro\n" diff --git a/library/asyncio-tools.po b/library/asyncio-tools.po index 32b7cc3be4b..a9b48be9748 100644 --- a/library/asyncio-tools.po +++ b/library/asyncio-tools.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-11 00:28+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -39,9 +39,11 @@ msgstr "" #: ../../library/asyncio-tools.rst:20 msgid "" -"$ python -m asyncio pstree PID\n" -"$ python -m asyncio ps PID" +"$ python -m asyncio pstree [--retries N] PID\n" +"$ python -m asyncio ps [--retries N] PID" msgstr "" +"$ python -m asyncio pstree [--retries N] PID\n" +"$ python -m asyncio ps [--retries N] PID" #: ../../library/asyncio-tools.rst:25 msgid "" @@ -221,3 +223,9 @@ msgid "" "play TaskGroup._aexit -> TaskGroup." "__aexit__ -> album TMBTE 0x10a439d70" msgstr "" + +#: ../../library/asyncio-tools.rst:154 +msgid "" +"Retry failed attempts to inspect the target process up to *N* times. This " +"can help when the target process changes while its state is being read." +msgstr "" diff --git a/library/atexit.po b/library/atexit.po index 4304a2a6e25..74567c6710c 100644 --- a/library/atexit.po +++ b/library/atexit.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-04 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2016-01-31 07:13+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,7 +22,7 @@ msgstr "" msgid ":mod:`!atexit` --- Exit handlers" msgstr ":mod:`!atexit` --- 退出處理函式" -#: ../../library/atexit.rst:12 +#: ../../library/atexit.rst:9 msgid "" "The :mod:`!atexit` module defines functions to register and unregister :dfn:" "`exit handlers`: functions that are automatically executed \"at exit\", that " @@ -31,7 +31,7 @@ msgid "" "term:`interpreter shutdown`." msgstr "" -#: ../../library/atexit.rst:18 +#: ../../library/atexit.rst:15 msgid "" "At exit, all registered exit handlers are called in the *reverse* order in " "which they were registered. If you register ``A``, ``B``, and ``C``, at " @@ -44,7 +44,7 @@ msgstr "" "``A`` 的順序執行。這邊做的假設是較低階的模組通常會在較高階模組之前被引入,因" "此較低階模組必須在比較後面才被清理。" -#: ../../library/atexit.rst:25 +#: ../../library/atexit.rst:22 msgid "" "If an exception is raised during execution of an exit handler, a traceback " "is printed (unless :exc:`SystemExit` is raised) and the exception " @@ -55,7 +55,7 @@ msgstr "" "發 :exc:`SystemExit`)並儲存例外資訊。在所有退出處理函式都有嘗試運作過後,將" "重新引發最後一個引發的例外。" -#: ../../library/atexit.rst:30 +#: ../../library/atexit.rst:27 msgid "" "In programs that use multiple interpreters, each interpreter has its own " "stack of exit handlers, which are executed when the interpreter shuts down " @@ -64,7 +64,7 @@ msgid "" "only affect the interpreter they are called from." msgstr "" -#: ../../library/atexit.rst:37 +#: ../../library/atexit.rst:34 msgid "" "**Note:** Exit handlers are not called when the program is killed by a " "signal not handled by Python, when a Python fatal internal error is " @@ -73,20 +73,20 @@ msgstr "" "**注意:**\\ 當程式被一個 Python 未處理的訊號終止、偵測到 Python 發生嚴重內部" "錯誤,或者 :func:`os._exit` 被呼叫時,退出處理函式就不會被呼叫。" -#: ../../library/atexit.rst:41 +#: ../../library/atexit.rst:38 msgid "" "**Note:** The effect of registering or unregistering functions from within a " "cleanup function is undefined." msgstr "**注意:**\\ 在清理函式中註冊或註銷函式的作用並未定義。" -#: ../../library/atexit.rst:45 +#: ../../library/atexit.rst:42 msgid "" "When writing exit handlers, especially in C API extensions, keep in mind " "that other exit handlers may still run arbitrary Python code after you clean " "up. Such code should succeed or fail with an exception, rather than crash." msgstr "" -#: ../../library/atexit.rst:50 +#: ../../library/atexit.rst:47 msgid "" "Attempts to start a new thread or :func:`os.fork` a new process in an exit " "handler now leads to :exc:`RuntimeError`. Previously, this could cause race " @@ -99,7 +99,7 @@ msgstr "" "緒狀態、而內部 :mod:`threading` 例程或新行程又嘗試使用該狀態時產生競態條件 " "(race condition),進而導致崩潰 (crash) 而非正常關閉。" -#: ../../library/atexit.rst:58 +#: ../../library/atexit.rst:55 msgid "" "When used with subinterpreters, registered functions are local to the " "interpreter they were registered in." @@ -107,7 +107,7 @@ msgstr "" "當與子直譯器 (subinterpreter) 一起使用時,已註冊函式對於它們所註冊的直譯器來" "說是區域的 (local)。" -#: ../../library/atexit.rst:64 +#: ../../library/atexit.rst:61 msgid "" "Register *func* as an exit handler. Any optional arguments that are to be " "passed to *func* must be passed as arguments to :func:`register`. It is " @@ -116,13 +116,13 @@ msgstr "" "將 *func* 註冊為退出處理函式。任何要傳遞給 *func* 的可選引數都必須作為引數傳" "遞給 :func:`register`。可以多次註冊相同的函式和引數。" -#: ../../library/atexit.rst:69 +#: ../../library/atexit.rst:66 msgid "" "This function returns *func*, which makes it possible to use it as a " "decorator." msgstr "該函式回傳 *func*,這使得可以將其作為裝飾器使用。" -#: ../../library/atexit.rst:74 +#: ../../library/atexit.rst:71 msgid "" "Remove *func* from the list of exit handlers. :func:`unregister` silently " "does nothing if *func* was not previously registered. If *func* has been " @@ -136,22 +136,22 @@ msgstr "" "在 :mod:`!atexit` 呼叫堆疊 (call stack) 中的所有存在都會被刪除。會在註銷期間" "於內部使用相等性比較 (``==``),因此函式參照不需要具有匹配的識別性。" -#: ../../library/atexit.rst:84 +#: ../../library/atexit.rst:81 msgid "Module :mod:`readline`" msgstr ":mod:`readline` 模組" -#: ../../library/atexit.rst:85 +#: ../../library/atexit.rst:82 msgid "" "Useful example of :mod:`!atexit` to read and write :mod:`readline` history " "files." msgstr "" ":mod:`!atexit` 用於讀取和寫入 :mod:`readline` 歷史檔案的一個不錯的範例。" -#: ../../library/atexit.rst:92 +#: ../../library/atexit.rst:89 msgid ":mod:`!atexit` Example" msgstr ":mod:`!atexit` 範例" -#: ../../library/atexit.rst:94 +#: ../../library/atexit.rst:91 msgid "" "The following simple example demonstrates how a module can initialize a " "counter from a file when it is imported and save the counter's updated value " @@ -161,7 +161,7 @@ msgstr "" "以下的簡單範例示範了模組如何在被引入時以檔案來初始化計數器,並在程式終止時自" "動儲存計數器的更新值,而不需要仰賴應用程式在終止時明確呼叫該模組。 ::" -#: ../../library/atexit.rst:99 +#: ../../library/atexit.rst:96 msgid "" "try:\n" " with open('counterfile') as infile:\n" @@ -199,7 +199,7 @@ msgstr "" "\n" "atexit.register(savecounter)" -#: ../../library/atexit.rst:117 +#: ../../library/atexit.rst:114 msgid "" "Positional and keyword arguments may also be passed to :func:`register` to " "be passed along to the registered function when it is called::" @@ -207,7 +207,7 @@ msgstr "" "位置引數和關鍵字引數也可以被傳遞給 :func:`register`,以便在呼叫時也傳遞給已註" "冊函式: ::" -#: ../../library/atexit.rst:120 +#: ../../library/atexit.rst:117 msgid "" "def goodbye(name, adjective):\n" " print('Goodbye %s, it was %s to meet you.' % (name, adjective))\n" @@ -227,11 +227,11 @@ msgstr "" "# 或是:\n" "atexit.register(goodbye, adjective='nice', name='Donny')" -#: ../../library/atexit.rst:129 +#: ../../library/atexit.rst:126 msgid "Usage as a :term:`decorator`::" msgstr "作為\\ :term:`裝飾器 `\\ 使用: ::" -#: ../../library/atexit.rst:131 +#: ../../library/atexit.rst:128 msgid "" "import atexit\n" "\n" @@ -245,7 +245,7 @@ msgstr "" "def goodbye():\n" " print('You are now leaving the Python sector.')" -#: ../../library/atexit.rst:137 +#: ../../library/atexit.rst:134 msgid "This only works with functions that can be called without arguments." msgstr "這只適用於可以不帶引數呼叫的函式。" diff --git a/library/base64.po b/library/base64.po index fa5ddb8cb90..65385c37122 100644 --- a/library/base64.po +++ b/library/base64.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-16 00:33+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -120,15 +120,23 @@ msgstr "" #: ../../library/base64.rst:66 msgid "" -"May assert or raise a :exc:`ValueError` if the length of *altchars* is not " -"2. Raises a :exc:`TypeError` if *altchars* is not a :term:`bytes-like " -"object`." +"If *padded* is true (default), pad the encoded data with the '=' character " +"to a size multiple of 4. If *padded* is false, do not add the pad characters." msgstr "" -"如果 *altchars* 的長度不是 2,可以斷言或引發 :exc:`ValueError`。如果 " -"*altchars* 不是\\ :term:`類位元組物件 `,則會引發 :exc:" -"`TypeError`。" -#: ../../library/base64.rst:72 +#: ../../library/base64.rst:70 ../../library/base64.rst:323 +msgid "" +"If *wrapcol* is non-zero, insert a newline (``b'\\n'``) character after at " +"most every *wrapcol* characters. If *wrapcol* is zero (default), do not " +"insert any newlines." +msgstr "" + +#: ../../library/base64.rst:74 ../../library/base64.rst:183 +#: ../../library/base64.rst:231 +msgid "Added the *padded* and *wrapcol* parameters." +msgstr "" + +#: ../../library/base64.rst:81 msgid "" "Decode the Base64 encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -136,7 +144,7 @@ msgstr "" "將經過 Base64 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII 字" "串 *s* 解碼,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:75 +#: ../../library/base64.rst:84 msgid "" "Optional *altchars* must be a :term:`bytes-like object` or ASCII string of " "length 2 which specifies the alternative alphabet used instead of the ``+`` " @@ -145,34 +153,74 @@ msgstr "" "可選的 *altchars* 必須是長度為 2 的\\ :term:`類位元組物件 `\\ 或 ASCII 字串,用於指定替代字母表,取代 ``+`` 和 ``/`` 字元。" -#: ../../library/base64.rst:79 +#: ../../library/base64.rst:88 +msgid "" +"If *padded* is true, the last group of 4 base 64 alphabet characters must be " +"padded with the '=' character. If *padded* is false, padding is neither " +"required nor recognized: the '=' character is not treated as padding but as " +"a non-alphabet character, which means it is silently discarded when " +"*validate* is false, or causes an :exc:`~binascii.Error` when *validate* is " +"true unless b'=' is included in *ignorechars*." +msgstr "" + +#: ../../library/base64.rst:96 msgid "" "A :exc:`binascii.Error` exception is raised if *s* is incorrectly padded." msgstr "如果 *s* 填充 (pad) 不正確,將引發 :exc:`binascii.Error` 例外。" -#: ../../library/base64.rst:82 +#: ../../library/base64.rst:99 msgid "" -"If *validate* is ``False`` (the default), characters that are neither in the " -"normal base-64 alphabet nor the alternative alphabet are discarded prior to " -"the padding check. If *validate* is ``True``, these non-alphabet characters " -"in the input result in a :exc:`binascii.Error`." +"If *ignorechars* is specified, it should be a :term:`bytes-like object` " +"containing characters to ignore from the input when *validate* is true. If " +"*ignorechars* contains the pad character ``'='``, the pad characters " +"presented before the end of the encoded data and the excess pad characters " +"will be ignored. The default value of *validate* is ``True`` if " +"*ignorechars* is specified, ``False`` otherwise." msgstr "" -"如果 *validate* 為 ``False``\\ (預設值),在 padding check(填充檢查)之前," -"不屬於標準 base-64 字母表和替代字母表的字元將被丟棄。如果 *validate* 為 " -"``True``,輸入中的這些非字母表字元將導致引發 :exc:`binascii.Error`。" -#: ../../library/base64.rst:88 +#: ../../library/base64.rst:107 +msgid "" +"If *validate* is false, characters that are neither in the normal base-64 " +"alphabet nor (if *ignorechars* is not specified) the alternative alphabet " +"are discarded prior to the padding check, but the ``+`` and ``/`` characters " +"keep their meaning if they are not in *altchars* (they will be discarded in " +"future Python versions)." +msgstr "" +"如果 *validate* 為 false,在 padding check(填充檢查)之前,既不屬於標準 " +"base-64 字母表、也不屬於替代字母表(若未指定 *ignorechars*)的字元將被丟棄," +"但如果 ``+`` 和 ``/`` 字元不在 *altchars* 中,它們仍保有原本的意義(在未來的 " +"Python 版本中將會被丟棄)。" + +#: ../../library/base64.rst:114 +msgid "" +"If *validate* is true, these non-alphabet characters in the input result in " +"a :exc:`binascii.Error`." +msgstr "" + +#: ../../library/base64.rst:117 +msgid "" +"If *canonical* is true, non-zero padding bits are rejected. See :func:" +"`binascii.a2b_base64` for details." +msgstr "" + +#: ../../library/base64.rst:120 msgid "" "For more information about the strict base64 check, see :func:`binascii." "a2b_base64`" msgstr "有關嚴格的 base64 檢查的更多資訊,請參閱 :func:`binascii.a2b_base64`。" -#: ../../library/base64.rst:90 +#: ../../library/base64.rst:122 ../../library/base64.rst:220 +#: ../../library/base64.rst:247 +msgid "Added the *canonical*, *ignorechars*, and *padded* parameters." +msgstr "" + +#: ../../library/base64.rst:125 msgid "" -"May assert or raise a :exc:`ValueError` if the length of *altchars* is not 2." -msgstr "如果 *altchars* 的長度不是 2,可能會斷言或引發 :exc:`ValueError`。" +"Accepting the ``+`` and ``/`` characters with an alternative alphabet is now " +"deprecated." +msgstr "" -#: ../../library/base64.rst:94 +#: ../../library/base64.rst:132 msgid "" "Encode :term:`bytes-like object` *s* using the standard Base64 alphabet and " "return the encoded :class:`bytes`." @@ -180,7 +228,7 @@ msgstr "" "使用標準 Base64 字母表對\\ :term:`類位元組物件 ` *s* 進行" "編碼,並回傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:100 +#: ../../library/base64.rst:138 msgid "" "Decode :term:`bytes-like object` or ASCII string *s* using the standard " "Base64 alphabet and return the decoded :class:`bytes`." @@ -188,18 +236,23 @@ msgstr "" "使用標準 Base64 字母表對\\ :term:`類位元組物件 `\\ 或 " "ASCII 字串 *s* 進行解碼,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:106 +#: ../../library/base64.rst:144 msgid "" "Encode :term:`bytes-like object` *s* using the URL- and filesystem-safe " "alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/" "`` in the standard Base64 alphabet, and return the encoded :class:`bytes`. " -"The result can still contain ``=``." +"The result can still contain ``=`` if *padded* is true (default)." msgstr "" "使用 URL 安全和檔案系統安全的字母表對\\ :term:`類位元組物件 ` *s* 進行編碼,該字母表將標準 Base64 字母表中的 ``+`` 替換為 ``-``," -"``/`` 替換為 ``_``,並回傳編碼後的 :class:`bytes`。結果仍可能包含 ``=``。" +"``/`` 替換為 ``_``,並回傳編碼後的 :class:`bytes`。如果 *padded* 為 true(預" +"設值),結果仍可能包含 ``=``。" -#: ../../library/base64.rst:115 +#: ../../library/base64.rst:150 +msgid "Added the *padded* parameter." +msgstr "" + +#: ../../library/base64.rst:156 msgid "" "Decode :term:`bytes-like object` or ASCII string *s* using the URL- and " "filesystem-safe alphabet, which substitutes ``-`` instead of ``+`` and ``_`` " @@ -210,7 +263,17 @@ msgstr "" "object>`\\ 或 ASCII 字串 *s* 進行解碼,該字母表將標準 Base64 字母表中的 " "``+`` 替換為 ``-``,``/`` 替換為 ``_``,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:124 +#: ../../library/base64.rst:162 +msgid "" +"Added the *padded* parameter. Padding of input is no longer required by " +"default." +msgstr "" + +#: ../../library/base64.rst:166 +msgid "Accepting the ``+`` and ``/`` characters is now deprecated." +msgstr "" + +#: ../../library/base64.rst:172 msgid "" "Encode the :term:`bytes-like object` *s* using Base32 and return the " "encoded :class:`bytes`." @@ -218,7 +281,21 @@ msgstr "" "使用 Base32 對\\ :term:`類位元組物件 ` *s* 進行編碼,並回" "傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:130 +#: ../../library/base64.rst:175 +msgid "" +"If *padded* is true (default), pad the encoded data with the '=' character " +"to a size multiple of 8. If *padded* is false, do not add the pad characters." +msgstr "" + +#: ../../library/base64.rst:179 ../../library/base64.rst:256 +#: ../../library/base64.rst:382 ../../library/base64.rst:421 +msgid "" +"If *wrapcol* is non-zero, insert a newline (``b'\\n'``) character after at " +"most every *wrapcol* characters. If *wrapcol* is zero (default), do not add " +"any newlines." +msgstr "" + +#: ../../library/base64.rst:189 msgid "" "Decode the Base32 encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -226,7 +303,7 @@ msgstr "" "解碼經過 Base32 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " "字串 *s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:133 ../../library/base64.rst:181 +#: ../../library/base64.rst:192 ../../library/base64.rst:269 msgid "" "Optional *casefold* is a flag specifying whether a lowercase alphabet is " "acceptable as input. For security purposes, the default is ``False``." @@ -234,7 +311,7 @@ msgstr "" "可選的 *casefold* 是一個是否接受小寫字母表作為輸入的旗標。出於安全性考量,預" "設值為 ``False``。" -#: ../../library/base64.rst:137 +#: ../../library/base64.rst:196 msgid "" ":rfc:`4648` allows for optional mapping of the digit 0 (zero) to the letter " "O (oh), and for optional mapping of the digit 1 (one) to either the letter I " @@ -249,14 +326,36 @@ msgstr "" "對映為哪個字母(當 *map01* 不為 ``None`` 時,數字 0 總是對映為字母 O)。出於" "安全性考量,預設值為 ``None``,因此不允許在輸入中使用數字 0 和 1。" -#: ../../library/base64.rst:144 ../../library/base64.rst:185 +#: ../../library/base64.rst:203 +msgid "" +"If *padded* is true, the last group of 8 base 32 alphabet characters must be " +"padded with the '=' character. If *padded* is false, padding is neither " +"required nor recognized: the '=' character is not treated as padding but as " +"a non-alphabet character, which means it raises an :exc:`~binascii.Error` " +"unless b'=' is included in *ignorechars*." +msgstr "" + +#: ../../library/base64.rst:210 ../../library/base64.rst:273 +#: ../../library/base64.rst:397 ../../library/base64.rst:439 +msgid "" +"*ignorechars* should be a :term:`bytes-like object` containing characters to " +"ignore from the input." +msgstr "" + +#: ../../library/base64.rst:213 +msgid "" +"If *canonical* is true, non-zero padding bits are rejected. See :func:" +"`binascii.a2b_base32` for details." +msgstr "" + +#: ../../library/base64.rst:216 ../../library/base64.rst:276 msgid "" "A :exc:`binascii.Error` is raised if *s* is incorrectly padded or if there " "are non-alphabet characters present in the input." msgstr "" "如果 *s* 的填充不正確或輸入中存在非字母表字元,將引發 :exc:`binascii.Error`。" -#: ../../library/base64.rst:151 +#: ../../library/base64.rst:226 msgid "" "Similar to :func:`b32encode` but uses the Extended Hex Alphabet, as defined " "in :rfc:`4648`." @@ -264,14 +363,14 @@ msgstr "" "類似於 :func:`b32encode`,但使用在 :rfc:`4648` 中定義的擴展十六進位字母表 " "(Extended Hex Alphabet)。" -#: ../../library/base64.rst:159 +#: ../../library/base64.rst:237 msgid "" "Similar to :func:`b32decode` but uses the Extended Hex Alphabet, as defined " "in :rfc:`4648`." msgstr "" "類似於 :func:`b32decode`,但使用在 :rfc:`4648` 中定義的擴展十六進位字母表。" -#: ../../library/base64.rst:162 +#: ../../library/base64.rst:240 msgid "" "This version does not allow the digit 0 (zero) to the letter O (oh) and " "digit 1 (one) to either the letter I (eye) or letter L (el) mappings, all " @@ -281,7 +380,7 @@ msgstr "" "這個版本不允許將數字 0 對映為字母 O ,以及將數字 1 對映為字母 I 或字母 L,所" "有這些字元都包含在擴展十六進位字母表中,並且不能互換使用。" -#: ../../library/base64.rst:172 +#: ../../library/base64.rst:253 msgid "" "Encode the :term:`bytes-like object` *s* using Base16 and return the " "encoded :class:`bytes`." @@ -289,7 +388,12 @@ msgstr "" "使用 Base16 對\\ :term:`類位元組物件 ` *s* 進行編碼,並回" "傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:178 +#: ../../library/base64.rst:260 ../../library/base64.rst:388 +#: ../../library/base64.rst:430 +msgid "Added the *wrapcol* parameter." +msgstr "" + +#: ../../library/base64.rst:266 msgid "" "Decode the Base16 encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -297,11 +401,15 @@ msgstr "" "解碼經過 Base16 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " "字串 *s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:192 +#: ../../library/base64.rst:280 +msgid "Added the *ignorechars* parameter." +msgstr "" + +#: ../../library/base64.rst:287 msgid "Base85 Encodings" msgstr "Base85 編碼" -#: ../../library/base64.rst:194 +#: ../../library/base64.rst:289 msgid "" "Base85 encoding is a family of algorithms which represent four bytes using " "five ASCII characters. Originally implemented in the Unix ``btoa(1)`` " @@ -310,51 +418,51 @@ msgid "" "its ``btoa`` and PDF variants, is implemented by :func:`a85encode`." msgstr "" -#: ../../library/base64.rst:201 +#: ../../library/base64.rst:296 msgid "" "A separate version, using a different output character set, was defined as " "an April Fool's joke in :rfc:`1924` but is now used by Git and other " "software. This version is implemented by :func:`b85encode`." msgstr "" -#: ../../library/base64.rst:205 +#: ../../library/base64.rst:300 msgid "" "Finally, a third version, using yet another output character set designed " "for safe inclusion in programming language strings, is defined by ZeroMQ and " "implemented here by :func:`z85encode`." msgstr "" -#: ../../library/base64.rst:209 +#: ../../library/base64.rst:304 msgid "" "The functions present in this module differ in how they handle the following:" msgstr "" -#: ../../library/base64.rst:211 +#: ../../library/base64.rst:306 msgid "Whether to include and expect enclosing ``<~`` and ``~>`` markers." msgstr "" -#: ../../library/base64.rst:212 +#: ../../library/base64.rst:307 msgid "Whether to fold the input into multiple lines." msgstr "" -#: ../../library/base64.rst:213 +#: ../../library/base64.rst:308 msgid "The set of ASCII characters used for encoding." msgstr "" -#: ../../library/base64.rst:214 +#: ../../library/base64.rst:309 msgid "Compact encodings of sequences of spaces and null bytes." msgstr "" -#: ../../library/base64.rst:215 +#: ../../library/base64.rst:310 msgid "The encoding of zero-padding bytes applied to the input." msgstr "" -#: ../../library/base64.rst:217 +#: ../../library/base64.rst:312 msgid "" "Refer to the documentation of the individual functions for more information." msgstr "" -#: ../../library/base64.rst:221 +#: ../../library/base64.rst:316 msgid "" "Encode the :term:`bytes-like object` *b* using Ascii85 and return the " "encoded :class:`bytes`." @@ -362,7 +470,7 @@ msgstr "" "使用 Ascii85 對\\ :term:`類位元組物件 ` *b* 進行編碼,並回" "傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:224 +#: ../../library/base64.rst:319 msgid "" "*foldspaces* is an optional flag that uses the special short sequence 'y' " "instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This " @@ -372,16 +480,7 @@ msgstr "" "(ASCII 0x20),這是由 'btoa' 支援的功能。這個特性不被 PDF 中使用的標準編碼所支" "援。" -#: ../../library/base64.rst:228 -msgid "" -"*wrapcol* controls whether the output should have newline (``b'\\n'``) " -"characters added to it. If this is non-zero, each output line will be at " -"most this many characters long, excluding the trailing newline." -msgstr "" -"*wrapcol* 控制輸出是否應該包含換行字元 (``b'\\n'``) 。如果這個值不為零,每行" -"輸出的長度將不超過這個字元長度(不包含後面的換行符號)。" - -#: ../../library/base64.rst:232 +#: ../../library/base64.rst:327 msgid "" "*pad* controls whether zero-padding applied to the end of the input is fully " "retained in the output encoding, as done by ``btoa``, producing an exact " @@ -389,7 +488,7 @@ msgid "" "used in PDF, as it does not preserve the length of the data." msgstr "" -#: ../../library/base64.rst:238 +#: ../../library/base64.rst:333 msgid "" "*adobe* controls whether the encoded byte sequence is framed with ``<~`` and " "``~>``, as in a PostScript base-85 string literal. Note that while " @@ -397,7 +496,7 @@ msgid "" "they *must not* use a leading ``<~``." msgstr "" -#: ../../library/base64.rst:248 +#: ../../library/base64.rst:343 msgid "" "Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and " "return the decoded :class:`bytes`." @@ -405,7 +504,7 @@ msgstr "" "解碼經過 Ascii85 編碼的\\ :term:`類位元組物件 `\\ 或 " "ASCII 字串 *b*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:251 +#: ../../library/base64.rst:346 msgid "" "*foldspaces* is a flag that specifies whether the 'y' short sequence should " "be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature " @@ -415,23 +514,36 @@ msgstr "" "0x20) 的簡寫。這個功能不受 PDF 和 PostScript 中使用的標準 Ascii85 編碼的支" "援。" -#: ../../library/base64.rst:256 +#: ../../library/base64.rst:351 msgid "" "*adobe* controls whether the ``<~`` and ``~>`` markers are present. While " "the leading ``<~`` is not required, the input must end with ``~>``, or a :" "exc:`ValueError` is raised." msgstr "" -#: ../../library/base64.rst:260 +#: ../../library/base64.rst:355 +msgid "" +"*ignorechars* should be a :term:`bytes-like object` containing characters to " +"ignore from the input. This should only contain whitespace characters, and " +"by default contains all whitespace characters in ASCII." +msgstr "" +"*ignorechars* 應是一個包含要從輸入中忽略的字元的\\ :term:`類位元組物件 " +"`。這應該只包含空白字元,預設情況下包含 ASCII 中的所有空白" +"字元。" + +#: ../../library/base64.rst:360 +msgid "" +"If *canonical* is true, non-canonical encodings are rejected. See :func:" +"`binascii.a2b_ascii85` for details." +msgstr "" + +#: ../../library/base64.rst:365 msgid "" -"*ignorechars* should be a byte string containing characters to ignore from " -"the input. This should only contain whitespace characters, and by default " -"contains all whitespace characters in ASCII." +"Added the *canonical* parameter. Single-character final groups are now " +"always rejected as encoding violations." msgstr "" -"*ignorechars* 應是一個包含要從輸入中忽略的字元的位元組字串。這只包含空格字" -"元,預設情況下包含 ASCII 中的所有空格字元。" -#: ../../library/base64.rst:269 +#: ../../library/base64.rst:373 msgid "" "Encode the :term:`bytes-like object` *b* using base85 (as used in e.g. git-" "style binary diffs) and return the encoded :class:`bytes`." @@ -439,7 +551,7 @@ msgstr "" "使用 Base85(例如,git 風格的二進位差異 (binary diff))對\\ :term:`類位元組物" "件 ` *b* 進行編碼,並回傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:272 +#: ../../library/base64.rst:376 msgid "" "The input is padded with ``b'\\0'`` so its length is a multiple of 4 bytes " "before encoding. If *pad* is true, all the resulting characters are " @@ -447,7 +559,7 @@ msgid "" "the length of the data may not be preserved on decoding." msgstr "" -#: ../../library/base64.rst:283 +#: ../../library/base64.rst:394 msgid "" "Decode the base85-encoded :term:`bytes-like object` or ASCII string *b* and " "return the decoded :class:`bytes`." @@ -455,7 +567,19 @@ msgstr "" "解碼經過 base85 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII " "字串 *b*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:291 +#: ../../library/base64.rst:400 ../../library/base64.rst:442 +msgid "" +"If *canonical* is true, non-canonical encodings are rejected. See :func:" +"`binascii.a2b_base85` for details." +msgstr "" + +#: ../../library/base64.rst:405 ../../library/base64.rst:447 +msgid "" +"Added the *canonical* and *ignorechars* parameters. Single-character final " +"groups are now always rejected as encoding violations." +msgstr "" + +#: ../../library/base64.rst:413 msgid "" "Encode the :term:`bytes-like object` *s* using Z85 (as used in ZeroMQ) and " "return the encoded :class:`bytes`." @@ -463,15 +587,19 @@ msgstr "" "使用 Z85(如用於 ZeroMQ)對\\ :term:`類位元組物件 ` *s* 進" "行編碼,並回傳編碼後的 :class:`bytes`。" -#: ../../library/base64.rst:294 +#: ../../library/base64.rst:416 msgid "" -"The `ZeroMQ specification `_ requires the " -"length of Z85-encoded data to be a multiple of 5 bytes. To produce compliant " -"data frames, you must pad the input data to this function to a multiple of 4 " -"bytes." +"The input is padded with ``b'\\0'`` so its length is a multiple of 4 bytes " +"before encoding. If *pad* is true, all the resulting characters are " +"retained in the output, which will always be a multiple of 5 bytes, as " +"required by the ZeroMQ standard." msgstr "" -#: ../../library/base64.rst:304 +#: ../../library/base64.rst:427 +msgid "The *pad* parameter was added." +msgstr "" + +#: ../../library/base64.rst:436 msgid "" "Decode the Z85-encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." @@ -479,11 +607,11 @@ msgstr "" "解碼經 Z85 編碼的\\ :term:`類位元組物件 `\\ 或 ASCII 字串 " "*s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:313 +#: ../../library/base64.rst:456 msgid "Legacy Interface" msgstr "舊版介面" -#: ../../library/base64.rst:317 +#: ../../library/base64.rst:460 msgid "" "Decode the contents of the binary *input* file and write the resulting " "binary data to the *output* file. *input* and *output* must be :term:`file " @@ -494,7 +622,7 @@ msgstr "" "*input* 和 *output* 必須是\\ :term:`檔案物件 `。*input* 將被讀" "取,直到 ``input.readline()`` 回傳一個空的 bytes 物件為止。" -#: ../../library/base64.rst:325 +#: ../../library/base64.rst:468 msgid "" "Decode the :term:`bytes-like object` *s*, which must contain one or more " "lines of base64 encoded data, and return the decoded :class:`bytes`." @@ -502,7 +630,7 @@ msgstr "" "解碼必須包含一行或多行的 base64 編碼資料\\ :term:`類位元組物件 ` *s*,並回傳解碼後的 :class:`bytes`。" -#: ../../library/base64.rst:333 +#: ../../library/base64.rst:476 msgid "" "Encode the contents of the binary *input* file and write the resulting " "base64 encoded data to the *output* file. *input* and *output* must be :term:" @@ -517,7 +645,7 @@ msgstr "" "出的每 76 個位元組之後插入一個換行字元 (``b'\\n'``),並確保輸出始終以換行字元" "結尾,符合 :rfc:`2045` (MIME) 的規定。" -#: ../../library/base64.rst:343 +#: ../../library/base64.rst:486 msgid "" "Encode the :term:`bytes-like object` *s*, which can contain arbitrary binary " "data, and return :class:`bytes` containing the base64-encoded data, with " @@ -528,15 +656,15 @@ msgstr "" "碼,並回傳包含 base64 編碼資料 :class:`bytes`,在每 76 個輸出位元組後插入換行" "字元 (``b'\\n'``) ,並確保有尾隨換行字元,符合 :rfc:`2045` (MIME) 的規定。" -#: ../../library/base64.rst:351 +#: ../../library/base64.rst:494 msgid "An example usage of the module:" msgstr "模組的一個範例用法:" -#: ../../library/base64.rst:364 +#: ../../library/base64.rst:507 msgid "Security Considerations" msgstr "安全性注意事項" -#: ../../library/base64.rst:366 +#: ../../library/base64.rst:509 msgid "" "A new security considerations section was added to :rfc:`4648` (section 12); " "it's recommended to review the security section for any code deployed to " @@ -545,18 +673,18 @@ msgstr "" ":rfc:`4648`\\ (第 12 節)中添加了一個新的安全性考量部分;建議對部署到正式環" "境的任何程式碼進行安全性部分的審查。" -#: ../../library/base64.rst:371 +#: ../../library/base64.rst:514 msgid "Module :mod:`binascii`" msgstr ":mod:`binascii` 模組" -#: ../../library/base64.rst:372 +#: ../../library/base64.rst:515 msgid "" "Support module containing ASCII-to-binary and binary-to-ASCII conversions." msgstr "" "支援模組中包含 ASCII 到二進位 (ASCII-to-binary) 和二進位到 ASCII (binary-to-" "ASCII) 的轉換功能。" -#: ../../library/base64.rst:374 +#: ../../library/base64.rst:517 msgid "" ":rfc:`1521` - MIME (Multipurpose Internet Mail Extensions) Part One: " "Mechanisms for Specifying and Describing the Format of Internet Message " @@ -565,20 +693,20 @@ msgstr "" ":rfc:`1521` - MIME(多用途網際網路郵件擴展)第一部分:指定和描述網際網路主體" "格式的機制。" -#: ../../library/base64.rst:375 +#: ../../library/base64.rst:518 msgid "" "Section 5.2, \"Base64 Content-Transfer-Encoding,\" provides the definition " "of the base64 encoding." msgstr "" "第 5.2 節,\"Base64 Content-Transfer-Encoding\",提供了 base64 編碼的定義。" -#: ../../library/base64.rst:378 +#: ../../library/base64.rst:521 msgid "" "`ISO 32000-2 Portable document format - Part 2: PDF 2.0 `_" msgstr "" -#: ../../library/base64.rst:379 +#: ../../library/base64.rst:522 msgid "" "Section 7.4.3, \"ASCII85Decode Filter,\" provides the definition of the " "Ascii85 encoding used in PDF and PostScript, including the output character " @@ -586,11 +714,11 @@ msgid "" "partial output groups." msgstr "" -#: ../../library/base64.rst:384 +#: ../../library/base64.rst:527 msgid "`ZeroMQ RFC 32/Z85 `_" msgstr "" -#: ../../library/base64.rst:385 +#: ../../library/base64.rst:528 msgid "" "The \"Formal Specification\" section provides the character set used in Z85." msgstr "" @@ -611,6 +739,28 @@ msgstr "MIME" msgid "base64 encoding" msgstr "base64 encoding(base64 編碼)" +#~ msgid "" +#~ "May assert or raise a :exc:`ValueError` if the length of *altchars* is " +#~ "not 2. Raises a :exc:`TypeError` if *altchars* is not a :term:`bytes-" +#~ "like object`." +#~ msgstr "" +#~ "如果 *altchars* 的長度不是 2,可以斷言或引發 :exc:`ValueError`。如果 " +#~ "*altchars* 不是\\ :term:`類位元組物件 `,則會引發 :exc:" +#~ "`TypeError`。" + +#~ msgid "" +#~ "May assert or raise a :exc:`ValueError` if the length of *altchars* is " +#~ "not 2." +#~ msgstr "如果 *altchars* 的長度不是 2,可能會斷言或引發 :exc:`ValueError`。" + +#~ msgid "" +#~ "*wrapcol* controls whether the output should have newline (``b'\\n'``) " +#~ "characters added to it. If this is non-zero, each output line will be at " +#~ "most this many characters long, excluding the trailing newline." +#~ msgstr "" +#~ "*wrapcol* 控制輸出是否應該包含換行字元 (``b'\\n'``) 。如果這個值不為零,每" +#~ "行輸出的長度將不超過這個字元長度(不包含後面的換行符號)。" + #~ msgid "" #~ "*pad* controls whether the input is padded to a multiple of 4 before " #~ "encoding. Note that the ``btoa`` implementation always pads." diff --git a/library/bdb.po b/library/bdb.po index 27843f5fbb4..964d3fa0242 100644 --- a/library/bdb.po +++ b/library/bdb.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -276,36 +276,22 @@ msgstr "" msgid "``\"exception\"``: An exception has occurred." msgstr "" -#: ../../library/bdb.rst:195 -msgid "``\"c_call\"``: A C function is about to be called." -msgstr "" - #: ../../library/bdb.rst:196 -msgid "``\"c_return\"``: A C function has returned." +msgid "For all the events, specialized functions (see below) are called." msgstr "" -#: ../../library/bdb.rst:197 -msgid "``\"c_exception\"``: A C function has raised an exception." -msgstr "" - -#: ../../library/bdb.rst:199 -msgid "" -"For the Python events, specialized functions (see below) are called. For " -"the C events, no action is taken." -msgstr "" - -#: ../../library/bdb.rst:202 +#: ../../library/bdb.rst:198 msgid "The *arg* parameter depends on the previous event." msgstr "" -#: ../../library/bdb.rst:204 +#: ../../library/bdb.rst:200 msgid "" "See the documentation for :func:`sys.settrace` for more information on the " "trace function. For more information on code and frame objects, refer to :" "ref:`types`." msgstr "" -#: ../../library/bdb.rst:210 +#: ../../library/bdb.rst:206 msgid "" "If the debugger should stop on the current line, invoke the :meth:" "`user_line` method (which should be overridden in subclasses). Raise a :exc:" @@ -314,7 +300,7 @@ msgid "" "`trace_dispatch` method for further tracing in that scope." msgstr "" -#: ../../library/bdb.rst:218 +#: ../../library/bdb.rst:214 msgid "" "If the debugger should stop on this function call, invoke the :meth:" "`user_call` method (which should be overridden in subclasses). Raise a :exc:" @@ -323,7 +309,7 @@ msgid "" "`trace_dispatch` method for further tracing in that scope." msgstr "" -#: ../../library/bdb.rst:226 +#: ../../library/bdb.rst:222 msgid "" "If the debugger should stop on this function return, invoke the :meth:" "`user_return` method (which should be overridden in subclasses). Raise a :" @@ -332,7 +318,7 @@ msgid "" "meth:`trace_dispatch` method for further tracing in that scope." msgstr "" -#: ../../library/bdb.rst:234 +#: ../../library/bdb.rst:230 msgid "" "If the debugger should stop at this exception, invokes the :meth:" "`user_exception` method (which should be overridden in subclasses). Raise a :" @@ -341,164 +327,164 @@ msgid "" "meth:`trace_dispatch` method for further tracing in that scope." msgstr "" -#: ../../library/bdb.rst:240 +#: ../../library/bdb.rst:236 msgid "" "Normally derived classes don't override the following methods, but they may " "if they want to redefine the definition of stopping and breakpoints." msgstr "" -#: ../../library/bdb.rst:245 +#: ../../library/bdb.rst:241 msgid "Return ``True`` if *module_name* matches any skip pattern." msgstr "" -#: ../../library/bdb.rst:249 +#: ../../library/bdb.rst:245 msgid "Return ``True`` if *frame* is below the starting frame in the stack." msgstr "" -#: ../../library/bdb.rst:253 +#: ../../library/bdb.rst:249 msgid "Return ``True`` if there is an effective breakpoint for this line." msgstr "" -#: ../../library/bdb.rst:255 +#: ../../library/bdb.rst:251 msgid "" "Check whether a line or function breakpoint exists and is in effect. Delete " "temporary breakpoints based on information from :func:`effective`." msgstr "" -#: ../../library/bdb.rst:260 +#: ../../library/bdb.rst:256 msgid "Return ``True`` if any breakpoint exists for *frame*'s filename." msgstr "" -#: ../../library/bdb.rst:262 +#: ../../library/bdb.rst:258 msgid "" "Derived classes should override these methods to gain control over debugger " "operation." msgstr "" -#: ../../library/bdb.rst:267 +#: ../../library/bdb.rst:263 msgid "" "Called from :meth:`dispatch_call` if a break might stop inside the called " "function." msgstr "" -#: ../../library/bdb.rst:270 +#: ../../library/bdb.rst:266 msgid "" "*argument_list* is not used anymore and will always be ``None``. The " "argument is kept for backwards compatibility." msgstr "" -#: ../../library/bdb.rst:275 +#: ../../library/bdb.rst:271 msgid "" "Called from :meth:`dispatch_line` when either :meth:`stop_here` or :meth:" "`break_here` returns ``True``." msgstr "" -#: ../../library/bdb.rst:280 +#: ../../library/bdb.rst:276 msgid "" "Called from :meth:`dispatch_return` when :meth:`stop_here` returns ``True``." msgstr "" -#: ../../library/bdb.rst:284 +#: ../../library/bdb.rst:280 msgid "" "Called from :meth:`dispatch_exception` when :meth:`stop_here` returns " "``True``." msgstr "" -#: ../../library/bdb.rst:289 +#: ../../library/bdb.rst:285 msgid "Handle how a breakpoint must be removed when it is a temporary one." msgstr "" -#: ../../library/bdb.rst:291 +#: ../../library/bdb.rst:287 msgid "This method must be implemented by derived classes." msgstr "" -#: ../../library/bdb.rst:294 +#: ../../library/bdb.rst:290 msgid "" "Derived classes and clients can call the following methods to affect the " "stepping state." msgstr "" -#: ../../library/bdb.rst:299 +#: ../../library/bdb.rst:295 msgid "Stop after one line of code." msgstr "" -#: ../../library/bdb.rst:303 +#: ../../library/bdb.rst:299 msgid "Stop on the next line in or below the given frame." msgstr "" -#: ../../library/bdb.rst:307 +#: ../../library/bdb.rst:303 msgid "Stop when returning from the given frame." msgstr "" -#: ../../library/bdb.rst:311 +#: ../../library/bdb.rst:307 msgid "" "Stop when the line with the *lineno* greater than the current one is reached " "or when returning from current frame." msgstr "" -#: ../../library/bdb.rst:316 +#: ../../library/bdb.rst:312 msgid "" "Start debugging from *frame*. If *frame* is not specified, debugging starts " "from caller's frame." msgstr "" -#: ../../library/bdb.rst:319 +#: ../../library/bdb.rst:315 msgid "" ":func:`set_trace` will enter the debugger immediately, rather than on the " "next line of code to be executed." msgstr "" -#: ../../library/bdb.rst:325 +#: ../../library/bdb.rst:321 msgid "" "Stop only at breakpoints or when finished. If there are no breakpoints, set " "the system trace function to ``None``." msgstr "" -#: ../../library/bdb.rst:332 +#: ../../library/bdb.rst:328 msgid "" "Set the :attr:`!quitting` attribute to ``True``. This raises :exc:`BdbQuit` " "in the next call to one of the :meth:`!dispatch_\\*` methods." msgstr "" -#: ../../library/bdb.rst:336 +#: ../../library/bdb.rst:332 msgid "" "Derived classes and clients can call the following methods to manipulate " "breakpoints. These methods return a string containing an error message if " "something went wrong, or ``None`` if all is well." msgstr "" -#: ../../library/bdb.rst:342 +#: ../../library/bdb.rst:338 msgid "" "Set a new breakpoint. If the *lineno* line doesn't exist for the *filename* " "passed as argument, return an error message. The *filename* should be in " "canonical form, as described in the :meth:`canonic` method." msgstr "" -#: ../../library/bdb.rst:348 +#: ../../library/bdb.rst:344 msgid "" "Delete the breakpoints in *filename* and *lineno*. If none were set, return " "an error message." msgstr "" -#: ../../library/bdb.rst:353 +#: ../../library/bdb.rst:349 msgid "" "Delete the breakpoint which has the index *arg* in the :attr:`Breakpoint." "bpbynumber`. If *arg* is not numeric or out of range, return an error " "message." msgstr "" -#: ../../library/bdb.rst:359 +#: ../../library/bdb.rst:355 msgid "" "Delete all breakpoints in *filename*. If none were set, return an error " "message." msgstr "" -#: ../../library/bdb.rst:364 +#: ../../library/bdb.rst:360 msgid "" "Delete all existing breakpoints. If none were set, return an error message." msgstr "" -#: ../../library/bdb.rst:369 +#: ../../library/bdb.rst:365 msgid "" "Return a breakpoint specified by the given number. If *arg* is a string, it " "will be converted to a number. If *arg* is a non-numeric string, if the " @@ -506,39 +492,39 @@ msgid "" "raised." msgstr "" -#: ../../library/bdb.rst:378 +#: ../../library/bdb.rst:374 msgid "Return ``True`` if there is a breakpoint for *lineno* in *filename*." msgstr "" -#: ../../library/bdb.rst:382 +#: ../../library/bdb.rst:378 msgid "" "Return all breakpoints for *lineno* in *filename*, or an empty list if none " "are set." msgstr "" -#: ../../library/bdb.rst:387 +#: ../../library/bdb.rst:383 msgid "Return all breakpoints in *filename*, or an empty list if none are set." msgstr "" -#: ../../library/bdb.rst:391 +#: ../../library/bdb.rst:387 msgid "Return all breakpoints that are set." msgstr "" -#: ../../library/bdb.rst:394 +#: ../../library/bdb.rst:390 msgid "" "Derived classes and clients can call the following methods to disable and " "restart events to achieve better performance. These methods only work when " "using the ``'monitoring'`` backend." msgstr "" -#: ../../library/bdb.rst:400 +#: ../../library/bdb.rst:396 msgid "" "Disable the current event until the next time :func:`restart_events` is " "called. This is helpful when the debugger is not interested in the current " "line." msgstr "" -#: ../../library/bdb.rst:408 +#: ../../library/bdb.rst:404 msgid "" "Restart all the disabled events. This function is automatically called in " "``dispatch_*`` methods after ``user_*`` methods are called. If the " @@ -546,85 +532,85 @@ msgid "" "restarted after each user interaction." msgstr "" -#: ../../library/bdb.rst:416 +#: ../../library/bdb.rst:412 msgid "" "Derived classes and clients can call the following methods to get a data " "structure representing a stack trace." msgstr "" -#: ../../library/bdb.rst:421 +#: ../../library/bdb.rst:417 msgid "Return a list of (frame, lineno) tuples in a stack trace, and a size." msgstr "" -#: ../../library/bdb.rst:423 +#: ../../library/bdb.rst:419 msgid "" "The most recently called frame is last in the list. The size is the number " "of frames below the frame where the debugger was invoked." msgstr "" -#: ../../library/bdb.rst:428 +#: ../../library/bdb.rst:424 msgid "" "Return a string with information about a stack entry, which is a ``(frame, " "lineno)`` tuple. The return string contains:" msgstr "" -#: ../../library/bdb.rst:431 +#: ../../library/bdb.rst:427 msgid "The canonical filename which contains the frame." msgstr "" -#: ../../library/bdb.rst:432 +#: ../../library/bdb.rst:428 msgid "The function name or ``\"\"``." msgstr "函式名稱或 ``\"\"``。" -#: ../../library/bdb.rst:433 +#: ../../library/bdb.rst:429 msgid "The input arguments." msgstr "輸入引數。" -#: ../../library/bdb.rst:434 +#: ../../library/bdb.rst:430 msgid "The return value." msgstr "回傳值。" -#: ../../library/bdb.rst:435 +#: ../../library/bdb.rst:431 msgid "The line of code (if it exists)." msgstr "" -#: ../../library/bdb.rst:438 +#: ../../library/bdb.rst:434 msgid "" "The following two methods can be called by clients to use a debugger to " "debug a :term:`statement`, given as a string." msgstr "" -#: ../../library/bdb.rst:443 +#: ../../library/bdb.rst:439 msgid "" "Debug a statement executed via the :func:`exec` function. *globals* " "defaults to :attr:`!__main__.__dict__`, *locals* defaults to *globals*." msgstr "" -#: ../../library/bdb.rst:448 +#: ../../library/bdb.rst:444 msgid "" "Debug an expression executed via the :func:`eval` function. *globals* and " "*locals* have the same meaning as in :meth:`run`." msgstr "" -#: ../../library/bdb.rst:453 +#: ../../library/bdb.rst:449 msgid "For backwards compatibility. Calls the :meth:`run` method." msgstr "" -#: ../../library/bdb.rst:457 +#: ../../library/bdb.rst:453 msgid "Debug a single function call, and return its result." msgstr "" -#: ../../library/bdb.rst:460 +#: ../../library/bdb.rst:456 msgid "Finally, the module defines the following functions:" msgstr "最後,這個模組定義了以下函式:" -#: ../../library/bdb.rst:464 +#: ../../library/bdb.rst:460 msgid "" "Return ``True`` if we should break here, depending on the way the :class:" "`Breakpoint` *b* was set." msgstr "" -#: ../../library/bdb.rst:467 +#: ../../library/bdb.rst:463 msgid "" "If it was set via line number, it checks if :attr:`b.line ` is the same as the one in *frame*. If the breakpoint was set via :" @@ -633,13 +619,13 @@ msgid "" "line." msgstr "" -#: ../../library/bdb.rst:476 +#: ../../library/bdb.rst:472 msgid "" "Return ``(active breakpoint, delete temporary flag)`` or ``(None, None)`` as " "the breakpoint to act upon." msgstr "" -#: ../../library/bdb.rst:479 +#: ../../library/bdb.rst:475 msgid "" "The *active breakpoint* is the first entry in :attr:`bplist ` for the (:attr:`file `, :attr:`line ` count is ignored)." msgstr "" -#: ../../library/bdb.rst:490 +#: ../../library/bdb.rst:486 msgid "If no such entry exists, then ``(None, None)`` is returned." msgstr "" -#: ../../library/bdb.rst:495 +#: ../../library/bdb.rst:491 msgid "Start debugging with a :class:`Bdb` instance from caller's frame." msgstr "" -#: ../../library/bdb.rst:330 +#: ../../library/bdb.rst:326 msgid "quitting (bdb.Bdb attribute)" msgstr "" diff --git a/library/binascii.po b/library/binascii.po index 90ebfaf4f45..0690e33ac13 100644 --- a/library/binascii.po +++ b/library/binascii.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-01 00:42+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -65,63 +65,330 @@ msgstr "" msgid "Added the *backtick* parameter." msgstr "新增 *backtick* 參數。" -#: ../../library/binascii.rst:53 +#: ../../library/binascii.rst:54 msgid "" "Convert a block of base64 data back to binary and return the binary data. " "More than one line may be passed at a time." msgstr "" -#: ../../library/binascii.rst:56 +#: ../../library/binascii.rst:57 +msgid "" +"Optional *alphabet* must be a :class:`bytes` object of length 64 which " +"specifies an alternative alphabet." +msgstr "" + +#: ../../library/binascii.rst:60 +msgid "" +"If *padded* is true, the last group of 4 base 64 alphabet characters must be " +"padded with the '=' character. If *padded* is false, padding is neither " +"required nor recognized: the '=' character is not treated as padding but as " +"a non-alphabet character, which means it is silently discarded when " +"*strict_mode* is false, or causes an :exc:`~binascii.Error` when " +"*strict_mode* is true unless b'=' is included in *ignorechars*." +msgstr "" + +#: ../../library/binascii.rst:68 +msgid "" +"If *ignorechars* is specified, it should be a :term:`bytes-like object` " +"containing characters to ignore from the input when *strict_mode* is true. " +"If *ignorechars* contains the pad character ``'='``, the pad characters " +"presented before the end of the encoded data and the excess pad characters " +"will be ignored. The default value of *strict_mode* is ``True`` if " +"*ignorechars* is specified, ``False`` otherwise." +msgstr "" + +#: ../../library/binascii.rst:76 msgid "" "If *strict_mode* is true, only valid base64 data will be converted. Invalid " "base64 data will raise :exc:`binascii.Error`." msgstr "" -#: ../../library/binascii.rst:59 +#: ../../library/binascii.rst:79 msgid "Valid base64:" msgstr "" -#: ../../library/binascii.rst:61 -msgid "Conforms to :rfc:`3548`." +#: ../../library/binascii.rst:81 +msgid "Conforms to :rfc:`4648`." msgstr "" -#: ../../library/binascii.rst:62 +#: ../../library/binascii.rst:82 msgid "Contains only characters from the base64 alphabet." msgstr "" -#: ../../library/binascii.rst:63 +#: ../../library/binascii.rst:83 msgid "" "Contains no excess data after padding (including excess padding, newlines, " "etc.)." msgstr "" -#: ../../library/binascii.rst:64 +#: ../../library/binascii.rst:84 msgid "Does not start with a padding." msgstr "" -#: ../../library/binascii.rst:66 +#: ../../library/binascii.rst:86 +msgid "" +"If *canonical* is true, non-zero padding bits in the last group are rejected " +"with :exc:`binascii.Error`, enforcing canonical encoding as defined in :rfc:" +"`4648` section 3.5. This check is independent of *strict_mode*." +msgstr "" + +#: ../../library/binascii.rst:90 msgid "Added the *strict_mode* parameter." msgstr "新增 *strict_mode* 參數。" -#: ../../library/binascii.rst:72 +#: ../../library/binascii.rst:93 msgid "" -"Convert binary data to a line of ASCII characters in base64 coding. The " -"return value is the converted line, including a newline char if *newline* is " -"true. The output of this function conforms to :rfc:`3548`." +"Added the *alphabet*, *canonical*, *ignorechars*, and *padded* parameters." msgstr "" -#: ../../library/binascii.rst:76 +#: ../../library/binascii.rst:99 +msgid "" +"Convert binary data to a line(s) of ASCII characters in base64 coding, as " +"specified in :rfc:`4648`." +msgstr "" + +#: ../../library/binascii.rst:102 +msgid "" +"If *padded* is true (default), pad the encoded data with the '=' character " +"to a size multiple of 4. If *padded* is false, do not add the pad characters." +msgstr "" + +#: ../../library/binascii.rst:106 ../../library/binascii.rst:166 +#: ../../library/binascii.rst:219 ../../library/binascii.rst:280 +msgid "" +"If *wrapcol* is non-zero, insert a newline (``b'\\n'``) character after at " +"most every *wrapcol* characters. If *wrapcol* is zero (default), do not " +"insert any newlines." +msgstr "" + +#: ../../library/binascii.rst:110 +msgid "" +"If *newline* is true (default), a newline character will be added at the end " +"of the output." +msgstr "" + +#: ../../library/binascii.rst:113 msgid "Added the *newline* parameter." msgstr "新增 *newline* 參數。" -#: ../../library/binascii.rst:82 +#: ../../library/binascii.rst:116 +msgid "Added the *alphabet*, *padded* and *wrapcol* parameters." +msgstr "新增 *alphabet*、*padded* 和 *wrapcol* 參數。" + +#: ../../library/binascii.rst:122 +msgid "Convert Ascii85 data back to binary and return the binary data." +msgstr "" + +#: ../../library/binascii.rst:124 +msgid "" +"Valid Ascii85 data contains characters from the Ascii85 alphabet in groups " +"of five (except for the final group, which may have from two to five " +"characters). Each group encodes 32 bits of binary data in the range from " +"``0`` to ``2 ** 32 - 1``, inclusive. The special character ``z`` is accepted " +"as a short form of the group ``!!!!!``, which encodes four consecutive null " +"bytes. A single-character final group is always rejected as an encoding " +"violation." +msgstr "" + +#: ../../library/binascii.rst:132 +msgid "" +"*foldspaces* is a flag that specifies whether the 'y' short sequence should " +"be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature " +"is not supported by the \"standard\" Ascii85 encoding." +msgstr "" + +#: ../../library/binascii.rst:136 +msgid "" +"*adobe* controls whether the encoded byte sequence is framed with ``<~`` and " +"``~>``, as in a PostScript base-85 string literal. If *adobe* is true, a " +"leading ``<~`` is optionally accepted, while a trailing ``~>`` is " +"*required*, and :exc:`binascii.Error` is raised if it is not found." +msgstr "" + +#: ../../library/binascii.rst:142 +msgid "" +"*ignorechars* should be a :term:`bytes-like object` containing characters to " +"ignore from the input. This should only contain whitespace characters." +msgstr "" + +#: ../../library/binascii.rst:146 +msgid "" +"If *canonical* is true, non-canonical encodings are rejected with :exc:" +"`binascii.Error`. Here \"canonical\" means the encoding that :func:" +"`b2a_ascii85` would produce: the ``z`` abbreviation must be used for all-" +"zero groups (rather than ``!!!!!``), and partial final groups must use the " +"same padding digits as the encoder." +msgstr "" + +#: ../../library/binascii.rst:152 +msgid "Invalid Ascii85 data will raise :exc:`binascii.Error`." +msgstr "" + +#: ../../library/binascii.rst:159 +msgid "" +"Convert binary data to a formatted sequence of ASCII characters in Ascii85 " +"coding. The return value is the converted data." +msgstr "" + +#: ../../library/binascii.rst:162 +msgid "" +"*foldspaces* is an optional flag that uses the special short sequence 'y' " +"instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This " +"feature is not supported by the \"standard\" Ascii85 encoding." +msgstr "" + +#: ../../library/binascii.rst:170 +msgid "" +"If *pad* is true, the zero-padding applied to the end of the input is fully " +"retained in the output encoding, as done by ``btoa``, producing an exact " +"multiple of 5 bytes of output. This is not part of the standard encoding " +"used in PDF, as it does not preserve the length of the data." +msgstr "" + +#: ../../library/binascii.rst:176 +msgid "" +"*adobe* controls whether the encoded byte sequence is framed with ``<~`` and " +"``~>``, as in a PostScript base-85 string literal. Note that while " +"ASCII85Decode streams in PDF documents *must* be terminated with ``~>``, " +"they *must not* use a leading ``<~``." +msgstr "" + +#: ../../library/binascii.rst:186 +msgid "" +"Convert Base85 data back to binary and return the binary data. More than one " +"line may be passed at a time." +msgstr "" + +#: ../../library/binascii.rst:189 +msgid "" +"Valid Base85 data contains characters from the Base85 alphabet in groups of " +"five (except for the final group, which may have from two to five " +"characters). Each group encodes 32 bits of binary data in the range from " +"``0`` to ``2 ** 32 - 1``, inclusive. A single-character final group is " +"always rejected as an encoding violation." +msgstr "" + +#: ../../library/binascii.rst:195 +msgid "" +"Optional *alphabet* must be a :class:`bytes` object of length 85 which " +"specifies an alternative alphabet." +msgstr "" + +#: ../../library/binascii.rst:198 ../../library/binascii.rst:367 +msgid "" +"*ignorechars* should be a :term:`bytes-like object` containing characters to " +"ignore from the input." +msgstr "" + +#: ../../library/binascii.rst:201 +msgid "" +"If *canonical* is true, non-canonical encodings are rejected with :exc:" +"`binascii.Error`. Here \"canonical\" means the encoding that :func:" +"`b2a_base85` would produce: partial final groups must use the same padding " +"digits as the encoder." +msgstr "" + +#: ../../library/binascii.rst:206 +msgid "Invalid Base85 data will raise :exc:`binascii.Error`." +msgstr "" + +#: ../../library/binascii.rst:213 +msgid "" +"Convert binary data to a line of ASCII characters in Base85 coding. The " +"return value is the converted line." +msgstr "" + +#: ../../library/binascii.rst:216 +msgid "" +"Optional *alphabet* must be a :term:`bytes-like object` of length 85 which " +"specifies an alternative alphabet." +msgstr "" + +#: ../../library/binascii.rst:223 +msgid "" +"If *pad* is true, the zero-padding applied to the end of the input is " +"retained in the output, which will always be a multiple of 5 bytes, and thus " +"the length of the data may not be preserved on decoding." +msgstr "" + +#: ../../library/binascii.rst:233 +msgid "Convert base32 data back to binary and return the binary data." +msgstr "" + +#: ../../library/binascii.rst:235 +msgid "" +"Valid base32 data contains characters from the base32 alphabet specified in :" +"rfc:`4648` in groups of eight (if necessary, the final group is padded to " +"eight characters with ``=``). Each group encodes 40 bits of binary data in " +"the range from ``0`` to ``2 ** 40 - 1``, inclusive." +msgstr "" + +#: ../../library/binascii.rst:241 +msgid "" +"This function does not map lowercase characters (which are invalid in " +"standard base32) to their uppercase counterparts, nor does it contextually " +"map ``0`` to ``O`` and ``1`` to ``I``/``L`` as :rfc:`4648` allows." +msgstr "" + +#: ../../library/binascii.rst:246 +msgid "" +"Optional *alphabet* must be a :class:`bytes` object of length 32 which " +"specifies an alternative alphabet." +msgstr "" + +#: ../../library/binascii.rst:249 +msgid "" +"If *padded* is true, the last group of 8 base 32 alphabet characters must be " +"padded with the '=' character. If *padded* is false, the '=' character is " +"treated as other non-alphabet characters (depending on the value of " +"*ignorechars*)." +msgstr "" + +#: ../../library/binascii.rst:254 +msgid "" +"*ignorechars* should be a :term:`bytes-like object` containing characters to " +"ignore from the input. If *ignorechars* contains the pad character ``'='``, " +"the pad characters presented before the end of the encoded data and the " +"excess pad characters will be ignored." +msgstr "" + +#: ../../library/binascii.rst:260 +msgid "" +"If *canonical* is true, non-zero padding bits in the last group are rejected " +"with :exc:`binascii.Error`, enforcing canonical encoding as defined in :rfc:" +"`4648` section 3.5." +msgstr "" + +#: ../../library/binascii.rst:264 +msgid "Invalid base32 data will raise :exc:`binascii.Error`." +msgstr "" + +#: ../../library/binascii.rst:270 +msgid "" +"Convert binary data to a line of ASCII characters in base32 coding, as " +"specified in :rfc:`4648`. The return value is the converted line." +msgstr "" + +#: ../../library/binascii.rst:273 +msgid "" +"Optional *alphabet* must be a :term:`bytes-like object` of length 32 which " +"specifies an alternative alphabet." +msgstr "" + +#: ../../library/binascii.rst:276 +msgid "" +"If *padded* is true (default), pad the encoded data with the '=' character " +"to a size multiple of 8. If *padded* is false, do not add the pad characters." +msgstr "" + +#: ../../library/binascii.rst:288 msgid "" "Convert a block of quoted-printable data back to binary and return the " "binary data. More than one line may be passed at a time. If the optional " "argument *header* is present and true, underscores will be decoded as spaces." msgstr "" -#: ../../library/binascii.rst:89 +#: ../../library/binascii.rst:295 msgid "" "Convert binary data to a line(s) of ASCII characters in quoted-printable " "encoding. The return value is the converted line(s). If the optional " @@ -134,7 +401,7 @@ msgid "" "might corrupt the binary data stream." msgstr "" -#: ../../library/binascii.rst:102 +#: ../../library/binascii.rst:308 msgid "" "Compute a 16-bit CRC value of *data*, starting with *value* as the initial " "CRC, and return the result. This uses the CRC-CCITT polynomial *x*:sup:`16` " @@ -142,7 +409,7 @@ msgid "" "used in the binhex4 format." msgstr "" -#: ../../library/binascii.rst:110 +#: ../../library/binascii.rst:316 msgid "" "Compute CRC-32, the unsigned 32-bit checksum of *data*, starting with an " "initial CRC of *value*. The default initial CRC is zero. The algorithm is " @@ -151,7 +418,7 @@ msgid "" "algorithm. Use as follows::" msgstr "" -#: ../../library/binascii.rst:116 +#: ../../library/binascii.rst:322 msgid "" "print(binascii.crc32(b\"hello world\"))\n" "# Or, in two pieces:\n" @@ -160,24 +427,24 @@ msgid "" "print('crc32 = {:#010x}'.format(crc))" msgstr "" -#: ../../library/binascii.rst:122 +#: ../../library/binascii.rst:328 msgid "The result is always unsigned." msgstr "" -#: ../../library/binascii.rst:128 +#: ../../library/binascii.rst:334 msgid "" "Return the hexadecimal representation of the binary *data*. Every byte of " "*data* is converted into the corresponding 2-digit hex representation. The " "returned bytes object is therefore twice as long as the length of *data*." msgstr "" -#: ../../library/binascii.rst:132 +#: ../../library/binascii.rst:338 msgid "" "Similar functionality (but returning a text string) is also conveniently " "accessible using the :meth:`bytes.hex` method." msgstr "" -#: ../../library/binascii.rst:135 +#: ../../library/binascii.rst:341 msgid "" "If *sep* is specified, it must be a single character str or bytes object. It " "will be inserted in the output after every *bytes_per_sep* input bytes. " @@ -185,11 +452,11 @@ msgid "" "if you wish to count from the left, supply a negative *bytes_per_sep* value." msgstr "" -#: ../../library/binascii.rst:150 +#: ../../library/binascii.rst:356 msgid "The *sep* and *bytes_per_sep* parameters were added." msgstr "新增 *sep* 與 *bytes_per_sep* 參數。" -#: ../../library/binascii.rst:156 +#: ../../library/binascii.rst:362 msgid "" "Return the binary data represented by the hexadecimal string *hexstr*. This " "function is the inverse of :func:`b2a_hex`. *hexstr* must contain an even " @@ -197,36 +464,85 @@ msgid "" "an :exc:`Error` exception is raised." msgstr "" -#: ../../library/binascii.rst:161 +#: ../../library/binascii.rst:370 msgid "" "Similar functionality (but more liberal towards whitespace) is also " "accessible using the :meth:`bytes.fromhex` class method." msgstr "" -#: ../../library/binascii.rst:166 +#: ../../library/binascii.rst:373 +msgid "Added the *ignorechars* parameter." +msgstr "新增 *ignorechars* 參數。" + +#: ../../library/binascii.rst:379 msgid "Exception raised on errors. These are usually programming errors." msgstr "" -#: ../../library/binascii.rst:171 +#: ../../library/binascii.rst:384 msgid "" "Exception raised on incomplete data. These are usually not programming " "errors, but may be handled by reading a little more data and trying again." msgstr "" -#: ../../library/binascii.rst:177 +#: ../../library/binascii.rst:390 +msgid "The Base 64 alphabet according to :rfc:`4648`." +msgstr "" + +#: ../../library/binascii.rst:396 +msgid "" +"The \"URL and filename safe\" Base 64 alphabet according to :rfc:`4648`." +msgstr "" + +#: ../../library/binascii.rst:402 +msgid "The uuencoding alphabet." +msgstr "" + +#: ../../library/binascii.rst:408 +msgid "" +"The Base 64 alphabet used in the :manpage:`crypt(3)` routine and in the " +"GEDCOM format." +msgstr "" + +#: ../../library/binascii.rst:414 +msgid "The Base 64 alphabet used in BinHex 4 (HQX) within the classic Mac OS." +msgstr "" + +#: ../../library/binascii.rst:420 +msgid "The Base85 alphabet." +msgstr "" + +#: ../../library/binascii.rst:426 +msgid "The Ascii85 alphabet." +msgstr "" + +#: ../../library/binascii.rst:432 +msgid "The `Z85 `_ alphabet." +msgstr "" + +#: ../../library/binascii.rst:438 +msgid "The Base 32 alphabet according to :rfc:`4648`." +msgstr "" + +#: ../../library/binascii.rst:444 +msgid "" +"The \"Extended Hex\" Base 32 alphabet according to :rfc:`4648`. Data encoded " +"with this alphabet maintains its sort order during bitwise comparisons." +msgstr "" + +#: ../../library/binascii.rst:453 msgid "Module :mod:`base64`" msgstr ":mod:`base64` 模組" -#: ../../library/binascii.rst:178 +#: ../../library/binascii.rst:454 msgid "" "Support for RFC compliant base64-style encoding in base 16, 32, 64, and 85." msgstr "" -#: ../../library/binascii.rst:181 +#: ../../library/binascii.rst:457 msgid "Module :mod:`quopri`" msgstr ":mod:`quopri` 模組" -#: ../../library/binascii.rst:182 +#: ../../library/binascii.rst:458 msgid "Support for quoted-printable encoding used in MIME email messages." msgstr "" diff --git a/library/bisect.po b/library/bisect.po index 9fbbe8f3ffb..cd3afe2b93f 100644 --- a/library/bisect.po +++ b/library/bisect.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -26,11 +26,11 @@ msgstr "" msgid ":mod:`!bisect` --- Array bisection algorithm" msgstr ":mod:`!bisect` --- 陣列二分演算法 (Array bisection algorithm)" -#: ../../library/bisect.rst:10 +#: ../../library/bisect.rst:7 msgid "**Source code:** :source:`Lib/bisect.py`" msgstr "**原始碼:**\\ :source:`Lib/bisect.py`" -#: ../../library/bisect.rst:14 +#: ../../library/bisect.rst:11 msgid "" "This module provides support for maintaining a list in sorted order without " "having to sort the list after each insertion. For long lists of items with " @@ -41,7 +41,7 @@ msgstr "" "list 。一個很長的 list 的比較操作很花費時間,可以透過線性搜尋或頻繁地詢問來改" "善。" -#: ../../library/bisect.rst:19 +#: ../../library/bisect.rst:16 msgid "" "The module is called :mod:`!bisect` because it uses a basic bisection " "algorithm to do its work. Unlike other bisection tools that search for a " @@ -56,7 +56,7 @@ msgstr "" "會呼叫 :meth:`~object.__eq__` 方法來確認是否找到一個值。相反地,這些函式只呼" "叫 :meth:`~object.__lt__` 方法,並在陣列中的值回傳一個插入點。" -#: ../../library/bisect.rst:29 +#: ../../library/bisect.rst:26 msgid "" "The functions in this module are not thread-safe. If multiple threads " "concurrently use :mod:`!bisect` functions on the same sequence, this may " @@ -67,11 +67,11 @@ msgid "" "unsorted." msgstr "" -#: ../../library/bisect.rst:39 +#: ../../library/bisect.rst:36 msgid "The following functions are provided:" msgstr "此模組提供下面的函式:" -#: ../../library/bisect.rst:44 +#: ../../library/bisect.rst:41 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 " @@ -85,7 +85,7 @@ msgstr "" "有 *x* 出現,插入的位置會在所有 *x* 的前面(左邊)。回傳值可以被當作 ``list." "insert()`` 的第一個參數,但列表 *a* 必須先排序過。" -#: ../../library/bisect.rst:51 +#: ../../library/bisect.rst:48 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 " @@ -96,7 +96,7 @@ msgstr "" "``all(elem < x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem >= " "x for elem in a[ip : hi])`` 為真。" -#: ../../library/bisect.rst:56 +#: ../../library/bisect.rst:53 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 " @@ -106,18 +106,18 @@ msgstr "" "所有元素以得到比較值來計算順位。注意此 function 只會套用在陣列中的元素,不會" "套用在 *x*。" -#: ../../library/bisect.rst:60 +#: ../../library/bisect.rst:57 msgid "" "If *key* is ``None``, the elements are compared directly and no key function " "is called." msgstr "若 *key* 為 ``None``,元素將直接進行比較,不會呼叫任何鍵函式。" -#: ../../library/bisect.rst:63 ../../library/bisect.rst:77 -#: ../../library/bisect.rst:95 ../../library/bisect.rst:115 +#: ../../library/bisect.rst:60 ../../library/bisect.rst:74 +#: ../../library/bisect.rst:92 ../../library/bisect.rst:112 msgid "Added the *key* parameter." msgstr "新增 *key* 參數。" -#: ../../library/bisect.rst:70 +#: ../../library/bisect.rst:67 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*." @@ -125,7 +125,7 @@ msgstr "" "類似 :py:func:`~bisect.bisect_left`,但回傳的插入位置會在所有 *a* 當中的 *x* " "的後面(右邊)。" -#: ../../library/bisect.rst:73 +#: ../../library/bisect.rst:70 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 " @@ -136,11 +136,11 @@ msgstr "" "``all(elem <= x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem > " "x for elem in a[ip : hi])`` 為真。" -#: ../../library/bisect.rst:83 +#: ../../library/bisect.rst:80 msgid "Insert *x* in *a* in sorted order." msgstr "將元素 *x* 插入 list *a*,並維持順序。" -#: ../../library/bisect.rst:85 +#: ../../library/bisect.rst:82 msgid "" "This function first runs :py:func:`~bisect.bisect_left` to locate an " "insertion point. Next, it runs the :meth:`~sequence.insert` method on *a* to " @@ -149,13 +149,13 @@ msgstr "" "此函式先使用 :py:func:`~bisect.bisect_left` 搜尋插入位置,接著用 :meth:" "`~sequence.insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" -#: ../../library/bisect.rst:89 ../../library/bisect.rst:109 +#: ../../library/bisect.rst:86 ../../library/bisect.rst:106 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:92 ../../library/bisect.rst:112 +#: ../../library/bisect.rst:89 ../../library/bisect.rst:109 msgid "" "Keep in mind that the *O*\\ (log *n*) search is dominated by the slow *O*\\ " "(*n*) insertion step." @@ -163,7 +163,7 @@ msgstr "" "注意雖然搜尋是 *O*\\ (log *n*),但插入是 *O*\\ (*n*),因此此函式整體時間複雜" "度是 *O*\\ (*n*)。" -#: ../../library/bisect.rst:102 +#: ../../library/bisect.rst:99 msgid "" "Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after " "any existing entries of *x*." @@ -171,7 +171,7 @@ msgstr "" "類似 :py:func:`~bisect.insort_left`,但插入的位置會在所有 *a* 當中的 *x* 的後" "面(右邊)。" -#: ../../library/bisect.rst:105 +#: ../../library/bisect.rst:102 msgid "" "This function first runs :py:func:`~bisect.bisect_right` to locate an " "insertion point. Next, it runs the :meth:`~sequence.insert` method on *a* to " @@ -180,11 +180,11 @@ msgstr "" "此函式先使用 :py:func:`~bisect.bisect_right` 搜尋插入位置,接著用 :meth:" "`~sequence.insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" -#: ../../library/bisect.rst:120 +#: ../../library/bisect.rst:117 msgid "Performance Notes" msgstr "效能考量" -#: ../../library/bisect.rst:122 +#: ../../library/bisect.rst:119 msgid "" "When writing time sensitive code using *bisect()* and *insort()*, keep these " "thoughts in mind:" @@ -192,7 +192,7 @@ msgstr "" "若在需要關注寫入時間的程式當中使用 *bisect()* 和 *insort()*,請特別注意幾個事" "項:" -#: ../../library/bisect.rst:125 +#: ../../library/bisect.rst:122 msgid "" "Bisection is effective for searching ranges of values. For locating specific " "values, dictionaries are more performant." @@ -200,7 +200,7 @@ msgstr "" "二分法在一段範圍的數值中做搜尋的效率較佳,但若是要存取特定數值,使用字典的表" "現還是比較好。" -#: ../../library/bisect.rst:128 +#: ../../library/bisect.rst:125 msgid "" "The *insort()* functions are *O*\\ (*n*) because the logarithmic search step " "is dominated by the linear time insertion step." @@ -208,7 +208,7 @@ msgstr "" "*insort()* 函式的複雜度為 *O*\\ (*n*),因為對數搜尋是以線性時間的插入步驟所主" "導 (dominate)。" -#: ../../library/bisect.rst:131 +#: ../../library/bisect.rst:128 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, " @@ -224,7 +224,7 @@ msgstr "" "算。另外,也可以考慮搜尋一個預先計算好的鍵陣列 (array of precomputed keys) 來" "定位插入點(如下方範例所示)。" -#: ../../library/bisect.rst:141 +#: ../../library/bisect.rst:138 msgid "" "`Sorted Collections `_ is a " "high performance module that uses *bisect* to managed sorted collections of " @@ -233,7 +233,7 @@ msgstr "" "`有序容器 (Sorted Collections) `_ 是一個使用 *bisect* 來管理資料之有序集合的高效能模組。" -#: ../../library/bisect.rst:145 +#: ../../library/bisect.rst:142 msgid "" "The `SortedCollection recipe `_ uses bisect to build a full-featured collection class " @@ -246,11 +246,11 @@ msgstr "" "class) 並帶有符合直覺的搜尋方法 (search methods) 與支援鍵函式。鍵會預先被計算" "好,以減少搜尋過程中多餘的鍵函式呼叫。" -#: ../../library/bisect.rst:153 +#: ../../library/bisect.rst:150 msgid "Searching Sorted Lists" msgstr "搜尋一個已排序的 list" -#: ../../library/bisect.rst:155 +#: ../../library/bisect.rst:152 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 " @@ -260,7 +260,7 @@ msgstr "" "上面的 `bisect functions`_ 在找到數值插入點上很有用,但一般的數值搜尋任務上就" "不是那麼的方便。以下的五個函式展示了如何將其轉換成標準的有序列表查找函式: ::" -#: ../../library/bisect.rst:160 +#: ../../library/bisect.rst:157 msgid "" "def index(a, x):\n" " 'Locate the leftmost value exactly equal to x'\n" @@ -298,11 +298,11 @@ msgid "" " raise ValueError" msgstr "" -#: ../../library/bisect.rst:197 +#: ../../library/bisect.rst:194 msgid "Examples" msgstr "範例" -#: ../../library/bisect.rst:201 +#: ../../library/bisect.rst:198 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 " @@ -313,7 +313,7 @@ msgstr "" "個範例使用 :py:func:`~bisect.bisect` 以基於一組有序的數值分界點來為一個考試成" "績找到相對應的字母等級:90 以上是 'A'、80 到 89 為 'B',依此類推: ::" -#: ../../library/bisect.rst:206 +#: ../../library/bisect.rst:203 msgid "" ">>> def grade(score):\n" "... i = bisect([60, 70, 80, 90], score)\n" @@ -329,7 +329,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:213 +#: ../../library/bisect.rst:210 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 " @@ -339,7 +339,7 @@ msgstr "" "tuples(元組)的 lists,*key* 引數可被用以取出在數值表中作為排序依據的欄" "位: ::" -#: ../../library/bisect.rst:217 +#: ../../library/bisect.rst:214 msgid "" ">>> from collections import namedtuple\n" ">>> from operator import attrgetter\n" @@ -401,7 +401,7 @@ msgstr "" " Movie(name='Aliens', released=1986, director='Cameron'),\n" " Movie(name='Titanic', released=1997, director='Cameron')]" -#: ../../library/bisect.rst:247 +#: ../../library/bisect.rst:244 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::" @@ -409,7 +409,7 @@ msgstr "" "如果鍵函式會消耗較多運算資源,那可以在預先計算好的鍵列表中搜尋該紀錄的索引" "值,以減少重複的函式呼叫: ::" -#: ../../library/bisect.rst:250 +#: ../../library/bisect.rst:247 msgid "" ">>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]\n" ">>> data.sort(key=lambda r: r[1]) # Or use operator.itemgetter(1).\n" diff --git a/library/bz2.po b/library/bz2.po index ef7b9ff91ad..be39e21b3ce 100644 --- a/library/bz2.po +++ b/library/bz2.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,33 +21,33 @@ msgstr "" msgid ":mod:`!bz2` --- Support for :program:`bzip2` compression" msgstr ":mod:`!bz2` --- :program:`bzip2` 壓縮的支援" -#: ../../library/bz2.rst:12 +#: ../../library/bz2.rst:7 msgid "**Source code:** :source:`Lib/bz2.py`" msgstr "**原始碼:**\\ :source:`Lib/bz2.py`" -#: ../../library/bz2.rst:16 +#: ../../library/bz2.rst:11 msgid "" "This module provides a comprehensive interface for compressing and " "decompressing data using the bzip2 compression algorithm." msgstr "" -#: ../../library/bz2.rst:19 +#: ../../library/bz2.rst:14 msgid "The :mod:`!bz2` module contains:" msgstr ":mod:`!bz2` 模組包含:" -#: ../../library/bz2.rst:21 +#: ../../library/bz2.rst:16 msgid "" "The :func:`.open` function and :class:`BZ2File` class for reading and " "writing compressed files." msgstr "" -#: ../../library/bz2.rst:23 +#: ../../library/bz2.rst:18 msgid "" "The :class:`BZ2Compressor` and :class:`BZ2Decompressor` classes for " "incremental (de)compression." msgstr "" -#: ../../library/bz2.rst:25 +#: ../../library/bz2.rst:20 msgid "" "The :func:`compress` and :func:`decompress` functions for one-shot " "(de)compression." @@ -61,37 +61,37 @@ msgid "" "module-requirements`." msgstr "" -#: ../../library/bz2.rst:32 +#: ../../library/bz2.rst:27 msgid "(De)compression of files" msgstr "" -#: ../../library/bz2.rst:36 +#: ../../library/bz2.rst:31 msgid "" "Open a bzip2-compressed file in binary or text mode, returning a :term:`file " "object`." msgstr "" -#: ../../library/bz2.rst:39 +#: ../../library/bz2.rst:34 msgid "" "As with the constructor for :class:`BZ2File`, the *filename* argument can be " "an actual filename (a :class:`str` or :class:`bytes` object), or an existing " "file object to read from or write to." msgstr "" -#: ../../library/bz2.rst:43 +#: ../../library/bz2.rst:38 msgid "" "The *mode* argument can be any of ``'r'``, ``'rb'``, ``'w'``, ``'wb'``, " "``'x'``, ``'xb'``, ``'a'`` or ``'ab'`` for binary mode, or ``'rt'``, " "``'wt'``, ``'xt'``, or ``'at'`` for text mode. The default is ``'rb'``." msgstr "" -#: ../../library/bz2.rst:47 +#: ../../library/bz2.rst:42 msgid "" "The *compresslevel* argument is an integer from 1 to 9, as for the :class:" "`BZ2File` constructor." msgstr "" -#: ../../library/bz2.rst:50 +#: ../../library/bz2.rst:45 msgid "" "For binary mode, this function is equivalent to the :class:`BZ2File` " "constructor: ``BZ2File(filename, mode, compresslevel=compresslevel)``. In " @@ -99,33 +99,33 @@ msgid "" "provided." msgstr "" -#: ../../library/bz2.rst:55 +#: ../../library/bz2.rst:50 msgid "" "For text mode, a :class:`BZ2File` object is created, and wrapped in an :" "class:`io.TextIOWrapper` instance with the specified encoding, error " "handling behavior, and line ending(s)." msgstr "" -#: ../../library/bz2.rst:61 ../../library/bz2.rst:177 +#: ../../library/bz2.rst:56 ../../library/bz2.rst:172 msgid "The ``'x'`` (exclusive creation) mode was added." msgstr "" -#: ../../library/bz2.rst:64 ../../library/bz2.rst:184 +#: ../../library/bz2.rst:59 ../../library/bz2.rst:179 msgid "Accepts a :term:`path-like object`." msgstr "接受一個\\ :term:`類路徑物件 `。" -#: ../../library/bz2.rst:70 +#: ../../library/bz2.rst:65 msgid "Open a bzip2-compressed file in binary mode." msgstr "" -#: ../../library/bz2.rst:72 +#: ../../library/bz2.rst:67 msgid "" "If *filename* is a :class:`str` or :class:`bytes` object, open the named " "file directly. Otherwise, *filename* should be a :term:`file object`, which " "will be used to read or write the compressed data." msgstr "" -#: ../../library/bz2.rst:76 +#: ../../library/bz2.rst:71 msgid "" "The *mode* argument can be either ``'r'`` for reading (default), ``'w'`` for " "overwriting, ``'x'`` for exclusive creation, or ``'a'`` for appending. These " @@ -133,44 +133,44 @@ msgid "" "respectively." msgstr "" -#: ../../library/bz2.rst:81 +#: ../../library/bz2.rst:76 msgid "" "If *filename* is a file object (rather than an actual file name), a mode of " "``'w'`` does not truncate the file, and is instead equivalent to ``'a'``." msgstr "" -#: ../../library/bz2.rst:84 +#: ../../library/bz2.rst:79 msgid "" "If *mode* is ``'w'`` or ``'a'``, *compresslevel* can be an integer between " "``1`` and ``9`` specifying the level of compression: ``1`` produces the " "least compression, and ``9`` (default) produces the most compression." msgstr "" -#: ../../library/bz2.rst:88 +#: ../../library/bz2.rst:83 msgid "" "If *mode* is ``'r'``, the input file may be the concatenation of multiple " "compressed streams." msgstr "" -#: ../../library/bz2.rst:91 +#: ../../library/bz2.rst:86 msgid "" ":class:`BZ2File` provides all of the members specified by the :class:`io." "BufferedIOBase`, except for :meth:`~io.BufferedIOBase.detach` and :meth:`~io." "IOBase.truncate`. Iteration and the :keyword:`with` statement are supported." msgstr "" -#: ../../library/bz2.rst:96 +#: ../../library/bz2.rst:91 msgid ":class:`BZ2File` also provides the following methods and attributes:" msgstr ":class:`BZ2File` 也提供了以下方法和屬性:" -#: ../../library/bz2.rst:100 +#: ../../library/bz2.rst:95 msgid "" "Return buffered data without advancing the file position. At least one byte " "of data will be returned (unless at EOF). The exact number of bytes returned " "is unspecified." msgstr "" -#: ../../library/bz2.rst:104 +#: ../../library/bz2.rst:99 msgid "" "While calling :meth:`peek` does not change the file position of the :class:" "`BZ2File`, it may change the position of the underlying file object (e.g. if " @@ -178,138 +178,138 @@ msgid "" "*filename*)." msgstr "" -#: ../../library/bz2.rst:113 +#: ../../library/bz2.rst:108 msgid "Return the file descriptor for the underlying file." msgstr "" -#: ../../library/bz2.rst:119 +#: ../../library/bz2.rst:114 msgid "Return whether the file was opened for reading." msgstr "" -#: ../../library/bz2.rst:125 +#: ../../library/bz2.rst:120 msgid "Return whether the file supports seeking." msgstr "" -#: ../../library/bz2.rst:131 +#: ../../library/bz2.rst:126 msgid "Return whether the file was opened for writing." msgstr "" -#: ../../library/bz2.rst:137 +#: ../../library/bz2.rst:132 msgid "" "Read up to *size* uncompressed bytes, while trying to avoid making multiple " "reads from the underlying stream. Reads up to a buffer's worth of data if " "size is negative." msgstr "" -#: ../../library/bz2.rst:141 +#: ../../library/bz2.rst:136 msgid "Returns ``b''`` if the file is at EOF." msgstr "如果檔案已經到達 EOF 則回傳 ``b''``。" -#: ../../library/bz2.rst:147 +#: ../../library/bz2.rst:142 msgid "Read bytes into *b*." msgstr "" -#: ../../library/bz2.rst:149 +#: ../../library/bz2.rst:144 msgid "Returns the number of bytes read (0 for EOF)." msgstr "" -#: ../../library/bz2.rst:155 +#: ../../library/bz2.rst:150 msgid "``'rb'`` for reading and ``'wb'`` for writing." msgstr "" -#: ../../library/bz2.rst:161 +#: ../../library/bz2.rst:156 msgid "" "The bzip2 file name. Equivalent to the :attr:`~io.FileIO.name` attribute of " "the underlying :term:`file object`." msgstr "" -#: ../../library/bz2.rst:167 +#: ../../library/bz2.rst:162 msgid "Support for the :keyword:`with` statement was added." msgstr "新增對 :keyword:`with` 陳述式的支援。" -#: ../../library/bz2.rst:170 +#: ../../library/bz2.rst:165 msgid "" "Support was added for *filename* being a :term:`file object` instead of an " "actual filename." msgstr "" -#: ../../library/bz2.rst:174 +#: ../../library/bz2.rst:169 msgid "" "The ``'a'`` (append) mode was added, along with support for reading multi-" "stream files." msgstr "" -#: ../../library/bz2.rst:180 +#: ../../library/bz2.rst:175 msgid "" "The :meth:`~io.BufferedIOBase.read` method now accepts an argument of " "``None``." msgstr "" -#: ../../library/bz2.rst:187 +#: ../../library/bz2.rst:182 msgid "" "The *buffering* parameter has been removed. It was ignored and deprecated " "since Python 3.0. Pass an open file object to control how the file is opened." msgstr "" -#: ../../library/bz2.rst:192 +#: ../../library/bz2.rst:187 msgid "The *compresslevel* parameter became keyword-only." msgstr "" -#: ../../library/bz2.rst:194 +#: ../../library/bz2.rst:189 msgid "" "This class is thread unsafe in the face of multiple simultaneous readers or " "writers, just like its equivalent classes in :mod:`gzip` and :mod:`lzma` " "have always been." msgstr "" -#: ../../library/bz2.rst:201 +#: ../../library/bz2.rst:196 msgid "Incremental (de)compression" msgstr "" -#: ../../library/bz2.rst:205 +#: ../../library/bz2.rst:200 msgid "" "Create a new compressor object. This object may be used to compress data " "incrementally. For one-shot compression, use the :func:`compress` function " "instead." msgstr "" -#: ../../library/bz2.rst:209 ../../library/bz2.rst:297 +#: ../../library/bz2.rst:204 ../../library/bz2.rst:292 msgid "" "*compresslevel*, if given, must be an integer between ``1`` and ``9``. The " "default is ``9``." msgstr "" -#: ../../library/bz2.rst:214 +#: ../../library/bz2.rst:209 msgid "" "Provide data to the compressor object. Returns a chunk of compressed data if " "possible, or an empty byte string otherwise." msgstr "" -#: ../../library/bz2.rst:217 +#: ../../library/bz2.rst:212 msgid "" "When you have finished providing data to the compressor, call the :meth:" "`flush` method to finish the compression process." msgstr "" -#: ../../library/bz2.rst:223 +#: ../../library/bz2.rst:218 msgid "" "Finish the compression process. Returns the compressed data left in internal " "buffers." msgstr "" -#: ../../library/bz2.rst:226 +#: ../../library/bz2.rst:221 msgid "" "The compressor object may not be used after this method has been called." msgstr "" -#: ../../library/bz2.rst:231 +#: ../../library/bz2.rst:226 msgid "" "Create a new decompressor object. This object may be used to decompress data " "incrementally. For one-shot compression, use the :func:`decompress` function " "instead." msgstr "" -#: ../../library/bz2.rst:236 +#: ../../library/bz2.rst:231 msgid "" "This class does not transparently handle inputs containing multiple " "compressed streams, unlike :func:`decompress` and :class:`BZ2File`. If you " @@ -317,7 +317,7 @@ msgid "" "must use a new decompressor for each stream." msgstr "" -#: ../../library/bz2.rst:243 +#: ../../library/bz2.rst:238 msgid "" "Decompress *data* (a :term:`bytes-like object`), returning uncompressed data " "as bytes. Some of *data* may be buffered internally, for use in later calls " @@ -325,7 +325,7 @@ msgid "" "output of any previous calls to :meth:`decompress`." msgstr "" -#: ../../library/bz2.rst:249 +#: ../../library/bz2.rst:244 msgid "" "If *max_length* is nonnegative, returns at most *max_length* bytes of " "decompressed data. If this limit is reached and further output can be " @@ -334,99 +334,99 @@ msgid "" "``b''`` to obtain more of the output." msgstr "" -#: ../../library/bz2.rst:256 +#: ../../library/bz2.rst:251 msgid "" "If all of the input data was decompressed and returned (either because this " "was less than *max_length* bytes, or because *max_length* was negative), " "the :attr:`~.needs_input` attribute will be set to ``True``." msgstr "" -#: ../../library/bz2.rst:261 +#: ../../library/bz2.rst:256 msgid "" "Attempting to decompress data after the end of stream is reached raises an :" "exc:`EOFError`. Any data found after the end of the stream is ignored and " "saved in the :attr:`~.unused_data` attribute." msgstr "" -#: ../../library/bz2.rst:265 +#: ../../library/bz2.rst:260 msgid "Added the *max_length* parameter." msgstr "新增 *max_length* 參數。" -#: ../../library/bz2.rst:270 +#: ../../library/bz2.rst:265 msgid "``True`` if the end-of-stream marker has been reached." msgstr "" -#: ../../library/bz2.rst:277 +#: ../../library/bz2.rst:272 msgid "Data found after the end of the compressed stream." msgstr "" -#: ../../library/bz2.rst:279 +#: ../../library/bz2.rst:274 msgid "" "If this attribute is accessed before the end of the stream has been reached, " "its value will be ``b''``." msgstr "" -#: ../../library/bz2.rst:284 +#: ../../library/bz2.rst:279 msgid "" "``False`` if the :meth:`.decompress` method can provide more decompressed " "data before requiring new uncompressed input." msgstr "" -#: ../../library/bz2.rst:291 +#: ../../library/bz2.rst:286 msgid "One-shot (de)compression" msgstr "" -#: ../../library/bz2.rst:295 +#: ../../library/bz2.rst:290 msgid "Compress *data*, a :term:`bytes-like object `." msgstr "" -#: ../../library/bz2.rst:300 +#: ../../library/bz2.rst:295 msgid "For incremental compression, use a :class:`BZ2Compressor` instead." msgstr "" -#: ../../library/bz2.rst:305 +#: ../../library/bz2.rst:300 msgid "Decompress *data*, a :term:`bytes-like object `." msgstr "" -#: ../../library/bz2.rst:307 +#: ../../library/bz2.rst:302 msgid "" "If *data* is the concatenation of multiple compressed streams, decompress " "all of the streams." msgstr "" -#: ../../library/bz2.rst:310 +#: ../../library/bz2.rst:305 msgid "For incremental decompression, use a :class:`BZ2Decompressor` instead." msgstr "" -#: ../../library/bz2.rst:312 +#: ../../library/bz2.rst:307 msgid "Support for multi-stream inputs was added." msgstr "" -#: ../../library/bz2.rst:318 +#: ../../library/bz2.rst:313 msgid "Examples of usage" msgstr "用法範例" -#: ../../library/bz2.rst:320 +#: ../../library/bz2.rst:315 msgid "Below are some examples of typical usage of the :mod:`!bz2` module." msgstr "" -#: ../../library/bz2.rst:322 +#: ../../library/bz2.rst:317 msgid "" "Using :func:`compress` and :func:`decompress` to demonstrate round-trip " "compression:" msgstr "" -#: ../../library/bz2.rst:340 +#: ../../library/bz2.rst:335 msgid "Using :class:`BZ2Compressor` for incremental compression:" msgstr "" -#: ../../library/bz2.rst:358 +#: ../../library/bz2.rst:353 msgid "" "The example above uses a very \"nonrandom\" stream of data (a stream of " "``b\"z\"`` chunks). Random data tends to compress poorly, while ordered, " "repetitive data usually yields a high compression ratio." msgstr "" -#: ../../library/bz2.rst:362 +#: ../../library/bz2.rst:357 msgid "Writing and reading a bzip2-compressed file in binary mode:" msgstr "" diff --git a/library/calendar.po b/library/calendar.po index de285f97cd3..389b3a45be4 100644 --- a/library/calendar.po +++ b/library/calendar.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-19 00:28+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!calendar` --- General calendar-related functions" msgstr ":mod:`!calendar` --- 日曆相關函式" -#: ../../library/calendar.rst:10 +#: ../../library/calendar.rst:8 msgid "**Source code:** :source:`Lib/calendar.py`" msgstr "**原始碼:**\\ :source:`Lib/calendar.py`" -#: ../../library/calendar.rst:14 +#: ../../library/calendar.rst:12 msgid "" "This module allows you to output calendars like the Unix :program:`cal` " "program, and provides additional useful functions related to the calendar. " @@ -41,7 +41,7 @@ msgstr "" "其它任一天,其中指定日期的參數是整數。相關功能參考 :mod:`datetime` 和 :mod:" "`time` 模組。" -#: ../../library/calendar.rst:22 +#: ../../library/calendar.rst:20 msgid "" "The functions and classes defined in this module use an idealized calendar, " "the current Gregorian calendar extended indefinitely in both directions. " @@ -57,7 +57,7 @@ msgstr "" "礎日曆。0 及負數年份的解讀跟 ISO 8601 標準裡規定的一樣,0 年是公元前 1 " "年,-1 年是公元前 2 年依此類推。" -#: ../../library/calendar.rst:33 +#: ../../library/calendar.rst:31 msgid "" "Creates a :class:`Calendar` object. *firstweekday* is an integer specifying " "the first day of the week. :const:`MONDAY` is ``0`` (the default), :const:" @@ -66,7 +66,7 @@ msgstr "" "建立 :class:`Calendar` 物件。*firstweekday* 是一個指定一週第一天的整數,:" "const:`MONDAY` 是 ``0``\\ (預設值),:const:`SUNDAY` 是 ``6``。" -#: ../../library/calendar.rst:36 +#: ../../library/calendar.rst:34 msgid "" "A :class:`Calendar` object provides several methods that can be used for " "preparing the calendar data for formatting. This class doesn't do any " @@ -75,38 +75,38 @@ msgstr "" ":class:`Calendar` 物件提供一些方法來為日曆資料的格式化做準備。這個類別本身不" "做任何格式化,這是子類別的工作。" -#: ../../library/calendar.rst:41 +#: ../../library/calendar.rst:39 msgid ":class:`Calendar` instances have the following methods and attributes:" msgstr ":class:`Calendar` 實例有以下方法與屬性:" -#: ../../library/calendar.rst:45 +#: ../../library/calendar.rst:43 msgid "The first weekday as an integer (0--6)." msgstr "" -#: ../../library/calendar.rst:47 +#: ../../library/calendar.rst:45 msgid "" "This property can also be set and read using :meth:`~Calendar." "setfirstweekday` and :meth:`~Calendar.getfirstweekday` respectively." msgstr "" -#: ../../library/calendar.rst:53 +#: ../../library/calendar.rst:51 msgid "Return an :class:`int` for the current first weekday (0--6)." msgstr "" -#: ../../library/calendar.rst:55 +#: ../../library/calendar.rst:53 msgid "Identical to reading the :attr:`~Calendar.firstweekday` property." msgstr "" -#: ../../library/calendar.rst:59 +#: ../../library/calendar.rst:57 msgid "" "Set the first weekday to *firstweekday*, passed as an :class:`int` (0--6)." msgstr "" -#: ../../library/calendar.rst:61 +#: ../../library/calendar.rst:59 msgid "Identical to setting the :attr:`~Calendar.firstweekday` property." msgstr "" -#: ../../library/calendar.rst:65 +#: ../../library/calendar.rst:63 msgid "" "Return an iterator for the weekday numbers that will be used for one week. " "The first value from the iterator will be the same as the value of the :attr:" @@ -115,7 +115,7 @@ msgstr "" "回傳一個以數字代表一週的每一天的疊代器 (iterator)。疊代器的第一個值和 :attr:" "`~Calendar.firstweekday` 屬性的值一樣。" -#: ../../library/calendar.rst:72 +#: ../../library/calendar.rst:70 msgid "" "Return an iterator for the month *month* (1--12) in the year *year*. This " "iterator will return all days (as :class:`datetime.date` objects) for the " @@ -125,7 +125,7 @@ msgstr "" "回傳一個在 *year* 年 *month* (1--12) 月的疊代器。這個疊代器會回傳該月的所有日" "期(:class:`datetime.date` 物件)以及在該月之前及之後用來組成完整一週的日期。" -#: ../../library/calendar.rst:80 +#: ../../library/calendar.rst:78 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " @@ -136,7 +136,7 @@ msgstr "" "限於 :class:`datetime.date` 的範圍。回傳的日期單純是該月當日的數字,對於該月" "之外的日期數字會是 ``0``。" -#: ../../library/calendar.rst:88 +#: ../../library/calendar.rst:86 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " @@ -147,7 +147,7 @@ msgstr "" "限於 :class:`datetime.date` 的範圍。回傳的日期是一個由該月當日的數字及代表週" "幾的數字組成的元組。" -#: ../../library/calendar.rst:96 +#: ../../library/calendar.rst:94 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " @@ -158,7 +158,7 @@ msgstr "" "限於 :class:`datetime.date` 的範圍。回傳的日期是一個由年、月、日的數字組成的" "元組。" -#: ../../library/calendar.rst:106 +#: ../../library/calendar.rst:104 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " @@ -169,7 +169,7 @@ msgstr "" "限於 :class:`datetime.date` 的範圍。回傳的日期是一個由年、月、日及代表週幾的" "數字組成的元組。" -#: ../../library/calendar.rst:116 +#: ../../library/calendar.rst:114 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven :class:`datetime.date` objects." @@ -177,7 +177,7 @@ msgstr "" "回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七個 :" "class:`datetime.date` 物件。" -#: ../../library/calendar.rst:122 +#: ../../library/calendar.rst:120 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven tuples of day numbers and weekday numbers." @@ -185,7 +185,7 @@ msgstr "" "回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七個該" "月當日的數字及代表週幾的數字組成的元組。" -#: ../../library/calendar.rst:129 +#: ../../library/calendar.rst:127 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven day numbers." @@ -193,7 +193,7 @@ msgstr "" "回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七個該" "月當日的數字。" -#: ../../library/calendar.rst:135 +#: ../../library/calendar.rst:133 msgid "" "Return the data for the specified year ready for formatting. The return " "value is a list of month rows. Each month row contains up to *width* months " @@ -204,7 +204,7 @@ msgstr "" "*width* 個月份組成(預設為 3)。每個月份包含四到六週,每一週包含一到七天,每" "一天則是一個 :class:`datetime.date` 物件。" -#: ../../library/calendar.rst:143 +#: ../../library/calendar.rst:141 msgid "" "Return the data for the specified year ready for formatting (similar to :" "meth:`yeardatescalendar`). Entries in the week lists are tuples of day " @@ -213,7 +213,7 @@ msgstr "" "回傳用來格式化的指定年份的資料(類似 :meth:`yeardatescalendar`)。每一天是一" "個該月當日的數字及代表週幾的數字組成的元組,該月外的日期的該月當日數字為 0。" -#: ../../library/calendar.rst:150 +#: ../../library/calendar.rst:148 msgid "" "Return the data for the specified year ready for formatting (similar to :" "meth:`yeardatescalendar`). Entries in the week lists are day numbers. Day " @@ -222,22 +222,28 @@ msgstr "" "回傳用來格式化的指定年份的資料(類似 :meth:`yeardatescalendar`)。每一天是一" "個該月當日的數字,該月外的日期的該月當日數字為 0。" -#: ../../library/calendar.rst:157 +#: ../../library/calendar.rst:155 msgid "This class can be used to generate plain text calendars." msgstr "這個類別用來產生純文字的日曆。" -#: ../../library/calendar.rst:159 +#: ../../library/calendar.rst:157 msgid ":class:`TextCalendar` instances have the following methods:" msgstr ":class:`TextCalendar` 實例有以下方法:" -#: ../../library/calendar.rst:164 +#: ../../library/calendar.rst:161 +msgid "" +"Print a week's calendar as returned by :meth:`formatweek` and without a " +"final newline." +msgstr "印出一週的日曆,內容和 :meth:`formatweek` 回傳的一樣,且結尾不帶換行。" + +#: ../../library/calendar.rst:167 msgid "" "Return a string representing a single day formatted with the given *width*. " "If *theday* is ``0``, return a string of spaces of the specified width, " "representing an empty day. The *weekday* parameter is unused." msgstr "" -#: ../../library/calendar.rst:171 +#: ../../library/calendar.rst:174 msgid "" "Return a single week in a string with no newline. If *w* is provided, it " "specifies the width of the date columns, which are centered. Depends on the " @@ -245,21 +251,21 @@ msgid "" "`setfirstweekday` method." msgstr "" -#: ../../library/calendar.rst:179 +#: ../../library/calendar.rst:182 msgid "" "Return a string representing the name of a single weekday formatted to the " "specified *width*. The *weekday* parameter is an integer representing the " "day of the week, where ``0`` is Monday and ``6`` is Sunday." msgstr "" -#: ../../library/calendar.rst:186 +#: ../../library/calendar.rst:189 msgid "" "Return a string containing the header row of weekday names, formatted with " "the given *width* for each column. The names depend on the locale settings " "and are padded to the specified width." msgstr "" -#: ../../library/calendar.rst:193 +#: ../../library/calendar.rst:196 msgid "" "Return a month's calendar in a multi-line string. If *w* is provided, it " "specifies the width of the date columns, which are centered. If *l* is " @@ -271,7 +277,7 @@ msgstr "" "度。如果給定 *l*,它會指定每一週使用的行數。這個日曆會依據在建構函式中指定或" "者透過 :meth:`setfirstweekday` 方法設定的一週的第一天來輸出。" -#: ../../library/calendar.rst:202 +#: ../../library/calendar.rst:205 msgid "" "Return a string representing the month's name centered within the specified " "*width*. If *withyear* is ``True``, include the year in the output. The " @@ -279,11 +285,11 @@ msgid "" "to be formatted respectively." msgstr "" -#: ../../library/calendar.rst:210 +#: ../../library/calendar.rst:213 msgid "Print a month's calendar as returned by :meth:`formatmonth`." msgstr "印出一個月份的日曆,內容和 :meth:`formatmonth` 回傳的一樣。" -#: ../../library/calendar.rst:215 +#: ../../library/calendar.rst:218 msgid "" "Return a *m*-column calendar for an entire year as a multi-line string. " "Optional parameters *w*, *l*, and *c* are for date column width, lines per " @@ -297,20 +303,20 @@ msgstr "" "者透過 :meth:`setfirstweekday` 方法設定的一週的第一天來輸出。最早可以產生日曆" "的年份會依據平台而不同。" -#: ../../library/calendar.rst:225 +#: ../../library/calendar.rst:228 msgid "" "Print the calendar for an entire year as returned by :meth:`formatyear`." msgstr "印出一整年的日曆,內容和 :meth:`formatyear` 回傳的一樣。" -#: ../../library/calendar.rst:230 +#: ../../library/calendar.rst:233 msgid "This class can be used to generate HTML calendars." msgstr "這個類別用來產生 HTML 日曆。" -#: ../../library/calendar.rst:233 +#: ../../library/calendar.rst:236 msgid ":class:`!HTMLCalendar` instances have the following methods:" msgstr ":class:`!HTMLCalendar` 實例有以下方法:" -#: ../../library/calendar.rst:237 +#: ../../library/calendar.rst:240 msgid "" "Return a month's calendar as an HTML table. If *withyear* is true the year " "will be included in the header, otherwise just the month name will be used." @@ -318,26 +324,26 @@ msgstr "" "以 HTML 表格的形式回傳一個月份的日曆。如果 *withyear* 是 true 則標題會包含年" "份,否則只會有月份名稱。" -#: ../../library/calendar.rst:244 +#: ../../library/calendar.rst:247 msgid "" "Return a year's calendar as an HTML table. *width* (defaulting to 3) " "specifies the number of months per row." msgstr "" "以 HTML 表格的形式回傳一整年的日曆。*width*\\ (預設為 3)指定一列有幾個月。" -#: ../../library/calendar.rst:250 +#: ../../library/calendar.rst:253 msgid "" "Return a year's calendar as a complete HTML page. *width* (defaulting to 3) " "specifies the number of months per row. *css* is the name for the cascading " "style sheet to be used. :const:`None` can be passed if no style sheet should " "be used. *encoding* specifies the encoding to be used for the output " -"(defaulting to the system default encoding)." +"(defaulting to ``'utf-8'``)." msgstr "" "以完整 HTML 頁面的形式回傳一整年的日曆。*width*\\ (預設為 3)指定一列有幾個" "月。*css* 是要使用的 CSS (cascading style sheet) 名稱,可以給 :const:`None` " -"表示不使用任何 CSS。*encoding* 指定輸出使用的編碼(預設使用系統預設編碼)。" +"表示不使用任何 CSS。*encoding* 指定輸出使用的編碼(預設為 ``'utf-8'``)。" -#: ../../library/calendar.rst:259 +#: ../../library/calendar.rst:262 msgid "" "Return a month name as an HTML table row. If *withyear* is true the year " "will be included in the row, otherwise just the month name will be used." @@ -345,28 +351,28 @@ msgstr "" "以 HTML 表列的形式回傳一個月份的名稱。如果 *withyear* 是 true 則該列會包含年" "份,否則只會有月份名稱。" -#: ../../library/calendar.rst:264 +#: ../../library/calendar.rst:267 msgid "" ":class:`!HTMLCalendar` has the following attributes you can override to " "customize the CSS classes used by the calendar:" msgstr ":class:`!HTMLCalendar` 可以覆寫以下屬性來客製日曆所使用的 CSS 類別:" -#: ../../library/calendar.rst:269 +#: ../../library/calendar.rst:272 msgid "" "A list of CSS classes used for each weekday. The default class list is::" msgstr "對應一週每一天 CSS 類別的串列。預設的串列內容為: ::" -#: ../../library/calendar.rst:271 +#: ../../library/calendar.rst:274 msgid "" "cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" msgstr "" "cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" -#: ../../library/calendar.rst:273 +#: ../../library/calendar.rst:276 msgid "more styles can be added for each day::" msgstr "可以針對每一天增加更多樣式: ::" -#: ../../library/calendar.rst:275 +#: ../../library/calendar.rst:278 msgid "" "cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " "\"sat\", \"sun red\"]" @@ -374,15 +380,15 @@ msgstr "" "cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " "\"sat\", \"sun red\"]" -#: ../../library/calendar.rst:277 +#: ../../library/calendar.rst:280 msgid "Note that the length of this list must be seven items." msgstr "注意這個串列的長度必須是七個項目。" -#: ../../library/calendar.rst:282 +#: ../../library/calendar.rst:285 msgid "The CSS class for a weekday occurring in the previous or coming month." msgstr "跟當月為同一週且屬於前一個或下一個月份的日期使用的 CSS 類別。" -#: ../../library/calendar.rst:289 +#: ../../library/calendar.rst:292 msgid "" "A list of CSS classes used for weekday names in the header row. The default " "is the same as :attr:`cssclasses`." @@ -390,7 +396,7 @@ msgstr "" "在標題列中一週每一天名稱的 CSS 類別的串列。預設內容和 :attr:`cssclasses` 相" "同。" -#: ../../library/calendar.rst:297 +#: ../../library/calendar.rst:300 msgid "" "The month's head CSS class (used by :meth:`formatmonthname`). The default " "value is ``\"month\"``." @@ -398,7 +404,7 @@ msgstr "" "月份標題的 CSS 類別(由 :meth:`formatmonthname` 所使用),預設值是 " "``\"month\"``。" -#: ../../library/calendar.rst:305 +#: ../../library/calendar.rst:308 msgid "" "The CSS class for the whole month's table (used by :meth:`formatmonth`). The " "default value is ``\"month\"``." @@ -406,14 +412,14 @@ msgstr "" "整個月份表格的 CSS 類別(由 :meth:`formatmonth` 所使用),預設值是 " "``\"month\"``。" -#: ../../library/calendar.rst:313 +#: ../../library/calendar.rst:316 msgid "" "The CSS class for the whole year's table of tables (used by :meth:" "`formatyear`). The default value is ``\"year\"``." msgstr "" "整年表格的 CSS 類別(由 :meth:`formatyear` 所使用),預設值是 ``\"year\"``。" -#: ../../library/calendar.rst:321 +#: ../../library/calendar.rst:324 msgid "" "The CSS class for the table head for the whole year (used by :meth:" "`formatyear`). The default value is ``\"year\"``." @@ -421,7 +427,7 @@ msgstr "" "整年表格標題的 CSS 類別(由 :meth:`formatyear` 所使用),預設值是 " "``\"year\"``。" -#: ../../library/calendar.rst:327 +#: ../../library/calendar.rst:330 msgid "" "Note that although the naming for the above described class attributes is " "singular (e.g. ``cssclass_month`` ``cssclass_noday``), one can replace the " @@ -431,15 +437,15 @@ msgstr "" "``cssclass_noday``),你可以使用多個以空格隔開的 CSS 類別取代單一 CSS 類別," "例如: ::" -#: ../../library/calendar.rst:331 +#: ../../library/calendar.rst:334 msgid "\"text-bold text-red\"" msgstr "\"text-bold text-red\"" -#: ../../library/calendar.rst:333 +#: ../../library/calendar.rst:336 msgid "Here is an example how :class:`!HTMLCalendar` can be customized::" msgstr "以下是客製化 :class:`!HTMLCalendar` 的範例: ::" -#: ../../library/calendar.rst:335 +#: ../../library/calendar.rst:338 msgid "" "class CustomHTMLCal(calendar.HTMLCalendar):\n" " cssclasses = [style + \" text-nowrap\" for style in\n" @@ -455,7 +461,7 @@ msgstr "" " cssclass_month = \"text-center month\"\n" " cssclass_year = \"text-italic lead\"" -#: ../../library/calendar.rst:345 +#: ../../library/calendar.rst:348 msgid "" "This subclass of :class:`TextCalendar` can be passed a locale name in the " "constructor and will return month and weekday names in the specified locale." @@ -463,7 +469,7 @@ msgstr "" ":class:`TextCalendar` 的子類別,可以在建構函式傳入語系名稱,它會回傳指定語系" "的月份及一週每一天的名稱。" -#: ../../library/calendar.rst:351 +#: ../../library/calendar.rst:354 msgid "" "This subclass of :class:`HTMLCalendar` can be passed a locale name in the " "constructor and will return month and weekday names in the specified locale." @@ -471,7 +477,7 @@ msgstr "" ":class:`HTMLCalendar` 的子類別,可以在建構函式傳入語系名稱,它會回傳指定語系" "的月份及一週每一天的名稱。" -#: ../../library/calendar.rst:357 +#: ../../library/calendar.rst:360 msgid "" "The constructor, :meth:`!formatweekday` and :meth:`!formatmonthname` methods " "of these two classes temporarily change the ``LC_TIME`` locale to the given " @@ -482,11 +488,11 @@ msgstr "" "會把 ``LC_TIME`` 語系暫時改成給定的 *locale*。因為目前的語系是屬於整個行程 " "(process-wide) 的設定,它們不是執行緒安全的。" -#: ../../library/calendar.rst:363 +#: ../../library/calendar.rst:366 msgid "For simple text calendars this module provides the following functions." msgstr "這個模組提供以下函式給單純的文字日曆使用。" -#: ../../library/calendar.rst:367 +#: ../../library/calendar.rst:370 msgid "" "Sets the weekday (``0`` is Monday, ``6`` is Sunday) to start each week. The " "values :const:`MONDAY`, :const:`TUESDAY`, :const:`WEDNESDAY`, :const:" @@ -497,7 +503,7 @@ msgstr "" "`TUESDAY`、:const:`WEDNESDAY`、:const:`THURSDAY`、:const:`FRIDAY`、:const:" "`SATURDAY` 及 :const:`SUNDAY` 可以方便設定。例如設定一週的第一天為週日: ::" -#: ../../library/calendar.rst:372 +#: ../../library/calendar.rst:375 msgid "" "import calendar\n" "calendar.setfirstweekday(calendar.SUNDAY)" @@ -505,27 +511,27 @@ msgstr "" "import calendar\n" "calendar.setfirstweekday(calendar.SUNDAY)" -#: ../../library/calendar.rst:378 +#: ../../library/calendar.rst:381 msgid "Returns the current setting for the weekday to start each week." msgstr "回傳目前設定的一週的第一天。" -#: ../../library/calendar.rst:383 +#: ../../library/calendar.rst:386 msgid "" "Returns :const:`True` if *year* is a leap year, otherwise :const:`False`." msgstr "如果 *year* 是閏年回傳 :const:`True`,否則回傳 :const:`False`。" -#: ../../library/calendar.rst:388 +#: ../../library/calendar.rst:391 msgid "" "Returns the number of leap years in the range from *y1* to *y2* (exclusive), " "where *y1* and *y2* are years." msgstr "" "回傳從 *y1* 到 *y2*\\ (不包含)間有幾個閏年,其中 *y1* 和 *y2* 是年份。" -#: ../../library/calendar.rst:391 +#: ../../library/calendar.rst:394 msgid "This function works for ranges spanning a century change." msgstr "這個函式也適用在跨越世紀的時間範圍。" -#: ../../library/calendar.rst:396 +#: ../../library/calendar.rst:399 msgid "" "Returns the day of the week (``0`` is Monday) for *year* (``1970``--...), " "*month* (``1``--``12``), *day* (``1``--``31``)." @@ -533,19 +539,19 @@ msgstr "" "回傳 *year* 年 (``1970``--...) *month* 月 (``1``--``12``) *day* 日 (``1``--" "``31``) 是週幾(``0`` 是星期一)。" -#: ../../library/calendar.rst:402 +#: ../../library/calendar.rst:405 msgid "" "Return a header containing abbreviated weekday names. *width* specifies the " "width in characters for one weekday." msgstr "回傳包含一週每一天的名稱縮寫的標題。*width* 指定每一天的字元寬度。" -#: ../../library/calendar.rst:408 +#: ../../library/calendar.rst:411 msgid "" "Returns weekday of first day of the month and number of days in month, for " "the specified *year* and *month*." msgstr "回傳指定 *year* 年 *month* 月該月第一天代表週幾的數字及該月有多少天。" -#: ../../library/calendar.rst:414 +#: ../../library/calendar.rst:417 msgid "" "Returns a matrix representing a month's calendar. Each row represents a " "week; days outside of the month are represented by zeros. Each week begins " @@ -554,11 +560,11 @@ msgstr "" "回傳代表一個月份日曆的矩陣。每一列為一週;該月以外的日期以 0 表示。每一週以週" "一開始,除非有使用 :func:`setfirstweekday` 改變設定。" -#: ../../library/calendar.rst:421 +#: ../../library/calendar.rst:424 msgid "Prints a month's calendar as returned by :func:`month`." msgstr "印出一個月份的日曆,跟 :func:`month` 回傳的內容一樣。" -#: ../../library/calendar.rst:426 +#: ../../library/calendar.rst:429 msgid "" "Returns a month's calendar in a multi-line string using the :meth:" "`~TextCalendar.formatmonth` of the :class:`TextCalendar` class." @@ -566,12 +572,12 @@ msgstr "" "以多行字串的形式回傳一個月的日曆,使用 :class:`TextCalendar` 類別的 :meth:" "`~TextCalendar.formatmonth`。" -#: ../../library/calendar.rst:432 +#: ../../library/calendar.rst:435 msgid "" "Prints the calendar for an entire year as returned by :func:`calendar`." msgstr "印出一整年的日曆,跟 :func:`calendar` 回傳的內容一樣。" -#: ../../library/calendar.rst:437 +#: ../../library/calendar.rst:440 msgid "" "Returns a 3-column calendar for an entire year as a multi-line string using " "the :meth:`~TextCalendar.formatyear` of the :class:`TextCalendar` class." @@ -579,7 +585,7 @@ msgstr "" "以多行字串回傳三欄形式的一整年日曆,使用 :class:`TextCalendar` 類別的 :meth:" "`~TextCalendar.formatyear`。" -#: ../../library/calendar.rst:443 +#: ../../library/calendar.rst:446 msgid "" "An unrelated but handy function that takes a time tuple such as returned by " "the :func:`~time.gmtime` function in the :mod:`time` module, and returns the " @@ -591,29 +597,29 @@ msgstr "" "gmtime` 函式回傳的元組,並回傳對應的 Unix 時間戳,假設從 1970 開始及 POSIX 編" "碼。事實上,:func:`time.gmtime` 和 :func:`timegm` 是彼此相反的。" -#: ../../library/calendar.rst:450 +#: ../../library/calendar.rst:453 msgid "The :mod:`!calendar` module exports the following data attributes:" msgstr ":mod:`!calendar` 模組匯出以下資料屬性:" -#: ../../library/calendar.rst:454 +#: ../../library/calendar.rst:457 msgid "" "A sequence that represents the days of the week in the current locale, where " "Monday is day number 0." msgstr "以目前語系來表示的一週每一天名稱的序列,其中週一是第 0 天。" -#: ../../library/calendar.rst:464 +#: ../../library/calendar.rst:467 msgid "" "A sequence that represents the abbreviated days of the week in the current " "locale, where Mon is day number 0." msgstr "以目前語系來表示的一週每一天縮寫名稱的序列,其中 Mon 是第 0 天。" -#: ../../library/calendar.rst:479 +#: ../../library/calendar.rst:482 msgid "" "Aliases for the days of the week, where ``MONDAY`` is ``0`` and ``SUNDAY`` " "is ``6``." msgstr "一週每一天的別名,其中 ``MONDAY`` 是 ``0`` 而 ``SUNDAY`` 是 ``6``。" -#: ../../library/calendar.rst:487 +#: ../../library/calendar.rst:490 msgid "" "Enumeration defining days of the week as integer constants. The members of " "this enumeration are exported to the module scope as :data:`MONDAY` through :" @@ -622,7 +628,7 @@ msgstr "" "將一週中的幾天定義為整數常數的列舉。此列舉的成員將作為 :data:`MONDAY` 到 :" "data:`SUNDAY` 匯出到模組作用域。" -#: ../../library/calendar.rst:496 +#: ../../library/calendar.rst:499 msgid "" "A sequence that represents the months of the year in the current locale. " "This follows normal convention of January being month number 1, so it has a " @@ -631,7 +637,16 @@ msgstr "" "以目前語系來表示的一年每個月份名稱的序列。它按照一般慣例以數字 1 代表一月,因" "此它的長度為 13,而 ``month_name[0]`` 是空字串。" -#: ../../library/calendar.rst:507 +#: ../../library/calendar.rst:509 +msgid "" +"In locales with alternative month names forms, the :data:`!month_name` " +"sequence may not be suitable when a month name stands by itself and not as " +"part of a date. For instance, in Greek and in many Slavic and Baltic " +"languages, :data:`!month_name` will produce the month in genitive case. Use :" +"data:`standalone_month_name` for a form suitable for standalone use." +msgstr "" + +#: ../../library/calendar.rst:518 msgid "" "A sequence that represents the abbreviated months of the year in the current " "locale. This follows normal convention of January being month number 1, so " @@ -642,12 +657,38 @@ msgstr "" #: ../../library/calendar.rst:528 msgid "" +"In locales with alternative month names forms, the :data:`!month_abbr` " +"sequence may not be suitable when a month name stands by itself and not as " +"part of a date. Use :data:`standalone_month_abbr` for a form suitable for " +"standalone use." +msgstr "" + +#: ../../library/calendar.rst:535 +msgid "" +"A sequence that represents the months of the year in the current locale in " +"the standalone form if the locale provides one. Else it is equivalent to :" +"data:`month_name`." +msgstr "" +"以目前語系來表示的一年每個月份名稱的序列,若該語系有提供獨立形式 (standalone " +"form) 則使用獨立形式,否則等同於 :data:`month_name`。" + +#: ../../library/calendar.rst:544 +msgid "" +"A sequence that represents the abbreviated months of the year in the current " +"locale in the standalone form if the locale provides one. Else it is " +"equivalent to :data:`month_abbr`." +msgstr "" +"以目前語系來表示的一年每個月份縮寫名稱的序列,若該語系有提供獨立形式 " +"(standalone form) 則使用獨立形式,否則等同於 :data:`month_abbr`。" + +#: ../../library/calendar.rst:564 +msgid "" "Aliases for the months of the year, where ``JANUARY`` is ``1`` and " "``DECEMBER`` is ``12``." msgstr "" "一年內每個月的別名,其中 ``JANUARY`` 是 ``1`` 而 ``DECEMBER`` 是 ``12``。" -#: ../../library/calendar.rst:536 +#: ../../library/calendar.rst:572 msgid "" "Enumeration defining months of the year as integer constants. The members of " "this enumeration are exported to the module scope as :data:`JANUARY` " @@ -656,11 +697,11 @@ msgstr "" "將一年中的月份定義為整數常數的列舉。此列舉的成員將作為 :data:`JANUARY` 到 :" "data:`DECEMBER` 匯出到模組作用域。" -#: ../../library/calendar.rst:543 +#: ../../library/calendar.rst:579 msgid "The :mod:`!calendar` module defines the following exceptions:" msgstr ":mod:`!calendar` 模組定義了以下例外:" -#: ../../library/calendar.rst:547 +#: ../../library/calendar.rst:583 msgid "" "A subclass of :exc:`ValueError` and :exc:`IndexError`, raised when the given " "month number is outside of the range 1-12 (inclusive)." @@ -668,56 +709,56 @@ msgstr "" ":exc:`ValueError` 和 :exc:`IndexError` 的子類別,當給定的月份數字超出 1-12 範" "圍(含)時引發。" -#: ../../library/calendar.rst:550 +#: ../../library/calendar.rst:586 msgid "" ":exc:`IllegalMonthError` is now also a subclass of :exc:`ValueError`. New " "code should avoid catching :exc:`IndexError`." msgstr "" -#: ../../library/calendar.rst:557 +#: ../../library/calendar.rst:593 msgid "The invalid month number." msgstr "無效的月份號。" -#: ../../library/calendar.rst:562 +#: ../../library/calendar.rst:598 msgid "" "A subclass of :exc:`ValueError`, raised when the given weekday number is " "outside of the range 0-6 (inclusive)." msgstr "" ":exc:`ValueError` 的子類別,當給定的週幾的數字超出 0-6(含)範圍時引發。" -#: ../../library/calendar.rst:567 +#: ../../library/calendar.rst:603 msgid "The invalid weekday number." msgstr "無效的週幾編號。" -#: ../../library/calendar.rst:572 +#: ../../library/calendar.rst:608 msgid "Module :mod:`datetime`" msgstr ":mod:`datetime` 模組" -#: ../../library/calendar.rst:573 +#: ../../library/calendar.rst:609 msgid "" "Object-oriented interface to dates and times with similar functionality to " "the :mod:`time` module." msgstr "日期與時間的物件導向介面,和 :mod:`time` 模組有相似的功能。" -#: ../../library/calendar.rst:576 +#: ../../library/calendar.rst:612 msgid "Module :mod:`time`" msgstr ":mod:`time` 模組" -#: ../../library/calendar.rst:577 +#: ../../library/calendar.rst:613 msgid "Low-level time related functions." msgstr "底層的時間相關函式。" -#: ../../library/calendar.rst:583 +#: ../../library/calendar.rst:619 msgid "Command-line usage" msgstr "命令列用法" -#: ../../library/calendar.rst:587 +#: ../../library/calendar.rst:623 msgid "" "The :mod:`!calendar` module can be executed as a script from the command " "line to interactively print a calendar." msgstr ":mod:`!calendar` 模組可以作為腳本從命令列執行,並以互動方式列印日曆。" -#: ../../library/calendar.rst:590 +#: ../../library/calendar.rst:626 msgid "" "python -m calendar [-h] [-L LOCALE] [-e ENCODING] [-t {text,html}]\n" " [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" @@ -727,11 +768,11 @@ msgstr "" " [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" " [-f FIRST_WEEKDAY] [year] [month]" -#: ../../library/calendar.rst:597 +#: ../../library/calendar.rst:633 msgid "For example, to print a calendar for the year 2000:" msgstr "例如,要列印 2000 年的日曆:" -#: ../../library/calendar.rst:599 +#: ../../library/calendar.rst:635 msgid "" "$ python -m calendar 2000\n" " 2000\n" @@ -809,53 +850,52 @@ msgstr "" "23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31\n" "30 31" -#: ../../library/calendar.rst:640 +#: ../../library/calendar.rst:676 msgid "The following options are accepted:" msgstr "接受以下選項:" -#: ../../library/calendar.rst:647 +#: ../../library/calendar.rst:683 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/calendar.rst:652 +#: ../../library/calendar.rst:688 msgid "The locale to use for month and weekday names. Defaults to English." msgstr "用於月份和週幾名稱的語系。預設為英語。" -#: ../../library/calendar.rst:658 +#: ../../library/calendar.rst:694 msgid "" "The encoding to use for output. :option:`--encoding` is required if :option:" "`--locale` is set." msgstr "" "用於輸出的編碼。如有設定 :option:`--locale` 則必須給定 :option:`--encoding`。" -#: ../../library/calendar.rst:664 +#: ../../library/calendar.rst:700 msgid "Print the calendar to the terminal as text, or as an HTML document." msgstr "將日曆以文字或 HTML 文件的形式印出到終端機。" -#: ../../library/calendar.rst:670 +#: ../../library/calendar.rst:706 msgid "" "The weekday to start each week. Must be a number between 0 (Monday) and 6 " "(Sunday). Defaults to 0." msgstr "一週起始的日子。必須是 0(週一)到 6(週日)之間的數字。預設為 0。" -#: ../../library/calendar.rst:678 +#: ../../library/calendar.rst:714 msgid "The year to print the calendar for. Defaults to the current year." msgstr "印出日曆的年份。預設為目前年份。" -#: ../../library/calendar.rst:684 +#: ../../library/calendar.rst:720 msgid "" "The month of the specified :option:`year` to print the calendar for. Must be " -"a number between 1 and 12, and may only be used in text mode. Defaults to " -"printing a calendar for the full year." +"a number between 1 and 12. Defaults to printing a calendar for the full year." msgstr "" -"要列印日曆的指定 :option:`year` 的月份。必須是 1 到 12 之間的數字,並且只能在" -"文字模式下使用。預設列印全年日曆。" +"要列印日曆的指定 :option:`year` 的月份。必須是 1 到 12 之間的數字。預設列印全" +"年日曆。" -#: ../../library/calendar.rst:690 +#: ../../library/calendar.rst:725 msgid "*Text-mode options:*" msgstr "*文字模式選項:*" -#: ../../library/calendar.rst:694 +#: ../../library/calendar.rst:729 msgid "" "The width of the date column in terminal columns. The date is printed " "centred in the column. Any value lower than 2 is ignored. Defaults to 2." @@ -863,7 +903,7 @@ msgstr "" "終端機行中日期行的寬度。日期印出在行的中央。任何小於 2 的值都會被忽略。預設" "為 2。" -#: ../../library/calendar.rst:702 +#: ../../library/calendar.rst:737 msgid "" "The number of lines for each week in terminal rows. The date is printed top-" "aligned. Any value lower than 1 is ignored. Defaults to 1." @@ -871,27 +911,34 @@ msgstr "" "終端機列中每週的列數。日期印出時頂部會對齊。任何小於 1 的值都會被忽略。預設" "為 1。" -#: ../../library/calendar.rst:710 +#: ../../library/calendar.rst:745 msgid "" "The space between months in columns. Any value lower than 2 is ignored. " "Defaults to 6." msgstr "行中月份之間的間距。任何小於 2 的值都會被忽略。預設為 6。" -#: ../../library/calendar.rst:717 +#: ../../library/calendar.rst:752 msgid "The number of months printed per row. Defaults to 3." msgstr "每列印出的月份數量。預設為 3。" -#: ../../library/calendar.rst:720 +#: ../../library/calendar.rst:755 msgid "" "By default, today's date is highlighted in color and can be :ref:`controlled " "using environment variables `." msgstr "" -#: ../../library/calendar.rst:724 +#: ../../library/calendar.rst:759 +msgid "" +"By default, the month is now also highlighted in color, and the days of the " +"week are also in color. This behavior can be :ref:`controlled using " +"environment variables `." +msgstr "" + +#: ../../library/calendar.rst:764 msgid "*HTML-mode options:*" msgstr "*HTML 模式選項:*" -#: ../../library/calendar.rst:728 +#: ../../library/calendar.rst:768 msgid "" "The path of a CSS stylesheet to use for the calendar. This must either be " "relative to the generated HTML, or an absolute HTTP or ``file:///`` URL." diff --git a/library/cmd.po b/library/cmd.po index 9078a8a6443..76518d94718 100644 --- a/library/cmd.po +++ b/library/cmd.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-05-19 20:25+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!cmd` --- Support for line-oriented command interpreters" msgstr ":mod:`!cmd` --- 以列為導向的命令直譯器支援" -#: ../../library/cmd.rst:9 +#: ../../library/cmd.rst:7 msgid "**Source code:** :source:`Lib/cmd.py`" msgstr "**原始碼:**\\ :source:`Lib/cmd.py`" -#: ../../library/cmd.rst:13 +#: ../../library/cmd.rst:11 msgid "" "The :class:`Cmd` class provides a simple framework for writing line-oriented " "command interpreters. These are often useful for test harnesses, " @@ -36,7 +36,7 @@ msgstr "" ":class:`Cmd` 類別提供了一個簡單的架構,用於撰寫列導向的命令直譯器。這類直譯器" "常用於測試控制工具、管理工具以及日後將包裝於更高階介面的原型中。" -#: ../../library/cmd.rst:20 +#: ../../library/cmd.rst:18 msgid "" "A :class:`Cmd` instance or subclass instance is a line-oriented interpreter " "framework. There is no good reason to instantiate :class:`Cmd` itself; " @@ -48,7 +48,7 @@ msgstr "" "化 :class:`Cmd` 本身;它更適合作為你自己定義的直譯器類別的父類別,讓你能繼" "承 :class:`Cmd` 的方法,並封裝動作方法。" -#: ../../library/cmd.rst:25 +#: ../../library/cmd.rst:23 msgid "" "The optional argument *completekey* is the :mod:`readline` name of a " "completion key; it defaults to :kbd:`Tab`. If *completekey* is not :const:" @@ -59,7 +59,7 @@ msgstr "" "為 :kbd:`Tab`。若 *completekey* 不為 :const:`None` 且 :mod:`readline` 可用," "則會自動啟用命令自動完成功能。" -#: ../../library/cmd.rst:29 +#: ../../library/cmd.rst:27 msgid "" "The default, ``'tab'``, is treated specially, so that it refers to the :kbd:" "`Tab` key on every :data:`readline.backend`. Specifically, if :data:" @@ -72,7 +72,7 @@ msgstr "" "``Cmd`` 會改用 ``'^I'`` 取代 ``'tab'``。請注意,其他值不會有此處理方式,且可" "能僅能在特定的後端中適用。" -#: ../../library/cmd.rst:36 +#: ../../library/cmd.rst:34 msgid "" "The optional arguments *stdin* and *stdout* specify the input and output " "file objects that the Cmd instance or subclass instance will use for input " @@ -82,7 +82,7 @@ msgstr "" "可選引數 *stdin* 與 *stdout* 用來指定 Cmd 實例或其子類別實例所使用的輸入與輸" "出檔案物件。若未指定,預設為 :data:`sys.stdin` 與 :data:`sys.stdout`。" -#: ../../library/cmd.rst:41 +#: ../../library/cmd.rst:39 msgid "" "If you want a given *stdin* to be used, make sure to set the instance's :" "attr:`use_rawinput` attribute to ``False``, otherwise *stdin* will be " @@ -91,19 +91,19 @@ msgstr "" "若你希望使用指定的 *stdin*,請務必將該實例的 :attr:`use_rawinput` 屬性設為 " "``False``,否則 *stdin* 會被忽略。" -#: ../../library/cmd.rst:45 +#: ../../library/cmd.rst:43 msgid "``completekey='tab'`` is replaced by ``'^I'`` for ``editline``." msgstr "對於 ``editline``,``completekey='tab'`` 會被替換為 ``'^I'``。" -#: ../../library/cmd.rst:52 +#: ../../library/cmd.rst:50 msgid "Cmd Objects" msgstr "Cmd 物件" -#: ../../library/cmd.rst:54 +#: ../../library/cmd.rst:52 msgid "A :class:`Cmd` instance has the following methods:" msgstr ":class:`Cmd` 實例具有以下方法:" -#: ../../library/cmd.rst:59 +#: ../../library/cmd.rst:57 msgid "" "Repeatedly issue a prompt, accept input, parse an initial prefix off the " "received input, and dispatch to action methods, passing them the remainder " @@ -112,7 +112,7 @@ msgstr "" "重複顯示提示字元、接收輸入、剖析接收到的輸入字串前綴,並派發給動作方法,將其" "餘部分作為引數傳遞給它們" -#: ../../library/cmd.rst:63 +#: ../../library/cmd.rst:61 msgid "" "The optional argument is a banner or intro string to be issued before the " "first prompt (this overrides the :attr:`intro` class attribute)." @@ -120,7 +120,7 @@ msgstr "" "此可選引數為橫幅或導言字串,會在首次顯示提示字元前輸出(此值會覆寫 :attr:" "`intro` 類別屬性)。" -#: ../../library/cmd.rst:66 +#: ../../library/cmd.rst:64 msgid "" "If the :mod:`readline` module is loaded, input will automatically inherit :" "program:`bash`\\ -like history-list editing (e.g. :kbd:`Control-P` scrolls " @@ -133,11 +133,11 @@ msgstr "" "下捲動至下一個命令,:kbd:`Control-F` 非破壞性地將游標向右移動,:kbd:`Control-" "B` 非破壞性地將游標向左移動等)。" -#: ../../library/cmd.rst:72 +#: ../../library/cmd.rst:70 msgid "An end-of-file on input is passed back as the string ``'EOF'``." msgstr "當輸入為檔案結尾(EOF)時,會傳回字串 ``'EOF'``。" -#: ../../library/cmd.rst:78 +#: ../../library/cmd.rst:76 msgid "" "An interpreter instance will recognize a command name ``foo`` if and only if " "it has a method :meth:`!do_foo`. As a special case, a line beginning with " @@ -150,7 +150,7 @@ msgstr "" "是,以字元 ``'!'`` 開頭的列會被派發至 :meth:`!do_shell` 方法(若該方法已定" "義)。" -#: ../../library/cmd.rst:84 +#: ../../library/cmd.rst:82 msgid "" "This method will return when the :meth:`postcmd` method returns a true " "value. The *stop* argument to :meth:`postcmd` is the return value from the " @@ -159,7 +159,7 @@ msgstr "" "當 :meth:`postcmd` 方法回傳真值時,此方法將會結束。傳遞給 :meth:`postcmd` 的 " "*stop* 引數是該命令對應的 :meth:`!do_\\*` 方法的回傳值。" -#: ../../library/cmd.rst:88 +#: ../../library/cmd.rst:86 msgid "" "If completion is enabled, completing commands will be done automatically, " "and completing of commands args is done by calling :meth:`!complete_foo` " @@ -176,7 +176,7 @@ msgstr "" "*line* 是目前的輸入列(前置空白會被移除),*begidx* 和 *endidx* 則分別是前綴" "字串的起始與結束索引,可用來根據引數所在的位置提供不同的自動完成結果。" -#: ../../library/cmd.rst:99 +#: ../../library/cmd.rst:97 msgid "" "All subclasses of :class:`Cmd` inherit a predefined :meth:`!do_help`. This " "method, called with an argument ``'bar'``, invokes the corresponding method :" @@ -192,7 +192,7 @@ msgstr "" "`!do_help` 會列出所有可用的說明主題(也就是所有具有對應 :meth:`!help_\\*` 方" "法或有說明字串的命令),並且也會列出所有尚未記錄的命令。" -#: ../../library/cmd.rst:110 +#: ../../library/cmd.rst:108 msgid "" "Interpret the argument as though it had been typed in response to the " "prompt. This may be overridden, but should not normally need to be; see the :" @@ -208,7 +208,7 @@ msgstr "" "若有對應 *str* 命令的 :meth:`!do_\\*` 方法,則會回傳該方法的回傳值;否則,回" "傳值將來自 :meth:`default` 方法。" -#: ../../library/cmd.rst:121 +#: ../../library/cmd.rst:119 msgid "" "Method called when an empty line is entered in response to the prompt. If " "this method is not overridden, it repeats the last nonempty command entered." @@ -216,7 +216,7 @@ msgstr "" "在回應提示字元時輸入空白列,會呼叫此方法。若此方法未被覆寫,則會重復上一次輸" "入的非空命令。" -#: ../../library/cmd.rst:127 +#: ../../library/cmd.rst:125 msgid "" "Method called on an input line when the command prefix is not recognized. If " "this method is not overridden, it prints an error message and returns." @@ -224,7 +224,7 @@ msgstr "" "當輸入列中的命令前綴無法辨識時,會呼叫此方法。若此方法未被覆寫,則會輸出並回" "傳錯誤訊息。" -#: ../../library/cmd.rst:133 +#: ../../library/cmd.rst:131 msgid "" "Method called to complete an input line when no command-specific :meth:`!" "complete_\\*` method is available. By default, it returns an empty list." @@ -232,7 +232,7 @@ msgstr "" "當沒有對應特定命令的 :meth:`!complete_\\*` 方法時,會呼叫此方法以完成輸入列。" "預設會回傳空串列。" -#: ../../library/cmd.rst:139 +#: ../../library/cmd.rst:137 msgid "" "Method called to display a list of strings as a compact set of columns. Each " "column is only as wide as necessary. Columns are separated by two spaces for " @@ -241,7 +241,7 @@ msgstr "" "此方法用來將字串串列顯示為緊湊的欄集合。每一欄的寬度僅足以容納其內容,各欄之" "間以兩個空格分隔,以提高可讀性。" -#: ../../library/cmd.rst:146 +#: ../../library/cmd.rst:144 msgid "" "Hook method executed just before the command line *line* is interpreted, but " "after the input prompt is generated and issued. This method is a stub in :" @@ -255,7 +255,7 @@ msgstr "" "`onecmd` 方法所執行的命令;:meth:`precmd` 的實作可以重寫該命令,或直接回傳未" "變更的 *line*。" -#: ../../library/cmd.rst:156 +#: ../../library/cmd.rst:154 msgid "" "Hook method executed just after a command dispatch is finished. This method " "is a stub in :class:`Cmd`; it exists to be overridden by subclasses. *line* " @@ -270,7 +270,7 @@ msgstr "" "meth:`postcmd` 後是否應終止執行;該值即為 :meth:`onecmd` 方法的回傳值。本方法" "的回傳值將會更新內部的 *stop* 旗標;若回傳 false,則會繼續進行直譯。" -#: ../../library/cmd.rst:167 +#: ../../library/cmd.rst:165 msgid "" "Hook method executed once when :meth:`cmdloop` is called. This method is a " "stub in :class:`Cmd`; it exists to be overridden by subclasses." @@ -278,7 +278,7 @@ msgstr "" "當 :meth:`cmdloop` 被呼叫時,此勾點方法會執行一次。這個方法在 :class:`Cmd` 類" "別中為 stub,預期由子類別覆寫。" -#: ../../library/cmd.rst:173 +#: ../../library/cmd.rst:171 msgid "" "Hook method executed once when :meth:`cmdloop` is about to return. This " "method is a stub in :class:`Cmd`; it exists to be overridden by subclasses." @@ -286,24 +286,24 @@ msgstr "" "當 :meth:`cmdloop` 即將回傳時,此勾點方法會執行一次。這個方法在 :class:`Cmd` " "類別中為 stub,預期由子類別覆寫。" -#: ../../library/cmd.rst:177 +#: ../../library/cmd.rst:175 msgid "" "Instances of :class:`Cmd` subclasses have some public instance variables:" msgstr ":class:`Cmd` 子類別的實例包含一些公開的實例變數:" -#: ../../library/cmd.rst:181 +#: ../../library/cmd.rst:179 msgid "The prompt issued to solicit input." msgstr "用來請求輸入的提示字元。" -#: ../../library/cmd.rst:186 +#: ../../library/cmd.rst:184 msgid "The string of characters accepted for the command prefix." msgstr "可作為命令前綴的字元字串" -#: ../../library/cmd.rst:191 +#: ../../library/cmd.rst:189 msgid "The last nonempty command prefix seen." msgstr "最後一個遇到的非空命令前綴" -#: ../../library/cmd.rst:196 +#: ../../library/cmd.rst:194 msgid "" "A list of queued input lines. The cmdqueue list is checked in :meth:" "`cmdloop` when new input is needed; if it is nonempty, its elements will be " @@ -312,19 +312,19 @@ msgstr "" "排入佇列的輸入列串列。當 :meth:`cmdloop` 需要新輸入時,會檢查 cmdqueue 串列;" "若不為空,其元素將依序處理,就如同它們是在提示字元中輸入的一樣。" -#: ../../library/cmd.rst:203 +#: ../../library/cmd.rst:201 msgid "" "A string to issue as an intro or banner. May be overridden by giving the :" "meth:`cmdloop` method an argument." msgstr "" "作為簡介或橫幅的字串。可透過為 :meth:`cmdloop` 方法提供引數來覆寫此內容。" -#: ../../library/cmd.rst:209 +#: ../../library/cmd.rst:207 msgid "" "The header to issue if the help output has a section for documented commands." msgstr "若說明輸出包含已記錄命令的區段,則會顯示的標頭字串。" -#: ../../library/cmd.rst:214 +#: ../../library/cmd.rst:212 msgid "" "The header to issue if the help output has a section for miscellaneous help " "topics (that is, there are :meth:`!help_\\*` methods without corresponding :" @@ -333,7 +333,7 @@ msgstr "" "若說明輸出包含雜項說明主題的區段(也就是存在 :meth:`!help_\\*` 方法但沒有對應" "的 :meth:`!do_\\*` 方法),則會顯示的標頭字串。" -#: ../../library/cmd.rst:221 +#: ../../library/cmd.rst:219 msgid "" "The header to issue if the help output has a section for undocumented " "commands (that is, there are :meth:`!do_\\*` methods without corresponding :" @@ -342,7 +342,7 @@ msgstr "" "若說明輸出包含未記錄命令的區段(也就是存在 :meth:`!do_\\*` 方法但沒有對應的 :" "meth:`!help_\\*` 方法),則會顯示的標頭字串。" -#: ../../library/cmd.rst:228 +#: ../../library/cmd.rst:226 msgid "" "The character used to draw separator lines under the help-message headers. " "If empty, no ruler line is drawn. It defaults to ``'='``." @@ -350,7 +350,7 @@ msgstr "" "用於在說明訊息的標頭下方繪製分隔線的字元。若為空,則不會繪製分隔線。預設為 " "``'='``。" -#: ../../library/cmd.rst:234 +#: ../../library/cmd.rst:232 msgid "" "A flag, defaulting to true. If true, :meth:`cmdloop` uses :func:`input` to " "display a prompt and read the next command; if false, :data:`sys.stdout." @@ -365,18 +365,18 @@ msgstr "" "統中,透過 import :mod:`readline` module,直譯器將自動支援類似 :program:" "`Emacs` 的列編輯與命令歷史快捷鍵。)" -#: ../../library/cmd.rst:244 +#: ../../library/cmd.rst:242 msgid "Cmd Example" msgstr "Cmd 範例" -#: ../../library/cmd.rst:248 +#: ../../library/cmd.rst:244 msgid "" "The :mod:`!cmd` module is mainly useful for building custom shells that let " "a user work with a program interactively." msgstr "" ":mod:`!cmd` module 主要用於建構自訂 shell,讓使用者能以互動方式操作程式。" -#: ../../library/cmd.rst:251 +#: ../../library/cmd.rst:247 msgid "" "This section presents a simple example of how to build a shell around a few " "of the commands in the :mod:`turtle` module." @@ -384,7 +384,7 @@ msgstr "" "本節將示範如何以 :mod:`turtle` module 中的幾個命令為基礎,建立一個簡單的 " "shell。" -#: ../../library/cmd.rst:254 +#: ../../library/cmd.rst:250 msgid "" "Basic turtle commands such as :meth:`~turtle.forward` are added to a :class:" "`Cmd` subclass with method named :meth:`!do_forward`. The argument is " @@ -395,7 +395,7 @@ msgstr "" "do_forward` 的方法加入至 :class:`Cmd` 子類別中。傳入的引數會轉換為數值,並傳" "送給 turtle 模組。該方法的說明字串會用於 shell 所提供的說明功能中。" -#: ../../library/cmd.rst:259 +#: ../../library/cmd.rst:255 msgid "" "The example also includes a basic record and playback facility implemented " "with the :meth:`~Cmd.precmd` method which is responsible for converting the " @@ -407,7 +407,7 @@ msgstr "" "方法,負責將輸入轉為小寫並寫入檔案。:meth:`!do_playback` 方法則會讀取該檔案," "並將錄製的命令加入 :attr:`~Cmd.cmdqueue` 中以供立即重播::" -#: ../../library/cmd.rst:265 +#: ../../library/cmd.rst:261 msgid "" "import cmd, sys\n" "from turtle import *\n" @@ -560,7 +560,7 @@ msgstr "" "if __name__ == '__main__':\n" " TurtleShell().cmdloop()" -#: ../../library/cmd.rst:340 +#: ../../library/cmd.rst:336 msgid "" "Here is a sample session with the turtle shell showing the help functions, " "using blank lines to repeat commands, and the simple record and playback " @@ -569,7 +569,7 @@ msgstr "" "以下是與 turtle shell 的一段範例互動,展示了說明功能、使用空白列重複執行命" "令,以及簡單的錄製與重播功能:" -#: ../../library/cmd.rst:343 +#: ../../library/cmd.rst:339 msgid "" "Welcome to the turtle shell. Type help or ? to list commands.\n" "\n" @@ -687,14 +687,14 @@ msgstr "" "(turtle) bye\n" "感謝使用 Turtle" -#: ../../library/cmd.rst:74 +#: ../../library/cmd.rst:72 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/cmd.rst:74 +#: ../../library/cmd.rst:72 msgid "in a command interpreter" msgstr "於 command interpreter(命令直譯器)中" -#: ../../library/cmd.rst:74 +#: ../../library/cmd.rst:72 msgid "! (exclamation)" msgstr "! (驚嘆號)" diff --git a/library/cmdline.po b/library/cmdline.po index 0c92f34f261..70a9bba0d0b 100644 --- a/library/cmdline.po +++ b/library/cmdline.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-18 00:15+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-10-14 16:03+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -50,8 +50,8 @@ msgid ":ref:`compileall `" msgstr ":ref:`compileall `" #: ../../library/cmdline.rst:15 -msgid ":mod:`cProfile`: see :ref:`profile `" -msgstr ":mod:`cProfile`: 請見 :ref:`profile `" +msgid "``cProfile``: see :ref:`profiling.tracing `" +msgstr "``cProfile``:請見 :ref:`profiling.tracing `" #: ../../library/cmdline.rst:16 msgid ":ref:`dis `" @@ -126,105 +126,112 @@ msgid ":mod:`poplib`" msgstr ":mod:`poplib`" #: ../../library/cmdline.rst:34 -msgid ":ref:`profile `" -msgstr ":ref:`profile `" +msgid ":ref:`profiling.sampling `" +msgstr ":ref:`profiling.sampling `" #: ../../library/cmdline.rst:35 -msgid ":mod:`pstats`" -msgstr ":mod:`pstats`" +msgid ":ref:`profiling.tracing `" +msgstr ":ref:`profiling.tracing `" #: ../../library/cmdline.rst:36 +msgid ":ref:`pstats `" +msgstr ":ref:`pstats `" + +#: ../../library/cmdline.rst:37 msgid ":ref:`py_compile `" msgstr ":ref:`py_compile `" -#: ../../library/cmdline.rst:37 +#: ../../library/cmdline.rst:38 msgid ":mod:`pyclbr`" msgstr ":mod:`pyclbr`" -#: ../../library/cmdline.rst:38 +#: ../../library/cmdline.rst:39 msgid ":mod:`pydoc`" msgstr ":mod:`pydoc`" -#: ../../library/cmdline.rst:39 +#: ../../library/cmdline.rst:40 msgid ":mod:`quopri`" msgstr ":mod:`quopri`" -#: ../../library/cmdline.rst:40 +#: ../../library/cmdline.rst:41 msgid ":ref:`random `" msgstr ":ref:`random `" -#: ../../library/cmdline.rst:41 +#: ../../library/cmdline.rst:42 msgid ":mod:`runpy`" msgstr ":mod:`runpy`" -#: ../../library/cmdline.rst:42 +#: ../../library/cmdline.rst:43 msgid ":ref:`site `" msgstr ":ref:`site `" -#: ../../library/cmdline.rst:43 +#: ../../library/cmdline.rst:44 msgid ":ref:`sqlite3 `" msgstr ":ref:`sqlite3 `" -#: ../../library/cmdline.rst:44 +#: ../../library/cmdline.rst:45 msgid ":ref:`symtable `" msgstr ":ref:`symtable `" -#: ../../library/cmdline.rst:45 +#: ../../library/cmdline.rst:46 msgid ":ref:`sysconfig `" msgstr ":ref:`sysconfig `" -#: ../../library/cmdline.rst:46 +#: ../../library/cmdline.rst:47 msgid ":mod:`tabnanny`" msgstr ":mod:`tabnanny`" -#: ../../library/cmdline.rst:47 +#: ../../library/cmdline.rst:48 msgid ":ref:`tarfile `" msgstr ":ref:`tarfile `" -#: ../../library/cmdline.rst:48 +#: ../../library/cmdline.rst:49 msgid ":mod:`!this`" msgstr ":mod:`!this`" -#: ../../library/cmdline.rst:49 +#: ../../library/cmdline.rst:50 msgid ":ref:`timeit `" msgstr ":ref:`timeit `" -#: ../../library/cmdline.rst:50 +#: ../../library/cmdline.rst:51 msgid ":ref:`tokenize `" msgstr ":ref:`tokenize `" -#: ../../library/cmdline.rst:51 +#: ../../library/cmdline.rst:52 msgid ":ref:`trace `" msgstr ":ref:`trace `" -#: ../../library/cmdline.rst:52 +#: ../../library/cmdline.rst:53 msgid ":mod:`turtledemo`" msgstr ":mod:`turtledemo`" -#: ../../library/cmdline.rst:53 +#: ../../library/cmdline.rst:54 msgid ":ref:`unittest `" msgstr ":ref:`unittest `" -#: ../../library/cmdline.rst:54 +#: ../../library/cmdline.rst:55 msgid ":ref:`uuid `" msgstr ":ref:`uuid `" -#: ../../library/cmdline.rst:55 +#: ../../library/cmdline.rst:56 msgid ":ref:`venv `" msgstr ":ref:`venv `" -#: ../../library/cmdline.rst:56 +#: ../../library/cmdline.rst:57 msgid ":ref:`webbrowser `" msgstr ":ref:`webbrowser `" -#: ../../library/cmdline.rst:57 +#: ../../library/cmdline.rst:58 msgid ":ref:`zipapp `" msgstr ":ref:`zipapp `" -#: ../../library/cmdline.rst:58 +#: ../../library/cmdline.rst:59 msgid ":ref:`zipfile `" msgstr ":ref:`zipfile `" -#: ../../library/cmdline.rst:60 +#: ../../library/cmdline.rst:61 msgid "See also the :ref:`Python command-line interface `." msgstr "另請見 :ref:`Python 命令列介面 `。" + +#~ msgid ":mod:`pstats`" +#~ msgstr ":mod:`pstats`" diff --git a/library/codecs.po b/library/codecs.po index 221eb840697..0f9c1d9f069 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-16 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!codecs` --- Codec registry and base classes" msgstr ":mod:`!codecs` --- 編解碼器註冊表和基底類別" -#: ../../library/codecs.rst:11 +#: ../../library/codecs.rst:7 msgid "**Source code:** :source:`Lib/codecs.py`" msgstr "**原始碼:**\\ :source:`Lib/codecs.py`" -#: ../../library/codecs.rst:23 +#: ../../library/codecs.rst:19 msgid "" "This module defines base classes for standard Python codecs (encoders and " "decoders) and provides access to the internal Python codec registry, which " @@ -38,17 +38,17 @@ msgid "" "encode to :class:`bytes`." msgstr "" -#: ../../library/codecs.rst:33 +#: ../../library/codecs.rst:29 msgid "" "The module defines the following functions for encoding and decoding with " "any codec:" msgstr "這個模組定義了以下函式,用於以任何編解碼器來編碼與解碼:" -#: ../../library/codecs.rst:38 +#: ../../library/codecs.rst:34 msgid "Encodes *obj* using the codec registered for *encoding*." msgstr "" -#: ../../library/codecs.rst:40 +#: ../../library/codecs.rst:36 msgid "" "*Errors* may be given to set the desired error handling scheme. The default " "error handler is ``'strict'`` meaning that encoding errors raise :exc:" @@ -57,11 +57,11 @@ msgid "" "information on codec error handling." msgstr "" -#: ../../library/codecs.rst:48 +#: ../../library/codecs.rst:44 msgid "Decodes *obj* using the codec registered for *encoding*." msgstr "" -#: ../../library/codecs.rst:50 +#: ../../library/codecs.rst:46 msgid "" "*Errors* may be given to set the desired error handling scheme. The default " "error handler is ``'strict'`` meaning that decoding errors raise :exc:" @@ -70,7 +70,7 @@ msgid "" "information on codec error handling." msgstr "" -#: ../../library/codecs.rst:58 +#: ../../library/codecs.rst:54 msgid "" "Return a mapping suitable for encoding with a custom single-byte encoding. " "Given a :class:`str` *string* of up to 256 characters representing a " @@ -79,35 +79,49 @@ msgid "" "to byte values. Raises a :exc:`TypeError` on invalid input." msgstr "" -#: ../../library/codecs.rst:64 +#: ../../library/codecs.rst:60 msgid "The full details for each codec can also be looked up directly:" msgstr "" -#: ../../library/codecs.rst:68 +#: ../../library/codecs.rst:64 msgid "" "Looks up the codec info in the Python codec registry and returns a :class:" "`CodecInfo` object as defined below." msgstr "" -#: ../../library/codecs.rst:71 +#: ../../library/codecs.rst:67 +msgid "" +"This function first normalizes the *encoding*: all ASCII letters are " +"converted to lower case, spaces are replaced with hyphens. Then encoding is " +"looked up in the registry's cache. If not found, the list of registered " +"search functions is scanned. If no :class:`CodecInfo` object is found, a :" +"exc:`LookupError` is raised. Otherwise, the :class:`CodecInfo` object is " +"stored in the cache and returned to the caller." +msgstr "" + +#: ../../library/codecs.rst:74 msgid "" -"Encodings are first looked up in the registry's cache. If not found, the " -"list of registered search functions is scanned. If no :class:`CodecInfo` " -"object is found, a :exc:`LookupError` is raised. Otherwise, the :class:" -"`CodecInfo` object is stored in the cache and returned to the caller." +"Any characters except ASCII letters and digits and a dot are converted to " +"underscore." msgstr "" -#: ../../library/codecs.rst:78 +#: ../../library/codecs.rst:77 +msgid "" +"No characters are converted to underscore anymore. Spaces are converted to " +"hyphens." +msgstr "" + +#: ../../library/codecs.rst:84 msgid "" "Codec details when looking up the codec registry. The constructor arguments " "are stored in attributes of the same name:" msgstr "" -#: ../../library/codecs.rst:84 +#: ../../library/codecs.rst:90 msgid "The name of the encoding." msgstr "編碼的名稱。" -#: ../../library/codecs.rst:90 +#: ../../library/codecs.rst:96 msgid "" "The stateless encoding and decoding functions. These must be functions or " "methods which have the same interface as the :meth:`~Codec.encode` and :meth:" @@ -116,7 +130,7 @@ msgid "" "mode." msgstr "" -#: ../../library/codecs.rst:100 +#: ../../library/codecs.rst:106 msgid "" "Incremental encoder and decoder classes or factory functions. These have to " "provide the interface defined by the base classes :class:" @@ -124,96 +138,91 @@ msgid "" "Incremental codecs can maintain state." msgstr "" -#: ../../library/codecs.rst:109 +#: ../../library/codecs.rst:115 msgid "" "Stream writer and reader classes or factory functions. These have to provide " "the interface defined by the base classes :class:`StreamWriter` and :class:" "`StreamReader`, respectively. Stream codecs can maintain state." msgstr "" -#: ../../library/codecs.rst:114 +#: ../../library/codecs.rst:120 msgid "" "To simplify access to the various codec components, the module provides " "these additional functions which use :func:`lookup` for the codec lookup:" msgstr "" -#: ../../library/codecs.rst:119 +#: ../../library/codecs.rst:125 msgid "" "Look up the codec for the given encoding and return its encoder function." msgstr "" -#: ../../library/codecs.rst:121 ../../library/codecs.rst:128 -#: ../../library/codecs.rst:154 ../../library/codecs.rst:162 +#: ../../library/codecs.rst:127 ../../library/codecs.rst:134 +#: ../../library/codecs.rst:160 ../../library/codecs.rst:168 msgid "Raises a :exc:`LookupError` in case the encoding cannot be found." msgstr "" -#: ../../library/codecs.rst:126 +#: ../../library/codecs.rst:132 msgid "" "Look up the codec for the given encoding and return its decoder function." msgstr "" -#: ../../library/codecs.rst:133 +#: ../../library/codecs.rst:139 msgid "" "Look up the codec for the given encoding and return its incremental encoder " "class or factory function." msgstr "" -#: ../../library/codecs.rst:136 +#: ../../library/codecs.rst:142 msgid "" "Raises a :exc:`LookupError` in case the encoding cannot be found or the " "codec doesn't support an incremental encoder." msgstr "" -#: ../../library/codecs.rst:142 +#: ../../library/codecs.rst:148 msgid "" "Look up the codec for the given encoding and return its incremental decoder " "class or factory function." msgstr "" -#: ../../library/codecs.rst:145 +#: ../../library/codecs.rst:151 msgid "" "Raises a :exc:`LookupError` in case the encoding cannot be found or the " "codec doesn't support an incremental decoder." msgstr "" -#: ../../library/codecs.rst:151 +#: ../../library/codecs.rst:157 msgid "" "Look up the codec for the given encoding and return its :class:" "`StreamReader` class or factory function." msgstr "" -#: ../../library/codecs.rst:159 +#: ../../library/codecs.rst:165 msgid "" "Look up the codec for the given encoding and return its :class:" "`StreamWriter` class or factory function." msgstr "" -#: ../../library/codecs.rst:164 +#: ../../library/codecs.rst:170 msgid "" "Custom codecs are made available by registering a suitable codec search " "function:" msgstr "" -#: ../../library/codecs.rst:169 +#: ../../library/codecs.rst:175 msgid "" "Register a codec search function. Search functions are expected to take one " -"argument, being the encoding name in all lower case letters with hyphens and " -"spaces converted to underscores, and return a :class:`CodecInfo` object. In " -"case a search function cannot find a given encoding, it should return " -"``None``." -msgstr "" - -#: ../../library/codecs.rst:175 -msgid "Hyphens and spaces are converted to underscore." +"argument, being the encoding name in all lower case letters with spaces " +"converted to hyphens, and return a :class:`CodecInfo` object. In case a " +"search function cannot find a given encoding, it should return ``None``." msgstr "" -#: ../../library/codecs.rst:181 +#: ../../library/codecs.rst:184 msgid "" "Unregister a codec search function and clear the registry's cache. If the " "search function is not registered, do nothing." msgstr "" -#: ../../library/codecs.rst:187 +#: ../../library/codecs.rst:190 msgid "" "While the builtin :func:`open` and the associated :mod:`io` module are the " "recommended approach for working with encoded text files, this module " @@ -221,14 +230,14 @@ msgid "" "wider range of codecs when working with binary files:" msgstr "" -#: ../../library/codecs.rst:194 +#: ../../library/codecs.rst:197 msgid "" "Open an encoded file using the given *mode* and return an instance of :class:" "`StreamReaderWriter`, providing transparent encoding/decoding. The default " "file mode is ``'r'``, meaning to open the file in read mode." msgstr "" -#: ../../library/codecs.rst:200 +#: ../../library/codecs.rst:203 msgid "" "If *encoding* is not ``None``, then the underlying encoded files are always " "opened in binary mode. No automatic conversion of ``'\\n'`` is done on " @@ -236,42 +245,42 @@ msgid "" "to the built-in :func:`open` function; the ``'b'`` is automatically added." msgstr "" -#: ../../library/codecs.rst:206 +#: ../../library/codecs.rst:209 msgid "" "*encoding* specifies the encoding which is to be used for the file. Any " "encoding that encodes to and decodes from bytes is allowed, and the data " "types supported by the file methods depend on the codec used." msgstr "" -#: ../../library/codecs.rst:210 +#: ../../library/codecs.rst:213 msgid "" "*errors* may be given to define the error handling. It defaults to " "``'strict'`` which causes a :exc:`ValueError` to be raised in case an " "encoding error occurs." msgstr "" -#: ../../library/codecs.rst:213 +#: ../../library/codecs.rst:216 msgid "" "*buffering* has the same meaning as for the built-in :func:`open` function. " "It defaults to -1 which means that the default buffer size will be used." msgstr "" -#: ../../library/codecs.rst:216 +#: ../../library/codecs.rst:219 msgid "The ``'U'`` mode has been removed." msgstr "已移除 ``'U'`` 模式。" -#: ../../library/codecs.rst:221 +#: ../../library/codecs.rst:224 msgid ":func:`codecs.open` has been superseded by :func:`open`." msgstr ":func:`codecs.open` 已被 :func:`open` 取代。" -#: ../../library/codecs.rst:226 +#: ../../library/codecs.rst:229 msgid "" "Return a :class:`StreamRecoder` instance, a wrapped version of *file* which " "provides transparent transcoding. The original file is closed when the " "wrapped version is closed." msgstr "" -#: ../../library/codecs.rst:230 +#: ../../library/codecs.rst:233 msgid "" "Data written to the wrapped file is decoded according to the given " "*data_encoding* and then written to the original file as bytes using " @@ -279,18 +288,18 @@ msgid "" "*file_encoding*, and the result is encoded using *data_encoding*." msgstr "" -#: ../../library/codecs.rst:236 +#: ../../library/codecs.rst:239 msgid "If *file_encoding* is not given, it defaults to *data_encoding*." msgstr "" -#: ../../library/codecs.rst:238 +#: ../../library/codecs.rst:241 msgid "" "*errors* may be given to define the error handling. It defaults to " "``'strict'``, which causes :exc:`ValueError` to be raised in case an " "encoding error occurs." msgstr "" -#: ../../library/codecs.rst:245 +#: ../../library/codecs.rst:248 msgid "" "Uses an incremental encoder to iteratively encode the input provided by " "*iterator*. *iterator* must yield :class:`str` objects. This function is a :" @@ -298,14 +307,14 @@ msgid "" "argument) is passed through to the incremental encoder." msgstr "" -#: ../../library/codecs.rst:250 +#: ../../library/codecs.rst:253 msgid "" "This function requires that the codec accept text :class:`str` objects to " "encode. Therefore it does not support bytes-to-bytes encoders such as " "``base64_codec``." msgstr "" -#: ../../library/codecs.rst:257 +#: ../../library/codecs.rst:260 msgid "" "Uses an incremental decoder to iteratively decode the input provided by " "*iterator*. *iterator* must yield :class:`bytes` objects. This function is " @@ -313,7 +322,7 @@ msgid "" "argument) is passed through to the incremental decoder." msgstr "" -#: ../../library/codecs.rst:262 +#: ../../library/codecs.rst:265 msgid "" "This function requires that the codec accept :class:`bytes` objects to " "decode. Therefore it does not support text-to-text encoders such as " @@ -321,18 +330,18 @@ msgid "" "`iterencode`." msgstr "" -#: ../../library/codecs.rst:270 +#: ../../library/codecs.rst:273 msgid "" "Return a :class:`tuple` containing the raw bytes of *buffer*, a :ref:`buffer-" "compatible object ` or :class:`str` (encoded to UTF-8 before " "processing), and their length in bytes." msgstr "" -#: ../../library/codecs.rst:274 +#: ../../library/codecs.rst:277 msgid "The *errors* argument is ignored." msgstr "忽略 *errors* 引數。" -#: ../../library/codecs.rst:276 +#: ../../library/codecs.rst:279 msgid "" ">>> codecs.readbuffer_encode(b\"Zito\")\n" "(b'Zito', 4)" @@ -340,13 +349,13 @@ msgstr "" ">>> codecs.readbuffer_encode(b\"Zito\")\n" "(b'Zito', 4)" -#: ../../library/codecs.rst:282 +#: ../../library/codecs.rst:285 msgid "" "The module also provides the following constants which are useful for " "reading and writing to platform dependent files:" msgstr "" -#: ../../library/codecs.rst:297 +#: ../../library/codecs.rst:300 msgid "" "These constants define various byte sequences, being Unicode byte order " "marks (BOMs) for several encodings. They are used in UTF-16 and UTF-32 data " @@ -358,18 +367,18 @@ msgid "" "represent the BOM in UTF-8 and UTF-32 encodings." msgstr "" -#: ../../library/codecs.rst:311 +#: ../../library/codecs.rst:314 msgid "Codec Base Classes" msgstr "" -#: ../../library/codecs.rst:313 +#: ../../library/codecs.rst:316 msgid "" "The :mod:`!codecs` module defines a set of base classes which define the " "interfaces for working with codec objects, and can also be used as the basis " "for custom codec implementations." msgstr "" -#: ../../library/codecs.rst:317 +#: ../../library/codecs.rst:320 msgid "" "Each codec has to define four interfaces to make it usable as codec in " "Python: stateless encoder, stateless decoder, stream reader and stream " @@ -378,69 +387,69 @@ msgid "" "how the codec will handle encoding and decoding errors." msgstr "" -#: ../../library/codecs.rst:328 +#: ../../library/codecs.rst:331 msgid "Error Handlers" msgstr "" -#: ../../library/codecs.rst:330 +#: ../../library/codecs.rst:333 msgid "" "To simplify and standardize error handling, codecs may implement different " "error handling schemes by accepting the *errors* string argument:" msgstr "" -#: ../../library/codecs.rst:350 +#: ../../library/codecs.rst:353 msgid "" "The following error handlers can be used with all Python :ref:`standard-" "encodings` codecs:" msgstr "" -#: ../../library/codecs.rst:356 ../../library/codecs.rst:399 -#: ../../library/codecs.rst:419 +#: ../../library/codecs.rst:359 ../../library/codecs.rst:402 +#: ../../library/codecs.rst:422 msgid "Value" msgstr "" -#: ../../library/codecs.rst:356 ../../library/codecs.rst:399 -#: ../../library/codecs.rst:419 ../../library/codecs.rst:1376 -#: ../../library/codecs.rst:1465 ../../library/codecs.rst:1550 +#: ../../library/codecs.rst:359 ../../library/codecs.rst:402 +#: ../../library/codecs.rst:422 ../../library/codecs.rst:1379 +#: ../../library/codecs.rst:1468 ../../library/codecs.rst:1553 msgid "Meaning" msgstr "含義" -#: ../../library/codecs.rst:358 +#: ../../library/codecs.rst:361 msgid "``'strict'``" msgstr "``'strict'``" -#: ../../library/codecs.rst:358 +#: ../../library/codecs.rst:361 msgid "" "Raise :exc:`UnicodeError` (or a subclass), this is the default. Implemented " "in :func:`strict_errors`." msgstr "" -#: ../../library/codecs.rst:362 +#: ../../library/codecs.rst:365 msgid "``'ignore'``" msgstr "``'ignore'``" -#: ../../library/codecs.rst:362 +#: ../../library/codecs.rst:365 msgid "" "Ignore the malformed data and continue without further notice. Implemented " "in :func:`ignore_errors`." msgstr "" -#: ../../library/codecs.rst:366 +#: ../../library/codecs.rst:369 msgid "``'replace'``" msgstr "``'replace'``" -#: ../../library/codecs.rst:366 +#: ../../library/codecs.rst:369 msgid "" "Replace with a replacement marker. On encoding, use ``?`` (ASCII character). " "On decoding, use ``�`` (U+FFFD, the official REPLACEMENT CHARACTER). " "Implemented in :func:`replace_errors`." msgstr "" -#: ../../library/codecs.rst:372 +#: ../../library/codecs.rst:375 msgid "``'backslashreplace'``" msgstr "``'backslashreplace'``" -#: ../../library/codecs.rst:372 +#: ../../library/codecs.rst:375 msgid "" "Replace with backslashed escape sequences. On encoding, use hexadecimal form " "of Unicode code point with formats :samp:`\\\\x{hh}` :samp:`\\\\u{xxxx}` :" @@ -448,11 +457,11 @@ msgid "" "format :samp:`\\\\x{hh}`. Implemented in :func:`backslashreplace_errors`." msgstr "" -#: ../../library/codecs.rst:381 +#: ../../library/codecs.rst:384 msgid "``'surrogateescape'``" msgstr "``'surrogateescape'``" -#: ../../library/codecs.rst:381 +#: ../../library/codecs.rst:384 msgid "" "On decoding, replace byte with individual surrogate code ranging from " "``U+DC80`` to ``U+DCFF``. This code will then be turned back into the same " @@ -460,92 +469,92 @@ msgid "" "data. (See :pep:`383` for more.)" msgstr "" -#: ../../library/codecs.rst:395 +#: ../../library/codecs.rst:398 msgid "" "The following error handlers are only applicable to encoding (within :term:" "`text encodings `):" msgstr "" -#: ../../library/codecs.rst:401 +#: ../../library/codecs.rst:404 msgid "``'xmlcharrefreplace'``" msgstr "``'xmlcharrefreplace'``" -#: ../../library/codecs.rst:401 +#: ../../library/codecs.rst:404 msgid "" "Replace with XML/HTML numeric character reference, which is a decimal form " "of Unicode code point with format :samp:`&#{num};`. Implemented in :func:" "`xmlcharrefreplace_errors`." msgstr "" -#: ../../library/codecs.rst:407 +#: ../../library/codecs.rst:410 msgid "``'namereplace'``" msgstr "``'namereplace'``" -#: ../../library/codecs.rst:407 +#: ../../library/codecs.rst:410 msgid "" "Replace with ``\\N{...}`` escape sequences, what appears in the braces is " "the Name property from Unicode Character Database. Implemented in :func:" "`namereplace_errors`." msgstr "" -#: ../../library/codecs.rst:416 +#: ../../library/codecs.rst:419 msgid "" "In addition, the following error handler is specific to the given codecs:" msgstr "" -#: ../../library/codecs.rst:13 ../../library/codecs.rst:419 +#: ../../library/codecs.rst:9 ../../library/codecs.rst:422 msgid "Codecs" msgstr "" -#: ../../library/codecs.rst:421 +#: ../../library/codecs.rst:424 msgid "``'surrogatepass'``" msgstr "``'surrogatepass'``" -#: ../../library/codecs.rst:421 +#: ../../library/codecs.rst:424 msgid "utf-8, utf-16, utf-32, utf-16-be, utf-16-le, utf-32-be, utf-32-le" msgstr "utf-8, utf-16, utf-32, utf-16-be, utf-16-le, utf-32-be, utf-32-le" -#: ../../library/codecs.rst:421 +#: ../../library/codecs.rst:424 msgid "" "Allow encoding and decoding surrogate code point (``U+D800`` - ``U+DFFF``) " "as normal code point. Otherwise these codecs treat the presence of surrogate " "code point in :class:`str` as an error." msgstr "" -#: ../../library/codecs.rst:428 +#: ../../library/codecs.rst:431 msgid "The ``'surrogateescape'`` and ``'surrogatepass'`` error handlers." msgstr "" -#: ../../library/codecs.rst:431 +#: ../../library/codecs.rst:434 msgid "" "The ``'surrogatepass'`` error handler now works with utf-16\\* and utf-32\\* " "codecs." msgstr "" -#: ../../library/codecs.rst:435 +#: ../../library/codecs.rst:438 msgid "The ``'namereplace'`` error handler." msgstr "" -#: ../../library/codecs.rst:438 +#: ../../library/codecs.rst:441 msgid "" "The ``'backslashreplace'`` error handler now works with decoding and " "translating." msgstr "" -#: ../../library/codecs.rst:442 +#: ../../library/codecs.rst:445 msgid "" "The set of allowed values can be extended by registering a new named error " "handler:" msgstr "" -#: ../../library/codecs.rst:447 +#: ../../library/codecs.rst:450 msgid "" "Register the error handling function *error_handler* under the name *name*. " "The *error_handler* argument will be called during encoding and decoding in " "case of an error, when *name* is specified as the errors parameter." msgstr "" -#: ../../library/codecs.rst:451 +#: ../../library/codecs.rst:454 msgid "" "For encoding, *error_handler* will be called with a :exc:" "`UnicodeEncodeError` instance, which contains information about the location " @@ -560,66 +569,66 @@ msgid "" "position is out of bound an :exc:`IndexError` will be raised." msgstr "" -#: ../../library/codecs.rst:463 +#: ../../library/codecs.rst:466 msgid "" "Decoding and translating works similarly, except :exc:`UnicodeDecodeError` " "or :exc:`UnicodeTranslateError` will be passed to the handler and that the " "replacement from the error handler will be put into the output directly." msgstr "" -#: ../../library/codecs.rst:468 +#: ../../library/codecs.rst:471 msgid "" "Previously registered error handlers (including the standard error handlers) " "can be looked up by name:" msgstr "" -#: ../../library/codecs.rst:473 +#: ../../library/codecs.rst:476 msgid "Return the error handler previously registered under the name *name*." msgstr "" -#: ../../library/codecs.rst:475 +#: ../../library/codecs.rst:478 msgid "Raises a :exc:`LookupError` in case the handler cannot be found." msgstr "" -#: ../../library/codecs.rst:477 +#: ../../library/codecs.rst:480 msgid "" "The following standard error handlers are also made available as module " "level functions:" msgstr "" -#: ../../library/codecs.rst:482 +#: ../../library/codecs.rst:485 msgid "Implements the ``'strict'`` error handling." msgstr "" -#: ../../library/codecs.rst:484 +#: ../../library/codecs.rst:487 msgid "Each encoding or decoding error raises a :exc:`UnicodeError`." msgstr "" -#: ../../library/codecs.rst:489 +#: ../../library/codecs.rst:492 msgid "Implements the ``'ignore'`` error handling." msgstr "" -#: ../../library/codecs.rst:491 +#: ../../library/codecs.rst:494 msgid "" "Malformed data is ignored; encoding or decoding is continued without further " "notice." msgstr "" -#: ../../library/codecs.rst:497 +#: ../../library/codecs.rst:500 msgid "Implements the ``'replace'`` error handling." msgstr "" -#: ../../library/codecs.rst:499 +#: ../../library/codecs.rst:502 msgid "" "Substitutes ``?`` (ASCII character) for encoding errors or ``�`` (U+FFFD, " "the official REPLACEMENT CHARACTER) for decoding errors." msgstr "" -#: ../../library/codecs.rst:505 +#: ../../library/codecs.rst:508 msgid "Implements the ``'backslashreplace'`` error handling." msgstr "" -#: ../../library/codecs.rst:507 +#: ../../library/codecs.rst:510 msgid "" "Malformed data is replaced by a backslashed escape sequence. On encoding, " "use the hexadecimal form of Unicode code point with formats :samp:`\\\\x{hh}" @@ -627,30 +636,30 @@ msgid "" "hexadecimal form of byte value with format :samp:`\\\\x{hh}`." msgstr "" -#: ../../library/codecs.rst:513 +#: ../../library/codecs.rst:516 msgid "Works with decoding and translating." msgstr "" -#: ../../library/codecs.rst:519 +#: ../../library/codecs.rst:522 msgid "" "Implements the ``'xmlcharrefreplace'`` error handling (for encoding within :" "term:`text encoding` only)." msgstr "" -#: ../../library/codecs.rst:522 +#: ../../library/codecs.rst:525 msgid "" "The unencodable character is replaced by an appropriate XML/HTML numeric " "character reference, which is a decimal form of Unicode code point with " "format :samp:`&#{num};` ." msgstr "" -#: ../../library/codecs.rst:529 +#: ../../library/codecs.rst:532 msgid "" "Implements the ``'namereplace'`` error handling (for encoding within :term:" "`text encoding` only)." msgstr "" -#: ../../library/codecs.rst:532 +#: ../../library/codecs.rst:535 msgid "" "The unencodable character is replaced by a ``\\N{...}`` escape sequence. The " "set of characters that appear in the braces is the Name property from " @@ -658,17 +667,17 @@ msgid "" "will be converted to byte sequence ``\\N{LATIN SMALL LETTER SHARP S}`` ." msgstr "" -#: ../../library/codecs.rst:543 +#: ../../library/codecs.rst:546 msgid "Stateless Encoding and Decoding" msgstr "" -#: ../../library/codecs.rst:545 +#: ../../library/codecs.rst:548 msgid "" "The base :class:`Codec` class defines these methods which also define the " "function interfaces of the stateless encoder and decoder:" msgstr "" -#: ../../library/codecs.rst:553 +#: ../../library/codecs.rst:556 msgid "" "Encodes the object *input* and returns a tuple (output object, length " "consumed). For instance, :term:`text encoding` converts a string object to a " @@ -676,26 +685,26 @@ msgid "" "``iso-8859-1``)." msgstr "" -#: ../../library/codecs.rst:558 ../../library/codecs.rst:580 +#: ../../library/codecs.rst:561 ../../library/codecs.rst:583 msgid "" "The *errors* argument defines the error handling to apply. It defaults to " "``'strict'`` handling." msgstr "" -#: ../../library/codecs.rst:561 +#: ../../library/codecs.rst:564 msgid "" "The method may not store state in the :class:`Codec` instance. Use :class:" "`StreamWriter` for codecs which have to keep state in order to make encoding " "efficient." msgstr "" -#: ../../library/codecs.rst:565 +#: ../../library/codecs.rst:568 msgid "" "The encoder must be able to handle zero length input and return an empty " "object of the output object type in this situation." msgstr "" -#: ../../library/codecs.rst:571 +#: ../../library/codecs.rst:574 msgid "" "Decodes the object *input* and returns a tuple (output object, length " "consumed). For instance, for a :term:`text encoding`, decoding converts a " @@ -703,31 +712,31 @@ msgid "" "object." msgstr "" -#: ../../library/codecs.rst:576 +#: ../../library/codecs.rst:579 msgid "" "For text encodings and bytes-to-bytes codecs, *input* must be a bytes object " "or one which provides the read-only buffer interface -- for example, buffer " "objects and memory mapped files." msgstr "" -#: ../../library/codecs.rst:583 +#: ../../library/codecs.rst:586 msgid "" "The method may not store state in the :class:`Codec` instance. Use :class:" "`StreamReader` for codecs which have to keep state in order to make decoding " "efficient." msgstr "" -#: ../../library/codecs.rst:587 +#: ../../library/codecs.rst:590 msgid "" "The decoder must be able to handle zero length input and return an empty " "object of the output object type in this situation." msgstr "" -#: ../../library/codecs.rst:592 +#: ../../library/codecs.rst:595 msgid "Incremental Encoding and Decoding" msgstr "" -#: ../../library/codecs.rst:594 +#: ../../library/codecs.rst:597 msgid "" "The :class:`IncrementalEncoder` and :class:`IncrementalDecoder` classes " "provide the basic interface for incremental encoding and decoding. Encoding/" @@ -738,7 +747,7 @@ msgid "" "during method calls." msgstr "" -#: ../../library/codecs.rst:602 +#: ../../library/codecs.rst:605 msgid "" "The joined output of calls to the :meth:`~IncrementalEncoder.encode`/:meth:" "`~IncrementalDecoder.decode` method is the same as if all the single inputs " @@ -746,36 +755,36 @@ msgid "" "encoder/decoder." msgstr "" -#: ../../library/codecs.rst:611 +#: ../../library/codecs.rst:614 msgid "IncrementalEncoder Objects" msgstr "IncrementalEncoder 物件" -#: ../../library/codecs.rst:613 +#: ../../library/codecs.rst:616 msgid "" "The :class:`IncrementalEncoder` class is used for encoding an input in " "multiple steps. It defines the following methods which every incremental " "encoder must define in order to be compatible with the Python codec registry." msgstr "" -#: ../../library/codecs.rst:620 +#: ../../library/codecs.rst:623 msgid "Constructor for an :class:`IncrementalEncoder` instance." msgstr ":class:`IncrementalEncoder` 的建構函式。" -#: ../../library/codecs.rst:622 +#: ../../library/codecs.rst:625 msgid "" "All incremental encoders must provide this constructor interface. They are " "free to add additional keyword arguments, but only the ones defined here are " "used by the Python codec registry." msgstr "" -#: ../../library/codecs.rst:626 +#: ../../library/codecs.rst:629 msgid "" "The :class:`IncrementalEncoder` may implement different error handling " "schemes by providing the *errors* keyword argument. See :ref:`error-" "handlers` for possible values." msgstr "" -#: ../../library/codecs.rst:630 +#: ../../library/codecs.rst:633 msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " @@ -783,21 +792,21 @@ msgid "" "`IncrementalEncoder` object." msgstr "" -#: ../../library/codecs.rst:638 +#: ../../library/codecs.rst:641 msgid "" "Encodes *object* (taking the current state of the encoder into account) and " "returns the resulting encoded object. If this is the last call to :meth:" "`encode` *final* must be true (the default is false)." msgstr "" -#: ../../library/codecs.rst:645 +#: ../../library/codecs.rst:648 msgid "" "Reset the encoder to the initial state. The output is discarded: call ``." "encode(object, final=True)``, passing an empty byte or text string if " "necessary, to reset the encoder and to get the output." msgstr "" -#: ../../library/codecs.rst:652 +#: ../../library/codecs.rst:655 msgid "" "Return the current state of the encoder which must be an integer. The " "implementation should make sure that ``0`` is the most common state. (States " @@ -806,42 +815,42 @@ msgid "" "into an integer.)" msgstr "" -#: ../../library/codecs.rst:661 +#: ../../library/codecs.rst:664 msgid "" "Set the state of the encoder to *state*. *state* must be an encoder state " "returned by :meth:`getstate`." msgstr "" -#: ../../library/codecs.rst:668 +#: ../../library/codecs.rst:671 msgid "IncrementalDecoder Objects" msgstr "IncrementalDecoder 物件" -#: ../../library/codecs.rst:670 +#: ../../library/codecs.rst:673 msgid "" "The :class:`IncrementalDecoder` class is used for decoding an input in " "multiple steps. It defines the following methods which every incremental " "decoder must define in order to be compatible with the Python codec registry." msgstr "" -#: ../../library/codecs.rst:677 +#: ../../library/codecs.rst:680 msgid "Constructor for an :class:`IncrementalDecoder` instance." msgstr ":class:`IncrementalDecoder` 的建構函式。" -#: ../../library/codecs.rst:679 +#: ../../library/codecs.rst:682 msgid "" "All incremental decoders must provide this constructor interface. They are " "free to add additional keyword arguments, but only the ones defined here are " "used by the Python codec registry." msgstr "" -#: ../../library/codecs.rst:683 +#: ../../library/codecs.rst:686 msgid "" "The :class:`IncrementalDecoder` may implement different error handling " "schemes by providing the *errors* keyword argument. See :ref:`error-" "handlers` for possible values." msgstr "" -#: ../../library/codecs.rst:687 +#: ../../library/codecs.rst:690 msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " @@ -849,7 +858,7 @@ msgid "" "`IncrementalDecoder` object." msgstr "" -#: ../../library/codecs.rst:695 +#: ../../library/codecs.rst:698 msgid "" "Decodes *object* (taking the current state of the decoder into account) and " "returns the resulting decoded object. If this is the last call to :meth:" @@ -860,11 +869,11 @@ msgid "" "(which might raise an exception)." msgstr "" -#: ../../library/codecs.rst:706 +#: ../../library/codecs.rst:709 msgid "Reset the decoder to the initial state." msgstr "將解碼器重設到初始狀態。" -#: ../../library/codecs.rst:711 +#: ../../library/codecs.rst:714 msgid "" "Return the current state of the decoder. This must be a tuple with two " "items, the first must be the buffer containing the still undecoded input. " @@ -879,59 +888,59 @@ msgid "" "bytes of the resulting string into an integer.)" msgstr "" -#: ../../library/codecs.rst:726 +#: ../../library/codecs.rst:729 msgid "" "Set the state of the decoder to *state*. *state* must be a decoder state " "returned by :meth:`getstate`." msgstr "" -#: ../../library/codecs.rst:731 +#: ../../library/codecs.rst:734 msgid "Stream Encoding and Decoding" msgstr "串流編碼和解碼" -#: ../../library/codecs.rst:734 +#: ../../library/codecs.rst:737 msgid "" "The :class:`StreamWriter` and :class:`StreamReader` classes provide generic " "working interfaces which can be used to implement new encoding submodules " "very easily. See :mod:`!encodings.utf_8` for an example of how this is done." msgstr "" -#: ../../library/codecs.rst:742 +#: ../../library/codecs.rst:745 msgid "StreamWriter Objects" msgstr "StreamWriter 物件" -#: ../../library/codecs.rst:744 +#: ../../library/codecs.rst:747 msgid "" "The :class:`StreamWriter` class is a subclass of :class:`Codec` and defines " "the following methods which every stream writer must define in order to be " "compatible with the Python codec registry." msgstr "" -#: ../../library/codecs.rst:751 +#: ../../library/codecs.rst:754 msgid "Constructor for a :class:`StreamWriter` instance." msgstr ":class:`StreamWriter` 的建構函式。" -#: ../../library/codecs.rst:753 +#: ../../library/codecs.rst:756 msgid "" "All stream writers must provide this constructor interface. They are free to " "add additional keyword arguments, but only the ones defined here are used by " "the Python codec registry." msgstr "" -#: ../../library/codecs.rst:757 +#: ../../library/codecs.rst:760 msgid "" "The *stream* argument must be a file-like object open for writing text or " "binary data, as appropriate for the specific codec." msgstr "" -#: ../../library/codecs.rst:760 +#: ../../library/codecs.rst:763 msgid "" "The :class:`StreamWriter` may implement different error handling schemes by " "providing the *errors* keyword argument. See :ref:`error-handlers` for the " "standard error handlers the underlying stream codec may support." msgstr "" -#: ../../library/codecs.rst:764 +#: ../../library/codecs.rst:767 msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " @@ -939,70 +948,70 @@ msgid "" "object." msgstr "" -#: ../../library/codecs.rst:770 +#: ../../library/codecs.rst:773 msgid "Writes the object's contents encoded to the stream." msgstr "" -#: ../../library/codecs.rst:775 +#: ../../library/codecs.rst:778 msgid "" "Writes the concatenated iterable of strings to the stream (possibly by " "reusing the :meth:`write` method). Infinite or very large iterables are not " "supported. The standard bytes-to-bytes codecs do not support this method." msgstr "" -#: ../../library/codecs.rst:783 ../../library/codecs.rst:878 +#: ../../library/codecs.rst:786 ../../library/codecs.rst:881 msgid "Resets the codec buffers used for keeping internal state." msgstr "" -#: ../../library/codecs.rst:785 +#: ../../library/codecs.rst:788 msgid "" "Calling this method should ensure that the data on the output is put into a " "clean state that allows appending of new fresh data without having to rescan " "the whole stream to recover state." msgstr "" -#: ../../library/codecs.rst:790 +#: ../../library/codecs.rst:793 msgid "" "In addition to the above methods, the :class:`StreamWriter` must also " "inherit all other methods and attributes from the underlying stream." msgstr "" -#: ../../library/codecs.rst:797 +#: ../../library/codecs.rst:800 msgid "StreamReader Objects" msgstr "StreamReader 物件" -#: ../../library/codecs.rst:799 +#: ../../library/codecs.rst:802 msgid "" "The :class:`StreamReader` class is a subclass of :class:`Codec` and defines " "the following methods which every stream reader must define in order to be " "compatible with the Python codec registry." msgstr "" -#: ../../library/codecs.rst:806 +#: ../../library/codecs.rst:809 msgid "Constructor for a :class:`StreamReader` instance." msgstr ":class:`StreamReader` 的建構函式。" -#: ../../library/codecs.rst:808 +#: ../../library/codecs.rst:811 msgid "" "All stream readers must provide this constructor interface. They are free to " "add additional keyword arguments, but only the ones defined here are used by " "the Python codec registry." msgstr "" -#: ../../library/codecs.rst:812 +#: ../../library/codecs.rst:815 msgid "" "The *stream* argument must be a file-like object open for reading text or " "binary data, as appropriate for the specific codec." msgstr "" -#: ../../library/codecs.rst:815 +#: ../../library/codecs.rst:818 msgid "" "The :class:`StreamReader` may implement different error handling schemes by " "providing the *errors* keyword argument. See :ref:`error-handlers` for the " "standard error handlers the underlying stream codec may support." msgstr "" -#: ../../library/codecs.rst:819 +#: ../../library/codecs.rst:822 msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " @@ -1010,24 +1019,24 @@ msgid "" "object." msgstr "" -#: ../../library/codecs.rst:823 +#: ../../library/codecs.rst:826 msgid "" "The set of allowed values for the *errors* argument can be extended with :" "func:`register_error`." msgstr "" -#: ../../library/codecs.rst:829 +#: ../../library/codecs.rst:832 msgid "Decodes data from the stream and returns the resulting object." msgstr "" -#: ../../library/codecs.rst:831 +#: ../../library/codecs.rst:834 msgid "" "The *chars* argument indicates the number of decoded code points or bytes to " "return. The :func:`read` method will never return more data than requested, " "but it might return less, if there is not enough available." msgstr "" -#: ../../library/codecs.rst:836 +#: ../../library/codecs.rst:839 msgid "" "The *size* argument indicates the approximate maximum number of encoded " "bytes or code points to read for decoding. The decoder can modify this " @@ -1036,13 +1045,13 @@ msgid "" "huge files in one step." msgstr "" -#: ../../library/codecs.rst:843 +#: ../../library/codecs.rst:846 msgid "" "The *firstline* flag indicates that it would be sufficient to only return " "the first line, if there are decoding errors on later lines." msgstr "" -#: ../../library/codecs.rst:847 +#: ../../library/codecs.rst:850 msgid "" "The method should use a greedy read strategy meaning that it should read as " "much data as is allowed within the definition of the encoding and the given " @@ -1050,68 +1059,68 @@ msgid "" "the stream, these should be read too." msgstr "" -#: ../../library/codecs.rst:855 +#: ../../library/codecs.rst:858 msgid "Read one line from the input stream and return the decoded data." msgstr "" -#: ../../library/codecs.rst:857 +#: ../../library/codecs.rst:860 msgid "" "*size*, if given, is passed as size argument to the stream's :meth:`read` " "method." msgstr "" -#: ../../library/codecs.rst:860 +#: ../../library/codecs.rst:863 msgid "" "If *keepends* is false line-endings will be stripped from the lines returned." msgstr "" -#: ../../library/codecs.rst:866 +#: ../../library/codecs.rst:869 msgid "" "Read all lines available on the input stream and return them as a list of " "lines." msgstr "" -#: ../../library/codecs.rst:869 +#: ../../library/codecs.rst:872 msgid "" "Line-endings are implemented using the codec's :meth:`decode` method and are " "included in the list entries if *keepends* is true." msgstr "" -#: ../../library/codecs.rst:872 +#: ../../library/codecs.rst:875 msgid "" "*sizehint*, if given, is passed as the *size* argument to the stream's :meth:" "`read` method." msgstr "" -#: ../../library/codecs.rst:880 +#: ../../library/codecs.rst:883 msgid "" "Note that no stream repositioning should take place. This method is " "primarily intended to be able to recover from decoding errors." msgstr "" -#: ../../library/codecs.rst:884 +#: ../../library/codecs.rst:887 msgid "" "In addition to the above methods, the :class:`StreamReader` must also " "inherit all other methods and attributes from the underlying stream." msgstr "" -#: ../../library/codecs.rst:890 +#: ../../library/codecs.rst:893 msgid "StreamReaderWriter Objects" msgstr "StreamReaderWriter 物件" -#: ../../library/codecs.rst:892 +#: ../../library/codecs.rst:895 msgid "" "The :class:`StreamReaderWriter` is a convenience class that allows wrapping " "streams which work in both read and write modes." msgstr "" -#: ../../library/codecs.rst:895 ../../library/codecs.rst:919 +#: ../../library/codecs.rst:898 ../../library/codecs.rst:922 msgid "" "The design is such that one can use the factory functions returned by the :" "func:`lookup` function to construct the instance." msgstr "" -#: ../../library/codecs.rst:901 +#: ../../library/codecs.rst:904 msgid "" "Creates a :class:`StreamReaderWriter` instance. *stream* must be a file-like " "object. *Reader* and *Writer* must be factory functions or classes providing " @@ -1120,24 +1129,24 @@ msgid "" "writers." msgstr "" -#: ../../library/codecs.rst:906 +#: ../../library/codecs.rst:909 msgid "" ":class:`StreamReaderWriter` instances define the combined interfaces of :" "class:`StreamReader` and :class:`StreamWriter` classes. They inherit all " "other methods and attributes from the underlying stream." msgstr "" -#: ../../library/codecs.rst:914 +#: ../../library/codecs.rst:917 msgid "StreamRecoder Objects" msgstr "StreamRecoder 物件" -#: ../../library/codecs.rst:916 +#: ../../library/codecs.rst:919 msgid "" "The :class:`StreamRecoder` translates data from one encoding to another, " "which is sometimes useful when dealing with different encoding environments." msgstr "" -#: ../../library/codecs.rst:925 +#: ../../library/codecs.rst:928 msgid "" "Creates a :class:`StreamRecoder` instance which implements a two-way " "conversion: *encode* and *decode* work on the frontend — the data visible to " @@ -1145,17 +1154,17 @@ msgid "" "while *Reader* and *Writer* work on the backend — the data in *stream*." msgstr "" -#: ../../library/codecs.rst:931 +#: ../../library/codecs.rst:934 msgid "" "You can use these objects to do transparent transcodings, e.g., from Latin-1 " "to UTF-8 and back." msgstr "" -#: ../../library/codecs.rst:934 +#: ../../library/codecs.rst:937 msgid "The *stream* argument must be a file-like object." msgstr "*stream* 引數必須是類檔案物件。" -#: ../../library/codecs.rst:936 +#: ../../library/codecs.rst:939 msgid "" "The *encode* and *decode* arguments must adhere to the :class:`Codec` " "interface. *Reader* and *Writer* must be factory functions or classes " @@ -1163,24 +1172,24 @@ msgid "" "interface respectively." msgstr "" -#: ../../library/codecs.rst:941 +#: ../../library/codecs.rst:944 msgid "" "Error handling is done in the same way as defined for the stream readers and " "writers." msgstr "" -#: ../../library/codecs.rst:945 +#: ../../library/codecs.rst:948 msgid "" ":class:`StreamRecoder` instances define the combined interfaces of :class:" "`StreamReader` and :class:`StreamWriter` classes. They inherit all other " "methods and attributes from the underlying stream." msgstr "" -#: ../../library/codecs.rst:953 +#: ../../library/codecs.rst:956 msgid "Encodings and Unicode" msgstr "編碼和 Unicode" -#: ../../library/codecs.rst:955 +#: ../../library/codecs.rst:958 msgid "" "Strings are stored internally as sequences of code points in range " "``U+0000``--``U+10FFFF``. (See :pep:`393` for more details about the " @@ -1192,7 +1201,7 @@ msgid "" "which are collectivity referred to as :term:`text encodings `." msgstr "" -#: ../../library/codecs.rst:965 +#: ../../library/codecs.rst:968 msgid "" "The simplest text encoding (called ``'latin-1'`` or ``'iso-8859-1'``) maps " "the code points 0--255 to the bytes ``0x0``--``0xff``, which means that a " @@ -1203,7 +1212,7 @@ msgid "" "position 3: ordinal not in range(256)``." msgstr "" -#: ../../library/codecs.rst:973 +#: ../../library/codecs.rst:976 msgid "" "There's another group of encodings (the so called charmap encodings) that " "choose a different subset of all Unicode code points and how these code " @@ -1213,7 +1222,7 @@ msgid "" "that shows you which character is mapped to which byte value." msgstr "" -#: ../../library/codecs.rst:980 +#: ../../library/codecs.rst:983 msgid "" "All of these encodings can only encode 256 of the 1114112 code points " "defined in Unicode. A simple and straightforward way that can store each " @@ -1237,7 +1246,7 @@ msgid "" "``U+FFFE``, the bytes have to be swapped on decoding." msgstr "" -#: ../../library/codecs.rst:1001 +#: ../../library/codecs.rst:1004 msgid "" "Unfortunately the character ``U+FEFF`` had a second purpose as a ``ZERO " "WIDTH NO-BREAK SPACE``: a character that has no width and doesn't allow a " @@ -1251,7 +1260,7 @@ msgid "" "be decoded like any other." msgstr "" -#: ../../library/codecs.rst:1011 +#: ../../library/codecs.rst:1014 msgid "" "There's another encoding that is able to encode the full range of Unicode " "characters: UTF-8. UTF-8 is an 8-bit encoding, which means there are no " @@ -1262,59 +1271,59 @@ msgid "" "which when concatenated give the Unicode character):" msgstr "" -#: ../../library/codecs.rst:1020 +#: ../../library/codecs.rst:1023 msgid "Range" msgstr "" -#: ../../library/codecs.rst:1020 +#: ../../library/codecs.rst:1023 msgid "Encoding" msgstr "" -#: ../../library/codecs.rst:1022 +#: ../../library/codecs.rst:1025 msgid "``U-00000000`` ... ``U-0000007F``" msgstr "``U-00000000`` ... ``U-0000007F``" -#: ../../library/codecs.rst:1022 +#: ../../library/codecs.rst:1025 msgid "0xxxxxxx" msgstr "0xxxxxxx" -#: ../../library/codecs.rst:1024 +#: ../../library/codecs.rst:1027 msgid "``U-00000080`` ... ``U-000007FF``" msgstr "``U-00000080`` ... ``U-000007FF``" -#: ../../library/codecs.rst:1024 +#: ../../library/codecs.rst:1027 msgid "110xxxxx 10xxxxxx" msgstr "110xxxxx 10xxxxxx" -#: ../../library/codecs.rst:1026 +#: ../../library/codecs.rst:1029 msgid "``U-00000800`` ... ``U-0000FFFF``" msgstr "``U-00000800`` ... ``U-0000FFFF``" -#: ../../library/codecs.rst:1026 +#: ../../library/codecs.rst:1029 msgid "1110xxxx 10xxxxxx 10xxxxxx" msgstr "1110xxxx 10xxxxxx 10xxxxxx" -#: ../../library/codecs.rst:1028 +#: ../../library/codecs.rst:1031 msgid "``U-00010000`` ... ``U-0010FFFF``" msgstr "``U-00010000`` ... ``U-0010FFFF``" -#: ../../library/codecs.rst:1028 +#: ../../library/codecs.rst:1031 msgid "11110xxx 10xxxxxx 10xxxxxx 10xxxxxx" msgstr "11110xxx 10xxxxxx 10xxxxxx 10xxxxxx" -#: ../../library/codecs.rst:1031 +#: ../../library/codecs.rst:1034 msgid "" "The least significant bit of the Unicode character is the rightmost x bit." msgstr "" -#: ../../library/codecs.rst:1033 +#: ../../library/codecs.rst:1036 msgid "" "As UTF-8 is an 8-bit encoding no BOM is required and any ``U+FEFF`` " "character in the decoded string (even if it's the first character) is " "treated as a ``ZERO WIDTH NO-BREAK SPACE``." msgstr "" -#: ../../library/codecs.rst:1037 +#: ../../library/codecs.rst:1040 msgid "" "Without external information it's impossible to reliably determine which " "encoding was used for encoding a string. Each charmap encoding can decode " @@ -1340,7 +1349,7 @@ msgstr "" msgid "INVERTED QUESTION MARK" msgstr "" -#: ../../library/codecs.rst:1053 +#: ../../library/codecs.rst:1056 msgid "" "in iso-8859-1), this increases the probability that a ``utf-8-sig`` encoding " "can be correctly guessed from the byte sequence. So here the BOM is not used " @@ -1352,37 +1361,37 @@ msgid "" "the use of the BOM is discouraged and should generally be avoided." msgstr "" -#: ../../library/codecs.rst:1066 +#: ../../library/codecs.rst:1069 msgid "Standard Encodings" msgstr "標準編碼" -#: ../../library/codecs.rst:1068 +#: ../../library/codecs.rst:1071 msgid "" "Python comes with a number of codecs built-in, either implemented as C " "functions or with dictionaries as mapping tables. The following table lists " "the codecs by name, together with a few common aliases, and the languages " "for which the encoding is likely used. Neither the list of aliases nor the " "list of languages is meant to be exhaustive. Notice that spelling " -"alternatives that only differ in case or use a hyphen instead of an " -"underscore are also valid aliases because they are equivalent when " +"alternatives that only differ in case or use a space or a hyphen instead of " +"an underscore are also valid aliases because they are equivalent when " "normalized by :func:`~encodings.normalize_encoding`. For example, " "``'utf-8'`` is a valid alias for the ``'utf_8'`` codec." msgstr "" -#: ../../library/codecs.rst:1080 +#: ../../library/codecs.rst:1083 msgid "" "The below table lists the most common aliases, for a complete list refer to " "the source :source:`aliases.py ` file." msgstr "" -#: ../../library/codecs.rst:1083 +#: ../../library/codecs.rst:1086 msgid "" "On Windows, ``cpXXX`` codecs are available for all code pages. But only " -"codecs listed in the following table are guarantead to exist on other " +"codecs listed in the following table are guaranteed to exist on other " "platforms." msgstr "" -#: ../../library/codecs.rst:1089 +#: ../../library/codecs.rst:1092 msgid "" "Some common encodings can bypass the codecs lookup machinery to improve " "performance. These optimization opportunities are only recognized by CPython " @@ -1392,11 +1401,11 @@ msgid "" "Using alternative aliases for these encodings may result in slower execution." msgstr "" -#: ../../library/codecs.rst:1097 +#: ../../library/codecs.rst:1100 msgid "Optimization opportunity recognized for us-ascii." msgstr "" -#: ../../library/codecs.rst:1100 +#: ../../library/codecs.rst:1103 msgid "" "Many of the character sets support the same languages. They vary in " "individual characters (e.g. whether the EURO SIGN is supported or not), and " @@ -1404,504 +1413,504 @@ msgid "" "languages in particular, the following variants typically exist:" msgstr "" -#: ../../library/codecs.rst:1105 +#: ../../library/codecs.rst:1108 msgid "an ISO 8859 codeset" msgstr "" -#: ../../library/codecs.rst:1107 +#: ../../library/codecs.rst:1110 msgid "" "a Microsoft Windows code page, which is typically derived from an 8859 " "codeset, but replaces control characters with additional graphic characters" msgstr "" -#: ../../library/codecs.rst:1110 +#: ../../library/codecs.rst:1113 msgid "an IBM EBCDIC code page" msgstr "" -#: ../../library/codecs.rst:1112 +#: ../../library/codecs.rst:1115 msgid "an IBM PC code page, which is ASCII compatible" msgstr "" -#: ../../library/codecs.rst:1117 ../../library/codecs.rst:1376 -#: ../../library/codecs.rst:1465 ../../library/codecs.rst:1550 +#: ../../library/codecs.rst:1120 ../../library/codecs.rst:1379 +#: ../../library/codecs.rst:1468 ../../library/codecs.rst:1553 msgid "Codec" msgstr "" -#: ../../library/codecs.rst:1117 ../../library/codecs.rst:1376 -#: ../../library/codecs.rst:1465 ../../library/codecs.rst:1550 +#: ../../library/codecs.rst:1120 ../../library/codecs.rst:1379 +#: ../../library/codecs.rst:1468 ../../library/codecs.rst:1553 msgid "Aliases" msgstr "" -#: ../../library/codecs.rst:1117 +#: ../../library/codecs.rst:1120 msgid "Languages" msgstr "語言" -#: ../../library/codecs.rst:1119 +#: ../../library/codecs.rst:1122 msgid "ascii" msgstr "ascii" -#: ../../library/codecs.rst:1119 +#: ../../library/codecs.rst:1122 msgid "646, us-ascii" msgstr "646, us-ascii" -#: ../../library/codecs.rst:1119 ../../library/codecs.rst:1125 -#: ../../library/codecs.rst:1133 +#: ../../library/codecs.rst:1122 ../../library/codecs.rst:1128 +#: ../../library/codecs.rst:1136 msgid "English" msgstr "英文" -#: ../../library/codecs.rst:1121 +#: ../../library/codecs.rst:1124 msgid "big5" msgstr "big5" -#: ../../library/codecs.rst:1121 +#: ../../library/codecs.rst:1124 msgid "big5-tw, csbig5" msgstr "big5-tw, csbig5" -#: ../../library/codecs.rst:1121 ../../library/codecs.rst:1123 -#: ../../library/codecs.rst:1182 +#: ../../library/codecs.rst:1124 ../../library/codecs.rst:1126 +#: ../../library/codecs.rst:1185 msgid "Traditional Chinese" msgstr "繁體中文" -#: ../../library/codecs.rst:1123 +#: ../../library/codecs.rst:1126 msgid "big5hkscs" msgstr "big5hkscs" -#: ../../library/codecs.rst:1123 +#: ../../library/codecs.rst:1126 msgid "big5-hkscs, hkscs" msgstr "big5-hkscs, hkscs" -#: ../../library/codecs.rst:1125 +#: ../../library/codecs.rst:1128 msgid "cp037" msgstr "cp037" -#: ../../library/codecs.rst:1125 +#: ../../library/codecs.rst:1128 msgid "IBM037, IBM039" msgstr "IBM037, IBM039" -#: ../../library/codecs.rst:1127 +#: ../../library/codecs.rst:1130 msgid "cp273" msgstr "cp273" -#: ../../library/codecs.rst:1127 +#: ../../library/codecs.rst:1130 msgid "273, IBM273, csIBM273" msgstr "273, IBM273, csIBM273" -#: ../../library/codecs.rst:1127 +#: ../../library/codecs.rst:1130 msgid "German" msgstr "德文" -#: ../../library/codecs.rst:1131 +#: ../../library/codecs.rst:1134 msgid "cp424" msgstr "cp424" -#: ../../library/codecs.rst:1131 +#: ../../library/codecs.rst:1134 msgid "EBCDIC-CP-HE, IBM424" msgstr "EBCDIC-CP-HE, IBM424" -#: ../../library/codecs.rst:1131 ../../library/codecs.rst:1151 -#: ../../library/codecs.rst:1161 ../../library/codecs.rst:1205 -#: ../../library/codecs.rst:1268 +#: ../../library/codecs.rst:1134 ../../library/codecs.rst:1154 +#: ../../library/codecs.rst:1164 ../../library/codecs.rst:1208 +#: ../../library/codecs.rst:1271 msgid "Hebrew" msgstr "希伯來文" -#: ../../library/codecs.rst:1133 +#: ../../library/codecs.rst:1136 msgid "cp437" msgstr "cp437" -#: ../../library/codecs.rst:1133 +#: ../../library/codecs.rst:1136 msgid "437, IBM437" msgstr "437, IBM437" -#: ../../library/codecs.rst:1135 +#: ../../library/codecs.rst:1138 msgid "cp500" msgstr "cp500" -#: ../../library/codecs.rst:1135 +#: ../../library/codecs.rst:1138 msgid "EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500" msgstr "EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500" -#: ../../library/codecs.rst:1135 ../../library/codecs.rst:1144 -#: ../../library/codecs.rst:1155 ../../library/codecs.rst:1192 -#: ../../library/codecs.rst:1199 ../../library/codecs.rst:1252 -#: ../../library/codecs.rst:1280 ../../library/codecs.rst:1308 +#: ../../library/codecs.rst:1138 ../../library/codecs.rst:1147 +#: ../../library/codecs.rst:1158 ../../library/codecs.rst:1195 +#: ../../library/codecs.rst:1202 ../../library/codecs.rst:1255 +#: ../../library/codecs.rst:1283 ../../library/codecs.rst:1311 msgid "Western Europe" msgstr "" -#: ../../library/codecs.rst:1138 +#: ../../library/codecs.rst:1141 msgid "cp720" msgstr "cp720" -#: ../../library/codecs.rst:1138 ../../library/codecs.rst:1165 -#: ../../library/codecs.rst:1207 ../../library/codecs.rst:1264 +#: ../../library/codecs.rst:1141 ../../library/codecs.rst:1168 +#: ../../library/codecs.rst:1210 ../../library/codecs.rst:1267 msgid "Arabic" msgstr "阿拉伯文" -#: ../../library/codecs.rst:1140 +#: ../../library/codecs.rst:1143 msgid "cp737" msgstr "cp737" -#: ../../library/codecs.rst:1140 ../../library/codecs.rst:1171 -#: ../../library/codecs.rst:1175 ../../library/codecs.rst:1201 -#: ../../library/codecs.rst:1266 ../../library/codecs.rst:1301 +#: ../../library/codecs.rst:1143 ../../library/codecs.rst:1174 +#: ../../library/codecs.rst:1178 ../../library/codecs.rst:1204 +#: ../../library/codecs.rst:1269 ../../library/codecs.rst:1304 msgid "Greek" msgstr "希臘文" -#: ../../library/codecs.rst:1142 +#: ../../library/codecs.rst:1145 msgid "cp775" msgstr "cp775" -#: ../../library/codecs.rst:1142 +#: ../../library/codecs.rst:1145 msgid "IBM775" msgstr "IBM775" -#: ../../library/codecs.rst:1142 ../../library/codecs.rst:1209 -#: ../../library/codecs.rst:1276 +#: ../../library/codecs.rst:1145 ../../library/codecs.rst:1212 +#: ../../library/codecs.rst:1279 msgid "Baltic languages" msgstr "" -#: ../../library/codecs.rst:1144 +#: ../../library/codecs.rst:1147 msgid "cp850" msgstr "cp850" -#: ../../library/codecs.rst:1144 +#: ../../library/codecs.rst:1147 msgid "850, IBM850" msgstr "850, IBM850" -#: ../../library/codecs.rst:1146 +#: ../../library/codecs.rst:1149 msgid "cp852" msgstr "cp852" -#: ../../library/codecs.rst:1146 +#: ../../library/codecs.rst:1149 msgid "852, IBM852" msgstr "852, IBM852" -#: ../../library/codecs.rst:1146 ../../library/codecs.rst:1194 -#: ../../library/codecs.rst:1255 ../../library/codecs.rst:1305 +#: ../../library/codecs.rst:1149 ../../library/codecs.rst:1197 +#: ../../library/codecs.rst:1258 ../../library/codecs.rst:1308 msgid "Central and Eastern Europe" msgstr "" -#: ../../library/codecs.rst:1148 +#: ../../library/codecs.rst:1151 msgid "cp855" msgstr "cp855" -#: ../../library/codecs.rst:1148 +#: ../../library/codecs.rst:1151 msgid "855, IBM855" msgstr "855, IBM855" -#: ../../library/codecs.rst:1148 ../../library/codecs.rst:1196 -#: ../../library/codecs.rst:1261 ../../library/codecs.rst:1298 +#: ../../library/codecs.rst:1151 ../../library/codecs.rst:1199 +#: ../../library/codecs.rst:1264 ../../library/codecs.rst:1301 msgid "Belarusian, Bulgarian, Macedonian, Russian, Serbian" msgstr "" -#: ../../library/codecs.rst:1151 +#: ../../library/codecs.rst:1154 msgid "cp856" msgstr "cp856" -#: ../../library/codecs.rst:1153 +#: ../../library/codecs.rst:1156 msgid "cp857" msgstr "cp857" -#: ../../library/codecs.rst:1153 +#: ../../library/codecs.rst:1156 msgid "857, IBM857" msgstr "857, IBM857" -#: ../../library/codecs.rst:1153 ../../library/codecs.rst:1186 -#: ../../library/codecs.rst:1203 ../../library/codecs.rst:1270 -#: ../../library/codecs.rst:1310 +#: ../../library/codecs.rst:1156 ../../library/codecs.rst:1189 +#: ../../library/codecs.rst:1206 ../../library/codecs.rst:1273 +#: ../../library/codecs.rst:1313 msgid "Turkish" msgstr "土耳其文" -#: ../../library/codecs.rst:1155 +#: ../../library/codecs.rst:1158 msgid "cp858" msgstr "cp858" -#: ../../library/codecs.rst:1155 +#: ../../library/codecs.rst:1158 msgid "858, IBM00858" msgstr "858, IBM00858" -#: ../../library/codecs.rst:1157 +#: ../../library/codecs.rst:1160 msgid "cp860" msgstr "cp860" -#: ../../library/codecs.rst:1157 +#: ../../library/codecs.rst:1160 msgid "860, IBM860" msgstr "860, IBM860" -#: ../../library/codecs.rst:1157 +#: ../../library/codecs.rst:1160 msgid "Portuguese" msgstr "" -#: ../../library/codecs.rst:1159 +#: ../../library/codecs.rst:1162 msgid "cp861" msgstr "cp861" -#: ../../library/codecs.rst:1159 +#: ../../library/codecs.rst:1162 msgid "861, CP-IS, IBM861" msgstr "861, CP-IS, IBM861" -#: ../../library/codecs.rst:1159 ../../library/codecs.rst:1303 +#: ../../library/codecs.rst:1162 ../../library/codecs.rst:1306 msgid "Icelandic" msgstr "" -#: ../../library/codecs.rst:1161 +#: ../../library/codecs.rst:1164 msgid "cp862" msgstr "cp862" -#: ../../library/codecs.rst:1161 +#: ../../library/codecs.rst:1164 msgid "862, IBM862" msgstr "862, IBM862" -#: ../../library/codecs.rst:1163 +#: ../../library/codecs.rst:1166 msgid "cp863" msgstr "cp863" -#: ../../library/codecs.rst:1163 +#: ../../library/codecs.rst:1166 msgid "863, IBM863" msgstr "863, IBM863" -#: ../../library/codecs.rst:1163 +#: ../../library/codecs.rst:1166 msgid "Canadian" msgstr "" -#: ../../library/codecs.rst:1165 +#: ../../library/codecs.rst:1168 msgid "cp864" msgstr "cp864" -#: ../../library/codecs.rst:1165 +#: ../../library/codecs.rst:1168 msgid "IBM864" msgstr "IBM864" -#: ../../library/codecs.rst:1167 +#: ../../library/codecs.rst:1170 msgid "cp865" msgstr "cp865" -#: ../../library/codecs.rst:1167 +#: ../../library/codecs.rst:1170 msgid "865, IBM865" msgstr "865, IBM865" -#: ../../library/codecs.rst:1167 +#: ../../library/codecs.rst:1170 msgid "Danish, Norwegian" msgstr "" -#: ../../library/codecs.rst:1169 +#: ../../library/codecs.rst:1172 msgid "cp866" msgstr "cp866" -#: ../../library/codecs.rst:1169 +#: ../../library/codecs.rst:1172 msgid "866, IBM866" msgstr "866, IBM866" -#: ../../library/codecs.rst:1169 ../../library/codecs.rst:1286 +#: ../../library/codecs.rst:1172 ../../library/codecs.rst:1289 msgid "Russian" msgstr "俄羅斯文" -#: ../../library/codecs.rst:1171 +#: ../../library/codecs.rst:1174 msgid "cp869" msgstr "cp869" -#: ../../library/codecs.rst:1171 +#: ../../library/codecs.rst:1174 msgid "869, CP-GR, IBM869" msgstr "869, CP-GR, IBM869" -#: ../../library/codecs.rst:1173 +#: ../../library/codecs.rst:1176 msgid "cp874" msgstr "cp874" -#: ../../library/codecs.rst:1173 +#: ../../library/codecs.rst:1176 msgid "Thai" msgstr "泰文" -#: ../../library/codecs.rst:1175 +#: ../../library/codecs.rst:1178 msgid "cp875" msgstr "cp875" -#: ../../library/codecs.rst:1177 +#: ../../library/codecs.rst:1180 msgid "cp932" msgstr "cp932" -#: ../../library/codecs.rst:1177 +#: ../../library/codecs.rst:1180 msgid "932, ms932, mskanji, ms-kanji, windows-31j" msgstr "932, ms932, mskanji, ms-kanji, windows-31j" -#: ../../library/codecs.rst:1177 ../../library/codecs.rst:1213 -#: ../../library/codecs.rst:1215 ../../library/codecs.rst:1217 -#: ../../library/codecs.rst:1234 ../../library/codecs.rst:1237 -#: ../../library/codecs.rst:1242 ../../library/codecs.rst:1245 -#: ../../library/codecs.rst:1247 ../../library/codecs.rst:1315 -#: ../../library/codecs.rst:1318 ../../library/codecs.rst:1321 +#: ../../library/codecs.rst:1180 ../../library/codecs.rst:1216 +#: ../../library/codecs.rst:1218 ../../library/codecs.rst:1220 +#: ../../library/codecs.rst:1237 ../../library/codecs.rst:1240 +#: ../../library/codecs.rst:1245 ../../library/codecs.rst:1248 +#: ../../library/codecs.rst:1250 ../../library/codecs.rst:1318 +#: ../../library/codecs.rst:1321 ../../library/codecs.rst:1324 msgid "Japanese" msgstr "日文" -#: ../../library/codecs.rst:1180 +#: ../../library/codecs.rst:1183 msgid "cp949" msgstr "cp949" -#: ../../library/codecs.rst:1180 +#: ../../library/codecs.rst:1183 msgid "949, ms949, uhc" msgstr "949, ms949, uhc" -#: ../../library/codecs.rst:1180 ../../library/codecs.rst:1219 -#: ../../library/codecs.rst:1249 ../../library/codecs.rst:1284 +#: ../../library/codecs.rst:1183 ../../library/codecs.rst:1222 +#: ../../library/codecs.rst:1252 ../../library/codecs.rst:1287 msgid "Korean" msgstr "韓文" -#: ../../library/codecs.rst:1182 +#: ../../library/codecs.rst:1185 msgid "cp950" msgstr "cp950" -#: ../../library/codecs.rst:1182 +#: ../../library/codecs.rst:1185 msgid "950, ms950" msgstr "950, ms950" -#: ../../library/codecs.rst:1184 +#: ../../library/codecs.rst:1187 msgid "cp1006" msgstr "cp1006" -#: ../../library/codecs.rst:1184 +#: ../../library/codecs.rst:1187 msgid "Urdu" msgstr "" -#: ../../library/codecs.rst:1186 +#: ../../library/codecs.rst:1189 msgid "cp1026" msgstr "cp1026" -#: ../../library/codecs.rst:1186 +#: ../../library/codecs.rst:1189 msgid "ibm1026" msgstr "ibm1026" -#: ../../library/codecs.rst:1188 +#: ../../library/codecs.rst:1191 msgid "cp1125" msgstr "cp1125" -#: ../../library/codecs.rst:1188 +#: ../../library/codecs.rst:1191 msgid "1125, ibm1125, cp866u, ruscii" msgstr "1125, ibm1125, cp866u, ruscii" -#: ../../library/codecs.rst:1188 ../../library/codecs.rst:1292 +#: ../../library/codecs.rst:1191 ../../library/codecs.rst:1295 msgid "Ukrainian" msgstr "烏克蘭文" -#: ../../library/codecs.rst:1192 +#: ../../library/codecs.rst:1195 msgid "cp1140" msgstr "cp1140" -#: ../../library/codecs.rst:1192 +#: ../../library/codecs.rst:1195 msgid "IBM01140" msgstr "" -#: ../../library/codecs.rst:1194 +#: ../../library/codecs.rst:1197 msgid "cp1250" msgstr "cp1250" -#: ../../library/codecs.rst:1194 +#: ../../library/codecs.rst:1197 msgid "windows-1250" msgstr "windows-1250" -#: ../../library/codecs.rst:1196 +#: ../../library/codecs.rst:1199 msgid "cp1251" msgstr "cp1251" -#: ../../library/codecs.rst:1196 +#: ../../library/codecs.rst:1199 msgid "windows-1251" msgstr "windows-1251" -#: ../../library/codecs.rst:1199 +#: ../../library/codecs.rst:1202 msgid "cp1252" msgstr "cp1252" -#: ../../library/codecs.rst:1199 +#: ../../library/codecs.rst:1202 msgid "windows-1252" msgstr "windows-1252" -#: ../../library/codecs.rst:1201 +#: ../../library/codecs.rst:1204 msgid "cp1253" msgstr "cp1253" -#: ../../library/codecs.rst:1201 +#: ../../library/codecs.rst:1204 msgid "windows-1253" msgstr "windows-1253" -#: ../../library/codecs.rst:1203 +#: ../../library/codecs.rst:1206 msgid "cp1254" msgstr "cp1254" -#: ../../library/codecs.rst:1203 +#: ../../library/codecs.rst:1206 msgid "windows-1254" msgstr "windows-1254" -#: ../../library/codecs.rst:1205 +#: ../../library/codecs.rst:1208 msgid "cp1255" msgstr "cp1255" -#: ../../library/codecs.rst:1205 +#: ../../library/codecs.rst:1208 msgid "windows-1255" msgstr "windows-1255" -#: ../../library/codecs.rst:1207 +#: ../../library/codecs.rst:1210 msgid "cp1256" msgstr "cp1256" -#: ../../library/codecs.rst:1207 +#: ../../library/codecs.rst:1210 msgid "windows-1256" msgstr "windows-1256" -#: ../../library/codecs.rst:1209 +#: ../../library/codecs.rst:1212 msgid "cp1257" msgstr "cp1257" -#: ../../library/codecs.rst:1209 +#: ../../library/codecs.rst:1212 msgid "windows-1257" msgstr "windows-1257" -#: ../../library/codecs.rst:1211 +#: ../../library/codecs.rst:1214 msgid "cp1258" msgstr "cp1258" -#: ../../library/codecs.rst:1211 +#: ../../library/codecs.rst:1214 msgid "windows-1258" msgstr "windows-1258" -#: ../../library/codecs.rst:1211 +#: ../../library/codecs.rst:1214 msgid "Vietnamese" msgstr "越南文" -#: ../../library/codecs.rst:1213 +#: ../../library/codecs.rst:1216 msgid "euc_jp" msgstr "euc_jp" -#: ../../library/codecs.rst:1213 +#: ../../library/codecs.rst:1216 msgid "eucjp, ujis, u-jis" msgstr "eucjp, ujis, u-jis" -#: ../../library/codecs.rst:1215 +#: ../../library/codecs.rst:1218 msgid "euc_jis_2004" msgstr "euc_jis_2004" -#: ../../library/codecs.rst:1215 +#: ../../library/codecs.rst:1218 msgid "jisx0213, eucjis2004" msgstr "jisx0213, eucjis2004" -#: ../../library/codecs.rst:1217 +#: ../../library/codecs.rst:1220 msgid "euc_jisx0213" msgstr "euc_jisx0213" -#: ../../library/codecs.rst:1217 +#: ../../library/codecs.rst:1220 msgid "eucjisx0213" msgstr "eucjisx0213" -#: ../../library/codecs.rst:1219 +#: ../../library/codecs.rst:1222 msgid "euc_kr" msgstr "euc_kr" -#: ../../library/codecs.rst:1219 +#: ../../library/codecs.rst:1222 msgid "euckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001" msgstr "euckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001" -#: ../../library/codecs.rst:1223 +#: ../../library/codecs.rst:1226 msgid "gb2312" msgstr "gb2312" -#: ../../library/codecs.rst:1223 +#: ../../library/codecs.rst:1226 msgid "" "chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, " "gb2312-80, iso-ir-58" @@ -1909,454 +1918,458 @@ msgstr "" "chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, " "gb2312-80, iso-ir-58" -#: ../../library/codecs.rst:1223 ../../library/codecs.rst:1232 +#: ../../library/codecs.rst:1226 ../../library/codecs.rst:1235 msgid "Simplified Chinese" msgstr "簡體中文" -#: ../../library/codecs.rst:1228 +#: ../../library/codecs.rst:1231 msgid "gbk" msgstr "gbk" -#: ../../library/codecs.rst:1228 +#: ../../library/codecs.rst:1231 msgid "936, cp936, ms936" msgstr "936, cp936, ms936" -#: ../../library/codecs.rst:1228 ../../library/codecs.rst:1230 +#: ../../library/codecs.rst:1231 ../../library/codecs.rst:1233 msgid "Unified Chinese" msgstr "" -#: ../../library/codecs.rst:1230 +#: ../../library/codecs.rst:1233 msgid "gb18030" msgstr "gb18030" -#: ../../library/codecs.rst:1230 +#: ../../library/codecs.rst:1233 msgid "gb18030-2000" msgstr "gb18030-2000" -#: ../../library/codecs.rst:1232 +#: ../../library/codecs.rst:1235 msgid "hz" msgstr "hz" -#: ../../library/codecs.rst:1232 +#: ../../library/codecs.rst:1235 msgid "hzgb, hz-gb, hz-gb-2312" msgstr "hzgb, hz-gb, hz-gb-2312" -#: ../../library/codecs.rst:1234 +#: ../../library/codecs.rst:1237 msgid "iso2022_jp" msgstr "iso2022_jp" -#: ../../library/codecs.rst:1234 +#: ../../library/codecs.rst:1237 msgid "csiso2022jp, iso2022jp, iso-2022-jp" msgstr "csiso2022jp, iso2022jp, iso-2022-jp" -#: ../../library/codecs.rst:1237 +#: ../../library/codecs.rst:1240 msgid "iso2022_jp_1" msgstr "iso2022_jp_1" -#: ../../library/codecs.rst:1237 +#: ../../library/codecs.rst:1240 msgid "iso2022jp-1, iso-2022-jp-1" msgstr "iso2022jp-1, iso-2022-jp-1" -#: ../../library/codecs.rst:1239 +#: ../../library/codecs.rst:1242 msgid "iso2022_jp_2" msgstr "iso2022_jp_2" -#: ../../library/codecs.rst:1239 +#: ../../library/codecs.rst:1242 msgid "iso2022jp-2, iso-2022-jp-2" msgstr "iso2022jp-2, iso-2022-jp-2" -#: ../../library/codecs.rst:1239 +#: ../../library/codecs.rst:1242 msgid "Japanese, Korean, Simplified Chinese, Western Europe, Greek" msgstr "" -#: ../../library/codecs.rst:1242 +#: ../../library/codecs.rst:1245 msgid "iso2022_jp_2004" msgstr "iso2022_jp_2004" -#: ../../library/codecs.rst:1242 +#: ../../library/codecs.rst:1245 msgid "iso2022jp-2004, iso-2022-jp-2004" msgstr "iso2022jp-2004, iso-2022-jp-2004" -#: ../../library/codecs.rst:1245 +#: ../../library/codecs.rst:1248 msgid "iso2022_jp_3" msgstr "iso2022_jp_3" -#: ../../library/codecs.rst:1245 +#: ../../library/codecs.rst:1248 msgid "iso2022jp-3, iso-2022-jp-3" msgstr "iso2022jp-3, iso-2022-jp-3" -#: ../../library/codecs.rst:1247 +#: ../../library/codecs.rst:1250 msgid "iso2022_jp_ext" msgstr "iso2022_jp_ext" -#: ../../library/codecs.rst:1247 +#: ../../library/codecs.rst:1250 msgid "iso2022jp-ext, iso-2022-jp-ext" msgstr "iso2022jp-ext, iso-2022-jp-ext" -#: ../../library/codecs.rst:1249 +#: ../../library/codecs.rst:1252 msgid "iso2022_kr" msgstr "iso2022_kr" -#: ../../library/codecs.rst:1249 +#: ../../library/codecs.rst:1252 msgid "csiso2022kr, iso2022kr, iso-2022-kr" msgstr "csiso2022kr, iso2022kr, iso-2022-kr" -#: ../../library/codecs.rst:1252 +#: ../../library/codecs.rst:1255 msgid "latin_1" msgstr "latin_1" -#: ../../library/codecs.rst:1252 +#: ../../library/codecs.rst:1255 msgid "iso-8859-1, iso8859-1, 8859, cp819, latin, latin1, L1" msgstr "iso-8859-1, iso8859-1, 8859, cp819, latin, latin1, L1" -#: ../../library/codecs.rst:1255 +#: ../../library/codecs.rst:1258 msgid "iso8859_2" msgstr "iso8859_2" -#: ../../library/codecs.rst:1255 +#: ../../library/codecs.rst:1258 msgid "iso-8859-2, latin2, L2" msgstr "iso-8859-2, latin2, L2" -#: ../../library/codecs.rst:1257 +#: ../../library/codecs.rst:1260 msgid "iso8859_3" msgstr "iso8859_3" -#: ../../library/codecs.rst:1257 +#: ../../library/codecs.rst:1260 msgid "iso-8859-3, latin3, L3" msgstr "iso-8859-3, latin3, L3" -#: ../../library/codecs.rst:1257 +#: ../../library/codecs.rst:1260 msgid "Esperanto, Maltese" msgstr "" -#: ../../library/codecs.rst:1259 +#: ../../library/codecs.rst:1262 msgid "iso8859_4" msgstr "iso8859_4" -#: ../../library/codecs.rst:1259 +#: ../../library/codecs.rst:1262 msgid "iso-8859-4, latin4, L4" msgstr "iso-8859-4, latin4, L4" -#: ../../library/codecs.rst:1259 +#: ../../library/codecs.rst:1262 msgid "Northern Europe" msgstr "" -#: ../../library/codecs.rst:1261 +#: ../../library/codecs.rst:1264 msgid "iso8859_5" msgstr "iso8859_5" -#: ../../library/codecs.rst:1261 +#: ../../library/codecs.rst:1264 msgid "iso-8859-5, cyrillic" msgstr "iso-8859-5, cyrillic" -#: ../../library/codecs.rst:1264 +#: ../../library/codecs.rst:1267 msgid "iso8859_6" msgstr "iso8859_6" -#: ../../library/codecs.rst:1264 +#: ../../library/codecs.rst:1267 msgid "iso-8859-6, arabic" msgstr "iso-8859-6, arabic" -#: ../../library/codecs.rst:1266 +#: ../../library/codecs.rst:1269 msgid "iso8859_7" msgstr "iso8859_7" -#: ../../library/codecs.rst:1266 +#: ../../library/codecs.rst:1269 msgid "iso-8859-7, greek, greek8" msgstr "iso-8859-7, greek, greek8" -#: ../../library/codecs.rst:1268 +#: ../../library/codecs.rst:1271 msgid "iso8859_8" msgstr "iso8859_8" -#: ../../library/codecs.rst:1268 +#: ../../library/codecs.rst:1271 msgid "iso-8859-8, hebrew" msgstr "iso-8859-8, hebrew" -#: ../../library/codecs.rst:1270 +#: ../../library/codecs.rst:1273 msgid "iso8859_9" msgstr "iso8859_9" -#: ../../library/codecs.rst:1270 +#: ../../library/codecs.rst:1273 msgid "iso-8859-9, latin5, L5" msgstr "iso-8859-9, latin5, L5" -#: ../../library/codecs.rst:1272 +#: ../../library/codecs.rst:1275 msgid "iso8859_10" msgstr "iso8859_10" -#: ../../library/codecs.rst:1272 +#: ../../library/codecs.rst:1275 msgid "iso-8859-10, latin6, L6" msgstr "iso-8859-10, latin6, L6" -#: ../../library/codecs.rst:1272 +#: ../../library/codecs.rst:1275 msgid "Nordic languages" msgstr "" -#: ../../library/codecs.rst:1274 +#: ../../library/codecs.rst:1277 msgid "iso8859_11" msgstr "iso8859_11" -#: ../../library/codecs.rst:1274 +#: ../../library/codecs.rst:1277 msgid "iso-8859-11, thai" msgstr "iso-8859-11, thai" -#: ../../library/codecs.rst:1274 +#: ../../library/codecs.rst:1277 msgid "Thai languages" msgstr "泰語" -#: ../../library/codecs.rst:1276 +#: ../../library/codecs.rst:1279 msgid "iso8859_13" msgstr "iso8859_13" -#: ../../library/codecs.rst:1276 +#: ../../library/codecs.rst:1279 msgid "iso-8859-13, latin7, L7" msgstr "iso-8859-13, latin7, L7" -#: ../../library/codecs.rst:1278 +#: ../../library/codecs.rst:1281 msgid "iso8859_14" msgstr "iso8859_14" -#: ../../library/codecs.rst:1278 +#: ../../library/codecs.rst:1281 msgid "iso-8859-14, latin8, L8" msgstr "iso-8859-14, latin8, L8" -#: ../../library/codecs.rst:1278 +#: ../../library/codecs.rst:1281 msgid "Celtic languages" msgstr "" -#: ../../library/codecs.rst:1280 +#: ../../library/codecs.rst:1283 msgid "iso8859_15" msgstr "iso8859_15" -#: ../../library/codecs.rst:1280 +#: ../../library/codecs.rst:1283 msgid "iso-8859-15, latin9, L9" msgstr "iso-8859-15, latin9, L9" -#: ../../library/codecs.rst:1282 +#: ../../library/codecs.rst:1285 msgid "iso8859_16" msgstr "iso8859_16" -#: ../../library/codecs.rst:1282 +#: ../../library/codecs.rst:1285 msgid "iso-8859-16, latin10, L10" msgstr "iso-8859-16, latin10, L10" -#: ../../library/codecs.rst:1282 +#: ../../library/codecs.rst:1285 msgid "South-Eastern Europe" msgstr "" -#: ../../library/codecs.rst:1284 +#: ../../library/codecs.rst:1287 msgid "johab" msgstr "johab" -#: ../../library/codecs.rst:1284 +#: ../../library/codecs.rst:1287 msgid "cp1361, ms1361" msgstr "cp1361, ms1361" -#: ../../library/codecs.rst:1286 +#: ../../library/codecs.rst:1289 msgid "koi8_r" msgstr "koi8_r" -#: ../../library/codecs.rst:1288 +#: ../../library/codecs.rst:1291 msgid "koi8_t" msgstr "koi8_t" -#: ../../library/codecs.rst:1288 +#: ../../library/codecs.rst:1291 msgid "Tajik" msgstr "" -#: ../../library/codecs.rst:1292 +#: ../../library/codecs.rst:1295 msgid "koi8_u" msgstr "koi8_u" -#: ../../library/codecs.rst:1294 +#: ../../library/codecs.rst:1297 msgid "kz1048" msgstr "kz1048" -#: ../../library/codecs.rst:1294 +#: ../../library/codecs.rst:1297 msgid "kz_1048, strk1048_2002, rk1048" msgstr "kz_1048, strk1048_2002, rk1048" -#: ../../library/codecs.rst:1294 ../../library/codecs.rst:1312 +#: ../../library/codecs.rst:1297 ../../library/codecs.rst:1315 msgid "Kazakh" msgstr "" -#: ../../library/codecs.rst:1298 +#: ../../library/codecs.rst:1301 msgid "mac_cyrillic" msgstr "mac_cyrillic" -#: ../../library/codecs.rst:1298 +#: ../../library/codecs.rst:1301 msgid "maccyrillic" msgstr "" -#: ../../library/codecs.rst:1301 +#: ../../library/codecs.rst:1304 msgid "mac_greek" msgstr "mac_greek" -#: ../../library/codecs.rst:1301 +#: ../../library/codecs.rst:1304 msgid "macgreek" msgstr "" -#: ../../library/codecs.rst:1303 +#: ../../library/codecs.rst:1306 msgid "mac_iceland" msgstr "mac_iceland" -#: ../../library/codecs.rst:1303 +#: ../../library/codecs.rst:1306 msgid "maciceland" msgstr "" -#: ../../library/codecs.rst:1305 +#: ../../library/codecs.rst:1308 msgid "mac_latin2" msgstr "mac_latin2" -#: ../../library/codecs.rst:1305 +#: ../../library/codecs.rst:1308 msgid "maclatin2, maccentraleurope, mac_centeuro" msgstr "maclatin2, maccentraleurope, mac_centeuro" -#: ../../library/codecs.rst:1308 +#: ../../library/codecs.rst:1311 msgid "mac_roman" msgstr "mac_roman" -#: ../../library/codecs.rst:1308 +#: ../../library/codecs.rst:1311 msgid "macroman, macintosh" msgstr "macroman, macintosh" -#: ../../library/codecs.rst:1310 +#: ../../library/codecs.rst:1313 msgid "mac_turkish" msgstr "mac_turkish" -#: ../../library/codecs.rst:1310 +#: ../../library/codecs.rst:1313 msgid "macturkish" msgstr "" -#: ../../library/codecs.rst:1312 +#: ../../library/codecs.rst:1315 msgid "ptcp154" msgstr "ptcp154" -#: ../../library/codecs.rst:1312 +#: ../../library/codecs.rst:1315 msgid "csptcp154, pt154, cp154, cyrillic-asian" msgstr "csptcp154, pt154, cp154, cyrillic-asian" -#: ../../library/codecs.rst:1315 +#: ../../library/codecs.rst:1318 msgid "shift_jis" msgstr "shift_jis" -#: ../../library/codecs.rst:1315 +#: ../../library/codecs.rst:1318 msgid "csshiftjis, shiftjis, sjis, s_jis" msgstr "csshiftjis, shiftjis, sjis, s_jis" -#: ../../library/codecs.rst:1318 +#: ../../library/codecs.rst:1321 msgid "shift_jis_2004" msgstr "shift_jis_2004" -#: ../../library/codecs.rst:1318 +#: ../../library/codecs.rst:1321 msgid "shiftjis2004, sjis_2004, sjis2004" msgstr "shiftjis2004, sjis_2004, sjis2004" -#: ../../library/codecs.rst:1321 +#: ../../library/codecs.rst:1324 msgid "shift_jisx0213" msgstr "shift_jisx0213" -#: ../../library/codecs.rst:1321 +#: ../../library/codecs.rst:1324 msgid "shiftjisx0213, sjisx0213, s_jisx0213" msgstr "shiftjisx0213, sjisx0213, s_jisx0213" -#: ../../library/codecs.rst:1324 +#: ../../library/codecs.rst:1327 msgid "utf_32" msgstr "utf_32" -#: ../../library/codecs.rst:1324 +#: ../../library/codecs.rst:1327 msgid "U32, utf32" msgstr "U32, utf32" -#: ../../library/codecs.rst:1324 ../../library/codecs.rst:1326 -#: ../../library/codecs.rst:1328 ../../library/codecs.rst:1330 -#: ../../library/codecs.rst:1332 ../../library/codecs.rst:1334 -#: ../../library/codecs.rst:1336 ../../library/codecs.rst:1338 -#: ../../library/codecs.rst:1340 +#: ../../library/codecs.rst:1327 ../../library/codecs.rst:1329 +#: ../../library/codecs.rst:1331 ../../library/codecs.rst:1333 +#: ../../library/codecs.rst:1335 ../../library/codecs.rst:1337 +#: ../../library/codecs.rst:1339 ../../library/codecs.rst:1341 +#: ../../library/codecs.rst:1343 msgid "all languages" msgstr "" -#: ../../library/codecs.rst:1326 +#: ../../library/codecs.rst:1329 msgid "utf_32_be" msgstr "utf_32_be" -#: ../../library/codecs.rst:1326 +#: ../../library/codecs.rst:1329 msgid "UTF-32BE" msgstr "UTF-32BE" -#: ../../library/codecs.rst:1328 +#: ../../library/codecs.rst:1331 msgid "utf_32_le" msgstr "utf_32_le" -#: ../../library/codecs.rst:1328 +#: ../../library/codecs.rst:1331 msgid "UTF-32LE" msgstr "UTF-32LE" -#: ../../library/codecs.rst:1330 +#: ../../library/codecs.rst:1333 msgid "utf_16" msgstr "utf_16" -#: ../../library/codecs.rst:1330 +#: ../../library/codecs.rst:1333 msgid "U16, utf16" msgstr "U16, utf16" -#: ../../library/codecs.rst:1332 +#: ../../library/codecs.rst:1335 msgid "utf_16_be" msgstr "utf_16_be" -#: ../../library/codecs.rst:1332 +#: ../../library/codecs.rst:1335 msgid "UTF-16BE" msgstr "UTF-16BE" -#: ../../library/codecs.rst:1334 +#: ../../library/codecs.rst:1337 msgid "utf_16_le" msgstr "utf_16_le" -#: ../../library/codecs.rst:1334 +#: ../../library/codecs.rst:1337 msgid "UTF-16LE" msgstr "UTF-16LE" -#: ../../library/codecs.rst:1336 +#: ../../library/codecs.rst:1339 msgid "utf_7" msgstr "utf_7" -#: ../../library/codecs.rst:1336 +#: ../../library/codecs.rst:1339 msgid "U7, unicode-1-1-utf-7" msgstr "U7, unicode-1-1-utf-7" -#: ../../library/codecs.rst:1338 +#: ../../library/codecs.rst:1341 msgid "utf_8" msgstr "utf_8" -#: ../../library/codecs.rst:1338 +#: ../../library/codecs.rst:1341 msgid "U8, UTF, utf8, cp65001" msgstr "U8, UTF, utf8, cp65001" -#: ../../library/codecs.rst:1340 +#: ../../library/codecs.rst:1343 msgid "utf_8_sig" msgstr "utf_8_sig" #: ../../library/codecs.rst:1343 +msgid "utf8-sig" +msgstr "" + +#: ../../library/codecs.rst:1346 msgid "" "The utf-16\\* and utf-32\\* encoders no longer allow surrogate code points " "(``U+D800``--``U+DFFF``) to be encoded. The utf-32\\* decoders no longer " "decode byte sequences that correspond to surrogate code points." msgstr "" -#: ../../library/codecs.rst:1349 +#: ../../library/codecs.rst:1352 msgid "``cp65001`` is now an alias to ``utf_8``." msgstr "``cp65001`` 現在是 ``utf_8`` 的別名。" -#: ../../library/codecs.rst:1352 +#: ../../library/codecs.rst:1355 msgid "On Windows, ``cpXXX`` codecs are now available for all code pages." msgstr "" -#: ../../library/codecs.rst:1357 +#: ../../library/codecs.rst:1360 msgid "Python Specific Encodings" msgstr "" -#: ../../library/codecs.rst:1359 +#: ../../library/codecs.rst:1362 msgid "" "A number of predefined codecs are specific to Python, so their codec names " "have no meaning outside Python. These are listed in the tables below based " @@ -2366,252 +2379,252 @@ msgid "" "asymmetric codecs, the stated meaning describes the encoding direction." msgstr "" -#: ../../library/codecs.rst:1367 +#: ../../library/codecs.rst:1370 msgid "Text Encodings" msgstr "" -#: ../../library/codecs.rst:1369 +#: ../../library/codecs.rst:1372 msgid "" "The following codecs provide :class:`str` to :class:`bytes` encoding and :" "term:`bytes-like object` to :class:`str` decoding, similar to the Unicode " "text encodings." msgstr "" -#: ../../library/codecs.rst:1378 +#: ../../library/codecs.rst:1381 msgid "idna" msgstr "idna" -#: ../../library/codecs.rst:1378 +#: ../../library/codecs.rst:1381 msgid "" "Implement :rfc:`3490`, see also :mod:`encodings.idna`. Only " "``errors='strict'`` is supported." msgstr "" -#: ../../library/codecs.rst:1386 +#: ../../library/codecs.rst:1389 msgid "" "This codec builds on ``punycode``, whose algorithms scale poorly, so limit " "the length of untrusted input." msgstr "" -#: ../../library/codecs.rst:1393 +#: ../../library/codecs.rst:1396 msgid "mbcs" msgstr "mbcs" -#: ../../library/codecs.rst:1393 +#: ../../library/codecs.rst:1396 msgid "ansi, dbcs" msgstr "ansi, dbcs" -#: ../../library/codecs.rst:1393 +#: ../../library/codecs.rst:1396 msgid "" "Windows only: Encode the operand according to the ANSI codepage (CP_ACP)." msgstr "" -#: ../../library/codecs.rst:1397 +#: ../../library/codecs.rst:1400 msgid "oem" msgstr "oem" -#: ../../library/codecs.rst:1397 +#: ../../library/codecs.rst:1400 msgid "" "Windows only: Encode the operand according to the OEM codepage (CP_OEMCP)." msgstr "" -#: ../../library/codecs.rst:1403 +#: ../../library/codecs.rst:1406 msgid "palmos" msgstr "palmos" -#: ../../library/codecs.rst:1403 +#: ../../library/codecs.rst:1406 msgid "Encoding of PalmOS 3.5." msgstr "PalmOS 3.5 的編碼。" -#: ../../library/codecs.rst:1405 +#: ../../library/codecs.rst:1408 msgid "punycode" msgstr "punycode" -#: ../../library/codecs.rst:1405 +#: ../../library/codecs.rst:1408 msgid "Implement :rfc:`3492`. Stateful codecs are not supported." msgstr "" -#: ../../library/codecs.rst:1411 +#: ../../library/codecs.rst:1414 msgid "" "The decoding and encoding algorithms scale poorly, so limit the length of " "untrusted input." msgstr "" -#: ../../library/codecs.rst:1417 +#: ../../library/codecs.rst:1420 msgid "raw_unicode_escape" msgstr "raw_unicode_escape" -#: ../../library/codecs.rst:1417 +#: ../../library/codecs.rst:1420 msgid "" "Latin-1 encoding with :samp:`\\\\u{XXXX}` and :samp:`\\\\U{XXXXXXXX}` for " "other code points. Existing backslashes are not escaped in any way. It is " "used in the Python pickle protocol." msgstr "" -#: ../../library/codecs.rst:1427 +#: ../../library/codecs.rst:1430 msgid "undefined" msgstr "" -#: ../../library/codecs.rst:1427 +#: ../../library/codecs.rst:1430 msgid "This Codec should only be used for testing purposes." msgstr "" -#: ../../library/codecs.rst:1431 +#: ../../library/codecs.rst:1434 msgid "" "Raise an exception for all conversions, even empty strings. The error " "handler is ignored." msgstr "" -#: ../../library/codecs.rst:1436 +#: ../../library/codecs.rst:1439 msgid "unicode_escape" msgstr "unicode_escape" -#: ../../library/codecs.rst:1436 +#: ../../library/codecs.rst:1439 msgid "" "Encoding suitable as the contents of a Unicode literal in ASCII-encoded " "Python source code, except that quotes are not escaped. Decode from Latin-1 " "source code. Beware that Python source code actually uses UTF-8 by default." msgstr "" -#: ../../library/codecs.rst:1448 +#: ../../library/codecs.rst:1451 msgid "\"unicode_internal\" codec is removed." msgstr "" -#: ../../library/codecs.rst:1455 +#: ../../library/codecs.rst:1458 msgid "Binary Transforms" msgstr "" -#: ../../library/codecs.rst:1457 +#: ../../library/codecs.rst:1460 msgid "" "The following codecs provide binary transforms: :term:`bytes-like object` " "to :class:`bytes` mappings. They are not supported by :meth:`bytes.decode` " "(which only produces :class:`str` output)." msgstr "" -#: ../../library/codecs.rst:1465 +#: ../../library/codecs.rst:1468 msgid "Encoder / decoder" msgstr "編碼器 / 解碼器" -#: ../../library/codecs.rst:1467 +#: ../../library/codecs.rst:1470 msgid "base64_codec [#b64]_" msgstr "base64_codec [#b64]_" -#: ../../library/codecs.rst:1467 +#: ../../library/codecs.rst:1470 msgid "base64, base_64" msgstr "base64, base_64" -#: ../../library/codecs.rst:1467 +#: ../../library/codecs.rst:1470 msgid "" "Convert the operand to multiline MIME base64 (the result always includes a " "trailing ``'\\n'``)." msgstr "" -#: ../../library/codecs.rst:1472 +#: ../../library/codecs.rst:1475 msgid "" "accepts any :term:`bytes-like object` as input for encoding and decoding" msgstr "" -#: ../../library/codecs.rst:1467 +#: ../../library/codecs.rst:1470 msgid ":meth:`base64.encodebytes` / :meth:`base64.decodebytes`" msgstr ":meth:`base64.encodebytes` / :meth:`base64.decodebytes`" -#: ../../library/codecs.rst:1478 +#: ../../library/codecs.rst:1481 msgid "bz2_codec" msgstr "bz2_codec" -#: ../../library/codecs.rst:1478 +#: ../../library/codecs.rst:1481 msgid "bz2" msgstr "bz2" -#: ../../library/codecs.rst:1478 +#: ../../library/codecs.rst:1481 msgid "Compress the operand using bz2." msgstr "" -#: ../../library/codecs.rst:1478 +#: ../../library/codecs.rst:1481 msgid ":meth:`bz2.compress` / :meth:`bz2.decompress`" msgstr ":meth:`bz2.compress` / :meth:`bz2.decompress`" -#: ../../library/codecs.rst:1481 +#: ../../library/codecs.rst:1484 msgid "hex_codec" msgstr "hex_codec" -#: ../../library/codecs.rst:1481 +#: ../../library/codecs.rst:1484 msgid "hex" msgstr "hex" -#: ../../library/codecs.rst:1481 +#: ../../library/codecs.rst:1484 msgid "" "Convert the operand to hexadecimal representation, with two digits per byte." msgstr "" -#: ../../library/codecs.rst:1481 +#: ../../library/codecs.rst:1484 msgid ":meth:`binascii.b2a_hex` / :meth:`binascii.a2b_hex`" msgstr ":meth:`binascii.b2a_hex` / :meth:`binascii.a2b_hex`" -#: ../../library/codecs.rst:1486 +#: ../../library/codecs.rst:1489 msgid "quopri_codec" msgstr "quopri_codec" -#: ../../library/codecs.rst:1486 +#: ../../library/codecs.rst:1489 msgid "quopri, quotedprintable, quoted_printable" msgstr "quopri, quotedprintable, quoted_printable" -#: ../../library/codecs.rst:1486 +#: ../../library/codecs.rst:1489 msgid "Convert the operand to MIME quoted printable." msgstr "" -#: ../../library/codecs.rst:1486 +#: ../../library/codecs.rst:1489 msgid ":meth:`quopri.encode` with ``quotetabs=True`` / :meth:`quopri.decode`" msgstr ":meth:`quopri.encode` with ``quotetabs=True`` / :meth:`quopri.decode`" -#: ../../library/codecs.rst:1490 +#: ../../library/codecs.rst:1493 msgid "uu_codec" msgstr "uu_codec" -#: ../../library/codecs.rst:1490 +#: ../../library/codecs.rst:1493 msgid "uu" msgstr "uu" -#: ../../library/codecs.rst:1490 +#: ../../library/codecs.rst:1493 msgid "Convert the operand using uuencode." msgstr "" -#: ../../library/codecs.rst:1493 +#: ../../library/codecs.rst:1496 msgid "zlib_codec" msgstr "zlib_codec" -#: ../../library/codecs.rst:1493 +#: ../../library/codecs.rst:1496 msgid "zip, zlib" msgstr "zip, zlib" -#: ../../library/codecs.rst:1493 +#: ../../library/codecs.rst:1496 msgid "Compress the operand using gzip." msgstr "" -#: ../../library/codecs.rst:1493 +#: ../../library/codecs.rst:1496 msgid ":meth:`zlib.compress` / :meth:`zlib.decompress`" msgstr ":meth:`zlib.compress` / :meth:`zlib.decompress`" -#: ../../library/codecs.rst:1497 +#: ../../library/codecs.rst:1500 msgid "" "In addition to :term:`bytes-like objects `, " "``'base64_codec'`` also accepts ASCII-only instances of :class:`str` for " "decoding" msgstr "" -#: ../../library/codecs.rst:1501 +#: ../../library/codecs.rst:1504 msgid "Restoration of the binary transforms." msgstr "" -#: ../../library/codecs.rst:1504 +#: ../../library/codecs.rst:1507 msgid "Restoration of the aliases for the binary transforms." msgstr "" -#: ../../library/codecs.rst:1511 +#: ../../library/codecs.rst:1514 msgid "Standalone Codec Functions" msgstr "" -#: ../../library/codecs.rst:1513 +#: ../../library/codecs.rst:1516 msgid "" "The following functions provide encoding and decoding functionality similar " "to codecs, but are not available as named codecs through :func:`codecs." @@ -2620,74 +2633,74 @@ msgid "" "removed in Python 3." msgstr "" -#: ../../library/codecs.rst:1520 +#: ../../library/codecs.rst:1523 msgid "" "Encode *input* using escape sequences. Similar to how :func:`repr` on bytes " "produces escaped byte values." msgstr "" -#: ../../library/codecs.rst:1523 +#: ../../library/codecs.rst:1526 msgid "*input* must be a :class:`bytes` object." msgstr "*input* 必須是個 :class:`bytes` 物件。" -#: ../../library/codecs.rst:1525 ../../library/codecs.rst:1534 +#: ../../library/codecs.rst:1528 ../../library/codecs.rst:1537 msgid "" "Returns a tuple ``(output, length)`` where *output* is a :class:`bytes` " "object and *length* is the number of bytes consumed." msgstr "" -#: ../../library/codecs.rst:1530 +#: ../../library/codecs.rst:1533 msgid "Decode *input* from escape sequences back to the original bytes." msgstr "" -#: ../../library/codecs.rst:1532 +#: ../../library/codecs.rst:1535 msgid "*input* must be a :term:`bytes-like object`." msgstr "*input* 必須是個 :term:`bytes-like object`。" -#: ../../library/codecs.rst:1541 +#: ../../library/codecs.rst:1544 msgid "Text Transforms" msgstr "" -#: ../../library/codecs.rst:1543 +#: ../../library/codecs.rst:1546 msgid "" "The following codec provides a text transform: a :class:`str` to :class:" "`str` mapping. It is not supported by :meth:`str.encode` (which only " "produces :class:`bytes` output)." msgstr "" -#: ../../library/codecs.rst:1552 +#: ../../library/codecs.rst:1555 msgid "rot_13" msgstr "rot_13" -#: ../../library/codecs.rst:1552 +#: ../../library/codecs.rst:1555 msgid "rot13" msgstr "rot13" -#: ../../library/codecs.rst:1552 +#: ../../library/codecs.rst:1555 msgid "Return the Caesar-cypher encryption of the operand." msgstr "" -#: ../../library/codecs.rst:1557 +#: ../../library/codecs.rst:1560 msgid "Restoration of the ``rot_13`` text transform." msgstr "" -#: ../../library/codecs.rst:1560 +#: ../../library/codecs.rst:1563 msgid "Restoration of the ``rot13`` alias." msgstr "" -#: ../../library/codecs.rst:1565 +#: ../../library/codecs.rst:1568 msgid ":mod:`!encodings` --- Encodings package" msgstr ":mod:`!encodings` --- 編碼套件" -#: ../../library/codecs.rst:1570 +#: ../../library/codecs.rst:1573 msgid "This module implements the following functions:" msgstr "" -#: ../../library/codecs.rst:1574 +#: ../../library/codecs.rst:1577 msgid "Normalize encoding name *encoding*." msgstr "" -#: ../../library/codecs.rst:1576 +#: ../../library/codecs.rst:1579 msgid "" "Normalization works as follows: all non-alphanumeric characters except the " "dot used for Python package names are collapsed and replaced with a single " @@ -2695,23 +2708,23 @@ msgid "" "-;#'`` becomes ``'_'``." msgstr "" -#: ../../library/codecs.rst:1581 +#: ../../library/codecs.rst:1584 msgid "Note that *encoding* should be ASCII only." msgstr "" -#: ../../library/codecs.rst:1585 +#: ../../library/codecs.rst:1588 msgid "" "The following functions should not be used directly, except for testing " "purposes; :func:`codecs.lookup` should be used instead." msgstr "" -#: ../../library/codecs.rst:1591 +#: ../../library/codecs.rst:1594 msgid "" "Search for the codec module corresponding to the given encoding name " "*encoding*." msgstr "" -#: ../../library/codecs.rst:1594 +#: ../../library/codecs.rst:1597 msgid "" "This function first normalizes the *encoding* using :func:" "`normalize_encoding`, then looks for a corresponding alias. It attempts to " @@ -2721,41 +2734,41 @@ msgid "" "the codec is cached and returned." msgstr "" -#: ../../library/codecs.rst:1601 +#: ../../library/codecs.rst:1604 msgid "" "If the codec module defines a ``getaliases()`` function any returned aliases " "are registered for future use." msgstr "" -#: ../../library/codecs.rst:1607 +#: ../../library/codecs.rst:1610 msgid "" "Search for a Windows code page encoding *encoding* of the form ``cpXXXX``." msgstr "" -#: ../../library/codecs.rst:1609 +#: ../../library/codecs.rst:1612 msgid "" "If the code page is valid and supported, return a :class:`codecs.CodecInfo` " "object for it." msgstr "" -#: ../../library/codecs.rst:1612 ../../library/codecs.rst:1703 +#: ../../library/codecs.rst:1615 ../../library/codecs.rst:1705 msgid "Availability" msgstr "可用性" -#: ../../library/codecs.rst:1617 +#: ../../library/codecs.rst:1620 msgid "This module implements the following exception:" msgstr "此模組實作了以下例外:" -#: ../../library/codecs.rst:1621 +#: ../../library/codecs.rst:1624 msgid "Raised when a codec is invalid or incompatible." msgstr "當編解碼器無效或不相容時引發。" -#: ../../library/codecs.rst:1625 +#: ../../library/codecs.rst:1628 msgid "" ":mod:`!encodings.idna` --- Internationalized Domain Names in Applications" msgstr "" -#: ../../library/codecs.rst:1631 +#: ../../library/codecs.rst:1633 msgid "" "This module implements :rfc:`3490` (Internationalized Domain Names in " "Applications) and :rfc:`3492` (Nameprep: A Stringprep Profile for " @@ -2763,19 +2776,19 @@ msgid "" "encoding and :mod:`stringprep`." msgstr "" -#: ../../library/codecs.rst:1638 +#: ../../library/codecs.rst:1640 msgid "" "This module builds on ``punycode``, whose algorithms scale poorly, so limit " "the length of untrusted input." msgstr "" -#: ../../library/codecs.rst:1641 +#: ../../library/codecs.rst:1643 msgid "" "If you need the IDNA 2008 standard from :rfc:`5891` and :rfc:`5895`, use the " "third-party :pypi:`idna` module." msgstr "" -#: ../../library/codecs.rst:1644 +#: ../../library/codecs.rst:1646 msgid "" "These RFCs together define a protocol to support non-ASCII characters in " "domain names. A domain name containing non-ASCII characters (such as ``www." @@ -2789,7 +2802,7 @@ msgid "" "presenting them to the user." msgstr "" -#: ../../library/codecs.rst:1655 +#: ../../library/codecs.rst:1657 msgid "" "Python supports this conversion in several ways: the ``idna`` codec " "performs conversion between Unicode and ACE, separating an input string into " @@ -2806,14 +2819,14 @@ msgid "" "sends that field at all)." msgstr "" -#: ../../library/codecs.rst:1668 +#: ../../library/codecs.rst:1670 msgid "" "When receiving host names from the wire (such as in reverse name lookup), no " "automatic conversion to Unicode is performed: applications wishing to " "present such host names to the user should decode them to Unicode." msgstr "" -#: ../../library/codecs.rst:1672 +#: ../../library/codecs.rst:1674 msgid "" "The module :mod:`!encodings.idna` also implements the nameprep procedure, " "which performs certain normalizations on host names, to achieve case-" @@ -2821,45 +2834,45 @@ msgid "" "characters. The nameprep functions can be used directly if desired." msgstr "" -#: ../../library/codecs.rst:1680 +#: ../../library/codecs.rst:1682 msgid "" "Return the nameprepped version of *label*. The implementation currently " "assumes query strings, so ``AllowUnassigned`` is true." msgstr "" -#: ../../library/codecs.rst:1686 +#: ../../library/codecs.rst:1688 msgid "" "Convert a label to ASCII, as specified in :rfc:`3490`. ``UseSTD3ASCIIRules`` " "is assumed to be false." msgstr "" -#: ../../library/codecs.rst:1692 +#: ../../library/codecs.rst:1694 msgid "Convert a label to Unicode, as specified in :rfc:`3490`." msgstr "" -#: ../../library/codecs.rst:1696 +#: ../../library/codecs.rst:1698 msgid ":mod:`!encodings.mbcs` --- Windows ANSI codepage" msgstr ":mod:`!encodings.mbcs` --- Windows ANSI 碼頁" -#: ../../library/codecs.rst:1701 +#: ../../library/codecs.rst:1703 msgid "This module implements the ANSI codepage (CP_ACP)." msgstr "這個模組實作了 ANSI 碼頁 (CP_ACP)。" -#: ../../library/codecs.rst:1705 +#: ../../library/codecs.rst:1707 msgid "" "Before 3.2, the *errors* argument was ignored; ``'replace'`` was always used " "to encode, and ``'ignore'`` to decode." msgstr "" -#: ../../library/codecs.rst:1709 +#: ../../library/codecs.rst:1711 msgid "Support any error handler." msgstr "支援任何錯誤處理器。" -#: ../../library/codecs.rst:1714 +#: ../../library/codecs.rst:1716 msgid ":mod:`!encodings.utf_8_sig` --- UTF-8 codec with BOM signature" msgstr ":mod:`!encodings.utf_8_sig` --- 帶有 BOM 簽名的 UTF-8 編解碼器" -#: ../../library/codecs.rst:1720 +#: ../../library/codecs.rst:1721 msgid "" "This module implements a variant of the UTF-8 codec. On encoding, a UTF-8 " "encoded BOM will be prepended to the UTF-8 encoded bytes. For the stateful " @@ -2868,92 +2881,92 @@ msgid "" "skipped." msgstr "" -#: ../../library/codecs.rst:13 +#: ../../library/codecs.rst:9 msgid "Unicode" msgstr "Unicode" -#: ../../library/codecs.rst:13 +#: ../../library/codecs.rst:9 msgid "encode" msgstr "encode(編碼)" -#: ../../library/codecs.rst:13 +#: ../../library/codecs.rst:9 msgid "decode" msgstr "decode(解碼)" -#: ../../library/codecs.rst:13 +#: ../../library/codecs.rst:9 msgid "streams" msgstr "streams(串流)" -#: ../../library/codecs.rst:13 +#: ../../library/codecs.rst:9 msgid "stackable" msgstr "stackable(可堆疊)" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "strict" msgstr "strict" -#: ../../library/codecs.rst:338 ../../library/codecs.rst:390 -#: ../../library/codecs.rst:413 +#: ../../library/codecs.rst:341 ../../library/codecs.rst:393 +#: ../../library/codecs.rst:416 msgid "error handler's name" msgstr "error handler's name(錯誤處理器名稱)" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "ignore" msgstr "ignore" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "replace" msgstr "replace" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "backslashreplace" msgstr "backslashreplace" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "surrogateescape" msgstr "surrogateescape" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "replacement character" msgstr "replacement character(替代字元)" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "\\ (backslash)" msgstr "\\ (反斜線)" -#: ../../library/codecs.rst:338 ../../library/codecs.rst:390 +#: ../../library/codecs.rst:341 ../../library/codecs.rst:393 msgid "escape sequence" msgstr "escape sequence(跳脫序列)" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "\\x" msgstr "\\x" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "\\u" msgstr "\\u" -#: ../../library/codecs.rst:338 +#: ../../library/codecs.rst:341 msgid "\\U" msgstr "\\U" -#: ../../library/codecs.rst:390 +#: ../../library/codecs.rst:393 msgid "xmlcharrefreplace" msgstr "xmlcharrefreplace" -#: ../../library/codecs.rst:390 +#: ../../library/codecs.rst:393 msgid "namereplace" msgstr "namereplace" -#: ../../library/codecs.rst:390 +#: ../../library/codecs.rst:393 msgid "\\N" msgstr "\\N" -#: ../../library/codecs.rst:413 +#: ../../library/codecs.rst:416 msgid "surrogatepass" msgstr "surrogatepass" diff --git a/library/codeop.po b/library/codeop.po index 479ddbae3a7..c175f9f2713 100644 --- a/library/codeop.po +++ b/library/codeop.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-09-24 20:28+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!codeop` --- Compile Python code" msgstr ":mod:`!codeop` --- 編譯 Python 程式碼" -#: ../../library/codeop.rst:10 +#: ../../library/codeop.rst:7 msgid "**Source code:** :source:`Lib/codeop.py`" msgstr "**原始碼:**\\ :source:`Lib/codeop.py`" -#: ../../library/codeop.rst:14 +#: ../../library/codeop.rst:11 msgid "" "The :mod:`!codeop` module provides utilities upon which the Python read-eval-" "print loop can be emulated, as is done in the :mod:`code` module. As a " @@ -39,11 +39,11 @@ msgstr "" "(utilities),就像在 :mod:`code` 模組中所做的那樣。因此你可能不想直接使用該模" "組;如果你想在程式中包含這樣的循環,你可能需要使用 :mod:`code` 模組。" -#: ../../library/codeop.rst:20 +#: ../../library/codeop.rst:17 msgid "There are two parts to this job:" msgstr "這個任務有兩個部分:" -#: ../../library/codeop.rst:22 +#: ../../library/codeop.rst:19 msgid "" "Being able to tell if a line of input completes a Python statement: in " "short, telling whether to print '``>>>``' or '``...``' next." @@ -51,7 +51,7 @@ msgstr "" "能夠判斷一列輸入是否完成了一項 Python 陳述式:簡而言之,判斷接下來是列印 " "'``>>>``' 還是 '``...``'。" -#: ../../library/codeop.rst:25 +#: ../../library/codeop.rst:22 msgid "" "Remembering which future statements the user has entered, so subsequent " "input can be compiled with these in effect." @@ -59,7 +59,7 @@ msgstr "" "記住使用者輸入了哪些未來陳述式,以便後續輸入可以在這些陳述式生效的情況下進行" "編譯。" -#: ../../library/codeop.rst:28 +#: ../../library/codeop.rst:25 msgid "" "The :mod:`!codeop` module provides a way of doing each of these things, and " "a way of doing them both." @@ -67,11 +67,11 @@ msgstr "" ":mod:`!codeop` 模組提供了一種完成上述每項任務的方法,以及同時完成這兩項任務的" "方法。" -#: ../../library/codeop.rst:31 +#: ../../library/codeop.rst:28 msgid "To do just the former:" msgstr "只做前者:" -#: ../../library/codeop.rst:35 +#: ../../library/codeop.rst:32 msgid "" "Tries to compile *source*, which should be a string of Python code and " "return a code object if *source* is valid Python code. In that case, the " @@ -84,7 +84,7 @@ msgstr "" "檔案名稱屬性將為 *filename*,預設為 ``''``。如果 *source* 不是有效的 " "Python 程式碼,而是有效 Python 程式碼的前綴,則回傳 ``None``。" -#: ../../library/codeop.rst:41 +#: ../../library/codeop.rst:38 msgid "" "If there is a problem with *source*, an exception will be raised. :exc:" "`SyntaxError` is raised if there is invalid Python syntax, and :exc:" @@ -94,7 +94,7 @@ msgstr "" "`SyntaxError`;如果存在無效的文字 (literal),則會引發 :exc:`OverflowError` " "或 :exc:`ValueError`。" -#: ../../library/codeop.rst:45 +#: ../../library/codeop.rst:42 msgid "" "The *symbol* argument determines whether *source* is compiled as a statement " "(``'single'``, the default), as a sequence of :term:`statement` (``'exec'``) " @@ -105,7 +105,7 @@ msgstr "" "term:`陳述式 `\\ 序列 (``'exec'``) 或為\\ :term:`運算式 " "` (``'eval'``)。任何其他值都會導致引發 :exc:`ValueError`。" -#: ../../library/codeop.rst:52 +#: ../../library/codeop.rst:49 msgid "" "It is possible (but not likely) that the parser stops parsing with a " "successful outcome before reaching the end of the source; in this case, " @@ -118,7 +118,7 @@ msgstr "" "上兩個換行符號後可以是任意的無意義符號。這個問題在未來會因為剖析器 API 的改善" "而被解決。" -#: ../../library/codeop.rst:61 +#: ../../library/codeop.rst:58 msgid "" "Instances of this class have :meth:`~object.__call__` methods identical in " "signature to the built-in function :func:`compile`, but with the difference " @@ -130,7 +130,7 @@ msgstr "" "`compile` 相同,區別在於如果實例編譯包含 :mod:`__future__` 陳述式的程式文本," "實例會「記住」並使用該陳述式開始編譯所有後續程式文本。" -#: ../../library/codeop.rst:70 +#: ../../library/codeop.rst:67 msgid "" "Instances of this class have :meth:`~object.__call__` methods identical in " "signature to :func:`compile_command`; the difference is that if the instance " diff --git a/library/collections.abc.po b/library/collections.abc.po index f5d30db6dda..9eec528243c 100644 --- a/library/collections.abc.po +++ b/library/collections.abc.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-09 00:37+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:41+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,15 +21,15 @@ msgstr "" msgid ":mod:`!collections.abc` --- Abstract Base Classes for Containers" msgstr ":mod:`!collections.abc` --- 容器的抽象基底類別" -#: ../../library/collections.abc.rst:10 +#: ../../library/collections.abc.rst:7 msgid "Formerly, this module was part of the :mod:`collections` module." msgstr "過去此模組是 :mod:`collections` 模組的一部分。" -#: ../../library/collections.abc.rst:13 +#: ../../library/collections.abc.rst:10 msgid "**Source code:** :source:`Lib/_collections_abc.py`" msgstr "**原始碼:**\\ :source:`Lib/_collections_abc.py`" -#: ../../library/collections.abc.rst:23 +#: ../../library/collections.abc.rst:20 msgid "" "This module provides :term:`abstract base classes ` " "that can be used to test whether a class provides a particular interface; " @@ -37,13 +37,13 @@ msgid "" "`mapping`." msgstr "" -#: ../../library/collections.abc.rst:27 +#: ../../library/collections.abc.rst:24 msgid "" "An :func:`issubclass` or :func:`isinstance` test for an interface works in " "one of three ways." msgstr "" -#: ../../library/collections.abc.rst:30 +#: ../../library/collections.abc.rst:27 msgid "" "A newly written class can inherit directly from one of the abstract base " "classes. The class must supply the required abstract methods. The " @@ -51,7 +51,7 @@ msgid "" "desired. Other methods may be added as needed:" msgstr "" -#: ../../library/collections.abc.rst:35 +#: ../../library/collections.abc.rst:32 msgid "" "class C(Sequence): # Direct inheritance\n" " def __init__(self): ... # Extra method not required by the " @@ -61,7 +61,7 @@ msgid "" " def count(self, value): ... # Optionally override a mixin method" msgstr "" -#: ../../library/collections.abc.rst:43 +#: ../../library/collections.abc.rst:40 msgid "" ">>> issubclass(C, Sequence)\n" "True\n" @@ -73,7 +73,7 @@ msgstr "" ">>> isinstance(C(), Sequence)\n" "True" -#: ../../library/collections.abc.rst:50 +#: ../../library/collections.abc.rst:47 msgid "" "Existing classes and built-in classes can be registered as \"virtual " "subclasses\" of the ABCs. Those classes should define the full API " @@ -83,7 +83,7 @@ msgid "" "rule is for methods that are automatically inferred from the rest of the API:" msgstr "" -#: ../../library/collections.abc.rst:58 +#: ../../library/collections.abc.rst:55 msgid "" "class D: # No inheritance\n" " def __init__(self): ... # Extra method not required by the " @@ -96,7 +96,7 @@ msgid "" "Sequence.register(D) # Register instead of inherit" msgstr "" -#: ../../library/collections.abc.rst:69 +#: ../../library/collections.abc.rst:66 msgid "" ">>> issubclass(D, Sequence)\n" "True\n" @@ -108,7 +108,7 @@ msgstr "" ">>> isinstance(D(), Sequence)\n" "True" -#: ../../library/collections.abc.rst:76 +#: ../../library/collections.abc.rst:73 msgid "" "In this example, class :class:`!D` does not need to define ``__contains__``, " "``__iter__``, and ``__reversed__`` because the :ref:`in-operator " @@ -117,13 +117,13 @@ msgid "" "``__len__``." msgstr "" -#: ../../library/collections.abc.rst:82 +#: ../../library/collections.abc.rst:79 msgid "" "Some simple interfaces are directly recognizable by the presence of the " "required methods (unless those methods have been set to :const:`None`):" msgstr "" -#: ../../library/collections.abc.rst:85 +#: ../../library/collections.abc.rst:82 msgid "" "class E:\n" " def __iter__(self): ...\n" @@ -133,7 +133,7 @@ msgstr "" " def __iter__(self): ...\n" " def __next__(self): ..." -#: ../../library/collections.abc.rst:91 +#: ../../library/collections.abc.rst:88 msgid "" ">>> issubclass(E, Iterable)\n" "True\n" @@ -145,7 +145,7 @@ msgstr "" ">>> isinstance(E(), Iterable)\n" "True" -#: ../../library/collections.abc.rst:98 +#: ../../library/collections.abc.rst:95 msgid "" "Complex interfaces do not support this last technique because an interface " "is more than just the presence of method names. Interfaces specify " @@ -155,156 +155,156 @@ msgid "" "insufficient for distinguishing a :class:`Sequence` from a :class:`Mapping`." msgstr "" -#: ../../library/collections.abc.rst:106 +#: ../../library/collections.abc.rst:103 msgid "" "These abstract classes now support ``[]``. See :ref:`types-genericalias` " "and :pep:`585`." msgstr "" -#: ../../library/collections.abc.rst:113 +#: ../../library/collections.abc.rst:110 msgid "Collections Abstract Base Classes" msgstr "" -#: ../../library/collections.abc.rst:115 +#: ../../library/collections.abc.rst:112 msgid "" "The collections module offers the following :term:`ABCs `:" msgstr "" -#: ../../library/collections.abc.rst:120 +#: ../../library/collections.abc.rst:117 msgid "ABC" msgstr "ABC" -#: ../../library/collections.abc.rst:120 +#: ../../library/collections.abc.rst:117 msgid "Inherits from" msgstr "" -#: ../../library/collections.abc.rst:120 +#: ../../library/collections.abc.rst:117 msgid "Abstract Methods" msgstr "抽象方法" -#: ../../library/collections.abc.rst:120 +#: ../../library/collections.abc.rst:117 msgid "Mixin Methods" msgstr "" -#: ../../library/collections.abc.rst:122 +#: ../../library/collections.abc.rst:119 msgid ":class:`Container` [1]_" msgstr ":class:`Container` [1]_" -#: ../../library/collections.abc.rst:122 +#: ../../library/collections.abc.rst:119 msgid "``__contains__``" msgstr "``__contains__``" -#: ../../library/collections.abc.rst:123 +#: ../../library/collections.abc.rst:120 msgid ":class:`Hashable` [1]_" msgstr ":class:`Hashable` [1]_" -#: ../../library/collections.abc.rst:123 +#: ../../library/collections.abc.rst:120 msgid "``__hash__``" msgstr "``__hash__``" -#: ../../library/collections.abc.rst:124 +#: ../../library/collections.abc.rst:121 msgid ":class:`Iterable` [1]_ [2]_" msgstr ":class:`Iterable` [1]_ [2]_" -#: ../../library/collections.abc.rst:124 ../../library/collections.abc.rst:125 +#: ../../library/collections.abc.rst:121 ../../library/collections.abc.rst:122 msgid "``__iter__``" msgstr "``__iter__``" -#: ../../library/collections.abc.rst:125 +#: ../../library/collections.abc.rst:122 msgid ":class:`Iterator` [1]_" msgstr ":class:`Iterator` [1]_" -#: ../../library/collections.abc.rst:125 ../../library/collections.abc.rst:126 +#: ../../library/collections.abc.rst:122 ../../library/collections.abc.rst:123 msgid ":class:`Iterable`" msgstr ":class:`Iterable`" -#: ../../library/collections.abc.rst:125 +#: ../../library/collections.abc.rst:122 msgid "``__next__``" msgstr "``__next__``" -#: ../../library/collections.abc.rst:126 +#: ../../library/collections.abc.rst:123 msgid ":class:`Reversible` [1]_" msgstr ":class:`Reversible` [1]_" -#: ../../library/collections.abc.rst:126 +#: ../../library/collections.abc.rst:123 msgid "``__reversed__``" msgstr "``__reversed__``" -#: ../../library/collections.abc.rst:127 +#: ../../library/collections.abc.rst:124 msgid ":class:`Generator` [1]_" msgstr ":class:`Generator` [1]_" -#: ../../library/collections.abc.rst:127 +#: ../../library/collections.abc.rst:124 msgid ":class:`Iterator`" msgstr ":class:`Iterator`" -#: ../../library/collections.abc.rst:127 ../../library/collections.abc.rst:176 +#: ../../library/collections.abc.rst:124 ../../library/collections.abc.rst:173 msgid "``send``, ``throw``" msgstr "``send``、``throw``" -#: ../../library/collections.abc.rst:127 +#: ../../library/collections.abc.rst:124 msgid "``close``, ``__iter__``, ``__next__``" msgstr "``close``、``__iter__``、``__next__``" -#: ../../library/collections.abc.rst:128 +#: ../../library/collections.abc.rst:125 msgid ":class:`Sized` [1]_" msgstr ":class:`Sized` [1]_" -#: ../../library/collections.abc.rst:128 +#: ../../library/collections.abc.rst:125 msgid "``__len__``" msgstr "``__len__``" -#: ../../library/collections.abc.rst:129 +#: ../../library/collections.abc.rst:126 msgid ":class:`Callable` [1]_" msgstr ":class:`Callable` [1]_" -#: ../../library/collections.abc.rst:129 +#: ../../library/collections.abc.rst:126 msgid "``__call__``" msgstr "``__call__``" -#: ../../library/collections.abc.rst:130 +#: ../../library/collections.abc.rst:127 msgid ":class:`Collection` [1]_" msgstr ":class:`Collection` [1]_" -#: ../../library/collections.abc.rst:130 +#: ../../library/collections.abc.rst:127 msgid ":class:`Sized`, :class:`Iterable`, :class:`Container`" msgstr ":class:`Sized`、:class:`Iterable`、:class:`Container`" -#: ../../library/collections.abc.rst:130 ../../library/collections.abc.rst:146 +#: ../../library/collections.abc.rst:127 ../../library/collections.abc.rst:143 msgid "``__contains__``, ``__iter__``, ``__len__``" msgstr "``__contains__``、``__iter__``、``__len__``" -#: ../../library/collections.abc.rst:134 ../../library/collections.abc.rst:137 -#: ../../library/collections.abc.rst:143 +#: ../../library/collections.abc.rst:131 ../../library/collections.abc.rst:134 +#: ../../library/collections.abc.rst:140 msgid ":class:`Sequence`" msgstr ":class:`Sequence`" -#: ../../library/collections.abc.rst:134 +#: ../../library/collections.abc.rst:131 msgid ":class:`Reversible`, :class:`Collection`" msgstr ":class:`Reversible`, :class:`Collection`" -#: ../../library/collections.abc.rst:134 ../../library/collections.abc.rst:143 +#: ../../library/collections.abc.rst:131 ../../library/collections.abc.rst:140 msgid "``__getitem__``, ``__len__``" msgstr "``__getitem__``、``__len__``" -#: ../../library/collections.abc.rst:134 +#: ../../library/collections.abc.rst:131 msgid "" "``__contains__``, ``__iter__``, ``__reversed__``, ``index``, and ``count``" msgstr "" "``__contains__``、``__iter__``、``__reversed__``、``index`` 和 ``count``" -#: ../../library/collections.abc.rst:137 +#: ../../library/collections.abc.rst:134 msgid ":class:`MutableSequence`" msgstr ":class:`MutableSequence`" -#: ../../library/collections.abc.rst:137 +#: ../../library/collections.abc.rst:134 msgid "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__len__``, ``insert``" msgstr "" "``__getitem__``、``__setitem__``、``__delitem__``、``__len__``、``insert``" -#: ../../library/collections.abc.rst:137 +#: ../../library/collections.abc.rst:134 msgid "" "Inherited :class:`Sequence` methods and ``append``, ``clear``, ``reverse``, " "``extend``, ``pop``, ``remove``, and ``__iadd__``" @@ -312,23 +312,23 @@ msgstr "" "繼承 :class:`Sequence` 方法和 ``append``、``clear``、``reverse``、" "``extend``、``pop``、``remove`` 和 ``__iadd__``" -#: ../../library/collections.abc.rst:143 +#: ../../library/collections.abc.rst:140 msgid ":class:`ByteString`" msgstr ":class:`ByteString`" -#: ../../library/collections.abc.rst:143 +#: ../../library/collections.abc.rst:140 msgid "Inherited :class:`Sequence` methods" msgstr ":class:`Sequence` 的繼承方法" -#: ../../library/collections.abc.rst:146 ../../library/collections.abc.rst:151 +#: ../../library/collections.abc.rst:143 ../../library/collections.abc.rst:148 msgid ":class:`Set`" msgstr ":class:`Set`" -#: ../../library/collections.abc.rst:146 ../../library/collections.abc.rst:157 +#: ../../library/collections.abc.rst:143 ../../library/collections.abc.rst:154 msgid ":class:`Collection`" msgstr ":class:`Collection`" -#: ../../library/collections.abc.rst:146 +#: ../../library/collections.abc.rst:143 msgid "" "``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, ``__gt__``, ``__ge__``, " "``__and__``, ``__or__``, ``__sub__``, ``__rsub__``, ``__xor__``, " @@ -338,29 +338,29 @@ msgstr "" "``__and__``、``__or__``、``__sub__``、``__rsub__``、``__xor__``、" "``__rxor__`` 和 ``isdisjoint``" -#: ../../library/collections.abc.rst:151 +#: ../../library/collections.abc.rst:148 msgid ":class:`MutableSet`" msgstr ":class:`MutableSet`" -#: ../../library/collections.abc.rst:151 +#: ../../library/collections.abc.rst:148 msgid "``__contains__``, ``__iter__``, ``__len__``, ``add``, ``discard``" msgstr "``__contains__``、``__iter__``、``__len__``、``add``、``discard``" -#: ../../library/collections.abc.rst:151 +#: ../../library/collections.abc.rst:148 msgid "" "Inherited :class:`Set` methods and ``clear``, ``pop``, ``remove``, " "``__ior__``, ``__iand__``, ``__ixor__``, and ``__isub__``" msgstr "" -#: ../../library/collections.abc.rst:157 ../../library/collections.abc.rst:161 +#: ../../library/collections.abc.rst:154 ../../library/collections.abc.rst:158 msgid ":class:`Mapping`" msgstr ":class:`Mapping`" -#: ../../library/collections.abc.rst:157 +#: ../../library/collections.abc.rst:154 msgid "``__getitem__``, ``__iter__``, ``__len__``" msgstr "``__getitem__``、``__iter__``、``__len__``" -#: ../../library/collections.abc.rst:157 +#: ../../library/collections.abc.rst:154 msgid "" "``__contains__``, ``keys``, ``items``, ``values``, ``get``, ``__eq__``, and " "``__ne__``" @@ -368,128 +368,128 @@ msgstr "" "``__contains__``、``keys``、``items``、``values``、``get``、``__eq__`` 和 " "``__ne__``" -#: ../../library/collections.abc.rst:161 +#: ../../library/collections.abc.rst:158 msgid ":class:`MutableMapping`" msgstr ":class:`MutableMapping`" -#: ../../library/collections.abc.rst:161 +#: ../../library/collections.abc.rst:158 msgid "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__iter__``, ``__len__``" msgstr "" "``__getitem__``、``__setitem__``、``__delitem__``、``__iter__``、``__len__``" -#: ../../library/collections.abc.rst:161 +#: ../../library/collections.abc.rst:158 msgid "" "Inherited :class:`Mapping` methods and ``pop``, ``popitem``, ``clear``, " "``update``, and ``setdefault``" msgstr "" -#: ../../library/collections.abc.rst:168 +#: ../../library/collections.abc.rst:165 msgid ":class:`MappingView`" msgstr ":class:`MappingView`" -#: ../../library/collections.abc.rst:168 +#: ../../library/collections.abc.rst:165 msgid ":class:`Sized`" msgstr ":class:`Sized`" -#: ../../library/collections.abc.rst:168 +#: ../../library/collections.abc.rst:165 msgid "``__init__``, ``__len__`` and ``__repr__``" msgstr "``__init__``、``__len__`` 和 ``__repr__``" -#: ../../library/collections.abc.rst:169 +#: ../../library/collections.abc.rst:166 msgid ":class:`ItemsView`" msgstr ":class:`ItemsView`" -#: ../../library/collections.abc.rst:169 ../../library/collections.abc.rst:171 +#: ../../library/collections.abc.rst:166 ../../library/collections.abc.rst:168 msgid ":class:`MappingView`, :class:`Set`" msgstr ":class:`MappingView`、:class:`Set`" -#: ../../library/collections.abc.rst:169 ../../library/collections.abc.rst:171 -#: ../../library/collections.abc.rst:173 +#: ../../library/collections.abc.rst:166 ../../library/collections.abc.rst:168 +#: ../../library/collections.abc.rst:170 msgid "``__contains__``, ``__iter__``" msgstr "``__contains__``、``__iter__``" -#: ../../library/collections.abc.rst:171 +#: ../../library/collections.abc.rst:168 msgid ":class:`KeysView`" msgstr ":class:`KeysView`" -#: ../../library/collections.abc.rst:173 +#: ../../library/collections.abc.rst:170 msgid ":class:`ValuesView`" msgstr ":class:`ValuesView`" -#: ../../library/collections.abc.rst:173 +#: ../../library/collections.abc.rst:170 msgid ":class:`MappingView`, :class:`Collection`" msgstr ":class:`MappingView`、:class:`Collection`" -#: ../../library/collections.abc.rst:175 +#: ../../library/collections.abc.rst:172 msgid ":class:`Awaitable` [1]_" msgstr ":class:`Awaitable` [1]_" -#: ../../library/collections.abc.rst:175 +#: ../../library/collections.abc.rst:172 msgid "``__await__``" msgstr "``__await__``" -#: ../../library/collections.abc.rst:176 +#: ../../library/collections.abc.rst:173 msgid ":class:`Coroutine` [1]_" msgstr ":class:`Coroutine` [1]_" -#: ../../library/collections.abc.rst:176 +#: ../../library/collections.abc.rst:173 msgid ":class:`Awaitable`" msgstr ":class:`Awaitable`" -#: ../../library/collections.abc.rst:176 +#: ../../library/collections.abc.rst:173 msgid "``close``" msgstr "``close``" -#: ../../library/collections.abc.rst:177 +#: ../../library/collections.abc.rst:174 msgid ":class:`AsyncIterable` [1]_" msgstr ":class:`AsyncIterable` [1]_" -#: ../../library/collections.abc.rst:177 ../../library/collections.abc.rst:178 +#: ../../library/collections.abc.rst:174 ../../library/collections.abc.rst:175 msgid "``__aiter__``" msgstr "``__aiter__``" -#: ../../library/collections.abc.rst:178 +#: ../../library/collections.abc.rst:175 msgid ":class:`AsyncIterator` [1]_" msgstr ":class:`AsyncIterator` [1]_" -#: ../../library/collections.abc.rst:178 +#: ../../library/collections.abc.rst:175 msgid ":class:`AsyncIterable`" msgstr ":class:`AsyncIterable`" -#: ../../library/collections.abc.rst:178 +#: ../../library/collections.abc.rst:175 msgid "``__anext__``" msgstr "``__anext__``" -#: ../../library/collections.abc.rst:179 +#: ../../library/collections.abc.rst:176 msgid ":class:`AsyncGenerator` [1]_" msgstr ":class:`AsyncGenerator` [1]_" -#: ../../library/collections.abc.rst:179 +#: ../../library/collections.abc.rst:176 msgid ":class:`AsyncIterator`" msgstr ":class:`AsyncIterator`" -#: ../../library/collections.abc.rst:179 +#: ../../library/collections.abc.rst:176 msgid "``asend``, ``athrow``" msgstr "``asend``、``athrow``" -#: ../../library/collections.abc.rst:179 +#: ../../library/collections.abc.rst:176 msgid "``aclose``, ``__aiter__``, ``__anext__``" msgstr "``aclose``、``__aiter__``、``__anext__``" -#: ../../library/collections.abc.rst:180 +#: ../../library/collections.abc.rst:177 msgid ":class:`Buffer` [1]_" msgstr ":class:`Buffer` [1]_" -#: ../../library/collections.abc.rst:180 +#: ../../library/collections.abc.rst:177 msgid "``__buffer__``" msgstr "``__buffer__``" -#: ../../library/collections.abc.rst:185 +#: ../../library/collections.abc.rst:182 msgid "Footnotes" msgstr "註腳" -#: ../../library/collections.abc.rst:186 +#: ../../library/collections.abc.rst:183 msgid "" "These ABCs override :meth:`~abc.ABCMeta.__subclasshook__` to support testing " "an interface by verifying the required methods are present and have not been " @@ -497,7 +497,7 @@ msgid "" "interfaces require registration or direct subclassing." msgstr "" -#: ../../library/collections.abc.rst:192 +#: ../../library/collections.abc.rst:189 msgid "" "Checking ``isinstance(obj, Iterable)`` detects classes that are registered " "as :class:`Iterable` or that have an :meth:`~container.__iter__` method, but " @@ -506,37 +506,37 @@ msgid "" "`iterable` is to call ``iter(obj)``." msgstr "" -#: ../../library/collections.abc.rst:200 +#: ../../library/collections.abc.rst:197 msgid "Collections Abstract Base Classes -- Detailed Descriptions" msgstr "集合抽象基底類別的詳細描述" -#: ../../library/collections.abc.rst:205 +#: ../../library/collections.abc.rst:202 msgid "ABC for classes that provide the :meth:`~object.__contains__` method." msgstr "有提供 :meth:`~object.__contains__` 方法之類別的 ABC。" -#: ../../library/collections.abc.rst:209 +#: ../../library/collections.abc.rst:206 msgid "ABC for classes that provide the :meth:`~object.__hash__` method." msgstr "有提供 :meth:`~object.__hash__` 方法之類別的 ABC。" -#: ../../library/collections.abc.rst:213 +#: ../../library/collections.abc.rst:210 msgid "ABC for classes that provide the :meth:`~object.__len__` method." msgstr "有提供 :meth:`~object.__len__` 方法之類別的 ABC。" -#: ../../library/collections.abc.rst:217 +#: ../../library/collections.abc.rst:214 msgid "ABC for classes that provide the :meth:`~object.__call__` method." msgstr "有提供 :meth:`~object.__call__` 方法之類別的 ABC。" -#: ../../library/collections.abc.rst:219 +#: ../../library/collections.abc.rst:216 msgid "" "See :ref:`annotating-callables` for details on how to use :class:`!Callable` " "in type annotations." msgstr "" -#: ../../library/collections.abc.rst:224 +#: ../../library/collections.abc.rst:221 msgid "ABC for classes that provide the :meth:`~container.__iter__` method." msgstr "有提供 :meth:`~container.__iter__` 方法之類別的 ABC。" -#: ../../library/collections.abc.rst:226 +#: ../../library/collections.abc.rst:223 msgid "" "Checking ``isinstance(obj, Iterable)`` detects classes that are registered " "as :class:`Iterable` or that have an :meth:`~container.__iter__` method, but " @@ -545,11 +545,11 @@ msgid "" "`iterable` is to call ``iter(obj)``." msgstr "" -#: ../../library/collections.abc.rst:235 +#: ../../library/collections.abc.rst:232 msgid "ABC for sized iterable container classes." msgstr "" -#: ../../library/collections.abc.rst:241 +#: ../../library/collections.abc.rst:238 msgid "" "ABC for classes that provide the :meth:`~iterator.__iter__` and :meth:" "`~iterator.__next__` methods. See also the definition of :term:`iterator`." @@ -557,13 +557,13 @@ msgstr "" "有提供 :meth:`~iterator.__iter__` 和 :meth:`~iterator.__next__` 方法之類別的 " "ABC。另請參閱 :term:`iterator` 的定義。" -#: ../../library/collections.abc.rst:247 +#: ../../library/collections.abc.rst:244 msgid "" "ABC for iterable classes that also provide the :meth:`~object.__reversed__` " "method." msgstr "亦有提供 :meth:`~object.__reversed__` 方法之可疊代類別的 ABC。" -#: ../../library/collections.abc.rst:254 +#: ../../library/collections.abc.rst:251 msgid "" "ABC for :term:`generator` classes that implement the protocol defined in :" "pep:`342` that extends :term:`iterators ` with the :meth:" @@ -571,17 +571,17 @@ msgid "" "methods." msgstr "" -#: ../../library/collections.abc.rst:259 +#: ../../library/collections.abc.rst:256 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on using :class:" "`!Generator` in type annotations." msgstr "" -#: ../../library/collections.abc.rst:268 +#: ../../library/collections.abc.rst:265 msgid "ABCs for read-only and mutable :term:`sequences `." msgstr "唯讀且可變\\ :term:`序列 `\\ 的 ABC。" -#: ../../library/collections.abc.rst:270 +#: ../../library/collections.abc.rst:267 msgid "" "Implementation note: Some of the mixin methods, such as :meth:`~container." "__iter__`, :meth:`~object.__reversed__`, and :meth:`~sequence.index` make " @@ -592,30 +592,30 @@ msgid "" "mixins will have quadratic performance and will likely need to be overridden." msgstr "" -#: ../../library/collections.abc.rst:282 +#: ../../library/collections.abc.rst:279 msgid "Return first index of *value*." msgstr "回傳 *value* 的第一個索引。" -#: ../../library/collections.abc.rst:284 +#: ../../library/collections.abc.rst:281 msgid "Raises :exc:`ValueError` if the value is not present." msgstr "如果找不到該值,則引發 :exc:`ValueError`。" -#: ../../library/collections.abc.rst:286 +#: ../../library/collections.abc.rst:283 msgid "" "Supporting the *start* and *stop* arguments is optional, but recommended." msgstr "建議要支援 *start* 和 *stop* 引數,但並非必要。" -#: ../../library/collections.abc.rst:288 +#: ../../library/collections.abc.rst:285 msgid "" "The :meth:`~sequence.index` method gained support for the *stop* and *start* " "arguments." msgstr "" -#: ../../library/collections.abc.rst:292 +#: ../../library/collections.abc.rst:289 msgid "The :class:`ByteString` ABC has been deprecated." msgstr ":class:`ByteString` ABC 已被棄用。" -#: ../../library/collections.abc.rst:295 +#: ../../library/collections.abc.rst:292 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -624,7 +624,7 @@ msgid "" "memoryview``)." msgstr "" -#: ../../library/collections.abc.rst:301 +#: ../../library/collections.abc.rst:298 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -640,37 +640,37 @@ msgstr "" "其他常見的緩衝區型別如 :class:`memoryview` 也從未被理解為 :class:`!" "ByteString` 的子型別(無論是在 runtime 還是由靜態型別檢查器)。" -#: ../../library/collections.abc.rst:309 +#: ../../library/collections.abc.rst:306 msgid "See :pep:`PEP 688 <688#current-options>` for more details." msgstr "更多詳細資訊請參閱 :pep:`PEP 688 <688#current-options>`。" -#: ../../library/collections.abc.rst:314 +#: ../../library/collections.abc.rst:311 msgid "ABCs for read-only and mutable :ref:`sets `." msgstr "唯讀且可變\\ :ref:`集合 `\\ 的 ABC。" -#: ../../library/collections.abc.rst:319 +#: ../../library/collections.abc.rst:316 msgid "ABCs for read-only and mutable :term:`mappings `." msgstr "唯讀且可變\\ :term:`對映 `\\ 的 ABC。" -#: ../../library/collections.abc.rst:326 +#: ../../library/collections.abc.rst:323 msgid "" "ABCs for mapping, items, keys, and values :term:`views `." msgstr "" -#: ../../library/collections.abc.rst:330 +#: ../../library/collections.abc.rst:327 msgid "" "ABC for :term:`awaitable` objects, which can be used in :keyword:`await` " "expressions. Custom implementations must provide the :meth:`~object." "__await__` method." msgstr "" -#: ../../library/collections.abc.rst:334 +#: ../../library/collections.abc.rst:331 msgid "" ":term:`Coroutine ` objects and instances of the :class:" "`~collections.abc.Coroutine` ABC are all instances of this ABC." msgstr "" -#: ../../library/collections.abc.rst:338 +#: ../../library/collections.abc.rst:335 msgid "" "In CPython, generator-based coroutines (:term:`generators ` " "decorated with :deco:`types.coroutine`) are *awaitables*, even though they " @@ -679,7 +679,7 @@ msgid "" "to detect them." msgstr "" -#: ../../library/collections.abc.rst:348 +#: ../../library/collections.abc.rst:345 msgid "" "ABC for :term:`coroutine` compatible classes. These implement the following " "methods, defined in :ref:`coroutine-objects`: :meth:`~coroutine.send`, :meth:" @@ -688,7 +688,7 @@ msgid "" "instances are also instances of :class:`Awaitable`." msgstr "" -#: ../../library/collections.abc.rst:356 +#: ../../library/collections.abc.rst:353 msgid "" "In CPython, generator-based coroutines (:term:`generators ` " "decorated with :deco:`types.coroutine`) are *awaitables*, even though they " @@ -697,54 +697,54 @@ msgid "" "to detect them." msgstr "" -#: ../../library/collections.abc.rst:362 +#: ../../library/collections.abc.rst:359 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on using :class:" "`!Coroutine` in type annotations. The variance and order of type parameters " "correspond to those of :class:`Generator`." msgstr "" -#: ../../library/collections.abc.rst:371 +#: ../../library/collections.abc.rst:368 msgid "" "ABC for classes that provide an ``__aiter__`` method. See also the " "definition of :term:`asynchronous iterable`." msgstr "" -#: ../../library/collections.abc.rst:378 +#: ../../library/collections.abc.rst:375 msgid "" "ABC for classes that provide ``__aiter__`` and ``__anext__`` methods. See " "also the definition of :term:`asynchronous iterator`." msgstr "" -#: ../../library/collections.abc.rst:385 +#: ../../library/collections.abc.rst:382 msgid "" "ABC for :term:`asynchronous generator` classes that implement the protocol " "defined in :pep:`525` and :pep:`492`." msgstr "" -#: ../../library/collections.abc.rst:388 +#: ../../library/collections.abc.rst:385 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on using :class:" "`!AsyncGenerator` in type annotations." msgstr "" -#: ../../library/collections.abc.rst:395 +#: ../../library/collections.abc.rst:392 msgid "" "ABC for classes that provide the :meth:`~object.__buffer__` method, " "implementing the :ref:`buffer protocol `. See :pep:`688`." msgstr "" -#: ../../library/collections.abc.rst:401 +#: ../../library/collections.abc.rst:398 msgid "Examples and Recipes" msgstr "" -#: ../../library/collections.abc.rst:403 +#: ../../library/collections.abc.rst:400 msgid "" "ABCs allow us to ask classes or instances if they provide particular " "functionality, for example::" msgstr "" -#: ../../library/collections.abc.rst:406 +#: ../../library/collections.abc.rst:403 msgid "" "size = None\n" "if isinstance(myvar, collections.abc.Sized):\n" @@ -754,7 +754,7 @@ msgstr "" "if isinstance(myvar, collections.abc.Sized):\n" " size = len(myvar)" -#: ../../library/collections.abc.rst:410 +#: ../../library/collections.abc.rst:407 msgid "" "Several of the ABCs are also useful as mixins that make it easier to develop " "classes supporting container APIs. For example, to write a class supporting " @@ -764,7 +764,7 @@ msgid "" "methods such as :meth:`!__and__` and :meth:`~frozenset.isdisjoint`::" msgstr "" -#: ../../library/collections.abc.rst:417 +#: ../../library/collections.abc.rst:414 msgid "" "class ListBasedSet(collections.abc.Set):\n" " ''' Alternate set implementation favoring space over speed\n" @@ -790,11 +790,11 @@ msgid "" "automatically" msgstr "" -#: ../../library/collections.abc.rst:439 +#: ../../library/collections.abc.rst:436 msgid "Notes on using :class:`Set` and :class:`MutableSet` as a mixin:" msgstr "" -#: ../../library/collections.abc.rst:442 +#: ../../library/collections.abc.rst:439 msgid "" "Since some set operations create new sets, the default mixin methods need a " "way to create new instances from an :term:`iterable`. The class constructor " @@ -807,14 +807,14 @@ msgid "" "iterable argument." msgstr "" -#: ../../library/collections.abc.rst:453 +#: ../../library/collections.abc.rst:450 msgid "" "To override the comparisons (presumably for speed, as the semantics are " "fixed), redefine :meth:`~object.__le__` and :meth:`~object.__ge__`, then the " "other operations will automatically follow suit." msgstr "" -#: ../../library/collections.abc.rst:459 +#: ../../library/collections.abc.rst:456 msgid "" "The :class:`Set` mixin provides a :meth:`!_hash` method to compute a hash " "value for the set; however, :meth:`~object.__hash__` is not defined because " @@ -823,12 +823,12 @@ msgid "" "define ``__hash__ = Set._hash``." msgstr "" -#: ../../library/collections.abc.rst:467 +#: ../../library/collections.abc.rst:464 msgid "" "`OrderedSet recipe `_ for an " "example built on :class:`MutableSet`." msgstr "" -#: ../../library/collections.abc.rst:470 +#: ../../library/collections.abc.rst:467 msgid "For more about ABCs, see the :mod:`abc` module and :pep:`3119`." msgstr "關於 ABC 的更多資訊請見 :mod:`abc` module 和 :pep:`3119`。" diff --git a/library/collections.po b/library/collections.po index 3fb28e9006e..085b778301f 100644 --- a/library/collections.po +++ b/library/collections.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-01-22 21:42+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,11 +25,11 @@ msgstr "" msgid ":mod:`!collections` --- Container datatypes" msgstr ":mod:`!collections` --- 容器資料型別" -#: ../../library/collections.rst:10 +#: ../../library/collections.rst:7 msgid "**Source code:** :source:`Lib/collections/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/collections/__init__.py`" -#: ../../library/collections.rst:20 +#: ../../library/collections.rst:17 msgid "" "This module implements specialized container datatypes providing " "alternatives to Python's general purpose built-in containers, :class:" @@ -39,84 +39,84 @@ msgstr "" "class:`dict`\\ (字典)、:class:`list`\\ (串列)、:class:`set`\\ (集合)" "和 :class:`tuple`\\ (元組)。" -#: ../../library/collections.rst:25 +#: ../../library/collections.rst:22 msgid ":func:`namedtuple`" msgstr ":func:`namedtuple`" -#: ../../library/collections.rst:25 +#: ../../library/collections.rst:22 msgid "factory function for creating tuple subclasses with named fields" msgstr "用來建立具名欄位的 tuple 子類別的工廠函式" -#: ../../library/collections.rst:26 +#: ../../library/collections.rst:23 msgid ":class:`deque`" msgstr ":class:`deque`" -#: ../../library/collections.rst:26 +#: ../../library/collections.rst:23 msgid "list-like container with fast appends and pops on either end" msgstr "" "一個類似 list 的容器,可以快速的在頭尾加入 (append) 元素與移除 (pop) 元素" -#: ../../library/collections.rst:27 +#: ../../library/collections.rst:24 msgid ":class:`ChainMap`" msgstr ":class:`ChainMap`" -#: ../../library/collections.rst:27 +#: ../../library/collections.rst:24 msgid "dict-like class for creating a single view of multiple mappings" msgstr "一個類似 dict 的類別,用來為多個對映 (mapping) 建立單一的視圖 (view)" -#: ../../library/collections.rst:28 +#: ../../library/collections.rst:25 msgid ":class:`Counter`" msgstr ":class:`Counter`" -#: ../../library/collections.rst:28 +#: ../../library/collections.rst:25 msgid "dict subclass for counting :term:`hashable` objects" msgstr "dict 的子類別,用來計算\\ :term:`可雜湊 `\\ 物件的數量" -#: ../../library/collections.rst:29 +#: ../../library/collections.rst:26 msgid ":class:`OrderedDict`" msgstr ":class:`OrderedDict`" -#: ../../library/collections.rst:29 +#: ../../library/collections.rst:26 msgid "dict subclass that remembers the order entries were added" msgstr "dict 的子類別,會記錄物件被加入的順序" -#: ../../library/collections.rst:30 +#: ../../library/collections.rst:27 msgid ":class:`defaultdict`" msgstr ":class:`defaultdict`" -#: ../../library/collections.rst:30 +#: ../../library/collections.rst:27 msgid "dict subclass that calls a factory function to supply missing values" msgstr "dict 的子類別,當值不存在 dict 中時會呼叫一個提供預設值的工廠函式" -#: ../../library/collections.rst:31 +#: ../../library/collections.rst:28 msgid ":class:`UserDict`" msgstr ":class:`UserDict`" -#: ../../library/collections.rst:31 +#: ../../library/collections.rst:28 msgid "wrapper around dictionary objects for easier dict subclassing" msgstr "dict 物件的包裝器 (wrapper),簡化了 dict 的子類別化過程" -#: ../../library/collections.rst:32 +#: ../../library/collections.rst:29 msgid ":class:`UserList`" msgstr ":class:`UserList`" -#: ../../library/collections.rst:32 +#: ../../library/collections.rst:29 msgid "wrapper around list objects for easier list subclassing" msgstr "list 物件的包裝器,簡化了 list 的子類別化過程" -#: ../../library/collections.rst:33 +#: ../../library/collections.rst:30 msgid ":class:`UserString`" msgstr ":class:`UserString`" -#: ../../library/collections.rst:33 +#: ../../library/collections.rst:30 msgid "wrapper around string objects for easier string subclassing" msgstr "字串物件的包裝器,簡化了字串的子類別化過程" -#: ../../library/collections.rst:38 +#: ../../library/collections.rst:35 msgid ":class:`ChainMap` objects" msgstr ":class:`ChainMap` 物件" -#: ../../library/collections.rst:42 +#: ../../library/collections.rst:39 msgid "" "A :class:`ChainMap` class is provided for quickly linking a number of " "mappings so they can be treated as a single unit. It is often much faster " @@ -127,14 +127,14 @@ msgstr "" "可以被當作一個單元來處理。它通常會比建立一個新的字典並多次呼叫 :meth:`~dict." "update` 來得更快。" -#: ../../library/collections.rst:46 +#: ../../library/collections.rst:43 msgid "" "The class can be used to simulate nested scopes and is useful in templating." msgstr "" "這個類別可用於模擬巢狀作用域 (nested scopes),且在模板化 (templating) 時能派" "上用場。" -#: ../../library/collections.rst:50 +#: ../../library/collections.rst:47 msgid "" "A :class:`ChainMap` groups multiple dicts or other mappings together to " "create a single, updateable view. If no *maps* are specified, a single " @@ -145,7 +145,7 @@ msgstr "" "的視圖。如果沒有指定 *maps*,預設會提供一個空字典讓每個新鏈結都至少有一個對" "映。" -#: ../../library/collections.rst:54 +#: ../../library/collections.rst:51 msgid "" "The underlying mappings are stored in a list. That list is public and can " "be accessed or updated using the *maps* attribute. There is no other state." @@ -153,7 +153,7 @@ msgstr "" "底層的對映儲存於一個 list 中,這個 list 是公開的且可透過 *maps* 屬性存取或更" "新,沒有其他狀態 (state)。" -#: ../../library/collections.rst:57 +#: ../../library/collections.rst:54 msgid "" "Lookups search the underlying mappings successively until a key is found. " "In contrast, writes, updates, and deletions only operate on the first " @@ -162,7 +162,7 @@ msgstr "" "檢索 (lookup) 陸續查詢底層對映,直到鍵被找到,然而讀取、更新和刪除就只會對第" "一個對映操作。" -#: ../../library/collections.rst:60 +#: ../../library/collections.rst:57 msgid "" "A :class:`ChainMap` incorporates the underlying mappings by reference. So, " "if one of the underlying mappings gets updated, those changes will be " @@ -171,7 +171,7 @@ msgstr "" ":class:`ChainMap` 透過參照將底層對映合併,所以當一個底層對映被更新,這些改變" "也會反映到 :class:`ChainMap`。" -#: ../../library/collections.rst:64 +#: ../../library/collections.rst:61 msgid "" "All of the usual dictionary methods are supported. In addition, there is a " "*maps* attribute, a method for creating new subcontexts, and a property for " @@ -181,7 +181,7 @@ msgstr "" "子上下文 (subcontext) 的方法、和一個能夠存取除了第一個以外其他所有對映的特性 " "(property):" -#: ../../library/collections.rst:70 +#: ../../library/collections.rst:67 msgid "" "A user updateable list of mappings. The list is ordered from first-searched " "to last-searched. It is the only stored state and can be modified to change " @@ -191,7 +191,7 @@ msgstr "" "一個可被更新的對映列表,這個列表是按照被搜尋的順序來排列,在 ChainMap 中它是" "唯一被儲存的狀態,可被修改來變換搜尋順序。回傳的列表都至少包含一個對映。" -#: ../../library/collections.rst:77 +#: ../../library/collections.rst:74 msgid "" "Returns a new :class:`ChainMap` containing a new map followed by all of the " "maps in the current instance. If ``m`` is specified, it becomes the new map " @@ -206,15 +206,15 @@ msgstr "" "個空 dict,如此一來呼叫 ``d.new_child()`` 就等同於 ``ChainMap({}, *d." "maps)``。這個方法用於建立子上下文,而保持父對映的不變。" -#: ../../library/collections.rst:86 +#: ../../library/collections.rst:83 msgid "The optional ``m`` parameter was added." msgstr "加入可選參數 ``m``。" -#: ../../library/collections.rst:89 +#: ../../library/collections.rst:86 msgid "Keyword arguments support was added." msgstr "增加了對關鍵字引數的支援。" -#: ../../library/collections.rst:94 +#: ../../library/collections.rst:91 msgid "" "Property returning a new :class:`ChainMap` containing all of the maps in the " "current instance except the first one. This is useful for skipping the " @@ -228,13 +228,13 @@ msgstr "" "scope>`\\ 當中使用 :keyword:`nonlocal` 關鍵字,也可與內建函式 :func:`super` " "做類比。引用 ``d.parents`` 等同於 ``ChainMap(*d.maps[1:])``。" -#: ../../library/collections.rst:102 +#: ../../library/collections.rst:99 msgid "" "Note, the iteration order of a :class:`ChainMap` is determined by scanning " "the mappings last to first::" msgstr "注意,一個 :class:`ChainMap` 的疊代順序是透過由後往前掃描對映而定: ::" -#: ../../library/collections.rst:105 +#: ../../library/collections.rst:102 msgid "" ">>> baseline = {'music': 'bach', 'art': 'rembrandt'}\n" ">>> adjustments = {'art': 'van gogh', 'opera': 'carmen'}\n" @@ -246,13 +246,13 @@ msgstr "" ">>> list(ChainMap(adjustments, baseline))\n" "['music', 'art', 'opera']" -#: ../../library/collections.rst:110 +#: ../../library/collections.rst:107 msgid "" "This gives the same ordering as a series of :meth:`dict.update` calls " "starting with the last mapping::" msgstr "這和呼叫 :meth:`dict.update` 結果的順序一樣是從最後一個對映開始: ::" -#: ../../library/collections.rst:113 +#: ../../library/collections.rst:110 msgid "" ">>> combined = baseline.copy()\n" ">>> combined.update(adjustments)\n" @@ -264,11 +264,11 @@ msgstr "" ">>> list(combined)\n" "['music', 'art', 'opera']" -#: ../../library/collections.rst:118 +#: ../../library/collections.rst:115 msgid "Added support for ``|`` and ``|=`` operators, specified in :pep:`584`." msgstr "支援 ``|`` 和 ``|=`` 運算子,詳見 :pep:`584`。" -#: ../../library/collections.rst:123 +#: ../../library/collections.rst:120 msgid "" "The `MultiContext class `_ in the Enthought `CodeTools package " @@ -279,7 +279,7 @@ msgstr "" "`MultiContext class `_ 支援在鏈中選定任意對映寫入。" -#: ../../library/collections.rst:129 +#: ../../library/collections.rst:126 msgid "" "Django's `Context class `_ for templating is a read-only chain of mappings. It " @@ -292,7 +292,7 @@ msgstr "" "(pop) 上下文的功能,與 :meth:`~collections.ChainMap.new_child` 方法和 :attr:" "`~collections.ChainMap.parents` 特性類似。" -#: ../../library/collections.rst:136 +#: ../../library/collections.rst:133 msgid "" "The `Nested Contexts recipe `_ has options to control " @@ -303,7 +303,7 @@ msgstr "" "contexts-a-chain-of-mapping-objects/>`_ 提供了控制是否只對鏈中第一個或其他對" "映做寫入或其他操作的選項。" -#: ../../library/collections.rst:141 +#: ../../library/collections.rst:138 msgid "" "A `greatly simplified read-only version of Chainmap `_." @@ -311,19 +311,19 @@ msgstr "" "一個\\ `極度簡化、維讀版本的 Chainmap `_。" -#: ../../library/collections.rst:146 +#: ../../library/collections.rst:143 msgid ":class:`ChainMap` Examples and Recipes" msgstr ":class:`ChainMap` 範例和用法" -#: ../../library/collections.rst:148 +#: ../../library/collections.rst:145 msgid "This section shows various approaches to working with chained maps." msgstr "此章節提供了多種操作 ChainMap 的案例。" -#: ../../library/collections.rst:151 +#: ../../library/collections.rst:148 msgid "Example of simulating Python's internal lookup chain::" msgstr "模擬 Python 內部檢索鏈結的例子: ::" -#: ../../library/collections.rst:153 +#: ../../library/collections.rst:150 msgid "" "import builtins\n" "pylookup = ChainMap(locals(), globals(), vars(builtins))" @@ -331,14 +331,14 @@ msgstr "" "import builtins\n" "pylookup = ChainMap(locals(), globals(), vars(builtins))" -#: ../../library/collections.rst:156 +#: ../../library/collections.rst:153 msgid "" "Example of letting user specified command-line arguments take precedence " "over environment variables which in turn take precedence over default " "values::" msgstr "讓使用者指定的命令列引數優先於環境變數、再優先於預設值的範例: ::" -#: ../../library/collections.rst:159 +#: ../../library/collections.rst:156 msgid "" "import os, argparse\n" "\n" @@ -370,13 +370,13 @@ msgstr "" "print(combined['color'])\n" "print(combined['user'])" -#: ../../library/collections.rst:173 +#: ../../library/collections.rst:170 msgid "" "Example patterns for using the :class:`ChainMap` class to simulate nested " "contexts::" msgstr "用 :class:`ChainMap` 類別模擬巢狀上下文的範例模式: ::" -#: ../../library/collections.rst:176 +#: ../../library/collections.rst:173 msgid "" "c = ChainMap() # Create root context\n" "d = c.new_child() # Create nested child context\n" @@ -396,7 +396,7 @@ msgid "" "dict(d) # Flatten into a regular dictionary" msgstr "" -#: ../../library/collections.rst:192 +#: ../../library/collections.rst:189 msgid "" "The :class:`ChainMap` class only makes updates (writes and deletions) to the " "first mapping in the chain while lookups will search the full chain. " @@ -406,7 +406,7 @@ msgstr "" ":class:`ChainMap` 類別只對鏈結中第一個對映來做寫入或刪除,但檢索則會掃過整個" "鏈結。但如果需要對更深層的鍵寫入或刪除,透過定義一個子類別來實作也不困難: ::" -#: ../../library/collections.rst:197 +#: ../../library/collections.rst:194 msgid "" "class DeepChainMap(ChainMap):\n" " 'Variant of ChainMap that allows direct updates to inner scopes'\n" @@ -434,17 +434,17 @@ msgid "" "DeepChainMap({'zebra': 'black', 'snake': 'red'}, {}, {'lion': 'orange'})" msgstr "" -#: ../../library/collections.rst:223 +#: ../../library/collections.rst:220 msgid ":class:`Counter` objects" msgstr ":class:`Counter` 物件" -#: ../../library/collections.rst:225 +#: ../../library/collections.rst:222 msgid "" "A counter tool is provided to support convenient and rapid tallies. For " "example::" msgstr "提供一個支援方便且快速計數的計數器工具,例如: ::" -#: ../../library/collections.rst:228 +#: ../../library/collections.rst:225 msgid "" ">>> # Tally occurrences of words in a list\n" ">>> cnt = Counter()\n" @@ -462,7 +462,7 @@ msgid "" " ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]" msgstr "" -#: ../../library/collections.rst:247 +#: ../../library/collections.rst:244 msgid "" "A :class:`Counter` is a :class:`dict` subclass for counting :term:`hashable` " "objects. It is a collection where elements are stored as dictionary keys and " @@ -475,7 +475,7 @@ msgstr "" "計數可以是包含 0 與負數的任何整數值。:class:`Counter` 類別類似其他程式語言中" "的 bags 或 multisets。" -#: ../../library/collections.rst:253 +#: ../../library/collections.rst:250 msgid "" "Elements are counted from an *iterable* or initialized from another " "*mapping* (or counter):" @@ -483,7 +483,7 @@ msgstr "" "被計數的元素來自一個 *iterable* 或是被其他的 *mapping*\\ (或 Counter)初始" "化:" -#: ../../library/collections.rst:261 +#: ../../library/collections.rst:258 msgid "" "Counter objects have a dictionary interface except that they return a zero " "count for missing items instead of raising a :exc:`KeyError`:" @@ -491,7 +491,7 @@ msgstr "" "Counter 物件擁有一個字典的使用介面,除了遇到 Counter 中沒有的值時會回傳計數 " "0 取代 :exc:`KeyError` 這點不同:" -#: ../../library/collections.rst:268 +#: ../../library/collections.rst:265 msgid "" "Setting a count to zero does not remove an element from a counter. Use " "``del`` to remove it entirely:" @@ -499,7 +499,7 @@ msgstr "" "將一個值的計數設為 0 並不會真的從 Counter 中刪除這個元素,要使用 ``del`` 來將" "其刪除:" -#: ../../library/collections.rst:276 +#: ../../library/collections.rst:273 msgid "" "As a :class:`dict` subclass, :class:`Counter` inherited the capability to " "remember insertion order. Math operations on *Counter* objects also " @@ -511,13 +511,13 @@ msgstr "" "*Counter* 做數學運算後同樣保留順序性,其結果是依照各個元素在運算元左邊出現的" "時間先後、再按照運算元右邊出現的時間先後來排列。" -#: ../../library/collections.rst:282 +#: ../../library/collections.rst:279 msgid "" "Counter objects support additional methods beyond those available for all " "dictionaries:" msgstr "除了字典原本就有的方法外,Counter 物件額外支援數個新方法:" -#: ../../library/collections.rst:287 +#: ../../library/collections.rst:284 msgid "" "Return an iterator over elements repeating each as many times as its count. " "Elements are returned in the order first encountered. If an element's count " @@ -527,7 +527,7 @@ msgstr "" "依照各元素首次出現的時間先後。如果元素的出現次數小於 1,:meth:`elements` 方法" "會忽略這些元素。" -#: ../../library/collections.rst:297 +#: ../../library/collections.rst:294 msgid "" "Return a list of the *n* most common elements and their counts from the most " "common to the least. If *n* is omitted or ``None``, :meth:`most_common` " @@ -538,7 +538,7 @@ msgstr "" "如果 *n* 被省略或者為 ``None``,:meth:`most_common` 會回傳\\ *所有* counter " "中的元素。出現次數相同的元素會按照首次出現的時間先後來排列:" -#: ../../library/collections.rst:309 +#: ../../library/collections.rst:306 msgid "" "Elements are subtracted from an *iterable* or from another *mapping* (or " "counter). Like :meth:`dict.update` but subtracts counts instead of " @@ -548,23 +548,23 @@ msgstr "" "似 :meth:`dict.update` 但是是為了減去計數而非取代其值。輸入和輸出都可以是 0 " "或是負數。" -#: ../../library/collections.rst:323 +#: ../../library/collections.rst:320 msgid "Compute the sum of the counts." msgstr "計算總計數值。" -#: ../../library/collections.rst:331 +#: ../../library/collections.rst:328 msgid "" "The usual dictionary methods are available for :class:`Counter` objects " -"except for two which work differently for counters." +"except for these two which work differently for counters:" msgstr "" -"通常來說字典方法也可以用於 :class:`Counter` 物件,除了以下兩個作用方式與計數" -"器不同。" +"通常來說字典方法也可以用於 :class:`Counter` 物件,除了以下兩個方法對計數器而" +"言作用方式不同:" -#: ../../library/collections.rst:336 +#: ../../library/collections.rst:333 msgid "This class method is not implemented for :class:`Counter` objects." msgstr "此類別方法沒有被實作於 :class:`Counter` 物件中。" -#: ../../library/collections.rst:342 +#: ../../library/collections.rst:339 msgid "" "Elements are counted from an *iterable* or added-in from another *mapping* " "(or counter). Like :meth:`dict.update` but adds counts instead of replacing " @@ -576,7 +576,7 @@ msgstr "" "*iterable* 需要是一串將被計算個數元素的序列,而非元素為 ``(key, value)`` 形式" "的序列。" -#: ../../library/collections.rst:347 +#: ../../library/collections.rst:344 msgid "" "Counters support rich comparison operators for equality, subset, and " "superset relationships: ``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``. All of " @@ -587,11 +587,11 @@ msgstr "" "``<``、``<=``、``>``、``>=``。這些檢測會將不存在的元素之計數值當作零,因此 " "``Counter(a=1) == Counter(a=1, b=0)`` 將回傳真值。" -#: ../../library/collections.rst:352 +#: ../../library/collections.rst:349 msgid "Rich comparison operations were added." msgstr "增加了 rich comparison 運算。" -#: ../../library/collections.rst:355 +#: ../../library/collections.rst:352 msgid "" "In equality tests, missing elements are treated as having zero counts. " "Formerly, ``Counter(a=3)`` and ``Counter(a=3, b=0)`` were considered " @@ -600,11 +600,11 @@ msgstr "" "在相等性運算中,不存在的元素之計數值會被當作零。在此之前,``Counter(a=3)`` " "和 ``Counter(a=3, b=0)`` 被視為不同。" -#: ../../library/collections.rst:360 +#: ../../library/collections.rst:357 msgid "Common patterns for working with :class:`Counter` objects::" msgstr "使用 :class:`Counter` 物件的常見使用模式: ::" -#: ../../library/collections.rst:362 +#: ../../library/collections.rst:359 msgid "" "c.total() # total of all counts\n" "c.clear() # reset all counts\n" @@ -617,23 +617,26 @@ msgid "" "+c # remove zero and negative counts" msgstr "" -#: ../../library/collections.rst:372 +#: ../../library/collections.rst:369 msgid "" "Several mathematical operations are provided for combining :class:`Counter` " "objects to produce multisets (counters that have counts greater than zero). " "Addition and subtraction combine counters by adding or subtracting the " "counts of corresponding elements. Intersection and union return the minimum " -"and maximum of corresponding counts. Equality and inclusion compare " -"corresponding counts. Each operation can accept inputs with signed counts, " -"but the output will exclude results with counts of zero or less." +"and maximum of corresponding counts. Symmetric difference returns the " +"difference between the maximum and minimum of the corresponding counts. " +"Equality and inclusion compare corresponding counts. Each operation can " +"accept inputs with signed counts, but the output will exclude results with " +"counts of zero or below." msgstr "" "為結合多個 :class:`Counter` 物件以產生 multiset(多重集合,擁有大於 0 計數元" "素的計數器),有提供了幾種數學操作。加法和減法是根據各個對應元素分別將 " -"Counter 加上和減去計數,交集和聯集分別回傳各個元素最小和最大計數,相等性與包" -"含性運算則會比較對應的計數。每一個操作都可以接受輸入帶有正負號的計數,但輸出" -"的 Counter 則會將擁有小於或等於 0 計數的元素剔除。" +"Counter 加上和減去計數,交集和聯集分別回傳各個元素最小和最大計數,對稱差集回" +"傳對應計數之最大值與最小值的差,相等性與包含性運算則會比較對應的計數。每一個" +"操作都可以接受輸入帶有正負號的計數,但輸出的 Counter 則會將擁有小於或等於 0 " +"計數的元素剔除。" -#: ../../library/collections.rst:380 +#: ../../library/collections.rst:379 msgid "" ">>> c = Counter(a=3, b=1)\n" ">>> d = Counter(a=1, b=2)\n" @@ -645,24 +648,47 @@ msgid "" "Counter({'a': 1, 'b': 1})\n" ">>> c | d # union: max(c[x], d[x])\n" "Counter({'a': 3, 'b': 2})\n" +">>> c ^ d # max(c[x], d[x]) - min(c[x], d[x])\n" +"Counter({'a': 2, 'b': 1})\n" ">>> c == d # equality: c[x] == d[x]\n" "False\n" ">>> c <= d # inclusion: c[x] <= d[x]\n" "False" msgstr "" +">>> c = Counter(a=3, b=1)\n" +">>> d = Counter(a=1, b=2)\n" +">>> c + d # 將兩個計數器相加:c[x] + d[x]\n" +"Counter({'a': 4, 'b': 3})\n" +">>> c - d # 相減(只保留正數計數)\n" +"Counter({'a': 2})\n" +">>> c & d # 交集:min(c[x], d[x])\n" +"Counter({'a': 1, 'b': 1})\n" +">>> c | d # 聯集:max(c[x], d[x])\n" +"Counter({'a': 3, 'b': 2})\n" +">>> c ^ d # max(c[x], d[x]) - min(c[x], d[x])\n" +"Counter({'a': 2, 'b': 1})\n" +">>> c == d # 相等:c[x] == d[x]\n" +"False\n" +">>> c <= d # 包含:c[x] <= d[x]\n" +"False" -#: ../../library/collections.rst:397 +#: ../../library/collections.rst:398 msgid "" "Unary addition and subtraction are shortcuts for adding an empty counter or " "subtracting from an empty counter." msgstr "加減法的一元運算子分別是加上空的 Counter 和從空 Counter 減去的簡寫。" -#: ../../library/collections.rst:406 +#: ../../library/collections.rst:407 msgid "" "Added support for unary plus, unary minus, and in-place multiset operations." msgstr "開始支援加減一元運算子和 multiset 的原地 (in-place) 操作。" -#: ../../library/collections.rst:411 +#: ../../library/collections.rst:410 +msgid "" +"Added support for the symmetric difference multiset operation, ``c ^ d``." +msgstr "新增對 multiset 對稱差集運算 ``c ^ d`` 的支援。" + +#: ../../library/collections.rst:415 msgid "" "Counters were primarily designed to work with positive integers to represent " "running counts; however, care was taken to not unnecessarily preclude use " @@ -673,7 +699,7 @@ msgstr "" "為負數或為其他型別的案例中,Counter 也小心地被設計成不會預先排除這些特殊元" "素。為了輔助使用於上述案例,這一小節記錄了最小範圍和型別限制。" -#: ../../library/collections.rst:416 +#: ../../library/collections.rst:420 msgid "" "The :class:`Counter` class itself is a dictionary subclass with no " "restrictions on its keys and values. The values are intended to be numbers " @@ -682,13 +708,13 @@ msgstr "" ":class:`Counter` 類別本身是字典的子類別,且不限制其鍵與值。值被用來表示計數," "但實際上你\\ *可以*\\ 儲存任何值。" -#: ../../library/collections.rst:420 +#: ../../library/collections.rst:424 msgid "" "The :meth:`~Counter.most_common` method requires only that the values be " "orderable." msgstr "使用 :meth:`~Counter.most_common` 方法的唯一條件是其值要是可被排序的。" -#: ../../library/collections.rst:422 +#: ../../library/collections.rst:426 msgid "" "For in-place operations such as ``c[key] += 1``, the value type need only " "support addition and subtraction. So fractions, floats, and decimals would " @@ -700,7 +726,7 @@ msgstr "" "數、十進位數與其負值都可以使用。同理,:meth:`~Counter.update` 和 :meth:" "`~Counter.subtract` 也都允許 0 或負值為輸入或輸出。" -#: ../../library/collections.rst:428 +#: ../../library/collections.rst:432 msgid "" "The multiset methods are designed only for use cases with positive values. " "The inputs may be negative or zero, but only outputs with positive values " @@ -710,13 +736,13 @@ msgstr "" "Multiset 相關方法只為了處理正值而設計,其輸入允許是 0 或負值但只有正值會被輸" "出。並無型別限制,但其值的型別須支援加、減及比較運算。" -#: ../../library/collections.rst:433 +#: ../../library/collections.rst:437 msgid "" "The :meth:`~Counter.elements` method requires integer counts. It ignores " "zero and negative counts." msgstr ":meth:`~Counter.elements` 方法需要其計數為正值,如為 0 或負值則忽略。" -#: ../../library/collections.rst:438 +#: ../../library/collections.rst:442 msgid "" "`Bag class `_ in Smalltalk." @@ -724,13 +750,13 @@ msgstr "" "Smalltalk 中的 `Bag class `_。" -#: ../../library/collections.rst:441 +#: ../../library/collections.rst:445 msgid "" "Wikipedia entry for `Multisets `_." msgstr "" "維基百科上的\\ `多重集合 `_\\ 條目。" -#: ../../library/collections.rst:443 +#: ../../library/collections.rst:447 msgid "" "`C++ multisets `_ tutorial with examples." @@ -738,7 +764,7 @@ msgstr "" "`C++ multisets `_ 教學與範例。" -#: ../../library/collections.rst:446 +#: ../../library/collections.rst:450 msgid "" "For mathematical operations on multisets and their use cases, see *Knuth, " "Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise " @@ -747,7 +773,7 @@ msgstr "" "Multiset 的數學運算及其使用時機,參考 *Knuth, Donald. The Art of Computer " "Programming Volume II, Section 4.6.3, Exercise 19*。" -#: ../../library/collections.rst:450 +#: ../../library/collections.rst:454 msgid "" "To enumerate all distinct multisets of a given size over a given set of " "elements, see :func:`itertools.combinations_with_replacement`::" @@ -755,17 +781,17 @@ msgstr "" "若要根據給定的元素集合來列舉出所有不重複且擁有指定元素數量的 multiset,請見 :" "func:`itertools.combinations_with_replacement`: ::" -#: ../../library/collections.rst:453 +#: ../../library/collections.rst:457 msgid "" "map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC" msgstr "" "map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC" -#: ../../library/collections.rst:457 +#: ../../library/collections.rst:461 msgid ":class:`deque` objects" msgstr ":class:`deque` 物件" -#: ../../library/collections.rst:461 +#: ../../library/collections.rst:465 msgid "" "Returns a new deque object initialized left-to-right (using :meth:`append`) " "with data from *iterable*. If *iterable* is not specified, the new deque is " @@ -775,7 +801,7 @@ msgstr "" "meth:`append`\\ )加入來做初始化。如果 *iterable* 並未給定,回傳的則是一個空" "的 deque。" -#: ../../library/collections.rst:464 +#: ../../library/collections.rst:468 msgid "" "Deques are a generalization of stacks and queues (the name is pronounced " "\"deck\" and is short for \"double-ended queue\"). Deques support thread-" @@ -786,7 +812,7 @@ msgstr "" "的一般化。deque 支援執行緒安全 (thread-safe),且能夠有效率地節省記憶體在頭和" "尾加入和移除元素,兩個方向的表現都大致為 *O*\\ (1) 複雜度。" -#: ../../library/collections.rst:469 +#: ../../library/collections.rst:473 msgid "" "Though :class:`list` objects support similar operations, they are optimized " "for fast fixed-length operations and incur *O*\\ (*n*) memory movement costs " @@ -797,7 +823,7 @@ msgstr "" "變底層資料的長度及位置的 ``pop(0)`` 和 ``insert(0, v)`` 操作,記憶體移動則為 " "*O*\\ (*n*) 複雜度。" -#: ../../library/collections.rst:475 +#: ../../library/collections.rst:479 msgid "" "If *maxlen* is not specified or is ``None``, deques may grow to an arbitrary " "length. Otherwise, the deque is bounded to the specified maximum length. " @@ -813,41 +839,41 @@ msgstr "" "Unix ``tail`` filter 類似的功能,可用於追蹤使用者在意的那些最新執行事項或數據" "源。" -#: ../../library/collections.rst:483 +#: ../../library/collections.rst:487 msgid "Deques are :ref:`generic ` over the type of their contents." msgstr "" -#: ../../library/collections.rst:486 +#: ../../library/collections.rst:490 msgid "Deque objects support the following methods:" msgstr "Deque 物件支援以下方法:" -#: ../../library/collections.rst:490 +#: ../../library/collections.rst:494 msgid "Add *item* to the right side of the deque." msgstr "將 *item* 自 deque 的右側加入。" -#: ../../library/collections.rst:495 +#: ../../library/collections.rst:499 msgid "Add *item* to the left side of the deque." msgstr "將 *item* 自 deque 的左側加入。" -#: ../../library/collections.rst:500 +#: ../../library/collections.rst:504 msgid "Remove all elements from the deque leaving it with length 0." msgstr "將所有元素從 deque 中移除,使其長度為 0。" -#: ../../library/collections.rst:505 +#: ../../library/collections.rst:509 msgid "Create a shallow copy of the deque." msgstr "建立一個 deque 的淺複製 (shallow copy)。" -#: ../../library/collections.rst:512 +#: ../../library/collections.rst:516 msgid "Count the number of deque elements equal to *value*." msgstr "計算 deque 內元素為 *value* 的個數。" -#: ../../library/collections.rst:519 +#: ../../library/collections.rst:523 msgid "" "Extend the right side of the deque by appending elements from the iterable " "argument." msgstr "將 iterable 引數加入 deque 的右側。" -#: ../../library/collections.rst:525 +#: ../../library/collections.rst:529 msgid "" "Extend the left side of the deque by appending elements from *iterable*. " "Note, the series of left appends results in reversing the order of elements " @@ -856,7 +882,7 @@ msgstr "" "將 iterable 引數加入 deque 的左側。要注意的是,加入後的元素順序和 iterable 參" "數是相反的。" -#: ../../library/collections.rst:532 +#: ../../library/collections.rst:536 msgid "" "Return the position of *value* in the deque (at or after index *start* and " "before index *stop*). Returns the first match or raises :exc:`ValueError` " @@ -865,11 +891,11 @@ msgstr "" "回傳 deque 中 *value* 的位置(或在索引 *start* 之後、索引 *stop* 之前的位" "置)。回傳第一個匹配的位置,如果沒找到就引發 :exc:`ValueError`。" -#: ../../library/collections.rst:541 +#: ../../library/collections.rst:545 msgid "Insert *value* into the deque at position *index*." msgstr "在 deque 位置 *index* 中插入 *value*。" -#: ../../library/collections.rst:543 +#: ../../library/collections.rst:547 msgid "" "If the insertion would cause a bounded deque to grow beyond *maxlen*, an :" "exc:`IndexError` is raised." @@ -877,7 +903,7 @@ msgstr "" "如果此插入操作導致 deque 超過其長度上限 *maxlen* 的話,會引發 :exc:" "`IndexError` 例外。" -#: ../../library/collections.rst:551 +#: ../../library/collections.rst:555 msgid "" "Remove and return an element from the right side of the deque. If no " "elements are present, raises an :exc:`IndexError`." @@ -885,7 +911,7 @@ msgstr "" "移除並回傳 deque 的最右側元素,若本來就沒有任何元素,則會引發 :exc:" "`IndexError`。" -#: ../../library/collections.rst:557 +#: ../../library/collections.rst:561 msgid "" "Remove and return an element from the left side of the deque. If no elements " "are present, raises an :exc:`IndexError`." @@ -893,23 +919,23 @@ msgstr "" "移除並回傳 deque 的最左側元素,若本來就沒有任何元素,則會引發 :exc:" "`IndexError`。" -#: ../../library/collections.rst:563 +#: ../../library/collections.rst:567 msgid "" "Remove the first occurrence of *value*. If not found, raises a :exc:" "`ValueError`." msgstr "移除第一個出現的 *value*,如果沒找到的話就引發一個 :exc:`ValueError`。" -#: ../../library/collections.rst:569 +#: ../../library/collections.rst:573 msgid "Reverse the elements of the deque in-place and then return ``None``." msgstr "將 deque 中的元素原地 (in-place) 倒序排列並回傳 ``None``。" -#: ../../library/collections.rst:576 +#: ../../library/collections.rst:580 msgid "" "Rotate the deque *n* steps to the right. If *n* is negative, rotate to the " "left." msgstr "將 deque 向右輪轉 *n* 步。若 *n* 為負值則向左輪轉。" -#: ../../library/collections.rst:579 +#: ../../library/collections.rst:583 msgid "" "When the deque is not empty, rotating one step to the right is equivalent to " "``d.appendleft(d.pop())``, and rotating one step to the left is equivalent " @@ -918,15 +944,15 @@ msgstr "" "當 deque 不是空的,向右輪轉一步和 ``d.appendleft(d.pop())`` 有相同意義,而向" "左輪轉亦等價於 ``d.append(d.popleft())``。" -#: ../../library/collections.rst:584 +#: ../../library/collections.rst:588 msgid "Deque objects also provide one read-only attribute:" msgstr "Deque 物件也提供了一個唯讀屬性:" -#: ../../library/collections.rst:588 +#: ../../library/collections.rst:592 msgid "Maximum size of a deque or ``None`` if unbounded." msgstr "Deque 的最大長度,如果不限制長度的話則為 ``None``。" -#: ../../library/collections.rst:593 +#: ../../library/collections.rst:597 msgid "" "In addition to the above, deques support iteration, pickling, ``len(d)``, " "``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing " @@ -941,7 +967,7 @@ msgstr "" "*O*\\ (1) 但越靠近中間則減慢至 *O*\\ (*n*)。若想要隨機而快速的存取,使用 " "list 會較為合適。" -#: ../../library/collections.rst:599 +#: ../../library/collections.rst:603 msgid "" "Starting in version 3.5, deques support ``__add__()``, ``__mul__()``, and " "``__imul__()``." @@ -949,11 +975,11 @@ msgstr "" "自從 3.5 版本起,deque 開始支援 ``__add__()``、``__mul__()`` 和 " "``__imul__()``。" -#: ../../library/collections.rst:602 +#: ../../library/collections.rst:606 msgid "Example:" msgstr "範例:" -#: ../../library/collections.rst:604 +#: ../../library/collections.rst:608 msgid "" ">>> from collections import deque\n" ">>> d = deque('ghi') # make a new deque with three items\n" @@ -1009,21 +1035,21 @@ msgid "" "deque(['c', 'b', 'a'])" msgstr "" -#: ../../library/collections.rst:659 +#: ../../library/collections.rst:663 msgid ":class:`deque` Recipes" msgstr ":class:`deque` 用法" -#: ../../library/collections.rst:661 +#: ../../library/collections.rst:665 msgid "This section shows various approaches to working with deques." msgstr "這一章節提供了多種操作 deque 的案例。" -#: ../../library/collections.rst:663 +#: ../../library/collections.rst:667 msgid "" "Bounded length deques provide functionality similar to the ``tail`` filter " "in Unix::" msgstr "被限制長度的 deque 功能類似 Unix 中的 ``tail`` filter: ::" -#: ../../library/collections.rst:666 +#: ../../library/collections.rst:670 msgid "" "def tail(filename, n=10):\n" " 'Return the last n lines of a file'\n" @@ -1035,13 +1061,13 @@ msgstr "" " with open(filename) as f:\n" " return deque(f, n)" -#: ../../library/collections.rst:671 +#: ../../library/collections.rst:675 msgid "" "Another approach to using deques is to maintain a sequence of recently added " "elements by appending to the right and popping to the left::" msgstr "另一用法是透過從右邊加入、從左邊移除來維護最近加入元素的 list: ::" -#: ../../library/collections.rst:674 +#: ../../library/collections.rst:678 msgid "" "def moving_average(iterable, n=3):\n" " # moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0\n" @@ -1056,7 +1082,7 @@ msgid "" " yield s / n" msgstr "" -#: ../../library/collections.rst:686 +#: ../../library/collections.rst:690 msgid "" "A `round-robin scheduler `_ can be implemented with input iterators stored in a :" @@ -1071,7 +1097,7 @@ msgstr "" "就用 :meth:`~deque.popleft` 將其從佇列中移除,否則利用 :meth:`~deque.rotate` " "來將其移至佇列尾端: ::" -#: ../../library/collections.rst:693 +#: ../../library/collections.rst:697 msgid "" "def roundrobin(*iterables):\n" " \"roundrobin('ABC', 'D', 'EF') --> A D E B F C\"\n" @@ -1097,7 +1123,7 @@ msgstr "" " # 移除耗盡的疊代器。\n" " iterators.popleft()" -#: ../../library/collections.rst:705 +#: ../../library/collections.rst:709 msgid "" "The :meth:`~deque.rotate` method provides a way to implement :class:`deque` " "slicing and deletion. For example, a pure Python implementation of ``del " @@ -1107,7 +1133,7 @@ msgstr "" "例來說,用純 Python 實作 ``del d[n]`` 需要用 ``rotate()`` 來定位要被移除的元" "素: ::" -#: ../../library/collections.rst:709 +#: ../../library/collections.rst:713 msgid "" "def delete_nth(d, n):\n" " d.rotate(-n)\n" @@ -1119,7 +1145,7 @@ msgstr "" " d.popleft()\n" " d.rotate(n)" -#: ../../library/collections.rst:714 +#: ../../library/collections.rst:718 msgid "" "To implement :class:`deque` slicing, use a similar approach applying :meth:" "`~deque.rotate` to bring a target element to the left side of the deque. " @@ -1134,11 +1160,11 @@ msgstr "" "就能簡單地實現 Forth 風格的 stack 操作,例如 ``dup``、``drop``、``swap``、" "``over``、``pick``、``rot`` 和 ``roll``。" -#: ../../library/collections.rst:724 +#: ../../library/collections.rst:728 msgid ":class:`defaultdict` objects" msgstr ":class:`defaultdict` 物件" -#: ../../library/collections.rst:730 +#: ../../library/collections.rst:734 msgid "" "Return a new dictionary-like object. :class:`defaultdict` is a subclass of " "the built-in :class:`dict` class. It overrides one method and adds one " @@ -1149,7 +1175,7 @@ msgstr "" "子類別。它覆蓋掉了一個方法並添加了一個可寫入的實例變數。其餘功能與 :class:" "`dict` 相同,此文件不再複述。" -#: ../../library/collections.rst:735 +#: ../../library/collections.rst:739 msgid "" "The first argument provides the initial value for the :attr:" "`default_factory` attribute; it defaults to ``None``. All remaining " @@ -1160,19 +1186,19 @@ msgstr "" "所有其他的引數(包括關鍵字引數)都會被傳遞給 :class:`dict` 的建構函式 " "(constructor)。" -#: ../../library/collections.rst:740 +#: ../../library/collections.rst:744 msgid "" ":class:`!defaultdict`\\s are :ref:`generic ` over two types, " "signifying (respectively) the types of the dictionary's keys and values." msgstr "" -#: ../../library/collections.rst:744 +#: ../../library/collections.rst:748 msgid "" ":class:`defaultdict` objects support the following method in addition to the " "standard :class:`dict` operations:" msgstr ":class:`defaultdict` 物件支援以下 :class:`dict` 所沒有的方法:" -#: ../../library/collections.rst:749 +#: ../../library/collections.rst:753 msgid "" "If the :attr:`default_factory` attribute is ``None``, this raises a :exc:" "`KeyError` exception with the *key* as argument." @@ -1180,7 +1206,7 @@ msgstr "" "如果 :attr:`default_factory` 屬性為 ``None``,呼叫此方法會引發一個附帶引數 " "*key* 的 :exc:`KeyError` 例外。" -#: ../../library/collections.rst:752 +#: ../../library/collections.rst:756 msgid "" "If :attr:`default_factory` is not ``None``, it is called without arguments " "to provide a default value for the given *key*, this value is inserted in " @@ -1190,14 +1216,14 @@ msgstr "" "*key* 提供一個預設值,這個值和 *key* 被作為鍵值對來插入到字典中,並且被此方法" "所回傳。" -#: ../../library/collections.rst:756 +#: ../../library/collections.rst:760 msgid "" "If calling :attr:`default_factory` raises an exception this exception is " "propagated unchanged." msgstr "" "如果呼叫 :attr:`default_factory` 時發生例外,則該例外將會保持不變地向外傳遞。" -#: ../../library/collections.rst:759 +#: ../../library/collections.rst:763 msgid "" "This method is called by the :meth:`~object.__getitem__` method of the :" "class:`dict` class when the requested key is not found; whatever it returns " @@ -1207,7 +1233,7 @@ msgstr "" "__getitem__` 方法呼叫。無論此方法回傳了值還是引發了例外,都會被 :meth:" "`~object.__getitem__` 所傳遞。" -#: ../../library/collections.rst:763 +#: ../../library/collections.rst:767 msgid "" "Note that :meth:`__missing__` is *not* called for any operations besides :" "meth:`~object.__getitem__`. This means that :meth:`~dict.get` will, like " @@ -1218,11 +1244,11 @@ msgstr "" "方法呼叫,這意味著 :meth:`~dict.get` 會像一般的 dict 那樣回傳 ``None`` 做為預" "設值,而非使用 :attr:`default_factory`。" -#: ../../library/collections.rst:769 +#: ../../library/collections.rst:773 msgid ":class:`defaultdict` objects support the following instance variable:" msgstr ":class:`defaultdict` 物件支援以下實例變數:" -#: ../../library/collections.rst:774 +#: ../../library/collections.rst:778 msgid "" "This attribute is used by the :meth:`~defaultdict.__missing__` method; it is " "initialized from the first argument to the constructor, if present, or to " @@ -1231,16 +1257,16 @@ msgstr "" "此屬性為 :meth:`~defaultdict.__missing__` 方法所使用。如果有引數被傳入建構函" "式,則此屬性會被初始化成第一個引數,如未提供引數則被初始化為 ``None``。" -#: ../../library/collections.rst:778 ../../library/collections.rst:1207 +#: ../../library/collections.rst:782 ../../library/collections.rst:1211 msgid "" "Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`." msgstr "新增合併 (``|``) 和更新 (``|=``) 運算子,請見 :pep:`584`。" -#: ../../library/collections.rst:784 +#: ../../library/collections.rst:788 msgid ":class:`defaultdict` Examples" msgstr ":class:`defaultdict` 範例" -#: ../../library/collections.rst:786 +#: ../../library/collections.rst:790 msgid "" "Using :class:`list` as the :attr:`~defaultdict.default_factory`, it is easy " "to group a sequence of key-value pairs into a dictionary of lists:" @@ -1248,7 +1274,7 @@ msgstr "" "使用 :class:`list` 作為 :attr:`~defaultdict.default_factory` 可以很輕鬆地將鍵" "值對序列轉換為包含 list 之字典:" -#: ../../library/collections.rst:797 +#: ../../library/collections.rst:801 msgid "" "When each key is encountered for the first time, it is not already in the " "mapping; so an entry is automatically created using the :attr:`~defaultdict." @@ -1266,7 +1292,7 @@ msgstr "" "增另一個值到 list 中。和使用與其等價的 :meth:`dict.setdefault` 相比,這個技巧" "更加快速和簡單:" -#: ../../library/collections.rst:812 +#: ../../library/collections.rst:816 msgid "" "Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the :" "class:`defaultdict` useful for counting (like a bag or multiset in other " @@ -1275,7 +1301,7 @@ msgstr "" "設定 :attr:`~defaultdict.default_factory` 為 :class:`int` 使得 :class:" "`defaultdict` 可被用於計數(類似其他語言中的 bag 或 multiset):" -#: ../../library/collections.rst:824 +#: ../../library/collections.rst:828 msgid "" "When a letter is first encountered, it is missing from the mapping, so the :" "attr:`~defaultdict.default_factory` function calls :func:`int` to supply a " @@ -1286,7 +1312,7 @@ msgstr "" "default_factory` 函式會呼叫 :func:`int` 來提供一個整數 0 作為預設值。後續的增" "加操作繼續對每個字母做計數。" -#: ../../library/collections.rst:828 +#: ../../library/collections.rst:832 msgid "" "The function :func:`int` which always returns zero is just a special case of " "constant functions. A faster and more flexible way to create constant " @@ -1296,7 +1322,7 @@ msgstr "" "函式 :func:`int` 總是回傳 0,這是常數函式的特殊情況。一個更快、更有彈性的方法" "是使用 lambda 函式來提供任何常數值(不用一定要是 0):" -#: ../../library/collections.rst:841 +#: ../../library/collections.rst:845 msgid "" "Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :" "class:`defaultdict` useful for building a dictionary of sets:" @@ -1304,11 +1330,11 @@ msgstr "" "將 :attr:`~defaultdict.default_factory` 設為 :class:`set` 使 :class:" "`defaultdict` 可用於構建一個值為 set 的字典:" -#: ../../library/collections.rst:854 +#: ../../library/collections.rst:858 msgid ":func:`namedtuple` Factory Function for Tuples with Named Fields" msgstr ":func:`namedtuple` 擁有具名欄位之 tuple 的工廠函式" -#: ../../library/collections.rst:856 +#: ../../library/collections.rst:860 msgid "" "Named tuples assign meaning to each position in a tuple and allow for more " "readable, self-documenting code. They can be used wherever regular tuples " @@ -1319,7 +1345,7 @@ msgstr "" "件性。它們可以用於任何普通 tuple 可使用的場合,賦予其透過名稱(而非位置索引)" "來存取欄位的能力。" -#: ../../library/collections.rst:862 +#: ../../library/collections.rst:866 msgid "" "Returns a new tuple subclass named *typename*. The new subclass is used to " "create tuple-like objects that have fields accessible by attribute lookup as " @@ -1334,7 +1360,7 @@ msgstr "" "和欄位名 *field_names*)和一個好用的 :meth:`~object.__repr__` 方法,可將 " "tuple 內容以 ``name=value`` 格式列出。" -#: ../../library/collections.rst:869 +#: ../../library/collections.rst:873 msgid "" "The *field_names* are a sequence of strings such as ``['x', 'y']``. " "Alternatively, *field_names* can be a single string with each fieldname " @@ -1343,7 +1369,7 @@ msgstr "" "*field_names* 是一個像 ``['x', 'y']`` 一樣的字串序列。*field_names* 也可以是" "一個用空白或逗號分隔各個欄位名稱的字串,比如 ``'x y'`` 或者 ``'x, y'``。" -#: ../../library/collections.rst:873 +#: ../../library/collections.rst:877 msgid "" "Any valid Python identifier may be used for a fieldname except for names " "starting with an underscore. Valid identifiers consist of letters, digits, " @@ -1355,7 +1381,7 @@ msgstr "" "詞 :mod:`keyword`,例如 *class*、*for*、*return*、*global*、*pass* 或 " "*raise*。" -#: ../../library/collections.rst:879 +#: ../../library/collections.rst:883 msgid "" "If *rename* is true, invalid fieldnames are automatically replaced with " "positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is " @@ -1366,7 +1392,7 @@ msgstr "" "'def', 'ghi', 'abc']`` 會被轉換成 ``['abc', '_1', 'ghi', '_3']``,移除了關鍵" "字 ``def`` 和重複欄位名 ``abc``。" -#: ../../library/collections.rst:884 +#: ../../library/collections.rst:888 msgid "" "*defaults* can be ``None`` or an :term:`iterable` of default values. Since " "fields with a default value must come after any fields without a default, " @@ -1380,7 +1406,7 @@ msgstr "" "如 fieldnames 為 ``['x', 'y', 'z']`` 且 defaults 為 ``(1, 2)``,那麼 ``x`` 就" "必須被給定一個引數,``y`` 被預設為 ``1``,``z`` 則被預設為 ``2``。" -#: ../../library/collections.rst:891 +#: ../../library/collections.rst:895 msgid "" "If *module* is defined, the :attr:`~type.__module__` attribute of the named " "tuple is set to that value." @@ -1388,7 +1414,7 @@ msgstr "" "如果 *module* 值有被定義,named tuple 的 :attr:`~type.__module__` 屬性就被設" "定為該值。" -#: ../../library/collections.rst:894 +#: ../../library/collections.rst:898 msgid "" "Named tuple instances do not have per-instance dictionaries, so they are " "lightweight and require no more memory than regular tuples." @@ -1396,17 +1422,17 @@ msgstr "" "Named tuple 實例中沒有字典,所以它們更加輕量,且和一般 tuple 相比佔用更少記憶" "體。" -#: ../../library/collections.rst:897 +#: ../../library/collections.rst:901 msgid "" "To support pickling, the named tuple class should be assigned to a variable " "that matches *typename*." msgstr "要支援 pickle,應將 named tuple 類別賦值給一個符合 *typename* 的變數。" -#: ../../library/collections.rst:900 +#: ../../library/collections.rst:904 msgid "Added support for *rename*." msgstr "新增對於 *rename* 的支援。" -#: ../../library/collections.rst:903 +#: ../../library/collections.rst:907 msgid "" "The *verbose* and *rename* parameters became :ref:`keyword-only arguments " "`." @@ -1414,21 +1440,21 @@ msgstr "" "*verbose* 和 *rename* 參數成為\\ :ref:`僅限關鍵字引數 `。" -#: ../../library/collections.rst:907 +#: ../../library/collections.rst:911 msgid "Added the *module* parameter." msgstr "新增 *module* 參數。" -#: ../../library/collections.rst:910 +#: ../../library/collections.rst:914 msgid "Removed the *verbose* parameter and the :attr:`!_source` attribute." msgstr "移除 *verbose* 參數和 :attr:`!_source` 屬性。" -#: ../../library/collections.rst:913 +#: ../../library/collections.rst:917 msgid "" "Added the *defaults* parameter and the :attr:`~somenamedtuple." "_field_defaults` attribute." msgstr "新增 *defaults* 參數和 :attr:`~somenamedtuple._field_defaults` 屬性。" -#: ../../library/collections.rst:917 +#: ../../library/collections.rst:921 msgid "" ">>> # Basic example\n" ">>> Point = namedtuple('Point', ['x', 'y'])\n" @@ -1445,7 +1471,7 @@ msgid "" "Point(x=11, y=22)" msgstr "" -#: ../../library/collections.rst:933 +#: ../../library/collections.rst:937 msgid "" "Named tuples are especially useful for assigning field names to result " "tuples returned by the :mod:`csv` or :mod:`sqlite3` modules::" @@ -1453,7 +1479,7 @@ msgstr "" "Named tuple 在賦予欄位名稱於 :mod:`csv` 或 :mod:`sqlite3` 模組回傳之 tuple 時" "相當有用: ::" -#: ../../library/collections.rst:936 +#: ../../library/collections.rst:940 msgid "" "EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, " "paygrade')\n" @@ -1487,7 +1513,7 @@ msgstr "" "for emp in map(EmployeeRecord._make, cursor.fetchall()):\n" " print(emp.name, emp.title)" -#: ../../library/collections.rst:949 +#: ../../library/collections.rst:953 msgid "" "In addition to the methods inherited from tuples, named tuples support three " "additional methods and two attributes. To prevent conflicts with field " @@ -1496,12 +1522,12 @@ msgstr "" "除了繼承自 tuple 的方法,named tuple 還支援三個額外的方法和兩個屬性。為了防止" "欄位名稱有衝突,方法和屬性的名稱以底線開頭。" -#: ../../library/collections.rst:955 +#: ../../library/collections.rst:959 msgid "" "Class method that makes a new instance from an existing sequence or iterable." msgstr "從已存在的序列或可疊代物件建立一個新實例的類別方法。" -#: ../../library/collections.rst:957 +#: ../../library/collections.rst:961 msgid "" ">>> t = [11, 22]\n" ">>> Point._make(t)\n" @@ -1511,13 +1537,13 @@ msgstr "" ">>> Point._make(t)\n" "Point(x=11, y=22)" -#: ../../library/collections.rst:965 +#: ../../library/collections.rst:969 msgid "" "Return a new :class:`dict` which maps field names to their corresponding " "values:" msgstr "回傳一個將欄位名稱對映至對應值的 :class:`dict`:" -#: ../../library/collections.rst:968 +#: ../../library/collections.rst:972 msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._asdict()\n" @@ -1527,11 +1553,11 @@ msgstr "" ">>> p._asdict()\n" "{'x': 11, 'y': 22}" -#: ../../library/collections.rst:974 +#: ../../library/collections.rst:978 msgid "Returns an :class:`OrderedDict` instead of a regular :class:`dict`." msgstr "回傳一個 :class:`OrderedDict` 而非 :class:`dict`。" -#: ../../library/collections.rst:977 +#: ../../library/collections.rst:981 msgid "" "Returns a regular :class:`dict` instead of an :class:`OrderedDict`. As of " "Python 3.7, regular dicts are guaranteed to be ordered. If the extra " @@ -1542,13 +1568,13 @@ msgstr "" "dict 已經保證有順序性,如果需要 :class:`OrderedDict` 所專屬的特性,推薦的解法" "是將結果專換成所需的類型:``OrderedDict(nt._asdict())``。" -#: ../../library/collections.rst:986 +#: ../../library/collections.rst:990 msgid "" "Return a new instance of the named tuple replacing specified fields with new " "values::" msgstr "回傳一個新的 named tuple 實例,並將指定欄位替換為新的值: ::" -#: ../../library/collections.rst:989 +#: ../../library/collections.rst:993 msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._replace(x=33)\n" @@ -1566,18 +1592,18 @@ msgstr "" "... inventory[partnum] = record._replace(price=newprices[partnum], " "timestamp=time.now())" -#: ../../library/collections.rst:996 +#: ../../library/collections.rst:1000 msgid "" "Named tuples are also supported by generic function :func:`copy.replace`." msgstr "" -#: ../../library/collections.rst:998 +#: ../../library/collections.rst:1002 msgid "" "Raise :exc:`TypeError` instead of :exc:`ValueError` for invalid keyword " "arguments." msgstr "" -#: ../../library/collections.rst:1004 +#: ../../library/collections.rst:1008 msgid "" "Tuple of strings listing the field names. Useful for introspection and for " "creating new named tuple types from existing named tuples." @@ -1585,7 +1611,7 @@ msgstr "" "列出 tuple 欄位名稱的字串,用於自我檢查或是從現有 named tuple 建立一個新的 " "named tuple 型別。" -#: ../../library/collections.rst:1007 +#: ../../library/collections.rst:1011 msgid "" ">>> p._fields # view the field names\n" "('x', 'y')\n" @@ -1603,11 +1629,11 @@ msgstr "" ">>> Pixel(11, 22, 128, 255, 0)\n" "Pixel(x=11, y=22, red=128, green=255, blue=0)" -#: ../../library/collections.rst:1019 +#: ../../library/collections.rst:1023 msgid "Dictionary mapping field names to default values." msgstr "將欄位名稱對映至預設值的字典。" -#: ../../library/collections.rst:1021 +#: ../../library/collections.rst:1025 msgid "" ">>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])\n" ">>> Account._field_defaults\n" @@ -1621,13 +1647,13 @@ msgstr "" ">>> Account('premium')\n" "Account(type='premium', balance=0)" -#: ../../library/collections.rst:1029 +#: ../../library/collections.rst:1033 msgid "" "To retrieve a field whose name is stored in a string, use the :func:" "`getattr` function:" msgstr "要取得這個名稱存於字串的欄位,要使用 :func:`getattr` 函式:" -#: ../../library/collections.rst:1035 +#: ../../library/collections.rst:1039 msgid "" "To convert a dictionary to a named tuple, use the double-star-operator (as " "described in :ref:`tut-unpacking-arguments`):" @@ -1635,7 +1661,7 @@ msgstr "" "(如\\ :ref:`tut-unpacking-arguments`\\ 所述)將一個字典轉換成 named tuple," "要使用 \\*\\* 雙星號運算子:" -#: ../../library/collections.rst:1042 +#: ../../library/collections.rst:1046 msgid "" "Since a named tuple is a regular Python class, it is easy to add or change " "functionality with a subclass. Here is how to add a calculated field and a " @@ -1644,7 +1670,7 @@ msgstr "" "因為一個 named tuple 是一個常規的 Python 類別,我們可以很容易的透過子類別來新" "增或更改功能,以下是如何新增一個計算得到的欄位和固定寬度的輸出列印格式:" -#: ../../library/collections.rst:1046 +#: ../../library/collections.rst:1050 msgid "" ">>> class Point(namedtuple('Point', ['x', 'y'])):\n" "... __slots__ = ()\n" @@ -1674,7 +1700,7 @@ msgstr "" "Point: x= 3.000 y= 4.000 hypot= 5.000\n" "Point: x=14.000 y= 0.714 hypot=14.018" -#: ../../library/collections.rst:1061 +#: ../../library/collections.rst:1065 msgid "" "The subclass shown above sets ``__slots__`` to an empty tuple. This helps " "keep memory requirements low by preventing the creation of instance " @@ -1683,7 +1709,7 @@ msgstr "" "上面的子類別將 ``__slots__`` 設定為空 tuple,這樣一來就防止了字典實例被建立," "因而保持了較低的記憶體用量。" -#: ../../library/collections.rst:1064 +#: ../../library/collections.rst:1068 msgid "" "Subclassing is not useful for adding new, stored fields. Instead, simply " "create a new named tuple type from the :attr:`~somenamedtuple._fields` " @@ -1692,17 +1718,17 @@ msgstr "" "子類別化無法用於增加新的、已被儲存的欄位,應當透過 :attr:`~somenamedtuple." "_fields` 屬性以建立一個新的 named tuple 來實現:" -#: ../../library/collections.rst:1069 +#: ../../library/collections.rst:1073 msgid "" "Docstrings can be customized by making direct assignments to the ``__doc__`` " "fields:" msgstr "透過直接賦值給 ``__doc__``,可以自訂說明文件字串:" -#: ../../library/collections.rst:1078 +#: ../../library/collections.rst:1082 msgid "Property docstrings became writeable." msgstr "文件字串屬性變成可寫入。" -#: ../../library/collections.rst:1083 +#: ../../library/collections.rst:1087 msgid "" "See :class:`typing.NamedTuple` for a way to add type hints for named " "tuples. It also provides an elegant notation using the :keyword:`class` " @@ -1711,7 +1737,7 @@ msgstr "" "關於為 named tuple 新增型別提示的方法,請參閱 :class:`typing.NamedTuple`,它" "運用 :keyword:`class` 關鍵字以提供了一個簡潔的表示法: ::" -#: ../../library/collections.rst:1087 +#: ../../library/collections.rst:1091 msgid "" "class Component(NamedTuple):\n" " part_number: int\n" @@ -1723,7 +1749,7 @@ msgstr "" " weight: float\n" " description: Optional[str] = None" -#: ../../library/collections.rst:1092 +#: ../../library/collections.rst:1096 msgid "" "See :meth:`types.SimpleNamespace` for a mutable namespace based on an " "underlying dictionary instead of a tuple." @@ -1731,7 +1757,7 @@ msgstr "" "關於以 dict 而非 tuple 為底層的可變命名空間,請參考 :meth:`types." "SimpleNamespace`。" -#: ../../library/collections.rst:1095 +#: ../../library/collections.rst:1099 msgid "" "The :mod:`dataclasses` module provides a decorator and functions for " "automatically adding generated special methods to user-defined classes." @@ -1739,11 +1765,11 @@ msgstr "" ":mod:`dataclasses` 模組提供了一個裝飾器和一些函式,用於自動將被生成的特殊方法" "新增到使用者定義的類別中。" -#: ../../library/collections.rst:1100 +#: ../../library/collections.rst:1104 msgid ":class:`OrderedDict` objects" msgstr ":class:`OrderedDict` 物件" -#: ../../library/collections.rst:1102 +#: ../../library/collections.rst:1106 msgid "" "Ordered dictionaries are just like regular dictionaries but have some extra " "capabilities relating to ordering operations. They have become less " @@ -1754,11 +1780,11 @@ msgstr "" "功能,但由於內建的 :class:`dict` 類別現在已經有記憶插入順序的能力(Python " "3.7 中確保了這種新行為),它們變得不那麼重要了。" -#: ../../library/collections.rst:1108 +#: ../../library/collections.rst:1112 msgid "Some differences from :class:`dict` still remain:" msgstr "仍存在一些與 :class:`dict` 的不同之處:" -#: ../../library/collections.rst:1110 +#: ../../library/collections.rst:1114 msgid "" "The regular :class:`dict` was designed to be very good at mapping " "operations. Tracking insertion order was secondary." @@ -1766,7 +1792,7 @@ msgstr "" "常規的 :class:`dict` 被設計成非常擅長於對映相關操作,追蹤插入的順序為次要目" "標。" -#: ../../library/collections.rst:1113 +#: ../../library/collections.rst:1117 msgid "" "The :class:`OrderedDict` was designed to be good at reordering operations. " "Space efficiency, iteration speed, and the performance of update operations " @@ -1775,7 +1801,7 @@ msgstr "" ":class:`OrderedDict` 則被設計成擅長於重新排序相關的操作,空間效率、疊代速度和" "更新操作的效能則為次要設計目標。" -#: ../../library/collections.rst:1117 +#: ../../library/collections.rst:1121 msgid "" "The :class:`OrderedDict` algorithm can handle frequent reordering operations " "better than :class:`dict`. As shown in the recipes below, this makes it " @@ -1784,12 +1810,12 @@ msgstr "" ":class:`OrderedDict` 比起 :class:`dict` 更適合處理頻繁的重新排序操作,如在下" "方用法中所示,這讓它適合用於多種 LRU cache 的實作中。" -#: ../../library/collections.rst:1121 +#: ../../library/collections.rst:1125 msgid "" "The equality operation for :class:`OrderedDict` checks for matching order." msgstr ":class:`OrderedDict` 之相等性運算會檢查順序是否相同。" -#: ../../library/collections.rst:1123 +#: ../../library/collections.rst:1127 msgid "" "A regular :class:`dict` can emulate the order sensitive equality test with " "``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``." @@ -1797,7 +1823,7 @@ msgstr "" "一個一般的 :class:`dict` 可以用 ``p == q and all(k1 == k2 for k1, k2 in " "zip(p, q))`` 來效仿有檢查順序的相等性運算。" -#: ../../library/collections.rst:1126 +#: ../../library/collections.rst:1130 msgid "" "The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a " "different signature. It accepts an optional argument to specify which item " @@ -1806,7 +1832,7 @@ msgstr "" ":class:`OrderedDict` 類別的 :meth:`~OrderedDict.popitem` 方法有不同的函式簽" "名 (signature),它接受傳入一個選擇性引數來指定要移除哪個元素。" -#: ../../library/collections.rst:1129 +#: ../../library/collections.rst:1133 msgid "" "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=True)`` " "with ``d.popitem()`` which is guaranteed to pop the rightmost (last) item." @@ -1814,7 +1840,7 @@ msgstr "" "一個一般的 :class:`dict` 可以用 ``d.popitem()`` 來效仿 OrderedDict 的 ``od." "popitem(last=True)``,這保證會移除最右邊(最後一個)的元素。" -#: ../../library/collections.rst:1132 +#: ../../library/collections.rst:1136 msgid "" "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=False)`` " "with ``(k := next(iter(d)), d.pop(k))`` which will return and remove the " @@ -1824,7 +1850,7 @@ msgstr "" "OrderedDict 的 ``od.popitem(last=False)``,若最左邊(第一個)的元素存在,則將" "其回傳並移除。" -#: ../../library/collections.rst:1136 +#: ../../library/collections.rst:1140 msgid "" ":class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to " "efficiently reposition an element to an endpoint." @@ -1832,7 +1858,7 @@ msgstr "" ":class:`OrderedDict` 有個 :meth:`~OrderedDict.move_to_end` 方法可有效率地將一" "個元素重新排列到任一端。" -#: ../../library/collections.rst:1139 +#: ../../library/collections.rst:1143 msgid "" "A regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k, " "last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its " @@ -1842,7 +1868,7 @@ msgstr "" "``od.move_to_end(k, last=True)``,這會將該鍵與其對應到的值移動至最右(最後" "面)的位置。" -#: ../../library/collections.rst:1143 +#: ../../library/collections.rst:1147 msgid "" "A regular :class:`dict` does not have an efficient equivalent for " "OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its " @@ -1852,20 +1878,20 @@ msgstr "" "last=False)`` 等價的有效方式,這是將鍵與其對應到的值移動至最左(最前面)位置" "的方法。" -#: ../../library/collections.rst:1147 +#: ../../library/collections.rst:1151 msgid "" "Until Python 3.8, :class:`dict` lacked a :meth:`~object.__reversed__` method." msgstr "" "在 Python 3.8 之前,:class:`dict` 並沒有 :meth:`~object.__reversed__` 方法。" -#: ../../library/collections.rst:1154 +#: ../../library/collections.rst:1158 msgid "" "Return an instance of a :class:`dict` subclass that has methods specialized " "for rearranging dictionary order." msgstr "" "回傳一個 :class:`dict` 子類別的實例,它具有專門用於重新排列字典順序的方法。" -#: ../../library/collections.rst:1161 +#: ../../library/collections.rst:1165 msgid "" "The :meth:`popitem` method for ordered dictionaries returns and removes a " "(key, value) pair. The pairs are returned in :abbr:`LIFO (last-in, first-" @@ -1877,7 +1903,7 @@ msgstr "" "回傳鍵值對,否則就按 :abbr:`FIFO (first-in, first-out)` 先進先出的順序回傳鍵" "值對。" -#: ../../library/collections.rst:1168 +#: ../../library/collections.rst:1172 msgid "" "Move an existing *key* to either end of an ordered dictionary. The item is " "moved to the right end if *last* is true (the default) or to the beginning " @@ -1887,7 +1913,7 @@ msgstr "" "設值)則將元素移至右端;如果 *last* 為假值則將元素移至左端。如果 *key* 不存在" "則會引發 :exc:`KeyError`:" -#: ../../library/collections.rst:1173 +#: ../../library/collections.rst:1177 msgid "" ">>> d = OrderedDict.fromkeys('abcde')\n" ">>> d.move_to_end('b')\n" @@ -1905,7 +1931,7 @@ msgstr "" ">>> ''.join(d)\n" "'bacde'" -#: ../../library/collections.rst:1185 +#: ../../library/collections.rst:1189 msgid "" "In addition to the usual mapping methods, ordered dictionaries also support " "reverse iteration using :func:`reversed`." @@ -1913,7 +1939,7 @@ msgstr "" "除了普通的對映方法,ordered dictionary 還支援了透過 :func:`reversed` 來做倒序" "疊代。" -#: ../../library/collections.rst:1190 +#: ../../library/collections.rst:1194 msgid "" "Equality tests between :class:`OrderedDict` objects are order-sensitive and " "are roughly equivalent to ``list(od1.items())==list(od2.items())``." @@ -1921,7 +1947,7 @@ msgstr "" ":class:`OrderedDict` 物件之間的相等性運算是會檢查順序是否相同的,大致等價於 " "``list(od1.items())==list(od2.items())``。" -#: ../../library/collections.rst:1193 +#: ../../library/collections.rst:1197 msgid "" "Equality tests between :class:`OrderedDict` objects and other :class:" "`~collections.abc.Mapping` objects are order-insensitive like regular " @@ -1932,7 +1958,7 @@ msgstr "" "等性運算則像普通字典一樣不考慮順序性,這使得 :class:`OrderedDict` 可於任何字" "典可使用的時機中被替換掉。" -#: ../../library/collections.rst:1198 +#: ../../library/collections.rst:1202 msgid "" "The items, keys, and values :term:`views ` of :class:" "`OrderedDict` now support reverse iteration using :func:`reversed`." @@ -1940,7 +1966,7 @@ msgstr "" ":class:`OrderedDict` 的項 (item)、鍵與值之\\ :term:`視圖 `\\ 現在可透過 :func:`reversed` 來倒序疊代。" -#: ../../library/collections.rst:1202 +#: ../../library/collections.rst:1206 msgid "" "With the acceptance of :pep:`468`, order is retained for keyword arguments " "passed to the :class:`OrderedDict` constructor and its :meth:`~dict.update` " @@ -1949,11 +1975,11 @@ msgstr "" "隨著 :pep:`468` 被核可,被傳入給 :class:`OrderedDict` 建構函式與其 :meth:" "`~dict.update` 方法的關鍵字引數之順序被保留了下來。" -#: ../../library/collections.rst:1212 +#: ../../library/collections.rst:1216 msgid ":class:`OrderedDict` Examples and Recipes" msgstr ":class:`OrderedDict` 範例與用法" -#: ../../library/collections.rst:1214 +#: ../../library/collections.rst:1218 msgid "" "It is straightforward to create an ordered dictionary variant that remembers " "the order the keys were *last* inserted. If a new entry overwrites an " @@ -1963,17 +1989,23 @@ msgstr "" "建立一個能夠記住鍵\\ *最後*\\ 插入順序的 ordered dictionary 變體很簡單。如果" "新條目覆蓋了現有條目,則原本插入位置會被更改並移動至末端: ::" -#: ../../library/collections.rst:1219 +#: ../../library/collections.rst:1223 msgid "" "class LastUpdatedOrderedDict(OrderedDict):\n" -" 'Store items in the order the keys were last added'\n" +" 'Store items in the order that the keys were last updated.'\n" "\n" " def __setitem__(self, key, value):\n" " super().__setitem__(key, value)\n" " self.move_to_end(key)" msgstr "" +"class LastUpdatedOrderedDict(OrderedDict):\n" +" 'Store items in the order that the keys were last updated.'\n" +"\n" +" def __setitem__(self, key, value):\n" +" super().__setitem__(key, value)\n" +" self.move_to_end(key)" -#: ../../library/collections.rst:1226 +#: ../../library/collections.rst:1230 msgid "" "An :class:`OrderedDict` would also be useful for implementing variants of :" "deco:`functools.lru_cache`:" @@ -1981,7 +2013,7 @@ msgstr "" ":class:`OrderedDict` 在實作 :deco:`functools.lru_cache` 的變形版本時也非常有" "用:" -#: ../../library/collections.rst:1229 +#: ../../library/collections.rst:1233 msgid "" "from collections import OrderedDict\n" "from time import monotonic\n" @@ -2008,7 +2040,7 @@ msgid "" " return result" msgstr "" -#: ../../library/collections.rst:1256 +#: ../../library/collections.rst:1260 msgid "" "class MultiHitLRUCache:\n" " \"\"\" LRU cache that defers caching a result until\n" @@ -2046,11 +2078,11 @@ msgid "" " return result" msgstr "" -#: ../../library/collections.rst:1325 +#: ../../library/collections.rst:1329 msgid ":class:`UserDict` objects" msgstr ":class:`UserDict` 物件" -#: ../../library/collections.rst:1327 +#: ../../library/collections.rst:1331 msgid "" "The class, :class:`UserDict` acts as a wrapper around dictionary objects. " "The need for this class has been partially supplanted by the ability to " @@ -2061,7 +2093,7 @@ msgstr "" "`dict` 建立子類別,這個類別的需求已部分被滿足,不過這個類別使用起來更方便,因" "為被包裝的字典可以作為其屬性來存取。" -#: ../../library/collections.rst:1337 +#: ../../library/collections.rst:1341 msgid "" "Class that simulates a dictionary. The instance's contents are kept in a " "regular dictionary, which is accessible via the :attr:`data` attribute of :" @@ -2072,23 +2104,35 @@ msgstr "" "attr:`data` 屬性來做存取。如果有提供引數,:attr:`data` 屬性會被初始化,就像一" "個一般的字典。" -#: ../../library/collections.rst:1342 +#: ../../library/collections.rst:1346 msgid "" "In addition to supporting the methods and operations of mappings, :class:`!" "UserDict` instances provide the following attribute:" msgstr "" "除了支援作為對映所需的方法與操作,:class:`!UserDict`\\ 實例提供了以下屬性:" -#: ../../library/collections.rst:1347 +#: ../../library/collections.rst:1351 msgid "" "A real dictionary used to store the contents of the :class:`UserDict` class." msgstr "一個真實的字典,用於儲存 :class:`UserDict` 類別的資料內容。" -#: ../../library/collections.rst:1353 +#: ../../library/collections.rst:1354 +msgid ":class:`!UserDict` instances also override the following method:" +msgstr "" + +#: ../../library/collections.rst:1358 +msgid "" +"Remove and return a ``(key, value)`` pair from the wrapped dictionary. Pairs " +"are returned in the same order as ``data.popitem()``. (For the default :meth:" +"`dict.popitem`, this order is :abbr:`LIFO (last-in, first-out)`.) If the " +"dictionary is empty, raises a :exc:`KeyError`." +msgstr "" + +#: ../../library/collections.rst:1364 msgid ":class:`UserList` objects" msgstr ":class:`UserList` 物件" -#: ../../library/collections.rst:1355 +#: ../../library/collections.rst:1366 msgid "" "This class acts as a wrapper around list objects. It is a useful base class " "for your own list-like classes which can inherit from them and override " @@ -2099,7 +2143,7 @@ msgstr "" "入新方法來定義你所需的一個類似於 list 的類別。如此一來,我們可以為 list 加入" "新的特性。" -#: ../../library/collections.rst:1360 +#: ../../library/collections.rst:1371 msgid "" "The need for this class has been partially supplanted by the ability to " "subclass directly from :class:`list`; however, this class can be easier to " @@ -2108,7 +2152,7 @@ msgstr "" "因為已經可以直接自 :class:`list` 建立子類別,這個類別的需求已部分被滿足,不過" "這個類別使用起來更方便,因為被包裝的 list 可以作為其屬性來存取。" -#: ../../library/collections.rst:1366 +#: ../../library/collections.rst:1377 msgid "" "Class that simulates a list. The instance's contents are kept in a regular " "list, which is accessible via the :attr:`data` attribute of :class:" @@ -2121,20 +2165,20 @@ msgstr "" "list ``[]``。*list* 可以是任何 iterable,例如一個真實的 Python list 或是一" "個 :class:`UserList` 物件。" -#: ../../library/collections.rst:1372 +#: ../../library/collections.rst:1383 msgid "" "In addition to supporting the methods and operations of mutable sequences, :" "class:`UserList` instances provide the following attribute:" msgstr "除了支援可變序列的方法與操作,:class:`UserList` 實例提供了以下屬性:" -#: ../../library/collections.rst:1377 +#: ../../library/collections.rst:1388 msgid "" "A real :class:`list` object used to store the contents of the :class:" "`UserList` class." msgstr "" "一個真實的 :class:`list` 物件,用於儲存 :class:`UserList` 類別的資料內容。" -#: ../../library/collections.rst:1380 +#: ../../library/collections.rst:1391 msgid "" "**Subclassing requirements:** Subclasses of :class:`UserList` are expected " "to offer a constructor which can be called with either no arguments or one " @@ -2148,7 +2192,7 @@ msgstr "" "例,為了達成上述目的,它假設建構函式可傳入單一參數來呼叫,該參數即是做為數據" "來源的一個序列物件。" -#: ../../library/collections.rst:1387 +#: ../../library/collections.rst:1398 msgid "" "If a derived class does not wish to comply with this requirement, all of the " "special methods supported by this class will need to be overridden; please " @@ -2158,11 +2202,11 @@ msgstr "" "如果希望一個自此獲得的子類別不遵從上述要求,那所有該類別支援的特殊方法則必須" "被覆寫;請參考原始碼來理解在這情況下哪些方法是必須提供的。" -#: ../../library/collections.rst:1393 +#: ../../library/collections.rst:1404 msgid ":class:`UserString` objects" msgstr ":class:`UserString` 物件" -#: ../../library/collections.rst:1395 +#: ../../library/collections.rst:1406 msgid "" "The class, :class:`UserString` acts as a wrapper around string objects. The " "need for this class has been partially supplanted by the ability to subclass " @@ -2173,7 +2217,7 @@ msgstr "" "建立子類別,這個類別的需求已經部分被滿足,不過這個類別使用起來更方便,因為被" "包裝的字串可以作為其屬性來存取。" -#: ../../library/collections.rst:1403 +#: ../../library/collections.rst:1414 msgid "" "Class that simulates a string object. The instance's content is kept in a " "regular string object, which is accessible via the :attr:`data` attribute " @@ -2185,21 +2229,21 @@ msgstr "" "的 :attr:`data` 屬性來做存取。實例內容被初始化為 *seq* 的複製,*seq* 引數可以" "是任何可被內建函式 :func:`str` 轉換成字串的物件。" -#: ../../library/collections.rst:1410 +#: ../../library/collections.rst:1421 msgid "" "In addition to supporting the methods and operations of strings, :class:" "`UserString` instances provide the following attribute:" msgstr "" "除了支援字串的方法和操作以外,:class:`UserString` 實例也提供了以下屬性:" -#: ../../library/collections.rst:1415 +#: ../../library/collections.rst:1426 msgid "" "A real :class:`str` object used to store the contents of the :class:" "`UserString` class." msgstr "" "一個真實的 :class:`str` 物件,用來儲存 :class:`UserString` 類別的資料內容。" -#: ../../library/collections.rst:1418 +#: ../../library/collections.rst:1429 msgid "" "New methods ``__getnewargs__``, ``__rmod__``, ``casefold``, ``format_map``, " "``isprintable``, and ``maketrans``." diff --git a/library/colorsys.po b/library/colorsys.po index 2dce8b5cfb2..7783a2b9032 100644 --- a/library/colorsys.po +++ b/library/colorsys.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-02-15 20:58+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!colorsys` --- Conversions between color systems" msgstr ":mod:`!colorsys` --- 顏色系統間的轉換" -#: ../../library/colorsys.rst:9 +#: ../../library/colorsys.rst:7 msgid "**Source code:** :source:`Lib/colorsys.py`" msgstr "**原始碼:**\\ :source:`Lib/colorsys.py`" -#: ../../library/colorsys.rst:13 +#: ../../library/colorsys.rst:11 msgid "" "The :mod:`!colorsys` module defines bidirectional conversions of color " "values between colors expressed in the RGB (Red Green Blue) color space used " @@ -44,7 +44,7 @@ msgstr "" "值 (floating-point) 來表示。在 YIQ 空間中,Y 座標值為 0 和 1 之間,而 I 和 Q " "座標均可以為正數或負數。在所有其他空間中,座標值均為 0 和 1 之間。" -#: ../../library/colorsys.rst:23 +#: ../../library/colorsys.rst:21 msgid "" "More information about color spaces can be found at https://www.poynton.ca/" "pdf/ColourFAQ.pdf and https://www.cambridgeincolour.com/tutorials/color-" @@ -53,39 +53,39 @@ msgstr "" "有關色彩空間的更多資訊請見 https://www.poynton.ca/pdf/ColourFAQ.pdf 和 " "https://www.cambridgeincolour.com/tutorials/color-spaces.htm。" -#: ../../library/colorsys.rst:27 +#: ../../library/colorsys.rst:25 msgid "The :mod:`!colorsys` module defines the following functions:" msgstr ":mod:`!colorsys` 模組定義了以下函式:" -#: ../../library/colorsys.rst:32 +#: ../../library/colorsys.rst:30 msgid "Convert the color from RGB coordinates to YIQ coordinates." msgstr "將顏色自 RGB 座標轉換至 YIQ 座標。" -#: ../../library/colorsys.rst:37 +#: ../../library/colorsys.rst:35 msgid "Convert the color from YIQ coordinates to RGB coordinates." msgstr "將顏色自 YIQ 座標轉換至 RGB 座標。" -#: ../../library/colorsys.rst:42 +#: ../../library/colorsys.rst:40 msgid "Convert the color from RGB coordinates to HLS coordinates." msgstr "將顏色自 RGB 座標轉換至 HLS 座標。" -#: ../../library/colorsys.rst:47 +#: ../../library/colorsys.rst:45 msgid "Convert the color from HLS coordinates to RGB coordinates." msgstr "將顏色自 HLS 座標轉換至 RGB 座標。" -#: ../../library/colorsys.rst:52 +#: ../../library/colorsys.rst:50 msgid "Convert the color from RGB coordinates to HSV coordinates." msgstr "將顏色自 RGB 座標轉換至 HSV 座標。" -#: ../../library/colorsys.rst:57 +#: ../../library/colorsys.rst:55 msgid "Convert the color from HSV coordinates to RGB coordinates." msgstr "將顏色自 HSV 座標轉換至 RGB 座標。" -#: ../../library/colorsys.rst:59 +#: ../../library/colorsys.rst:57 msgid "Example::" msgstr "範例: ::" -#: ../../library/colorsys.rst:61 +#: ../../library/colorsys.rst:59 msgid "" ">>> import colorsys\n" ">>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4)\n" diff --git a/library/compression.zstd.po b/library/compression.zstd.po index 9990a39f584..65fda4979f5 100644 --- a/library/compression.zstd.po +++ b/library/compression.zstd.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-15 00:10+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -430,48 +430,59 @@ msgstr "" msgid "" "If *max_length* is non-negative, the method returns at most *max_length* " "bytes of decompressed data. If this limit is reached and further output can " -"be produced, the :attr:`~.needs_input` attribute will be set to ``False``. " -"In this case, the next call to :meth:`~.decompress` may provide *data* as " -"``b''`` to obtain more of the output." +"be produced (or EOF is reached), the :attr:`~.needs_input` attribute will be " +"set to ``False``. In this case, the next call to :meth:`~.decompress` may " +"provide *data* as ``b''`` to obtain more of the output. The full content can " +"thus be read like::" msgstr "" #: ../../library/compression.zstd.rst:339 msgid "" +"process_output(d.decompress(data, max_length))\n" +"while not d.eof and not d.needs_input:\n" +" process_output(d.decompress(b\"\", max_length))" +msgstr "" +"process_output(d.decompress(data, max_length))\n" +"while not d.eof and not d.needs_input:\n" +" process_output(d.decompress(b\"\", max_length))" + +#: ../../library/compression.zstd.rst:343 +msgid "" "If all of the input data was decompressed and returned (either because this " "was less than *max_length* bytes, or because *max_length* was negative), " "the :attr:`~.needs_input` attribute will be set to ``True``." msgstr "" -#: ../../library/compression.zstd.rst:344 +#: ../../library/compression.zstd.rst:348 msgid "" "Attempting to decompress data after the end of a frame will raise a :exc:" "`EOFError`. Any data found after the end of the frame is ignored and saved " "in the :attr:`~.unused_data` attribute." msgstr "" -#: ../../library/compression.zstd.rst:350 +#: ../../library/compression.zstd.rst:354 msgid "``True`` if the end-of-stream marker has been reached." msgstr "" -#: ../../library/compression.zstd.rst:354 +#: ../../library/compression.zstd.rst:358 msgid "Data found after the end of the compressed stream." msgstr "" -#: ../../library/compression.zstd.rst:356 +#: ../../library/compression.zstd.rst:360 msgid "Before the end of the stream is reached, this will be ``b''``." msgstr "" -#: ../../library/compression.zstd.rst:360 +#: ../../library/compression.zstd.rst:364 msgid "" "``False`` if the :meth:`.decompress` method can provide more decompressed " "data before requiring new compressed input." msgstr "" -#: ../../library/compression.zstd.rst:365 +#: ../../library/compression.zstd.rst:369 msgid "Zstandard dictionaries" msgstr "Zstandard 字典" -#: ../../library/compression.zstd.rst:370 +#: ../../library/compression.zstd.rst:374 msgid "" "Train a Zstandard dictionary, returning a :class:`ZstdDict` instance. " "Zstandard dictionaries enable more efficient compression of smaller sizes of " @@ -481,13 +492,13 @@ msgid "" "significantly." msgstr "" -#: ../../library/compression.zstd.rst:377 +#: ../../library/compression.zstd.rst:381 msgid "" "The *samples* argument (an iterable of :class:`bytes` objects), is the " "population of samples used to train the Zstandard dictionary." msgstr "" -#: ../../library/compression.zstd.rst:380 +#: ../../library/compression.zstd.rst:384 msgid "" "The *dict_size* argument, an integer, is the maximum size (in bytes) the " "Zstandard dictionary should be. The Zstandard documentation suggests an " @@ -497,7 +508,7 @@ msgid "" "faster compression, but reduce the compression ratio." msgstr "" -#: ../../library/compression.zstd.rst:390 +#: ../../library/compression.zstd.rst:394 msgid "" "An advanced function for converting a \"raw content\" Zstandard dictionary " "into a regular Zstandard dictionary. \"Raw content\" dictionaries are a " @@ -505,26 +516,26 @@ msgid "" "Zstandard dictionary." msgstr "" -#: ../../library/compression.zstd.rst:395 +#: ../../library/compression.zstd.rst:399 msgid "" "The *zstd_dict* argument is a :class:`ZstdDict` instance with the :attr:" "`~ZstdDict.dict_content` containing the raw dictionary contents." msgstr "" -#: ../../library/compression.zstd.rst:398 +#: ../../library/compression.zstd.rst:402 msgid "" "The *samples* argument (an iterable of :class:`bytes` objects), contains " "sample data for generating the Zstandard dictionary." msgstr "" -#: ../../library/compression.zstd.rst:401 +#: ../../library/compression.zstd.rst:405 msgid "" "The *dict_size* argument, an integer, is the maximum size (in bytes) the " "Zstandard dictionary should be. See :func:`train_dict` for suggestions on " "the maximum dictionary size." msgstr "" -#: ../../library/compression.zstd.rst:405 +#: ../../library/compression.zstd.rst:409 msgid "" "The *level* argument (an integer) is the compression level expected to be " "passed to the compressors using this dictionary. The dictionary information " @@ -532,20 +543,20 @@ msgid "" "level can make compression more efficient." msgstr "" -#: ../../library/compression.zstd.rst:413 +#: ../../library/compression.zstd.rst:417 msgid "" "A wrapper around Zstandard dictionaries. Dictionaries can be used to improve " "the compression of many small chunks of data. Use :func:`train_dict` if you " "need to train a new dictionary from sample data." msgstr "" -#: ../../library/compression.zstd.rst:417 +#: ../../library/compression.zstd.rst:421 msgid "" "The *dict_content* argument (a :term:`bytes-like object`), is the already " "trained dictionary information." msgstr "" -#: ../../library/compression.zstd.rst:420 +#: ../../library/compression.zstd.rst:424 msgid "" "The *is_raw* argument, a boolean, is an advanced parameter controlling the " "meaning of *dict_content*. ``True`` means *dict_content* is a \"raw " @@ -555,7 +566,7 @@ msgid "" "CLI." msgstr "" -#: ../../library/compression.zstd.rst:426 +#: ../../library/compression.zstd.rst:430 msgid "" "When passing a :class:`!ZstdDict` to a function, the :attr:`!" "as_digested_dict` and :attr:`!as_undigested_dict` attributes can control how " @@ -567,25 +578,25 @@ msgid "" "dictionary." msgstr "" -#: ../../library/compression.zstd.rst:435 +#: ../../library/compression.zstd.rst:439 msgid "Difference for compression" msgstr "" -#: ../../library/compression.zstd.rst:440 +#: ../../library/compression.zstd.rst:444 msgid "Digested dictionary" msgstr "" -#: ../../library/compression.zstd.rst:441 +#: ../../library/compression.zstd.rst:445 msgid "Undigested dictionary" msgstr "" -#: ../../library/compression.zstd.rst:442 +#: ../../library/compression.zstd.rst:446 msgid "" "Advanced parameters of the compressor which may be overridden by the " "dictionary's parameters" msgstr "" -#: ../../library/compression.zstd.rst:444 +#: ../../library/compression.zstd.rst:448 msgid "" "``window_log``, ``hash_log``, ``chain_log``, ``search_log``, ``min_match``, " "``target_length``, ``strategy``, ``enable_long_distance_matching``, " @@ -593,114 +604,114 @@ msgid "" "``ldm_hash_rate_log``, and some non-public parameters." msgstr "" -#: ../../library/compression.zstd.rst:449 +#: ../../library/compression.zstd.rst:453 msgid "None" msgstr "" -#: ../../library/compression.zstd.rst:450 +#: ../../library/compression.zstd.rst:454 msgid ":class:`!ZstdDict` internally caches the dictionary" msgstr "" -#: ../../library/compression.zstd.rst:451 +#: ../../library/compression.zstd.rst:455 msgid "" "Yes. It's faster when loading a digested dictionary again with the same " "compression level." msgstr "" -#: ../../library/compression.zstd.rst:453 +#: ../../library/compression.zstd.rst:457 msgid "" "No. If you wish to load an undigested dictionary multiple times, consider " "reusing a compressor object." msgstr "" -#: ../../library/compression.zstd.rst:456 +#: ../../library/compression.zstd.rst:460 msgid "" "If passing a :class:`!ZstdDict` without any attribute, an undigested " "dictionary is passed by default when compressing and a digested dictionary " "is generated if necessary and passed by default when decompressing." msgstr "" -#: ../../library/compression.zstd.rst:462 +#: ../../library/compression.zstd.rst:466 msgid "" "The content of the Zstandard dictionary, a ``bytes`` object. It's the same " "as the *dict_content* argument in the ``__init__`` method. It can be used " "with other programs, such as the ``zstd`` CLI program." msgstr "" -#: ../../library/compression.zstd.rst:468 +#: ../../library/compression.zstd.rst:472 msgid "Identifier of the Zstandard dictionary, a non-negative int value." msgstr "" -#: ../../library/compression.zstd.rst:470 +#: ../../library/compression.zstd.rst:474 msgid "" "Non-zero means the dictionary is ordinary, created by Zstandard functions " "and following the Zstandard format." msgstr "" -#: ../../library/compression.zstd.rst:473 +#: ../../library/compression.zstd.rst:477 msgid "" "``0`` means a \"raw content\" dictionary, free of any format restriction, " "used for advanced users." msgstr "" -#: ../../library/compression.zstd.rst:478 +#: ../../library/compression.zstd.rst:482 msgid "" "The meaning of ``0`` for :attr:`!ZstdDict.dict_id` is different from the " "``dictionary_id`` attribute to the :func:`get_frame_info` function." msgstr "" -#: ../../library/compression.zstd.rst:484 +#: ../../library/compression.zstd.rst:488 msgid "Load as a digested dictionary." msgstr "" -#: ../../library/compression.zstd.rst:488 +#: ../../library/compression.zstd.rst:492 msgid "Load as an undigested dictionary." msgstr "" -#: ../../library/compression.zstd.rst:492 +#: ../../library/compression.zstd.rst:496 msgid "Advanced parameter control" msgstr "" -#: ../../library/compression.zstd.rst:496 +#: ../../library/compression.zstd.rst:500 msgid "" "An :class:`~enum.IntEnum` containing the advanced compression parameter keys " "that can be used when compressing data." msgstr "" -#: ../../library/compression.zstd.rst:499 -#: ../../library/compression.zstd.rst:733 +#: ../../library/compression.zstd.rst:503 +#: ../../library/compression.zstd.rst:737 msgid "" "The :meth:`~.bounds` method can be used on any attribute to get the valid " "values for that parameter." msgstr "" -#: ../../library/compression.zstd.rst:502 +#: ../../library/compression.zstd.rst:506 msgid "" "Parameters are optional; any omitted parameter will have its value selected " "automatically." msgstr "" -#: ../../library/compression.zstd.rst:505 +#: ../../library/compression.zstd.rst:509 msgid "" "Example getting the lower and upper bound of :attr:`~.compression_level`::" msgstr "" -#: ../../library/compression.zstd.rst:507 +#: ../../library/compression.zstd.rst:511 msgid "lower, upper = CompressionParameter.compression_level.bounds()" msgstr "" -#: ../../library/compression.zstd.rst:509 +#: ../../library/compression.zstd.rst:513 msgid "Example setting the :attr:`~.window_log` to the maximum size::" msgstr "" -#: ../../library/compression.zstd.rst:511 +#: ../../library/compression.zstd.rst:515 msgid "" "_lower, upper = CompressionParameter.window_log.bounds()\n" "options = {CompressionParameter.window_log: upper}\n" "compress(b'venezuelan beaver cheese', options=options)" msgstr "" -#: ../../library/compression.zstd.rst:517 +#: ../../library/compression.zstd.rst:521 msgid "" "Return the tuple of int bounds, ``(lower, upper)``, of a compression " "parameter. This method should be called on the attribute you wish to " @@ -709,18 +720,18 @@ msgid "" "compression_level.bounds()``." msgstr "" -#: ../../library/compression.zstd.rst:523 -#: ../../library/compression.zstd.rst:751 +#: ../../library/compression.zstd.rst:527 +#: ../../library/compression.zstd.rst:755 msgid "Both the lower and upper bounds are inclusive." msgstr "" -#: ../../library/compression.zstd.rst:527 +#: ../../library/compression.zstd.rst:531 msgid "" "A high-level means of setting other compression parameters that affect the " "speed and ratio of compressing data." msgstr "" -#: ../../library/compression.zstd.rst:530 +#: ../../library/compression.zstd.rst:534 msgid "" "Regular compression levels are greater than ``0``. Values greater than " "``20`` are considered \"ultra\" compression and require more memory than " @@ -728,11 +739,11 @@ msgid "" "for worse compression ratios." msgstr "" -#: ../../library/compression.zstd.rst:535 +#: ../../library/compression.zstd.rst:539 msgid "Setting the level to zero uses :attr:`COMPRESSION_LEVEL_DEFAULT`." msgstr "" -#: ../../library/compression.zstd.rst:539 +#: ../../library/compression.zstd.rst:543 msgid "" "Maximum allowed back-reference distance the compressor can use when " "compressing data, expressed as power of two, ``1 << window_log`` bytes. This " @@ -740,22 +751,22 @@ msgid "" "require more memory but gain better compression values." msgstr "" -#: ../../library/compression.zstd.rst:544 -#: ../../library/compression.zstd.rst:553 -#: ../../library/compression.zstd.rst:564 -#: ../../library/compression.zstd.rst:572 -#: ../../library/compression.zstd.rst:583 -#: ../../library/compression.zstd.rst:598 -#: ../../library/compression.zstd.rst:629 -#: ../../library/compression.zstd.rst:636 -#: ../../library/compression.zstd.rst:644 -#: ../../library/compression.zstd.rst:652 -#: ../../library/compression.zstd.rst:711 -#: ../../library/compression.zstd.rst:760 +#: ../../library/compression.zstd.rst:548 +#: ../../library/compression.zstd.rst:557 +#: ../../library/compression.zstd.rst:568 +#: ../../library/compression.zstd.rst:576 +#: ../../library/compression.zstd.rst:587 +#: ../../library/compression.zstd.rst:602 +#: ../../library/compression.zstd.rst:633 +#: ../../library/compression.zstd.rst:640 +#: ../../library/compression.zstd.rst:648 +#: ../../library/compression.zstd.rst:656 +#: ../../library/compression.zstd.rst:715 +#: ../../library/compression.zstd.rst:764 msgid "A value of zero causes the value to be selected automatically." msgstr "" -#: ../../library/compression.zstd.rst:548 +#: ../../library/compression.zstd.rst:552 msgid "" "Size of the initial probe table, as a power of two. The resulting memory " "usage is ``1 << (hash_log+2)`` bytes. Larger tables improve compression " @@ -763,7 +774,7 @@ msgid "" "speed of strategies > :attr:`~Strategy.dfast`." msgstr "" -#: ../../library/compression.zstd.rst:557 +#: ../../library/compression.zstd.rst:561 msgid "" "Size of the multi-probe search table, as a power of two. The resulting " "memory usage is ``1 << (chain_log+2)`` bytes. Larger tables result in better " @@ -772,14 +783,14 @@ msgid "" "dfast` strategy, in which case it defines a secondary probe table." msgstr "" -#: ../../library/compression.zstd.rst:568 +#: ../../library/compression.zstd.rst:572 msgid "" "Number of search attempts, as a power of two. More attempts result in better " "and slower compression. This parameter is useless for :attr:`~Strategy.fast` " "and :attr:`~Strategy.dfast` strategies." msgstr "" -#: ../../library/compression.zstd.rst:576 +#: ../../library/compression.zstd.rst:580 msgid "" "Minimum size of searched matches. Larger values increase compression and " "decompression speed, but decrease ratio. Note that Zstandard can still find " @@ -789,11 +800,11 @@ msgid "" "effective maximum is ``6``." msgstr "" -#: ../../library/compression.zstd.rst:587 +#: ../../library/compression.zstd.rst:591 msgid "The impact of this field depends on the selected :class:`Strategy`." msgstr "" -#: ../../library/compression.zstd.rst:589 +#: ../../library/compression.zstd.rst:593 msgid "" "For strategies :attr:`~Strategy.btopt`, :attr:`~Strategy.btultra` and :attr:" "`~Strategy.btultra2`, the value is the length of a match considered \"good " @@ -801,38 +812,38 @@ msgid "" "but compresses slower." msgstr "" -#: ../../library/compression.zstd.rst:594 +#: ../../library/compression.zstd.rst:598 msgid "" "For strategy :attr:`~Strategy.fast`, it is the distance between match " "sampling. Larger values make compression faster, but with a worse " "compression ratio." msgstr "" -#: ../../library/compression.zstd.rst:602 +#: ../../library/compression.zstd.rst:606 msgid "" "The higher the value of selected strategy, the more complex the compression " "technique used by zstd, resulting in higher compression ratios but slower " "compression." msgstr "" -#: ../../library/compression.zstd.rst:606 +#: ../../library/compression.zstd.rst:610 msgid ":class:`Strategy`" msgstr ":class:`Strategy`" -#: ../../library/compression.zstd.rst:610 +#: ../../library/compression.zstd.rst:614 msgid "" "Long distance matching can be used to improve compression for large inputs " "by finding large matches at greater distances. It increases memory usage and " "window size." msgstr "" -#: ../../library/compression.zstd.rst:614 +#: ../../library/compression.zstd.rst:618 msgid "" "``True`` or ``1`` enable long distance matching while ``False`` or ``0`` " "disable it." msgstr "" -#: ../../library/compression.zstd.rst:617 +#: ../../library/compression.zstd.rst:621 msgid "" "Enabling this parameter increases default :attr:`~CompressionParameter." "window_log` to 128 MiB except when expressly set to a different value. This " @@ -840,55 +851,55 @@ msgid "" "compression strategy >= :attr:`~Strategy.btopt` (compression level 16+)." msgstr "" -#: ../../library/compression.zstd.rst:625 +#: ../../library/compression.zstd.rst:629 msgid "" "Size of the table for long distance matching, as a power of two. Larger " "values increase memory usage and compression ratio, but decrease compression " "speed." msgstr "" -#: ../../library/compression.zstd.rst:633 +#: ../../library/compression.zstd.rst:637 msgid "" "Minimum match size for long distance matcher. Larger or too small values can " "often decrease the compression ratio." msgstr "" -#: ../../library/compression.zstd.rst:640 +#: ../../library/compression.zstd.rst:644 msgid "" "Log size of each bucket in the long distance matcher hash table for " "collision resolution. Larger values improve collision resolution but " "decrease compression speed." msgstr "" -#: ../../library/compression.zstd.rst:648 +#: ../../library/compression.zstd.rst:652 msgid "" "Frequency of inserting/looking up entries into the long distance matcher " "hash table. Larger values improve compression speed. Deviating far from the " "default value will likely result in a compression ratio decrease." msgstr "" -#: ../../library/compression.zstd.rst:656 +#: ../../library/compression.zstd.rst:660 msgid "" "Write the size of the data to be compressed into the Zstandard frame header " "when known prior to compressing." msgstr "" -#: ../../library/compression.zstd.rst:659 +#: ../../library/compression.zstd.rst:663 msgid "This flag only takes effect under the following scenarios:" msgstr "" -#: ../../library/compression.zstd.rst:661 +#: ../../library/compression.zstd.rst:665 msgid "Calling :func:`compress` for one-shot compression" msgstr "" -#: ../../library/compression.zstd.rst:662 +#: ../../library/compression.zstd.rst:666 msgid "" "Providing all of the data to be compressed in the frame in a single :meth:" "`ZstdCompressor.compress` call, with the :attr:`ZstdCompressor.FLUSH_FRAME` " "mode." msgstr "" -#: ../../library/compression.zstd.rst:665 +#: ../../library/compression.zstd.rst:669 msgid "" "Calling :meth:`ZstdCompressor.set_pledged_input_size` with the exact amount " "of data that will be provided to the compressor prior to any calls to :meth:" @@ -896,44 +907,44 @@ msgid "" "set_pledged_input_size` must be called for each new frame." msgstr "" -#: ../../library/compression.zstd.rst:671 +#: ../../library/compression.zstd.rst:675 msgid "" "All other compression calls may not write the size information into the " "frame header." msgstr "" -#: ../../library/compression.zstd.rst:674 +#: ../../library/compression.zstd.rst:678 msgid "" "``True`` or ``1`` enable the content size flag while ``False`` or ``0`` " "disable it." msgstr "" -#: ../../library/compression.zstd.rst:679 +#: ../../library/compression.zstd.rst:683 msgid "" "A four-byte checksum using XXHash64 of the uncompressed content is written " "at the end of each frame. Zstandard's decompression code verifies the " "checksum. If there is a mismatch a :class:`ZstdError` exception is raised." msgstr "" -#: ../../library/compression.zstd.rst:684 +#: ../../library/compression.zstd.rst:688 msgid "" "``True`` or ``1`` enable checksum generation while ``False`` or ``0`` " "disable it." msgstr "" -#: ../../library/compression.zstd.rst:689 +#: ../../library/compression.zstd.rst:693 msgid "" "When compressing with a :class:`ZstdDict`, the dictionary's ID is written " "into the frame header." msgstr "" -#: ../../library/compression.zstd.rst:692 +#: ../../library/compression.zstd.rst:696 msgid "" "``True`` or ``1`` enable storing the dictionary ID while ``False`` or ``0`` " "disable it." msgstr "" -#: ../../library/compression.zstd.rst:697 +#: ../../library/compression.zstd.rst:701 msgid "" "Select how many threads will be spawned to compress in parallel. When :attr:" "`!nb_workers` > 0, enables multi-threaded compression, a value of ``1`` " @@ -941,11 +952,11 @@ msgid "" "also increase memory usage and slightly reduce compression ratio." msgstr "" -#: ../../library/compression.zstd.rst:702 +#: ../../library/compression.zstd.rst:706 msgid "A value of zero disables multi-threading." msgstr "" -#: ../../library/compression.zstd.rst:706 +#: ../../library/compression.zstd.rst:710 msgid "" "Size of a compression job, in bytes. This value is enforced only when :attr:" "`~CompressionParameter.nb_workers` >= 1. Each compression job is completed " @@ -953,7 +964,7 @@ msgid "" "threads." msgstr "" -#: ../../library/compression.zstd.rst:715 +#: ../../library/compression.zstd.rst:719 msgid "" "Sets how much data is reloaded from previous jobs (threads) for new jobs to " "be used by the look behind window during compression. This value is only " @@ -961,36 +972,36 @@ msgid "" "vary from 0 to 9." msgstr "" -#: ../../library/compression.zstd.rst:720 +#: ../../library/compression.zstd.rst:724 msgid "0 means dynamically set the overlap amount" msgstr "" -#: ../../library/compression.zstd.rst:721 +#: ../../library/compression.zstd.rst:725 msgid "1 means no overlap" msgstr "" -#: ../../library/compression.zstd.rst:722 +#: ../../library/compression.zstd.rst:726 msgid "9 means use a full window size from the previous job" msgstr "" -#: ../../library/compression.zstd.rst:724 +#: ../../library/compression.zstd.rst:728 msgid "" "Each increment halves/doubles the overlap size. \"8\" means an overlap of " "``window_size/2``, \"7\" means an overlap of ``window_size/4``, etc." msgstr "" -#: ../../library/compression.zstd.rst:729 +#: ../../library/compression.zstd.rst:733 msgid "" "An :class:`~enum.IntEnum` containing the advanced decompression parameter " "keys that can be used when decompressing data. Parameters are optional; any " "omitted parameter will have its value selected automatically." msgstr "" -#: ../../library/compression.zstd.rst:736 +#: ../../library/compression.zstd.rst:740 msgid "Example setting the :attr:`~.window_log_max` to the maximum size::" msgstr "" -#: ../../library/compression.zstd.rst:738 +#: ../../library/compression.zstd.rst:742 msgid "" "data = compress(b'Some very long buffer of bytes...')\n" "\n" @@ -1006,14 +1017,14 @@ msgstr "" "options = {DecompressionParameter.window_log_max: upper}\n" "decompress(data, options=options)" -#: ../../library/compression.zstd.rst:747 +#: ../../library/compression.zstd.rst:751 msgid "" "Return the tuple of int bounds, ``(lower, upper)``, of a decompression " "parameter. This method should be called on the attribute you wish to " "retrieve the bounds of." msgstr "" -#: ../../library/compression.zstd.rst:755 +#: ../../library/compression.zstd.rst:759 msgid "" "The base-two logarithm of the maximum size of the window used during " "decompression. This can be useful to limit the amount of memory used when " @@ -1021,42 +1032,42 @@ msgid "" "decompression." msgstr "" -#: ../../library/compression.zstd.rst:765 +#: ../../library/compression.zstd.rst:769 msgid "" "An :class:`~enum.IntEnum` containing strategies for compression. Higher-" "numbered strategies correspond to more complex and slower compression." msgstr "" -#: ../../library/compression.zstd.rst:771 +#: ../../library/compression.zstd.rst:775 msgid "" "The values of attributes of :class:`!Strategy` are not necessarily stable " "across zstd versions. Only the ordering of the attributes may be relied " "upon. The attributes are listed below in order." msgstr "" -#: ../../library/compression.zstd.rst:775 +#: ../../library/compression.zstd.rst:779 msgid "The following strategies are available:" msgstr "" -#: ../../library/compression.zstd.rst:797 +#: ../../library/compression.zstd.rst:801 msgid "Miscellaneous" msgstr "" -#: ../../library/compression.zstd.rst:801 +#: ../../library/compression.zstd.rst:805 msgid "" "Retrieve a :class:`FrameInfo` object containing metadata about a Zstandard " "frame. Frames contain metadata related to the compressed data they hold." msgstr "" -#: ../../library/compression.zstd.rst:807 +#: ../../library/compression.zstd.rst:811 msgid "Metadata related to a Zstandard frame." msgstr "" -#: ../../library/compression.zstd.rst:811 +#: ../../library/compression.zstd.rst:815 msgid "The size of the decompressed contents of the frame." msgstr "" -#: ../../library/compression.zstd.rst:815 +#: ../../library/compression.zstd.rst:819 msgid "" "An integer representing the Zstandard dictionary ID needed for decompressing " "the frame. ``0`` means the dictionary ID was not recorded in the frame " @@ -1064,25 +1075,25 @@ msgid "" "ID of a required dictionary was not recorded." msgstr "" -#: ../../library/compression.zstd.rst:823 +#: ../../library/compression.zstd.rst:827 msgid "The default compression level for Zstandard: ``3``." msgstr "" -#: ../../library/compression.zstd.rst:828 +#: ../../library/compression.zstd.rst:832 msgid "" "Version number of the runtime zstd library as a tuple of integers (major, " "minor, release)." msgstr "" -#: ../../library/compression.zstd.rst:833 +#: ../../library/compression.zstd.rst:837 msgid "Examples" msgstr "範例" -#: ../../library/compression.zstd.rst:835 +#: ../../library/compression.zstd.rst:839 msgid "Reading in a compressed file:" msgstr "讀取壓縮檔案:" -#: ../../library/compression.zstd.rst:837 +#: ../../library/compression.zstd.rst:841 msgid "" "from compression import zstd\n" "\n" @@ -1094,11 +1105,11 @@ msgstr "" "with zstd.open(\"file.zst\") as f:\n" " file_content = f.read()" -#: ../../library/compression.zstd.rst:844 +#: ../../library/compression.zstd.rst:848 msgid "Creating a compressed file:" msgstr "" -#: ../../library/compression.zstd.rst:846 +#: ../../library/compression.zstd.rst:850 msgid "" "from compression import zstd\n" "\n" @@ -1112,11 +1123,11 @@ msgstr "" "with zstd.open(\"file.zst\", \"w\") as f:\n" " f.write(data)" -#: ../../library/compression.zstd.rst:854 +#: ../../library/compression.zstd.rst:858 msgid "Compressing data in memory:" msgstr "" -#: ../../library/compression.zstd.rst:856 +#: ../../library/compression.zstd.rst:860 msgid "" "from compression import zstd\n" "\n" @@ -1128,11 +1139,11 @@ msgstr "" "data_in = b\"Insert Data Here\"\n" "data_out = zstd.compress(data_in)" -#: ../../library/compression.zstd.rst:863 +#: ../../library/compression.zstd.rst:867 msgid "Incremental compression:" msgstr "" -#: ../../library/compression.zstd.rst:865 +#: ../../library/compression.zstd.rst:869 msgid "" "from compression import zstd\n" "\n" @@ -1154,11 +1165,11 @@ msgstr "" "# Concatenate all the partial results:\n" "result = b\"\".join([out1, out2, out3, out4])" -#: ../../library/compression.zstd.rst:877 +#: ../../library/compression.zstd.rst:881 msgid "Writing compressed data to an already-open file:" msgstr "" -#: ../../library/compression.zstd.rst:879 +#: ../../library/compression.zstd.rst:883 msgid "" "from compression import zstd\n" "\n" @@ -1176,11 +1187,11 @@ msgstr "" " zstf.write(b\"This *will* be compressed\\n\")\n" " f.write(b\"Not compressed\\n\")" -#: ../../library/compression.zstd.rst:889 +#: ../../library/compression.zstd.rst:893 msgid "Creating a compressed file using compression parameters:" msgstr "" -#: ../../library/compression.zstd.rst:891 +#: ../../library/compression.zstd.rst:895 msgid "" "from compression import zstd\n" "\n" diff --git a/library/concurrent.interpreters.po b/library/concurrent.interpreters.po index cfee9a4c03d..5d5f0699aa9 100644 --- a/library/concurrent.interpreters.po +++ b/library/concurrent.interpreters.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-14 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -22,17 +22,17 @@ msgid "" ":mod:`!concurrent.interpreters` --- Multiple interpreters in the same process" msgstr ":mod:`!concurrent.interpreters` --- 在同一個行程中使用多個直譯器" -#: ../../library/concurrent.interpreters.rst:12 +#: ../../library/concurrent.interpreters.rst:9 msgid "**Source code:** :source:`Lib/concurrent/interpreters`" msgstr "**原始碼:**\\ :source:`Lib/concurrent/interpreters`" -#: ../../library/concurrent.interpreters.rst:16 +#: ../../library/concurrent.interpreters.rst:13 msgid "" "The :mod:`!concurrent.interpreters` module constructs higher-level " "interfaces on top of the lower level :mod:`!_interpreters` module." msgstr "" -#: ../../library/concurrent.interpreters.rst:19 +#: ../../library/concurrent.interpreters.rst:16 msgid "" "The module is primarily meant to provide a basic API for managing " "interpreters (AKA \"subinterpreters\") and running things in them. Running " @@ -40,7 +40,7 @@ msgid "" "calling a function in that execution context." msgstr "" -#: ../../library/concurrent.interpreters.rst:24 +#: ../../library/concurrent.interpreters.rst:21 msgid "" "For concurrency, interpreters themselves (and this module) don't provide " "much more than isolation, which on its own isn't useful. Actual concurrency " @@ -48,31 +48,31 @@ msgid "" "`_." msgstr "" -#: ../../library/concurrent.interpreters.rst:31 +#: ../../library/concurrent.interpreters.rst:28 msgid ":class:`~concurrent.futures.InterpreterPoolExecutor`" msgstr ":class:`~concurrent.futures.InterpreterPoolExecutor`" -#: ../../library/concurrent.interpreters.rst:32 +#: ../../library/concurrent.interpreters.rst:29 msgid "Combines threads with interpreters in a familiar interface." msgstr "" -#: ../../library/concurrent.interpreters.rst:36 +#: ../../library/concurrent.interpreters.rst:33 msgid ":ref:`isolating-extensions-howto`" msgstr ":ref:`isolating-extensions-howto`" -#: ../../library/concurrent.interpreters.rst:37 +#: ../../library/concurrent.interpreters.rst:34 msgid "How to update an extension module to support multiple interpreters." msgstr "" -#: ../../library/concurrent.interpreters.rst:39 +#: ../../library/concurrent.interpreters.rst:36 msgid ":pep:`554`" msgstr ":pep:`554`" -#: ../../library/concurrent.interpreters.rst:41 +#: ../../library/concurrent.interpreters.rst:38 msgid ":pep:`734`" msgstr ":pep:`734`" -#: ../../library/concurrent.interpreters.rst:43 +#: ../../library/concurrent.interpreters.rst:40 msgid ":pep:`684`" msgstr ":pep:`684`" @@ -86,33 +86,33 @@ msgid "" "availability` for more information." msgstr "" -#: ../../library/concurrent.interpreters.rst:51 +#: ../../library/concurrent.interpreters.rst:48 msgid "Key details" msgstr "" -#: ../../library/concurrent.interpreters.rst:53 +#: ../../library/concurrent.interpreters.rst:50 msgid "" "Before we dive in further, there are a small number of details to keep in " "mind about using multiple interpreters:" msgstr "" -#: ../../library/concurrent.interpreters.rst:56 +#: ../../library/concurrent.interpreters.rst:53 msgid "`isolated `_, by default" msgstr "" -#: ../../library/concurrent.interpreters.rst:57 +#: ../../library/concurrent.interpreters.rst:54 msgid "no implicit threads" msgstr "" -#: ../../library/concurrent.interpreters.rst:58 +#: ../../library/concurrent.interpreters.rst:55 msgid "not all PyPI packages support use in multiple interpreters yet" msgstr "" -#: ../../library/concurrent.interpreters.rst:66 +#: ../../library/concurrent.interpreters.rst:63 msgid "Introduction" msgstr "" -#: ../../library/concurrent.interpreters.rst:68 +#: ../../library/concurrent.interpreters.rst:65 msgid "" "An \"interpreter\" is effectively the execution context of the Python " "runtime. It contains all of the state the runtime needs to execute a " @@ -122,7 +122,7 @@ msgid "" "the bytecode eval loop.)" msgstr "" -#: ../../library/concurrent.interpreters.rst:75 +#: ../../library/concurrent.interpreters.rst:72 msgid "" "The concept and functionality of the interpreter have been a part of Python " "since version 2.2, but the feature was only available through the C-API and " @@ -130,11 +130,11 @@ msgid "" "incomplete until version 3.12." msgstr "" -#: ../../library/concurrent.interpreters.rst:83 +#: ../../library/concurrent.interpreters.rst:80 msgid "Multiple Interpreters and Isolation" msgstr "" -#: ../../library/concurrent.interpreters.rst:85 +#: ../../library/concurrent.interpreters.rst:82 msgid "" "A Python implementation may support using multiple interpreters in the same " "process. CPython has this support. Each interpreter is effectively " @@ -142,14 +142,14 @@ msgid "" "global exceptions to the rule)." msgstr "" -#: ../../library/concurrent.interpreters.rst:90 +#: ../../library/concurrent.interpreters.rst:87 msgid "" "That isolation is primarily useful as a strong separation between distinct " "logical components of a program, where you want to have careful control of " "how those components interact." msgstr "" -#: ../../library/concurrent.interpreters.rst:96 +#: ../../library/concurrent.interpreters.rst:93 msgid "" "Interpreters in the same process can technically never be strictly isolated " "from one another since there are few restrictions on memory access within " @@ -159,11 +159,11 @@ msgid "" "access to each other's data." msgstr "" -#: ../../library/concurrent.interpreters.rst:104 +#: ../../library/concurrent.interpreters.rst:101 msgid "Running in an Interpreter" msgstr "" -#: ../../library/concurrent.interpreters.rst:106 +#: ../../library/concurrent.interpreters.rst:103 msgid "" "Running in a different interpreter involves switching to it in the current " "thread and then calling some function. The runtime will execute the " @@ -172,14 +172,14 @@ msgid "" "interpreters, as well as the switch-and-call operation." msgstr "" -#: ../../library/concurrent.interpreters.rst:113 +#: ../../library/concurrent.interpreters.rst:110 msgid "" "No other threads are automatically started for the operation. There is `a " "helper `_ for that though. There is another " "dedicated helper for calling the builtin :func:`exec` in an interpreter." msgstr "" -#: ../../library/concurrent.interpreters.rst:118 +#: ../../library/concurrent.interpreters.rst:115 msgid "" "When :func:`exec` (or :func:`eval`) are called in an interpreter, they run " "using the interpreter's :mod:`!__main__` module as the \"globals\" " @@ -188,11 +188,11 @@ msgid "" "in the :mod:`!__main__` module." msgstr "" -#: ../../library/concurrent.interpreters.rst:128 +#: ../../library/concurrent.interpreters.rst:125 msgid "Concurrency and Parallelism" msgstr "" -#: ../../library/concurrent.interpreters.rst:130 +#: ../../library/concurrent.interpreters.rst:127 msgid "" "As noted earlier, interpreters do not provide any concurrency on their own. " "They strictly represent the isolated execution context the runtime will use " @@ -200,7 +200,7 @@ msgid "" "but they still enjoy in-process efficiency, like threads." msgstr "" -#: ../../library/concurrent.interpreters.rst:136 +#: ../../library/concurrent.interpreters.rst:133 msgid "" "All that said, interpreters do naturally support certain flavors of " "concurrency. There's a powerful side effect of that isolation. It enables a " @@ -209,7 +209,7 @@ msgid "" "relatively easy to reason about." msgstr "" -#: ../../library/concurrent.interpreters.rst:143 +#: ../../library/concurrent.interpreters.rst:140 msgid "" "You can take advantage of that concurrency model in a single thread, " "switching back and forth between interpreters, Stackless-style. However, " @@ -218,20 +218,20 @@ msgid "" "another interpreter and run what you want there." msgstr "" -#: ../../library/concurrent.interpreters.rst:149 +#: ../../library/concurrent.interpreters.rst:146 msgid "" "Each actual thread in Python, even if you're only running in the main " "thread, has its own *current* execution context. Multiple threads can use " "the same interpreter or different ones." msgstr "" -#: ../../library/concurrent.interpreters.rst:153 +#: ../../library/concurrent.interpreters.rst:150 msgid "" "At a high level, you can think of the combination of threads and " "interpreters as threads with opt-in sharing." msgstr "" -#: ../../library/concurrent.interpreters.rst:156 +#: ../../library/concurrent.interpreters.rst:153 msgid "" "As a significant bonus, interpreters are sufficiently isolated that they do " "not share the :term:`GIL`, which means combining threads with multiple " @@ -239,28 +239,28 @@ msgid "" "since Python 3.12.)" msgstr "" -#: ../../library/concurrent.interpreters.rst:162 +#: ../../library/concurrent.interpreters.rst:159 msgid "Communication Between Interpreters" msgstr "直譯器之間的溝通" -#: ../../library/concurrent.interpreters.rst:164 +#: ../../library/concurrent.interpreters.rst:161 msgid "" "In practice, multiple interpreters are useful only if we have a way to " "communicate between them. This usually involves some form of message " "passing, but can even mean sharing data in some carefully managed way." msgstr "" -#: ../../library/concurrent.interpreters.rst:169 +#: ../../library/concurrent.interpreters.rst:166 msgid "" "With this in mind, the :mod:`!concurrent.interpreters` module provides a :" "class:`queue.Queue` implementation, available through :func:`create_queue`." msgstr "" -#: ../../library/concurrent.interpreters.rst:176 +#: ../../library/concurrent.interpreters.rst:173 msgid "\"Sharing\" Objects" msgstr "" -#: ../../library/concurrent.interpreters.rst:178 +#: ../../library/concurrent.interpreters.rst:175 msgid "" "Any data actually shared between interpreters loses the thread-safety " "provided by the :term:`GIL`. There are various options for dealing with " @@ -270,94 +270,94 @@ msgid "" "sync." msgstr "" -#: ../../library/concurrent.interpreters.rst:185 +#: ../../library/concurrent.interpreters.rst:182 msgid "" "By default, most objects are copied with :mod:`pickle` when they are passed " "to another interpreter. Nearly all of the immutable builtin objects are " "either directly shared or copied efficiently. For example:" msgstr "" -#: ../../library/concurrent.interpreters.rst:189 +#: ../../library/concurrent.interpreters.rst:186 msgid ":const:`None`" msgstr ":const:`None`" -#: ../../library/concurrent.interpreters.rst:190 +#: ../../library/concurrent.interpreters.rst:187 msgid ":class:`bool` (:const:`True` and :const:`False`)" msgstr ":class:`bool`\\ (:const:`True` 和 :const:`False`)" -#: ../../library/concurrent.interpreters.rst:191 +#: ../../library/concurrent.interpreters.rst:188 msgid ":class:`bytes`" msgstr ":class:`bytes`" -#: ../../library/concurrent.interpreters.rst:192 +#: ../../library/concurrent.interpreters.rst:189 msgid ":class:`str`" msgstr ":class:`str`" -#: ../../library/concurrent.interpreters.rst:193 +#: ../../library/concurrent.interpreters.rst:190 msgid ":class:`int`" msgstr ":class:`int`" -#: ../../library/concurrent.interpreters.rst:194 +#: ../../library/concurrent.interpreters.rst:191 msgid ":class:`float`" msgstr ":class:`float`" -#: ../../library/concurrent.interpreters.rst:195 +#: ../../library/concurrent.interpreters.rst:192 msgid ":class:`tuple` (of similarly supported objects)" msgstr "" -#: ../../library/concurrent.interpreters.rst:197 +#: ../../library/concurrent.interpreters.rst:194 msgid "" "There are a small number of Python types that actually share mutable data " "between interpreters:" msgstr "" -#: ../../library/concurrent.interpreters.rst:200 +#: ../../library/concurrent.interpreters.rst:197 msgid ":class:`memoryview`" msgstr ":class:`memoryview`" -#: ../../library/concurrent.interpreters.rst:201 +#: ../../library/concurrent.interpreters.rst:198 msgid ":class:`Queue`" msgstr ":class:`Queue`" -#: ../../library/concurrent.interpreters.rst:205 +#: ../../library/concurrent.interpreters.rst:202 msgid "Reference" msgstr "" -#: ../../library/concurrent.interpreters.rst:207 +#: ../../library/concurrent.interpreters.rst:204 msgid "This module defines the following functions:" msgstr "" -#: ../../library/concurrent.interpreters.rst:211 +#: ../../library/concurrent.interpreters.rst:208 msgid "" "Return a :class:`list` of :class:`Interpreter` objects, one for each " "existing interpreter." msgstr "" -#: ../../library/concurrent.interpreters.rst:216 +#: ../../library/concurrent.interpreters.rst:213 msgid "" "Return an :class:`Interpreter` object for the currently running interpreter." msgstr "" -#: ../../library/concurrent.interpreters.rst:221 +#: ../../library/concurrent.interpreters.rst:218 msgid "" "Return an :class:`Interpreter` object for the main interpreter. This is the " "interpreter the runtime created to run the :term:`REPL` or the script given " "at the command-line. It is usually the only one." msgstr "" -#: ../../library/concurrent.interpreters.rst:227 +#: ../../library/concurrent.interpreters.rst:224 msgid "" "Initialize a new (idle) Python interpreter and return a :class:`Interpreter` " "object for it." msgstr "" -#: ../../library/concurrent.interpreters.rst:232 +#: ../../library/concurrent.interpreters.rst:229 msgid "" "Initialize a new cross-interpreter queue and return a :class:`Queue` object " "for it." msgstr "" -#: ../../library/concurrent.interpreters.rst:235 +#: ../../library/concurrent.interpreters.rst:232 msgid "" "*maxsize* is an integer that sets the upperbound limit on the number of " "items that can be placed in the queue. Insertion will be blocked once this " @@ -365,106 +365,106 @@ msgid "" "than or equal to zero, the queue size is infinite." msgstr "" -#: ../../library/concurrent.interpreters.rst:241 +#: ../../library/concurrent.interpreters.rst:238 msgid "Interpreter objects" msgstr "" -#: ../../library/concurrent.interpreters.rst:245 +#: ../../library/concurrent.interpreters.rst:242 msgid "A single interpreter in the current process." msgstr "" -#: ../../library/concurrent.interpreters.rst:247 +#: ../../library/concurrent.interpreters.rst:244 msgid "" "Generally, :class:`Interpreter` shouldn't be called directly. Instead, use :" "func:`create` or one of the other module functions." msgstr "" -#: ../../library/concurrent.interpreters.rst:252 -#: ../../library/concurrent.interpreters.rst:258 -#: ../../library/concurrent.interpreters.rst:339 +#: ../../library/concurrent.interpreters.rst:249 +#: ../../library/concurrent.interpreters.rst:255 +#: ../../library/concurrent.interpreters.rst:336 msgid "(read-only)" msgstr "" -#: ../../library/concurrent.interpreters.rst:254 +#: ../../library/concurrent.interpreters.rst:251 msgid "The underlying interpreter's ID." msgstr "" -#: ../../library/concurrent.interpreters.rst:260 +#: ../../library/concurrent.interpreters.rst:257 msgid "A string describing where the interpreter came from." msgstr "" -#: ../../library/concurrent.interpreters.rst:264 +#: ../../library/concurrent.interpreters.rst:261 msgid "" "Return ``True`` if the interpreter is currently executing code in its :mod:`!" "__main__` module and ``False`` otherwise." msgstr "" -#: ../../library/concurrent.interpreters.rst:269 +#: ../../library/concurrent.interpreters.rst:266 msgid "Finalize and destroy the interpreter." msgstr "" -#: ../../library/concurrent.interpreters.rst:273 +#: ../../library/concurrent.interpreters.rst:270 msgid "Bind objects in the interpreter's :mod:`!__main__` module." msgstr "" -#: ../../library/concurrent.interpreters.rst:275 -#: ../../library/concurrent.interpreters.rst:334 +#: ../../library/concurrent.interpreters.rst:272 +#: ../../library/concurrent.interpreters.rst:331 msgid "" "Some objects are actually shared and some are copied efficiently, but most " "are copied via :mod:`pickle`. See :ref:`interp-object-sharing`." msgstr "" -#: ../../library/concurrent.interpreters.rst:280 +#: ../../library/concurrent.interpreters.rst:277 msgid "Run the given source code in the interpreter (in the current thread)." msgstr "" -#: ../../library/concurrent.interpreters.rst:284 +#: ../../library/concurrent.interpreters.rst:281 msgid "" "Return the result of running the given function in the interpreter (in the " "current thread)." msgstr "" -#: ../../library/concurrent.interpreters.rst:291 +#: ../../library/concurrent.interpreters.rst:288 msgid "Run the given function in the interpreter (in a new thread)." msgstr "" -#: ../../library/concurrent.interpreters.rst:294 +#: ../../library/concurrent.interpreters.rst:291 msgid "Exceptions" msgstr "例外" -#: ../../library/concurrent.interpreters.rst:298 +#: ../../library/concurrent.interpreters.rst:295 msgid "" "This exception, a subclass of :exc:`Exception`, is raised when an " "interpreter-related error happens." msgstr "" -#: ../../library/concurrent.interpreters.rst:303 +#: ../../library/concurrent.interpreters.rst:300 msgid "" "This exception, a subclass of :exc:`InterpreterError`, is raised when the " "targeted interpreter no longer exists." msgstr "" -#: ../../library/concurrent.interpreters.rst:308 +#: ../../library/concurrent.interpreters.rst:305 msgid "" "This exception, a subclass of :exc:`InterpreterError`, is raised when the " "running code raised an uncaught exception." msgstr "" -#: ../../library/concurrent.interpreters.rst:313 +#: ../../library/concurrent.interpreters.rst:310 msgid "A basic snapshot of the exception raised in the other interpreter." msgstr "" -#: ../../library/concurrent.interpreters.rst:319 +#: ../../library/concurrent.interpreters.rst:316 msgid "" "This exception, a subclass of :exc:`TypeError`, is raised when an object " "cannot be sent to another interpreter." msgstr "" -#: ../../library/concurrent.interpreters.rst:324 +#: ../../library/concurrent.interpreters.rst:321 msgid "Communicating Between Interpreters" msgstr "在直譯器之間溝通" -#: ../../library/concurrent.interpreters.rst:328 +#: ../../library/concurrent.interpreters.rst:325 msgid "" "A wrapper around a low-level, cross-interpreter queue, which implements all " "the methods of :class:`queue.Queue` except for :meth:`~queue.Queue." @@ -472,23 +472,23 @@ msgid "" "The underlying queue can only be created through :func:`create_queue`." msgstr "" -#: ../../library/concurrent.interpreters.rst:341 +#: ../../library/concurrent.interpreters.rst:338 msgid "The queue's ID." msgstr "" -#: ../../library/concurrent.interpreters.rst:345 +#: ../../library/concurrent.interpreters.rst:342 msgid "Return the number of items in the queue." msgstr "" -#: ../../library/concurrent.interpreters.rst:349 +#: ../../library/concurrent.interpreters.rst:346 msgid "Return ``True`` if the queue is empty, ``False`` otherwise." msgstr "" -#: ../../library/concurrent.interpreters.rst:353 +#: ../../library/concurrent.interpreters.rst:350 msgid "Return ``True`` if the queue is full, ``False`` otherwise." msgstr "" -#: ../../library/concurrent.interpreters.rst:357 +#: ../../library/concurrent.interpreters.rst:354 msgid "" "Put *obj* into the queue. If optional args *block* is true and *timeout* is " "``None`` (the default), block if necessary until a free slot is available. " @@ -499,11 +499,11 @@ msgid "" "exception (*timeout* is ignored in that case)." msgstr "" -#: ../../library/concurrent.interpreters.rst:368 +#: ../../library/concurrent.interpreters.rst:365 msgid "Equivalent to ``put(obj, block=False)``." msgstr "" -#: ../../library/concurrent.interpreters.rst:372 +#: ../../library/concurrent.interpreters.rst:369 msgid "" "Remove and return an object from the queue. If optional args *block* is " "true and *timeout* is ``None`` (the default), block if necessary until an " @@ -514,31 +514,31 @@ msgid "" "exception (*timeout* is ignored in that case)." msgstr "" -#: ../../library/concurrent.interpreters.rst:383 +#: ../../library/concurrent.interpreters.rst:380 msgid "Equivalent to ``get(block=False)``." msgstr "" -#: ../../library/concurrent.interpreters.rst:388 +#: ../../library/concurrent.interpreters.rst:385 msgid "" "This exception, a subclass of :exc:`queue.Empty`, is raised from :meth:" "`Queue.get` and :meth:`Queue.get_nowait` when the queue is empty." msgstr "" -#: ../../library/concurrent.interpreters.rst:394 +#: ../../library/concurrent.interpreters.rst:391 msgid "" "This exception, a subclass of :exc:`queue.Full`, is raised from :meth:`Queue." "put` and :meth:`Queue.put_nowait` when the queue is full." msgstr "" -#: ../../library/concurrent.interpreters.rst:400 +#: ../../library/concurrent.interpreters.rst:397 msgid "Basic usage" msgstr "基本用法" -#: ../../library/concurrent.interpreters.rst:402 +#: ../../library/concurrent.interpreters.rst:399 msgid "Creating an interpreter and running code in it::" msgstr "建立一個直譯器並在其中運行程式碼: ::" -#: ../../library/concurrent.interpreters.rst:404 +#: ../../library/concurrent.interpreters.rst:401 msgid "" "from concurrent import interpreters\n" "\n" @@ -574,11 +574,11 @@ msgid "" "t.join()" msgstr "" -#: ../../library/concurrent.interpreters.rst:437 +#: ../../library/concurrent.interpreters.rst:434 msgid "Communicating between interpreters with a queue::" msgstr "使用佇列在直譯器之間溝通: ::" -#: ../../library/concurrent.interpreters.rst:439 +#: ../../library/concurrent.interpreters.rst:436 msgid "" "from concurrent import interpreters\n" "\n" @@ -602,4 +602,4 @@ msgstr "" "\n" "t = interp.call_in_thread(worker, queue)\n" "print(queue.get())\n" -"t.join()" \ No newline at end of file +"t.join()" diff --git a/library/configparser.po b/library/configparser.po index 2c0f3b1c96f..b47523378fa 100644 --- a/library/configparser.po +++ b/library/configparser.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:41+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!configparser` --- Configuration file parser" msgstr ":mod:`!configparser` --- 設定檔剖析器" -#: ../../library/configparser.rst:14 +#: ../../library/configparser.rst:7 msgid "**Source code:** :source:`Lib/configparser.py`" msgstr "**原始碼:**\\ :source:`Lib/configparser.py`" -#: ../../library/configparser.rst:24 +#: ../../library/configparser.rst:17 msgid "" "This module provides the :class:`ConfigParser` class which implements a " "basic configuration language which provides a structure similar to what's " @@ -33,51 +33,58 @@ msgid "" "programs which can be customized by end users easily." msgstr "" -#: ../../library/configparser.rst:31 +#: ../../library/configparser.rst:24 msgid "" "This library does *not* interpret or write the value-type prefixes used in " "the Windows Registry extended version of INI syntax." msgstr "" -#: ../../library/configparser.rst:36 +#: ../../library/configparser.rst:28 +msgid "" +"Be cautious when parsing data from untrusted sources. A malicious INI file " +"may cause the decoder to consume considerable CPU and memory resources. " +"Limiting the size of data to be parsed is recommended." +msgstr "" + +#: ../../library/configparser.rst:34 msgid "Module :mod:`tomllib`" msgstr ":mod:`tomllib` 模組" -#: ../../library/configparser.rst:37 +#: ../../library/configparser.rst:35 msgid "" "TOML is a well-specified format for application configuration files. It is " "specifically designed to be an improved version of INI." msgstr "" -#: ../../library/configparser.rst:40 +#: ../../library/configparser.rst:38 msgid "Module :mod:`shlex`" msgstr ":mod:`shlex` 模組" -#: ../../library/configparser.rst:41 +#: ../../library/configparser.rst:39 msgid "" "Support for creating Unix shell-like mini-languages which can also be used " "for application configuration files." msgstr "" -#: ../../library/configparser.rst:44 +#: ../../library/configparser.rst:42 msgid "Module :mod:`json`" msgstr ":mod:`json` 模組" -#: ../../library/configparser.rst:45 +#: ../../library/configparser.rst:43 msgid "" "The ``json`` module implements a subset of JavaScript syntax which is " "sometimes used for configuration, but does not support comments." msgstr "" -#: ../../library/configparser.rst:61 +#: ../../library/configparser.rst:59 msgid "Quick Start" msgstr "" -#: ../../library/configparser.rst:63 +#: ../../library/configparser.rst:61 msgid "Let's take a very basic configuration file that looks like this:" msgstr "" -#: ../../library/configparser.rst:65 +#: ../../library/configparser.rst:63 msgid "" "[DEFAULT]\n" "ServerAliveInterval = 45\n" @@ -105,7 +112,7 @@ msgstr "" "Port = 50022\n" "ForwardX11 = no" -#: ../../library/configparser.rst:80 +#: ../../library/configparser.rst:78 msgid "" "The structure of INI files is described `in the following section " "<#supported-ini-file-structure>`_. Essentially, the file consists of " @@ -114,7 +121,7 @@ msgid "" "configuration file programmatically." msgstr "" -#: ../../library/configparser.rst:86 +#: ../../library/configparser.rst:84 msgid "" ">>> import configparser\n" ">>> config = configparser.ConfigParser()\n" @@ -148,20 +155,20 @@ msgstr "" "... config.write(configfile)\n" "..." -#: ../../library/configparser.rst:104 +#: ../../library/configparser.rst:102 msgid "" "As you can see, we can treat a config parser much like a dictionary. There " "are differences, `outlined later <#mapping-protocol-access>`_, but the " "behavior is very close to what you would expect from a dictionary." msgstr "" -#: ../../library/configparser.rst:108 +#: ../../library/configparser.rst:106 msgid "" "Now that we have created and saved a configuration file, let's read it back " "and explore the data it holds." msgstr "" -#: ../../library/configparser.rst:111 +#: ../../library/configparser.rst:109 msgid "" ">>> config = configparser.ConfigParser()\n" ">>> config.sections()\n" @@ -223,7 +230,7 @@ msgstr "" ">>> config['forge.example']['ForwardX11']\n" "'yes'" -#: ../../library/configparser.rst:143 +#: ../../library/configparser.rst:141 msgid "" "As we can see above, the API is pretty straightforward. The only bit of " "magic involves the ``DEFAULT`` section which provides default values for all " @@ -231,7 +238,7 @@ msgid "" "and stored in lowercase [1]_." msgstr "" -#: ../../library/configparser.rst:148 ../../library/configparser.rst:1003 +#: ../../library/configparser.rst:146 ../../library/configparser.rst:1001 msgid "" "It is possible to read several configurations into a single :class:" "`ConfigParser`, where the most recently added configuration has the highest " @@ -241,7 +248,7 @@ msgid "" "``example.ini`` file." msgstr "" -#: ../../library/configparser.rst:155 ../../library/configparser.rst:1010 +#: ../../library/configparser.rst:153 ../../library/configparser.rst:1008 msgid "" "[DEFAULT]\n" "ServerAliveInterval = -1" @@ -249,7 +256,7 @@ msgstr "" "[DEFAULT]\n" "ServerAliveInterval = -1" -#: ../../library/configparser.rst:160 ../../library/configparser.rst:1015 +#: ../../library/configparser.rst:158 ../../library/configparser.rst:1013 msgid "" ">>> config_override = configparser.ConfigParser()\n" ">>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}\n" @@ -273,24 +280,24 @@ msgstr "" ">>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))\n" "-1" -#: ../../library/configparser.rst:174 +#: ../../library/configparser.rst:172 msgid "" "This behaviour is equivalent to a :meth:`ConfigParser.read` call with " "several files passed to the *filenames* parameter." msgstr "" -#: ../../library/configparser.rst:179 +#: ../../library/configparser.rst:177 msgid "Supported Datatypes" msgstr "" -#: ../../library/configparser.rst:181 +#: ../../library/configparser.rst:179 msgid "" "Config parsers do not guess datatypes of values in configuration files, " "always storing them internally as strings. This means that if you need " "other datatypes, you should convert on your own:" msgstr "" -#: ../../library/configparser.rst:185 +#: ../../library/configparser.rst:183 msgid "" ">>> int(topsecret['Port'])\n" "50022\n" @@ -302,7 +309,7 @@ msgstr "" ">>> float(topsecret['CompressionLevel'])\n" "9.0" -#: ../../library/configparser.rst:192 +#: ../../library/configparser.rst:190 msgid "" "Since this task is so common, config parsers provide a range of handy getter " "methods to handle integers, floats and booleans. The last one is the most " @@ -313,7 +320,7 @@ msgid "" "``'true'``/``'false'`` and ``'1'``/``'0'`` [1]_. For example:" msgstr "" -#: ../../library/configparser.rst:200 +#: ../../library/configparser.rst:198 msgid "" ">>> topsecret.getboolean('ForwardX11')\n" "False\n" @@ -329,7 +336,7 @@ msgstr "" ">>> config.getboolean('forge.example', 'Compression')\n" "True" -#: ../../library/configparser.rst:209 +#: ../../library/configparser.rst:207 msgid "" "Apart from :meth:`~ConfigParser.getboolean`, config parsers also provide " "equivalent :meth:`~ConfigParser.getint` and :meth:`~ConfigParser.getfloat` " @@ -337,17 +344,17 @@ msgid "" "ones. [1]_" msgstr "" -#: ../../library/configparser.rst:215 +#: ../../library/configparser.rst:213 msgid "Fallback Values" msgstr "" -#: ../../library/configparser.rst:217 +#: ../../library/configparser.rst:215 msgid "" "As with a dictionary, you can use a section's :meth:`~ConfigParser.get` " "method to provide fallback values:" msgstr "" -#: ../../library/configparser.rst:220 +#: ../../library/configparser.rst:218 msgid "" ">>> topsecret.get('Port')\n" "'50022'\n" @@ -365,7 +372,7 @@ msgstr "" ">>> topsecret.get('Cipher', '3des-cbc')\n" "'3des-cbc'" -#: ../../library/configparser.rst:230 +#: ../../library/configparser.rst:228 msgid "" "Please note that default values have precedence over fallback values. For " "instance, in our example the ``'CompressionLevel'`` key was specified only " @@ -374,7 +381,7 @@ msgid "" "specify a fallback:" msgstr "" -#: ../../library/configparser.rst:236 +#: ../../library/configparser.rst:234 msgid "" ">>> topsecret.get('CompressionLevel', '3')\n" "'9'" @@ -382,7 +389,7 @@ msgstr "" ">>> topsecret.get('CompressionLevel', '3')\n" "'9'" -#: ../../library/configparser.rst:241 +#: ../../library/configparser.rst:239 msgid "" "One more thing to be aware of is that the parser-level :meth:`~ConfigParser." "get` method provides a custom, more complex interface, maintained for " @@ -390,7 +397,7 @@ msgid "" "provided via the ``fallback`` keyword-only argument:" msgstr "" -#: ../../library/configparser.rst:246 +#: ../../library/configparser.rst:244 msgid "" ">>> config.get('forge.example', 'monster',\n" "... fallback='No such things as monsters')\n" @@ -400,14 +407,14 @@ msgstr "" "... fallback='No such things as monsters')\n" "'No such things as monsters'" -#: ../../library/configparser.rst:252 +#: ../../library/configparser.rst:250 msgid "" "The same ``fallback`` argument can be used with the :meth:`~ConfigParser." "getint`, :meth:`~ConfigParser.getfloat` and :meth:`~ConfigParser.getboolean` " "methods, for example:" msgstr "" -#: ../../library/configparser.rst:256 +#: ../../library/configparser.rst:254 msgid "" ">>> 'BatchMode' in topsecret\n" "False\n" @@ -425,11 +432,11 @@ msgstr "" ">>> topsecret.getboolean('BatchMode', fallback=True)\n" "False" -#: ../../library/configparser.rst:268 +#: ../../library/configparser.rst:266 msgid "Supported INI File Structure" msgstr "支援的 INI 檔案結構" -#: ../../library/configparser.rst:270 +#: ../../library/configparser.rst:268 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by a specific string (``=`` " @@ -442,13 +449,13 @@ msgid "" "parts of multiline values or ignored." msgstr "" -#: ../../library/configparser.rst:280 +#: ../../library/configparser.rst:278 msgid "" "By default, a valid section name can be any string that does not contain '\\" "\\n'. To change this, see :attr:`ConfigParser.SECTCRE`." msgstr "" -#: ../../library/configparser.rst:283 +#: ../../library/configparser.rst:281 msgid "" "The first section name may be omitted if the parser is configured to allow " "an unnamed top level section with ``allow_unnamed_section=True``. In this " @@ -456,18 +463,18 @@ msgid "" "``config[UNNAMED_SECTION]``." msgstr "" -#: ../../library/configparser.rst:288 +#: ../../library/configparser.rst:286 msgid "" "Configuration files may include comments, prefixed by specific characters " "(``#`` and ``;`` by default [1]_). Comments may appear on their own on an " "otherwise empty line, possibly indented. [1]_" msgstr "" -#: ../../library/configparser.rst:292 ../../library/configparser.rst:376 +#: ../../library/configparser.rst:290 ../../library/configparser.rst:374 msgid "For example:" msgstr "舉例來說:" -#: ../../library/configparser.rst:294 +#: ../../library/configparser.rst:292 msgid "" "[Simple Values]\n" "key=value\n" @@ -512,17 +519,17 @@ msgid "" " # Did I mention we can indent comments, too?" msgstr "" -#: ../../library/configparser.rst:342 +#: ../../library/configparser.rst:340 msgid "Unnamed Sections" msgstr "" -#: ../../library/configparser.rst:344 +#: ../../library/configparser.rst:342 msgid "" "The name of the first section (or unique) may be omitted and values " "retrieved by the :const:`UNNAMED_SECTION` attribute." msgstr "" -#: ../../library/configparser.rst:347 +#: ../../library/configparser.rst:345 msgid "" ">>> config = \"\"\"\n" "... option = value\n" @@ -546,18 +553,18 @@ msgstr "" ">>> unnamed.get(configparser.UNNAMED_SECTION, 'option')\n" "'value'" -#: ../../library/configparser.rst:361 +#: ../../library/configparser.rst:359 msgid "Interpolation of values" msgstr "" -#: ../../library/configparser.rst:363 +#: ../../library/configparser.rst:361 msgid "" "On top of the core functionality, :class:`ConfigParser` supports " "interpolation. This means values can be preprocessed before returning them " "from ``get()`` calls." msgstr "" -#: ../../library/configparser.rst:371 +#: ../../library/configparser.rst:369 msgid "" "The default implementation used by :class:`ConfigParser`. It enables values " "to contain format strings which refer to other values in the same section, " @@ -565,7 +572,7 @@ msgid "" "can be provided on initialization." msgstr "" -#: ../../library/configparser.rst:378 +#: ../../library/configparser.rst:376 msgid "" "[Paths]\n" "home_dir: /Users\n" @@ -578,7 +585,7 @@ msgid "" "gain: 80%%" msgstr "" -#: ../../library/configparser.rst:389 +#: ../../library/configparser.rst:387 msgid "" "In the example above, :class:`ConfigParser` with *interpolation* set to " "``BasicInterpolation()`` would resolve ``%(home_dir)s`` to the value of " @@ -588,14 +595,14 @@ msgid "" "specific order in the configuration file." msgstr "" -#: ../../library/configparser.rst:396 +#: ../../library/configparser.rst:394 msgid "" "With ``interpolation`` set to ``None``, the parser would simply return " "``%(my_dir)s/Pictures`` as the value of ``my_pictures`` and ``%(home_dir)s/" "lumberjack`` as the value of ``my_dir``." msgstr "" -#: ../../library/configparser.rst:404 +#: ../../library/configparser.rst:402 msgid "" "An alternative handler for interpolation which implements a more advanced " "syntax, used for instance in ``zc.buildout``. Extended interpolation is " @@ -605,13 +612,13 @@ msgid "" "possibly the default values from the special section)." msgstr "" -#: ../../library/configparser.rst:411 +#: ../../library/configparser.rst:409 msgid "" "For example, the configuration specified above with basic interpolation, " "would look like this with extended interpolation:" msgstr "" -#: ../../library/configparser.rst:414 +#: ../../library/configparser.rst:412 msgid "" "[Paths]\n" "home_dir: /Users\n" @@ -624,11 +631,11 @@ msgid "" "cost: $$80" msgstr "" -#: ../../library/configparser.rst:425 +#: ../../library/configparser.rst:423 msgid "Values from other sections can be fetched as well:" msgstr "" -#: ../../library/configparser.rst:427 +#: ../../library/configparser.rst:425 msgid "" "[Common]\n" "home_dir: /Users\n" @@ -664,11 +671,11 @@ msgstr "" "my_pictures: ${my_dir}/Pictures\n" "python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}" -#: ../../library/configparser.rst:447 +#: ../../library/configparser.rst:445 msgid "Mapping Protocol Access" msgstr "" -#: ../../library/configparser.rst:451 +#: ../../library/configparser.rst:449 msgid "" "Mapping protocol access is a generic name for functionality that enables " "using custom objects as if they were dictionaries. In case of :mod:`!" @@ -676,7 +683,7 @@ msgid "" "``parser['section']['option']`` notation." msgstr "" -#: ../../library/configparser.rst:456 +#: ../../library/configparser.rst:454 msgid "" "``parser['section']`` in particular returns a proxy for the section's data " "in the parser. This means that the values are not copied but they are taken " @@ -685,7 +692,7 @@ msgid "" "original parser." msgstr "" -#: ../../library/configparser.rst:462 +#: ../../library/configparser.rst:460 msgid "" ":mod:`!configparser` objects behave as close to actual dictionaries as " "possible. The mapping interface is complete and adheres to the :class:" @@ -693,7 +700,7 @@ msgid "" "that should be taken into account:" msgstr "" -#: ../../library/configparser.rst:467 +#: ../../library/configparser.rst:465 msgid "" "By default, all keys in sections are accessible in a case-insensitive manner " "[1]_. E.g. ``for option in parser[\"section\"]`` yields only " @@ -702,7 +709,7 @@ msgid "" "expressions return ``True``::" msgstr "" -#: ../../library/configparser.rst:472 +#: ../../library/configparser.rst:470 msgid "" "\"a\" in parser[\"section\"]\n" "\"A\" in parser[\"section\"]" @@ -710,7 +717,7 @@ msgstr "" "\"a\" in parser[\"section\"]\n" "\"A\" in parser[\"section\"]" -#: ../../library/configparser.rst:475 +#: ../../library/configparser.rst:473 msgid "" "All sections include ``DEFAULTSECT`` values as well which means that ``." "clear()`` on a section may not leave the section visibly empty. This is " @@ -720,30 +727,30 @@ msgid "" "default value causes a :exc:`KeyError`." msgstr "" -#: ../../library/configparser.rst:482 +#: ../../library/configparser.rst:480 msgid "``DEFAULTSECT`` cannot be removed from the parser:" msgstr "``DEFAULTSECT`` 不能從剖析器中移除:" -#: ../../library/configparser.rst:484 +#: ../../library/configparser.rst:482 msgid "trying to delete it raises :exc:`ValueError`," msgstr "嘗試刪除它會引發 :exc:`ValueError`," -#: ../../library/configparser.rst:486 +#: ../../library/configparser.rst:484 msgid "``parser.clear()`` leaves it intact," msgstr "``parser.clear()`` 會保持它不變," -#: ../../library/configparser.rst:488 +#: ../../library/configparser.rst:486 msgid "``parser.popitem()`` never returns it." msgstr "``parser.popitem()`` 永遠不會回傳它。" -#: ../../library/configparser.rst:490 +#: ../../library/configparser.rst:488 msgid "" "``parser.get(section, option, **kwargs)`` - the second argument is **not** a " "fallback value. Note however that the section-level ``get()`` methods are " "compatible both with the mapping protocol and the classic configparser API." msgstr "" -#: ../../library/configparser.rst:494 +#: ../../library/configparser.rst:492 msgid "" "``parser.items()`` is compatible with the mapping protocol (returns a list " "of *section_name*, *section_proxy* pairs including the DEFAULTSECT). " @@ -753,18 +760,18 @@ msgid "" "(unless ``raw=True`` is provided)." msgstr "" -#: ../../library/configparser.rst:501 +#: ../../library/configparser.rst:499 msgid "" "The mapping protocol is implemented on top of the existing legacy API so " "that subclasses overriding the original interface still should have mappings " "working as expected." msgstr "" -#: ../../library/configparser.rst:507 +#: ../../library/configparser.rst:505 msgid "Customizing Parser Behaviour" msgstr "" -#: ../../library/configparser.rst:509 +#: ../../library/configparser.rst:507 msgid "" "There are nearly as many INI format variants as there are applications using " "it. :mod:`!configparser` goes a long way to provide support for the largest " @@ -773,17 +780,17 @@ msgid "" "customize some of the features." msgstr "" -#: ../../library/configparser.rst:515 +#: ../../library/configparser.rst:513 msgid "" "The most common way to change the way a specific config parser works is to " "use the :meth:`!__init__` options:" msgstr "" -#: ../../library/configparser.rst:518 +#: ../../library/configparser.rst:516 msgid "*defaults*, default value: ``None``" msgstr "" -#: ../../library/configparser.rst:520 +#: ../../library/configparser.rst:518 msgid "" "This option accepts a dictionary of key-value pairs which will be initially " "put in the ``DEFAULT`` section. This makes for an elegant way to support " @@ -791,17 +798,17 @@ msgid "" "the documented default." msgstr "" -#: ../../library/configparser.rst:525 +#: ../../library/configparser.rst:523 msgid "" "Hint: if you want to specify default values for a specific section, use :" "meth:`~ConfigParser.read_dict` before you read the actual file." msgstr "" -#: ../../library/configparser.rst:528 +#: ../../library/configparser.rst:526 msgid "*dict_type*, default value: :class:`dict`" msgstr "" -#: ../../library/configparser.rst:530 +#: ../../library/configparser.rst:528 msgid "" "This option has a major impact on how the mapping protocol will behave and " "how the written configuration files look. With the standard dictionary, " @@ -809,20 +816,20 @@ msgid "" "goes for options within sections." msgstr "" -#: ../../library/configparser.rst:535 +#: ../../library/configparser.rst:533 msgid "" "An alternative dictionary type can be used for example to sort sections and " "options on write-back." msgstr "" -#: ../../library/configparser.rst:538 +#: ../../library/configparser.rst:536 msgid "" "Please note: there are ways to add a set of key-value pairs in a single " "operation. When you use a regular dictionary in those operations, the order " "of the keys will be ordered. For example:" msgstr "" -#: ../../library/configparser.rst:542 +#: ../../library/configparser.rst:540 msgid "" ">>> parser = configparser.ConfigParser()\n" ">>> parser.read_dict({'section1': {'key1': 'value1',\n" @@ -856,11 +863,11 @@ msgstr "" ">>> [option for option in parser['section3']]\n" "['foo', 'bar', 'baz']" -#: ../../library/configparser.rst:560 +#: ../../library/configparser.rst:558 msgid "*allow_no_value*, default value: ``False``" msgstr "" -#: ../../library/configparser.rst:562 +#: ../../library/configparser.rst:560 msgid "" "Some configuration files are known to include settings without values, but " "which otherwise conform to the syntax supported by :mod:`!configparser`. " @@ -868,7 +875,7 @@ msgid "" "that such values should be accepted:" msgstr "" -#: ../../library/configparser.rst:567 +#: ../../library/configparser.rst:565 msgid "" ">>> import configparser\n" "\n" @@ -899,32 +906,32 @@ msgid "" "KeyError: 'does-not-exist'" msgstr "" -#: ../../library/configparser.rst:597 +#: ../../library/configparser.rst:595 msgid "*delimiters*, default value: ``('=', ':')``" msgstr "" -#: ../../library/configparser.rst:599 +#: ../../library/configparser.rst:597 msgid "" "Delimiters are substrings that delimit keys from values within a section. " "The first occurrence of a delimiting substring on a line is considered a " "delimiter. This means values (but not keys) can contain the delimiters." msgstr "" -#: ../../library/configparser.rst:603 +#: ../../library/configparser.rst:601 msgid "" "See also the *space_around_delimiters* argument to :meth:`ConfigParser." "write`." msgstr "" -#: ../../library/configparser.rst:606 +#: ../../library/configparser.rst:604 msgid "*comment_prefixes*, default value: ``('#', ';')``" msgstr "" -#: ../../library/configparser.rst:608 +#: ../../library/configparser.rst:606 msgid "*inline_comment_prefixes*, default value: ``None``" msgstr "" -#: ../../library/configparser.rst:610 +#: ../../library/configparser.rst:608 msgid "" "Comment prefixes are strings that indicate the start of a valid comment " "within a config file. *comment_prefixes* are used only on otherwise empty " @@ -934,13 +941,13 @@ msgid "" "used as prefixes for whole line comments." msgstr "" -#: ../../library/configparser.rst:617 +#: ../../library/configparser.rst:615 msgid "" "In previous versions of :mod:`!configparser` behaviour matched " "``comment_prefixes=('#',';')`` and ``inline_comment_prefixes=(';',)``." msgstr "" -#: ../../library/configparser.rst:621 +#: ../../library/configparser.rst:619 msgid "" "Please note that config parsers don't support escaping of comment prefixes " "so using *inline_comment_prefixes* may prevent users from specifying option " @@ -950,7 +957,7 @@ msgid "" "values is to interpolate the prefix, for example::" msgstr "" -#: ../../library/configparser.rst:628 +#: ../../library/configparser.rst:626 msgid "" ">>> from configparser import ConfigParser, ExtendedInterpolation\n" ">>> parser = ConfigParser(interpolation=ExtendedInterpolation())\n" @@ -992,11 +999,11 @@ msgid "" "line #3" msgstr "" -#: ../../library/configparser.rst:667 +#: ../../library/configparser.rst:665 msgid "*strict*, default value: ``True``" msgstr "" -#: ../../library/configparser.rst:669 +#: ../../library/configparser.rst:667 msgid "" "When set to ``True``, the parser will not allow for any section or option " "duplicates while reading from a single source (using :meth:`~ConfigParser." @@ -1004,17 +1011,17 @@ msgid "" "read_dict`). It is recommended to use strict parsers in new applications." msgstr "" -#: ../../library/configparser.rst:674 +#: ../../library/configparser.rst:672 msgid "" "In previous versions of :mod:`!configparser` behaviour matched " "``strict=False``." msgstr "" -#: ../../library/configparser.rst:678 +#: ../../library/configparser.rst:676 msgid "*empty_lines_in_values*, default value: ``True``" msgstr "" -#: ../../library/configparser.rst:680 +#: ../../library/configparser.rst:678 msgid "" "In config parsers, values can span multiple lines as long as they are " "indented more than the key that holds them. By default parsers also let " @@ -1024,7 +1031,7 @@ msgid "" "lose track of the file structure. Take for instance:" msgstr "" -#: ../../library/configparser.rst:687 +#: ../../library/configparser.rst:685 msgid "" "[Section]\n" "key = multiline\n" @@ -1038,7 +1045,7 @@ msgstr "" "\n" " this = is still a part of the multiline value of 'key'" -#: ../../library/configparser.rst:695 +#: ../../library/configparser.rst:693 msgid "" "This can be especially problematic for the user to see if she's using a " "proportional font to edit the file. That is why when your application does " @@ -1047,13 +1054,13 @@ msgid "" "would produce two keys, ``key`` and ``this``." msgstr "" -#: ../../library/configparser.rst:701 +#: ../../library/configparser.rst:699 msgid "" "*default_section*, default value: ``configparser.DEFAULTSECT`` (that is: " "``\"DEFAULT\"``)" msgstr "" -#: ../../library/configparser.rst:704 +#: ../../library/configparser.rst:702 msgid "" "The convention of allowing a special section of default values for other " "sections or interpolation purposes is a powerful concept of this library, " @@ -1067,11 +1074,11 @@ msgid "" "files from one format to another)." msgstr "" -#: ../../library/configparser.rst:715 +#: ../../library/configparser.rst:713 msgid "*interpolation*, default value: ``configparser.BasicInterpolation``" msgstr "" -#: ../../library/configparser.rst:717 +#: ../../library/configparser.rst:715 msgid "" "Interpolation behaviour may be customized by providing a custom handler " "through the *interpolation* argument. ``None`` can be used to turn off " @@ -1081,11 +1088,11 @@ msgid "" "`RawConfigParser` has a default value of ``None``." msgstr "" -#: ../../library/configparser.rst:724 +#: ../../library/configparser.rst:722 msgid "*converters*, default value: not set" msgstr "" -#: ../../library/configparser.rst:726 +#: ../../library/configparser.rst:724 msgid "" "Config parsers provide option value getters that perform type conversion. " "By default :meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat`, " @@ -1099,7 +1106,7 @@ msgid "" "``parser_instance['section'].getdecimal('key', 0)``." msgstr "" -#: ../../library/configparser.rst:737 +#: ../../library/configparser.rst:735 msgid "" "If the converter needs to access the state of the parser, it can be " "implemented as a method on a config parser subclass. If the name of this " @@ -1107,14 +1114,14 @@ msgid "" "the dict-compatible form (see the ``getdecimal()`` example above)." msgstr "" -#: ../../library/configparser.rst:742 +#: ../../library/configparser.rst:740 msgid "" "More advanced customization may be achieved by overriding default values of " "these parser attributes. The defaults are defined on the classes, so they " "may be overridden by subclasses or by attribute assignment." msgstr "" -#: ../../library/configparser.rst:748 +#: ../../library/configparser.rst:746 msgid "" "By default when using :meth:`~ConfigParser.getboolean`, config parsers " "consider the following values ``True``: ``'1'``, ``'yes'``, ``'true'``, " @@ -1123,7 +1130,7 @@ msgid "" "strings and their Boolean outcomes. For example:" msgstr "" -#: ../../library/configparser.rst:754 +#: ../../library/configparser.rst:752 msgid "" ">>> custom = configparser.ConfigParser()\n" ">>> custom['section1'] = {'funky': 'nope'}\n" @@ -1145,13 +1152,13 @@ msgstr "" ">>> custom['section1'].getboolean('funky')\n" "False" -#: ../../library/configparser.rst:766 +#: ../../library/configparser.rst:764 msgid "" "Other typical Boolean pairs include ``accept``/``reject`` or ``enabled``/" "``disabled``." msgstr "" -#: ../../library/configparser.rst:772 +#: ../../library/configparser.rst:770 msgid "" "This method transforms option names on every read, get, or set operation. " "The default converts the name to lowercase. This also means that when a " @@ -1159,7 +1166,7 @@ msgid "" "method if that's unsuitable. For example:" msgstr "" -#: ../../library/configparser.rst:778 +#: ../../library/configparser.rst:776 msgid "" ">>> config = \"\"\"\n" "... [Section1]\n" @@ -1203,14 +1210,14 @@ msgstr "" ">>> list(custom['Section2'].keys())\n" "['AnotherKey']" -#: ../../library/configparser.rst:802 +#: ../../library/configparser.rst:800 msgid "" "The optionxform function transforms option names to a canonical form. This " "should be an idempotent function: if the name is already in canonical form, " "it should be returned unchanged." msgstr "" -#: ../../library/configparser.rst:809 +#: ../../library/configparser.rst:807 msgid "" "A compiled regular expression used to parse section headers. The default " "matches ``[section]`` to the name ``\"section\"``. Whitespace is considered " @@ -1219,7 +1226,7 @@ msgid "" "example:" msgstr "" -#: ../../library/configparser.rst:815 +#: ../../library/configparser.rst:813 msgid "" ">>> import re\n" ">>> config = \"\"\"\n" @@ -1257,18 +1264,18 @@ msgstr "" ">>> custom.sections()\n" "['Section 1', 'Section 2']" -#: ../../library/configparser.rst:837 +#: ../../library/configparser.rst:835 msgid "" "While ConfigParser objects also use an ``OPTCRE`` attribute for recognizing " "option lines, it's not recommended to override it because that would " "interfere with constructor options *allow_no_value* and *delimiters*." msgstr "" -#: ../../library/configparser.rst:843 +#: ../../library/configparser.rst:841 msgid "Legacy API Examples" msgstr "" -#: ../../library/configparser.rst:845 +#: ../../library/configparser.rst:843 msgid "" "Mainly because of backwards compatibility concerns, :mod:`!configparser` " "provides also a legacy API with explicit ``get``/``set`` methods. While " @@ -1277,11 +1284,11 @@ msgid "" "advanced, low-level and downright counterintuitive." msgstr "" -#: ../../library/configparser.rst:851 +#: ../../library/configparser.rst:849 msgid "An example of writing to a configuration file::" msgstr "" -#: ../../library/configparser.rst:853 +#: ../../library/configparser.rst:851 msgid "" "import configparser\n" "\n" @@ -1305,11 +1312,11 @@ msgid "" " config.write(configfile)" msgstr "" -#: ../../library/configparser.rst:874 +#: ../../library/configparser.rst:872 msgid "An example of reading the configuration file again::" msgstr "" -#: ../../library/configparser.rst:876 +#: ../../library/configparser.rst:874 msgid "" "import configparser\n" "\n" @@ -1328,11 +1335,11 @@ msgid "" " print(config.get('Section1', 'foo'))" msgstr "" -#: ../../library/configparser.rst:892 +#: ../../library/configparser.rst:890 msgid "To get interpolation, use :class:`ConfigParser`::" msgstr "" -#: ../../library/configparser.rst:894 +#: ../../library/configparser.rst:892 msgid "" "import configparser\n" "\n" @@ -1367,13 +1374,13 @@ msgid "" " # -> None" msgstr "" -#: ../../library/configparser.rst:925 +#: ../../library/configparser.rst:923 msgid "" "Default values are available in both types of ConfigParsers. They are used " "in interpolation if an option used is not defined elsewhere. ::" msgstr "" -#: ../../library/configparser.rst:928 +#: ../../library/configparser.rst:926 msgid "" "import configparser\n" "\n" @@ -1387,11 +1394,11 @@ msgid "" "print(config.get('Section1', 'foo')) # -> \"Life is hard!\"" msgstr "" -#: ../../library/configparser.rst:943 +#: ../../library/configparser.rst:941 msgid "ConfigParser Objects" msgstr "ConfigParser 物件" -#: ../../library/configparser.rst:953 +#: ../../library/configparser.rst:951 msgid "" "The main configuration parser. When *defaults* is given, it is initialized " "into the dictionary of intrinsic defaults. When *dict_type* is given, it " @@ -1399,7 +1406,7 @@ msgid "" "the options within a section, and for the default values." msgstr "" -#: ../../library/configparser.rst:958 +#: ../../library/configparser.rst:956 msgid "" "When *delimiters* is given, it is used as the set of substrings that divide " "keys from values. When *comment_prefixes* is given, it will be used as the " @@ -1408,7 +1415,7 @@ msgid "" "as the set of substrings that prefix comments in non-empty lines." msgstr "" -#: ../../library/configparser.rst:964 +#: ../../library/configparser.rst:962 msgid "" "When *strict* is ``True`` (the default), the parser won't allow for any " "section or option duplicates while reading from a single source (file, " @@ -1421,7 +1428,7 @@ msgid "" "without the trailing delimiter." msgstr "" -#: ../../library/configparser.rst:974 +#: ../../library/configparser.rst:972 msgid "" "When *default_section* is given, it specifies the name for the special " "section holding default values for other sections and interpolation purposes " @@ -1431,7 +1438,7 @@ msgid "" "settings to a new config file." msgstr "" -#: ../../library/configparser.rst:981 +#: ../../library/configparser.rst:979 msgid "" "Interpolation behaviour may be customized by providing a custom handler " "through the *interpolation* argument. ``None`` can be used to turn off " @@ -1440,7 +1447,7 @@ msgid "" "`dedicated documentation section <#interpolation-of-values>`_." msgstr "" -#: ../../library/configparser.rst:987 +#: ../../library/configparser.rst:985 msgid "" "All option names used in interpolation will be passed through the :meth:" "`optionxform` method just like any other option name reference. For " @@ -1449,7 +1456,7 @@ msgid "" "%(BAR)s`` are equivalent." msgstr "" -#: ../../library/configparser.rst:993 +#: ../../library/configparser.rst:991 msgid "" "When *converters* is given, it should be a dictionary where each key " "represents the name of a type converter and each value is a callable " @@ -1458,61 +1465,61 @@ msgid "" "object and section proxies." msgstr "" -#: ../../library/configparser.rst:999 +#: ../../library/configparser.rst:997 msgid "" "When *allow_unnamed_section* is ``True`` (default: ``False``), the first " "section name can be omitted. See the `\"Unnamed Sections\" section <#unnamed-" "sections>`_." msgstr "" -#: ../../library/configparser.rst:1028 +#: ../../library/configparser.rst:1026 msgid "The default *dict_type* is :class:`collections.OrderedDict`." msgstr "預設的 *dict_type* 是 :class:`collections.OrderedDict`。" -#: ../../library/configparser.rst:1031 ../../library/configparser.rst:1324 +#: ../../library/configparser.rst:1029 ../../library/configparser.rst:1322 msgid "" "*allow_no_value*, *delimiters*, *comment_prefixes*, *strict*, " "*empty_lines_in_values*, *default_section* and *interpolation* were added." msgstr "" -#: ../../library/configparser.rst:1036 ../../library/configparser.rst:1329 +#: ../../library/configparser.rst:1034 ../../library/configparser.rst:1327 msgid "The *converters* argument was added." msgstr "新增 *converters* 引數。" -#: ../../library/configparser.rst:1039 +#: ../../library/configparser.rst:1037 msgid "" "The *defaults* argument is read with :meth:`read_dict`, providing consistent " "behavior across the parser: non-string keys and values are implicitly " "converted to strings." msgstr "" -#: ../../library/configparser.rst:1044 ../../library/configparser.rst:1332 +#: ../../library/configparser.rst:1042 ../../library/configparser.rst:1330 msgid "" "The default *dict_type* is :class:`dict`, since it now preserves insertion " "order." msgstr "" -#: ../../library/configparser.rst:1048 +#: ../../library/configparser.rst:1046 msgid "" "Raise a :exc:`MultilineContinuationError` when *allow_no_value* is ``True``, " "and a key without a value is continued with an indented line." msgstr "" -#: ../../library/configparser.rst:1052 ../../library/configparser.rst:1336 +#: ../../library/configparser.rst:1050 ../../library/configparser.rst:1334 msgid "The *allow_unnamed_section* argument was added." msgstr "新增 *allow_unnamed_section* 引數。" -#: ../../library/configparser.rst:1057 +#: ../../library/configparser.rst:1055 msgid "Return a dictionary containing the instance-wide defaults." msgstr "回傳包含整個實例預設值的字典。" -#: ../../library/configparser.rst:1062 +#: ../../library/configparser.rst:1060 msgid "" "Return a list of the sections available; the *default section* is not " "included in the list." msgstr "" -#: ../../library/configparser.rst:1068 +#: ../../library/configparser.rst:1066 msgid "" "Add a section named *section* to the instance. If a section by the given " "name already exists, :exc:`DuplicateSectionError` is raised. If the " @@ -1520,34 +1527,34 @@ msgid "" "the section must be a string; if not, :exc:`TypeError` is raised." msgstr "" -#: ../../library/configparser.rst:1073 +#: ../../library/configparser.rst:1071 msgid "Non-string section names raise :exc:`TypeError`." msgstr "" -#: ../../library/configparser.rst:1079 +#: ../../library/configparser.rst:1077 msgid "" "Indicates whether the named *section* is present in the configuration. The " "*default section* is not acknowledged." msgstr "" -#: ../../library/configparser.rst:1085 +#: ../../library/configparser.rst:1083 msgid "Return a list of options available in the specified *section*." msgstr "" -#: ../../library/configparser.rst:1090 +#: ../../library/configparser.rst:1088 msgid "" "If the given *section* exists, and contains the given *option*, return :" "const:`True`; otherwise return :const:`False`. If the specified *section* " "is :const:`None` or an empty string, DEFAULT is assumed." msgstr "" -#: ../../library/configparser.rst:1097 +#: ../../library/configparser.rst:1095 msgid "" "Attempt to read and parse an iterable of filenames, returning a list of " "filenames which were successfully parsed." msgstr "" -#: ../../library/configparser.rst:1100 +#: ../../library/configparser.rst:1098 msgid "" "If *filenames* is a string, a :class:`bytes` object or a :term:`path-like " "object`, it is treated as a single filename. If a file named in *filenames* " @@ -1558,7 +1565,7 @@ msgid "" "be read." msgstr "" -#: ../../library/configparser.rst:1109 +#: ../../library/configparser.rst:1107 msgid "" "If none of the named files exist, the :class:`ConfigParser` instance will " "contain an empty dataset. An application which requires initial values to " @@ -1566,7 +1573,7 @@ msgid "" "`read_file` before calling :meth:`read` for any optional files::" msgstr "" -#: ../../library/configparser.rst:1115 +#: ../../library/configparser.rst:1113 msgid "" "import configparser, os\n" "\n" @@ -1582,49 +1589,49 @@ msgstr "" "config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')],\n" " encoding='cp1250')" -#: ../../library/configparser.rst:1122 +#: ../../library/configparser.rst:1120 msgid "" "Added the *encoding* parameter. Previously, all files were read using the " "default encoding for :func:`open`." msgstr "" -#: ../../library/configparser.rst:1126 +#: ../../library/configparser.rst:1124 msgid "The *filenames* parameter accepts a :term:`path-like object`." msgstr "" -#: ../../library/configparser.rst:1129 +#: ../../library/configparser.rst:1127 msgid "The *filenames* parameter accepts a :class:`bytes` object." msgstr "" -#: ../../library/configparser.rst:1135 +#: ../../library/configparser.rst:1133 msgid "" "Read and parse configuration data from *f* which must be an iterable " "yielding Unicode strings (for example files opened in text mode)." msgstr "" -#: ../../library/configparser.rst:1138 +#: ../../library/configparser.rst:1136 msgid "" "Optional argument *source* specifies the name of the file being read. If " "not given and *f* has a :attr:`!name` attribute, that is used for *source*; " "the default is ``''``." msgstr "" -#: ../../library/configparser.rst:1142 +#: ../../library/configparser.rst:1140 msgid "Replaces :meth:`!readfp`." msgstr "取代 :meth:`!readfp`。" -#: ../../library/configparser.rst:1147 +#: ../../library/configparser.rst:1145 msgid "Parse configuration data from a string." msgstr "" -#: ../../library/configparser.rst:1149 +#: ../../library/configparser.rst:1147 msgid "" "Optional argument *source* specifies a context-specific name of the string " "passed. If not given, ``''`` is used. This should commonly be a " "filesystem path or a URL." msgstr "" -#: ../../library/configparser.rst:1158 +#: ../../library/configparser.rst:1156 msgid "" "Load configuration from any object that provides a dict-like ``items()`` " "method. Keys are section names, values are dictionaries with keys and " @@ -1633,17 +1640,17 @@ msgid "" "automatically converted to strings." msgstr "" -#: ../../library/configparser.rst:1164 +#: ../../library/configparser.rst:1162 msgid "" "Optional argument *source* specifies a context-specific name of the " "dictionary passed. If not given, ```` is used." msgstr "" -#: ../../library/configparser.rst:1167 +#: ../../library/configparser.rst:1165 msgid "This method can be used to copy state between parsers." msgstr "" -#: ../../library/configparser.rst:1174 +#: ../../library/configparser.rst:1172 msgid "" "Get an *option* value for the named *section*. If *vars* is provided, it " "must be a dictionary. The *option* is looked up in *vars* (if provided), " @@ -1652,35 +1659,35 @@ msgid "" "provided as a *fallback* value." msgstr "" -#: ../../library/configparser.rst:1180 +#: ../../library/configparser.rst:1178 msgid "" "All the ``'%'`` interpolations are expanded in the return values, unless the " "*raw* argument is true. Values for interpolation keys are looked up in the " "same manner as the option." msgstr "" -#: ../../library/configparser.rst:1184 +#: ../../library/configparser.rst:1182 msgid "" "Arguments *raw*, *vars* and *fallback* are keyword only to protect users " "from trying to use the third argument as the *fallback* fallback (especially " "when using the mapping protocol)." msgstr "" -#: ../../library/configparser.rst:1192 +#: ../../library/configparser.rst:1190 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to an integer. See :meth:`get` for explanation of *raw*, *vars* and " "*fallback*." msgstr "" -#: ../../library/configparser.rst:1199 +#: ../../library/configparser.rst:1197 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to a floating-point number. See :meth:`get` for explanation of *raw*, " "*vars* and *fallback*." msgstr "" -#: ../../library/configparser.rst:1206 +#: ../../library/configparser.rst:1204 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to a Boolean value. Note that the accepted values for the option are " @@ -1692,34 +1699,34 @@ msgid "" "*fallback*." msgstr "" -#: ../../library/configparser.rst:1219 +#: ../../library/configparser.rst:1217 msgid "" "When *section* is not given, return a list of *section_name*, " "*section_proxy* pairs, including DEFAULTSECT." msgstr "" -#: ../../library/configparser.rst:1222 +#: ../../library/configparser.rst:1220 msgid "" "Otherwise, return a list of *name*, *value* pairs for the options in the " "given *section*. Optional arguments have the same meaning as for the :meth:" "`get` method." msgstr "" -#: ../../library/configparser.rst:1226 +#: ../../library/configparser.rst:1224 msgid "" "Items present in *vars* no longer appear in the result. The previous " "behaviour mixed actual parser options with variables provided for " "interpolation." msgstr "" -#: ../../library/configparser.rst:1234 +#: ../../library/configparser.rst:1232 msgid "" "If the given section exists, set the given option to the specified value; " "otherwise raise :exc:`NoSectionError`. *option* and *value* must be " "strings; if not, :exc:`TypeError` is raised." msgstr "" -#: ../../library/configparser.rst:1241 +#: ../../library/configparser.rst:1239 msgid "" "Write a representation of the configuration to the specified :term:`file " "object`, which must be opened in text mode (accepting strings). This " @@ -1728,33 +1735,33 @@ msgid "" "surrounded by spaces." msgstr "" -#: ../../library/configparser.rst:1247 +#: ../../library/configparser.rst:1245 msgid "" "Raises InvalidWriteError if this would write a representation which cannot " "be accurately parsed by a future :meth:`read` call from this parser." msgstr "" -#: ../../library/configparser.rst:1253 +#: ../../library/configparser.rst:1251 msgid "" "Comments in the original configuration file are not preserved when writing " "the configuration back. What is considered a comment, depends on the given " "values for *comment_prefix* and *inline_comment_prefix*." msgstr "" -#: ../../library/configparser.rst:1261 +#: ../../library/configparser.rst:1259 msgid "" "Remove the specified *option* from the specified *section*. If the section " "does not exist, raise :exc:`NoSectionError`. If the option existed to be " "removed, return :const:`True`; otherwise return :const:`False`." msgstr "" -#: ../../library/configparser.rst:1269 +#: ../../library/configparser.rst:1267 msgid "" "Remove the specified *section* from the configuration. If the section in " "fact existed, return ``True``. Otherwise return ``False``." msgstr "" -#: ../../library/configparser.rst:1275 +#: ../../library/configparser.rst:1273 msgid "" "Transforms the option name *option* as found in an input file or as passed " "in by client code to the form that should be used in the internal " @@ -1763,7 +1770,7 @@ msgid "" "of this name on instances to affect this behavior." msgstr "" -#: ../../library/configparser.rst:1281 +#: ../../library/configparser.rst:1279 msgid "" "You don't need to subclass the parser to use this method, you can also set " "it on an instance, to a function that takes a string argument and returns a " @@ -1771,7 +1778,7 @@ msgid "" "sensitive::" msgstr "" -#: ../../library/configparser.rst:1286 +#: ../../library/configparser.rst:1284 msgid "" "cfgparser = ConfigParser()\n" "cfgparser.optionxform = str" @@ -1779,30 +1786,30 @@ msgstr "" "cfgparser = ConfigParser()\n" "cfgparser.optionxform = str" -#: ../../library/configparser.rst:1289 +#: ../../library/configparser.rst:1287 msgid "" "Note that when reading configuration files, whitespace around the option " "names is stripped before :meth:`optionxform` is called." msgstr "" -#: ../../library/configparser.rst:1295 +#: ../../library/configparser.rst:1293 msgid "" "A special object representing a section name used to reference the unnamed " "section (see :ref:`unnamed-sections`)." msgstr "" -#: ../../library/configparser.rst:1300 +#: ../../library/configparser.rst:1298 msgid "" "The maximum depth for recursive interpolation for :meth:`~configparser." "ConfigParser.get` when the *raw* parameter is false. This is relevant only " "when the default *interpolation* is used." msgstr "" -#: ../../library/configparser.rst:1308 +#: ../../library/configparser.rst:1306 msgid "RawConfigParser Objects" msgstr "RawConfigParser 物件" -#: ../../library/configparser.rst:1319 +#: ../../library/configparser.rst:1317 msgid "" "Legacy variant of the :class:`ConfigParser`. It has interpolation disabled " "by default and allows for non-string section names, option names, and values " @@ -1810,19 +1817,19 @@ msgid "" "``defaults=`` keyword argument handling." msgstr "" -#: ../../library/configparser.rst:1340 +#: ../../library/configparser.rst:1338 msgid "" "Consider using :class:`ConfigParser` instead which checks types of the " "values to be stored internally. If you don't want interpolation, you can " "use ``ConfigParser(interpolation=None)``." msgstr "" -#: ../../library/configparser.rst:1347 +#: ../../library/configparser.rst:1345 msgid "" "Add a section named *section* or :const:`UNNAMED_SECTION` to the instance." msgstr "" -#: ../../library/configparser.rst:1349 +#: ../../library/configparser.rst:1347 msgid "" "If the given section already exists, :exc:`DuplicateSectionError` is raised. " "If the *default section* name is passed, :exc:`ValueError` is raised. If :" @@ -1830,17 +1837,17 @@ msgid "" "`UnnamedSectionDisabledError` is raised." msgstr "" -#: ../../library/configparser.rst:1354 +#: ../../library/configparser.rst:1352 msgid "" "Type of *section* is not checked which lets users create non-string named " "sections. This behaviour is unsupported and may cause internal errors." msgstr "" -#: ../../library/configparser.rst:1357 +#: ../../library/configparser.rst:1355 msgid "Added support for :const:`UNNAMED_SECTION`." msgstr "新增對 :const:`UNNAMED_SECTION` 的支援。" -#: ../../library/configparser.rst:1363 +#: ../../library/configparser.rst:1361 msgid "" "If the given section exists, set the given option to the specified value; " "otherwise raise :exc:`NoSectionError`. While it is possible to use :class:" @@ -1850,7 +1857,7 @@ msgid "" "string values." msgstr "" -#: ../../library/configparser.rst:1370 +#: ../../library/configparser.rst:1368 msgid "" "This method lets users assign non-string values to keys internally. This " "behaviour is unsupported and will cause errors when attempting to write to a " @@ -1858,32 +1865,32 @@ msgid "" "not allow such assignments to take place." msgstr "" -#: ../../library/configparser.rst:1377 +#: ../../library/configparser.rst:1375 msgid "Exceptions" msgstr "例外" -#: ../../library/configparser.rst:1381 +#: ../../library/configparser.rst:1379 msgid "Base class for all other :mod:`!configparser` exceptions." msgstr "" -#: ../../library/configparser.rst:1386 +#: ../../library/configparser.rst:1384 msgid "Exception raised when a specified section is not found." msgstr "" -#: ../../library/configparser.rst:1391 +#: ../../library/configparser.rst:1389 msgid "" "Exception raised if :meth:`~ConfigParser.add_section` is called with the " "name of a section that is already present or in strict parsers when a " "section if found more than once in a single input file, string or dictionary." msgstr "" -#: ../../library/configparser.rst:1395 +#: ../../library/configparser.rst:1393 msgid "" "Added the optional *source* and *lineno* attributes and parameters to :meth:" "`!__init__`." msgstr "" -#: ../../library/configparser.rst:1402 +#: ../../library/configparser.rst:1400 msgid "" "Exception raised by strict parsers if a single option appears twice during " "reading from a single file, string or dictionary. This catches misspellings " @@ -1891,117 +1898,117 @@ msgid "" "representing the same case-insensitive configuration key." msgstr "" -#: ../../library/configparser.rst:1410 +#: ../../library/configparser.rst:1408 msgid "" "Exception raised when a specified option is not found in the specified " "section." msgstr "" -#: ../../library/configparser.rst:1416 +#: ../../library/configparser.rst:1414 msgid "" "Base class for exceptions raised when problems occur performing string " "interpolation." msgstr "" -#: ../../library/configparser.rst:1422 +#: ../../library/configparser.rst:1420 msgid "" "Exception raised when string interpolation cannot be completed because the " "number of iterations exceeds :const:`MAX_INTERPOLATION_DEPTH`. Subclass of :" "exc:`InterpolationError`." msgstr "" -#: ../../library/configparser.rst:1429 +#: ../../library/configparser.rst:1427 msgid "" "Exception raised when an option referenced from a value does not exist. " "Subclass of :exc:`InterpolationError`." msgstr "" -#: ../../library/configparser.rst:1435 +#: ../../library/configparser.rst:1433 msgid "" "Exception raised when the source text into which substitutions are made does " "not conform to the required syntax. Subclass of :exc:`InterpolationError`." msgstr "" -#: ../../library/configparser.rst:1441 +#: ../../library/configparser.rst:1439 msgid "" "Exception raised when attempting to parse a file which has no section " "headers." msgstr "" -#: ../../library/configparser.rst:1446 +#: ../../library/configparser.rst:1444 msgid "Exception raised when errors occur attempting to parse a file." msgstr "" -#: ../../library/configparser.rst:1448 +#: ../../library/configparser.rst:1446 msgid "" "The ``filename`` attribute and :meth:`!__init__` constructor argument were " "removed. They have been available using the name ``source`` since 3.2." msgstr "" -#: ../../library/configparser.rst:1454 +#: ../../library/configparser.rst:1452 msgid "" "Exception raised when a key without a corresponding value is continued with " "an indented line." msgstr "" -#: ../../library/configparser.rst:1461 +#: ../../library/configparser.rst:1459 msgid "" "Exception raised when attempting to use the :const:`UNNAMED_SECTION` without " "enabling it." msgstr "" -#: ../../library/configparser.rst:1468 +#: ../../library/configparser.rst:1466 msgid "" "Exception raised when an attempted :meth:`ConfigParser.write` would not be " "parsed accurately with a future :meth:`ConfigParser.read` call." msgstr "" -#: ../../library/configparser.rst:1471 +#: ../../library/configparser.rst:1469 msgid "" "Ex: Writing a key beginning with the :attr:`ConfigParser.SECTCRE` pattern " "would parse as a section header when read. Attempting to write this will " "raise this exception." msgstr "" -#: ../../library/configparser.rst:1478 +#: ../../library/configparser.rst:1476 msgid "Footnotes" msgstr "註腳" -#: ../../library/configparser.rst:1479 +#: ../../library/configparser.rst:1477 msgid "" "Config parsers allow for heavy customization. If you are interested in " "changing the behaviour outlined by the footnote reference, consult the " "`Customizing Parser Behaviour`_ section." msgstr "" -#: ../../library/configparser.rst:16 +#: ../../library/configparser.rst:9 msgid ".ini" msgstr ".ini" -#: ../../library/configparser.rst:16 +#: ../../library/configparser.rst:9 msgid "file" msgstr "file(檔案)" -#: ../../library/configparser.rst:16 +#: ../../library/configparser.rst:9 msgid "configuration" msgstr "configuration(設定)" -#: ../../library/configparser.rst:16 +#: ../../library/configparser.rst:9 msgid "ini file" msgstr "ini file(ini 檔案)" -#: ../../library/configparser.rst:16 +#: ../../library/configparser.rst:9 msgid "Windows ini file" msgstr "Windows ini file(Windows ini 檔案)" -#: ../../library/configparser.rst:367 +#: ../../library/configparser.rst:365 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/configparser.rst:367 ../../library/configparser.rst:400 +#: ../../library/configparser.rst:365 ../../library/configparser.rst:398 msgid "interpolation in configuration files" msgstr "interpolation in configuration files(設定檔中的插值)" -#: ../../library/configparser.rst:400 +#: ../../library/configparser.rst:398 msgid "$ (dollar)" msgstr "$ (金錢符號)" diff --git a/library/contextlib.po b/library/contextlib.po index d7185288ffd..755b0b1703d 100644 --- a/library/contextlib.po +++ b/library/contextlib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:41+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -498,14 +498,14 @@ msgstr "" #: ../../library/contextlib.rst:329 msgid "" -"Context manager for temporarily redirecting :data:`sys.stdout` to another " -"file or file-like object." +"Context manager for temporarily redirecting :data:`sys.stdout` to another :" +"term:`file object`." msgstr "" #: ../../library/contextlib.rst:332 msgid "" "This tool adds flexibility to existing functions or classes whose output is " -"hardwired to stdout." +"hardwired to :data:`sys.stdout`." msgstr "" #: ../../library/contextlib.rst:335 @@ -565,8 +565,8 @@ msgstr "" #: ../../library/contextlib.rst:369 msgid "" -"Similar to :func:`~contextlib.redirect_stdout` but redirecting :data:`sys." -"stderr` to another file or file-like object." +"Similar to :func:`~contextlib.redirect_stdout` but redirecting the global :" +"data:`sys.stderr` to another :term:`file object`." msgstr "" #: ../../library/contextlib.rst:379 @@ -632,7 +632,7 @@ msgstr "" " print('Finishing')\n" " return False" -#: ../../library/contextlib.rst:419 ../../library/contextlib.rst:491 +#: ../../library/contextlib.rst:419 ../../library/contextlib.rst:519 msgid "The class can then be used like this::" msgstr "這個類別可以這樣使用: ::" @@ -739,16 +739,52 @@ msgid "" "explicit :keyword:`!with` statement inside the function should be used." msgstr "" -#: ../../library/contextlib.rst:475 +#: ../../library/contextlib.rst:470 msgid "" -"Similar to :class:`ContextDecorator` but only for asynchronous functions." -msgstr "和 :class:`ContextDecorator` 類似,但僅用於非同步函式。" +"When the decorated callable is a generator function, coroutine function, or " +"asynchronous generator function, the returned wrapper is of the same kind " +"and keeps the context manager open for the lifetime of the iteration or " +"await rather than only for the call that creates the generator or coroutine " +"object. Wrapped generators and asynchronous generators are explicitly " +"closed when iteration ends, as if by :func:`closing` or :func:`aclosing`." +msgstr "" -#: ../../library/contextlib.rst:477 +#: ../../library/contextlib.rst:478 +msgid "" +"For asynchronous generators the wrapper re-yields each value with ``async " +"for``; values sent with :meth:`~agen.asend` and exceptions thrown with :meth:" +"`~agen.athrow` are not forwarded to the wrapped generator." +msgstr "" + +#: ../../library/contextlib.rst:485 +msgid "" +"Decorating a generator function, coroutine function, or asynchronous " +"generator function now keeps the context manager open across iteration or " +"await. Previously the context manager exited as soon as the generator or " +"coroutine object was created." +msgstr "" + +#: ../../library/contextlib.rst:494 +msgid "" +"Similar to :class:`ContextDecorator`, but the context manager is entered and " +"exited with :keyword:`async with`. Decorate coroutine functions and " +"asynchronous generator functions with this class; the returned wrapper is of " +"the same kind." +msgstr "" + +#: ../../library/contextlib.rst:500 +msgid "" +"Synchronous functions and generators are accepted, but the wrapper is always " +"asynchronous, so the decorated callable must then be awaited or iterated " +"with ``async for``. If that change of calling convention is not intended, " +"use :class:`ContextDecorator` instead." +msgstr "" + +#: ../../library/contextlib.rst:505 msgid "Example of ``AsyncContextDecorator``::" msgstr "``AsyncContextDecorator`` 範例: ::" -#: ../../library/contextlib.rst:479 +#: ../../library/contextlib.rst:507 msgid "" "from asyncio import run\n" "from contextlib import AsyncContextDecorator\n" @@ -774,7 +810,7 @@ msgstr "" " print('Finishing')\n" " return False" -#: ../../library/contextlib.rst:493 +#: ../../library/contextlib.rst:521 msgid "" ">>> @mycontext()\n" "... async def function():\n" @@ -812,20 +848,29 @@ msgstr "" "The bit in the middle\n" "Finishing" -#: ../../library/contextlib.rst:516 +#: ../../library/contextlib.rst:541 +msgid "" +"Decorating an asynchronous generator function now keeps the context manager " +"open across iteration. Previously the context manager exited as soon as the " +"generator object was created. Synchronous functions and synchronous " +"generator functions are also now accepted, with an asynchronous wrapper " +"returned." +msgstr "" + +#: ../../library/contextlib.rst:551 msgid "" "A context manager that is designed to make it easy to programmatically " "combine other context managers and cleanup functions, especially those that " "are optional or otherwise driven by input data." msgstr "" -#: ../../library/contextlib.rst:520 +#: ../../library/contextlib.rst:555 msgid "" "For example, a set of files may easily be handled in a single with statement " "as follows::" msgstr "" -#: ../../library/contextlib.rst:523 +#: ../../library/contextlib.rst:558 msgid "" "with ExitStack() as stack:\n" " files = [stack.enter_context(open(fname)) for fname in filenames]\n" @@ -834,13 +879,13 @@ msgid "" " # in the list raise an exception" msgstr "" -#: ../../library/contextlib.rst:529 +#: ../../library/contextlib.rst:564 msgid "" "The :meth:`~object.__enter__` method returns the :class:`ExitStack` " "instance, and performs no additional operations." msgstr "" -#: ../../library/contextlib.rst:532 +#: ../../library/contextlib.rst:567 msgid "" "Each instance maintains a stack of registered callbacks that are called in " "reverse order when the instance is closed (either explicitly or implicitly " @@ -848,14 +893,14 @@ msgid "" "invoked implicitly when the context stack instance is garbage collected." msgstr "" -#: ../../library/contextlib.rst:537 +#: ../../library/contextlib.rst:572 msgid "" "This stack model is used so that context managers that acquire their " "resources in their ``__init__`` method (such as file objects) can be handled " "correctly." msgstr "" -#: ../../library/contextlib.rst:541 +#: ../../library/contextlib.rst:576 msgid "" "Since registered callbacks are invoked in the reverse order of registration, " "this ends up behaving as if multiple nested :keyword:`with` statements had " @@ -865,7 +910,7 @@ msgid "" "updated state." msgstr "" -#: ../../library/contextlib.rst:548 +#: ../../library/contextlib.rst:583 msgid "" "This is a relatively low level API that takes care of the details of " "correctly unwinding the stack of exit callbacks. It provides a suitable " @@ -873,76 +918,86 @@ msgid "" "in application specific ways." msgstr "" -#: ../../library/contextlib.rst:557 +#: ../../library/contextlib.rst:592 msgid "" "Enters a new context manager and adds its :meth:`~object.__exit__` method to " "the callback stack. The return value is the result of the context manager's " "own :meth:`~object.__enter__` method." msgstr "" -#: ../../library/contextlib.rst:561 +#: ../../library/contextlib.rst:596 msgid "" "These context managers may suppress exceptions just as they normally would " "if used directly as part of a :keyword:`with` statement." msgstr "" -#: ../../library/contextlib.rst:564 +#: ../../library/contextlib.rst:599 msgid "" "Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not a " "context manager." msgstr "" -#: ../../library/contextlib.rst:570 +#: ../../library/contextlib.rst:603 +msgid "" +"Added support for arbitrary descriptors :meth:`!__enter__` and :meth:`!" +"__exit__`." +msgstr "" + +#: ../../library/contextlib.rst:609 msgid "" "Adds a context manager's :meth:`~object.__exit__` method to the callback " "stack." msgstr "" -#: ../../library/contextlib.rst:572 +#: ../../library/contextlib.rst:611 msgid "" "As ``__enter__`` is *not* invoked, this method can be used to cover part of " "an :meth:`~object.__enter__` implementation with a context manager's own :" "meth:`~object.__exit__` method." msgstr "" -#: ../../library/contextlib.rst:576 +#: ../../library/contextlib.rst:615 msgid "" "If passed an object that is not a context manager, this method assumes it is " "a callback with the same signature as a context manager's :meth:`~object." "__exit__` method and adds it directly to the callback stack." msgstr "" -#: ../../library/contextlib.rst:580 +#: ../../library/contextlib.rst:619 msgid "" "By returning true values, these callbacks can suppress exceptions the same " "way context manager :meth:`~object.__exit__` methods can." msgstr "" -#: ../../library/contextlib.rst:583 +#: ../../library/contextlib.rst:622 msgid "" "The passed in object is returned from the function, allowing this method to " "be used as a function decorator." msgstr "" -#: ../../library/contextlib.rst:588 +#: ../../library/contextlib.rst:625 +msgid "Added support for arbitrary descriptors :meth:`!__exit__`." +msgstr "" + +#: ../../library/contextlib.rst:630 msgid "" "Accepts an arbitrary callback function and arguments and adds it to the " "callback stack." msgstr "" -#: ../../library/contextlib.rst:591 +#: ../../library/contextlib.rst:633 msgid "" "Unlike the other methods, callbacks added this way cannot suppress " "exceptions (as they are never passed the exception details)." msgstr "" -#: ../../library/contextlib.rst:594 +#: ../../library/contextlib.rst:636 msgid "" "The passed in callback is returned from the function, allowing this method " "to be used as a function decorator." msgstr "" -#: ../../library/contextlib.rst:599 +#: ../../library/contextlib.rst:641 msgid "" "Transfers the callback stack to a fresh :class:`ExitStack` instance and " "returns it. No callbacks are invoked by this operation - instead, they will " @@ -950,13 +1005,13 @@ msgid "" "at the end of a :keyword:`with` statement)." msgstr "" -#: ../../library/contextlib.rst:604 +#: ../../library/contextlib.rst:646 msgid "" "For example, a group of files can be opened as an \"all or nothing\" " "operation as follows::" msgstr "" -#: ../../library/contextlib.rst:607 +#: ../../library/contextlib.rst:649 msgid "" "with ExitStack() as stack:\n" " files = [stack.enter_context(open(fname)) for fname in filenames]\n" @@ -968,57 +1023,67 @@ msgid "" " # close_files() can then be invoked explicitly to close them all." msgstr "" -#: ../../library/contextlib.rst:618 +#: ../../library/contextlib.rst:660 msgid "" "Immediately unwinds the callback stack, invoking callbacks in the reverse " "order of registration. For any context managers and exit callbacks " "registered, the arguments passed in will indicate that no exception occurred." msgstr "" -#: ../../library/contextlib.rst:625 +#: ../../library/contextlib.rst:667 msgid "" "An :ref:`asynchronous context manager `, similar to :" "class:`ExitStack`, that supports combining both synchronous and asynchronous " "context managers, as well as having coroutines for cleanup logic." msgstr "" -#: ../../library/contextlib.rst:630 +#: ../../library/contextlib.rst:672 msgid "" "The :meth:`~ExitStack.close` method is not implemented; :meth:`aclose` must " "be used instead." msgstr "" -#: ../../library/contextlib.rst:636 +#: ../../library/contextlib.rst:678 msgid "" "Similar to :meth:`ExitStack.enter_context` but expects an asynchronous " "context manager." msgstr "" -#: ../../library/contextlib.rst:639 +#: ../../library/contextlib.rst:681 msgid "" "Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not an " "asynchronous context manager." msgstr "" -#: ../../library/contextlib.rst:645 +#: ../../library/contextlib.rst:685 +msgid "" +"Added support for arbitrary descriptors :meth:`!__aenter__` and :meth:`!" +"__aexit__`." +msgstr "" + +#: ../../library/contextlib.rst:690 msgid "" "Similar to :meth:`ExitStack.push` but expects either an asynchronous context " "manager or a coroutine function." msgstr "" -#: ../../library/contextlib.rst:650 +#: ../../library/contextlib.rst:693 +msgid "Added support for arbitrary descriptors :meth:`!__aexit__`." +msgstr "" + +#: ../../library/contextlib.rst:698 msgid "Similar to :meth:`ExitStack.callback` but expects a coroutine function." msgstr "和 :meth:`ExitStack.callback` 類似,但預期接受一個協程函式。" -#: ../../library/contextlib.rst:655 +#: ../../library/contextlib.rst:703 msgid "Similar to :meth:`ExitStack.close` but properly handles awaitables." msgstr "和 :meth:`ExitStack.close` 類似,但能夠正確處理可等待物件。" -#: ../../library/contextlib.rst:657 +#: ../../library/contextlib.rst:705 msgid "Continuing the example for :deco:`asynccontextmanager`::" msgstr "延續 :deco:`asynccontextmanager` 的範例: ::" -#: ../../library/contextlib.rst:659 +#: ../../library/contextlib.rst:707 msgid "" "async with AsyncExitStack() as stack:\n" " connections = [await stack.enter_async_context(get_connection())\n" @@ -1028,21 +1093,21 @@ msgid "" " # later in the list raise an exception." msgstr "" -#: ../../library/contextlib.rst:669 +#: ../../library/contextlib.rst:717 msgid "Examples and Recipes" msgstr "" -#: ../../library/contextlib.rst:671 +#: ../../library/contextlib.rst:719 msgid "" "This section describes some examples and recipes for making effective use of " "the tools provided by :mod:`!contextlib`." msgstr "" -#: ../../library/contextlib.rst:676 +#: ../../library/contextlib.rst:724 msgid "Supporting a variable number of context managers" msgstr "" -#: ../../library/contextlib.rst:678 +#: ../../library/contextlib.rst:726 msgid "" "The primary use case for :class:`ExitStack` is the one given in the class " "documentation: supporting a variable number of context managers and other " @@ -1052,7 +1117,7 @@ msgid "" "of the context managers being optional::" msgstr "" -#: ../../library/contextlib.rst:685 +#: ../../library/contextlib.rst:733 msgid "" "with ExitStack() as stack:\n" " for resource in resources:\n" @@ -1063,18 +1128,18 @@ msgid "" " # Perform operations that use the acquired resources" msgstr "" -#: ../../library/contextlib.rst:693 +#: ../../library/contextlib.rst:741 msgid "" "As shown, :class:`ExitStack` also makes it quite easy to use :keyword:`with` " "statements to manage arbitrary resources that don't natively support the " "context management protocol." msgstr "" -#: ../../library/contextlib.rst:699 +#: ../../library/contextlib.rst:747 msgid "Catching exceptions from ``__enter__`` methods" msgstr "" -#: ../../library/contextlib.rst:701 +#: ../../library/contextlib.rst:749 msgid "" "It is occasionally desirable to catch exceptions from an :meth:`~object." "__enter__` method implementation, *without* inadvertently catching " @@ -1084,7 +1149,7 @@ msgid "" "this::" msgstr "" -#: ../../library/contextlib.rst:707 +#: ../../library/contextlib.rst:755 msgid "" "stack = ExitStack()\n" "try:\n" @@ -1096,7 +1161,7 @@ msgid "" " # Handle normal case" msgstr "" -#: ../../library/contextlib.rst:716 +#: ../../library/contextlib.rst:764 msgid "" "Actually needing to do this is likely to indicate that the underlying API " "should be providing a direct resource management interface for use with :" @@ -1107,25 +1172,25 @@ msgid "" "`with` statement." msgstr "" -#: ../../library/contextlib.rst:726 +#: ../../library/contextlib.rst:774 msgid "Cleaning up in an ``__enter__`` implementation" msgstr "" -#: ../../library/contextlib.rst:728 +#: ../../library/contextlib.rst:776 msgid "" "As noted in the documentation of :meth:`ExitStack.push`, this method can be " "useful in cleaning up an already allocated resource if later steps in the :" "meth:`~object.__enter__` implementation fail." msgstr "" -#: ../../library/contextlib.rst:732 +#: ../../library/contextlib.rst:780 msgid "" "Here's an example of doing this for a context manager that accepts resource " "acquisition and release functions, along with an optional validation " "function, and maps them to the context management protocol::" msgstr "" -#: ../../library/contextlib.rst:736 +#: ../../library/contextlib.rst:784 msgid "" "from contextlib import contextmanager, AbstractContextManager, ExitStack\n" "\n" @@ -1163,11 +1228,11 @@ msgid "" " self.release_resource()" msgstr "" -#: ../../library/contextlib.rst:772 +#: ../../library/contextlib.rst:820 msgid "Replacing any use of ``try-finally`` and flag variables" msgstr "" -#: ../../library/contextlib.rst:774 +#: ../../library/contextlib.rst:822 msgid "" "A pattern you will sometimes see is a ``try-finally`` statement with a flag " "variable to indicate whether or not the body of the ``finally`` clause " @@ -1175,7 +1240,7 @@ msgid "" "by using an ``except`` clause instead), it looks something like this::" msgstr "" -#: ../../library/contextlib.rst:779 +#: ../../library/contextlib.rst:827 msgid "" "cleanup_needed = True\n" "try:\n" @@ -1195,21 +1260,21 @@ msgstr "" " if cleanup_needed:\n" " cleanup_resources()" -#: ../../library/contextlib.rst:788 +#: ../../library/contextlib.rst:836 msgid "" "As with any ``try`` statement based code, this can cause problems for " "development and review, because the setup code and the cleanup code can end " "up being separated by arbitrarily long sections of code." msgstr "" -#: ../../library/contextlib.rst:792 +#: ../../library/contextlib.rst:840 msgid "" ":class:`ExitStack` makes it possible to instead register a callback for " "execution at the end of a ``with`` statement, and then later decide to skip " "executing that callback::" msgstr "" -#: ../../library/contextlib.rst:796 +#: ../../library/contextlib.rst:844 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1227,19 +1292,19 @@ msgstr "" " if result:\n" " stack.pop_all()" -#: ../../library/contextlib.rst:804 +#: ../../library/contextlib.rst:852 msgid "" "This allows the intended cleanup behaviour to be made explicit up front, " "rather than requiring a separate flag variable." msgstr "" -#: ../../library/contextlib.rst:807 +#: ../../library/contextlib.rst:855 msgid "" "If a particular application uses this pattern a lot, it can be simplified " "even further by means of a small helper class::" msgstr "" -#: ../../library/contextlib.rst:810 +#: ../../library/contextlib.rst:858 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1271,14 +1336,14 @@ msgstr "" " if result:\n" " cb.cancel()" -#: ../../library/contextlib.rst:825 +#: ../../library/contextlib.rst:873 msgid "" "If the resource cleanup isn't already neatly bundled into a standalone " "function, then it is still possible to use the decorator form of :meth:" "`ExitStack.callback` to declare the resource cleanup in advance::" msgstr "" -#: ../../library/contextlib.rst:830 +#: ../../library/contextlib.rst:878 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1300,24 +1365,24 @@ msgstr "" " if result:\n" " stack.pop_all()" -#: ../../library/contextlib.rst:840 +#: ../../library/contextlib.rst:888 msgid "" "Due to the way the decorator protocol works, a callback function declared " "this way cannot take any parameters. Instead, any resources to be released " "must be accessed as closure variables." msgstr "" -#: ../../library/contextlib.rst:846 +#: ../../library/contextlib.rst:894 msgid "Using a context manager as a function decorator" msgstr "" -#: ../../library/contextlib.rst:848 +#: ../../library/contextlib.rst:896 msgid "" ":class:`ContextDecorator` makes it possible to use a context manager in both " "an ordinary ``with`` statement and also as a function decorator." msgstr "" -#: ../../library/contextlib.rst:851 +#: ../../library/contextlib.rst:899 msgid "" "For example, it is sometimes useful to wrap functions or groups of " "statements with a logger that can track the time of entry and time of exit. " @@ -1326,7 +1391,7 @@ msgid "" "in a single definition::" msgstr "" -#: ../../library/contextlib.rst:857 +#: ../../library/contextlib.rst:905 msgid "" "from contextlib import ContextDecorator\n" "import logging\n" @@ -1358,11 +1423,11 @@ msgstr "" " def __exit__(self, exc_type, exc, exc_tb):\n" " logging.info('Exiting: %s', self.name)" -#: ../../library/contextlib.rst:872 +#: ../../library/contextlib.rst:920 msgid "Instances of this class can be used as both a context manager::" msgstr "" -#: ../../library/contextlib.rst:874 +#: ../../library/contextlib.rst:922 msgid "" "with track_entry_and_exit('widget loader'):\n" " print('Some time consuming activity goes here')\n" @@ -1372,11 +1437,11 @@ msgstr "" " print('Some time consuming activity goes here')\n" " load_widget()" -#: ../../library/contextlib.rst:878 +#: ../../library/contextlib.rst:926 msgid "And also as a function decorator::" msgstr "" -#: ../../library/contextlib.rst:880 +#: ../../library/contextlib.rst:928 msgid "" "@track_entry_and_exit('widget loader')\n" "def activity():\n" @@ -1388,7 +1453,7 @@ msgstr "" " print('Some time consuming activity goes here')\n" " load_widget()" -#: ../../library/contextlib.rst:885 +#: ../../library/contextlib.rst:933 msgid "" "Note that there is one additional limitation when using context managers as " "function decorators: there's no way to access the return value of :meth:" @@ -1396,21 +1461,21 @@ msgid "" "use an explicit ``with`` statement." msgstr "" -#: ../../library/contextlib.rst:892 +#: ../../library/contextlib.rst:940 msgid ":pep:`343` - The \"with\" statement" msgstr ":pep:`343` - \"with\" 陳述式" -#: ../../library/contextlib.rst:893 +#: ../../library/contextlib.rst:941 msgid "" "The specification, background, and examples for the Python :keyword:`with` " "statement." msgstr "" -#: ../../library/contextlib.rst:899 +#: ../../library/contextlib.rst:947 msgid "Single use, reusable and reentrant context managers" msgstr "" -#: ../../library/contextlib.rst:901 +#: ../../library/contextlib.rst:949 msgid "" "Most context managers are written in a way that means they can only be used " "effectively in a :keyword:`with` statement once. These single use context " @@ -1418,28 +1483,28 @@ msgid "" "them a second time will trigger an exception or otherwise not work correctly." msgstr "" -#: ../../library/contextlib.rst:907 +#: ../../library/contextlib.rst:955 msgid "" "This common limitation means that it is generally advisable to create " "context managers directly in the header of the :keyword:`with` statement " "where they are used (as shown in all of the usage examples above)." msgstr "" -#: ../../library/contextlib.rst:911 +#: ../../library/contextlib.rst:959 msgid "" "Files are an example of effectively single use context managers, since the " "first :keyword:`with` statement will close the file, preventing any further " "IO operations using that file object." msgstr "" -#: ../../library/contextlib.rst:915 +#: ../../library/contextlib.rst:963 msgid "" "Context managers created using :deco:`contextmanager` are also single use " "context managers, and will complain about the underlying generator failing " "to yield if an attempt is made to use them a second time::" msgstr "" -#: ../../library/contextlib.rst:919 +#: ../../library/contextlib.rst:967 msgid "" ">>> from contextlib import contextmanager\n" ">>> @contextmanager\n" @@ -1481,11 +1546,11 @@ msgstr "" " ...\n" "RuntimeError: generator didn't yield" -#: ../../library/contextlib.rst:943 +#: ../../library/contextlib.rst:991 msgid "Reentrant context managers" msgstr "" -#: ../../library/contextlib.rst:945 +#: ../../library/contextlib.rst:993 msgid "" "More sophisticated context managers may be \"reentrant\". These context " "managers can not only be used in multiple :keyword:`with` statements, but " @@ -1493,14 +1558,14 @@ msgid "" "the same context manager." msgstr "" -#: ../../library/contextlib.rst:950 +#: ../../library/contextlib.rst:998 msgid "" ":class:`threading.RLock` is an example of a reentrant context manager, as " "are :func:`suppress`, :func:`redirect_stdout`, and :func:`chdir`. Here's a " "very simple example of reentrant use::" msgstr "" -#: ../../library/contextlib.rst:954 +#: ../../library/contextlib.rst:1002 msgid "" ">>> from contextlib import redirect_stdout\n" ">>> from io import StringIO\n" @@ -1532,14 +1597,14 @@ msgstr "" "This is written to the stream rather than stdout\n" "This is also written to the stream" -#: ../../library/contextlib.rst:969 +#: ../../library/contextlib.rst:1017 msgid "" "Real world examples of reentrancy are more likely to involve multiple " "functions calling each other and hence be far more complicated than this " "example." msgstr "" -#: ../../library/contextlib.rst:973 +#: ../../library/contextlib.rst:1021 msgid "" "Note also that being reentrant is *not* the same thing as being thread " "safe. :func:`redirect_stdout`, for example, is definitely not thread safe, " @@ -1547,11 +1612,11 @@ msgid "" "stdout` to a different stream." msgstr "" -#: ../../library/contextlib.rst:982 +#: ../../library/contextlib.rst:1030 msgid "Reusable context managers" msgstr "" -#: ../../library/contextlib.rst:984 +#: ../../library/contextlib.rst:1032 msgid "" "Distinct from both single use and reentrant context managers are " "\"reusable\" context managers (or, to be completely explicit, \"reusable, " @@ -1561,21 +1626,21 @@ msgid "" "manager instance has already been used in a containing with statement." msgstr "" -#: ../../library/contextlib.rst:991 +#: ../../library/contextlib.rst:1039 msgid "" ":class:`threading.Lock` is an example of a reusable, but not reentrant, " "context manager (for a reentrant lock, it is necessary to use :class:" "`threading.RLock` instead)." msgstr "" -#: ../../library/contextlib.rst:995 +#: ../../library/contextlib.rst:1043 msgid "" "Another example of a reusable, but not reentrant, context manager is :class:" "`ExitStack`, as it invokes *all* currently registered callbacks when leaving " "any with statement, regardless of where those callbacks were added::" msgstr "" -#: ../../library/contextlib.rst:1000 +#: ../../library/contextlib.rst:1048 msgid "" ">>> from contextlib import ExitStack\n" ">>> stack = ExitStack()\n" @@ -1629,7 +1694,7 @@ msgstr "" "Callback: from outer context\n" "Leaving outer context" -#: ../../library/contextlib.rst:1026 +#: ../../library/contextlib.rst:1074 msgid "" "As the output from the example shows, reusing a single stack object across " "multiple with statements works correctly, but attempting to nest them will " @@ -1637,13 +1702,13 @@ msgid "" "which is unlikely to be desirable behaviour." msgstr "" -#: ../../library/contextlib.rst:1031 +#: ../../library/contextlib.rst:1079 msgid "" "Using separate :class:`ExitStack` instances instead of reusing a single " "instance avoids that problem::" msgstr "" -#: ../../library/contextlib.rst:1034 +#: ../../library/contextlib.rst:1082 msgid "" ">>> from contextlib import ExitStack\n" ">>> with ExitStack() as outer_stack:\n" @@ -1670,3 +1735,7 @@ msgstr "" "Callback: from inner context\n" "Leaving outer context\n" "Callback: from outer context" + +#~ msgid "" +#~ "Similar to :class:`ContextDecorator` but only for asynchronous functions." +#~ msgstr "和 :class:`ContextDecorator` 類似,但僅用於非同步函式。" diff --git a/library/contextvars.po b/library/contextvars.po index 3638ff3def3..f23a5ea3073 100644 --- a/library/contextvars.po +++ b/library/contextvars.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-03 00:49+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-07-30 22:06+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -19,7 +19,7 @@ msgstr "" msgid ":mod:`!contextvars` --- Context Variables" msgstr ":mod:`!contextvars` --- 情境變數" -#: ../../library/contextvars.rst:11 +#: ../../library/contextvars.rst:9 msgid "" "This module provides APIs to manage, store, and access context-local state. " "The :class:`~contextvars.ContextVar` class is used to declare and work with " @@ -32,7 +32,7 @@ msgstr "" "`~contextvars.copy_context` 函式和 :class:`~contextvars.Context` 類別應在非同" "步框架中管理目前的情境。" -#: ../../library/contextvars.rst:17 +#: ../../library/contextvars.rst:15 msgid "" "Context managers that have state should use Context Variables instead of :" "func:`threading.local` to prevent their state from bleeding to other code " @@ -42,28 +42,28 @@ msgstr "" "才能防止它們的狀態在並行(concurrent)程式碼中使用時意外外溢並干擾到其他程式" "碼。" -#: ../../library/contextvars.rst:21 +#: ../../library/contextvars.rst:19 msgid "See also :pep:`567` for additional details." msgstr "其他詳細資訊,請參閱 :pep:`567`。" -#: ../../library/contextvars.rst:27 +#: ../../library/contextvars.rst:25 msgid "Context Variables" msgstr "情境變數" -#: ../../library/contextvars.rst:31 +#: ../../library/contextvars.rst:29 msgid "This class is used to declare a new Context Variable, e.g.::" msgstr "此類別用在宣告新的情境變數,例如:" -#: ../../library/contextvars.rst:33 +#: ../../library/contextvars.rst:31 msgid "var: ContextVar[int] = ContextVar('var', default=42)" msgstr "var: ContextVar[int] = ContextVar('var', default=42)" -#: ../../library/contextvars.rst:35 +#: ../../library/contextvars.rst:33 msgid "" "The required *name* parameter is used for introspection and debug purposes." msgstr "必要參數 *name* 用於自我檢查(introspection)和除錯。" -#: ../../library/contextvars.rst:38 +#: ../../library/contextvars.rst:36 msgid "" "The optional keyword-only *default* parameter is returned by :meth:" "`ContextVar.get` when no value for the variable is found in the current " @@ -72,7 +72,7 @@ msgstr "" "當在目前的情境中找不到變數的值時,:meth:`ContextVar.get` 會回傳可選的僅限關鍵" "字參數 *default*。" -#: ../../library/contextvars.rst:42 +#: ../../library/contextvars.rst:40 msgid "" "**Important:** Context Variables should be created at the top module level " "and never in closures. :class:`Context` objects hold strong references to " @@ -83,52 +83,52 @@ msgstr "" "建立。 :class:`Context` 物件持有情境變數的強參照,這會阻止情境變數被正確地垃" "圾回收(garbage collected)。" -#: ../../library/contextvars.rst:47 +#: ../../library/contextvars.rst:45 msgid "" ":class:`!ContextVar`\\s are :ref:`generic ` over the type of their " "contained value." msgstr "" -#: ../../library/contextvars.rst:52 +#: ../../library/contextvars.rst:50 msgid "The name of the variable. This is a read-only property." msgstr "這個變數的名稱。這是一個唯讀屬性。" -#: ../../library/contextvars.rst:58 +#: ../../library/contextvars.rst:56 msgid "Return a value for the context variable for the current context." msgstr "回傳目前情境的情境變數值。" -#: ../../library/contextvars.rst:60 +#: ../../library/contextvars.rst:58 msgid "" "If there is no value for the variable in the current context, the method " "will:" msgstr "如果在目前情境中沒有變數的值,此方法將:" -#: ../../library/contextvars.rst:63 +#: ../../library/contextvars.rst:61 msgid "" "return the value of the *default* argument of the method, if provided; or" msgstr "回傳方法的 *default* 引數值(如果有的話);否則" -#: ../../library/contextvars.rst:66 +#: ../../library/contextvars.rst:64 msgid "" "return the default value for the context variable, if it was created with " "one; or" msgstr "回傳情境變數的預設值(如果建立情境變數時有指定預設值的話);否則" -#: ../../library/contextvars.rst:69 +#: ../../library/contextvars.rst:67 msgid "raise a :exc:`LookupError`." msgstr "會引發一個 :exc:`LookupError`。" -#: ../../library/contextvars.rst:73 +#: ../../library/contextvars.rst:71 msgid "" "Call to set a new value for the context variable in the current context." msgstr "在目前的情境中,呼叫以設定情境變數的新值。" -#: ../../library/contextvars.rst:76 +#: ../../library/contextvars.rst:74 msgid "" "The required *value* argument is the new value for the context variable." msgstr "*value* 屬必要引數,是情境變數的新值。" -#: ../../library/contextvars.rst:79 +#: ../../library/contextvars.rst:77 msgid "" "Returns a :class:`~contextvars.Token` object that can be used to restore the " "variable to its previous value via the :meth:`ContextVar.reset` method." @@ -136,7 +136,7 @@ msgstr "" "回傳一個 :class:`~contextvars.Token` 物件,該物件可透過 :meth:`ContextVar." "reset` 方法,用來將變數還原到之前的值。" -#: ../../library/contextvars.rst:83 +#: ../../library/contextvars.rst:81 msgid "" "For convenience, the token object can be used as a context manager to avoid " "calling :meth:`ContextVar.reset` manually::" @@ -144,7 +144,7 @@ msgstr "" "為了方便起見,token 物件可以用作情境管理器,以避免手動呼叫 :meth:`ContextVar." "reset`: ::" -#: ../../library/contextvars.rst:86 +#: ../../library/contextvars.rst:84 msgid "" "var = ContextVar('var', default='default value')\n" "\n" @@ -160,11 +160,11 @@ msgstr "" "\n" "assert var.get() == 'default value'" -#: ../../library/contextvars.rst:93 +#: ../../library/contextvars.rst:91 msgid "It is a shorthand for::" msgstr "它是以下程式碼的簡寫: ::" -#: ../../library/contextvars.rst:95 +#: ../../library/contextvars.rst:93 msgid "" "var = ContextVar('var', default='default value')\n" "\n" @@ -186,21 +186,21 @@ msgstr "" "\n" "assert var.get() == 'default value'" -#: ../../library/contextvars.rst:107 +#: ../../library/contextvars.rst:105 msgid "Added support for using tokens as context managers." msgstr "新增對將 token 用作情境管理器的支援。" -#: ../../library/contextvars.rst:111 +#: ../../library/contextvars.rst:109 msgid "" "Reset the context variable to the value it had before the :meth:`ContextVar." "set` that created the *token* was used." msgstr "將情境變數重設為使用 :meth:`ContextVar.set` 建立 *token* 前的值。" -#: ../../library/contextvars.rst:114 +#: ../../library/contextvars.rst:112 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/contextvars.rst:116 +#: ../../library/contextvars.rst:114 msgid "" "var = ContextVar('var')\n" "\n" @@ -220,11 +220,11 @@ msgstr "" "# 在重設呼叫之後,var 又沒有值了,所以\n" "# var.get() 會引發 LookupError。" -#: ../../library/contextvars.rst:125 +#: ../../library/contextvars.rst:123 msgid "The same *token* cannot be used twice." msgstr "同一個 *token* 不能被使用兩次。" -#: ../../library/contextvars.rst:130 +#: ../../library/contextvars.rst:128 msgid "" "*Token* objects are returned by the :meth:`ContextVar.set` method. They can " "be passed to the :meth:`ContextVar.reset` method to revert the value of the " @@ -235,7 +235,7 @@ msgstr "" "reset` 方法,用以將變數的值還原為相對應的 *set* 之前的值。單一 token 不能重設" "情境變數超過一次。" -#: ../../library/contextvars.rst:135 +#: ../../library/contextvars.rst:133 msgid "" "Tokens support the :ref:`context manager protocol ` to " "automatically reset context variables. See :meth:`ContextVar.set`." @@ -243,23 +243,23 @@ msgstr "" "Token 支援\\ :ref:`情境管理器協定 `,可自動重設情境變數。請" "參閱 :meth:`ContextVar.set`。" -#: ../../library/contextvars.rst:138 +#: ../../library/contextvars.rst:136 msgid "" "Tokens are :ref:`generic ` over the same type as the :class:" "`ContextVar` which created them." msgstr "" -#: ../../library/contextvars.rst:143 +#: ../../library/contextvars.rst:141 msgid "Added support for usage as a context manager." msgstr "新增對用作情境管理器的支援。" -#: ../../library/contextvars.rst:147 +#: ../../library/contextvars.rst:145 msgid "" "A read-only property. Points to the :class:`ContextVar` object that created " "the token." msgstr "唯讀屬性。 指向建立 token 的 :class:`ContextVar` 物件。" -#: ../../library/contextvars.rst:152 +#: ../../library/contextvars.rst:150 msgid "" "A read-only property. Set to the value the variable had before the :meth:" "`ContextVar.set` method call that created the token. It points to :attr:" @@ -268,26 +268,26 @@ msgstr "" "唯讀屬性。 值為變數在呼叫 :meth:`ContextVar.set` 方法之前的值。如果變數在呼叫" "前沒有設定,則指向 :attr:`Token.MISSING`。" -#: ../../library/contextvars.rst:159 +#: ../../library/contextvars.rst:157 msgid "A marker object used by :attr:`Token.old_value`." msgstr "由 :attr:`Token.old_value` 使用的標記物件。" -#: ../../library/contextvars.rst:163 +#: ../../library/contextvars.rst:161 msgid "Manual Context Management" msgstr "手動情境管理" -#: ../../library/contextvars.rst:167 +#: ../../library/contextvars.rst:165 msgid "Returns a copy of the current :class:`~contextvars.Context` object." msgstr "回傳目前 :class:`~contextvars.Context` 物件的複本(copy)。" -#: ../../library/contextvars.rst:169 +#: ../../library/contextvars.rst:167 msgid "" "The following snippet gets a copy of the current context and prints all " "variables and their values that are set in it::" msgstr "" "以下程式碼片段會取得目前情境的複本,並顯示在其中設定的所有變數及其值:::" -#: ../../library/contextvars.rst:172 +#: ../../library/contextvars.rst:170 msgid "" "ctx: Context = copy_context()\n" "print(list(ctx.items()))" @@ -295,7 +295,7 @@ msgstr "" "ctx: Context = copy_context()\n" "print(list(ctx.items()))" -#: ../../library/contextvars.rst:175 +#: ../../library/contextvars.rst:173 msgid "" "The function has an *O*\\ (1) complexity, i.e. works equally fast for " "contexts with a few context variables and for contexts that have a lot of " @@ -304,11 +304,11 @@ msgstr "" "這個函式具有 *O*\\ (1) 的複雜度,也就是說,對於只有少許情境變數的情境和有大量" "情境變數的情境,速度都一樣快。" -#: ../../library/contextvars.rst:182 +#: ../../library/contextvars.rst:180 msgid "A mapping of :class:`ContextVars ` to their values." msgstr ":class:`ContextVars` 到其值的映射。" -#: ../../library/contextvars.rst:184 +#: ../../library/contextvars.rst:182 msgid "" "``Context()`` creates an empty context with no values in it. To get a copy " "of the current context use the :func:`~contextvars.copy_context` function." @@ -316,7 +316,7 @@ msgstr "" "``Context()`` 會建立一個沒有值的空情境。要取得目前情境的複本,請使用 :func:" "`~contextvars.copy_context` 函式。" -#: ../../library/contextvars.rst:188 +#: ../../library/contextvars.rst:186 msgid "" "Each thread has its own effective stack of :class:`!Context` objects. The :" "term:`current context` is the :class:`!Context` object at the top of the " @@ -327,7 +327,7 @@ msgstr "" "term:`current context` 是目前執行緒堆疊頂端的 :class:`!Context` 物件。 堆疊" "中的所有 :class:`!Context` 物件都被視為\\ *已進入*。" -#: ../../library/contextvars.rst:193 +#: ../../library/contextvars.rst:191 msgid "" "*Entering* a context, which can be done by calling its :meth:`~Context.run` " "method, makes the context the current context by pushing it onto the top of " @@ -336,7 +336,7 @@ msgstr "" "*進入*\\ 一個情境,可以藉由呼叫其 :meth:`~Context.run` 方法來完成,此\\ *進入" "*\\ 的動作會將一情境推到目前執行緒的情境堆疊的頂端,使該情境成為目前的情境。" -#: ../../library/contextvars.rst:197 +#: ../../library/contextvars.rst:195 msgid "" "*Exiting* from the current context, which can be done by returning from the " "callback passed to the :meth:`~Context.run` method, restores the current " @@ -347,7 +347,7 @@ msgstr "" "式回傳之後,就會自動\\ *退出*\\ 目前的情境,這會將目前的情境還原到進入情境之" "前的狀態,方法是將情境從情境堆疊的頂端彈出。" -#: ../../library/contextvars.rst:202 +#: ../../library/contextvars.rst:200 msgid "" "Since each thread has its own context stack, :class:`ContextVar` objects " "behave in a similar fashion to :func:`threading.local` when values are " @@ -356,7 +356,7 @@ msgstr "" "因為每個執行緒都有自己的情境堆疊,當值在不同的執行緒中被指定時, :class:" "`ContextVar` 物件的行為與 :func:`threading.local` 相似。" -#: ../../library/contextvars.rst:206 +#: ../../library/contextvars.rst:204 msgid "" "Attempting to enter an already entered context, including contexts entered " "in other threads, raises a :exc:`RuntimeError`." @@ -364,11 +364,11 @@ msgstr "" "嘗試進入已進入的情境,包括在其他執行緒中進入的情境,會引發 :exc:" "`RuntimeError`。" -#: ../../library/contextvars.rst:209 +#: ../../library/contextvars.rst:207 msgid "After exiting a context, it can later be re-entered (from any thread)." msgstr "退出情境後,之後可以重新進入(從任何執行緒)。" -#: ../../library/contextvars.rst:211 +#: ../../library/contextvars.rst:209 msgid "" "Any changes to :class:`ContextVar` values via the :meth:`ContextVar.set` " "method are recorded in the current context. The :meth:`ContextVar.get` " @@ -382,11 +382,11 @@ msgstr "" "實際造成的效果會像是將其在進入情境時對情境變數所做的任何變一一彈出並還原(如" "果需要,可以透過重新進入情境來還原值)。" -#: ../../library/contextvars.rst:218 +#: ../../library/contextvars.rst:216 msgid "Context implements the :class:`collections.abc.Mapping` interface." msgstr "情境(Context)實作了 :class:`collections.abc.Mapping` 介面。" -#: ../../library/contextvars.rst:222 +#: ../../library/contextvars.rst:220 msgid "" "Enters the Context, executes ``callable(*args, **kwargs)``, then exits the " "Context. Returns *callable*'s return value, or propagates an exception if " @@ -395,11 +395,11 @@ msgstr "" "進入 Context,執行 ``callable(*args, **kwargs)``,然後退出 Context。 回傳 " "*callable* 的回傳值,如果發生例外(exception),則傳播例外。" -#: ../../library/contextvars.rst:226 +#: ../../library/contextvars.rst:224 msgid "Example:" msgstr "例如:" -#: ../../library/contextvars.rst:228 +#: ../../library/contextvars.rst:226 msgid "" "import contextvars\n" "\n" @@ -463,18 +463,18 @@ msgstr "" "# 但是,在 'ctx' 外, 'var' 的值仍然是 'spam':\n" "print(var.get()) # 'spam'" -#: ../../library/contextvars.rst:274 +#: ../../library/contextvars.rst:272 msgid "Return a shallow copy of the context object." msgstr "回傳情境物件的淺層複本(shallow copy)。" -#: ../../library/contextvars.rst:278 +#: ../../library/contextvars.rst:276 msgid "" "Return ``True`` if the *context* has a value for *var* set; return ``False`` " "otherwise." msgstr "" "如果\\ *情境*\\ 裡面有 *var* 的值,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/contextvars.rst:283 +#: ../../library/contextvars.rst:281 msgid "" "Return the value of the *var* :class:`ContextVar` variable. If the variable " "is not set in the context object, a :exc:`KeyError` is raised." @@ -482,7 +482,7 @@ msgstr "" "回傳 *var* :class:`ContextVar` 變數的值。如果該變數並沒有在情境物件中設定,則" "會引發 :exc:`KeyError` 錯誤。" -#: ../../library/contextvars.rst:289 +#: ../../library/contextvars.rst:287 msgid "" "Return the value for *var* if *var* has the value in the context object. " "Return *default* otherwise. If *default* is not given, return ``None``." @@ -490,33 +490,33 @@ msgstr "" "如果 *var* 的值在情境物件中,則回傳 *var* 的值。否則回傳 *default*。如果沒有 " "*default* 值,則回傳 ``None``。" -#: ../../library/contextvars.rst:295 +#: ../../library/contextvars.rst:293 msgid "Return an iterator over the variables stored in the context object." msgstr "回傳儲存於情境物件中變數的疊代器。" -#: ../../library/contextvars.rst:300 +#: ../../library/contextvars.rst:298 msgid "Return the number of variables set in the context object." msgstr "回傳情境物件中的變數個數。" -#: ../../library/contextvars.rst:304 +#: ../../library/contextvars.rst:302 msgid "Return a list of all variables in the context object." msgstr "回傳情境物件中所有變數的串列。" -#: ../../library/contextvars.rst:308 +#: ../../library/contextvars.rst:306 msgid "Return a list of all variables' values in the context object." msgstr "回傳情境物件中所有變數的值的串列。" -#: ../../library/contextvars.rst:313 +#: ../../library/contextvars.rst:311 msgid "" "Return a list of 2-tuples containing all variables and their values in the " "context object." msgstr "回傳情境物件中所有變數與其值的 2-元組(2-tuples)的串列。" -#: ../../library/contextvars.rst:318 +#: ../../library/contextvars.rst:316 msgid "asyncio support" msgstr "對 asyncio 的支援" -#: ../../library/contextvars.rst:320 +#: ../../library/contextvars.rst:318 msgid "" "Context variables are natively supported in :mod:`asyncio` and are ready to " "be used without any extra configuration. For example, here is a simple echo " @@ -526,7 +526,7 @@ msgstr "" ":mod:`asyncio` 原生支援情境變數,不需任何額外設定。 舉例來說,以下是一個簡單" "的 echo 伺服器,使用情境變數讓遠端用戶端的位址在處理該用戶端的任務中可用:" -#: ../../library/contextvars.rst:326 +#: ../../library/contextvars.rst:324 msgid "" "import asyncio\n" "import contextvars\n" @@ -544,7 +544,7 @@ msgid "" " addr = writer.transport.get_extra_info('socket').getpeername()\n" " client_addr_var.set(addr)\n" "\n" -" # In any code that we call is now possible to get\n" +" # In any code that we call, it is now possible to get the\n" " # client's address by calling 'client_addr_var.get()'.\n" "\n" " while True:\n" @@ -587,7 +587,7 @@ msgstr "" " addr = writer.transport.get_extra_info('socket').getpeername()\n" " client_addr_var.set(addr)\n" "\n" -" # 在任何我們呼叫的程式碼中,都可以\n" +" # 在任何我們呼叫的程式碼中,現在都可以\n" " # 呼叫 'client_addr_var.get()' 來取得用戶端的位址\n" "\n" " while True:\n" @@ -610,6 +610,6 @@ msgstr "" "\n" "asyncio.run(main())\n" "\n" -"# 你可以使用 telnet 或 curl 測試:\n" +"# 你可以使用 telnet 或 curl 測試:\n" "# telnet 127.0.0.1 8081\n" -"# curl 127.0.0.1:8081" +"# curl 127.0.0.1:8081" \ No newline at end of file diff --git a/library/csv.po b/library/csv.po index 204538b83ab..19de4e9df33 100644 --- a/library/csv.po +++ b/library/csv.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-14 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-11-08 15:06+0800\n" "Last-Translator: RockLeon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -19,14 +19,14 @@ msgstr "" "X-Generator: Poedit 3.4\n" #: ../../library/csv.rst:2 -msgid ":mod:`!csv` --- CSV File Reading and Writing" +msgid ":mod:`!csv` --- CSV file reading and writing" msgstr ":mod:`!csv` --- CSV 檔案讀取及寫入" -#: ../../library/csv.rst:9 +#: ../../library/csv.rst:7 msgid "**Source code:** :source:`Lib/csv.py`" msgstr "**原始碼:**\\ :source:`Lib/csv.py`" -#: ../../library/csv.rst:17 +#: ../../library/csv.rst:15 msgid "" "The so-called CSV (Comma Separated Values) format is the most common import " "and export format for spreadsheets and databases. CSV format was used for " @@ -46,7 +46,7 @@ msgstr "" "人。儘管如此,雖然分隔符號和引號字元有所不同,整體的格式非常相似,可以寫個單" "一模組來高效率的操作這樣的資料,讓程式設計師可以隱藏讀取及寫入資料的細節。" -#: ../../library/csv.rst:28 +#: ../../library/csv.rst:26 msgid "" "The :mod:`!csv` module implements classes to read and write tabular data in " "CSV format. It allows programmers to say, \"write this data in the format " @@ -61,7 +61,7 @@ msgstr "" "也可以描述其他應用程式所理解的 CSV 格式或他們自行定義具有特殊意義的 CSV 格" "式。" -#: ../../library/csv.rst:35 +#: ../../library/csv.rst:33 msgid "" "The :mod:`!csv` module's :class:`reader` and :class:`writer` objects read " "and write sequences. Programmers can also read and write data in dictionary " @@ -71,23 +71,23 @@ msgstr "" "列。程式設計師也可以透過 :class:`DictReader` 及 :class:`DictWriter` class(類" "別)使用 dictionary (字典)讀取及寫入資料。" -#: ../../library/csv.rst:41 +#: ../../library/csv.rst:39 msgid ":pep:`305` - CSV File API" msgstr ":pep:`305` - CSV 檔案 API" -#: ../../library/csv.rst:42 +#: ../../library/csv.rst:40 msgid "The Python Enhancement Proposal which proposed this addition to Python." msgstr "Python Enhancement Proposal (PEP) 所提出的 Python 附加功能。" -#: ../../library/csv.rst:48 -msgid "Module Contents" +#: ../../library/csv.rst:46 +msgid "Module contents" msgstr "模組內容" -#: ../../library/csv.rst:50 +#: ../../library/csv.rst:48 msgid "The :mod:`!csv` module defines the following functions:" msgstr ":mod:`!csv` 模組定義了以下函式:" -#: ../../library/csv.rst:58 +#: ../../library/csv.rst:56 msgid "" "Return a :ref:`reader object ` that will process lines from " "the given *csvfile*. A csvfile must be an iterable of strings, each in the " @@ -112,7 +112,7 @@ msgstr "" "(formatting parameter)。關於 dialect 及格式化參數的完整說明,請見段落 :ref:" "`csv-fmt-params`。" -#: ../../library/csv.rst:72 +#: ../../library/csv.rst:70 msgid "" "Each row read from the csv file is returned as a list of strings. No " "automatic data type conversion is performed unless the :data:" @@ -123,12 +123,12 @@ msgstr "" "`QUOTE_NONNUMERIC` 有被指定(在這個情況之下,沒有引號的欄位都會被轉換成浮點" "數),否則不會進行自動資料型別轉換。" -#: ../../library/csv.rst:76 ../../library/csv.rst:113 ../../library/csv.rst:196 -#: ../../library/csv.rst:242 +#: ../../library/csv.rst:74 ../../library/csv.rst:111 ../../library/csv.rst:194 +#: ../../library/csv.rst:240 msgid "A short usage example::" msgstr "一個簡短的用法範例: ::" -#: ../../library/csv.rst:78 +#: ../../library/csv.rst:76 msgid "" ">>> import csv\n" ">>> with open('eggs.csv', newline='') as csvfile:\n" @@ -146,17 +146,17 @@ msgstr "" "Spam, Spam, Spam, Spam, Spam, Baked Beans\n" "Spam, Lovely Spam, Wonderful Spam" -#: ../../library/csv.rst:86 +#: ../../library/csv.rst:84 msgid "where :file:`eggs.csv` contains:" msgstr "" -#: ../../library/csv.rst:88 ../../library/csv.rst:124 +#: ../../library/csv.rst:86 ../../library/csv.rst:122 msgid "" "Spam Spam Spam Spam Spam |Baked Beans|\n" "Spam |Lovely Spam| |Wonderful Spam|" msgstr "" -#: ../../library/csv.rst:96 +#: ../../library/csv.rst:94 msgid "" "Return a writer object responsible for converting the user's data into " "delimited strings on the given file-like object. *csvfile* can be any " @@ -188,7 +188,7 @@ msgstr "" "``cursor.fetch*`` 呼叫回傳的資料進行預處理 (preprocessing)。其餘非字串的資料" "則會在寫入之前用 :func:`str` 函式進行字串化 (stringify)。" -#: ../../library/csv.rst:115 +#: ../../library/csv.rst:113 msgid "" "import csv\n" "with open('eggs.csv', 'w', newline='') as csvfile:\n" @@ -204,11 +204,11 @@ msgstr "" " spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])\n" " spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])" -#: ../../library/csv.rst:122 +#: ../../library/csv.rst:120 msgid "which writes :file:`eggs.csv` containing:" msgstr "" -#: ../../library/csv.rst:132 +#: ../../library/csv.rst:130 msgid "" "Associate *dialect* with *name*. *name* must be a string. The dialect can " "be specified either by passing a sub-class of :class:`Dialect`, or by " @@ -221,7 +221,7 @@ msgstr "" "或是以上兩者皆是,並透過關鍵字引數來覆寫 dialect 的參數。關於 dialect 及格式" "化參數的完整說明,請見段落 :ref:`csv-fmt-params`。" -#: ../../library/csv.rst:141 +#: ../../library/csv.rst:139 msgid "" "Delete the dialect associated with *name* from the dialect registry. An :" "exc:`Error` is raised if *name* is not a registered dialect name." @@ -229,7 +229,7 @@ msgstr "" "從 dialect 註冊表 (registry) 中,刪除與 *name* 關聯的 dialect。若 *name* 如果" "不是註冊的 dialect 名稱,則會產生一個 :exc:`Error`。" -#: ../../library/csv.rst:147 +#: ../../library/csv.rst:145 msgid "" "Return the dialect associated with *name*. An :exc:`Error` is raised if " "*name* is not a registered dialect name. This function returns an " @@ -239,11 +239,11 @@ msgstr "" "產生一個 :exc:`Error`。這個函式會回傳一個 immutable (不可變物件) :class:" "`Dialect`。" -#: ../../library/csv.rst:153 +#: ../../library/csv.rst:151 msgid "Return the names of all registered dialects." msgstr "回傳所有已註冊的 dialect 名稱。" -#: ../../library/csv.rst:159 +#: ../../library/csv.rst:157 msgid "" "Returns the current maximum field size allowed by the parser. If *new_limit* " "is given, this becomes the new limit." @@ -251,11 +251,11 @@ msgstr "" "回傳目前的剖析器 (parser) 允許的最大字串大小。如果 *new_limit* 被給定,則會變" "成新的最大字串大小。" -#: ../../library/csv.rst:163 +#: ../../library/csv.rst:161 msgid "The :mod:`!csv` module defines the following classes:" msgstr ":mod:`!csv` 模組定義了下列的類別:" -#: ../../library/csv.rst:168 +#: ../../library/csv.rst:166 msgid "" "Create an object that operates like a regular reader but maps the " "information in each row to a :class:`dict` whose keys are given by the " @@ -264,7 +264,7 @@ msgstr "" "建立一個物件,其運作上就像一般的讀取器,但可以將每一列資訊 map (對映) 到 :" "class:`dict` 中,可以透過選填的參數 *fieldnames* 設定 key。" -#: ../../library/csv.rst:172 +#: ../../library/csv.rst:170 msgid "" "The *fieldnames* parameter is a :term:`sequence`. If *fieldnames* is " "omitted, the values in the first row of file *f* will be used as the " @@ -278,7 +278,7 @@ msgstr "" "供,它們就會被使用,且第一列會被包含在結果中。不管欄位標題是如何決定的," "dictionary 都會保留原始的排序。" -#: ../../library/csv.rst:179 +#: ../../library/csv.rst:177 msgid "" "If a row has more fields than fieldnames, the remaining data is put in a " "list and stored with the fieldname specified by *restkey* (which defaults to " @@ -290,28 +290,28 @@ msgstr "" "``None``)特指的欄位標題會放入列表當中並儲存。如果一個非空的 (non-blank) 列中" "的欄位比欄位標題還少,缺少的值則會填入 *restval* (預設為 ``None``)的值。" -#: ../../library/csv.rst:185 +#: ../../library/csv.rst:183 msgid "" "All other optional or keyword arguments are passed to the underlying :class:" "`reader` instance." msgstr "所有其他選填的引數或關鍵字引數皆會傳遞至下層的 :class:`reader` 實例。" -#: ../../library/csv.rst:188 ../../library/csv.rst:240 +#: ../../library/csv.rst:186 ../../library/csv.rst:238 msgid "" "If the argument passed to *fieldnames* is an iterator, it will be coerced to " "a :class:`list`." msgstr "" "如果傳遞至 *fieldnames* 的引數是個疊代器,則會被迫成為一個 :class:`list`。" -#: ../../library/csv.rst:190 +#: ../../library/csv.rst:188 msgid "Returned rows are now of type :class:`OrderedDict`." msgstr "回傳的列已成為型別 :class:`OrderedDict`。" -#: ../../library/csv.rst:193 +#: ../../library/csv.rst:191 msgid "Returned rows are now of type :class:`dict`." msgstr "回傳的列已成為型別 :class:`dict`。" -#: ../../library/csv.rst:198 +#: ../../library/csv.rst:196 msgid "" ">>> import csv\n" ">>> with open('names.csv', newline='') as csvfile:\n" @@ -337,18 +337,18 @@ msgstr "" ">>> print(row)\n" "{'first_name': 'John', 'last_name': 'Cleese'}" -#: ../../library/csv.rst:210 +#: ../../library/csv.rst:208 msgid "where :file:`names.csv` contains:" msgstr "" -#: ../../library/csv.rst:212 +#: ../../library/csv.rst:210 msgid "" "first_name,last_name\n" "Eric,Idle\n" "John,Cleese" msgstr "" -#: ../../library/csv.rst:222 +#: ../../library/csv.rst:220 msgid "" "Create an object which operates like a regular writer but maps dictionaries " "onto output rows. The *fieldnames* parameter is a :mod:`sequence " @@ -373,7 +373,7 @@ msgstr "" "被設定為 ``'ignore'``,dictionary 中額外的值會被忽略。其他選填的引數或關鍵字" "引數皆會傳遞至下層的 :class:`writer` 實例。" -#: ../../library/csv.rst:237 +#: ../../library/csv.rst:235 msgid "" "Note that unlike the :class:`DictReader` class, the *fieldnames* parameter " "of the :class:`DictWriter` class is not optional." @@ -381,7 +381,7 @@ msgstr "" "請記得這不像類別 :class:`DictReader`,在類別 :class:`DictWriter` 中,參數 " "*fieldnames* 並不是選填的。" -#: ../../library/csv.rst:244 +#: ../../library/csv.rst:242 msgid "" "import csv\n" "\n" @@ -405,11 +405,11 @@ msgstr "" " writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'})\n" " writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'})" -#: ../../library/csv.rst:255 +#: ../../library/csv.rst:253 msgid "which writes :file:`names.csv` containing:" msgstr "" -#: ../../library/csv.rst:257 +#: ../../library/csv.rst:255 msgid "" "first_name,last_name\n" "Baked,Beans\n" @@ -417,7 +417,7 @@ msgid "" "Wonderful,Spam" msgstr "" -#: ../../library/csv.rst:267 +#: ../../library/csv.rst:265 msgid "" "The :class:`Dialect` class is a container class whose attributes contain " "information for how to handle doublequotes, whitespace, delimiters, etc. Due " @@ -430,7 +430,7 @@ msgstr "" "巧妙不同的 CSV 資料。:class:`Dialect` 實例定義了 :class:`reader` 以及 :class:" "`writer` 的實例該如何表示。" -#: ../../library/csv.rst:273 +#: ../../library/csv.rst:271 msgid "" "All available :class:`Dialect` names are returned by :func:`list_dialects`, " "and they can be registered with specific :class:`reader` and :class:`writer` " @@ -440,7 +440,7 @@ msgstr "" "透過特定 :class:`reader` 及 :class:`writer` 類別的初始器 (initializer, " "``__init__``) 函式進行註冊,就像這樣: ::" -#: ../../library/csv.rst:277 +#: ../../library/csv.rst:275 msgid "" "import csv\n" "\n" @@ -452,7 +452,7 @@ msgstr "" "with open('students.csv', 'w', newline='') as csvfile:\n" " writer = csv.writer(csvfile, dialect='unix')" -#: ../../library/csv.rst:285 +#: ../../library/csv.rst:283 msgid "" "The :class:`excel` class defines the usual properties of an Excel-generated " "CSV file. It is registered with the dialect name ``'excel'``." @@ -460,7 +460,7 @@ msgstr "" "類別 :class:`excel` 定義了透過 Excel 產生的 CSV 檔案的慣用屬性。它被註冊的 " "dialect 名稱為 ``'excel'``。" -#: ../../library/csv.rst:291 +#: ../../library/csv.rst:289 msgid "" "The :class:`excel_tab` class defines the usual properties of an Excel-" "generated TAB-delimited file. It is registered with the dialect name " @@ -469,7 +469,7 @@ msgstr "" "類別 :class:`excel_tab` 定義了透過 Excel 產生並以 Tab 作為分隔的 CSV 檔案的慣" "用屬性。它被註冊的 dialect 名稱為 ``'excel-tab'``。" -#: ../../library/csv.rst:297 +#: ../../library/csv.rst:295 msgid "" "The :class:`unix_dialect` class defines the usual properties of a CSV file " "generated on UNIX systems, i.e. using ``'\\n'`` as line terminator and " @@ -479,15 +479,15 @@ msgstr "" "句話說,使用 ``'\\n'`` 作為換行符號且所有欄位都被引號包覆起來。它被註冊的 " "dialect 名稱為 ``'unix'``。" -#: ../../library/csv.rst:306 +#: ../../library/csv.rst:304 msgid "The :class:`Sniffer` class is used to deduce the format of a CSV file." msgstr "類別 :class:`Sniffer` 被用來推斷 CSV 檔案的格式。" -#: ../../library/csv.rst:308 +#: ../../library/csv.rst:306 msgid "The :class:`Sniffer` class provides two methods:" msgstr "類別 :class:`Sniffer` 提供了兩個 method:" -#: ../../library/csv.rst:312 +#: ../../library/csv.rst:310 msgid "" "Analyze the given *sample* and return a :class:`Dialect` subclass reflecting " "the parameters found. If the optional *delimiters* parameter is given, it " @@ -497,7 +497,7 @@ msgstr "" "數。如果給定選填的參數 *delimiters*,它會被解釋為一個字串且含有可能、有效的分" "隔字元。" -#: ../../library/csv.rst:317 +#: ../../library/csv.rst:315 msgid "" "If several delimiters fit the sample equally well --- for example if both " "``','`` and ``';'`` split every row consistently --- the delimiters listed " @@ -505,7 +505,7 @@ msgid "" "matter how many times each of them occurs." msgstr "" -#: ../../library/csv.rst:325 +#: ../../library/csv.rst:323 msgid "" "Analyze the sample text (presumed to be in CSV format) and return :const:" "`True` if the first row appears to be a series of column headers. Inspecting " @@ -516,18 +516,18 @@ msgstr "" "格式)並回傳 :const:`True`。檢查每一欄時,會考慮是否滿足兩個關鍵標準其中之" "一,判斷 sample 是否包含標題:" -#: ../../library/csv.rst:330 +#: ../../library/csv.rst:328 msgid "the second through n-th rows contain numeric values" msgstr "第二列至第 n 列包含數字" -#: ../../library/csv.rst:331 +#: ../../library/csv.rst:329 msgid "" "the second through n-th rows contain strings where at least one value's " "length differs from that of the putative header of that column." msgstr "" "第二列到第 n 列包含的字串中至少有一個值的長度與該行的假定標題的長度不同。" -#: ../../library/csv.rst:334 +#: ../../library/csv.rst:332 msgid "" "Twenty-one rows after the header are sampled; if more than half of the " "columns + rows meet the criteria, :const:`True` is returned." @@ -535,7 +535,7 @@ msgstr "" "對標頭之後的二十一個列進行取樣;如果超過一半的行及列滿足條件,則回傳 :const:" "`True`。" -#: ../../library/csv.rst:339 +#: ../../library/csv.rst:337 msgid "" "This method is a rough heuristic and may produce both false positives and " "negatives." @@ -543,22 +543,22 @@ msgstr "" "此方法是一個粗略的啟發,可能會產生偽陽性及偽陰性 (false positives and " "negatives)。" -#: ../../library/csv.rst:342 +#: ../../library/csv.rst:340 msgid "The :class:`Sniffer` class has the following attribute:" msgstr ":class:`Sniffer` 類別有以下屬性:" -#: ../../library/csv.rst:346 +#: ../../library/csv.rst:344 msgid "" "The list of the delimiters preferred for breaking ties, in the order of " "preference. It can be modified. Its initial value is ``[',', '\\t', ';', ' " "', ':']``." msgstr "" -#: ../../library/csv.rst:351 +#: ../../library/csv.rst:349 msgid "An example for :class:`Sniffer` use::" msgstr "一個 :class:`Sniffer` 的使用範例: ::" -#: ../../library/csv.rst:353 +#: ../../library/csv.rst:351 msgid "" "with open('example.csv', newline='') as csvfile:\n" " dialect = csv.Sniffer().sniff(csvfile.read(1024))\n" @@ -572,15 +572,15 @@ msgstr "" " reader = csv.reader(csvfile, dialect)\n" " # ... 在這邊處理 CSV 檔案 ..." -#: ../../library/csv.rst:362 +#: ../../library/csv.rst:360 msgid "The :mod:`!csv` module defines the following constants:" msgstr ":mod:`!csv` 模組定義了以下常數:" -#: ../../library/csv.rst:366 +#: ../../library/csv.rst:364 msgid "Instructs :class:`writer` objects to quote all fields." msgstr "引導 :class:`writer` 物件引用所有欄位。" -#: ../../library/csv.rst:371 +#: ../../library/csv.rst:369 msgid "" "Instructs :class:`writer` objects to only quote those fields which contain " "special characters such as *delimiter*, *quotechar*, ``'\\r'``, ``'\\n'`` or " @@ -593,17 +593,17 @@ msgstr "" "*doublequote* 為 :const:`False` 且有設定 *escapechar*,則會跳脫 *quotechar*," "而不是將該欄位加上引號。" -#: ../../library/csv.rst:380 +#: ../../library/csv.rst:378 msgid "Instructs :class:`writer` objects to quote all non-numeric fields." msgstr "引導 :class:`writer` 物件引用所有非數字的欄位。" -#: ../../library/csv.rst:382 +#: ../../library/csv.rst:380 msgid "" "Instructs :class:`reader` objects to convert all non-quoted fields to type :" "class:`float`." msgstr "引導 :class:`reader` 物件轉換所有非引用的欄位為 :class:`float`。" -#: ../../library/csv.rst:385 +#: ../../library/csv.rst:383 msgid "" "Some numeric types, such as :class:`bool`, :class:`~fractions.Fraction`, or :" "class:`~enum.IntEnum`, have a string representation that cannot be converted " @@ -611,7 +611,7 @@ msgid "" "data:`QUOTE_STRINGS` modes." msgstr "" -#: ../../library/csv.rst:393 +#: ../../library/csv.rst:391 msgid "" "Instructs :class:`writer` objects to never quote fields. When the current " "*delimiter*, *quotechar*, *escapechar*, ``'\\r'``, ``'\\n'`` or any of the " @@ -625,13 +625,13 @@ msgstr "" "前的字元是目前的 *escapechar*。如果沒有設定 *escapechar*,若遇到任何字元需要" "逸出,寫入器則會引發 :exc:`Error`。設定 *quotechar* 為 ``None`` 以防止逸出。" -#: ../../library/csv.rst:401 +#: ../../library/csv.rst:399 msgid "" "Instructs :class:`reader` objects to perform no special processing of quote " "characters." msgstr "引導 :class:`reader` 物件不對引號進行特別處理。" -#: ../../library/csv.rst:405 +#: ../../library/csv.rst:403 msgid "" "Instructs :class:`writer` objects to quote all fields which are not " "``None``. This is similar to :data:`QUOTE_ALL`, except that if a field " @@ -640,7 +640,7 @@ msgstr "" "引導 :class:`writer` 物件引用所有非 ``None`` 的欄位。這與 :data:`QUOTE_ALL` " "相似,除非如果欄位值為 ``None``,該欄位則被寫成空(沒有引號)字串。" -#: ../../library/csv.rst:409 +#: ../../library/csv.rst:407 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) field as " "``None`` and to otherwise behave as :data:`QUOTE_ALL`." @@ -648,7 +648,7 @@ msgstr "" "引導 :class:`reader` 物件將空(沒有引號)欄位直譯 (interpret) 為 ``None``,否" "則會和 :data:`QUOTE_ALL` 有相同的表現方式。" -#: ../../library/csv.rst:416 +#: ../../library/csv.rst:414 msgid "" "Instructs :class:`writer` objects to always place quotes around fields which " "are strings. This is similar to :data:`QUOTE_NONNUMERIC`, except that if a " @@ -658,7 +658,7 @@ msgstr "" "`QUOTE_NONNUMERIC` 相似,除非如果欄位值為 ``None``,該欄位則被寫成空(沒有引" "號)字串。" -#: ../../library/csv.rst:420 +#: ../../library/csv.rst:418 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) string as " "``None`` and to otherwise behave as :data:`QUOTE_NONNUMERIC`." @@ -666,19 +666,19 @@ msgstr "" "引導 :class:`reader` 物件將空(沒有引號)字串直譯為 ``None``,否則會和 :data:" "`QUOTE_NONNUMERIC` 有相同的表現方式。" -#: ../../library/csv.rst:425 +#: ../../library/csv.rst:423 msgid "The :mod:`!csv` module defines the following exception:" msgstr ":mod:`!csv` 模組定義下列例外:" -#: ../../library/csv.rst:430 +#: ../../library/csv.rst:428 msgid "Raised by any of the functions when an error is detected." msgstr "當偵測到錯誤時,任何函式都可以引發。" -#: ../../library/csv.rst:435 -msgid "Dialects and Formatting Parameters" +#: ../../library/csv.rst:433 +msgid "Dialects and formatting parameters" msgstr "Dialect 與格式參數" -#: ../../library/csv.rst:437 +#: ../../library/csv.rst:435 msgid "" "To make it easier to specify the format of input and output records, " "specific formatting parameters are grouped together into dialects. A " @@ -697,16 +697,16 @@ msgstr "" "代,在\\ *dialect*\\ 參數中,程式設計師可以指定個別的格式化參數,其與 :class:" "`Dialect` 類別定義的屬性具有相同的名字。" -#: ../../library/csv.rst:447 +#: ../../library/csv.rst:445 msgid "Dialects support the following attributes:" msgstr "Dialect 支援下列屬性:" -#: ../../library/csv.rst:452 +#: ../../library/csv.rst:450 msgid "" "A one-character string used to separate fields. It defaults to ``','``." msgstr "一個單一字元 (one-character) 的字串可已用來分割欄位。預設為 ``','``。" -#: ../../library/csv.rst:457 +#: ../../library/csv.rst:455 msgid "" "Controls how instances of *quotechar* appearing inside a field should " "themselves be quoted. When :const:`True`, the character is doubled. When :" @@ -717,7 +717,7 @@ msgstr "" "為 :const:`True`,字元會是雙引號。若為 :const:`False`,在 *quotechar* 之前會" "先使用 *escapechar* 作為前綴字。預設為 :const:`True`。" -#: ../../library/csv.rst:462 +#: ../../library/csv.rst:460 msgid "" "On output, if *doublequote* is :const:`False` and no *escapechar* is set, :" "exc:`Error` is raised if a *quotechar* is found in a field." @@ -725,28 +725,28 @@ msgstr "" "在輸出時,若 *doublequote* 是 :const:`False` 且\\ *逸出字元*\\ 沒有被設定,當" "一個\\ *引號*\\ 在欄位中被發現時,:exc:`Error` 會被引發。" -#: ../../library/csv.rst:468 +#: ../../library/csv.rst:466 msgid "" "A one-character string used by the writer to escape characters that require " "escaping:" msgstr "一個單一字元的字串,會被寫入器用來逸出需要逸出的字元:" -#: ../../library/csv.rst:471 +#: ../../library/csv.rst:469 msgid "" "the *delimiter*, the *quotechar*, ``'\\r'``, ``'\\n'`` and any of the " "characters in *lineterminator* are escaped if *quoting* is set to :const:" "`QUOTE_NONE`;" msgstr "" -#: ../../library/csv.rst:474 +#: ../../library/csv.rst:472 msgid "the *quotechar* is escaped if *doublequote* is :const:`False`;" msgstr "" -#: ../../library/csv.rst:475 +#: ../../library/csv.rst:473 msgid "the *escapechar* itself." msgstr "*escapechar* 本身。" -#: ../../library/csv.rst:477 +#: ../../library/csv.rst:475 msgid "" "On reading, the *escapechar* removes any special meaning from the following " "character. It defaults to :const:`None`, which disables escaping." @@ -754,22 +754,22 @@ msgstr "" "在讀取時,*escapechar* 會移除後面字元的任何特殊意義。預設為 :const:`None`,表" "示禁止逸出。" -#: ../../library/csv.rst:480 +#: ../../library/csv.rst:478 msgid "" "Previously the *escapechar* itself was not escaped, which lost it on reading." msgstr "" -#: ../../library/csv.rst:484 +#: ../../library/csv.rst:482 msgid "An empty *escapechar* is not allowed." msgstr "*escapechar* 為空是不被接受的。" -#: ../../library/csv.rst:489 +#: ../../library/csv.rst:487 msgid "" "The string used to terminate lines produced by the :class:`writer`. It " "defaults to ``'\\r\\n'``." msgstr "由 :class:`writer` 產生被用來分行的字串。預設為 ``'\\r\\n'``。" -#: ../../library/csv.rst:494 +#: ../../library/csv.rst:492 msgid "" "The :class:`reader` is hard-coded to recognise either ``'\\r'`` or ``'\\n'`` " "as end-of-line, and ignores *lineterminator*. This behavior may change in " @@ -778,7 +778,7 @@ msgstr "" ":class:`reader` 是 hard-coded 辨別 ``'\\r'`` or ``'\\n'`` 作為行尾 (end-of-" "line),並忽略\\ *lineterminator*。未來可能會改變這個行為。" -#: ../../library/csv.rst:501 +#: ../../library/csv.rst:499 msgid "" "A one-character string used to quote fields containing special characters, " "such as the *delimiter* or the *quotechar*, or which contain new-line " @@ -791,11 +791,11 @@ msgstr "" "元)。預設為 ``'\"'``。如果 *quoting* 設定為 :const:`QUOTE_NONE`,可以設定為 " "``None`` 以防止逸出 ``'\"'``。" -#: ../../library/csv.rst:508 +#: ../../library/csv.rst:506 msgid "An empty *quotechar* is not allowed." msgstr "*quotechar* 為空是不被允許的。" -#: ../../library/csv.rst:513 +#: ../../library/csv.rst:511 msgid "" "Controls when quotes should be generated by the writer and recognised by the " "reader. It can take on any of the :ref:`QUOTE_\\* constants `\\ 且預設為 :" "const:`QUOTE_MINIMAL`。否則預設為 :const:`QUOTE_NONE`。" -#: ../../library/csv.rst:521 +#: ../../library/csv.rst:519 msgid "" "When :const:`True`, spaces immediately following the *delimiter* are " "ignored. The default is :const:`False`. When combining ``delimiter=' '`` " @@ -816,18 +816,18 @@ msgstr "" "`False`。當結合 ``delimiter=' '`` 與 ``skipinitialspace=True`` 時,不允許沒有" "引號的空欄位。" -#: ../../library/csv.rst:528 +#: ../../library/csv.rst:526 msgid "" "When ``True``, raise exception :exc:`Error` on bad CSV input. The default is " "``False``." msgstr "" "若為 ``True``,若有錯誤的 CSV 輸入則會引發 :exc:`Error`。預設為 ``False``。" -#: ../../library/csv.rst:534 -msgid "Reader Objects" +#: ../../library/csv.rst:532 +msgid "Reader objects" msgstr "讀取器物件" -#: ../../library/csv.rst:536 +#: ../../library/csv.rst:534 msgid "" "Reader objects (:class:`DictReader` instances and objects returned by the :" "func:`reader` function) have the following public methods:" @@ -835,7 +835,7 @@ msgstr "" "讀取器物件(:func:`reader` 函式回傳的 :class:`DictReader` 實例與物件)有下列" "公開方法 (public method):" -#: ../../library/csv.rst:541 +#: ../../library/csv.rst:539 msgid "" "Return the next row of the reader's iterable object as a list (if the object " "was returned from :func:`reader`) or a dict (if it is a :class:`DictReader` " @@ -846,25 +846,25 @@ msgstr "" "傳)或是一個 dict(若為 :class:`DictReader` 實例),會依據目前的 :class:" "`Dialect` 進行剖析。通常會用 ``next(reader)`` 來進行呼叫。" -#: ../../library/csv.rst:547 +#: ../../library/csv.rst:545 msgid "Reader objects have the following public attributes:" msgstr "讀取器物件有下列公開屬性 (public attributes):" -#: ../../library/csv.rst:551 +#: ../../library/csv.rst:549 msgid "A read-only description of the dialect in use by the parser." msgstr "dialect 的唯讀敘述,會被剖析器使用。" -#: ../../library/csv.rst:556 +#: ../../library/csv.rst:554 msgid "" "The number of lines read from the source iterator. This is not the same as " "the number of records returned, as records can span multiple lines." msgstr "來源疊代器所讀取的行數。這與回傳的紀錄數不同,因為可以進行跨行紀錄。" -#: ../../library/csv.rst:560 +#: ../../library/csv.rst:558 msgid "DictReader objects have the following public attribute:" msgstr "DictReader 物件有下列公開屬性:" -#: ../../library/csv.rst:564 +#: ../../library/csv.rst:562 msgid "" "If not passed as a parameter when creating the object, this attribute is " "initialized upon first access or when the first record is read from the file." @@ -872,11 +872,11 @@ msgstr "" "若在建立物件時沒有作為參數傳遞,這個屬性會在第一次存取之前或是第一筆資料被讀" "取之前進行初始化 (initialize)。" -#: ../../library/csv.rst:571 -msgid "Writer Objects" +#: ../../library/csv.rst:569 +msgid "Writer objects" msgstr "寫入器物件" -#: ../../library/csv.rst:573 +#: ../../library/csv.rst:571 msgid "" ":class:`writer` objects (:class:`DictWriter` instances and objects returned " "by the :func:`writer` function) have the following public methods. A *row* " @@ -894,7 +894,7 @@ msgstr "" "遞)。請注意,在寫入複數 (complex number) 時會用小括號 (parens) 包起來。這可" "能在其他程式讀取 CSV 檔案時導致某些問題(假設他們完全支援複雜數字)。" -#: ../../library/csv.rst:584 +#: ../../library/csv.rst:582 msgid "" "Write the *row* parameter to the writer's file object, formatted according " "to the current :class:`Dialect`. Return the return value of the call to the " @@ -903,11 +903,11 @@ msgstr "" "將參數 *row* 寫入至寫入器的檔案物件中,並依照目前的 :class:`Dialect` 進行格式" "化。回傳下層檔案物件 *write* 方法的回傳值。" -#: ../../library/csv.rst:588 +#: ../../library/csv.rst:586 msgid "Added support of arbitrary iterables." msgstr "新增對任意可疊代物件 (arbitrary iterables) 的支援。" -#: ../../library/csv.rst:593 +#: ../../library/csv.rst:591 msgid "" "Write all elements in *rows* (an iterable of *row* objects as described " "above) to the writer's file object, formatted according to the current " @@ -916,19 +916,19 @@ msgstr "" "將 *rows* 中所有元素(為上述的一個可疊代的 *row* 物件)寫入至寫入器的檔案物件" "中,並依照目前的 dialect 進行格式化。" -#: ../../library/csv.rst:597 +#: ../../library/csv.rst:595 msgid "Writer objects have the following public attribute:" msgstr "寫入器物件有下列公開屬性:" -#: ../../library/csv.rst:602 +#: ../../library/csv.rst:600 msgid "A read-only description of the dialect in use by the writer." msgstr "dialect 的唯讀敘述,會被寫入器使用。" -#: ../../library/csv.rst:605 +#: ../../library/csv.rst:603 msgid "DictWriter objects have the following public method:" msgstr "DictWriter 物件有下列公開方法:" -#: ../../library/csv.rst:610 +#: ../../library/csv.rst:608 msgid "" "Write a row with the field names (as specified in the constructor) to the " "writer's file object, formatted according to the current dialect. Return the " @@ -938,7 +938,7 @@ msgstr "" "中,並依照目前的 dialect 進行格式化。回傳內部呼叫 :meth:`csvwriter.writerow` " "的回傳值。" -#: ../../library/csv.rst:615 +#: ../../library/csv.rst:613 msgid "" ":meth:`writeheader` now also returns the value returned by the :meth:" "`csvwriter.writerow` method it uses internally." @@ -946,15 +946,15 @@ msgstr "" ":meth:`writeheader` 現在也會回傳內部呼叫 :meth:`csvwriter.writerow` 的回傳" "值。" -#: ../../library/csv.rst:623 +#: ../../library/csv.rst:621 msgid "Examples" msgstr "範例" -#: ../../library/csv.rst:625 +#: ../../library/csv.rst:623 msgid "The simplest example of reading a CSV file::" msgstr "最簡單的讀取 CSV 檔案範例: ::" -#: ../../library/csv.rst:627 +#: ../../library/csv.rst:625 msgid "" "import csv\n" "with open('some.csv', newline='') as f:\n" @@ -968,11 +968,11 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:633 +#: ../../library/csv.rst:631 msgid "Reading a file with an alternate format::" msgstr "讀取一個其他格式的檔案: ::" -#: ../../library/csv.rst:635 +#: ../../library/csv.rst:633 msgid "" "import csv\n" "with open('passwd', newline='') as f:\n" @@ -986,11 +986,11 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:641 +#: ../../library/csv.rst:639 msgid "The corresponding simplest possible writing example is::" msgstr "相對最簡單、可行的寫入範例為: ::" -#: ../../library/csv.rst:643 +#: ../../library/csv.rst:641 msgid "" "import csv\n" "with open('some.csv', 'w', newline='') as f:\n" @@ -1002,44 +1002,43 @@ msgstr "" " writer = csv.writer(f)\n" " writer.writerows(someiterable)" -#: ../../library/csv.rst:648 +#: ../../library/csv.rst:646 msgid "" "Since :func:`open` is used to open a CSV file for reading, the file will by " -"default be decoded into unicode using the system default encoding (see :func:" -"`locale.getencoding`). To decode a file using a different encoding, use the " -"``encoding`` argument of open::" +"default be decoded into Unicode using UTF-8. To decode a file using a " +"different encoding, use the ``encoding`` argument of open::" msgstr "" -"當 :func:`open` 被使用於開啟並讀取一個 CSV 檔案,該檔案會預設使用系統預設的編" -"碼格式(請見 :func:`locale.getencoding`),並解碼為 unicode。若要使用不同編碼" -"格式進行檔案解碼,請使用 open 函式的 ``encoding`` 引數: ::" +"當 :func:`open` 被使用於開啟並讀取一個 CSV 檔案,該檔案會預設使用 UTF-8 解碼" +"為 Unicode。若要使用不同編碼格式進行檔案解碼,請使用 open 函式的 " +"``encoding`` 引數: ::" -#: ../../library/csv.rst:653 +#: ../../library/csv.rst:650 msgid "" "import csv\n" -"with open('some.csv', newline='', encoding='utf-8') as f:\n" +"with open('some.csv', newline='', encoding='latin-1') as f:\n" " reader = csv.reader(f)\n" " for row in reader:\n" " print(row)" msgstr "" "import csv\n" -"with open('some.csv', newline='', encoding='utf-8') as f:\n" +"with open('some.csv', newline='', encoding='latin-1') as f:\n" " reader = csv.reader(f)\n" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:659 +#: ../../library/csv.rst:656 msgid "" -"The same applies to writing in something other than the system default " -"encoding: specify the encoding argument when opening the output file." +"The same applies to writing in something other than the default encoding: " +"specify the encoding argument when opening the output file." msgstr "" -"同理可以應用到使用不同編碼格式進行寫入:當開啟輸出檔案時,指定 ``encoding`` " -"引數。" +"同理可以應用到使用不同編碼格式進行寫入:當開啟輸出檔案時,指定 encoding 引" +"數。" -#: ../../library/csv.rst:662 +#: ../../library/csv.rst:659 msgid "Registering a new dialect::" msgstr "註冊一個新的 dialect : ::" -#: ../../library/csv.rst:664 +#: ../../library/csv.rst:661 msgid "" "import csv\n" "csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE)\n" @@ -1051,13 +1050,13 @@ msgstr "" "with open('passwd', newline='') as f:\n" " reader = csv.reader(f, 'unixpwd')" -#: ../../library/csv.rst:669 +#: ../../library/csv.rst:666 msgid "" "A slightly more advanced use of the reader --- catching and reporting " "errors::" msgstr "稍微進階的讀取器用法 -- 擷取及回報錯誤: ::" -#: ../../library/csv.rst:671 +#: ../../library/csv.rst:668 msgid "" "import csv, sys\n" "filename = 'some.csv'\n" @@ -1079,13 +1078,13 @@ msgstr "" " except csv.Error as e:\n" " sys.exit(f'file {filename}, line {reader.line_num}: {e}')" -#: ../../library/csv.rst:681 +#: ../../library/csv.rst:678 msgid "" "And while the module doesn't directly support parsing strings, it can easily " "be done::" msgstr "而當模組無法直接支援剖析字串時,仍可以輕鬆的解決: ::" -#: ../../library/csv.rst:684 +#: ../../library/csv.rst:681 msgid "" "import csv\n" "for row in csv.reader(['one,two,three']):\n" @@ -1095,11 +1094,11 @@ msgstr "" "for row in csv.reader(['one,two,three']):\n" " print(row)" -#: ../../library/csv.rst:690 +#: ../../library/csv.rst:687 msgid "Footnotes" msgstr "註解" -#: ../../library/csv.rst:691 +#: ../../library/csv.rst:688 msgid "" "If ``newline=''`` is not specified, newlines embedded inside quoted fields " "will not be interpreted correctly, and on platforms that use ``\\r\\n`` line " @@ -1112,22 +1111,22 @@ msgstr "" "己 (:term:`統一的 `) 換行處理方式,因此指定 " "``newline=''`` 會永遠是安全的。" -#: ../../library/csv.rst:11 +#: ../../library/csv.rst:9 msgid "csv" msgstr "csv" -#: ../../library/csv.rst:11 +#: ../../library/csv.rst:9 msgid "data" msgstr "data(資料)" -#: ../../library/csv.rst:11 +#: ../../library/csv.rst:9 msgid "tabular" msgstr "tabular(表格)" -#: ../../library/csv.rst:53 +#: ../../library/csv.rst:51 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/csv.rst:53 +#: ../../library/csv.rst:51 msgid "csv.reader function" msgstr "csv.reader 函式" diff --git a/library/ctypes.po b/library/ctypes.po index 09a43a8a505..efccf40b90c 100644 --- a/library/ctypes.po +++ b/library/ctypes.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-13 00:23+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-04-26 02:59+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!ctypes` --- A foreign function library for Python" msgstr ":mod:`!ctypes` --- 用於 Python 的外部函式庫" -#: ../../library/ctypes.rst:9 +#: ../../library/ctypes.rst:7 msgid "**Source code:** :source:`Lib/ctypes`" msgstr "**原始碼:**\\ :source:`Lib/ctypes`" -#: ../../library/ctypes.rst:13 +#: ../../library/ctypes.rst:11 msgid "" ":mod:`!ctypes` is a foreign function library for Python. It provides C " "compatible data types, and allows calling functions in DLLs or shared " @@ -41,7 +41,7 @@ msgid "" "module-requirements`." msgstr "" -#: ../../library/ctypes.rst:21 +#: ../../library/ctypes.rst:19 msgid "" ":mod:`!ctypes` provides low-level access to native libraries and the " "process's memory, bypassing Python's safety mechanisms and allowing " @@ -50,11 +50,11 @@ msgid "" "compromise the running process." msgstr "" -#: ../../library/ctypes.rst:31 +#: ../../library/ctypes.rst:29 msgid "ctypes tutorial" msgstr "ctypes 教學" -#: ../../library/ctypes.rst:33 +#: ../../library/ctypes.rst:31 msgid "" "Note: Some code samples reference the ctypes :class:`c_int` type. On " "platforms where ``sizeof(long) == sizeof(int)`` it is an alias to :class:" @@ -62,18 +62,18 @@ msgid "" "you would expect :class:`c_int` --- they are actually the same type." msgstr "" -#: ../../library/ctypes.rst:41 +#: ../../library/ctypes.rst:39 msgid "Loading dynamic link libraries" msgstr "" -#: ../../library/ctypes.rst:43 +#: ../../library/ctypes.rst:41 msgid "" ":mod:`!ctypes` exports the :py:data:`~ctypes.cdll`, and on Windows :py:data:" "`~ctypes.windll` and :py:data:`~ctypes.oledll` objects, for loading dynamic " "link libraries." msgstr "" -#: ../../library/ctypes.rst:47 +#: ../../library/ctypes.rst:45 msgid "" "You load libraries by accessing them as attributes of these objects. :py:" "data:`!cdll` loads libraries which export functions using the standard " @@ -85,20 +85,20 @@ msgid "" "fails." msgstr "" -#: ../../library/ctypes.rst:57 +#: ../../library/ctypes.rst:55 msgid "" "Windows errors used to raise :exc:`WindowsError`, which is now an alias of :" "exc:`OSError`." msgstr "" -#: ../../library/ctypes.rst:62 +#: ../../library/ctypes.rst:60 msgid "" "Here are some examples for Windows. Note that ``msvcrt`` is the MS standard " "C library containing most standard C functions, and uses the ``cdecl`` " "calling convention::" msgstr "" -#: ../../library/ctypes.rst:66 +#: ../../library/ctypes.rst:64 msgid "" ">>> from ctypes import *\n" ">>> print(windll.kernel32)\n" @@ -116,11 +116,11 @@ msgstr "" ">>> libc = cdll.msvcrt\n" ">>>" -#: ../../library/ctypes.rst:74 +#: ../../library/ctypes.rst:72 msgid "Windows appends the usual ``.dll`` file suffix automatically." msgstr "" -#: ../../library/ctypes.rst:77 +#: ../../library/ctypes.rst:75 msgid "" "Accessing the standard C library through ``cdll.msvcrt`` will use an " "outdated version of the library that may be incompatible with the one being " @@ -128,7 +128,7 @@ msgid "" "import and use the ``msvcrt`` module." msgstr "" -#: ../../library/ctypes.rst:82 +#: ../../library/ctypes.rst:80 msgid "" "Other systems require the filename *including* the extension to load a " "library, so attribute access can not be used to load libraries. Either the :" @@ -137,11 +137,11 @@ msgid "" "by calling the constructor." msgstr "" -#: ../../library/ctypes.rst:88 +#: ../../library/ctypes.rst:86 msgid "For example, on Linux::" msgstr "舉例來說,在 Linux 上: ::" -#: ../../library/ctypes.rst:90 +#: ../../library/ctypes.rst:88 msgid "" ">>> cdll.LoadLibrary(\"libc.so.6\")\n" "\n" @@ -157,11 +157,11 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:97 +#: ../../library/ctypes.rst:95 msgid "On macOS::" msgstr "在 macOS 上: ::" -#: ../../library/ctypes.rst:99 +#: ../../library/ctypes.rst:97 msgid "" ">>> cdll.LoadLibrary(\"libc.dylib\")\n" "\n" @@ -175,15 +175,15 @@ msgstr "" ">>> libc\n" "" -#: ../../library/ctypes.rst:110 +#: ../../library/ctypes.rst:108 msgid "Accessing functions from loaded dlls" msgstr "" -#: ../../library/ctypes.rst:112 +#: ../../library/ctypes.rst:110 msgid "Functions are accessed as attributes of dll objects::" msgstr "" -#: ../../library/ctypes.rst:114 +#: ../../library/ctypes.rst:112 msgid "" ">>> libc.printf\n" "<_FuncPtr object at 0x...>\n" @@ -209,7 +209,7 @@ msgstr "" "AttributeError: function 'MyOwnFunction' not found\n" ">>>" -#: ../../library/ctypes.rst:126 +#: ../../library/ctypes.rst:124 msgid "" "Note that win32 system dlls like ``kernel32`` and ``user32`` often export " "ANSI as well as UNICODE versions of a function. The UNICODE version is " @@ -220,7 +220,7 @@ msgid "" "``GetModuleHandle`` depending on whether UNICODE is defined or not::" msgstr "" -#: ../../library/ctypes.rst:134 +#: ../../library/ctypes.rst:132 msgid "" "/* ANSI version */\n" "HMODULE GetModuleHandleA(LPCSTR lpModuleName);\n" @@ -232,21 +232,21 @@ msgstr "" "/* UNICODE 版本 */\n" "HMODULE GetModuleHandleW(LPCWSTR lpModuleName);" -#: ../../library/ctypes.rst:139 +#: ../../library/ctypes.rst:137 msgid "" "*windll* does not try to select one of them by magic, you must access the " "version you need by specifying ``GetModuleHandleA`` or ``GetModuleHandleW`` " "explicitly, and then call it with bytes or string objects respectively." msgstr "" -#: ../../library/ctypes.rst:143 +#: ../../library/ctypes.rst:141 msgid "" "Sometimes, dlls export functions with names which aren't valid Python " "identifiers, like ``\"??2@YAPAXI@Z\"``. In this case you have to use :func:" "`getattr` to retrieve the function::" msgstr "" -#: ../../library/ctypes.rst:147 +#: ../../library/ctypes.rst:145 msgid "" ">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\")\n" "<_FuncPtr object at 0x...>\n" @@ -256,14 +256,14 @@ msgstr "" "<_FuncPtr object at 0x...>\n" ">>>" -#: ../../library/ctypes.rst:151 +#: ../../library/ctypes.rst:149 msgid "" "On Windows, some dlls export functions not by name but by ordinal. These " "functions can be accessed by indexing the dll object with the ordinal " "number::" msgstr "" -#: ../../library/ctypes.rst:154 +#: ../../library/ctypes.rst:152 msgid "" ">>> cdll.kernel32[1]\n" "<_FuncPtr object at 0x...>\n" @@ -285,18 +285,18 @@ msgstr "" "AttributeError: function ordinal 0 not found\n" ">>>" -#: ../../library/ctypes.rst:168 +#: ../../library/ctypes.rst:166 msgid "Calling functions" msgstr "呼叫函式" -#: ../../library/ctypes.rst:170 +#: ../../library/ctypes.rst:168 msgid "" "You can call these functions like any other Python callable. This example " "uses the ``rand()`` function, which takes no arguments and returns a pseudo-" "random integer::" msgstr "" -#: ../../library/ctypes.rst:173 +#: ../../library/ctypes.rst:171 msgid "" ">>> print(libc.rand())\n" "1804289383" @@ -304,14 +304,14 @@ msgstr "" ">>> print(libc.rand())\n" "1804289383" -#: ../../library/ctypes.rst:176 +#: ../../library/ctypes.rst:174 msgid "" "On Windows, you can call the ``GetModuleHandleA()`` function, which returns " "a win32 module handle (passing ``None`` as single argument to call it with a " "``NULL`` pointer)::" msgstr "" -#: ../../library/ctypes.rst:179 +#: ../../library/ctypes.rst:177 msgid "" ">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n" "0x1d000000\n" @@ -321,13 +321,13 @@ msgstr "" "0x1d000000\n" ">>>" -#: ../../library/ctypes.rst:183 +#: ../../library/ctypes.rst:181 msgid "" ":exc:`ValueError` is raised when you call an ``stdcall`` function with the " "``cdecl`` calling convention, or vice versa::" msgstr "" -#: ../../library/ctypes.rst:186 +#: ../../library/ctypes.rst:184 msgid "" ">>> cdll.kernel32.GetModuleHandleA(None)\n" "Traceback (most recent call last):\n" @@ -357,20 +357,20 @@ msgstr "" "excess)\n" ">>>" -#: ../../library/ctypes.rst:198 +#: ../../library/ctypes.rst:196 msgid "" "To find out the correct calling convention you have to look into the C " "header file or the documentation for the function you want to call." msgstr "" -#: ../../library/ctypes.rst:201 +#: ../../library/ctypes.rst:199 msgid "" "On Windows, :mod:`!ctypes` uses win32 structured exception handling to " "prevent crashes from general protection faults when functions are called " "with invalid argument values::" msgstr "" -#: ../../library/ctypes.rst:205 +#: ../../library/ctypes.rst:203 msgid "" ">>> windll.kernel32.GetModuleHandleA(32)\n" "Traceback (most recent call last):\n" @@ -384,13 +384,13 @@ msgstr "" "OSError: exception: access violation reading 0x00000020\n" ">>>" -#: ../../library/ctypes.rst:211 +#: ../../library/ctypes.rst:209 msgid "" "The :mod:`faulthandler` module can help debug crashes, such as segmentation " "faults produced by erroneous C library calls." msgstr "" -#: ../../library/ctypes.rst:214 +#: ../../library/ctypes.rst:212 msgid "" "``None``, integers, bytes objects and (unicode) strings are the only native " "Python objects that can directly be used as parameters in these function " @@ -401,483 +401,489 @@ msgid "" "the C type." msgstr "" -#: ../../library/ctypes.rst:221 +#: ../../library/ctypes.rst:219 msgid "" "Before we move on calling functions with other parameter types, we have to " "learn more about :mod:`!ctypes` data types." msgstr "" -#: ../../library/ctypes.rst:228 ../../library/ctypes.rst:2558 +#: ../../library/ctypes.rst:226 ../../library/ctypes.rst:2569 msgid "Fundamental data types" msgstr "" -#: ../../library/ctypes.rst:230 +#: ../../library/ctypes.rst:228 msgid ":mod:`!ctypes` defines a number of primitive C compatible data types:" msgstr "" -#: ../../library/ctypes.rst:235 ../../library/ctypes.rst:374 +#: ../../library/ctypes.rst:233 ../../library/ctypes.rst:372 msgid "ctypes type" msgstr "ctypes 型別" -#: ../../library/ctypes.rst:236 ../../library/ctypes.rst:375 +#: ../../library/ctypes.rst:234 ../../library/ctypes.rst:373 msgid "C type" msgstr "C 型別" -#: ../../library/ctypes.rst:237 ../../library/ctypes.rst:376 +#: ../../library/ctypes.rst:235 ../../library/ctypes.rst:374 msgid "Python type" msgstr "Python 型別" -#: ../../library/ctypes.rst:238 ../../library/ctypes.rst:377 +#: ../../library/ctypes.rst:236 ../../library/ctypes.rst:375 msgid ":py:attr:`~_SimpleCData._type_`" msgstr "" -#: ../../library/ctypes.rst:239 +#: ../../library/ctypes.rst:237 msgid ":class:`c_bool`" msgstr ":class:`c_bool`" -#: ../../library/ctypes.rst:240 +#: ../../library/ctypes.rst:238 msgid ":c:expr:`_Bool`" msgstr ":c:expr:`_Bool`" -#: ../../library/ctypes.rst:241 ../../library/ctypes.rst:365 +#: ../../library/ctypes.rst:239 ../../library/ctypes.rst:363 msgid ":py:class:`bool`" msgstr ":py:class:`bool`" -#: ../../library/ctypes.rst:242 +#: ../../library/ctypes.rst:240 msgid "``'?'``" msgstr "" -#: ../../library/ctypes.rst:243 +#: ../../library/ctypes.rst:241 msgid ":class:`c_char`" msgstr ":class:`c_char`" -#: ../../library/ctypes.rst:244 ../../library/ctypes.rst:252 +#: ../../library/ctypes.rst:242 ../../library/ctypes.rst:250 msgid ":c:expr:`char`" msgstr ":c:expr:`char`" -#: ../../library/ctypes.rst:245 +#: ../../library/ctypes.rst:243 msgid "1-character :py:class:`bytes`" msgstr "" -#: ../../library/ctypes.rst:246 +#: ../../library/ctypes.rst:244 msgid "``'c'``" msgstr "" -#: ../../library/ctypes.rst:247 +#: ../../library/ctypes.rst:245 msgid ":class:`c_wchar`" msgstr ":class:`c_wchar`" -#: ../../library/ctypes.rst:248 +#: ../../library/ctypes.rst:246 msgid ":c:type:`wchar_t`" msgstr ":c:type:`wchar_t`" -#: ../../library/ctypes.rst:249 +#: ../../library/ctypes.rst:247 msgid "1-character :py:class:`str`" msgstr "" -#: ../../library/ctypes.rst:250 +#: ../../library/ctypes.rst:248 msgid "``'u'``" msgstr "" -#: ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:249 msgid ":class:`c_byte`" msgstr ":class:`c_byte`" -#: ../../library/ctypes.rst:253 ../../library/ctypes.rst:257 -#: ../../library/ctypes.rst:261 ../../library/ctypes.rst:265 -#: ../../library/ctypes.rst:269 ../../library/ctypes.rst:273 -#: ../../library/ctypes.rst:277 ../../library/ctypes.rst:281 -#: ../../library/ctypes.rst:285 ../../library/ctypes.rst:289 -#: ../../library/ctypes.rst:293 ../../library/ctypes.rst:297 -#: ../../library/ctypes.rst:301 ../../library/ctypes.rst:305 -#: ../../library/ctypes.rst:309 ../../library/ctypes.rst:313 -#: ../../library/ctypes.rst:317 ../../library/ctypes.rst:321 -#: ../../library/ctypes.rst:325 ../../library/ctypes.rst:329 -#: ../../library/ctypes.rst:333 +#: ../../library/ctypes.rst:251 ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:259 ../../library/ctypes.rst:263 +#: ../../library/ctypes.rst:267 ../../library/ctypes.rst:271 +#: ../../library/ctypes.rst:275 ../../library/ctypes.rst:279 +#: ../../library/ctypes.rst:283 ../../library/ctypes.rst:287 +#: ../../library/ctypes.rst:291 ../../library/ctypes.rst:295 +#: ../../library/ctypes.rst:299 ../../library/ctypes.rst:303 +#: ../../library/ctypes.rst:307 ../../library/ctypes.rst:311 +#: ../../library/ctypes.rst:315 ../../library/ctypes.rst:319 +#: ../../library/ctypes.rst:323 ../../library/ctypes.rst:327 +#: ../../library/ctypes.rst:331 msgid ":py:class:`int`" msgstr ":py:class:`int`" -#: ../../library/ctypes.rst:254 +#: ../../library/ctypes.rst:252 msgid "``'b'``" msgstr "" -#: ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:253 msgid ":class:`c_ubyte`" msgstr ":class:`c_ubyte`" -#: ../../library/ctypes.rst:256 +#: ../../library/ctypes.rst:254 msgid ":c:expr:`unsigned char`" msgstr ":c:expr:`unsigned char`" -#: ../../library/ctypes.rst:258 +#: ../../library/ctypes.rst:256 msgid "``'B'``" msgstr "" -#: ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:257 msgid ":class:`c_short`" msgstr ":class:`c_short`" -#: ../../library/ctypes.rst:260 +#: ../../library/ctypes.rst:258 msgid ":c:expr:`short`" msgstr ":c:expr:`short`" -#: ../../library/ctypes.rst:262 +#: ../../library/ctypes.rst:260 msgid "``'h'``" msgstr "" -#: ../../library/ctypes.rst:263 +#: ../../library/ctypes.rst:261 msgid ":class:`c_ushort`" msgstr ":class:`c_ushort`" -#: ../../library/ctypes.rst:264 +#: ../../library/ctypes.rst:262 msgid ":c:expr:`unsigned short`" msgstr ":c:expr:`unsigned short`" -#: ../../library/ctypes.rst:266 +#: ../../library/ctypes.rst:264 msgid "``'H'``" msgstr "" -#: ../../library/ctypes.rst:267 +#: ../../library/ctypes.rst:265 msgid ":class:`c_int`" msgstr ":class:`c_int`" -#: ../../library/ctypes.rst:268 +#: ../../library/ctypes.rst:266 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../library/ctypes.rst:270 +#: ../../library/ctypes.rst:268 msgid "``'i'`` \\*" msgstr "" -#: ../../library/ctypes.rst:271 +#: ../../library/ctypes.rst:269 msgid ":class:`c_int8`" msgstr ":class:`c_int8`" -#: ../../library/ctypes.rst:272 +#: ../../library/ctypes.rst:270 msgid ":c:type:`int8_t`" msgstr ":c:type:`int8_t`" -#: ../../library/ctypes.rst:274 ../../library/ctypes.rst:278 -#: ../../library/ctypes.rst:282 ../../library/ctypes.rst:286 -#: ../../library/ctypes.rst:294 ../../library/ctypes.rst:298 -#: ../../library/ctypes.rst:302 ../../library/ctypes.rst:306 -#: ../../library/ctypes.rst:326 ../../library/ctypes.rst:330 -#: ../../library/ctypes.rst:334 +#: ../../library/ctypes.rst:272 ../../library/ctypes.rst:276 +#: ../../library/ctypes.rst:280 ../../library/ctypes.rst:284 +#: ../../library/ctypes.rst:292 ../../library/ctypes.rst:296 +#: ../../library/ctypes.rst:300 ../../library/ctypes.rst:304 +#: ../../library/ctypes.rst:324 ../../library/ctypes.rst:328 +#: ../../library/ctypes.rst:332 msgid "\\*" msgstr "" -#: ../../library/ctypes.rst:275 +#: ../../library/ctypes.rst:273 msgid ":class:`c_int16`" msgstr ":class:`c_int16`" -#: ../../library/ctypes.rst:276 +#: ../../library/ctypes.rst:274 msgid ":c:type:`int16_t`" msgstr ":c:type:`int16_t`" -#: ../../library/ctypes.rst:279 +#: ../../library/ctypes.rst:277 msgid ":class:`c_int32`" msgstr ":class:`c_int32`" -#: ../../library/ctypes.rst:280 +#: ../../library/ctypes.rst:278 msgid ":c:type:`int32_t`" msgstr ":c:type:`int32_t`" -#: ../../library/ctypes.rst:283 +#: ../../library/ctypes.rst:281 msgid ":class:`c_int64`" msgstr ":class:`c_int64`" -#: ../../library/ctypes.rst:284 +#: ../../library/ctypes.rst:282 msgid ":c:type:`int64_t`" msgstr ":c:type:`int64_t`" -#: ../../library/ctypes.rst:287 +#: ../../library/ctypes.rst:285 msgid ":class:`c_uint`" msgstr ":class:`c_uint`" -#: ../../library/ctypes.rst:288 +#: ../../library/ctypes.rst:286 msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../library/ctypes.rst:290 +#: ../../library/ctypes.rst:288 msgid "``'I'`` \\*" msgstr "" -#: ../../library/ctypes.rst:291 +#: ../../library/ctypes.rst:289 msgid ":class:`c_uint8`" msgstr ":class:`c_uint8`" -#: ../../library/ctypes.rst:292 +#: ../../library/ctypes.rst:290 msgid ":c:type:`uint8_t`" msgstr ":c:type:`uint8_t`" -#: ../../library/ctypes.rst:295 +#: ../../library/ctypes.rst:293 msgid ":class:`c_uint16`" msgstr ":class:`c_uint16`" -#: ../../library/ctypes.rst:296 +#: ../../library/ctypes.rst:294 msgid ":c:type:`uint16_t`" msgstr ":c:type:`uint16_t`" -#: ../../library/ctypes.rst:299 +#: ../../library/ctypes.rst:297 msgid ":class:`c_uint32`" msgstr ":class:`c_uint32`" -#: ../../library/ctypes.rst:300 +#: ../../library/ctypes.rst:298 msgid ":c:type:`uint32_t`" msgstr ":c:type:`uint32_t`" -#: ../../library/ctypes.rst:303 +#: ../../library/ctypes.rst:301 msgid ":class:`c_uint64`" msgstr ":class:`c_uint64`" -#: ../../library/ctypes.rst:304 +#: ../../library/ctypes.rst:302 msgid ":c:type:`uint64_t`" msgstr ":c:type:`uint64_t`" -#: ../../library/ctypes.rst:307 +#: ../../library/ctypes.rst:305 msgid ":class:`c_long`" msgstr ":class:`c_long`" -#: ../../library/ctypes.rst:308 +#: ../../library/ctypes.rst:306 msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../library/ctypes.rst:310 +#: ../../library/ctypes.rst:308 msgid "``'l'``" msgstr "" -#: ../../library/ctypes.rst:311 +#: ../../library/ctypes.rst:309 msgid ":class:`c_ulong`" msgstr ":class:`c_ulong`" -#: ../../library/ctypes.rst:312 +#: ../../library/ctypes.rst:310 msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../library/ctypes.rst:314 +#: ../../library/ctypes.rst:312 msgid "``'L'``" msgstr "" -#: ../../library/ctypes.rst:315 +#: ../../library/ctypes.rst:313 msgid ":class:`c_longlong`" msgstr ":class:`c_longlong`" -#: ../../library/ctypes.rst:316 +#: ../../library/ctypes.rst:314 msgid ":c:expr:`long long`" msgstr ":c:expr:`long long`" -#: ../../library/ctypes.rst:318 +#: ../../library/ctypes.rst:316 msgid "``'q'`` \\*" msgstr "" -#: ../../library/ctypes.rst:319 +#: ../../library/ctypes.rst:317 msgid ":class:`c_ulonglong`" msgstr ":class:`c_ulonglong`" -#: ../../library/ctypes.rst:320 +#: ../../library/ctypes.rst:318 msgid ":c:expr:`unsigned long long`" msgstr ":c:expr:`unsigned long long`" -#: ../../library/ctypes.rst:322 +#: ../../library/ctypes.rst:320 msgid "``'Q'`` \\*" msgstr "" -#: ../../library/ctypes.rst:323 +#: ../../library/ctypes.rst:321 msgid ":class:`c_size_t`" msgstr ":class:`c_size_t`" -#: ../../library/ctypes.rst:324 +#: ../../library/ctypes.rst:322 msgid ":c:type:`size_t`" msgstr ":c:type:`size_t`" -#: ../../library/ctypes.rst:327 +#: ../../library/ctypes.rst:325 msgid ":class:`c_ssize_t`" msgstr ":class:`c_ssize_t`" -#: ../../library/ctypes.rst:328 +#: ../../library/ctypes.rst:326 msgid ":c:type:`Py_ssize_t`" msgstr ":c:type:`Py_ssize_t`" -#: ../../library/ctypes.rst:331 +#: ../../library/ctypes.rst:329 msgid ":class:`c_time_t`" msgstr ":class:`c_time_t`" -#: ../../library/ctypes.rst:332 +#: ../../library/ctypes.rst:330 msgid ":c:type:`time_t`" msgstr ":c:type:`time_t`" -#: ../../library/ctypes.rst:335 +#: ../../library/ctypes.rst:333 msgid ":class:`c_float`" msgstr ":class:`c_float`" -#: ../../library/ctypes.rst:336 +#: ../../library/ctypes.rst:334 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../library/ctypes.rst:337 ../../library/ctypes.rst:341 -#: ../../library/ctypes.rst:345 +#: ../../library/ctypes.rst:335 ../../library/ctypes.rst:339 +#: ../../library/ctypes.rst:343 msgid ":py:class:`float`" msgstr ":py:class:`float`" -#: ../../library/ctypes.rst:338 +#: ../../library/ctypes.rst:336 msgid "``'f'``" msgstr "" -#: ../../library/ctypes.rst:339 +#: ../../library/ctypes.rst:337 msgid ":class:`c_double`" msgstr ":class:`c_double`" -#: ../../library/ctypes.rst:340 +#: ../../library/ctypes.rst:338 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../library/ctypes.rst:342 +#: ../../library/ctypes.rst:340 msgid "``'d'``" msgstr "" -#: ../../library/ctypes.rst:343 +#: ../../library/ctypes.rst:341 msgid ":class:`c_longdouble`" msgstr ":class:`c_longdouble`" -#: ../../library/ctypes.rst:344 +#: ../../library/ctypes.rst:342 msgid ":c:expr:`long double`" msgstr ":c:expr:`long double`" -#: ../../library/ctypes.rst:346 +#: ../../library/ctypes.rst:344 msgid "``'g'`` \\*" msgstr "" -#: ../../library/ctypes.rst:347 +#: ../../library/ctypes.rst:345 msgid ":class:`c_char_p`" msgstr ":class:`c_char_p`" -#: ../../library/ctypes.rst:348 +#: ../../library/ctypes.rst:346 msgid ":c:expr:`char *` (NUL terminated)" msgstr "" -#: ../../library/ctypes.rst:349 +#: ../../library/ctypes.rst:347 msgid ":py:class:`bytes` or ``None``" msgstr ":py:class:`bytes`\\ 或 ``None``" -#: ../../library/ctypes.rst:350 +#: ../../library/ctypes.rst:348 msgid "``'z'``" msgstr "" -#: ../../library/ctypes.rst:351 +#: ../../library/ctypes.rst:349 msgid ":class:`c_wchar_p`" msgstr ":class:`c_wchar_p`" -#: ../../library/ctypes.rst:352 +#: ../../library/ctypes.rst:350 msgid ":c:expr:`wchar_t *` (NUL terminated)" msgstr "" -#: ../../library/ctypes.rst:353 +#: ../../library/ctypes.rst:351 msgid ":py:class:`str` or ``None``" msgstr ":py:class:`str`\\ 或 ``None``" -#: ../../library/ctypes.rst:354 +#: ../../library/ctypes.rst:352 msgid "``'Z'``" msgstr "" -#: ../../library/ctypes.rst:355 +#: ../../library/ctypes.rst:353 msgid ":class:`c_void_p`" msgstr ":class:`c_void_p`" -#: ../../library/ctypes.rst:356 +#: ../../library/ctypes.rst:354 msgid ":c:expr:`void *`" msgstr ":c:expr:`void *`" -#: ../../library/ctypes.rst:357 +#: ../../library/ctypes.rst:355 msgid ":py:class:`int` or ``None``" msgstr ":py:class:`int`\\ 或 ``None``" -#: ../../library/ctypes.rst:358 +#: ../../library/ctypes.rst:356 msgid "``'P'``" msgstr "" -#: ../../library/ctypes.rst:359 +#: ../../library/ctypes.rst:357 msgid ":class:`py_object`" msgstr ":class:`py_object`" -#: ../../library/ctypes.rst:360 +#: ../../library/ctypes.rst:358 msgid ":c:expr:`PyObject *`" msgstr ":c:expr:`PyObject *`" -#: ../../library/ctypes.rst:361 +#: ../../library/ctypes.rst:359 msgid ":py:class:`object`" msgstr ":py:class:`object`" -#: ../../library/ctypes.rst:362 +#: ../../library/ctypes.rst:360 msgid "``'O'``" msgstr "" -#: ../../library/ctypes.rst:363 +#: ../../library/ctypes.rst:361 msgid ":ref:`VARIANT_BOOL `" msgstr "" -#: ../../library/ctypes.rst:364 +#: ../../library/ctypes.rst:362 msgid ":c:expr:`short int`" msgstr ":c:expr:`short int`" -#: ../../library/ctypes.rst:366 +#: ../../library/ctypes.rst:364 msgid "``'v'``" msgstr "" -#: ../../library/ctypes.rst:368 +#: ../../library/ctypes.rst:366 msgid "" "Additionally, if IEC 60559 compatible complex arithmetic (Annex G) is " "supported in both C and ``libffi``, the following complex types are " "available:" msgstr "" -#: ../../library/ctypes.rst:378 +#: ../../library/ctypes.rst:376 msgid ":class:`c_float_complex`" msgstr ":class:`c_float_complex`" -#: ../../library/ctypes.rst:379 +#: ../../library/ctypes.rst:377 msgid ":c:expr:`float complex`" msgstr ":c:expr:`float complex`" -#: ../../library/ctypes.rst:380 ../../library/ctypes.rst:384 -#: ../../library/ctypes.rst:388 +#: ../../library/ctypes.rst:378 ../../library/ctypes.rst:382 +#: ../../library/ctypes.rst:386 msgid ":py:class:`complex`" msgstr ":py:class:`complex`" -#: ../../library/ctypes.rst:381 -msgid "``'F'``" -msgstr "" +#: ../../library/ctypes.rst:379 +msgid "``'Zf'``" +msgstr "``'Zf'``" -#: ../../library/ctypes.rst:382 +#: ../../library/ctypes.rst:380 msgid ":class:`c_double_complex`" msgstr ":class:`c_double_complex`" -#: ../../library/ctypes.rst:383 +#: ../../library/ctypes.rst:381 msgid ":c:expr:`double complex`" msgstr ":c:expr:`double complex`" -#: ../../library/ctypes.rst:385 -msgid "``'D'``" -msgstr "" +#: ../../library/ctypes.rst:383 +msgid "``'Zd'``" +msgstr "``'Zd'``" -#: ../../library/ctypes.rst:386 +#: ../../library/ctypes.rst:384 msgid ":class:`c_longdouble_complex`" msgstr ":class:`c_longdouble_complex`" -#: ../../library/ctypes.rst:387 +#: ../../library/ctypes.rst:385 msgid ":c:expr:`long double complex`" msgstr ":c:expr:`long double complex`" +#: ../../library/ctypes.rst:387 +msgid "``'Zg'``" +msgstr "``'Zg'``" + #: ../../library/ctypes.rst:389 -msgid "``'G'``" +msgid "" +"The :py:attr:`~_SimpleCData._type_` types ``F``, ``D`` and ``G`` have been " +"replaced with ``Zf``, ``Zd`` and ``Zg``." msgstr "" -#: ../../library/ctypes.rst:392 +#: ../../library/ctypes.rst:394 msgid "" "All these types can be created by calling them with an optional initializer " "of the correct type and value::" msgstr "" -#: ../../library/ctypes.rst:395 +#: ../../library/ctypes.rst:397 msgid "" ">>> c_int()\n" "c_long(0)\n" @@ -895,7 +901,7 @@ msgstr "" "c_ushort(65533)\n" ">>>" -#: ../../library/ctypes.rst:403 +#: ../../library/ctypes.rst:405 msgid "" "The constructors for numeric types will convert input using :py:meth:" "`~object.__bool__`, :py:meth:`~object.__index__` (for ``int``), :py:meth:" @@ -903,19 +909,19 @@ msgid "" "`~ctypes.c_bool` accepts any object with a truth value::" msgstr "" -#: ../../library/ctypes.rst:409 +#: ../../library/ctypes.rst:411 msgid "" ">>> empty_list = []\n" ">>> c_bool(empty_list)\n" "c_bool(False)" msgstr "" -#: ../../library/ctypes.rst:413 +#: ../../library/ctypes.rst:415 msgid "" "Since these types are mutable, their value can also be changed afterwards::" msgstr "" -#: ../../library/ctypes.rst:415 +#: ../../library/ctypes.rst:417 msgid "" ">>> i = c_int(42)\n" ">>> print(i)\n" @@ -937,7 +943,7 @@ msgstr "" "-99\n" ">>>" -#: ../../library/ctypes.rst:425 +#: ../../library/ctypes.rst:427 msgid "" "Assigning a new value to instances of the pointer types :class:`c_char_p`, :" "class:`c_wchar_p`, and :class:`c_void_p` changes the *memory location* they " @@ -945,7 +951,7 @@ msgid "" "Python string objects are immutable)::" msgstr "" -#: ../../library/ctypes.rst:430 +#: ../../library/ctypes.rst:432 msgid "" ">>> s = \"Hello, World\"\n" ">>> c_s = c_wchar_p(s)\n" @@ -977,7 +983,7 @@ msgstr "" "Hello, World\n" ">>>" -#: ../../library/ctypes.rst:445 +#: ../../library/ctypes.rst:447 msgid "" "You should be careful, however, not to pass them to functions expecting " "pointers to mutable memory. If you need mutable memory blocks, ctypes has a :" @@ -987,7 +993,7 @@ msgid "" "``value`` property::" msgstr "" -#: ../../library/ctypes.rst:452 +#: ../../library/ctypes.rst:454 msgid "" ">>> from ctypes import *\n" ">>> p = create_string_buffer(3) # create a 3 byte buffer, " @@ -1009,7 +1015,7 @@ msgid "" ">>>" msgstr "" -#: ../../library/ctypes.rst:469 +#: ../../library/ctypes.rst:471 msgid "" "The :func:`create_string_buffer` function replaces the old :func:`!c_buffer` " "function (which is still available as an alias). To create a mutable memory " @@ -1017,18 +1023,18 @@ msgid "" "the :func:`create_unicode_buffer` function." msgstr "" -#: ../../library/ctypes.rst:478 +#: ../../library/ctypes.rst:480 msgid "Calling functions, continued" msgstr "" -#: ../../library/ctypes.rst:480 +#: ../../library/ctypes.rst:482 msgid "" "Note that printf prints to the real standard output channel, *not* to :data:" "`sys.stdout`, so these examples will only work at the console prompt, not " "from within *IDLE* or *PythonWin*::" msgstr "" -#: ../../library/ctypes.rst:484 +#: ../../library/ctypes.rst:486 msgid "" ">>> printf = libc.printf\n" ">>> printf(b\"Hello, %s\\n\", b\"World!\")\n" @@ -1064,14 +1070,14 @@ msgstr "" "parameter 2\n" ">>>" -#: ../../library/ctypes.rst:500 +#: ../../library/ctypes.rst:502 msgid "" "As has been mentioned before, all Python types except integers, strings, and " "bytes objects have to be wrapped in their corresponding :mod:`!ctypes` type, " "so that they can be converted to the required C data type::" msgstr "" -#: ../../library/ctypes.rst:504 +#: ../../library/ctypes.rst:506 msgid "" ">>> printf(b\"An int %d, a double %f\\n\", 1234, c_double(3.14))\n" "An int 1234, a double 3.140000\n" @@ -1083,11 +1089,11 @@ msgstr "" "31\n" ">>>" -#: ../../library/ctypes.rst:512 +#: ../../library/ctypes.rst:514 msgid "Calling variadic functions" msgstr "" -#: ../../library/ctypes.rst:514 +#: ../../library/ctypes.rst:516 msgid "" "On a lot of platforms calling variadic functions through ctypes is exactly " "the same as calling functions with a fixed number of parameters. On some " @@ -1096,27 +1102,27 @@ msgid "" "functions." msgstr "" -#: ../../library/ctypes.rst:519 +#: ../../library/ctypes.rst:521 msgid "" "On those platforms it is required to specify the :attr:`~_CFuncPtr.argtypes` " "attribute for the regular, non-variadic, function arguments:" msgstr "" -#: ../../library/ctypes.rst:522 +#: ../../library/ctypes.rst:524 msgid "libc.printf.argtypes = [ctypes.c_char_p]" msgstr "libc.printf.argtypes = [ctypes.c_char_p]" -#: ../../library/ctypes.rst:526 +#: ../../library/ctypes.rst:528 msgid "" "Because specifying the attribute does not inhibit portability it is advised " "to always specify :attr:`~_CFuncPtr.argtypes` for all variadic functions." msgstr "" -#: ../../library/ctypes.rst:533 +#: ../../library/ctypes.rst:535 msgid "Calling functions with your own custom data types" msgstr "" -#: ../../library/ctypes.rst:535 +#: ../../library/ctypes.rst:537 msgid "" "You can also customize :mod:`!ctypes` argument conversion to allow instances " "of your own classes be used as function arguments. :mod:`!ctypes` looks for " @@ -1125,7 +1131,7 @@ msgid "" "or an object with an :attr:`!_as_parameter_` attribute::" msgstr "" -#: ../../library/ctypes.rst:541 +#: ../../library/ctypes.rst:543 msgid "" ">>> class Bottles:\n" "... def __init__(self, number):\n" @@ -1147,24 +1153,24 @@ msgstr "" "19\n" ">>>" -#: ../../library/ctypes.rst:551 +#: ../../library/ctypes.rst:553 msgid "" "If you don't want to store the instance's data in the :attr:`!" "_as_parameter_` instance variable, you could define a :deco:`property` which " "makes the attribute available on request." msgstr "" -#: ../../library/ctypes.rst:559 +#: ../../library/ctypes.rst:561 msgid "Specifying the required argument types (function prototypes)" msgstr "" -#: ../../library/ctypes.rst:561 +#: ../../library/ctypes.rst:563 msgid "" "It is possible to specify the required argument types of functions exported " "from DLLs by setting the :attr:`~_CFuncPtr.argtypes` attribute." msgstr "" -#: ../../library/ctypes.rst:564 +#: ../../library/ctypes.rst:566 msgid "" ":attr:`~_CFuncPtr.argtypes` must be a sequence of C data types (the :func:`!" "printf` function is probably not a good example here, because it takes a " @@ -1173,7 +1179,7 @@ msgid "" "feature)::" msgstr "" -#: ../../library/ctypes.rst:569 +#: ../../library/ctypes.rst:571 msgid "" ">>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]\n" ">>> printf(b\"String '%s', Int %d, Double %f\\n\", b\"Hi\", 10, 2.2)\n" @@ -1187,14 +1193,14 @@ msgstr "" "37\n" ">>>" -#: ../../library/ctypes.rst:575 +#: ../../library/ctypes.rst:577 msgid "" "Specifying a format protects against incompatible argument types (just as a " "prototype for a C function), and tries to convert the arguments to valid " "types::" msgstr "" -#: ../../library/ctypes.rst:578 +#: ../../library/ctypes.rst:580 msgid "" ">>> printf(b\"%d %d %d\", 1, 2, 3)\n" "Traceback (most recent call last):\n" @@ -1216,7 +1222,7 @@ msgstr "" "13\n" ">>>" -#: ../../library/ctypes.rst:587 +#: ../../library/ctypes.rst:589 msgid "" "If you have defined your own classes which you pass to function calls, you " "have to implement a :meth:`~_CData.from_param` class method for them to be " @@ -1230,43 +1236,43 @@ msgid "" "_as_parameter_` attribute." msgstr "" -#: ../../library/ctypes.rst:601 +#: ../../library/ctypes.rst:603 msgid "Return types" msgstr "" -#: ../../library/ctypes.rst:611 +#: ../../library/ctypes.rst:613 msgid "" "By default functions are assumed to return the C :c:expr:`int` type. Other " "return types can be specified by setting the :attr:`~_CFuncPtr.restype` " "attribute of the function object." msgstr "" -#: ../../library/ctypes.rst:615 +#: ../../library/ctypes.rst:617 msgid "" "The C prototype of :c:func:`time` is ``time_t time(time_t *)``. Because :c:" "type:`time_t` might be of a different type than the default return type :c:" "expr:`int`, you should specify the :attr:`!restype` attribute::" msgstr "" -#: ../../library/ctypes.rst:619 +#: ../../library/ctypes.rst:621 msgid ">>> libc.time.restype = c_time_t" msgstr ">>> libc.time.restype = c_time_t" -#: ../../library/ctypes.rst:621 +#: ../../library/ctypes.rst:623 msgid "The argument types can be specified using :attr:`~_CFuncPtr.argtypes`::" msgstr "" -#: ../../library/ctypes.rst:623 +#: ../../library/ctypes.rst:625 msgid ">>> libc.time.argtypes = (POINTER(c_time_t),)" msgstr ">>> libc.time.argtypes = (POINTER(c_time_t),)" -#: ../../library/ctypes.rst:625 +#: ../../library/ctypes.rst:627 msgid "" "To call the function with a ``NULL`` pointer as first argument, use " "``None``::" msgstr "" -#: ../../library/ctypes.rst:627 +#: ../../library/ctypes.rst:629 msgid "" ">>> print(libc.time(None))\n" "1150640792" @@ -1274,13 +1280,13 @@ msgstr "" ">>> print(libc.time(None))\n" "1150640792" -#: ../../library/ctypes.rst:630 +#: ../../library/ctypes.rst:632 msgid "" "Here is a more advanced example, it uses the :func:`!strchr` function, which " "expects a string pointer and a char, and returns a pointer to a string::" msgstr "" -#: ../../library/ctypes.rst:633 +#: ../../library/ctypes.rst:635 msgid "" ">>> strchr = libc.strchr\n" ">>> strchr(b\"abcdef\", ord(\"d\"))\n" @@ -1302,14 +1308,14 @@ msgstr "" "None\n" ">>>" -#: ../../library/ctypes.rst:643 +#: ../../library/ctypes.rst:645 msgid "" "If you want to avoid the :func:`ord(\"x\") ` calls above, you can set " "the :attr:`~_CFuncPtr.argtypes` attribute, and the second argument will be " "converted from a single character Python bytes object into a C char:" msgstr "" -#: ../../library/ctypes.rst:647 +#: ../../library/ctypes.rst:649 msgid "" ">>> strchr.restype = c_char_p\n" ">>> strchr.argtypes = [c_char_p, c_char]\n" @@ -1339,7 +1345,7 @@ msgstr "" "b'def'\n" ">>>" -#: ../../library/ctypes.rst:662 +#: ../../library/ctypes.rst:664 msgid "" "You can also use a callable Python object (a function or a class for " "example) as the :attr:`~_CFuncPtr.restype` attribute, if the foreign " @@ -1349,7 +1355,7 @@ msgid "" "values and automatically raise an exception::" msgstr "" -#: ../../library/ctypes.rst:668 +#: ../../library/ctypes.rst:670 msgid "" ">>> GetModuleHandle = windll.kernel32.GetModuleHandleA\n" ">>> def ValidHandle(value):\n" @@ -1385,7 +1391,7 @@ msgstr "" "OSError: [Errno 126] The specified module could not be found.\n" ">>>" -#: ../../library/ctypes.rst:685 +#: ../../library/ctypes.rst:687 msgid "" "``WinError`` is a function which will call Windows ``FormatMessage()`` api " "to get the string representation of an error code, and *returns* an " @@ -1393,18 +1399,18 @@ msgid "" "used, it calls :func:`GetLastError` to retrieve it." msgstr "" -#: ../../library/ctypes.rst:690 +#: ../../library/ctypes.rst:692 msgid "" "Please note that a much more powerful error checking mechanism is available " "through the :attr:`~_CFuncPtr.errcheck` attribute; see the reference manual " "for details." msgstr "" -#: ../../library/ctypes.rst:698 +#: ../../library/ctypes.rst:700 msgid "Passing pointers (or: passing parameters by reference)" msgstr "" -#: ../../library/ctypes.rst:700 +#: ../../library/ctypes.rst:702 msgid "" "Sometimes a C api function expects a *pointer* to a data type as parameter, " "probably to write into the corresponding location, or if the data is too " @@ -1412,7 +1418,7 @@ msgid "" "reference*." msgstr "" -#: ../../library/ctypes.rst:704 +#: ../../library/ctypes.rst:706 msgid "" ":mod:`!ctypes` exports the :func:`byref` function which is used to pass " "parameters by reference. The same effect can be achieved with the :func:" @@ -1421,7 +1427,7 @@ msgid "" "you don't need the pointer object in Python itself::" msgstr "" -#: ../../library/ctypes.rst:710 +#: ../../library/ctypes.rst:712 msgid "" ">>> i = c_int()\n" ">>> f = c_float()\n" @@ -1447,11 +1453,11 @@ msgstr "" "1 3.1400001049 b'Hello'\n" ">>>" -#: ../../library/ctypes.rst:726 +#: ../../library/ctypes.rst:728 msgid "Structures and unions" msgstr "" -#: ../../library/ctypes.rst:728 +#: ../../library/ctypes.rst:730 msgid "" "Structures and unions must derive from the :class:`Structure` and :class:" "`Union` base classes which are defined in the :mod:`!ctypes` module. Each " @@ -1460,20 +1466,20 @@ msgid "" "*field type*." msgstr "" -#: ../../library/ctypes.rst:733 +#: ../../library/ctypes.rst:735 msgid "" "The field type must be a :mod:`!ctypes` type like :class:`c_int`, or any " "other derived :mod:`!ctypes` type: structure, union, array, pointer." msgstr "" -#: ../../library/ctypes.rst:736 +#: ../../library/ctypes.rst:738 msgid "" "Here is a simple example of a POINT structure, which contains two integers " "named *x* and *y*, and also shows how to initialize a structure in the " "constructor::" msgstr "" -#: ../../library/ctypes.rst:739 +#: ../../library/ctypes.rst:741 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1509,19 +1515,19 @@ msgstr "" "TypeError: too many initializers\n" ">>>" -#: ../../library/ctypes.rst:756 +#: ../../library/ctypes.rst:758 msgid "" "You can, however, build much more complicated structures. A structure can " "itself contain other structures by using a structure as a field type." msgstr "" -#: ../../library/ctypes.rst:759 +#: ../../library/ctypes.rst:761 msgid "" "Here is a RECT structure which contains two POINTs named *upperleft* and " "*lowerright*::" msgstr "" -#: ../../library/ctypes.rst:762 +#: ../../library/ctypes.rst:764 msgid "" ">>> class RECT(Structure):\n" "... _fields_ = [(\"upperleft\", POINT),\n" @@ -1545,13 +1551,13 @@ msgstr "" "0 0\n" ">>>" -#: ../../library/ctypes.rst:773 +#: ../../library/ctypes.rst:775 msgid "" "Nested structures can also be initialized in the constructor in several " "ways::" msgstr "" -#: ../../library/ctypes.rst:775 +#: ../../library/ctypes.rst:777 msgid "" ">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" ">>> r = RECT((1, 2), (3, 4))" @@ -1559,14 +1565,14 @@ msgstr "" ">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" ">>> r = RECT((1, 2), (3, 4))" -#: ../../library/ctypes.rst:778 +#: ../../library/ctypes.rst:780 msgid "" "Field :term:`descriptor`\\s can be retrieved from the *class*, they are " "useful for debugging because they can provide useful information. See :class:" "`CField`::" msgstr "" -#: ../../library/ctypes.rst:782 +#: ../../library/ctypes.rst:784 msgid "" ">>> POINT.x\n" "\n" @@ -1580,7 +1586,7 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:793 +#: ../../library/ctypes.rst:795 msgid "" ":mod:`!ctypes` does not support passing unions or structures with bit-fields " "to functions by value. While this may work on 32-bit x86, it's not " @@ -1588,11 +1594,11 @@ msgid "" "structures with bit-fields should always be passed to functions by pointer." msgstr "" -#: ../../library/ctypes.rst:799 +#: ../../library/ctypes.rst:801 msgid "Structure/union layout, alignment and byte order" msgstr "" -#: ../../library/ctypes.rst:801 +#: ../../library/ctypes.rst:803 msgid "" "By default, Structure and Union fields are laid out in the same way the C " "compiler does it. It is possible to override this behavior entirely by " @@ -1600,7 +1606,7 @@ msgid "" "definition; see the attribute documentation for details." msgstr "" -#: ../../library/ctypes.rst:806 +#: ../../library/ctypes.rst:808 msgid "" "It is possible to specify the maximum alignment for the fields and/or for " "the structure itself by setting the class attributes :attr:`~Structure." @@ -1608,7 +1614,7 @@ msgid "" "documentation for details." msgstr "" -#: ../../library/ctypes.rst:811 +#: ../../library/ctypes.rst:813 msgid "" ":mod:`!ctypes` uses the native byte order for Structures and Unions. To " "build structures with non-native byte order, you can use one of the :class:" @@ -1617,18 +1623,18 @@ msgid "" "classes cannot contain pointer fields." msgstr "" -#: ../../library/ctypes.rst:821 +#: ../../library/ctypes.rst:823 msgid "Bit fields in structures and unions" msgstr "" -#: ../../library/ctypes.rst:823 +#: ../../library/ctypes.rst:825 msgid "" "It is possible to create structures and unions containing bit fields. Bit " "fields are only possible for integer fields, the bit width is specified as " "the third item in the :attr:`~Structure._fields_` tuples::" msgstr "" -#: ../../library/ctypes.rst:827 +#: ../../library/ctypes.rst:829 msgid "" ">>> class Int(Structure):\n" "... _fields_ = [(\"first_16\", c_int, 16),\n" @@ -1648,7 +1654,7 @@ msgstr "" ">>> print(Int.second_16)\n" "" -#: ../../library/ctypes.rst:836 +#: ../../library/ctypes.rst:838 msgid "" "It is important to note that bit field allocation and layout in memory are " "not defined as a C standard; their implementation is compiler-specific. By " @@ -1657,33 +1663,33 @@ msgid "" "details on the default behavior and how to change it." msgstr "" -#: ../../library/ctypes.rst:847 +#: ../../library/ctypes.rst:849 msgid "Arrays" msgstr "" -#: ../../library/ctypes.rst:849 +#: ../../library/ctypes.rst:851 msgid "" "Arrays are sequences, containing a fixed number of instances of the same " "type." msgstr "" -#: ../../library/ctypes.rst:851 +#: ../../library/ctypes.rst:853 msgid "" "The recommended way to create array types is by multiplying a data type with " "a positive integer::" msgstr "" -#: ../../library/ctypes.rst:854 +#: ../../library/ctypes.rst:856 msgid "TenPointsArrayType = POINT * 10" msgstr "" -#: ../../library/ctypes.rst:856 +#: ../../library/ctypes.rst:858 msgid "" "Here is an example of a somewhat artificial data type, a structure " "containing 4 POINTs among other stuff::" msgstr "" -#: ../../library/ctypes.rst:859 +#: ../../library/ctypes.rst:861 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1711,11 +1717,11 @@ msgstr "" "4\n" ">>>" -#: ../../library/ctypes.rst:872 +#: ../../library/ctypes.rst:874 msgid "Instances are created in the usual way, by calling the class::" msgstr "" -#: ../../library/ctypes.rst:874 +#: ../../library/ctypes.rst:876 msgid "" "arr = TenPointsArrayType()\n" "for pt in arr:\n" @@ -1725,17 +1731,17 @@ msgstr "" "for pt in arr:\n" " print(pt.x, pt.y)" -#: ../../library/ctypes.rst:878 +#: ../../library/ctypes.rst:880 msgid "" "The above code print a series of ``0 0`` lines, because the array contents " "is initialized to zeros." msgstr "" -#: ../../library/ctypes.rst:881 +#: ../../library/ctypes.rst:883 msgid "Initializers of the correct type can also be specified::" msgstr "" -#: ../../library/ctypes.rst:883 +#: ../../library/ctypes.rst:885 msgid "" ">>> from ctypes import *\n" ">>> TenIntegers = c_int * 10\n" @@ -1757,17 +1763,17 @@ msgstr "" "1 2 3 4 5 6 7 8 9 10\n" ">>>" -#: ../../library/ctypes.rst:897 +#: ../../library/ctypes.rst:899 msgid "Pointers" msgstr "指標" -#: ../../library/ctypes.rst:899 +#: ../../library/ctypes.rst:901 msgid "" "Pointer instances are created by calling the :func:`pointer` function on a :" "mod:`!ctypes` type::" msgstr "" -#: ../../library/ctypes.rst:902 +#: ../../library/ctypes.rst:904 msgid "" ">>> from ctypes import *\n" ">>> i = c_int(42)\n" @@ -1779,13 +1785,13 @@ msgstr "" ">>> pi = pointer(i)\n" ">>>" -#: ../../library/ctypes.rst:907 +#: ../../library/ctypes.rst:909 msgid "" "Pointer instances have a :attr:`~_Pointer.contents` attribute which returns " "the object to which the pointer points, the ``i`` object above::" msgstr "" -#: ../../library/ctypes.rst:910 +#: ../../library/ctypes.rst:912 msgid "" ">>> pi.contents\n" "c_long(42)\n" @@ -1795,13 +1801,13 @@ msgstr "" "c_long(42)\n" ">>>" -#: ../../library/ctypes.rst:914 +#: ../../library/ctypes.rst:916 msgid "" "Note that :mod:`!ctypes` does not have OOR (original object return), it " "constructs a new, equivalent object each time you retrieve an attribute::" msgstr "" -#: ../../library/ctypes.rst:917 +#: ../../library/ctypes.rst:919 msgid "" ">>> pi.contents is i\n" "False\n" @@ -1815,14 +1821,14 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:923 +#: ../../library/ctypes.rst:925 msgid "" "Assigning another :class:`c_int` instance to the pointer's contents " "attribute would cause the pointer to point to the memory location where this " "is stored::" msgstr "" -#: ../../library/ctypes.rst:926 +#: ../../library/ctypes.rst:928 msgid "" ">>> i = c_int(99)\n" ">>> pi.contents = i\n" @@ -1836,11 +1842,11 @@ msgstr "" "c_long(99)\n" ">>>" -#: ../../library/ctypes.rst:935 +#: ../../library/ctypes.rst:937 msgid "Pointer instances can also be indexed with integers::" msgstr "" -#: ../../library/ctypes.rst:937 +#: ../../library/ctypes.rst:939 msgid "" ">>> pi[0]\n" "99\n" @@ -1850,11 +1856,11 @@ msgstr "" "99\n" ">>>" -#: ../../library/ctypes.rst:941 +#: ../../library/ctypes.rst:943 msgid "Assigning to an integer index changes the pointed to value::" msgstr "" -#: ../../library/ctypes.rst:943 +#: ../../library/ctypes.rst:945 msgid "" ">>> print(i)\n" "c_long(99)\n" @@ -1870,7 +1876,7 @@ msgstr "" "c_long(22)\n" ">>>" -#: ../../library/ctypes.rst:950 +#: ../../library/ctypes.rst:952 msgid "" "It is also possible to use indexes different from 0, but you must know what " "you're doing, just as in C: You can access or change arbitrary memory " @@ -1879,7 +1885,7 @@ msgid "" "instead of a single item." msgstr "" -#: ../../library/ctypes.rst:958 +#: ../../library/ctypes.rst:960 msgid "" "Because pointer objects support subscription, they implicitly support :term:" "`iteration `. Unless doing this in a controlled manner, such as by " @@ -1889,7 +1895,7 @@ msgid "" "infinitely yield arbitrary memory." msgstr "" -#: ../../library/ctypes.rst:965 +#: ../../library/ctypes.rst:967 msgid "" "Behind the scenes, the :func:`pointer` function does more than simply create " "pointer instances, it has to create pointer *types* first. This is done with " @@ -1897,7 +1903,7 @@ msgid "" "returns a new type::" msgstr "" -#: ../../library/ctypes.rst:970 +#: ../../library/ctypes.rst:972 msgid "" ">>> PI = POINTER(c_int)\n" ">>> PI\n" @@ -1921,13 +1927,13 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:981 +#: ../../library/ctypes.rst:983 msgid "" "Calling the pointer type without an argument creates a ``NULL`` pointer. " "``NULL`` pointers have a ``False`` boolean value::" msgstr "" -#: ../../library/ctypes.rst:984 +#: ../../library/ctypes.rst:986 msgid "" ">>> null_ptr = POINTER(c_int)()\n" ">>> print(bool(null_ptr))\n" @@ -1939,13 +1945,13 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:989 +#: ../../library/ctypes.rst:991 msgid "" ":mod:`!ctypes` checks for ``NULL`` when dereferencing pointers (but " "dereferencing invalid non-\\ ``NULL`` pointers would crash Python)::" msgstr "" -#: ../../library/ctypes.rst:992 +#: ../../library/ctypes.rst:994 msgid "" ">>> null_ptr[0]\n" "Traceback (most recent call last):\n" @@ -1971,18 +1977,18 @@ msgstr "" "ValueError: NULL pointer access\n" ">>>" -#: ../../library/ctypes.rst:1007 +#: ../../library/ctypes.rst:1009 msgid "Thread safety without the GIL" msgstr "" -#: ../../library/ctypes.rst:1009 +#: ../../library/ctypes.rst:1011 msgid "" "From Python 3.13 onward, the :term:`GIL` can be disabled on the :term:`free-" "threaded build`. In ctypes, reads and writes to a single object concurrently " "is safe, but not across multiple objects:" msgstr "" -#: ../../library/ctypes.rst:1012 +#: ../../library/ctypes.rst:1014 msgid "" ">>> number = c_int(42)\n" ">>> pointer_a = pointer(number)\n" @@ -1992,7 +1998,7 @@ msgstr "" ">>> pointer_a = pointer(number)\n" ">>> pointer_b = pointer(number)" -#: ../../library/ctypes.rst:1018 +#: ../../library/ctypes.rst:1020 msgid "" "In the above, it's only safe for one object to read and write to the address " "at once if the GIL is disabled. So, ``pointer_a`` can be shared and written " @@ -2001,7 +2007,7 @@ msgid "" "Lock` to synchronize access to memory:" msgstr "" -#: ../../library/ctypes.rst:1023 +#: ../../library/ctypes.rst:1025 msgid "" ">>> import threading\n" ">>> lock = threading.Lock()\n" @@ -2021,11 +2027,11 @@ msgstr "" ">>> with lock:\n" "... pointer_b.contents = 42" -#: ../../library/ctypes.rst:1038 +#: ../../library/ctypes.rst:1040 msgid "Type conversions" msgstr "" -#: ../../library/ctypes.rst:1040 +#: ../../library/ctypes.rst:1042 msgid "" "Usually, ctypes does strict type checking. This means, if you have " "``POINTER(c_int)`` in the :attr:`~_CFuncPtr.argtypes` list of a function or " @@ -2036,7 +2042,7 @@ msgid "" "ctypes accepts an array of c_int::" msgstr "" -#: ../../library/ctypes.rst:1047 +#: ../../library/ctypes.rst:1049 msgid "" ">>> class Bar(Structure):\n" "... _fields_ = [(\"count\", c_int), (\"values\", POINTER(c_int))]\n" @@ -2066,7 +2072,7 @@ msgstr "" "3\n" ">>>" -#: ../../library/ctypes.rst:1061 +#: ../../library/ctypes.rst:1063 msgid "" "In addition, if a function argument is explicitly declared to be a pointer " "type (such as ``POINTER(c_int)``) in :attr:`~_CFuncPtr.argtypes`, an object " @@ -2075,11 +2081,11 @@ msgid "" "automatically." msgstr "" -#: ../../library/ctypes.rst:1066 +#: ../../library/ctypes.rst:1068 msgid "To set a POINTER type field to ``NULL``, you can assign ``None``::" msgstr "" -#: ../../library/ctypes.rst:1068 +#: ../../library/ctypes.rst:1070 msgid "" ">>> bar.values = None\n" ">>>" @@ -2087,7 +2093,7 @@ msgstr "" ">>> bar.values = None\n" ">>>" -#: ../../library/ctypes.rst:1073 +#: ../../library/ctypes.rst:1075 msgid "" "Sometimes you have instances of incompatible types. In C, you can cast one " "type into another type. :mod:`!ctypes` provides a :func:`cast` function " @@ -2096,7 +2102,7 @@ msgid "" "``values`` field, but not instances of other types::" msgstr "" -#: ../../library/ctypes.rst:1079 +#: ../../library/ctypes.rst:1081 msgid "" ">>> bar.values = (c_byte * 4)()\n" "Traceback (most recent call last):\n" @@ -2112,11 +2118,11 @@ msgstr "" "instance\n" ">>>" -#: ../../library/ctypes.rst:1085 +#: ../../library/ctypes.rst:1087 msgid "For these cases, the :func:`cast` function is handy." msgstr "" -#: ../../library/ctypes.rst:1087 +#: ../../library/ctypes.rst:1089 msgid "" "The :func:`cast` function can be used to cast a ctypes instance into a " "pointer to a different ctypes data type. :func:`cast` takes two parameters, " @@ -2125,7 +2131,7 @@ msgid "" "references the same memory block as the first argument::" msgstr "" -#: ../../library/ctypes.rst:1093 +#: ../../library/ctypes.rst:1095 msgid "" ">>> a = (c_byte * 4)()\n" ">>> cast(a, POINTER(c_int))\n" @@ -2137,13 +2143,13 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:1098 +#: ../../library/ctypes.rst:1100 msgid "" "So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` " "the structure::" msgstr "" -#: ../../library/ctypes.rst:1101 +#: ../../library/ctypes.rst:1103 msgid "" ">>> bar = Bar()\n" ">>> bar.values = cast((c_byte * 4)(), POINTER(c_int))\n" @@ -2157,18 +2163,18 @@ msgstr "" "0\n" ">>>" -#: ../../library/ctypes.rst:1111 +#: ../../library/ctypes.rst:1113 msgid "Incomplete Types" msgstr "" -#: ../../library/ctypes.rst:1113 +#: ../../library/ctypes.rst:1115 msgid "" "*Incomplete Types* are structures, unions or arrays whose members are not " "yet specified. In C, they are specified by forward declarations, which are " "defined later::" msgstr "" -#: ../../library/ctypes.rst:1117 +#: ../../library/ctypes.rst:1119 msgid "" "struct cell; /* forward declaration */\n" "\n" @@ -2178,13 +2184,13 @@ msgid "" "};" msgstr "" -#: ../../library/ctypes.rst:1124 +#: ../../library/ctypes.rst:1126 msgid "" "The straightforward translation into ctypes code would be this, but it does " "not work::" msgstr "" -#: ../../library/ctypes.rst:1127 +#: ../../library/ctypes.rst:1129 msgid "" ">>> class cell(Structure):\n" "... _fields_ = [(\"name\", c_char_p),\n" @@ -2206,14 +2212,14 @@ msgstr "" "NameError: name 'cell' is not defined\n" ">>>" -#: ../../library/ctypes.rst:1137 +#: ../../library/ctypes.rst:1139 msgid "" "because the new ``class cell`` is not available in the class statement " "itself. In :mod:`!ctypes`, we can define the ``cell`` class and set the :" "attr:`~Structure._fields_` attribute later, after the class statement::" msgstr "" -#: ../../library/ctypes.rst:1141 +#: ../../library/ctypes.rst:1143 msgid "" ">>> from ctypes import *\n" ">>> class cell(Structure):\n" @@ -2231,13 +2237,13 @@ msgstr "" "... (\"next\", POINTER(cell))]\n" ">>>" -#: ../../library/ctypes.rst:1149 +#: ../../library/ctypes.rst:1151 msgid "" "Let's try it. We create two instances of ``cell``, and let them point to " "each other, and finally follow the pointer chain a few times::" msgstr "" -#: ../../library/ctypes.rst:1152 +#: ../../library/ctypes.rst:1154 msgid "" ">>> c1 = cell()\n" ">>> c1.name = b\"foo\"\n" @@ -2267,24 +2273,24 @@ msgstr "" "foo bar foo bar foo bar foo bar\n" ">>>" -#: ../../library/ctypes.rst:1170 +#: ../../library/ctypes.rst:1172 msgid "Callback functions" msgstr "回呼函式" -#: ../../library/ctypes.rst:1172 +#: ../../library/ctypes.rst:1174 msgid "" ":mod:`!ctypes` allows creating C callable function pointers from Python " "callables. These are sometimes called *callback functions*." msgstr "" -#: ../../library/ctypes.rst:1175 +#: ../../library/ctypes.rst:1177 msgid "" "First, you must create a class for the callback function. The class knows " "the calling convention, the return type, and the number and types of " "arguments this function will receive." msgstr "" -#: ../../library/ctypes.rst:1179 +#: ../../library/ctypes.rst:1181 msgid "" "The :func:`CFUNCTYPE` factory function creates types for callback functions " "using the ``cdecl`` calling convention. On Windows, the :func:`WINFUNCTYPE` " @@ -2292,21 +2298,21 @@ msgid "" "calling convention." msgstr "" -#: ../../library/ctypes.rst:1184 +#: ../../library/ctypes.rst:1186 msgid "" "Both of these factory functions are called with the result type as first " "argument, and the callback functions expected argument types as the " "remaining arguments." msgstr "" -#: ../../library/ctypes.rst:1188 +#: ../../library/ctypes.rst:1190 msgid "" "I will present an example here which uses the standard C library's :c:func:`!" "qsort` function, that is used to sort items with the help of a callback " "function. :c:func:`!qsort` will be used to sort an array of integers::" msgstr "" -#: ../../library/ctypes.rst:1192 +#: ../../library/ctypes.rst:1194 msgid "" ">>> IntArray5 = c_int * 5\n" ">>> ia = IntArray5(5, 1, 7, 33, 99)\n" @@ -2320,7 +2326,7 @@ msgstr "" ">>> qsort.restype = None\n" ">>>" -#: ../../library/ctypes.rst:1198 +#: ../../library/ctypes.rst:1200 msgid "" ":func:`!qsort` must be called with a pointer to the data to sort, the number " "of items in the data array, the size of one item, and a pointer to the " @@ -2330,13 +2336,13 @@ msgid "" "otherwise." msgstr "" -#: ../../library/ctypes.rst:1204 +#: ../../library/ctypes.rst:1206 msgid "" "So our callback function receives pointers to integers, and must return an " "integer. First we create the ``type`` for the callback function::" msgstr "" -#: ../../library/ctypes.rst:1207 +#: ../../library/ctypes.rst:1209 msgid "" ">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" ">>>" @@ -2344,13 +2350,13 @@ msgstr "" ">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" ">>>" -#: ../../library/ctypes.rst:1210 +#: ../../library/ctypes.rst:1212 msgid "" "To get started, here is a simple callback that shows the values it gets " "passed::" msgstr "" -#: ../../library/ctypes.rst:1213 +#: ../../library/ctypes.rst:1215 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" @@ -2366,11 +2372,11 @@ msgstr "" ">>> cmp_func = CMPFUNC(py_cmp_func)\n" ">>>" -#: ../../library/ctypes.rst:1220 +#: ../../library/ctypes.rst:1222 msgid "The result::" msgstr "結果為: ::" -#: ../../library/ctypes.rst:1222 +#: ../../library/ctypes.rst:1224 msgid "" ">>> qsort(ia, len(ia), sizeof(c_int), cmp_func)\n" "py_cmp_func 5 1\n" @@ -2388,11 +2394,11 @@ msgstr "" "py_cmp_func 1 7\n" ">>>" -#: ../../library/ctypes.rst:1230 +#: ../../library/ctypes.rst:1232 msgid "Now we can actually compare the two items and return a useful result::" msgstr "" -#: ../../library/ctypes.rst:1232 +#: ../../library/ctypes.rst:1234 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" @@ -2420,11 +2426,11 @@ msgstr "" "py_cmp_func 5 7\n" ">>>" -#: ../../library/ctypes.rst:1245 +#: ../../library/ctypes.rst:1247 msgid "As we can easily check, our array is sorted now::" msgstr "" -#: ../../library/ctypes.rst:1247 +#: ../../library/ctypes.rst:1249 msgid "" ">>> for i in ia: print(i, end=\" \")\n" "...\n" @@ -2436,13 +2442,13 @@ msgstr "" "1 5 7 33 99\n" ">>>" -#: ../../library/ctypes.rst:1252 +#: ../../library/ctypes.rst:1254 msgid "" "The function factories can be used as decorator factories, so we may as well " "write::" msgstr "" -#: ../../library/ctypes.rst:1255 +#: ../../library/ctypes.rst:1257 msgid "" ">>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" "... def py_cmp_func(a, b):\n" @@ -2470,14 +2476,14 @@ msgstr "" "py_cmp_func 5 7\n" ">>>" -#: ../../library/ctypes.rst:1270 +#: ../../library/ctypes.rst:1272 msgid "" "Make sure you keep references to :func:`CFUNCTYPE` objects as long as they " "are used from C code. :mod:`!ctypes` doesn't, and if you don't, they may be " "garbage collected, crashing your program when a callback is made." msgstr "" -#: ../../library/ctypes.rst:1274 +#: ../../library/ctypes.rst:1276 msgid "" "Also, note that if the callback function is called in a thread created " "outside of Python's control (e.g. by the foreign code that calls the " @@ -2487,25 +2493,25 @@ msgid "" "even when those calls are made from the same C thread." msgstr "" -#: ../../library/ctypes.rst:1284 +#: ../../library/ctypes.rst:1286 msgid "Accessing values exported from dlls" msgstr "" -#: ../../library/ctypes.rst:1286 +#: ../../library/ctypes.rst:1288 msgid "" "Some shared libraries not only export functions, they also export variables. " "An example in the Python library itself is the :c:data:`Py_Version`, Python " "runtime version number encoded in a single constant integer." msgstr "" -#: ../../library/ctypes.rst:1290 +#: ../../library/ctypes.rst:1292 msgid "" ":mod:`!ctypes` can access values like this with the :meth:`~_CData.in_dll` " "class methods of the type. *pythonapi* is a predefined symbol giving access " "to the Python C api::" msgstr "" -#: ../../library/ctypes.rst:1294 +#: ../../library/ctypes.rst:1296 msgid "" ">>> version = ctypes.c_int.in_dll(ctypes.pythonapi, \"Py_Version\")\n" ">>> print(hex(version.value))\n" @@ -2515,17 +2521,17 @@ msgstr "" ">>> print(hex(version.value))\n" "0x30c00a0" -#: ../../library/ctypes.rst:1298 +#: ../../library/ctypes.rst:1300 msgid "" "An extended example which also demonstrates the use of pointers accesses " "the :c:data:`PyImport_FrozenModules` pointer exported by Python." msgstr "" -#: ../../library/ctypes.rst:1301 +#: ../../library/ctypes.rst:1303 msgid "Quoting the docs for that value:" msgstr "" -#: ../../library/ctypes.rst:1303 +#: ../../library/ctypes.rst:1305 msgid "" "This pointer is initialized to point to an array of :c:struct:`_frozen` " "records, terminated by one whose members are all ``NULL`` or zero. When a " @@ -2534,13 +2540,13 @@ msgid "" "frozen modules." msgstr "" -#: ../../library/ctypes.rst:1308 +#: ../../library/ctypes.rst:1310 msgid "" "So manipulating this pointer could even prove useful. To restrict the " "example size, we show only how this table can be read with :mod:`!ctypes`::" msgstr "" -#: ../../library/ctypes.rst:1311 +#: ../../library/ctypes.rst:1313 msgid "" ">>> from ctypes import *\n" ">>>\n" @@ -2564,13 +2570,13 @@ msgstr "" "...\n" ">>>" -#: ../../library/ctypes.rst:1322 +#: ../../library/ctypes.rst:1324 msgid "" "We have defined the :c:struct:`_frozen` data type, so we can get the pointer " "to the table::" msgstr "" -#: ../../library/ctypes.rst:1325 +#: ../../library/ctypes.rst:1327 msgid "" ">>> FrozenTable = POINTER(struct_frozen)\n" ">>> table = FrozenTable.in_dll(pythonapi, \"_PyImport_FrozenBootstrap\")\n" @@ -2580,7 +2586,7 @@ msgstr "" ">>> table = FrozenTable.in_dll(pythonapi, \"_PyImport_FrozenBootstrap\")\n" ">>>" -#: ../../library/ctypes.rst:1329 +#: ../../library/ctypes.rst:1331 msgid "" "Since ``table`` is a ``pointer`` to the array of ``struct_frozen`` records, " "we can iterate over it, but we just have to make sure that our loop " @@ -2589,7 +2595,7 @@ msgid "" "the loop when we hit the ``NULL`` entry::" msgstr "" -#: ../../library/ctypes.rst:1335 +#: ../../library/ctypes.rst:1337 msgid "" ">>> for item in table:\n" "... if item.name is None:\n" @@ -2611,28 +2617,28 @@ msgstr "" "zipimport 12345\n" ">>>" -#: ../../library/ctypes.rst:1345 +#: ../../library/ctypes.rst:1347 msgid "" "The fact that standard Python has a frozen module and a frozen package " "(indicated by the negative ``size`` member) is not well known, it is only " "used for testing. Try it out with ``import __hello__`` for example." msgstr "" -#: ../../library/ctypes.rst:1353 +#: ../../library/ctypes.rst:1355 msgid "Surprises" msgstr "" -#: ../../library/ctypes.rst:1355 +#: ../../library/ctypes.rst:1357 msgid "" "There are some edges in :mod:`!ctypes` where you might expect something " "other than what actually happens." msgstr "" -#: ../../library/ctypes.rst:1358 +#: ../../library/ctypes.rst:1360 msgid "Consider the following example::" msgstr "" -#: ../../library/ctypes.rst:1360 +#: ../../library/ctypes.rst:1362 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -2670,13 +2676,13 @@ msgstr "" "3 4 3 4\n" ">>>" -#: ../../library/ctypes.rst:1378 +#: ../../library/ctypes.rst:1380 msgid "" "Hm. We certainly expected the last statement to print ``3 4 1 2``. What " "happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above::" msgstr "" -#: ../../library/ctypes.rst:1381 +#: ../../library/ctypes.rst:1383 msgid "" ">>> temp0, temp1 = rc.b, rc.a\n" ">>> rc.a = temp0\n" @@ -2688,7 +2694,7 @@ msgstr "" ">>> rc.b = temp1\n" ">>>" -#: ../../library/ctypes.rst:1386 +#: ../../library/ctypes.rst:1388 msgid "" "Note that ``temp0`` and ``temp1`` are objects still using the internal " "buffer of the ``rc`` object above. So executing ``rc.a = temp0`` copies the " @@ -2697,20 +2703,20 @@ msgid "" "have the expected effect." msgstr "" -#: ../../library/ctypes.rst:1392 +#: ../../library/ctypes.rst:1394 msgid "" "Keep in mind that retrieving sub-objects from Structure, Unions, and Arrays " "doesn't *copy* the sub-object, instead it retrieves a wrapper object " "accessing the root-object's underlying buffer." msgstr "" -#: ../../library/ctypes.rst:1396 +#: ../../library/ctypes.rst:1398 msgid "" "Another example that may behave differently from what one would expect is " "this::" msgstr "" -#: ../../library/ctypes.rst:1398 +#: ../../library/ctypes.rst:1400 msgid "" ">>> s = c_char_p()\n" ">>> s.value = b\"abc def ghi\"\n" @@ -2728,13 +2734,13 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:1408 +#: ../../library/ctypes.rst:1410 msgid "" "Objects instantiated from :class:`c_char_p` can only have their value set to " "bytes or integers." msgstr "" -#: ../../library/ctypes.rst:1411 +#: ../../library/ctypes.rst:1413 msgid "" "Why is it printing ``False``? ctypes instances are objects containing a " "memory block plus some :term:`descriptor`\\s accessing the contents of the " @@ -2743,17 +2749,17 @@ msgid "" "the contents again constructs a new Python object each time!" msgstr "" -#: ../../library/ctypes.rst:1421 +#: ../../library/ctypes.rst:1423 msgid "Variable-sized data types" msgstr "" -#: ../../library/ctypes.rst:1423 +#: ../../library/ctypes.rst:1425 msgid "" ":mod:`!ctypes` provides some support for variable-sized arrays and " "structures." msgstr "" -#: ../../library/ctypes.rst:1425 +#: ../../library/ctypes.rst:1427 msgid "" "The :func:`resize` function can be used to resize the memory buffer of an " "existing ctypes object. The function takes the object as first argument, " @@ -2762,7 +2768,7 @@ msgid "" "objects type, a :exc:`ValueError` is raised if this is tried::" msgstr "" -#: ../../library/ctypes.rst:1431 +#: ../../library/ctypes.rst:1433 msgid "" ">>> short_array = (c_short * 4)()\n" ">>> print(sizeof(short_array))\n" @@ -2792,14 +2798,14 @@ msgstr "" "8\n" ">>>" -#: ../../library/ctypes.rst:1445 +#: ../../library/ctypes.rst:1447 msgid "" "This is nice and fine, but how would one access the additional elements " "contained in this array? Since the type still only knows about 4 elements, " "we get errors accessing other elements::" msgstr "" -#: ../../library/ctypes.rst:1449 +#: ../../library/ctypes.rst:1451 msgid "" ">>> short_array[:]\n" "[0, 0, 0, 0]\n" @@ -2817,249 +2823,91 @@ msgstr "" "IndexError: invalid index\n" ">>>" -#: ../../library/ctypes.rst:1457 +#: ../../library/ctypes.rst:1459 msgid "" "Another way to use variable-sized data types with :mod:`!ctypes` is to use " "the dynamic nature of Python, and (re-)define the data type after the " "required size is already known, on a case by case basis." msgstr "" -#: ../../library/ctypes.rst:1465 +#: ../../library/ctypes.rst:1467 msgid "ctypes reference" msgstr "" -#: ../../library/ctypes.rst:1471 -msgid "Finding shared libraries" +#: ../../library/ctypes.rst:1472 +msgid "Loading shared libraries" msgstr "" -#: ../../library/ctypes.rst:1473 +#: ../../library/ctypes.rst:1474 msgid "" -"When programming in a compiled language, shared libraries are accessed when " -"compiling/linking a program, and when the program is run." +"There are several ways to load shared libraries into the Python process. " +"One way is to instantiate :py:class:`CDLL` or one of its subclasses:" msgstr "" -#: ../../library/ctypes.rst:1476 -msgid "" -"The purpose of the :func:`~ctypes.util.find_library` function is to locate a " -"library in a way similar to what the compiler or runtime loader does (on " -"platforms with several versions of a shared library the most recent should " -"be loaded), while the ctypes library loaders act like when a program is run, " -"and call the runtime loader directly." +#: ../../library/ctypes.rst:1480 +msgid "Represents a loaded shared library." msgstr "" #: ../../library/ctypes.rst:1482 msgid "" -"The :mod:`!ctypes.util` module provides a function which can help to " -"determine the library to load." +"Functions in this library use the standard C calling convention, and are " +"assumed to return :c:expr:`int`. The Python :term:`global interpreter lock` " +"is released before calling any function exported by these libraries, and " +"reacquired afterwards. For different function behavior, use a subclass: :py:" +"class:`~ctypes.OleDLL`, :py:class:`~ctypes.WinDLL`, or :py:class:`~ctypes." +"PyDLL`." msgstr "" -#: ../../library/ctypes.rst:1490 +#: ../../library/ctypes.rst:1489 msgid "" -"Try to find a library and return a pathname. *name* is the library name " -"without any prefix like *lib*, suffix like ``.so``, ``.dylib`` or version " -"number (this is the form used for the posix linker option :option:`!-l`). " -"If no library can be found, returns ``None``." +"If you have an existing :py:attr:`handle ` to an " +"already loaded shared library, it can be passed as the *handle* argument to " +"wrap the opened library in a new :py:class:`!CDLL` object. In this case, " +"*name* is only used to set the :py:attr:`~ctypes.CDLL._name` attribute, but " +"it may be adjusted and/or validated." msgstr "" -#: ../../library/ctypes.rst:1495 ../../library/ctypes.rst:2261 -msgid "The exact functionality is system dependent." +#: ../../library/ctypes.rst:1495 +msgid "" +"If *handle* is ``None``, the underlying platform's :manpage:`dlopen(3)` or " +"`LoadLibraryExW`_ function is used to load the library into the process, and " +"to get a handle to it." msgstr "" -#: ../../library/ctypes.rst:1497 +#: ../../library/ctypes.rst:1499 msgid "" -"On Linux, :func:`~ctypes.util.find_library` tries to run external programs " -"(``/sbin/ldconfig``, ``gcc``, ``objdump`` and ``ld``) to find the library " -"file. It returns the filename of the library file." +"*name* is the pathname of the shared library to open. If *name* does not " +"contain a path separator, the library is found in a platform-specific way." msgstr "" -#: ../../library/ctypes.rst:1501 +#: ../../library/ctypes.rst:1503 msgid "" -"Note that if the output of these programs does not correspond to the dynamic " -"linker used by Python, the result of this function may be misleading." +"On Windows, the ``.DLL`` suffix may be missing. (For details, see " +"`LoadLibraryExW`_ documentation.) Other platform-specific prefixes and " +"suffixes (for example, ``lib``, ``.so``, ``.dylib``, or version numbers) " +"must be present in *name*; they are not added automatically. See :ref:" +"`ctypes-finding-shared-libraries` for more information." msgstr "" -#: ../../library/ctypes.rst:1504 +#: ../../library/ctypes.rst:1510 msgid "" -"On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used " -"when searching for libraries, if a library cannot be found by any other " -"means." +"On non-Windows systems, *name* can be ``None``. In this case, :c:func:`!" +"dlopen` is called with ``NULL``, which opens the main program as a " +"\"library\". (Some systems do the same is *name* is empty; ``None``/``NULL`` " +"is more portable.)" msgstr "" -#: ../../library/ctypes.rst:1508 -msgid "Here are some examples::" -msgstr "以下是一些範例: ::" +#: ../../library/ctypes.rst:1516 +msgid "CPython implementation detail" +msgstr "" -#: ../../library/ctypes.rst:1510 -msgid "" -">>> from ctypes.util import find_library\n" -">>> find_library(\"m\")\n" -"'libm.so.6'\n" -">>> find_library(\"c\")\n" -"'libc.so.6'\n" -">>> find_library(\"bz2\")\n" -"'libbz2.so.1.0'\n" -">>>" -msgstr "" -">>> from ctypes.util import find_library\n" -">>> find_library(\"m\")\n" -"'libm.so.6'\n" -">>> find_library(\"c\")\n" -"'libc.so.6'\n" -">>> find_library(\"bz2\")\n" -"'libbz2.so.1.0'\n" -">>>" - -#: ../../library/ctypes.rst:1519 -msgid "" -"On macOS and Android, :func:`~ctypes.util.find_library` uses the system's " -"standard naming schemes and paths to locate the library, and returns a full " -"pathname if successful::" -msgstr "" - -#: ../../library/ctypes.rst:1523 -msgid "" -">>> from ctypes.util import find_library\n" -">>> find_library(\"c\")\n" -"'/usr/lib/libc.dylib'\n" -">>> find_library(\"m\")\n" -"'/usr/lib/libm.dylib'\n" -">>> find_library(\"bz2\")\n" -"'/usr/lib/libbz2.dylib'\n" -">>> find_library(\"AGL\")\n" -"'/System/Library/Frameworks/AGL.framework/AGL'\n" -">>>" -msgstr "" -">>> from ctypes.util import find_library\n" -">>> find_library(\"c\")\n" -"'/usr/lib/libc.dylib'\n" -">>> find_library(\"m\")\n" -"'/usr/lib/libm.dylib'\n" -">>> find_library(\"bz2\")\n" -"'/usr/lib/libbz2.dylib'\n" -">>> find_library(\"AGL\")\n" -"'/System/Library/Frameworks/AGL.framework/AGL'\n" -">>>" - -#: ../../library/ctypes.rst:1534 -msgid "" -"On Windows, :func:`~ctypes.util.find_library` searches along the system " -"search path, and returns the full pathname, but since there is no predefined " -"naming scheme a call like ``find_library(\"c\")`` will fail and return " -"``None``." -msgstr "" - -#: ../../library/ctypes.rst:1538 -msgid "" -"If wrapping a shared library with :mod:`!ctypes`, it *may* be better to " -"determine the shared library name at development time, and hardcode that " -"into the wrapper module instead of using :func:`~ctypes.util.find_library` " -"to locate the library at runtime." -msgstr "" - -#: ../../library/ctypes.rst:1546 -msgid "Listing loaded shared libraries" -msgstr "" - -#: ../../library/ctypes.rst:1548 -msgid "" -"When writing code that relies on code loaded from shared libraries, it can " -"be useful to know which shared libraries have already been loaded into the " -"current process." -msgstr "" - -#: ../../library/ctypes.rst:1552 -msgid "" -"The :mod:`!ctypes.util` module provides the :func:`~ctypes.util.dllist` " -"function, which calls the different APIs provided by the various platforms " -"to help determine which shared libraries have already been loaded into the " -"current process." -msgstr "" - -#: ../../library/ctypes.rst:1556 -msgid "" -"The exact output of this function will be system dependent. On most " -"platforms, the first entry of this list represents the current process " -"itself, which may be an empty string. For example, on glibc-based Linux, the " -"return may look like::" -msgstr "" - -#: ../../library/ctypes.rst:1561 -msgid "" -">>> from ctypes.util import dllist\n" -">>> dllist()\n" -"['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-" -"linux-gnu/libc.so.6', ... ]" -msgstr "" -">>> from ctypes.util import dllist\n" -">>> dllist()\n" -"['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-" -"linux-gnu/libc.so.6', ... ]" - -#: ../../library/ctypes.rst:1568 -msgid "Loading shared libraries" -msgstr "" - -#: ../../library/ctypes.rst:1570 -msgid "" -"There are several ways to load shared libraries into the Python process. " -"One way is to instantiate :py:class:`CDLL` or one of its subclasses:" -msgstr "" - -#: ../../library/ctypes.rst:1576 -msgid "Represents a loaded shared library." -msgstr "" - -#: ../../library/ctypes.rst:1578 -msgid "" -"Functions in this library use the standard C calling convention, and are " -"assumed to return :c:expr:`int`. The Python :term:`global interpreter lock` " -"is released before calling any function exported by these libraries, and " -"reacquired afterwards. For different function behavior, use a subclass: :py:" -"class:`~ctypes.OleDLL`, :py:class:`~ctypes.WinDLL`, or :py:class:`~ctypes." -"PyDLL`." -msgstr "" - -#: ../../library/ctypes.rst:1585 -msgid "" -"If you have an existing :py:attr:`handle ` to an " -"already loaded shared library, it can be passed as the *handle* argument to " -"wrap the opened library in a new :py:class:`!CDLL` object. In this case, " -"*name* is only used to set the :py:attr:`~ctypes.CDLL._name` attribute, but " -"it may be adjusted and/or validated." -msgstr "" - -#: ../../library/ctypes.rst:1591 -msgid "" -"If *handle* is ``None``, the underlying platform's :manpage:`dlopen(3)` or :" -"c:func:`!LoadLibrary` function is used to load the library into the process, " -"and to get a handle to it." -msgstr "" - -#: ../../library/ctypes.rst:1595 -msgid "" -"*name* is the pathname of the shared library to open. If *name* does not " -"contain a path separator, the library is found in a platform-specific way." -msgstr "" - -#: ../../library/ctypes.rst:1599 -msgid "" -"On non-Windows systems, *name* can be ``None``. In this case, :c:func:`!" -"dlopen` is called with ``NULL``, which opens the main program as a " -"\"library\". (Some systems do the same is *name* is empty; ``None``/``NULL`` " -"is more portable.)" -msgstr "" - -#: ../../library/ctypes.rst:1605 -msgid "CPython implementation detail" -msgstr "" - -#: ../../library/ctypes.rst:1607 +#: ../../library/ctypes.rst:1518 msgid "" "Since CPython is linked to ``libc``, a ``None`` *name* is often used to " "access the C standard library::" msgstr "" -#: ../../library/ctypes.rst:1610 +#: ../../library/ctypes.rst:1521 msgid "" ">>> printf = ctypes.CDLL(None).printf\n" ">>> printf.argtypes = [ctypes.c_char_p]\n" @@ -3068,13 +2916,13 @@ msgid "" "6" msgstr "" -#: ../../library/ctypes.rst:1616 +#: ../../library/ctypes.rst:1527 msgid "" "To access the Python C API, prefer :py:data:`ctypes.pythonapi` which works " "across platforms." msgstr "" -#: ../../library/ctypes.rst:1619 +#: ../../library/ctypes.rst:1530 msgid "" "The *mode* parameter can be used to specify how the library is loaded. For " "details, consult the :manpage:`dlopen(3)` manpage. On Windows, *mode* is " @@ -3082,7 +2930,7 @@ msgid "" "configurable." msgstr "" -#: ../../library/ctypes.rst:1624 +#: ../../library/ctypes.rst:1535 msgid "" "The *use_errno* parameter, when set to true, enables a ctypes mechanism that " "allows accessing the system :data:`errno` error number in a safe way. :mod:`!" @@ -3096,14 +2944,14 @@ msgid "" "ctypes` cannot observe." msgstr "" -#: ../../library/ctypes.rst:1634 +#: ../../library/ctypes.rst:1545 msgid "" "The function :func:`ctypes.get_errno` returns the value of the ctypes " "private copy, and the function :func:`ctypes.set_errno` changes the ctypes " "private copy to a new value and returns the former value." msgstr "" -#: ../../library/ctypes.rst:1638 +#: ../../library/ctypes.rst:1549 msgid "" "The *use_last_error* parameter, when set to true, enables the same mechanism " "for the Windows error code which is managed by the :func:`GetLastError` and :" @@ -3112,17 +2960,17 @@ msgid "" "private copy of the windows error code." msgstr "" -#: ../../library/ctypes.rst:1644 +#: ../../library/ctypes.rst:1555 msgid "" "The *winmode* parameter is used on Windows to specify how the library is " "loaded (since *mode* is ignored). It takes any value that is valid for the " -"Win32 API ``LoadLibraryEx`` flags parameter. When omitted, the default is to " +"Win32 API `LoadLibraryExW`_ flags parameter. When omitted, the default is to " "use the flags that result in the most secure DLL load, which avoids issues " "such as DLL hijacking. Passing the full path to the DLL is the safest way to " "ensure the correct library and dependencies are loaded." msgstr "" -#: ../../library/ctypes.rst:1651 +#: ../../library/ctypes.rst:1562 msgid "" "On Windows creating a :class:`CDLL` instance may fail even if the DLL name " "exists. When a dependent DLL of the loaded DLL is not found, a :exc:" @@ -3134,22 +2982,22 @@ msgid "" "determine which one is not found using Windows debugging and tracing tools." msgstr "" -#: ../../library/ctypes.rst:1663 +#: ../../library/ctypes.rst:1574 msgid "" "`Microsoft DUMPBIN tool `_ -- A tool to find DLL " "dependents." msgstr "" -#: ../../library/ctypes.rst:1666 +#: ../../library/ctypes.rst:1577 msgid "Added *winmode* parameter." msgstr "新增 *winmode* 參數。" -#: ../../library/ctypes.rst:1671 +#: ../../library/ctypes.rst:1582 msgid "The *name* parameter can now be a :term:`path-like object`." msgstr "" -#: ../../library/ctypes.rst:1673 +#: ../../library/ctypes.rst:1584 msgid "" "Instances of this class have no public methods. Functions exported by the " "shared library can be accessed as attributes or by index. Please note that " @@ -3158,7 +3006,7 @@ msgid "" "hand, accessing it through an index returns a new object each time::" msgstr "" -#: ../../library/ctypes.rst:1679 +#: ../../library/ctypes.rst:1590 msgid "" ">>> from ctypes import CDLL\n" ">>> libc = CDLL(\"libc.so.6\") # On Linux\n" @@ -3174,26 +3022,26 @@ msgstr "" ">>> libc['time'] == libc['time']\n" "False" -#: ../../library/ctypes.rst:1686 +#: ../../library/ctypes.rst:1597 msgid "" "The following public attributes are available. Their name starts with an " "underscore to not clash with exported function names:" msgstr "" -#: ../../library/ctypes.rst:1691 +#: ../../library/ctypes.rst:1602 msgid "The system handle used to access the library." msgstr "" -#: ../../library/ctypes.rst:1695 +#: ../../library/ctypes.rst:1606 msgid "The name of the library passed in the constructor." msgstr "" -#: ../../library/ctypes.rst:1699 ../../library/ctypes.rst:1716 -#: ../../library/ctypes.rst:1725 +#: ../../library/ctypes.rst:1612 ../../library/ctypes.rst:1629 +#: ../../library/ctypes.rst:1638 msgid "See :py:class:`~ctypes.CDLL`, the superclass, for common information." msgstr "" -#: ../../library/ctypes.rst:1701 +#: ../../library/ctypes.rst:1614 msgid "" "Functions in this library use the ``stdcall`` calling convention, and are " "assumed to return the windows specific :class:`HRESULT` code. :class:" @@ -3202,60 +3050,60 @@ msgid "" "value signals a failure, an :class:`OSError` is automatically raised." msgstr "" -#: ../../library/ctypes.rst:1707 ../../library/ctypes.rst:1721 -#: ../../library/ctypes.rst:1784 ../../library/ctypes.rst:1791 -#: ../../library/ctypes.rst:1965 ../../library/ctypes.rst:2017 -#: ../../library/ctypes.rst:2169 ../../library/ctypes.rst:2241 -#: ../../library/ctypes.rst:2250 ../../library/ctypes.rst:2277 -#: ../../library/ctypes.rst:2291 ../../library/ctypes.rst:2300 -#: ../../library/ctypes.rst:2309 ../../library/ctypes.rst:2324 -#: ../../library/ctypes.rst:2391 ../../library/ctypes.rst:2418 -#: ../../library/ctypes.rst:2850 ../../library/ctypes.rst:3273 +#: ../../library/ctypes.rst:1620 ../../library/ctypes.rst:1634 +#: ../../library/ctypes.rst:1697 ../../library/ctypes.rst:1704 +#: ../../library/ctypes.rst:1844 ../../library/ctypes.rst:2003 +#: ../../library/ctypes.rst:2055 ../../library/ctypes.rst:2207 +#: ../../library/ctypes.rst:2279 ../../library/ctypes.rst:2288 +#: ../../library/ctypes.rst:2302 ../../library/ctypes.rst:2311 +#: ../../library/ctypes.rst:2320 ../../library/ctypes.rst:2335 +#: ../../library/ctypes.rst:2402 ../../library/ctypes.rst:2429 +#: ../../library/ctypes.rst:2861 ../../library/ctypes.rst:3284 msgid "Availability" msgstr "可用性" -#: ../../library/ctypes.rst:1709 +#: ../../library/ctypes.rst:1622 msgid "" ":exc:`WindowsError` used to be raised, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/ctypes.rst:1718 +#: ../../library/ctypes.rst:1631 msgid "" "Functions in these libraries use the ``stdcall`` calling convention, and are " "assumed to return :c:expr:`int` by default." msgstr "" -#: ../../library/ctypes.rst:1727 +#: ../../library/ctypes.rst:1640 msgid "" "When functions in this library are called, the Python GIL is *not* released " "during the function call, and after the function execution the Python error " "flag is checked. If the error flag is set, a Python exception is raised." msgstr "" -#: ../../library/ctypes.rst:1732 +#: ../../library/ctypes.rst:1645 msgid "Thus, this is only useful to call Python C API functions directly." msgstr "" -#: ../../library/ctypes.rst:1737 +#: ../../library/ctypes.rst:1650 msgid "" "Flag to use as *mode* parameter. On platforms where this flag is not " "available, it is defined as the integer zero." msgstr "" -#: ../../library/ctypes.rst:1743 +#: ../../library/ctypes.rst:1656 msgid "" "Flag to use as *mode* parameter. On platforms where this is not available, " "it is the same as *RTLD_GLOBAL*." msgstr "" -#: ../../library/ctypes.rst:1749 +#: ../../library/ctypes.rst:1662 msgid "" "The default mode which is used to load shared libraries. On OSX 10.3, this " "is *RTLD_GLOBAL*, otherwise it is the same as *RTLD_LOCAL*." msgstr "" -#: ../../library/ctypes.rst:1753 +#: ../../library/ctypes.rst:1666 msgid "" "Shared libraries can also be loaded by using one of the prefabricated " "objects, which are instances of the :class:`LibraryLoader` class, either by " @@ -3263,13 +3111,13 @@ msgid "" "library as attribute of the loader instance." msgstr "" -#: ../../library/ctypes.rst:1760 +#: ../../library/ctypes.rst:1673 msgid "" "Class which loads shared libraries. *dlltype* should be one of the :class:" "`CDLL`, :class:`PyDLL`, :class:`WinDLL`, or :class:`OleDLL` types." msgstr "" -#: ../../library/ctypes.rst:1763 +#: ../../library/ctypes.rst:1676 msgid "" ":meth:`!__getattr__` has special behavior: It allows loading a shared " "library by accessing it as attribute of a library loader instance. The " @@ -3277,39 +3125,33 @@ msgid "" "each time." msgstr "" -#: ../../library/ctypes.rst:1769 +#: ../../library/ctypes.rst:1682 msgid "" "Load a shared library into the process and return it. This method always " "returns a new instance of the library." msgstr "" -#: ../../library/ctypes.rst:1773 +#: ../../library/ctypes.rst:1686 msgid "These prefabricated library loaders are available:" msgstr "" -#: ../../library/ctypes.rst:1777 +#: ../../library/ctypes.rst:1690 msgid "Creates :class:`CDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1782 +#: ../../library/ctypes.rst:1695 msgid "Creates :class:`WinDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1789 +#: ../../library/ctypes.rst:1702 msgid "Creates :class:`OleDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1796 +#: ../../library/ctypes.rst:1709 msgid "Creates :class:`PyDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1799 -msgid "" -"For accessing the C Python api directly, a ready-to-use Python shared " -"library object is available:" -msgstr "" - -#: ../../library/ctypes.rst:1804 +#: ../../library/ctypes.rst:1714 msgid "" "An instance of :class:`PyDLL` that exposes Python C API functions as " "attributes. Note that all these functions are assumed to return C :c:expr:" @@ -3317,37 +3159,234 @@ msgid "" "correct :attr:`!restype` attribute to use these functions." msgstr "" -#: ../../library/ctypes.rst:1811 +#: ../../library/ctypes.rst:1721 msgid "If the Python interpreter is statically linked, this may be ``None``." msgstr "" -#: ../../library/ctypes.rst:1813 ../../library/ctypes.rst:1815 +#: ../../library/ctypes.rst:1723 ../../library/ctypes.rst:1725 msgid "" "Loading a library through any of these objects raises an :ref:`auditing " "event ` ``ctypes.dlopen`` with string argument ``name``, the name " "used to load the library." msgstr "" -#: ../../library/ctypes.rst:1819 ../../library/ctypes.rst:1821 +#: ../../library/ctypes.rst:1729 ../../library/ctypes.rst:1731 msgid "" "Accessing a function on a loaded library raises an auditing event ``ctypes." "dlsym`` with arguments ``library`` (the library object) and ``name`` (the " "symbol's name as a string or integer)." msgstr "" -#: ../../library/ctypes.rst:1825 ../../library/ctypes.rst:1827 +#: ../../library/ctypes.rst:1735 ../../library/ctypes.rst:1737 msgid "" "In cases when only the library handle is available rather than the object, " "accessing a function raises an auditing event ``ctypes.dlsym/handle`` with " "arguments ``handle`` (the raw library handle) and ``name``." msgstr "" -#: ../../library/ctypes.rst:1834 -msgid "Foreign functions" +#: ../../library/ctypes.rst:1745 +msgid "Finding shared libraries" +msgstr "" + +#: ../../library/ctypes.rst:1747 +msgid "" +"When programming in a compiled language, shared libraries are accessed when " +"compiling/linking a program, and when the program is run. The programmer " +"specifies a short name; the C compiler, linker, and runtime dynamic library " +"loader then interact in system-specific ways to find the filename of the " +"library to load." +msgstr "" + +#: ../../library/ctypes.rst:1753 +msgid "" +"While the mapping from short names to filenames is not consistently exposed " +"by platforms, the :mod:`!ctypes.util` module provides a function, :func:`!" +"find_library`, that attempts to match it. However, as backwards " +"compatibility concerns make it difficult to adjust its behavior for new " +"platforms and configurations, the function is :term:`soft deprecated`." +msgstr "" + +#: ../../library/ctypes.rst:1760 +msgid "" +"If wrapping a shared library with :mod:`!ctypes`, consider determining the " +"shared library name at development time, and hardcoding it into the wrapper " +"module instead of using :func:`!find_library` to locate the library at " +"runtime. Also consider adding a configuration option or environment variable " +"to let users select a library to use, and then perhaps use :func:`!" +"find_library` as a default or fallback." +msgstr "" + +#: ../../library/ctypes.rst:1771 +msgid "Try to find a library and return a pathname." +msgstr "" + +#: ../../library/ctypes.rst:1773 +msgid "" +"*name* is the \"short\" library name without any prefix like ``lib``, suffix " +"like ``.so``, ``.dylib`` or version number. (This is the form used for the " +"posix linker option :option:`!-l`.) The result is in a format suitable for " +"passing to :py:class:`~ctypes.CDLL`." +msgstr "" + +#: ../../library/ctypes.rst:1778 +msgid "If no library can be found, return ``None``." +msgstr "" + +#: ../../library/ctypes.rst:1780 +msgid "" +"The exact functionality is system dependent, and is *not guaranteed* to " +"match the behavior of the compiler, linker, and loader used for (or by) " +"Python. It is recommended to only use this function as a default or fallback," +msgstr "" + +#: ../../library/ctypes.rst:1787 +msgid "" +"This function is kept for use in cases where it works, but not expected to " +"be updated for additional platforms and configurations." +msgstr "" + +#: ../../library/ctypes.rst:1790 +msgid "" +"On Linux, :func:`!find_library` tries to run external programs (``/sbin/" +"ldconfig``, ``gcc``, ``objdump`` and ``ld``) to find the library file. If " +"the output of these programs does not correspond to the dynamic linker used " +"by Python, the result of this function may be misleading." +msgstr "" + +#: ../../library/ctypes.rst:1796 +msgid "" +"On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used " +"when searching for libraries, if a library cannot be found by any other " +"means." +msgstr "" + +#: ../../library/ctypes.rst:1800 +msgid "Here are some examples::" +msgstr "以下是一些範例: ::" + +#: ../../library/ctypes.rst:1802 +msgid "" +">>> from ctypes.util import find_library\n" +">>> find_library(\"m\")\n" +"'libm.so.6'\n" +">>> find_library(\"c\")\n" +"'libc.so.6'\n" +">>> find_library(\"bz2\")\n" +"'libbz2.so.1.0'\n" +">>>" +msgstr "" +">>> from ctypes.util import find_library\n" +">>> find_library(\"m\")\n" +"'libm.so.6'\n" +">>> find_library(\"c\")\n" +"'libc.so.6'\n" +">>> find_library(\"bz2\")\n" +"'libbz2.so.1.0'\n" +">>>" + +#: ../../library/ctypes.rst:1811 +msgid "" +"On macOS and Android, :func:`!find_library` uses the system's standard " +"naming schemes and paths to locate the library, and returns a full pathname " +"if successful::" +msgstr "" + +#: ../../library/ctypes.rst:1815 +msgid "" +">>> from ctypes.util import find_library\n" +">>> find_library(\"c\")\n" +"'/usr/lib/libc.dylib'\n" +">>> find_library(\"m\")\n" +"'/usr/lib/libm.dylib'\n" +">>> find_library(\"bz2\")\n" +"'/usr/lib/libbz2.dylib'\n" +">>> find_library(\"AGL\")\n" +"'/System/Library/Frameworks/AGL.framework/AGL'\n" +">>>" +msgstr "" +">>> from ctypes.util import find_library\n" +">>> find_library(\"c\")\n" +"'/usr/lib/libc.dylib'\n" +">>> find_library(\"m\")\n" +"'/usr/lib/libm.dylib'\n" +">>> find_library(\"bz2\")\n" +"'/usr/lib/libbz2.dylib'\n" +">>> find_library(\"AGL\")\n" +"'/System/Library/Frameworks/AGL.framework/AGL'\n" +">>>" + +#: ../../library/ctypes.rst:1826 +msgid "" +"On Windows, :func:`!find_library` searches along the system search path, and " +"returns the full pathname, but since there is no predefined naming scheme a " +"call like ``find_library(\"c\")`` will fail and return ``None``." +msgstr "" + +#: ../../library/ctypes.rst:1833 +msgid "" +"Returns the filename of the VC runtime library used by Python, and by the " +"extension modules." msgstr "" #: ../../library/ctypes.rst:1836 msgid "" +"If the name of the library cannot be determined, ``None`` is returned. " +"Notably, this will happen for recent versions of the VC runtime library, " +"which are not directly loadable." +msgstr "" + +#: ../../library/ctypes.rst:1840 +msgid "" +"If you need to free memory, for example, allocated by an extension module " +"with a call to the ``free(void *)``, it is important that you use the " +"function in the same library that allocated the memory." +msgstr "" + +#: ../../library/ctypes.rst:1850 +msgid "Listing loaded shared libraries" +msgstr "" + +#: ../../library/ctypes.rst:1852 +msgid "" +"When writing code that relies on code loaded from shared libraries, it can " +"be useful to know which shared libraries have already been loaded into the " +"current process." +msgstr "" + +#: ../../library/ctypes.rst:1856 +msgid "" +"The :mod:`!ctypes.util` module provides the :func:`~ctypes.util.dllist` " +"function, which calls the different APIs provided by the various platforms " +"to help determine which shared libraries have already been loaded into the " +"current process." +msgstr "" + +#: ../../library/ctypes.rst:1860 +msgid "" +"The exact output of this function will be system dependent. On most " +"platforms, the first entry of this list represents the current process " +"itself, which may be an empty string. For example, on glibc-based Linux, the " +"return may look like::" +msgstr "" + +#: ../../library/ctypes.rst:1865 +msgid "" +">>> from ctypes.util import dllist\n" +">>> dllist()\n" +"['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-" +"linux-gnu/libc.so.6', ... ]" +msgstr "" +">>> from ctypes.util import dllist\n" +">>> dllist()\n" +"['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-" +"linux-gnu/libc.so.6', ... ]" + +#: ../../library/ctypes.rst:1872 +msgid "Foreign functions" +msgstr "" + +#: ../../library/ctypes.rst:1874 +msgid "" "As explained in the previous section, foreign functions can be accessed as " "attributes of loaded shared libraries. The function objects created in this " "way by default accept any number of arguments, accept any ctypes data " @@ -3355,13 +3394,13 @@ msgid "" "library loader." msgstr "" -#: ../../library/ctypes.rst:1841 +#: ../../library/ctypes.rst:1879 msgid "" "They are instances of a private local class :class:`!_FuncPtr` (not exposed " "in :mod:`!ctypes`) which inherits from the private :class:`_CFuncPtr` class:" msgstr "" -#: ../../library/ctypes.rst:1844 +#: ../../library/ctypes.rst:1882 msgid "" ">>> import ctypes\n" ">>> lib = ctypes.CDLL(None)\n" @@ -3377,29 +3416,29 @@ msgstr "" ">>> lib._FuncPtr is ctypes._CFuncPtr\n" "False" -#: ../../library/ctypes.rst:1855 +#: ../../library/ctypes.rst:1893 msgid "Base class for C callable foreign functions." msgstr "" -#: ../../library/ctypes.rst:1857 +#: ../../library/ctypes.rst:1895 msgid "" "Instances of foreign functions are also C compatible data types; they " "represent C function pointers." msgstr "" -#: ../../library/ctypes.rst:1860 +#: ../../library/ctypes.rst:1898 msgid "" "This behavior can be customized by assigning to special attributes of the " "foreign function object." msgstr "" -#: ../../library/ctypes.rst:1865 +#: ../../library/ctypes.rst:1903 msgid "" "Assign a ctypes type to specify the result type of the foreign function. Use " "``None`` for :c:expr:`void`, a function not returning anything." msgstr "" -#: ../../library/ctypes.rst:1868 +#: ../../library/ctypes.rst:1906 msgid "" "It is possible to assign a callable Python object that is not a ctypes type, " "in this case the function is assumed to return a C :c:expr:`int`, and the " @@ -3409,7 +3448,7 @@ msgid "" "callable to the :attr:`errcheck` attribute." msgstr "" -#: ../../library/ctypes.rst:1877 +#: ../../library/ctypes.rst:1915 msgid "" "Assign a tuple of ctypes types to specify the argument types that the " "function accepts. Functions using the ``stdcall`` calling convention can " @@ -3418,7 +3457,7 @@ msgid "" "unspecified arguments as well." msgstr "" -#: ../../library/ctypes.rst:1883 +#: ../../library/ctypes.rst:1921 msgid "" "When a foreign function is called, each actual argument is passed to the :" "meth:`~_CData.from_param` class method of the items in the :attr:`argtypes` " @@ -3428,7 +3467,7 @@ msgid "" "object using ctypes conversion rules." msgstr "" -#: ../../library/ctypes.rst:1890 +#: ../../library/ctypes.rst:1928 msgid "" "New: It is now possible to put items in argtypes which are not ctypes types, " "but each item must have a :meth:`~_CData.from_param` method which returns a " @@ -3436,38 +3475,38 @@ msgid "" "defining adapters that can adapt custom objects as function parameters." msgstr "" -#: ../../library/ctypes.rst:1897 +#: ../../library/ctypes.rst:1935 msgid "" "Assign a Python function or another callable to this attribute. The callable " "will be called with three or more arguments:" msgstr "" -#: ../../library/ctypes.rst:1904 +#: ../../library/ctypes.rst:1942 msgid "" "*result* is what the foreign function returns, as specified by the :attr:`!" "restype` attribute." msgstr "" -#: ../../library/ctypes.rst:1907 +#: ../../library/ctypes.rst:1945 msgid "" "*func* is the foreign function object itself, this allows reusing the same " "callable object to check or post process the results of several functions." msgstr "" -#: ../../library/ctypes.rst:1911 +#: ../../library/ctypes.rst:1949 msgid "" "*arguments* is a tuple containing the parameters originally passed to the " "function call, this allows specializing the behavior on the arguments used." msgstr "" -#: ../../library/ctypes.rst:1915 +#: ../../library/ctypes.rst:1953 msgid "" "The object that this function returns will be returned from the foreign " "function call, but it can also check the result value and raise an exception " "if the foreign function call failed." msgstr "" -#: ../../library/ctypes.rst:1920 ../../library/ctypes.rst:1922 +#: ../../library/ctypes.rst:1958 ../../library/ctypes.rst:1960 msgid "" "On Windows, when a foreign function call raises a system exception (for " "example, due to an access violation), it will be captured and replaced with " @@ -3476,18 +3515,18 @@ msgid "" "hook to replace the exception with its own." msgstr "" -#: ../../library/ctypes.rst:1928 ../../library/ctypes.rst:1930 +#: ../../library/ctypes.rst:1966 ../../library/ctypes.rst:1968 msgid "" "Some ways to invoke foreign function calls as well as some of the functions " "in this module may raise an auditing event ``ctypes.call_function`` with " "arguments ``function pointer`` and ``arguments``." msgstr "" -#: ../../library/ctypes.rst:1937 +#: ../../library/ctypes.rst:1975 msgid "Function prototypes" msgstr "" -#: ../../library/ctypes.rst:1939 +#: ../../library/ctypes.rst:1977 msgid "" "Foreign functions can also be created by instantiating function prototypes. " "Function prototypes are similar to function prototypes in C; they describe a " @@ -3498,7 +3537,7 @@ msgid "" "``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples." msgstr "" -#: ../../library/ctypes.rst:1950 +#: ../../library/ctypes.rst:1988 msgid "" "The returned function prototype creates functions that use the standard C " "calling convention. The function will release the GIL during the call. If " @@ -3507,37 +3546,37 @@ msgid "" "after the call; *use_last_error* does the same for the Windows error code." msgstr "" -#: ../../library/ctypes.rst:1960 +#: ../../library/ctypes.rst:1998 msgid "" "The returned function prototype creates functions that use the ``stdcall`` " "calling convention. The function will release the GIL during the call. " "*use_errno* and *use_last_error* have the same meaning as above." msgstr "" -#: ../../library/ctypes.rst:1970 +#: ../../library/ctypes.rst:2008 msgid "" "The returned function prototype creates functions that use the Python " "calling convention. The function will *not* release the GIL during the call." msgstr "" -#: ../../library/ctypes.rst:1973 +#: ../../library/ctypes.rst:2011 msgid "" "Function prototypes created by these factory functions can be instantiated " "in different ways, depending on the type and number of the parameters in the " "call:" msgstr "" -#: ../../library/ctypes.rst:1980 +#: ../../library/ctypes.rst:2018 msgid "" "Returns a foreign function at the specified address which must be an integer." msgstr "" -#: ../../library/ctypes.rst:1987 +#: ../../library/ctypes.rst:2025 msgid "" "Create a C callable function (a callback function) from a Python *callable*." msgstr "" -#: ../../library/ctypes.rst:1994 +#: ../../library/ctypes.rst:2032 msgid "" "Returns a foreign function exported by a shared library. *func_spec* must be " "a 2-tuple ``(name_or_ordinal, library)``. The first item is the name of the " @@ -3545,7 +3584,7 @@ msgid "" "small integer. The second item is the shared library instance." msgstr "" -#: ../../library/ctypes.rst:2004 +#: ../../library/ctypes.rst:2042 msgid "" "Returns a foreign function that will call a COM method. *vtbl_index* is the " "index into the virtual function table, a small non-negative integer. *name* " @@ -3553,86 +3592,86 @@ msgid "" "identifier which is used in extended error reporting." msgstr "" -#: ../../library/ctypes.rst:2009 +#: ../../library/ctypes.rst:2047 msgid "" "If *iid* is not specified, an :exc:`OSError` is raised if the COM method " "call fails. If *iid* is specified, a :exc:`~ctypes.COMError` is raised " "instead." msgstr "" -#: ../../library/ctypes.rst:2013 +#: ../../library/ctypes.rst:2051 msgid "" "COM methods use a special calling convention: They require a pointer to the " "COM interface as first argument, in addition to those parameters that are " "specified in the :attr:`!argtypes` tuple." msgstr "" -#: ../../library/ctypes.rst:2020 +#: ../../library/ctypes.rst:2058 msgid "" "The optional *paramflags* parameter creates foreign function wrappers with " "much more functionality than the features described above." msgstr "" -#: ../../library/ctypes.rst:2023 +#: ../../library/ctypes.rst:2061 msgid "" "*paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr." "argtypes`." msgstr "" -#: ../../library/ctypes.rst:2025 +#: ../../library/ctypes.rst:2063 msgid "" "Each item in this tuple contains further information about a parameter, it " "must be a tuple containing one, two, or three items." msgstr "" -#: ../../library/ctypes.rst:2028 +#: ../../library/ctypes.rst:2066 msgid "" "The first item is an integer containing a combination of direction flags for " "the parameter:" msgstr "" -#: ../../library/ctypes.rst:2031 +#: ../../library/ctypes.rst:2069 msgid "1" msgstr "1" -#: ../../library/ctypes.rst:2032 +#: ../../library/ctypes.rst:2070 msgid "Specifies an input parameter to the function." msgstr "" -#: ../../library/ctypes.rst:2034 +#: ../../library/ctypes.rst:2072 msgid "2" msgstr "2" -#: ../../library/ctypes.rst:2035 +#: ../../library/ctypes.rst:2073 msgid "Output parameter. The foreign function fills in a value." msgstr "" -#: ../../library/ctypes.rst:2037 +#: ../../library/ctypes.rst:2075 msgid "4" msgstr "4" -#: ../../library/ctypes.rst:2038 +#: ../../library/ctypes.rst:2076 msgid "Input parameter which defaults to the integer zero." msgstr "" -#: ../../library/ctypes.rst:2040 +#: ../../library/ctypes.rst:2078 msgid "" "The optional second item is the parameter name as string. If this is " "specified, the foreign function can be called with named parameters." msgstr "" -#: ../../library/ctypes.rst:2043 +#: ../../library/ctypes.rst:2081 msgid "The optional third item is the default value for this parameter." msgstr "" -#: ../../library/ctypes.rst:2046 +#: ../../library/ctypes.rst:2084 msgid "" "The following example demonstrates how to wrap the Windows ``MessageBoxW`` " "function so that it supports default parameters and named arguments. The C " "declaration from the windows header file is this::" msgstr "" -#: ../../library/ctypes.rst:2050 +#: ../../library/ctypes.rst:2088 msgid "" "WINUSERAPI int WINAPI\n" "MessageBoxW(\n" @@ -3648,11 +3687,11 @@ msgstr "" " LPCWSTR lpCaption,\n" " UINT uType);" -#: ../../library/ctypes.rst:2057 ../../library/ctypes.rst:2080 +#: ../../library/ctypes.rst:2095 ../../library/ctypes.rst:2118 msgid "Here is the wrapping with :mod:`!ctypes`::" msgstr "" -#: ../../library/ctypes.rst:2059 +#: ../../library/ctypes.rst:2097 msgid "" ">>> from ctypes import c_int, WINFUNCTYPE, windll\n" ">>> from ctypes.wintypes import HWND, LPCWSTR, UINT\n" @@ -3668,11 +3707,11 @@ msgstr "" "\"Hello from ctypes\"), (1, \"flags\", 0)\n" ">>> MessageBox = prototype((\"MessageBoxW\", windll.user32), paramflags)" -#: ../../library/ctypes.rst:2065 +#: ../../library/ctypes.rst:2103 msgid "The ``MessageBox`` foreign function can now be called in these ways::" msgstr "" -#: ../../library/ctypes.rst:2067 +#: ../../library/ctypes.rst:2105 msgid "" ">>> MessageBox()\n" ">>> MessageBox(text=\"Spam, spam, spam\")\n" @@ -3682,7 +3721,7 @@ msgstr "" ">>> MessageBox(text=\"Spam, spam, spam\")\n" ">>> MessageBox(flags=2, text=\"foo bar\")" -#: ../../library/ctypes.rst:2071 +#: ../../library/ctypes.rst:2109 msgid "" "A second example demonstrates output parameters. The win32 " "``GetWindowRect`` function retrieves the dimensions of a specified window by " @@ -3690,7 +3729,7 @@ msgid "" "the C declaration::" msgstr "" -#: ../../library/ctypes.rst:2075 +#: ../../library/ctypes.rst:2113 msgid "" "WINUSERAPI BOOL WINAPI\n" "GetWindowRect(\n" @@ -3702,7 +3741,7 @@ msgstr "" " HWND hWnd,\n" " LPRECT lpRect);" -#: ../../library/ctypes.rst:2082 +#: ../../library/ctypes.rst:2120 msgid "" ">>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError\n" ">>> from ctypes.wintypes import BOOL, HWND, RECT\n" @@ -3720,7 +3759,7 @@ msgstr "" "paramflags)\n" ">>>" -#: ../../library/ctypes.rst:2089 +#: ../../library/ctypes.rst:2127 msgid "" "Functions with output parameters will automatically return the output " "parameter value if there is a single one, or a tuple containing the output " @@ -3728,7 +3767,7 @@ msgid "" "now returns a RECT instance, when called." msgstr "" -#: ../../library/ctypes.rst:2094 +#: ../../library/ctypes.rst:2132 msgid "" "Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` " "protocol to do further output processing and error checking. The win32 " @@ -3737,7 +3776,7 @@ msgid "" "exception when the api call failed::" msgstr "" -#: ../../library/ctypes.rst:2099 +#: ../../library/ctypes.rst:2137 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3755,7 +3794,7 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:2107 +#: ../../library/ctypes.rst:2145 msgid "" "If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it " "receives unchanged, :mod:`!ctypes` continues the normal processing it does " @@ -3765,7 +3804,7 @@ msgid "" "take place::" msgstr "" -#: ../../library/ctypes.rst:2113 +#: ../../library/ctypes.rst:2151 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3785,17 +3824,17 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:2126 +#: ../../library/ctypes.rst:2164 msgid "Utility functions" msgstr "" -#: ../../library/ctypes.rst:2130 +#: ../../library/ctypes.rst:2168 msgid "" "Returns the address of the memory buffer as integer. *obj* must be an " "instance of a ctypes type." msgstr "" -#: ../../library/ctypes.rst:2133 +#: ../../library/ctypes.rst:2171 msgid "" "Raises an :ref:`auditing event ` ``ctypes.addressof`` with " "argument ``obj``." @@ -3803,46 +3842,46 @@ msgstr "" "引發一個附帶引數 ``obj`` 的\\ :ref:`稽核事件 ` ``ctypes." "addressof``。" -#: ../../library/ctypes.rst:2138 +#: ../../library/ctypes.rst:2176 msgid "" "Returns the alignment requirements of a ctypes type. *obj_or_type* must be a " "ctypes type or instance." msgstr "" -#: ../../library/ctypes.rst:2144 +#: ../../library/ctypes.rst:2182 msgid "" "Returns a light-weight pointer to *obj*, which must be an instance of a " "ctypes type. *offset* defaults to zero, and must be an integer that will be " "added to the internal pointer value." msgstr "" -#: ../../library/ctypes.rst:2148 +#: ../../library/ctypes.rst:2186 msgid "``byref(obj, offset)`` corresponds to this C code::" msgstr "" -#: ../../library/ctypes.rst:2150 +#: ../../library/ctypes.rst:2188 msgid "(((char *)&obj) + offset)" msgstr "(((char *)&obj) + offset)" -#: ../../library/ctypes.rst:2152 +#: ../../library/ctypes.rst:2190 msgid "" "The returned object can only be used as a foreign function call parameter. " "It behaves similar to ``pointer(obj)``, but the construction is a lot faster." msgstr "" -#: ../../library/ctypes.rst:2158 +#: ../../library/ctypes.rst:2196 msgid "" "Copies a COM pointer from *src* to *dst* and returns the Windows specific :c:" "type:`!HRESULT` value." msgstr "" -#: ../../library/ctypes.rst:2161 +#: ../../library/ctypes.rst:2199 msgid "" "If *src* is not ``NULL``, its ``AddRef`` method is called, incrementing the " "reference count." msgstr "" -#: ../../library/ctypes.rst:2164 +#: ../../library/ctypes.rst:2202 msgid "" "In contrast, the reference count of *dst* will not be decremented before " "assigning the new value. Unless *dst* is ``NULL``, the caller is responsible " @@ -3850,7 +3889,7 @@ msgid "" "necessary." msgstr "" -#: ../../library/ctypes.rst:2176 +#: ../../library/ctypes.rst:2214 msgid "" "This function is similar to the cast operator in C. It returns a new " "instance of *type* which points to the same memory block as *obj*. *type* " @@ -3858,47 +3897,47 @@ msgid "" "as a pointer." msgstr "" -#: ../../library/ctypes.rst:2185 +#: ../../library/ctypes.rst:2223 msgid "" "This function creates a mutable character buffer. The returned object is a " "ctypes array of :class:`c_char`." msgstr "" -#: ../../library/ctypes.rst:2188 +#: ../../library/ctypes.rst:2226 msgid "" "If *size* is given (and not ``None``), it must be an :class:`int`. It " "specifies the size of the returned array." msgstr "" -#: ../../library/ctypes.rst:2191 +#: ../../library/ctypes.rst:2229 msgid "" "If the *init* argument is given, it must be :class:`bytes`. It is used to " "initialize the array items. Bytes not initialized this way are set to zero " "(NUL)." msgstr "" -#: ../../library/ctypes.rst:2195 +#: ../../library/ctypes.rst:2233 msgid "" "If *size* is not given (or if it is ``None``), the buffer is made one " "element larger than *init*, effectively adding a NUL terminator." msgstr "" -#: ../../library/ctypes.rst:2198 +#: ../../library/ctypes.rst:2236 msgid "" "If both arguments are given, *size* must not be less than ``len(init)``." msgstr "如果兩個引數皆有提供,*size* 不得小於 ``len(init)``。" -#: ../../library/ctypes.rst:2202 +#: ../../library/ctypes.rst:2240 msgid "" "If *size* is equal to ``len(init)``, a NUL terminator is not added. Do not " "treat such a buffer as a C string." msgstr "" -#: ../../library/ctypes.rst:2205 +#: ../../library/ctypes.rst:2243 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/ctypes.rst:2207 +#: ../../library/ctypes.rst:2245 msgid "" ">>> bytes(create_string_buffer(2))\n" "b'\\x00\\x00'\n" @@ -3926,7 +3965,7 @@ msgstr "" " ...\n" "ValueError: byte string too long" -#: ../../library/ctypes.rst:2220 +#: ../../library/ctypes.rst:2258 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_string_buffer`` " "with arguments ``init``, ``size``." @@ -3934,19 +3973,19 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_string_buffer``。" -#: ../../library/ctypes.rst:2226 +#: ../../library/ctypes.rst:2264 msgid "" "This function creates a mutable unicode character buffer. The returned " "object is a ctypes array of :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:2229 +#: ../../library/ctypes.rst:2267 msgid "" "The function takes the same arguments as :func:`~create_string_buffer` " "except *init* must be a string and *size* counts :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:2232 +#: ../../library/ctypes.rst:2270 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_unicode_buffer`` " "with arguments ``init``, ``size``." @@ -3954,47 +3993,21 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_unicode_buffer``。" -#: ../../library/ctypes.rst:2237 +#: ../../library/ctypes.rst:2275 msgid "" "This function is a hook which allows implementing in-process COM servers " "with ctypes. It is called from the DllCanUnloadNow function that the " "_ctypes extension dll exports." msgstr "" -#: ../../library/ctypes.rst:2246 +#: ../../library/ctypes.rst:2284 msgid "" "This function is a hook which allows implementing in-process COM servers " "with ctypes. It is called from the DllGetClassObject function that the " "``_ctypes`` extension dll exports." msgstr "" -#: ../../library/ctypes.rst:2256 -msgid "" -"Try to find a library and return a pathname. *name* is the library name " -"without any prefix like ``lib``, suffix like ``.so``, ``.dylib`` or version " -"number (this is the form used for the posix linker option :option:`!-l`). " -"If no library can be found, returns ``None``." -msgstr "" - -#: ../../library/ctypes.rst:2263 -msgid "See :ref:`ctypes-finding-shared-libraries` for complete documentation." -msgstr "" - -#: ../../library/ctypes.rst:2269 -msgid "" -"Returns the filename of the VC runtime library used by Python, and by the " -"extension modules. If the name of the library cannot be determined, " -"``None`` is returned." -msgstr "" - -#: ../../library/ctypes.rst:2273 -msgid "" -"If you need to free memory, for example, allocated by an extension module " -"with a call to the ``free(void *)``, it is important that you use the " -"function in the same library that allocated the memory." -msgstr "" - -#: ../../library/ctypes.rst:2283 +#: ../../library/ctypes.rst:2294 msgid "" "Try to provide a list of paths of the shared libraries loaded into the " "current process. These paths are not normalized or processed in any way. " @@ -4002,74 +4015,74 @@ msgid "" "The exact functionality is system dependent." msgstr "" -#: ../../library/ctypes.rst:2288 +#: ../../library/ctypes.rst:2299 msgid "" "On most platforms, the first element of the list represents the current " "executable file. It may be an empty string." msgstr "" -#: ../../library/ctypes.rst:2296 +#: ../../library/ctypes.rst:2307 msgid "" "Returns a textual description of the error code *code*. If no error code is " "specified, the last error code is used by calling the Windows API function :" "func:`GetLastError`." msgstr "" -#: ../../library/ctypes.rst:2305 +#: ../../library/ctypes.rst:2316 msgid "" "Returns the last error code set by Windows in the calling thread. This " "function calls the Windows ``GetLastError()`` function directly, it does not " "return the ctypes-private copy of the error code." msgstr "" -#: ../../library/ctypes.rst:2314 +#: ../../library/ctypes.rst:2325 msgid "" "Returns the current value of the ctypes-private copy of the system :data:" "`errno` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2317 +#: ../../library/ctypes.rst:2328 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_errno`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_errno``。" -#: ../../library/ctypes.rst:2321 +#: ../../library/ctypes.rst:2332 msgid "" "Returns the current value of the ctypes-private copy of the system :data:`!" "LastError` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2326 +#: ../../library/ctypes.rst:2337 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_last_error`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_last_error``。" -#: ../../library/ctypes.rst:2331 +#: ../../library/ctypes.rst:2342 msgid "" "Same as the standard C memmove library function: copies *count* bytes from " "*src* to *dst*. *dst* and *src* must be integers or ctypes instances that " "can be converted to pointers." msgstr "" -#: ../../library/ctypes.rst:2338 +#: ../../library/ctypes.rst:2349 msgid "" "Same as the standard C memset library function: fills the memory block at " "address *dst* with *count* bytes of value *c*. *dst* must be an integer " "specifying an address, or a ctypes instance." msgstr "" -#: ../../library/ctypes.rst:2345 +#: ../../library/ctypes.rst:2356 msgid "" "Create or return a ctypes pointer type. Pointer types are cached and reused " "internally, so calling this function repeatedly is cheap. *type* must be a " "ctypes type." msgstr "" -#: ../../library/ctypes.rst:2351 +#: ../../library/ctypes.rst:2362 msgid "" "The resulting pointer type is cached in the ``__pointer_type__`` attribute " "of *type*. It is possible to set this attribute before the first call to " @@ -4078,19 +4091,19 @@ msgid "" "relying on implementation details that may change in future Python versions." msgstr "" -#: ../../library/ctypes.rst:2362 +#: ../../library/ctypes.rst:2373 msgid "" "Create a new pointer instance, pointing to *obj*. The returned object is of " "the type ``POINTER(type(obj))``." msgstr "" -#: ../../library/ctypes.rst:2365 +#: ../../library/ctypes.rst:2376 msgid "" "Note: If you just want to pass a pointer to an object to a foreign function " "call, you should use ``byref(obj)`` which is much faster." msgstr "" -#: ../../library/ctypes.rst:2371 +#: ../../library/ctypes.rst:2382 msgid "" "This function resizes the internal memory buffer of *obj*, which must be an " "instance of a ctypes type. It is not possible to make the buffer smaller " @@ -4098,13 +4111,13 @@ msgid "" "but it is possible to enlarge the buffer." msgstr "" -#: ../../library/ctypes.rst:2379 +#: ../../library/ctypes.rst:2390 msgid "" "Set the current value of the ctypes-private copy of the system :data:`errno` " "variable in the calling thread to *value* and return the previous value." msgstr "" -#: ../../library/ctypes.rst:2382 +#: ../../library/ctypes.rst:2393 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_errno`` with " "argument ``errno``." @@ -4112,14 +4125,14 @@ msgstr "" "引發一個附帶引數 ``errno`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_errno``。" -#: ../../library/ctypes.rst:2387 +#: ../../library/ctypes.rst:2398 msgid "" "Sets the current value of the ctypes-private copy of the system :data:`!" "LastError` variable in the calling thread to *value* and return the previous " "value." msgstr "" -#: ../../library/ctypes.rst:2393 +#: ../../library/ctypes.rst:2404 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_last_error`` with " "argument ``error``." @@ -4127,19 +4140,19 @@ msgstr "" "引發一個附帶引數 ``error`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_last_error``。" -#: ../../library/ctypes.rst:2398 +#: ../../library/ctypes.rst:2409 msgid "" "Returns the size in bytes of a ctypes type or instance memory buffer. Does " "the same as the C ``sizeof`` operator." msgstr "" -#: ../../library/ctypes.rst:2404 +#: ../../library/ctypes.rst:2415 msgid "" "Return the byte string at *void \\*ptr*. If *size* is specified, it is used " "as size, otherwise the string is assumed to be zero-terminated." msgstr "" -#: ../../library/ctypes.rst:2408 +#: ../../library/ctypes.rst:2419 msgid "" "Raises an :ref:`auditing event ` ``ctypes.string_at`` with " "arguments ``ptr``, ``size``." @@ -4147,7 +4160,7 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "string_at``。" -#: ../../library/ctypes.rst:2413 +#: ../../library/ctypes.rst:2424 msgid "" "Creates an instance of :exc:`OSError`. If *code* is not specified, :func:" "`GetLastError` is called to determine the error code. If *descr* is not " @@ -4155,20 +4168,20 @@ msgid "" "error." msgstr "" -#: ../../library/ctypes.rst:2420 +#: ../../library/ctypes.rst:2431 msgid "" "An instance of :exc:`WindowsError` used to be created, which is now an alias " "of :exc:`OSError`." msgstr "" -#: ../../library/ctypes.rst:2427 +#: ../../library/ctypes.rst:2438 msgid "" "Return the wide-character string at *void \\*ptr*. If *size* is specified, " "it is used as the number of characters of the string, otherwise the string " "is assumed to be zero-terminated." msgstr "" -#: ../../library/ctypes.rst:2432 +#: ../../library/ctypes.rst:2443 msgid "" "Raises an :ref:`auditing event ` ``ctypes.wstring_at`` with " "arguments ``ptr``, ``size``." @@ -4176,20 +4189,20 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "wstring_at``。" -#: ../../library/ctypes.rst:2437 +#: ../../library/ctypes.rst:2448 msgid "" "Return a :class:`memoryview` object of length *size* that references memory " "starting at *void \\*ptr*." msgstr "" -#: ../../library/ctypes.rst:2440 +#: ../../library/ctypes.rst:2451 msgid "" "If *readonly* is true, the returned :class:`!memoryview` object can not be " "used to modify the underlying memory. (Changes made by other means will " "still be reflected in the returned object.)" msgstr "" -#: ../../library/ctypes.rst:2445 +#: ../../library/ctypes.rst:2456 msgid "" "This function is similar to :func:`string_at` with the key difference of not " "making a copy of the specified memory. It is a semantically equivalent (but " @@ -4199,7 +4212,7 @@ msgid "" "`~ctypes.byref` object.)" msgstr "" -#: ../../library/ctypes.rst:2452 +#: ../../library/ctypes.rst:2463 msgid "" "Raises an :ref:`auditing event ` ``ctypes.memoryview_at`` with " "arguments ``address``, ``size``, ``readonly``." @@ -4207,11 +4220,11 @@ msgstr "" "引發一個附帶引數 ``address``、``size`` 與 ``readonly`` 的\\ :ref:`稽核事件 " "` ``ctypes.memoryview_at``。" -#: ../../library/ctypes.rst:2460 +#: ../../library/ctypes.rst:2471 msgid "Data types" msgstr "" -#: ../../library/ctypes.rst:2465 +#: ../../library/ctypes.rst:2476 msgid "" "This non-public class is the common base class of all ctypes data types. " "Among other things, all ctypes type instances contain a memory block that " @@ -4221,13 +4234,13 @@ msgid "" "alive in case the memory block contains pointers." msgstr "" -#: ../../library/ctypes.rst:2472 +#: ../../library/ctypes.rst:2483 msgid "" "Common methods of ctypes data types, these are all class methods (to be " "exact, they are methods of the :term:`metaclass`):" msgstr "" -#: ../../library/ctypes.rst:2477 +#: ../../library/ctypes.rst:2488 msgid "" "This method returns a ctypes instance that shares the buffer of the *source* " "object. The *source* object must support the writeable buffer interface. " @@ -4236,7 +4249,7 @@ msgid "" "exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2483 ../../library/ctypes.rst:2493 +#: ../../library/ctypes.rst:2494 ../../library/ctypes.rst:2504 msgid "" "Raises an :ref:`auditing event ` ``ctypes.cdata/buffer`` with " "arguments ``pointer``, ``size``, ``offset``." @@ -4244,7 +4257,7 @@ msgstr "" "引發一個附帶引數 ``pointer``、``size``、``offset`` 的\\ :ref:`稽核事件 " "` ``ctypes.cdata/buffer``。" -#: ../../library/ctypes.rst:2487 +#: ../../library/ctypes.rst:2498 msgid "" "This method creates a ctypes instance, copying the buffer from the *source* " "object buffer which must be readable. The optional *offset* parameter " @@ -4252,19 +4265,19 @@ msgid "" "If the source buffer is not large enough a :exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2497 +#: ../../library/ctypes.rst:2508 msgid "" "This method returns a ctypes type instance using the memory specified by " "*address* which must be an integer." msgstr "" -#: ../../library/ctypes.rst:2500 ../../library/ctypes.rst:2502 +#: ../../library/ctypes.rst:2511 ../../library/ctypes.rst:2513 msgid "" "This method, and others that indirectly call this method, raises an :ref:" "`auditing event ` ``ctypes.cdata`` with argument ``address``." msgstr "" -#: ../../library/ctypes.rst:2508 +#: ../../library/ctypes.rst:2519 msgid "" "This method adapts *obj* to a ctypes type. It is called with the actual " "object used in a foreign function call when the type is present in the " @@ -4272,36 +4285,36 @@ msgid "" "object that can be used as a function call parameter." msgstr "" -#: ../../library/ctypes.rst:2513 +#: ../../library/ctypes.rst:2524 msgid "" "All ctypes data types have a default implementation of this classmethod that " "normally returns *obj* if that is an instance of the type. Some types " "accept other objects as well." msgstr "" -#: ../../library/ctypes.rst:2519 +#: ../../library/ctypes.rst:2530 msgid "" "This method returns a ctypes type instance exported by a shared library. " "*name* is the name of the symbol that exports the data, *library* is the " "loaded shared library." msgstr "" -#: ../../library/ctypes.rst:2523 +#: ../../library/ctypes.rst:2534 msgid "Common class variables of ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2527 +#: ../../library/ctypes.rst:2538 msgid "" "The pointer type that was created by calling :func:`POINTER` for " "corresponding ctypes data type. If a pointer type was not yet created, the " "attribute is missing." msgstr "" -#: ../../library/ctypes.rst:2533 +#: ../../library/ctypes.rst:2544 msgid "Common instance variables of ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2537 +#: ../../library/ctypes.rst:2548 msgid "" "Sometimes ctypes data instances do not own the memory block they contain, " "instead they share part of the memory block of a base object. The :attr:" @@ -4309,13 +4322,13 @@ msgid "" "block." msgstr "" -#: ../../library/ctypes.rst:2544 +#: ../../library/ctypes.rst:2555 msgid "" "This read-only variable is true when the ctypes data instance has allocated " "the memory block itself, false otherwise." msgstr "" -#: ../../library/ctypes.rst:2549 +#: ../../library/ctypes.rst:2560 msgid "" "This member is either ``None`` or a dictionary containing Python objects " "that need to be kept alive so that the memory block contents is kept valid. " @@ -4323,7 +4336,7 @@ msgid "" "dictionary." msgstr "" -#: ../../library/ctypes.rst:2562 +#: ../../library/ctypes.rst:2573 msgid "" "This non-public class is the base class of all fundamental ctypes data " "types. It is mentioned here because it contains the common attributes of the " @@ -4332,11 +4345,11 @@ msgid "" "types that are not and do not contain pointers can now be pickled." msgstr "" -#: ../../library/ctypes.rst:2568 +#: ../../library/ctypes.rst:2579 msgid "Instances have a single attribute:" msgstr "" -#: ../../library/ctypes.rst:2572 +#: ../../library/ctypes.rst:2583 msgid "" "This attribute contains the actual value of the instance. For integer and " "pointer types, it is an integer, for character types, it is a single " @@ -4344,7 +4357,7 @@ msgid "" "bytes object or string." msgstr "" -#: ../../library/ctypes.rst:2577 +#: ../../library/ctypes.rst:2588 msgid "" "When the ``value`` attribute is retrieved from a ctypes instance, usually a " "new object is returned each time. :mod:`!ctypes` does *not* implement " @@ -4352,17 +4365,17 @@ msgid "" "true for all other ctypes object instances." msgstr "" -#: ../../library/ctypes.rst:2582 +#: ../../library/ctypes.rst:2593 msgid "Each subclass has a class attribute:" msgstr "" -#: ../../library/ctypes.rst:2586 +#: ../../library/ctypes.rst:2597 msgid "" "Class attribute that contains an internal type code, as a single-character " "string. See :ref:`ctypes-fundamental-data-types` for a summary." msgstr "" -#: ../../library/ctypes.rst:2590 +#: ../../library/ctypes.rst:2601 msgid "" "Types marked \\* in the summary may be (or always are) aliases of a " "different :class:`_SimpleCData` subclass, and will not necessarily use the " @@ -4373,7 +4386,7 @@ msgid "" "code will be unused." msgstr "" -#: ../../library/ctypes.rst:2601 +#: ../../library/ctypes.rst:2612 msgid "" "The :mod:`array` and :ref:`struct ` modules, as well as " "third-party modules like `numpy >> class Color(Structure):\n" "... _fields_ = (\n" @@ -4993,100 +5006,100 @@ msgstr "" ">>> Color.blinking.bit_offset\n" "1" -#: ../../library/ctypes.rst:3103 +#: ../../library/ctypes.rst:3114 msgid "All attributes are read-only." msgstr "" -#: ../../library/ctypes.rst:3105 +#: ../../library/ctypes.rst:3116 msgid "" ":class:`!CField` objects are created via :attr:`~Structure._fields_`; do not " "instantiate the class directly." msgstr "" -#: ../../library/ctypes.rst:3110 +#: ../../library/ctypes.rst:3121 msgid "" "Previously, descriptors only had ``offset`` and ``size`` attributes and a " "readable string representation; the :class:`!CField` class was not available " "directly." msgstr "" -#: ../../library/ctypes.rst:3116 +#: ../../library/ctypes.rst:3127 msgid "Name of the field, as a string." msgstr "" -#: ../../library/ctypes.rst:3120 +#: ../../library/ctypes.rst:3131 msgid "Type of the field, as a :ref:`ctypes class `." msgstr "" -#: ../../library/ctypes.rst:3125 +#: ../../library/ctypes.rst:3136 msgid "Offset of the field, in bytes." msgstr "" -#: ../../library/ctypes.rst:3127 +#: ../../library/ctypes.rst:3138 msgid "" "For bitfields, this is the offset of the underlying byte-aligned *storage " "unit*; see :attr:`~CField.bit_offset`." msgstr "" -#: ../../library/ctypes.rst:3132 +#: ../../library/ctypes.rst:3143 msgid "Size of the field, in bytes." msgstr "" -#: ../../library/ctypes.rst:3134 +#: ../../library/ctypes.rst:3145 msgid "" "For bitfields, this is the size of the underlying *storage unit*. Typically, " "it has the same size as the bitfield's type." msgstr "" -#: ../../library/ctypes.rst:3139 +#: ../../library/ctypes.rst:3150 msgid "For non-bitfields, equivalent to :attr:`~CField.byte_size`." msgstr "" -#: ../../library/ctypes.rst:3141 +#: ../../library/ctypes.rst:3152 msgid "" "For bitfields, this contains a backwards-compatible bit-packed value that " "combines :attr:`~CField.bit_size` and :attr:`~CField.bit_offset`. Prefer " "using the explicit attributes instead." msgstr "" -#: ../../library/ctypes.rst:3148 +#: ../../library/ctypes.rst:3159 msgid "True if this is a bitfield." msgstr "" -#: ../../library/ctypes.rst:3153 +#: ../../library/ctypes.rst:3164 msgid "" "The location of a bitfield within its *storage unit*, that is, within :attr:" "`~CField.byte_size` bytes of memory starting at :attr:`~CField.byte_offset`." msgstr "" -#: ../../library/ctypes.rst:3157 +#: ../../library/ctypes.rst:3168 msgid "" "To get the field's value, read the storage unit as an integer, :ref:`shift " "left ` by :attr:`!bit_offset` and take the :attr:`!bit_size` least " "significant bits." msgstr "" -#: ../../library/ctypes.rst:3161 +#: ../../library/ctypes.rst:3172 msgid "" "For non-bitfields, :attr:`!bit_offset` is zero and :attr:`!bit_size` is " "equal to ``byte_size * 8``." msgstr "" -#: ../../library/ctypes.rst:3166 +#: ../../library/ctypes.rst:3177 msgid "" "True if this field is anonymous, that is, it contains nested sub-fields that " "should be merged into a containing structure or union." msgstr "" -#: ../../library/ctypes.rst:3173 +#: ../../library/ctypes.rst:3184 msgid "Arrays and pointers" msgstr "" -#: ../../library/ctypes.rst:3177 +#: ../../library/ctypes.rst:3188 msgid "Abstract base class for arrays." msgstr "" -#: ../../library/ctypes.rst:3179 +#: ../../library/ctypes.rst:3190 msgid "" "The recommended way to create concrete array types is by multiplying any :" "mod:`!ctypes` data type with a non-negative integer. Alternatively, you can " @@ -5096,48 +5109,48 @@ msgid "" "an :class:`Array`." msgstr "" -#: ../../library/ctypes.rst:3186 +#: ../../library/ctypes.rst:3197 msgid "Arrays are :ref:`generic ` over the type of their elements." msgstr "" -#: ../../library/ctypes.rst:3191 +#: ../../library/ctypes.rst:3202 msgid "" "A positive integer specifying the number of elements in the array. Out-of-" "range subscripts result in an :exc:`IndexError`. Will be returned by :func:" "`len`." msgstr "" -#: ../../library/ctypes.rst:3198 +#: ../../library/ctypes.rst:3209 msgid "Specifies the type of each element in the array." msgstr "" -#: ../../library/ctypes.rst:3201 +#: ../../library/ctypes.rst:3212 msgid "" "Array subclass constructors accept positional arguments, used to initialize " "the elements in order." msgstr "" -#: ../../library/ctypes.rst:3206 +#: ../../library/ctypes.rst:3217 msgid "" "Create an array. Equivalent to ``type * length``, where *type* is a :mod:`!" "ctypes` data type and *length* an integer." msgstr "" -#: ../../library/ctypes.rst:3210 +#: ../../library/ctypes.rst:3221 msgid "In favor of multiplication." msgstr "" -#: ../../library/ctypes.rst:3216 +#: ../../library/ctypes.rst:3227 msgid "Private, abstract base class for pointers." msgstr "" -#: ../../library/ctypes.rst:3218 +#: ../../library/ctypes.rst:3229 msgid "" "Concrete pointer types are created by calling :func:`POINTER` with the type " "that will be pointed to; this is done automatically by :func:`pointer`." msgstr "" -#: ../../library/ctypes.rst:3222 +#: ../../library/ctypes.rst:3233 msgid "" "If a pointer points to an array, its elements can be read and written using " "standard subscript and slice accesses. Pointer objects have no size, so :" @@ -5146,43 +5159,43 @@ msgid "" "probably crash with an access violation (if you're lucky)." msgstr "" -#: ../../library/ctypes.rst:3232 +#: ../../library/ctypes.rst:3243 msgid "Specifies the type pointed to." msgstr "" -#: ../../library/ctypes.rst:3236 +#: ../../library/ctypes.rst:3247 msgid "" "Returns the object to which to pointer points. Assigning to this attribute " "changes the pointer to point to the assigned object." msgstr "" -#: ../../library/ctypes.rst:3243 +#: ../../library/ctypes.rst:3254 msgid "Exceptions" msgstr "" -#: ../../library/ctypes.rst:3247 +#: ../../library/ctypes.rst:3258 msgid "" "This exception is raised when a foreign function call cannot convert one of " "the passed arguments." msgstr "" -#: ../../library/ctypes.rst:3253 +#: ../../library/ctypes.rst:3264 msgid "This exception is raised when a COM method call failed." msgstr "" -#: ../../library/ctypes.rst:3257 +#: ../../library/ctypes.rst:3268 msgid "The integer value representing the error code." msgstr "" -#: ../../library/ctypes.rst:3261 +#: ../../library/ctypes.rst:3272 msgid "The error message." msgstr "" -#: ../../library/ctypes.rst:3265 +#: ../../library/ctypes.rst:3276 msgid "The 5-tuple ``(descr, source, helpfile, helpcontext, progid)``." msgstr "" -#: ../../library/ctypes.rst:3267 +#: ../../library/ctypes.rst:3278 msgid "" "*descr* is the textual description. *source* is the language-dependent " "``ProgID`` for the class or application that raised the error. *helpfile* " diff --git a/library/curses.ascii.po b/library/curses.ascii.po index 62a5aa98c91..899fbda0cc3 100644 --- a/library/curses.ascii.po +++ b/library/curses.ascii.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-19 00:50+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,296 +21,296 @@ msgstr "" msgid ":mod:`!curses.ascii` --- Utilities for ASCII characters" msgstr ":mod:`!curses.ascii` --- ASCII 字元的工具程式" -#: ../../library/curses.ascii.rst:10 +#: ../../library/curses.ascii.rst:7 msgid "**Source code:** :source:`Lib/curses/ascii.py`" msgstr "**原始碼:**\\ :source:`Lib/curses/ascii.py`" -#: ../../library/curses.ascii.rst:14 +#: ../../library/curses.ascii.rst:11 msgid "" "The :mod:`!curses.ascii` module supplies name constants for ASCII characters " "and functions to test membership in various ASCII character classes. The " "constants supplied are names for control characters as follows:" msgstr "" -#: ../../library/curses.ascii.rst:19 +#: ../../library/curses.ascii.rst:16 msgid "Name" msgstr "名稱" -#: ../../library/curses.ascii.rst:19 +#: ../../library/curses.ascii.rst:16 msgid "Meaning" msgstr "含義" -#: ../../library/curses.ascii.rst:23 +#: ../../library/curses.ascii.rst:20 msgid "Start of heading, console interrupt" msgstr "" -#: ../../library/curses.ascii.rst:25 +#: ../../library/curses.ascii.rst:22 msgid "Start of text" msgstr "" -#: ../../library/curses.ascii.rst:27 +#: ../../library/curses.ascii.rst:24 msgid "End of text" msgstr "" -#: ../../library/curses.ascii.rst:29 +#: ../../library/curses.ascii.rst:26 msgid "End of transmission" msgstr "" -#: ../../library/curses.ascii.rst:31 +#: ../../library/curses.ascii.rst:28 msgid "Enquiry, goes with :const:`ACK` flow control" msgstr "" -#: ../../library/curses.ascii.rst:33 +#: ../../library/curses.ascii.rst:30 msgid "Acknowledgement" msgstr "" -#: ../../library/curses.ascii.rst:35 +#: ../../library/curses.ascii.rst:32 msgid "Bell" msgstr "" -#: ../../library/curses.ascii.rst:37 +#: ../../library/curses.ascii.rst:34 msgid "Backspace" msgstr "" -#: ../../library/curses.ascii.rst:39 +#: ../../library/curses.ascii.rst:36 msgid "Tab" msgstr "" -#: ../../library/curses.ascii.rst:41 +#: ../../library/curses.ascii.rst:38 msgid "Alias for :const:`TAB`: \"Horizontal tab\"" msgstr "" -#: ../../library/curses.ascii.rst:43 +#: ../../library/curses.ascii.rst:40 msgid "Line feed" msgstr "" -#: ../../library/curses.ascii.rst:45 +#: ../../library/curses.ascii.rst:42 msgid "Alias for :const:`LF`: \"New line\"" msgstr "" -#: ../../library/curses.ascii.rst:47 +#: ../../library/curses.ascii.rst:44 msgid "Vertical tab" msgstr "" -#: ../../library/curses.ascii.rst:49 +#: ../../library/curses.ascii.rst:46 msgid "Form feed" msgstr "" -#: ../../library/curses.ascii.rst:51 +#: ../../library/curses.ascii.rst:48 msgid "Carriage return" msgstr "" -#: ../../library/curses.ascii.rst:53 +#: ../../library/curses.ascii.rst:50 msgid "Shift-out, begin alternate character set" msgstr "" -#: ../../library/curses.ascii.rst:55 +#: ../../library/curses.ascii.rst:52 msgid "Shift-in, resume default character set" msgstr "" -#: ../../library/curses.ascii.rst:57 +#: ../../library/curses.ascii.rst:54 msgid "Data-link escape" msgstr "" -#: ../../library/curses.ascii.rst:59 +#: ../../library/curses.ascii.rst:56 msgid "XON, for flow control" msgstr "" -#: ../../library/curses.ascii.rst:61 +#: ../../library/curses.ascii.rst:58 msgid "Device control 2, block-mode flow control" msgstr "" -#: ../../library/curses.ascii.rst:63 +#: ../../library/curses.ascii.rst:60 msgid "XOFF, for flow control" msgstr "" -#: ../../library/curses.ascii.rst:65 +#: ../../library/curses.ascii.rst:62 msgid "Device control 4" msgstr "" -#: ../../library/curses.ascii.rst:67 +#: ../../library/curses.ascii.rst:64 msgid "Negative acknowledgement" msgstr "" -#: ../../library/curses.ascii.rst:69 +#: ../../library/curses.ascii.rst:66 msgid "Synchronous idle" msgstr "" -#: ../../library/curses.ascii.rst:71 +#: ../../library/curses.ascii.rst:68 msgid "End transmission block" msgstr "" -#: ../../library/curses.ascii.rst:73 +#: ../../library/curses.ascii.rst:70 msgid "Cancel" msgstr "" -#: ../../library/curses.ascii.rst:75 +#: ../../library/curses.ascii.rst:72 msgid "End of medium" msgstr "" -#: ../../library/curses.ascii.rst:77 +#: ../../library/curses.ascii.rst:74 msgid "Substitute" msgstr "" -#: ../../library/curses.ascii.rst:79 +#: ../../library/curses.ascii.rst:76 msgid "Escape" msgstr "" -#: ../../library/curses.ascii.rst:81 +#: ../../library/curses.ascii.rst:78 msgid "File separator" msgstr "" -#: ../../library/curses.ascii.rst:83 +#: ../../library/curses.ascii.rst:80 msgid "Group separator" msgstr "" -#: ../../library/curses.ascii.rst:85 +#: ../../library/curses.ascii.rst:82 msgid "Record separator, block-mode terminator" msgstr "" -#: ../../library/curses.ascii.rst:87 +#: ../../library/curses.ascii.rst:84 msgid "Unit separator" msgstr "" -#: ../../library/curses.ascii.rst:89 +#: ../../library/curses.ascii.rst:86 msgid "Space" msgstr "" -#: ../../library/curses.ascii.rst:91 +#: ../../library/curses.ascii.rst:88 msgid "Delete" msgstr "" -#: ../../library/curses.ascii.rst:94 +#: ../../library/curses.ascii.rst:91 msgid "" "Note that many of these have little practical significance in modern usage. " "The mnemonics derive from teleprinter conventions that predate digital " "computers." msgstr "" -#: ../../library/curses.ascii.rst:97 +#: ../../library/curses.ascii.rst:94 msgid "" "The module supplies the following functions, patterned on those in the " "standard C library:" msgstr "" -#: ../../library/curses.ascii.rst:103 +#: ../../library/curses.ascii.rst:100 msgid "" "Checks for an ASCII alphanumeric character; it is equivalent to ``isalpha(c) " "or isdigit(c)``." msgstr "" -#: ../../library/curses.ascii.rst:109 +#: ../../library/curses.ascii.rst:106 msgid "" "Checks for an ASCII alphabetic character; it is equivalent to ``isupper(c) " "or islower(c)``." msgstr "" -#: ../../library/curses.ascii.rst:115 +#: ../../library/curses.ascii.rst:112 msgid "Checks for a character value that fits in the 7-bit ASCII set." msgstr "" -#: ../../library/curses.ascii.rst:120 +#: ../../library/curses.ascii.rst:117 msgid "Checks for an ASCII blank character; space or horizontal tab." msgstr "" -#: ../../library/curses.ascii.rst:125 +#: ../../library/curses.ascii.rst:122 msgid "" "Checks for an ASCII control character (in the range 0x00 to 0x1f or 0x7f)." msgstr "" -#: ../../library/curses.ascii.rst:130 +#: ../../library/curses.ascii.rst:127 msgid "" "Checks for an ASCII decimal digit, ``'0'`` through ``'9'``. This is " "equivalent to ``c in string.digits``." msgstr "" -#: ../../library/curses.ascii.rst:136 +#: ../../library/curses.ascii.rst:133 msgid "Checks for any ASCII printable character except space." msgstr "" -#: ../../library/curses.ascii.rst:141 +#: ../../library/curses.ascii.rst:138 msgid "Checks for an ASCII lower-case character." msgstr "" -#: ../../library/curses.ascii.rst:146 +#: ../../library/curses.ascii.rst:143 msgid "Checks for any ASCII printable character including space." msgstr "" -#: ../../library/curses.ascii.rst:151 +#: ../../library/curses.ascii.rst:148 msgid "" "Checks for any ASCII printable character which is not a space or an " "alphanumeric character." msgstr "" -#: ../../library/curses.ascii.rst:157 +#: ../../library/curses.ascii.rst:154 msgid "" "Checks for ASCII white-space characters; space, line feed, carriage return, " "form feed, horizontal tab, vertical tab." msgstr "" -#: ../../library/curses.ascii.rst:163 +#: ../../library/curses.ascii.rst:160 msgid "Checks for an ASCII uppercase letter." msgstr "" -#: ../../library/curses.ascii.rst:168 +#: ../../library/curses.ascii.rst:165 msgid "" "Checks for an ASCII hexadecimal digit. This is equivalent to ``c in string." "hexdigits``." msgstr "" -#: ../../library/curses.ascii.rst:174 +#: ../../library/curses.ascii.rst:171 msgid "" "Checks for an ASCII control character (ordinal values 0 to 31). Unlike :" "func:`iscntrl`, this does not include the delete character (0x7f)." msgstr "" -#: ../../library/curses.ascii.rst:180 +#: ../../library/curses.ascii.rst:177 msgid "Checks for a non-ASCII character (ordinal values 0x80 and above)." msgstr "" -#: ../../library/curses.ascii.rst:182 +#: ../../library/curses.ascii.rst:179 msgid "" "These functions accept either integers or single-character strings; when the " "argument is a string, it is first converted using the built-in function :" "func:`ord`." msgstr "" -#: ../../library/curses.ascii.rst:185 +#: ../../library/curses.ascii.rst:182 msgid "" "Note that all these functions check ordinal bit values derived from the " "character of the string you pass in; they do not actually know anything " "about the host machine's character encoding." msgstr "" -#: ../../library/curses.ascii.rst:189 +#: ../../library/curses.ascii.rst:186 msgid "" "The following two functions take either a single-character string or integer " "byte value; they return a value of the same type." msgstr "" -#: ../../library/curses.ascii.rst:195 +#: ../../library/curses.ascii.rst:192 msgid "Return the ASCII value corresponding to the low 7 bits of *c*." msgstr "" -#: ../../library/curses.ascii.rst:200 +#: ../../library/curses.ascii.rst:197 msgid "" "Return the control character corresponding to the given character (the " "character bit value is bitwise-anded with 0x1f)." msgstr "" -#: ../../library/curses.ascii.rst:206 +#: ../../library/curses.ascii.rst:203 msgid "" "Return the 8-bit character corresponding to the given ASCII character (the " "character bit value is bitwise-ored with 0x80)." msgstr "" -#: ../../library/curses.ascii.rst:209 +#: ../../library/curses.ascii.rst:206 msgid "" "The following function takes either a single-character string or integer " "value; it returns a string." msgstr "" -#: ../../library/curses.ascii.rst:219 +#: ../../library/curses.ascii.rst:216 msgid "" "Return a string representation of the ASCII character *c*. If *c* is " "printable, this string is the character itself. If the character is a " @@ -321,21 +321,21 @@ msgid "" "``'!'`` prepended to the result." msgstr "" -#: ../../library/curses.ascii.rst:229 +#: ../../library/curses.ascii.rst:226 msgid "" "A 33-element string array that contains the ASCII mnemonics for the thirty-" "two ASCII control characters from 0 (NUL) to 0x1f (US), in order, plus the " "mnemonic ``SP`` for the space character." msgstr "" -#: ../../library/curses.ascii.rst:213 +#: ../../library/curses.ascii.rst:210 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../library/curses.ascii.rst:213 +#: ../../library/curses.ascii.rst:210 msgid "in curses module" msgstr "於 curses 模組中" -#: ../../library/curses.ascii.rst:213 +#: ../../library/curses.ascii.rst:210 msgid "! (exclamation)" msgstr "! (驚嘆號)" diff --git a/library/curses.panel.po b/library/curses.panel.po index bb7e80b5de0..7efb3cf4d9f 100644 --- a/library/curses.panel.po +++ b/library/curses.panel.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-16 00:27+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,34 +21,34 @@ msgstr "" msgid ":mod:`!curses.panel` --- A panel stack extension for curses" msgstr ":mod:`!curses.panel` --- curses 的面板堆疊擴充" -#: ../../library/curses.panel.rst:11 +#: ../../library/curses.panel.rst:9 msgid "" "Panels are windows with the added feature of depth, so they can be stacked " "on top of each other, and only the visible portions of each window will be " "displayed. Panels can be added, moved up or down in the stack, and removed." msgstr "" -#: ../../library/curses.panel.rst:19 +#: ../../library/curses.panel.rst:17 msgid "Functions" msgstr "函式" -#: ../../library/curses.panel.rst:21 +#: ../../library/curses.panel.rst:19 msgid "The module :mod:`!curses.panel` defines the following exception:" msgstr ":mod:`!curses.panel` 模組定義了以下例外:" -#: ../../library/curses.panel.rst:26 +#: ../../library/curses.panel.rst:24 msgid "Exception raised when a curses panel library function returns an error." msgstr "" -#: ../../library/curses.panel.rst:29 +#: ../../library/curses.panel.rst:27 msgid "The module :mod:`!curses.panel` defines the following functions:" msgstr ":mod:`!curses.panel` 模組定義了以下函式:" -#: ../../library/curses.panel.rst:34 +#: ../../library/curses.panel.rst:32 msgid "Returns the bottom panel in the panel stack." msgstr "" -#: ../../library/curses.panel.rst:39 +#: ../../library/curses.panel.rst:37 msgid "" "Returns a panel object, associating it with the given window *win* and " "placing the new panel on top of the panel stack. Be aware that you need to " @@ -56,21 +56,21 @@ msgid "" "panel object is garbage collected and removed from the panel stack." msgstr "" -#: ../../library/curses.panel.rst:47 +#: ../../library/curses.panel.rst:45 msgid "Returns the top panel in the panel stack." msgstr "" -#: ../../library/curses.panel.rst:52 +#: ../../library/curses.panel.rst:50 msgid "" "Updates the virtual screen after changes in the panel stack. This does not " "call :func:`curses.doupdate`, so you'll have to do this yourself." msgstr "" -#: ../../library/curses.panel.rst:59 +#: ../../library/curses.panel.rst:57 msgid "Panel objects" msgstr "" -#: ../../library/curses.panel.rst:79 +#: ../../library/curses.panel.rst:77 msgid "" "Panel objects, as returned by :func:`new_panel` above, are windows with a " "stacking order. There's always a window associated with a panel which " @@ -78,62 +78,62 @@ msgid "" "window's depth in the panel stack." msgstr "" -#: ../../library/curses.panel.rst:84 +#: ../../library/curses.panel.rst:82 msgid "Panel objects have the following methods:" msgstr "" -#: ../../library/curses.panel.rst:89 +#: ../../library/curses.panel.rst:87 msgid "Returns the panel above the current panel." msgstr "" -#: ../../library/curses.panel.rst:94 +#: ../../library/curses.panel.rst:92 msgid "Returns the panel below the current panel." msgstr "" -#: ../../library/curses.panel.rst:99 +#: ../../library/curses.panel.rst:97 msgid "Push the panel to the bottom of the stack." msgstr "" -#: ../../library/curses.panel.rst:104 +#: ../../library/curses.panel.rst:102 msgid "" "Returns ``True`` if the panel is hidden (not visible), ``False`` otherwise." msgstr "" -#: ../../library/curses.panel.rst:109 +#: ../../library/curses.panel.rst:107 msgid "" "Hide the panel. This does not delete the object, it just makes the window on " "screen invisible." msgstr "" -#: ../../library/curses.panel.rst:115 +#: ../../library/curses.panel.rst:113 msgid "Move the panel to the screen coordinates ``(y, x)``." msgstr "" -#: ../../library/curses.panel.rst:120 +#: ../../library/curses.panel.rst:118 msgid "Change the window associated with the panel to the window *win*." msgstr "" -#: ../../library/curses.panel.rst:125 +#: ../../library/curses.panel.rst:123 msgid "" "Set the panel's user pointer to *obj*. This is used to associate an " "arbitrary piece of data with the panel, and can be any Python object." msgstr "" -#: ../../library/curses.panel.rst:131 +#: ../../library/curses.panel.rst:129 msgid "" "Display the panel (which might have been hidden), placing it on top of the " "panel stack." msgstr "" -#: ../../library/curses.panel.rst:137 +#: ../../library/curses.panel.rst:135 msgid "Push panel to the top of the stack." msgstr "" -#: ../../library/curses.panel.rst:142 +#: ../../library/curses.panel.rst:140 msgid "" "Returns the user pointer for the panel. This might be any Python object." msgstr "" -#: ../../library/curses.panel.rst:147 +#: ../../library/curses.panel.rst:145 msgid "Returns the window object associated with the panel." msgstr "" diff --git a/library/curses.po b/library/curses.po index c2dddec0605..790d1e7a473 100644 --- a/library/curses.po +++ b/library/curses.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-04 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,17 +21,17 @@ msgstr "" msgid ":mod:`!curses` --- Terminal handling for character-cell displays" msgstr ":mod:`!curses` --- 字元儲存格顯示的終端處理" -#: ../../library/curses.rst:11 +#: ../../library/curses.rst:8 msgid "**Source code:** :source:`Lib/curses`" msgstr "**原始碼:**\\ :source:`Lib/curses`" -#: ../../library/curses.rst:15 +#: ../../library/curses.rst:12 msgid "" "The :mod:`!curses` module provides an interface to the curses library, the " "de-facto standard for portable advanced terminal handling." msgstr "" -#: ../../library/curses.rst:18 +#: ../../library/curses.rst:15 msgid "" "While curses is most widely used in the Unix environment, versions are " "available for Windows, DOS, and possibly other systems as well. This " @@ -39,7 +39,7 @@ msgid "" "curses library hosted on Linux and the BSD variants of Unix." msgstr "" -#: ../../library/curses.rst:27 ../../includes/wasm-mobile-notavail.rst:3 +#: ../../library/curses.rst:24 ../../includes/wasm-mobile-notavail.rst:3 msgid "Availability" msgstr "可用性" @@ -59,7 +59,7 @@ msgid "" "module-requirements`." msgstr "" -#: ../../library/curses.rst:31 +#: ../../library/curses.rst:28 msgid "" "Whenever the documentation mentions a *character* it can be specified as an " "integer, a one-character Unicode string or a one-byte byte string. An " @@ -67,13 +67,13 @@ msgid "" "attributes and a color pair, as returned by :meth:`window.inch`." msgstr "" -#: ../../library/curses.rst:36 +#: ../../library/curses.rst:33 msgid "" "Whenever the documentation mentions a *character string* it can be specified " "as a Unicode string or a byte string." msgstr "" -#: ../../library/curses.rst:41 +#: ../../library/curses.rst:38 msgid "" "Whether curses may be used from several threads depends on the underlying " "library and how it was built. In many implementations, including the default " @@ -83,74 +83,74 @@ msgid "" "threads can then crash the interpreter. Serialize the calls." msgstr "" -#: ../../library/curses.rst:53 +#: ../../library/curses.rst:50 msgid "Module :mod:`curses.ascii`" msgstr ":mod:`curses.ascii` 模組" -#: ../../library/curses.rst:54 +#: ../../library/curses.rst:51 msgid "" "Utilities for working with ASCII characters, regardless of your locale " "settings." msgstr "" -#: ../../library/curses.rst:56 +#: ../../library/curses.rst:53 msgid "Module :mod:`curses.panel`" msgstr ":mod:`curses.panel` 模組" -#: ../../library/curses.rst:57 +#: ../../library/curses.rst:54 msgid "A panel stack extension that adds depth to curses windows." msgstr "" -#: ../../library/curses.rst:59 +#: ../../library/curses.rst:56 msgid "Module :mod:`curses.textpad`" msgstr ":mod:`curses.textpad` 模組" -#: ../../library/curses.rst:60 +#: ../../library/curses.rst:57 msgid "" "Editable text widget for curses supporting :program:`Emacs`\\ -like " "bindings." msgstr "" -#: ../../library/curses.rst:62 +#: ../../library/curses.rst:59 msgid ":ref:`curses-howto`" msgstr ":ref:`curses-howto`" -#: ../../library/curses.rst:63 +#: ../../library/curses.rst:60 msgid "" "Tutorial material on using curses with Python, by Andrew Kuchling and Eric " "Raymond." msgstr "" -#: ../../library/curses.rst:70 +#: ../../library/curses.rst:67 msgid "Functions" msgstr "函式" -#: ../../library/curses.rst:72 +#: ../../library/curses.rst:69 msgid "The module :mod:`!curses` defines the following exception:" msgstr ":mod:`!curses` 模組定義了以下例外:" -#: ../../library/curses.rst:77 +#: ../../library/curses.rst:74 msgid "Exception raised when a curses library function returns an error." msgstr "" -#: ../../library/curses.rst:81 +#: ../../library/curses.rst:78 msgid "" "Whenever *x* or *y* arguments to a function or a method are optional, they " "default to the current cursor location. Whenever *attr* is optional, it " "defaults to :const:`A_NORMAL`." msgstr "" -#: ../../library/curses.rst:85 +#: ../../library/curses.rst:82 msgid "The module :mod:`!curses` defines the following functions:" msgstr ":mod:`!curses` 模組定義了以下函式:" -#: ../../library/curses.rst:90 +#: ../../library/curses.rst:87 msgid "" "Allow use of default values for colors on terminals supporting this feature. " "Use this to support transparency in your application." msgstr "" -#: ../../library/curses.rst:93 +#: ../../library/curses.rst:90 msgid "" "Assign terminal default foreground/background colors to color number ``-1``. " "So ``init_pair(x, COLOR_RED, -1)`` will initialize pair *x* as red on " @@ -158,15 +158,15 @@ msgid "" "*x* as default foreground on blue." msgstr "" -#: ../../library/curses.rst:98 +#: ../../library/curses.rst:95 msgid "Change the definition of the color-pair ``0`` to ``(fg, bg)``." msgstr "" -#: ../../library/curses.rst:100 +#: ../../library/curses.rst:97 msgid "This is an ncurses extension." msgstr "" -#: ../../library/curses.rst:107 +#: ../../library/curses.rst:104 msgid "" "Return the output speed of the terminal in bits per second. On software " "terminal emulators it will have a fixed high value. Included for historical " @@ -174,17 +174,17 @@ msgid "" "and occasionally to change interfaces depending on the line speed." msgstr "" -#: ../../library/curses.rst:115 +#: ../../library/curses.rst:112 msgid "Emit a short attention sound." msgstr "" -#: ../../library/curses.rst:120 +#: ../../library/curses.rst:117 msgid "" "Return ``True`` or ``False``, depending on whether the programmer can change " "the colors displayed by the terminal." msgstr "" -#: ../../library/curses.rst:126 +#: ../../library/curses.rst:123 msgid "" "Enter cbreak mode. In cbreak mode (sometimes called \"rare\" mode) normal " "tty line buffering is turned off and characters are available to be read one " @@ -194,7 +194,7 @@ msgid "" "terminal in cbreak mode." msgstr "" -#: ../../library/curses.rst:135 +#: ../../library/curses.rst:132 msgid "" "Return the intensity of the red, green, and blue (RGB) components in the " "color *color_number*, which must be between ``0`` and ``COLORS - 1``. " @@ -203,7 +203,7 @@ msgid "" "component). Raise an exception if the color is not supported." msgstr "" -#: ../../library/curses.rst:144 +#: ../../library/curses.rst:141 msgid "" "Return the attribute value for displaying text in the specified color pair. " "Only the first 256 color pairs are supported. This attribute value can be " @@ -212,7 +212,7 @@ msgid "" "function." msgstr "" -#: ../../library/curses.rst:153 +#: ../../library/curses.rst:150 msgid "" "Set the cursor state. *visibility* can be set to ``0``, ``1``, or ``2``, " "for invisible, normal, or very visible. If the terminal supports the " @@ -221,7 +221,7 @@ msgid "" "and the \"very visible\" mode is a block cursor." msgstr "" -#: ../../library/curses.rst:162 +#: ../../library/curses.rst:159 msgid "" "Save the current terminal mode as the \"program\" mode, the mode when the " "running program is using curses. (Its counterpart is the \"shell\" mode, " @@ -229,7 +229,7 @@ msgid "" "`reset_prog_mode` will restore this mode." msgstr "" -#: ../../library/curses.rst:170 +#: ../../library/curses.rst:167 msgid "" "Save the current terminal mode as the \"shell\" mode, the mode when the " "running program is not using curses. (Its counterpart is the \"program\" " @@ -237,11 +237,11 @@ msgid "" "func:`reset_shell_mode` will restore this mode." msgstr "" -#: ../../library/curses.rst:178 +#: ../../library/curses.rst:175 msgid "Insert an *ms* millisecond pause in output." msgstr "" -#: ../../library/curses.rst:183 +#: ../../library/curses.rst:180 msgid "" "Update the physical screen. The curses library keeps two data structures, " "one representing the current physical screen contents and a virtual screen " @@ -249,7 +249,7 @@ msgid "" "the physical screen to match the virtual screen." msgstr "" -#: ../../library/curses.rst:188 +#: ../../library/curses.rst:185 msgid "" "The virtual screen may be updated by a :meth:`~window.noutrefresh` call " "after write operations such as :meth:`~window.addstr` have been performed on " @@ -260,24 +260,24 @@ msgid "" "func:`!doupdate`." msgstr "" -#: ../../library/curses.rst:198 +#: ../../library/curses.rst:195 msgid "" "Enter echo mode. In echo mode, each character input is echoed to the screen " "as it is entered." msgstr "" -#: ../../library/curses.rst:204 +#: ../../library/curses.rst:201 msgid "De-initialize the library, and return terminal to normal status." msgstr "" -#: ../../library/curses.rst:209 +#: ../../library/curses.rst:206 msgid "" "Return the user's current erase character as a one-byte bytes object. Under " "Unix operating systems this is a property of the controlling tty of the " "curses program, and is not set by the curses library itself." msgstr "" -#: ../../library/curses.rst:216 +#: ../../library/curses.rst:213 msgid "" "The :func:`.filter` routine, if used, must be called before :func:`initscr` " "is called. The effect is that, during the initialization, :envvar:`LINES` " @@ -288,20 +288,20 @@ msgid "" "character-at-a-time line editing without touching the rest of the screen." msgstr "" -#: ../../library/curses.rst:226 +#: ../../library/curses.rst:223 msgid "" "Flash the screen. That is, change it to reverse-video and then change it " "back in a short interval. Some people prefer such as 'visible bell' to the " "audible attention signal produced by :func:`beep`." msgstr "" -#: ../../library/curses.rst:233 +#: ../../library/curses.rst:230 msgid "" "Flush all input buffers. This throws away any typeahead that has been " "typed by the user and has not yet been processed by the program." msgstr "" -#: ../../library/curses.rst:239 +#: ../../library/curses.rst:236 msgid "" "After :meth:`~window.getch` returns :const:`KEY_MOUSE` to signal a mouse " "event, this method should be called to retrieve the queued mouse event, " @@ -316,20 +316,20 @@ msgid "" "const:`BUTTON_ALT`." msgstr "" -#: ../../library/curses.rst:250 ../../library/curses.rst:1923 +#: ../../library/curses.rst:247 ../../library/curses.rst:1920 msgid "" "The ``BUTTON5_*`` constants are now exposed if they are provided by the " "underlying curses library." msgstr "" -#: ../../library/curses.rst:257 +#: ../../library/curses.rst:254 msgid "" "Return the current coordinates of the virtual screen cursor as a tuple ``(y, " "x)``. If :meth:`leaveok ` is currently ``True``, then " "return ``(-1, -1)``." msgstr "" -#: ../../library/curses.rst:263 +#: ../../library/curses.rst:260 msgid "" "Read window-related data stored in the file by an earlier :meth:`window." "putwin` call. The routine then creates and initializes a new window using " @@ -337,31 +337,31 @@ msgid "" "file object opened for reading in binary mode." msgstr "" -#: ../../library/curses.rst:271 +#: ../../library/curses.rst:268 msgid "" "Return ``True`` if the terminal can display colors; otherwise, return " "``False``." msgstr "" -#: ../../library/curses.rst:275 +#: ../../library/curses.rst:272 msgid "" "Return ``True`` if the module supports extended colors; otherwise, return " "``False``. Extended color support allows more than 256 color pairs for " "terminals that support more than 16 colors (for example, xterm-256color)." msgstr "" -#: ../../library/curses.rst:279 +#: ../../library/curses.rst:276 msgid "Extended color support requires ncurses version 6.1 or later." msgstr "" -#: ../../library/curses.rst:285 +#: ../../library/curses.rst:282 msgid "" "Return ``True`` if the terminal has insert- and delete-character " "capabilities. This function is included for historical reasons only, as all " "modern software terminal emulators have such capabilities." msgstr "" -#: ../../library/curses.rst:292 +#: ../../library/curses.rst:289 msgid "" "Return ``True`` if the terminal has insert- and delete-line capabilities, or " "can simulate them using scrolling regions. This function is included for " @@ -369,13 +369,13 @@ msgid "" "capabilities." msgstr "" -#: ../../library/curses.rst:300 +#: ../../library/curses.rst:297 msgid "" "Take a key value *ch*, and return ``True`` if the current terminal type " "recognizes a key with that value." msgstr "" -#: ../../library/curses.rst:306 +#: ../../library/curses.rst:303 msgid "" "Used for half-delay mode, which is similar to cbreak mode in that characters " "typed by the user are immediately available to the program. However, after " @@ -384,7 +384,7 @@ msgid "" "``255``. Use :func:`nocbreak` to leave half-delay mode." msgstr "" -#: ../../library/curses.rst:315 +#: ../../library/curses.rst:312 msgid "" "Change the definition of a color, taking the number of the color to be " "changed followed by three RGB values (for the amounts of red, green, and " @@ -396,7 +396,7 @@ msgid "" "``True``." msgstr "" -#: ../../library/curses.rst:326 +#: ../../library/curses.rst:323 msgid "" "Change the definition of a color-pair. It takes three arguments: the number " "of the color-pair to be changed, the foreground color number, and the " @@ -410,43 +410,43 @@ msgid "" "definition." msgstr "" -#: ../../library/curses.rst:341 +#: ../../library/curses.rst:338 msgid "" "Initialize the library. Return a :ref:`window ` " "object which represents the whole screen." msgstr "" -#: ../../library/curses.rst:344 +#: ../../library/curses.rst:341 msgid "" "See :func:`setupterm` for a caveat about calling it before this function." msgstr "" -#: ../../library/curses.rst:348 +#: ../../library/curses.rst:345 msgid "" "If there is an error opening the terminal, the underlying curses library may " "cause the interpreter to exit." msgstr "" -#: ../../library/curses.rst:354 +#: ../../library/curses.rst:351 msgid "" "If *flag* is ``True``, pressing an interrupt key (interrupt, break, or quit) " "will flush all output in the terminal driver queue. If *flag* is ``False``, " "no flushing is done." msgstr "" -#: ../../library/curses.rst:361 +#: ../../library/curses.rst:358 msgid "" "Return ``True`` if :func:`resize_term` would modify the window structure, " "``False`` otherwise." msgstr "" -#: ../../library/curses.rst:367 +#: ../../library/curses.rst:364 msgid "" "Return ``True`` if :func:`endwin` has been called (that is, the curses " "library has been deinitialized)." msgstr "" -#: ../../library/curses.rst:373 +#: ../../library/curses.rst:370 msgid "" "Return the name of the key numbered *k* as a bytes object. The name of a " "key generating printable ASCII character is the key's character. The name " @@ -457,31 +457,31 @@ msgid "" "character." msgstr "" -#: ../../library/curses.rst:380 +#: ../../library/curses.rst:377 msgid "Raise a :exc:`ValueError` if *k* is negative." msgstr "" -#: ../../library/curses.rst:385 +#: ../../library/curses.rst:382 msgid "" "Return the user's current line kill character as a one-byte bytes object. " "Under Unix operating systems this is a property of the controlling tty of " "the curses program, and is not set by the curses library itself." msgstr "" -#: ../../library/curses.rst:392 +#: ../../library/curses.rst:389 msgid "" "Return a bytes object containing the terminfo long name field describing the " "current terminal. The maximum length of a verbose description is 128 " "characters. It is defined only after the call to :func:`initscr`." msgstr "" -#: ../../library/curses.rst:399 +#: ../../library/curses.rst:396 msgid "" "If *flag* is ``True``, allow 8-bit characters to be input. If *flag* is " "``False``, allow only 7-bit chars." msgstr "" -#: ../../library/curses.rst:405 +#: ../../library/curses.rst:402 msgid "" "Set the maximum time in milliseconds that can elapse between press and " "release events in order for them to be recognized as a click, and return the " @@ -490,7 +490,7 @@ msgid "" "without changing it." msgstr "" -#: ../../library/curses.rst:413 +#: ../../library/curses.rst:410 msgid "" "Set the mouse events to be reported, and return a tuple ``(availmask, " "oldmask)``. *availmask* indicates which of the specified mouse events can " @@ -499,17 +499,17 @@ msgid "" "no mouse events are ever reported." msgstr "" -#: ../../library/curses.rst:422 +#: ../../library/curses.rst:419 msgid "Sleep for *ms* milliseconds." msgstr "" -#: ../../library/curses.rst:427 +#: ../../library/curses.rst:424 msgid "" "Create and return a pointer to a new pad data structure with the given " "number of lines and columns. Return a pad as a window object." msgstr "" -#: ../../library/curses.rst:430 +#: ../../library/curses.rst:427 msgid "" "A pad is like a window, except that it is not restricted by the screen size, " "and is not necessarily associated with a particular part of the screen. " @@ -525,39 +525,39 @@ msgid "" "to be displayed." msgstr "" -#: ../../library/curses.rst:446 +#: ../../library/curses.rst:443 msgid "" "Return a new :ref:`window `, whose left-upper corner " "is at ``(begin_y, begin_x)``, and whose height/width is *nlines*/*ncols*." msgstr "" -#: ../../library/curses.rst:449 +#: ../../library/curses.rst:446 msgid "" "By default, the window will extend from the specified position to the lower " "right corner of the screen." msgstr "" -#: ../../library/curses.rst:455 +#: ../../library/curses.rst:452 msgid "" "Enter newline mode. This mode translates the return key into newline on " "input, and translates newline into return and line-feed on output. Newline " "mode is initially on." msgstr "" -#: ../../library/curses.rst:459 +#: ../../library/curses.rst:456 msgid "If *flag* is ``False``, the effect is the same as calling :func:`nonl`." msgstr "" -#: ../../library/curses.rst:464 +#: ../../library/curses.rst:461 msgid "" "Leave cbreak mode. Return to normal \"cooked\" mode with line buffering." msgstr "" -#: ../../library/curses.rst:469 +#: ../../library/curses.rst:466 msgid "Leave echo mode. Echoing of input characters is turned off." msgstr "" -#: ../../library/curses.rst:474 +#: ../../library/curses.rst:471 msgid "" "Leave newline mode. Disable translation of return into newline on input, " "and disable low-level translation of newline into newline/return on output " @@ -567,7 +567,7 @@ msgid "" "also, it will be able to detect the return key on input." msgstr "" -#: ../../library/curses.rst:484 +#: ../../library/curses.rst:481 msgid "" "When the :func:`!noqiflush` routine is used, normal flush of input and " "output queues associated with the ``INTR``, ``QUIT`` and ``SUSP`` characters " @@ -576,69 +576,69 @@ msgid "" "occurred, after the handler exits." msgstr "" -#: ../../library/curses.rst:492 +#: ../../library/curses.rst:489 msgid "Leave raw mode. Return to normal \"cooked\" mode with line buffering." msgstr "" -#: ../../library/curses.rst:497 +#: ../../library/curses.rst:494 msgid "" "Return a tuple ``(fg, bg)`` containing the colors for the requested color " "pair. The value of *pair_number* must be between ``0`` and ``COLOR_PAIRS - " "1``." msgstr "" -#: ../../library/curses.rst:503 +#: ../../library/curses.rst:500 msgid "" "Return the number of the color-pair set by the attribute value *attr*. :func:" "`color_pair` is the counterpart to this function." msgstr "" -#: ../../library/curses.rst:509 +#: ../../library/curses.rst:506 msgid "" "Equivalent to ``tputs(str, 1, putchar)``; emit the value of a specified " "terminfo capability, a bytes object, for the current terminal. Note that the " "output of :func:`putp` always goes to standard output." msgstr "" -#: ../../library/curses.rst:513 ../../library/curses.rst:656 -#: ../../library/curses.rst:666 ../../library/curses.rst:676 -#: ../../library/curses.rst:686 +#: ../../library/curses.rst:510 ../../library/curses.rst:653 +#: ../../library/curses.rst:663 ../../library/curses.rst:673 +#: ../../library/curses.rst:683 msgid ":func:`setupterm` (or :func:`initscr`) must be called first." msgstr "" -#: ../../library/curses.rst:518 +#: ../../library/curses.rst:515 msgid "" "If *flag* is ``False``, the effect is the same as calling :func:`noqiflush`. " "If *flag* is ``True``, or no argument is provided, the queues will be " "flushed when these control characters are read." msgstr "" -#: ../../library/curses.rst:525 +#: ../../library/curses.rst:522 msgid "" "Enter raw mode. In raw mode, normal line buffering and processing of " "interrupt, quit, suspend, and flow control keys are turned off; characters " "are presented to curses input functions one by one." msgstr "" -#: ../../library/curses.rst:532 +#: ../../library/curses.rst:529 msgid "" "Restore the terminal to \"program\" mode, as previously saved by :func:" "`def_prog_mode`." msgstr "" -#: ../../library/curses.rst:538 +#: ../../library/curses.rst:535 msgid "" "Restore the terminal to \"shell\" mode, as previously saved by :func:" "`def_shell_mode`." msgstr "" -#: ../../library/curses.rst:544 +#: ../../library/curses.rst:541 msgid "" "Restore the state of the terminal modes to what it was at the last call to :" "func:`savetty`." msgstr "" -#: ../../library/curses.rst:550 +#: ../../library/curses.rst:547 msgid "" "Backend function used by :func:`resizeterm`, performing most of the work; " "when resizing the windows, :func:`resize_term` blank-fills the areas that " @@ -648,47 +648,47 @@ msgid "" "to resize these without additional interaction with the application." msgstr "" -#: ../../library/curses.rst:560 +#: ../../library/curses.rst:557 msgid "" "Resize the standard and current windows to the specified dimensions, and " "adjusts other bookkeeping data used by the curses library that record the " "window dimensions (in particular the SIGWINCH handler)." msgstr "" -#: ../../library/curses.rst:567 +#: ../../library/curses.rst:564 msgid "" "Save the current state of the terminal modes in a buffer, usable by :func:" "`resetty`." msgstr "" -#: ../../library/curses.rst:572 +#: ../../library/curses.rst:569 msgid "Retrieves the value set by :func:`set_escdelay`." msgstr "" -#: ../../library/curses.rst:578 +#: ../../library/curses.rst:575 msgid "" "Sets the number of milliseconds to wait after reading an escape character, " "to distinguish between an individual escape character entered on the " "keyboard from escape sequences sent by cursor and function keys." msgstr "" -#: ../../library/curses.rst:586 +#: ../../library/curses.rst:583 msgid "Retrieves the value set by :func:`set_tabsize`." msgstr "" -#: ../../library/curses.rst:592 +#: ../../library/curses.rst:589 msgid "" "Sets the number of columns used by the curses library when converting a tab " "character to spaces as it adds the tab to a window." msgstr "" -#: ../../library/curses.rst:599 +#: ../../library/curses.rst:596 msgid "" "Set the virtual screen cursor to *y*, *x*. If *y* and *x* are both ``-1``, " "then :meth:`leaveok ` is set ``True``." msgstr "" -#: ../../library/curses.rst:605 +#: ../../library/curses.rst:602 msgid "" "Initialize the terminal. *term* is a string giving the terminal name, or " "``None``; if omitted or ``None``, the value of the :envvar:`TERM` " @@ -697,28 +697,28 @@ msgid "" "descriptor for ``sys.stdout`` will be used." msgstr "" -#: ../../library/curses.rst:611 +#: ../../library/curses.rst:608 msgid "" "Raise a :exc:`curses.error` if the terminal could not be found or its " "terminfo database entry could not be read. If the terminal has already been " "initialized, this function has no effect." msgstr "" -#: ../../library/curses.rst:617 +#: ../../library/curses.rst:614 msgid "" "Calling :func:`initscr` after :func:`setupterm` leaks the terminal that :" "func:`setupterm` allocated: the curses library keeps only a single current " "terminal and does not free the previously allocated one." msgstr "" -#: ../../library/curses.rst:625 +#: ../../library/curses.rst:622 msgid "" "Must be called if the programmer wants to use colors, and before any other " "color manipulation routine is called. It is good practice to call this " "routine right after :func:`initscr`." msgstr "" -#: ../../library/curses.rst:629 +#: ../../library/curses.rst:626 msgid "" ":func:`start_color` initializes eight basic colors (black, red, green, " "yellow, blue, magenta, cyan, and white), and two global variables in the :" @@ -728,20 +728,20 @@ msgid "" "terminal was just turned on." msgstr "" -#: ../../library/curses.rst:638 +#: ../../library/curses.rst:635 msgid "" "Return a logical OR of all video attributes supported by the terminal. This " "information is useful when a curses program needs complete control over the " "appearance of the screen." msgstr "" -#: ../../library/curses.rst:645 +#: ../../library/curses.rst:642 msgid "" "Return the value of the environment variable :envvar:`TERM`, as a bytes " "object, truncated to 14 characters." msgstr "" -#: ../../library/curses.rst:651 +#: ../../library/curses.rst:648 msgid "" "Return the value of the Boolean capability corresponding to the terminfo " "capability name *capname* as an integer. Return the value ``-1`` if " @@ -749,7 +749,7 @@ msgid "" "from the terminal description." msgstr "" -#: ../../library/curses.rst:661 +#: ../../library/curses.rst:658 msgid "" "Return the value of the numeric capability corresponding to the terminfo " "capability name *capname* as an integer. Return the value ``-2`` if " @@ -757,7 +757,7 @@ msgid "" "from the terminal description." msgstr "" -#: ../../library/curses.rst:671 +#: ../../library/curses.rst:668 msgid "" "Return the value of the string capability corresponding to the terminfo " "capability name *capname* as a bytes object. Return ``None`` if *capname* " @@ -765,7 +765,7 @@ msgid "" "terminal description." msgstr "" -#: ../../library/curses.rst:681 +#: ../../library/curses.rst:678 msgid "" "Instantiate the bytes object *str* with the supplied parameters, where *str* " "should be a parameterized byte string obtained from the terminfo database. " @@ -774,13 +774,13 @@ msgid "" "integer parameters may be supplied." msgstr "" -#: ../../library/curses.rst:691 +#: ../../library/curses.rst:688 msgid "" "Specify that the file descriptor *fd* be used for typeahead checking. If " "*fd* is ``-1``, then no typeahead checking is done." msgstr "" -#: ../../library/curses.rst:694 +#: ../../library/curses.rst:691 msgid "" "The curses library does \"line-breakout optimization\" by looking for " "typeahead periodically while updating the screen. If input is found, and it " @@ -790,7 +790,7 @@ msgid "" "typeahead checking." msgstr "" -#: ../../library/curses.rst:703 +#: ../../library/curses.rst:700 msgid "" "Return a bytes object which is a printable representation of the character " "*ch*; any attributes and color pair are ignored. Control characters are " @@ -798,47 +798,47 @@ msgid "" "Printing characters are left as they are." msgstr "" -#: ../../library/curses.rst:711 +#: ../../library/curses.rst:708 msgid "Push *ch* so the next :meth:`~window.getch` will return it." msgstr "" -#: ../../library/curses.rst:713 +#: ../../library/curses.rst:710 msgid "" "*ch* may be an integer (a key code or the code of an encoded byte), a byte, " "or a string of length 1 which encodes to a single byte." msgstr "" -#: ../../library/curses.rst:718 +#: ../../library/curses.rst:715 msgid "Only one *ch* can be pushed before :meth:`!getch` is called." msgstr "" -#: ../../library/curses.rst:723 +#: ../../library/curses.rst:720 msgid "" "Update the :const:`LINES` and :const:`COLS` module variables. Useful for " "detecting manual screen resize." msgstr "" -#: ../../library/curses.rst:731 +#: ../../library/curses.rst:728 msgid "Push *ch* so the next :meth:`~window.get_wch` will return it." msgstr "" -#: ../../library/curses.rst:733 +#: ../../library/curses.rst:730 msgid "" "*ch* may be an integer (a character code, not a key code) or a string of " "length 1." msgstr "" -#: ../../library/curses.rst:738 +#: ../../library/curses.rst:735 msgid "Only one *ch* can be pushed before :meth:`!get_wch` is called." msgstr "" -#: ../../library/curses.rst:745 +#: ../../library/curses.rst:742 msgid "" "Push a :const:`KEY_MOUSE` event onto the input queue, associating the given " "state data with it." msgstr "" -#: ../../library/curses.rst:751 +#: ../../library/curses.rst:748 msgid "" "If used, this function should be called before :func:`initscr` or newterm " "are called. When *flag* is ``False``, the values of lines and columns " @@ -848,11 +848,11 @@ msgid "" "to use the window size if :envvar:`LINES` and :envvar:`COLUMNS` are not set)." msgstr "" -#: ../../library/curses.rst:761 +#: ../../library/curses.rst:758 msgid "Equivalent to ``assume_default_colors(-1, -1)``." msgstr "" -#: ../../library/curses.rst:766 +#: ../../library/curses.rst:763 msgid "" "Initialize curses and call another callable object, *func*, which should be " "the rest of your curses-using application. If the application raises an " @@ -866,50 +866,50 @@ msgid "" "echo, and disables the terminal keypad." msgstr "" -#: ../../library/curses.rst:780 +#: ../../library/curses.rst:777 msgid "Window objects" msgstr "" -#: ../../library/curses.rst:784 +#: ../../library/curses.rst:781 msgid "" "Window objects, as returned by :func:`initscr` and :func:`newwin` above, " "have the following methods and attributes:" msgstr "" -#: ../../library/curses.rst:791 +#: ../../library/curses.rst:788 msgid "" "Paint character *ch* at ``(y, x)`` with attributes *attr*, overwriting any " "character previously painted at that location. By default, the character " "position and attributes are the current settings for the window object." msgstr "" -#: ../../library/curses.rst:797 +#: ../../library/curses.rst:794 msgid "" "Writing outside the window, subwindow, or pad raises a :exc:`curses.error`. " "Attempting to write to the lower-right corner of a window, subwindow, or pad " "will cause an exception to be raised after the character is printed." msgstr "" -#: ../../library/curses.rst:805 +#: ../../library/curses.rst:802 msgid "" "Paint at most *n* characters of the character string *str* at ``(y, x)`` " "with attributes *attr*, overwriting anything previously on the display." msgstr "" -#: ../../library/curses.rst:813 +#: ../../library/curses.rst:810 msgid "" "Paint the character string *str* at ``(y, x)`` with attributes *attr*, " "overwriting anything previously on the display." msgstr "" -#: ../../library/curses.rst:818 +#: ../../library/curses.rst:815 msgid "" "Writing outside the window, subwindow, or pad raises :exc:`curses.error`. " "Attempting to write to the lower-right corner of a window, subwindow, or pad " "will cause an exception to be raised after the string is printed." msgstr "" -#: ../../library/curses.rst:822 +#: ../../library/curses.rst:819 msgid "" "A bug in ncurses, the backend for this Python module, could cause segfaults " "when resizing windows. This was fixed in ncurses-6.1-20190511. If you are " @@ -918,44 +918,44 @@ msgid "" "`!addstr` separately for each line." msgstr "" -#: ../../library/curses.rst:831 +#: ../../library/curses.rst:828 msgid "" "Remove attribute *attr* from the \"background\" set applied to all writes to " "the current window." msgstr "" -#: ../../library/curses.rst:837 +#: ../../library/curses.rst:834 msgid "" "Add attribute *attr* to the \"background\" set applied to all writes to the " "current window." msgstr "" -#: ../../library/curses.rst:843 +#: ../../library/curses.rst:840 msgid "" "Set the \"background\" set of attributes to *attr*. This set is initially " "``0`` (no attributes)." msgstr "" -#: ../../library/curses.rst:849 +#: ../../library/curses.rst:846 msgid "" "Set the background property of the window to the character *ch*, with " "attributes *attr*. The change is then applied to every character position " "in that window:" msgstr "" -#: ../../library/curses.rst:853 +#: ../../library/curses.rst:850 msgid "" "The attribute of every character in the window is changed to the new " "background attribute." msgstr "" -#: ../../library/curses.rst:856 +#: ../../library/curses.rst:853 msgid "" "Wherever the former background character appears, it is changed to the new " "background character." msgstr "" -#: ../../library/curses.rst:862 +#: ../../library/curses.rst:859 msgid "" "Set the window's background. A window's background consists of a character " "and any combination of attributes. The attribute part of the background is " @@ -966,128 +966,128 @@ msgid "" "delete line/character operations." msgstr "" -#: ../../library/curses.rst:872 +#: ../../library/curses.rst:869 msgid "" "Draw a border around the edges of the window. Each parameter specifies the " "character to use for a specific part of the border; see the table below for " "more details." msgstr "" -#: ../../library/curses.rst:878 +#: ../../library/curses.rst:875 msgid "" "A ``0`` value for any parameter will cause the default character to be used " "for that parameter. Keyword parameters can *not* be used. The defaults are " "listed in this table:" msgstr "" -#: ../../library/curses.rst:883 +#: ../../library/curses.rst:880 msgid "Parameter" msgstr "參數" -#: ../../library/curses.rst:883 +#: ../../library/curses.rst:880 msgid "Description" msgstr "描述" -#: ../../library/curses.rst:883 +#: ../../library/curses.rst:880 msgid "Default value" msgstr "預設值" -#: ../../library/curses.rst:885 +#: ../../library/curses.rst:882 msgid "*ls*" msgstr "*ls*" -#: ../../library/curses.rst:885 +#: ../../library/curses.rst:882 msgid "Left side" msgstr "" -#: ../../library/curses.rst:885 ../../library/curses.rst:887 +#: ../../library/curses.rst:882 ../../library/curses.rst:884 msgid ":const:`ACS_VLINE`" msgstr ":const:`ACS_VLINE`" -#: ../../library/curses.rst:887 +#: ../../library/curses.rst:884 msgid "*rs*" msgstr "*rs*" -#: ../../library/curses.rst:887 +#: ../../library/curses.rst:884 msgid "Right side" msgstr "" -#: ../../library/curses.rst:889 +#: ../../library/curses.rst:886 msgid "*ts*" msgstr "*ts*" -#: ../../library/curses.rst:889 +#: ../../library/curses.rst:886 msgid "Top" msgstr "" -#: ../../library/curses.rst:889 ../../library/curses.rst:891 +#: ../../library/curses.rst:886 ../../library/curses.rst:888 msgid ":const:`ACS_HLINE`" msgstr ":const:`ACS_HLINE`" -#: ../../library/curses.rst:891 +#: ../../library/curses.rst:888 msgid "*bs*" msgstr "*bs*" -#: ../../library/curses.rst:891 +#: ../../library/curses.rst:888 msgid "Bottom" msgstr "" -#: ../../library/curses.rst:893 +#: ../../library/curses.rst:890 msgid "*tl*" msgstr "*tl*" -#: ../../library/curses.rst:893 +#: ../../library/curses.rst:890 msgid "Upper-left corner" msgstr "" -#: ../../library/curses.rst:893 +#: ../../library/curses.rst:890 msgid ":const:`ACS_ULCORNER`" msgstr ":const:`ACS_ULCORNER`" -#: ../../library/curses.rst:895 +#: ../../library/curses.rst:892 msgid "*tr*" msgstr "*tr*" -#: ../../library/curses.rst:895 +#: ../../library/curses.rst:892 msgid "Upper-right corner" msgstr "" -#: ../../library/curses.rst:895 +#: ../../library/curses.rst:892 msgid ":const:`ACS_URCORNER`" msgstr ":const:`ACS_URCORNER`" -#: ../../library/curses.rst:897 +#: ../../library/curses.rst:894 msgid "*bl*" msgstr "*bl*" -#: ../../library/curses.rst:897 +#: ../../library/curses.rst:894 msgid "Bottom-left corner" msgstr "" -#: ../../library/curses.rst:897 +#: ../../library/curses.rst:894 msgid ":const:`ACS_LLCORNER`" msgstr ":const:`ACS_LLCORNER`" -#: ../../library/curses.rst:899 +#: ../../library/curses.rst:896 msgid "*br*" msgstr "*br*" -#: ../../library/curses.rst:899 +#: ../../library/curses.rst:896 msgid "Bottom-right corner" msgstr "" -#: ../../library/curses.rst:899 +#: ../../library/curses.rst:896 msgid ":const:`ACS_LRCORNER`" msgstr ":const:`ACS_LRCORNER`" -#: ../../library/curses.rst:905 +#: ../../library/curses.rst:902 msgid "" "Similar to :meth:`border`, but both *ls* and *rs* are *vertch* and both *ts* " "and *bs* are *horch*. The default corner characters are always used by this " "function." msgstr "" -#: ../../library/curses.rst:914 +#: ../../library/curses.rst:911 msgid "" "Set the attributes of *num* characters at the current cursor position, or at " "position ``(y, x)`` if supplied. If *num* is not given or is ``-1``, the " @@ -1097,47 +1097,47 @@ msgid "" "be redisplayed by the next window refresh." msgstr "" -#: ../../library/curses.rst:924 +#: ../../library/curses.rst:921 msgid "" "Like :meth:`erase`, but also cause the whole window to be repainted upon " "next call to :meth:`refresh`." msgstr "" -#: ../../library/curses.rst:930 +#: ../../library/curses.rst:927 msgid "" "If *flag* is ``True``, the next call to :meth:`refresh` will clear the " "window completely." msgstr "" -#: ../../library/curses.rst:936 +#: ../../library/curses.rst:933 msgid "" "Erase from cursor to the end of the window: all lines below the cursor are " "deleted, and then the equivalent of :meth:`clrtoeol` is performed." msgstr "" -#: ../../library/curses.rst:942 +#: ../../library/curses.rst:939 msgid "Erase from cursor to the end of the line." msgstr "" -#: ../../library/curses.rst:947 +#: ../../library/curses.rst:944 msgid "" "Update the current cursor position of all the ancestors of the window to " "reflect the current cursor position of the window." msgstr "" -#: ../../library/curses.rst:953 +#: ../../library/curses.rst:950 msgid "" "Delete the character under the cursor, or at ``(y, x)`` if specified. All " "characters to the right on the same line are shifted one position left." msgstr "" -#: ../../library/curses.rst:959 +#: ../../library/curses.rst:956 msgid "" "Delete the line under the cursor. All following lines are moved up by one " "line." msgstr "" -#: ../../library/curses.rst:965 +#: ../../library/curses.rst:962 msgid "" "An abbreviation for \"derive window\", :meth:`derwin` is the same as " "calling :meth:`subwin`, except that *begin_y* and *begin_x* are relative to " @@ -1145,13 +1145,13 @@ msgid "" "a window object for the derived window." msgstr "" -#: ../../library/curses.rst:973 +#: ../../library/curses.rst:970 msgid "" "Add character *ch* with attribute *attr*, and immediately call :meth:" "`refresh` on the window." msgstr "" -#: ../../library/curses.rst:979 +#: ../../library/curses.rst:976 msgid "" "Test whether the given pair of screen-relative character-cell coordinates " "are enclosed by the given window, returning ``True`` or ``False``. It is " @@ -1159,11 +1159,11 @@ msgid "" "location of a mouse event." msgstr "" -#: ../../library/curses.rst:984 +#: ../../library/curses.rst:981 msgid "Previously it returned ``1`` or ``0`` instead of ``True`` or ``False``." msgstr "" -#: ../../library/curses.rst:990 +#: ../../library/curses.rst:987 msgid "" "Encoding used to encode the string arguments of the methods and to decode " "their results on a build without wide-character support. The encoding " @@ -1172,15 +1172,15 @@ msgid "" "is used (see :func:`locale.getencoding`)." msgstr "" -#: ../../library/curses.rst:1001 +#: ../../library/curses.rst:998 msgid "Clear the window." msgstr "清除視窗。" -#: ../../library/curses.rst:1006 +#: ../../library/curses.rst:1003 msgid "Return a tuple ``(y, x)`` of coordinates of upper-left corner." msgstr "回傳左上角的座標 ``(y, x)``。" -#: ../../library/curses.rst:1011 +#: ../../library/curses.rst:1008 msgid "" "Return the given window's current background character/attribute pair. Its " "components can be extracted like those of :meth:`inch`." @@ -1188,7 +1188,7 @@ msgstr "" "回傳給定視窗目前的背景字元/屬性對。其組成部分可以像 :meth:`inch` 的回傳值一樣" "被提取。" -#: ../../library/curses.rst:1017 +#: ../../library/curses.rst:1014 msgid "" "Read a key press, after moving the cursor to *y*, *x* if specified, and " "return it as an integer. The window is refreshed first if it is not a pad " @@ -1197,7 +1197,7 @@ msgid "" "and :meth:`timeout`)." msgstr "" -#: ../../library/curses.rst:1024 +#: ../../library/curses.rst:1021 msgid "" "An ordinary key is returned as the code of a single byte of its encoding in " "the current locale, so a character encoded with several bytes takes several " @@ -1205,7 +1205,7 @@ msgid "" "``169``. Use :meth:`get_wch` to read it as a single character." msgstr "" -#: ../../library/curses.rst:1030 +#: ../../library/curses.rst:1027 msgid "" "In keypad mode (see :meth:`keypad`) function keys and other special keys are " "returned as one of the :ref:`KEY_* constants `, which " @@ -1214,13 +1214,13 @@ msgid "" "`set_escdelay`), their bytes are returned one at a time." msgstr "" -#: ../../library/curses.rst:1037 ../../library/curses.rst:1057 +#: ../../library/curses.rst:1034 ../../library/curses.rst:1054 msgid "" "In echo mode (see :func:`echo`) the key is added to the window as by :meth:" "`addch`; special keys are not echoed." msgstr "" -#: ../../library/curses.rst:1043 +#: ../../library/curses.rst:1040 msgid "" "Read a key press, after moving the cursor to *y*, *x* if specified, and " "return it as a one-character :class:`str`. The window is refreshed first if " @@ -1229,7 +1229,7 @@ msgid "" "(see :meth:`nodelay` and :meth:`timeout`)." msgstr "" -#: ../../library/curses.rst:1050 +#: ../../library/curses.rst:1047 msgid "" "In keypad mode (see :meth:`keypad`) function keys and other special keys are " "returned as one of the :ref:`KEY_* constants `, an " @@ -1238,7 +1238,7 @@ msgid "" "returned one at a time." msgstr "" -#: ../../library/curses.rst:1065 +#: ../../library/curses.rst:1062 msgid "" "Read a key press as :meth:`getch` does, but return it as a :class:`str`: an " "ordinary key as a one-character string, the byte decoded as Latin-1, and a " @@ -1246,18 +1246,18 @@ msgid "" "exc:`error` instead of returning ``-1`` if there is no input." msgstr "" -#: ../../library/curses.rst:1073 +#: ../../library/curses.rst:1070 msgid "Return a tuple ``(y, x)`` of the height and width of the window." msgstr "回傳視窗的高度和寬度的元組 ``(y, x)``。" -#: ../../library/curses.rst:1078 +#: ../../library/curses.rst:1075 msgid "" "Return the beginning coordinates of this window relative to its parent " "window as a tuple ``(y, x)``. Return ``(-1, -1)`` if this window has no " "parent." msgstr "" -#: ../../library/curses.rst:1088 +#: ../../library/curses.rst:1085 msgid "" "Read a line of input from the user, with primitive line editing capacity, " "after moving the cursor to *y*, *x* if specified. Return it as a bytes " @@ -1265,24 +1265,24 @@ msgid "" "newline. At most *n* bytes are read; *n* defaults to and cannot exceed 2047." msgstr "" -#: ../../library/curses.rst:1095 ../../library/curses.rst:1200 +#: ../../library/curses.rst:1092 ../../library/curses.rst:1197 msgid "The maximum value for *n* was increased from 1023 to 2047." msgstr "" -#: ../../library/curses.rst:1101 +#: ../../library/curses.rst:1098 msgid "" "Return a tuple ``(y, x)`` of current cursor position relative to the " "window's upper-left corner." msgstr "" -#: ../../library/curses.rst:1108 +#: ../../library/curses.rst:1105 msgid "" "Display a horizontal line starting at ``(y, x)`` with length *n* consisting " "of the character *ch* with attributes *attr*. The line stops at the right " "edge of the window if fewer than *n* cells are available." msgstr "" -#: ../../library/curses.rst:1115 +#: ../../library/curses.rst:1112 msgid "" "If *flag* is ``False``, curses no longer considers using the hardware insert/" "delete character feature of the terminal; if *flag* is ``True``, use of " @@ -1290,13 +1290,13 @@ msgid "" "initialized, use of character insert/delete is enabled by default." msgstr "" -#: ../../library/curses.rst:1123 +#: ../../library/curses.rst:1120 msgid "" "If *flag* is ``True``, :mod:`!curses` will try to use hardware line editing " "facilities. Otherwise, curses will not use them." msgstr "" -#: ../../library/curses.rst:1129 +#: ../../library/curses.rst:1126 msgid "" "If *flag* is ``True``, any change in the window image automatically causes " "the window to be refreshed; you no longer have to call :meth:`refresh` " @@ -1304,7 +1304,7 @@ msgid "" "calls to wrefresh. This option is disabled by default." msgstr "" -#: ../../library/curses.rst:1137 +#: ../../library/curses.rst:1134 msgid "" "Return the character at the given position in the window. The bottom 8 bits " "are the character proper and the upper bits are the attributes; extract them " @@ -1316,7 +1316,7 @@ msgid "" "characters." msgstr "" -#: ../../library/curses.rst:1151 +#: ../../library/curses.rst:1148 msgid "" "Insert character *ch* with attributes *attr* before the character under the " "cursor, or at ``(y, x)`` if specified. All characters to the right of the " @@ -1324,7 +1324,7 @@ msgid "" "line being lost. The cursor position does not change." msgstr "" -#: ../../library/curses.rst:1159 +#: ../../library/curses.rst:1156 msgid "" "Insert *nlines* lines into the specified window above the current line. The " "*nlines* bottom lines are lost. For negative *nlines*, delete *nlines* " @@ -1333,13 +1333,13 @@ msgid "" "remains the same." msgstr "" -#: ../../library/curses.rst:1168 +#: ../../library/curses.rst:1165 msgid "" "Insert a blank line under the cursor. All following lines are moved down by " "one line." msgstr "" -#: ../../library/curses.rst:1175 +#: ../../library/curses.rst:1172 msgid "" "Insert a character string (as many characters as will fit on the line) " "before the character under the cursor, up to *n* characters. If *n* is " @@ -1349,7 +1349,7 @@ msgid "" "if specified)." msgstr "" -#: ../../library/curses.rst:1185 +#: ../../library/curses.rst:1182 msgid "" "Insert a character string (as many characters as will fit on the line) " "before the character under the cursor. All characters to the right of the " @@ -1358,7 +1358,7 @@ msgid "" "specified)." msgstr "" -#: ../../library/curses.rst:1194 +#: ../../library/curses.rst:1191 msgid "" "Read the text of the window from the current cursor position, or from *y*, " "*x* if specified, to the end of the line, and return it as a bytes object, " @@ -1366,20 +1366,20 @@ msgid "" "stripped. At most *n* bytes are read; *n* defaults to and cannot exceed 2047." msgstr "" -#: ../../library/curses.rst:1206 +#: ../../library/curses.rst:1203 msgid "" "Return ``True`` if the specified line was modified since the last call to :" "meth:`refresh`; otherwise return ``False``. Raise a :exc:`curses.error` " "exception if *line* is not valid for the given window." msgstr "" -#: ../../library/curses.rst:1213 +#: ../../library/curses.rst:1210 msgid "" "Return ``True`` if the specified window was modified since the last call to :" "meth:`refresh`; otherwise return ``False``." msgstr "" -#: ../../library/curses.rst:1219 +#: ../../library/curses.rst:1216 msgid "" "If *flag* is ``True``, escape sequences generated by some keys (keypad, " "function keys) will be interpreted by :mod:`!curses`. If *flag* is " @@ -1388,68 +1388,68 @@ msgid "" "window." msgstr "" -#: ../../library/curses.rst:1228 +#: ../../library/curses.rst:1225 msgid "" "If *flag* is ``True``, cursor is left where it is on update, instead of " "being at \"cursor position.\" This reduces cursor movement where possible." msgstr "" -#: ../../library/curses.rst:1231 +#: ../../library/curses.rst:1228 msgid "" "If *flag* is ``False``, cursor will always be at \"cursor position\" after " "an update." msgstr "" -#: ../../library/curses.rst:1236 +#: ../../library/curses.rst:1233 msgid "Move cursor to ``(new_y, new_x)``." msgstr "移動游標到 ``(new_y, new_x)``。" -#: ../../library/curses.rst:1241 +#: ../../library/curses.rst:1238 msgid "" "Move the window inside its parent window. The screen-relative parameters of " "the window are not changed. This routine is used to display different parts " "of the parent window at the same physical position on the screen." msgstr "" -#: ../../library/curses.rst:1248 +#: ../../library/curses.rst:1245 msgid "Move the window so its upper-left corner is at ``(new_y, new_x)``." msgstr "" -#: ../../library/curses.rst:1250 +#: ../../library/curses.rst:1247 msgid "" "Moving the window so that any part of it would be off the screen is an " "error: the window is not moved and :exc:`curses.error` is raised." msgstr "" -#: ../../library/curses.rst:1256 +#: ../../library/curses.rst:1253 msgid "If *flag* is ``True``, :meth:`getch` will be non-blocking." msgstr "如果 *flag* 為 ``True``,則 :meth:`getch` 將為非阻塞的。" -#: ../../library/curses.rst:1261 +#: ../../library/curses.rst:1258 msgid "If *flag* is ``True``, escape sequences will not be timed out." msgstr "" -#: ../../library/curses.rst:1263 +#: ../../library/curses.rst:1260 msgid "" "If *flag* is ``False``, after a few milliseconds, an escape sequence will " "not be interpreted, and will be left in the input stream as is." msgstr "" -#: ../../library/curses.rst:1270 +#: ../../library/curses.rst:1267 msgid "" "Mark for refresh but wait. This function updates the data structure " "representing the desired state of the window, but does not force an update " "of the physical screen. To accomplish that, call :func:`doupdate`." msgstr "" -#: ../../library/curses.rst:1274 +#: ../../library/curses.rst:1271 msgid "" "The 6 arguments can only be specified, and are then required, when the " "window is a pad created with :func:`newpad`; they have the same meaning as " "for :meth:`refresh`." msgstr "" -#: ../../library/curses.rst:1281 +#: ../../library/curses.rst:1278 msgid "" "Overlay the window on top of *destwin*. The windows need not be the same " "size, only the overlapping region is copied. This copy is non-destructive, " @@ -1457,7 +1457,7 @@ msgid "" "contents of *destwin*." msgstr "" -#: ../../library/curses.rst:1286 +#: ../../library/curses.rst:1283 msgid "" "To get fine-grained control over the copied region, the second form of :meth:" "`overlay` can be used. *sminrow* and *smincol* are the upper-left " @@ -1465,7 +1465,7 @@ msgid "" "in the destination window." msgstr "" -#: ../../library/curses.rst:1294 +#: ../../library/curses.rst:1291 msgid "" "Overwrite the window on top of *destwin*. The windows need not be the same " "size, in which case only the overlapping region is copied. This copy is " @@ -1473,7 +1473,7 @@ msgid "" "the old contents of *destwin*." msgstr "" -#: ../../library/curses.rst:1299 +#: ../../library/curses.rst:1296 msgid "" "To get fine-grained control over the copied region, the second form of :meth:" "`overwrite` can be used. *sminrow* and *smincol* are the upper-left " @@ -1481,31 +1481,31 @@ msgid "" "the destination window." msgstr "" -#: ../../library/curses.rst:1307 +#: ../../library/curses.rst:1304 msgid "" "Write all data associated with the window into the provided file object. " "This information can be later retrieved using the :func:`getwin` function." msgstr "" -#: ../../library/curses.rst:1313 +#: ../../library/curses.rst:1310 msgid "" "Indicate that the *num* screen lines, starting at line *beg*, are corrupted " "and should be completely redrawn on the next :meth:`refresh` call." msgstr "" -#: ../../library/curses.rst:1319 +#: ../../library/curses.rst:1316 msgid "" "Touch the entire window, causing it to be completely redrawn on the next :" "meth:`refresh` call." msgstr "" -#: ../../library/curses.rst:1325 +#: ../../library/curses.rst:1322 msgid "" "Update the display immediately (sync actual screen with previous drawing/" "deleting methods)." msgstr "" -#: ../../library/curses.rst:1328 +#: ../../library/curses.rst:1325 msgid "" "The 6 arguments can only be specified, and are then required, when the " "window is a pad created with :func:`newpad`. The additional parameters are " @@ -1520,7 +1520,7 @@ msgid "" "as if they were zero." msgstr "" -#: ../../library/curses.rst:1342 +#: ../../library/curses.rst:1339 msgid "" "Reallocate storage for a curses window to adjust its dimensions to the " "specified values. If either dimension is larger than the current values, " @@ -1528,14 +1528,14 @@ msgid "" "rendition (as set by :meth:`bkgdset`) merged into them." msgstr "" -#: ../../library/curses.rst:1350 +#: ../../library/curses.rst:1347 msgid "" "Scroll the screen or scrolling region. Scroll upward by *lines* lines if " "*lines* is positive, or downward if it is negative. Scrolling has no effect " "unless it has been enabled for the window with :meth:`scrollok`." msgstr "" -#: ../../library/curses.rst:1357 +#: ../../library/curses.rst:1354 msgid "" "Control what happens when the cursor of a window is moved off the edge of " "the window or scrolling region, either as a result of a newline action on " @@ -1545,23 +1545,23 @@ msgid "" "scrolling effect on the terminal, it is also necessary to call :meth:`idlok`." msgstr "" -#: ../../library/curses.rst:1367 +#: ../../library/curses.rst:1364 msgid "" "Set the scrolling region from line *top* to line *bottom*. All scrolling " "actions will take place in this region." msgstr "" -#: ../../library/curses.rst:1373 +#: ../../library/curses.rst:1370 msgid "" "Turn off the standout attribute. On some terminals this has the side effect " "of turning off all attributes." msgstr "" -#: ../../library/curses.rst:1379 +#: ../../library/curses.rst:1376 msgid "Turn on attribute *A_STANDOUT*." msgstr "" -#: ../../library/curses.rst:1385 +#: ../../library/curses.rst:1382 msgid "" "Return a sub-pad, whose upper-left corner is at ``(begin_y, begin_x)``, and " "whose width/height is *ncols*/*nlines*. The coordinates are relative to the " @@ -1569,39 +1569,39 @@ msgid "" "method is only available for pads created with :func:`newpad`." msgstr "" -#: ../../library/curses.rst:1394 +#: ../../library/curses.rst:1391 msgid "" "Return a sub-window, whose upper-left corner is at the screen-relative " "coordinates ``(begin_y, begin_x)``, and whose width/height is *ncols*/" "*nlines*." msgstr "" -#: ../../library/curses.rst:1397 +#: ../../library/curses.rst:1394 msgid "" "By default, the sub-window will extend from the specified position to the " "lower right corner of the window." msgstr "" -#: ../../library/curses.rst:1403 +#: ../../library/curses.rst:1400 msgid "" "Touch each location in the window that has been touched in any of its " "ancestor windows. This routine is called by :meth:`refresh`, so it should " "almost never be necessary to call it manually." msgstr "" -#: ../../library/curses.rst:1410 +#: ../../library/curses.rst:1407 msgid "" "If *flag* is ``True``, then :meth:`syncup` is called automatically whenever " "there is a change in the window." msgstr "" -#: ../../library/curses.rst:1416 +#: ../../library/curses.rst:1413 msgid "" "Touch all locations in ancestors of the window that have been changed in " "the window." msgstr "" -#: ../../library/curses.rst:1422 +#: ../../library/curses.rst:1419 msgid "" "Set blocking or non-blocking read behavior for the window. If *delay* is " "negative, blocking read is used (which will wait indefinitely for input). " @@ -1611,7 +1611,7 @@ msgid "" "still no input at the end of that time." msgstr "" -#: ../../library/curses.rst:1432 +#: ../../library/curses.rst:1429 msgid "" "Pretend *count* lines have been changed, starting with line *start*. If " "*changed* is supplied, it specifies whether the affected lines are marked as " @@ -1619,49 +1619,49 @@ msgid "" "``=False``)." msgstr "" -#: ../../library/curses.rst:1439 +#: ../../library/curses.rst:1436 msgid "" "Pretend the whole window has been changed, for purposes of drawing " "optimizations." msgstr "" -#: ../../library/curses.rst:1445 +#: ../../library/curses.rst:1442 msgid "" "Mark all lines in the window as unchanged since the last call to :meth:" "`refresh`." msgstr "" -#: ../../library/curses.rst:1452 +#: ../../library/curses.rst:1449 msgid "" "Display a vertical line starting at ``(y, x)`` with length *n* consisting of " "the character *ch* with attributes *attr*." msgstr "" -#: ../../library/curses.rst:1457 +#: ../../library/curses.rst:1454 msgid "Constants" msgstr "" -#: ../../library/curses.rst:1459 +#: ../../library/curses.rst:1456 msgid "The :mod:`!curses` module defines the following data members:" msgstr ":mod:`!curses` 模組定義了以下資料成員:" -#: ../../library/curses.rst:1464 +#: ../../library/curses.rst:1461 msgid "" "Some curses routines that return an integer, such as :meth:`~window." "getch`, return :const:`ERR` upon failure." msgstr "" -#: ../../library/curses.rst:1470 +#: ../../library/curses.rst:1467 msgid "" "Some curses routines that return an integer, such as :func:`napms`, " "return :const:`OK` upon success." msgstr "" -#: ../../library/curses.rst:1476 +#: ../../library/curses.rst:1473 msgid "A bytes object representing the current version of the module." msgstr "" -#: ../../library/curses.rst:1481 +#: ../../library/curses.rst:1478 msgid "" "A named tuple containing the three components of the ncurses library " "version: *major*, *minor*, and *patch*. All values are integers. The " @@ -1669,536 +1669,536 @@ msgid "" "is equivalent to ``curses.ncurses_version.major`` and so on." msgstr "" -#: ../../library/curses.rst:1486 +#: ../../library/curses.rst:1483 msgid "Availability: if the ncurses library is used." msgstr "" -#: ../../library/curses.rst:1492 +#: ../../library/curses.rst:1489 msgid "" "The maximum number of colors the terminal can support. It is defined only " "after the call to :func:`start_color`." msgstr "" -#: ../../library/curses.rst:1497 +#: ../../library/curses.rst:1494 msgid "" "The maximum number of color pairs the terminal can support. It is defined " "only after the call to :func:`start_color`." msgstr "" -#: ../../library/curses.rst:1502 +#: ../../library/curses.rst:1499 msgid "" "The width of the screen, that is, the number of columns. It is defined only " "after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" "func:`resizeterm` and :func:`resize_term`." msgstr "" -#: ../../library/curses.rst:1509 +#: ../../library/curses.rst:1506 msgid "" "The height of the screen, that is, the number of lines. It is defined only " "after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" "func:`resizeterm` and :func:`resize_term`." msgstr "" -#: ../../library/curses.rst:1515 +#: ../../library/curses.rst:1512 msgid "" "Some constants are available to specify character cell attributes. The exact " "constants available are system dependent." msgstr "" -#: ../../library/curses.rst:1519 +#: ../../library/curses.rst:1516 msgid "Attribute" msgstr "" -#: ../../library/curses.rst:1519 ../../library/curses.rst:1564 -#: ../../library/curses.rst:1812 ../../library/curses.rst:1904 +#: ../../library/curses.rst:1516 ../../library/curses.rst:1561 +#: ../../library/curses.rst:1809 ../../library/curses.rst:1901 msgid "Meaning" msgstr "含義" -#: ../../library/curses.rst:1521 +#: ../../library/curses.rst:1518 msgid "Alternate character set mode" msgstr "" -#: ../../library/curses.rst:1523 +#: ../../library/curses.rst:1520 msgid "Blink mode" msgstr "" -#: ../../library/curses.rst:1525 +#: ../../library/curses.rst:1522 msgid "Bold mode" msgstr "" -#: ../../library/curses.rst:1527 +#: ../../library/curses.rst:1524 msgid "Dim mode" msgstr "" -#: ../../library/curses.rst:1529 +#: ../../library/curses.rst:1526 msgid "Invisible or blank mode" msgstr "" -#: ../../library/curses.rst:1531 +#: ../../library/curses.rst:1528 msgid "Italic mode" msgstr "" -#: ../../library/curses.rst:1533 +#: ../../library/curses.rst:1530 msgid "Normal attribute" msgstr "" -#: ../../library/curses.rst:1535 +#: ../../library/curses.rst:1532 msgid "Protected mode" msgstr "" -#: ../../library/curses.rst:1537 +#: ../../library/curses.rst:1534 msgid "Reverse background and foreground colors" msgstr "" -#: ../../library/curses.rst:1540 +#: ../../library/curses.rst:1537 msgid "Standout mode" msgstr "" -#: ../../library/curses.rst:1542 +#: ../../library/curses.rst:1539 msgid "Underline mode" msgstr "" -#: ../../library/curses.rst:1544 +#: ../../library/curses.rst:1541 msgid "Horizontal highlight" msgstr "" -#: ../../library/curses.rst:1546 +#: ../../library/curses.rst:1543 msgid "Left highlight" msgstr "" -#: ../../library/curses.rst:1548 +#: ../../library/curses.rst:1545 msgid "Low highlight" msgstr "" -#: ../../library/curses.rst:1550 +#: ../../library/curses.rst:1547 msgid "Right highlight" msgstr "" -#: ../../library/curses.rst:1552 +#: ../../library/curses.rst:1549 msgid "Top highlight" msgstr "" -#: ../../library/curses.rst:1554 +#: ../../library/curses.rst:1551 msgid "Vertical highlight" msgstr "" -#: ../../library/curses.rst:1557 +#: ../../library/curses.rst:1554 msgid "``A_ITALIC`` was added." msgstr "新增 ``A_ITALIC``。" -#: ../../library/curses.rst:1560 +#: ../../library/curses.rst:1557 msgid "" "Several constants are available to extract corresponding attributes returned " "by some methods." msgstr "" -#: ../../library/curses.rst:1564 +#: ../../library/curses.rst:1561 msgid "Bit-mask" msgstr "" -#: ../../library/curses.rst:1566 +#: ../../library/curses.rst:1563 msgid "Bit-mask to extract attributes" msgstr "" -#: ../../library/curses.rst:1569 +#: ../../library/curses.rst:1566 msgid "Bit-mask to extract a character" msgstr "" -#: ../../library/curses.rst:1572 +#: ../../library/curses.rst:1569 msgid "Bit-mask to extract color-pair field information" msgstr "" -#: ../../library/curses.rst:1578 +#: ../../library/curses.rst:1575 msgid "" "Keys are referred to by integer constants with names starting with " "``KEY_``. The exact keycaps available are system dependent." msgstr "" -#: ../../library/curses.rst:1584 +#: ../../library/curses.rst:1581 msgid "Key constant" msgstr "" -#: ../../library/curses.rst:1584 +#: ../../library/curses.rst:1581 msgid "Key" msgstr "" -#: ../../library/curses.rst:1586 +#: ../../library/curses.rst:1583 msgid "Minimum key value" msgstr "" -#: ../../library/curses.rst:1588 +#: ../../library/curses.rst:1585 msgid "Break key (unreliable)" msgstr "" -#: ../../library/curses.rst:1590 +#: ../../library/curses.rst:1587 msgid "Down-arrow" msgstr "" -#: ../../library/curses.rst:1592 +#: ../../library/curses.rst:1589 msgid "Up-arrow" msgstr "" -#: ../../library/curses.rst:1594 +#: ../../library/curses.rst:1591 msgid "Left-arrow" msgstr "" -#: ../../library/curses.rst:1596 +#: ../../library/curses.rst:1593 msgid "Right-arrow" msgstr "" -#: ../../library/curses.rst:1598 +#: ../../library/curses.rst:1595 msgid "Home key (upward+left arrow)" msgstr "" -#: ../../library/curses.rst:1600 +#: ../../library/curses.rst:1597 msgid "Backspace (unreliable)" msgstr "" -#: ../../library/curses.rst:1602 +#: ../../library/curses.rst:1599 msgid "Function keys. Up to 64 function keys are supported." msgstr "" -#: ../../library/curses.rst:1605 +#: ../../library/curses.rst:1602 msgid "Value of function key *n*" msgstr "" -#: ../../library/curses.rst:1607 +#: ../../library/curses.rst:1604 msgid "Delete line" msgstr "" -#: ../../library/curses.rst:1609 +#: ../../library/curses.rst:1606 msgid "Insert line" msgstr "" -#: ../../library/curses.rst:1611 +#: ../../library/curses.rst:1608 msgid "Delete character" msgstr "" -#: ../../library/curses.rst:1613 +#: ../../library/curses.rst:1610 msgid "Insert char or enter insert mode" msgstr "" -#: ../../library/curses.rst:1615 +#: ../../library/curses.rst:1612 msgid "Exit insert char mode" msgstr "" -#: ../../library/curses.rst:1617 +#: ../../library/curses.rst:1614 msgid "Clear screen" msgstr "" -#: ../../library/curses.rst:1619 +#: ../../library/curses.rst:1616 msgid "Clear to end of screen" msgstr "" -#: ../../library/curses.rst:1621 +#: ../../library/curses.rst:1618 msgid "Clear to end of line" msgstr "" -#: ../../library/curses.rst:1623 +#: ../../library/curses.rst:1620 msgid "Scroll 1 line forward" msgstr "" -#: ../../library/curses.rst:1625 +#: ../../library/curses.rst:1622 msgid "Scroll 1 line backward (reverse)" msgstr "" -#: ../../library/curses.rst:1627 +#: ../../library/curses.rst:1624 msgid "Next page" msgstr "" -#: ../../library/curses.rst:1629 +#: ../../library/curses.rst:1626 msgid "Previous page" msgstr "" -#: ../../library/curses.rst:1631 +#: ../../library/curses.rst:1628 msgid "Set tab" msgstr "" -#: ../../library/curses.rst:1633 +#: ../../library/curses.rst:1630 msgid "Clear tab" msgstr "" -#: ../../library/curses.rst:1635 +#: ../../library/curses.rst:1632 msgid "Clear all tabs" msgstr "" -#: ../../library/curses.rst:1637 +#: ../../library/curses.rst:1634 msgid "Enter or send (unreliable)" msgstr "" -#: ../../library/curses.rst:1639 +#: ../../library/curses.rst:1636 msgid "Soft (partial) reset (unreliable)" msgstr "" -#: ../../library/curses.rst:1641 +#: ../../library/curses.rst:1638 msgid "Reset or hard reset (unreliable)" msgstr "" -#: ../../library/curses.rst:1643 +#: ../../library/curses.rst:1640 msgid "Print" msgstr "" -#: ../../library/curses.rst:1645 +#: ../../library/curses.rst:1642 msgid "Home down or bottom (lower left)" msgstr "" -#: ../../library/curses.rst:1647 +#: ../../library/curses.rst:1644 msgid "Upper left of keypad" msgstr "" -#: ../../library/curses.rst:1649 +#: ../../library/curses.rst:1646 msgid "Upper right of keypad" msgstr "" -#: ../../library/curses.rst:1651 +#: ../../library/curses.rst:1648 msgid "Center of keypad" msgstr "" -#: ../../library/curses.rst:1653 +#: ../../library/curses.rst:1650 msgid "Lower left of keypad" msgstr "" -#: ../../library/curses.rst:1655 +#: ../../library/curses.rst:1652 msgid "Lower right of keypad" msgstr "" -#: ../../library/curses.rst:1657 +#: ../../library/curses.rst:1654 msgid "Back tab" msgstr "" -#: ../../library/curses.rst:1659 +#: ../../library/curses.rst:1656 msgid "Beg (beginning)" msgstr "" -#: ../../library/curses.rst:1661 +#: ../../library/curses.rst:1658 msgid "Cancel" msgstr "" -#: ../../library/curses.rst:1663 +#: ../../library/curses.rst:1660 msgid "Close" msgstr "" -#: ../../library/curses.rst:1665 +#: ../../library/curses.rst:1662 msgid "Cmd (command)" msgstr "" -#: ../../library/curses.rst:1667 +#: ../../library/curses.rst:1664 msgid "Copy" msgstr "" -#: ../../library/curses.rst:1669 +#: ../../library/curses.rst:1666 msgid "Create" msgstr "" -#: ../../library/curses.rst:1671 +#: ../../library/curses.rst:1668 msgid "End" msgstr "" -#: ../../library/curses.rst:1673 +#: ../../library/curses.rst:1670 msgid "Exit" msgstr "" -#: ../../library/curses.rst:1675 +#: ../../library/curses.rst:1672 msgid "Find" msgstr "" -#: ../../library/curses.rst:1677 +#: ../../library/curses.rst:1674 msgid "Help" msgstr "" -#: ../../library/curses.rst:1679 +#: ../../library/curses.rst:1676 msgid "Mark" msgstr "" -#: ../../library/curses.rst:1681 +#: ../../library/curses.rst:1678 msgid "Message" msgstr "" -#: ../../library/curses.rst:1683 +#: ../../library/curses.rst:1680 msgid "Move" msgstr "" -#: ../../library/curses.rst:1685 +#: ../../library/curses.rst:1682 msgid "Next" msgstr "" -#: ../../library/curses.rst:1687 +#: ../../library/curses.rst:1684 msgid "Open" msgstr "" -#: ../../library/curses.rst:1689 +#: ../../library/curses.rst:1686 msgid "Options" msgstr "" -#: ../../library/curses.rst:1691 +#: ../../library/curses.rst:1688 msgid "Prev (previous)" msgstr "" -#: ../../library/curses.rst:1693 +#: ../../library/curses.rst:1690 msgid "Redo" msgstr "" -#: ../../library/curses.rst:1695 +#: ../../library/curses.rst:1692 msgid "Ref (reference)" msgstr "" -#: ../../library/curses.rst:1697 +#: ../../library/curses.rst:1694 msgid "Refresh" msgstr "" -#: ../../library/curses.rst:1699 +#: ../../library/curses.rst:1696 msgid "Replace" msgstr "" -#: ../../library/curses.rst:1701 +#: ../../library/curses.rst:1698 msgid "Restart" msgstr "" -#: ../../library/curses.rst:1703 +#: ../../library/curses.rst:1700 msgid "Resume" msgstr "" -#: ../../library/curses.rst:1705 +#: ../../library/curses.rst:1702 msgid "Save" msgstr "" -#: ../../library/curses.rst:1707 +#: ../../library/curses.rst:1704 msgid "Shifted Beg (beginning)" msgstr "" -#: ../../library/curses.rst:1709 +#: ../../library/curses.rst:1706 msgid "Shifted Cancel" msgstr "" -#: ../../library/curses.rst:1711 +#: ../../library/curses.rst:1708 msgid "Shifted Command" msgstr "" -#: ../../library/curses.rst:1713 +#: ../../library/curses.rst:1710 msgid "Shifted Copy" msgstr "" -#: ../../library/curses.rst:1715 +#: ../../library/curses.rst:1712 msgid "Shifted Create" msgstr "" -#: ../../library/curses.rst:1717 +#: ../../library/curses.rst:1714 msgid "Shifted Delete char" msgstr "" -#: ../../library/curses.rst:1719 +#: ../../library/curses.rst:1716 msgid "Shifted Delete line" msgstr "" -#: ../../library/curses.rst:1721 +#: ../../library/curses.rst:1718 msgid "Select" msgstr "" -#: ../../library/curses.rst:1723 +#: ../../library/curses.rst:1720 msgid "Shifted End" msgstr "" -#: ../../library/curses.rst:1725 +#: ../../library/curses.rst:1722 msgid "Shifted Clear line" msgstr "" -#: ../../library/curses.rst:1727 +#: ../../library/curses.rst:1724 msgid "Shifted Exit" msgstr "" -#: ../../library/curses.rst:1729 +#: ../../library/curses.rst:1726 msgid "Shifted Find" msgstr "" -#: ../../library/curses.rst:1731 +#: ../../library/curses.rst:1728 msgid "Shifted Help" msgstr "" -#: ../../library/curses.rst:1733 +#: ../../library/curses.rst:1730 msgid "Shifted Home" msgstr "" -#: ../../library/curses.rst:1735 +#: ../../library/curses.rst:1732 msgid "Shifted Input" msgstr "" -#: ../../library/curses.rst:1737 +#: ../../library/curses.rst:1734 msgid "Shifted Left arrow" msgstr "" -#: ../../library/curses.rst:1739 +#: ../../library/curses.rst:1736 msgid "Shifted Message" msgstr "" -#: ../../library/curses.rst:1741 +#: ../../library/curses.rst:1738 msgid "Shifted Move" msgstr "" -#: ../../library/curses.rst:1743 +#: ../../library/curses.rst:1740 msgid "Shifted Next" msgstr "" -#: ../../library/curses.rst:1745 +#: ../../library/curses.rst:1742 msgid "Shifted Options" msgstr "" -#: ../../library/curses.rst:1747 +#: ../../library/curses.rst:1744 msgid "Shifted Prev" msgstr "" -#: ../../library/curses.rst:1749 +#: ../../library/curses.rst:1746 msgid "Shifted Print" msgstr "" -#: ../../library/curses.rst:1751 +#: ../../library/curses.rst:1748 msgid "Shifted Redo" msgstr "" -#: ../../library/curses.rst:1753 +#: ../../library/curses.rst:1750 msgid "Shifted Replace" msgstr "" -#: ../../library/curses.rst:1755 +#: ../../library/curses.rst:1752 msgid "Shifted Right arrow" msgstr "" -#: ../../library/curses.rst:1757 +#: ../../library/curses.rst:1754 msgid "Shifted Resume" msgstr "" -#: ../../library/curses.rst:1759 +#: ../../library/curses.rst:1756 msgid "Shifted Save" msgstr "" -#: ../../library/curses.rst:1761 +#: ../../library/curses.rst:1758 msgid "Shifted Suspend" msgstr "" -#: ../../library/curses.rst:1763 +#: ../../library/curses.rst:1760 msgid "Shifted Undo" msgstr "" -#: ../../library/curses.rst:1765 +#: ../../library/curses.rst:1762 msgid "Suspend" msgstr "" -#: ../../library/curses.rst:1767 +#: ../../library/curses.rst:1764 msgid "Undo" msgstr "" -#: ../../library/curses.rst:1769 +#: ../../library/curses.rst:1766 msgid "Mouse event has occurred" msgstr "" -#: ../../library/curses.rst:1771 +#: ../../library/curses.rst:1768 msgid "Terminal resize event" msgstr "" -#: ../../library/curses.rst:1773 +#: ../../library/curses.rst:1770 msgid "Maximum key value" msgstr "" -#: ../../library/curses.rst:1776 +#: ../../library/curses.rst:1773 msgid "" "On VT100s and their software emulations, such as X terminal emulators, there " "are normally at least four function keys (:const:`KEY_F1 `, :const:" @@ -2210,64 +2210,64 @@ msgid "" "keypad mappings are standard:" msgstr "" -#: ../../library/curses.rst:1785 +#: ../../library/curses.rst:1782 msgid "Keycap" msgstr "" -#: ../../library/curses.rst:1785 ../../library/curses.rst:1930 -#: ../../library/curses.rst:2059 +#: ../../library/curses.rst:1782 ../../library/curses.rst:1927 +#: ../../library/curses.rst:2053 msgid "Constant" msgstr "" -#: ../../library/curses.rst:1787 +#: ../../library/curses.rst:1784 msgid ":kbd:`Insert`" msgstr ":kbd:`Insert`" -#: ../../library/curses.rst:1787 +#: ../../library/curses.rst:1784 msgid "KEY_IC" msgstr "KEY_IC" -#: ../../library/curses.rst:1789 +#: ../../library/curses.rst:1786 msgid ":kbd:`Delete`" msgstr ":kbd:`Delete`" -#: ../../library/curses.rst:1789 +#: ../../library/curses.rst:1786 msgid "KEY_DC" msgstr "KEY_DC" -#: ../../library/curses.rst:1791 +#: ../../library/curses.rst:1788 msgid ":kbd:`Home`" msgstr ":kbd:`Home`" -#: ../../library/curses.rst:1791 +#: ../../library/curses.rst:1788 msgid "KEY_HOME" msgstr "KEY_HOME" -#: ../../library/curses.rst:1793 +#: ../../library/curses.rst:1790 msgid ":kbd:`End`" msgstr ":kbd:`End`" -#: ../../library/curses.rst:1793 +#: ../../library/curses.rst:1790 msgid "KEY_END" msgstr "KEY_END" -#: ../../library/curses.rst:1795 +#: ../../library/curses.rst:1792 msgid ":kbd:`Page Up`" msgstr ":kbd:`Page Up`" -#: ../../library/curses.rst:1795 +#: ../../library/curses.rst:1792 msgid "KEY_PPAGE" msgstr "KEY_PPAGE" -#: ../../library/curses.rst:1797 +#: ../../library/curses.rst:1794 msgid ":kbd:`Page Down`" msgstr ":kbd:`Page Down`" -#: ../../library/curses.rst:1797 +#: ../../library/curses.rst:1794 msgid "KEY_NPAGE" msgstr "KEY_NPAGE" -#: ../../library/curses.rst:1802 +#: ../../library/curses.rst:1799 msgid "" "The following table lists characters from the alternate character set. These " "are inherited from the VT100 terminal, and will generally be available on " @@ -2275,272 +2275,272 @@ msgid "" "available, curses falls back on a crude printable ASCII approximation." msgstr "" -#: ../../library/curses.rst:1809 +#: ../../library/curses.rst:1806 msgid "These are available only after :func:`initscr` has been called." msgstr "" -#: ../../library/curses.rst:1812 +#: ../../library/curses.rst:1809 msgid "ACS code" msgstr "" -#: ../../library/curses.rst:1814 +#: ../../library/curses.rst:1811 msgid "alternate name for upper-right corner" msgstr "" -#: ../../library/curses.rst:1816 +#: ../../library/curses.rst:1813 msgid "solid square block" msgstr "" -#: ../../library/curses.rst:1818 +#: ../../library/curses.rst:1815 msgid "board of squares" msgstr "" -#: ../../library/curses.rst:1820 +#: ../../library/curses.rst:1817 msgid "alternate name for horizontal line" msgstr "" -#: ../../library/curses.rst:1822 +#: ../../library/curses.rst:1819 msgid "alternate name for upper-left corner" msgstr "左上角的替代名稱" -#: ../../library/curses.rst:1824 +#: ../../library/curses.rst:1821 msgid "alternate name for top tee" msgstr "" -#: ../../library/curses.rst:1826 +#: ../../library/curses.rst:1823 msgid "bottom tee" msgstr "" -#: ../../library/curses.rst:1828 +#: ../../library/curses.rst:1825 msgid "bullet" msgstr "" -#: ../../library/curses.rst:1830 +#: ../../library/curses.rst:1827 msgid "checker board (stipple)" msgstr "" -#: ../../library/curses.rst:1832 +#: ../../library/curses.rst:1829 msgid "arrow pointing down" msgstr "" -#: ../../library/curses.rst:1834 +#: ../../library/curses.rst:1831 msgid "degree symbol" msgstr "" -#: ../../library/curses.rst:1836 +#: ../../library/curses.rst:1833 msgid "diamond" msgstr "" -#: ../../library/curses.rst:1838 +#: ../../library/curses.rst:1835 msgid "greater-than-or-equal-to" msgstr "" -#: ../../library/curses.rst:1840 +#: ../../library/curses.rst:1837 msgid "horizontal line" msgstr "" -#: ../../library/curses.rst:1842 +#: ../../library/curses.rst:1839 msgid "lantern symbol" msgstr "" -#: ../../library/curses.rst:1844 +#: ../../library/curses.rst:1841 msgid "left arrow" msgstr "" -#: ../../library/curses.rst:1846 +#: ../../library/curses.rst:1843 msgid "less-than-or-equal-to" msgstr "" -#: ../../library/curses.rst:1848 +#: ../../library/curses.rst:1845 msgid "lower-left corner" msgstr "" -#: ../../library/curses.rst:1850 +#: ../../library/curses.rst:1847 msgid "lower-right corner" msgstr "" -#: ../../library/curses.rst:1852 +#: ../../library/curses.rst:1849 msgid "left tee" msgstr "" -#: ../../library/curses.rst:1854 +#: ../../library/curses.rst:1851 msgid "not-equal sign" msgstr "" -#: ../../library/curses.rst:1856 +#: ../../library/curses.rst:1853 msgid "letter pi" msgstr "" -#: ../../library/curses.rst:1858 +#: ../../library/curses.rst:1855 msgid "plus-or-minus sign" msgstr "" -#: ../../library/curses.rst:1860 +#: ../../library/curses.rst:1857 msgid "big plus sign" msgstr "" -#: ../../library/curses.rst:1862 +#: ../../library/curses.rst:1859 msgid "right arrow" msgstr "" -#: ../../library/curses.rst:1864 +#: ../../library/curses.rst:1861 msgid "right tee" msgstr "" -#: ../../library/curses.rst:1866 +#: ../../library/curses.rst:1863 msgid "scan line 1" msgstr "" -#: ../../library/curses.rst:1868 +#: ../../library/curses.rst:1865 msgid "scan line 3" msgstr "" -#: ../../library/curses.rst:1870 +#: ../../library/curses.rst:1867 msgid "scan line 7" msgstr "" -#: ../../library/curses.rst:1872 +#: ../../library/curses.rst:1869 msgid "scan line 9" msgstr "" -#: ../../library/curses.rst:1874 +#: ../../library/curses.rst:1871 msgid "alternate name for lower-right corner" msgstr "" -#: ../../library/curses.rst:1876 +#: ../../library/curses.rst:1873 msgid "alternate name for vertical line" msgstr "" -#: ../../library/curses.rst:1878 +#: ../../library/curses.rst:1875 msgid "alternate name for right tee" msgstr "" -#: ../../library/curses.rst:1880 +#: ../../library/curses.rst:1877 msgid "alternate name for lower-left corner" msgstr "" -#: ../../library/curses.rst:1882 +#: ../../library/curses.rst:1879 msgid "alternate name for bottom tee" msgstr "" -#: ../../library/curses.rst:1884 +#: ../../library/curses.rst:1881 msgid "alternate name for left tee" msgstr "" -#: ../../library/curses.rst:1886 +#: ../../library/curses.rst:1883 msgid "alternate name for crossover or big plus" msgstr "" -#: ../../library/curses.rst:1888 +#: ../../library/curses.rst:1885 msgid "pound sterling" msgstr "" -#: ../../library/curses.rst:1890 +#: ../../library/curses.rst:1887 msgid "top tee" msgstr "" -#: ../../library/curses.rst:1892 +#: ../../library/curses.rst:1889 msgid "up arrow" msgstr "" -#: ../../library/curses.rst:1894 +#: ../../library/curses.rst:1891 msgid "upper-left corner" msgstr "" -#: ../../library/curses.rst:1896 +#: ../../library/curses.rst:1893 msgid "upper-right corner" msgstr "" -#: ../../library/curses.rst:1898 +#: ../../library/curses.rst:1895 msgid "vertical line" msgstr "" -#: ../../library/curses.rst:1901 +#: ../../library/curses.rst:1898 msgid "" "The following table lists mouse button constants used by :meth:`getmouse`:" msgstr "" -#: ../../library/curses.rst:1904 +#: ../../library/curses.rst:1901 msgid "Mouse button constant" msgstr "" -#: ../../library/curses.rst:1906 +#: ../../library/curses.rst:1903 msgid "Mouse button *n* pressed" msgstr "" -#: ../../library/curses.rst:1908 +#: ../../library/curses.rst:1905 msgid "Mouse button *n* released" msgstr "" -#: ../../library/curses.rst:1910 +#: ../../library/curses.rst:1907 msgid "Mouse button *n* clicked" msgstr "" -#: ../../library/curses.rst:1912 +#: ../../library/curses.rst:1909 msgid "Mouse button *n* double clicked" msgstr "" -#: ../../library/curses.rst:1914 +#: ../../library/curses.rst:1911 msgid "Mouse button *n* triple clicked" msgstr "" -#: ../../library/curses.rst:1916 +#: ../../library/curses.rst:1913 msgid "Shift was down during button state change" msgstr "" -#: ../../library/curses.rst:1918 +#: ../../library/curses.rst:1915 msgid "Control was down during button state change" msgstr "" -#: ../../library/curses.rst:1920 +#: ../../library/curses.rst:1917 msgid "Alt was down during button state change" msgstr "" -#: ../../library/curses.rst:1927 +#: ../../library/curses.rst:1924 msgid "The following table lists the predefined colors:" msgstr "" -#: ../../library/curses.rst:1930 +#: ../../library/curses.rst:1927 msgid "Color" msgstr "顏色" -#: ../../library/curses.rst:1932 +#: ../../library/curses.rst:1929 msgid "Black" msgstr "黑" -#: ../../library/curses.rst:1934 +#: ../../library/curses.rst:1931 msgid "Blue" msgstr "藍" -#: ../../library/curses.rst:1936 +#: ../../library/curses.rst:1933 msgid "Cyan (light greenish blue)" msgstr "" -#: ../../library/curses.rst:1938 +#: ../../library/curses.rst:1935 msgid "Green" msgstr "綠" -#: ../../library/curses.rst:1940 +#: ../../library/curses.rst:1937 msgid "Magenta (purplish red)" msgstr "" -#: ../../library/curses.rst:1942 +#: ../../library/curses.rst:1939 msgid "Red" msgstr "紅" -#: ../../library/curses.rst:1944 +#: ../../library/curses.rst:1941 msgid "White" msgstr "白" -#: ../../library/curses.rst:1946 +#: ../../library/curses.rst:1943 msgid "Yellow" msgstr "" -#: ../../library/curses.rst:1951 +#: ../../library/curses.rst:1948 msgid ":mod:`!curses.textpad` --- Text input widget for curses programs" msgstr "" -#: ../../library/curses.rst:1959 +#: ../../library/curses.rst:1953 msgid "" "The :mod:`!curses.textpad` module provides a :class:`Textbox` class that " "handles elementary text editing in a curses window, supporting a set of " @@ -2550,11 +2550,11 @@ msgid "" "purposes." msgstr "" -#: ../../library/curses.rst:1965 +#: ../../library/curses.rst:1959 msgid "The module :mod:`!curses.textpad` defines the following function:" msgstr ":mod:`!curses.textpad` 模組定義了以下函式:" -#: ../../library/curses.rst:1970 +#: ../../library/curses.rst:1964 msgid "" "Draw a rectangle. The first argument must be a window object; the remaining " "arguments are coordinates relative to that window. The second and third " @@ -2566,15 +2566,15 @@ msgid "" "will be drawn with ASCII dashes, vertical bars, and plus signs." msgstr "" -#: ../../library/curses.rst:1983 +#: ../../library/curses.rst:1977 msgid "Textbox objects" msgstr "" -#: ../../library/curses.rst:1985 +#: ../../library/curses.rst:1979 msgid "You can instantiate a :class:`Textbox` object as follows:" msgstr "" -#: ../../library/curses.rst:1990 +#: ../../library/curses.rst:1984 msgid "" "Return a textbox widget object. The *win* argument should be a curses :ref:" "`window ` object in which the textbox is to be " @@ -2585,11 +2585,11 @@ msgid "" "`stripspaces` flag is initially on." msgstr "" -#: ../../library/curses.rst:1998 +#: ../../library/curses.rst:1992 msgid ":class:`Textbox` objects have the following methods:" msgstr "" -#: ../../library/curses.rst:2003 +#: ../../library/curses.rst:1997 msgid "" "This is the entry point you will normally use. It accepts editing " "keystrokes until one of the termination keystrokes is entered. If " @@ -2600,170 +2600,170 @@ msgid "" "window are included is affected by the :attr:`stripspaces` attribute." msgstr "" -#: ../../library/curses.rst:2015 +#: ../../library/curses.rst:2009 msgid "" "Process a single command keystroke. Returns ``1`` to continue editing, or " "``0`` if a termination keystroke was processed. Here are the supported " "special keystrokes:" msgstr "" -#: ../../library/curses.rst:2020 ../../library/curses.rst:2059 +#: ../../library/curses.rst:2014 ../../library/curses.rst:2053 msgid "Keystroke" msgstr "" -#: ../../library/curses.rst:2020 +#: ../../library/curses.rst:2014 msgid "Action" msgstr "" -#: ../../library/curses.rst:2022 +#: ../../library/curses.rst:2016 msgid ":kbd:`Control-A`" msgstr ":kbd:`Control-A`" -#: ../../library/curses.rst:2022 +#: ../../library/curses.rst:2016 msgid "Go to left edge of window." msgstr "" -#: ../../library/curses.rst:2024 ../../library/curses.rst:2061 +#: ../../library/curses.rst:2018 ../../library/curses.rst:2055 msgid ":kbd:`Control-B`" msgstr ":kbd:`Control-B`" -#: ../../library/curses.rst:2024 +#: ../../library/curses.rst:2018 msgid "Cursor left, wrapping to previous line if appropriate." msgstr "" -#: ../../library/curses.rst:2027 +#: ../../library/curses.rst:2021 msgid ":kbd:`Control-D`" msgstr ":kbd:`Control-D`" -#: ../../library/curses.rst:2027 +#: ../../library/curses.rst:2021 msgid "Delete character under cursor." msgstr "" -#: ../../library/curses.rst:2029 +#: ../../library/curses.rst:2023 msgid ":kbd:`Control-E`" msgstr ":kbd:`Control-E`" -#: ../../library/curses.rst:2029 +#: ../../library/curses.rst:2023 msgid "Go to right edge (stripspaces off) or end of line (stripspaces on)." msgstr "" -#: ../../library/curses.rst:2032 ../../library/curses.rst:2063 +#: ../../library/curses.rst:2026 ../../library/curses.rst:2057 msgid ":kbd:`Control-F`" msgstr ":kbd:`Control-F`" -#: ../../library/curses.rst:2032 +#: ../../library/curses.rst:2026 msgid "Cursor right, wrapping to next line when appropriate." msgstr "" -#: ../../library/curses.rst:2035 +#: ../../library/curses.rst:2029 msgid ":kbd:`Control-G`" msgstr ":kbd:`Control-G`" -#: ../../library/curses.rst:2035 +#: ../../library/curses.rst:2029 msgid "Terminate, returning the window contents." msgstr "" -#: ../../library/curses.rst:2037 +#: ../../library/curses.rst:2031 msgid ":kbd:`Control-H`" msgstr ":kbd:`Control-H`" -#: ../../library/curses.rst:2037 +#: ../../library/curses.rst:2031 msgid "Delete character backward." msgstr "" -#: ../../library/curses.rst:2039 +#: ../../library/curses.rst:2033 msgid ":kbd:`Control-J`" msgstr ":kbd:`Control-J`" -#: ../../library/curses.rst:2039 +#: ../../library/curses.rst:2033 msgid "" "Terminate if the window is 1 line, otherwise move to the start of the next " "line." msgstr "" -#: ../../library/curses.rst:2043 +#: ../../library/curses.rst:2037 msgid ":kbd:`Control-K`" msgstr ":kbd:`Control-K`" -#: ../../library/curses.rst:2043 +#: ../../library/curses.rst:2037 msgid "If line is blank, delete it, otherwise clear to end of line." msgstr "" -#: ../../library/curses.rst:2046 +#: ../../library/curses.rst:2040 msgid ":kbd:`Control-L`" msgstr ":kbd:`Control-L`" -#: ../../library/curses.rst:2046 +#: ../../library/curses.rst:2040 msgid "Refresh screen." msgstr "" -#: ../../library/curses.rst:2048 ../../library/curses.rst:2067 +#: ../../library/curses.rst:2042 ../../library/curses.rst:2061 msgid ":kbd:`Control-N`" msgstr ":kbd:`Control-N`" -#: ../../library/curses.rst:2048 +#: ../../library/curses.rst:2042 msgid "Cursor down; move down one line." msgstr "" -#: ../../library/curses.rst:2050 +#: ../../library/curses.rst:2044 msgid ":kbd:`Control-O`" msgstr ":kbd:`Control-O`" -#: ../../library/curses.rst:2050 +#: ../../library/curses.rst:2044 msgid "Insert a blank line at cursor location." msgstr "" -#: ../../library/curses.rst:2052 ../../library/curses.rst:2065 +#: ../../library/curses.rst:2046 ../../library/curses.rst:2059 msgid ":kbd:`Control-P`" msgstr ":kbd:`Control-P`" -#: ../../library/curses.rst:2052 +#: ../../library/curses.rst:2046 msgid "Cursor up; move up one line." msgstr "" -#: ../../library/curses.rst:2055 +#: ../../library/curses.rst:2049 msgid "" "Move operations do nothing if the cursor is at an edge where the movement is " "not possible. The following synonyms are supported where possible:" msgstr "" -#: ../../library/curses.rst:2061 +#: ../../library/curses.rst:2055 msgid ":const:`~curses.KEY_LEFT`" msgstr ":const:`~curses.KEY_LEFT`" -#: ../../library/curses.rst:2063 +#: ../../library/curses.rst:2057 msgid ":const:`~curses.KEY_RIGHT`" msgstr ":const:`~curses.KEY_RIGHT`" -#: ../../library/curses.rst:2065 +#: ../../library/curses.rst:2059 msgid ":const:`~curses.KEY_UP`" msgstr ":const:`~curses.KEY_UP`" -#: ../../library/curses.rst:2067 +#: ../../library/curses.rst:2061 msgid ":const:`~curses.KEY_DOWN`" msgstr ":const:`~curses.KEY_DOWN`" -#: ../../library/curses.rst:2069 +#: ../../library/curses.rst:2063 msgid ":const:`~curses.KEY_BACKSPACE`" msgstr ":const:`~curses.KEY_BACKSPACE`" -#: ../../library/curses.rst:2069 +#: ../../library/curses.rst:2063 msgid ":kbd:`Control-h`" msgstr ":kbd:`Control-h`" -#: ../../library/curses.rst:2072 +#: ../../library/curses.rst:2066 msgid "" "All other keystrokes are treated as a command to insert the given character " "and move right (with line wrapping)." msgstr "" -#: ../../library/curses.rst:2078 +#: ../../library/curses.rst:2072 msgid "" "Return the window contents as a string; whether blanks in the window are " "included is affected by the :attr:`stripspaces` member." msgstr "" -#: ../../library/curses.rst:2084 +#: ../../library/curses.rst:2078 msgid "" "This attribute is a flag which controls the interpretation of blanks in the " "window. When it is on, trailing blanks on each line are ignored; any cursor " diff --git a/library/dataclasses.po b/library/dataclasses.po index dcfc903aa6f..b0cdf392a77 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-12 00:46+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -19,11 +19,11 @@ msgstr "" msgid ":mod:`!dataclasses` --- Data Classes" msgstr ":mod:`!dataclasses` --- Data Classes" -#: ../../library/dataclasses.rst:10 +#: ../../library/dataclasses.rst:7 msgid "**Source code:** :source:`Lib/dataclasses.py`" msgstr "**原始碼:**\\ :source:`Lib/dataclasses.py`" -#: ../../library/dataclasses.rst:14 +#: ../../library/dataclasses.rst:11 #, fuzzy msgid "" "This module provides a decorator and functions for automatically adding " @@ -35,7 +35,7 @@ msgstr "" "method>`,例如 :meth:`~object.__init__` 和 :meth:`~object.__repr__` 到使用者" "定義的類別。它最初在 :pep:`557` 中描述。" -#: ../../library/dataclasses.rst:19 +#: ../../library/dataclasses.rst:16 #, fuzzy msgid "" "The member variables to use in these generated methods are defined using :" @@ -44,7 +44,7 @@ msgstr "" "在這些生成的方法中使用的成員變數是使用 :pep:`526` 型別註釋定義的。例如,這段" "程式碼: ::" -#: ../../library/dataclasses.rst:22 +#: ../../library/dataclasses.rst:19 msgid "" "from dataclasses import dataclass\n" "\n" @@ -59,12 +59,12 @@ msgid "" " return self.unit_price * self.quantity_on_hand" msgstr "" -#: ../../library/dataclasses.rst:34 +#: ../../library/dataclasses.rst:31 #, fuzzy msgid "will add, among other things, a :meth:`!__init__` that looks like::" msgstr "將新增,除其他事項外,一個 :meth:`!__init__` 看起來像: ::" -#: ../../library/dataclasses.rst:36 +#: ../../library/dataclasses.rst:33 msgid "" "def __init__(self, name: str, unit_price: float, quantity_on_hand: int = " "0):\n" @@ -78,7 +78,7 @@ msgstr "" " self.unit_price = unit_price\n" " self.quantity_on_hand = quantity_on_hand" -#: ../../library/dataclasses.rst:41 +#: ../../library/dataclasses.rst:38 #, fuzzy msgid "" "Note that this method is automatically added to the class: it is not " @@ -87,11 +87,11 @@ msgstr "" "請注意,此方法會自動新增到類別中:它不會在上面顯示的 :class:`!InventoryItem` " "定義中直接指定。" -#: ../../library/dataclasses.rst:47 +#: ../../library/dataclasses.rst:44 msgid "Module contents" msgstr "模組內容" -#: ../../library/dataclasses.rst:51 +#: ../../library/dataclasses.rst:48 #, fuzzy msgid "" "This function is a :term:`decorator` that is used to add generated :term:" @@ -100,7 +100,7 @@ msgstr "" "此函式是一個 :term:`decorator`,用於將生成的\\ :term:`特殊方法 `\\新增到類別中,如下所述。" -#: ../../library/dataclasses.rst:54 +#: ../../library/dataclasses.rst:51 #, fuzzy msgid "" "The ``@dataclass`` decorator examines the class to find ``field``\\s. A " @@ -112,14 +112,14 @@ msgstr "" "term:`type annotation ` 的類別變數。除了下面描述的兩個例" "外,``@dataclass`` 中沒有任何內容檢查變數註釋中指定的型別。" -#: ../../library/dataclasses.rst:60 +#: ../../library/dataclasses.rst:57 #, fuzzy msgid "" "The order of the fields in all of the generated methods is the order in " "which they appear in the class definition." msgstr "所有生成的方法中欄位的順序是它們在類別定義中出現的順序。" -#: ../../library/dataclasses.rst:63 +#: ../../library/dataclasses.rst:60 msgid "" "The ``@dataclass`` decorator will add various \"dunder\" methods to the " "class, described below. If any of the added methods already exist in the " @@ -131,7 +131,7 @@ msgstr "" "存在任何新增的方法,則行為會取決於參數,如下方文件所述。裝飾器會回傳呼叫它的" "同一個類別;不會建立新類別。" -#: ../../library/dataclasses.rst:69 +#: ../../library/dataclasses.rst:66 #, fuzzy msgid "" "If ``@dataclass`` is used just as a simple decorator with no parameters, it " @@ -141,7 +141,7 @@ msgstr "" "如果 ``@dataclass`` 僅用作不帶參數的簡單裝飾器,它的行為就好像它具有此簽名中" "記錄的預設值一樣。也就是說,``@dataclass`` 的這三種用法是等價的: ::" -#: ../../library/dataclasses.rst:74 +#: ../../library/dataclasses.rst:71 msgid "" "@dataclass\n" "class C:\n" @@ -171,22 +171,22 @@ msgstr "" "class C:\n" " ..." -#: ../../library/dataclasses.rst:87 +#: ../../library/dataclasses.rst:84 msgid "The parameters to ``@dataclass`` are:" msgstr "``@dataclass`` 的參數是:" -#: ../../library/dataclasses.rst:89 +#: ../../library/dataclasses.rst:86 msgid "" "*init*: If true (the default), a :meth:`~object.__init__` method will be " "generated." msgstr "*init*:如果為真(預設值),將生成一個 :meth:`~object.__init__` 方法。" -#: ../../library/dataclasses.rst:92 +#: ../../library/dataclasses.rst:89 msgid "" "If the class already defines :meth:`!__init__`, this parameter is ignored." msgstr "如果該類別已經定義了 :meth:`!__init__`,則此參數會被忽略。" -#: ../../library/dataclasses.rst:95 +#: ../../library/dataclasses.rst:92 #, fuzzy msgid "" "*repr*: If true (the default), a :meth:`~object.__repr__` method will be " @@ -201,50 +201,50 @@ msgstr "" "包括標記為從 repr 中排除的欄位。例如:``InventoryItem(name='widget', " "unit_price=3.0, quantity_on_hand=10)``。" -#: ../../library/dataclasses.rst:102 +#: ../../library/dataclasses.rst:99 msgid "" "If the class already defines :meth:`!__repr__`, this parameter is ignored." msgstr "如果該類別已經定義了 :meth:`!__repr__`,則此參數會被忽略。" -#: ../../library/dataclasses.rst:105 +#: ../../library/dataclasses.rst:102 msgid "" "*eq*: If true (the default), an :meth:`~object.__eq__` method will be " "generated." msgstr "*eq*:如果為真(預設值),將生成一個 :meth:`~object.__eq__` 方法。" -#: ../../library/dataclasses.rst:108 +#: ../../library/dataclasses.rst:105 msgid "" "This method compares the class by comparing each field in order. Both " "instances in the comparison must be of the identical type." msgstr "此方法按順序比較每個欄位來比較類別。比較中的兩個實例必須屬於同一型別。" -#: ../../library/dataclasses.rst:111 +#: ../../library/dataclasses.rst:108 msgid "" "If the class already defines :meth:`!__eq__`, this parameter is ignored." msgstr "如果該類別已經定義了 :meth:`!__eq__`,則此參數會被忽略。" -#: ../../library/dataclasses.rst:113 +#: ../../library/dataclasses.rst:110 msgid "" "The generated ``__eq__`` method now compares each field individually (for " "example, ``self.a == other.a and self.b == other.b``), rather than comparing " "tuples of fields as in previous versions." msgstr "" -#: ../../library/dataclasses.rst:118 +#: ../../library/dataclasses.rst:115 msgid "" "This change makes the comparison faster but it may alter results in cases " "where attributes compare equal by identity but not by value (such as " "``float('nan')``)." msgstr "" -#: ../../library/dataclasses.rst:122 +#: ../../library/dataclasses.rst:119 msgid "" "In Python 3.12 and earlier, the comparison was performed by creating tuples " "of the fields and comparing them (for example, ``(self.a, self.b) == (other." "a, other.b)``)." msgstr "" -#: ../../library/dataclasses.rst:126 +#: ../../library/dataclasses.rst:123 #, fuzzy msgid "" "*order*: If true (the default is ``False``), :meth:`~object.__lt__`, :meth:" @@ -258,7 +258,7 @@ msgstr "" "生。它們按順序比較類別,就好像它是其欄位的元組一樣。比較中的兩個實例必須屬於" "同一型別。如果 *order* 為真且 *eq* 為假,則會引發 :exc:`ValueError`。" -#: ../../library/dataclasses.rst:133 +#: ../../library/dataclasses.rst:130 msgid "" "If the class already defines any of :meth:`!__lt__`, :meth:`!__le__`, :meth:" "`!__gt__`, or :meth:`!__ge__`, then :exc:`TypeError` is raised." @@ -266,7 +266,7 @@ msgstr "" "如果該類別已經定義了 :meth:`!__lt__`、:meth:`!__le__`、:meth:`!__gt__` 或 :" "meth:`!__ge__` 中的任何一個,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:137 +#: ../../library/dataclasses.rst:134 #, fuzzy msgid "" "*unsafe_hash*: If true, force ``dataclasses`` to create a :meth:`~object." @@ -277,7 +277,7 @@ msgstr "" "*unsafe_hash*:如果 ``False``\\ (預設值),將根據 *eq* 和 *frozen* 的設定生" "成一個 :meth:`~object.__hash__` 方法。" -#: ../../library/dataclasses.rst:143 +#: ../../library/dataclasses.rst:140 #, fuzzy msgid "" ":meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are " @@ -292,7 +292,7 @@ msgstr "" "複雜的屬性,它取決於程序設計師的意圖 :meth:`!__eq__` 的存在和行為,以及 " "dataclass 裝飾器中的 *eq* 和 *frozen* 旗標的值." -#: ../../library/dataclasses.rst:150 +#: ../../library/dataclasses.rst:147 #, fuzzy msgid "" "By default, ``@dataclass`` will not implicitly add a :meth:`~object." @@ -306,7 +306,7 @@ msgstr "" "類別屬性 ``__hash__ = None`` 對 Python 具有特定含義,如 :meth:`!__hash__` 文" "件中所述。" -#: ../../library/dataclasses.rst:156 +#: ../../library/dataclasses.rst:153 #, fuzzy msgid "" "If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, " @@ -322,7 +322,7 @@ msgstr "" "方法。如果你的類別在邏輯上是不可變的但仍然可以改變,則可能是這種情況。這是一" "個特殊的用例,應該仔細考慮。" -#: ../../library/dataclasses.rst:163 +#: ../../library/dataclasses.rst:160 #, fuzzy msgid "" "Here are the rules governing implicit creation of a :meth:`!__hash__` " @@ -334,7 +334,7 @@ msgstr "" "有顯式的 :meth:`!__hash__` 方法又設定 ``unsafe_hash=True``;這將導致 :exc:" "`TypeError`。" -#: ../../library/dataclasses.rst:168 +#: ../../library/dataclasses.rst:165 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, :" @@ -350,7 +350,7 @@ msgstr "" "__hash__` 將保持不變,這意味著將使用超類別的 :meth:`!__hash__` 方法(如果超類" "別是 :class:`object`,這意味著它將回退到基於 id 的雜湊)。" -#: ../../library/dataclasses.rst:176 +#: ../../library/dataclasses.rst:173 #, fuzzy msgid "" "*frozen*: If true (the default is ``False``), assigning to fields will " @@ -361,7 +361,7 @@ msgstr "" "凍結實例。如果 :meth:`~object.__setattr__` 或 :meth:`~object.__delattr__` 在" "類別中定義,則 :exc:`TypeError` 被引發。請參閱下面的討論。" -#: ../../library/dataclasses.rst:180 +#: ../../library/dataclasses.rst:177 msgid "" "If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in " "the class and *frozen* is true, then :exc:`TypeError` is raised." @@ -369,7 +369,7 @@ msgstr "" "如果類別中定義了 :meth:`~object.__setattr__` 或 :meth:`~object.__delattr__` " "且 *frozen* 為真,則會引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:183 +#: ../../library/dataclasses.rst:180 #, fuzzy msgid "" "*match_args*: If true (the default is ``True``), the :attr:`~object." @@ -384,7 +384,7 @@ msgstr "" "成,見上文)。如果為 false,或者類別中已經定義了 :attr:`!__match_args__`,則" "不會生成 :attr:`!__match_args__`。" -#: ../../library/dataclasses.rst:192 +#: ../../library/dataclasses.rst:189 #, fuzzy msgid "" "*kw_only*: If true (the default value is ``False``), then all fields will be " @@ -400,11 +400,11 @@ msgstr "" "類別的任何其他方面都沒有影響。有關詳細資訊,請參閱 :term:`parameter` 詞彙表條" "目。另請參閱 :const:`KW_ONLY` 部分。" -#: ../../library/dataclasses.rst:200 +#: ../../library/dataclasses.rst:197 msgid "Keyword-only fields are not included in :attr:`!__match_args__`." msgstr "" -#: ../../library/dataclasses.rst:204 +#: ../../library/dataclasses.rst:201 #, fuzzy msgid "" "*slots*: If true (the default is ``False``), :attr:`~object.__slots__` " @@ -416,7 +416,7 @@ msgstr "" "屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義," "則 :exc:`TypeError` 被引發。" -#: ../../library/dataclasses.rst:210 +#: ../../library/dataclasses.rst:207 msgid "" "Passing parameters to a base class :meth:`~object.__init_subclass__` when " "using ``slots=True`` will result in a :exc:`TypeError`. Either use " @@ -424,7 +424,7 @@ msgid "" "workaround. See :gh:`91126` for full details." msgstr "" -#: ../../library/dataclasses.rst:218 +#: ../../library/dataclasses.rst:215 #, fuzzy msgid "" "If a field name is already included in the :attr:`!__slots__` of a base " @@ -440,7 +440,7 @@ msgstr "" "夠確定繼承的插槽,基底類別 :attr:`!__slots__` 可以是任何可疊代的,但*不是*疊" "代器。" -#: ../../library/dataclasses.rst:228 +#: ../../library/dataclasses.rst:225 #, fuzzy msgid "" "*weakref_slot*: If true (the default is ``False``), add a slot named " @@ -452,14 +452,14 @@ msgstr "" "插槽,這是使實例可弱引用所必需的。在沒有指定 ``slots=True`` 的情況下指定 " "``weakref_slot=True`` 是錯誤的。" -#: ../../library/dataclasses.rst:236 +#: ../../library/dataclasses.rst:233 #, fuzzy msgid "" "``field``\\s may optionally specify a default value, using normal Python " "syntax::" msgstr "``field``\\s 可以選擇指定一個預設值,使用普通的 Python 語法: ::" -#: ../../library/dataclasses.rst:239 +#: ../../library/dataclasses.rst:236 msgid "" "@dataclass\n" "class C:\n" @@ -467,7 +467,7 @@ msgid "" " b: int = 0 # assign a default value for 'b'" msgstr "" -#: ../../library/dataclasses.rst:244 +#: ../../library/dataclasses.rst:241 #, fuzzy msgid "" "In this example, both :attr:`!a` and :attr:`!b` will be included in the " @@ -476,11 +476,11 @@ msgstr "" "在此示例中,:attr:`!a` 和 :attr:`!b` 都將包含在新增的 :meth:`~object." "__init__` 方法中,該方法將定義為: ::" -#: ../../library/dataclasses.rst:247 +#: ../../library/dataclasses.rst:244 msgid "def __init__(self, a: int, b: int = 0):" msgstr "def __init__(self, a: int, b: int = 0):" -#: ../../library/dataclasses.rst:249 +#: ../../library/dataclasses.rst:246 #, fuzzy msgid "" ":exc:`TypeError` will be raised if a field without a default value follows a " @@ -490,7 +490,7 @@ msgstr "" ":exc:`TypeError` 如果沒有預設值的欄位跟在具有預設值的欄位之後,將引發。無論這" "發生在單個類別中還是作為類別繼承的結果,都是如此。" -#: ../../library/dataclasses.rst:255 +#: ../../library/dataclasses.rst:252 #, fuzzy msgid "" "For common and simple use cases, no other functionality is required. There " @@ -503,7 +503,7 @@ msgstr "" "位資訊。為了滿足這種對附加資訊的需求,你可以透過呼叫提供的 :func:`!field` 函" "式來替換預設欄位值。例如: ::" -#: ../../library/dataclasses.rst:261 +#: ../../library/dataclasses.rst:258 msgid "" "@dataclass\n" "class C:\n" @@ -519,23 +519,22 @@ msgstr "" "c = C()\n" "c.mylist += [1, 2, 3]" -#: ../../library/dataclasses.rst:268 -#, fuzzy +#: ../../library/dataclasses.rst:265 msgid "" -"As shown above, the :const:`MISSING` value is a sentinel object used to " -"detect if some parameters are provided by the user. This sentinel is used " -"because ``None`` is a valid value for some parameters with a distinct " +"As shown above, the :const:`MISSING` value is a :class:`sentinel` object " +"used to detect if some parameters are provided by the user. This sentinel is " +"used because ``None`` is a valid value for some parameters with a distinct " "meaning. No code should directly use the :const:`MISSING` value." msgstr "" -"如上所示,:const:`MISSING` 值是一個哨兵物件,用於檢測某些參數是否由使用者提" -"供。使用此標記是因為 ``None`` 對於某些具有不同含義的參數是有效值。任何程式碼" -"都不應直接使用 :const:`MISSING` 值。" +"如上所示,:const:`MISSING` 值是一個 :class:`sentinel` 物件,用於檢測某些參數" +"是否由使用者提供。使用此標記是因為 ``None`` 對於某些具有不同含義的參數是有效" +"值。任何程式碼都不應直接使用 :const:`MISSING` 值。" -#: ../../library/dataclasses.rst:273 +#: ../../library/dataclasses.rst:270 msgid "The parameters to :func:`!field` are:" msgstr ":func:`!field` 的參數是:" -#: ../../library/dataclasses.rst:275 +#: ../../library/dataclasses.rst:272 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 " @@ -544,7 +543,7 @@ msgstr "" "*default*:如果有提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` " "呼叫本身會替換預設值的正常位置。" -#: ../../library/dataclasses.rst:279 +#: ../../library/dataclasses.rst:276 #, fuzzy msgid "" "*default_factory*: If provided, it must be a zero-argument callable that " @@ -557,7 +556,7 @@ msgstr "" "時將被呼叫。除其他用途外,這可用於指定具有可變預設值的欄位,如下所述。同時指" "定 *default* 和 *default_factory* 是錯誤的。" -#: ../../library/dataclasses.rst:285 +#: ../../library/dataclasses.rst:282 #, fuzzy msgid "" "*init*: If true (the default), this field is included as a parameter to the " @@ -566,7 +565,7 @@ msgstr "" "*init*:如果為 true(預設值),則此欄位將作為生成的 :meth:`~object.__init__` " "方法的參數包含在內。" -#: ../../library/dataclasses.rst:288 +#: ../../library/dataclasses.rst:285 #, fuzzy msgid "" "*repr*: If true (the default), this field is included in the string returned " @@ -575,7 +574,7 @@ msgstr "" "*repr*:如果為真(預設值),則此欄位包含在生成的 :meth:`~object.__repr__` 方" "法回傳的字串中。" -#: ../../library/dataclasses.rst:291 +#: ../../library/dataclasses.rst:288 #, fuzzy msgid "" "*hash*: This can be a bool or ``None``. If true, this field is included in " @@ -591,7 +590,7 @@ msgstr "" "是預期的行為。如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定" "為 ``None`` 以外的任何值。" -#: ../../library/dataclasses.rst:299 +#: ../../library/dataclasses.rst:296 #, fuzzy msgid "" "One possible reason to set ``hash=False`` but ``compare=True`` would be if a " @@ -604,7 +603,7 @@ msgstr "" "湊值的成本很高,則需要該欄位進行相等性測試,並且還有其他欄位有助於型別的雜湊" "值。即使一個欄位被排除在雜湊之外,它仍然會被用於比較。" -#: ../../library/dataclasses.rst:305 +#: ../../library/dataclasses.rst:302 #, fuzzy msgid "" "*compare*: If true (the default), this field is included in the generated " @@ -614,7 +613,7 @@ msgstr "" "*compare*:如果為真(預設值),則此欄位包含在生成的相等和比較方法中(:meth:" "`~object.__eq__`、:meth:`~object.__gt__` 等)。" -#: ../../library/dataclasses.rst:309 +#: ../../library/dataclasses.rst:306 #, fuzzy msgid "" "*metadata*: This can be a mapping or ``None``. ``None`` is treated as an " @@ -629,7 +628,7 @@ msgstr "" "不被資料類別使用,而是作為第三方擴充機制提供的。多個第三方可以各自擁有自己的" "密鑰,用作元資料中的命名空間。" -#: ../../library/dataclasses.rst:317 +#: ../../library/dataclasses.rst:314 #, fuzzy msgid "" "*kw_only*: If true, this field will be marked as keyword-only. This is used " @@ -638,15 +637,15 @@ msgstr "" "*kw_only*:如果為真,該欄位將被標記為僅限關鍵字。這在計算生成的 :meth:" "`~object.__init__` 方法的參數時使用。" -#: ../../library/dataclasses.rst:321 +#: ../../library/dataclasses.rst:318 msgid "Keyword-only fields are also not included in :attr:`!__match_args__`." msgstr "" -#: ../../library/dataclasses.rst:325 +#: ../../library/dataclasses.rst:322 msgid "*doc*: optional docstring for this field." msgstr "" -#: ../../library/dataclasses.rst:329 +#: ../../library/dataclasses.rst:326 #, fuzzy msgid "" "If the default value of a field is specified by a call to :func:`!field`, " @@ -662,7 +661,7 @@ msgstr "" "在 :func:`@dataclass ` 裝飾器運行後,類別屬性將全部包含欄位的預設" "值,就像預設值本身已指定一樣。例如,在: ::" -#: ../../library/dataclasses.rst:338 +#: ../../library/dataclasses.rst:335 msgid "" "@dataclass\n" "class C:\n" @@ -678,7 +677,7 @@ msgstr "" " z: int = field(repr=False, default=10)\n" " t: int = 20" -#: ../../library/dataclasses.rst:345 +#: ../../library/dataclasses.rst:342 #, fuzzy msgid "" "The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!" @@ -688,7 +687,13 @@ msgstr "" "類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,類別屬" "性 :attr:`!C.x` 和 :attr:`!C.y` 將不會放。" -#: ../../library/dataclasses.rst:351 +#: ../../library/dataclasses.rst:346 +msgid "" +"If *metadata* is ``None``, use an empty :class:`frozendict`, instead of a :" +"func:`~types.MappingProxyType` of an empty :class:`dict`." +msgstr "" + +#: ../../library/dataclasses.rst:352 #, fuzzy msgid "" ":class:`!Field` objects describe each defined field. These objects are " @@ -700,15 +705,15 @@ msgstr "" "`fields` 模組級方法回傳(見下文)。使用者不應該直接實例化 :class:`!Field` 物" "件。它記錄的屬性是:" -#: ../../library/dataclasses.rst:356 +#: ../../library/dataclasses.rst:357 msgid ":attr:`!name`: The name of the field." msgstr ":attr:`!name`:欄位的名稱。" -#: ../../library/dataclasses.rst:357 +#: ../../library/dataclasses.rst:358 msgid ":attr:`!type`: The type of the field." msgstr ":attr:`!type`:欄位的型別。" -#: ../../library/dataclasses.rst:358 +#: ../../library/dataclasses.rst:359 #, fuzzy msgid "" ":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :" @@ -719,14 +724,14 @@ msgstr "" "attr:`!hash`、:attr:`!compare`, :attr:`!metadata` 和 :attr:`!kw_only` 有與它" "們在 :func:`field` 函式中的含義和值相同。" -#: ../../library/dataclasses.rst:362 +#: ../../library/dataclasses.rst:363 #, fuzzy msgid "" "Other attributes may exist, but they are private and must not be inspected " "or relied on." msgstr "可能存在其他屬性,但它們是私有的,不得檢查或依賴。" -#: ../../library/dataclasses.rst:367 +#: ../../library/dataclasses.rst:368 msgid "" "``InitVar[T]`` type annotations describe variables that are :ref:`init-only " "`. Fields annotated with :class:`!InitVar` " @@ -735,7 +740,7 @@ msgid "" "meth:`~object.__init__` and an optional :meth:`__post_init__`." msgstr "" -#: ../../library/dataclasses.rst:376 +#: ../../library/dataclasses.rst:377 #, fuzzy msgid "" "Returns a tuple of :class:`Field` objects that define the fields for this " @@ -747,24 +752,23 @@ msgstr "" "實例。如果未傳遞資料類別或其中一個實例,則引發 :exc:`TypeError`。不回傳 " "``ClassVar`` 或 ``InitVar`` 的偽欄位。" -#: ../../library/dataclasses.rst:383 -#, fuzzy +#: ../../library/dataclasses.rst:384 msgid "" "Converts the dataclass *obj* to a dict (by using the factory function " "*dict_factory*). Each dataclass is converted to a dict of its fields, as " -"``name: value`` pairs. dataclasses, dicts, lists, and tuples are recursed " -"into. Other objects are copied with :func:`copy.deepcopy`." +"``name: value`` pairs. dataclasses, dicts, frozendicts, lists, and tuples " +"are recursed into. Other objects are copied with :func:`copy.deepcopy`." msgstr "" "將資料類別 *obj* 轉換為字典(透過使用工廠函式 *dict_factory*)。每個資料類別" -"都被轉換為其欄位的字典,作為 ``name: value`` 對。資料類別、字典、列表和元組被" -"遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。" +"都被轉換為其欄位的字典,作為 ``name: value`` 對。資料類別、字典、frozendict、" +"列表和元組被遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:389 +#: ../../library/dataclasses.rst:390 #, fuzzy msgid "Example of using :func:`!asdict` on nested dataclasses::" msgstr "在嵌套資料類別上使用 :func:`!asdict` 的範例: ::" -#: ../../library/dataclasses.rst:391 +#: ../../library/dataclasses.rst:392 msgid "" "@dataclass\n" "class Point:\n" @@ -796,38 +800,37 @@ 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:406 ../../library/dataclasses.rst:426 +#: ../../library/dataclasses.rst:407 ../../library/dataclasses.rst:427 #, fuzzy msgid "To create a shallow copy, the following workaround may be used::" msgstr "要建立淺複製,可以使用以下解決方法:" -#: ../../library/dataclasses.rst:408 +#: ../../library/dataclasses.rst:409 msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}" msgstr "{field.name: getattr(obj, field.name) for field in fields(obj)}" -#: ../../library/dataclasses.rst:410 +#: ../../library/dataclasses.rst:411 #, fuzzy msgid "" ":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance." msgstr ":func:`!asdict` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:415 -#, fuzzy +#: ../../library/dataclasses.rst:416 msgid "" "Converts the dataclass *obj* to a tuple (by using the factory function " "*tuple_factory*). Each dataclass is converted to a tuple of its field " -"values. dataclasses, dicts, lists, and tuples are recursed into. Other " -"objects are copied with :func:`copy.deepcopy`." +"values. dataclasses, dicts, frozendicts, lists, and tuples are recursed " +"into. Other objects are copied with :func:`copy.deepcopy`." msgstr "" "將資料類別 *obj* 轉換為元組(透過使用工廠函式 *tuple_factory*)。每個資料類別" -"都被轉換為其欄位值的元組。資料類別、字典、列表和元組被遞迴到。其他物件使用 :" -"func:`copy.deepcopy` 複製。" +"都被轉換為其欄位值的元組。資料類別、字典、frozendict、列表和元組被遞迴到。其" +"他物件使用 :func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:421 +#: ../../library/dataclasses.rst:422 msgid "Continuing from the previous example::" msgstr "從前面的例子繼續: ::" -#: ../../library/dataclasses.rst:423 +#: ../../library/dataclasses.rst:424 msgid "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" @@ -835,11 +838,11 @@ msgstr "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" -#: ../../library/dataclasses.rst:428 +#: ../../library/dataclasses.rst:429 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:430 +#: ../../library/dataclasses.rst:431 #, fuzzy msgid "" ":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass " @@ -847,7 +850,7 @@ msgid "" msgstr "" ":func:`!astuple` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:435 +#: ../../library/dataclasses.rst:436 #, fuzzy msgid "" "Creates a new dataclass with name *cls_name*, fields as defined in *fields*, " @@ -867,13 +870,13 @@ msgstr "" "``kw_only`` 的值, ``slots`` 和 ``weakref_slot`` 與它們在 :func:`dataclass` 中" "的含義相同。" -#: ../../library/dataclasses.rst:445 +#: ../../library/dataclasses.rst:446 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:449 +#: ../../library/dataclasses.rst:450 msgid "" "The *decorator* parameter is a callable that will be used to create the " "dataclass. It should take the class object as a first argument and the same " @@ -881,7 +884,7 @@ msgid "" "function is used." msgstr "" -#: ../../library/dataclasses.rst:454 +#: ../../library/dataclasses.rst:455 #, fuzzy msgid "" "This function is not strictly required, because any Python mechanism for " @@ -893,7 +896,7 @@ msgstr "" "別的 Python 機制都可以應用 :func:`dataclass` 函式將該類別轉換為資料類別。提供" "此功能是為了方便。例如: ::" -#: ../../library/dataclasses.rst:460 +#: ../../library/dataclasses.rst:461 msgid "" "C = make_dataclass('C',\n" " [('x', int),\n" @@ -907,11 +910,11 @@ msgstr "" " ('z', int, field(default=5))],\n" " namespace={'add_one': lambda self: self.x + 1})" -#: ../../library/dataclasses.rst:466 +#: ../../library/dataclasses.rst:467 msgid "Is equivalent to::" msgstr "相當於: ::" -#: ../../library/dataclasses.rst:468 +#: ../../library/dataclasses.rst:469 msgid "" "@dataclass\n" "class C:\n" @@ -931,11 +934,11 @@ msgstr "" " def add_one(self):\n" " return self.x + 1" -#: ../../library/dataclasses.rst:477 +#: ../../library/dataclasses.rst:478 msgid "Added the *decorator* parameter." msgstr "新增了 *decorator* 參數。" -#: ../../library/dataclasses.rst:482 +#: ../../library/dataclasses.rst:483 msgid "" "Creates a new object of the same type as *obj*, replacing fields with values " "from *changes*. If *obj* is not a Data Class, raises :exc:`TypeError`. If " @@ -946,7 +949,7 @@ msgstr "" "``obj`` 不是資料類別則引發 :exc:`TypeError`。如果 ``changes`` 中的鍵不是給定 " "dataclass 的欄位則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:487 +#: ../../library/dataclasses.rst:488 #, fuzzy msgid "" "The newly returned object is created by calling the :meth:`~object.__init__` " @@ -956,7 +959,7 @@ msgstr "" "新回傳的物件是透過呼叫資料類別的 :meth:`~object.__init__` 方法建立的。這確" "保 :meth:`__post_init__`\\ (如果存在)也被呼叫。" -#: ../../library/dataclasses.rst:491 +#: ../../library/dataclasses.rst:492 #, fuzzy msgid "" "Init-only variables without default values, if any exist, must be specified " @@ -966,7 +969,7 @@ msgstr "" "沒有預設值的僅初始化變數(如果存在)必須在呼叫 :func:`replace` 時指定,以便它" "們可以傳遞給 :meth:`__init__` 和 :meth:`__post_init__`。" -#: ../../library/dataclasses.rst:495 +#: ../../library/dataclasses.rst:496 #, fuzzy msgid "" "It is an error for *changes* to contain any fields that are defined as " @@ -975,7 +978,7 @@ msgstr "" "*changes* 包含任何定義為具有 ``init=False`` 的欄位是錯誤的。在這種情況下將引" "發 :exc:`ValueError`。" -#: ../../library/dataclasses.rst:499 +#: ../../library/dataclasses.rst:500 #, fuzzy msgid "" "Be forewarned about how ``init=False`` fields work during a call to :func:`!" @@ -992,13 +995,13 @@ msgstr "" "建構函式可能是明智的,或者可能是處理實例複製的自訂 :func:`!replace` (或類似" "命名的)方法。" -#: ../../library/dataclasses.rst:508 +#: ../../library/dataclasses.rst:509 msgid "" "Dataclass instances are also supported by generic function :func:`copy." "replace`." msgstr "" -#: ../../library/dataclasses.rst:512 +#: ../../library/dataclasses.rst:513 msgid "" "Return ``True`` if its parameter is a dataclass (including subclasses of a " "dataclass, but not including :ref:`generic aliases `) or " @@ -1007,7 +1010,7 @@ msgstr "" "如果它的參數是一個資料類別(包含一個資料類別的子類別,但不包含\\ :ref:`通用別" "名 `)或一個實例則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/dataclasses.rst:516 +#: ../../library/dataclasses.rst:517 #, fuzzy msgid "" "If you need to know if a class is an instance of a dataclass (and not a " @@ -1017,7 +1020,7 @@ msgstr "" "如果你需要知道一個類別是否是資料類別的實例(而不是資料類別本身),那麼新增一" "個進一步的檢查 ``not isinstance(obj, type)``: ::" -#: ../../library/dataclasses.rst:520 +#: ../../library/dataclasses.rst:521 msgid "" "def is_dataclass_instance(obj):\n" " return is_dataclass(obj) and not isinstance(obj, type)" @@ -1025,35 +1028,39 @@ msgstr "" "def is_dataclass_instance(obj):\n" " return is_dataclass(obj) and not isinstance(obj, type)" -#: ../../library/dataclasses.rst:525 -#, fuzzy -msgid "A sentinel value signifying a missing default or default_factory." -msgstr "表示缺少 default 或 default_factory 的標記值。" +#: ../../library/dataclasses.rst:526 +msgid "" +"A :class:`sentinel` object signifying a missing default or *default_factory*." +msgstr "表示缺少 default 或 *default_factory* 的 :class:`sentinel` 物件。" -#: ../../library/dataclasses.rst:529 -#, fuzzy +#: ../../library/dataclasses.rst:528 +msgid ":const:`!MISSING` is now a :class:`sentinel` object." +msgstr "" + +#: ../../library/dataclasses.rst:533 msgid "" -"A sentinel value used as a type annotation. Any fields after a pseudo-field " -"with the type of :const:`!KW_ONLY` are marked as keyword-only fields. Note " -"that a pseudo-field of type :const:`!KW_ONLY` is otherwise completely " -"ignored. This includes the name of such a field. By convention, a name of " -"``_`` is used for a :const:`!KW_ONLY` field. Keyword-only fields signify :" -"meth:`~object.__init__` parameters that must be specified as keywords when " -"the class is instantiated." +"A :class:`sentinel` object used as a type annotation. Any fields after a " +"pseudo-field with the type of :const:`!KW_ONLY` are marked as keyword-only " +"fields. Note that a pseudo-field of type :const:`!KW_ONLY` is otherwise " +"completely ignored. This includes the name of such a field. By convention, " +"a name of ``_`` is used for a :const:`!KW_ONLY` field. Keyword-only fields " +"signify :meth:`~object.__init__` parameters that must be specified as " +"keywords when the class is instantiated." msgstr "" -"用作型別註釋的標記值。型別為 :const:`!KW_ONLY` 的偽欄位之後的任何欄位都被標記" -"為僅關鍵字欄位。請注意,:const:`!KW_ONLY` 型別的偽欄位將被完全忽略。這包括此" -"類欄位的名稱。按照慣例,名稱 ``_`` 用於 :const:`!KW_ONLY` 欄位。僅關鍵字欄位" -"表示 :meth:`~object.__init__` 參數,在實例化類別時必須將其指定為關鍵字。" +"用作型別註釋的 :class:`sentinel` 物件。型別為 :const:`!KW_ONLY` 的偽欄位之後" +"的任何欄位都被標記為僅關鍵字欄位。請注意,:const:`!KW_ONLY` 型別的偽欄位將被" +"完全忽略。這包括此類欄位的名稱。按照慣例,名稱 ``_`` 用於 :const:`!KW_ONLY` " +"欄位。僅關鍵字欄位表示 :meth:`~object.__init__` 參數,在實例化類別時必須將其" +"指定為關鍵字。" -#: ../../library/dataclasses.rst:538 +#: ../../library/dataclasses.rst:542 #, fuzzy msgid "" "In this example, the fields ``y`` and ``z`` will be marked as keyword-only " "fields::" msgstr "在此示例中,欄位 ``y`` 和 ``z`` 將被標記為僅關鍵字欄位: ::" -#: ../../library/dataclasses.rst:540 +#: ../../library/dataclasses.rst:544 msgid "" "@dataclass\n" "class Point:\n" @@ -1073,14 +1080,18 @@ msgstr "" "\n" "p = Point(0, y=1.5, z=2.0)" -#: ../../library/dataclasses.rst:549 +#: ../../library/dataclasses.rst:553 #, 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:556 +#: ../../library/dataclasses.rst:558 +msgid ":const:`!KW_ONLY` is now a :class:`sentinel` object." +msgstr "" + +#: ../../library/dataclasses.rst:563 #, fuzzy msgid "" "Raised when an implicitly defined :meth:`~object.__setattr__` or :meth:" @@ -1090,12 +1101,12 @@ msgstr "" "當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :" "meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。" -#: ../../library/dataclasses.rst:563 +#: ../../library/dataclasses.rst:570 #, fuzzy msgid "Post-init processing" msgstr "後初始化處理" -#: ../../library/dataclasses.rst:567 +#: ../../library/dataclasses.rst:574 #, fuzzy msgid "" "When defined on the class, it will be called by the generated :meth:`~object." @@ -1111,14 +1122,14 @@ msgstr "" "將按照它們在類別中定義的順序傳遞給 :meth:`!__post_init__` 。如果沒有生成 :" "meth:`!__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。" -#: ../../library/dataclasses.rst:574 +#: ../../library/dataclasses.rst:581 #, 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:577 +#: ../../library/dataclasses.rst:584 msgid "" "@dataclass\n" "class C:\n" @@ -1138,7 +1149,7 @@ msgstr "" " def __post_init__(self):\n" " self.c = self.a + self.b" -#: ../../library/dataclasses.rst:586 +#: ../../library/dataclasses.rst:593 #, fuzzy msgid "" "The :meth:`~object.__init__` method generated by :deco:`dataclass` does not " @@ -1150,7 +1161,7 @@ msgstr "" "類別 :meth:`!__init__` 方法。如果基底類別有一個必須呼叫的 :meth:`!__init__` " "方法,通常在 :meth:`__post_init__` 方法中呼叫此方法: ::" -#: ../../library/dataclasses.rst:591 +#: ../../library/dataclasses.rst:598 msgid "" "class Rectangle:\n" " def __init__(self, height, width):\n" @@ -1176,7 +1187,7 @@ msgstr "" " def __post_init__(self):\n" " super().__init__(self.side, self.side)" -#: ../../library/dataclasses.rst:603 +#: ../../library/dataclasses.rst:610 #, fuzzy msgid "" "Note, however, that in general the dataclass-generated :meth:`!__init__` " @@ -1186,7 +1197,7 @@ msgstr "" "但是請注意,通常不需要呼叫資料類別生成的 :meth:`!__init__` 方法,因為衍生資料" "類別將負責初始化作為資料類別本身的任何基底類別的所有欄位。" -#: ../../library/dataclasses.rst:607 +#: ../../library/dataclasses.rst:614 #, fuzzy msgid "" "See the section below on init-only variables for ways to pass parameters to :" @@ -1196,11 +1207,11 @@ msgstr "" "請參閱下面有關僅初始化變數的部分,了解將參數傳遞給 :meth:`!__post_init__` 的" "方法。另請參閱有關 :func:`replace` 如何處理 ``init=False`` 欄位的警告。" -#: ../../library/dataclasses.rst:614 +#: ../../library/dataclasses.rst:621 msgid "Class variables" msgstr "類別變數" -#: ../../library/dataclasses.rst:616 +#: ../../library/dataclasses.rst:623 #, fuzzy msgid "" "One of the few places where :deco:`dataclass` actually inspects the type of " @@ -1216,12 +1227,12 @@ msgstr "" "外,並被資料類別機制忽略。模組級 :func:`fields` 函式不會回傳此類別 " "``ClassVar`` 偽欄位。" -#: ../../library/dataclasses.rst:627 +#: ../../library/dataclasses.rst:634 #, fuzzy msgid "Init-only variables" msgstr "僅初始化變數" -#: ../../library/dataclasses.rst:629 +#: ../../library/dataclasses.rst:636 #, fuzzy msgid "" "Another place where :deco:`dataclass` inspects a type annotation is to " @@ -1240,14 +1251,14 @@ msgstr "" "的 :meth:`~object.__init__` 方法,並傳遞給可選的 :meth:`__post_init__` 方法。" "它們不被資料類別使用。" -#: ../../library/dataclasses.rst:639 +#: ../../library/dataclasses.rst:646 #, 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:642 +#: ../../library/dataclasses.rst:649 msgid "" "@dataclass\n" "class C:\n" @@ -1273,7 +1284,7 @@ msgstr "" "\n" "c = C(10, database=my_database)" -#: ../../library/dataclasses.rst:654 +#: ../../library/dataclasses.rst:661 #, fuzzy msgid "" "In this case, :func:`fields` will return :class:`Field` objects for :attr:`!" @@ -1282,11 +1293,11 @@ msgstr "" "在這種情況下,:func:`fields` 將為 :attr:`!i` 和 :attr:`!j` 回傳 :class:" "`Field` 物件,但不會為 :attr:`!database` 回傳。" -#: ../../library/dataclasses.rst:660 +#: ../../library/dataclasses.rst:667 msgid "Frozen instances" msgstr "凍結實例" -#: ../../library/dataclasses.rst:662 +#: ../../library/dataclasses.rst:669 #, fuzzy msgid "" "It is not possible to create truly immutable Python objects. However, by " @@ -1300,7 +1311,7 @@ msgstr "" "別將向類別新增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方" "法。這些方法在叫用時會引發 :exc:`FrozenInstanceError`。" -#: ../../library/dataclasses.rst:668 +#: ../../library/dataclasses.rst:675 #, fuzzy msgid "" "There is a tiny performance penalty when using ``frozen=True``: :meth:" @@ -1310,11 +1321,11 @@ msgstr "" "使用 ``frozen=True`` 時有一個微小的性能損失::meth:`~object.__init__` 不能使" "用簡單賦值來初始化欄位,必須使用 :meth:`!object.__setattr__`。" -#: ../../library/dataclasses.rst:677 +#: ../../library/dataclasses.rst:684 msgid "Inheritance" msgstr "繼承" -#: ../../library/dataclasses.rst:679 +#: ../../library/dataclasses.rst:686 #, fuzzy msgid "" "When the dataclass is being created by the :deco:`dataclass` decorator, it " @@ -1332,7 +1343,7 @@ msgstr "" "將自己的欄位新增到有序對映中。所有生成的方法都將使用這種組合的、計算的有序欄" "位對映。因為欄位是按插入順序排列的,所以衍生類別會覆蓋基底類別。一個例子: ::" -#: ../../library/dataclasses.rst:689 +#: ../../library/dataclasses.rst:696 msgid "" "@dataclass\n" "class Base:\n" @@ -1354,7 +1365,7 @@ msgstr "" " z: int = 10\n" " x: int = 15" -#: ../../library/dataclasses.rst:699 +#: ../../library/dataclasses.rst:706 #, fuzzy msgid "" "The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. " @@ -1364,23 +1375,23 @@ msgstr "" "最終的欄位列表按順序為 :attr:`!x`、:attr:`!y`、:attr:`!z`。:attr:`!x` 的最終" "型別是 :class:`int`,如類別 :class:`!C` 中指定的那樣。" -#: ../../library/dataclasses.rst:702 +#: ../../library/dataclasses.rst:709 #, fuzzy msgid "" "The generated :meth:`~object.__init__` method for :class:`!C` will look " "like::" msgstr "為 :class:`!C` 生成的 :meth:`~object.__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:704 +#: ../../library/dataclasses.rst:711 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:707 +#: ../../library/dataclasses.rst:714 #, fuzzy msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`" msgstr ":meth:`!__init__` 中僅關鍵字參數的重新排序" -#: ../../library/dataclasses.rst:709 +#: ../../library/dataclasses.rst:716 #, fuzzy msgid "" "After the parameters needed for :meth:`~object.__init__` are computed, any " @@ -1392,7 +1403,7 @@ msgstr "" "僅關鍵字)參數之後。這是如何在 Python 中實作僅關鍵字參數的要求:它們必須位於" "非僅關鍵字參數之後。" -#: ../../library/dataclasses.rst:715 +#: ../../library/dataclasses.rst:722 #, fuzzy msgid "" "In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are " @@ -1402,7 +1413,7 @@ msgstr "" "在此示例中,:attr:`!Base.y`、:attr:`!Base.w` 和 :attr:`!D.t` 是僅限關鍵字的欄" "位,:attr:`!Base.x` 和 :attr:`!D.z` 是常規欄位: ::" -#: ../../library/dataclasses.rst:718 +#: ../../library/dataclasses.rst:725 msgid "" "@dataclass\n" "class Base:\n" @@ -1428,12 +1439,12 @@ msgstr "" " z: int = 10\n" " t: int = field(kw_only=True, default=0)" -#: ../../library/dataclasses.rst:730 +#: ../../library/dataclasses.rst:737 #, fuzzy msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::" msgstr "為 :class:`!D` 生成的 :meth:`!__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:732 +#: ../../library/dataclasses.rst:739 msgid "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" @@ -1441,7 +1452,7 @@ msgstr "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" -#: ../../library/dataclasses.rst:734 +#: ../../library/dataclasses.rst:741 #, fuzzy msgid "" "Note that the parameters have been re-ordered from how they appear in the " @@ -1451,18 +1462,18 @@ msgstr "" "請注意,參數已根據它們在欄位列表中的顯示方式重新排序:從常規欄位衍生的參數後" "跟從僅關鍵字欄位衍生的參數。" -#: ../../library/dataclasses.rst:738 +#: ../../library/dataclasses.rst:745 #, 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:743 +#: ../../library/dataclasses.rst:750 msgid "Default factory functions" msgstr "預設工廠函式" -#: ../../library/dataclasses.rst:745 +#: ../../library/dataclasses.rst:752 #, fuzzy msgid "" "If a :func:`field` specifies a *default_factory*, it is called with zero " @@ -1472,11 +1483,11 @@ msgstr "" "如果 :func:`field` 指定了 *default_factory*,當需要該欄位的預設值時,它會以零" "引數呼叫。例如,要建立列表的新實例,請使用: ::" -#: ../../library/dataclasses.rst:749 +#: ../../library/dataclasses.rst:756 msgid "mylist: list = field(default_factory=list)" msgstr "mylist: list = field(default_factory=list)" -#: ../../library/dataclasses.rst:751 +#: ../../library/dataclasses.rst:758 #, fuzzy msgid "" "If a field is excluded from :meth:`~object.__init__` (using ``init=False``) " @@ -1489,11 +1500,11 @@ msgstr "" "位還指定了 ``default_factory``,那麼預設工廠函式將始終從生成的 :meth:" "`__init__ 中呼叫`功能。發生這種情況是因為沒有其他方法可以為該欄位賦予初始值。" -#: ../../library/dataclasses.rst:758 +#: ../../library/dataclasses.rst:765 msgid "Mutable default values" msgstr "可變預設值" -#: ../../library/dataclasses.rst:760 +#: ../../library/dataclasses.rst:767 #, fuzzy msgid "" "Python stores default member variable values in class attributes. Consider " @@ -1501,7 +1512,7 @@ msgid "" msgstr "" "Python 將預設成員變數值儲存在類別屬性中。考慮這個例子,不使用資料類別: ::" -#: ../../library/dataclasses.rst:763 +#: ../../library/dataclasses.rst:770 msgid "" "class C:\n" " x = []\n" @@ -1527,7 +1538,7 @@ msgstr "" "assert o1.x == [1, 2]\n" "assert o1.x is o2.x" -#: ../../library/dataclasses.rst:775 +#: ../../library/dataclasses.rst:782 #, fuzzy msgid "" "Note that the two instances of class :class:`!C` share the same class " @@ -1536,12 +1547,12 @@ msgstr "" "請注意,類別 :class:`!C` 的兩個實例共享同一個類別變數 :attr:`!x`,正如預期的" "那樣。" -#: ../../library/dataclasses.rst:778 +#: ../../library/dataclasses.rst:785 #, fuzzy msgid "Using dataclasses, *if* this code was valid::" msgstr "使用資料類別,*如果*\\ 此程式碼有效: ::" -#: ../../library/dataclasses.rst:780 +#: ../../library/dataclasses.rst:787 msgid "" "@dataclass\n" "class D:\n" @@ -1555,11 +1566,11 @@ msgstr "" " def add(self, element):\n" " self.x.append(element)" -#: ../../library/dataclasses.rst:786 +#: ../../library/dataclasses.rst:793 msgid "it would generate code similar to::" msgstr "它會生成類似的程式碼: ::" -#: ../../library/dataclasses.rst:788 +#: ../../library/dataclasses.rst:795 msgid "" "class D:\n" " x = []\n" @@ -1579,7 +1590,7 @@ msgstr "" "\n" "assert D().x is D().x" -#: ../../library/dataclasses.rst:797 +#: ../../library/dataclasses.rst:804 #, fuzzy msgid "" "This has the same issue as the original example using class :class:`!C`. " @@ -1599,14 +1610,14 @@ msgstr "" "檢測到不可雜湊的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散" "列的,那麼它就是可變的。這是一個部分解決方案,但它確實可以防止許多常見錯誤。" -#: ../../library/dataclasses.rst:808 +#: ../../library/dataclasses.rst:815 #, 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:811 +#: ../../library/dataclasses.rst:818 msgid "" "@dataclass\n" "class D:\n" @@ -1620,7 +1631,7 @@ msgstr "" "\n" "assert D().x is not D().x" -#: ../../library/dataclasses.rst:817 +#: ../../library/dataclasses.rst:824 #, fuzzy msgid "" "Instead of looking for and disallowing objects of type :class:`list`, :class:" @@ -1630,12 +1641,12 @@ msgstr "" "不再查找和禁止型別為 :class:`list`、:class:`dict` 或 :class:`set` 的物件,現" "在不允許使用不可雜湊的物件作為預設值。不可雜湊性用於近似可變性。" -#: ../../library/dataclasses.rst:824 +#: ../../library/dataclasses.rst:831 #, fuzzy msgid "Descriptor-typed fields" msgstr "描述器型別的欄位" -#: ../../library/dataclasses.rst:826 +#: ../../library/dataclasses.rst:833 #, fuzzy msgid "" "Fields that are assigned :ref:`descriptor objects ` as their " @@ -1643,7 +1654,7 @@ msgid "" msgstr "" "指定為\\ :ref:`描述器物件 `\\ 作為預設值的欄位具有以下特殊行為:" -#: ../../library/dataclasses.rst:829 +#: ../../library/dataclasses.rst:836 #, fuzzy msgid "" "The value for the field passed to the dataclass's :meth:`~object.__init__` " @@ -1653,7 +1664,7 @@ msgstr "" "傳遞給資料類別的 :meth:`~object.__init__` 方法的欄位值被傳遞給描述器的 :meth:" "`~object.__set__` 方法,而不是覆蓋描述器物件。" -#: ../../library/dataclasses.rst:833 +#: ../../library/dataclasses.rst:840 #, fuzzy msgid "" "Similarly, when getting or setting the field, the descriptor's :meth:" @@ -1663,7 +1674,7 @@ msgstr "" "同樣,在取得或設定欄位時,將呼叫描述器的 :meth:`~object.__get__` 或 :meth:`!" "__set__` 方法,而不是回傳或覆蓋描述器物件。" -#: ../../library/dataclasses.rst:837 +#: ../../library/dataclasses.rst:844 #, fuzzy msgid "" "To determine whether a field contains a default value, :deco:`dataclass` " @@ -1679,7 +1690,7 @@ msgstr "" "面,如果描述器在這種情況下引發 :exc:`AttributeError`,則不會為該欄位提供預設" "值。" -#: ../../library/dataclasses.rst:847 +#: ../../library/dataclasses.rst:854 msgid "" "class IntConversionDescriptor:\n" " def __init__(self, *, default):\n" @@ -1733,7 +1744,7 @@ msgstr "" "i.quantity_on_hand = 2.5 # 以 2.5 呼叫 __set__\n" "print(i.quantity_on_hand) # 2" -#: ../../library/dataclasses.rst:872 +#: ../../library/dataclasses.rst:879 #, fuzzy msgid "" "Note that if a field is annotated with a descriptor type, but is not " diff --git a/library/datatypes.po b/library/datatypes.po index c6980edfad2..8af8ac2b94a 100644 --- a/library/datatypes.po +++ b/library/datatypes.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-20 18:08+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-02-11 12:12+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -34,16 +34,17 @@ msgstr "" #: ../../library/datatypes.rst:11 msgid "" -"Python also provides some built-in data types, in particular, :class:" -"`dict`, :class:`list`, :class:`set` and :class:`frozenset`, and :class:" -"`tuple`. The :class:`str` class is used to hold Unicode strings, and the :" -"class:`bytes` and :class:`bytearray` classes are used to hold binary data." +"Python also provides :ref:`some built-in data types `, in " +"particular, :class:`list`, :class:`tuple`, :class:`dict`, :class:" +"`frozendict`, :class:`set`, and :class:`frozenset`. The :class:`str` class " +"is used to hold Unicode strings, and the :class:`bytes` and :class:" +"`bytearray` classes are used to hold binary data." msgstr "" -"Python 也有提供一些內建資料型別,特別是 :class:`dict`、:class:`list`、:class:" -"`set` 與 :class:`frozenset` 和 :class:`tuple`。:class:`str` 類別是用來儲存 " -"Unicode 字串,:class:`bytes` 與 :class:`bytearray` 類別則是用來儲存二進位制資" -"料。" +"Python 也有提供\\ :ref:`一些內建資料型別 `,特別" +"是 :class:`list`、:class:`tuple`、:class:`dict`、:class:`frozendict`、:class:`set` " +"與 :class:`frozenset`。:class:`str` 類別是用來儲存 Unicode 字" +"串,:class:`bytes` 與 :class:`bytearray` 類別則是用來儲存二進位資料。" -#: ../../library/datatypes.rst:17 +#: ../../library/datatypes.rst:18 msgid "The following modules are documented in this chapter:" msgstr "本章節包含下列模組的文件:" diff --git a/library/datetime.po b/library/datetime.po index 485959dcf03..5cd23642761 100644 --- a/library/datetime.po +++ b/library/datetime.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-07 01:12+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-08-07 10:20+0800\n" "Last-Translator: Griiid \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,80 +22,80 @@ msgstr "" msgid ":mod:`!datetime` --- Basic date and time types" msgstr ":mod:`!datetime` --- 日期與時間的基本型別" -#: ../../library/datetime.rst:11 +#: ../../library/datetime.rst:7 msgid "**Source code:** :source:`Lib/datetime.py`" msgstr "**原始碼:**\\ :source:`Lib/datetime.py`" -#: ../../library/datetime.rst:15 +#: ../../library/datetime.rst:11 msgid "" "The :mod:`!datetime` module supplies classes for manipulating dates and " "times." msgstr ":mod:`!datetime` 模組提供操作日期與時間的類別。" -#: ../../library/datetime.rst:17 +#: ../../library/datetime.rst:13 msgid "" "While date and time arithmetic is supported, the focus of the implementation " "is on efficient attribute extraction for output formatting and manipulation." msgstr "" -#: ../../library/datetime.rst:22 +#: ../../library/datetime.rst:18 msgid "Skip to :ref:`the format codes `." msgstr "跳轉至\\ :ref:`格式碼 (format codes) `。" -#: ../../library/datetime.rst:26 +#: ../../library/datetime.rst:22 msgid "Module :mod:`calendar`" msgstr ":mod:`calendar` 模組" -#: ../../library/datetime.rst:27 +#: ../../library/datetime.rst:23 msgid "General calendar related functions." msgstr "與日曆相關的一般函式。" -#: ../../library/datetime.rst:29 +#: ../../library/datetime.rst:25 msgid "Module :mod:`time`" msgstr ":mod:`time` 模組" -#: ../../library/datetime.rst:30 +#: ../../library/datetime.rst:26 msgid "Time access and conversions." msgstr "" -#: ../../library/datetime.rst:32 +#: ../../library/datetime.rst:28 msgid "Module :mod:`zoneinfo`" msgstr ":mod:`zoneinfo` 模組" -#: ../../library/datetime.rst:33 +#: ../../library/datetime.rst:29 msgid "Concrete time zones representing the IANA time zone database." msgstr "" -#: ../../library/datetime.rst:35 +#: ../../library/datetime.rst:31 msgid "Package `dateutil `_" msgstr "`dateutil `_ 套件" -#: ../../library/datetime.rst:36 +#: ../../library/datetime.rst:32 msgid "Third-party library with expanded time zone and parsing support." msgstr "帶有時區與剖析擴充支援的第三方函式庫。" -#: ../../library/datetime.rst:38 +#: ../../library/datetime.rst:34 msgid "Package :pypi:`DateType`" msgstr ":pypi:`DateType` 套件" -#: ../../library/datetime.rst:39 +#: ../../library/datetime.rst:35 msgid "" "Third-party library that introduces distinct static types to for example, " "allow :term:`static type checkers ` to differentiate " "between naive and aware datetimes." msgstr "" -#: ../../library/datetime.rst:47 +#: ../../library/datetime.rst:43 msgid "Aware and naive objects" msgstr "" -#: ../../library/datetime.rst:49 +#: ../../library/datetime.rst:45 msgid "" "Date and time objects may be categorized as \"aware\" or \"naive\" depending " "on whether or not they include time zone information." msgstr "" -#: ../../library/datetime.rst:52 +#: ../../library/datetime.rst:48 msgid "" "With sufficient knowledge of applicable algorithmic and political time " "adjustments, such as time zone and daylight saving time information, an " @@ -104,7 +104,7 @@ msgid "" "interpretation. [#]_" msgstr "" -#: ../../library/datetime.rst:58 +#: ../../library/datetime.rst:54 msgid "" "A **naive** object does not contain enough information to unambiguously " "locate itself relative to other date/time objects. Whether a naive object " @@ -115,7 +115,7 @@ msgid "" "some aspects of reality." msgstr "" -#: ../../library/datetime.rst:65 +#: ../../library/datetime.rst:61 msgid "" "For applications requiring aware objects, :class:`.datetime` and :class:`." "time` objects have an optional time zone information attribute, :attr:`!" @@ -125,7 +125,7 @@ msgid "" "is in effect." msgstr "" -#: ../../library/datetime.rst:71 +#: ../../library/datetime.rst:67 msgid "" "Only one concrete :class:`tzinfo` class, the :class:`timezone` class, is " "supplied by the :mod:`!datetime` module. The :class:`!timezone` class can " @@ -136,42 +136,42 @@ msgid "" "there is no standard suitable for every application aside from UTC." msgstr "" -#: ../../library/datetime.rst:81 +#: ../../library/datetime.rst:77 msgid "Constants" msgstr "常數" -#: ../../library/datetime.rst:83 +#: ../../library/datetime.rst:79 msgid "The :mod:`!datetime` module exports the following constants:" msgstr ":mod:`!datetime` 模組匯出以下常數:" -#: ../../library/datetime.rst:87 +#: ../../library/datetime.rst:83 msgid "" "The smallest year number allowed in a :class:`date` or :class:`.datetime` " "object. :const:`MINYEAR` is 1." msgstr "" -#: ../../library/datetime.rst:93 +#: ../../library/datetime.rst:89 msgid "" "The largest year number allowed in a :class:`date` or :class:`.datetime` " "object. :const:`MAXYEAR` is 9999." msgstr "" -#: ../../library/datetime.rst:99 +#: ../../library/datetime.rst:95 msgid "Alias for the UTC time zone singleton :attr:`datetime.timezone.utc`." msgstr "" -#: ../../library/datetime.rst:105 +#: ../../library/datetime.rst:101 msgid "Available types" msgstr "" -#: ../../library/datetime.rst:110 +#: ../../library/datetime.rst:106 msgid "" "An idealized naive date, assuming the current Gregorian calendar always was, " "and always will be, in effect. Attributes: :attr:`year`, :attr:`month`, and :" "attr:`day`." msgstr "" -#: ../../library/datetime.rst:118 +#: ../../library/datetime.rst:114 msgid "" "An idealized time, independent of any particular day, assuming that every " "day has exactly 24\\*60\\*60 seconds. (There is no notion of \"leap " @@ -179,14 +179,14 @@ msgid "" "attr:`microsecond`, and :attr:`.tzinfo`." msgstr "" -#: ../../library/datetime.rst:127 +#: ../../library/datetime.rst:123 msgid "" "A combination of a date and a time. Attributes: :attr:`year`, :attr:" "`month`, :attr:`day`, :attr:`hour`, :attr:`minute`, :attr:`second`, :attr:" "`microsecond`, and :attr:`.tzinfo`." msgstr "" -#: ../../library/datetime.rst:135 +#: ../../library/datetime.rst:131 msgid "" "A duration expressing the difference between two :class:`.datetime` or :" "class:`date` instances to microsecond resolution." @@ -194,7 +194,7 @@ msgstr "" "表示兩個 :class:`.datetime` 或 :class:`date` 實例之間時間的差異,以微秒為解析" "度。" -#: ../../library/datetime.rst:142 +#: ../../library/datetime.rst:138 msgid "" "An abstract base class for time zone information objects. These are used by " "the :class:`.datetime` and :class:`.time` classes to provide a customizable " @@ -202,105 +202,105 @@ msgid "" "daylight saving time)." msgstr "" -#: ../../library/datetime.rst:151 +#: ../../library/datetime.rst:147 msgid "" "A class that implements the :class:`tzinfo` abstract base class as a fixed " "offset from the UTC." msgstr "" -#: ../../library/datetime.rst:157 ../../library/datetime.rst:174 +#: ../../library/datetime.rst:153 ../../library/datetime.rst:170 msgid "Objects of these types are immutable." msgstr "" -#: ../../library/datetime.rst:159 +#: ../../library/datetime.rst:155 msgid "Subclass relationships:" msgstr "" -#: ../../library/datetime.rst:161 +#: ../../library/datetime.rst:157 msgid "" "timedelta, tzinfo, time, and date inherit from object; timezone inherits\n" "from tzinfo; and datetime inherits from date." msgstr "" -#: ../../library/datetime.rst:169 +#: ../../library/datetime.rst:165 msgid "Common properties" msgstr "常見屬性" -#: ../../library/datetime.rst:171 +#: ../../library/datetime.rst:167 msgid "" "The :class:`date`, :class:`.datetime`, :class:`.time`, and :class:`timezone` " "types share these common features:" msgstr "" -#: ../../library/datetime.rst:175 +#: ../../library/datetime.rst:171 msgid "" "Objects of these types are :term:`hashable`, meaning that they can be used " "as dictionary keys." msgstr "" -#: ../../library/datetime.rst:177 +#: ../../library/datetime.rst:173 msgid "" "Objects of these types support efficient pickling via the :mod:`pickle` " "module." msgstr "" -#: ../../library/datetime.rst:181 +#: ../../library/datetime.rst:177 msgid "Determining if an object is aware or naive" msgstr "" -#: ../../library/datetime.rst:183 +#: ../../library/datetime.rst:179 msgid "Objects of the :class:`date` type are always naive." msgstr "" -#: ../../library/datetime.rst:185 +#: ../../library/datetime.rst:181 msgid "" "An object of type :class:`.time` or :class:`.datetime` may be aware or naive." msgstr "" -#: ../../library/datetime.rst:187 +#: ../../library/datetime.rst:183 msgid "" "A :class:`.datetime` object ``d`` is aware if both of the following hold:" msgstr "" -#: ../../library/datetime.rst:189 +#: ../../library/datetime.rst:185 msgid "``d.tzinfo`` is not ``None``" msgstr "``d.tzinfo`` 不是 ``None``" -#: ../../library/datetime.rst:190 +#: ../../library/datetime.rst:186 msgid "``d.tzinfo.utcoffset(d)`` does not return ``None``" msgstr "``d.tzinfo.utcoffset(d)`` 不會回傳 ``None``" -#: ../../library/datetime.rst:192 +#: ../../library/datetime.rst:188 msgid "Otherwise, ``d`` is naive." msgstr "否則 ``d`` 會是 naive 的。" -#: ../../library/datetime.rst:194 +#: ../../library/datetime.rst:190 msgid "A :class:`.time` object ``t`` is aware if both of the following hold:" msgstr "" -#: ../../library/datetime.rst:196 +#: ../../library/datetime.rst:192 msgid "``t.tzinfo`` is not ``None``" msgstr "``t.tzinfo`` 不是 ``None``" -#: ../../library/datetime.rst:197 +#: ../../library/datetime.rst:193 msgid "``t.tzinfo.utcoffset(None)`` does not return ``None``." msgstr "``t.tzinfo.utcoffset(None)`` 沒有回傳 ``None``。" -#: ../../library/datetime.rst:199 +#: ../../library/datetime.rst:195 msgid "Otherwise, ``t`` is naive." msgstr "否則 ``t`` 會是 naive 的。" -#: ../../library/datetime.rst:201 +#: ../../library/datetime.rst:197 msgid "" "The distinction between aware and naive doesn't apply to :class:`timedelta` " "objects." msgstr "" -#: ../../library/datetime.rst:208 +#: ../../library/datetime.rst:204 msgid ":class:`!timedelta` objects" msgstr ":class:`!timedelta` 物件" -#: ../../library/datetime.rst:210 +#: ../../library/datetime.rst:206 msgid "" "A :class:`timedelta` object represents a duration, the difference between " "two :class:`.datetime` or :class:`date` instances." @@ -308,60 +308,60 @@ msgstr "" "一個 :class:`timedelta` 物件代表著一段持續時間,即兩個 :class:`.datetime` " "或 :class:`date` 之間的差異。" -#: ../../library/datetime.rst:215 +#: ../../library/datetime.rst:211 msgid "" "All arguments are optional and default to 0. Arguments may be integers or " "floats, and may be positive or negative." msgstr "" -#: ../../library/datetime.rst:218 +#: ../../library/datetime.rst:214 msgid "" "Only *days*, *seconds* and *microseconds* are stored internally. Arguments " "are converted to those units:" msgstr "" -#: ../../library/datetime.rst:221 +#: ../../library/datetime.rst:217 msgid "A millisecond is converted to 1000 microseconds." msgstr "一毫秒會被轉換為 1000 微秒。" -#: ../../library/datetime.rst:222 +#: ../../library/datetime.rst:218 msgid "A minute is converted to 60 seconds." msgstr "一分鐘會被轉換為 60 秒。" -#: ../../library/datetime.rst:223 +#: ../../library/datetime.rst:219 msgid "An hour is converted to 3600 seconds." msgstr "一小時會被轉換為 3600 秒。" -#: ../../library/datetime.rst:224 +#: ../../library/datetime.rst:220 msgid "A week is converted to 7 days." msgstr "一週會被轉換為 7 天。" -#: ../../library/datetime.rst:226 +#: ../../library/datetime.rst:222 msgid "" "and days, seconds and microseconds are then normalized so that the " "representation is unique, with" msgstr "" -#: ../../library/datetime.rst:229 +#: ../../library/datetime.rst:225 msgid "``0 <= microseconds < 1000000``" msgstr "``0 <= microseconds < 1000000``" -#: ../../library/datetime.rst:230 +#: ../../library/datetime.rst:226 msgid "``0 <= seconds < 3600*24`` (the number of seconds in one day)" msgstr "" -#: ../../library/datetime.rst:231 +#: ../../library/datetime.rst:227 msgid "``-999999999 <= days <= 999999999``" msgstr "``-999999999 <= days <= 999999999``" -#: ../../library/datetime.rst:233 +#: ../../library/datetime.rst:229 msgid "" "The following example illustrates how any arguments besides *days*, " "*seconds* and *microseconds* are \"merged\" and normalized into those three " "resulting attributes::" msgstr "" -#: ../../library/datetime.rst:237 +#: ../../library/datetime.rst:233 msgid "" ">>> import datetime as dt\n" ">>> delta = dt.timedelta(\n" @@ -378,7 +378,7 @@ msgid "" "datetime.timedelta(days=64, seconds=29156, microseconds=10)" msgstr "" -#: ../../library/datetime.rst:252 +#: ../../library/datetime.rst:248 msgid "" "``import datetime as dt`` instead of ``import datetime`` or ``from datetime " "import datetime`` to avoid confusion between the module and the class. See " @@ -386,7 +386,7 @@ msgid "" "i-import-pythons-datetime-module/>`__." msgstr "" -#: ../../library/datetime.rst:257 +#: ../../library/datetime.rst:253 msgid "" "If any argument is a float and there are fractional microseconds, the " "fractional microseconds left over from all arguments are combined and their " @@ -395,19 +395,19 @@ msgid "" "processes are exact (no information is lost)." msgstr "" -#: ../../library/datetime.rst:264 +#: ../../library/datetime.rst:260 msgid "" "If the normalized value of days lies outside the indicated range, :exc:" "`OverflowError` is raised." msgstr "" -#: ../../library/datetime.rst:267 +#: ../../library/datetime.rst:263 msgid "" "Note that normalization of negative values may be surprising at first. For " "example::" msgstr "" -#: ../../library/datetime.rst:270 +#: ../../library/datetime.rst:266 msgid "" ">>> import datetime as dt\n" ">>> d = dt.timedelta(microseconds=-1)\n" @@ -419,13 +419,13 @@ msgstr "" ">>> (d.days, d.seconds, d.microseconds)\n" "(-1, 86399, 999999)" -#: ../../library/datetime.rst:275 +#: ../../library/datetime.rst:271 msgid "" "Since the string representation of :class:`!timedelta` objects can be " "confusing, use the following recipe to produce a more readable format:" msgstr "" -#: ../../library/datetime.rst:278 +#: ../../library/datetime.rst:274 msgid "" ">>> def pretty_timedelta(td):\n" "... if td.days >= 0:\n" @@ -449,56 +449,56 @@ msgstr "" ">>> pretty_timedelta(d)\n" "'-(1:00:00)'" -#: ../../library/datetime.rst:292 ../../library/datetime.rst:630 -#: ../../library/datetime.rst:1200 ../../library/datetime.rst:1849 -#: ../../library/datetime.rst:2485 +#: ../../library/datetime.rst:288 ../../library/datetime.rst:628 +#: ../../library/datetime.rst:1201 ../../library/datetime.rst:1850 +#: ../../library/datetime.rst:2486 msgid "Class attributes:" msgstr "類別屬性:" -#: ../../library/datetime.rst:296 +#: ../../library/datetime.rst:292 msgid "The most negative :class:`timedelta` object, ``timedelta(-999999999)``." msgstr "" -#: ../../library/datetime.rst:301 +#: ../../library/datetime.rst:297 msgid "" "The most positive :class:`timedelta` object, ``timedelta(days=999999999, " "hours=23, minutes=59, seconds=59, microseconds=999999)``." msgstr "" -#: ../../library/datetime.rst:307 +#: ../../library/datetime.rst:303 msgid "" "The smallest possible difference between non-equal :class:`timedelta` " "objects, ``timedelta(microseconds=1)``." msgstr "" -#: ../../library/datetime.rst:311 +#: ../../library/datetime.rst:307 msgid "" "Note that, because of normalization, ``timedelta.max`` is greater than ``-" "timedelta.min``. ``-timedelta.max`` is not representable as a :class:" "`timedelta` object." msgstr "" -#: ../../library/datetime.rst:315 ../../library/datetime.rst:648 -#: ../../library/datetime.rst:1220 ../../library/datetime.rst:1869 +#: ../../library/datetime.rst:311 ../../library/datetime.rst:646 +#: ../../library/datetime.rst:1221 ../../library/datetime.rst:1870 msgid "Instance attributes (read-only):" msgstr "" -#: ../../library/datetime.rst:319 +#: ../../library/datetime.rst:315 msgid "Between -999,999,999 and 999,999,999 inclusive." msgstr "在 -999,999,999 到 999,999,999 (含)之間" -#: ../../library/datetime.rst:324 +#: ../../library/datetime.rst:320 msgid "Between 0 and 86,399 inclusive." msgstr "在 0 到 86,399 (含)之間" -#: ../../library/datetime.rst:328 +#: ../../library/datetime.rst:324 msgid "" "It is a somewhat common bug for code to unintentionally use this attribute " "when it is actually intended to get a :meth:`~timedelta.total_seconds` value " "instead:" msgstr "" -#: ../../library/datetime.rst:332 +#: ../../library/datetime.rst:328 msgid "" ">>> import datetime as dt\n" ">>> duration = dt.timedelta(seconds=11235813)\n" @@ -514,130 +514,130 @@ msgstr "" ">>> duration.total_seconds()\n" "11235813.0" -#: ../../library/datetime.rst:344 +#: ../../library/datetime.rst:340 msgid "Between 0 and 999,999 inclusive." msgstr "在 0 到 999,999 (含)之間" -#: ../../library/datetime.rst:347 ../../library/datetime.rst:665 -#: ../../library/datetime.rst:1274 +#: ../../library/datetime.rst:343 ../../library/datetime.rst:663 +#: ../../library/datetime.rst:1275 msgid "Supported operations:" msgstr "" -#: ../../library/datetime.rst:350 ../../library/datetime.rst:668 -#: ../../library/datetime.rst:1277 +#: ../../library/datetime.rst:346 ../../library/datetime.rst:666 +#: ../../library/datetime.rst:1278 msgid "Operation" msgstr "" -#: ../../library/datetime.rst:350 ../../library/datetime.rst:668 -#: ../../library/datetime.rst:1277 +#: ../../library/datetime.rst:346 ../../library/datetime.rst:666 +#: ../../library/datetime.rst:1278 msgid "Result" msgstr "" -#: ../../library/datetime.rst:352 +#: ../../library/datetime.rst:348 msgid "``t1 = t2 + t3``" msgstr "``t1 = t2 + t3``" -#: ../../library/datetime.rst:352 +#: ../../library/datetime.rst:348 msgid "" "Sum of ``t2`` and ``t3``. Afterwards ``t1 - t2 == t3`` and ``t1 - t3 == t2`` " "are true. (1)" msgstr "" -#: ../../library/datetime.rst:356 +#: ../../library/datetime.rst:352 msgid "``t1 = t2 - t3``" msgstr "``t1 = t2 - t3``" -#: ../../library/datetime.rst:356 +#: ../../library/datetime.rst:352 msgid "" "Difference of ``t2`` and ``t3``. Afterwards ``t1 == t2 - t3`` and ``t2 == " "t1 + t3`` are true. (1)(6)" msgstr "" -#: ../../library/datetime.rst:360 +#: ../../library/datetime.rst:356 msgid "``t1 = t2 * i or t1 = i * t2``" msgstr "``t1 = t2 * i or t1 = i * t2``" -#: ../../library/datetime.rst:360 +#: ../../library/datetime.rst:356 msgid "" "Delta multiplied by an integer. Afterwards ``t1 // i == t2`` is true, " "provided ``i != 0``." msgstr "" -#: ../../library/datetime.rst:364 +#: ../../library/datetime.rst:360 msgid "In general, ``t1 * i == t1 * (i-1) + t1`` is true. (1)" msgstr "" -#: ../../library/datetime.rst:367 +#: ../../library/datetime.rst:363 msgid "``t1 = t2 * f or t1 = f * t2``" msgstr "``t1 = t2 * f or t1 = f * t2``" -#: ../../library/datetime.rst:367 +#: ../../library/datetime.rst:363 msgid "" "Delta multiplied by a float. The result is rounded to the nearest multiple " "of timedelta.resolution using round-half-to-even." msgstr "" -#: ../../library/datetime.rst:371 +#: ../../library/datetime.rst:367 msgid "``f = t2 / t3``" msgstr "``f = t2 / t3``" -#: ../../library/datetime.rst:371 +#: ../../library/datetime.rst:367 msgid "" "Division (3) of overall duration ``t2`` by interval unit ``t3``. Returns a :" "class:`float` object." msgstr "" -#: ../../library/datetime.rst:375 +#: ../../library/datetime.rst:371 msgid "``t1 = t2 / f or t1 = t2 / i``" msgstr "``t1 = t2 / f or t1 = t2 / i``" -#: ../../library/datetime.rst:375 +#: ../../library/datetime.rst:371 msgid "" "Delta divided by a float or an int. The result is rounded to the nearest " "multiple of timedelta.resolution using round-half-to-even." msgstr "" -#: ../../library/datetime.rst:379 +#: ../../library/datetime.rst:375 msgid "``t1 = t2 // i`` or ``t1 = t2 // t3``" msgstr "``t1 = t2 // i`` or ``t1 = t2 // t3``" -#: ../../library/datetime.rst:379 +#: ../../library/datetime.rst:375 msgid "" "The floor is computed and the remainder (if any) is thrown away. In the " "second case, an integer is returned. (3)" msgstr "" -#: ../../library/datetime.rst:383 +#: ../../library/datetime.rst:379 msgid "``t1 = t2 % t3``" msgstr "``t1 = t2 % t3``" -#: ../../library/datetime.rst:383 +#: ../../library/datetime.rst:379 msgid "The remainder is computed as a :class:`timedelta` object. (3)" msgstr "" -#: ../../library/datetime.rst:386 +#: ../../library/datetime.rst:382 msgid "``q, r = divmod(t1, t2)``" msgstr "``q, r = divmod(t1, t2)``" -#: ../../library/datetime.rst:386 +#: ../../library/datetime.rst:382 msgid "" "Computes the quotient and the remainder: ``q = t1 // t2`` (3) and ``r = t1 % " "t2``. ``q`` is an integer and ``r`` is a :class:`timedelta` object." msgstr "" -#: ../../library/datetime.rst:391 +#: ../../library/datetime.rst:387 msgid "``+t1``" msgstr "``+t1``" -#: ../../library/datetime.rst:391 +#: ../../library/datetime.rst:387 msgid "Returns a :class:`timedelta` object with the same value. (2)" msgstr "" -#: ../../library/datetime.rst:394 +#: ../../library/datetime.rst:390 msgid "``-t1``" msgstr "``-t1``" -#: ../../library/datetime.rst:394 +#: ../../library/datetime.rst:390 msgid "" "Equivalent to ``timedelta(-t1.days, -t1.seconds, -t1.microseconds)``, and to " "``t1 * -1``. (1)(4)" @@ -645,65 +645,65 @@ msgstr "" "等價於 ``timedelta(-t1.days, -t1.seconds, -t1.microseconds)``,也等價於 ``t1 " "* -1``。 (1)(4)" -#: ../../library/datetime.rst:398 +#: ../../library/datetime.rst:394 msgid "``abs(t)``" msgstr "``abs(t)``" -#: ../../library/datetime.rst:398 +#: ../../library/datetime.rst:394 msgid "" "Equivalent to ``+t`` when ``t.days >= 0``, and to ``-t`` when ``t.days < " "0``. (2)" msgstr "" -#: ../../library/datetime.rst:401 +#: ../../library/datetime.rst:397 msgid "``str(t)``" msgstr "``str(t)``" -#: ../../library/datetime.rst:401 +#: ../../library/datetime.rst:397 msgid "" "Returns a string in the form ``[D day[s], ][H]H:MM:SS[.UUUUUU]``, where D is " "negative for negative ``t``. (5)" msgstr "" -#: ../../library/datetime.rst:405 +#: ../../library/datetime.rst:401 msgid "``repr(t)``" msgstr "``repr(t)``" -#: ../../library/datetime.rst:405 +#: ../../library/datetime.rst:401 msgid "" "Returns a string representation of the :class:`timedelta` object as a " "constructor call with canonical attribute values." msgstr "" -#: ../../library/datetime.rst:410 ../../library/datetime.rst:687 -#: ../../library/datetime.rst:2754 +#: ../../library/datetime.rst:406 ../../library/datetime.rst:685 +#: ../../library/datetime.rst:2796 msgid "Notes:" msgstr "註解:" -#: ../../library/datetime.rst:413 +#: ../../library/datetime.rst:409 msgid "This is exact but may overflow." msgstr "這是精確的,但可能會溢位。" -#: ../../library/datetime.rst:416 +#: ../../library/datetime.rst:412 msgid "This is exact and cannot overflow." msgstr "這是精確的,且不會溢位。" -#: ../../library/datetime.rst:419 +#: ../../library/datetime.rst:415 msgid "Division by zero raises :exc:`ZeroDivisionError`." msgstr "" -#: ../../library/datetime.rst:422 +#: ../../library/datetime.rst:418 msgid "``-timedelta.max`` is not representable as a :class:`timedelta` object." msgstr "" -#: ../../library/datetime.rst:425 +#: ../../library/datetime.rst:421 msgid "" "String representations of :class:`timedelta` objects are normalized " "similarly to their internal representation. This leads to somewhat unusual " "results for negative timedeltas. For example::" msgstr "" -#: ../../library/datetime.rst:429 +#: ../../library/datetime.rst:425 msgid "" ">>> timedelta(hours=-5)\n" "datetime.timedelta(days=-1, seconds=68400)\n" @@ -715,21 +715,21 @@ msgstr "" ">>> print(_)\n" "-1 day, 19:00:00" -#: ../../library/datetime.rst:435 +#: ../../library/datetime.rst:431 msgid "" "The expression ``t2 - t3`` will always be equal to the expression ``t2 + (-" "t3)`` except when t3 is equal to ``timedelta.max``; in that case the former " "will produce a result while the latter will overflow." msgstr "" -#: ../../library/datetime.rst:439 +#: ../../library/datetime.rst:435 msgid "" "In addition to the operations listed above, :class:`timedelta` objects " "support certain additions and subtractions with :class:`date` and :class:`." "datetime` objects (see below)." msgstr "" -#: ../../library/datetime.rst:443 +#: ../../library/datetime.rst:439 msgid "" "Floor division and true division of a :class:`timedelta` object by another :" "class:`!timedelta` object are now supported, as are remainder operations and " @@ -737,43 +737,43 @@ msgid "" "timedelta` object by a :class:`float` object are now supported." msgstr "" -#: ../../library/datetime.rst:449 +#: ../../library/datetime.rst:445 msgid ":class:`timedelta` objects support equality and order comparisons." msgstr "" -#: ../../library/datetime.rst:451 +#: ../../library/datetime.rst:447 msgid "" "In Boolean contexts, a :class:`timedelta` object is considered to be true if " "and only if it isn't equal to ``timedelta(0)``." msgstr "" -#: ../../library/datetime.rst:454 ../../library/datetime.rst:729 -#: ../../library/datetime.rst:1365 ../../library/datetime.rst:1994 +#: ../../library/datetime.rst:450 ../../library/datetime.rst:727 +#: ../../library/datetime.rst:1366 ../../library/datetime.rst:1995 msgid "Instance methods:" msgstr "實例方法:" -#: ../../library/datetime.rst:458 +#: ../../library/datetime.rst:454 msgid "" "Return the total number of seconds contained in the duration. Equivalent to " "``td / timedelta(seconds=1)``. For interval units other than seconds, use " "the division form directly (for example, ``td / timedelta(microseconds=1)``)." msgstr "" -#: ../../library/datetime.rst:462 +#: ../../library/datetime.rst:458 msgid "" "Note that for very large time intervals (greater than 270 years on most " "platforms) this method will lose microsecond accuracy." msgstr "" -#: ../../library/datetime.rst:469 +#: ../../library/datetime.rst:465 msgid "Examples of usage: :class:`!timedelta`" msgstr "用法範例::class:`!timedelta`" -#: ../../library/datetime.rst:471 +#: ../../library/datetime.rst:467 msgid "An additional example of normalization::" msgstr "" -#: ../../library/datetime.rst:473 +#: ../../library/datetime.rst:469 msgid "" ">>> # Components of another_year add up to exactly 365 days\n" ">>> import datetime as dt\n" @@ -786,11 +786,11 @@ msgid "" "31536000.0" msgstr "" -#: ../../library/datetime.rst:483 +#: ../../library/datetime.rst:479 msgid "Examples of :class:`timedelta` arithmetic::" msgstr "" -#: ../../library/datetime.rst:485 +#: ../../library/datetime.rst:481 msgid "" ">>> import datetime as dt\n" ">>> year = dt.timedelta(days=365)\n" @@ -820,65 +820,65 @@ msgstr "" ">>> three_years, three_years.days // 365\n" "(datetime.timedelta(days=1095), 3)" -#: ../../library/datetime.rst:503 +#: ../../library/datetime.rst:499 msgid ":class:`!date` objects" msgstr ":class:`!date` 物件" -#: ../../library/datetime.rst:505 +#: ../../library/datetime.rst:501 msgid "" "A :class:`date` object represents a date (year, month and day) in an " "idealized calendar, the current Gregorian calendar indefinitely extended in " "both directions." msgstr "" -#: ../../library/datetime.rst:509 +#: ../../library/datetime.rst:505 msgid "" "January 1 of year 1 is called day number 1, January 2 of year 1 is called " "day number 2, and so on. [#]_" msgstr "" -#: ../../library/datetime.rst:514 +#: ../../library/datetime.rst:510 msgid "" "All arguments are required. Arguments must be integers, in the following " "ranges:" msgstr "" -#: ../../library/datetime.rst:517 +#: ../../library/datetime.rst:513 msgid "``MINYEAR <= year <= MAXYEAR``" msgstr "``MINYEAR <= year <= MAXYEAR``" -#: ../../library/datetime.rst:518 +#: ../../library/datetime.rst:514 msgid "``1 <= month <= 12``" msgstr "``1 <= month <= 12``" -#: ../../library/datetime.rst:519 +#: ../../library/datetime.rst:515 msgid "``1 <= day <= number of days in the given month and year``" msgstr "``1 <= day <= 該年該月的天數``" -#: ../../library/datetime.rst:521 ../../library/datetime.rst:950 +#: ../../library/datetime.rst:517 ../../library/datetime.rst:948 msgid "" "If an argument outside those ranges is given, :exc:`ValueError` is raised." msgstr "" -#: ../../library/datetime.rst:524 ../../library/datetime.rst:956 +#: ../../library/datetime.rst:520 ../../library/datetime.rst:954 msgid "Other constructors, all class methods:" msgstr "" -#: ../../library/datetime.rst:528 +#: ../../library/datetime.rst:524 msgid "Return the current local date." msgstr "回傳目前的本地日期。" -#: ../../library/datetime.rst:530 +#: ../../library/datetime.rst:526 msgid "This is equivalent to ``date.fromtimestamp(time.time())``." msgstr "這等同於 ``date.fromtimestamp(time.time())``。" -#: ../../library/datetime.rst:535 +#: ../../library/datetime.rst:531 msgid "" "Return the local date corresponding to the POSIX *timestamp*, such as is " "returned by :func:`time.time`." msgstr "" -#: ../../library/datetime.rst:538 +#: ../../library/datetime.rst:534 msgid "" "This may raise :exc:`OverflowError`, if the timestamp is out of the range of " "values supported by the platform C :c:func:`localtime` function, and :exc:" @@ -888,7 +888,7 @@ msgid "" "ignored by :meth:`fromtimestamp`." msgstr "" -#: ../../library/datetime.rst:545 +#: ../../library/datetime.rst:541 msgid "" "Raise :exc:`OverflowError` instead of :exc:`ValueError` if the timestamp is " "out of the range of values supported by the platform C :c:func:`localtime` " @@ -896,45 +896,50 @@ msgid "" "`localtime` failure." msgstr "" -#: ../../library/datetime.rst:554 +#: ../../library/datetime.rst:547 ../../library/datetime.rst:1042 +#: ../../library/datetime.rst:1082 +msgid "Accepts any real number as *timestamp*, not only integer or float." +msgstr "" + +#: ../../library/datetime.rst:553 msgid "" "Return the date corresponding to the proleptic Gregorian *ordinal*, where " "January 1 of year 1 has ordinal 1." msgstr "" -#: ../../library/datetime.rst:557 +#: ../../library/datetime.rst:556 msgid "" ":exc:`ValueError` is raised unless ``1 <= ordinal <= date.max.toordinal()``. " "For any date ``d``, ``date.fromordinal(d.toordinal()) == d``." msgstr "" -#: ../../library/datetime.rst:564 +#: ../../library/datetime.rst:563 msgid "" "Return a :class:`date` corresponding to a *date_string* given in any valid " "ISO 8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:567 ../../library/datetime.rst:1121 +#: ../../library/datetime.rst:566 ../../library/datetime.rst:1123 msgid "" "Reduced precision dates are not currently supported (``YYYY-MM``, ``YYYY``)." msgstr "" -#: ../../library/datetime.rst:569 ../../library/datetime.rst:1123 +#: ../../library/datetime.rst:568 ../../library/datetime.rst:1125 msgid "" "Extended date representations are not currently supported (``±YYYYYY-MM-" "DD``)." msgstr "" -#: ../../library/datetime.rst:571 ../../library/datetime.rst:1125 +#: ../../library/datetime.rst:570 ../../library/datetime.rst:1127 msgid "Ordinal dates are not currently supported (``YYYY-OOO``)." msgstr "" -#: ../../library/datetime.rst:573 ../../library/datetime.rst:1127 -#: ../../library/datetime.rst:1603 +#: ../../library/datetime.rst:572 ../../library/datetime.rst:1129 +#: ../../library/datetime.rst:1604 msgid "Examples::" msgstr "範例: ::" -#: ../../library/datetime.rst:575 +#: ../../library/datetime.rst:574 msgid "" ">>> import datetime as dt\n" ">>> dt.date.fromisoformat('2019-12-04')\n" @@ -952,46 +957,45 @@ msgstr "" ">>> dt.date.fromisoformat('2021-W01-1')\n" "datetime.date(2021, 1, 4)" -#: ../../library/datetime.rst:584 +#: ../../library/datetime.rst:583 msgid "Previously, this method only supported the format ``YYYY-MM-DD``." msgstr "" -#: ../../library/datetime.rst:590 +#: ../../library/datetime.rst:589 msgid "" "Return a :class:`date` corresponding to the ISO calendar date specified by " "*year*, *week* and *day*. This is the inverse of the function :meth:`date." "isocalendar`." msgstr "" -#: ../../library/datetime.rst:598 +#: ../../library/datetime.rst:597 msgid "" "Return a :class:`.date` corresponding to *date_string*, parsed according to " "*format*. This is equivalent to::" msgstr "" -#: ../../library/datetime.rst:601 +#: ../../library/datetime.rst:600 msgid "date(*(time.strptime(date_string, format)[0:3]))" msgstr "date(*(time.strptime(date_string, format)[0:3]))" -#: ../../library/datetime.rst:603 +#: ../../library/datetime.rst:602 msgid "" ":exc:`ValueError` is raised if the date_string and format can't be parsed " "by :func:`time.strptime` or if it returns a value which isn't a time tuple. " "See also :ref:`strftime-strptime-behavior` and :meth:`date.fromisoformat`." msgstr "" -#: ../../library/datetime.rst:610 +#: ../../library/datetime.rst:609 ../../library/datetime.rst:1184 msgid "" -"If *format* specifies a day of month without a year a :exc:" -"`DeprecationWarning` is emitted. This is to avoid a quadrennial leap year " -"bug in code seeking to parse only a month and day as the default year used " -"in absence of one in the format is not a leap year. Such *format* values may " -"raise an error as of Python 3.15. The workaround is to always include a " -"year in your *format*. If parsing *date_string* values that do not have a " -"year, explicitly add a year that is a leap year before parsing:" +"If *format* specifies a day of month (``%d``) without a year, :exc:" +"`ValueError` is raised. This is to avoid a quadrennial leap year bug in " +"code seeking to parse only a month and day as the default year used in " +"absence of one in the format is not a leap year. The workaround is to always " +"include a year in your *format*. If parsing *date_string* values that do " +"not have a year, explicitly add a year that is a leap year before parsing:" msgstr "" -#: ../../library/datetime.rst:619 +#: ../../library/datetime.rst:617 msgid "" ">>> import datetime as dt\n" ">>> date_string = \"02/29\"\n" @@ -1007,53 +1011,53 @@ msgstr "" ">>> when.strftime(\"%B %d\")\n" "'February 29'" -#: ../../library/datetime.rst:634 +#: ../../library/datetime.rst:632 msgid "The earliest representable date, ``date(MINYEAR, 1, 1)``." msgstr "" -#: ../../library/datetime.rst:639 +#: ../../library/datetime.rst:637 msgid "The latest representable date, ``date(MAXYEAR, 12, 31)``." msgstr "" -#: ../../library/datetime.rst:644 +#: ../../library/datetime.rst:642 msgid "" "The smallest possible difference between non-equal date objects, " "``timedelta(days=1)``." msgstr "" -#: ../../library/datetime.rst:652 ../../library/datetime.rst:1224 +#: ../../library/datetime.rst:650 ../../library/datetime.rst:1225 msgid "Between :const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -#: ../../library/datetime.rst:657 ../../library/datetime.rst:1229 +#: ../../library/datetime.rst:655 ../../library/datetime.rst:1230 msgid "Between 1 and 12 inclusive." msgstr "在 1 到 12 (含)之間。" -#: ../../library/datetime.rst:662 ../../library/datetime.rst:1234 +#: ../../library/datetime.rst:660 ../../library/datetime.rst:1235 msgid "Between 1 and the number of days in the given month of the given year." msgstr "" -#: ../../library/datetime.rst:670 +#: ../../library/datetime.rst:668 msgid "``date2 = date1 + timedelta``" msgstr "``date2 = date1 + timedelta``" -#: ../../library/datetime.rst:670 +#: ../../library/datetime.rst:668 msgid "``date2`` will be ``timedelta.days`` days after ``date1``. (1)" msgstr "" -#: ../../library/datetime.rst:673 +#: ../../library/datetime.rst:671 msgid "``date2 = date1 - timedelta``" msgstr "``date2 = date1 - timedelta``" -#: ../../library/datetime.rst:673 +#: ../../library/datetime.rst:671 msgid "Computes ``date2`` such that ``date2 + timedelta == date1``. (2)" msgstr "" -#: ../../library/datetime.rst:676 +#: ../../library/datetime.rst:674 msgid "``timedelta = date1 - date2``" msgstr "``timedelta = date1 - date2``" -#: ../../library/datetime.rst:676 ../../library/datetime.rst:1283 +#: ../../library/datetime.rst:674 ../../library/datetime.rst:1284 msgid "\\(3)" msgstr "\\(3)" @@ -1065,7 +1069,7 @@ msgstr "``date1 == date2``" msgid "``date1 != date2``" msgstr "``date1 != date2``" -#: ../../library/datetime.rst:678 ../../library/datetime.rst:1285 +#: ../../library/datetime.rst:676 ../../library/datetime.rst:1286 msgid "Equality comparison. (4)" msgstr "" @@ -1085,11 +1089,11 @@ msgstr "``date1 <= date2``" msgid "``date1 >= date2``" msgstr "``date1 >= date2``" -#: ../../library/datetime.rst:681 ../../library/datetime.rst:1288 +#: ../../library/datetime.rst:679 ../../library/datetime.rst:1289 msgid "Order comparison. (5)" msgstr "" -#: ../../library/datetime.rst:690 +#: ../../library/datetime.rst:688 msgid "" "*date2* is moved forward in time if ``timedelta.days > 0``, or backward if " "``timedelta.days < 0``. Afterward ``date2 - date1 == timedelta.days``. " @@ -1098,41 +1102,41 @@ msgid "" "`MINYEAR` or larger than :const:`MAXYEAR`." msgstr "" -#: ../../library/datetime.rst:697 +#: ../../library/datetime.rst:695 msgid "``timedelta.seconds`` and ``timedelta.microseconds`` are ignored." msgstr "``timedelta.seconds`` 和 ``timedelta.microseconds`` 被忽略。" -#: ../../library/datetime.rst:700 +#: ../../library/datetime.rst:698 msgid "" "This is exact, and cannot overflow. ``timedelta.seconds`` and ``timedelta." "microseconds`` are 0, and ``date2 + timedelta == date1`` after." msgstr "" -#: ../../library/datetime.rst:704 +#: ../../library/datetime.rst:702 msgid ":class:`date` objects are equal if they represent the same date." msgstr "" -#: ../../library/datetime.rst:706 +#: ../../library/datetime.rst:704 msgid "" ":class:`!date` objects that are not also :class:`.datetime` instances are " "never equal to :class:`!datetime` objects, even if they represent the same " "date." msgstr "" -#: ../../library/datetime.rst:711 +#: ../../library/datetime.rst:709 msgid "" "*date1* is considered less than *date2* when *date1* precedes *date2* in " "time. In other words, ``date1 < date2`` if and only if ``date1.toordinal() < " "date2.toordinal()``." msgstr "" -#: ../../library/datetime.rst:715 +#: ../../library/datetime.rst:713 msgid "" "Order comparison between a :class:`date` object that is not also a :class:`." "datetime` instance and a :class:`!datetime` object raises :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:719 ../../library/datetime.rst:1356 +#: ../../library/datetime.rst:717 ../../library/datetime.rst:1357 msgid "" "Comparison between :class:`.datetime` object and an instance of the :class:" "`date` subclass that is not a :class:`!datetime` subclass no longer converts " @@ -1141,22 +1145,22 @@ msgid "" "in subclasses." msgstr "" -#: ../../library/datetime.rst:727 +#: ../../library/datetime.rst:725 msgid "" "In Boolean contexts, all :class:`date` objects are considered to be true." msgstr "" -#: ../../library/datetime.rst:733 +#: ../../library/datetime.rst:731 msgid "" "Return a new :class:`date` object with the same values, but with specified " "parameters updated." msgstr "" -#: ../../library/datetime.rst:736 ../../library/datetime.rst:2040 +#: ../../library/datetime.rst:734 ../../library/datetime.rst:2041 msgid "Example::" msgstr "範例: ::" -#: ../../library/datetime.rst:738 +#: ../../library/datetime.rst:736 msgid "" ">>> import datetime as dt\n" ">>> d = dt.date(2002, 12, 31)\n" @@ -1168,47 +1172,47 @@ msgstr "" ">>> d.replace(day=26)\n" "datetime.date(2002, 12, 26)" -#: ../../library/datetime.rst:743 +#: ../../library/datetime.rst:741 msgid "" "The generic function :func:`copy.replace` also supports :class:`date` " "objects." msgstr "" -#: ../../library/datetime.rst:749 ../../library/datetime.rst:1481 +#: ../../library/datetime.rst:747 ../../library/datetime.rst:1482 msgid "" "Return a :class:`time.struct_time` such as returned by :func:`time." "localtime`." msgstr "" "回傳一個 :class:`time.struct_time`,如同 :func:`time.localtime` 所回傳。" -#: ../../library/datetime.rst:751 +#: ../../library/datetime.rst:749 msgid "The hours, minutes and seconds are 0, and the DST flag is -1." msgstr "" -#: ../../library/datetime.rst:753 ../../library/datetime.rst:1483 +#: ../../library/datetime.rst:751 ../../library/datetime.rst:1484 msgid "``d.timetuple()`` is equivalent to::" msgstr "``d.timetuple()`` 等價於: ::" -#: ../../library/datetime.rst:755 +#: ../../library/datetime.rst:753 msgid "" "time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))" msgstr "" "time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))" -#: ../../library/datetime.rst:757 +#: ../../library/datetime.rst:755 msgid "" "where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1`` is the " "day number within the current year starting with 1 for January 1st." msgstr "" -#: ../../library/datetime.rst:763 +#: ../../library/datetime.rst:761 msgid "" "Return the proleptic Gregorian ordinal of the date, where January 1 of year " "1 has ordinal 1. For any :class:`date` object ``d``, ``date.fromordinal(d." "toordinal()) == d``." msgstr "" -#: ../../library/datetime.rst:770 +#: ../../library/datetime.rst:768 msgid "" "Return the day of the week as an integer, where Monday is 0 and Sunday is 6. " "For example, ``date(2002, 12, 4).weekday() == 2``, a Wednesday. See also :" @@ -1217,25 +1221,25 @@ msgstr "" "回傳一個代表星期幾的整數,星期一為 0、星期日為 6。例如 ``date(2002, 12, 4)." "weekday() == 2`` 為星期三。也請參考 :meth:`isoweekday`。" -#: ../../library/datetime.rst:777 +#: ../../library/datetime.rst:775 msgid "" "Return the day of the week as an integer, where Monday is 1 and Sunday is 7. " "For example, ``date(2002, 12, 4).isoweekday() == 3``, a Wednesday. See also :" "meth:`weekday`, :meth:`isocalendar`." msgstr "" -#: ../../library/datetime.rst:784 +#: ../../library/datetime.rst:782 msgid "" "Return a :term:`named tuple` object with three components: ``year``, " "``week`` and ``weekday``." msgstr "" -#: ../../library/datetime.rst:787 +#: ../../library/datetime.rst:785 msgid "" "The ISO calendar is a widely used variant of the Gregorian calendar. [#]_" msgstr "" -#: ../../library/datetime.rst:789 +#: ../../library/datetime.rst:787 msgid "" "The ISO year consists of 52 or 53 full weeks, and where a week starts on a " "Monday and ends on a Sunday. The first week of an ISO year is the first " @@ -1244,13 +1248,13 @@ msgid "" "Gregorian year." msgstr "" -#: ../../library/datetime.rst:794 +#: ../../library/datetime.rst:792 msgid "" "For example, 2004 begins on a Thursday, so the first week of ISO year 2004 " "begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004::" msgstr "" -#: ../../library/datetime.rst:797 +#: ../../library/datetime.rst:795 msgid "" ">>> import datetime as dt\n" ">>> dt.date(2003, 12, 29).isocalendar()\n" @@ -1264,16 +1268,16 @@ msgstr "" ">>> dt.date(2004, 1, 4).isocalendar()\n" "datetime.IsoCalendarDate(year=2004, week=1, weekday=7)" -#: ../../library/datetime.rst:803 +#: ../../library/datetime.rst:801 msgid "Result changed from a tuple to a :term:`named tuple`." msgstr "" -#: ../../library/datetime.rst:809 +#: ../../library/datetime.rst:807 msgid "" "Return a string representing the date in ISO 8601 format, ``YYYY-MM-DD``::" msgstr "回傳一以 ISO 8601 格式 ``YYYY-MM-DD`` 表示的日期字串: ::" -#: ../../library/datetime.rst:811 +#: ../../library/datetime.rst:809 msgid "" ">>> import datetime as dt\n" ">>> dt.date(2002, 12, 4).isoformat()\n" @@ -1283,15 +1287,15 @@ msgstr "" ">>> dt.date(2002, 12, 4).isoformat()\n" "'2002-12-04'" -#: ../../library/datetime.rst:818 +#: ../../library/datetime.rst:816 msgid "For a date ``d``, ``str(d)`` is equivalent to ``d.isoformat()``." msgstr "" -#: ../../library/datetime.rst:823 +#: ../../library/datetime.rst:821 msgid "Return a string representing the date::" msgstr "" -#: ../../library/datetime.rst:825 +#: ../../library/datetime.rst:823 msgid "" ">>> import datetime as dt\n" ">>> dt.date(2002, 12, 4).ctime()\n" @@ -1301,22 +1305,22 @@ msgstr "" ">>> dt.date(2002, 12, 4).ctime()\n" "'Wed Dec 4 00:00:00 2002'" -#: ../../library/datetime.rst:829 ../../library/datetime.rst:1674 +#: ../../library/datetime.rst:827 ../../library/datetime.rst:1675 msgid "``d.ctime()`` is equivalent to::" msgstr "``d.ctime()`` 等價於: ::" -#: ../../library/datetime.rst:831 ../../library/datetime.rst:1676 +#: ../../library/datetime.rst:829 ../../library/datetime.rst:1677 msgid "time.ctime(time.mktime(d.timetuple()))" msgstr "time.ctime(time.mktime(d.timetuple()))" -#: ../../library/datetime.rst:833 +#: ../../library/datetime.rst:831 msgid "" "on platforms where the native C :c:func:`ctime` function (which :func:`time." "ctime` invokes, but which :meth:`date.ctime` does not invoke) conforms to " "the C standard." msgstr "" -#: ../../library/datetime.rst:840 +#: ../../library/datetime.rst:838 msgid "" "Return a string representing the date, controlled by an explicit format " "string. Format codes referring to hours, minutes or seconds will see 0 " @@ -1324,7 +1328,7 @@ msgid "" "isoformat`." msgstr "" -#: ../../library/datetime.rst:847 +#: ../../library/datetime.rst:845 msgid "" "Same as :meth:`.date.strftime`. This makes it possible to specify a format " "string for a :class:`.date` object in :ref:`formatted string literals >> import time\n" ">>> import datetime as dt\n" @@ -1376,11 +1380,11 @@ msgstr "" ">>> time_to_birthday.days\n" "202" -#: ../../library/datetime.rst:875 +#: ../../library/datetime.rst:873 msgid "More examples of working with :class:`date`:" msgstr "更多 :class:`date` 的用法範例:" -#: ../../library/datetime.rst:877 +#: ../../library/datetime.rst:875 msgid "" ">>> import datetime as dt\n" ">>> d = dt.date.fromordinal(730920) # 730920th day after 1. 1. 0001\n" @@ -1424,17 +1428,17 @@ msgid "" "datetime.date(2005, 3, 11)" msgstr "" -#: ../../library/datetime.rst:924 +#: ../../library/datetime.rst:922 msgid ":class:`!datetime` objects" msgstr ":class:`!datetime` 物件" -#: ../../library/datetime.rst:926 +#: ../../library/datetime.rst:924 msgid "" "A :class:`.datetime` object is a single object containing all the " "information from a :class:`date` object and a :class:`.time` object." msgstr "" -#: ../../library/datetime.rst:929 +#: ../../library/datetime.rst:927 msgid "" "Like a :class:`date` object, :class:`.datetime` assumes the current " "Gregorian calendar extended in both directions; like a :class:`.time` " @@ -1442,81 +1446,81 @@ msgid "" "every day." msgstr "" -#: ../../library/datetime.rst:933 +#: ../../library/datetime.rst:931 msgid "Constructor:" msgstr "建構函式:" -#: ../../library/datetime.rst:937 +#: ../../library/datetime.rst:935 msgid "" "The *year*, *month* and *day* arguments are required. *tzinfo* may be " "``None``, or an instance of a :class:`tzinfo` subclass. The remaining " "arguments must be integers in the following ranges:" msgstr "" -#: ../../library/datetime.rst:941 +#: ../../library/datetime.rst:939 msgid "``MINYEAR <= year <= MAXYEAR``," msgstr "``MINYEAR <= year <= MAXYEAR``," -#: ../../library/datetime.rst:942 +#: ../../library/datetime.rst:940 msgid "``1 <= month <= 12``," msgstr "``1 <= month <= 12``," -#: ../../library/datetime.rst:943 +#: ../../library/datetime.rst:941 msgid "``1 <= day <= number of days in the given month and year``," msgstr "" -#: ../../library/datetime.rst:944 ../../library/datetime.rst:1839 +#: ../../library/datetime.rst:942 ../../library/datetime.rst:1840 msgid "``0 <= hour < 24``," msgstr "``0 <= hour < 24``," -#: ../../library/datetime.rst:945 ../../library/datetime.rst:1840 +#: ../../library/datetime.rst:943 ../../library/datetime.rst:1841 msgid "``0 <= minute < 60``," msgstr "``0 <= minute < 60``," -#: ../../library/datetime.rst:946 ../../library/datetime.rst:1841 +#: ../../library/datetime.rst:944 ../../library/datetime.rst:1842 msgid "``0 <= second < 60``," msgstr "``0 <= second < 60``," -#: ../../library/datetime.rst:947 ../../library/datetime.rst:1842 +#: ../../library/datetime.rst:945 ../../library/datetime.rst:1843 msgid "``0 <= microsecond < 1000000``," msgstr "``0 <= microsecond < 1000000``," -#: ../../library/datetime.rst:948 ../../library/datetime.rst:1843 +#: ../../library/datetime.rst:946 ../../library/datetime.rst:1844 msgid "``fold in [0, 1]``." msgstr "``fold in [0, 1]``。" -#: ../../library/datetime.rst:952 ../../library/datetime.rst:1402 -#: ../../library/datetime.rst:2007 +#: ../../library/datetime.rst:950 ../../library/datetime.rst:1403 +#: ../../library/datetime.rst:2008 msgid "Added the *fold* parameter." msgstr "新增 *fold* 參數。" -#: ../../library/datetime.rst:960 +#: ../../library/datetime.rst:958 msgid "Return the current local date and time, with :attr:`.tzinfo` ``None``." msgstr "回傳目前的本地日期與時間,且 :attr:`.tzinfo` 為 ``None``。" -#: ../../library/datetime.rst:962 +#: ../../library/datetime.rst:960 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../library/datetime.rst:964 +#: ../../library/datetime.rst:962 msgid "datetime.fromtimestamp(time.time())" msgstr "datetime.fromtimestamp(time.time())" -#: ../../library/datetime.rst:966 +#: ../../library/datetime.rst:964 msgid "See also :meth:`now`, :meth:`fromtimestamp`." msgstr "也請見 :meth:`now`、:meth:`fromtimestamp`。" -#: ../../library/datetime.rst:968 +#: ../../library/datetime.rst:966 msgid "" "This method is functionally equivalent to :meth:`now`, but without a ``tz`` " "parameter." msgstr "" -#: ../../library/datetime.rst:974 +#: ../../library/datetime.rst:972 msgid "Return the current local date and time." msgstr "" -#: ../../library/datetime.rst:976 +#: ../../library/datetime.rst:974 msgid "" "If optional argument *tz* is ``None`` or not specified, this is like :meth:" "`today`, but, if possible, supplies more precision than can be gotten from " @@ -1527,34 +1531,34 @@ msgstr "" "供比透過 :func:`time.time` 取得的時間戳記更多位數的資訊(例如,這在有提供 C :" "c:func:`gettimeofday` 函式的平台上可能可行)。" -#: ../../library/datetime.rst:982 +#: ../../library/datetime.rst:980 msgid "" "If *tz* is not ``None``, it must be an instance of a :class:`tzinfo` " "subclass, and the current date and time are converted to *tz*’s time zone." msgstr "" -#: ../../library/datetime.rst:985 +#: ../../library/datetime.rst:983 msgid "This function is preferred over :meth:`today` and :meth:`utcnow`." msgstr "" -#: ../../library/datetime.rst:989 +#: ../../library/datetime.rst:987 msgid "" "Subsequent calls to :meth:`!datetime.now` may return the same instant " "depending on the precision of the underlying clock." msgstr "" -#: ../../library/datetime.rst:995 +#: ../../library/datetime.rst:993 msgid "Return the current UTC date and time, with :attr:`.tzinfo` ``None``." msgstr "" -#: ../../library/datetime.rst:997 +#: ../../library/datetime.rst:995 msgid "" "This is like :meth:`now`, but returns the current UTC date and time, as a " "naive :class:`.datetime` object. An aware current UTC datetime can be " "obtained by calling ``datetime.now(timezone.utc)``. See also :meth:`now`." msgstr "" -#: ../../library/datetime.rst:1003 +#: ../../library/datetime.rst:1001 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " @@ -1562,11 +1566,11 @@ msgid "" "current time in UTC is by calling ``datetime.now(timezone.utc)``." msgstr "" -#: ../../library/datetime.rst:1010 +#: ../../library/datetime.rst:1008 msgid "Use :meth:`datetime.now` with :const:`UTC` instead." msgstr "" -#: ../../library/datetime.rst:1015 +#: ../../library/datetime.rst:1013 msgid "" "Return the local date and time corresponding to the POSIX timestamp, such as " "is returned by :func:`time.time`. If optional argument *tz* is ``None`` or " @@ -1574,13 +1578,13 @@ msgid "" "time, and the returned :class:`.datetime` object is naive." msgstr "" -#: ../../library/datetime.rst:1020 +#: ../../library/datetime.rst:1018 msgid "" "If *tz* is not ``None``, it must be an instance of a :class:`tzinfo` " "subclass, and the timestamp is converted to *tz*’s time zone." msgstr "" -#: ../../library/datetime.rst:1023 +#: ../../library/datetime.rst:1021 msgid "" ":meth:`fromtimestamp` may raise :exc:`OverflowError`, if the timestamp is " "out of the range of values supported by the platform C :c:func:`localtime` " @@ -1593,7 +1597,7 @@ msgid "" "preferred over :meth:`utcfromtimestamp`." msgstr "" -#: ../../library/datetime.rst:1034 +#: ../../library/datetime.rst:1032 msgid "" "Raise :exc:`OverflowError` instead of :exc:`ValueError` if the timestamp is " "out of the range of values supported by the platform C :c:func:`localtime` " @@ -1601,17 +1605,17 @@ msgid "" "`ValueError` on :c:func:`localtime` or :c:func:`gmtime` failure." msgstr "" -#: ../../library/datetime.rst:1041 +#: ../../library/datetime.rst:1039 msgid ":meth:`fromtimestamp` may return instances with :attr:`.fold` set to 1." msgstr "" -#: ../../library/datetime.rst:1046 +#: ../../library/datetime.rst:1048 msgid "" "Return the UTC :class:`.datetime` corresponding to the POSIX timestamp, " "with :attr:`.tzinfo` ``None``. (The resulting object is naive.)" msgstr "" -#: ../../library/datetime.rst:1049 +#: ../../library/datetime.rst:1051 msgid "" "This may raise :exc:`OverflowError`, if the timestamp is out of the range of " "values supported by the platform C :c:func:`gmtime` function, and :exc:" @@ -1619,33 +1623,33 @@ msgid "" "to years in 1970 through 2038." msgstr "" -#: ../../library/datetime.rst:1054 +#: ../../library/datetime.rst:1056 msgid "To get an aware :class:`.datetime` object, call :meth:`fromtimestamp`::" msgstr "" -#: ../../library/datetime.rst:1056 +#: ../../library/datetime.rst:1058 msgid "datetime.fromtimestamp(timestamp, timezone.utc)" msgstr "datetime.fromtimestamp(timestamp, timezone.utc)" -#: ../../library/datetime.rst:1058 +#: ../../library/datetime.rst:1060 msgid "" "On the POSIX compliant platforms, it is equivalent to the following " "expression::" msgstr "" -#: ../../library/datetime.rst:1061 +#: ../../library/datetime.rst:1063 msgid "" "datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp)" msgstr "" "datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp)" -#: ../../library/datetime.rst:1063 +#: ../../library/datetime.rst:1065 msgid "" "except the latter formula always supports the full years range: between :" "const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -#: ../../library/datetime.rst:1068 +#: ../../library/datetime.rst:1070 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " @@ -1654,7 +1658,7 @@ msgid "" "tz=timezone.utc)``." msgstr "" -#: ../../library/datetime.rst:1074 +#: ../../library/datetime.rst:1076 msgid "" "Raise :exc:`OverflowError` instead of :exc:`ValueError` if the timestamp is " "out of the range of values supported by the platform C :c:func:`gmtime` " @@ -1662,15 +1666,11 @@ msgid "" "`gmtime` failure." msgstr "" -#: ../../library/datetime.rst:1080 -msgid "Accepts any real number as *timestamp*, not only integer or float." -msgstr "" - -#: ../../library/datetime.rst:1085 +#: ../../library/datetime.rst:1087 msgid "Use :meth:`datetime.fromtimestamp` with :const:`UTC` instead." msgstr "" -#: ../../library/datetime.rst:1090 +#: ../../library/datetime.rst:1092 msgid "" "Return the :class:`.datetime` corresponding to the proleptic Gregorian " "ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is " @@ -1679,7 +1679,7 @@ msgid "" "is ``None``." msgstr "" -#: ../../library/datetime.rst:1098 +#: ../../library/datetime.rst:1100 msgid "" "Return a new :class:`.datetime` object whose date components are equal to " "the given :class:`date` object's, and whose time components are equal to the " @@ -1690,35 +1690,35 @@ msgid "" "attr:`.tzinfo` attributes are ignored." msgstr "" -#: ../../library/datetime.rst:1106 +#: ../../library/datetime.rst:1108 msgid "" "For any :class:`.datetime` object ``d``, ``d == datetime.combine(d.date(), d." "time(), d.tzinfo)``." msgstr "" -#: ../../library/datetime.rst:1109 +#: ../../library/datetime.rst:1111 msgid "Added the *tzinfo* argument." msgstr "新增 *tzinfo* 引數。" -#: ../../library/datetime.rst:1115 +#: ../../library/datetime.rst:1117 msgid "" "Return a :class:`.datetime` corresponding to a *date_string* in any valid " "ISO 8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:1118 ../../library/datetime.rst:1941 +#: ../../library/datetime.rst:1120 ../../library/datetime.rst:1942 msgid "Time zone offsets may have fractional seconds." msgstr "" -#: ../../library/datetime.rst:1119 +#: ../../library/datetime.rst:1121 msgid "The ``T`` separator may be replaced by any single unicode character." msgstr "" -#: ../../library/datetime.rst:1120 ../../library/datetime.rst:1946 +#: ../../library/datetime.rst:1122 ../../library/datetime.rst:1947 msgid "Fractional hours and minutes are not supported." msgstr "" -#: ../../library/datetime.rst:1129 +#: ../../library/datetime.rst:1131 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime.fromisoformat('2011-11-04')\n" @@ -1764,13 +1764,13 @@ msgstr "" "datetime.datetime(2011, 11, 4, 0, 5, 23,\n" " tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))" -#: ../../library/datetime.rst:1151 +#: ../../library/datetime.rst:1153 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`date.isoformat` or :meth:`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1158 +#: ../../library/datetime.rst:1160 msgid "" "Return a :class:`.datetime` corresponding to the ISO calendar date specified " "by *year*, *week* and *day*. The non-date components of the datetime are " @@ -1778,23 +1778,23 @@ msgid "" "function :meth:`datetime.isocalendar`." msgstr "" -#: ../../library/datetime.rst:1168 +#: ../../library/datetime.rst:1170 msgid "" "Return a :class:`.datetime` corresponding to *date_string*, parsed according " "to *format*." msgstr "" -#: ../../library/datetime.rst:1171 +#: ../../library/datetime.rst:1173 msgid "" "If *format* does not contain microseconds or time zone information, this is " "equivalent to::" msgstr "" -#: ../../library/datetime.rst:1173 ../../library/datetime.rst:2734 +#: ../../library/datetime.rst:1175 ../../library/datetime.rst:2776 msgid "datetime(*(time.strptime(date_string, format)[0:6]))" msgstr "datetime(*(time.strptime(date_string, format)[0:6]))" -#: ../../library/datetime.rst:1175 +#: ../../library/datetime.rst:1177 msgid "" ":exc:`ValueError` is raised if the date_string and format can't be parsed " "by :func:`time.strptime` or if it returns a value which isn't a time tuple. " @@ -1802,18 +1802,7 @@ msgid "" "fromisoformat`." msgstr "" -#: ../../library/datetime.rst:1182 -msgid "" -"If *format* specifies a day of month without a year a :exc:" -"`DeprecationWarning` is now emitted. This is to avoid a quadrennial leap " -"year bug in code seeking to parse only a month and day as the default year " -"used in absence of one in the format is not a leap year. Such *format* " -"values may raise an error as of Python 3.15. The workaround is to always " -"include a year in your *format*. If parsing *date_string* values that do " -"not have a year, explicitly add a year that is a leap year before parsing:" -msgstr "" - -#: ../../library/datetime.rst:1191 +#: ../../library/datetime.rst:1192 msgid "" ">>> import datetime as dt\n" ">>> date_string = \"02/29\"\n" @@ -1829,44 +1818,44 @@ msgstr "" ">>> when.strftime(\"%B %d\")\n" "'February 29'" -#: ../../library/datetime.rst:1204 +#: ../../library/datetime.rst:1205 msgid "" "The earliest representable :class:`.datetime`, ``datetime(MINYEAR, 1, 1, " "tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1210 +#: ../../library/datetime.rst:1211 msgid "" "The latest representable :class:`.datetime`, ``datetime(MAXYEAR, 12, 31, 23, " "59, 59, 999999, tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1216 +#: ../../library/datetime.rst:1217 msgid "" "The smallest possible difference between non-equal :class:`.datetime` " "objects, ``timedelta(microseconds=1)``." msgstr "" -#: ../../library/datetime.rst:1239 ../../library/datetime.rst:1873 +#: ../../library/datetime.rst:1240 ../../library/datetime.rst:1874 msgid "In ``range(24)``." msgstr "" -#: ../../library/datetime.rst:1244 ../../library/datetime.rst:1249 -#: ../../library/datetime.rst:1878 ../../library/datetime.rst:1883 +#: ../../library/datetime.rst:1245 ../../library/datetime.rst:1250 +#: ../../library/datetime.rst:1879 ../../library/datetime.rst:1884 msgid "In ``range(60)``." msgstr "" -#: ../../library/datetime.rst:1254 ../../library/datetime.rst:1888 +#: ../../library/datetime.rst:1255 ../../library/datetime.rst:1889 msgid "In ``range(1000000)``." msgstr "" -#: ../../library/datetime.rst:1259 +#: ../../library/datetime.rst:1260 msgid "" "The object passed as the *tzinfo* argument to the :class:`.datetime` " "constructor, or ``None`` if none was passed." msgstr "" -#: ../../library/datetime.rst:1265 ../../library/datetime.rst:1899 +#: ../../library/datetime.rst:1266 ../../library/datetime.rst:1900 msgid "" "In ``[0, 1]``. Used to disambiguate wall times during a repeated interval. " "(A repeated interval occurs when clocks are rolled back at the end of " @@ -1876,26 +1865,26 @@ msgid "" "time representation." msgstr "" -#: ../../library/datetime.rst:1279 +#: ../../library/datetime.rst:1280 msgid "``datetime2 = datetime1 + timedelta``" msgstr "``datetime2 = datetime1 + timedelta``" -#: ../../library/datetime.rst:1279 ../../library/datetime.rst:2542 -#: ../../library/datetime.rst:2547 ../../library/datetime.rst:2559 -#: ../../library/datetime.rst:2564 ../../library/datetime.rst:2624 -#: ../../library/datetime.rst:2629 ../../library/datetime.rst:2633 +#: ../../library/datetime.rst:1280 ../../library/datetime.rst:2544 +#: ../../library/datetime.rst:2549 ../../library/datetime.rst:2554 +#: ../../library/datetime.rst:2559 ../../library/datetime.rst:2564 +#: ../../library/datetime.rst:2664 ../../library/datetime.rst:2668 msgid "\\(1)" msgstr "\\(1)" -#: ../../library/datetime.rst:1281 +#: ../../library/datetime.rst:1282 msgid "``datetime2 = datetime1 - timedelta``" msgstr "``datetime2 = datetime1 - timedelta``" -#: ../../library/datetime.rst:1281 ../../library/datetime.rst:2575 +#: ../../library/datetime.rst:1282 ../../library/datetime.rst:2674 msgid "\\(2)" msgstr "\\(2)" -#: ../../library/datetime.rst:1283 +#: ../../library/datetime.rst:1284 msgid "``timedelta = datetime1 - datetime2``" msgstr "``timedelta = datetime1 - datetime2``" @@ -1923,7 +1912,7 @@ msgstr "``datetime1 <= datetime2``" msgid "``datetime1 >= datetime2``" msgstr "``datetime1 >= datetime2``" -#: ../../library/datetime.rst:1295 +#: ../../library/datetime.rst:1296 msgid "" "``datetime2`` is a duration of ``timedelta`` removed from ``datetime1``, " "moving forward in time if ``timedelta.days > 0``, or backward if ``timedelta." @@ -1934,7 +1923,7 @@ msgid "" "adjustments are done even if the input is an aware object." msgstr "" -#: ../../library/datetime.rst:1304 +#: ../../library/datetime.rst:1305 msgid "" "Computes the ``datetime2`` such that ``datetime2 + timedelta == datetime1``. " "As for addition, the result has the same :attr:`~.datetime.tzinfo` attribute " @@ -1942,14 +1931,14 @@ msgid "" "input is aware." msgstr "" -#: ../../library/datetime.rst:1309 +#: ../../library/datetime.rst:1310 msgid "" "Subtraction of a :class:`.datetime` from a :class:`!datetime` is defined " "only if both operands are naive, or if both are aware. If one is aware and " "the other is naive, :exc:`TypeError` is raised." msgstr "" -#: ../../library/datetime.rst:1313 +#: ../../library/datetime.rst:1314 msgid "" "If both are naive, or both are aware and have the same :attr:`~.datetime." "tzinfo` attribute, the :attr:`~.datetime.tzinfo` attributes are ignored, and " @@ -1957,7 +1946,7 @@ msgid "" "datetime1``. No time zone adjustments are done in this case." msgstr "" -#: ../../library/datetime.rst:1318 +#: ../../library/datetime.rst:1319 msgid "" "If both are aware and have different :attr:`~.datetime.tzinfo` attributes, " "``a-b`` acts as if ``a`` and ``b`` were first converted to naive UTC " @@ -1966,17 +1955,17 @@ msgid "" "overflows." msgstr "" -#: ../../library/datetime.rst:1324 +#: ../../library/datetime.rst:1325 msgid "" ":class:`.datetime` objects are equal if they represent the same date and " "time, taking into account the time zone." msgstr "" -#: ../../library/datetime.rst:1327 +#: ../../library/datetime.rst:1328 msgid "Naive and aware :class:`.datetime` objects are never equal." msgstr "" -#: ../../library/datetime.rst:1329 +#: ../../library/datetime.rst:1330 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -1987,19 +1976,19 @@ msgid "" "interval are never equal to :class:`!datetime` instances in other time zone." msgstr "" -#: ../../library/datetime.rst:1339 +#: ../../library/datetime.rst:1340 msgid "" "*datetime1* is considered less than *datetime2* when *datetime1* precedes " "*datetime2* in time, taking into account the time zone." msgstr "" -#: ../../library/datetime.rst:1342 +#: ../../library/datetime.rst:1343 msgid "" "Order comparison between naive and aware :class:`.datetime` objects raises :" "exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1345 +#: ../../library/datetime.rst:1346 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -2009,33 +1998,33 @@ msgid "" "implementation never overflows." msgstr "" -#: ../../library/datetime.rst:1352 +#: ../../library/datetime.rst:1353 msgid "" "Equality comparisons between aware and naive :class:`.datetime` instances " "don't raise :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1369 +#: ../../library/datetime.rst:1370 msgid "Return :class:`date` object with same year, month and day." msgstr "" -#: ../../library/datetime.rst:1374 +#: ../../library/datetime.rst:1375 msgid "" "Return :class:`.time` object with same hour, minute, second, microsecond and " "fold. :attr:`.tzinfo` is ``None``. See also method :meth:`timetz`." msgstr "" -#: ../../library/datetime.rst:1377 ../../library/datetime.rst:1386 +#: ../../library/datetime.rst:1378 ../../library/datetime.rst:1387 msgid "The fold value is copied to the returned :class:`.time` object." msgstr "" -#: ../../library/datetime.rst:1383 +#: ../../library/datetime.rst:1384 msgid "" "Return :class:`.time` object with same hour, minute, second, microsecond, " "fold, and tzinfo attributes. See also method :meth:`time`." msgstr "" -#: ../../library/datetime.rst:1394 +#: ../../library/datetime.rst:1395 msgid "" "Return a new :class:`datetime` object with the same attributes, but with " "specified parameters updated. Note that ``tzinfo=None`` can be specified to " @@ -2043,27 +2032,27 @@ msgid "" "and time data." msgstr "" -#: ../../library/datetime.rst:1399 +#: ../../library/datetime.rst:1400 msgid "" ":class:`.datetime` objects are also supported by generic function :func:" "`copy.replace`." msgstr "" -#: ../../library/datetime.rst:1408 +#: ../../library/datetime.rst:1409 msgid "" "Return a :class:`.datetime` object with new :attr:`.tzinfo` attribute *tz*, " "adjusting the date and time data so the result is the same UTC time as " "*self*, but in *tz*'s local time." msgstr "" -#: ../../library/datetime.rst:1412 +#: ../../library/datetime.rst:1413 msgid "" "If provided, *tz* must be an instance of a :class:`tzinfo` subclass, and " "its :meth:`utcoffset` and :meth:`dst` methods must not return ``None``. If " "*self* is naive, it is presumed to represent time in the system time zone." msgstr "" -#: ../../library/datetime.rst:1416 +#: ../../library/datetime.rst:1417 msgid "" "If called without arguments (or with ``tz=None``) the system local time zone " "is assumed for the target time zone. The ``.tzinfo`` attribute of the " @@ -2071,7 +2060,7 @@ msgid "" "with the zone name and offset obtained from the OS." msgstr "" -#: ../../library/datetime.rst:1421 +#: ../../library/datetime.rst:1422 msgid "" "If ``self.tzinfo`` is *tz*, ``self.astimezone(tz)`` is equal to *self*: no " "adjustment of date or time data is performed. Else the result is local time " @@ -2080,7 +2069,7 @@ msgid "" "date and time data as ``dt - dt.utcoffset()``." msgstr "" -#: ../../library/datetime.rst:1427 +#: ../../library/datetime.rst:1428 msgid "" "If you merely want to attach a :class:`timezone` object *tz* to a datetime " "*dt* without adjustment of date and time data, use ``dt." @@ -2089,14 +2078,14 @@ msgid "" "use ``dt.replace(tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1432 +#: ../../library/datetime.rst:1433 msgid "" "Note that the default :meth:`tzinfo.fromutc` method can be overridden in a :" "class:`tzinfo` subclass to affect the result returned by :meth:`astimezone`. " "Ignoring error cases, :meth:`astimezone` acts like::" msgstr "" -#: ../../library/datetime.rst:1436 +#: ../../library/datetime.rst:1437 msgid "" "def astimezone(self, tz):\n" " if self.tzinfo is tz:\n" @@ -2107,49 +2096,49 @@ msgid "" " return tz.fromutc(utc)" msgstr "" -#: ../../library/datetime.rst:1444 +#: ../../library/datetime.rst:1445 msgid "*tz* now can be omitted." msgstr "" -#: ../../library/datetime.rst:1447 +#: ../../library/datetime.rst:1448 msgid "" "The :meth:`astimezone` method can now be called on naive instances that are " "presumed to represent system local time." msgstr "" -#: ../../library/datetime.rst:1454 +#: ../../library/datetime.rst:1455 msgid "" "If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." "utcoffset(self)``, and raises an exception if the latter doesn't return " "``None`` or a :class:`timedelta` object with magnitude less than one day." msgstr "" -#: ../../library/datetime.rst:1458 ../../library/datetime.rst:2080 -#: ../../library/datetime.rst:2189 ../../library/datetime.rst:2442 -#: ../../library/datetime.rst:2454 ../../library/datetime.rst:2807 +#: ../../library/datetime.rst:1459 ../../library/datetime.rst:2081 +#: ../../library/datetime.rst:2190 ../../library/datetime.rst:2443 +#: ../../library/datetime.rst:2455 ../../library/datetime.rst:2852 msgid "The UTC offset is not restricted to a whole number of minutes." msgstr "" -#: ../../library/datetime.rst:1464 +#: ../../library/datetime.rst:1465 msgid "" "If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." "dst(self)``, and raises an exception if the latter doesn't return ``None`` " "or a :class:`timedelta` object with magnitude less than one day." msgstr "" -#: ../../library/datetime.rst:1468 ../../library/datetime.rst:2090 -#: ../../library/datetime.rst:2247 +#: ../../library/datetime.rst:1469 ../../library/datetime.rst:2091 +#: ../../library/datetime.rst:2248 msgid "The DST offset is not restricted to a whole number of minutes." msgstr "" -#: ../../library/datetime.rst:1474 +#: ../../library/datetime.rst:1475 msgid "" "If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." "tzname(self)``, raises an exception if the latter doesn't return ``None`` or " "a string object," msgstr "" -#: ../../library/datetime.rst:1485 +#: ../../library/datetime.rst:1486 msgid "" "time.struct_time((d.year, d.month, d.day,\n" " d.hour, d.minute, d.second,\n" @@ -2159,7 +2148,7 @@ msgstr "" " d.hour, d.minute, d.second,\n" " d.weekday(), yday, dst))" -#: ../../library/datetime.rst:1489 +#: ../../library/datetime.rst:1490 msgid "" "where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1`` is the " "day number within the current year starting with 1 for January 1st. The :" @@ -2170,7 +2159,7 @@ msgid "" "to 0." msgstr "" -#: ../../library/datetime.rst:1500 +#: ../../library/datetime.rst:1501 msgid "" "If :class:`.datetime` instance ``d`` is naive, this is the same as ``d." "timetuple()`` except that :attr:`~.time.struct_time.tm_isdst` is forced to 0 " @@ -2178,7 +2167,7 @@ msgid "" "time." msgstr "" -#: ../../library/datetime.rst:1504 +#: ../../library/datetime.rst:1505 msgid "" "If ``d`` is aware, ``d`` is normalized to UTC time, by subtracting ``d." "utcoffset()``, and a :class:`time.struct_time` for the normalized time is " @@ -2187,7 +2176,7 @@ msgid "" "and UTC adjustment spills over a year boundary." msgstr "" -#: ../../library/datetime.rst:1513 +#: ../../library/datetime.rst:1514 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " @@ -2197,20 +2186,20 @@ msgid "" "meth:`.datetime.timetuple`." msgstr "" -#: ../../library/datetime.rst:1523 +#: ../../library/datetime.rst:1524 msgid "" "Return the proleptic Gregorian ordinal of the date. The same as ``self." "date().toordinal()``." msgstr "" -#: ../../library/datetime.rst:1529 +#: ../../library/datetime.rst:1530 msgid "" "Return POSIX timestamp corresponding to the :class:`.datetime` instance. The " "return value is a :class:`float` similar to that returned by :func:`time." "time`." msgstr "" -#: ../../library/datetime.rst:1533 +#: ../../library/datetime.rst:1534 msgid "" "Naive :class:`.datetime` instances are assumed to represent local time and " "this method relies on platform C functions to perform the conversion. Since :" @@ -2219,16 +2208,16 @@ msgid "" "exc:`OSError` for times far in the past or far in the future." msgstr "" -#: ../../library/datetime.rst:1540 +#: ../../library/datetime.rst:1541 msgid "" "For aware :class:`.datetime` instances, the return value is computed as::" msgstr "" -#: ../../library/datetime.rst:1543 +#: ../../library/datetime.rst:1544 msgid "(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()" msgstr "(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()" -#: ../../library/datetime.rst:1547 +#: ../../library/datetime.rst:1548 msgid "" "There is no method to obtain the POSIX timestamp directly from a naive :" "class:`.datetime` instance representing UTC time. If your application uses " @@ -2236,69 +2225,69 @@ msgid "" "the POSIX timestamp by supplying ``tzinfo=timezone.utc``::" msgstr "" -#: ../../library/datetime.rst:1553 +#: ../../library/datetime.rst:1554 msgid "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" msgstr "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" -#: ../../library/datetime.rst:1555 +#: ../../library/datetime.rst:1556 msgid "or by calculating the timestamp directly::" msgstr "" -#: ../../library/datetime.rst:1557 +#: ../../library/datetime.rst:1558 msgid "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" msgstr "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" -#: ../../library/datetime.rst:1561 +#: ../../library/datetime.rst:1562 msgid "" "The :meth:`timestamp` method uses the :attr:`.fold` attribute to " "disambiguate the times during a repeated interval." msgstr "" -#: ../../library/datetime.rst:1565 +#: ../../library/datetime.rst:1566 msgid "" "This method no longer relies on the platform C :c:func:`mktime` function to " "perform conversions." msgstr "" -#: ../../library/datetime.rst:1572 +#: ../../library/datetime.rst:1573 msgid "" "Return the day of the week as an integer, where Monday is 0 and Sunday is 6. " "The same as ``self.date().weekday()``. See also :meth:`isoweekday`." msgstr "" -#: ../../library/datetime.rst:1578 +#: ../../library/datetime.rst:1579 msgid "" "Return the day of the week as an integer, where Monday is 1 and Sunday is 7. " "The same as ``self.date().isoweekday()``. See also :meth:`weekday`, :meth:" "`isocalendar`." msgstr "" -#: ../../library/datetime.rst:1585 +#: ../../library/datetime.rst:1586 msgid "" "Return a :term:`named tuple` with three components: ``year``, ``week`` and " "``weekday``. The same as ``self.date().isocalendar()``." msgstr "" -#: ../../library/datetime.rst:1591 +#: ../../library/datetime.rst:1592 msgid "Return a string representing the date and time in ISO 8601 format:" msgstr "" -#: ../../library/datetime.rst:1593 +#: ../../library/datetime.rst:1594 msgid "``YYYY-MM-DDTHH:MM:SS.ffffff``, if :attr:`microsecond` is not 0" msgstr "``YYYY-MM-DDTHH:MM:SS.ffffff``,如果 :attr:`microsecond` 不是 0" -#: ../../library/datetime.rst:1594 +#: ../../library/datetime.rst:1595 msgid "``YYYY-MM-DDTHH:MM:SS``, if :attr:`microsecond` is 0" msgstr "``YYYY-MM-DDTHH:MM:SS``,如果 :attr:`microsecond` 是 0" -#: ../../library/datetime.rst:1596 +#: ../../library/datetime.rst:1597 msgid "" "If :meth:`utcoffset` does not return ``None``, a string is appended, giving " "the UTC offset:" msgstr "" "如果 :meth:`utcoffset` 没有回傳 ``None``,則會附加一个字串,給出 UTC 偏移:" -#: ../../library/datetime.rst:1599 +#: ../../library/datetime.rst:1600 msgid "" "``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` " "is not 0" @@ -2306,13 +2295,13 @@ msgstr "" "``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``,如果 :attr:`microsecond` " "不是 0" -#: ../../library/datetime.rst:1601 +#: ../../library/datetime.rst:1602 msgid "" "``YYYY-MM-DDTHH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0" msgstr "" "``YYYY-MM-DDTHH:MM:SS+HH:MM[:SS[.ffffff]]``,如果 :attr:`microsecond` 是 0" -#: ../../library/datetime.rst:1605 +#: ../../library/datetime.rst:1606 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat()\n" @@ -2326,13 +2315,13 @@ msgstr "" ">>> dt.datetime(2019, 5, 18, 15, 17, tzinfo=dt.timezone.utc).isoformat()\n" "'2019-05-18T15:17:00+00:00'" -#: ../../library/datetime.rst:1611 +#: ../../library/datetime.rst:1612 msgid "" "The optional argument *sep* (default ``'T'``) is a one-character separator, " "placed between the date and time portions of the result. For example::" msgstr "" -#: ../../library/datetime.rst:1614 +#: ../../library/datetime.rst:1615 msgid "" ">>> import datetime as dt\n" ">>> class TZ(dt.tzinfo):\n" @@ -2356,53 +2345,53 @@ msgstr "" ">>> dt.datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat()\n" "'2009-11-27T00:00:00.000100-06:39'" -#: ../../library/datetime.rst:1625 ../../library/datetime.rst:2020 +#: ../../library/datetime.rst:1626 ../../library/datetime.rst:2021 msgid "" "The optional argument *timespec* specifies the number of additional " "components of the time to include (the default is ``'auto'``). It can be one " "of the following:" msgstr "" -#: ../../library/datetime.rst:1629 ../../library/datetime.rst:2024 +#: ../../library/datetime.rst:1630 ../../library/datetime.rst:2025 msgid "" "``'auto'``: Same as ``'seconds'`` if :attr:`microsecond` is 0, same as " "``'microseconds'`` otherwise." msgstr "" -#: ../../library/datetime.rst:1631 ../../library/datetime.rst:2026 +#: ../../library/datetime.rst:1632 ../../library/datetime.rst:2027 msgid "``'hours'``: Include the :attr:`hour` in the two-digit ``HH`` format." msgstr "" -#: ../../library/datetime.rst:1632 ../../library/datetime.rst:2027 +#: ../../library/datetime.rst:1633 ../../library/datetime.rst:2028 msgid "" "``'minutes'``: Include :attr:`hour` and :attr:`minute` in ``HH:MM`` format." msgstr "" -#: ../../library/datetime.rst:1633 ../../library/datetime.rst:2028 +#: ../../library/datetime.rst:1634 ../../library/datetime.rst:2029 msgid "" "``'seconds'``: Include :attr:`hour`, :attr:`minute`, and :attr:`second` in " "``HH:MM:SS`` format." msgstr "" -#: ../../library/datetime.rst:1635 ../../library/datetime.rst:2030 +#: ../../library/datetime.rst:1636 ../../library/datetime.rst:2031 msgid "" "``'milliseconds'``: Include full time, but truncate fractional second part " "to milliseconds. ``HH:MM:SS.sss`` format." msgstr "" -#: ../../library/datetime.rst:1637 ../../library/datetime.rst:2032 +#: ../../library/datetime.rst:1638 ../../library/datetime.rst:2033 msgid "``'microseconds'``: Include full time in ``HH:MM:SS.ffffff`` format." msgstr "" -#: ../../library/datetime.rst:1641 ../../library/datetime.rst:2036 +#: ../../library/datetime.rst:1642 ../../library/datetime.rst:2037 msgid "Excluded time components are truncated, not rounded." msgstr "" -#: ../../library/datetime.rst:1643 +#: ../../library/datetime.rst:1644 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument::" msgstr "" -#: ../../library/datetime.rst:1646 +#: ../../library/datetime.rst:1647 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime.now().isoformat(timespec='minutes')\n" @@ -2418,21 +2407,21 @@ msgstr "" ">>> my_datetime.isoformat(timespec='microseconds')\n" "'2015-01-01T12:30:59.000000'" -#: ../../library/datetime.rst:1653 ../../library/datetime.rst:2051 +#: ../../library/datetime.rst:1654 ../../library/datetime.rst:2052 msgid "Added the *timespec* parameter." msgstr "新增 *timespec* 參數。" -#: ../../library/datetime.rst:1659 +#: ../../library/datetime.rst:1660 msgid "" "For a :class:`.datetime` instance ``d``, ``str(d)`` is equivalent to ``d." "isoformat(' ')``." msgstr "" -#: ../../library/datetime.rst:1665 +#: ../../library/datetime.rst:1666 msgid "Return a string representing the date and time::" msgstr "" -#: ../../library/datetime.rst:1667 +#: ../../library/datetime.rst:1668 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime(2002, 12, 4, 20, 30, 40).ctime()\n" @@ -2442,27 +2431,27 @@ msgstr "" ">>> dt.datetime(2002, 12, 4, 20, 30, 40).ctime()\n" "'Wed Dec 4 20:30:40 2002'" -#: ../../library/datetime.rst:1671 +#: ../../library/datetime.rst:1672 msgid "" "The output string will *not* include time zone information, regardless of " "whether the input is aware or naive." msgstr "" -#: ../../library/datetime.rst:1678 +#: ../../library/datetime.rst:1679 msgid "" "on platforms where the native C :c:func:`ctime` function (which :func:`time." "ctime` invokes, but which :meth:`datetime.ctime` does not invoke) conforms " "to the C standard." msgstr "" -#: ../../library/datetime.rst:1685 +#: ../../library/datetime.rst:1686 msgid "" "Return a string representing the date and time, controlled by an explicit " "format string. See also :ref:`strftime-strptime-behavior` and :meth:" "`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1692 +#: ../../library/datetime.rst:1693 msgid "" "Same as :meth:`.datetime.strftime`. This makes it possible to specify a " "format string for a :class:`.datetime` object in :ref:`formatted string " @@ -2470,15 +2459,15 @@ msgid "" "`strftime-strptime-behavior` and :meth:`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1699 +#: ../../library/datetime.rst:1700 msgid "Examples of usage: :class:`!datetime`" msgstr "用法範例::class:`!datetime`" -#: ../../library/datetime.rst:1701 +#: ../../library/datetime.rst:1702 msgid "Examples of working with :class:`.datetime` objects:" msgstr "更多 :class:`.datetime` 的用法範例:" -#: ../../library/datetime.rst:1703 +#: ../../library/datetime.rst:1704 msgid "" ">>> import datetime as dt\n" "\n" @@ -2533,14 +2522,14 @@ msgid "" "'The day is 21, the month is November, the time is 04:30PM.'" msgstr "" -#: ../../library/datetime.rst:1754 +#: ../../library/datetime.rst:1755 msgid "" "The example below defines a :class:`tzinfo` subclass capturing time zone " "information for Kabul, Afghanistan, which used +4 UTC until 1945 and then " "+4:30 UTC thereafter::" msgstr "" -#: ../../library/datetime.rst:1758 +#: ../../library/datetime.rst:1759 msgid "" "import datetime as dt\n" "\n" @@ -2587,11 +2576,11 @@ msgid "" " return \"+04\"" msgstr "" -#: ../../library/datetime.rst:1801 +#: ../../library/datetime.rst:1802 msgid "Usage of ``KabulTz`` from above::" msgstr "" -#: ../../library/datetime.rst:1803 +#: ../../library/datetime.rst:1804 msgid "" ">>> tz1 = KabulTz()\n" "\n" @@ -2615,63 +2604,63 @@ msgid "" "True" msgstr "" -#: ../../library/datetime.rst:1828 +#: ../../library/datetime.rst:1829 msgid ":class:`!time` objects" msgstr ":class:`!time` 物件" -#: ../../library/datetime.rst:1830 +#: ../../library/datetime.rst:1831 msgid "" "A :class:`.time` object represents a (local) time of day, independent of any " "particular day, and subject to adjustment via a :class:`tzinfo` object." msgstr "" -#: ../../library/datetime.rst:1835 +#: ../../library/datetime.rst:1836 msgid "" "All arguments are optional. *tzinfo* may be ``None``, or an instance of a :" "class:`tzinfo` subclass. The remaining arguments must be integers in the " "following ranges:" msgstr "" -#: ../../library/datetime.rst:1845 +#: ../../library/datetime.rst:1846 msgid "" "If an argument outside those ranges is given, :exc:`ValueError` is raised. " "All default to 0 except *tzinfo*, which defaults to ``None``." msgstr "" -#: ../../library/datetime.rst:1854 +#: ../../library/datetime.rst:1855 msgid "The earliest representable :class:`.time`, ``time(0, 0, 0, 0)``." msgstr "" -#: ../../library/datetime.rst:1859 +#: ../../library/datetime.rst:1860 msgid "The latest representable :class:`.time`, ``time(23, 59, 59, 999999)``." msgstr "" -#: ../../library/datetime.rst:1864 +#: ../../library/datetime.rst:1865 msgid "" "The smallest possible difference between non-equal :class:`.time` objects, " "``timedelta(microseconds=1)``, although note that arithmetic on :class:`." "time` objects is not supported." msgstr "" -#: ../../library/datetime.rst:1893 +#: ../../library/datetime.rst:1894 msgid "" "The object passed as the tzinfo argument to the :class:`.time` constructor, " "or ``None`` if none was passed." msgstr "" -#: ../../library/datetime.rst:1908 +#: ../../library/datetime.rst:1909 msgid "" ":class:`.time` objects support equality and order comparisons, where ``a`` " "is considered less than ``b`` when ``a`` precedes ``b`` in time." msgstr "" -#: ../../library/datetime.rst:1911 +#: ../../library/datetime.rst:1912 msgid "" "Naive and aware :class:`!time` objects are never equal. Order comparison " "between naive and aware :class:`!time` objects raises :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1915 +#: ../../library/datetime.rst:1916 msgid "" "If both comparands are aware, and have the same :attr:`~.time.tzinfo` " "attribute, the :attr:`!tzinfo` and :attr:`!fold` attributes are ignored and " @@ -2680,18 +2669,18 @@ msgid "" "subtracting their UTC offsets (obtained from ``self.utcoffset()``)." msgstr "" -#: ../../library/datetime.rst:1921 +#: ../../library/datetime.rst:1922 msgid "" "Equality comparisons between aware and naive :class:`.time` instances don't " "raise :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1925 +#: ../../library/datetime.rst:1926 msgid "" "In Boolean contexts, a :class:`.time` object is always considered to be true." msgstr "" -#: ../../library/datetime.rst:1927 +#: ../../library/datetime.rst:1928 msgid "" "Before Python 3.5, a :class:`.time` object was considered to be false if it " "represented midnight in UTC. This behavior was considered obscure and error-" @@ -2699,33 +2688,33 @@ msgid "" "information." msgstr "" -#: ../../library/datetime.rst:1934 +#: ../../library/datetime.rst:1935 msgid "Other constructors:" msgstr "其他建構函式:" -#: ../../library/datetime.rst:1938 +#: ../../library/datetime.rst:1939 msgid "" "Return a :class:`.time` corresponding to a *time_string* in any valid ISO " "8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:1942 +#: ../../library/datetime.rst:1943 msgid "" "The leading ``T``, normally required in cases where there may be ambiguity " "between a date and a time, is not required." msgstr "" -#: ../../library/datetime.rst:1944 +#: ../../library/datetime.rst:1945 msgid "" "Fractional seconds may have any number of digits (anything beyond 6 will be " "truncated)." msgstr "" -#: ../../library/datetime.rst:1948 +#: ../../library/datetime.rst:1949 msgid "Examples:" msgstr "範例: ::" -#: ../../library/datetime.rst:1950 +#: ../../library/datetime.rst:1951 msgid "" ">>> import datetime as dt\n" ">>> dt.time.fromisoformat('04:23:01')\n" @@ -2765,29 +2754,29 @@ msgstr "" ">>> dt.time.fromisoformat('04:23:01+00:00')\n" "datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)" -#: ../../library/datetime.rst:1972 +#: ../../library/datetime.rst:1973 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`time.isoformat`." msgstr "" -#: ../../library/datetime.rst:1979 +#: ../../library/datetime.rst:1980 msgid "" "Return a :class:`.time` corresponding to *date_string*, parsed according to " "*format*." msgstr "" -#: ../../library/datetime.rst:1982 +#: ../../library/datetime.rst:1983 msgid "" "If *format* does not contain microseconds or timezone information, this is " "equivalent to::" msgstr "" -#: ../../library/datetime.rst:1984 +#: ../../library/datetime.rst:1985 msgid "time(*(time.strptime(date_string, format)[3:6]))" msgstr "time(*(time.strptime(date_string, format)[3:6]))" -#: ../../library/datetime.rst:1986 +#: ../../library/datetime.rst:1987 msgid "" ":exc:`ValueError` is raised if the *date_string* and *format* cannot be " "parsed by :func:`time.strptime` or if it returns a value which is not a time " @@ -2795,7 +2784,7 @@ msgid "" "fromisoformat`." msgstr "" -#: ../../library/datetime.rst:1999 +#: ../../library/datetime.rst:2000 msgid "" "Return a new :class:`.time` with the same values, but with specified " "parameters updated. Note that ``tzinfo=None`` can be specified to create a " @@ -2803,41 +2792,41 @@ msgid "" "time data." msgstr "" -#: ../../library/datetime.rst:2004 +#: ../../library/datetime.rst:2005 msgid "" ":class:`.time` objects are also supported by generic function :func:`copy." "replace`." msgstr "" -#: ../../library/datetime.rst:2013 +#: ../../library/datetime.rst:2014 msgid "Return a string representing the time in ISO 8601 format, one of:" msgstr "" -#: ../../library/datetime.rst:2015 +#: ../../library/datetime.rst:2016 msgid "``HH:MM:SS.ffffff``, if :attr:`microsecond` is not 0" msgstr "" -#: ../../library/datetime.rst:2016 +#: ../../library/datetime.rst:2017 msgid "``HH:MM:SS``, if :attr:`microsecond` is 0" msgstr "" -#: ../../library/datetime.rst:2017 +#: ../../library/datetime.rst:2018 msgid "" "``HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :meth:`utcoffset` does not " "return ``None``" msgstr "" -#: ../../library/datetime.rst:2018 +#: ../../library/datetime.rst:2019 msgid "" "``HH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0 and :meth:" "`utcoffset` does not return ``None``" msgstr "" -#: ../../library/datetime.rst:2038 +#: ../../library/datetime.rst:2039 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument." msgstr "" -#: ../../library/datetime.rst:2042 +#: ../../library/datetime.rst:2043 msgid "" ">>> import datetime as dt\n" ">>> dt.time(hour=12, minute=34, second=56, microsecond=123456)." @@ -2859,18 +2848,18 @@ msgstr "" ">>> my_time.isoformat(timespec='auto')\n" "'12:34:56'" -#: ../../library/datetime.rst:2057 +#: ../../library/datetime.rst:2058 msgid "For a time ``t``, ``str(t)`` is equivalent to ``t.isoformat()``." msgstr "" -#: ../../library/datetime.rst:2062 +#: ../../library/datetime.rst:2063 msgid "" "Return a string representing the time, controlled by an explicit format " "string. See also :ref:`strftime-strptime-behavior` and :meth:`time." "isoformat`." msgstr "" -#: ../../library/datetime.rst:2068 +#: ../../library/datetime.rst:2069 msgid "" "Same as :meth:`.time.strftime`. This makes it possible to specify a format " "string for a :class:`.time` object in :ref:`formatted string literals >> import datetime as dt\n" ">>> class TZ1(dt.tzinfo):\n" @@ -2959,18 +2948,18 @@ msgstr "" ">>> 'The {} is {:%H:%M}.'.format(\"time\", t)\n" "'The time is 12:10.'" -#: ../../library/datetime.rst:2135 +#: ../../library/datetime.rst:2136 msgid ":class:`!tzinfo` objects" msgstr ":class:`!tzinfo` 物件" -#: ../../library/datetime.rst:2139 +#: ../../library/datetime.rst:2140 msgid "" "This is an :term:`abstract base class`, meaning that this class should not " "be instantiated directly. Define a subclass of :class:`tzinfo` to capture " "information about a particular time zone." msgstr "" -#: ../../library/datetime.rst:2143 +#: ../../library/datetime.rst:2144 msgid "" "An instance of (a concrete subclass of) :class:`tzinfo` can be passed to the " "constructors for :class:`.datetime` and :class:`.time` objects. The latter " @@ -2980,7 +2969,7 @@ msgid "" "passed to them." msgstr "" -#: ../../library/datetime.rst:2149 +#: ../../library/datetime.rst:2150 msgid "" "You need to derive a concrete subclass, and (at least) supply " "implementations of the standard :class:`tzinfo` methods needed by the :class:" @@ -2990,7 +2979,7 @@ msgid "" "American EST and EDT." msgstr "" -#: ../../library/datetime.rst:2156 +#: ../../library/datetime.rst:2157 msgid "" "Special requirement for pickling: A :class:`tzinfo` subclass must have an :" "meth:`~object.__init__` method that can be called with no arguments, " @@ -2998,20 +2987,20 @@ msgid "" "technical requirement that may be relaxed in the future." msgstr "" -#: ../../library/datetime.rst:2162 +#: ../../library/datetime.rst:2163 msgid "" "A concrete subclass of :class:`tzinfo` may need to implement the following " "methods. Exactly which methods are needed depends on the uses made of aware :" "mod:`!datetime` objects. If in doubt, simply implement all of them." msgstr "" -#: ../../library/datetime.rst:2169 +#: ../../library/datetime.rst:2170 msgid "" "Return offset of local time from UTC, as a :class:`timedelta` object that is " "positive east of UTC. If local time is west of UTC, this should be negative." msgstr "" -#: ../../library/datetime.rst:2172 +#: ../../library/datetime.rst:2173 msgid "" "This represents the *total* offset from UTC; for example, if a :class:" "`tzinfo` object represents both time zone and DST adjustments, :meth:" @@ -3022,31 +3011,31 @@ msgid "" "meth:`utcoffset` will probably look like one of these two::" msgstr "" -#: ../../library/datetime.rst:2180 +#: ../../library/datetime.rst:2181 msgid "" "return CONSTANT # fixed-offset class\n" "return CONSTANT + self.dst(dt) # daylight-aware class" msgstr "" -#: ../../library/datetime.rst:2183 +#: ../../library/datetime.rst:2184 msgid "" "If :meth:`utcoffset` does not return ``None``, :meth:`dst` should not return " "``None`` either." msgstr "" -#: ../../library/datetime.rst:2186 +#: ../../library/datetime.rst:2187 msgid "" "The default implementation of :meth:`utcoffset` raises :exc:" "`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2195 +#: ../../library/datetime.rst:2196 msgid "" "Return the daylight saving time (DST) adjustment, as a :class:`timedelta` " "object or ``None`` if DST information isn't known." msgstr "" -#: ../../library/datetime.rst:2199 +#: ../../library/datetime.rst:2200 msgid "" "Return ``timedelta(0)`` if DST is not in effect. If DST is in effect, return " "the offset as a :class:`timedelta` object (see :meth:`utcoffset` for " @@ -3059,17 +3048,17 @@ msgid "" "to account for DST changes when crossing time zones." msgstr "" -#: ../../library/datetime.rst:2209 +#: ../../library/datetime.rst:2210 msgid "" "An instance *tz* of a :class:`tzinfo` subclass that models both standard and " "daylight times must be consistent in this sense:" msgstr "" -#: ../../library/datetime.rst:2212 +#: ../../library/datetime.rst:2213 msgid "``tz.utcoffset(dt) - tz.dst(dt)``" msgstr "``tz.utcoffset(dt) - tz.dst(dt)``" -#: ../../library/datetime.rst:2214 +#: ../../library/datetime.rst:2215 msgid "" "must return the same result for every :class:`.datetime` *dt* with ``dt." "tzinfo == tz``. For sane :class:`!tzinfo` subclasses, this expression yields " @@ -3082,13 +3071,13 @@ msgid "" "astimezone` regardless." msgstr "" -#: ../../library/datetime.rst:2223 +#: ../../library/datetime.rst:2224 msgid "" "Most implementations of :meth:`dst` will probably look like one of these " "two::" msgstr "" -#: ../../library/datetime.rst:2225 +#: ../../library/datetime.rst:2226 msgid "" "import datetime as dt\n" "\n" @@ -3097,11 +3086,11 @@ msgid "" " return dt.timedelta(0)" msgstr "" -#: ../../library/datetime.rst:2231 +#: ../../library/datetime.rst:2232 msgid "or::" msgstr "或是: ::" -#: ../../library/datetime.rst:2233 +#: ../../library/datetime.rst:2234 msgid "" "import datetime as dt\n" "\n" @@ -3116,12 +3105,12 @@ msgid "" " return dt.timedelta(0)" msgstr "" -#: ../../library/datetime.rst:2245 +#: ../../library/datetime.rst:2246 msgid "" "The default implementation of :meth:`dst` raises :exc:`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2253 +#: ../../library/datetime.rst:2254 msgid "" "Return the time zone name corresponding to the :class:`.datetime` object " "*dt*, as a string. Nothing about string names is defined by the :mod:`!" @@ -3135,13 +3124,13 @@ msgid "" "accounting for daylight time." msgstr "" -#: ../../library/datetime.rst:2263 +#: ../../library/datetime.rst:2264 msgid "" "The default implementation of :meth:`tzname` raises :exc:" "`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2266 +#: ../../library/datetime.rst:2267 msgid "" "These methods are called by a :class:`.datetime` or :class:`.time` object, " "in response to their methods of the same names. A :class:`!datetime` object " @@ -3151,7 +3140,7 @@ msgid "" "datetime`." msgstr "" -#: ../../library/datetime.rst:2272 +#: ../../library/datetime.rst:2273 msgid "" "When ``None`` is passed, it's up to the class designer to decide the best " "response. For example, returning ``None`` is appropriate if the class wishes " @@ -3160,7 +3149,7 @@ msgid "" "offset, as there is no other convention for discovering the standard offset." msgstr "" -#: ../../library/datetime.rst:2278 +#: ../../library/datetime.rst:2279 msgid "" "When a :class:`.datetime` object is passed in response to a :class:`!" "datetime` method, ``dt.tzinfo`` is the same object as *self*. :class:" @@ -3170,13 +3159,13 @@ msgid "" "zones." msgstr "" -#: ../../library/datetime.rst:2284 +#: ../../library/datetime.rst:2285 msgid "" "There is one more :class:`tzinfo` method that a subclass may wish to " "override:" msgstr "" -#: ../../library/datetime.rst:2289 +#: ../../library/datetime.rst:2290 msgid "" "This is called from the default :meth:`datetime.astimezone` implementation. " "When called from that, ``dt.tzinfo`` is *self*, and *dt*'s date and time " @@ -3185,7 +3174,7 @@ msgid "" "datetime in *self*'s local time." msgstr "" -#: ../../library/datetime.rst:2295 +#: ../../library/datetime.rst:2296 msgid "" "Most :class:`tzinfo` subclasses should be able to inherit the default :meth:" "`fromutc` implementation without problems. It's strong enough to handle " @@ -3200,13 +3189,13 @@ msgid "" "offset changes." msgstr "" -#: ../../library/datetime.rst:2306 +#: ../../library/datetime.rst:2307 msgid "" "Skipping code for error cases, the default :meth:`fromutc` implementation " "acts like::" msgstr "" -#: ../../library/datetime.rst:2309 +#: ../../library/datetime.rst:2310 msgid "" "import datetime as dt\n" "\n" @@ -3226,13 +3215,13 @@ msgid "" " return when" msgstr "" -#: ../../library/datetime.rst:2326 +#: ../../library/datetime.rst:2327 msgid "" "In the following :download:`tzinfo_examples.py <../includes/tzinfo_examples." "py>` file there are some examples of :class:`tzinfo` classes:" msgstr "" -#: ../../library/datetime.rst:2330 +#: ../../library/datetime.rst:2331 msgid "" "import datetime as dt\n" "\n" @@ -3415,7 +3404,7 @@ msgid "" "Pacific = USTimeZone(-8, \"Pacific\", \"PST\", \"PDT\")\n" msgstr "" -#: ../../library/datetime.rst:2332 +#: ../../library/datetime.rst:2333 msgid "" "Note that there are unavoidable subtleties twice per year in a :class:" "`tzinfo` subclass accounting for both standard and daylight time, at the DST " @@ -3424,7 +3413,7 @@ msgid "" "ends the minute after 1:59 (EDT) on the first Sunday in November::" msgstr "" -#: ../../library/datetime.rst:2338 +#: ../../library/datetime.rst:2339 msgid "" " UTC 3:MM 4:MM 5:MM 6:MM 7:MM 8:MM\n" " EST 22:MM 23:MM 0:MM 1:MM 2:MM 3:MM\n" @@ -3442,7 +3431,7 @@ msgstr "" "\n" " end 23:MM 0:MM 1:MM 1:MM 2:MM 3:MM" -#: ../../library/datetime.rst:2346 +#: ../../library/datetime.rst:2347 msgid "" "When DST starts (the \"start\" line), the local wall clock leaps from 1:59 " "to 3:00. A wall time of the form 2:MM doesn't really make sense on that day, " @@ -3451,7 +3440,7 @@ msgid "" "get::" msgstr "" -#: ../../library/datetime.rst:2351 +#: ../../library/datetime.rst:2352 msgid "" ">>> import datetime as dt\n" ">>> from tzinfo_examples import HOUR, Eastern\n" @@ -3479,7 +3468,7 @@ msgstr "" "07:00:00 UTC = 03:00:00 EDT\n" "08:00:00 UTC = 04:00:00 EDT" -#: ../../library/datetime.rst:2365 +#: ../../library/datetime.rst:2366 msgid "" "When DST ends (the \"end\" line), there's a potentially worse problem: " "there's an hour that can't be spelled unambiguously in local wall time: the " @@ -3494,7 +3483,7 @@ msgid "" "Fall back transition of 2016, we get::" msgstr "" -#: ../../library/datetime.rst:2376 +#: ../../library/datetime.rst:2377 msgid "" ">>> import datetime as dt\n" ">>> from tzinfo_examples import HOUR, Eastern\n" @@ -3522,13 +3511,13 @@ msgstr "" "06:00:00 UTC = 01:00:00 EST 1\n" "07:00:00 UTC = 02:00:00 EST 0" -#: ../../library/datetime.rst:2389 +#: ../../library/datetime.rst:2390 msgid "" "Note that the :class:`.datetime` instances that differ only by the value of " "the :attr:`~.datetime.fold` attribute are considered equal in comparisons." msgstr "" -#: ../../library/datetime.rst:2392 +#: ../../library/datetime.rst:2393 msgid "" "Applications that can't bear wall-time ambiguities should explicitly check " "the value of the :attr:`~.datetime.fold` attribute or avoid using hybrid :" @@ -3538,28 +3527,28 @@ msgid "" "offset -4 hours))." msgstr "" -#: ../../library/datetime.rst:2400 +#: ../../library/datetime.rst:2401 msgid ":mod:`zoneinfo`" msgstr ":mod:`zoneinfo`" -#: ../../library/datetime.rst:2401 +#: ../../library/datetime.rst:2402 msgid "" "The :mod:`!datetime` module has a basic :class:`timezone` class (for " "handling arbitrary fixed offsets from UTC) and its :attr:`timezone.utc` " "attribute (a UTC :class:`!timezone` instance)." msgstr "" -#: ../../library/datetime.rst:2405 +#: ../../library/datetime.rst:2406 msgid "" "``zoneinfo`` brings the *IANA time zone database* (also known as the Olson " "database) to Python, and its usage is recommended." msgstr "" -#: ../../library/datetime.rst:2408 +#: ../../library/datetime.rst:2409 msgid "`IANA time zone database `_" msgstr "`IANA 時區資料庫 `_" -#: ../../library/datetime.rst:2409 +#: ../../library/datetime.rst:2410 msgid "" "The Time Zone Database (often called tz, tzdata or zoneinfo) contains code " "and data that represent the history of local time for many representative " @@ -3568,24 +3557,24 @@ msgid "" "saving rules." msgstr "" -#: ../../library/datetime.rst:2419 +#: ../../library/datetime.rst:2420 msgid ":class:`!timezone` objects" msgstr ":class:`!timezone` 物件" -#: ../../library/datetime.rst:2421 +#: ../../library/datetime.rst:2422 msgid "" "The :class:`timezone` class is a subclass of :class:`tzinfo`, each instance " "of which represents a time zone defined by a fixed offset from UTC." msgstr "" -#: ../../library/datetime.rst:2425 +#: ../../library/datetime.rst:2426 msgid "" "Objects of this class cannot be used to represent time zone information in " "the locations where different offsets are used in different days of the year " "or where historical changes have been made to civil time." msgstr "" -#: ../../library/datetime.rst:2432 +#: ../../library/datetime.rst:2433 msgid "" "The *offset* argument must be specified as a :class:`timedelta` object " "representing the difference between the local time and UTC. It must be " @@ -3593,25 +3582,25 @@ msgid "" "otherwise :exc:`ValueError` is raised." msgstr "" -#: ../../library/datetime.rst:2437 +#: ../../library/datetime.rst:2438 msgid "" "The *name* argument is optional. If specified it must be a string that will " "be used as the value returned by the :meth:`datetime.tzname` method." msgstr "" -#: ../../library/datetime.rst:2448 ../../library/datetime.rst:2460 +#: ../../library/datetime.rst:2449 ../../library/datetime.rst:2461 msgid "" "Return the fixed value specified when the :class:`timezone` instance is " "constructed." msgstr "" -#: ../../library/datetime.rst:2451 +#: ../../library/datetime.rst:2452 msgid "" "The *dt* argument is ignored. The return value is a :class:`timedelta` " "instance equal to the difference between the local time and UTC." msgstr "" -#: ../../library/datetime.rst:2463 +#: ../../library/datetime.rst:2464 msgid "" "If *name* is not provided in the constructor, the name returned by " "``tzname(dt)`` is generated from the value of the ``offset`` as follows. If " @@ -3620,105 +3609,105 @@ msgid "" "are two digits of ``offset.hours`` and ``offset.minutes`` respectively." msgstr "" -#: ../../library/datetime.rst:2469 +#: ../../library/datetime.rst:2470 msgid "" "Name generated from ``offset=timedelta(0)`` is now plain ``'UTC'``, not " "``'UTC+00:00'``." msgstr "" -#: ../../library/datetime.rst:2476 +#: ../../library/datetime.rst:2477 msgid "Always returns ``None``." msgstr "總是回傳 ``None``。" -#: ../../library/datetime.rst:2481 +#: ../../library/datetime.rst:2482 msgid "" "Return ``dt + offset``. The *dt* argument must be an aware :class:`." "datetime` instance, with ``tzinfo`` set to ``self``." msgstr "" -#: ../../library/datetime.rst:2489 +#: ../../library/datetime.rst:2490 msgid "The UTC time zone, ``timezone(timedelta(0))``." msgstr "UTC 時區,``timezone(timedelta(0))``。" -#: ../../library/datetime.rst:2498 +#: ../../library/datetime.rst:2499 msgid ":meth:`!strftime` and :meth:`!strptime` behavior" msgstr ":meth:`!strftime` 與 :meth:`!strptime` 的行為" -#: ../../library/datetime.rst:2500 +#: ../../library/datetime.rst:2501 msgid "" ":class:`date`, :class:`.datetime`, and :class:`.time` objects all support a " "``strftime(format)`` method, to create a string representing the time under " "the control of an explicit format string." msgstr "" -#: ../../library/datetime.rst:2504 +#: ../../library/datetime.rst:2505 msgid "" "Conversely, the :meth:`date.strptime`, :meth:`datetime.strptime` and :meth:" "`time.strptime` class methods create an object from a string representing " "the time and a corresponding format string." msgstr "" -#: ../../library/datetime.rst:2508 +#: ../../library/datetime.rst:2509 msgid "" "The table below provides a high-level comparison of :meth:`~.datetime." "strftime` versus :meth:`~.datetime.strptime`:" msgstr "" -#: ../../library/datetime.rst:2512 +#: ../../library/datetime.rst:2513 msgid "``strftime``" msgstr "``strftime``" -#: ../../library/datetime.rst:2512 +#: ../../library/datetime.rst:2513 msgid "``strptime``" msgstr "``strptime``" -#: ../../library/datetime.rst:2514 +#: ../../library/datetime.rst:2515 msgid "Usage" msgstr "用法" -#: ../../library/datetime.rst:2514 +#: ../../library/datetime.rst:2515 msgid "Convert object to a string according to a given format" msgstr "" -#: ../../library/datetime.rst:2514 +#: ../../library/datetime.rst:2515 msgid "Parse a string into an object given a corresponding format" msgstr "" -#: ../../library/datetime.rst:2516 +#: ../../library/datetime.rst:2517 msgid "Type of method" msgstr "" -#: ../../library/datetime.rst:2516 +#: ../../library/datetime.rst:2517 msgid "Instance method" msgstr "實例方法" -#: ../../library/datetime.rst:2516 +#: ../../library/datetime.rst:2517 msgid "Class method" msgstr "類別方法" -#: ../../library/datetime.rst:2518 +#: ../../library/datetime.rst:2519 msgid "Signature" msgstr "" -#: ../../library/datetime.rst:2518 +#: ../../library/datetime.rst:2519 msgid "``strftime(format)``" msgstr "``strftime(format)``" -#: ../../library/datetime.rst:2518 +#: ../../library/datetime.rst:2519 msgid "``strptime(date_string, format)``" msgstr "``strptime(date_string, format)``" -#: ../../library/datetime.rst:2525 +#: ../../library/datetime.rst:2526 msgid ":meth:`!strftime` and :meth:`!strptime` format codes" msgstr ":meth:`!strftime` 與 :meth:`!strptime` 格式碼" -#: ../../library/datetime.rst:2527 +#: ../../library/datetime.rst:2528 msgid "" "These methods accept format codes that can be used to parse and format " "dates::" msgstr "" -#: ../../library/datetime.rst:2529 +#: ../../library/datetime.rst:2530 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime.strptime('31/01/22 23:59:59.999999',\n" @@ -3734,33 +3723,33 @@ msgstr "" ">>> _.strftime('%a %d %b %Y, %I:%M%p')\n" "'Mon 31 Jan 2022, 11:59PM'" -#: ../../library/datetime.rst:2536 +#: ../../library/datetime.rst:2537 msgid "" -"The following is a list of all the format codes that the 1989 C standard " -"requires, and these work on all platforms with a standard C implementation." +"The following is a list of all the format codes that the 2011 C standard " +"requires, and these work on all supported platforms." msgstr "" -#: ../../library/datetime.rst:2540 ../../library/datetime.rst:2643 +#: ../../library/datetime.rst:2541 ../../library/datetime.rst:2696 msgid "Directive" msgstr "" -#: ../../library/datetime.rst:2540 ../../library/datetime.rst:2643 +#: ../../library/datetime.rst:2541 ../../library/datetime.rst:2696 msgid "Meaning" msgstr "含義" -#: ../../library/datetime.rst:2540 ../../library/datetime.rst:2643 +#: ../../library/datetime.rst:2541 ../../library/datetime.rst:2696 msgid "Example" msgstr "範例" -#: ../../library/datetime.rst:2540 ../../library/datetime.rst:2643 +#: ../../library/datetime.rst:2541 ../../library/datetime.rst:2696 msgid "Notes" msgstr "註解" -#: ../../library/datetime.rst:2542 +#: ../../library/datetime.rst:2544 msgid "``%a``" msgstr "``%a``" -#: ../../library/datetime.rst:2542 +#: ../../library/datetime.rst:2544 msgid "Weekday as locale's abbreviated name." msgstr "" @@ -3772,11 +3761,11 @@ msgstr "" msgid "So, Mo, ..., Sa (de_DE)" msgstr "" -#: ../../library/datetime.rst:2547 +#: ../../library/datetime.rst:2549 msgid "``%A``" msgstr "``%A``" -#: ../../library/datetime.rst:2547 +#: ../../library/datetime.rst:2549 msgid "Weekday as locale's full name." msgstr "" @@ -3788,42 +3777,11 @@ msgstr "" msgid "Sonntag, Montag, ..., Samstag (de_DE)" msgstr "" -#: ../../library/datetime.rst:2552 -msgid "``%w``" -msgstr "``%w``" - -#: ../../library/datetime.rst:2552 -msgid "Weekday as a decimal number, where 0 is Sunday and 6 is Saturday." -msgstr "" - -#: ../../library/datetime.rst:2552 -msgid "0, 1, ..., 6" -msgstr "0, 1, ..., 6" - -#: ../../library/datetime.rst:2556 -msgid "``%d``" -msgstr "``%d``" - -#: ../../library/datetime.rst:2556 -msgid "Day of the month as a zero-padded decimal number." -msgstr "" - -#: ../../library/datetime.rst:2556 -msgid "01, 02, ..., 31" -msgstr "01, 02, ..., 31" - -#: ../../library/datetime.rst:2556 ../../library/datetime.rst:2569 -#: ../../library/datetime.rst:2572 ../../library/datetime.rst:2578 -#: ../../library/datetime.rst:2581 ../../library/datetime.rst:2587 -#: ../../library/datetime.rst:2605 -msgid "\\(9)" -msgstr "\\(9)" - -#: ../../library/datetime.rst:2559 +#: ../../library/datetime.rst:2554 msgid "``%b``" msgstr "``%b``" -#: ../../library/datetime.rst:2559 +#: ../../library/datetime.rst:2554 msgid "Month as locale's abbreviated name." msgstr "" @@ -3835,11 +3793,11 @@ msgstr "" msgid "Jan, Feb, ..., Dez (de_DE)" msgstr "" -#: ../../library/datetime.rst:2564 +#: ../../library/datetime.rst:2559 msgid "``%B``" msgstr "``%B``" -#: ../../library/datetime.rst:2564 +#: ../../library/datetime.rst:2559 msgid "Month as locale's full name." msgstr "" @@ -3851,67 +3809,223 @@ msgstr "" msgid "Januar, Februar, ..., Dezember (de_DE)" msgstr "" +#: ../../library/datetime.rst:2564 +msgid "``%c``" +msgstr "``%c``" + +#: ../../library/datetime.rst:2564 +msgid "Locale's appropriate date and time representation." +msgstr "" + +#: ../../library/datetime.rst:0 +msgid "Tue Aug 16 21:30:00 1988 (en_US);" +msgstr "" + +#: ../../library/datetime.rst:0 +msgid "Di 16 Aug 21:30:00 1988 (de_DE)" +msgstr "" + #: ../../library/datetime.rst:2569 -msgid "``%m``" -msgstr "``%m``" +msgid "``%C``" +msgstr "``%C``" #: ../../library/datetime.rst:2569 -msgid "Month as a zero-padded decimal number." -msgstr "以零填充的並以十進位數字表示的月份。" +msgid "" +"The year divided by 100 and truncated to an integer as a zero-padded decimal " +"number." +msgstr "" -#: ../../library/datetime.rst:2569 ../../library/datetime.rst:2581 -msgid "01, 02, ..., 12" -msgstr "01, 02, ..., 12" +#: ../../library/datetime.rst:2569 +msgid "01, 02, ..., 99" +msgstr "01, 02, ..., 99" -#: ../../library/datetime.rst:2572 -msgid "``%y``" -msgstr "``%y``" +#: ../../library/datetime.rst:2569 ../../library/datetime.rst:2585 +#: ../../library/datetime.rst:2595 +msgid "\\(0)" +msgstr "\\(0)" -#: ../../library/datetime.rst:2572 -msgid "Year without century as a zero-padded decimal number." +#: ../../library/datetime.rst:2573 +msgid "``%d``" +msgstr "``%d``" + +#: ../../library/datetime.rst:2573 +msgid "Day of the month as a zero-padded decimal number." +msgstr "" + +#: ../../library/datetime.rst:2573 +msgid "01, 02, ..., 31" +msgstr "01, 02, ..., 31" + +#: ../../library/datetime.rst:2573 +msgid "\\(9), \\(10)" +msgstr "\\(9), \\(10)" + +#: ../../library/datetime.rst:2576 +msgid "``%D``" +msgstr "``%D``" + +#: ../../library/datetime.rst:2576 +msgid "Equivalent to ``%m/%d/%y``." +msgstr "等價於 ``%m/%d/%y``。" + +#: ../../library/datetime.rst:2576 +msgid "11/28/25" +msgstr "11/28/25" + +#: ../../library/datetime.rst:2576 ../../library/datetime.rst:2597 +#: ../../library/datetime.rst:2600 ../../library/datetime.rst:2603 +#: ../../library/datetime.rst:2606 ../../library/datetime.rst:2609 +#: ../../library/datetime.rst:2671 +msgid "\\(9)" +msgstr "\\(9)" + +#: ../../library/datetime.rst:2579 +msgid "``%e``" +msgstr "``%e``" + +#: ../../library/datetime.rst:2579 +msgid "The day of the month as a space-padded decimal number." +msgstr "以空格填充的並以十進位數字表示的月份中的日。" + +#: ../../library/datetime.rst:2579 +msgid "␣1, ␣2, ..., 31" +msgstr "␣1, ␣2, ..., 31" + +#: ../../library/datetime.rst:2579 +msgid "\\(10)" +msgstr "\\(10)" + +#: ../../library/datetime.rst:2582 +msgid "``%F``" +msgstr "``%F``" + +#: ../../library/datetime.rst:2582 +msgid "Equivalent to ``%Y-%m-%d``, the ISO 8601 format." msgstr "" -#: ../../library/datetime.rst:2572 +#: ../../library/datetime.rst:2582 +msgid "2025-10-11, 1001-12-30" +msgstr "2025-10-11, 1001-12-30" + +#: ../../library/datetime.rst:2585 +msgid "``%g``" +msgstr "``%g``" + +#: ../../library/datetime.rst:2585 +msgid "" +"Last 2 digits of ISO 8601 year representing the year that contains the " +"greater part of the ISO week (``%V``)." +msgstr "" + +#: ../../library/datetime.rst:2585 ../../library/datetime.rst:2671 msgid "00, 01, ..., 99" msgstr "00, 01, ..., 99" -#: ../../library/datetime.rst:2575 -msgid "``%Y``" -msgstr "``%Y``" +#: ../../library/datetime.rst:2590 +msgid "``%G``" +msgstr "``%G``" -#: ../../library/datetime.rst:2575 -msgid "Year with century as a decimal number." +#: ../../library/datetime.rst:2590 +msgid "" +"ISO 8601 year with century representing the year that contains the greater " +"part of the ISO week (``%V``)." msgstr "" -#: ../../library/datetime.rst:2575 ../../library/datetime.rst:2645 +#: ../../library/datetime.rst:2590 ../../library/datetime.rst:2674 msgid "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" msgstr "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" -#: ../../library/datetime.rst:2578 +#: ../../library/datetime.rst:2590 +msgid "\\(8)" +msgstr "\\(8)" + +#: ../../library/datetime.rst:2595 +msgid "``%h``" +msgstr "``%h``" + +#: ../../library/datetime.rst:2595 +msgid "Equivalent to ``%b``." +msgstr "等價於 ``%b``。" + +#: ../../library/datetime.rst:2595 +msgid "See ``%b``." +msgstr "請見 ``%b``。" + +#: ../../library/datetime.rst:2597 msgid "``%H``" msgstr "``%H``" -#: ../../library/datetime.rst:2578 +#: ../../library/datetime.rst:2597 msgid "Hour (24-hour clock) as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2578 +#: ../../library/datetime.rst:2597 msgid "00, 01, ..., 23" msgstr "00, 01, ..., 23" -#: ../../library/datetime.rst:2581 +#: ../../library/datetime.rst:2600 msgid "``%I``" msgstr "``%I``" -#: ../../library/datetime.rst:2581 +#: ../../library/datetime.rst:2600 msgid "Hour (12-hour clock) as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2584 +#: ../../library/datetime.rst:2600 ../../library/datetime.rst:2606 +msgid "01, 02, ..., 12" +msgstr "01, 02, ..., 12" + +#: ../../library/datetime.rst:2603 +msgid "``%j``" +msgstr "``%j``" + +#: ../../library/datetime.rst:2603 +msgid "Day of the year as a zero-padded decimal number." +msgstr "" + +#: ../../library/datetime.rst:2603 +msgid "001, 002, ..., 366" +msgstr "001, 002, ..., 366" + +#: ../../library/datetime.rst:2606 +msgid "``%m``" +msgstr "``%m``" + +#: ../../library/datetime.rst:2606 +msgid "Month as a zero-padded decimal number." +msgstr "以零填充的並以十進位數字表示的月份。" + +#: ../../library/datetime.rst:2609 +msgid "``%M``" +msgstr "``%M``" + +#: ../../library/datetime.rst:2609 +msgid "Minute as a zero-padded decimal number." +msgstr "" + +#: ../../library/datetime.rst:2609 ../../library/datetime.rst:2625 +msgid "00, 01, ..., 59" +msgstr "00, 01, ..., 59" + +#: ../../library/datetime.rst:2612 +msgid "``%n``" +msgstr "``%n``" + +#: ../../library/datetime.rst:2612 +msgid "" +"The newline character (``'\\n'``). For :meth:`!strptime`, zero or more " +"whitespace." +msgstr "" + +#: ../../library/datetime.rst:2612 +msgid "``\\n``" +msgstr "``\\n``" + +#: ../../library/datetime.rst:2617 msgid "``%p``" msgstr "``%p``" -#: ../../library/datetime.rst:2584 +#: ../../library/datetime.rst:2617 msgid "Locale's equivalent of either AM or PM." msgstr "" @@ -3923,144 +4037,153 @@ msgstr "AM, PM (en_US);" msgid "am, pm (de_DE)" msgstr "am, pm (de_DE)" -#: ../../library/datetime.rst:2584 +#: ../../library/datetime.rst:2617 msgid "\\(1), \\(3)" msgstr "\\(1), \\(3)" -#: ../../library/datetime.rst:2587 -msgid "``%M``" -msgstr "``%M``" +#: ../../library/datetime.rst:2620 +msgid "``%r``" +msgstr "``%r``" -#: ../../library/datetime.rst:2587 -msgid "Minute as a zero-padded decimal number." +#: ../../library/datetime.rst:2620 +msgid "Locale's 12-hour clock time." msgstr "" -#: ../../library/datetime.rst:2587 ../../library/datetime.rst:2590 -msgid "00, 01, ..., 59" -msgstr "00, 01, ..., 59" +#: ../../library/datetime.rst:2620 +msgid "12:00:00 AM" +msgstr "" -#: ../../library/datetime.rst:2590 +#: ../../library/datetime.rst:2620 +msgid "\\(1), \\(0)" +msgstr "\\(1), \\(0)" + +#: ../../library/datetime.rst:2623 +msgid "``%R``" +msgstr "``%R``" + +#: ../../library/datetime.rst:2623 +msgid "Equivalent to ``%H:%M``." +msgstr "等價於 ``%H:%M``。" + +#: ../../library/datetime.rst:2623 +msgid "10:01" +msgstr "10:01" + +#: ../../library/datetime.rst:2625 msgid "``%S``" msgstr "``%S``" -#: ../../library/datetime.rst:2590 +#: ../../library/datetime.rst:2625 msgid "Second as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2590 +#: ../../library/datetime.rst:2625 msgid "\\(4), \\(9)" msgstr "\\(4), \\(9)" -#: ../../library/datetime.rst:2593 -msgid "``%f``" -msgstr "``%f``" - -#: ../../library/datetime.rst:2593 -msgid "Microsecond as a decimal number, zero-padded to 6 digits." -msgstr "" - -#: ../../library/datetime.rst:2593 -msgid "000000, 000001, ..., 999999" -msgstr "000000, 000001, ..., 999999" - -#: ../../library/datetime.rst:2593 -msgid "\\(5)" -msgstr "\\(5)" - -#: ../../library/datetime.rst:2597 ../../library/datetime.rst:2795 -msgid "``%z``" -msgstr "``%z``" +#: ../../library/datetime.rst:2628 +msgid "``%t``" +msgstr "``%t``" -#: ../../library/datetime.rst:2597 +#: ../../library/datetime.rst:2628 msgid "" -"UTC offset in the form ``±HHMM[SS[.ffffff]]`` (empty string if the object is " -"naive)." +"The tab character (``'\\t'``). For :meth:`!strptime`, zero or more " +"whitespace." msgstr "" -#: ../../library/datetime.rst:2597 -msgid "(empty), +0000, -0400, +1030, +063415, -030712.345216" -msgstr "" +#: ../../library/datetime.rst:2628 +msgid "``\\t``" +msgstr "``\\t``" -#: ../../library/datetime.rst:2597 ../../library/datetime.rst:2602 -#: ../../library/datetime.rst:2659 -msgid "\\(6)" -msgstr "\\(6)" - -#: ../../library/datetime.rst:2602 ../../library/datetime.rst:2821 -msgid "``%Z``" -msgstr "``%Z``" +#: ../../library/datetime.rst:2632 +msgid "``%T``" +msgstr "``%T``" -#: ../../library/datetime.rst:2602 -msgid "Time zone name (empty string if the object is naive)." +#: ../../library/datetime.rst:2632 +msgid "ISO 8601 time format, equivalent to ``%H:%M:%S``." msgstr "" -#: ../../library/datetime.rst:2602 -msgid "(empty), UTC, GMT" -msgstr "" +#: ../../library/datetime.rst:2632 +msgid "10:01:59" +msgstr "10:01:59" -#: ../../library/datetime.rst:2605 -msgid "``%j``" -msgstr "``%j``" +#: ../../library/datetime.rst:2635 +msgid "``%u``" +msgstr "``%u``" -#: ../../library/datetime.rst:2605 -msgid "Day of the year as a zero-padded decimal number." +#: ../../library/datetime.rst:2635 +msgid "ISO 8601 weekday as a decimal number where 1 is Monday." msgstr "" -#: ../../library/datetime.rst:2605 -msgid "001, 002, ..., 366" -msgstr "001, 002, ..., 366" +#: ../../library/datetime.rst:2635 +msgid "1, 2, ..., 7" +msgstr "1, 2, ..., 7" -#: ../../library/datetime.rst:2608 +#: ../../library/datetime.rst:2638 msgid "``%U``" msgstr "``%U``" -#: ../../library/datetime.rst:2608 +#: ../../library/datetime.rst:2638 msgid "" "Week number of the year (Sunday as the first day of the week) as a zero-" "padded decimal number. All days in a new year preceding the first Sunday are " "considered to be in week 0." msgstr "" -#: ../../library/datetime.rst:2608 ../../library/datetime.rst:2616 +#: ../../library/datetime.rst:2638 ../../library/datetime.rst:2656 msgid "00, 01, ..., 53" msgstr "00, 01, ..., 53" -#: ../../library/datetime.rst:2608 ../../library/datetime.rst:2616 +#: ../../library/datetime.rst:2638 ../../library/datetime.rst:2656 msgid "\\(7), \\(9)" msgstr "\\(7), \\(9)" -#: ../../library/datetime.rst:2616 -msgid "``%W``" -msgstr "``%W``" +#: ../../library/datetime.rst:2646 +msgid "``%V``" +msgstr "``%V``" -#: ../../library/datetime.rst:2616 +#: ../../library/datetime.rst:2646 msgid "" -"Week number of the year (Monday as the first day of the week) as a zero-" -"padded decimal number. All days in a new year preceding the first Monday are " -"considered to be in week 0." +"ISO 8601 week as a decimal number with Monday as the first day of the week. " +"Week 01 is the week containing Jan 4." msgstr "" -#: ../../library/datetime.rst:2624 -msgid "``%c``" -msgstr "``%c``" +#: ../../library/datetime.rst:2646 +msgid "01, 02, ..., 53" +msgstr "01, 02, ..., 53" -#: ../../library/datetime.rst:2624 -msgid "Locale's appropriate date and time representation." -msgstr "" +#: ../../library/datetime.rst:2646 +msgid "\\(8), \\(9)" +msgstr "\\(8), \\(9)" -#: ../../library/datetime.rst:0 -msgid "Tue Aug 16 21:30:00 1988 (en_US);" +#: ../../library/datetime.rst:2652 +msgid "``%w``" +msgstr "``%w``" + +#: ../../library/datetime.rst:2652 +msgid "Weekday as a decimal number, where 0 is Sunday and 6 is Saturday." msgstr "" -#: ../../library/datetime.rst:0 -msgid "Di 16 Aug 21:30:00 1988 (de_DE)" +#: ../../library/datetime.rst:2652 +msgid "0, 1, ..., 6" +msgstr "0, 1, ..., 6" + +#: ../../library/datetime.rst:2656 +msgid "``%W``" +msgstr "``%W``" + +#: ../../library/datetime.rst:2656 +msgid "" +"Week number of the year (Monday as the first day of the week) as a zero-" +"padded decimal number. All days in a new year preceding the first Monday are " +"considered to be in week 0." msgstr "" -#: ../../library/datetime.rst:2629 +#: ../../library/datetime.rst:2664 msgid "``%x``" msgstr "``%x``" -#: ../../library/datetime.rst:2629 +#: ../../library/datetime.rst:2664 msgid "Locale's appropriate date representation." msgstr "" @@ -4076,11 +4199,11 @@ msgstr "" msgid "16.08.1988 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2633 +#: ../../library/datetime.rst:2668 msgid "``%X``" msgstr "``%X``" -#: ../../library/datetime.rst:2633 +#: ../../library/datetime.rst:2668 msgid "Locale's appropriate time representation." msgstr "" @@ -4092,92 +4215,110 @@ msgstr "" msgid "21:30:00 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2636 -msgid "``%%``" -msgstr "``%%``" +#: ../../library/datetime.rst:2671 +msgid "``%y``" +msgstr "``%y``" -#: ../../library/datetime.rst:2636 -msgid "A literal ``'%'`` character." +#: ../../library/datetime.rst:2671 +msgid "Year without century as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2636 -msgid "%" -msgstr "%" +#: ../../library/datetime.rst:2674 +msgid "``%Y``" +msgstr "``%Y``" -#: ../../library/datetime.rst:2639 -msgid "" -"Several additional directives not required by the C89 standard are included " -"for convenience. These parameters all correspond to ISO 8601 date values." +#: ../../library/datetime.rst:2674 +msgid "Year with century as a decimal number." msgstr "" -#: ../../library/datetime.rst:2645 -msgid "``%G``" -msgstr "``%G``" +#: ../../library/datetime.rst:2677 ../../library/datetime.rst:2840 +msgid "``%z``" +msgstr "``%z``" -#: ../../library/datetime.rst:2645 +#: ../../library/datetime.rst:2677 msgid "" -"ISO 8601 year with century representing the year that contains the greater " -"part of the ISO week (``%V``)." +"UTC offset in the form ``±HHMM[SS[.ffffff]]`` (empty string if the object is " +"naive)." msgstr "" -#: ../../library/datetime.rst:2645 -msgid "\\(8)" -msgstr "\\(8)" +#: ../../library/datetime.rst:2677 +msgid "(empty), +0000, -0400, +1030, +063415, -030712.345216" +msgstr "" -#: ../../library/datetime.rst:2650 -msgid "``%u``" -msgstr "``%u``" +#: ../../library/datetime.rst:2677 ../../library/datetime.rst:2682 +#: ../../library/datetime.rst:2702 +msgid "\\(6)" +msgstr "\\(6)" -#: ../../library/datetime.rst:2650 -msgid "ISO 8601 weekday as a decimal number where 1 is Monday." +#: ../../library/datetime.rst:2682 ../../library/datetime.rst:2872 +msgid "``%Z``" +msgstr "``%Z``" + +#: ../../library/datetime.rst:2682 +msgid "Time zone name (empty string if the object is naive)." msgstr "" -#: ../../library/datetime.rst:2650 -msgid "1, 2, ..., 7" -msgstr "1, 2, ..., 7" +#: ../../library/datetime.rst:2682 +msgid "(empty), UTC, GMT" +msgstr "" -#: ../../library/datetime.rst:2653 -msgid "``%V``" -msgstr "``%V``" +#: ../../library/datetime.rst:2685 +msgid "``%%``" +msgstr "``%%``" -#: ../../library/datetime.rst:2653 +#: ../../library/datetime.rst:2685 +msgid "A literal ``'%'`` character." +msgstr "" + +#: ../../library/datetime.rst:2685 +msgid "%" +msgstr "%" + +#: ../../library/datetime.rst:2688 msgid "" -"ISO 8601 week as a decimal number with Monday as the first day of the week. " -"Week 01 is the week containing Jan 4." +"The ISO 8601 year and ISO 8601 week directives are not interchangeable with " +"the year and week number directives above. Calling :meth:`~.datetime." +"strptime` with incomplete or ambiguous ISO 8601 directives will raise a :exc:" +"`ValueError`." msgstr "" -#: ../../library/datetime.rst:2653 -msgid "01, 02, ..., 53" -msgstr "01, 02, ..., 53" +#: ../../library/datetime.rst:2692 +msgid "" +"Several additional directives not required by the C11 standard are included " +"for convenience." +msgstr "" -#: ../../library/datetime.rst:2653 -msgid "\\(8), \\(9)" -msgstr "\\(8), \\(9)" +#: ../../library/datetime.rst:2698 +msgid "``%f``" +msgstr "``%f``" + +#: ../../library/datetime.rst:2698 +msgid "Microsecond as a decimal number, zero-padded to 6 digits." +msgstr "" -#: ../../library/datetime.rst:2659 ../../library/datetime.rst:2817 +#: ../../library/datetime.rst:2698 +msgid "000000, 000001, ..., 999999" +msgstr "000000, 000001, ..., 999999" + +#: ../../library/datetime.rst:2698 +msgid "\\(5)" +msgstr "\\(5)" + +#: ../../library/datetime.rst:2702 ../../library/datetime.rst:2862 msgid "``%:z``" msgstr "``%:z``" -#: ../../library/datetime.rst:2659 +#: ../../library/datetime.rst:2702 msgid "" "UTC offset in the form ``±HH:MM[:SS[.ffffff]]`` (empty string if the object " "is naive)." msgstr "" -#: ../../library/datetime.rst:2659 +#: ../../library/datetime.rst:2702 msgid "(empty), +00:00, -04:00, +10:30, +06:34:15, -03:07:12.345216" msgstr "" -#: ../../library/datetime.rst:2665 -msgid "" -"These may not be available on all platforms when used with the :meth:`~." -"datetime.strftime` method. The ISO 8601 year and ISO 8601 week directives " -"are not interchangeable with the year and week number directives above. " -"Calling :meth:`~.datetime.strptime` with incomplete or ambiguous ISO 8601 " -"directives will raise a :exc:`ValueError`." -msgstr "" - -#: ../../library/datetime.rst:2670 +#: ../../library/datetime.rst:2708 msgid "" "The full set of format codes supported varies across platforms, because " "Python calls the platform C library's :c:func:`strftime` function, and " @@ -4187,33 +4328,39 @@ msgid "" "unsupported format specifiers." msgstr "" -#: ../../library/datetime.rst:2676 +#: ../../library/datetime.rst:2714 msgid "``%G``, ``%u`` and ``%V`` were added." msgstr "新增 ``%G``、``%u`` 與 ``%V``。" -#: ../../library/datetime.rst:2679 -msgid "``%:z`` was added." -msgstr "新增 ``%:z``。" +#: ../../library/datetime.rst:2717 +msgid "``%:z`` was added for :meth:`~.datetime.strftime`." +msgstr "" + +#: ../../library/datetime.rst:2720 +msgid "" +"``%D``, ``%F``, ``%n``, ``%t``, and ``%:z`` were added for :meth:`~.datetime." +"strptime`." +msgstr "" -#: ../../library/datetime.rst:2684 +#: ../../library/datetime.rst:2726 msgid "Technical detail" msgstr "技術細節" -#: ../../library/datetime.rst:2686 +#: ../../library/datetime.rst:2728 msgid "" "Broadly speaking, ``d.strftime(fmt)`` acts like the :mod:`time` module's " "``time.strftime(fmt, d.timetuple())`` although not all objects support a :" "meth:`~date.timetuple` method." msgstr "" -#: ../../library/datetime.rst:2690 +#: ../../library/datetime.rst:2732 msgid "" "For the :meth:`.datetime.strptime` and :meth:`.date.strptime` class methods, " "the default value is ``1900-01-01T00:00:00.000``: any components not " "specified in the format string will be pulled from the default value." msgstr "" -#: ../../library/datetime.rst:2695 +#: ../../library/datetime.rst:2737 msgid "" "Format strings without separators can be ambiguous for parsing. For example, " "with ``%Y%m%d``, the string ``2026111`` may be parsed either as " @@ -4221,7 +4368,7 @@ msgid "" "parsed as intended." msgstr "" -#: ../../library/datetime.rst:2701 +#: ../../library/datetime.rst:2743 msgid "" "When used to parse partial dates lacking a year, :meth:`.datetime.strptime` " "and :meth:`.date.strptime` will raise when encountering February 29 because " @@ -4229,7 +4376,7 @@ msgid "" "year to partial date strings before parsing." msgstr "" -#: ../../library/datetime.rst:2721 +#: ../../library/datetime.rst:2763 msgid "" ">>> import datetime as dt\n" ">>> value = \"2/29\"\n" @@ -4241,18 +4388,18 @@ msgid "" "datetime.datetime(1904, 2, 29, 0, 0)" msgstr "" -#: ../../library/datetime.rst:2732 +#: ../../library/datetime.rst:2774 msgid "Using ``datetime.strptime(date_string, format)`` is equivalent to::" msgstr "" -#: ../../library/datetime.rst:2736 +#: ../../library/datetime.rst:2778 msgid "" "except when the format includes sub-second components or time zone offset " "information, which are supported in ``datetime.strptime`` but are discarded " "by ``time.strptime``." msgstr "" -#: ../../library/datetime.rst:2740 +#: ../../library/datetime.rst:2782 msgid "" "For :class:`.time` objects, the format codes for year, month, and day should " "not be used, as :class:`!time` objects have no such values. If they're used " @@ -4262,7 +4409,7 @@ msgstr "" "time` 物件並沒有這些值。如果使用這些格式碼,年份會以 1900 代替、月及日會以 1 " "代替。" -#: ../../library/datetime.rst:2744 +#: ../../library/datetime.rst:2786 msgid "" "For :class:`date` objects, the format codes for hours, minutes, seconds, and " "microseconds should not be used, as :class:`date` objects have no such " @@ -4271,7 +4418,7 @@ msgstr "" "對 :class:`.date` 物件來說,不應該使用時、分、秒、微秒的格式碼,因為 :class:" "`date` 物件並沒有這些值。如果使用這些格式碼,這些值都會以 0 代替。" -#: ../../library/datetime.rst:2748 +#: ../../library/datetime.rst:2790 msgid "" "For the same reason, handling of format strings containing Unicode code " "points that can't be represented in the charset of the current locale is " @@ -4280,7 +4427,12 @@ msgid "" "`UnicodeError` or return an empty string instead." msgstr "" -#: ../../library/datetime.rst:2757 +#: ../../library/datetime.rst:2799 +msgid "" +"This format code is currently unsupported by :meth:`~.datetime.strptime`." +msgstr "" + +#: ../../library/datetime.rst:2802 msgid "" "Because the format depends on the current locale, care should be taken when " "making assumptions about the output value. Field orderings will vary (for " @@ -4288,38 +4440,38 @@ msgid "" "contain non-ASCII characters." msgstr "" -#: ../../library/datetime.rst:2763 +#: ../../library/datetime.rst:2808 msgid "" "The :meth:`~.datetime.strptime` method can parse years in the full [1, 9999] " "range, but years < 1000 must be zero-filled to 4-digit width." msgstr "" -#: ../../library/datetime.rst:2766 +#: ../../library/datetime.rst:2811 msgid "" "In previous versions, :meth:`~.datetime.strftime` method was restricted to " "years >= 1900." msgstr "" -#: ../../library/datetime.rst:2770 +#: ../../library/datetime.rst:2815 msgid "" "In version 3.2, :meth:`~.datetime.strftime` method was restricted to years " ">= 1000." msgstr "" -#: ../../library/datetime.rst:2775 +#: ../../library/datetime.rst:2820 msgid "" "When used with the :meth:`~.datetime.strptime` method, the ``%p`` directive " "only affects the output hour field if the ``%I`` directive is used to parse " "the hour." msgstr "" -#: ../../library/datetime.rst:2779 +#: ../../library/datetime.rst:2824 msgid "" "Unlike the :mod:`time` module, the :mod:`!datetime` module does not support " "leap seconds." msgstr "" -#: ../../library/datetime.rst:2783 +#: ../../library/datetime.rst:2828 msgid "" "When used with the :meth:`~.datetime.strptime` method, the ``%f`` directive " "accepts from one to six digits and zero pads on the right. ``%f`` is an " @@ -4327,17 +4479,17 @@ msgid "" "separately in datetime objects, and therefore always available)." msgstr "" -#: ../../library/datetime.rst:2790 +#: ../../library/datetime.rst:2835 msgid "" "For a naive object, the ``%z``, ``%:z`` and ``%Z`` format codes are replaced " "by empty strings." msgstr "" -#: ../../library/datetime.rst:2793 +#: ../../library/datetime.rst:2838 msgid "For an aware object:" msgstr "" -#: ../../library/datetime.rst:2796 +#: ../../library/datetime.rst:2841 msgid "" ":meth:`~.datetime.utcoffset` is transformed into a string of the form " "``±HHMM[SS[.ffffff]]``, where ``HH`` is a 2-digit string giving the number " @@ -4351,62 +4503,70 @@ msgid "" "replaced with the string ``'-0330'``." msgstr "" -#: ../../library/datetime.rst:2810 +#: ../../library/datetime.rst:2855 msgid "" "When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` " "method, the UTC offsets can have a colon as a separator between hours, " -"minutes and seconds. For example, ``'+01:00:00'`` will be parsed as an " -"offset of one hour. In addition, providing ``'Z'`` is identical to " -"``'+00:00'``." +"minutes and seconds. For example, both ``'+010000'`` and ``'+01:00:00'`` " +"will be parsed as an offset of one hour. In addition, providing ``'Z'`` is " +"identical to ``'+00:00'``." msgstr "" -#: ../../library/datetime.rst:2818 +#: ../../library/datetime.rst:2863 +msgid "" +"When used with :meth:`~.datetime.strftime`, behaves exactly as ``%z``, " +"except that a colon separator is added between hours, minutes and seconds." +msgstr "" + +#: ../../library/datetime.rst:2866 msgid "" -"Behaves exactly as ``%z``, but has a colon separator added between hours, " -"minutes and seconds." +"When used with :meth:`~.datetime.strptime`, the UTC offset is *required* to " +"have a colon as a separator between hours, minutes and seconds. For example, " +"``'+01:00:00'`` (but *not* ``'+010000'``) will be parsed as an offset of one " +"hour. In addition, providing ``'Z'`` is identical to ``'+00:00'``." msgstr "" -#: ../../library/datetime.rst:2822 +#: ../../library/datetime.rst:2873 msgid "" "In :meth:`~.datetime.strftime`, ``%Z`` is replaced by an empty string if :" "meth:`~.datetime.tzname` returns ``None``; otherwise ``%Z`` is replaced by " "the returned value, which must be a string." msgstr "" -#: ../../library/datetime.rst:2826 +#: ../../library/datetime.rst:2877 msgid ":meth:`~.datetime.strptime` only accepts certain values for ``%Z``:" msgstr "" -#: ../../library/datetime.rst:2828 +#: ../../library/datetime.rst:2879 msgid "any value in ``time.tzname`` for your machine's locale" msgstr "" -#: ../../library/datetime.rst:2829 +#: ../../library/datetime.rst:2880 msgid "the hard-coded values ``UTC`` and ``GMT``" msgstr "" -#: ../../library/datetime.rst:2831 +#: ../../library/datetime.rst:2882 msgid "" "So someone living in Japan may have ``JST``, ``UTC``, and ``GMT`` as valid " "values, but probably not ``EST``. It will raise ``ValueError`` for invalid " "values." msgstr "" -#: ../../library/datetime.rst:2835 +#: ../../library/datetime.rst:2886 msgid "" "When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` " "method, an aware :class:`.datetime` object will be produced. The ``tzinfo`` " "of the result will be set to a :class:`timezone` instance." msgstr "" -#: ../../library/datetime.rst:2841 +#: ../../library/datetime.rst:2892 msgid "" "When used with the :meth:`~.datetime.strptime` method, ``%U`` and ``%W`` are " "only used in calculations when the day of the week and the calendar year " "(``%Y``) are specified." msgstr "" -#: ../../library/datetime.rst:2846 +#: ../../library/datetime.rst:2897 msgid "" "Similar to ``%U`` and ``%W``, ``%V`` is only used in calculations when the " "day of the week and the ISO year (``%G``) are specified in a :meth:`~." @@ -4414,7 +4574,7 @@ msgid "" "interchangeable." msgstr "" -#: ../../library/datetime.rst:2852 +#: ../../library/datetime.rst:2903 msgid "" "When used with the :meth:`~.datetime.strptime` method, the leading zero is " "optional for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, " @@ -4422,7 +4582,7 @@ msgid "" "zero." msgstr "" -#: ../../library/datetime.rst:2857 +#: ../../library/datetime.rst:2908 msgid "" "When parsing a month and day using :meth:`~.datetime.strptime`, always " "include a year in the format. If the value you need to parse lacks a year, " @@ -4431,7 +4591,7 @@ msgid "" "parser (1900) is not a leap year. Users run into that bug every leap year." msgstr "" -#: ../../library/datetime.rst:2863 +#: ../../library/datetime.rst:2914 msgid "" ">>> month_day = \"02/29\"\n" ">>> dt.datetime.strptime(f\"{month_day};1984\", \"%m/%d;%Y\") # No leap " @@ -4443,23 +4603,25 @@ msgstr "" "題。\n" "datetime.datetime(1984, 2, 29, 0, 0)" -#: ../../library/datetime.rst:2869 +#: ../../library/datetime.rst:2920 +msgid "Using ``%d`` without a year now raises :exc:`ValueError`." +msgstr "" + +#: ../../library/datetime.rst:2923 msgid "" -":meth:`~.datetime.strptime` calls using a format string containing a day of " -"month without a year now emit a :exc:`DeprecationWarning`. In 3.15 or later " -"we may change this into an error or change the default year to a leap year. " -"See :gh:`70647`." +":meth:`~.datetime.strptime` calls using a format string containing ``%e`` " +"without a year now emit a :exc:`DeprecationWarning`." msgstr "" -#: ../../library/datetime.rst:2876 +#: ../../library/datetime.rst:2928 msgid "Footnotes" msgstr "註解" -#: ../../library/datetime.rst:2877 +#: ../../library/datetime.rst:2929 msgid "If, that is, we ignore the effects of relativity." msgstr "也就是說,我們會忽略相對論的效應。" -#: ../../library/datetime.rst:2879 +#: ../../library/datetime.rst:2931 msgid "" "This matches the definition of the \"proleptic Gregorian\" calendar in " "Dershowitz and Reingold's book *Calendrical Calculations*, where it's the " @@ -4468,21 +4630,24 @@ msgid "" "systems." msgstr "" -#: ../../library/datetime.rst:2885 +#: ../../library/datetime.rst:2937 msgid "" "See R. H. van Gent's `guide to the mathematics of the ISO 8601 calendar " "`_ for a good explanation." msgstr "" -#: ../../library/datetime.rst:2492 +#: ../../library/datetime.rst:2493 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/datetime.rst:2492 +#: ../../library/datetime.rst:2493 msgid "datetime format" msgstr "datetime format(日期時間格式)" +#~ msgid "``%:z`` was added." +#~ msgstr "新增 ``%:z``。" + #~ msgid "" #~ ">>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc)\n" #~ ">>> for i in range(4):\n" diff --git a/library/dbm.po b/library/dbm.po index 88beeda6a42..d06a07d76b4 100644 --- a/library/dbm.po +++ b/library/dbm.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-20 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -45,48 +45,56 @@ msgstr ":mod:`dbm.ndbm`" #: ../../library/dbm.rst:17 msgid "" "If none of these modules are installed, the slow-but-simple implementation " -"in module :mod:`dbm.dumb` will be used. There is a `third party interface " +"in module :mod:`dbm.dumb` will be used. There is a `third party interface " "`_ to the Oracle Berkeley DB." msgstr "" -#: ../../library/dbm.rst:24 +#: ../../library/dbm.rst:23 +msgid "" +"None of the underlying modules will automatically shrink the disk space used " +"by the database file. However, :mod:`dbm.sqlite3`, :mod:`dbm.gnu` and :mod:" +"`dbm.dumb` provide a :meth:`!reorganize` method that can be used for this " +"purpose." +msgstr "" + +#: ../../library/dbm.rst:30 msgid "" "A tuple containing the exceptions that can be raised by each of the " "supported modules, with a unique exception also named :exc:`dbm.error` as " "the first item --- the latter is used when :exc:`dbm.error` is raised." msgstr "" -#: ../../library/dbm.rst:31 +#: ../../library/dbm.rst:37 msgid "" "This function attempts to guess which of the several simple database modules " "available --- :mod:`dbm.sqlite3`, :mod:`dbm.gnu`, :mod:`dbm.ndbm`, or :mod:" "`dbm.dumb` --- should be used to open a given file." msgstr "" -#: ../../library/dbm.rst:35 +#: ../../library/dbm.rst:41 msgid "Return one of the following values:" msgstr "回傳以下其中一個值:" -#: ../../library/dbm.rst:37 +#: ../../library/dbm.rst:43 msgid "" "``None`` if the file can't be opened because it's unreadable or doesn't exist" msgstr "" -#: ../../library/dbm.rst:38 +#: ../../library/dbm.rst:44 msgid "the empty string (``''``) if the file's format can't be guessed" msgstr "" -#: ../../library/dbm.rst:39 +#: ../../library/dbm.rst:45 msgid "" "a string containing the required module name, such as ``'dbm.ndbm'`` or " "``'dbm.gnu'``" msgstr "" -#: ../../library/dbm.rst:41 ../../library/dbm.rst:270 ../../library/dbm.rst:472 +#: ../../library/dbm.rst:47 ../../library/dbm.rst:288 ../../library/dbm.rst:499 msgid "*filename* accepts a :term:`path-like object`." msgstr "" -#: ../../library/dbm.rst:65 +#: ../../library/dbm.rst:71 msgid "Open a database and return the corresponding database object." msgstr "" @@ -94,7 +102,7 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../library/dbm.rst:67 +#: ../../library/dbm.rst:73 msgid "" "The database file to open. If the database file already exists, the :func:" "`whichdb` function is used to determine its type and the appropriate module " @@ -102,18 +110,18 @@ msgid "" "imported is used." msgstr "" -#: ../../library/dbm.rst:68 ../../library/dbm.rst:242 +#: ../../library/dbm.rst:74 ../../library/dbm.rst:260 msgid "The database file to open." msgstr "要打開的資料庫檔案" -#: ../../library/dbm.rst:70 +#: ../../library/dbm.rst:76 msgid "" "If the database file already exists, the :func:`whichdb` function is used to " "determine its type and the appropriate module is used; if it does not exist, " "the first submodule listed above that can be imported is used." msgstr "" -#: ../../library/dbm.rst:75 ../../library/dbm.rst:181 ../../library/dbm.rst:375 +#: ../../library/dbm.rst:81 ../../library/dbm.rst:187 ../../library/dbm.rst:397 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n|" @@ -121,36 +129,36 @@ msgstr "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n|" -#: ../../library/dbm.rst:76 ../../library/dbm.rst:183 ../../library/dbm.rst:247 -#: ../../library/dbm.rst:376 +#: ../../library/dbm.rst:82 ../../library/dbm.rst:189 ../../library/dbm.rst:265 +#: ../../library/dbm.rst:398 msgid "``'r'`` (default): |flag_r|" msgstr "``'r'`` (default): |flag_r|" -#: ../../library/dbm.rst:77 ../../library/dbm.rst:184 ../../library/dbm.rst:248 -#: ../../library/dbm.rst:377 ../../library/dbm.rst:453 +#: ../../library/dbm.rst:83 ../../library/dbm.rst:190 ../../library/dbm.rst:266 +#: ../../library/dbm.rst:399 ../../library/dbm.rst:475 msgid "``'w'``: |flag_w|" msgstr "``'w'``: |flag_w|" -#: ../../library/dbm.rst:78 ../../library/dbm.rst:185 ../../library/dbm.rst:249 -#: ../../library/dbm.rst:378 +#: ../../library/dbm.rst:84 ../../library/dbm.rst:191 ../../library/dbm.rst:267 +#: ../../library/dbm.rst:400 msgid "``'c'``: |flag_c|" msgstr "``'c'``: |flag_c|" -#: ../../library/dbm.rst:79 ../../library/dbm.rst:186 ../../library/dbm.rst:250 -#: ../../library/dbm.rst:379 ../../library/dbm.rst:455 +#: ../../library/dbm.rst:85 ../../library/dbm.rst:192 ../../library/dbm.rst:268 +#: ../../library/dbm.rst:401 ../../library/dbm.rst:477 msgid "``'n'``: |flag_n|" msgstr "``'n'``: |flag_n|" -#: ../../library/dbm.rst:81 ../../library/dbm.rst:264 ../../library/dbm.rst:381 -#: ../../library/dbm.rst:457 +#: ../../library/dbm.rst:87 ../../library/dbm.rst:282 ../../library/dbm.rst:403 +#: ../../library/dbm.rst:479 msgid "|mode_param_doc|" msgstr "|mode_param_doc|" -#: ../../library/dbm.rst:84 +#: ../../library/dbm.rst:90 msgid "*file* accepts a :term:`path-like object`." msgstr "*file* 接受一個\\ :term:`類路徑物件 `。" -#: ../../library/dbm.rst:87 +#: ../../library/dbm.rst:93 msgid "" "The object returned by :func:`~dbm.open` supports the basic functionality of " "mutable :term:`mappings `; keys and their corresponding values can " @@ -160,48 +168,48 @@ msgid "" "view object. The :meth:`!setdefault` method requires two arguments." msgstr "" -#: ../../library/dbm.rst:95 +#: ../../library/dbm.rst:101 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:99 +#: ../../library/dbm.rst:105 msgid "" "These objects also support being used in a :keyword:`with` statement, which " "will automatically close them when done." msgstr "" -#: ../../library/dbm.rst:102 +#: ../../library/dbm.rst:108 msgid "" ":meth:`!get` and :meth:`!setdefault` methods are now available for all :mod:" "`!dbm` backends." msgstr "" -#: ../../library/dbm.rst:106 +#: ../../library/dbm.rst:112 msgid "" "Added native support for the context management protocol to the objects " "returned by :func:`~dbm.open`." msgstr "" -#: ../../library/dbm.rst:110 +#: ../../library/dbm.rst:116 msgid "" "Deleting a key from a read-only database raises a database module specific " "exception instead of :exc:`KeyError`." msgstr "" -#: ../../library/dbm.rst:114 +#: ../../library/dbm.rst:120 msgid ":meth:`!clear` methods are now available for all :mod:`!dbm` backends." msgstr ":meth:`!clear` 方法現在可用於所有 :mod:`!dbm` 後端。" -#: ../../library/dbm.rst:118 +#: ../../library/dbm.rst:124 msgid "" "The following example records some hostnames and a corresponding title, and " "then prints out the contents of the database::" msgstr "" -#: ../../library/dbm.rst:121 +#: ../../library/dbm.rst:127 msgid "" "import dbm\n" "\n" @@ -228,27 +236,27 @@ msgid "" "# db is automatically closed when leaving the with statement." msgstr "" -#: ../../library/dbm.rst:148 +#: ../../library/dbm.rst:154 msgid "Module :mod:`shelve`" msgstr ":mod:`shelve` 模組" -#: ../../library/dbm.rst:149 +#: ../../library/dbm.rst:155 msgid "Persistence module which stores non-string data." msgstr "" -#: ../../library/dbm.rst:152 +#: ../../library/dbm.rst:158 msgid "The individual submodules are described in the following sections." msgstr "" -#: ../../library/dbm.rst:155 +#: ../../library/dbm.rst:161 msgid ":mod:`!dbm.sqlite3` --- SQLite backend for dbm" msgstr ":mod:`!dbm.sqlite3` --- dbm 的 SQLite 後端" -#: ../../library/dbm.rst:162 +#: ../../library/dbm.rst:168 msgid "**Source code:** :source:`Lib/dbm/sqlite3.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/sqlite3.py`" -#: ../../library/dbm.rst:166 +#: ../../library/dbm.rst:172 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." @@ -256,7 +264,7 @@ msgid "" "including the SQLite CLI." msgstr "" -#: ../../library/dbm.rst:225 ../../library/dbm.rst:353 +#: ../../library/dbm.rst:243 ../../library/dbm.rst:375 #: ../../includes/wasm-mobile-notavail.rst:3 ../../includes/wasm-notavail.rst:3 msgid "Availability" msgstr "可用性" @@ -269,21 +277,21 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/dbm.rst:175 +#: ../../library/dbm.rst:181 msgid "Open an SQLite database." msgstr "打開一個 SQLite 資料庫。" -#: ../../library/dbm.rst:177 +#: ../../library/dbm.rst:183 msgid "The path to the database to be opened." msgstr "要打開的資料庫路徑" -#: ../../library/dbm.rst:188 +#: ../../library/dbm.rst:194 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:192 +#: ../../library/dbm.rst:198 msgid "" "The returned database object behaves similar to a mutable :term:`mapping`, " "but the :meth:`!keys` method returns a list, and the :meth:`!setdefault` " @@ -291,30 +299,46 @@ msgid "" "manager via the :keyword:`with` keyword." msgstr "" -#: ../../library/dbm.rst:197 ../../library/dbm.rst:400 -msgid "The following method is also provided:" +#: ../../library/dbm.rst:203 ../../library/dbm.rst:304 +#: ../../library/dbm.rst:507 +msgid "The following methods are also provided:" msgstr "也提供了以下方法:" -#: ../../library/dbm.rst:201 +#: ../../library/dbm.rst:207 msgid "Close the SQLite database." msgstr "關閉 SQLite 資料庫。" -#: ../../library/dbm.rst:205 +#: ../../library/dbm.rst:211 +msgid "" +"If you have carried out a lot of deletions and would like to shrink the " +"space used on disk, this method will reorganize the database; otherwise, " +"deleted file space will be kept and reused as new (key, value) pairs are " +"added." +msgstr "" + +#: ../../library/dbm.rst:216 +msgid "" +"While reorganizing, as much as two times the size of the original database " +"is required in free disk space. However, be aware that this factor changes " +"for each :mod:`!dbm` submodule." +msgstr "" + +#: ../../library/dbm.rst:223 msgid ":mod:`!dbm.gnu` --- GNU database manager" msgstr ":mod:`!dbm.gnu` --- GNU 資料庫管理器" -#: ../../library/dbm.rst:210 +#: ../../library/dbm.rst:228 msgid "**Source code:** :source:`Lib/dbm/gnu.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/gnu.py`" -#: ../../library/dbm.rst:214 +#: ../../library/dbm.rst:232 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:220 +#: ../../library/dbm.rst:238 msgid "" "The file formats created by :mod:`!dbm.gnu` and :mod:`dbm.ndbm` are " "incompatible and can not be used interchangeably." @@ -328,24 +352,24 @@ msgstr "" "此模組在\\ :ref:`行動平台 `\\ 或 :ref:`WebAssembly 平台 " "`\\ 上不支援。" -#: ../../library/dbm.rst:229 +#: ../../library/dbm.rst:247 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:235 +#: ../../library/dbm.rst:253 msgid "" "A string of characters the *flag* parameter of :meth:`~dbm.gnu.open` " "supports." msgstr "" -#: ../../library/dbm.rst:240 +#: ../../library/dbm.rst:258 msgid "Open a GDBM database and return a :class:`!gdbm` object." msgstr "打開一個 GDBM 資料庫,並回傳一個 :class:`!gdbm` 物件。" -#: ../../library/dbm.rst:246 +#: ../../library/dbm.rst:264 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n| The following additional characters may be appended to " @@ -357,29 +381,29 @@ msgid "" "flag characters." msgstr "" -#: ../../library/dbm.rst:252 +#: ../../library/dbm.rst:270 msgid "" "The following additional characters may be appended to control how the " "database is opened:" msgstr "" -#: ../../library/dbm.rst:255 +#: ../../library/dbm.rst:273 msgid "" "``'f'``: Open the database in fast mode. Writes to the database will not be " "synchronized." msgstr "" -#: ../../library/dbm.rst:257 +#: ../../library/dbm.rst:275 msgid "" "``'s'``: Synchronized mode. Changes to the database will be written " "immediately to the file." msgstr "" -#: ../../library/dbm.rst:259 +#: ../../library/dbm.rst:277 msgid "``'u'``: Do not lock database." msgstr "``'u'``: 不要鎖住資料庫。" -#: ../../library/dbm.rst:261 +#: ../../library/dbm.rst:279 msgid "" "Not all flags are valid for all versions of GDBM. See the :data:`open_flags` " "member for a list of supported flag characters." @@ -389,11 +413,11 @@ msgstr "" msgid "Raises" msgstr "引發" -#: ../../library/dbm.rst:267 +#: ../../library/dbm.rst:285 msgid "If an invalid *flag* argument is passed." msgstr "如果一個無效的 *flag* 引數被傳入。" -#: ../../library/dbm.rst:273 +#: ../../library/dbm.rst:291 msgid "" ":class:`!gdbm` objects behave similar to mutable :term:`mappings `, " "but methods :meth:`!items`, :meth:`!values`, :meth:`!pop`, :meth:`!popitem`, " @@ -402,23 +426,19 @@ msgid "" "supports a \"closing\" context manager via the :keyword:`with` keyword." msgstr "" -#: ../../library/dbm.rst:280 ../../library/dbm.rst:394 +#: ../../library/dbm.rst:298 ../../library/dbm.rst:416 msgid "Added the :meth:`!get` and :meth:`!setdefault` methods." msgstr "新增了 :meth:`!get` 和 :meth:`!setdefault` 方法。" -#: ../../library/dbm.rst:283 ../../library/dbm.rst:397 +#: ../../library/dbm.rst:301 ../../library/dbm.rst:419 msgid "Added the :meth:`!clear` method." msgstr "新增了 :meth:`!clear` 方法。" -#: ../../library/dbm.rst:286 ../../library/dbm.rst:480 -msgid "The following methods are also provided:" -msgstr "也提供了以下方法:" - -#: ../../library/dbm.rst:290 +#: ../../library/dbm.rst:308 msgid "Close the GDBM database." msgstr "關閉 GDBM 資料庫。" -#: ../../library/dbm.rst:294 +#: ../../library/dbm.rst:312 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 " @@ -426,14 +446,14 @@ msgid "" "starting key." msgstr "" -#: ../../library/dbm.rst:301 +#: ../../library/dbm.rst:319 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:305 +#: ../../library/dbm.rst:323 msgid "" "k = db.firstkey()\n" "while k is not None:\n" @@ -445,7 +465,7 @@ msgstr "" " print(k)\n" " k = db.nextkey(k)" -#: ../../library/dbm.rst:312 +#: ../../library/dbm.rst:330 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. :" @@ -454,34 +474,41 @@ msgid "" "reused as new (key, value) pairs are added." msgstr "" -#: ../../library/dbm.rst:320 +#: ../../library/dbm.rst:337 +msgid "" +"While reorganizing, as much as one time the size of the original database is " +"required in free disk space. However, be aware that this factor changes for " +"each :mod:`!dbm` submodule." +msgstr "" + +#: ../../library/dbm.rst:342 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:325 +#: ../../library/dbm.rst:347 msgid ":mod:`!dbm.ndbm` --- New Database Manager" msgstr ":mod:`!dbm.ndbm` --- 新資料庫管理器" -#: ../../library/dbm.rst:330 +#: ../../library/dbm.rst:352 msgid "**Source code:** :source:`Lib/dbm/ndbm.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/ndbm.py`" -#: ../../library/dbm.rst:334 +#: ../../library/dbm.rst:356 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:341 +#: ../../library/dbm.rst:363 msgid "" "The file formats created by :mod:`dbm.gnu` and :mod:`!dbm.ndbm` are " "incompatible and can not be used interchangeably." msgstr "" -#: ../../library/dbm.rst:346 +#: ../../library/dbm.rst:368 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 " @@ -489,32 +516,32 @@ msgid "" "result in a hard crash (segmentation fault)." msgstr "" -#: ../../library/dbm.rst:357 +#: ../../library/dbm.rst:379 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:363 +#: ../../library/dbm.rst:385 msgid "Name of the NDBM implementation library used." msgstr "" -#: ../../library/dbm.rst:368 +#: ../../library/dbm.rst:390 msgid "Open an NDBM database and return an :class:`!ndbm` object." msgstr "" -#: ../../library/dbm.rst:370 +#: ../../library/dbm.rst:392 msgid "" "The basename of the database file (without the :file:`.dir` or :file:`.pag` " "extensions)." msgstr "" -#: ../../library/dbm.rst:384 +#: ../../library/dbm.rst:406 msgid "Accepts :term:`path-like object` for filename." msgstr "" -#: ../../library/dbm.rst:387 +#: ../../library/dbm.rst:409 msgid "" ":class:`!ndbm` objects behave similar to mutable :term:`mappings `, " "but methods :meth:`!items`, :meth:`!values`, :meth:`!pop`, :meth:`!popitem`, " @@ -523,19 +550,23 @@ msgid "" "supports a \"closing\" context manager via the :keyword:`with` keyword." msgstr "" -#: ../../library/dbm.rst:404 +#: ../../library/dbm.rst:422 +msgid "The following method is also provided:" +msgstr "也提供了以下方法:" + +#: ../../library/dbm.rst:426 msgid "Close the NDBM database." msgstr "關閉 NDBM 資料庫。" -#: ../../library/dbm.rst:408 +#: ../../library/dbm.rst:430 msgid ":mod:`!dbm.dumb` --- Portable DBM implementation" msgstr ":mod:`!dbm.dumb` --- 可移植的 DBM 實作" -#: ../../library/dbm.rst:413 +#: ../../library/dbm.rst:435 msgid "**Source code:** :source:`Lib/dbm/dumb.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/dumb.py`" -#: ../../library/dbm.rst:419 +#: ../../library/dbm.rst:441 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." @@ -543,50 +574,50 @@ msgid "" "the other database modules." msgstr "" -#: ../../library/dbm.rst:426 +#: ../../library/dbm.rst:448 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:431 +#: ../../library/dbm.rst:453 msgid "The :mod:`!dbm.dumb` module defines the following:" msgstr ":mod:`!dbm.dumb` 模組定義了以下項目:" -#: ../../library/dbm.rst:435 +#: ../../library/dbm.rst:457 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:441 +#: ../../library/dbm.rst:463 msgid "Open a :mod:`!dbm.dumb` database." msgstr "開啟一個 :mod:`!dbm.dumb` 資料庫。" -#: ../../library/dbm.rst:443 +#: ../../library/dbm.rst:465 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:444 +#: ../../library/dbm.rst:466 msgid "" "The basename of the database file (without extensions). A new database " "creates the following files:" msgstr "" -#: ../../library/dbm.rst:447 +#: ../../library/dbm.rst:469 msgid ":file:`{filename}.dat`" msgstr ":file:`{filename}.dat`" -#: ../../library/dbm.rst:448 +#: ../../library/dbm.rst:470 msgid ":file:`{filename}.dir`" msgstr ":file:`{filename}.dir`" -#: ../../library/dbm.rst:451 +#: ../../library/dbm.rst:473 msgid "" "* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (default): |flag_c| * " "``'n'``: |flag_n|" @@ -594,33 +625,40 @@ msgstr "" "* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (default): |flag_c| * " "``'n'``: |flag_n|" -#: ../../library/dbm.rst:452 +#: ../../library/dbm.rst:474 msgid "``'r'``: |flag_r|" msgstr "``'r'``: |flag_r|" -#: ../../library/dbm.rst:454 +#: ../../library/dbm.rst:476 msgid "``'c'`` (default): |flag_c|" msgstr "``'c'`` (default): |flag_c|" -#: ../../library/dbm.rst:461 +#: ../../library/dbm.rst:483 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:465 +#: ../../library/dbm.rst:488 +msgid "" +":mod:`!dbm.dumb` does not support concurrent read/write access. (Multiple " +"simultaneous read accesses are safe.) When a program has the database open " +"for writing, no other program should have it open for reading or writing." +msgstr "" + +#: ../../library/dbm.rst:492 msgid "" ":func:`~dbm.dumb.open` always creates a new database when *flag* is ``'n'``." msgstr "" -#: ../../library/dbm.rst:468 +#: ../../library/dbm.rst:495 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:475 +#: ../../library/dbm.rst:502 msgid "" "The returned database object behaves similar to a mutable :term:`mapping`, " "but the :meth:`!keys` and :meth:`!items` methods return lists, and the :meth:" @@ -628,16 +666,29 @@ msgid "" "context manager via the :keyword:`with` keyword." msgstr "" -#: ../../library/dbm.rst:484 +#: ../../library/dbm.rst:511 msgid "Close the database." msgstr "關閉資料庫。" -#: ../../library/dbm.rst:488 +#: ../../library/dbm.rst:515 +msgid "" +"If you have carried out a lot of deletions and would like to shrink the " +"space used on disk, this method will reorganize the database; otherwise, " +"deleted file space will not be reused." +msgstr "" + +#: ../../library/dbm.rst:520 +msgid "" +"While reorganizing, no additional free disk space is required. However, be " +"aware that this factor changes for each :mod:`!dbm` submodule." +msgstr "" + +#: ../../library/dbm.rst:527 msgid "" "Synchronize the on-disk directory and data files. This method is called by " "the :meth:`shelve.Shelf.sync` method." msgstr "" -#: ../../library/dbm.rst:415 +#: ../../library/dbm.rst:437 msgid "databases" msgstr "databases(資料庫)" diff --git a/library/debug.po b/library/debug.po index 17ff8f43eda..98c7503b4b4 100644 --- a/library/debug.po +++ b/library/debug.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-20 18:08+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2021-12-08 00:47+0800\n" "Last-Translator: Jordan Su \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,7 +20,7 @@ msgstr "" "X-Generator: Poedit 3.0\n" #: ../../library/debug.rst:3 -msgid "Debugging and Profiling" +msgid "Debugging and profiling" msgstr "除錯與效能分析" #: ../../library/debug.rst:5 diff --git a/library/decimal.po b/library/decimal.po index 8fb3aff7ab9..465bdccfc4e 100644 --- a/library/decimal.po +++ b/library/decimal.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!decimal` --- Decimal fixed-point and floating-point arithmetic" msgstr ":mod:`!decimal` --- 十進位固定點和浮點運算" -#: ../../library/decimal.rst:15 +#: ../../library/decimal.rst:7 msgid "**Source code:** :source:`Lib/decimal.py`" msgstr "**原始碼:**\\ :source:`Lib/decimal.py`" -#: ../../library/decimal.rst:33 +#: ../../library/decimal.rst:25 msgid "" "The :mod:`!decimal` module provides support for fast correctly rounded " "decimal floating-point arithmetic. It offers several advantages over the :" @@ -34,7 +34,7 @@ msgstr "" ":mod:`!decimal` 模組提供對快速且正確捨入的十進位浮點運算的支援。它提供了優" "於 :class:`float` 資料型別的幾項優勢:" -#: ../../library/decimal.rst:37 +#: ../../library/decimal.rst:29 msgid "" "Decimal \"is based on a `floating-point model `__ which was designed with people in mind, " @@ -47,7 +47,7 @@ msgstr "" "導原則——電腦必須提供一種與人們在學校學到的算術相同運作方式的算術。」——摘自十" "進位算術規格。" -#: ../../library/decimal.rst:44 +#: ../../library/decimal.rst:36 msgid "" "Decimal numbers can be represented exactly. In contrast, numbers like " "``1.1`` and ``2.2`` do not have exact representations in binary floating " @@ -58,7 +58,7 @@ msgstr "" "浮點數中沒有精確的表示方式。終端使用者通常不會期望 ``1.1 + 2.2`` 顯示為 " "``3.3000000000000003``,但這正是二進位浮點數的表現。" -#: ../../library/decimal.rst:49 +#: ../../library/decimal.rst:41 msgid "" "The exactness carries over into arithmetic. In decimal floating point, " "``0.1 + 0.1 + 0.1 - 0.3`` is exactly equal to zero. In binary floating " @@ -72,7 +72,7 @@ msgstr "" "差異會妨礙可靠的相等性測試,並且差異可能累積。因此,在具有嚴格相等不變量的會" "計應用程式中,decimal 是首選。" -#: ../../library/decimal.rst:56 +#: ../../library/decimal.rst:48 msgid "" "The decimal module incorporates a notion of significant places so that " "``1.30 + 1.20`` is ``2.50``. The trailing zero is kept to indicate " @@ -86,7 +86,7 @@ msgstr "" "使用被乘數中的所有數字。例如,``1.3 * 1.2`` 得到 ``1.56``,而 ``1.30 * " "1.20`` 得到 ``1.5600``。" -#: ../../library/decimal.rst:63 +#: ../../library/decimal.rst:55 msgid "" "Unlike hardware based binary floating point, the decimal module has a user " "alterable precision (defaulting to 28 places) which can be as large as " @@ -95,7 +95,7 @@ msgstr "" "與基於硬體的二進位浮點數不同,decimal 模組具有使用者可變的精度(預設為 28 " "位),可以根據給定問題的需要設定得足夠大:" -#: ../../library/decimal.rst:75 +#: ../../library/decimal.rst:67 msgid "" "Both binary and decimal floating point are implemented in terms of published " "standards. While the built-in float type exposes only a modest portion of " @@ -109,7 +109,7 @@ msgstr "" "捨入和訊號處理有完全的控制權。這包括透過使用例外來阻止任何不精確運算以強制執" "行精確算術的選項。" -#: ../../library/decimal.rst:82 +#: ../../library/decimal.rst:74 msgid "" "The decimal module was designed to support \"without prejudice, both exact " "unrounded decimal arithmetic (sometimes called fixed-point arithmetic) and " @@ -119,13 +119,13 @@ msgstr "" "decimal 模組被設計為支援「不帶偏見地同時支援精確無捨入的十進位算術(有時稱為" "固定點算術)和有捨入的浮點算術。」——摘自十進位算術規格。" -#: ../../library/decimal.rst:87 +#: ../../library/decimal.rst:79 msgid "" "The module design is centered around three concepts: the decimal number, " "the context for arithmetic, and signals." msgstr "模組設計圍繞三個概念:decimal 數字、算術情境和訊號。" -#: ../../library/decimal.rst:90 +#: ../../library/decimal.rst:82 msgid "" "A decimal number is immutable. It has a sign, coefficient digits, and an " "exponent. To preserve significance, the coefficient digits do not truncate " @@ -137,7 +137,7 @@ msgstr "" "會截斷尾隨零。Decimal 也包含特殊值,如 ``Infinity``、``-Infinity`` 和 " "``NaN``。標準也區分 ``-0`` 和 ``+0``。" -#: ../../library/decimal.rst:96 +#: ../../library/decimal.rst:88 msgid "" "The context for arithmetic is an environment specifying precision, rounding " "rules, limits on exponents, flags indicating the results of operations, and " @@ -152,7 +152,7 @@ msgstr "" "`ROUND_HALF_EVEN`、:const:`ROUND_HALF_UP`、:const:`ROUND_UP` 和 :const:" "`ROUND_05UP`。" -#: ../../library/decimal.rst:103 +#: ../../library/decimal.rst:95 msgid "" "Signals are groups of exceptional conditions arising during the course of " "computation. Depending on the needs of the application, signals may be " @@ -168,7 +168,7 @@ msgstr "" "`Rounded`、:const:`Subnormal`、:const:`Overflow`、:const:`Underflow` 和 :" "const:`FloatOperation`。" -#: ../../library/decimal.rst:110 +#: ../../library/decimal.rst:102 msgid "" "For each signal there is a flag and a trap enabler. When a signal is " "encountered, its flag is set to one, then, if the trap enabler is set to " @@ -179,7 +179,7 @@ msgstr "" "如果陷阱啟用器被設定為一,就會引發例外。旗標是黏性的,因此使用者需要在監控計" "算之前重設它們。" -#: ../../library/decimal.rst:118 +#: ../../library/decimal.rst:110 msgid "" "IBM's General Decimal Arithmetic Specification, `The General Decimal " "Arithmetic Specification `_." @@ -187,11 +187,11 @@ msgstr "" "IBM 的一般十進位算術規範,`一般十進位算術規範 `_。" -#: ../../library/decimal.rst:127 +#: ../../library/decimal.rst:119 msgid "Quick-start tutorial" msgstr "快速入門教學" -#: ../../library/decimal.rst:129 +#: ../../library/decimal.rst:121 msgid "" "The usual start to using decimals is importing the module, viewing the " "current context with :func:`getcontext` and, if necessary, setting new " @@ -200,7 +200,7 @@ msgstr "" "使用 decimal 的通常起始步驟是引入模組、使用 :func:`getcontext` 檢視目前的情" "境,以及若有必要的話,設定精度、捨入方式或啟用陷阱的新值: ::" -#: ../../library/decimal.rst:133 +#: ../../library/decimal.rst:125 msgid "" ">>> from decimal import *\n" ">>> getcontext()\n" @@ -218,7 +218,7 @@ msgstr "" "\n" ">>> getcontext().prec = 7 # 設定新的精度" -#: ../../library/decimal.rst:141 +#: ../../library/decimal.rst:133 msgid "" "Decimal instances can be constructed from integers, strings, floats, or " "tuples. Construction from an integer or a float performs an exact conversion " @@ -230,7 +230,7 @@ msgstr "" "數或浮點數的值進行精確轉換。Decimal 數字包括特殊值,例如代表「非數字」的 " "``NaN``、正負 ``Infinity`` 和 ``-0``\\ ::" -#: ../../library/decimal.rst:147 +#: ../../library/decimal.rst:139 msgid "" ">>> getcontext().prec = 28\n" ">>> Decimal(10)\n" @@ -268,7 +268,7 @@ msgstr "" ">>> Decimal('-Infinity')\n" "Decimal('-Infinity')" -#: ../../library/decimal.rst:165 +#: ../../library/decimal.rst:157 msgid "" "If the :exc:`FloatOperation` signal is trapped, accidental mixing of " "decimals and floats in constructors or ordering comparisons raises an " @@ -277,7 +277,7 @@ msgstr "" "如果 :exc:`FloatOperation` 訊號被捕捉,在建構函式或排序比較中意外混用 " "decimal 和 float 會引發例外: ::" -#: ../../library/decimal.rst:169 +#: ../../library/decimal.rst:161 msgid "" ">>> c = getcontext()\n" ">>> c.traps[FloatOperation] = True\n" @@ -305,7 +305,7 @@ msgstr "" ">>> Decimal('3.5') == 3.5\n" "True" -#: ../../library/decimal.rst:184 +#: ../../library/decimal.rst:176 msgid "" "The significance of a new Decimal is determined solely by the number of " "digits input. Context precision and rounding only come into play during " @@ -314,7 +314,7 @@ msgstr "" "新 Decimal 的精度僅由輸入的數字位數決定。情境精度和捨入只會在算術運算期間發揮" "作用。" -#: ../../library/decimal.rst:188 +#: ../../library/decimal.rst:180 msgid "" ">>> getcontext().prec = 6\n" ">>> Decimal('3.0')\n" @@ -338,14 +338,14 @@ msgstr "" ">>> Decimal('3.1415926535') + Decimal('2.7182818285')\n" "Decimal('5.85988')" -#: ../../library/decimal.rst:201 +#: ../../library/decimal.rst:193 msgid "" "If the internal limits of the C version are exceeded, constructing a decimal " "raises :class:`InvalidOperation`::" msgstr "" "如果超過 C 版本的內部限制,建構 decimal 會引發 :class:`InvalidOperation`: ::" -#: ../../library/decimal.rst:204 +#: ../../library/decimal.rst:196 msgid "" ">>> Decimal(\"1e9999999999999999999\")\n" "Traceback (most recent call last):\n" @@ -357,14 +357,14 @@ msgstr "" " File \"\", line 1, in \n" "decimal.InvalidOperation: []" -#: ../../library/decimal.rst:211 +#: ../../library/decimal.rst:203 msgid "" "Decimals interact well with much of the rest of Python. Here is a small " "decimal floating-point flying circus:" msgstr "" "Decimal 與 Python 的其他部分互動良好。以下是一個小小的 decimal 浮點數展示:" -#: ../../library/decimal.rst:214 +#: ../../library/decimal.rst:206 msgid "" ">>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()))\n" ">>> max(data)\n" @@ -418,7 +418,7 @@ msgstr "" ">>> c % a\n" "Decimal('0.77')" -#: ../../library/decimal.rst:243 +#: ../../library/decimal.rst:235 msgid "" "Decimals can be formatted (with :func:`format` built-in or :ref:`f-strings`) " "in fixed-point or scientific notation, using the same formatting syntax " @@ -428,7 +428,7 @@ msgstr "" "建 :class:`float` 型別相同的格式化語法(見 :ref:`formatspec`)以固定點或科學" "記號格式化:" -#: ../../library/decimal.rst:247 +#: ../../library/decimal.rst:239 msgid "" ">>> format(Decimal('2.675'), \"f\")\n" "'2.675'\n" @@ -458,11 +458,11 @@ msgstr "" "...\n" "2.67" -#: ../../library/decimal.rst:263 +#: ../../library/decimal.rst:255 msgid "And some mathematical functions are also available to Decimal:" msgstr "而且 Decimal 也提供一些數學函式:" -#: ../../library/decimal.rst:275 +#: ../../library/decimal.rst:267 msgid "" "The :meth:`~Decimal.quantize` method rounds a number to a fixed exponent. " "This method is useful for monetary applications that often round results to " @@ -471,7 +471,7 @@ msgstr "" ":meth:`~Decimal.quantize` 方法將數字捨入到固定的指數。此方法對於經常將結果捨" "入到固定位數的金融應用程式很有用:" -#: ../../library/decimal.rst:284 +#: ../../library/decimal.rst:276 msgid "" "As shown above, the :func:`getcontext` function accesses the current context " "and allows the settings to be changed. This approach meets the needs of " @@ -480,7 +480,7 @@ msgstr "" "如上所示,:func:`getcontext` 函式存取目前的情境並允許變更設定。這種方法滿足大" "多數應用程式的需求。" -#: ../../library/decimal.rst:288 +#: ../../library/decimal.rst:280 msgid "" "For more advanced work, it may be useful to create alternate contexts using " "the :meth:`Context` constructor. To make an alternate active, use the :func:" @@ -489,7 +489,7 @@ msgstr "" "對於更進階的工作,使用 :meth:`Context` 建構函式來建立替代的 context 可能會很" "有用。要啟用替代的 context,使用 :func:`setcontext` 函式。" -#: ../../library/decimal.rst:292 +#: ../../library/decimal.rst:284 msgid "" "In accordance with the standard, the :mod:`!decimal` module provides two " "ready to use standard contexts, :const:`BasicContext` and :const:" @@ -500,7 +500,7 @@ msgstr "" "`BasicContext` 和 :const:`ExtendedContext`。前者對除錯特別有用,因為許多陷阱" "都被啟用了:" -#: ../../library/decimal.rst:297 +#: ../../library/decimal.rst:289 msgid "" ">>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN)\n" ">>> setcontext(myothercontext)\n" @@ -544,7 +544,7 @@ msgstr "" " Decimal(42) / Decimal(0)\n" "DivisionByZero: x / 0" -#: ../../library/decimal.rst:321 +#: ../../library/decimal.rst:313 msgid "" "Contexts also have signal flags for monitoring exceptional conditions " "encountered during computations. The flags remain set until explicitly " @@ -555,7 +555,7 @@ msgstr "" "清除,因此最好在每組受監控的計算之前使用 :meth:`~Context.clear_flags` 方法清" "除旗標: ::" -#: ../../library/decimal.rst:326 +#: ../../library/decimal.rst:318 msgid "" ">>> setcontext(ExtendedContext)\n" ">>> getcontext().clear_flags()\n" @@ -573,7 +573,7 @@ msgstr "" "Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,\n" " capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[])" -#: ../../library/decimal.rst:334 +#: ../../library/decimal.rst:326 msgid "" "The *flags* entry shows that the rational approximation to pi was rounded " "(digits beyond the context precision were thrown away) and that the result " @@ -582,13 +582,13 @@ msgstr "" "*flags* 條目顯示對 pi 的有理逼近已被捨入(超出情境精度的數字被丟棄),並且結" "果是不精確的(一些被丟棄的數字非零)。" -#: ../../library/decimal.rst:338 +#: ../../library/decimal.rst:330 msgid "" "Individual traps are set using the dictionary in the :attr:`~Context.traps` " "attribute of a context:" msgstr "個別陷阱使用情境的 :attr:`~Context.traps` 屬性中的字典設定:" -#: ../../library/decimal.rst:341 +#: ../../library/decimal.rst:333 msgid "" ">>> setcontext(ExtendedContext)\n" ">>> Decimal(1) / Decimal(0)\n" @@ -610,7 +610,7 @@ msgstr "" " Decimal(1) / Decimal(0)\n" "DivisionByZero: x / 0" -#: ../../library/decimal.rst:353 +#: ../../library/decimal.rst:345 msgid "" "Most programs adjust the current context only once, at the beginning of the " "program. And, in many applications, data is converted to :class:`Decimal` " @@ -622,15 +622,15 @@ msgstr "" "單次轉換轉換為 :class:`Decimal`。設定情境並建立 decimal 後,程式的大部分操作" "資料的方式與其他 Python 數值型別沒有什麼不同。" -#: ../../library/decimal.rst:365 +#: ../../library/decimal.rst:357 msgid "Decimal objects" msgstr "Decimal 物件" -#: ../../library/decimal.rst:370 +#: ../../library/decimal.rst:362 msgid "Construct a new :class:`Decimal` object based from *value*." msgstr "基於 *value* 建構一個新的 :class:`Decimal` 物件。" -#: ../../library/decimal.rst:372 +#: ../../library/decimal.rst:364 msgid "" "*value* can be an integer, string, tuple, :class:`float`, or another :class:" "`Decimal` object. If no *value* is given, returns ``Decimal('0')``. If " @@ -642,7 +642,7 @@ msgstr "" "如果沒有提供 *value*,則回傳 ``Decimal('0')``。如果 *value* 是字串,在移除前" "後空白字元以及整個字串中的底線後,它應該符合十進位數字字串語法: ::" -#: ../../library/decimal.rst:377 +#: ../../library/decimal.rst:369 msgid "" "sign ::= '+' | '-'\n" "digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | " @@ -668,7 +668,7 @@ msgstr "" "numeric-value ::= decimal-part [exponent-part] | infinity\n" "numeric-string ::= [sign] numeric-value | [sign] nan" -#: ../../library/decimal.rst:388 +#: ../../library/decimal.rst:380 msgid "" "Other Unicode decimal digits are also permitted where ``digit`` appears " "above. These include decimal digits from various other alphabets (for " @@ -682,7 +682,7 @@ msgstr "" "``'\\uff10'`` 到 ``'\\uff19'``。大小寫不重要,所以例如 ``inf``、``Inf``、" "``INFINITY`` 和 ``iNfINity`` 都是正無窮大的可接受拼寫。" -#: ../../library/decimal.rst:395 +#: ../../library/decimal.rst:387 msgid "" "If *value* is a :class:`tuple`, it should have three components, a sign " "(``0`` for positive or ``1`` for negative), a :class:`tuple` of digits, and " @@ -693,7 +693,7 @@ msgstr "" "``1`` 代表負數)、一個數字的 :class:`tuple`,以及一個整數指數。例如," "``Decimal((0, (1, 4, 1, 4), -3))`` 回傳 ``Decimal('1.414')``。" -#: ../../library/decimal.rst:400 +#: ../../library/decimal.rst:392 msgid "" "If *value* is a :class:`float`, the binary floating-point value is " "losslessly converted to its exact decimal equivalent. This conversion can " @@ -706,7 +706,7 @@ msgstr "" "``Decimal(float('1.1'))`` 轉換為 " "``Decimal('1.100000000000000088817841970012523233890533447265625')``。" -#: ../../library/decimal.rst:406 +#: ../../library/decimal.rst:398 msgid "" "The *context* precision does not affect how many digits are stored. That is " "determined exclusively by the number of digits in *value*. For example, " @@ -716,7 +716,7 @@ msgstr "" "*context* 精度不會影響儲存多少位數。這完全由 *value* 中的位數決定。例如,即使" "情境精度只有三位,``Decimal('3.00000')`` 也會記錄所有五個零。" -#: ../../library/decimal.rst:411 +#: ../../library/decimal.rst:403 msgid "" "The purpose of the *context* argument is determining what to do if *value* " "is a malformed string. If the context traps :const:`InvalidOperation`, an " @@ -727,17 +727,17 @@ msgstr "" "捉 :const:`InvalidOperation`,就會引發例外;否則,建構函式會回傳一個值為 " "``NaN`` 的新 Decimal。" -#: ../../library/decimal.rst:416 +#: ../../library/decimal.rst:408 msgid "Once constructed, :class:`Decimal` objects are immutable." msgstr "一旦建構,:class:`Decimal` 物件就是不可變的。" -#: ../../library/decimal.rst:418 +#: ../../library/decimal.rst:410 msgid "" "The argument to the constructor is now permitted to be a :class:`float` " "instance." msgstr "建構函式的引數現在允許是 :class:`float` 實例。" -#: ../../library/decimal.rst:422 +#: ../../library/decimal.rst:414 msgid "" ":class:`float` arguments raise an exception if the :exc:`FloatOperation` " "trap is set. By default the trap is off." @@ -745,13 +745,13 @@ msgstr "" "如果設定了 :exc:`FloatOperation` 陷阱,:class:`float` 引數會引發例外。預設情" "況下陷阱是關閉的。" -#: ../../library/decimal.rst:426 +#: ../../library/decimal.rst:418 msgid "" "Underscores are allowed for grouping, as with integral and floating-point " "literals in code." msgstr "允許使用底線進行分組,就像程式碼中的整數和浮點數字面值一樣。" -#: ../../library/decimal.rst:430 +#: ../../library/decimal.rst:422 msgid "" "Decimal floating-point objects share many properties with the other built-in " "numeric types such as :class:`float` and :class:`int`. All of the usual " @@ -765,7 +765,7 @@ msgstr "" "製、pickle 序列化、列印、用作字典鍵、用作集合元素、比較、排序,以及強制轉換為" "其他型別(如 :class:`float` 或 :class:`int`)。" -#: ../../library/decimal.rst:437 +#: ../../library/decimal.rst:429 msgid "" "There are some small differences between arithmetic on Decimal objects and " "arithmetic on integers and floats. When the remainder operator ``%`` is " @@ -776,7 +776,7 @@ msgstr "" "``%`` 應用於 Decimal 物件時,結果的符號是 *被除數* 的符號,而不是除數的符" "號: ::" -#: ../../library/decimal.rst:442 +#: ../../library/decimal.rst:434 msgid "" ">>> (-7) % 4\n" "1\n" @@ -788,7 +788,7 @@ msgstr "" ">>> Decimal(-7) % Decimal(4)\n" "Decimal('-3')" -#: ../../library/decimal.rst:447 +#: ../../library/decimal.rst:439 msgid "" "The integer division operator ``//`` behaves analogously, returning the " "integer part of the true quotient (truncating towards zero) rather than its " @@ -797,7 +797,7 @@ msgstr "" "整數除法運算子 ``//`` 的行為類似,回傳真商的整數部分(向零截斷)而不是其底" "數,以保持通常的恆等式 ``x == (x // y) * y + x % y``: ::" -#: ../../library/decimal.rst:451 +#: ../../library/decimal.rst:443 msgid "" ">>> -7 // 4\n" "-2\n" @@ -809,7 +809,7 @@ msgstr "" ">>> Decimal(-7) // Decimal(4)\n" "Decimal('-1')" -#: ../../library/decimal.rst:456 +#: ../../library/decimal.rst:448 msgid "" "The ``%`` and ``//`` operators implement the ``remainder`` and ``divide-" "integer`` operations (respectively) as described in the specification." @@ -817,7 +817,7 @@ msgstr "" "``%`` 和 ``//`` 運算子分別實作規格中描述的 ``remainder`` 和 ``divide-" "integer`` 運算。" -#: ../../library/decimal.rst:460 +#: ../../library/decimal.rst:452 msgid "" "Decimal objects cannot generally be combined with floats or instances of :" "class:`fractions.Fraction` in arithmetic operations: an attempt to add a :" @@ -833,19 +833,19 @@ msgstr "" "``x`` 與另一個數字 ``y``。這避免了在不同型別的數字之間進行相等比較時產生令人" "困惑的結果。" -#: ../../library/decimal.rst:468 +#: ../../library/decimal.rst:460 msgid "" "Mixed-type comparisons between :class:`Decimal` instances and other numeric " "types are now fully supported." msgstr ":class:`Decimal` 實例與其他數值型別之間的混合型別比較現在完全支援。" -#: ../../library/decimal.rst:472 +#: ../../library/decimal.rst:464 msgid "" "In addition to the standard numeric properties, decimal floating-point " "objects also have a number of specialized methods:" msgstr "除了標準數值屬性外,decimal 浮點數物件也有許多專門的方法:" -#: ../../library/decimal.rst:478 +#: ../../library/decimal.rst:470 msgid "" "Return the adjusted exponent after shifting out the coefficient's rightmost " "digits until only the lead digit remains: ``Decimal('321e+5').adjusted()`` " @@ -856,7 +856,7 @@ msgstr "" "``Decimal('321e+5').adjusted()`` 回傳七。用於確定最高有效數字相對於小數點的位" "置。" -#: ../../library/decimal.rst:485 +#: ../../library/decimal.rst:477 msgid "" "Return a pair ``(n, d)`` of integers that represent the given :class:" "`Decimal` instance as a fraction, in lowest terms and with a positive " @@ -865,7 +865,7 @@ msgstr "" "回傳一對表示給定 :class:`Decimal` 實例作為分數的整數 ``(n, d)``,以最簡形式且" "分母為正: ::" -#: ../../library/decimal.rst:489 +#: ../../library/decimal.rst:481 msgid "" ">>> Decimal('-3.14').as_integer_ratio()\n" "(-157, 50)" @@ -873,13 +873,13 @@ msgstr "" ">>> Decimal('-3.14').as_integer_ratio()\n" "(-157, 50)" -#: ../../library/decimal.rst:492 +#: ../../library/decimal.rst:484 msgid "" "The conversion is exact. Raise OverflowError on infinities and ValueError " "on NaNs." msgstr "轉換是精確的。對無窮大引發 OverflowError,對 NaN 引發 ValueError。" -#: ../../library/decimal.rst:499 +#: ../../library/decimal.rst:491 msgid "" "Return a :term:`named tuple` representation of the number: " "``DecimalTuple(sign, digits, exponent)``." @@ -887,7 +887,7 @@ msgstr "" "回傳數字的 :term:`named tuple` 表示形式:``DecimalTuple(sign, digits, " "exponent)``。" -#: ../../library/decimal.rst:505 +#: ../../library/decimal.rst:497 msgid "" "Return the canonical encoding of the argument. Currently, the encoding of " "a :class:`Decimal` instance is always canonical, so this operation returns " @@ -896,7 +896,7 @@ msgstr "" "回傳引數的標準編碼。目前,:class:`Decimal` 實例的編碼總是標準的,因此此運算回" "傳其引數不變。" -#: ../../library/decimal.rst:511 +#: ../../library/decimal.rst:503 msgid "" "Compare the values of two Decimal instances. :meth:`compare` returns a " "Decimal instance, and if either operand is a NaN then the result is a NaN::" @@ -904,7 +904,7 @@ msgstr "" "比較兩個 Decimal 實例的值。:meth:`compare` 回傳一個 Decimal 實例,如果任一運" "算元是 NaN,則結果是 NaN: ::" -#: ../../library/decimal.rst:515 +#: ../../library/decimal.rst:507 msgid "" "a or b is a NaN ==> Decimal('NaN')\n" "a < b ==> Decimal('-1')\n" @@ -916,7 +916,7 @@ msgstr "" "a == b ==> Decimal('0')\n" "a > b ==> Decimal('1')" -#: ../../library/decimal.rst:522 +#: ../../library/decimal.rst:514 msgid "" "This operation is identical to the :meth:`compare` method, except that all " "NaNs signal. That is, if neither operand is a signaling NaN then any quiet " @@ -926,7 +926,7 @@ msgstr "" "兩個運算元都不是發出訊號的 NaN,那麼任何安靜的 NaN 運算元都會被視為發出訊號" "的 NaN。" -#: ../../library/decimal.rst:528 +#: ../../library/decimal.rst:520 msgid "" "Compare two operands using their abstract representation rather than their " "numerical value. Similar to the :meth:`compare` method, but the result " @@ -938,7 +938,7 @@ msgstr "" "對 :class:`Decimal` 實例給出全序。在此排序中,具有相同數值但不同表示的兩個 :" "class:`Decimal` 實例比較為不相等:" -#: ../../library/decimal.rst:537 +#: ../../library/decimal.rst:529 msgid "" "Quiet and signaling NaNs are also included in the total ordering. The " "result of this function is ``Decimal('0')`` if both operands have the same " @@ -952,8 +952,8 @@ msgstr "" "``Decimal('-1')``;如果第一個運算元在全序中高於第二個運算元,則為 " "``Decimal('1')``。有關全序的詳細資訊,請參閱規範。" -#: ../../library/decimal.rst:544 ../../library/decimal.rst:555 -#: ../../library/decimal.rst:583 ../../library/decimal.rst:887 +#: ../../library/decimal.rst:536 ../../library/decimal.rst:547 +#: ../../library/decimal.rst:575 ../../library/decimal.rst:879 msgid "" "This operation is unaffected by context and is quiet: no flags are changed " "and no rounding is performed. As an exception, the C version may raise " @@ -962,7 +962,7 @@ msgstr "" "此運算不受情境影響且是安靜的:不會變更旗標也不會執行捨入。例外情況下,如果第" "二個運算元無法精確轉換,C 版本可能會引發 InvalidOperation。" -#: ../../library/decimal.rst:550 +#: ../../library/decimal.rst:542 msgid "" "Compare two operands using their abstract representation rather than their " "value as in :meth:`compare_total`, but ignoring the sign of each operand. " @@ -973,33 +973,33 @@ msgstr "" "算元的符號。``x.compare_total_mag(y)`` 等於 ``x.copy_abs().compare_total(y." "copy_abs())``。" -#: ../../library/decimal.rst:561 +#: ../../library/decimal.rst:553 msgid "" "Just returns self, this method is only to comply with the Decimal " "Specification." msgstr "只是回傳 self,此方法僅為符合 Decimal 規範。" -#: ../../library/decimal.rst:566 +#: ../../library/decimal.rst:558 msgid "" "Return the absolute value of the argument. This operation is unaffected by " "the context and is quiet: no flags are changed and no rounding is performed." msgstr "" "回傳引數的絕對值。此運算不受情境影響且是安靜的:不會變更旗標也不會執行捨入。" -#: ../../library/decimal.rst:572 +#: ../../library/decimal.rst:564 msgid "" "Return the negation of the argument. This operation is unaffected by the " "context and is quiet: no flags are changed and no rounding is performed." msgstr "" "回傳引數的否定。此運算不受情境影響且是安靜的:不會變更旗標也不會執行捨入。" -#: ../../library/decimal.rst:577 +#: ../../library/decimal.rst:569 msgid "" "Return a copy of the first operand with the sign set to be the same as the " "sign of the second operand. For example:" msgstr "回傳第一個運算元的副本,其符號被設定為與第二個運算元的符號相同。例如:" -#: ../../library/decimal.rst:589 +#: ../../library/decimal.rst:581 msgid "" "Return the value of the (natural) exponential function ``e**x`` at the given " "number. The result is correctly rounded using the :const:`ROUND_HALF_EVEN` " @@ -1008,13 +1008,13 @@ msgstr "" "回傳給定數字的(自然)指數函式 ``e**x`` 的值。使用 :const:`ROUND_HALF_EVEN` " "捨入模式正確地捨入結果。" -#: ../../library/decimal.rst:600 +#: ../../library/decimal.rst:592 msgid "" "Alternative constructor that only accepts instances of :class:`float` or :" "class:`int`." msgstr "僅接受 :class:`float` 或 :class:`int` 實例的替代建構函式。" -#: ../../library/decimal.rst:603 +#: ../../library/decimal.rst:595 msgid "" "Note ``Decimal.from_float(0.1)`` is not the same as ``Decimal('0.1')``. " "Since 0.1 is not exactly representable in binary floating point, the value " @@ -1027,14 +1027,14 @@ msgstr "" "``0x1.999999999999ap-4``。該值在十進位中的等價值是 " "``0.1000000000000000055511151231257827021181583404541015625``。" -#: ../../library/decimal.rst:609 +#: ../../library/decimal.rst:601 msgid "" "From Python 3.2 onwards, a :class:`Decimal` instance can also be constructed " "directly from a :class:`float`." msgstr "" "從 Python 3.2 開始,:class:`Decimal` 實例也可以直接從 :class:`float` 建構。" -#: ../../library/decimal.rst:612 +#: ../../library/decimal.rst:604 msgid "" ">>> Decimal.from_float(0.1)\n" "Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" @@ -1054,7 +1054,7 @@ msgstr "" ">>> Decimal.from_float(float('-inf'))\n" "Decimal('-Infinity')" -#: ../../library/decimal.rst:627 +#: ../../library/decimal.rst:619 msgid "" "Alternative constructor that only accepts instances of :class:`float`, :" "class:`int` or :class:`Decimal`, but not strings or tuples." @@ -1062,7 +1062,7 @@ msgstr "" "替代建構函式,僅接受 :class:`float`、:class:`int` 或 :class:`Decimal` 的實" "例,但不接受字串或 tuple。" -#: ../../library/decimal.rst:631 +#: ../../library/decimal.rst:623 msgid "" ">>> Decimal.from_number(314)\n" "Decimal('314')\n" @@ -1078,13 +1078,13 @@ msgstr "" ">>> Decimal.from_number(Decimal('3.14'))\n" "Decimal('3.14')" -#: ../../library/decimal.rst:644 +#: ../../library/decimal.rst:636 msgid "" "Fused multiply-add. Return self*other+third with no rounding of the " "intermediate product self*other." msgstr "融合乘加。回傳 self*other+third,對中間產品 self*other 不進行捨入。" -#: ../../library/decimal.rst:652 +#: ../../library/decimal.rst:644 msgid "" "Return :const:`True` if the argument is canonical and :const:`False` " "otherwise. Currently, a :class:`Decimal` instance is always canonical, so " @@ -1093,7 +1093,7 @@ msgstr "" "如果引數是標準形式則回傳 :const:`True`,否則回傳 :const:`False`。目前,:" "class:`Decimal` 實例總是標準形式,因此此運算總是回傳 :const:`True`。" -#: ../../library/decimal.rst:658 +#: ../../library/decimal.rst:650 msgid "" "Return :const:`True` if the argument is a finite number, and :const:`False` " "if the argument is an infinity or a NaN." @@ -1101,14 +1101,14 @@ msgstr "" "如果引數是有限數則回傳 :const:`True`,如果引數是無窮大或 NaN 則回傳 :const:" "`False`。" -#: ../../library/decimal.rst:663 +#: ../../library/decimal.rst:655 msgid "" "Return :const:`True` if the argument is either positive or negative infinity " "and :const:`False` otherwise." msgstr "" "如果引數是正無窮大或負無窮大則回傳 :const:`True`,否則回傳 :const:`False`。" -#: ../../library/decimal.rst:668 +#: ../../library/decimal.rst:660 msgid "" "Return :const:`True` if the argument is a (quiet or signaling) NaN and :" "const:`False` otherwise." @@ -1116,7 +1116,7 @@ msgstr "" "如果引數是(安靜或發出訊號的)NaN 則回傳 :const:`True`,否則回傳 :const:" "`False`。" -#: ../../library/decimal.rst:673 +#: ../../library/decimal.rst:665 msgid "" "Return :const:`True` if the argument is a *normal* finite number. Return :" "const:`False` if the argument is zero, subnormal, infinite or a NaN." @@ -1124,13 +1124,13 @@ msgstr "" "如果引數是 *正常* 有限數則回傳 :const:`True`。如果引數是零、次正規、無窮大或 " "NaN 則回傳 :const:`False`。" -#: ../../library/decimal.rst:678 +#: ../../library/decimal.rst:670 msgid "" "Return :const:`True` if the argument is a quiet NaN, and :const:`False` " "otherwise." msgstr "如果引數是安靜 NaN 則回傳 :const:`True`,否則回傳 :const:`False`。" -#: ../../library/decimal.rst:683 +#: ../../library/decimal.rst:675 msgid "" "Return :const:`True` if the argument has a negative sign and :const:`False` " "otherwise. Note that zeros and NaNs can both carry signs." @@ -1138,26 +1138,26 @@ msgstr "" "如果引數具有負號則回傳 :const:`True`,否則回傳 :const:`False`。注意零和 NaN " "都可以帶有符號。" -#: ../../library/decimal.rst:688 +#: ../../library/decimal.rst:680 msgid "" "Return :const:`True` if the argument is a signaling NaN and :const:`False` " "otherwise." msgstr "" "如果引數是發出訊號的 NaN 則回傳 :const:`True`,否則回傳 :const:`False`。" -#: ../../library/decimal.rst:693 +#: ../../library/decimal.rst:685 msgid "" "Return :const:`True` if the argument is subnormal, and :const:`False` " "otherwise." msgstr "如果引數是次正規則回傳 :const:`True`,否則回傳 :const:`False`。" -#: ../../library/decimal.rst:698 +#: ../../library/decimal.rst:690 msgid "" "Return :const:`True` if the argument is a (positive or negative) zero and :" "const:`False` otherwise." msgstr "如果引數是(正或負)零則回傳 :const:`True`,否則回傳 :const:`False`。" -#: ../../library/decimal.rst:703 +#: ../../library/decimal.rst:695 msgid "" "Return the natural (base e) logarithm of the operand. The result is " "correctly rounded using the :const:`ROUND_HALF_EVEN` rounding mode." @@ -1165,7 +1165,7 @@ msgstr "" "回傳運算元的自然(以 e 為底)對數。使用 :const:`ROUND_HALF_EVEN` 捨入模式正確" "地捨入結果。" -#: ../../library/decimal.rst:708 +#: ../../library/decimal.rst:700 msgid "" "Return the base ten logarithm of the operand. The result is correctly " "rounded using the :const:`ROUND_HALF_EVEN` rounding mode." @@ -1173,7 +1173,7 @@ msgstr "" "回傳運算元的十進位對數。使用 :const:`ROUND_HALF_EVEN` 捨入模式正確地捨入結" "果。" -#: ../../library/decimal.rst:713 +#: ../../library/decimal.rst:705 msgid "" "For a nonzero number, return the adjusted exponent of its operand as a :" "class:`Decimal` instance. If the operand is a zero then ``Decimal('-" @@ -1184,7 +1184,7 @@ msgstr "" "零,則回傳 ``Decimal('-Infinity')`` 並引發 :const:`DivisionByZero` 旗標。如果" "運算元是無窮大,則回傳 ``Decimal('Infinity')``。" -#: ../../library/decimal.rst:721 +#: ../../library/decimal.rst:713 msgid "" ":meth:`logical_and` is a logical operation which takes two *logical " "operands* (see :ref:`logical_operands_label`). The result is the digit-wise " @@ -1193,13 +1193,13 @@ msgstr "" ":meth:`logical_and` 是一個邏輯運算,接受兩個 *logical operands* (參見 :ref:" "`logical_operands_label`)。結果是兩個運算元的逐位 ``and``。" -#: ../../library/decimal.rst:727 +#: ../../library/decimal.rst:719 msgid "" ":meth:`logical_invert` is a logical operation. The result is the digit-wise " "inversion of the operand." msgstr ":meth:`logical_invert` 是一個邏輯運算。結果是運算元的逐位反轉。" -#: ../../library/decimal.rst:732 +#: ../../library/decimal.rst:724 msgid "" ":meth:`logical_or` is a logical operation which takes two *logical operands* " "(see :ref:`logical_operands_label`). The result is the digit-wise ``or`` of " @@ -1208,7 +1208,7 @@ msgstr "" ":meth:`logical_or` 是一個邏輯運算,接受兩個 *logical operands* (參見 :ref:" "`logical_operands_label`)。結果是兩個運算元的逐位 ``or``。" -#: ../../library/decimal.rst:738 +#: ../../library/decimal.rst:730 msgid "" ":meth:`logical_xor` is a logical operation which takes two *logical " "operands* (see :ref:`logical_operands_label`). The result is the digit-wise " @@ -1217,7 +1217,7 @@ msgstr "" ":meth:`logical_xor` 是一個邏輯運算,接受兩個 *logical operands* (參見 :ref:" "`logical_operands_label`)。結果是兩個運算元的逐位互斥或。" -#: ../../library/decimal.rst:744 +#: ../../library/decimal.rst:736 msgid "" "Like ``max(self, other)`` except that the context rounding rule is applied " "before returning and that ``NaN`` values are either signaled or ignored " @@ -1226,13 +1226,13 @@ msgstr "" "類似於 ``max(self, other)``,但在回傳前會套用情境捨入規則,且 ``NaN`` 值會被" "發出訊號或忽略(取決於情境以及它們是發出訊號或安靜的)。" -#: ../../library/decimal.rst:751 +#: ../../library/decimal.rst:743 msgid "" "Similar to the :meth:`.max` method, but the comparison is done using the " "absolute values of the operands." msgstr "類似於 :meth:`.max` 方法,但比較是使用運算元的絕對值進行的。" -#: ../../library/decimal.rst:756 +#: ../../library/decimal.rst:748 msgid "" "Like ``min(self, other)`` except that the context rounding rule is applied " "before returning and that ``NaN`` values are either signaled or ignored " @@ -1241,13 +1241,13 @@ msgstr "" "類似於 ``min(self, other)``,但在回傳前會套用情境捨入規則,且 ``NaN`` 值會被" "發出訊號或忽略(取決於情境以及它們是發出訊號或安靜的)。" -#: ../../library/decimal.rst:763 +#: ../../library/decimal.rst:755 msgid "" "Similar to the :meth:`.min` method, but the comparison is done using the " "absolute values of the operands." msgstr "類似於 :meth:`.min` 方法,但比較是使用運算元的絕對值進行的。" -#: ../../library/decimal.rst:768 +#: ../../library/decimal.rst:760 msgid "" "Return the largest number representable in the given context (or in the " "current thread's context if no context is given) that is smaller than the " @@ -1256,7 +1256,7 @@ msgstr "" "回傳在給定情境中(或如果沒有提供情境則在目前執行緒的情境中)可表示的最大數" "字,且該數字小於給定的運算元。" -#: ../../library/decimal.rst:774 +#: ../../library/decimal.rst:766 msgid "" "Return the smallest number representable in the given context (or in the " "current thread's context if no context is given) that is larger than the " @@ -1265,7 +1265,7 @@ msgstr "" "回傳在給定情境中(或如果沒有提供情境則在目前執行緒的情境中)可表示的最小數" "字,且該數字大於給定的運算元。" -#: ../../library/decimal.rst:780 +#: ../../library/decimal.rst:772 msgid "" "If the two operands are unequal, return the number closest to the first " "operand in the direction of the second operand. If both operands are " @@ -1276,13 +1276,13 @@ msgstr "" "兩個運算元在數值上相等,回傳第一個運算元的副本,其符號設定為與第二個運算元的" "符號相同。" -#: ../../library/decimal.rst:787 +#: ../../library/decimal.rst:779 msgid "" "Used for producing canonical values of an equivalence class within either " "the current context or the specified context." msgstr "用於在目前情境或指定情境中產生等價類別的標準值。" -#: ../../library/decimal.rst:790 +#: ../../library/decimal.rst:782 msgid "" "This has the same semantics as the unary plus operation, except that if the " "final result is finite it is reduced to its simplest form, with all trailing " @@ -1295,7 +1295,7 @@ msgstr "" "除所有尾隨零並保留符號。也就是說,當係數非零且是十的倍數時,係數除以十,指數" "增加 1。否則(係數為零)指數設定為 0。在所有情況下符號都不變。" -#: ../../library/decimal.rst:797 +#: ../../library/decimal.rst:789 msgid "" "For example, ``Decimal('32.100')`` and ``Decimal('0.321000e+2')`` both " "normalize to the equivalent value ``Decimal('32.1')``." @@ -1303,73 +1303,73 @@ msgstr "" "例如,``Decimal('32.100')`` 和 ``Decimal('0.321000e+2')`` 都正規化為等價值 " "``Decimal('32.1')``。" -#: ../../library/decimal.rst:800 +#: ../../library/decimal.rst:792 msgid "Note that rounding is applied *before* reducing to simplest form." msgstr "注意捨入是在簡化為最簡形式 *之前* 套用的。" -#: ../../library/decimal.rst:802 +#: ../../library/decimal.rst:794 msgid "" "In the latest versions of the specification, this operation is also known as " "``reduce``." msgstr "在規格的最新版本中,此運算也被稱為 ``reduce``。" -#: ../../library/decimal.rst:807 +#: ../../library/decimal.rst:799 msgid "" "Return a string describing the *class* of the operand. The returned value " "is one of the following ten strings." msgstr "回傳描述運算元 *類別* 的字串。回傳值是下列十個字串之一。" -#: ../../library/decimal.rst:810 +#: ../../library/decimal.rst:802 msgid "``\"-Infinity\"``, indicating that the operand is negative infinity." msgstr "``\"-Infinity\"``,表示運算元是負無窮大。" -#: ../../library/decimal.rst:811 +#: ../../library/decimal.rst:803 msgid "" "``\"-Normal\"``, indicating that the operand is a negative normal number." msgstr "``\"-Normal\"``,表示運算元是負的正規數。" -#: ../../library/decimal.rst:812 +#: ../../library/decimal.rst:804 msgid "" "``\"-Subnormal\"``, indicating that the operand is negative and subnormal." msgstr "``\"-Subnormal\"``,表示運算元是負的次正規數。" -#: ../../library/decimal.rst:813 +#: ../../library/decimal.rst:805 msgid "``\"-Zero\"``, indicating that the operand is a negative zero." msgstr "``\"-Zero\"``,表示運算元是負零。" -#: ../../library/decimal.rst:814 +#: ../../library/decimal.rst:806 msgid "``\"+Zero\"``, indicating that the operand is a positive zero." msgstr "``\"+Zero\"``,表示運算元是正零。" -#: ../../library/decimal.rst:815 +#: ../../library/decimal.rst:807 msgid "" "``\"+Subnormal\"``, indicating that the operand is positive and subnormal." msgstr "``\"+Subnormal\"``,表示運算元是正的次正規數。" -#: ../../library/decimal.rst:816 +#: ../../library/decimal.rst:808 msgid "" "``\"+Normal\"``, indicating that the operand is a positive normal number." msgstr "``\"+Normal\"``,表示運算元是正的正規數。" -#: ../../library/decimal.rst:817 +#: ../../library/decimal.rst:809 msgid "``\"+Infinity\"``, indicating that the operand is positive infinity." msgstr "``\"+Infinity\"``,表示運算元是正無窮大。" -#: ../../library/decimal.rst:818 +#: ../../library/decimal.rst:810 msgid "``\"NaN\"``, indicating that the operand is a quiet NaN (Not a Number)." msgstr "``\"NaN\"``,表示運算元是安靜型 NaN(Not a Number,非數字)。" -#: ../../library/decimal.rst:819 +#: ../../library/decimal.rst:811 msgid "``\"sNaN\"``, indicating that the operand is a signaling NaN." msgstr "``\"sNaN\"``,表示運算元是發訊型 NaN (signaling NaN)。" -#: ../../library/decimal.rst:823 +#: ../../library/decimal.rst:815 msgid "" "Return a value equal to the first operand after rounding and having the " "exponent of the second operand." msgstr "回傳一個值,該值等於第一個運算元在捨入後並具有第二個運算元的指數。" -#: ../../library/decimal.rst:829 +#: ../../library/decimal.rst:821 msgid "" "Unlike other operations, if the length of the coefficient after the quantize " "operation would be greater than precision, then an :const:`InvalidOperation` " @@ -1380,7 +1380,7 @@ msgstr "" "`InvalidOperation` 訊號。這保證了除非有錯誤條件,否則量化指數總是等於右運算元" "的指數。" -#: ../../library/decimal.rst:835 +#: ../../library/decimal.rst:827 msgid "" "Also unlike other operations, quantize never signals Underflow, even if the " "result is subnormal and inexact." @@ -1388,7 +1388,7 @@ msgstr "" "同樣與其他運算不同,quantize 永遠不會發出 Underflow 訊號,即使結果是次正規且" "不精確的。" -#: ../../library/decimal.rst:838 +#: ../../library/decimal.rst:830 msgid "" "If the exponent of the second operand is larger than that of the first then " "rounding may be necessary. In this case, the rounding mode is determined by " @@ -1400,7 +1400,7 @@ msgstr "" "``rounding`` 引數決定(如果有提供),否則由給定的 ``context`` 引數決定;如果" "兩個引數都沒有提供,則使用目前執行緒情境的捨入模式。" -#: ../../library/decimal.rst:844 +#: ../../library/decimal.rst:836 msgid "" "An error is returned whenever the resulting exponent is greater than :attr:" "`~Context.Emax` or less than :meth:`~Context.Etiny`." @@ -1408,7 +1408,7 @@ msgstr "" "當結果指數大於 :attr:`~Context.Emax` 或小於 :meth:`~Context.Etiny` 時會回傳錯" "誤。" -#: ../../library/decimal.rst:849 +#: ../../library/decimal.rst:841 msgid "" "Return ``Decimal(10)``, the radix (base) in which the :class:`Decimal` class " "does all its arithmetic. Included for compatibility with the specification." @@ -1416,7 +1416,7 @@ msgstr "" "回傳 ``Decimal(10)``,這是 :class:`Decimal` 類別執行所有算術運算的基數(底" "數)。包含此項是為了與規格相容。" -#: ../../library/decimal.rst:855 +#: ../../library/decimal.rst:847 msgid "" "Return the remainder from dividing *self* by *other*. This differs from " "``self % other`` in that the sign of the remainder is chosen so as to " @@ -1429,11 +1429,11 @@ msgstr "" "``n`` 是最接近 ``self / other`` 精確值的整數,如果兩個整數同樣接近,則選擇偶" "數。" -#: ../../library/decimal.rst:862 +#: ../../library/decimal.rst:854 msgid "If the result is zero then its sign will be the sign of *self*." msgstr "如果結果是零,則其符號將是 *self* 的符號。" -#: ../../library/decimal.rst:873 +#: ../../library/decimal.rst:865 msgid "" "Return the result of rotating the digits of the first operand by an amount " "specified by the second operand. The second operand must be an integer in " @@ -1449,13 +1449,13 @@ msgstr "" "如果第二個運算元是正數,則向左旋轉;否則向右旋轉。第一個運算元的係數如有必要" "會在左側填補零以達到精度長度。第一個運算元的符號和指數不變。" -#: ../../library/decimal.rst:884 +#: ../../library/decimal.rst:876 msgid "" "Test whether self and other have the same exponent or whether both are " "``NaN``." msgstr "測試 self 和 other 是否具有相同的指數,或兩者是否都是 ``NaN``。" -#: ../../library/decimal.rst:893 +#: ../../library/decimal.rst:885 msgid "" "Return the first operand with exponent adjusted by the second. Equivalently, " "return the first operand multiplied by ``10**other``. The second operand " @@ -1464,7 +1464,7 @@ msgstr "" "回傳第一個運算元,其指數由第二個運算元調整。等價地,回傳第一個運算元乘以 " "``10**other``。第二個運算元必須是整數。" -#: ../../library/decimal.rst:899 +#: ../../library/decimal.rst:891 msgid "" "Return the result of shifting the digits of the first operand by an amount " "specified by the second operand. The second operand must be an integer in " @@ -1479,16 +1479,16 @@ msgstr "" "如果第二個運算元是正數,則向左移位;否則向右移位。移入係數的數字是零。第一個" "運算元的符號和指數不變。" -#: ../../library/decimal.rst:909 +#: ../../library/decimal.rst:901 msgid "Return the square root of the argument to full precision." msgstr "回傳引數的完整精度平方根。" -#: ../../library/decimal.rst:914 ../../library/decimal.rst:1571 +#: ../../library/decimal.rst:906 ../../library/decimal.rst:1563 msgid "" "Convert to a string, using engineering notation if an exponent is needed." msgstr "轉換為字串,如果需要指數則使用工程記號。" -#: ../../library/decimal.rst:916 ../../library/decimal.rst:1573 +#: ../../library/decimal.rst:908 ../../library/decimal.rst:1565 msgid "" "Engineering notation has an exponent which is a multiple of 3. This can " "leave up to 3 digits to the left of the decimal place and may require the " @@ -1497,12 +1497,12 @@ msgstr "" "工程記號的指數是 3 的倍數。這可能在小數點左側留下最多 3 位數字,並可能需要添" "加一個或兩個尾隨零。" -#: ../../library/decimal.rst:920 +#: ../../library/decimal.rst:912 msgid "" "For example, this converts ``Decimal('123E+1')`` to ``Decimal('1.23E+3')``." msgstr "例如,這將 ``Decimal('123E+1')`` 轉換為 ``Decimal('1.23E+3')``。" -#: ../../library/decimal.rst:924 +#: ../../library/decimal.rst:916 msgid "" "Identical to the :meth:`to_integral_value` method. The ``to_integral`` name " "has been kept for compatibility with older versions." @@ -1510,7 +1510,7 @@ msgstr "" "與 :meth:`to_integral_value` 方法相同。保留 ``to_integral`` 名稱是為了與舊版" "本相容。" -#: ../../library/decimal.rst:929 +#: ../../library/decimal.rst:921 msgid "" "Round to the nearest integer, signaling :const:`Inexact` or :const:`Rounded` " "as appropriate if rounding occurs. The rounding mode is determined by the " @@ -1521,7 +1521,7 @@ msgstr "" "`Rounded` 訊號。捨入模式由 ``rounding`` 參數決定(如果有提供),否則由給定的 " "``context`` 決定。如果兩個參數都沒有提供,則使用目前情境的捨入模式。" -#: ../../library/decimal.rst:937 +#: ../../library/decimal.rst:929 msgid "" "Round to the nearest integer without signaling :const:`Inexact` or :const:" "`Rounded`. If given, applies *rounding*; otherwise, uses the rounding " @@ -1530,11 +1530,11 @@ msgstr "" "捨入到最近的整數,不發出 :const:`Inexact` 或 :const:`Rounded` 訊號。如果有提" "供,套用 *rounding*;否則,使用提供的 *context* 或目前情境中的捨入方法。" -#: ../../library/decimal.rst:941 +#: ../../library/decimal.rst:933 msgid "Decimal numbers can be rounded using the :func:`.round` function:" msgstr "Decimal 數字可以使用 :func:`.round` 函式進行捨入:" -#: ../../library/decimal.rst:946 +#: ../../library/decimal.rst:938 msgid "" "If *ndigits* is not given or ``None``, returns the nearest :class:`int` to " "*number*, rounding ties to even, and ignoring the rounding mode of the :" @@ -1546,7 +1546,7 @@ msgstr "" "大則引發 :exc:`OverflowError`,如果是(安靜或發出訊號的)NaN 則引發 :exc:" "`ValueError`。" -#: ../../library/decimal.rst:952 +#: ../../library/decimal.rst:944 msgid "" "If *ndigits* is an :class:`int`, the context's rounding mode is respected " "and a :class:`Decimal` representing *number* rounded to the nearest multiple " @@ -1564,28 +1564,28 @@ msgstr "" "發出訊號的 NaN,或 quantize 運算後係數的長度大於目前情境的精度,則引發 :" "class:`InvalidOperation`。換句話說,對於非邊界情況:" -#: ../../library/decimal.rst:962 +#: ../../library/decimal.rst:954 msgid "" "if *ndigits* is positive, return *number* rounded to *ndigits* decimal " "places;" msgstr "如果 *ndigits* 是正數,回傳 *number* 捨入到 *ndigits* 小數位數;" -#: ../../library/decimal.rst:964 +#: ../../library/decimal.rst:956 msgid "if *ndigits* is zero, return *number* rounded to the nearest integer;" msgstr "如果 *ndigits* 是零,回傳 *number* 捨入到最近的整數;" -#: ../../library/decimal.rst:965 +#: ../../library/decimal.rst:957 msgid "" "if *ndigits* is negative, return *number* rounded to the nearest multiple of " "``10**abs(ndigits)``." msgstr "" "如果 *ndigits* 是負數,回傳 *number* 捨入到 ``10**abs(ndigits)`` 的最近倍數。" -#: ../../library/decimal.rst:968 +#: ../../library/decimal.rst:960 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/decimal.rst:970 +#: ../../library/decimal.rst:962 msgid "" ">>> from decimal import Decimal, getcontext, ROUND_DOWN\n" ">>> getcontext().rounding = ROUND_DOWN\n" @@ -1613,11 +1613,11 @@ msgstr "" ">>> round(Decimal('3.75'), -1)\n" "Decimal('0E+1')" -#: ../../library/decimal.rst:987 +#: ../../library/decimal.rst:979 msgid "Logical operands" msgstr "邏輯運算元" -#: ../../library/decimal.rst:989 +#: ../../library/decimal.rst:981 msgid "" "The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:" "`~Decimal.logical_or`, and :meth:`~Decimal.logical_xor` methods expect their " @@ -1630,11 +1630,11 @@ msgstr "" "*logical operands*。*logical operand* 是指數和符號都為零,且數字全部為 ``0`` " "或 ``1`` 的 :class:`Decimal` 實例。" -#: ../../library/decimal.rst:1001 +#: ../../library/decimal.rst:993 msgid "Context objects" msgstr "Context 物件" -#: ../../library/decimal.rst:1003 +#: ../../library/decimal.rst:995 msgid "" "Contexts are environments for arithmetic operations. They govern precision, " "set rules for rounding, determine which signals are treated as exceptions, " @@ -1643,7 +1643,7 @@ msgstr "" "Context 是算術運算的環境。它們控制精度、設定捨入規則、決定哪些訊號被視為例" "外,並限制指數的範圍。" -#: ../../library/decimal.rst:1007 +#: ../../library/decimal.rst:999 msgid "" "Each thread has its own current context which is accessed or changed using " "the :func:`getcontext` and :func:`setcontext` functions:" @@ -1651,15 +1651,15 @@ msgstr "" "每個執行緒都有自己的目前情境,可以使用 :func:`getcontext` 和 :func:" "`setcontext` 函式來存取或變更:" -#: ../../library/decimal.rst:1013 +#: ../../library/decimal.rst:1005 msgid "Return the current context for the active thread." msgstr "回傳作用中執行緒的目前情境。" -#: ../../library/decimal.rst:1018 +#: ../../library/decimal.rst:1010 msgid "Set the current context for the active thread to *c*." msgstr "將作用中執行緒的目前情境設定為 *c*。" -#: ../../library/decimal.rst:1020 +#: ../../library/decimal.rst:1012 msgid "" "You can also use the :keyword:`with` statement and the :func:`localcontext` " "function to temporarily change the active context." @@ -1667,7 +1667,7 @@ msgstr "" "你也可以使用 :keyword:`with` 陳述式和 :func:`localcontext` 函式來暫時變更作用" "中的情境。" -#: ../../library/decimal.rst:1025 +#: ../../library/decimal.rst:1017 msgid "" "Return a context manager that will set the current context for the active " "thread to a copy of *ctx* on entry to the with-statement and restore the " @@ -1679,7 +1679,7 @@ msgstr "" "*ctx* 的副本,並在退出 with 陳述式時恢復先前的情境。如果沒有指定情境,則使用" "目前情境的副本。*kwargs* 引數用於設定新情境的屬性。" -#: ../../library/decimal.rst:1031 +#: ../../library/decimal.rst:1023 msgid "" "For example, the following code sets the current decimal precision to 42 " "places, performs a calculation, and then automatically restores the previous " @@ -1688,7 +1688,7 @@ msgstr "" "例如,以下程式碼將目前的 decimal 精度設定為 42 位,執行計算,然後自動恢復先前" "的情境: ::" -#: ../../library/decimal.rst:1034 +#: ../../library/decimal.rst:1026 msgid "" "from decimal import localcontext\n" "\n" @@ -1704,11 +1704,11 @@ msgstr "" " s = calculate_something()\n" "s = +s # 將最終結果捨入回預設精度" -#: ../../library/decimal.rst:1041 +#: ../../library/decimal.rst:1033 msgid "Using keyword arguments, the code would be the following::" msgstr "使用關鍵字引數,程式碼如下: ::" -#: ../../library/decimal.rst:1043 +#: ../../library/decimal.rst:1035 msgid "" "from decimal import localcontext\n" "\n" @@ -1722,7 +1722,7 @@ msgstr "" " s = calculate_something()\n" "s = +s" -#: ../../library/decimal.rst:1049 +#: ../../library/decimal.rst:1041 msgid "" "Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:" "`Context` doesn't support. Raises either :exc:`TypeError` or :exc:" @@ -1732,13 +1732,13 @@ msgstr "" "如果 *kwargs* 為屬性提供了無效值,則引發 :exc:`TypeError` 或 :exc:" "`ValueError`。" -#: ../../library/decimal.rst:1053 +#: ../../library/decimal.rst:1045 msgid "" ":meth:`localcontext` now supports setting context attributes through the use " "of keyword arguments." msgstr ":meth:`localcontext` 現在支援透過關鍵字引數來設定 context 屬性。" -#: ../../library/decimal.rst:1058 +#: ../../library/decimal.rst:1050 msgid "" "Return a context object initialized to the proper values for one of the IEEE " "interchange formats. The argument must be a multiple of 32 and less than :" @@ -1747,7 +1747,7 @@ msgstr "" "回傳一個 context 物件,其值被初始化為某個 IEEE 交換格式的適當值。引數必須是 " "32 的倍數且小於 :const:`IEEE_CONTEXT_MAX_BITS`。" -#: ../../library/decimal.rst:1064 +#: ../../library/decimal.rst:1056 msgid "" "New contexts can also be created using the :class:`Context` constructor " "described below. In addition, the module provides three pre-made contexts:" @@ -1755,7 +1755,7 @@ msgstr "" "新的 context 也可以使用下面描述的 :class:`Context` 建構函式來建立。此外,該模" "組提供了三個預製的 context:" -#: ../../library/decimal.rst:1070 +#: ../../library/decimal.rst:1062 msgid "" "This is a standard context defined by the General Decimal Arithmetic " "Specification. Precision is set to nine. Rounding is set to :const:" @@ -1767,12 +1767,12 @@ msgstr "" "`ROUND_HALF_UP`。所有旗標都被清除。所有的 trap 都被啟用(視為例外),除了 :" "const:`Inexact`、:const:`Rounded` 和 :const:`Subnormal`。" -#: ../../library/decimal.rst:1076 +#: ../../library/decimal.rst:1068 msgid "" "Because many of the traps are enabled, this context is useful for debugging." msgstr "因為很多 trap 都被啟用,這個 context 對於除錯很有用。" -#: ../../library/decimal.rst:1081 +#: ../../library/decimal.rst:1073 msgid "" "This is a standard context defined by the General Decimal Arithmetic " "Specification. Precision is set to nine. Rounding is set to :const:" @@ -1783,7 +1783,7 @@ msgstr "" "`ROUND_HALF_EVEN`。所有旗標都被清除。沒有 trap 被啟用(因此在運算過程中不會引" "發例外)。" -#: ../../library/decimal.rst:1086 +#: ../../library/decimal.rst:1078 msgid "" "Because the traps are disabled, this context is useful for applications that " "prefer to have result value of ``NaN`` or ``Infinity`` instead of raising " @@ -1794,7 +1794,7 @@ msgstr "" "而不是引發例外的應用程式很有用。這讓應用程式在存在原本會中止程式的條件時也能" "完成執行。" -#: ../../library/decimal.rst:1094 +#: ../../library/decimal.rst:1086 msgid "" "This context is used by the :class:`Context` constructor as a prototype for " "new contexts. Changing a field (such a precision) has the effect of " @@ -1804,7 +1804,7 @@ msgstr "" "這個 context 被 :class:`Context` 建構函式用作新 context 的原型。改變一個欄位" "(例如精度)的效果是改變 :class:`Context` 建構函式建立的新 context 的預設值。" -#: ../../library/decimal.rst:1098 +#: ../../library/decimal.rst:1090 msgid "" "This context is most useful in multi-threaded environments. Changing one of " "the fields before threads are started has the effect of setting system-wide " @@ -1815,7 +1815,7 @@ msgstr "" "設定系統級預設值。不建議在執行緒啟動後改變欄位,因為這會需要執行緒同步來防止" "競爭條件。" -#: ../../library/decimal.rst:1103 +#: ../../library/decimal.rst:1095 msgid "" "In single threaded environments, it is preferable to not use this context at " "all. Instead, simply create contexts explicitly as described below." @@ -1823,7 +1823,7 @@ msgstr "" "在單執行緒環境中,最好完全不使用這個 context。取而代之,只需按下面描述的方式" "明確建立 context。" -#: ../../library/decimal.rst:1106 +#: ../../library/decimal.rst:1098 msgid "" "The default values are :attr:`Context.prec`\\ =\\ ``28``, :attr:`Context." "rounding`\\ =\\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:" @@ -1833,7 +1833,7 @@ msgstr "" "const:`ROUND_HALF_EVEN`,並啟用 :class:`Overflow`、:class:`InvalidOperation` " "和 :class:`DivisionByZero` 的 trap。" -#: ../../library/decimal.rst:1111 +#: ../../library/decimal.rst:1103 msgid "" "In addition to the three supplied contexts, new contexts can be created with " "the :class:`Context` constructor." @@ -1841,7 +1841,7 @@ msgstr "" "除了這三個提供的 context 之外,還可以使用 :class:`Context` 建構函式建立新的 " "context。" -#: ../../library/decimal.rst:1117 +#: ../../library/decimal.rst:1109 msgid "" "Creates a new context. If a field is not specified or is :const:`None`, the " "default values are copied from the :const:`DefaultContext`. If the *flags* " @@ -1851,7 +1851,7 @@ msgstr "" "`DefaultContext` 複製預設值。如果 *flags* 欄位未指定或為 :const:`None`,則清" "除所有旗標。" -#: ../../library/decimal.rst:1123 +#: ../../library/decimal.rst:1115 msgid "" "An integer in the range [``1``, :const:`MAX_PREC`] that sets the precision " "for arithmetic operations in the context." @@ -1859,18 +1859,18 @@ msgstr "" "在 [``1``, :const:`MAX_PREC`] 範圍內的整數,用於設定 context 中算術運算的精" "度。" -#: ../../library/decimal.rst:1128 +#: ../../library/decimal.rst:1120 msgid "One of the constants listed in the section `Rounding Modes`_." msgstr "`Rounding Modes`_ 段落中列出的常數之一。" -#: ../../library/decimal.rst:1133 +#: ../../library/decimal.rst:1125 msgid "" "Lists of any signals to be set. Generally, new contexts should only set " "traps and leave the flags clear." msgstr "" "要設定的任何訊號列表。一般來說,新 context 應該只設定 trap 並保持旗標清除。" -#: ../../library/decimal.rst:1139 +#: ../../library/decimal.rst:1131 msgid "" "Integers specifying the outer limits allowable for exponents. *Emin* must be " "in the range [:const:`MIN_EMIN`, ``0``], *Emax* in the range [``0``, :const:" @@ -1879,7 +1879,7 @@ msgstr "" "指定指數允許的外部限制的整數。*Emin* 必須在 [:const:`MIN_EMIN`、``0``] 範圍" "內,*Emax* 在 [``0``、:const:`MAX_EMAX`] 範圍內。" -#: ../../library/decimal.rst:1145 +#: ../../library/decimal.rst:1137 msgid "" "Either ``0`` or ``1`` (the default). If set to ``1``, exponents are printed " "with a capital ``E``; otherwise, a lowercase ``e`` is used: " @@ -1888,7 +1888,7 @@ msgstr "" "``0`` 或 ``1``\\(預設)。如果設定為 ``1``,指數用大寫 ``E`` 列印;否則,使用" "小寫 ``e``:``Decimal('6.02e+23')``。" -#: ../../library/decimal.rst:1151 +#: ../../library/decimal.rst:1143 msgid "" "Either ``0`` (the default) or ``1``. If set to ``1``, the exponent ``e`` of " "a :class:`Decimal` instance representable in this context is strictly " @@ -1907,7 +1907,7 @@ msgstr "" "話,大的正規數字會減少其指數並在其係數上添加相應數量的零,以符合指數約束;這" "保留了數字的值,但會失去有關有效尾隨零的資訊。例如: ::" -#: ../../library/decimal.rst:1162 +#: ../../library/decimal.rst:1154 msgid "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" @@ -1915,14 +1915,14 @@ msgstr "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" -#: ../../library/decimal.rst:1165 +#: ../../library/decimal.rst:1157 msgid "" "A *clamp* value of ``1`` allows compatibility with the fixed-width decimal " "interchange formats specified in IEEE 754." msgstr "" "*clamp* 值為 ``1`` 可以與 IEEE 754 中指定的固定寬度十進位交換格式相容。" -#: ../../library/decimal.rst:1168 +#: ../../library/decimal.rst:1160 msgid "" "The :class:`Context` class defines several general purpose methods as well " "as a large number of methods for doing arithmetic directly in a given " @@ -1942,23 +1942,23 @@ msgstr "" "`Context` 方法在接受 Decimal 實例的任何地方都接受 Python 整數(:class:`int` " "的實例)。" -#: ../../library/decimal.rst:1181 +#: ../../library/decimal.rst:1173 msgid "Resets all of the flags to ``0``." msgstr "將所有旗標重設為 ``0``。" -#: ../../library/decimal.rst:1185 +#: ../../library/decimal.rst:1177 msgid "Resets all of the traps to ``0``." msgstr "將所有 trap 重設為 ``0``。" -#: ../../library/decimal.rst:1191 +#: ../../library/decimal.rst:1183 msgid "Return a duplicate of the context." msgstr "回傳 context 的一個副本。" -#: ../../library/decimal.rst:1195 +#: ../../library/decimal.rst:1187 msgid "Return a copy of the Decimal instance num." msgstr "回傳 Decimal 實例 num 的副本。" -#: ../../library/decimal.rst:1199 +#: ../../library/decimal.rst:1191 msgid "" "Creates a new Decimal instance from *num* but using *self* as context. " "Unlike the :class:`Decimal` constructor, the context precision, rounding " @@ -1967,7 +1967,7 @@ msgstr "" "從 *num* 建立一個新的 Decimal 實例,但使用 *self* 作為 context。與 :class:" "`Decimal` 建構函式不同,context 精度、捨入方法、旗標和 trap 會套用於轉換。" -#: ../../library/decimal.rst:1203 +#: ../../library/decimal.rst:1195 msgid "" "This is useful because constants are often given to a greater precision than " "is needed by the application. Another benefit is that rounding immediately " @@ -1979,7 +1979,7 @@ msgstr "" "除超出當前精度的數字的意外影響。在以下範例中,使用未捨入的輸入意味著在總和中" "加零可能會改變結果:" -#: ../../library/decimal.rst:1209 +#: ../../library/decimal.rst:1201 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.4445') + Decimal('1.0023')\n" @@ -1993,7 +1993,7 @@ msgstr "" ">>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023')\n" "Decimal('4.44')" -#: ../../library/decimal.rst:1217 +#: ../../library/decimal.rst:1209 msgid "" "This method implements the to-number operation of the IBM specification. If " "the argument is a string, no leading or trailing whitespace or underscores " @@ -2002,7 +2002,7 @@ msgstr "" "此方法實作了 IBM 規格的 to-number 操作。如果引數是字串,則不允許前導或尾隨的" "空白字元或底線。" -#: ../../library/decimal.rst:1223 +#: ../../library/decimal.rst:1215 msgid "" "Creates a new Decimal instance from a float *f* but rounding using *self* as " "the context. Unlike the :meth:`Decimal.from_float` class method, the " @@ -2013,7 +2013,7 @@ msgstr "" "入。與 :meth:`Decimal.from_float` 類別方法不同,context 精度、捨入方法、旗標" "和 trap 會套用於轉換。" -#: ../../library/decimal.rst:1228 +#: ../../library/decimal.rst:1220 msgid "" ">>> context = Context(prec=5, rounding=ROUND_DOWN)\n" ">>> context.create_decimal_from_float(math.pi)\n" @@ -2033,7 +2033,7 @@ msgstr "" " ...\n" "decimal.Inexact: None" -#: ../../library/decimal.rst:1243 +#: ../../library/decimal.rst:1235 msgid "" "Returns a value equal to ``Emin - prec + 1`` which is the minimum exponent " "value for subnormal results. When underflow occurs, the exponent is set to :" @@ -2042,11 +2042,11 @@ msgstr "" "回傳等於 ``Emin - prec + 1`` 的值,這是次正規結果的最小指數值。當發生下溢時," "指數設定為 :const:`Etiny`。" -#: ../../library/decimal.rst:1249 +#: ../../library/decimal.rst:1241 msgid "Returns a value equal to ``Emax - prec + 1``." msgstr "回傳一個等於 ``Emax - prec + 1`` 的值。" -#: ../../library/decimal.rst:1251 +#: ../../library/decimal.rst:1243 msgid "" "The usual approach to working with decimals is to create :class:`Decimal` " "instances and then apply arithmetic operations which take place within the " @@ -2059,181 +2059,181 @@ msgstr "" "context 中進行算術運算。另一種方法是使用 context 方法在特定 context 中進行計" "算。這些方法與 :class:`Decimal` 類別的方法相似,在此僅簡要重述。" -#: ../../library/decimal.rst:1261 +#: ../../library/decimal.rst:1253 msgid "Returns the absolute value of *x*." msgstr "回傳 *x* 的絕對值。" -#: ../../library/decimal.rst:1266 +#: ../../library/decimal.rst:1258 msgid "Return the sum of *x* and *y*." msgstr "回傳 *x* 與 *y* 的和。" -#: ../../library/decimal.rst:1271 +#: ../../library/decimal.rst:1263 msgid "Returns the same Decimal object *x*." msgstr "回傳相同的 Decimal 物件 *x*。" -#: ../../library/decimal.rst:1276 +#: ../../library/decimal.rst:1268 msgid "Compares *x* and *y* numerically." msgstr "數值比較 *x* 和 *y*。" -#: ../../library/decimal.rst:1281 +#: ../../library/decimal.rst:1273 msgid "Compares the values of the two operands numerically." msgstr "數值比較兩個運算元的值。" -#: ../../library/decimal.rst:1286 +#: ../../library/decimal.rst:1278 msgid "Compares two operands using their abstract representation." msgstr "使用兩個運算元的抽象表示法進行比較。" -#: ../../library/decimal.rst:1291 +#: ../../library/decimal.rst:1283 msgid "" "Compares two operands using their abstract representation, ignoring sign." msgstr "使用兩個運算元的抽象表示法進行比較,忽略符號。" -#: ../../library/decimal.rst:1296 +#: ../../library/decimal.rst:1288 msgid "Returns a copy of *x* with the sign set to 0." msgstr "回傳 *x* 的副本,將符號設定為 0。" -#: ../../library/decimal.rst:1301 +#: ../../library/decimal.rst:1293 msgid "Returns a copy of *x* with the sign inverted." msgstr "回傳 *x* 的副本,將符號反轉。" -#: ../../library/decimal.rst:1306 +#: ../../library/decimal.rst:1298 msgid "Copies the sign from *y* to *x*." msgstr "將 *y* 的正負號複製到 *x*。" -#: ../../library/decimal.rst:1311 +#: ../../library/decimal.rst:1303 msgid "Return *x* divided by *y*." msgstr "回傳 *x* 除以 *y*。" -#: ../../library/decimal.rst:1316 +#: ../../library/decimal.rst:1308 msgid "Return *x* divided by *y*, truncated to an integer." msgstr "回傳 *x* 除以 *y*,截斷為整數。" -#: ../../library/decimal.rst:1321 +#: ../../library/decimal.rst:1313 msgid "Divides two numbers and returns the integer part of the result." msgstr "將兩個數相除並回傳結果的整數部分。" -#: ../../library/decimal.rst:1326 +#: ../../library/decimal.rst:1318 msgid "Returns ``e ** x``." msgstr "回傳 ``e ** x``。" -#: ../../library/decimal.rst:1331 +#: ../../library/decimal.rst:1323 msgid "Returns *x* multiplied by *y*, plus *z*." msgstr "回傳 *x* 乘以 *y*,再加上 *z*。" -#: ../../library/decimal.rst:1336 +#: ../../library/decimal.rst:1328 msgid "Returns ``True`` if *x* is canonical; otherwise returns ``False``." msgstr "如果 *x* 是標準形式則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1341 +#: ../../library/decimal.rst:1333 msgid "Returns ``True`` if *x* is finite; otherwise returns ``False``." msgstr "如果 *x* 是有限的則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1346 +#: ../../library/decimal.rst:1338 msgid "Returns ``True`` if *x* is infinite; otherwise returns ``False``." msgstr "如果 *x* 是無限大則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1351 +#: ../../library/decimal.rst:1343 msgid "Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``." msgstr "如果 *x* 是 qNaN 或 sNaN 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1356 +#: ../../library/decimal.rst:1348 msgid "" "Returns ``True`` if *x* is a normal number; otherwise returns ``False``." msgstr "" "如果 *x* 是正規數 (normal number) 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1361 +#: ../../library/decimal.rst:1353 msgid "Returns ``True`` if *x* is a quiet NaN; otherwise returns ``False``." msgstr "" "如果 *x* 是安靜型 NaN (quiet NaN) 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1366 +#: ../../library/decimal.rst:1358 msgid "Returns ``True`` if *x* is negative; otherwise returns ``False``." msgstr "如果 *x* 是負數則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1371 +#: ../../library/decimal.rst:1363 msgid "" "Returns ``True`` if *x* is a signaling NaN; otherwise returns ``False``." msgstr "" "如果 *x* 是訊號型 NaN (signaling NaN) 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1376 +#: ../../library/decimal.rst:1368 msgid "Returns ``True`` if *x* is subnormal; otherwise returns ``False``." msgstr "如果 *x* 是次正規數 (subnormal) 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1381 +#: ../../library/decimal.rst:1373 msgid "Returns ``True`` if *x* is a zero; otherwise returns ``False``." msgstr "如果 *x* 是零則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1386 +#: ../../library/decimal.rst:1378 msgid "Returns the natural (base e) logarithm of *x*." msgstr "回傳 *x* 的自然對數(以 e 為底)。" -#: ../../library/decimal.rst:1391 +#: ../../library/decimal.rst:1383 msgid "Returns the base 10 logarithm of *x*." msgstr "回傳 *x* 的以 10 為底的對數。" -#: ../../library/decimal.rst:1396 +#: ../../library/decimal.rst:1388 msgid "Returns the exponent of the magnitude of the operand's MSD." msgstr "回傳運算元最高有效位數(MSD)數值的指數。" -#: ../../library/decimal.rst:1401 +#: ../../library/decimal.rst:1393 msgid "Applies the logical operation *and* between each operand's digits." msgstr "將每個運算元的位數套用邏輯運算 *and*。" -#: ../../library/decimal.rst:1406 +#: ../../library/decimal.rst:1398 msgid "Invert all the digits in *x*." msgstr "反轉 *x* 中的所有數字。" -#: ../../library/decimal.rst:1411 +#: ../../library/decimal.rst:1403 msgid "Applies the logical operation *or* between each operand's digits." msgstr "在每個運算元的數字之間套用邏輯運算 *or*。" -#: ../../library/decimal.rst:1416 +#: ../../library/decimal.rst:1408 msgid "Applies the logical operation *xor* between each operand's digits." msgstr "在每個運算元的數字之間套用邏輯運算 *xor*。" -#: ../../library/decimal.rst:1421 +#: ../../library/decimal.rst:1413 msgid "Compares two values numerically and returns the maximum." msgstr "數值比較兩個值並回傳最大值。" -#: ../../library/decimal.rst:1426 ../../library/decimal.rst:1436 +#: ../../library/decimal.rst:1418 ../../library/decimal.rst:1428 msgid "Compares the values numerically with their sign ignored." msgstr "數值比較值,忽略其符號。" -#: ../../library/decimal.rst:1431 +#: ../../library/decimal.rst:1423 msgid "Compares two values numerically and returns the minimum." msgstr "數值比較兩個值並回傳最小值。" -#: ../../library/decimal.rst:1441 +#: ../../library/decimal.rst:1433 msgid "Minus corresponds to the unary prefix minus operator in Python." msgstr "Minus 對應於 Python 中的一元前綴減號運算子。" -#: ../../library/decimal.rst:1446 +#: ../../library/decimal.rst:1438 msgid "Return the product of *x* and *y*." msgstr "回傳 *x* 和 *y* 的乘積。" -#: ../../library/decimal.rst:1451 +#: ../../library/decimal.rst:1443 msgid "Returns the largest representable number smaller than *x*." msgstr "回傳小於 *x* 的最大可表示數字。" -#: ../../library/decimal.rst:1456 +#: ../../library/decimal.rst:1448 msgid "Returns the smallest representable number larger than *x*." msgstr "回傳大於 *x* 的最小可表示數字。" -#: ../../library/decimal.rst:1461 +#: ../../library/decimal.rst:1453 msgid "Returns the number closest to *x*, in direction towards *y*." msgstr "回傳最接近 *x* 的數字,方向指向 *y*。" -#: ../../library/decimal.rst:1466 +#: ../../library/decimal.rst:1458 msgid "Reduces *x* to its simplest form." msgstr "將 *x* 簡化為最簡形式。" -#: ../../library/decimal.rst:1471 +#: ../../library/decimal.rst:1463 msgid "Returns an indication of the class of *x*." msgstr "回傳 *x* 類別的指示。" -#: ../../library/decimal.rst:1476 +#: ../../library/decimal.rst:1468 msgid "" "Plus corresponds to the unary prefix plus operator in Python. This " "operation applies the context precision and rounding, so it is *not* an " @@ -2242,13 +2242,13 @@ msgstr "" "Plus 對應於 Python 中的一元前綴加號運算子。此運算會套用 context 精度和捨入," "因此它 *不是* 一個恆等運算。" -#: ../../library/decimal.rst:1483 +#: ../../library/decimal.rst:1475 msgid "Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given." msgstr "" "回傳 ``x`` 的 ``y`` 次方;如果有提供 ``modulo``,則回傳對 ``modulo`` 取模後的" "結果。" -#: ../../library/decimal.rst:1485 +#: ../../library/decimal.rst:1477 msgid "" "With two arguments, compute ``x**y``. If ``x`` is negative then ``y`` must " "be integral. The result will be inexact unless ``y`` is integral and the " @@ -2260,7 +2260,7 @@ msgstr "" "``y`` 是整數且結果是有限的且可以在「精度」位數中精確表示,否則結果將是不精確" "的。使用 context 的捨入模式。在 Python 版本中,結果總是正確捨入的。" -#: ../../library/decimal.rst:1491 +#: ../../library/decimal.rst:1483 msgid "" "``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if " "``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``." @@ -2268,7 +2268,7 @@ msgstr "" "``Decimal(0) ** Decimal(0)`` 會導致 ``InvalidOperation``,如果 " "``InvalidOperation`` 沒有被捕捉,則會產生 ``Decimal('NaN')``。" -#: ../../library/decimal.rst:1494 +#: ../../library/decimal.rst:1486 msgid "" "The C module computes :meth:`power` in terms of the correctly rounded :meth:" "`exp` and :meth:`ln` functions. The result is well-defined but only \"almost " @@ -2277,30 +2277,30 @@ msgstr "" "C 模組以正確捨入的 :meth:`exp` 和 :meth:`ln` 函式來計算 :meth:`power`。結果是" "明確定義的,但僅「幾乎總是正確捨入」。" -#: ../../library/decimal.rst:1499 +#: ../../library/decimal.rst:1491 msgid "" "With three arguments, compute ``(x**y) % modulo``. For the three argument " "form, the following restrictions on the arguments hold:" msgstr "" "使用三個引數計算 ``(x**y) % modulo``。對於三個引數的形式,引數有以下限制:" -#: ../../library/decimal.rst:1502 +#: ../../library/decimal.rst:1494 msgid "all three arguments must be integral" msgstr "所有三個引數必須是整數" -#: ../../library/decimal.rst:1503 +#: ../../library/decimal.rst:1495 msgid "``y`` must be nonnegative" msgstr "``y`` 必須是非負數" -#: ../../library/decimal.rst:1504 +#: ../../library/decimal.rst:1496 msgid "at least one of ``x`` or ``y`` must be nonzero" msgstr "``x`` 或 ``y`` 中至少一個必須是非零" -#: ../../library/decimal.rst:1505 +#: ../../library/decimal.rst:1497 msgid "``modulo`` must be nonzero and have at most 'precision' digits" msgstr "``modulo`` 必須是非零且最多有「精度」位數" -#: ../../library/decimal.rst:1507 +#: ../../library/decimal.rst:1499 msgid "" "The value resulting from ``Context.power(x, y, modulo)`` is equal to the " "value that would be obtained by computing ``(x**y) % modulo`` with unbounded " @@ -2312,25 +2312,25 @@ msgstr "" "modulo`` 所得到的值,但計算更加高效。結果的指數是零,無論 ``x``、``y`` 和 " "``modulo`` 的指數如何。結果總是精確的。" -#: ../../library/decimal.rst:1517 +#: ../../library/decimal.rst:1509 msgid "Returns a value equal to *x* (rounded), having the exponent of *y*." msgstr "回傳等於 *x*(捨入後)的值,具有 *y* 的指數。" -#: ../../library/decimal.rst:1522 +#: ../../library/decimal.rst:1514 msgid "Just returns 10, as this is Decimal, :)" msgstr "只回傳 10,因為這是 Decimal :)" -#: ../../library/decimal.rst:1527 +#: ../../library/decimal.rst:1519 msgid "Returns the remainder from integer division." msgstr "回傳整數除法的餘數。" -#: ../../library/decimal.rst:1529 +#: ../../library/decimal.rst:1521 msgid "" "The sign of the result, if non-zero, is the same as that of the original " "dividend." msgstr "結果的符號(如果非零)與原始被除數的符號相同。" -#: ../../library/decimal.rst:1535 +#: ../../library/decimal.rst:1527 msgid "" "Returns ``x - y * n``, where *n* is the integer nearest the exact value of " "``x / y`` (if the result is 0 then its sign will be the sign of *x*)." @@ -2338,95 +2338,103 @@ msgstr "" "回傳 ``x - y * n``,其中 *n* 是最接近 ``x / y`` 精確值的整數(如果結果是 0," "則其符號將是 *x* 的符號)。" -#: ../../library/decimal.rst:1541 +#: ../../library/decimal.rst:1533 msgid "Returns a rotated copy of *x*, *y* times." msgstr "回傳 *x* 的旋轉副本,旋轉 *y* 次。" -#: ../../library/decimal.rst:1546 +#: ../../library/decimal.rst:1538 msgid "Returns ``True`` if the two operands have the same exponent." msgstr "如果兩個運算元有相同的指數則回傳 ``True``。" -#: ../../library/decimal.rst:1551 +#: ../../library/decimal.rst:1543 msgid "Returns the first operand after adding the second value its exp." msgstr "回傳第一個運算元在加上第二個值的 exp 後的結果。" -#: ../../library/decimal.rst:1556 +#: ../../library/decimal.rst:1548 msgid "Returns a shifted copy of *x*, *y* times." msgstr "回傳 *x* 的移位副本,移位 *y* 次。" -#: ../../library/decimal.rst:1561 +#: ../../library/decimal.rst:1553 msgid "Square root of a non-negative number to context precision." msgstr "非負數在 context 精度下的平方根。" -#: ../../library/decimal.rst:1566 +#: ../../library/decimal.rst:1558 msgid "Return the difference between *x* and *y*." msgstr "回傳 *x* 和 *y* 的差。" -#: ../../library/decimal.rst:1580 +#: ../../library/decimal.rst:1572 msgid "Rounds to an integer." msgstr "捨入為整數。" -#: ../../library/decimal.rst:1585 +#: ../../library/decimal.rst:1577 msgid "Converts a number to a string using scientific notation." msgstr "使用科學記號法將數字轉換為字串。" -#: ../../library/decimal.rst:1592 +#: ../../library/decimal.rst:1584 msgid "Constants" msgstr "常數" -#: ../../library/decimal.rst:1594 +#: ../../library/decimal.rst:1588 msgid "" -"The constants in this section are only relevant for the C module. They are " -"also included in the pure Python version for compatibility." +"The highest version of the General Decimal Arithmetic Specification that " +"this implementation complies with. See https://speleotrove.com/decimal/" +"decarith.html for the specification." msgstr "" -"本節中的常數僅與 C 模組相關。為了相容性,它們也包含在純 Python 版本中。" +"此實作所遵循的一般十進位算術規範 (General Decimal Arithmetic Specification) " +"的最高版本。規範內容請參閱 https://speleotrove.com/decimal/decarith.html。" + +#: ../../library/decimal.rst:1595 +msgid "" +"The following constants are only relevant for the C module. They are also " +"included in the pure Python version for compatibility." +msgstr "以下常數僅與 C 模組相關。為了相容性,它們也包含在純 Python 版本中。" -#: ../../library/decimal.rst:1598 +#: ../../library/decimal.rst:1599 msgid "32-bit" msgstr "32 位元" -#: ../../library/decimal.rst:1598 +#: ../../library/decimal.rst:1599 msgid "64-bit" msgstr "64 位元" -#: ../../library/decimal.rst:1600 ../../library/decimal.rst:1602 +#: ../../library/decimal.rst:1601 ../../library/decimal.rst:1603 msgid "``425000000``" msgstr "``425000000``" -#: ../../library/decimal.rst:1600 ../../library/decimal.rst:1602 +#: ../../library/decimal.rst:1601 ../../library/decimal.rst:1603 msgid "``999999999999999999``" msgstr "``999999999999999999``" -#: ../../library/decimal.rst:1604 +#: ../../library/decimal.rst:1605 msgid "``-425000000``" msgstr "``-425000000``" -#: ../../library/decimal.rst:1604 +#: ../../library/decimal.rst:1605 msgid "``-999999999999999999``" msgstr "``-999999999999999999``" -#: ../../library/decimal.rst:1606 +#: ../../library/decimal.rst:1607 msgid "``-849999999``" msgstr "``-849999999``" -#: ../../library/decimal.rst:1606 +#: ../../library/decimal.rst:1607 msgid "``-1999999999999999997``" msgstr "``-1999999999999999997``" -#: ../../library/decimal.rst:1608 +#: ../../library/decimal.rst:1609 msgid "``256``" msgstr "``256``" -#: ../../library/decimal.rst:1608 +#: ../../library/decimal.rst:1609 msgid "``512``" msgstr "``512``" -#: ../../library/decimal.rst:1613 +#: ../../library/decimal.rst:1614 msgid "" "The value is ``True``. Deprecated, because Python now always has threads." msgstr "值是 ``True``。已棄用,因為 Python 現在總是有執行緒。" -#: ../../library/decimal.rst:1619 +#: ../../library/decimal.rst:1620 msgid "" "The default value is ``True``. If Python is :option:`configured using the --" "without-decimal-contextvar option <--without-decimal-contextvar>`, the C " @@ -2438,49 +2446,49 @@ msgstr "" "選項 <--without-decimal-contextvar>` 配置的,C 版本使用執行緒區域而非協程區" "域 context,且值為 ``False``。在某些巢狀 context 情境中這稍微快一些。" -#: ../../library/decimal.rst:1628 +#: ../../library/decimal.rst:1629 msgid "Rounding modes" msgstr "捨入模式" -#: ../../library/decimal.rst:1632 +#: ../../library/decimal.rst:1633 msgid "Round towards ``Infinity``." msgstr "向 ``Infinity`` 捨入。" -#: ../../library/decimal.rst:1636 +#: ../../library/decimal.rst:1637 msgid "Round towards zero." msgstr "向零捨入。" -#: ../../library/decimal.rst:1640 +#: ../../library/decimal.rst:1641 msgid "Round towards ``-Infinity``." msgstr "向 ``-Infinity`` 捨入。" -#: ../../library/decimal.rst:1644 +#: ../../library/decimal.rst:1645 msgid "Round to nearest with ties going towards zero." msgstr "捨入到最近值,平局時向零捨入。" -#: ../../library/decimal.rst:1648 +#: ../../library/decimal.rst:1649 msgid "Round to nearest with ties going to nearest even integer." msgstr "捨入到最近值,平局時向最近的偶數捨入。" -#: ../../library/decimal.rst:1652 +#: ../../library/decimal.rst:1653 msgid "Round to nearest with ties going away from zero." msgstr "捨入到最近值,平局時遠離零捨入。" -#: ../../library/decimal.rst:1656 +#: ../../library/decimal.rst:1657 msgid "Round away from zero." msgstr "遠離零捨入。" -#: ../../library/decimal.rst:1660 +#: ../../library/decimal.rst:1661 msgid "" "Round away from zero if last digit after rounding towards zero would have " "been 0 or 5; otherwise round towards zero." msgstr "如果向零捨入後的最後一位數字為 0 或 5,則遠離零捨入;否則向零捨入。" -#: ../../library/decimal.rst:1667 +#: ../../library/decimal.rst:1668 msgid "Signals" msgstr "訊號" -#: ../../library/decimal.rst:1669 +#: ../../library/decimal.rst:1670 msgid "" "Signals represent conditions that arise during computation. Each corresponds " "to one context flag and one context trap enabler." @@ -2488,7 +2496,7 @@ msgstr "" "訊號代表在計算過程中產生的條件。每個訊號對應一個情境旗標和一個情境陷阱啟用" "器。" -#: ../../library/decimal.rst:1672 +#: ../../library/decimal.rst:1673 msgid "" "The context flag is set whenever the condition is encountered. After the " "computation, flags may be checked for informational purposes (for instance, " @@ -2498,7 +2506,7 @@ msgstr "" "每當遇到條件時,情境旗標就會被設定。計算後,可以檢查旗標以獲取資訊(例如,確" "定計算是否精確)。檢查旗標後,請確保在開始下一次計算之前清除所有旗標。" -#: ../../library/decimal.rst:1677 +#: ../../library/decimal.rst:1678 msgid "" "If the context's trap enabler is set for the signal, then the condition " "causes a Python exception to be raised. For example, if the :class:" @@ -2509,11 +2517,11 @@ msgstr "" "設定了 :class:`DivisionByZero` 陷阱,那麼在遇到條件時會引發 :exc:" "`DivisionByZero` 例外。" -#: ../../library/decimal.rst:1685 +#: ../../library/decimal.rst:1686 msgid "Altered an exponent to fit representation constraints." msgstr "更改指數以符合表示限制。" -#: ../../library/decimal.rst:1687 +#: ../../library/decimal.rst:1688 msgid "" "Typically, clamping occurs when an exponent falls outside the context's :" "attr:`~Context.Emin` and :attr:`~Context.Emax` limits. If possible, the " @@ -2522,15 +2530,15 @@ msgstr "" "通常,當指數超出情境的 :attr:`~Context.Emin` 和 :attr:`~Context.Emax` 限制" "時,會發生夾制。如果可能的話,透過在係數中新增零來縮小指數以符合限制。" -#: ../../library/decimal.rst:1694 +#: ../../library/decimal.rst:1695 msgid "Base class for other signals and a subclass of :exc:`ArithmeticError`." msgstr "其他訊號的基底類別,也是 :exc:`ArithmeticError` 的子類別。" -#: ../../library/decimal.rst:1699 +#: ../../library/decimal.rst:1700 msgid "Signals the division of a non-infinite number by zero." msgstr "發出非無限數被零除的訊號。" -#: ../../library/decimal.rst:1701 +#: ../../library/decimal.rst:1702 msgid "" "Can occur with division, modulo division, or when raising a number to a " "negative power. If this signal is not trapped, returns ``Infinity`` or ``-" @@ -2539,11 +2547,11 @@ msgstr "" "可能發生在除法、模除法或將數字提升到負次方時。如果此訊號未被捕捉,回傳 " "``Infinity`` 或 ``-Infinity``,符號由計算的輸入決定。" -#: ../../library/decimal.rst:1708 +#: ../../library/decimal.rst:1709 msgid "Indicates that rounding occurred and the result is not exact." msgstr "指示發生了捨入且結果不精確。" -#: ../../library/decimal.rst:1710 +#: ../../library/decimal.rst:1711 msgid "" "Signals when non-zero digits were discarded during rounding. The rounded " "result is returned. The signal flag or trap is used to detect when results " @@ -2552,18 +2560,18 @@ msgstr "" "當捨入過程中丟棄非零數字時發出訊號。回傳捨入結果。訊號旗標或陷阱用於檢測結果" "何時不精確。" -#: ../../library/decimal.rst:1717 +#: ../../library/decimal.rst:1718 msgid "An invalid operation was performed." msgstr "執行了無效的運算。" -#: ../../library/decimal.rst:1719 +#: ../../library/decimal.rst:1720 msgid "" "Indicates that an operation was requested that does not make sense. If not " "trapped, returns ``NaN``. Possible causes include::" msgstr "" "指示請求了不合理的運算。如果未被捕捉,回傳 ``NaN``。可能的原因包括: ::" -#: ../../library/decimal.rst:1722 +#: ../../library/decimal.rst:1723 msgid "" "Infinity - Infinity\n" "0 * Infinity\n" @@ -2585,11 +2593,11 @@ msgstr "" "x ** (non-integer)\n" "x ** Infinity" -#: ../../library/decimal.rst:1735 +#: ../../library/decimal.rst:1736 msgid "Numerical overflow." msgstr "數值溢位。" -#: ../../library/decimal.rst:1737 +#: ../../library/decimal.rst:1738 msgid "" "Indicates the exponent is larger than :attr:`Context.Emax` after rounding " "has occurred. If not trapped, the result depends on the rounding mode, " @@ -2601,11 +2609,11 @@ msgstr "" "式,要麼向內拉到最大可表示的有限數,要麼向外捨入到 ``Infinity``。在任何情況" "下,:class:`Inexact` 和 :class:`Rounded` 也會發出訊號。" -#: ../../library/decimal.rst:1746 +#: ../../library/decimal.rst:1747 msgid "Rounding occurred though possibly no information was lost." msgstr "發生了捨入,但可能沒有遺失資訊。" -#: ../../library/decimal.rst:1748 +#: ../../library/decimal.rst:1749 msgid "" "Signaled whenever rounding discards digits; even if those digits are zero " "(such as rounding ``5.00`` to ``5.0``). If not trapped, returns the result " @@ -2614,22 +2622,22 @@ msgstr "" "當捨入丟棄數字時發出訊號;即使這些數字是零(例如將 ``5.00`` 捨入為 " "``5.0``)。如果沒有被捕捉,則回傳不變的結果。此訊號用於檢測有效數字的遺失。" -#: ../../library/decimal.rst:1756 +#: ../../library/decimal.rst:1757 msgid "Exponent was lower than :attr:`~Context.Emin` prior to rounding." msgstr "在捨入之前指數低於 :attr:`~Context.Emin`。" -#: ../../library/decimal.rst:1758 +#: ../../library/decimal.rst:1759 msgid "" "Occurs when an operation result is subnormal (the exponent is too small). If " "not trapped, returns the result unchanged." msgstr "" "當運算結果是次正規(指數太小)時發生。如果沒有被捕捉,則回傳不變的結果。" -#: ../../library/decimal.rst:1764 +#: ../../library/decimal.rst:1765 msgid "Numerical underflow with result rounded to zero." msgstr "數值下溢,結果捨入為零。" -#: ../../library/decimal.rst:1766 +#: ../../library/decimal.rst:1767 msgid "" "Occurs when a subnormal result is pushed to zero by rounding. :class:" "`Inexact` and :class:`Subnormal` are also signaled." @@ -2637,11 +2645,11 @@ msgstr "" "當次正規結果被捨入推向零時發生。:class:`Inexact` 和 :class:`Subnormal` 也會發" "出訊號。" -#: ../../library/decimal.rst:1772 +#: ../../library/decimal.rst:1773 msgid "Enable stricter semantics for mixing floats and Decimals." msgstr "啟用混合 float 和 Decimal 的更嚴格語意。" -#: ../../library/decimal.rst:1774 +#: ../../library/decimal.rst:1775 msgid "" "If the signal is not trapped (default), mixing floats and Decimals is " "permitted in the :class:`~decimal.Decimal` constructor, :meth:`~decimal." @@ -2658,7 +2666,7 @@ msgstr "" "from_float` 或 :meth:`~decimal.Context.create_decimal_from_float` 的明確轉換" "不會設定標誌。" -#: ../../library/decimal.rst:1782 +#: ../../library/decimal.rst:1783 msgid "" "Otherwise (the signal is trapped), only equality comparisons and explicit " "conversions are silent. All other mixed operations raise :exc:" @@ -2667,11 +2675,11 @@ msgstr "" "否則(訊號被捕捉),只有相等比較和明確轉換是安靜的。所有其他混合運算都會引" "發 :exc:`FloatOperation`。" -#: ../../library/decimal.rst:1786 +#: ../../library/decimal.rst:1787 msgid "The following table summarizes the hierarchy of signals::" msgstr "以下表格總結了訊號的階層結構: ::" -#: ../../library/decimal.rst:1788 +#: ../../library/decimal.rst:1789 msgid "" "exceptions.ArithmeticError(exceptions.Exception)\n" " DecimalException\n" @@ -2697,15 +2705,15 @@ msgstr "" " Subnormal\n" " FloatOperation(DecimalException, exceptions.TypeError)" -#: ../../library/decimal.rst:1807 +#: ../../library/decimal.rst:1808 msgid "Floating-point notes" msgstr "浮點數注意事項" -#: ../../library/decimal.rst:1811 +#: ../../library/decimal.rst:1812 msgid "Mitigating round-off error with increased precision" msgstr "透過增加精度來減輕捨入誤差" -#: ../../library/decimal.rst:1813 +#: ../../library/decimal.rst:1814 msgid "" "The use of decimal floating point eliminates decimal representation error " "(making it possible to represent ``0.1`` exactly); however, some operations " @@ -2715,7 +2723,7 @@ msgstr "" "使用十進位浮點數消除了十進位表示誤差(使得可以精確表示 ``0.1``);然而,當非" "零數字超過固定精度時,某些運算仍然可能產生捨入誤差。" -#: ../../library/decimal.rst:1817 +#: ../../library/decimal.rst:1818 msgid "" "The effects of round-off error can be amplified by the addition or " "subtraction of nearly offsetting quantities resulting in loss of " @@ -2727,7 +2735,7 @@ msgstr "" "失。Knuth 提供了兩個教學範例,其中精度不足的捨入浮點運算導致加法的結合律和分" "配律失效:" -#: ../../library/decimal.rst:1823 +#: ../../library/decimal.rst:1824 msgid "" "# Examples from Seminumerical Algorithms, Section 4.2.2.\n" ">>> from decimal import Decimal, getcontext\n" @@ -2761,7 +2769,7 @@ msgstr "" ">>> u * (v+w)\n" "Decimal('0.0060000')" -#: ../../library/decimal.rst:1841 +#: ../../library/decimal.rst:1842 msgid "" "The :mod:`!decimal` module makes it possible to restore the identities by " "expanding the precision sufficiently to avoid loss of significance:" @@ -2769,7 +2777,7 @@ msgstr "" ":mod:`!decimal` 模組使得透過充分擴展精度來避免有效位數損失,從而恢復恆等式成" "為可能:" -#: ../../library/decimal.rst:1844 +#: ../../library/decimal.rst:1845 msgid "" ">>> getcontext().prec = 20\n" ">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" @@ -2797,11 +2805,11 @@ msgstr "" ">>> u * (v+w)\n" "Decimal('0.0060000')" -#: ../../library/decimal.rst:1861 +#: ../../library/decimal.rst:1862 msgid "Special values" msgstr "特殊值" -#: ../../library/decimal.rst:1863 +#: ../../library/decimal.rst:1864 msgid "" "The number system for the :mod:`!decimal` module provides special values " "including ``NaN``, ``sNaN``, ``-Infinity``, ``Infinity``, and two zeros, " @@ -2810,7 +2818,7 @@ msgstr "" ":mod:`!decimal` 模組的數字系統提供特殊值,包括 ``NaN``、``sNaN``、``-" "Infinity``、``Infinity`` 以及兩個零 ``+0`` 和 ``-0``。" -#: ../../library/decimal.rst:1867 +#: ../../library/decimal.rst:1868 msgid "" "Infinities can be constructed directly with: ``Decimal('Infinity')``. Also, " "they can arise from dividing by zero when the :exc:`DivisionByZero` signal " @@ -2822,7 +2830,7 @@ msgstr "" "`DivisionByZero` 訊號未被捕捉時,它們可能來自被零除。同樣地,當 :exc:" "`Overflow` 訊號未被捕捉時,無窮大可能來自超出最大可表示數字限制的捨入。" -#: ../../library/decimal.rst:1872 +#: ../../library/decimal.rst:1873 msgid "" "The infinities are signed (affine) and can be used in arithmetic operations " "where they get treated as very large, indeterminate numbers. For instance, " @@ -2831,7 +2839,7 @@ msgstr "" "無窮大是有符號的(仿射)並且可以用於算術運算,在那裡它們被視為非常大的不確定" "數字。例如,將常數加到無窮大會得到另一個無限結果。" -#: ../../library/decimal.rst:1876 +#: ../../library/decimal.rst:1877 msgid "" "Some operations are indeterminate and return ``NaN``, or if the :exc:" "`InvalidOperation` signal is trapped, raise an exception. For example, " @@ -2847,7 +2855,7 @@ msgstr "" "對於偶爾有缺失輸入的一系列計算很有用——它允許計算繼續進行,同時將特定結果標記" "為無效。" -#: ../../library/decimal.rst:1884 +#: ../../library/decimal.rst:1885 msgid "" "A variant is ``sNaN`` which signals rather than remaining quiet after every " "operation. This is a useful return value when an invalid result needs to " @@ -2856,7 +2864,7 @@ msgstr "" "一個變體是 ``sNaN``,它在每次運算後發出訊號而不是保持安靜。當無效結果需要中斷" "計算進行特殊處理時,這是一個有用的回傳值。" -#: ../../library/decimal.rst:1888 +#: ../../library/decimal.rst:1889 msgid "" "The behavior of Python's comparison operators can be a little surprising " "where a ``NaN`` is involved. A test for equality where one of the operands " @@ -2882,7 +2890,7 @@ msgstr "" "為確保嚴格符合標準,請改用 :meth:`~Decimal.compare` 和 :meth:`~Decimal." "compare_signal` 方法。" -#: ../../library/decimal.rst:1901 +#: ../../library/decimal.rst:1902 msgid "" "The signed zeros can result from calculations that underflow. They keep the " "sign that would have resulted if the calculation had been carried out to " @@ -2892,7 +2900,7 @@ msgstr "" "帶符號的零可能來自下溢計算。它們保持如果計算以更高精度執行所會產生的符號。由" "於它們的大小是零,正零和負零都被視為相等,它們的符號是資訊性的。" -#: ../../library/decimal.rst:1906 +#: ../../library/decimal.rst:1907 msgid "" "In addition to the two signed zeros which are distinct yet equal, there are " "various representations of zero with differing precisions yet equivalent in " @@ -2904,11 +2912,11 @@ msgstr "" "相等。這需要一點時間來適應。對於習慣於標準化浮點表示的眼睛來說,以下計算回傳" "等於零的值並不立即明顯:" -#: ../../library/decimal.rst:1921 +#: ../../library/decimal.rst:1922 msgid "Working with threads" msgstr "與執行緒協作" -#: ../../library/decimal.rst:1923 +#: ../../library/decimal.rst:1924 msgid "" "The :func:`getcontext` function accesses a different :class:`Context` object " "for each thread. Having separate thread contexts means that threads may " @@ -2919,13 +2927,13 @@ msgstr "" "的執行緒情境意味著執行緒可以進行變更(如 ``getcontext().prec=10``)而不會干擾" "其他執行緒。" -#: ../../library/decimal.rst:1927 +#: ../../library/decimal.rst:1928 msgid "" "Likewise, the :func:`setcontext` function automatically assigns its target " "to the current thread." msgstr "同樣地,:func:`setcontext` 函式會自動將其目標指派給目前執行緒。" -#: ../../library/decimal.rst:1930 +#: ../../library/decimal.rst:1931 msgid "" "If :func:`setcontext` has not been called before :func:`getcontext`, then :" "func:`getcontext` will automatically create a new context for use in the " @@ -2936,7 +2944,7 @@ msgstr "" "`getcontext` 會自動建立新的 context 供目前執行緒使用。新的 context 物件的預設" "值取自 :data:`decimal.DefaultContext` 物件。" -#: ../../library/decimal.rst:1935 +#: ../../library/decimal.rst:1936 msgid "" "The :data:`sys.flags.thread_inherit_context` flag affects the context for " "new threads. If the flag is false, new threads will start with an empty " @@ -2951,7 +2959,7 @@ msgstr "" "設值。如果該旗標為 true,新執行緒會以呼叫 :meth:`threading.Thread.start` 的執" "行緒的 context 副本啟動。" -#: ../../library/decimal.rst:1942 +#: ../../library/decimal.rst:1943 msgid "" "To control the defaults so that each thread will use the same values " "throughout the application, directly modify the *DefaultContext* object. " @@ -2962,7 +2970,7 @@ msgstr "" "*DefaultContext* 物件。這應該在任何執行緒啟動\\ *之前*\\ 完成,這樣執行緒呼" "叫 :func:`getcontext` 時就不會有競爭條件。例如: ::" -#: ../../library/decimal.rst:1947 +#: ../../library/decimal.rst:1948 msgid "" "# Set applicationwide defaults for all threads about to be launched\n" "DefaultContext.prec = 12\n" @@ -2990,18 +2998,18 @@ msgstr "" "t3.start()\n" " . . ." -#: ../../library/decimal.rst:1966 +#: ../../library/decimal.rst:1967 msgid "Recipes" msgstr "實用範例" -#: ../../library/decimal.rst:1968 +#: ../../library/decimal.rst:1969 msgid "" "Here are a few recipes that serve as utility functions and that demonstrate " "ways to work with the :class:`Decimal` class::" msgstr "" "以下是一些實用範例,作為工具函式並展示與 :class:`Decimal` 類別協作的方法: ::" -#: ../../library/decimal.rst:1971 +#: ../../library/decimal.rst:1972 msgid "" "def moneyfmt(value, places=2, curr='', sep=',', dp='.',\n" " pos='', neg='-', trailneg=''):\n" @@ -3294,11 +3302,11 @@ msgstr "" " getcontext().prec -= 2\n" " return +s" -#: ../../library/decimal.rst:2123 +#: ../../library/decimal.rst:2124 msgid "Decimal FAQ" msgstr "Decimal 常見問題" -#: ../../library/decimal.rst:2125 +#: ../../library/decimal.rst:2126 msgid "" "Q: It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way " "to minimize typing when using the interactive interpreter?" @@ -3306,11 +3314,11 @@ msgstr "" "問:輸入 ``decimal.Decimal('1234.5')`` 很麻煩。在使用互動式直譯器時,有沒有辦" "法減少輸入?" -#: ../../library/decimal.rst:2128 +#: ../../library/decimal.rst:2129 msgid "A: Some users abbreviate the constructor to just a single letter:" msgstr "答:有些使用者會將建構式縮寫為單一字母:" -#: ../../library/decimal.rst:2134 +#: ../../library/decimal.rst:2135 msgid "" "Q: In a fixed-point application with two decimal places, some inputs have " "many places and need to be rounded. Others are not supposed to have excess " @@ -3319,7 +3327,7 @@ msgstr "" "問:在一個有兩位小數的定點應用程式中,有些輸入有很多位數需要被捨入。其他輸入" "不應該有多餘的位數,需要被驗證。應該使用什麼方法?" -#: ../../library/decimal.rst:2138 +#: ../../library/decimal.rst:2139 msgid "" "A: The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal " "places. If the :const:`Inexact` trap is set, it is also useful for " @@ -3328,13 +3336,13 @@ msgstr "" "答::meth:`~Decimal.quantize` 方法會捨入到固定的小數位數。如果設定了 :const:" "`Inexact` 陷阱,它也可用於驗證:" -#: ../../library/decimal.rst:2156 +#: ../../library/decimal.rst:2157 msgid "" "Q: Once I have valid two place inputs, how do I maintain that invariant " "throughout an application?" msgstr "問:一旦我有了有效的兩位小數輸入,如何在整個應用程式中維持這個不變式?" -#: ../../library/decimal.rst:2159 +#: ../../library/decimal.rst:2160 msgid "" "A: Some operations like addition, subtraction, and multiplication by an " "integer will automatically preserve fixed point. Others operations, like " @@ -3344,14 +3352,14 @@ msgstr "" "答:某些運算如加法、減法和整數乘法會自動保留定點。其他運算,例如除法和非整數" "乘法,會改變小數位數,需要接著執行 :meth:`~Decimal.quantize` 步驟:" -#: ../../library/decimal.rst:2177 +#: ../../library/decimal.rst:2178 msgid "" "In developing fixed-point applications, it is convenient to define functions " "to handle the :meth:`~Decimal.quantize` step:" msgstr "" "在開發定點應用程式時,定義函式來處理 :meth:`~Decimal.quantize` 步驟很方便:" -#: ../../library/decimal.rst:2191 +#: ../../library/decimal.rst:2192 msgid "" "Q: There are many ways to express the same value. The numbers ``200``, " "``200.000``, ``2E2``, and ``.02E+4`` all have the same value at various " @@ -3362,17 +3370,17 @@ msgstr "" "``.02E+4`` 在不同精度下都有相同的值。有沒有辦法將它們轉換為單一可識別的標準" "值?" -#: ../../library/decimal.rst:2196 +#: ../../library/decimal.rst:2197 msgid "" "A: The :meth:`~Decimal.normalize` method maps all equivalent values to a " "single representative:" msgstr "答::meth:`~Decimal.normalize` 方法會將所有等價的值對映到單一代表值:" -#: ../../library/decimal.rst:2203 +#: ../../library/decimal.rst:2204 msgid "Q: When does rounding occur in a computation?" msgstr "問:在計算中何時會發生捨入?" -#: ../../library/decimal.rst:2205 +#: ../../library/decimal.rst:2206 msgid "" "A: It occurs *after* the computation. The philosophy of the decimal " "specification is that numbers are considered exact and are created " @@ -3386,7 +3394,7 @@ msgstr "" "確的輸入進行處理,然後捨入(或其他 context 運算)被套用到計算的\\ *結果*\\ " "上: ::" -#: ../../library/decimal.rst:2212 +#: ../../library/decimal.rst:2213 msgid "" ">>> getcontext().prec = 5\n" ">>> pi = Decimal('3.1415926535') # More than 5 digits\n" @@ -3410,13 +3418,13 @@ msgstr "" ">>> pi + 0 - Decimal('0.00005'). # 中間值被捨入\n" "Decimal('3.1416')" -#: ../../library/decimal.rst:2223 +#: ../../library/decimal.rst:2224 msgid "" "Q: Some decimal values always print with exponential notation. Is there a " "way to get a non-exponential representation?" msgstr "問:有些 decimal 值總是以指數表示法印出。有沒有辦法得到非指數表示法?" -#: ../../library/decimal.rst:2226 +#: ../../library/decimal.rst:2227 msgid "" "A: For some values, exponential notation is the only way to express the " "number of significant places in the coefficient. For example, expressing " @@ -3426,7 +3434,7 @@ msgstr "" "答:對於某些值,指數表示法是表達係數中有效位數的唯一方式。例如,將 " "``5.0E+3`` 表示為 ``5000`` 保持了值不變,但無法顯示原始值的兩位有效性。" -#: ../../library/decimal.rst:2231 +#: ../../library/decimal.rst:2232 msgid "" "If an application does not care about tracking significance, it is easy to " "remove the exponent and trailing zeroes, losing significance, but keeping " @@ -3435,11 +3443,11 @@ msgstr "" "如果應用程式不關心追蹤有效性,很容易移除指數和尾隨零,遺失有效性,但保持值不" "變:" -#: ../../library/decimal.rst:2241 +#: ../../library/decimal.rst:2242 msgid "Q: Is there a way to convert a regular float to a :class:`Decimal`?" msgstr "問:有沒有辦法將一般的 float 轉換為 :class:`Decimal`?" -#: ../../library/decimal.rst:2243 +#: ../../library/decimal.rst:2244 msgid "" "A: Yes, any binary floating-point number can be exactly expressed as a " "Decimal though an exact conversion may take more precision than intuition " @@ -3448,7 +3456,7 @@ msgstr "" "答:是的,任何二進位浮點數都可以精確地表示為 Decimal,儘管精確轉換可能需要比" "直覺所預期的更高精度:" -#: ../../library/decimal.rst:2247 +#: ../../library/decimal.rst:2248 msgid "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" @@ -3456,14 +3464,14 @@ msgstr "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" -#: ../../library/decimal.rst:2252 +#: ../../library/decimal.rst:2253 msgid "" "Q: Within a complex calculation, how can I make sure that I haven't gotten a " "spurious result because of insufficient precision or rounding anomalies." msgstr "" "問:在複雜計算中,如何確保我沒有因為精度不足或捨入異常而得到虛假的結果?" -#: ../../library/decimal.rst:2255 +#: ../../library/decimal.rst:2256 msgid "" "A: The decimal module makes it easy to test results. A best practice is to " "re-run calculations using greater precision and with various rounding modes. " @@ -3474,7 +3482,7 @@ msgstr "" "新執行計算。結果差異很大表示精度不足、捨入模式問題、病態輸入或數值不穩定的演" "算法。" -#: ../../library/decimal.rst:2260 +#: ../../library/decimal.rst:2261 msgid "" "Q: I noticed that context precision is applied to the results of operations " "but not to the inputs. Is there anything to watch out for when mixing " @@ -3483,7 +3491,7 @@ msgstr "" "問:我注意到 context 精度被套用到運算的結果上,但不套用到輸入上。在混合不同精" "度的值時,有什麼需要注意的嗎?" -#: ../../library/decimal.rst:2264 +#: ../../library/decimal.rst:2265 msgid "" "A: Yes. The principle is that all values are considered to be exact and so " "is the arithmetic on those values. Only the results are rounded. The " @@ -3495,7 +3503,7 @@ msgstr "" "入。對於輸入的好處是「你輸入什麼就得到什麼」。缺點是如果你忘記輸入沒有被捨" "入,結果可能看起來很奇怪:" -#: ../../library/decimal.rst:2269 +#: ../../library/decimal.rst:2270 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.104') + Decimal('2.104')\n" @@ -3509,13 +3517,13 @@ msgstr "" ">>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104')\n" "Decimal('5.20')" -#: ../../library/decimal.rst:2277 +#: ../../library/decimal.rst:2278 msgid "" "The solution is either to increase precision or to force rounding of inputs " "using the unary plus operation:" msgstr "解決方案是增加精度或使用一元加號運算強制輸入捨入:" -#: ../../library/decimal.rst:2280 +#: ../../library/decimal.rst:2281 msgid "" ">>> getcontext().prec = 3\n" ">>> +Decimal('1.23456789') # unary plus triggers rounding\n" @@ -3525,17 +3533,17 @@ msgstr "" ">>> +Decimal('1.23456789') # 一元正號觸發捨入\n" "Decimal('1.23')" -#: ../../library/decimal.rst:2286 +#: ../../library/decimal.rst:2287 msgid "" "Alternatively, inputs can be rounded upon creation using the :meth:`Context." "create_decimal` method:" msgstr "或者,可以使用 :meth:`Context.create_decimal` 方法在建立時將輸入捨入:" -#: ../../library/decimal.rst:2292 +#: ../../library/decimal.rst:2293 msgid "Q: Is the CPython implementation fast for large numbers?" msgstr "問:CPython 實作對大數運算快嗎?" -#: ../../library/decimal.rst:2294 +#: ../../library/decimal.rst:2295 msgid "" "A: Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of " "the decimal module integrate the high speed `libmpdec `_\\ 。" -#: ../../library/decimal.rst:2304 +#: ../../library/decimal.rst:2305 msgid "" "The context must be adapted for exact arbitrary precision arithmetic. :attr:" "`~Context.Emin` and :attr:`~Context.Emax` should always be set to the " @@ -3566,14 +3574,14 @@ msgstr "" "Emax` 應該始終設定為最大值,:attr:`~Context.clamp` 應該始終為 0(預設)。設" "定 :attr:`~Context.prec` 需要一些小心。" -#: ../../library/decimal.rst:2308 +#: ../../library/decimal.rst:2309 msgid "" "The easiest approach for trying out bignum arithmetic is to use the maximum " "value for :attr:`~Context.prec` as well [#]_::" msgstr "" "嘗試大數運算的最簡單方法是同時使用 :attr:`~Context.prec` 的最大值 [#]_: ::" -#: ../../library/decimal.rst:2311 +#: ../../library/decimal.rst:2312 msgid "" ">>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))\n" ">>> x = Decimal(2) ** 256\n" @@ -3585,7 +3593,7 @@ msgstr "" ">>> x / 128\n" "Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')" -#: ../../library/decimal.rst:2317 +#: ../../library/decimal.rst:2318 msgid "" "For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms " "and the available memory will be insufficient::" @@ -3593,7 +3601,7 @@ msgstr "" "對於不精確的結果,:const:`MAX_PREC` 在 64 位元平台上太大了,可用記憶體將不" "足: ::" -#: ../../library/decimal.rst:2320 +#: ../../library/decimal.rst:2321 msgid "" ">>> Decimal(1) / 3\n" "Traceback (most recent call last):\n" @@ -3605,7 +3613,7 @@ msgstr "" " File \"\", line 1, in \n" "MemoryError" -#: ../../library/decimal.rst:2325 +#: ../../library/decimal.rst:2326 msgid "" "On systems with overallocation (e.g. Linux), a more sophisticated approach " "is to adjust :attr:`~Context.prec` to the amount of available RAM. Suppose " @@ -3616,7 +3624,7 @@ msgstr "" "調整為可用 RAM 的數量。假設你有 8GB 的 RAM,並且預期 10 個同時操作數,每個最" "多使用 500MB: ::" -#: ../../library/decimal.rst:2329 +#: ../../library/decimal.rst:2330 msgid "" ">>> import sys\n" ">>>\n" @@ -3659,7 +3667,7 @@ msgstr "" " File \"\", line 1, in \n" " decimal.Inexact: []" -#: ../../library/decimal.rst:2349 +#: ../../library/decimal.rst:2350 msgid "" "In general (and especially on systems without overallocation), it is " "recommended to estimate even tighter bounds and set the :attr:`Inexact` trap " @@ -3668,7 +3676,7 @@ msgstr "" "一般來說(特別是在沒有過度分配的系統上),建議估算更緊密的界限並設定 :attr:" "`Inexact` trap,如果所有計算都預期是精確的。" -#: ../../library/decimal.rst:2358 +#: ../../library/decimal.rst:2359 msgid "" "This approach now works for all exact results except for non-integer powers." msgstr "這個方法現在對所有精確結果都有效,除了非整數冪次。" diff --git a/library/difflib.po b/library/difflib.po index 3396aa22e7a..69e77827f56 100644 --- a/library/difflib.po +++ b/library/difflib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-25 00:10+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!difflib` --- Helpers for computing deltas" msgstr ":mod:`!difflib` --- 計算差異的輔助工具" -#: ../../library/difflib.rst:11 +#: ../../library/difflib.rst:7 msgid "**Source code:** :source:`Lib/difflib.py`" msgstr "**原始碼:**\\ :source:`Lib/difflib.py`" -#: ../../library/difflib.rst:20 +#: ../../library/difflib.rst:16 msgid "" "This module provides classes and functions for comparing sequences. Most of " "them compare sequences of text lines (for example lists of strings, or :term:" @@ -35,7 +35,7 @@ msgid "" "` and :manpage:`git diff `." msgstr "" -#: ../../library/difflib.rst:28 +#: ../../library/difflib.rst:24 msgid "" "Comparisons are done using a matching algorithm implemented in :class:" "`SequenceMatcher` -- a flexible class for comparing pairs of sequences of " @@ -43,18 +43,18 @@ msgid "" "`hashable`." msgstr "" -#: ../../library/difflib.rst:37 +#: ../../library/difflib.rst:33 msgid "Junk heuristic" msgstr "" -#: ../../library/difflib.rst:39 +#: ../../library/difflib.rst:35 msgid "" ":mod:`!difflib` uses a :dfn:`junk` heuristic: some items are deemed to be :" "dfn:`junk`, and ignored when searching for similarities. Ideally, these are " "uninteresting or common items, such as blank lines or whitespace." msgstr "" -#: ../../library/difflib.rst:44 +#: ../../library/difflib.rst:40 msgid "" "This heuristic can speed the algorithm up (because it reduces the number of " "possible combinations) and it can produce results that are more " @@ -62,26 +62,26 @@ msgid "" "also cause pathological cases:" msgstr "" -#: ../../library/difflib.rst:49 +#: ../../library/difflib.rst:45 msgid "" "Inappropriately chosen junk items can cause an unexpectedly **large** (but " "still correct) result." msgstr "" -#: ../../library/difflib.rst:51 +#: ../../library/difflib.rst:47 msgid "" "The default heuristic is **asymmetric**: only the second sequence is " "inspected when determining what is considered junk, so comparing A to B can " "give different results than comparing B to A and reversing the result." msgstr "" -#: ../../library/difflib.rst:55 +#: ../../library/difflib.rst:51 msgid "" "By default, if the second input sequence is at least 200 items long, items " "that account for more than 1% it are considered *junk*." msgstr "" -#: ../../library/difflib.rst:58 +#: ../../library/difflib.rst:54 msgid "" "Depending on your data, you should consider turning this heuristic off " "(setting :class:`~difflib.SequenceMatcher`'s *autojunk* argument to " @@ -89,11 +89,11 @@ msgid "" "ref:`predefined functions `)." msgstr "" -#: ../../library/difflib.rst:65 +#: ../../library/difflib.rst:61 msgid "The :mod:`!difflib` algorithm" msgstr "" -#: ../../library/difflib.rst:67 +#: ../../library/difflib.rst:63 msgid "" "The algorithm used in :class:`SequenceMatcher` predates, and is a little " "fancier than, an algorithm published in the late 1980s by Ratcliff and " @@ -103,30 +103,30 @@ msgid "" "of the matching subsequence." msgstr "" -#: ../../library/difflib.rst:76 +#: ../../library/difflib.rst:72 msgid "" "`Pattern Matching: The Gestalt Approach `_" msgstr "" -#: ../../library/difflib.rst:77 +#: ../../library/difflib.rst:73 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." msgstr "" -#: ../../library/difflib.rst:80 +#: ../../library/difflib.rst:76 msgid "" "As an extension to the Ratcliff and Obershelp algorithm, :mod:`!difflib` " "searches for the longest *junk-free* contiguous subsequence. See the :ref:" "`difflib-junk` section for details." msgstr "" -#: ../../library/difflib.rst:84 +#: ../../library/difflib.rst:80 msgid "Timing" msgstr "" -#: ../../library/difflib.rst:86 +#: ../../library/difflib.rst:82 msgid "" "The basic Ratcliff-Obershelp algorithm is cubic time in the worst case and " "quadratic time in the expected case. :mod:`difflib`'s algorithm is quadratic " @@ -135,11 +135,11 @@ msgid "" "time is linear." msgstr "" -#: ../../library/difflib.rst:97 +#: ../../library/difflib.rst:93 msgid "Diff generation" msgstr "" -#: ../../library/difflib.rst:103 +#: ../../library/difflib.rst:99 msgid "" "This is a class for comparing sequences of lines of text, and producing " "human-readable differences or deltas. Differ uses :class:`SequenceMatcher` " @@ -147,51 +147,51 @@ msgid "" "within similar (near-matching) lines." msgstr "" -#: ../../library/difflib.rst:108 +#: ../../library/difflib.rst:104 msgid "Each line of a :class:`Differ` delta begins with a two-letter code:" msgstr "" -#: ../../library/difflib.rst:111 +#: ../../library/difflib.rst:107 msgid "Code" msgstr "程式碼" -#: ../../library/difflib.rst:111 ../../library/difflib.rst:580 +#: ../../library/difflib.rst:107 ../../library/difflib.rst:584 msgid "Meaning" msgstr "含義" -#: ../../library/difflib.rst:113 +#: ../../library/difflib.rst:109 msgid "``'- '``" msgstr "``'- '``" -#: ../../library/difflib.rst:113 +#: ../../library/difflib.rst:109 msgid "line unique to sequence 1" msgstr "" -#: ../../library/difflib.rst:115 +#: ../../library/difflib.rst:111 msgid "``'+ '``" msgstr "``'+ '``" -#: ../../library/difflib.rst:115 +#: ../../library/difflib.rst:111 msgid "line unique to sequence 2" msgstr "" -#: ../../library/difflib.rst:117 +#: ../../library/difflib.rst:113 msgid "``' '``" msgstr "``' '``" -#: ../../library/difflib.rst:117 +#: ../../library/difflib.rst:113 msgid "line common to both sequences" msgstr "" -#: ../../library/difflib.rst:119 +#: ../../library/difflib.rst:115 msgid "``'? '``" msgstr "``'? '``" -#: ../../library/difflib.rst:119 +#: ../../library/difflib.rst:115 msgid "line not present in either input sequence" msgstr "" -#: ../../library/difflib.rst:122 +#: ../../library/difflib.rst:118 msgid "" "Lines beginning with '``?``' attempt to guide the eye to intraline " "differences, and were not present in either input sequence. These lines can " @@ -199,7 +199,7 @@ msgid "" "tabs or line breaks." msgstr "" -#: ../../library/difflib.rst:126 +#: ../../library/difflib.rst:122 msgid "" "Note that :class:`Differ`\\ -generated deltas make no claim to be " "**minimal** diffs. To the contrary, minimal diffs are often counter-" @@ -209,31 +209,31 @@ msgid "" "producing a longer diff." msgstr "" -#: ../../library/difflib.rst:133 +#: ../../library/difflib.rst:129 msgid "The :class:`Differ` class has this constructor:" msgstr ":class:`Differ` 類別有這個建構函式:" -#: ../../library/difflib.rst:137 +#: ../../library/difflib.rst:133 msgid "" "Optional keyword parameters *linejunk* and *charjunk* are for filter " "functions (or ``None``):" msgstr "" -#: ../../library/difflib.rst:140 +#: ../../library/difflib.rst:136 msgid "" "*linejunk*: A function that accepts a single string argument, and returns " "true if the string is junk. The default is ``None``, meaning that no line " "is considered junk." msgstr "" -#: ../../library/difflib.rst:144 +#: ../../library/difflib.rst:140 msgid "" "*charjunk*: A function that accepts a single character argument (a string of " "length 1), and returns true if the character is junk. The default is " "``None``, meaning that no character is considered junk." msgstr "" -#: ../../library/difflib.rst:148 +#: ../../library/difflib.rst:144 msgid "" "These junk-filtering functions speed up matching to find differences and do " "not cause any differing lines or characters to be ignored. Read the " @@ -241,17 +241,17 @@ msgid "" "*isjunk* parameter for an explanation." msgstr "" -#: ../../library/difflib.rst:154 +#: ../../library/difflib.rst:150 msgid "" ":class:`Differ` objects are used (deltas generated) via a single method:" msgstr "" -#: ../../library/difflib.rst:159 +#: ../../library/difflib.rst:155 msgid "" "Compare two sequences of lines, and generate the delta (a sequence of lines)." msgstr "" -#: ../../library/difflib.rst:161 +#: ../../library/difflib.rst:157 msgid "" "Each sequence must contain individual single-line strings ending with " "newlines. Such sequences can be obtained from the :meth:`~io.IOBase." @@ -260,7 +260,7 @@ msgid "" "IOBase.writelines` method of a file-like object." msgstr "" -#: ../../library/difflib.rst:170 +#: ../../library/difflib.rst:166 msgid "" "This class can be used to create an HTML table (or a complete HTML file " "containing the table) showing a side by side, line by line comparison of " @@ -268,33 +268,33 @@ msgid "" "generated in either full or contextual difference mode." msgstr "" -#: ../../library/difflib.rst:177 +#: ../../library/difflib.rst:173 msgid "" "The trailing newlines get stripped before the diff, so the result can be " "incomplete. See :gh:`71896` for details." msgstr "" -#: ../../library/difflib.rst:180 +#: ../../library/difflib.rst:176 msgid "The constructor for this class is:" msgstr "" -#: ../../library/difflib.rst:185 +#: ../../library/difflib.rst:181 msgid "Initializes instance of :class:`HtmlDiff`." msgstr "" -#: ../../library/difflib.rst:187 +#: ../../library/difflib.rst:183 msgid "" "*tabsize* is an optional keyword argument to specify tab stop spacing and " "defaults to ``8``." msgstr "" -#: ../../library/difflib.rst:190 +#: ../../library/difflib.rst:186 msgid "" "*wrapcolumn* is an optional keyword to specify column number where lines are " "broken and wrapped, defaults to ``None`` where lines are not wrapped." msgstr "" -#: ../../library/difflib.rst:193 +#: ../../library/difflib.rst:189 msgid "" "*linejunk* and *charjunk* are optional keyword arguments passed into :func:" "`ndiff` (used by :class:`HtmlDiff` to generate the side by side HTML " @@ -302,24 +302,24 @@ msgid "" "and descriptions." msgstr "" -#: ../../library/difflib.rst:197 +#: ../../library/difflib.rst:193 msgid "The following methods are public:" msgstr "" -#: ../../library/difflib.rst:202 +#: ../../library/difflib.rst:198 msgid "" "Compares *fromlines* and *tolines* (lists of strings) and returns a string " "which is a complete HTML file containing a table showing line by line " "differences with inter-line and intra-line changes highlighted." msgstr "" -#: ../../library/difflib.rst:206 +#: ../../library/difflib.rst:202 msgid "" "*fromdesc* and *todesc* are optional keyword arguments to specify from/to " "file column header strings (both default to an empty string)." msgstr "" -#: ../../library/difflib.rst:209 +#: ../../library/difflib.rst:205 msgid "" "*context* and *numlines* are both optional keyword arguments. Set *context* " "to ``True`` when contextual differences are to be shown, else the default is " @@ -332,45 +332,45 @@ msgid "" "without any leading context)." msgstr "" -#: ../../library/difflib.rst:220 +#: ../../library/difflib.rst:216 msgid "" "*fromdesc* and *todesc* are interpreted as unescaped HTML and should be " "properly escaped while receiving input from untrusted sources." msgstr "" -#: ../../library/difflib.rst:223 +#: ../../library/difflib.rst:219 msgid "" "*charset* keyword-only argument was added. The default charset of HTML " "document changed from ``'ISO-8859-1'`` to ``'utf-8'``." msgstr "" -#: ../../library/difflib.rst:229 +#: ../../library/difflib.rst:225 msgid "" "Compares *fromlines* and *tolines* (lists of strings) and returns a string " "which is a complete HTML table showing line by line differences with inter-" "line and intra-line changes highlighted." msgstr "" -#: ../../library/difflib.rst:233 +#: ../../library/difflib.rst:229 msgid "" "The arguments for this method are the same as those for the :meth:" "`make_file` method." msgstr "" -#: ../../library/difflib.rst:240 +#: ../../library/difflib.rst:236 msgid "" "Compare *a* and *b* (lists of strings); return a delta (a :term:`generator` " "generating the delta lines) in context diff format." msgstr "" -#: ../../library/difflib.rst:243 +#: ../../library/difflib.rst:239 msgid "" "Context diffs are a compact way of showing just the lines that have changed " "plus a few lines of context. The changes are shown in a before/after " "style. The number of context lines is set by *n* which defaults to three." msgstr "" -#: ../../library/difflib.rst:247 +#: ../../library/difflib.rst:243 msgid "" "By default, the diff control lines (those with ``***`` or ``---``) are " "created with a trailing newline. This is helpful so that inputs created " @@ -379,13 +379,13 @@ msgid "" "trailing newlines." msgstr "" -#: ../../library/difflib.rst:253 ../../library/difflib.rst:385 +#: ../../library/difflib.rst:249 ../../library/difflib.rst:381 msgid "" "For inputs that do not have trailing newlines, set the *lineterm* argument " "to ``\"\"`` so that the output will be uniformly newline free." msgstr "" -#: ../../library/difflib.rst:256 +#: ../../library/difflib.rst:252 msgid "" "The context diff format normally has a header for filenames and modification " "times. Any or all of these may be specified using strings for *fromfile*, " @@ -394,11 +394,11 @@ msgid "" "default to blanks." msgstr "" -#: ../../library/difflib.rst:282 ../../library/difflib.rst:408 +#: ../../library/difflib.rst:278 ../../library/difflib.rst:408 msgid "See :ref:`difflib-interface` for a more detailed example." msgstr "一個更詳盡的範例請見 :ref:`difflib-interface`。" -#: ../../library/difflib.rst:287 +#: ../../library/difflib.rst:283 msgid "" "Return a list of the best \"good enough\" matches. *word* is a sequence for " "which close matches are desired (typically a string), and *possibilities* is " @@ -406,37 +406,37 @@ msgid "" "strings)." msgstr "" -#: ../../library/difflib.rst:291 +#: ../../library/difflib.rst:287 msgid "" "Optional argument *n* (default ``3``) is the maximum number of close matches " "to return; *n* must be greater than ``0``." msgstr "" -#: ../../library/difflib.rst:294 +#: ../../library/difflib.rst:290 msgid "" "Optional argument *cutoff* (default ``0.6``) is a float in the range [0, 1]. " "Possibilities that don't score at least that similar to *word* are ignored." msgstr "" -#: ../../library/difflib.rst:297 +#: ../../library/difflib.rst:293 msgid "" "The best (no more than *n*) matches among the possibilities are returned in " "a list, sorted by similarity score, most similar first." msgstr "" -#: ../../library/difflib.rst:313 +#: ../../library/difflib.rst:309 msgid "" "Compare *a* and *b* (lists of strings); return a :class:`Differ`\\ -style " "delta (a :term:`generator` generating the delta lines)." msgstr "" -#: ../../library/difflib.rst:316 +#: ../../library/difflib.rst:312 msgid "" "Optional keyword parameters *linejunk* and *charjunk* are filtering " "functions (or ``None``):" msgstr "" -#: ../../library/difflib.rst:319 +#: ../../library/difflib.rst:315 msgid "" "*linejunk*: A function that accepts a single string argument, and returns " "true if the string is junk, or false if not. The default is ``None``. There " @@ -447,7 +447,7 @@ msgid "" "this usually works better than using this function." msgstr "" -#: ../../library/difflib.rst:327 +#: ../../library/difflib.rst:323 msgid "" "*charjunk*: A function that accepts a character (a string of length 1), and " "returns if the character is junk, or false if not. The default is module-" @@ -455,28 +455,28 @@ msgid "" "characters (a blank or tab; it's a bad idea to include newline in this!)." msgstr "" -#: ../../library/difflib.rst:348 +#: ../../library/difflib.rst:344 msgid "Return one of the two sequences that generated a delta." msgstr "" -#: ../../library/difflib.rst:350 +#: ../../library/difflib.rst:346 msgid "" "Given a *sequence* produced by :meth:`Differ.compare` or :func:`ndiff`, " "extract lines originating from file 1 or 2 (parameter *which*), stripping " "off line prefixes." msgstr "" -#: ../../library/difflib.rst:354 +#: ../../library/difflib.rst:350 msgid "Example:" msgstr "範例:" -#: ../../library/difflib.rst:371 +#: ../../library/difflib.rst:367 msgid "" "Compare *a* and *b* (lists of strings); return a delta (a :term:`generator` " "generating the delta lines) in unified diff format." msgstr "" -#: ../../library/difflib.rst:374 +#: ../../library/difflib.rst:370 msgid "" "Unified diffs are a compact way of showing just the lines that have changed " "plus a few lines of context. The changes are shown in an inline style " @@ -484,7 +484,7 @@ msgid "" "set by *n* which defaults to three." msgstr "" -#: ../../library/difflib.rst:379 +#: ../../library/difflib.rst:375 msgid "" "By default, the diff control lines (those with ``---``, ``+++``, or ``@@``) " "are created with a trailing newline. This is helpful so that inputs created " @@ -493,6 +493,13 @@ msgid "" "trailing newlines." msgstr "" +#: ../../library/difflib.rst:384 +msgid "" +"Set *color* to ``True`` to enable output in color, similar to :program:`git " +"diff --color`. Even if enabled, it can be :ref:`controlled using environment " +"variables `." +msgstr "" + #: ../../library/difflib.rst:388 msgid "" "The unified diff format normally has a header for filenames and modification " @@ -502,14 +509,18 @@ msgid "" "default to blanks." msgstr "" -#: ../../library/difflib.rst:412 +#: ../../library/difflib.rst:410 +msgid "Added the *color* parameter." +msgstr "新增 *color* 參數。" + +#: ../../library/difflib.rst:416 msgid "" "Compare *a* and *b* (lists of bytes objects) using *dfunc*; yield a sequence " "of delta lines (also bytes) in the format returned by *dfunc*. *dfunc* must " "be a callable, typically either :func:`unified_diff` or :func:`context_diff`." msgstr "" -#: ../../library/difflib.rst:417 +#: ../../library/difflib.rst:421 msgid "" "Allows you to compare data with unknown or inconsistent encoding. All inputs " "except *n* must be bytes objects, not str. Works by losslessly converting " @@ -519,29 +530,29 @@ msgid "" "unknown/inconsistent encodings as *a* and *b*." msgstr "" -#: ../../library/difflib.rst:430 +#: ../../library/difflib.rst:434 msgid "Junk definition functions" msgstr "" -#: ../../library/difflib.rst:434 +#: ../../library/difflib.rst:438 msgid "" "Return ``True`` for ignorable lines. The line *line* is ignorable if *line* " "is blank or contains a single ``'#'``, otherwise it is not ignorable. Used " "as a default for parameter *linejunk* in :func:`ndiff` in older versions." msgstr "" -#: ../../library/difflib.rst:441 +#: ../../library/difflib.rst:445 msgid "" "Return ``True`` for ignorable characters. The character *ch* is ignorable " "if *ch* is a space or tab, otherwise it is not ignorable. Used as a default " "for parameter *charjunk* in :func:`ndiff`." msgstr "" -#: ../../library/difflib.rst:449 +#: ../../library/difflib.rst:453 msgid "SequenceMatcher objects" msgstr "SequenceMatcher 物件" -#: ../../library/difflib.rst:453 +#: ../../library/difflib.rst:457 msgid "" "Optional argument *isjunk* must be ``None`` (the default) or a one-argument " "function that takes a sequence element and returns true if and only if the " @@ -550,34 +561,34 @@ msgid "" "ignored. For example, pass::" msgstr "" -#: ../../library/difflib.rst:459 +#: ../../library/difflib.rst:463 msgid "lambda x: x in \" \\t\"" msgstr "lambda x: x in \" \\t\"" -#: ../../library/difflib.rst:461 +#: ../../library/difflib.rst:465 msgid "" "if you're comparing lines as sequences of characters, and don't want to " "synch up on blanks or hard tabs." msgstr "" -#: ../../library/difflib.rst:464 +#: ../../library/difflib.rst:468 msgid "" "The optional arguments *a* and *b* are sequences to be compared; both " "default to empty strings. The elements of both sequences must be :term:" "`hashable`." msgstr "" -#: ../../library/difflib.rst:467 +#: ../../library/difflib.rst:471 msgid "" "The optional argument *autojunk* can be used to disable the automatic junk " "heuristic." msgstr "" -#: ../../library/difflib.rst:470 +#: ../../library/difflib.rst:474 msgid "Added the *autojunk* parameter." msgstr "新增 *autojunk* 參數。" -#: ../../library/difflib.rst:473 +#: ../../library/difflib.rst:477 msgid "" "SequenceMatcher objects get three data attributes: *bjunk* is the set of " "elements of *b* for which *isjunk* is ``True``; *bpopular* is the set of non-" @@ -587,19 +598,19 @@ msgid "" "`set_seqs` or :meth:`set_seq2`." msgstr "" -#: ../../library/difflib.rst:480 +#: ../../library/difflib.rst:484 msgid "The *bjunk* and *bpopular* attributes." msgstr "" -#: ../../library/difflib.rst:483 +#: ../../library/difflib.rst:487 msgid ":class:`SequenceMatcher` objects have the following methods:" msgstr ":class:`SequenceMatcher` 物件有以下方法:" -#: ../../library/difflib.rst:487 +#: ../../library/difflib.rst:491 msgid "Set the two sequences to be compared." msgstr "" -#: ../../library/difflib.rst:489 +#: ../../library/difflib.rst:493 msgid "" ":class:`SequenceMatcher` computes and caches detailed information about the " "second sequence, so if you want to compare one sequence against many " @@ -607,23 +618,23 @@ msgid "" "call :meth:`set_seq1` repeatedly, once for each of the other sequences." msgstr "" -#: ../../library/difflib.rst:497 +#: ../../library/difflib.rst:501 msgid "" "Set the first sequence to be compared. The second sequence to be compared " "is not changed." msgstr "" -#: ../../library/difflib.rst:503 +#: ../../library/difflib.rst:507 msgid "" "Set the second sequence to be compared. The first sequence to be compared " "is not changed." msgstr "" -#: ../../library/difflib.rst:509 +#: ../../library/difflib.rst:513 msgid "Find longest matching block in ``a[alo:ahi]`` and ``b[blo:bhi]``." msgstr "" -#: ../../library/difflib.rst:511 +#: ../../library/difflib.rst:515 msgid "" "If *isjunk* was omitted or ``None``, :meth:`find_longest_match` returns " "``(i, j, k)`` such that ``a[i:i+k]`` is equal to ``b[j:j+k]``, where ``alo " @@ -635,7 +646,7 @@ msgid "" "that starts earliest in *b*." msgstr "" -#: ../../library/difflib.rst:524 +#: ../../library/difflib.rst:528 msgid "" "If *isjunk* was provided, first the longest matching block is determined as " "above, but with the additional restriction that no junk element appears in " @@ -644,7 +655,7 @@ msgid "" "junk except as identical junk happens to be adjacent to an interesting match." msgstr "" -#: ../../library/difflib.rst:531 +#: ../../library/difflib.rst:535 msgid "" "Here's the same example as before, but considering blanks to be junk. That " "prevents ``' abcd'`` from matching the ``' abcd'`` at the tail end of the " @@ -652,26 +663,26 @@ msgid "" "matches the leftmost ``'abcd'`` in the second sequence:" msgstr "" -#: ../../library/difflib.rst:540 +#: ../../library/difflib.rst:544 msgid "If no blocks match, this returns ``(alo, blo, 0)``." msgstr "" -#: ../../library/difflib.rst:542 +#: ../../library/difflib.rst:546 msgid "This method returns a :term:`named tuple` ``Match(a, b, size)``." msgstr "" -#: ../../library/difflib.rst:544 +#: ../../library/difflib.rst:548 msgid "Added default arguments." msgstr "新增預設引數。" -#: ../../library/difflib.rst:550 +#: ../../library/difflib.rst:554 msgid "" "Return list of triples describing non-overlapping matching subsequences. " "Each triple is of the form ``(i, j, n)``, and means that ``a[i:i+n] == b[j:" "j+n]``. The triples are monotonically increasing in *i* and *j*." msgstr "" -#: ../../library/difflib.rst:555 +#: ../../library/difflib.rst:559 msgid "" "The last triple is a dummy, and has the value ``(len(a), len(b), 0)``. It " "is the only triple with ``n == 0``. If ``(i, j, n)`` and ``(i', j', n')`` " @@ -680,7 +691,7 @@ msgid "" "triples always describe non-adjacent equal blocks." msgstr "" -#: ../../library/difflib.rst:563 +#: ../../library/difflib.rst:567 msgid "" ">>> s = SequenceMatcher(None, \"abxcd\", \"abcd\")\n" ">>> s.get_matching_blocks()\n" @@ -690,7 +701,7 @@ msgstr "" ">>> s.get_matching_blocks()\n" "[Match(a=0, b=0, size=2), Match(a=3, b=2, size=2), Match(a=5, b=4, size=0)]" -#: ../../library/difflib.rst:572 +#: ../../library/difflib.rst:576 msgid "" "Return list of 5-tuples describing how to turn *a* into *b*. Each tuple is " "of the form ``(tag, i1, i2, j1, j2)``. The first tuple has ``i1 == j1 == " @@ -698,53 +709,53 @@ msgid "" "tuple, and, likewise, *j1* equal to the previous *j2*." msgstr "" -#: ../../library/difflib.rst:577 +#: ../../library/difflib.rst:581 msgid "The *tag* values are strings, with these meanings:" msgstr "" -#: ../../library/difflib.rst:580 +#: ../../library/difflib.rst:584 msgid "Value" msgstr "" -#: ../../library/difflib.rst:582 +#: ../../library/difflib.rst:586 msgid "``'replace'``" msgstr "``'replace'``" -#: ../../library/difflib.rst:582 +#: ../../library/difflib.rst:586 msgid "``a[i1:i2]`` should be replaced by ``b[j1:j2]``." msgstr "``a[i1:i2]`` 應該被替換為 ``b[j1:j2]``。" -#: ../../library/difflib.rst:585 +#: ../../library/difflib.rst:589 msgid "``'delete'``" msgstr "``'delete'``" -#: ../../library/difflib.rst:585 +#: ../../library/difflib.rst:589 msgid "``a[i1:i2]`` should be deleted. Note that ``j1 == j2`` in this case." msgstr "``a[i1:i2]`` 應該被刪除。請注意,在這種情況下 ``j1 == j2``。" -#: ../../library/difflib.rst:588 +#: ../../library/difflib.rst:592 msgid "``'insert'``" msgstr "``'insert'``" -#: ../../library/difflib.rst:588 +#: ../../library/difflib.rst:592 msgid "" "``b[j1:j2]`` should be inserted at ``a[i1:i1]``. Note that ``i1 == i2`` in " "this case." msgstr "" -#: ../../library/difflib.rst:592 +#: ../../library/difflib.rst:596 msgid "``'equal'``" msgstr "``'equal'``" -#: ../../library/difflib.rst:592 +#: ../../library/difflib.rst:596 msgid "``a[i1:i2] == b[j1:j2]`` (the sub-sequences are equal)." msgstr "" -#: ../../library/difflib.rst:596 +#: ../../library/difflib.rst:600 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/difflib.rst:598 +#: ../../library/difflib.rst:602 msgid "" ">>> a = \"qabxcd\"\n" ">>> b = \"abycdf\"\n" @@ -770,49 +781,49 @@ msgstr "" "equal a[4:6] --> b[3:5] 'cd' --> 'cd'\n" "insert a[6:6] --> b[5:6] '' --> 'f'" -#: ../../library/difflib.rst:613 +#: ../../library/difflib.rst:617 msgid "Return a :term:`generator` of groups with up to *n* lines of context." msgstr "" -#: ../../library/difflib.rst:615 +#: ../../library/difflib.rst:619 msgid "" "Starting with the groups returned by :meth:`get_opcodes`, this method splits " "out smaller change clusters and eliminates intervening ranges which have no " "changes." msgstr "" -#: ../../library/difflib.rst:619 +#: ../../library/difflib.rst:623 msgid "The groups are returned in the same format as :meth:`get_opcodes`." msgstr "" -#: ../../library/difflib.rst:624 +#: ../../library/difflib.rst:628 msgid "" "Return a measure of the sequences' similarity as a float in the range [0, 1]." msgstr "" -#: ../../library/difflib.rst:627 +#: ../../library/difflib.rst:631 msgid "" "Where T is the total number of elements in both sequences, and M is the " "number of matches, this is 2.0\\*M / T. Note that this is ``1.0`` if the " "sequences are identical, and ``0.0`` if they have nothing in common." msgstr "" -#: ../../library/difflib.rst:631 +#: ../../library/difflib.rst:635 msgid "" "This is expensive to compute if :meth:`get_matching_blocks` or :meth:" "`get_opcodes` hasn't already been called, in which case you may want to try :" "meth:`quick_ratio` or :meth:`real_quick_ratio` first to get an upper bound." msgstr "" -#: ../../library/difflib.rst:639 +#: ../../library/difflib.rst:643 msgid "Return an upper bound on :meth:`ratio` relatively quickly." msgstr "" -#: ../../library/difflib.rst:644 +#: ../../library/difflib.rst:648 msgid "Return an upper bound on :meth:`ratio` very quickly." msgstr "" -#: ../../library/difflib.rst:647 +#: ../../library/difflib.rst:651 msgid "" "The three methods that return the ratio of matching to total characters can " "give different results due to differing levels of approximation, although :" @@ -821,32 +832,32 @@ msgid "" "ratio`:" msgstr "" -#: ../../library/difflib.rst:662 +#: ../../library/difflib.rst:666 msgid "Examples" msgstr "範例" -#: ../../library/difflib.rst:667 +#: ../../library/difflib.rst:671 msgid "SequenceMatcher examples" msgstr "SequenceMatcher 範例" -#: ../../library/difflib.rst:669 +#: ../../library/difflib.rst:673 msgid "This example compares two strings, considering blanks to be \"junk\":" msgstr "" -#: ../../library/difflib.rst:675 +#: ../../library/difflib.rst:679 msgid "" ":meth:`~SequenceMatcher.ratio` returns a float in [0, 1], measuring the " "similarity of the sequences. As a rule of thumb, a :meth:`~SequenceMatcher." "ratio` value over 0.6 means the sequences are close matches:" msgstr "" -#: ../../library/difflib.rst:682 +#: ../../library/difflib.rst:686 msgid "" "If you're only interested in where the sequences match, :meth:" "`~SequenceMatcher.get_matching_blocks` is handy:" msgstr "" -#: ../../library/difflib.rst:691 +#: ../../library/difflib.rst:695 msgid "" "Note that the last tuple returned by :meth:`~SequenceMatcher." "get_matching_blocks` is always a dummy, ``(len(a), len(b), 0)``, and this is " @@ -854,30 +865,30 @@ msgid "" "is ``0``." msgstr "" -#: ../../library/difflib.rst:695 +#: ../../library/difflib.rst:699 msgid "" "If you want to know how to change the first sequence into the second, use :" "meth:`~SequenceMatcher.get_opcodes`:" msgstr "" -#: ../../library/difflib.rst:706 +#: ../../library/difflib.rst:710 msgid "" "The :func:`get_close_matches` function in this module which shows how simple " "code building on :class:`SequenceMatcher` can be used to do useful work." msgstr "" -#: ../../library/difflib.rst:710 +#: ../../library/difflib.rst:714 msgid "" "`Simple version control recipe `_ for a small application built with :class:" "`SequenceMatcher`." msgstr "" -#: ../../library/difflib.rst:718 +#: ../../library/difflib.rst:722 msgid "Differ example" msgstr "Differ 範例" -#: ../../library/difflib.rst:720 +#: ../../library/difflib.rst:724 msgid "" "This example compares two texts. First we set up the texts, sequences of " "individual single-line strings ending with newlines (such sequences can also " @@ -885,39 +896,39 @@ msgid "" "objects):" msgstr "" -#: ../../library/difflib.rst:739 +#: ../../library/difflib.rst:743 msgid "Next we instantiate a Differ object:" msgstr "" -#: ../../library/difflib.rst:743 +#: ../../library/difflib.rst:747 msgid "" "Note that when instantiating a :class:`Differ` object we may pass functions " "to filter out line and character \"junk.\" See the :meth:`Differ` " "constructor for details." msgstr "" -#: ../../library/difflib.rst:747 +#: ../../library/difflib.rst:751 msgid "Finally, we compare the two:" msgstr "" -#: ../../library/difflib.rst:751 +#: ../../library/difflib.rst:755 msgid "``result`` is a list of strings, so let's pretty-print it:" msgstr "" -#: ../../library/difflib.rst:766 +#: ../../library/difflib.rst:770 msgid "As a single multi-line string it looks like this:" msgstr "" -#: ../../library/difflib.rst:785 +#: ../../library/difflib.rst:789 msgid "A command-line interface to difflib" msgstr "difflib 的命令列介面" -#: ../../library/difflib.rst:787 +#: ../../library/difflib.rst:791 msgid "" "This example shows how to use difflib to create a ``diff``-like utility." msgstr "" -#: ../../library/difflib.rst:789 +#: ../../library/difflib.rst:793 msgid "" "\"\"\" Command-line interface to difflib.py providing diffs in four " "formats:\n" @@ -1047,15 +1058,15 @@ msgstr "" "if __name__ == '__main__':\n" " main()\n" -#: ../../library/difflib.rst:792 +#: ../../library/difflib.rst:796 msgid "ndiff example" msgstr "ndiff 範例: ::" -#: ../../library/difflib.rst:794 +#: ../../library/difflib.rst:798 msgid "This example shows how to use :func:`difflib.ndiff`." msgstr "" -#: ../../library/difflib.rst:796 +#: ../../library/difflib.rst:800 msgid "" "\"\"\"ndiff [-q] file1 file2\n" " or\n" diff --git a/library/dis.po b/library/dis.po index 98af4b883ab..4283ebd7b0c 100644 --- a/library/dis.po +++ b/library/dis.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-07-27 16:55+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -501,7 +501,7 @@ msgstr "" #: ../../library/dis.rst:401 msgid "" "The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the :" -"attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab` " +"attr:`~codeobject.co_firstlineno` and :attr:`!codeobject.co_lnotab` " "attributes of the :ref:`code object `." msgstr "" @@ -1821,7 +1821,7 @@ msgstr "" #: ../../library/dis.rst:1643 msgid "" "Pushes a ``NULL`` to the stack. Used in the call sequence to match the " -"``NULL`` pushed by :opcode:`!LOAD_METHOD` for non-method calls." +"``NULL`` pushed by :opcode:`LOAD_ATTR` for non-method calls." msgstr "" #: ../../library/dis.rst:1652 @@ -2311,76 +2311,71 @@ msgid "" "``SETUP_CLEANUP`` or ``SETUP_WITH``." msgstr "" -#: ../../library/dis.rst:1973 -msgid "" -"Works as :opcode:`LOAD_CONST`, but is more efficient for immortal objects." -msgstr "" - -#: ../../library/dis.rst:1979 +#: ../../library/dis.rst:1974 msgid "" "Undirected relative jump instructions which are replaced by their directed " "(forward/backward) counterparts by the assembler." msgstr "" -#: ../../library/dis.rst:1985 +#: ../../library/dis.rst:1980 msgid "" "Conditional jumps which do not impact the stack. Replaced by the sequence " "``COPY 1``, ``TO_BOOL``, ``POP_JUMP_IF_TRUE/FALSE``." msgstr "" -#: ../../library/dis.rst:1990 +#: ../../library/dis.rst:1985 msgid "" "Pushes a reference to the cell contained in slot ``i`` of the \"fast " "locals\" storage." msgstr "" -#: ../../library/dis.rst:1993 +#: ../../library/dis.rst:1988 msgid "" "Note that ``LOAD_CLOSURE`` is replaced with ``LOAD_FAST`` in the assembler." msgstr "" -#: ../../library/dis.rst:1995 +#: ../../library/dis.rst:1990 msgid "This opcode is now a pseudo-instruction." msgstr "" -#: ../../library/dis.rst:2002 +#: ../../library/dis.rst:1997 msgid "Opcode collections" msgstr "" -#: ../../library/dis.rst:2004 +#: ../../library/dis.rst:1999 msgid "" "These collections are provided for automatic introspection of bytecode " "instructions:" msgstr "" -#: ../../library/dis.rst:2007 +#: ../../library/dis.rst:2002 msgid "" "The collections now contain pseudo instructions and instrumented " "instructions as well. These are opcodes with values ``>= MIN_PSEUDO_OPCODE`` " "and ``>= MIN_INSTRUMENTED_OPCODE``." msgstr "" -#: ../../library/dis.rst:2014 +#: ../../library/dis.rst:2009 msgid "Sequence of operation names, indexable using the bytecode." msgstr "" -#: ../../library/dis.rst:2019 +#: ../../library/dis.rst:2014 msgid "Dictionary mapping operation names to bytecodes." msgstr "" -#: ../../library/dis.rst:2024 +#: ../../library/dis.rst:2019 msgid "Sequence of all compare operation names." msgstr "" -#: ../../library/dis.rst:2029 +#: ../../library/dis.rst:2024 msgid "Sequence of bytecodes that use their argument." msgstr "" -#: ../../library/dis.rst:2036 +#: ../../library/dis.rst:2031 msgid "Sequence of bytecodes that access a constant." msgstr "" -#: ../../library/dis.rst:2041 +#: ../../library/dis.rst:2036 msgid "" "Sequence of bytecodes that access a :term:`free (closure) variable `. 'free' in this context refers to names in the current scope that " @@ -2389,39 +2384,39 @@ msgid "" "scopes." msgstr "" -#: ../../library/dis.rst:2049 +#: ../../library/dis.rst:2044 msgid "Sequence of bytecodes that access an attribute by name." msgstr "" -#: ../../library/dis.rst:2054 +#: ../../library/dis.rst:2049 msgid "Sequence of bytecodes that have a jump target. All jumps are relative." msgstr "" -#: ../../library/dis.rst:2061 +#: ../../library/dis.rst:2056 msgid "Sequence of bytecodes that access a local variable." msgstr "" -#: ../../library/dis.rst:2066 +#: ../../library/dis.rst:2061 msgid "Sequence of bytecodes of Boolean operations." msgstr "" -#: ../../library/dis.rst:2070 +#: ../../library/dis.rst:2065 msgid "Sequence of bytecodes that set an exception handler." msgstr "" -#: ../../library/dis.rst:2077 +#: ../../library/dis.rst:2072 msgid "Sequence of bytecodes that have a relative jump target." msgstr "" -#: ../../library/dis.rst:2079 +#: ../../library/dis.rst:2074 msgid "All jumps are now relative. Use :data:`hasjump`." msgstr "" -#: ../../library/dis.rst:2085 +#: ../../library/dis.rst:2080 msgid "Sequence of bytecodes that have an absolute jump target." msgstr "" -#: ../../library/dis.rst:2087 +#: ../../library/dis.rst:2082 msgid "All jumps are now relative. This list is empty." msgstr "" diff --git a/library/doctest.po b/library/doctest.po index cfe92997602..0a6480425af 100644 --- a/library/doctest.po +++ b/library/doctest.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,30 +21,30 @@ msgstr "" msgid ":mod:`!doctest` --- Test interactive Python examples" msgstr ":mod:`!doctest` --- 測試互動式 Python 範例" -#: ../../library/doctest.rst:12 +#: ../../library/doctest.rst:7 msgid "**Source code:** :source:`Lib/doctest.py`" msgstr "**原始碼:**\\ :source:`Lib/doctest.py`" -#: ../../library/doctest.rst:16 +#: ../../library/doctest.rst:11 msgid "" "The :mod:`!doctest` module searches for pieces of text that look like " "interactive Python sessions, and then executes those sessions to verify that " "they work exactly as shown. There are several common ways to use doctest:" msgstr "" -#: ../../library/doctest.rst:20 +#: ../../library/doctest.rst:15 msgid "" "To check that a module's docstrings are up-to-date by verifying that all " "interactive examples still work as documented." msgstr "" -#: ../../library/doctest.rst:23 +#: ../../library/doctest.rst:18 msgid "" "To perform regression testing by verifying that interactive examples from a " "test file or a test object work as expected." msgstr "透過驗證測試檔案或測試物件中的互動式範例是否按預期運作來執行迴歸測試。" -#: ../../library/doctest.rst:26 +#: ../../library/doctest.rst:21 msgid "" "To write tutorial documentation for a package, liberally illustrated with " "input-output examples. Depending on whether the examples or the expository " @@ -52,11 +52,11 @@ msgid "" "\"executable documentation\"." msgstr "" -#: ../../library/doctest.rst:31 +#: ../../library/doctest.rst:26 msgid "Here's a complete but small example module::" msgstr "" -#: ../../library/doctest.rst:33 +#: ../../library/doctest.rst:28 msgid "" "\"\"\"\n" "This is the \"example\" module.\n" @@ -114,13 +114,13 @@ msgid "" " doctest.testmod()" msgstr "" -#: ../../library/doctest.rst:88 +#: ../../library/doctest.rst:83 msgid "" "If you run :file:`example.py` directly from the command line, :mod:`!" "doctest` works its magic:" msgstr "" -#: ../../library/doctest.rst:91 +#: ../../library/doctest.rst:86 msgid "" "$ python example.py\n" "$" @@ -128,14 +128,14 @@ msgstr "" "$ python example.py\n" "$" -#: ../../library/doctest.rst:96 +#: ../../library/doctest.rst:91 msgid "" "There's no output! That's normal, and it means all the examples worked. " "Pass ``-v`` to the script, and :mod:`!doctest` prints a detailed log of what " "it's trying, and prints a summary at the end:" msgstr "" -#: ../../library/doctest.rst:100 +#: ../../library/doctest.rst:95 msgid "" "$ python example.py -v\n" "Trying:\n" @@ -161,11 +161,11 @@ msgstr "" " [1, 1, 2, 6, 24, 120]\n" "ok" -#: ../../library/doctest.rst:114 +#: ../../library/doctest.rst:109 msgid "And so on, eventually ending with:" msgstr "" -#: ../../library/doctest.rst:116 +#: ../../library/doctest.rst:111 msgid "" "Trying:\n" " factorial(1e100)\n" @@ -197,7 +197,7 @@ msgstr "" "Test passed.\n" "$" -#: ../../library/doctest.rst:133 +#: ../../library/doctest.rst:128 msgid "" "That's all you need to know to start making productive use of :mod:`!" "doctest`! Jump in. The following sections provide full details. Note that " @@ -206,23 +206,23 @@ msgid "" "file :file:`Lib/test/test_doctest/test_doctest.py`." msgstr "" -#: ../../library/doctest.rst:139 +#: ../../library/doctest.rst:134 msgid "" "Output is colorized by default and can be :ref:`controlled using environment " "variables `." msgstr "" -#: ../../library/doctest.rst:147 +#: ../../library/doctest.rst:142 msgid "Simple Usage: Checking Examples in Docstrings" msgstr "" -#: ../../library/doctest.rst:149 +#: ../../library/doctest.rst:144 msgid "" "The simplest way to start using doctest (but not necessarily the way you'll " "continue to do it) is to end each module :mod:`!M` with::" msgstr "" -#: ../../library/doctest.rst:152 +#: ../../library/doctest.rst:147 msgid "" "if __name__ == \"__main__\":\n" " import doctest\n" @@ -232,21 +232,21 @@ msgstr "" " import doctest\n" " doctest.testmod()" -#: ../../library/doctest.rst:156 +#: ../../library/doctest.rst:151 msgid ":mod:`!doctest` then examines docstrings in module :mod:`!M`." msgstr "" -#: ../../library/doctest.rst:158 +#: ../../library/doctest.rst:153 msgid "" "Running the module as a script causes the examples in the docstrings to get " "executed and verified::" msgstr "" -#: ../../library/doctest.rst:161 +#: ../../library/doctest.rst:156 msgid "python M.py" msgstr "python M.py" -#: ../../library/doctest.rst:163 +#: ../../library/doctest.rst:158 msgid "" "This won't display anything unless an example fails, in which case the " "failing example(s) and the cause(s) of the failure(s) are printed to stdout, " @@ -254,21 +254,21 @@ msgid "" "is the number of examples that failed." msgstr "" -#: ../../library/doctest.rst:168 +#: ../../library/doctest.rst:163 msgid "Run it with the ``-v`` switch instead::" msgstr "" -#: ../../library/doctest.rst:170 +#: ../../library/doctest.rst:165 msgid "python M.py -v" msgstr "python M.py -v" -#: ../../library/doctest.rst:172 +#: ../../library/doctest.rst:167 msgid "" "and a detailed report of all examples tried is printed to standard output, " "along with assorted summaries at the end." msgstr "" -#: ../../library/doctest.rst:175 +#: ../../library/doctest.rst:170 msgid "" "You can force verbose mode by passing ``verbose=True`` to :func:`testmod`, " "or prohibit it by passing ``verbose=False``. In either of those cases, :" @@ -276,29 +276,29 @@ msgid "" "has no effect)." msgstr "" -#: ../../library/doctest.rst:180 +#: ../../library/doctest.rst:175 msgid "" "There is also a command line shortcut for running :func:`testmod`, see " "section :ref:`doctest-cli`." msgstr "" -#: ../../library/doctest.rst:183 +#: ../../library/doctest.rst:178 msgid "" "For more information on :func:`testmod`, see section :ref:`doctest-basic-" "api`." msgstr "" -#: ../../library/doctest.rst:189 +#: ../../library/doctest.rst:184 msgid "Simple Usage: Checking Examples in a Text File" msgstr "" -#: ../../library/doctest.rst:191 +#: ../../library/doctest.rst:186 msgid "" "Another simple application of doctest is testing interactive examples in a " "text file. This can be done with the :func:`testfile` function::" msgstr "" -#: ../../library/doctest.rst:194 +#: ../../library/doctest.rst:189 msgid "" "import doctest\n" "doctest.testfile(\"example.txt\")" @@ -306,7 +306,7 @@ msgstr "" "import doctest\n" "doctest.testfile(\"example.txt\")" -#: ../../library/doctest.rst:197 +#: ../../library/doctest.rst:192 msgid "" "That short script executes and verifies any interactive Python examples " "contained in the file :file:`example.txt`. The file content is treated as " @@ -314,7 +314,7 @@ msgid "" "Python program! For example, perhaps :file:`example.txt` contains this:" msgstr "" -#: ../../library/doctest.rst:202 +#: ../../library/doctest.rst:197 msgid "" "The ``example`` module\n" "======================\n" @@ -348,13 +348,13 @@ msgstr "" " >>> factorial(6)\n" " 120" -#: ../../library/doctest.rst:220 +#: ../../library/doctest.rst:215 msgid "" "Running ``doctest.testfile(\"example.txt\")`` then finds the error in this " "documentation::" msgstr "" -#: ../../library/doctest.rst:223 +#: ../../library/doctest.rst:218 msgid "" "File \"./example.txt\", line 14, in example.txt\n" "Failed example:\n" @@ -372,7 +372,7 @@ msgstr "" "Got:\n" " 720" -#: ../../library/doctest.rst:231 +#: ../../library/doctest.rst:226 msgid "" "As with :func:`testmod`, :func:`testfile` won't display anything unless an " "example fails. If an example does fail, then the failing example(s) and the " @@ -380,7 +380,7 @@ msgid "" "func:`!testmod`." msgstr "" -#: ../../library/doctest.rst:236 +#: ../../library/doctest.rst:231 msgid "" "By default, :func:`testfile` looks for files in the calling module's " "directory. See section :ref:`doctest-basic-api` for a description of the " @@ -388,79 +388,79 @@ msgid "" "locations." msgstr "" -#: ../../library/doctest.rst:240 +#: ../../library/doctest.rst:235 msgid "" "Like :func:`testmod`, :func:`testfile`'s verbosity can be set with the ``-" "v`` command-line switch or with the optional keyword argument *verbose*." msgstr "" -#: ../../library/doctest.rst:244 +#: ../../library/doctest.rst:239 msgid "" "There is also a command line shortcut for running :func:`testfile`, see " "section :ref:`doctest-cli`." msgstr "" -#: ../../library/doctest.rst:247 +#: ../../library/doctest.rst:242 msgid "" "For more information on :func:`testfile`, see section :ref:`doctest-basic-" "api`." msgstr "" -#: ../../library/doctest.rst:253 +#: ../../library/doctest.rst:248 msgid "Command-line Usage" msgstr "命令列用法" -#: ../../library/doctest.rst:255 +#: ../../library/doctest.rst:250 msgid "" "The :mod:`!doctest` module can be invoked as a script from the command line:" msgstr "可以從命令列以腳本方式叫用 :mod:`!doctest` 模組:" -#: ../../library/doctest.rst:257 +#: ../../library/doctest.rst:252 msgid "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" msgstr "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" -#: ../../library/doctest.rst:265 +#: ../../library/doctest.rst:260 msgid "" "Detailed report of all examples tried is printed to standard output, along " "with assorted summaries at the end::" msgstr "" -#: ../../library/doctest.rst:268 +#: ../../library/doctest.rst:263 msgid "python -m doctest -v example.py" msgstr "python -m doctest -v example.py" -#: ../../library/doctest.rst:270 +#: ../../library/doctest.rst:265 msgid "" "This will import :file:`example.py` as a standalone module and run :func:" "`testmod` on it. Note that this may not work correctly if the file is part " "of a package and imports other submodules from that package." msgstr "" -#: ../../library/doctest.rst:274 +#: ../../library/doctest.rst:269 msgid "" "If the file name does not end with :file:`.py`, :mod:`!doctest` infers that " "it must be run with :func:`testfile` instead::" msgstr "" -#: ../../library/doctest.rst:277 +#: ../../library/doctest.rst:272 msgid "python -m doctest -v example.txt" msgstr "python -m doctest -v example.txt" -#: ../../library/doctest.rst:281 +#: ../../library/doctest.rst:276 msgid "" "Option flags control various aspects of doctest's behavior, see section :ref:" "`doctest-options`." msgstr "" -#: ../../library/doctest.rst:288 +#: ../../library/doctest.rst:283 msgid "This is shorthand for ``-o FAIL_FAST``." msgstr "" -#: ../../library/doctest.rst:296 +#: ../../library/doctest.rst:291 msgid "How It Works" msgstr "運作方式" -#: ../../library/doctest.rst:298 +#: ../../library/doctest.rst:293 msgid "" "This section examines in detail how doctest works: which docstrings it looks " "at, how it finds interactive examples, what execution context it uses, how " @@ -470,17 +470,17 @@ msgid "" "see the following sections." msgstr "" -#: ../../library/doctest.rst:309 +#: ../../library/doctest.rst:304 msgid "Which Docstrings Are Examined?" msgstr "" -#: ../../library/doctest.rst:311 +#: ../../library/doctest.rst:306 msgid "" "The module docstring, and all function, class and method docstrings are " "searched. Objects imported into the module are not searched." msgstr "" -#: ../../library/doctest.rst:321 +#: ../../library/doctest.rst:316 msgid "" "In addition, there are cases when you want tests to be part of a module but " "not part of the help text, which requires that the tests not be included in " @@ -493,11 +493,11 @@ msgid "" "__test__.K``." msgstr "" -#: ../../library/doctest.rst:330 +#: ../../library/doctest.rst:325 msgid "For example, place this block of code at the top of :file:`example.py`:" msgstr "" -#: ../../library/doctest.rst:332 +#: ../../library/doctest.rst:327 msgid "" "__test__ = {\n" " 'numbers': \"\"\"\n" @@ -519,7 +519,7 @@ msgstr "" "\"\"\"\n" "}" -#: ../../library/doctest.rst:344 +#: ../../library/doctest.rst:339 msgid "" "The value of ``example.__test__[\"numbers\"]`` will be treated as a " "docstring and all the tests inside it will be run. It is important to note " @@ -528,36 +528,36 @@ msgid "" "scanned for tests." msgstr "" -#: ../../library/doctest.rst:350 +#: ../../library/doctest.rst:345 msgid "" "Any classes found are recursively searched similarly, to test docstrings in " "their contained methods and nested classes." msgstr "" -#: ../../library/doctest.rst:355 +#: ../../library/doctest.rst:350 msgid "" "``doctest`` can only automatically discover classes and functions that are " "defined at the module level or inside other classes." msgstr "" -#: ../../library/doctest.rst:358 +#: ../../library/doctest.rst:353 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:364 +#: ../../library/doctest.rst:359 msgid "How are Docstring Examples Recognized?" msgstr "" -#: ../../library/doctest.rst:366 +#: ../../library/doctest.rst:361 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:371 +#: ../../library/doctest.rst:366 msgid "" ">>> # comments are ignored\n" ">>> x = 12\n" @@ -591,18 +591,18 @@ msgstr "" "NO!!!\n" ">>>" -#: ../../library/doctest.rst:391 +#: ../../library/doctest.rst:386 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:395 +#: ../../library/doctest.rst:390 msgid "The fine print:" msgstr "" -#: ../../library/doctest.rst:397 +#: ../../library/doctest.rst:392 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 " @@ -610,7 +610,7 @@ msgid "" "line is expected." msgstr "" -#: ../../library/doctest.rst:402 +#: ../../library/doctest.rst:397 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 " @@ -625,20 +625,20 @@ msgid "" "`DocTestParser` class." msgstr "" -#: ../../library/doctest.rst:414 +#: ../../library/doctest.rst:409 msgid "" "Output to stdout is captured, but not output to stderr (exception tracebacks " "are captured via a different means)." msgstr "" -#: ../../library/doctest.rst:417 +#: ../../library/doctest.rst:412 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:421 +#: ../../library/doctest.rst:416 msgid "" ">>> def f(x):\n" "... r'''Backslashes in a raw docstring: m\\n'''\n" @@ -647,7 +647,7 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:427 +#: ../../library/doctest.rst:422 msgid "" "Otherwise, the backslash will be interpreted as part of the string. For " "example, the ``\\n`` above would be interpreted as a newline character. " @@ -655,7 +655,7 @@ msgid "" "use a raw string)::" msgstr "" -#: ../../library/doctest.rst:431 +#: ../../library/doctest.rst:426 msgid "" ">>> def f(x):\n" "... '''Backslashes in a raw docstring: m\\\\n'''\n" @@ -664,11 +664,11 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:437 +#: ../../library/doctest.rst:432 msgid "The starting column doesn't matter::" msgstr "" -#: ../../library/doctest.rst:439 +#: ../../library/doctest.rst:434 msgid "" ">>> assert \"Easy!\"\n" " >>> import math\n" @@ -680,17 +680,17 @@ msgstr "" " >>> math.floor(1.9)\n" " 1" -#: ../../library/doctest.rst:444 +#: ../../library/doctest.rst:439 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:451 +#: ../../library/doctest.rst:446 msgid "What's the Execution Context?" msgstr "" -#: ../../library/doctest.rst:453 +#: ../../library/doctest.rst:448 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 " @@ -701,17 +701,17 @@ msgid "" "defined in other docstrings." msgstr "" -#: ../../library/doctest.rst:461 +#: ../../library/doctest.rst:456 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:468 +#: ../../library/doctest.rst:463 msgid "What About Exceptions?" msgstr "" -#: ../../library/doctest.rst:470 +#: ../../library/doctest.rst:465 msgid "" "No problem, provided that the traceback is the only output produced by the " "example: just paste in the traceback. [#]_ Since tracebacks contain details " @@ -720,11 +720,11 @@ msgid "" "it accepts." msgstr "" -#: ../../library/doctest.rst:476 +#: ../../library/doctest.rst:471 msgid "Simple example::" msgstr "簡單範例: ::" -#: ../../library/doctest.rst:478 +#: ../../library/doctest.rst:473 msgid "" ">>> [1, 2, 3].remove(42)\n" "Traceback (most recent call last):\n" @@ -736,20 +736,20 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: list.remove(x): x not in list" -#: ../../library/doctest.rst:483 +#: ../../library/doctest.rst:478 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:486 +#: ../../library/doctest.rst:481 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:490 +#: ../../library/doctest.rst:485 msgid "" "Traceback (most recent call last):\n" "Traceback (innermost last):" @@ -757,14 +757,14 @@ msgstr "" "Traceback (most recent call last):\n" "Traceback (innermost last):" -#: ../../library/doctest.rst:493 +#: ../../library/doctest.rst:488 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:497 +#: ../../library/doctest.rst:492 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 " @@ -772,7 +772,7 @@ msgid "" "multi-line detail::" msgstr "" -#: ../../library/doctest.rst:502 +#: ../../library/doctest.rst:497 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -788,20 +788,20 @@ msgstr "" " line\n" "detail" -#: ../../library/doctest.rst:509 +#: ../../library/doctest.rst:504 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:512 +#: ../../library/doctest.rst:507 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:515 +#: ../../library/doctest.rst:510 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -817,7 +817,7 @@ msgstr "" " line\n" "detail" -#: ../../library/doctest.rst:522 +#: ../../library/doctest.rst:517 msgid "" "Note that tracebacks are treated very specially. In particular, in the " "rewritten example, the use of ``...`` is independent of doctest's :const:" @@ -826,11 +826,11 @@ msgid "" "transcript of a Monty Python skit." msgstr "" -#: ../../library/doctest.rst:528 +#: ../../library/doctest.rst:523 msgid "Some details you should read once, but won't need to remember:" msgstr "" -#: ../../library/doctest.rst:530 +#: ../../library/doctest.rst:525 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 " @@ -840,7 +840,7 @@ msgid "" "create real problems." msgstr "" -#: ../../library/doctest.rst:537 +#: ../../library/doctest.rst:532 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. " @@ -849,14 +849,14 @@ msgid "" "course this does the right thing for genuine tracebacks." msgstr "" -#: ../../library/doctest.rst:543 +#: ../../library/doctest.rst:538 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:547 +#: ../../library/doctest.rst:542 msgid "" "The interactive shell omits the traceback header line for some :exc:" "`SyntaxError`\\ s. But doctest uses the traceback header line to " @@ -865,13 +865,13 @@ msgid "" "need to manually add the traceback header line to your test example." msgstr "" -#: ../../library/doctest.rst:555 +#: ../../library/doctest.rst:550 msgid "" "For some exceptions, Python displays the position of the error using ``^`` " "markers and tildes::" msgstr "" -#: ../../library/doctest.rst:558 +#: ../../library/doctest.rst:553 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -885,7 +885,7 @@ msgstr "" " ~~^~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:564 +#: ../../library/doctest.rst:559 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 " @@ -893,7 +893,7 @@ msgid "" "location::" msgstr "" -#: ../../library/doctest.rst:568 +#: ../../library/doctest.rst:563 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -907,11 +907,11 @@ msgstr "" " ^~~~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:579 +#: ../../library/doctest.rst:574 msgid "Option Flags" msgstr "可選旗標" -#: ../../library/doctest.rst:581 +#: ../../library/doctest.rst:576 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 :" @@ -921,13 +921,13 @@ msgid "" "option." msgstr "" -#: ../../library/doctest.rst:587 +#: ../../library/doctest.rst:582 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:593 +#: ../../library/doctest.rst:588 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 " @@ -939,7 +939,7 @@ msgid "" "not for several years." msgstr "" -#: ../../library/doctest.rst:605 +#: ../../library/doctest.rst:600 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 " @@ -948,7 +948,7 @@ msgid "" "`DONT_ACCEPT_BLANKLINE` is specified, this substitution is not allowed." msgstr "" -#: ../../library/doctest.rst:614 +#: ../../library/doctest.rst:609 msgid "" "When specified, all sequences of whitespace (blanks and newlines) are " "treated as equal. Any sequence of whitespace within the expected output " @@ -958,7 +958,7 @@ msgid "" "across multiple lines in your source." msgstr "" -#: ../../library/doctest.rst:625 +#: ../../library/doctest.rst:620 msgid "" "When specified, an ellipsis marker (``...``) in the expected output can " "match any substring in the actual output. This includes substrings that " @@ -967,14 +967,14 @@ msgid "" "matched too much!\" surprises that ``.*`` is prone to in regular expressions." msgstr "" -#: ../../library/doctest.rst:634 +#: ../../library/doctest.rst:629 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:638 +#: ../../library/doctest.rst:633 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:" @@ -984,7 +984,7 @@ msgid "" "these variations will work with the flag specified:" msgstr "" -#: ../../library/doctest.rst:646 +#: ../../library/doctest.rst:641 msgid "" ">>> raise Exception('message')\n" "Traceback (most recent call last):\n" @@ -1010,20 +1010,20 @@ msgstr "" "Traceback (most recent call last):\n" "__main__.Exception: message" -#: ../../library/doctest.rst:660 +#: ../../library/doctest.rst:655 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:664 +#: ../../library/doctest.rst:659 msgid "" ":const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating " "to the module containing the exception under test." msgstr "" -#: ../../library/doctest.rst:671 +#: ../../library/doctest.rst:666 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, " @@ -1032,32 +1032,32 @@ msgid "" "might depend on resources which would be unavailable to the test driver." msgstr "" -#: ../../library/doctest.rst:677 +#: ../../library/doctest.rst:672 msgid "" "The SKIP flag can also be used for temporarily \"commenting out\" examples." msgstr "" -#: ../../library/doctest.rst:682 +#: ../../library/doctest.rst:677 msgid "A bitmask or'ing together all the comparison flags above." msgstr "" -#: ../../library/doctest.rst:684 +#: ../../library/doctest.rst:679 msgid "The second group of options controls how test failures are reported:" msgstr "" -#: ../../library/doctest.rst:689 +#: ../../library/doctest.rst:684 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "are displayed using a unified diff." msgstr "" -#: ../../library/doctest.rst:695 +#: ../../library/doctest.rst:690 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "will be displayed using a context diff." msgstr "" -#: ../../library/doctest.rst:701 +#: ../../library/doctest.rst:696 msgid "" "When specified, differences are computed by ``difflib.Differ``, using the " "same algorithm as the popular :file:`ndiff.py` utility. This is the only " @@ -1067,7 +1067,7 @@ msgid "" "mismatching column positions." msgstr "" -#: ../../library/doctest.rst:710 +#: ../../library/doctest.rst:705 msgid "" "When specified, display the first failing example in each doctest, but " "suppress output for all remaining examples. This will prevent doctest from " @@ -1078,7 +1078,7 @@ msgid "" "of failures reported; only the output is suppressed." msgstr "" -#: ../../library/doctest.rst:721 +#: ../../library/doctest.rst:716 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 " @@ -1086,17 +1086,17 @@ msgid "" "first failure won't even produce debugging output." msgstr "" -#: ../../library/doctest.rst:729 +#: ../../library/doctest.rst:724 msgid "A bitmask or'ing together all the reporting flags above." msgstr "" -#: ../../library/doctest.rst:732 +#: ../../library/doctest.rst:727 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:738 +#: ../../library/doctest.rst:733 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 :" @@ -1105,39 +1105,39 @@ msgid "" "be called using the following idiom::" msgstr "" -#: ../../library/doctest.rst:744 +#: ../../library/doctest.rst:739 msgid "MY_FLAG = register_optionflag('MY_FLAG')" msgstr "MY_FLAG = register_optionflag('MY_FLAG')" -#: ../../library/doctest.rst:754 +#: ../../library/doctest.rst:749 msgid "Directives" msgstr "" -#: ../../library/doctest.rst:756 +#: ../../library/doctest.rst:751 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:767 +#: ../../library/doctest.rst:762 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:771 +#: ../../library/doctest.rst:766 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:774 +#: ../../library/doctest.rst:769 msgid "For example, this test passes:" msgstr "舉例來說,這個測試會通過:" -#: ../../library/doctest.rst:776 +#: ../../library/doctest.rst:771 msgid "" ">>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" @@ -1147,7 +1147,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:783 +#: ../../library/doctest.rst:778 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 " @@ -1155,7 +1155,7 @@ msgid "" "a directive to do so:" msgstr "" -#: ../../library/doctest.rst:788 +#: ../../library/doctest.rst:783 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" @@ -1163,13 +1163,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:794 +#: ../../library/doctest.rst:789 msgid "" "Multiple directives can be used on a single physical line, separated by " "commas:" msgstr "" -#: ../../library/doctest.rst:797 +#: ../../library/doctest.rst:792 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" @@ -1177,13 +1177,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:803 +#: ../../library/doctest.rst:798 msgid "" "If multiple directive comments are used for a single example, then they are " "combined:" msgstr "" -#: ../../library/doctest.rst:806 +#: ../../library/doctest.rst:801 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "... # doctest: +NORMALIZE_WHITESPACE\n" @@ -1193,14 +1193,14 @@ msgstr "" "... # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:813 +#: ../../library/doctest.rst:808 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:817 +#: ../../library/doctest.rst:812 msgid "" ">>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))\n" "... # doctest: +ELLIPSIS\n" @@ -1210,7 +1210,7 @@ msgstr "" "... # doctest: +ELLIPSIS\n" "[0, ..., 4, 10, ..., 19, 30, ..., 39]" -#: ../../library/doctest.rst:824 +#: ../../library/doctest.rst:819 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 " @@ -1220,11 +1220,11 @@ msgid "" "be useful." msgstr "" -#: ../../library/doctest.rst:834 +#: ../../library/doctest.rst:829 msgid "Warnings" msgstr "警告" -#: ../../library/doctest.rst:836 +#: ../../library/doctest.rst:831 msgid "" ":mod:`!doctest` is serious about requiring exact matches in expected " "output. If even a single character doesn't match, the test fails. This " @@ -1234,7 +1234,7 @@ msgid "" "order, so a test like ::" msgstr "" -#: ../../library/doctest.rst:842 +#: ../../library/doctest.rst:837 msgid "" ">>> foo()\n" "{\"spam\", \"eggs\"}" @@ -1242,11 +1242,11 @@ msgstr "" ">>> foo()\n" "{\"spam\", \"eggs\"}" -#: ../../library/doctest.rst:845 +#: ../../library/doctest.rst:840 msgid "is vulnerable! One workaround is to do ::" msgstr "" -#: ../../library/doctest.rst:847 +#: ../../library/doctest.rst:842 msgid "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" @@ -1254,11 +1254,11 @@ msgstr "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" -#: ../../library/doctest.rst:850 +#: ../../library/doctest.rst:845 msgid "instead. Another is to do ::" msgstr "" -#: ../../library/doctest.rst:852 +#: ../../library/doctest.rst:847 msgid "" ">>> d = sorted(foo())\n" ">>> d\n" @@ -1268,15 +1268,15 @@ msgstr "" ">>> d\n" "['eggs', 'spam']" -#: ../../library/doctest.rst:856 +#: ../../library/doctest.rst:851 msgid "There are others, but you get the idea." msgstr "" -#: ../../library/doctest.rst:858 +#: ../../library/doctest.rst:853 msgid "Another bad idea is to print things that embed an object address, like" msgstr "" -#: ../../library/doctest.rst:860 +#: ../../library/doctest.rst:855 msgid "" ">>> id(1.0) # certain to fail some of the time\n" "7948648\n" @@ -1285,12 +1285,12 @@ msgid "" "" msgstr "" -#: ../../library/doctest.rst:868 +#: ../../library/doctest.rst:863 msgid "" "The :const:`ELLIPSIS` directive gives a nice approach for the last example:" msgstr "" -#: ../../library/doctest.rst:870 +#: ../../library/doctest.rst:865 msgid "" ">>> C() # doctest: +ELLIPSIS\n" "" @@ -1298,14 +1298,14 @@ msgstr "" ">>> C() # doctest: +ELLIPSIS\n" "" -#: ../../library/doctest.rst:876 +#: ../../library/doctest.rst:871 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:880 +#: ../../library/doctest.rst:875 msgid "" ">>> 1000**0.1 # risky\n" "1.9952623149688797\n" @@ -1321,13 +1321,13 @@ msgstr "" ">>> print(f'{1000**0.1:.4f}') # 更加安全\n" "1.9953" -#: ../../library/doctest.rst:887 +#: ../../library/doctest.rst:882 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:890 +#: ../../library/doctest.rst:885 msgid "" ">>> 3./4 # utterly safe\n" "0.75" @@ -1335,17 +1335,17 @@ msgstr "" ">>> 3./4 # utterly safe\n" "0.75" -#: ../../library/doctest.rst:893 +#: ../../library/doctest.rst:888 msgid "" "Simple fractions are also easier for people to understand, and that makes " "for better documentation." msgstr "" -#: ../../library/doctest.rst:900 +#: ../../library/doctest.rst:895 msgid "Basic API" msgstr "基礎 API" -#: ../../library/doctest.rst:902 +#: ../../library/doctest.rst:897 msgid "" "The functions :func:`testmod` and :func:`testfile` provide a simple " "interface to doctest that should be sufficient for most basic uses. For a " @@ -1353,25 +1353,25 @@ msgid "" "simple-testmod` and :ref:`doctest-simple-testfile`." msgstr "" -#: ../../library/doctest.rst:910 +#: ../../library/doctest.rst:905 msgid "" "All arguments except *filename* are optional, and should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:913 +#: ../../library/doctest.rst:908 msgid "" "Test examples in the file named *filename*. Return ``(failure_count, " "test_count)``." msgstr "" -#: ../../library/doctest.rst:916 +#: ../../library/doctest.rst:911 msgid "" "Optional argument *module_relative* specifies how the filename should be " "interpreted:" msgstr "" -#: ../../library/doctest.rst:919 +#: ../../library/doctest.rst:914 msgid "" "If *module_relative* is ``True`` (the default), then *filename* specifies an " "OS-independent module-relative path. By default, this path is relative to " @@ -1381,20 +1381,20 @@ msgid "" "absolute path (i.e., it may not begin with ``/``)." msgstr "" -#: ../../library/doctest.rst:926 +#: ../../library/doctest.rst:921 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:930 +#: ../../library/doctest.rst:925 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:933 +#: ../../library/doctest.rst:928 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-" @@ -1403,7 +1403,7 @@ msgid "" "is an error to specify *package* if *module_relative* is ``False``." msgstr "" -#: ../../library/doctest.rst:939 +#: ../../library/doctest.rst:934 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 " @@ -1411,7 +1411,7 @@ msgid "" "``None``, a new empty dict is used." msgstr "" -#: ../../library/doctest.rst:944 +#: ../../library/doctest.rst:939 msgid "" "Optional argument *extraglobs* gives a dict merged into the globals used to " "execute examples. This works like :meth:`dict.update`: if *globs* and " @@ -1424,27 +1424,27 @@ msgid "" "tested." msgstr "" -#: ../../library/doctest.rst:953 +#: ../../library/doctest.rst:948 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:957 +#: ../../library/doctest.rst:952 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:961 +#: ../../library/doctest.rst:956 msgid "" "Optional argument *optionflags* (default value ``0``) takes the :ref:" "`bitwise OR ` of option flags. See section :ref:`doctest-options`." msgstr "" -#: ../../library/doctest.rst:965 +#: ../../library/doctest.rst:960 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. " @@ -1452,33 +1452,33 @@ msgid "" "continue running examples." msgstr "" -#: ../../library/doctest.rst:970 ../../library/doctest.rst:1113 +#: ../../library/doctest.rst:965 ../../library/doctest.rst:1111 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:974 ../../library/doctest.rst:1117 +#: ../../library/doctest.rst:969 ../../library/doctest.rst:1115 msgid "" "Optional argument *encoding* specifies an encoding that should be used to " "convert the file to unicode." msgstr "" -#: ../../library/doctest.rst:980 +#: ../../library/doctest.rst:975 msgid "" "All arguments are optional, and all except for *m* should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:983 +#: ../../library/doctest.rst:978 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:987 +#: ../../library/doctest.rst:982 msgid "" "Also test examples reachable from dict ``m.__test__``, if it exists. ``m." "__test__`` maps names (strings) to functions, classes and strings; function " @@ -1486,22 +1486,22 @@ msgid "" "directly, as if they were docstrings." msgstr "" -#: ../../library/doctest.rst:992 +#: ../../library/doctest.rst:987 msgid "" "Only docstrings attached to objects belonging to module *m* are searched." msgstr "" -#: ../../library/doctest.rst:994 +#: ../../library/doctest.rst:989 msgid "Return ``(failure_count, test_count)``." msgstr "回傳 ``(failure_count, test_count)``。" -#: ../../library/doctest.rst:996 +#: ../../library/doctest.rst:991 msgid "" "Optional argument *name* gives the name of the module; by default, or if " "``None``, ``m.__name__`` is used." msgstr "" -#: ../../library/doctest.rst:999 +#: ../../library/doctest.rst:994 msgid "" "Optional argument *exclude_empty* defaults to false. If true, objects for " "which no doctests are found are excluded from consideration. The default is " @@ -1512,39 +1512,39 @@ msgid "" "defaults to true." msgstr "" -#: ../../library/doctest.rst:1007 +#: ../../library/doctest.rst:1002 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:1014 +#: ../../library/doctest.rst:1009 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:1017 +#: ../../library/doctest.rst:1012 msgid "" "A shallow copy of dictionary argument *globs* is used for the execution " "context." msgstr "" -#: ../../library/doctest.rst:1019 +#: ../../library/doctest.rst:1014 msgid "" "Optional argument *name* is used in failure messages, and defaults to " "``\"NoName\"``." msgstr "" -#: ../../library/doctest.rst:1022 +#: ../../library/doctest.rst:1017 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:1025 +#: ../../library/doctest.rst:1020 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 " @@ -1552,16 +1552,16 @@ msgid "" "found in *globs*." msgstr "" -#: ../../library/doctest.rst:1029 +#: ../../library/doctest.rst:1024 msgid "" "Optional argument *optionflags* works as for function :func:`testfile` above." msgstr "" -#: ../../library/doctest.rst:1035 +#: ../../library/doctest.rst:1030 msgid "Unittest API" msgstr "Unittest API" -#: ../../library/doctest.rst:1037 +#: ../../library/doctest.rst:1032 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 " @@ -1571,7 +1571,7 @@ msgid "" "your test module::" msgstr "" -#: ../../library/doctest.rst:1043 +#: ../../library/doctest.rst:1038 msgid "" "import unittest\n" "import doctest\n" @@ -1589,44 +1589,45 @@ msgstr "" " tests.addTests(doctest.DocTestSuite(my_module_with_doctests))\n" " return tests" -#: ../../library/doctest.rst:1051 +#: ../../library/doctest.rst:1046 msgid "" "There are two main functions for creating :class:`unittest.TestSuite` " "instances from text files and modules with doctests:" msgstr "" -#: ../../library/doctest.rst:1057 +#: ../../library/doctest.rst:1052 msgid "" "Convert doctest tests from one or more text files to a :class:`unittest." "TestSuite`." msgstr "" -#: ../../library/doctest.rst:1060 +#: ../../library/doctest.rst:1055 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 " -"any file fails, then the synthesized unit test fails, and a :exc:`~unittest." -"TestCase.failureException` exception is raised showing the name of the file " -"containing the test and a (sometimes approximate) line number. If all the " -"examples in a file are skipped, then the synthesized unit test is also " +"framework and runs the interactive examples in each file. Each file is run " +"as a separate unit test, and each example in a file is run as a :ref:" +"`subtest `. If any example in a file fails, then the synthesized " +"unit test fails. The traceback for failure or error contains the name of the " +"file containing the test and a (sometimes approximate) line number. If all " +"the examples in a file are skipped, then the synthesized unit test is also " "marked as skipped." msgstr "" -#: ../../library/doctest.rst:1067 +#: ../../library/doctest.rst:1065 msgid "Pass one or more paths (as strings) to text files to be examined." msgstr "" -#: ../../library/doctest.rst:1069 +#: ../../library/doctest.rst:1067 msgid "Options may be provided as keyword arguments:" msgstr "" -#: ../../library/doctest.rst:1071 +#: ../../library/doctest.rst:1069 msgid "" "Optional argument *module_relative* specifies how the filenames in *paths* " "should be interpreted:" msgstr "" -#: ../../library/doctest.rst:1074 +#: ../../library/doctest.rst:1072 msgid "" "If *module_relative* is ``True`` (the default), then each filename in " "*paths* specifies an OS-independent module-relative path. By default, this " @@ -1637,14 +1638,14 @@ msgid "" "``)." msgstr "" -#: ../../library/doctest.rst:1082 +#: ../../library/doctest.rst:1080 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:1086 +#: ../../library/doctest.rst:1084 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-" @@ -1654,7 +1655,7 @@ msgid "" "``False``." msgstr "" -#: ../../library/doctest.rst:1093 +#: ../../library/doctest.rst:1091 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 " @@ -1662,7 +1663,7 @@ msgid "" "the test globals as the :attr:`~DocTest.globs` attribute of the test passed." msgstr "" -#: ../../library/doctest.rst:1098 +#: ../../library/doctest.rst:1096 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* " @@ -1671,14 +1672,14 @@ msgid "" "test passed." msgstr "" -#: ../../library/doctest.rst:1104 +#: ../../library/doctest.rst:1102 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:1108 +#: ../../library/doctest.rst:1106 msgid "" "Optional argument *optionflags* specifies the default doctest options for " "the tests, created by or-ing together individual option flags. See section :" @@ -1686,71 +1687,76 @@ msgid "" "for a better way to set reporting options." msgstr "" -#: ../../library/doctest.rst:1120 +#: ../../library/doctest.rst:1118 msgid "" "The global ``__file__`` is added to the globals provided to doctests loaded " "from a text file using :func:`DocFileSuite`." msgstr "" -#: ../../library/doctest.rst:1126 +#: ../../library/doctest.rst:1121 ../../library/doctest.rst:1162 +msgid "Run each example as a :ref:`subtest `." +msgstr "" + +#: ../../library/doctest.rst:1127 msgid "Convert doctest tests for a module to a :class:`unittest.TestSuite`." msgstr "" -#: ../../library/doctest.rst:1128 +#: ../../library/doctest.rst:1129 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 " -"separate unit test. If any of the doctests fail, then the synthesized unit " -"test fails, and a :exc:`unittest.TestCase.failureException` exception is " -"raised showing the name of the file containing the test and a (sometimes " -"approximate) line number. If all the examples in a docstring are skipped, " -"then the" +"separate unit test, and each example in a docstring is run as a :ref:" +"`subtest `. If any of the doctests fail, then the synthesized unit " +"test fails. The traceback for failure or error contains the name of the file " +"containing the test and a (sometimes approximate) line number. If all the " +"examples in a docstring are skipped, then the synthesized unit test is also " +"marked as skipped." msgstr "" -#: ../../library/doctest.rst:1136 +#: ../../library/doctest.rst:1139 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:1140 +#: ../../library/doctest.rst:1143 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:1144 +#: ../../library/doctest.rst:1147 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:1147 +#: ../../library/doctest.rst:1150 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:1150 +#: ../../library/doctest.rst:1153 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:1153 +#: ../../library/doctest.rst:1156 msgid "This function uses the same search technique as :func:`testmod`." msgstr "" -#: ../../library/doctest.rst:1155 +#: ../../library/doctest.rst:1158 msgid "" ":func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if " "*module* contains no docstrings instead of raising :exc:`ValueError`." msgstr "" -#: ../../library/doctest.rst:1159 +#: ../../library/doctest.rst:1165 msgid "" "Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` " "out of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is " @@ -1759,14 +1765,14 @@ msgid "" "questions about the exact details of :mod:`unittest` integration." msgstr "" -#: ../../library/doctest.rst:1165 +#: ../../library/doctest.rst:1171 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:1169 +#: ../../library/doctest.rst:1175 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 :" @@ -1779,23 +1785,23 @@ msgid "" "pass options through :mod:`!unittest` to :mod:`!doctest` test runners." msgstr "" -#: ../../library/doctest.rst:1179 +#: ../../library/doctest.rst:1185 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:1185 +#: ../../library/doctest.rst:1191 msgid "Set the :mod:`!doctest` reporting flags to use." msgstr "" -#: ../../library/doctest.rst:1187 +#: ../../library/doctest.rst:1193 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:1190 +#: ../../library/doctest.rst:1196 msgid "" "This is a module-global setting, and affects all future doctests run by " "module :mod:`unittest`: the :meth:`!runTest` method of :class:`!" @@ -1809,17 +1815,17 @@ msgid "" "`!doctest`'s :mod:`!unittest` reporting flags are ignored." msgstr "" -#: ../../library/doctest.rst:1201 +#: ../../library/doctest.rst:1207 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:1208 +#: ../../library/doctest.rst:1214 msgid "Advanced API" msgstr "" -#: ../../library/doctest.rst:1210 +#: ../../library/doctest.rst:1216 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 " @@ -1827,62 +1833,62 @@ msgid "" "doctest's capabilities, then you should use the advanced API." msgstr "" -#: ../../library/doctest.rst:1215 +#: ../../library/doctest.rst:1221 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:1218 +#: ../../library/doctest.rst:1224 msgid "" ":class:`Example`: A single Python :term:`statement`, paired with its " "expected output." msgstr "" -#: ../../library/doctest.rst:1221 +#: ../../library/doctest.rst:1227 msgid "" ":class:`DocTest`: A collection of :class:`Example`\\ s, typically extracted " "from a single docstring or text file." msgstr "" -#: ../../library/doctest.rst:1224 +#: ../../library/doctest.rst:1230 msgid "" "Additional processing classes are defined to find, parse, and run, and check " "doctest examples:" msgstr "" -#: ../../library/doctest.rst:1227 +#: ../../library/doctest.rst:1233 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:1231 +#: ../../library/doctest.rst:1237 msgid "" ":class:`DocTestParser`: Creates a :class:`DocTest` object from a string " "(such as an object's docstring)." msgstr "" -#: ../../library/doctest.rst:1234 +#: ../../library/doctest.rst:1240 msgid "" ":class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and " "uses an :class:`OutputChecker` to verify their output." msgstr "" -#: ../../library/doctest.rst:1237 +#: ../../library/doctest.rst:1243 msgid "" ":class:`OutputChecker`: Compares the actual output from a doctest example " "with the expected output, and decides whether they match." msgstr "" -#: ../../library/doctest.rst:1240 +#: ../../library/doctest.rst:1246 msgid "" "The relationships among these processing classes are summarized in the " "following diagram::" msgstr "" -#: ../../library/doctest.rst:1243 +#: ../../library/doctest.rst:1249 msgid "" " list of:\n" "+------+ +---------+\n" @@ -1902,30 +1908,30 @@ msgstr "" " DocTestParser | Example | OutputChecker\n" " +---------+" -#: ../../library/doctest.rst:1256 +#: ../../library/doctest.rst:1262 msgid "DocTest Objects" msgstr "DocTest 物件" -#: ../../library/doctest.rst:1261 +#: ../../library/doctest.rst:1267 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:1265 +#: ../../library/doctest.rst:1271 msgid "" ":class:`DocTest` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1271 +#: ../../library/doctest.rst:1277 msgid "" "A list of :class:`Example` objects encoding the individual interactive " "Python examples that should be run by this test." msgstr "" -#: ../../library/doctest.rst:1277 +#: ../../library/doctest.rst:1283 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 " @@ -1933,57 +1939,57 @@ msgid "" "`globs` after the test is run." msgstr "" -#: ../../library/doctest.rst:1285 +#: ../../library/doctest.rst:1291 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:1291 +#: ../../library/doctest.rst:1297 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:1298 +#: ../../library/doctest.rst:1304 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:1305 +#: ../../library/doctest.rst:1311 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:1312 +#: ../../library/doctest.rst:1318 msgid "Example Objects" msgstr "Example 物件" -#: ../../library/doctest.rst:1317 +#: ../../library/doctest.rst:1323 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:1322 +#: ../../library/doctest.rst:1328 msgid "" ":class:`Example` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1328 +#: ../../library/doctest.rst:1334 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:1335 +#: ../../library/doctest.rst:1341 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 " @@ -1991,7 +1997,7 @@ msgid "" "The constructor adds a newline when necessary." msgstr "" -#: ../../library/doctest.rst:1343 +#: ../../library/doctest.rst:1349 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 " @@ -2000,20 +2006,20 @@ msgid "" "unless it's ``None``. The constructor adds a newline if needed." msgstr "" -#: ../../library/doctest.rst:1352 +#: ../../library/doctest.rst:1358 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:1359 +#: ../../library/doctest.rst:1365 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:1365 +#: ../../library/doctest.rst:1371 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 " @@ -2022,11 +2028,11 @@ msgid "" "default, no options are set." msgstr "" -#: ../../library/doctest.rst:1375 +#: ../../library/doctest.rst:1381 msgid "DocTestFinder objects" msgstr "DocTestFinder 物件" -#: ../../library/doctest.rst:1380 +#: ../../library/doctest.rst:1386 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 " @@ -2034,48 +2040,48 @@ msgid "" "classes, functions, methods, staticmethods, classmethods, and properties." msgstr "" -#: ../../library/doctest.rst:1385 +#: ../../library/doctest.rst:1391 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:1388 +#: ../../library/doctest.rst:1394 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:1391 +#: ../../library/doctest.rst:1397 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:1394 +#: ../../library/doctest.rst:1400 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:1398 +#: ../../library/doctest.rst:1404 msgid ":class:`DocTestFinder` defines the following method:" msgstr ":class:`DocTestFinder` 定義了以下方法:" -#: ../../library/doctest.rst:1403 +#: ../../library/doctest.rst:1409 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:1406 +#: ../../library/doctest.rst:1412 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:1410 +#: ../../library/doctest.rst:1416 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 " @@ -2083,26 +2089,26 @@ msgid "" "module is used:" msgstr "" -#: ../../library/doctest.rst:1414 +#: ../../library/doctest.rst:1420 msgid "As a default namespace, if *globs* is not specified." msgstr "" -#: ../../library/doctest.rst:1416 +#: ../../library/doctest.rst:1422 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:1420 +#: ../../library/doctest.rst:1426 msgid "To find the name of the file containing the object." msgstr "" -#: ../../library/doctest.rst:1422 +#: ../../library/doctest.rst:1428 msgid "To help find the line number of the object within its file." msgstr "" -#: ../../library/doctest.rst:1424 +#: ../../library/doctest.rst:1430 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 " @@ -2111,7 +2117,7 @@ msgid "" "contained objects will (recursively) be searched for doctests." msgstr "" -#: ../../library/doctest.rst:1430 +#: ../../library/doctest.rst:1436 msgid "" "The globals for each :class:`DocTest` is formed by combining *globs* and " "*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A new " @@ -2121,34 +2127,34 @@ msgid "" "is not specified, then it defaults to ``{}``." msgstr "" -#: ../../library/doctest.rst:1441 +#: ../../library/doctest.rst:1447 msgid "DocTestParser objects" msgstr "DocTestParser 物件" -#: ../../library/doctest.rst:1446 +#: ../../library/doctest.rst:1452 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:1450 +#: ../../library/doctest.rst:1456 msgid ":class:`DocTestParser` defines the following methods:" msgstr ":class:`DocTestParser` 定義了以下方法:" -#: ../../library/doctest.rst:1455 +#: ../../library/doctest.rst:1461 msgid "" "Extract all doctest examples from the given string, and collect them into a :" "class:`DocTest` object." msgstr "" -#: ../../library/doctest.rst:1458 +#: ../../library/doctest.rst:1464 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:1465 +#: ../../library/doctest.rst:1471 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 " @@ -2156,7 +2162,7 @@ msgid "" "error messages." msgstr "" -#: ../../library/doctest.rst:1472 +#: ../../library/doctest.rst:1478 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 " @@ -2164,33 +2170,33 @@ msgid "" "name identifying this string, and is only used for error messages." msgstr "" -#: ../../library/doctest.rst:1479 +#: ../../library/doctest.rst:1485 msgid "TestResults objects" msgstr "TestResults 物件" -#: ../../library/doctest.rst:1486 +#: ../../library/doctest.rst:1492 msgid "Number of failed tests." msgstr "失敗的測試數量。" -#: ../../library/doctest.rst:1490 +#: ../../library/doctest.rst:1496 msgid "Number of attempted tests." msgstr "嘗試的測試數量。" -#: ../../library/doctest.rst:1494 +#: ../../library/doctest.rst:1500 msgid "Number of skipped tests." msgstr "跳過的測試數量。" -#: ../../library/doctest.rst:1502 +#: ../../library/doctest.rst:1508 msgid "DocTestRunner objects" msgstr "DocTestRunner 物件" -#: ../../library/doctest.rst:1507 +#: ../../library/doctest.rst:1513 msgid "" "A processing class used to execute and verify the interactive examples in a :" "class:`DocTest`." msgstr "" -#: ../../library/doctest.rst:1510 +#: ../../library/doctest.rst:1516 msgid "" "The comparison between expected outputs and actual outputs is done by an :" "class:`OutputChecker`. This comparison may be customized with a number of " @@ -2200,25 +2206,25 @@ msgid "" "constructor." msgstr "" -#: ../../library/doctest.rst:1516 +#: ../../library/doctest.rst:1522 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 " "with strings that should be displayed. It defaults to ``sys.stdout." "write``. If capturing the output is not sufficient, then the display output " "can be also customized by subclassing DocTestRunner, and overriding the " -"methods :meth:`report_start`, :meth:`report_success`, :meth:" -"`report_unexpected_exception`, and :meth:`report_failure`." +"methods :meth:`report_skip`, :meth:`report_start`, :meth:`report_success`, :" +"meth:`report_unexpected_exception`, and :meth:`report_failure`." msgstr "" -#: ../../library/doctest.rst:1524 +#: ../../library/doctest.rst:1530 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:1528 +#: ../../library/doctest.rst:1534 msgid "" "The optional keyword argument *verbose* controls the :class:" "`DocTestRunner`'s verbosity. If *verbose* is ``True``, then information is " @@ -2227,14 +2233,14 @@ msgid "" "verbose output is used iff the command-line switch ``-v`` is used." msgstr "" -#: ../../library/doctest.rst:1534 +#: ../../library/doctest.rst:1540 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:1538 +#: ../../library/doctest.rst:1544 msgid "" "The test runner accumulates statistics. The aggregated number of attempted, " "failed and skipped examples is also available via the :attr:`tries`, :attr:" @@ -2242,53 +2248,60 @@ msgid "" "`summarize` methods return a :class:`TestResults` instance." msgstr "" -#: ../../library/doctest.rst:1543 +#: ../../library/doctest.rst:1549 msgid ":class:`DocTestRunner` defines the following methods:" msgstr ":class:`DocTestRunner` 定義了以下方法:" -#: ../../library/doctest.rst:1548 +#: ../../library/doctest.rst:1554 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." +"Report that the given example was skipped. 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:1558 ../../library/doctest.rst:1571 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:1559 +#: ../../library/doctest.rst:1567 +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:1578 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:1563 ../../library/doctest.rst:1574 +#: ../../library/doctest.rst:1582 ../../library/doctest.rst:1593 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:1570 +#: ../../library/doctest.rst:1589 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:1581 +#: ../../library/doctest.rst:1600 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:1585 +#: ../../library/doctest.rst:1604 msgid "" "*example* is the example about to be processed. *exc_info* is a tuple " "containing information about the unexpected exception (as returned by :func:" @@ -2296,14 +2309,14 @@ msgid "" "output function that was passed to :meth:`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1593 +#: ../../library/doctest.rst:1612 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:1597 +#: ../../library/doctest.rst:1616 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, " @@ -2311,54 +2324,54 @@ msgid "" "after the test completes, then use *clear_globs=False*." msgstr "" -#: ../../library/doctest.rst:1602 +#: ../../library/doctest.rst:1621 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:1606 +#: ../../library/doctest.rst:1625 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:1613 +#: ../../library/doctest.rst:1632 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:1616 +#: ../../library/doctest.rst:1635 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:1620 +#: ../../library/doctest.rst:1639 msgid ":class:`DocTestParser` has the following attributes:" msgstr ":class:`DocTestParser` 有以下屬性:" -#: ../../library/doctest.rst:1624 +#: ../../library/doctest.rst:1643 msgid "Number of attempted examples." msgstr "嘗試的範例數量。" -#: ../../library/doctest.rst:1628 +#: ../../library/doctest.rst:1647 msgid "Number of failed examples." msgstr "失敗的範例數量。" -#: ../../library/doctest.rst:1632 +#: ../../library/doctest.rst:1651 msgid "Number of skipped examples." msgstr "跳過的範例數量。" -#: ../../library/doctest.rst:1640 +#: ../../library/doctest.rst:1659 msgid "OutputChecker objects" msgstr "OutputChecker 物件" -#: ../../library/doctest.rst:1645 +#: ../../library/doctest.rst:1664 msgid "" "A class used to check the whether the actual output from a doctest example " "matches the expected output. :class:`OutputChecker` defines two methods: :" @@ -2367,11 +2380,11 @@ msgid "" "string describing the differences between two outputs." msgstr "" -#: ../../library/doctest.rst:1652 +#: ../../library/doctest.rst:1671 msgid ":class:`OutputChecker` defines the following methods:" msgstr ":class:`OutputChecker` 定義了以下方法:" -#: ../../library/doctest.rst:1656 +#: ../../library/doctest.rst:1675 msgid "" "Return ``True`` iff the actual output from an example (*got*) matches the " "expected output (*want*). These strings are always considered to match if " @@ -2380,28 +2393,28 @@ msgid "" "`doctest-options` for more information about option flags." msgstr "" -#: ../../library/doctest.rst:1665 +#: ../../library/doctest.rst:1684 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:1673 +#: ../../library/doctest.rst:1692 msgid "Debugging" msgstr "偵錯" -#: ../../library/doctest.rst:1675 +#: ../../library/doctest.rst:1694 msgid "Doctest provides several mechanisms for debugging doctest examples:" msgstr "Doctest 提供了幾種偵錯 doctest 範例的機制:" -#: ../../library/doctest.rst:1677 +#: ../../library/doctest.rst:1696 msgid "" "Several functions convert doctests to executable Python programs, which can " "be run under the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1680 +#: ../../library/doctest.rst:1699 msgid "" "The :class:`DebugRunner` class is a subclass of :class:`DocTestRunner` that " "raises an exception for the first failing example, containing information " @@ -2409,13 +2422,13 @@ msgid "" "debugging on the example." msgstr "" -#: ../../library/doctest.rst:1685 +#: ../../library/doctest.rst:1704 msgid "" "The :mod:`unittest` cases generated by :func:`DocTestSuite` support the :" "meth:`debug` method defined by :class:`unittest.TestCase`." msgstr "" -#: ../../library/doctest.rst:1688 +#: ../../library/doctest.rst:1707 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 " @@ -2423,7 +2436,7 @@ msgid "" "`a.py` contains just this module docstring::" msgstr "" -#: ../../library/doctest.rst:1693 +#: ../../library/doctest.rst:1712 msgid "" "\"\"\"\n" ">>> def f(x):\n" @@ -2445,11 +2458,11 @@ msgstr "" "9\n" "\"\"\"" -#: ../../library/doctest.rst:1703 +#: ../../library/doctest.rst:1722 msgid "Then an interactive Python session may look like this::" msgstr "" -#: ../../library/doctest.rst:1705 +#: ../../library/doctest.rst:1724 msgid "" ">>> import a, doctest\n" ">>> doctest.testmod(a)\n" @@ -2511,17 +2524,17 @@ msgstr "" "(0, 3)\n" ">>>" -#: ../../library/doctest.rst:1736 +#: ../../library/doctest.rst:1755 msgid "" "Functions that convert doctests to Python code, and possibly run the " "synthesized code under the debugger:" msgstr "" -#: ../../library/doctest.rst:1742 +#: ../../library/doctest.rst:1761 msgid "Convert text with examples to a script." msgstr "" -#: ../../library/doctest.rst:1744 +#: ../../library/doctest.rst:1763 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 " @@ -2529,7 +2542,7 @@ msgid "" "generated script is returned as a string. For example, ::" msgstr "" -#: ../../library/doctest.rst:1749 +#: ../../library/doctest.rst:1768 msgid "" "import doctest\n" "print(doctest.script_from_examples(r\"\"\"\n" @@ -2542,11 +2555,11 @@ msgid "" "\"\"\"))" msgstr "" -#: ../../library/doctest.rst:1759 +#: ../../library/doctest.rst:1778 msgid "displays::" msgstr "" -#: ../../library/doctest.rst:1761 +#: ../../library/doctest.rst:1780 msgid "" "# Set x and y to 1 and 2.\n" "x, y = 1, 2\n" @@ -2557,18 +2570,18 @@ msgid "" "## 3" msgstr "" -#: ../../library/doctest.rst:1769 +#: ../../library/doctest.rst:1788 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:1776 +#: ../../library/doctest.rst:1795 msgid "Convert the doctest for an object to a script." msgstr "" -#: ../../library/doctest.rst:1778 +#: ../../library/doctest.rst:1797 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 " @@ -2578,7 +2591,7 @@ msgid "" "module :file:`a.py` contains a top-level function :func:`!f`, then ::" msgstr "" -#: ../../library/doctest.rst:1785 +#: ../../library/doctest.rst:1804 msgid "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" @@ -2586,17 +2599,17 @@ msgstr "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" -#: ../../library/doctest.rst:1788 +#: ../../library/doctest.rst:1807 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:1794 +#: ../../library/doctest.rst:1813 msgid "Debug the doctests for an object." msgstr "" -#: ../../library/doctest.rst:1796 +#: ../../library/doctest.rst:1815 msgid "" "The *module* and *name* arguments are the same as for function :func:" "`testsource` above. The synthesized Python script for the named object's " @@ -2604,13 +2617,13 @@ msgid "" "the control of the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1801 +#: ../../library/doctest.rst:1820 msgid "" "A shallow copy of ``module.__dict__`` is used for both local and global " "execution context." msgstr "" -#: ../../library/doctest.rst:1804 +#: ../../library/doctest.rst:1823 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 " @@ -2622,30 +2635,30 @@ msgid "" "to :func:`pdb.run`." msgstr "" -#: ../../library/doctest.rst:1815 +#: ../../library/doctest.rst:1834 msgid "Debug the doctests in a string." msgstr "" -#: ../../library/doctest.rst:1817 +#: ../../library/doctest.rst:1836 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:1820 +#: ../../library/doctest.rst:1839 msgid "" "Optional argument *pm* has the same meaning as in function :func:`debug` " "above." msgstr "" -#: ../../library/doctest.rst:1822 +#: ../../library/doctest.rst:1841 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:1827 +#: ../../library/doctest.rst:1846 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 " @@ -2653,7 +2666,7 @@ msgid "" "(which is a doctest!) for more details:" msgstr "" -#: ../../library/doctest.rst:1835 +#: ../../library/doctest.rst:1854 msgid "" "A subclass of :class:`DocTestRunner` that raises an exception as soon as a " "failure is encountered. If an unexpected exception occurs, an :exc:" @@ -2663,89 +2676,89 @@ msgid "" "the actual output." msgstr "" -#: ../../library/doctest.rst:1842 +#: ../../library/doctest.rst:1861 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:1845 +#: ../../library/doctest.rst:1864 msgid "" "There are two exceptions that may be raised by :class:`DebugRunner` " "instances:" msgstr "" -#: ../../library/doctest.rst:1850 +#: ../../library/doctest.rst:1869 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:1854 +#: ../../library/doctest.rst:1873 msgid ":exc:`DocTestFailure` defines the following attributes:" msgstr ":exc:`DocTestFailure` 定義了以下屬性:" -#: ../../library/doctest.rst:1859 ../../library/doctest.rst:1883 +#: ../../library/doctest.rst:1878 ../../library/doctest.rst:1902 msgid "The :class:`DocTest` object that was being run when the example failed." msgstr "" -#: ../../library/doctest.rst:1864 ../../library/doctest.rst:1888 +#: ../../library/doctest.rst:1883 ../../library/doctest.rst:1907 msgid "The :class:`Example` that failed." msgstr "" -#: ../../library/doctest.rst:1869 +#: ../../library/doctest.rst:1888 msgid "The example's actual output." msgstr "" -#: ../../library/doctest.rst:1874 +#: ../../library/doctest.rst:1893 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:1878 +#: ../../library/doctest.rst:1897 msgid ":exc:`UnexpectedException` defines the following attributes:" msgstr ":exc:`UnexpectedException` 定義了以下屬性:" -#: ../../library/doctest.rst:1893 +#: ../../library/doctest.rst:1912 msgid "" "A tuple containing information about the unexpected exception, as returned " "by :func:`sys.exc_info`." msgstr "" -#: ../../library/doctest.rst:1900 +#: ../../library/doctest.rst:1919 msgid "Soapbox" msgstr "" -#: ../../library/doctest.rst:1902 +#: ../../library/doctest.rst:1921 msgid "" "As mentioned in the introduction, :mod:`!doctest` has grown to have three " "primary uses:" msgstr "" -#: ../../library/doctest.rst:1905 +#: ../../library/doctest.rst:1924 msgid "Checking examples in docstrings." msgstr "" -#: ../../library/doctest.rst:1907 +#: ../../library/doctest.rst:1926 msgid "Regression testing." msgstr "回歸測試。" -#: ../../library/doctest.rst:1909 +#: ../../library/doctest.rst:1928 msgid "Executable documentation / literate testing." msgstr "" -#: ../../library/doctest.rst:1911 +#: ../../library/doctest.rst:1930 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:1915 +#: ../../library/doctest.rst:1934 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. " @@ -2757,7 +2770,7 @@ msgid "" "\"harmless\" change." msgstr "" -#: ../../library/doctest.rst:1923 +#: ../../library/doctest.rst:1942 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 " @@ -2778,13 +2791,13 @@ msgid "" "different results, blurring the distinction between testing and explaining." msgstr "" -#: ../../library/doctest.rst:1941 +#: ../../library/doctest.rst:1960 msgid "" "Regression testing is best confined to dedicated objects or files. There " "are several options for organizing tests:" msgstr "" -#: ../../library/doctest.rst:1944 +#: ../../library/doctest.rst:1963 msgid "" "Write text files containing test cases as interactive examples, and test the " "files using :func:`testfile` or :func:`DocFileSuite`. This is recommended, " @@ -2792,7 +2805,7 @@ msgid "" "doctest." msgstr "" -#: ../../library/doctest.rst:1949 +#: ../../library/doctest.rst:1968 msgid "" "Define functions named ``_regrtest_topic`` that consist of single " "docstrings, containing test cases for the named topics. These functions can " @@ -2800,13 +2813,13 @@ msgid "" "test file." msgstr "" -#: ../../library/doctest.rst:1953 +#: ../../library/doctest.rst:1972 msgid "" "Define a :attr:`~module.__test__` dictionary mapping from regression test " "topics to docstrings containing test cases." msgstr "" -#: ../../library/doctest.rst:1956 +#: ../../library/doctest.rst:1975 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-" @@ -2814,7 +2827,7 @@ msgid "" "example of such a test runner::" msgstr "" -#: ../../library/doctest.rst:1961 +#: ../../library/doctest.rst:1980 msgid "" "if __name__ == '__main__':\n" " import doctest\n" @@ -2846,54 +2859,54 @@ msgstr "" " fail, total = doctest.testmod(optionflags=flags)\n" " print(f\"{fail} failures out of {total} tests\")" -#: ../../library/doctest.rst:1978 +#: ../../library/doctest.rst:1997 msgid "Footnotes" msgstr "註腳" -#: ../../library/doctest.rst:1979 +#: ../../library/doctest.rst:1998 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:387 +#: ../../library/doctest.rst:382 msgid ">>>" msgstr ">>>" -#: ../../library/doctest.rst:387 +#: ../../library/doctest.rst:382 msgid "interpreter prompt" msgstr "interpreter prompt(直譯器提示)" -#: ../../library/doctest.rst:387 ../../library/doctest.rst:622 +#: ../../library/doctest.rst:382 ../../library/doctest.rst:617 msgid "..." msgstr "..." -#: ../../library/doctest.rst:553 +#: ../../library/doctest.rst:548 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../library/doctest.rst:553 +#: ../../library/doctest.rst:548 msgid "marker" msgstr "marker(標記)" -#: ../../library/doctest.rst:602 +#: ../../library/doctest.rst:597 msgid "" msgstr "" -#: ../../library/doctest.rst:622 ../../library/doctest.rst:747 +#: ../../library/doctest.rst:617 ../../library/doctest.rst:742 msgid "in doctests" msgstr "於 doctests 中" -#: ../../library/doctest.rst:747 +#: ../../library/doctest.rst:742 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/doctest.rst:747 +#: ../../library/doctest.rst:742 msgid "+ (plus)" msgstr "+ (加號)" -#: ../../library/doctest.rst:747 +#: ../../library/doctest.rst:742 msgid "- (minus)" msgstr "- (減號)" diff --git a/library/email.contentmanager.po b/library/email.contentmanager.po index 4d551feb51b..f0ae9d71d68 100644 --- a/library/email.contentmanager.po +++ b/library/email.contentmanager.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-13 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,22 +21,22 @@ msgstr "" msgid ":mod:`!email.contentmanager`: Managing MIME Content" msgstr ":mod:`!email.contentmanager`:管理 MIME 內容" -#: ../../library/email.contentmanager.rst:10 +#: ../../library/email.contentmanager.rst:7 msgid "**Source code:** :source:`Lib/email/contentmanager.py`" msgstr "**原始碼:**\\ :source:`Lib/email/contentmanager.py`" -#: ../../library/email.contentmanager.rst:14 +#: ../../library/email.contentmanager.rst:11 msgid "[1]_" msgstr "[1]_" -#: ../../library/email.contentmanager.rst:19 +#: ../../library/email.contentmanager.rst:16 msgid "" "Base class for content managers. Provides the standard registry mechanisms " "to register converters between MIME content and other representations, as " "well as the ``get_content`` and ``set_content`` dispatch methods." msgstr "" -#: ../../library/email.contentmanager.rst:26 +#: ../../library/email.contentmanager.rst:23 msgid "" "Look up a handler function based on the ``mimetype`` of *msg* (see next " "paragraph), call it, passing through all arguments, and return the result of " @@ -44,31 +44,31 @@ msgid "" "*msg* and return an object that encodes information about the extracted data." msgstr "" -#: ../../library/email.contentmanager.rst:32 +#: ../../library/email.contentmanager.rst:29 msgid "" "To find the handler, look for the following keys in the registry, stopping " "with the first one found:" msgstr "" -#: ../../library/email.contentmanager.rst:35 +#: ../../library/email.contentmanager.rst:32 msgid "the string representing the full MIME type (``maintype/subtype``)" msgstr "" -#: ../../library/email.contentmanager.rst:36 +#: ../../library/email.contentmanager.rst:33 msgid "the string representing the ``maintype``" msgstr "" -#: ../../library/email.contentmanager.rst:37 +#: ../../library/email.contentmanager.rst:34 msgid "the empty string" msgstr "" -#: ../../library/email.contentmanager.rst:39 +#: ../../library/email.contentmanager.rst:36 msgid "" "If none of these keys produce a handler, raise a :exc:`KeyError` for the " "full MIME type." msgstr "" -#: ../../library/email.contentmanager.rst:45 +#: ../../library/email.contentmanager.rst:42 msgid "" "If the ``maintype`` is ``multipart``, raise a :exc:`TypeError`; otherwise " "look up a handler function based on the type of *obj* (see next paragraph), " @@ -79,32 +79,32 @@ msgid "" "to encode information needed to interpret the stored data." msgstr "" -#: ../../library/email.contentmanager.rst:54 +#: ../../library/email.contentmanager.rst:51 msgid "" "To find the handler, obtain the type of *obj* (``typ = type(obj)``), and " "look for the following keys in the registry, stopping with the first one " "found:" msgstr "" -#: ../../library/email.contentmanager.rst:58 +#: ../../library/email.contentmanager.rst:55 msgid "the type itself (``typ``)" msgstr "" -#: ../../library/email.contentmanager.rst:59 +#: ../../library/email.contentmanager.rst:56 msgid "" "the type's fully qualified name (``typ.__module__ + '.' + typ." "__qualname__``)." msgstr "" -#: ../../library/email.contentmanager.rst:61 +#: ../../library/email.contentmanager.rst:58 msgid "the type's :attr:`qualname ` (``typ.__qualname__``)" msgstr "" -#: ../../library/email.contentmanager.rst:62 +#: ../../library/email.contentmanager.rst:59 msgid "the type's :attr:`name ` (``typ.__name__``)." msgstr "" -#: ../../library/email.contentmanager.rst:64 +#: ../../library/email.contentmanager.rst:61 msgid "" "If none of the above match, repeat all of the checks above for each of the " "types in the :term:`MRO` (:attr:`typ.__mro__ `). Finally, if " @@ -113,30 +113,30 @@ msgid "" "qualified name of the type." msgstr "" -#: ../../library/email.contentmanager.rst:71 +#: ../../library/email.contentmanager.rst:68 msgid "" "Also add a :mailheader:`MIME-Version` header if one is not present (see " "also :class:`.MIMEPart`)." msgstr "" -#: ../../library/email.contentmanager.rst:77 +#: ../../library/email.contentmanager.rst:74 msgid "" "Record the function *handler* as the handler for *key*. For the possible " "values of *key*, see :meth:`get_content`." msgstr "" -#: ../../library/email.contentmanager.rst:83 +#: ../../library/email.contentmanager.rst:80 msgid "" "Record *handler* as the function to call when an object of a type matching " "*typekey* is passed to :meth:`set_content`. For the possible values of " "*typekey*, see :meth:`set_content`." msgstr "" -#: ../../library/email.contentmanager.rst:89 +#: ../../library/email.contentmanager.rst:86 msgid "Content Manager Instances" msgstr "" -#: ../../library/email.contentmanager.rst:91 +#: ../../library/email.contentmanager.rst:88 msgid "" "Currently the email package provides only one concrete content manager, :" "data:`raw_data_manager`, although more may be added in the future. :data:" @@ -144,7 +144,7 @@ msgid "" "provided by :attr:`~email.policy.EmailPolicy` and its derivatives." msgstr "" -#: ../../library/email.contentmanager.rst:100 +#: ../../library/email.contentmanager.rst:97 msgid "" "This content manager provides only a minimum interface beyond that provided " "by :class:`~email.message.Message` itself: it deals only with text, raw " @@ -157,7 +157,7 @@ msgid "" "the creation of multipart messages." msgstr "" -#: ../../library/email.contentmanager.rst:112 +#: ../../library/email.contentmanager.rst:109 msgid "" "Return the payload of the part as either a string (for ``text`` parts), an :" "class:`~email.message.EmailMessage` object (for ``message/rfc822`` parts), " @@ -167,28 +167,28 @@ msgid "" "to a string. The default error handler is ``replace``." msgstr "" -#: ../../library/email.contentmanager.rst:131 +#: ../../library/email.contentmanager.rst:128 msgid "Add headers and payload to *msg*:" msgstr "" -#: ../../library/email.contentmanager.rst:133 +#: ../../library/email.contentmanager.rst:130 msgid "" "Add a :mailheader:`Content-Type` header with a ``maintype/subtype`` value." msgstr "" -#: ../../library/email.contentmanager.rst:136 +#: ../../library/email.contentmanager.rst:133 msgid "" "For ``str``, set the MIME ``maintype`` to ``text``, and set the subtype to " "*subtype* if it is specified, or ``plain`` if it is not." msgstr "" -#: ../../library/email.contentmanager.rst:138 +#: ../../library/email.contentmanager.rst:135 msgid "" "For ``bytes``, use the specified *maintype* and *subtype*, or raise a :exc:" "`TypeError` if they are not specified." msgstr "" -#: ../../library/email.contentmanager.rst:140 +#: ../../library/email.contentmanager.rst:137 msgid "" "For :class:`~email.message.EmailMessage` objects, set the maintype to " "``message``, and set the subtype to *subtype* if it is specified or " @@ -196,7 +196,7 @@ msgid "" "(``bytes`` objects must be used to construct ``message/partial`` parts)." msgstr "" -#: ../../library/email.contentmanager.rst:146 +#: ../../library/email.contentmanager.rst:143 msgid "" "If *charset* is provided (which is valid only for ``str``), encode the " "string to bytes using the specified character set. The default is " @@ -204,7 +204,7 @@ msgid "" "charset name, use the standard charset instead." msgstr "" -#: ../../library/email.contentmanager.rst:151 +#: ../../library/email.contentmanager.rst:148 msgid "" "If *cte* is set, encode the payload using the specified content transfer " "encoding, and set the :mailheader:`Content-Transfer-Encoding` header to that " @@ -214,7 +214,7 @@ msgid "" "that contains non-ASCII values), raise a :exc:`ValueError`." msgstr "" -#: ../../library/email.contentmanager.rst:159 +#: ../../library/email.contentmanager.rst:156 msgid "" "For ``str`` objects, if *cte* is not set use heuristics to determine the " "most compact encoding. Prior to encoding, :meth:`str.splitlines` is used to " @@ -223,13 +223,13 @@ msgid "" "property (even if the original string did not end with one)." msgstr "" -#: ../../library/email.contentmanager.rst:165 +#: ../../library/email.contentmanager.rst:162 msgid "" "For ``bytes`` objects, *cte* is taken to be base64 if not set, and the " "aforementioned newline translation is not performed." msgstr "" -#: ../../library/email.contentmanager.rst:167 +#: ../../library/email.contentmanager.rst:164 msgid "" "For :class:`~email.message.EmailMessage`, per :rfc:`2046`, raise an error if " "a *cte* of ``quoted-printable`` or ``base64`` is requested for *subtype* " @@ -238,14 +238,14 @@ msgid "" "For all other values of *subtype*, use ``7bit``." msgstr "" -#: ../../library/email.contentmanager.rst:174 +#: ../../library/email.contentmanager.rst:171 msgid "" "A *cte* of ``binary`` does not actually work correctly yet. The " "``EmailMessage`` object as modified by ``set_content`` is correct, but :" "class:`~email.generator.BytesGenerator` does not serialize it correctly." msgstr "" -#: ../../library/email.contentmanager.rst:179 +#: ../../library/email.contentmanager.rst:176 msgid "" "If *disposition* is set, use it as the value of the :mailheader:`Content-" "Disposition` header. If not specified, and *filename* is specified, add the " @@ -254,37 +254,37 @@ msgid "" "values for *disposition* are ``attachment`` and ``inline``." msgstr "" -#: ../../library/email.contentmanager.rst:186 +#: ../../library/email.contentmanager.rst:183 msgid "" "If *filename* is specified, use it as the value of the ``filename`` " "parameter of the :mailheader:`Content-Disposition` header." msgstr "" -#: ../../library/email.contentmanager.rst:189 +#: ../../library/email.contentmanager.rst:186 msgid "" "If *cid* is specified, add a :mailheader:`Content-ID` header with *cid* as " "its value." msgstr "" -#: ../../library/email.contentmanager.rst:192 +#: ../../library/email.contentmanager.rst:189 msgid "" "If *params* is specified, iterate its ``items`` method and use the resulting " "``(key, value)`` pairs to set additional parameters on the :mailheader:" "`Content-Type` header." msgstr "" -#: ../../library/email.contentmanager.rst:196 +#: ../../library/email.contentmanager.rst:193 msgid "" "If *headers* is specified and is a list of strings of the form ``headername: " "headervalue`` or a list of ``header`` objects (distinguished from strings by " "having a ``name`` attribute), add the headers to *msg*." msgstr "" -#: ../../library/email.contentmanager.rst:203 +#: ../../library/email.contentmanager.rst:200 msgid "Footnotes" msgstr "註解" -#: ../../library/email.contentmanager.rst:204 +#: ../../library/email.contentmanager.rst:201 msgid "" "Originally added in 3.4 as a :term:`provisional module `" msgstr "" diff --git a/library/email.headerregistry.po b/library/email.headerregistry.po index 85412a47851..bfffe205929 100644 --- a/library/email.headerregistry.po +++ b/library/email.headerregistry.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-13 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,15 +21,15 @@ msgstr "" msgid ":mod:`!email.headerregistry`: Custom Header Objects" msgstr ":mod:`!email.headerregistry`:自訂標頭物件" -#: ../../library/email.headerregistry.rst:10 +#: ../../library/email.headerregistry.rst:7 msgid "**Source code:** :source:`Lib/email/headerregistry.py`" msgstr "**原始碼:**\\ :source:`Lib/email/headerregistry.py`" -#: ../../library/email.headerregistry.rst:14 +#: ../../library/email.headerregistry.rst:11 msgid "[1]_" msgstr "[1]_" -#: ../../library/email.headerregistry.rst:16 +#: ../../library/email.headerregistry.rst:13 msgid "" "Headers are represented by customized subclasses of :class:`str`. The " "particular class used to represent a given header is determined by the :attr:" @@ -41,7 +41,7 @@ msgid "" "applications to add their own custom header types." msgstr "" -#: ../../library/email.headerregistry.rst:25 +#: ../../library/email.headerregistry.rst:22 msgid "" "When using any of the policy objects derived from :data:`~email.policy." "EmailPolicy`, all headers are produced by :class:`.HeaderRegistry` and have :" @@ -55,7 +55,7 @@ msgid "" "behavior for use by more complex applications." msgstr "" -#: ../../library/email.headerregistry.rst:36 +#: ../../library/email.headerregistry.rst:33 msgid "" "The sections below first document the header base classes and their " "attributes, followed by the API for modifying the behavior of :class:`." @@ -63,25 +63,25 @@ msgid "" "parsed from structured headers." msgstr "" -#: ../../library/email.headerregistry.rst:44 +#: ../../library/email.headerregistry.rst:41 msgid "" "*name* and *value* are passed to ``BaseHeader`` from the :attr:`~email." "policy.EmailPolicy.header_factory` call. The string value of any header " "object is the *value* fully decoded to a string." msgstr "" -#: ../../library/email.headerregistry.rst:48 +#: ../../library/email.headerregistry.rst:45 msgid "This base class defines the following read-only properties:" msgstr "這個基底類別定義了以下唯讀屬性:" -#: ../../library/email.headerregistry.rst:53 +#: ../../library/email.headerregistry.rst:50 msgid "" "The name of the header (the portion of the field before the ':'). This is " "exactly the value passed in the :attr:`~email.policy.EmailPolicy." "header_factory` call for *name*; that is, case is preserved." msgstr "" -#: ../../library/email.headerregistry.rst:61 +#: ../../library/email.headerregistry.rst:58 msgid "" "A tuple of :exc:`~email.errors.HeaderDefect` instances reporting any RFC " "compliance problems found during parsing. The email package tries to be " @@ -89,7 +89,7 @@ msgid "" "module for a discussion of the types of defects that may be reported." msgstr "" -#: ../../library/email.headerregistry.rst:69 +#: ../../library/email.headerregistry.rst:66 msgid "" "The maximum number of headers of this type that can have the same ``name``. " "A value of ``None`` means unlimited. The ``BaseHeader`` value for this " @@ -97,14 +97,14 @@ msgid "" "override this value as needed." msgstr "" -#: ../../library/email.headerregistry.rst:74 +#: ../../library/email.headerregistry.rst:71 msgid "" "``BaseHeader`` also provides the following method, which is called by the " "email library code and should not in general be called by application " "programs:" msgstr "" -#: ../../library/email.headerregistry.rst:80 +#: ../../library/email.headerregistry.rst:77 msgid "" "Return a string containing :attr:`~email.policy.Policy.linesep` characters " "as required to correctly fold the header according to *policy*. A :attr:" @@ -114,7 +114,7 @@ msgid "" "`2047` encoded." msgstr "" -#: ../../library/email.headerregistry.rst:88 +#: ../../library/email.headerregistry.rst:85 msgid "" "``BaseHeader`` by itself cannot be used to create a header object. It " "defines a protocol that each specialized header cooperates with in order to " @@ -123,11 +123,11 @@ msgid "" "method is called as follows::" msgstr "" -#: ../../library/email.headerregistry.rst:94 +#: ../../library/email.headerregistry.rst:91 msgid "parse(string, kwds)" msgstr "parse(string, kwds)" -#: ../../library/email.headerregistry.rst:96 +#: ../../library/email.headerregistry.rst:93 msgid "" "``kwds`` is a dictionary containing one pre-initialized key, ``defects``. " "``defects`` is an empty list. The parse method should append any detected " @@ -141,7 +141,7 @@ msgid "" "header values." msgstr "" -#: ../../library/email.headerregistry.rst:106 +#: ../../library/email.headerregistry.rst:103 msgid "" "``BaseHeader``'s ``__new__`` then creates the header instance, and calls its " "``init`` method. The specialized class only needs to provide an ``init`` " @@ -149,7 +149,7 @@ msgid "" "``BaseHeader`` itself. Such an ``init`` method should look like this::" msgstr "" -#: ../../library/email.headerregistry.rst:111 +#: ../../library/email.headerregistry.rst:108 msgid "" "def init(self, /, *args, **kw):\n" " self._myattr = kw.pop('myattr')\n" @@ -159,14 +159,14 @@ msgstr "" " self._myattr = kw.pop('myattr')\n" " super().init(*args, **kw)" -#: ../../library/email.headerregistry.rst:115 +#: ../../library/email.headerregistry.rst:112 msgid "" "That is, anything extra that the specialized class puts in to the ``kwds`` " "dictionary should be removed and handled, and the remaining contents of " "``kw`` (and ``args``) passed to the ``BaseHeader`` ``init`` method." msgstr "" -#: ../../library/email.headerregistry.rst:122 +#: ../../library/email.headerregistry.rst:119 msgid "" "An \"unstructured\" header is the default type of header in :rfc:`5322`. Any " "header that does not have a specified syntax is treated as unstructured. " @@ -174,7 +174,7 @@ msgid "" "header." msgstr "" -#: ../../library/email.headerregistry.rst:127 +#: ../../library/email.headerregistry.rst:124 msgid "" "In :rfc:`5322`, an unstructured header is a run of arbitrary text in the " "ASCII character set. :rfc:`2047`, however, has an :rfc:`5322` compatible " @@ -187,11 +187,11 @@ msgid "" "such as invalid characters within the encoded words or the non-encoded text." msgstr "" -#: ../../library/email.headerregistry.rst:137 +#: ../../library/email.headerregistry.rst:134 msgid "This header type provides no additional attributes." msgstr "" -#: ../../library/email.headerregistry.rst:142 +#: ../../library/email.headerregistry.rst:139 msgid "" ":rfc:`5322` specifies a very specific format for dates within email headers. " "The ``DateHeader`` parser recognizes that date format, as well as " @@ -199,12 +199,12 @@ msgid "" "wild\"." msgstr "" -#: ../../library/email.headerregistry.rst:147 -#: ../../library/email.headerregistry.rst:189 +#: ../../library/email.headerregistry.rst:144 +#: ../../library/email.headerregistry.rst:186 msgid "This header type provides the following additional attributes:" msgstr "" -#: ../../library/email.headerregistry.rst:151 +#: ../../library/email.headerregistry.rst:148 msgid "" "If the header value can be recognized as a valid date of one form or " "another, this attribute will contain a :class:`~datetime.datetime` instance " @@ -216,28 +216,28 @@ msgid "" "`datetime.timezone` to record the timezone offset." msgstr "" -#: ../../library/email.headerregistry.rst:161 +#: ../../library/email.headerregistry.rst:158 msgid "" "The ``decoded`` value of the header is determined by formatting the " "``datetime`` according to the :rfc:`5322` rules; that is, it is set to::" msgstr "" -#: ../../library/email.headerregistry.rst:164 +#: ../../library/email.headerregistry.rst:161 msgid "email.utils.format_datetime(self.datetime)" msgstr "" -#: ../../library/email.headerregistry.rst:166 +#: ../../library/email.headerregistry.rst:163 msgid "" "When creating a ``DateHeader``, *value* may be :class:`~datetime.datetime` " "instance. This means, for example, that the following code is valid and " "does what one would expect::" msgstr "" -#: ../../library/email.headerregistry.rst:170 +#: ../../library/email.headerregistry.rst:167 msgid "msg['Date'] = datetime(2011, 7, 15, 21)" msgstr "msg['Date'] = datetime(2011, 7, 15, 21)" -#: ../../library/email.headerregistry.rst:172 +#: ../../library/email.headerregistry.rst:169 msgid "" "Because this is a naive ``datetime`` it will be interpreted as a UTC " "timestamp, and the resulting value will have a timezone of ``-0000``. Much " @@ -245,23 +245,23 @@ msgid "" "mod:`~email.utils` module::" msgstr "" -#: ../../library/email.headerregistry.rst:177 +#: ../../library/email.headerregistry.rst:174 msgid "msg['Date'] = utils.localtime()" msgstr "msg['Date'] = utils.localtime()" -#: ../../library/email.headerregistry.rst:179 +#: ../../library/email.headerregistry.rst:176 msgid "" "This example sets the date header to the current time and date using the " "current timezone offset." msgstr "" -#: ../../library/email.headerregistry.rst:185 +#: ../../library/email.headerregistry.rst:182 msgid "" "Address headers are one of the most complex structured header types. The " "``AddressHeader`` class provides a generic interface to any address header." msgstr "" -#: ../../library/email.headerregistry.rst:194 +#: ../../library/email.headerregistry.rst:191 msgid "" "A tuple of :class:`.Group` objects encoding the addresses and groups found " "in the header value. Addresses that are not part of a group are represented " @@ -269,7 +269,7 @@ msgid "" "is ``None``." msgstr "" -#: ../../library/email.headerregistry.rst:202 +#: ../../library/email.headerregistry.rst:199 msgid "" "A tuple of :class:`.Address` objects encoding all of the individual " "addresses from the header value. If the header value contains any groups, " @@ -278,7 +278,7 @@ msgid "" "\"flattened\" into a one dimensional list)." msgstr "" -#: ../../library/email.headerregistry.rst:208 +#: ../../library/email.headerregistry.rst:205 msgid "" "The ``decoded`` value of the header will have all encoded words decoded to a " "string. :class:`~encodings.idna` encoded domain names are also decoded to a " @@ -286,7 +286,7 @@ msgid "" "class:`str` value of the elements of the ``groups`` attribute with ``', '``." msgstr "" -#: ../../library/email.headerregistry.rst:214 +#: ../../library/email.headerregistry.rst:211 msgid "" "A list of :class:`.Address` and :class:`.Group` objects in any combination " "may be used to set the value of an address header. ``Group`` objects whose " @@ -295,12 +295,12 @@ msgid "" "obtained from the ``groups`` attribute of the source header." msgstr "" -#: ../../library/email.headerregistry.rst:223 +#: ../../library/email.headerregistry.rst:220 msgid "" "A subclass of :class:`.AddressHeader` that adds one additional attribute:" msgstr "" -#: ../../library/email.headerregistry.rst:229 +#: ../../library/email.headerregistry.rst:226 msgid "" "The single address encoded by the header value. If the header value " "actually contains more than one address (which would be a violation of the " @@ -308,14 +308,14 @@ msgid "" "result in a :exc:`ValueError`." msgstr "" -#: ../../library/email.headerregistry.rst:235 +#: ../../library/email.headerregistry.rst:232 msgid "" "Many of the above classes also have a ``Unique`` variant (for example, " "``UniqueUnstructuredHeader``). The only difference is that in the " "``Unique`` variant, :attr:`~.BaseHeader.max_count` is set to 1." msgstr "" -#: ../../library/email.headerregistry.rst:242 +#: ../../library/email.headerregistry.rst:239 msgid "" "There is really only one valid value for the :mailheader:`MIME-Version` " "header, and that is ``1.0``. For future proofing, this header class " @@ -324,20 +324,20 @@ msgid "" "the following attributes:" msgstr "" -#: ../../library/email.headerregistry.rst:250 +#: ../../library/email.headerregistry.rst:247 msgid "" "The version number as a string, with any whitespace and/or comments removed." msgstr "" -#: ../../library/email.headerregistry.rst:255 +#: ../../library/email.headerregistry.rst:252 msgid "The major version number as an integer" msgstr "" -#: ../../library/email.headerregistry.rst:259 +#: ../../library/email.headerregistry.rst:256 msgid "The minor version number as an integer" msgstr "" -#: ../../library/email.headerregistry.rst:264 +#: ../../library/email.headerregistry.rst:261 msgid "" "MIME headers all start with the prefix 'Content-'. Each specific header has " "a certain value, described under the class for that header. Some can also " @@ -345,41 +345,46 @@ msgid "" "class serves as a base for all the MIME headers that take parameters." msgstr "" -#: ../../library/email.headerregistry.rst:271 +#: ../../library/email.headerregistry.rst:268 msgid "A dictionary mapping parameter names to parameter values." msgstr "" -#: ../../library/email.headerregistry.rst:276 +#: ../../library/email.headerregistry.rst:270 +msgid "" +"It is now a :class:`frozendict` instead of a :class:`types.MappingProxyType`." +msgstr "" + +#: ../../library/email.headerregistry.rst:277 msgid "" "A :class:`ParameterizedMIMEHeader` class that handles the :mailheader:" "`Content-Type` header." msgstr "" -#: ../../library/email.headerregistry.rst:281 +#: ../../library/email.headerregistry.rst:282 msgid "The content type string, in the form ``maintype/subtype``." msgstr "" -#: ../../library/email.headerregistry.rst:290 +#: ../../library/email.headerregistry.rst:291 msgid "" "A :class:`ParameterizedMIMEHeader` class that handles the :mailheader:" "`Content-Disposition` header." msgstr "" -#: ../../library/email.headerregistry.rst:295 +#: ../../library/email.headerregistry.rst:296 msgid "``inline`` and ``attachment`` are the only valid values in common use." msgstr "" -#: ../../library/email.headerregistry.rst:300 +#: ../../library/email.headerregistry.rst:301 msgid "Handles the :mailheader:`Content-Transfer-Encoding` header." msgstr "" -#: ../../library/email.headerregistry.rst:304 +#: ../../library/email.headerregistry.rst:305 msgid "" "Valid values are ``7bit``, ``8bit``, ``base64``, and ``quoted-printable``. " "See :rfc:`2045` for more information." msgstr "" -#: ../../library/email.headerregistry.rst:313 +#: ../../library/email.headerregistry.rst:314 msgid "" "This is the factory used by :class:`~email.policy.EmailPolicy` by default. " "``HeaderRegistry`` builds the class used to create a header instance " @@ -392,7 +397,7 @@ msgid "" "class's :class:`~type.__bases__` list." msgstr "" -#: ../../library/email.headerregistry.rst:323 +#: ../../library/email.headerregistry.rst:324 msgid "The default mappings are:" msgstr "" @@ -400,7 +405,7 @@ msgstr "" msgid "subject" msgstr "subject" -#: ../../library/email.headerregistry.rst:325 +#: ../../library/email.headerregistry.rst:326 msgid "UniqueUnstructuredHeader" msgstr "UniqueUnstructuredHeader" @@ -408,8 +413,8 @@ msgstr "UniqueUnstructuredHeader" msgid "date" msgstr "date" -#: ../../library/email.headerregistry.rst:326 -#: ../../library/email.headerregistry.rst:328 +#: ../../library/email.headerregistry.rst:327 +#: ../../library/email.headerregistry.rst:329 msgid "UniqueDateHeader" msgstr "UniqueDateHeader" @@ -417,7 +422,7 @@ msgstr "UniqueDateHeader" msgid "resent-date" msgstr "resent-date" -#: ../../library/email.headerregistry.rst:327 +#: ../../library/email.headerregistry.rst:328 msgid "DateHeader" msgstr "DateHeader" @@ -429,7 +434,7 @@ msgstr "orig-date" msgid "sender" msgstr "sender" -#: ../../library/email.headerregistry.rst:329 +#: ../../library/email.headerregistry.rst:330 msgid "UniqueSingleAddressHeader" msgstr "UniqueSingleAddressHeader" @@ -437,7 +442,7 @@ msgstr "UniqueSingleAddressHeader" msgid "resent-sender" msgstr "resent-sender" -#: ../../library/email.headerregistry.rst:330 +#: ../../library/email.headerregistry.rst:331 msgid "SingleAddressHeader" msgstr "SingleAddressHeader" @@ -445,11 +450,11 @@ msgstr "SingleAddressHeader" msgid "to" msgstr "to" -#: ../../library/email.headerregistry.rst:331 -#: ../../library/email.headerregistry.rst:333 -#: ../../library/email.headerregistry.rst:335 -#: ../../library/email.headerregistry.rst:337 -#: ../../library/email.headerregistry.rst:339 +#: ../../library/email.headerregistry.rst:332 +#: ../../library/email.headerregistry.rst:334 +#: ../../library/email.headerregistry.rst:336 +#: ../../library/email.headerregistry.rst:338 +#: ../../library/email.headerregistry.rst:340 msgid "UniqueAddressHeader" msgstr "UniqueAddressHeader" @@ -457,10 +462,10 @@ msgstr "UniqueAddressHeader" msgid "resent-to" msgstr "resent-to" -#: ../../library/email.headerregistry.rst:332 -#: ../../library/email.headerregistry.rst:334 -#: ../../library/email.headerregistry.rst:336 -#: ../../library/email.headerregistry.rst:338 +#: ../../library/email.headerregistry.rst:333 +#: ../../library/email.headerregistry.rst:335 +#: ../../library/email.headerregistry.rst:337 +#: ../../library/email.headerregistry.rst:339 msgid "AddressHeader" msgstr "AddressHeader" @@ -496,7 +501,7 @@ msgstr "reply-to" msgid "mime-version" msgstr "mime-version" -#: ../../library/email.headerregistry.rst:340 +#: ../../library/email.headerregistry.rst:341 msgid "MIMEVersionHeader" msgstr "MIMEVersionHeader" @@ -504,7 +509,7 @@ msgstr "MIMEVersionHeader" msgid "content-type" msgstr "content-type" -#: ../../library/email.headerregistry.rst:341 +#: ../../library/email.headerregistry.rst:342 msgid "ContentTypeHeader" msgstr "ContentTypeHeader" @@ -512,7 +517,7 @@ msgstr "ContentTypeHeader" msgid "content-disposition" msgstr "content-disposition" -#: ../../library/email.headerregistry.rst:342 +#: ../../library/email.headerregistry.rst:343 msgid "ContentDispositionHeader" msgstr "ContentDispositionHeader" @@ -520,7 +525,7 @@ msgstr "ContentDispositionHeader" msgid "content-transfer-encoding" msgstr "content-transfer-encoding" -#: ../../library/email.headerregistry.rst:343 +#: ../../library/email.headerregistry.rst:344 msgid "ContentTransferEncodingHeader" msgstr "ContentTransferEncodingHeader" @@ -528,15 +533,15 @@ msgstr "ContentTransferEncodingHeader" msgid "message-id" msgstr "message-id" -#: ../../library/email.headerregistry.rst:344 +#: ../../library/email.headerregistry.rst:345 msgid "MessageIDHeader" msgstr "MessageIDHeader" -#: ../../library/email.headerregistry.rst:346 +#: ../../library/email.headerregistry.rst:347 msgid "``HeaderRegistry`` has the following methods:" msgstr "``HeaderRegistry`` 有以下方法:" -#: ../../library/email.headerregistry.rst:351 +#: ../../library/email.headerregistry.rst:352 msgid "" "*name* is the name of the header to be mapped. It will be converted to " "lower case in the registry. *cls* is the specialized class to be used, " @@ -544,11 +549,11 @@ msgid "" "that match *name*." msgstr "" -#: ../../library/email.headerregistry.rst:359 +#: ../../library/email.headerregistry.rst:360 msgid "Construct and return a class to handle creating a *name* header." msgstr "" -#: ../../library/email.headerregistry.rst:364 +#: ../../library/email.headerregistry.rst:365 msgid "" "Retrieves the specialized header associated with *name* from the registry " "(using *default_class* if *name* does not appear in the registry) and " @@ -557,38 +562,38 @@ msgid "" "the class instance created thereby." msgstr "" -#: ../../library/email.headerregistry.rst:371 +#: ../../library/email.headerregistry.rst:372 msgid "" "The following classes are the classes used to represent data parsed from " "structured headers and can, in general, be used by an application program to " "construct structured values to assign to specific headers." msgstr "" -#: ../../library/email.headerregistry.rst:378 +#: ../../library/email.headerregistry.rst:379 msgid "" "The class used to represent an email address. The general form of an " "address is::" msgstr "" -#: ../../library/email.headerregistry.rst:381 +#: ../../library/email.headerregistry.rst:382 msgid "[display_name] " msgstr "[display_name] " -#: ../../library/email.headerregistry.rst:383 +#: ../../library/email.headerregistry.rst:384 msgid "or::" msgstr "或是: ::" -#: ../../library/email.headerregistry.rst:385 +#: ../../library/email.headerregistry.rst:386 msgid "username@domain" msgstr "username@domain" -#: ../../library/email.headerregistry.rst:387 +#: ../../library/email.headerregistry.rst:388 msgid "" "where each part must conform to specific syntax rules spelled out in :rfc:" "`5322`." msgstr "" -#: ../../library/email.headerregistry.rst:390 +#: ../../library/email.headerregistry.rst:391 msgid "" "As a convenience *addr_spec* can be specified instead of *username* and " "*domain*, in which case *username* and *domain* will be parsed from the " @@ -598,52 +603,52 @@ msgid "" "*not* allowed in the username portion of the address." msgstr "" -#: ../../library/email.headerregistry.rst:399 +#: ../../library/email.headerregistry.rst:400 msgid "" "The display name portion of the address, if any, with all quoting removed. " "If the address does not have a display name, this attribute will be an empty " "string." msgstr "" -#: ../../library/email.headerregistry.rst:405 +#: ../../library/email.headerregistry.rst:406 msgid "The ``username`` portion of the address, with all quoting removed." msgstr "" -#: ../../library/email.headerregistry.rst:409 +#: ../../library/email.headerregistry.rst:410 msgid "The ``domain`` portion of the address." msgstr "" -#: ../../library/email.headerregistry.rst:413 +#: ../../library/email.headerregistry.rst:414 msgid "" "The ``username@domain`` portion of the address, correctly quoted for use as " "a bare address (the second form shown above). This attribute is not mutable." msgstr "" -#: ../../library/email.headerregistry.rst:419 +#: ../../library/email.headerregistry.rst:420 msgid "" "The ``str`` value of the object is the address quoted according to :rfc:" "`5322` rules, but with no Content Transfer Encoding of any non-ASCII " "characters." msgstr "" -#: ../../library/email.headerregistry.rst:423 +#: ../../library/email.headerregistry.rst:424 msgid "" "To support SMTP (:rfc:`5321`), ``Address`` handles one special case: if " "``username`` and ``domain`` are both the empty string (or ``None``), then " "the string value of the ``Address`` is ``<>``." msgstr "" -#: ../../library/email.headerregistry.rst:430 +#: ../../library/email.headerregistry.rst:431 msgid "" "The class used to represent an address group. The general form of an " "address group is::" msgstr "" -#: ../../library/email.headerregistry.rst:433 +#: ../../library/email.headerregistry.rst:434 msgid "display_name: [address-list];" msgstr "display_name: [address-list];" -#: ../../library/email.headerregistry.rst:435 +#: ../../library/email.headerregistry.rst:436 msgid "" "As a convenience for processing lists of addresses that consist of a mixture " "of groups and single addresses, a ``Group`` may also be used to represent " @@ -651,20 +656,20 @@ msgid "" "``None`` and providing a list of the single address as *addresses*." msgstr "" -#: ../../library/email.headerregistry.rst:442 +#: ../../library/email.headerregistry.rst:443 msgid "" "The ``display_name`` of the group. If it is ``None`` and there is exactly " "one ``Address`` in ``addresses``, then the ``Group`` represents a single " "address that is not in a group." msgstr "" -#: ../../library/email.headerregistry.rst:448 +#: ../../library/email.headerregistry.rst:449 msgid "" "A possibly empty tuple of :class:`.Address` objects representing the " "addresses in the group." msgstr "" -#: ../../library/email.headerregistry.rst:453 +#: ../../library/email.headerregistry.rst:454 msgid "" "The ``str`` value of a ``Group`` is formatted according to :rfc:`5322`, but " "with no Content Transfer Encoding of any non-ASCII characters. If " @@ -673,11 +678,11 @@ msgid "" "that single ``Address``." msgstr "" -#: ../../library/email.headerregistry.rst:461 +#: ../../library/email.headerregistry.rst:462 msgid "Footnotes" msgstr "註解" -#: ../../library/email.headerregistry.rst:462 +#: ../../library/email.headerregistry.rst:463 msgid "" "Originally added in 3.3 as a :term:`provisional module `" msgstr "" diff --git a/library/email.message.po b/library/email.message.po index 993b808ab16..b31ccae4c9d 100644 --- a/library/email.message.po +++ b/library/email.message.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,15 +21,15 @@ msgstr "" msgid ":mod:`!email.message`: Representing an email message" msgstr ":mod:`!email.message`:表示電子郵件訊息" -#: ../../library/email.message.rst:10 +#: ../../library/email.message.rst:7 msgid "**Source code:** :source:`Lib/email/message.py`" msgstr "**原始碼:**\\ :source:`Lib/email/message.py`" -#: ../../library/email.message.rst:14 +#: ../../library/email.message.rst:11 msgid "[1]_" msgstr "[1]_" -#: ../../library/email.message.rst:16 +#: ../../library/email.message.rst:13 msgid "" "The central class in the :mod:`email` package is the :class:`EmailMessage` " "class, imported from the :mod:`!email.message` module. It is the base class " @@ -38,7 +38,7 @@ msgid "" "bodies, and for creating or modifying structured messages." msgstr "" -#: ../../library/email.message.rst:22 +#: ../../library/email.message.rst:19 msgid "" "An email message consists of *headers* and a *payload* (which is also " "referred to as the *content*). Headers are :rfc:`5322` or :rfc:`6532` style " @@ -51,7 +51,7 @@ msgid "" "rfc822`." msgstr "" -#: ../../library/email.message.rst:31 +#: ../../library/email.message.rst:28 msgid "" "The conceptual model provided by an :class:`EmailMessage` object is that of " "an ordered dictionary of headers coupled with a *payload* that represents " @@ -63,7 +63,7 @@ msgid "" "the message, and for recursively walking over the object tree." msgstr "" -#: ../../library/email.message.rst:40 +#: ../../library/email.message.rst:37 msgid "" "The :class:`EmailMessage` dictionary-like interface is indexed by the header " "names, which must be ASCII values. The values of the dictionary are strings " @@ -73,7 +73,7 @@ msgid "" "provided for working with headers that have duplicate keys." msgstr "" -#: ../../library/email.message.rst:47 +#: ../../library/email.message.rst:44 msgid "" "The *payload* is either a string or bytes object, in the case of simple " "message objects, or a list of :class:`EmailMessage` objects, for MIME " @@ -81,7 +81,7 @@ msgid "" "rfc822` message objects." msgstr "" -#: ../../library/email.message.rst:55 +#: ../../library/email.message.rst:52 msgid "" "If *policy* is specified use the rules it specifies to update and serialize " "the representation of the message. If *policy* is not set, use the :class:" @@ -91,7 +91,7 @@ msgid "" "`~email.policy` documentation. [2]_" msgstr "" -#: ../../library/email.message.rst:64 +#: ../../library/email.message.rst:61 msgid "" "Return the entire message flattened as a string. When optional *unixfrom* " "is true, the envelope header is included in the returned string. *unixfrom* " @@ -105,14 +105,14 @@ msgid "" "class:`~email.generator.Generator`." msgstr "" -#: ../../library/email.message.rst:76 ../../library/email.message.rst:114 +#: ../../library/email.message.rst:73 ../../library/email.message.rst:111 msgid "" "Flattening the message may trigger changes to the :class:`EmailMessage` if " "defaults need to be filled in to complete the transformation to a string " "(for example, MIME boundaries may be generated or modified)." msgstr "" -#: ../../library/email.message.rst:80 +#: ../../library/email.message.rst:77 msgid "" "Note that this method is provided as a convenience and may not be the most " "useful way to serialize messages in your application, especially if you are " @@ -122,28 +122,28 @@ msgid "" "`~email.policy.EmailPolicy.utf8` is ``False``, which is the default." msgstr "" -#: ../../library/email.message.rst:88 +#: ../../library/email.message.rst:85 msgid "" "the default behavior when *maxheaderlen* is not specified was changed from " "defaulting to 0 to defaulting to the value of *max_line_length* from the " "policy." msgstr "" -#: ../../library/email.message.rst:95 +#: ../../library/email.message.rst:92 msgid "" "Equivalent to ``as_string(policy=self.policy.clone(utf8=True))``. Allows " "``str(msg)`` to produce a string containing the serialized message in a " "readable format." msgstr "" -#: ../../library/email.message.rst:99 +#: ../../library/email.message.rst:96 msgid "" "the method was changed to use ``utf8=True``, thus producing an :rfc:`6531`-" "like message representation, instead of being a direct alias for :meth:" "`as_string`." msgstr "" -#: ../../library/email.message.rst:106 +#: ../../library/email.message.rst:103 msgid "" "Return the entire message flattened as a bytes object. When optional " "*unixfrom* is true, the envelope header is included in the returned string. " @@ -154,7 +154,7 @@ msgid "" "BytesGenerator`." msgstr "" -#: ../../library/email.message.rst:118 +#: ../../library/email.message.rst:115 msgid "" "Note that this method is provided as a convenience and may not be the most " "useful way to serialize messages in your application, especially if you are " @@ -162,13 +162,13 @@ msgid "" "for a more flexible API for serializing messages." msgstr "" -#: ../../library/email.message.rst:127 +#: ../../library/email.message.rst:124 msgid "" "Equivalent to :meth:`.as_bytes`. Allows ``bytes(msg)`` to produce a bytes " "object containing the serialized message." msgstr "" -#: ../../library/email.message.rst:133 +#: ../../library/email.message.rst:130 msgid "" "Return ``True`` if the message's payload is a list of sub-\\ :class:" "`EmailMessage` objects, otherwise return ``False``. When :meth:" @@ -180,19 +180,19 @@ msgid "" "`EmailMessage` is of type ``message/rfc822``." msgstr "" -#: ../../library/email.message.rst:145 +#: ../../library/email.message.rst:142 msgid "" "Set the message's envelope header to *unixfrom*, which should be a string. " "(See :class:`~mailbox.mboxMessage` for a brief description of this header.)" msgstr "" -#: ../../library/email.message.rst:152 +#: ../../library/email.message.rst:149 msgid "" "Return the message's envelope header. Defaults to ``None`` if the envelope " "header was never set." msgstr "" -#: ../../library/email.message.rst:156 +#: ../../library/email.message.rst:153 msgid "" "The following methods implement the mapping-like interface for accessing the " "message's headers. Note that there are some semantic differences between " @@ -206,30 +206,30 @@ msgid "" "list." msgstr "" -#: ../../library/email.message.rst:167 +#: ../../library/email.message.rst:164 msgid "" "These semantic differences are intentional and are biased toward convenience " "in the most common use cases." msgstr "" -#: ../../library/email.message.rst:170 +#: ../../library/email.message.rst:167 msgid "" "Note that in all cases, any envelope header present in the message is not " "included in the mapping interface." msgstr "" -#: ../../library/email.message.rst:176 +#: ../../library/email.message.rst:173 msgid "Return the total number of headers, including duplicates." msgstr "" -#: ../../library/email.message.rst:181 +#: ../../library/email.message.rst:178 msgid "" "Return ``True`` if the message object has a field named *name*. Matching is " "done without regard to case and *name* does not include the trailing colon. " "Used for the ``in`` operator. For example::" msgstr "" -#: ../../library/email.message.rst:185 +#: ../../library/email.message.rst:182 msgid "" "if 'message-id' in myMessage:\n" " print('Message-ID:', myMessage['message-id'])" @@ -237,14 +237,14 @@ msgstr "" "if 'message-id' in myMessage:\n" " print('Message-ID:', myMessage['message-id'])" -#: ../../library/email.message.rst:191 +#: ../../library/email.message.rst:188 msgid "" "Return the value of the named header field. *name* does not include the " "colon field separator. If the header is missing, ``None`` is returned; a :" "exc:`KeyError` is never raised." msgstr "" -#: ../../library/email.message.rst:195 +#: ../../library/email.message.rst:192 msgid "" "Note that if the named field appears more than once in the message's " "headers, exactly which of those field values will be returned is undefined. " @@ -252,26 +252,26 @@ msgid "" "named *name*." msgstr "" -#: ../../library/email.message.rst:200 +#: ../../library/email.message.rst:197 msgid "" "Using the standard (non-``compat32``) policies, the returned value is an " "instance of a subclass of :class:`email.headerregistry.BaseHeader`." msgstr "" -#: ../../library/email.message.rst:206 +#: ../../library/email.message.rst:203 msgid "" "Add a header to the message with field name *name* and value *val*. The " "field is appended to the end of the message's existing headers." msgstr "" -#: ../../library/email.message.rst:209 +#: ../../library/email.message.rst:206 msgid "" "Note that this does *not* overwrite or delete any existing header with the " "same name. If you want to ensure that the new header is the only one " "present in the message with field name *name*, delete the field first, e.g.::" msgstr "" -#: ../../library/email.message.rst:213 +#: ../../library/email.message.rst:210 msgid "" "del msg['subject']\n" "msg['subject'] = 'Python roolz!'" @@ -279,7 +279,7 @@ msgstr "" "del msg['subject']\n" "msg['subject'] = 'Python roolz!'" -#: ../../library/email.message.rst:216 +#: ../../library/email.message.rst:213 msgid "" "If the :mod:`policy ` defines certain headers to be unique (as " "the standard policies do), this method may raise a :exc:`ValueError` when an " @@ -289,46 +289,46 @@ msgid "" "existing header in the future." msgstr "" -#: ../../library/email.message.rst:226 +#: ../../library/email.message.rst:223 msgid "" "Delete all occurrences of the field with name *name* from the message's " "headers. No exception is raised if the named field isn't present in the " "headers." msgstr "" -#: ../../library/email.message.rst:233 +#: ../../library/email.message.rst:230 msgid "Return a list of all the message's header field names." msgstr "" -#: ../../library/email.message.rst:238 +#: ../../library/email.message.rst:235 msgid "Return a list of all the message's field values." msgstr "" -#: ../../library/email.message.rst:243 +#: ../../library/email.message.rst:240 msgid "" "Return a list of 2-tuples containing all the message's field headers and " "values." msgstr "" -#: ../../library/email.message.rst:249 +#: ../../library/email.message.rst:246 msgid "" "Return the value of the named header field. This is identical to :meth:" "`~object.__getitem__` except that optional *failobj* is returned if the " "named header is missing (*failobj* defaults to ``None``)." msgstr "" -#: ../../library/email.message.rst:254 +#: ../../library/email.message.rst:251 msgid "Here are some additional useful header related methods:" msgstr "" -#: ../../library/email.message.rst:259 +#: ../../library/email.message.rst:256 msgid "" "Return a list of all the values for the field named *name*. If there are no " "such named headers in the message, *failobj* is returned (defaults to " "``None``)." msgstr "" -#: ../../library/email.message.rst:266 +#: ../../library/email.message.rst:263 msgid "" "Extended header setting. This method is similar to :meth:`__setitem__` " "except that additional header parameters can be provided as keyword " @@ -336,7 +336,7 @@ msgid "" "value for the header." msgstr "" -#: ../../library/email.message.rst:271 +#: ../../library/email.message.rst:268 msgid "" "For each item in the keyword argument dictionary *_params*, the key is taken " "as the parameter name, with underscores converted to dashes (since dashes " @@ -345,7 +345,7 @@ msgid "" "key will be added." msgstr "" -#: ../../library/email.message.rst:277 +#: ../../library/email.message.rst:274 msgid "" "If the value contains non-ASCII characters, the charset and language may be " "explicitly controlled by specifying the value as a three tuple in the format " @@ -358,41 +358,41 @@ msgid "" "and a ``LANGUAGE`` of ``None``." msgstr "" -#: ../../library/email.message.rst:287 +#: ../../library/email.message.rst:284 msgid "Here is an example::" msgstr "以下是個範例: ::" -#: ../../library/email.message.rst:289 +#: ../../library/email.message.rst:286 msgid "msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')" msgstr "" "msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')" -#: ../../library/email.message.rst:291 +#: ../../library/email.message.rst:288 msgid "This will add a header that looks like ::" msgstr "" -#: ../../library/email.message.rst:293 +#: ../../library/email.message.rst:290 msgid "Content-Disposition: attachment; filename=\"bud.gif\"" msgstr "Content-Disposition: attachment; filename=\"bud.gif\"" -#: ../../library/email.message.rst:295 +#: ../../library/email.message.rst:292 msgid "An example of the extended interface with non-ASCII characters::" msgstr "" -#: ../../library/email.message.rst:297 +#: ../../library/email.message.rst:294 msgid "" "msg.add_header('Content-Disposition', 'attachment',\n" " filename=('iso-8859-1', '', 'Fußballer.ppt'))" msgstr "" -#: ../../library/email.message.rst:303 +#: ../../library/email.message.rst:300 msgid "" "Replace a header. Replace the first header found in the message that " "matches *_name*, retaining header order and field name case of the original " "header. If no matching header is found, raise a :exc:`KeyError`." msgstr "" -#: ../../library/email.message.rst:311 +#: ../../library/email.message.rst:308 msgid "" "Return the message's content type, coerced to lower case of the form :" "mimetype:`maintype/subtype`. If there is no :mailheader:`Content-Type` " @@ -401,7 +401,7 @@ msgid "" "return ``text/plain``." msgstr "" -#: ../../library/email.message.rst:317 +#: ../../library/email.message.rst:314 msgid "" "(According to :rfc:`2045`, messages always have a default type, :meth:" "`get_content_type` will always return a value. :rfc:`2045` defines a " @@ -412,19 +412,19 @@ msgid "" "mimetype:`text/plain`.)" msgstr "" -#: ../../library/email.message.rst:328 +#: ../../library/email.message.rst:325 msgid "" "Return the message's main content type. This is the :mimetype:`maintype` " "part of the string returned by :meth:`get_content_type`." msgstr "" -#: ../../library/email.message.rst:334 +#: ../../library/email.message.rst:331 msgid "" "Return the message's sub-content type. This is the :mimetype:`subtype` part " "of the string returned by :meth:`get_content_type`." msgstr "" -#: ../../library/email.message.rst:340 +#: ../../library/email.message.rst:337 msgid "" "Return the default content type. Most messages have a default content type " "of :mimetype:`text/plain`, except for messages that are subparts of :" @@ -432,7 +432,7 @@ msgid "" "content type of :mimetype:`message/rfc822`." msgstr "" -#: ../../library/email.message.rst:348 +#: ../../library/email.message.rst:345 msgid "" "Set the default content type. *ctype* should either be :mimetype:`text/" "plain` or :mimetype:`message/rfc822`, although this is not enforced. The " @@ -441,7 +441,7 @@ msgid "" "no :mailheader:`Content-Type` header is present in the message." msgstr "" -#: ../../library/email.message.rst:359 +#: ../../library/email.message.rst:356 msgid "" "Set a parameter in the :mailheader:`Content-Type` header. If the parameter " "already exists in the header, replace its value with *value*. When *header* " @@ -451,7 +451,7 @@ msgid "" "mailheader:`Content-Type`." msgstr "" -#: ../../library/email.message.rst:366 +#: ../../library/email.message.rst:363 msgid "" "If the value contains non-ASCII characters, the charset and language may be " "explicitly specified using the optional *charset* and *language* " @@ -461,31 +461,31 @@ msgid "" "*language*." msgstr "" -#: ../../library/email.message.rst:373 +#: ../../library/email.message.rst:370 msgid "" "If *replace* is ``False`` (the default) the header is moved to the end of " "the list of headers. If *replace* is ``True``, the header will be updated " "in place." msgstr "" -#: ../../library/email.message.rst:377 ../../library/email.message.rst:394 +#: ../../library/email.message.rst:374 ../../library/email.message.rst:391 msgid "" "Use of the *requote* parameter with :class:`EmailMessage` objects is " "deprecated." msgstr "" -#: ../../library/email.message.rst:380 +#: ../../library/email.message.rst:377 msgid "" "Note that existing parameter values of headers may be accessed through the :" "attr:`~email.headerregistry.ParameterizedMIMEHeader.params` attribute of the " "header value (for example, ``msg['Content-Type'].params['charset']``)." msgstr "" -#: ../../library/email.message.rst:384 +#: ../../library/email.message.rst:381 msgid "``replace`` keyword was added." msgstr "新增 ``replace`` 關鍵字。" -#: ../../library/email.message.rst:389 +#: ../../library/email.message.rst:386 msgid "" "Remove the given parameter completely from the :mailheader:`Content-Type` " "header. The header will be re-written in place without the parameter or its " @@ -493,7 +493,7 @@ msgid "" "Type`." msgstr "" -#: ../../library/email.message.rst:400 +#: ../../library/email.message.rst:397 msgid "" "Return the value of the ``filename`` parameter of the :mailheader:`Content-" "Disposition` header of the message. If the header does not have a " @@ -503,7 +503,7 @@ msgid "" "always be unquoted as per :func:`email.utils.unquote`." msgstr "" -#: ../../library/email.message.rst:411 +#: ../../library/email.message.rst:408 msgid "" "Return the value of the ``boundary`` parameter of the :mailheader:`Content-" "Type` header of the message, or *failobj* if either the header is missing, " @@ -511,7 +511,7 @@ msgid "" "unquoted as per :func:`email.utils.unquote`." msgstr "" -#: ../../library/email.message.rst:419 +#: ../../library/email.message.rst:416 msgid "" "Set the ``boundary`` parameter of the :mailheader:`Content-Type` header to " "*boundary*. :meth:`set_boundary` will always quote *boundary* if " @@ -519,7 +519,7 @@ msgid "" "object has no :mailheader:`Content-Type` header." msgstr "" -#: ../../library/email.message.rst:424 +#: ../../library/email.message.rst:421 msgid "" "Note that using this method is subtly different from deleting the old :" "mailheader:`Content-Type` header and adding a new one with the new boundary " @@ -527,21 +527,21 @@ msgid "" "the :mailheader:`Content-Type` header in the list of headers." msgstr "" -#: ../../library/email.message.rst:433 +#: ../../library/email.message.rst:430 msgid "" "Return the ``charset`` parameter of the :mailheader:`Content-Type` header, " "coerced to lower case. If there is no :mailheader:`Content-Type` header, or " "if that header has no ``charset`` parameter, *failobj* is returned." msgstr "" -#: ../../library/email.message.rst:440 +#: ../../library/email.message.rst:437 msgid "" "Return a list containing the character set names in the message. If the " "message is a :mimetype:`multipart`, then the list will contain one element " "for each subpart in the payload, otherwise, it will be a list of length 1." msgstr "" -#: ../../library/email.message.rst:444 +#: ../../library/email.message.rst:441 msgid "" "Each item in the list will be a string which is the value of the ``charset`` " "parameter in the :mailheader:`Content-Type` header for the represented " @@ -550,19 +550,19 @@ msgid "" "then that item in the returned list will be *failobj*." msgstr "" -#: ../../library/email.message.rst:453 +#: ../../library/email.message.rst:450 msgid "" "Return ``True`` if there is a :mailheader:`Content-Disposition` header and " "its (case insensitive) value is ``attachment``, ``False`` otherwise." msgstr "" -#: ../../library/email.message.rst:456 +#: ../../library/email.message.rst:453 msgid "" "is_attachment is now a method instead of a property, for consistency with :" "meth:`~email.message.Message.is_multipart`." msgstr "" -#: ../../library/email.message.rst:463 +#: ../../library/email.message.rst:460 msgid "" "Return the lowercased value (without parameters) of the message's :" "mailheader:`Content-Disposition` header if it has one, or ``None``. The " @@ -570,13 +570,13 @@ msgid "" "the message follows :rfc:`2183`." msgstr "" -#: ../../library/email.message.rst:471 +#: ../../library/email.message.rst:468 msgid "" "The following methods relate to interrogating and manipulating the content " "(payload) of the message." msgstr "" -#: ../../library/email.message.rst:477 +#: ../../library/email.message.rst:474 msgid "" "The :meth:`walk` method is an all-purpose generator which can be used to " "iterate over all the parts and subparts of a message object tree, in depth-" @@ -584,13 +584,13 @@ msgid "" "in a ``for`` loop; each iteration returns the next subpart." msgstr "" -#: ../../library/email.message.rst:482 +#: ../../library/email.message.rst:479 msgid "" "Here's an example that prints the MIME type of every part of a multipart " "message structure:" msgstr "" -#: ../../library/email.message.rst:491 +#: ../../library/email.message.rst:488 msgid "" ">>> for part in msg.walk():\n" "... print(part.get_content_type())\n" @@ -612,7 +612,7 @@ msgstr "" "message/rfc822\n" "text/plain" -#: ../../library/email.message.rst:503 +#: ../../library/email.message.rst:500 msgid "" "``walk`` iterates over the subparts of any part where :meth:`is_multipart` " "returns ``True``, even though ``msg.get_content_maintype() == 'multipart'`` " @@ -620,7 +620,7 @@ msgid "" "``_structure`` debug helper function:" msgstr "" -#: ../../library/email.message.rst:509 +#: ../../library/email.message.rst:506 msgid "" ">>> from email.iterators import _structure\n" ">>> for part in msg.walk():\n" @@ -662,40 +662,40 @@ msgstr "" " message/rfc822\n" " text/plain" -#: ../../library/email.message.rst:531 +#: ../../library/email.message.rst:528 msgid "" "Here the ``message`` parts are not ``multiparts``, but they do contain " "subparts. ``is_multipart()`` returns ``True`` and ``walk`` descends into the " "subparts." msgstr "" -#: ../../library/email.message.rst:538 +#: ../../library/email.message.rst:535 msgid "" "Return the MIME part that is the best candidate to be the \"body\" of the " "message." msgstr "" -#: ../../library/email.message.rst:541 +#: ../../library/email.message.rst:538 msgid "" "*preferencelist* must be a sequence of strings from the set ``related``, " "``html``, and ``plain``, and indicates the order of preference for the " "content type of the part returned." msgstr "" -#: ../../library/email.message.rst:545 +#: ../../library/email.message.rst:542 msgid "" "Start looking for candidate matches with the object on which the " "``get_body`` method is called." msgstr "" -#: ../../library/email.message.rst:548 +#: ../../library/email.message.rst:545 msgid "" "If ``related`` is not included in *preferencelist*, consider the root part " "(or subpart of the root part) of any related encountered as a candidate if " "the (sub-)part matches a preference." msgstr "" -#: ../../library/email.message.rst:552 +#: ../../library/email.message.rst:549 msgid "" "When encountering a ``multipart/related``, check the ``start`` parameter and " "if a part with a matching :mailheader:`Content-ID` is found, consider only " @@ -703,19 +703,19 @@ msgid "" "(default root) part of the ``multipart/related``." msgstr "" -#: ../../library/email.message.rst:557 +#: ../../library/email.message.rst:554 msgid "" "If a part has a :mailheader:`Content-Disposition` header, only consider the " "part a candidate match if the value of the header is ``inline``." msgstr "" -#: ../../library/email.message.rst:560 +#: ../../library/email.message.rst:557 msgid "" "If none of the candidates matches any of the preferences in " "*preferencelist*, return ``None``." msgstr "" -#: ../../library/email.message.rst:563 +#: ../../library/email.message.rst:560 msgid "" "Notes: (1) For most applications the only *preferencelist* combinations that " "really make sense are ``('plain',)``, ``('html', 'plain')``, and the default " @@ -728,7 +728,7 @@ msgid "" "occasionally cause ``get_body`` to return unexpected results." msgstr "" -#: ../../library/email.message.rst:577 +#: ../../library/email.message.rst:574 msgid "" "Return an iterator over all of the immediate sub-parts of the message that " "are not candidate \"body\" parts. That is, skip the first occurrence of " @@ -743,14 +743,14 @@ msgid "" "alternative`` or a non-``multipart``, return an empty iterator." msgstr "" -#: ../../library/email.message.rst:593 +#: ../../library/email.message.rst:590 msgid "" "Return an iterator over all of the immediate sub-parts of the message, which " "will be empty for a non-``multipart``. (See also :meth:`~email.message." "EmailMessage.walk`.)" msgstr "" -#: ../../library/email.message.rst:600 +#: ../../library/email.message.rst:597 msgid "" "Call the :meth:`~email.contentmanager.ContentManager.get_content` method of " "the *content_manager*, passing self as the message object, and passing along " @@ -759,7 +759,7 @@ msgid "" "the current :mod:`~email.policy`." msgstr "" -#: ../../library/email.message.rst:609 +#: ../../library/email.message.rst:606 msgid "" "Call the :meth:`~email.contentmanager.ContentManager.set_content` method of " "the *content_manager*, passing self as the message object, and passing along " @@ -768,7 +768,7 @@ msgid "" "the current :mod:`~email.policy`." msgstr "" -#: ../../library/email.message.rst:618 +#: ../../library/email.message.rst:615 msgid "" "Convert a non-``multipart`` message into a ``multipart/related`` message, " "moving any existing :mailheader:`Content-` headers and payload into a (new) " @@ -778,7 +778,7 @@ msgid "" "serialized)." msgstr "" -#: ../../library/email.message.rst:628 +#: ../../library/email.message.rst:625 msgid "" "Convert a non-``multipart`` or a ``multipart/related`` into a ``multipart/" "alternative``, moving any existing :mailheader:`Content-` headers and " @@ -788,7 +788,7 @@ msgid "" "when the message is serialized)." msgstr "" -#: ../../library/email.message.rst:638 +#: ../../library/email.message.rst:635 msgid "" "Convert a non-``multipart``, a ``multipart/related``, or a ``multipart-" "alternative`` into a ``multipart/mixed``, moving any existing :mailheader:" @@ -798,7 +798,7 @@ msgid "" "it is needed (for example, when the message is serialized)." msgstr "" -#: ../../library/email.message.rst:648 +#: ../../library/email.message.rst:645 msgid "" "If the message is a ``multipart/related``, create a new message object, pass " "all of the arguments to its :meth:`set_content` method, and :meth:`~email." @@ -810,7 +810,7 @@ msgid "" "`Content-Disposition` header, add one with the value ``inline``." msgstr "" -#: ../../library/email.message.rst:661 +#: ../../library/email.message.rst:658 msgid "" "If the message is a ``multipart/alternative``, create a new message object, " "pass all of the arguments to its :meth:`set_content` method, and :meth:" @@ -822,7 +822,7 @@ msgid "" "policy`." msgstr "" -#: ../../library/email.message.rst:673 +#: ../../library/email.message.rst:670 msgid "" "If the message is a ``multipart/mixed``, create a new message object, pass " "all of the arguments to its :meth:`set_content` method, and :meth:`~email." @@ -837,21 +837,21 @@ msgid "" "passing appropriate options to the ``content_manager``." msgstr "" -#: ../../library/email.message.rst:689 +#: ../../library/email.message.rst:686 msgid "Remove the payload and all of the headers." msgstr "" -#: ../../library/email.message.rst:694 +#: ../../library/email.message.rst:691 msgid "" "Remove the payload and all of the :mailheader:`!Content-` headers, leaving " "all other headers intact and in their original order." msgstr "" -#: ../../library/email.message.rst:698 +#: ../../library/email.message.rst:695 msgid ":class:`EmailMessage` objects have the following instance attributes:" msgstr "" -#: ../../library/email.message.rst:703 +#: ../../library/email.message.rst:700 msgid "" "The format of a MIME document allows for some text between the blank line " "following the headers, and the first multipart boundary string. Normally, " @@ -861,7 +861,7 @@ msgid "" "can become visible." msgstr "" -#: ../../library/email.message.rst:710 +#: ../../library/email.message.rst:707 msgid "" "The *preamble* attribute contains this leading extra-armor text for MIME " "documents. When the :class:`~email.parser.Parser` discovers some text after " @@ -873,13 +873,13 @@ msgid "" "parser` and :mod:`email.generator` for details." msgstr "" -#: ../../library/email.message.rst:720 +#: ../../library/email.message.rst:717 msgid "" "Note that if the message object has no preamble, the *preamble* attribute " "will be ``None``." msgstr "" -#: ../../library/email.message.rst:726 +#: ../../library/email.message.rst:723 msgid "" "The *epilogue* attribute acts the same way as the *preamble* attribute, " "except that it contains text that appears between the last boundary and the " @@ -887,14 +887,14 @@ msgid "" "no epilog text this attribute will be ``None``." msgstr "" -#: ../../library/email.message.rst:734 +#: ../../library/email.message.rst:731 msgid "" "The *defects* attribute contains a list of all the problems found when " "parsing this message. See :mod:`email.errors` for a detailed description of " "the possible parsing defects." msgstr "" -#: ../../library/email.message.rst:741 +#: ../../library/email.message.rst:738 msgid "" "This class represents a subpart of a MIME message. It is identical to :" "class:`EmailMessage`, except that no :mailheader:`MIME-Version` headers are " @@ -902,17 +902,17 @@ msgid "" "not need their own :mailheader:`MIME-Version` headers." msgstr "" -#: ../../library/email.message.rst:748 +#: ../../library/email.message.rst:745 msgid "Footnotes" msgstr "註解" -#: ../../library/email.message.rst:749 +#: ../../library/email.message.rst:746 msgid "" "Originally added in 3.4 as a :term:`provisional module `. Docs for legacy message class moved to :ref:`compat32_message`." msgstr "" -#: ../../library/email.message.rst:753 +#: ../../library/email.message.rst:750 msgid "" "The :class:`EmailMessage` class requires a policy that provides a " "``content_manager`` attribute for content management methods like " diff --git a/library/email.po b/library/email.po index 4cb84708a00..707252220a9 100644 --- a/library/email.po +++ b/library/email.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-13 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!email` --- An email and MIME handling package" msgstr ":mod:`!email` --- 郵件和 MIME 處理套件" -#: ../../library/email.rst:11 +#: ../../library/email.rst:8 msgid "**Source code:** :source:`Lib/email/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/email/__init__.py`" -#: ../../library/email.rst:15 +#: ../../library/email.rst:12 msgid "" "The :mod:`!email` package is a library for managing email messages. It is " "specifically *not* designed to do any sending of email messages to SMTP (:" @@ -36,14 +36,14 @@ msgid "" "`2231`." msgstr "" -#: ../../library/email.rst:23 +#: ../../library/email.rst:20 msgid "" "The overall structure of the email package can be divided into three major " "components, plus a fourth component that controls the behavior of the other " "components." msgstr "" -#: ../../library/email.rst:27 +#: ../../library/email.rst:24 msgid "" "The central component of the package is an \"object model\" that represents " "email messages. An application interacts with the package primarily through " @@ -56,7 +56,7 @@ msgid "" "message.EmailMessage` API." msgstr "" -#: ../../library/email.rst:37 +#: ../../library/email.rst:34 msgid "" "The other two major components of the package are the :mod:`~email.parser` " "and the :mod:`~email.generator`. The parser takes the serialized version of " @@ -68,7 +68,7 @@ msgid "" "are not valid in one way or another.)" msgstr "" -#: ../../library/email.rst:46 +#: ../../library/email.rst:43 msgid "" "The control component is the :mod:`~email.policy` module. Every :class:" "`~email.message.EmailMessage`, every :mod:`~email.generator`, and every :mod:" @@ -83,7 +83,7 @@ msgid "" "to an email server." msgstr "" -#: ../../library/email.rst:58 +#: ../../library/email.rst:55 msgid "" "The email package does its best to hide the details of the various governing " "RFCs from the application. Conceptually the application should be able to " @@ -100,7 +100,7 @@ msgid "" "to many programmers." msgstr "" -#: ../../library/email.rst:71 +#: ../../library/email.rst:68 msgid "" "The following sections describe the functionality of the :mod:`!email` " "package. We start with the :mod:`~email.message` object model, which is the " @@ -110,7 +110,7 @@ msgid "" "components of the library." msgstr "" -#: ../../library/email.rst:78 +#: ../../library/email.rst:75 msgid "" "The next three sections cover the exceptions the package may raise and the " "defects (non-compliance with the RFCs) that the :mod:`~email.parser` may " @@ -122,13 +122,13 @@ msgid "" "interest to advanced applications." msgstr "" -#: ../../library/email.rst:87 +#: ../../library/email.rst:84 msgid "" "Following those is a set of examples of using the fundamental parts of the " "APIs covered in the preceding sections." msgstr "" -#: ../../library/email.rst:90 +#: ../../library/email.rst:87 msgid "" "The foregoing represent the modern (Unicode friendly) API of the email " "package. The remaining sections, starting with the :class:`~email.message." @@ -141,49 +141,49 @@ msgid "" "compat32` API for backward compatibility reasons." msgstr "" -#: ../../library/email.rst:100 +#: ../../library/email.rst:97 msgid "" "Docs reorganized and rewritten to promote the new :class:`~email.message." "EmailMessage`/:class:`~email.policy.EmailPolicy` API." msgstr "" -#: ../../library/email.rst:105 +#: ../../library/email.rst:102 msgid "Contents of the :mod:`!email` package documentation:" msgstr ":mod:`!email` 套件文件的內容:" -#: ../../library/email.rst:120 +#: ../../library/email.rst:117 msgid "Legacy API:" msgstr "" -#: ../../library/email.rst:135 +#: ../../library/email.rst:132 msgid "Module :mod:`smtplib`" msgstr ":mod:`smtplib` 模組" -#: ../../library/email.rst:136 +#: ../../library/email.rst:133 msgid "SMTP (Simple Mail Transport Protocol) client" msgstr "" -#: ../../library/email.rst:138 +#: ../../library/email.rst:135 msgid "Module :mod:`poplib`" msgstr ":mod:`poplib` 模組" -#: ../../library/email.rst:139 +#: ../../library/email.rst:136 msgid "POP (Post Office Protocol) client" msgstr "" -#: ../../library/email.rst:141 +#: ../../library/email.rst:138 msgid "Module :mod:`imaplib`" msgstr ":mod:`imaplib` 模組" -#: ../../library/email.rst:142 +#: ../../library/email.rst:139 msgid "IMAP (Internet Message Access Protocol) client" msgstr "" -#: ../../library/email.rst:144 +#: ../../library/email.rst:141 msgid "Module :mod:`mailbox`" msgstr ":mod:`mailbox` 模組" -#: ../../library/email.rst:145 +#: ../../library/email.rst:142 msgid "" "Tools for creating, reading, and managing collections of messages on disk " "using a variety standard formats." diff --git a/library/email.policy.po b/library/email.policy.po index 3d26b74f8bd..a2d34c284b3 100644 --- a/library/email.policy.po +++ b/library/email.policy.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-13 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!email.policy`: Policy Objects" msgstr "" -#: ../../library/email.policy.rst:12 +#: ../../library/email.policy.rst:9 msgid "**Source code:** :source:`Lib/email/policy.py`" msgstr "**原始碼:**\\ :source:`Lib/email/policy.py`" -#: ../../library/email.policy.rst:16 +#: ../../library/email.policy.rst:13 msgid "" "The :mod:`email` package's prime focus is the handling of email messages as " "described by the various email and MIME RFCs. However, the general format " @@ -40,13 +40,13 @@ msgid "" "violate the standards." msgstr "" -#: ../../library/email.policy.rst:28 +#: ../../library/email.policy.rst:25 msgid "" "Policy objects give the email package the flexibility to handle all these " "disparate use cases." msgstr "" -#: ../../library/email.policy.rst:31 +#: ../../library/email.policy.rst:28 msgid "" "A :class:`Policy` object encapsulates a set of attributes and methods that " "control the behavior of various components of the email package during use. :" @@ -55,7 +55,7 @@ msgid "" "defaults are described below." msgstr "" -#: ../../library/email.policy.rst:37 +#: ../../library/email.policy.rst:34 msgid "" "There is a default policy used by all classes in the email package. For all " "of the :mod:`~email.parser` classes and the related convenience functions, " @@ -66,14 +66,14 @@ msgid "" "the email package." msgstr "" -#: ../../library/email.policy.rst:44 +#: ../../library/email.policy.rst:41 msgid "" "This default value for the *policy* keyword to :class:`~email.message." "EmailMessage` is the :class:`EmailPolicy` policy, via its pre-defined " "instance :data:`~default`." msgstr "" -#: ../../library/email.policy.rst:48 +#: ../../library/email.policy.rst:45 msgid "" "When a :class:`~email.message.Message` or :class:`~email.message." "EmailMessage` object is created, it acquires a policy. If the message is " @@ -85,7 +85,7 @@ msgid "" "to the generator that will override the one stored on the message object." msgstr "" -#: ../../library/email.policy.rst:57 +#: ../../library/email.policy.rst:54 msgid "" "The default value for the *policy* keyword for the :mod:`email.parser` " "classes and the parser convenience functions **will be changing** in a " @@ -94,7 +94,7 @@ msgid "" "described in the :mod:`~email.parser` module." msgstr "" -#: ../../library/email.policy.rst:63 +#: ../../library/email.policy.rst:60 msgid "" "The first part of this documentation covers the features of :class:`Policy`, " "an :term:`abstract base class` that defines the features that are common to " @@ -106,7 +106,7 @@ msgid "" "backward compatible behavior and features, respectively." msgstr "" -#: ../../library/email.policy.rst:72 +#: ../../library/email.policy.rst:69 msgid "" ":class:`Policy` instances are immutable, but they can be cloned, accepting " "the same keyword arguments as the class constructor and returning a new :" @@ -114,14 +114,14 @@ msgid "" "specified attributes values changed." msgstr "" -#: ../../library/email.policy.rst:77 +#: ../../library/email.policy.rst:74 msgid "" "As an example, the following code could be used to read an email message " "from a file on disk and pass it to the system ``sendmail`` program on a Unix " "system:" msgstr "" -#: ../../library/email.policy.rst:92 +#: ../../library/email.policy.rst:89 msgid "" ">>> from email import message_from_binary_file\n" ">>> from email.generator import BytesGenerator\n" @@ -149,7 +149,7 @@ msgstr "" ">>> p.stdin.close()\n" ">>> rc = p.wait()" -#: ../../library/email.policy.rst:114 +#: ../../library/email.policy.rst:111 msgid "" "Here we are telling :class:`~email.generator.BytesGenerator` to use the RFC " "correct line separator characters when creating the binary string to feed " @@ -157,7 +157,7 @@ msgid "" "line separators." msgstr "" -#: ../../library/email.policy.rst:119 +#: ../../library/email.policy.rst:116 msgid "" "Some email package methods accept a *policy* keyword argument, allowing the " "policy to be overridden for that method. For example, the following code " @@ -166,7 +166,7 @@ msgid "" "line separators for the platform on which it is running::" msgstr "" -#: ../../library/email.policy.rst:125 +#: ../../library/email.policy.rst:122 msgid "" ">>> import os\n" ">>> with open('converted.txt', 'wb') as f:\n" @@ -178,14 +178,14 @@ msgstr "" "... f.write(msg.as_bytes(policy=msg.policy.clone(linesep=os.linesep)))\n" "17" -#: ../../library/email.policy.rst:130 +#: ../../library/email.policy.rst:127 msgid "" "Policy objects can also be combined using the addition operator, producing a " "policy object whose settings are a combination of the non-default values of " "the summed objects::" msgstr "" -#: ../../library/email.policy.rst:134 +#: ../../library/email.policy.rst:131 msgid "" ">>> compat_SMTP = policy.compat32.clone(linesep='\\r\\n')\n" ">>> compat_strict = policy.compat32.clone(raise_on_defect=True)\n" @@ -195,13 +195,13 @@ msgstr "" ">>> compat_strict = policy.compat32.clone(raise_on_defect=True)\n" ">>> compat_strict_SMTP = compat_SMTP + compat_strict" -#: ../../library/email.policy.rst:138 +#: ../../library/email.policy.rst:135 msgid "" "This operation is not commutative; that is, the order in which the objects " "are added matters. To illustrate::" msgstr "" -#: ../../library/email.policy.rst:141 +#: ../../library/email.policy.rst:138 msgid "" ">>> policy100 = policy.compat32.clone(max_line_length=100)\n" ">>> policy80 = policy.compat32.clone(max_line_length=80)\n" @@ -221,7 +221,7 @@ msgstr "" ">>> apolicy.max_line_length\n" "100" -#: ../../library/email.policy.rst:153 +#: ../../library/email.policy.rst:150 msgid "" "This is the :term:`abstract base class` for all policy classes. It provides " "default implementations for a couple of trivial methods, as well as the " @@ -229,7 +229,7 @@ msgid "" "the constructor semantics." msgstr "" -#: ../../library/email.policy.rst:158 +#: ../../library/email.policy.rst:155 msgid "" "The constructor of a policy class can be passed various keyword arguments. " "The arguments that may be specified are any non-method properties on this " @@ -238,48 +238,48 @@ msgid "" "corresponding attribute." msgstr "" -#: ../../library/email.policy.rst:164 +#: ../../library/email.policy.rst:161 msgid "" "This class defines the following properties, and thus values for the " "following may be passed in the constructor of any policy class:" msgstr "" -#: ../../library/email.policy.rst:170 +#: ../../library/email.policy.rst:167 msgid "" "The maximum length of any line in the serialized output, not counting the " "end of line character(s). Default is 78, per :rfc:`5322`. A value of ``0`` " "or :const:`None` indicates that no line wrapping should be done at all." msgstr "" -#: ../../library/email.policy.rst:178 +#: ../../library/email.policy.rst:175 msgid "" "The string to be used to terminate lines in serialized output. The default " "is ``\\n`` because that's the internal end-of-line discipline used by " "Python, though ``\\r\\n`` is required by the RFCs." msgstr "" -#: ../../library/email.policy.rst:185 +#: ../../library/email.policy.rst:182 msgid "" "Controls the type of Content Transfer Encodings that may be or are required " "to be used. The possible values are:" msgstr "" -#: ../../library/email.policy.rst:191 +#: ../../library/email.policy.rst:188 msgid "``7bit``" msgstr "``7bit``" -#: ../../library/email.policy.rst:191 +#: ../../library/email.policy.rst:188 msgid "" "all data must be \"7 bit clean\" (ASCII-only). This means that where " "necessary data will be encoded using either quoted-printable or base64 " "encoding." msgstr "" -#: ../../library/email.policy.rst:195 +#: ../../library/email.policy.rst:192 msgid "``8bit``" msgstr "``8bit``" -#: ../../library/email.policy.rst:195 +#: ../../library/email.policy.rst:192 msgid "" "data is not constrained to be 7 bit clean. Data in headers is still " "required to be ASCII-only and so will be encoded (see :meth:`fold_binary` " @@ -287,7 +287,7 @@ msgid "" "the ``8bit`` CTE." msgstr "" -#: ../../library/email.policy.rst:201 +#: ../../library/email.policy.rst:198 msgid "" "A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not " "``Generator``, because strings cannot contain binary data. If a " @@ -295,28 +295,28 @@ msgid "" "it will act as if ``cte_type`` is ``7bit``." msgstr "" -#: ../../library/email.policy.rst:209 +#: ../../library/email.policy.rst:206 msgid "" "If :const:`True`, any defects encountered will be raised as errors. If :" "const:`False` (the default), defects will be passed to the :meth:" "`register_defect` method." msgstr "" -#: ../../library/email.policy.rst:216 +#: ../../library/email.policy.rst:213 msgid "" "If :const:`True`, lines starting with *\"From \"* in the body are escaped by " "putting a ``>`` in front of them. This parameter is used when the message is " "being serialized by a generator. Default: :const:`False`." msgstr "" -#: ../../library/email.policy.rst:226 +#: ../../library/email.policy.rst:223 msgid "" "A factory function for constructing a new empty message object. Used by the " "parser when building messages. Defaults to ``None``, in which case :class:" "`~email.message.Message` is used." msgstr "" -#: ../../library/email.policy.rst:235 +#: ../../library/email.policy.rst:232 msgid "" "If ``True`` (the default), the generator will raise :exc:`~email.errors." "HeaderWriteError` instead of writing a header that is improperly folded or " @@ -325,53 +325,53 @@ msgid "" "bugs in the ``email`` module." msgstr "" -#: ../../library/email.policy.rst:242 +#: ../../library/email.policy.rst:239 msgid "" "As it's a security feature, this defaults to ``True`` even in the :class:" "`~email.policy.Compat32` policy. For backwards compatible, but unsafe, " "behavior, it must be set to ``False`` explicitly." msgstr "" -#: ../../library/email.policy.rst:250 +#: ../../library/email.policy.rst:247 msgid "" "The following :class:`Policy` method is intended to be called by code using " "the email library to create policy instances with custom settings:" msgstr "" -#: ../../library/email.policy.rst:256 +#: ../../library/email.policy.rst:253 msgid "" "Return a new :class:`Policy` instance whose attributes have the same values " "as the current instance, except where those attributes are given new values " "by the keyword arguments." msgstr "" -#: ../../library/email.policy.rst:261 +#: ../../library/email.policy.rst:258 msgid "" "The remaining :class:`Policy` methods are called by the email package code, " "and are not intended to be called by an application using the email package. " "A custom policy must implement all of these methods." msgstr "" -#: ../../library/email.policy.rst:268 +#: ../../library/email.policy.rst:265 msgid "" "Handle a *defect* found on *obj*. When the email package calls this method, " "*defect* will always be a subclass of :class:`~email.errors.MessageDefect`." msgstr "" -#: ../../library/email.policy.rst:272 +#: ../../library/email.policy.rst:269 msgid "" "The default implementation checks the :attr:`raise_on_defect` flag. If it " "is ``True``, *defect* is raised as an exception. If it is ``False`` (the " "default), *obj* and *defect* are passed to :meth:`register_defect`." msgstr "" -#: ../../library/email.policy.rst:279 +#: ../../library/email.policy.rst:276 msgid "" "Register a *defect* on *obj*. In the email package, *defect* will always be " "a subclass of :class:`~email.errors.MessageDefect`." msgstr "" -#: ../../library/email.policy.rst:282 +#: ../../library/email.policy.rst:279 msgid "" "The default implementation calls the ``append`` method of the ``defects`` " "attribute of *obj*. When the email package calls :attr:`handle_defect`, " @@ -381,11 +381,11 @@ msgid "" "defects in parsed messages will raise unexpected errors." msgstr "" -#: ../../library/email.policy.rst:292 +#: ../../library/email.policy.rst:289 msgid "Return the maximum allowed number of headers named *name*." msgstr "" -#: ../../library/email.policy.rst:294 +#: ../../library/email.policy.rst:291 msgid "" "Called when a header is added to an :class:`~email.message.EmailMessage` or :" "class:`~email.message.Message` object. If the returned value is not ``0`` " @@ -393,7 +393,7 @@ msgid "" "greater than or equal to the value returned, a :exc:`ValueError` is raised." msgstr "" -#: ../../library/email.policy.rst:300 +#: ../../library/email.policy.rst:297 msgid "" "Because the default behavior of ``Message.__setitem__`` is to append the " "value to the list of headers, it is easy to create duplicate headers without " @@ -403,11 +403,11 @@ msgid "" "faithfully produce as many headers as exist in the message being parsed.)" msgstr "" -#: ../../library/email.policy.rst:308 +#: ../../library/email.policy.rst:305 msgid "The default implementation returns ``None`` for all header names." msgstr "" -#: ../../library/email.policy.rst:313 +#: ../../library/email.policy.rst:310 msgid "" "The email package calls this method with a list of strings, each string " "ending with the line separation characters found in the source being " @@ -417,7 +417,7 @@ msgid "" "the parsed header." msgstr "" -#: ../../library/email.policy.rst:320 +#: ../../library/email.policy.rst:317 msgid "" "If an implementation wishes to retain compatibility with the existing email " "package policies, *name* should be the case preserved name (all characters " @@ -426,16 +426,16 @@ msgid "" "stripped of leading whitespace." msgstr "" -#: ../../library/email.policy.rst:326 +#: ../../library/email.policy.rst:323 msgid "*sourcelines* may contain surrogateescaped binary data." msgstr "" -#: ../../library/email.policy.rst:328 ../../library/email.policy.rst:344 -#: ../../library/email.policy.rst:360 +#: ../../library/email.policy.rst:325 ../../library/email.policy.rst:341 +#: ../../library/email.policy.rst:357 msgid "There is no default implementation" msgstr "" -#: ../../library/email.policy.rst:333 +#: ../../library/email.policy.rst:330 msgid "" "The email package calls this method with the name and value provided by the " "application program when the application program is modifying a ``Message`` " @@ -444,14 +444,14 @@ msgid "" "``Message`` to represent the header." msgstr "" -#: ../../library/email.policy.rst:339 +#: ../../library/email.policy.rst:336 msgid "" "If an implementation wishes to retain compatibility with the existing email " "package policies, the *name* and *value* should be strings or string " "subclasses that do not change the content of the passed in arguments." msgstr "" -#: ../../library/email.policy.rst:349 +#: ../../library/email.policy.rst:346 msgid "" "The email package calls this method with the *name* and *value* currently " "stored in the ``Message`` when that header is requested by the application " @@ -462,13 +462,13 @@ msgid "" "returned to the application." msgstr "" -#: ../../library/email.policy.rst:357 +#: ../../library/email.policy.rst:354 msgid "" "*value* may contain surrogateescaped binary data. There should be no " "surrogateescaped binary data in the value returned by the method." msgstr "" -#: ../../library/email.policy.rst:365 +#: ../../library/email.policy.rst:362 msgid "" "The email package calls this method with the *name* and *value* currently " "stored in the ``Message`` for a given header. The method should return a " @@ -478,32 +478,32 @@ msgid "" "discussion of the rules for folding email headers." msgstr "" -#: ../../library/email.policy.rst:372 +#: ../../library/email.policy.rst:369 msgid "" "*value* may contain surrogateescaped binary data. There should be no " "surrogateescaped binary data in the string returned by the method." msgstr "" -#: ../../library/email.policy.rst:378 +#: ../../library/email.policy.rst:375 msgid "" "The same as :meth:`fold`, except that the returned value should be a bytes " "object rather than a string." msgstr "" -#: ../../library/email.policy.rst:381 +#: ../../library/email.policy.rst:378 msgid "" "*value* may contain surrogateescaped binary data. These could be converted " "back into binary data in the returned bytes object." msgstr "" -#: ../../library/email.policy.rst:388 +#: ../../library/email.policy.rst:385 msgid "" "This concrete :class:`Policy` provides behavior that is intended to be fully " "compliant with the current email RFCs. These include (but are not limited " "to) :rfc:`5322`, :rfc:`2047`, and the current MIME RFCs." msgstr "" -#: ../../library/email.policy.rst:392 +#: ../../library/email.policy.rst:389 msgid "" "This policy adds new header parsing and folding algorithms. Instead of " "simple strings, headers are ``str`` subclasses with attributes that depend " @@ -511,31 +511,52 @@ msgid "" "implement :rfc:`2047` and :rfc:`5322`." msgstr "" -#: ../../library/email.policy.rst:397 +#: ../../library/email.policy.rst:394 msgid "" "The default value for the :attr:`~email.policy.Policy.message_factory` " "attribute is :class:`~email.message.EmailMessage`." msgstr "" -#: ../../library/email.policy.rst:400 +#: ../../library/email.policy.rst:397 msgid "" "In addition to the settable attributes listed above that apply to all " "policies, this policy adds the following additional attributes:" msgstr "" -#: ../../library/email.policy.rst:403 +#: ../../library/email.policy.rst:400 msgid "[1]_" msgstr "[1]_" -#: ../../library/email.policy.rst:408 +#: ../../library/email.policy.rst:405 msgid "" "If ``False``, follow :rfc:`5322`, supporting non-ASCII characters in headers " -"by encoding them as \"encoded words\". If ``True``, follow :rfc:`6532` and " -"use ``utf-8`` encoding for headers. Messages formatted in this way may be " -"passed to SMTP servers that support the ``SMTPUTF8`` extension (:rfc:`6531`)." +"by encoding them as :rfc:`2047` \"encoded words\". If ``True``, follow :rfc:" +"`6532` and use ``utf-8`` encoding for headers. Messages formatted in this " +"way may be passed to SMTP servers that support the ``SMTPUTF8`` extension (:" +"rfc:`6531`)." +msgstr "" + +#: ../../library/email.policy.rst:411 +msgid "" +"When ``False``, the generator will raise :exc:`~email.errors." +"HeaderWriteError` if any header includes non-ASCII characters in a context " +"where :rfc:`2047` does not permit encoded words. This particularly applies " +"to mailboxes (\"addr-spec\") with non-ASCII characters, which can be created " +"via :class:`~email.headerregistry.Address`. To use a mailbox with a non-" +"ASCII domain name with ``utf8=False``, first encode the domain using the " +"third-party :pypi:`idna` or :pypi:`uts46` module or with :mod:`encodings." +"idna`. It is not possible to use a non-ASCII username (\"local-part\") in a " +"mailbox when ``utf8=False``." msgstr "" -#: ../../library/email.policy.rst:417 +#: ../../library/email.policy.rst:422 +msgid "" +"Can trigger the raising of :exc:`~email.errors.HeaderWriteError`. (Earlier " +"versions incorrectly applied :rfc:`2047` in certain contexts, mostly notably " +"in addr-specs.)" +msgstr "" + +#: ../../library/email.policy.rst:429 msgid "" "If the value for a header in the ``Message`` object originated from a :mod:" "`~email.parser` (as opposed to being set by a program), this attribute " @@ -543,37 +564,37 @@ msgid "" "transforming the message back into serialized form. The possible values are:" msgstr "" -#: ../../library/email.policy.rst:424 +#: ../../library/email.policy.rst:436 msgid "``none``" msgstr "``none``" -#: ../../library/email.policy.rst:424 +#: ../../library/email.policy.rst:436 msgid "all source values use original folding" msgstr "" -#: ../../library/email.policy.rst:426 +#: ../../library/email.policy.rst:438 msgid "``long``" msgstr "``long``" -#: ../../library/email.policy.rst:426 +#: ../../library/email.policy.rst:438 msgid "" "source values that have any line that is longer than ``max_line_length`` " "will be refolded" msgstr "" -#: ../../library/email.policy.rst:429 +#: ../../library/email.policy.rst:441 msgid "``all``" msgstr "``all``" -#: ../../library/email.policy.rst:429 +#: ../../library/email.policy.rst:441 msgid "all values are refolded." msgstr "" -#: ../../library/email.policy.rst:432 +#: ../../library/email.policy.rst:444 msgid "The default is ``long``." msgstr "預設為 ``long``。" -#: ../../library/email.policy.rst:437 +#: ../../library/email.policy.rst:449 msgid "" "A callable that takes two arguments, ``name`` and ``value``, where ``name`` " "is a header field name and ``value`` is an unfolded header field value, and " @@ -584,7 +605,7 @@ msgid "" "custom parsing will be added in the future." msgstr "" -#: ../../library/email.policy.rst:448 +#: ../../library/email.policy.rst:460 msgid "" "An object with at least two methods: get_content and set_content. When the :" "meth:`~email.message.EmailMessage.get_content` or :meth:`~email.message." @@ -595,20 +616,20 @@ msgid "" "``content_manager`` is set to :data:`~email.contentmanager.raw_data_manager`." msgstr "" -#: ../../library/email.policy.rst:460 ../../library/email.policy.rst:618 +#: ../../library/email.policy.rst:472 ../../library/email.policy.rst:630 msgid "" "The class provides the following concrete implementations of the abstract " "methods of :class:`Policy`:" msgstr "" -#: ../../library/email.policy.rst:466 +#: ../../library/email.policy.rst:478 msgid "" "Returns the value of the :attr:`~email.headerregistry.BaseHeader.max_count` " "attribute of the specialized class used to represent the header with the " "given name." msgstr "" -#: ../../library/email.policy.rst:474 ../../library/email.policy.rst:624 +#: ../../library/email.policy.rst:486 ../../library/email.policy.rst:636 msgid "" "The name is parsed as everything up to the '``:``' and returned unmodified. " "The value is determined by stripping leading whitespace off the remainder of " @@ -616,7 +637,7 @@ msgid "" "trailing carriage return or linefeed characters." msgstr "" -#: ../../library/email.policy.rst:482 +#: ../../library/email.policy.rst:494 msgid "" "The name is returned unchanged. If the input value has a ``name`` attribute " "and it matches *name* ignoring case, the value is returned unchanged. " @@ -625,7 +646,7 @@ msgid "" "``ValueError`` is raised if the input value contains CR or LF characters." msgstr "" -#: ../../library/email.policy.rst:492 +#: ../../library/email.policy.rst:504 msgid "" "If the value has a ``name`` attribute, it is returned to unmodified. " "Otherwise the *name*, and the *value* with any CR or LF characters removed, " @@ -634,7 +655,7 @@ msgid "" "character glyph." msgstr "" -#: ../../library/email.policy.rst:501 +#: ../../library/email.policy.rst:513 msgid "" "Header folding is controlled by the :attr:`refold_source` policy setting. A " "value is considered to be a 'source value' if and only if it does not have a " @@ -646,7 +667,7 @@ msgid "" "current policy." msgstr "" -#: ../../library/email.policy.rst:510 +#: ../../library/email.policy.rst:522 msgid "" "Source values are split into lines using :meth:`~str.splitlines`. If the " "value is not to be refolded, the lines are rejoined using the ``linesep`` " @@ -656,13 +677,13 @@ msgid "" "using the ``unknown-8bit`` charset." msgstr "" -#: ../../library/email.policy.rst:520 +#: ../../library/email.policy.rst:532 msgid "" "The same as :meth:`fold` if :attr:`~Policy.cte_type` is ``7bit``, except " "that the returned value is bytes." msgstr "" -#: ../../library/email.policy.rst:523 +#: ../../library/email.policy.rst:535 msgid "" "If :attr:`~Policy.cte_type` is ``8bit``, non-ASCII binary data is converted " "back into bytes. Headers with binary data are not refolded, regardless of " @@ -670,7 +691,7 @@ msgid "" "binary data consists of single byte characters or multibyte characters." msgstr "" -#: ../../library/email.policy.rst:530 +#: ../../library/email.policy.rst:542 msgid "" "The following instances of :class:`EmailPolicy` provide defaults suitable " "for specific application domains. Note that in the future the behavior of " @@ -678,20 +699,20 @@ msgid "" "conform even more closely to the RFCs relevant to their domains." msgstr "" -#: ../../library/email.policy.rst:538 +#: ../../library/email.policy.rst:550 msgid "" "An instance of ``EmailPolicy`` with all defaults unchanged. This policy " "uses the standard Python ``\\n`` line endings rather than the RFC-correct " "``\\r\\n``." msgstr "" -#: ../../library/email.policy.rst:545 +#: ../../library/email.policy.rst:557 msgid "" "Suitable for serializing messages in conformance with the email RFCs. Like " "``default``, but with ``linesep`` set to ``\\r\\n``, which is RFC compliant." msgstr "" -#: ../../library/email.policy.rst:552 +#: ../../library/email.policy.rst:564 msgid "" "The same as ``SMTP`` except that :attr:`~EmailPolicy.utf8` is ``True``. " "Useful for serializing messages to a message store without using encoded " @@ -700,50 +721,50 @@ msgid "" "SMTP.send_message` method handles this automatically)." msgstr "" -#: ../../library/email.policy.rst:561 +#: ../../library/email.policy.rst:573 msgid "" "Suitable for serializing headers with for use in HTTP traffic. Like " "``SMTP`` except that ``max_line_length`` is set to ``None`` (unlimited)." msgstr "" -#: ../../library/email.policy.rst:567 +#: ../../library/email.policy.rst:579 msgid "" "Convenience instance. The same as ``default`` except that " "``raise_on_defect`` is set to ``True``. This allows any policy to be made " "strict by writing::" msgstr "" -#: ../../library/email.policy.rst:571 +#: ../../library/email.policy.rst:583 msgid "somepolicy + policy.strict" msgstr "somepolicy + policy.strict" -#: ../../library/email.policy.rst:574 +#: ../../library/email.policy.rst:586 msgid "" "With all of these :class:`EmailPolicies <.EmailPolicy>`, the effective API " "of the email package is changed from the Python 3.2 API in the following " "ways:" msgstr "" -#: ../../library/email.policy.rst:577 +#: ../../library/email.policy.rst:589 msgid "" "Setting a header on a :class:`~email.message.Message` results in that header " "being parsed and a header object created." msgstr "" -#: ../../library/email.policy.rst:580 +#: ../../library/email.policy.rst:592 msgid "" "Fetching a header value from a :class:`~email.message.Message` results in " "that header being parsed and a header object created and returned." msgstr "" -#: ../../library/email.policy.rst:584 +#: ../../library/email.policy.rst:596 msgid "" "Any header object, or any header that is refolded due to the policy " "settings, is folded using an algorithm that fully implements the RFC folding " "algorithms, including knowing where encoded words are required and allowed." msgstr "" -#: ../../library/email.policy.rst:589 +#: ../../library/email.policy.rst:601 msgid "" "From the application view, this means that any header obtained through the :" "class:`~email.message.EmailMessage` is a header object with extra " @@ -753,13 +774,13 @@ msgid "" "the correct RFC encoded form." msgstr "" -#: ../../library/email.policy.rst:596 +#: ../../library/email.policy.rst:608 msgid "" "The header objects and their attributes are described in :mod:`~email." "headerregistry`." msgstr "" -#: ../../library/email.policy.rst:603 +#: ../../library/email.policy.rst:615 msgid "" "This concrete :class:`Policy` is the backward compatibility policy. It " "replicates the behavior of the email package in Python 3.2. The :mod:`!" @@ -768,28 +789,28 @@ msgid "" "package is to maintain compatibility with Python 3.2." msgstr "" -#: ../../library/email.policy.rst:609 +#: ../../library/email.policy.rst:621 msgid "" "The following attributes have values that are different from the :class:" "`Policy` default:" msgstr "" -#: ../../library/email.policy.rst:615 +#: ../../library/email.policy.rst:627 msgid "The default is ``True``." msgstr "預設值為 ``True``。" -#: ../../library/email.policy.rst:632 +#: ../../library/email.policy.rst:644 msgid "The name and value are returned unmodified." msgstr "名稱和值會原封不動地回傳。" -#: ../../library/email.policy.rst:637 +#: ../../library/email.policy.rst:649 msgid "" "If the value contains binary data, it is converted into a :class:`~email." "header.Header` object using the ``unknown-8bit`` charset. Otherwise it is " "returned unmodified." msgstr "" -#: ../../library/email.policy.rst:644 +#: ../../library/email.policy.rst:656 msgid "" "Headers are folded using the :class:`~email.header.Header` folding " "algorithm, which preserves existing line breaks in the value, and wraps each " @@ -797,7 +818,7 @@ msgid "" "encoded using the ``unknown-8bit`` charset." msgstr "" -#: ../../library/email.policy.rst:652 +#: ../../library/email.policy.rst:664 msgid "" "Headers are folded using the :class:`~email.header.Header` folding " "algorithm, which preserves existing line breaks in the value, and wraps each " @@ -807,24 +828,24 @@ msgid "" "and any (RFC invalid) binary data it may contain." msgstr "" -#: ../../library/email.policy.rst:662 +#: ../../library/email.policy.rst:674 msgid "" "An instance of :class:`Compat32`, providing backward compatibility with the " "behavior of the email package in Python 3.2." msgstr "" -#: ../../library/email.policy.rst:667 +#: ../../library/email.policy.rst:679 msgid "" "The :const:`compat32` policy should not be used as a policy for :class:" "`~email.message.EmailMessage` objects, and should only be used to serialize " "messages that were created using the :const:`compat32` policy." msgstr "" -#: ../../library/email.policy.rst:674 +#: ../../library/email.policy.rst:686 msgid "Footnotes" msgstr "註解" -#: ../../library/email.policy.rst:675 +#: ../../library/email.policy.rst:687 msgid "" "Originally added in 3.3 as a :term:`provisional feature `." diff --git a/library/enum.po b/library/enum.po index aaf9cbace3b..734dd7c3b2f 100644 --- a/library/enum.po +++ b/library/enum.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,57 +21,57 @@ msgstr "" msgid ":mod:`!enum` --- Support for enumerations" msgstr ":mod:`!enum` --- 對列舉的支援" -#: ../../library/enum.rst:14 +#: ../../library/enum.rst:9 msgid "**Source code:** :source:`Lib/enum.py`" msgstr "**原始碼:**\\ :source:`Lib/enum.py`" -#: ../../library/enum.rst:18 +#: ../../library/enum.rst:13 msgid "" "This page contains the API reference information. For tutorial information " "and discussion of more advanced topics, see" msgstr "本頁包含 API 的參考資訊。關於教學資訊及更多進階主題的討論請參考" -#: ../../library/enum.rst:21 +#: ../../library/enum.rst:16 msgid ":ref:`Basic Tutorial `" msgstr ":ref:`基本教學 `" -#: ../../library/enum.rst:22 +#: ../../library/enum.rst:17 msgid ":ref:`Advanced Tutorial `" msgstr ":ref:`進階教學 `" -#: ../../library/enum.rst:23 +#: ../../library/enum.rst:18 msgid ":ref:`Enum Cookbook `" msgstr ":ref:`列舉指南 `" -#: ../../library/enum.rst:27 +#: ../../library/enum.rst:22 msgid "An enumeration:" msgstr "列舉:" -#: ../../library/enum.rst:29 +#: ../../library/enum.rst:24 msgid "is a set of symbolic names (members) bound to unique values" msgstr "是一組綁定唯一值的代表名稱(成員)" -#: ../../library/enum.rst:30 +#: ../../library/enum.rst:25 msgid "" "can be iterated over to return its canonical (i.e. non-alias) members in " "definition order" msgstr "可以用疊代的方式以定義的順序回傳其正式 (canonical)(即非別名)成員" -#: ../../library/enum.rst:32 +#: ../../library/enum.rst:27 msgid "uses *call* syntax to return members by value" msgstr "使用 *call* 語法來透過值回傳成員" -#: ../../library/enum.rst:33 +#: ../../library/enum.rst:28 msgid "uses *index* syntax to return members by name" msgstr "使用 *index* 語法來透過名稱回傳成員" -#: ../../library/enum.rst:35 +#: ../../library/enum.rst:30 msgid "" "Enumerations are created either by using :keyword:`class` syntax, or by " "using function-call syntax::" msgstr "列舉透過 :keyword:`class` 語法或函式呼叫的語法來建立: ::" -#: ../../library/enum.rst:38 +#: ../../library/enum.rst:33 msgid "" ">>> from enum import Enum\n" "\n" @@ -95,7 +95,7 @@ msgstr "" ">>> # 函式語法\n" ">>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])" -#: ../../library/enum.rst:49 +#: ../../library/enum.rst:44 msgid "" "Even though we can use :keyword:`class` syntax to create Enums, Enums are " "not normal Python classes. See :ref:`How are Enums different? `\\ 以取得更多細節。" -#: ../../library/enum.rst:53 +#: ../../library/enum.rst:48 msgid "Nomenclature" msgstr "命名方式" -#: ../../library/enum.rst:55 +#: ../../library/enum.rst:50 msgid "The class :class:`!Color` is an *enumeration* (or *enum*)" msgstr ":class:`!Color` 類別是一個\\ *列舉*\\ (或 *enum*)" -#: ../../library/enum.rst:56 +#: ../../library/enum.rst:51 msgid "" "The attributes :attr:`!Color.RED`, :attr:`!Color.GREEN`, etc., are " "*enumeration members* (or *members*) and are functionally constants." @@ -120,7 +120,7 @@ msgstr "" ":attr:`!Color.RED`、:attr:`!Color.GREEN` 等屬性是\\ *列舉成員*\\ (或\\ *成員" "*),並且使用上可以看作常數。" -#: ../../library/enum.rst:58 +#: ../../library/enum.rst:53 msgid "" "The enum members have *names* and *values* (the name of :attr:`!Color.RED` " "is ``RED``, the value of :attr:`!Color.BLUE` is ``3``, etc.)" @@ -128,31 +128,31 @@ msgstr "" "列舉成員有\\ *名稱*\\ 和\\ *值*\\ (:attr:`!Color.RED` 的名稱是 ``RED``,:" "attr:`!Color.BLUE` 的值是 ``3`` 諸如此類)" -#: ../../library/enum.rst:65 +#: ../../library/enum.rst:60 msgid "Module contents" msgstr "模組內容" -#: ../../library/enum.rst:67 +#: ../../library/enum.rst:62 msgid ":class:`EnumType`" msgstr ":class:`EnumType`" -#: ../../library/enum.rst:69 +#: ../../library/enum.rst:64 msgid "The ``type`` for Enum and its subclasses." msgstr "Enum 及其子類別的 ``type``。" -#: ../../library/enum.rst:71 +#: ../../library/enum.rst:66 msgid ":class:`Enum`" msgstr ":class:`Enum`" -#: ../../library/enum.rst:73 +#: ../../library/enum.rst:68 msgid "Base class for creating enumerated constants." msgstr "用來建立列舉常數的基礎類別。" -#: ../../library/enum.rst:75 +#: ../../library/enum.rst:70 msgid ":class:`IntEnum`" msgstr ":class:`IntEnum`" -#: ../../library/enum.rst:77 +#: ../../library/enum.rst:72 msgid "" "Base class for creating enumerated constants that are also subclasses of :" "class:`int`. (`Notes`_)" @@ -160,11 +160,11 @@ msgstr "" "用來建立列舉常數的基礎類別,同時也是 :class:`int` 的子類別。(`備註 " "`_)" -#: ../../library/enum.rst:80 +#: ../../library/enum.rst:75 msgid ":class:`StrEnum`" msgstr ":class:`StrEnum`" -#: ../../library/enum.rst:82 +#: ../../library/enum.rst:77 msgid "" "Base class for creating enumerated constants that are also subclasses of :" "class:`str`. (`Notes`_)" @@ -172,11 +172,11 @@ msgstr "" "用來建立列舉常數的基礎類別,同時也是 :class:`str` 的子類別。(`備註 " "`_)" -#: ../../library/enum.rst:85 +#: ../../library/enum.rst:80 msgid ":class:`Flag`" msgstr ":class:`Flag`" -#: ../../library/enum.rst:87 +#: ../../library/enum.rst:82 msgid "" "Base class for creating enumerated constants that can be combined using the " "bitwise operations without losing their :class:`Flag` membership." @@ -184,11 +184,11 @@ msgstr "" "用來建立列舉常數的基礎類別,可以使用位元操作來結合成員且其結果不失去 :class:" "`Flag` 的成員資格。" -#: ../../library/enum.rst:90 +#: ../../library/enum.rst:85 msgid ":class:`IntFlag`" msgstr ":class:`IntFlag`" -#: ../../library/enum.rst:92 +#: ../../library/enum.rst:87 msgid "" "Base class for creating enumerated constants that can be combined using the " "bitwise operators without losing their :class:`IntFlag` membership. :class:" @@ -198,11 +198,11 @@ msgstr "" "`IntFlag` 的成員資格。:class:`IntFlag` 的成員也是 :class:`int` 的子類別。(`" "備註 `_)" -#: ../../library/enum.rst:96 +#: ../../library/enum.rst:91 msgid ":class:`ReprEnum`" msgstr ":class:`ReprEnum`" -#: ../../library/enum.rst:98 +#: ../../library/enum.rst:93 msgid "" "Used by :class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag` to keep " "the :class:`str() ` of the mixed-in type." @@ -210,11 +210,11 @@ msgstr "" "由 :class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag` 所使用來保留這些混" "合型別的 :class:`str() `。" -#: ../../library/enum.rst:101 +#: ../../library/enum.rst:96 msgid ":class:`EnumCheck`" msgstr ":class:`EnumCheck`" -#: ../../library/enum.rst:103 +#: ../../library/enum.rst:98 msgid "" "An enumeration with the values ``CONTINUOUS``, ``NAMED_FLAGS``, and " "``UNIQUE``, for use with :func:`verify` to ensure various constraints are " @@ -223,11 +223,11 @@ msgstr "" "一個有 ``CONTINUOUS``、``NAMED_FLAGS`` 及 ``UNIQUE`` 這些值的列舉,和 :func:" "`verify` 一起使用來確保給定的列舉符合多種限制。" -#: ../../library/enum.rst:107 +#: ../../library/enum.rst:102 msgid ":class:`FlagBoundary`" msgstr ":class:`FlagBoundary`" -#: ../../library/enum.rst:109 +#: ../../library/enum.rst:104 msgid "" "An enumeration with the values ``STRICT``, ``CONFORM``, ``EJECT``, and " "``KEEP`` which allows for more fine-grained control over how invalid values " @@ -236,19 +236,19 @@ msgstr "" "一個有 ``STRICT``、``CONFORM``、``EJECT`` 及 ``KEEP`` 這些值的列舉,允許列舉" "對如何處理非法值做更細微的控制。" -#: ../../library/enum.rst:113 +#: ../../library/enum.rst:108 msgid ":class:`EnumDict`" msgstr ":class:`EnumDict`" -#: ../../library/enum.rst:115 +#: ../../library/enum.rst:110 msgid "A subclass of :class:`dict` for use when subclassing :class:`EnumType`." msgstr ":class:`dict` 的子類別,用於當作 :class:`EnumType` 的子類別時使用。" -#: ../../library/enum.rst:117 +#: ../../library/enum.rst:112 msgid ":class:`auto`" msgstr ":class:`auto`" -#: ../../library/enum.rst:119 +#: ../../library/enum.rst:114 msgid "" "Instances are replaced with an appropriate value for Enum members. :class:" "`StrEnum` defaults to the lower-cased version of the member name, while " @@ -257,11 +257,11 @@ msgstr "" "列舉成員的實例會被取代成合適的值。:class:`StrEnum` 預設是小寫版本的成員名稱," "其它列舉則預設是 1 且往後遞增。" -#: ../../library/enum.rst:123 +#: ../../library/enum.rst:118 msgid ":deco:`~enum.property`" msgstr ":deco:`~enum.property`" -#: ../../library/enum.rst:125 +#: ../../library/enum.rst:120 msgid "" "Allows :class:`Enum` members to have attributes without conflicting with " "member names. The ``value`` and ``name`` attributes are implemented this " @@ -270,46 +270,46 @@ msgstr "" "允許 :class:`Enum` 成員擁有屬性且不會與成員名稱有衝突。``value`` 及 ``name`` " "屬性是用這個方式來實作。" -#: ../../library/enum.rst:129 +#: ../../library/enum.rst:124 msgid ":deco:`unique`" msgstr ":deco:`unique`" -#: ../../library/enum.rst:131 +#: ../../library/enum.rst:126 msgid "" "Enum class decorator that ensures only one name is bound to any one value." msgstr "Enum 類別的裝飾器,用來確保任何值只有綁定到一個名稱上。" -#: ../../library/enum.rst:133 +#: ../../library/enum.rst:128 msgid ":deco:`verify`" msgstr ":deco:`verify`" -#: ../../library/enum.rst:135 +#: ../../library/enum.rst:130 msgid "" "Enum class decorator that checks user-selectable constraints on an " "enumeration." msgstr "Enum 類別的裝飾器,用來檢查列舉上使用者所選的限制。" -#: ../../library/enum.rst:138 +#: ../../library/enum.rst:133 msgid ":deco:`member`" msgstr ":deco:`member`" -#: ../../library/enum.rst:140 +#: ../../library/enum.rst:135 msgid "Make ``obj`` a member. Can be used as a decorator." msgstr "讓 ``obj`` 變成成員。可以當作裝飾器使用。" -#: ../../library/enum.rst:142 +#: ../../library/enum.rst:137 msgid ":deco:`nonmember`" msgstr ":deco:`nonmember`" -#: ../../library/enum.rst:144 +#: ../../library/enum.rst:139 msgid "Do not make ``obj`` a member. Can be used as a decorator." msgstr "不讓 ``obj`` 變成成員。可以當作裝飾器使用。" -#: ../../library/enum.rst:146 +#: ../../library/enum.rst:141 msgid ":deco:`global_enum`" msgstr ":deco:`global_enum`" -#: ../../library/enum.rst:148 +#: ../../library/enum.rst:143 msgid "" "Modify the :class:`str() ` and :func:`repr` of an enum to show its " "members as belonging to the module instead of its class, and export the enum " @@ -318,19 +318,19 @@ msgstr "" "修改列舉上的 :class:`str() ` 及 :func:`repr` ,讓成員顯示為屬於模組而不" "是類別,並將該列舉成員匯出到全域命名空間。" -#: ../../library/enum.rst:152 +#: ../../library/enum.rst:147 msgid ":func:`show_flag_values`" msgstr ":func:`show_flag_values`" -#: ../../library/enum.rst:154 +#: ../../library/enum.rst:149 msgid "Return a list of all power-of-two integers contained in a flag." msgstr "回傳旗標 (flag) 裡包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:156 +#: ../../library/enum.rst:151 msgid ":func:`enum.bin`" msgstr ":func:`enum.bin`" -#: ../../library/enum.rst:158 ../../library/enum.rst:1081 +#: ../../library/enum.rst:153 ../../library/enum.rst:1076 msgid "" "Like built-in :func:`bin`, except negative values are represented in two's " "complement, and the leading bit always indicates sign (``0`` implies " @@ -339,11 +339,11 @@ msgstr "" "與內建的 :func:`bin` 類似,但負值以二補數表示,且前導位元永遠表示正負號" "(``0`` 表示正,``1`` 表示負)。" -#: ../../library/enum.rst:163 +#: ../../library/enum.rst:158 msgid "``Flag``, ``IntFlag``, ``auto``" msgstr "``Flag``, ``IntFlag``, ``auto``" -#: ../../library/enum.rst:164 +#: ../../library/enum.rst:159 msgid "" "``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, " "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" @@ -351,15 +351,15 @@ msgstr "" "``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, " "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" -#: ../../library/enum.rst:165 +#: ../../library/enum.rst:160 msgid "``EnumDict``" msgstr "``EnumDict``" -#: ../../library/enum.rst:170 +#: ../../library/enum.rst:165 msgid "Data types" msgstr "資料型別" -#: ../../library/enum.rst:175 +#: ../../library/enum.rst:170 msgid "" "*EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible " "to subclass *EnumType* -- see :ref:`Subclassing EnumType `。" -#: ../../library/enum.rst:179 +#: ../../library/enum.rst:174 msgid "" "``EnumType`` is responsible for setting the correct :meth:`!__repr__`, :meth:" "`!__str__`, :meth:`!__format__`, and :meth:`!__reduce__` methods on the " @@ -379,17 +379,17 @@ msgstr "" "`!__str__`、:meth:`!__format__` 及 :meth:`!__reduce__` 方法,以及建立列舉成" "員、正確處理重複、提供列舉類別的疊代等等。" -#: ../../library/enum.rst:186 +#: ../../library/enum.rst:181 msgid "" "Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available " "as an alias." msgstr "在 3.11 之前,``EnumType`` 稱作 ``EnumMeta``,其目前仍可作為別名使用。" -#: ../../library/enum.rst:190 +#: ../../library/enum.rst:185 msgid "This method is called in two different ways:" msgstr "這個方法可以用兩種不同的方式呼叫:" -#: ../../library/enum.rst:192 +#: ../../library/enum.rst:187 msgid "to look up an existing member:" msgstr "查詢已存在的成員:" @@ -397,7 +397,7 @@ msgstr "查詢已存在的成員:" msgid "cls" msgstr "cls" -#: ../../library/enum.rst:194 ../../library/enum.rst:200 +#: ../../library/enum.rst:189 ../../library/enum.rst:195 msgid "The enum class being called." msgstr "所呼叫的列舉類別。" @@ -405,17 +405,17 @@ msgstr "所呼叫的列舉類別。" msgid "value" msgstr "value" -#: ../../library/enum.rst:195 +#: ../../library/enum.rst:190 msgid "The value to lookup." msgstr "要查詢的值。" -#: ../../library/enum.rst:197 +#: ../../library/enum.rst:192 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:201 +#: ../../library/enum.rst:196 msgid "The name of the new Enum to create." msgstr "要建立的新列舉的名稱。" @@ -423,7 +423,7 @@ msgstr "要建立的新列舉的名稱。" msgid "names" msgstr "names" -#: ../../library/enum.rst:202 +#: ../../library/enum.rst:197 msgid "The names/values of the members for the new Enum." msgstr "新列舉的成員的名稱/值。" @@ -431,7 +431,7 @@ msgstr "新列舉的成員的名稱/值。" msgid "module" msgstr "module" -#: ../../library/enum.rst:203 +#: ../../library/enum.rst:198 msgid "The name of the module the new Enum is created in." msgstr "新列舉要建立在哪個模組名稱下。" @@ -439,7 +439,7 @@ msgstr "新列舉要建立在哪個模組名稱下。" msgid "qualname" msgstr "qualname" -#: ../../library/enum.rst:204 +#: ../../library/enum.rst:199 msgid "The actual location in the module where this Enum can be found." msgstr "這個列舉在模組裡實際上的位置。" @@ -447,7 +447,7 @@ msgstr "這個列舉在模組裡實際上的位置。" msgid "type" msgstr "type" -#: ../../library/enum.rst:205 +#: ../../library/enum.rst:200 msgid "A mix-in type for the new Enum." msgstr "新列舉的混合型別。" @@ -455,7 +455,7 @@ msgstr "新列舉的混合型別。" msgid "start" msgstr "start" -#: ../../library/enum.rst:206 +#: ../../library/enum.rst:201 msgid "The first integer value for the Enum (used by :class:`auto`)." msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" @@ -463,16 +463,16 @@ msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" msgid "boundary" msgstr "boundary" -#: ../../library/enum.rst:207 +#: ../../library/enum.rst:202 msgid "" "How to handle out-of-range values from bit operations (:class:`Flag` only)." msgstr "在位元操作時怎麼處理範圍外的值(只有 :class:`Flag` 會用到)" -#: ../../library/enum.rst:211 +#: ../../library/enum.rst:206 msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "如果 member 屬於 ``cls`` 則回傳 ``True``: ::" -#: ../../library/enum.rst:213 +#: ../../library/enum.rst:208 msgid "" ">>> some_var = Color.RED\n" ">>> some_var in Color\n" @@ -486,7 +486,7 @@ msgstr "" ">>> Color.RED.value in Color\n" "True" -#: ../../library/enum.rst:221 +#: ../../library/enum.rst:216 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " "in a containment check." @@ -494,7 +494,7 @@ msgstr "" "在 Python 3.12 之前,如果用非列舉成員做屬於檢查 (containment check) 會引發 " "``TypeError``。" -#: ../../library/enum.rst:226 +#: ../../library/enum.rst:221 msgid "" "Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the " "names of the members in *cls*::" @@ -502,7 +502,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__members__', '__module__']`` 及 *cls* 的成" "員名稱: ::" -#: ../../library/enum.rst:229 +#: ../../library/enum.rst:224 msgid "" ">>> dir(Color)\n" "['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " @@ -514,13 +514,13 @@ msgstr "" "'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " "'__module__', '__name__', '__qualname__']" -#: ../../library/enum.rst:234 +#: ../../library/enum.rst:229 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" msgstr "回傳 *cls* 中符合 *name* 的列舉成員,或引發 :exc:`KeyError`: ::" -#: ../../library/enum.rst:236 +#: ../../library/enum.rst:231 msgid "" ">>> Color['BLUE']\n" "" @@ -528,11 +528,11 @@ msgstr "" ">>> Color['BLUE']\n" "" -#: ../../library/enum.rst:241 +#: ../../library/enum.rst:236 msgid "Returns each member in *cls* in definition order::" msgstr "以定義的順序回傳在 *cls* 中的每個成員: ::" -#: ../../library/enum.rst:243 +#: ../../library/enum.rst:238 msgid "" ">>> list(Color)\n" "[, , ]" @@ -540,11 +540,11 @@ msgstr "" ">>> list(Color)\n" "[, , ]" -#: ../../library/enum.rst:248 +#: ../../library/enum.rst:243 msgid "Returns the number of members in *cls*::" msgstr "回傳 *cls* 的成員數量: ::" -#: ../../library/enum.rst:250 +#: ../../library/enum.rst:245 msgid "" ">>> len(Color)\n" "3" @@ -552,15 +552,15 @@ msgstr "" ">>> len(Color)\n" "3" -#: ../../library/enum.rst:255 +#: ../../library/enum.rst:250 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "回傳每個列舉名稱到其成員的對映,包括別名" -#: ../../library/enum.rst:259 +#: ../../library/enum.rst:254 msgid "Returns each member in *cls* in reverse definition order::" msgstr "以跟定義相反的順序回傳 *cls* 的每個成員: ::" -#: ../../library/enum.rst:261 +#: ../../library/enum.rst:256 msgid "" ">>> list(reversed(Color))\n" "[, , ]" @@ -568,15 +568,15 @@ msgstr "" ">>> list(reversed(Color))\n" "[, , ]" -#: ../../library/enum.rst:267 +#: ../../library/enum.rst:262 msgid "*Enum* is the base class for all *enum* enumerations." msgstr "*Enum* 是所有 *enum* 列舉的基礎類別。" -#: ../../library/enum.rst:271 +#: ../../library/enum.rst:266 msgid "The name used to define the ``Enum`` member::" msgstr "用來定義 ``Enum`` 成員的名稱: ::" -#: ../../library/enum.rst:273 +#: ../../library/enum.rst:268 msgid "" ">>> Color.BLUE.name\n" "'BLUE'" @@ -584,11 +584,11 @@ msgstr "" ">>> Color.BLUE.name\n" "'BLUE'" -#: ../../library/enum.rst:278 +#: ../../library/enum.rst:273 msgid "The value given to the ``Enum`` member::" msgstr "``Enum`` 成員給定的值: ::" -#: ../../library/enum.rst:280 +#: ../../library/enum.rst:275 msgid "" ">>> Color.RED.value\n" "1" @@ -596,15 +596,15 @@ msgstr "" ">>> Color.RED.value\n" "1" -#: ../../library/enum.rst:283 ../../library/enum.rst:303 +#: ../../library/enum.rst:278 ../../library/enum.rst:298 msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "成員的值,可以在 :meth:`~Enum.__new__` 設定。" -#: ../../library/enum.rst:285 +#: ../../library/enum.rst:280 msgid "Enum member values" msgstr "列舉成員的值" -#: ../../library/enum.rst:287 +#: ../../library/enum.rst:282 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 " @@ -614,7 +614,7 @@ msgstr "" "重要,你可以使用 :class:`auto` 實例,它會為你選擇合適的值。更多細節請參考 :" "class:`auto`。" -#: ../../library/enum.rst:292 +#: ../../library/enum.rst:287 msgid "" "While mutable/unhashable values, such as :class:`dict`, :class:`list` or a " "mutable :class:`~dataclasses.dataclass`, can be used, they will have a " @@ -625,24 +625,24 @@ msgstr "" "`dict`、:class:`list` 或可變的 :class:`~dataclasses.dataclass`,它們在建立期" "間會對效能產生相對於列舉中可變的 / 不可雜湊的值總數量的二次方影響。" -#: ../../library/enum.rst:299 +#: ../../library/enum.rst:294 msgid "Name of the member." msgstr "成員名稱。" -#: ../../library/enum.rst:307 +#: ../../library/enum.rst:302 msgid "" "No longer used, kept for backward compatibility. (class attribute, removed " "during class creation)." msgstr "已不再使用,只為了向後相容而保留(類別屬性,在類別建立時移除)" -#: ../../library/enum.rst:310 +#: ../../library/enum.rst:305 msgid "" "The :attr:`~Enum._order_` attribute can be provided to help keep Python 2 / " "Python 3 code in sync. It will be checked against the actual order of the " "enumeration and raise an error if the two do not match::" msgstr "" -#: ../../library/enum.rst:313 +#: ../../library/enum.rst:308 msgid "" ">>> class Color(Enum):\n" "... _order_ = 'RED GREEN BLUE'\n" @@ -657,19 +657,19 @@ msgid "" " ['RED', 'GREEN', 'BLUE']" msgstr "" -#: ../../library/enum.rst:327 +#: ../../library/enum.rst:322 msgid "" "In Python 2 code the :attr:`~Enum._order_` attribute is necessary as " "definition order is lost before it can be recorded." msgstr "" -#: ../../library/enum.rst:334 +#: ../../library/enum.rst:329 msgid "" "``_ignore_`` is only used during creation and is removed from the " "enumeration once creation is complete." msgstr "``_ignore_`` 只有在建立的時候用到,在列舉建立完成後會被移除。" -#: ../../library/enum.rst:337 +#: ../../library/enum.rst:332 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:" @@ -678,7 +678,7 @@ msgstr "" "``_ignore_`` 是一個不會變成成員的名稱串列,在列舉建立完成後其名稱會被移除。範" "例請參考 :ref:`TimePeriod `。" -#: ../../library/enum.rst:345 +#: ../../library/enum.rst:340 msgid "" "Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and any " "public methods defined on *self.__class__*::" @@ -686,7 +686,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__module__', 'name', 'value']`` 及任何 " "*self.__class__* 上定義的公開方法: ::" -#: ../../library/enum.rst:348 +#: ../../library/enum.rst:343 msgid "" ">>> from enum import Enum\n" ">>> import datetime as dt\n" @@ -728,11 +728,11 @@ msgstr "" msgid "name" msgstr "name" -#: ../../library/enum.rst:367 +#: ../../library/enum.rst:362 msgid "The name of the member being defined (e.g. 'RED')." msgstr "定義的成員名稱(例如 'RED')。" -#: ../../library/enum.rst:368 +#: ../../library/enum.rst:363 msgid "The start value for the Enum; the default is 1." msgstr "列舉的開始值,預設為 1。" @@ -740,7 +740,7 @@ msgstr "列舉的開始值,預設為 1。" msgid "count" msgstr "count" -#: ../../library/enum.rst:369 +#: ../../library/enum.rst:364 msgid "The number of members currently defined, not including this one." msgstr "已定義的成員數量,不包含目前這一個。" @@ -748,35 +748,35 @@ msgstr "已定義的成員數量,不包含目前這一個。" msgid "last_values" msgstr "last_values" -#: ../../library/enum.rst:370 +#: ../../library/enum.rst:365 msgid "A list of the previous values." msgstr "一個之前值的串列。" -#: ../../library/enum.rst:372 +#: ../../library/enum.rst:367 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`." msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值。" -#: ../../library/enum.rst:376 +#: ../../library/enum.rst:371 msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " "value seen incremented by one." msgstr "" "對標準的 :class:`Enum` 類別來說,下一個被選擇的值是所看過的最大值加一。" -#: ../../library/enum.rst:379 +#: ../../library/enum.rst:374 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two." msgstr "" "對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方的數字。" -#: ../../library/enum.rst:382 +#: ../../library/enum.rst:377 msgid "This method may be overridden, e.g.::" msgstr "" -#: ../../library/enum.rst:384 +#: ../../library/enum.rst:379 msgid "" ">>> from enum import auto, Enum\n" ">>> class PowersOfThree(Enum):\n" @@ -800,12 +800,12 @@ msgstr "" ">>> PowersOfThree.SECOND.value\n" "9" -#: ../../library/enum.rst:396 +#: ../../library/enum.rst:391 msgid "" "Prior versions would use the last seen value instead of the highest value." msgstr "" -#: ../../library/enum.rst:401 +#: ../../library/enum.rst:396 msgid "" "By default, does nothing. If multiple values are given in the member " "assignment, those values become separate arguments to ``__init__``; e.g." @@ -813,19 +813,19 @@ msgstr "" "預設情況下,不執行任何操作。如果在成員賦值中給出多個值,這些值將成為與 " "``__init__`` 分別的引數;例如" -#: ../../library/enum.rst:408 +#: ../../library/enum.rst:403 msgid "" "``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, " "'Mon')``" msgstr "``Weekday.__init__()`` 將被稱為 ``Weekday.__init__(self, 1, 'Mon')``" -#: ../../library/enum.rst:412 +#: ../../library/enum.rst:407 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。" -#: ../../library/enum.rst:417 +#: ../../library/enum.rst:412 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::" @@ -833,7 +833,7 @@ msgstr "" "一個 *classmethod*,用來查詢在 *cls* 裡找不到的值。預設不做任何事,但可以被覆" "寫以實作客製化的搜尋行為: ::" -#: ../../library/enum.rst:420 +#: ../../library/enum.rst:415 msgid "" ">>> from enum import auto, StrEnum\n" ">>> class Build(StrEnum):\n" @@ -869,7 +869,7 @@ msgstr "" ">>> Build('deBUG')\n" "" -#: ../../library/enum.rst:441 +#: ../../library/enum.rst:436 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 " @@ -878,12 +878,12 @@ msgstr "" "預設情況下不存在。如果有指定,無論是在列舉類別定義中還是在 mixin 類別中(例" "如 ``int``\\ ),都將傳遞成員賦值中給出的所有值;例如" -#: ../../library/enum.rst:449 +#: ../../library/enum.rst:444 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "會產生呼叫 ``int('1a', 16)`` 而該成員的值為 ``26``。" -#: ../../library/enum.rst:453 +#: ../../library/enum.rst:448 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." @@ -891,7 +891,7 @@ msgstr "" "當寫自訂的 ``__new__`` 時,不要使用 ``super().__new__``,而是要呼叫適當的 " "``__new__``。" -#: ../../library/enum.rst:458 +#: ../../library/enum.rst:453 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" @@ -899,7 +899,7 @@ msgstr "" "回傳呼叫 *repr()* 時使用的字串。預設回傳 *Enum* 名稱、成員名稱及值,但可以被" "覆寫: ::" -#: ../../library/enum.rst:461 +#: ../../library/enum.rst:456 msgid "" ">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" @@ -927,7 +927,7 @@ msgstr "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" -#: ../../library/enum.rst:475 +#: ../../library/enum.rst:470 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" @@ -935,7 +935,7 @@ msgstr "" "回傳呼叫 *str()* 時使用的字串。預設回傳 *Enum* 名稱及成員名稱,但可以被覆" "寫: ::" -#: ../../library/enum.rst:478 +#: ../../library/enum.rst:473 msgid "" ">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" @@ -961,7 +961,7 @@ msgstr "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:491 +#: ../../library/enum.rst:486 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" @@ -969,7 +969,7 @@ msgstr "" "回傳呼叫 *format()* 及 *f-string* 時使用的字串。預設回傳 :meth:`__str__` 的回" "傳值,但可以被覆寫: ::" -#: ../../library/enum.rst:494 +#: ../../library/enum.rst:489 msgid "" ">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" @@ -995,21 +995,21 @@ msgstr "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:507 +#: ../../library/enum.rst:502 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:510 -msgid "Added :ref:`enum-dataclass-support`" -msgstr "新增 :ref:`enum-dataclass-support`" +#: ../../library/enum.rst:505 +msgid "Added :ref:`enum-dataclass-support`." +msgstr "新增 :ref:`enum-dataclass-support`。" -#: ../../library/enum.rst:514 +#: ../../library/enum.rst:509 msgid "Adds a new name as an alias to an existing member::" msgstr "新增一個名稱作為現有成員的別名: ::" -#: ../../library/enum.rst:516 +#: ../../library/enum.rst:511 msgid "" ">>> Color.RED._add_alias_(\"ERROR\")\n" ">>> Color.ERROR\n" @@ -1019,17 +1019,17 @@ msgstr "" ">>> Color.ERROR\n" "" -#: ../../library/enum.rst:520 +#: ../../library/enum.rst:515 msgid "" "Raises a :exc:`NameError` if the name is already assigned to a different " "member." msgstr "如果該名稱已經被指派給不同的成員,則會引發 :exc:`NameError`。" -#: ../../library/enum.rst:526 +#: ../../library/enum.rst:521 msgid "Adds a new value as an alias to an existing member::" msgstr "新增一個值作為現有成員的別名: ::" -#: ../../library/enum.rst:528 +#: ../../library/enum.rst:523 msgid "" ">>> Color.RED._add_value_alias_(42)\n" ">>> Color(42)\n" @@ -1039,17 +1039,17 @@ msgstr "" ">>> Color(42)\n" "" -#: ../../library/enum.rst:532 +#: ../../library/enum.rst:527 msgid "" "Raises a :exc:`ValueError` if the value is already linked with a different " "member." msgstr "如果該值已經被連結到不同的成員,則會引發 :exc:`ValueError`。" -#: ../../library/enum.rst:533 +#: ../../library/enum.rst:528 msgid "See :ref:`multi-value-enum` for an example." msgstr "" -#: ../../library/enum.rst:540 +#: ../../library/enum.rst:535 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 " @@ -1059,13 +1059,13 @@ msgstr "" "*IntEnum* 和 :class:`Enum` 一樣,但其成員同時也是整數而可以被用在任何使用整數" "的地方。如果 *IntEnum* 成員經過任何整數運算,結果值會失去其列舉狀態。" -#: ../../library/enum.rst:561 +#: ../../library/enum.rst:556 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:564 +#: ../../library/enum.rst:559 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` was " @@ -1075,7 +1075,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:571 +#: ../../library/enum.rst:566 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 " @@ -1085,7 +1085,7 @@ msgstr "" "*StrEnum* 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使用" "字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" -#: ../../library/enum.rst:592 +#: ../../library/enum.rst:587 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 " @@ -1096,13 +1096,13 @@ msgstr "" "是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方" "你需要使用 ``str(MyStrEnum.MY_MEMBER)``。" -#: ../../library/enum.rst:599 +#: ../../library/enum.rst:594 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:604 +#: ../../library/enum.rst:599 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " @@ -1112,7 +1112,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!str.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 也會是 :meth:`!str.__format__`。" -#: ../../library/enum.rst:612 +#: ../../library/enum.rst:607 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " @@ -1122,11 +1122,11 @@ msgstr "" "(*OR*)、``^`` (*XOR*) 和 ``~`` (*INVERT*);這些操作的結果是列舉的成員(的別" "名)。" -#: ../../library/enum.rst:618 +#: ../../library/enum.rst:613 msgid "Returns *True* if value is in self::" msgstr "如果 value 在 self 裡則回傳 *True*: ::" -#: ../../library/enum.rst:620 +#: ../../library/enum.rst:615 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1162,11 +1162,11 @@ msgstr "" ">>> white in purple\n" "False" -#: ../../library/enum.rst:639 +#: ../../library/enum.rst:634 msgid "Returns all contained non-alias members::" msgstr "回傳所有包含的非別名成員: ::" -#: ../../library/enum.rst:641 +#: ../../library/enum.rst:636 msgid "" ">>> list(Color.RED)\n" "[]\n" @@ -1178,11 +1178,11 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../library/enum.rst:650 +#: ../../library/enum.rst:645 msgid "Returns number of members in flag::" msgstr "回傳旗標裡的成員數量: ::" -#: ../../library/enum.rst:652 +#: ../../library/enum.rst:647 msgid "" ">>> len(Color.GREEN)\n" "1\n" @@ -1194,11 +1194,11 @@ msgstr "" ">>> len(white)\n" "3" -#: ../../library/enum.rst:661 +#: ../../library/enum.rst:656 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "如果成員在旗標裡則回傳 *True*,否則回傳 *False*: ::" -#: ../../library/enum.rst:663 +#: ../../library/enum.rst:658 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1216,11 +1216,11 @@ msgstr "" ">>> bool(black)\n" "False" -#: ../../library/enum.rst:673 +#: ../../library/enum.rst:668 msgid "Returns current flag binary or'ed with other::" msgstr "回傳和 other 做 OR 過後的二進位旗標: ::" -#: ../../library/enum.rst:675 +#: ../../library/enum.rst:670 msgid "" ">>> Color.RED | Color.GREEN\n" "" @@ -1228,11 +1228,11 @@ msgstr "" ">>> Color.RED | Color.GREEN\n" "" -#: ../../library/enum.rst:680 +#: ../../library/enum.rst:675 msgid "Returns current flag binary and'ed with other::" msgstr "回傳和 other 做 AND 過後的二進位旗標: ::" -#: ../../library/enum.rst:682 +#: ../../library/enum.rst:677 msgid "" ">>> purple & white\n" "\n" @@ -1244,11 +1244,11 @@ msgstr "" ">>> purple & Color.GREEN\n" "" -#: ../../library/enum.rst:689 +#: ../../library/enum.rst:684 msgid "Returns current flag binary xor'ed with other::" msgstr "回傳和 other 做 XOR 過後的二進位旗標: ::" -#: ../../library/enum.rst:691 +#: ../../library/enum.rst:686 msgid "" ">>> purple ^ white\n" "\n" @@ -1260,11 +1260,11 @@ msgstr "" ">>> purple ^ Color.GREEN\n" "" -#: ../../library/enum.rst:698 +#: ../../library/enum.rst:693 msgid "Returns all the flags in *type(self)* that are not in *self*::" msgstr "回傳所有在 *type(self)* 但不在 *self* 裡的旗標: ::" -#: ../../library/enum.rst:700 +#: ../../library/enum.rst:695 msgid "" ">>> ~white\n" "\n" @@ -1280,7 +1280,7 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../library/enum.rst:709 +#: ../../library/enum.rst:704 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." @@ -1288,17 +1288,17 @@ msgstr "" "用來格式化任何剩下未命名數值的函式。預設是值的 repr,常見選擇是 :func:`hex` " "和 :func:`oct`。" -#: ../../library/enum.rst:714 +#: ../../library/enum.rst:709 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:717 +#: ../../library/enum.rst:712 msgid "The *repr()* of zero-valued flags has changed. It is now:" msgstr "值為 0 的旗標的 *repr()* 已改變。現在是:" -#: ../../library/enum.rst:725 +#: ../../library/enum.rst:720 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." @@ -1306,13 +1306,13 @@ msgstr "" "``IntFlag`` 和 :class:`Flag` 一樣,但其成員同時也是整數而可以被用在任何使用整" "數的地方。" -#: ../../library/enum.rst:739 +#: ../../library/enum.rst:734 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "如果 *IntFlag* 成員經過任何整數運算,其結果不是 *IntFlag*: ::" -#: ../../library/enum.rst:742 +#: ../../library/enum.rst:737 msgid "" ">>> Color.RED + 2\n" "3" @@ -1320,25 +1320,25 @@ msgstr "" ">>> Color.RED + 2\n" "3" -#: ../../library/enum.rst:745 +#: ../../library/enum.rst:740 msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" msgstr "如果 *IntFlag* 成員經過 :class:`Flag` 操作且:" -#: ../../library/enum.rst:747 +#: ../../library/enum.rst:742 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果是合法的 *IntFlag*:回傳 *IntFlag*" -#: ../../library/enum.rst:748 +#: ../../library/enum.rst:743 msgid "" "the result is not a valid *IntFlag*: the result depends on the :class:" "`FlagBoundary` setting" msgstr "結果不是合法的 *IntFlag*:結果會根據 :class:`FlagBoundary` 的設定" -#: ../../library/enum.rst:750 +#: ../../library/enum.rst:745 msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now::" msgstr "未命名且值為 0 的旗標的 :func:`repr` 已改變。現在是: ::" -#: ../../library/enum.rst:752 +#: ../../library/enum.rst:747 msgid "" ">>> Color(0)\n" "" @@ -1346,14 +1346,14 @@ msgstr "" ">>> Color(0)\n" "" -#: ../../library/enum.rst:757 +#: ../../library/enum.rst:752 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:762 +#: ../../library/enum.rst:757 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " @@ -1363,7 +1363,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:766 +#: ../../library/enum.rst:761 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 " @@ -1372,7 +1372,7 @@ msgstr "" ":class:`!IntFlag` 的反轉 (inversion) 現在會回傳正值,該值是不在給定旗標的所有" "旗標聯集,而不是一個負值。這符合現有 :class:`Flag` 的行為。" -#: ../../library/enum.rst:772 +#: ../../library/enum.rst:767 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" @@ -1380,15 +1380,15 @@ msgstr "" ":class:`!ReprEnum` 使用 :class:`Enum` 的 :meth:`repr() `,但使" "用混合資料型別的 :class:`str() `:" -#: ../../library/enum.rst:775 +#: ../../library/enum.rst:770 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "對 :class:`IntEnum` 和 :class:`IntFlag` 是 :meth:`!int.__str__`" -#: ../../library/enum.rst:776 +#: ../../library/enum.rst:771 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "對 :class:`StrEnum` 是 :meth:`!str.__str__`" -#: ../../library/enum.rst:778 +#: ../../library/enum.rst:773 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" @@ -1397,7 +1397,7 @@ msgstr "" "繼承 :class:`!ReprEnum` 來保留混合資料型別的 :class:`str() ` / :func:" "`format`,而不是使用 :class:`Enum` 預設的 :meth:`str() `。" -#: ../../library/enum.rst:787 +#: ../../library/enum.rst:782 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." @@ -1405,11 +1405,11 @@ msgstr "" "*EnumCheck* 包含 :func:`verify` 裝飾器使用的選項,以確保多樣的限制,不符合限" "制會產生 :exc:`ValueError`。" -#: ../../library/enum.rst:792 +#: ../../library/enum.rst:787 msgid "Ensure that each value has only one name::" msgstr "確保每個值只有一個名稱: ::" -#: ../../library/enum.rst:794 +#: ../../library/enum.rst:789 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1433,13 +1433,13 @@ msgstr "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" -#: ../../library/enum.rst:808 +#: ../../library/enum.rst:803 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "確保在最小值成員跟最大值成員間沒有缺少值: ::" -#: ../../library/enum.rst:811 +#: ../../library/enum.rst:806 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1461,7 +1461,7 @@ msgstr "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:823 +#: ../../library/enum.rst:818 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" @@ -1469,7 +1469,7 @@ msgstr "" "確保任何旗標群組 / 遮罩只包含命名旗標 -- 當值是用指定而不是透過 :func:`auto` " "產生時是很實用的: ::" -#: ../../library/enum.rst:826 +#: ../../library/enum.rst:821 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1497,24 +1497,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:840 +#: ../../library/enum.rst:835 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "CONTINUOUS 和 NAMED_FLAGS 是設計用來運作在整數值的成員上。" -#: ../../library/enum.rst:846 +#: ../../library/enum.rst:841 msgid "" "``FlagBoundary`` controls how out-of-range values are handled in :class:" "`Flag` and its subclasses." msgstr "``FlagBoundary`` 控制在 :class:`Flag` 及其子類別中如何處理範圍外的值。" -#: ../../library/enum.rst:851 +#: ../../library/enum.rst:846 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:854 +#: ../../library/enum.rst:849 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1542,13 +1542,13 @@ msgstr "" " given 0b0 10100\n" " allowed 0b0 00111" -#: ../../library/enum.rst:869 +#: ../../library/enum.rst:864 msgid "" "Out-of-range values have invalid values removed, leaving a valid :class:" "`Flag` value::" msgstr "會移除範圍外的值中的非法值,留下合法的 :class:`Flag` 值: ::" -#: ../../library/enum.rst:872 +#: ../../library/enum.rst:867 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1568,13 +1568,13 @@ msgstr "" ">>> ConformFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:883 +#: ../../library/enum.rst:878 msgid "" "Out-of-range values lose their :class:`Flag` membership and revert to :class:" "`int`." msgstr "範圍外的值會失去它們的 :class:`Flag` 成員資格且恢復成 :class:`int`。" -#: ../../library/enum.rst:896 +#: ../../library/enum.rst:891 msgid "" "Out-of-range values are kept, and the :class:`Flag` membership is kept. This " "is the default for :class:`IntFlag`::" @@ -1582,7 +1582,7 @@ msgstr "" "範圍外的值會被保留,:class:`Flag` 成員資格也會被保留。這是 :class:`IntFlag` " "的預設行為: ::" -#: ../../library/enum.rst:899 +#: ../../library/enum.rst:894 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1602,7 +1602,7 @@ msgstr "" ">>> KeepFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:912 +#: ../../library/enum.rst:907 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 " @@ -1616,7 +1616,7 @@ msgstr "" "如讓每個成員有多個值。它應該在被呼叫時帶上正在建立的列舉類別名稱,否則私有名" "稱和內部類別將無法被正確處理。" -#: ../../library/enum.rst:919 +#: ../../library/enum.rst:914 msgid "" "Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" "`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " @@ -1627,15 +1627,15 @@ msgstr "" "__setitem__` 和 :meth:`~dict.update`)被覆寫。可能可以使用其他 :class:`!" "dict` 操作來繞過檢查,例如 :meth:`|= `。" -#: ../../library/enum.rst:926 +#: ../../library/enum.rst:921 msgid "A list of member names." msgstr "一個成員名稱的串列。" -#: ../../library/enum.rst:935 +#: ../../library/enum.rst:930 msgid "Supported ``__dunder__`` names" msgstr "支援的 ``__dunder__`` 名稱" -#: ../../library/enum.rst:937 +#: ../../library/enum.rst:932 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." @@ -1643,7 +1643,7 @@ msgstr "" ":attr:`~EnumType.__members__` 是一個唯讀有序的\\ ``成員名稱``:``成員``\\ 項" "目的對映。只有在類別上可用。" -#: ../../library/enum.rst:940 +#: ../../library/enum.rst:935 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:`~Enum." @@ -1654,26 +1654,26 @@ msgstr "" "的 :attr:`~Enum._value_` 也是一個很好的主意。一旦所有成員都建立之後就不會再被" "用到。" -#: ../../library/enum.rst:946 +#: ../../library/enum.rst:941 msgid "Supported ``_sunder_`` names" msgstr "支援的 ``_sunder_`` 名稱" -#: ../../library/enum.rst:948 +#: ../../library/enum.rst:943 msgid ":attr:`~Enum._name_` -- name of the member" msgstr ":attr:`~Enum._name_` -- 成員名稱" -#: ../../library/enum.rst:949 +#: ../../library/enum.rst:944 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- 成員的值;可以在 ``__new__`` 設定" -#: ../../library/enum.rst:950 +#: ../../library/enum.rst:945 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 當值沒有被找到時會使用的查詢函式;可以被覆寫" -#: ../../library/enum.rst:952 +#: ../../library/enum.rst:947 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 " @@ -1682,7 +1682,7 @@ msgstr "" ":attr:`~Enum._ignore_` -- 一個名稱的串列,可以是 :class:`list` 或 :class:" "`str`,它不會被轉換成成員,且在最後的類別上會被移除" -#: ../../library/enum.rst:955 +#: ../../library/enum.rst:950 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" @@ -1690,26 +1690,26 @@ msgstr "" ":attr:`~Enum._order_` -- 不再被使用,僅為了向後相容而保留(類別屬性,在類別建" "立時移除)" -#: ../../library/enum.rst:958 +#: ../../library/enum.rst:953 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:961 +#: ../../library/enum.rst:956 msgid "" ":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr ":meth:`~Enum._add_alias_` -- 新增一個名稱作為現有成員的別名。" -#: ../../library/enum.rst:963 +#: ../../library/enum.rst:958 msgid "" ":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " "existing member." msgstr ":meth:`~Enum._add_value_alias_` -- 新增一個值作為現有成員的別名。" -#: ../../library/enum.rst:966 +#: ../../library/enum.rst:961 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:" @@ -1717,57 +1717,59 @@ msgstr "" "雖然 ``_sunder_`` 名稱通常保留用於 :class:`Enum` 類別的進一步開發而不能被使" "用,但有些是明確允許的:" -#: ../../library/enum.rst:969 +#: ../../library/enum.rst:964 msgid "" "``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" msgstr "" "``_repr_*``\\ (例如 ``_repr_html_``),例如用於 `IPython 的豐富顯示 " "`_" -#: ../../library/enum.rst:971 +#: ../../library/enum.rst:966 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../library/enum.rst:972 +#: ../../library/enum.rst:967 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:973 +#: ../../library/enum.rst:968 msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" msgstr "``_add_alias_``、``_add_value_alias_``、``_repr_*``" -#: ../../library/enum.rst:979 +#: ../../library/enum.rst:974 msgid "Utilities and decorators" msgstr "通用項目與裝飾器" -#: ../../library/enum.rst:983 +#: ../../library/enum.rst:978 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 " "appropriate value. For :class:`Enum` and :class:`IntEnum` that appropriate " -"value will be the last value plus one; for :class:`Flag` and :class:" -"`IntFlag` it will be the first power-of-two greater than the highest value; " -"for :class:`StrEnum` it will be the lower-cased version of the member's " -"name. Care must be taken if mixing *auto()* with manually specified values." +"value will be the highest value seen plus one; for :class:`Flag` and :class:" +"`IntFlag` it will be the first power-of-two greater than the highest value " +"seen; for :class:`StrEnum` it will be the lower-cased version of the " +"member's name. Care must be taken if mixing *auto()* with manually " +"specified values." msgstr "" -"*auto* 可以用來取代給值。如果使用的話,*Enum* 系統會呼叫 :class:`Enum` 的 :" -"meth:`~Enum._generate_next_value_` 來取得合適的值。對 :class:`Enum` 和 :" -"class:`IntEnum` 來說,合適的值是最後一個值加一;對 :class:`Flag` 和 :class:" -"`IntFlag` 來說,是第一個比最大值還大的 2 的次方的數字;對 :class:`StrEnum` 來" -"說,是成員名稱的小寫版本。如果混用 *auto()* 和手動指定值的話要特別注意。" +"*auto* 可以用來取代給值。如果使用的話,*Enum* 系統會呼叫 :class:`Enum` " +"的 :meth:`~Enum._generate_next_value_` 來取得合適的值。對 :class:`Enum` " +"和 :class:`IntEnum` 來說,合適的值是目前看到的最大值加一;對 :class:`Flag` " +"和 :class:`IntFlag` 來說,是第一個比目前看到的最大值還大的 2 的次方的數字;" +"對 :class:`StrEnum` 來說,是成員名稱的小寫版本。如果混用 *auto()* 和手動指定" +"值的話要特別注意。" -#: ../../library/enum.rst:991 +#: ../../library/enum.rst:986 msgid "" "*auto* instances are only resolved when at the top level of an assignment, " "either by itself or as part of a tuple:" msgstr "" "*auto* 實例只有在最上層的賦值時才會被解析,不論是獨自一個或作為元組的一部分:" -#: ../../library/enum.rst:994 +#: ../../library/enum.rst:989 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "``FIRST = auto()`` 可以運作(auto() 會被取代成 ``1``)" -#: ../../library/enum.rst:995 +#: ../../library/enum.rst:990 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" @@ -1775,36 +1777,36 @@ msgstr "" "``SECOND = auto(), -2`` 可以運作(auto 會被取代成 ``2``, 因此 ``2, -2`` 會被" "用來建立列舉成員 ``SECOND``;" -#: ../../library/enum.rst:997 +#: ../../library/enum.rst:992 msgid "" -"``THREE = [auto(), -3]`` will *not* work (``[, -3]`` is used " -"to create the ``THREE`` enum member)" +"``THIRD = [auto(), -3]`` will *not* work (``[, -3]`` is used " +"to create the ``THIRD`` enum member)" msgstr "" -"``THREE = [auto(), -3]`` *無法*\\ 運作(``[, -3]`` 會被用來建" -"立列舉成員 ``THREE``)" +"``THIRD = [auto(), -3]`` *無法*\\ 運作(``[, -3]`` 會被用來建" +"立列舉成員 ``THIRD``)" -#: ../../library/enum.rst:1002 +#: ../../library/enum.rst:997 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "在之前的版本中,``auto()`` 必須是賦值行裡的唯一內容才能運作正確。" -#: ../../library/enum.rst:1005 +#: ../../library/enum.rst:1000 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "可以覆寫 ``_generate_next_value_`` 來客製 *auto* 使用的值。" -#: ../../library/enum.rst:1008 +#: ../../library/enum.rst:1003 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 " +"In version 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 " "incompatible type." msgstr "" -"在 3.13 預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果任何成員" -"是不相容的型別就會失敗。" +"在 3.13 版本中,預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果" +"任何成員是不相容的型別就會失敗。" -#: ../../library/enum.rst:1014 +#: ../../library/enum.rst:1009 msgid "" "A decorator similar to the built-in :deco:`property`, but specifically for " "enumerations. It allows member attributes to have the same names as members " @@ -1813,9 +1815,9 @@ msgstr "" "和內建的 :deco:`property` 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成" "員本身有相同名稱。" -#: ../../library/enum.rst:1018 +#: ../../library/enum.rst:1013 msgid "" -"the *property* and the member must be defined in separate classes; for " +"The *property* and the member must be defined in separate classes; for " "example, the *value* and *name* attributes are defined in the *Enum* class, " "and *Enum* subclasses can define members with the names ``value`` and " "``name``." @@ -1823,7 +1825,7 @@ msgstr "" "*屬性*\\ 和成員必須定義在分開的類別裡;例如 *value* 和 *name* 屬性定義在 " "*Enum* 類別而 *Enum* 子類別可以定義成員名稱為 ``value`` 和 ``name``。" -#: ../../library/enum.rst:1027 +#: ../../library/enum.rst:1022 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " @@ -1833,7 +1835,7 @@ msgstr "" "__members__`,蒐集任何它找到的別名;如果有找到任何別名則引發 :exc:" "`ValueError` 並附上細節: ::" -#: ../../library/enum.rst:1031 +#: ../../library/enum.rst:1026 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1859,7 +1861,7 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../library/enum.rst:1045 +#: ../../library/enum.rst:1040 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " @@ -1868,15 +1870,15 @@ msgstr "" "專門針對列舉的 :keyword:`class` 裝飾器。使用 :class:`EnumCheck` 裡的成員來指" "定在裝飾的列舉上應該檢查什麼限制。" -#: ../../library/enum.rst:1053 +#: ../../library/enum.rst:1048 msgid "A decorator for use in enums: its target will become a member." msgstr "列舉所使用的裝飾器:其目標會變成成員。" -#: ../../library/enum.rst:1059 +#: ../../library/enum.rst:1054 msgid "A decorator for use in enums: its target will not become a member." msgstr "列舉所使用的裝飾器:其目標不會變成成員。" -#: ../../library/enum.rst:1065 +#: ../../library/enum.rst:1060 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 " @@ -1887,19 +1889,19 @@ msgstr "" "組而不是其類別。應該只有當列舉成員被匯出到模組的全域命名空間才使用(範例請參" "考 :class:`re.RegexFlag`)。" -#: ../../library/enum.rst:1075 +#: ../../library/enum.rst:1070 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "回傳在旗標\\ *值*\\ 中包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:1096 +#: ../../library/enum.rst:1091 msgid "Notes" msgstr "備註" -#: ../../library/enum.rst:1098 +#: ../../library/enum.rst:1093 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr ":class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag`" -#: ../../library/enum.rst:1100 +#: ../../library/enum.rst:1095 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:" @@ -1907,17 +1909,17 @@ msgstr "" "這三種列舉型別是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" "制:" -#: ../../library/enum.rst:1103 +#: ../../library/enum.rst:1098 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "``__str__`` 使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1105 +#: ../../library/enum.rst:1100 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:1108 +#: ../../library/enum.rst:1103 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::" @@ -1925,7 +1927,7 @@ msgstr "" "如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 型別來建立自" "己的基礎類別: ::" -#: ../../library/enum.rst:1111 +#: ../../library/enum.rst:1106 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" @@ -1935,11 +1937,11 @@ msgstr "" ">>> class MyIntEnum(int, Enum):\n" "... pass" -#: ../../library/enum.rst:1115 +#: ../../library/enum.rst:1110 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "或者你也可以在你的列舉重新給定合適的 :meth:`str`: ::" -#: ../../library/enum.rst:1117 +#: ../../library/enum.rst:1112 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" diff --git a/library/faulthandler.po b/library/faulthandler.po index 6a951db496c..e219baa49a6 100644 --- a/library/faulthandler.po +++ b/library/faulthandler.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -65,97 +65,105 @@ msgid "" msgstr "" #: ../../library/faulthandler.rst:34 -msgid "It is limited to 100 frames and 100 threads." +msgid "" +"It is limited to 100 frames per thread, and 100 threads (configurable via " +"*max_threads*)." msgstr "" -#: ../../library/faulthandler.rst:35 +#: ../../library/faulthandler.rst:36 msgid "The order is reversed: the most recent call is shown first." msgstr "" -#: ../../library/faulthandler.rst:37 +#: ../../library/faulthandler.rst:38 msgid "" "By default, the Python traceback is written to :data:`sys.stderr`. To see " "tracebacks, applications must be run in the terminal. A log file can " "alternatively be passed to :func:`faulthandler.enable`." msgstr "" -#: ../../library/faulthandler.rst:41 +#: ../../library/faulthandler.rst:42 msgid "" "The module is implemented in C, so tracebacks can be dumped on a crash or " "when Python is deadlocked." msgstr "" -#: ../../library/faulthandler.rst:44 +#: ../../library/faulthandler.rst:45 msgid "" "The :ref:`Python Development Mode ` " "calls :func:`faulthandler.enable` at Python startup." msgstr "" -#: ../../library/faulthandler.rst:49 +#: ../../library/faulthandler.rst:50 msgid "Module :mod:`pdb`" msgstr ":mod:`pdb` 模組" -#: ../../library/faulthandler.rst:50 +#: ../../library/faulthandler.rst:51 msgid "Interactive source code debugger for Python programs." msgstr "" -#: ../../library/faulthandler.rst:52 +#: ../../library/faulthandler.rst:53 msgid "Module :mod:`traceback`" msgstr ":mod:`traceback` 模組" -#: ../../library/faulthandler.rst:53 +#: ../../library/faulthandler.rst:54 msgid "" "Standard interface to extract, format and print stack traces of Python " "programs." msgstr "" -#: ../../library/faulthandler.rst:56 +#: ../../library/faulthandler.rst:57 msgid "Dumping the traceback" msgstr "" -#: ../../library/faulthandler.rst:60 +#: ../../library/faulthandler.rst:61 msgid "" "Dump the tracebacks of all threads into *file*. If *all_threads* is " -"``False``, dump only the current thread." +"``False``, dump only the current thread. *max_threads* caps the number of " +"threads dumped." msgstr "" -#: ../../library/faulthandler.rst:63 +#: ../../library/faulthandler.rst:65 msgid "" ":func:`traceback.print_tb`, which can be used to print a traceback object." msgstr "" -#: ../../library/faulthandler.rst:65 ../../library/faulthandler.rst:119 -#: ../../library/faulthandler.rst:165 ../../library/faulthandler.rst:190 +#: ../../library/faulthandler.rst:67 ../../library/faulthandler.rst:126 +#: ../../library/faulthandler.rst:175 ../../library/faulthandler.rst:204 msgid "Added support for passing file descriptor to this function." msgstr "新增傳遞檔案描述器給此函式的支援。" -#: ../../library/faulthandler.rst:70 +#: ../../library/faulthandler.rst:70 ../../library/faulthandler.rst:143 +#: ../../library/faulthandler.rst:181 ../../library/faulthandler.rst:207 +msgid "Added the *max_threads* keyword argument." +msgstr "" + +#: ../../library/faulthandler.rst:75 msgid "Dumping the C stack" msgstr "" -#: ../../library/faulthandler.rst:76 +#: ../../library/faulthandler.rst:81 msgid "Dump the C stack trace of the current thread into *file*." msgstr "" -#: ../../library/faulthandler.rst:78 +#: ../../library/faulthandler.rst:83 msgid "" "If the Python build does not support it or the operating system does not " "provide a stack trace, then this prints an error in place of a dumped C " "stack." msgstr "" -#: ../../library/faulthandler.rst:85 +#: ../../library/faulthandler.rst:90 msgid "C Stack Compatibility" msgstr "" -#: ../../library/faulthandler.rst:87 +#: ../../library/faulthandler.rst:92 msgid "" "If the system does not support the C-level :manpage:`backtrace(3)` " "or :manpage:`dladdr1(3)`, then C stack dumps will not work. An error will be " "printed instead of the stack." msgstr "" -#: ../../library/faulthandler.rst:91 +#: ../../library/faulthandler.rst:96 msgid "" "Additionally, some compilers do not support :term:`CPython's ` " "implementation of C stack dumps. As a result, a different error may be " @@ -163,17 +171,17 @@ msgid "" "stacks." msgstr "" -#: ../../library/faulthandler.rst:97 +#: ../../library/faulthandler.rst:102 msgid "" "Dumping C stacks can be arbitrarily slow, depending on the DWARF level of " "the binaries in the call stack." msgstr "" -#: ../../library/faulthandler.rst:101 +#: ../../library/faulthandler.rst:106 msgid "Fault handler state" msgstr "" -#: ../../library/faulthandler.rst:105 +#: ../../library/faulthandler.rst:110 msgid "" "Enable the fault handler: install handlers for " "the :const:`~signal.SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS` " @@ -182,117 +190,123 @@ msgid "" "Otherwise, dump only the current thread." msgstr "" -#: ../../library/faulthandler.rst:112 +#: ../../library/faulthandler.rst:117 msgid "" "The *file* must be kept open until the fault handler is disabled: " "see :ref:`issue with file descriptors `." msgstr "" -#: ../../library/faulthandler.rst:115 +#: ../../library/faulthandler.rst:120 msgid "" "If *c_stack* is ``True``, then the C stack trace is printed after the Python " "traceback, unless the system does not support it. See :func:`dump_c_stack` " "for more information on compatibility." msgstr "" -#: ../../library/faulthandler.rst:122 +#: ../../library/faulthandler.rst:124 +msgid "" +"*max_threads* caps the number of threads dumped when a fatal signal fires." +msgstr "" + +#: ../../library/faulthandler.rst:129 msgid "On Windows, a handler for Windows exception is also installed." msgstr "" -#: ../../library/faulthandler.rst:125 +#: ../../library/faulthandler.rst:132 msgid "" "The dump now mentions if a garbage collector collection is running if " "*all_threads* is true." msgstr "" -#: ../../library/faulthandler.rst:129 +#: ../../library/faulthandler.rst:136 msgid "" "Only the current thread is dumped if the :term:`GIL` is disabled to prevent " "the risk of data races." msgstr "" -#: ../../library/faulthandler.rst:133 +#: ../../library/faulthandler.rst:140 msgid "The dump now displays the C stack trace if *c_stack* is true." msgstr "" -#: ../../library/faulthandler.rst:138 +#: ../../library/faulthandler.rst:148 msgid "" "Disable the fault handler: uninstall the signal handlers installed " "by :func:`enable`." msgstr "" -#: ../../library/faulthandler.rst:143 +#: ../../library/faulthandler.rst:153 msgid "Check if the fault handler is enabled." msgstr "" -#: ../../library/faulthandler.rst:147 +#: ../../library/faulthandler.rst:157 msgid "Dumping the tracebacks after a timeout" msgstr "" -#: ../../library/faulthandler.rst:151 +#: ../../library/faulthandler.rst:161 msgid "" "Dump the tracebacks of all threads, after a timeout of *timeout* seconds, or " "every *timeout* seconds if *repeat* is ``True``. If *exit* is ``True``, " -"call :c:func:`!_exit` with status=1 after dumping the tracebacks. " -"(Note :c:func:`!_exit` exits the process immediately, which means it doesn't " -"do any cleanup like flushing file buffers.) If the function is called twice, " -"the new call replaces previous parameters and resets the timeout. The timer " -"has a sub-second resolution." +"call :c:func:`!_exit` with status=1 after dumping the tracebacks. (Note :c:" +"func:`!_exit` exits the process immediately, which means it doesn't do any " +"cleanup like flushing file buffers.) If the function is called twice, the " +"new call replaces previous parameters and resets the timeout. The timer has " +"a sub-second resolution. *max_threads* caps the number of threads dumped." msgstr "" -#: ../../library/faulthandler.rst:159 +#: ../../library/faulthandler.rst:169 msgid "" "The *file* must be kept open until the traceback is dumped " "or :func:`cancel_dump_traceback_later` is called: see :ref:`issue with file " "descriptors `." msgstr "" -#: ../../library/faulthandler.rst:163 +#: ../../library/faulthandler.rst:173 msgid "This function is implemented using a watchdog thread." msgstr "" -#: ../../library/faulthandler.rst:168 +#: ../../library/faulthandler.rst:178 msgid "This function is now always available." msgstr "" -#: ../../library/faulthandler.rst:173 +#: ../../library/faulthandler.rst:186 msgid "Cancel the last call to :func:`dump_traceback_later`." msgstr "" -#: ../../library/faulthandler.rst:177 +#: ../../library/faulthandler.rst:190 msgid "Dumping the traceback on a user signal" msgstr "" -#: ../../library/faulthandler.rst:181 +#: ../../library/faulthandler.rst:194 msgid "" "Register a user signal: install a handler for the *signum* signal to dump " "the traceback of all threads, or of the current thread if *all_threads* is " -"``False``, into *file*. Call the previous handler if chain is ``True``." +"``False``, into *file*. Call the previous handler if chain is ``True``. " +"*max_threads* caps the number of threads dumped." msgstr "" -#: ../../library/faulthandler.rst:185 +#: ../../library/faulthandler.rst:199 msgid "" "The *file* must be kept open until the signal is unregistered " "by :func:`unregister`: see :ref:`issue with file descriptors `." msgstr "" -#: ../../library/faulthandler.rst:188 ../../library/faulthandler.rst:199 +#: ../../library/faulthandler.rst:202 ../../library/faulthandler.rst:216 msgid "Not available on Windows." msgstr "" -#: ../../library/faulthandler.rst:195 +#: ../../library/faulthandler.rst:212 msgid "" "Unregister a user signal: uninstall the handler of the *signum* signal " "installed by :func:`register`. Return ``True`` if the signal was registered, " "``False`` otherwise." msgstr "" -#: ../../library/faulthandler.rst:205 +#: ../../library/faulthandler.rst:222 msgid "Issue with file descriptors" msgstr "" -#: ../../library/faulthandler.rst:207 +#: ../../library/faulthandler.rst:224 msgid "" ":func:`enable`, :func:`dump_traceback_later` and :func:`register` keep the " "file descriptor of their *file* argument. If the file is closed and its file " @@ -301,17 +315,17 @@ msgid "" "Call these functions again each time that the file is replaced." msgstr "" -#: ../../library/faulthandler.rst:215 +#: ../../library/faulthandler.rst:232 msgid "Example" msgstr "範例" -#: ../../library/faulthandler.rst:217 +#: ../../library/faulthandler.rst:234 msgid "" "Example of a segmentation fault on Linux with and without enabling the fault " "handler:" msgstr "" -#: ../../library/faulthandler.rst:220 +#: ../../library/faulthandler.rst:237 msgid "" "$ python -c \"import ctypes; ctypes.string_at(0)\"\n" "Segmentation fault\n" @@ -332,16 +346,16 @@ msgid "" " Binary file \"/opt/python/python\", at +0x32df8a [0x5b27f7d85f8a]\n" " Binary file \"/usr/lib/libc.so.6\", at +0x3def0 [0x77b73226bef0]\n" " Binary file \"/usr/lib/libc.so.6\", at +0x17ef9c [0x77b7323acf9c]\n" -" Binary file \"/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" "x86_64-linux-gnu.so\", at +0xcdf6 [0x77b7315dddf6]\n" " Binary file \"/usr/lib/libffi.so.8\", at +0x7976 [0x77b73158f976]\n" " Binary file \"/usr/lib/libffi.so.8\", at +0x413c [0x77b73158c13c]\n" " Binary file \"/usr/lib/libffi.so.8\", at ffi_call+0x12e [0x77b73158ef0e]\n" -" Binary file \"/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" "x86_64-linux-gnu.so\", at +0x15a33 [0x77b7315e6a33]\n" -" Binary file \"/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" "x86_64-linux-gnu.so\", at +0x164fa [0x77b7315e74fa]\n" -" Binary file \"/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" "x86_64-linux-gnu.so\", at +0xc624 [0x77b7315dd624]\n" " Binary file \"/opt/python/python\", at _PyObject_MakeTpCall+0xce " "[0x5b27f7b73883]\n" @@ -372,6 +386,64 @@ msgid "" " \n" "Segmentation fault" msgstr "" +"$ python -c \"import ctypes; ctypes.string_at(0)\"\n" +"Segmentation fault\n" +"\n" +"$ python -q -X faulthandler\n" +">>> import ctypes\n" +">>> ctypes.string_at(0)\n" +"Fatal Python error: Segmentation fault\n" +"\n" +"Current thread 0x00007fb899f39700 (most recent call first):\n" +" File \"/opt/python/Lib/ctypes/__init__.py\", line 486 in string_at\n" +" File \"\", line 1 in \n" +"\n" +"Current thread's C stack trace (most recent call first):\n" +" Binary file \"/opt/python/python\", at _Py_DumpStack+0x42 " +"[0x5b27f7d7147e]\n" +" Binary file \"/opt/python/python\", at +0x32dcbd [0x5b27f7d85cbd]\n" +" Binary file \"/opt/python/python\", at +0x32df8a [0x5b27f7d85f8a]\n" +" Binary file \"/usr/lib/libc.so.6\", at +0x3def0 [0x77b73226bef0]\n" +" Binary file \"/usr/lib/libc.so.6\", at +0x17ef9c [0x77b7323acf9c]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" +"x86_64-linux-gnu.so\", at +0xcdf6 [0x77b7315dddf6]\n" +" Binary file \"/usr/lib/libffi.so.8\", at +0x7976 [0x77b73158f976]\n" +" Binary file \"/usr/lib/libffi.so.8\", at +0x413c [0x77b73158c13c]\n" +" Binary file \"/usr/lib/libffi.so.8\", at ffi_call+0x12e [0x77b73158ef0e]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" +"x86_64-linux-gnu.so\", at +0x15a33 [0x77b7315e6a33]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" +"x86_64-linux-gnu.so\", at +0x164fa [0x77b7315e74fa]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" +"x86_64-linux-gnu.so\", at +0xc624 [0x77b7315dd624]\n" +" Binary file \"/opt/python/python\", at _PyObject_MakeTpCall+0xce " +"[0x5b27f7b73883]\n" +" Binary file \"/opt/python/python\", at +0x11bab6 [0x5b27f7b73ab6]\n" +" Binary file \"/opt/python/python\", at PyObject_Vectorcall+0x23 " +"[0x5b27f7b73b04]\n" +" Binary file \"/opt/python/python\", at _PyEval_EvalFrameDefault+0x490c " +"[0x5b27f7cbb302]\n" +" Binary file \"/opt/python/python\", at +0x2818e6 [0x5b27f7cd98e6]\n" +" Binary file \"/opt/python/python\", at +0x281aab [0x5b27f7cd9aab]\n" +" Binary file \"/opt/python/python\", at PyEval_EvalCode+0xc5 " +"[0x5b27f7cd9ba3]\n" +" Binary file \"/opt/python/python\", at +0x255957 [0x5b27f7cad957]\n" +" Binary file \"/opt/python/python\", at +0x255ab4 [0x5b27f7cadab4]\n" +" Binary file \"/opt/python/python\", at _PyEval_EvalFrameDefault+0x6c3e " +"[0x5b27f7cbd634]\n" +" Binary file \"/opt/python/python\", at +0x2818e6 [0x5b27f7cd98e6]\n" +" Binary file \"/opt/python/python\", at +0x281aab [0x5b27f7cd9aab]\n" +" Binary file \"/opt/python/python\", at +0x11b6e1 [0x5b27f7b736e1]\n" +" Binary file \"/opt/python/python\", at +0x11d348 [0x5b27f7b75348]\n" +" Binary file \"/opt/python/python\", at +0x11d626 [0x5b27f7b75626]\n" +" Binary file \"/opt/python/python\", at PyObject_Call+0x20 " +"[0x5b27f7b7565e]\n" +" Binary file \"/opt/python/python\", at +0x32a67a [0x5b27f7d8267a]\n" +" Binary file \"/opt/python/python\", at +0x32a7f8 [0x5b27f7d827f8]\n" +" Binary file \"/opt/python/python\", at +0x32ac1b [0x5b27f7d82c1b]\n" +" Binary file \"/opt/python/python\", at Py_RunMain+0x31 [0x5b27f7d82ebe]\n" +" \n" +"Segmentation fault" #~ msgid "" #~ "$ python -c \"import ctypes; ctypes.string_at(0)\"\n" diff --git a/library/fcntl.po b/library/fcntl.po index f7f5227caa2..dbd78625b29 100644 --- a/library/fcntl.po +++ b/library/fcntl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-20 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,7 +21,7 @@ msgstr "" msgid ":mod:`!fcntl` --- The ``fcntl`` and ``ioctl`` system calls" msgstr ":mod:`!fcntl` --- ``fcntl`` 和 ``ioctl`` 系統呼叫" -#: ../../library/fcntl.rst:15 +#: ../../library/fcntl.rst:13 msgid "" "This module performs file and I/O control on file descriptors. It is an " "interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines. See the :" @@ -29,11 +29,11 @@ msgid "" "details." msgstr "" -#: ../../library/fcntl.rst:20 +#: ../../library/fcntl.rst:18 msgid "Availability" msgstr "可用性" -#: ../../library/fcntl.rst:22 +#: ../../library/fcntl.rst:20 msgid "" "All functions in this module take a file descriptor *fd* as their first " "argument. This can be an integer file descriptor, such as returned by ``sys." @@ -42,20 +42,20 @@ msgid "" "file descriptor." msgstr "" -#: ../../library/fcntl.rst:28 +#: ../../library/fcntl.rst:26 msgid "" "Operations in this module used to raise an :exc:`IOError` where they now " "raise an :exc:`OSError`." msgstr "" -#: ../../library/fcntl.rst:32 +#: ../../library/fcntl.rst:30 msgid "" "The :mod:`!fcntl` module now contains ``F_ADD_SEALS``, ``F_GET_SEALS``, and " "``F_SEAL_*`` constants for sealing of :func:`os.memfd_create` file " "descriptors." msgstr "" -#: ../../library/fcntl.rst:37 +#: ../../library/fcntl.rst:35 msgid "" "On macOS, the :mod:`!fcntl` module exposes the ``F_GETPATH`` constant, which " "obtains the path of a file from a file descriptor. On Linux(>=3.15), the :" @@ -64,21 +64,21 @@ msgid "" "description locks." msgstr "" -#: ../../library/fcntl.rst:44 +#: ../../library/fcntl.rst:42 msgid "" "On Linux >= 2.6.11, the :mod:`!fcntl` module exposes the ``F_GETPIPE_SZ`` " "and ``F_SETPIPE_SZ`` constants, which allow to check and modify a pipe's " "size respectively." msgstr "" -#: ../../library/fcntl.rst:49 +#: ../../library/fcntl.rst:47 msgid "" "On FreeBSD, the :mod:`!fcntl` module exposes the ``F_DUP2FD`` and " "``F_DUP2FD_CLOEXEC`` constants, which allow to duplicate a file descriptor, " "the latter setting ``FD_CLOEXEC`` flag in addition." msgstr "" -#: ../../library/fcntl.rst:54 +#: ../../library/fcntl.rst:52 msgid "" "On Linux >= 4.5, the :mod:`!fcntl` module exposes the ``FICLONE`` and " "``FICLONERANGE`` constants, which allow to share some data of one file with " @@ -86,7 +86,7 @@ msgid "" "XFS). This behavior is commonly referred to as \"copy-on-write\"." msgstr "" -#: ../../library/fcntl.rst:60 +#: ../../library/fcntl.rst:58 msgid "" "On Linux >= 2.6.32, the :mod:`!fcntl` module exposes the ``F_GETOWN_EX``, " "``F_SETOWN_EX``, ``F_OWNER_TID``, ``F_OWNER_PID``, ``F_OWNER_PGRP`` " @@ -107,17 +107,17 @@ msgid "" "and ``F_SETNOSIGPIPE`` constant." msgstr "" -#: ../../library/fcntl.rst:81 +#: ../../library/fcntl.rst:79 msgid "" "On Linux >= 6.1, the :mod:`!fcntl` module exposes the ``F_DUPFD_QUERY`` to " "query a file descriptor pointing to the same file." msgstr "" -#: ../../library/fcntl.rst:85 +#: ../../library/fcntl.rst:83 msgid "The module defines the following functions:" msgstr "這個模組定義了以下函式:" -#: ../../library/fcntl.rst:90 +#: ../../library/fcntl.rst:88 msgid "" "Perform the operation *cmd* on file descriptor *fd* (file objects providing " "a :meth:`~io.IOBase.fileno` method are accepted as well). The values used " @@ -129,13 +129,13 @@ msgid "" "C documentation." msgstr "" -#: ../../library/fcntl.rst:99 +#: ../../library/fcntl.rst:97 msgid "" "When *arg* is an integer, the function returns the integer return value of " "the C :c:func:`fcntl` call." msgstr "" -#: ../../library/fcntl.rst:102 +#: ../../library/fcntl.rst:100 msgid "" "When the argument is bytes-like object, it represents a binary structure, " "for example, created by :func:`struct.pack`. A string value is encoded to " @@ -143,23 +143,23 @@ msgid "" "address is passed to the C :c:func:`fcntl` call. The return value after a " "successful call is the contents of the buffer, converted to a :class:`bytes` " "object. The length of the returned object will be the same as the length of " -"the *arg* argument. This is limited to 1024 bytes." +"the *arg* argument." msgstr "" -#: ../../library/fcntl.rst:111 +#: ../../library/fcntl.rst:109 msgid "If the :c:func:`fcntl` call fails, an :exc:`OSError` is raised." msgstr "" -#: ../../library/fcntl.rst:114 +#: ../../library/fcntl.rst:112 ../../library/fcntl.rst:161 msgid "" -"If the type or the size of *arg* does not match the type or size of the " -"argument of the operation (for example, if an integer is passed when a " -"pointer is expected, or the information returned in the buffer by the " -"operating system is larger than 1024 bytes), this is most likely to result " -"in a segmentation violation or a more subtle data corruption." +"If the type or size of *arg* does not match the type or size of the " +"operation's argument (for example, if an integer is passed when a pointer is " +"expected, or the information returned in the buffer by the operating system " +"is larger than the size of *arg*), this is most likely to result in a " +"segmentation violation or a more subtle data corruption." msgstr "" -#: ../../library/fcntl.rst:121 +#: ../../library/fcntl.rst:119 msgid "" "Raises an :ref:`auditing event ` ``fcntl.fcntl`` with arguments " "``fd``, ``cmd``, ``arg``." @@ -167,19 +167,23 @@ msgstr "" "引發一個附帶引數 ``fd``、``cmd``、``arg`` 的\\ :ref:`稽核事件 ` " "``fcntl.fcntl``。" -#: ../../library/fcntl.rst:123 +#: ../../library/fcntl.rst:121 msgid "" "Add support of arbitrary :term:`bytes-like objects `, not " "only :class:`bytes`." msgstr "" -#: ../../library/fcntl.rst:130 +#: ../../library/fcntl.rst:125 +msgid "The size of bytes-like objects is no longer limited to 1024 bytes." +msgstr "" + +#: ../../library/fcntl.rst:131 msgid "" "This function is identical to the :func:`~fcntl.fcntl` function, except that " "the argument handling is even more complicated." msgstr "" -#: ../../library/fcntl.rst:133 +#: ../../library/fcntl.rst:134 msgid "" "The *request* parameter is limited to values that can fit in 32-bits or 64-" "bits, depending on the platform. Additional constants of interest for use as " @@ -187,20 +191,20 @@ msgid "" "same names as used in the relevant C header files." msgstr "" -#: ../../library/fcntl.rst:139 +#: ../../library/fcntl.rst:140 msgid "" "The parameter *arg* can be an integer, a :term:`bytes-like object`, or a " "string. The type and size of *arg* must match the type and size of the " "argument of the operation as specified in the relevant C documentation." msgstr "" -#: ../../library/fcntl.rst:144 +#: ../../library/fcntl.rst:145 msgid "" "If *arg* does not support the read-write buffer interface or the " "*mutate_flag* is false, behavior is as for the :func:`~fcntl.fcntl` function." msgstr "" -#: ../../library/fcntl.rst:148 +#: ../../library/fcntl.rst:149 msgid "" "If *arg* supports the read-write buffer interface (like :class:`bytearray`) " "and *mutate_flag* is true (the default), then the buffer is (in effect) " @@ -212,21 +216,11 @@ msgid "" "`ioctl` and copied back into the supplied buffer." msgstr "" -#: ../../library/fcntl.rst:157 +#: ../../library/fcntl.rst:158 msgid "" "If the :c:func:`ioctl` call fails, an :exc:`OSError` exception is raised." msgstr "" -#: ../../library/fcntl.rst:160 -msgid "" -"If the type or size of *arg* does not match the type or size of the " -"operation's argument (for example, if an integer is passed when a pointer is " -"expected, or the information returned in the buffer by the operating system " -"is larger than 1024 bytes, or the size of the mutable bytes-like object is " -"too small), this is most likely to result in a segmentation violation or a " -"more subtle data corruption." -msgstr "" - #: ../../library/fcntl.rst:168 msgid "An example::" msgstr "範例: ::" @@ -269,7 +263,13 @@ msgid "" "EINTR are automatically retried." msgstr "" -#: ../../library/fcntl.rst:189 +#: ../../library/fcntl.rst:187 +msgid "" +"The size of not mutated bytes-like objects is no longer limited to 1024 " +"bytes." +msgstr "" + +#: ../../library/fcntl.rst:193 msgid "" "Perform the lock operation *operation* on file descriptor *fd* (file objects " "providing a :meth:`~io.IOBase.fileno` method are accepted as well). See the " @@ -277,12 +277,12 @@ msgid "" "function is emulated using :c:func:`fcntl`.)" msgstr "" -#: ../../library/fcntl.rst:194 +#: ../../library/fcntl.rst:198 msgid "" "If the :c:func:`flock` call fails, an :exc:`OSError` exception is raised." msgstr "" -#: ../../library/fcntl.rst:196 +#: ../../library/fcntl.rst:200 msgid "" "Raises an :ref:`auditing event ` ``fcntl.flock`` with arguments " "``fd``, ``operation``." @@ -290,7 +290,7 @@ msgstr "" "引發一個附帶引數 ``fd``、``operation`` 的\\ :ref:`稽核事件 ` " "``fcntl.flock``。" -#: ../../library/fcntl.rst:201 +#: ../../library/fcntl.rst:205 msgid "" "This is essentially a wrapper around the :func:`~fcntl.fcntl` locking calls. " "*fd* is the file descriptor (file objects providing a :meth:`~io.IOBase." @@ -298,25 +298,25 @@ msgid "" "*cmd* is one of the following values:" msgstr "" -#: ../../library/fcntl.rst:208 +#: ../../library/fcntl.rst:212 msgid "Release an existing lock." msgstr "" -#: ../../library/fcntl.rst:212 +#: ../../library/fcntl.rst:216 msgid "Acquire a shared lock." msgstr "" -#: ../../library/fcntl.rst:216 +#: ../../library/fcntl.rst:220 msgid "Acquire an exclusive lock." msgstr "" -#: ../../library/fcntl.rst:220 +#: ../../library/fcntl.rst:224 msgid "" "Bitwise OR with any of the other three ``LOCK_*`` constants to make the " "request non-blocking." msgstr "" -#: ../../library/fcntl.rst:223 +#: ../../library/fcntl.rst:227 msgid "" "If :const:`!LOCK_NB` is used and the lock cannot be acquired, an :exc:" "`OSError` will be raised and the exception will have an *errno* attribute " @@ -326,33 +326,33 @@ msgid "" "a file opened for writing." msgstr "" -#: ../../library/fcntl.rst:230 +#: ../../library/fcntl.rst:234 msgid "" "*len* is the number of bytes to lock, *start* is the byte offset at which " "the lock starts, relative to *whence*, and *whence* is as with :func:`io." "IOBase.seek`, specifically:" msgstr "" -#: ../../library/fcntl.rst:234 +#: ../../library/fcntl.rst:238 msgid "``0`` -- relative to the start of the file (:const:`os.SEEK_SET`)" msgstr "" -#: ../../library/fcntl.rst:235 +#: ../../library/fcntl.rst:239 msgid "``1`` -- relative to the current buffer position (:const:`os.SEEK_CUR`)" msgstr "" -#: ../../library/fcntl.rst:236 +#: ../../library/fcntl.rst:240 msgid "``2`` -- relative to the end of the file (:const:`os.SEEK_END`)" msgstr "" -#: ../../library/fcntl.rst:238 +#: ../../library/fcntl.rst:242 msgid "" "The default for *start* is 0, which means to start at the beginning of the " "file. The default for *len* is 0 which means to lock to the end of the " "file. The default for *whence* is also 0." msgstr "" -#: ../../library/fcntl.rst:242 +#: ../../library/fcntl.rst:246 msgid "" "Raises an :ref:`auditing event ` ``fcntl.lockf`` with arguments " "``fd``, ``cmd``, ``len``, ``start``, ``whence``." @@ -360,11 +360,11 @@ msgstr "" "引發一個附帶引數 ``fd``、``cmd``、``len``、``start``、``whence`` 的\\ :ref:`" "稽核事件 ` ``fcntl.lockf``。" -#: ../../library/fcntl.rst:244 +#: ../../library/fcntl.rst:248 msgid "Examples (all on a SVR4 compliant system)::" msgstr "" -#: ../../library/fcntl.rst:246 +#: ../../library/fcntl.rst:250 msgid "" "import struct, fcntl, os\n" "\n" @@ -382,7 +382,7 @@ msgstr "" "lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)\n" "rv = fcntl.fcntl(f, fcntl.F_SETLKW, lockdata)" -#: ../../library/fcntl.rst:254 +#: ../../library/fcntl.rst:258 msgid "" "Note that in the first example the return value variable *rv* will hold an " "integer value; in the second example it will hold a :class:`bytes` object. " @@ -390,25 +390,25 @@ msgid "" "therefore using the :func:`flock` call may be better." msgstr "" -#: ../../library/fcntl.rst:262 +#: ../../library/fcntl.rst:266 msgid "Module :mod:`os`" msgstr ":mod:`os` 模組" -#: ../../library/fcntl.rst:263 +#: ../../library/fcntl.rst:267 msgid "" "If the locking flags :const:`~os.O_SHLOCK` and :const:`~os.O_EXLOCK` are " "present in the :mod:`os` module (on BSD only), the :func:`os.open` function " "provides an alternative to the :func:`lockf` and :func:`flock` functions." msgstr "" -#: ../../library/fcntl.rst:9 +#: ../../library/fcntl.rst:7 msgid "UNIX" msgstr "UNIX" -#: ../../library/fcntl.rst:9 +#: ../../library/fcntl.rst:7 msgid "file control" msgstr "file control(檔案控制)" -#: ../../library/fcntl.rst:9 +#: ../../library/fcntl.rst:7 msgid "I/O control" msgstr "I/O control(I/O 控制)" diff --git a/library/filecmp.po b/library/filecmp.po index 9c1ff38a681..21b5d4cec32 100644 --- a/library/filecmp.po +++ b/library/filecmp.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-19 00:28+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,60 +21,60 @@ msgstr "" msgid ":mod:`!filecmp` --- File and Directory Comparisons" msgstr ":mod:`!filecmp` --- 檔案與目錄比較" -#: ../../library/filecmp.rst:9 +#: ../../library/filecmp.rst:7 msgid "**Source code:** :source:`Lib/filecmp.py`" msgstr "**原始碼:**\\ :source:`Lib/filecmp.py`" -#: ../../library/filecmp.rst:13 +#: ../../library/filecmp.rst:11 msgid "" "The :mod:`!filecmp` module defines functions to compare files and " "directories, with various optional time/correctness trade-offs. For " "comparing files, see also the :mod:`difflib` module." msgstr "" -#: ../../library/filecmp.rst:17 +#: ../../library/filecmp.rst:15 msgid "The :mod:`!filecmp` module defines the following functions:" msgstr ":mod:`!filecmp` 模組定義了以下函式:" -#: ../../library/filecmp.rst:22 +#: ../../library/filecmp.rst:20 msgid "" "Compare the files named *f1* and *f2*, returning ``True`` if they seem " "equal, ``False`` otherwise." msgstr "" -#: ../../library/filecmp.rst:25 +#: ../../library/filecmp.rst:23 msgid "" "If *shallow* is true and the :func:`os.stat` signatures (file type, size, " "and modification time) of both files are identical, the files are taken to " "be equal." msgstr "" -#: ../../library/filecmp.rst:29 +#: ../../library/filecmp.rst:27 msgid "" "Otherwise, the files are treated as different if their sizes or contents " "differ." msgstr "" -#: ../../library/filecmp.rst:31 +#: ../../library/filecmp.rst:29 msgid "" "Note that no external programs are called from this function, giving it " "portability and efficiency." msgstr "" -#: ../../library/filecmp.rst:34 +#: ../../library/filecmp.rst:32 msgid "" "This function uses a cache for past comparisons and the results, with cache " "entries invalidated if the :func:`os.stat` information for the file " "changes. The entire cache may be cleared using :func:`clear_cache`." msgstr "" -#: ../../library/filecmp.rst:41 +#: ../../library/filecmp.rst:39 msgid "" "Compare the files in the two directories *a* and *b* whose names are given " "by *common*." msgstr "" -#: ../../library/filecmp.rst:44 +#: ../../library/filecmp.rst:42 msgid "" "Returns three lists of file names: *match*, *mismatch*, *errors*. *match* " "contains the list of files that match, *mismatch* contains the names of " @@ -84,31 +84,31 @@ msgid "" "could not be done for some other reason." msgstr "" -#: ../../library/filecmp.rst:51 +#: ../../library/filecmp.rst:49 msgid "" "The *shallow* parameter has the same meaning and default value as for :func:" "`filecmp.cmp`." msgstr "" -#: ../../library/filecmp.rst:54 +#: ../../library/filecmp.rst:52 msgid "" "For example, ``cmpfiles('a', 'b', ['c', 'd/e'])`` will compare ``a/c`` with " "``b/c`` and ``a/d/e`` with ``b/d/e``. ``'c'`` and ``'d/e'`` will each be in " "one of the three returned lists." msgstr "" -#: ../../library/filecmp.rst:61 +#: ../../library/filecmp.rst:59 msgid "" "Clear the filecmp cache. This may be useful if a file is compared so quickly " "after it is modified that it is within the mtime resolution of the " "underlying filesystem." msgstr "" -#: ../../library/filecmp.rst:71 +#: ../../library/filecmp.rst:69 msgid "The :class:`dircmp` class" msgstr "" -#: ../../library/filecmp.rst:75 +#: ../../library/filecmp.rst:73 msgid "" "Construct a new directory comparison object, to compare the directories *a* " "and *b*. *ignore* is a list of names to ignore, and defaults to :const:" @@ -116,131 +116,131 @@ msgid "" "to ``[os.curdir, os.pardir]``." msgstr "" -#: ../../library/filecmp.rst:80 +#: ../../library/filecmp.rst:78 msgid "" "The :class:`dircmp` class compares files by doing *shallow* comparisons as " "described for :func:`filecmp.cmp` by default using the *shallow* parameter." msgstr "" -#: ../../library/filecmp.rst:86 +#: ../../library/filecmp.rst:84 msgid "Added the *shallow* parameter." msgstr "新增了 *shallow* 參數。" -#: ../../library/filecmp.rst:88 +#: ../../library/filecmp.rst:86 msgid "The :class:`dircmp` class provides the following methods:" msgstr "" -#: ../../library/filecmp.rst:92 +#: ../../library/filecmp.rst:90 msgid "Print (to :data:`sys.stdout`) a comparison between *a* and *b*." msgstr "" -#: ../../library/filecmp.rst:96 +#: ../../library/filecmp.rst:94 msgid "" "Print a comparison between *a* and *b* and common immediate subdirectories." msgstr "" -#: ../../library/filecmp.rst:101 +#: ../../library/filecmp.rst:99 msgid "" "Print a comparison between *a* and *b* and common subdirectories " "(recursively)." msgstr "" -#: ../../library/filecmp.rst:104 +#: ../../library/filecmp.rst:102 msgid "" "The :class:`dircmp` class offers a number of interesting attributes that may " "be used to get various bits of information about the directory trees being " "compared." msgstr "" -#: ../../library/filecmp.rst:108 +#: ../../library/filecmp.rst:106 msgid "" "Note that via :meth:`~object.__getattr__` hooks, all attributes are computed " "lazily, so there is no speed penalty if only those attributes which are " "lightweight to compute are used." msgstr "" -#: ../../library/filecmp.rst:115 +#: ../../library/filecmp.rst:113 msgid "The directory *a*." msgstr "" -#: ../../library/filecmp.rst:120 +#: ../../library/filecmp.rst:118 msgid "The directory *b*." msgstr "" -#: ../../library/filecmp.rst:125 +#: ../../library/filecmp.rst:123 msgid "Files and subdirectories in *a*, filtered by *hide* and *ignore*." msgstr "" -#: ../../library/filecmp.rst:130 +#: ../../library/filecmp.rst:128 msgid "Files and subdirectories in *b*, filtered by *hide* and *ignore*." msgstr "" -#: ../../library/filecmp.rst:135 +#: ../../library/filecmp.rst:133 msgid "Files and subdirectories in both *a* and *b*." msgstr "" -#: ../../library/filecmp.rst:140 +#: ../../library/filecmp.rst:138 msgid "Files and subdirectories only in *a*." msgstr "" -#: ../../library/filecmp.rst:145 +#: ../../library/filecmp.rst:143 msgid "Files and subdirectories only in *b*." msgstr "" -#: ../../library/filecmp.rst:150 +#: ../../library/filecmp.rst:148 msgid "Subdirectories in both *a* and *b*." msgstr "" -#: ../../library/filecmp.rst:155 +#: ../../library/filecmp.rst:153 msgid "Files in both *a* and *b*." msgstr "" -#: ../../library/filecmp.rst:160 +#: ../../library/filecmp.rst:158 msgid "" "Names in both *a* and *b*, such that the type differs between the " "directories, or names for which :func:`os.stat` reports an error." msgstr "" -#: ../../library/filecmp.rst:166 +#: ../../library/filecmp.rst:164 msgid "" "Files which are identical in both *a* and *b*, using the class's file " "comparison operator." msgstr "" -#: ../../library/filecmp.rst:172 +#: ../../library/filecmp.rst:170 msgid "" "Files which are in both *a* and *b*, whose contents differ according to the " "class's file comparison operator." msgstr "" -#: ../../library/filecmp.rst:178 +#: ../../library/filecmp.rst:176 msgid "Files which are in both *a* and *b*, but could not be compared." msgstr "" -#: ../../library/filecmp.rst:183 +#: ../../library/filecmp.rst:181 msgid "" "A dictionary mapping names in :attr:`common_dirs` to :class:`dircmp` " "instances (or MyDirCmp instances if this instance is of type MyDirCmp, a " "subclass of :class:`dircmp`)." msgstr "" -#: ../../library/filecmp.rst:187 +#: ../../library/filecmp.rst:185 msgid "" "Previously entries were always :class:`dircmp` instances. Now entries are " "the same type as *self*, if *self* is a subclass of :class:`dircmp`." msgstr "" -#: ../../library/filecmp.rst:196 +#: ../../library/filecmp.rst:194 msgid "List of directories ignored by :class:`dircmp` by default." msgstr "" -#: ../../library/filecmp.rst:199 +#: ../../library/filecmp.rst:197 msgid "" "Here is a simplified example of using the ``subdirs`` attribute to search " "recursively through two directories to show common different files::" msgstr "" -#: ../../library/filecmp.rst:202 +#: ../../library/filecmp.rst:200 msgid "" ">>> from filecmp import dircmp\n" ">>> def print_diff_files(dcmp):\n" diff --git a/library/fileinput.po b/library/fileinput.po index 377e8618708..6da24d7ad59 100644 --- a/library/fileinput.po +++ b/library/fileinput.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,22 +21,22 @@ msgstr "" msgid ":mod:`!fileinput` --- Iterate over lines from multiple input streams" msgstr ":mod:`!fileinput` --- 逐列疊代多個輸入串流" -#: ../../library/fileinput.rst:10 +#: ../../library/fileinput.rst:7 msgid "**Source code:** :source:`Lib/fileinput.py`" msgstr "**原始碼:**\\ :source:`Lib/fileinput.py`" -#: ../../library/fileinput.rst:14 +#: ../../library/fileinput.rst:11 msgid "" "This module implements a helper class and functions to quickly write a loop " "over standard input or a list of files. If you just want to read or write " "one file see :func:`open`." msgstr "" -#: ../../library/fileinput.rst:18 +#: ../../library/fileinput.rst:15 msgid "The typical use is::" msgstr "" -#: ../../library/fileinput.rst:20 +#: ../../library/fileinput.rst:17 msgid "" "import fileinput\n" "for line in fileinput.input(encoding=\"utf-8\"):\n" @@ -46,7 +46,7 @@ msgstr "" "for line in fileinput.input(encoding=\"utf-8\"):\n" " process(line)" -#: ../../library/fileinput.rst:24 +#: ../../library/fileinput.rst:21 msgid "" "This iterates over the lines of all files listed in ``sys.argv[1:]``, " "defaulting to ``sys.stdin`` if the list is empty. If a filename is ``'-'``, " @@ -56,7 +56,7 @@ msgid "" "allowed." msgstr "" -#: ../../library/fileinput.rst:30 +#: ../../library/fileinput.rst:27 msgid "" "All files are opened in text mode by default, but you can override this by " "specifying the *mode* parameter in the call to :func:`.input` or :class:" @@ -64,31 +64,31 @@ msgid "" "`OSError` is raised." msgstr "" -#: ../../library/fileinput.rst:35 +#: ../../library/fileinput.rst:32 msgid ":exc:`IOError` used to be raised; it is now an alias of :exc:`OSError`." msgstr ":exc:`IOError` 曾經被引發;現在它是一個 :exc:`OSError` 的別名。" -#: ../../library/fileinput.rst:38 +#: ../../library/fileinput.rst:35 msgid "" "If ``sys.stdin`` is used more than once, the second and further use will " "return no lines, except perhaps for interactive use, or if it has been " "explicitly reset (e.g. using ``sys.stdin.seek(0)``)." msgstr "" -#: ../../library/fileinput.rst:42 +#: ../../library/fileinput.rst:39 msgid "" "Empty files are opened and immediately closed; the only time their presence " "in the list of filenames is noticeable at all is when the last file opened " "is empty." msgstr "" -#: ../../library/fileinput.rst:46 +#: ../../library/fileinput.rst:43 msgid "" "Lines are returned with any newlines intact, which means that the last line " "in a file may not have one." msgstr "" -#: ../../library/fileinput.rst:49 +#: ../../library/fileinput.rst:46 msgid "" "You can control how files are opened by providing an opening hook via the " "*openhook* parameter to :func:`fileinput.input` or :func:`FileInput`. The " @@ -99,11 +99,11 @@ msgid "" "compressed files." msgstr "" -#: ../../library/fileinput.rst:56 +#: ../../library/fileinput.rst:53 msgid "The following function is the primary interface of this module:" msgstr "" -#: ../../library/fileinput.rst:61 +#: ../../library/fileinput.rst:58 msgid "" "Create an instance of the :class:`FileInput` class. The instance will be " "used as global state for the functions of this module, and is also returned " @@ -111,14 +111,14 @@ msgid "" "along to the constructor of the :class:`FileInput` class." msgstr "" -#: ../../library/fileinput.rst:66 +#: ../../library/fileinput.rst:63 msgid "" "The :class:`FileInput` instance can be used as a context manager in the :" "keyword:`with` statement. In this example, *input* is closed after the :" "keyword:`!with` statement is exited, even if an exception occurs::" msgstr "" -#: ../../library/fileinput.rst:70 +#: ../../library/fileinput.rst:67 msgid "" "with fileinput.input(files=('spam.txt', 'eggs.txt'), encoding=\"utf-8\") as " "f:\n" @@ -130,64 +130,64 @@ msgstr "" " for line in f:\n" " process(line)" -#: ../../library/fileinput.rst:74 ../../library/fileinput.rst:170 +#: ../../library/fileinput.rst:71 ../../library/fileinput.rst:167 msgid "Can be used as a context manager." msgstr "" -#: ../../library/fileinput.rst:77 +#: ../../library/fileinput.rst:74 msgid "The keyword parameters *mode* and *openhook* are now keyword-only." msgstr "" -#: ../../library/fileinput.rst:80 ../../library/fileinput.rst:176 -#: ../../library/fileinput.rst:210 +#: ../../library/fileinput.rst:77 ../../library/fileinput.rst:173 +#: ../../library/fileinput.rst:207 msgid "The keyword-only parameter *encoding* and *errors* are added." msgstr "" -#: ../../library/fileinput.rst:84 +#: ../../library/fileinput.rst:81 msgid "" "The following functions use the global state created by :func:`fileinput." "input`; if there is no active state, :exc:`RuntimeError` is raised." msgstr "" -#: ../../library/fileinput.rst:90 +#: ../../library/fileinput.rst:87 msgid "" "Return the name of the file currently being read. Before the first line has " "been read, returns ``None``." msgstr "" -#: ../../library/fileinput.rst:96 +#: ../../library/fileinput.rst:93 msgid "" "Return the integer \"file descriptor\" for the current file. When no file is " "opened (before the first line and between files), returns ``-1``." msgstr "" -#: ../../library/fileinput.rst:102 +#: ../../library/fileinput.rst:99 msgid "" "Return the cumulative line number of the line that has just been read. " "Before the first line has been read, returns ``0``. After the last line of " "the last file has been read, returns the line number of that line." msgstr "" -#: ../../library/fileinput.rst:109 +#: ../../library/fileinput.rst:106 msgid "" "Return the line number in the current file. Before the first line has been " "read, returns ``0``. After the last line of the last file has been read, " "returns the line number of that line within the file." msgstr "" -#: ../../library/fileinput.rst:116 +#: ../../library/fileinput.rst:113 msgid "" "Return ``True`` if the line just read is the first line of its file, " "otherwise return ``False``." msgstr "" -#: ../../library/fileinput.rst:122 +#: ../../library/fileinput.rst:119 msgid "" "Return ``True`` if the last line was read from ``sys.stdin``, otherwise " "return ``False``." msgstr "" -#: ../../library/fileinput.rst:128 +#: ../../library/fileinput.rst:125 msgid "" "Close the current file so that the next iteration will read the first line " "from the next file (if any); lines not read from the file will not count " @@ -198,17 +198,17 @@ msgid "" "no effect." msgstr "" -#: ../../library/fileinput.rst:138 +#: ../../library/fileinput.rst:135 msgid "Close the sequence." msgstr "" -#: ../../library/fileinput.rst:140 +#: ../../library/fileinput.rst:137 msgid "" "The class which implements the sequence behavior provided by the module is " "available for subclassing as well:" msgstr "" -#: ../../library/fileinput.rst:146 +#: ../../library/fileinput.rst:143 msgid "" "Class :class:`FileInput` is the implementation; its methods :meth:" "`filename`, :meth:`fileno`, :meth:`lineno`, :meth:`filelineno`, :meth:" @@ -220,33 +220,33 @@ msgid "" "be mixed." msgstr "" -#: ../../library/fileinput.rst:154 +#: ../../library/fileinput.rst:151 msgid "" "With *mode* you can specify which file mode will be passed to :func:`open`. " "It must be one of ``'r'`` and ``'rb'``." msgstr "" -#: ../../library/fileinput.rst:157 +#: ../../library/fileinput.rst:154 msgid "" "The *openhook*, when given, must be a function that takes two arguments, " "*filename* and *mode*, and returns an accordingly opened file-like object. " "You cannot use *inplace* and *openhook* together." msgstr "" -#: ../../library/fileinput.rst:161 +#: ../../library/fileinput.rst:158 msgid "" "You can specify *encoding* and *errors* that is passed to :func:`open` or " "*openhook*." msgstr "" -#: ../../library/fileinput.rst:163 +#: ../../library/fileinput.rst:160 msgid "" "A :class:`FileInput` instance can be used as a context manager in the :" "keyword:`with` statement. In this example, *input* is closed after the :" "keyword:`!with` statement is exited, even if an exception occurs::" msgstr "" -#: ../../library/fileinput.rst:167 +#: ../../library/fileinput.rst:164 msgid "" "with FileInput(files=('spam.txt', 'eggs.txt')) as input:\n" " process(input)" @@ -254,17 +254,17 @@ msgstr "" "with FileInput(files=('spam.txt', 'eggs.txt')) as input:\n" " process(input)" -#: ../../library/fileinput.rst:173 +#: ../../library/fileinput.rst:170 msgid "The keyword parameter *mode* and *openhook* are now keyword-only." msgstr "" -#: ../../library/fileinput.rst:179 +#: ../../library/fileinput.rst:176 msgid "" "The ``'rU'`` and ``'U'`` modes and the :meth:`!__getitem__` method have been " "removed." msgstr "" -#: ../../library/fileinput.rst:184 +#: ../../library/fileinput.rst:181 msgid "" "**Optional in-place filtering:** if the keyword argument ``inplace=True`` is " "passed to :func:`fileinput.input` or to the :class:`FileInput` constructor, " @@ -278,11 +278,11 @@ msgid "" "In-place filtering is disabled when standard input is read." msgstr "" -#: ../../library/fileinput.rst:196 +#: ../../library/fileinput.rst:193 msgid "The two following opening hooks are provided by this module:" msgstr "" -#: ../../library/fileinput.rst:200 +#: ../../library/fileinput.rst:197 msgid "" "Transparently opens files compressed with gzip and bzip2 (recognized by the " "extensions ``'.gz'`` and ``'.bz2'``) using the :mod:`gzip` and :mod:`bz2` " @@ -290,35 +290,35 @@ msgid "" "is opened normally (ie, using :func:`open` without any decompression)." msgstr "" -#: ../../library/fileinput.rst:205 +#: ../../library/fileinput.rst:202 msgid "" "The *encoding* and *errors* values are passed to :class:`io.TextIOWrapper` " "for compressed files and open for normal files." msgstr "" -#: ../../library/fileinput.rst:208 +#: ../../library/fileinput.rst:205 msgid "" "Usage example: ``fi = fileinput.FileInput(openhook=fileinput." "hook_compressed, encoding=\"utf-8\")``" msgstr "" -#: ../../library/fileinput.rst:216 +#: ../../library/fileinput.rst:213 msgid "" "Returns a hook which opens each file with :func:`open`, using the given " "*encoding* and *errors* to read the file." msgstr "" -#: ../../library/fileinput.rst:219 +#: ../../library/fileinput.rst:216 msgid "" "Usage example: ``fi = fileinput.FileInput(openhook=fileinput." "hook_encoded(\"utf-8\", \"surrogateescape\"))``" msgstr "" -#: ../../library/fileinput.rst:223 +#: ../../library/fileinput.rst:220 msgid "Added the optional *errors* parameter." msgstr "新增可選參數 *errors*。" -#: ../../library/fileinput.rst:226 +#: ../../library/fileinput.rst:223 msgid "" "This function is deprecated since :func:`fileinput.input` and :class:" "`FileInput` now have *encoding* and *errors* parameters." diff --git a/library/fnmatch.po b/library/fnmatch.po index 1a2f5f34859..2ac21522642 100644 --- a/library/fnmatch.po +++ b/library/fnmatch.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:02+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -159,18 +159,19 @@ msgstr "" #: ../../library/fnmatch.rst:105 msgid "" "Return the shell-style pattern *pat* converted to a regular expression for " -"using with :func:`re.match`. The pattern is expected to be a :class:`str`." +"using with :func:`re.prefixmatch`. The pattern is expected to be a :class:" +"`str`." msgstr "" -#: ../../library/fnmatch.rst:108 +#: ../../library/fnmatch.rst:109 msgid "Example:" msgstr "範例:" -#: ../../library/fnmatch.rst:122 +#: ../../library/fnmatch.rst:123 msgid "Module :mod:`glob`" msgstr ":mod:`glob` 模組" -#: ../../library/fnmatch.rst:123 +#: ../../library/fnmatch.rst:124 msgid "Unix shell-style path expansion." msgstr "" diff --git a/library/fractions.po b/library/fractions.po index f3858882408..daf6fef2c7a 100644 --- a/library/fractions.po +++ b/library/fractions.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,22 +21,22 @@ msgstr "" msgid ":mod:`!fractions` --- Rational numbers" msgstr ":mod:`!fractions` --- 有理數" -#: ../../library/fractions.rst:10 +#: ../../library/fractions.rst:7 msgid "**Source code:** :source:`Lib/fractions.py`" msgstr "**原始碼:**\\ :source:`Lib/fractions.py`" -#: ../../library/fractions.rst:14 +#: ../../library/fractions.rst:11 msgid "" "The :mod:`!fractions` module provides support for rational number arithmetic." msgstr "" -#: ../../library/fractions.rst:17 +#: ../../library/fractions.rst:14 msgid "" "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 +#: ../../library/fractions.rst:23 msgid "" "The first version requires that *numerator* and *denominator* are instances " "of :class:`numbers.Rational` and returns a new :class:`Fraction` instance " @@ -44,7 +44,7 @@ msgid "" "it raises a :exc:`ZeroDivisionError`." msgstr "" -#: ../../library/fractions.rst:31 +#: ../../library/fractions.rst:28 msgid "" "The second version requires that *number* is an instance of :class:`numbers." "Rational` or has the :meth:`!as_integer_ratio` method (this includes :class:" @@ -58,17 +58,17 @@ msgid "" "`limit_denominator` method below.)" msgstr "" -#: ../../library/fractions.rst:43 +#: ../../library/fractions.rst:40 msgid "" "The last version of the constructor expects a string. The usual form for " "this instance is::" msgstr "" -#: ../../library/fractions.rst:46 +#: ../../library/fractions.rst:43 msgid "[sign] numerator ['/' denominator]" msgstr "[sign] numerator ['/' denominator]" -#: ../../library/fractions.rst:48 +#: ../../library/fractions.rst:45 msgid "" "where the optional ``sign`` may be either '+' or '-' and ``numerator`` and " "``denominator`` (if present) are strings of decimal digits (underscores may " @@ -79,7 +79,7 @@ msgid "" "whitespace. Here are some examples::" msgstr "" -#: ../../library/fractions.rst:57 +#: ../../library/fractions.rst:54 msgid "" ">>> from fractions import Fraction\n" ">>> Fraction(16, -10)\n" @@ -131,7 +131,7 @@ msgstr "" ">>> Fraction(Decimal('1.1'))\n" "Fraction(11, 10)" -#: ../../library/fractions.rst:83 +#: ../../library/fractions.rst:80 msgid "" "The :class:`Fraction` class inherits from the abstract base class :class:" "`numbers.Rational`, and implements all of the methods and operations from " @@ -140,7 +140,7 @@ msgid "" "properties and methods:" msgstr "" -#: ../../library/fractions.rst:89 +#: ../../library/fractions.rst:86 msgid "" "The :class:`Fraction` constructor now accepts :class:`float` and :class:" "`decimal.Decimal` instances." @@ -148,44 +148,44 @@ msgstr "" ":class:`Fraction` 建構函式現在可接受 :class:`float` 和 :class:`decimal." "Decimal` 實例。" -#: ../../library/fractions.rst:93 +#: ../../library/fractions.rst:90 msgid "" "The :func:`math.gcd` function is now used to normalize the *numerator* and " "*denominator*. :func:`math.gcd` always returns an :class:`int` type. " "Previously, the GCD type depended on *numerator* and *denominator*." msgstr "" -#: ../../library/fractions.rst:98 +#: ../../library/fractions.rst:95 msgid "" "Underscores are now permitted when creating a :class:`Fraction` instance " "from a string, following :PEP:`515` rules." msgstr "" -#: ../../library/fractions.rst:102 +#: ../../library/fractions.rst:99 msgid "" ":class:`Fraction` implements ``__int__`` now to satisfy ``typing." "SupportsInt`` instance checks." msgstr "" -#: ../../library/fractions.rst:106 +#: ../../library/fractions.rst:103 msgid "" "Space is allowed around the slash for string inputs: ``Fraction('2 / 3')``." msgstr "" -#: ../../library/fractions.rst:109 +#: ../../library/fractions.rst:106 msgid "" ":class:`Fraction` instances now support float-style formatting, with " "presentation types ``\"e\"``, ``\"E\"``, ``\"f\"``, ``\"F\"``, ``\"g\"``, " "``\"G\"`` and ``\"%\"\"``." msgstr "" -#: ../../library/fractions.rst:114 +#: ../../library/fractions.rst:111 msgid "" "Formatting of :class:`Fraction` instances without a presentation type now " "supports fill, alignment, sign handling, minimum width and grouping." msgstr "" -#: ../../library/fractions.rst:118 +#: ../../library/fractions.rst:115 msgid "" "The :class:`Fraction` constructor now accepts any objects with the :meth:`!" "as_integer_ratio` method." @@ -193,50 +193,50 @@ msgstr "" ":class:`Fraction` 建構函式現在可接受任何具有 :meth:`!as_integer_ratio` 方法的" "物件。" -#: ../../library/fractions.rst:124 +#: ../../library/fractions.rst:121 msgid "Numerator of the Fraction in lowest term." msgstr "" -#: ../../library/fractions.rst:128 +#: ../../library/fractions.rst:125 msgid "Denominator of the Fraction in lowest terms. Guaranteed to be positive." msgstr "" -#: ../../library/fractions.rst:134 +#: ../../library/fractions.rst:131 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:142 +#: ../../library/fractions.rst:139 msgid "Return ``True`` if the Fraction is an integer." msgstr "" -#: ../../library/fractions.rst:148 +#: ../../library/fractions.rst:145 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)``." msgstr "" -#: ../../library/fractions.rst:154 +#: ../../library/fractions.rst:151 msgid "" "From Python 3.2 onwards, you can also construct a :class:`Fraction` instance " "directly from a :class:`float`." msgstr "" -#: ../../library/fractions.rst:160 +#: ../../library/fractions.rst:157 msgid "" "Alternative constructor which only accepts instances of :class:`decimal." "Decimal` or :class:`numbers.Integral`." msgstr "" -#: ../../library/fractions.rst:165 +#: ../../library/fractions.rst:162 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:172 +#: ../../library/fractions.rst:169 msgid "" "Alternative constructor which only accepts instances of :class:`numbers." "Integral`, :class:`numbers.Rational`, :class:`float` or :class:`decimal." @@ -244,30 +244,30 @@ msgid "" "strings." msgstr "" -#: ../../library/fractions.rst:182 +#: ../../library/fractions.rst:179 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:190 +#: ../../library/fractions.rst:187 msgid "or for recovering a rational number that's represented as a float:" msgstr "" -#: ../../library/fractions.rst:203 +#: ../../library/fractions.rst:200 msgid "" "Returns the greatest :class:`int` ``<= self``. This method can also be " "accessed through the :func:`math.floor` function:" msgstr "" -#: ../../library/fractions.rst:213 +#: ../../library/fractions.rst:210 msgid "" "Returns the least :class:`int` ``>= self``. This method can also be " "accessed through the :func:`math.ceil` function." msgstr "" -#: ../../library/fractions.rst:220 +#: ../../library/fractions.rst:217 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 " @@ -276,14 +276,14 @@ msgid "" "func:`round` function." msgstr "" -#: ../../library/fractions.rst:228 +#: ../../library/fractions.rst:225 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 `." msgstr "" -#: ../../library/fractions.rst:232 +#: ../../library/fractions.rst:229 msgid "" "If the ``format_spec`` format specification string does not end with one of " "the presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` " @@ -295,7 +295,7 @@ msgid "" "exact integer. The zero-fill flag ``'0'`` is not supported." msgstr "" -#: ../../library/fractions.rst:242 +#: ../../library/fractions.rst:239 msgid "" "If the ``format_spec`` format specification string ends with one of the " "presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` or " @@ -303,11 +303,11 @@ msgid "" "type in the :ref:`formatspec` section." msgstr "" -#: ../../library/fractions.rst:247 +#: ../../library/fractions.rst:244 msgid "Here are some examples::" msgstr "" -#: ../../library/fractions.rst:249 +#: ../../library/fractions.rst:246 msgid "" ">>> from fractions import Fraction\n" ">>> format(Fraction(103993, 33102), '_')\n" @@ -347,14 +347,14 @@ msgstr "" ">>> \"{:.2%} price increase\".format(Fraction(new_price, old_price) - 1)\n" "'34.67% price increase'" -#: ../../library/fractions.rst:271 +#: ../../library/fractions.rst:268 msgid "Module :mod:`numbers`" msgstr ":mod:`numbers` 模組" -#: ../../library/fractions.rst:272 +#: ../../library/fractions.rst:269 msgid "The abstract base classes making up the numeric tower." msgstr "" -#: ../../library/fractions.rst:20 +#: ../../library/fractions.rst:17 msgid "as_integer_ratio()" msgstr "as_integer_ratio()" diff --git a/library/ftplib.po b/library/ftplib.po index 693d31168e9..b9af834fa52 100644 --- a/library/ftplib.po +++ b/library/ftplib.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-04-26 19:44+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -645,17 +645,10 @@ msgstr "" ":class:`!FTP_TLS` 類別繼承自 :class:`FTP`,並另外定義了這些的方法與屬性:" #: ../../library/ftplib.rst:529 -msgid "The SSL version to use (defaults to :data:`ssl.PROTOCOL_SSLv23`)." -msgstr "要使用的 SSL 版本(預設為 :data:`ssl.PROTOCOL_SSLv23`)。" +msgid "Set up a secure control connection by using TLS." +msgstr "使用 TLS 設定安全控制連線。" -#: ../../library/ftplib.rst:533 -msgid "" -"Set up a secure control connection by using TLS or SSL, depending on what is " -"specified in the :attr:`ssl_version` attribute." -msgstr "" -"根據 :attr:`ssl_version` 屬性中指定的內容,使用 TLS 或 SSL 設定安全控制連線。" - -#: ../../library/ftplib.rst:536 +#: ../../library/ftplib.rst:531 msgid "" "The method now supports hostname check with :attr:`ssl.SSLContext." "check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." @@ -663,7 +656,7 @@ msgstr "" "該方法現在支援使用 :attr:`ssl.SSLContext.check_hostname` 和 *Server Name " "Indication* 進行主機名檢查(參見 :const:`ssl.HAS_SNI`)。" -#: ../../library/ftplib.rst:543 +#: ../../library/ftplib.rst:538 msgid "" "Revert control channel back to plaintext. This can be useful to take " "advantage of firewalls that know how to handle NAT with non-secure FTP " @@ -672,37 +665,37 @@ msgstr "" "將控制通道恢復為純文本。這對於利用知道如何在不打開固定連接埠的情況下使用非安" "全 (non-secure) FTP 以處理 NAT 的防火牆很有用。" -#: ../../library/ftplib.rst:551 -msgid "Set up secure data connection." -msgstr "設定安全資料連線。" +#: ../../library/ftplib.rst:546 +msgid "Set up secure data connection by using TLS." +msgstr "使用 TLS 設定安全資料連線。" -#: ../../library/ftplib.rst:555 +#: ../../library/ftplib.rst:550 msgid "Set up clear text data connection." msgstr "設定明文資料 (clear text data) 連線。" -#: ../../library/ftplib.rst:559 +#: ../../library/ftplib.rst:554 msgid "Module variables" msgstr "模組變數" -#: ../../library/ftplib.rst:563 +#: ../../library/ftplib.rst:558 msgid "Exception raised when an unexpected reply is received from the server." msgstr "伺服器收到意外回覆時所引發的例外。" -#: ../../library/ftplib.rst:568 +#: ../../library/ftplib.rst:563 msgid "" "Exception raised when an error code signifying a temporary error (response " "codes in the range 400--499) is received." msgstr "" "當收到表示暫時錯誤的錯誤碼(400--499 範圍內的回應狀態碼)時引發的例外。" -#: ../../library/ftplib.rst:574 +#: ../../library/ftplib.rst:569 msgid "" "Exception raised when an error code signifying a permanent error (response " "codes in the range 500--599) is received." msgstr "" "當收到表示永久錯誤的錯誤碼(500--599 範圍內的回應狀態碼)時引發的例外。" -#: ../../library/ftplib.rst:580 +#: ../../library/ftplib.rst:575 msgid "" "Exception raised when a reply is received from the server that does not fit " "the response specifications of the File Transfer Protocol, i.e. begin with a " @@ -711,7 +704,7 @@ msgstr "" "當從伺服器收到不符合檔案傳輸協定回應規範的回覆時引發例外,即 1--5 範圍內的數" "字開頭。" -#: ../../library/ftplib.rst:587 +#: ../../library/ftplib.rst:582 msgid "" "The set of all exceptions (as a tuple) that methods of :class:`FTP` " "instances may raise as a result of problems with the FTP connection (as " @@ -722,11 +715,11 @@ msgstr "" "所有例外集合(元組形式)。該集合包括上面列出的四個例外以及 :exc:`OSError` " "和 :exc:`EOFError`。" -#: ../../library/ftplib.rst:595 +#: ../../library/ftplib.rst:590 msgid "Module :mod:`netrc`" msgstr ":mod:`netrc` 模組" -#: ../../library/ftplib.rst:596 +#: ../../library/ftplib.rst:591 msgid "" "Parser for the :file:`.netrc` file format. The file :file:`.netrc` is " "typically used by FTP clients to load user authentication information before " @@ -746,3 +739,13 @@ msgstr "protocol(協定)" #: ../../library/ftplib.rst:9 msgid "ftplib (standard module)" msgstr "ftplib(標準模組)" + +#~ msgid "The SSL version to use (defaults to :data:`ssl.PROTOCOL_SSLv23`)." +#~ msgstr "要使用的 SSL 版本(預設為 :data:`ssl.PROTOCOL_SSLv23`)。" + +#~ msgid "" +#~ "Set up a secure control connection by using TLS or SSL, depending on what " +#~ "is specified in the :attr:`ssl_version` attribute." +#~ msgstr "" +#~ "根據 :attr:`ssl_version` 屬性中指定的內容,使用 TLS 或 SSL 設定安全控制連" +#~ "線。" diff --git a/library/functools.po b/library/functools.po index 0a76bf6f145..48595bba8d1 100644 --- a/library/functools.po +++ b/library/functools.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-03 00:30+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-05-11 16:02+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgid "" "objects" msgstr ":mod:`functools` --- 可呼叫物件上的高階函式與操作" -#: ../../library/functools.rst:14 +#: ../../library/functools.rst:7 msgid "**Source code:** :source:`Lib/functools.py`" msgstr "**原始碼:**\\ :source:`Lib/functools.py`" -#: ../../library/functools.rst:23 +#: ../../library/functools.rst:16 msgid "" "The :mod:`!functools` module is for higher-order functions: functions that " "act on or return other functions. In general, any callable object can be " @@ -37,11 +37,11 @@ msgstr "" ":mod:`!functools` 模組用於高階函式:作用於或回傳其他函式的函式。一般來說,任" "何可呼叫物件都可以被視為用於此模組的函式。" -#: ../../library/functools.rst:27 +#: ../../library/functools.rst:20 msgid "The :mod:`!functools` module defines the following functions:" msgstr ":mod:`!functools` 模組定義了以下函式:" -#: ../../library/functools.rst:31 +#: ../../library/functools.rst:24 msgid "" "Simple lightweight unbounded function cache. Sometimes called `\"memoize\" " "`_." @@ -50,7 +50,7 @@ msgstr "" "時稱之為 `\"memoize\"(記憶化) `_。" -#: ../../library/functools.rst:34 +#: ../../library/functools.rst:27 msgid "" "Returns the same as ``lru_cache(maxsize=None)``, creating a thin wrapper " "around a dictionary lookup for the function arguments. Because it never " @@ -61,11 +61,11 @@ msgstr "" "裝器。因為它永遠不需要丟棄舊值,所以這比有大小限制的 :deco:`lru_cache` 更小、" "更快。" -#: ../../library/functools.rst:39 ../../library/functools.rst:297 +#: ../../library/functools.rst:32 ../../library/functools.rst:294 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/functools.rst:41 +#: ../../library/functools.rst:34 msgid "" "@cache\n" "def factorial(n):\n" @@ -89,7 +89,7 @@ msgstr "" ">>> factorial(12) # 兩次新的遞迴呼叫,factorial(10) 有被快取起來\n" "479001600" -#: ../../library/functools.rst:52 ../../library/functools.rst:158 +#: ../../library/functools.rst:45 ../../library/functools.rst:155 msgid "" "The cache is threadsafe so that the wrapped function can be used in multiple " "threads. This means that the underlying data structure will remain coherent " @@ -98,7 +98,7 @@ msgstr "" "該快取是執行緒安全的 (threadsafe),因此包裝的函式可以在多個執行緒中使用。這意" "味著底層資料結構在並行更新期間將保持連貫 (coherent)。" -#: ../../library/functools.rst:56 ../../library/functools.rst:162 +#: ../../library/functools.rst:49 ../../library/functools.rst:159 msgid "" "It is possible for the wrapped function to be called more than once if " "another thread makes an additional call before the initial call has been " @@ -107,7 +107,14 @@ msgstr "" "如果另一個執行緒在初始呼叫完成並快取之前進行額外的呼叫,則包裝的函式可能會被" "多次呼叫。" -#: ../../library/functools.rst:65 +#: ../../library/functools.rst:53 +msgid "" +"Call-once behavior is not guaranteed because locks are not held during the " +"function call. Potentially another call with the same arguments could occur " +"while the first call is still running." +msgstr "" + +#: ../../library/functools.rst:62 msgid "" "Transform a method of a class into a property whose value is computed once " "and then cached as a normal attribute for the life of the instance. Similar " @@ -118,12 +125,12 @@ msgstr "" "快取為普通屬性。類似 :deco:`property`,但增加了快取機制。對於除使用該裝飾器的" "屬性外實質上幾乎是不可變 (immutable) 的實例,針對其所需要繁重計算會很有用。" -#: ../../library/functools.rst:70 ../../library/functools.rst:142 -#: ../../library/functools.rst:438 +#: ../../library/functools.rst:67 ../../library/functools.rst:139 +#: ../../library/functools.rst:435 msgid "Example::" msgstr "範例: ::" -#: ../../library/functools.rst:72 +#: ../../library/functools.rst:69 msgid "" "class DataSet:\n" "\n" @@ -143,7 +150,7 @@ msgstr "" " def stdev(self):\n" " return statistics.stdev(self._data)" -#: ../../library/functools.rst:81 +#: ../../library/functools.rst:78 msgid "" "The mechanics of :deco:`cached_property` are somewhat different from :deco:" "`property`. A regular property blocks attribute writes unless a setter is " @@ -152,7 +159,7 @@ msgstr "" ":deco:`cached_property` 的機制與 :deco:`property` 有所不同。除非定義了 " "setter,否則常規屬性會阻止屬性的寫入。相反地,*cached_property* 則允許寫入。" -#: ../../library/functools.rst:85 +#: ../../library/functools.rst:82 msgid "" "The *cached_property* decorator only runs on lookups and only when an " "attribute of the same name doesn't exist. When it does run, the " @@ -164,14 +171,14 @@ msgstr "" "*cached_property* 會寫入同名的屬性。後續屬性讀取和寫入優先於 " "*cached_property* 方法,並且它的工作方式與普通屬性類似。" -#: ../../library/functools.rst:91 +#: ../../library/functools.rst:88 msgid "" "The cached value can be cleared by deleting the attribute. This allows the " "*cached_property* method to run again." msgstr "" "可以透過刪除屬性來清除快取的值,這使得 *cached_property* 方法可以再次運行。" -#: ../../library/functools.rst:94 +#: ../../library/functools.rst:91 msgid "" "The *cached_property* does not prevent a possible race condition in multi-" "threaded usage. The getter function could run more than once on the same " @@ -187,7 +194,7 @@ msgstr "" "題。如果同步是必要的,請在裝飾的 getter 函式內部或在快取的屬性存取周圍實作必" "要的鎖。" -#: ../../library/functools.rst:102 +#: ../../library/functools.rst:99 msgid "" "Note, this decorator interferes with the operation of :pep:`412` key-sharing " "dictionaries. This means that instance dictionaries can take more space " @@ -196,7 +203,7 @@ msgstr "" "請注意,此裝飾器會干擾 :pep:`412` 金鑰共用字典的操作。這意味著實例字典可能比" "平常佔用更多的空間。" -#: ../../library/functools.rst:106 +#: ../../library/functools.rst:103 msgid "" "Also, this decorator requires that the ``__dict__`` attribute on each " "instance be a mutable mapping. This means it will not work with some types, " @@ -211,7 +218,7 @@ msgstr "" "不包含 ``__dict__`` 的型別作為有定義的插槽之一(因為此種類別根本不提供 " "``__dict__`` 屬性)。" -#: ../../library/functools.rst:113 +#: ../../library/functools.rst:110 msgid "" "If a mutable mapping is not available or if space-efficient key sharing is " "desired, an effect similar to :deco:`cached_property` can also be achieved " @@ -224,7 +231,7 @@ msgstr "" "\\ :ref:`faq-cache-method-calls`\\ 以了解有關這與 :deco:`cached_property` 間" "不同之處的更多詳細資訊。" -#: ../../library/functools.rst:120 +#: ../../library/functools.rst:117 msgid "" "Prior to Python 3.12, :deco:`!cached_property` included an undocumented lock " "to ensure that in multi-threaded usage the getter function was guaranteed to " @@ -237,7 +244,7 @@ msgstr "" "每個屬性,而不是針對每個實例,這可能會導致無法被接受的嚴重鎖爭用 (lock " "contention)。在 Python 3.12+ 中,此鎖已被刪除。" -#: ../../library/functools.rst:130 +#: ../../library/functools.rst:127 msgid "" "Transform an old-style comparison function to a :term:`key function`. Used " "with tools that accept key functions (such as :func:`sorted`, :func:`min`, :" @@ -251,7 +258,7 @@ msgstr "" "nlargest`、:func:`heapq.nsmallest`、:func:`itertools.groupby`)。此函式主要作" "為轉換工具,用於從有支援使用比較函式的 Python 2 轉換成的程式。" -#: ../../library/functools.rst:137 +#: ../../library/functools.rst:134 msgid "" "A comparison function is any callable that accepts two arguments, compares " "them, and returns a negative number for less-than, zero for equality, or a " @@ -262,17 +269,17 @@ msgstr "" "或正數(大於)的可呼叫物件。鍵函式是接受一個引數並回傳另一個用作排序鍵之值的" "可呼叫物件。" -#: ../../library/functools.rst:144 +#: ../../library/functools.rst:141 msgid "" "sorted(iterable, key=cmp_to_key(locale.strcoll)) # locale-aware sort order" msgstr "" -#: ../../library/functools.rst:146 +#: ../../library/functools.rst:143 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "有關排序範例和簡短的排序教學,請參閱\\ :ref:`sortinghowto`。" -#: ../../library/functools.rst:154 +#: ../../library/functools.rst:151 msgid "" "Decorator to wrap a function with a memoizing callable that saves up to the " "*maxsize* most recent calls. It can save time when an expensive or I/O " @@ -281,7 +288,7 @@ msgstr "" "以記憶化可呼叫物件來包裝函式的裝飾器,最多可省去 *maxsize* 個最近的呼叫。當使" "用相同引數定期呼叫繁重的或 I/O 密集的函式時,它可以節省時間。" -#: ../../library/functools.rst:166 +#: ../../library/functools.rst:163 msgid "" "Since a dictionary is used to cache results, the positional and keyword " "arguments to the function must be :term:`hashable`." @@ -289,7 +296,7 @@ msgstr "" "由於字典用於快取結果,因此函式的位置引數和關鍵字引數必須是\\ :term:`可雜湊的 " "`。" -#: ../../library/functools.rst:169 +#: ../../library/functools.rst:166 msgid "" "Distinct argument patterns may be considered to be distinct calls with " "separate cache entries. For example, ``f(a=1, b=2)`` and ``f(b=2, a=1)`` " @@ -299,7 +306,7 @@ msgstr "" "不同的引數模式可以被認為是具有不同快取條目的不同呼叫。例如,``f(a=1, b=2)`` " "和 ``f(b=2, a=1)`` 的關鍵字引數順序不同,並且可能有兩個不同的快取條目。" -#: ../../library/functools.rst:174 +#: ../../library/functools.rst:171 msgid "" "If *user_function* is specified, it must be a callable. This allows the " "*lru_cache* decorator to be applied directly to a user function, leaving the " @@ -308,24 +315,24 @@ msgstr "" "如果指定了 *user_function*,則它必須是個可呼叫物件。這使得 *lru_cache* 裝飾器" "能夠直接應用於使用者函式,將 *maxsize* 保留為其預設值 128: ::" -#: ../../library/functools.rst:178 +#: ../../library/functools.rst:175 msgid "" "@lru_cache\n" -"def count_vowels(sentence):\n" -" return sum(sentence.count(vowel) for vowel in 'AEIOUaeiou')" +"def count_vowels(word):\n" +" return sum(word.count(vowel) for vowel in 'AEIOUaeiou')" msgstr "" "@lru_cache\n" -"def count_vowels(sentence):\n" -" return sum(sentence.count(vowel) for vowel in 'AEIOUaeiou')" +"def count_vowels(word):\n" +" return sum(word.count(vowel) for vowel in 'AEIOUaeiou')" -#: ../../library/functools.rst:182 +#: ../../library/functools.rst:179 msgid "" "If *maxsize* is set to ``None``, the LRU feature is disabled and the cache " "can grow without bound." msgstr "" "如果 *maxsize* 設定為 ``None``,則 LRU 功能將被停用,且快取可以無限制地成長。" -#: ../../library/functools.rst:185 +#: ../../library/functools.rst:182 msgid "" "If *typed* is set to true, function arguments of different types will be " "cached separately. If *typed* is false, the implementation will usually " @@ -336,7 +343,7 @@ msgstr "" "為 false,則實作通常會將它們視為等效呼叫,並且僅快取單一結果。(某些型別,例" "如 *str* 和 *int* 可能會被單獨快取起來,即使 *typed* 為 false。)" -#: ../../library/functools.rst:191 +#: ../../library/functools.rst:188 msgid "" "Note, type specificity applies only to the function's immediate arguments " "rather than their contents. The scalar arguments, ``Decimal(42)`` and " @@ -349,7 +356,7 @@ msgstr "" "呼叫。相反地,元組引數 ``('answer', Decimal(42))`` 和 ``('answer', " "Fraction(42))`` 被視為等效。" -#: ../../library/functools.rst:197 +#: ../../library/functools.rst:194 msgid "" "The wrapped function is instrumented with a :func:`!cache_parameters` " "function that returns a new :class:`dict` showing the values for *maxsize* " @@ -360,7 +367,7 @@ msgstr "" "的 :class:`dict` 以顯示 *maxsize* 和 *typed* 的值。這僅能顯示資訊,改變其值不" "會有任何效果。" -#: ../../library/functools.rst:205 +#: ../../library/functools.rst:202 msgid "" "To help measure the effectiveness of the cache and tune the *maxsize* " "parameter, the wrapped function is instrumented with a :func:`!cache_info` " @@ -371,13 +378,13 @@ msgstr "" "cache_info` 函式來做檢測,該函式會回傳一個\\ :term:`附名元組 `\\ 來顯示 *hits*、*misses*、*maxsize* 和 *currsize*。" -#: ../../library/functools.rst:213 +#: ../../library/functools.rst:210 msgid "" "The decorator also provides a :func:`!cache_clear` function for clearing or " "invalidating the cache." msgstr "裝飾器還提供了一個 :func:`!cache_clear` 函式來清除或使快取失效。" -#: ../../library/functools.rst:216 +#: ../../library/functools.rst:213 msgid "" "The original underlying function is accessible through the :attr:" "`__wrapped__` attribute. This is useful for introspection, for bypassing " @@ -386,14 +393,14 @@ msgstr "" "原本的底層函式可以透過 :attr:`__wrapped__` 屬性存取。這對於要自我檢查 " "(introspection)、繞過快取或使用不同的快取重新包裝函式時非常有用。" -#: ../../library/functools.rst:220 +#: ../../library/functools.rst:217 msgid "" "The cache keeps references to the arguments and return values until they age " "out of the cache or until the cache is cleared." msgstr "" "快取會保留對引數和回傳值的參照,直到快取過時 (age out) 或快取被清除為止。" -#: ../../library/functools.rst:223 +#: ../../library/functools.rst:220 msgid "" "If a method is cached, the ``self`` instance argument is included in the " "cache. See :ref:`faq-cache-method-calls`" @@ -401,7 +408,7 @@ msgstr "" "如果方法被快取起來,則 ``self`` 實例引數將包含在快取中。請參閱\\ :ref:`faq-" "cache-method-calls`" -#: ../../library/functools.rst:226 +#: ../../library/functools.rst:223 msgid "" "An `LRU (least recently used) cache `_ works best when the " @@ -416,7 +423,7 @@ msgstr "" "能發揮最好的效果。快取的大小限制可確保快取不會在長時間運行的行程(例如 Web 伺" "服器)上無限制地成長。" -#: ../../library/functools.rst:233 +#: ../../library/functools.rst:230 msgid "" "In general, the LRU cache should only be used when you want to reuse " "previously computed values. Accordingly, it doesn't make sense to cache " @@ -428,11 +435,11 @@ msgstr "" "side-effects 的函式、需要在每次呼叫時建立不同可變物件的函式(例如產生器和非同" "步函式)或不純函式(impure function,例如 time() 或 random())是沒有意義的。" -#: ../../library/functools.rst:239 +#: ../../library/functools.rst:236 msgid "Example of an LRU cache for static web content::" msgstr "靜態網頁內容的 LRU 快取範例: ::" -#: ../../library/functools.rst:241 +#: ../../library/functools.rst:238 msgid "" "@lru_cache(maxsize=32)\n" "def get_pep(num):\n" @@ -468,7 +475,7 @@ msgstr "" ">>> get_pep.cache_info()\n" "CacheInfo(hits=3, misses=8, maxsize=32, currsize=8)" -#: ../../library/functools.rst:258 +#: ../../library/functools.rst:255 msgid "" "Example of efficiently computing `Fibonacci numbers `_ using a cache to implement a `dynamic " @@ -478,7 +485,7 @@ msgstr "" "wiki/Dynamic_programming>`_ 技法以有效率地計算\\ `費波那契數 (Fibonacci " "numbers) `_ 的範例: ::" -#: ../../library/functools.rst:264 +#: ../../library/functools.rst:261 msgid "" "@lru_cache(maxsize=None)\n" "def fib(n):\n" @@ -504,19 +511,19 @@ msgstr "" ">>> fib.cache_info()\n" "CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)" -#: ../../library/functools.rst:278 +#: ../../library/functools.rst:275 msgid "Added the *typed* option." msgstr "新增 *typed* 選項。" -#: ../../library/functools.rst:281 +#: ../../library/functools.rst:278 msgid "Added the *user_function* option." msgstr "新增 *user_function* 選項。" -#: ../../library/functools.rst:284 +#: ../../library/functools.rst:281 msgid "Added the function :func:`!cache_parameters`" msgstr "新增 :func:`!cache_parameters` 函式。" -#: ../../library/functools.rst:289 +#: ../../library/functools.rst:286 msgid "" "Given a class defining one or more rich comparison ordering methods, this " "class decorator supplies the rest. This simplifies the effort involved in " @@ -525,7 +532,7 @@ msgstr "" "給定一個定義一個或多個 rich comparison 排序方法的類別,該類別裝飾器會提供其餘" "部分。這簡化了指定所有可能的 rich comparison 操作所涉及的工作:" -#: ../../library/functools.rst:293 +#: ../../library/functools.rst:290 msgid "" "The class must define one of :meth:`~object.__lt__`, :meth:`~object." "__le__`, :meth:`~object.__gt__`, or :meth:`~object.__ge__`. In addition, the " @@ -535,7 +542,7 @@ msgstr "" "__gt__` 或 :meth:`~object.__ge__` 其中之一。此外,該類別應該提供 :meth:" "`~object.__eq__` 方法。" -#: ../../library/functools.rst:299 +#: ../../library/functools.rst:296 msgid "" "@total_ordering\n" "class Student:\n" @@ -569,7 +576,7 @@ msgstr "" " return ((self.lastname.lower(), self.firstname.lower()) <\n" " (other.lastname.lower(), other.firstname.lower()))" -#: ../../library/functools.rst:317 +#: ../../library/functools.rst:314 msgid "" "While this decorator makes it easy to create well behaved totally ordered " "types, it *does* come at the cost of slower execution and more complex stack " @@ -582,7 +589,7 @@ msgstr "" "其代價。如果效能基準測試顯示這是給定應用程式的效能瓶頸,那麼實作全部六種 " "rich comparison 方法通常能輕鬆地提升速度。" -#: ../../library/functools.rst:326 +#: ../../library/functools.rst:323 msgid "" "This decorator makes no attempt to override methods that have been declared " "in the class *or its superclasses*. Meaning that if a superclass defines a " @@ -593,19 +600,19 @@ msgstr "" "如果超類別定義了比較運算子,*total_ordering* 將不會再次實作它,即使原始方法是" "抽象的。" -#: ../../library/functools.rst:333 +#: ../../library/functools.rst:330 msgid "" "Returning ``NotImplemented`` from the underlying comparison function for " "unrecognised types is now supported." msgstr "現在支援從底層對於未識別型別的比較函式回傳 ``NotImplemented``。" -#: ../../library/functools.rst:339 +#: ../../library/functools.rst:336 msgid "" "A singleton object used as a sentinel to reserve a place for positional " "arguments when calling :func:`partial` and :func:`partialmethod`." msgstr "" -#: ../../library/functools.rst:347 +#: ../../library/functools.rst:344 msgid "" "Return a new :ref:`partial object` which when called will " "behave like *func* called with the positional arguments *args* and keyword " @@ -618,7 +625,7 @@ msgstr "" "引數,它們將被附加到 *args*。如果提供了額外的關鍵字引數,它們會擴充並覆寫 " "*keywords*。大致相當於: ::" -#: ../../library/functools.rst:354 +#: ../../library/functools.rst:351 msgid "" "def partial(func, /, *args, **keywords):\n" " def newfunc(*more_args, **more_keywords):\n" @@ -636,7 +643,7 @@ msgstr "" " newfunc.keywords = keywords\n" " return newfunc" -#: ../../library/functools.rst:362 +#: ../../library/functools.rst:359 msgid "" "The :func:`!partial` function is used for partial function application which " "\"freezes\" some portion of a function's arguments and/or keywords resulting " @@ -648,7 +655,7 @@ msgstr "" "分,從而產生具有簡化簽名的新物件。例如,:func:`partial` 可用來建立可呼叫函" "式,其行為類似於 :func:`int` 函式,其中 *base* 引數預設為 2:" -#: ../../library/functools.rst:368 +#: ../../library/functools.rst:365 msgid "" ">>> basetwo = partial(int, base=2)\n" ">>> basetwo.__doc__ = 'Convert base 2 string to an int.'\n" @@ -660,7 +667,7 @@ msgstr "" ">>> basetwo('10010')\n" "18" -#: ../../library/functools.rst:375 +#: ../../library/functools.rst:372 msgid "" "If :data:`Placeholder` sentinels are present in *args*, they will be filled " "first when :func:`!partial` is called. This makes it possible to pre-fill " @@ -669,13 +676,13 @@ msgid "" "pre-filled." msgstr "" -#: ../../library/functools.rst:380 +#: ../../library/functools.rst:377 msgid "" "If any :data:`!Placeholder` sentinels are present, all must be filled at " "call time:" msgstr "" -#: ../../library/functools.rst:382 +#: ../../library/functools.rst:379 msgid "" ">>> say_to_world = partial(print, Placeholder, Placeholder, \"world!\")\n" ">>> say_to_world('Hello', 'dear')\n" @@ -685,14 +692,14 @@ msgstr "" ">>> say_to_world('Hello', 'dear')\n" "Hello dear world!" -#: ../../library/functools.rst:388 +#: ../../library/functools.rst:385 msgid "" "Calling ``say_to_world('Hello')`` raises a :exc:`TypeError`, because only " "one positional argument is provided, but there are two placeholders that " "must be filled in." msgstr "" -#: ../../library/functools.rst:392 +#: ../../library/functools.rst:389 msgid "" "If :func:`!partial` is applied to an existing :ref:`partial object `, :data:`!Placeholder` sentinels of the input object are filled in " @@ -701,7 +708,7 @@ msgid "" "Placeholder`:" msgstr "" -#: ../../library/functools.rst:398 +#: ../../library/functools.rst:395 msgid "" ">>> from functools import partial, Placeholder as _\n" ">>> remove = partial(str.replace, _, _, '')\n" @@ -727,17 +734,17 @@ msgstr "" ">>> remove_first_dear(message)\n" "'Hello, dear world!'" -#: ../../library/functools.rst:412 +#: ../../library/functools.rst:409 msgid "" ":data:`!Placeholder` cannot be passed to :func:`!partial` as a keyword " "argument." msgstr "" -#: ../../library/functools.rst:414 +#: ../../library/functools.rst:411 msgid "Added support for :data:`Placeholder` in positional arguments." msgstr "" -#: ../../library/functools.rst:419 +#: ../../library/functools.rst:416 msgid "" "Return a new :class:`partialmethod` descriptor which behaves like :class:" "`partial` except that it is designed to be used as a method definition " @@ -746,7 +753,7 @@ msgstr "" "回傳一個新的 :class:`partialmethod` 描述器 (descriptor),其行為類似於 :class:" "`partial`,只不過它被設計為用於方法定義而不能直接呼叫。" -#: ../../library/functools.rst:423 +#: ../../library/functools.rst:420 msgid "" "*func* must be a :term:`descriptor` or a callable (objects which are both, " "like normal functions, are handled as descriptors)." @@ -754,7 +761,7 @@ msgstr "" "*func* 必須是一個 :term:`descriptor` 或可呼叫物件(兩者兼具的物件,就像普通函" "式一樣,會被當作描述器處理)。" -#: ../../library/functools.rst:426 +#: ../../library/functools.rst:423 msgid "" "When *func* is a descriptor (such as a normal Python function, :func:" "`classmethod`, :func:`staticmethod`, :func:`~abc.abstractmethod` or another " @@ -767,7 +774,7 @@ msgstr "" "個實例),對 ``__get__`` 的呼叫將被委託 (delegated) 給底層描述器,且一個適當" "的 :ref:`partial 物件 `\\ 會被作為結果回傳。" -#: ../../library/functools.rst:432 +#: ../../library/functools.rst:429 msgid "" "When *func* is a non-descriptor callable, an appropriate bound method is " "created dynamically. This behaves like a normal Python function when used as " @@ -780,7 +787,7 @@ msgstr "" "*self* 引數將作為第一個位置引數插入,甚至會在提供給 :class:`partialmethod` 建" "構函式的 *args* 和 *keywords* 的前面。" -#: ../../library/functools.rst:440 +#: ../../library/functools.rst:437 msgid "" ">>> class Cell:\n" "... def __init__(self):\n" @@ -818,7 +825,7 @@ msgstr "" ">>> c.alive\n" "True" -#: ../../library/functools.rst:463 +#: ../../library/functools.rst:460 msgid "" "Apply *function* of two arguments cumulatively to the items of *iterable*, " "from left to right, so as to reduce the iterable to a single value. For " @@ -837,13 +844,13 @@ msgstr "" "物件的項目之前,並在可疊代物件為空時作為預設值。如果未給定 *initial* 且 " "*iterable* 僅包含一個項目,則回傳第一個項目。" -#: ../../library/functools.rst:472 +#: ../../library/functools.rst:469 msgid "Roughly equivalent to::" msgstr "大致相當於: ::" -#: ../../library/functools.rst:474 +#: ../../library/functools.rst:471 msgid "" -"initial_missing = object()\n" +"initial_missing = sentinel('initial_missing')\n" "\n" "def reduce(function, iterable, /, initial=initial_missing):\n" " it = iter(iterable)\n" @@ -855,7 +862,7 @@ msgid "" " value = function(value, element)\n" " return value" msgstr "" -"initial_missing = object()\n" +"initial_missing = sentinel('initial_missing')\n" "\n" "def reduce(function, iterable, /, initial=initial_missing):\n" " it = iter(iterable)\n" @@ -867,7 +874,7 @@ msgstr "" " value = function(value, element)\n" " return value" -#: ../../library/functools.rst:486 +#: ../../library/functools.rst:483 msgid "" "See :func:`itertools.accumulate` for an iterator that yields all " "intermediate values." @@ -875,11 +882,11 @@ msgstr "" "請參閱 :func:`itertools.accumulate` 以了解產生 (yield) 所有中間值 " "(intermediate value) 的疊代器。" -#: ../../library/functools.rst:489 +#: ../../library/functools.rst:486 msgid "*initial* is now supported as a keyword argument." msgstr "" -#: ../../library/functools.rst:494 +#: ../../library/functools.rst:491 msgid "" "Transform a function into a :term:`single-dispatch ` :term:" "`generic function`." @@ -887,7 +894,7 @@ msgstr "" "將函式轉換為\\ :term:`單一調度 `\\ :term:`泛型函式 `。" -#: ../../library/functools.rst:497 +#: ../../library/functools.rst:494 msgid "" "To define a generic function, decorate it with the ``@singledispatch`` " "decorator. When defining a function using ``@singledispatch``, note that the " @@ -897,7 +904,7 @@ msgstr "" "``@singledispatch`` 定義函式時,分派調度 (dispatch) 是發生在第一個引數的型別" "上: ::" -#: ../../library/functools.rst:501 +#: ../../library/functools.rst:498 msgid "" ">>> from functools import singledispatch\n" ">>> @singledispatch\n" @@ -913,7 +920,7 @@ msgstr "" "... print(\"Let me just say,\", end=\" \")\n" "... print(arg)" -#: ../../library/functools.rst:511 +#: ../../library/functools.rst:508 msgid "" "To add overloaded implementations to the function, use the :func:`!register` " "attribute of the generic function, which can be used as a decorator. For " @@ -923,7 +930,7 @@ msgstr "" "若要為函式新增過載實作,請使用泛型函式的 :func:`!register` 屬性,該屬性可用作" "裝飾器。對於以型別來註釋的函式,裝飾器將自動推斷第一個引數的型別: ::" -#: ../../library/functools.rst:516 +#: ../../library/functools.rst:513 msgid "" ">>> @fun.register\n" "... def _(arg: int, verbose=False):\n" @@ -951,11 +958,11 @@ msgstr "" "... for i, elem in enumerate(arg):\n" "... print(i, elem)" -#: ../../library/functools.rst:529 +#: ../../library/functools.rst:526 msgid ":class:`typing.Union` can also be used::" msgstr "也可以使用 :class:`typing.Union`: ::" -#: ../../library/functools.rst:531 +#: ../../library/functools.rst:528 msgid "" ">>> @fun.register\n" "... def _(arg: int | float, verbose=False):\n" @@ -987,14 +994,14 @@ msgstr "" "... print(i, elem)\n" "..." -#: ../../library/functools.rst:546 +#: ../../library/functools.rst:543 msgid "" "For code which doesn't use type annotations, the appropriate type argument " "can be passed explicitly to the decorator itself::" msgstr "" "對於不使用型別註釋的程式碼,可以將適當的型別引數明確傳遞給裝飾器本身: ::" -#: ../../library/functools.rst:549 +#: ../../library/functools.rst:546 msgid "" ">>> @fun.register(complex)\n" "... def _(arg, verbose=False):\n" @@ -1010,7 +1017,7 @@ msgstr "" "... print(arg.real, arg.imag)\n" "..." -#: ../../library/functools.rst:556 +#: ../../library/functools.rst:553 msgid "" "For code that dispatches on a collections type (e.g., ``list``), but wants " "to typehint the items of the collection (e.g., ``list[int]``), the dispatch " @@ -1018,7 +1025,7 @@ msgid "" "going into the function definition::" msgstr "" -#: ../../library/functools.rst:561 +#: ../../library/functools.rst:558 msgid "" ">>> @fun.register(list)\n" "... def _(arg: list[int], verbose=False):\n" @@ -1034,7 +1041,7 @@ msgstr "" "... for i, elem in enumerate(arg):\n" "... print(i, elem)" -#: ../../library/functools.rst:570 +#: ../../library/functools.rst:567 msgid "" "At runtime the function will dispatch on an instance of a list regardless of " "the type contained within the list i.e. ``[1,2,3]`` will be dispatched the " @@ -1042,7 +1049,7 @@ msgid "" "example is for static type checkers only and has no runtime impact." msgstr "" -#: ../../library/functools.rst:576 +#: ../../library/functools.rst:573 msgid "" "To enable registering :term:`lambdas` and pre-existing functions, " "the :func:`~singledispatch.register` attribute can also be used in a " @@ -1051,7 +1058,7 @@ msgstr "" "若要啟用註冊 :term:`lambdas` 和預先存在的函式,:func:" "`~singledispatch.register` 屬性也能以函式形式使用: ::" -#: ../../library/functools.rst:579 +#: ../../library/functools.rst:576 msgid "" ">>> def nothing(arg, verbose=False):\n" "... print(\"Nothing.\")\n" @@ -1063,7 +1070,7 @@ msgstr "" "...\n" ">>> fun.register(type(None), nothing)" -#: ../../library/functools.rst:584 +#: ../../library/functools.rst:581 msgid "" "The :func:`~singledispatch.register` attribute returns the undecorated " "function. This enables decorator stacking, :mod:`pickling`, and the " @@ -1073,7 +1080,7 @@ msgstr "" "疊 (decorator stacking)、:mod:`pickling` 以及為每個變體獨立建立單元測" "試成為可能:" -#: ../../library/functools.rst:588 +#: ../../library/functools.rst:585 msgid "" ">>> @fun.register(float)\n" "... @fun.register(Decimal)\n" @@ -1095,13 +1102,13 @@ msgstr "" ">>> fun_num is fun\n" "False" -#: ../../library/functools.rst:598 +#: ../../library/functools.rst:595 msgid "" "When called, the generic function dispatches on the type of the first " "argument::" msgstr "呼叫時,泛型函式會分派第一個引數的型別: ::" -#: ../../library/functools.rst:601 +#: ../../library/functools.rst:598 msgid "" ">>> fun(\"Hello, world.\")\n" "Hello, world.\n" @@ -1137,7 +1144,7 @@ msgstr "" ">>> fun(1.23)\n" "0.615" -#: ../../library/functools.rst:618 +#: ../../library/functools.rst:615 msgid "" "Where there is no registered implementation for a specific type, its method " "resolution order is used to find a more generic implementation. The original " @@ -1149,7 +1156,7 @@ msgstr "" "尋找更通用的實作。用 ``@singledispatch`` 裝飾的原始函式是為基底 :class:" "`object` 型別註冊的,這意味著如果沒有找到更好的實作就會使用它。" -#: ../../library/functools.rst:624 +#: ../../library/functools.rst:621 msgid "" "If an implementation is registered to an :term:`abstract base class`, " "virtual subclasses of the base class will be dispatched to that " @@ -1158,7 +1165,7 @@ msgstr "" "如果一個實作有被註冊到一個\\ :term:`抽象基底類別 `,則基" "底類別的虛擬子類別將被分派到該實作: ::" -#: ../../library/functools.rst:628 +#: ../../library/functools.rst:625 msgid "" ">>> from collections.abc import Mapping\n" ">>> @fun.register\n" @@ -1182,14 +1189,14 @@ msgstr "" ">>> fun({\"a\": \"b\"})\n" "a => b" -#: ../../library/functools.rst:639 +#: ../../library/functools.rst:636 msgid "" "To check which implementation the generic function will choose for a given " "type, use the ``dispatch()`` attribute::" msgstr "" "若要檢查泛型函式將為給定型別選擇哪種實作,請使用 ``dispatch()`` 屬性: ::" -#: ../../library/functools.rst:642 +#: ../../library/functools.rst:639 msgid "" ">>> fun.dispatch(float)\n" "\n" @@ -1197,13 +1204,13 @@ msgid "" "" msgstr "" -#: ../../library/functools.rst:647 +#: ../../library/functools.rst:644 msgid "" "To access all registered implementations, use the read-only ``registry`` " "attribute::" msgstr "若要存取所有已註冊的實作,請使用唯讀 ``registry`` 屬性: ::" -#: ../../library/functools.rst:650 +#: ../../library/functools.rst:647 msgid "" ">>> fun.registry.keys()\n" "dict_keys([, , ,\n" @@ -1223,13 +1230,13 @@ msgstr "" ">>> fun.registry[object]\n" "" -#: ../../library/functools.rst:661 +#: ../../library/functools.rst:658 msgid "" "The :func:`~singledispatch.register` attribute now supports using type " "annotations." msgstr ":func:`~singledispatch.register` 屬性現在支援使用型別註釋。" -#: ../../library/functools.rst:664 +#: ../../library/functools.rst:661 msgid "" "The :func:`~singledispatch.register` attribute now supports :class:`typing." "Union` as a type annotation." @@ -1237,7 +1244,7 @@ msgstr "" ":func:`~singledispatch.register` 屬性現在支援使用 :class:`typing.Union` 型別" "註釋。" -#: ../../library/functools.rst:671 +#: ../../library/functools.rst:668 msgid "" "Transform a method into a :term:`single-dispatch ` :term:" "`generic function`." @@ -1245,7 +1252,7 @@ msgstr "" "將方法轉換為\\ :term:`單一調度 `\\ :term:`泛型函式 `。" -#: ../../library/functools.rst:674 +#: ../../library/functools.rst:671 msgid "" "To define a generic method, decorate it with the ``@singledispatchmethod`` " "decorator. When defining a method using ``@singledispatchmethod``, note that " @@ -1256,7 +1263,7 @@ msgstr "" "用 ``@singledispatchmethod`` 定義方法時,分派調度是發生在第一個非 *self* 或" "非 *cls* 引數的型別上: ::" -#: ../../library/functools.rst:679 +#: ../../library/functools.rst:676 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1284,7 +1291,7 @@ msgstr "" " def _(self, arg: bool):\n" " return not arg" -#: ../../library/functools.rst:692 +#: ../../library/functools.rst:689 msgid "" "``@singledispatchmethod`` supports nesting with other decorators such as :" "deco:`classmethod`. Note that to allow for ``dispatcher.register``, " @@ -1297,7 +1304,7 @@ msgstr "" "``singledispatchmethod`` 必須是\\ *最外面的*\\ 裝飾器。以下範例是 " "``Negator`` 類別,其 ``neg`` 方法繫結到該類別,而不是該類別的實例: ::" -#: ../../library/functools.rst:698 +#: ../../library/functools.rst:695 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1331,7 +1338,7 @@ msgstr "" " def _(cls, arg: bool):\n" " return not arg" -#: ../../library/functools.rst:714 +#: ../../library/functools.rst:711 msgid "" "The same pattern can be used for other similar decorators: :deco:" "`staticmethod`, :deco:`~abc.abstractmethod`, and others." @@ -1339,6 +1346,10 @@ msgstr "" "相同的模式可用於其他類似的裝飾器::deco:`staticmethod`、:deco:`~abc." "abstractmethod` 等。" +#: ../../library/functools.rst:716 +msgid "Added support of non-:term:`descriptor` callables." +msgstr "" + #: ../../library/functools.rst:722 msgid "" "Update a *wrapper* function to look like the *wrapped* function. The " diff --git a/library/gc.po b/library/gc.po index c94ba0a6a4d..be347fc93e3 100644 --- a/library/gc.po +++ b/library/gc.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-04-27 00:28+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-04-24 21:25+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,7 +25,7 @@ msgstr "" msgid ":mod:`!gc` --- Garbage Collector interface" msgstr ":mod:`!gc` --- 垃圾回收器介面 (Garbage Collector interface)" -#: ../../library/gc.rst:12 +#: ../../library/gc.rst:9 msgid "" "This module provides an interface to the optional garbage collector. It " "provides the ability to disable the collector, tune the collection " @@ -46,23 +46,23 @@ msgstr "" "program) 除錯,請呼叫 ``gc.set_debug(gc.DEBUG_LEAK)``;需要注意的是,它包含 " "``gc.DEBUG_SAVEALL``,使得被回收的物件會被存放在 gc.garbage 中以待檢查。" -#: ../../library/gc.rst:23 +#: ../../library/gc.rst:20 msgid "The :mod:`!gc` module provides the following functions:" msgstr ":mod:`!gc` module 提供下列函式:" -#: ../../library/gc.rst:28 +#: ../../library/gc.rst:25 msgid "Enable automatic garbage collection." msgstr "啟用自動垃圾回收。" -#: ../../library/gc.rst:33 +#: ../../library/gc.rst:30 msgid "Disable automatic garbage collection." msgstr "停用自動垃圾回收。" -#: ../../library/gc.rst:38 +#: ../../library/gc.rst:35 msgid "Return ``True`` if automatic collection is enabled." msgstr "如果啟用了自動回收則回傳 ``True``。" -#: ../../library/gc.rst:43 +#: ../../library/gc.rst:40 msgid "" "With no arguments, run a full collection. The optional argument " "*generation* may be an integer specifying which generation to collect (from " @@ -73,7 +73,7 @@ msgstr "" "收哪一代垃圾的整數(從 0 到 2)。當 generation 數值無效時,會引發 :exc:" "`ValueError` 例外。可回收物件與不可回收物件的總和會被回傳。" -#: ../../library/gc.rst:48 +#: ../../library/gc.rst:45 msgid "" "The free lists maintained for a number of built-in types are cleared " "whenever a full collection or collection of the highest generation (2) is " @@ -84,21 +84,21 @@ msgstr "" "為了特定型別的實現,特別是 :class:`float`,在某些空閒列表中並非所有項目都會被" "釋放。" -#: ../../library/gc.rst:53 +#: ../../library/gc.rst:50 msgid "" "The effect of calling ``gc.collect()`` while the interpreter is already " "performing a collection is undefined." msgstr "當直譯器已經執行收集時呼叫 ``gc.collect()`` 的效果是未定義的。" -#: ../../library/gc.rst:56 +#: ../../library/gc.rst:53 msgid "``generation=1`` performs an increment of collection." msgstr "``generation=1`` 會執行增量收集。" -#: ../../library/gc.rst:59 +#: ../../library/gc.rst:56 msgid "``generation=1`` performs collection of the middle generation." msgstr "``generation=1`` 會執行中間代的回收。" -#: ../../library/gc.rst:65 +#: ../../library/gc.rst:62 msgid "" "Set the garbage collection debugging flags. Debugging information will be " "written to ``sys.stderr``. See below for a list of debugging flags which " @@ -107,11 +107,11 @@ msgstr "" "設定垃圾回收器的除錯旗標。除錯資訊會被寫入 ``sys.stderr``。請見下方的除錯旗標" "列表,可以使用位元操作 (bit operation) 進行設定以控制除錯程式。" -#: ../../library/gc.rst:72 +#: ../../library/gc.rst:69 msgid "Return the debugging flags currently set." msgstr "回傳目前設置的除錯旗標。" -#: ../../library/gc.rst:77 +#: ../../library/gc.rst:74 msgid "" "Returns a list of all objects tracked by the collector, excluding the list " "returned. If *generation* is not ``None``, return only the objects tracked " @@ -120,19 +120,19 @@ msgstr "" "回傳一個包含回收器正在追蹤的所有物件的 list,除去所回傳的 list。如果 " "*generation* 不為 ``None``,只回傳在該代中由回收器追蹤的物件。" -#: ../../library/gc.rst:81 +#: ../../library/gc.rst:78 msgid "New *generation* parameter." msgstr "新增 *generation* 參數。" -#: ../../library/gc.rst:84 +#: ../../library/gc.rst:81 msgid "Generation 1 is removed" msgstr "第一代已被刪除" -#: ../../library/gc.rst:87 +#: ../../library/gc.rst:84 msgid "Generation 1 is reintroduced to maintain GC behavior from 3.13." msgstr "" -#: ../../library/gc.rst:90 +#: ../../library/gc.rst:87 msgid "" "Raises an :ref:`auditing event ` ``gc.get_objects`` with argument " "``generation``." @@ -140,7 +140,7 @@ msgstr "" "引發一個附帶引數 ``generation`` 的\\ :ref:`稽核事件 (auditing event) " "` ``gc.get_objects``。" -#: ../../library/gc.rst:94 +#: ../../library/gc.rst:91 msgid "" "Return a list of three per-generation dictionaries containing collection " "statistics since interpreter start. The number of keys may change in the " @@ -150,32 +150,48 @@ msgstr "" "的垃圾回收統計資料。字典的鍵的數目在將來可能會改變,但目前每個字典包含以下項" "目:" -#: ../../library/gc.rst:99 +#: ../../library/gc.rst:96 msgid "``collections`` is the number of times this generation was collected;" msgstr "``collections`` 是該代被回收的次數;" -#: ../../library/gc.rst:101 +#: ../../library/gc.rst:98 msgid "" "``collected`` is the total number of objects collected inside this " "generation;" msgstr "``collected`` 是該代中被回收的物件總數;" -#: ../../library/gc.rst:104 +#: ../../library/gc.rst:101 msgid "" "``uncollectable`` is the total number of objects which were found to be " "uncollectable (and were therefore moved to the :data:`garbage` list) inside " -"this generation." +"this generation;" msgstr "" -"``uncollectable`` 是在這一代中被發現無法回收的物件總數(因此被移到 :data:" -"`garbage` list 中)。" +"``uncollectable`` 是在這一代中被發現無法回收的物件總數(因此被移" +"到 :data:`garbage` list 中);" + +#: ../../library/gc.rst:105 +msgid "" +"``candidates`` is the total number of objects in this generation which were " +"considered for collection and traversed;" +msgstr "``candidates`` 是該代中被考慮回收並被遍歷的物件總數;" + +#: ../../library/gc.rst:108 +msgid "" +"``duration`` is the total time in seconds spent in collections for this " +"generation." +msgstr "``duration`` 是該代花費在回收上的總時間(以秒為單位)。" #: ../../library/gc.rst:113 +msgid "Add ``duration`` and ``candidates``." +msgstr "" + +#: ../../library/gc.rst:119 msgid "" "Set the garbage collection thresholds (the collection frequency). Setting " "*threshold0* to zero disables collection." msgstr "設定垃圾回收閾值(回收頻率)。 將 *threshold0* 設為零會停止回收。" -#: ../../library/gc.rst:116 +#: ../../library/gc.rst:122 msgid "" "The GC classifies objects into three generations depending on how many " "collection sweeps they have survived. New objects are placed in the " @@ -205,47 +221,36 @@ msgstr "" "cpython/blob/ff0ef0a54bef26fc507fbf9b7a6009eb7d3f17f5/InternalDocs/" "garbage_collector.md#collecting-the-oldest-generation>`_ 來了解詳情。" -#: ../../library/gc.rst:130 +#: ../../library/gc.rst:136 msgid "" -"In the free-threaded build, the increase in process memory usage is also " -"checked before running the collector. If the memory usage has not increased " -"by 10% since the last collection and the net number of object allocations " -"has not exceeded 40 times *threshold0*, the collection is not run." -msgstr "" -"在自由執行緒建置 (free-threaded build) 中,在運行回收器之前還會檢查行程記憶體" -"使用量的增加。如果自上次回收以來記憶體使用量未增加 10%,且物件分配的淨數量未" -"超過 *threshold0* 的 40 倍,則不會運行回收。" - -#: ../../library/gc.rst:135 -msgid "" -"See `Garbage collector design `_ for more information." msgstr "" "有關更多資訊,請參閱\\ `垃圾回收器設計 `_。" +"blob/3.15/InternalDocs/garbage_collector.md>`_。" -#: ../../library/gc.rst:137 +#: ../../library/gc.rst:138 msgid "*threshold2* is ignored" msgstr "*threshold2* 會被忽略" -#: ../../library/gc.rst:140 +#: ../../library/gc.rst:141 msgid "*threshold2* is restored to match Python 3.13 behavior." msgstr "" -#: ../../library/gc.rst:146 +#: ../../library/gc.rst:147 msgid "" "Return the current collection counts as a tuple of ``(count0, count1, " "count2)``." msgstr "將目前回收計數以 ``(count0, count1, count2)`` 形式的 tuple 回傳。" -#: ../../library/gc.rst:152 +#: ../../library/gc.rst:153 msgid "" "Return the current collection thresholds as a tuple of ``(threshold0, " "threshold1, threshold2)``." msgstr "" "將目前回收閾值以 ``(threshold0, threshold1, threshold2)`` 形式的 tuple 回傳。" -#: ../../library/gc.rst:158 +#: ../../library/gc.rst:159 msgid "" "Return the list of objects that directly refer to any of objs. This function " "will only locate those containers which support garbage collection; " @@ -255,7 +260,7 @@ msgstr "" "回傳包含直接參照 objs 中任一個物件的物件 list。這個函式只定位支援垃圾回收的容" "器;參照了其它物件但不支援垃圾回收的擴充套件型別無法被找到。" -#: ../../library/gc.rst:163 +#: ../../library/gc.rst:164 msgid "" "Note that objects which have already been dereferenced, but which live in " "cycles and have not yet been collected by the garbage collector can be " @@ -266,7 +271,7 @@ msgstr "" "會被作為參照者出現在回傳的 list 中。若只要取得目前正在參照的物件,需要在呼" "叫 :func:`get_referrers` 之前呼叫 :func:`collect`。" -#: ../../library/gc.rst:169 +#: ../../library/gc.rst:170 msgid "" "Care must be taken when using objects returned by :func:`get_referrers` " "because some of them could still be under construction and hence in a " @@ -277,7 +282,7 @@ msgstr "" "在建構中而處於暫時無效的狀態。不要把 :func:`get_referrers` 用於除錯以外的其它" "目的。" -#: ../../library/gc.rst:174 +#: ../../library/gc.rst:175 msgid "" "Raises an :ref:`auditing event ` ``gc.get_referrers`` with " "argument ``objs``." @@ -285,7 +290,7 @@ msgstr "" "引發一個附帶引數 ``objs`` 的\\ :ref:`稽核事件 ` ``gc." "get_referrers``。" -#: ../../library/gc.rst:179 +#: ../../library/gc.rst:180 msgid "" "Return a list of objects directly referred to by any of the arguments. The " "referents returned are those objects visited by the arguments' C-level :c:" @@ -303,7 +308,7 @@ msgstr "" "此,可以有以下例子:一個整數對於一個引數是直接可達的,這個整數物件有可能出現" "或不出現在結果的 list 當中。" -#: ../../library/gc.rst:187 +#: ../../library/gc.rst:188 msgid "" "Raises an :ref:`auditing event ` ``gc.get_referents`` with " "argument ``objs``." @@ -311,7 +316,7 @@ msgstr "" "引發一個附帶引數 ``objs`` 的\\ :ref:`稽核事件 ` ``gc." "get_referents``。" -#: ../../library/gc.rst:191 +#: ../../library/gc.rst:192 msgid "" "Returns ``True`` if the object is currently tracked by the garbage " "collector, ``False`` otherwise. As a general rule, instances of atomic " @@ -325,7 +330,7 @@ msgstr "" "件)會被追蹤。然而,有一些特定型別最佳化會被用來減少垃圾回收器在簡單實例(如" "只含有原子性的鍵和值的字典)上的足跡: ::" -#: ../../library/gc.rst:198 +#: ../../library/gc.rst:199 msgid "" ">>> gc.is_tracked(0)\n" "False\n" @@ -349,14 +354,14 @@ msgstr "" ">>> gc.is_tracked({\"a\": 1})\n" "True" -#: ../../library/gc.rst:214 +#: ../../library/gc.rst:215 msgid "" "Returns ``True`` if the given object has been finalized by the garbage " "collector, ``False`` otherwise. ::" msgstr "" "如果給定物件已被垃圾回收器終結則回傳 ``True``,否則回傳 ``False``。: ::" -#: ../../library/gc.rst:217 +#: ../../library/gc.rst:218 msgid "" ">>> x = None\n" ">>> class Lazarus:\n" @@ -384,7 +389,7 @@ msgstr "" ">>> gc.is_finalized(x)\n" "True" -#: ../../library/gc.rst:235 +#: ../../library/gc.rst:236 msgid "" "Freeze all the objects tracked by the garbage collector; move them to a " "permanent generation and ignore them in all the future collections." @@ -392,7 +397,7 @@ msgstr "" "凍結 (freeze) 垃圾回收器所追蹤的所有物件;將它們移至永久代並忽略所有未來的收" "集動作。" -#: ../../library/gc.rst:238 +#: ../../library/gc.rst:239 msgid "" "If a process will ``fork()`` without ``exec()``, avoiding unnecessary copy-" "on-write in child processes will maximize memory sharing and reduce overall " @@ -410,23 +415,23 @@ msgstr "" "disable()``,在 ``fork()`` 之前呼叫 ``gc.freeze()``,並儘早在子行程中呼叫 " "``gc.enable()``。" -#: ../../library/gc.rst:252 +#: ../../library/gc.rst:253 msgid "" "Unfreeze the objects in the permanent generation, put them back into the " "oldest generation." msgstr "解凍 (unfreeze) 永久代中的物件,並將它們放回到最年老代中。" -#: ../../library/gc.rst:260 +#: ../../library/gc.rst:261 msgid "Return the number of objects in the permanent generation." msgstr "回傳永久代中的物件數量。" -#: ../../library/gc.rst:265 +#: ../../library/gc.rst:266 msgid "" "The following variables are provided for read-only access (you can mutate " "the values but should not rebind them):" msgstr "以下變數僅供唯讀存取(你可以修改其值但不應該重新繫結 (rebind) 它們):" -#: ../../library/gc.rst:270 +#: ../../library/gc.rst:271 msgid "" "A list of objects which the collector found to be unreachable but could not " "be freed (uncollectable objects). Starting with Python 3.4, this list " @@ -437,7 +442,7 @@ msgstr "" "開始,該 list 在大多數時候都應該是空的,除非使用了有非 ``NULL`` ``tp_del`` 槽" "位的 C 擴充套件型別的實例。" -#: ../../library/gc.rst:275 +#: ../../library/gc.rst:276 msgid "" "If :const:`DEBUG_SAVEALL` is set, then all unreachable objects will be added " "to this list rather than freed." @@ -445,7 +450,7 @@ msgstr "" "如果設定了 :const:`DEBUG_SAVEALL`,則所有不可達物件將被加進該 list 而不會被釋" "放。" -#: ../../library/gc.rst:278 +#: ../../library/gc.rst:279 msgid "" "If this list is non-empty at :term:`interpreter shutdown`, a :exc:" "`ResourceWarning` is emitted, which is silent by default. If :const:" @@ -456,7 +461,7 @@ msgstr "" "`ResourceWarning`,在預設情況下此警告不會被提醒。如果設定了 :const:" "`DEBUG_UNCOLLECTABLE`,所有無法被回收的物件會被印出。" -#: ../../library/gc.rst:284 +#: ../../library/gc.rst:285 msgid "" "Following :pep:`442`, objects with a :meth:`~object.__del__` method don't " "end up in :data:`gc.garbage` anymore." @@ -464,7 +469,7 @@ msgstr "" "根據 :pep:`442`,帶有 :meth:`~object.__del__` method 的物件最終不會在 :data:" "`gc.garbage` 內。" -#: ../../library/gc.rst:290 +#: ../../library/gc.rst:291 msgid "" "A list of callbacks that will be invoked by the garbage collector before and " "after collection. The callbacks will be called with two arguments, *phase* " @@ -473,29 +478,29 @@ msgstr "" "會被垃圾回收器在回收開始前和完成後叫用的一系列回呼函式 (callback) 。這些回呼" "函式在被呼叫時附帶兩個引數:*phase* 和 *info*。" -#: ../../library/gc.rst:294 +#: ../../library/gc.rst:295 msgid "*phase* can be one of two values:" msgstr "*phase* 可為以下兩者之一:" -#: ../../library/gc.rst:296 +#: ../../library/gc.rst:297 msgid "\"start\": The garbage collection is about to start." msgstr "\"start\":垃圾回收即將開始。" -#: ../../library/gc.rst:298 +#: ../../library/gc.rst:299 msgid "\"stop\": The garbage collection has finished." msgstr "\"stop\":垃圾回收已結束。" -#: ../../library/gc.rst:300 +#: ../../library/gc.rst:301 msgid "" "*info* is a dict providing more information for the callback. The following " "keys are currently defined:" msgstr "*info* 是一個字典,提供回呼函式更多資訊。已有定義的鍵有:" -#: ../../library/gc.rst:303 +#: ../../library/gc.rst:304 msgid "\"generation\": The oldest generation being collected." msgstr "\"generation\"(代):正在被回收的最年老的一代。" -#: ../../library/gc.rst:305 +#: ../../library/gc.rst:306 msgid "" "\"collected\": When *phase* is \"stop\", the number of objects successfully " "collected." @@ -503,7 +508,7 @@ msgstr "" "\"collected\"(已回收的):當 *phase* 為 \"stop\" 時,被成功回收的物件的數" "目。" -#: ../../library/gc.rst:308 +#: ../../library/gc.rst:309 msgid "" "\"uncollectable\": When *phase* is \"stop\", the number of objects that " "could not be collected and were put in :data:`garbage`." @@ -511,40 +516,60 @@ msgstr "" "\"uncollectable\"(不可回收的):當 *phase* 為 \"stop\" 時,不能被回收並被放" "入 :data:`garbage` 的物件的數目。" -#: ../../library/gc.rst:311 +#: ../../library/gc.rst:312 +msgid "" +"\"candidates\": When *phase* is \"stop\", the total number of objects in " +"this generation which were considered for collection and traversed." +msgstr "" +"\"candidates\"(候選的):當 *phase* 為 \"stop\" 時,該代中被考慮回收並被遍歷" +"的物件總數。" + +#: ../../library/gc.rst:315 +msgid "" +"\"duration\": When *phase* is \"stop\", the time in seconds spent in the " +"collection." +msgstr "" +"\"duration\"(持續時間):當 *phase* 為 \"stop\" 時,花費在該次回收上的時間" +"(以秒為單位)。" + +#: ../../library/gc.rst:318 msgid "" "Applications can add their own callbacks to this list. The primary use " "cases are:" msgstr "應用程式可以把他們自己的回呼函式加入此 list。主要的使用場景有:" -#: ../../library/gc.rst:314 +#: ../../library/gc.rst:321 msgid "" "Gathering statistics about garbage collection, such as how often various " "generations are collected, and how long the collection takes." msgstr "收集垃圾回收的統計資料,如:不同代的回收頻率、回收任務所花費的時間。" -#: ../../library/gc.rst:318 +#: ../../library/gc.rst:325 msgid "" "Allowing applications to identify and clear their own uncollectable types " "when they appear in :data:`garbage`." msgstr "" "讓應用程式可以識別和清理他們自己在 :data:`garbage` 中的不可回收型別物件。" -#: ../../library/gc.rst:324 +#: ../../library/gc.rst:330 +msgid "Add \"duration\" and \"candidates\"." +msgstr "" + +#: ../../library/gc.rst:334 msgid "The following constants are provided for use with :func:`set_debug`:" msgstr "以下常數是為了和 :func:`set_debug` 一起使用所提供:" -#: ../../library/gc.rst:329 +#: ../../library/gc.rst:339 msgid "" "Print statistics during collection. This information can be useful when " "tuning the collection frequency." msgstr "在回收完成後印出統計資訊。當調校回收頻率設定時,這些資訊會很有用。" -#: ../../library/gc.rst:335 +#: ../../library/gc.rst:345 msgid "Print information on collectable objects found." msgstr "當發現可回收物件時印出資訊。" -#: ../../library/gc.rst:340 +#: ../../library/gc.rst:350 msgid "" "Print information of uncollectable objects found (objects which are not " "reachable but cannot be freed by the collector). These objects will be " @@ -553,7 +578,7 @@ msgstr "" "印出找到的不可回收物件的資訊(指不能被回收器回收的不可達物件)。這些物件會被" "新增到 ``garbage`` list 中。" -#: ../../library/gc.rst:344 +#: ../../library/gc.rst:354 msgid "" "Also print the contents of the :data:`garbage` list at :term:`interpreter " "shutdown`, if it isn't empty." @@ -561,7 +586,7 @@ msgstr "" "當 :term:`interpreter shutdown`\\ (直譯器關閉)時,若 :data:`garbage` list " "不是空的,那這些內容也會被印出。" -#: ../../library/gc.rst:350 +#: ../../library/gc.rst:360 msgid "" "When set, all unreachable objects found will be appended to *garbage* rather " "than being freed. This can be useful for debugging a leaking program." @@ -569,7 +594,7 @@ msgstr "" "設定後,所有回收器找到的不可達物件會被加進 *garbage* 而不是直接被釋放。這在為" "一個記憶體流失的程式除錯時會很有用。" -#: ../../library/gc.rst:356 +#: ../../library/gc.rst:366 msgid "" "The debugging flags necessary for the collector to print information about a " "leaking program (equal to ``DEBUG_COLLECTABLE | DEBUG_UNCOLLECTABLE | " @@ -578,6 +603,17 @@ msgstr "" "要印出記憶體流失程式之相關資訊時,回收器所需的除錯旗標。(等同於 " "``DEBUG_COLLECTABLE | DEBUG_UNCOLLECTABLE | DEBUG_SAVEALL``)。" +#~ msgid "" +#~ "In the free-threaded build, the increase in process memory usage is also " +#~ "checked before running the collector. If the memory usage has not " +#~ "increased by 10% since the last collection and the net number of object " +#~ "allocations has not exceeded 40 times *threshold0*, the collection is not " +#~ "run." +#~ msgstr "" +#~ "在自由執行緒建置 (free-threaded build) 中,在運行回收器之前還會檢查行程記" +#~ "憶體使用量的增加。如果自上次回收以來記憶體使用量未增加 10%,且物件分配的淨" +#~ "數量未超過 *threshold0* 的 40 倍,則不會運行回收。" + #~ msgid "" #~ "Calling ``gc.collect(0)`` will perform a GC collection on the young " #~ "generation." diff --git a/library/getpass.po b/library/getpass.po index 9d280cfb651..b13f3ae3348 100644 --- a/library/getpass.po +++ b/library/getpass.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-02-11 12:04+0800\n" "Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,7 +23,7 @@ msgstr "" msgid ":mod:`!getpass` --- Portable password input" msgstr ":mod:`!getpass` --- 可攜式密碼輸入工具" -#: ../../library/getpass.rst:11 +#: ../../library/getpass.rst:7 msgid "**Source code:** :source:`Lib/getpass.py`" msgstr "**原始碼:**\\ :source:`Lib/getpass.py`" @@ -39,11 +39,11 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/getpass.rst:17 +#: ../../library/getpass.rst:13 msgid "The :mod:`!getpass` module provides two functions:" msgstr ":mod:`!getpass` 模組 (module) 提供了兩個函式:" -#: ../../library/getpass.rst:21 +#: ../../library/getpass.rst:17 msgid "" "Prompt the user for a password without echoing. The user is prompted using " "the string *prompt*, which defaults to ``'Password: '``. On Unix, the " @@ -58,7 +58,7 @@ msgstr "" "中。*stream* 預設為主控終端機 (controlling terminal) (\\ :file:`/dev/" "tty`\\ ),如果不可用則為 ``sys.stderr`` (此引數在 Windows 上會被忽略)。" -#: ../../library/getpass.rst:28 +#: ../../library/getpass.rst:24 msgid "" "The *echo_char* argument controls how user input is displayed while typing. " "If *echo_char* is ``None`` (default), input remains hidden. Otherwise, " @@ -67,7 +67,7 @@ msgid "" "asterisks instead of the actual input." msgstr "" -#: ../../library/getpass.rst:34 +#: ../../library/getpass.rst:30 msgid "" "If echo free input is unavailable getpass() falls back to printing a warning " "message to *stream* and reading from ``sys.stdin`` and issuing a :exc:" @@ -76,7 +76,7 @@ msgstr "" "如果無回音輸入 (echo-free input) 無法使用則 getpass() 將回退為印出一條警告訊" "息到 *stream*,並從 ``sys.stdin`` 讀取且同時發出 :exc:`GetPassWarning`。" -#: ../../library/getpass.rst:39 +#: ../../library/getpass.rst:35 msgid "" "If you call getpass from within IDLE, the input may be done in the terminal " "you launched IDLE from rather than the idle window itself." @@ -84,28 +84,68 @@ msgstr "" "如果你從 IDLE 內部呼叫 getpass,輸入可能會在你啟動 IDLE 的終端機中完成,而非" "在 IDLE 視窗中。" -#: ../../library/getpass.rst:43 +#: ../../library/getpass.rst:39 msgid "" "On Unix systems, when *echo_char* is set, the terminal will be configured to " "operate in :manpage:`noncanonical mode " -"`. In particular, this means " -"that line editing shortcuts such as :kbd:`Ctrl+U` will not work and may " -"insert unexpected characters into the input." +"`. Common terminal control " +"characters are supported:" +msgstr "" + +#: ../../library/getpass.rst:44 +msgid ":kbd:`Ctrl+A` - Move cursor to beginning of line" +msgstr "" + +#: ../../library/getpass.rst:45 +msgid ":kbd:`Ctrl+E` - Move cursor to end of line" +msgstr "" + +#: ../../library/getpass.rst:46 +msgid ":kbd:`Ctrl+K` - Kill (delete) from cursor to end of line" +msgstr "" + +#: ../../library/getpass.rst:47 +msgid ":kbd:`Ctrl+U` - Kill (delete) entire line" +msgstr "" + +#: ../../library/getpass.rst:48 +msgid ":kbd:`Ctrl+W` - Erase previous word" +msgstr "" + +#: ../../library/getpass.rst:49 +msgid ":kbd:`Ctrl+V` - Insert next character literally (quote)" msgstr "" #: ../../library/getpass.rst:50 -msgid "Added the *echo_char* parameter for keyboard feedback." +msgid ":kbd:`Backspace`/:kbd:`DEL` - Delete character before cursor" +msgstr "" + +#: ../../library/getpass.rst:52 +msgid "" +"These shortcuts work by reading the terminal's configured control character " +"mappings from termios settings." msgstr "" #: ../../library/getpass.rst:55 +msgid "Added the *echo_char* parameter for keyboard feedback." +msgstr "" + +#: ../../library/getpass.rst:58 +msgid "" +"When using non-empty *echo_char* on Unix, keyboard shortcuts (including " +"cursor movement and line editing) are now properly handled using the " +"terminal's control character configuration." +msgstr "" + +#: ../../library/getpass.rst:65 msgid "A :exc:`UserWarning` subclass issued when password input may be echoed." msgstr "當密碼輸入可能被回音時會發出的 :exc:`UserWarning` 子類別。" -#: ../../library/getpass.rst:60 +#: ../../library/getpass.rst:70 msgid "Return the \"login name\" of the user." msgstr "回傳使用者的\"登入名稱\"。" -#: ../../library/getpass.rst:62 +#: ../../library/getpass.rst:72 msgid "" "This function checks the environment variables :envvar:`LOGNAME`, :envvar:" "`USER`, :envvar:`!LNAME` and :envvar:`USERNAME`, in order, and returns the " @@ -118,10 +158,10 @@ msgstr "" "設定,則在支援 :mod:`pwd` 模組的系統上將會回傳來自密碼資料庫的登入名稱,否則" "將引發一個 :exc:`OSError` 例外。" -#: ../../library/getpass.rst:69 +#: ../../library/getpass.rst:79 msgid "In general, this function should be preferred over :func:`os.getlogin`." msgstr "大部分情況下,此函式應該要比 :func:`os.getlogin` 優先使用。" -#: ../../library/getpass.rst:71 +#: ../../library/getpass.rst:81 msgid "Previously, various exceptions beyond just :exc:`OSError` were raised." msgstr "在過去,除了 :exc:`OSError` 外還會引發各種例外。" diff --git a/library/gettext.po b/library/gettext.po index 068658e0fb3..8b489253cf2 100644 --- a/library/gettext.po +++ b/library/gettext.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:02+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!gettext` --- Multilingual internationalization services" msgstr ":mod:`!gettext` --- 多語言國際化服務" -#: ../../library/gettext.rst:10 +#: ../../library/gettext.rst:7 msgid "**Source code:** :source:`Lib/gettext.py`" msgstr "**原始碼:**\\ :source:`Lib/gettext.py`" -#: ../../library/gettext.rst:14 +#: ../../library/gettext.rst:11 msgid "" "The :mod:`!gettext` module provides internationalization (I18N) and " "localization (L10N) services for your Python modules and applications. It " @@ -36,16 +36,16 @@ msgid "" "messages for running under different natural languages." msgstr "" -#: ../../library/gettext.rst:22 +#: ../../library/gettext.rst:19 msgid "" "Some hints on localizing your Python modules and applications are also given." msgstr "" -#: ../../library/gettext.rst:26 +#: ../../library/gettext.rst:23 msgid "GNU :program:`gettext` API" msgstr "GNU :program:`gettext` API" -#: ../../library/gettext.rst:28 +#: ../../library/gettext.rst:25 msgid "" "The :mod:`!gettext` module defines the following API, which is very similar " "to the GNU :program:`gettext` API. If you use this API you will affect the " @@ -56,7 +56,7 @@ msgid "" "probably want to use the class-based API instead." msgstr "" -#: ../../library/gettext.rst:39 +#: ../../library/gettext.rst:36 msgid "" "Bind the *domain* to the locale directory *localedir*. More concretely, :" "mod:`!gettext` will look for binary :file:`.mo` files for the given domain " @@ -66,32 +66,32 @@ msgid "" "respectively." msgstr "" -#: ../../library/gettext.rst:45 +#: ../../library/gettext.rst:42 msgid "" "If *localedir* is omitted or ``None``, then the current binding for *domain* " "is returned. [#]_" msgstr "" -#: ../../library/gettext.rst:51 +#: ../../library/gettext.rst:48 msgid "" "Change or query the current global domain. If *domain* is ``None``, then " "the current global domain is returned, otherwise the global domain is set to " "*domain*, which is returned." msgstr "" -#: ../../library/gettext.rst:59 +#: ../../library/gettext.rst:56 msgid "" "Return the localized translation of *message*, based on the current global " "domain, language, and locale directory. This function is usually aliased " "as :func:`!_` in the local namespace (see examples below)." msgstr "" -#: ../../library/gettext.rst:66 +#: ../../library/gettext.rst:63 msgid "" "Like :func:`.gettext`, but look the message up in the specified *domain*." msgstr "" -#: ../../library/gettext.rst:71 +#: ../../library/gettext.rst:68 msgid "" "Like :func:`.gettext`, but consider plural forms. If a translation is found, " "apply the plural formula to *n*, and return the resulting message (some " @@ -99,7 +99,7 @@ msgid "" "return *singular* if *n* is 1; return *plural* otherwise." msgstr "" -#: ../../library/gettext.rst:76 +#: ../../library/gettext.rst:73 msgid "" "The Plural formula is taken from the catalog header. It is a C or Python " "expression that has a free variable *n*; the expression evaluates to the " @@ -109,29 +109,29 @@ msgid "" "variety of languages." msgstr "" -#: ../../library/gettext.rst:86 +#: ../../library/gettext.rst:83 msgid "" "Like :func:`ngettext`, but look the message up in the specified *domain*." msgstr "" -#: ../../library/gettext.rst:94 +#: ../../library/gettext.rst:91 msgid "" "Similar to the corresponding functions without the ``p`` in the prefix (that " "is, :func:`gettext`, :func:`dgettext`, :func:`ngettext`, :func:`dngettext`), " "but the translation is restricted to the given message *context*." msgstr "" -#: ../../library/gettext.rst:101 +#: ../../library/gettext.rst:98 msgid "" "Note that GNU :program:`gettext` also defines a :func:`!dcgettext` method, " "but this was deemed not useful and so it is currently unimplemented." msgstr "" -#: ../../library/gettext.rst:104 +#: ../../library/gettext.rst:101 msgid "Here's an example of typical usage for this API::" msgstr "" -#: ../../library/gettext.rst:106 +#: ../../library/gettext.rst:103 msgid "" "import gettext\n" "gettext.bindtextdomain('myapplication', '/path/to/my/language/directory')\n" @@ -147,11 +147,11 @@ msgstr "" "# ...\n" "print(_('This is a translatable string.'))" -#: ../../library/gettext.rst:115 +#: ../../library/gettext.rst:112 msgid "Class-based API" msgstr "" -#: ../../library/gettext.rst:117 +#: ../../library/gettext.rst:114 msgid "" "The class-based API of the :mod:`!gettext` module gives you more flexibility " "and greater convenience than the GNU :program:`gettext` API. It is the " @@ -162,7 +162,7 @@ msgid "" "namespace as the function :func:`!_`." msgstr "" -#: ../../library/gettext.rst:127 +#: ../../library/gettext.rst:124 msgid "" "This function implements the standard :file:`.mo` file search algorithm. It " "takes a *domain*, identical to what :func:`textdomain` takes. Optional " @@ -170,7 +170,7 @@ msgid "" "of strings, where each string is a language code." msgstr "" -#: ../../library/gettext.rst:132 +#: ../../library/gettext.rst:129 msgid "" "If *localedir* is not given, then the default system locale directory is " "used. [#]_ If *languages* is not given, then the following environment " @@ -181,17 +181,17 @@ msgid "" "colon to produce the expected list of language code strings." msgstr "" -#: ../../library/gettext.rst:140 +#: ../../library/gettext.rst:137 msgid "" ":func:`find` then expands and normalizes the languages, and then iterates " "through them, searching for an existing file built of these components:" msgstr "" -#: ../../library/gettext.rst:143 +#: ../../library/gettext.rst:140 msgid ":file:`{localedir}/{language}/LC_MESSAGES/{domain}.mo`" msgstr ":file:`{localedir}/{language}/LC_MESSAGES/{domain}.mo`" -#: ../../library/gettext.rst:145 +#: ../../library/gettext.rst:142 msgid "" "The first such file name that exists is returned by :func:`find`. If no such " "file is found, then ``None`` is returned. If *all* is given, it returns a " @@ -199,7 +199,7 @@ msgid "" "list or the environment variables." msgstr "" -#: ../../library/gettext.rst:153 +#: ../../library/gettext.rst:150 msgid "" "Return a ``*Translations`` instance based on the *domain*, *localedir*, and " "*languages*, which are first passed to :func:`find` to get a list of the " @@ -209,7 +209,7 @@ msgid "" "take a single :term:`file object` argument." msgstr "" -#: ../../library/gettext.rst:160 +#: ../../library/gettext.rst:157 msgid "" "If multiple files are found, later files are used as fallbacks for earlier " "ones. To allow setting the fallback, :func:`copy.copy` is used to clone each " @@ -217,61 +217,61 @@ msgid "" "with the cache." msgstr "" -#: ../../library/gettext.rst:165 +#: ../../library/gettext.rst:162 msgid "" "If no :file:`.mo` file is found, this function raises :exc:`OSError` if " "*fallback* is false (which is the default), and returns a :class:" "`NullTranslations` instance if *fallback* is true." msgstr "" -#: ../../library/gettext.rst:169 +#: ../../library/gettext.rst:166 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." msgstr ":exc:`IOError` 曾經被引發,現在它是一個 :exc:`OSError` 的別名。" -#: ../../library/gettext.rst:172 +#: ../../library/gettext.rst:169 msgid "*codeset* parameter is removed." msgstr "*codeset* 參數被移除。" -#: ../../library/gettext.rst:177 +#: ../../library/gettext.rst:174 msgid "" "This installs the function :func:`!_` in Python's builtins namespace, based " "on *domain* and *localedir* which are passed to the function :func:" "`translation`." msgstr "" -#: ../../library/gettext.rst:180 +#: ../../library/gettext.rst:177 msgid "" "For the *names* parameter, please see the description of the translation " "object's :meth:`~NullTranslations.install` method." msgstr "" -#: ../../library/gettext.rst:183 +#: ../../library/gettext.rst:180 msgid "" "As seen below, you usually mark the strings in your application that are " "candidates for translation, by wrapping them in a call to the :func:`!_` " "function, like this::" msgstr "" -#: ../../library/gettext.rst:187 +#: ../../library/gettext.rst:184 msgid "print(_('This string will be translated.'))" msgstr "print(_('This string will be translated.'))" -#: ../../library/gettext.rst:189 +#: ../../library/gettext.rst:186 msgid "" "For convenience, you want the :func:`!_` function to be installed in " "Python's builtins namespace, so it is easily accessible in all modules of " "your application." msgstr "" -#: ../../library/gettext.rst:193 +#: ../../library/gettext.rst:190 msgid "*names* is now a keyword-only parameter." msgstr "" -#: ../../library/gettext.rst:197 +#: ../../library/gettext.rst:194 msgid "The :class:`NullTranslations` class" msgstr "" -#: ../../library/gettext.rst:199 +#: ../../library/gettext.rst:196 msgid "" "Translation classes are what actually implement the translation of original " "source file message strings to translated message strings. The base class " @@ -280,7 +280,7 @@ msgid "" "classes. Here are the methods of :class:`!NullTranslations`:" msgstr "" -#: ../../library/gettext.rst:208 +#: ../../library/gettext.rst:205 msgid "" "Takes an optional :term:`file object` *fp*, which is ignored by the base " "class. Initializes \"protected\" instance variables *_info* and *_charset* " @@ -289,7 +289,7 @@ msgid "" "not ``None``." msgstr "" -#: ../../library/gettext.rst:216 +#: ../../library/gettext.rst:213 msgid "" "No-op in the base class, this method takes file object *fp*, and reads the " "data from the file, initializing its message catalog. If you have an " @@ -297,55 +297,55 @@ msgid "" "parse your format." msgstr "" -#: ../../library/gettext.rst:224 +#: ../../library/gettext.rst:221 msgid "" "Add *fallback* as the fallback object for the current translation object. A " "translation object should consult the fallback if it cannot provide a " "translation for a given message." msgstr "" -#: ../../library/gettext.rst:231 +#: ../../library/gettext.rst:228 msgid "" "If a fallback has been set, forward :meth:`!gettext` to the fallback. " "Otherwise, return *message*. Overridden in derived classes." msgstr "" -#: ../../library/gettext.rst:237 +#: ../../library/gettext.rst:234 msgid "" "If a fallback has been set, forward :meth:`!ngettext` to the fallback. " "Otherwise, return *singular* if *n* is 1; return *plural* otherwise. " "Overridden in derived classes." msgstr "" -#: ../../library/gettext.rst:244 +#: ../../library/gettext.rst:241 msgid "" "If a fallback has been set, forward :meth:`pgettext` to the fallback. " "Otherwise, return the translated message. Overridden in derived classes." msgstr "" -#: ../../library/gettext.rst:252 +#: ../../library/gettext.rst:249 msgid "" "If a fallback has been set, forward :meth:`npgettext` to the fallback. " "Otherwise, return the translated message. Overridden in derived classes." msgstr "" -#: ../../library/gettext.rst:260 +#: ../../library/gettext.rst:257 msgid "" "Return a dictionary containing the metadata found in the message catalog " "file." msgstr "" -#: ../../library/gettext.rst:266 +#: ../../library/gettext.rst:263 msgid "Return the encoding of the message catalog file." msgstr "" -#: ../../library/gettext.rst:271 +#: ../../library/gettext.rst:268 msgid "" "This method installs :meth:`.gettext` into the built-in namespace, binding " "it to ``_``." msgstr "" -#: ../../library/gettext.rst:274 +#: ../../library/gettext.rst:271 msgid "" "If the *names* parameter is given, it must be a sequence containing the " "names of functions you want to install in the builtins namespace in addition " @@ -353,7 +353,7 @@ msgid "" "``'pgettext'``, and ``'npgettext'``." msgstr "" -#: ../../library/gettext.rst:279 +#: ../../library/gettext.rst:276 msgid "" "Note that this is only one way, albeit the most convenient way, to make the :" "func:`!_` function available to your application. Because it affects the " @@ -362,7 +362,7 @@ msgid "" "this code to make :func:`!_` available to their module::" msgstr "" -#: ../../library/gettext.rst:285 +#: ../../library/gettext.rst:282 msgid "" "import gettext\n" "t = gettext.translation('mymodule', ...)\n" @@ -372,21 +372,21 @@ msgstr "" "t = gettext.translation('mymodule', ...)\n" "_ = t.gettext" -#: ../../library/gettext.rst:289 +#: ../../library/gettext.rst:286 msgid "" "This puts :func:`!_` only in the module's global namespace and so only " "affects calls within this module." msgstr "" -#: ../../library/gettext.rst:292 +#: ../../library/gettext.rst:289 msgid "Added ``'pgettext'`` and ``'npgettext'``." msgstr "新增 ``'pgettext'`` 與 ``'npgettext'``。" -#: ../../library/gettext.rst:297 +#: ../../library/gettext.rst:294 msgid "The :class:`GNUTranslations` class" msgstr "" -#: ../../library/gettext.rst:299 +#: ../../library/gettext.rst:296 msgid "" "The :mod:`!gettext` module provides one additional class derived from :class:" "`NullTranslations`: :class:`GNUTranslations`. This class overrides :meth:`!" @@ -394,7 +394,7 @@ msgid "" "both big-endian and little-endian format." msgstr "" -#: ../../library/gettext.rst:304 +#: ../../library/gettext.rst:301 msgid "" ":class:`GNUTranslations` parses optional metadata out of the translation " "catalog. It is convention with GNU :program:`gettext` to include metadata as " @@ -407,31 +407,31 @@ msgid "" "to Unicode using this encoding, else ASCII is assumed." msgstr "" -#: ../../library/gettext.rst:314 +#: ../../library/gettext.rst:311 msgid "" "Since message ids are read as Unicode strings too, all ``*gettext()`` " "methods will assume message ids as Unicode strings, not byte strings." msgstr "" -#: ../../library/gettext.rst:317 +#: ../../library/gettext.rst:314 msgid "" "The entire set of key/value pairs are placed into a dictionary and set as " "the \"protected\" :attr:`!_info` instance variable." msgstr "" -#: ../../library/gettext.rst:320 +#: ../../library/gettext.rst:317 msgid "" "If the :file:`.mo` file's magic number is invalid, the major version number " "is unexpected, or if other problems occur while reading the file, " "instantiating a :class:`GNUTranslations` class can raise :exc:`OSError`." msgstr "" -#: ../../library/gettext.rst:326 +#: ../../library/gettext.rst:323 msgid "" "The following methods are overridden from the base class implementation:" msgstr "" -#: ../../library/gettext.rst:330 +#: ../../library/gettext.rst:327 msgid "" "Look up the *message* id in the catalog and return the corresponding message " "string, as a Unicode string. If there is no entry in the catalog for the " @@ -440,14 +440,14 @@ msgid "" "*message* id is returned." msgstr "" -#: ../../library/gettext.rst:339 +#: ../../library/gettext.rst:336 msgid "" "Do a plural-forms lookup of a message id. *singular* is used as the message " "id for purposes of lookup in the catalog, while *n* is used to determine " "which plural form to use. The returned message string is a Unicode string." msgstr "" -#: ../../library/gettext.rst:343 +#: ../../library/gettext.rst:340 msgid "" "If the message id is not found in the catalog, and a fallback is specified, " "the request is forwarded to the fallback's :meth:`~NullTranslations." @@ -455,11 +455,11 @@ msgid "" "*plural* is returned in all other cases." msgstr "" -#: ../../library/gettext.rst:348 +#: ../../library/gettext.rst:345 msgid "Here is an example::" msgstr "以下是個範例: ::" -#: ../../library/gettext.rst:350 +#: ../../library/gettext.rst:347 msgid "" "n = len(os.listdir('.'))\n" "cat = GNUTranslations(somefile)\n" @@ -475,7 +475,7 @@ msgstr "" " 'There are %(num)d files in this directory',\n" " n) % {'num': n}" -#: ../../library/gettext.rst:360 +#: ../../library/gettext.rst:357 msgid "" "Look up the *context* and *message* id in the catalog and return the " "corresponding message string, as a Unicode string. If there is no entry in " @@ -484,14 +484,14 @@ msgid "" "Otherwise, the *message* id is returned." msgstr "" -#: ../../library/gettext.rst:371 +#: ../../library/gettext.rst:368 msgid "" "Do a plural-forms lookup of a message id. *singular* is used as the message " "id for purposes of lookup in the catalog, while *n* is used to determine " "which plural form to use." msgstr "" -#: ../../library/gettext.rst:375 +#: ../../library/gettext.rst:372 msgid "" "If the message id for *context* is not found in the catalog, and a fallback " "is specified, the request is forwarded to the fallback's :meth:`npgettext` " @@ -499,28 +499,28 @@ msgid "" "returned in all other cases." msgstr "" -#: ../../library/gettext.rst:384 +#: ../../library/gettext.rst:381 msgid "Solaris message catalog support" msgstr "" -#: ../../library/gettext.rst:386 +#: ../../library/gettext.rst:383 msgid "" "The Solaris operating system defines its own binary :file:`.mo` file format, " "but since no documentation can be found on this format, it is not supported " "at this time." msgstr "" -#: ../../library/gettext.rst:392 +#: ../../library/gettext.rst:389 msgid "The Catalog constructor" msgstr "" -#: ../../library/gettext.rst:396 +#: ../../library/gettext.rst:393 msgid "" "GNOME uses a version of the :mod:`!gettext` module by James Henstridge, but " "this version has a slightly different API. Its documented usage was::" msgstr "" -#: ../../library/gettext.rst:399 +#: ../../library/gettext.rst:396 msgid "" "import gettext\n" "cat = gettext.Catalog(domain, localedir)\n" @@ -532,24 +532,24 @@ msgstr "" "_ = cat.gettext\n" "print(_('hello world'))" -#: ../../library/gettext.rst:404 +#: ../../library/gettext.rst:401 msgid "" "For compatibility with this older module, the function :func:`!Catalog` is " "an alias for the :func:`translation` function described above." msgstr "" -#: ../../library/gettext.rst:407 +#: ../../library/gettext.rst:404 msgid "" "One difference between this module and Henstridge's: his catalog objects " "supported access through a mapping API, but this appears to be unused and so " "is not currently supported." msgstr "" -#: ../../library/gettext.rst:414 +#: ../../library/gettext.rst:411 msgid "Internationalizing your programs and modules" msgstr "" -#: ../../library/gettext.rst:416 +#: ../../library/gettext.rst:413 msgid "" "Internationalization (I18N) refers to the operation by which a program is " "made aware of multiple languages. Localization (L10N) refers to the " @@ -558,27 +558,27 @@ msgid "" "Python programs, you need to take the following steps:" msgstr "" -#: ../../library/gettext.rst:422 +#: ../../library/gettext.rst:419 msgid "" "prepare your program or module by specially marking translatable strings" msgstr "" -#: ../../library/gettext.rst:424 +#: ../../library/gettext.rst:421 msgid "" "run a suite of tools over your marked files to generate raw messages catalogs" msgstr "" -#: ../../library/gettext.rst:426 +#: ../../library/gettext.rst:423 msgid "create language-specific translations of the message catalogs" msgstr "" -#: ../../library/gettext.rst:428 +#: ../../library/gettext.rst:425 msgid "" "use the :mod:`!gettext` module so that message strings are properly " "translated" msgstr "" -#: ../../library/gettext.rst:430 +#: ../../library/gettext.rst:427 msgid "" "In order to prepare your code for I18N, you need to look at all the strings " "in your files. Any string that needs to be translated should be marked by " @@ -586,7 +586,7 @@ msgid "" "`. For example::" msgstr "" -#: ../../library/gettext.rst:434 +#: ../../library/gettext.rst:431 msgid "" "filename = 'mylog.txt'\n" "message = _('writing a log message')\n" @@ -598,14 +598,14 @@ msgstr "" "with open(filename, 'w') as fp:\n" " fp.write(message)" -#: ../../library/gettext.rst:439 +#: ../../library/gettext.rst:436 msgid "" "In this example, the string ``'writing a log message'`` is marked as a " "candidate for translation, while the strings ``'mylog.txt'`` and ``'w'`` are " "not." msgstr "" -#: ../../library/gettext.rst:442 +#: ../../library/gettext.rst:439 msgid "" "There are a few tools to extract the strings meant for translation. The " "original GNU :program:`gettext` only supported C or C++ source code but its " @@ -618,7 +618,7 @@ msgid "" "utils>`__." msgstr "" -#: ../../library/gettext.rst:452 +#: ../../library/gettext.rst:449 msgid "" "(Python also includes pure-Python versions of these programs, called :" "program:`pygettext.py` and :program:`msgfmt.py`; some Python distributions " @@ -631,7 +631,7 @@ msgid "" "GNU :program:`gettext` package to internationalize your Python applications.)" msgstr "" -#: ../../library/gettext.rst:464 +#: ../../library/gettext.rst:461 msgid "" ":program:`xgettext`, :program:`pygettext`, and similar tools generate :file:" "`.po` files that are message catalogs. They are structured human-readable " @@ -639,7 +639,7 @@ msgid "" "placeholder for the translated versions of these strings." msgstr "" -#: ../../library/gettext.rst:470 +#: ../../library/gettext.rst:467 msgid "" "Copies of these :file:`.po` files are then handed over to the individual " "human translators who write translations for every supported natural " @@ -650,25 +650,25 @@ msgid "" "processing at run-time." msgstr "" -#: ../../library/gettext.rst:479 +#: ../../library/gettext.rst:476 msgid "" "How you use the :mod:`!gettext` module in your code depends on whether you " "are internationalizing a single module or your entire application. The next " "two sections will discuss each case." msgstr "" -#: ../../library/gettext.rst:485 +#: ../../library/gettext.rst:482 msgid "Localizing your module" msgstr "" -#: ../../library/gettext.rst:487 +#: ../../library/gettext.rst:484 msgid "" "If you are localizing your module, you must take care not to make global " "changes, e.g. to the built-in namespace. You should not use the GNU :program:" "`gettext` API but instead the class-based API." msgstr "" -#: ../../library/gettext.rst:491 +#: ../../library/gettext.rst:488 msgid "" "Let's say your module is called \"spam\" and the module's various natural " "language translation :file:`.mo` files reside in :file:`/usr/share/locale` " @@ -676,7 +676,7 @@ msgid "" "your module::" msgstr "" -#: ../../library/gettext.rst:496 +#: ../../library/gettext.rst:493 msgid "" "import gettext\n" "t = gettext.translation('spam', '/usr/share/locale')\n" @@ -686,11 +686,11 @@ msgstr "" "t = gettext.translation('spam', '/usr/share/locale')\n" "_ = t.gettext" -#: ../../library/gettext.rst:502 +#: ../../library/gettext.rst:499 msgid "Localizing your application" msgstr "" -#: ../../library/gettext.rst:504 +#: ../../library/gettext.rst:501 msgid "" "If you are localizing your application, you can install the :func:`!_` " "function globally into the built-in namespace, usually in the main driver " @@ -698,13 +698,13 @@ msgid "" "just use ``_('...')`` without having to explicitly install it in each file." msgstr "" -#: ../../library/gettext.rst:509 +#: ../../library/gettext.rst:506 msgid "" "In the simple case then, you need only add the following bit of code to the " "main driver file of your application::" msgstr "" -#: ../../library/gettext.rst:512 +#: ../../library/gettext.rst:509 msgid "" "import gettext\n" "gettext.install('myapplication')" @@ -712,13 +712,13 @@ msgstr "" "import gettext\n" "gettext.install('myapplication')" -#: ../../library/gettext.rst:515 +#: ../../library/gettext.rst:512 msgid "" "If you need to set the locale directory, you can pass it into the :func:" "`install` function::" msgstr "" -#: ../../library/gettext.rst:518 +#: ../../library/gettext.rst:515 msgid "" "import gettext\n" "gettext.install('myapplication', '/usr/share/locale')" @@ -726,18 +726,18 @@ msgstr "" "import gettext\n" "gettext.install('myapplication', '/usr/share/locale')" -#: ../../library/gettext.rst:523 +#: ../../library/gettext.rst:520 msgid "Changing languages on the fly" msgstr "" -#: ../../library/gettext.rst:525 +#: ../../library/gettext.rst:522 msgid "" "If your program needs to support many languages at the same time, you may " "want to create multiple translation instances and then switch between them " "explicitly, like so::" msgstr "" -#: ../../library/gettext.rst:529 +#: ../../library/gettext.rst:526 msgid "" "import gettext\n" "\n" @@ -755,18 +755,18 @@ msgid "" "lang3.install()" msgstr "" -#: ../../library/gettext.rst:546 +#: ../../library/gettext.rst:543 msgid "Deferred translations" msgstr "" -#: ../../library/gettext.rst:548 +#: ../../library/gettext.rst:545 msgid "" "In most coding situations, strings are translated where they are coded. " "Occasionally however, you need to mark strings for translation, but defer " "actual translation until later. A classic example is::" msgstr "" -#: ../../library/gettext.rst:552 +#: ../../library/gettext.rst:549 msgid "" "animals = ['mollusk',\n" " 'albatross',\n" @@ -786,18 +786,18 @@ msgstr "" "for a in animals:\n" " print(a)" -#: ../../library/gettext.rst:561 +#: ../../library/gettext.rst:558 msgid "" "Here, you want to mark the strings in the ``animals`` list as being " "translatable, but you don't actually want to translate them until they are " "printed." msgstr "" -#: ../../library/gettext.rst:565 +#: ../../library/gettext.rst:562 msgid "Here is one way you can handle this situation::" msgstr "" -#: ../../library/gettext.rst:567 +#: ../../library/gettext.rst:564 msgid "" "def _(message): return message\n" "\n" @@ -827,7 +827,7 @@ msgstr "" "for a in animals:\n" " print(_(a))" -#: ../../library/gettext.rst:581 +#: ../../library/gettext.rst:578 msgid "" "This works because the dummy definition of :func:`!_` simply returns the " "string unchanged. And this dummy definition will temporarily override any " @@ -836,18 +836,18 @@ msgid "" "in the local namespace." msgstr "" -#: ../../library/gettext.rst:587 +#: ../../library/gettext.rst:584 msgid "" "Note that the second use of :func:`!_` will not identify \"a\" as being " "translatable to the :program:`gettext` program, because the parameter is not " "a string literal." msgstr "" -#: ../../library/gettext.rst:591 +#: ../../library/gettext.rst:588 msgid "Another way to handle this is with the following example::" msgstr "" -#: ../../library/gettext.rst:593 +#: ../../library/gettext.rst:590 msgid "" "def N_(message): return message\n" "\n" @@ -873,7 +873,7 @@ msgstr "" "for a in animals:\n" " print(_(a))" -#: ../../library/gettext.rst:605 +#: ../../library/gettext.rst:602 msgid "" "In this case, you are marking translatable strings with the function :func:`!" "N_`, which won't conflict with any definition of :func:`!_`. However, you " @@ -885,54 +885,54 @@ msgid "" "MarkThisStringForTranslation`." msgstr "" -#: ../../library/gettext.rst:616 +#: ../../library/gettext.rst:613 msgid "Acknowledgements" msgstr "致謝" -#: ../../library/gettext.rst:618 +#: ../../library/gettext.rst:615 msgid "" "The following people contributed code, feedback, design suggestions, " "previous implementations, and valuable experience to the creation of this " "module:" msgstr "" -#: ../../library/gettext.rst:621 +#: ../../library/gettext.rst:618 msgid "Peter Funk" msgstr "Peter Funk" -#: ../../library/gettext.rst:623 +#: ../../library/gettext.rst:620 msgid "James Henstridge" msgstr "James Henstridge" -#: ../../library/gettext.rst:625 +#: ../../library/gettext.rst:622 msgid "Juan David Ibáñez Palomar" msgstr "Juan David Ibáñez Palomar" -#: ../../library/gettext.rst:627 +#: ../../library/gettext.rst:624 msgid "Marc-André Lemburg" msgstr "Marc-André Lemburg" -#: ../../library/gettext.rst:629 +#: ../../library/gettext.rst:626 msgid "Martin von Löwis" msgstr "Martin von Löwis" -#: ../../library/gettext.rst:631 +#: ../../library/gettext.rst:628 msgid "François Pinard" msgstr "François Pinard" -#: ../../library/gettext.rst:633 +#: ../../library/gettext.rst:630 msgid "Barry Warsaw" msgstr "Barry Warsaw" -#: ../../library/gettext.rst:635 +#: ../../library/gettext.rst:632 msgid "Gustavo Niemeyer" msgstr "Gustavo Niemeyer" -#: ../../library/gettext.rst:638 +#: ../../library/gettext.rst:635 msgid "Footnotes" msgstr "註解" -#: ../../library/gettext.rst:639 +#: ../../library/gettext.rst:636 msgid "" "The default locale directory is system dependent; for example, on Red Hat " "Linux it is :file:`/usr/share/locale`, but on Solaris it is :file:`/usr/lib/" @@ -943,18 +943,18 @@ msgid "" "your application." msgstr "" -#: ../../library/gettext.rst:647 +#: ../../library/gettext.rst:644 msgid "See the footnote for :func:`bindtextdomain` above." msgstr "請見上方 :func:`bindtextdomain` 之註解。" -#: ../../library/gettext.rst:56 +#: ../../library/gettext.rst:53 msgid "_ (underscore)" msgstr "_ (底線)" -#: ../../library/gettext.rst:56 +#: ../../library/gettext.rst:53 msgid "gettext" msgstr "gettext" -#: ../../library/gettext.rst:394 +#: ../../library/gettext.rst:391 msgid "GNOME" msgstr "GNOME" diff --git a/library/glob.po b/library/glob.po index 458465f4cd3..f1203284877 100644 --- a/library/glob.po +++ b/library/glob.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-07 00:35+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-01-24 01:21+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -194,49 +194,50 @@ msgstr "" #: ../../library/glob.rst:143 msgid "" "Convert the given path specification to a regular expression for use with :" -"func:`re.match`. The path specification can contain shell-style wildcards." +"func:`re.prefixmatch`. The path specification can contain shell-style " +"wildcards." msgstr "" -#: ../../library/glob.rst:146 +#: ../../library/glob.rst:147 msgid "For example:" msgstr "舉例來說:" -#: ../../library/glob.rst:157 +#: ../../library/glob.rst:158 msgid "" "Path separators and segments are meaningful to this function, unlike :func:" "`fnmatch.translate`. By default wildcards do not match path separators, and " "``*`` pattern segments match precisely one path segment." msgstr "" -#: ../../library/glob.rst:161 +#: ../../library/glob.rst:162 msgid "" "If *recursive* is true, the pattern segment \"``**``\" will match any number " "of path segments." msgstr "" -#: ../../library/glob.rst:164 +#: ../../library/glob.rst:165 msgid "" "If *include_hidden* is true, wildcards can match path segments that start " "with a dot (``.``)." msgstr "" -#: ../../library/glob.rst:167 +#: ../../library/glob.rst:168 msgid "" "A sequence of path separators may be supplied to the *seps* argument. If not " "given, :data:`os.sep` and :data:`~os.altsep` (if available) are used." msgstr "" -#: ../../library/glob.rst:172 +#: ../../library/glob.rst:173 msgid "" ":meth:`pathlib.PurePath.full_match` and :meth:`pathlib.Path.glob` methods, " "which call this function to implement pattern matching and globbing." msgstr "" -#: ../../library/glob.rst:180 +#: ../../library/glob.rst:181 msgid "Examples" msgstr "範例" -#: ../../library/glob.rst:182 +#: ../../library/glob.rst:183 msgid "" "Consider a directory containing the following files: :file:`1.gif`, :file:`2." "txt`, :file:`card.gif` and a subdirectory :file:`sub` which contains only " @@ -247,7 +248,7 @@ msgstr "" "gif`,和一個僅包含 :file:`3.txt` 檔案的子目錄 :file:`sub`,:func:`glob` 將產" "生以下結果。請注意路徑的任何前導部分是如何保留的。 ::" -#: ../../library/glob.rst:188 +#: ../../library/glob.rst:189 msgid "" ">>> import glob\n" ">>> glob.glob('./[0-9].*')\n" @@ -273,7 +274,7 @@ msgstr "" ">>> glob.glob('./**/', recursive=True)\n" "['./', './sub/']" -#: ../../library/glob.rst:200 +#: ../../library/glob.rst:201 msgid "" "If the directory contains files starting with ``.`` they won't be matched by " "default. For example, consider a directory containing :file:`card.gif` and :" @@ -282,7 +283,7 @@ msgstr "" "如果目錄包含以 ``.`` 開頭的檔案,則預設情況下不會去匹配到它們。例如,一個包" "含 :file:`card.gif` 和 :file:`.card.gif` 的目錄: ::" -#: ../../library/glob.rst:204 +#: ../../library/glob.rst:205 msgid "" ">>> import glob\n" ">>> glob.glob('*.gif')\n" @@ -296,12 +297,12 @@ msgstr "" ">>> glob.glob('.c*')\n" "['.card.gif']" -#: ../../library/glob.rst:211 +#: ../../library/glob.rst:212 msgid "" "The :mod:`fnmatch` module offers shell-style filename (not path) expansion." msgstr ":mod:`fnmatch` 模組提供了 shell 風格檔案名(不是路徑)的擴展" -#: ../../library/glob.rst:214 +#: ../../library/glob.rst:215 msgid "The :mod:`pathlib` module offers high-level path objects." msgstr ":mod:`pathlib` 模組提供高階路徑物件。" diff --git a/library/gzip.po b/library/gzip.po index 706115d1f9e..e2e1a40eb74 100644 --- a/library/gzip.po +++ b/library/gzip.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:03+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -113,18 +113,26 @@ msgstr "" msgid "Added support for the ``'x'``, ``'xb'`` and ``'xt'`` modes." msgstr "新增 ``'x'``、``'xb'`` 和 ``'xt'`` 模式的支援。" -#: ../../library/gzip.rst:61 ../../library/gzip.rst:175 +#: ../../library/gzip.rst:61 ../../library/gzip.rst:184 msgid "Accepts a :term:`path-like object`." msgstr "接受\\ :term:`類路徑物件 `。" -#: ../../library/gzip.rst:66 +#: ../../library/gzip.rst:64 ../../library/gzip.rst:195 +#: ../../library/gzip.rst:225 +msgid "" +"The default compression level was reduced to 6 (down from 9). It is the " +"default level used by most compression tools and a better tradeoff between " +"speed and performance." +msgstr "" + +#: ../../library/gzip.rst:71 msgid "" "An exception raised for invalid gzip files. It inherits from :exc:" "`OSError`. :exc:`EOFError` and :exc:`zlib.error` can also be raised for " "invalid gzip files." msgstr "" -#: ../../library/gzip.rst:74 +#: ../../library/gzip.rst:79 msgid "" "Constructor for the :class:`GzipFile` class, which simulates most of the " "methods of a :term:`file object`, with the exception of the :meth:`~io." @@ -132,7 +140,7 @@ msgid "" "given a non-trivial value." msgstr "" -#: ../../library/gzip.rst:79 +#: ../../library/gzip.rst:84 msgid "" "The new class instance is based on *fileobj*, which can be a regular file, " "an :class:`io.BytesIO` object, or any other object which simulates a file. " @@ -140,7 +148,7 @@ msgid "" "file object." msgstr "" -#: ../../library/gzip.rst:84 +#: ../../library/gzip.rst:89 msgid "" "When *fileobj* is not ``None``, the *filename* argument is only used to be " "included in the :program:`gzip` file header, which may include the original " @@ -149,7 +157,7 @@ msgid "" "in this case the original filename is not included in the header." msgstr "" -#: ../../library/gzip.rst:90 +#: ../../library/gzip.rst:95 msgid "" "The *mode* argument can be any of ``'r'``, ``'rb'``, ``'a'``, ``'ab'``, " "``'w'``, ``'wb'``, ``'x'``, or ``'xb'``, depending on whether the file will " @@ -159,14 +167,14 @@ msgid "" "writing." msgstr "" -#: ../../library/gzip.rst:96 +#: ../../library/gzip.rst:101 msgid "" "Note that the file is always opened in binary mode. To open a compressed " "file in text mode, use :func:`.open` (or wrap your :class:`GzipFile` with " "an :class:`io.TextIOWrapper`)." msgstr "" -#: ../../library/gzip.rst:100 +#: ../../library/gzip.rst:105 msgid "" "The *compresslevel* argument is an integer from ``0`` to ``9`` controlling " "the level of compression; ``1`` is fastest and produces the least " @@ -174,20 +182,24 @@ msgid "" "is no compression. The default is ``9``." msgstr "" -#: ../../library/gzip.rst:105 +#: ../../library/gzip.rst:110 msgid "" "The optional *mtime* argument is the timestamp requested by gzip. The time " -"is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970. If " -"*mtime* is omitted or ``None``, the current time is used. Use *mtime* = 0 to " -"generate a compressed stream that does not depend on creation time." +"is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970. Set " +"*mtime* to ``0`` to generate a compressed stream that does not depend on " +"creation time. If *mtime* is omitted or ``None``, the current time is used; " +"however, if the current time is outside the range 00:00:00 UTC, January 1, " +"1970 through 06:28:15 UTC, February 7, 2106, or explicitly passed *mtime* " +"argument is outside the range ``0`` to ``2**32-1``, then the value ``0`` is " +"used instead." msgstr "" -#: ../../library/gzip.rst:110 +#: ../../library/gzip.rst:119 msgid "" "See below for the :attr:`mtime` attribute that is set when decompressing." msgstr "" -#: ../../library/gzip.rst:112 +#: ../../library/gzip.rst:121 msgid "" "Calling a :class:`GzipFile` object's :meth:`!close` method does not close " "*fileobj*, since you might wish to append more material after the compressed " @@ -196,39 +208,39 @@ msgid "" "class:`io.BytesIO` object's :meth:`~io.BytesIO.getvalue` method." msgstr "" -#: ../../library/gzip.rst:118 +#: ../../library/gzip.rst:127 msgid "" ":class:`GzipFile` supports the :class:`io.BufferedIOBase` interface, " "including iteration and the :keyword:`with` statement. Only the :meth:`~io." "IOBase.truncate` method isn't implemented." msgstr "" -#: ../../library/gzip.rst:122 +#: ../../library/gzip.rst:131 msgid ":class:`GzipFile` also provides the following method and attribute:" msgstr ":class:`GzipFile` 也提供了以下的方法和屬性:" -#: ../../library/gzip.rst:126 +#: ../../library/gzip.rst:135 msgid "" "Read *n* uncompressed bytes without advancing the file position. The number " "of bytes returned may be more or less than requested." msgstr "" -#: ../../library/gzip.rst:129 +#: ../../library/gzip.rst:138 msgid "" "While calling :meth:`peek` does not change the file position of the :class:" "`GzipFile`, it may change the position of the underlying file object (e.g. " "if the :class:`GzipFile` was constructed with the *fileobj* parameter)." msgstr "" -#: ../../library/gzip.rst:138 +#: ../../library/gzip.rst:147 msgid "``'rb'`` for reading and ``'wb'`` for writing." msgstr "``'rb'`` 用於讀取、``'wb'`` 用於寫入。" -#: ../../library/gzip.rst:140 +#: ../../library/gzip.rst:149 msgid "In previous versions it was an integer ``1`` or ``2``." msgstr "在先前版本中它是整數 ``1`` 或 ``2``。" -#: ../../library/gzip.rst:145 +#: ../../library/gzip.rst:154 msgid "" "When decompressing, this attribute is set to the last timestamp in the most " "recently read header. It is an integer, holding the number of seconds since " @@ -236,51 +248,51 @@ msgid "" "reading any headers is ``None``." msgstr "" -#: ../../library/gzip.rst:152 +#: ../../library/gzip.rst:161 msgid "" "The path to the gzip file on disk, as a :class:`str` or :class:`bytes`. " "Equivalent to the output of :func:`os.fspath` on the original input path, " "with no other normalization, resolution or expansion." msgstr "" -#: ../../library/gzip.rst:156 +#: ../../library/gzip.rst:165 msgid "" "Support for the :keyword:`with` statement was added, along with the *mtime* " "constructor argument and :attr:`mtime` attribute." msgstr "" -#: ../../library/gzip.rst:160 +#: ../../library/gzip.rst:169 msgid "Support for zero-padded and unseekable files was added." msgstr "" -#: ../../library/gzip.rst:163 +#: ../../library/gzip.rst:172 msgid "The :meth:`io.BufferedIOBase.read1` method is now implemented." msgstr ":meth:`io.BufferedIOBase.read1` 方法現在已有實作。" -#: ../../library/gzip.rst:166 +#: ../../library/gzip.rst:175 msgid "Added support for the ``'x'`` and ``'xb'`` modes." msgstr "新增 ``'x'`` 和 ``'xb'`` 模式的支援。" -#: ../../library/gzip.rst:169 +#: ../../library/gzip.rst:178 msgid "" "Added support for writing arbitrary :term:`bytes-like objects `. The :meth:`~io.BufferedIOBase.read` method now accepts an argument " "of ``None``." msgstr "" -#: ../../library/gzip.rst:178 +#: ../../library/gzip.rst:187 msgid "" "Opening :class:`GzipFile` for writing without specifying the *mode* argument " "is deprecated." msgstr "" -#: ../../library/gzip.rst:182 +#: ../../library/gzip.rst:191 msgid "" "Remove the ``filename`` attribute, use the :attr:`~GzipFile.name` attribute " "instead." msgstr "" -#: ../../library/gzip.rst:189 +#: ../../library/gzip.rst:203 msgid "" "Compress the *data*, returning a :class:`bytes` object containing the " "compressed data. *compresslevel* and *mtime* have the same meaning as in " @@ -288,11 +300,11 @@ msgid "" "reproducible output." msgstr "" -#: ../../library/gzip.rst:195 +#: ../../library/gzip.rst:209 msgid "Added the *mtime* parameter for reproducible output." msgstr "" -#: ../../library/gzip.rst:197 +#: ../../library/gzip.rst:211 msgid "" "Speed is improved by compressing all data at once instead of in a streamed " "fashion. Calls with *mtime* set to ``0`` are delegated to :func:`zlib." @@ -301,19 +313,19 @@ msgid "" "underlying zlib implementation." msgstr "" -#: ../../library/gzip.rst:204 +#: ../../library/gzip.rst:218 msgid "" "The gzip header OS byte is guaranteed to be set to 255 when this function is " "used as was the case in 3.10 and earlier." msgstr "" -#: ../../library/gzip.rst:207 +#: ../../library/gzip.rst:221 msgid "" "The *mtime* parameter now defaults to 0 for reproducible output. For the " "previous behaviour of using the current time, pass ``None`` to *mtime*." msgstr "" -#: ../../library/gzip.rst:214 +#: ../../library/gzip.rst:232 msgid "" "Decompress the *data*, returning a :class:`bytes` object containing the " "uncompressed data. This function is capable of decompressing multi-member " @@ -322,21 +334,21 @@ msgid "" "*wbits* set to 31 is faster." msgstr "" -#: ../../library/gzip.rst:221 +#: ../../library/gzip.rst:239 msgid "" "Speed is improved by decompressing members at once in memory instead of in a " "streamed fashion." msgstr "" -#: ../../library/gzip.rst:228 +#: ../../library/gzip.rst:246 msgid "Examples of usage" msgstr "用法範例" -#: ../../library/gzip.rst:230 +#: ../../library/gzip.rst:248 msgid "Example of how to read a compressed file::" msgstr "如何讀取壓縮檔案的範例: ::" -#: ../../library/gzip.rst:232 +#: ../../library/gzip.rst:250 msgid "" "import gzip\n" "with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" @@ -346,11 +358,11 @@ msgstr "" "with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" " file_content = f.read()" -#: ../../library/gzip.rst:236 +#: ../../library/gzip.rst:254 msgid "Example of how to create a compressed GZIP file::" msgstr "如何建立一個壓縮的 GZIP 檔案的範例: ::" -#: ../../library/gzip.rst:238 +#: ../../library/gzip.rst:256 msgid "" "import gzip\n" "content = b\"Lots of content here\"\n" @@ -362,11 +374,11 @@ msgstr "" "with gzip.open('/home/joe/file.txt.gz', 'wb') as f:\n" " f.write(content)" -#: ../../library/gzip.rst:243 +#: ../../library/gzip.rst:261 msgid "Example of how to GZIP compress an existing file::" msgstr "如何壓縮一個已存在的檔案的範例: ::" -#: ../../library/gzip.rst:245 +#: ../../library/gzip.rst:263 msgid "" "import gzip\n" "import shutil\n" @@ -380,11 +392,11 @@ msgstr "" " with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:\n" " shutil.copyfileobj(f_in, f_out)" -#: ../../library/gzip.rst:251 +#: ../../library/gzip.rst:269 msgid "Example of how to GZIP compress a binary string::" msgstr "如何壓縮一個二進位字串的範例: ::" -#: ../../library/gzip.rst:253 +#: ../../library/gzip.rst:271 msgid "" "import gzip\n" "s_in = b\"Lots of content here\"\n" @@ -394,62 +406,62 @@ msgstr "" "s_in = b\"Lots of content here\"\n" "s_out = gzip.compress(s_in)" -#: ../../library/gzip.rst:259 +#: ../../library/gzip.rst:277 msgid "Module :mod:`zlib`" msgstr ":mod:`zlib` 模組" -#: ../../library/gzip.rst:260 +#: ../../library/gzip.rst:278 msgid "" "The basic data compression module needed to support the :program:`gzip` file " "format." msgstr "" -#: ../../library/gzip.rst:263 +#: ../../library/gzip.rst:281 msgid "" "In case gzip (de)compression is a bottleneck, the `python-isal`_ package " "speeds up (de)compression with a mostly compatible API." msgstr "" -#: ../../library/gzip.rst:273 +#: ../../library/gzip.rst:291 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/gzip.rst:275 +#: ../../library/gzip.rst:293 msgid "" "The :mod:`!gzip` module provides a simple command line interface to compress " "or decompress files." msgstr "" -#: ../../library/gzip.rst:278 +#: ../../library/gzip.rst:296 msgid "Once executed the :mod:`!gzip` module keeps the input file(s)." msgstr "" -#: ../../library/gzip.rst:282 +#: ../../library/gzip.rst:300 msgid "" "Add a new command line interface with a usage. By default, when you will " "execute the CLI, the default compression level is 6." msgstr "" -#: ../../library/gzip.rst:286 +#: ../../library/gzip.rst:304 msgid "Command-line options" msgstr "命令列選項" -#: ../../library/gzip.rst:290 +#: ../../library/gzip.rst:308 msgid "If *file* is not specified, read from :data:`sys.stdin`." msgstr "如果未指定 *file*,則從 :data:`sys.stdin` 讀取。" -#: ../../library/gzip.rst:294 +#: ../../library/gzip.rst:312 msgid "Indicates the fastest compression method (less compression)." msgstr "" -#: ../../library/gzip.rst:298 +#: ../../library/gzip.rst:316 msgid "Indicates the slowest compression method (best compression)." msgstr "" -#: ../../library/gzip.rst:302 +#: ../../library/gzip.rst:320 msgid "Decompress the given file." msgstr "解壓縮指定的檔案。" -#: ../../library/gzip.rst:306 +#: ../../library/gzip.rst:324 msgid "Show the help message." msgstr "顯示幫助訊息。" diff --git a/library/hashlib.po b/library/hashlib.po index ea20df9e3e4..d31d1b02356 100644 --- a/library/hashlib.po +++ b/library/hashlib.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-05-11 16:03+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!hashlib` --- Secure hashes and message digests" msgstr ":mod:`!hashlib` --- 安全雜湊與訊息摘要" -#: ../../library/hashlib.rst:10 +#: ../../library/hashlib.rst:7 msgid "**Source code:** :source:`Lib/hashlib.py`" msgstr "**原始碼:**\\ :source:`Lib/hashlib.py`" -#: ../../library/hashlib.rst:23 +#: ../../library/hashlib.rst:20 msgid "" "This module implements a common interface to many different hash algorithms. " "Included are the FIPS secure hash algorithms SHA224, SHA256, SHA384, SHA512, " @@ -41,18 +41,18 @@ msgstr "" "standard_>`_)以及遺留的 SHA1 演算法(`先前為 FIPS 的一部分 `_)和 MD5 演算法(定義於網際網路 :rfc:`1321`)。" -#: ../../library/hashlib.rst:31 +#: ../../library/hashlib.rst:28 msgid "" "If you want the adler32 or crc32 hash functions, they are available in the :" "mod:`zlib` module." msgstr "" "如果你需要 adler32 或 crc32 雜湊函式,可以在 :mod:`zlib` 模組中找到它們。" -#: ../../library/hashlib.rst:38 +#: ../../library/hashlib.rst:35 msgid "Hash algorithms" msgstr "雜湊演算法" -#: ../../library/hashlib.rst:40 +#: ../../library/hashlib.rst:37 msgid "" "There is one constructor method named for each type of :dfn:`hash`. All " "return a hash object with the same simple interface. For example: use :func:" @@ -71,7 +71,7 @@ msgstr "" "` 方法來要求它提供迄今為止傳遞給它的資料串聯的\\ :dfn:`摘要 " "(digest)`。" -#: ../../library/hashlib.rst:48 +#: ../../library/hashlib.rst:45 msgid "" "To allow multithreading, the Python :term:`GIL` is released while computing " "a hash supplied more than 2047 bytes of data at once in its constructor or :" @@ -81,22 +81,26 @@ msgstr "" "式或 :meth:`.update` 方法中計算一次提供超過 2047 位元組資料的雜" "湊值。" -#: ../../library/hashlib.rst:55 +#: ../../library/hashlib.rst:52 msgid "" "Constructors for hash algorithms that are always present in this module are :" -"func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, :func:" -"`sha512`, :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:" +"func:`md5`, :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, :" +"func:`sha512`, :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:" "`sha3_512`, :func:`shake_128`, :func:`shake_256`, :func:`blake2b`, and :func:" -"`blake2s`. :func:`md5` is normally available as well, though it may be " -"missing or blocked if you are using a rare \"FIPS compliant\" build of " -"Python. These correspond to :data:`algorithms_guaranteed`." +"`blake2s`. These correspond to :data:`algorithms_guaranteed`." +msgstr "" +"此模組中始終存在的雜湊演算法之建構函式" +"有 :func:`md5`、:func:`sha1`、:func:`sha224`、:func:`sha256`、:func:`sha384`、:func:`sha512`、:func:`sha3_224`、:func:`sha3_256`、:func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:`shake_256`、:func:`blake2b` " +"和 :func:`blake2s`。以上會對應到 :data:`algorithms_guaranteed`。" + +#: ../../library/hashlib.rst:58 +msgid "" +"Any of these may nonetheless be missing or blocked in unusual environments, " +"such as a rare \"FIPS compliant\" build of Python or when OpenSSL's \"FIPS " +"mode\" is configured to exclude some algorithms from its default provider. " +"Calling the constructor of an algorithm that is unavailable raises :exc:" +"`ValueError`." msgstr "" -"此模組中始終存在的雜湊演算法之建構函式有 :func:`sha1`、:func:`sha224`、:func:" -"`sha256`、:func:`sha384`、:func:`sha512`、:func:`sha3_224`、:func:" -"`sha3_256`、:func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:" -"`shake_256`、:func:`blake2b` 和 :func:`blake2s`。:func:`md5` 通常也可用,但如" -"果你使用罕見的「符合 FIPS (FIPS compliant)」的 Python 建置版本,它可能不存在" -"或者不被允許使用。以上會對應到 :data:`algorithms_guaranteed`。" #: ../../library/hashlib.rst:63 msgid "" @@ -155,18 +159,26 @@ msgstr "" "對於鏈結之 OpenSSL 未提供的任何 MD5、SHA1、SHA2 或 SHA3 演算法,我們會回退使" "用 `HACL\\* 專案 `_\\ 中經過驗證的實作。" -#: ../../library/hashlib.rst:98 +#: ../../library/hashlib.rst:97 +msgid "" +"The undocumented ``string`` keyword parameter in :func:`!_hashlib.new` and " +"hash-named constructors such as :func:`!_md5.md5` is deprecated. Prefer " +"passing the initial data as a positional argument for maximum backwards " +"compatibility." +msgstr "" + +#: ../../library/hashlib.rst:105 msgid "Usage" msgstr "用法" -#: ../../library/hashlib.rst:100 +#: ../../library/hashlib.rst:107 msgid "" "To obtain the digest of the byte string ``b\"Nobody inspects the spammish " "repetition\"``::" msgstr "" "取得位元組字串 ``b\"Nobody inspects the spammish repetition\"`` 的摘要: ::" -#: ../../library/hashlib.rst:103 +#: ../../library/hashlib.rst:110 msgid "" ">>> import hashlib\n" ">>> m = hashlib.sha256()\n" @@ -190,15 +202,15 @@ msgstr "" ">>> m.hexdigest()\n" "'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'" -#: ../../library/hashlib.rst:112 +#: ../../library/hashlib.rst:119 msgid "More condensed:" msgstr "更濃縮:" -#: ../../library/hashlib.rst:118 +#: ../../library/hashlib.rst:125 msgid "Constructors" msgstr "建構函式" -#: ../../library/hashlib.rst:122 +#: ../../library/hashlib.rst:129 msgid "" "Is a generic constructor that takes the string *name* of the desired " "algorithm as its first parameter. It also exists to allow access to the " @@ -208,25 +220,25 @@ msgstr "" "是一個通用建構函式,它將目標演算法的字串 *name* 作為其第一個參數。它還允許使" "用者取得上面列出的雜湊值以及 OpenSSL 函式庫可能提供的任何其他演算法。" -#: ../../library/hashlib.rst:127 +#: ../../library/hashlib.rst:134 msgid "Using :func:`new` with an algorithm name:" msgstr "使用 :func:`new` 和演算法名稱:" -#: ../../library/hashlib.rst:146 +#: ../../library/hashlib.rst:153 msgid "" "Named constructors such as these are faster than passing an algorithm name " "to :func:`new`." msgstr "諸如此類的附名建構函式比將演算法名稱傳遞給 :func:`new` 更快。" -#: ../../library/hashlib.rst:150 +#: ../../library/hashlib.rst:157 msgid "Attributes" msgstr "屬性" -#: ../../library/hashlib.rst:152 +#: ../../library/hashlib.rst:159 msgid "Hashlib provides the following constant module attributes:" msgstr "Hashlib 提供以下常數模組屬性:" -#: ../../library/hashlib.rst:156 +#: ../../library/hashlib.rst:163 msgid "" "A set containing the names of the hash algorithms guaranteed to be supported " "by this module on all platforms. Note that 'md5' is in this list despite " @@ -237,7 +249,7 @@ msgstr "" "列表中,儘管有一些上游供應商提供了奇怪的「符合 FIPS (FIPS compliant)」的 " "Python 建置,並將其排除在外。" -#: ../../library/hashlib.rst:165 +#: ../../library/hashlib.rst:172 msgid "" "A set containing the names of the hash algorithms that are available in the " "running Python interpreter. These names will be recognized when passed to :" @@ -249,29 +261,29 @@ msgstr "" "func:`new` 時將被識別。:attr:`algorithms_guaranteed` 都會是它的一個子集。相同" "的演算法可能會以不同的名稱多次出現在該集合中(多虧了 OpenSSL)。" -#: ../../library/hashlib.rst:174 +#: ../../library/hashlib.rst:181 msgid "Hash Objects" msgstr "雜湊物件" -#: ../../library/hashlib.rst:176 +#: ../../library/hashlib.rst:183 msgid "" "The following values are provided as constant attributes of the hash objects " "returned by the constructors:" msgstr "以下的值皆為建構函式回傳之雜湊物件的常數屬性:" -#: ../../library/hashlib.rst:181 +#: ../../library/hashlib.rst:188 msgid "The size of the resulting hash in bytes." msgstr "生成雜湊的大小(以位元組為單位)。" -#: ../../library/hashlib.rst:185 +#: ../../library/hashlib.rst:192 msgid "The internal block size of the hash algorithm in bytes." msgstr "雜湊演算法的內部區塊大小(以位元組為單位)。" -#: ../../library/hashlib.rst:187 +#: ../../library/hashlib.rst:194 msgid "A hash object has the following attributes:" msgstr "雜湊物件具有以下屬性:" -#: ../../library/hashlib.rst:191 +#: ../../library/hashlib.rst:198 msgid "" "The canonical name of this hash, always lowercase and always suitable as a " "parameter to :func:`new` to create another hash of this type." @@ -279,7 +291,7 @@ msgstr "" "該雜湊的規範名稱,都會是小寫,且都會適合作為 :func:`new` 的參數以建立此型別的" "另一個雜湊。" -#: ../../library/hashlib.rst:194 +#: ../../library/hashlib.rst:201 msgid "" "The name attribute has been present in CPython since its inception, but " "until Python 3.4 was not formally specified, so may not exist on some " @@ -288,11 +300,11 @@ msgstr "" "name 屬性自 CPython 誕生以來就存在於其中,但直到 Python 3.4 才正式確立,因此" "在某些平台上可能不存在。" -#: ../../library/hashlib.rst:199 +#: ../../library/hashlib.rst:206 msgid "A hash object has the following methods:" msgstr "雜湊物件具有以下方法:" -#: ../../library/hashlib.rst:204 +#: ../../library/hashlib.rst:211 msgid "" "Update the hash object with the :term:`bytes-like object`. Repeated calls " "are equivalent to a single call with the concatenation of all the arguments: " @@ -302,7 +314,7 @@ msgstr "" "當於連接所有引數的單一呼叫:``m.update(a); m.update(b)`` 等價於 ``m." "update(a+b)``。" -#: ../../library/hashlib.rst:212 +#: ../../library/hashlib.rst:219 msgid "" "Return the digest of the data passed to the :meth:`update` method so far. " "This is a bytes object of size :attr:`digest_size` which may contain bytes " @@ -311,7 +323,7 @@ msgstr "" "回傳目前有傳遞給 :meth:`update` 方法的資料之摘要。這是一個大小為 :attr:" "`digest_size` 的位元組物件,它可能包含從 0 到 255 的整個範圍內的位元組。" -#: ../../library/hashlib.rst:219 +#: ../../library/hashlib.rst:226 msgid "" "Like :meth:`digest` except the digest is returned as a string object of " "double length, containing only hexadecimal digits. This may be used to " @@ -320,7 +332,7 @@ msgstr "" "與 :meth:`digest` 類似,只不過摘要會是作為雙倍長度的字串物件回傳,僅包含十六" "進位數字。這可用於在電子郵件或其他非二進位環境中安全地交換值。" -#: ../../library/hashlib.rst:226 +#: ../../library/hashlib.rst:233 msgid "" "Return a copy (\"clone\") of the hash object. This can be used to " "efficiently compute the digests of data sharing a common initial substring." @@ -328,11 +340,11 @@ msgstr "" "回傳雜湊物件的副本(「複製 (clone)」),這可用於高效率地計算出共享同一初始子" "字串的資料之摘要。" -#: ../../library/hashlib.rst:231 +#: ../../library/hashlib.rst:238 msgid "SHAKE variable length digests" msgstr "SHAKE 可變長度摘要" -#: ../../library/hashlib.rst:236 +#: ../../library/hashlib.rst:243 msgid "" "The :func:`shake_128` and :func:`shake_256` algorithms provide variable " "length digests with length_in_bits//2 up to 128 or 256 bits of security. As " @@ -343,7 +355,7 @@ msgstr "" "length_in_bits//2 最高為 128 或 256 位元安全性。因此,他們的摘要方法會需要長" "度。最大長度不受 SHAKE 演算法限制。" -#: ../../library/hashlib.rst:243 +#: ../../library/hashlib.rst:250 msgid "" "Return the digest of the data passed to the :meth:`~hash.update` method so " "far. This is a bytes object of size *length* which may contain bytes in the " @@ -352,7 +364,7 @@ msgstr "" "回傳目前有傳遞給 :meth:`~hash.update` 方法的資料之摘要。這是一個大小為 " "*length* 的位元組物件,可能包含從 0 到 255 的整個範圍內的位元組。" -#: ../../library/hashlib.rst:250 +#: ../../library/hashlib.rst:257 msgid "" "Like :meth:`digest` except the digest is returned as a string object of " "double length, containing only hexadecimal digits. This may be used to " @@ -361,15 +373,15 @@ msgstr "" "與 :meth:`digest` 類似,只不過摘要作為雙倍長度的字串物件回傳,僅包含十六進位" "數字。這可用於交換電子郵件或其他非二進位環境中的值。" -#: ../../library/hashlib.rst:254 +#: ../../library/hashlib.rst:261 msgid "Example use:" msgstr "範例:" -#: ../../library/hashlib.rst:261 +#: ../../library/hashlib.rst:268 msgid "File hashing" msgstr "檔案雜湊" -#: ../../library/hashlib.rst:263 +#: ../../library/hashlib.rst:270 msgid "" "The hashlib module provides a helper function for efficient hashing of a " "file or file-like object." @@ -377,12 +389,12 @@ msgstr "" "hashlib 模組提供了一個輔助函式,用於對檔案或類檔案物件 (file-like object) 進" "行有效率的雜湊。" -#: ../../library/hashlib.rst:268 +#: ../../library/hashlib.rst:275 msgid "" "Return a digest object that has been updated with contents of file object." msgstr "回傳已用檔案物件內容更新的摘要物件。" -#: ../../library/hashlib.rst:270 +#: ../../library/hashlib.rst:277 msgid "" "*fileobj* must be a file-like object opened for reading in binary mode. It " "accepts file objects from builtin :func:`open`, :class:`~io.BytesIO` " @@ -395,7 +407,7 @@ msgstr "" "SocketIO 物件等。*fileobj* 必須以阻塞模式開啟,否則可能會引發 :exc:" "`BlockingIOError`。" -#: ../../library/hashlib.rst:276 +#: ../../library/hashlib.rst:283 msgid "" "The function may bypass Python's I/O and use the file descriptor from :meth:" "`~io.IOBase.fileno` directly. *fileobj* must be assumed to be in an unknown " @@ -406,7 +418,7 @@ msgstr "" "述器 (file descriptor)。在此函式回傳或引發後,必須假定 *fileobj* 處於未知狀" "態 (unknown state)。由呼叫者決定是否關閉 *fileobj*。" -#: ../../library/hashlib.rst:281 +#: ../../library/hashlib.rst:288 msgid "" "*digest* must either be a hash algorithm name as a *str*, a hash " "constructor, or a callable that returns a hash object." @@ -414,11 +426,11 @@ msgstr "" "*digest* 必須是名稱作為 *str* 的雜湊演算法、雜湊建構函式或會回傳雜湊物件的可" "呼叫函式。" -#: ../../library/hashlib.rst:284 +#: ../../library/hashlib.rst:291 msgid "Example:" msgstr "範例:" -#: ../../library/hashlib.rst:305 +#: ../../library/hashlib.rst:312 msgid "" "Now raises a :exc:`BlockingIOError` if the file is opened in non-blocking " "mode. Previously, spurious null bytes were added to the digest." @@ -426,11 +438,11 @@ msgstr "" "現在如果檔案以非阻塞模式開啟,會引發 :exc:`BlockingIOError`。先前," "會有多餘的空位元組被加入到摘要中。" -#: ../../library/hashlib.rst:311 +#: ../../library/hashlib.rst:318 msgid "Key derivation" msgstr "密鑰的生成" -#: ../../library/hashlib.rst:313 +#: ../../library/hashlib.rst:320 msgid "" "Key derivation and key stretching algorithms are designed for secure " "password hashing. Naive algorithms such as ``sha1(password)`` are not " @@ -443,7 +455,7 @@ msgstr "" "的密碼雜湊函式必須是可調校的 (tunable)、緩慢的,並且有包含 `salt(鹽) " "`_。" -#: ../../library/hashlib.rst:321 +#: ../../library/hashlib.rst:328 msgid "" "The function provides PKCS#5 password-based key derivation function 2. It " "uses HMAC as pseudorandom function." @@ -451,7 +463,7 @@ msgstr "" "該函式提供基於密碼的 PKCS#5 密鑰生成函式 2。它使用 HMAC 作為偽隨機函式 " "(pseudorandom function)。" -#: ../../library/hashlib.rst:324 +#: ../../library/hashlib.rst:331 msgid "" "The string *hash_name* is the desired name of the hash digest algorithm for " "HMAC, e.g. 'sha1' or 'sha256'. *password* and *salt* are interpreted as " @@ -464,7 +476,7 @@ msgstr "" "*password* 設下合理的長度限制(例如 1024)。*salt* 應該是來自適當來源(例如 :" "func:`os.urandom`)且大約 16 或更多位元組。" -#: ../../library/hashlib.rst:330 +#: ../../library/hashlib.rst:337 msgid "" "The number of *iterations* should be chosen based on the hash algorithm and " "computing power. As of 2022, hundreds of thousands of iterations of SHA-256 " @@ -477,7 +489,7 @@ msgstr "" "讀 NIST-SP-800-132_ 的 *Appendix A.2.2*。`stackexchange pbkdf2 疊代問題`_\\ " "上的答案有詳細解釋。" -#: ../../library/hashlib.rst:336 +#: ../../library/hashlib.rst:343 msgid "" "*dklen* is the length of the derived key in bytes. If *dklen* is ``None`` " "then the digest size of the hash algorithm *hash_name* is used, e.g. 64 for " @@ -486,11 +498,11 @@ msgstr "" "*dklen* 是生成的密鑰長度。如果 *dklen* 為 ``None``,則會使用雜湊演算法 " "*hash_name* 的摘要大小,例如 SHA-512 為 64。" -#: ../../library/hashlib.rst:345 +#: ../../library/hashlib.rst:352 msgid "Function only available when Python is compiled with OpenSSL." msgstr "僅當有使用 OpenSSL 編譯 Python 時該函式才可用。" -#: ../../library/hashlib.rst:349 +#: ../../library/hashlib.rst:356 msgid "" "Function now only available when Python is built with OpenSSL. The slow pure " "Python implementation has been removed." @@ -498,13 +510,13 @@ msgstr "" "該函式現在僅在有使用 OpenSSL 建置 Python 時可用。緩慢的純 Python 實作已被刪" "除。" -#: ../../library/hashlib.rst:355 +#: ../../library/hashlib.rst:362 msgid "" "The function provides scrypt password-based key derivation function as " "defined in :rfc:`7914`." msgstr "該函式提供(如 :rfc:`7914` 中所定義的)scrypt 基於密碼的密鑰衍生函式。" -#: ../../library/hashlib.rst:358 +#: ../../library/hashlib.rst:365 msgid "" "*password* and *salt* must be :term:`bytes-like objects `. Applications and libraries should limit *password* to a sensible " @@ -515,7 +527,7 @@ msgstr "" "程式和函式庫應為 *password* 設下合理的長度限制(例如 1024)。*salt* 應該是來" "自適當來源(例如 :func:`os.urandom`)且大約 16 或更多位元組。" -#: ../../library/hashlib.rst:363 +#: ../../library/hashlib.rst:370 msgid "" "*n* is the CPU/Memory cost factor, *r* the block size, *p* parallelization " "factor and *maxmem* limits memory (OpenSSL 1.1.0 defaults to 32 MiB). " @@ -524,17 +536,17 @@ msgstr "" "*n* 是 CPU/記憶體開銷係數、*r* 是區塊大小、*p* 為平行化係數、*maxmem* 為記憶" "體限制(OpenSSL 1.1.0 預設為 32 MiB)。*dklen* 是生成密鑰的長度。" -#: ../../library/hashlib.rst:373 +#: ../../library/hashlib.rst:380 msgid "BLAKE2" msgstr "BLAKE2" -#: ../../library/hashlib.rst:380 +#: ../../library/hashlib.rst:385 msgid "" "BLAKE2_ is a cryptographic hash function defined in :rfc:`7693` that comes " "in two flavors:" msgstr "BLAKE2_ 是在 :rfc:`7693` 中定義的加密雜湊函式,有兩種類型:" -#: ../../library/hashlib.rst:383 +#: ../../library/hashlib.rst:388 msgid "" "**BLAKE2b**, optimized for 64-bit platforms and produces digests of any size " "between 1 and 64 bytes," @@ -542,7 +554,7 @@ msgstr "" "**BLAKE2b**,針對 64 位元平台進行了最佳化,可生成 1 到 64 位元組之間任意大小" "的摘要," -#: ../../library/hashlib.rst:386 +#: ../../library/hashlib.rst:391 msgid "" "**BLAKE2s**, optimized for 8- to 32-bit platforms and produces digests of " "any size between 1 and 32 bytes." @@ -550,7 +562,7 @@ msgstr "" "**BLAKE2s**,針對 8 至 32 位元平台進行了最佳化,可生成 1 至 32 位元組之間任意" "大小的摘要。" -#: ../../library/hashlib.rst:389 +#: ../../library/hashlib.rst:394 msgid "" "BLAKE2 supports **keyed mode** (a faster and simpler replacement for HMAC_), " "**salted hashing**, **personalization**, and **tree hashing**." @@ -558,21 +570,21 @@ msgstr "" "BLAKE2 支援\\ **密鑰模式 (keyed mode)** (更快、更簡單的 HMAC_ 替代品)、**加" "鹽雜湊 (salted hashing)**、**個人化**\\ 和\\ **樹狀雜湊**。" -#: ../../library/hashlib.rst:392 +#: ../../library/hashlib.rst:397 msgid "" "Hash objects from this module follow the API of standard library's :mod:`!" "hashlib` objects." msgstr "該模組中的雜湊物件遵循標準函式庫的 :mod:`!hashlib` 物件 API。" -#: ../../library/hashlib.rst:397 +#: ../../library/hashlib.rst:402 msgid "Creating hash objects" msgstr "建立雜湊物件" -#: ../../library/hashlib.rst:399 +#: ../../library/hashlib.rst:404 msgid "New hash objects are created by calling constructor functions:" msgstr "新的雜湊物件是透過呼叫建構函式建立的:" -#: ../../library/hashlib.rst:413 +#: ../../library/hashlib.rst:418 msgid "" "These functions return the corresponding hash objects for calculating " "BLAKE2b or BLAKE2s. They optionally take these general parameters:" @@ -580,7 +592,7 @@ msgstr "" "這些函式回傳相應的雜湊物件以計算 BLAKE2b 或 BLAKE2s。他們可以選擇採用這些通用" "參數:" -#: ../../library/hashlib.rst:416 +#: ../../library/hashlib.rst:421 msgid "" "*data*: initial chunk of data to hash, which must be :term:`bytes-like " "object`. It can be passed only as positional argument." @@ -588,18 +600,18 @@ msgstr "" "*data*:要雜湊的初始資料塊 (data chunk),它必須是\\ :term:`類位元組物件 " "`。它只能作為位置引數傳遞。" -#: ../../library/hashlib.rst:419 +#: ../../library/hashlib.rst:424 msgid "*digest_size*: size of output digest in bytes." msgstr "*digest_size*:輸出摘要的大小(以位元組為單位)。" -#: ../../library/hashlib.rst:421 +#: ../../library/hashlib.rst:426 msgid "" "*key*: key for keyed hashing (up to 64 bytes for BLAKE2b, up to 32 bytes for " "BLAKE2s)." msgstr "" "*key*:用於密鑰雜湊的密鑰(BLAKE2b 最多 64 位元組、BLAKE2s 最多 32 位元組)。" -#: ../../library/hashlib.rst:424 +#: ../../library/hashlib.rst:429 msgid "" "*salt*: salt for randomized hashing (up to 16 bytes for BLAKE2b, up to 8 " "bytes for BLAKE2s)." @@ -607,62 +619,62 @@ msgstr "" "*salt*:用於隨機雜湊的鹽(BLAKE2b 最多 16 個位元組、BLAKE2s 最多 8 個位元" "組)。" -#: ../../library/hashlib.rst:427 +#: ../../library/hashlib.rst:432 msgid "" "*person*: personalization string (up to 16 bytes for BLAKE2b, up to 8 bytes " "for BLAKE2s)." msgstr "" "*person*:個人化字串(BLAKE2b 最多 16 個位元組、BLAKE2s 最多 8 個位元組)。" -#: ../../library/hashlib.rst:430 +#: ../../library/hashlib.rst:435 msgid "The following table shows limits for general parameters (in bytes):" msgstr "下表顯示了一般參數的限制(以位元組為單位):" -#: ../../library/hashlib.rst:433 +#: ../../library/hashlib.rst:438 msgid "Hash" msgstr "雜湊" -#: ../../library/hashlib.rst:433 +#: ../../library/hashlib.rst:438 msgid "digest_size" msgstr "digest_size" -#: ../../library/hashlib.rst:433 +#: ../../library/hashlib.rst:438 msgid "len(key)" msgstr "len(key)" -#: ../../library/hashlib.rst:433 +#: ../../library/hashlib.rst:438 msgid "len(salt)" msgstr "len(salt)" -#: ../../library/hashlib.rst:433 +#: ../../library/hashlib.rst:438 msgid "len(person)" msgstr "len(person)" -#: ../../library/hashlib.rst:435 +#: ../../library/hashlib.rst:440 msgid "BLAKE2b" msgstr "BLAKE2b" -#: ../../library/hashlib.rst:435 +#: ../../library/hashlib.rst:440 msgid "64" msgstr "64" -#: ../../library/hashlib.rst:435 +#: ../../library/hashlib.rst:440 msgid "16" msgstr "16" -#: ../../library/hashlib.rst:436 +#: ../../library/hashlib.rst:441 msgid "BLAKE2s" msgstr "BLAKE2s" -#: ../../library/hashlib.rst:436 +#: ../../library/hashlib.rst:441 msgid "32" msgstr "32" -#: ../../library/hashlib.rst:436 +#: ../../library/hashlib.rst:441 msgid "8" msgstr "8" -#: ../../library/hashlib.rst:441 +#: ../../library/hashlib.rst:446 msgid "" "BLAKE2 specification defines constant lengths for salt and personalization " "parameters, however, for convenience, this implementation accepts byte " @@ -676,26 +688,26 @@ msgstr "" "以像是 ``b'salt`` 和 ``b'salt\\x00`` 是相同的值。(但 *key* 的情況並非如" "此。)" -#: ../../library/hashlib.rst:448 +#: ../../library/hashlib.rst:453 msgid "These sizes are available as module `constants`_ described below." msgstr "這些大小可作為模組\\ `常數 `_\\ 使用,如下所述。" -#: ../../library/hashlib.rst:450 +#: ../../library/hashlib.rst:455 msgid "" "Constructor functions also accept the following tree hashing parameters:" msgstr "建構函式還接受以下樹狀雜湊參數:" -#: ../../library/hashlib.rst:452 +#: ../../library/hashlib.rst:457 msgid "*fanout*: fanout (0 to 255, 0 if unlimited, 1 in sequential mode)." msgstr "*fanout*:扇出(0 到 255,如果無限制則為 0、順序模式為 1)。" -#: ../../library/hashlib.rst:454 +#: ../../library/hashlib.rst:459 msgid "" "*depth*: maximal depth of tree (1 to 255, 255 if unlimited, 1 in sequential " "mode)." msgstr "*depth*:樹的最大深度(1 到 255,如果無限制則為 255、順序模式為 1)。" -#: ../../library/hashlib.rst:457 +#: ../../library/hashlib.rst:462 msgid "" "*leaf_size*: maximal byte length of leaf (0 to ``2**32-1``, 0 if unlimited " "or in sequential mode)." @@ -703,7 +715,7 @@ msgstr "" "*leaf_size*:葉的最大位元組長度(0 到 ``2**32-1``,如果無限制或處於順序模式則" "為 0)。" -#: ../../library/hashlib.rst:460 +#: ../../library/hashlib.rst:465 msgid "" "*node_offset*: node offset (0 to ``2**64-1`` for BLAKE2b, 0 to ``2**48-1`` " "for BLAKE2s, 0 for the first, leftmost, leaf, or in sequential mode)." @@ -711,12 +723,12 @@ msgstr "" "*node_offset*:節點偏移量(BLAKE2b 為 0 到 ``2**64-1``,BLAKE2s 為 0 到 " "``2**48-1``,0 表示第一個、最左邊、葉子或在順序模式下)。" -#: ../../library/hashlib.rst:463 +#: ../../library/hashlib.rst:468 msgid "" "*node_depth*: node depth (0 to 255, 0 for leaves, or in sequential mode)." msgstr "*node_depth*:節點深度(0 到 255,葉為 0,或在順序模式下)。" -#: ../../library/hashlib.rst:465 +#: ../../library/hashlib.rst:470 msgid "" "*inner_size*: inner digest size (0 to 64 for BLAKE2b, 0 to 32 for BLAKE2s, 0 " "in sequential mode)." @@ -724,18 +736,18 @@ msgstr "" "*inner_size*:內部摘要大小(BLAKE2b 為 0 到 64,BLAKE2s 為 0 到 32,順序模式" "為 0)。" -#: ../../library/hashlib.rst:468 +#: ../../library/hashlib.rst:473 msgid "" "*last_node*: boolean indicating whether the processed node is the last one " "(``False`` for sequential mode)." msgstr "" "*last_node*:布林值,代表處理的節點是否為最後一個(``False`` 代表順序模式)。" -#: ../../library/hashlib.rst:471 +#: ../../library/hashlib.rst:476 msgid "Explanation of tree mode parameters." msgstr "樹狀模式參數說明。" -#: ../../library/hashlib.rst:475 +#: ../../library/hashlib.rst:480 msgid "" "See section 2.10 in `BLAKE2 specification `_ for comprehensive review of tree hashing." @@ -743,36 +755,36 @@ msgstr "" "關於樹狀雜湊的綜合回顧,請參閱 `BLAKE2 規範 `_\\ 中的第 2.10 節。" -#: ../../library/hashlib.rst:481 +#: ../../library/hashlib.rst:486 msgid "Constants" msgstr "常數" -#: ../../library/hashlib.rst:486 +#: ../../library/hashlib.rst:491 msgid "Salt length (maximum length accepted by constructors)." msgstr "鹽長度(建構函式接受的最大長度)。" -#: ../../library/hashlib.rst:492 +#: ../../library/hashlib.rst:497 msgid "" "Personalization string length (maximum length accepted by constructors)." msgstr "個人化字串長度(建構函式接受的最大長度)。" -#: ../../library/hashlib.rst:498 +#: ../../library/hashlib.rst:503 msgid "Maximum key size." msgstr "最大密鑰大小。" -#: ../../library/hashlib.rst:504 +#: ../../library/hashlib.rst:509 msgid "Maximum digest size that the hash function can output." msgstr "雜湊函式可以輸出的最大摘要大小。" -#: ../../library/hashlib.rst:508 +#: ../../library/hashlib.rst:513 msgid "Examples" msgstr "範例" -#: ../../library/hashlib.rst:511 +#: ../../library/hashlib.rst:516 msgid "Simple hashing" msgstr "簡單雜湊" -#: ../../library/hashlib.rst:513 +#: ../../library/hashlib.rst:518 msgid "" "To calculate hash of some data, you should first construct a hash object by " "calling the appropriate constructor function (:func:`blake2b` or :func:" @@ -785,7 +797,7 @@ msgstr "" "update` 來以資料對它更新,最後透過呼叫 :meth:`~hash.digest`\\ (或對於十六進" "位編碼字串則為 :meth:`~hash.hexdigest`)從物件中獲得摘要。" -#: ../../library/hashlib.rst:526 +#: ../../library/hashlib.rst:531 msgid "" "As a shortcut, you can pass the first chunk of data to update directly to " "the constructor as the positional argument:" @@ -793,17 +805,17 @@ msgstr "" "作為一個快捷方式,你可以將要更新的第一個資料塊作為位置引數直接傳遞給建構函" "式:" -#: ../../library/hashlib.rst:533 +#: ../../library/hashlib.rst:538 msgid "" "You can call :meth:`hash.update` as many times as you need to iteratively " "update the hash:" msgstr "你可以根據需求來多次呼叫 :meth:`hash.update` 以疊代更新雜湊:" -#: ../../library/hashlib.rst:547 +#: ../../library/hashlib.rst:552 msgid "Using different digest sizes" msgstr "使用不同的摘要大小" -#: ../../library/hashlib.rst:549 +#: ../../library/hashlib.rst:554 msgid "" "BLAKE2 has configurable size of digests up to 64 bytes for BLAKE2b and up to " "32 bytes for BLAKE2s. For example, to replace SHA-1 with BLAKE2b without " @@ -813,7 +825,7 @@ msgstr "" "組。例如,要在不改變輸出大小的情況下用 BLAKE2b 替換 SHA-1,我們可以指定 " "BLAKE2b 生成 20 位元組的摘要:" -#: ../../library/hashlib.rst:563 +#: ../../library/hashlib.rst:568 msgid "" "Hash objects with different digest sizes have completely different outputs " "(shorter hashes are *not* prefixes of longer hashes); BLAKE2b and BLAKE2s " @@ -822,11 +834,11 @@ msgstr "" "具有不同摘要大小的雜湊物件具有完全不同的輸出(較短的雜湊值\\ *不是*\\ 較長雜" "湊值的前綴);即使輸出長度相同,BLAKE2b 和 BLAKE2s 也會產生不同的輸出:" -#: ../../library/hashlib.rst:579 +#: ../../library/hashlib.rst:584 msgid "Keyed hashing" msgstr "密鑰雜湊 (Keyed hashing)" -#: ../../library/hashlib.rst:581 +#: ../../library/hashlib.rst:586 msgid "" "Keyed hashing can be used for authentication as a faster and simpler " "replacement for `Hash-based message authentication code >> from hashlib import blake2b\n" ">>> h = blake2b(key=b'pseudorandom key', digest_size=16)\n" @@ -860,7 +872,7 @@ msgstr "" ">>> h.hexdigest()\n" "'3d363ff7401e02026f4a4687d4863ced'" -#: ../../library/hashlib.rst:597 +#: ../../library/hashlib.rst:602 msgid "" "As a practical example, a web application can symmetrically sign cookies " "sent to users and later verify them to make sure they weren't tampered with::" @@ -868,7 +880,7 @@ msgstr "" "舉一個實際的例子,網頁應用程式可以對發送給使用者的 cookie 進行對稱簽名 " "(symmetrically sign),然後驗證它們以確保它們沒有被篡改: ::" -#: ../../library/hashlib.rst:600 +#: ../../library/hashlib.rst:605 msgid "" ">>> from hashlib import blake2b\n" ">>> from hmac import compare_digest\n" @@ -922,7 +934,7 @@ msgstr "" ">>> verify(cookie, b'0102030405060708090a0b0c0d0e0f00')\n" "False" -#: ../../library/hashlib.rst:626 +#: ../../library/hashlib.rst:631 msgid "" "Even though there's a native keyed hashing mode, BLAKE2 can, of course, be " "used in HMAC construction with :mod:`hmac` module::" @@ -930,7 +942,7 @@ msgstr "" "儘管有原生密鑰雜湊模式,BLAKE2 還是可以透過 :mod:`hmac` 模組用於建構 " "HMAC: ::" -#: ../../library/hashlib.rst:629 +#: ../../library/hashlib.rst:634 msgid "" ">>> import hmac, hashlib\n" ">>> m = hmac.new(b'secret key', digestmod=hashlib.blake2s)\n" @@ -944,11 +956,11 @@ msgstr "" ">>> m.hexdigest()\n" "'e3c8102868d28b5ff85fc35dda07329970d1a01e273c37481326fe0c861c8142'" -#: ../../library/hashlib.rst:637 +#: ../../library/hashlib.rst:642 msgid "Randomized hashing" msgstr "隨機雜湊 (Randomized hashing)" -#: ../../library/hashlib.rst:639 +#: ../../library/hashlib.rst:644 msgid "" "By setting *salt* parameter users can introduce randomization to the hash " "function. Randomized hashing is useful for protecting against collision " @@ -957,7 +969,7 @@ msgstr "" "透過設定 *salt* 參數,使用者可以向雜湊函式引入隨機化。隨機雜湊在防止針對數位" "簽章中雜湊函式的碰撞攻擊 (collision attacks) 非常有用。" -#: ../../library/hashlib.rst:643 +#: ../../library/hashlib.rst:648 msgid "" "Randomized hashing is designed for situations where one party, the message " "preparer, generates all or part of a message to be signed by a second party, " @@ -988,7 +1000,7 @@ msgstr "" "的所有部分都是由簽名者所準備好的,使用隨機雜湊可能會降低數位簽章提供的安全" "性。" -#: ../../library/hashlib.rst:662 +#: ../../library/hashlib.rst:667 msgid "" "(`NIST SP-800-106 \"Randomized Hashing for Digital Signatures\" `_)" @@ -996,7 +1008,7 @@ msgstr "" "(`NIST SP-800-106 「數位簽章的隨機雜湊 (Randomized Hashing for Digital " "Signatures)」 `_)" -#: ../../library/hashlib.rst:665 +#: ../../library/hashlib.rst:670 msgid "" "In BLAKE2 the salt is processed as a one-time input to the hash function " "during initialization, rather than as an input to each compression function." @@ -1004,7 +1016,7 @@ msgstr "" "在 BLAKE2 中,鹽在初始化期間作為雜湊函式的一次性輸入被處理,而不是作為每個壓" "縮函式的輸入。" -#: ../../library/hashlib.rst:670 +#: ../../library/hashlib.rst:675 msgid "" "*Salted hashing* (or just hashing) with BLAKE2 or any other general-purpose " "cryptographic hash function, such as SHA-256, is not suitable for hashing " @@ -1015,11 +1027,11 @@ msgstr "" "純雜湊)不適合對密碼進行雜湊處理。有關更多資訊,請參閱 `BLAKE2 FAQ `_ 。" -#: ../../library/hashlib.rst:693 +#: ../../library/hashlib.rst:698 msgid "Personalization" msgstr "個人化" -#: ../../library/hashlib.rst:695 +#: ../../library/hashlib.rst:700 msgid "" "Sometimes it is useful to force hash function to produce different digests " "for the same input for different purposes. Quoting the authors of the Skein " @@ -1028,7 +1040,7 @@ msgstr "" "有時候強制雜湊函式為不同目的的相同輸入生成不同的摘要是很有用的。引用 Skein 雜" "湊函式的作者的話:" -#: ../../library/hashlib.rst:699 +#: ../../library/hashlib.rst:704 msgid "" "We recommend that all application designers seriously consider doing this; " "we have seen many protocols where a hash that is computed in one part of the " @@ -1042,7 +1054,7 @@ msgstr "" "關的資料上完成的,並且攻擊者可以強制應用程式將雜湊輸入設為相同的。對協定中使" "用的每個雜湊函式進行個人化可以立即阻止此類攻擊。" -#: ../../library/hashlib.rst:706 +#: ../../library/hashlib.rst:711 msgid "" "(`The Skein Hash Function Family `_, p. 21)" @@ -1050,11 +1062,11 @@ msgstr "" "(`Skein 雜湊函式系列 `_,第 21 頁)" -#: ../../library/hashlib.rst:710 +#: ../../library/hashlib.rst:715 msgid "BLAKE2 can be personalized by passing bytes to the *person* argument::" msgstr "BLAKE2 可以透過將位元組傳遞給 *person* 引數來做個人化: ::" -#: ../../library/hashlib.rst:712 +#: ../../library/hashlib.rst:717 msgid "" ">>> from hashlib import blake2b\n" ">>> FILES_HASH_PERSON = b'MyApp Files Hash'\n" @@ -1080,21 +1092,21 @@ msgstr "" ">>> h.hexdigest()\n" "'cf68fb5761b9c44e7878bfb2c4c9aea52264a80b75005e65619778de59f383a3'" -#: ../../library/hashlib.rst:724 +#: ../../library/hashlib.rst:729 msgid "" "Personalization together with the keyed mode can also be used to derive " "different keys from a single one." msgstr "個人化與密鑰模式還可以一起用於從單個密鑰得出不同的密鑰。" -#: ../../library/hashlib.rst:738 +#: ../../library/hashlib.rst:743 msgid "Tree mode" msgstr "樹狀模式" -#: ../../library/hashlib.rst:740 +#: ../../library/hashlib.rst:745 msgid "Here's an example of hashing a minimal tree with two leaf nodes::" msgstr "下面是對具有兩個葉節點的最小樹進行雜湊處理的範例: ::" -#: ../../library/hashlib.rst:742 +#: ../../library/hashlib.rst:747 msgid "" " 10\n" " / \\\n" @@ -1104,13 +1116,13 @@ msgstr "" " / \\\n" "00 01" -#: ../../library/hashlib.rst:746 +#: ../../library/hashlib.rst:751 msgid "" "This example uses 64-byte internal digests, and returns the 32-byte final " "digest::" msgstr "此範例使用 64-byte 內部摘要,並回傳 32-byte 最終摘要: ::" -#: ../../library/hashlib.rst:749 +#: ../../library/hashlib.rst:754 msgid "" ">>> from hashlib import blake2b\n" ">>>\n" @@ -1164,11 +1176,11 @@ msgstr "" ">>> h10.hexdigest()\n" "'3ad2a9b37c6070e374c7a8c508fe20ca86b6ed54e286e93a0318e95e881db5aa'" -#: ../../library/hashlib.rst:776 +#: ../../library/hashlib.rst:781 msgid "Credits" msgstr "製作人員" -#: ../../library/hashlib.rst:778 +#: ../../library/hashlib.rst:783 msgid "" "BLAKE2_ was designed by *Jean-Philippe Aumasson*, *Samuel Neves*, *Zooko " "Wilcox-O'Hearn*, and *Christian Winnerlein* based on SHA-3_ finalist BLAKE_ " @@ -1180,13 +1192,13 @@ msgstr "" "Henzen*、*Willi Meier* 和 *Raphael C.-W. Phan* 所建立的 SHA-3_ 最終版本 " "BLAKE_。" -#: ../../library/hashlib.rst:783 +#: ../../library/hashlib.rst:788 msgid "" "It uses core algorithm from ChaCha_ cipher designed by *Daniel J. " "Bernstein*." msgstr "它使用 *Daniel J. Bernstein* 設計的 ChaCha_ 密碼的核心演算法。" -#: ../../library/hashlib.rst:785 +#: ../../library/hashlib.rst:790 msgid "" "The stdlib implementation is based on pyblake2_ module. It was written by " "*Dmitry Chestnykh* based on C implementation written by *Samuel Neves*. The " @@ -1196,17 +1208,17 @@ msgstr "" "Neves* 的 C 版本實作為基礎所編寫的。該文件是由 *Dmitry Chestnykh* 編寫並從 " "pyblake2_ 複製過來的。" -#: ../../library/hashlib.rst:789 +#: ../../library/hashlib.rst:794 msgid "The C code was partly rewritten for Python by *Christian Heimes*." msgstr "*Christian Heimes* 為 Python 重寫了部分 C 程式碼。" -#: ../../library/hashlib.rst:791 +#: ../../library/hashlib.rst:796 msgid "" "The following public domain dedication applies for both C hash function " "implementation, extension code, and this documentation:" msgstr "以下公開領域貢獻適用於 C 雜湊函式實作、擴充程式碼和此文件:" -#: ../../library/hashlib.rst:794 +#: ../../library/hashlib.rst:799 msgid "" "To the extent possible under law, the author(s) have dedicated all copyright " "and related and neighboring rights to this software to the public domain " @@ -1215,7 +1227,7 @@ msgstr "" "在法律允許的範圍內,作者已將該軟體的所有版權以及相關和鄰接權利奉獻給全球的公" "開領域。該軟體的發布沒有任何授權 (warranty)。" -#: ../../library/hashlib.rst:798 +#: ../../library/hashlib.rst:803 msgid "" "You should have received a copy of the CC0 Public Domain Dedication along " "with this software. If not, see https://creativecommons.org/publicdomain/" @@ -1225,7 +1237,7 @@ msgstr "" "Dedication) 的副本。如果沒有,請參閱 https://creativecommons.org/" "publicdomain/zero/1.0/ 。" -#: ../../library/hashlib.rst:802 +#: ../../library/hashlib.rst:807 msgid "" "The following people have helped with development or contributed their " "changes to the project and the public domain according to the Creative " @@ -1234,55 +1246,55 @@ msgstr "" "以下人員根據創用 CC 通用公眾領域貢獻宣告 1.0 (Creative Commons Public Domain " "Dedication 1.0 Universal) 於專案和公開領域做出了開發或貢獻:" -#: ../../library/hashlib.rst:806 +#: ../../library/hashlib.rst:811 msgid "*Alexandr Sokolovskiy*" msgstr "*Alexandr Sokolovskiy*" -#: ../../library/hashlib.rst:827 +#: ../../library/hashlib.rst:832 msgid "Module :mod:`hmac`" msgstr ":mod:`hmac` 模組" -#: ../../library/hashlib.rst:828 +#: ../../library/hashlib.rst:833 msgid "A module to generate message authentication codes using hashes." msgstr "使用雜湊生成訊息驗證程式碼的模組。" -#: ../../library/hashlib.rst:830 +#: ../../library/hashlib.rst:835 msgid "Module :mod:`base64`" msgstr ":mod:`base64` 模組" -#: ../../library/hashlib.rst:831 +#: ../../library/hashlib.rst:836 msgid "Another way to encode binary hashes for non-binary environments." msgstr "另一種在非二進位環境中編碼二進位雜湊的方法。" -#: ../../library/hashlib.rst:833 +#: ../../library/hashlib.rst:838 msgid "https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf" msgstr "https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf" -#: ../../library/hashlib.rst:834 +#: ../../library/hashlib.rst:839 msgid "The FIPS 180-4 publication on Secure Hash Algorithms." msgstr "有關安全雜湊演算法的 FIPS 180-4 出版物。" -#: ../../library/hashlib.rst:836 +#: ../../library/hashlib.rst:841 msgid "https://csrc.nist.gov/pubs/fips/202/final" msgstr "https://csrc.nist.gov/pubs/fips/202/final" -#: ../../library/hashlib.rst:837 +#: ../../library/hashlib.rst:842 msgid "The FIPS 202 publication on the SHA-3 Standard." msgstr "有關 SHA-3 標準的 FIPS 202 出版物。" -#: ../../library/hashlib.rst:839 +#: ../../library/hashlib.rst:844 msgid "https://www.blake2.net/" msgstr "https://www.blake2.net/" -#: ../../library/hashlib.rst:840 +#: ../../library/hashlib.rst:845 msgid "Official BLAKE2 website." msgstr "BLAKE2 官方網站。" -#: ../../library/hashlib.rst:842 +#: ../../library/hashlib.rst:847 msgid "https://en.wikipedia.org/wiki/Cryptographic_hash_function" msgstr "https://en.wikipedia.org/wiki/Cryptographic_hash_function" -#: ../../library/hashlib.rst:843 +#: ../../library/hashlib.rst:848 msgid "" "Wikipedia article with information on which algorithms have known issues and " "what that means regarding their use." @@ -1290,29 +1302,29 @@ msgstr "" "包含有關哪些演算法存在已知問題以及這些問題對其使用意味著什麼資訊的維基百科文" "章。" -#: ../../library/hashlib.rst:846 +#: ../../library/hashlib.rst:851 msgid "https://www.ietf.org/rfc/rfc8018.txt" msgstr "https://www.ietf.org/rfc/rfc8018.txt" -#: ../../library/hashlib.rst:847 +#: ../../library/hashlib.rst:852 msgid "PKCS #5: Password-Based Cryptography Specification Version 2.1" msgstr "PKCS #5:基於密碼的加密規範版本 2.1" -#: ../../library/hashlib.rst:849 +#: ../../library/hashlib.rst:854 msgid "" "https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf" msgstr "" "https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf" -#: ../../library/hashlib.rst:850 +#: ../../library/hashlib.rst:855 msgid "NIST Recommendation for Password-Based Key Derivation." msgstr "NIST(美國國家標準技術研究院)針對基於密碼的密鑰衍生的建議。" -#: ../../library/hashlib.rst:12 +#: ../../library/hashlib.rst:9 msgid "message digest, MD5" msgstr "message digest(訊息摘要)、MD5" -#: ../../library/hashlib.rst:12 +#: ../../library/hashlib.rst:9 msgid "" "secure hash algorithm, SHA1, SHA2, SHA224, SHA256, SHA384, SHA512, SHA3, " "Shake, Blake2" @@ -1320,14 +1332,14 @@ msgstr "" "安全雜湊演算法、SHA1、SHA2、SHA224、SHA256、SHA384、SHA512、SHA3、Shake、" "Blake2" -#: ../../library/hashlib.rst:53 +#: ../../library/hashlib.rst:50 msgid "OpenSSL" msgstr "OpenSSL" -#: ../../library/hashlib.rst:53 +#: ../../library/hashlib.rst:50 msgid "(use in module hashlib)" msgstr "(使用於 hashlib 模組中)" -#: ../../library/hashlib.rst:377 +#: ../../library/hashlib.rst:382 msgid "blake2b, blake2s" msgstr "blake2b, blake2s" diff --git a/library/heapq.po b/library/heapq.po index 2af9543ea9f..75f2962a4b6 100644 --- a/library/heapq.po +++ b/library/heapq.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-14 00:16+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-07-01 18:20+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!heapq` --- Heap queue algorithm" msgstr ":mod:`!heapq` --- 堆積佇列 (heap queue) 演算法" -#: ../../library/heapq.rst:12 +#: ../../library/heapq.rst:7 msgid "**Source code:** :source:`Lib/heapq.py`" msgstr "**原始碼:**\\ :source:`Lib/heapq.py`" -#: ../../library/heapq.rst:16 +#: ../../library/heapq.rst:11 msgid "" "This module provides an implementation of the heap queue algorithm, also " "known as the priority queue algorithm." @@ -36,7 +36,7 @@ msgstr "" "這個模組實作了堆積佇列 (heap queue) 演算法,亦被稱為優先佇列 (priority " "queue) 演算法。" -#: ../../library/heapq.rst:19 +#: ../../library/heapq.rst:14 msgid "" "Min-heaps are binary trees for which every parent node has a value less than " "or equal to any of its children. We refer to this condition as the heap " @@ -45,7 +45,7 @@ msgstr "" "最小堆積 (min-heap) 是一顆二元樹,樹上每個父節點的值都小於或等於其子節點的" "值。我們將這種情況稱為堆積性質不變 (heap invariant)。" -#: ../../library/heapq.rst:23 +#: ../../library/heapq.rst:18 msgid "" "For min-heaps, this implementation uses lists for which ``heap[k] <= " "heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k* for which the " @@ -57,7 +57,7 @@ msgstr "" "<= heap[2*k+1]`` 和 ``heap[k] <= heap[2*k+2]``。元素是從零開始計數。最小堆積" "有一個有趣的性質:最小的元素永遠在根節點 ``heap[0]``。" -#: ../../library/heapq.rst:29 +#: ../../library/heapq.rst:24 msgid "" "Max-heaps satisfy the reverse invariant: every parent node has a value " "*greater* than any of its children. These are implemented as lists for " @@ -67,7 +67,7 @@ msgid "" "max-heap invariant." msgstr "" -#: ../../library/heapq.rst:36 +#: ../../library/heapq.rst:31 msgid "" "The :mod:`!heapq` API differs from textbook heap algorithms in two aspects: " "(a) We use zero-based indexing. This makes the relationship between the " @@ -83,7 +83,7 @@ msgstr "" "合原地排序。我們的實作偏向於最小堆積,因為它們更符合 Python :class:`串列 " "`。" -#: ../../library/heapq.rst:43 +#: ../../library/heapq.rst:38 msgid "" "These two aspects make it possible to view the heap as a regular Python list " "without surprises: ``heap[0]`` is the smallest item, and ``heap.sort()`` " @@ -92,20 +92,20 @@ msgstr "" "這兩個特性使得可以將堆積視為一個普通的 Python 串列而不會有意外:``heap[0]`` " "是最小的元素,而 ``heap.sort()`` 維持堆積性質不變!" -#: ../../library/heapq.rst:47 +#: ../../library/heapq.rst:42 msgid "" "Like :meth:`list.sort`, this implementation uses only the ``<`` operator for " "comparisons, for both min-heaps and max-heaps." msgstr "" -#: ../../library/heapq.rst:50 +#: ../../library/heapq.rst:45 msgid "" "In the API below, and in this documentation, the unqualified term *heap* " "generally refers to a min-heap. The API for max-heaps is named using a " "``_max`` suffix." msgstr "" -#: ../../library/heapq.rst:54 +#: ../../library/heapq.rst:49 msgid "" "To create a heap, use a list initialized as ``[]``, or transform an existing " "list into a min-heap or max-heap using the :func:`heapify` or :func:" @@ -114,20 +114,20 @@ msgstr "" "要建立一個堆積,使用初始化為 ``[]`` 的串列,或者分別使用 :func:`heapify` 或 :" "func:`heapify_max` 函式將現有的串列轉換為最小堆積或最大堆積。" -#: ../../library/heapq.rst:58 +#: ../../library/heapq.rst:53 msgid "The following functions are provided for min-heaps:" msgstr "提供了以下針對最小堆積的函式:" -#: ../../library/heapq.rst:63 +#: ../../library/heapq.rst:58 msgid "Transform list *x* into a min-heap, in-place, in linear time." msgstr "在線性時間內將串列 *x* 原地轉換為最小堆積。" -#: ../../library/heapq.rst:68 +#: ../../library/heapq.rst:63 msgid "" "Push the value *item* onto the *heap*, maintaining the min-heap invariant." msgstr "將值 *item* 推入 *heap*,並維持最小堆積性質不變。" -#: ../../library/heapq.rst:73 +#: ../../library/heapq.rst:68 msgid "" "Pop and return the smallest item from the *heap*, maintaining the min-heap " "invariant. If the heap is empty, :exc:`IndexError` is raised. To access " @@ -136,7 +136,7 @@ msgstr "" "從 *heap* 取出並回傳最小的元素,維持最小堆積性質不變。如果堆積為空,會引發 :" "exc:`IndexError`。若要在不取出的情況下存取最小元素,請使用 ``heap[0]``。" -#: ../../library/heapq.rst:80 +#: ../../library/heapq.rst:75 msgid "" "Push *item* on the heap, then pop and return the smallest item from the " "*heap*. The combined action runs more efficiently than :func:`heappush` " @@ -145,7 +145,7 @@ msgstr "" "將 *item* 放入 heap ,接著從 *heap* 取出並回傳最小的元素。這個組合函式比呼" "叫 :func:`heappush` 之後呼叫 :func:`heappop` 更有效率。" -#: ../../library/heapq.rst:87 +#: ../../library/heapq.rst:82 msgid "" "Pop and return the smallest item from the *heap*, and also push the new " "*item*. The heap size doesn't change. If the heap is empty, :exc:" @@ -154,7 +154,7 @@ msgstr "" "從 *heap* 取出並回傳最小的元素,接著將新的 *item* 放進heap。heap 的大小不會改" "變。如果 heap 是空的會產生 :exc:`IndexError` 錯誤。" -#: ../../library/heapq.rst:90 +#: ../../library/heapq.rst:85 msgid "" "This one step operation is more efficient than a :func:`heappop` followed " "by :func:`heappush` and can be more appropriate when using a fixed-size " @@ -165,7 +165,7 @@ msgstr "" "率,並在維護 heap 的大小不變時更為適當,取出/放入的組合函式一定會從 heap 回傳" "一個元素並用 *item* 取代他。" -#: ../../library/heapq.rst:95 +#: ../../library/heapq.rst:90 msgid "" "The value returned may be larger than the *item* added. If that isn't " "desired, consider using :func:`heappushpop` instead. Its push/pop " @@ -176,21 +176,21 @@ msgstr "" "用 :func:`heappushpop` 替代,他會回傳 heap 的最小值和 *item* 兩個當中比較小的" "那個,並將大的留在 heap 內。" -#: ../../library/heapq.rst:101 +#: ../../library/heapq.rst:96 msgid "For max-heaps, the following functions are provided:" msgstr "提供以下針對最大堆積的函式:" -#: ../../library/heapq.rst:106 +#: ../../library/heapq.rst:101 msgid "Transform list *x* into a max-heap, in-place, in linear time." msgstr "在線性時間內將串列 *x* 原地轉換為最大堆積。" -#: ../../library/heapq.rst:113 +#: ../../library/heapq.rst:108 msgid "" "Push the value *item* onto the max-heap *heap*, maintaining the max-heap " "invariant." msgstr "將值 *item* 推入最大堆積 *heap*,維持最大堆積性質不變。" -#: ../../library/heapq.rst:121 +#: ../../library/heapq.rst:116 msgid "" "Pop and return the largest item from the max-heap *heap*, maintaining the " "max-heap invariant. If the max-heap is empty, :exc:`IndexError` is raised. " @@ -200,7 +200,7 @@ msgstr "" "空,會引發 :exc:`IndexError`。若要在不取出的情況下存取最大元素,請使用 " "``maxheap[0]``。" -#: ../../library/heapq.rst:130 +#: ../../library/heapq.rst:125 msgid "" "Push *item* on the max-heap *heap*, then pop and return the largest item " "from *heap*. The combined action runs more efficiently than :func:" @@ -209,7 +209,7 @@ msgstr "" "將 *item* 推入 max-heap *heap*,然後取出並回傳 *heap* 中最大的元素。這個組合" "動作比先呼叫 :func:`heappush_max` 再單獨呼叫 :func:`heappop_max` 更有效率。" -#: ../../library/heapq.rst:140 +#: ../../library/heapq.rst:135 msgid "" "Pop and return the largest item from the max-heap *heap* and also push the " "new *item*. The max-heap size doesn't change. If the max-heap is empty, :exc:" @@ -218,17 +218,17 @@ msgstr "" "從最大堆積 *heap* 取出並回傳最大的元素,同時推入新的 *item*。最大堆積的大小不" "會改變。如果最大堆積為空,會引發 :exc:`IndexError`。" -#: ../../library/heapq.rst:145 +#: ../../library/heapq.rst:140 msgid "" "The value returned may be smaller than the *item* added. Refer to the " "analogous function :func:`heapreplace` for detailed usage notes." msgstr "" -#: ../../library/heapq.rst:151 +#: ../../library/heapq.rst:146 msgid "The module also offers three general purpose functions based on heaps." msgstr "這個模組也提供三個利用 heap 實作的一般用途函式" -#: ../../library/heapq.rst:156 +#: ../../library/heapq.rst:151 msgid "" "Merge multiple sorted inputs into a single sorted output (for example, merge " "timestamped entries from multiple log files). Returns an :term:`iterator` " @@ -237,7 +237,7 @@ msgstr "" "合併多個已排序的輸入並產生單一且已排序的輸出(舉例:合併來自多個 log 檔中有時" "間戳記的項目)。回傳一個 :term:`iterator` 包含已經排序的值。" -#: ../../library/heapq.rst:160 +#: ../../library/heapq.rst:155 msgid "" "Similar to ``sorted(itertools.chain(*iterables))`` but returns an iterable, " "does not pull the data into memory all at once, and assumes that each of the " @@ -246,12 +246,12 @@ msgstr "" "和 ``sorted(itertools.chain(*iterables))`` 類似但回傳值是一個 iterable ,不會" "一次把所有資料都放進記憶體中,並且假設每一個輸入都已經(由小到大)排序過了。" -#: ../../library/heapq.rst:164 +#: ../../library/heapq.rst:159 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "有兩個選用參數,指定時必須被當作關鍵字參數指定。" -#: ../../library/heapq.rst:166 +#: ../../library/heapq.rst:161 msgid "" "*key* specifies a :term:`key function` of one argument that is used to " "extract a comparison key from each input element. The default value is " @@ -260,7 +260,7 @@ msgstr "" "*key* 參數指定了一個 :term:`key function` 引數,用來從每一個輸入的元素中決定" "一個比較的依據。預設的值是 ``None`` (直接比較元素)。" -#: ../../library/heapq.rst:170 +#: ../../library/heapq.rst:165 msgid "" "*reverse* is a boolean value. If set to ``True``, then the input elements " "are merged as if each comparison were reversed. To achieve behavior similar " @@ -271,11 +271,11 @@ msgstr "" "進行合併。為了達成類似 ``sorted(itertools.chain(*iterables), reverse=True)`` " "的行為,所有 iterables 必須由大到小排序。" -#: ../../library/heapq.rst:175 +#: ../../library/heapq.rst:170 msgid "Added the optional *key* and *reverse* parameters." msgstr "加入選用參數 *key* 和 *reverse* 。" -#: ../../library/heapq.rst:181 +#: ../../library/heapq.rst:176 msgid "" "Return a list with the *n* largest elements from the dataset defined by " "*iterable*. *key*, if provided, specifies a function of one argument that " @@ -288,7 +288,7 @@ msgstr "" "的依據(例如 ``key=str.lower`` )。效果相當於 ``sorted(iterable, key=key, " "reverse=True)[:n]`` 。" -#: ../../library/heapq.rst:190 +#: ../../library/heapq.rst:185 msgid "" "Return a list with the *n* smallest elements from the dataset defined by " "*iterable*. *key*, if provided, specifies a function of one argument that " @@ -301,7 +301,7 @@ msgstr "" "的依據(例如 ``key=str.lower`` )。效果相當於 ``sorted(iterable, key=key)[:" "n]`` 。" -#: ../../library/heapq.rst:196 +#: ../../library/heapq.rst:191 msgid "" "The latter two functions perform best for smaller values of *n*. For larger " "values, it is more efficient to use the :func:`sorted` function. Also, when " @@ -314,11 +314,11 @@ msgstr "" "和 :func:`max` 會有更好的效率。如果需要重複使用這些函式,可以考慮將 iterable " "轉成真正的 heap 。" -#: ../../library/heapq.rst:204 +#: ../../library/heapq.rst:199 msgid "Basic Examples" msgstr "基礎範例" -#: ../../library/heapq.rst:206 +#: ../../library/heapq.rst:201 msgid "" "A `heapsort `_ can be implemented by " "pushing all values onto a heap and then popping off the smallest values one " @@ -327,7 +327,7 @@ msgstr "" "`堆積排序 (heapsort) `_ 可以透過將所" "有的值推入一個 heap,並且從 heap 中一個接一個彈出最小元素來實作: ::" -#: ../../library/heapq.rst:210 +#: ../../library/heapq.rst:205 msgid "" ">>> def heapsort(iterable):\n" "... h = []\n" @@ -347,7 +347,7 @@ msgstr "" ">>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" -#: ../../library/heapq.rst:219 +#: ../../library/heapq.rst:214 msgid "" "This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this " "implementation is not stable." @@ -355,7 +355,7 @@ msgstr "" "雖然類似 ``sorted(iterable)`` ,但跟 :func:`sorted` 不同的是,這個實作不是 " "stable 的排序。" -#: ../../library/heapq.rst:222 +#: ../../library/heapq.rst:217 msgid "" "Heap elements can be tuples. This is useful for assigning comparison values " "(such as task priorities) alongside the main record being tracked::" @@ -363,7 +363,7 @@ msgstr "" "Heap 中的元素可以是 tuple 。這有利於將要比較的值(例如一個 task 的優先度)和" "主要資料放在一起排序: ::" -#: ../../library/heapq.rst:225 +#: ../../library/heapq.rst:220 msgid "" ">>> h = []\n" ">>> heappush(h, (5, 'write code'))\n" @@ -381,11 +381,11 @@ msgstr "" ">>> heappop(h)\n" "(1, 'write spec')" -#: ../../library/heapq.rst:235 +#: ../../library/heapq.rst:230 msgid "Other Applications" msgstr "" -#: ../../library/heapq.rst:237 +#: ../../library/heapq.rst:232 msgid "" "`Medians `_ are a measure of central " "tendency for a set of numbers. In distributions skewed by outliers, the " @@ -394,7 +394,7 @@ msgid "" "Online_algorithm>`_ that updates continuously as new data arrives." msgstr "" -#: ../../library/heapq.rst:244 +#: ../../library/heapq.rst:239 msgid "" "A running median can be efficiently implemented by balancing two heaps, a " "max-heap for values at or below the midpoint and a min-heap for values above " @@ -403,7 +403,7 @@ msgid "" "the larger heap::" msgstr "" -#: ../../library/heapq.rst:250 +#: ../../library/heapq.rst:245 msgid "" "def running_median(iterable):\n" " \"Yields the cumulative median of values seen so far.\"\n" @@ -420,11 +420,11 @@ msgid "" " yield (lo[0] + hi[0]) / 2" msgstr "" -#: ../../library/heapq.rst:264 +#: ../../library/heapq.rst:259 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/heapq.rst:266 +#: ../../library/heapq.rst:261 msgid "" ">>> list(running_median([5.0, 9.0, 4.0, 12.0, 8.0, 9.0]))\n" "[5.0, 7.0, 5.0, 7.0, 8.0, 8.5]" @@ -432,11 +432,11 @@ msgstr "" ">>> list(running_median([5.0, 9.0, 4.0, 12.0, 8.0, 9.0]))\n" "[5.0, 7.0, 5.0, 7.0, 8.0, 8.5]" -#: ../../library/heapq.rst:271 +#: ../../library/heapq.rst:266 msgid "Priority Queue Implementation Notes" msgstr "優先佇列實作細節" -#: ../../library/heapq.rst:273 +#: ../../library/heapq.rst:268 msgid "" "A `priority queue `_ is common " "use for a heap, and it presents several implementation challenges:" @@ -444,7 +444,7 @@ msgstr "" "`優先佇列 (priority queue) `_ " "是 heap 的常見用途之一,實作優先佇列伴隨著下列挑戰:" -#: ../../library/heapq.rst:276 +#: ../../library/heapq.rst:271 msgid "" "Sort stability: how do you get two tasks with equal priorities to be " "returned in the order they were originally added?" @@ -452,7 +452,7 @@ msgstr "" "排序的穩定性:如何將兩個擁有相同優先次序 (priority) 的 task 按照他們被加入的" "順序回傳?" -#: ../../library/heapq.rst:279 +#: ../../library/heapq.rst:274 msgid "" "Tuple comparison breaks for (priority, task) pairs if the priorities are " "equal and the tasks do not have a default comparison order." @@ -460,21 +460,21 @@ msgstr "" "Tuple的排序在某些情況下會壞掉,例如當 Tuple (priority, task) 的 priorities 相" "等且 tasks 沒有一個預設的排序時。" -#: ../../library/heapq.rst:282 +#: ../../library/heapq.rst:277 msgid "" "If the priority of a task changes, how do you move it to a new position in " "the heap?" msgstr "" "當一個 heap 中 task 的 priority 改變時,如何將它移到 heap 正確的位置上?" -#: ../../library/heapq.rst:285 +#: ../../library/heapq.rst:280 msgid "" "Or if a pending task needs to be deleted, how do you find it and remove it " "from the queue?" msgstr "" "或者一個還沒被解決的 task 需要被刪除時,要如何從佇列中找到並刪除指定的 task?" -#: ../../library/heapq.rst:288 +#: ../../library/heapq.rst:283 msgid "" "A solution to the first two challenges is to store entries as 3-element list " "including the priority, an entry count, and the task. The entry count " @@ -487,7 +487,7 @@ msgstr "" "入的順序排序。因為沒有任何兩個 task 擁有相同的 entry count,所以永遠不會直接" "使用 task 做比較。" -#: ../../library/heapq.rst:294 +#: ../../library/heapq.rst:289 msgid "" "Another solution to the problem of non-comparable tasks is to create a " "wrapper class that ignores the task item and only compares the priority " @@ -496,7 +496,7 @@ msgstr "" "task 無法比較的另一個解決方案是建立一個包裝器類別,該類別忽略 task 項目,只比" "較優先等級: ::" -#: ../../library/heapq.rst:297 +#: ../../library/heapq.rst:292 msgid "" "from dataclasses import dataclass, field\n" "from typing import Any\n" @@ -514,7 +514,7 @@ msgstr "" " priority: int\n" " item: Any=field(compare=False)" -#: ../../library/heapq.rst:305 +#: ../../library/heapq.rst:300 msgid "" "The remaining challenges revolve around finding a pending task and making " "changes to its priority or removing it entirely. Finding a task can be done " @@ -523,7 +523,7 @@ msgstr "" "剩下的問題可以藉由找到要刪除的 task 並更改它的 priority 或者直接將它移除。尋" "找一個 task 可以使用一個 dictionary 指向佇列當中的 entry 。" -#: ../../library/heapq.rst:309 +#: ../../library/heapq.rst:304 msgid "" "Removing the entry or changing its priority is more difficult because it " "would break the heap structure invariants. So, a possible solution is to " @@ -533,7 +533,7 @@ msgstr "" "行的方案是將原本的 entry 做一個標記表示它已經被刪除,並新增一個擁有新的 " "priority 的 entry: ::" -#: ../../library/heapq.rst:313 +#: ../../library/heapq.rst:308 msgid "" "pq = [] # list of entries arranged in a heap\n" "entry_finder = {} # mapping of tasks to entries\n" @@ -591,11 +591,11 @@ msgstr "" " return task\n" " raise KeyError('從空的優先佇列中 pop 出元素')" -#: ../../library/heapq.rst:343 +#: ../../library/heapq.rst:338 msgid "Theory" msgstr "原理" -#: ../../library/heapq.rst:345 +#: ../../library/heapq.rst:340 msgid "" "Heaps are arrays for which ``a[k] <= a[2*k+1]`` and ``a[k] <= a[2*k+2]`` for " "all *k*, counting elements from 0. For the sake of comparison, non-existing " @@ -606,37 +606,19 @@ msgstr "" "和 ``a[k] <= a[2*k+2]`` 。為了方便比較,不存在的元素被視為無限大。Heap 的一個" "有趣的性質是:``a[0]`` 永遠是最小的元素。" -#: ../../library/heapq.rst:350 +#: ../../library/heapq.rst:345 msgid "" "The strange invariant above is meant to be an efficient memory " -"representation for a tournament. The numbers below are *k*, not ``a[k]``::" +"representation for a tournament. The numbers below are *k*, not ``a[k]``:" msgstr "" "上述乍看之下有些奇怪的不變式,是為了實作一個對記憶體來說有效率的方法,其表示" -"方式如同錦標賽一般。下列的數字為 *k*,而不是 ``a[k]``: ::" +"方式如同錦標賽一般。下列的數字為 *k*,而不是 ``a[k]``:" -#: ../../library/heapq.rst:353 -msgid "" -" 0\n" -"\n" -" 1 2\n" -"\n" -" 3 4 5 6\n" -"\n" -" 7 8 9 10 11 12 13 14\n" -"\n" -"15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30" +#: ../../library/heapq.rst:348 +msgid "Example (min-heap) binary tree." msgstr "" -" 0\n" -"\n" -" 1 2\n" -"\n" -" 3 4 5 6\n" -"\n" -" 7 8 9 10 11 12 13 14\n" -"\n" -"15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30" -#: ../../library/heapq.rst:363 +#: ../../library/heapq.rst:353 msgid "" "In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In a " "usual binary tournament we see in sports, each cell is the winner over the " @@ -655,7 +637,7 @@ msgstr "" "下方較低層級的另一個項目來取代它,至此規則變為一個單元以及它下方兩個單元,包" "含三個不同項目,但是最上方的單元「勝過」下方兩個單元。" -#: ../../library/heapq.rst:372 +#: ../../library/heapq.rst:362 msgid "" "If this heap invariant is protected at all time, index 0 is clearly the " "overall winner. The simplest algorithmic way to remove it and find the " @@ -671,7 +653,7 @@ msgstr "" "的複雜度顯然是樹的節點數目的對數級別。透過對所有項目疊代,可以得到一個複雜度" "為 *O*\\ (*n* log *n*) 的排序。" -#: ../../library/heapq.rst:379 +#: ../../library/heapq.rst:369 msgid "" "A nice feature of this sort is that you can efficiently insert new items " "while the sort is going on, provided that the inserted items are not " @@ -688,7 +670,7 @@ msgstr "" "時,因這些事件仍在等待進行,所以很容易將它們插入 heap 當中。因此, heap 是一" "個實現排程器的優秀資料結構(這就是我用以實作 MIDI 編曲器的方法 :-)。" -#: ../../library/heapq.rst:388 +#: ../../library/heapq.rst:378 msgid "" "Various structures for implementing schedulers have been extensively " "studied, and heaps are good for this, as they are reasonably speedy, the " @@ -700,7 +682,7 @@ msgstr "" "快,且速度幾乎不受其他因素影響,最壞情況與平均狀況差異無幾。也有其它整體說來" "更有效率的方法,然而它們的最壞情況可能會非常糟糕。" -#: ../../library/heapq.rst:394 +#: ../../library/heapq.rst:384 msgid "" "Heaps are also very useful in big disk sorts. You most probably all know " "that a big sort implies producing \"runs\" (which are pre-sorted sequences, " @@ -721,7 +703,7 @@ msgstr "" "於隨機產生的輸入,將可以產生長度兩倍於記憶體大小的 run。對於已模糊排序過的輸" "入,效果更好。" -#: ../../library/heapq.rst:404 +#: ../../library/heapq.rst:394 msgid "" "Moreover, if you output the 0'th item on disk and get an input which may not " "fit in the current tournament (because the value \"wins\" over the last " @@ -737,7 +719,7 @@ msgstr "" "大小增加的速度會與第一個 heap 減少的速度一致。當第一個 heap 完全消失時,你可" "以切換至第二個 heap 開啟一個新 run 。這真是個聰明且相當有效率的做法!" -#: ../../library/heapq.rst:412 +#: ../../library/heapq.rst:402 msgid "" "In a word, heaps are useful memory structures to know. I use them in a few " "applications, and I think it is good to keep a 'heap' module around. :-)" @@ -745,11 +727,11 @@ msgstr "" "總結來說,heap 是值得了解的有用記憶體結構。我在一些應用中使用它們,我認為能有" "一個 'heap' 模組是很棒的。:-)" -#: ../../library/heapq.rst:416 +#: ../../library/heapq.rst:406 msgid "Footnotes" msgstr "註解" -#: ../../library/heapq.rst:417 +#: ../../library/heapq.rst:407 msgid "" "The disk balancing algorithms which are current, nowadays, are more annoying " "than clever, and this is a consequence of the seeking capabilities of the " @@ -766,3 +748,24 @@ msgstr "" "可能是最有效率的(也就是盡可能更好地「推進」合併的過程)。有些磁帶甚至能夠向" "後讀取,這也被用來避免倒轉的時間。相信我,真正優秀的磁帶排序看起來相當壯觀!" "排序一直以來都是一門偉大的藝術!:-)" + +#~ msgid "" +#~ " 0\n" +#~ "\n" +#~ " 1 2\n" +#~ "\n" +#~ " 3 4 5 6\n" +#~ "\n" +#~ " 7 8 9 10 11 12 13 14\n" +#~ "\n" +#~ "15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30" +#~ msgstr "" +#~ " 0\n" +#~ "\n" +#~ " 1 2\n" +#~ "\n" +#~ " 3 4 5 6\n" +#~ "\n" +#~ " 7 8 9 10 11 12 13 14\n" +#~ "\n" +#~ "15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30" diff --git a/library/hmac.po b/library/hmac.po index 127397cc417..09446b96727 100644 --- a/library/hmac.po +++ b/library/hmac.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-04 00:15+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-03-30 00:16+0800\n" "Last-Translator: Phil Lin \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!hmac` --- Keyed-Hashing for Message Authentication" msgstr ":mod:`!hmac` --- 基於金鑰雜湊的訊息驗證" -#: ../../library/hmac.rst:10 +#: ../../library/hmac.rst:7 msgid "**Source code:** :source:`Lib/hmac.py`" msgstr "**原始碼:**\\ :source:`Lib/hmac.py`" -#: ../../library/hmac.rst:14 +#: ../../library/hmac.rst:11 msgid "" "This module implements the HMAC algorithm as described by :rfc:`2104`. The " "interface allows to use any hash function with a *fixed* digest size. In " @@ -39,7 +39,7 @@ msgstr "" "摘要 (digest) 長度的任意雜湊函式。要特別注意的是擴充輸出函式(如 SHAKE-128 " "或 SHAKE-256)不能與 HMAC 一起使用。" -#: ../../library/hmac.rst:22 +#: ../../library/hmac.rst:19 msgid "" "Return a new hmac object. *key* is a bytes or bytearray object giving the " "secret key. If *msg* is present, the method call ``update(msg)`` is made. " @@ -52,7 +52,7 @@ msgstr "" "所用的摘要名稱、摘要建構函式 (constructor) 或模組。它可以是適用於 :func:" "`hashlib.new` 的任何名稱。儘管該引數的位置在後,但它卻是必須的。" -#: ../../library/hmac.rst:28 +#: ../../library/hmac.rst:25 msgid "" "Parameter *key* can be a bytes or bytearray object. Parameter *msg* can be " "of any type supported by :mod:`hashlib`. Parameter *digestmod* can be the " @@ -61,7 +61,7 @@ msgstr "" "參數 *key* 可以為 bytes 或 bytearray 物件。參數 *msg* 可以為 :mod:`hashlib` " "所支援的任意型別。參數 *digestmod* 可以為雜湊演算法的名稱。" -#: ../../library/hmac.rst:33 +#: ../../library/hmac.rst:30 msgid "" "The *digestmod* argument is now required. Pass it as a keyword argument to " "avoid awkwardness when you do not have an initial *msg*." @@ -69,7 +69,7 @@ msgstr "" "*digestmod* 引數現在是必須的。請將其作為關鍵字引數傳入以避免當你沒有初始 " "*msg* 時導致的麻煩。" -#: ../../library/hmac.rst:40 +#: ../../library/hmac.rst:37 msgid "" "Return digest of *msg* for given secret *key* and *digest*. The function is " "equivalent to ``HMAC(key, msg, digest).digest()``, but uses an optimized C " @@ -82,7 +82,7 @@ msgstr "" "implementation),對放入記憶體的訊息能處理得更快。參數 *key*、*msg* 和 " "*digest* 在 :func:`~hmac.new` 中具有相同含義。" -#: ../../library/hmac.rst:46 +#: ../../library/hmac.rst:43 msgid "" "CPython implementation detail, the optimized C implementation is only used " "when *digest* is a string and name of a digest algorithm, which is supported " @@ -91,11 +91,11 @@ msgstr "" "作為 CPython 的實現細節,C 的最佳化實作只有當 *digest* 為字串並且是一個 " "OpenSSL 所支援的摘要演算法的名稱時才會被使用。" -#: ../../library/hmac.rst:55 +#: ../../library/hmac.rst:52 msgid "An HMAC object has the following methods:" msgstr "HMAC 物件具有下列方法 (method):" -#: ../../library/hmac.rst:59 +#: ../../library/hmac.rst:56 msgid "" "Update the hmac object with *msg*. Repeated calls are equivalent to a " "single call with the concatenation of all the arguments: ``m.update(a); m." @@ -104,11 +104,11 @@ msgstr "" "用 *msg* 來更新 hmac 物件。重複呼叫相當於單次呼叫並傳入所有引數的拼接結果:" "``m.update(a); m.update(b)`` 等價於 ``m.update(a + b)``。" -#: ../../library/hmac.rst:63 +#: ../../library/hmac.rst:60 msgid "Parameter *msg* can be of any type supported by :mod:`hashlib`." msgstr "參數 *msg* 可以是 :mod:`hashlib` 所支援的任何型別。" -#: ../../library/hmac.rst:69 +#: ../../library/hmac.rst:66 msgid "" "Return the digest of the bytes passed to the :meth:`update` method so far. " "This bytes object will be the same length as the *digest_size* of the digest " @@ -119,7 +119,7 @@ msgstr "" "給建構函式的摘要 *digest_size* 的長度相同。它可以包含 NUL bytes 以及 non-" "ASCII bytes。" -#: ../../library/hmac.rst:76 +#: ../../library/hmac.rst:73 msgid "" "When comparing the output of :meth:`digest` to an externally supplied digest " "during a verification routine, it is recommended to use the :func:" @@ -130,7 +130,7 @@ msgstr "" "較時,建議使用 :func:`compare_digest` 函式而不是 ``==`` 運算子以減少被定時攻" "擊時的漏洞。" -#: ../../library/hmac.rst:84 +#: ../../library/hmac.rst:81 msgid "" "Like :meth:`digest` except the digest is returned as a string twice the " "length containing only hexadecimal digits. This may be used to exchange the " @@ -139,7 +139,7 @@ msgstr "" "像是 :meth:`digest` 但摘要的回傳形式為兩倍長度的字串,且此字串只包含十六進位" "數位。這可以被用於在電子郵件或其他非二進位制環境中安全地交換數據。" -#: ../../library/hmac.rst:90 +#: ../../library/hmac.rst:87 msgid "" "When comparing the output of :meth:`hexdigest` to an externally supplied " "digest during a verification routine, it is recommended to use the :func:" @@ -150,7 +150,7 @@ msgstr "" "比較時,建議使用 :func:`compare_digest` 函式而不是 ``==`` 運算子以減少被定時" "攻擊時的漏洞。" -#: ../../library/hmac.rst:98 +#: ../../library/hmac.rst:95 msgid "" "Return a copy (\"clone\") of the hmac object. This can be used to " "efficiently compute the digests of strings that share a common initial " @@ -159,23 +159,23 @@ msgstr "" "回傳 hmac 物件的拷貝 (\"clone\")。這可以被用來有效率地計算那些共享相同初始子" "字串的字串的摘要。" -#: ../../library/hmac.rst:102 +#: ../../library/hmac.rst:99 msgid "A hash object has the following attributes:" msgstr "一個 hash 物件具有以下屬性:" -#: ../../library/hmac.rst:106 +#: ../../library/hmac.rst:103 msgid "The size of the resulting HMAC digest in bytes." msgstr "以 bytes 表示最終 HMAC 摘要的大小。" -#: ../../library/hmac.rst:110 +#: ../../library/hmac.rst:107 msgid "The internal block size of the hash algorithm in bytes." msgstr "以 bytes 表示雜湊演算法的內部區塊大小。" -#: ../../library/hmac.rst:116 +#: ../../library/hmac.rst:113 msgid "The canonical name of this HMAC, always lowercase, e.g. ``hmac-md5``." msgstr "HMAC 的正準名稱總是為小寫形式,例如 ``hmac-md5``。" -#: ../../library/hmac.rst:121 +#: ../../library/hmac.rst:118 msgid "" "Removed the undocumented attributes ``HMAC.digest_cons``, ``HMAC.inner``, " "and ``HMAC.outer``." @@ -183,11 +183,11 @@ msgstr "" "未寫入文件的屬性 ``HMAC.digest_cons``,``HMAC.inner`` 和 ``HMAC.outer`` 已被" "移除。" -#: ../../library/hmac.rst:125 +#: ../../library/hmac.rst:122 msgid "This module also provides the following helper function:" msgstr "這個模組還提供了下列輔助函式:" -#: ../../library/hmac.rst:129 +#: ../../library/hmac.rst:126 msgid "" "Return ``a == b``. This function uses an approach designed to prevent " "timing analysis by avoiding content-based short circuiting behaviour, making " @@ -200,7 +200,7 @@ msgstr "" "`str`\\ (僅限 ASCII,如 :meth:`HMAC.hexdigest` 的回傳值),或者是 :term:" "`bytes-like object`。" -#: ../../library/hmac.rst:137 +#: ../../library/hmac.rst:134 msgid "" "If *a* and *b* are of different lengths, or if an error occurs, a timing " "attack could theoretically reveal information about the types and lengths of " @@ -209,15 +209,15 @@ msgstr "" "如果 *a* 和 *b* 具有不同的長度,或者如果發生了錯誤,定時攻擊在理論上可以取得" "有關 *a* 和 *b* 的型別和長度的訊息 — 但不能取得他們的值。" -#: ../../library/hmac.rst:145 +#: ../../library/hmac.rst:142 msgid "" "The function uses OpenSSL's ``CRYPTO_memcmp()`` internally when available." msgstr "此函式在可能的情況下會在內部使用 OpenSSL 的 ``CRYPTO_memcmp()``。" -#: ../../library/hmac.rst:151 +#: ../../library/hmac.rst:148 msgid "Module :mod:`hashlib`" msgstr ":mod:`hashlib` 模組" -#: ../../library/hmac.rst:152 +#: ../../library/hmac.rst:149 msgid "The Python module providing secure hash functions." msgstr "Python 模組提供安全的雜湊函式。" diff --git a/library/html.entities.po b/library/html.entities.po index 4f108d3e57c..22ef314c829 100644 --- a/library/html.entities.po +++ b/library/html.entities.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-06-27 09:38+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!html.entities` --- Definitions of HTML general entities" msgstr ":mod:`!html.entities` --- HTML 一般實體的定義" -#: ../../library/html.entities.rst:9 +#: ../../library/html.entities.rst:7 msgid "**Source code:** :source:`Lib/html/entities.py`" msgstr "**原始碼:**\\ :source:`Lib/html/entities.py`" -#: ../../library/html.entities.rst:13 +#: ../../library/html.entities.rst:11 msgid "" "This module defines four dictionaries, :data:`html5`, :data:" "`name2codepoint`, :data:`codepoint2name`, and :data:`entitydefs`." @@ -36,7 +36,7 @@ msgstr "" "該 module(模組)定義了四個字典::data:`html5`、:data:`name2codepoint`、:" "data:`codepoint2name` 以及 :data:`entitydefs`。" -#: ../../library/html.entities.rst:19 +#: ../../library/html.entities.rst:17 msgid "" "A dictionary that maps HTML5 named character references [#]_ to the " "equivalent Unicode character(s), e.g. ``html5['gt;'] == '>'``. Note that the " @@ -50,25 +50,25 @@ msgstr "" "但有些名稱即使沒有分號也會被此標準接受:在這種情況下,名稱可帶有或不帶有 " "``';'``。請見 :func:`html.unescape`。" -#: ../../library/html.entities.rst:31 +#: ../../library/html.entities.rst:29 msgid "" "A dictionary mapping XHTML 1.0 entity definitions to their replacement text " "in ISO Latin-1." msgstr "將 XHTML 1.0 實體定義對映到 ISO Latin-1 中的替換文字的字典。" -#: ../../library/html.entities.rst:37 +#: ../../library/html.entities.rst:35 msgid "A dictionary that maps HTML4 entity names to the Unicode code points." msgstr "將 HTML4 實體名稱對映到 Unicode 程式點的字典。" -#: ../../library/html.entities.rst:42 +#: ../../library/html.entities.rst:40 msgid "A dictionary that maps Unicode code points to HTML4 entity names." msgstr "將 Unicode 程式點對映到 HTML4 實體名稱的字典。" -#: ../../library/html.entities.rst:46 +#: ../../library/html.entities.rst:44 msgid "Footnotes" msgstr "註解" -#: ../../library/html.entities.rst:47 +#: ../../library/html.entities.rst:45 msgid "" "See https://html.spec.whatwg.org/multipage/named-characters.html#named-" "character-references" diff --git a/library/http.client.po b/library/http.client.po index a2053eb26a3..dd9af0e96c8 100644 --- a/library/http.client.po +++ b/library/http.client.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-14 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:03+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -71,16 +71,19 @@ msgid "" "not given, the global default timeout setting is used). The optional " "*source_address* parameter may be a tuple of a (host, port) to use as the " "source address the HTTP connection is made from. The optional *blocksize* " -"parameter sets the buffer size in bytes for sending a file-like message body." +"parameter sets the buffer size in bytes for sending a file-like message " +"body. The optional *max_response_headers* parameter sets the maximum number " +"of allowed response headers to help prevent denial-of-service attacks, " +"otherwise the default value (100) is used." msgstr "" -#: ../../library/http.client.rst:51 +#: ../../library/http.client.rst:53 msgid "" "For example, the following calls all create instances that connect to the " "server at the same host and port::" msgstr "" -#: ../../library/http.client.rst:54 +#: ../../library/http.client.rst:56 msgid "" ">>> h1 = http.client.HTTPConnection('www.python.org')\n" ">>> h2 = http.client.HTTPConnection('www.python.org:80')\n" @@ -92,21 +95,25 @@ msgstr "" ">>> h3 = http.client.HTTPConnection('www.python.org', 80)\n" ">>> h4 = http.client.HTTPConnection('www.python.org', 80, timeout=10)" -#: ../../library/http.client.rst:59 +#: ../../library/http.client.rst:61 msgid "*source_address* was added." msgstr "新增 *source_address*。" -#: ../../library/http.client.rst:62 +#: ../../library/http.client.rst:64 msgid "" "The *strict* parameter was removed. HTTP 0.9-style \"Simple Responses\" are " "no longer supported." msgstr "" -#: ../../library/http.client.rst:66 +#: ../../library/http.client.rst:68 msgid "*blocksize* parameter was added." msgstr "新增 *blocksize* 參數。" -#: ../../library/http.client.rst:74 +#: ../../library/http.client.rst:71 ../../library/http.client.rst:117 +msgid "*max_response_headers* parameter was added." +msgstr "新增 *max_response_headers* 參數。" + +#: ../../library/http.client.rst:79 msgid "" "A subclass of :class:`HTTPConnection` that uses SSL for communication with " "secure servers. Default port is ``443``. If *context* is specified, it " @@ -114,77 +121,77 @@ msgid "" "options." msgstr "" -#: ../../library/http.client.rst:79 +#: ../../library/http.client.rst:84 msgid "Please read :ref:`ssl-security` for more information on best practices." msgstr "" -#: ../../library/http.client.rst:81 +#: ../../library/http.client.rst:86 msgid "*source_address*, *context* and *check_hostname* were added." msgstr "新增 *source_address*、*context* 與 *check_hostname*。" -#: ../../library/http.client.rst:84 +#: ../../library/http.client.rst:89 msgid "" "This class now supports HTTPS virtual hosts if possible (that is, if :const:" "`ssl.HAS_SNI` is true)." msgstr "" -#: ../../library/http.client.rst:88 +#: ../../library/http.client.rst:93 msgid "" "The *strict* parameter was removed. HTTP 0.9-style \"Simple Responses\" are " "no longer supported." msgstr "" -#: ../../library/http.client.rst:92 +#: ../../library/http.client.rst:97 msgid "" "This class now performs all the necessary certificate and hostname checks by " "default. To revert to the previous, unverified, behavior :func:`!ssl." "_create_unverified_context` can be passed to the *context* parameter." msgstr "" -#: ../../library/http.client.rst:98 +#: ../../library/http.client.rst:103 msgid "" "This class now enables TLS 1.3 :attr:`ssl.SSLContext.post_handshake_auth` " "for the default *context* or when *cert_file* is passed with a custom " "*context*." msgstr "" -#: ../../library/http.client.rst:103 +#: ../../library/http.client.rst:108 msgid "" "This class now sends an ALPN extension with protocol indicator ``http/1.1`` " "when no *context* is given. Custom *context* should set ALPN protocols with :" "meth:`~ssl.SSLContext.set_alpn_protocols`." msgstr "" -#: ../../library/http.client.rst:108 +#: ../../library/http.client.rst:113 msgid "" "The deprecated *key_file*, *cert_file* and *check_hostname* parameters have " "been removed." msgstr "" -#: ../../library/http.client.rst:115 +#: ../../library/http.client.rst:123 msgid "" "Class whose instances are returned upon successful connection. Not " "instantiated directly by user." msgstr "" -#: ../../library/http.client.rst:118 +#: ../../library/http.client.rst:126 msgid "" "The *strict* parameter was removed. HTTP 0.9 style \"Simple Responses\" are " "no longer supported." msgstr "" -#: ../../library/http.client.rst:122 +#: ../../library/http.client.rst:130 msgid "This module provides the following function:" msgstr "" -#: ../../library/http.client.rst:126 +#: ../../library/http.client.rst:134 msgid "" "Parse the headers from a file pointer *fp* representing a HTTP request/" "response. The file has to be a :class:`~io.BufferedIOBase` reader (i.e. not " "text) and must provide a valid :rfc:`5322` style header." msgstr "" -#: ../../library/http.client.rst:130 +#: ../../library/http.client.rst:138 msgid "" "This function returns an instance of :class:`http.client.HTTPMessage` that " "holds the header fields, but no payload (the same as :attr:`HTTPResponse." @@ -192,7 +199,7 @@ msgid "" "returning, the file pointer *fp* is ready to read the HTTP body." msgstr "" -#: ../../library/http.client.rst:137 +#: ../../library/http.client.rst:145 msgid "" ":meth:`parse_headers` does not parse the start-line of a HTTP message; it " "only parses the ``Name: value`` lines. The file has to be ready to read " @@ -200,46 +207,46 @@ msgid "" "calling the function." msgstr "" -#: ../../library/http.client.rst:142 +#: ../../library/http.client.rst:150 msgid "The following exceptions are raised as appropriate:" msgstr "" -#: ../../library/http.client.rst:147 +#: ../../library/http.client.rst:155 msgid "" "The base class of the other exceptions in this module. It is a subclass of :" "exc:`Exception`." msgstr "" -#: ../../library/http.client.rst:153 ../../library/http.client.rst:164 -#: ../../library/http.client.rst:169 ../../library/http.client.rst:174 -#: ../../library/http.client.rst:179 ../../library/http.client.rst:184 +#: ../../library/http.client.rst:161 ../../library/http.client.rst:172 +#: ../../library/http.client.rst:177 ../../library/http.client.rst:182 +#: ../../library/http.client.rst:187 ../../library/http.client.rst:192 msgid "A subclass of :exc:`HTTPException`." msgstr ":exc:`HTTPException` 的子類別。" -#: ../../library/http.client.rst:158 +#: ../../library/http.client.rst:166 msgid "" "A subclass of :exc:`HTTPException`, raised if a port is given and is either " "non-numeric or empty." msgstr "" -#: ../../library/http.client.rst:189 ../../library/http.client.rst:194 -#: ../../library/http.client.rst:199 +#: ../../library/http.client.rst:197 ../../library/http.client.rst:202 +#: ../../library/http.client.rst:207 msgid "A subclass of :exc:`ImproperConnectionState`." msgstr "" -#: ../../library/http.client.rst:204 +#: ../../library/http.client.rst:212 msgid "" "A subclass of :exc:`HTTPException`. Raised if a server responds with a HTTP " "status code that we don't understand." msgstr "" -#: ../../library/http.client.rst:210 +#: ../../library/http.client.rst:218 msgid "" "A subclass of :exc:`HTTPException`. Raised if an excessively long line is " "received in the HTTP protocol from the server." msgstr "" -#: ../../library/http.client.rst:216 +#: ../../library/http.client.rst:224 msgid "" "A subclass of :exc:`ConnectionResetError` and :exc:`BadStatusLine`. Raised " "by :meth:`HTTPConnection.getresponse` when the attempt to read the response " @@ -247,46 +254,46 @@ msgid "" "has closed the connection." msgstr "" -#: ../../library/http.client.rst:221 +#: ../../library/http.client.rst:229 msgid "Previously, :exc:`BadStatusLine`\\ ``('')`` was raised." msgstr "" -#: ../../library/http.client.rst:225 +#: ../../library/http.client.rst:233 msgid "The constants defined in this module are:" msgstr "" -#: ../../library/http.client.rst:229 +#: ../../library/http.client.rst:237 msgid "The default port for the HTTP protocol (always ``80``)." msgstr "" -#: ../../library/http.client.rst:233 +#: ../../library/http.client.rst:241 msgid "The default port for the HTTPS protocol (always ``443``)." msgstr "" -#: ../../library/http.client.rst:237 +#: ../../library/http.client.rst:245 msgid "This dictionary maps the HTTP 1.1 status codes to the W3C names." msgstr "" -#: ../../library/http.client.rst:239 +#: ../../library/http.client.rst:247 msgid "" "Example: ``http.client.responses[http.client.NOT_FOUND]`` is ``'Not Found'``." msgstr "" -#: ../../library/http.client.rst:241 +#: ../../library/http.client.rst:249 msgid "" "See :ref:`http-status-codes` for a list of HTTP status codes that are " "available in this module as constants." msgstr "" -#: ../../library/http.client.rst:248 +#: ../../library/http.client.rst:256 msgid "HTTPConnection Objects" msgstr "HTTPConnection 物件" -#: ../../library/http.client.rst:250 +#: ../../library/http.client.rst:258 msgid ":class:`HTTPConnection` instances have the following methods:" msgstr "" -#: ../../library/http.client.rst:256 +#: ../../library/http.client.rst:264 msgid "" "This will send a request to the server using the HTTP request method " "*method* and the request URI *url*. The provided *url* must be an absolute " @@ -295,7 +302,7 @@ msgid "" "methods)." msgstr "" -#: ../../library/http.client.rst:262 +#: ../../library/http.client.rst:270 msgid "" "If *body* is specified, the specified data is sent after the headers are " "finished. It may be a :class:`str`, a :term:`bytes-like object`, an open :" @@ -310,7 +317,7 @@ msgid "" "iterable is :term:`exhausted`." msgstr "" -#: ../../library/http.client.rst:274 +#: ../../library/http.client.rst:282 msgid "" "The *headers* argument should be a mapping of extra HTTP headers to send " "with the request. A :rfc:`Host header <2616#section-14.23>` must be provided " @@ -319,7 +326,7 @@ msgid "" "methods)." msgstr "" -#: ../../library/http.client.rst:280 +#: ../../library/http.client.rst:288 msgid "" "If *headers* contains neither Content-Length nor Transfer-Encoding, but " "there is a request body, one of those header fields will be added " @@ -332,7 +339,7 @@ msgid "" "Length." msgstr "" -#: ../../library/http.client.rst:292 +#: ../../library/http.client.rst:300 msgid "" "The *encode_chunked* argument is only relevant if Transfer-Encoding is " "specified in *headers*. If *encode_chunked* is ``False``, the " @@ -340,12 +347,12 @@ msgid "" "code. If it is ``True``, the body will be chunk-encoded." msgstr "" -#: ../../library/http.client.rst:297 +#: ../../library/http.client.rst:305 msgid "" "For example, to perform a ``GET`` request to ``https://docs.python.org/3/``::" msgstr "" -#: ../../library/http.client.rst:299 +#: ../../library/http.client.rst:307 msgid "" ">>> import http.client\n" ">>> host = \"docs.python.org\"\n" @@ -363,7 +370,7 @@ msgstr "" ">>> print(response.status, response.reason)\n" "200 OK" -#: ../../library/http.client.rst:308 +#: ../../library/http.client.rst:316 msgid "" "Chunked transfer encoding has been added to the HTTP protocol version 1.1. " "Unless the HTTP server is known to handle HTTP 1.1, the caller must either " @@ -371,18 +378,18 @@ msgid "" "that is not also a file as the body representation." msgstr "" -#: ../../library/http.client.rst:316 +#: ../../library/http.client.rst:324 msgid "" "Note that you must have read the whole response or call :meth:`close` if :" "meth:`getresponse` raised an non-:exc:`ConnectionError` exception before you " "can send a new request to the server." msgstr "" -#: ../../library/http.client.rst:320 +#: ../../library/http.client.rst:328 msgid "*body* can now be an iterable." msgstr "" -#: ../../library/http.client.rst:323 +#: ../../library/http.client.rst:331 msgid "" "If neither Content-Length nor Transfer-Encoding are set in *headers*, file " "and iterable *body* objects are now chunk-encoded. The *encode_chunked* " @@ -390,27 +397,27 @@ msgid "" "file objects." msgstr "" -#: ../../library/http.client.rst:332 +#: ../../library/http.client.rst:340 msgid "" "Should be called after a request is sent to get the response from the " "server. Returns an :class:`HTTPResponse` instance." msgstr "" -#: ../../library/http.client.rst:335 +#: ../../library/http.client.rst:343 msgid "" "If a :exc:`ConnectionError` or subclass is raised, the :class:" "`HTTPConnection` object will be ready to reconnect when a new request is " "sent." msgstr "" -#: ../../library/http.client.rst:340 +#: ../../library/http.client.rst:348 msgid "" "Note that this does not apply to :exc:`OSError`\\s raised by the underlying " "socket. Instead the caller is responsible to call :meth:`close` on the " "existing connection." msgstr "" -#: ../../library/http.client.rst:347 +#: ../../library/http.client.rst:355 msgid "" "Set the debugging level. The default debug level is ``0``, meaning no " "debugging output is printed. Any value greater than ``0`` will cause all " @@ -418,27 +425,27 @@ msgid "" "is passed to any new :class:`HTTPResponse` objects that are created." msgstr "" -#: ../../library/http.client.rst:357 +#: ../../library/http.client.rst:365 msgid "" "Set the host and the port for HTTP Connect Tunnelling. This allows running " "the connection through a proxy server." msgstr "" -#: ../../library/http.client.rst:360 +#: ../../library/http.client.rst:368 msgid "" "The *host* and *port* arguments specify the endpoint of the tunneled " "connection (i.e. the address included in the CONNECT request, *not* the " "address of the proxy server)." msgstr "" -#: ../../library/http.client.rst:364 +#: ../../library/http.client.rst:372 msgid "" "The *headers* argument should be a mapping of extra HTTP headers to send " "with the CONNECT request. Non-string header values are converted to strings " "via :func:`str`." msgstr "" -#: ../../library/http.client.rst:368 +#: ../../library/http.client.rst:376 msgid "" "As HTTP/1.1 is used for HTTP CONNECT tunnelling request, `as per the RFC " "`_, a HTTP " @@ -448,7 +455,7 @@ msgid "" "generated and transmitted automatically." msgstr "" -#: ../../library/http.client.rst:375 +#: ../../library/http.client.rst:383 msgid "" "For example, to tunnel through a HTTPS proxy server running locally on port " "8080, we would pass the address of the proxy to the :class:`HTTPSConnection` " @@ -456,7 +463,7 @@ msgid "" "the :meth:`~HTTPConnection.set_tunnel` method::" msgstr "" -#: ../../library/http.client.rst:380 +#: ../../library/http.client.rst:388 msgid "" ">>> import http.client\n" ">>> conn = http.client.HTTPSConnection(\"localhost\", 8080)\n" @@ -468,7 +475,7 @@ msgstr "" ">>> conn.set_tunnel(\"www.python.org\")\n" ">>> conn.request(\"HEAD\",\"/index.html\")" -#: ../../library/http.client.rst:387 +#: ../../library/http.client.rst:395 msgid "" "HTTP CONNECT tunnelling requests use protocol HTTP/1.1, upgraded from " "protocol HTTP/1.0. ``Host:`` HTTP headers are mandatory for HTTP/1.1, so one " @@ -476,24 +483,24 @@ msgid "" "headers argument." msgstr "" -#: ../../library/http.client.rst:396 +#: ../../library/http.client.rst:404 msgid "" "Returns a dictionary with the headers of the response received from the " "proxy server to the CONNECT request." msgstr "" -#: ../../library/http.client.rst:399 +#: ../../library/http.client.rst:407 msgid "If the CONNECT request was not sent, the method returns ``None``." msgstr "" -#: ../../library/http.client.rst:406 +#: ../../library/http.client.rst:414 msgid "" "Connect to the server specified when the object was created. By default, " "this is called automatically when making a request if the client does not " "already have a connection." msgstr "" -#: ../../library/http.client.rst:410 +#: ../../library/http.client.rst:418 msgid "" "Raises an :ref:`auditing event ` ``http.client.connect`` with " "arguments ``self``, ``host``, ``port``." @@ -501,22 +508,29 @@ msgstr "" "引發一個附帶引數 ``self``、``host``、``port`` 的\\ :ref:`稽核事件 " "` ``http.client.connect``。" -#: ../../library/http.client.rst:415 +#: ../../library/http.client.rst:423 msgid "Close the connection to the server." msgstr "" -#: ../../library/http.client.rst:420 +#: ../../library/http.client.rst:428 msgid "Buffer size in bytes for sending a file-like message body." msgstr "" -#: ../../library/http.client.rst:425 +#: ../../library/http.client.rst:435 +msgid "" +"The maximum number of allowed response headers to help prevent denial-of-" +"service attacks. By default, the maximum number of allowed headers is set to " +"100. The same limit applies to the trailer section of a chunked response." +msgstr "" + +#: ../../library/http.client.rst:442 msgid "" "As an alternative to using the :meth:`~HTTPConnection.request` method " "described above, you can also send your request step by step, by using the " "four functions below." msgstr "" -#: ../../library/http.client.rst:432 +#: ../../library/http.client.rst:449 msgid "" "This should be the first call after the connection to the server has been " "made. It sends a line to the server consisting of the *method* string, the " @@ -526,7 +540,7 @@ msgid "" "with non-False values." msgstr "" -#: ../../library/http.client.rst:442 +#: ../../library/http.client.rst:459 msgid "" "Send an :rfc:`822`\\ -style header to the server. It sends a line to the " "server consisting of the header, a colon and a space, and the first " @@ -534,14 +548,14 @@ msgid "" "consisting of a tab and an argument." msgstr "" -#: ../../library/http.client.rst:450 +#: ../../library/http.client.rst:467 msgid "" "Send a blank line to the server, signalling the end of the headers. The " "optional *message_body* argument can be used to pass a message body " "associated with the request." msgstr "" -#: ../../library/http.client.rst:454 +#: ../../library/http.client.rst:471 msgid "" "If *encode_chunked* is ``True``, the result of each iteration of " "*message_body* will be chunk-encoded as specified in :rfc:`7230`, Section " @@ -554,7 +568,7 @@ msgid "" "the chunk-encoded data immediately after *message_body*." msgstr "" -#: ../../library/http.client.rst:465 +#: ../../library/http.client.rst:482 msgid "" "Due to the chunked encoding specification, empty chunks yielded by an " "iterator body will be ignored by the chunk-encoder. This is to avoid " @@ -562,17 +576,17 @@ msgid "" "malformed encoding." msgstr "" -#: ../../library/http.client.rst:470 +#: ../../library/http.client.rst:487 msgid "Added chunked encoding support and the *encode_chunked* parameter." msgstr "" -#: ../../library/http.client.rst:476 +#: ../../library/http.client.rst:493 msgid "" "Send data to the server. This should be used directly only after the :meth:" "`endheaders` method has been called and before :meth:`getresponse` is called." msgstr "" -#: ../../library/http.client.rst:480 +#: ../../library/http.client.rst:497 msgid "" "Raises an :ref:`auditing event ` ``http.client.send`` with " "arguments ``self``, ``data``." @@ -580,34 +594,34 @@ msgstr "" "引發一個附帶引數 ``self``、``data`` 的\\ :ref:`稽核事件 ` ``http." "client.send``。" -#: ../../library/http.client.rst:486 +#: ../../library/http.client.rst:503 msgid "HTTPResponse Objects" msgstr "HTTPResponse 物件" -#: ../../library/http.client.rst:488 +#: ../../library/http.client.rst:505 msgid "" "An :class:`HTTPResponse` instance wraps the HTTP response from the server. " "It provides access to the request headers and the entity body. The response " "is an iterable object and can be used in a with statement." msgstr "" -#: ../../library/http.client.rst:493 +#: ../../library/http.client.rst:510 msgid "" "The :class:`io.BufferedIOBase` interface is now implemented and all of its " "reader operations are supported." msgstr "" -#: ../../library/http.client.rst:500 +#: ../../library/http.client.rst:517 msgid "Reads and returns the response body, or up to the next *amt* bytes." msgstr "" -#: ../../library/http.client.rst:504 +#: ../../library/http.client.rst:521 msgid "" "Reads up to the next len(b) bytes of the response body into the buffer *b*. " "Returns the number of bytes read." msgstr "" -#: ../../library/http.client.rst:511 +#: ../../library/http.client.rst:528 msgid "" "Return the value of the header *name*, or *default* if there is no header " "matching *name*. If there is more than one header with the name *name*, " @@ -615,77 +629,77 @@ msgid "" "than a single string, its elements are similarly returned joined by commas." msgstr "" -#: ../../library/http.client.rst:518 +#: ../../library/http.client.rst:535 msgid "Return a list of (header, value) tuples." msgstr "" -#: ../../library/http.client.rst:522 +#: ../../library/http.client.rst:539 msgid "Return the ``fileno`` of the underlying socket." msgstr "" -#: ../../library/http.client.rst:526 +#: ../../library/http.client.rst:543 msgid "" "A :class:`http.client.HTTPMessage` instance containing the response " "headers. :class:`http.client.HTTPMessage` is a subclass of :class:`email." "message.Message`." msgstr "" -#: ../../library/http.client.rst:532 +#: ../../library/http.client.rst:549 msgid "" "HTTP protocol version used by server. 10 for HTTP/1.0, 11 for HTTP/1.1." msgstr "" -#: ../../library/http.client.rst:536 +#: ../../library/http.client.rst:553 msgid "" "URL of the resource retrieved, commonly used to determine if a redirect was " "followed." msgstr "" -#: ../../library/http.client.rst:540 +#: ../../library/http.client.rst:557 msgid "" "Headers of the response in the form of an :class:`email.message." "EmailMessage` instance." msgstr "" -#: ../../library/http.client.rst:544 +#: ../../library/http.client.rst:561 msgid "Status code returned by server." msgstr "" -#: ../../library/http.client.rst:548 +#: ../../library/http.client.rst:565 msgid "Reason phrase returned by server." msgstr "" -#: ../../library/http.client.rst:552 +#: ../../library/http.client.rst:569 msgid "" "A debugging hook. If :attr:`debuglevel` is greater than zero, messages will " "be printed to stdout as the response is read and parsed." msgstr "" -#: ../../library/http.client.rst:557 +#: ../../library/http.client.rst:574 msgid "Is ``True`` if the stream is closed." msgstr "" -#: ../../library/http.client.rst:561 +#: ../../library/http.client.rst:578 msgid "Deprecated in favor of :attr:`~HTTPResponse.url`." msgstr "" -#: ../../library/http.client.rst:566 +#: ../../library/http.client.rst:583 msgid "Deprecated in favor of :attr:`~HTTPResponse.headers`." msgstr "" -#: ../../library/http.client.rst:571 +#: ../../library/http.client.rst:588 msgid "Deprecated in favor of :attr:`~HTTPResponse.status`." msgstr "" -#: ../../library/http.client.rst:575 +#: ../../library/http.client.rst:592 msgid "Examples" msgstr "範例" -#: ../../library/http.client.rst:577 +#: ../../library/http.client.rst:594 msgid "Here is an example session that uses the ``GET`` method::" msgstr "" -#: ../../library/http.client.rst:579 +#: ../../library/http.client.rst:596 msgid "" ">>> import http.client\n" ">>> conn = http.client.HTTPSConnection(\"www.python.org\")\n" @@ -711,13 +725,13 @@ msgid "" ">>> conn.close()" msgstr "" -#: ../../library/http.client.rst:602 +#: ../../library/http.client.rst:619 msgid "" "Here is an example session that uses the ``HEAD`` method. Note that the " "``HEAD`` method never returns any data. ::" msgstr "" -#: ../../library/http.client.rst:605 +#: ../../library/http.client.rst:622 msgid "" ">>> import http.client\n" ">>> conn = http.client.HTTPSConnection(\"www.python.org\")\n" @@ -743,11 +757,11 @@ msgstr "" ">>> data == b''\n" "True" -#: ../../library/http.client.rst:617 +#: ../../library/http.client.rst:634 msgid "Here is an example session that uses the ``POST`` method::" msgstr "" -#: ../../library/http.client.rst:619 +#: ../../library/http.client.rst:636 msgid "" ">>> import http.client, urllib.parse\n" ">>> params = urllib.parse.urlencode({'@number': 12524, '@type': 'issue', " @@ -781,7 +795,7 @@ msgstr "" "python.org/issue12524'\n" ">>> conn.close()" -#: ../../library/http.client.rst:633 +#: ../../library/http.client.rst:650 msgid "" "Client side HTTP ``PUT`` requests are very similar to ``POST`` requests. The " "difference lies only on the server side where HTTP servers will allow " @@ -791,7 +805,7 @@ msgid "" "``PUT`` method::" msgstr "" -#: ../../library/http.client.rst:639 +#: ../../library/http.client.rst:656 msgid "" ">>> # This creates an HTTP request\n" ">>> # with the content of BODY as the enclosed representation\n" @@ -806,11 +820,11 @@ msgid "" "200, OK" msgstr "" -#: ../../library/http.client.rst:654 +#: ../../library/http.client.rst:671 msgid "HTTPMessage Objects" msgstr "HTTPMessage 物件" -#: ../../library/http.client.rst:658 +#: ../../library/http.client.rst:675 msgid "" "An :class:`http.client.HTTPMessage` instance holds the headers from an HTTP " "response. It is implemented using the :class:`email.message.Message` class." diff --git a/library/http.cookiejar.po b/library/http.cookiejar.po index 25326896024..a96f3bea2a5 100644 --- a/library/http.cookiejar.po +++ b/library/http.cookiejar.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-05 00:34+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-06-28 00:56+0800\n" "Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!http.cookiejar` --- Cookie handling for HTTP clients" msgstr ":mod:`!http.cookiejar` --- HTTP 用戶端的 Cookie 處理" -#: ../../library/http.cookiejar.rst:10 +#: ../../library/http.cookiejar.rst:7 msgid "**Source code:** :source:`Lib/http/cookiejar.py`" msgstr "**原始碼:**\\ :source:`Lib/http/cookiejar.py`" -#: ../../library/http.cookiejar.rst:14 +#: ../../library/http.cookiejar.rst:11 msgid "" "The :mod:`!http.cookiejar` module defines classes for automatic handling of " "HTTP cookies. It is useful for accessing websites that require small pieces " @@ -39,7 +39,7 @@ msgstr "" "資料 —— :dfn:`cookies` —— 的網站時會非常有用。這些資料會依據網頁伺服器的 " "HTTP 回應來設置於用戶端機器,並在之後的請求中被回傳到伺服器。" -#: ../../library/http.cookiejar.rst:19 +#: ../../library/http.cookiejar.rst:16 msgid "" "Both the regular Netscape cookie protocol and the protocol defined by :rfc:" "`2965` are handled. RFC 2965 handling is switched off by default. :rfc:" @@ -58,7 +58,7 @@ msgstr "" "的協定有很大的不同),包括 RFC 2965 所引進的 ``max-age`` 和 ``port`` cookie " "屬性。" -#: ../../library/http.cookiejar.rst:31 +#: ../../library/http.cookiejar.rst:28 msgid "" "The various named parameters found in :mailheader:`Set-Cookie` and :" "mailheader:`Set-Cookie2` headers (for example, ``domain`` and ``expires``) " @@ -70,11 +70,11 @@ msgstr "" "參數(例如 ``domain`` 和 ``expires``)通常被稱為 :dfn:`attributes`。為了與 " "Python 的屬性區分,這個模組的說明文件改用 :dfn:`cookie-attribute` 這個術語。" -#: ../../library/http.cookiejar.rst:38 +#: ../../library/http.cookiejar.rst:35 msgid "The module defines the following exception:" msgstr "模組定義了以下例外:" -#: ../../library/http.cookiejar.rst:43 +#: ../../library/http.cookiejar.rst:40 msgid "" "Instances of :class:`FileCookieJar` raise this exception on failure to load " "cookies from a file. :exc:`LoadError` is a subclass of :exc:`OSError`." @@ -82,7 +82,7 @@ msgstr "" "當從檔案載入 cookies 失敗時,:class:`FileCookieJar` 的實例會引發這個例外。:" "exc:`LoadError` 是 :exc:`OSError` 的子類別。" -#: ../../library/http.cookiejar.rst:46 +#: ../../library/http.cookiejar.rst:43 msgid "" ":exc:`LoadError` used to be a subtype of :exc:`IOError`, which is now an " "alias of :exc:`OSError`." @@ -90,15 +90,15 @@ msgstr "" ":exc:`LoadError` 以前是 :exc:`IOError` 的子型別,現在是 :exc:`OSError` 的別" "名。" -#: ../../library/http.cookiejar.rst:51 +#: ../../library/http.cookiejar.rst:48 msgid "The following classes are provided:" msgstr "這個模組提供了以下類別:" -#: ../../library/http.cookiejar.rst:56 +#: ../../library/http.cookiejar.rst:53 msgid "*policy* is an object implementing the :class:`CookiePolicy` interface." msgstr "*policy* 是實作了 :class:`CookiePolicy` 介面的一個物件。" -#: ../../library/http.cookiejar.rst:58 +#: ../../library/http.cookiejar.rst:55 msgid "" "The :class:`CookieJar` class stores HTTP cookies. It extracts cookies from " "HTTP requests, and returns them in HTTP responses. :class:`CookieJar` " @@ -110,7 +110,7 @@ msgstr "" "cookies,並在 HTTP 回應中將它們回傳。:class:`CookieJar` 實例會在必要時自動使" "包含的 cookies 過期。它的子類別也負責從檔案或資料庫中儲存和擷取 cookies。" -#: ../../library/http.cookiejar.rst:66 +#: ../../library/http.cookiejar.rst:63 msgid "" "*policy* is an object implementing the :class:`CookiePolicy` interface. For " "the other arguments, see the documentation for the corresponding attributes." @@ -118,7 +118,7 @@ msgstr "" "*policy* 是實作了 :class:`CookiePolicy` 介面的一個物件。至於其他引數,請參閱" "對應屬性的說明文件。" -#: ../../library/http.cookiejar.rst:69 +#: ../../library/http.cookiejar.rst:66 msgid "" "A :class:`CookieJar` which can load cookies from, and perhaps save cookies " "to, a file on disk. Cookies are **NOT** loaded from the named file until " @@ -130,22 +130,22 @@ msgstr "" "不會**\\ 從指定的檔案載入。這個類別的子類別有記載於 :ref:`file-cookie-jar-" "classes` 章節。" -#: ../../library/http.cookiejar.rst:74 +#: ../../library/http.cookiejar.rst:71 msgid "" "This should not be initialized directly – use its subclasses below instead." msgstr "這個類別不應該直接初始化 - 請使用下面的子類別代替。" -#: ../../library/http.cookiejar.rst:78 ../../library/http.cookiejar.rst:363 +#: ../../library/http.cookiejar.rst:75 ../../library/http.cookiejar.rst:360 msgid "The filename parameter supports a :term:`path-like object`." msgstr "filename 參數支援傳入一個 :term:`path-like object`。" -#: ../../library/http.cookiejar.rst:83 +#: ../../library/http.cookiejar.rst:80 msgid "" "This class is responsible for deciding whether each cookie should be " "accepted from / returned to the server." msgstr "此類別負責決定是否應從伺服器接受 / 回傳每個 cookie。" -#: ../../library/http.cookiejar.rst:89 +#: ../../library/http.cookiejar.rst:86 msgid "" "Constructor arguments should be passed as keyword arguments only. " "*blocked_domains* is a sequence of domain names that we never accept cookies " @@ -163,7 +163,7 @@ msgstr "" "websocket)會被視為安全通訊協定。所有其他引數請參閱 :class:`CookiePolicy` " "及 :class:`DefaultCookiePolicy` 物件的說明文件。" -#: ../../library/http.cookiejar.rst:98 +#: ../../library/http.cookiejar.rst:95 msgid "" ":class:`DefaultCookiePolicy` implements the standard accept / reject rules " "for Netscape and :rfc:`2965` cookies. By default, :rfc:`2109` cookies (that " @@ -183,7 +183,7 @@ msgstr "" "cookie,方法是將 :class:`Cookie` 實例的 :attr:`~Cookie.version` 屬性設為 " "0。:class:`DefaultCookiePolicy` 也提供了一些參數來允許對策略進行一些微調。" -#: ../../library/http.cookiejar.rst:111 +#: ../../library/http.cookiejar.rst:108 msgid "" "This class represents Netscape, :rfc:`2109` and :rfc:`2965` cookies. It is " "not expected that users of :mod:`!http.cookiejar` construct their own :class:" @@ -194,19 +194,19 @@ msgstr "" "http.cookiejar` 的使用者建立自己的 :class:`Cookie` 實例。如有必要,請" "在 :class:`CookieJar` 實例上呼叫 :meth:`~CookieJar.make_cookies`。" -#: ../../library/http.cookiejar.rst:119 +#: ../../library/http.cookiejar.rst:116 msgid "Module :mod:`urllib.request`" msgstr ":mod:`urllib.request` 模組" -#: ../../library/http.cookiejar.rst:120 +#: ../../library/http.cookiejar.rst:117 msgid "URL opening with automatic cookie handling." msgstr "URL 打開時會自動處理 cookie。" -#: ../../library/http.cookiejar.rst:122 +#: ../../library/http.cookiejar.rst:119 msgid "Module :mod:`http.cookies`" msgstr ":mod:`http.cookies` 模組" -#: ../../library/http.cookiejar.rst:123 +#: ../../library/http.cookiejar.rst:120 msgid "" "HTTP cookie classes, principally useful for server-side code. The :mod:`!" "http.cookiejar` and :mod:`http.cookies` modules do not depend on each other." @@ -214,11 +214,11 @@ msgstr "" "HTTP cookie 類別,主要用於伺服器端程式碼。 :mod:`!http.cookiejar` 和 :mod:" "`http.cookies` 模組不互相依賴。" -#: ../../library/http.cookiejar.rst:127 +#: ../../library/http.cookiejar.rst:124 msgid "https://curl.se/rfc/cookie_spec.html" msgstr "https://curl.se/rfc/cookie_spec.html" -#: ../../library/http.cookiejar.rst:128 +#: ../../library/http.cookiejar.rst:125 msgid "" "The specification of the original Netscape cookie protocol. Though this is " "still the dominant protocol, the 'Netscape cookie protocol' implemented by " @@ -229,20 +229,20 @@ msgstr "" "mod:`!http.cookiejar`)實作的「Netscape cookie 協定」與 ``cookie_spec.html`` " "中實作的協定只有一點相似之處。" -#: ../../library/http.cookiejar.rst:133 +#: ../../library/http.cookiejar.rst:130 msgid ":rfc:`2109` - HTTP State Management Mechanism" msgstr ":rfc:`2109` - HTTP 狀態管理機制" -#: ../../library/http.cookiejar.rst:134 +#: ../../library/http.cookiejar.rst:131 msgid "Obsoleted by :rfc:`2965`. Uses :mailheader:`Set-Cookie` with version=1." msgstr "" "被 :rfc:`2965` 所取代,會使用 :mailheader:`Set-Cookie` 設定 version=1。" -#: ../../library/http.cookiejar.rst:136 +#: ../../library/http.cookiejar.rst:133 msgid ":rfc:`2965` - HTTP State Management Mechanism" msgstr ":rfc:`2965` - HTTP 狀態管理機制" -#: ../../library/http.cookiejar.rst:137 +#: ../../library/http.cookiejar.rst:134 msgid "" "The Netscape protocol with the bugs fixed. Uses :mailheader:`Set-Cookie2` " "in place of :mailheader:`Set-Cookie`. Not widely used." @@ -250,23 +250,23 @@ msgstr "" "有錯誤修正的 Netscape 通訊協定。使用 :mailheader:`Set-Cookie2` 取代 :" "mailheader:`Set-Cookie`。未被廣泛使用。" -#: ../../library/http.cookiejar.rst:140 +#: ../../library/http.cookiejar.rst:137 msgid "https://kristol.org/cookie/errata.html" msgstr "https://kristol.org/cookie/errata.html" -#: ../../library/http.cookiejar.rst:141 +#: ../../library/http.cookiejar.rst:138 msgid "Unfinished errata to :rfc:`2965`." msgstr "未完成的 :rfc:`2965` 勘誤表。" -#: ../../library/http.cookiejar.rst:143 +#: ../../library/http.cookiejar.rst:140 msgid ":rfc:`2964` - Use of HTTP State Management" msgstr ":rfc:`2964` - HTTP 狀態管理使用方法" -#: ../../library/http.cookiejar.rst:148 +#: ../../library/http.cookiejar.rst:145 msgid "CookieJar and FileCookieJar objects" msgstr "CookieJar 與 FileCookieJar 物件" -#: ../../library/http.cookiejar.rst:150 +#: ../../library/http.cookiejar.rst:147 msgid "" ":class:`CookieJar` objects support the :term:`iterator` protocol for " "iterating over contained :class:`Cookie` objects." @@ -274,15 +274,15 @@ msgstr "" ":class:`CookieJar` 物件支援 :term:`iterator` 協定來遍歷包含的 :class:" "`Cookie` 物件。" -#: ../../library/http.cookiejar.rst:153 +#: ../../library/http.cookiejar.rst:150 msgid ":class:`CookieJar` has the following methods:" msgstr ":class:`CookieJar` 擁有以下方法:" -#: ../../library/http.cookiejar.rst:158 +#: ../../library/http.cookiejar.rst:155 msgid "Add correct :mailheader:`Cookie` header to *request*." msgstr "將正確的 :mailheader:`Cookie` 標頭加入 *request*。" -#: ../../library/http.cookiejar.rst:160 +#: ../../library/http.cookiejar.rst:157 msgid "" "If policy allows (that is, the :attr:`~CookiePolicy.rfc2965` and :attr:" "`~CookiePolicy.hide_cookie2` attributes of the :class:`CookieJar`'s :class:" @@ -293,7 +293,7 @@ msgstr "" "的 :attr:`~CookiePolicy.rfc2965` 和 :attr:`~CookiePolicy.hide_cookie2` 屬性分" "別為 true 和 false),:mailheader:`Cookie2` 標頭也會在適當的時候加入。" -#: ../../library/http.cookiejar.rst:165 +#: ../../library/http.cookiejar.rst:162 msgid "" "The *request* object (usually a :class:`urllib.request.Request` instance) " "must support the methods :meth:`~urllib.request.Request.get_full_url`, :meth:" @@ -311,7 +311,7 @@ msgstr "" "與 :attr:`~urllib.request.Request.host`、:attr:`~urllib.request.Request.type`、:attr:`~urllib.request.Request.unverifiable`、:attr:`~urllib.request.Request.origin_req_host` " "屬性。" -#: ../../library/http.cookiejar.rst:178 ../../library/http.cookiejar.rst:208 +#: ../../library/http.cookiejar.rst:175 ../../library/http.cookiejar.rst:205 msgid "" "*request* object needs :attr:`~urllib.request.Request.origin_req_host` " "attribute. Dependency on a deprecated method :meth:`!get_origin_req_host` " @@ -320,7 +320,7 @@ msgstr "" "*request* 物件需要 :attr:`~urllib.request.Request.origin_req_host` 屬性。已移" "除對已棄用方法 :meth:`!get_origin_req_host` 的依賴。" -#: ../../library/http.cookiejar.rst:185 +#: ../../library/http.cookiejar.rst:182 msgid "" "Extract cookies from HTTP *response* and store them in the :class:" "`CookieJar`, where allowed by policy." @@ -328,7 +328,7 @@ msgstr "" "在策略允許的情況下,從 HTTP *response* 抽取出 cookies 並儲存到 :class:" "`CookieJar` 中。" -#: ../../library/http.cookiejar.rst:188 +#: ../../library/http.cookiejar.rst:185 msgid "" "The :class:`CookieJar` will look for allowable :mailheader:`Set-Cookie` and :" "mailheader:`Set-Cookie2` headers in the *response* argument, and store " @@ -339,7 +339,7 @@ msgstr "" "和 :mailheader:`Set-Cookie2` 標頭,並視情況儲存 cookies(需經 :meth:" "`CookiePolicy.set_ok` 方法的檢測)。" -#: ../../library/http.cookiejar.rst:192 +#: ../../library/http.cookiejar.rst:189 msgid "" "The *response* object (usually the result of a call to :meth:`urllib.request." "urlopen`, or similar) should support an :meth:`~http.client.HTTPResponse." @@ -349,7 +349,7 @@ msgstr "" "西)應該支援 :meth:`~http.client.HTTPResponse.info` 方法,它會回傳一" "個 :class:`email.message.Message` 的實例。" -#: ../../library/http.cookiejar.rst:197 +#: ../../library/http.cookiejar.rst:194 msgid "" "The *request* object (usually a :class:`urllib.request.Request` instance) " "must support the method :meth:`~urllib.request.Request.get_full_url` and the " @@ -366,16 +366,16 @@ msgstr "" "和 :attr:`~urllib.request.Request.origin_req_host` 等屬性。該請求被用於設定 " "cookie-attributes 的預設值,並檢查 cookie 是否允許被設定。" -#: ../../library/http.cookiejar.rst:214 +#: ../../library/http.cookiejar.rst:211 msgid "Set the :class:`CookiePolicy` instance to be used." msgstr "設定要使用的 :class:`CookiePolicy` 實例。" -#: ../../library/http.cookiejar.rst:219 +#: ../../library/http.cookiejar.rst:216 msgid "" "Return sequence of :class:`Cookie` objects extracted from *response* object." msgstr "回傳從 *response* 物件抽取出的 :class:`Cookie` 物件序列。" -#: ../../library/http.cookiejar.rst:221 +#: ../../library/http.cookiejar.rst:218 msgid "" "See the documentation for :meth:`extract_cookies` for the interfaces " "required of the *response* and *request* arguments." @@ -383,21 +383,21 @@ msgstr "" "有關 *response* 和 *request* 引數所需的介面,請參閱 :meth:`extract_cookies` " "的說明檔案。" -#: ../../library/http.cookiejar.rst:227 +#: ../../library/http.cookiejar.rst:224 msgid "Set a :class:`Cookie` if policy says it's OK to do so." msgstr "如果策略允許這麼做,設定 :class:`Cookie`。" -#: ../../library/http.cookiejar.rst:232 +#: ../../library/http.cookiejar.rst:229 msgid "" "Set a :class:`Cookie`, without checking with policy to see whether or not it " "should be set." msgstr "設定一個 :class:`Cookie`,不經過策略檢查。" -#: ../../library/http.cookiejar.rst:238 +#: ../../library/http.cookiejar.rst:235 msgid "Clear some cookies." msgstr "清除一些 cookies。" -#: ../../library/http.cookiejar.rst:240 +#: ../../library/http.cookiejar.rst:237 msgid "" "If invoked without arguments, clear all cookies. If given a single " "argument, only cookies belonging to that *domain* will be removed. If given " @@ -410,15 +410,15 @@ msgstr "" "*path* 的 cookie。 如果給定三個引數,則會移除指定 *domain*、*path* 和 *name* " "的 cookie。" -#: ../../library/http.cookiejar.rst:246 +#: ../../library/http.cookiejar.rst:243 msgid "Raises :exc:`KeyError` if no matching cookie exists." msgstr "如果沒有符合的 cookie 存在,則引發 :exc:`KeyError`。" -#: ../../library/http.cookiejar.rst:251 +#: ../../library/http.cookiejar.rst:248 msgid "Discard all session cookies." msgstr "刪除所有 session cookies。" -#: ../../library/http.cookiejar.rst:253 +#: ../../library/http.cookiejar.rst:250 msgid "" "Discards all contained cookies that have a true :attr:`~Cookie.discard` " "attribute (usually because they had either no ``max-age`` or ``expires`` " @@ -430,7 +430,7 @@ msgstr "" "``max-age`` 或 ``expires`` cookie-attribute,或有明確的 ``discard`` cookie-" "attribute)。對於互動式瀏覽器,工作階段的結束通常對應於關閉瀏覽器視窗。" -#: ../../library/http.cookiejar.rst:258 +#: ../../library/http.cookiejar.rst:255 msgid "" "Note that the :meth:`~FileCookieJar.save` method won't save session cookies " "anyway, unless you ask otherwise by passing a true *ignore_discard* argument." @@ -438,22 +438,22 @@ msgstr "" "請注意,:meth:`~FileCookieJar.save` 方法無論如何都不會儲存 session cookies," "除非你透過傳入值為 true 的 *ignore_discard* 引數來要求。" -#: ../../library/http.cookiejar.rst:261 +#: ../../library/http.cookiejar.rst:258 msgid ":class:`FileCookieJar` implements the following additional methods:" msgstr ":class:`FileCookieJar` 實例有下列附加方法:" -#: ../../library/http.cookiejar.rst:266 +#: ../../library/http.cookiejar.rst:263 msgid "Save cookies to a file." msgstr "將 cookies 儲存到檔案中。" -#: ../../library/http.cookiejar.rst:268 +#: ../../library/http.cookiejar.rst:265 msgid "" "This base class raises :exc:`NotImplementedError`. Subclasses may leave " "this method unimplemented." msgstr "" "這個基底類別會產生 :exc:`NotImplementedError`。子類別可以不實作此方法。" -#: ../../library/http.cookiejar.rst:271 +#: ../../library/http.cookiejar.rst:268 msgid "" "*filename* is the name of file in which to save cookies. If *filename* is " "not specified, :attr:`self.filename ` is used (whose " @@ -465,7 +465,7 @@ msgstr "" "的值,如果有的話);如果 :attr:`self.filename ` 為 " "``None``,則會引發 :exc:`ValueError`。" -#: ../../library/http.cookiejar.rst:277 +#: ../../library/http.cookiejar.rst:274 msgid "" "*ignore_discard*: save even cookies set to be discarded. *ignore_expires*: " "save even cookies that have expired" @@ -473,7 +473,7 @@ msgstr "" "*ignore_discard*: 即使設定為捨棄的 cookies 也會儲存。*ignore_expires*: 保存過" "期的 cookie" -#: ../../library/http.cookiejar.rst:280 +#: ../../library/http.cookiejar.rst:277 msgid "" "The file is overwritten if it already exists, thus wiping all the cookies it " "contains. Saved cookies can be restored later using the :meth:`load` or :" @@ -482,19 +482,19 @@ msgstr "" "如果檔案已經存在,則會被覆寫,因此會抹除其中包含的所有 cookies。 儲存的 " "cookies 可以稍後使用 :meth:`load` 或 :meth:`revert` 方法還原。" -#: ../../library/http.cookiejar.rst:287 +#: ../../library/http.cookiejar.rst:284 msgid "Load cookies from a file." msgstr "從檔案中載入 cookies。" -#: ../../library/http.cookiejar.rst:289 +#: ../../library/http.cookiejar.rst:286 msgid "Old cookies are kept unless overwritten by newly loaded ones." msgstr "舊的 cookies 會被保留,除非被新載入的 cookies 覆蓋。" -#: ../../library/http.cookiejar.rst:291 +#: ../../library/http.cookiejar.rst:288 msgid "Arguments are as for :meth:`save`." msgstr "引數與 :meth:`save` 相同。" -#: ../../library/http.cookiejar.rst:293 +#: ../../library/http.cookiejar.rst:290 msgid "" "The named file must be in the format understood by the class, or :exc:" "`LoadError` will be raised. Also, :exc:`OSError` may be raised, for example " @@ -503,15 +503,15 @@ msgstr "" "被命名的檔案必須是類別所能正確剖析的格式,否則會產生 :exc:`LoadError`。此" "外,:exc:`OSError` 可能會被引發,例如檔案不存在時。" -#: ../../library/http.cookiejar.rst:297 +#: ../../library/http.cookiejar.rst:294 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." msgstr "以前會引發 :exc:`IOError`,現在它是 :exc:`OSError` 的別名。" -#: ../../library/http.cookiejar.rst:303 +#: ../../library/http.cookiejar.rst:300 msgid "Clear all cookies and reload cookies from a saved file." msgstr "清除所有 cookies, 並從儲存的檔案重新載入 cookies。" -#: ../../library/http.cookiejar.rst:305 +#: ../../library/http.cookiejar.rst:302 msgid "" ":meth:`revert` can raise the same exceptions as :meth:`load`. If there is a " "failure, the object's state will not be altered." @@ -519,17 +519,17 @@ msgstr "" ":meth:`revert` 可以產生與 :meth:`load` 相同的例外。如果失敗,物件的狀態不會被" "改變。" -#: ../../library/http.cookiejar.rst:308 +#: ../../library/http.cookiejar.rst:305 msgid ":class:`FileCookieJar` instances have the following public attributes:" msgstr ":class:`FileCookieJar` 實例擁有以下公開屬性:" -#: ../../library/http.cookiejar.rst:313 +#: ../../library/http.cookiejar.rst:310 msgid "" "Filename of default file in which to keep cookies. This attribute may be " "assigned to." msgstr "保存 cookie 的預設檔案的檔案名稱。 此屬性可以被指定。" -#: ../../library/http.cookiejar.rst:319 +#: ../../library/http.cookiejar.rst:316 msgid "" "If true, load cookies lazily from disk. This attribute should not be " "assigned to. This is only a hint, since this only affects performance, not " @@ -542,17 +542,17 @@ msgstr "" "`CookieJar` 物件可以忽略它。 沒有一個包含在標準函式庫中的 :class:" "`FileCookieJar` 類別會惰性地載入 cookies。" -#: ../../library/http.cookiejar.rst:329 +#: ../../library/http.cookiejar.rst:326 msgid "FileCookieJar subclasses and co-operation with web browsers" msgstr "FileCookieJar 子類別及與網頁瀏覽器的合作" -#: ../../library/http.cookiejar.rst:331 +#: ../../library/http.cookiejar.rst:328 msgid "" "The following :class:`CookieJar` subclasses are provided for reading and " "writing." msgstr "以下 :class:`CookieJar` 子類別提供用於讀取和寫入。" -#: ../../library/http.cookiejar.rst:336 +#: ../../library/http.cookiejar.rst:333 msgid "" "A :class:`FileCookieJar` that can load from and save cookies to disk in the " "Mozilla ``cookies.txt`` file format (which is also used by curl and the Lynx " @@ -561,7 +561,7 @@ msgstr "" "一個能夠以 Mozilla ``cookies.txt`` 檔案格式(該格式也被 curl 和 Lynx 以及 " "Netscape 瀏覽器所使用)從磁碟載入和儲存 cookie 的 :class:`FileCookieJar`。" -#: ../../library/http.cookiejar.rst:342 +#: ../../library/http.cookiejar.rst:339 msgid "" "This loses information about :rfc:`2965` cookies, and also about newer or " "non-standard cookie-attributes such as ``port``." @@ -569,7 +569,7 @@ msgstr "" "這會遺失關於 :rfc:`2965` cookie 的訊息,以及較新或非標準 cookie 屬性(例如 " "``port``)的訊息。" -#: ../../library/http.cookiejar.rst:347 +#: ../../library/http.cookiejar.rst:344 msgid "" "Back up your cookies before saving if you have cookies whose loss / " "corruption would be inconvenient (there are some subtleties which may lead " @@ -578,13 +578,13 @@ msgstr "" "如果 Cookie 遺失或損壞會造成不便,請在儲存之前先備份 Cookie(有些微妙的情況可" "能會導致檔案在載入/儲存往返過程中發生輕微變化)。" -#: ../../library/http.cookiejar.rst:351 +#: ../../library/http.cookiejar.rst:348 msgid "" "Also note that cookies saved while Mozilla is running will get clobbered by " "Mozilla." msgstr "另外請注意,在 Mozilla 執行時儲存的 cookies 會被 Mozilla 刪除。" -#: ../../library/http.cookiejar.rst:357 +#: ../../library/http.cookiejar.rst:354 msgid "" "A :class:`FileCookieJar` that can load from and save cookies to disk in " "format compatible with the libwww-perl library's ``Set-Cookie3`` file " @@ -595,23 +595,23 @@ msgstr "" "式載入 cookies 並儲存 cookies 到磁碟。如果你想要將 cookie 儲存在人類可讀的檔" "案中,這是很方便的。" -#: ../../library/http.cookiejar.rst:368 +#: ../../library/http.cookiejar.rst:365 msgid "CookiePolicy objects" msgstr "CookiePolicy 物件" -#: ../../library/http.cookiejar.rst:370 +#: ../../library/http.cookiejar.rst:367 msgid "" "Objects implementing the :class:`CookiePolicy` interface have the following " "methods:" msgstr "實作 :class:`CookiePolicy` 介面的物件有以下方法:" -#: ../../library/http.cookiejar.rst:376 +#: ../../library/http.cookiejar.rst:373 msgid "" "Return boolean value indicating whether cookie should be accepted from " "server." msgstr "回傳值表示的是否接受伺服器 cookie 的布林值。" -#: ../../library/http.cookiejar.rst:378 +#: ../../library/http.cookiejar.rst:375 msgid "" "*cookie* is a :class:`Cookie` instance. *request* is an object implementing " "the interface defined by the documentation for :meth:`CookieJar." @@ -620,12 +620,12 @@ msgstr "" "*cookie* 是一個 :class:`Cookie` 實例。 *request* 是一個實作了 :meth:" "`CookieJar.extract_cookies` 文件所定義的介面的物件。" -#: ../../library/http.cookiejar.rst:385 +#: ../../library/http.cookiejar.rst:382 msgid "" "Return boolean value indicating whether cookie should be returned to server." msgstr "回傳布林值,表示 cookie 是否應回傳伺服器。" -#: ../../library/http.cookiejar.rst:387 +#: ../../library/http.cookiejar.rst:384 msgid "" "*cookie* is a :class:`Cookie` instance. *request* is an object implementing " "the interface defined by the documentation for :meth:`CookieJar." @@ -634,12 +634,12 @@ msgstr "" "*cookie* 是一個 :class:`Cookie` 實例。 *request* 是一個實作了 :meth:" "`CookieJar.add_cookie_header` 文件所定義的介面的物件。" -#: ../../library/http.cookiejar.rst:394 +#: ../../library/http.cookiejar.rst:391 msgid "" "Return ``False`` if cookies should not be returned, given cookie domain." msgstr "在給定 cookie 網域如果不應回傳 cookie,則回傳 ``False``。" -#: ../../library/http.cookiejar.rst:396 +#: ../../library/http.cookiejar.rst:393 msgid "" "This method is an optimization. It removes the need for checking every " "cookie with a particular domain (which might involve reading many files). " @@ -650,7 +650,7 @@ msgstr "" "讀取許多檔案)。從 :meth:`domain_return_ok` 和 :meth:`path_return_ok` 回傳 " "true 會把所有的工作留給 :meth:`return_ok`。" -#: ../../library/http.cookiejar.rst:401 +#: ../../library/http.cookiejar.rst:398 msgid "" "If :meth:`domain_return_ok` returns true for the cookie domain, :meth:" "`path_return_ok` is called for the cookie path. Otherwise, :meth:" @@ -665,7 +665,7 @@ msgstr "" "呼叫 :meth:`return_ok` 附帶的 :class:`Cookie` 物件本身以進行全面檢查。否則,:" "meth:`return_ok` 將永遠不會被呼叫。" -#: ../../library/http.cookiejar.rst:408 +#: ../../library/http.cookiejar.rst:405 msgid "" "Note that :meth:`domain_return_ok` is called for every *cookie* domain, not " "just for the *request* domain. For example, the function might be called " @@ -677,19 +677,19 @@ msgstr "" "能會同時被 ``\".example.com\"`` 和 ``\"www.example.com\"`` 呼叫。 同樣的道理" "也適用於 :meth:`path_return_ok`。" -#: ../../library/http.cookiejar.rst:413 +#: ../../library/http.cookiejar.rst:410 msgid "The *request* argument is as documented for :meth:`return_ok`." msgstr "*request* 引數與 :meth:`return_ok` 的說明文件相同。" -#: ../../library/http.cookiejar.rst:418 +#: ../../library/http.cookiejar.rst:415 msgid "Return ``False`` if cookies should not be returned, given cookie path." msgstr "給定 cookie 路徑如不應該回傳 cookie,則回傳 ``False`` 。" -#: ../../library/http.cookiejar.rst:420 +#: ../../library/http.cookiejar.rst:417 msgid "See the documentation for :meth:`domain_return_ok`." msgstr "關於 :meth:`domain_return_ok` 請見文件。" -#: ../../library/http.cookiejar.rst:422 +#: ../../library/http.cookiejar.rst:419 msgid "" "In addition to implementing the methods above, implementations of the :class:" "`CookiePolicy` interface must also supply the following attributes, " @@ -699,15 +699,15 @@ msgstr "" "除了實作上述方法外, :class:`CookiePolicy` 介面的實作也必須提供下列屬性,指出" "應該使用哪些通訊協定,以及如何使用。所有這些屬性都可以被指定。" -#: ../../library/http.cookiejar.rst:430 +#: ../../library/http.cookiejar.rst:427 msgid "Implement Netscape protocol." msgstr "實作 Netscape 協定。" -#: ../../library/http.cookiejar.rst:435 +#: ../../library/http.cookiejar.rst:432 msgid "Implement :rfc:`2965` protocol." msgstr "實作 :rfc:`2965` 協定。" -#: ../../library/http.cookiejar.rst:440 +#: ../../library/http.cookiejar.rst:437 msgid "" "Don't add :mailheader:`Cookie2` header to requests (the presence of this " "header indicates to the server that we understand :rfc:`2965` cookies)." @@ -715,7 +715,7 @@ msgstr "" "不要在請求中加入 :mailheader:`Cookie2` 標頭(這個標頭的存在向伺服器表明我們能" "夠正確剖析 :rfc:`2965` cookie)。" -#: ../../library/http.cookiejar.rst:443 +#: ../../library/http.cookiejar.rst:440 msgid "" "The most useful way to define a :class:`CookiePolicy` class is by " "subclassing from :class:`DefaultCookiePolicy` and overriding some or all of " @@ -727,21 +727,21 @@ msgstr "" "寫其中的一些或全部方法是最有用的。:class:`CookiePolicy` 本身可以用做 '無策" "略',允許設定和接收任何和所有的 cookies (這不太可能有用)。" -#: ../../library/http.cookiejar.rst:452 +#: ../../library/http.cookiejar.rst:449 msgid "DefaultCookiePolicy objects" msgstr "DefaultCookiePolicy 物件" -#: ../../library/http.cookiejar.rst:454 +#: ../../library/http.cookiejar.rst:451 msgid "Implements the standard rules for accepting and returning cookies." msgstr "執行接受和回傳 cookie 的標準規則。" -#: ../../library/http.cookiejar.rst:456 +#: ../../library/http.cookiejar.rst:453 msgid "" "Both :rfc:`2965` and Netscape cookies are covered. RFC 2965 handling is " "switched off by default." msgstr "同時支援 :rfc:`2965` 和 Netscape cookies。 RFC 2965 的處理預設為關閉。" -#: ../../library/http.cookiejar.rst:459 +#: ../../library/http.cookiejar.rst:456 msgid "" "The easiest way to provide your own policy is to override this class and " "call its methods in your overridden implementations before adding your own " @@ -750,7 +750,7 @@ msgstr "" "提供你自己的策略的最簡單方法是覆寫此類別,並在你覆寫的實作中呼叫其方法,然後" "再加入你自己的額外檢查: ::" -#: ../../library/http.cookiejar.rst:463 +#: ../../library/http.cookiejar.rst:460 msgid "" "import http.cookiejar\n" "class MyCookiePolicy(http.cookiejar.DefaultCookiePolicy):\n" @@ -772,7 +772,7 @@ msgstr "" " return False\n" " return True" -#: ../../library/http.cookiejar.rst:472 +#: ../../library/http.cookiejar.rst:469 msgid "" "In addition to the features required to implement the :class:`CookiePolicy` " "interface, this class allows you to block and allow domains from setting and " @@ -784,7 +784,7 @@ msgstr "" "域名稱設定和接收 cookies。 還有調整嚴格度的控制選項,可讓你稍微收緊相對寬鬆" "的 Netscape 通訊協定(代價是阻擋一些良性 cookies)。" -#: ../../library/http.cookiejar.rst:478 +#: ../../library/http.cookiejar.rst:475 msgid "" "A domain blocklist and allowlist is provided (both off by default). Only " "domains not in the blocklist and present in the allowlist (if the allowlist " @@ -802,7 +802,7 @@ msgstr "" "*allowed_domains* 的相應引數和方法)。如果你設定了允許清單,可以透過將它設為 " "``None`` 來再次關閉它。" -#: ../../library/http.cookiejar.rst:486 +#: ../../library/http.cookiejar.rst:483 msgid "" "Domains in block or allow lists that do not start with a dot must equal the " "cookie domain to be matched. For example, ``\"example.com\"`` matches a " @@ -822,40 +822,40 @@ msgstr "" "必須完全匹配。例如,如果 blocked_domains 包含 ``\"192.168.1.2\"`` 和 " "``\".168.1.2\"``,則 192.168.1.2 會被封鎖,但 193.168.1.2 則不會。" -#: ../../library/http.cookiejar.rst:495 +#: ../../library/http.cookiejar.rst:492 msgid "" ":class:`DefaultCookiePolicy` implements the following additional methods:" msgstr ":class:`DefaultCookiePolicy` 實作了下列附加方法:" -#: ../../library/http.cookiejar.rst:500 +#: ../../library/http.cookiejar.rst:497 msgid "Return the sequence of blocked domains (as a tuple)." msgstr "回傳被阻止網域的序列(以元組形式)。" -#: ../../library/http.cookiejar.rst:505 +#: ../../library/http.cookiejar.rst:502 msgid "Set the sequence of blocked domains." msgstr "設定阻止網域的順序。" -#: ../../library/http.cookiejar.rst:510 +#: ../../library/http.cookiejar.rst:507 msgid "" "Return ``True`` if *domain* is on the blocklist for setting or receiving " "cookies." msgstr "如果 *domain* 在設定或接收 cookies 的阻止列表上,則回傳 ``True``。" -#: ../../library/http.cookiejar.rst:516 +#: ../../library/http.cookiejar.rst:513 msgid "Return ``None``, or the sequence of allowed domains (as a tuple)." msgstr "回傳 ``None``,或允許網域的序列(以元組形式)。" -#: ../../library/http.cookiejar.rst:521 +#: ../../library/http.cookiejar.rst:518 msgid "Set the sequence of allowed domains, or ``None``." msgstr "設定允許網域的序列,或 ``None``。" -#: ../../library/http.cookiejar.rst:526 +#: ../../library/http.cookiejar.rst:523 msgid "" "Return ``True`` if *domain* is not on the allowlist for setting or receiving " "cookies." msgstr "如果 *domain* 不在設定或接收 cookies 的允許清單上,則回傳 ``True``。" -#: ../../library/http.cookiejar.rst:529 +#: ../../library/http.cookiejar.rst:526 msgid "" ":class:`DefaultCookiePolicy` instances have the following attributes, which " "are all initialised from the constructor arguments of the same name, and " @@ -864,7 +864,7 @@ msgstr "" ":class:`DefaultCookiePolicy` 實例有以下屬性,這些屬性都是由同名的建構函式引數" "初始化,而且都可以被指定。" -#: ../../library/http.cookiejar.rst:536 +#: ../../library/http.cookiejar.rst:533 msgid "" "If true, request that the :class:`CookieJar` instance downgrade :rfc:`2109` " "cookies (that is, cookies received in a :mailheader:`Set-Cookie` header with " @@ -880,11 +880,11 @@ msgstr "" "``None``,在這種情況下,若且唯若 :rfc:`2965` 處理被關閉,RFC 2109 cookies 才" "會被降級。因此,RFC 2109 cookie 在預設情況下會被降級。" -#: ../../library/http.cookiejar.rst:544 +#: ../../library/http.cookiejar.rst:541 msgid "General strictness switches:" msgstr "一般的調整嚴格度的控制選項:" -#: ../../library/http.cookiejar.rst:548 +#: ../../library/http.cookiejar.rst:545 msgid "" "Don't allow sites to set two-component domains with country-code top-level " "domains like ``.co.uk``, ``.gov.uk``, ``.co.nz``.etc. This is far from " @@ -893,11 +893,11 @@ msgstr "" "不允許網站設定具有國家代碼頂層域名的兩層域名,如 ``.co.uk``、``.gov.uk``、``." "co.nz`` 等。 這遠遠不夠完美,也不能保證一定有效!" -#: ../../library/http.cookiejar.rst:553 +#: ../../library/http.cookiejar.rst:550 msgid ":rfc:`2965` protocol strictness switches:" msgstr ":rfc:`2965` 通訊協定調整嚴格度的控制選項:" -#: ../../library/http.cookiejar.rst:557 +#: ../../library/http.cookiejar.rst:554 msgid "" "Follow :rfc:`2965` rules on unverifiable transactions (usually, an " "unverifiable transaction is one resulting from a redirect or a request for " @@ -908,32 +908,32 @@ msgstr "" "重定向或請求發佈在其它網站的圖片導致的)。 如果該屬性為假值,則\\ *永遠不會" "*\\ 基於可驗證性而阻止 cookie" -#: ../../library/http.cookiejar.rst:563 +#: ../../library/http.cookiejar.rst:560 msgid "Netscape protocol strictness switches:" msgstr "Netscape 通訊協定調整嚴格度的控制選項:" -#: ../../library/http.cookiejar.rst:567 +#: ../../library/http.cookiejar.rst:564 msgid "" "Apply :rfc:`2965` rules on unverifiable transactions even to Netscape " "cookies." msgstr "即便是對 Netscape cookie 也要應用 :rfc:`2965` 規則。" -#: ../../library/http.cookiejar.rst:572 +#: ../../library/http.cookiejar.rst:569 msgid "" "Flags indicating how strict to be with domain-matching rules for Netscape " "cookies. See below for acceptable values." msgstr "指明針對 Netscape cookie 的網域匹配規則的嚴格程度。 可接受的值見下文。" -#: ../../library/http.cookiejar.rst:578 +#: ../../library/http.cookiejar.rst:575 msgid "" "Ignore cookies in Set-Cookie: headers that have names starting with ``'$'``." msgstr "忽略 Set-Cookie: 標頭中名稱以 ``'$'`` 開頭的 cookies。" -#: ../../library/http.cookiejar.rst:583 +#: ../../library/http.cookiejar.rst:580 msgid "Don't allow setting cookies whose path doesn't path-match request URI." msgstr "不允許設置路徑與請求 URL 路徑不匹配的 cookie。" -#: ../../library/http.cookiejar.rst:585 +#: ../../library/http.cookiejar.rst:582 msgid "" ":attr:`~DefaultCookiePolicy.strict_ns_domain` is a collection of flags. Its " "value is constructed by or-ing together (for example, ``DomainStrictNoDots|" @@ -943,7 +943,7 @@ msgstr "" "位元或組成(例如,``DomainStrictNoDots|DomainStrictNonDomain`` 表示兩個旗標都" "被設定)。" -#: ../../library/http.cookiejar.rst:592 +#: ../../library/http.cookiejar.rst:589 msgid "" "When setting cookies, the 'host prefix' must not contain a dot (for example, " "``www.foo.bar.com`` can't set a cookie for ``.bar.com``, because ``www.foo`` " @@ -952,7 +952,7 @@ msgstr "" "設定 cookie 時,「host 前綴」不得包含點(例如,``www.foo.bar.com`` 不能為 " "``.bar.com`` 設定 cookie,因為 ``www.foo`` 包含一個點)。" -#: ../../library/http.cookiejar.rst:599 +#: ../../library/http.cookiejar.rst:596 msgid "" "Cookies that did not explicitly specify a ``domain`` cookie-attribute can " "only be returned to a domain equal to the domain that set the cookie (for " @@ -963,31 +963,31 @@ msgstr "" "域相同的網域(例如,``spam.example.com`` 將不會回傳來自 ``example.com`` 但沒" "有 ``domain`` cookie-attribute 的 Cookie)。" -#: ../../library/http.cookiejar.rst:607 +#: ../../library/http.cookiejar.rst:604 msgid "When setting cookies, require a full :rfc:`2965` domain-match." msgstr "設定 cookie 時,需要完整的 :rfc:`2965` 網域匹配。" -#: ../../library/http.cookiejar.rst:609 +#: ../../library/http.cookiejar.rst:606 msgid "" "The following attributes are provided for convenience, and are the most " "useful combinations of the above flags:" msgstr "為了方便起見,以下屬性是上述旗標最有用的組合:" -#: ../../library/http.cookiejar.rst:615 +#: ../../library/http.cookiejar.rst:612 msgid "" "Equivalent to 0 (that is, all of the above Netscape domain strictness flags " "switched off)." msgstr "等於 0(即關閉上述所有 Netscape 網域嚴格度旗標)。" -#: ../../library/http.cookiejar.rst:621 +#: ../../library/http.cookiejar.rst:618 msgid "Equivalent to ``DomainStrictNoDots|DomainStrictNonDomain``." msgstr "等價於 ``DomainStrictNoDots|DomainStrictNonDomain``。" -#: ../../library/http.cookiejar.rst:625 +#: ../../library/http.cookiejar.rst:622 msgid "Cookie objects" msgstr "Cookie 物件" -#: ../../library/http.cookiejar.rst:627 +#: ../../library/http.cookiejar.rst:624 msgid "" ":class:`Cookie` instances have Python attributes roughly corresponding to " "the standard cookie-attributes specified in the various cookie standards. " @@ -1003,7 +1003,7 @@ msgstr "" "cookie 可能會被 :mod:`!http.cookiejar` 從版本 1「降級」到版本 0 (Netscape) " "cookie。" -#: ../../library/http.cookiejar.rst:635 +#: ../../library/http.cookiejar.rst:632 msgid "" "Assignment to these attributes should not be necessary other than in rare " "circumstances in a :class:`CookiePolicy` method. The class does not enforce " @@ -1012,7 +1012,7 @@ msgstr "" "除了在 :class:`CookiePolicy` 方法中的罕見情況外,不應該對這些屬性進行指定。 " "這個類別不會強制執行內部一致性,所以如果你這麼做,你應該要知道你在做什麼。" -#: ../../library/http.cookiejar.rst:642 +#: ../../library/http.cookiejar.rst:639 msgid "" "Integer or ``None``. Netscape cookies have :attr:`version` 0. :rfc:`2965` " "and :rfc:`2109` cookies have a ``version`` cookie-attribute of 1. However, " @@ -1024,34 +1024,34 @@ msgstr "" "意 :mod:`!http.cookiejar` 可能會將 RFC 2109 cookie「降級」為 Netscape " "cookie,在這種情況下 :attr:`version` 為 0。" -#: ../../library/http.cookiejar.rst:650 +#: ../../library/http.cookiejar.rst:647 msgid "Cookie name (a string)." msgstr "Cookie 名稱(字串)。" -#: ../../library/http.cookiejar.rst:655 +#: ../../library/http.cookiejar.rst:652 msgid "Cookie value (a string), or ``None``." msgstr "Cookie 值(字串),或 ``None``。" -#: ../../library/http.cookiejar.rst:660 +#: ../../library/http.cookiejar.rst:657 msgid "" "String representing a port or a set of ports (for example, '80', or " "'80,8080'), or ``None``." msgstr "" "代表一個連接埠或一組連接埠的字串(例如「80」或「80,8080」),或 ``None``。" -#: ../../library/http.cookiejar.rst:666 +#: ../../library/http.cookiejar.rst:663 msgid "Cookie domain (a string)." msgstr "Cookie 網域(字串)。" -#: ../../library/http.cookiejar.rst:671 +#: ../../library/http.cookiejar.rst:668 msgid "Cookie path (a string, for example, ``'/acme/rocket_launchers'``)." msgstr "Cookie 路徑(字串,例如 ``'/acme/rocket_launchers'``)。" -#: ../../library/http.cookiejar.rst:676 +#: ../../library/http.cookiejar.rst:673 msgid "``True`` if cookie should only be returned over a secure connection." msgstr "如果 cookie 只能透過安全連線回傳,則為 ``True``。" -#: ../../library/http.cookiejar.rst:681 +#: ../../library/http.cookiejar.rst:678 msgid "" "Integer expiry date in seconds since epoch, or ``None``. See also the :meth:" "`is_expired` method." @@ -1059,23 +1059,23 @@ msgstr "" "自 epoch 起計算的整數到期時間,以秒為單位,或 ``None``。另請參" "閱 :meth:`is_expired` 方法。" -#: ../../library/http.cookiejar.rst:687 +#: ../../library/http.cookiejar.rst:684 msgid "``True`` if this is a session cookie." msgstr "如果這是 session cookie,即為 ``True``。" -#: ../../library/http.cookiejar.rst:692 +#: ../../library/http.cookiejar.rst:689 msgid "" "String comment from the server explaining the function of this cookie, or " "``None``." msgstr "來自伺服器解釋此 cookie 功能的字串註解,或 ``None``。" -#: ../../library/http.cookiejar.rst:698 +#: ../../library/http.cookiejar.rst:695 msgid "" "URL linking to a comment from the server explaining the function of this " "cookie, or ``None``." msgstr "連結到伺服器所提供、解釋此 cookie 功能之註解的 URL,或為 ``None``。" -#: ../../library/http.cookiejar.rst:704 +#: ../../library/http.cookiejar.rst:701 msgid "" "``True`` if this cookie was received as an :rfc:`2109` cookie (that is, the " "cookie arrived in a :mailheader:`Set-Cookie` header, and the value of the " @@ -1089,7 +1089,7 @@ msgstr "" "http.cookiejar` 可能會將 RFC 2109 cookie「降級」為 Netscape cookie,在這種情" "況下 :attr:`version` 的值是 0。" -#: ../../library/http.cookiejar.rst:713 +#: ../../library/http.cookiejar.rst:710 msgid "" "``True`` if a port or set of ports was explicitly specified by the server " "(in the :mailheader:`Set-Cookie` / :mailheader:`Set-Cookie2` header)." @@ -1097,42 +1097,42 @@ msgstr "" "如果伺服器顯式地指定了一個連接埠或一組連接埠(在 :mailheader:`Set-Cookie` / :" "mailheader:`Set-Cookie2` 標頭中)。" -#: ../../library/http.cookiejar.rst:719 +#: ../../library/http.cookiejar.rst:716 msgid "``True`` if a domain was explicitly specified by the server." msgstr "如果伺服器明確指定網域,則為 ``True``。" -#: ../../library/http.cookiejar.rst:724 +#: ../../library/http.cookiejar.rst:721 msgid "" "``True`` if the domain explicitly specified by the server began with a dot " "(``'.'``)." msgstr "如果伺服器明確指定的網域以點 (``'.'``) 開頭,則為 ``True``。" -#: ../../library/http.cookiejar.rst:727 +#: ../../library/http.cookiejar.rst:724 msgid "" "Cookies may have additional non-standard cookie-attributes. These may be " "accessed using the following methods:" msgstr "" "Cookies 可能具有額外的非標準 cookie 屬性。你可以使用下列方法存取這些屬性:" -#: ../../library/http.cookiejar.rst:733 +#: ../../library/http.cookiejar.rst:730 msgid "Return ``True`` if cookie has the named cookie-attribute." msgstr "如果 cookie 具有指定的 cookie 屬性,則回傳 ``True`` 。" -#: ../../library/http.cookiejar.rst:738 +#: ../../library/http.cookiejar.rst:735 msgid "" "If cookie has the named cookie-attribute, return its value. Otherwise, " "return *default*." msgstr "如果 cookie 具有指定的 cookie 屬性,則回傳其值。否則,回傳 *default*。" -#: ../../library/http.cookiejar.rst:744 +#: ../../library/http.cookiejar.rst:741 msgid "Set the value of the named cookie-attribute." msgstr "設定指定 cookie 屬性的值。" -#: ../../library/http.cookiejar.rst:746 +#: ../../library/http.cookiejar.rst:743 msgid "The :class:`Cookie` class also defines the following method:" msgstr ":class:`Cookie` 類別也定義了以下方法:" -#: ../../library/http.cookiejar.rst:751 +#: ../../library/http.cookiejar.rst:748 msgid "" "``True`` if cookie has passed the time at which the server requested it " "should expire. If *now* is given (in seconds since the epoch), return " @@ -1141,16 +1141,16 @@ msgstr "" "如果 cookie 已經超過伺服器要求的過期時間,則回傳 ``True`` 。 如果給定了 " "*now* (以自紀元起的秒數為單位),則會回傳 cookie 是否已在指定時間過期。" -#: ../../library/http.cookiejar.rst:757 +#: ../../library/http.cookiejar.rst:754 msgid "Examples" msgstr "範例" -#: ../../library/http.cookiejar.rst:759 +#: ../../library/http.cookiejar.rst:756 msgid "" "The first example shows the most common usage of :mod:`!http.cookiejar`::" msgstr "第一個範例展示了 :mod:`!http.cookiejar`: 最常見的用法: ::" -#: ../../library/http.cookiejar.rst:761 +#: ../../library/http.cookiejar.rst:758 msgid "" "import http.cookiejar, urllib.request\n" "cj = http.cookiejar.CookieJar()\n" @@ -1164,7 +1164,7 @@ msgstr "" "HTTPCookieProcessor(cj))\n" "r = opener.open(\"http://example.com/\")" -#: ../../library/http.cookiejar.rst:766 +#: ../../library/http.cookiejar.rst:763 msgid "" "This example illustrates how to open a URL using your Netscape, Mozilla, or " "Lynx cookies (assumes Unix/Netscape convention for location of the cookies " @@ -1173,7 +1173,7 @@ msgstr "" "本範例說明如何使用你的 Netscape、Mozilla 或 Lynx cookies 打開 URL (假設 Unix/" "Netscape 會慣用 cookies 檔案的位置): ::" -#: ../../library/http.cookiejar.rst:769 +#: ../../library/http.cookiejar.rst:766 msgid "" "import os, http.cookiejar, urllib.request\n" "cj = http.cookiejar.MozillaCookieJar()\n" @@ -1191,7 +1191,7 @@ msgstr "" "HTTPCookieProcessor(cj))\n" "r = opener.open(\"http://example.com/\")" -#: ../../library/http.cookiejar.rst:775 +#: ../../library/http.cookiejar.rst:772 msgid "" "The next example illustrates the use of :class:`DefaultCookiePolicy`. Turn " "on :rfc:`2965` cookies, be more strict about domains when setting and " @@ -1202,7 +1202,7 @@ msgstr "" "cookies,在設定和回傳 Netscape cookies 時對網域更嚴格,並阻止某些網域設定 " "cookies 或讓其回傳: ::" -#: ../../library/http.cookiejar.rst:780 +#: ../../library/http.cookiejar.rst:777 msgid "" "import urllib.request\n" "from http.cookiejar import CookieJar, DefaultCookiePolicy\n" diff --git a/library/http.cookies.po b/library/http.cookies.po index f1315b328bf..a44bd1c705d 100644 --- a/library/http.cookies.po +++ b/library/http.cookies.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-12-24 18:49+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!http.cookies` --- HTTP state management" msgstr ":mod:`!http.cookies` --- HTTP 狀態管理" -#: ../../library/http.cookies.rst:10 +#: ../../library/http.cookies.rst:7 msgid "**Source code:** :source:`Lib/http/cookies.py`" msgstr "**原始碼:**\\ :source:`Lib/http/cookies.py`" -#: ../../library/http.cookies.rst:14 +#: ../../library/http.cookies.rst:11 msgid "" "The :mod:`!http.cookies` module defines classes for abstracting the concept " "of cookies, an HTTP state management mechanism. It supports both simple " @@ -36,7 +36,7 @@ msgstr "" "狀態管理機制。它支援簡單的純字串 cookie,也提供了將任何可序列化的資料型別作" "為 cookie 值的抽象化。" -#: ../../library/http.cookies.rst:19 +#: ../../library/http.cookies.rst:16 msgid "" "The module formerly strictly applied the parsing rules described in the :rfc:" "`2109` and :rfc:`2068` specifications. It has since been discovered that " @@ -49,7 +49,7 @@ msgstr "" "現 MSIE 3.0x 並不遵循這些規範所描述的字元規則,許多目前的瀏覽器和伺服器也在處" "理 cookie 時放寬了剖析規則。因此,此模組現在使用的剖析規則比之前的更為寬鬆。" -#: ../../library/http.cookies.rst:26 +#: ../../library/http.cookies.rst:23 msgid "" "The character set, :data:`string.ascii_letters`, :data:`string.digits` and " "``!#$%&'*+-.^_`|~:`` denote the set of valid characters allowed by this " @@ -58,11 +58,11 @@ msgstr "" "字元集 :data:`string.ascii_letters`、:data:`string.digits` 和 ``!#$%&'*+-." "^_`|~`` 表示此模組在 cookie 名稱 (:attr:`~Morsel.key`) 中允許的合法字元集合。" -#: ../../library/http.cookies.rst:30 +#: ../../library/http.cookies.rst:27 msgid "Allowed ':' as a valid cookie name character." msgstr "允許 ':' 作為有效的 cookie 名稱字元。" -#: ../../library/http.cookies.rst:36 +#: ../../library/http.cookies.rst:33 msgid "" "On encountering an invalid cookie, :exc:`CookieError` is raised, so if your " "cookie data comes from a browser you should always prepare for invalid data " @@ -71,7 +71,7 @@ msgstr "" "當遇到無效的 cookie 時,會引發 :exc:`CookieError`,因此如果你的 cookie 資料來" "自瀏覽器,在剖析時你應該總是為無效資料作準備並捕捉 :exc:`CookieError`。" -#: ../../library/http.cookies.rst:43 +#: ../../library/http.cookies.rst:40 msgid "" "Exception failing because of :rfc:`2109` invalidity: incorrect attributes, " "incorrect :mailheader:`Set-Cookie` header, etc." @@ -79,7 +79,7 @@ msgstr "" "因為不符合 :rfc:`2109` 而引發的例外:不正確的屬性、不正確的 :mailheader:`Set-" "Cookie` 標頭等。" -#: ../../library/http.cookies.rst:49 +#: ../../library/http.cookies.rst:46 msgid "" "This class is a dictionary-like object whose keys are strings and whose " "values are :class:`Morsel` instances. Note that upon setting a key to a " @@ -89,11 +89,11 @@ msgstr "" "這個類別是一個類似字典的物件,其中的鍵是字串,而值則是 :class:`Morsel` 實例。" "請注意,當設定鍵的值時,值會先被轉換為一個包含該鍵和值的 :class:`Morsel`。" -#: ../../library/http.cookies.rst:53 +#: ../../library/http.cookies.rst:50 msgid "If *input* is given, it is passed to the :meth:`load` method." msgstr "如果有給定 *input*,它會被傳遞給 :meth:`load` 方法。" -#: ../../library/http.cookies.rst:58 +#: ../../library/http.cookies.rst:55 msgid "" "This class derives from :class:`BaseCookie` and overrides :meth:`~BaseCookie." "value_decode` and :meth:`~BaseCookie.value_encode`. :class:`!SimpleCookie` " @@ -106,11 +106,11 @@ msgstr "" "cookie 值。當設定值時,:class:`!SimpleCookie` 會呼叫內建的 :func:`str` 來將值" "轉換為字串。從 HTTP 接收的值會保持為字串。" -#: ../../library/http.cookies.rst:66 +#: ../../library/http.cookies.rst:63 msgid "Module :mod:`http.cookiejar`" msgstr ":mod:`http.cookiejar` 模組" -#: ../../library/http.cookies.rst:67 +#: ../../library/http.cookies.rst:64 msgid "" "HTTP cookie handling for web *clients*. The :mod:`http.cookiejar` and :mod:" "`!http.cookies` modules do not depend on each other." @@ -118,19 +118,19 @@ msgstr "" "用於網路\\ *用戶端*\\ 的 HTTP cookie 處理。:mod:`http.cookiejar` 和 :mod:" "`!http.cookies` 模組互不相依。" -#: ../../library/http.cookies.rst:70 +#: ../../library/http.cookies.rst:67 msgid ":rfc:`2109` - HTTP State Management Mechanism" msgstr ":rfc:`2109` - HTTP 狀態管理機制" -#: ../../library/http.cookies.rst:71 +#: ../../library/http.cookies.rst:68 msgid "This is the state management specification implemented by this module." msgstr "這是此模組實作的狀態管理規範。" -#: ../../library/http.cookies.rst:77 +#: ../../library/http.cookies.rst:74 msgid "Cookie Objects" msgstr "Cookie 物件" -#: ../../library/http.cookies.rst:82 +#: ../../library/http.cookies.rst:79 msgid "" "Return a tuple ``(real_value, coded_value)`` from a string representation. " "``real_value`` can be any type. This method does no decoding in :class:" @@ -139,7 +139,7 @@ msgstr "" "從字串表示回傳 ``(real_value, coded_value)`` 的元組。``real_value`` 可以是任" "何型別。此方法在 :class:`BaseCookie` 中不做解碼 --- 它存在以便可以被覆寫。" -#: ../../library/http.cookies.rst:89 +#: ../../library/http.cookies.rst:86 msgid "" "Return a tuple ``(real_value, coded_value)``. *val* can be any type, but " "``coded_value`` will always be converted to a string. This method does no " @@ -149,7 +149,7 @@ msgstr "" "``coded_value`` 總是會被轉換為字串。此方法在 :class:`BaseCookie` 中不做編碼 " "--- 它存在以便可以被覆寫。" -#: ../../library/http.cookies.rst:94 +#: ../../library/http.cookies.rst:91 msgid "" "In general, it should be the case that :meth:`value_encode` and :meth:" "`value_decode` are inverses on the range of *value_decode*." @@ -157,7 +157,7 @@ msgstr "" "一般來說,:meth:`value_encode` 和 :meth:`value_decode` 應該在 *value_decode* " "的範圍內是互逆的 (inverse)。" -#: ../../library/http.cookies.rst:100 +#: ../../library/http.cookies.rst:97 msgid "" "Return a string representation suitable to be sent as HTTP headers. *attrs* " "and *header* are sent to each :class:`Morsel`'s :meth:`~Morsel.output` " @@ -168,7 +168,7 @@ msgstr "" "個 :class:`Morsel` 的 :meth:`~Morsel.output` 方法。*sep* 用來連接標頭,預設" "為 ``'\\r\\n'`` (CRLF) 的組合。" -#: ../../library/http.cookies.rst:108 +#: ../../library/http.cookies.rst:105 msgid "" "Return an embeddable JavaScript snippet, which, if run on a browser which " "supports JavaScript, will act the same as if the HTTP headers was sent." @@ -176,12 +176,19 @@ msgstr "" "回傳一個可嵌入的 JavaScript 片段,如果在支援 JavaScript 的瀏覽器上執行,它的" "行為會與 HTTP 標頭被傳送的情況相同。" -#: ../../library/http.cookies.rst:111 ../../library/http.cookies.rst:227 -#: ../../library/http.cookies.rst:235 +#: ../../library/http.cookies.rst:108 ../../library/http.cookies.rst:230 +#: ../../library/http.cookies.rst:244 msgid "The meaning for *attrs* is the same as in :meth:`output`." msgstr "*attrs* 的意義與 :meth:`output` 裡的相同。" -#: ../../library/http.cookies.rst:116 +#: ../../library/http.cookies.rst:110 +msgid "" +"This method generates a JavaScript snippet to set cookies in the browser, " +"which is no longer considered a standard or recommended approach. Use :meth:" +"`~http.cookies.BaseCookie.output` instead to generate HTTP headers." +msgstr "" + +#: ../../library/http.cookies.rst:119 msgid "" "If *rawdata* is a string, parse it as an ``HTTP_COOKIE`` and add the values " "found there as :class:`Morsel`\\ s. If it is a dictionary, it is equivalent " @@ -190,7 +197,7 @@ msgstr "" "如果 *rawdata* 是字串,會將其作為 ``HTTP_COOKIE`` 剖析,並將在其中找到的值當" "作 :class:`Morsel` 新增。如果它是一個字典,則等同於: ::" -#: ../../library/http.cookies.rst:119 +#: ../../library/http.cookies.rst:122 msgid "" "for k, v in rawdata.items():\n" " cookie[k] = v" @@ -198,15 +205,15 @@ msgstr "" "for k, v in rawdata.items():\n" " cookie[k] = v" -#: ../../library/http.cookies.rst:126 +#: ../../library/http.cookies.rst:129 msgid "Morsel Objects" msgstr "Morsel 物件" -#: ../../library/http.cookies.rst:131 +#: ../../library/http.cookies.rst:134 msgid "Abstract a key/value pair, which has some :rfc:`2109` attributes." msgstr "抽象化一個鍵 / 值對,它有一些 :rfc:`2109` 屬性。" -#: ../../library/http.cookies.rst:133 +#: ../../library/http.cookies.rst:136 msgid "" "Morsels are dictionary-like objects, whose set of keys is constant --- the " "valid :rfc:`2109` attributes, which are:" @@ -214,7 +221,7 @@ msgstr "" "Morsel 是一種類似字典的物件,其鍵的集合是固定的 --- 有效的 :rfc:`2109` 屬性," "它們是:" -#: ../../library/http.cookies.rst:147 +#: ../../library/http.cookies.rst:150 msgid "" "The attribute :attr:`httponly` specifies that the cookie is only transferred " "in HTTP requests, and is not accessible through JavaScript. This is intended " @@ -223,7 +230,7 @@ msgstr "" "屬性 :attr:`httponly` 指定 cookie 僅在 HTTP 請求中傳輸,而不可透過 " "JavaScript 存取。這是為了減輕某些形式的跨網站腳本攻擊。" -#: ../../library/http.cookies.rst:151 +#: ../../library/http.cookies.rst:154 msgid "" "The attribute :attr:`samesite` controls when the browser sends the cookie " "with cross-site requests. This helps to mitigate CSRF attacks. Valid values " @@ -237,7 +244,7 @@ msgstr "" "(同站請求和頂層導航時傳送)和 \"None\"\\ (同站請求和跨站請求時傳送)。使用 " "\"None\" 時,必須同時設定 \"secure\" 屬性,這是現代瀏覽器的要求。" -#: ../../library/http.cookies.rst:158 +#: ../../library/http.cookies.rst:161 msgid "" "The attribute :attr:`partitioned` indicates to user agents that these cross-" "site cookies *should* only be available in the same top-level context that " @@ -248,7 +255,7 @@ msgstr "" "該*\\ 只能在與首次設定 cookie 時相同的頂層情境中使用。要讓 user agent 接受此" "設定,你\\ **必須**\\ 同時設定 ``Secure``。" -#: ../../library/http.cookies.rst:163 +#: ../../library/http.cookies.rst:166 msgid "" "In addition, it is recommended to use the ``__Host`` prefix when setting " "partitioned cookies to make them bound to the hostname and not the " @@ -259,18 +266,18 @@ msgstr "" "主機名稱而非可註冊網域。請閱讀 `CHIPS (Cookies Having Independent " "Partitioned State)`_ 以取得完整細節和範例。" -#: ../../library/http.cookies.rst:171 +#: ../../library/http.cookies.rst:174 msgid "The keys are case-insensitive and their default value is ``''``." msgstr "鍵不區分大小寫,其預設值為 ``''``。" -#: ../../library/http.cookies.rst:173 +#: ../../library/http.cookies.rst:176 msgid "" ":meth:`!__eq__` now takes :attr:`~Morsel.key` and :attr:`~Morsel.value` into " "account." msgstr "" ":meth:`!__eq__` 現在會考慮 :attr:`~Morsel.key` 和 :attr:`~Morsel.value`。" -#: ../../library/http.cookies.rst:177 +#: ../../library/http.cookies.rst:180 msgid "" "Attributes :attr:`~Morsel.key`, :attr:`~Morsel.value` and :attr:`~Morsel." "coded_value` are read-only. Use :meth:`~Morsel.set` for setting them." @@ -278,35 +285,35 @@ msgstr "" "屬性 :attr:`~Morsel.key`、:attr:`~Morsel.value` 和 :attr:`~Morsel." "coded_value` 是唯讀的。請使用 :meth:`~Morsel.set` 來設定它們。" -#: ../../library/http.cookies.rst:182 +#: ../../library/http.cookies.rst:185 msgid "Added support for the :attr:`samesite` attribute." msgstr "新增對 :attr:`samesite` 屬性的支援。" -#: ../../library/http.cookies.rst:185 +#: ../../library/http.cookies.rst:188 msgid "Added support for the :attr:`partitioned` attribute." msgstr "新增對 :attr:`partitioned` 屬性的支援。" -#: ../../library/http.cookies.rst:191 +#: ../../library/http.cookies.rst:194 msgid "The value of the cookie." msgstr "cookie 的值。" -#: ../../library/http.cookies.rst:196 +#: ../../library/http.cookies.rst:199 msgid "The encoded value of the cookie --- this is what should be sent." msgstr "cookie 的編碼值 --- 這是應該被傳送的值。" -#: ../../library/http.cookies.rst:201 +#: ../../library/http.cookies.rst:204 msgid "The name of the cookie." msgstr "cookie 的名稱。" -#: ../../library/http.cookies.rst:206 +#: ../../library/http.cookies.rst:209 msgid "Set the *key*, *value* and *coded_value* attributes." msgstr "設定 *key*、*value* 和 *coded_value* 屬性。" -#: ../../library/http.cookies.rst:211 +#: ../../library/http.cookies.rst:214 msgid "Whether *K* is a member of the set of keys of a :class:`Morsel`." msgstr "*K* 是否為 :class:`Morsel` 的鍵集合中的成員。" -#: ../../library/http.cookies.rst:216 +#: ../../library/http.cookies.rst:219 msgid "" "Return a string representation of the Morsel, suitable to be sent as an HTTP " "header. By default, all the attributes are included, unless *attrs* is " @@ -317,7 +324,7 @@ msgstr "" "定 *attrs*,在此情況下,它應該是一個要使用的屬性的串列。預設的 *header* 是 " "``\"Set-Cookie:\"``。" -#: ../../library/http.cookies.rst:224 +#: ../../library/http.cookies.rst:227 msgid "" "Return an embeddable JavaScript snippet, which, if run on a browser which " "supports JavaScript, will act the same as if the HTTP header was sent." @@ -327,11 +334,18 @@ msgstr "" #: ../../library/http.cookies.rst:232 msgid "" +"This method generates a JavaScript snippet to set cookies in the browser, " +"which is no longer considered a standard or recommended approach. Use :meth:" +"`~http.cookies.Morsel.output` instead to generate HTTP headers." +msgstr "" + +#: ../../library/http.cookies.rst:241 +msgid "" "Return a string representing the Morsel, without any surrounding HTTP or " "JavaScript." msgstr "回傳表示 Morsel 的字串,不包含周圍任何的 HTTP 或 JavaScript。" -#: ../../library/http.cookies.rst:240 +#: ../../library/http.cookies.rst:249 msgid "" "Update the values in the Morsel dictionary with the values in the dictionary " "*values*. Raise an error if any of the keys in the *values* dict is not a " @@ -340,19 +354,19 @@ msgstr "" "更新 Morsel 字典中的值為 *values* 字典中的值。如果 *values* 字典中的任何鍵不" "是有效的 :rfc:`2109` 屬性則引發錯誤。" -#: ../../library/http.cookies.rst:244 +#: ../../library/http.cookies.rst:253 msgid "an error is raised for invalid keys." msgstr "對於無效的鍵會引發錯誤。" -#: ../../library/http.cookies.rst:250 +#: ../../library/http.cookies.rst:259 msgid "Return a shallow copy of the Morsel object." msgstr "回傳 Morsel 物件的淺層複製。" -#: ../../library/http.cookies.rst:252 +#: ../../library/http.cookies.rst:261 msgid "return a Morsel object instead of a dict." msgstr "回傳 Morsel 物件而不是字典。" -#: ../../library/http.cookies.rst:258 +#: ../../library/http.cookies.rst:267 msgid "" "Raise an error if key is not a valid :rfc:`2109` attribute, otherwise behave " "the same as :meth:`dict.setdefault`." @@ -360,17 +374,17 @@ msgstr "" "如果鍵不是一個有效的 :rfc:`2109` 屬性會引發錯誤,否則行為與 :meth:`dict." "setdefault` 相同。" -#: ../../library/http.cookies.rst:265 +#: ../../library/http.cookies.rst:274 msgid "Example" msgstr "範例" -#: ../../library/http.cookies.rst:267 +#: ../../library/http.cookies.rst:276 msgid "" "The following example demonstrates how to use the :mod:`!http.cookies` " "module." msgstr "以下範例示範如何使用 :mod:`!http.cookies` 模組。" -#: ../../library/http.cookies.rst:269 +#: ../../library/http.cookies.rst:278 msgid "" ">>> from http import cookies\n" ">>> C = cookies.SimpleCookie()\n" diff --git a/library/http.server.po b/library/http.server.po index b8b056505a6..5f07ee8fc15 100644 --- a/library/http.server.po +++ b/library/http.server.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-06 00:35+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:03+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -456,80 +456,104 @@ msgid "" "now always returns the IP address." msgstr "" -#: ../../library/http.server.rst:381 +#: ../../library/http.server.rst:382 msgid "" "This class serves files from the directory *directory* and below, or the " "current directory if *directory* is not provided, directly mapping the " "directory structure to HTTP requests." msgstr "" -#: ../../library/http.server.rst:385 +#: ../../library/http.server.rst:386 msgid "Added the *directory* parameter." msgstr "新增 *directory* 參數。" -#: ../../library/http.server.rst:388 +#: ../../library/http.server.rst:389 msgid "The *directory* parameter accepts a :term:`path-like object`." msgstr "" -#: ../../library/http.server.rst:391 +#: ../../library/http.server.rst:392 +msgid "Added *extra_response_headers* parameter." +msgstr "新增 *extra_response_headers* 參數。" + +#: ../../library/http.server.rst:395 msgid "" "A lot of the work, such as parsing the request, is done by the base class :" "class:`BaseHTTPRequestHandler`. This class implements the :func:`do_GET` " "and :func:`do_HEAD` functions." msgstr "" -#: ../../library/http.server.rst:395 +#: ../../library/http.server.rst:399 msgid "" "The following are defined as class-level attributes of :class:" "`SimpleHTTPRequestHandler`:" msgstr "" -#: ../../library/http.server.rst:400 +#: ../../library/http.server.rst:404 msgid "" "This will be ``\"SimpleHTTP/\" + __version__``, where ``__version__`` is " "defined at the module level." msgstr "" -#: ../../library/http.server.rst:405 +#: ../../library/http.server.rst:409 +msgid "" +"Specifies the Content-Type header value sent when the MIME type cannot be " +"guessed from the file extension of the requested URL. By default, it is set " +"to ``'application/octet-stream'``." +msgstr "" + +#: ../../library/http.server.rst:417 msgid "Specifies the filenames that are treated as directory index pages." msgstr "" -#: ../../library/http.server.rst:407 +#: ../../library/http.server.rst:419 msgid "Defaults to ``(\"index.html\", \"index.htm\")``." msgstr "" -#: ../../library/http.server.rst:413 +#: ../../library/http.server.rst:425 msgid "" "A dictionary mapping suffixes into MIME types, contains custom overrides for " "the default system mappings. The mapping is used case-insensitively, and so " "should contain only lower-cased keys." msgstr "" -#: ../../library/http.server.rst:417 +#: ../../library/http.server.rst:429 msgid "" "This dictionary is no longer filled with the default system mappings, but " "only contains overrides." msgstr "" -#: ../../library/http.server.rst:421 +#: ../../library/http.server.rst:435 +msgid "" +"A sequence of ``(name, value)`` pairs containing user-defined extra HTTP " +"response headers to add to each successful HTTP status 200 response. These " +"headers are not included in other status code responses." +msgstr "" + +#: ../../library/http.server.rst:439 +msgid "" +"Headers that the server sends automatically such as ``Content-Type`` will " +"not be overwritten by :attr:`!extra_response_headers`." +msgstr "" + +#: ../../library/http.server.rst:442 msgid "" "The :class:`SimpleHTTPRequestHandler` class defines the following methods:" msgstr ":class:`SimpleHTTPRequestHandler` 類別定義了以下方法:" -#: ../../library/http.server.rst:425 +#: ../../library/http.server.rst:446 msgid "" "This method serves the ``'HEAD'`` request type: it sends the headers it " "would send for the equivalent ``GET`` request. See the :meth:`do_GET` method " "for a more complete explanation of the possible headers." msgstr "" -#: ../../library/http.server.rst:431 +#: ../../library/http.server.rst:452 msgid "" "The request is mapped to a local file by interpreting the request as a path " "relative to the current working directory." msgstr "" -#: ../../library/http.server.rst:434 +#: ../../library/http.server.rst:455 msgid "" "If the request was mapped to a directory, the directory is checked for an " "index page as specified by :attr:`index_pages`. If found, the file's " @@ -539,7 +563,7 @@ msgid "" "listdir` fails." msgstr "" -#: ../../library/http.server.rst:441 +#: ../../library/http.server.rst:462 msgid "" "If the request was mapped to a file, it is opened. Any :exc:`OSError` " "exception in opening the requested file is mapped to a ``404``, ``'File not " @@ -550,68 +574,74 @@ msgid "" "*extensions_map* variable, and the file contents are returned." msgstr "" -#: ../../library/http.server.rst:449 +#: ../../library/http.server.rst:470 msgid "" "A ``'Content-type:'`` header with the guessed content type is output, " "followed by a ``'Content-Length:'`` header with the file's size and a " "``'Last-Modified:'`` header with the file's modification time." msgstr "" -#: ../../library/http.server.rst:453 +#: ../../library/http.server.rst:474 +msgid "" +"The instance attribute :attr:`extra_response_headers` is a sequence of " +"``(name, value)`` pairs containing user-defined extra response headers." +msgstr "" + +#: ../../library/http.server.rst:477 msgid "" "Then follows a blank line signifying the end of the headers, and then the " "contents of the file are output." msgstr "" -#: ../../library/http.server.rst:456 +#: ../../library/http.server.rst:480 msgid "" "For example usage, see the implementation of the ``test`` function in :" "source:`Lib/http/server.py`." msgstr "" -#: ../../library/http.server.rst:459 +#: ../../library/http.server.rst:483 msgid "Support of the ``'If-Modified-Since'`` header." msgstr "" -#: ../../library/http.server.rst:464 +#: ../../library/http.server.rst:488 msgid "Helper to list the contents of *path* when no index page is present." msgstr "" -#: ../../library/http.server.rst:466 +#: ../../library/http.server.rst:490 msgid "" "This returns either a :term:`file-like object` (which must be closed by the " "caller) or ``None`` to indicate an error, in which case the caller has " "nothing further to do. In either case, the headers are sent." msgstr "" -#: ../../library/http.server.rst:472 +#: ../../library/http.server.rst:496 msgid "Guess the type of the file at the given *path*." msgstr "" -#: ../../library/http.server.rst:474 +#: ../../library/http.server.rst:498 msgid "" "This returns a string of the form ``type/subtype``, usable for a MIME " "Content-type header." msgstr "" -#: ../../library/http.server.rst:477 +#: ../../library/http.server.rst:501 msgid "" "The default implementation looks the file's extension up in :attr:" "`extensions_map`, falling back to :func:`mimetypes.guess_file_type` and then " -"to ``'application/octet-stream'``." +"to :attr:`default_content_type`." msgstr "" -#: ../../library/http.server.rst:482 +#: ../../library/http.server.rst:506 msgid "Add :func:`mimetypes.guess_file_type` as a fallback." msgstr "" -#: ../../library/http.server.rst:486 +#: ../../library/http.server.rst:510 msgid "" "The :class:`SimpleHTTPRequestHandler` class can be used to create a very " "basic webserver serving files relative to the current directory as follows::" msgstr "" -#: ../../library/http.server.rst:489 +#: ../../library/http.server.rst:513 msgid "" "import http.server\n" "import socketserver\n" @@ -635,109 +665,43 @@ msgstr "" " print(\"serving at port\", PORT)\n" " httpd.serve_forever()" -#: ../../library/http.server.rst:501 +#: ../../library/http.server.rst:525 msgid "" ":class:`SimpleHTTPRequestHandler` can also be subclassed to enhance " "behavior, such as using different index file names by overriding the class " "attribute :attr:`~SimpleHTTPRequestHandler.index_pages`." msgstr "" -#: ../../library/http.server.rst:508 -msgid "" -"This class is used to serve either files or output of CGI scripts from the " -"current directory and below. Note that mapping HTTP hierarchic structure to " -"local directory structure is exactly as in :class:`SimpleHTTPRequestHandler`." -msgstr "" - -#: ../../library/http.server.rst:514 -msgid "" -"CGI scripts run by the :class:`CGIHTTPRequestHandler` class cannot execute " -"redirects (HTTP code 302), because code 200 (script output follows) is sent " -"prior to execution of the CGI script. This pre-empts the status code." -msgstr "" - -#: ../../library/http.server.rst:519 -msgid "" -"The class will however, run the CGI script, instead of serving it as a file, " -"if it guesses it to be a CGI script. Only directory-based CGI are used --- " -"the other common server configuration is to treat special extensions as " -"denoting CGI scripts." -msgstr "" - -#: ../../library/http.server.rst:524 -msgid "" -"The :func:`~SimpleHTTPRequestHandler.do_GET` and :func:" -"`~SimpleHTTPRequestHandler.do_HEAD` functions are modified to run CGI " -"scripts and serve the output, instead of serving files, if the request leads " -"to somewhere below the ``cgi_directories`` path." -msgstr "" - -#: ../../library/http.server.rst:530 -msgid "The :class:`CGIHTTPRequestHandler` defines the following data member:" -msgstr ":class:`CGIHTTPRequestHandler` 類別定義了以下資料成員:" - -#: ../../library/http.server.rst:534 -msgid "" -"This defaults to ``['/cgi-bin', '/htbin']`` and describes directories to " -"treat as containing CGI scripts." -msgstr "" - -#: ../../library/http.server.rst:537 -msgid "The :class:`CGIHTTPRequestHandler` defines the following method:" -msgstr ":class:`CGIHTTPRequestHandler` 類別定義了以下方法:" - -#: ../../library/http.server.rst:541 -msgid "" -"This method serves the ``'POST'`` request type, only allowed for CGI " -"scripts. Error 501, \"Can only POST to CGI scripts\", is output when trying " -"to POST to a non-CGI url." -msgstr "" - -#: ../../library/http.server.rst:545 -msgid "" -"Note that CGI scripts will be run with UID of user nobody, for security " -"reasons. Problems with the CGI script will be translated to error 403." -msgstr "" - -#: ../../library/http.server.rst:550 -msgid "" -":class:`CGIHTTPRequestHandler` is being removed in 3.15. CGI has not been " -"considered a good way to do things for well over a decade. This code has " -"been unmaintained for a while now and sees very little practical use. " -"Retaining it could lead to further :ref:`security considerations `." -msgstr "" - -#: ../../library/http.server.rst:560 +#: ../../library/http.server.rst:533 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/http.server.rst:562 +#: ../../library/http.server.rst:535 msgid "" ":mod:`!http.server` can also be invoked directly using the :option:`-m` " "switch of the interpreter. The following example illustrates how to serve " "files relative to the current directory:" msgstr "" -#: ../../library/http.server.rst:566 +#: ../../library/http.server.rst:539 msgid "python -m http.server [OPTIONS] [port]" msgstr "python -m http.server [OPTIONS] [port]" -#: ../../library/http.server.rst:570 +#: ../../library/http.server.rst:543 msgid "The following options are accepted:" msgstr "可接受以下選項:" -#: ../../library/http.server.rst:576 +#: ../../library/http.server.rst:549 msgid "" "The server listens to port 8000 by default. The default can be overridden by " "passing the desired port number as an argument:" msgstr "" -#: ../../library/http.server.rst:579 +#: ../../library/http.server.rst:552 msgid "python -m http.server 9000" msgstr "python -m http.server 9000" -#: ../../library/http.server.rst:585 +#: ../../library/http.server.rst:558 msgid "" "Specifies a specific address to which it should bind. Both IPv4 and IPv6 " "addresses are supported. By default, the server binds itself to all " @@ -745,80 +709,68 @@ msgid "" "localhost only:" msgstr "" -#: ../../library/http.server.rst:590 +#: ../../library/http.server.rst:563 msgid "python -m http.server --bind 127.0.0.1" msgstr "python -m http.server --bind 127.0.0.1" -#: ../../library/http.server.rst:596 +#: ../../library/http.server.rst:569 msgid "Support IPv6 in the ``--bind`` option." msgstr "於 ``--bind`` 選項中支援 IPv6。" -#: ../../library/http.server.rst:601 +#: ../../library/http.server.rst:574 msgid "" "Specifies a directory to which it should serve the files. By default, the " "server uses the current directory. For example, the following command uses a " "specific directory:" msgstr "" -#: ../../library/http.server.rst:605 +#: ../../library/http.server.rst:578 msgid "python -m http.server --directory /tmp/" msgstr "python -m http.server --directory /tmp/" -#: ../../library/http.server.rst:613 +#: ../../library/http.server.rst:586 msgid "" "Specifies the HTTP version to which the server is conformant. By default, " "the server is conformant to HTTP/1.0. For example, the following command " "runs an HTTP/1.1 conformant server:" msgstr "" -#: ../../library/http.server.rst:617 +#: ../../library/http.server.rst:590 msgid "python -m http.server --protocol HTTP/1.1" msgstr "python -m http.server --protocol HTTP/1.1" -#: ../../library/http.server.rst:625 +#: ../../library/http.server.rst:598 msgid "" -":class:`CGIHTTPRequestHandler` can be enabled in the command line by passing " -"the ``--cgi`` option::" +"Specifies the default Content-Type HTTP header used when the MIME type " +"cannot be guessed from the URL's file extension. By default, the server uses " +"``'application/octet-stream'``:" msgstr "" -#: ../../library/http.server.rst:628 -msgid "python -m http.server --cgi" -msgstr "python -m http.server --cgi" - -#: ../../library/http.server.rst:632 -msgid "" -":mod:`!http.server` command line ``--cgi`` support is being removed because :" -"class:`CGIHTTPRequestHandler` is being removed." -msgstr "" +#: ../../library/http.server.rst:602 +msgid "python -m http.server --content-type text/html" +msgstr "python -m http.server --content-type text/html" -#: ../../library/http.server.rst:637 -msgid "" -":class:`CGIHTTPRequestHandler` and the ``--cgi`` command-line option are not " -"intended for use by untrusted clients and may be vulnerable to exploitation. " -"Always use within a secure environment." -msgstr "" - -#: ../../library/http.server.rst:643 +#: ../../library/http.server.rst:610 msgid "Specifies a TLS certificate chain for HTTPS connections:" msgstr "" -#: ../../library/http.server.rst:645 +#: ../../library/http.server.rst:612 msgid "python -m http.server --tls-cert fullchain.pem" msgstr "python -m http.server --tls-cert fullchain.pem" -#: ../../library/http.server.rst:653 +#: ../../library/http.server.rst:620 msgid "Specifies a private key file for HTTPS connections." msgstr "" -#: ../../library/http.server.rst:655 ../../library/http.server.rst:670 +#: ../../library/http.server.rst:622 ../../library/http.server.rst:637 msgid "This option requires ``--tls-cert`` to be specified." msgstr "" -#: ../../library/http.server.rst:661 +#: ../../library/http.server.rst:628 msgid "Specifies the password file for password-protected private keys:" msgstr "" -#: ../../library/http.server.rst:663 +#: ../../library/http.server.rst:630 msgid "" "python -m http.server \\\n" " --tls-cert cert.pem \\\n" @@ -830,18 +782,26 @@ msgstr "" " --tls-key key.pem \\\n" " --tls-password-file password.txt" -#: ../../library/http.server.rst:678 +#: ../../library/http.server.rst:643 +msgid "" +"Specify an additional HTTP Response Header to send on successful HTTP 200 " +"responses. Can be used multiple times to send additional custom response " +"headers. Headers that are sent automatically by the server (for instance " +"Content-Type) will not be overwritten by the server." +msgstr "" + +#: ../../library/http.server.rst:654 msgid "Security considerations" msgstr "安全性注意事項" -#: ../../library/http.server.rst:682 +#: ../../library/http.server.rst:658 msgid "" ":class:`SimpleHTTPRequestHandler` will follow symbolic links when handling " "requests which makes it possible for files outside of the specified " "directory to be served." msgstr "" -#: ../../library/http.server.rst:686 +#: ../../library/http.server.rst:662 msgid "" "Methods :meth:`BaseHTTPRequestHandler.send_header` and :meth:" "`BaseHTTPRequestHandler.send_response_only` assume sanitized input and do " @@ -849,7 +809,7 @@ msgid "" "sequences. Untrusted input may result in HTTP header injection attacks." msgstr "" -#: ../../library/http.server.rst:691 +#: ../../library/http.server.rst:667 msgid "" "Earlier versions of Python did not scrub control characters from the log " "messages emitted to stderr from ``python -m http.server`` or the default :" @@ -858,7 +818,7 @@ msgid "" "codes to your terminal." msgstr "" -#: ../../library/http.server.rst:697 +#: ../../library/http.server.rst:673 msgid "Control characters are scrubbed in stderr logs." msgstr "" @@ -886,10 +846,20 @@ msgstr "URL(統一資源定位器)" msgid "httpd" msgstr "httpd" -#: ../../library/http.server.rst:680 +#: ../../library/http.server.rst:656 msgid "http.server" msgstr "http.server" -#: ../../library/http.server.rst:680 +#: ../../library/http.server.rst:656 msgid "security" msgstr "security(安全)" + +#~ msgid "" +#~ "The :class:`CGIHTTPRequestHandler` defines the following data member:" +#~ msgstr ":class:`CGIHTTPRequestHandler` 類別定義了以下資料成員:" + +#~ msgid "The :class:`CGIHTTPRequestHandler` defines the following method:" +#~ msgstr ":class:`CGIHTTPRequestHandler` 類別定義了以下方法:" + +#~ msgid "python -m http.server --cgi" +#~ msgstr "python -m http.server --cgi" diff --git a/library/idle.po b/library/idle.po index c3b87b2c3b6..84df95bea13 100644 --- a/library/idle.po +++ b/library/idle.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-12 00:24+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:03+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,32 +21,32 @@ msgstr "" msgid "IDLE --- Python editor and shell" msgstr "IDLE --- Python 編輯器與 shell" -#: ../../library/idle.rst:8 +#: ../../library/idle.rst:6 msgid "**Source code:** :source:`Lib/idlelib/`" msgstr "**原始碼:**\\ :source:`Lib/idlelib/`" -#: ../../library/idle.rst:20 +#: ../../library/idle.rst:18 msgid "IDLE is Python's Integrated Development and Learning Environment." msgstr "" "IDLE 是 Python 的整合開發與學習環境 (Integrated Development and Learning " "Environment)。" -#: ../../library/idle.rst:22 +#: ../../library/idle.rst:20 msgid "IDLE has the following features:" msgstr "IDLE 具有以下功能:" -#: ../../library/idle.rst:24 +#: ../../library/idle.rst:22 msgid "cross-platform: works mostly the same on Windows, Unix, and macOS" msgstr "跨平台:在 Windows、Unix 和 macOS 上的運作大致相同" -#: ../../library/idle.rst:26 +#: ../../library/idle.rst:24 msgid "" "Python shell window (interactive interpreter) with colorizing of code input, " "output, and error messages" msgstr "" "Python shell window(互動式直譯器)提供有色彩的程式碼輸入、輸出和錯誤訊息" -#: ../../library/idle.rst:29 +#: ../../library/idle.rst:27 msgid "" "multi-window text editor with multiple undo, Python colorizing, smart " "indent, call tips, auto completion, and other features" @@ -54,23 +54,23 @@ msgstr "" "多視窗文字編輯器,具有多次復原、Python 語法上色、智慧縮排、呼叫提示、自動完成" "等功能" -#: ../../library/idle.rst:32 +#: ../../library/idle.rst:30 msgid "" "search within any window, replace within editor windows, and search through " "multiple files (grep)" msgstr "能在任何視窗中搜尋、編輯器視窗中取代文字,以及搜尋多個檔案 (grep)" -#: ../../library/idle.rst:35 +#: ../../library/idle.rst:33 msgid "" "debugger with persistent breakpoints, stepping, and viewing of global and " "local namespaces" msgstr "具有持久性斷點、能夠逐步執行和檢視全域和區域命名空間的除錯器" -#: ../../library/idle.rst:38 +#: ../../library/idle.rst:36 msgid "configuration, browsers, and other dialogs" msgstr "設定、瀏覽器和其他對話框" -#: ../../library/idle.rst:40 +#: ../../library/idle.rst:38 msgid "The IDLE application is implemented in the :mod:`idlelib` package." msgstr "" @@ -82,11 +82,11 @@ msgid "" "module-requirements`." msgstr "" -#: ../../library/idle.rst:45 +#: ../../library/idle.rst:43 msgid "Menus" msgstr "目錄" -#: ../../library/idle.rst:47 +#: ../../library/idle.rst:45 msgid "" "IDLE has two main window types, the Shell window and the Editor window. It " "is possible to have multiple editor windows simultaneously. On Windows and " @@ -94,81 +94,81 @@ msgid "" "which window type it is associated with." msgstr "" -#: ../../library/idle.rst:52 +#: ../../library/idle.rst:50 msgid "" "Output windows, such as used for Edit => Find in Files, are a subtype of " "editor window. They currently have the same top menu but a different " "default title and context menu." msgstr "" -#: ../../library/idle.rst:56 +#: ../../library/idle.rst:54 msgid "" "On macOS, there is one application menu. It dynamically changes according " "to the window currently selected. It has an IDLE menu, and some entries " "described below are moved around to conform to Apple guidelines." msgstr "" -#: ../../library/idle.rst:61 +#: ../../library/idle.rst:59 msgid "File menu (Shell and Editor)" msgstr "" -#: ../../library/idle.rst:63 +#: ../../library/idle.rst:61 msgid "New File" msgstr "新增檔案" -#: ../../library/idle.rst:64 +#: ../../library/idle.rst:62 msgid "Create a new file editing window." msgstr "" -#: ../../library/idle.rst:66 +#: ../../library/idle.rst:64 msgid "Open..." msgstr "" -#: ../../library/idle.rst:67 +#: ../../library/idle.rst:65 msgid "Open an existing file with an Open dialog." msgstr "" -#: ../../library/idle.rst:69 +#: ../../library/idle.rst:67 msgid "Open Module..." msgstr "" -#: ../../library/idle.rst:70 +#: ../../library/idle.rst:68 msgid "Open an existing module (searches sys.path)." msgstr "" -#: ../../library/idle.rst:72 +#: ../../library/idle.rst:70 msgid "Recent Files" msgstr "" -#: ../../library/idle.rst:73 +#: ../../library/idle.rst:71 msgid "Open a list of recent files. Click one to open it." msgstr "" -#: ../../library/idle.rst:79 +#: ../../library/idle.rst:77 msgid "Module Browser" msgstr "" -#: ../../library/idle.rst:80 +#: ../../library/idle.rst:78 msgid "" "Show functions, classes, and methods in the current Editor file in a tree " "structure. In the shell, open a module first." msgstr "" -#: ../../library/idle.rst:83 +#: ../../library/idle.rst:81 msgid "Path Browser" msgstr "" -#: ../../library/idle.rst:84 +#: ../../library/idle.rst:82 msgid "" "Show sys.path directories, modules, functions, classes and methods in a tree " "structure." msgstr "" -#: ../../library/idle.rst:87 +#: ../../library/idle.rst:85 msgid "Save" msgstr "" -#: ../../library/idle.rst:88 +#: ../../library/idle.rst:86 msgid "" "Save the current window to the associated file, if there is one. Windows " "that have been changed since being opened or last saved have a \\* before " @@ -176,11 +176,11 @@ msgid "" "instead." msgstr "" -#: ../../library/idle.rst:93 +#: ../../library/idle.rst:91 msgid "Save As..." msgstr "" -#: ../../library/idle.rst:94 +#: ../../library/idle.rst:92 msgid "" "Save the current window with a Save As dialog. The file saved becomes the " "new associated file for the window. (If your file manager is set to hide " @@ -189,283 +189,283 @@ msgid "" "text files, except that on macOS Aqua,'.py' is added for all files.)" msgstr "" -#: ../../library/idle.rst:100 +#: ../../library/idle.rst:98 msgid "Save Copy As..." msgstr "" -#: ../../library/idle.rst:101 +#: ../../library/idle.rst:99 msgid "" "Save the current window to different file without changing the associated " "file. (See Save As note above about filename extensions.)" msgstr "" -#: ../../library/idle.rst:104 +#: ../../library/idle.rst:102 msgid "Print Window" msgstr "" -#: ../../library/idle.rst:105 +#: ../../library/idle.rst:103 msgid "Print the current window to the default printer." msgstr "" -#: ../../library/idle.rst:107 +#: ../../library/idle.rst:105 msgid "Close Window" msgstr "" -#: ../../library/idle.rst:108 +#: ../../library/idle.rst:106 msgid "" "Close the current window (if an unsaved editor, ask to save; if an unsaved " "Shell, ask to quit execution). Calling ``exit()`` or ``close()`` in the " "Shell window also closes Shell. If this is the only window, also exit IDLE." msgstr "" -#: ../../library/idle.rst:112 +#: ../../library/idle.rst:110 msgid "Exit IDLE" msgstr "離開 IDLE" -#: ../../library/idle.rst:113 +#: ../../library/idle.rst:111 msgid "Close all windows and quit IDLE (ask to save unsaved edit windows)." msgstr "" -#: ../../library/idle.rst:116 +#: ../../library/idle.rst:114 msgid "Edit menu (Shell and Editor)" msgstr "" -#: ../../library/idle.rst:118 +#: ../../library/idle.rst:116 msgid "Undo" msgstr "" -#: ../../library/idle.rst:119 +#: ../../library/idle.rst:117 msgid "" "Undo the last change to the current window. A maximum of 1000 changes may " "be undone." msgstr "" -#: ../../library/idle.rst:122 +#: ../../library/idle.rst:120 msgid "Redo" msgstr "" -#: ../../library/idle.rst:123 +#: ../../library/idle.rst:121 msgid "Redo the last undone change to the current window." msgstr "" -#: ../../library/idle.rst:125 +#: ../../library/idle.rst:123 msgid "Select All" msgstr "Select All(選擇全部)" -#: ../../library/idle.rst:126 +#: ../../library/idle.rst:124 msgid "Select the entire contents of the current window." msgstr "" -#: ../../library/idle.rst:128 ../../library/idle.rst:360 -#: ../../library/idle.rst:374 +#: ../../library/idle.rst:126 ../../library/idle.rst:358 +#: ../../library/idle.rst:372 msgid "Cut" msgstr "Cut(剪下)" -#: ../../library/idle.rst:129 ../../library/idle.rst:375 +#: ../../library/idle.rst:127 ../../library/idle.rst:373 msgid "" "Copy selection into the system-wide clipboard; then delete the selection." msgstr "" -#: ../../library/idle.rst:131 ../../library/idle.rst:360 -#: ../../library/idle.rst:377 +#: ../../library/idle.rst:129 ../../library/idle.rst:358 +#: ../../library/idle.rst:375 msgid "Copy" msgstr "Copy(複製)" -#: ../../library/idle.rst:132 ../../library/idle.rst:378 +#: ../../library/idle.rst:130 ../../library/idle.rst:376 msgid "Copy selection into the system-wide clipboard." msgstr "" -#: ../../library/idle.rst:134 ../../library/idle.rst:360 -#: ../../library/idle.rst:380 +#: ../../library/idle.rst:132 ../../library/idle.rst:358 +#: ../../library/idle.rst:378 msgid "Paste" msgstr "Paste(貼上)" -#: ../../library/idle.rst:135 ../../library/idle.rst:381 +#: ../../library/idle.rst:133 ../../library/idle.rst:379 msgid "Insert contents of the system-wide clipboard into the current window." msgstr "" -#: ../../library/idle.rst:137 +#: ../../library/idle.rst:135 msgid "The clipboard functions are also available in context menus." msgstr "" -#: ../../library/idle.rst:139 +#: ../../library/idle.rst:137 msgid "Find..." msgstr "" -#: ../../library/idle.rst:140 +#: ../../library/idle.rst:138 msgid "Open a search dialog with many options" msgstr "" -#: ../../library/idle.rst:142 +#: ../../library/idle.rst:140 msgid "Find Again" msgstr "" -#: ../../library/idle.rst:143 +#: ../../library/idle.rst:141 msgid "Repeat the last search, if there is one." msgstr "" -#: ../../library/idle.rst:145 +#: ../../library/idle.rst:143 msgid "Find Selection" msgstr "" -#: ../../library/idle.rst:146 +#: ../../library/idle.rst:144 msgid "Search for the currently selected string, if there is one." msgstr "" -#: ../../library/idle.rst:148 +#: ../../library/idle.rst:146 msgid "Find in Files..." msgstr "" -#: ../../library/idle.rst:149 +#: ../../library/idle.rst:147 msgid "Open a file search dialog. Put results in a new output window." msgstr "" -#: ../../library/idle.rst:151 +#: ../../library/idle.rst:149 msgid "Replace..." msgstr "" -#: ../../library/idle.rst:152 +#: ../../library/idle.rst:150 msgid "Open a search-and-replace dialog." msgstr "" -#: ../../library/idle.rst:154 +#: ../../library/idle.rst:152 msgid "Go to Line" msgstr "" -#: ../../library/idle.rst:155 +#: ../../library/idle.rst:153 msgid "" "Move the cursor to the beginning of the line requested and make that line " "visible. A request past the end of the file goes to the end. Clear any " "selection and update the line and column status." msgstr "" -#: ../../library/idle.rst:159 +#: ../../library/idle.rst:157 msgid "Show Completions" msgstr "" -#: ../../library/idle.rst:160 +#: ../../library/idle.rst:158 msgid "" "Open a scrollable list allowing selection of existing names. See :ref:" "`Completions ` in the Editing and Navigation section below." msgstr "" -#: ../../library/idle.rst:163 +#: ../../library/idle.rst:161 msgid "Expand Word" msgstr "" -#: ../../library/idle.rst:164 +#: ../../library/idle.rst:162 msgid "" "Expand a prefix you have typed to match a full word in the same window; " "repeat to get a different expansion." msgstr "" -#: ../../library/idle.rst:167 +#: ../../library/idle.rst:165 msgid "Show Call Tip" msgstr "" -#: ../../library/idle.rst:168 +#: ../../library/idle.rst:166 msgid "" "After an unclosed parenthesis for a function, open a small window with " "function parameter hints. See :ref:`Calltips ` in the Editing and " "Navigation section below." msgstr "" -#: ../../library/idle.rst:172 +#: ../../library/idle.rst:170 msgid "Show Surrounding Parens" msgstr "" -#: ../../library/idle.rst:173 +#: ../../library/idle.rst:171 msgid "Highlight the surrounding parenthesis." msgstr "" -#: ../../library/idle.rst:178 +#: ../../library/idle.rst:176 msgid "Format menu (Editor window only)" msgstr "" -#: ../../library/idle.rst:180 +#: ../../library/idle.rst:178 msgid "Format Paragraph" msgstr "" -#: ../../library/idle.rst:181 +#: ../../library/idle.rst:179 msgid "" "Rewrap the text block containing the text insert cursor. Avoid code lines. " "See :ref:`Format block` in the Editing and Navigation section " "below." msgstr "" -#: ../../library/idle.rst:185 +#: ../../library/idle.rst:183 msgid "Indent Region" msgstr "" -#: ../../library/idle.rst:186 +#: ../../library/idle.rst:184 msgid "Shift selected lines right by the indent width (default 4 spaces)." msgstr "" -#: ../../library/idle.rst:188 +#: ../../library/idle.rst:186 msgid "Dedent Region" msgstr "" -#: ../../library/idle.rst:189 +#: ../../library/idle.rst:187 msgid "Shift selected lines left by the indent width (default 4 spaces)." msgstr "" -#: ../../library/idle.rst:191 +#: ../../library/idle.rst:189 msgid "Comment Out Region" msgstr "" -#: ../../library/idle.rst:192 +#: ../../library/idle.rst:190 msgid "Insert ## in front of selected lines." msgstr "" -#: ../../library/idle.rst:194 +#: ../../library/idle.rst:192 msgid "Uncomment Region" msgstr "" -#: ../../library/idle.rst:195 +#: ../../library/idle.rst:193 msgid "Remove leading # or ## from selected lines." msgstr "" -#: ../../library/idle.rst:197 +#: ../../library/idle.rst:195 msgid "Tabify Region" msgstr "" -#: ../../library/idle.rst:198 +#: ../../library/idle.rst:196 msgid "" "Turn *leading* stretches of spaces into tabs. (Note: We recommend using 4 " "space blocks to indent Python code.)" msgstr "" -#: ../../library/idle.rst:201 +#: ../../library/idle.rst:199 msgid "Untabify Region" msgstr "" -#: ../../library/idle.rst:202 +#: ../../library/idle.rst:200 msgid "Turn *all* tabs into the correct number of spaces." msgstr "" -#: ../../library/idle.rst:204 +#: ../../library/idle.rst:202 msgid "Toggle Tabs" msgstr "" -#: ../../library/idle.rst:205 +#: ../../library/idle.rst:203 msgid "Open a dialog to switch between indenting with spaces and tabs." msgstr "" -#: ../../library/idle.rst:207 +#: ../../library/idle.rst:205 msgid "New Indent Width" msgstr "" -#: ../../library/idle.rst:208 +#: ../../library/idle.rst:206 msgid "" "Open a dialog to change indent width. The accepted default by the Python " "community is 4 spaces." msgstr "" -#: ../../library/idle.rst:211 +#: ../../library/idle.rst:209 msgid "Strip Trailing Whitespace" msgstr "" -#: ../../library/idle.rst:212 +#: ../../library/idle.rst:210 msgid "" "Remove trailing space and other whitespace characters after the last non-" "whitespace character of a line by applying :meth:`str.rstrip` to each line, " @@ -473,15 +473,15 @@ msgid "" "extra newlines at the end of the file." msgstr "" -#: ../../library/idle.rst:221 +#: ../../library/idle.rst:219 msgid "Run menu (Editor window only)" msgstr "" -#: ../../library/idle.rst:225 +#: ../../library/idle.rst:223 msgid "Run Module" msgstr "" -#: ../../library/idle.rst:226 +#: ../../library/idle.rst:224 msgid "" "Do :ref:`Check Module `. If no error, restart the shell to " "clean the environment, then execute the module. Output is displayed in the " @@ -491,22 +491,22 @@ msgid "" "similar to executing a file with ``python -i file`` at a command line." msgstr "" -#: ../../library/idle.rst:236 +#: ../../library/idle.rst:234 msgid "Run... Customized" msgstr "" -#: ../../library/idle.rst:237 +#: ../../library/idle.rst:235 msgid "" "Same as :ref:`Run Module `, but run the module with customized " "settings. *Command Line Arguments* extend :data:`sys.argv` as if passed on " "a command line. The module can be run in the Shell without restarting." msgstr "" -#: ../../library/idle.rst:243 +#: ../../library/idle.rst:241 msgid "Check Module" msgstr "" -#: ../../library/idle.rst:244 +#: ../../library/idle.rst:242 msgid "" "Check the syntax of the module currently open in the Editor window. If the " "module has not been saved IDLE will either prompt the user to save or " @@ -515,70 +515,70 @@ msgid "" "window." msgstr "" -#: ../../library/idle.rst:252 +#: ../../library/idle.rst:250 msgid "Python Shell" msgstr "" -#: ../../library/idle.rst:253 +#: ../../library/idle.rst:251 msgid "Open or wake up the Python Shell window." msgstr "" -#: ../../library/idle.rst:257 +#: ../../library/idle.rst:255 msgid "Shell menu (Shell window only)" msgstr "" -#: ../../library/idle.rst:259 +#: ../../library/idle.rst:257 msgid "View Last Restart" msgstr "" -#: ../../library/idle.rst:260 +#: ../../library/idle.rst:258 msgid "Scroll the shell window to the last Shell restart." msgstr "" -#: ../../library/idle.rst:262 +#: ../../library/idle.rst:260 msgid "Restart Shell" msgstr "" -#: ../../library/idle.rst:263 +#: ../../library/idle.rst:261 msgid "" "Restart the shell to clean the environment and reset display and exception " "handling." msgstr "" -#: ../../library/idle.rst:265 +#: ../../library/idle.rst:263 msgid "Previous History" msgstr "" -#: ../../library/idle.rst:266 +#: ../../library/idle.rst:264 msgid "" "Cycle through earlier commands in history which match the current entry." msgstr "" -#: ../../library/idle.rst:268 +#: ../../library/idle.rst:266 msgid "Next History" msgstr "" -#: ../../library/idle.rst:269 +#: ../../library/idle.rst:267 msgid "Cycle through later commands in history which match the current entry." msgstr "" -#: ../../library/idle.rst:271 +#: ../../library/idle.rst:269 msgid "Interrupt Execution" msgstr "" -#: ../../library/idle.rst:272 +#: ../../library/idle.rst:270 msgid "Stop a running program." msgstr "" -#: ../../library/idle.rst:275 +#: ../../library/idle.rst:273 msgid "Debug menu (Shell window only)" msgstr "" -#: ../../library/idle.rst:277 +#: ../../library/idle.rst:275 msgid "Go to File/Line" msgstr "" -#: ../../library/idle.rst:278 +#: ../../library/idle.rst:276 msgid "" "Look on the current line. with the cursor, and the line above for a filename " "and line number. If found, open the file if not already open, and show the " @@ -587,45 +587,45 @@ msgid "" "Shell window and Output windows." msgstr "" -#: ../../library/idle.rst:288 +#: ../../library/idle.rst:286 msgid "Debugger (toggle)" msgstr "" -#: ../../library/idle.rst:289 +#: ../../library/idle.rst:287 msgid "" "When activated, code entered in the Shell or run from an Editor will run " "under the debugger. In the Editor, breakpoints can be set with the context " "menu. This feature is still incomplete and somewhat experimental." msgstr "" -#: ../../library/idle.rst:293 +#: ../../library/idle.rst:291 msgid "Stack Viewer" msgstr "" -#: ../../library/idle.rst:294 +#: ../../library/idle.rst:292 msgid "" "Show the stack traceback of the last exception in a tree widget, with access " "to locals and globals." msgstr "" -#: ../../library/idle.rst:297 +#: ../../library/idle.rst:295 msgid "Auto-open Stack Viewer" msgstr "" -#: ../../library/idle.rst:298 +#: ../../library/idle.rst:296 msgid "" "Toggle automatically opening the stack viewer on an unhandled exception." msgstr "" -#: ../../library/idle.rst:301 +#: ../../library/idle.rst:299 msgid "Options menu (Shell and Editor)" msgstr "" -#: ../../library/idle.rst:303 +#: ../../library/idle.rst:301 msgid "Configure IDLE" msgstr "" -#: ../../library/idle.rst:304 +#: ../../library/idle.rst:302 msgid "" "Open a configuration dialog and change preferences for the following: fonts, " "indentation, keybindings, text color themes, startup windows and size, " @@ -634,39 +634,39 @@ msgid "" "see :ref:`Setting preferences ` under Help and preferences." msgstr "" -#: ../../library/idle.rst:311 +#: ../../library/idle.rst:309 msgid "" "Most configuration options apply to all windows or all future windows. The " "option items below only apply to the active window." msgstr "" -#: ../../library/idle.rst:314 +#: ../../library/idle.rst:312 msgid "Show/Hide Code Context (Editor Window only)" msgstr "" -#: ../../library/idle.rst:315 +#: ../../library/idle.rst:313 msgid "" "Open a pane at the top of the edit window which shows the block context of " "the code which has scrolled above the top of the window. See :ref:`Code " "Context ` in the Editing and Navigation section below." msgstr "" -#: ../../library/idle.rst:320 +#: ../../library/idle.rst:318 msgid "Show/Hide Line Numbers (Editor Window only)" msgstr "" -#: ../../library/idle.rst:321 +#: ../../library/idle.rst:319 msgid "" "Open a column to the left of the edit window which shows the number of each " "line of text. The default is off, which may be changed in the preferences " "(see :ref:`Setting preferences `)." msgstr "" -#: ../../library/idle.rst:325 +#: ../../library/idle.rst:323 msgid "Zoom/Restore Height" msgstr "" -#: ../../library/idle.rst:326 +#: ../../library/idle.rst:324 msgid "" "Toggles the window between normal size and maximum height. The initial size " "defaults to 40 lines by 80 chars unless changed on the General tab of the " @@ -676,74 +676,74 @@ msgid "" "no effect when a window is maximized." msgstr "" -#: ../../library/idle.rst:334 +#: ../../library/idle.rst:332 msgid "Window menu (Shell and Editor)" msgstr "" -#: ../../library/idle.rst:336 +#: ../../library/idle.rst:334 msgid "" "Lists the names of all open windows; select one to bring it to the " "foreground (deiconifying it if necessary)." msgstr "" -#: ../../library/idle.rst:340 +#: ../../library/idle.rst:338 msgid "Help menu (Shell and Editor)" msgstr "" -#: ../../library/idle.rst:342 +#: ../../library/idle.rst:340 msgid "About IDLE" msgstr "關於 IDLE" -#: ../../library/idle.rst:343 +#: ../../library/idle.rst:341 msgid "Display version, copyright, license, credits, and more." msgstr "" -#: ../../library/idle.rst:345 +#: ../../library/idle.rst:343 msgid "IDLE Help" msgstr "" -#: ../../library/idle.rst:346 +#: ../../library/idle.rst:344 msgid "" "Display this IDLE document, detailing the menu options, basic editing and " "navigation, and other tips." msgstr "" -#: ../../library/idle.rst:349 +#: ../../library/idle.rst:347 msgid "Python Docs" msgstr "Python 文件" -#: ../../library/idle.rst:350 +#: ../../library/idle.rst:348 msgid "" "Access local Python documentation, if installed, or start a web browser and " "open docs.python.org showing the latest Python documentation." msgstr "" -#: ../../library/idle.rst:353 +#: ../../library/idle.rst:351 msgid "Turtle Demo" msgstr "" -#: ../../library/idle.rst:354 +#: ../../library/idle.rst:352 msgid "Run the turtledemo module with example Python code and turtle drawings." msgstr "" -#: ../../library/idle.rst:356 +#: ../../library/idle.rst:354 msgid "" "Additional help sources may be added here with the Configure IDLE dialog " "under the General tab. See the :ref:`Help sources ` subsection " "below for more on Help menu choices." msgstr "" -#: ../../library/idle.rst:369 +#: ../../library/idle.rst:367 msgid "Context menus" msgstr "" -#: ../../library/idle.rst:371 +#: ../../library/idle.rst:369 msgid "" "Open a context menu by right-clicking in a window (Control-click on macOS). " "Context menus have the standard clipboard functions also on the Edit menu." msgstr "" -#: ../../library/idle.rst:383 +#: ../../library/idle.rst:381 msgid "" "Editor windows also have breakpoint functions. Lines with a breakpoint set " "are specially marked. Breakpoints only have an effect when running under " @@ -751,66 +751,66 @@ msgid "" "directory." msgstr "" -#: ../../library/idle.rst:360 ../../library/idle.rst:388 +#: ../../library/idle.rst:358 ../../library/idle.rst:386 msgid "Set Breakpoint" msgstr "" -#: ../../library/idle.rst:389 +#: ../../library/idle.rst:387 msgid "Set a breakpoint on the current line." msgstr "" -#: ../../library/idle.rst:360 ../../library/idle.rst:391 +#: ../../library/idle.rst:358 ../../library/idle.rst:389 msgid "Clear Breakpoint" msgstr "" -#: ../../library/idle.rst:392 +#: ../../library/idle.rst:390 msgid "Clear the breakpoint on that line." msgstr "" -#: ../../library/idle.rst:394 +#: ../../library/idle.rst:392 msgid "Shell and Output windows also have the following." msgstr "" -#: ../../library/idle.rst:396 +#: ../../library/idle.rst:394 msgid "Go to file/line" msgstr "" -#: ../../library/idle.rst:397 +#: ../../library/idle.rst:395 msgid "Same as in Debug menu." msgstr "" -#: ../../library/idle.rst:399 +#: ../../library/idle.rst:397 msgid "" "The Shell window also has an output squeezing facility explained in the " "*Python Shell window* subsection below." msgstr "" -#: ../../library/idle.rst:402 +#: ../../library/idle.rst:400 msgid "Squeeze" msgstr "" -#: ../../library/idle.rst:403 +#: ../../library/idle.rst:401 msgid "" "If the cursor is over an output line, squeeze all the output between the " "code above and the prompt below down to a 'Squeezed text' label." msgstr "" -#: ../../library/idle.rst:410 +#: ../../library/idle.rst:408 msgid "Editing and Navigation" msgstr "" -#: ../../library/idle.rst:413 +#: ../../library/idle.rst:411 msgid "Editor windows" msgstr "" -#: ../../library/idle.rst:415 +#: ../../library/idle.rst:413 msgid "" "IDLE may open editor windows when it starts, depending on settings and how " "you start IDLE. Thereafter, use the File menu. There can be only one open " "editor window for a given file." msgstr "" -#: ../../library/idle.rst:419 +#: ../../library/idle.rst:417 msgid "" "The title bar contains the name of the file, the full path, and the version " "of Python and IDLE running the window. The status bar contains the line " @@ -818,17 +818,17 @@ msgid "" "numbers with 0." msgstr "" -#: ../../library/idle.rst:424 +#: ../../library/idle.rst:422 msgid "" "IDLE assumes that files with a known .py* extension contain Python code and " "that other files do not. Run Python code with the Run menu." msgstr "" -#: ../../library/idle.rst:428 +#: ../../library/idle.rst:426 msgid "Key bindings" msgstr "" -#: ../../library/idle.rst:430 +#: ../../library/idle.rst:428 msgid "" "The IDLE insertion cursor is a thin vertical bar between character " "positions. When characters are entered, the insertion cursor and everything " @@ -836,7 +836,7 @@ msgid "" "the new space." msgstr "" -#: ../../library/idle.rst:435 +#: ../../library/idle.rst:433 msgid "" "Several non-character keys move the cursor and possibly delete characters. " "Deletion does not puts text on the clipboard, but IDLE has an undo list. " @@ -845,52 +845,52 @@ msgid "" "discussions assume that the keys have not been re-bound to something else.)" msgstr "" -#: ../../library/idle.rst:442 +#: ../../library/idle.rst:440 msgid "Arrow keys move the cursor one character or line." msgstr "" -#: ../../library/idle.rst:444 +#: ../../library/idle.rst:442 msgid "" ":kbd:`C-LeftArrow` and :kbd:`C-RightArrow` moves left or right one word." msgstr "" -#: ../../library/idle.rst:446 +#: ../../library/idle.rst:444 msgid ":kbd:`Home` and :kbd:`End` go to the beginning or end of the line." msgstr "" -#: ../../library/idle.rst:448 +#: ../../library/idle.rst:446 msgid ":kbd:`Page Up` and :kbd:`Page Down` go up or down one screen." msgstr "" -#: ../../library/idle.rst:450 +#: ../../library/idle.rst:448 msgid ":kbd:`C-Home` and :kbd:`C-End` go to beginning or end of the file." msgstr "" -#: ../../library/idle.rst:452 +#: ../../library/idle.rst:450 msgid "" ":kbd:`Backspace` and :kbd:`Del` (or :kbd:`C-d`) delete the previous or next " "character." msgstr "" -#: ../../library/idle.rst:455 +#: ../../library/idle.rst:453 msgid ":kbd:`C-Backspace` and :kbd:`C-Del` delete one word left or right." msgstr "" -#: ../../library/idle.rst:457 +#: ../../library/idle.rst:455 msgid ":kbd:`C-k` deletes ('kills') everything to the right." msgstr "" -#: ../../library/idle.rst:459 +#: ../../library/idle.rst:457 msgid "" "Standard keybindings (like :kbd:`C-c` to copy and :kbd:`C-v` to paste) may " "work. Keybindings are selected in the Configure IDLE dialog." msgstr "" -#: ../../library/idle.rst:463 +#: ../../library/idle.rst:461 msgid "Automatic indentation" msgstr "" -#: ../../library/idle.rst:465 +#: ../../library/idle.rst:463 msgid "" "After a block-opening statement, the next line is indented by 4 spaces (in " "the Python Shell window by one tab). After certain keywords (break, return " @@ -900,17 +900,17 @@ msgid "" "tabs are restricted to four spaces due to Tcl/Tk limitations." msgstr "" -#: ../../library/idle.rst:472 +#: ../../library/idle.rst:470 msgid "" "See also the indent/dedent region commands on the :ref:`Format menu `." msgstr "" -#: ../../library/idle.rst:476 +#: ../../library/idle.rst:474 msgid "Search and Replace" msgstr "" -#: ../../library/idle.rst:478 +#: ../../library/idle.rst:476 msgid "" "Any selection becomes a search target. However, only selections within a " "line work because searches are only performed within lines with the terminal " @@ -918,11 +918,11 @@ msgid "" "interpreted according to the Python re module." msgstr "" -#: ../../library/idle.rst:486 +#: ../../library/idle.rst:484 msgid "Completions" msgstr "" -#: ../../library/idle.rst:488 +#: ../../library/idle.rst:486 msgid "" "Completions are supplied, when requested and available, for module names, " "attributes of classes or functions, or filenames. Each request method " @@ -935,7 +935,7 @@ msgid "" "box. A double click within the box selects and closes." msgstr "" -#: ../../library/idle.rst:499 +#: ../../library/idle.rst:497 msgid "" "One way to open a box is to type a key character and wait for a predefined " "interval. This defaults to 2 seconds; customize it in the settings dialog. " @@ -947,7 +947,7 @@ msgid "" "directory name and a separator." msgstr "" -#: ../../library/idle.rst:509 +#: ../../library/idle.rst:507 msgid "" "Instead of waiting, or after a box is closed, open a completion box " "immediately with Show Completions on the Edit menu. The default hot key is :" @@ -958,7 +958,7 @@ msgid "" "directory." msgstr "" -#: ../../library/idle.rst:517 +#: ../../library/idle.rst:515 msgid "" "Hitting :kbd:`Tab` after a prefix usually has the same effect as Show " "Completions. (With no prefix, it indents.) However, if there is only one " @@ -966,14 +966,14 @@ msgid "" "without opening a box." msgstr "" -#: ../../library/idle.rst:522 +#: ../../library/idle.rst:520 msgid "" "Invoking 'Show Completions', or hitting :kbd:`Tab` after a prefix, outside " "of a string and without a preceding '.' opens a box with keywords, builtin " "names, and available module-level names." msgstr "" -#: ../../library/idle.rst:526 +#: ../../library/idle.rst:524 msgid "" "When editing code in an editor (as oppose to Shell), increase the available " "module-level names by running your code and not restarting the Shell " @@ -981,18 +981,18 @@ msgid "" "file. This also increases possible attribute completions." msgstr "" -#: ../../library/idle.rst:532 +#: ../../library/idle.rst:530 msgid "" "Completion boxes initially exclude names beginning with '_' or, for modules, " "not included in '__all__'. The hidden names can be accessed by typing '_' " "after '.', either before or after the box is opened." msgstr "" -#: ../../library/idle.rst:539 +#: ../../library/idle.rst:537 msgid "Calltips" msgstr "" -#: ../../library/idle.rst:541 +#: ../../library/idle.rst:539 msgid "" "A calltip is shown automatically when one types :kbd:`(` after the name of " "an *accessible* function. A function name expression may include dots and " @@ -1002,7 +1002,7 @@ msgid "" "or enter its shortcut to display a calltip." msgstr "" -#: ../../library/idle.rst:548 +#: ../../library/idle.rst:546 msgid "" "The calltip consists of the function's signature and docstring up to the " "latter's first blank line or the fifth non-blank line. (Some builtin " @@ -1011,14 +1011,14 @@ msgid "" "or name (keyword) only. Details are subject to change." msgstr "" -#: ../../library/idle.rst:554 +#: ../../library/idle.rst:552 msgid "" "In Shell, the accessible functions depends on what modules have been " "imported into the user process, including those imported by Idle itself, and " "which definitions have been run, all since the last restart." msgstr "" -#: ../../library/idle.rst:558 +#: ../../library/idle.rst:556 msgid "" "For example, restart the Shell and enter ``itertools.count(``. A calltip " "appears because Idle imports itertools into the user process for its own " @@ -1028,18 +1028,18 @@ msgid "" "display a calltip." msgstr "" -#: ../../library/idle.rst:565 +#: ../../library/idle.rst:563 msgid "" "In an editor, import statements have no effect until one runs the file. One " "might want to run a file after writing import statements, after adding " "function definitions, or after opening an existing file." msgstr "" -#: ../../library/idle.rst:572 +#: ../../library/idle.rst:570 msgid "Format block" msgstr "" -#: ../../library/idle.rst:574 +#: ../../library/idle.rst:572 msgid "" "Reformat Paragraph rewraps a block ('paragraph') of contiguous equally " "indented non-blank comments, a similar block of text within a multiline " @@ -1050,11 +1050,11 @@ msgid "" "Window tab of IDLE Settings." msgstr "" -#: ../../library/idle.rst:586 +#: ../../library/idle.rst:584 msgid "Code Context" msgstr "" -#: ../../library/idle.rst:588 +#: ../../library/idle.rst:586 msgid "" "Within an editor window containing Python code, code context can be toggled " "in order to show or hide a pane at the top of the window. When shown, this " @@ -1068,23 +1068,23 @@ msgid "" "the top of the editor." msgstr "" -#: ../../library/idle.rst:599 +#: ../../library/idle.rst:597 msgid "" "The text and background colors for the context pane can be configured under " "the Highlights tab in the Configure IDLE dialog." msgstr "" -#: ../../library/idle.rst:603 +#: ../../library/idle.rst:601 msgid "Shell window" msgstr "" -#: ../../library/idle.rst:605 +#: ../../library/idle.rst:603 msgid "" "In IDLE's Shell, enter, edit, and recall complete statements. (Most consoles " "and terminals only work with a single physical line at a time)." msgstr "" -#: ../../library/idle.rst:608 +#: ../../library/idle.rst:606 msgid "" "Submit a single-line statement for execution by hitting :kbd:`Return` with " "the cursor anywhere on the line. If a line is extended with Backslash (:kbd:" @@ -1092,7 +1092,7 @@ msgid "" "compound statement by entering a blank line after the statement." msgstr "" -#: ../../library/idle.rst:614 +#: ../../library/idle.rst:612 msgid "" "When one pastes code into Shell, it is not compiled and possibly executed " "until one hits :kbd:`Return`, as specified above. One may edit pasted code " @@ -1101,7 +1101,7 @@ msgid "" "one." msgstr "" -#: ../../library/idle.rst:620 +#: ../../library/idle.rst:618 msgid "" "Lines containing ``RESTART`` mean that the user execution process has been " "re-started. This occurs when the user execution process has crashed, when " @@ -1109,38 +1109,38 @@ msgid "" "window." msgstr "" -#: ../../library/idle.rst:625 +#: ../../library/idle.rst:623 msgid "" "The editing features described in previous subsections work when entering " "code interactively. IDLE's Shell window also responds to the following:" msgstr "" -#: ../../library/idle.rst:628 +#: ../../library/idle.rst:626 msgid ":kbd:`C-c` attempts to interrupt statement execution (but may fail)." msgstr "" -#: ../../library/idle.rst:630 +#: ../../library/idle.rst:628 msgid ":kbd:`C-d` closes Shell if typed at a ``>>>`` prompt." msgstr "" -#: ../../library/idle.rst:632 +#: ../../library/idle.rst:630 msgid "" ":kbd:`Alt-p` and :kbd:`Alt-n` (:kbd:`C-p` and :kbd:`C-n` on macOS) retrieve " "to the current prompt the previous or next previously entered statement that " "matches anything already typed." msgstr "" -#: ../../library/idle.rst:636 +#: ../../library/idle.rst:634 msgid "" ":kbd:`Return` while the cursor is on any previous statement appends the " "latter to anything already typed at the prompt." msgstr "" -#: ../../library/idle.rst:640 +#: ../../library/idle.rst:638 msgid "Text colors" msgstr "" -#: ../../library/idle.rst:642 +#: ../../library/idle.rst:640 msgid "" "Idle defaults to black on white text, but colors text with special meanings. " "For the shell, these are shell output, shell error, user output, and user " @@ -1150,7 +1150,7 @@ msgid "" "(when present), found text (when possible), and selected text." msgstr "" -#: ../../library/idle.rst:649 +#: ../../library/idle.rst:647 msgid "" "IDLE also highlights the :ref:`soft keywords ` :keyword:" "`match`, :keyword:`case `, and :keyword:`_ ` in " @@ -1159,7 +1159,7 @@ msgid "" "patterns." msgstr "" -#: ../../library/idle.rst:655 +#: ../../library/idle.rst:653 msgid "" "Text coloring is done in the background, so uncolorized text is occasionally " "visible. To change the color scheme, use the Configure IDLE dialog " @@ -1167,11 +1167,11 @@ msgid "" "and text in popups and dialogs is not user-configurable." msgstr "" -#: ../../library/idle.rst:662 +#: ../../library/idle.rst:660 msgid "Startup and Code Execution" msgstr "" -#: ../../library/idle.rst:664 +#: ../../library/idle.rst:662 msgid "" "Upon startup with the ``-s`` option, IDLE will execute the file referenced " "by the environment variables :envvar:`IDLESTARTUP` or :envvar:" @@ -1183,7 +1183,7 @@ msgid "" "modules." msgstr "" -#: ../../library/idle.rst:672 +#: ../../library/idle.rst:670 msgid "" "In addition, ``Tk`` also loads a startup file if it is present. Note that " "the Tk file is loaded unconditionally. This additional file is ``.Idle.py`` " @@ -1192,72 +1192,72 @@ msgid "" "importing functions to be used from IDLE's Python shell." msgstr "" -#: ../../library/idle.rst:681 +#: ../../library/idle.rst:679 msgid "Command-line usage" msgstr "命令列用法" -#: ../../library/idle.rst:685 +#: ../../library/idle.rst:683 msgid "" "IDLE can be invoked from the command line with various options. The general " "syntax is:" msgstr "" -#: ../../library/idle.rst:687 +#: ../../library/idle.rst:685 msgid "python -m idlelib [options] [file ...]" msgstr "python -m idlelib [options] [file ...]" -#: ../../library/idle.rst:691 +#: ../../library/idle.rst:689 msgid "The following options are available:" msgstr "" -#: ../../library/idle.rst:695 +#: ../../library/idle.rst:693 msgid "" "Run the specified Python command in the shell window. For example, pass ``-c " "\"print('Hello, World!')\"``. On Windows, the outer quotes must be double " "quotes as shown." msgstr "" -#: ../../library/idle.rst:701 +#: ../../library/idle.rst:699 msgid "Enable the debugger and open the shell window." msgstr "" -#: ../../library/idle.rst:705 +#: ../../library/idle.rst:703 msgid "Open an editor window." msgstr "" -#: ../../library/idle.rst:709 +#: ../../library/idle.rst:707 msgid "Print a help message with legal combinations of options and exit." msgstr "" -#: ../../library/idle.rst:713 +#: ../../library/idle.rst:711 msgid "Open a shell window." msgstr "" -#: ../../library/idle.rst:717 +#: ../../library/idle.rst:715 msgid "Run the specified file in the shell window." msgstr "" -#: ../../library/idle.rst:721 +#: ../../library/idle.rst:719 msgid "" "Run the startup file (as defined by the environment variables :envvar:" "`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`) before opening the shell window." msgstr "" -#: ../../library/idle.rst:725 +#: ../../library/idle.rst:723 msgid "Set the title of the shell window." msgstr "" -#: ../../library/idle.rst:729 +#: ../../library/idle.rst:727 msgid "" "Read and execute standard input in the shell window. This option must be the " "last one before any arguments." msgstr "" -#: ../../library/idle.rst:731 +#: ../../library/idle.rst:729 msgid "If arguments are provided:" msgstr "" -#: ../../library/idle.rst:733 +#: ../../library/idle.rst:731 msgid "" "If ``-``, ``-c``, or ``-r`` is used, all arguments are placed in ``sys." "argv[1:]``, and ``sys.argv[0]`` is set to ``''``, ``'-c'``, or ``'-r'`` " @@ -1265,17 +1265,17 @@ msgid "" "the *Options* dialog." msgstr "" -#: ../../library/idle.rst:736 +#: ../../library/idle.rst:734 msgid "" "Otherwise, arguments are treated as files to be opened for editing, and " "``sys.argv`` reflects the arguments passed to IDLE itself." msgstr "" -#: ../../library/idle.rst:740 +#: ../../library/idle.rst:738 msgid "Startup failure" msgstr "" -#: ../../library/idle.rst:742 +#: ../../library/idle.rst:740 msgid "" "IDLE uses a socket to communicate between the IDLE GUI process and the user " "code execution process. A connection must be established whenever the Shell " @@ -1285,7 +1285,7 @@ msgid "" "directs the user here. It then exits." msgstr "" -#: ../../library/idle.rst:749 +#: ../../library/idle.rst:747 msgid "" "One specific connection failure on Unix systems results from misconfigured " "masquerading rules somewhere in a system's network setup. When IDLE is " @@ -1295,7 +1295,7 @@ msgid "" "``tcplisten `` in another." msgstr "" -#: ../../library/idle.rst:757 +#: ../../library/idle.rst:755 msgid "" "A common cause of failure is a user-written file with the same name as a " "standard library module, such as *random.py* and *tkinter.py*. When such a " @@ -1304,7 +1304,7 @@ msgid "" "file." msgstr "" -#: ../../library/idle.rst:763 +#: ../../library/idle.rst:761 msgid "" "Though less common than in the past, an antivirus or firewall program may " "stop the connection. If the program cannot be taught to allow the " @@ -1314,7 +1314,7 @@ msgid "" "connections." msgstr "" -#: ../../library/idle.rst:770 +#: ../../library/idle.rst:768 msgid "" "Python installation issues occasionally stop IDLE: multiple versions can " "clash, or a single installation might need admin access. If one undo the " @@ -1322,7 +1322,7 @@ msgid "" "completely remove Python and start over." msgstr "" -#: ../../library/idle.rst:775 +#: ../../library/idle.rst:773 msgid "" "A zombie pythonw.exe process could be a problem. On Windows, use Task " "Manager to check for one and stop it if there is. Sometimes a restart " @@ -1331,7 +1331,7 @@ msgid "" "may fix a temporary problem." msgstr "" -#: ../../library/idle.rst:781 +#: ../../library/idle.rst:779 msgid "" "When IDLE first starts, it attempts to read user configuration files in ``~/." "idlerc/`` (~ is one's home directory). If there is a problem, an error " @@ -1342,14 +1342,14 @@ msgid "" "with the settings dialog." msgstr "" -#: ../../library/idle.rst:789 +#: ../../library/idle.rst:787 msgid "" "If IDLE quits with no message, and it was not started from a console, try " "starting it from a console or terminal (``python -m idlelib``) and see if " "this results in an error message." msgstr "" -#: ../../library/idle.rst:793 +#: ../../library/idle.rst:791 msgid "" "On Unix-based systems with tcl/tk older than ``8.6.11`` (see ``About IDLE``) " "certain characters of certain fonts can cause a tk failure with a message to " @@ -1358,11 +1358,11 @@ msgid "" "upgrade tcl/tk, then re-configure IDLE to use a font that works better." msgstr "" -#: ../../library/idle.rst:801 +#: ../../library/idle.rst:799 msgid "Running user code" msgstr "" -#: ../../library/idle.rst:803 +#: ../../library/idle.rst:801 msgid "" "With rare exceptions, the result of executing Python code with IDLE is " "intended to be the same as executing the same code by the default method, " @@ -1372,7 +1372,7 @@ msgid "" "``threading.active_count()`` returns 2 instead of 1." msgstr "" -#: ../../library/idle.rst:810 +#: ../../library/idle.rst:808 msgid "" "By default, IDLE runs user code in a separate OS process rather than in the " "user interface process that runs the shell and editor. In the execution " @@ -1382,7 +1382,7 @@ msgid "" "__stderr__`` are not touched, but may be ``None``." msgstr "" -#: ../../library/idle.rst:817 +#: ../../library/idle.rst:815 msgid "" "Sending print output from one process to a text widget in another is slower " "than printing to a system terminal in the same process. This has the most " @@ -1394,7 +1394,7 @@ msgid "" "fields and lines." msgstr "" -#: ../../library/idle.rst:826 +#: ../../library/idle.rst:824 msgid "" "IDLE's standard stream replacements are not inherited by subprocesses " "created in the execution process, whether directly by user code or by " @@ -1405,14 +1405,14 @@ msgid "" "attached to that window for input and output." msgstr "" -#: ../../library/idle.rst:835 +#: ../../library/idle.rst:833 msgid "" "If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``, " "IDLE's changes are lost and input from the keyboard and output to the screen " "will not work correctly." msgstr "" -#: ../../library/idle.rst:839 +#: ../../library/idle.rst:837 msgid "" "When Shell has the focus, it controls the keyboard and screen. This is " "normally transparent, but functions that directly access the keyboard and " @@ -1420,7 +1420,7 @@ msgid "" "determine whether a key has been pressed and if so, which." msgstr "" -#: ../../library/idle.rst:844 +#: ../../library/idle.rst:842 msgid "" "The IDLE code running in the execution process adds frames to the call stack " "that would not be there otherwise. IDLE wraps ``sys.getrecursionlimit`` and " @@ -1428,17 +1428,17 @@ msgid "" "frames." msgstr "" -#: ../../library/idle.rst:849 +#: ../../library/idle.rst:847 msgid "" "When user code raises SystemExit either directly or by calling sys.exit, " "IDLE returns to a Shell prompt instead of exiting." msgstr "" -#: ../../library/idle.rst:853 +#: ../../library/idle.rst:851 msgid "User output in Shell" msgstr "" -#: ../../library/idle.rst:855 +#: ../../library/idle.rst:853 msgid "" "When a program outputs text, the result is determined by the corresponding " "output device. When IDLE executes user code, ``sys.stdout`` and ``sys." @@ -1448,7 +1448,7 @@ msgid "" "rather than production runs." msgstr "" -#: ../../library/idle.rst:862 +#: ../../library/idle.rst:860 msgid "" "For instance, Shell never throws away output. A program that sends " "unlimited output to Shell will eventually fill memory, resulting in a memory " @@ -1457,7 +1457,7 @@ msgid "" "lines, with 300 the default." msgstr "" -#: ../../library/idle.rst:868 +#: ../../library/idle.rst:866 msgid "" "A Tk Text widget, and hence IDLE's Shell, displays characters (codepoints) " "in the BMP (Basic Multilingual Plane) subset of Unicode. Which characters " @@ -1471,7 +1471,7 @@ msgid "" "spacing behavior.) ::" msgstr "" -#: ../../library/idle.rst:878 +#: ../../library/idle.rst:876 msgid "" ">>> s = 'a\\tb\\a<\\x02><\\r>\\bc\\nd' # Enter 22 chars.\n" ">>> len(s)\n" @@ -1482,7 +1482,7 @@ msgid "" "# Result varies by OS and font. Try it." msgstr "" -#: ../../library/idle.rst:886 +#: ../../library/idle.rst:884 msgid "" "The ``repr`` function is used for interactive echo of expression values. It " "returns an altered version of the input string in which control codes, some " @@ -1491,13 +1491,13 @@ msgid "" "regardless of how they are displayed." msgstr "" -#: ../../library/idle.rst:892 +#: ../../library/idle.rst:890 msgid "" "Normal and error output are generally kept separate (on separate lines) from " "code input and each other. They each get different highlight colors." msgstr "" -#: ../../library/idle.rst:895 +#: ../../library/idle.rst:893 msgid "" "For SyntaxError tracebacks, the normal '^' marking where the error was " "detected is replaced by coloring the text with an error highlight. When code " @@ -1506,7 +1506,7 @@ msgid "" "opened if necessary." msgstr "" -#: ../../library/idle.rst:901 +#: ../../library/idle.rst:899 msgid "" "Shell has a special facility for squeezing output lines down to a 'Squeezed " "text' label. This is done automatically for output over N lines (N = 50 by " @@ -1515,18 +1515,18 @@ msgid "" "on the output. This can be useful lines long enough to slow down scrolling." msgstr "" -#: ../../library/idle.rst:909 +#: ../../library/idle.rst:907 msgid "" "Squeezed output is expanded in place by double-clicking the label. It can " "also be sent to the clipboard or a separate view window by right-clicking " "the label." msgstr "" -#: ../../library/idle.rst:914 +#: ../../library/idle.rst:912 msgid "Developing tkinter applications" msgstr "" -#: ../../library/idle.rst:916 +#: ../../library/idle.rst:914 msgid "" "IDLE is intentionally different from standard Python in order to facilitate " "development of tkinter programs. Enter ``import tkinter as tk; root = tk." @@ -1538,7 +1538,7 @@ msgid "" "changes in standard Python until one enters ``root.update()``." msgstr "" -#: ../../library/idle.rst:925 +#: ../../library/idle.rst:923 msgid "" "Most tkinter programs run ``root.mainloop()``, which usually does not return " "until the tk app is destroyed. If the program is run with ``python -i`` or " @@ -1546,7 +1546,7 @@ msgid "" "``mainloop()`` returns, at which time there is nothing left to interact with." msgstr "" -#: ../../library/idle.rst:931 +#: ../../library/idle.rst:929 msgid "" "When running a tkinter program from an IDLE editor, one can comment out the " "mainloop call. One then gets a shell prompt immediately and can interact " @@ -1554,11 +1554,11 @@ msgid "" "mainloop call when running in standard Python." msgstr "" -#: ../../library/idle.rst:939 +#: ../../library/idle.rst:937 msgid "Running without a subprocess" msgstr "" -#: ../../library/idle.rst:941 +#: ../../library/idle.rst:939 msgid "" "By default, IDLE executes user code in a separate subprocess via a socket, " "which uses the internal loopback interface. This connection is not " @@ -1566,7 +1566,7 @@ msgid "" "firewall software complains anyway, you can ignore it." msgstr "" -#: ../../library/idle.rst:946 +#: ../../library/idle.rst:944 msgid "" "If the attempt to make the socket connection fails, Idle will notify you. " "Such failures are sometimes transient, but if persistent, the problem may be " @@ -1575,7 +1575,7 @@ msgid "" "command line switch." msgstr "" -#: ../../library/idle.rst:952 +#: ../../library/idle.rst:950 msgid "" "If IDLE is started with the -n command line switch it will run in a single " "process and will not create the subprocess which runs the RPC Python " @@ -1589,15 +1589,15 @@ msgid "" "at all possible." msgstr "" -#: ../../library/idle.rst:967 +#: ../../library/idle.rst:965 msgid "Help and Preferences" msgstr "" -#: ../../library/idle.rst:972 +#: ../../library/idle.rst:970 msgid "Help sources" msgstr "" -#: ../../library/idle.rst:974 +#: ../../library/idle.rst:972 msgid "" "Help menu entry \"IDLE Help\" displays a formatted html version of the IDLE " "chapter of the Library Reference. The result, in a read-only tkinter text " @@ -1607,7 +1607,7 @@ msgid "" "the opened box." msgstr "" -#: ../../library/idle.rst:982 +#: ../../library/idle.rst:980 msgid "" "Help menu entry \"Python Docs\" opens the extensive sources of help, " "including tutorials, available at ``docs.python.org/x.y``, where 'x.y' is " @@ -1616,17 +1616,17 @@ msgid "" "instead." msgstr "" -#: ../../library/idle.rst:988 +#: ../../library/idle.rst:986 msgid "" "Selected URLs can be added or removed from the help menu at any time using " "the General tab of the Configure IDLE dialog." msgstr "" -#: ../../library/idle.rst:994 +#: ../../library/idle.rst:992 msgid "Setting preferences" msgstr "設定偏好" -#: ../../library/idle.rst:996 +#: ../../library/idle.rst:994 msgid "" "The font preferences, highlighting, keys, and general preferences can be " "changed via Configure IDLE on the Option menu. Non-default user settings are " @@ -1635,7 +1635,7 @@ msgid "" "or more of the files in ``.idlerc``." msgstr "" -#: ../../library/idle.rst:1002 +#: ../../library/idle.rst:1000 msgid "" "On the Font tab, see the text sample for the effect of font face and size on " "multiple characters in multiple languages. Edit the sample to add other " @@ -1644,7 +1644,7 @@ msgid "" "them to the top of the sample and try changing first size and then font." msgstr "" -#: ../../library/idle.rst:1009 +#: ../../library/idle.rst:1007 msgid "" "On the Highlights and Keys tab, select a built-in or custom color theme and " "key set. To use a newer built-in color theme or key set with older IDLEs, " @@ -1652,22 +1652,22 @@ msgid "" "IDLEs." msgstr "" -#: ../../library/idle.rst:1015 +#: ../../library/idle.rst:1013 msgid "IDLE on macOS" msgstr "macOS 上的 IDLE" -#: ../../library/idle.rst:1017 +#: ../../library/idle.rst:1015 msgid "" "Under System Preferences: Dock, one can set \"Prefer tabs when opening " "documents\" to \"Always\". This setting is not compatible with the tk/" "tkinter GUI framework used by IDLE, and it breaks a few IDLE features." msgstr "" -#: ../../library/idle.rst:1022 +#: ../../library/idle.rst:1020 msgid "Extensions" msgstr "" -#: ../../library/idle.rst:1024 +#: ../../library/idle.rst:1022 msgid "" "IDLE contains an extension facility. Preferences for extensions can be " "changed with the Extensions tab of the preferences dialog. See the beginning " @@ -1676,21 +1676,21 @@ msgid "" "testing." msgstr "" -#: ../../library/idle.rst:1032 +#: ../../library/idle.rst:1030 msgid "idlelib --- implementation of IDLE application" msgstr "" -#: ../../library/idle.rst:1037 +#: ../../library/idle.rst:1035 msgid "**Source code:** :source:`Lib/idlelib`" msgstr "**原始碼:**\\ :source:`Lib/idlelib/`" -#: ../../library/idle.rst:1041 +#: ../../library/idle.rst:1039 msgid "" "The Lib/idlelib package implements the IDLE application. See the rest of " "this page for how to use IDLE." msgstr "" -#: ../../library/idle.rst:1044 +#: ../../library/idle.rst:1042 msgid "" "The files in idlelib are described in idlelib/README.txt. Access it either " "in idlelib or click Help => About IDLE on the IDLE menu. This file also " @@ -1699,38 +1699,38 @@ msgid "" "changes can be backported (see :pep:`434`)." msgstr "" -#: ../../library/idle.rst:10 +#: ../../library/idle.rst:8 msgid "IDLE" msgstr "IDLE" -#: ../../library/idle.rst:10 +#: ../../library/idle.rst:8 msgid "Python Editor" msgstr "Python Editor(Python 編輯器)" -#: ../../library/idle.rst:10 +#: ../../library/idle.rst:8 msgid "Integrated Development Environment" msgstr "Integrated Development Environment(整合開發環境)" -#: ../../library/idle.rst:75 +#: ../../library/idle.rst:73 msgid "Module browser" msgstr "Module browser(模組瀏覽器)" -#: ../../library/idle.rst:75 +#: ../../library/idle.rst:73 msgid "Path browser" msgstr "Path browser(路徑瀏覽器)" -#: ../../library/idle.rst:217 +#: ../../library/idle.rst:215 msgid "Run script" msgstr "Run script(執行腳本)" -#: ../../library/idle.rst:284 +#: ../../library/idle.rst:282 msgid "debugger" msgstr "debugger(除錯器)" -#: ../../library/idle.rst:284 +#: ../../library/idle.rst:282 msgid "stack viewer" msgstr "stack viewer(堆疊檢視器)" -#: ../../library/idle.rst:360 +#: ../../library/idle.rst:358 msgid "breakpoints" msgstr "breakpoints(中斷點)" diff --git a/library/imaplib.po b/library/imaplib.po index 7b957314c85..2518cb7c2ed 100644 --- a/library/imaplib.po +++ b/library/imaplib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-30 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:04+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!imaplib` --- IMAP4 protocol client" msgstr ":mod:`!imaplib` --- IMAP4 協定用戶端" -#: ../../library/imaplib.rst:15 +#: ../../library/imaplib.rst:7 msgid "**Source code:** :source:`Lib/imaplib.py`" msgstr "**原始碼:**\\ :source:`Lib/imaplib.py`" -#: ../../library/imaplib.rst:24 +#: ../../library/imaplib.rst:16 msgid "" "This module defines three classes, :class:`IMAP4`, :class:`IMAP4_SSL` and :" "class:`IMAP4_stream`, which encapsulate a connection to an IMAP4 server and " @@ -46,13 +46,13 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/imaplib.rst:32 +#: ../../library/imaplib.rst:24 msgid "" "Three classes are provided by the :mod:`!imaplib` module, :class:`IMAP4` is " "the base class:" msgstr "" -#: ../../library/imaplib.rst:38 +#: ../../library/imaplib.rst:30 msgid "" "This class implements the actual IMAP4 protocol. The connection is created " "and protocol version (IMAP4 or IMAP4rev1) is determined when the instance is " @@ -63,14 +63,14 @@ msgid "" "timeout is used." msgstr "" -#: ../../library/imaplib.rst:45 +#: ../../library/imaplib.rst:37 msgid "" "The :class:`IMAP4` class supports the :keyword:`with` statement. When used " "like this, the IMAP4 ``LOGOUT`` command is issued automatically when the :" "keyword:`!with` statement exits. E.g.::" msgstr "" -#: ../../library/imaplib.rst:49 +#: ../../library/imaplib.rst:41 msgid "" ">>> from imaplib import IMAP4\n" ">>> with IMAP4(\"domain.org\") as M:\n" @@ -84,32 +84,32 @@ msgstr "" "...\n" "('OK', [b'Nothing Accomplished. d25if65hy903weo.87'])" -#: ../../library/imaplib.rst:55 +#: ../../library/imaplib.rst:47 msgid "Support for the :keyword:`with` statement was added." msgstr "新增對 :keyword:`with` 陳述式的支援。" -#: ../../library/imaplib.rst:58 ../../library/imaplib.rst:119 +#: ../../library/imaplib.rst:50 ../../library/imaplib.rst:111 msgid "The optional *timeout* parameter was added." msgstr "新增 *timeout* 選用參數。" -#: ../../library/imaplib.rst:61 +#: ../../library/imaplib.rst:53 msgid "Three exceptions are defined as attributes of the :class:`IMAP4` class:" msgstr "" -#: ../../library/imaplib.rst:66 +#: ../../library/imaplib.rst:58 msgid "" "Exception raised on any errors. The reason for the exception is passed to " "the constructor as a string." msgstr "" -#: ../../library/imaplib.rst:72 +#: ../../library/imaplib.rst:64 msgid "" "IMAP4 server errors cause this exception to be raised. This is a sub-class " "of :exc:`IMAP4.error`. Note that closing the instance and instantiating a " "new one will usually allow recovery from this exception." msgstr "" -#: ../../library/imaplib.rst:79 +#: ../../library/imaplib.rst:71 msgid "" "This exception is raised when a writable mailbox has its status changed by " "the server. This is a sub-class of :exc:`IMAP4.error`. Some other client " @@ -117,11 +117,11 @@ msgid "" "obtain write permission." msgstr "" -#: ../../library/imaplib.rst:85 +#: ../../library/imaplib.rst:77 msgid "There's also a subclass for secure connections:" msgstr "" -#: ../../library/imaplib.rst:91 +#: ../../library/imaplib.rst:83 msgid "" "This is a subclass derived from :class:`IMAP4` that connects over an SSL " "encrypted socket (to use this class you need a socket module that was " @@ -133,70 +133,70 @@ msgid "" "for best practices." msgstr "" -#: ../../library/imaplib.rst:102 ../../library/imaplib.rst:611 +#: ../../library/imaplib.rst:94 ../../library/imaplib.rst:603 msgid "" "With the default *ssl_context*, the connection is encrypted but the server " "certificate and hostname are not verified. To verify them, pass a context " "created by :func:`ssl.create_default_context`." msgstr "" -#: ../../library/imaplib.rst:107 +#: ../../library/imaplib.rst:99 msgid "" "The optional *timeout* parameter specifies a timeout in seconds for the " "connection attempt. If timeout is not given or is ``None``, the global " "default socket timeout is used." msgstr "" -#: ../../library/imaplib.rst:111 +#: ../../library/imaplib.rst:103 msgid "*ssl_context* parameter was added." msgstr "新增 *ssl_context* 參數。" -#: ../../library/imaplib.rst:114 +#: ../../library/imaplib.rst:106 msgid "" "The class now supports hostname check with :attr:`ssl.SSLContext." "check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." msgstr "" -#: ../../library/imaplib.rst:122 +#: ../../library/imaplib.rst:114 msgid "The deprecated *keyfile* and *certfile* parameters have been removed." msgstr "" -#: ../../library/imaplib.rst:125 +#: ../../library/imaplib.rst:117 msgid "The second subclass allows for connections created by a child process:" msgstr "" -#: ../../library/imaplib.rst:130 +#: ../../library/imaplib.rst:122 msgid "" "This is a subclass derived from :class:`IMAP4` that connects to the ``stdin/" "stdout`` file descriptors created by passing *command* to ``subprocess." "Popen()``." msgstr "" -#: ../../library/imaplib.rst:135 +#: ../../library/imaplib.rst:127 msgid "The following utility functions are defined:" msgstr "" -#: ../../library/imaplib.rst:140 +#: ../../library/imaplib.rst:132 msgid "" "Parse a :term:`bytes-like object` containing an IMAP4 ``INTERNALDATE`` " "response and return the corresponding local time. The return value is a :" "class:`time.struct_time` tuple or ``None`` if the input has wrong format." msgstr "" -#: ../../library/imaplib.rst:146 +#: ../../library/imaplib.rst:138 msgid "" "Converts an integer into a bytes representation using characters from the " "set [``A`` .. ``P``]." msgstr "" -#: ../../library/imaplib.rst:152 +#: ../../library/imaplib.rst:144 msgid "" "Converts a :term:`bytes-like object` containing an IMAP4 ``FLAGS`` response " "to a tuple of individual flags as :class:`bytes`. The return value is an " "empty tuple if the input has wrong format." msgstr "" -#: ../../library/imaplib.rst:159 +#: ../../library/imaplib.rst:151 msgid "" "Convert *date_time* to an IMAP4 ``INTERNALDATE`` representation. The return " "value is a string in the form: ``\"DD-Mmm-YYYY HH:MM:SS +HHMM\"`` (including " @@ -208,7 +208,7 @@ msgid "" "already be in the correct format." msgstr "" -#: ../../library/imaplib.rst:169 +#: ../../library/imaplib.rst:161 msgid "" "Note that IMAP4 message numbers change as the mailbox changes; in " "particular, after an ``EXPUNGE`` command performs deletions the remaining " @@ -216,30 +216,30 @@ msgid "" "the UID command." msgstr "" -#: ../../library/imaplib.rst:173 +#: ../../library/imaplib.rst:165 msgid "" "At the end of the module, there is a test section that contains a more " "extensive example of usage." msgstr "" -#: ../../library/imaplib.rst:179 +#: ../../library/imaplib.rst:171 msgid "" "Documents describing the protocol, sources for servers implementing it, by " "the University of Washington's IMAP Information Center can all be found at " "(**Source Code**) https://github.com/uw-imap/imap (**Not Maintained**)." msgstr "" -#: ../../library/imaplib.rst:187 +#: ../../library/imaplib.rst:179 msgid "IMAP4 Objects" msgstr "IMAP4 物件" -#: ../../library/imaplib.rst:189 +#: ../../library/imaplib.rst:181 msgid "" "All IMAP4rev1 commands are represented by methods of the same name, either " "uppercase or lowercase." msgstr "" -#: ../../library/imaplib.rst:192 +#: ../../library/imaplib.rst:184 msgid "" "All arguments to commands are converted to strings, except for " "``AUTHENTICATE``, and the last argument to ``APPEND`` which is passed as an " @@ -254,7 +254,7 @@ msgid "" "working." msgstr "" -#: ../../library/imaplib.rst:203 +#: ../../library/imaplib.rst:195 msgid "" "Most commands return a tuple: ``(type, [data, ...])`` where *type* is " "usually ``'OK'`` or ``'NO'``, and *data* is either the text from the command " @@ -263,7 +263,7 @@ msgid "" "response, and the second part contains the data (ie: 'literal' value)." msgstr "" -#: ../../library/imaplib.rst:209 +#: ../../library/imaplib.rst:201 msgid "" "The *message_set* options to commands below is a string specifying one or " "more messages to be acted upon. It may be a simple message number " @@ -272,41 +272,41 @@ msgid "" "an asterisk to indicate an infinite upper bound (``'3:*'``)." msgstr "" -#: ../../library/imaplib.rst:215 +#: ../../library/imaplib.rst:207 msgid "An :class:`IMAP4` instance has the following methods:" msgstr ":class:`IMAP4` 實例擁有以下方法:" -#: ../../library/imaplib.rst:220 +#: ../../library/imaplib.rst:212 msgid "Append *message* to named mailbox." msgstr "" -#: ../../library/imaplib.rst:222 +#: ../../library/imaplib.rst:214 msgid "" "*flags* may be ``None`` or a string of IMAP flag tokens. Multiple flags are " "separated by spaces, for example ``r'\\Seen \\Answered'``. If *flags* is not " "already enclosed in parentheses, parentheses are added automatically." msgstr "" -#: ../../library/imaplib.rst:230 +#: ../../library/imaplib.rst:222 msgid "Authenticate command --- requires response processing." msgstr "" -#: ../../library/imaplib.rst:232 +#: ../../library/imaplib.rst:224 msgid "" "*mechanism* specifies which authentication mechanism is to be used - it " "should appear in the instance variable ``capabilities`` in the form " "``AUTH=mechanism``." msgstr "" -#: ../../library/imaplib.rst:235 +#: ../../library/imaplib.rst:227 msgid "*authobject* must be a callable object::" msgstr "" -#: ../../library/imaplib.rst:237 +#: ../../library/imaplib.rst:229 msgid "data = authobject(response)" msgstr "data = authobject(response)" -#: ../../library/imaplib.rst:239 +#: ../../library/imaplib.rst:231 msgid "" "It will be called to process server continuation responses; the *response* " "argument it is passed will be ``bytes``. It should return ``bytes`` *data* " @@ -314,101 +314,101 @@ msgid "" "``None`` if the client abort response ``*`` should be sent instead." msgstr "" -#: ../../library/imaplib.rst:244 +#: ../../library/imaplib.rst:236 msgid "" "string usernames and passwords are now encoded to ``utf-8`` instead of being " "limited to ASCII." msgstr "" -#: ../../library/imaplib.rst:251 +#: ../../library/imaplib.rst:243 msgid "Checkpoint mailbox on server." msgstr "" -#: ../../library/imaplib.rst:256 +#: ../../library/imaplib.rst:248 msgid "" "Close currently selected mailbox. Deleted messages are removed from writable " "mailbox. This is the recommended command before ``LOGOUT``." msgstr "" -#: ../../library/imaplib.rst:262 +#: ../../library/imaplib.rst:254 msgid "Copy *message_set* messages onto end of *new_mailbox*." msgstr "" -#: ../../library/imaplib.rst:267 +#: ../../library/imaplib.rst:259 msgid "Create new mailbox named *mailbox*." msgstr "" -#: ../../library/imaplib.rst:272 +#: ../../library/imaplib.rst:264 msgid "Delete old mailbox named *mailbox*." msgstr "" -#: ../../library/imaplib.rst:277 +#: ../../library/imaplib.rst:269 msgid "Delete the ACLs (remove any rights) set for who on mailbox." msgstr "" -#: ../../library/imaplib.rst:282 +#: ../../library/imaplib.rst:274 msgid "" "Enable *capability* (see :rfc:`5161`). Most capabilities do not need to be " "enabled. Currently only the ``UTF8=ACCEPT`` capability is supported (see :" "RFC:`6855`)." msgstr "" -#: ../../library/imaplib.rst:286 +#: ../../library/imaplib.rst:278 msgid "The :meth:`enable` method itself, and :RFC:`6855` support." msgstr "" -#: ../../library/imaplib.rst:292 +#: ../../library/imaplib.rst:284 msgid "" "Permanently remove deleted items from selected mailbox. Generates an " "``EXPUNGE`` response for each deleted message. Returned data contains a list " "of ``EXPUNGE`` message numbers in order received." msgstr "" -#: ../../library/imaplib.rst:299 +#: ../../library/imaplib.rst:291 msgid "" "Fetch (parts of) messages. *message_parts* should be a string of message " "part names enclosed within parentheses, eg: ``\"(UID BODY[TEXT])\"``. " "Returned data are tuples of message part envelope and data." msgstr "" -#: ../../library/imaplib.rst:306 +#: ../../library/imaplib.rst:298 msgid "" "Get the ``ACL``\\ s for *mailbox*. The method is non-standard, but is " "supported by the ``Cyrus`` server." msgstr "" -#: ../../library/imaplib.rst:312 +#: ../../library/imaplib.rst:304 msgid "" "Retrieve the specified ``ANNOTATION``\\ s for *mailbox*. The method is non-" "standard, but is supported by the ``Cyrus`` server." msgstr "" -#: ../../library/imaplib.rst:318 +#: ../../library/imaplib.rst:310 msgid "" "Get the ``quota`` *root*'s resource usage and limits. This method is part of " "the IMAP4 QUOTA extension defined in rfc2087." msgstr "" -#: ../../library/imaplib.rst:324 +#: ../../library/imaplib.rst:316 msgid "" "Get the list of ``quota`` ``roots`` for the named *mailbox*. This method is " "part of the IMAP4 QUOTA extension defined in rfc2087." msgstr "" -#: ../../library/imaplib.rst:330 +#: ../../library/imaplib.rst:322 msgid "" "Return an :class:`!Idler`: an iterable context manager implementing the " "IMAP4 ``IDLE`` command as defined in :rfc:`2177`." msgstr "" -#: ../../library/imaplib.rst:333 +#: ../../library/imaplib.rst:325 msgid "" "The returned object sends the ``IDLE`` command when activated by the :" "keyword:`with` statement, produces IMAP untagged responses via the :term:" "`iterator` protocol, and sends ``DONE`` upon context exit." msgstr "" -#: ../../library/imaplib.rst:337 +#: ../../library/imaplib.rst:329 msgid "" "All untagged responses that arrive after sending the ``IDLE`` command " "(including any that arrive before the server acknowledges the command) will " @@ -417,13 +417,13 @@ msgid "" "``IDLE`` ends, using :meth:`IMAP4.response`." msgstr "" -#: ../../library/imaplib.rst:343 +#: ../../library/imaplib.rst:335 msgid "" "Responses are represented as ``(type, [data, ...])`` tuples, as described " "in :ref:`IMAP4 Objects `." msgstr "" -#: ../../library/imaplib.rst:346 +#: ../../library/imaplib.rst:338 msgid "" "The *duration* argument sets a maximum duration (in seconds) to keep idling, " "after which any ongoing iteration will stop. It can be an :class:`int` or :" @@ -433,7 +433,7 @@ msgid "" "``None`` on :class:`IMAP4_stream` connections." msgstr "" -#: ../../library/imaplib.rst:354 +#: ../../library/imaplib.rst:346 msgid "" ">>> with M.idle(duration=29 * 60) as idler:\n" "... for typ, data in idler:\n" @@ -449,13 +449,13 @@ msgstr "" "EXISTS [b'1']\n" "RECENT [b'1']" -#: ../../library/imaplib.rst:366 +#: ../../library/imaplib.rst:358 msgid "" "Yield a burst of responses no more than *interval* seconds apart (expressed " "as an :class:`int` or :class:`float`)." msgstr "" -#: ../../library/imaplib.rst:369 +#: ../../library/imaplib.rst:361 msgid "" "This :term:`generator` is an alternative to iterating one response at a " "time, intended to aid in efficient batch processing. It retrieves the next " @@ -463,13 +463,13 @@ msgid "" "example, a rapid series of ``EXPUNGE`` responses after a bulk delete.)" msgstr "" -#: ../../library/imaplib.rst:375 +#: ../../library/imaplib.rst:367 msgid "" "Requires a socket connection; does not work on :class:`IMAP4_stream` " "connections." msgstr "" -#: ../../library/imaplib.rst:378 +#: ../../library/imaplib.rst:370 msgid "" ">>> with M.idle() as idler:\n" "... # get a response and any others following by < 0.1 seconds\n" @@ -481,7 +481,7 @@ msgid "" "[('EXPUNGE', [b'2']), ('EXPUNGE', [b'1']), ('RECENT', [b'0'])]" msgstr "" -#: ../../library/imaplib.rst:391 +#: ../../library/imaplib.rst:383 msgid "" "The ``IDLE`` context's maximum duration, as passed to :meth:`IMAP4.idle`, is " "respected when waiting for the first response in a burst. Therefore, an " @@ -490,7 +490,7 @@ msgid "" "loop." msgstr "" -#: ../../library/imaplib.rst:400 +#: ../../library/imaplib.rst:392 msgid "" "The iterator returned by :meth:`IMAP4.idle` is usable only within a :keyword:" "`with` statement. Before or after that context, unsolicited responses are " @@ -498,7 +498,7 @@ msgid "" "meth:`IMAP4.response`." msgstr "" -#: ../../library/imaplib.rst:407 +#: ../../library/imaplib.rst:399 msgid "" "The :class:`!Idler` class name and structure are internal interfaces, " "subject to change. Calling code can rely on its context management, " @@ -506,58 +506,58 @@ msgid "" "instantiate, compare, or otherwise directly reference the class." msgstr "" -#: ../../library/imaplib.rst:417 +#: ../../library/imaplib.rst:409 msgid "" "List mailbox names in *directory* matching *pattern*. *directory* defaults " "to the top-level mail folder, and *pattern* defaults to match anything. " "Returned data contains a list of ``LIST`` responses." msgstr "" -#: ../../library/imaplib.rst:424 +#: ../../library/imaplib.rst:416 msgid "" "Identify the client using a plaintext password. The *password* will be " "quoted." msgstr "" -#: ../../library/imaplib.rst:429 +#: ../../library/imaplib.rst:421 msgid "" "Force use of ``CRAM-MD5`` authentication when identifying the client to " "protect the password. Will only work if the server ``CAPABILITY`` response " "includes the phrase ``AUTH=CRAM-MD5``." msgstr "" -#: ../../library/imaplib.rst:433 +#: ../../library/imaplib.rst:425 msgid "An :exc:`IMAP4.error` is raised if MD5 support is not available." msgstr "" -#: ../../library/imaplib.rst:439 +#: ../../library/imaplib.rst:431 msgid "Shutdown connection to server. Returns server ``BYE`` response." msgstr "" -#: ../../library/imaplib.rst:441 +#: ../../library/imaplib.rst:433 msgid "The method no longer ignores silently arbitrary exceptions." msgstr "" -#: ../../library/imaplib.rst:447 +#: ../../library/imaplib.rst:439 msgid "" "List subscribed mailbox names in directory matching pattern. *directory* " "defaults to the top level directory and *pattern* defaults to match any " "mailbox. Returned data are tuples of message part envelope and data." msgstr "" -#: ../../library/imaplib.rst:454 +#: ../../library/imaplib.rst:446 msgid "Show my ACLs for a mailbox (i.e. the rights that I have on mailbox)." msgstr "" -#: ../../library/imaplib.rst:459 +#: ../../library/imaplib.rst:451 msgid "Returns IMAP namespaces as defined in :rfc:`2342`." msgstr "" -#: ../../library/imaplib.rst:464 +#: ../../library/imaplib.rst:456 msgid "Send ``NOOP`` to server." msgstr "" -#: ../../library/imaplib.rst:469 +#: ../../library/imaplib.rst:461 msgid "" "Opens socket to *port* at *host*. The optional *timeout* parameter specifies " "a timeout in seconds for the connection attempt. If timeout is not given or " @@ -570,7 +570,7 @@ msgid "" "You may override this method." msgstr "" -#: ../../library/imaplib.rst:479 +#: ../../library/imaplib.rst:471 msgid "" "Raises an :ref:`auditing event ` ``imaplib.open`` with arguments " "``self``, ``host``, ``port``." @@ -578,48 +578,48 @@ msgstr "" "引發一個附帶引數 ``self``、``host``、``port`` 的\\ :ref:`稽核事件 " "` ``imaplib.open``。" -#: ../../library/imaplib.rst:481 +#: ../../library/imaplib.rst:473 msgid "The *timeout* parameter was added." msgstr "新增 *timeout* 參數。" -#: ../../library/imaplib.rst:486 +#: ../../library/imaplib.rst:478 msgid "" "Fetch truncated part of a message. Returned data is a tuple of message part " "envelope and data." msgstr "" -#: ../../library/imaplib.rst:492 +#: ../../library/imaplib.rst:484 msgid "" "Assume authentication as *user*. Allows an authorised administrator to proxy " "into any user's mailbox." msgstr "" -#: ../../library/imaplib.rst:498 +#: ../../library/imaplib.rst:490 msgid "" "Reads *size* bytes from the remote server. You may override this method." msgstr "" -#: ../../library/imaplib.rst:503 +#: ../../library/imaplib.rst:495 msgid "Reads one line from the remote server. You may override this method." msgstr "" -#: ../../library/imaplib.rst:508 +#: ../../library/imaplib.rst:500 msgid "" "Prompt server for an update. Returned data is ``None`` if no new messages, " "else value of ``RECENT`` response." msgstr "" -#: ../../library/imaplib.rst:514 +#: ../../library/imaplib.rst:506 msgid "Rename mailbox named *oldmailbox* to *newmailbox*." msgstr "" -#: ../../library/imaplib.rst:519 +#: ../../library/imaplib.rst:511 msgid "" "Return data for response *code* if received, or ``None``. Returns the given " "code, instead of the usual type." msgstr "" -#: ../../library/imaplib.rst:525 +#: ../../library/imaplib.rst:517 msgid "" "Search mailbox for matching messages. *charset* may be ``None``, in which " "case no ``CHARSET`` will be specified in the request to the server. The " @@ -629,11 +629,11 @@ msgid "" "`enable` command." msgstr "" -#: ../../library/imaplib.rst:532 +#: ../../library/imaplib.rst:524 msgid "Example::" msgstr "範例: ::" -#: ../../library/imaplib.rst:534 +#: ../../library/imaplib.rst:526 msgid "" "# M is a connected IMAP4 instance...\n" "typ, msgnums = M.search(None, 'FROM', '\"LDJ\"')\n" @@ -642,18 +642,18 @@ msgid "" "typ, msgnums = M.search(None, '(FROM \"LDJ\")')" msgstr "" -#: ../../library/imaplib.rst:543 +#: ../../library/imaplib.rst:535 msgid "" "Select a mailbox. Returned data is the count of messages in *mailbox* " "(``EXISTS`` response). The default *mailbox* is ``'INBOX'``. If the " "*readonly* flag is set, modifications to the mailbox are not allowed." msgstr "" -#: ../../library/imaplib.rst:550 +#: ../../library/imaplib.rst:542 msgid "Sends ``data`` to the remote server. You may override this method." msgstr "" -#: ../../library/imaplib.rst:552 +#: ../../library/imaplib.rst:544 msgid "" "Raises an :ref:`auditing event ` ``imaplib.send`` with arguments " "``self``, ``data``." @@ -661,42 +661,42 @@ msgstr "" "引發一個附帶引數 ``self``、``data`` 的\\ :ref:`稽核事件 ` " "``imaplib.send``。" -#: ../../library/imaplib.rst:557 +#: ../../library/imaplib.rst:549 msgid "" "Set an ``ACL`` for *mailbox*. The method is non-standard, but is supported " "by the ``Cyrus`` server." msgstr "" -#: ../../library/imaplib.rst:563 +#: ../../library/imaplib.rst:555 msgid "" "Set ``ANNOTATION``\\ s for *mailbox*. The method is non-standard, but is " "supported by the ``Cyrus`` server." msgstr "" -#: ../../library/imaplib.rst:569 +#: ../../library/imaplib.rst:561 msgid "" "Set the ``quota`` *root*'s resource *limits*. This method is part of the " "IMAP4 QUOTA extension defined in rfc2087." msgstr "" -#: ../../library/imaplib.rst:575 +#: ../../library/imaplib.rst:567 msgid "" "Close connection established in ``open``. This method is implicitly called " "by :meth:`IMAP4.logout`. You may override this method." msgstr "" -#: ../../library/imaplib.rst:581 +#: ../../library/imaplib.rst:573 msgid "Returns socket instance used to connect to server." msgstr "" -#: ../../library/imaplib.rst:586 +#: ../../library/imaplib.rst:578 msgid "" "The ``sort`` command is a variant of ``search`` with sorting semantics for " "the results. Returned data contains a space separated list of matching " "message numbers." msgstr "" -#: ../../library/imaplib.rst:590 +#: ../../library/imaplib.rst:582 msgid "" "Sort has two arguments before the *search_criterion* argument(s); a " "parenthesized list of *sort_criteria*, and the searching *charset*. Note " @@ -708,39 +708,39 @@ msgid "" "searching criteria. It then returns the numbers of matching messages." msgstr "" -#: ../../library/imaplib.rst:599 ../../library/imaplib.rst:677 +#: ../../library/imaplib.rst:591 ../../library/imaplib.rst:669 msgid "This is an ``IMAP4rev1`` extension command." msgstr "" -#: ../../library/imaplib.rst:604 +#: ../../library/imaplib.rst:596 msgid "" "Send a ``STARTTLS`` command. The *ssl_context* argument is optional and " "should be a :class:`ssl.SSLContext` object. This will enable encryption on " "the IMAP connection. Please read :ref:`ssl-security` for best practices." msgstr "" -#: ../../library/imaplib.rst:618 +#: ../../library/imaplib.rst:610 msgid "" "The method now supports hostname check with :attr:`ssl.SSLContext." "check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." msgstr "" -#: ../../library/imaplib.rst:626 +#: ../../library/imaplib.rst:618 msgid "Request named status conditions for *mailbox*." msgstr "" -#: ../../library/imaplib.rst:631 +#: ../../library/imaplib.rst:623 msgid "" "Alters flag dispositions for messages in mailbox. *command* is specified by " "section 6.4.6 of :rfc:`3501` as being one of \"FLAGS\", \"+FLAGS\", or \"-" "FLAGS\", optionally with a suffix of \".SILENT\"." msgstr "" -#: ../../library/imaplib.rst:635 +#: ../../library/imaplib.rst:627 msgid "For example, to set the delete flag on all messages::" msgstr "" -#: ../../library/imaplib.rst:637 +#: ../../library/imaplib.rst:629 msgid "" "typ, data = M.search(None, 'ALL')\n" "for num in data[0].split():\n" @@ -752,7 +752,7 @@ msgstr "" " M.store(num, '+FLAGS', '\\\\Deleted')\n" "M.expunge()" -#: ../../library/imaplib.rst:644 +#: ../../library/imaplib.rst:636 msgid "" "Creating flags containing ']' (for example: \"[test]\") violates :rfc:`3501` " "(the IMAP protocol). However, imaplib has historically allowed creation of " @@ -764,24 +764,24 @@ msgid "" "are sent from the server, since this improves real-world compatibility." msgstr "" -#: ../../library/imaplib.rst:656 +#: ../../library/imaplib.rst:648 msgid "Subscribe to new mailbox." msgstr "" -#: ../../library/imaplib.rst:661 +#: ../../library/imaplib.rst:653 msgid "" "The ``thread`` command is a variant of ``search`` with threading semantics " "for the results. Returned data contains a space separated list of thread " "members." msgstr "" -#: ../../library/imaplib.rst:664 +#: ../../library/imaplib.rst:656 msgid "" "Thread members consist of zero or more messages numbers, delimited by " "spaces, indicating successive parent and child." msgstr "" -#: ../../library/imaplib.rst:667 +#: ../../library/imaplib.rst:659 msgid "" "Thread has two arguments before the *search_criterion* argument(s); a " "*threading_algorithm*, and the searching *charset*. Note that unlike " @@ -794,7 +794,7 @@ msgid "" "specified threading algorithm." msgstr "" -#: ../../library/imaplib.rst:682 +#: ../../library/imaplib.rst:674 msgid "" "Execute command args with messages identified by UID, rather than message " "number. Returns response appropriate to command. At least one argument " @@ -802,11 +802,11 @@ msgid "" "an exception will be raised." msgstr "" -#: ../../library/imaplib.rst:690 +#: ../../library/imaplib.rst:682 msgid "Unsubscribe from old mailbox." msgstr "" -#: ../../library/imaplib.rst:694 +#: ../../library/imaplib.rst:686 msgid "" ":meth:`imaplib.IMAP4.unselect` frees server's resources associated with the " "selected mailbox and returns the server to the authenticated state. This " @@ -814,21 +814,21 @@ msgid "" "that no messages are permanently removed from the currently selected mailbox." msgstr "" -#: ../../library/imaplib.rst:704 +#: ../../library/imaplib.rst:696 msgid "" "Allow simple extension commands notified by server in ``CAPABILITY`` " "response." msgstr "" -#: ../../library/imaplib.rst:707 +#: ../../library/imaplib.rst:699 msgid "The following attributes are defined on instances of :class:`IMAP4`:" msgstr "" -#: ../../library/imaplib.rst:711 +#: ../../library/imaplib.rst:703 msgid "A tuple of the capabilities advertised by the server, in upper case." msgstr "" -#: ../../library/imaplib.rst:713 +#: ../../library/imaplib.rst:705 msgid "" "It is set when the connection is established, and refreshed after a " "successful :meth:`~IMAP4.login`, :meth:`~IMAP4.authenticate` or :meth:" @@ -836,40 +836,48 @@ msgid "" "in different connection states." msgstr "" -#: ../../library/imaplib.rst:719 +#: ../../library/imaplib.rst:711 msgid "Refreshed after :meth:`~IMAP4.login` and :meth:`~IMAP4.authenticate`." msgstr "" -#: ../../library/imaplib.rst:725 +#: ../../library/imaplib.rst:717 msgid "" "The most recent supported protocol in the ``CAPABILITY`` response from the " "server." msgstr "" -#: ../../library/imaplib.rst:731 +#: ../../library/imaplib.rst:723 msgid "" "Integer value to control debugging output. The initialize value is taken " "from the module variable ``Debug``. Values greater than three trace each " "command." msgstr "" -#: ../../library/imaplib.rst:737 +#: ../../library/imaplib.rst:729 msgid "" "Boolean value that is normally ``False``, but is set to ``True`` if an :meth:" "`enable` command is successfully issued for the ``UTF8=ACCEPT`` capability." msgstr "" -#: ../../library/imaplib.rst:747 +#: ../../library/imaplib.rst:738 +msgid "" +"Internal :class:`~io.BufferedReader` associated with the underlying socket. " +"This property is documented for legacy purposes but not part of the public " +"interface. The caller is responsible to ensure that the current file is " +"closed before changing it." +msgstr "" + +#: ../../library/imaplib.rst:749 msgid "IMAP4 Example" msgstr "IMAP4 範例" -#: ../../library/imaplib.rst:749 +#: ../../library/imaplib.rst:751 msgid "" "Here is a minimal example (without error checking) that opens a mailbox and " "retrieves and prints all messages::" msgstr "" -#: ../../library/imaplib.rst:752 +#: ../../library/imaplib.rst:754 msgid "" "import getpass, imaplib\n" "\n" @@ -895,25 +903,25 @@ msgstr "" "M.close()\n" "M.logout()" -#: ../../library/imaplib.rst:766 +#: ../../library/imaplib.rst:768 msgid "" "A ``FETCH`` response may contain additional or unsolicited data (see :rfc:" "`3501`, section 7.4.2), so production code should inspect the whole response " "rather than rely on ``data[0][1]``." msgstr "" -#: ../../library/imaplib.rst:17 +#: ../../library/imaplib.rst:9 msgid "IMAP4" msgstr "IMAP4" -#: ../../library/imaplib.rst:17 +#: ../../library/imaplib.rst:9 msgid "protocol" msgstr "protocol(協定)" -#: ../../library/imaplib.rst:17 +#: ../../library/imaplib.rst:9 msgid "IMAP4_SSL" msgstr "IMAP4_SSL" -#: ../../library/imaplib.rst:17 +#: ../../library/imaplib.rst:9 msgid "IMAP4_stream" msgstr "IMAP4_stream" diff --git a/library/importlib.metadata.po b/library/importlib.metadata.po index 9221898e404..7f274334ef1 100644 --- a/library/importlib.metadata.po +++ b/library/importlib.metadata.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -169,19 +169,26 @@ msgid "" "current Python environment." msgstr "" -#: ../../library/importlib.metadata.rst:110 +#: ../../library/importlib.metadata.rst:111 +msgid "" +"Subclass of :class:`FileNotFoundError` raised when attempting to load " +"metadata from a distribution folder that is empty or otherwise does not " +"contain a metadata file." +msgstr "" + +#: ../../library/importlib.metadata.rst:117 msgid "Functional API" msgstr "" -#: ../../library/importlib.metadata.rst:112 +#: ../../library/importlib.metadata.rst:119 msgid "This package provides the following functionality via its public API." msgstr "" -#: ../../library/importlib.metadata.rst:118 +#: ../../library/importlib.metadata.rst:125 msgid "Entry points" msgstr "" -#: ../../library/importlib.metadata.rst:122 +#: ../../library/importlib.metadata.rst:129 msgid "" "Returns a :class:`EntryPoints` instance describing entry points for the " "current environment. Any given keyword parameters are passed to the :meth:`!" @@ -189,30 +196,30 @@ msgid "" "point definitions." msgstr "" -#: ../../library/importlib.metadata.rst:127 +#: ../../library/importlib.metadata.rst:134 msgid "" -"Note: it is not currently possible to query for entry points based on their :" -"attr:`!EntryPoint.dist` attribute (as different :class:`!Distribution` " -"instances do not currently compare equal, even if they have the same " -"attributes)" +"Note: to query for entry points based on :attr:`!EntryPoint.dist` attribute, " +"use :meth:`Distribution.entry_points` instead (as different :class:" +"`Distribution` instances do not currently compare equal, even if they have " +"the same attributes)" msgstr "" -#: ../../library/importlib.metadata.rst:133 +#: ../../library/importlib.metadata.rst:140 msgid "Details of a collection of installed entry points." msgstr "" -#: ../../library/importlib.metadata.rst:135 +#: ../../library/importlib.metadata.rst:142 msgid "" "Also provides a ``.groups`` attribute that reports all identified entry " "point groups, and a ``.names`` attribute that reports all identified entry " "point names." msgstr "" -#: ../../library/importlib.metadata.rst:141 +#: ../../library/importlib.metadata.rst:148 msgid "Details of an installed entry point." msgstr "" -#: ../../library/importlib.metadata.rst:143 +#: ../../library/importlib.metadata.rst:150 msgid "" "Each :class:`!EntryPoint` instance has ``.name``, ``.group``, and ``.value`` " "attributes and a ``.load()`` method to resolve the value. There are also ``." @@ -221,22 +228,22 @@ msgid "" "regarding the distribution package that provides the entry point." msgstr "" -#: ../../library/importlib.metadata.rst:149 +#: ../../library/importlib.metadata.rst:156 msgid "Query all entry points::" msgstr "" -#: ../../library/importlib.metadata.rst:151 +#: ../../library/importlib.metadata.rst:158 msgid ">>> eps = entry_points()" msgstr ">>> eps = entry_points()" -#: ../../library/importlib.metadata.rst:153 +#: ../../library/importlib.metadata.rst:160 msgid "" "The :func:`!entry_points` function returns a :class:`!EntryPoints` object, a " "collection of all :class:`!EntryPoint` objects with ``names`` and ``groups`` " "attributes for convenience::" msgstr "" -#: ../../library/importlib.metadata.rst:157 +#: ../../library/importlib.metadata.rst:164 msgid "" ">>> sorted(eps.groups)\n" "['console_scripts', 'distutils.commands', 'distutils.setup_keywords', " @@ -246,33 +253,33 @@ msgstr "" "['console_scripts', 'distutils.commands', 'distutils.setup_keywords', " "'egg_info.writers', 'setuptools.installation']" -#: ../../library/importlib.metadata.rst:160 +#: ../../library/importlib.metadata.rst:167 msgid "" ":class:`!EntryPoints` has a :meth:`!select` method to select entry points " "matching specific properties. Select entry points in the ``console_scripts`` " "group::" msgstr "" -#: ../../library/importlib.metadata.rst:164 +#: ../../library/importlib.metadata.rst:171 msgid ">>> scripts = eps.select(group='console_scripts')" msgstr ">>> scripts = eps.select(group='console_scripts')" -#: ../../library/importlib.metadata.rst:166 +#: ../../library/importlib.metadata.rst:173 msgid "" "Equivalently, since :func:`!entry_points` passes keyword arguments through " "to select::" msgstr "" -#: ../../library/importlib.metadata.rst:169 +#: ../../library/importlib.metadata.rst:176 msgid ">>> scripts = entry_points(group='console_scripts')" msgstr ">>> scripts = entry_points(group='console_scripts')" -#: ../../library/importlib.metadata.rst:171 +#: ../../library/importlib.metadata.rst:178 msgid "" "Pick out a specific script named \"wheel\" (found in the wheel project)::" msgstr "" -#: ../../library/importlib.metadata.rst:173 +#: ../../library/importlib.metadata.rst:180 msgid "" ">>> 'wheel' in scripts.names\n" "True\n" @@ -282,11 +289,11 @@ msgstr "" "True\n" ">>> wheel = scripts['wheel']" -#: ../../library/importlib.metadata.rst:177 +#: ../../library/importlib.metadata.rst:184 msgid "Equivalently, query for that entry point during selection::" msgstr "" -#: ../../library/importlib.metadata.rst:179 +#: ../../library/importlib.metadata.rst:186 msgid "" ">>> (wheel,) = entry_points(group='console_scripts', name='wheel')\n" ">>> (wheel,) = entry_points().select(group='console_scripts', name='wheel')" @@ -294,11 +301,11 @@ msgstr "" ">>> (wheel,) = entry_points(group='console_scripts', name='wheel')\n" ">>> (wheel,) = entry_points().select(group='console_scripts', name='wheel')" -#: ../../library/importlib.metadata.rst:182 +#: ../../library/importlib.metadata.rst:189 msgid "Inspect the resolved entry point::" msgstr "" -#: ../../library/importlib.metadata.rst:184 +#: ../../library/importlib.metadata.rst:191 msgid "" ">>> wheel\n" "EntryPoint(name='wheel', value='wheel.cli:main', group='console_scripts')\n" @@ -324,7 +331,7 @@ msgstr "" ">>> main\n" "" -#: ../../library/importlib.metadata.rst:196 +#: ../../library/importlib.metadata.rst:203 msgid "" "The ``group`` and ``name`` are arbitrary values defined by the package " "author and usually a client will wish to resolve all entry points for a " @@ -333,7 +340,7 @@ msgid "" "their definition, and usage." msgstr "" -#: ../../library/importlib.metadata.rst:202 +#: ../../library/importlib.metadata.rst:209 msgid "" "The \"selectable\" entry points were introduced in ``importlib_metadata`` " "3.6 and Python 3.10. Prior to those changes, ``entry_points`` accepted no " @@ -343,63 +350,69 @@ msgid "" "entry_points_selectable` for compatibility options." msgstr "" -#: ../../library/importlib.metadata.rst:211 +#: ../../library/importlib.metadata.rst:218 msgid "" "``EntryPoint`` objects no longer present a tuple-like interface (:meth:" "`~object.__getitem__`)." msgstr "" -#: ../../library/importlib.metadata.rst:218 +#: ../../library/importlib.metadata.rst:225 msgid "Distribution metadata" msgstr "" -#: ../../library/importlib.metadata.rst:222 +#: ../../library/importlib.metadata.rst:229 msgid "" "Return the distribution metadata corresponding to the named distribution " "package as a :class:`PackageMetadata` instance." msgstr "" -#: ../../library/importlib.metadata.rst:225 -#: ../../library/importlib.metadata.rst:274 -#: ../../library/importlib.metadata.rst:295 -#: ../../library/importlib.metadata.rst:358 -#: ../../library/importlib.metadata.rst:409 +#: ../../library/importlib.metadata.rst:232 +#: ../../library/importlib.metadata.rst:290 +#: ../../library/importlib.metadata.rst:311 +#: ../../library/importlib.metadata.rst:384 +#: ../../library/importlib.metadata.rst:447 msgid "" "Raises :exc:`PackageNotFoundError` if the named distribution package is not " "installed in the current Python environment." msgstr "" -#: ../../library/importlib.metadata.rst:230 +#: ../../library/importlib.metadata.rst:235 +msgid "" +"Raises :exc:`MetadataNotFound` if a distribution package is present but no " +"METADATA file is present." +msgstr "" + +#: ../../library/importlib.metadata.rst:240 msgid "" "A concrete implementation of the `PackageMetadata protocol `_." msgstr "" -#: ../../library/importlib.metadata.rst:233 +#: ../../library/importlib.metadata.rst:243 msgid "" "In addition to providing the defined protocol methods and attributes, " "subscripting the instance is equivalent to calling the :meth:`!get` method." msgstr "" -#: ../../library/importlib.metadata.rst:236 +#: ../../library/importlib.metadata.rst:246 msgid "" "Every `Distribution Package `_ includes some metadata, which you can extract " "using the :func:`!metadata` function::" msgstr "" -#: ../../library/importlib.metadata.rst:239 +#: ../../library/importlib.metadata.rst:249 msgid ">>> wheel_metadata = metadata('wheel')" msgstr ">>> wheel_metadata = metadata('wheel')" -#: ../../library/importlib.metadata.rst:241 +#: ../../library/importlib.metadata.rst:251 msgid "" "The keys of the returned data structure name the metadata keywords, and the " "values are returned unparsed from the distribution metadata::" msgstr "" -#: ../../library/importlib.metadata.rst:244 +#: ../../library/importlib.metadata.rst:254 msgid "" ">>> wheel_metadata['Requires-Python']\n" "'>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'" @@ -407,13 +420,13 @@ msgstr "" ">>> wheel_metadata['Requires-Python']\n" "'>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'" -#: ../../library/importlib.metadata.rst:247 +#: ../../library/importlib.metadata.rst:257 msgid "" ":class:`PackageMetadata` also presents a :attr:`!json` attribute that " "returns all the metadata in a JSON-compatible form per :PEP:`566`::" msgstr "" -#: ../../library/importlib.metadata.rst:250 +#: ../../library/importlib.metadata.rst:260 msgid "" ">>> wheel_metadata.json['requires_python']\n" "'>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'" @@ -421,43 +434,51 @@ msgstr "" ">>> wheel_metadata.json['requires_python']\n" "'>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'" -#: ../../library/importlib.metadata.rst:253 -#: ../../library/importlib.metadata.rst:452 +#: ../../library/importlib.metadata.rst:263 +#: ../../library/importlib.metadata.rst:496 msgid "" "The full set of available metadata is not described here. See the PyPA `Core " "metadata specification `_ for additional details." msgstr "" -#: ../../library/importlib.metadata.rst:256 +#: ../../library/importlib.metadata.rst:266 +msgid "" +"Previously and incidentally, if a METADATA file was missing from a " +"distribution, an empty ``PackageMetadata`` would be returned, " +"indistinguishable from an empty METADATA file. Now, a missing METADATA file " +"triggers a ``MetadataNotFound`` exception." +msgstr "" + +#: ../../library/importlib.metadata.rst:272 msgid "" "The ``Description`` is now included in the metadata when presented through " "the payload. Line continuation characters have been removed." msgstr "" -#: ../../library/importlib.metadata.rst:260 +#: ../../library/importlib.metadata.rst:276 msgid "The ``json`` attribute was added." msgstr "新增 ``json`` 屬性。" -#: ../../library/importlib.metadata.rst:266 +#: ../../library/importlib.metadata.rst:282 msgid "Distribution versions" msgstr "" -#: ../../library/importlib.metadata.rst:270 +#: ../../library/importlib.metadata.rst:286 msgid "" "Return the installed distribution package `version `__ for the named " "distribution package." msgstr "" -#: ../../library/importlib.metadata.rst:277 +#: ../../library/importlib.metadata.rst:293 msgid "" "The :func:`!version` function is the quickest way to get a `Distribution " "Package `_'s version number, as a string::" msgstr "" -#: ../../library/importlib.metadata.rst:281 +#: ../../library/importlib.metadata.rst:297 msgid "" ">>> version('wheel')\n" "'0.32.3'" @@ -465,38 +486,51 @@ msgstr "" ">>> version('wheel')\n" "'0.32.3'" -#: ../../library/importlib.metadata.rst:288 +#: ../../library/importlib.metadata.rst:304 msgid "Distribution files" msgstr "" -#: ../../library/importlib.metadata.rst:292 +#: ../../library/importlib.metadata.rst:308 msgid "" -"Return the full set of files contained within the named distribution package." +"Return the full set of files contained within the named distribution package " +"as :class:`PackagePath` instances." msgstr "" -#: ../../library/importlib.metadata.rst:298 +#: ../../library/importlib.metadata.rst:314 msgid "" "Returns :const:`None` if the distribution is found but the installation " "database records reporting the files associated with the distribution " "package are missing." msgstr "" -#: ../../library/importlib.metadata.rst:304 +#: ../../library/importlib.metadata.rst:320 msgid "" "A :class:`pathlib.PurePath` derived object with additional ``dist``, " "``size``, and ``hash`` properties corresponding to the distribution " -"package's installation metadata for that file." +"package's installation metadata for that file, also:" msgstr "" -#: ../../library/importlib.metadata.rst:308 +#: ../../library/importlib.metadata.rst:326 +msgid "" +"If possible, return the concrete :class:`SimplePath` allowing to access " +"data, or raise a :exc:`NotImplementedError` otherwise." +msgstr "" + +#: ../../library/importlib.metadata.rst:331 +msgid "" +"A protocol representing a minimal subset of :class:`pathlib.Path` that " +"allows to check if it ``exists()``, to traverse using ``joinpath()`` and " +"``parent``, and to retrieve data using ``read_text()`` and ``read_bytes()``." +msgstr "" + +#: ../../library/importlib.metadata.rst:335 msgid "" "The :func:`!files` function takes a `Distribution Package `_ name and returns " -"all of the files installed by this distribution. Each file is reported as a :" -"class:`PackagePath` instance. For example::" +"all of the files installed by this distribution. For example::" msgstr "" -#: ../../library/importlib.metadata.rst:313 +#: ../../library/importlib.metadata.rst:339 msgid "" ">>> util = [p for p in files('wheel') if 'util.py' in str(p)][0]\n" ">>> util\n" @@ -518,11 +552,11 @@ msgstr "" ">>> util.hash\n" "" -#: ../../library/importlib.metadata.rst:323 +#: ../../library/importlib.metadata.rst:349 msgid "Once you have the file, you can also read its contents::" msgstr "" -#: ../../library/importlib.metadata.rst:325 +#: ../../library/importlib.metadata.rst:351 msgid "" ">>> print(util.read_text())\n" "import base64\n" @@ -542,13 +576,13 @@ msgstr "" " return s.encode('utf-8')\n" " return s" -#: ../../library/importlib.metadata.rst:334 +#: ../../library/importlib.metadata.rst:360 msgid "" "You can also use the :meth:`!locate` method to get the absolute path to the " "file::" msgstr "" -#: ../../library/importlib.metadata.rst:337 +#: ../../library/importlib.metadata.rst:363 msgid "" ">>> util.locate()\n" "PosixPath('/home/gustav/example/lib/site-packages/wheel/util.py')" @@ -556,7 +590,7 @@ msgstr "" ">>> util.locate()\n" "PosixPath('/home/gustav/example/lib/site-packages/wheel/util.py')" -#: ../../library/importlib.metadata.rst:340 +#: ../../library/importlib.metadata.rst:366 msgid "" "In the case where the metadata file listing files (``RECORD`` or ``SOURCES." "txt``) is missing, :func:`!files` will return :const:`None`. The caller may " @@ -566,23 +600,23 @@ msgid "" "distribution is not known to have the metadata present." msgstr "" -#: ../../library/importlib.metadata.rst:351 +#: ../../library/importlib.metadata.rst:377 msgid "Distribution requirements" msgstr "" -#: ../../library/importlib.metadata.rst:355 +#: ../../library/importlib.metadata.rst:381 msgid "" "Return the declared dependency specifiers for the named distribution package." msgstr "" -#: ../../library/importlib.metadata.rst:361 +#: ../../library/importlib.metadata.rst:387 msgid "" "To get the full set of requirements for a `Distribution Package `_, use " "the :func:`!requires` function::" msgstr "" -#: ../../library/importlib.metadata.rst:365 +#: ../../library/importlib.metadata.rst:391 msgid "" ">>> requires('wheel')\n" "[\"pytest (>=3.0.0) ; extra == 'test'\", \"pytest-cov ; extra == 'test'\"]" @@ -590,25 +624,25 @@ msgstr "" ">>> requires('wheel')\n" "[\"pytest (>=3.0.0) ; extra == 'test'\", \"pytest-cov ; extra == 'test'\"]" -#: ../../library/importlib.metadata.rst:373 +#: ../../library/importlib.metadata.rst:399 msgid "Mapping import to distribution packages" msgstr "" -#: ../../library/importlib.metadata.rst:377 +#: ../../library/importlib.metadata.rst:403 msgid "" "Return a mapping from the top level module and import package names found " "via :data:`sys.meta_path` to the names of the distribution packages (if any) " "that provide the corresponding files." msgstr "" -#: ../../library/importlib.metadata.rst:381 +#: ../../library/importlib.metadata.rst:407 msgid "" "To allow for namespace packages (which may have members provided by multiple " "distribution packages), each top level import name maps to a list of " "distribution names rather than mapping directly to a single name." msgstr "" -#: ../../library/importlib.metadata.rst:385 +#: ../../library/importlib.metadata.rst:411 msgid "" "A convenience method to resolve the `Distribution Package `_ name (or names, " @@ -617,7 +651,7 @@ msgid "" "glossary/#term-Import-Package>`_::" msgstr "" -#: ../../library/importlib.metadata.rst:390 +#: ../../library/importlib.metadata.rst:416 msgid "" ">>> packages_distributions()\n" "{'importlib_metadata': ['importlib-metadata'], 'yaml': ['PyYAML'], 'jaraco': " @@ -627,46 +661,29 @@ msgstr "" "{'importlib_metadata': ['importlib-metadata'], 'yaml': ['PyYAML'], 'jaraco': " "['jaraco.classes', 'jaraco.functools'], ...}" -#: ../../library/importlib.metadata.rst:393 +#: ../../library/importlib.metadata.rst:419 msgid "" "Some editable installs, `do not supply top-level names `_, and thus this function is not " "reliable with such installs." msgstr "" -#: ../../library/importlib.metadata.rst:402 +#: ../../library/importlib.metadata.rst:428 msgid "Distributions" msgstr "" -#: ../../library/importlib.metadata.rst:406 -msgid "" -"Return a :class:`Distribution` instance describing the named distribution " -"package." -msgstr "" - -#: ../../library/importlib.metadata.rst:414 -msgid "Details of an installed distribution package." -msgstr "" - -#: ../../library/importlib.metadata.rst:416 -msgid "" -"Note: different :class:`!Distribution` instances do not currently compare " -"equal, even if they relate to the same installed distribution and " -"accordingly have the same attributes." -msgstr "" - -#: ../../library/importlib.metadata.rst:420 +#: ../../library/importlib.metadata.rst:430 msgid "" "While the module level API described above is the most common and convenient " -"usage, you can get all of that information from the :class:`!Distribution` " +"usage, all that information is accessible from the :class:`Distribution` " "class. :class:`!Distribution` is an abstract object that represents the " "metadata for a Python `Distribution Package `_. You can get the concrete :" -"class:`!Distribution` subclass instance for an installed distribution " -"package by calling the :func:`distribution` function::" +"latest/glossary/#term-Distribution-Package>`_. Get the concrete :class:`!" +"Distribution` subclass instance for an installed distribution package by " +"calling the :func:`distribution` function::" msgstr "" -#: ../../library/importlib.metadata.rst:427 +#: ../../library/importlib.metadata.rst:437 msgid "" ">>> from importlib.metadata import distribution\n" ">>> dist = distribution('wheel')\n" @@ -678,13 +695,19 @@ msgstr "" ">>> type(dist)\n" "" -#: ../../library/importlib.metadata.rst:432 +#: ../../library/importlib.metadata.rst:444 msgid "" -"Thus, an alternative way to get the version number is through the :class:`!" -"Distribution` instance::" +"Return a :class:`Distribution` instance describing the named distribution " +"package." msgstr "" -#: ../../library/importlib.metadata.rst:435 +#: ../../library/importlib.metadata.rst:450 +msgid "" +"Thus, an alternative way to get e.g. the version number is through the :attr:" +"`Distribution.version` attribute::" +msgstr "" + +#: ../../library/importlib.metadata.rst:453 msgid "" ">>> dist.version\n" "'0.32.3'" @@ -692,13 +715,54 @@ msgstr "" ">>> dist.version\n" "'0.32.3'" -#: ../../library/importlib.metadata.rst:438 +#: ../../library/importlib.metadata.rst:456 +msgid "The same applies for :func:`entry_points` and :func:`files`." +msgstr "" + +#: ../../library/importlib.metadata.rst:460 +msgid "Details of an installed distribution package." +msgstr "" + +#: ../../library/importlib.metadata.rst:462 +msgid "" +"Note: different :class:`!Distribution` instances do not currently compare " +"equal, even if they relate to the same installed distribution and " +"accordingly have the same attributes." +msgstr "" + +#: ../../library/importlib.metadata.rst:469 +msgid "" +"Return a :class:`!Distribution` instance at the given path or with the given " +"name." +msgstr "" + +#: ../../library/importlib.metadata.rst:474 +msgid "" +"Returns an iterable of :class:`!Distribution` instances for all packages " +"(see distribution-discovery_)." +msgstr "" + +#: ../../library/importlib.metadata.rst:477 +msgid "" +"The optional argument *context* is a :class:`DistributionFinder.Context` " +"instance, used to modify the search for distributions. Alternatively, " +"*kwargs* may contain keyword arguments for constructing a new :class:`!" +"DistributionFinder.Context`." +msgstr "" + +#: ../../library/importlib.metadata.rst:485 +msgid "" +"Raises :exc:`MetadataNotFound` if the METADATA file is not present in the " +"distribution." +msgstr "" + +#: ../../library/importlib.metadata.rst:488 msgid "" "There are all kinds of additional metadata available on :class:`!" -"Distribution` instances::" +"Distribution` instances as a :class:`PackageMetadata` instance::" msgstr "" -#: ../../library/importlib.metadata.rst:441 +#: ../../library/importlib.metadata.rst:491 msgid "" ">>> dist.metadata['Requires-Python']\n" "'>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'\n" @@ -710,13 +774,21 @@ msgstr "" ">>> dist.metadata['License']\n" "'MIT'" -#: ../../library/importlib.metadata.rst:446 +#: ../../library/importlib.metadata.rst:506 +msgid "A few metadata fields are also available as shortcut properties." +msgstr "" + +#: ../../library/importlib.metadata.rst:510 +msgid "The ``name`` shortcut was added." +msgstr "新增 ``name`` 快捷屬性。" + +#: ../../library/importlib.metadata.rst:514 msgid "" "For editable packages, an ``origin`` property may present :pep:`610` " -"metadata::" +"metadata (for non-editable packages, ``origin`` is :const:`None`)::" msgstr "" -#: ../../library/importlib.metadata.rst:449 +#: ../../library/importlib.metadata.rst:517 msgid "" ">>> dist.origin.url\n" "'file:///path/to/wheel-0.32.3.editable-py3-none-any.whl'" @@ -724,15 +796,43 @@ msgstr "" ">>> dist.origin.url\n" "'file:///path/to/wheel-0.32.3.editable-py3-none-any.whl'" -#: ../../library/importlib.metadata.rst:455 -msgid "The ``.origin`` property was added." -msgstr "新增 ``.origin`` 屬性 (property)。" +#: ../../library/importlib.metadata.rst:520 +msgid "" +"The ``origin`` object follows the `Direct URL Data Structure `_." +msgstr "" -#: ../../library/importlib.metadata.rst:459 +#: ../../library/importlib.metadata.rst:528 +msgid "The entry points provided by this distribution package." +msgstr "" + +#: ../../library/importlib.metadata.rst:533 +msgid "" +"All files contained in this distribution package. Like :func:`files`, this " +"returns :const:`None` if there are no records." +msgstr "" + +#: ../../library/importlib.metadata.rst:536 +msgid "" +"The following two abstract methods need to be implemented when implementing-" +"custom-providers_:" +msgstr "" + +#: ../../library/importlib.metadata.rst:540 +msgid "" +"Like :meth:`!PackagePath.locate`, return a :class:`SimplePath` for the given " +"path. Takes a :class:`os.PathLike` or a :class:`str`." +msgstr "" + +#: ../../library/importlib.metadata.rst:545 +msgid "A shortcut for ``distribution.locate_file(filename).read_text()``." +msgstr "" + +#: ../../library/importlib.metadata.rst:550 msgid "Distribution Discovery" msgstr "" -#: ../../library/importlib.metadata.rst:461 +#: ../../library/importlib.metadata.rst:552 msgid "" "By default, this package provides built-in support for discovery of metadata " "for file system and zip file `Distribution Package `_ metadata is not available through :" @@ -776,23 +948,23 @@ msgid "" "`sys.meta_path`." msgstr "" -#: ../../library/importlib.metadata.rst:487 +#: ../../library/importlib.metadata.rst:633 msgid "" "The implementation has hooks integrated into the ``PathFinder``, serving " "metadata for distribution packages found on the file system." msgstr "" -#: ../../library/importlib.metadata.rst:490 +#: ../../library/importlib.metadata.rst:636 msgid "" "The abstract class :py:class:`importlib.abc.MetaPathFinder` defines the " "interface expected of finders by Python's import system. ``importlib." "metadata`` extends this protocol by looking for an optional " "``find_distributions`` callable on the finders from :data:`sys.meta_path` " -"and presents this extended interface as the ``DistributionFinder`` abstract " -"base class, which defines this abstract method::" +"and presents this extended interface as the :class:`DistributionFinder` " +"abstract base class, which defines this abstract method::" msgstr "" -#: ../../library/importlib.metadata.rst:498 +#: ../../library/importlib.metadata.rst:644 msgid "" "@abc.abstractmethod\n" "def find_distributions(context=DistributionFinder.Context()) -> " @@ -802,30 +974,31 @@ msgid "" " \"\"\"" msgstr "" -#: ../../library/importlib.metadata.rst:504 +#: ../../library/importlib.metadata.rst:650 msgid "" -"The ``DistributionFinder.Context`` object provides ``.path`` and ``.name`` " -"properties indicating the path to search and name to match and may supply " -"other relevant context sought by the consumer." +"The :class:`DistributionFinder.Context` object provides :attr:" +"`~DistributionFinder.Context.path` and :attr:`~DistributionFinder.Context." +"name` properties indicating the path to search and name to match and may " +"supply other relevant context sought by the consumer." msgstr "" -#: ../../library/importlib.metadata.rst:508 +#: ../../library/importlib.metadata.rst:656 msgid "" "In practice, to support finding distribution package metadata in locations " -"other than the file system, subclass ``Distribution`` and implement the " -"abstract methods. Then from a custom finder, return instances of this " -"derived ``Distribution`` in the ``find_distributions()`` method." +"other than the file system, subclass :class:`!Distribution` and implement " +"the abstract methods. Then from a custom finder, return instances of this " +"derived :class:`!Distribution` in the ``find_distributions()`` method." msgstr "" -#: ../../library/importlib.metadata.rst:515 +#: ../../library/importlib.metadata.rst:663 msgid "Example" msgstr "範例" -#: ../../library/importlib.metadata.rst:517 +#: ../../library/importlib.metadata.rst:665 msgid "Imagine a custom finder that loads Python modules from a database::" msgstr "" -#: ../../library/importlib.metadata.rst:519 +#: ../../library/importlib.metadata.rst:667 msgid "" "class DatabaseImporter(importlib.abc.MetaPathFinder):\n" " def __init__(self, db):\n" @@ -845,14 +1018,15 @@ msgstr "" "\n" "sys.meta_path.append(DatabaseImporter(connect_db(...)))" -#: ../../library/importlib.metadata.rst:528 +#: ../../library/importlib.metadata.rst:676 msgid "" "That importer now presumably provides importable modules from a database, " "but it provides no metadata or entry points. For this custom importer to " -"provide metadata, it would also need to implement ``DistributionFinder``::" +"provide metadata, it would also need to implement :class:" +"`DistributionFinder`::" msgstr "" -#: ../../library/importlib.metadata.rst:533 +#: ../../library/importlib.metadata.rst:681 msgid "" "from importlib.metadata import DistributionFinder\n" "\n" @@ -874,7 +1048,7 @@ msgstr "" " for dist_record in self.db.query_distributions(query):\n" " yield DatabaseDistribution(dist_record)" -#: ../../library/importlib.metadata.rst:543 +#: ../../library/importlib.metadata.rst:691 msgid "" "In this way, ``query_distributions`` would return records for each " "distribution served by the database matching the query. For example, if " @@ -883,7 +1057,7 @@ msgid "" "``Context(name=None)``." msgstr "" -#: ../../library/importlib.metadata.rst:549 +#: ../../library/importlib.metadata.rst:697 msgid "" "For the sake of simplicity, this example ignores ``context.path``\\. The " "``path`` attribute defaults to ``sys.path`` and is the set of import paths " @@ -896,11 +1070,11 @@ msgid "" "``context.path`` and only yield ``Distribution``\\ s pertinent to that path." msgstr "" -#: ../../library/importlib.metadata.rst:560 +#: ../../library/importlib.metadata.rst:708 msgid "``DatabaseDistribution``, then, would look something like::" msgstr "" -#: ../../library/importlib.metadata.rst:562 +#: ../../library/importlib.metadata.rst:710 msgid "" "class DatabaseDistribution(importlib.metadata.Distribution):\n" " def __init__(self, record):\n" @@ -923,17 +1097,20 @@ msgid "" " raise RuntimeError(\"This distribution has no file system\")" msgstr "" -#: ../../library/importlib.metadata.rst:582 +#: ../../library/importlib.metadata.rst:730 msgid "" "This basic implementation should provide metadata and entry points for " "packages served by the ``DatabaseImporter``, assuming that the ``record`` " "supplies suitable ``.name``, ``.version``, and ``.entry_points`` attributes." msgstr "" -#: ../../library/importlib.metadata.rst:587 +#: ../../library/importlib.metadata.rst:735 msgid "" "The ``DatabaseDistribution`` may also provide other metadata files, like " -"``RECORD`` (required for ``Distribution.files``) or override the " -"implementation of ``Distribution.files``. See the source for more " +"``RECORD`` (required for :attr:`!Distribution.files`) or override the " +"implementation of :attr:`!Distribution.files`. See the source for more " "inspiration." msgstr "" + +#~ msgid "The ``.origin`` property was added." +#~ msgstr "新增 ``.origin`` 屬性 (property)。" diff --git a/library/importlib.po b/library/importlib.po index 1e92dcff0e0..b0c02a007e6 100644 --- a/library/importlib.po +++ b/library/importlib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-18 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:04+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,19 +21,19 @@ msgstr "" msgid ":mod:`!importlib` --- The implementation of :keyword:`!import`" msgstr ":mod:`!importlib` --- :keyword:`!import` 的實作" -#: ../../library/importlib.rst:12 +#: ../../library/importlib.rst:9 msgid "**Source code:** :source:`Lib/importlib/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/importlib/__init__.py`" -#: ../../library/importlib.rst:18 +#: ../../library/importlib.rst:15 msgid "Introduction" msgstr "簡介" -#: ../../library/importlib.rst:20 +#: ../../library/importlib.rst:17 msgid "The purpose of the :mod:`!importlib` package is three-fold." msgstr ":mod:`!importlib` 的目的可分為三個部分。" -#: ../../library/importlib.rst:22 +#: ../../library/importlib.rst:19 msgid "" "One is to provide the implementation of the :keyword:`import` statement (and " "thus, by extension, the :func:`__import__` function) in Python source code. " @@ -46,7 +46,7 @@ msgstr "" "func:`__import__` 函式)。這讓 :keyword:`!import` 實作可以移植到任何 Python " "直譯器。同時,這也提供了一個比用其他程式語言實作更容易理解的版本。" -#: ../../library/importlib.rst:29 +#: ../../library/importlib.rst:26 msgid "" "Two, the components to implement :keyword:`import` are exposed in this " "package, making it easier for users to create their own custom objects " @@ -54,171 +54,171 @@ msgid "" "process." msgstr "" -#: ../../library/importlib.rst:33 +#: ../../library/importlib.rst:30 msgid "" "Three, the package contains modules exposing additional functionality for " "managing aspects of Python packages:" msgstr "" -#: ../../library/importlib.rst:36 +#: ../../library/importlib.rst:33 msgid "" ":mod:`importlib.metadata` presents access to metadata from third-party " "distributions." msgstr "" -#: ../../library/importlib.rst:38 +#: ../../library/importlib.rst:35 msgid "" ":mod:`importlib.resources` provides routines for accessing non-code " "\"resources\" from Python packages." msgstr "" -#: ../../library/importlib.rst:43 +#: ../../library/importlib.rst:40 msgid ":ref:`import`" msgstr ":ref:`import`" -#: ../../library/importlib.rst:44 +#: ../../library/importlib.rst:41 msgid "The language reference for the :keyword:`import` statement." msgstr "" -#: ../../library/importlib.rst:46 +#: ../../library/importlib.rst:43 msgid "" "`Packages specification `__" msgstr "" -#: ../../library/importlib.rst:47 +#: ../../library/importlib.rst:44 msgid "" "Original specification of packages. Some semantics have changed since the " "writing of this document (e.g. redirecting based on ``None`` in :data:`sys." "modules`)." msgstr "" -#: ../../library/importlib.rst:51 +#: ../../library/importlib.rst:48 msgid "The :func:`.__import__` function" msgstr ":func:`.__import__` 函式" -#: ../../library/importlib.rst:52 +#: ../../library/importlib.rst:49 msgid "The :keyword:`import` statement is syntactic sugar for this function." msgstr "" -#: ../../library/importlib.rst:54 +#: ../../library/importlib.rst:51 msgid ":ref:`sys-path-init`" msgstr ":ref:`sys-path-init`" -#: ../../library/importlib.rst:55 +#: ../../library/importlib.rst:52 msgid "The initialization of :data:`sys.path`." msgstr "" -#: ../../library/importlib.rst:57 +#: ../../library/importlib.rst:54 msgid ":pep:`235`" msgstr ":pep:`235`" -#: ../../library/importlib.rst:58 +#: ../../library/importlib.rst:55 msgid "Import on Case-Insensitive Platforms" msgstr "" -#: ../../library/importlib.rst:60 +#: ../../library/importlib.rst:57 msgid ":pep:`263`" msgstr ":pep:`263`" -#: ../../library/importlib.rst:61 +#: ../../library/importlib.rst:58 msgid "Defining Python Source Code Encodings" msgstr "" -#: ../../library/importlib.rst:63 +#: ../../library/importlib.rst:60 msgid ":pep:`302`" msgstr ":pep:`302`" -#: ../../library/importlib.rst:64 +#: ../../library/importlib.rst:61 msgid "New Import Hooks" msgstr "" -#: ../../library/importlib.rst:66 +#: ../../library/importlib.rst:63 msgid ":pep:`328`" msgstr ":pep:`328`" -#: ../../library/importlib.rst:67 +#: ../../library/importlib.rst:64 msgid "Imports: Multi-Line and Absolute/Relative" msgstr "" -#: ../../library/importlib.rst:69 +#: ../../library/importlib.rst:66 msgid ":pep:`366`" msgstr ":pep:`366`" -#: ../../library/importlib.rst:70 +#: ../../library/importlib.rst:67 msgid "Main module explicit relative imports" msgstr "" -#: ../../library/importlib.rst:72 +#: ../../library/importlib.rst:69 msgid ":pep:`420`" msgstr ":pep:`420`" -#: ../../library/importlib.rst:73 +#: ../../library/importlib.rst:70 msgid "Implicit namespace packages" msgstr "" -#: ../../library/importlib.rst:75 +#: ../../library/importlib.rst:72 msgid ":pep:`451`" msgstr ":pep:`451`" -#: ../../library/importlib.rst:76 +#: ../../library/importlib.rst:73 msgid "A ModuleSpec Type for the Import System" msgstr "" -#: ../../library/importlib.rst:78 +#: ../../library/importlib.rst:75 msgid ":pep:`488`" msgstr ":pep:`488`" -#: ../../library/importlib.rst:79 +#: ../../library/importlib.rst:76 msgid "Elimination of PYO files" msgstr "" -#: ../../library/importlib.rst:81 +#: ../../library/importlib.rst:78 msgid ":pep:`489`" msgstr ":pep:`489`" -#: ../../library/importlib.rst:82 +#: ../../library/importlib.rst:79 msgid "Multi-phase extension module initialization" msgstr "多階段擴充模組初始化" -#: ../../library/importlib.rst:84 +#: ../../library/importlib.rst:81 msgid ":pep:`552`" msgstr ":pep:`552`" -#: ../../library/importlib.rst:85 +#: ../../library/importlib.rst:82 msgid "Deterministic pycs" msgstr "" -#: ../../library/importlib.rst:87 +#: ../../library/importlib.rst:84 msgid ":pep:`3120`" msgstr ":pep:`3120`" -#: ../../library/importlib.rst:88 +#: ../../library/importlib.rst:85 msgid "Using UTF-8 as the Default Source Encoding" msgstr "" -#: ../../library/importlib.rst:90 +#: ../../library/importlib.rst:87 msgid ":pep:`3147`" msgstr ":pep:`3147`" -#: ../../library/importlib.rst:91 +#: ../../library/importlib.rst:88 msgid "PYC Repository Directories" msgstr "" -#: ../../library/importlib.rst:95 +#: ../../library/importlib.rst:92 msgid "Functions" msgstr "函式" -#: ../../library/importlib.rst:99 +#: ../../library/importlib.rst:96 msgid "An implementation of the built-in :func:`__import__` function." msgstr "" -#: ../../library/importlib.rst:102 +#: ../../library/importlib.rst:99 msgid "" "Programmatic importing of modules should use :func:`import_module` instead " "of this function." msgstr "" -#: ../../library/importlib.rst:107 +#: ../../library/importlib.rst:104 msgid "" "Import a module. The *name* argument specifies what module to import in " "absolute or relative terms (e.g. either ``pkg.mod`` or ``..mod``). If the " @@ -228,7 +228,7 @@ msgid "" "``pkg.mod``)." msgstr "" -#: ../../library/importlib.rst:115 +#: ../../library/importlib.rst:112 msgid "" "The :func:`import_module` function acts as a simplifying wrapper around :" "func:`importlib.__import__`. This means all semantics of the function are " @@ -238,7 +238,7 @@ msgid "" "returns the top-level package or module (e.g. ``pkg``)." msgstr "" -#: ../../library/importlib.rst:122 +#: ../../library/importlib.rst:119 msgid "" "If you are dynamically importing a module that was created since the " "interpreter began execution (e.g., created a Python source file), you may " @@ -246,11 +246,17 @@ msgid "" "noticed by the import system." msgstr "" -#: ../../library/importlib.rst:127 +#: ../../library/importlib.rst:124 +msgid "" +"If the module cannot be imported, :func:`import_module` will raise :exc:" +"`ImportError` or an appropriate subclass like :exc:`ModuleNotFoundError`." +msgstr "" + +#: ../../library/importlib.rst:128 msgid "Parent packages are automatically imported." msgstr "" -#: ../../library/importlib.rst:132 +#: ../../library/importlib.rst:133 msgid "" "Invalidate the internal caches of finders stored at :data:`sys.meta_path`. " "If a finder implements ``invalidate_caches()`` then it will be called to " @@ -259,13 +265,13 @@ msgid "" "will notice the new module's existence." msgstr "" -#: ../../library/importlib.rst:140 +#: ../../library/importlib.rst:141 msgid "" "Namespace packages created/installed in a different :data:`sys.path` " "location after the same namespace was already imported are noticed." msgstr "" -#: ../../library/importlib.rst:146 +#: ../../library/importlib.rst:147 msgid "" "Reload a previously imported *module*. The argument must be a module " "object, so it must have been successfully imported before. This is useful " @@ -275,11 +281,11 @@ msgid "" "causes a different object to be placed in :data:`sys.modules`)." msgstr "" -#: ../../library/importlib.rst:153 +#: ../../library/importlib.rst:154 msgid "When :func:`reload` is executed:" msgstr "" -#: ../../library/importlib.rst:155 +#: ../../library/importlib.rst:156 msgid "" "Python module's code is recompiled and the module-level code re-executed, " "defining a new set of objects which are bound to names in the module's " @@ -288,30 +294,30 @@ msgid "" "time." msgstr "" -#: ../../library/importlib.rst:161 +#: ../../library/importlib.rst:162 msgid "" "As with all other objects in Python the old objects are only reclaimed after " "their reference counts drop to zero." msgstr "" -#: ../../library/importlib.rst:164 +#: ../../library/importlib.rst:165 msgid "" "The names in the module namespace are updated to point to any new or changed " "objects." msgstr "" -#: ../../library/importlib.rst:167 +#: ../../library/importlib.rst:168 msgid "" "Other references to the old objects (such as names external to the module) " "are not rebound to refer to the new objects and must be updated in each " "namespace where they occur if that is desired." msgstr "" -#: ../../library/importlib.rst:171 +#: ../../library/importlib.rst:172 msgid "There are a number of other caveats:" msgstr "" -#: ../../library/importlib.rst:173 +#: ../../library/importlib.rst:174 msgid "" "When a module is reloaded, its dictionary (containing the module's global " "variables) is retained. Redefinitions of names will override the old " @@ -323,7 +329,7 @@ msgid "" "if desired::" msgstr "" -#: ../../library/importlib.rst:182 +#: ../../library/importlib.rst:183 msgid "" "try:\n" " cache\n" @@ -335,7 +341,7 @@ msgstr "" "except NameError:\n" " cache = {}" -#: ../../library/importlib.rst:187 +#: ../../library/importlib.rst:188 msgid "" "It is generally not very useful to reload built-in or dynamically loaded " "modules. Reloading :mod:`sys`, :mod:`__main__`, :mod:`builtins` and other " @@ -344,7 +350,7 @@ msgid "" "when reloaded." msgstr "" -#: ../../library/importlib.rst:193 +#: ../../library/importlib.rst:194 msgid "" "If a module imports objects from another module using :keyword:`from` ... :" "keyword:`import` ..., calling :func:`reload` for the other module does not " @@ -353,7 +359,7 @@ msgid "" "and qualified names (*module.name*) instead." msgstr "" -#: ../../library/importlib.rst:199 +#: ../../library/importlib.rst:200 msgid "" "If a module instantiates instances of a class, reloading the module that " "defines the class does not affect the method definitions of the instances " @@ -361,39 +367,39 @@ msgid "" "derived classes." msgstr "" -#: ../../library/importlib.rst:205 +#: ../../library/importlib.rst:206 msgid "" ":exc:`ModuleNotFoundError` is raised when the module being reloaded lacks a :" "class:`~importlib.machinery.ModuleSpec`." msgstr "" -#: ../../library/importlib.rst:210 +#: ../../library/importlib.rst:211 msgid "" "This function is not thread-safe. Calling it from multiple threads can " "result in unexpected behavior. It's recommended to use the :class:`threading." "Lock` or other synchronization primitives for thread-safe module reloading." msgstr "" -#: ../../library/importlib.rst:215 +#: ../../library/importlib.rst:216 msgid ":mod:`!importlib.abc` -- Abstract base classes related to import" msgstr "" -#: ../../library/importlib.rst:220 +#: ../../library/importlib.rst:221 msgid "**Source code:** :source:`Lib/importlib/abc.py`" msgstr "**原始碼:**\\ :source:`Lib/importlib/abc.py`" -#: ../../library/importlib.rst:225 +#: ../../library/importlib.rst:226 msgid "" "The :mod:`!importlib.abc` module contains all of the core abstract base " "classes used by :keyword:`import`. Some subclasses of the core abstract base " "classes are also provided to help in implementing the core ABCs." msgstr "" -#: ../../library/importlib.rst:229 +#: ../../library/importlib.rst:230 msgid "ABC hierarchy::" msgstr "" -#: ../../library/importlib.rst:231 +#: ../../library/importlib.rst:232 msgid "" "object\n" " +-- MetaPathFinder\n" @@ -415,15 +421,15 @@ msgstr "" " +-- FileLoader\n" " +-- SourceLoader" -#: ../../library/importlib.rst:244 +#: ../../library/importlib.rst:245 msgid "An abstract base class representing a :term:`meta path finder`." msgstr "" -#: ../../library/importlib.rst:248 ../../library/importlib.rst:284 +#: ../../library/importlib.rst:249 ../../library/importlib.rst:307 msgid "No longer a subclass of :class:`!Finder`." msgstr "不再是 :class:`!Finder` 的子類別。" -#: ../../library/importlib.rst:253 +#: ../../library/importlib.rst:254 msgid "" "An abstract method for finding a :term:`spec ` for the " "specified module. If this is a top-level import, *path* will be ``None``. " @@ -435,26 +441,56 @@ msgid "" "for implementing concrete ``MetaPathFinders``." msgstr "" -#: ../../library/importlib.rst:267 +#: ../../library/importlib.rst:268 msgid "" "An optional method which, when called, should invalidate any internal cache " "used by the finder. Used by :func:`importlib.invalidate_caches` when " "invalidating the caches of all finders on :data:`sys.meta_path`." msgstr "" -#: ../../library/importlib.rst:271 +#: ../../library/importlib.rst:272 msgid "Returns ``None`` when called instead of :data:`NotImplemented`." msgstr "呼叫時回傳 ``None`` 而非 :data:`NotImplemented`。" #: ../../library/importlib.rst:277 msgid "" +"An optional method which searches for possible specs with given *parent* " +"module spec. If *parent* is *None*, :meth:`MetaPathFinder.discover` will " +"search for top-level modules." +msgstr "" + +#: ../../library/importlib.rst:281 ../../library/importlib.rst:335 +msgid "Returns an iterable of possible specs." +msgstr "" + +#: ../../library/importlib.rst:283 ../../library/importlib.rst:337 +msgid "Raises :exc:`ValueError` if *parent* is not a package module." +msgstr "" + +#: ../../library/importlib.rst:286 ../../library/importlib.rst:340 +msgid "" +"This method can potentially yield a very large number of objects, and it may " +"carry out IO operations when computing these values." +msgstr "" + +#: ../../library/importlib.rst:289 ../../library/importlib.rst:343 +msgid "" +"Because of this, it will generally be desirable to compute the result values " +"on-the-fly, as they are needed. As such, the returned object is only " +"guaranteed to be an :class:`iterable `, instead of " +"a :class:`list` or other :class:`collection ` " +"type." +msgstr "" + +#: ../../library/importlib.rst:300 +msgid "" "An abstract base class representing a :term:`path entry finder`. Though it " "bears some similarities to :class:`MetaPathFinder`, ``PathEntryFinder`` is " "meant for use only within the path-based import subsystem provided by :class:" "`importlib.machinery.PathFinder`." msgstr "" -#: ../../library/importlib.rst:289 +#: ../../library/importlib.rst:312 msgid "" "An abstract method for finding a :term:`spec ` for the " "specified module. The finder will search for the module only within the :" @@ -465,42 +501,55 @@ msgid "" "concrete ``PathEntryFinders``." msgstr "" -#: ../../library/importlib.rst:301 +#: ../../library/importlib.rst:324 msgid "" "An optional method which, when called, should invalidate any internal cache " "used by the finder. Used by :meth:`importlib.machinery.PathFinder." "invalidate_caches` when invalidating the caches of all cached finders." msgstr "" -#: ../../library/importlib.rst:309 +#: ../../library/importlib.rst:331 +msgid "" +"An optional method which searches for possible specs with given *parent* " +"module spec. If *parent* is *None*, :meth:`PathEntryFinder.discover` will " +"search for top-level modules." +msgstr "" + +#: ../../library/importlib.rst:354 msgid "" "An abstract base class for a :term:`loader`. See :pep:`302` for the exact " "definition for a loader." msgstr "" -#: ../../library/importlib.rst:312 +#: ../../library/importlib.rst:357 msgid "" "Loaders that wish to support resource reading should implement a :meth:`!" "get_resource_reader` method as specified by :class:`importlib.resources.abc." "ResourceReader`." msgstr "" -#: ../../library/importlib.rst:316 +#: ../../library/importlib.rst:361 msgid "Introduced the optional :meth:`!get_resource_reader` method." msgstr "" -#: ../../library/importlib.rst:321 +#: ../../library/importlib.rst:364 ../../library/importlib.rst:529 +#: ../../library/importlib.rst:571 ../../library/importlib.rst:886 +#: ../../library/importlib.rst:922 +msgid "Removed the ``load_module()`` method." +msgstr "" + +#: ../../library/importlib.rst:369 msgid "" "A method that returns the module object to use when importing a module. " "This method may return ``None``, indicating that default module creation " "semantics should take place." msgstr "" -#: ../../library/importlib.rst:327 +#: ../../library/importlib.rst:375 msgid "This method is no longer optional when :meth:`exec_module` is defined." msgstr "" -#: ../../library/importlib.rst:333 +#: ../../library/importlib.rst:381 msgid "" "An abstract method that executes the module in its own namespace when a " "module is imported or reloaded. The module should already be initialized " @@ -508,96 +557,28 @@ msgid "" "`create_module` must be defined." msgstr "" -#: ../../library/importlib.rst:340 +#: ../../library/importlib.rst:388 msgid ":meth:`create_module` must also be defined." msgstr ":meth:`create_module` 也必須被定義。" -#: ../../library/importlib.rst:345 -msgid "" -"A legacy method for loading a module. If the module cannot be loaded, :exc:" -"`ImportError` is raised, otherwise the loaded module is returned." -msgstr "" - -#: ../../library/importlib.rst:349 -msgid "" -"If the requested module already exists in :data:`sys.modules`, that module " -"should be used and reloaded. Otherwise the loader should create a new module " -"and insert it into :data:`sys.modules` before any loading begins, to prevent " -"recursion from the import. If the loader inserted a module and the load " -"fails, it must be removed by the loader from :data:`sys.modules`; modules " -"already in :data:`sys.modules` before the loader began execution should be " -"left alone." -msgstr "" - -#: ../../library/importlib.rst:358 -msgid "" -"The loader should set several attributes on the module (note that some of " -"these attributes can change when a module is reloaded):" -msgstr "" - -#: ../../library/importlib.rst:362 -msgid ":attr:`module.__name__`" -msgstr ":attr:`module.__name__`" - -#: ../../library/importlib.rst:363 -msgid ":attr:`module.__file__`" -msgstr ":attr:`module.__file__`" - -#: ../../library/importlib.rst:364 -msgid ":attr:`module.__cached__` *(deprecated)*" -msgstr ":attr:`module.__cached__` *(已棄用)*" - -#: ../../library/importlib.rst:365 -msgid ":attr:`module.__path__`" -msgstr ":attr:`module.__path__`" - -#: ../../library/importlib.rst:366 -msgid ":attr:`module.__package__` *(deprecated)*" -msgstr ":attr:`module.__package__` *(已棄用)*" - -#: ../../library/importlib.rst:367 -msgid ":attr:`module.__loader__` *(deprecated)*" -msgstr ":attr:`module.__loader__` *(已棄用)*" - -#: ../../library/importlib.rst:369 -msgid "" -"When :meth:`exec_module` is available then backwards-compatible " -"functionality is provided." -msgstr "" - -#: ../../library/importlib.rst:372 -msgid "" -"Raise :exc:`ImportError` when called instead of :exc:`NotImplementedError`. " -"Functionality provided when :meth:`exec_module` is available." -msgstr "" - -#: ../../library/importlib.rst:377 -msgid "" -"The recommended API for loading a module is :meth:`exec_module` (and :meth:" -"`create_module`). Loaders should implement it instead of :meth:" -"`load_module`. The import machinery takes care of all the other " -"responsibilities of :meth:`load_module` when :meth:`exec_module` is " -"implemented." -msgstr "" - -#: ../../library/importlib.rst:387 +#: ../../library/importlib.rst:394 msgid "*Superseded by TraversableResources*" msgstr "" -#: ../../library/importlib.rst:389 +#: ../../library/importlib.rst:396 msgid "" "An abstract base class for a :term:`loader` which implements the optional :" "pep:`302` protocol for loading arbitrary resources from the storage back-end." msgstr "" -#: ../../library/importlib.rst:393 +#: ../../library/importlib.rst:400 msgid "" "This ABC is deprecated in favour of supporting resource loading through :" "class:`importlib.resources.abc.TraversableResources`. This class exists for " "backwards compatibility only with other ABCs in this module." msgstr "" -#: ../../library/importlib.rst:402 +#: ../../library/importlib.rst:409 msgid "" "An abstract method to return the bytes for the data located at *path*. " "Loaders that have a file-like storage back-end that allows storing arbitrary " @@ -607,34 +588,34 @@ msgid "" "__file__` attribute or an item from a package's :attr:`~module.__path__`." msgstr "" -#: ../../library/importlib.rst:411 +#: ../../library/importlib.rst:418 msgid "Raises :exc:`OSError` instead of :exc:`NotImplementedError`." msgstr "引發 :exc:`OSError` 而非 :exc:`NotImplementedError`。" -#: ../../library/importlib.rst:417 +#: ../../library/importlib.rst:424 msgid "" "An abstract base class for a :term:`loader` which implements the optional :" "pep:`302` protocol for loaders that inspect modules." msgstr "" -#: ../../library/importlib.rst:422 +#: ../../library/importlib.rst:429 msgid "" "Return the code object for a module, or ``None`` if the module does not have " "a code object (as would be the case, for example, for a built-in module). " "Raise an :exc:`ImportError` if loader cannot find the requested module." msgstr "" -#: ../../library/importlib.rst:428 +#: ../../library/importlib.rst:435 msgid "" "While the method has a default implementation, it is suggested that it be " "overridden if possible for performance." msgstr "" -#: ../../library/importlib.rst:434 +#: ../../library/importlib.rst:441 msgid "No longer abstract and a concrete implementation is provided." msgstr "" -#: ../../library/importlib.rst:440 +#: ../../library/importlib.rst:447 msgid "" "An abstract method to return the source of a module. It is returned as a " "text string using :term:`universal newlines`, translating all recognized " @@ -643,23 +624,23 @@ msgid "" "cannot find the module specified." msgstr "" -#: ../../library/importlib.rst:446 ../../library/importlib.rst:455 -#: ../../library/importlib.rst:506 +#: ../../library/importlib.rst:453 ../../library/importlib.rst:462 +#: ../../library/importlib.rst:514 msgid "Raises :exc:`ImportError` instead of :exc:`NotImplementedError`." msgstr "引發 :exc:`ImportError` 而非 :exc:`NotImplementedError`。" -#: ../../library/importlib.rst:451 +#: ../../library/importlib.rst:458 msgid "" "An optional method to return a true value if the module is a package, a " "false value otherwise. :exc:`ImportError` is raised if the :term:`loader` " "cannot find the module." msgstr "" -#: ../../library/importlib.rst:460 +#: ../../library/importlib.rst:467 msgid "Create a code object from Python source." msgstr "" -#: ../../library/importlib.rst:462 +#: ../../library/importlib.rst:469 msgid "" "The *data* argument can be whatever the :func:`compile` function supports (i." "e. string or bytes). The *path* argument should be the \"path\" to where the " @@ -667,107 +648,101 @@ msgid "" "in a zip file)." msgstr "" -#: ../../library/importlib.rst:467 +#: ../../library/importlib.rst:474 msgid "" "With the subsequent code object one can execute it in a module by running " "``exec(code, module.__dict__)``." msgstr "" -#: ../../library/importlib.rst:472 +#: ../../library/importlib.rst:477 +msgid "" +"The optional argument *fullname* specifies the module name. It is needed to " +"unambiguous :ref:`filter ` syntax warnings by module name." +msgstr "" + +#: ../../library/importlib.rst:483 msgid "Made the method static." msgstr "" -#: ../../library/importlib.rst:477 +#: ../../library/importlib.rst:486 +msgid "Added the *fullname* parameter." +msgstr "" + +#: ../../library/importlib.rst:492 msgid "Implementation of :meth:`Loader.exec_module`." msgstr ":meth:`Loader.exec_module` 的實作。" -#: ../../library/importlib.rst:483 -msgid "Implementation of :meth:`Loader.load_module`." -msgstr ":meth:`Loader.load_module` 的實作。" - -#: ../../library/importlib.rst:485 -msgid "use :meth:`exec_module` instead." -msgstr "請改用 :meth:`exec_module`。" - -#: ../../library/importlib.rst:491 +#: ../../library/importlib.rst:499 msgid "" "An abstract base class which inherits from :class:`InspectLoader` that, when " "implemented, helps a module to be executed as a script. The ABC represents " "an optional :pep:`302` protocol." msgstr "" -#: ../../library/importlib.rst:498 +#: ../../library/importlib.rst:506 msgid "" "An abstract method that is to return the value of :attr:`~module.__file__` " "for the specified module. If no path is available, :exc:`ImportError` is " "raised." msgstr "" -#: ../../library/importlib.rst:502 +#: ../../library/importlib.rst:510 msgid "" "If source code is available, then the method should return the path to the " "source file, regardless of whether a bytecode was used to load the module." msgstr "" -#: ../../library/importlib.rst:512 +#: ../../library/importlib.rst:520 msgid "" "An abstract base class which inherits from :class:`ResourceLoader` and :" "class:`ExecutionLoader`, providing concrete implementations of :meth:" "`ResourceLoader.get_data` and :meth:`ExecutionLoader.get_filename`." msgstr "" -#: ../../library/importlib.rst:516 +#: ../../library/importlib.rst:524 msgid "" "The *fullname* argument is a fully resolved name of the module the loader is " "to handle. The *path* argument is the path to the file for the module." msgstr "" -#: ../../library/importlib.rst:523 +#: ../../library/importlib.rst:534 msgid "The name of the module the loader can handle." msgstr "" -#: ../../library/importlib.rst:527 +#: ../../library/importlib.rst:538 msgid "Path to the file of the module." msgstr "" -#: ../../library/importlib.rst:531 -msgid "Calls super's ``load_module()``." -msgstr "" - -#: ../../library/importlib.rst:533 -msgid "Use :meth:`Loader.exec_module` instead." -msgstr "改用 :meth:`Loader.exec_module`。" - -#: ../../library/importlib.rst:539 ../../library/importlib.rst:982 +#: ../../library/importlib.rst:543 ../../library/importlib.rst:1000 msgid "Returns :attr:`path`." msgstr "回傳 :attr:`path`。" -#: ../../library/importlib.rst:544 +#: ../../library/importlib.rst:548 msgid "Reads *path* as a binary file and returns the bytes from it." msgstr "將 *path* 作為二進位檔案讀取並回傳其位元組。" -#: ../../library/importlib.rst:549 +#: ../../library/importlib.rst:553 msgid "" "An abstract base class for implementing source (and optionally bytecode) " "file loading. The class inherits from both :class:`ResourceLoader` and :" "class:`ExecutionLoader`, requiring the implementation of:" msgstr "" -#: ../../library/importlib.rst:553 +#: ../../library/importlib.rst:557 msgid ":meth:`ResourceLoader.get_data`" msgstr ":meth:`ResourceLoader.get_data`" -#: ../../library/importlib.rst:554 +#: ../../library/importlib.rst:558 msgid ":meth:`ExecutionLoader.get_filename`" msgstr ":meth:`ExecutionLoader.get_filename`" -#: ../../library/importlib.rst:555 +#: ../../library/importlib.rst:559 msgid "" "Should only return the path to the source file; sourceless loading is not " "supported." msgstr "" -#: ../../library/importlib.rst:558 +#: ../../library/importlib.rst:562 msgid "" "The abstract methods defined by this class are to add optional bytecode file " "support. Not implementing these optional methods (or causing them to raise :" @@ -779,78 +754,70 @@ msgid "" "bytecode-specific API is exposed." msgstr "" -#: ../../library/importlib.rst:569 +#: ../../library/importlib.rst:576 msgid "" "Optional abstract method which returns a :class:`dict` containing metadata " "about the specified path. Supported dictionary keys are:" msgstr "" -#: ../../library/importlib.rst:572 +#: ../../library/importlib.rst:579 msgid "" "``'mtime'`` (mandatory): an integer or floating-point number representing " "the modification time of the source code;" msgstr "" -#: ../../library/importlib.rst:574 +#: ../../library/importlib.rst:581 msgid "``'size'`` (optional): the size in bytes of the source code." msgstr "" -#: ../../library/importlib.rst:576 +#: ../../library/importlib.rst:583 msgid "" "Any other keys in the dictionary are ignored, to allow for future " "extensions. If the path cannot be handled, :exc:`OSError` is raised." msgstr "" -#: ../../library/importlib.rst:581 ../../library/importlib.rst:594 +#: ../../library/importlib.rst:588 ../../library/importlib.rst:601 msgid "Raise :exc:`OSError` instead of :exc:`NotImplementedError`." msgstr "引發 :exc:`OSError` 而非 :exc:`NotImplementedError`。" -#: ../../library/importlib.rst:586 +#: ../../library/importlib.rst:593 msgid "" "Optional abstract method which returns the modification time for the " "specified path." msgstr "" -#: ../../library/importlib.rst:589 +#: ../../library/importlib.rst:596 msgid "" "This method is deprecated in favour of :meth:`path_stats`. You don't have " "to implement it, but it is still available for compatibility purposes. " "Raise :exc:`OSError` if the path cannot be handled." msgstr "" -#: ../../library/importlib.rst:599 +#: ../../library/importlib.rst:606 msgid "" "Optional abstract method which writes the specified bytes to a file path. " "Any intermediate directories which do not exist are to be created " "automatically." msgstr "" -#: ../../library/importlib.rst:603 +#: ../../library/importlib.rst:610 msgid "" "When writing to the path fails because the path is read-only (:const:`errno." "EACCES`/:exc:`PermissionError`), do not propagate the exception." msgstr "" -#: ../../library/importlib.rst:607 +#: ../../library/importlib.rst:614 msgid "No longer raises :exc:`NotImplementedError` when called." msgstr "呼叫時不再引發 :exc:`NotImplementedError`。" -#: ../../library/importlib.rst:612 +#: ../../library/importlib.rst:619 msgid "Concrete implementation of :meth:`InspectLoader.get_code`." msgstr ":meth:`InspectLoader.get_code` 的具體實作。" -#: ../../library/importlib.rst:616 +#: ../../library/importlib.rst:623 msgid "Concrete implementation of :meth:`Loader.exec_module`." msgstr ":meth:`Loader.exec_module` 的具體實作。" -#: ../../library/importlib.rst:622 -msgid "Concrete implementation of :meth:`Loader.load_module`." -msgstr ":meth:`Loader.load_module` 的具體實作。" - -#: ../../library/importlib.rst:624 -msgid "Use :meth:`exec_module` instead." -msgstr "改用 :meth:`exec_module`。" - #: ../../library/importlib.rst:629 msgid "Concrete implementation of :meth:`InspectLoader.get_source`." msgstr ":meth:`InspectLoader.get_source` 的具體實作。" @@ -1075,139 +1042,177 @@ msgstr "" #: ../../library/importlib.rst:850 msgid "" +"Represents a :term:`namespace package`'s path (:attr:`module.__path__`)." +msgstr "" + +#: ../../library/importlib.rst:852 +msgid "" +"When its ``__path__`` value is accessed it will be recomputed if necessary. " +"This keeps it in-sync with the global state (:attr:`sys.modules`)." +msgstr "" + +#: ../../library/importlib.rst:855 +msgid "The *name* argument is the name of the namespace module." +msgstr "" + +#: ../../library/importlib.rst:857 +msgid "The *path* argument is the initial path value." +msgstr "" + +#: ../../library/importlib.rst:859 +msgid "" +"The *path_finder* argument is the callable used to recompute the path value. " +"The callable has the same signature as :meth:`importlib.abc.MetaPathFinder." +"find_spec`." +msgstr "" + +#: ../../library/importlib.rst:862 +msgid "" +"When the parent's :attr:`module.__path__` attribute is updated, the path " +"value is recomputed." +msgstr "" + +#: ../../library/importlib.rst:865 +msgid "" +"If the parent module is missing from :data:`sys.modules`, then :exc:" +"`ModuleNotFoundError` will be raised." +msgstr "" + +#: ../../library/importlib.rst:868 +msgid "For top-level modules, the parent module's path is :data:`sys.path`." +msgstr "" + +#: ../../library/importlib.rst:872 +msgid "" +":meth:`PathFinder.invalidate_caches` invalidates :class:`NamespacePath`, " +"forcing the path value to be recomputed next time it is accessed." +msgstr "" + +#: ../../library/importlib.rst:880 +msgid "" "A concrete implementation of :class:`importlib.abc.SourceLoader` by " "subclassing :class:`importlib.abc.FileLoader` and providing some concrete " "implementations of other methods." msgstr "" -#: ../../library/importlib.rst:858 +#: ../../library/importlib.rst:891 msgid "The name of the module that this loader will handle." msgstr "" -#: ../../library/importlib.rst:862 +#: ../../library/importlib.rst:895 msgid "The path to the source file." msgstr "" -#: ../../library/importlib.rst:866 +#: ../../library/importlib.rst:899 msgid "Return ``True`` if :attr:`path` appears to be for a package." msgstr "" -#: ../../library/importlib.rst:870 +#: ../../library/importlib.rst:903 msgid "" "Concrete implementation of :meth:`importlib.abc.SourceLoader.path_stats`." msgstr "" -#: ../../library/importlib.rst:874 +#: ../../library/importlib.rst:907 msgid "Concrete implementation of :meth:`importlib.abc.SourceLoader.set_data`." msgstr "" -#: ../../library/importlib.rst:878 ../../library/importlib.rst:921 -msgid "" -"Concrete implementation of :meth:`importlib.abc.Loader.load_module` where " -"specifying the name of the module to load is optional." -msgstr "" - -#: ../../library/importlib.rst:883 ../../library/importlib.rst:926 -msgid "Use :meth:`importlib.abc.Loader.exec_module` instead." -msgstr "" - -#: ../../library/importlib.rst:888 +#: ../../library/importlib.rst:912 msgid "" "A concrete implementation of :class:`importlib.abc.FileLoader` which can " "import bytecode files (i.e. no source code files exist)." msgstr "" -#: ../../library/importlib.rst:891 +#: ../../library/importlib.rst:915 msgid "" "Please note that direct use of bytecode files (and thus not source code " "files) inhibits your modules from being usable by all Python implementations " "or new versions of Python which change the bytecode format." msgstr "" -#: ../../library/importlib.rst:900 +#: ../../library/importlib.rst:927 msgid "The name of the module the loader will handle." msgstr "" -#: ../../library/importlib.rst:904 +#: ../../library/importlib.rst:931 msgid "The path to the bytecode file." msgstr "" -#: ../../library/importlib.rst:908 +#: ../../library/importlib.rst:935 msgid "Determines if the module is a package based on :attr:`path`." msgstr "" -#: ../../library/importlib.rst:912 +#: ../../library/importlib.rst:939 msgid "Returns the code object for :attr:`name` created from :attr:`path`." msgstr "" -#: ../../library/importlib.rst:916 +#: ../../library/importlib.rst:943 msgid "" "Returns ``None`` as bytecode files have no source when this loader is used." msgstr "" -#: ../../library/importlib.rst:931 +#: ../../library/importlib.rst:949 msgid "" "A concrete implementation of :class:`importlib.abc.ExecutionLoader` for " "extension modules." msgstr "" -#: ../../library/importlib.rst:934 +#: ../../library/importlib.rst:952 msgid "" "The *fullname* argument specifies the name of the module the loader is to " "support. The *path* argument is the path to the extension module's file." msgstr "" -#: ../../library/importlib.rst:937 +#: ../../library/importlib.rst:955 msgid "" "Note that, by default, importing an extension module will fail in " "subinterpreters if it doesn't implement multi-phase init (see :pep:`489`), " "even if it would otherwise import successfully." msgstr "" -#: ../../library/importlib.rst:943 +#: ../../library/importlib.rst:961 msgid "Multi-phase init is now required for use in subinterpreters." msgstr "" -#: ../../library/importlib.rst:948 ../../library/importlib.rst:1134 +#: ../../library/importlib.rst:966 ../../library/importlib.rst:1151 msgid "Name of the module the loader supports." msgstr "" -#: ../../library/importlib.rst:952 +#: ../../library/importlib.rst:970 msgid "Path to the extension module." msgstr "" -#: ../../library/importlib.rst:956 +#: ../../library/importlib.rst:974 msgid "" "Creates the module object from the given specification in accordance with :" "pep:`489`." msgstr "" -#: ../../library/importlib.rst:963 +#: ../../library/importlib.rst:981 msgid "Initializes the given module object in accordance with :pep:`489`." msgstr "" -#: ../../library/importlib.rst:969 +#: ../../library/importlib.rst:987 msgid "" "Returns ``True`` if the file path points to a package's ``__init__`` module " "based on :const:`EXTENSION_SUFFIXES`." msgstr "" -#: ../../library/importlib.rst:974 +#: ../../library/importlib.rst:992 msgid "Returns ``None`` as extension modules lack a code object." msgstr "" -#: ../../library/importlib.rst:978 +#: ../../library/importlib.rst:996 msgid "Returns ``None`` as extension modules do not have source code." msgstr "" -#: ../../library/importlib.rst:989 +#: ../../library/importlib.rst:1007 msgid "" "A concrete implementation of :class:`importlib.abc.InspectLoader` for " "namespace packages. This is an alias for a private class and is only made " "public for introspecting the ``__loader__`` attribute on namespace packages::" msgstr "" -#: ../../library/importlib.rst:994 +#: ../../library/importlib.rst:1012 msgid "" ">>> from importlib.machinery import NamespaceLoader\n" ">>> import my_namespace\n" @@ -1225,7 +1230,7 @@ msgstr "" ">>> isinstance(my_namespace.__loader__, importlib.abc.Loader)\n" "True" -#: ../../library/importlib.rst:1007 +#: ../../library/importlib.rst:1025 msgid "" "A specification for a module's import-system-related state. This is " "typically exposed as the module's :attr:`~module.__spec__` attribute. Many " @@ -1238,19 +1243,19 @@ msgid "" "origin>`, and vice versa." msgstr "" -#: ../../library/importlib.rst:1021 +#: ../../library/importlib.rst:1039 msgid "" "The module's fully qualified name (see :attr:`module.__name__`). The :term:" "`finder` should always set this attribute to a non-empty string." msgstr "" -#: ../../library/importlib.rst:1026 +#: ../../library/importlib.rst:1044 msgid "" "The :term:`loader` used to load the module (see :attr:`module.__loader__`). " "The :term:`finder` should always set this attribute." msgstr "" -#: ../../library/importlib.rst:1031 +#: ../../library/importlib.rst:1049 msgid "" "The location the :term:`loader` should use to load the module (see :attr:" "`module.__file__`). For example, for modules loaded from a ``.py`` file this " @@ -1259,14 +1264,14 @@ msgid "" "there is not one (like for namespace packages), it should be set to ``None``." msgstr "" -#: ../../library/importlib.rst:1040 +#: ../../library/importlib.rst:1058 msgid "" "A (possibly empty) :term:`sequence` of strings enumerating the locations in " "which a package's submodules will be found (see :attr:`module.__path__`). " "Most of the time there will only be a single directory in this list." msgstr "" -#: ../../library/importlib.rst:1045 +#: ../../library/importlib.rst:1063 msgid "" "The :term:`finder` should set this attribute to a sequence, even an empty " "one, to indicate to the import system that the module is a package. It " @@ -1274,41 +1279,41 @@ msgid "" "later to a special object for namespace packages." msgstr "" -#: ../../library/importlib.rst:1053 +#: ../../library/importlib.rst:1071 msgid "" "The :term:`finder` may set this attribute to an object containing " "additional, module-specific data to use when loading the module. Otherwise " "it should be set to ``None``." msgstr "" -#: ../../library/importlib.rst:1059 +#: ../../library/importlib.rst:1077 msgid "" -"The filename of a compiled version of the module's code (see :attr:`module." -"__cached__`). The :term:`finder` should always set this attribute but it may " -"be ``None`` for modules that do not need compiled code stored." +"The filename of a compiled version of the module's code. The :term:`finder` " +"should always set this attribute but it may be ``None`` for modules that do " +"not need compiled code stored." msgstr "" -#: ../../library/importlib.rst:1066 +#: ../../library/importlib.rst:1083 msgid "" "(Read-only) The fully qualified name of the package the module is in (or the " "empty string for a top-level module). See :attr:`module.__package__`. If the " "module is a package then this is the same as :attr:`name`." msgstr "" -#: ../../library/importlib.rst:1073 +#: ../../library/importlib.rst:1090 msgid "" "``True`` if the spec's :attr:`origin` refers to a loadable location, " "``False`` otherwise. This value impacts how :attr:`!origin` is interpreted " "and how the module's :attr:`~module.__file__` is populated." msgstr "" -#: ../../library/importlib.rst:1080 +#: ../../library/importlib.rst:1097 msgid "" "A specialization of :class:`importlib.machinery.ExtensionFileLoader` that is " "able to load extension modules in Framework format." msgstr "" -#: ../../library/importlib.rst:1083 +#: ../../library/importlib.rst:1100 msgid "" "For compatibility with the iOS App Store, *all* binary modules in an iOS app " "must be dynamic libraries, contained in a framework with appropriate " @@ -1317,7 +1322,7 @@ msgid "" "material outside the Frameworks folder." msgstr "" -#: ../../library/importlib.rst:1089 +#: ../../library/importlib.rst:1106 msgid "" "To accommodate this requirement, when running on iOS, extension module " "binaries are *not* packaged as ``.so`` files on ``sys.path``, but as " @@ -1331,7 +1336,7 @@ msgid "" "fwork`` file, relative to the app bundle." msgstr "" -#: ../../library/importlib.rst:1100 +#: ../../library/importlib.rst:1117 msgid "" "For example, consider the case of an import ``from foo.bar import _whiz``, " "where ``_whiz`` is implemented with the binary module ``sources/foo/bar/" @@ -1347,7 +1352,7 @@ msgid "" "_whiz.origin``, containing the path to the ``.fwork`` file." msgstr "" -#: ../../library/importlib.rst:1114 +#: ../../library/importlib.rst:1131 msgid "" "When a module is loaded with this loader, the ``__file__`` for the module " "will report as the location of the ``.fwork`` file. This allows code to use " @@ -1356,7 +1361,7 @@ msgid "" "in the ``.framework`` folder." msgstr "" -#: ../../library/importlib.rst:1120 +#: ../../library/importlib.rst:1137 msgid "" "The Xcode project building the app is responsible for converting any ``.so`` " "files from wherever they exist in the ``PYTHONPATH`` into frameworks in the " @@ -1367,35 +1372,35 @@ msgid "" "details on how to construct this build step." msgstr "" -#: ../../library/importlib.rst:1130 +#: ../../library/importlib.rst:1147 msgid "Availability" msgstr "可用性" -#: ../../library/importlib.rst:1138 +#: ../../library/importlib.rst:1155 msgid "Path to the ``.fwork`` file for the extension module." msgstr "" -#: ../../library/importlib.rst:1142 +#: ../../library/importlib.rst:1159 msgid ":mod:`!importlib.util` -- Utility code for importers" msgstr "" -#: ../../library/importlib.rst:1148 +#: ../../library/importlib.rst:1165 msgid "**Source code:** :source:`Lib/importlib/util.py`" msgstr "**原始碼:**\\ :source:`Lib/importlib/util.py`" -#: ../../library/importlib.rst:1152 +#: ../../library/importlib.rst:1169 msgid "" "This module contains the various objects that help in the construction of " "an :term:`importer`." msgstr "" -#: ../../library/importlib.rst:1157 +#: ../../library/importlib.rst:1174 msgid "" "The bytes which represent the bytecode version number. If you need help with " "loading/writing bytecode then consider :class:`importlib.abc.SourceLoader`." msgstr "" -#: ../../library/importlib.rst:1164 +#: ../../library/importlib.rst:1181 msgid "" "Return the :pep:`3147`/:pep:`488` path to the byte-compiled file associated " "with the source *path*. For example, if *path* is ``/foo/bar/baz.py`` the " @@ -1405,7 +1410,7 @@ msgid "" "then :exc:`NotImplementedError` will be raised)." msgstr "" -#: ../../library/importlib.rst:1171 +#: ../../library/importlib.rst:1188 msgid "" "The *optimization* parameter is used to specify the optimization level of " "the bytecode file. An empty string represents no optimization, so ``/foo/bar/" @@ -1418,27 +1423,22 @@ msgid "" "be alphanumeric, else :exc:`ValueError` is raised." msgstr "" -#: ../../library/importlib.rst:1181 -msgid "" -"The *debug_override* parameter is deprecated and can be used to override the " -"system's value for ``__debug__``. A ``True`` value is the equivalent of " -"setting *optimization* to the empty string. A ``False`` value is the same as " -"setting *optimization* to ``1``. If both *debug_override* an *optimization* " -"are not ``None`` then :exc:`TypeError` is raised." -msgstr "" - -#: ../../library/importlib.rst:1189 +#: ../../library/importlib.rst:1200 msgid "" "The *optimization* parameter was added and the *debug_override* parameter " "was deprecated." msgstr "" -#: ../../library/importlib.rst:1193 ../../library/importlib.rst:1209 -#: ../../library/importlib.rst:1300 +#: ../../library/importlib.rst:1204 ../../library/importlib.rst:1223 +#: ../../library/importlib.rst:1314 msgid "Accepts a :term:`path-like object`." msgstr "接受一個 :term:`path-like object`。" -#: ../../library/importlib.rst:1199 +#: ../../library/importlib.rst:1207 +msgid "The *debug_override* parameter was removed." +msgstr "" + +#: ../../library/importlib.rst:1213 msgid "" "Given the *path* to a :pep:`3147` file name, return the associated source " "code file path. For example, if *path* is ``/foo/bar/__pycache__/baz." @@ -1449,25 +1449,25 @@ msgid "" "is raised." msgstr "" -#: ../../library/importlib.rst:1214 +#: ../../library/importlib.rst:1228 msgid "" "Decode the given bytes representing source code and return it as a string " "with universal newlines (as required by :meth:`importlib.abc.InspectLoader." "get_source`)." msgstr "" -#: ../../library/importlib.rst:1222 +#: ../../library/importlib.rst:1236 msgid "Resolve a relative module name to an absolute one." msgstr "" -#: ../../library/importlib.rst:1224 +#: ../../library/importlib.rst:1238 msgid "" "If **name** has no leading dots, then **name** is simply returned. This " "allows for usage such as ``importlib.util.resolve_name('sys', __spec__." "parent)`` without doing a check to see if the **package** argument is needed." msgstr "" -#: ../../library/importlib.rst:1229 +#: ../../library/importlib.rst:1243 msgid "" ":exc:`ImportError` is raised if **name** is a relative module name but " "**package** is a false value (e.g. ``None`` or the empty string). :exc:" @@ -1475,13 +1475,13 @@ msgid "" "package (e.g. requesting ``..bacon`` from within the ``spam`` package)." msgstr "" -#: ../../library/importlib.rst:1237 +#: ../../library/importlib.rst:1251 msgid "" "To improve consistency with import statements, raise :exc:`ImportError` " "instead of :exc:`ValueError` for invalid relative import attempts." msgstr "" -#: ../../library/importlib.rst:1244 +#: ../../library/importlib.rst:1258 msgid "" "Find the :term:`spec ` for a module, optionally relative to the " "specified **package** name. If the module is in :data:`sys.modules`, then " @@ -1491,32 +1491,32 @@ msgid "" "if no spec is found." msgstr "" -#: ../../library/importlib.rst:1251 +#: ../../library/importlib.rst:1265 msgid "" "If **name** is for a submodule (contains a dot), the parent module is " "automatically imported." msgstr "" -#: ../../library/importlib.rst:1254 +#: ../../library/importlib.rst:1268 msgid "" "**name** and **package** work the same as for :func:`importlib." "import_module`." msgstr "" -#: ../../library/importlib.rst:1259 +#: ../../library/importlib.rst:1273 msgid "" "Raises :exc:`ModuleNotFoundError` instead of :exc:`AttributeError` if " "**package** is in fact not a package (i.e. lacks a :attr:`~module.__path__` " "attribute)." msgstr "" -#: ../../library/importlib.rst:1266 +#: ../../library/importlib.rst:1280 msgid "" "Create a new module based on **spec** and :meth:`spec.loader.create_module " "`." msgstr "" -#: ../../library/importlib.rst:1269 +#: ../../library/importlib.rst:1283 msgid "" "If :meth:`spec.loader.create_module ` " "does not return ``None``, then any pre-existing attributes will not be " @@ -1524,14 +1524,14 @@ msgid "" "accessing **spec** or setting an attribute on the module." msgstr "" -#: ../../library/importlib.rst:1274 +#: ../../library/importlib.rst:1288 msgid "" "This function is preferred over using :class:`types.ModuleType` to create a " "new module as **spec** is used to set as many import-controlled attributes " "on the module as possible." msgstr "" -#: ../../library/importlib.rst:1282 +#: ../../library/importlib.rst:1296 msgid "" "A factory function for creating a :class:`~importlib.machinery.ModuleSpec` " "instance based on a loader. The parameters have the same meaning as they do " @@ -1540,7 +1540,7 @@ msgid "" "fill in any missing information on the spec." msgstr "" -#: ../../library/importlib.rst:1293 +#: ../../library/importlib.rst:1307 msgid "" "A factory function for creating a :class:`~importlib.machinery.ModuleSpec` " "instance based on the path to a file. Missing information will be filled in " @@ -1548,14 +1548,14 @@ msgid "" "module will be file-based." msgstr "" -#: ../../library/importlib.rst:1305 +#: ../../library/importlib.rst:1319 msgid "" "Return the hash of *source_bytes* as bytes. A hash-based ``.pyc`` file " "embeds the :func:`source_hash` of the corresponding source file's contents " "in its header." msgstr "" -#: ../../library/importlib.rst:1313 +#: ../../library/importlib.rst:1327 msgid "" "A context manager that can temporarily skip the compatibility check for " "extension modules. By default the check is enabled and will fail when a " @@ -1564,14 +1564,14 @@ msgid "" "interpreter GIL, when imported in an interpreter with its own GIL." msgstr "" -#: ../../library/importlib.rst:1320 +#: ../../library/importlib.rst:1334 msgid "" "Note that this function is meant to accommodate an unusual case; one which " "is likely to eventually go away. There's is a pretty good chance this is " "not what you were looking for." msgstr "" -#: ../../library/importlib.rst:1324 +#: ../../library/importlib.rst:1338 msgid "" "You can get the same effect as this function by implementing the basic " "interface of multi-phase init (:pep:`489`) and lying about support for " @@ -1580,19 +1580,19 @@ msgstr "" "你可以透過實作多階段初始化的基本介面 (:pep:`489`) 並假稱有多個直譯器(或直譯" "器各別持有的 GIL)的支援,來達到與此函式相同的效果。" -#: ../../library/importlib.rst:1329 +#: ../../library/importlib.rst:1343 msgid "" "Using this function to disable the check can lead to unexpected behavior and " "even crashes. It should only be used during extension module development." msgstr "" -#: ../../library/importlib.rst:1337 +#: ../../library/importlib.rst:1351 msgid "" "A class which postpones the execution of the loader of a module until the " "module has an attribute accessed." msgstr "" -#: ../../library/importlib.rst:1340 +#: ../../library/importlib.rst:1354 msgid "" "This class **only** works with loaders that define :meth:`~importlib.abc." "Loader.exec_module` as control over what module type is used for the module " @@ -1605,7 +1605,7 @@ msgid "" "raised if such a substitution is detected." msgstr "" -#: ../../library/importlib.rst:1351 +#: ../../library/importlib.rst:1365 msgid "" "For projects where startup time is critical, this class allows for " "potentially minimizing the cost of loading a module if it is never used. For " @@ -1614,21 +1614,21 @@ msgid "" "postponed and thus occurring out of context." msgstr "" -#: ../../library/importlib.rst:1359 +#: ../../library/importlib.rst:1373 msgid "" "Began calling :meth:`~importlib.abc.Loader.create_module`, removing the " "compatibility warning for :class:`importlib.machinery.BuiltinImporter` and :" "class:`importlib.machinery.ExtensionFileLoader`." msgstr "" -#: ../../library/importlib.rst:1366 +#: ../../library/importlib.rst:1380 msgid "" "A class method which returns a callable that creates a lazy loader. This is " "meant to be used in situations where the loader is passed by class instead " "of by instance. ::" msgstr "" -#: ../../library/importlib.rst:1371 +#: ../../library/importlib.rst:1385 msgid "" "suffixes = importlib.machinery.SOURCE_SUFFIXES\n" "loader = importlib.machinery.SourceFileLoader\n" @@ -1640,20 +1640,20 @@ msgstr "" "lazy_loader = importlib.util.LazyLoader.factory(loader)\n" "finder = importlib.machinery.FileFinder(path, (lazy_loader, suffixes))" -#: ../../library/importlib.rst:1379 +#: ../../library/importlib.rst:1393 msgid "Examples" msgstr "範例" -#: ../../library/importlib.rst:1382 +#: ../../library/importlib.rst:1396 msgid "Importing programmatically" msgstr "" -#: ../../library/importlib.rst:1384 +#: ../../library/importlib.rst:1398 msgid "" "To programmatically import a module, use :func:`importlib.import_module`. ::" msgstr "" -#: ../../library/importlib.rst:1387 +#: ../../library/importlib.rst:1401 msgid "" "import importlib\n" "\n" @@ -1663,23 +1663,23 @@ msgstr "" "\n" "itertools = importlib.import_module('itertools')" -#: ../../library/importlib.rst:1393 +#: ../../library/importlib.rst:1407 msgid "Checking if a module can be imported" msgstr "" -#: ../../library/importlib.rst:1395 +#: ../../library/importlib.rst:1409 msgid "" "If you need to find out if a module can be imported without actually doing " "the import, then you should use :func:`importlib.util.find_spec`." msgstr "" -#: ../../library/importlib.rst:1398 +#: ../../library/importlib.rst:1412 msgid "" "Note that if ``name`` is a submodule (contains a dot), :func:`importlib.util." "find_spec` will import the parent module. ::" msgstr "" -#: ../../library/importlib.rst:1402 +#: ../../library/importlib.rst:1416 msgid "" "import importlib.util\n" "import sys\n" @@ -1699,11 +1699,11 @@ msgid "" " print(f\"can't find the {name!r} module\")" msgstr "" -#: ../../library/importlib.rst:1421 +#: ../../library/importlib.rst:1435 msgid "Importing a source file directly" msgstr "" -#: ../../library/importlib.rst:1423 +#: ../../library/importlib.rst:1437 msgid "" "This recipe should be used with caution: it is an approximation of an import " "statement where the file path is specified directly, rather than :data:`sys." @@ -1713,13 +1713,13 @@ msgid "" "file is appropriate." msgstr "" -#: ../../library/importlib.rst:1430 +#: ../../library/importlib.rst:1444 msgid "" "To import a Python source file directly from a path, use the following " "recipe::" msgstr "" -#: ../../library/importlib.rst:1432 +#: ../../library/importlib.rst:1446 msgid "" "import importlib.util\n" "import sys\n" @@ -1742,15 +1742,15 @@ msgid "" "json = import_from_path(module_name, file_path)" msgstr "" -#: ../../library/importlib.rst:1454 +#: ../../library/importlib.rst:1468 msgid "Implementing lazy imports" msgstr "" -#: ../../library/importlib.rst:1456 +#: ../../library/importlib.rst:1470 msgid "The example below shows how to implement lazy imports::" msgstr "" -#: ../../library/importlib.rst:1458 +#: ../../library/importlib.rst:1472 msgid "" ">>> import importlib.util\n" ">>> import sys\n" @@ -1786,11 +1786,11 @@ msgstr "" ">>> lazy_typing.TYPE_CHECKING\n" "False" -#: ../../library/importlib.rst:1477 +#: ../../library/importlib.rst:1491 msgid "Setting up an importer" msgstr "" -#: ../../library/importlib.rst:1479 +#: ../../library/importlib.rst:1493 msgid "" "For deep customizations of import, you typically want to implement an :term:" "`importer`. This means managing both the :term:`finder` and :term:`loader` " @@ -1804,7 +1804,7 @@ msgid "" "for the appropriate classes defined within this package)::" msgstr "" -#: ../../library/importlib.rst:1490 +#: ../../library/importlib.rst:1504 msgid "" "import importlib.machinery\n" "import sys\n" @@ -1828,11 +1828,11 @@ msgid "" "sys.path_hooks.append(SpamPathEntryFinder.path_hook(loader_details))" msgstr "" -#: ../../library/importlib.rst:1511 +#: ../../library/importlib.rst:1525 msgid "Approximating :func:`importlib.import_module`" msgstr "" -#: ../../library/importlib.rst:1513 +#: ../../library/importlib.rst:1527 msgid "" "Import itself is implemented in Python code, making it possible to expose " "most of the import machinery through importlib. The following helps " @@ -1840,7 +1840,7 @@ msgid "" "approximate implementation of :func:`importlib.import_module`::" msgstr "" -#: ../../library/importlib.rst:1519 +#: ../../library/importlib.rst:1533 msgid "" "import importlib.util\n" "import sys\n" @@ -1873,14 +1873,47 @@ msgid "" " return module" msgstr "" -#: ../../library/importlib.rst:431 +#: ../../library/importlib.rst:438 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/importlib.rst:431 +#: ../../library/importlib.rst:438 msgid "importlib.abc.InspectLoader.get_source method" msgstr "importlib.abc.InspectLoader.get_source 方法" +#~ msgid ":attr:`module.__name__`" +#~ msgstr ":attr:`module.__name__`" + +#~ msgid ":attr:`module.__file__`" +#~ msgstr ":attr:`module.__file__`" + +#~ msgid ":attr:`module.__cached__` *(deprecated)*" +#~ msgstr ":attr:`module.__cached__` *(已棄用)*" + +#~ msgid ":attr:`module.__path__`" +#~ msgstr ":attr:`module.__path__`" + +#~ msgid ":attr:`module.__package__` *(deprecated)*" +#~ msgstr ":attr:`module.__package__` *(已棄用)*" + +#~ msgid ":attr:`module.__loader__` *(deprecated)*" +#~ msgstr ":attr:`module.__loader__` *(已棄用)*" + +#~ msgid "Implementation of :meth:`Loader.load_module`." +#~ msgstr ":meth:`Loader.load_module` 的實作。" + +#~ msgid "use :meth:`exec_module` instead." +#~ msgstr "請改用 :meth:`exec_module`。" + +#~ msgid "Use :meth:`Loader.exec_module` instead." +#~ msgstr "改用 :meth:`Loader.exec_module`。" + +#~ msgid "Concrete implementation of :meth:`Loader.load_module`." +#~ msgstr ":meth:`Loader.load_module` 的具體實作。" + +#~ msgid "Use :meth:`exec_module` instead." +#~ msgstr "改用 :meth:`exec_module`。" + #~ msgid "Read contents of ``self`` as bytes." #~ msgstr "以位元組讀取 ``self`` 的內容。" diff --git a/library/importlib.resources.po b/library/importlib.resources.po index aea4ecf7d75..b74d94dbee7 100644 --- a/library/importlib.resources.po +++ b/library/importlib.resources.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-06 15:51+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -104,14 +104,20 @@ msgstr "" #: ../../library/importlib.resources.rst:73 msgid "" -"*package* parameter was renamed to *anchor*. *anchor* can now be a non-" -"package module and if omitted will default to the caller's module. *package* " -"is still accepted for compatibility but will raise a :exc:" -"`DeprecationWarning`. Consider passing the anchor positionally or using " -"``importlib_resources >= 5.10`` for a compatible interface on older Pythons." +"*package* parameter was renamed to *anchor*. *package* was still accepted, " +"but deprecated." msgstr "" -#: ../../library/importlib.resources.rst:83 +#: ../../library/importlib.resources.rst:77 +msgid "" +"*package* parameter was fully removed. *anchor* can now be a non-package " +"module and if omitted will default to the caller's module. *package* is no " +"longer accepted since Python 3.15. Consider passing the anchor positionally " +"or using ``importlib_resources >= 5.10`` for a compatible interface on older " +"Pythons." +msgstr "" + +#: ../../library/importlib.resources.rst:86 msgid "" "Given a :class:`~importlib.resources.abc.Traversable` object representing a " "file or directory, typically from :func:`importlib.resources.files`, return " @@ -119,60 +125,60 @@ msgid "" "manager provides a :class:`pathlib.Path` object." msgstr "" -#: ../../library/importlib.resources.rst:88 +#: ../../library/importlib.resources.rst:91 msgid "" "Exiting the context manager cleans up any temporary file or directory " "created when the resource was extracted from e.g. a zip file." msgstr "" -#: ../../library/importlib.resources.rst:91 +#: ../../library/importlib.resources.rst:94 msgid "" "Use ``as_file`` when the Traversable methods (``read_text``, etc) are " "insufficient and an actual file or directory on the file system is required." msgstr "" -#: ../../library/importlib.resources.rst:97 +#: ../../library/importlib.resources.rst:100 msgid "Added support for *traversable* representing a directory." msgstr "" -#: ../../library/importlib.resources.rst:104 +#: ../../library/importlib.resources.rst:107 msgid "Functional API" msgstr "" -#: ../../library/importlib.resources.rst:106 +#: ../../library/importlib.resources.rst:109 msgid "" "A set of simplified, backwards-compatible helpers is available. These allow " "common operations in a single function call." msgstr "" -#: ../../library/importlib.resources.rst:109 +#: ../../library/importlib.resources.rst:112 msgid "For all the following functions:" msgstr "" -#: ../../library/importlib.resources.rst:111 +#: ../../library/importlib.resources.rst:114 msgid "" "*anchor* is an :class:`~importlib.resources.Anchor`, as in :func:`~importlib." "resources.files`. Unlike in ``files``, it may not be omitted." msgstr "" -#: ../../library/importlib.resources.rst:115 +#: ../../library/importlib.resources.rst:118 msgid "" "*path_names* are components of a resource's path name, relative to the " "anchor. For example, to get the text of resource named ``info.txt``, use::" msgstr "" -#: ../../library/importlib.resources.rst:119 +#: ../../library/importlib.resources.rst:122 msgid "importlib.resources.read_text(my_module, \"info.txt\")" msgstr "importlib.resources.read_text(my_module, \"info.txt\")" -#: ../../library/importlib.resources.rst:121 +#: ../../library/importlib.resources.rst:124 msgid "" "Like :meth:`Traversable.joinpath `, The " "individual components should use forward slashes (``/``) as path separators. " "For example, the following are equivalent::" msgstr "" -#: ../../library/importlib.resources.rst:126 +#: ../../library/importlib.resources.rst:129 msgid "" "importlib.resources.read_binary(my_module, \"pics/painting.png\")\n" "importlib.resources.read_binary(my_module, \"pics\", \"painting.png\")" @@ -180,14 +186,14 @@ msgstr "" "importlib.resources.read_binary(my_module, \"pics/painting.png\")\n" "importlib.resources.read_binary(my_module, \"pics\", \"painting.png\")" -#: ../../library/importlib.resources.rst:129 +#: ../../library/importlib.resources.rst:132 msgid "" "For backward compatibility reasons, functions that read text require an " "explicit *encoding* argument if multiple *path_names* are given. For " "example, to get the text of ``info/chapter1.txt``, use::" msgstr "" -#: ../../library/importlib.resources.rst:133 +#: ../../library/importlib.resources.rst:136 msgid "" "importlib.resources.read_text(my_module, \"info\", \"chapter1.txt\",\n" " encoding='utf-8')" @@ -195,124 +201,124 @@ msgstr "" "importlib.resources.read_text(my_module, \"info\", \"chapter1.txt\",\n" " encoding='utf-8')" -#: ../../library/importlib.resources.rst:138 +#: ../../library/importlib.resources.rst:141 msgid "Open the named resource for binary reading." msgstr "" -#: ../../library/importlib.resources.rst:140 -#: ../../library/importlib.resources.rst:183 -#: ../../library/importlib.resources.rst:231 -#: ../../library/importlib.resources.rst:247 -#: ../../library/importlib.resources.rst:265 +#: ../../library/importlib.resources.rst:143 +#: ../../library/importlib.resources.rst:186 +#: ../../library/importlib.resources.rst:234 +#: ../../library/importlib.resources.rst:250 +#: ../../library/importlib.resources.rst:268 msgid "" "See :ref:`the introduction ` for details on " "*anchor* and *path_names*." msgstr "" -#: ../../library/importlib.resources.rst:143 +#: ../../library/importlib.resources.rst:146 msgid "" "This function returns a :class:`~typing.BinaryIO` object, that is, a binary " "stream open for reading." msgstr "" -#: ../../library/importlib.resources.rst:146 -#: ../../library/importlib.resources.rst:170 -#: ../../library/importlib.resources.rst:186 -#: ../../library/importlib.resources.rst:207 -#: ../../library/importlib.resources.rst:234 -#: ../../library/importlib.resources.rst:250 -#: ../../library/importlib.resources.rst:268 +#: ../../library/importlib.resources.rst:149 +#: ../../library/importlib.resources.rst:173 +#: ../../library/importlib.resources.rst:189 +#: ../../library/importlib.resources.rst:210 +#: ../../library/importlib.resources.rst:237 +#: ../../library/importlib.resources.rst:253 +#: ../../library/importlib.resources.rst:271 msgid "This function is roughly equivalent to::" msgstr "這個函式大致等同於: ::" -#: ../../library/importlib.resources.rst:148 +#: ../../library/importlib.resources.rst:151 msgid "files(anchor).joinpath(*path_names).open('rb')" msgstr "files(anchor).joinpath(*path_names).open('rb')" -#: ../../library/importlib.resources.rst:150 -#: ../../library/importlib.resources.rst:190 -#: ../../library/importlib.resources.rst:238 -#: ../../library/importlib.resources.rst:254 +#: ../../library/importlib.resources.rst:153 +#: ../../library/importlib.resources.rst:193 +#: ../../library/importlib.resources.rst:241 +#: ../../library/importlib.resources.rst:257 msgid "Multiple *path_names* are accepted." msgstr "多個 *path_names* 是被接受的。" -#: ../../library/importlib.resources.rst:156 +#: ../../library/importlib.resources.rst:159 msgid "" "Open the named resource for text reading. By default, the contents are read " "as strict UTF-8." msgstr "" -#: ../../library/importlib.resources.rst:159 -#: ../../library/importlib.resources.rst:199 +#: ../../library/importlib.resources.rst:162 +#: ../../library/importlib.resources.rst:202 msgid "" "See :ref:`the introduction ` for details on " "*anchor* and *path_names*. *encoding* and *errors* have the same meaning as " "in built-in :func:`open`." msgstr "" -#: ../../library/importlib.resources.rst:163 -#: ../../library/importlib.resources.rst:203 +#: ../../library/importlib.resources.rst:166 +#: ../../library/importlib.resources.rst:206 msgid "" "For backward compatibility reasons, the *encoding* argument must be given " "explicitly if there are multiple *path_names*. This limitation is scheduled " "to be removed in Python 3.15." msgstr "" -#: ../../library/importlib.resources.rst:167 +#: ../../library/importlib.resources.rst:170 msgid "" "This function returns a :class:`~typing.TextIO` object, that is, a text " "stream open for reading." msgstr "" -#: ../../library/importlib.resources.rst:172 +#: ../../library/importlib.resources.rst:175 msgid "files(anchor).joinpath(*path_names).open('r', encoding=encoding)" msgstr "files(anchor).joinpath(*path_names).open('r', encoding=encoding)" -#: ../../library/importlib.resources.rst:174 -#: ../../library/importlib.resources.rst:211 +#: ../../library/importlib.resources.rst:177 +#: ../../library/importlib.resources.rst:214 msgid "" "Multiple *path_names* are accepted. *encoding* and *errors* must be given as " "keyword arguments." msgstr "" -#: ../../library/importlib.resources.rst:181 +#: ../../library/importlib.resources.rst:184 msgid "Read and return the contents of the named resource as :class:`bytes`." msgstr "以 :class:`bytes` 形式讀取並回傳指定資源的內容。" -#: ../../library/importlib.resources.rst:188 +#: ../../library/importlib.resources.rst:191 msgid "files(anchor).joinpath(*path_names).read_bytes()" msgstr "files(anchor).joinpath(*path_names).read_bytes()" -#: ../../library/importlib.resources.rst:196 +#: ../../library/importlib.resources.rst:199 msgid "" "Read and return the contents of the named resource as :class:`str`. By " "default, the contents are read as strict UTF-8." msgstr "" -#: ../../library/importlib.resources.rst:209 +#: ../../library/importlib.resources.rst:212 msgid "files(anchor).joinpath(*path_names).read_text(encoding=encoding)" msgstr "files(anchor).joinpath(*path_names).read_text(encoding=encoding)" -#: ../../library/importlib.resources.rst:218 +#: ../../library/importlib.resources.rst:221 msgid "" "Provides the path to the *resource* as an actual file system path. This " "function returns a context manager for use in a :keyword:`with` statement. " "The context manager provides a :class:`pathlib.Path` object." msgstr "" -#: ../../library/importlib.resources.rst:222 +#: ../../library/importlib.resources.rst:225 msgid "" "Exiting the context manager cleans up any temporary files created, e.g. when " "the resource needs to be extracted from a zip file." msgstr "" -#: ../../library/importlib.resources.rst:225 +#: ../../library/importlib.resources.rst:228 msgid "" "For example, the :meth:`~pathlib.Path.stat` method requires an actual file " "system path; it can be used like this::" msgstr "" -#: ../../library/importlib.resources.rst:228 +#: ../../library/importlib.resources.rst:231 msgid "" "with importlib.resources.path(anchor, \"resource.txt\") as fspath:\n" " result = fspath.stat()" @@ -320,21 +326,21 @@ msgstr "" "with importlib.resources.path(anchor, \"resource.txt\") as fspath:\n" " result = fspath.stat()" -#: ../../library/importlib.resources.rst:236 +#: ../../library/importlib.resources.rst:239 msgid "as_file(files(anchor).joinpath(*path_names))" msgstr "as_file(files(anchor).joinpath(*path_names))" -#: ../../library/importlib.resources.rst:244 +#: ../../library/importlib.resources.rst:247 msgid "" "Return ``True`` if the named resource exists, otherwise ``False``. This " "function does not consider directories to be resources." msgstr "" -#: ../../library/importlib.resources.rst:252 +#: ../../library/importlib.resources.rst:255 msgid "files(anchor).joinpath(*path_names).is_file()" msgstr "files(anchor).joinpath(*path_names).is_file()" -#: ../../library/importlib.resources.rst:260 +#: ../../library/importlib.resources.rst:263 msgid "" "Return an iterable over the named items within the package or path. The " "iterable returns names of resources (e.g. files) and non-resources (e.g. " @@ -342,7 +348,7 @@ msgid "" "subdirectories." msgstr "" -#: ../../library/importlib.resources.rst:270 +#: ../../library/importlib.resources.rst:273 msgid "" "for resource in files(anchor).joinpath(*path_names).iterdir():\n" " yield resource.name" @@ -350,7 +356,7 @@ msgstr "" "for resource in files(anchor).joinpath(*path_names).iterdir():\n" " yield resource.name" -#: ../../library/importlib.resources.rst:273 +#: ../../library/importlib.resources.rst:276 msgid "" "Prefer ``iterdir()`` as above, which offers more control over the results " "and richer functionality." diff --git a/library/inspect.po b/library/inspect.po index 9b5b131902c..b04967b8b7d 100644 --- a/library/inspect.po +++ b/library/inspect.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-04 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-10-16 06:59+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!inspect` --- Inspect live objects" msgstr ":mod:`!inspect` --- 檢視活動物件" -#: ../../library/inspect.rst:15 +#: ../../library/inspect.rst:12 msgid "**Source code:** :source:`Lib/inspect.py`" msgstr "**原始碼:**\\ :source:`Lib/inspect.py`" -#: ../../library/inspect.rst:19 +#: ../../library/inspect.rst:16 msgid "" "The :mod:`!inspect` module provides several useful functions to help get " "information about live objects such as modules, classes, methods, functions, " @@ -36,18 +36,18 @@ msgid "" "information you need to display a detailed traceback." msgstr "" -#: ../../library/inspect.rst:26 +#: ../../library/inspect.rst:23 msgid "" "There are four main kinds of services provided by this module: type " "checking, getting source code, inspecting classes and functions, and " "examining the interpreter stack." msgstr "" -#: ../../library/inspect.rst:34 +#: ../../library/inspect.rst:31 msgid "Types and members" msgstr "" -#: ../../library/inspect.rst:36 +#: ../../library/inspect.rst:33 msgid "" "The :func:`getmembers` function retrieves the members of an object such as a " "class or module. The functions whose names begin with \"is\" are mainly " @@ -57,629 +57,657 @@ msgid "" "attributes):" msgstr "" -#: ../../library/inspect.rst:46 +#: ../../library/inspect.rst:43 msgid "Type" msgstr "" -#: ../../library/inspect.rst:46 +#: ../../library/inspect.rst:43 msgid "Attribute" msgstr "屬性" -#: ../../library/inspect.rst:46 +#: ../../library/inspect.rst:43 msgid "Description" msgstr "描述" -#: ../../library/inspect.rst:48 +#: ../../library/inspect.rst:45 msgid "class" msgstr "" -#: ../../library/inspect.rst:48 ../../library/inspect.rst:63 -#: ../../library/inspect.rst:81 ../../library/inspect.rst:301 +#: ../../library/inspect.rst:45 ../../library/inspect.rst:60 +#: ../../library/inspect.rst:78 ../../library/inspect.rst:313 msgid "__doc__" msgstr "__doc__" -#: ../../library/inspect.rst:48 ../../library/inspect.rst:63 -#: ../../library/inspect.rst:81 ../../library/inspect.rst:301 +#: ../../library/inspect.rst:45 ../../library/inspect.rst:60 +#: ../../library/inspect.rst:78 ../../library/inspect.rst:313 msgid "documentation string" msgstr "" -#: ../../library/inspect.rst:50 ../../library/inspect.rst:65 -#: ../../library/inspect.rst:83 ../../library/inspect.rst:248 -#: ../../library/inspect.rst:265 ../../library/inspect.rst:281 -#: ../../library/inspect.rst:303 +#: ../../library/inspect.rst:47 ../../library/inspect.rst:62 +#: ../../library/inspect.rst:80 ../../library/inspect.rst:241 +#: ../../library/inspect.rst:264 ../../library/inspect.rst:287 +#: ../../library/inspect.rst:315 msgid "__name__" msgstr "__name__" -#: ../../library/inspect.rst:50 +#: ../../library/inspect.rst:47 msgid "name with which this class was defined" msgstr "" -#: ../../library/inspect.rst:53 ../../library/inspect.rst:68 -#: ../../library/inspect.rst:86 ../../library/inspect.rst:250 -#: ../../library/inspect.rst:267 ../../library/inspect.rst:283 -#: ../../library/inspect.rst:306 +#: ../../library/inspect.rst:50 ../../library/inspect.rst:65 +#: ../../library/inspect.rst:83 ../../library/inspect.rst:243 +#: ../../library/inspect.rst:266 ../../library/inspect.rst:289 +#: ../../library/inspect.rst:318 msgid "__qualname__" msgstr "__qualname__" -#: ../../library/inspect.rst:53 ../../library/inspect.rst:68 -#: ../../library/inspect.rst:86 ../../library/inspect.rst:250 -#: ../../library/inspect.rst:267 ../../library/inspect.rst:283 -#: ../../library/inspect.rst:306 +#: ../../library/inspect.rst:50 ../../library/inspect.rst:65 +#: ../../library/inspect.rst:83 ../../library/inspect.rst:243 +#: ../../library/inspect.rst:266 ../../library/inspect.rst:289 +#: ../../library/inspect.rst:318 msgid "qualified name" msgstr "" -#: ../../library/inspect.rst:55 ../../library/inspect.rst:78 -#: ../../library/inspect.rst:116 +#: ../../library/inspect.rst:52 ../../library/inspect.rst:75 +#: ../../library/inspect.rst:113 msgid "__module__" msgstr "__module__" -#: ../../library/inspect.rst:55 +#: ../../library/inspect.rst:52 msgid "name of module in which this class was defined" msgstr "" -#: ../../library/inspect.rst:58 ../../library/inspect.rst:111 +#: ../../library/inspect.rst:55 ../../library/inspect.rst:108 msgid "__type_params__" msgstr "__type_params__" -#: ../../library/inspect.rst:58 +#: ../../library/inspect.rst:55 msgid "" "A tuple containing the :ref:`type parameters ` of a generic " "class" msgstr "" -#: ../../library/inspect.rst:63 +#: ../../library/inspect.rst:60 msgid "method" msgstr "" -#: ../../library/inspect.rst:65 +#: ../../library/inspect.rst:62 msgid "name with which this method was defined" msgstr "" -#: ../../library/inspect.rst:70 +#: ../../library/inspect.rst:67 msgid "__func__" msgstr "__func__" -#: ../../library/inspect.rst:70 +#: ../../library/inspect.rst:67 msgid "function object containing implementation of method" msgstr "" -#: ../../library/inspect.rst:74 ../../library/inspect.rst:308 +#: ../../library/inspect.rst:71 ../../library/inspect.rst:320 msgid "__self__" msgstr "__self__" -#: ../../library/inspect.rst:74 +#: ../../library/inspect.rst:71 msgid "instance to which this method is bound, or ``None``" msgstr "" -#: ../../library/inspect.rst:78 +#: ../../library/inspect.rst:75 msgid "name of module in which this method was defined" msgstr "" -#: ../../library/inspect.rst:81 +#: ../../library/inspect.rst:78 msgid "function" msgstr "函式" -#: ../../library/inspect.rst:83 +#: ../../library/inspect.rst:80 msgid "name with which this function was defined" msgstr "" -#: ../../library/inspect.rst:88 +#: ../../library/inspect.rst:85 msgid "__code__" msgstr "__code__" -#: ../../library/inspect.rst:88 +#: ../../library/inspect.rst:85 msgid "code object containing compiled function :term:`bytecode`" msgstr "" -#: ../../library/inspect.rst:92 +#: ../../library/inspect.rst:89 msgid "__defaults__" msgstr "__defaults__" -#: ../../library/inspect.rst:92 +#: ../../library/inspect.rst:89 msgid "tuple of any default values for positional or keyword parameters" msgstr "" -#: ../../library/inspect.rst:96 +#: ../../library/inspect.rst:93 msgid "__kwdefaults__" msgstr "__kwdefaults__" -#: ../../library/inspect.rst:96 +#: ../../library/inspect.rst:93 msgid "mapping of any default values for keyword-only parameters" msgstr "" -#: ../../library/inspect.rst:100 +#: ../../library/inspect.rst:97 msgid "__globals__" msgstr "__globals__" -#: ../../library/inspect.rst:100 +#: ../../library/inspect.rst:97 msgid "global namespace in which this function was defined" msgstr "" -#: ../../library/inspect.rst:103 +#: ../../library/inspect.rst:100 msgid "__builtins__" msgstr "__builtins__" -#: ../../library/inspect.rst:103 +#: ../../library/inspect.rst:100 msgid "builtins namespace" msgstr "" -#: ../../library/inspect.rst:105 +#: ../../library/inspect.rst:102 msgid "__annotations__" msgstr "__annotations__" -#: ../../library/inspect.rst:105 +#: ../../library/inspect.rst:102 msgid "" "mapping of parameters names to annotations; ``\"return\"`` key is reserved " "for return annotations." msgstr "" -#: ../../library/inspect.rst:111 +#: ../../library/inspect.rst:108 msgid "" "A tuple containing the :ref:`type parameters ` of a generic " "function" msgstr "" -#: ../../library/inspect.rst:116 +#: ../../library/inspect.rst:113 msgid "name of module in which this function was defined" msgstr "" -#: ../../library/inspect.rst:119 +#: ../../library/inspect.rst:116 msgid "traceback" msgstr "traceback" -#: ../../library/inspect.rst:119 +#: ../../library/inspect.rst:116 msgid "tb_frame" msgstr "tb_frame" -#: ../../library/inspect.rst:119 +#: ../../library/inspect.rst:116 msgid "frame object at this level" msgstr "" -#: ../../library/inspect.rst:122 +#: ../../library/inspect.rst:119 msgid "tb_lasti" msgstr "tb_lasti" -#: ../../library/inspect.rst:122 ../../library/inspect.rst:144 +#: ../../library/inspect.rst:119 ../../library/inspect.rst:141 msgid "index of last attempted instruction in bytecode" msgstr "" -#: ../../library/inspect.rst:125 +#: ../../library/inspect.rst:122 msgid "tb_lineno" msgstr "tb_lineno" -#: ../../library/inspect.rst:125 ../../library/inspect.rst:147 +#: ../../library/inspect.rst:122 ../../library/inspect.rst:144 msgid "current line number in Python source code" msgstr "" -#: ../../library/inspect.rst:128 +#: ../../library/inspect.rst:125 msgid "tb_next" msgstr "tb_next" -#: ../../library/inspect.rst:128 +#: ../../library/inspect.rst:125 msgid "next inner traceback object (called by this level)" msgstr "" -#: ../../library/inspect.rst:132 ../../library/inspect.rst:252 -#: ../../library/inspect.rst:272 ../../library/inspect.rst:288 +#: ../../library/inspect.rst:129 ../../library/inspect.rst:245 +#: ../../library/inspect.rst:271 ../../library/inspect.rst:294 msgid "frame" msgstr "" -#: ../../library/inspect.rst:132 +#: ../../library/inspect.rst:129 msgid "f_back" msgstr "f_back" -#: ../../library/inspect.rst:132 +#: ../../library/inspect.rst:129 msgid "next outer frame object (this frame's caller)" msgstr "" -#: ../../library/inspect.rst:135 +#: ../../library/inspect.rst:132 msgid "f_builtins" msgstr "f_builtins" -#: ../../library/inspect.rst:135 +#: ../../library/inspect.rst:132 msgid "builtins namespace seen by this frame" msgstr "" -#: ../../library/inspect.rst:138 +#: ../../library/inspect.rst:135 msgid "f_code" msgstr "f_code" -#: ../../library/inspect.rst:138 +#: ../../library/inspect.rst:135 msgid "code object being executed in this frame" msgstr "" -#: ../../library/inspect.rst:141 +#: ../../library/inspect.rst:138 msgid "f_globals" msgstr "f_globals" -#: ../../library/inspect.rst:141 +#: ../../library/inspect.rst:138 msgid "global namespace seen by this frame" msgstr "" -#: ../../library/inspect.rst:144 +#: ../../library/inspect.rst:141 msgid "f_lasti" msgstr "f_lasti" -#: ../../library/inspect.rst:147 +#: ../../library/inspect.rst:144 msgid "f_lineno" msgstr "f_lineno" -#: ../../library/inspect.rst:150 +#: ../../library/inspect.rst:147 msgid "f_locals" msgstr "f_locals" -#: ../../library/inspect.rst:150 +#: ../../library/inspect.rst:147 msgid "local namespace seen by this frame" msgstr "" -#: ../../library/inspect.rst:153 +#: ../../library/inspect.rst:150 msgid "f_generator" msgstr "f_generator" -#: ../../library/inspect.rst:153 +#: ../../library/inspect.rst:150 msgid "" "returns the generator or coroutine object that owns this frame, or ``None`` " "if the frame is of a regular function" msgstr "" -#: ../../library/inspect.rst:159 +#: ../../library/inspect.rst:156 msgid "f_trace" msgstr "f_trace" -#: ../../library/inspect.rst:159 +#: ../../library/inspect.rst:156 msgid "tracing function for this frame, or ``None``" msgstr "" -#: ../../library/inspect.rst:162 +#: ../../library/inspect.rst:159 msgid "f_trace_lines" msgstr "f_trace_lines" -#: ../../library/inspect.rst:162 +#: ../../library/inspect.rst:159 msgid "" "indicate whether a tracing event is triggered for each source source line" msgstr "" -#: ../../library/inspect.rst:167 +#: ../../library/inspect.rst:164 msgid "f_trace_opcodes" msgstr "f_trace_opcodes" -#: ../../library/inspect.rst:167 +#: ../../library/inspect.rst:164 msgid "indicate whether per-opcode events are requested" msgstr "" -#: ../../library/inspect.rst:171 +#: ../../library/inspect.rst:168 msgid "clear()" msgstr "" -#: ../../library/inspect.rst:171 +#: ../../library/inspect.rst:168 msgid "used to clear all references to local variables" msgstr "" -#: ../../library/inspect.rst:175 ../../library/inspect.rst:259 -#: ../../library/inspect.rst:279 ../../library/inspect.rst:295 +#: ../../library/inspect.rst:172 ../../library/inspect.rst:252 +#: ../../library/inspect.rst:278 ../../library/inspect.rst:301 msgid "code" msgstr "code(程式碼)" -#: ../../library/inspect.rst:175 +#: ../../library/inspect.rst:172 msgid "co_argcount" msgstr "co_argcount" -#: ../../library/inspect.rst:175 +#: ../../library/inspect.rst:172 msgid "" "number of arguments (not including keyword only arguments, \\* or \\*\\* " "args)" msgstr "" -#: ../../library/inspect.rst:180 +#: ../../library/inspect.rst:177 msgid "co_code" msgstr "co_code" -#: ../../library/inspect.rst:180 +#: ../../library/inspect.rst:177 msgid "string of raw compiled bytecode" msgstr "" -#: ../../library/inspect.rst:183 +#: ../../library/inspect.rst:180 msgid "co_cellvars" msgstr "co_cellvars" -#: ../../library/inspect.rst:183 +#: ../../library/inspect.rst:180 msgid "tuple of names of cell variables (referenced by containing scopes)" msgstr "" -#: ../../library/inspect.rst:187 +#: ../../library/inspect.rst:184 msgid "co_consts" msgstr "co_consts" -#: ../../library/inspect.rst:187 +#: ../../library/inspect.rst:184 msgid "tuple of constants used in the bytecode" msgstr "" -#: ../../library/inspect.rst:190 +#: ../../library/inspect.rst:187 msgid "co_filename" msgstr "co_filename" -#: ../../library/inspect.rst:190 +#: ../../library/inspect.rst:187 msgid "name of file in which this code object was created" msgstr "" -#: ../../library/inspect.rst:194 +#: ../../library/inspect.rst:191 msgid "co_firstlineno" msgstr "co_firstlineno" -#: ../../library/inspect.rst:194 +#: ../../library/inspect.rst:191 msgid "number of first line in Python source code" msgstr "" -#: ../../library/inspect.rst:197 +#: ../../library/inspect.rst:194 msgid "co_flags" msgstr "co_flags" -#: ../../library/inspect.rst:197 +#: ../../library/inspect.rst:194 msgid "" "bitmap of ``CO_*`` flags, read more :ref:`here `" msgstr "" -#: ../../library/inspect.rst:201 -msgid "co_lnotab" -msgstr "co_lnotab" - -#: ../../library/inspect.rst:201 -msgid "encoded mapping of line numbers to bytecode indices" -msgstr "" - -#: ../../library/inspect.rst:205 +#: ../../library/inspect.rst:198 msgid "co_freevars" msgstr "co_freevars" -#: ../../library/inspect.rst:205 +#: ../../library/inspect.rst:198 msgid "tuple of names of free variables (referenced via a function's closure)" msgstr "" -#: ../../library/inspect.rst:209 +#: ../../library/inspect.rst:202 msgid "co_posonlyargcount" msgstr "co_posonlyargcount" -#: ../../library/inspect.rst:209 +#: ../../library/inspect.rst:202 msgid "number of positional only arguments" msgstr "" -#: ../../library/inspect.rst:212 +#: ../../library/inspect.rst:205 msgid "co_kwonlyargcount" msgstr "co_kwonlyargcount" -#: ../../library/inspect.rst:212 +#: ../../library/inspect.rst:205 msgid "number of keyword only arguments (not including \\*\\* arg)" msgstr "" -#: ../../library/inspect.rst:216 +#: ../../library/inspect.rst:209 msgid "co_name" msgstr "co_name" -#: ../../library/inspect.rst:216 +#: ../../library/inspect.rst:209 msgid "name with which this code object was defined" msgstr "" -#: ../../library/inspect.rst:219 +#: ../../library/inspect.rst:212 msgid "co_qualname" msgstr "co_qualname" -#: ../../library/inspect.rst:219 +#: ../../library/inspect.rst:212 msgid "fully qualified name with which this code object was defined" msgstr "" -#: ../../library/inspect.rst:223 +#: ../../library/inspect.rst:216 msgid "co_names" msgstr "co_names" -#: ../../library/inspect.rst:223 +#: ../../library/inspect.rst:216 msgid "tuple of names other than arguments and function locals" msgstr "" -#: ../../library/inspect.rst:227 +#: ../../library/inspect.rst:220 msgid "co_nlocals" msgstr "co_nlocals" -#: ../../library/inspect.rst:227 +#: ../../library/inspect.rst:220 msgid "number of local variables" msgstr "" -#: ../../library/inspect.rst:229 +#: ../../library/inspect.rst:222 msgid "co_stacksize" msgstr "co_stacksize" -#: ../../library/inspect.rst:229 +#: ../../library/inspect.rst:222 msgid "virtual machine stack space required" msgstr "" -#: ../../library/inspect.rst:232 +#: ../../library/inspect.rst:225 msgid "co_varnames" msgstr "co_varnames" -#: ../../library/inspect.rst:232 +#: ../../library/inspect.rst:225 msgid "tuple of names of arguments and local variables" msgstr "" -#: ../../library/inspect.rst:236 +#: ../../library/inspect.rst:229 msgid "co_lines()" msgstr "co_lines()" -#: ../../library/inspect.rst:236 +#: ../../library/inspect.rst:229 msgid "returns an iterator that yields successive bytecode ranges" msgstr "" -#: ../../library/inspect.rst:240 +#: ../../library/inspect.rst:233 msgid "co_positions()" msgstr "co_positions()" -#: ../../library/inspect.rst:240 +#: ../../library/inspect.rst:233 msgid "" "returns an iterator of source code positions for each bytecode instruction" msgstr "" -#: ../../library/inspect.rst:244 +#: ../../library/inspect.rst:237 msgid "replace()" msgstr "replace()" -#: ../../library/inspect.rst:244 +#: ../../library/inspect.rst:237 msgid "returns a copy of the code object with new values" msgstr "" -#: ../../library/inspect.rst:248 +#: ../../library/inspect.rst:241 msgid "generator" msgstr "" -#: ../../library/inspect.rst:248 ../../library/inspect.rst:265 -#: ../../library/inspect.rst:281 +#: ../../library/inspect.rst:241 ../../library/inspect.rst:264 +#: ../../library/inspect.rst:287 msgid "name" msgstr "" -#: ../../library/inspect.rst:252 +#: ../../library/inspect.rst:245 msgid "gi_frame" msgstr "gi_frame" -#: ../../library/inspect.rst:254 +#: ../../library/inspect.rst:247 msgid "gi_running" msgstr "gi_running" -#: ../../library/inspect.rst:254 ../../library/inspect.rst:274 +#: ../../library/inspect.rst:247 ../../library/inspect.rst:273 msgid "is the generator running?" msgstr "" -#: ../../library/inspect.rst:256 +#: ../../library/inspect.rst:249 msgid "gi_suspended" msgstr "gi_suspended" -#: ../../library/inspect.rst:256 ../../library/inspect.rst:276 +#: ../../library/inspect.rst:249 ../../library/inspect.rst:275 msgid "is the generator suspended?" msgstr "" -#: ../../library/inspect.rst:259 +#: ../../library/inspect.rst:252 msgid "gi_code" msgstr "gi_code" -#: ../../library/inspect.rst:261 +#: ../../library/inspect.rst:254 msgid "gi_yieldfrom" msgstr "gi_yieldfrom" -#: ../../library/inspect.rst:261 +#: ../../library/inspect.rst:254 msgid "object being iterated by ``yield from``, or ``None``" msgstr "" -#: ../../library/inspect.rst:265 +#: ../../library/inspect.rst:258 +msgid "gi_state" +msgstr "" + +#: ../../library/inspect.rst:258 +msgid "" +"state of the generator, one of ``GEN_CREATED``, ``GEN_RUNNING``, " +"``GEN_SUSPENDED``, or ``GEN_CLOSED``" +msgstr "" + +#: ../../library/inspect.rst:264 msgid "async generator" msgstr "" -#: ../../library/inspect.rst:269 +#: ../../library/inspect.rst:268 msgid "ag_await" msgstr "ag_await" -#: ../../library/inspect.rst:269 ../../library/inspect.rst:285 +#: ../../library/inspect.rst:268 ../../library/inspect.rst:291 msgid "object being awaited on, or ``None``" msgstr "" -#: ../../library/inspect.rst:272 +#: ../../library/inspect.rst:271 msgid "ag_frame" msgstr "ag_frame" -#: ../../library/inspect.rst:274 +#: ../../library/inspect.rst:273 msgid "ag_running" msgstr "ag_running" -#: ../../library/inspect.rst:276 +#: ../../library/inspect.rst:275 msgid "ag_suspended" msgstr "ag_suspended" -#: ../../library/inspect.rst:279 +#: ../../library/inspect.rst:278 msgid "ag_code" msgstr "ag_code" -#: ../../library/inspect.rst:281 +#: ../../library/inspect.rst:280 +msgid "ag_state" +msgstr "" + +#: ../../library/inspect.rst:280 +msgid "" +"state of the async generator, one of ``AGEN_CREATED``, ``AGEN_RUNNING``, " +"``AGEN_SUSPENDED``, or ``AGEN_CLOSED``" +msgstr "" + +#: ../../library/inspect.rst:287 msgid "coroutine" msgstr "coroutine" -#: ../../library/inspect.rst:285 +#: ../../library/inspect.rst:291 msgid "cr_await" msgstr "cr_await" -#: ../../library/inspect.rst:288 +#: ../../library/inspect.rst:294 msgid "cr_frame" msgstr "cr_frame" -#: ../../library/inspect.rst:290 +#: ../../library/inspect.rst:296 msgid "cr_running" msgstr "cr_running" -#: ../../library/inspect.rst:290 +#: ../../library/inspect.rst:296 msgid "is the coroutine running?" msgstr "" -#: ../../library/inspect.rst:292 +#: ../../library/inspect.rst:298 msgid "cr_suspended" msgstr "cr_suspended" -#: ../../library/inspect.rst:292 +#: ../../library/inspect.rst:298 msgid "is the coroutine suspended?" msgstr "" -#: ../../library/inspect.rst:295 +#: ../../library/inspect.rst:301 msgid "cr_code" msgstr "cr_code" -#: ../../library/inspect.rst:297 +#: ../../library/inspect.rst:303 msgid "cr_origin" msgstr "cr_origin" -#: ../../library/inspect.rst:297 +#: ../../library/inspect.rst:303 msgid "where coroutine was created, or ``None``. See |coroutine-origin-link|" msgstr "" -#: ../../library/inspect.rst:301 +#: ../../library/inspect.rst:307 +msgid "cr_state" +msgstr "cr_state" + +#: ../../library/inspect.rst:307 +msgid "" +"state of the coroutine, one of ``CORO_CREATED``, ``CORO_RUNNING``, " +"``CORO_SUSPENDED``, or ``CORO_CLOSED``" +msgstr "" + +#: ../../library/inspect.rst:313 msgid "builtin" msgstr "" -#: ../../library/inspect.rst:303 +#: ../../library/inspect.rst:315 msgid "original name of this function or method" msgstr "" -#: ../../library/inspect.rst:308 +#: ../../library/inspect.rst:320 msgid "instance to which a method is bound, or ``None``" msgstr "" -#: ../../library/inspect.rst:315 +#: ../../library/inspect.rst:327 msgid "Add ``__qualname__`` and ``gi_yieldfrom`` attributes to generators." msgstr "新增產生器的 ``__qualname__`` 和 ``gi_yieldfrom`` 屬性。" -#: ../../library/inspect.rst:317 +#: ../../library/inspect.rst:329 msgid "" "The ``__name__`` attribute of generators is now set from the function name, " "instead of the code name, and it can now be modified." msgstr "" -#: ../../library/inspect.rst:322 +#: ../../library/inspect.rst:334 msgid "Add ``cr_origin`` attribute to coroutines." msgstr "新增協程的 ``cr_origin`` 屬性。" -#: ../../library/inspect.rst:326 +#: ../../library/inspect.rst:338 msgid "Add ``__builtins__`` attribute to functions." msgstr "新增函式的 ``__builtins__`` 屬性。" -#: ../../library/inspect.rst:330 +#: ../../library/inspect.rst:342 msgid "Add ``gi_suspended`` attribute to generators." msgstr "新增產生器的 ``gi_suspended`` 屬性。" -#: ../../library/inspect.rst:334 +#: ../../library/inspect.rst:346 msgid "Add ``cr_suspended`` attribute to coroutines." msgstr "新增協程的 ``cr_suspended`` 屬性。" -#: ../../library/inspect.rst:338 +#: ../../library/inspect.rst:350 msgid "Add ``ag_suspended`` attribute to async generators." msgstr "新增非同步產生器的 ``ag_suspended`` 屬性。" -#: ../../library/inspect.rst:342 +#: ../../library/inspect.rst:354 msgid "Add ``f_generator`` attribute to frames." msgstr "新增 ``f_generator`` 屬性到 frame。" -#: ../../library/inspect.rst:346 +#: ../../library/inspect.rst:358 +msgid "" +"Add ``gi_state`` attribute to generators, ``cr_state`` attribute to " +"coroutines, and ``ag_state`` attribute to async generators." +msgstr "" + +#: ../../library/inspect.rst:363 msgid "" "Return all the members of an object in a list of ``(name, value)`` pairs " "sorted by name. If the optional *predicate* argument—which will be called " @@ -687,14 +715,14 @@ msgid "" "the predicate returns a true value are included." msgstr "" -#: ../../library/inspect.rst:353 +#: ../../library/inspect.rst:370 msgid "" ":func:`getmembers` will only return class attributes defined in the " "metaclass when the argument is a class and those attributes have been listed " "in the metaclass' custom :meth:`~object.__dir__`." msgstr "" -#: ../../library/inspect.rst:360 +#: ../../library/inspect.rst:377 msgid "" "Return all the members of an object in a list of ``(name, value)`` pairs " "sorted by name without triggering dynamic lookup via the descriptor " @@ -702,7 +730,7 @@ msgid "" "that satisfy a given predicate." msgstr "" -#: ../../library/inspect.rst:367 +#: ../../library/inspect.rst:384 msgid "" ":func:`getmembers_static` may not be able to retrieve all members that " "getmembers can fetch (like dynamically created attributes) and may find " @@ -711,7 +739,7 @@ msgid "" "cases." msgstr "" -#: ../../library/inspect.rst:378 +#: ../../library/inspect.rst:395 msgid "" "Return the name of the module named by the file *path*, without including " "the names of enclosing packages. The file extension is checked against all " @@ -720,56 +748,56 @@ msgid "" "``None`` is returned." msgstr "" -#: ../../library/inspect.rst:384 +#: ../../library/inspect.rst:401 msgid "" "Note that this function *only* returns a meaningful name for actual Python " "modules - paths that potentially refer to Python packages will still return " "``None``." msgstr "" -#: ../../library/inspect.rst:388 +#: ../../library/inspect.rst:405 msgid "The function is based directly on :mod:`importlib`." msgstr "此函式直接基於 :mod:`importlib`。" -#: ../../library/inspect.rst:394 +#: ../../library/inspect.rst:411 msgid "Return ``True`` if the object is a module." msgstr "如果物件是模組,則回傳 ``True``。" -#: ../../library/inspect.rst:399 +#: ../../library/inspect.rst:416 msgid "" "Return ``True`` if the object is a class, whether built-in or created in " "Python code." msgstr "" -#: ../../library/inspect.rst:402 +#: ../../library/inspect.rst:419 msgid "" "This function returns ``False`` for :ref:`generic aliases ` of classes, such as ``list[int]``." msgstr "" -#: ../../library/inspect.rst:408 +#: ../../library/inspect.rst:425 msgid "Return ``True`` if the object is a bound method written in Python." msgstr "" -#: ../../library/inspect.rst:412 +#: ../../library/inspect.rst:429 msgid "For example, given this class::" msgstr "" -#: ../../library/inspect.rst:414 +#: ../../library/inspect.rst:431 msgid "" ">>> class Greeter:\n" "... def say_hello(self):\n" "... print('hello!')" msgstr "" -#: ../../library/inspect.rst:418 +#: ../../library/inspect.rst:435 msgid "" "A bound method (also known as an *instance method*) is created when " "accessing ``say_hello`` (a :term:`function` defined in the ``Greeter`` " "namespace) through an instance of the ``Greeter`` class::" msgstr "" -#: ../../library/inspect.rst:422 +#: ../../library/inspect.rst:439 msgid "" ">>> instance = Greeter()\n" "\n" @@ -781,14 +809,14 @@ msgid "" "False" msgstr "" -#: ../../library/inspect.rst:431 +#: ../../library/inspect.rst:448 msgid "" "Accessing ``say_hello`` through the ``Greeter`` class will return the " "function itself. For this function, :func:`ismethod` will return ``False``, " "but :func:`isfunction` will return ``True``::" msgstr "" -#: ../../library/inspect.rst:435 +#: ../../library/inspect.rst:452 msgid "" ">>> Greeter.say_hello\n" "\n" @@ -798,57 +826,57 @@ msgid "" "True" msgstr "" -#: ../../library/inspect.rst:442 +#: ../../library/inspect.rst:459 msgid "See :ref:`typesmethods` for details." msgstr "" -#: ../../library/inspect.rst:447 +#: ../../library/inspect.rst:464 msgid "" "Return ``True`` if the object is a Python function, which includes functions " "created by a :term:`lambda` expression." msgstr "" -#: ../../library/inspect.rst:450 +#: ../../library/inspect.rst:467 msgid "See the note for :func:`~inspect.ismethod` for an example." msgstr "" -#: ../../library/inspect.rst:455 +#: ../../library/inspect.rst:472 msgid "Return ``True`` if the object is a :term:`package`." msgstr "如果物件是 :term:`package`,則回傳 ``True``。" -#: ../../library/inspect.rst:462 +#: ../../library/inspect.rst:479 msgid "Return ``True`` if the object is a Python generator function." msgstr "如果物件是 Python 產生器函式,則回傳 ``True``。" -#: ../../library/inspect.rst:464 +#: ../../library/inspect.rst:481 msgid "" "It also returns ``True`` for bound methods created from Python generator " "functions (see :ref:`typesmethods` for more information)." msgstr "" -#: ../../library/inspect.rst:467 +#: ../../library/inspect.rst:484 msgid "" "Functions wrapped in :func:`functools.partial` now return ``True`` if the " "wrapped function is a Python generator function." msgstr "" -#: ../../library/inspect.rst:471 +#: ../../library/inspect.rst:488 msgid "" ":term:`Duck-typed ` function-like objects now return ``True`` " "if their code object has the :data:`CO_GENERATOR` flag." msgstr "" -#: ../../library/inspect.rst:475 +#: ../../library/inspect.rst:492 msgid "" "Functions wrapped in :func:`functools.partialmethod` now return ``True`` if " "the wrapped function is a Python generator function." msgstr "" -#: ../../library/inspect.rst:481 +#: ../../library/inspect.rst:498 msgid "Return ``True`` if the object is a generator." msgstr "如果物件是產生器,則回傳 ``True``。" -#: ../../library/inspect.rst:486 +#: ../../library/inspect.rst:503 msgid "" "Return ``True`` if the object is a :term:`coroutine function` (a function " "defined with an :keyword:`async def` syntax), a :func:`functools.partial` " @@ -856,66 +884,66 @@ msgid "" "`markcoroutinefunction`." msgstr "" -#: ../../library/inspect.rst:493 +#: ../../library/inspect.rst:510 msgid "" "Functions wrapped in :func:`functools.partial` now return ``True`` if the " "wrapped function is a :term:`coroutine function`." msgstr "" -#: ../../library/inspect.rst:497 +#: ../../library/inspect.rst:514 msgid "" ":term:`Duck-typed ` function-like objects now return ``True`` " "if their code object has the :data:`CO_COROUTINE` flag." msgstr "" -#: ../../library/inspect.rst:501 +#: ../../library/inspect.rst:518 msgid "" "Sync functions marked with :func:`markcoroutinefunction` now return ``True``." msgstr "" -#: ../../library/inspect.rst:505 +#: ../../library/inspect.rst:522 msgid "" "Functions wrapped in :func:`functools.partialmethod` now return ``True`` if " "the wrapped function is a :term:`coroutine function`." msgstr "" -#: ../../library/inspect.rst:512 +#: ../../library/inspect.rst:529 msgid "" "Decorator to mark a callable as a :term:`coroutine function` if it would not " "otherwise be detected by :func:`iscoroutinefunction`." msgstr "" -#: ../../library/inspect.rst:515 +#: ../../library/inspect.rst:532 msgid "" "This may be of use for sync functions that return a :term:`coroutine`, if " "the function is passed to an API that requires :func:`iscoroutinefunction`." msgstr "" -#: ../../library/inspect.rst:518 +#: ../../library/inspect.rst:535 msgid "" "When possible, using an :keyword:`async def` function is preferred. Also " "acceptable is calling the function and testing the return with :func:" "`iscoroutine`." msgstr "" -#: ../../library/inspect.rst:527 +#: ../../library/inspect.rst:544 msgid "" "Return ``True`` if the object is a :term:`coroutine` created by an :keyword:" "`async def` function." msgstr "" -#: ../../library/inspect.rst:535 +#: ../../library/inspect.rst:552 msgid "" "Return ``True`` if the object can be used in :keyword:`await` expression." msgstr "" -#: ../../library/inspect.rst:537 +#: ../../library/inspect.rst:554 msgid "" "Can also be used to distinguish generator-based coroutines from regular " "generators:" msgstr "" -#: ../../library/inspect.rst:540 +#: ../../library/inspect.rst:557 msgid "" "import types\n" "\n" @@ -939,13 +967,13 @@ msgstr "" "assert not isawaitable(gen())\n" "assert isawaitable(gen_coro())" -#: ../../library/inspect.rst:558 +#: ../../library/inspect.rst:575 msgid "" "Return ``True`` if the object is an :term:`asynchronous generator` function, " "for example:" msgstr "" -#: ../../library/inspect.rst:561 +#: ../../library/inspect.rst:578 msgid "" ">>> async def agen():\n" "... yield 1\n" @@ -959,76 +987,76 @@ msgstr "" ">>> inspect.isasyncgenfunction(agen)\n" "True" -#: ../../library/inspect.rst:571 +#: ../../library/inspect.rst:588 msgid "" "Functions wrapped in :func:`functools.partial` now return ``True`` if the " "wrapped function is an :term:`asynchronous generator` function." msgstr "" -#: ../../library/inspect.rst:575 +#: ../../library/inspect.rst:592 msgid "" ":term:`Duck-typed ` function-like objects now return ``True`` " "if their code object has the :data:`CO_ASYNC_GENERATOR` flag." msgstr "" -#: ../../library/inspect.rst:579 +#: ../../library/inspect.rst:596 msgid "" "Functions wrapped in :func:`functools.partialmethod` now return ``True`` if " "the wrapped function is a :term:`asynchronous generator` function." msgstr "" -#: ../../library/inspect.rst:585 +#: ../../library/inspect.rst:602 msgid "" "Return ``True`` if the object is an :term:`asynchronous generator iterator` " "created by an :term:`asynchronous generator` function." msgstr "" -#: ../../library/inspect.rst:592 +#: ../../library/inspect.rst:609 msgid "Return ``True`` if the object is a traceback." msgstr "" -#: ../../library/inspect.rst:597 +#: ../../library/inspect.rst:614 msgid "Return ``True`` if the object is a frame." msgstr "" -#: ../../library/inspect.rst:602 +#: ../../library/inspect.rst:619 msgid "Return ``True`` if the object is a code." msgstr "如果物件是程式碼,則回傳 ``True``。" -#: ../../library/inspect.rst:607 +#: ../../library/inspect.rst:624 msgid "" "Return ``True`` if the object is a built-in function or a bound built-in " "method." msgstr "" -#: ../../library/inspect.rst:612 +#: ../../library/inspect.rst:629 msgid "" "Return ``True`` if the type of object is a :class:`~types.MethodWrapperType`." msgstr "" -#: ../../library/inspect.rst:614 +#: ../../library/inspect.rst:631 msgid "" "These are instances of :class:`~types.MethodWrapperType`, such as :meth:" "`~object.__str__`, :meth:`~object.__eq__` and :meth:`~object.__repr__`." msgstr "" -#: ../../library/inspect.rst:622 +#: ../../library/inspect.rst:639 msgid "" "Return ``True`` if the object is a user-defined or built-in function or " "method." msgstr "如果物件是使用者定義或內建的函式或方法,則回傳 ``True``。" -#: ../../library/inspect.rst:627 +#: ../../library/inspect.rst:644 msgid "Return ``True`` if the object is an abstract base class." msgstr "如果物件是抽象基底類別,則回傳 ``True``。" -#: ../../library/inspect.rst:632 +#: ../../library/inspect.rst:649 msgid "" "Return ``True`` if the object is a method descriptor, but not if :func:" "`isclass`, :func:`ismethod` or :func:`isfunction` is true." msgstr "" -#: ../../library/inspect.rst:635 +#: ../../library/inspect.rst:652 msgid "" "This, for example, is true of ``int.__add__``. An object passing this test " "has a :meth:`~object.__get__` method, but not a :meth:`~object.__set__` " @@ -1037,7 +1065,7 @@ msgid "" "sensible, and :attr:`~definition.__doc__` often is." msgstr "" -#: ../../library/inspect.rst:641 +#: ../../library/inspect.rst:658 msgid "" "Method descriptors that also pass any of the other tests (:func:`!isclass`, :" "func:`!ismethod` or :func:`!isfunction`) make this function return " @@ -1046,7 +1074,7 @@ msgid "" "object passes :func:`ismethod`." msgstr "" -#: ../../library/inspect.rst:647 +#: ../../library/inspect.rst:664 msgid "" "This function no longer incorrectly reports objects with :meth:`~object." "__get__` and :meth:`~object.__delete__`, but not :meth:`~object.__set__`, as " @@ -1054,20 +1082,20 @@ msgid "" "descriptors)." msgstr "" -#: ../../library/inspect.rst:655 +#: ../../library/inspect.rst:672 msgid "" "Return ``True`` if the object is a data descriptor, but not if :func:" "`isclass`, :func:`ismethod` or :func:`isfunction` is true." msgstr "" -#: ../../library/inspect.rst:658 +#: ../../library/inspect.rst:675 msgid "" "Data descriptors always have a :meth:`~object.__set__` method and/or a :meth:" "`~object.__delete__` method. Optionally, they may also have a :meth:" "`~object.__get__` method." msgstr "" -#: ../../library/inspect.rst:662 +#: ../../library/inspect.rst:679 msgid "" "Examples of data descriptors are :func:`properties `, getsets and " "member descriptors. Note that for the latter two (defined only in C " @@ -1075,14 +1103,14 @@ msgid "" "`isgetsetdescriptor` and :func:`ismemberdescriptor`, respectively." msgstr "" -#: ../../library/inspect.rst:667 +#: ../../library/inspect.rst:684 msgid "" "While data descriptors may also have :attr:`~definition.__name__` and :attr:" "`!__doc__` attributes (as properties, getsets and member descriptors do), " "this is not necessarily the case in general." msgstr "" -#: ../../library/inspect.rst:671 +#: ../../library/inspect.rst:688 msgid "" "This function now reports objects with only a :meth:`~object.__set__` method " "as being data descriptors (the presence of :meth:`~object.__get__` is no " @@ -1091,46 +1119,75 @@ msgid "" "data descriptors as well, which was not the case previously." msgstr "" -#: ../../library/inspect.rst:680 +#: ../../library/inspect.rst:697 msgid "Return ``True`` if the object is a getset descriptor." msgstr "如果物件是 getset 描述器,則回傳 ``True``。" -#: ../../library/inspect.rst:684 +#: ../../library/inspect.rst:701 msgid "" "getsets are attributes defined in extension modules via :c:type:" "`PyGetSetDef` structures. For Python implementations without such types, " "this method will always return ``False``." msgstr "" -#: ../../library/inspect.rst:691 +#: ../../library/inspect.rst:708 msgid "Return ``True`` if the object is a member descriptor." msgstr "如果物件是成員描述器,則回傳 ``True``。" -#: ../../library/inspect.rst:695 +#: ../../library/inspect.rst:712 msgid "" "Member descriptors are attributes defined in extension modules via :c:type:" "`PyMemberDef` structures. For Python implementations without such types, " "this method will always return ``False``." msgstr "" -#: ../../library/inspect.rst:703 +#: ../../library/inspect.rst:720 msgid "Retrieving source code" msgstr "取得原始碼" -#: ../../library/inspect.rst:707 +#: ../../library/inspect.rst:724 msgid "" "Get the documentation string for an object, cleaned up with :func:" -"`cleandoc`. If the documentation string for an object is not provided and " -"the object is a class, a method, a property or a descriptor, retrieve the " -"documentation string from the inheritance hierarchy. Return ``None`` if the " -"documentation string is invalid or missing." +"`cleandoc`. If the documentation string for an object is not provided:" +msgstr "" + +#: ../../library/inspect.rst:727 +msgid "" +"if the object is a class and *inherit_class_doc* is true (by default), " +"retrieve the documentation string from the inheritance hierarchy;" +msgstr "" + +#: ../../library/inspect.rst:729 +msgid "" +"if the object is a method, a property or a descriptor, retrieve the " +"documentation string from the inheritance hierarchy;" +msgstr "" + +#: ../../library/inspect.rst:731 +msgid "" +"otherwise, if *fallback_to_class_doc* is true (by default), retrieve the " +"documentation string from the class of the object." +msgstr "" + +#: ../../library/inspect.rst:734 +msgid "Return ``None`` if the documentation string is invalid or missing." msgstr "" -#: ../../library/inspect.rst:713 +#: ../../library/inspect.rst:736 msgid "Documentation strings are now inherited if not overridden." msgstr "" -#: ../../library/inspect.rst:719 +#: ../../library/inspect.rst:739 +msgid "Added parameters *inherit_class_doc* and *fallback_to_class_doc*." +msgstr "" + +#: ../../library/inspect.rst:742 +msgid "" +"Documentation strings on :class:`~functools.cached_property` objects are now " +"inherited if not overridden." +msgstr "" + +#: ../../library/inspect.rst:748 msgid "" "Return in a single string any lines of comments immediately preceding the " "object's source code (for a class, function, or method), or at the top of " @@ -1139,7 +1196,7 @@ msgid "" "been defined in C or the interactive shell." msgstr "" -#: ../../library/inspect.rst:728 +#: ../../library/inspect.rst:757 msgid "" "Return the name of the (text or binary) file in which an object was defined. " "An :exc:`OSError` is raised if the source code cannot be retrieved. This " @@ -1147,13 +1204,13 @@ msgid "" "or function." msgstr "" -#: ../../library/inspect.rst:736 +#: ../../library/inspect.rst:765 msgid "" "Try to guess which module an object was defined in. Return ``None`` if the " "module cannot be determined." msgstr "" -#: ../../library/inspect.rst:742 +#: ../../library/inspect.rst:771 msgid "" "Return the name of the Python source file in which an object was defined or " "``None`` if no way can be identified to get the source. An :exc:`OSError` " @@ -1161,7 +1218,7 @@ msgid "" "`TypeError` if the object is a built-in module, class, or function." msgstr "" -#: ../../library/inspect.rst:751 +#: ../../library/inspect.rst:780 msgid "" "Return a list of source lines and starting line number for an object. The " "argument may be a module, class, method, function, traceback, frame, or code " @@ -1172,13 +1229,13 @@ msgid "" "built-in module, class, or function." msgstr "" -#: ../../library/inspect.rst:760 ../../library/inspect.rst:774 +#: ../../library/inspect.rst:789 ../../library/inspect.rst:803 msgid "" ":exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the " "former." msgstr "" -#: ../../library/inspect.rst:767 +#: ../../library/inspect.rst:796 msgid "" "Return the text of the source code for an object. The argument may be a " "module, class, method, function, traceback, frame, or code object. The " @@ -1187,13 +1244,13 @@ msgid "" "object is a built-in module, class, or function." msgstr "" -#: ../../library/inspect.rst:781 +#: ../../library/inspect.rst:810 msgid "" "Clean up indentation from docstrings that are indented to line up with " "blocks of code." msgstr "" -#: ../../library/inspect.rst:784 +#: ../../library/inspect.rst:813 msgid "" "All leading whitespace is removed from the first line. Any leading " "whitespace that can be uniformly removed from the second line onwards is " @@ -1201,22 +1258,22 @@ msgid "" "Also, all tabs are expanded to spaces." msgstr "" -#: ../../library/inspect.rst:793 +#: ../../library/inspect.rst:822 msgid "Introspecting callables with the Signature object" msgstr "" -#: ../../library/inspect.rst:797 +#: ../../library/inspect.rst:826 msgid "" "The :class:`Signature` object represents the call signature of a callable " "object and its return annotation. To retrieve a :class:`!Signature` object, " "use the :func:`!signature` function." msgstr "" -#: ../../library/inspect.rst:804 +#: ../../library/inspect.rst:833 msgid "Return a :class:`Signature` object for the given *callable*:" msgstr "" -#: ../../library/inspect.rst:806 +#: ../../library/inspect.rst:835 msgid "" ">>> from inspect import signature\n" ">>> def foo(a, *, b:int, **kwargs):\n" @@ -1248,13 +1305,13 @@ msgstr "" ">>> sig.parameters['b'].annotation\n" "" -#: ../../library/inspect.rst:823 +#: ../../library/inspect.rst:852 msgid "" "Accepts a wide range of Python callables, from plain functions and classes " "to :func:`functools.partial` objects." msgstr "" -#: ../../library/inspect.rst:826 +#: ../../library/inspect.rst:855 msgid "" "If some of the annotations are strings (e.g., because ``from __future__ " "import annotations`` was used), :func:`signature` will attempt to " @@ -1269,7 +1326,7 @@ msgid "" "STRING`` to return annotations in string format." msgstr "" -#: ../../library/inspect.rst:840 +#: ../../library/inspect.rst:869 msgid "" "Raises :exc:`ValueError` if no signature can be provided, and :exc:" "`TypeError` if that type of object is not supported. Also, if the " @@ -1278,36 +1335,36 @@ msgid "" "get_annotations` could potentially raise any kind of exception." msgstr "" -#: ../../library/inspect.rst:846 +#: ../../library/inspect.rst:875 msgid "" "A slash (/) in the signature of a function denotes that the parameters prior " "to it are positional-only. For more info, see :ref:`the FAQ entry on " "positional-only parameters `." msgstr "" -#: ../../library/inspect.rst:850 +#: ../../library/inspect.rst:879 msgid "" "The *follow_wrapped* parameter was added. Pass ``False`` to get a signature " "of *callable* specifically (``callable.__wrapped__`` will not be used to " "unwrap decorated callables.)" msgstr "" -#: ../../library/inspect.rst:856 ../../library/inspect.rst:992 +#: ../../library/inspect.rst:885 ../../library/inspect.rst:1021 msgid "The *globals*, *locals*, and *eval_str* parameters were added." msgstr "" -#: ../../library/inspect.rst:859 +#: ../../library/inspect.rst:888 ../../library/inspect.rst:1314 msgid "The *annotation_format* parameter was added." msgstr "新增了 *annotation_format* 參數。" -#: ../../library/inspect.rst:864 +#: ../../library/inspect.rst:893 msgid "" "Some callables may not be introspectable in certain implementations of " "Python. For example, in CPython, some built-in functions defined in C " "provide no metadata about their arguments." msgstr "" -#: ../../library/inspect.rst:870 +#: ../../library/inspect.rst:899 msgid "" "If the passed object has a :attr:`!__signature__` attribute, we may use it " "to create the signature. The exact semantics are an implementation detail " @@ -1315,14 +1372,14 @@ msgid "" "semantics." msgstr "" -#: ../../library/inspect.rst:878 +#: ../../library/inspect.rst:907 msgid "" "A :class:`!Signature` object represents the call signature of a function and " "its return annotation. For each parameter accepted by the function it " "stores a :class:`Parameter` object in its :attr:`parameters` collection." msgstr "" -#: ../../library/inspect.rst:883 +#: ../../library/inspect.rst:912 msgid "" "The optional *parameters* argument is a sequence of :class:`Parameter` " "objects, which is validated to check that there are no parameters with " @@ -1331,54 +1388,54 @@ msgid "" "defaults follow parameters without defaults." msgstr "" -#: ../../library/inspect.rst:889 +#: ../../library/inspect.rst:918 msgid "" "The optional *return_annotation* argument can be an arbitrary Python object. " "It represents the \"return\" annotation of the callable." msgstr "" -#: ../../library/inspect.rst:892 +#: ../../library/inspect.rst:921 msgid "" ":class:`!Signature` objects are *immutable*. Use :meth:`Signature.replace` " "or :func:`copy.replace` to make a modified copy." msgstr "" -#: ../../library/inspect.rst:895 +#: ../../library/inspect.rst:924 msgid ":class:`!Signature` objects are now picklable and :term:`hashable`." msgstr "" -#: ../../library/inspect.rst:900 +#: ../../library/inspect.rst:929 msgid "A special class-level marker to specify absence of a return annotation." msgstr "" -#: ../../library/inspect.rst:904 +#: ../../library/inspect.rst:933 msgid "" "An ordered mapping of parameters' names to the corresponding :class:" "`Parameter` objects. Parameters appear in strict definition order, " "including keyword-only parameters." msgstr "" -#: ../../library/inspect.rst:908 ../../library/inspect.rst:1272 +#: ../../library/inspect.rst:937 ../../library/inspect.rst:1309 msgid "" "Python only explicitly guaranteed that it preserved the declaration order of " "keyword-only parameters as of version 3.7, although in practice this order " "had always been preserved in Python 3." msgstr "" -#: ../../library/inspect.rst:915 +#: ../../library/inspect.rst:944 msgid "" "The \"return\" annotation for the callable. If the callable has no " "\"return\" annotation, this attribute is set to :attr:`Signature.empty`." msgstr "" -#: ../../library/inspect.rst:920 +#: ../../library/inspect.rst:949 msgid "" "Create a mapping from positional and keyword arguments to parameters. " "Returns :class:`BoundArguments` if ``*args`` and ``**kwargs`` match the " "signature, or raises a :exc:`TypeError`." msgstr "" -#: ../../library/inspect.rst:926 +#: ../../library/inspect.rst:955 msgid "" "Works the same way as :meth:`Signature.bind`, but allows the omission of " "some required arguments (mimics :func:`functools.partial` behavior.) " @@ -1386,7 +1443,7 @@ msgid "" "arguments do not match the signature." msgstr "" -#: ../../library/inspect.rst:933 +#: ../../library/inspect.rst:962 msgid "" "Create a new :class:`Signature` instance based on the instance :meth:" "`replace` was invoked on. It is possible to pass different *parameters* and/" @@ -1395,7 +1452,7 @@ msgid "" "Signature`, pass in :attr:`Signature.empty`." msgstr "" -#: ../../library/inspect.rst:941 +#: ../../library/inspect.rst:970 msgid "" ">>> def test(a, b):\n" "... pass\n" @@ -1413,24 +1470,24 @@ msgstr "" ">>> str(new_sig)\n" "\"(a, b) -> 'new return anno'\"" -#: ../../library/inspect.rst:951 +#: ../../library/inspect.rst:980 msgid "" ":class:`Signature` objects are also supported by the generic function :func:" "`copy.replace`." msgstr "" -#: ../../library/inspect.rst:956 +#: ../../library/inspect.rst:985 msgid "Create a string representation of the :class:`Signature` object." msgstr "" -#: ../../library/inspect.rst:958 +#: ../../library/inspect.rst:987 msgid "" "If *max_width* is passed, the method will attempt to fit the signature into " "lines of at most *max_width* characters. If the signature is longer than " "*max_width*, all parameters will be on separate lines." msgstr "" -#: ../../library/inspect.rst:963 +#: ../../library/inspect.rst:992 msgid "" "If *quote_annotation_strings* is False, :term:`annotations ` in " "the signature are displayed without opening and closing quotation marks if " @@ -1439,21 +1496,21 @@ msgid "" "annotations`` was used." msgstr "" -#: ../../library/inspect.rst:971 +#: ../../library/inspect.rst:1000 msgid "The *unquote_annotations* parameter was added." msgstr "新增了 *unquote_annotations* 參數。" -#: ../../library/inspect.rst:976 +#: ../../library/inspect.rst:1005 msgid "" "Return a :class:`Signature` (or its subclass) object for a given callable " "*obj*." msgstr "" -#: ../../library/inspect.rst:979 +#: ../../library/inspect.rst:1008 msgid "This method simplifies subclassing of :class:`Signature`:" msgstr "此方法簡化了 :class:`Signature` 的子類別化:" -#: ../../library/inspect.rst:981 +#: ../../library/inspect.rst:1010 msgid "" "class MySignature(Signature):\n" " pass\n" @@ -1465,129 +1522,129 @@ msgstr "" "sig = MySignature.from_callable(sum)\n" "assert isinstance(sig, MySignature)" -#: ../../library/inspect.rst:988 +#: ../../library/inspect.rst:1017 msgid "Its behavior is otherwise identical to that of :func:`signature`." msgstr "" -#: ../../library/inspect.rst:998 +#: ../../library/inspect.rst:1027 msgid "" ":class:`!Parameter` objects are *immutable*. Instead of modifying a :class:`!" "Parameter` object, you can use :meth:`Parameter.replace` or :func:`copy." "replace` to create a modified copy." msgstr "" -#: ../../library/inspect.rst:1002 +#: ../../library/inspect.rst:1031 msgid "Parameter objects are now picklable and :term:`hashable`." msgstr "" -#: ../../library/inspect.rst:1007 +#: ../../library/inspect.rst:1036 msgid "" "A special class-level marker to specify absence of default values and " "annotations." msgstr "" -#: ../../library/inspect.rst:1012 +#: ../../library/inspect.rst:1041 msgid "" "The name of the parameter as a string. The name must be a valid Python " "identifier." msgstr "" -#: ../../library/inspect.rst:1017 +#: ../../library/inspect.rst:1046 msgid "" "CPython generates implicit parameter names of the form ``.0`` on the code " "objects used to implement comprehensions and generator expressions." msgstr "" -#: ../../library/inspect.rst:1021 +#: ../../library/inspect.rst:1050 msgid "" "These parameter names are now exposed by this module as names like " "``implicit0``." msgstr "" -#: ../../library/inspect.rst:1027 +#: ../../library/inspect.rst:1056 msgid "" "The default value for the parameter. If the parameter has no default value, " "this attribute is set to :attr:`Parameter.empty`." msgstr "" -#: ../../library/inspect.rst:1032 +#: ../../library/inspect.rst:1061 msgid "" "The annotation for the parameter. If the parameter has no annotation, this " "attribute is set to :attr:`Parameter.empty`." msgstr "" -#: ../../library/inspect.rst:1037 +#: ../../library/inspect.rst:1066 msgid "" "Describes how argument values are bound to the parameter. The possible " "values are accessible via :class:`Parameter` (like ``Parameter." "KEYWORD_ONLY``), and support comparison and ordering, in the following order:" msgstr "" -#: ../../library/inspect.rst:1044 +#: ../../library/inspect.rst:1073 msgid "Name" msgstr "名稱" -#: ../../library/inspect.rst:1044 +#: ../../library/inspect.rst:1073 msgid "Meaning" msgstr "意義" -#: ../../library/inspect.rst:1046 +#: ../../library/inspect.rst:1075 msgid "*POSITIONAL_ONLY*" msgstr "*POSITIONAL_ONLY*" -#: ../../library/inspect.rst:1046 +#: ../../library/inspect.rst:1075 msgid "" "Value must be supplied as a positional argument. Positional only parameters " "are those which appear before a ``/`` entry (if present) in a Python " "function definition." msgstr "" -#: ../../library/inspect.rst:1051 +#: ../../library/inspect.rst:1080 msgid "*POSITIONAL_OR_KEYWORD*" msgstr "*POSITIONAL_OR_KEYWORD*" -#: ../../library/inspect.rst:1051 +#: ../../library/inspect.rst:1080 msgid "" "Value may be supplied as either a keyword or positional argument (this is " "the standard binding behaviour for functions implemented in Python.)" msgstr "" -#: ../../library/inspect.rst:1056 +#: ../../library/inspect.rst:1085 msgid "*VAR_POSITIONAL*" msgstr "*VAR_POSITIONAL*" -#: ../../library/inspect.rst:1056 +#: ../../library/inspect.rst:1085 msgid "" "A tuple of positional arguments that aren't bound to any other parameter. " "This corresponds to a ``*args`` parameter in a Python function definition." msgstr "" -#: ../../library/inspect.rst:1061 +#: ../../library/inspect.rst:1090 msgid "*KEYWORD_ONLY*" msgstr "*KEYWORD_ONLY*" -#: ../../library/inspect.rst:1061 +#: ../../library/inspect.rst:1090 msgid "" "Value must be supplied as a keyword argument. Keyword only parameters are " "those which appear after a ``*`` or ``*args`` entry in a Python function " "definition." msgstr "" -#: ../../library/inspect.rst:1066 +#: ../../library/inspect.rst:1095 msgid "*VAR_KEYWORD*" msgstr "*VAR_KEYWORD*" -#: ../../library/inspect.rst:1066 +#: ../../library/inspect.rst:1095 msgid "" "A dict of keyword arguments that aren't bound to any other parameter. This " "corresponds to a ``**kwargs`` parameter in a Python function definition." msgstr "" -#: ../../library/inspect.rst:1072 +#: ../../library/inspect.rst:1101 msgid "Example: print all keyword-only arguments without default values:" msgstr "" -#: ../../library/inspect.rst:1074 +#: ../../library/inspect.rst:1103 msgid "" ">>> def foo(a, b, *, c, d=10):\n" "... pass\n" @@ -1609,15 +1666,15 @@ msgstr "" "... print('Parameter:', param)\n" "Parameter: c" -#: ../../library/inspect.rst:1088 +#: ../../library/inspect.rst:1117 msgid "Describes an enum value of :attr:`Parameter.kind`." msgstr "" -#: ../../library/inspect.rst:1092 +#: ../../library/inspect.rst:1121 msgid "Example: print all descriptions of arguments:" msgstr "範例:列印所有引數的描述:" -#: ../../library/inspect.rst:1094 +#: ../../library/inspect.rst:1123 msgid "" ">>> def foo(a, b, *, c, d=10):\n" "... pass\n" @@ -1641,7 +1698,7 @@ msgstr "" "keyword-only\n" "keyword-only" -#: ../../library/inspect.rst:1109 +#: ../../library/inspect.rst:1138 msgid "" "Create a new :class:`Parameter` instance based on the instance replaced was " "invoked on. To override a :class:`!Parameter` attribute, pass the " @@ -1649,7 +1706,7 @@ msgid "" "a :class:`!Parameter`, pass :attr:`Parameter.empty`." msgstr "" -#: ../../library/inspect.rst:1114 +#: ../../library/inspect.rst:1143 msgid "" ">>> from inspect import Parameter\n" ">>> param = Parameter('foo', Parameter.KEYWORD_ONLY, default=42)\n" @@ -1673,83 +1730,83 @@ msgstr "" ">>> str(param.replace(default=Parameter.empty, annotation='spam'))\n" "\"foo: 'spam'\"" -#: ../../library/inspect.rst:1127 +#: ../../library/inspect.rst:1156 msgid "" ":class:`Parameter` objects are also supported by the generic function :func:" "`copy.replace`." msgstr "" -#: ../../library/inspect.rst:1130 +#: ../../library/inspect.rst:1159 msgid "" "In Python 3.3 :class:`Parameter` objects were allowed to have ``name`` set " "to ``None`` if their ``kind`` was set to ``POSITIONAL_ONLY``. This is no " "longer permitted." msgstr "" -#: ../../library/inspect.rst:1137 +#: ../../library/inspect.rst:1166 msgid "" "Result of a :meth:`Signature.bind` or :meth:`Signature.bind_partial` call. " "Holds the mapping of arguments to the function's parameters." msgstr "" -#: ../../library/inspect.rst:1142 +#: ../../library/inspect.rst:1171 msgid "" "A mutable mapping of parameters' names to arguments' values. Contains only " "explicitly bound arguments. Changes in :attr:`arguments` will reflect in :" "attr:`args` and :attr:`kwargs`." msgstr "" -#: ../../library/inspect.rst:1146 +#: ../../library/inspect.rst:1175 msgid "" "Should be used in conjunction with :attr:`Signature.parameters` for any " "argument processing purposes." msgstr "" -#: ../../library/inspect.rst:1151 +#: ../../library/inspect.rst:1180 msgid "" "Arguments for which :meth:`Signature.bind` or :meth:`Signature.bind_partial` " "relied on a default value are skipped. However, if needed, use :meth:" "`BoundArguments.apply_defaults` to add them." msgstr "" -#: ../../library/inspect.rst:1156 +#: ../../library/inspect.rst:1185 msgid "" ":attr:`arguments` is now of type :class:`dict`. Formerly, it was of type :" "class:`collections.OrderedDict`." msgstr "" -#: ../../library/inspect.rst:1162 +#: ../../library/inspect.rst:1191 msgid "" "A tuple of positional arguments values. Dynamically computed from the :attr:" "`arguments` attribute." msgstr "" -#: ../../library/inspect.rst:1167 +#: ../../library/inspect.rst:1196 msgid "" "A dict of keyword arguments values. Dynamically computed from the :attr:" "`arguments` attribute. Arguments that can be passed positionally are " "included in :attr:`args` instead." msgstr "" -#: ../../library/inspect.rst:1173 +#: ../../library/inspect.rst:1202 msgid "A reference to the parent :class:`Signature` object." msgstr "" -#: ../../library/inspect.rst:1177 +#: ../../library/inspect.rst:1206 msgid "Set default values for missing arguments." msgstr "為遺漏的引數設定預設值。" -#: ../../library/inspect.rst:1179 +#: ../../library/inspect.rst:1208 msgid "" "For variable-positional arguments (``*args``) the default is an empty tuple." msgstr "" -#: ../../library/inspect.rst:1182 +#: ../../library/inspect.rst:1211 msgid "" "For variable-keyword arguments (``**kwargs``) the default is an empty dict." msgstr "" -#: ../../library/inspect.rst:1185 +#: ../../library/inspect.rst:1214 msgid "" ">>> def foo(a, b='ham', *args): pass\n" ">>> ba = inspect.signature(foo).bind('spam')\n" @@ -1763,13 +1820,13 @@ msgstr "" ">>> ba.arguments\n" "{'a': 'spam', 'b': 'ham', 'args': ()}" -#: ../../library/inspect.rst:1195 +#: ../../library/inspect.rst:1224 msgid "" "The :attr:`args` and :attr:`kwargs` properties can be used to invoke " "functions:" msgstr "" -#: ../../library/inspect.rst:1198 +#: ../../library/inspect.rst:1227 msgid "" "def test(a, *, b):\n" " ...\n" @@ -1785,19 +1842,19 @@ msgstr "" "ba = sig.bind(10, b=20)\n" "test(*ba.args, **ba.kwargs)" -#: ../../library/inspect.rst:1210 +#: ../../library/inspect.rst:1239 msgid ":pep:`362` - Function Signature Object." msgstr ":pep:`362` - 函式簽名物件。" -#: ../../library/inspect.rst:1211 +#: ../../library/inspect.rst:1240 msgid "The detailed specification, implementation details and examples." msgstr "詳細的規格、實作細節和範例。" -#: ../../library/inspect.rst:1217 +#: ../../library/inspect.rst:1246 msgid "Classes and functions" msgstr "類別與函式" -#: ../../library/inspect.rst:1221 +#: ../../library/inspect.rst:1250 msgid "" "Arrange the given list of classes into a hierarchy of nested lists. Where a " "nested list appears, it contains classes derived from the class whose entry " @@ -1808,13 +1865,13 @@ msgid "" "will appear multiple times." msgstr "" -#: ../../library/inspect.rst:1232 +#: ../../library/inspect.rst:1261 msgid "" "Get the names and default values of a Python function's parameters. A :term:" "`named tuple` is returned:" msgstr "" -#: ../../library/inspect.rst:1235 +#: ../../library/inspect.rst:1264 msgid "" "``FullArgSpec(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, " "annotations)``" @@ -1822,7 +1879,7 @@ msgstr "" "``FullArgSpec(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, " "annotations)``" -#: ../../library/inspect.rst:1238 +#: ../../library/inspect.rst:1267 msgid "" "*args* is a list of the positional parameter names. *varargs* is the name of " "the ``*`` parameter or ``None`` if arbitrary positional arguments are not " @@ -1837,7 +1894,7 @@ msgid "" "report the function return value annotation (if any)." msgstr "" -#: ../../library/inspect.rst:1253 +#: ../../library/inspect.rst:1282 msgid "" "Note that :func:`signature` and :ref:`Signature Object ` provide the recommended API for callable introspection, and support " @@ -1847,14 +1904,23 @@ msgid "" "``inspect`` module API." msgstr "" -#: ../../library/inspect.rst:1260 +#: ../../library/inspect.rst:1289 +msgid "" +"A member of the :class:`annotationlib.Format` enum can be passed to the " +"*annotation_format* parameter to control the format of the returned " +"annotations. For example, use ``annotation_format=annotationlib.Format." +"STRING`` to return annotations in string format. Note that with the default " +"``VALUE`` format, creation of some argspecs may raise an exception." +msgstr "" + +#: ../../library/inspect.rst:1297 msgid "" "This function is now based on :func:`signature`, but still ignores " "``__wrapped__`` attributes and includes the already bound first parameter in " "the signature output for bound methods." msgstr "" -#: ../../library/inspect.rst:1265 +#: ../../library/inspect.rst:1302 msgid "" "This method was previously documented as deprecated in favour of :func:" "`signature` in Python 3.5, but that decision has been reversed in order to " @@ -1862,7 +1928,7 @@ msgid "" "code migrating away from the legacy :func:`!getargspec` API." msgstr "" -#: ../../library/inspect.rst:1280 +#: ../../library/inspect.rst:1320 msgid "" "Get information about arguments passed into a particular frame. A :term:" "`named tuple` ``ArgInfo(args, varargs, keywords, locals)`` is returned. " @@ -1871,18 +1937,18 @@ msgid "" "dictionary of the given frame." msgstr "" -#: ../../library/inspect.rst:1287 ../../library/inspect.rst:1297 +#: ../../library/inspect.rst:1327 ../../library/inspect.rst:1337 msgid "This function was inadvertently marked as deprecated in Python 3.5." msgstr "" -#: ../../library/inspect.rst:1292 +#: ../../library/inspect.rst:1332 msgid "" "Format a pretty argument spec from the four values returned by :func:" "`getargvalues`. The format\\* arguments are the corresponding optional " "formatting functions that are called to turn names and values into strings." msgstr "" -#: ../../library/inspect.rst:1302 +#: ../../library/inspect.rst:1342 msgid "" "Return a tuple of class cls's base classes, including cls, in method " "resolution order. No class appears more than once in this tuple. Note that " @@ -1890,7 +1956,7 @@ msgid "" "user-defined metatype is in use, cls will be the first element of the tuple." msgstr "" -#: ../../library/inspect.rst:1310 +#: ../../library/inspect.rst:1350 msgid "" "Bind the *args* and *kwds* to the argument names of the Python function or " "method *func*, as if it was called with them. For bound methods, bind also " @@ -1903,7 +1969,7 @@ msgid "" "example:" msgstr "" -#: ../../library/inspect.rst:1319 +#: ../../library/inspect.rst:1359 msgid "" ">>> from inspect import getcallargs\n" ">>> def f(a, b=1, *pos, **named):\n" @@ -1933,11 +1999,11 @@ msgstr "" "...\n" "TypeError: f() missing 1 required positional argument: 'a'" -#: ../../library/inspect.rst:1336 +#: ../../library/inspect.rst:1376 msgid "Use :meth:`Signature.bind` and :meth:`Signature.bind_partial` instead." msgstr "請改用 :meth:`Signature.bind` 與 :meth:`Signature.bind_partial`。" -#: ../../library/inspect.rst:1342 +#: ../../library/inspect.rst:1382 msgid "" "Get the mapping of external name references in a Python function or method " "*func* to their current values. A :term:`named tuple` " @@ -1949,18 +2015,18 @@ msgid "" "builtins." msgstr "" -#: ../../library/inspect.rst:1351 +#: ../../library/inspect.rst:1391 msgid "" ":exc:`TypeError` is raised if *func* is not a Python function or method." msgstr "如果 *func* 不是 Python 函式或方法,則引發 :exc:`TypeError`。" -#: ../../library/inspect.rst:1358 +#: ../../library/inspect.rst:1398 msgid "" "Get the object wrapped by *func*. It follows the chain of :attr:" "`__wrapped__` attributes returning the last object in the chain." msgstr "" -#: ../../library/inspect.rst:1361 +#: ../../library/inspect.rst:1401 msgid "" "*stop* is an optional callback accepting an object in the wrapper chain as " "its sole argument that allows the unwrapping to be terminated early if the " @@ -1970,37 +2036,37 @@ msgid "" "``__signature__`` attribute defined." msgstr "" -#: ../../library/inspect.rst:1368 +#: ../../library/inspect.rst:1408 msgid ":exc:`ValueError` is raised if a cycle is encountered." msgstr "如果遇到循環,則引發 :exc:`ValueError`。" -#: ../../library/inspect.rst:1375 +#: ../../library/inspect.rst:1415 msgid "Compute the annotations dict for an object." msgstr "" -#: ../../library/inspect.rst:1377 +#: ../../library/inspect.rst:1417 msgid "" "This is an alias for :func:`annotationlib.get_annotations`; see the " "documentation of that function for more information." msgstr "" -#: ../../library/inspect.rst:1382 +#: ../../library/inspect.rst:1422 msgid "" "This function may execute arbitrary code contained in annotations. See :ref:" "`annotationlib-security` for more information." msgstr "" -#: ../../library/inspect.rst:1387 +#: ../../library/inspect.rst:1427 msgid "" "This function is now an alias for :func:`annotationlib.get_annotations`. " "Calling it as ``inspect.get_annotations`` will continue to work." msgstr "" -#: ../../library/inspect.rst:1395 +#: ../../library/inspect.rst:1435 msgid "The interpreter stack" msgstr "直譯器堆疊" -#: ../../library/inspect.rst:1397 +#: ../../library/inspect.rst:1437 msgid "" "Some of the following functions return :class:`FrameInfo` objects. For " "backwards compatibility these objects allow tuple-like operations on all " @@ -2008,95 +2074,95 @@ msgid "" "may be removed in the future." msgstr "" -#: ../../library/inspect.rst:1406 +#: ../../library/inspect.rst:1446 msgid "The :ref:`frame object ` that the record corresponds to." msgstr "" -#: ../../library/inspect.rst:1410 +#: ../../library/inspect.rst:1450 msgid "" "The file name associated with the code being executed by the frame this " "record corresponds to." msgstr "" -#: ../../library/inspect.rst:1415 +#: ../../library/inspect.rst:1455 msgid "" "The line number of the current line associated with the code being executed " "by the frame this record corresponds to." msgstr "" -#: ../../library/inspect.rst:1420 +#: ../../library/inspect.rst:1460 msgid "" "The function name that is being executed by the frame this record " "corresponds to." msgstr "" -#: ../../library/inspect.rst:1424 +#: ../../library/inspect.rst:1464 msgid "" "A list of lines of context from the source code that's being executed by the " "frame this record corresponds to." msgstr "" -#: ../../library/inspect.rst:1429 ../../library/inspect.rst:1468 +#: ../../library/inspect.rst:1469 ../../library/inspect.rst:1508 msgid "" "The index of the current line being executed in the :attr:`code_context` " "list." msgstr "" -#: ../../library/inspect.rst:1433 +#: ../../library/inspect.rst:1473 msgid "" "A :class:`dis.Positions` object containing the start line number, end line " "number, start column offset, and end column offset associated with the " "instruction being executed by the frame this record corresponds to." msgstr "" -#: ../../library/inspect.rst:1437 +#: ../../library/inspect.rst:1477 msgid "Return a :term:`named tuple` instead of a :class:`tuple`." msgstr "" -#: ../../library/inspect.rst:1440 +#: ../../library/inspect.rst:1480 msgid "" ":class:`!FrameInfo` is now a class instance (that is backwards compatible " "with the previous :term:`named tuple`)." msgstr "" -#: ../../library/inspect.rst:1449 +#: ../../library/inspect.rst:1489 msgid "" "The file name associated with the code being executed by the frame this " "traceback corresponds to." msgstr "" -#: ../../library/inspect.rst:1454 +#: ../../library/inspect.rst:1494 msgid "" "The line number of the current line associated with the code being executed " "by the frame this traceback corresponds to." msgstr "" -#: ../../library/inspect.rst:1459 +#: ../../library/inspect.rst:1499 msgid "" "The function name that is being executed by the frame this traceback " "corresponds to." msgstr "" -#: ../../library/inspect.rst:1463 +#: ../../library/inspect.rst:1503 msgid "" "A list of lines of context from the source code that's being executed by the " "frame this traceback corresponds to." msgstr "" -#: ../../library/inspect.rst:1472 +#: ../../library/inspect.rst:1512 msgid "" "A :class:`dis.Positions` object containing the start line number, end line " "number, start column offset, and end column offset associated with the " "instruction being executed by the frame this traceback corresponds to." msgstr "" -#: ../../library/inspect.rst:1477 +#: ../../library/inspect.rst:1517 msgid "" ":class:`!Traceback` is now a class instance (that is backwards compatible " "with the previous :term:`named tuple`)." msgstr "" -#: ../../library/inspect.rst:1484 +#: ../../library/inspect.rst:1524 msgid "" "Keeping references to frame objects, as found in the first element of the " "frame records these functions return, can cause your program to create " @@ -2108,7 +2174,7 @@ msgid "" "consumption which occurs." msgstr "" -#: ../../library/inspect.rst:1492 +#: ../../library/inspect.rst:1532 msgid "" "Though the cycle detector will catch these, destruction of the frames (and " "local variables) can be made deterministic by removing the cycle in a :" @@ -2116,7 +2182,7 @@ msgid "" "disabled when Python was compiled or using :func:`gc.disable`. For example::" msgstr "" -#: ../../library/inspect.rst:1497 +#: ../../library/inspect.rst:1537 msgid "" "def handle_stackframe_without_leak():\n" " frame = inspect.currentframe()\n" @@ -2126,31 +2192,31 @@ msgid "" " del frame" msgstr "" -#: ../../library/inspect.rst:1504 +#: ../../library/inspect.rst:1544 msgid "" "If you want to keep the frame around (for example to print a traceback " "later), you can also break reference cycles by using the :meth:`frame.clear` " "method." msgstr "" -#: ../../library/inspect.rst:1508 +#: ../../library/inspect.rst:1548 msgid "" "The optional *context* argument supported by most of these functions " "specifies the number of lines of context to return, which are centered " "around the current line." msgstr "" -#: ../../library/inspect.rst:1515 +#: ../../library/inspect.rst:1555 msgid "" "Get information about a frame or traceback object. A :class:`Traceback` " "object is returned." msgstr "" -#: ../../library/inspect.rst:1518 +#: ../../library/inspect.rst:1558 msgid "A :class:`Traceback` object is returned instead of a named tuple." msgstr "" -#: ../../library/inspect.rst:1523 +#: ../../library/inspect.rst:1563 msgid "" "Get a list of :class:`FrameInfo` objects for a frame and all outer frames. " "These frames represent the calls that lead to the creation of *frame*. The " @@ -2158,19 +2224,19 @@ msgid "" "represents the outermost call on *frame*'s stack." msgstr "" -#: ../../library/inspect.rst:1528 ../../library/inspect.rst:1543 -#: ../../library/inspect.rst:1569 ../../library/inspect.rst:1584 +#: ../../library/inspect.rst:1568 ../../library/inspect.rst:1583 +#: ../../library/inspect.rst:1609 ../../library/inspect.rst:1624 msgid "" "A list of :term:`named tuples ` ``FrameInfo(frame, filename, " "lineno, function, code_context, index)`` is returned." msgstr "" -#: ../../library/inspect.rst:1533 ../../library/inspect.rst:1548 -#: ../../library/inspect.rst:1574 ../../library/inspect.rst:1589 +#: ../../library/inspect.rst:1573 ../../library/inspect.rst:1588 +#: ../../library/inspect.rst:1614 ../../library/inspect.rst:1629 msgid "A list of :class:`FrameInfo` objects is returned." msgstr "回傳一個 :class:`FrameInfo` 物件串列。" -#: ../../library/inspect.rst:1538 +#: ../../library/inspect.rst:1578 msgid "" "Get a list of :class:`FrameInfo` objects for a traceback's frame and all " "inner frames. These frames represent calls made as a consequence of " @@ -2178,11 +2244,11 @@ msgid "" "represents where the exception was raised." msgstr "" -#: ../../library/inspect.rst:1553 +#: ../../library/inspect.rst:1593 msgid "Return the frame object for the caller's stack frame." msgstr "" -#: ../../library/inspect.rst:1557 +#: ../../library/inspect.rst:1597 msgid "" "This function relies on Python stack frame support in the interpreter, which " "isn't guaranteed to exist in all implementations of Python. If running in " @@ -2190,14 +2256,14 @@ msgid "" "``None``." msgstr "" -#: ../../library/inspect.rst:1565 +#: ../../library/inspect.rst:1605 msgid "" "Return a list of :class:`FrameInfo` objects for the caller's stack. The " "first entry in the returned list represents the caller; the last entry " "represents the outermost call on the stack." msgstr "" -#: ../../library/inspect.rst:1579 +#: ../../library/inspect.rst:1619 msgid "" "Return a list of :class:`FrameInfo` objects for the stack between the " "current frame and the frame in which an exception currently being handled " @@ -2205,11 +2271,11 @@ msgid "" "entry represents where the exception was raised." msgstr "" -#: ../../library/inspect.rst:1593 +#: ../../library/inspect.rst:1633 msgid "Fetching attributes statically" msgstr "" -#: ../../library/inspect.rst:1595 +#: ../../library/inspect.rst:1635 msgid "" "Both :func:`getattr` and :func:`hasattr` can trigger code execution when " "fetching or checking for the existence of attributes. Descriptors, like " @@ -2217,20 +2283,20 @@ msgid "" "`~object.__getattribute__` may be called." msgstr "" -#: ../../library/inspect.rst:1601 +#: ../../library/inspect.rst:1641 msgid "" "For cases where you want passive introspection, like documentation tools, " "this can be inconvenient. :func:`getattr_static` has a similar signature as :" "func:`getattr` but avoids executing code when it fetches attributes." msgstr "" -#: ../../library/inspect.rst:1608 +#: ../../library/inspect.rst:1648 msgid "" "Retrieve attributes without triggering dynamic lookup via the descriptor " "protocol, :meth:`~object.__getattr__` or :meth:`~object.__getattribute__`." msgstr "" -#: ../../library/inspect.rst:1612 +#: ../../library/inspect.rst:1652 msgid "" "Note: this function may not be able to retrieve all attributes that getattr " "can fetch (like dynamically created attributes) and may find attributes that " @@ -2238,27 +2304,27 @@ msgid "" "return descriptors objects instead of instance members." msgstr "" -#: ../../library/inspect.rst:1618 +#: ../../library/inspect.rst:1658 msgid "" "If the instance :attr:`~object.__dict__` is shadowed by another member (for " "example a property) then this function will be unable to find instance " "members." msgstr "" -#: ../../library/inspect.rst:1624 +#: ../../library/inspect.rst:1664 msgid "" ":func:`getattr_static` does not resolve descriptors, for example slot " "descriptors or getset descriptors on objects implemented in C. The " "descriptor object is returned instead of the underlying attribute." msgstr "" -#: ../../library/inspect.rst:1628 +#: ../../library/inspect.rst:1668 msgid "" "You can handle these with code like the following. Note that for arbitrary " "getset descriptors invoking these may trigger code execution::" msgstr "" -#: ../../library/inspect.rst:1632 +#: ../../library/inspect.rst:1672 msgid "" "# example code for resolving the builtin descriptor types\n" "class _foo:\n" @@ -2281,11 +2347,11 @@ msgid "" " pass" msgstr "" -#: ../../library/inspect.rst:1654 +#: ../../library/inspect.rst:1694 msgid "Current State of Generators, Coroutines, and Asynchronous Generators" msgstr "" -#: ../../library/inspect.rst:1656 +#: ../../library/inspect.rst:1696 msgid "" "When implementing coroutine schedulers and for other advanced uses of " "generators, it is useful to determine whether a generator is currently " @@ -2294,32 +2360,32 @@ msgid "" "generator to be determined easily." msgstr "" -#: ../../library/inspect.rst:1664 +#: ../../library/inspect.rst:1704 msgid "Get current state of a generator-iterator." msgstr "" -#: ../../library/inspect.rst:1666 ../../library/inspect.rst:1682 -#: ../../library/inspect.rst:1699 +#: ../../library/inspect.rst:1706 ../../library/inspect.rst:1722 +#: ../../library/inspect.rst:1739 msgid "Possible states are:" msgstr "" -#: ../../library/inspect.rst:1668 +#: ../../library/inspect.rst:1708 msgid "GEN_CREATED: Waiting to start execution." msgstr "GEN_CREATED:等待開始執行。" -#: ../../library/inspect.rst:1669 +#: ../../library/inspect.rst:1709 msgid "GEN_RUNNING: Currently being executed by the interpreter." msgstr "GEN_RUNNING:目前正在被直譯器執行。" -#: ../../library/inspect.rst:1670 +#: ../../library/inspect.rst:1710 msgid "GEN_SUSPENDED: Currently suspended at a yield expression." msgstr "" -#: ../../library/inspect.rst:1671 +#: ../../library/inspect.rst:1711 msgid "GEN_CLOSED: Execution has completed." msgstr "GEN_CLOSED:執行已完成。" -#: ../../library/inspect.rst:1677 +#: ../../library/inspect.rst:1717 msgid "" "Get current state of a coroutine object. The function is intended to be " "used with coroutine objects created by :keyword:`async def` functions, but " @@ -2327,23 +2393,23 @@ msgid "" "``cr_frame`` attributes." msgstr "" -#: ../../library/inspect.rst:1684 +#: ../../library/inspect.rst:1724 msgid "CORO_CREATED: Waiting to start execution." msgstr "CORO_CREATED:等待開始執行。" -#: ../../library/inspect.rst:1685 +#: ../../library/inspect.rst:1725 msgid "CORO_RUNNING: Currently being executed by the interpreter." msgstr "CORO_RUNNING:目前正在被直譯器執行。" -#: ../../library/inspect.rst:1686 +#: ../../library/inspect.rst:1726 msgid "CORO_SUSPENDED: Currently suspended at an await expression." msgstr "" -#: ../../library/inspect.rst:1687 +#: ../../library/inspect.rst:1727 msgid "CORO_CLOSED: Execution has completed." msgstr "CORO_CLOSED:執行已完成。" -#: ../../library/inspect.rst:1693 +#: ../../library/inspect.rst:1733 msgid "" "Get current state of an asynchronous generator object. The function is " "intended to be used with asynchronous iterator objects created by :keyword:" @@ -2352,30 +2418,30 @@ msgid "" "``ag_frame`` attributes." msgstr "" -#: ../../library/inspect.rst:1701 +#: ../../library/inspect.rst:1741 msgid "AGEN_CREATED: Waiting to start execution." msgstr "AGEN_CREATED: 等待開始執行。" -#: ../../library/inspect.rst:1702 +#: ../../library/inspect.rst:1742 msgid "AGEN_RUNNING: Currently being executed by the interpreter." msgstr "AGEN_RUNNING: 目前正在被直譯器執行。" -#: ../../library/inspect.rst:1703 +#: ../../library/inspect.rst:1743 msgid "AGEN_SUSPENDED: Currently suspended at a yield expression." msgstr "AGEN_SUSPENDED: 目前於 yield 運算式暫停。" -#: ../../library/inspect.rst:1704 +#: ../../library/inspect.rst:1744 msgid "AGEN_CLOSED: Execution has completed." msgstr "AGEN_CLOSED: 執行已完成。" -#: ../../library/inspect.rst:1708 +#: ../../library/inspect.rst:1748 msgid "" "The current internal state of the generator can also be queried. This is " "mostly useful for testing purposes, to ensure that internal state is being " "updated as expected:" msgstr "" -#: ../../library/inspect.rst:1714 +#: ../../library/inspect.rst:1754 msgid "" "Get the mapping of live local variables in *generator* to their current " "values. A dictionary is returned that maps from variable names to values. " @@ -2383,14 +2449,14 @@ msgid "" "generator, and all the same caveats apply." msgstr "" -#: ../../library/inspect.rst:1719 +#: ../../library/inspect.rst:1759 msgid "" "If *generator* is a :term:`generator` with no currently associated frame, " "then an empty dictionary is returned. :exc:`TypeError` is raised if " "*generator* is not a Python generator object." msgstr "" -#: ../../library/inspect.rst:1725 +#: ../../library/inspect.rst:1765 msgid "" "This function relies on the generator exposing a Python stack frame for " "introspection, which isn't guaranteed to be the case in all implementations " @@ -2398,90 +2464,90 @@ msgid "" "dictionary." msgstr "" -#: ../../library/inspect.rst:1734 +#: ../../library/inspect.rst:1774 msgid "" "This function is analogous to :func:`~inspect.getgeneratorlocals`, but works " "for coroutine objects created by :keyword:`async def` functions." msgstr "" -#: ../../library/inspect.rst:1741 +#: ../../library/inspect.rst:1781 msgid "" "This function is analogous to :func:`~inspect.getgeneratorlocals`, but works " "for asynchronous generator objects created by :keyword:`async def` functions " "which use the :keyword:`yield` statement." msgstr "" -#: ../../library/inspect.rst:1751 +#: ../../library/inspect.rst:1791 msgid "Code Objects Bit Flags" msgstr "" -#: ../../library/inspect.rst:1753 +#: ../../library/inspect.rst:1793 msgid "" "Python code objects have a :attr:`~codeobject.co_flags` attribute, which is " "a bitmap of the following flags:" msgstr "" -#: ../../library/inspect.rst:1758 +#: ../../library/inspect.rst:1798 msgid "The code object is optimized, using fast locals." msgstr "" -#: ../../library/inspect.rst:1762 +#: ../../library/inspect.rst:1802 msgid "" "If set, a new dict will be created for the frame's :attr:`~frame.f_locals` " "when the code object is executed." msgstr "" -#: ../../library/inspect.rst:1767 +#: ../../library/inspect.rst:1807 msgid "The code object has a variable positional parameter (``*args``-like)." msgstr "" -#: ../../library/inspect.rst:1771 +#: ../../library/inspect.rst:1811 msgid "The code object has a variable keyword parameter (``**kwargs``-like)." msgstr "" -#: ../../library/inspect.rst:1775 +#: ../../library/inspect.rst:1815 msgid "The flag is set when the code object is a nested function." msgstr "" -#: ../../library/inspect.rst:1779 +#: ../../library/inspect.rst:1819 msgid "" "The flag is set when the code object is a generator function, i.e. a " "generator object is returned when the code object is executed." msgstr "" -#: ../../library/inspect.rst:1784 +#: ../../library/inspect.rst:1824 msgid "" "The flag is set when the code object is a coroutine function. When the code " "object is executed it returns a coroutine object. See :pep:`492` for more " "details." msgstr "" -#: ../../library/inspect.rst:1792 +#: ../../library/inspect.rst:1832 msgid "" "The flag is used to transform generators into generator-based coroutines. " "Generator objects with this flag can be used in ``await`` expression, and " "can ``yield from`` coroutine objects. See :pep:`492` for more details." msgstr "" -#: ../../library/inspect.rst:1801 +#: ../../library/inspect.rst:1841 msgid "" "The flag is set when the code object is an asynchronous generator function. " "When the code object is executed it returns an asynchronous generator " "object. See :pep:`525` for more details." msgstr "" -#: ../../library/inspect.rst:1809 +#: ../../library/inspect.rst:1849 msgid "" "The flag is set when there is a docstring for the code object in the source " "code. If set, it will be the first item in :attr:`~codeobject.co_consts`." msgstr "" -#: ../../library/inspect.rst:1817 +#: ../../library/inspect.rst:1857 msgid "" "The flag is set when the code object is a function defined in class scope." msgstr "" -#: ../../library/inspect.rst:1823 +#: ../../library/inspect.rst:1863 msgid "" "The flags are specific to CPython, and may not be defined in other Python " "implementations. Furthermore, the flags are an implementation detail, and " @@ -2489,42 +2555,53 @@ msgid "" "use public APIs from the :mod:`!inspect` module for any introspection needs." msgstr "" -#: ../../library/inspect.rst:1831 +#: ../../library/inspect.rst:1871 msgid "Buffer flags" msgstr "" -#: ../../library/inspect.rst:1835 +#: ../../library/inspect.rst:1875 msgid "" "This is an :class:`enum.IntFlag` that represents the flags that can be " "passed to the :meth:`~object.__buffer__` method of objects implementing the :" "ref:`buffer protocol `." msgstr "" -#: ../../library/inspect.rst:1839 +#: ../../library/inspect.rst:1879 msgid "The meaning of the flags is explained at :ref:`buffer-request-types`." msgstr "" -#: ../../library/inspect.rst:1866 +#: ../../library/inspect.rst:1906 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/inspect.rst:1868 +#: ../../library/inspect.rst:1908 msgid "" "The :mod:`!inspect` module also provides a basic introspection capability " "from the command line." msgstr "" -#: ../../library/inspect.rst:1873 +#: ../../library/inspect.rst:1913 msgid "" "By default, accepts the name of a module and prints the source of that " "module. A class or function within the module can be printed instead by " -"appended a colon and the qualified name of the target object." +"appending a colon and the qualified name of the target object." msgstr "" -#: ../../library/inspect.rst:1879 +#: ../../library/inspect.rst:1919 msgid "" "Print information about the specified object rather than the source code" msgstr "" +#: ../../library/inspect.rst:1923 +msgid "" +"The ``--details`` option now supports basic introspection for modules " +"without available source code and indicates when modules are frozen. It also " +"indicates when the given target reference is not the canonical name of the " +"referenced object." +msgstr "" + +#~ msgid "co_lnotab" +#~ msgstr "co_lnotab" + #~ msgid "Return ``True`` if the object is a data descriptor." #~ msgstr "如果物件是資料描述器,則回傳 ``True``。" diff --git a/library/io.po b/library/io.po index 67477a7f2f2..1a4d937b9e5 100644 --- a/library/io.po +++ b/library/io.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-05 12:14+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-12-08 00:08+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,15 +22,15 @@ msgstr "" msgid ":mod:`!io` --- Core tools for working with streams" msgstr ":mod:`!io` — 處理資料串流的核心工具" -#: ../../library/io.rst:15 +#: ../../library/io.rst:7 msgid "**Source code:** :source:`Lib/io.py`" msgstr "**原始碼:**\\ :source:`Lib/io.py`" -#: ../../library/io.rst:22 +#: ../../library/io.rst:14 msgid "Overview" msgstr "總覽" -#: ../../library/io.rst:27 +#: ../../library/io.rst:19 msgid "" "The :mod:`!io` module provides Python's main facilities for dealing with " "various types of I/O. There are three main types of I/O: *text I/O*, " @@ -45,7 +45,7 @@ msgstr "" "(backing store)。任一種屬於這些類型的具體物件稱為 :term:`file object`。其它常" "見的名詞還有\\ *資料串流 (stream)* 以及\\ *類檔案物件 (file-like objects)*。" -#: ../../library/io.rst:34 +#: ../../library/io.rst:26 msgid "" "Independent of its category, each concrete stream object will also have " "various capabilities: it can be read-only, write-only, or read-write. It can " @@ -57,7 +57,7 @@ msgstr "" "的、或者讀寫兼具的。它還允許任意的隨機存取(向前或向後尋找至任意位置),或者" "只能依順序存取(例如 socket 或 pipe 的情形下)。" -#: ../../library/io.rst:40 +#: ../../library/io.rst:32 msgid "" "All streams are careful about the type of data you give to them. For " "example giving a :class:`str` object to the :meth:`!write` method of a " @@ -69,7 +69,7 @@ msgstr "" "樣地,若提供一個 :class:`bytes` 物件給文字資料串流的 :meth:`!write` 方法,也" "會引發同樣的錯誤。" -#: ../../library/io.rst:45 +#: ../../library/io.rst:37 msgid "" "Operations that used to raise :exc:`IOError` now raise :exc:`OSError`, " "since :exc:`IOError` is now an alias of :exc:`OSError`." @@ -77,11 +77,11 @@ msgstr "" "原本會引發 :exc:`IOError` 的操作,現在將改成引發 :exc:`OSError`。因為 :exc:" "`IOError` 現在是 :exc:`OSError` 的別名。" -#: ../../library/io.rst:52 ../../library/io.rst:899 ../../library/io.rst:1249 +#: ../../library/io.rst:44 ../../library/io.rst:881 ../../library/io.rst:1231 msgid "Text I/O" msgstr "文字 I/O" -#: ../../library/io.rst:54 +#: ../../library/io.rst:46 msgid "" "Text I/O expects and produces :class:`str` objects. This means that " "whenever the backing store is natively made of bytes (such as in the case of " @@ -92,44 +92,44 @@ msgstr "" "(例如在檔案的情形下),資料的編碼與解碼會以清楚易懂的方式進行,也可選擇同時" "轉換特定於平台的換行字元。" -#: ../../library/io.rst:59 +#: ../../library/io.rst:51 msgid "" "The easiest way to create a text stream is with :meth:`open`, optionally " "specifying an encoding::" msgstr "" "建立文字資料串流最簡單的方法是使用 :meth:`open`,可選擇性地指定編碼: ::" -#: ../../library/io.rst:62 +#: ../../library/io.rst:54 msgid "f = open(\"myfile.txt\", \"r\", encoding=\"utf-8\")" msgstr "f = open(\"myfile.txt\", \"r\", encoding=\"utf-8\")" -#: ../../library/io.rst:64 +#: ../../library/io.rst:56 msgid "" "In-memory text streams are also available as :class:`StringIO` objects::" msgstr "記憶體內的文字資料串流也可以使用 :class:`StringIO` 物件建立: ::" -#: ../../library/io.rst:66 +#: ../../library/io.rst:58 msgid "f = io.StringIO(\"some initial text data\")" msgstr "f = io.StringIO(\"some initial text data\")" -#: ../../library/io.rst:70 +#: ../../library/io.rst:62 msgid "" "When working with a non-blocking stream, be aware that read operations on " "text I/O objects might raise a :exc:`BlockingIOError` if the stream cannot " "perform the operation immediately." msgstr "" -#: ../../library/io.rst:74 +#: ../../library/io.rst:66 msgid "" "The text stream API is described in detail in the documentation of :class:" "`TextIOBase`." msgstr "文字資料串流 API 的詳細說明在 :class:`TextIOBase` 文件當中。" -#: ../../library/io.rst:80 ../../library/io.rst:1237 +#: ../../library/io.rst:72 ../../library/io.rst:1219 msgid "Binary I/O" msgstr "二進位 (Binary) I/O" -#: ../../library/io.rst:82 +#: ../../library/io.rst:74 msgid "" "Binary I/O (also called *buffered I/O*) expects :term:`bytes-like objects " "` and produces :class:`bytes` objects. No encoding, " @@ -142,7 +142,7 @@ msgstr "" "行編碼、解碼或者換行字元轉換。這種類型的資料串流可用於各種非文字資料,以及需" "要手動控制對文字資料的處理時。" -#: ../../library/io.rst:88 +#: ../../library/io.rst:80 msgid "" "The easiest way to create a binary stream is with :meth:`open` with ``'b'`` " "in the mode string::" @@ -150,26 +150,26 @@ msgstr "" "建立二進位資料串流最簡單的方法是使用 :meth:`open`,並在 mode 字串中加入 " "``'b'``: ::" -#: ../../library/io.rst:91 +#: ../../library/io.rst:83 msgid "f = open(\"myfile.jpg\", \"rb\")" msgstr "f = open(\"myfile.jpg\", \"rb\")" -#: ../../library/io.rst:93 +#: ../../library/io.rst:85 msgid "" "In-memory binary streams are also available as :class:`BytesIO` objects::" msgstr "記憶體內的二進位資料串流也可以透過 :class:`BytesIO` 物件來建立: ::" -#: ../../library/io.rst:95 +#: ../../library/io.rst:87 msgid "f = io.BytesIO(b\"some initial binary data: \\x00\\x01\")" msgstr "f = io.BytesIO(b\"some initial binary data: \\x00\\x01\")" -#: ../../library/io.rst:97 +#: ../../library/io.rst:89 msgid "" "The binary stream API is described in detail in the docs of :class:" "`BufferedIOBase`." msgstr "二進位資料串流 API 的詳細說明在 :class:`BufferedIOBase` 文件當中。" -#: ../../library/io.rst:100 +#: ../../library/io.rst:92 msgid "" "Other library modules may provide additional ways to create text or binary " "streams. See :meth:`socket.socket.makefile` for example." @@ -177,11 +177,11 @@ msgstr "" "其它函式庫模組可能提供額外的方法來建立文字或二進位資料串流。例如 :meth:" "`socket.socket.makefile`。" -#: ../../library/io.rst:105 +#: ../../library/io.rst:97 msgid "Raw I/O" msgstr "原始 (Raw) I/O" -#: ../../library/io.rst:107 +#: ../../library/io.rst:99 msgid "" "Raw I/O (also called *unbuffered I/O*) is generally used as a low-level " "building-block for binary and text streams; it is rarely useful to directly " @@ -193,16 +193,16 @@ msgstr "" "用。然而,你可以透過以無緩衝的二進位模式開啟一個檔案來建立一個原始資料串" "流: ::" -#: ../../library/io.rst:112 +#: ../../library/io.rst:104 msgid "f = open(\"myfile.jpg\", \"rb\", buffering=0)" msgstr "f = open(\"myfile.jpg\", \"rb\", buffering=0)" -#: ../../library/io.rst:114 +#: ../../library/io.rst:106 msgid "" "The raw stream API is described in detail in the docs of :class:`RawIOBase`." msgstr "原始串流 API 在 :class:`RawIOBase` 文件中有詳細描述。" -#: ../../library/io.rst:117 +#: ../../library/io.rst:109 msgid "" "Raw I/O is a low-level interface and methods generally must have their " "return values checked and be explicitly retried to ensure an operation " @@ -212,86 +212,57 @@ msgid "" "implement retry behavior." msgstr "" -#: ../../library/io.rst:127 -msgid "Text Encoding" +#: ../../library/io.rst:119 +msgid "Text encoding" msgstr "文字編碼" -#: ../../library/io.rst:129 +#: ../../library/io.rst:121 msgid "" -"The default encoding of :class:`TextIOWrapper` and :func:`open` is locale-" -"specific (:func:`locale.getencoding`)." +"The default encoding of :class:`TextIOWrapper` and :func:`open` is UTF-8. " +"If :ref:`Python UTF-8 Mode ` is disabled, the default encoding is " +"locale-specific (:func:`locale.getencoding`)." msgstr "" -":class:`TextIOWrapper` 和 :func:`open` 預設編碼是根據區域設定的 (locale-" +":class:`TextIOWrapper` 和 :func:`open` 預設編碼是 UTF-8。如果停用" +"了 :ref:`Python UTF-8 模式 `,則預設編碼是根據區域設定的 (locale-" "specific) (:func:`locale.getencoding`)。" -#: ../../library/io.rst:132 -msgid "" -"However, many developers forget to specify the encoding when opening text " -"files encoded in UTF-8 (e.g. JSON, TOML, Markdown, etc...) since most Unix " -"platforms use UTF-8 locale by default. This causes bugs because the locale " -"encoding is not UTF-8 for most Windows users. For example::" -msgstr "" -"然而,許多開發人員在開啟以 UTF-8 編碼的文字檔案(例如:JSON、TOML、Markdown" -"等)時忘記指定編碼,因為多數 Unix 平台預設使用 UTF-8 區域設定。這會導致錯誤," -"因為對於大多數 Windows 使用者來說,預設地區編碼並非 UTF-8。舉例來說:" - -#: ../../library/io.rst:137 -msgid "" -"# May not work on Windows when non-ASCII characters in the file.\n" -"with open(\"README.md\") as f:\n" -" long_description = f.read()" -msgstr "" - -#: ../../library/io.rst:141 -msgid "" -"Accordingly, it is highly recommended that you specify the encoding " -"explicitly when opening text files. If you want to use UTF-8, pass " -"``encoding=\"utf-8\"``. To use the current locale encoding, " -"``encoding=\"locale\"`` is supported since Python 3.10." -msgstr "" -"因此,強烈建議在開啟文字檔案時,明確指定編碼。若你想使用 UTF-8 編碼,請傳入 " -"``encoding=\"utf-8\"``。若想使用目前的地區編碼,Python 3.10 以後的版本支援使" -"用 ``encoding=\"locale\"``。" - -#: ../../library/io.rst:148 +#: ../../library/io.rst:127 msgid ":ref:`utf8-mode`" msgstr ":ref:`utf8-mode`" -#: ../../library/io.rst:149 +#: ../../library/io.rst:128 msgid "" -"Python UTF-8 Mode can be used to change the default encoding to UTF-8 from " -"locale-specific encoding." -msgstr "在 Python UTF-8 模式下,可以將預設編碼從特定地區編碼改為 UTF-8。" +"Python UTF-8 Mode ignores the locale encoding and forces the use of UTF-8." +msgstr "" -#: ../../library/io.rst:152 +#: ../../library/io.rst:131 msgid ":pep:`686`" msgstr ":pep:`686`" -#: ../../library/io.rst:153 -msgid "Python 3.15 will make :ref:`utf8-mode` default." -msgstr "Python 3.15 將預設使用 :ref:`utf8-mode`。" +#: ../../library/io.rst:132 +msgid "Python 3.15 made :ref:`utf8-mode` the default." +msgstr "Python 3.15 已將 :ref:`utf8-mode` 設為預設。" -#: ../../library/io.rst:158 +#: ../../library/io.rst:137 msgid "Opt-in EncodingWarning" msgstr "選擇性加入的編碼警告" -#: ../../library/io.rst:160 +#: ../../library/io.rst:139 msgid "See :pep:`597` for more details." msgstr "更多資訊請見 :pep:`597`。" -#: ../../library/io.rst:163 +#: ../../library/io.rst:142 msgid "" -"To find where the default locale encoding is used, you can enable the :" -"option:`-X warn_default_encoding <-X>` command line option or set the :" -"envvar:`PYTHONWARNDEFAULTENCODING` environment variable, which will emit an :" -"exc:`EncodingWarning` when the default encoding is used." +"To find where the default encoding is used, you can enable the :option:`-X " +"warn_default_encoding <-X>` command line option or set the :envvar:" +"`PYTHONWARNDEFAULTENCODING` environment variable, which will emit an :exc:" +"`EncodingWarning` when the default encoding is used." msgstr "" -"要找出哪些地方使用到預設的地區編碼,你可以啟用 :option:`-X " -"warn_default_encoding <-X>` 命令列選項,或者設定環境變數 :envvar:" -"`PYTHONWARNDEFAULTENCODING`。當使用到預設編碼時,會引發 :exc:" -"`EncodingWarning`。" +"要找出哪些地方使用到預設編碼,你可以啟用 :option:`-X warn_default_encoding <-" +"X>` 命令列選項,或者設定環境變數 :envvar:`PYTHONWARNDEFAULTENCODING`。當使用" +"到預設編碼時,會引發 :exc:`EncodingWarning`。" -#: ../../library/io.rst:168 +#: ../../library/io.rst:147 msgid "" "If you are providing an API that uses :func:`open` or :class:`TextIOWrapper` " "and passes ``encoding=None`` as a parameter, you can use :func:" @@ -305,11 +276,11 @@ msgstr "" "`EncodingWarning`。然而,對於新的 API,請考慮預設使用 UTF-8(即 " "``encoding=\"utf-8\"``)。" -#: ../../library/io.rst:177 -msgid "High-level Module Interface" +#: ../../library/io.rst:156 +msgid "High-level module interface" msgstr "高階模組介面" -#: ../../library/io.rst:181 +#: ../../library/io.rst:160 msgid "" "An int containing the default buffer size used by the module's buffered I/O " "classes. :func:`open` uses the file's blksize (as obtained by :func:`os." @@ -318,11 +289,11 @@ msgstr "" "一個包含模組中緩衝 I/O 類別所使用的預設緩衝區大小的整數。若可能的話,:func:" "`open` 會使用檔案的 blksize (透過 :func:`os.stat` 取得)。" -#: ../../library/io.rst:188 +#: ../../library/io.rst:167 msgid "This is an alias for the builtin :func:`open` function." msgstr "這是內建函式 :func:`open` 的別名。" -#: ../../library/io.rst:190 ../../library/io.rst:192 +#: ../../library/io.rst:169 ../../library/io.rst:171 msgid "" "This function raises an :ref:`auditing event ` ``open`` with " "arguments *path*, *mode* and *flags*. The *mode* and *flags* arguments may " @@ -332,7 +303,7 @@ msgstr "" "(auditing event) ` ``open``。*mode* 與 *flags* 引數可能已經被修改或" "者從原始呼叫中被推斷出來。" -#: ../../library/io.rst:199 +#: ../../library/io.rst:178 msgid "" "Opens the provided file with mode ``'rb'``. This function should be used " "when the intent is to treat the contents as executable code." @@ -340,11 +311,11 @@ msgstr "" "以 ``'rb'`` 模式開啟提供的檔案。此函式應用於意圖將內容視為可執行的程式碼的情" "況下。" -#: ../../library/io.rst:202 +#: ../../library/io.rst:181 msgid "*path* should be a :class:`str` and an absolute path." msgstr "*path* 應該要屬於 :class:`str` 類別,且是個絕對路徑。" -#: ../../library/io.rst:204 +#: ../../library/io.rst:183 msgid "" "The behavior of this function may be overridden by an earlier call to the :c:" "func:`PyFile_SetOpenCodeHook`. However, assuming that *path* is a :class:" @@ -357,7 +328,7 @@ msgstr "" "與 ``open(path, 'rb')`` 有相同行為。覆寫這個行為是為了對檔案進行額外驗證或預" "處理。" -#: ../../library/io.rst:215 +#: ../../library/io.rst:194 msgid "" "This is a helper function for callables that use :func:`open` or :class:" "`TextIOWrapper` and have an ``encoding=None`` parameter." @@ -365,7 +336,7 @@ msgstr "" "這是個輔助函式,適用於使用 :func:`open` 或 :class:`TextIOWrapper` 且具有 " "``encoding=None`` 參數的可呼叫物件。" -#: ../../library/io.rst:218 +#: ../../library/io.rst:197 msgid "" "This function returns *encoding* if it is not ``None``. Otherwise, it " "returns ``\"locale\"`` or ``\"utf-8\"`` depending on :ref:`UTF-8 Mode ` 回傳 ``\"locale\"`` 或 ``\"utf-8\"``。" -#: ../../library/io.rst:222 +#: ../../library/io.rst:201 msgid "" "This function emits an :class:`EncodingWarning` if :data:`sys.flags." "warn_default_encoding ` is true and *encoding* is ``None``. " @@ -384,7 +355,7 @@ msgstr "" "為 ``None``,此函式會發出一個 :class:`EncodingWarning`。*stacklevel* 指定警告" "在哪層發出。範例: ::" -#: ../../library/io.rst:227 +#: ../../library/io.rst:206 msgid "" "def read_text(path, encoding=None):\n" " encoding = io.text_encoding(encoding) # stacklevel=2\n" @@ -396,7 +367,7 @@ msgstr "" " with open(path, encoding) as f:\n" " return f.read()" -#: ../../library/io.rst:232 +#: ../../library/io.rst:211 msgid "" "In this example, an :class:`EncodingWarning` is emitted for the caller of " "``read_text()``." @@ -404,11 +375,11 @@ msgstr "" "在此範例中,對於 ``read_text()`` 的呼叫方會引發一個 :class:" "`EncodingWarning`。" -#: ../../library/io.rst:235 +#: ../../library/io.rst:214 msgid "See :ref:`io-text-encoding` for more information." msgstr "更多資訊請見 :ref:`io-text-encoding`。" -#: ../../library/io.rst:239 +#: ../../library/io.rst:218 msgid "" ":func:`text_encoding` returns \"utf-8\" when UTF-8 mode is enabled and " "*encoding* is ``None``." @@ -416,13 +387,13 @@ msgstr "" "當 UTF-8 模式啟用且 *encoding* 為 ``None`` 時,:func:`text_encoding` 會回傳 " "\"utf-8\"。" -#: ../../library/io.rst:246 +#: ../../library/io.rst:225 msgid "" "This is a compatibility alias for the builtin :exc:`BlockingIOError` " "exception." msgstr "這是內建的 :exc:`BlockingIOError` 例外的相容性別名。" -#: ../../library/io.rst:252 +#: ../../library/io.rst:231 msgid "" "An exception inheriting :exc:`OSError` and :exc:`ValueError` that is raised " "when an unsupported operation is called on a stream." @@ -430,11 +401,11 @@ msgstr "" "當在資料串流上呼叫不支援的操作時,會引發繼承自 :exc:`OSError` 與 :exc:" "`ValueError` 的例外。" -#: ../../library/io.rst:258 +#: ../../library/io.rst:237 msgid ":mod:`sys`" msgstr ":mod:`sys`" -#: ../../library/io.rst:259 +#: ../../library/io.rst:238 msgid "" "contains the standard IO streams: :data:`sys.stdin`, :data:`sys.stdout`, " "and :data:`sys.stderr`." @@ -442,11 +413,11 @@ msgstr "" "包含標準的 IO 資料串流::data:`sys.stdin`、:data:`sys.stdout` 以及 :data:" "`sys.stderr`。" -#: ../../library/io.rst:264 +#: ../../library/io.rst:243 msgid "Class hierarchy" msgstr "類別階層" -#: ../../library/io.rst:266 +#: ../../library/io.rst:245 msgid "" "The implementation of I/O streams is organized as a hierarchy of classes. " "First :term:`abstract base classes ` (ABCs), which are " @@ -457,7 +428,7 @@ msgstr "" "base classes ` (抽象基底類別,ABCs),它們被用來規範各" "種不同類型的串流,接著具體類別會提供標準串流的實作。" -#: ../../library/io.rst:273 +#: ../../library/io.rst:252 msgid "" "The abstract base classes also provide default implementations of some " "methods in order to help implementation of concrete stream classes. For " @@ -468,7 +439,7 @@ msgstr "" "class:`BufferedIOBase` 提供未經最佳化的 :meth:`!readinto` 與 :meth:`!" "readline` 實作。" -#: ../../library/io.rst:278 +#: ../../library/io.rst:257 msgid "" "At the top of the I/O hierarchy is the abstract base class :class:`IOBase`. " "It defines the basic interface to a stream. Note, however, that there is no " @@ -480,7 +451,7 @@ msgstr "" "面。然而,請注意,讀取串流與寫入串流之間並沒有分離;若不支援給定的操作,實作" "是允許引發 :exc:`UnsupportedOperation` 例外的。" -#: ../../library/io.rst:283 +#: ../../library/io.rst:262 msgid "" "The :class:`RawIOBase` ABC extends :class:`IOBase`. It deals with the " "reading and writing of bytes to a stream. :class:`FileIO` subclasses :class:" @@ -490,7 +461,7 @@ msgstr "" "組讀寫。:class:`FileIO` 則繼承 :class:`RawIOBase` 來提供一個介面以存取機器檔" "案系統內的檔案。" -#: ../../library/io.rst:287 +#: ../../library/io.rst:266 msgid "" "The :class:`BufferedIOBase` ABC extends :class:`IOBase`. It deals with " "buffering on a raw binary stream (:class:`RawIOBase`). Its subclasses, :" @@ -507,7 +478,7 @@ msgstr "" "(seekable stream) 的緩衝介面。另一個類別 :class:`BufferedIOBase` 的子類別 :" "class:`BytesIO`,是一個記憶體內位元組串流。" -#: ../../library/io.rst:295 +#: ../../library/io.rst:274 msgid "" "The :class:`TextIOBase` ABC extends :class:`IOBase`. It deals with streams " "whose bytes represent text, and handles encoding and decoding to and from " @@ -520,43 +491,43 @@ msgstr "" "`TextIOBase`,這是個對緩衝原始串流 (:class:`BufferedIOBase`) 的緩衝文本介面。" "最後,:class:`StringIO` 是個文字記憶體內串流。" -#: ../../library/io.rst:301 +#: ../../library/io.rst:280 msgid "" "Argument names are not part of the specification, and only the arguments of :" "func:`open` are intended to be used as keyword arguments." msgstr "引數名稱不是規範的一部份,只有 :func:`open` 的引數將作為關鍵字引數。" -#: ../../library/io.rst:304 +#: ../../library/io.rst:283 msgid "" "The following table summarizes the ABCs provided by the :mod:`!io` module:" msgstr "以下表格總結了 :mod:`!io` 模組提供的抽象基底類別 (ABC):" -#: ../../library/io.rst:309 +#: ../../library/io.rst:288 msgid "ABC" msgstr "抽象基底類別 (ABC)" -#: ../../library/io.rst:309 +#: ../../library/io.rst:288 msgid "Inherits" msgstr "繼承" -#: ../../library/io.rst:309 +#: ../../library/io.rst:288 msgid "Stub Methods" msgstr "Stub 方法" -#: ../../library/io.rst:309 +#: ../../library/io.rst:288 msgid "Mixin Methods and Properties" msgstr "Mixin 方法與屬性" -#: ../../library/io.rst:311 ../../library/io.rst:316 ../../library/io.rst:318 -#: ../../library/io.rst:320 +#: ../../library/io.rst:290 ../../library/io.rst:295 ../../library/io.rst:297 +#: ../../library/io.rst:299 msgid ":class:`IOBase`" msgstr ":class:`IOBase`" -#: ../../library/io.rst:311 +#: ../../library/io.rst:290 msgid "``fileno``, ``seek``, and ``truncate``" msgstr "``fileno``、``seek`` 和 ``truncate``" -#: ../../library/io.rst:311 +#: ../../library/io.rst:290 msgid "" "``close``, ``closed``, ``__enter__``, ``__exit__``, ``flush``, ``isatty``, " "``__iter__``, ``__next__``, ``readable``, ``readline``, ``readlines``, " @@ -566,53 +537,53 @@ msgstr "" "``__iter__``、``__next__``、``readable``、``readline``、``readlines``、" "``seekable``、``tell``、``writable`` 與 ``writelines``" -#: ../../library/io.rst:316 +#: ../../library/io.rst:295 msgid ":class:`RawIOBase`" msgstr ":class:`RawIOBase`" -#: ../../library/io.rst:316 +#: ../../library/io.rst:295 msgid "``readinto`` and ``write``" msgstr "``readinto`` 和 ``write``" -#: ../../library/io.rst:316 +#: ../../library/io.rst:295 msgid "Inherited :class:`IOBase` methods, ``read``, and ``readall``" msgstr "繼承自 :class:`IOBase` 的方法,``read`` 與 ``readall``" -#: ../../library/io.rst:318 +#: ../../library/io.rst:297 msgid ":class:`BufferedIOBase`" msgstr ":class:`BufferedIOBase`" -#: ../../library/io.rst:318 +#: ../../library/io.rst:297 msgid "``detach``, ``read``, ``read1``, and ``write``" msgstr "``detach``、``read``、``read1`` 和 ``write``" -#: ../../library/io.rst:318 +#: ../../library/io.rst:297 msgid "Inherited :class:`IOBase` methods, ``readinto``, and ``readinto1``" msgstr "繼承自 :class:`IOBase` 的方法,``readinto`` 與 ``readinto1``" -#: ../../library/io.rst:320 +#: ../../library/io.rst:299 msgid ":class:`TextIOBase`" msgstr ":class:`TextIOBase`" -#: ../../library/io.rst:320 +#: ../../library/io.rst:299 msgid "``detach``, ``read``, ``readline``, and ``write``" msgstr "``detach``、``read``、``readline`` 和 ``write``" -#: ../../library/io.rst:320 +#: ../../library/io.rst:299 msgid "" "Inherited :class:`IOBase` methods, ``encoding``, ``errors``, and ``newlines``" msgstr "" "繼承自 :class:`IOBase` 的方法,``encoding``、``errors`` 與 ``newlines``" -#: ../../library/io.rst:327 -msgid "I/O Base Classes" +#: ../../library/io.rst:306 +msgid "I/O base classes" msgstr "I/O 基礎類別" -#: ../../library/io.rst:331 +#: ../../library/io.rst:310 msgid "The abstract base class for all I/O classes." msgstr "所有 I/O 類別的抽象基礎類別。" -#: ../../library/io.rst:333 +#: ../../library/io.rst:312 msgid "" "This class provides empty abstract implementations for many methods that " "derived classes can override selectively; the default implementations " @@ -621,7 +592,7 @@ msgstr "" "為許多方法提供了空的抽象實作,衍生類別可以選擇性地覆寫這些方法;預設的實作代" "表一個無法讀取、寫入或搜尋的檔案。" -#: ../../library/io.rst:338 +#: ../../library/io.rst:317 msgid "" "Even though :class:`IOBase` does not declare :meth:`!read` or :meth:`!write` " "because their signatures will vary, implementations and clients should " @@ -634,14 +605,14 @@ msgstr "" "支援的操作時,可能會引發 :exc:`ValueError` (或 :exc:`UnsupportedOperation`)" "例外。" -#: ../../library/io.rst:344 +#: ../../library/io.rst:323 msgid "" "The basic type used for binary data read from or written to a file is :class:" "`bytes`. Other :term:`bytes-like objects ` are accepted " "as method arguments too. Text I/O classes work with :class:`str` data." msgstr "" -#: ../../library/io.rst:348 +#: ../../library/io.rst:327 msgid "" "Note that calling any method (even inquiries) on a closed stream is " "undefined. Implementations may raise :exc:`ValueError` in this case." @@ -649,7 +620,7 @@ msgstr "" "請注意,在一個已經關閉的串流上呼叫任何方法(即使只是查詢)都是未定義的。在這" "種情況下,實作可能會引發 :exc:`ValueError` 例外。" -#: ../../library/io.rst:351 +#: ../../library/io.rst:330 msgid "" ":class:`IOBase` (and its subclasses) supports the iterator protocol, meaning " "that an :class:`IOBase` object can be iterated over yielding the lines in a " @@ -658,7 +629,7 @@ msgid "" "character strings). See :meth:`~IOBase.readline` below." msgstr "" -#: ../../library/io.rst:357 +#: ../../library/io.rst:336 msgid "" ":class:`IOBase` is also a context manager and therefore supports the :" "keyword:`with` statement. In this example, *file* is closed after the :" @@ -667,7 +638,7 @@ msgstr "" ":class:`IOBase` 也是個情境管理器,因此支援 :keyword:`with` 陳述式。在這個例子" "中,*file* 會在 :keyword:`!with` 陳述式執行完畢後關閉——即使發生了異常。" -#: ../../library/io.rst:361 +#: ../../library/io.rst:340 msgid "" "with open('spam.txt', 'w') as file:\n" " file.write('Spam and eggs!')" @@ -675,11 +646,11 @@ msgstr "" "with open('spam.txt', 'w') as file:\n" " file.write('Spam and eggs!')" -#: ../../library/io.rst:364 +#: ../../library/io.rst:343 msgid ":class:`IOBase` provides these data attributes and methods:" msgstr ":class:`IOBase` 提供這些資料屬性與方法:" -#: ../../library/io.rst:368 +#: ../../library/io.rst:347 msgid "" "Flush and close this stream. This method has no effect if the file is " "already closed. Once the file is closed, any operation on the file (e.g. " @@ -688,17 +659,17 @@ msgstr "" "清除並關閉這個串流。若檔案已經關閉,則此方法沒有作用。一旦檔案被關閉,任何對" "檔案的操作(例如讀取或寫入)將引發 :exc:`ValueError` 異常。" -#: ../../library/io.rst:372 +#: ../../library/io.rst:351 msgid "" "As a convenience, it is allowed to call this method more than once; only the " "first call, however, will have an effect." msgstr "為了方便起見,允許多次呼叫這個方法;然而,只有第一次呼叫會有效果。" -#: ../../library/io.rst:377 +#: ../../library/io.rst:356 msgid "``True`` if the stream is closed." msgstr "如果串流已關閉,則為 ``True``。" -#: ../../library/io.rst:381 +#: ../../library/io.rst:360 msgid "" "Return the underlying file descriptor (an integer) of the stream if it " "exists. An :exc:`OSError` is raised if the IO object does not use a file " @@ -707,7 +678,7 @@ msgstr "" "如果串流存在,則回傳其底層的檔案描述器(一個整數)。如果 IO 物件不使用檔案描" "述器,則會引發一個 :exc:`OSError` 例外。" -#: ../../library/io.rst:387 +#: ../../library/io.rst:366 msgid "" "Flush the write buffers of the stream if applicable. This does nothing for " "read-only and non-blocking streams." @@ -715,13 +686,13 @@ msgstr "" "如果適用,清空串流的寫入緩衝區。對於唯讀和非阻塞串流,此操作不會執行任何操" "作。" -#: ../../library/io.rst:392 +#: ../../library/io.rst:371 msgid "" "Return ``True`` if the stream is interactive (i.e., connected to a terminal/" "tty device)." msgstr "如果串流是互動式的(即連接到終端機/tty 設備),則回傳 ``True``。" -#: ../../library/io.rst:397 +#: ../../library/io.rst:376 msgid "" "Return ``True`` if the stream can be read from. If ``False``, :meth:`!read` " "will raise :exc:`OSError`." @@ -729,13 +700,13 @@ msgstr "" "如果串流可以被讀取,則回傳 ``True``。如果是 ``False``,:meth:`!read` 將會引" "發 :exc:`OSError` 例外。" -#: ../../library/io.rst:402 +#: ../../library/io.rst:381 msgid "" "Read and return one line from the stream. If *size* is specified, at most " "*size* bytes will be read." msgstr "從串流讀取並回傳一行。如果指定了 *size*,則最多讀取 *size* 個位元組。" -#: ../../library/io.rst:405 +#: ../../library/io.rst:384 msgid "" "The line terminator is always ``b'\\n'`` for binary files; for text files, " "the *newline* argument to :func:`open` can be used to select the line " @@ -744,7 +715,7 @@ msgstr "" "對於二進位檔案,行結束符總是 ``b'\\n'``;對於文字檔案,可以使用 :func:`open` " "函式的 *newline* 引數來選擇識別的行結束符號。" -#: ../../library/io.rst:411 +#: ../../library/io.rst:390 msgid "" "Read and return a list of lines from the stream. *hint* can be specified to " "control the number of lines read: no more lines will be read if the total " @@ -754,12 +725,12 @@ msgstr "" "果到目前為止所有行的總大小(以位元組/字元計)超過 *hint*,則不會再讀取更多" "行。" -#: ../../library/io.rst:415 +#: ../../library/io.rst:394 msgid "" "*hint* values of ``0`` or less, as well as ``None``, are treated as no hint." msgstr "*hint* 值為 ``0`` 或更小,以及 ``None``,都被視為沒有提供 hint。" -#: ../../library/io.rst:418 +#: ../../library/io.rst:397 msgid "" "Note that it's already possible to iterate on file objects using ``for line " "in file: ...`` without calling :meth:`!file.readlines`." @@ -767,7 +738,7 @@ msgstr "" "請注意,已經可以使用 ``for line in file: ...`` 在檔案物件上進行疊代,而不一定" "需要呼叫 :meth:`!file.readlines`。" -#: ../../library/io.rst:423 +#: ../../library/io.rst:402 msgid "" "Change the stream position to the given byte *offset*, interpreted relative " "to the position indicated by *whence*, and return the new absolute position. " @@ -776,30 +747,30 @@ msgstr "" "將串流位置改變到給定的位元組 *offset*,此位置是相對於由 *whence* 指示的位置解" "釋的,並回傳新的絕對位置。*whence* 的值可為:" -#: ../../library/io.rst:428 +#: ../../library/io.rst:407 msgid "" ":data:`os.SEEK_SET` or ``0`` -- start of the stream (the default); *offset* " "should be zero or positive" msgstr "" ":data:`os.SEEK_SET` 或 ``0`` -- 串流的起點(預設值);*offset* 應為零或正數" -#: ../../library/io.rst:430 +#: ../../library/io.rst:409 msgid "" ":data:`os.SEEK_CUR` or ``1`` -- current stream position; *offset* may be " "negative" msgstr ":data:`os.SEEK_CUR` 或 ``1`` -- 目前串流位置;*offset* 可以是負數" -#: ../../library/io.rst:432 +#: ../../library/io.rst:411 msgid "" ":data:`os.SEEK_END` or ``2`` -- end of the stream; *offset* is usually " "negative" msgstr ":data:`os.SEEK_END` 或 ``2`` -- 串流的結尾;*offset* 通常是負數" -#: ../../library/io.rst:435 ../../library/io.rst:975 +#: ../../library/io.rst:414 ../../library/io.rst:957 msgid "The :data:`!SEEK_*` constants." msgstr ":data:`!SEEK_*` 常數。" -#: ../../library/io.rst:438 +#: ../../library/io.rst:417 msgid "" "Some operating systems could support additional values, like :const:`os." "SEEK_HOLE` or :const:`os.SEEK_DATA`. The valid values for a file could " @@ -808,7 +779,7 @@ msgstr "" "某些作業系統可以支援額外的值,例如 :const:`os.SEEK_HOLE` 或 :const:`os." "SEEK_DATA`。檔案的合法值取決於它是以文字模式還是二進位模式開啟。" -#: ../../library/io.rst:445 +#: ../../library/io.rst:424 msgid "" "Return ``True`` if the stream supports random access. If ``False``, :meth:" "`seek`, :meth:`tell` and :meth:`truncate` will raise :exc:`OSError`." @@ -816,11 +787,11 @@ msgstr "" "如果串流支援隨機存取,則回傳 ``True``。如果是 ``False``,則 :meth:`seek`、:" "meth:`tell` 和 :meth:`truncate` 會引發 :exc:`OSError`。" -#: ../../library/io.rst:450 +#: ../../library/io.rst:429 msgid "Return the current stream position." msgstr "回傳目前串流的位置。" -#: ../../library/io.rst:454 +#: ../../library/io.rst:433 msgid "" "Resize the stream to the given *size* in bytes (or the current position if " "*size* is not specified). The current stream position isn't changed. This " @@ -833,11 +804,11 @@ msgstr "" "下,新檔案區域的內容取決於平台(在大多數系統上,額外的位元組會被填充為零)。" "回傳新的檔案大小。" -#: ../../library/io.rst:461 +#: ../../library/io.rst:440 msgid "Windows will now zero-fill files when extending." msgstr "Windows 現在在擴展時會對檔案進行零填充 (zero-fill)。" -#: ../../library/io.rst:466 +#: ../../library/io.rst:445 msgid "" "Return ``True`` if the stream supports writing. If ``False``, :meth:`!" "write` and :meth:`truncate` will raise :exc:`OSError`." @@ -845,7 +816,7 @@ msgstr "" "如果串流支援寫入,則回傳 ``True``。如果是 ``False``,:meth:`!write` 和 :meth:" "`truncate` 將會引發 :exc:`OSError`。" -#: ../../library/io.rst:471 +#: ../../library/io.rst:450 msgid "" "Write a list of lines to the stream. Line separators are not added, so it " "is usual for each of the lines provided to have a line separator at the end." @@ -853,7 +824,7 @@ msgstr "" "將一個包含每一行的 list 寫入串流。這不會新增行分隔符號,因此通常提供的每一行" "末尾都有一個行分隔符號。" -#: ../../library/io.rst:477 +#: ../../library/io.rst:456 msgid "" "Prepare for object destruction. :class:`IOBase` provides a default " "implementation of this method that calls the instance's :meth:`~IOBase." @@ -862,11 +833,11 @@ msgstr "" "為物件銷毀做準備。:class:`IOBase` 提供了這個方法的預設實作,該實作會呼叫實例" "的 :meth:`~IOBase.close` 方法。" -#: ../../library/io.rst:484 +#: ../../library/io.rst:463 msgid "Base class for raw binary streams. It inherits from :class:`IOBase`." msgstr "原始二進位串流的基底類別。它繼承自 :class:`IOBase`。" -#: ../../library/io.rst:486 +#: ../../library/io.rst:465 msgid "" "Raw binary streams typically provide low-level access to an underlying OS " "device or API, and do not try to encapsulate it in high-level primitives " @@ -877,13 +848,13 @@ msgstr "" "高階原語 (primitive) 中(這項功能在緩衝二進位串流和文字串流中的更高階層級完" "成,後面的頁面會有描述)。" -#: ../../library/io.rst:491 +#: ../../library/io.rst:470 msgid "" ":class:`RawIOBase` provides these methods in addition to those from :class:" "`IOBase`:" msgstr ":class:`RawIOBase` 除了 :class:`IOBase` 的方法外,還提供以下這些方法:" -#: ../../library/io.rst:496 +#: ../../library/io.rst:475 msgid "" "Read up to *size* bytes from the object and return them. As a convenience, " "if *size* is unspecified or -1, all bytes until EOF are returned." @@ -891,7 +862,7 @@ msgstr "" "從物件中讀取最多 *size* 個位元組並回傳。方便起見,如果 *size* 未指定或為 -1," "則回傳直到檔案結尾 (EOF) 的所有位元組。" -#: ../../library/io.rst:499 +#: ../../library/io.rst:478 msgid "" "Attempts to make only one system call but will retry if interrupted and the " "signal handler does not raise an exception (see :pep:`475` for the " @@ -902,7 +873,7 @@ msgstr "" "pep:`475` 的原因說明)。這意味著如果作業系統呼叫回傳的位元組少於 *size*,則可" "能回傳少於 *size* 的位元組。" -#: ../../library/io.rst:504 +#: ../../library/io.rst:483 msgid "" "If 0 bytes are returned, and *size* was not 0, this indicates end of file. " "If the object is in non-blocking mode and no bytes are available, ``None`` " @@ -911,18 +882,18 @@ msgstr "" "如果回傳了 0 位元組,且 *size* 不是 0,這表示檔案結尾 (end of file)。如果物件" "處於非阻塞模式且沒有可用的位元組,則回傳 ``None``。" -#: ../../library/io.rst:508 +#: ../../library/io.rst:487 msgid "" "The default implementation defers to :meth:`readall` and :meth:`readinto`." msgstr "預設的實作會遵守 :meth:`readall` 和 :meth:`readinto` 的實作。" -#: ../../library/io.rst:513 +#: ../../library/io.rst:492 msgid "" "Read and return all the bytes from the stream until EOF, using multiple " "calls to the stream if necessary." msgstr "讀取並回傳串流中直到檔案結尾的所有位元組,必要時使用多次對串流的呼叫。" -#: ../../library/io.rst:516 +#: ../../library/io.rst:495 msgid "" "If ``0`` bytes are returned this indicates end of file. If the object is in " "non-blocking mode and the underlying :meth:`read` returns ``None`` " @@ -931,7 +902,7 @@ msgstr "" "如果回傳了 ``0`` 個位元組,這表示檔案結尾 (end of file)。如果物件處於非阻塞模" "式且底層的 :meth:`read` 回傳 ``None`` 表示沒有可用的位元組,則回傳 ``None``。" -#: ../../library/io.rst:522 +#: ../../library/io.rst:501 msgid "" "Read bytes into a pre-allocated, writable :term:`bytes-like object` *b*, and " "return the number of bytes read. For example, *b* might be a :class:" @@ -940,7 +911,7 @@ msgstr "" "讀取位元組到一個預先分配的、可寫的 :term:`bytes-like object` *b* 當中,並回傳" "讀取的位元組數量。例如,*b* 可能是一個 :class:`bytearray`。" -#: ../../library/io.rst:526 +#: ../../library/io.rst:505 msgid "" "If ``0`` is returned and ``len(b)`` is not ``0``, this indicates end of " "file. If the object is in non-blocking mode and no bytes are available, " @@ -949,7 +920,7 @@ msgstr "" "如果回傳了 ``0`` 且 ``len(b)`` 不是 ``0``,這表示檔案結尾 (end of file)。如果" "物件處於非阻塞模式且沒有可用的位元組,則回傳 ``None``。" -#: ../../library/io.rst:532 +#: ../../library/io.rst:511 msgid "" "Write the given :term:`bytes-like object`, *b*, to the underlying raw " "stream, and return the number of bytes written. This can be less than the " @@ -965,7 +936,7 @@ msgstr "" "何單一位元組,則回傳 ``None``。呼叫者在此方法回傳後可以釋放或變更 *b*,因此實" "作應該只在方法呼叫期間存取 *b*。" -#: ../../library/io.rst:544 +#: ../../library/io.rst:523 msgid "" "This function does not ensure all bytes are written or an exception is " "thrown. Callers may implement that behavior by checking the return value " @@ -974,13 +945,13 @@ msgid "" "ref:`binary-io` and :ref:`text-io` implement retry behavior." msgstr "" -#: ../../library/io.rst:552 +#: ../../library/io.rst:531 msgid "" "Base class for binary streams that support some kind of buffering. It " "inherits from :class:`IOBase`." msgstr "支援某種緩衝的二進位串流的基底類別。它繼承自 :class:`IOBase`。" -#: ../../library/io.rst:555 +#: ../../library/io.rst:534 msgid "" "The main difference with :class:`RawIOBase` is that methods :meth:`read`, :" "meth:`readinto` and :meth:`write` will try (respectively) to read as much " @@ -989,7 +960,7 @@ msgstr "" "與 :class:`RawIOBase` 的主要差異在於,:meth:`read`、:meth:`readinto` 及 :" "meth:`write` 方法將分別嘗試讀取所請求的盡可能多的輸入,或發出所有提供的資料。" -#: ../../library/io.rst:559 +#: ../../library/io.rst:538 msgid "" "In addition, if the underlying raw stream is in non-blocking mode, when the " "system returns would block :meth:`write` will raise :exc:`BlockingIOError` " @@ -997,13 +968,13 @@ msgid "" "data read so far or ``None`` if no data is available." msgstr "" -#: ../../library/io.rst:564 +#: ../../library/io.rst:543 msgid "" "Besides, the :meth:`read` method does not have a default implementation that " "defers to :meth:`readinto`." msgstr "此外,:meth:`read` 方法不存在一個遵從 :meth:`readinto` 的預設實作。" -#: ../../library/io.rst:567 +#: ../../library/io.rst:546 msgid "" "A typical :class:`BufferedIOBase` implementation should not inherit from a :" "class:`RawIOBase` implementation, but wrap one, like :class:`BufferedWriter` " @@ -1013,7 +984,7 @@ msgstr "" "實作,而是應該改用包裝的方式,像 :class:`BufferedWriter` 和 :class:" "`BufferedReader` 那樣的作法。" -#: ../../library/io.rst:571 +#: ../../library/io.rst:550 msgid "" ":class:`BufferedIOBase` provides or overrides these data attributes and " "methods in addition to those from :class:`IOBase`:" @@ -1021,7 +992,7 @@ msgstr "" ":class:`BufferedIOBase` 除了提供或覆寫來自 :class:`IOBase` 的資料屬性和方法以" "外,還包含了這些:" -#: ../../library/io.rst:576 +#: ../../library/io.rst:555 msgid "" "The underlying raw stream (a :class:`RawIOBase` instance) that :class:" "`BufferedIOBase` deals with. This is not part of the :class:" @@ -1030,16 +1001,16 @@ msgstr "" "底層的原始串流(一個 :class:`RawIOBase` 實例),:class:`BufferedIOBase` 處理" "的對象。這不是 :class:`BufferedIOBase` API 的一部分,且在某些實作可能不存在。" -#: ../../library/io.rst:582 +#: ../../library/io.rst:561 msgid "Separate the underlying raw stream from the buffer and return it." msgstr "將底層的原始串流從緩衝區中分離出來,並回傳它。" -#: ../../library/io.rst:584 +#: ../../library/io.rst:563 msgid "" "After the raw stream has been detached, the buffer is in an unusable state." msgstr "在原始串流被分離後,緩衝區處於一個不可用的狀態。" -#: ../../library/io.rst:587 +#: ../../library/io.rst:566 msgid "" "Some buffers, like :class:`BytesIO`, do not have the concept of a single raw " "stream to return from this method. They raise :exc:`UnsupportedOperation`." @@ -1047,7 +1018,7 @@ msgstr "" "某些緩衝區,如 :class:`BytesIO`,沒有單一原始串流的概念可從此方法回傳。它們會" "引發 :exc:`UnsupportedOperation`。" -#: ../../library/io.rst:595 +#: ../../library/io.rst:574 msgid "" "Read and return up to *size* bytes. If the argument is omitted, ``None``, or " "negative read as much as possible." @@ -1055,7 +1026,7 @@ msgstr "" "讀取並回傳最多 *size* 個位元組。如果引數被省略、為 ``None`` 或為負值,將讀取" "盡可能最多的位元組。" -#: ../../library/io.rst:598 +#: ../../library/io.rst:577 msgid "" "Fewer bytes may be returned than requested. An empty :class:`bytes` object " "is returned if the stream is already at EOF. More than one read may be made " @@ -1064,7 +1035,7 @@ msgid "" "does not imply that EOF is imminent." msgstr "" -#: ../../library/io.rst:604 +#: ../../library/io.rst:583 msgid "" "When reading as much as possible the default implementation will use ``raw." "readall`` if available (which should implement :meth:`RawIOBase.readall`), " @@ -1073,14 +1044,14 @@ msgid "" "non-blocking streams more data may become available." msgstr "" -#: ../../library/io.rst:613 ../../library/io.rst:626 +#: ../../library/io.rst:592 ../../library/io.rst:605 msgid "" "When the underlying raw stream is non-blocking, implementations may either " "raise :exc:`BlockingIOError` or return ``None`` if no data is available. :" "mod:`!io` implementations return ``None``." msgstr "" -#: ../../library/io.rst:619 +#: ../../library/io.rst:598 msgid "" "Read and return up to *size* bytes, calling :meth:`~RawIOBase.readinto` " "which may retry if :py:const:`~errno.EINTR` is encountered per :pep:`475`. " @@ -1088,7 +1059,7 @@ msgid "" "arbitrary value for *size*." msgstr "" -#: ../../library/io.rst:632 +#: ../../library/io.rst:611 msgid "" "Read bytes into a pre-allocated, writable :term:`bytes-like object` *b* and " "return the number of bytes read. For example, *b* might be a :class:" @@ -1097,7 +1068,7 @@ msgstr "" "讀取位元組到一個預先分配的、可寫的 :term:`bytes-like object` *b* 當中,並回傳" "讀取的位元組數量。例如,*b* 可能是一個 :class:`bytearray`。" -#: ../../library/io.rst:636 +#: ../../library/io.rst:615 msgid "" "Like :meth:`read`, multiple reads may be issued to the underlying raw " "stream, unless the latter is interactive." @@ -1105,7 +1076,7 @@ msgstr "" "類似於 :meth:`read`,除非後者是互動式的,否則可能會對底層原始串流發出多次讀" "取。" -#: ../../library/io.rst:639 ../../library/io.rst:649 +#: ../../library/io.rst:618 ../../library/io.rst:628 msgid "" "A :exc:`BlockingIOError` is raised if the underlying raw stream is in non " "blocking-mode, and has no data available at the moment." @@ -1113,7 +1084,7 @@ msgstr "" "如果底層原始串流處於非阻塞模式,且目前沒有可用資料,則會引發 :exc:" "`BlockingIOError`。" -#: ../../library/io.rst:644 +#: ../../library/io.rst:623 msgid "" "Read bytes into a pre-allocated, writable :term:`bytes-like object` *b*, " "using at most one call to the underlying raw stream's :meth:`~RawIOBase." @@ -1124,7 +1095,7 @@ msgstr "" "一次底層原始串流的 :meth:`~RawIOBase.read` (或 :meth:`~RawIOBase.readinto`)" "方法。此方法回傳讀取的位元組數量。" -#: ../../library/io.rst:656 +#: ../../library/io.rst:635 msgid "" "Write the given :term:`bytes-like object`, *b*, and return the number of " "bytes written (always equal to the length of *b* in bytes, since if the " @@ -1137,7 +1108,7 @@ msgstr "" "實作,這些位元組可能會立即寫入底層串流,或出於性能和延遲的緣故而被留在緩衝區" "當中。" -#: ../../library/io.rst:663 +#: ../../library/io.rst:642 msgid "" "When in non-blocking mode, a :exc:`BlockingIOError` is raised if the data " "needed to be written to the raw stream but it couldn't accept all the data " @@ -1146,7 +1117,7 @@ msgstr "" "當處於非阻塞模式時,如果需要將資料寫入原始串流,但它無法接受所有資料而不阻" "塞,則會引發 :exc:`BlockingIOError`。" -#: ../../library/io.rst:667 +#: ../../library/io.rst:646 msgid "" "The caller may release or mutate *b* after this method returns, so the " "implementation should only access *b* during the method call." @@ -1154,11 +1125,11 @@ msgstr "" "呼叫者可以在此方法回傳後釋放或變更 *b*,因此實作應該僅在方法呼叫期間存取 " "*b*。" -#: ../../library/io.rst:672 -msgid "Raw File I/O" +#: ../../library/io.rst:651 +msgid "Raw file I/O" msgstr "原始檔案 I/O" -#: ../../library/io.rst:676 +#: ../../library/io.rst:655 msgid "" "A raw binary stream representing an OS-level file containing bytes data. It " "inherits from :class:`RawIOBase` and implements its low-level access design. " @@ -1168,11 +1139,11 @@ msgid "" "\"read at least\" behavior, use :ref:`binary-io`." msgstr "" -#: ../../library/io.rst:683 +#: ../../library/io.rst:662 msgid "The *name* can be one of two things:" msgstr "*name* 可以是兩種事物之一:" -#: ../../library/io.rst:685 +#: ../../library/io.rst:664 msgid "" "a character string or :class:`bytes` object representing the path to the " "file which will be opened. In this case closefd must be ``True`` (the " @@ -1181,7 +1152,7 @@ msgstr "" "代表將要打開的檔案路徑的一個字元串或 :class:`bytes` 物件。在這種情況下," "closefd 必須是 ``True`` (預設值),否則將引發錯誤。" -#: ../../library/io.rst:688 +#: ../../library/io.rst:667 msgid "" "an integer representing the number of an existing OS-level file descriptor " "to which the resulting :class:`FileIO` object will give access. When the " @@ -1189,7 +1160,7 @@ msgid "" "set to ``False``." msgstr "" -#: ../../library/io.rst:693 +#: ../../library/io.rst:672 msgid "" "The *mode* can be ``'r'``, ``'w'``, ``'x'`` or ``'a'`` for reading " "(default), writing, exclusive creation or appending. The file will be " @@ -1200,7 +1171,7 @@ msgid "" "``'+'`` to the mode to allow simultaneous reading and writing." msgstr "" -#: ../../library/io.rst:701 +#: ../../library/io.rst:680 msgid "" "A custom opener can be used by passing a callable as *opener*. The " "underlying file descriptor for the file object is then obtained by calling " @@ -1209,17 +1180,17 @@ msgid "" "similar to passing ``None``)." msgstr "" -#: ../../library/io.rst:707 +#: ../../library/io.rst:686 msgid "The newly created file is :ref:`non-inheritable `." msgstr "" -#: ../../library/io.rst:709 +#: ../../library/io.rst:688 msgid "" "See the :func:`open` built-in function for examples on using the *opener* " "parameter." msgstr "" -#: ../../library/io.rst:713 +#: ../../library/io.rst:692 msgid "" ":class:`FileIO` is a low-level I/O object and members, such as :meth:" "`~RawIOBase.read` and :meth:`~RawIOBase.write`, need to have their return " @@ -1228,67 +1199,73 @@ msgid "" "`text-io` implement retry behavior." msgstr "" -#: ../../library/io.rst:719 +#: ../../library/io.rst:698 msgid "The *opener* parameter was added. The ``'x'`` mode was added." msgstr "" -#: ../../library/io.rst:723 +#: ../../library/io.rst:702 msgid "The file is now non-inheritable." msgstr "" -#: ../../library/io.rst:726 +#: ../../library/io.rst:705 msgid "" ":class:`FileIO` provides these data attributes in addition to those from :" "class:`RawIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:731 +#: ../../library/io.rst:710 msgid "The mode as given in the constructor." msgstr "" -#: ../../library/io.rst:735 +#: ../../library/io.rst:714 msgid "" "The file name. This is the file descriptor of the file when no name is " "given in the constructor." msgstr "" -#: ../../library/io.rst:740 -msgid "Buffered Streams" +#: ../../library/io.rst:719 +msgid "Buffered streams" msgstr "" -#: ../../library/io.rst:742 +#: ../../library/io.rst:721 msgid "" "Buffered I/O streams provide a higher-level interface to an I/O device than " "raw I/O does." msgstr "" -#: ../../library/io.rst:747 +#: ../../library/io.rst:726 msgid "" "A binary stream using an in-memory bytes buffer. It inherits from :class:" "`BufferedIOBase`. The buffer is discarded when the :meth:`~IOBase.close` " "method is called." msgstr "" -#: ../../library/io.rst:751 +#: ../../library/io.rst:730 msgid "" "The optional argument *initial_bytes* is a :term:`bytes-like object` that " "contains initial data." msgstr "" -#: ../../library/io.rst:754 +#: ../../library/io.rst:733 +msgid "" +"Methods may be used from multiple threads without external locking in :term:" +"`free-threaded builds `." +msgstr "" + +#: ../../library/io.rst:736 msgid "" ":class:`BytesIO` provides or overrides these methods in addition to those " "from :class:`BufferedIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:759 +#: ../../library/io.rst:741 msgid "" "Return a readable and writable view over the contents of the buffer without " "copying them. Also, mutating the view will transparently update the " "contents of the buffer::" msgstr "" -#: ../../library/io.rst:763 +#: ../../library/io.rst:745 msgid "" ">>> b = io.BytesIO(b\"abcdef\")\n" ">>> view = b.getbuffer()\n" @@ -1302,126 +1279,126 @@ msgstr "" ">>> b.getvalue()\n" "b'ab56ef'" -#: ../../library/io.rst:770 +#: ../../library/io.rst:752 msgid "" "As long as the view exists, the :class:`BytesIO` object cannot be resized or " "closed." msgstr "" -#: ../../library/io.rst:777 +#: ../../library/io.rst:759 msgid "Return :class:`bytes` containing the entire contents of the buffer." msgstr "" -#: ../../library/io.rst:782 +#: ../../library/io.rst:764 msgid "In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.read`." msgstr "" -#: ../../library/io.rst:784 ../../library/io.rst:824 +#: ../../library/io.rst:766 ../../library/io.rst:806 msgid "The *size* argument is now optional." msgstr "" -#: ../../library/io.rst:789 +#: ../../library/io.rst:771 msgid "" "In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.readinto`." msgstr "" -#: ../../library/io.rst:795 +#: ../../library/io.rst:777 msgid "" "A buffered binary stream providing higher-level access to a readable, non " "seekable :class:`RawIOBase` raw binary stream. It inherits from :class:" "`BufferedIOBase`." msgstr "" -#: ../../library/io.rst:799 +#: ../../library/io.rst:781 msgid "" "When reading data from this object, a larger amount of data may be requested " "from the underlying raw stream, and kept in an internal buffer. The buffered " "data can then be returned directly on subsequent reads." msgstr "" -#: ../../library/io.rst:803 +#: ../../library/io.rst:785 msgid "" "The constructor creates a :class:`BufferedReader` for the given readable " "*raw* stream and *buffer_size*. If *buffer_size* is omitted, :data:" "`DEFAULT_BUFFER_SIZE` is used." msgstr "" -#: ../../library/io.rst:807 +#: ../../library/io.rst:789 msgid "" ":class:`BufferedReader` provides or overrides these methods in addition to " "those from :class:`BufferedIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:812 +#: ../../library/io.rst:794 msgid "" "Return bytes from the stream without advancing the position. The number of " "bytes returned may be less or more than requested. If the underlying raw " "stream is non-blocking and the operation would block, returns empty bytes." msgstr "" -#: ../../library/io.rst:818 +#: ../../library/io.rst:800 msgid "" "In :class:`BufferedReader` this is the same as :meth:`io.BufferedIOBase.read`" msgstr "" -#: ../../library/io.rst:822 +#: ../../library/io.rst:804 msgid "" "In :class:`BufferedReader` this is the same as :meth:`io.BufferedIOBase." "read1`" msgstr "" -#: ../../library/io.rst:829 +#: ../../library/io.rst:811 msgid "" "A buffered binary stream providing higher-level access to a writeable, non " "seekable :class:`RawIOBase` raw binary stream. It inherits from :class:" "`BufferedIOBase`." msgstr "" -#: ../../library/io.rst:833 +#: ../../library/io.rst:815 msgid "" "When writing to this object, data is normally placed into an internal " "buffer. The buffer will be written out to the underlying :class:`RawIOBase` " "object under various conditions, including:" msgstr "" -#: ../../library/io.rst:837 +#: ../../library/io.rst:819 msgid "when the buffer gets too small for all pending data;" msgstr "" -#: ../../library/io.rst:838 +#: ../../library/io.rst:820 msgid "when :meth:`flush` is called;" msgstr "" -#: ../../library/io.rst:839 +#: ../../library/io.rst:821 msgid "" "when a :meth:`~IOBase.seek` is requested (for :class:`BufferedRandom` " "objects);" msgstr "" -#: ../../library/io.rst:840 +#: ../../library/io.rst:822 msgid "when the :class:`BufferedWriter` object is closed or destroyed." msgstr "" -#: ../../library/io.rst:842 +#: ../../library/io.rst:824 msgid "" "The constructor creates a :class:`BufferedWriter` for the given writeable " "*raw* stream. If the *buffer_size* is not given, it defaults to :data:" "`DEFAULT_BUFFER_SIZE`." msgstr "" -#: ../../library/io.rst:846 +#: ../../library/io.rst:828 msgid "" ":class:`BufferedWriter` provides or overrides these methods in addition to " "those from :class:`BufferedIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:851 +#: ../../library/io.rst:833 msgid "" "Force bytes held in the buffer into the raw stream. A :exc:" "`BlockingIOError` should be raised if the raw stream blocks." msgstr "" -#: ../../library/io.rst:856 +#: ../../library/io.rst:838 msgid "" "Write the :term:`bytes-like object`, *b*, and return the number of bytes " "written. When in non-blocking mode, a :exc:`BlockingIOError` with :attr:" @@ -1429,85 +1406,85 @@ msgid "" "written out but the raw stream blocks." msgstr "" -#: ../../library/io.rst:864 +#: ../../library/io.rst:846 msgid "" "A buffered binary stream implementing :class:`BufferedIOBase` interfaces " "providing higher-level access to a seekable :class:`RawIOBase` raw binary " "stream." msgstr "" -#: ../../library/io.rst:868 +#: ../../library/io.rst:850 msgid "" "The constructor creates a reader and writer for a seekable raw stream, given " "in the first argument. If the *buffer_size* is omitted it defaults to :data:" "`DEFAULT_BUFFER_SIZE`." msgstr "" -#: ../../library/io.rst:872 +#: ../../library/io.rst:854 msgid "" ":class:`BufferedRandom` is capable of anything :class:`BufferedReader` or :" "class:`BufferedWriter` can do. In addition, :meth:`~IOBase.seek` and :meth:" "`~IOBase.tell` are guaranteed to be implemented." msgstr "" -#: ../../library/io.rst:879 +#: ../../library/io.rst:861 msgid "" "A buffered binary stream providing higher-level access to two non seekable :" "class:`RawIOBase` raw binary streams---one readable, the other writeable. It " "inherits from :class:`BufferedIOBase`." msgstr "" -#: ../../library/io.rst:883 +#: ../../library/io.rst:865 msgid "" "*reader* and *writer* are :class:`RawIOBase` objects that are readable and " "writeable respectively. If the *buffer_size* is omitted it defaults to :" "data:`DEFAULT_BUFFER_SIZE`." msgstr "" -#: ../../library/io.rst:887 +#: ../../library/io.rst:869 msgid "" ":class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\\'s " "methods except for :meth:`~BufferedIOBase.detach`, which raises :exc:" "`UnsupportedOperation`." msgstr "" -#: ../../library/io.rst:893 +#: ../../library/io.rst:875 msgid "" ":class:`BufferedRWPair` does not attempt to synchronize accesses to its " "underlying raw streams. You should not pass it the same object as reader " "and writer; use :class:`BufferedRandom` instead." msgstr "" -#: ../../library/io.rst:903 +#: ../../library/io.rst:885 msgid "" "Base class for text streams. This class provides a character and line based " "interface to stream I/O. It inherits from :class:`IOBase`." msgstr "" -#: ../../library/io.rst:906 +#: ../../library/io.rst:888 msgid "" ":class:`TextIOBase` provides or overrides these data attributes and methods " "in addition to those from :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:911 +#: ../../library/io.rst:893 msgid "" "The name of the encoding used to decode the stream's bytes into strings, and " "to encode strings into bytes." msgstr "" -#: ../../library/io.rst:916 +#: ../../library/io.rst:898 msgid "The error setting of the decoder or encoder." msgstr "" -#: ../../library/io.rst:920 +#: ../../library/io.rst:902 msgid "" "A string, a tuple of strings, or ``None``, indicating the newlines " "translated so far. Depending on the implementation and the initial " "constructor flags, this may not be available." msgstr "" -#: ../../library/io.rst:926 +#: ../../library/io.rst:908 msgid "" "The underlying binary buffer (a :class:`BufferedIOBase` or :class:" "`RawIOBase` instance) that :class:`TextIOBase` deals with. This is not part " @@ -1517,99 +1494,99 @@ msgstr "" "為 :class:`TextIOBase` 處理的對象。這不是 :class:`TextIOBase` API 的一部分," "且在某些實作可能不存在。" -#: ../../library/io.rst:933 +#: ../../library/io.rst:915 msgid "" "Separate the underlying binary buffer from the :class:`TextIOBase` and " "return it." msgstr "" -#: ../../library/io.rst:936 +#: ../../library/io.rst:918 msgid "" "After the underlying buffer has been detached, the :class:`TextIOBase` is in " "an unusable state." msgstr "" -#: ../../library/io.rst:939 +#: ../../library/io.rst:921 msgid "" "Some :class:`TextIOBase` implementations, like :class:`StringIO`, may not " "have the concept of an underlying buffer and calling this method will raise :" "exc:`UnsupportedOperation`." msgstr "" -#: ../../library/io.rst:947 +#: ../../library/io.rst:929 msgid "" "Read and return at most *size* characters from the stream as a single :class:" "`str`. If *size* is negative or ``None``, reads until EOF." msgstr "" -#: ../../library/io.rst:952 +#: ../../library/io.rst:934 msgid "" "Read until newline or EOF and return a single :class:`str`. If the stream " "is already at EOF, an empty string is returned." msgstr "" -#: ../../library/io.rst:955 +#: ../../library/io.rst:937 msgid "If *size* is specified, at most *size* characters will be read." msgstr "" -#: ../../library/io.rst:959 +#: ../../library/io.rst:941 msgid "" "Change the stream position to the given *offset*. Behaviour depends on the " "*whence* parameter. The default value for *whence* is :data:`!SEEK_SET`." msgstr "" -#: ../../library/io.rst:963 +#: ../../library/io.rst:945 msgid "" ":data:`!SEEK_SET` or ``0``: seek from the start of the stream (the default); " "*offset* must either be a number returned by :meth:`TextIOBase.tell`, or " "zero. Any other *offset* value produces undefined behaviour." msgstr "" -#: ../../library/io.rst:967 +#: ../../library/io.rst:949 msgid "" ":data:`!SEEK_CUR` or ``1``: \"seek\" to the current position; *offset* must " "be zero, which is a no-operation (all other values are unsupported)." msgstr "" -#: ../../library/io.rst:970 +#: ../../library/io.rst:952 msgid "" ":data:`!SEEK_END` or ``2``: seek to the end of the stream; *offset* must be " "zero (all other values are unsupported)." msgstr "" -#: ../../library/io.rst:973 +#: ../../library/io.rst:955 msgid "Return the new absolute position as an opaque number." msgstr "" -#: ../../library/io.rst:980 +#: ../../library/io.rst:962 msgid "" "Return the current stream position as an opaque number. The number does not " "usually represent a number of bytes in the underlying binary storage." msgstr "" -#: ../../library/io.rst:986 +#: ../../library/io.rst:968 msgid "" "Write the string *s* to the stream and return the number of characters " "written." msgstr "" -#: ../../library/io.rst:993 +#: ../../library/io.rst:975 msgid "" "A buffered text stream providing higher-level access to a :class:" "`BufferedIOBase` buffered binary stream. It inherits from :class:" "`TextIOBase`." msgstr "" -#: ../../library/io.rst:997 +#: ../../library/io.rst:979 msgid "" "*encoding* gives the name of the encoding that the stream will be decoded or " -"encoded with. In :ref:`UTF-8 Mode `, this defaults to UTF-8. " -"Otherwise, it defaults to :func:`locale.getencoding`. " -"``encoding=\"locale\"`` can be used to specify the current locale's encoding " -"explicitly. See :ref:`io-text-encoding` for more information." +"encoded with. This defaults to UTF-8; if :ref:`UTF-8 Mode ` is " +"disabled, it defaults to :func:`locale.getencoding`. ``encoding=\"locale\"`` " +"can be used to specify the current locale's encoding explicitly. See :ref:" +"`io-text-encoding` for more information." msgstr "" -#: ../../library/io.rst:1003 +#: ../../library/io.rst:985 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled. Pass ``'strict'`` to raise a :exc:`ValueError` " @@ -1624,13 +1601,13 @@ msgid "" "that has been registered with :func:`codecs.register_error` is also valid." msgstr "" -#: ../../library/io.rst:1019 +#: ../../library/io.rst:1001 msgid "" "*newline* controls how line endings are handled. It can be ``None``, " "``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as follows:" msgstr "" -#: ../../library/io.rst:1022 +#: ../../library/io.rst:1004 msgid "" "When reading input from the stream, if *newline* is ``None``, :term:" "`universal newlines` mode is enabled. Lines in the input can end in " @@ -1642,7 +1619,7 @@ msgid "" "returned to the caller untranslated." msgstr "" -#: ../../library/io.rst:1031 +#: ../../library/io.rst:1013 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " "characters written are translated to the system default line separator, :" @@ -1651,13 +1628,13 @@ msgid "" "characters written are translated to the given string." msgstr "" -#: ../../library/io.rst:1037 +#: ../../library/io.rst:1019 msgid "" "If *line_buffering* is ``True``, :meth:`~IOBase.flush` is implied when a " "call to write contains a newline character or a carriage return." msgstr "" -#: ../../library/io.rst:1040 +#: ../../library/io.rst:1022 msgid "" "If *write_through* is ``True``, calls to :meth:`~BufferedIOBase.write` are " "guaranteed not to be buffered: any data written on the :class:" @@ -1665,11 +1642,11 @@ msgid "" "*buffer*." msgstr "" -#: ../../library/io.rst:1044 +#: ../../library/io.rst:1026 msgid "The *write_through* argument has been added." msgstr "" -#: ../../library/io.rst:1047 +#: ../../library/io.rst:1029 msgid "" "The default *encoding* is now ``locale.getpreferredencoding(False)`` instead " "of ``locale.getpreferredencoding()``. Don't change temporary the locale " @@ -1677,114 +1654,114 @@ msgid "" "instead of the user preferred encoding." msgstr "" -#: ../../library/io.rst:1053 +#: ../../library/io.rst:1035 msgid "" "The *encoding* argument now supports the ``\"locale\"`` dummy encoding name." msgstr "" -#: ../../library/io.rst:1058 +#: ../../library/io.rst:1040 msgid "" "When the underlying raw stream is non-blocking, a :exc:`BlockingIOError` may " "be raised if a read operation cannot be completed immediately." msgstr "" -#: ../../library/io.rst:1061 +#: ../../library/io.rst:1043 msgid "" ":class:`TextIOWrapper` provides these data attributes and methods in " "addition to those from :class:`TextIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:1066 +#: ../../library/io.rst:1048 msgid "Whether line buffering is enabled." msgstr "" -#: ../../library/io.rst:1070 +#: ../../library/io.rst:1052 msgid "Whether writes are passed immediately to the underlying binary buffer." msgstr "" -#: ../../library/io.rst:1078 +#: ../../library/io.rst:1060 msgid "" "Reconfigure this text stream using new settings for *encoding*, *errors*, " "*newline*, *line_buffering* and *write_through*." msgstr "" -#: ../../library/io.rst:1081 +#: ../../library/io.rst:1063 msgid "" "Parameters not specified keep current settings, except ``errors='strict'`` " "is used when *encoding* is specified but *errors* is not specified." msgstr "" -#: ../../library/io.rst:1085 +#: ../../library/io.rst:1067 msgid "" "It is not possible to change the encoding or newline if some data has " "already been read from the stream. On the other hand, changing encoding " "after write is possible." msgstr "" -#: ../../library/io.rst:1089 +#: ../../library/io.rst:1071 msgid "" "This method does an implicit stream flush before setting the new parameters." msgstr "" -#: ../../library/io.rst:1094 +#: ../../library/io.rst:1076 msgid "The method supports ``encoding=\"locale\"`` option." msgstr "" -#: ../../library/io.rst:1099 +#: ../../library/io.rst:1081 msgid "" "Set the stream position. Return the new stream position as an :class:`int`." msgstr "" -#: ../../library/io.rst:1102 +#: ../../library/io.rst:1084 msgid "" "Four operations are supported, given by the following argument combinations:" msgstr "" -#: ../../library/io.rst:1105 +#: ../../library/io.rst:1087 msgid "``seek(0, SEEK_SET)``: Rewind to the start of the stream." msgstr "" -#: ../../library/io.rst:1106 +#: ../../library/io.rst:1088 msgid "" "``seek(cookie, SEEK_SET)``: Restore a previous position; *cookie* **must " "be** a number returned by :meth:`tell`." msgstr "" -#: ../../library/io.rst:1108 +#: ../../library/io.rst:1090 msgid "``seek(0, SEEK_END)``: Fast-forward to the end of the stream." msgstr "" -#: ../../library/io.rst:1109 +#: ../../library/io.rst:1091 msgid "``seek(0, SEEK_CUR)``: Leave the current stream position unchanged." msgstr "" -#: ../../library/io.rst:1111 +#: ../../library/io.rst:1093 msgid "Any other argument combinations are invalid, and may raise exceptions." msgstr "" -#: ../../library/io.rst:1116 +#: ../../library/io.rst:1098 msgid ":data:`os.SEEK_SET`, :data:`os.SEEK_CUR`, and :data:`os.SEEK_END`." msgstr ":data:`os.SEEK_SET`、:data:`os.SEEK_CUR` 以及 :data:`os.SEEK_END`。" -#: ../../library/io.rst:1120 +#: ../../library/io.rst:1102 msgid "" "Return the stream position as an opaque number. The return value of :meth:`!" "tell` can be given as input to :meth:`seek`, to restore a previous stream " "position." msgstr "" -#: ../../library/io.rst:1127 +#: ../../library/io.rst:1109 msgid "" "A text stream using an in-memory text buffer. It inherits from :class:" "`TextIOBase`." msgstr "" -#: ../../library/io.rst:1130 +#: ../../library/io.rst:1112 msgid "" "The text buffer is discarded when the :meth:`~IOBase.close` method is called." msgstr "" -#: ../../library/io.rst:1133 +#: ../../library/io.rst:1115 msgid "" "The initial value of the buffer can be set by providing *initial_value*. If " "newline translation is enabled, newlines will be encoded as if by :meth:" @@ -1796,31 +1773,31 @@ msgid "" "at the end of the buffer." msgstr "" -#: ../../library/io.rst:1142 +#: ../../library/io.rst:1124 msgid "" "The *newline* argument works like that of :class:`TextIOWrapper`, except " "that when writing output to the stream, if *newline* is ``None``, newlines " "are written as ``\\n`` on all platforms." msgstr "" -#: ../../library/io.rst:1146 +#: ../../library/io.rst:1128 msgid "" ":class:`StringIO` provides this method in addition to those from :class:" "`TextIOBase` and :class:`IOBase`:" msgstr "" -#: ../../library/io.rst:1151 +#: ../../library/io.rst:1133 msgid "" "Return a :class:`str` containing the entire contents of the buffer. Newlines " "are decoded as if by :meth:`~TextIOBase.read`, although the stream position " "is not changed." msgstr "" -#: ../../library/io.rst:1155 +#: ../../library/io.rst:1137 msgid "Example usage::" msgstr "使用範例: ::" -#: ../../library/io.rst:1157 +#: ../../library/io.rst:1139 msgid "" "import io\n" "\n" @@ -1837,42 +1814,42 @@ msgid "" "output.close()" msgstr "" -#: ../../library/io.rst:1177 +#: ../../library/io.rst:1159 msgid "" "A helper codec that decodes newlines for :term:`universal newlines` mode. It " "inherits from :class:`codecs.IncrementalDecoder`." msgstr "" -#: ../../library/io.rst:1182 -msgid "Static Typing" +#: ../../library/io.rst:1164 +msgid "Static typing" msgstr "" -#: ../../library/io.rst:1184 +#: ../../library/io.rst:1166 msgid "" "The following protocols can be used for annotating function and method " "arguments for simple stream reading or writing operations. They are " "decorated with :deco:`typing.runtime_checkable`." msgstr "" -#: ../../library/io.rst:1190 +#: ../../library/io.rst:1172 msgid "" "Generic protocol for reading from a file or other input stream. ``T`` will " "usually be :class:`str` or :class:`bytes`, but can be any type that is read " "from the stream." msgstr "" -#: ../../library/io.rst:1199 +#: ../../library/io.rst:1181 msgid "" "Read data from the input stream and return it. If *size* is specified, it " "should be an integer, and at most *size* items (bytes/characters) will be " "read." msgstr "" -#: ../../library/io.rst:1203 ../../library/io.rst:1222 +#: ../../library/io.rst:1185 ../../library/io.rst:1204 msgid "For example::" msgstr "例如: ::" -#: ../../library/io.rst:1205 +#: ../../library/io.rst:1187 msgid "" "def read_it(reader: Reader[str]):\n" " data = reader.read(11)\n" @@ -1882,20 +1859,20 @@ msgstr "" " data = reader.read(11)\n" " assert isinstance(data, str)" -#: ../../library/io.rst:1211 +#: ../../library/io.rst:1193 msgid "" "Generic protocol for writing to a file or other output stream. ``T`` will " "usually be :class:`str` or :class:`bytes`, but can be any type that can be " "written to the stream." msgstr "" -#: ../../library/io.rst:1219 +#: ../../library/io.rst:1201 msgid "" "Write *data* to the output stream and return the number of items (bytes/" "characters) written." msgstr "" -#: ../../library/io.rst:1224 +#: ../../library/io.rst:1206 msgid "" "def write_binary(writer: Writer[bytes]):\n" " writer.write(b\"Hello world!\\n\")" @@ -1903,23 +1880,23 @@ msgstr "" "def write_binary(writer: Writer[bytes]):\n" " writer.write(b\"Hello world!\\n\")" -#: ../../library/io.rst:1227 +#: ../../library/io.rst:1209 msgid "" "See :ref:`typing-io` for other I/O related protocols and classes that can be " "used for static type checking." msgstr "" -#: ../../library/io.rst:1231 +#: ../../library/io.rst:1213 msgid "Performance" msgstr "" -#: ../../library/io.rst:1233 +#: ../../library/io.rst:1215 msgid "" "This section discusses the performance of the provided concrete I/O " "implementations." msgstr "" -#: ../../library/io.rst:1239 +#: ../../library/io.rst:1221 msgid "" "By reading and writing only large chunks of data even when the user asks for " "a single byte, buffered I/O hides any inefficiency in calling and executing " @@ -1932,7 +1909,7 @@ msgid "" "data." msgstr "" -#: ../../library/io.rst:1251 +#: ../../library/io.rst:1233 msgid "" "Text I/O over a binary storage (such as a file) is significantly slower than " "binary I/O over the same storage, because it requires conversions between " @@ -1942,24 +1919,24 @@ msgid "" "the reconstruction algorithm used." msgstr "" -#: ../../library/io.rst:1258 +#: ../../library/io.rst:1240 msgid "" ":class:`StringIO`, however, is a native in-memory unicode container and will " "exhibit similar speed to :class:`BytesIO`." msgstr "" -#: ../../library/io.rst:1262 +#: ../../library/io.rst:1244 msgid "Multi-threading" msgstr "" -#: ../../library/io.rst:1264 +#: ../../library/io.rst:1246 msgid "" ":class:`FileIO` objects are thread-safe to the extent that the operating " "system calls (such as :manpage:`read(2)` under Unix) they wrap are thread-" "safe too." msgstr "" -#: ../../library/io.rst:1267 +#: ../../library/io.rst:1249 msgid "" "Binary buffered objects (instances of :class:`BufferedReader`, :class:" "`BufferedWriter`, :class:`BufferedRandom` and :class:`BufferedRWPair`) " @@ -1967,15 +1944,15 @@ msgid "" "them from multiple threads at once." msgstr "" -#: ../../library/io.rst:1272 +#: ../../library/io.rst:1254 msgid ":class:`TextIOWrapper` objects are not thread-safe." msgstr ":class:`TextIOWrapper` 物件不是執行緒安全的。" -#: ../../library/io.rst:1275 +#: ../../library/io.rst:1257 msgid "Reentrancy" msgstr "" -#: ../../library/io.rst:1277 +#: ../../library/io.rst:1259 msgid "" "Binary buffered objects (instances of :class:`BufferedReader`, :class:" "`BufferedWriter`, :class:`BufferedRandom` and :class:`BufferedRWPair`) are " @@ -1986,7 +1963,7 @@ msgid "" "from entering the buffered object." msgstr "" -#: ../../library/io.rst:1285 +#: ../../library/io.rst:1267 msgid "" "The above implicitly extends to text files, since the :func:`open` function " "will wrap a buffered object inside a :class:`TextIOWrapper`. This includes " @@ -1994,26 +1971,52 @@ msgid "" "as well." msgstr "" -#: ../../library/io.rst:24 +#: ../../library/io.rst:16 msgid "file object" msgstr "file object(檔案物件)" -#: ../../library/io.rst:24 +#: ../../library/io.rst:16 msgid "io module" msgstr "io 模組" -#: ../../library/io.rst:1016 ../../library/io.rst:1172 +#: ../../library/io.rst:998 ../../library/io.rst:1154 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/io.rst:1016 +#: ../../library/io.rst:998 msgid "io.TextIOWrapper class" msgstr "io.TextIOWrapper 類別" -#: ../../library/io.rst:1172 +#: ../../library/io.rst:1154 msgid "io.IncrementalNewlineDecoder class" msgstr "io.IncrementalNewlineDecoder 類別" +#~ msgid "" +#~ "However, many developers forget to specify the encoding when opening text " +#~ "files encoded in UTF-8 (e.g. JSON, TOML, Markdown, etc...) since most " +#~ "Unix platforms use UTF-8 locale by default. This causes bugs because the " +#~ "locale encoding is not UTF-8 for most Windows users. For example::" +#~ msgstr "" +#~ "然而,許多開發人員在開啟以 UTF-8 編碼的文字檔案(例如:JSON、TOML、" +#~ "Markdown等)時忘記指定編碼,因為多數 Unix 平台預設使用 UTF-8 區域設定。這" +#~ "會導致錯誤,因為對於大多數 Windows 使用者來說,預設地區編碼並非 UTF-8。舉" +#~ "例來說:" + +#~ msgid "" +#~ "Accordingly, it is highly recommended that you specify the encoding " +#~ "explicitly when opening text files. If you want to use UTF-8, pass " +#~ "``encoding=\"utf-8\"``. To use the current locale encoding, " +#~ "``encoding=\"locale\"`` is supported since Python 3.10." +#~ msgstr "" +#~ "因此,強烈建議在開啟文字檔案時,明確指定編碼。若你想使用 UTF-8 編碼,請傳" +#~ "入 ``encoding=\"utf-8\"``。若想使用目前的地區編碼,Python 3.10 以後的版本" +#~ "支援使用 ``encoding=\"locale\"``。" + +#~ msgid "" +#~ "Python UTF-8 Mode can be used to change the default encoding to UTF-8 " +#~ "from locale-specific encoding." +#~ msgstr "在 Python UTF-8 模式下,可以將預設編碼從特定地區編碼改為 UTF-8。" + #~ msgid "" #~ "Read bytes into a pre-allocated, writable :term:`bytes-like object` *b*, " #~ "and return the number of bytes read. For example, *b* might be a :class:" diff --git a/library/ipaddress.po b/library/ipaddress.po index 10e164f97f8..28506910709 100644 --- a/library/ipaddress.po +++ b/library/ipaddress.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-24 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:04+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,17 +21,17 @@ msgstr "" msgid ":mod:`!ipaddress` --- IPv4/IPv6 manipulation library" msgstr ":mod:`!ipaddress` --- IPv4/IPv6 操作函式庫" -#: ../../library/ipaddress.rst:9 +#: ../../library/ipaddress.rst:7 msgid "**Source code:** :source:`Lib/ipaddress.py`" msgstr "**原始碼:**\\ :source:`Lib/ipaddress.py`" -#: ../../library/ipaddress.rst:13 +#: ../../library/ipaddress.rst:11 msgid "" ":mod:`!ipaddress` provides the capabilities to create, manipulate and " "operate on IPv4 and IPv6 addresses and networks." msgstr "" -#: ../../library/ipaddress.rst:16 +#: ../../library/ipaddress.rst:14 msgid "" "The functions and classes in this module make it straightforward to handle " "various tasks related to IP addresses, including checking whether or not two " @@ -40,23 +40,23 @@ msgid "" "network definition, and so on." msgstr "" -#: ../../library/ipaddress.rst:22 +#: ../../library/ipaddress.rst:20 msgid "" "This is the full module API reference—for an overview and introduction, see :" "ref:`ipaddress-howto`." msgstr "" -#: ../../library/ipaddress.rst:35 +#: ../../library/ipaddress.rst:33 msgid "Convenience factory functions" msgstr "" -#: ../../library/ipaddress.rst:37 +#: ../../library/ipaddress.rst:35 msgid "" "The :mod:`!ipaddress` module provides factory functions to conveniently " "create IP addresses, networks and interfaces:" msgstr "" -#: ../../library/ipaddress.rst:42 +#: ../../library/ipaddress.rst:40 msgid "" "Return an :class:`IPv4Address` or :class:`IPv6Address` object depending on " "the IP address passed as argument. Either IPv4 or IPv6 addresses may be " @@ -65,7 +65,7 @@ msgid "" "valid IPv4 or IPv6 address." msgstr "" -#: ../../library/ipaddress.rst:56 +#: ../../library/ipaddress.rst:54 msgid "" "Return an :class:`IPv4Network` or :class:`IPv6Network` object depending on " "the IP address passed as argument. *address* is a string or integer " @@ -76,7 +76,7 @@ msgid "" "a valid IPv4 or IPv6 address, or if the network has host bits set." msgstr "" -#: ../../library/ipaddress.rst:70 +#: ../../library/ipaddress.rst:68 msgid "" "Return an :class:`IPv4Interface` or :class:`IPv6Interface` object depending " "on the IP address passed as argument. *address* is a string or integer " @@ -86,7 +86,7 @@ msgid "" "IPv6 address." msgstr "" -#: ../../library/ipaddress.rst:77 +#: ../../library/ipaddress.rst:75 msgid "" "One downside of these convenience functions is that the need to handle both " "IPv4 and IPv6 formats means that error messages provide minimal information " @@ -95,15 +95,15 @@ msgid "" "calling the appropriate version specific class constructors directly." msgstr "" -#: ../../library/ipaddress.rst:86 +#: ../../library/ipaddress.rst:84 msgid "IP Addresses" msgstr "" -#: ../../library/ipaddress.rst:89 +#: ../../library/ipaddress.rst:87 msgid "Address objects" msgstr "" -#: ../../library/ipaddress.rst:91 +#: ../../library/ipaddress.rst:89 msgid "" "The :class:`IPv4Address` and :class:`IPv6Address` objects share a lot of " "common attributes. Some attributes that are only meaningful for IPv6 " @@ -113,17 +113,17 @@ msgid "" "dictionaries." msgstr "" -#: ../../library/ipaddress.rst:99 +#: ../../library/ipaddress.rst:97 msgid "" "Construct an IPv4 address. An :exc:`AddressValueError` is raised if " "*address* is not a valid IPv4 address." msgstr "" -#: ../../library/ipaddress.rst:102 +#: ../../library/ipaddress.rst:100 msgid "The following constitutes a valid IPv4 address:" msgstr "" -#: ../../library/ipaddress.rst:104 +#: ../../library/ipaddress.rst:102 msgid "" "A string in decimal-dot notation, consisting of four decimal integers in the " "inclusive range 0--255, separated by dots (e.g. ``192.168.0.1``). Each " @@ -131,55 +131,55 @@ msgid "" "tolerated to prevent confusion with octal notation." msgstr "" -#: ../../library/ipaddress.rst:108 +#: ../../library/ipaddress.rst:106 msgid "An integer that fits into 32 bits." msgstr "一個可以放入 32 位元的整數。" -#: ../../library/ipaddress.rst:109 +#: ../../library/ipaddress.rst:107 msgid "" "An integer packed into a :class:`bytes` object of length 4 (most significant " "octet first)." msgstr "" -#: ../../library/ipaddress.rst:121 +#: ../../library/ipaddress.rst:119 msgid "" "Leading zeros are tolerated, even in ambiguous cases that look like octal " "notation." msgstr "" -#: ../../library/ipaddress.rst:126 +#: ../../library/ipaddress.rst:124 msgid "" "Leading zeros are no longer tolerated and are treated as an error. IPv4 " "address strings are now parsed as strict as glibc :func:`~socket.inet_pton`." msgstr "" -#: ../../library/ipaddress.rst:132 +#: ../../library/ipaddress.rst:130 msgid "The appropriate version number: ``4`` for IPv4, ``6`` for IPv6." msgstr "" -#: ../../library/ipaddress.rst:136 ../../library/ipaddress.rst:149 +#: ../../library/ipaddress.rst:134 ../../library/ipaddress.rst:147 msgid "Made available on the class." msgstr "" -#: ../../library/ipaddress.rst:140 +#: ../../library/ipaddress.rst:138 msgid "" "The total number of bits in the address representation for this version: " "``32`` for IPv4, ``128`` for IPv6." msgstr "" -#: ../../library/ipaddress.rst:143 +#: ../../library/ipaddress.rst:141 msgid "" "The prefix defines the number of leading bits in an address that are " "compared to determine whether or not an address is part of a network." msgstr "" -#: ../../library/ipaddress.rst:154 +#: ../../library/ipaddress.rst:152 msgid "" "The string representation in dotted decimal notation. Leading zeroes are " "never included in the representation." msgstr "" -#: ../../library/ipaddress.rst:157 +#: ../../library/ipaddress.rst:155 msgid "" "As IPv4 does not define a shorthand notation for addresses with octets set " "to zero, these two attributes are always the same as ``str(addr)`` for IPv4 " @@ -187,18 +187,18 @@ msgid "" "that can handle both IPv4 and IPv6 addresses." msgstr "" -#: ../../library/ipaddress.rst:164 +#: ../../library/ipaddress.rst:162 msgid "" "The binary representation of this address - a :class:`bytes` object of the " "appropriate length (most significant octet first). This is 4 bytes for IPv4 " "and 16 bytes for IPv6." msgstr "" -#: ../../library/ipaddress.rst:170 +#: ../../library/ipaddress.rst:168 msgid "The name of the reverse DNS PTR record for the IP address, e.g.::" msgstr "" -#: ../../library/ipaddress.rst:172 +#: ../../library/ipaddress.rst:170 msgid "" ">>> ipaddress.ip_address(\"127.0.0.1\").reverse_pointer\n" "'1.0.0.127.in-addr.arpa'\n" @@ -210,67 +210,67 @@ msgstr "" ">>> ipaddress.ip_address(\"2001:db8::1\").reverse_pointer\n" "'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa'" -#: ../../library/ipaddress.rst:177 +#: ../../library/ipaddress.rst:175 msgid "" "This is the name that could be used for performing a PTR lookup, not the " "resolved hostname itself." msgstr "" -#: ../../library/ipaddress.rst:184 +#: ../../library/ipaddress.rst:182 msgid "" "``True`` if the address is reserved for multicast use. See :RFC:`3171` (for " "IPv4) or :RFC:`2373` (for IPv6)." msgstr "" -#: ../../library/ipaddress.rst:189 +#: ../../library/ipaddress.rst:187 msgid "" "``True`` if the address is defined as not globally reachable by iana-ipv4-" "special-registry_ (for IPv4) or iana-ipv6-special-registry_ (for IPv6) with " "the following exceptions:" msgstr "" -#: ../../library/ipaddress.rst:193 +#: ../../library/ipaddress.rst:191 msgid "" "``is_private`` is ``False`` for the shared address space (``100.64.0.0/10``)" msgstr "" -#: ../../library/ipaddress.rst:194 ../../library/ipaddress.rst:221 +#: ../../library/ipaddress.rst:192 ../../library/ipaddress.rst:219 msgid "" "For IPv4-mapped IPv6-addresses the ``is_private`` value is determined by the " "semantics of the underlying IPv4 addresses and the following condition holds " "(see :attr:`IPv6Address.ipv4_mapped`)::" msgstr "" -#: ../../library/ipaddress.rst:198 +#: ../../library/ipaddress.rst:196 msgid "address.is_private == address.ipv4_mapped.is_private" msgstr "address.is_private == address.ipv4_mapped.is_private" -#: ../../library/ipaddress.rst:200 +#: ../../library/ipaddress.rst:198 msgid "" "``is_private`` has value opposite to :attr:`is_global`, except for the " "shared address space (``100.64.0.0/10`` range) where they are both ``False``." msgstr "" -#: ../../library/ipaddress.rst:205 +#: ../../library/ipaddress.rst:203 msgid "Fixed some false positives and false negatives." msgstr "" -#: ../../library/ipaddress.rst:207 +#: ../../library/ipaddress.rst:205 msgid "" "``192.0.0.0/24`` is considered private with the exception of " "``192.0.0.9/32`` and ``192.0.0.10/32`` (previously: only the " "``192.0.0.0/29`` sub-range was considered private)." msgstr "" -#: ../../library/ipaddress.rst:209 +#: ../../library/ipaddress.rst:207 msgid "``64:ff9b:1::/48`` is considered private." msgstr "``64:ff9b:1::/48`` 被視為私有。" -#: ../../library/ipaddress.rst:210 +#: ../../library/ipaddress.rst:208 msgid "``2002::/16`` is considered private." msgstr "``2002::/16`` 被視為私有。" -#: ../../library/ipaddress.rst:211 +#: ../../library/ipaddress.rst:209 msgid "" "There are exceptions within ``2001::/23`` (otherwise considered private): " "``2001:1::1/128``, ``2001:1::2/128``, ``2001:3::/32``, ``2001:4:112::/48``, " @@ -278,36 +278,36 @@ msgid "" "private." msgstr "" -#: ../../library/ipaddress.rst:217 +#: ../../library/ipaddress.rst:215 msgid "" "``True`` if the address is defined as globally reachable by iana-ipv4-" "special-registry_ (for IPv4) or iana-ipv6-special-registry_ (for IPv6) with " "the following exception:" msgstr "" -#: ../../library/ipaddress.rst:225 +#: ../../library/ipaddress.rst:223 msgid "address.is_global == address.ipv4_mapped.is_global" msgstr "address.is_global == address.ipv4_mapped.is_global" -#: ../../library/ipaddress.rst:227 +#: ../../library/ipaddress.rst:225 msgid "" "``is_global`` has value opposite to :attr:`is_private`, except for the " "shared address space (``100.64.0.0/10`` range) where they are both ``False``." msgstr "" -#: ../../library/ipaddress.rst:234 +#: ../../library/ipaddress.rst:232 msgid "" "Fixed some false positives and false negatives, see :attr:`is_private` for " "details." msgstr "" -#: ../../library/ipaddress.rst:238 +#: ../../library/ipaddress.rst:236 msgid "" "``True`` if the address is unspecified. See :RFC:`5735` (for IPv4) or :RFC:" "`2373` (for IPv6)." msgstr "" -#: ../../library/ipaddress.rst:243 +#: ../../library/ipaddress.rst:241 msgid "" "``True`` if the address is noted as reserved by the IETF. For IPv4, this is " "only ``240.0.0.0/4``, the ``Reserved`` address block. For IPv6, this is all " @@ -315,37 +315,37 @@ msgid "" "for future use." msgstr "" -#: ../../library/ipaddress.rst:248 +#: ../../library/ipaddress.rst:246 msgid "" "For IPv4, ``is_reserved`` is not related to the address block value of the " "``Reserved-by-Protocol`` column in iana-ipv4-special-registry_." msgstr "" -#: ../../library/ipaddress.rst:251 +#: ../../library/ipaddress.rst:249 msgid "" "For IPv6, ``fec0::/10`` a former Site-Local scoped address prefix is " "currently excluded from that list (see :attr:`~IPv6Address.is_site_local` & :" "rfc:`3879`)." msgstr "" -#: ../../library/ipaddress.rst:256 +#: ../../library/ipaddress.rst:254 msgid "" "``True`` if this is a loopback address. See :RFC:`3330` (for IPv4) or :RFC:" "`2373` (for IPv6)." msgstr "" -#: ../../library/ipaddress.rst:261 +#: ../../library/ipaddress.rst:259 msgid "" "``True`` if the address is reserved for link-local usage. See :RFC:`3927`." msgstr "" -#: ../../library/ipaddress.rst:266 +#: ../../library/ipaddress.rst:264 msgid "" ":class:`IPv6Address` object representing the IPv4-mapped IPv6 address. See :" "RFC:`4291`." msgstr "" -#: ../../library/ipaddress.rst:277 +#: ../../library/ipaddress.rst:275 msgid "" "Returns a string representation of the IP address, controlled by an explicit " "format string. *fmt* can be one of the following: ``'s'``, the default " @@ -357,17 +357,17 @@ msgid "" "used by ``format``, ``str.format`` and f-strings." msgstr "" -#: ../../library/ipaddress.rst:304 +#: ../../library/ipaddress.rst:302 msgid "" "Construct an IPv6 address. An :exc:`AddressValueError` is raised if " "*address* is not a valid IPv6 address." msgstr "" -#: ../../library/ipaddress.rst:307 +#: ../../library/ipaddress.rst:305 msgid "The following constitutes a valid IPv6 address:" msgstr "" -#: ../../library/ipaddress.rst:309 +#: ../../library/ipaddress.rst:307 msgid "" "A string consisting of eight groups of four hexadecimal digits, each group " "representing 16 bits. The groups are separated by colons. This describes an " @@ -377,7 +377,7 @@ msgid "" "to ``\"::abc:7:def\"``." msgstr "" -#: ../../library/ipaddress.rst:317 +#: ../../library/ipaddress.rst:315 msgid "" "Optionally, the string may also have a scope zone ID, expressed with a " "suffix ``%scope_id``. If present, the scope ID must be non-empty, and may " @@ -386,39 +386,39 @@ msgid "" "the node." msgstr "" -#: ../../library/ipaddress.rst:322 +#: ../../library/ipaddress.rst:320 msgid "An integer that fits into 128 bits." msgstr "一個可以放入 128 位元的整數。" -#: ../../library/ipaddress.rst:323 +#: ../../library/ipaddress.rst:321 msgid "" "An integer packed into a :class:`bytes` object of length 16, big-endian." msgstr "" -#: ../../library/ipaddress.rst:333 +#: ../../library/ipaddress.rst:331 msgid "" "The short form of the address representation, with leading zeroes in groups " "omitted and the longest sequence of groups consisting entirely of zeroes " "collapsed to a single empty group." msgstr "" -#: ../../library/ipaddress.rst:337 +#: ../../library/ipaddress.rst:335 msgid "This is also the value returned by ``str(addr)`` for IPv6 addresses." msgstr "" -#: ../../library/ipaddress.rst:341 +#: ../../library/ipaddress.rst:339 msgid "" "The long form of the address representation, with all leading zeroes and " "groups consisting entirely of zeroes included." msgstr "" -#: ../../library/ipaddress.rst:345 +#: ../../library/ipaddress.rst:343 msgid "" "For the following attributes and methods, see the corresponding " "documentation of the :class:`IPv4Address` class:" msgstr "" -#: ../../library/ipaddress.rst:365 +#: ../../library/ipaddress.rst:363 msgid "" "``True`` if the address is reserved for site-local usage. Note that the " "site-local address space has been deprecated by :RFC:`3879`. Use :attr:" @@ -426,21 +426,21 @@ msgid "" "local addresses as defined by :RFC:`4193`." msgstr "" -#: ../../library/ipaddress.rst:372 +#: ../../library/ipaddress.rst:370 msgid "" "For addresses that appear to be IPv4 mapped addresses in the range ``::" "FFFF:0:0/96`` as defined by :RFC:`4291`, this property reports the embedded " "IPv4 address. For any other address, this property will be ``None``." msgstr "" -#: ../../library/ipaddress.rst:378 +#: ../../library/ipaddress.rst:376 msgid "" "For scoped addresses as defined by :RFC:`4007`, this property identifies the " "particular zone of the address's scope that the address belongs to, as a " "string. When no scope zone is specified, this property will be ``None``." msgstr "" -#: ../../library/ipaddress.rst:384 +#: ../../library/ipaddress.rst:382 msgid "" "For addresses that appear to be 6to4 addresses (starting with " "``2002::/16``) as defined by :RFC:`3056`, this property will report the " @@ -448,7 +448,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/ipaddress.rst:391 +#: ../../library/ipaddress.rst:389 msgid "" "For addresses that appear to be Teredo addresses (starting with " "``2001::/32``) as defined by :RFC:`4380`, this property will report the " @@ -456,23 +456,23 @@ msgid "" "property will be ``None``." msgstr "" -#: ../../library/ipaddress.rst:398 +#: ../../library/ipaddress.rst:396 msgid "" "Refer to the corresponding method documentation in :class:`IPv4Address`." msgstr "" -#: ../../library/ipaddress.rst:404 +#: ../../library/ipaddress.rst:402 msgid "Conversion to Strings and Integers" msgstr "" -#: ../../library/ipaddress.rst:406 +#: ../../library/ipaddress.rst:404 msgid "" "To interoperate with networking interfaces such as the socket module, " "addresses must be converted to strings or integers. This is handled using " "the :func:`str` and :func:`int` builtin functions::" msgstr "" -#: ../../library/ipaddress.rst:410 +#: ../../library/ipaddress.rst:408 msgid "" ">>> str(ipaddress.IPv4Address('192.168.0.1'))\n" "'192.168.0.1'\n" @@ -492,36 +492,36 @@ msgstr "" ">>> int(ipaddress.IPv6Address('::1'))\n" "1" -#: ../../library/ipaddress.rst:419 +#: ../../library/ipaddress.rst:417 msgid "" "Note that IPv6 scoped addresses are converted to integers without scope zone " "ID." msgstr "" -#: ../../library/ipaddress.rst:423 ../../library/ipaddress.rst:807 -#: ../../library/ipaddress.rst:943 +#: ../../library/ipaddress.rst:421 ../../library/ipaddress.rst:805 +#: ../../library/ipaddress.rst:941 msgid "Operators" msgstr "運算子" -#: ../../library/ipaddress.rst:425 +#: ../../library/ipaddress.rst:423 msgid "" "Address objects support some operators. Unless stated otherwise, operators " "can only be applied between compatible objects (i.e. IPv4 with IPv4, IPv6 " "with IPv6)." msgstr "" -#: ../../library/ipaddress.rst:431 +#: ../../library/ipaddress.rst:429 msgid "Comparison operators" msgstr "比較運算子" -#: ../../library/ipaddress.rst:433 +#: ../../library/ipaddress.rst:431 msgid "" "Address objects can be compared with the usual set of comparison operators. " "Same IPv6 addresses with different scope zone IDs are not equal. Some " "examples::" msgstr "" -#: ../../library/ipaddress.rst:437 +#: ../../library/ipaddress.rst:435 msgid "" ">>> IPv4Address('127.0.0.2') > IPv4Address('127.0.0.1')\n" "True\n" @@ -545,16 +545,16 @@ msgstr "" ">>> IPv6Address('fe80::1234%1') != IPv6Address('fe80::1234%2')\n" "True" -#: ../../library/ipaddress.rst:450 +#: ../../library/ipaddress.rst:448 msgid "Arithmetic operators" msgstr "算術運算子" -#: ../../library/ipaddress.rst:452 +#: ../../library/ipaddress.rst:450 msgid "" "Integers can be added to or subtracted from address objects. Some examples::" msgstr "" -#: ../../library/ipaddress.rst:454 +#: ../../library/ipaddress.rst:452 msgid "" ">>> IPv4Address('127.0.0.2') + 3\n" "IPv4Address('127.0.0.5')\n" @@ -576,11 +576,11 @@ msgstr "" "ipaddress.AddressValueError: 4294967296 (>= 2**32) is not permitted as an " "IPv4 address" -#: ../../library/ipaddress.rst:465 +#: ../../library/ipaddress.rst:463 msgid "IP Network definitions" msgstr "" -#: ../../library/ipaddress.rst:467 +#: ../../library/ipaddress.rst:465 msgid "" "The :class:`IPv4Network` and :class:`IPv6Network` objects provide a " "mechanism for defining and inspecting IP network definitions. A network " @@ -591,11 +591,11 @@ msgid "" "addresses in the inclusive range ``192.168.1.0`` to ``192.168.1.255``." msgstr "" -#: ../../library/ipaddress.rst:477 +#: ../../library/ipaddress.rst:475 msgid "Prefix, net mask and host mask" msgstr "" -#: ../../library/ipaddress.rst:479 +#: ../../library/ipaddress.rst:477 msgid "" "There are several equivalent ways to specify IP network masks. A *prefix* " "``/`` is a notation that denotes how many high-order bits are set in " @@ -607,11 +607,11 @@ msgid "" "mask equivalent to ``/24`` in IPv4 is ``0.0.0.255``." msgstr "" -#: ../../library/ipaddress.rst:490 +#: ../../library/ipaddress.rst:488 msgid "Network objects" msgstr "" -#: ../../library/ipaddress.rst:492 +#: ../../library/ipaddress.rst:490 msgid "" "All attributes implemented by address objects are implemented by network " "objects as well. In addition, network objects implement additional " @@ -621,12 +621,12 @@ msgid "" "keys in dictionaries." msgstr "" -#: ../../library/ipaddress.rst:501 +#: ../../library/ipaddress.rst:499 msgid "" "Construct an IPv4 network definition. *address* can be one of the following:" msgstr "" -#: ../../library/ipaddress.rst:503 +#: ../../library/ipaddress.rst:501 msgid "" "A string consisting of an IP address and an optional mask, separated by a " "slash (``/``). The IP address is the network address, and the mask can be " @@ -638,26 +638,26 @@ msgid "" "it's considered to be ``/32``." msgstr "" -#: ../../library/ipaddress.rst:512 +#: ../../library/ipaddress.rst:510 msgid "" "For example, the following *address* specifications are equivalent: " "``192.168.1.0/24``, ``192.168.1.0/255.255.255.0`` and " "``192.168.1.0/0.0.0.255``." msgstr "" -#: ../../library/ipaddress.rst:516 +#: ../../library/ipaddress.rst:514 msgid "" "An integer that fits into 32 bits. This is equivalent to a single-address " "network, with the network address being *address* and the mask being ``/32``." msgstr "" -#: ../../library/ipaddress.rst:520 +#: ../../library/ipaddress.rst:518 msgid "" "An integer packed into a :class:`bytes` object of length 4, big-endian. The " "interpretation is similar to an integer *address*." msgstr "" -#: ../../library/ipaddress.rst:523 +#: ../../library/ipaddress.rst:521 msgid "" "A two-tuple of an address description and a netmask, where the address " "description is either a string, a 32-bits integer, a 4-bytes packed integer, " @@ -666,92 +666,92 @@ msgid "" "representing the prefix mask (e.g. ``255.255.255.0``)." msgstr "" -#: ../../library/ipaddress.rst:529 +#: ../../library/ipaddress.rst:527 msgid "" "An :exc:`AddressValueError` is raised if *address* is not a valid IPv4 " "address. A :exc:`NetmaskValueError` is raised if the mask is not valid for " "an IPv4 address." msgstr "" -#: ../../library/ipaddress.rst:533 ../../library/ipaddress.rst:753 +#: ../../library/ipaddress.rst:531 ../../library/ipaddress.rst:751 msgid "" "If *strict* is ``True`` and host bits are set in the supplied address, then :" "exc:`ValueError` is raised. Otherwise, the host bits are masked out to " "determine the appropriate network address." msgstr "" -#: ../../library/ipaddress.rst:537 +#: ../../library/ipaddress.rst:535 msgid "" "Unless stated otherwise, all network methods accepting other network/address " "objects will raise :exc:`TypeError` if the argument's IP version is " "incompatible to ``self``." msgstr "" -#: ../../library/ipaddress.rst:543 ../../library/ipaddress.rst:759 +#: ../../library/ipaddress.rst:541 ../../library/ipaddress.rst:757 msgid "Added the two-tuple form for the *address* constructor parameter." msgstr "" -#: ../../library/ipaddress.rst:548 +#: ../../library/ipaddress.rst:546 msgid "" "Refer to the corresponding attribute documentation in :class:`IPv4Address`." msgstr "" -#: ../../library/ipaddress.rst:558 +#: ../../library/ipaddress.rst:556 msgid "" "These attributes are true for the network as a whole if they are true for " "both the network address and the broadcast address." msgstr "" -#: ../../library/ipaddress.rst:563 +#: ../../library/ipaddress.rst:561 msgid "" "The network address for the network. The network address and the prefix " "length together uniquely define a network." msgstr "" -#: ../../library/ipaddress.rst:568 +#: ../../library/ipaddress.rst:566 msgid "" "The broadcast address for the network. Packets sent to the broadcast address " "should be received by every host on the network." msgstr "" -#: ../../library/ipaddress.rst:573 +#: ../../library/ipaddress.rst:571 msgid "The host mask, as an :class:`IPv4Address` object." msgstr "" -#: ../../library/ipaddress.rst:577 +#: ../../library/ipaddress.rst:575 msgid "The net mask, as an :class:`IPv4Address` object." msgstr "" -#: ../../library/ipaddress.rst:583 +#: ../../library/ipaddress.rst:581 msgid "" "A string representation of the network, with the mask in prefix notation." msgstr "" -#: ../../library/ipaddress.rst:586 +#: ../../library/ipaddress.rst:584 msgid "" "``with_prefixlen`` and ``compressed`` are always the same as " "``str(network)``. ``exploded`` uses the exploded form the network address." msgstr "" -#: ../../library/ipaddress.rst:592 +#: ../../library/ipaddress.rst:590 msgid "" "A string representation of the network, with the mask in net mask notation." msgstr "" -#: ../../library/ipaddress.rst:597 +#: ../../library/ipaddress.rst:595 msgid "" "A string representation of the network, with the mask in host mask notation." msgstr "" -#: ../../library/ipaddress.rst:602 +#: ../../library/ipaddress.rst:600 msgid "The total number of addresses in the network." msgstr "" -#: ../../library/ipaddress.rst:606 +#: ../../library/ipaddress.rst:604 msgid "Length of the network prefix, in bits." msgstr "" -#: ../../library/ipaddress.rst:610 +#: ../../library/ipaddress.rst:608 msgid "" "Returns an iterator over the usable hosts in the network. The usable hosts " "are all the IP addresses that belong to the network, except the network " @@ -761,20 +761,20 @@ msgid "" "containing the single host address." msgstr "" -#: ../../library/ipaddress.rst:628 +#: ../../library/ipaddress.rst:626 msgid "" "``True`` if this network is partly or wholly contained in *other* or *other* " "is wholly contained in this network." msgstr "" -#: ../../library/ipaddress.rst:633 +#: ../../library/ipaddress.rst:631 msgid "" "Computes the network definitions resulting from removing the given *network* " "from this one. Returns an iterator of network objects. Raises :exc:" "`ValueError` if *network* is not completely contained in this network." msgstr "" -#: ../../library/ipaddress.rst:646 +#: ../../library/ipaddress.rst:644 msgid "" "The subnets that join to make the current network definition, depending on " "the argument values. *prefixlen_diff* is the amount our prefix length " @@ -784,7 +784,7 @@ msgid "" "network objects." msgstr "" -#: ../../library/ipaddress.rst:671 +#: ../../library/ipaddress.rst:669 msgid "" "The supernet containing this network definition, depending on the argument " "values. *prefixlen_diff* is the amount our prefix length should be " @@ -793,33 +793,33 @@ msgid "" "*new_prefix* must be set. Returns a single network object." msgstr "" -#: ../../library/ipaddress.rst:687 +#: ../../library/ipaddress.rst:685 msgid "Return ``True`` if this network is a subnet of *other*." msgstr "" -#: ../../library/ipaddress.rst:698 +#: ../../library/ipaddress.rst:696 msgid "Return ``True`` if this network is a supernet of *other*." msgstr "" -#: ../../library/ipaddress.rst:709 +#: ../../library/ipaddress.rst:707 msgid "" "Compare this network to *other*. In this comparison only the network " "addresses are considered; host bits aren't. Returns either ``-1``, ``0`` or " "``1``." msgstr "" -#: ../../library/ipaddress.rst:720 +#: ../../library/ipaddress.rst:718 msgid "" "It uses the same ordering and comparison algorithm as \"<\", \"==\", and " "\">\"" msgstr "" -#: ../../library/ipaddress.rst:726 +#: ../../library/ipaddress.rst:724 msgid "" "Construct an IPv6 network definition. *address* can be one of the following:" msgstr "" -#: ../../library/ipaddress.rst:728 +#: ../../library/ipaddress.rst:726 msgid "" "A string consisting of an IP address and an optional prefix length, " "separated by a slash (``/``). The IP address is the network address, and " @@ -827,26 +827,26 @@ msgid "" "length is provided, it's considered to be ``/128``." msgstr "" -#: ../../library/ipaddress.rst:733 +#: ../../library/ipaddress.rst:731 msgid "" "Note that currently expanded netmasks are not supported. That means ``2001:" "db00::0/24`` is a valid argument while ``2001:db00::0/ffff:ff00::`` is not." msgstr "" -#: ../../library/ipaddress.rst:737 +#: ../../library/ipaddress.rst:735 msgid "" "An integer that fits into 128 bits. This is equivalent to a single-address " "network, with the network address being *address* and the mask being " "``/128``." msgstr "" -#: ../../library/ipaddress.rst:741 +#: ../../library/ipaddress.rst:739 msgid "" "An integer packed into a :class:`bytes` object of length 16, big-endian. The " "interpretation is similar to an integer *address*." msgstr "" -#: ../../library/ipaddress.rst:744 +#: ../../library/ipaddress.rst:742 msgid "" "A two-tuple of an address description and a netmask, where the address " "description is either a string, a 128-bits integer, a 16-bytes packed " @@ -854,14 +854,14 @@ msgid "" "integer representing the prefix length." msgstr "" -#: ../../library/ipaddress.rst:749 +#: ../../library/ipaddress.rst:747 msgid "" "An :exc:`AddressValueError` is raised if *address* is not a valid IPv6 " "address. A :exc:`NetmaskValueError` is raised if the mask is not valid for " "an IPv6 address." msgstr "" -#: ../../library/ipaddress.rst:782 +#: ../../library/ipaddress.rst:780 msgid "" "Returns an iterator over the usable hosts in the network. The usable hosts " "are all the IP addresses that belong to the network, except the Subnet-" @@ -870,46 +870,46 @@ msgid "" "of 128 will return a list containing the single host address." msgstr "" -#: ../../library/ipaddress.rst:797 +#: ../../library/ipaddress.rst:795 msgid "" "Refer to the corresponding attribute documentation in :class:`IPv4Network`." msgstr "" -#: ../../library/ipaddress.rst:802 +#: ../../library/ipaddress.rst:800 msgid "" "This attribute is true for the network as a whole if it is true for both the " "network address and the broadcast address." msgstr "" -#: ../../library/ipaddress.rst:809 +#: ../../library/ipaddress.rst:807 msgid "" "Network objects support some operators. Unless stated otherwise, operators " "can only be applied between compatible objects (i.e. IPv4 with IPv4, IPv6 " "with IPv6)." msgstr "" -#: ../../library/ipaddress.rst:815 ../../library/ipaddress.rst:951 +#: ../../library/ipaddress.rst:813 ../../library/ipaddress.rst:949 msgid "Logical operators" msgstr "" -#: ../../library/ipaddress.rst:817 +#: ../../library/ipaddress.rst:815 msgid "" "Network objects can be compared with the usual set of logical operators. " "Network objects are ordered first by network address, then by net mask." msgstr "" -#: ../../library/ipaddress.rst:822 +#: ../../library/ipaddress.rst:820 msgid "Iteration" msgstr "疊代" -#: ../../library/ipaddress.rst:824 +#: ../../library/ipaddress.rst:822 msgid "" "Network objects can be iterated to list all the addresses belonging to the " "network. For iteration, *all* hosts are returned, including unusable hosts " "(for usable hosts, use the :meth:`~IPv4Network.hosts` method). An example::" msgstr "" -#: ../../library/ipaddress.rst:829 +#: ../../library/ipaddress.rst:827 msgid "" ">>> for addr in IPv4Network('192.0.2.0/28'):\n" "... addr\n" @@ -951,15 +951,15 @@ msgstr "" "IPv4Address('192.0.2.14')\n" "IPv4Address('192.0.2.15')" -#: ../../library/ipaddress.rst:851 +#: ../../library/ipaddress.rst:849 msgid "Networks as containers of addresses" msgstr "" -#: ../../library/ipaddress.rst:853 +#: ../../library/ipaddress.rst:851 msgid "Network objects can act as containers of addresses. Some examples::" msgstr "" -#: ../../library/ipaddress.rst:855 +#: ../../library/ipaddress.rst:853 msgid "" ">>> IPv4Network('192.0.2.0/28')[0]\n" "IPv4Address('192.0.2.0')\n" @@ -979,92 +979,92 @@ msgstr "" ">>> IPv4Address('192.0.3.6') in IPv4Network('192.0.2.0/28')\n" "False" -#: ../../library/ipaddress.rst:866 +#: ../../library/ipaddress.rst:864 msgid "Interface objects" msgstr "" -#: ../../library/ipaddress.rst:868 +#: ../../library/ipaddress.rst:866 msgid "" "Interface objects are :term:`hashable`, so they can be used as keys in " "dictionaries." msgstr "" -#: ../../library/ipaddress.rst:873 +#: ../../library/ipaddress.rst:871 msgid "" "Construct an IPv4 interface. The meaning of *address* is as in the " "constructor of :class:`IPv4Network`, except that arbitrary host addresses " "are always accepted." msgstr "" -#: ../../library/ipaddress.rst:877 +#: ../../library/ipaddress.rst:875 msgid "" ":class:`IPv4Interface` is a subclass of :class:`IPv4Address`, so it inherits " "all the attributes from that class. In addition, the following attributes " "are available:" msgstr "" -#: ../../library/ipaddress.rst:883 +#: ../../library/ipaddress.rst:881 msgid "The address (:class:`IPv4Address`) without network information." msgstr "" -#: ../../library/ipaddress.rst:891 +#: ../../library/ipaddress.rst:889 msgid "The network (:class:`IPv4Network`) this interface belongs to." msgstr "" -#: ../../library/ipaddress.rst:899 +#: ../../library/ipaddress.rst:897 msgid "" "A string representation of the interface with the mask in prefix notation." msgstr "" -#: ../../library/ipaddress.rst:907 +#: ../../library/ipaddress.rst:905 msgid "" "A string representation of the interface with the network as a net mask." msgstr "" -#: ../../library/ipaddress.rst:915 +#: ../../library/ipaddress.rst:913 msgid "" "A string representation of the interface with the network as a host mask." msgstr "" -#: ../../library/ipaddress.rst:924 +#: ../../library/ipaddress.rst:922 msgid "" "Construct an IPv6 interface. The meaning of *address* is as in the " "constructor of :class:`IPv6Network`, except that arbitrary host addresses " "are always accepted." msgstr "" -#: ../../library/ipaddress.rst:928 +#: ../../library/ipaddress.rst:926 msgid "" ":class:`IPv6Interface` is a subclass of :class:`IPv6Address`, so it inherits " "all the attributes from that class. In addition, the following attributes " "are available:" msgstr "" -#: ../../library/ipaddress.rst:938 +#: ../../library/ipaddress.rst:936 msgid "" "Refer to the corresponding attribute documentation in :class:`IPv4Interface`." msgstr "" -#: ../../library/ipaddress.rst:945 +#: ../../library/ipaddress.rst:943 msgid "" "Interface objects support some operators. Unless stated otherwise, " "operators can only be applied between compatible objects (i.e. IPv4 with " "IPv4, IPv6 with IPv6)." msgstr "" -#: ../../library/ipaddress.rst:953 +#: ../../library/ipaddress.rst:951 msgid "" "Interface objects can be compared with the usual set of logical operators." msgstr "" -#: ../../library/ipaddress.rst:955 +#: ../../library/ipaddress.rst:953 msgid "" "For equality comparison (``==`` and ``!=``), both the IP address and network " "must be the same for the objects to be equal. An interface will not compare " "equal to any address or network object." msgstr "" -#: ../../library/ipaddress.rst:959 +#: ../../library/ipaddress.rst:957 msgid "" "For ordering (``<``, ``>``, etc) the rules are different. Interface and " "address objects with the same IP version can be compared, and the address " @@ -1073,15 +1073,15 @@ msgid "" "then by their IP addresses." msgstr "" -#: ../../library/ipaddress.rst:967 +#: ../../library/ipaddress.rst:965 msgid "Other Module Level Functions" msgstr "" -#: ../../library/ipaddress.rst:969 +#: ../../library/ipaddress.rst:967 msgid "The module also provides the following module level functions:" msgstr "" -#: ../../library/ipaddress.rst:973 +#: ../../library/ipaddress.rst:971 msgid "" "Represent an address as 4 packed bytes in network (big-endian) order. " "*address* is an integer representation of an IPv4 IP address. A :exc:" @@ -1089,7 +1089,7 @@ msgid "" "IP address." msgstr "" -#: ../../library/ipaddress.rst:986 +#: ../../library/ipaddress.rst:984 msgid "" "Represent an address as 16 packed bytes in network (big-endian) order. " "*address* is an integer representation of an IPv6 IP address. A :exc:" @@ -1097,7 +1097,7 @@ msgid "" "IP address." msgstr "" -#: ../../library/ipaddress.rst:994 +#: ../../library/ipaddress.rst:992 msgid "" "Return an iterator of the summarized network range given the first and last " "IP addresses. *first* is the first :class:`IPv4Address` or :class:" @@ -1108,7 +1108,7 @@ msgid "" "address version is not 4 or 6." msgstr "" -#: ../../library/ipaddress.rst:1010 +#: ../../library/ipaddress.rst:1008 msgid "" "Return an iterator of the collapsed :class:`IPv4Network` or :class:" "`IPv6Network` objects. *addresses* is an :term:`iterable` of :class:" @@ -1116,43 +1116,43 @@ msgid "" "if *addresses* contains mixed version objects." msgstr "" -#: ../../library/ipaddress.rst:1023 +#: ../../library/ipaddress.rst:1021 msgid "" "Return a key suitable for sorting between networks and addresses. Address " "and Network objects are not sortable by default; they're fundamentally " "different, so the expression::" msgstr "" -#: ../../library/ipaddress.rst:1027 +#: ../../library/ipaddress.rst:1025 msgid "IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24')" msgstr "IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24')" -#: ../../library/ipaddress.rst:1029 +#: ../../library/ipaddress.rst:1027 msgid "" "doesn't make sense. There are some times however, where you may wish to " "have :mod:`!ipaddress` sort these anyway. If you need to do this, you can " "use this function as the *key* argument to :func:`sorted`." msgstr "" -#: ../../library/ipaddress.rst:1033 +#: ../../library/ipaddress.rst:1031 msgid "*obj* is either a network or address object." msgstr "" -#: ../../library/ipaddress.rst:1037 +#: ../../library/ipaddress.rst:1035 msgid "Custom Exceptions" msgstr "" -#: ../../library/ipaddress.rst:1039 +#: ../../library/ipaddress.rst:1037 msgid "" "To support more specific error reporting from class constructors, the module " "defines the following exceptions:" msgstr "" -#: ../../library/ipaddress.rst:1044 +#: ../../library/ipaddress.rst:1042 msgid "Any value error related to the address." msgstr "" -#: ../../library/ipaddress.rst:1049 +#: ../../library/ipaddress.rst:1047 msgid "Any value error related to the net mask." msgstr "" diff --git a/library/itertools.po b/library/itertools.po index f0afbfe3e69..4ac2d6f9881 100644 --- a/library/itertools.po +++ b/library/itertools.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-08-16 15:01+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,7 +23,7 @@ msgid "" ":mod:`!itertools` --- Functions creating iterators for efficient looping" msgstr ":mod:`!itertools` --- 建立產生高效率迴圈之疊代器的函式" -#: ../../library/itertools.rst:20 +#: ../../library/itertools.rst:17 msgid "" "This module implements a number of :term:`iterator` building blocks inspired " "by constructs from APL, Haskell, and SML. Each has been recast in a form " @@ -33,7 +33,7 @@ msgstr "" "block),其靈感來自 APL、Haskell 和 SML 的結構。每個構建塊都以適合 Python 的形" "式來重新設計。" -#: ../../library/itertools.rst:24 +#: ../../library/itertools.rst:21 msgid "" "The module standardizes a core set of fast, memory efficient tools that are " "useful by themselves or in combination. Together, they form an \"iterator " @@ -44,7 +44,7 @@ msgstr "" "很有用。它們共同構成了一個「疊代器代數 (iterator algebra)」,使得在純 Python " "中簡潔且高效地建構專用工具成為可能。" -#: ../../library/itertools.rst:29 +#: ../../library/itertools.rst:26 msgid "" "For instance, SML provides a tabulation tool: ``tabulate(f)`` which produces " "a sequence ``f(0), f(1), ...``. The same effect can be achieved in Python " @@ -54,369 +54,369 @@ msgstr "" "f(1), ...``。在 Python 中,可以透過結合 :func:`map` 和 :func:`count` 組成 " "``map(f, count())`` 以達到同樣的效果。" -#: ../../library/itertools.rst:33 +#: ../../library/itertools.rst:30 msgid "**General iterators:**" msgstr "**一般疊代器:**" -#: ../../library/itertools.rst:36 ../../library/itertools.rst:60 +#: ../../library/itertools.rst:33 ../../library/itertools.rst:57 msgid "Iterator" msgstr "疊代器" -#: ../../library/itertools.rst:36 ../../library/itertools.rst:60 +#: ../../library/itertools.rst:33 ../../library/itertools.rst:57 msgid "Arguments" msgstr "引數" -#: ../../library/itertools.rst:36 ../../library/itertools.rst:60 -#: ../../library/itertools.rst:69 +#: ../../library/itertools.rst:33 ../../library/itertools.rst:57 +#: ../../library/itertools.rst:66 msgid "Results" msgstr "結果" -#: ../../library/itertools.rst:36 +#: ../../library/itertools.rst:33 msgid "Example" msgstr "範例" -#: ../../library/itertools.rst:38 +#: ../../library/itertools.rst:35 msgid ":func:`accumulate`" msgstr ":func:`accumulate`" -#: ../../library/itertools.rst:38 +#: ../../library/itertools.rst:35 msgid "p [,func]" msgstr "p [,func]" -#: ../../library/itertools.rst:38 +#: ../../library/itertools.rst:35 msgid "p0, p0+p1, p0+p1+p2, ..." msgstr "p0, p0+p1, p0+p1+p2, ..." -#: ../../library/itertools.rst:38 +#: ../../library/itertools.rst:35 msgid "``accumulate([1,2,3,4,5]) → 1 3 6 10 15``" msgstr "``accumulate([1,2,3,4,5]) → 1 3 6 10 15``" -#: ../../library/itertools.rst:39 +#: ../../library/itertools.rst:36 msgid ":func:`batched`" msgstr ":func:`batched`" -#: ../../library/itertools.rst:39 +#: ../../library/itertools.rst:36 msgid "p, n" msgstr "p, n" -#: ../../library/itertools.rst:39 +#: ../../library/itertools.rst:36 msgid "(p0, p1, ..., p_n-1), ..." msgstr "(p0, p1, ..., p_n-1), ..." -#: ../../library/itertools.rst:39 +#: ../../library/itertools.rst:36 msgid "``batched('ABCDEFG', n=3) → ABC DEF G``" msgstr "``batched('ABCDEFG', n=3) → ABC DEF G``" -#: ../../library/itertools.rst:40 +#: ../../library/itertools.rst:37 msgid ":func:`chain`" msgstr ":func:`chain`" -#: ../../library/itertools.rst:40 ../../library/itertools.rst:54 +#: ../../library/itertools.rst:37 ../../library/itertools.rst:51 msgid "p, q, ..." msgstr "p, q, ..." -#: ../../library/itertools.rst:40 ../../library/itertools.rst:41 +#: ../../library/itertools.rst:37 ../../library/itertools.rst:38 msgid "p0, p1, ... plast, q0, q1, ..." msgstr "p0, p1, ... plast, q0, q1, ..." -#: ../../library/itertools.rst:40 +#: ../../library/itertools.rst:37 msgid "``chain('ABC', 'DEF') → A B C D E F``" msgstr "``chain('ABC', 'DEF') → A B C D E F``" -#: ../../library/itertools.rst:41 +#: ../../library/itertools.rst:38 msgid ":func:`chain.from_iterable`" msgstr ":func:`chain.from_iterable`" -#: ../../library/itertools.rst:41 ../../library/itertools.rst:49 +#: ../../library/itertools.rst:38 ../../library/itertools.rst:46 msgid "iterable" msgstr "可疊代物件" -#: ../../library/itertools.rst:41 +#: ../../library/itertools.rst:38 msgid "``chain.from_iterable(['ABC', 'DEF']) → A B C D E F``" msgstr "``chain.from_iterable(['ABC', 'DEF']) → A B C D E F``" -#: ../../library/itertools.rst:42 +#: ../../library/itertools.rst:39 msgid ":func:`compress`" msgstr ":func:`compress`" -#: ../../library/itertools.rst:42 +#: ../../library/itertools.rst:39 msgid "data, selectors" msgstr "data, selectors" -#: ../../library/itertools.rst:42 +#: ../../library/itertools.rst:39 msgid "(d[0] if s[0]), (d[1] if s[1]), ..." msgstr "(d[0] if s[0]), (d[1] if s[1]), ..." -#: ../../library/itertools.rst:42 +#: ../../library/itertools.rst:39 msgid "``compress('ABCDEF', [1,0,1,0,1,1]) → A C E F``" msgstr "``compress('ABCDEF', [1,0,1,0,1,1]) → A C E F``" -#: ../../library/itertools.rst:43 +#: ../../library/itertools.rst:40 msgid ":func:`count`" msgstr ":func:`count`" -#: ../../library/itertools.rst:43 +#: ../../library/itertools.rst:40 msgid "[start[, step]]" msgstr "[start[, step]]" -#: ../../library/itertools.rst:43 +#: ../../library/itertools.rst:40 msgid "start, start+step, start+2*step, ..." msgstr "start, start+step, start+2*step, ..." -#: ../../library/itertools.rst:43 +#: ../../library/itertools.rst:40 msgid "``count(10) → 10 11 12 13 14 ...``" msgstr "``count(10) → 10 11 12 13 14 ...``" -#: ../../library/itertools.rst:44 +#: ../../library/itertools.rst:41 msgid ":func:`cycle`" msgstr ":func:`cycle`" -#: ../../library/itertools.rst:44 +#: ../../library/itertools.rst:41 msgid "p" msgstr "p" -#: ../../library/itertools.rst:44 +#: ../../library/itertools.rst:41 msgid "p0, p1, ... plast, p0, p1, ..." msgstr "p0, p1, ... plast, p0, p1, ..." -#: ../../library/itertools.rst:44 +#: ../../library/itertools.rst:41 msgid "``cycle('ABCD') → A B C D A B C D ...``" msgstr "``cycle('ABCD') → A B C D A B C D ...``" -#: ../../library/itertools.rst:45 +#: ../../library/itertools.rst:42 msgid ":func:`dropwhile`" msgstr ":func:`dropwhile`" -#: ../../library/itertools.rst:45 ../../library/itertools.rst:46 -#: ../../library/itertools.rst:52 +#: ../../library/itertools.rst:42 ../../library/itertools.rst:43 +#: ../../library/itertools.rst:49 msgid "predicate, seq" msgstr "predicate, seq" -#: ../../library/itertools.rst:45 +#: ../../library/itertools.rst:42 msgid "seq[n], seq[n+1], starting when predicate fails" msgstr "seq[n], seq[n+1],當 predicate 失敗時開始" -#: ../../library/itertools.rst:45 +#: ../../library/itertools.rst:42 msgid "``dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8``" msgstr "``dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8``" -#: ../../library/itertools.rst:46 +#: ../../library/itertools.rst:43 msgid ":func:`filterfalse`" msgstr ":func:`filterfalse`" -#: ../../library/itertools.rst:46 +#: ../../library/itertools.rst:43 msgid "elements of seq where predicate(elem) fails" msgstr "當 predicate(elem) 失敗時 seq 的元素" -#: ../../library/itertools.rst:46 +#: ../../library/itertools.rst:43 msgid "``filterfalse(lambda x: x<5, [1,4,6,3,8]) → 6 8``" msgstr "``filterfalse(lambda x: x<5, [1,4,6,3,8]) → 6 8``" -#: ../../library/itertools.rst:47 +#: ../../library/itertools.rst:44 msgid ":func:`groupby`" msgstr ":func:`groupby`" -#: ../../library/itertools.rst:47 +#: ../../library/itertools.rst:44 msgid "iterable[, key]" msgstr "iterable[, key]" -#: ../../library/itertools.rst:47 +#: ../../library/itertools.rst:44 msgid "sub-iterators grouped by value of key(v)" msgstr "根據 key(v) 的值分組的子疊代器" -#: ../../library/itertools.rst:47 +#: ../../library/itertools.rst:44 msgid "``groupby(['A','B','DEF'], len) → (1, A B) (3, DEF)``" msgstr "``groupby(['A','B','DEF'], len) → (1, A B) (3, DEF)``" -#: ../../library/itertools.rst:48 +#: ../../library/itertools.rst:45 msgid ":func:`islice`" msgstr ":func:`islice`" -#: ../../library/itertools.rst:48 +#: ../../library/itertools.rst:45 msgid "seq, [start,] stop [, step]" msgstr "seq, [start,] stop [, step]" -#: ../../library/itertools.rst:48 +#: ../../library/itertools.rst:45 msgid "elements from seq[start:stop:step]" msgstr "seq[start:stop:step] 的元素" -#: ../../library/itertools.rst:48 +#: ../../library/itertools.rst:45 msgid "``islice('ABCDEFG', 2, None) → C D E F G``" msgstr "``islice('ABCDEFG', 2, None) → C D E F G``" -#: ../../library/itertools.rst:49 +#: ../../library/itertools.rst:46 msgid ":func:`pairwise`" msgstr ":func:`pairwise`" -#: ../../library/itertools.rst:49 +#: ../../library/itertools.rst:46 msgid "(p[0], p[1]), (p[1], p[2])" msgstr "(p[0], p[1]), (p[1], p[2])" -#: ../../library/itertools.rst:49 +#: ../../library/itertools.rst:46 msgid "``pairwise('ABCDEFG') → AB BC CD DE EF FG``" msgstr "``pairwise('ABCDEFG') → AB BC CD DE EF FG``" -#: ../../library/itertools.rst:50 +#: ../../library/itertools.rst:47 msgid ":func:`repeat`" msgstr ":func:`repeat`" -#: ../../library/itertools.rst:50 +#: ../../library/itertools.rst:47 msgid "elem [,n]" msgstr "elem [,n]" -#: ../../library/itertools.rst:50 +#: ../../library/itertools.rst:47 msgid "elem, elem, elem, ... endlessly or up to n times" msgstr "elem, elem, elem,... 重複無限次或 n 次" -#: ../../library/itertools.rst:50 +#: ../../library/itertools.rst:47 msgid "``repeat(10, 3) → 10 10 10``" msgstr "``repeat(10, 3) → 10 10 10``" -#: ../../library/itertools.rst:51 +#: ../../library/itertools.rst:48 msgid ":func:`starmap`" msgstr ":func:`starmap`" -#: ../../library/itertools.rst:51 +#: ../../library/itertools.rst:48 msgid "func, seq" msgstr "func, seq" -#: ../../library/itertools.rst:51 +#: ../../library/itertools.rst:48 msgid "func(\\*seq[0]), func(\\*seq[1]), ..." msgstr "func(\\*seq[0]), func(\\*seq[1]), ..." -#: ../../library/itertools.rst:51 +#: ../../library/itertools.rst:48 msgid "``starmap(pow, [(2,5), (3,2), (10,3)]) → 32 9 1000``" msgstr "``starmap(pow, [(2,5), (3,2), (10,3)]) → 32 9 1000``" -#: ../../library/itertools.rst:52 +#: ../../library/itertools.rst:49 msgid ":func:`takewhile`" msgstr ":func:`takewhile`" -#: ../../library/itertools.rst:52 +#: ../../library/itertools.rst:49 msgid "seq[0], seq[1], until predicate fails" msgstr "seq[0], seq[1],直到 predicate 失敗" -#: ../../library/itertools.rst:52 +#: ../../library/itertools.rst:49 msgid "``takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4``" msgstr "``takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4``" -#: ../../library/itertools.rst:53 +#: ../../library/itertools.rst:50 msgid ":func:`tee`" msgstr ":func:`tee`" -#: ../../library/itertools.rst:53 +#: ../../library/itertools.rst:50 msgid "it, n" msgstr "it, n" -#: ../../library/itertools.rst:53 +#: ../../library/itertools.rst:50 msgid "it1, it2, ... itn splits one iterator into n" msgstr "it1, it2, ... itn,將一個疊代器分成 n 個" -#: ../../library/itertools.rst:53 +#: ../../library/itertools.rst:50 msgid "``tee('ABC', 2) → A B C, A B C``" msgstr "``tee('ABC', 2) → A B C, A B C``" -#: ../../library/itertools.rst:54 +#: ../../library/itertools.rst:51 msgid ":func:`zip_longest`" msgstr ":func:`zip_longest`" -#: ../../library/itertools.rst:54 +#: ../../library/itertools.rst:51 msgid "(p[0], q[0]), (p[1], q[1]), ..." msgstr "(p[0], q[0]), (p[1], q[1]), ..." -#: ../../library/itertools.rst:54 +#: ../../library/itertools.rst:51 msgid "``zip_longest('ABCD', 'xy', fillvalue='-') → Ax By C- D-``" msgstr "``zip_longest('ABCD', 'xy', fillvalue='-') → Ax By C- D-``" -#: ../../library/itertools.rst:57 +#: ../../library/itertools.rst:54 msgid "**Combinatoric iterators:**" msgstr "**組合疊代器:**" -#: ../../library/itertools.rst:62 +#: ../../library/itertools.rst:59 msgid ":func:`product`" msgstr ":func:`product`" -#: ../../library/itertools.rst:62 +#: ../../library/itertools.rst:59 msgid "p, q, ... [repeat=1]" msgstr "p, q, ... [repeat=1]" -#: ../../library/itertools.rst:62 +#: ../../library/itertools.rst:59 msgid "cartesian product, equivalent to a nested for-loop" msgstr "笛卡爾乘積 (cartesian product),相當於巢狀的 for 迴圈" -#: ../../library/itertools.rst:63 +#: ../../library/itertools.rst:60 msgid ":func:`permutations`" msgstr ":func:`permutations`" -#: ../../library/itertools.rst:63 +#: ../../library/itertools.rst:60 msgid "p[, r]" msgstr "p[, r]" -#: ../../library/itertools.rst:63 +#: ../../library/itertools.rst:60 msgid "r-length tuples, all possible orderings, no repeated elements" msgstr "長度為 r 的元組,所有可能的定序,無重複元素" -#: ../../library/itertools.rst:64 +#: ../../library/itertools.rst:61 msgid ":func:`combinations`" msgstr ":func:`combinations`" -#: ../../library/itertools.rst:64 ../../library/itertools.rst:65 +#: ../../library/itertools.rst:61 ../../library/itertools.rst:62 msgid "p, r" msgstr "p, r" -#: ../../library/itertools.rst:64 +#: ../../library/itertools.rst:61 msgid "r-length tuples, in sorted order, no repeated elements" msgstr "長度為 r 的元組,按照排序過後的定序,無重複元素" -#: ../../library/itertools.rst:65 +#: ../../library/itertools.rst:62 msgid ":func:`combinations_with_replacement`" msgstr ":func:`combinations_with_replacement`" -#: ../../library/itertools.rst:65 +#: ../../library/itertools.rst:62 msgid "r-length tuples, in sorted order, with repeated elements" msgstr "長度為 r 的元組,按照排序過後的定序,有重複元素" -#: ../../library/itertools.rst:69 +#: ../../library/itertools.rst:66 msgid "Examples" msgstr "範例" -#: ../../library/itertools.rst:71 +#: ../../library/itertools.rst:68 msgid "``product('ABCD', repeat=2)``" msgstr "``product('ABCD', repeat=2)``" -#: ../../library/itertools.rst:71 +#: ../../library/itertools.rst:68 msgid "``AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD``" msgstr "``AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD``" -#: ../../library/itertools.rst:72 +#: ../../library/itertools.rst:69 msgid "``permutations('ABCD', 2)``" msgstr "``permutations('ABCD', 2)``" -#: ../../library/itertools.rst:72 +#: ../../library/itertools.rst:69 msgid "``AB AC AD BA BC BD CA CB CD DA DB DC``" msgstr "``AB AC AD BA BC BD CA CB CD DA DB DC``" -#: ../../library/itertools.rst:73 +#: ../../library/itertools.rst:70 msgid "``combinations('ABCD', 2)``" msgstr "``combinations('ABCD', 2)``" -#: ../../library/itertools.rst:73 +#: ../../library/itertools.rst:70 msgid "``AB AC AD BC BD CD``" msgstr "``AB AC AD BC BD CD``" -#: ../../library/itertools.rst:74 +#: ../../library/itertools.rst:71 msgid "``combinations_with_replacement('ABCD', 2)``" msgstr "``combinations_with_replacement('ABCD', 2)``" -#: ../../library/itertools.rst:74 +#: ../../library/itertools.rst:71 msgid "``AA AB AC AD BB BC BD CC CD DD``" msgstr "``AA AB AC AD BB BC BD CC CD DD``" -#: ../../library/itertools.rst:81 +#: ../../library/itertools.rst:78 msgid "Itertool Functions" msgstr "Itertool 函式" -#: ../../library/itertools.rst:83 +#: ../../library/itertools.rst:80 msgid "" "The following functions all construct and return iterators. Some provide " "streams of infinite length, so they should only be accessed by functions or " @@ -425,13 +425,13 @@ msgstr "" "以下的函式都會建構並回傳疊代器。一些函式提供無限長度的串流 (stream),因此應僅" "由截斷串流的函式或迴圈來存取它們。" -#: ../../library/itertools.rst:90 +#: ../../library/itertools.rst:87 msgid "" "Make an iterator that returns accumulated sums or accumulated results from " "other binary functions." msgstr "建立一個回傳累積和的疊代器,或其他二進位函式的累積結果。" -#: ../../library/itertools.rst:93 +#: ../../library/itertools.rst:90 msgid "" "The *function* defaults to addition. The *function* should accept two " "arguments, an accumulated total and a value from the *iterable*." @@ -439,7 +439,7 @@ msgstr "" "*function* 預設為加法。*function* 應接受兩個引數,即累積總和和來自 " "*iterable* 的值。" -#: ../../library/itertools.rst:96 +#: ../../library/itertools.rst:93 msgid "" "If an *initial* value is provided, the accumulation will start with that " "value and the output will have one more element than the input iterable." @@ -447,15 +447,15 @@ msgstr "" "如果提供了 *initial* 值,則累積將從該值開始,並且輸出的元素數將比輸入的可疊代" "物件多一個。" -#: ../../library/itertools.rst:100 ../../library/itertools.rst:173 -#: ../../library/itertools.rst:232 ../../library/itertools.rst:275 -#: ../../library/itertools.rst:476 ../../library/itertools.rst:511 -#: ../../library/itertools.rst:548 ../../library/itertools.rst:624 -#: ../../library/itertools.rst:685 ../../library/itertools.rst:766 +#: ../../library/itertools.rst:97 ../../library/itertools.rst:170 +#: ../../library/itertools.rst:237 ../../library/itertools.rst:280 +#: ../../library/itertools.rst:481 ../../library/itertools.rst:516 +#: ../../library/itertools.rst:553 ../../library/itertools.rst:629 +#: ../../library/itertools.rst:690 ../../library/itertools.rst:771 msgid "Roughly equivalent to::" msgstr "大致等價於: ::" -#: ../../library/itertools.rst:102 +#: ../../library/itertools.rst:99 msgid "" "def accumulate(iterable, function=operator.add, *, initial=None):\n" " 'Return running totals'\n" @@ -495,7 +495,7 @@ msgstr "" " total = function(total, element)\n" " yield total" -#: ../../library/itertools.rst:121 +#: ../../library/itertools.rst:118 msgid "" "To compute a running minimum, set *function* to :func:`min`. For a running " "maximum, set *function* to :func:`max`. Or for a running product, set " @@ -508,7 +508,7 @@ msgstr "" "也可以透過累積利息和付款來建立\\ `攤銷表 (Amortization tables) `_ :" -#: ../../library/itertools.rst:128 +#: ../../library/itertools.rst:125 msgid "" ">>> data = [3, 4, 6, 2, 1, 9, 0, 7, 5, 8]\n" ">>> list(accumulate(data, max)) # running maximum\n" @@ -532,36 +532,36 @@ msgstr "" ">>> list(accumulate(repeat(90, 10), update, initial=1_000))\n" "[1000, 960, 918, 874, 828, 779, 728, 674, 618, 559, 497]" -#: ../../library/itertools.rst:141 +#: ../../library/itertools.rst:138 msgid "" "See :func:`functools.reduce` for a similar function that returns only the " "final accumulated value." msgstr "" "可參見 :func:`functools.reduce`,其是個類似的函式,但僅回傳最終的累積值。" -#: ../../library/itertools.rst:146 +#: ../../library/itertools.rst:143 msgid "Added the optional *function* parameter." msgstr "新增可選的 *function* 參數。" -#: ../../library/itertools.rst:149 +#: ../../library/itertools.rst:146 msgid "Added the optional *initial* parameter." msgstr "新增可選的 *initial* 參數。" -#: ../../library/itertools.rst:155 +#: ../../library/itertools.rst:152 msgid "" "Batch data from the *iterable* into tuples of length *n*. The last batch may " "be shorter than *n*." msgstr "" "將來自 *iterable* 的資料分批為長度為 *n* 的元組。最後一個批次可能比 *n* 短。" -#: ../../library/itertools.rst:158 +#: ../../library/itertools.rst:155 msgid "" "If *strict* is true, will raise a :exc:`ValueError` if the final batch is " "shorter than *n*." msgstr "" "如果 *strict* 為真,則當最後一個批次比 *n* 短時,會引發 :exc:`ValueError`。" -#: ../../library/itertools.rst:161 +#: ../../library/itertools.rst:158 msgid "" "Loops over the input iterable and accumulates data into tuples up to size " "*n*. The input is consumed lazily, just enough to fill a batch. The result " @@ -572,7 +572,7 @@ msgstr "" "消耗 (consumed lazily) 的,會剛好足夠填充一批的資料。一旦批次填滿或輸入的可疊" "代物件\\ :term:`耗盡 `,就會 yield 出結果:" -#: ../../library/itertools.rst:166 +#: ../../library/itertools.rst:163 msgid "" ">>> flattened_data = ['roses', 'red', 'violets', 'blue', 'sugar', 'sweet']\n" ">>> unflattened = list(batched(flattened_data, 2))\n" @@ -584,7 +584,7 @@ msgstr "" ">>> unflattened\n" "[('roses', 'red'), ('violets', 'blue'), ('sugar', 'sweet')]" -#: ../../library/itertools.rst:175 +#: ../../library/itertools.rst:172 msgid "" "def batched(iterable, n, *, strict=False):\n" " # batched('ABCDEFG', 3) → ABC DEF G\n" @@ -606,11 +606,11 @@ msgstr "" " raise ValueError('batched(): incomplete batch')\n" " yield batch" -#: ../../library/itertools.rst:187 +#: ../../library/itertools.rst:184 msgid "Added the *strict* option." msgstr "新增 *strict* 選項。" -#: ../../library/itertools.rst:193 +#: ../../library/itertools.rst:190 msgid "" "Make an iterator that returns elements from the first iterable until it is :" "term:`exhausted`, then proceeds to the next iterable, until all of the " @@ -621,7 +621,7 @@ msgstr "" "然後繼續處理下一個可疊代物件,直到所有可疊代物件都耗盡。這將多個資料來源結合" "為單一個疊代器。大致等價於: ::" -#: ../../library/itertools.rst:198 +#: ../../library/itertools.rst:195 msgid "" "def chain(*iterables):\n" " # chain('ABC', 'DEF') → A B C D E F\n" @@ -633,7 +633,14 @@ msgstr "" " for iterable in iterables:\n" " yield from iterable" -#: ../../library/itertools.rst:206 +#: ../../library/itertools.rst:200 +msgid "" +"Note that :ref:`unpacking in comprehensions ` " +"provides similar functionality so that ``list(chain(p, q))`` could be " +"written as ``[*s for s in (p, q)]``." +msgstr "" + +#: ../../library/itertools.rst:207 msgid "" "Alternate constructor for :func:`chain`. Gets chained inputs from a single " "iterable argument that is evaluated lazily. Roughly equivalent to::" @@ -641,7 +648,7 @@ msgstr "" ":func:`chain` 的另一個建構函式。從單個可疊代的引數中得到鏈接的輸入,該引數是" "惰性計算的。大致等價於:" -#: ../../library/itertools.rst:209 +#: ../../library/itertools.rst:210 msgid "" "def from_iterable(iterables):\n" " # chain.from_iterable(['ABC', 'DEF']) → A B C D E F\n" @@ -653,11 +660,18 @@ msgstr "" " for iterable in iterables:\n" " yield from iterable" -#: ../../library/itertools.rst:217 +#: ../../library/itertools.rst:215 +msgid "" +"Note that :ref:`unpacking in comprehensions ` " +"provides similar functionality so that ``list(chain." +"from_iterable(iterables))`` could be written as ``[*s for s in iterables]``." +msgstr "" + +#: ../../library/itertools.rst:222 msgid "Return *r* length subsequences of elements from the input *iterable*." msgstr "從輸入 *iterable* 中回傳長度為 *r* 的元素的子序列。" -#: ../../library/itertools.rst:219 +#: ../../library/itertools.rst:224 msgid "" "The output is a subsequence of :func:`product` keeping only entries that are " "subsequences of the *iterable*. The length of the output is given by :func:" @@ -668,7 +682,7 @@ msgstr "" "度由 :func:`math.comb` 給定,當 ``0 ≤ r ≤ n`` 時,長度為 ``n! / r! / (n - r)!" "``,當 ``r > n`` 時為零。" -#: ../../library/itertools.rst:224 +#: ../../library/itertools.rst:229 msgid "" "The combination tuples are emitted in lexicographic order according to the " "order of the input *iterable*. If the input *iterable* is sorted, the output " @@ -677,7 +691,7 @@ msgstr "" "根據輸入值 *iterable* 的順序,組合的元組會按照字典順序輸出。如果輸入的 " "*iterable* 已經排序,則輸出的元組也將按排序的順序產生。" -#: ../../library/itertools.rst:228 +#: ../../library/itertools.rst:233 msgid "" "Elements are treated as unique based on their position, not on their value. " "If the input elements are unique, there will be no repeated values within " @@ -686,7 +700,7 @@ msgstr "" "元素是根據它們的位置(而非值)來決定其唯一性。如果輸入的元素都是獨特的,則每" "個組合內將不會有重複的值。" -#: ../../library/itertools.rst:234 +#: ../../library/itertools.rst:239 msgid "" "def combinations(iterable, r):\n" " # combinations('ABCD', 2) → AB AC AD BC BD CD\n" @@ -732,14 +746,14 @@ msgstr "" " indices[j] = indices[j-1] + 1\n" " yield tuple(pool[i] for i in indices)" -#: ../../library/itertools.rst:259 +#: ../../library/itertools.rst:264 msgid "" "Return *r* length subsequences of elements from the input *iterable* " "allowing individual elements to be repeated more than once." msgstr "" "回傳來自輸入 *iterable* 的長度為 *r* 的子序列,且允許個別元素重複多次。" -#: ../../library/itertools.rst:262 +#: ../../library/itertools.rst:267 msgid "" "The output is a subsequence of :func:`product` that keeps only entries that " "are subsequences (with possible repeated elements) of the *iterable*. The " @@ -750,7 +764,7 @@ msgstr "" "複元素)的條目。當 ``n > 0`` 時,回傳的子序列數量為 ``(n + r - 1)! / r! / (n " "- 1)!``。" -#: ../../library/itertools.rst:267 +#: ../../library/itertools.rst:272 msgid "" "The combination tuples are emitted in lexicographic order according to the " "order of the input *iterable*. if the input *iterable* is sorted, the output " @@ -759,7 +773,7 @@ msgstr "" "根據輸入值 *iterable* 的順序,組合的元組會按照字典順序輸出。如果輸入的 " "*iterable* 已經排序,則輸出的元組也將按排序的順序產生。" -#: ../../library/itertools.rst:271 +#: ../../library/itertools.rst:276 msgid "" "Elements are treated as unique based on their position, not on their value. " "If the input elements are unique, the generated combinations will also be " @@ -768,7 +782,7 @@ msgstr "" "元素是根據它們的位置(而非值)來決定其唯一性。如果輸入的元素都是獨特的,生成" "的組合也將是獨特的。" -#: ../../library/itertools.rst:277 +#: ../../library/itertools.rst:282 msgid "" "def combinations_with_replacement(iterable, r):\n" " # combinations_with_replacement('ABC', 2) → AA AB AC BB BC CC\n" @@ -808,7 +822,7 @@ msgstr "" " indices[i:] = [indices[i] + 1] * (r - i)\n" " yield tuple(pool[i] for i in indices)" -#: ../../library/itertools.rst:301 +#: ../../library/itertools.rst:306 msgid "" "Make an iterator that returns elements from *data* where the corresponding " "element in *selectors* is true. Stops when either the *data* or *selectors* " @@ -818,7 +832,7 @@ msgstr "" "*data* 或 *selectors* 可疊代物件\\ :term:`耗盡 `\\ 時停止。大致等" "價於: ::" -#: ../../library/itertools.rst:306 +#: ../../library/itertools.rst:311 msgid "" "def compress(data, selectors):\n" " # compress('ABCDEF', [1,0,1,0,1,1]) → A C E F\n" @@ -828,7 +842,7 @@ msgstr "" " # compress('ABCDEF', [1,0,1,0,1,1]) → A C E F\n" " return (datum for datum, selector in zip(data, selectors) if selector)" -#: ../../library/itertools.rst:315 +#: ../../library/itertools.rst:320 msgid "" "Make an iterator that returns evenly spaced values beginning with *start*. " "Can be used with :func:`map` to generate consecutive data points or with :" @@ -837,7 +851,7 @@ msgstr "" "建立一個疊代器,回傳從 *start* 開始的等差的值。可以與 :func:`map` 一起使用來" "產生連續的資料點,或與 :func:`zip` 一起使用來增加序列號。大致等價於: ::" -#: ../../library/itertools.rst:320 +#: ../../library/itertools.rst:325 msgid "" "def count(start=0, step=1):\n" " # count(10) → 10 11 12 13 14 ...\n" @@ -855,7 +869,7 @@ msgstr "" " yield n\n" " n += step" -#: ../../library/itertools.rst:328 +#: ../../library/itertools.rst:333 msgid "" "When counting with floating-point numbers, better accuracy can sometimes be " "achieved by substituting multiplicative code such as: ``(start + step * i " @@ -864,11 +878,11 @@ msgstr "" "當用浮點數計數時,將上述程式碼替換為乘法有時可以獲得更好的精確度,例如:" "``(start + step * i for i in count())``。" -#: ../../library/itertools.rst:332 +#: ../../library/itertools.rst:337 msgid "Added *step* argument and allowed non-integer arguments." msgstr "新增 *step* 引數並允許非整數引數。" -#: ../../library/itertools.rst:338 +#: ../../library/itertools.rst:343 msgid "" "Make an iterator returning elements from the *iterable* and saving a copy of " "each. When the iterable is :term:`exhausted`, return elements from the " @@ -878,7 +892,7 @@ msgstr "" "\\ :term:`耗盡 `\\ 時,從保存的副本中回傳元素。會無限次的重複。大" "致等價於: ::" -#: ../../library/itertools.rst:342 +#: ../../library/itertools.rst:347 msgid "" "def cycle(iterable):\n" " # cycle('ABCD') → A B C D A B C D A B C D ...\n" @@ -904,13 +918,13 @@ msgstr "" " for element in saved:\n" " yield element" -#: ../../library/itertools.rst:354 +#: ../../library/itertools.rst:359 msgid "" "This itertool may require significant auxiliary storage (depending on the " "length of the iterable)." msgstr "此 itertool 可能需要大量的輔助儲存空間(取決於可疊代物件的長度)。" -#: ../../library/itertools.rst:360 +#: ../../library/itertools.rst:365 msgid "" "Make an iterator that drops elements from the *iterable* while the " "*predicate* is true and afterwards returns every element. Roughly " @@ -919,7 +933,7 @@ msgstr "" "建立一個疊代器,在 *predicate* 為 true 時丟棄 *iterable* 中的元素,之後回傳每" "個元素。大致等價於:" -#: ../../library/itertools.rst:364 +#: ../../library/itertools.rst:369 msgid "" "def dropwhile(predicate, iterable):\n" " # dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8\n" @@ -945,7 +959,7 @@ msgstr "" " for x in iterator:\n" " yield x" -#: ../../library/itertools.rst:376 +#: ../../library/itertools.rst:381 msgid "" "Note this does not produce *any* output until the predicate first becomes " "false, so this itertool may have a lengthy start-up time." @@ -953,7 +967,7 @@ msgstr "" "注意,在 predicate 首次變為 False 之前,這不會產生\\ *任何*\\ 輸出,所以此 " "itertool 可能會有較長的啟動時間。" -#: ../../library/itertools.rst:382 +#: ../../library/itertools.rst:387 msgid "" "Make an iterator that filters elements from the *iterable* returning only " "those for which the *predicate* returns a false value. If *predicate* is " @@ -962,7 +976,7 @@ msgstr "" "建立一個疊代器,過濾 *iterable* 中的元素,僅回傳 *predicate* 為 False 值的元" "素。如果 *predicate* 是 ``None``,則回傳為 False 的項目。大致等價於: ::" -#: ../../library/itertools.rst:387 +#: ../../library/itertools.rst:392 msgid "" "def filterfalse(predicate, iterable):\n" " # filterfalse(lambda x: x<5, [1,4,6,3,8]) → 6 8\n" @@ -984,7 +998,7 @@ msgstr "" " if not predicate(x):\n" " yield x" -#: ../../library/itertools.rst:400 +#: ../../library/itertools.rst:405 msgid "" "Make an iterator that returns consecutive keys and groups from the " "*iterable*. The *key* is a function computing a key value for each element. " @@ -997,7 +1011,7 @@ msgstr "" "(identity function),並回傳未被更改的元素。一般來說,可疊代物件需要已經用相同" "的鍵函式進行排序。" -#: ../../library/itertools.rst:406 +#: ../../library/itertools.rst:411 msgid "" "The operation of :func:`groupby` is similar to the ``uniq`` filter in Unix. " "It generates a break or new group every time the value of the key function " @@ -1010,7 +1024,7 @@ msgstr "" "料進行排序)。這種行為不同於 SQL 的 GROUP BY,其無論輸入順序如何都會聚合相同" "的元素。" -#: ../../library/itertools.rst:412 +#: ../../library/itertools.rst:417 msgid "" "The returned group is itself an iterator that shares the underlying iterable " "with :func:`groupby`. Because the source is shared, when the :func:" @@ -1021,7 +1035,7 @@ msgstr "" "共享的,當 :func:`groupby` 物件前進時,前一個群組將不再可見。因此,如果之後需" "要該資料,應將其儲存為串列: ::" -#: ../../library/itertools.rst:417 +#: ../../library/itertools.rst:422 msgid "" "groups = []\n" "uniquekeys = []\n" @@ -1037,11 +1051,11 @@ msgstr "" " groups.append(list(g)) # 將群組疊代器儲存為串列\n" " uniquekeys.append(k)" -#: ../../library/itertools.rst:424 +#: ../../library/itertools.rst:429 msgid ":func:`groupby` is roughly equivalent to::" msgstr ":func:`groupby` 大致等價於: ::" -#: ../../library/itertools.rst:426 +#: ../../library/itertools.rst:431 msgid "" "def groupby(iterable, key=None):\n" " # [k for k, g in groupby('AAAABBBCCDAABBB')] → A B C D A B\n" @@ -1107,7 +1121,7 @@ msgstr "" " for _ in curr_group:\n" " pass" -#: ../../library/itertools.rst:462 +#: ../../library/itertools.rst:467 msgid "" "Make an iterator that returns selected elements from the iterable. Works " "like sequence slicing but does not support negative values for *start*, " @@ -1116,7 +1130,7 @@ msgstr "" "建立一個疊代器,回傳從 iterable 中選取的元素。其作用類似於序列切片 (sequence " "slicing),但不支援負數的 *start*、*stop* 或 *step* 的值。" -#: ../../library/itertools.rst:466 +#: ../../library/itertools.rst:471 msgid "" "If *start* is zero or ``None``, iteration starts at zero. Otherwise, " "elements from the iterable are skipped until *start* is reached." @@ -1124,7 +1138,7 @@ msgstr "" "如果 *start* 為零或 ``None``,則從零開始疊代。否則在達到 *start* 之前,會跳" "過 iterable 中的元素。" -#: ../../library/itertools.rst:469 +#: ../../library/itertools.rst:474 msgid "" "If *stop* is ``None``, iteration continues until the input is :term:" "`exhausted`, if at all. Otherwise, it stops at the specified position." @@ -1133,7 +1147,7 @@ msgstr "" "`\\ (如果會耗盡的話)。如果指定了 *stop*,則在達到指定位置時停" "止。" -#: ../../library/itertools.rst:472 +#: ../../library/itertools.rst:477 msgid "" "If *step* is ``None``, the step defaults to one. Elements are returned " "consecutively unless *step* is set higher than one which results in items " @@ -1142,7 +1156,7 @@ msgstr "" "如果 *step* 為 ``None``,則步長 (step) 預設為一。元素會連續回傳,除非將 " "*step* 設定為大於一,這會導致一些項目被跳過。" -#: ../../library/itertools.rst:478 +#: ../../library/itertools.rst:483 msgid "" "def islice(iterable, *args):\n" " # islice('ABCDEFG', 2) → A B\n" @@ -1184,7 +1198,7 @@ msgstr "" " yield element\n" " next_i += step" -#: ../../library/itertools.rst:498 +#: ../../library/itertools.rst:503 msgid "" "If the input is an iterator, then fully consuming the *islice* advances the " "input iterator by ``max(start, stop)`` steps regardless of the *step* value." @@ -1192,11 +1206,11 @@ msgstr "" "若輸入為疊代器,則完整耗盡 *islice* 會使輸入的疊代器向前移動 ``max(start, " "stop)`` 步,與 *step* 的值無關。" -#: ../../library/itertools.rst:505 +#: ../../library/itertools.rst:510 msgid "Return successive overlapping pairs taken from the input *iterable*." msgstr "回傳從輸入的 *iterable* 中提取的連續重疊對。" -#: ../../library/itertools.rst:507 +#: ../../library/itertools.rst:512 msgid "" "The number of 2-tuples in the output iterator will be one fewer than the " "number of inputs. It will be empty if the input iterable has fewer than two " @@ -1205,7 +1219,7 @@ msgstr "" "輸出疊代器中的 2 元組數量將比輸入少一個。如果輸入的可疊代物件中的值少於兩個," "則輸出將為空值。" -#: ../../library/itertools.rst:513 +#: ../../library/itertools.rst:518 msgid "" "def pairwise(iterable):\n" " # pairwise('ABCDEFG') → AB BC CD DE EF FG\n" @@ -1227,7 +1241,7 @@ msgstr "" " yield a, b\n" " a = b" -#: ../../library/itertools.rst:528 +#: ../../library/itertools.rst:533 msgid "" "Return successive *r* length `permutations of elements `_ from the *iterable*." @@ -1235,7 +1249,7 @@ msgstr "" "回傳 *iterable* 中連續且長度為 *r* 的\\ `元素排列 `_ 。" -#: ../../library/itertools.rst:531 +#: ../../library/itertools.rst:536 msgid "" "If *r* is not specified or is ``None``, then *r* defaults to the length of " "the *iterable* and all possible full-length permutations are generated." @@ -1243,7 +1257,7 @@ msgstr "" "如果未指定 *r* 或其值為 ``None``,則 *r* 預設為 *iterable* 的長度,並產生所有" "可能的完整長度的排列。" -#: ../../library/itertools.rst:535 +#: ../../library/itertools.rst:540 msgid "" "The output is a subsequence of :func:`product` where entries with repeated " "elements have been filtered out. The length of the output is given by :func:" @@ -1254,7 +1268,7 @@ msgstr "" "func:`math.perm` 給定,當 ``0 ≤ r ≤ n`` 時,長度為 ``n! / (n - r)!``,當 ``r " "> n`` 時為零。" -#: ../../library/itertools.rst:540 +#: ../../library/itertools.rst:545 msgid "" "The permutation tuples are emitted in lexicographic order according to the " "order of the input *iterable*. If the input *iterable* is sorted, the " @@ -1263,7 +1277,7 @@ msgstr "" "根據輸入值 *iterable* 的順序,排列的元組會按照字典順序輸出。如果輸入的 " "*iterable* 已排序,則輸出的元組也將按排序的順序產生。" -#: ../../library/itertools.rst:544 +#: ../../library/itertools.rst:549 msgid "" "Elements are treated as unique based on their position, not on their value. " "If the input elements are unique, there will be no repeated values within a " @@ -1272,7 +1286,7 @@ msgstr "" "元素是根據它們的位置(而非值)來決定其唯一性。如果輸入的元素都是獨特的,則排" "列中將不會有重複的值。" -#: ../../library/itertools.rst:550 +#: ../../library/itertools.rst:555 msgid "" "def permutations(iterable, r=None):\n" " # permutations('ABCD', 2) → AB AC AD BA BC BD CA CB CD DA DB DC\n" @@ -1330,7 +1344,7 @@ msgstr "" " else:\n" " return" -#: ../../library/itertools.rst:581 +#: ../../library/itertools.rst:586 msgid "" "`Cartesian product `_ of " "the input iterables." @@ -1338,7 +1352,7 @@ msgstr "" "輸入可疊代物的 `笛卡爾乘積 `_" -#: ../../library/itertools.rst:584 +#: ../../library/itertools.rst:589 msgid "" "Roughly equivalent to nested for-loops in a generator expression. For " "example, ``product(A, B)`` returns the same as ``((x,y) for x in A for y in " @@ -1347,7 +1361,7 @@ msgstr "" "大致等價於產生器運算式中的巢狀 for 迴圈。例如,``product(A, B)`` 的回傳結果" "與 ``((x,y) for x in A for y in B)`` 相同。" -#: ../../library/itertools.rst:587 +#: ../../library/itertools.rst:592 msgid "" "The nested loops cycle like an odometer with the rightmost element advancing " "on every iteration. This pattern creates a lexicographic ordering so that " @@ -1357,7 +1371,7 @@ msgstr "" "巢狀迴圈的循環類似於里程表,最右邊的元素在每次疊代時前進。這種模式會建立字典" "順序,因此如果輸入的 iterables 已排序,則輸出的乘積元組也將按排序的順序產生。" -#: ../../library/itertools.rst:592 +#: ../../library/itertools.rst:597 msgid "" "To compute the product of an iterable with itself, specify the number of " "repetitions with the optional *repeat* keyword argument. For example, " @@ -1366,7 +1380,7 @@ msgstr "" "要計算可疊代物件自身的乘積,可以使用可選的 *repeat* 關鍵字引數來指定重複次" "數。例如,``product(A, repeat=4)`` 與 ``product(A, A, A, A)`` 相同。" -#: ../../library/itertools.rst:596 +#: ../../library/itertools.rst:601 msgid "" "This function is roughly equivalent to the following code, except that the " "actual implementation does not build up intermediate results in memory::" @@ -1374,7 +1388,7 @@ msgstr "" "此函式大致等價於以下的程式碼,不同之處在於真正的實作不會在記憶體中建立中間結" "果: ::" -#: ../../library/itertools.rst:599 +#: ../../library/itertools.rst:604 msgid "" "def product(*iterables, repeat=1):\n" " # product('ABCD', 'xy') → Ax Ay Bx By Cx Cy Dx Dy\n" @@ -1406,7 +1420,7 @@ msgstr "" " for prod in result:\n" " yield tuple(prod)" -#: ../../library/itertools.rst:614 +#: ../../library/itertools.rst:619 msgid "" "Before :func:`product` runs, it completely consumes the input iterables, " "keeping pools of values in memory to generate the products. Accordingly, it " @@ -1415,7 +1429,7 @@ msgstr "" "在 :func:`product` 執行之前,它會完全消耗輸入的 iterables,並將值的池 (pools " "of values) 保存在記憶體中以產生乘積。因此,它僅對有限的輸入有用。" -#: ../../library/itertools.rst:621 +#: ../../library/itertools.rst:626 msgid "" "Make an iterator that returns *object* over and over again. Runs " "indefinitely unless the *times* argument is specified." @@ -1423,7 +1437,7 @@ msgstr "" "建立一個疊代器,反覆回傳 *object*。除非指定了 *times* 引數,否則會執行無限" "次。" -#: ../../library/itertools.rst:626 +#: ../../library/itertools.rst:631 msgid "" "def repeat(object, times=None):\n" " # repeat(10, 3) → 10 10 10\n" @@ -1443,13 +1457,13 @@ msgstr "" " for i in range(times):\n" " yield object" -#: ../../library/itertools.rst:635 +#: ../../library/itertools.rst:640 msgid "" "A common use for *repeat* is to supply a stream of constant values to *map* " "or *zip*:" msgstr "*repeat* 的常見用途是為 *map* 或 *zip* 提供定值的串流:" -#: ../../library/itertools.rst:638 +#: ../../library/itertools.rst:643 msgid "" ">>> list(map(pow, range(10), repeat(2)))\n" "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" @@ -1457,7 +1471,7 @@ msgstr "" ">>> list(map(pow, range(10), repeat(2)))\n" "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" -#: ../../library/itertools.rst:646 +#: ../../library/itertools.rst:651 msgid "" "Make an iterator that computes the *function* using arguments obtained from " "the *iterable*. Used instead of :func:`map` when argument parameters have " @@ -1466,7 +1480,7 @@ msgstr "" "建立一個疊代器,使用從 *iterable* 取得的引數計算 *function* 。當引數參數已經" "被「預先壓縮 (pre-zipped)」成元組時,使用此方法代替 :func:`map`。" -#: ../../library/itertools.rst:650 +#: ../../library/itertools.rst:655 msgid "" "The difference between :func:`map` and :func:`starmap` parallels the " "distinction between ``function(a,b)`` and ``function(*c)``. Roughly " @@ -1475,7 +1489,7 @@ msgstr "" ":func:`map` 和 :func:`starmap` 之間的區別類似於 ``function(a,b)`` 和 " "``function(*c)`` 之間的區別。大致等價於:" -#: ../../library/itertools.rst:654 +#: ../../library/itertools.rst:659 msgid "" "def starmap(function, iterable):\n" " # starmap(pow, [(2,5), (3,2), (10,3)]) → 32 9 1000\n" @@ -1487,7 +1501,7 @@ msgstr "" " for args in iterable:\n" " yield function(*args)" -#: ../../library/itertools.rst:662 +#: ../../library/itertools.rst:667 msgid "" "Make an iterator that returns elements from the *iterable* as long as the " "*predicate* is true. Roughly equivalent to::" @@ -1495,7 +1509,7 @@ msgstr "" "建立一個疊代器,只在 *predicate* 為 true 時回傳 *iterable* 中的元素。大致等價" "於:" -#: ../../library/itertools.rst:665 +#: ../../library/itertools.rst:670 msgid "" "def takewhile(predicate, iterable):\n" " # takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4\n" @@ -1511,7 +1525,7 @@ msgstr "" " break\n" " yield x" -#: ../../library/itertools.rst:672 +#: ../../library/itertools.rst:677 msgid "" "Note, the element that first fails the predicate condition is consumed from " "the input iterator and there is no way to access it. This could be an issue " @@ -1527,11 +1541,11 @@ msgstr "" "的 before_and_after() `__ 作為替代。" -#: ../../library/itertools.rst:683 +#: ../../library/itertools.rst:688 msgid "Return *n* independent iterators from a single iterable." msgstr "從一個 iterable 中回傳 *n* 個獨立的疊代器。" -#: ../../library/itertools.rst:687 +#: ../../library/itertools.rst:692 msgid "" "def tee(iterable, n=2):\n" " if n < 0:\n" @@ -1599,7 +1613,7 @@ msgstr "" " value, self.link = link\n" " return value" -#: ../../library/itertools.rst:720 +#: ../../library/itertools.rst:725 msgid "" "When the input *iterable* is already a tee iterator object, all members of " "the return tuple are constructed as if they had been produced by the " @@ -1612,11 +1626,11 @@ msgstr "" "驟 (flattening step)」讓巢狀的 :func:`tee` 呼叫能共享相同的底層資料鏈,並以單" "一的更新步驟取代一連串的呼叫。" -#: ../../library/itertools.rst:726 +#: ../../library/itertools.rst:731 msgid "The flattening property makes tee iterators efficiently peekable:" msgstr "展平特性讓 tee 疊代器具備高效的預覽能力:" -#: ../../library/itertools.rst:728 +#: ../../library/itertools.rst:733 msgid "" "def lookahead(tee_iterator):\n" " \"Return the next value without moving the input forward\"\n" @@ -1628,7 +1642,7 @@ msgstr "" " [forked_iterator] = tee(tee_iterator, 1)\n" " return next(forked_iterator)" -#: ../../library/itertools.rst:735 +#: ../../library/itertools.rst:740 msgid "" ">>> iterator = iter('abcdef')\n" ">>> [iterator] = tee(iterator, 1) # Make the input peekable\n" @@ -1648,7 +1662,7 @@ msgstr "" ">>> next(iterator) # 繼續往前移動\n" "'b'" -#: ../../library/itertools.rst:746 +#: ../../library/itertools.rst:751 msgid "" "``tee`` iterators are not threadsafe. A :exc:`RuntimeError` may be raised " "when simultaneously using iterators returned by the same :func:`tee` call, " @@ -1658,7 +1672,7 @@ msgstr "" "呼叫所回傳的疊代器時,即使原始的 *iterable* 是執行緒安全的,也可能引發 :exc:" "`RuntimeError`。" -#: ../../library/itertools.rst:750 +#: ../../library/itertools.rst:755 msgid "" "This itertool may require significant auxiliary storage (depending on how " "much temporary data needs to be stored). In general, if one iterator uses " @@ -1669,11 +1683,11 @@ msgstr "" "果一個疊代器在另一個疊代器開始之前使用了大部分或全部的資料,使用 :func:" "`list` 會比 :func:`tee` 更快。" -#: ../../library/itertools.rst:758 +#: ../../library/itertools.rst:763 msgid "Make an iterator that aggregates elements from each of the *iterables*." msgstr "建立一個疊代器,聚合來自每個 *iterables* 中的元素。" -#: ../../library/itertools.rst:761 +#: ../../library/itertools.rst:766 msgid "" "If the iterables are of uneven length, missing values are filled-in with " "*fillvalue*. If not specified, *fillvalue* defaults to ``None``." @@ -1681,11 +1695,11 @@ msgstr "" "如果 iterables 的長度不一,則使用 *fillvalue* 填充缺少的值。如果未指定," "*fillvalue* 會預設為 ``None``。" -#: ../../library/itertools.rst:764 +#: ../../library/itertools.rst:769 msgid "Iteration continues until the longest iterable is :term:`exhausted`." msgstr "疊代將持續直到最長的可疊代物件\\ :term:`耗盡 `\\ 為止。" -#: ../../library/itertools.rst:768 +#: ../../library/itertools.rst:773 msgid "" "def zip_longest(*iterables, fillvalue=None):\n" " # zip_longest('ABCD', 'xy', fillvalue='-') → Ax By C- D-\n" @@ -1731,7 +1745,7 @@ msgstr "" " values.append(value)\n" " yield tuple(values)" -#: ../../library/itertools.rst:790 +#: ../../library/itertools.rst:795 msgid "" "If one of the iterables is potentially infinite, then the :func:" "`zip_longest` function should be wrapped with something that limits the " @@ -1740,18 +1754,18 @@ msgstr "" "如果其中一個 iterables 可能是無限的,那麼應該用別的可以限制呼叫次數的方法來包" "裝 :func:`zip_longest` 函式(例如 :func:`islice` 或 :func:`takewhile`)。" -#: ../../library/itertools.rst:798 +#: ../../library/itertools.rst:803 msgid "Itertools Recipes" msgstr "Itertools 應用技巧" -#: ../../library/itertools.rst:800 +#: ../../library/itertools.rst:805 msgid "" "This section shows recipes for creating an extended toolset using the " "existing itertools as building blocks." msgstr "" "此段落展示了使用現有的 itertools 作為構建塊來建立擴展工具集的應用技巧。" -#: ../../library/itertools.rst:803 +#: ../../library/itertools.rst:808 msgid "" "The primary purpose of the itertools recipes is educational. The recipes " "show various ways of thinking about individual tools — for example, that " @@ -1769,7 +1783,7 @@ msgstr "" "`collections` 模組一同使用以及與內建 itertools(如 ``map()``、``filter()``、" "``reversed()`` 和 ``enumerate()``)一同使用的模式。" -#: ../../library/itertools.rst:812 +#: ../../library/itertools.rst:817 msgid "" "A secondary purpose of the recipes is to serve as an incubator. The " "``accumulate()``, ``compress()``, and ``pairwise()`` itertools started out " @@ -1781,7 +1795,7 @@ msgstr "" "``sliding_window()``、``derangements()`` 和 ``sieve()`` 的應用技巧正在被測" "試,以確定它們是否有價值被收錄到內建的 itertools 中。" -#: ../../library/itertools.rst:817 +#: ../../library/itertools.rst:822 msgid "" "Substantially all of these recipes and many, many others can be installed " "from the :pypi:`more-itertools` project found on the Python Package Index::" @@ -1789,11 +1803,11 @@ msgstr "" "幾乎所有這些應用技巧以及許多其他應用技巧都可以從 Python Package Index 上的 :" "pypi:`more-itertools` 專案中安裝: ::" -#: ../../library/itertools.rst:821 +#: ../../library/itertools.rst:826 msgid "python -m pip install more-itertools" msgstr "python -m pip install more-itertools" -#: ../../library/itertools.rst:823 +#: ../../library/itertools.rst:828 msgid "" "Many of the recipes offer the same high performance as the underlying " "toolset. Superior memory performance is kept by processing elements one at a " @@ -1811,7 +1825,7 @@ msgstr "" "用「向量化 (vectorized)」的構建塊而不是使用會造成直譯器負擔的 for 迴圈和\\ :" "term:`產生器 `,則能保持高速度。" -#: ../../library/itertools.rst:831 +#: ../../library/itertools.rst:836 msgid "" "from itertools import (accumulate, batched, chain, combinations, compress,\n" " count, cycle, filterfalse, groupby, islice, permutations, product,\n" diff --git a/library/json.po b/library/json.po index b7568cac641..594619ce6ac 100644 --- a/library/json.po +++ b/library/json.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-22 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-08-05 15:25+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!json` --- JSON encoder and decoder" msgstr ":mod:`!json` --- JSON 編碼器與解碼器" -#: ../../library/json.rst:10 +#: ../../library/json.rst:7 msgid "**Source code:** :source:`Lib/json/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/json/__init__.py`" -#: ../../library/json.rst:14 +#: ../../library/json.rst:11 msgid "" "`JSON (JavaScript Object Notation) `_, specified by :rfc:" "`7159` (which obsoletes :rfc:`4627`) and by `ECMA-404 `_ 的物件字面語法 (object literal syntax)(雖然它並不是 " "JavaScript 的嚴格子集 [#rfc-errata]_\\ )。" -#: ../../library/json.rst:22 +#: ../../library/json.rst:19 msgid "" "The term \"object\" in the context of JSON processing in Python can be " "ambiguous. All values in Python are objects. In JSON, an object refers to " "any data wrapped in curly braces, similar to a Python dictionary." msgstr "" -#: ../../library/json.rst:27 +#: ../../library/json.rst:24 msgid "" "Be cautious when parsing JSON data from untrusted sources. A malicious JSON " "string may cause the decoder to consume considerable CPU and memory " @@ -60,7 +60,7 @@ msgstr "" "當剖析無法信任來源的 JSON 資料時要小心。一段惡意的 JSON 字串可能會導致解碼器" "耗費大量 CPU 與記憶體資源。建議限制剖析資料的大小。" -#: ../../library/json.rst:31 +#: ../../library/json.rst:28 msgid "" "This module exposes an API familiar to users of the standard library :mod:" "`marshal` and :mod:`pickle` modules." @@ -68,11 +68,11 @@ msgstr "" "此模組為習慣標準函式庫 :mod:`marshal` 與 :mod:`pickle` 模組的使用者提供熟悉" "的 API。" -#: ../../library/json.rst:34 +#: ../../library/json.rst:31 msgid "Encoding basic Python object hierarchies::" msgstr "對基本 Python 物件階層進行編碼: ::" -#: ../../library/json.rst:36 +#: ../../library/json.rst:33 msgid "" ">>> import json\n" ">>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])\n" @@ -108,11 +108,11 @@ msgstr "" ">>> io.getvalue()\n" "'[\"streaming API\"]'" -#: ../../library/json.rst:53 +#: ../../library/json.rst:50 msgid "Compact encoding::" msgstr "改用緊湊型編碼方式: ::" -#: ../../library/json.rst:55 +#: ../../library/json.rst:52 msgid "" ">>> import json\n" ">>> json.dumps([1, 2, 3, {'4': 5, '6': 7}], separators=(',', ':'))\n" @@ -122,11 +122,11 @@ msgstr "" ">>> json.dumps([1, 2, 3, {'4': 5, '6': 7}], separators=(',', ':'))\n" "'[1,2,3,{\"4\":5,\"6\":7}]'" -#: ../../library/json.rst:59 +#: ../../library/json.rst:56 msgid "Pretty printing::" msgstr "美化輸出: ::" -#: ../../library/json.rst:61 +#: ../../library/json.rst:58 msgid "" ">>> import json\n" ">>> print(json.dumps({'6': 7, '4': 5}, sort_keys=True, indent=4))\n" @@ -142,11 +142,11 @@ msgstr "" " \"6\": 7\n" "}" -#: ../../library/json.rst:68 +#: ../../library/json.rst:65 msgid "Customizing JSON object encoding::" msgstr "自訂 JSON 物件編碼方式: ::" -#: ../../library/json.rst:70 +#: ../../library/json.rst:67 msgid "" ">>> import json\n" ">>> def custom_json(obj):\n" @@ -168,11 +168,11 @@ msgstr "" ">>> json.dumps(1 + 2j, default=custom_json)\n" "'{\"__complex__\": true, \"real\": 1.0, \"imag\": 2.0}'" -#: ../../library/json.rst:79 +#: ../../library/json.rst:76 msgid "Decoding JSON::" msgstr "JSON 解碼: ::" -#: ../../library/json.rst:81 +#: ../../library/json.rst:78 msgid "" ">>> import json\n" ">>> json.loads('[\"foo\", {\"bar\":[\"baz\", null, 1.0, 2]}]')\n" @@ -194,11 +194,11 @@ msgstr "" ">>> json.load(io)\n" "['streaming API']" -#: ../../library/json.rst:91 +#: ../../library/json.rst:88 msgid "Customizing JSON object decoding::" msgstr "自訂 JSON 物件解碼方式: ::" -#: ../../library/json.rst:93 +#: ../../library/json.rst:90 msgid "" ">>> import json\n" ">>> def as_complex(dct):\n" @@ -226,11 +226,11 @@ msgstr "" ">>> json.loads('1.1', parse_float=decimal.Decimal)\n" "Decimal('1.1')" -#: ../../library/json.rst:106 +#: ../../library/json.rst:103 msgid "Extending :class:`JSONEncoder`::" msgstr "繼承 :class:`JSONEncoder` 類別並自行擴充額外的編碼方法: ::" -#: ../../library/json.rst:108 +#: ../../library/json.rst:105 msgid "" ">>> import json\n" ">>> class ComplexEncoder(json.JSONEncoder):\n" @@ -248,11 +248,11 @@ msgid "" "['[2.0', ', 1.0', ']']" msgstr "" -#: ../../library/json.rst:124 +#: ../../library/json.rst:121 msgid "Using :mod:`!json` from the shell to validate and pretty-print:" msgstr "在 shell 使用 :mod:`!json` 來驗證和美化印出:" -#: ../../library/json.rst:126 +#: ../../library/json.rst:123 msgid "" "$ echo '{\"json\":\"obj\"}' | python -m json\n" "{\n" @@ -268,11 +268,11 @@ msgstr "" "$ echo '{1.2:3.4}' | python -m json\n" "Expecting property name enclosed in double quotes: line 1 column 2 (char 1)" -#: ../../library/json.rst:135 +#: ../../library/json.rst:132 msgid "See :ref:`json-commandline` for detailed documentation." msgstr "更詳盡的文件請見 :ref:`json-commandline`。" -#: ../../library/json.rst:139 +#: ../../library/json.rst:136 msgid "" "JSON is a subset of `YAML `_ 1.2. The JSON produced by " "this module's default settings (in particular, the default *separators* " @@ -284,7 +284,7 @@ msgstr "" "輸出也符合 YAML 1.0 和 1.1 的子集合規範。因此你也可以利用這個模組來當作 YAML " "的序列化工具(serializer)。" -#: ../../library/json.rst:146 +#: ../../library/json.rst:143 msgid "" "This module's encoders and decoders preserve input and output order by " "default. Order is only lost if the underlying containers are unordered." @@ -292,11 +292,11 @@ msgstr "" "這個模組的編、解碼器預設會保存輸入與輸出資料的順序關係,除非一開始的輸入本身" "就是無序的。" -#: ../../library/json.rst:151 +#: ../../library/json.rst:148 msgid "Basic Usage" msgstr "基本用法" -#: ../../library/json.rst:158 +#: ../../library/json.rst:155 msgid "" "Serialize *obj* as a JSON formatted stream to *fp* (a ``.write()``-" "supporting :term:`file-like object`) using this :ref:`Python-to-JSON " @@ -308,7 +308,7 @@ msgstr "" # SkyLull: 我想這裡的 "framed protocol" 指的是 # https://peps.python.org/pep-3154/#framing -#: ../../library/json.rst:164 +#: ../../library/json.rst:161 msgid "" "Unlike :mod:`pickle` and :mod:`marshal`, JSON is not a framed protocol, so " "trying to serialize multiple objects with repeated calls to :func:`dump` " @@ -322,25 +322,25 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../library/json.rst:168 +#: ../../library/json.rst:165 msgid "The Python object to be serialized." msgstr "要被序列化的 Python 物件。" -#: ../../library/json.rst:171 +#: ../../library/json.rst:168 msgid "" "The file-like object *obj* will be serialized to. The :mod:`!json` module " "always produces :class:`str` objects, not :class:`bytes` objects, therefore " "``fp.write()`` must support :class:`str` input." msgstr "" -#: ../../library/json.rst:178 +#: ../../library/json.rst:175 msgid "" "If ``True``, keys that are not of a basic type (:class:`str`, :class:`int`, :" "class:`float`, :class:`bool`, ``None``) will be skipped instead of raising " "a :exc:`TypeError`. Default ``False``." msgstr "" -#: ../../library/json.rst:184 +#: ../../library/json.rst:181 msgid "" "If ``True`` (the default), the output is guaranteed to have all incoming non-" "ASCII and non-printable characters escaped. If ``False``, all characters " @@ -349,7 +349,7 @@ msgid "" "U+001F." msgstr "" -#: ../../library/json.rst:191 +#: ../../library/json.rst:188 msgid "" "If ``False``, the circular reference check for container types is skipped " "and a circular reference will result in a :exc:`RecursionError` (or worse). " @@ -359,7 +359,7 @@ msgstr "" "跳過,若有循環參照則最後將引發 :exc:`RecursionError`\\ (或其他更糟的錯誤)。" "預設為 ``True``。" -#: ../../library/json.rst:196 +#: ../../library/json.rst:193 msgid "" "If ``False``, serialization of out-of-range :class:`float` values (``nan``, " "``inf``, ``-inf``) will result in a :exc:`ValueError`, in strict compliance " @@ -371,14 +371,14 @@ msgstr "" "值),則將使用它們的 JavaScript 等效表示 (``NaN``, ``Infinity``, ``-" "Infinity``)。" -#: ../../library/json.rst:203 +#: ../../library/json.rst:200 msgid "" "If set, a custom JSON encoder with the :meth:`~JSONEncoder.default` method " "overridden, for serializing into custom datatypes. If ``None`` (the " "default), :class:`!JSONEncoder` is used." msgstr "" -#: ../../library/json.rst:210 +#: ../../library/json.rst:207 msgid "" "If a positive integer or string, JSON array elements and object members will " "be pretty-printed with that indent level. A positive integer indents that " @@ -387,7 +387,7 @@ msgid "" "inserted. If ``None`` (the default), no newlines are inserted." msgstr "" -#: ../../library/json.rst:220 +#: ../../library/json.rst:217 msgid "" "A two-tuple: ``(item_separator, key_separator)``. If ``None`` (the default), " "*separators* defaults to ``(', ', ': ')`` if *indent* is ``None``, and " @@ -398,19 +398,19 @@ msgstr "" "則 *separators* 被預設為 ``(', ', ': ')``,否則預設為 ``(',', ': ')``。想要獲" "得最緊湊的 JSON 表示形式,你可以指定 ``(',', ':')`` 來消除空格。" -#: ../../library/json.rst:229 +#: ../../library/json.rst:226 msgid "" "A function that is called for objects that can't otherwise be serialized. It " "should return a JSON encodable version of the object or raise a :exc:" "`TypeError`. If ``None`` (the default), :exc:`!TypeError` is raised." msgstr "" -#: ../../library/json.rst:236 +#: ../../library/json.rst:233 msgid "" "If ``True``, dictionaries will be outputted sorted by key. Default ``False``." msgstr "" -#: ../../library/json.rst:242 +#: ../../library/json.rst:239 msgid "" "Keys in key/value pairs of JSON are always of the type :class:`str`. When a " "dictionary is converted into JSON, all the keys of the dictionary are " @@ -426,21 +426,21 @@ msgstr "" "``loads(dumps(x)) != x``。*sort_keys* 會在鍵被轉換為字串之前進行排序,因此數" "值鍵會依其數值排序,而非依其字串表示法排序。" -#: ../../library/json.rst:250 ../../library/json.rst:528 +#: ../../library/json.rst:247 ../../library/json.rst:548 msgid "Allow strings for *indent* in addition to integers." msgstr "除了整數之外,*indent* 還允許使用字串作為輸入。" -#: ../../library/json.rst:253 ../../library/json.rst:536 +#: ../../library/json.rst:250 ../../library/json.rst:556 msgid "Use ``(',', ': ')`` as default if *indent* is not ``None``." msgstr "如果 *indent* 不是 ``None``,則使用 ``(',', ': ')`` 作為預設值" -#: ../../library/json.rst:256 ../../library/json.rst:346 +#: ../../library/json.rst:253 ../../library/json.rst:352 msgid "" "All optional parameters are now :ref:`keyword-only `." msgstr "" "所有可選參數現在都是\\ :ref:`僅限關鍵字 `\\ 參數了。" -#: ../../library/json.rst:265 +#: ../../library/json.rst:262 msgid "" "Serialize *obj* to a JSON formatted :class:`str` using this :ref:`conversion " "table `. The arguments have the same meaning as in :func:" @@ -449,7 +449,7 @@ msgstr "" "使用此\\ :ref:`轉換表 `\\ 來將 *obj* 序列化為 JSON 格式 :" "class:`str`。這個引數的作用與 :func:`dump` 中的同名引數意義相同。" -#: ../../library/json.rst:273 +#: ../../library/json.rst:270 msgid "" "Deserialize *fp* to a Python object using the :ref:`JSON-to-Python " "conversion table `." @@ -457,20 +457,20 @@ msgstr "" "使用此 :ref:`JSON-to-Python 轉換表 `\\ 將 *fp* 解碼為 " "Python 物件。" -#: ../../library/json.rst:276 +#: ../../library/json.rst:273 msgid "" "A ``.read()``-supporting :term:`text file` or :term:`binary file` containing " "the JSON document to be deserialized." msgstr "" -#: ../../library/json.rst:281 +#: ../../library/json.rst:278 msgid "" "If set, a custom JSON decoder. Additional keyword arguments to :func:`!load` " "will be passed to the constructor of *cls*. If ``None`` (the default), :" "class:`!JSONDecoder` is used." msgstr "" -#: ../../library/json.rst:288 +#: ../../library/json.rst:285 msgid "" "If set, a function that is called with the result of any JSON object literal " "decoded (a :class:`dict`). The return value of this function will be used " @@ -482,7 +482,7 @@ msgstr "" "函式。此函式的回傳值將用來取代 :class:`dict`。此功能可用於實作自訂解碼器,例" "如 `JSON-RPC `_ 類別提示。預設為 ``None``。" -#: ../../library/json.rst:298 +#: ../../library/json.rst:295 msgid "" "If set, a function that is called with the result of any JSON object literal " "decoded with an ordered list of pairs. The return value of this function " @@ -494,7 +494,18 @@ msgstr "" "式的回傳值將用來取代 :class:`dict`。此功能可用於實作自訂解碼器。如果也設定了 " "*object_hook*,以 *object_pairs_hook* 優先。預設為 ``None``。" -#: ../../library/json.rst:308 +#: ../../library/json.rst:305 +msgid "" +"If set, a function that is called with the result of any JSON array literal " +"decoded with as a Python list. The return value of this function will be " +"used instead of the :class:`list`. This feature can be used to implement " +"custom decoders. Default ``None``." +msgstr "" +"如果有設定,會用任何 JSON 陣列字面值解碼為 Python list 的結果來呼叫此函式。此" +"函式的回傳值將用來取代 :class:`list`。此功能可用於實作自訂解碼器。預設為 " +"``None``。" + +#: ../../library/json.rst:314 msgid "" "If set, a function that is called with the string of every JSON float to be " "decoded. If ``None`` (the default), it is equivalent to ``float(num_str)``. " @@ -505,7 +516,7 @@ msgstr "" "``None``\\ (預設值),則等同於 ``float(num_str)``。此功能可用於將 JSON 浮點" "數剖析為自訂資料型別,例如 :class:`decimal.Decimal`。" -#: ../../library/json.rst:316 +#: ../../library/json.rst:322 msgid "" "If set, a function that is called with the string of every JSON int to be " "decoded. If ``None`` (the default), it is equivalent to ``int(num_str)``. " @@ -516,7 +527,7 @@ msgstr "" "(預設值),則等同於 ``int(num_str)``。此功能可用於將 JSON 整數剖析為自訂資料" "型別,例如 :class:`float`。" -#: ../../library/json.rst:324 +#: ../../library/json.rst:330 msgid "" "If set, a function that is called with one of the following strings: ``'-" "Infinity'``, ``'Infinity'``, or ``'NaN'``. This can be used to raise an " @@ -529,26 +540,26 @@ msgstr "" msgid "Raises" msgstr "" -#: ../../library/json.rst:332 +#: ../../library/json.rst:338 msgid "When the data being deserialized is not a valid JSON document." msgstr "當被去序列化的資料不是有效的 JSON 文件時。" -#: ../../library/json.rst:335 +#: ../../library/json.rst:341 msgid "" "When the data being deserialized does not contain UTF-8, UTF-16 or UTF-32 " "encoded data." msgstr "當被去序列化的資料不包含 UTF-8、UTF-16 或 UTF-32 編碼資料時。" -#: ../../library/json.rst:341 +#: ../../library/json.rst:347 msgid "Added the optional *object_pairs_hook* parameter." msgstr "新增可選的 *object_pairs_hook* 參數。" -#: ../../library/json.rst:342 +#: ../../library/json.rst:348 msgid "*parse_constant* doesn't get called on 'null', 'true', 'false' anymore." msgstr "" "遭遇 'null'、'true' 或 'false' 時不再以 *parse_constant* 給定的函式來處理了。" -#: ../../library/json.rst:347 +#: ../../library/json.rst:353 msgid "" "*fp* can now be a :term:`binary file`. The input encoding should be UTF-8, " "UTF-16 or UTF-32." @@ -556,7 +567,7 @@ msgstr "" "現在,*fp* 可以是一個\\ :term:`二進位檔案 `,前提是其編碼格式為 " "UTF-8、UTF-16 或 UTF-32。" -#: ../../library/json.rst:350 +#: ../../library/json.rst:356 msgid "" "The default *parse_int* of :func:`int` now limits the maximum length of the " "integer string via the interpreter's :ref:`integer string conversion length " @@ -566,7 +577,11 @@ msgstr "" "由直譯器的\\ :ref:`整數字串轉換長度限制 `\\ 機制來達成," "這能防止阻斷服務攻擊 (Denial of Service attacks)。" -#: ../../library/json.rst:358 +#: ../../library/json.rst:362 +msgid "Added the optional *array_hook* parameter." +msgstr "新增可選的 *array_hook* 參數。" + +#: ../../library/json.rst:367 msgid "" "Identical to :func:`load`, but instead of a file-like object, deserialize " "*s* (a :class:`str`, :class:`bytes` or :class:`bytearray` instance " @@ -577,7 +592,7 @@ msgstr "" "table>`\\ 將 *s*\\ (一個包含 JSON 文件的 :class:`str`、:class:`bytes` 或 :" "class:`bytearray` 實例)去序列化為 Python 物件。" -#: ../../library/json.rst:363 +#: ../../library/json.rst:372 msgid "" "*s* can now be of type :class:`bytes` or :class:`bytearray`. The input " "encoding should be UTF-8, UTF-16 or UTF-32." @@ -585,95 +600,95 @@ msgstr "" "現在,*s* 可以是一個二進位檔案如 :class:`bytes` 或 :class:`bytearray`,前提是" "其編碼格式為 UTF-8、UTF-16 或 UTF-32。" -#: ../../library/json.rst:367 +#: ../../library/json.rst:376 msgid "The keyword argument *encoding* has been removed." msgstr "刪除關鍵字引數 *encoding*。" -#: ../../library/json.rst:372 +#: ../../library/json.rst:381 msgid "Encoders and Decoders" msgstr "編碼器與解碼器" -#: ../../library/json.rst:376 +#: ../../library/json.rst:385 msgid "Simple JSON decoder." msgstr "簡易 JSON 解碼器" -#: ../../library/json.rst:378 +#: ../../library/json.rst:387 msgid "Performs the following translations in decoding by default:" msgstr "預設將執行下列資料型別轉換:" -#: ../../library/json.rst:383 ../../library/json.rst:471 +#: ../../library/json.rst:392 ../../library/json.rst:488 msgid "JSON" msgstr "JSON" -#: ../../library/json.rst:383 ../../library/json.rst:471 +#: ../../library/json.rst:392 ../../library/json.rst:488 msgid "Python" msgstr "Python" -#: ../../library/json.rst:385 ../../library/json.rst:473 +#: ../../library/json.rst:394 ../../library/json.rst:490 msgid "object" msgstr "object" -#: ../../library/json.rst:385 ../../library/json.rst:473 +#: ../../library/json.rst:394 msgid "dict" msgstr "dict" -#: ../../library/json.rst:387 ../../library/json.rst:475 +#: ../../library/json.rst:396 ../../library/json.rst:492 msgid "array" msgstr "array" -#: ../../library/json.rst:387 +#: ../../library/json.rst:396 msgid "list" msgstr "list" -#: ../../library/json.rst:389 ../../library/json.rst:477 +#: ../../library/json.rst:398 ../../library/json.rst:494 msgid "string" msgstr "string" -#: ../../library/json.rst:389 ../../library/json.rst:477 +#: ../../library/json.rst:398 ../../library/json.rst:494 msgid "str" msgstr "str" -#: ../../library/json.rst:391 +#: ../../library/json.rst:400 msgid "number (int)" msgstr "number (整數)" -#: ../../library/json.rst:391 +#: ../../library/json.rst:400 msgid "int" msgstr "int" -#: ../../library/json.rst:393 +#: ../../library/json.rst:402 msgid "number (real)" msgstr "number (實數)" -#: ../../library/json.rst:393 +#: ../../library/json.rst:402 msgid "float" msgstr "float" -#: ../../library/json.rst:395 ../../library/json.rst:481 +#: ../../library/json.rst:404 ../../library/json.rst:498 msgid "true" msgstr "true" -#: ../../library/json.rst:395 ../../library/json.rst:481 +#: ../../library/json.rst:404 ../../library/json.rst:498 msgid "True" msgstr "True" -#: ../../library/json.rst:397 ../../library/json.rst:483 +#: ../../library/json.rst:406 ../../library/json.rst:500 msgid "false" msgstr "false" -#: ../../library/json.rst:397 ../../library/json.rst:483 +#: ../../library/json.rst:406 ../../library/json.rst:500 msgid "False" msgstr "False" -#: ../../library/json.rst:399 ../../library/json.rst:485 +#: ../../library/json.rst:408 ../../library/json.rst:502 msgid "null" msgstr "null" -#: ../../library/json.rst:399 ../../library/json.rst:485 +#: ../../library/json.rst:408 ../../library/json.rst:502 msgid "None" msgstr "None" -#: ../../library/json.rst:402 +#: ../../library/json.rst:411 msgid "" "It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as their " "corresponding ``float`` values, which is outside the JSON spec." @@ -681,7 +696,7 @@ msgstr "" "雖然 ``NaN``、``Infinity`` 和 ``-Infinity`` 並不符合 JSON 規範,但解碼器依然" "能正確地將其轉換到相應的 Python ``float`` 值。" -#: ../../library/json.rst:405 +#: ../../library/json.rst:414 msgid "" "*object_hook* is an optional function that will be called with the result of " "every JSON object decoded and its return value will be used in place of the " @@ -692,7 +707,7 @@ msgstr "" "回傳值來取代原先的 :class:`dict`。這個功能可用於提供自訂的去序列化(例如支援 " "`JSON-RPC `_ 類別提示)。" -#: ../../library/json.rst:410 +#: ../../library/json.rst:419 msgid "" "*object_pairs_hook* is an optional function that will be called with the " "result of every JSON object decoded with an ordered list of pairs. The " @@ -701,11 +716,25 @@ msgid "" "*object_hook* is also defined, the *object_pairs_hook* takes priority." msgstr "" -#: ../../library/json.rst:416 +#: ../../library/json.rst:425 msgid "Added support for *object_pairs_hook*." msgstr "新增對於 *object_pairs_hook* 的支援。" -#: ../../library/json.rst:419 +#: ../../library/json.rst:428 +msgid "" +"*array_hook* is an optional function that will be called with the result of " +"every JSON array decoded as a list. The return value of *array_hook* will be " +"used instead of the :class:`list`. This feature can be used to implement " +"custom decoders." +msgstr "" +"*array_hook* 是一個可選函式,其接受每個解碼為 list 的 JSON 陣列作為輸入,並使" +"用其回傳值來取代原先的 :class:`list`。這個功能可用於實作自訂解碼器。" + +#: ../../library/json.rst:433 +msgid "Added support for *array_hook*." +msgstr "新增對於 *array_hook* 的支援。" + +#: ../../library/json.rst:436 msgid "" "*parse_float* is an optional function that will be called with the string of " "every JSON float to be decoded. By default, this is equivalent to " @@ -716,7 +745,7 @@ msgstr "" "的函式來進行解碼。預設情況這等效於 ``float(num_str)``。這個參數可用於將 JSON " "中的浮點數解碼或剖析為另一種資料型別(例如 :class:`decimal.Decimal`\\ )。" -#: ../../library/json.rst:424 +#: ../../library/json.rst:441 msgid "" "*parse_int* is an optional function that will be called with the string of " "every JSON int to be decoded. By default, this is equivalent to " @@ -727,7 +756,7 @@ msgstr "" "``int(num_str)``。這個參數可用於將 JSON 中的整數解碼或剖析為另一種資料型別" "(例如 :class:`float`)。" -#: ../../library/json.rst:429 +#: ../../library/json.rst:446 msgid "" "*parse_constant* is an optional function that will be called with one of the " "following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be " @@ -737,7 +766,7 @@ msgstr "" "``'Infinity'`` 或 ``'NaN'`` 其中之一則會改用這個參數給定的函式來進行解碼。這" "也可用於使解碼過程中遇到無效的 JSON 數字時引發一個例外。" -#: ../../library/json.rst:433 +#: ../../library/json.rst:450 msgid "" "If *strict* is false (``True`` is the default), then control characters will " "be allowed inside strings. Control characters in this context are those " @@ -748,7 +777,7 @@ msgstr "" "語境中的控制字元指的是 ASCII 字元編碼在 0~31 範圍內的字元,包括 ``'\\t'``" "(tab)、``'\\n'``、``'\\r'`` 和 ``'\\0'``。" -#: ../../library/json.rst:438 +#: ../../library/json.rst:455 msgid "" "If the data being deserialized is not a valid JSON document, a :exc:" "`JSONDecodeError` will be raised." @@ -756,25 +785,25 @@ msgstr "" "如果被去序列化(deserialized)的資料不符合 JSON 格式,將會引發 :exc:" "`JSONDecodeError` 例外。" -#: ../../library/json.rst:441 ../../library/json.rst:544 +#: ../../library/json.rst:458 ../../library/json.rst:564 msgid "All parameters are now :ref:`keyword-only `." msgstr "" "所有參數現在都是\\ :ref:`僅限關鍵字參數 `\\ 了。" -#: ../../library/json.rst:446 +#: ../../library/json.rst:463 msgid "" "Return the Python representation of *s* (a :class:`str` instance containing " "a JSON document)." msgstr "" "回傳用 Python 型式表達的 *s* (一個含有 JSON 文件的 :class:`str` 實例)。" -#: ../../library/json.rst:449 +#: ../../library/json.rst:466 msgid "" ":exc:`JSONDecodeError` will be raised if the given JSON document is not " "valid." msgstr "若給定的輸入不符合 JSON 格式會引發 :exc:`JSONDecodeError` 例外。" -#: ../../library/json.rst:454 +#: ../../library/json.rst:471 msgid "" "Decode a JSON document from *s* (a :class:`str` beginning with a JSON " "document) and return a 2-tuple of the Python representation and the index in " @@ -783,40 +812,48 @@ msgstr "" "將 *s* (一個開頭部分含有合格 JSON 文件的 :class:`str`) 解碼,並將 JSON 文件" "結束點的索引值(index)和解碼結果合併為一個二元組(2-tuple)後回傳。" -#: ../../library/json.rst:458 +#: ../../library/json.rst:475 msgid "" "This can be used to decode a JSON document from a string that may have " "extraneous data at the end." msgstr "這個方法可以用來解碼尾段可能帶有 JSON 以外資料的文字。" -#: ../../library/json.rst:464 +#: ../../library/json.rst:481 msgid "Extensible JSON encoder for Python data structures." msgstr "可擴充的 Python 資料結構 JSON 編碼器。" -#: ../../library/json.rst:466 +#: ../../library/json.rst:483 msgid "Supports the following objects and types by default:" msgstr "預設可支援下列物件及型別:" -#: ../../library/json.rst:475 +#: ../../library/json.rst:490 +msgid "dict, frozendict" +msgstr "" + +#: ../../library/json.rst:492 msgid "list, tuple" msgstr "list, tuple" -#: ../../library/json.rst:479 +#: ../../library/json.rst:496 msgid "int, float, int- & float-derived Enums" msgstr "" "int、float 或可作為整數或浮點數運算的衍生列舉(int- or float-derived Enums)" -#: ../../library/json.rst:479 +#: ../../library/json.rst:496 msgid "number" msgstr "number" -#: ../../library/json.rst:488 +#: ../../library/json.rst:505 msgid "Added support for int- and float-derived Enum classes." msgstr "" "增加對整數(int)、浮點數(float)或可作為整數或浮點數運算的衍生列舉(int- " "or float-derived Enums)類別的支援性。" -#: ../../library/json.rst:491 +#: ../../library/json.rst:508 +msgid "Added support for :class:`frozendict`." +msgstr "新增對於 :class:`frozendict` 的支援。" + +#: ../../library/json.rst:511 msgid "" "To extend this to recognize other objects, subclass and implement a :meth:" "`~JSONEncoder.default` method with another method that returns a " @@ -827,7 +864,7 @@ msgstr "" "方法。此方法應回傳一個可序列化的 ``o`` 物件,否則此方法應呼叫父類別的 " "JSONEncoder.default 方法(以引發 :exc:`TypeError` 例外)。" -#: ../../library/json.rst:496 +#: ../../library/json.rst:516 msgid "" "If *skipkeys* is false (the default), a :exc:`TypeError` will be raised when " "trying to encode keys that are not :class:`str`, :class:`int`, :class:" @@ -838,7 +875,7 @@ msgstr "" "`int`、:class:`float`、:class:`bool` 或 ``None`` 的鍵值時,將引發 :exc:" "`TypeError`。如果 *skipkeys* 為 true,這些項目將直接被跳過。" -#: ../../library/json.rst:500 +#: ../../library/json.rst:520 msgid "" "If *ensure_ascii* is true (the default), the output is guaranteed to have " "all incoming non-ASCII and non-printable characters escaped. If " @@ -850,7 +887,7 @@ msgstr "" "元都會被跳脫。如果 *ensure_ascii* 為 false,則所有字元都將按原樣輸出,唯有必" "須跳脫的字元例外:引號、反斜線,以及控制字元 U+0000 到 U+001F。" -#: ../../library/json.rst:506 +#: ../../library/json.rst:526 msgid "" "If *check_circular* is true (the default), then lists, dicts, and custom " "encoded objects will be checked for circular references during encoding to " @@ -861,7 +898,7 @@ msgstr "" "(dict)和自訂編碼物件的循環參照,以防止無限遞迴(一個會導致 :exc:" "`RecursionError` 例外的問題)。否則不會進行此類檢查。" -#: ../../library/json.rst:511 +#: ../../library/json.rst:531 msgid "" "If *allow_nan* is true (the default), then ``NaN``, ``Infinity``, and ``-" "Infinity`` will be encoded as such. This behavior is not JSON specification " @@ -873,7 +910,7 @@ msgstr "" "數基於 JavaScript 的編碼器和解碼器一致。否則若設為 false,嘗試對這些浮點數進" "行編碼將引發 :exc:`ValueError` 例外。" -#: ../../library/json.rst:517 +#: ../../library/json.rst:537 msgid "" "If *sort_keys* is true (default: ``False``), then the output of dictionaries " "will be sorted by key; this is useful for regression tests to ensure that " @@ -883,7 +920,7 @@ msgstr "" "按鍵值排序。這項功能可確保 JSON 序列化的結果能被互相比較,能讓日常的回歸測試" "檢查變得方便一些。" -#: ../../library/json.rst:521 +#: ../../library/json.rst:541 msgid "" "If *indent* is a non-negative integer or string, then JSON array elements " "and object members will be pretty-printed with that indent level. An indent " @@ -897,7 +934,7 @@ msgstr "" "值)等於是選擇最緊湊的表示法。使用正整數縮排可以在每層縮排數量相同的空格。如" "果 *indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個層級。" -#: ../../library/json.rst:531 +#: ../../library/json.rst:551 msgid "" "If specified, *separators* should be an ``(item_separator, key_separator)`` " "tuple. The default is ``(', ', ': ')`` if *indent* is ``None`` and ``(',', " @@ -909,7 +946,7 @@ msgstr "" "')``,否則預設為 ``(',', ': ')``。想要獲得最緊湊的 JSON 表示形式,你可以改成" "指定 ``(',', ':')`` 來消除空格。" -#: ../../library/json.rst:539 +#: ../../library/json.rst:559 msgid "" "If specified, *default* should be a function that gets called for objects " "that can't otherwise be serialized. It should return a JSON encodable " @@ -920,7 +957,7 @@ msgstr "" "應該回傳該物件的 JSON 可編碼版本或引發 :exc:`TypeError`。如果未指定,則會直接" "引發 :exc:`TypeError`。" -#: ../../library/json.rst:550 +#: ../../library/json.rst:570 msgid "" "Implement this method in a subclass such that it returns a serializable " "object for *o*, or calls the base implementation (to raise a :exc:" @@ -929,7 +966,7 @@ msgstr "" "在任意一個子類別裡實作這個方法時須讓其回傳一個可序列化的物件 *o* ,或呼叫原始" "的實作以引發 :exc:`TypeError` 例外。" -#: ../../library/json.rst:554 +#: ../../library/json.rst:574 msgid "" "For example, to support arbitrary iterators, you could implement :meth:" "`~JSONEncoder.default` like this::" @@ -937,7 +974,7 @@ msgstr "" "舉例來說,想要讓編碼器支援任意疊代器(iterator),你可以實作這樣子的 :meth:" "`~JSONEncoder.default`: ::" -#: ../../library/json.rst:557 +#: ../../library/json.rst:577 msgid "" "def default(self, o):\n" " try:\n" @@ -959,13 +996,13 @@ msgstr "" " # 讓基底類別的預設方法引發 TypeError\n" " return super().default(o)" -#: ../../library/json.rst:570 +#: ../../library/json.rst:590 msgid "" "Return a JSON string representation of a Python data structure, *o*. For " "example::" msgstr "回傳一個 Python 資料結構物件 *o* 的 JSON 的字串表示。例如: ::" -#: ../../library/json.rst:573 +#: ../../library/json.rst:593 msgid "" ">>> json.JSONEncoder().encode({\"foo\": [\"bar\", \"baz\"]})\n" "'{\"foo\": [\"bar\", \"baz\"]}'" @@ -973,7 +1010,7 @@ msgstr "" ">>> json.JSONEncoder().encode({\"foo\": [\"bar\", \"baz\"]})\n" "'{\"foo\": [\"bar\", \"baz\"]}'" -#: ../../library/json.rst:579 +#: ../../library/json.rst:599 msgid "" "Encode the given object, *o*, and yield each string representation as " "available. For example::" @@ -981,7 +1018,7 @@ msgstr "" "將物件 *o* 編碼,並將結果統整為一個能依序產生(yield)各結果字串的物件。如下" "例: ::" -#: ../../library/json.rst:582 +#: ../../library/json.rst:602 msgid "" "for chunk in json.JSONEncoder().iterencode(bigobject):\n" " mysocket.write(chunk)" @@ -989,39 +1026,39 @@ msgstr "" "for chunk in json.JSONEncoder().iterencode(bigobject):\n" " mysocket.write(chunk)" -#: ../../library/json.rst:587 +#: ../../library/json.rst:607 msgid "Exceptions" msgstr "例外" -#: ../../library/json.rst:591 +#: ../../library/json.rst:611 msgid "Subclass of :exc:`ValueError` with the following additional attributes:" msgstr ":exc:`ValueError` 的子類別具有下列額外屬性:" -#: ../../library/json.rst:595 +#: ../../library/json.rst:615 msgid "The unformatted error message." msgstr "未受格式化的錯誤訊息。" -#: ../../library/json.rst:599 +#: ../../library/json.rst:619 msgid "The JSON document being parsed." msgstr "正在被剖析的 JSON 文件。" -#: ../../library/json.rst:603 +#: ../../library/json.rst:623 msgid "The start index of *doc* where parsing failed." msgstr "*doc* 剖析失敗處的起始點的索引值。" -#: ../../library/json.rst:607 +#: ../../library/json.rst:627 msgid "The line corresponding to *pos*." msgstr "*pos* 所在的列(line)數。" -#: ../../library/json.rst:611 +#: ../../library/json.rst:631 msgid "The column corresponding to *pos*." msgstr "*pos* 所在的行(column)數。" -#: ../../library/json.rst:617 +#: ../../library/json.rst:637 msgid "Standard Compliance and Interoperability" msgstr "合規性與互通性(Interoperability)" -#: ../../library/json.rst:619 +#: ../../library/json.rst:639 msgid "" "The JSON format is specified by :rfc:`7159` and by `ECMA-404 `_. This " @@ -1034,7 +1071,7 @@ msgstr "" "組對 RFC 的遵循程度。簡單起見,:class:`JSONEncoder` 和 :class:`JSONDecoder` " "子類別以及未明確提及的參數將不予討論。" -#: ../../library/json.rst:625 +#: ../../library/json.rst:645 msgid "" "This module does not comply with the RFC in a strict fashion, implementing " "some extensions that are valid JavaScript but not valid JSON. In particular:" @@ -1042,17 +1079,17 @@ msgstr "" "這個模組的部份實作並未非常嚴格地遵循 RFC 規範。準確來說,下列實際實作符合 " "JavaScript 語法格式,但並不符合 JSON 格式:" -#: ../../library/json.rst:628 +#: ../../library/json.rst:648 msgid "Infinite and NaN number values are accepted and output;" msgstr "無限(Infinite)和非數字(NaN)值會被接受。" -#: ../../library/json.rst:629 +#: ../../library/json.rst:649 msgid "" "Repeated names within an object are accepted, and only the value of the last " "name-value pair is used." msgstr "同一個物件內可以有重複的名稱,但只有最後一個同名物件是有效的。" -#: ../../library/json.rst:632 +#: ../../library/json.rst:652 msgid "" "Since the RFC permits RFC-compliant parsers to accept input texts that are " "not RFC-compliant, this module's deserializer is technically RFC-compliant " @@ -1061,11 +1098,11 @@ msgstr "" "不過 RFC 准許遵循 RFC 的剖析器接受不合規的文字輸入,所以技術上來說若以預設設" "定運作,本模組的去序列化器(deserializer)是符合 RFC 規範的。" -#: ../../library/json.rst:637 +#: ../../library/json.rst:657 msgid "Character Encodings" msgstr "字元編碼格式" -#: ../../library/json.rst:639 +#: ../../library/json.rst:659 msgid "" "The RFC requires that JSON be represented using either UTF-8, UTF-16, or " "UTF-32, with UTF-8 being the recommended default for maximum " @@ -1074,7 +1111,7 @@ msgstr "" "RFC 要求 JSON 必須以 UTF-8、UTF-16 或 UTF-32 格式編碼。並推薦以 UTF-8 編碼以" "達成最佳的互通性。" -#: ../../library/json.rst:642 +#: ../../library/json.rst:662 msgid "" "As permitted, though not required, by the RFC, this module's serializer sets " "*ensure_ascii=True* by default, thus escaping the output so that the " @@ -1083,7 +1120,7 @@ msgstr "" "RFC 准許但並不強制編碼器預設要設定 *ensure_ascii=True*,因此跳脫輸出使得結果" "字串只包含可列印的 ASCII 字元。" -#: ../../library/json.rst:646 +#: ../../library/json.rst:666 msgid "" "Other than the *ensure_ascii* parameter, this module is defined strictly in " "terms of conversion between Python objects and :class:`Unicode strings " @@ -1093,7 +1130,7 @@ msgstr "" "除了 *ensure_ascii* 選項參數之外,本模組嚴格遵循 Python 物件與 :class:" "`Unicode strings ` 之間的轉換規範,因此並不另外處理字元編碼的問題。" -#: ../../library/json.rst:651 +#: ../../library/json.rst:671 msgid "" "The RFC prohibits adding a byte order mark (BOM) to the start of a JSON " "text, and this module's serializer does not add a BOM to its output. The RFC " @@ -1106,7 +1143,7 @@ msgstr "" "(deserializer)忽略文件初始的端序記號,因此本模組的去序列化器將在遭遇位於文" "件開頭的端序記號時引發 :exc:`ValueError` 例外。" -#: ../../library/json.rst:657 +#: ../../library/json.rst:677 msgid "" "The RFC does not explicitly forbid JSON strings which contain byte sequences " "that don't correspond to valid Unicode characters (e.g. unpaired UTF-16 " @@ -1119,11 +1156,11 @@ msgstr "" "預設情況下,當原始輸入的 :class:`str` 中存在此類序列時,該模組將接受並輸出這" "些序列的編碼位置(code points)。" -#: ../../library/json.rst:665 +#: ../../library/json.rst:685 msgid "Infinite and NaN Number Values" msgstr "正負無限與非數值" -#: ../../library/json.rst:667 +#: ../../library/json.rst:687 msgid "" "The RFC does not permit the representation of infinite or NaN number values. " "Despite that, by default, this module accepts and outputs ``Infinity``, ``-" @@ -1132,7 +1169,7 @@ msgstr "" "RFC 不允許表現無限大或非數值(NaN)。但預設情況下,這個模組仍接受並輸出 " "``Infinity``、``-Infinity`` 和 ``NaN``,如同它們是有效的 JSON 數值字面值: ::" -#: ../../library/json.rst:671 +#: ../../library/json.rst:691 msgid "" ">>> # Neither of these calls raises an exception, but the results are not " "valid JSON\n" @@ -1147,7 +1184,7 @@ msgid "" "nan" msgstr "" -#: ../../library/json.rst:682 +#: ../../library/json.rst:702 msgid "" "In the serializer, the *allow_nan* parameter can be used to alter this " "behavior. In the deserializer, the *parse_constant* parameter can be used " @@ -1156,11 +1193,11 @@ msgstr "" "在序列化器中,*allow_nan* 參數可以改變這個行為。在去序列化器中," "*parse_constant* 參數可以改變這個行為。" -#: ../../library/json.rst:688 +#: ../../library/json.rst:708 msgid "Repeated Names Within an Object" msgstr "物件內重複的名稱" -#: ../../library/json.rst:690 +#: ../../library/json.rst:710 msgid "" "The RFC specifies that the names within a JSON object should be unique, but " "does not mandate how repeated names in JSON objects should be handled. By " @@ -1171,7 +1208,7 @@ msgstr "" "字。預設情況下,本模組不會因此引發例外;相反的,它會忽略該名字的所有重複鍵值" "對,並只保留最後一個: ::" -#: ../../library/json.rst:695 +#: ../../library/json.rst:715 msgid "" ">>> weird_json = '{\"x\": 1, \"x\": 2, \"x\": 3}'\n" ">>> json.loads(weird_json)\n" @@ -1181,15 +1218,15 @@ msgstr "" ">>> json.loads(weird_json)\n" "{'x': 3}" -#: ../../library/json.rst:699 +#: ../../library/json.rst:719 msgid "The *object_pairs_hook* parameter can be used to alter this behavior." msgstr "*object_pairs_hook* 參數可以改變這個行為。" -#: ../../library/json.rst:703 +#: ../../library/json.rst:723 msgid "Top-level Non-Object, Non-Array Values" msgstr "位於頂層的非物件及非列表值" -#: ../../library/json.rst:705 +#: ../../library/json.rst:725 msgid "" "The old version of JSON specified by the obsolete :rfc:`4627` required that " "the top-level value of a JSON text must be either a JSON object or array " @@ -1203,37 +1240,37 @@ msgstr "" "boolean、數字或字串值。 :rfc:`7159` 移除了這個限制,而本模組的序列化器或去串" "列化器中未曾實施過該限制。" -#: ../../library/json.rst:712 +#: ../../library/json.rst:732 msgid "" "Regardless, for maximum interoperability, you may wish to voluntarily adhere " "to the restriction yourself." msgstr "如果想要最大限度地保留互通性,你可能還是會想要自行施加這個限制。" -#: ../../library/json.rst:717 +#: ../../library/json.rst:737 msgid "Implementation Limitations" msgstr "實作限制" -#: ../../library/json.rst:719 +#: ../../library/json.rst:739 msgid "Some JSON deserializer implementations may set limits on:" msgstr "某些 JSON 去序列化器的實作可能會造成下列限制:" -#: ../../library/json.rst:721 +#: ../../library/json.rst:741 msgid "the size of accepted JSON texts" msgstr "JSON 文件長度上限" -#: ../../library/json.rst:722 +#: ../../library/json.rst:742 msgid "the maximum level of nesting of JSON objects and arrays" msgstr "JSON 物件或陣列的最大巢狀層數(level of nesting)限制" -#: ../../library/json.rst:723 +#: ../../library/json.rst:743 msgid "the range and precision of JSON numbers" msgstr "數字的精準度或範圍" -#: ../../library/json.rst:724 +#: ../../library/json.rst:744 msgid "the content and maximum length of JSON strings" msgstr "JSON 字串長度上限" -#: ../../library/json.rst:726 +#: ../../library/json.rst:746 msgid "" "This module does not impose any such limits beyond those of the relevant " "Python datatypes themselves or the Python interpreter itself." @@ -1241,7 +1278,7 @@ msgstr "" "本模組除了 Python 資料型別本身或 Python 直譯器本身的限制以外,不會設定任何此" "類限制。" -#: ../../library/json.rst:729 +#: ../../library/json.rst:749 msgid "" "When serializing to JSON, beware any such limitations in applications that " "may consume your JSON. In particular, it is common for JSON numbers to be " @@ -1256,22 +1293,22 @@ msgstr "" "因而受到其表示範圍和精度限制的影響。這在序列化極大的 Python :class:`int` 數" "值、或是序列化特殊數字型別的實例時(例如 :class:`decimal.Decimal`)尤其重要。" -#: ../../library/json.rst:742 +#: ../../library/json.rst:762 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/json.rst:747 +#: ../../library/json.rst:767 msgid "**Source code:** :source:`Lib/json/tool.py`" msgstr "**原始碼:**\\ :source:`Lib/json/tool.py`" -#: ../../library/json.rst:751 +#: ../../library/json.rst:771 msgid "" "The :mod:`!json` module can be invoked as a script via ``python -m json`` to " "validate and pretty-print JSON objects. The :mod:`!json.tool` submodule " "implements this interface." msgstr "" -#: ../../library/json.rst:755 +#: ../../library/json.rst:775 msgid "" "If the optional ``infile`` and ``outfile`` arguments are not specified, :" "data:`sys.stdin` and :data:`sys.stdout` will be used respectively:" @@ -1279,7 +1316,7 @@ msgstr "" "如果沒有指定可選引數 ``infile`` 和 ``outfile`` ,則 :data:`sys.stdin` 和 :" "data:`sys.stdout` 將各自做為輸入和輸出的預設值。" -#: ../../library/json.rst:758 +#: ../../library/json.rst:778 msgid "" "$ echo '{\"json\": \"obj\"}' | python -m json\n" "{\n" @@ -1295,7 +1332,7 @@ msgstr "" "$ echo '{1.2:3.4}' | python -m json\n" "Expecting property name enclosed in double quotes: line 1 column 2 (char 1)" -#: ../../library/json.rst:767 +#: ../../library/json.rst:787 msgid "" "The output is now in the same order as the input. Use the :option:`--sort-" "keys` option to sort the output of dictionaries alphabetically by key." @@ -1303,22 +1340,22 @@ msgstr "" "現在開始輸出和輸入的資料順序會是相同的。傳入 :option:`--sort-keys` 引數以按照" "鍵值的字母順序對輸出進行排序。" -#: ../../library/json.rst:772 +#: ../../library/json.rst:792 msgid "" "The :mod:`!json` module may now be directly executed as ``python -m json``. " "For backwards compatibility, invoking the CLI as ``python -m json.tool`` " "remains supported." msgstr "" -#: ../../library/json.rst:779 +#: ../../library/json.rst:799 msgid "Command-line options" msgstr "命令列選項" -#: ../../library/json.rst:783 +#: ../../library/json.rst:803 msgid "The JSON file to be validated or pretty-printed:" msgstr "將被用於校驗或美化呈現的 JSON 文件:" -#: ../../library/json.rst:785 +#: ../../library/json.rst:805 msgid "" "$ python -m json mp_films.json\n" "[\n" @@ -1344,11 +1381,11 @@ msgstr "" " }\n" "]" -#: ../../library/json.rst:799 +#: ../../library/json.rst:819 msgid "If *infile* is not specified, read from :data:`sys.stdin`." msgstr "如果沒有指定 *infile* 則會從 :data:`sys.stdin` 讀取輸入。" -#: ../../library/json.rst:803 +#: ../../library/json.rst:823 msgid "" "Write the output of the *infile* to the given *outfile*. Otherwise, write it " "to :data:`sys.stdout`." @@ -1356,33 +1393,33 @@ msgstr "" "將 *infile* 的結果寫入到給定的 *outfile*。若未提供則寫入到 :data:`sys." "stdout`。" -#: ../../library/json.rst:808 +#: ../../library/json.rst:828 msgid "Sort the output of dictionaries alphabetically by key." msgstr "按照鍵值的字母順序對輸出字典進行排序。" -#: ../../library/json.rst:814 +#: ../../library/json.rst:834 msgid "" "Disable escaping of non-ascii characters, see :func:`json.dumps` for more " "information." msgstr "關閉非 ASCII 字元的自動跳脫功能。詳情請參照 :func:`json.dumps`。" -#: ../../library/json.rst:820 +#: ../../library/json.rst:840 msgid "Parse every input line as separate JSON object." msgstr "將每一行輸入都單獨輸出為一個 JSON 物件。" -#: ../../library/json.rst:826 +#: ../../library/json.rst:846 msgid "Mutually exclusive options for whitespace control." msgstr "互斥的空白字元控制選項。" -#: ../../library/json.rst:832 +#: ../../library/json.rst:852 msgid "Show the help message." msgstr "顯示說明訊息。" -#: ../../library/json.rst:836 +#: ../../library/json.rst:856 msgid "Footnotes" msgstr "註解" -#: ../../library/json.rst:837 +#: ../../library/json.rst:857 msgid "" "As noted in `the errata for RFC 7159 `_, JSON permits literal U+2028 (LINE SEPARATOR) " diff --git a/library/linecache.po b/library/linecache.po index bca9cbd203f..71f705ffa5b 100644 --- a/library/linecache.po +++ b/library/linecache.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-07-07 23:50+0800\n" "Last-Translator: Weilin Du <1372449351@qq.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!linecache` --- Random access to text lines" msgstr ":mod:`!linecache` --- 隨機存取文字列" -#: ../../library/linecache.rst:9 +#: ../../library/linecache.rst:7 msgid "**Source code:** :source:`Lib/linecache.py`" msgstr "**原始碼:**\\ :source:`Lib/linecache.py`" -#: ../../library/linecache.rst:13 +#: ../../library/linecache.rst:11 msgid "" "The :mod:`!linecache` module allows one to get any line from a Python source " "file, while attempting to optimize internally, using a cache, the common " @@ -39,7 +39,7 @@ msgstr "" "進行最佳化,會使用快取,這是從單一檔案讀取許多行的常見情況。 這被 :mod:" "`traceback` 模組用來擷取來自原始碼檔案的行,以包含在格式化的 traceback 中。" -#: ../../library/linecache.rst:18 +#: ../../library/linecache.rst:16 msgid "" "The :func:`tokenize.open` function is used to open files. This function " "uses :func:`tokenize.detect_encoding` to get the encoding of the file; in " @@ -49,11 +49,11 @@ msgstr "" "detect_encoding` 來取得檔案的編碼;在沒有編碼標記的情況下,檔案編碼預設為 " "UTF-8。" -#: ../../library/linecache.rst:22 +#: ../../library/linecache.rst:20 msgid "The :mod:`!linecache` module defines the following functions:" msgstr ":mod:`!linecache` 模組定義了下列函式:" -#: ../../library/linecache.rst:27 +#: ../../library/linecache.rst:25 msgid "" "Get line *lineno* from file named *filename*. This function will never raise " "an exception --- it will return ``''`` on errors (the terminating newline " @@ -62,7 +62,7 @@ msgstr "" "從名為 *filename* 的檔案中取得 *lineno* 行。這個函式不會產生例外 --- 它會在出" "錯時回傳 ``''`` (找到的行會包含終止換行字元)。" -#: ../../library/linecache.rst:33 +#: ../../library/linecache.rst:31 msgid "" "If *filename* indicates a frozen module (starting with ``'>> import linecache\n" ">>> linecache.getline(linecache.__file__, 8)\n" @@ -133,14 +133,14 @@ msgstr "" ">>> linecache.getline(linecache.__file__, 8)\n" "'import sys\\n'" -#: ../../library/linecache.rst:31 +#: ../../library/linecache.rst:29 msgid "module" msgstr "module(模組)" -#: ../../library/linecache.rst:31 +#: ../../library/linecache.rst:29 msgid "search" msgstr "search(搜尋)" -#: ../../library/linecache.rst:31 +#: ../../library/linecache.rst:29 msgid "path" msgstr "path(路徑)" diff --git a/library/locale.po b/library/locale.po index 80a48941b75..de44a117549 100644 --- a/library/locale.po +++ b/library/locale.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-12 00:46+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!locale` --- Internationalization services" msgstr ":mod:`!locale` --- 國際化服務" -#: ../../library/locale.rst:10 +#: ../../library/locale.rst:7 msgid "**Source code:** :source:`Lib/locale.py`" msgstr "**原始碼:**\\ :source:`Lib/locale.py`" -#: ../../library/locale.rst:14 +#: ../../library/locale.rst:11 msgid "" "The :mod:`!locale` module opens access to the POSIX locale database and " "functionality. The POSIX locale mechanism allows programmers to deal with " @@ -33,24 +33,24 @@ msgid "" "to know all the specifics of each country where the software is executed." msgstr "" -#: ../../library/locale.rst:21 +#: ../../library/locale.rst:18 msgid "" "The :mod:`!locale` module is implemented on top of the :mod:`!_locale` " "module, which in turn uses an ANSI C locale implementation if available." msgstr "" -#: ../../library/locale.rst:24 +#: ../../library/locale.rst:21 msgid "" "The :mod:`!locale` module defines the following exception and functions:" msgstr "" -#: ../../library/locale.rst:29 +#: ../../library/locale.rst:26 msgid "" "Exception raised when the locale passed to :func:`setlocale` is not " "recognized." msgstr "" -#: ../../library/locale.rst:35 +#: ../../library/locale.rst:32 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 " @@ -60,25 +60,25 @@ msgid "" "`Error` is raised. If successful, the new locale setting is returned." msgstr "" -#: ../../library/locale.rst:42 +#: ../../library/locale.rst:39 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``." +"name `, but without encoding. The language code and encoding " +"can be ``None``." msgstr "" -#: ../../library/locale.rst:48 +#: ../../library/locale.rst:45 msgid "" "If *locale* is omitted or ``None``, the current setting for *category* is " "returned." msgstr "" -#: ../../library/locale.rst:51 +#: ../../library/locale.rst:48 msgid "Example::" msgstr "範例: ::" -#: ../../library/locale.rst:53 +#: ../../library/locale.rst:50 msgid "" ">>> import locale\n" ">>> loc = locale.setlocale(locale.LC_ALL) # get current locale\n" @@ -91,13 +91,13 @@ msgid "" ">>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale" msgstr "" -#: ../../library/locale.rst:62 +#: ../../library/locale.rst:59 msgid "" ":func:`setlocale` is not thread-safe on most systems. Applications typically " "start with a call of::" msgstr "" -#: ../../library/locale.rst:65 +#: ../../library/locale.rst:62 msgid "" "import locale\n" "locale.setlocale(locale.LC_ALL, '')" @@ -105,7 +105,7 @@ msgstr "" "import locale\n" "locale.setlocale(locale.LC_ALL, '')" -#: ../../library/locale.rst:68 +#: ../../library/locale.rst:65 msgid "" "This sets the locale for all categories to the user's default setting " "(typically specified in the :envvar:`LANG` environment variable). If the " @@ -113,6 +113,10 @@ msgid "" "problems." msgstr "" +#: ../../library/locale.rst:69 +msgid "Support language codes with ``@``-modifiers." +msgstr "" + #: ../../library/locale.rst:75 msgid "" "Returns the database of the local conventions as a dictionary. This " @@ -540,7 +544,7 @@ msgid "" "``'LC_CTYPE'``, ``'LANG'`` and ``'LANGUAGE'``, in that order." msgstr "" -#: ../../library/locale.rst:364 ../../library/locale.rst:377 +#: ../../library/locale.rst:364 msgid "" "The language code has the same format as a :ref:`locale name `, " "but without encoding and ``@``-modifier. The language code and encoding may " @@ -556,7 +560,21 @@ msgid "" "`LC_CTYPE`." msgstr "" -#: ../../library/locale.rst:386 +#: ../../library/locale.rst:377 +msgid "" +"The language code has the same format as a :ref:`locale name `, " +"but without encoding. 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:383 +msgid "" +"``@``-modifier are no longer silently removed, but included in the language " +"code." +msgstr "" + +#: ../../library/locale.rst:390 msgid "" "Return the :term:`locale encoding` used for text data, according to user " "preferences. User preferences are expressed differently on different " @@ -564,72 +582,72 @@ msgid "" "this function only returns a guess." msgstr "" -#: ../../library/locale.rst:391 +#: ../../library/locale.rst:395 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:395 +#: ../../library/locale.rst:399 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:399 ../../library/locale.rst:417 +#: ../../library/locale.rst:403 ../../library/locale.rst:421 msgid "" "The :ref:`Python preinitialization ` configures the LC_CTYPE " "locale. See also the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../library/locale.rst:402 +#: ../../library/locale.rst:406 msgid "" "The function now always returns ``\"utf-8\"`` on Android or if the :ref:" "`Python UTF-8 Mode ` is enabled." msgstr "" -#: ../../library/locale.rst:409 +#: ../../library/locale.rst:413 msgid "Get the current :term:`locale encoding`:" msgstr "" -#: ../../library/locale.rst:411 +#: ../../library/locale.rst:415 msgid "On Android and VxWorks, return ``\"utf-8\"``." msgstr "" -#: ../../library/locale.rst:412 +#: ../../library/locale.rst:416 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:415 +#: ../../library/locale.rst:419 msgid "On Windows, return the ANSI code page." msgstr "" -#: ../../library/locale.rst:420 +#: ../../library/locale.rst:424 msgid "" "This function is similar to :func:`getpreferredencoding(False) " "` except this function ignores the :ref:`Python UTF-8 " "Mode `." msgstr "" -#: ../../library/locale.rst:429 +#: ../../library/locale.rst:433 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:433 +#: ../../library/locale.rst:437 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:439 +#: ../../library/locale.rst:443 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 " @@ -637,7 +655,7 @@ msgid "" "is equal to it." msgstr "" -#: ../../library/locale.rst:447 +#: ../../library/locale.rst:451 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, " @@ -645,7 +663,7 @@ msgid "" "repeatedly, e.g. when collating a sequence of strings." msgstr "" -#: ../../library/locale.rst:456 +#: ../../library/locale.rst:460 msgid "" "Formats a number *val* according to the current :const:`LC_NUMERIC` setting. " "The format follows the conventions of the ``%`` operator. For floating-" @@ -653,29 +671,29 @@ msgid "" "is ``True``, also takes the grouping into account." msgstr "" -#: ../../library/locale.rst:461 +#: ../../library/locale.rst:465 msgid "" "If *monetary* is true, the conversion uses monetary thousands separator and " "grouping strings." msgstr "" -#: ../../library/locale.rst:464 +#: ../../library/locale.rst:468 msgid "" "Processes formatting specifiers as in ``format % val``, but takes the " "current locale settings into account." msgstr "" -#: ../../library/locale.rst:467 +#: ../../library/locale.rst:471 msgid "The *monetary* keyword parameter was added." msgstr "新增了 *monetary* 關鍵字參數。" -#: ../../library/locale.rst:473 +#: ../../library/locale.rst:477 msgid "" "Formats a number *val* according to the current :const:`LC_MONETARY` " "settings." msgstr "" -#: ../../library/locale.rst:475 +#: ../../library/locale.rst:479 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), " @@ -683,43 +701,43 @@ msgid "" "not the default), the international currency symbol is used." msgstr "" -#: ../../library/locale.rst:482 +#: ../../library/locale.rst:486 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:488 +#: ../../library/locale.rst:492 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:494 +#: ../../library/locale.rst:498 msgid "" "Converts a string into a normalized number string, following the :const:" "`LC_NUMERIC` settings." msgstr "" -#: ../../library/locale.rst:502 +#: ../../library/locale.rst:506 msgid "" "Converts a normalized number string into a formatted string following the :" "const:`LC_NUMERIC` settings." msgstr "" -#: ../../library/locale.rst:510 +#: ../../library/locale.rst:514 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:516 +#: ../../library/locale.rst:520 msgid "" "Converts a string to an integer, following the :const:`LC_NUMERIC` " "conventions." msgstr "" -#: ../../library/locale.rst:521 +#: ../../library/locale.rst:525 msgid "" "Locale category for the character type functions. Most importantly, this " "category defines the text encoding, i.e. how bytes are interpreted as " @@ -729,32 +747,32 @@ msgid "" "SSH connections." msgstr "" -#: ../../library/locale.rst:528 +#: ../../library/locale.rst:532 msgid "" "Python doesn't internally use locale-dependent character transformation " "functions from ``ctype.h``. Instead, ``pyctype.h`` provides locale-" "independent equivalents like :c:macro:`Py_TOLOWER`." msgstr "" -#: ../../library/locale.rst:535 +#: ../../library/locale.rst:539 msgid "" "Locale category for sorting strings. The functions :func:`strcoll` and :" "func:`strxfrm` of the :mod:`!locale` module are affected." msgstr "" -#: ../../library/locale.rst:541 +#: ../../library/locale.rst:545 msgid "" "Locale category for the formatting of time. The function :func:`time." "strftime` follows these conventions." msgstr "" -#: ../../library/locale.rst:547 +#: ../../library/locale.rst:551 msgid "" "Locale category for formatting of monetary values. The available options " "are available from the :func:`localeconv` function." msgstr "" -#: ../../library/locale.rst:553 +#: ../../library/locale.rst:557 msgid "" "Locale category for message display. Python currently does not support " "application specific locale-aware messages. Messages displayed by the " @@ -762,13 +780,13 @@ msgid "" "affected by this category." msgstr "" -#: ../../library/locale.rst:558 +#: ../../library/locale.rst:562 msgid "" "This value may not be available on operating systems not conforming to the " "POSIX standard, most notably Windows." msgstr "" -#: ../../library/locale.rst:564 +#: ../../library/locale.rst:568 msgid "" "Locale category for formatting numbers. The functions :func:" "`format_string`, :func:`atoi`, :func:`atof` and :func:`.str` of the :mod:`!" @@ -776,7 +794,7 @@ msgid "" "operations are not affected." msgstr "" -#: ../../library/locale.rst:572 +#: ../../library/locale.rst:576 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 " @@ -786,17 +804,17 @@ msgid "" "settings." msgstr "" -#: ../../library/locale.rst:581 +#: ../../library/locale.rst:585 msgid "" "This is a symbolic constant used for different values returned by :func:" "`localeconv`." msgstr "" -#: ../../library/locale.rst:586 +#: ../../library/locale.rst:590 msgid "Background, details, hints, tips and caveats" msgstr "" -#: ../../library/locale.rst:588 +#: ../../library/locale.rst:592 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 " @@ -804,7 +822,7 @@ msgid "" "This makes the locale somewhat painful to use correctly." msgstr "" -#: ../../library/locale.rst:593 +#: ../../library/locale.rst:597 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 :" @@ -814,7 +832,7 @@ msgid "" "categories by calling ``setlocale(LC_ALL, '')``." msgstr "" -#: ../../library/locale.rst:600 +#: ../../library/locale.rst:604 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 " @@ -822,7 +840,7 @@ msgid "" "that happen to run before the settings have been restored." msgstr "" -#: ../../library/locale.rst:605 +#: ../../library/locale.rst:609 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 " @@ -833,14 +851,14 @@ msgid "" "settings." msgstr "" -#: ../../library/locale.rst:612 +#: ../../library/locale.rst:616 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:616 +#: ../../library/locale.rst:620 msgid "" "There is no way to perform case conversions and character classifications " "according to the locale. For (Unicode) text strings these are done " @@ -851,21 +869,21 @@ msgid "" "whitespace." msgstr "" -#: ../../library/locale.rst:627 +#: ../../library/locale.rst:631 msgid "Locale names" msgstr "" -#: ../../library/locale.rst:629 +#: ../../library/locale.rst:633 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:632 +#: ../../library/locale.rst:636 msgid "On Posix platforms, it usually has the format [1]_:" msgstr "" -#: ../../library/locale.rst:637 +#: ../../library/locale.rst:641 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`_, " @@ -874,13 +892,13 @@ msgid "" "\"latin\", \"valencia\", \"stroke\" and \"euro\")." msgstr "" -#: ../../library/locale.rst:643 +#: ../../library/locale.rst:647 msgid "" "On Windows, several formats are supported. [2]_ [3]_ A subset of `IETF BCP " "47`_ tags:" msgstr "" -#: ../../library/locale.rst:650 +#: ../../library/locale.rst:654 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 " @@ -890,11 +908,11 @@ msgid "" "allowed for BCP 47 tags." msgstr "" -#: ../../library/locale.rst:657 +#: ../../library/locale.rst:661 msgid "Windows also supports locale names in the format:" msgstr "" -#: ../../library/locale.rst:662 +#: ../../library/locale.rst:666 msgid "" "where *language* and *territory* are full names, such as \"English\" and " "\"United States\", and *charset* is either a code page number (for example, " @@ -902,34 +920,34 @@ msgid "" "format." msgstr "" -#: ../../library/locale.rst:667 +#: ../../library/locale.rst:671 msgid "The \"C\" locale is supported on all platforms." msgstr "" -#: ../../library/locale.rst:674 +#: ../../library/locale.rst:678 msgid "" "`IEEE Std 1003.1-2024; 8.2 Internationalization Variables `_" msgstr "" -#: ../../library/locale.rst:675 +#: ../../library/locale.rst:679 msgid "" "`UCRT Locale names, Languages, and Country/Region strings `_" msgstr "" -#: ../../library/locale.rst:676 +#: ../../library/locale.rst:680 msgid "" "`Locale Names `_" msgstr "" -#: ../../library/locale.rst:682 +#: ../../library/locale.rst:686 msgid "For extension writers and programs that embed Python" msgstr "" -#: ../../library/locale.rst:684 +#: ../../library/locale.rst:688 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 " @@ -937,7 +955,7 @@ msgid "" "whether or not the locale is ``C``)." msgstr "" -#: ../../library/locale.rst:689 +#: ../../library/locale.rst:693 msgid "" "When Python code uses the :mod:`!locale` module to change the locale, this " "also affects the embedding application. If the embedding application " @@ -947,11 +965,11 @@ msgid "" "accessible as a shared library." msgstr "" -#: ../../library/locale.rst:700 +#: ../../library/locale.rst:704 msgid "Access to message catalogs" msgstr "" -#: ../../library/locale.rst:709 +#: ../../library/locale.rst:713 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:" @@ -962,7 +980,7 @@ msgid "" "locating message catalogs." msgstr "" -#: ../../library/locale.rst:716 +#: ../../library/locale.rst:720 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 " @@ -972,11 +990,11 @@ msgid "" "their message catalogs." msgstr "" -#: ../../library/locale.rst:19 +#: ../../library/locale.rst:16 msgid "module" msgstr "module(模組)" -#: ../../library/locale.rst:19 +#: ../../library/locale.rst:16 msgid "_locale" msgstr "_locale" diff --git a/library/logging.config.po b/library/logging.config.po index 005cb11de42..547cf87f0f7 100644 --- a/library/logging.config.po +++ b/library/logging.config.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-10 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,36 +21,36 @@ msgstr "" msgid ":mod:`!logging.config` --- Logging configuration" msgstr ":mod:`!logging.config` --- 日誌記錄配置" -#: ../../library/logging.config.rst:10 +#: ../../library/logging.config.rst:7 msgid "**Source code:** :source:`Lib/logging/config.py`" msgstr "**原始碼:**\\ :source:`Lib/logging/config.py`" -#: ../../library/logging.config.rst:14 +#: ../../library/logging.config.rst:11 msgid "" "This page contains only reference information. For tutorials, please see" msgstr "" -#: ../../library/logging.config.rst:17 +#: ../../library/logging.config.rst:14 msgid ":ref:`Basic Tutorial `" msgstr ":ref:`基礎教學 `" -#: ../../library/logging.config.rst:18 +#: ../../library/logging.config.rst:15 msgid ":ref:`Advanced Tutorial `" msgstr ":ref:`進階教學 `" -#: ../../library/logging.config.rst:19 +#: ../../library/logging.config.rst:16 msgid ":ref:`Logging Cookbook `" msgstr "" -#: ../../library/logging.config.rst:23 +#: ../../library/logging.config.rst:20 msgid "This section describes the API for configuring the logging module." msgstr "" -#: ../../library/logging.config.rst:28 +#: ../../library/logging.config.rst:25 msgid "Configuration functions" msgstr "" -#: ../../library/logging.config.rst:30 +#: ../../library/logging.config.rst:27 msgid "" "The following functions configure the logging module. They are located in " "the :mod:`!logging.config` module. Their use is optional --- you can " @@ -59,13 +59,13 @@ msgid "" "declared either in :mod:`logging` or :mod:`logging.handlers`." msgstr "" -#: ../../library/logging.config.rst:38 +#: ../../library/logging.config.rst:35 msgid "" "Takes the logging configuration from a dictionary. The contents of this " "dictionary are described in :ref:`logging-config-dictschema` below." msgstr "" -#: ../../library/logging.config.rst:42 +#: ../../library/logging.config.rst:39 msgid "" "If an error is encountered during configuration, this function will raise a :" "exc:`ValueError`, :exc:`TypeError`, :exc:`AttributeError` or :exc:" @@ -73,33 +73,33 @@ msgid "" "(possibly incomplete) list of conditions which will raise an error:" msgstr "" -#: ../../library/logging.config.rst:48 +#: ../../library/logging.config.rst:45 msgid "" "A ``level`` which is not a string or which is a string not corresponding to " "an actual logging level." msgstr "" -#: ../../library/logging.config.rst:50 +#: ../../library/logging.config.rst:47 msgid "A ``propagate`` value which is not a boolean." msgstr "" -#: ../../library/logging.config.rst:51 +#: ../../library/logging.config.rst:48 msgid "An id which does not have a corresponding destination." msgstr "" -#: ../../library/logging.config.rst:52 +#: ../../library/logging.config.rst:49 msgid "A non-existent handler id found during an incremental call." msgstr "" -#: ../../library/logging.config.rst:53 +#: ../../library/logging.config.rst:50 msgid "An invalid logger name." msgstr "" -#: ../../library/logging.config.rst:54 +#: ../../library/logging.config.rst:51 msgid "Inability to resolve to an internal or external object." msgstr "" -#: ../../library/logging.config.rst:56 +#: ../../library/logging.config.rst:53 msgid "" "Parsing is performed by the :class:`DictConfigurator` class, whose " "constructor is passed the dictionary used for configuration, and has a :meth:" @@ -109,14 +109,14 @@ msgid "" "with a suitable implementation of your own." msgstr "" -#: ../../library/logging.config.rst:64 +#: ../../library/logging.config.rst:61 msgid "" ":func:`dictConfig` calls :attr:`dictConfigClass` passing the specified " "dictionary, and then calls the :meth:`configure` method on the returned " "object to put the configuration into effect::" msgstr "" -#: ../../library/logging.config.rst:68 +#: ../../library/logging.config.rst:65 msgid "" "def dictConfig(config):\n" " dictConfigClass(config).configure()" @@ -124,7 +124,7 @@ msgstr "" "def dictConfig(config):\n" " dictConfigClass(config).configure()" -#: ../../library/logging.config.rst:71 +#: ../../library/logging.config.rst:68 msgid "" "For example, a subclass of :class:`DictConfigurator` could call " "``DictConfigurator.__init__()`` in its own :meth:`__init__`, then set up " @@ -134,7 +134,7 @@ msgid "" "state." msgstr "" -#: ../../library/logging.config.rst:82 +#: ../../library/logging.config.rst:79 msgid "" "Reads the logging configuration from a :mod:`configparser`\\-format file. " "The format of the file should be as described in :ref:`logging-config-" @@ -144,7 +144,7 @@ msgid "" "chosen configuration)." msgstr "" -#: ../../library/logging.config.rst:90 +#: ../../library/logging.config.rst:87 msgid "" "It will raise :exc:`FileNotFoundError` if the file doesn't exist and :exc:" "`RuntimeError` if the file is invalid or empty." @@ -154,7 +154,7 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../library/logging.config.rst:94 +#: ../../library/logging.config.rst:91 msgid "" "A filename, or a file-like object, or an instance derived from :class:" "`~configparser.RawConfigParser`. If a :class:`!RawConfigParser`-derived " @@ -166,13 +166,13 @@ msgid "" "passed to :meth:`~configparser.ConfigParser.read`." msgstr "" -#: ../../library/logging.config.rst:106 +#: ../../library/logging.config.rst:103 msgid "" "Defaults to be passed to the :class:`!ConfigParser` can be specified in this " "argument." msgstr "" -#: ../../library/logging.config.rst:109 +#: ../../library/logging.config.rst:106 msgid "" "If specified as ``False``, loggers which exist when this call is made are " "left enabled. The default is ``True`` because this enables old behaviour in " @@ -181,40 +181,40 @@ msgid "" "logging configuration." msgstr "" -#: ../../library/logging.config.rst:118 +#: ../../library/logging.config.rst:115 msgid "The encoding used to open file when *fname* is filename." msgstr "" -#: ../../library/logging.config.rst:120 +#: ../../library/logging.config.rst:117 msgid "" "An instance of a subclass of :class:`~configparser.RawConfigParser` is now " "accepted as a value for ``fname``. This facilitates:" msgstr "" -#: ../../library/logging.config.rst:124 +#: ../../library/logging.config.rst:121 msgid "" "Use of a configuration file where logging configuration is just part of the " "overall application configuration." msgstr "" -#: ../../library/logging.config.rst:126 +#: ../../library/logging.config.rst:123 msgid "" "Use of a configuration read from a file, and then modified by the using " "application (e.g. based on command-line parameters or other aspects of the " "runtime environment) before being passed to ``fileConfig``." msgstr "" -#: ../../library/logging.config.rst:130 +#: ../../library/logging.config.rst:127 msgid "Added the *encoding* parameter." msgstr "新增了 *encoding* 參數。" -#: ../../library/logging.config.rst:133 +#: ../../library/logging.config.rst:130 msgid "" "An exception will be thrown if the provided file doesn't exist or is invalid " "or empty." msgstr "" -#: ../../library/logging.config.rst:139 +#: ../../library/logging.config.rst:136 msgid "" "Starts up a socket server on the specified port, and listens for new " "configurations. If no port is specified, the module's default :const:" @@ -226,7 +226,7 @@ msgid "" "func:`stopListening`." msgstr "" -#: ../../library/logging.config.rst:148 +#: ../../library/logging.config.rst:145 msgid "" "The ``verify`` argument, if specified, should be a callable which should " "verify whether bytes received across the socket are valid and should be " @@ -240,14 +240,14 @@ msgid "" "(perhaps if decryption were performed)." msgstr "" -#: ../../library/logging.config.rst:159 +#: ../../library/logging.config.rst:156 msgid "" "To send a configuration to the socket, read in the configuration file and " "send it to the socket as a sequence of bytes preceded by a four-byte length " "string packed in binary using ``struct.pack('>L', n)``." msgstr "" -#: ../../library/logging.config.rst:167 +#: ../../library/logging.config.rst:164 msgid "" "Because portions of the configuration are passed through :func:`eval`, use " "of this function may open its users to a security risk. While the function " @@ -265,11 +265,11 @@ msgid "" "from being applied." msgstr "" -#: ../../library/logging.config.rst:183 +#: ../../library/logging.config.rst:180 msgid "The ``verify`` argument was added." msgstr "新增 ``verify`` 引數。" -#: ../../library/logging.config.rst:188 +#: ../../library/logging.config.rst:185 msgid "" "If you want to send configurations to the listener which don't disable " "existing loggers, you will need to use a JSON format for the configuration, " @@ -278,18 +278,18 @@ msgid "" "you send." msgstr "" -#: ../../library/logging.config.rst:197 +#: ../../library/logging.config.rst:194 msgid "" "Stops the listening server which was created with a call to :func:`listen`. " "This is typically called before calling :meth:`join` on the return value " "from :func:`listen`." msgstr "" -#: ../../library/logging.config.rst:203 +#: ../../library/logging.config.rst:200 msgid "Security considerations" msgstr "" -#: ../../library/logging.config.rst:205 +#: ../../library/logging.config.rst:202 msgid "" "The logging configuration functionality tries to offer convenience, and in " "part this is done by offering the ability to convert text in configuration " @@ -302,11 +302,11 @@ msgid "" "bad can happen if you load them, before actually loading them." msgstr "" -#: ../../library/logging.config.rst:219 +#: ../../library/logging.config.rst:216 msgid "Configuration dictionary schema" msgstr "" -#: ../../library/logging.config.rst:221 +#: ../../library/logging.config.rst:218 msgid "" "Describing a logging configuration requires listing the various objects to " "create and the connections between them; for example, you may create a " @@ -319,23 +319,23 @@ msgid "" "connections` below." msgstr "" -#: ../../library/logging.config.rst:233 +#: ../../library/logging.config.rst:230 msgid "Dictionary Schema Details" msgstr "" -#: ../../library/logging.config.rst:235 +#: ../../library/logging.config.rst:232 msgid "" "The dictionary passed to :func:`dictConfig` must contain the following keys:" msgstr "" -#: ../../library/logging.config.rst:238 +#: ../../library/logging.config.rst:235 msgid "" "*version* - to be set to an integer value representing the schema version. " "The only valid value at present is 1, but having this key allows the schema " "to evolve while still preserving backwards compatibility." msgstr "" -#: ../../library/logging.config.rst:243 +#: ../../library/logging.config.rst:240 msgid "" "All other keys are optional, but if present they will be interpreted as " "described below. In all cases below where a 'configuring dict' is " @@ -345,41 +345,41 @@ msgid "" "otherwise, the context is used to determine what to instantiate." msgstr "" -#: ../../library/logging.config.rst:252 +#: ../../library/logging.config.rst:249 msgid "" "*formatters* - the corresponding value will be a dict in which each key is a " "formatter id and each value is a dict describing how to configure the " "corresponding :class:`~logging.Formatter` instance." msgstr "" -#: ../../library/logging.config.rst:256 +#: ../../library/logging.config.rst:253 msgid "" "The configuring dict is searched for the following optional keys which " "correspond to the arguments passed to create a :class:`~logging.Formatter` " "object:" msgstr "" -#: ../../library/logging.config.rst:260 +#: ../../library/logging.config.rst:257 msgid "``format``" msgstr "``format``" -#: ../../library/logging.config.rst:261 +#: ../../library/logging.config.rst:258 msgid "``datefmt``" msgstr "``datefmt``" -#: ../../library/logging.config.rst:262 +#: ../../library/logging.config.rst:259 msgid "``style``" msgstr "``style``" -#: ../../library/logging.config.rst:263 +#: ../../library/logging.config.rst:260 msgid "``validate`` (since version >=3.8)" msgstr "``validate`` (自 3.8 版起)" -#: ../../library/logging.config.rst:264 +#: ../../library/logging.config.rst:261 msgid "``defaults`` (since version >=3.12)" msgstr "``defaults`` (自 3.12 版起)" -#: ../../library/logging.config.rst:266 +#: ../../library/logging.config.rst:263 msgid "" "An optional ``class`` key indicates the name of the formatter's class (as a " "dotted module and class name). The instantiation arguments are as for :" @@ -390,60 +390,60 @@ msgid "" "configuration keys, you should use :ref:`logging-config-dict-userdef`." msgstr "" -#: ../../library/logging.config.rst:275 +#: ../../library/logging.config.rst:272 msgid "" "*filters* - the corresponding value will be a dict in which each key is a " "filter id and each value is a dict describing how to configure the " "corresponding Filter instance." msgstr "" -#: ../../library/logging.config.rst:279 +#: ../../library/logging.config.rst:276 msgid "" "The configuring dict is searched for the key ``name`` (defaulting to the " "empty string) and this is used to construct a :class:`logging.Filter` " "instance." msgstr "" -#: ../../library/logging.config.rst:283 +#: ../../library/logging.config.rst:280 msgid "" "*handlers* - the corresponding value will be a dict in which each key is a " "handler id and each value is a dict describing how to configure the " "corresponding Handler instance." msgstr "" -#: ../../library/logging.config.rst:287 ../../library/logging.config.rst:332 +#: ../../library/logging.config.rst:284 ../../library/logging.config.rst:329 msgid "The configuring dict is searched for the following keys:" msgstr "" -#: ../../library/logging.config.rst:289 +#: ../../library/logging.config.rst:286 msgid "" "``class`` (mandatory). This is the fully qualified name of the handler " "class." msgstr "" -#: ../../library/logging.config.rst:292 +#: ../../library/logging.config.rst:289 msgid "``level`` (optional). The level of the handler." msgstr "" -#: ../../library/logging.config.rst:294 +#: ../../library/logging.config.rst:291 msgid "``formatter`` (optional). The id of the formatter for this handler." msgstr "" -#: ../../library/logging.config.rst:297 +#: ../../library/logging.config.rst:294 msgid "``filters`` (optional). A list of ids of the filters for this handler." msgstr "" -#: ../../library/logging.config.rst:300 ../../library/logging.config.rst:341 +#: ../../library/logging.config.rst:297 ../../library/logging.config.rst:338 msgid "``filters`` can take filter instances in addition to ids." msgstr "" -#: ../../library/logging.config.rst:303 +#: ../../library/logging.config.rst:300 msgid "" "All *other* keys are passed through as keyword arguments to the handler's " "constructor. For example, given the snippet:" msgstr "" -#: ../../library/logging.config.rst:306 +#: ../../library/logging.config.rst:303 msgid "" "handlers:\n" " console:\n" @@ -473,7 +473,7 @@ msgstr "" " maxBytes: 1024\n" " backupCount: 3" -#: ../../library/logging.config.rst:322 +#: ../../library/logging.config.rst:319 msgid "" "the handler with id ``console`` is instantiated as a :class:`logging." "StreamHandler`, using ``sys.stdout`` as the underlying stream. The handler " @@ -482,44 +482,44 @@ msgid "" "maxBytes=1024, backupCount=3``." msgstr "" -#: ../../library/logging.config.rst:328 +#: ../../library/logging.config.rst:325 msgid "" "*loggers* - the corresponding value will be a dict in which each key is a " "logger name and each value is a dict describing how to configure the " "corresponding Logger instance." msgstr "" -#: ../../library/logging.config.rst:334 +#: ../../library/logging.config.rst:331 msgid "``level`` (optional). The level of the logger." msgstr "" -#: ../../library/logging.config.rst:336 +#: ../../library/logging.config.rst:333 msgid "``propagate`` (optional). The propagation setting of the logger." msgstr "" -#: ../../library/logging.config.rst:338 +#: ../../library/logging.config.rst:335 msgid "``filters`` (optional). A list of ids of the filters for this logger." msgstr "" -#: ../../library/logging.config.rst:344 +#: ../../library/logging.config.rst:341 msgid "" "``handlers`` (optional). A list of ids of the handlers for this logger." msgstr "" -#: ../../library/logging.config.rst:347 +#: ../../library/logging.config.rst:344 msgid "" "The specified loggers will be configured according to the level, " "propagation, filters and handlers specified." msgstr "" -#: ../../library/logging.config.rst:350 +#: ../../library/logging.config.rst:347 msgid "" "*root* - this will be the configuration for the root logger. Processing of " "the configuration will be as for any logger, except that the ``propagate`` " "setting will not be applicable." msgstr "" -#: ../../library/logging.config.rst:354 +#: ../../library/logging.config.rst:351 msgid "" "*incremental* - whether the configuration is to be interpreted as " "incremental to the existing configuration. This value defaults to " @@ -528,13 +528,13 @@ msgid "" "`fileConfig` API." msgstr "" -#: ../../library/logging.config.rst:360 +#: ../../library/logging.config.rst:357 msgid "" "If the specified value is ``True``, the configuration is processed as " "described in the section on :ref:`logging-config-dict-incremental`." msgstr "" -#: ../../library/logging.config.rst:363 +#: ../../library/logging.config.rst:360 msgid "" "*disable_existing_loggers* - whether any existing non-root loggers are to be " "disabled. This setting mirrors the parameter of the same name in :func:" @@ -542,11 +542,11 @@ msgid "" "ignored if *incremental* is ``True``." msgstr "" -#: ../../library/logging.config.rst:371 +#: ../../library/logging.config.rst:368 msgid "Incremental Configuration" msgstr "" -#: ../../library/logging.config.rst:373 +#: ../../library/logging.config.rst:370 msgid "" "It is difficult to provide complete flexibility for incremental " "configuration. For example, because objects such as filters and formatters " @@ -554,7 +554,7 @@ msgid "" "to such anonymous objects when augmenting a configuration." msgstr "" -#: ../../library/logging.config.rst:379 +#: ../../library/logging.config.rst:376 msgid "" "Furthermore, there is not a compelling case for arbitrarily altering the " "object graph of loggers, handlers, filters, formatters at run-time, once a " @@ -565,7 +565,7 @@ msgid "" "worth the complexity it adds to the implementation." msgstr "" -#: ../../library/logging.config.rst:388 +#: ../../library/logging.config.rst:385 msgid "" "Thus, when the ``incremental`` key of a configuration dict is present and is " "``True``, the system will completely ignore any ``formatters`` and " @@ -574,7 +574,7 @@ msgid "" "``loggers`` and ``root`` entries." msgstr "" -#: ../../library/logging.config.rst:394 +#: ../../library/logging.config.rst:391 msgid "" "Using a value in the configuration dict lets configurations to be sent over " "the wire as pickled dicts to a socket listener. Thus, the logging verbosity " @@ -582,11 +582,11 @@ msgid "" "and restart the application." msgstr "" -#: ../../library/logging.config.rst:402 +#: ../../library/logging.config.rst:399 msgid "Object connections" msgstr "" -#: ../../library/logging.config.rst:404 +#: ../../library/logging.config.rst:401 msgid "" "The schema describes a set of logging objects - loggers, handlers, " "formatters, filters - which are connected to each other in an object graph. " @@ -602,11 +602,11 @@ msgid "" "source and the destination object with that id." msgstr "" -#: ../../library/logging.config.rst:418 +#: ../../library/logging.config.rst:415 msgid "So, for example, consider the following YAML snippet:" msgstr "" -#: ../../library/logging.config.rst:420 +#: ../../library/logging.config.rst:417 msgid "" "formatters:\n" " brief:\n" @@ -626,13 +626,13 @@ msgid "" " handlers: [h1, h2]" msgstr "" -#: ../../library/logging.config.rst:439 +#: ../../library/logging.config.rst:436 msgid "" "(Note: YAML used here because it's a little more readable than the " "equivalent Python source form for the dictionary.)" msgstr "" -#: ../../library/logging.config.rst:442 +#: ../../library/logging.config.rst:439 msgid "" "The ids for loggers are the logger names which would be used " "programmatically to obtain a reference to those loggers, e.g. ``foo.bar." @@ -643,7 +643,7 @@ msgid "" "configuration call is complete." msgstr "" -#: ../../library/logging.config.rst:450 +#: ../../library/logging.config.rst:447 msgid "" "The above snippet indicates that logger named ``foo.bar.baz`` should have " "two handlers attached to it, which are described by the handler ids ``h1`` " @@ -651,11 +651,11 @@ msgid "" "the formatter for ``h2`` is that described by id ``precise``." msgstr "" -#: ../../library/logging.config.rst:460 +#: ../../library/logging.config.rst:457 msgid "User-defined objects" msgstr "" -#: ../../library/logging.config.rst:462 +#: ../../library/logging.config.rst:459 msgid "" "The schema supports user-defined objects for handlers, filters and " "formatters. (Loggers do not need to have different types for different " @@ -663,7 +663,7 @@ msgid "" "defined logger classes.)" msgstr "" -#: ../../library/logging.config.rst:467 +#: ../../library/logging.config.rst:464 msgid "" "Objects to be configured are described by dictionaries which detail their " "configuration. In some places, the logging system will be able to infer " @@ -676,7 +676,7 @@ msgid "" "made available under the special key ``'()'``. Here's a concrete example:" msgstr "" -#: ../../library/logging.config.rst:479 +#: ../../library/logging.config.rst:476 msgid "" "formatters:\n" " brief:\n" @@ -702,7 +702,7 @@ msgstr "" " spam: 99.9\n" " answer: 42" -#: ../../library/logging.config.rst:493 +#: ../../library/logging.config.rst:490 msgid "" "The above YAML snippet defines three formatters. The first, with id " "``brief``, is a standard :class:`logging.Formatter` instance with the " @@ -713,7 +713,7 @@ msgid "" "configuration sub-dictionaries::" msgstr "" -#: ../../library/logging.config.rst:501 +#: ../../library/logging.config.rst:498 msgid "" "{\n" " 'format' : '%(message)s'\n" @@ -723,11 +723,11 @@ msgstr "" " 'format' : '%(message)s'\n" "}" -#: ../../library/logging.config.rst:505 +#: ../../library/logging.config.rst:502 msgid "and::" msgstr "和: ::" -#: ../../library/logging.config.rst:507 +#: ../../library/logging.config.rst:504 msgid "" "{\n" " 'format' : '%(asctime)s %(levelname)-8s %(name)-15s %(message)s',\n" @@ -739,7 +739,7 @@ msgstr "" " 'datefmt' : '%Y-%m-%d %H:%M:%S'\n" "}" -#: ../../library/logging.config.rst:512 +#: ../../library/logging.config.rst:509 msgid "" "respectively, and as these dictionaries do not contain the special key " "``'()'``, the instantiation is inferred from the context: as a result, " @@ -748,7 +748,7 @@ msgid "" "is::" msgstr "" -#: ../../library/logging.config.rst:518 +#: ../../library/logging.config.rst:515 msgid "" "{\n" " '()' : 'my.package.customFormatterFactory',\n" @@ -764,7 +764,7 @@ msgstr "" " 'answer' : 42\n" "}" -#: ../../library/logging.config.rst:525 +#: ../../library/logging.config.rst:522 msgid "" "and this contains the special key ``'()'``, which means that user-defined " "instantiation is wanted. In this case, the specified factory callable will " @@ -776,11 +776,11 @@ msgid "" "assumed to be returned by the call::" msgstr "" -#: ../../library/logging.config.rst:535 +#: ../../library/logging.config.rst:532 msgid "my.package.customFormatterFactory(bar='baz', spam=99.9, answer=42)" msgstr "my.package.customFormatterFactory(bar='baz', spam=99.9, answer=42)" -#: ../../library/logging.config.rst:537 +#: ../../library/logging.config.rst:534 msgid "" "The values for keys such as ``bar``, ``spam`` and ``answer`` in the above " "example should not be configuration dictionaries or references such as " @@ -788,7 +788,7 @@ msgid "" "configuration machinery, but passed to the callable as-is." msgstr "" -#: ../../library/logging.config.rst:542 +#: ../../library/logging.config.rst:539 msgid "" "The key ``'()'`` has been used as the special key because it is not a valid " "keyword parameter name, and so will not clash with the names of the keyword " @@ -796,13 +796,13 @@ msgid "" "corresponding value is a callable." msgstr "" -#: ../../library/logging.config.rst:547 +#: ../../library/logging.config.rst:544 msgid "" "The ``filters`` member of ``handlers`` and ``loggers`` can take filter " "instances in addition to ids." msgstr "" -#: ../../library/logging.config.rst:551 +#: ../../library/logging.config.rst:548 msgid "" "You can also specify a special key ``'.'`` whose value is a mapping of " "attribute names to values. If found, the specified attributes will be set on " @@ -810,7 +810,7 @@ msgid "" "configuration::" msgstr "" -#: ../../library/logging.config.rst:556 +#: ../../library/logging.config.rst:553 msgid "" "{\n" " '()' : 'my.package.customFormatterFactory',\n" @@ -834,13 +834,13 @@ msgstr "" " }\n" "}" -#: ../../library/logging.config.rst:567 +#: ../../library/logging.config.rst:564 msgid "" "the returned formatter will have attribute ``foo`` set to ``'bar'`` and " "attribute ``baz`` set to ``'bozz'``." msgstr "" -#: ../../library/logging.config.rst:570 +#: ../../library/logging.config.rst:567 msgid "" "The values for attributes such as ``foo`` and ``baz`` in the above example " "should not be configuration dictionaries or references such as ``cfg://foo`` " @@ -848,11 +848,11 @@ msgid "" "machinery, but set as attribute values as-is." msgstr "" -#: ../../library/logging.config.rst:579 +#: ../../library/logging.config.rst:576 msgid "Handler configuration order" msgstr "" -#: ../../library/logging.config.rst:581 +#: ../../library/logging.config.rst:578 msgid "" "Handlers are configured in alphabetical order of their keys, and a " "configured handler replaces the configuration dictionary in (a working copy " @@ -873,11 +873,11 @@ msgid "" "dictionary." msgstr "" -#: ../../library/logging.config.rst:602 +#: ../../library/logging.config.rst:599 msgid "Access to external objects" msgstr "" -#: ../../library/logging.config.rst:604 +#: ../../library/logging.config.rst:601 msgid "" "There are times where a configuration needs to refer to objects external to " "the configuration, for example ``sys.stderr``. If the configuration dict is " @@ -892,7 +892,7 @@ msgid "" "import mechanisms." msgstr "" -#: ../../library/logging.config.rst:617 +#: ../../library/logging.config.rst:614 msgid "" "The handling of such prefixes is done in a way analogous to protocol " "handling: there is a generic mechanism to look for prefixes which match the " @@ -902,11 +902,11 @@ msgid "" "prefix is not recognised, then the string value will be left as-is." msgstr "" -#: ../../library/logging.config.rst:629 +#: ../../library/logging.config.rst:626 msgid "Access to internal objects" msgstr "" -#: ../../library/logging.config.rst:631 +#: ../../library/logging.config.rst:628 msgid "" "As well as external objects, there is sometimes also a need to refer to " "objects in the configuration. This will be done implicitly by the " @@ -917,7 +917,7 @@ msgid "" "and resolve to the appropriate destination object." msgstr "" -#: ../../library/logging.config.rst:639 +#: ../../library/logging.config.rst:636 msgid "" "However, a more generic mechanism is needed for user-defined objects which " "are not known to the :mod:`logging` module. For example, consider :class:" @@ -931,7 +931,7 @@ msgid "" "resolution system allows the user to specify:" msgstr "" -#: ../../library/logging.config.rst:651 +#: ../../library/logging.config.rst:648 msgid "" "handlers:\n" " file:\n" @@ -942,7 +942,7 @@ msgid "" " alternate: cfg://handlers.file" msgstr "" -#: ../../library/logging.config.rst:661 +#: ../../library/logging.config.rst:658 msgid "" "The literal string ``'cfg://handlers.file'`` will be resolved in an " "analogous way to strings with the ``ext://`` prefix, but looking in the " @@ -951,7 +951,7 @@ msgid "" "format``. Thus, given the following snippet:" msgstr "" -#: ../../library/logging.config.rst:667 +#: ../../library/logging.config.rst:664 msgid "" "handlers:\n" " email:\n" @@ -973,7 +973,7 @@ msgstr "" " - dev_team@domain.tld\n" " subject: Houston, we have a problem." -#: ../../library/logging.config.rst:679 +#: ../../library/logging.config.rst:676 msgid "" "in the configuration, the string ``'cfg://handlers'`` would resolve to the " "dict with key ``handlers``, the string ``'cfg://handlers.email`` would " @@ -990,7 +990,7 @@ msgid "" "to the string value if needed." msgstr "" -#: ../../library/logging.config.rst:694 +#: ../../library/logging.config.rst:691 msgid "" "Given a string ``cfg://handlers.myhandler.mykey.123``, this will resolve to " "``config_dict['handlers']['myhandler']['mykey']['123']``. If the string is " @@ -1000,11 +1000,11 @@ msgid "" "['mykey']['123']`` if that fails." msgstr "" -#: ../../library/logging.config.rst:706 +#: ../../library/logging.config.rst:703 msgid "Import resolution and custom importers" msgstr "" -#: ../../library/logging.config.rst:708 +#: ../../library/logging.config.rst:705 msgid "" "Import resolution, by default, uses the builtin :func:`__import__` function " "to do its importing. You may want to replace this with your own importing " @@ -1016,7 +1016,7 @@ msgid "" "instance level, you need to wrap it with :func:`staticmethod`. For example::" msgstr "" -#: ../../library/logging.config.rst:718 +#: ../../library/logging.config.rst:715 msgid "" "from importlib import import_module\n" "from logging.config import BaseConfigurator\n" @@ -1028,17 +1028,17 @@ msgstr "" "\n" "BaseConfigurator.importer = staticmethod(import_module)" -#: ../../library/logging.config.rst:723 +#: ../../library/logging.config.rst:720 msgid "" "You don't need to wrap with :func:`staticmethod` if you're setting the " "import callable on a configurator *instance*." msgstr "" -#: ../../library/logging.config.rst:729 +#: ../../library/logging.config.rst:726 msgid "Configuring QueueHandler and QueueListener" msgstr "" -#: ../../library/logging.config.rst:731 +#: ../../library/logging.config.rst:728 msgid "" "If you want to configure a :class:`~logging.handlers.QueueHandler`, noting " "that this is normally used in conjunction with a :class:`~logging.handlers." @@ -1051,7 +1051,7 @@ msgid "" "the example YAML snippet below." msgstr "" -#: ../../library/logging.config.rst:740 +#: ../../library/logging.config.rst:737 msgid "" "handlers:\n" " qhand:\n" @@ -1073,17 +1073,17 @@ msgstr "" " - hand_name_2\n" " ..." -#: ../../library/logging.config.rst:752 +#: ../../library/logging.config.rst:749 msgid "The ``queue`` and ``listener`` keys are optional." msgstr "" -#: ../../library/logging.config.rst:754 +#: ../../library/logging.config.rst:751 msgid "" "If the ``queue`` key is present, the corresponding value can be one of the " "following:" msgstr "" -#: ../../library/logging.config.rst:756 +#: ../../library/logging.config.rst:753 msgid "" "An object implementing the :meth:`Queue.put_nowait ` " "and :meth:`Queue.get ` public API. For instance, this may " @@ -1091,13 +1091,13 @@ msgid "" "proxy obtained by :meth:`multiprocessing.managers.SyncManager.Queue`." msgstr "" -#: ../../library/logging.config.rst:761 +#: ../../library/logging.config.rst:758 msgid "" "This is of course only possible if you are constructing or modifying the " "configuration dictionary in code." msgstr "" -#: ../../library/logging.config.rst:764 +#: ../../library/logging.config.rst:761 msgid "" "A string that resolves to a callable which, when called with no arguments, " "returns the queue instance to use. That callable could be a :class:`queue." @@ -1105,39 +1105,39 @@ msgid "" "as ``my.module.queue_factory()``." msgstr "" -#: ../../library/logging.config.rst:769 +#: ../../library/logging.config.rst:766 msgid "" "A dict with a ``'()'`` key which is constructed in the usual way as " "discussed in :ref:`logging-config-dict-userdef`. The result of this " "construction should be a :class:`queue.Queue` instance." msgstr "" -#: ../../library/logging.config.rst:773 +#: ../../library/logging.config.rst:770 msgid "" "If the ``queue`` key is absent, a standard unbounded :class:`queue.Queue` " "instance is created and used." msgstr "" -#: ../../library/logging.config.rst:776 +#: ../../library/logging.config.rst:773 msgid "" "If the ``listener`` key is present, the corresponding value can be one of " "the following:" msgstr "" -#: ../../library/logging.config.rst:778 +#: ../../library/logging.config.rst:775 msgid "" "A subclass of :class:`logging.handlers.QueueListener`. This is of course " "only possible if you are constructing or modifying the configuration " "dictionary in code." msgstr "" -#: ../../library/logging.config.rst:782 +#: ../../library/logging.config.rst:779 msgid "" "A string which resolves to a class which is a subclass of ``QueueListener``, " "such as ``'my.package.CustomListener'``." msgstr "" -#: ../../library/logging.config.rst:785 +#: ../../library/logging.config.rst:782 msgid "" "A dict with a ``'()'`` key which is constructed in the usual way as " "discussed in :ref:`logging-config-dict-userdef`. The result of this " @@ -1145,31 +1145,31 @@ msgid "" "``QueueListener`` initializer." msgstr "" -#: ../../library/logging.config.rst:789 +#: ../../library/logging.config.rst:786 msgid "" "If the ``listener`` key is absent, :class:`logging.handlers.QueueListener` " "is used." msgstr "" -#: ../../library/logging.config.rst:791 +#: ../../library/logging.config.rst:788 msgid "" "The values under the ``handlers`` key are the names of other handlers in the " "configuration (not shown in the above snippet) which will be passed to the " "queue listener." msgstr "" -#: ../../library/logging.config.rst:795 +#: ../../library/logging.config.rst:792 msgid "" "Any custom queue handler and listener classes will need to be defined with " "the same initialization signatures as :class:`~logging.handlers." "QueueHandler` and :class:`~logging.handlers.QueueListener`." msgstr "" -#: ../../library/logging.config.rst:804 +#: ../../library/logging.config.rst:801 msgid "Configuration file format" msgstr "" -#: ../../library/logging.config.rst:806 +#: ../../library/logging.config.rst:803 msgid "" "The configuration file format understood by :func:`fileConfig` is based on :" "mod:`configparser` functionality. The file must contain sections called " @@ -1186,7 +1186,7 @@ msgid "" "specified in a section called ``[logger_root]``." msgstr "" -#: ../../library/logging.config.rst:821 +#: ../../library/logging.config.rst:818 msgid "" "The :func:`fileConfig` API is older than the :func:`dictConfig` API and does " "not provide functionality to cover certain aspects of logging. For example, " @@ -1199,11 +1199,11 @@ msgid "" "when it's convenient to do so." msgstr "" -#: ../../library/logging.config.rst:831 +#: ../../library/logging.config.rst:828 msgid "Examples of these sections in the file are given below." msgstr "" -#: ../../library/logging.config.rst:833 +#: ../../library/logging.config.rst:830 msgid "" "[loggers]\n" "keys=root,log02,log03,log04,log05,log06,log07\n" @@ -1223,13 +1223,13 @@ msgstr "" "[formatters]\n" "keys=form01,form02,form03,form04,form05,form06,form07,form08,form09" -#: ../../library/logging.config.rst:844 +#: ../../library/logging.config.rst:841 msgid "" "The root logger must specify a level and a list of handlers. An example of a " "root logger section is given below." msgstr "" -#: ../../library/logging.config.rst:847 +#: ../../library/logging.config.rst:844 msgid "" "[logger_root]\n" "level=NOTSET\n" @@ -1239,7 +1239,7 @@ msgstr "" "level=NOTSET\n" "handlers=hand01" -#: ../../library/logging.config.rst:853 +#: ../../library/logging.config.rst:850 msgid "" "The ``level`` entry can be one of ``DEBUG, INFO, WARNING, ERROR, CRITICAL`` " "or ``NOTSET``. For the root logger only, ``NOTSET`` means that all messages " @@ -1247,7 +1247,7 @@ msgid "" "of the ``logging`` package's namespace." msgstr "" -#: ../../library/logging.config.rst:858 +#: ../../library/logging.config.rst:855 msgid "" "The ``handlers`` entry is a comma-separated list of handler names, which " "must appear in the ``[handlers]`` section. These names must appear in the " @@ -1255,13 +1255,13 @@ msgid "" "file." msgstr "" -#: ../../library/logging.config.rst:863 +#: ../../library/logging.config.rst:860 msgid "" "For loggers other than the root logger, some additional information is " "required. This is illustrated by the following example." msgstr "" -#: ../../library/logging.config.rst:866 +#: ../../library/logging.config.rst:863 msgid "" "[logger_parser]\n" "level=DEBUG\n" @@ -1275,7 +1275,7 @@ msgstr "" "propagate=1\n" "qualname=compiler.parser" -#: ../../library/logging.config.rst:874 +#: ../../library/logging.config.rst:871 msgid "" "The ``level`` and ``handlers`` entries are interpreted as for the root " "logger, except that if a non-root logger's level is specified as ``NOTSET``, " @@ -1288,13 +1288,13 @@ msgid "" "application to get the logger." msgstr "" -#: ../../library/logging.config.rst:883 +#: ../../library/logging.config.rst:880 msgid "" "Sections which specify handler configuration are exemplified by the " "following." msgstr "" -#: ../../library/logging.config.rst:885 +#: ../../library/logging.config.rst:882 msgid "" "[handler_hand01]\n" "class=StreamHandler\n" @@ -1308,14 +1308,14 @@ msgstr "" "formatter=form01\n" "args=(sys.stdout,)" -#: ../../library/logging.config.rst:893 +#: ../../library/logging.config.rst:890 msgid "" "The ``class`` entry indicates the handler's class (as determined by :func:" "`eval` in the ``logging`` package's namespace). The ``level`` is interpreted " "as for loggers, and ``NOTSET`` is taken to mean 'log everything'." msgstr "" -#: ../../library/logging.config.rst:897 +#: ../../library/logging.config.rst:894 msgid "" "The ``formatter`` entry indicates the key name of the formatter for this " "handler. If blank, a default formatter (``logging._defaultFormatter``) is " @@ -1323,7 +1323,7 @@ msgid "" "and have a corresponding section in the configuration file." msgstr "" -#: ../../library/logging.config.rst:902 +#: ../../library/logging.config.rst:899 msgid "" "The ``args`` entry, when :ref:`evaluated ` in the context of the " "``logging`` package's namespace, is the list of arguments to the constructor " @@ -1332,7 +1332,7 @@ msgid "" "provided, it defaults to ``()``." msgstr "" -#: ../../library/logging.config.rst:908 +#: ../../library/logging.config.rst:905 msgid "" "The optional ``kwargs`` entry, when :ref:`evaluated ` in the " "context of the ``logging`` package's namespace, is the keyword argument dict " @@ -1340,7 +1340,7 @@ msgid "" "``{}``." msgstr "" -#: ../../library/logging.config.rst:912 +#: ../../library/logging.config.rst:909 msgid "" "[handler_hand02]\n" "class=FileHandler\n" @@ -1448,12 +1448,12 @@ msgstr "" "args=('localhost:9022', '/log', 'GET')\n" "kwargs={'secure': True}" -#: ../../library/logging.config.rst:965 +#: ../../library/logging.config.rst:962 msgid "" "Sections which specify formatter configuration are typified by the following." msgstr "" -#: ../../library/logging.config.rst:967 +#: ../../library/logging.config.rst:964 msgid "" "[formatter_form01]\n" "format=F1 %(asctime)s %(levelname)s %(message)s %(customfield)s\n" @@ -1471,21 +1471,21 @@ msgstr "" "defaults={'customfield': 'defaultvalue'}\n" "class=logging.Formatter" -#: ../../library/logging.config.rst:977 +#: ../../library/logging.config.rst:974 msgid "" "The arguments for the formatter configuration are the same as the keys in " "the dictionary schema :ref:`formatters section `." msgstr "" -#: ../../library/logging.config.rst:981 +#: ../../library/logging.config.rst:978 msgid "" "The ``defaults`` entry, when :ref:`evaluated ` in the context of " "the ``logging`` package's namespace, is a dictionary of default values for " "custom formatting fields. If not provided, it defaults to ``None``." msgstr "" -#: ../../library/logging.config.rst:988 +#: ../../library/logging.config.rst:985 msgid "" "Due to the use of :func:`eval` as described above, there are potential " "security risks which result from using the :func:`listen` to send and " @@ -1494,19 +1494,19 @@ msgid "" "`listen` documentation for more information." msgstr "" -#: ../../library/logging.config.rst:996 +#: ../../library/logging.config.rst:993 msgid "Module :mod:`logging`" msgstr ":mod:`logging` 模組" -#: ../../library/logging.config.rst:997 +#: ../../library/logging.config.rst:994 msgid "API reference for the logging module." msgstr "" -#: ../../library/logging.config.rst:999 +#: ../../library/logging.config.rst:996 msgid "Module :mod:`logging.handlers`" msgstr ":mod:`logging.handlers` 模組" -#: ../../library/logging.config.rst:1000 +#: ../../library/logging.config.rst:997 msgid "Useful handlers included with the logging module." msgstr "" diff --git a/library/logging.handlers.po b/library/logging.handlers.po index f6eae728ae6..cde08fc7893 100644 --- a/library/logging.handlers.po +++ b/library/logging.handlers.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,28 +21,28 @@ msgstr "" msgid ":mod:`!logging.handlers` --- Logging handlers" msgstr ":mod:`!logging.handlers` --- 日誌紀錄處理器" -#: ../../library/logging.handlers.rst:10 +#: ../../library/logging.handlers.rst:7 msgid "**Source code:** :source:`Lib/logging/handlers.py`" msgstr "**原始碼:**\\ :source:`Lib/logging/handlers.py`" -#: ../../library/logging.handlers.rst:14 +#: ../../library/logging.handlers.rst:11 msgid "" "This page contains only reference information. For tutorials, please see" msgstr "" -#: ../../library/logging.handlers.rst:17 +#: ../../library/logging.handlers.rst:14 msgid ":ref:`Basic Tutorial `" msgstr ":ref:`基礎教學 `" -#: ../../library/logging.handlers.rst:18 +#: ../../library/logging.handlers.rst:15 msgid ":ref:`Advanced Tutorial `" msgstr ":ref:`進階教學 `" -#: ../../library/logging.handlers.rst:19 +#: ../../library/logging.handlers.rst:16 msgid ":ref:`Logging Cookbook `" msgstr "" -#: ../../library/logging.handlers.rst:25 +#: ../../library/logging.handlers.rst:22 msgid "" "The following useful handlers are provided in the package. Note that three " "of the handlers (:class:`StreamHandler`, :class:`FileHandler` and :class:" @@ -50,11 +50,11 @@ msgid "" "have been documented here along with the other handlers." msgstr "" -#: ../../library/logging.handlers.rst:33 +#: ../../library/logging.handlers.rst:30 msgid "StreamHandler" msgstr "StreamHandler" -#: ../../library/logging.handlers.rst:35 +#: ../../library/logging.handlers.rst:32 msgid "" "The :class:`StreamHandler` class, located in the core :mod:`logging` " "package, sends logging output to streams such as *sys.stdout*, *sys.stderr* " @@ -62,14 +62,14 @@ msgid "" "`write` and :meth:`flush` methods)." msgstr "" -#: ../../library/logging.handlers.rst:43 +#: ../../library/logging.handlers.rst:40 msgid "" "Returns a new instance of the :class:`StreamHandler` class. If *stream* is " "specified, the instance will use it for logging output; otherwise, *sys." "stderr* will be used." msgstr "" -#: ../../library/logging.handlers.rst:50 +#: ../../library/logging.handlers.rst:47 msgid "" "If a formatter is specified, it is used to format the record. The record is " "then written to the stream followed by :attr:`terminator`. If exception " @@ -77,14 +77,14 @@ msgid "" "print_exception` and appended to the stream." msgstr "" -#: ../../library/logging.handlers.rst:58 +#: ../../library/logging.handlers.rst:55 msgid "" "Flushes the stream by calling its :meth:`flush` method. Note that the :meth:" "`close` method is inherited from :class:`~logging.Handler` and so does no " "output, so an explicit :meth:`flush` call may be needed at times." msgstr "" -#: ../../library/logging.handlers.rst:64 +#: ../../library/logging.handlers.rst:61 msgid "" "Sets the instance's stream to the specified value, if it is different. The " "old stream is flushed before the new stream is set." @@ -94,7 +94,7 @@ msgstr "" msgid "Parameters" msgstr "" -#: ../../library/logging.handlers.rst:67 +#: ../../library/logging.handlers.rst:64 msgid "The stream that the handler should use." msgstr "" @@ -102,38 +102,38 @@ msgstr "" msgid "Returns" msgstr "" -#: ../../library/logging.handlers.rst:69 +#: ../../library/logging.handlers.rst:66 msgid "the old stream, if the stream was changed, or ``None`` if it wasn't." msgstr "" -#: ../../library/logging.handlers.rst:75 +#: ../../library/logging.handlers.rst:72 msgid "" "String used as the terminator when writing a formatted record to a stream. " "Default value is ``'\\n'``." msgstr "" -#: ../../library/logging.handlers.rst:78 +#: ../../library/logging.handlers.rst:75 msgid "" "If you don't want a newline termination, you can set the handler instance's " "``terminator`` attribute to the empty string." msgstr "" -#: ../../library/logging.handlers.rst:81 +#: ../../library/logging.handlers.rst:78 msgid "In earlier versions, the terminator was hardcoded as ``'\\n'``." msgstr "" -#: ../../library/logging.handlers.rst:89 +#: ../../library/logging.handlers.rst:86 msgid "FileHandler" msgstr "FileHandler" -#: ../../library/logging.handlers.rst:91 +#: ../../library/logging.handlers.rst:88 msgid "" "The :class:`FileHandler` class, located in the core :mod:`logging` package, " "sends logging output to a disk file. It inherits the output functionality " "from :class:`StreamHandler`." msgstr "" -#: ../../library/logging.handlers.rst:98 +#: ../../library/logging.handlers.rst:95 msgid "" "Returns a new instance of the :class:`FileHandler` class. The specified file " "is opened and used as the stream for logging. If *mode* is not specified, " @@ -144,73 +144,73 @@ msgid "" "handled." msgstr "" -#: ../../library/logging.handlers.rst:105 -#: ../../library/logging.handlers.rst:190 -#: ../../library/logging.handlers.rst:338 -#: ../../library/logging.handlers.rst:448 +#: ../../library/logging.handlers.rst:102 +#: ../../library/logging.handlers.rst:187 +#: ../../library/logging.handlers.rst:335 +#: ../../library/logging.handlers.rst:445 msgid "" "As well as string values, :class:`~pathlib.Path` objects are also accepted " "for the *filename* argument." msgstr "" -#: ../../library/logging.handlers.rst:109 -#: ../../library/logging.handlers.rst:194 -#: ../../library/logging.handlers.rst:342 -#: ../../library/logging.handlers.rst:452 +#: ../../library/logging.handlers.rst:106 +#: ../../library/logging.handlers.rst:191 +#: ../../library/logging.handlers.rst:339 +#: ../../library/logging.handlers.rst:449 msgid "The *errors* parameter was added." msgstr "新增 *errors* 參數。" -#: ../../library/logging.handlers.rst:114 +#: ../../library/logging.handlers.rst:111 msgid "Closes the file." msgstr "關閉檔案。" -#: ../../library/logging.handlers.rst:118 +#: ../../library/logging.handlers.rst:115 msgid "Outputs the record to the file." msgstr "" -#: ../../library/logging.handlers.rst:120 +#: ../../library/logging.handlers.rst:117 msgid "" "Note that if the file was closed due to logging shutdown at exit and the " "file mode is 'w', the record will not be emitted (see :issue:`42378`)." msgstr "" -#: ../../library/logging.handlers.rst:127 +#: ../../library/logging.handlers.rst:124 msgid "NullHandler" msgstr "NullHandler" -#: ../../library/logging.handlers.rst:131 +#: ../../library/logging.handlers.rst:128 msgid "" "The :class:`NullHandler` class, located in the core :mod:`logging` package, " "does not do any formatting or output. It is essentially a 'no-op' handler " "for use by library developers." msgstr "" -#: ../../library/logging.handlers.rst:137 +#: ../../library/logging.handlers.rst:134 msgid "Returns a new instance of the :class:`NullHandler` class." msgstr "" -#: ../../library/logging.handlers.rst:141 -#: ../../library/logging.handlers.rst:145 +#: ../../library/logging.handlers.rst:138 +#: ../../library/logging.handlers.rst:142 msgid "This method does nothing." msgstr "此方法不做任何事。" -#: ../../library/logging.handlers.rst:149 +#: ../../library/logging.handlers.rst:146 msgid "" "This method returns ``None`` for the lock, since there is no underlying I/O " "to which access needs to be serialized." msgstr "" -#: ../../library/logging.handlers.rst:153 +#: ../../library/logging.handlers.rst:150 msgid "" "See :ref:`library-config` for more information on how to use :class:" "`NullHandler`." msgstr "" -#: ../../library/logging.handlers.rst:159 +#: ../../library/logging.handlers.rst:156 msgid "WatchedFileHandler" msgstr "WatchedFileHandler" -#: ../../library/logging.handlers.rst:163 +#: ../../library/logging.handlers.rst:160 msgid "" "The :class:`WatchedFileHandler` class, located in the :mod:`!logging." "handlers` module, is a :class:`FileHandler` which watches the file it is " @@ -218,7 +218,7 @@ msgid "" "name." msgstr "" -#: ../../library/logging.handlers.rst:167 +#: ../../library/logging.handlers.rst:164 msgid "" "A file change can happen because of usage of programs such as *newsyslog* " "and *logrotate* which perform log file rotation. This handler, intended for " @@ -228,7 +228,7 @@ msgid "" "file opened to get a new stream." msgstr "" -#: ../../library/logging.handlers.rst:174 +#: ../../library/logging.handlers.rst:171 msgid "" "This handler is not appropriate for use under Windows, because under Windows " "open log files cannot be moved or renamed - logging opens the files with " @@ -237,7 +237,7 @@ msgid "" "zero for this value." msgstr "" -#: ../../library/logging.handlers.rst:183 +#: ../../library/logging.handlers.rst:180 msgid "" "Returns a new instance of the :class:`WatchedFileHandler` class. The " "specified file is opened and used as the stream for logging. If *mode* is " @@ -248,24 +248,24 @@ msgid "" "errors are handled." msgstr "" -#: ../../library/logging.handlers.rst:199 +#: ../../library/logging.handlers.rst:196 msgid "" "Checks to see if the file has changed. If it has, the existing stream is " "flushed and closed and the file opened again, typically as a precursor to " "outputting the record to the file." msgstr "" -#: ../../library/logging.handlers.rst:208 +#: ../../library/logging.handlers.rst:205 msgid "" "Outputs the record to the file, but first calls :meth:`reopenIfNeeded` to " "reopen the file if it has changed." msgstr "" -#: ../../library/logging.handlers.rst:214 +#: ../../library/logging.handlers.rst:211 msgid "BaseRotatingHandler" msgstr "BaseRotatingHandler" -#: ../../library/logging.handlers.rst:216 +#: ../../library/logging.handlers.rst:213 msgid "" "The :class:`BaseRotatingHandler` class, located in the :mod:`!logging." "handlers` module, is the base class for the rotating file handlers, :class:" @@ -274,18 +274,18 @@ msgid "" "need to override." msgstr "" -#: ../../library/logging.handlers.rst:224 +#: ../../library/logging.handlers.rst:221 msgid "The parameters are as for :class:`FileHandler`. The attributes are:" msgstr "" -#: ../../library/logging.handlers.rst:228 +#: ../../library/logging.handlers.rst:225 msgid "" "If this attribute is set to a callable, the :meth:`rotation_filename` method " "delegates to this callable. The parameters passed to the callable are those " "passed to :meth:`rotation_filename`." msgstr "" -#: ../../library/logging.handlers.rst:232 +#: ../../library/logging.handlers.rst:229 msgid "" "The namer function is called quite a few times during rollover, so it should " "be as simple and as fast as possible. It should also return the same output " @@ -293,7 +293,7 @@ msgid "" "as expected." msgstr "" -#: ../../library/logging.handlers.rst:237 +#: ../../library/logging.handlers.rst:234 msgid "" "It's also worth noting that care should be taken when using a namer to " "preserve certain attributes in the filename which are used during rotation. " @@ -310,37 +310,37 @@ msgid "" "custom naming scheme.)" msgstr "" -#: ../../library/logging.handlers.rst:255 +#: ../../library/logging.handlers.rst:252 msgid "" "If this attribute is set to a callable, the :meth:`rotate` method delegates " "to this callable. The parameters passed to the callable are those passed " "to :meth:`rotate`." msgstr "" -#: ../../library/logging.handlers.rst:263 +#: ../../library/logging.handlers.rst:260 msgid "Modify the filename of a log file when rotating." msgstr "" -#: ../../library/logging.handlers.rst:265 +#: ../../library/logging.handlers.rst:262 msgid "This is provided so that a custom filename can be provided." msgstr "" -#: ../../library/logging.handlers.rst:267 +#: ../../library/logging.handlers.rst:264 msgid "" "The default implementation calls the 'namer' attribute of the handler, if " "it's callable, passing the default name to it. If the attribute isn't " "callable (the default is ``None``), the name is returned unchanged." msgstr "" -#: ../../library/logging.handlers.rst:271 +#: ../../library/logging.handlers.rst:268 msgid "The default name for the log file." msgstr "" -#: ../../library/logging.handlers.rst:278 +#: ../../library/logging.handlers.rst:275 msgid "When rotating, rotate the current log." msgstr "" -#: ../../library/logging.handlers.rst:280 +#: ../../library/logging.handlers.rst:277 msgid "" "The default implementation calls the 'rotator' attribute of the handler, if " "it's callable, passing the source and dest arguments to it. If the attribute " @@ -348,18 +348,18 @@ msgid "" "the destination." msgstr "" -#: ../../library/logging.handlers.rst:285 +#: ../../library/logging.handlers.rst:282 msgid "" "The source filename. This is normally the base filename, e.g. 'test.log'." msgstr "" -#: ../../library/logging.handlers.rst:287 +#: ../../library/logging.handlers.rst:284 msgid "" "The destination filename. This is normally what the source is rotated to, e." "g. 'test.log.1'." msgstr "" -#: ../../library/logging.handlers.rst:292 +#: ../../library/logging.handlers.rst:289 msgid "" "The reason the attributes exist is to save you having to subclass - you can " "use the same callables for instances of :class:`RotatingFileHandler` and :" @@ -369,27 +369,27 @@ msgid "" "method of the handler." msgstr "" -#: ../../library/logging.handlers.rst:299 +#: ../../library/logging.handlers.rst:296 msgid "" "If you need to make more significant changes to rotation processing, you can " "override the methods." msgstr "" -#: ../../library/logging.handlers.rst:302 +#: ../../library/logging.handlers.rst:299 msgid "For an example, see :ref:`cookbook-rotator-namer`." msgstr "" -#: ../../library/logging.handlers.rst:308 +#: ../../library/logging.handlers.rst:305 msgid "RotatingFileHandler" msgstr "RotatingFileHandler" -#: ../../library/logging.handlers.rst:310 +#: ../../library/logging.handlers.rst:307 msgid "" "The :class:`RotatingFileHandler` class, located in the :mod:`!logging." "handlers` module, supports rotation of disk log files." msgstr "" -#: ../../library/logging.handlers.rst:316 +#: ../../library/logging.handlers.rst:313 msgid "" "Returns a new instance of the :class:`RotatingFileHandler` class. The " "specified file is opened and used as the stream for logging. If *mode* is " @@ -400,7 +400,7 @@ msgid "" "errors are handled." msgstr "" -#: ../../library/logging.handlers.rst:323 +#: ../../library/logging.handlers.rst:320 msgid "" "You can use the *maxBytes* and *backupCount* values to allow the file to :" "dfn:`rollover` at a predetermined size. When the size is about to be " @@ -418,35 +418,35 @@ msgid "" "they are renamed to :file:`app.log.2`, :file:`app.log.3` etc. respectively." msgstr "" -#: ../../library/logging.handlers.rst:347 -#: ../../library/logging.handlers.rst:457 +#: ../../library/logging.handlers.rst:344 +#: ../../library/logging.handlers.rst:454 msgid "Does a rollover, as described above." msgstr "" -#: ../../library/logging.handlers.rst:352 +#: ../../library/logging.handlers.rst:349 msgid "" "Outputs the record to the file, catering for rollover as described " "previously." msgstr "" -#: ../../library/logging.handlers.rst:357 +#: ../../library/logging.handlers.rst:354 msgid "" "See if the supplied record would cause the file to exceed the configured " "size limit." msgstr "" -#: ../../library/logging.handlers.rst:362 +#: ../../library/logging.handlers.rst:359 msgid "TimedRotatingFileHandler" msgstr "TimedRotatingFileHandler" -#: ../../library/logging.handlers.rst:364 +#: ../../library/logging.handlers.rst:361 msgid "" "The :class:`TimedRotatingFileHandler` class, located in the :mod:`!logging." "handlers` module, supports rotation of disk log files at certain timed " "intervals." msgstr "" -#: ../../library/logging.handlers.rst:371 +#: ../../library/logging.handlers.rst:368 msgid "" "Returns a new instance of the :class:`TimedRotatingFileHandler` class. The " "specified file is opened and used as the stream for logging. On rotating it " @@ -454,92 +454,92 @@ msgid "" "*when* and *interval*." msgstr "" -#: ../../library/logging.handlers.rst:376 +#: ../../library/logging.handlers.rst:373 msgid "" "You can use the *when* to specify the type of *interval*. The list of " "possible values is below. Note that they are not case sensitive." msgstr "" -#: ../../library/logging.handlers.rst:380 +#: ../../library/logging.handlers.rst:377 msgid "Value" msgstr "" -#: ../../library/logging.handlers.rst:380 +#: ../../library/logging.handlers.rst:377 msgid "Type of interval" msgstr "" -#: ../../library/logging.handlers.rst:380 +#: ../../library/logging.handlers.rst:377 msgid "If/how *atTime* is used" msgstr "" -#: ../../library/logging.handlers.rst:382 +#: ../../library/logging.handlers.rst:379 msgid "``'S'``" msgstr "``'S'``" -#: ../../library/logging.handlers.rst:382 +#: ../../library/logging.handlers.rst:379 msgid "Seconds" msgstr "" -#: ../../library/logging.handlers.rst:382 -#: ../../library/logging.handlers.rst:384 -#: ../../library/logging.handlers.rst:386 -#: ../../library/logging.handlers.rst:388 +#: ../../library/logging.handlers.rst:379 +#: ../../library/logging.handlers.rst:381 +#: ../../library/logging.handlers.rst:383 +#: ../../library/logging.handlers.rst:385 msgid "Ignored" msgstr "" -#: ../../library/logging.handlers.rst:384 +#: ../../library/logging.handlers.rst:381 msgid "``'M'``" msgstr "``'M'``" -#: ../../library/logging.handlers.rst:384 +#: ../../library/logging.handlers.rst:381 msgid "Minutes" msgstr "" -#: ../../library/logging.handlers.rst:386 +#: ../../library/logging.handlers.rst:383 msgid "``'H'``" msgstr "``'H'``" -#: ../../library/logging.handlers.rst:386 +#: ../../library/logging.handlers.rst:383 msgid "Hours" msgstr "" -#: ../../library/logging.handlers.rst:388 +#: ../../library/logging.handlers.rst:385 msgid "``'D'``" msgstr "``'D'``" -#: ../../library/logging.handlers.rst:388 +#: ../../library/logging.handlers.rst:385 msgid "Days" msgstr "" -#: ../../library/logging.handlers.rst:390 +#: ../../library/logging.handlers.rst:387 msgid "``'W0'-'W6'``" msgstr "``'W0'-'W6'``" -#: ../../library/logging.handlers.rst:390 +#: ../../library/logging.handlers.rst:387 msgid "Weekday (0=Monday)" msgstr "" +#: ../../library/logging.handlers.rst:387 #: ../../library/logging.handlers.rst:390 -#: ../../library/logging.handlers.rst:393 msgid "Used to compute initial rollover time" msgstr "" -#: ../../library/logging.handlers.rst:393 +#: ../../library/logging.handlers.rst:390 msgid "``'midnight'``" msgstr "``'midnight'``" -#: ../../library/logging.handlers.rst:393 +#: ../../library/logging.handlers.rst:390 msgid "Roll over at midnight, if *atTime* not specified, else at time *atTime*" msgstr "" -#: ../../library/logging.handlers.rst:398 +#: ../../library/logging.handlers.rst:395 msgid "" "When using weekday-based rotation, specify 'W0' for Monday, 'W1' for " "Tuesday, and so on up to 'W6' for Sunday. In this case, the value passed for " "*interval* isn't used." msgstr "" -#: ../../library/logging.handlers.rst:402 +#: ../../library/logging.handlers.rst:399 msgid "" "The system will save old log files by appending extensions to the filename. " "The extensions are date-and-time based, using the strftime format ``%Y-%m-" @@ -547,20 +547,20 @@ msgid "" "interval." msgstr "" -#: ../../library/logging.handlers.rst:407 +#: ../../library/logging.handlers.rst:404 msgid "" "When computing the next rollover time for the first time (when the handler " "is created), the last modification time of an existing log file, or else the " "current time, is used to compute when the next rotation will occur." msgstr "" -#: ../../library/logging.handlers.rst:411 +#: ../../library/logging.handlers.rst:408 msgid "" "If the *utc* argument is true, times in UTC will be used; otherwise local " "time is used." msgstr "" -#: ../../library/logging.handlers.rst:414 +#: ../../library/logging.handlers.rst:411 msgid "" "If *backupCount* is nonzero, at most *backupCount* files will be kept, and " "if more would be created when rollover occurs, the oldest one is deleted. " @@ -568,13 +568,13 @@ msgid "" "changing the interval may leave old files lying around." msgstr "" -#: ../../library/logging.handlers.rst:419 +#: ../../library/logging.handlers.rst:416 msgid "" "If *delay* is true, then file opening is deferred until the first call to :" "meth:`emit`." msgstr "" -#: ../../library/logging.handlers.rst:422 +#: ../../library/logging.handlers.rst:419 msgid "" "If *atTime* is not ``None``, it must be a ``datetime.time`` instance which " "specifies the time of day when rollover occurs, for the cases where rollover " @@ -584,13 +584,13 @@ msgid "" "normal interval calculation." msgstr "" -#: ../../library/logging.handlers.rst:429 +#: ../../library/logging.handlers.rst:426 msgid "" "If *errors* is specified, it's used to determine how encoding errors are " "handled." msgstr "" -#: ../../library/logging.handlers.rst:432 +#: ../../library/logging.handlers.rst:429 msgid "" "Calculation of the initial rollover time is done when the handler is " "initialised. Calculation of subsequent rollover times is done only when " @@ -605,57 +605,57 @@ msgid "" "to the minutes where no output (and hence no rollover) occurred." msgstr "" -#: ../../library/logging.handlers.rst:445 +#: ../../library/logging.handlers.rst:442 msgid "*atTime* parameter was added." msgstr "新增 *atTime* 參數。" -#: ../../library/logging.handlers.rst:461 +#: ../../library/logging.handlers.rst:458 msgid "" "Outputs the record to the file, catering for rollover as described above." msgstr "" -#: ../../library/logging.handlers.rst:465 +#: ../../library/logging.handlers.rst:462 msgid "" "Returns a list of filenames which should be deleted as part of rollover. " "These are the absolute paths of the oldest backup log files written by the " "handler." msgstr "" -#: ../../library/logging.handlers.rst:470 +#: ../../library/logging.handlers.rst:467 msgid "" "See if enough time has passed for a rollover to occur and if it has, compute " "the next rollover time." msgstr "" -#: ../../library/logging.handlers.rst:476 +#: ../../library/logging.handlers.rst:473 msgid "SocketHandler" msgstr "SocketHandler" -#: ../../library/logging.handlers.rst:478 +#: ../../library/logging.handlers.rst:475 msgid "" "The :class:`SocketHandler` class, located in the :mod:`!logging.handlers` " "module, sends logging output to a network socket. The base class uses a TCP " "socket." msgstr "" -#: ../../library/logging.handlers.rst:484 +#: ../../library/logging.handlers.rst:481 msgid "" "Returns a new instance of the :class:`SocketHandler` class intended to " "communicate with a remote machine whose address is given by *host* and " "*port*." msgstr "" -#: ../../library/logging.handlers.rst:487 +#: ../../library/logging.handlers.rst:484 msgid "" "If ``port`` is specified as ``None``, a Unix domain socket is created using " "the value in ``host`` - otherwise, a TCP socket is created." msgstr "" -#: ../../library/logging.handlers.rst:493 +#: ../../library/logging.handlers.rst:490 msgid "Closes the socket." msgstr "關閉 socket。" -#: ../../library/logging.handlers.rst:498 +#: ../../library/logging.handlers.rst:495 msgid "" "Pickles the record's attribute dictionary and writes it to the socket in " "binary format. If there is an error with the socket, silently drops the " @@ -664,28 +664,28 @@ msgid "" "`~logging.LogRecord`, use the :func:`~logging.makeLogRecord` function." msgstr "" -#: ../../library/logging.handlers.rst:508 +#: ../../library/logging.handlers.rst:505 msgid "" "Handles an error which has occurred during :meth:`emit`. The most likely " "cause is a lost connection. Closes the socket so that we can retry on the " "next event." msgstr "" -#: ../../library/logging.handlers.rst:515 +#: ../../library/logging.handlers.rst:512 msgid "" "This is a factory method which allows subclasses to define the precise type " "of socket they want. The default implementation creates a TCP socket (:const:" "`socket.SOCK_STREAM`)." msgstr "" -#: ../../library/logging.handlers.rst:522 +#: ../../library/logging.handlers.rst:519 msgid "" "Pickles the record's attribute dictionary in binary format with a length " "prefix, and returns it ready for transmission across the socket. The details " "of this operation are equivalent to::" msgstr "" -#: ../../library/logging.handlers.rst:526 +#: ../../library/logging.handlers.rst:523 msgid "" "data = pickle.dumps(record_attr_dict, 1)\n" "datalen = struct.pack('>L', len(data))\n" @@ -695,7 +695,7 @@ msgstr "" "datalen = struct.pack('>L', len(data))\n" "return datalen + data" -#: ../../library/logging.handlers.rst:530 +#: ../../library/logging.handlers.rst:527 msgid "" "Note that pickles aren't completely secure. If you are concerned about " "security, you may want to override this method to implement a more secure " @@ -704,20 +704,20 @@ msgid "" "objects on the receiving end." msgstr "" -#: ../../library/logging.handlers.rst:539 +#: ../../library/logging.handlers.rst:536 msgid "" "Send a pickled byte-string *packet* to the socket. The format of the sent " "byte-string is as described in the documentation for :meth:`~SocketHandler." "makePickle`." msgstr "" -#: ../../library/logging.handlers.rst:543 +#: ../../library/logging.handlers.rst:540 msgid "" "This function allows for partial sends, which can happen when the network is " "busy." msgstr "" -#: ../../library/logging.handlers.rst:549 +#: ../../library/logging.handlers.rst:546 msgid "" "Tries to create a socket; on failure, uses an exponential back-off " "algorithm. On initial failure, the handler will drop the message it was " @@ -728,23 +728,23 @@ msgid "" "each time up to a maximum of 30 seconds." msgstr "" -#: ../../library/logging.handlers.rst:557 +#: ../../library/logging.handlers.rst:554 msgid "This behaviour is controlled by the following handler attributes:" msgstr "" -#: ../../library/logging.handlers.rst:559 +#: ../../library/logging.handlers.rst:556 msgid "``retryStart`` (initial delay, defaulting to 1.0 seconds)." msgstr "" -#: ../../library/logging.handlers.rst:560 +#: ../../library/logging.handlers.rst:557 msgid "``retryFactor`` (multiplier, defaulting to 2.0)." msgstr "" -#: ../../library/logging.handlers.rst:561 +#: ../../library/logging.handlers.rst:558 msgid "``retryMax`` (maximum delay, defaulting to 30.0 seconds)." msgstr "" -#: ../../library/logging.handlers.rst:563 +#: ../../library/logging.handlers.rst:560 msgid "" "This means that if the remote listener starts up *after* the handler has " "been used, you could lose messages (since the handler won't even attempt a " @@ -752,25 +752,25 @@ msgid "" "during the delay period)." msgstr "" -#: ../../library/logging.handlers.rst:572 +#: ../../library/logging.handlers.rst:569 msgid "DatagramHandler" msgstr "DatagramHandler" -#: ../../library/logging.handlers.rst:574 +#: ../../library/logging.handlers.rst:571 msgid "" "The :class:`DatagramHandler` class, located in the :mod:`!logging.handlers` " "module, inherits from :class:`SocketHandler` to support sending logging " "messages over UDP sockets." msgstr "" -#: ../../library/logging.handlers.rst:581 +#: ../../library/logging.handlers.rst:578 msgid "" "Returns a new instance of the :class:`DatagramHandler` class intended to " "communicate with a remote machine whose address is given by *host* and " "*port*." msgstr "" -#: ../../library/logging.handlers.rst:584 +#: ../../library/logging.handlers.rst:581 msgid "" "As UDP is not a streaming protocol, there is no persistent connection " "between an instance of this handler and *host*. For this reason, when using " @@ -780,13 +780,13 @@ msgid "" "looked-up IP address rather than the hostname." msgstr "" -#: ../../library/logging.handlers.rst:591 +#: ../../library/logging.handlers.rst:588 msgid "" "If ``port`` is specified as ``None``, a Unix domain socket is created using " "the value in ``host`` - otherwise, a UDP socket is created." msgstr "" -#: ../../library/logging.handlers.rst:597 +#: ../../library/logging.handlers.rst:594 msgid "" "Pickles the record's attribute dictionary and writes it to the socket in " "binary format. If there is an error with the socket, silently drops the " @@ -794,29 +794,29 @@ msgid "" "LogRecord`, use the :func:`~logging.makeLogRecord` function." msgstr "" -#: ../../library/logging.handlers.rst:606 +#: ../../library/logging.handlers.rst:603 msgid "" "The factory method of :class:`SocketHandler` is here overridden to create a " "UDP socket (:const:`socket.SOCK_DGRAM`)." msgstr "" -#: ../../library/logging.handlers.rst:612 +#: ../../library/logging.handlers.rst:609 msgid "" "Send a pickled byte-string to a socket. The format of the sent byte-string " "is as described in the documentation for :meth:`SocketHandler.makePickle`." msgstr "" -#: ../../library/logging.handlers.rst:619 +#: ../../library/logging.handlers.rst:616 msgid "SysLogHandler" msgstr "SysLogHandler" -#: ../../library/logging.handlers.rst:621 +#: ../../library/logging.handlers.rst:618 msgid "" "The :class:`SysLogHandler` class, located in the :mod:`!logging.handlers` " "module, supports sending logging messages to a remote or local Unix syslog." msgstr "" -#: ../../library/logging.handlers.rst:627 +#: ../../library/logging.handlers.rst:624 msgid "" "Returns a new instance of the :class:`SysLogHandler` class intended to " "communicate with a remote Unix machine whose address is given by *address* " @@ -835,7 +835,7 @@ msgid "" "applied." msgstr "" -#: ../../library/logging.handlers.rst:644 +#: ../../library/logging.handlers.rst:641 msgid "" "Note that if your server is not listening on UDP port 514, :class:" "`SysLogHandler` may appear not to work. In that case, check what address you " @@ -846,30 +846,30 @@ msgid "" "platforms). On Windows, you pretty much have to use the UDP option." msgstr "" -#: ../../library/logging.handlers.rst:653 +#: ../../library/logging.handlers.rst:650 msgid "" "On macOS 12.x (Monterey), Apple has changed the behaviour of their syslog " "daemon - it no longer listens on a domain socket. Therefore, you cannot " "expect :class:`SysLogHandler` to work on this system." msgstr "" -#: ../../library/logging.handlers.rst:657 +#: ../../library/logging.handlers.rst:654 msgid "See :gh:`91070` for more information." msgstr "請見 :gh:`91070` 以取得更多資訊。" -#: ../../library/logging.handlers.rst:659 +#: ../../library/logging.handlers.rst:656 msgid "*socktype* was added." msgstr "新增 *socktype*。" -#: ../../library/logging.handlers.rst:662 +#: ../../library/logging.handlers.rst:659 msgid "*timeout* was added." msgstr "新增 *timeout*。" -#: ../../library/logging.handlers.rst:667 +#: ../../library/logging.handlers.rst:664 msgid "Closes the socket to the remote host." msgstr "" -#: ../../library/logging.handlers.rst:671 +#: ../../library/logging.handlers.rst:668 msgid "" "Tries to create a socket and, if it's not a datagram socket, connect it to " "the other end. This method is called during handler initialization, but it's " @@ -878,13 +878,13 @@ msgid "" "socket at that point." msgstr "" -#: ../../library/logging.handlers.rst:681 +#: ../../library/logging.handlers.rst:678 msgid "" "The record is formatted, and then sent to the syslog server. If exception " "information is present, it is *not* sent to the server." msgstr "" -#: ../../library/logging.handlers.rst:684 +#: ../../library/logging.handlers.rst:681 msgid "" "(See: :issue:`12168`.) In earlier versions, the message sent to the syslog " "daemons was always terminated with a NUL byte, because early versions of " @@ -895,7 +895,7 @@ msgid "" "byte on as part of the message." msgstr "" -#: ../../library/logging.handlers.rst:693 +#: ../../library/logging.handlers.rst:690 msgid "" "To enable easier handling of syslog messages in the face of all these " "differing daemon behaviours, the appending of the NUL byte has been made " @@ -905,7 +905,7 @@ msgid "" "*not* append the NUL terminator." msgstr "" -#: ../../library/logging.handlers.rst:700 +#: ../../library/logging.handlers.rst:697 msgid "" "(See: :issue:`12419`.) In earlier versions, there was no facility for an " "\"ident\" or \"tag\" prefix to identify the source of the message. This can " @@ -916,262 +916,262 @@ msgid "" "bytes, and is prepended to the message exactly as is." msgstr "" -#: ../../library/logging.handlers.rst:711 +#: ../../library/logging.handlers.rst:708 msgid "" "Encodes the facility and priority into an integer. You can pass in strings " "or integers - if strings are passed, internal mapping dictionaries are used " "to convert them to integers." msgstr "" -#: ../../library/logging.handlers.rst:715 +#: ../../library/logging.handlers.rst:712 msgid "" "The symbolic ``LOG_`` values are defined in :class:`SysLogHandler` and " "mirror the values defined in the ``sys/syslog.h`` header file." msgstr "" -#: ../../library/logging.handlers.rst:718 +#: ../../library/logging.handlers.rst:715 msgid "**Priorities**" msgstr "" -#: ../../library/logging.handlers.rst:721 -#: ../../library/logging.handlers.rst:743 +#: ../../library/logging.handlers.rst:718 +#: ../../library/logging.handlers.rst:740 msgid "Name (string)" msgstr "" -#: ../../library/logging.handlers.rst:721 -#: ../../library/logging.handlers.rst:743 +#: ../../library/logging.handlers.rst:718 +#: ../../library/logging.handlers.rst:740 msgid "Symbolic value" msgstr "" -#: ../../library/logging.handlers.rst:723 +#: ../../library/logging.handlers.rst:720 msgid "``alert``" msgstr "``alert``" -#: ../../library/logging.handlers.rst:723 +#: ../../library/logging.handlers.rst:720 msgid "LOG_ALERT" msgstr "LOG_ALERT" -#: ../../library/logging.handlers.rst:725 +#: ../../library/logging.handlers.rst:722 msgid "``crit`` or ``critical``" msgstr "``crit`` 或 ``critical``" -#: ../../library/logging.handlers.rst:725 +#: ../../library/logging.handlers.rst:722 msgid "LOG_CRIT" msgstr "LOG_CRIT" -#: ../../library/logging.handlers.rst:727 +#: ../../library/logging.handlers.rst:724 msgid "``debug``" msgstr "``debug``" -#: ../../library/logging.handlers.rst:727 +#: ../../library/logging.handlers.rst:724 msgid "LOG_DEBUG" msgstr "LOG_DEBUG" -#: ../../library/logging.handlers.rst:729 +#: ../../library/logging.handlers.rst:726 msgid "``emerg`` or ``panic``" msgstr "``emerg`` 或 ``panic``" -#: ../../library/logging.handlers.rst:729 +#: ../../library/logging.handlers.rst:726 msgid "LOG_EMERG" msgstr "LOG_EMERG" -#: ../../library/logging.handlers.rst:731 +#: ../../library/logging.handlers.rst:728 msgid "``err`` or ``error``" msgstr "``err`` 或 ``error``" -#: ../../library/logging.handlers.rst:731 +#: ../../library/logging.handlers.rst:728 msgid "LOG_ERR" msgstr "LOG_ERR" -#: ../../library/logging.handlers.rst:733 +#: ../../library/logging.handlers.rst:730 msgid "``info``" msgstr "``info``" -#: ../../library/logging.handlers.rst:733 +#: ../../library/logging.handlers.rst:730 msgid "LOG_INFO" msgstr "LOG_INFO" -#: ../../library/logging.handlers.rst:735 +#: ../../library/logging.handlers.rst:732 msgid "``notice``" msgstr "``notice``" -#: ../../library/logging.handlers.rst:735 +#: ../../library/logging.handlers.rst:732 msgid "LOG_NOTICE" msgstr "LOG_NOTICE" -#: ../../library/logging.handlers.rst:737 +#: ../../library/logging.handlers.rst:734 msgid "``warn`` or ``warning``" msgstr "``warn`` 或 ``warning``" -#: ../../library/logging.handlers.rst:737 +#: ../../library/logging.handlers.rst:734 msgid "LOG_WARNING" msgstr "LOG_WARNING" -#: ../../library/logging.handlers.rst:740 +#: ../../library/logging.handlers.rst:737 msgid "**Facilities**" msgstr "" -#: ../../library/logging.handlers.rst:745 +#: ../../library/logging.handlers.rst:742 msgid "``auth``" msgstr "``auth``" -#: ../../library/logging.handlers.rst:745 +#: ../../library/logging.handlers.rst:742 msgid "LOG_AUTH" msgstr "LOG_AUTH" -#: ../../library/logging.handlers.rst:747 +#: ../../library/logging.handlers.rst:744 msgid "``authpriv``" msgstr "``authpriv``" -#: ../../library/logging.handlers.rst:747 +#: ../../library/logging.handlers.rst:744 msgid "LOG_AUTHPRIV" msgstr "LOG_AUTHPRIV" -#: ../../library/logging.handlers.rst:749 +#: ../../library/logging.handlers.rst:746 msgid "``cron``" msgstr "``cron``" -#: ../../library/logging.handlers.rst:749 +#: ../../library/logging.handlers.rst:746 msgid "LOG_CRON" msgstr "LOG_CRON" -#: ../../library/logging.handlers.rst:751 +#: ../../library/logging.handlers.rst:748 msgid "``daemon``" msgstr "``daemon``" -#: ../../library/logging.handlers.rst:751 +#: ../../library/logging.handlers.rst:748 msgid "LOG_DAEMON" msgstr "LOG_DAEMON" -#: ../../library/logging.handlers.rst:753 +#: ../../library/logging.handlers.rst:750 msgid "``ftp``" msgstr "``ftp``" -#: ../../library/logging.handlers.rst:753 +#: ../../library/logging.handlers.rst:750 msgid "LOG_FTP" msgstr "LOG_FTP" -#: ../../library/logging.handlers.rst:755 +#: ../../library/logging.handlers.rst:752 msgid "``kern``" msgstr "``kern``" -#: ../../library/logging.handlers.rst:755 +#: ../../library/logging.handlers.rst:752 msgid "LOG_KERN" msgstr "LOG_KERN" -#: ../../library/logging.handlers.rst:757 +#: ../../library/logging.handlers.rst:754 msgid "``lpr``" msgstr "``lpr``" -#: ../../library/logging.handlers.rst:757 +#: ../../library/logging.handlers.rst:754 msgid "LOG_LPR" msgstr "LOG_LPR" -#: ../../library/logging.handlers.rst:759 +#: ../../library/logging.handlers.rst:756 msgid "``mail``" msgstr "``mail``" -#: ../../library/logging.handlers.rst:759 +#: ../../library/logging.handlers.rst:756 msgid "LOG_MAIL" msgstr "LOG_MAIL" -#: ../../library/logging.handlers.rst:761 +#: ../../library/logging.handlers.rst:758 msgid "``news``" msgstr "``news``" -#: ../../library/logging.handlers.rst:761 +#: ../../library/logging.handlers.rst:758 msgid "LOG_NEWS" msgstr "LOG_NEWS" -#: ../../library/logging.handlers.rst:763 +#: ../../library/logging.handlers.rst:760 msgid "``syslog``" msgstr "``syslog``" -#: ../../library/logging.handlers.rst:763 +#: ../../library/logging.handlers.rst:760 msgid "LOG_SYSLOG" msgstr "LOG_SYSLOG" -#: ../../library/logging.handlers.rst:765 +#: ../../library/logging.handlers.rst:762 msgid "``user``" msgstr "``user``" -#: ../../library/logging.handlers.rst:765 +#: ../../library/logging.handlers.rst:762 msgid "LOG_USER" msgstr "LOG_USER" -#: ../../library/logging.handlers.rst:767 +#: ../../library/logging.handlers.rst:764 msgid "``uucp``" msgstr "``uucp``" -#: ../../library/logging.handlers.rst:767 +#: ../../library/logging.handlers.rst:764 msgid "LOG_UUCP" msgstr "LOG_UUCP" -#: ../../library/logging.handlers.rst:769 +#: ../../library/logging.handlers.rst:766 msgid "``local0``" msgstr "``local0``" -#: ../../library/logging.handlers.rst:769 +#: ../../library/logging.handlers.rst:766 msgid "LOG_LOCAL0" msgstr "LOG_LOCAL0" -#: ../../library/logging.handlers.rst:771 +#: ../../library/logging.handlers.rst:768 msgid "``local1``" msgstr "``local1``" -#: ../../library/logging.handlers.rst:771 +#: ../../library/logging.handlers.rst:768 msgid "LOG_LOCAL1" msgstr "LOG_LOCAL1" -#: ../../library/logging.handlers.rst:773 +#: ../../library/logging.handlers.rst:770 msgid "``local2``" msgstr "``local2``" -#: ../../library/logging.handlers.rst:773 +#: ../../library/logging.handlers.rst:770 msgid "LOG_LOCAL2" msgstr "LOG_LOCAL2" -#: ../../library/logging.handlers.rst:775 +#: ../../library/logging.handlers.rst:772 msgid "``local3``" msgstr "``local3``" -#: ../../library/logging.handlers.rst:775 +#: ../../library/logging.handlers.rst:772 msgid "LOG_LOCAL3" msgstr "LOG_LOCAL3" -#: ../../library/logging.handlers.rst:777 +#: ../../library/logging.handlers.rst:774 msgid "``local4``" msgstr "``local4``" -#: ../../library/logging.handlers.rst:777 +#: ../../library/logging.handlers.rst:774 msgid "LOG_LOCAL4" msgstr "LOG_LOCAL4" -#: ../../library/logging.handlers.rst:779 +#: ../../library/logging.handlers.rst:776 msgid "``local5``" msgstr "``local5``" -#: ../../library/logging.handlers.rst:779 +#: ../../library/logging.handlers.rst:776 msgid "LOG_LOCAL5" msgstr "LOG_LOCAL5" -#: ../../library/logging.handlers.rst:781 +#: ../../library/logging.handlers.rst:778 msgid "``local6``" msgstr "``local6``" -#: ../../library/logging.handlers.rst:781 +#: ../../library/logging.handlers.rst:778 msgid "LOG_LOCAL6" msgstr "LOG_LOCAL6" -#: ../../library/logging.handlers.rst:783 +#: ../../library/logging.handlers.rst:780 msgid "``local7``" msgstr "``local7``" -#: ../../library/logging.handlers.rst:783 +#: ../../library/logging.handlers.rst:780 msgid "LOG_LOCAL7" msgstr "LOG_LOCAL7" -#: ../../library/logging.handlers.rst:788 +#: ../../library/logging.handlers.rst:785 msgid "" "Maps a logging level name to a syslog priority name. You may need to " "override this if you are using custom levels, or if the default algorithm is " @@ -1180,11 +1180,11 @@ msgid "" "all other level names to 'warning'." msgstr "" -#: ../../library/logging.handlers.rst:798 +#: ../../library/logging.handlers.rst:795 msgid "NTEventLogHandler" msgstr "NTEventLogHandler" -#: ../../library/logging.handlers.rst:800 +#: ../../library/logging.handlers.rst:797 msgid "" "The :class:`NTEventLogHandler` class, located in the :mod:`!logging." "handlers` module, supports sending logging messages to a local Windows NT, " @@ -1192,7 +1192,7 @@ msgid "" "Hammond's Win32 extensions for Python installed." msgstr "" -#: ../../library/logging.handlers.rst:808 +#: ../../library/logging.handlers.rst:805 msgid "" "Returns a new instance of the :class:`NTEventLogHandler` class. The " "*appname* is used to define the application name as it appears in the event " @@ -1208,7 +1208,7 @@ msgid "" "or ``'Security'``, and defaults to ``'Application'``." msgstr "" -#: ../../library/logging.handlers.rst:824 +#: ../../library/logging.handlers.rst:821 msgid "" "At this point, you can remove the application name from the registry as a " "source of event log entries. However, if you do this, you will not be able " @@ -1217,19 +1217,19 @@ msgid "" "not do this." msgstr "" -#: ../../library/logging.handlers.rst:833 +#: ../../library/logging.handlers.rst:830 msgid "" "Determines the message ID, event category and event type, and then logs the " "message in the NT event log." msgstr "" -#: ../../library/logging.handlers.rst:839 +#: ../../library/logging.handlers.rst:836 msgid "" "Returns the event category for the record. Override this if you want to " "specify your own categories. This version returns 0." msgstr "" -#: ../../library/logging.handlers.rst:845 +#: ../../library/logging.handlers.rst:842 msgid "" "Returns the event type for the record. Override this if you want to specify " "your own types. This version does a mapping using the handler's typemap " @@ -1240,7 +1240,7 @@ msgid "" "the handler's *typemap* attribute." msgstr "" -#: ../../library/logging.handlers.rst:856 +#: ../../library/logging.handlers.rst:853 msgid "" "Returns the message ID for the record. If you are using your own messages, " "you could do this by having the *msg* passed to the logger being an ID " @@ -1249,17 +1249,17 @@ msgid "" "message ID in :file:`win32service.pyd`." msgstr "" -#: ../../library/logging.handlers.rst:865 +#: ../../library/logging.handlers.rst:862 msgid "SMTPHandler" msgstr "SMTPHandler" -#: ../../library/logging.handlers.rst:867 +#: ../../library/logging.handlers.rst:864 msgid "" "The :class:`SMTPHandler` class, located in the :mod:`!logging.handlers` " "module, supports sending logging messages to an email address via SMTP." msgstr "" -#: ../../library/logging.handlers.rst:873 +#: ../../library/logging.handlers.rst:870 msgid "" "Returns a new instance of the :class:`SMTPHandler` class. The instance is " "initialized with the from and to addresses and subject line of the email. " @@ -1270,7 +1270,7 @@ msgid "" "*credentials* argument." msgstr "" -#: ../../library/logging.handlers.rst:880 +#: ../../library/logging.handlers.rst:877 msgid "" "To specify the use of a secure protocol (TLS), pass in a tuple to the " "*secure* argument. This will only be used when authentication credentials " @@ -1280,31 +1280,31 @@ msgid "" "SMTP.starttls` method.)" msgstr "" -#: ../../library/logging.handlers.rst:887 +#: ../../library/logging.handlers.rst:884 msgid "" "A timeout can be specified for communication with the SMTP server using the " "*timeout* argument." msgstr "" -#: ../../library/logging.handlers.rst:890 +#: ../../library/logging.handlers.rst:887 msgid "Added the *timeout* parameter." msgstr "新增 *timeout* 參數。" -#: ../../library/logging.handlers.rst:895 +#: ../../library/logging.handlers.rst:892 msgid "Formats the record and sends it to the specified addressees." msgstr "" -#: ../../library/logging.handlers.rst:900 +#: ../../library/logging.handlers.rst:897 msgid "" "If you want to specify a subject line which is record-dependent, override " "this method." msgstr "" -#: ../../library/logging.handlers.rst:906 +#: ../../library/logging.handlers.rst:903 msgid "MemoryHandler" msgstr "MemoryHandler" -#: ../../library/logging.handlers.rst:908 +#: ../../library/logging.handlers.rst:905 msgid "" "The :class:`MemoryHandler` class, located in the :mod:`!logging.handlers` " "module, supports buffering of logging records in memory, periodically " @@ -1312,7 +1312,7 @@ msgid "" "buffer is full, or when an event of a certain severity or greater is seen." msgstr "" -#: ../../library/logging.handlers.rst:913 +#: ../../library/logging.handlers.rst:910 msgid "" ":class:`MemoryHandler` is a subclass of the more general :class:" "`BufferingHandler`, which is an abstract class. This buffers logging records " @@ -1321,32 +1321,32 @@ msgid "" "should, then :meth:`flush` is expected to do the flushing." msgstr "" -#: ../../library/logging.handlers.rst:922 +#: ../../library/logging.handlers.rst:919 msgid "" "Initializes the handler with a buffer of the specified capacity. Here, " "*capacity* means the number of logging records buffered." msgstr "" -#: ../../library/logging.handlers.rst:928 +#: ../../library/logging.handlers.rst:925 msgid "" "Append the record to the buffer. If :meth:`shouldFlush` returns true, call :" "meth:`flush` to process the buffer." msgstr "" -#: ../../library/logging.handlers.rst:934 +#: ../../library/logging.handlers.rst:931 msgid "" "For a :class:`BufferingHandler` instance, flushing means that it sets the " "buffer to an empty list. This method can be overwritten to implement more " "useful flushing behavior." msgstr "" -#: ../../library/logging.handlers.rst:941 +#: ../../library/logging.handlers.rst:938 msgid "" "Return ``True`` if the buffer is up to capacity. This method can be " "overridden to implement custom flushing strategies." msgstr "" -#: ../../library/logging.handlers.rst:947 +#: ../../library/logging.handlers.rst:944 msgid "" "Returns a new instance of the :class:`MemoryHandler` class. The instance is " "initialized with a buffer size of *capacity* (number of records buffered). " @@ -1358,15 +1358,15 @@ msgid "" "the buffer will occur when the handler is closed." msgstr "" -#: ../../library/logging.handlers.rst:956 +#: ../../library/logging.handlers.rst:953 msgid "The *flushOnClose* parameter was added." msgstr "新增 *flushOnClose* 參數。" -#: ../../library/logging.handlers.rst:962 +#: ../../library/logging.handlers.rst:959 msgid "Calls :meth:`flush`, sets the target to ``None`` and clears the buffer." msgstr "" -#: ../../library/logging.handlers.rst:968 +#: ../../library/logging.handlers.rst:965 msgid "" "For a :class:`MemoryHandler` instance, flushing means just sending the " "buffered records to the target, if there is one. The buffer is also cleared " @@ -1374,26 +1374,26 @@ msgid "" "behavior." msgstr "" -#: ../../library/logging.handlers.rst:975 +#: ../../library/logging.handlers.rst:972 msgid "Sets the target handler for this handler." msgstr "" -#: ../../library/logging.handlers.rst:980 +#: ../../library/logging.handlers.rst:977 msgid "Checks for buffer full or a record at the *flushLevel* or higher." msgstr "" -#: ../../library/logging.handlers.rst:986 +#: ../../library/logging.handlers.rst:983 msgid "HTTPHandler" msgstr "HTTPHandler" -#: ../../library/logging.handlers.rst:988 +#: ../../library/logging.handlers.rst:985 msgid "" "The :class:`HTTPHandler` class, located in the :mod:`!logging.handlers` " "module, supports sending logging messages to a web server, using either " "``GET`` or ``POST`` semantics." msgstr "" -#: ../../library/logging.handlers.rst:995 +#: ../../library/logging.handlers.rst:992 msgid "" "Returns a new instance of the :class:`HTTPHandler` class. The *host* can be " "of the form ``host:port``, should you need to use a specific port number. " @@ -1407,11 +1407,11 @@ msgid "" "cleartext across the wire." msgstr "" -#: ../../library/logging.handlers.rst:1006 +#: ../../library/logging.handlers.rst:1003 msgid "The *context* parameter was added." msgstr "新增 *context* 參數。" -#: ../../library/logging.handlers.rst:1011 +#: ../../library/logging.handlers.rst:1008 msgid "" "Provides a dictionary, based on ``record``, which is to be URL-encoded and " "sent to the web server. The default implementation just returns ``record." @@ -1420,14 +1420,14 @@ msgid "" "customization of what's sent to the server is required." msgstr "" -#: ../../library/logging.handlers.rst:1019 +#: ../../library/logging.handlers.rst:1016 msgid "" "Sends the record to the web server as a URL-encoded dictionary. The :meth:" "`mapLogRecord` method is used to convert the record to the dictionary to be " "sent." msgstr "" -#: ../../library/logging.handlers.rst:1023 +#: ../../library/logging.handlers.rst:1020 msgid "" "Since preparing a record for sending it to a web server is not the same as a " "generic formatting operation, using :meth:`~logging.Handler.setFormatter` to " @@ -1437,18 +1437,18 @@ msgid "" "the dictionary in a form suitable for sending to a web server." msgstr "" -#: ../../library/logging.handlers.rst:1036 +#: ../../library/logging.handlers.rst:1033 msgid "QueueHandler" msgstr "QueueHandler" -#: ../../library/logging.handlers.rst:1040 +#: ../../library/logging.handlers.rst:1037 msgid "" "The :class:`QueueHandler` class, located in the :mod:`!logging.handlers` " "module, supports sending logging messages to a queue, such as those " "implemented in the :mod:`queue` or :mod:`multiprocessing` modules." msgstr "" -#: ../../library/logging.handlers.rst:1044 +#: ../../library/logging.handlers.rst:1041 msgid "" "Along with the :class:`QueueListener` class, :class:`QueueHandler` can be " "used to let handlers do their work on a separate thread from the one which " @@ -1458,7 +1458,7 @@ msgid "" "an email via :class:`SMTPHandler`) are done on a separate thread." msgstr "" -#: ../../library/logging.handlers.rst:1053 +#: ../../library/logging.handlers.rst:1050 msgid "" "Returns a new instance of the :class:`QueueHandler` class. The instance is " "initialized with the queue to send messages to. The *queue* can be any queue-" @@ -1468,14 +1468,14 @@ msgid "" "instances for *queue*." msgstr "" -#: ../../library/logging.handlers.rst:1060 -#: ../../library/logging.handlers.rst:1158 +#: ../../library/logging.handlers.rst:1057 +#: ../../library/logging.handlers.rst:1155 msgid "" "If you are using :mod:`multiprocessing`, you should avoid using :class:" "`~queue.SimpleQueue` and instead use :class:`multiprocessing.Queue`." msgstr "" -#: ../../library/logging.handlers.rst:1065 +#: ../../library/logging.handlers.rst:1062 msgid "" "The :mod:`multiprocessing` module uses an internal logger created and " "accessed via :meth:`~multiprocessing.get_logger`. :class:`multiprocessing." @@ -1485,7 +1485,7 @@ msgid "" "recursion." msgstr "" -#: ../../library/logging.handlers.rst:1074 +#: ../../library/logging.handlers.rst:1071 msgid "" "Enqueues the result of preparing the LogRecord. Should an exception occur (e." "g. because a bounded queue has filled up), the :meth:`~logging.Handler." @@ -1495,13 +1495,13 @@ msgid "" "raiseExceptions` is ``True``)." msgstr "" -#: ../../library/logging.handlers.rst:1083 +#: ../../library/logging.handlers.rst:1080 msgid "" "Prepares a record for queuing. The object returned by this method is " "enqueued." msgstr "" -#: ../../library/logging.handlers.rst:1086 +#: ../../library/logging.handlers.rst:1083 msgid "" "The base implementation formats the record to merge the message, arguments, " "exception and stack information, if present. It also removes unpickleable " @@ -1511,14 +1511,14 @@ msgid "" "attr:`exc_info` and :attr:`exc_text` attributes to ``None``." msgstr "" -#: ../../library/logging.handlers.rst:1094 +#: ../../library/logging.handlers.rst:1091 msgid "" "You might want to override this method if you want to convert the record to " "a dict or JSON string, or send a modified copy of the record while leaving " "the original intact." msgstr "" -#: ../../library/logging.handlers.rst:1098 +#: ../../library/logging.handlers.rst:1095 msgid "" "The base implementation formats the message with arguments, sets the " "``message`` and ``msg`` attributes to the formatted message and sets the " @@ -1534,25 +1534,25 @@ msgid "" "libraries that you use.)" msgstr "" -#: ../../library/logging.handlers.rst:1114 +#: ../../library/logging.handlers.rst:1111 msgid "" "Enqueues the record on the queue using ``put_nowait()``; you may want to " "override this if you want to use blocking behaviour, or a timeout, or a " "customized queue implementation." msgstr "" -#: ../../library/logging.handlers.rst:1120 +#: ../../library/logging.handlers.rst:1117 msgid "" "When created via configuration using :func:`~logging.config.dictConfig`, " "this attribute will contain a :class:`QueueListener` instance for use with " "this handler. Otherwise, it will be ``None``." msgstr "" -#: ../../library/logging.handlers.rst:1129 +#: ../../library/logging.handlers.rst:1126 msgid "QueueListener" msgstr "QueueListener" -#: ../../library/logging.handlers.rst:1133 +#: ../../library/logging.handlers.rst:1130 msgid "" "The :class:`QueueListener` class, located in the :mod:`!logging.handlers` " "module, supports receiving logging messages from a queue, such as those " @@ -1563,7 +1563,7 @@ msgid "" "works hand-in-hand with :class:`QueueHandler`." msgstr "" -#: ../../library/logging.handlers.rst:1141 +#: ../../library/logging.handlers.rst:1138 msgid "" "Along with the :class:`QueueHandler` class, :class:`QueueListener` can be " "used to let handlers do their work on a separate thread from the one which " @@ -1573,7 +1573,7 @@ msgid "" "an email via :class:`SMTPHandler`) are done on a separate thread." msgstr "" -#: ../../library/logging.handlers.rst:1150 +#: ../../library/logging.handlers.rst:1147 msgid "" "Returns a new instance of the :class:`QueueListener` class. The instance is " "initialized with the queue to send messages to and a list of handlers which " @@ -1584,7 +1584,7 @@ msgid "" "class:`~queue.SimpleQueue` instances for *queue*." msgstr "" -#: ../../library/logging.handlers.rst:1161 +#: ../../library/logging.handlers.rst:1158 msgid "" "If ``respect_handler_level`` is ``True``, a handler's level is respected " "(compared with the level for the message) when deciding whether to pass " @@ -1592,11 +1592,11 @@ msgid "" "versions - to always pass each message to each handler." msgstr "" -#: ../../library/logging.handlers.rst:1166 +#: ../../library/logging.handlers.rst:1163 msgid "The ``respect_handler_level`` argument was added." msgstr "新增 ``respect_handler_level`` 引數。" -#: ../../library/logging.handlers.rst:1169 +#: ../../library/logging.handlers.rst:1166 msgid "" ":class:`QueueListener` can now be used as a context manager via :keyword:" "`with`. When entering the context, the listener is started. When exiting the " @@ -1604,84 +1604,84 @@ msgid "" "the :class:`QueueListener` object." msgstr "" -#: ../../library/logging.handlers.rst:1178 +#: ../../library/logging.handlers.rst:1175 msgid "Dequeues a record and return it, optionally blocking." msgstr "" -#: ../../library/logging.handlers.rst:1180 +#: ../../library/logging.handlers.rst:1177 msgid "" "The base implementation uses ``get()``. You may want to override this method " "if you want to use timeouts or work with custom queue implementations." msgstr "" -#: ../../library/logging.handlers.rst:1186 +#: ../../library/logging.handlers.rst:1183 msgid "Prepare a record for handling." msgstr "" -#: ../../library/logging.handlers.rst:1188 +#: ../../library/logging.handlers.rst:1185 msgid "" "This implementation just returns the passed-in record. You may want to " "override this method if you need to do any custom marshalling or " "manipulation of the record before passing it to the handlers." msgstr "" -#: ../../library/logging.handlers.rst:1194 +#: ../../library/logging.handlers.rst:1191 msgid "Handle a record." msgstr "" -#: ../../library/logging.handlers.rst:1196 +#: ../../library/logging.handlers.rst:1193 msgid "" "This just loops through the handlers offering them the record to handle. The " "actual object passed to the handlers is that which is returned from :meth:" "`prepare`." msgstr "" -#: ../../library/logging.handlers.rst:1202 +#: ../../library/logging.handlers.rst:1199 msgid "Starts the listener." msgstr "" -#: ../../library/logging.handlers.rst:1204 +#: ../../library/logging.handlers.rst:1201 msgid "" "This starts up a background thread to monitor the queue for LogRecords to " "process." msgstr "" -#: ../../library/logging.handlers.rst:1207 +#: ../../library/logging.handlers.rst:1204 msgid "" "Raises :exc:`RuntimeError` if called and the listener is already running." msgstr "" -#: ../../library/logging.handlers.rst:1213 +#: ../../library/logging.handlers.rst:1210 msgid "Stops the listener." msgstr "" -#: ../../library/logging.handlers.rst:1215 +#: ../../library/logging.handlers.rst:1212 msgid "" "This asks the thread to terminate, and then waits for it to do so. Note that " "if you don't call this before your application exits, there may be some " "records still left on the queue, which won't be processed." msgstr "" -#: ../../library/logging.handlers.rst:1221 +#: ../../library/logging.handlers.rst:1218 msgid "" "Writes a sentinel to the queue to tell the listener to quit. This " "implementation uses ``put_nowait()``. You may want to override this method " "if you want to use timeouts or work with custom queue implementations." msgstr "" -#: ../../library/logging.handlers.rst:1231 +#: ../../library/logging.handlers.rst:1228 msgid "Module :mod:`logging`" msgstr ":mod:`logging` 模組" -#: ../../library/logging.handlers.rst:1232 +#: ../../library/logging.handlers.rst:1229 msgid "API reference for the logging module." msgstr "" -#: ../../library/logging.handlers.rst:1234 +#: ../../library/logging.handlers.rst:1231 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` 模組" -#: ../../library/logging.handlers.rst:1235 +#: ../../library/logging.handlers.rst:1232 msgid "Configuration API for the logging module." msgstr "" diff --git a/library/logging.po b/library/logging.po index 71c7fa9b49a..a92ede8347e 100644 --- a/library/logging.po +++ b/library/logging.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -23,36 +23,36 @@ msgstr "" msgid ":mod:`!logging` --- Logging facility for Python" msgstr ":mod:`!logging` --- Python 的日誌記錄工具" -#: ../../library/logging.rst:10 +#: ../../library/logging.rst:7 msgid "**Source code:** :source:`Lib/logging/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/logging/__init__.py`" -#: ../../library/logging.rst:16 +#: ../../library/logging.rst:13 msgid "" "This page contains the API reference information. For tutorial information " "and discussion of more advanced topics, see" msgstr "此頁面包含 API 參考訊息。有關教學流程和更進階的主題討論,請參閱" -#: ../../library/logging.rst:19 +#: ../../library/logging.rst:16 msgid ":ref:`Basic Tutorial `" msgstr ":ref:`基礎教學 `" -#: ../../library/logging.rst:20 +#: ../../library/logging.rst:17 msgid ":ref:`Advanced Tutorial `" msgstr ":ref:`進階教學 `" -#: ../../library/logging.rst:21 +#: ../../library/logging.rst:18 msgid ":ref:`Logging Cookbook `" msgstr ":ref:`日誌記錄手冊 `" -#: ../../library/logging.rst:25 +#: ../../library/logging.rst:22 msgid "" "This module defines functions and classes which implement a flexible event " "logging system for applications and libraries." msgstr "" "這個模組定義了函式與類別 (class),為應用程式和函式庫實作彈性的日誌管理系統。" -#: ../../library/logging.rst:28 +#: ../../library/logging.rst:25 msgid "" "The key benefit of having the logging API provided by a standard library " "module is that all Python modules can participate in logging, so your " @@ -63,11 +63,11 @@ msgstr "" "誌記錄,因此你的應用程式日誌可以包含你自己的訊息,並與來自第三方模組的訊息整" "合在一起。" -#: ../../library/logging.rst:33 +#: ../../library/logging.rst:30 msgid "Here's a simple example of idiomatic usage: ::" msgstr "" -#: ../../library/logging.rst:35 +#: ../../library/logging.rst:32 msgid "" "# myapp.py\n" "import logging\n" @@ -97,7 +97,7 @@ msgstr "" "if __name__ == '__main__':\n" " main()" -#: ../../library/logging.rst:51 +#: ../../library/logging.rst:48 msgid "" "# mylib.py\n" "import logging\n" @@ -113,11 +113,11 @@ msgstr "" "def do_something():\n" " logger.info('Doing something')" -#: ../../library/logging.rst:58 +#: ../../library/logging.rst:55 msgid "If you run *myapp.py*, you should see this in *myapp.log*:" msgstr "" -#: ../../library/logging.rst:60 +#: ../../library/logging.rst:57 msgid "" "INFO:__main__:Started\n" "INFO:mylib:Doing something\n" @@ -127,7 +127,7 @@ msgstr "" "INFO:mylib:Doing something\n" "INFO:__main__:Finished" -#: ../../library/logging.rst:66 +#: ../../library/logging.rst:63 msgid "" "The key feature of this idiomatic usage is that the majority of code is " "simply creating a module level logger with ``getLogger(__name__)``, and " @@ -138,7 +138,7 @@ msgid "" "logger; this approach is known as hierarchical logging." msgstr "" -#: ../../library/logging.rst:74 +#: ../../library/logging.rst:71 msgid "" "For logging to be useful, it needs to be configured: setting the levels and " "destinations for each logger, potentially changing how specific modules log, " @@ -149,7 +149,7 @@ msgid "" "to configure the root logger that handles many use cases." msgstr "" -#: ../../library/logging.rst:82 +#: ../../library/logging.rst:79 msgid "" "The module provides a lot of functionality and flexibility. If you are " "unfamiliar with logging, the best way to get to grips with it is to view the " @@ -158,37 +158,37 @@ msgstr "" "這個模組提供了很多的功能性以及彈性。如果你對於 logging 不熟悉,熟悉它最好的方" "法就是去看教學(**請看右上方的連結**)。" -#: ../../library/logging.rst:86 +#: ../../library/logging.rst:83 msgid "" "The basic classes defined by the module, together with their attributes and " "methods, are listed in the sections below." msgstr "" -#: ../../library/logging.rst:89 +#: ../../library/logging.rst:86 msgid "Loggers expose the interface that application code directly uses." msgstr "" -#: ../../library/logging.rst:90 +#: ../../library/logging.rst:87 msgid "" "Handlers send the log records (created by loggers) to the appropriate " "destination." msgstr "" -#: ../../library/logging.rst:92 +#: ../../library/logging.rst:89 msgid "" "Filters provide a finer grained facility for determining which log records " "to output." msgstr "" -#: ../../library/logging.rst:94 +#: ../../library/logging.rst:91 msgid "Formatters specify the layout of log records in the final output." msgstr "格式器指定日誌記錄在最終輸出中的佈局。" -#: ../../library/logging.rst:100 +#: ../../library/logging.rst:97 msgid "Logger Objects" msgstr "Logger 物件" -#: ../../library/logging.rst:102 +#: ../../library/logging.rst:99 msgid "" "Loggers have the following attributes and methods. Note that Loggers should " "*NEVER* be instantiated directly, but always through the module-level " @@ -196,7 +196,7 @@ msgid "" "with the same name will always return a reference to the same Logger object." msgstr "" -#: ../../library/logging.rst:107 +#: ../../library/logging.rst:104 msgid "" "The ``name`` is potentially a period-separated hierarchical value, like " "``foo.bar.baz`` (though it could also be just plain ``foo``, for example). " @@ -211,37 +211,37 @@ msgid "" "module's name in the Python package namespace." msgstr "" -#: ../../library/logging.rst:123 +#: ../../library/logging.rst:120 msgid "" "This is the logger's name, and is the value that was passed to :func:" "`getLogger` to obtain the logger." msgstr "" -#: ../../library/logging.rst:126 ../../library/logging.rst:186 +#: ../../library/logging.rst:123 ../../library/logging.rst:183 msgid "This attribute should be treated as read-only." msgstr "此屬性應被視為唯讀。" -#: ../../library/logging.rst:130 +#: ../../library/logging.rst:127 msgid "The threshold of this logger, as set by the :meth:`setLevel` method." msgstr "" -#: ../../library/logging.rst:132 +#: ../../library/logging.rst:129 msgid "" "Do not set this attribute directly - always use :meth:`setLevel`, which has " "checks for the level passed to it." msgstr "" -#: ../../library/logging.rst:137 +#: ../../library/logging.rst:134 msgid "" "The parent logger of this logger. It may change based on later instantiation " "of loggers which are higher up in the namespace hierarchy." msgstr "" -#: ../../library/logging.rst:140 +#: ../../library/logging.rst:137 msgid "This value should be treated as read-only." msgstr "" -#: ../../library/logging.rst:144 +#: ../../library/logging.rst:141 msgid "" "If this attribute evaluates to true, events logged to this logger will be " "passed to the handlers of higher level (ancestor) loggers, in addition to " @@ -253,13 +253,13 @@ msgstr "" "記錄器 的處理函式和所有附加在此日誌記錄器的任何處理器。訊息會直接傳到上代 " "loggers 的處理器 - 在問題中上代日誌記錄器的層級或是篩選器都不會被考慮。" -#: ../../library/logging.rst:150 +#: ../../library/logging.rst:147 msgid "" "If this evaluates to false, logging messages are not passed to the handlers " "of ancestor loggers." msgstr "" -#: ../../library/logging.rst:153 +#: ../../library/logging.rst:150 msgid "" "Spelling it out with an example: If the propagate attribute of the logger " "named ``A.B.C`` evaluates to true, any event logged to ``A.B.C`` via a " @@ -272,11 +272,11 @@ msgid "" "handle, and propagation stops at that point." msgstr "" -#: ../../library/logging.rst:162 +#: ../../library/logging.rst:159 msgid "The constructor sets this attribute to ``True``." msgstr "此建構函式將該屬性設為 ``True``。" -#: ../../library/logging.rst:164 +#: ../../library/logging.rst:161 msgid "" "If you attach a handler to a logger *and* one or more of its ancestors, it " "may emit the same record multiple times. In general, you should not need to " @@ -288,24 +288,24 @@ msgid "" "rest." msgstr "" -#: ../../library/logging.rst:175 +#: ../../library/logging.rst:172 msgid "The list of handlers directly attached to this logger instance." msgstr "" -#: ../../library/logging.rst:177 +#: ../../library/logging.rst:174 msgid "" "This attribute should be treated as read-only; it is normally changed via " "the :meth:`addHandler` and :meth:`removeHandler` methods, which use locks to " "ensure thread-safe operation." msgstr "" -#: ../../library/logging.rst:183 +#: ../../library/logging.rst:180 msgid "" "This attribute disables handling of any events. It is set to ``False`` in " "the initializer, and only changed by logging configuration code." msgstr "" -#: ../../library/logging.rst:190 +#: ../../library/logging.rst:187 msgid "" "Sets the threshold for this logger to *level*. Logging messages which are " "less severe than *level* will be ignored; logging messages which have " @@ -314,7 +314,7 @@ msgid "" "severity level than *level*." msgstr "" -#: ../../library/logging.rst:195 +#: ../../library/logging.rst:192 msgid "" "When a logger is created, the level is set to :const:`NOTSET` (which causes " "all messages to be processed when the logger is the root logger, or " @@ -325,32 +325,32 @@ msgstr "" "是根日誌記錄器,或是代表父日誌記錄器的非根日誌記錄器時,會使所有訊息被處" "理)。請注意根日誌記錄器會以記錄等級 :const:`WARNING` 被建立。" -#: ../../library/logging.rst:200 +#: ../../library/logging.rst:197 msgid "" "The term 'delegation to the parent' means that if a logger has a level of " "NOTSET, its chain of ancestor loggers is traversed until either an ancestor " "with a level other than NOTSET is found, or the root is reached." msgstr "" -#: ../../library/logging.rst:204 +#: ../../library/logging.rst:201 msgid "" "If an ancestor is found with a level other than NOTSET, then that ancestor's " "level is treated as the effective level of the logger where the ancestor " "search began, and is used to determine how a logging event is handled." msgstr "" -#: ../../library/logging.rst:208 +#: ../../library/logging.rst:205 msgid "" "If the root is reached, and it has a level of NOTSET, then all messages will " "be processed. Otherwise, the root's level will be used as the effective " "level." msgstr "" -#: ../../library/logging.rst:211 ../../library/logging.rst:555 +#: ../../library/logging.rst:208 ../../library/logging.rst:552 msgid "See :ref:`levels` for a list of levels." msgstr "層級清單請見 :ref:`levels`。" -#: ../../library/logging.rst:213 +#: ../../library/logging.rst:210 msgid "" "The *level* parameter now accepts a string representation of the level such " "as 'INFO' as an alternative to the integer constants such as :const:`INFO`. " @@ -359,7 +359,7 @@ msgid "" "expect to be passed integers." msgstr "" -#: ../../library/logging.rst:223 +#: ../../library/logging.rst:220 msgid "" "Indicates if a message of severity *level* would be processed by this " "logger. This method checks first the module-level level set by ``logging." @@ -367,7 +367,7 @@ msgid "" "meth:`getEffectiveLevel`." msgstr "" -#: ../../library/logging.rst:231 +#: ../../library/logging.rst:228 msgid "" "Indicates the effective level for this logger. If a value other than :const:" "`NOTSET` has been set using :meth:`setLevel`, it is returned. Otherwise, the " @@ -376,7 +376,7 @@ msgid "" "integer, typically one of :const:`logging.DEBUG`, :const:`logging.INFO` etc." msgstr "" -#: ../../library/logging.rst:241 +#: ../../library/logging.rst:238 msgid "" "Returns a logger which is a descendant to this logger, as determined by the " "suffix. Thus, ``logging.getLogger('abc').getChild('def.ghi')`` would return " @@ -385,7 +385,7 @@ msgid "" "named using e.g. ``__name__`` rather than a literal string." msgstr "" -#: ../../library/logging.rst:252 +#: ../../library/logging.rst:249 msgid "" "Returns a set of loggers which are immediate children of this logger. So for " "example ``logging.getLogger().getChildren()`` might return a set containing " @@ -395,7 +395,7 @@ msgid "" "include one named ``foo.bar.baz``." msgstr "" -#: ../../library/logging.rst:264 +#: ../../library/logging.rst:261 msgid "" "Logs a message with level :const:`DEBUG` on this logger. The *msg* is the " "message format string, and the *args* are the arguments which are merged " @@ -405,13 +405,13 @@ msgid "" "are supplied." msgstr "" -#: ../../library/logging.rst:270 +#: ../../library/logging.rst:267 msgid "" "There are four keyword arguments in *kwargs* which are inspected: " "*exc_info*, *stack_info*, *stacklevel* and *extra*." msgstr "" -#: ../../library/logging.rst:273 +#: ../../library/logging.rst:270 msgid "" "If *exc_info* does not evaluate as false, it causes exception information to " "be added to the logging message. If an exception tuple (in the format " @@ -420,7 +420,7 @@ msgid "" "information." msgstr "" -#: ../../library/logging.rst:278 +#: ../../library/logging.rst:275 msgid "" "The second optional keyword argument is *stack_info*, which defaults to " "``False``. If true, stack information is added to the logging message, " @@ -432,24 +432,24 @@ msgid "" "handlers." msgstr "" -#: ../../library/logging.rst:287 +#: ../../library/logging.rst:284 msgid "" "You can specify *stack_info* independently of *exc_info*, e.g. to just show " "how you got to a certain point in your code, even when no exceptions were " "raised. The stack frames are printed following a header line which says:" msgstr "" -#: ../../library/logging.rst:291 +#: ../../library/logging.rst:288 msgid "Stack (most recent call last):" msgstr "Stack (most recent call last):" -#: ../../library/logging.rst:295 +#: ../../library/logging.rst:292 msgid "" "This mimics the ``Traceback (most recent call last):`` which is used when " "displaying exception frames." msgstr "" -#: ../../library/logging.rst:298 +#: ../../library/logging.rst:295 msgid "" "The third optional keyword argument is *stacklevel*, which defaults to " "``1``. If greater than 1, the corresponding number of stack frames are " @@ -461,7 +461,7 @@ msgid "" "module." msgstr "" -#: ../../library/logging.rst:306 +#: ../../library/logging.rst:303 msgid "" "The fourth keyword argument is *extra* which can be used to pass a " "dictionary which is used to populate the :attr:`~object.__dict__` of the :" @@ -470,7 +470,7 @@ msgid "" "example, they could be incorporated into logged messages. For example::" msgstr "" -#: ../../library/logging.rst:313 +#: ../../library/logging.rst:310 msgid "" "FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s'\n" "logging.basicConfig(format=FORMAT)\n" @@ -484,24 +484,24 @@ msgstr "" "logger = logging.getLogger('tcpserver')\n" "logger.warning('Protocol problem: %s', 'connection reset', extra=d)" -#: ../../library/logging.rst:319 +#: ../../library/logging.rst:316 msgid "would print something like" msgstr "" -#: ../../library/logging.rst:321 +#: ../../library/logging.rst:318 msgid "" "2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem: connection " "reset" msgstr "" -#: ../../library/logging.rst:325 +#: ../../library/logging.rst:322 msgid "" "The keys in the dictionary passed in *extra* should not clash with the keys " "used by the logging system. (See the section on :ref:`logrecord-attributes` " "for more information on which keys are used by the logging system.)" msgstr "" -#: ../../library/logging.rst:329 +#: ../../library/logging.rst:326 msgid "" "If you choose to use these attributes in logged messages, you need to " "exercise some care. In the above example, for instance, the :class:" @@ -512,7 +512,7 @@ msgid "" "dictionary with these keys." msgstr "" -#: ../../library/logging.rst:336 +#: ../../library/logging.rst:333 msgid "" "While this might be annoying, this feature is intended for use in " "specialized circumstances, such as multi-threaded servers where the same " @@ -523,32 +523,32 @@ msgid "" "particular :class:`Handler`\\ s." msgstr "" -#: ../../library/logging.rst:343 +#: ../../library/logging.rst:340 msgid "" "If no handler is attached to this logger (or any of its ancestors, taking " "into account the relevant :attr:`Logger.propagate` attributes), the message " "will be sent to the handler set on :data:`lastResort`." msgstr "" -#: ../../library/logging.rst:347 +#: ../../library/logging.rst:344 msgid "The *stack_info* parameter was added." msgstr "新增 *stack_info* 參數。" -#: ../../library/logging.rst:350 +#: ../../library/logging.rst:347 msgid "The *exc_info* parameter can now accept exception instances." msgstr "" -#: ../../library/logging.rst:353 +#: ../../library/logging.rst:350 msgid "The *stacklevel* parameter was added." msgstr "新增 *stacklevel* 參數。" -#: ../../library/logging.rst:359 +#: ../../library/logging.rst:356 msgid "" "Logs a message with level :const:`INFO` on this logger. The arguments are " "interpreted as for :meth:`debug`." msgstr "" -#: ../../library/logging.rst:365 +#: ../../library/logging.rst:362 msgid "" "Logs a message with level :const:`WARNING` on this logger. The arguments are " "interpreted as for :meth:`debug`." @@ -556,47 +556,47 @@ msgstr "" "在此記錄器上記錄一條層級為 :const:`WARNING` 的訊息。這些引數被直譯的方式與 :" "meth:`debug` 相同。" -#: ../../library/logging.rst:368 +#: ../../library/logging.rst:365 msgid "" "There is an obsolete method ``warn`` which is functionally identical to " "``warning``. As ``warn`` is deprecated, please do not use it - use " "``warning`` instead." msgstr "" -#: ../../library/logging.rst:374 +#: ../../library/logging.rst:371 msgid "" "Logs a message with level :const:`ERROR` on this logger. The arguments are " "interpreted as for :meth:`debug`." msgstr "" -#: ../../library/logging.rst:380 +#: ../../library/logging.rst:377 msgid "" "Logs a message with level :const:`CRITICAL` on this logger. The arguments " "are interpreted as for :meth:`debug`." msgstr "" -#: ../../library/logging.rst:386 +#: ../../library/logging.rst:383 msgid "" "Logs a message with integer level *level* on this logger. The other " "arguments are interpreted as for :meth:`debug`." msgstr "" -#: ../../library/logging.rst:392 +#: ../../library/logging.rst:389 msgid "" "Logs a message with level :const:`ERROR` on this logger. The arguments are " "interpreted as for :meth:`debug`. Exception info is added to the logging " "message. This method should only be called from an exception handler." msgstr "" -#: ../../library/logging.rst:399 +#: ../../library/logging.rst:396 msgid "Adds the specified filter *filter* to this logger." msgstr "在該 logger 內增加指定的 filter *filter*。" -#: ../../library/logging.rst:404 +#: ../../library/logging.rst:401 msgid "Removes the specified filter *filter* from this logger." msgstr "在該 logger 內移除指定的 filter *filter*。" -#: ../../library/logging.rst:409 +#: ../../library/logging.rst:406 msgid "" "Apply this logger's filters to the record and return ``True`` if the record " "is to be processed. The filters are consulted in turn, until one of them " @@ -605,22 +605,22 @@ msgid "" "processing of the record occurs." msgstr "" -#: ../../library/logging.rst:418 +#: ../../library/logging.rst:415 msgid "Adds the specified handler *hdlr* to this logger." msgstr "" -#: ../../library/logging.rst:423 +#: ../../library/logging.rst:420 msgid "Removes the specified handler *hdlr* from this logger." msgstr "" -#: ../../library/logging.rst:428 +#: ../../library/logging.rst:425 msgid "" "Finds the caller's source filename and line number. Returns the filename, " "line number, function name and stack information as a 4-element tuple. The " "stack information is returned as ``None`` unless *stack_info* is ``True``." msgstr "" -#: ../../library/logging.rst:432 +#: ../../library/logging.rst:429 msgid "" "The *stacklevel* parameter is passed from code calling the :meth:`debug` and " "other APIs. If greater than 1, the excess is used to skip stack frames " @@ -630,7 +630,7 @@ msgid "" "calls it." msgstr "" -#: ../../library/logging.rst:442 +#: ../../library/logging.rst:439 msgid "" "Handles a record by passing it to all handlers associated with this logger " "and its ancestors (until a false value of *propagate* is found). This method " @@ -639,13 +639,13 @@ msgid "" "filter`." msgstr "" -#: ../../library/logging.rst:450 +#: ../../library/logging.rst:447 msgid "" "This is a factory method which can be overridden in subclasses to create " "specialized :class:`LogRecord` instances." msgstr "" -#: ../../library/logging.rst:455 +#: ../../library/logging.rst:452 msgid "" "Checks to see if this logger has any handlers configured. This is done by " "looking for handlers in this logger and its parents in the logger hierarchy. " @@ -655,15 +655,15 @@ msgid "" "the existence of handlers." msgstr "" -#: ../../library/logging.rst:464 +#: ../../library/logging.rst:461 msgid "Loggers can now be pickled and unpickled." msgstr "" -#: ../../library/logging.rst:470 +#: ../../library/logging.rst:467 msgid "Logging Levels" msgstr "" -#: ../../library/logging.rst:472 +#: ../../library/logging.rst:469 msgid "" "The numeric values of logging levels are given in the following table. These " "are primarily of interest if you want to define your own levels, and need " @@ -672,83 +672,83 @@ msgid "" "value; the predefined name is lost." msgstr "" -#: ../../library/logging.rst:479 +#: ../../library/logging.rst:476 msgid "Level" msgstr "" -#: ../../library/logging.rst:479 +#: ../../library/logging.rst:476 msgid "Numeric value" msgstr "" -#: ../../library/logging.rst:479 +#: ../../library/logging.rst:476 msgid "What it means / When to use it" msgstr "" -#: ../../library/logging.rst:481 +#: ../../library/logging.rst:478 msgid "0" msgstr "0" -#: ../../library/logging.rst:481 +#: ../../library/logging.rst:478 msgid "" "When set on a logger, indicates that ancestor loggers are to be consulted to " "determine the effective level. If that still resolves to :const:`!NOTSET`, " "then all events are logged. When set on a handler, all events are handled." msgstr "" -#: ../../library/logging.rst:489 +#: ../../library/logging.rst:486 msgid "10" msgstr "10" -#: ../../library/logging.rst:489 +#: ../../library/logging.rst:486 msgid "" "Detailed information, typically only of interest to a developer trying to " "diagnose a problem." msgstr "" -#: ../../library/logging.rst:493 +#: ../../library/logging.rst:490 msgid "20" msgstr "20" -#: ../../library/logging.rst:493 +#: ../../library/logging.rst:490 msgid "Confirmation that things are working as expected." msgstr "" -#: ../../library/logging.rst:496 +#: ../../library/logging.rst:493 msgid "30" msgstr "30" -#: ../../library/logging.rst:496 +#: ../../library/logging.rst:493 msgid "" "An indication that something unexpected happened, or that a problem might " "occur in the near future (e.g. 'disk space low'). The software is still " "working as expected." msgstr "" -#: ../../library/logging.rst:503 +#: ../../library/logging.rst:500 msgid "40" msgstr "40" -#: ../../library/logging.rst:503 +#: ../../library/logging.rst:500 msgid "" "Due to a more serious problem, the software has not been able to perform " "some function." msgstr "" -#: ../../library/logging.rst:507 +#: ../../library/logging.rst:504 msgid "50" msgstr "50" -#: ../../library/logging.rst:507 +#: ../../library/logging.rst:504 msgid "" "A serious error, indicating that the program itself may be unable to " "continue running." msgstr "" -#: ../../library/logging.rst:516 +#: ../../library/logging.rst:513 msgid "Handler Objects" msgstr "" -#: ../../library/logging.rst:518 +#: ../../library/logging.rst:515 msgid "" "Handlers have the following attributes and methods. Note that :class:" "`Handler` is never instantiated directly; this class acts as a base for more " @@ -756,55 +756,55 @@ msgid "" "to call :meth:`Handler.__init__`." msgstr "" -#: ../../library/logging.rst:527 +#: ../../library/logging.rst:524 msgid "" "Initializes the :class:`Handler` instance by setting its level, setting the " "list of filters to the empty list and creating a lock (using :meth:" "`createLock`) for serializing access to an I/O mechanism." msgstr "" -#: ../../library/logging.rst:534 +#: ../../library/logging.rst:531 msgid "" "Initializes a thread lock which can be used to serialize access to " "underlying I/O functionality which may not be threadsafe." msgstr "" -#: ../../library/logging.rst:540 +#: ../../library/logging.rst:537 msgid "Acquires the thread lock created with :meth:`createLock`." msgstr "" -#: ../../library/logging.rst:545 +#: ../../library/logging.rst:542 msgid "Releases the thread lock acquired with :meth:`acquire`." msgstr "" -#: ../../library/logging.rst:550 +#: ../../library/logging.rst:547 msgid "" "Sets the threshold for this handler to *level*. Logging messages which are " "less severe than *level* will be ignored. When a handler is created, the " "level is set to :const:`NOTSET` (which causes all messages to be processed)." msgstr "" -#: ../../library/logging.rst:557 +#: ../../library/logging.rst:554 msgid "" "The *level* parameter now accepts a string representation of the level such " "as 'INFO' as an alternative to the integer constants such as :const:`INFO`." msgstr "" -#: ../../library/logging.rst:565 +#: ../../library/logging.rst:562 msgid "" "Sets the formatter for this handler to *fmt*. The *fmt* argument must be a :" "class:`Formatter` instance or ``None``." msgstr "" -#: ../../library/logging.rst:571 +#: ../../library/logging.rst:568 msgid "Adds the specified filter *filter* to this handler." msgstr "" -#: ../../library/logging.rst:576 +#: ../../library/logging.rst:573 msgid "Removes the specified filter *filter* from this handler." msgstr "" -#: ../../library/logging.rst:581 +#: ../../library/logging.rst:578 msgid "" "Apply this handler's filters to the record and return ``True`` if the record " "is to be processed. The filters are consulted in turn, until one of them " @@ -813,33 +813,33 @@ msgid "" "record." msgstr "" -#: ../../library/logging.rst:590 +#: ../../library/logging.rst:587 msgid "" "Ensure all logging output has been flushed. This version does nothing and is " "intended to be implemented by subclasses." msgstr "" -#: ../../library/logging.rst:596 +#: ../../library/logging.rst:593 msgid "" "Tidy up any resources used by the handler. This version does no output but " "removes the handler from an internal map of handlers, which is used for " "handler lookup by name." msgstr "" -#: ../../library/logging.rst:600 +#: ../../library/logging.rst:597 msgid "" "Subclasses should ensure that this gets called from overridden :meth:`close` " "methods." msgstr "" -#: ../../library/logging.rst:606 +#: ../../library/logging.rst:603 msgid "" "Conditionally emits the specified logging record, depending on filters which " "may have been added to the handler. Wraps the actual emission of the record " "with acquisition/release of the I/O thread lock." msgstr "" -#: ../../library/logging.rst:613 +#: ../../library/logging.rst:610 msgid "" "This method should be called from handlers when an exception is encountered " "during an :meth:`emit` call. If the module-level attribute :data:" @@ -852,20 +852,20 @@ msgid "" "is more useful during development)." msgstr "" -#: ../../library/logging.rst:626 +#: ../../library/logging.rst:623 msgid "" "Do formatting for a record - if a formatter is set, use it. Otherwise, use " "the default formatter for the module." msgstr "" -#: ../../library/logging.rst:632 +#: ../../library/logging.rst:629 msgid "" "Do whatever it takes to actually log the specified logging record. This " "version is intended to be implemented by subclasses and so raises a :exc:" "`NotImplementedError`." msgstr "" -#: ../../library/logging.rst:636 +#: ../../library/logging.rst:633 msgid "" "This method is called after a handler-level lock is acquired, which is " "released after this method returns. When you override this method, note that " @@ -874,13 +874,13 @@ msgid "" "Specifically:" msgstr "" -#: ../../library/logging.rst:642 +#: ../../library/logging.rst:639 msgid "" "Logging configuration APIs acquire the module-level lock, and then " "individual handler-level locks as those handlers are configured." msgstr "" -#: ../../library/logging.rst:645 +#: ../../library/logging.rst:642 msgid "" "Many logging APIs lock the module-level lock. If such an API is called from " "this method, it could cause a deadlock if a configuration call is made on " @@ -890,16 +890,16 @@ msgid "" "method, the handler-level lock has already been acquired)." msgstr "" -#: ../../library/logging.rst:652 +#: ../../library/logging.rst:649 msgid "" "For a list of handlers included as standard, see :mod:`logging.handlers`." msgstr "" -#: ../../library/logging.rst:657 +#: ../../library/logging.rst:654 msgid "Formatter Objects" msgstr "" -#: ../../library/logging.rst:663 +#: ../../library/logging.rst:660 msgid "" "Responsible for converting a :class:`LogRecord` to an output string to be " "interpreted by a human or external system." @@ -909,7 +909,7 @@ msgstr "" msgid "Parameters" msgstr "" -#: ../../library/logging.rst:666 +#: ../../library/logging.rst:663 msgid "" "A format string in the given *style* for the logged output as a whole. The " "possible mapping keys are drawn from the :class:`LogRecord` object's :ref:" @@ -917,13 +917,13 @@ msgid "" "is just the logged message." msgstr "" -#: ../../library/logging.rst:674 +#: ../../library/logging.rst:671 msgid "" "A format string for the date/time portion of the logged output. If not " "specified, the default described in :meth:`formatTime` is used." msgstr "" -#: ../../library/logging.rst:678 +#: ../../library/logging.rst:675 msgid "" "Can be one of ``'%'``, ``'{'`` or ``'$'`` and determines how the format " "string will be merged with its data: using one of :ref:`old-string-" @@ -934,32 +934,32 @@ msgid "" "``{``- and ``$``-formatting for log messages." msgstr "" -#: ../../library/logging.rst:688 +#: ../../library/logging.rst:685 msgid "" "If ``True`` (the default), incorrect or mismatched *fmt* and *style* will " "raise a :exc:`ValueError`; for example, ``logging.Formatter('%(asctime)s - " "%(message)s', style='{')``." msgstr "" -#: ../../library/logging.rst:693 +#: ../../library/logging.rst:690 msgid "" "A dictionary with default values to use in custom fields. For example, " "``logging.Formatter('%(ip)s %(message)s', defaults={\"ip\": None})``" msgstr "" -#: ../../library/logging.rst:698 +#: ../../library/logging.rst:695 msgid "Added the *style* parameter." msgstr "新增 *style* 參數。" -#: ../../library/logging.rst:701 +#: ../../library/logging.rst:698 msgid "Added the *validate* parameter." msgstr "新增 *validate* 參數。" -#: ../../library/logging.rst:704 +#: ../../library/logging.rst:701 msgid "Added the *defaults* parameter." msgstr "新增 *defaults* 參數。" -#: ../../library/logging.rst:710 +#: ../../library/logging.rst:707 msgid "" "The record's attribute dictionary is used as the operand to a string " "formatting operation. Returns the resulting string. Before formatting the " @@ -978,13 +978,13 @@ msgid "" "recalculates it afresh." msgstr "" -#: ../../library/logging.rst:726 +#: ../../library/logging.rst:723 msgid "" "If stack information is available, it's appended after the exception " "information, using :meth:`formatStack` to transform it if necessary." msgstr "" -#: ../../library/logging.rst:732 +#: ../../library/logging.rst:729 msgid "" "This method should be called from :meth:`format` by a formatter which wants " "to make use of a formatted time. This method can be overridden in formatters " @@ -997,7 +997,7 @@ msgid "" "resulting string is returned." msgstr "" -#: ../../library/logging.rst:742 +#: ../../library/logging.rst:739 msgid "" "This function uses a user-configurable function to convert the creation time " "to a tuple. By default, :func:`time.localtime` is used; to change this for a " @@ -1007,7 +1007,7 @@ msgid "" "be shown in GMT, set the ``converter`` attribute in the ``Formatter`` class." msgstr "" -#: ../../library/logging.rst:750 +#: ../../library/logging.rst:747 msgid "" "Previously, the default format was hard-coded as in this example: " "``2010-09-06 22:38:15,292`` where the part before the comma is handled by a " @@ -1022,11 +1022,11 @@ msgid "" "the millisecond value)." msgstr "" -#: ../../library/logging.rst:763 +#: ../../library/logging.rst:760 msgid "The ``default_msec_format`` can be ``None``." msgstr "" -#: ../../library/logging.rst:768 +#: ../../library/logging.rst:765 msgid "" "Formats the specified exception information (a standard exception tuple as " "returned by :func:`sys.exc_info`) as a string. This default implementation " @@ -1034,14 +1034,14 @@ msgid "" "returned." msgstr "" -#: ../../library/logging.rst:775 +#: ../../library/logging.rst:772 msgid "" "Formats the specified stack information (a string as returned by :func:" "`traceback.print_stack`, but with the last newline removed) as a string. " "This default implementation just returns the input value." msgstr "" -#: ../../library/logging.rst:781 +#: ../../library/logging.rst:778 msgid "" "A base formatter class suitable for subclassing when you want to format a " "number of records. You can pass a :class:`Formatter` instance which you want " @@ -1050,7 +1050,7 @@ msgid "" "used as the line formatter." msgstr "" -#: ../../library/logging.rst:789 +#: ../../library/logging.rst:786 msgid "" "Return a header for a list of *records*. The base implementation just " "returns the empty string. You will need to override this method if you want " @@ -1058,14 +1058,14 @@ msgid "" "separator line." msgstr "" -#: ../../library/logging.rst:796 +#: ../../library/logging.rst:793 msgid "" "Return a footer for a list of *records*. The base implementation just " "returns the empty string. You will need to override this method if you want " "specific behaviour, e.g. to show the count of records or a separator line." msgstr "" -#: ../../library/logging.rst:803 +#: ../../library/logging.rst:800 msgid "" "Return formatted text for a list of *records*. The base implementation just " "returns the empty string if there are no records; otherwise, it returns the " @@ -1073,11 +1073,11 @@ msgid "" "and the footer." msgstr "" -#: ../../library/logging.rst:811 +#: ../../library/logging.rst:808 msgid "Filter Objects" msgstr "" -#: ../../library/logging.rst:813 +#: ../../library/logging.rst:810 msgid "" "``Filters`` can be used by ``Handlers`` and ``Loggers`` for more " "sophisticated filtering than is provided by levels. The base filter class " @@ -1087,7 +1087,7 @@ msgid "" "If initialized with the empty string, all events are passed." msgstr "" -#: ../../library/logging.rst:823 +#: ../../library/logging.rst:820 msgid "" "Returns an instance of the :class:`Filter` class. If *name* is specified, it " "names a logger which, together with its children, will have its events " @@ -1095,7 +1095,7 @@ msgid "" "event." msgstr "" -#: ../../library/logging.rst:830 +#: ../../library/logging.rst:827 msgid "" "Is the specified record to be logged? Returns false for no, true for yes. " "Filters can either modify log records in-place or return a completely " @@ -1103,7 +1103,7 @@ msgid "" "future processing of the event." msgstr "" -#: ../../library/logging.rst:835 +#: ../../library/logging.rst:832 msgid "" "Note that filters attached to handlers are consulted before an event is " "emitted by the handler, whereas filters attached to loggers are consulted " @@ -1113,13 +1113,13 @@ msgid "" "setting, unless the filter has also been applied to those descendant loggers." msgstr "" -#: ../../library/logging.rst:842 +#: ../../library/logging.rst:839 msgid "" "You don't actually need to subclass ``Filter``: you can pass any instance " "which has a ``filter`` method with the same semantics." msgstr "" -#: ../../library/logging.rst:845 +#: ../../library/logging.rst:842 msgid "" "You don't need to create specialized ``Filter`` classes, or use other " "classes with a ``filter`` method: you can use a function (or other callable) " @@ -1130,7 +1130,7 @@ msgid "" "value should conform to that returned by :meth:`~Filter.filter`." msgstr "" -#: ../../library/logging.rst:855 +#: ../../library/logging.rst:852 msgid "" "You can now return a :class:`LogRecord` instance from filters to replace the " "log record rather than modifying it in place. This allows filters attached " @@ -1138,7 +1138,7 @@ msgid "" "having side effects on other handlers." msgstr "" -#: ../../library/logging.rst:861 +#: ../../library/logging.rst:858 msgid "" "Although filters are used primarily to filter records based on more " "sophisticated criteria than levels, they get to see every record which is " @@ -1150,11 +1150,11 @@ msgid "" "contextual information into logs (see :ref:`filters-contextual`)." msgstr "" -#: ../../library/logging.rst:874 +#: ../../library/logging.rst:871 msgid "LogRecord Objects" msgstr "LogRecord 物件" -#: ../../library/logging.rst:876 +#: ../../library/logging.rst:873 msgid "" ":class:`LogRecord` instances are created automatically by the :class:" "`Logger` every time something is logged, and can be created manually via :" @@ -1162,17 +1162,17 @@ msgid "" "wire)." msgstr "" -#: ../../library/logging.rst:884 +#: ../../library/logging.rst:881 msgid "Contains all the information pertinent to the event being logged." msgstr "" -#: ../../library/logging.rst:886 +#: ../../library/logging.rst:883 msgid "" "The primary information is passed in *msg* and *args*, which are combined " "using ``msg % args`` to create the :attr:`!message` attribute of the record." msgstr "" -#: ../../library/logging.rst:890 +#: ../../library/logging.rst:887 msgid "" "The name of the logger used to log the event represented by this :class:`!" "LogRecord`. Note that the logger name in the :class:`!LogRecord` will always " @@ -1180,7 +1180,7 @@ msgid "" "different (ancestor) logger." msgstr "" -#: ../../library/logging.rst:898 +#: ../../library/logging.rst:895 msgid "" "The :ref:`numeric level ` of the logging event (such as ``10`` for " "``DEBUG``, ``20`` for ``INFO``, etc). Note that this is converted to *two* " @@ -1188,46 +1188,46 @@ msgid "" "attr:`!levelname` for the corresponding level name." msgstr "" -#: ../../library/logging.rst:905 +#: ../../library/logging.rst:902 msgid "" "The full string path of the source file where the logging call was made." msgstr "" -#: ../../library/logging.rst:909 +#: ../../library/logging.rst:906 msgid "The line number in the source file where the logging call was made." msgstr "" -#: ../../library/logging.rst:913 +#: ../../library/logging.rst:910 msgid "" "The event description message, which can be a %-format string with " "placeholders for variable data, or an arbitrary object (see :ref:`arbitrary-" "object-messages`)." msgstr "" -#: ../../library/logging.rst:918 +#: ../../library/logging.rst:915 msgid "" "Variable data to merge into the *msg* argument to obtain the event " "description." msgstr "" -#: ../../library/logging.rst:922 +#: ../../library/logging.rst:919 msgid "" "An exception tuple with the current exception information, as returned by :" "func:`sys.exc_info`, or ``None`` if no exception information is available." msgstr "" -#: ../../library/logging.rst:927 +#: ../../library/logging.rst:924 msgid "" "The name of the function or method from which the logging call was invoked." msgstr "" -#: ../../library/logging.rst:931 +#: ../../library/logging.rst:928 msgid "" "A text string representing stack information from the base of the stack in " "the current thread, up to the logging call." msgstr "" -#: ../../library/logging.rst:938 +#: ../../library/logging.rst:935 msgid "" "Returns the message for this :class:`LogRecord` instance after merging any " "user-supplied arguments with the message. If the user-supplied message " @@ -1236,7 +1236,7 @@ msgid "" "whose ``__str__`` method can return the actual format string to be used." msgstr "" -#: ../../library/logging.rst:945 +#: ../../library/logging.rst:942 msgid "" "The creation of a :class:`LogRecord` has been made more configurable by " "providing a factory which is used to create the record. The factory can be " @@ -1244,13 +1244,13 @@ msgid "" "this for the factory's signature)." msgstr "" -#: ../../library/logging.rst:951 +#: ../../library/logging.rst:948 msgid "" "This functionality can be used to inject your own values into a :class:" "`LogRecord` at creation time. You can use the following pattern::" msgstr "" -#: ../../library/logging.rst:954 +#: ../../library/logging.rst:951 msgid "" "old_factory = logging.getLogRecordFactory()\n" "\n" @@ -1270,18 +1270,18 @@ msgstr "" "\n" "logging.setLogRecordFactory(record_factory)" -#: ../../library/logging.rst:963 +#: ../../library/logging.rst:960 msgid "" "With this pattern, multiple factories could be chained, and as long as they " "don't overwrite each other's attributes or unintentionally overwrite the " "standard attributes listed above, there should be no surprises." msgstr "" -#: ../../library/logging.rst:972 +#: ../../library/logging.rst:969 msgid "LogRecord attributes" msgstr "LogRecord 屬性" -#: ../../library/logging.rst:974 +#: ../../library/logging.rst:971 msgid "" "The LogRecord has a number of attributes, most of which are derived from the " "parameters to the constructor. (Note that the names do not always correspond " @@ -1292,7 +1292,7 @@ msgid "" "style format string." msgstr "" -#: ../../library/logging.rst:982 +#: ../../library/logging.rst:979 msgid "" "If you are using {}-formatting (:func:`str.format`), you can use ``{attrname}" "`` as the placeholder in the format string. If you are using $-formatting (:" @@ -1300,7 +1300,7 @@ msgid "" "course, replace ``attrname`` with the actual attribute name you want to use." msgstr "" -#: ../../library/logging.rst:988 +#: ../../library/logging.rst:985 msgid "" "In the case of {}-formatting, you can specify formatting flags by placing " "them after the attribute name, separated from it with a colon. For example: " @@ -1309,329 +1309,329 @@ msgid "" "on the options available to you." msgstr "" -#: ../../library/logging.rst:995 +#: ../../library/logging.rst:992 msgid "Attribute name" msgstr "屬性名稱" -#: ../../library/logging.rst:995 ../../library/logging.rst:1375 +#: ../../library/logging.rst:992 ../../library/logging.rst:1373 msgid "Format" msgstr "格式" -#: ../../library/logging.rst:995 ../../library/logging.rst:1375 +#: ../../library/logging.rst:992 ../../library/logging.rst:1373 msgid "Description" msgstr "描述" -#: ../../library/logging.rst:0 ../../library/logging.rst:997 +#: ../../library/logging.rst:0 ../../library/logging.rst:994 msgid "args" msgstr "args" -#: ../../library/logging.rst:997 ../../library/logging.rst:1011 -#: ../../library/logging.rst:1014 ../../library/logging.rst:1044 -#: ../../library/logging.rst:1062 +#: ../../library/logging.rst:994 ../../library/logging.rst:1008 +#: ../../library/logging.rst:1011 ../../library/logging.rst:1041 +#: ../../library/logging.rst:1059 msgid "You shouldn't need to format this yourself." msgstr "你不應該需要自己格式化它。" -#: ../../library/logging.rst:997 +#: ../../library/logging.rst:994 msgid "" "The tuple of arguments merged into ``msg`` to produce ``message``, or a dict " "whose values are used for the merge (when there is only one argument, and it " "is a dictionary)." msgstr "" -#: ../../library/logging.rst:1002 +#: ../../library/logging.rst:999 msgid "asctime" msgstr "asctime" -#: ../../library/logging.rst:1002 +#: ../../library/logging.rst:999 msgid "``%(asctime)s``" msgstr "``%(asctime)s``" -#: ../../library/logging.rst:1002 +#: ../../library/logging.rst:999 msgid "" "Human-readable time when the :class:`LogRecord` was created. By default " "this is of the form '2003-07-08 16:49:45,896' (the numbers after the comma " "are millisecond portion of the time)." msgstr "" -#: ../../library/logging.rst:1008 +#: ../../library/logging.rst:1005 msgid "created" msgstr "created" -#: ../../library/logging.rst:1008 +#: ../../library/logging.rst:1005 msgid "``%(created)f``" msgstr "``%(created)f``" -#: ../../library/logging.rst:1008 +#: ../../library/logging.rst:1005 msgid "" "Time when the :class:`LogRecord` was created (as returned by :func:`time." "time_ns` / 1e9)." msgstr "" -#: ../../library/logging.rst:0 ../../library/logging.rst:1011 +#: ../../library/logging.rst:0 ../../library/logging.rst:1008 msgid "exc_info" msgstr "exc_info" -#: ../../library/logging.rst:1011 +#: ../../library/logging.rst:1008 msgid "" "Exception tuple (à la ``sys.exc_info``) or, if no exception has occurred, " "``None``." msgstr "" -#: ../../library/logging.rst:1014 +#: ../../library/logging.rst:1011 msgid "exc_text" msgstr "" -#: ../../library/logging.rst:1014 +#: ../../library/logging.rst:1011 msgid "" "Exception information formatted as a string. This is set when :meth:" "`Formatter.format` is invoked, or ``None`` if no exception has occurred." msgstr "" -#: ../../library/logging.rst:1019 +#: ../../library/logging.rst:1016 msgid "filename" msgstr "filename" -#: ../../library/logging.rst:1019 +#: ../../library/logging.rst:1016 msgid "``%(filename)s``" msgstr "``%(filename)s``" -#: ../../library/logging.rst:1019 +#: ../../library/logging.rst:1016 msgid "Filename portion of ``pathname``." msgstr "``pathname`` 的檔案名稱部分。" -#: ../../library/logging.rst:1021 +#: ../../library/logging.rst:1018 msgid "funcName" msgstr "funcName" -#: ../../library/logging.rst:1021 +#: ../../library/logging.rst:1018 msgid "``%(funcName)s``" msgstr "``%(funcName)s``" -#: ../../library/logging.rst:1021 +#: ../../library/logging.rst:1018 msgid "Name of function containing the logging call." msgstr "" -#: ../../library/logging.rst:1023 +#: ../../library/logging.rst:1020 msgid "levelname" msgstr "levelname" -#: ../../library/logging.rst:1023 +#: ../../library/logging.rst:1020 msgid "``%(levelname)s``" msgstr "``%(levelname)s``" -#: ../../library/logging.rst:1023 +#: ../../library/logging.rst:1020 msgid "" "Text logging level for the message (``'DEBUG'``, ``'INFO'``, ``'WARNING'``, " "``'ERROR'``, ``'CRITICAL'``)." msgstr "" -#: ../../library/logging.rst:1027 +#: ../../library/logging.rst:1024 msgid "levelno" msgstr "levelno" -#: ../../library/logging.rst:1027 +#: ../../library/logging.rst:1024 msgid "``%(levelno)s``" msgstr "``%(levelno)s``" -#: ../../library/logging.rst:1027 +#: ../../library/logging.rst:1024 msgid "" "Numeric logging level for the message (:const:`DEBUG`, :const:`INFO`, :const:" "`WARNING`, :const:`ERROR`, :const:`CRITICAL`)." msgstr "" -#: ../../library/logging.rst:1032 +#: ../../library/logging.rst:1029 msgid "lineno" msgstr "lineno" -#: ../../library/logging.rst:1032 +#: ../../library/logging.rst:1029 msgid "``%(lineno)d``" msgstr "``%(lineno)d``" -#: ../../library/logging.rst:1032 +#: ../../library/logging.rst:1029 msgid "Source line number where the logging call was issued (if available)." msgstr "" -#: ../../library/logging.rst:1035 +#: ../../library/logging.rst:1032 msgid "message" msgstr "message" -#: ../../library/logging.rst:1035 +#: ../../library/logging.rst:1032 msgid "``%(message)s``" msgstr "``%(message)s``" -#: ../../library/logging.rst:1035 +#: ../../library/logging.rst:1032 msgid "" "The logged message, computed as ``msg % args``. This is set when :meth:" "`Formatter.format` is invoked." msgstr "" -#: ../../library/logging.rst:1039 +#: ../../library/logging.rst:1036 msgid "module" msgstr "模組" -#: ../../library/logging.rst:1039 +#: ../../library/logging.rst:1036 msgid "``%(module)s``" msgstr "``%(module)s``" -#: ../../library/logging.rst:1039 +#: ../../library/logging.rst:1036 msgid "Module (name portion of ``filename``)." msgstr "模組(``filename`` 的名稱部分)。" -#: ../../library/logging.rst:1041 +#: ../../library/logging.rst:1038 msgid "msecs" msgstr "msecs" -#: ../../library/logging.rst:1041 +#: ../../library/logging.rst:1038 msgid "``%(msecs)d``" msgstr "``%(msecs)d``" -#: ../../library/logging.rst:1041 +#: ../../library/logging.rst:1038 msgid "" "Millisecond portion of the time when the :class:`LogRecord` was created." msgstr "" -#: ../../library/logging.rst:0 ../../library/logging.rst:1044 +#: ../../library/logging.rst:0 ../../library/logging.rst:1041 msgid "msg" msgstr "msg" -#: ../../library/logging.rst:1044 +#: ../../library/logging.rst:1041 msgid "" "The format string passed in the original logging call. Merged with ``args`` " "to produce ``message``, or an arbitrary object (see :ref:`arbitrary-object-" "messages`)." msgstr "" -#: ../../library/logging.rst:0 ../../library/logging.rst:1049 +#: ../../library/logging.rst:0 ../../library/logging.rst:1046 msgid "name" msgstr "name" -#: ../../library/logging.rst:1049 +#: ../../library/logging.rst:1046 msgid "``%(name)s``" msgstr "``%(name)s``" -#: ../../library/logging.rst:1049 +#: ../../library/logging.rst:1046 msgid "Name of the logger used to log the call." msgstr "" -#: ../../library/logging.rst:1051 +#: ../../library/logging.rst:1048 msgid "pathname" msgstr "pathname" -#: ../../library/logging.rst:1051 +#: ../../library/logging.rst:1048 msgid "``%(pathname)s``" msgstr "``%(pathname)s``" -#: ../../library/logging.rst:1051 +#: ../../library/logging.rst:1048 msgid "" "Full pathname of the source file where the logging call was issued (if " "available)." msgstr "" -#: ../../library/logging.rst:1054 +#: ../../library/logging.rst:1051 msgid "process" msgstr "process" -#: ../../library/logging.rst:1054 +#: ../../library/logging.rst:1051 msgid "``%(process)d``" msgstr "``%(process)d``" -#: ../../library/logging.rst:1054 +#: ../../library/logging.rst:1051 msgid "Process ID (if available)." msgstr "行程 ID(如果可用)。" -#: ../../library/logging.rst:1056 +#: ../../library/logging.rst:1053 msgid "processName" msgstr "processName" -#: ../../library/logging.rst:1056 +#: ../../library/logging.rst:1053 msgid "``%(processName)s``" msgstr "``%(processName)s``" -#: ../../library/logging.rst:1056 +#: ../../library/logging.rst:1053 msgid "Process name (if available)." msgstr "行程名稱(如果可用)。" -#: ../../library/logging.rst:1058 +#: ../../library/logging.rst:1055 msgid "relativeCreated" msgstr "relativeCreated" -#: ../../library/logging.rst:1058 +#: ../../library/logging.rst:1055 msgid "``%(relativeCreated)d``" msgstr "``%(relativeCreated)d``" -#: ../../library/logging.rst:1058 +#: ../../library/logging.rst:1055 msgid "" "Time in milliseconds when the LogRecord was created, relative to the time " "the logging module was loaded." msgstr "" -#: ../../library/logging.rst:1062 +#: ../../library/logging.rst:1059 msgid "stack_info" msgstr "stack_info" -#: ../../library/logging.rst:1062 +#: ../../library/logging.rst:1059 msgid "" "Stack frame information (where available) from the bottom of the stack in " "the current thread, up to and including the stack frame of the logging call " "which resulted in the creation of this record." msgstr "" -#: ../../library/logging.rst:1068 +#: ../../library/logging.rst:1065 msgid "thread" msgstr "thread" -#: ../../library/logging.rst:1068 +#: ../../library/logging.rst:1065 msgid "``%(thread)d``" msgstr "``%(thread)d``" -#: ../../library/logging.rst:1068 +#: ../../library/logging.rst:1065 msgid "Thread ID (if available)." msgstr "執行緒 ID(如果可用)。" -#: ../../library/logging.rst:1070 +#: ../../library/logging.rst:1067 msgid "threadName" msgstr "threadName" -#: ../../library/logging.rst:1070 +#: ../../library/logging.rst:1067 msgid "``%(threadName)s``" msgstr "``%(threadName)s``" -#: ../../library/logging.rst:1070 +#: ../../library/logging.rst:1067 msgid "Thread name (if available)." msgstr "" -#: ../../library/logging.rst:1072 +#: ../../library/logging.rst:1069 msgid "taskName" msgstr "taskName" -#: ../../library/logging.rst:1072 +#: ../../library/logging.rst:1069 msgid "``%(taskName)s``" msgstr "``%(taskName)s``" -#: ../../library/logging.rst:1072 +#: ../../library/logging.rst:1069 msgid ":class:`asyncio.Task` name (if available)." msgstr "" -#: ../../library/logging.rst:1075 +#: ../../library/logging.rst:1072 msgid "*processName* was added." msgstr "新增 *processName*。" -#: ../../library/logging.rst:1078 +#: ../../library/logging.rst:1075 msgid "*taskName* was added." msgstr "新增 *taskName*。" -#: ../../library/logging.rst:1084 +#: ../../library/logging.rst:1081 msgid "LoggerAdapter Objects" msgstr "LoggerAdapter 物件" -#: ../../library/logging.rst:1086 +#: ../../library/logging.rst:1083 msgid "" ":class:`LoggerAdapter` instances are used to conveniently pass contextual " "information into logging calls. For a usage example, see the section on :ref:" "`adding contextual information to your logging output `." msgstr "" -#: ../../library/logging.rst:1092 +#: ../../library/logging.rst:1089 msgid "" "Returns an instance of :class:`LoggerAdapter` initialized with an " "underlying :class:`Logger` instance, an optional dict-like object (*extra*), " @@ -1642,7 +1642,7 @@ msgid "" "`LoggerAdapter` instance" msgstr "" -#: ../../library/logging.rst:1102 +#: ../../library/logging.rst:1099 msgid "" "Modifies the message and/or keyword arguments passed to a logging call in " "order to insert contextual information. This implementation takes the object " @@ -1651,15 +1651,15 @@ msgid "" "(possibly modified) versions of the arguments passed in." msgstr "" -#: ../../library/logging.rst:1110 +#: ../../library/logging.rst:1107 msgid "Delegates to the underlying :attr:`!manager` on *logger*." msgstr "" -#: ../../library/logging.rst:1114 +#: ../../library/logging.rst:1111 msgid "Delegates to the underlying :meth:`!_log` method on *logger*." msgstr "" -#: ../../library/logging.rst:1116 +#: ../../library/logging.rst:1113 msgid "" "In addition to the above, :class:`LoggerAdapter` supports the following " "methods of :class:`Logger`: :meth:`~Logger.debug`, :meth:`~Logger.info`, :" @@ -1671,32 +1671,32 @@ msgid "" "interchangeably." msgstr "" -#: ../../library/logging.rst:1127 +#: ../../library/logging.rst:1124 msgid "" "The :meth:`~Logger.isEnabledFor`, :meth:`~Logger.getEffectiveLevel`, :meth:" "`~Logger.setLevel` and :meth:`~Logger.hasHandlers` methods were added to :" "class:`LoggerAdapter`. These methods delegate to the underlying logger." msgstr "" -#: ../../library/logging.rst:1133 +#: ../../library/logging.rst:1130 msgid "" "Attribute :attr:`!manager` and method :meth:`!_log` were added, which " "delegate to the underlying logger and allow adapters to be nested." msgstr "" -#: ../../library/logging.rst:1138 +#: ../../library/logging.rst:1135 msgid "The *extra* argument is now optional." msgstr "*extra* 引數現在是可選的。" -#: ../../library/logging.rst:1142 +#: ../../library/logging.rst:1139 msgid "The *merge_extra* parameter was added." msgstr "新增 *merge_extra* 參數。" -#: ../../library/logging.rst:1146 +#: ../../library/logging.rst:1143 msgid "Thread Safety" msgstr "執行緒安全" -#: ../../library/logging.rst:1148 +#: ../../library/logging.rst:1145 msgid "" "The logging module is intended to be thread-safe without any special work " "needing to be done by its clients. It achieves this through using threading " @@ -1705,7 +1705,7 @@ msgid "" "O." msgstr "" -#: ../../library/logging.rst:1153 +#: ../../library/logging.rst:1150 msgid "" "If you are implementing asynchronous signal handlers using the :mod:`signal` " "module, you may not be able to use logging from within such handlers. This " @@ -1713,17 +1713,17 @@ msgid "" "always re-entrant, and so cannot be invoked from such signal handlers." msgstr "" -#: ../../library/logging.rst:1160 +#: ../../library/logging.rst:1157 msgid "Module-Level Functions" msgstr "模組層級函式" -#: ../../library/logging.rst:1162 +#: ../../library/logging.rst:1159 msgid "" "In addition to the classes described above, there are a number of module-" "level functions." msgstr "" -#: ../../library/logging.rst:1168 +#: ../../library/logging.rst:1165 msgid "" "Return a logger with the specified name or, if name is ``None``, return the " "root logger of the hierarchy. If specified, the name is typically a dot-" @@ -1733,14 +1733,14 @@ msgid "" "for not doing that, as mentioned in :ref:`logger`." msgstr "" -#: ../../library/logging.rst:1175 +#: ../../library/logging.rst:1172 msgid "" "All calls to this function with a given name return the same logger " "instance. This means that logger instances never need to be passed between " "different parts of an application." msgstr "" -#: ../../library/logging.rst:1182 +#: ../../library/logging.rst:1179 msgid "" "Return either the standard :class:`Logger` class, or the last class passed " "to :func:`setLoggerClass`. This function may be called from within a new " @@ -1749,7 +1749,7 @@ msgid "" "example::" msgstr "" -#: ../../library/logging.rst:1187 +#: ../../library/logging.rst:1184 msgid "" "class MyLogger(logging.getLoggerClass()):\n" " # ... override behaviour here" @@ -1757,37 +1757,37 @@ msgstr "" "class MyLogger(logging.getLoggerClass()):\n" " # ... 在這裡覆蓋其行為" -#: ../../library/logging.rst:1193 +#: ../../library/logging.rst:1190 msgid "Return a callable which is used to create a :class:`LogRecord`." msgstr "" -#: ../../library/logging.rst:1195 +#: ../../library/logging.rst:1192 msgid "" "This function has been provided, along with :func:`setLogRecordFactory`, to " "allow developers more control over how the :class:`LogRecord` representing a " "logging event is constructed." msgstr "" -#: ../../library/logging.rst:1200 +#: ../../library/logging.rst:1197 msgid "" "See :func:`setLogRecordFactory` for more information about the how the " "factory is called." msgstr "" -#: ../../library/logging.rst:1205 +#: ../../library/logging.rst:1202 msgid "" "This is a convenience function that calls :meth:`Logger.debug`, on the root " "logger. The handling of the arguments is in every way identical to what is " "described in that method." msgstr "" -#: ../../library/logging.rst:1209 +#: ../../library/logging.rst:1206 msgid "" "The only difference is that if the root logger has no handlers, then :func:" "`basicConfig` is called, prior to calling ``debug`` on the root logger." msgstr "" -#: ../../library/logging.rst:1212 +#: ../../library/logging.rst:1209 msgid "" "For very short scripts or quick demonstrations of ``logging`` facilities, " "``debug`` and the other module-level functions may be convenient. However, " @@ -1797,38 +1797,38 @@ msgid "" "described at the beginning of this documentation." msgstr "" -#: ../../library/logging.rst:1222 +#: ../../library/logging.rst:1219 msgid "" "Logs a message with level :const:`INFO` on the root logger. The arguments " "and behavior are otherwise the same as for :func:`debug`." msgstr "" -#: ../../library/logging.rst:1228 +#: ../../library/logging.rst:1225 msgid "" "Logs a message with level :const:`WARNING` on the root logger. The arguments " "and behavior are otherwise the same as for :func:`debug`." msgstr "" -#: ../../library/logging.rst:1231 +#: ../../library/logging.rst:1228 msgid "" "There is an obsolete function ``warn`` which is functionally identical to " "``warning``. As ``warn`` is deprecated, please do not use it - use " "``warning`` instead." msgstr "" -#: ../../library/logging.rst:1238 +#: ../../library/logging.rst:1235 msgid "" "Logs a message with level :const:`ERROR` on the root logger. The arguments " "and behavior are otherwise the same as for :func:`debug`." msgstr "" -#: ../../library/logging.rst:1244 +#: ../../library/logging.rst:1241 msgid "" "Logs a message with level :const:`CRITICAL` on the root logger. The " "arguments and behavior are otherwise the same as for :func:`debug`." msgstr "" -#: ../../library/logging.rst:1250 +#: ../../library/logging.rst:1247 msgid "" "Logs a message with level :const:`ERROR` on the root logger. The arguments " "and behavior are otherwise the same as for :func:`debug`. Exception info is " @@ -1836,13 +1836,13 @@ msgid "" "exception handler." msgstr "" -#: ../../library/logging.rst:1256 +#: ../../library/logging.rst:1253 msgid "" "Logs a message with level *level* on the root logger. The arguments and " "behavior are otherwise the same as for :func:`debug`." msgstr "" -#: ../../library/logging.rst:1261 +#: ../../library/logging.rst:1258 msgid "" "Provides an overriding level *level* for all loggers which takes precedence " "over the logger's own level. When the need arises to temporarily throttle " @@ -1856,7 +1856,7 @@ msgid "" "individual loggers." msgstr "" -#: ../../library/logging.rst:1272 +#: ../../library/logging.rst:1269 msgid "" "Note that if you have defined any custom logging level higher than " "``CRITICAL`` (this is not recommended), you won't be able to rely on the " @@ -1864,13 +1864,13 @@ msgid "" "a suitable value." msgstr "" -#: ../../library/logging.rst:1277 +#: ../../library/logging.rst:1274 msgid "" "The *level* parameter was defaulted to level ``CRITICAL``. See :issue:" "`28524` for more information about this change." msgstr "" -#: ../../library/logging.rst:1283 +#: ../../library/logging.rst:1280 msgid "" "Associates level *level* with text *levelName* in an internal dictionary, " "which is used to map numeric levels to a textual representation, for example " @@ -1880,24 +1880,24 @@ msgid "" "and they should increase in increasing order of severity." msgstr "" -#: ../../library/logging.rst:1290 +#: ../../library/logging.rst:1287 msgid "" "If you are thinking of defining your own levels, please see the section on :" "ref:`custom-levels`." msgstr "" -#: ../../library/logging.rst:1295 +#: ../../library/logging.rst:1292 msgid "" "Returns a mapping from level names to their corresponding logging levels. " "For example, the string \"CRITICAL\" maps to :const:`CRITICAL`. The returned " "mapping is copied from an internal mapping on each call to this function." msgstr "" -#: ../../library/logging.rst:1303 +#: ../../library/logging.rst:1300 msgid "Returns the textual or numeric representation of logging level *level*." msgstr "" -#: ../../library/logging.rst:1305 +#: ../../library/logging.rst:1302 msgid "" "If *level* is one of the predefined levels :const:`CRITICAL`, :const:" "`ERROR`, :const:`WARNING`, :const:`INFO` or :const:`DEBUG` then you get the " @@ -1907,20 +1907,20 @@ msgid "" "the corresponding string representation is returned." msgstr "" -#: ../../library/logging.rst:1312 +#: ../../library/logging.rst:1309 msgid "" "The *level* parameter also accepts a string representation of the level such " "as 'INFO'. In such cases, this functions returns the corresponding numeric " "value of the level." msgstr "" -#: ../../library/logging.rst:1316 +#: ../../library/logging.rst:1313 msgid "" "If no matching numeric or string value is passed in, the string 'Level %s' % " "level is returned." msgstr "" -#: ../../library/logging.rst:1319 +#: ../../library/logging.rst:1316 msgid "" "Levels are internally integers (as they need to be compared in the logging " "logic). This function is used to convert between an integer level and the " @@ -1929,25 +1929,26 @@ msgid "" "vice versa." msgstr "" -#: ../../library/logging.rst:1325 +#: ../../library/logging.rst:1322 msgid "" "In Python versions earlier than 3.4, this function could also be passed a " "text level, and would return the corresponding numeric value of the level. " "This undocumented behaviour was considered a mistake, and was removed in " -"Python 3.4, but reinstated in 3.4.2 due to retain backward compatibility." +"Python 3.4, but reinstated in 3.4.2 in order to retain backward " +"compatibility." msgstr "" -#: ../../library/logging.rst:1333 +#: ../../library/logging.rst:1330 msgid "" "Returns a handler with the specified *name*, or ``None`` if there is no " "handler with that name." msgstr "" -#: ../../library/logging.rst:1340 +#: ../../library/logging.rst:1337 msgid "Returns an immutable set of all known handler names." msgstr "" -#: ../../library/logging.rst:1346 +#: ../../library/logging.rst:1343 msgid "" "Creates and returns a new :class:`LogRecord` instance whose attributes are " "defined by *attrdict*. This function is useful for taking a pickled :class:" @@ -1955,22 +1956,23 @@ msgid "" "as a :class:`LogRecord` instance at the receiving end." msgstr "" -#: ../../library/logging.rst:1354 +#: ../../library/logging.rst:1351 msgid "" -"Does basic configuration for the logging system by creating a :class:" -"`StreamHandler` with a default :class:`Formatter` and adding it to the root " -"logger. The functions :func:`debug`, :func:`info`, :func:`warning`, :func:" -"`error` and :func:`critical` will call :func:`basicConfig` automatically if " -"no handlers are defined for the root logger." +"Does basic configuration for the logging system by either creating a :class:" +"`StreamHandler` with a default :class:`Formatter` or using the given " +"*formatter* instance, and adding it to the root logger. The functions :func:" +"`debug`, :func:`info`, :func:`warning`, :func:`error` and :func:`critical` " +"will call :func:`basicConfig` automatically if no handlers are defined for " +"the root logger." msgstr "" -#: ../../library/logging.rst:1360 +#: ../../library/logging.rst:1358 msgid "" "This function does nothing if the root logger already has handlers " "configured, unless the keyword argument *force* is set to ``True``." msgstr "" -#: ../../library/logging.rst:1363 +#: ../../library/logging.rst:1361 msgid "" "This function should be called from the main thread before other threads are " "started. In versions of Python prior to 2.7.1 and 3.2, if this function is " @@ -1979,54 +1981,54 @@ msgid "" "unexpected results such as messages being duplicated in the log." msgstr "" -#: ../../library/logging.rst:1370 +#: ../../library/logging.rst:1368 msgid "The following keyword arguments are supported." msgstr "支援以下的關鍵字引數。" -#: ../../library/logging.rst:1377 +#: ../../library/logging.rst:1375 msgid "*filename*" msgstr "*filename*" -#: ../../library/logging.rst:1377 +#: ../../library/logging.rst:1375 msgid "" "Specifies that a :class:`FileHandler` be created, using the specified " "filename, rather than a :class:`StreamHandler`." msgstr "" -#: ../../library/logging.rst:1381 +#: ../../library/logging.rst:1379 msgid "*filemode*" msgstr "*filemode*" -#: ../../library/logging.rst:1381 +#: ../../library/logging.rst:1379 msgid "" "If *filename* is specified, open the file in this :ref:`mode `. " "Defaults to ``'a'``." msgstr "" -#: ../../library/logging.rst:1385 +#: ../../library/logging.rst:1383 msgid "*format*" msgstr "*format*" -#: ../../library/logging.rst:1385 +#: ../../library/logging.rst:1383 msgid "" "Use the specified format string for the handler. Defaults to attributes " "``levelname``, ``name`` and ``message`` separated by colons." msgstr "" -#: ../../library/logging.rst:1390 +#: ../../library/logging.rst:1388 msgid "*datefmt*" msgstr "*datefmt*" -#: ../../library/logging.rst:1390 +#: ../../library/logging.rst:1388 msgid "" "Use the specified date/time format, as accepted by :func:`time.strftime`." msgstr "" -#: ../../library/logging.rst:1393 +#: ../../library/logging.rst:1391 msgid "*style*" msgstr "*style*" -#: ../../library/logging.rst:1393 +#: ../../library/logging.rst:1391 msgid "" "If *format* is specified, use this style for the format string. One of " "``'%'``, ``'{'`` or ``'$'`` for :ref:`printf-style `." msgstr "" -#: ../../library/logging.rst:1404 +#: ../../library/logging.rst:1402 msgid "*stream*" msgstr "*stream*" -#: ../../library/logging.rst:1404 +#: ../../library/logging.rst:1402 msgid "" "Use the specified stream to initialize the :class:`StreamHandler`. Note that " "this argument is incompatible with *filename* - if both are present, a " "``ValueError`` is raised." msgstr "" -#: ../../library/logging.rst:1410 +#: ../../library/logging.rst:1408 msgid "*handlers*" msgstr "*handlers*" -#: ../../library/logging.rst:1410 +#: ../../library/logging.rst:1408 msgid "" "If specified, this should be an iterable of already created handlers to add " "to the root logger. Any handlers which don't already have a formatter set " @@ -2066,33 +2068,33 @@ msgid "" "present, a ``ValueError`` is raised." msgstr "" -#: ../../library/logging.rst:1419 +#: ../../library/logging.rst:1417 msgid "*force*" msgstr "*force*" -#: ../../library/logging.rst:1419 +#: ../../library/logging.rst:1417 msgid "" "If this keyword argument is specified as true, any existing handlers " "attached to the root logger are removed and closed, before carrying out the " "configuration as specified by the other arguments." msgstr "" -#: ../../library/logging.rst:1425 +#: ../../library/logging.rst:1423 msgid "*encoding*" msgstr "*encoding*" -#: ../../library/logging.rst:1425 +#: ../../library/logging.rst:1423 msgid "" "If this keyword argument is specified along with *filename*, its value is " "used when the :class:`FileHandler` is created, and thus used when opening " "the output file." msgstr "" -#: ../../library/logging.rst:1430 +#: ../../library/logging.rst:1428 msgid "*errors*" msgstr "*errors*" -#: ../../library/logging.rst:1430 +#: ../../library/logging.rst:1428 msgid "" "If this keyword argument is specified along with *filename*, its value is " "used when the :class:`FileHandler` is created, and thus used when opening " @@ -2101,39 +2103,57 @@ msgid "" "`open`, which means that it will be treated the same as passing 'errors'." msgstr "" -#: ../../library/logging.rst:1441 +#: ../../library/logging.rst:1438 +msgid "*formatter*" +msgstr "*formatter*" + +#: ../../library/logging.rst:1438 +msgid "" +"If specified, set this formatter instance (see :ref:`formatter-objects`) for " +"all involved handlers. If not specified, the default is to create and use an " +"instance of :class:`logging.Formatter` based on arguments *format*, " +"*datefmt* and *style*. When *formatter* is specified together with any of " +"the three arguments *format*, *datefmt* and *style*, a ``ValueError`` is " +"raised to signal that these arguments would lose meaning otherwise." +msgstr "" + +#: ../../library/logging.rst:1452 msgid "The *style* argument was added." msgstr "新增 *style* 引數。" -#: ../../library/logging.rst:1444 +#: ../../library/logging.rst:1455 msgid "" "The *handlers* argument was added. Additional checks were added to catch " "situations where incompatible arguments are specified (e.g. *handlers* " "together with *stream* or *filename*, or *stream* together with *filename*)." msgstr "" -#: ../../library/logging.rst:1450 +#: ../../library/logging.rst:1461 msgid "The *force* argument was added." msgstr "新增 *force* 引數。" -#: ../../library/logging.rst:1453 +#: ../../library/logging.rst:1464 msgid "The *encoding* and *errors* arguments were added." msgstr "新增 *encoding* 與 *errors* 引數。" -#: ../../library/logging.rst:1458 +#: ../../library/logging.rst:1467 +msgid "The *formatter* argument was added." +msgstr "新增 *formatter* 引數。" + +#: ../../library/logging.rst:1472 msgid "" "Informs the logging system to perform an orderly shutdown by flushing and " "closing all handlers. This should be called at application exit and no " "further use of the logging system should be made after this call." msgstr "" -#: ../../library/logging.rst:1462 +#: ../../library/logging.rst:1476 msgid "" "When the logging module is imported, it registers this function as an exit " "handler (see :mod:`atexit`), so normally there's no need to do that manually." msgstr "" -#: ../../library/logging.rst:1469 +#: ../../library/logging.rst:1483 msgid "" "Tells the logging system to use the class *klass* when instantiating a " "logger. The class should define :meth:`!__init__` such that only a name " @@ -2145,32 +2165,32 @@ msgid "" "loggers." msgstr "" -#: ../../library/logging.rst:1480 +#: ../../library/logging.rst:1494 msgid "Set a callable which is used to create a :class:`LogRecord`." msgstr "" -#: ../../library/logging.rst:1482 +#: ../../library/logging.rst:1496 msgid "The factory callable to be used to instantiate a log record." msgstr "" -#: ../../library/logging.rst:1484 +#: ../../library/logging.rst:1498 msgid "" "This function has been provided, along with :func:`getLogRecordFactory`, to " "allow developers more control over how the :class:`LogRecord` representing a " "logging event is constructed." msgstr "" -#: ../../library/logging.rst:1489 +#: ../../library/logging.rst:1503 msgid "The factory has the following signature:" msgstr "" -#: ../../library/logging.rst:1491 +#: ../../library/logging.rst:1505 msgid "" "``factory(name, level, fn, lno, msg, args, exc_info, func=None, sinfo=None, " "**kwargs)``" msgstr "" -#: ../../library/logging.rst:1493 +#: ../../library/logging.rst:1507 msgid "The logger name." msgstr "" @@ -2178,7 +2198,7 @@ msgstr "" msgid "level" msgstr "" -#: ../../library/logging.rst:1494 +#: ../../library/logging.rst:1508 msgid "The logging level (numeric)." msgstr "" @@ -2186,7 +2206,7 @@ msgstr "" msgid "fn" msgstr "fn" -#: ../../library/logging.rst:1495 +#: ../../library/logging.rst:1509 msgid "The full pathname of the file where the logging call was made." msgstr "" @@ -2194,19 +2214,19 @@ msgstr "" msgid "lno" msgstr "lno" -#: ../../library/logging.rst:1496 +#: ../../library/logging.rst:1510 msgid "The line number in the file where the logging call was made." msgstr "" -#: ../../library/logging.rst:1497 +#: ../../library/logging.rst:1511 msgid "The logging message." msgstr "" -#: ../../library/logging.rst:1498 +#: ../../library/logging.rst:1512 msgid "The arguments for the logging message." msgstr "" -#: ../../library/logging.rst:1499 +#: ../../library/logging.rst:1513 msgid "An exception tuple, or ``None``." msgstr "" @@ -2214,7 +2234,7 @@ msgstr "" msgid "func" msgstr "func" -#: ../../library/logging.rst:1500 +#: ../../library/logging.rst:1514 msgid "The name of the function or method which invoked the logging call." msgstr "" @@ -2222,7 +2242,7 @@ msgstr "" msgid "sinfo" msgstr "sinfo" -#: ../../library/logging.rst:1502 +#: ../../library/logging.rst:1516 msgid "" "A stack traceback such as is provided by :func:`traceback.print_stack`, " "showing the call hierarchy." @@ -2232,15 +2252,15 @@ msgstr "" msgid "kwargs" msgstr "kwargs" -#: ../../library/logging.rst:1504 +#: ../../library/logging.rst:1518 msgid "Additional keyword arguments." msgstr "額外的關鍵字引數。" -#: ../../library/logging.rst:1508 +#: ../../library/logging.rst:1522 msgid "Module-Level Attributes" msgstr "模組層級屬性" -#: ../../library/logging.rst:1512 +#: ../../library/logging.rst:1526 msgid "" "A \"handler of last resort\" is available through this attribute. This is a :" "class:`StreamHandler` writing to ``sys.stderr`` with a level of ``WARNING``, " @@ -2251,15 +2271,15 @@ msgid "" "reason, ``lastResort`` can be set to ``None``." msgstr "" -#: ../../library/logging.rst:1524 +#: ../../library/logging.rst:1538 msgid "Used to see if exceptions during handling should be propagated." msgstr "" -#: ../../library/logging.rst:1526 +#: ../../library/logging.rst:1540 msgid "Default: ``True``." msgstr "" -#: ../../library/logging.rst:1528 +#: ../../library/logging.rst:1542 msgid "" "If :data:`raiseExceptions` is ``False``, exceptions get silently ignored. " "This is what is mostly wanted for a logging system - most users will not " @@ -2267,22 +2287,22 @@ msgid "" "application errors." msgstr "" -#: ../../library/logging.rst:1535 +#: ../../library/logging.rst:1549 msgid "Integration with the warnings module" msgstr "" -#: ../../library/logging.rst:1537 +#: ../../library/logging.rst:1551 msgid "" "The :func:`captureWarnings` function can be used to integrate :mod:`!" "logging` with the :mod:`warnings` module." msgstr "" -#: ../../library/logging.rst:1542 +#: ../../library/logging.rst:1556 msgid "" "This function is used to turn the capture of warnings by logging on and off." msgstr "" -#: ../../library/logging.rst:1545 +#: ../../library/logging.rst:1559 msgid "" "If *capture* is ``True``, warnings issued by the :mod:`warnings` module will " "be redirected to the logging system. Specifically, a warning will be " @@ -2291,46 +2311,46 @@ msgid "" "`WARNING`." msgstr "" -#: ../../library/logging.rst:1550 +#: ../../library/logging.rst:1564 msgid "" "If *capture* is ``False``, the redirection of warnings to the logging system " "will stop, and warnings will be redirected to their original destinations (i." "e. those in effect before ``captureWarnings(True)`` was called)." msgstr "" -#: ../../library/logging.rst:1557 +#: ../../library/logging.rst:1571 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` 模組" -#: ../../library/logging.rst:1558 +#: ../../library/logging.rst:1572 msgid "Configuration API for the logging module." msgstr "" -#: ../../library/logging.rst:1560 +#: ../../library/logging.rst:1574 msgid "Module :mod:`logging.handlers`" msgstr ":mod:`logging.handlers` 模組" -#: ../../library/logging.rst:1561 +#: ../../library/logging.rst:1575 msgid "Useful handlers included with the logging module." msgstr "" -#: ../../library/logging.rst:1563 +#: ../../library/logging.rst:1577 msgid ":pep:`282` - A Logging System" msgstr "" -#: ../../library/logging.rst:1564 +#: ../../library/logging.rst:1578 msgid "" "The proposal which described this feature for inclusion in the Python " "standard library." msgstr "" -#: ../../library/logging.rst:1567 +#: ../../library/logging.rst:1581 msgid "" "`Original Python logging package `_" msgstr "" -#: ../../library/logging.rst:1568 +#: ../../library/logging.rst:1582 msgid "" "This is the original source for the :mod:`!logging` package. The version of " "the package available from this site is suitable for use with Python 1.5.2, " @@ -2338,11 +2358,11 @@ msgid "" "standard library." msgstr "" -#: ../../library/logging.rst:12 +#: ../../library/logging.rst:9 msgid "Errors" msgstr "Errors(錯誤)" -#: ../../library/logging.rst:12 +#: ../../library/logging.rst:9 msgid "logging" msgstr "logging(日誌)" diff --git a/library/lzma.po b/library/lzma.po index 6cf4df4f9b8..d449b10f980 100644 --- a/library/lzma.po +++ b/library/lzma.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-24 00:27+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!lzma` --- Compression using the LZMA algorithm" msgstr ":mod:`!lzma` --- 使用 LZMA 演算法進行壓縮" -#: ../../library/lzma.rst:12 +#: ../../library/lzma.rst:9 msgid "**Source code:** :source:`Lib/lzma.py`" msgstr "**原始碼:**\\ :source:`Lib/lzma.py`" -#: ../../library/lzma.rst:16 +#: ../../library/lzma.rst:13 msgid "" "This module provides classes and convenience functions for compressing and " "decompressing data using the LZMA compression algorithm. Also included is a " @@ -33,7 +33,7 @@ msgid "" "by the :program:`xz` utility, as well as raw compressed streams." msgstr "" -#: ../../library/lzma.rst:21 +#: ../../library/lzma.rst:18 msgid "" "The interface provided by this module is very similar to that of the :mod:" "`bz2` module. Note that :class:`LZMAFile` and :class:`bz2.BZ2File` are *not* " @@ -49,23 +49,23 @@ msgid "" "module-requirements`." msgstr "" -#: ../../library/lzma.rst:31 +#: ../../library/lzma.rst:28 msgid "" "This exception is raised when an error occurs during compression or " "decompression, or while initializing the compressor/decompressor state." msgstr "" -#: ../../library/lzma.rst:36 +#: ../../library/lzma.rst:33 msgid "Reading and writing compressed files" msgstr "" -#: ../../library/lzma.rst:40 +#: ../../library/lzma.rst:37 msgid "" "Open an LZMA-compressed file in binary or text mode, returning a :term:`file " "object`." msgstr "" -#: ../../library/lzma.rst:43 +#: ../../library/lzma.rst:40 msgid "" "The *filename* argument can be either an actual file name (given as a :class:" "`str`, :class:`bytes` or :term:`path-like ` object), in " @@ -73,7 +73,7 @@ msgid "" "read from or write to." msgstr "" -#: ../../library/lzma.rst:48 +#: ../../library/lzma.rst:45 msgid "" "The *mode* argument can be any of ``\"r\"``, ``\"rb\"``, ``\"w\"``, " "``\"wb\"``, ``\"x\"``, ``\"xb\"``, ``\"a\"`` or ``\"ab\"`` for binary mode, " @@ -81,46 +81,46 @@ msgid "" "default is ``\"rb\"``." msgstr "" -#: ../../library/lzma.rst:52 ../../library/lzma.rst:97 +#: ../../library/lzma.rst:49 ../../library/lzma.rst:94 msgid "" "When opening a file for reading, the *format* and *filters* arguments have " "the same meanings as for :class:`LZMADecompressor`. In this case, the " "*check* and *preset* arguments should not be used." msgstr "" -#: ../../library/lzma.rst:56 ../../library/lzma.rst:101 +#: ../../library/lzma.rst:53 ../../library/lzma.rst:98 msgid "" "When opening a file for writing, the *format*, *check*, *preset* and " "*filters* arguments have the same meanings as for :class:`LZMACompressor`." msgstr "" -#: ../../library/lzma.rst:59 +#: ../../library/lzma.rst:56 msgid "" "For binary mode, this function is equivalent to the :class:`LZMAFile` " "constructor: ``LZMAFile(filename, mode, ...)``. In this case, the " "*encoding*, *errors* and *newline* arguments must not be provided." msgstr "" -#: ../../library/lzma.rst:63 +#: ../../library/lzma.rst:60 msgid "" "For text mode, a :class:`LZMAFile` object is created, and wrapped in an :" "class:`io.TextIOWrapper` instance with the specified encoding, error " "handling behavior, and line ending(s)." msgstr "" -#: ../../library/lzma.rst:67 +#: ../../library/lzma.rst:64 msgid "Added support for the ``\"x\"``, ``\"xb\"`` and ``\"xt\"`` modes." msgstr "新增 ``\"x\"``、``\"xb\"`` 和 ``\"xt\"`` 模式的支援。" -#: ../../library/lzma.rst:70 ../../library/lzma.rst:143 +#: ../../library/lzma.rst:67 ../../library/lzma.rst:140 msgid "Accepts a :term:`path-like object`." msgstr "" -#: ../../library/lzma.rst:76 +#: ../../library/lzma.rst:73 msgid "Open an LZMA-compressed file in binary mode." msgstr "" -#: ../../library/lzma.rst:78 +#: ../../library/lzma.rst:75 msgid "" "An :class:`LZMAFile` can wrap an already-open :term:`file object`, or " "operate directly on a named file. The *filename* argument specifies either " @@ -130,7 +130,7 @@ msgid "" "the :class:`LZMAFile` is closed." msgstr "" -#: ../../library/lzma.rst:85 +#: ../../library/lzma.rst:82 msgid "" "The *mode* argument can be either ``\"r\"`` for reading (default), ``\"w\"`` " "for overwriting, ``\"x\"`` for exclusive creation, or ``\"a\"`` for " @@ -138,38 +138,38 @@ msgid "" "``\"xb\"`` and ``\"ab\"`` respectively." msgstr "" -#: ../../library/lzma.rst:90 +#: ../../library/lzma.rst:87 msgid "" "If *filename* is a file object (rather than an actual file name), a mode of " "``\"w\"`` does not truncate the file, and is instead equivalent to ``\"a\"``." msgstr "" -#: ../../library/lzma.rst:93 +#: ../../library/lzma.rst:90 msgid "" "When opening a file for reading, the input file may be the concatenation of " "multiple separate compressed streams. These are transparently decoded as a " "single logical stream." msgstr "" -#: ../../library/lzma.rst:104 +#: ../../library/lzma.rst:101 msgid "" ":class:`LZMAFile` supports all the members specified by :class:`io." "BufferedIOBase`, except for :meth:`~io.BufferedIOBase.detach` and :meth:`~io." "IOBase.truncate`. Iteration and the :keyword:`with` statement are supported." msgstr "" -#: ../../library/lzma.rst:109 +#: ../../library/lzma.rst:106 msgid "The following method and attributes are also provided:" msgstr "" -#: ../../library/lzma.rst:113 +#: ../../library/lzma.rst:110 msgid "" "Return buffered data without advancing the file position. At least one byte " "of data will be returned, unless EOF has been reached. The exact number of " "bytes returned is unspecified (the *size* argument is ignored)." msgstr "" -#: ../../library/lzma.rst:117 +#: ../../library/lzma.rst:114 msgid "" "While calling :meth:`peek` does not change the file position of the :class:" "`LZMAFile`, it may change the position of the underlying file object (e.g. " @@ -177,49 +177,49 @@ msgid "" "*filename*)." msgstr "" -#: ../../library/lzma.rst:124 +#: ../../library/lzma.rst:121 msgid "``'rb'`` for reading and ``'wb'`` for writing." msgstr "" -#: ../../library/lzma.rst:130 +#: ../../library/lzma.rst:127 msgid "" "The lzma file name. Equivalent to the :attr:`~io.FileIO.name` attribute of " "the underlying :term:`file object`." msgstr "" -#: ../../library/lzma.rst:136 +#: ../../library/lzma.rst:133 msgid "Added support for the ``\"x\"`` and ``\"xb\"`` modes." msgstr "新增 ``\"x\"`` 和 ``\"xb\"`` 模式的支援。" -#: ../../library/lzma.rst:139 +#: ../../library/lzma.rst:136 msgid "" "The :meth:`~io.BufferedIOBase.read` method now accepts an argument of " "``None``." msgstr "" -#: ../../library/lzma.rst:148 +#: ../../library/lzma.rst:145 msgid "Compressing and decompressing data in memory" msgstr "" -#: ../../library/lzma.rst:152 +#: ../../library/lzma.rst:149 msgid "" "Create a compressor object, which can be used to compress data incrementally." msgstr "" -#: ../../library/lzma.rst:154 +#: ../../library/lzma.rst:151 msgid "" "For a more convenient way of compressing a single chunk of data, see :func:" "`compress`." msgstr "" -#: ../../library/lzma.rst:157 +#: ../../library/lzma.rst:154 msgid "" "The *format* argument specifies what container format should be used. " "Possible values are :const:`FORMAT_XZ` (the default), :const:`FORMAT_ALONE` " "and :const:`FORMAT_RAW`." msgstr "" -#: ../../library/lzma.rst:161 +#: ../../library/lzma.rst:158 msgid "" "The *check* argument specifies the type of integrity check to include in the " "compressed data. This check is used when decompressing, to ensure that the " @@ -228,19 +228,19 @@ msgid "" "and :const:`CHECK_SHA256`." msgstr "" -#: ../../library/lzma.rst:167 +#: ../../library/lzma.rst:164 msgid "" "If the specified check is not supported, an :class:`LZMAError` is raised." msgstr "" -#: ../../library/lzma.rst:169 +#: ../../library/lzma.rst:166 msgid "" "The compression settings can be specified either as a preset compression " "level (with the *preset* argument), or in detail as a custom filter chain " "(with the *filters* argument)." msgstr "" -#: ../../library/lzma.rst:173 +#: ../../library/lzma.rst:170 msgid "" "The *preset* argument (if provided) should be an integer between ``0`` and " "``9`` (inclusive), optionally OR-ed with the constant :const:" @@ -249,7 +249,7 @@ msgid "" "presets produce smaller output, but make the compression process slower." msgstr "" -#: ../../library/lzma.rst:182 +#: ../../library/lzma.rst:179 msgid "" "In addition to being more CPU-intensive, compression with higher presets " "also requires much more memory (and produces output that needs more memory " @@ -258,13 +258,13 @@ msgid "" "generally best to stick with the default preset." msgstr "" -#: ../../library/lzma.rst:188 +#: ../../library/lzma.rst:185 msgid "" "The *filters* argument (if provided) should be a filter chain specifier. " "See :ref:`filter-chain-specs` for details." msgstr "" -#: ../../library/lzma.rst:193 +#: ../../library/lzma.rst:190 msgid "" "Compress *data* (a :class:`bytes` object), returning a :class:`bytes` object " "containing compressed data for at least part of the input. Some of *data* " @@ -273,29 +273,29 @@ msgid "" "any previous calls to :meth:`compress`." msgstr "" -#: ../../library/lzma.rst:201 +#: ../../library/lzma.rst:198 msgid "" "Finish the compression process, returning a :class:`bytes` object containing " "any data stored in the compressor's internal buffers." msgstr "" -#: ../../library/lzma.rst:204 +#: ../../library/lzma.rst:201 msgid "The compressor cannot be used after this method has been called." msgstr "" -#: ../../library/lzma.rst:209 +#: ../../library/lzma.rst:206 msgid "" "Create a decompressor object, which can be used to decompress data " "incrementally." msgstr "" -#: ../../library/lzma.rst:212 +#: ../../library/lzma.rst:209 msgid "" "For a more convenient way of decompressing an entire compressed stream at " "once, see :func:`decompress`." msgstr "" -#: ../../library/lzma.rst:215 +#: ../../library/lzma.rst:212 msgid "" "The *format* argument specifies the container format that should be used. " "The default is :const:`FORMAT_AUTO`, which can decompress both ``.xz`` and " @@ -303,7 +303,7 @@ msgid "" "`FORMAT_ALONE`, and :const:`FORMAT_RAW`." msgstr "" -#: ../../library/lzma.rst:220 +#: ../../library/lzma.rst:217 msgid "" "The *memlimit* argument specifies a limit (in bytes) on the amount of memory " "that the decompressor can use. When this argument is used, decompression " @@ -311,7 +311,7 @@ msgid "" "input within the given memory limit." msgstr "" -#: ../../library/lzma.rst:225 +#: ../../library/lzma.rst:222 msgid "" "The *filters* argument specifies the filter chain that was used to create " "the stream being decompressed. This argument is required if *format* is :" @@ -319,7 +319,7 @@ msgid "" "`filter-chain-specs` for more information about filter chains." msgstr "" -#: ../../library/lzma.rst:231 +#: ../../library/lzma.rst:228 msgid "" "This class does not transparently handle inputs containing multiple " "compressed streams, unlike :func:`decompress` and :class:`LZMAFile`. To " @@ -327,7 +327,7 @@ msgid "" "create a new decompressor for each stream." msgstr "" -#: ../../library/lzma.rst:238 +#: ../../library/lzma.rst:235 msgid "" "Decompress *data* (a :term:`bytes-like object`), returning uncompressed data " "as bytes. Some of *data* may be buffered internally, for use in later calls " @@ -335,7 +335,7 @@ msgid "" "output of any previous calls to :meth:`decompress`." msgstr "" -#: ../../library/lzma.rst:244 +#: ../../library/lzma.rst:241 msgid "" "If *max_length* is nonnegative, returns at most *max_length* bytes of " "decompressed data. If this limit is reached and further output can be " @@ -344,100 +344,100 @@ msgid "" "``b''`` to obtain more of the output." msgstr "" -#: ../../library/lzma.rst:251 +#: ../../library/lzma.rst:248 msgid "" "If all of the input data was decompressed and returned (either because this " "was less than *max_length* bytes, or because *max_length* was negative), " "the :attr:`~.needs_input` attribute will be set to ``True``." msgstr "" -#: ../../library/lzma.rst:256 +#: ../../library/lzma.rst:253 msgid "" "Attempting to decompress data after the end of stream is reached raises an :" "exc:`EOFError`. Any data found after the end of the stream is ignored and " "saved in the :attr:`~.unused_data` attribute." msgstr "" -#: ../../library/lzma.rst:260 +#: ../../library/lzma.rst:257 msgid "Added the *max_length* parameter." msgstr "新增 *max_length* 參數。" -#: ../../library/lzma.rst:265 +#: ../../library/lzma.rst:262 msgid "" "The ID of the integrity check used by the input stream. This may be :const:" "`CHECK_UNKNOWN` until enough of the input has been decoded to determine what " "integrity check it uses." msgstr "" -#: ../../library/lzma.rst:271 +#: ../../library/lzma.rst:268 msgid "``True`` if the end-of-stream marker has been reached." msgstr "" -#: ../../library/lzma.rst:275 +#: ../../library/lzma.rst:272 msgid "Data found after the end of the compressed stream." msgstr "" -#: ../../library/lzma.rst:277 +#: ../../library/lzma.rst:274 msgid "Before the end of the stream is reached, this will be ``b\"\"``." msgstr "" -#: ../../library/lzma.rst:281 +#: ../../library/lzma.rst:278 msgid "" "``False`` if the :meth:`.decompress` method can provide more decompressed " "data before requiring new uncompressed input." msgstr "" -#: ../../library/lzma.rst:288 +#: ../../library/lzma.rst:285 msgid "" "Compress *data* (a :class:`bytes` object), returning the compressed data as " "a :class:`bytes` object." msgstr "" -#: ../../library/lzma.rst:291 +#: ../../library/lzma.rst:288 msgid "" "See :class:`LZMACompressor` above for a description of the *format*, " "*check*, *preset* and *filters* arguments." msgstr "" -#: ../../library/lzma.rst:297 +#: ../../library/lzma.rst:294 msgid "" "Decompress *data* (a :class:`bytes` object), returning the uncompressed data " "as a :class:`bytes` object." msgstr "" -#: ../../library/lzma.rst:300 +#: ../../library/lzma.rst:297 msgid "" "If *data* is the concatenation of multiple distinct compressed streams, " "decompress all of these streams, and return the concatenation of the results." msgstr "" -#: ../../library/lzma.rst:303 +#: ../../library/lzma.rst:300 msgid "" "See :class:`LZMADecompressor` above for a description of the *format*, " "*memlimit* and *filters* arguments." msgstr "" -#: ../../library/lzma.rst:308 +#: ../../library/lzma.rst:305 msgid "Miscellaneous" msgstr "" -#: ../../library/lzma.rst:312 +#: ../../library/lzma.rst:309 msgid "" "Return ``True`` if the given integrity check is supported on this system." msgstr "" -#: ../../library/lzma.rst:314 +#: ../../library/lzma.rst:311 msgid "" ":const:`CHECK_NONE` and :const:`CHECK_CRC32` are always supported. :const:" "`CHECK_CRC64` and :const:`CHECK_SHA256` may be unavailable if you are using " "a version of :program:`liblzma` that was compiled with a limited feature set." msgstr "" -#: ../../library/lzma.rst:323 +#: ../../library/lzma.rst:320 msgid "Specifying custom filter chains" msgstr "" -#: ../../library/lzma.rst:325 +#: ../../library/lzma.rst:322 msgid "" "A filter chain specifier is a sequence of dictionaries, where each " "dictionary contains the ID and options for a single filter. Each dictionary " @@ -445,118 +445,118 @@ msgid "" "filter-dependent options. Valid filter IDs are as follows:" msgstr "" -#: ../../library/lzma.rst:330 +#: ../../library/lzma.rst:327 msgid "Compression filters:" msgstr "" -#: ../../library/lzma.rst:332 +#: ../../library/lzma.rst:329 msgid ":const:`FILTER_LZMA1` (for use with :const:`FORMAT_ALONE`)" msgstr "" -#: ../../library/lzma.rst:333 +#: ../../library/lzma.rst:330 msgid "" ":const:`FILTER_LZMA2` (for use with :const:`FORMAT_XZ` and :const:" "`FORMAT_RAW`)" msgstr "" -#: ../../library/lzma.rst:335 +#: ../../library/lzma.rst:332 msgid "Delta filter:" msgstr "" -#: ../../library/lzma.rst:337 +#: ../../library/lzma.rst:334 msgid ":const:`FILTER_DELTA`" msgstr ":const:`FILTER_DELTA`" -#: ../../library/lzma.rst:339 +#: ../../library/lzma.rst:336 msgid "Branch-Call-Jump (BCJ) filters:" msgstr "" -#: ../../library/lzma.rst:341 +#: ../../library/lzma.rst:338 msgid ":const:`!FILTER_X86`" msgstr ":const:`!FILTER_X86`" -#: ../../library/lzma.rst:342 +#: ../../library/lzma.rst:339 msgid ":const:`!FILTER_IA64`" msgstr ":const:`!FILTER_IA64`" -#: ../../library/lzma.rst:343 +#: ../../library/lzma.rst:340 msgid ":const:`!FILTER_ARM`" msgstr ":const:`!FILTER_ARM`" -#: ../../library/lzma.rst:344 +#: ../../library/lzma.rst:341 msgid ":const:`!FILTER_ARMTHUMB`" msgstr ":const:`!FILTER_ARMTHUMB`" -#: ../../library/lzma.rst:345 +#: ../../library/lzma.rst:342 msgid ":const:`!FILTER_POWERPC`" msgstr ":const:`!FILTER_POWERPC`" -#: ../../library/lzma.rst:346 +#: ../../library/lzma.rst:343 msgid ":const:`!FILTER_SPARC`" msgstr ":const:`!FILTER_SPARC`" -#: ../../library/lzma.rst:348 +#: ../../library/lzma.rst:345 msgid "" "A filter chain can consist of up to 4 filters, and cannot be empty. The last " "filter in the chain must be a compression filter, and any other filters must " "be delta or BCJ filters." msgstr "" -#: ../../library/lzma.rst:352 +#: ../../library/lzma.rst:349 msgid "" "Compression filters support the following options (specified as additional " "entries in the dictionary representing the filter):" msgstr "" -#: ../../library/lzma.rst:355 +#: ../../library/lzma.rst:352 msgid "" "``preset``: A compression preset to use as a source of default values for " "options that are not specified explicitly." msgstr "" -#: ../../library/lzma.rst:357 +#: ../../library/lzma.rst:354 msgid "" "``dict_size``: Dictionary size in bytes. This should be between 4 KiB and " "1.5 GiB (inclusive)." msgstr "" -#: ../../library/lzma.rst:359 +#: ../../library/lzma.rst:356 msgid "``lc``: Number of literal context bits." msgstr "" -#: ../../library/lzma.rst:360 +#: ../../library/lzma.rst:357 msgid "" "``lp``: Number of literal position bits. The sum ``lc + lp`` must be at most " "4." msgstr "" -#: ../../library/lzma.rst:362 +#: ../../library/lzma.rst:359 msgid "``pb``: Number of position bits; must be at most 4." msgstr "" -#: ../../library/lzma.rst:363 +#: ../../library/lzma.rst:360 msgid "``mode``: :const:`MODE_FAST` or :const:`MODE_NORMAL`." msgstr "" -#: ../../library/lzma.rst:364 +#: ../../library/lzma.rst:361 msgid "" "``nice_len``: What should be considered a \"nice length\" for a match. This " "should be 273 or less." msgstr "" -#: ../../library/lzma.rst:366 +#: ../../library/lzma.rst:363 msgid "" "``mf``: What match finder to use -- :const:`MF_HC3`, :const:`MF_HC4`, :const:" "`MF_BT2`, :const:`MF_BT3`, or :const:`MF_BT4`." msgstr "" -#: ../../library/lzma.rst:368 +#: ../../library/lzma.rst:365 msgid "" "``depth``: Maximum search depth used by match finder. 0 (default) means to " "select automatically based on other filter options." msgstr "" -#: ../../library/lzma.rst:371 +#: ../../library/lzma.rst:368 msgid "" "The delta filter stores the differences between bytes, producing more " "repetitive input for the compressor in certain circumstances. It supports " @@ -565,7 +565,7 @@ msgid "" "bytes." msgstr "" -#: ../../library/lzma.rst:376 +#: ../../library/lzma.rst:373 msgid "" "The BCJ filters are intended to be applied to machine code. They convert " "relative branches, calls and jumps in the code to use absolute addressing, " @@ -575,31 +575,31 @@ msgid "" "data. The default is 0." msgstr "" -#: ../../library/lzma.rst:384 +#: ../../library/lzma.rst:381 msgid "Constants" msgstr "" -#: ../../library/lzma.rst:386 +#: ../../library/lzma.rst:383 msgid "" "The following module-level constants are provided for use as the *format*, " "*check*, *preset* and *filters* arguments of the classes and functions above." msgstr "" -#: ../../library/lzma.rst:389 +#: ../../library/lzma.rst:386 msgid "Container formats:" msgstr "" -#: ../../library/lzma.rst:393 +#: ../../library/lzma.rst:390 msgid "The ``.xz`` container format." msgstr "" -#: ../../library/lzma.rst:397 +#: ../../library/lzma.rst:394 msgid "" "The legacy ``.lzma`` container format. This format is more limited than ``." "xz`` -- it does not support integrity checks or multiple filters." msgstr "" -#: ../../library/lzma.rst:402 +#: ../../library/lzma.rst:399 msgid "" "A raw data stream, not using any container format. This format specifier " "does not support integrity checks, and requires that you always specify a " @@ -608,97 +608,97 @@ msgid "" "`FORMAT_AUTO`." msgstr "" -#: ../../library/lzma.rst:410 +#: ../../library/lzma.rst:407 msgid "" "Used for decompression only. The container format is detected " "automatically, so that both ``.xz`` and ``.lzma`` files can be decompressed." msgstr "" -#: ../../library/lzma.rst:413 +#: ../../library/lzma.rst:410 msgid "Integrity checks:" msgstr "" -#: ../../library/lzma.rst:417 +#: ../../library/lzma.rst:414 msgid "" "No integrity check. This is the default (and the only acceptable value) " "for :const:`FORMAT_ALONE` and :const:`FORMAT_RAW`." msgstr "" -#: ../../library/lzma.rst:422 +#: ../../library/lzma.rst:419 msgid "A 32-bit Cyclic Redundancy Check." msgstr "" -#: ../../library/lzma.rst:426 +#: ../../library/lzma.rst:423 msgid "" "A 64-bit Cyclic Redundancy Check. This is the default for :const:" "`FORMAT_XZ`." msgstr "" -#: ../../library/lzma.rst:431 +#: ../../library/lzma.rst:428 msgid "A 256-bit Secure Hash Algorithm." msgstr "" -#: ../../library/lzma.rst:435 +#: ../../library/lzma.rst:432 msgid "" "The integrity check used by a stream could not yet be determined. This may " "be the value of the :attr:`LZMADecompressor.check` attribute until enough of " "the input has been decoded." msgstr "" -#: ../../library/lzma.rst:441 +#: ../../library/lzma.rst:438 msgid "The largest supported integrity-check ID." msgstr "" -#: ../../library/lzma.rst:443 +#: ../../library/lzma.rst:440 msgid "Compression presets:" msgstr "" -#: ../../library/lzma.rst:447 +#: ../../library/lzma.rst:444 msgid "The default compression preset, equivalent to preset level ``6``." msgstr "" -#: ../../library/lzma.rst:451 +#: ../../library/lzma.rst:448 msgid "" "A flag that may be bitwise OR-ed with a preset level (``0`` to ``9``) to " "select a slower but more thorough variant of that preset." msgstr "" -#: ../../library/lzma.rst:454 +#: ../../library/lzma.rst:451 msgid "Filter IDs and options:" msgstr "" -#: ../../library/lzma.rst:459 +#: ../../library/lzma.rst:456 msgid "" "The LZMA1 and LZMA2 compression filters. :const:`FILTER_LZMA1` is for use " "with :const:`FORMAT_ALONE`, while :const:`FILTER_LZMA2` is for use with :" "const:`FORMAT_XZ` and :const:`FORMAT_RAW`." msgstr "" -#: ../../library/lzma.rst:465 +#: ../../library/lzma.rst:462 msgid "The delta filter." msgstr "" -#: ../../library/lzma.rst:470 +#: ../../library/lzma.rst:467 msgid "" "Compression modes that may be used as the ``mode`` option of a filter " "specifier (see :ref:`filter-chain-specs`)." msgstr "" -#: ../../library/lzma.rst:479 +#: ../../library/lzma.rst:476 msgid "" "Match finders that may be used as the ``mf`` option of a filter specifier " "(see :ref:`filter-chain-specs`)." msgstr "" -#: ../../library/lzma.rst:484 +#: ../../library/lzma.rst:481 msgid "Examples" msgstr "範例" -#: ../../library/lzma.rst:486 +#: ../../library/lzma.rst:483 msgid "Reading in a compressed file::" msgstr "" -#: ../../library/lzma.rst:488 +#: ../../library/lzma.rst:485 msgid "" "import lzma\n" "with lzma.open(\"file.xz\") as f:\n" @@ -708,11 +708,11 @@ msgstr "" "with lzma.open(\"file.xz\") as f:\n" " file_content = f.read()" -#: ../../library/lzma.rst:492 +#: ../../library/lzma.rst:489 msgid "Creating a compressed file::" msgstr "" -#: ../../library/lzma.rst:494 +#: ../../library/lzma.rst:491 msgid "" "import lzma\n" "data = b\"Insert Data Here\"\n" @@ -724,11 +724,11 @@ msgstr "" "with lzma.open(\"file.xz\", \"w\") as f:\n" " f.write(data)" -#: ../../library/lzma.rst:499 +#: ../../library/lzma.rst:496 msgid "Compressing data in memory::" msgstr "" -#: ../../library/lzma.rst:501 +#: ../../library/lzma.rst:498 msgid "" "import lzma\n" "data_in = b\"Insert Data Here\"\n" @@ -738,11 +738,11 @@ msgstr "" "data_in = b\"Insert Data Here\"\n" "data_out = lzma.compress(data_in)" -#: ../../library/lzma.rst:505 +#: ../../library/lzma.rst:502 msgid "Incremental compression::" msgstr "" -#: ../../library/lzma.rst:507 +#: ../../library/lzma.rst:504 msgid "" "import lzma\n" "lzc = lzma.LZMACompressor()\n" @@ -754,11 +754,11 @@ msgid "" "result = b\"\".join([out1, out2, out3, out4])" msgstr "" -#: ../../library/lzma.rst:516 +#: ../../library/lzma.rst:513 msgid "Writing compressed data to an already-open file::" msgstr "" -#: ../../library/lzma.rst:518 +#: ../../library/lzma.rst:515 msgid "" "import lzma\n" "with open(\"file.xz\", \"wb\") as f:\n" @@ -774,11 +774,11 @@ msgstr "" " lzf.write(b\"This *will* be compressed\\n\")\n" " f.write(b\"Not compressed\\n\")" -#: ../../library/lzma.rst:525 +#: ../../library/lzma.rst:522 msgid "Creating a compressed file using a custom filter chain::" msgstr "" -#: ../../library/lzma.rst:527 +#: ../../library/lzma.rst:524 msgid "" "import lzma\n" "my_filters = [\n" diff --git a/library/mailbox.po b/library/mailbox.po index 20ddc3e60fe..b8fedd6ee04 100644 --- a/library/mailbox.po +++ b/library/mailbox.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-18 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!mailbox` --- Manipulate mailboxes in various formats" msgstr ":mod:`!mailbox` --- 以各種格式操作郵件信箱" -#: ../../library/mailbox.rst:10 +#: ../../library/mailbox.rst:7 msgid "**Source code:** :source:`Lib/mailbox.py`" msgstr "**原始碼:**\\ :source:`Lib/mailbox.py`" -#: ../../library/mailbox.rst:14 +#: ../../library/mailbox.rst:11 msgid "" "This module defines two classes, :class:`Mailbox` and :class:`Message`, for " "accessing and manipulating on-disk mailboxes and the messages they contain. :" @@ -35,30 +35,30 @@ msgid "" "mailbox formats are Maildir, mbox, MH, Babyl, and MMDF." msgstr "" -#: ../../library/mailbox.rst:24 +#: ../../library/mailbox.rst:21 msgid "Module :mod:`email`" msgstr ":mod:`email` 模組" -#: ../../library/mailbox.rst:25 +#: ../../library/mailbox.rst:22 msgid "Represent and manipulate messages." msgstr "" -#: ../../library/mailbox.rst:31 +#: ../../library/mailbox.rst:28 msgid ":class:`!Mailbox` objects" msgstr ":class:`!Mailbox` 物件" -#: ../../library/mailbox.rst:35 +#: ../../library/mailbox.rst:32 msgid "A mailbox, which may be inspected and modified." msgstr "" -#: ../../library/mailbox.rst:37 +#: ../../library/mailbox.rst:34 msgid "" "The :class:`!Mailbox` class defines an interface and is not intended to be " "instantiated. Instead, format-specific subclasses should inherit from :" "class:`!Mailbox` and your code should instantiate a particular subclass." msgstr "" -#: ../../library/mailbox.rst:41 +#: ../../library/mailbox.rst:38 msgid "" "The :class:`!Mailbox` interface is dictionary-like, with small keys " "corresponding to messages. Keys are issued by the :class:`!Mailbox` instance " @@ -68,14 +68,14 @@ msgid "" "message." msgstr "" -#: ../../library/mailbox.rst:47 +#: ../../library/mailbox.rst:44 msgid "" "Messages may be added to a :class:`!Mailbox` instance using the set-like " "method :meth:`add` and removed using a ``del`` statement or the set-like " "methods :meth:`remove` and :meth:`discard`." msgstr "" -#: ../../library/mailbox.rst:51 +#: ../../library/mailbox.rst:48 msgid "" ":class:`!Mailbox` interface semantics differ from dictionary semantics in " "some noteworthy ways. Each time a message is requested, a new representation " @@ -86,7 +86,7 @@ msgid "" "the :class:`!Mailbox` instance." msgstr "" -#: ../../library/mailbox.rst:59 +#: ../../library/mailbox.rst:56 msgid "" "The default :class:`!Mailbox` :term:`iterator` iterates over message " "representations, not keys as the default :class:`dictionary ` iterator " @@ -98,7 +98,7 @@ msgid "" "message is subsequently removed." msgstr "" -#: ../../library/mailbox.rst:71 +#: ../../library/mailbox.rst:68 msgid "" "Be very cautious when modifying mailboxes that might be simultaneously " "changed by some other process. The safest mailbox format to use for such " @@ -110,16 +110,28 @@ msgid "" "messages or corrupting the entire mailbox." msgstr "" -#: ../../library/mailbox.rst:81 -msgid ":class:`!Mailbox` instances have the following methods:" +#: ../../library/mailbox.rst:78 +msgid "" +"The :class:`!Mailbox` class supports the :keyword:`with` statement. When " +"used as a context manager, :class:`!Mailbox` calls :meth:`lock` when the " +"context is entered, returns the mailbox object as the context object, and at " +"context end calls :meth:`close`, thereby releasing the lock." +msgstr "" + +#: ../../library/mailbox.rst:83 +msgid "Support for the :keyword:`with` statement was added." msgstr "" #: ../../library/mailbox.rst:86 +msgid ":class:`!Mailbox` instances have the following methods:" +msgstr "" + +#: ../../library/mailbox.rst:91 msgid "" "Add *message* to the mailbox and return the key that has been assigned to it." msgstr "" -#: ../../library/mailbox.rst:89 +#: ../../library/mailbox.rst:94 msgid "" "Parameter *message* may be a :class:`Message` instance, an :class:`email." "message.Message` instance, a string, a byte string, or a file-like object " @@ -130,15 +142,15 @@ msgid "" "format-specific information are used." msgstr "" -#: ../../library/mailbox.rst:98 +#: ../../library/mailbox.rst:103 msgid "Support for binary input was added." msgstr "" -#: ../../library/mailbox.rst:106 +#: ../../library/mailbox.rst:111 msgid "Delete the message corresponding to *key* from the mailbox." msgstr "" -#: ../../library/mailbox.rst:108 +#: ../../library/mailbox.rst:113 msgid "" "If no such message exists, a :exc:`KeyError` exception is raised if the " "method was called as :meth:`remove` or :meth:`__delitem__` but no exception " @@ -147,13 +159,13 @@ msgid "" "concurrent modification by other processes." msgstr "" -#: ../../library/mailbox.rst:117 +#: ../../library/mailbox.rst:122 msgid "" "Replace the message corresponding to *key* with *message*. Raise a :exc:" "`KeyError` exception if no message already corresponds to *key*." msgstr "" -#: ../../library/mailbox.rst:120 +#: ../../library/mailbox.rst:125 msgid "" "As with :meth:`add`, parameter *message* may be a :class:`Message` instance, " "an :class:`email.message.Message` instance, a string, a byte string, or a " @@ -165,17 +177,17 @@ msgid "" "left unchanged." msgstr "" -#: ../../library/mailbox.rst:133 +#: ../../library/mailbox.rst:138 msgid "Return an :term:`iterator` over all keys" msgstr "" -#: ../../library/mailbox.rst:138 +#: ../../library/mailbox.rst:143 msgid "" "The same as :meth:`iterkeys`, except that a :class:`list` is returned rather " "than an :term:`iterator`" msgstr "" -#: ../../library/mailbox.rst:145 +#: ../../library/mailbox.rst:150 msgid "" "Return an :term:`iterator` over representations of all messages. The " "messages are represented as instances of the appropriate format-specific :" @@ -183,19 +195,19 @@ msgid "" "the :class:`!Mailbox` instance was initialized." msgstr "" -#: ../../library/mailbox.rst:153 +#: ../../library/mailbox.rst:158 msgid "" "The behavior of :meth:`__iter__` is unlike that of dictionaries, which " "iterate over keys." msgstr "" -#: ../../library/mailbox.rst:159 +#: ../../library/mailbox.rst:164 msgid "" "The same as :meth:`itervalues`, except that a :class:`list` is returned " "rather than an :term:`iterator`" msgstr "" -#: ../../library/mailbox.rst:165 +#: ../../library/mailbox.rst:170 msgid "" "Return an :term:`iterator` over (*key*, *message*) pairs, where *key* is a " "key and *message* is a message representation. The messages are represented " @@ -204,13 +216,13 @@ msgid "" "instance was initialized." msgstr "" -#: ../../library/mailbox.rst:174 +#: ../../library/mailbox.rst:179 msgid "" "The same as :meth:`iteritems`, except that a :class:`list` of pairs is " "returned rather than an :term:`iterator` of pairs." msgstr "" -#: ../../library/mailbox.rst:181 +#: ../../library/mailbox.rst:186 msgid "" "Return a representation of the message corresponding to *key*. If no such " "message exists, *default* is returned if the method was called as :meth:" @@ -221,20 +233,20 @@ msgid "" "initialized." msgstr "" -#: ../../library/mailbox.rst:192 +#: ../../library/mailbox.rst:197 msgid "" "Return a representation of the message corresponding to *key* as an instance " "of the appropriate format-specific :class:`Message` subclass, or raise a :" "exc:`KeyError` exception if no such message exists." msgstr "" -#: ../../library/mailbox.rst:199 +#: ../../library/mailbox.rst:204 msgid "" "Return a byte representation of the message corresponding to *key*, or raise " "a :exc:`KeyError` exception if no such message exists." msgstr "" -#: ../../library/mailbox.rst:207 +#: ../../library/mailbox.rst:212 msgid "" "Return a string representation of the message corresponding to *key*, or " "raise a :exc:`KeyError` exception if no such message exists. The message is " @@ -242,7 +254,7 @@ msgid "" "clean representation." msgstr "" -#: ../../library/mailbox.rst:215 +#: ../../library/mailbox.rst:220 msgid "" "Return a :term:`file-like ` representation of the message " "corresponding to *key*, or raise a :exc:`KeyError` exception if no such " @@ -250,7 +262,7 @@ msgid "" "This file should be closed once it is no longer needed." msgstr "" -#: ../../library/mailbox.rst:221 +#: ../../library/mailbox.rst:226 msgid "" "The file object really is a :term:`binary file`; previously it was " "incorrectly returned in text mode. Also, the :term:`file-like object` now " @@ -258,7 +270,7 @@ msgid "" "statement to automatically close it." msgstr "" -#: ../../library/mailbox.rst:229 +#: ../../library/mailbox.rst:234 msgid "" "Unlike other representations of messages, :term:`file-like ` representations are not necessarily independent of the :class:`!" @@ -266,19 +278,19 @@ msgid "" "specific documentation is provided by each subclass." msgstr "" -#: ../../library/mailbox.rst:238 +#: ../../library/mailbox.rst:243 msgid "Return ``True`` if *key* corresponds to a message, ``False`` otherwise." msgstr "" -#: ../../library/mailbox.rst:243 +#: ../../library/mailbox.rst:248 msgid "Return a count of messages in the mailbox." msgstr "" -#: ../../library/mailbox.rst:248 +#: ../../library/mailbox.rst:253 msgid "Delete all messages from the mailbox." msgstr "" -#: ../../library/mailbox.rst:253 +#: ../../library/mailbox.rst:258 msgid "" "Return a representation of the message corresponding to *key* and delete the " "message. If no such message exists, return *default*. The message is " @@ -287,7 +299,7 @@ msgid "" "class:`!Mailbox` instance was initialized." msgstr "" -#: ../../library/mailbox.rst:262 +#: ../../library/mailbox.rst:267 msgid "" "Return an arbitrary (*key*, *message*) pair, where *key* is a key and " "*message* is a message representation, and delete the corresponding message. " @@ -297,7 +309,7 @@ msgid "" "class:`!Mailbox` instance was initialized." msgstr "" -#: ../../library/mailbox.rst:272 +#: ../../library/mailbox.rst:277 msgid "" "Parameter *arg* should be a *key*-to-*message* mapping or an iterable of " "(*key*, *message*) pairs. Updates the mailbox so that, for each given *key* " @@ -308,18 +320,18 @@ msgid "" "class:`!Mailbox` instance." msgstr "" -#: ../../library/mailbox.rst:282 +#: ../../library/mailbox.rst:287 msgid "Unlike with dictionaries, keyword arguments are not supported." msgstr "" -#: ../../library/mailbox.rst:287 +#: ../../library/mailbox.rst:292 msgid "" "Write any pending changes to the filesystem. For some :class:`Mailbox` " "subclasses, changes are always written immediately and :meth:`!flush` does " "nothing, but you should still make a habit of calling this method." msgstr "" -#: ../../library/mailbox.rst:294 +#: ../../library/mailbox.rst:299 msgid "" "Acquire an exclusive advisory lock on the mailbox so that other processes " "know not to modify it. An :exc:`ExternalClashError` is raised if the lock is " @@ -328,21 +340,21 @@ msgid "" "modifications to its contents." msgstr "" -#: ../../library/mailbox.rst:303 +#: ../../library/mailbox.rst:308 msgid "Release the lock on the mailbox, if any." msgstr "" -#: ../../library/mailbox.rst:308 +#: ../../library/mailbox.rst:313 msgid "" "Flush the mailbox, unlock it if necessary, and close any open files. For " "some :class:`!Mailbox` subclasses, this method does nothing." msgstr "" -#: ../../library/mailbox.rst:315 +#: ../../library/mailbox.rst:320 msgid ":class:`!Maildir` objects" msgstr ":class:`!Mailbox` 物件" -#: ../../library/mailbox.rst:320 +#: ../../library/mailbox.rst:325 msgid "" "A subclass of :class:`Mailbox` for mailboxes in Maildir format. Parameter " "*factory* is a callable object that accepts a file-like message " @@ -352,19 +364,19 @@ msgid "" "mailbox is created if it does not exist." msgstr "" -#: ../../library/mailbox.rst:327 +#: ../../library/mailbox.rst:332 msgid "" "If *create* is ``True`` and the *dirname* path exists, it will be treated as " "an existing maildir without attempting to verify its directory layout." msgstr "" -#: ../../library/mailbox.rst:330 +#: ../../library/mailbox.rst:335 msgid "" "It is for historical reasons that *dirname* is named as such rather than " "*path*." msgstr "" -#: ../../library/mailbox.rst:332 +#: ../../library/mailbox.rst:337 msgid "" "Maildir is a directory-based mailbox format invented for the qmail mail " "transfer agent and now widely supported by other programs. Messages in a " @@ -374,7 +386,7 @@ msgid "" "unnecessary." msgstr "" -#: ../../library/mailbox.rst:339 +#: ../../library/mailbox.rst:344 msgid "" "Maildir mailboxes contain three subdirectories, namely: :file:`tmp`, :file:" "`new`, and :file:`cur`. Messages are created momentarily in the :file:`tmp` " @@ -384,7 +396,7 @@ msgid "" "special \"info\" section appended to its file name." msgstr "" -#: ../../library/mailbox.rst:346 +#: ../../library/mailbox.rst:351 msgid "" "Folders of the style introduced by the Courier mail transfer agent are also " "supported. Any subdirectory of the main mailbox is considered a folder if " @@ -395,7 +407,7 @@ msgid "" "\"Archived.2005.07\"." msgstr "" -#: ../../library/mailbox.rst:355 +#: ../../library/mailbox.rst:360 msgid "" "The Maildir specification requires the use of a colon (``':'``) in certain " "message file names. However, some operating systems do not permit this " @@ -404,7 +416,7 @@ msgid "" "exclamation point (``'!'``) is a popular choice. For example::" msgstr "" -#: ../../library/mailbox.rst:362 +#: ../../library/mailbox.rst:367 msgid "" "import mailbox\n" "mailbox.Maildir.colon = '!'" @@ -412,52 +424,52 @@ msgstr "" "import mailbox\n" "mailbox.Maildir.colon = '!'" -#: ../../library/mailbox.rst:365 +#: ../../library/mailbox.rst:370 msgid "The :attr:`!colon` attribute may also be set on a per-instance basis." msgstr "" -#: ../../library/mailbox.rst:367 +#: ../../library/mailbox.rst:372 msgid ":class:`Maildir` now ignores files with a leading dot." msgstr "" -#: ../../library/mailbox.rst:370 +#: ../../library/mailbox.rst:375 msgid "" ":class:`!Maildir` instances have all of the methods of :class:`Mailbox` in " "addition to the following:" msgstr "" -#: ../../library/mailbox.rst:376 ../../library/mailbox.rst:669 +#: ../../library/mailbox.rst:381 ../../library/mailbox.rst:674 msgid "Return a list of the names of all folders." msgstr "" -#: ../../library/mailbox.rst:381 +#: ../../library/mailbox.rst:386 msgid "" "Return a :class:`!Maildir` instance representing the folder whose name is " "*folder*. A :exc:`NoSuchMailboxError` exception is raised if the folder does " "not exist." msgstr "" -#: ../../library/mailbox.rst:388 +#: ../../library/mailbox.rst:393 msgid "" "Create a folder whose name is *folder* and return a :class:`!Maildir` " "instance representing it." msgstr "" -#: ../../library/mailbox.rst:394 ../../library/mailbox.rst:687 +#: ../../library/mailbox.rst:399 ../../library/mailbox.rst:692 msgid "" "Delete the folder whose name is *folder*. If the folder contains any " "messages, a :exc:`NotEmptyError` exception will be raised and the folder " "will not be deleted." msgstr "" -#: ../../library/mailbox.rst:401 +#: ../../library/mailbox.rst:406 msgid "" "Delete temporary files from the mailbox that have not been accessed in the " "last 36 hours. The Maildir specification says that mail-reading programs " "should do this occasionally." msgstr "" -#: ../../library/mailbox.rst:408 +#: ../../library/mailbox.rst:413 msgid "" "Return as a string the flags that are set on the message corresponding to " "*key*. This is the same as ``get_message(key).get_flags()`` but much faster, " @@ -465,7 +477,7 @@ msgid "" "over the keys to determine which messages are interesting to get." msgstr "" -#: ../../library/mailbox.rst:415 +#: ../../library/mailbox.rst:420 msgid "" "If you do have a :class:`MaildirMessage` object, use its :meth:" "`~MaildirMessage.get_flags` method instead, because changes made by the " @@ -474,25 +486,25 @@ msgid "" "here until the mailbox's :meth:`__setitem__` method is called." msgstr "" -#: ../../library/mailbox.rst:427 +#: ../../library/mailbox.rst:432 msgid "" "On the message corresponding to *key*, set the flags specified by *flags* " "and unset all others. Calling ``some_mailbox.set_flags(key, flags)`` is " "similar to ::" msgstr "" -#: ../../library/mailbox.rst:431 +#: ../../library/mailbox.rst:436 msgid "" "one_message = some_mailbox.get_message(key)\n" "one_message.set_flags(flags)\n" "some_mailbox[key] = one_message" msgstr "" -#: ../../library/mailbox.rst:435 ../../library/mailbox.rst:498 +#: ../../library/mailbox.rst:440 ../../library/mailbox.rst:503 msgid "but faster, because it does not open the message file." msgstr "" -#: ../../library/mailbox.rst:437 +#: ../../library/mailbox.rst:442 msgid "" "If you do have a :class:`MaildirMessage` object, use its :meth:" "`~MaildirMessage.set_flags` method instead, because changes made with this " @@ -500,35 +512,35 @@ msgid "" "`~MaildirMessage.get_flags`." msgstr "" -#: ../../library/mailbox.rst:447 +#: ../../library/mailbox.rst:452 msgid "" "On the message corresponding to *key*, set the flags specified by *flag* " "without changing other flags. To add more than one flag at a time, *flag* " "may be a string of more than one character." msgstr "" -#: ../../library/mailbox.rst:451 +#: ../../library/mailbox.rst:456 msgid "" "Considerations for using this method versus the message object's :meth:" "`~MaildirMessage.add_flag` method are similar to those for :meth:" "`set_flags`; see the discussion there." msgstr "" -#: ../../library/mailbox.rst:460 +#: ../../library/mailbox.rst:465 msgid "" "On the message corresponding to *key*, unset the flags specified by *flag* " "without changing other flags. To remove more than one flag at a time, *flag* " "may be a string of more than one character." msgstr "" -#: ../../library/mailbox.rst:464 +#: ../../library/mailbox.rst:469 msgid "" "Considerations for using this method versus the message object's :meth:" "`~MaildirMessage.remove_flag` method are similar to those for :meth:" "`set_flags`; see the discussion there." msgstr "" -#: ../../library/mailbox.rst:473 +#: ../../library/mailbox.rst:478 msgid "" "Return a string containing the info for the message corresponding to *key*. " "This is the same as ``get_message(key).get_info()`` but much faster, because " @@ -536,7 +548,7 @@ msgid "" "keys to determine which messages are interesting to get." msgstr "" -#: ../../library/mailbox.rst:480 +#: ../../library/mailbox.rst:485 msgid "" "If you do have a :class:`MaildirMessage` object, use its :meth:" "`~MaildirMessage.get_info` method instead, because changes made by the " @@ -544,20 +556,20 @@ msgid "" "until the mailbox's :meth:`__setitem__` method is called." msgstr "" -#: ../../library/mailbox.rst:491 +#: ../../library/mailbox.rst:496 msgid "" "Set the info of the message corresponding to *key* to *info*. Calling " "``some_mailbox.set_info(key, flags)`` is similar to ::" msgstr "" -#: ../../library/mailbox.rst:494 +#: ../../library/mailbox.rst:499 msgid "" "one_message = some_mailbox.get_message(key)\n" "one_message.set_info(info)\n" "some_mailbox[key] = one_message" msgstr "" -#: ../../library/mailbox.rst:500 +#: ../../library/mailbox.rst:505 msgid "" "If you do have a :class:`MaildirMessage` object, use its :meth:" "`~MaildirMessage.set_info` method instead, because changes made with this " @@ -565,13 +577,13 @@ msgid "" "`~MaildirMessage.get_info`." msgstr "" -#: ../../library/mailbox.rst:507 +#: ../../library/mailbox.rst:512 msgid "" "Some :class:`Mailbox` methods implemented by :class:`!Maildir` deserve " "special remarks:" msgstr "" -#: ../../library/mailbox.rst:517 +#: ../../library/mailbox.rst:522 msgid "" "These methods generate unique file names based upon the current process ID. " "When using multiple threads, undetected name clashes may occur and cause " @@ -579,56 +591,56 @@ msgid "" "these methods to manipulate the same mailbox simultaneously." msgstr "" -#: ../../library/mailbox.rst:525 +#: ../../library/mailbox.rst:530 msgid "" "All changes to Maildir mailboxes are immediately applied, so this method " "does nothing." msgstr "" -#: ../../library/mailbox.rst:532 +#: ../../library/mailbox.rst:537 msgid "" "Maildir mailboxes do not support (or require) locking, so these methods do " "nothing." msgstr "" -#: ../../library/mailbox.rst:538 +#: ../../library/mailbox.rst:543 msgid "" ":class:`!Maildir` instances do not keep any open files and the underlying " "mailboxes do not support locking, so this method does nothing." msgstr "" -#: ../../library/mailbox.rst:544 +#: ../../library/mailbox.rst:549 msgid "" "Depending upon the host platform, it may not be possible to modify or remove " "the underlying message while the returned file remains open." msgstr "" -#: ../../library/mailbox.rst:550 +#: ../../library/mailbox.rst:555 msgid "" "`maildir man page from Courier `_" msgstr "" -#: ../../library/mailbox.rst:551 +#: ../../library/mailbox.rst:556 msgid "" "A specification of the format. Describes a common extension for supporting " "folders." msgstr "" -#: ../../library/mailbox.rst:554 +#: ../../library/mailbox.rst:559 msgid "`Using maildir format `_" msgstr "" -#: ../../library/mailbox.rst:555 +#: ../../library/mailbox.rst:560 msgid "" "Notes on Maildir by its inventor. Includes an updated name-creation scheme " "and details on \"info\" semantics." msgstr "" -#: ../../library/mailbox.rst:562 +#: ../../library/mailbox.rst:567 msgid ":class:`!mbox` objects" msgstr ":class:`!mbox` 物件" -#: ../../library/mailbox.rst:567 +#: ../../library/mailbox.rst:572 msgid "" "A subclass of :class:`Mailbox` for mailboxes in mbox format. Parameter " "*factory* is a callable object that accepts a file-like message " @@ -638,7 +650,7 @@ msgid "" "mailbox is created if it does not exist." msgstr "" -#: ../../library/mailbox.rst:574 +#: ../../library/mailbox.rst:579 msgid "" "The mbox format is the classic format for storing mail on Unix systems. All " "messages in an mbox mailbox are stored in a single file with the beginning " @@ -646,7 +658,7 @@ msgid "" "\"." msgstr "" -#: ../../library/mailbox.rst:578 +#: ../../library/mailbox.rst:583 msgid "" "Several variations of the mbox format exist to address perceived " "shortcomings in the original. In the interest of compatibility, :class:`!" @@ -658,70 +670,70 @@ msgid "" "when reading the message." msgstr "" -#: ../../library/mailbox.rst:586 +#: ../../library/mailbox.rst:591 msgid "" "Some :class:`Mailbox` methods implemented by :class:`!mbox` deserve special " "remarks:" msgstr "" -#: ../../library/mailbox.rst:592 ../../library/mailbox.rst:602 -#: ../../library/mailbox.rst:608 ../../library/mailbox.rst:871 -#: ../../library/mailbox.rst:881 +#: ../../library/mailbox.rst:597 ../../library/mailbox.rst:607 +#: ../../library/mailbox.rst:613 ../../library/mailbox.rst:876 +#: ../../library/mailbox.rst:886 msgid "" "Note: This method has an extra parameter (*from_*) compared with other " "classes. The first line of an mbox file entry is the Unix \"From \" line. If " "*from_* is False, the first line of the file is dropped." msgstr "" -#: ../../library/mailbox.rst:598 +#: ../../library/mailbox.rst:603 msgid "" "Using the file after calling :meth:`~Mailbox.flush` or :meth:`~Mailbox." "close` on the :class:`!mbox` instance may yield unpredictable results or " "raise an exception." msgstr "" -#: ../../library/mailbox.rst:615 ../../library/mailbox.rst:828 -#: ../../library/mailbox.rst:889 +#: ../../library/mailbox.rst:620 ../../library/mailbox.rst:833 +#: ../../library/mailbox.rst:894 msgid "" "Three locking mechanisms are used---dot locking and, if available, the :c:" "func:`!flock` and :c:func:`!lockf` system calls." msgstr "" -#: ../../library/mailbox.rst:621 +#: ../../library/mailbox.rst:626 msgid "" "`mbox man page from tin `_" msgstr "" -#: ../../library/mailbox.rst:622 +#: ../../library/mailbox.rst:627 msgid "A specification of the format, with details on locking." msgstr "" -#: ../../library/mailbox.rst:624 +#: ../../library/mailbox.rst:629 msgid "" "`Configuring Netscape Mail on Unix: Why The Content-Length Format is Bad " "`_" msgstr "" -#: ../../library/mailbox.rst:625 +#: ../../library/mailbox.rst:630 msgid "An argument for using the original mbox format rather than a variation." msgstr "" -#: ../../library/mailbox.rst:627 +#: ../../library/mailbox.rst:632 msgid "" "`\"mbox\" is a family of several mutually incompatible mailbox formats " "`_" msgstr "" -#: ../../library/mailbox.rst:628 +#: ../../library/mailbox.rst:633 msgid "A history of mbox variations." msgstr "" -#: ../../library/mailbox.rst:634 +#: ../../library/mailbox.rst:639 msgid ":class:`!MH` objects" msgstr ":class:`!MH` 物件" -#: ../../library/mailbox.rst:639 +#: ../../library/mailbox.rst:644 msgid "" "A subclass of :class:`Mailbox` for mailboxes in MH format. Parameter " "*factory* is a callable object that accepts a file-like message " @@ -731,7 +743,7 @@ msgid "" "is created if it does not exist." msgstr "" -#: ../../library/mailbox.rst:646 +#: ../../library/mailbox.rst:651 msgid "" "MH is a directory-based mailbox format invented for the MH Message Handling " "System, a mail user agent. Each message in an MH mailbox resides in its own " @@ -742,7 +754,7 @@ msgid "" "called :file:`.mh_sequences` in each folder." msgstr "" -#: ../../library/mailbox.rst:654 +#: ../../library/mailbox.rst:659 msgid "" "The :class:`!MH` class manipulates MH mailboxes, but it does not attempt to " "emulate all of :program:`mh`'s behaviors. In particular, it does not modify " @@ -750,67 +762,67 @@ msgid "" "are used by :program:`mh` to store its state and configuration." msgstr "" -#: ../../library/mailbox.rst:659 +#: ../../library/mailbox.rst:664 msgid "" ":class:`!MH` instances have all of the methods of :class:`Mailbox` in " "addition to the following:" msgstr "" -#: ../../library/mailbox.rst:664 +#: ../../library/mailbox.rst:669 msgid "Supported folders that don't contain a :file:`.mh_sequences` file." msgstr "" -#: ../../library/mailbox.rst:674 +#: ../../library/mailbox.rst:679 msgid "" "Return an :class:`!MH` instance representing the folder whose name is " "*folder*. A :exc:`NoSuchMailboxError` exception is raised if the folder does " "not exist." msgstr "" -#: ../../library/mailbox.rst:681 +#: ../../library/mailbox.rst:686 msgid "" "Create a folder whose name is *folder* and return an :class:`!MH` instance " "representing it." msgstr "" -#: ../../library/mailbox.rst:694 +#: ../../library/mailbox.rst:699 msgid "" "Return a dictionary of sequence names mapped to key lists. If there are no " "sequences, the empty dictionary is returned." msgstr "" -#: ../../library/mailbox.rst:700 +#: ../../library/mailbox.rst:705 msgid "" "Re-define the sequences that exist in the mailbox based upon *sequences*, a " "dictionary of names mapped to key lists, like returned by :meth:" "`get_sequences`." msgstr "" -#: ../../library/mailbox.rst:707 +#: ../../library/mailbox.rst:712 msgid "" "Rename messages in the mailbox as necessary to eliminate gaps in numbering. " "Entries in the sequences list are updated correspondingly." msgstr "" -#: ../../library/mailbox.rst:712 +#: ../../library/mailbox.rst:717 msgid "" "Already-issued keys are invalidated by this operation and should not be " "subsequently used." msgstr "" -#: ../../library/mailbox.rst:715 +#: ../../library/mailbox.rst:720 msgid "" "Some :class:`Mailbox` methods implemented by :class:`!MH` deserve special " "remarks:" msgstr "" -#: ../../library/mailbox.rst:723 +#: ../../library/mailbox.rst:728 msgid "" "These methods immediately delete the message. The MH convention of marking a " "message for deletion by prepending a comma to its name is not used." msgstr "" -#: ../../library/mailbox.rst:730 +#: ../../library/mailbox.rst:735 msgid "" "Three locking mechanisms are used---dot locking and, if available, the :c:" "func:`!flock` and :c:func:`!lockf` system calls. For MH mailboxes, locking " @@ -819,51 +831,51 @@ msgid "" "files." msgstr "" -#: ../../library/mailbox.rst:739 +#: ../../library/mailbox.rst:744 msgid "" "Depending upon the host platform, it may not be possible to remove the " "underlying message while the returned file remains open." msgstr "" -#: ../../library/mailbox.rst:745 +#: ../../library/mailbox.rst:750 msgid "" "All changes to MH mailboxes are immediately applied, so this method does " "nothing." msgstr "" -#: ../../library/mailbox.rst:751 +#: ../../library/mailbox.rst:756 msgid "" ":class:`!MH` instances do not keep any open files, so this method is " "equivalent to :meth:`unlock`." msgstr "" -#: ../../library/mailbox.rst:757 +#: ../../library/mailbox.rst:762 msgid "`nmh - Message Handling System `_" msgstr "" -#: ../../library/mailbox.rst:758 +#: ../../library/mailbox.rst:763 msgid "" "Home page of :program:`nmh`, an updated version of the original :program:" "`mh`." msgstr "" -#: ../../library/mailbox.rst:760 +#: ../../library/mailbox.rst:765 msgid "" "`MH & nmh: Email for Users & Programmers `_" msgstr "" -#: ../../library/mailbox.rst:761 +#: ../../library/mailbox.rst:766 msgid "" "A GPL-licensed book on :program:`mh` and :program:`nmh`, with some " "information on the mailbox format." msgstr "" -#: ../../library/mailbox.rst:768 +#: ../../library/mailbox.rst:773 msgid ":class:`!Babyl` objects" msgstr ":class:`!Babyl` 物件" -#: ../../library/mailbox.rst:773 +#: ../../library/mailbox.rst:778 msgid "" "A subclass of :class:`Mailbox` for mailboxes in Babyl format. Parameter " "*factory* is a callable object that accepts a file-like message " @@ -873,7 +885,7 @@ msgid "" "mailbox is created if it does not exist." msgstr "" -#: ../../library/mailbox.rst:780 +#: ../../library/mailbox.rst:785 msgid "" "Babyl is a single-file mailbox format used by the Rmail mail user agent " "included with Emacs. The beginning of a message is indicated by a line " @@ -883,7 +895,7 @@ msgid "" "Underscore (``'\\037'``) character." msgstr "" -#: ../../library/mailbox.rst:787 +#: ../../library/mailbox.rst:792 msgid "" "Messages in a Babyl mailbox have two sets of headers, original headers and " "so-called visible headers. Visible headers are typically a subset of the " @@ -894,31 +906,31 @@ msgid "" "in the Babyl options section." msgstr "" -#: ../../library/mailbox.rst:795 +#: ../../library/mailbox.rst:800 msgid "" ":class:`!Babyl` instances have all of the methods of :class:`Mailbox` in " "addition to the following:" msgstr "" -#: ../../library/mailbox.rst:801 +#: ../../library/mailbox.rst:806 msgid "" "Return a list of the names of all user-defined labels used in the mailbox." msgstr "" -#: ../../library/mailbox.rst:805 +#: ../../library/mailbox.rst:810 msgid "" "The actual messages are inspected to determine which labels exist in the " "mailbox rather than consulting the list of labels in the Babyl options " "section, but the Babyl section is updated whenever the mailbox is modified." msgstr "" -#: ../../library/mailbox.rst:810 +#: ../../library/mailbox.rst:815 msgid "" "Some :class:`Mailbox` methods implemented by :class:`!Babyl` deserve special " "remarks:" msgstr "" -#: ../../library/mailbox.rst:816 +#: ../../library/mailbox.rst:821 msgid "" "In Babyl mailboxes, the headers of a message are not stored contiguously " "with the body of the message. To generate a file-like representation, the " @@ -928,30 +940,30 @@ msgid "" "memory compared to a string representation." msgstr "" -#: ../../library/mailbox.rst:834 +#: ../../library/mailbox.rst:839 msgid "" "`Format of Version 5 Babyl Files `_" msgstr "" -#: ../../library/mailbox.rst:835 +#: ../../library/mailbox.rst:840 msgid "A specification of the Babyl format." msgstr "" -#: ../../library/mailbox.rst:837 +#: ../../library/mailbox.rst:842 msgid "" "`Reading Mail with Rmail `_" msgstr "" -#: ../../library/mailbox.rst:838 +#: ../../library/mailbox.rst:843 msgid "The Rmail manual, with some information on Babyl semantics." msgstr "" -#: ../../library/mailbox.rst:844 +#: ../../library/mailbox.rst:849 msgid ":class:`!MMDF` objects" msgstr ":class:`!MMDF` 物件" -#: ../../library/mailbox.rst:849 +#: ../../library/mailbox.rst:854 msgid "" "A subclass of :class:`Mailbox` for mailboxes in MMDF format. Parameter " "*factory* is a callable object that accepts a file-like message " @@ -961,7 +973,7 @@ msgid "" "mailbox is created if it does not exist." msgstr "" -#: ../../library/mailbox.rst:856 +#: ../../library/mailbox.rst:861 msgid "" "MMDF is a single-file mailbox format invented for the Multichannel " "Memorandum Distribution Facility, a mail transfer agent. Each message is in " @@ -974,52 +986,52 @@ msgid "" "subsequent messages." msgstr "" -#: ../../library/mailbox.rst:865 +#: ../../library/mailbox.rst:870 msgid "" "Some :class:`Mailbox` methods implemented by :class:`!MMDF` deserve special " "remarks:" msgstr "" -#: ../../library/mailbox.rst:877 +#: ../../library/mailbox.rst:882 msgid "" "Using the file after calling :meth:`~Mailbox.flush` or :meth:`~Mailbox." "close` on the :class:`!MMDF` instance may yield unpredictable results or " "raise an exception." msgstr "" -#: ../../library/mailbox.rst:895 +#: ../../library/mailbox.rst:900 msgid "" "`mmdf man page from tin `_" msgstr "" -#: ../../library/mailbox.rst:896 +#: ../../library/mailbox.rst:901 msgid "" "A specification of MMDF format from the documentation of tin, a newsreader." msgstr "" -#: ../../library/mailbox.rst:898 +#: ../../library/mailbox.rst:903 msgid "`MMDF `_" msgstr "`MMDF `_" -#: ../../library/mailbox.rst:899 +#: ../../library/mailbox.rst:904 msgid "" "A Wikipedia article describing the Multichannel Memorandum Distribution " "Facility." msgstr "" -#: ../../library/mailbox.rst:906 +#: ../../library/mailbox.rst:911 msgid ":class:`!Message` objects" msgstr ":class:`!Message` 物件" -#: ../../library/mailbox.rst:911 +#: ../../library/mailbox.rst:916 msgid "" "A subclass of the :mod:`email.message` module's :class:`~email.message." "Message`. Subclasses of :class:`!mailbox.Message` add mailbox-format-" "specific state and behavior." msgstr "" -#: ../../library/mailbox.rst:915 +#: ../../library/mailbox.rst:920 msgid "" "If *message* is omitted, the new instance is created in a default, empty " "state. If *message* is an :class:`email.message.Message` instance, its " @@ -1031,7 +1043,7 @@ msgid "" "compatibility." msgstr "" -#: ../../library/mailbox.rst:924 +#: ../../library/mailbox.rst:929 msgid "" "The format-specific state and behaviors offered by subclasses vary, but in " "general it is only the properties that are not specific to a particular " @@ -1043,7 +1055,7 @@ msgid "" "important is retained, because it applies to the message itself." msgstr "" -#: ../../library/mailbox.rst:933 +#: ../../library/mailbox.rst:938 msgid "" "There is no requirement that :class:`!Message` instances be used to " "represent messages retrieved using :class:`Mailbox` instances. In some " @@ -1054,17 +1066,17 @@ msgid "" "initialized." msgstr "" -#: ../../library/mailbox.rst:944 +#: ../../library/mailbox.rst:949 msgid ":class:`!MaildirMessage` objects" msgstr ":class:`!MaildirMessage` 物件" -#: ../../library/mailbox.rst:949 +#: ../../library/mailbox.rst:954 msgid "" "A message with Maildir-specific behaviors. Parameter *message* has the same " "meaning as with the :class:`Message` constructor." msgstr "" -#: ../../library/mailbox.rst:952 +#: ../../library/mailbox.rst:957 msgid "" "Typically, a mail user agent application moves all of the messages in the :" "file:`new` subdirectory to the :file:`cur` subdirectory after the first time " @@ -1078,128 +1090,128 @@ msgid "" "flags for Maildir messages are as follows:" msgstr "" -#: ../../library/mailbox.rst:964 ../../library/mailbox.rst:1131 -#: ../../library/mailbox.rst:1502 +#: ../../library/mailbox.rst:969 ../../library/mailbox.rst:1136 +#: ../../library/mailbox.rst:1507 msgid "Flag" msgstr "旗標" -#: ../../library/mailbox.rst:964 ../../library/mailbox.rst:1131 -#: ../../library/mailbox.rst:1502 +#: ../../library/mailbox.rst:969 ../../library/mailbox.rst:1136 +#: ../../library/mailbox.rst:1507 msgid "Meaning" msgstr "含義" -#: ../../library/mailbox.rst:964 ../../library/mailbox.rst:1131 -#: ../../library/mailbox.rst:1282 ../../library/mailbox.rst:1369 -#: ../../library/mailbox.rst:1502 +#: ../../library/mailbox.rst:969 ../../library/mailbox.rst:1136 +#: ../../library/mailbox.rst:1287 ../../library/mailbox.rst:1374 +#: ../../library/mailbox.rst:1507 msgid "Explanation" msgstr "解釋" -#: ../../library/mailbox.rst:966 ../../library/mailbox.rst:1137 -#: ../../library/mailbox.rst:1508 +#: ../../library/mailbox.rst:971 ../../library/mailbox.rst:1142 +#: ../../library/mailbox.rst:1513 msgid "D" msgstr "D" -#: ../../library/mailbox.rst:966 +#: ../../library/mailbox.rst:971 msgid "Draft" msgstr "草稿" -#: ../../library/mailbox.rst:966 +#: ../../library/mailbox.rst:971 msgid "Under composition" msgstr "編輯中" -#: ../../library/mailbox.rst:968 ../../library/mailbox.rst:1139 -#: ../../library/mailbox.rst:1510 +#: ../../library/mailbox.rst:973 ../../library/mailbox.rst:1144 +#: ../../library/mailbox.rst:1515 msgid "F" msgstr "F" -#: ../../library/mailbox.rst:968 ../../library/mailbox.rst:1139 -#: ../../library/mailbox.rst:1510 +#: ../../library/mailbox.rst:973 ../../library/mailbox.rst:1144 +#: ../../library/mailbox.rst:1515 msgid "Flagged" msgstr "已標記" -#: ../../library/mailbox.rst:968 ../../library/mailbox.rst:1139 -#: ../../library/mailbox.rst:1288 ../../library/mailbox.rst:1510 +#: ../../library/mailbox.rst:973 ../../library/mailbox.rst:1144 +#: ../../library/mailbox.rst:1293 ../../library/mailbox.rst:1515 msgid "Marked as important" msgstr "標記為重要" -#: ../../library/mailbox.rst:970 +#: ../../library/mailbox.rst:975 msgid "P" msgstr "P" -#: ../../library/mailbox.rst:970 +#: ../../library/mailbox.rst:975 msgid "Passed" msgstr "" -#: ../../library/mailbox.rst:970 +#: ../../library/mailbox.rst:975 msgid "Forwarded, resent, or bounced" msgstr "" -#: ../../library/mailbox.rst:972 ../../library/mailbox.rst:1133 -#: ../../library/mailbox.rst:1504 +#: ../../library/mailbox.rst:977 ../../library/mailbox.rst:1138 +#: ../../library/mailbox.rst:1509 msgid "R" msgstr "R" -#: ../../library/mailbox.rst:972 +#: ../../library/mailbox.rst:977 msgid "Replied" msgstr "已回覆" -#: ../../library/mailbox.rst:972 ../../library/mailbox.rst:1141 -#: ../../library/mailbox.rst:1286 ../../library/mailbox.rst:1377 -#: ../../library/mailbox.rst:1512 +#: ../../library/mailbox.rst:977 ../../library/mailbox.rst:1146 +#: ../../library/mailbox.rst:1291 ../../library/mailbox.rst:1382 +#: ../../library/mailbox.rst:1517 msgid "Replied to" msgstr "" -#: ../../library/mailbox.rst:974 +#: ../../library/mailbox.rst:979 msgid "S" msgstr "S" -#: ../../library/mailbox.rst:974 +#: ../../library/mailbox.rst:979 msgid "Seen" msgstr "已查看" -#: ../../library/mailbox.rst:974 ../../library/mailbox.rst:1133 -#: ../../library/mailbox.rst:1504 +#: ../../library/mailbox.rst:979 ../../library/mailbox.rst:1138 +#: ../../library/mailbox.rst:1509 msgid "Read" msgstr "" -#: ../../library/mailbox.rst:976 +#: ../../library/mailbox.rst:981 msgid "T" msgstr "T" -#: ../../library/mailbox.rst:976 +#: ../../library/mailbox.rst:981 msgid "Trashed" msgstr "" -#: ../../library/mailbox.rst:976 ../../library/mailbox.rst:1137 -#: ../../library/mailbox.rst:1373 ../../library/mailbox.rst:1508 +#: ../../library/mailbox.rst:981 ../../library/mailbox.rst:1142 +#: ../../library/mailbox.rst:1378 ../../library/mailbox.rst:1513 msgid "Marked for subsequent deletion" msgstr "" -#: ../../library/mailbox.rst:979 +#: ../../library/mailbox.rst:984 msgid ":class:`!MaildirMessage` instances offer the following methods:" msgstr ":class:`!MaildirMessage` 實例提供以下方法:" -#: ../../library/mailbox.rst:984 +#: ../../library/mailbox.rst:989 msgid "" "Return either \"new\" (if the message should be stored in the :file:`new` " "subdirectory) or \"cur\" (if the message should be stored in the :file:`cur` " "subdirectory)." msgstr "" -#: ../../library/mailbox.rst:990 +#: ../../library/mailbox.rst:995 msgid "" "A message is typically moved from :file:`new` to :file:`cur` after its " "mailbox has been accessed, whether or not the message has been read. A " "message ``msg`` has been read if ``\"S\" in msg.get_flags()`` is ``True``." msgstr "" -#: ../../library/mailbox.rst:998 +#: ../../library/mailbox.rst:1003 msgid "" "Set the subdirectory the message should be stored in. Parameter *subdir* " "must be either \"new\" or \"cur\"." msgstr "" -#: ../../library/mailbox.rst:1004 +#: ../../library/mailbox.rst:1009 msgid "" "Return a string specifying the flags that are currently set. If the message " "complies with the standard Maildir format, the result is the concatenation " @@ -1208,11 +1220,11 @@ msgid "" "flags are set or if \"info\" contains experimental semantics." msgstr "" -#: ../../library/mailbox.rst:1014 +#: ../../library/mailbox.rst:1019 msgid "Set the flags specified by *flags* and unset all others." msgstr "" -#: ../../library/mailbox.rst:1019 +#: ../../library/mailbox.rst:1024 msgid "" "Set the flag(s) specified by *flag* without changing other flags. To add " "more than one flag at a time, *flag* may be a string of more than one " @@ -1220,7 +1232,7 @@ msgid "" "experimental information rather than flags." msgstr "" -#: ../../library/mailbox.rst:1027 +#: ../../library/mailbox.rst:1032 msgid "" "Unset the flag(s) specified by *flag* without changing other flags. To " "remove more than one flag at a time, *flag* may be a string of more than one " @@ -1228,30 +1240,30 @@ msgid "" "the current \"info\" is not modified." msgstr "" -#: ../../library/mailbox.rst:1035 +#: ../../library/mailbox.rst:1040 msgid "" "Return the delivery date of the message as a floating-point number " "representing seconds since the epoch." msgstr "" -#: ../../library/mailbox.rst:1041 +#: ../../library/mailbox.rst:1046 msgid "" "Set the delivery date of the message to *date*, a floating-point number " "representing seconds since the epoch." msgstr "" -#: ../../library/mailbox.rst:1047 +#: ../../library/mailbox.rst:1052 msgid "" "Return a string containing the \"info\" for a message. This is useful for " "accessing and modifying \"info\" that is experimental (i.e., not a list of " "flags)." msgstr "" -#: ../../library/mailbox.rst:1054 +#: ../../library/mailbox.rst:1059 msgid "Set \"info\" to *info*, which should be a string." msgstr "" -#: ../../library/mailbox.rst:1056 +#: ../../library/mailbox.rst:1061 msgid "" "When a :class:`!MaildirMessage` instance is created based upon an :class:" "`mboxMessage` or :class:`MMDFMessage` instance, the :mailheader:`Status` " @@ -1259,176 +1271,176 @@ msgid "" "take place:" msgstr "" -#: ../../library/mailbox.rst:1062 ../../library/mailbox.rst:1080 -#: ../../library/mailbox.rst:1095 ../../library/mailbox.rst:1202 -#: ../../library/mailbox.rst:1219 ../../library/mailbox.rst:1234 -#: ../../library/mailbox.rst:1250 ../../library/mailbox.rst:1317 -#: ../../library/mailbox.rst:1332 ../../library/mailbox.rst:1346 -#: ../../library/mailbox.rst:1443 ../../library/mailbox.rst:1460 -#: ../../library/mailbox.rst:1474 ../../library/mailbox.rst:1574 -#: ../../library/mailbox.rst:1591 ../../library/mailbox.rst:1606 -#: ../../library/mailbox.rst:1622 +#: ../../library/mailbox.rst:1067 ../../library/mailbox.rst:1085 +#: ../../library/mailbox.rst:1100 ../../library/mailbox.rst:1207 +#: ../../library/mailbox.rst:1224 ../../library/mailbox.rst:1239 +#: ../../library/mailbox.rst:1255 ../../library/mailbox.rst:1322 +#: ../../library/mailbox.rst:1337 ../../library/mailbox.rst:1351 +#: ../../library/mailbox.rst:1448 ../../library/mailbox.rst:1465 +#: ../../library/mailbox.rst:1479 ../../library/mailbox.rst:1579 +#: ../../library/mailbox.rst:1596 ../../library/mailbox.rst:1611 +#: ../../library/mailbox.rst:1627 msgid "Resulting state" msgstr "" -#: ../../library/mailbox.rst:1062 ../../library/mailbox.rst:1332 -#: ../../library/mailbox.rst:1460 +#: ../../library/mailbox.rst:1067 ../../library/mailbox.rst:1337 +#: ../../library/mailbox.rst:1465 msgid ":class:`mboxMessage` or :class:`MMDFMessage` state" msgstr ":class:`mboxMessage` 或 :class:`MMDFMessage` 狀態" -#: ../../library/mailbox.rst:1065 ../../library/mailbox.rst:1082 -#: ../../library/mailbox.rst:1097 ../../library/mailbox.rst:1206 -#: ../../library/mailbox.rst:1578 +#: ../../library/mailbox.rst:1070 ../../library/mailbox.rst:1087 +#: ../../library/mailbox.rst:1102 ../../library/mailbox.rst:1211 +#: ../../library/mailbox.rst:1583 msgid "\"cur\" subdirectory" msgstr "\"cur\" 子目錄" -#: ../../library/mailbox.rst:1065 ../../library/mailbox.rst:1206 -#: ../../library/mailbox.rst:1223 ../../library/mailbox.rst:1238 -#: ../../library/mailbox.rst:1254 ../../library/mailbox.rst:1578 -#: ../../library/mailbox.rst:1595 ../../library/mailbox.rst:1610 -#: ../../library/mailbox.rst:1626 +#: ../../library/mailbox.rst:1070 ../../library/mailbox.rst:1211 +#: ../../library/mailbox.rst:1228 ../../library/mailbox.rst:1243 +#: ../../library/mailbox.rst:1259 ../../library/mailbox.rst:1583 +#: ../../library/mailbox.rst:1600 ../../library/mailbox.rst:1615 +#: ../../library/mailbox.rst:1631 msgid "O flag" msgstr "O 旗標" -#: ../../library/mailbox.rst:1067 ../../library/mailbox.rst:1086 -#: ../../library/mailbox.rst:1210 ../../library/mailbox.rst:1225 -#: ../../library/mailbox.rst:1258 ../../library/mailbox.rst:1323 -#: ../../library/mailbox.rst:1339 ../../library/mailbox.rst:1582 -#: ../../library/mailbox.rst:1597 ../../library/mailbox.rst:1630 +#: ../../library/mailbox.rst:1072 ../../library/mailbox.rst:1091 +#: ../../library/mailbox.rst:1215 ../../library/mailbox.rst:1230 +#: ../../library/mailbox.rst:1263 ../../library/mailbox.rst:1328 +#: ../../library/mailbox.rst:1344 ../../library/mailbox.rst:1587 +#: ../../library/mailbox.rst:1602 ../../library/mailbox.rst:1635 msgid "F flag" msgstr "F 旗標" -#: ../../library/mailbox.rst:1069 ../../library/mailbox.rst:1071 -#: ../../library/mailbox.rst:1088 ../../library/mailbox.rst:1103 -#: ../../library/mailbox.rst:1204 ../../library/mailbox.rst:1212 -#: ../../library/mailbox.rst:1252 ../../library/mailbox.rst:1321 -#: ../../library/mailbox.rst:1449 ../../library/mailbox.rst:1576 -#: ../../library/mailbox.rst:1584 ../../library/mailbox.rst:1624 +#: ../../library/mailbox.rst:1074 ../../library/mailbox.rst:1076 +#: ../../library/mailbox.rst:1093 ../../library/mailbox.rst:1108 +#: ../../library/mailbox.rst:1209 ../../library/mailbox.rst:1217 +#: ../../library/mailbox.rst:1257 ../../library/mailbox.rst:1326 +#: ../../library/mailbox.rst:1454 ../../library/mailbox.rst:1581 +#: ../../library/mailbox.rst:1589 ../../library/mailbox.rst:1629 msgid "R flag" msgstr "R 旗標" -#: ../../library/mailbox.rst:1069 ../../library/mailbox.rst:1212 -#: ../../library/mailbox.rst:1227 ../../library/mailbox.rst:1242 -#: ../../library/mailbox.rst:1260 ../../library/mailbox.rst:1337 -#: ../../library/mailbox.rst:1467 ../../library/mailbox.rst:1584 -#: ../../library/mailbox.rst:1599 ../../library/mailbox.rst:1614 -#: ../../library/mailbox.rst:1632 +#: ../../library/mailbox.rst:1074 ../../library/mailbox.rst:1217 +#: ../../library/mailbox.rst:1232 ../../library/mailbox.rst:1247 +#: ../../library/mailbox.rst:1265 ../../library/mailbox.rst:1342 +#: ../../library/mailbox.rst:1472 ../../library/mailbox.rst:1589 +#: ../../library/mailbox.rst:1604 ../../library/mailbox.rst:1619 +#: ../../library/mailbox.rst:1637 msgid "A flag" msgstr "A 旗標" -#: ../../library/mailbox.rst:1071 ../../library/mailbox.rst:1204 -#: ../../library/mailbox.rst:1576 +#: ../../library/mailbox.rst:1076 ../../library/mailbox.rst:1209 +#: ../../library/mailbox.rst:1581 msgid "S flag" msgstr "S 旗標" -#: ../../library/mailbox.rst:1073 ../../library/mailbox.rst:1105 -#: ../../library/mailbox.rst:1208 ../../library/mailbox.rst:1447 -#: ../../library/mailbox.rst:1580 +#: ../../library/mailbox.rst:1078 ../../library/mailbox.rst:1110 +#: ../../library/mailbox.rst:1213 ../../library/mailbox.rst:1452 +#: ../../library/mailbox.rst:1585 msgid "T flag" msgstr "T 旗標" -#: ../../library/mailbox.rst:1073 ../../library/mailbox.rst:1208 -#: ../../library/mailbox.rst:1240 ../../library/mailbox.rst:1256 -#: ../../library/mailbox.rst:1465 ../../library/mailbox.rst:1580 -#: ../../library/mailbox.rst:1612 ../../library/mailbox.rst:1628 +#: ../../library/mailbox.rst:1078 ../../library/mailbox.rst:1213 +#: ../../library/mailbox.rst:1245 ../../library/mailbox.rst:1261 +#: ../../library/mailbox.rst:1470 ../../library/mailbox.rst:1585 +#: ../../library/mailbox.rst:1617 ../../library/mailbox.rst:1633 msgid "D flag" msgstr "D 旗標" -#: ../../library/mailbox.rst:1076 +#: ../../library/mailbox.rst:1081 msgid "" "When a :class:`!MaildirMessage` instance is created based upon an :class:" "`MHMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1080 ../../library/mailbox.rst:1219 -#: ../../library/mailbox.rst:1474 ../../library/mailbox.rst:1591 +#: ../../library/mailbox.rst:1085 ../../library/mailbox.rst:1224 +#: ../../library/mailbox.rst:1479 ../../library/mailbox.rst:1596 msgid ":class:`MHMessage` state" msgstr ":class:`MHMessage` 狀態" -#: ../../library/mailbox.rst:1082 ../../library/mailbox.rst:1223 -#: ../../library/mailbox.rst:1319 ../../library/mailbox.rst:1335 -#: ../../library/mailbox.rst:1348 ../../library/mailbox.rst:1476 -#: ../../library/mailbox.rst:1595 +#: ../../library/mailbox.rst:1087 ../../library/mailbox.rst:1228 +#: ../../library/mailbox.rst:1324 ../../library/mailbox.rst:1340 +#: ../../library/mailbox.rst:1353 ../../library/mailbox.rst:1481 +#: ../../library/mailbox.rst:1600 msgid "\"unseen\" sequence" msgstr "\"unseen\" 序列" -#: ../../library/mailbox.rst:1084 ../../library/mailbox.rst:1099 +#: ../../library/mailbox.rst:1089 ../../library/mailbox.rst:1104 msgid "\"cur\" subdirectory and S flag" msgstr "\"cur\" 子目錄和 S 旗標" -#: ../../library/mailbox.rst:1084 ../../library/mailbox.rst:1221 -#: ../../library/mailbox.rst:1593 +#: ../../library/mailbox.rst:1089 ../../library/mailbox.rst:1226 +#: ../../library/mailbox.rst:1598 msgid "no \"unseen\" sequence" msgstr "沒有 \"unseen\" 序列" -#: ../../library/mailbox.rst:1086 ../../library/mailbox.rst:1225 -#: ../../library/mailbox.rst:1323 ../../library/mailbox.rst:1339 -#: ../../library/mailbox.rst:1597 +#: ../../library/mailbox.rst:1091 ../../library/mailbox.rst:1230 +#: ../../library/mailbox.rst:1328 ../../library/mailbox.rst:1344 +#: ../../library/mailbox.rst:1602 msgid "\"flagged\" sequence" msgstr "\"flagged\" 序列" -#: ../../library/mailbox.rst:1088 ../../library/mailbox.rst:1227 -#: ../../library/mailbox.rst:1321 ../../library/mailbox.rst:1337 -#: ../../library/mailbox.rst:1350 ../../library/mailbox.rst:1478 -#: ../../library/mailbox.rst:1599 +#: ../../library/mailbox.rst:1093 ../../library/mailbox.rst:1232 +#: ../../library/mailbox.rst:1326 ../../library/mailbox.rst:1342 +#: ../../library/mailbox.rst:1355 ../../library/mailbox.rst:1483 +#: ../../library/mailbox.rst:1604 msgid "\"replied\" sequence" msgstr "\"replied\" 序列" -#: ../../library/mailbox.rst:1091 +#: ../../library/mailbox.rst:1096 msgid "" "When a :class:`!MaildirMessage` instance is created based upon a :class:" "`BabylMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1095 ../../library/mailbox.rst:1234 -#: ../../library/mailbox.rst:1346 ../../library/mailbox.rst:1606 +#: ../../library/mailbox.rst:1100 ../../library/mailbox.rst:1239 +#: ../../library/mailbox.rst:1351 ../../library/mailbox.rst:1611 msgid ":class:`BabylMessage` state" msgstr ":class:`BabylMessage` 狀態" -#: ../../library/mailbox.rst:1097 ../../library/mailbox.rst:1238 -#: ../../library/mailbox.rst:1348 ../../library/mailbox.rst:1445 -#: ../../library/mailbox.rst:1463 ../../library/mailbox.rst:1476 -#: ../../library/mailbox.rst:1610 +#: ../../library/mailbox.rst:1102 ../../library/mailbox.rst:1243 +#: ../../library/mailbox.rst:1353 ../../library/mailbox.rst:1450 +#: ../../library/mailbox.rst:1468 ../../library/mailbox.rst:1481 +#: ../../library/mailbox.rst:1615 msgid "\"unseen\" label" msgstr "\"unseen\" 標籤" -#: ../../library/mailbox.rst:1099 ../../library/mailbox.rst:1236 -#: ../../library/mailbox.rst:1608 +#: ../../library/mailbox.rst:1104 ../../library/mailbox.rst:1241 +#: ../../library/mailbox.rst:1613 msgid "no \"unseen\" label" msgstr "沒有 \"unseen\" 標籤" -#: ../../library/mailbox.rst:1101 ../../library/mailbox.rst:1451 +#: ../../library/mailbox.rst:1106 ../../library/mailbox.rst:1456 msgid "P flag" msgstr "P 旗標" -#: ../../library/mailbox.rst:1101 +#: ../../library/mailbox.rst:1106 msgid "\"forwarded\" or \"resent\" label" msgstr "\"forwarded\" 或 \"resent\" 標籤" -#: ../../library/mailbox.rst:1103 ../../library/mailbox.rst:1242 -#: ../../library/mailbox.rst:1350 ../../library/mailbox.rst:1449 -#: ../../library/mailbox.rst:1467 ../../library/mailbox.rst:1478 -#: ../../library/mailbox.rst:1614 +#: ../../library/mailbox.rst:1108 ../../library/mailbox.rst:1247 +#: ../../library/mailbox.rst:1355 ../../library/mailbox.rst:1454 +#: ../../library/mailbox.rst:1472 ../../library/mailbox.rst:1483 +#: ../../library/mailbox.rst:1619 msgid "\"answered\" label" msgstr "\"answered\" 標籤" -#: ../../library/mailbox.rst:1105 ../../library/mailbox.rst:1240 -#: ../../library/mailbox.rst:1447 ../../library/mailbox.rst:1465 -#: ../../library/mailbox.rst:1612 +#: ../../library/mailbox.rst:1110 ../../library/mailbox.rst:1245 +#: ../../library/mailbox.rst:1452 ../../library/mailbox.rst:1470 +#: ../../library/mailbox.rst:1617 msgid "\"deleted\" label" msgstr "\"deleted\" 標籤" -#: ../../library/mailbox.rst:1112 +#: ../../library/mailbox.rst:1117 msgid ":class:`!mboxMessage` objects" msgstr ":class:`!mboxMessage` 物件" -#: ../../library/mailbox.rst:1117 +#: ../../library/mailbox.rst:1122 msgid "" "A message with mbox-specific behaviors. Parameter *message* has the same " "meaning as with the :class:`Message` constructor." msgstr "" -#: ../../library/mailbox.rst:1120 +#: ../../library/mailbox.rst:1125 msgid "" "Messages in an mbox mailbox are stored together in a single file. The " "sender's envelope address and the time of delivery are typically stored in a " @@ -1439,53 +1451,53 @@ msgid "" "typically stored in :mailheader:`Status` and :mailheader:`X-Status` headers." msgstr "" -#: ../../library/mailbox.rst:1128 +#: ../../library/mailbox.rst:1133 msgid "Conventional flags for mbox messages are as follows:" msgstr "" -#: ../../library/mailbox.rst:1135 ../../library/mailbox.rst:1506 +#: ../../library/mailbox.rst:1140 ../../library/mailbox.rst:1511 msgid "O" msgstr "O" -#: ../../library/mailbox.rst:1135 ../../library/mailbox.rst:1506 +#: ../../library/mailbox.rst:1140 ../../library/mailbox.rst:1511 msgid "Old" msgstr "" -#: ../../library/mailbox.rst:1135 ../../library/mailbox.rst:1506 +#: ../../library/mailbox.rst:1140 ../../library/mailbox.rst:1511 msgid "Previously detected by MUA" msgstr "" -#: ../../library/mailbox.rst:1137 ../../library/mailbox.rst:1508 +#: ../../library/mailbox.rst:1142 ../../library/mailbox.rst:1513 msgid "Deleted" msgstr "" -#: ../../library/mailbox.rst:1141 ../../library/mailbox.rst:1512 +#: ../../library/mailbox.rst:1146 ../../library/mailbox.rst:1517 msgid "A" msgstr "A" -#: ../../library/mailbox.rst:1141 ../../library/mailbox.rst:1512 +#: ../../library/mailbox.rst:1146 ../../library/mailbox.rst:1517 msgid "Answered" msgstr "" -#: ../../library/mailbox.rst:1144 ../../library/mailbox.rst:1515 +#: ../../library/mailbox.rst:1149 ../../library/mailbox.rst:1520 msgid "" "The \"R\" and \"O\" flags are stored in the :mailheader:`Status` header, and " "the \"D\", \"F\", and \"A\" flags are stored in the :mailheader:`X-Status` " "header. The flags and headers typically appear in the order mentioned." msgstr "" -#: ../../library/mailbox.rst:1148 +#: ../../library/mailbox.rst:1153 msgid ":class:`!mboxMessage` instances offer the following methods:" msgstr ":class:`!mboxMessage` 實例提供以下方法:" -#: ../../library/mailbox.rst:1153 ../../library/mailbox.rst:1525 +#: ../../library/mailbox.rst:1158 ../../library/mailbox.rst:1530 msgid "" "Return a string representing the \"From \" line that marks the start of the " "message in an mbox mailbox. The leading \"From \" and the trailing newline " "are excluded." msgstr "" -#: ../../library/mailbox.rst:1160 ../../library/mailbox.rst:1532 +#: ../../library/mailbox.rst:1165 ../../library/mailbox.rst:1537 msgid "" "Set the \"From \" line to *from_*, which should be specified without a " "leading \"From \" or trailing newline. For convenience, *time_* may be " @@ -1495,7 +1507,7 @@ msgid "" "func:`time.gmtime`)." msgstr "" -#: ../../library/mailbox.rst:1170 ../../library/mailbox.rst:1542 +#: ../../library/mailbox.rst:1175 ../../library/mailbox.rst:1547 msgid "" "Return a string specifying the flags that are currently set. If the message " "complies with the conventional format, the result is the concatenation in " @@ -1503,28 +1515,28 @@ msgid "" "``'D'``, ``'F'``, and ``'A'``." msgstr "" -#: ../../library/mailbox.rst:1178 ../../library/mailbox.rst:1550 +#: ../../library/mailbox.rst:1183 ../../library/mailbox.rst:1555 msgid "" "Set the flags specified by *flags* and unset all others. Parameter *flags* " "should be the concatenation in any order of zero or more occurrences of each " "of ``'R'``, ``'O'``, ``'D'``, ``'F'``, and ``'A'``." msgstr "" -#: ../../library/mailbox.rst:1185 ../../library/mailbox.rst:1557 +#: ../../library/mailbox.rst:1190 ../../library/mailbox.rst:1562 msgid "" "Set the flag(s) specified by *flag* without changing other flags. To add " "more than one flag at a time, *flag* may be a string of more than one " "character." msgstr "" -#: ../../library/mailbox.rst:1192 ../../library/mailbox.rst:1564 +#: ../../library/mailbox.rst:1197 ../../library/mailbox.rst:1569 msgid "" "Unset the flag(s) specified by *flag* without changing other flags. To " "remove more than one flag at a time, *flag* may be a string of more than one " "character." msgstr "" -#: ../../library/mailbox.rst:1196 +#: ../../library/mailbox.rst:1201 msgid "" "When an :class:`!mboxMessage` instance is created based upon a :class:" "`MaildirMessage` instance, a \"From \" line is generated based upon the :" @@ -1532,50 +1544,50 @@ msgid "" "conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1202 ../../library/mailbox.rst:1317 -#: ../../library/mailbox.rst:1443 ../../library/mailbox.rst:1574 +#: ../../library/mailbox.rst:1207 ../../library/mailbox.rst:1322 +#: ../../library/mailbox.rst:1448 ../../library/mailbox.rst:1579 msgid ":class:`MaildirMessage` state" msgstr ":class:`MaildirMessage` 狀態" -#: ../../library/mailbox.rst:1215 +#: ../../library/mailbox.rst:1220 msgid "" "When an :class:`!mboxMessage` instance is created based upon an :class:" "`MHMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1221 ../../library/mailbox.rst:1236 -#: ../../library/mailbox.rst:1593 ../../library/mailbox.rst:1608 +#: ../../library/mailbox.rst:1226 ../../library/mailbox.rst:1241 +#: ../../library/mailbox.rst:1598 ../../library/mailbox.rst:1613 msgid "R flag and O flag" msgstr "R 旗標和 O 旗標" -#: ../../library/mailbox.rst:1230 +#: ../../library/mailbox.rst:1235 msgid "" "When an :class:`!mboxMessage` instance is created based upon a :class:" "`BabylMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1245 +#: ../../library/mailbox.rst:1250 msgid "" "When a :class:`!mboxMessage` instance is created based upon an :class:" "`MMDFMessage` instance, the \"From \" line is copied and all flags directly " "correspond:" msgstr "" -#: ../../library/mailbox.rst:1250 +#: ../../library/mailbox.rst:1255 msgid ":class:`MMDFMessage` state" msgstr ":class:`MMDFMessage` 狀態" -#: ../../library/mailbox.rst:1267 +#: ../../library/mailbox.rst:1272 msgid ":class:`!MHMessage` objects" msgstr ":class:`!MHMessage` 物件" -#: ../../library/mailbox.rst:1272 +#: ../../library/mailbox.rst:1277 msgid "" "A message with MH-specific behaviors. Parameter *message* has the same " "meaning as with the :class:`Message` constructor." msgstr "" -#: ../../library/mailbox.rst:1275 +#: ../../library/mailbox.rst:1280 msgid "" "MH messages do not support marks or flags in the traditional sense, but they " "do support sequences, which are logical groupings of arbitrary messages. " @@ -1584,57 +1596,57 @@ msgid "" "formats, as follows:" msgstr "" -#: ../../library/mailbox.rst:1282 +#: ../../library/mailbox.rst:1287 msgid "Sequence" msgstr "" -#: ../../library/mailbox.rst:1284 ../../library/mailbox.rst:1371 +#: ../../library/mailbox.rst:1289 ../../library/mailbox.rst:1376 msgid "unseen" msgstr "" -#: ../../library/mailbox.rst:1284 ../../library/mailbox.rst:1371 +#: ../../library/mailbox.rst:1289 ../../library/mailbox.rst:1376 msgid "Not read, but previously detected by MUA" msgstr "" -#: ../../library/mailbox.rst:1286 +#: ../../library/mailbox.rst:1291 msgid "replied" msgstr "" -#: ../../library/mailbox.rst:1288 +#: ../../library/mailbox.rst:1293 msgid "flagged" msgstr "" -#: ../../library/mailbox.rst:1291 +#: ../../library/mailbox.rst:1296 msgid ":class:`!MHMessage` instances offer the following methods:" msgstr ":class:`!MHMessage` 實例提供以下方法:" -#: ../../library/mailbox.rst:1296 +#: ../../library/mailbox.rst:1301 msgid "Return a list of the names of sequences that include this message." msgstr "" -#: ../../library/mailbox.rst:1301 +#: ../../library/mailbox.rst:1306 msgid "Set the list of sequences that include this message." msgstr "" -#: ../../library/mailbox.rst:1306 +#: ../../library/mailbox.rst:1311 msgid "Add *sequence* to the list of sequences that include this message." msgstr "" -#: ../../library/mailbox.rst:1311 +#: ../../library/mailbox.rst:1316 msgid "Remove *sequence* from the list of sequences that include this message." msgstr "" -#: ../../library/mailbox.rst:1313 +#: ../../library/mailbox.rst:1318 msgid "" "When an :class:`!MHMessage` instance is created based upon a :class:" "`MaildirMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1319 ../../library/mailbox.rst:1445 +#: ../../library/mailbox.rst:1324 ../../library/mailbox.rst:1450 msgid "no S flag" msgstr "無 S 旗標" -#: ../../library/mailbox.rst:1326 +#: ../../library/mailbox.rst:1331 msgid "" "When an :class:`!MHMessage` instance is created based upon an :class:" "`mboxMessage` or :class:`MMDFMessage` instance, the :mailheader:`Status` " @@ -1642,110 +1654,110 @@ msgid "" "take place:" msgstr "" -#: ../../library/mailbox.rst:1335 ../../library/mailbox.rst:1463 +#: ../../library/mailbox.rst:1340 ../../library/mailbox.rst:1468 msgid "no R flag" msgstr "無 R 旗標" -#: ../../library/mailbox.rst:1342 +#: ../../library/mailbox.rst:1347 msgid "" "When an :class:`!MHMessage` instance is created based upon a :class:" "`BabylMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1357 +#: ../../library/mailbox.rst:1362 msgid ":class:`!BabylMessage` objects" msgstr ":class:`!BabylMessage` 物件" -#: ../../library/mailbox.rst:1362 +#: ../../library/mailbox.rst:1367 msgid "" "A message with Babyl-specific behaviors. Parameter *message* has the same " "meaning as with the :class:`Message` constructor." msgstr "" -#: ../../library/mailbox.rst:1365 +#: ../../library/mailbox.rst:1370 msgid "" "Certain message labels, called :dfn:`attributes`, are defined by convention " "to have special meanings. The attributes are as follows:" msgstr "" -#: ../../library/mailbox.rst:1369 +#: ../../library/mailbox.rst:1374 msgid "Label" msgstr "" -#: ../../library/mailbox.rst:1373 +#: ../../library/mailbox.rst:1378 msgid "deleted" msgstr "" -#: ../../library/mailbox.rst:1375 +#: ../../library/mailbox.rst:1380 msgid "filed" msgstr "" -#: ../../library/mailbox.rst:1375 +#: ../../library/mailbox.rst:1380 msgid "Copied to another file or mailbox" msgstr "" -#: ../../library/mailbox.rst:1377 +#: ../../library/mailbox.rst:1382 msgid "answered" msgstr "" -#: ../../library/mailbox.rst:1379 +#: ../../library/mailbox.rst:1384 msgid "forwarded" msgstr "" -#: ../../library/mailbox.rst:1379 +#: ../../library/mailbox.rst:1384 msgid "Forwarded" msgstr "" -#: ../../library/mailbox.rst:1381 +#: ../../library/mailbox.rst:1386 msgid "edited" msgstr "" -#: ../../library/mailbox.rst:1381 +#: ../../library/mailbox.rst:1386 msgid "Modified by the user" msgstr "" -#: ../../library/mailbox.rst:1383 +#: ../../library/mailbox.rst:1388 msgid "resent" msgstr "" -#: ../../library/mailbox.rst:1383 +#: ../../library/mailbox.rst:1388 msgid "Resent" msgstr "" -#: ../../library/mailbox.rst:1386 +#: ../../library/mailbox.rst:1391 msgid "" "By default, Rmail displays only visible headers. The :class:`!BabylMessage` " "class, though, uses the original headers because they are more complete. " "Visible headers may be accessed explicitly if desired." msgstr "" -#: ../../library/mailbox.rst:1390 +#: ../../library/mailbox.rst:1395 msgid ":class:`!BabylMessage` instances offer the following methods:" msgstr ":class:`!BabylMessage` 實例提供以下方法:" -#: ../../library/mailbox.rst:1395 +#: ../../library/mailbox.rst:1400 msgid "Return a list of labels on the message." msgstr "" -#: ../../library/mailbox.rst:1400 +#: ../../library/mailbox.rst:1405 msgid "Set the list of labels on the message to *labels*." msgstr "" -#: ../../library/mailbox.rst:1405 +#: ../../library/mailbox.rst:1410 msgid "Add *label* to the list of labels on the message." msgstr "" -#: ../../library/mailbox.rst:1410 +#: ../../library/mailbox.rst:1415 msgid "Remove *label* from the list of labels on the message." msgstr "" -#: ../../library/mailbox.rst:1415 +#: ../../library/mailbox.rst:1420 msgid "" "Return a :class:`Message` instance whose headers are the message's visible " "headers and whose body is empty." msgstr "" -#: ../../library/mailbox.rst:1421 +#: ../../library/mailbox.rst:1426 msgid "" "Set the message's visible headers to be the same as the headers in " "*message*. Parameter *visible* should be a :class:`Message` instance, an :" @@ -1753,7 +1765,7 @@ msgid "" "(which should be open in text mode)." msgstr "" -#: ../../library/mailbox.rst:1429 +#: ../../library/mailbox.rst:1434 msgid "" "When a :class:`!BabylMessage` instance's original headers are modified, the " "visible headers are not automatically modified to correspond. This method " @@ -1766,17 +1778,17 @@ msgid "" "visible headers." msgstr "" -#: ../../library/mailbox.rst:1439 +#: ../../library/mailbox.rst:1444 msgid "" "When a :class:`!BabylMessage` instance is created based upon a :class:" "`MaildirMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1451 +#: ../../library/mailbox.rst:1456 msgid "\"forwarded\" label" msgstr "\"forwarded\" 標籤" -#: ../../library/mailbox.rst:1454 +#: ../../library/mailbox.rst:1459 msgid "" "When a :class:`!BabylMessage` instance is created based upon an :class:" "`mboxMessage` or :class:`MMDFMessage` instance, the :mailheader:`Status` " @@ -1784,23 +1796,23 @@ msgid "" "take place:" msgstr "" -#: ../../library/mailbox.rst:1470 +#: ../../library/mailbox.rst:1475 msgid "" "When a :class:`!BabylMessage` instance is created based upon an :class:" "`MHMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1485 +#: ../../library/mailbox.rst:1490 msgid ":class:`!MMDFMessage` objects" msgstr ":class:`!MMDFMessage` 物件" -#: ../../library/mailbox.rst:1490 +#: ../../library/mailbox.rst:1495 msgid "" "A message with MMDF-specific behaviors. Parameter *message* has the same " "meaning as with the :class:`Message` constructor." msgstr "" -#: ../../library/mailbox.rst:1493 +#: ../../library/mailbox.rst:1498 msgid "" "As with message in an mbox mailbox, MMDF messages are stored with the " "sender's address and the delivery date in an initial line beginning with " @@ -1808,19 +1820,19 @@ msgid "" "typically stored in :mailheader:`Status` and :mailheader:`X-Status` headers." msgstr "" -#: ../../library/mailbox.rst:1498 +#: ../../library/mailbox.rst:1503 msgid "" "Conventional flags for MMDF messages are identical to those of mbox message " "and are as follows:" msgstr "" -#: ../../library/mailbox.rst:1519 +#: ../../library/mailbox.rst:1524 msgid "" ":class:`!MMDFMessage` instances offer the following methods, which are " "identical to those offered by :class:`mboxMessage`:" msgstr "" -#: ../../library/mailbox.rst:1568 +#: ../../library/mailbox.rst:1573 msgid "" "When an :class:`!MMDFMessage` instance is created based upon a :class:" "`MaildirMessage` instance, a \"From \" line is generated based upon the :" @@ -1828,43 +1840,43 @@ msgid "" "conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1587 +#: ../../library/mailbox.rst:1592 msgid "" "When an :class:`!MMDFMessage` instance is created based upon an :class:" "`MHMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1602 +#: ../../library/mailbox.rst:1607 msgid "" "When an :class:`!MMDFMessage` instance is created based upon a :class:" "`BabylMessage` instance, the following conversions take place:" msgstr "" -#: ../../library/mailbox.rst:1617 +#: ../../library/mailbox.rst:1622 msgid "" "When an :class:`!MMDFMessage` instance is created based upon an :class:" "`mboxMessage` instance, the \"From \" line is copied and all flags directly " "correspond:" msgstr "" -#: ../../library/mailbox.rst:1622 +#: ../../library/mailbox.rst:1627 msgid ":class:`mboxMessage` state" msgstr ":class:`mboxMessage` 狀態" -#: ../../library/mailbox.rst:1637 +#: ../../library/mailbox.rst:1642 msgid "Exceptions" msgstr "例外" -#: ../../library/mailbox.rst:1639 +#: ../../library/mailbox.rst:1644 msgid "" "The following exception classes are defined in the :mod:`!mailbox` module:" msgstr "" -#: ../../library/mailbox.rst:1644 +#: ../../library/mailbox.rst:1649 msgid "The base class for all other module-specific exceptions." msgstr "" -#: ../../library/mailbox.rst:1649 +#: ../../library/mailbox.rst:1654 msgid "" "Raised when a mailbox is expected but is not found, such as when " "instantiating a :class:`Mailbox` subclass with a path that does not exist " @@ -1872,13 +1884,13 @@ msgid "" "that does not exist." msgstr "" -#: ../../library/mailbox.rst:1656 +#: ../../library/mailbox.rst:1661 msgid "" "Raised when a mailbox is not empty but is expected to be, such as when " "deleting a folder that contains messages." msgstr "" -#: ../../library/mailbox.rst:1662 +#: ../../library/mailbox.rst:1667 msgid "" "Raised when some mailbox-related condition beyond the control of the program " "causes it to be unable to proceed, such as when failing to acquire a lock " @@ -1886,23 +1898,23 @@ msgid "" "already exists." msgstr "" -#: ../../library/mailbox.rst:1670 +#: ../../library/mailbox.rst:1675 msgid "" "Raised when the data in a file cannot be parsed, such as when an :class:`MH` " "instance attempts to read a corrupted :file:`.mh_sequences` file." msgstr "" -#: ../../library/mailbox.rst:1677 +#: ../../library/mailbox.rst:1682 msgid "Examples" msgstr "範例" -#: ../../library/mailbox.rst:1679 +#: ../../library/mailbox.rst:1684 msgid "" "A simple example of printing the subjects of all messages in a mailbox that " "seem interesting::" msgstr "" -#: ../../library/mailbox.rst:1682 +#: ../../library/mailbox.rst:1687 msgid "" "import mailbox\n" "for message in mailbox.mbox('~/mbox'):\n" @@ -1916,13 +1928,13 @@ msgstr "" " if subject and 'python' in subject.lower():\n" " print(subject)" -#: ../../library/mailbox.rst:1688 +#: ../../library/mailbox.rst:1693 msgid "" "To copy all mail from a Babyl mailbox to an MH mailbox, converting all of " "the format-specific information that can be converted::" msgstr "" -#: ../../library/mailbox.rst:1691 +#: ../../library/mailbox.rst:1696 msgid "" "import mailbox\n" "destination = mailbox.MH('~/Mail')\n" @@ -1940,7 +1952,7 @@ msgstr "" "destination.flush()\n" "destination.unlock()" -#: ../../library/mailbox.rst:1699 +#: ../../library/mailbox.rst:1704 msgid "" "This example sorts mail from several mailing lists into different mailboxes, " "being careful to avoid mail corruption due to concurrent modification by " @@ -1948,7 +1960,7 @@ msgid "" "termination due to malformed messages in the mailbox::" msgstr "" -#: ../../library/mailbox.rst:1704 +#: ../../library/mailbox.rst:1709 msgid "" "import mailbox\n" "import email.errors\n" diff --git a/library/marshal.po b/library/marshal.po index d4255f425fd..070a53cdfa9 100644 --- a/library/marshal.po +++ b/library/marshal.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-04-24 21:28+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -99,44 +99,49 @@ msgstr "" #: ../../library/marshal.rst:54 msgid "" -"Containers: :class:`tuple`, :class:`list`, :class:`set`, :class:`frozenset`, " -"and (since :data:`version` 5), :class:`slice`. It should be understood that " +"Containers: :class:`tuple`, :class:`list`, :class:`dict`, :class:" +"`frozendict` (since :data:`version` 6), :class:`set`, :class:`frozenset`, " +"and :class:`slice` (since :data:`version` 5). It should be understood that " "these are supported only if the values contained therein are themselves " "supported. Recursive containers are supported since :data:`version` 3." msgstr "" -#: ../../library/marshal.rst:59 +#: ../../library/marshal.rst:60 msgid "" "The singletons :const:`None`, :const:`Ellipsis` and :exc:`StopIteration`." msgstr "" -#: ../../library/marshal.rst:60 +#: ../../library/marshal.rst:61 msgid "" ":class:`code` objects, if *allow_code* is true. See note above about version " "dependence." msgstr "" -#: ../../library/marshal.rst:65 +#: ../../library/marshal.rst:66 msgid "" "Added format version 3, which supports marshalling recursive lists, sets and " "dictionaries." msgstr "" -#: ../../library/marshal.rst:67 +#: ../../library/marshal.rst:68 msgid "" "Added format version 4, which supports efficient representations of short " "strings." msgstr "" -#: ../../library/marshal.rst:72 +#: ../../library/marshal.rst:73 msgid "Added format version 5, which allows marshalling slices." msgstr "" -#: ../../library/marshal.rst:75 +#: ../../library/marshal.rst:77 +msgid "Added format version 6, which allows marshalling :class:`frozendict`." +msgstr "" + +#: ../../library/marshal.rst:80 msgid "The module defines these functions:" msgstr "這個模組定義了以下函式:" -#: ../../library/marshal.rst:80 +#: ../../library/marshal.rst:85 msgid "" "Write the value on the open file. The value must be a supported type. The " "file must be a writeable :term:`binary file`." @@ -144,7 +149,7 @@ msgstr "" "將值寫入被開啟的檔案。值必須為受支援的型別,檔案必須為可寫入的 :term:`binary " "file`。" -#: ../../library/marshal.rst:83 +#: ../../library/marshal.rst:88 msgid "" "If the value has (or contains an object that has) an unsupported type, a :" "exc:`ValueError` exception is raised --- but garbage data will also be " @@ -157,13 +162,13 @@ msgstr "" "`load` 重新讀取。:ref:`程式碼物件 `\\ 只有在 *allow_code* 為 " "true 時才會支援。" -#: ../../library/marshal.rst:88 +#: ../../library/marshal.rst:93 msgid "" "The *version* argument indicates the data format that ``dump`` should use " "(see below)." msgstr "*version* 引數指明 ``dump`` 應該使用的資料格式(見下文)。" -#: ../../library/marshal.rst:91 ../../library/marshal.rst:131 +#: ../../library/marshal.rst:96 ../../library/marshal.rst:136 msgid "" "Raises an :ref:`auditing event ` ``marshal.dumps`` with arguments " "``value``, ``version``." @@ -171,12 +176,12 @@ msgstr "" "引發一個附帶引數 ``value`` 與 ``version`` 的\\ :ref:`稽核事件 (auditing " "event) ` ``marshal.dumps``。" -#: ../../library/marshal.rst:93 ../../library/marshal.rst:117 -#: ../../library/marshal.rst:133 ../../library/marshal.rst:151 +#: ../../library/marshal.rst:98 ../../library/marshal.rst:122 +#: ../../library/marshal.rst:138 ../../library/marshal.rst:156 msgid "Added the *allow_code* parameter." msgstr "新增 *allow_code* 參數。" -#: ../../library/marshal.rst:99 +#: ../../library/marshal.rst:104 msgid "" "Read one value from the open file and return it. If no valid value is read " "(e.g. because the data has a different Python version's incompatible marshal " @@ -189,13 +194,13 @@ msgstr "" "`ValueError` 或 :exc:`TypeError`。:ref:`程式碼物件 `\\ 只有在 " "*allow_code* 為 true 時才會支援。檔案必須為可讀取的 :term:`binary file`。" -#: ../../library/marshal.rst:105 +#: ../../library/marshal.rst:110 msgid "" "Raises an :ref:`auditing event ` ``marshal.load`` with no " "arguments." msgstr "引發一個沒有附帶引數的\\ :ref:`稽核事件 ` ``marshal.load``。" -#: ../../library/marshal.rst:109 +#: ../../library/marshal.rst:114 msgid "" "If an object containing an unsupported type was marshalled with :func:" "`dump`, :func:`load` will substitute ``None`` for the unmarshallable type." @@ -203,7 +208,7 @@ msgstr "" "如果透過 :func:`dump` marshal 了一個包含不支援型別的物件,:func:`load` 會將不" "可 marshal 的型別替換為 ``None``。" -#: ../../library/marshal.rst:114 +#: ../../library/marshal.rst:119 msgid "" "This call used to raise a ``code.__new__`` audit event for each code object. " "Now it raises a single ``marshal.load`` event for the entire load operation." @@ -211,7 +216,7 @@ msgstr "" "使用此呼叫為每個程式碼物件引發一個 ``code.__new__`` 稽核事件。現在它會為整個" "載入操作引發單個 ``marshal.load`` 事件。" -#: ../../library/marshal.rst:123 +#: ../../library/marshal.rst:128 msgid "" "Return the bytes object that would be written to a file by ``dump(value, " "file)``. The value must be a supported type. Raise a :exc:`ValueError` " @@ -224,13 +229,13 @@ msgstr "" "`ValueError`。:ref:`程式碼物件 `\\ 只有在 *allow_code* 為 true " "時才會支援。" -#: ../../library/marshal.rst:128 +#: ../../library/marshal.rst:133 msgid "" "The *version* argument indicates the data format that ``dumps`` should use " "(see below)." msgstr "*version* 引數指明 ``dumps`` 應當使用的資料型別(見下文)。" -#: ../../library/marshal.rst:139 +#: ../../library/marshal.rst:144 msgid "" "Convert the :term:`bytes-like object` to a value. If no valid value is " "found, raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. :ref:" @@ -242,7 +247,7 @@ msgstr "" "objects>`\\ 只有在 *allow_code* 為 true 時才會支援。輸入中額外的位元組串會被" "忽略。" -#: ../../library/marshal.rst:144 +#: ../../library/marshal.rst:149 msgid "" "Raises an :ref:`auditing event ` ``marshal.loads`` with argument " "``bytes``." @@ -250,7 +255,7 @@ msgstr "" "引發一個附帶引數 ``bytes`` 的\\ :ref:`稽核事件 ` ``marshal." "loads``。" -#: ../../library/marshal.rst:148 +#: ../../library/marshal.rst:153 msgid "" "This call used to raise a ``code.__new__`` audit event for each code object. " "Now it raises a single ``marshal.loads`` event for the entire load operation." @@ -258,11 +263,11 @@ msgstr "" "使用此呼叫為每個程式碼物件引發一個 ``code.__new__`` 稽核事件。現在它會為整個" "載入操作引發單個 ``marshal.loads`` 事件。" -#: ../../library/marshal.rst:155 +#: ../../library/marshal.rst:160 msgid "In addition, the following constants are defined:" msgstr "此外,還定義了以下常數:" -#: ../../library/marshal.rst:159 +#: ../../library/marshal.rst:164 msgid "" "Indicates the format that the module uses. Version 0 is the historical first " "version; subsequent versions add new features. Generally, a new version " @@ -271,79 +276,91 @@ msgstr "" "表示模組所使用的格式。第 0 版為歷史上第一版本;後續版本會新增功能。當引入新版" "本時,它通常會成為預設版本。" -#: ../../library/marshal.rst:165 +#: ../../library/marshal.rst:170 msgid "Version" msgstr "版本" -#: ../../library/marshal.rst:165 +#: ../../library/marshal.rst:170 msgid "Available since" msgstr "" -#: ../../library/marshal.rst:165 +#: ../../library/marshal.rst:170 msgid "New features" msgstr "" -#: ../../library/marshal.rst:167 +#: ../../library/marshal.rst:172 msgid "1" msgstr "1" -#: ../../library/marshal.rst:167 +#: ../../library/marshal.rst:172 msgid "Python 2.4" msgstr "Python 2.4" -#: ../../library/marshal.rst:167 +#: ../../library/marshal.rst:172 msgid "Sharing interned strings" msgstr "共享駐留字串" -#: ../../library/marshal.rst:169 +#: ../../library/marshal.rst:174 msgid "2" msgstr "2" -#: ../../library/marshal.rst:169 +#: ../../library/marshal.rst:174 msgid "Python 2.5" msgstr "Python 2.5" -#: ../../library/marshal.rst:169 +#: ../../library/marshal.rst:174 msgid "Binary representation of floats" msgstr "" -#: ../../library/marshal.rst:171 +#: ../../library/marshal.rst:176 msgid "3" msgstr "3" -#: ../../library/marshal.rst:171 ../../library/marshal.rst:173 +#: ../../library/marshal.rst:176 ../../library/marshal.rst:178 msgid "Python 3.4" msgstr "Python 3.4" -#: ../../library/marshal.rst:171 +#: ../../library/marshal.rst:176 msgid "Support for object instancing and recursion" msgstr "" -#: ../../library/marshal.rst:173 +#: ../../library/marshal.rst:178 msgid "4" msgstr "4" -#: ../../library/marshal.rst:173 +#: ../../library/marshal.rst:178 msgid "Efficient representation of short strings" msgstr "" -#: ../../library/marshal.rst:175 +#: ../../library/marshal.rst:180 msgid "5" msgstr "5" -#: ../../library/marshal.rst:175 +#: ../../library/marshal.rst:180 msgid "Python 3.14" msgstr "Python 3.14" -#: ../../library/marshal.rst:175 +#: ../../library/marshal.rst:180 msgid "Support for :class:`slice` objects" msgstr "" -#: ../../library/marshal.rst:180 +#: ../../library/marshal.rst:182 +msgid "6" +msgstr "6" + +#: ../../library/marshal.rst:182 +msgid "Python 3.15" +msgstr "Python 3.15" + +#: ../../library/marshal.rst:182 +msgid "Support for :class:`frozendict` objects" +msgstr "" + +#: ../../library/marshal.rst:187 msgid "Footnotes" msgstr "註解" -#: ../../library/marshal.rst:181 +#: ../../library/marshal.rst:188 msgid "" "The name of this module stems from a bit of terminology used by the " "designers of Modula-3 (amongst others), who use the term \"marshalling\" for " diff --git a/library/math.integer.po b/library/math.integer.po new file mode 100644 index 00000000000..b3cba4fafb4 --- /dev/null +++ b/library/math.integer.po @@ -0,0 +1,127 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../library/math.integer.rst:2 +msgid ":mod:`!math.integer` --- integer-specific mathematics functions" +msgstr "" + +#: ../../library/math.integer.rst:11 +msgid "" +"This module provides access to the mathematical functions defined for " +"integer arguments. These functions accept integers and objects that " +"implement the :meth:`~object.__index__` method which is used to convert the " +"object to an integer number." +msgstr "" + +#: ../../library/math.integer.rst:16 +msgid "" +"The following functions are provided by this module. All return values are " +"computed exactly and are integers." +msgstr "" + +#: ../../library/math.integer.rst:22 +msgid "" +"Return the number of ways to choose *k* items from *n* items without " +"repetition and without order." +msgstr "回傳從 *n* 個物品中不重複且不考慮排序地取出 *k* 個物品的方法數。" + +#: ../../library/math.integer.rst:25 +msgid "" +"Evaluates to ``n! / (k! * (n - k)!)`` when ``k <= n`` and evaluates to zero " +"when ``k > n``." +msgstr "當 ``k <= n`` 時其值為 ``n! / (k! * (n - k)!)``,否則其值為 ``0``。" + +#: ../../library/math.integer.rst:28 +msgid "" +"Also called the binomial coefficient because it is equivalent to the " +"coefficient of k-th term in polynomial expansion of ``(1 + x)ⁿ``." +msgstr "" +"因為此值等同於 ``(1 + x)ⁿ`` 進行多項式展開後第 k 項的係數,所以又稱為二項式係" +"數。" + +#: ../../library/math.integer.rst:32 ../../library/math.integer.rst:85 +msgid "Raises :exc:`ValueError` if either of the arguments are negative." +msgstr "" + +#: ../../library/math.integer.rst:37 +msgid "Return factorial of the nonnegative integer *n*." +msgstr "回傳非負整數 *n* 的階乘。" + +#: ../../library/math.integer.rst:42 +msgid "" +"Return the greatest common divisor of the specified integer arguments. If " +"any of the arguments is nonzero, then the returned value is the largest " +"positive integer that is a divisor of all arguments. If all arguments are " +"zero, then the returned value is ``0``. ``gcd()`` without arguments returns " +"``0``." +msgstr "" +"回傳指定整數引數的最大公因數。若存在任一非零引數,回傳值為所有引數共有因數中" +"最大的正整數。若所有引數皆為零,則回傳值為 ``0``。``gcd()`` 若未傳入任何引數" +"也將回傳 ``0``。" + +#: ../../library/math.integer.rst:51 +msgid "" +"Return the integer square root of the nonnegative integer *n*. This is the " +"floor of the exact square root of *n*, or equivalently the greatest integer " +"*a* such that *a*\\ ² |nbsp| ≤ |nbsp| *n*." +msgstr "" +"回傳非負整數 *n* 的整數平方根。此值為 *n* 精確平方根經下取整的值,亦等同於滿" +"足 *a*\\ ² |nbsp| ≤ |nbsp| *n* 的最大整數值 *a*。" + +#: ../../library/math.integer.rst:55 +msgid "" +"For some applications, it may be more convenient to have the least integer " +"*a* such that *n* |nbsp| ≤ |nbsp| *a*\\ ², or in other words the ceiling of " +"the exact square root of *n*. For positive *n*, this can be computed using " +"``a = 1 + isqrt(n - 1)``." +msgstr "" +"於有些應用程式中,取得滿足 *n* |nbsp| ≤ |nbsp| *a*\\ ² 的最小整數值 *a* ── 或" +"者說 *n* 精確平方根經上取整的值 ── 會更加方便。對正數 *n*,此值可使用 ``a = " +"1 + isqrt(n - 1)`` 計算。" + +#: ../../library/math.integer.rst:67 +msgid "" +"Return the least common multiple of the specified integer arguments. If all " +"arguments are nonzero, then the returned value is the smallest positive " +"integer that is a multiple of all arguments. If any of the arguments is " +"zero, then the returned value is ``0``. ``lcm()`` without arguments returns " +"``1``." +msgstr "" +"回傳指定整數引數的最小公倍數。若所有引數值皆非零,回傳值為所有引數共有倍數中" +"最小的正整數。若存在任一引數值為零,則回傳值為 ``0``。``lcm()`` 若未傳入任何" +"引數將回傳 ``1``。" + +#: ../../library/math.integer.rst:76 +msgid "" +"Return the number of ways to choose *k* items from *n* items without " +"repetition and with order." +msgstr "回傳從 *n* 個物品中不重複且考慮排序地取出 *k* 個物品的方法數。" + +#: ../../library/math.integer.rst:79 +msgid "" +"Evaluates to ``n! / (n - k)!`` when ``k <= n`` and evaluates to zero when " +"``k > n``." +msgstr "當 ``k <= n`` 時其值為 ``n! / (n - k)!``,否則其值為 ``0``。" + +#: ../../library/math.integer.rst:82 +msgid "" +"If *k* is not specified or is ``None``, then *k* defaults to *n* and the " +"function returns ``n!``." +msgstr "" +"若未給定 *k* 或其值為 ``None``,則 *k* 值預設為 *n*,且函式回傳 ``n!``。" \ No newline at end of file diff --git a/library/math.po b/library/math.po index c0be65a9cd2..22cac56284b 100644 --- a/library/math.po +++ b/library/math.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-01 00:42+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-10-06 23:31+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -51,485 +51,469 @@ msgid "" msgstr "此模組提供下列函式。除非特意註明,否則回傳值皆為浮點數。" #: ../../library/math.rst:30 -msgid "**Number-theoretic functions**" -msgstr "**數論函式**" - -#: ../../library/math.rst:32 -msgid ":func:`comb(n, k) `" -msgstr ":func:`comb(n, k) `" - -#: ../../library/math.rst:32 -msgid "" -"Number of ways to choose *k* items from *n* items without repetition and " -"without order" -msgstr "從 *n* 個物品中不重複且不考慮排序地取出 *k* 個物品的方法數。" - -#: ../../library/math.rst:33 -msgid ":func:`factorial(n) `" -msgstr ":func:`factorial(n) `" - -#: ../../library/math.rst:33 -msgid "*n* factorial" -msgstr "*n* 的階乘" - -#: ../../library/math.rst:34 -msgid ":func:`gcd(*integers) `" -msgstr ":func:`gcd(*integers) `" - -#: ../../library/math.rst:34 -msgid "Greatest common divisor of the integer arguments" -msgstr "整數引數的最大公因數" - -#: ../../library/math.rst:35 -msgid ":func:`isqrt(n) `" -msgstr ":func:`isqrt(n) `" - -#: ../../library/math.rst:35 -msgid "Integer square root of a nonnegative integer *n*" -msgstr "非負整數 *n* 的整數平方根" - -#: ../../library/math.rst:36 -msgid ":func:`lcm(*integers) `" -msgstr ":func:`lcm(*integers) `" - -#: ../../library/math.rst:36 -msgid "Least common multiple of the integer arguments" -msgstr "整數引數的最小公倍數" - -#: ../../library/math.rst:37 -msgid ":func:`perm(n, k) `" -msgstr ":func:`perm(n, k) `" - -#: ../../library/math.rst:37 -msgid "" -"Number of ways to choose *k* items from *n* items without repetition and " -"with order" -msgstr "從 *n* 個物品中不重複但考慮排序地取出 *k* 個物品的方法數。" - -#: ../../library/math.rst:39 msgid "**Floating point arithmetic**" msgstr "**浮點數算術運算**" -#: ../../library/math.rst:41 +#: ../../library/math.rst:32 msgid ":func:`ceil(x) `" msgstr ":func:`ceil(x) `" -#: ../../library/math.rst:41 +#: ../../library/math.rst:32 msgid "Ceiling of *x*, the smallest integer greater than or equal to *x*" msgstr "*x* 的上取整值,即大於或等於 *x* 的最小整數" -#: ../../library/math.rst:42 +#: ../../library/math.rst:33 msgid ":func:`fabs(x) `" msgstr ":func:`fabs(x) `" -#: ../../library/math.rst:42 +#: ../../library/math.rst:33 msgid "Absolute value of *x*" msgstr "*x* 的絕對值。" -#: ../../library/math.rst:43 +#: ../../library/math.rst:34 msgid ":func:`floor(x) `" msgstr ":func:`floor(x) `" -#: ../../library/math.rst:43 +#: ../../library/math.rst:34 msgid "Floor of *x*, the largest integer less than or equal to *x*" msgstr "*x* 的下取整值,即小於或等於 *x* 的最大整數" -#: ../../library/math.rst:44 +#: ../../library/math.rst:35 msgid ":func:`fma(x, y, z) `" msgstr ":func:`fma(x, y, z) `" -#: ../../library/math.rst:44 +#: ../../library/math.rst:35 msgid "Fused multiply-add operation: ``(x * y) + z``" msgstr "融合乘加運算:``(x * y) + z``" -#: ../../library/math.rst:45 +#: ../../library/math.rst:36 +msgid ":func:`fmax(x, y) `" +msgstr ":func:`fmax(x, y) `" + +#: ../../library/math.rst:36 +msgid "Maximum of two floating-point values" +msgstr "" + +#: ../../library/math.rst:37 +msgid ":func:`fmin(x, y) `" +msgstr ":func:`fmin(x, y) `" + +#: ../../library/math.rst:37 +msgid "Minimum of two floating-point values" +msgstr "" + +#: ../../library/math.rst:38 msgid ":func:`fmod(x, y) `" msgstr ":func:`fmod(x, y) `" -#: ../../library/math.rst:45 +#: ../../library/math.rst:38 msgid "Remainder of division ``x / y``" msgstr "除法 ``x / y`` 的餘數" -#: ../../library/math.rst:46 +#: ../../library/math.rst:39 msgid ":func:`modf(x) `" msgstr ":func:`modf(x) `" -#: ../../library/math.rst:46 +#: ../../library/math.rst:39 msgid "Fractional and integer parts of *x*" msgstr "*x* 的小數部分與整數部分" -#: ../../library/math.rst:47 +#: ../../library/math.rst:40 msgid ":func:`remainder(x, y) `" msgstr ":func:`remainder(x, y) `" -#: ../../library/math.rst:47 +#: ../../library/math.rst:40 msgid "Remainder of *x* with respect to *y*" msgstr "*x* 相對於 *y* 的餘數" -#: ../../library/math.rst:48 +#: ../../library/math.rst:41 msgid ":func:`trunc(x) `" msgstr ":func:`trunc(x) `" -#: ../../library/math.rst:48 +#: ../../library/math.rst:41 msgid "Integer part of *x*" msgstr "*x* 的整數部分" -#: ../../library/math.rst:50 +#: ../../library/math.rst:43 msgid "**Floating point manipulation functions**" msgstr "**浮點數操作函式**" -#: ../../library/math.rst:52 +#: ../../library/math.rst:45 msgid ":func:`copysign(x, y) `" msgstr ":func:`copysign(x, y) `" -#: ../../library/math.rst:52 +#: ../../library/math.rst:45 msgid "Magnitude (absolute value) of *x* with the sign of *y*" msgstr "帶有 *y* 的正負號的 *x* 的量值(絕對值)" -#: ../../library/math.rst:53 +#: ../../library/math.rst:46 msgid ":func:`frexp(x) `" msgstr ":func:`frexp(x) `" -#: ../../library/math.rst:53 +#: ../../library/math.rst:46 msgid "Mantissa and exponent of *x*" msgstr "*x* 的尾數與指數" -#: ../../library/math.rst:54 +#: ../../library/math.rst:47 msgid ":func:`isclose(a, b, rel_tol, abs_tol) `" msgstr ":func:`isclose(a, b, rel_tol, abs_tol) `" -#: ../../library/math.rst:54 +#: ../../library/math.rst:47 msgid "Check if the values *a* and *b* are close to each other" msgstr "檢查 *a* 與 *b* 兩值是否足夠接近" -#: ../../library/math.rst:55 +#: ../../library/math.rst:48 msgid ":func:`isfinite(x) `" msgstr ":func:`isfinite(x) `" -#: ../../library/math.rst:55 +#: ../../library/math.rst:48 msgid "Check if *x* is neither an infinity nor a NaN" msgstr "檢查 *x* 是否既非無限值也非 NaN" -#: ../../library/math.rst:56 +#: ../../library/math.rst:49 +msgid ":func:`isnormal(x) `" +msgstr ":func:`isnormal(x) `" + +#: ../../library/math.rst:49 +msgid "Check if *x* is a normal number" +msgstr "檢查 *x* 是否為正規數" + +#: ../../library/math.rst:50 +msgid ":func:`issubnormal(x) `" +msgstr ":func:`issubnormal(x) `" + +#: ../../library/math.rst:50 +msgid "Check if *x* is a subnormal number" +msgstr "檢查 *x* 是否為次正規數" + +#: ../../library/math.rst:51 msgid ":func:`isinf(x) `" msgstr ":func:`isinf(x) `" -#: ../../library/math.rst:56 +#: ../../library/math.rst:51 msgid "Check if *x* is a positive or negative infinity" msgstr "檢查 *x* 是否為正無限或負無限" -#: ../../library/math.rst:57 +#: ../../library/math.rst:52 msgid ":func:`isnan(x) `" msgstr ":func:`isnan(x) `" -#: ../../library/math.rst:57 +#: ../../library/math.rst:52 msgid "Check if *x* is a NaN (not a number)" msgstr "檢查 *x* 是否為 NaN(非數值)" -#: ../../library/math.rst:58 +#: ../../library/math.rst:53 msgid ":func:`ldexp(x, i) `" msgstr ":func:`ldexp(x, i) `" -#: ../../library/math.rst:58 +#: ../../library/math.rst:53 msgid "``x * (2**i)``, inverse of function :func:`frexp`" msgstr "``x * (2**i)``,:func:`frexp` 的反函式" -#: ../../library/math.rst:59 +#: ../../library/math.rst:54 msgid ":func:`nextafter(x, y, steps) `" msgstr ":func:`nextafter(x, y, steps) `" -#: ../../library/math.rst:59 +#: ../../library/math.rst:54 msgid "Floating-point value *steps* steps after *x* towards *y*" msgstr "從 *x* 向 *y* 移動 *steps* 步的浮點數值" -#: ../../library/math.rst:60 +#: ../../library/math.rst:55 +msgid ":func:`signbit(x) `" +msgstr ":func:`signbit(x) `" + +#: ../../library/math.rst:55 +msgid "Check if *x* is a negative number" +msgstr "檢查 *x* 是否為負數" + +#: ../../library/math.rst:56 msgid ":func:`ulp(x) `" msgstr ":func:`ulp(x) `" -#: ../../library/math.rst:60 +#: ../../library/math.rst:56 msgid "Value of the least significant bit of *x*" msgstr "*x* 的最低有效位元的值" -#: ../../library/math.rst:62 +#: ../../library/math.rst:58 msgid "**Power, exponential and logarithmic functions**" msgstr "**次方、指數與對數函式**" -#: ../../library/math.rst:64 +#: ../../library/math.rst:60 msgid ":func:`cbrt(x) `" msgstr ":func:`cbrt(x) `" -#: ../../library/math.rst:64 +#: ../../library/math.rst:60 msgid "Cube root of *x*" msgstr "*x* 的立方根" -#: ../../library/math.rst:65 +#: ../../library/math.rst:61 msgid ":func:`exp(x) `" msgstr ":func:`exp(x) `" -#: ../../library/math.rst:65 +#: ../../library/math.rst:61 msgid "*e* raised to the power *x*" msgstr "*e* 的 *x* 次方" -#: ../../library/math.rst:66 +#: ../../library/math.rst:62 msgid ":func:`exp2(x) `" msgstr ":func:`exp2(x) `" -#: ../../library/math.rst:66 +#: ../../library/math.rst:62 msgid "*2* raised to the power *x*" msgstr "*2* 的 *x* 次方" -#: ../../library/math.rst:67 +#: ../../library/math.rst:63 msgid ":func:`expm1(x) `" msgstr ":func:`expm1(x) `" -#: ../../library/math.rst:67 +#: ../../library/math.rst:63 msgid "*e* raised to the power *x*, minus 1" msgstr "*e* 的 *x* 次方減 1" -#: ../../library/math.rst:68 +#: ../../library/math.rst:64 msgid ":func:`log(x, base) `" msgstr ":func:`log(x, base) `" -#: ../../library/math.rst:68 +#: ../../library/math.rst:64 msgid "Logarithm of *x* to the given base (*e* by default)" msgstr "*x* 以給定底數(預設為 *e*)的對數" -#: ../../library/math.rst:69 +#: ../../library/math.rst:65 msgid ":func:`log1p(x) `" msgstr ":func:`log1p(x) `" -#: ../../library/math.rst:69 +#: ../../library/math.rst:65 msgid "Natural logarithm of *1+x* (base *e*)" msgstr "*1+x* 的自然對數(以 *e* 為底)" -#: ../../library/math.rst:70 +#: ../../library/math.rst:66 msgid ":func:`log2(x) `" msgstr ":func:`log2(x) `" -#: ../../library/math.rst:70 +#: ../../library/math.rst:66 msgid "Base-2 logarithm of *x*" msgstr "*x* 的以 2 為底的對數" -#: ../../library/math.rst:71 +#: ../../library/math.rst:67 msgid ":func:`log10(x) `" msgstr ":func:`log10(x) `" -#: ../../library/math.rst:71 +#: ../../library/math.rst:67 msgid "Base-10 logarithm of *x*" msgstr "*x* 的以 10 為底的對數" -#: ../../library/math.rst:72 +#: ../../library/math.rst:68 msgid ":func:`pow(x, y) `" msgstr ":func:`pow(x, y) `" -#: ../../library/math.rst:72 +#: ../../library/math.rst:68 msgid "*x* raised to the power *y*" msgstr "*x* 的 *y* 次方" -#: ../../library/math.rst:73 +#: ../../library/math.rst:69 msgid ":func:`sqrt(x) `" msgstr ":func:`sqrt(x) `" -#: ../../library/math.rst:73 +#: ../../library/math.rst:69 msgid "Square root of *x*" msgstr "*x* 的平方根" -#: ../../library/math.rst:75 +#: ../../library/math.rst:71 msgid "**Summation and product functions**" msgstr "**總和與乘積函式**" -#: ../../library/math.rst:77 +#: ../../library/math.rst:73 msgid ":func:`dist(p, q) `" msgstr ":func:`dist(p, q) `" -#: ../../library/math.rst:77 +#: ../../library/math.rst:73 msgid "" "Euclidean distance between two points *p* and *q* given as an iterable of " "coordinates" msgstr "兩點 *p* 與 *q* 之間的歐幾里得距離,各點以座標的可疊代物件表示" -#: ../../library/math.rst:78 +#: ../../library/math.rst:74 msgid ":func:`fsum(iterable) `" msgstr ":func:`fsum(iterable) `" -#: ../../library/math.rst:78 +#: ../../library/math.rst:74 msgid "Sum of values in the input *iterable*" msgstr "輸入 *iterable* 中所有值的總和" -#: ../../library/math.rst:79 +#: ../../library/math.rst:75 msgid ":func:`hypot(*coordinates) `" msgstr ":func:`hypot(*coordinates) `" -#: ../../library/math.rst:79 +#: ../../library/math.rst:75 msgid "Euclidean norm of an iterable of coordinates" msgstr "座標可疊代物件的歐幾里得範數" -#: ../../library/math.rst:80 +#: ../../library/math.rst:76 msgid ":func:`prod(iterable, start) `" msgstr ":func:`prod(iterable, start) `" -#: ../../library/math.rst:80 +#: ../../library/math.rst:76 msgid "Product of elements in the input *iterable* with a *start* value" msgstr "輸入 *iterable* 中所有元素與 *start* 起始值的乘積" -#: ../../library/math.rst:81 +#: ../../library/math.rst:77 msgid ":func:`sumprod(p, q) `" msgstr ":func:`sumprod(p, q) `" -#: ../../library/math.rst:81 +#: ../../library/math.rst:77 msgid "Sum of products from two iterables *p* and *q*" msgstr "兩個可疊代物件 *p* 與 *q* 各元素乘積的總和" -#: ../../library/math.rst:83 +#: ../../library/math.rst:79 msgid "**Angular conversion**" msgstr "**角度轉換**" -#: ../../library/math.rst:85 +#: ../../library/math.rst:81 msgid ":func:`degrees(x) `" msgstr ":func:`degrees(x) `" -#: ../../library/math.rst:85 +#: ../../library/math.rst:81 msgid "Convert angle *x* from radians to degrees" msgstr "將角度 *x* 從弧度轉換為度" -#: ../../library/math.rst:86 +#: ../../library/math.rst:82 msgid ":func:`radians(x) `" msgstr ":func:`radians(x) `" -#: ../../library/math.rst:86 +#: ../../library/math.rst:82 msgid "Convert angle *x* from degrees to radians" msgstr "將角度 *x* 從度轉換為弧度" -#: ../../library/math.rst:88 +#: ../../library/math.rst:84 msgid "**Trigonometric functions**" msgstr "**三角函式**" -#: ../../library/math.rst:90 +#: ../../library/math.rst:86 msgid ":func:`acos(x) `" msgstr ":func:`acos(x) `" -#: ../../library/math.rst:90 +#: ../../library/math.rst:86 msgid "Arc cosine of *x*" msgstr "*x* 的反餘弦" -#: ../../library/math.rst:91 +#: ../../library/math.rst:87 msgid ":func:`asin(x) `" msgstr ":func:`asin(x) `" -#: ../../library/math.rst:91 +#: ../../library/math.rst:87 msgid "Arc sine of *x*" msgstr "*x* 的反正弦" -#: ../../library/math.rst:92 +#: ../../library/math.rst:88 msgid ":func:`atan(x) `" msgstr ":func:`atan(x) `" -#: ../../library/math.rst:92 +#: ../../library/math.rst:88 msgid "Arc tangent of *x*" msgstr "*x* 的反正切" -#: ../../library/math.rst:93 +#: ../../library/math.rst:89 msgid ":func:`atan2(y, x) `" msgstr ":func:`atan2(y, x) `" -#: ../../library/math.rst:93 +#: ../../library/math.rst:89 msgid "``atan(y / x)``" msgstr "``atan(y / x)``" -#: ../../library/math.rst:94 +#: ../../library/math.rst:90 msgid ":func:`cos(x) `" msgstr ":func:`cos(x) `" -#: ../../library/math.rst:94 +#: ../../library/math.rst:90 msgid "Cosine of *x*" msgstr "*x* 的餘弦" -#: ../../library/math.rst:95 +#: ../../library/math.rst:91 msgid ":func:`sin(x) `" msgstr ":func:`sin(x) `" -#: ../../library/math.rst:95 +#: ../../library/math.rst:91 msgid "Sine of *x*" msgstr "*x* 的正弦" -#: ../../library/math.rst:96 +#: ../../library/math.rst:92 msgid ":func:`tan(x) `" msgstr ":func:`tan(x) `" -#: ../../library/math.rst:96 +#: ../../library/math.rst:92 msgid "Tangent of *x*" msgstr "*x* 的正切" -#: ../../library/math.rst:98 +#: ../../library/math.rst:94 msgid "**Hyperbolic functions**" msgstr "**雙曲函式**" -#: ../../library/math.rst:100 +#: ../../library/math.rst:96 msgid ":func:`acosh(x) `" msgstr ":func:`acosh(x) `" -#: ../../library/math.rst:100 +#: ../../library/math.rst:96 msgid "Inverse hyperbolic cosine of *x*" msgstr "*x* 的反雙曲餘弦" -#: ../../library/math.rst:101 +#: ../../library/math.rst:97 msgid ":func:`asinh(x) `" msgstr ":func:`asinh(x) `" -#: ../../library/math.rst:101 +#: ../../library/math.rst:97 msgid "Inverse hyperbolic sine of *x*" msgstr "*x* 的反雙曲正弦" -#: ../../library/math.rst:102 +#: ../../library/math.rst:98 msgid ":func:`atanh(x) `" msgstr ":func:`atanh(x) `" -#: ../../library/math.rst:102 +#: ../../library/math.rst:98 msgid "Inverse hyperbolic tangent of *x*" msgstr "*x* 的反雙曲正切" -#: ../../library/math.rst:103 +#: ../../library/math.rst:99 msgid ":func:`cosh(x) `" msgstr ":func:`cosh(x) `" -#: ../../library/math.rst:103 +#: ../../library/math.rst:99 msgid "Hyperbolic cosine of *x*" msgstr "*x* 的雙曲餘弦" -#: ../../library/math.rst:104 +#: ../../library/math.rst:100 msgid ":func:`sinh(x) `" msgstr ":func:`sinh(x) `" -#: ../../library/math.rst:104 +#: ../../library/math.rst:100 msgid "Hyperbolic sine of *x*" msgstr "*x* 的雙曲正弦" -#: ../../library/math.rst:105 +#: ../../library/math.rst:101 msgid ":func:`tanh(x) `" msgstr ":func:`tanh(x) `" -#: ../../library/math.rst:105 +#: ../../library/math.rst:101 msgid "Hyperbolic tangent of *x*" msgstr "*x* 的雙曲正切" -#: ../../library/math.rst:107 +#: ../../library/math.rst:103 msgid "**Special functions**" msgstr "**特殊函式**" -#: ../../library/math.rst:109 +#: ../../library/math.rst:105 msgid ":func:`erf(x) `" msgstr ":func:`erf(x) `" -#: ../../library/math.rst:109 +#: ../../library/math.rst:105 msgid "`Error function `_ at *x*" msgstr "" "在 *x* 處的\\ `誤差函式 `_\\ 值" -#: ../../library/math.rst:110 +#: ../../library/math.rst:106 msgid ":func:`erfc(x) `" msgstr ":func:`erfc(x) `" -#: ../../library/math.rst:110 +#: ../../library/math.rst:106 msgid "" "`Complementary error function `_ at *x*" @@ -537,20 +521,20 @@ msgstr "" "在 *x* 處的\\ `互補誤差函式 `_\\ 值" -#: ../../library/math.rst:111 +#: ../../library/math.rst:107 msgid ":func:`gamma(x) `" msgstr ":func:`gamma(x) `" -#: ../../library/math.rst:111 +#: ../../library/math.rst:107 msgid "`Gamma function `_ at *x*" msgstr "" "在 *x* 處的 `Gamma 函式 `_\\ 值" -#: ../../library/math.rst:112 +#: ../../library/math.rst:108 msgid ":func:`lgamma(x) `" msgstr ":func:`lgamma(x) `" -#: ../../library/math.rst:112 +#: ../../library/math.rst:108 msgid "" "Natural logarithm of the absolute value of the `Gamma function `_ at *x*" @@ -558,164 +542,55 @@ msgstr "" "在 *x* 處的 `Gamma 函式 `_\\ 絕" "對值的自然對數" -#: ../../library/math.rst:114 +#: ../../library/math.rst:110 msgid "**Constants**" msgstr "**常數**" -#: ../../library/math.rst:116 +#: ../../library/math.rst:112 msgid ":data:`pi`" msgstr ":data:`pi`" -#: ../../library/math.rst:116 +#: ../../library/math.rst:112 msgid "*π* = 3.141592..." msgstr "*π* = 3.141592..." -#: ../../library/math.rst:117 +#: ../../library/math.rst:113 msgid ":data:`e`" msgstr ":data:`e`" -#: ../../library/math.rst:117 +#: ../../library/math.rst:113 msgid "*e* = 2.718281..." msgstr "*e* = 2.718281..." -#: ../../library/math.rst:118 +#: ../../library/math.rst:114 msgid ":data:`tau`" msgstr ":data:`tau`" -#: ../../library/math.rst:118 +#: ../../library/math.rst:114 msgid "*τ* = 2\\ *π* = 6.283185..." msgstr "*τ* = 2\\ *π* = 6.283185..." -#: ../../library/math.rst:119 +#: ../../library/math.rst:115 msgid ":data:`inf`" msgstr ":data:`inf`" -#: ../../library/math.rst:119 +#: ../../library/math.rst:115 msgid "Positive infinity" msgstr "正無限大" -#: ../../library/math.rst:120 +#: ../../library/math.rst:116 msgid ":data:`nan`" msgstr ":data:`nan`" -#: ../../library/math.rst:120 +#: ../../library/math.rst:116 msgid "\"Not a number\" (NaN)" msgstr "「非數值」(NaN)" -#: ../../library/math.rst:125 -msgid "Number-theoretic functions" -msgstr "數論函式" - -#: ../../library/math.rst:129 -msgid "" -"Return the number of ways to choose *k* items from *n* items without " -"repetition and without order." -msgstr "回傳從 *n* 個物品中不重複且不考慮排序地取出 *k* 個物品的方法數。" - -#: ../../library/math.rst:132 -msgid "" -"Evaluates to ``n! / (k! * (n - k)!)`` when ``k <= n`` and evaluates to zero " -"when ``k > n``." -msgstr "當 ``k <= n`` 時其值為 ``n! / (k! * (n - k)!)``,否則其值為 ``0``。" - -#: ../../library/math.rst:135 -msgid "" -"Also called the binomial coefficient because it is equivalent to the " -"coefficient of k-th term in polynomial expansion of ``(1 + x)ⁿ``." -msgstr "" -"因為此值等同於 ``(1 + x)ⁿ`` 進行多項式展開後第 k 項的係數,所以又稱為二項式係" -"數。" - -#: ../../library/math.rst:139 ../../library/math.rst:204 -msgid "" -"Raises :exc:`TypeError` if either of the arguments are not integers. Raises :" -"exc:`ValueError` if either of the arguments are negative." -msgstr "" -"當任一參數非整數型別時會引發 :exc:`TypeError`。當任一參數為負數時會引發 :exc:" -"`ValueError`。" - -#: ../../library/math.rst:147 -msgid "Return factorial of the nonnegative integer *n*." -msgstr "回傳非負整數 *n* 的階乘。" - -#: ../../library/math.rst:149 -msgid "Floats with integral values (like ``5.0``) are no longer accepted." -msgstr "現在已經不允許傳入其值為整數的浮點數(如:``5.0``)。" - -#: ../../library/math.rst:155 -msgid "" -"Return the greatest common divisor of the specified integer arguments. If " -"any of the arguments is nonzero, then the returned value is the largest " -"positive integer that is a divisor of all arguments. If all arguments are " -"zero, then the returned value is ``0``. ``gcd()`` without arguments returns " -"``0``." -msgstr "" -"回傳指定整數引數的最大公因數。若存在任一非零引數,回傳值為所有引數共有因數中" -"最大的正整數。若所有引數皆為零,則回傳值為 ``0``。``gcd()`` 若未傳入任何引數" -"也將回傳 ``0``。" - -#: ../../library/math.rst:163 -msgid "" -"Added support for an arbitrary number of arguments. Formerly, only two " -"arguments were supported." -msgstr "新增支援任意數量的引數。先前僅支援兩個引數。" - -#: ../../library/math.rst:170 -msgid "" -"Return the integer square root of the nonnegative integer *n*. This is the " -"floor of the exact square root of *n*, or equivalently the greatest integer " -"*a* such that *a*\\ ² |nbsp| ≤ |nbsp| *n*." -msgstr "" -"回傳非負整數 *n* 的整數平方根。此值為 *n* 精確平方根經下取整的值,亦等同於滿" -"足 *a*\\ ² |nbsp| ≤ |nbsp| *n* 的最大整數值 *a*。" - -#: ../../library/math.rst:174 -msgid "" -"For some applications, it may be more convenient to have the least integer " -"*a* such that *n* |nbsp| ≤ |nbsp| *a*\\ ², or in other words the ceiling of " -"the exact square root of *n*. For positive *n*, this can be computed using " -"``a = 1 + isqrt(n - 1)``." -msgstr "" -"於有些應用程式中,取得滿足 *n* |nbsp| ≤ |nbsp| *a*\\ ² 的最小整數值 *a* ── 或" -"者說 *n* 精確平方根經上取整的值 ── 會更加方便。對正數 *n*,此值可使用 ``a = " -"1 + isqrt(n - 1)`` 計算。" - -#: ../../library/math.rst:184 -msgid "" -"Return the least common multiple of the specified integer arguments. If all " -"arguments are nonzero, then the returned value is the smallest positive " -"integer that is a multiple of all arguments. If any of the arguments is " -"zero, then the returned value is ``0``. ``lcm()`` without arguments returns " -"``1``." -msgstr "" -"回傳指定整數引數的最小公倍數。若所有引數值皆非零,回傳值為所有引數共有倍數中" -"最小的正整數。若存在任一引數值為零,則回傳值為 ``0``。``lcm()`` 若未傳入任何" -"引數將回傳 ``1``。" - -#: ../../library/math.rst:195 -msgid "" -"Return the number of ways to choose *k* items from *n* items without " -"repetition and with order." -msgstr "回傳從 *n* 個物品中不重複且考慮排序地取出 *k* 個物品的方法數。" - -#: ../../library/math.rst:198 -msgid "" -"Evaluates to ``n! / (n - k)!`` when ``k <= n`` and evaluates to zero when " -"``k > n``." -msgstr "當 ``k <= n`` 時其值為 ``n! / (n - k)!``,否則其值為 ``0``。" - -#: ../../library/math.rst:201 -msgid "" -"If *k* is not specified or is ``None``, then *k* defaults to *n* and the " -"function returns ``n!``." -msgstr "" -"若未給定 *k* 或其值為 ``None``,則 *k* 值預設為 *n*,且函式回傳 ``n!``。" - -#: ../../library/math.rst:211 +#: ../../library/math.rst:121 msgid "Floating point arithmetic" msgstr "浮點數算術運算" -#: ../../library/math.rst:215 +#: ../../library/math.rst:125 msgid "" "Return the ceiling of *x*, the smallest integer greater than or equal to " "*x*. If *x* is not a float, delegates to :meth:`x.__ceil__ `,並回傳 :class:`~numbers." "Integral` 型別的值。" -#: ../../library/math.rst:222 +#: ../../library/math.rst:132 msgid "Return the absolute value of *x*." msgstr "回傳 *x* 的絕對值。" -#: ../../library/math.rst:227 +#: ../../library/math.rst:137 msgid "" "Return the floor of *x*, the largest integer less than or equal to *x*. If " "*x* is not a float, delegates to :meth:`x.__floor__ `, " @@ -739,7 +614,7 @@ msgstr "" "將委派給 :meth:`x.__floor__ `,並回傳 :class:`~numbers." "Integral` 型別的值。" -#: ../../library/math.rst:234 +#: ../../library/math.rst:144 msgid "" "Fused multiply-add operation. Return ``(x * y) + z``, computed as though " "with infinite precision and range followed by a single round to the " @@ -750,7 +625,7 @@ msgstr "" "一次轉換為 ``float`` 格式。此操作通常能提供比運算式 ``(x * y) + z`` 更高的精" "確度。" -#: ../../library/math.rst:239 +#: ../../library/math.rst:149 msgid "" "This function follows the specification of the fusedMultiplyAdd operation " "described in the IEEE 754 standard. The standard leaves one case " @@ -762,7 +637,33 @@ msgstr "" "一種由實作決定的案例,即 ``fma(0, inf, nan)`` 和 ``fma(inf, 0, nan)`` 的結" "果;在這些案例中,``math.fma`` 回傳 NaN 且不會引發例外。" -#: ../../library/math.rst:250 +#: ../../library/math.rst:160 +msgid "" +"Get the larger of two floating-point values, treating NaNs as missing data." +msgstr "" + +#: ../../library/math.rst:162 +msgid "" +"When both operands are (signed) NaNs or zeroes, return ``nan`` and ``0`` " +"respectively and the sign of the result is implementation-defined, that is, :" +"func:`!fmax` is not required to be sensitive to the sign of such operands " +"(see Annex F of the C11 standard, §F.10.0.3 and §F.10.9.2)." +msgstr "" + +#: ../../library/math.rst:172 +msgid "" +"Get the smaller of two floating-point values, treating NaNs as missing data." +msgstr "" + +#: ../../library/math.rst:174 +msgid "" +"When both operands are (signed) NaNs or zeroes, return ``nan`` and ``0`` " +"respectively and the sign of the result is implementation-defined, that is, :" +"func:`!fmin` is not required to be sensitive to the sign of such operands " +"(see Annex F of the C11 standard, §F.10.0.3 and §F.10.9.3)." +msgstr "" + +#: ../../library/math.rst:184 msgid "" "Return the floating-point remainder of ``x / y``, as defined by the platform " "C library function ``fmod(x, y)``. Note that the Python expression ``x % y`` " @@ -787,13 +688,13 @@ msgstr "" "出乎意料的 ``1e100``。因此,處理浮點數時通常會選擇函式 :func:`fmod`,而處理整" "數時會選擇 Python 運算式 ``x % y``。" -#: ../../library/math.rst:266 +#: ../../library/math.rst:200 msgid "" "Return the fractional and integer parts of *x*. Both results carry the sign " "of *x* and are floats." msgstr "回傳 *x* 的小數及整數部分,兩者皆為與 *x* 同號的浮點數。" -#: ../../library/math.rst:269 +#: ../../library/math.rst:203 msgid "" "Note that :func:`modf` has a different call/return pattern than its C " "equivalents: it takes a single argument and return a pair of values, rather " @@ -804,7 +705,7 @@ msgstr "" "數並回傳一對值,而非透過一個「輸出參數(output parameter)」傳遞第二個回傳值" "(Python 沒有那種東西)。" -#: ../../library/math.rst:277 +#: ../../library/math.rst:211 msgid "" "Return the IEEE 754-style remainder of *x* with respect to *y*. For finite " "*x* and finite nonzero *y*, this is the difference ``x - n*y``, where ``n`` " @@ -818,7 +719,7 @@ msgstr "" "於兩個連續整數的正中間,``n`` 為最接近的\\ *偶*\\ 數。因此該餘數 ``r = " "remainder(x, y)`` 總是滿足 ``abs(r) <= 0.5 * abs(y)``。" -#: ../../library/math.rst:284 +#: ../../library/math.rst:218 msgid "" "Special cases follow IEEE 754: in particular, ``remainder(x, math.inf)`` is " "*x* for any finite *x*, and ``remainder(x, 0)`` and ``remainder(math.inf, " @@ -830,7 +731,7 @@ msgstr "" "inf, x)`` 會引發 :exc:`ValueError`。若取餘數操作的結果為零,則該零值會與 *x* " "同號。" -#: ../../library/math.rst:290 +#: ../../library/math.rst:224 msgid "" "On platforms using IEEE 754 binary floating point, the result of this " "operation is always exactly representable: no rounding error is introduced." @@ -838,7 +739,7 @@ msgstr "" "在使用 IEEE 754 浮點標準中二進制浮點數的平台上,此操作的結果必能精準表示,不" "會出現捨入誤差。" -#: ../../library/math.rst:298 +#: ../../library/math.rst:232 msgid "" "Return *x* with the fractional part removed, leaving the integer part. This " "rounds toward 0: ``trunc()`` is equivalent to :func:`floor` for positive " @@ -851,7 +752,7 @@ msgstr "" "`ceil`。若 *x* 非浮點數,此函式將委派給 :meth:`x.__trunc__ `,而後回傳一 :class:`~numbers.Integral` 值。" -#: ../../library/math.rst:305 +#: ../../library/math.rst:239 msgid "" "For the :func:`ceil`, :func:`floor`, and :func:`modf` functions, note that " "*all* floating-point numbers of sufficiently large magnitude are exact " @@ -864,11 +765,11 @@ msgstr "" "位元(與 C 語言 double 型別相同),因此當浮點數 *x* 滿足 ``abs(x) >= 2**52`` " "時,它必然沒有小數部分。" -#: ../../library/math.rst:313 +#: ../../library/math.rst:247 msgid "Floating point manipulation functions" msgstr "浮點數操作函式" -#: ../../library/math.rst:317 +#: ../../library/math.rst:251 msgid "" "Return a float with the magnitude (absolute value) of *x* but the sign of " "*y*. On platforms that support signed zeros, ``copysign(1.0, -0.0)`` " @@ -877,7 +778,7 @@ msgstr "" "回傳與 *x* 相同量值(絕對值)且與 *y* 同號的浮點數。在支援帶符號零的平臺上," "``copysign(1.0, -0.0)`` 回傳 *-1.0*。" -#: ../../library/math.rst:324 +#: ../../library/math.rst:258 msgid "" "Return the mantissa and exponent of *x* as the pair ``(m, e)``. If *x* is a " "finite nonzero number, then *m* is a float with ``0.5 <= abs(m) < 1.0`` and " @@ -890,7 +791,7 @@ msgstr "" "2**e`` 完全成立。否則,回傳 ``(x, 0)``。此函式用於以可攜的方式「分割」浮點數" "內部表示法。" -#: ../../library/math.rst:331 +#: ../../library/math.rst:265 msgid "" "Note that :func:`frexp` has a different call/return pattern than its C " "equivalents: it takes a single argument and return a pair of values, rather " @@ -901,13 +802,13 @@ msgstr "" "數並回傳一對值,而非透過一個「輸出參數(output parameter)」傳遞第二個回傳值" "(Python 沒有那種東西)。" -#: ../../library/math.rst:338 +#: ../../library/math.rst:272 msgid "" "Return ``True`` if the values *a* and *b* are close to each other and " "``False`` otherwise." msgstr "若 *a* 及 *b* 兩值足夠接近便回傳 ``True``,否則回傳 ``False``。" -#: ../../library/math.rst:341 +#: ../../library/math.rst:275 msgid "" "Whether or not two values are considered close is determined according to " "given absolute and relative tolerances. If no errors occur, the result will " @@ -916,7 +817,7 @@ msgstr "" "兩數是否足夠接近取決於給定的絕對及相對容許偏差 (tolerance)。如果沒有錯誤發" "生,結果將為:``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``。" -#: ../../library/math.rst:345 +#: ../../library/math.rst:279 msgid "" "*rel_tol* is the relative tolerance -- it is the maximum allowed difference " "between *a* and *b*, relative to the larger absolute value of *a* or *b*. " @@ -930,7 +831,7 @@ msgstr "" "設值為 ``1e-09``,該值可確保兩數於大約 9 個十進數位內相同。*rel_tol* 須不為負" "且小於 ``1.0``。" -#: ../../library/math.rst:352 +#: ../../library/math.rst:286 msgid "" "*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be " "nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed " @@ -943,7 +844,7 @@ msgstr "" "果對任何非零 ``x`` 及小於 ``1.0`` 的 *rel_tol* 而言皆為 ``False``。因此呼叫時" "應加上適當的正數 *abs_tol* 引數。" -#: ../../library/math.rst:358 +#: ../../library/math.rst:292 msgid "" "The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be " "handled according to IEEE rules. Specifically, ``NaN`` is not considered " @@ -954,11 +855,11 @@ msgstr "" "處理。更明確地說,``NaN`` 不會與包含自身在內的任何數字足夠接近,而 ``inf`` " "及 ``-inf`` 皆只與自身接近。" -#: ../../library/math.rst:367 +#: ../../library/math.rst:301 msgid ":pep:`485` -- A function for testing approximate equality" msgstr ":pep:`485` ── 用於測試近似相等的函式" -#: ../../library/math.rst:372 +#: ../../library/math.rst:306 msgid "" "Return ``True`` if *x* is neither an infinity nor a NaN, and ``False`` " "otherwise. (Note that ``0.0`` *is* considered finite.)" @@ -966,78 +867,100 @@ msgstr "" "若 *x* 不是無限值或 NaN 便回傳 ``True``,否則回傳 ``False``。(注意 ``0.0`` " "被視為有限數。)" -#: ../../library/math.rst:380 +#: ../../library/math.rst:314 +msgid "" +"Return ``True`` if *x* is a normal number, that is a finite nonzero number " +"that is not a subnormal (see :func:`issubnormal`). Return ``False`` " +"otherwise." +msgstr "" + +#: ../../library/math.rst:323 +msgid "" +"Return ``True`` if *x* is a subnormal number, that is a finite nonzero " +"number with a magnitude smaller than :data:`sys.float_info.min`. Return " +"``False`` otherwise." +msgstr "" + +#: ../../library/math.rst:332 msgid "" "Return ``True`` if *x* is a positive or negative infinity, and ``False`` " "otherwise." msgstr "若 *x* 是正無限值或負無限值便回傳 ``True``,否則回傳 ``False``。" -#: ../../library/math.rst:386 +#: ../../library/math.rst:338 msgid "" "Return ``True`` if *x* is a NaN (not a number), and ``False`` otherwise." msgstr "" "若 *x* 是 NaN ── 即非數值(NaN, not a number)── 便回傳 ``True``,否則回傳 " "``False``。" -#: ../../library/math.rst:391 +#: ../../library/math.rst:343 msgid "" "Return ``x * (2**i)``. This is essentially the inverse of function :func:" "`frexp`." msgstr "回傳 ``x * (2**i)``。此函式本質上為 :func:`frexp` 的反函式。" -#: ../../library/math.rst:397 +#: ../../library/math.rst:349 msgid "Return the floating-point value *steps* steps after *x* towards *y*." msgstr "回傳 *x* 向 *y* *steps* 步的浮點數值。" -#: ../../library/math.rst:399 +#: ../../library/math.rst:351 msgid "If *x* is equal to *y*, return *y*, unless *steps* is zero." msgstr "除非 *steps* 為零,否則當 *x* 與 *y* 相等時回傳 *y*。" -#: ../../library/math.rst:401 +#: ../../library/math.rst:353 msgid "Examples:" msgstr "範例:" -#: ../../library/math.rst:403 +#: ../../library/math.rst:355 msgid "``math.nextafter(x, math.inf)`` goes up: towards positive infinity." msgstr "``math.nextafter(x, math.inf)`` 增加:往正無限。" -#: ../../library/math.rst:404 +#: ../../library/math.rst:356 msgid "``math.nextafter(x, -math.inf)`` goes down: towards minus infinity." msgstr "``math.nextafter(x, -math.inf)`` 減少:往負無限。" -#: ../../library/math.rst:405 +#: ../../library/math.rst:357 msgid "``math.nextafter(x, 0.0)`` goes towards zero." msgstr "``math.nextafter(x, 0.0)`` 靠近零。" -#: ../../library/math.rst:406 +#: ../../library/math.rst:358 msgid "``math.nextafter(x, math.copysign(math.inf, x))`` goes away from zero." msgstr "``math.nextafter(x, math.copysign(math.inf, x))`` 遠離零。" -#: ../../library/math.rst:408 +#: ../../library/math.rst:360 msgid "See also :func:`math.ulp`." msgstr "另請參閱 :func:`math.ulp`。" -#: ../../library/math.rst:412 +#: ../../library/math.rst:364 msgid "Added the *steps* argument." msgstr "新增 *steps* 引數。" -#: ../../library/math.rst:418 +#: ../../library/math.rst:370 +msgid "Return ``True`` if the sign of *x* is negative and ``False`` otherwise." +msgstr "若 *x* 的正負號為負便回傳 ``True``,否則回傳 ``False``。" + +#: ../../library/math.rst:372 +msgid "This is useful to detect the sign bit of zeroes, infinities and NaNs." +msgstr "" + +#: ../../library/math.rst:379 msgid "Return the value of the least significant bit of the float *x*:" msgstr "回傳浮點數 *x* 的最低有效位元:" -#: ../../library/math.rst:420 +#: ../../library/math.rst:381 msgid "If *x* is a NaN (not a number), return *x*." msgstr "若 *x* 為 NaN(非數值),回傳 *x*。" -#: ../../library/math.rst:421 +#: ../../library/math.rst:382 msgid "If *x* is negative, return ``ulp(-x)``." msgstr "若 *x* 為負值,回傳 ``ulp(-x)``。" -#: ../../library/math.rst:422 +#: ../../library/math.rst:383 msgid "If *x* is a positive infinity, return *x*." msgstr "若 *x* 為正無限值,回傳 *x*。" -#: ../../library/math.rst:423 +#: ../../library/math.rst:384 msgid "" "If *x* is equal to zero, return the smallest positive *denormalized* " "representable float (smaller than the minimum positive *normalized* float, :" @@ -1046,7 +969,7 @@ msgstr "" "若 *x* 等於零,回傳\\ *反正規化*\\ 可表示的最小正浮點數(此值小於\\ *正規化" "*\\ 可表示的最小正浮點數 :data:`sys.float_info.min `)。" -#: ../../library/math.rst:426 +#: ../../library/math.rst:387 msgid "" "If *x* is equal to the largest positive representable float, return the " "value of the least significant bit of *x*, such that the first float smaller " @@ -1055,7 +978,7 @@ msgstr "" "若 *x* 等於可表示的最大正浮點數,回傳 *x* 的最低有效位元值,使 ``x-ulp(x)`` " "為第一個小於 *x* 的浮點數。" -#: ../../library/math.rst:429 +#: ../../library/math.rst:390 msgid "" "Otherwise (*x* is a positive finite number), return the value of the least " "significant bit of *x*, such that the first float bigger than *x* is ``x + " @@ -1064,11 +987,11 @@ msgstr "" "否則(當 *x* 為正有限數),回傳 *x* 的最低有效位元值,使 ``x+ulp(x)`` 為第一" "個大於 *x* 的浮點數。" -#: ../../library/math.rst:433 +#: ../../library/math.rst:394 msgid "ULP stands for \"Unit in the Last Place\"." msgstr "ULP 即最後一位上的單位值(Unit in the Last Place)。" -#: ../../library/math.rst:435 +#: ../../library/math.rst:396 msgid "" "See also :func:`math.nextafter` and :data:`sys.float_info.epsilon `." @@ -1076,15 +999,15 @@ msgstr "" "另請參閱 :func:`math.nextafter` 及 :data:`sys.float_info.epsilon `。" -#: ../../library/math.rst:442 +#: ../../library/math.rst:403 msgid "Power, exponential and logarithmic functions" msgstr "次方、指數與對數函式" -#: ../../library/math.rst:446 +#: ../../library/math.rst:407 msgid "Return the cube root of *x*." msgstr "回傳 *x* 的立方根。" -#: ../../library/math.rst:453 +#: ../../library/math.rst:414 msgid "" "Return *e* raised to the power *x*, where *e* = 2.718281... is the base of " "natural logarithms. This is usually more accurate than ``math.e ** x`` or " @@ -1093,11 +1016,11 @@ msgstr "" "回傳 *e* 的 *x* 次方,其中 *e* = 2.718281... 為自然對數的底數。此函式通常比 " "``math.e ** x`` 或 ``pow(math.e, x)`` 更為精確。" -#: ../../library/math.rst:460 +#: ../../library/math.rst:421 msgid "Return *2* raised to the power *x*." msgstr "回傳 *2* 的 *x* 次方。" -#: ../../library/math.rst:467 +#: ../../library/math.rst:428 msgid "" "Return *e* raised to the power *x*, minus 1. Here *e* is the base of " "natural logarithms. For small floats *x*, the subtraction in ``exp(x) - 1`` " @@ -1110,11 +1033,11 @@ msgstr "" "wikipedia.org/wiki/Loss_of_significance>`_;:func:`expm1` 函式提供了一種能以" "完整精密度計算此值的方法:" -#: ../../library/math.rst:484 +#: ../../library/math.rst:445 msgid "With one argument, return the natural logarithm of *x* (to base *e*)." msgstr "傳入一個引數時,回傳 *x* 的自然對數(以 *e* 為底)。" -#: ../../library/math.rst:486 +#: ../../library/math.rst:447 msgid "" "With two arguments, return the logarithm of *x* to the given *base*, " "calculated as ``log(x)/log(base)``." @@ -1122,20 +1045,20 @@ msgstr "" "傳入兩個引數時,回傳 *x* 以給定 *base* 為底的對數,計算方式為 ``log(x)/" "log(base)``。" -#: ../../library/math.rst:492 +#: ../../library/math.rst:453 msgid "" "Return the natural logarithm of *1+x* (base *e*). The result is calculated " "in a way which is accurate for *x* near zero." msgstr "" "回傳 *1+x* 的自然對數(以 *e* 為底)。計算結果對於接近零的 *x* 值是精確的。" -#: ../../library/math.rst:498 +#: ../../library/math.rst:459 msgid "" "Return the base-2 logarithm of *x*. This is usually more accurate than " "``log(x, 2)``." msgstr "回傳 *x* 的以 2 為底的對數。此函式通常比 ``log(x, 2)`` 更為精確。" -#: ../../library/math.rst:505 +#: ../../library/math.rst:466 msgid "" ":meth:`int.bit_length` returns the number of bits necessary to represent an " "integer in binary, excluding the sign and leading zeros." @@ -1143,13 +1066,13 @@ msgstr "" ":meth:`int.bit_length` 回傳以二進位表示一個整數所需的位元數,不包含正負號及前" "導零。" -#: ../../library/math.rst:511 +#: ../../library/math.rst:472 msgid "" "Return the base-10 logarithm of *x*. This is usually more accurate than " "``log(x, 10)``." msgstr "回傳 *x* 的以 10 為底的對數。此函式通常比 ``log(x, 10)`` 更為精確。" -#: ../../library/math.rst:517 +#: ../../library/math.rst:478 msgid "" "Return *x* raised to the power *y*. Exceptional cases follow the IEEE 754 " "standard as far as possible. In particular, ``pow(1.0, x)`` and ``pow(x, " @@ -1162,7 +1085,7 @@ msgstr "" "*x* 和 *y* 皆為有限數、*x* 為負數且 *y* 不是整數,則 ``pow(x, y)`` 是未定義" "的,並會引發 :exc:`ValueError`。" -#: ../../library/math.rst:524 +#: ../../library/math.rst:485 msgid "" "Unlike the built-in ``**`` operator, :func:`math.pow` converts both its " "arguments to type :class:`float`. Use ``**`` or the built-in :func:`pow` " @@ -1172,7 +1095,7 @@ msgstr "" "`float` 型別。若需要計算精確的整數次方,請使用 ``**`` 或內建的 :func:`pow` 函" "式。" -#: ../../library/math.rst:528 +#: ../../library/math.rst:489 msgid "" "The special cases ``pow(0.0, -inf)`` and ``pow(-0.0, -inf)`` were changed to " "return ``inf`` instead of raising :exc:`ValueError`, for consistency with " @@ -1181,15 +1104,15 @@ msgstr "" "特殊情況 ``pow(0.0, -inf)`` 和 ``pow(-0.0, -inf)`` 已變更為回傳 ``inf`` 而非" "引發 :exc:`ValueError`,以符合 IEEE 754 標準。" -#: ../../library/math.rst:536 +#: ../../library/math.rst:497 msgid "Return the square root of *x*." msgstr "回傳 *x* 的平方根。" -#: ../../library/math.rst:540 +#: ../../library/math.rst:501 msgid "Summation and product functions" msgstr "總和與乘積函式" -#: ../../library/math.rst:544 +#: ../../library/math.rst:505 msgid "" "Return the Euclidean distance between two points *p* and *q*, each given as " "a sequence (or iterable) of coordinates. The two points must have the same " @@ -1198,15 +1121,15 @@ msgstr "" "回傳兩點 *p* 與 *q* 之間的歐幾里得距離,各點以座標的序列(或可疊代物件)表" "示。兩點必須具有相同的維度。" -#: ../../library/math.rst:548 ../../library/math.rst:609 +#: ../../library/math.rst:509 ../../library/math.rst:570 msgid "Roughly equivalent to::" msgstr "約等價於: ::" -#: ../../library/math.rst:550 -msgid "sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))" -msgstr "sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))" +#: ../../library/math.rst:511 +msgid "sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q, strict=True)))" +msgstr "sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q, strict=True)))" -#: ../../library/math.rst:557 +#: ../../library/math.rst:518 msgid "" "Return an accurate floating-point sum of values in the iterable. Avoids " "loss of precision by tracking multiple intermediate partial sums." @@ -1214,7 +1137,7 @@ msgstr "" "回傳可疊代物件(iterable)中所有值的精確浮點數和。透過追蹤過程中多個部分和" "(partial sum)以避免精密度損失。" -#: ../../library/math.rst:560 +#: ../../library/math.rst:521 msgid "" "The algorithm's accuracy depends on IEEE-754 arithmetic guarantees and the " "typical case where the rounding mode is half-even. On some non-Windows " @@ -1226,7 +1149,7 @@ msgstr "" "有些非 Windows 平台建置時,底層 C 函式庫使用延伸精密度加法運算,而可能導致對" "過程中同一部分和重複捨入,並使其最低有效位不如預期。" -#: ../../library/math.rst:566 +#: ../../library/math.rst:527 msgid "" "For further discussion and two alternative approaches, see the `ASPN " "cookbook recipes for accurate floating-point summation `_。" -#: ../../library/math.rst:573 +#: ../../library/math.rst:534 msgid "" "Return the Euclidean norm, ``sqrt(sum(x**2 for x in coordinates))``. This is " "the length of the vector from the origin to the point given by the " @@ -1245,7 +1168,7 @@ msgstr "" "回傳歐幾里得範數 ``sqrt(sum(x**2 for x in coordinates))``。這是從原點到座標所" "給定的點之間的向量長度。" -#: ../../library/math.rst:577 +#: ../../library/math.rst:538 msgid "" "For a two dimensional point ``(x, y)``, this is equivalent to computing the " "hypotenuse of a right triangle using the Pythagorean theorem, ``sqrt(x*x + " @@ -1254,13 +1177,13 @@ msgstr "" "對於二維點 ``(x, y)``,這等同於使用畢氏定理計算直角三角形的斜邊,即 " "``sqrt(x*x + y*y)``。" -#: ../../library/math.rst:581 +#: ../../library/math.rst:542 msgid "" "Added support for n-dimensional points. Formerly, only the two dimensional " "case was supported." msgstr "新增對 n 維點的支援。先前僅支援二維情況。" -#: ../../library/math.rst:585 +#: ../../library/math.rst:546 msgid "" "Improved the algorithm's accuracy so that the maximum error is under 1 ulp " "(unit in the last place). More typically, the result is almost always " @@ -1269,14 +1192,14 @@ msgstr "" "改進了演算法的精確度,使最大誤差低於 1 ulp(最後一位上的單位值)。更典型的情" "況是,結果幾乎總是能正確捨入到 1/2 ulp 以內。" -#: ../../library/math.rst:593 +#: ../../library/math.rst:554 msgid "" "Calculate the product of all the elements in the input *iterable*. The " "default *start* value for the product is ``1``." msgstr "" "計算輸入 *iterable* 中所有元素的乘積。乘積的預設 *start* 起始值為 ``1``。" -#: ../../library/math.rst:596 +#: ../../library/math.rst:557 msgid "" "When the iterable is empty, return the start value. This function is " "intended specifically for use with numeric values and may reject non-numeric " @@ -1285,19 +1208,19 @@ msgstr "" "當可疊代物件為空時,回傳起始值。此函式專門設計用於數值運算,可能會拒絕非數值" "型別。" -#: ../../library/math.rst:605 +#: ../../library/math.rst:566 msgid "Return the sum of products of values from two iterables *p* and *q*." msgstr "回傳兩個可疊代物件 *p* 及 *q* 各值乘積的總和。" -#: ../../library/math.rst:607 +#: ../../library/math.rst:568 msgid "Raises :exc:`ValueError` if the inputs do not have the same length." msgstr "若兩個傳入物件長度不同會引發 :exc:`ValueError`。" -#: ../../library/math.rst:611 +#: ../../library/math.rst:572 msgid "sum(map(operator.mul, p, q, strict=True))" msgstr "sum(map(operator.mul, p, q, strict=True))" -#: ../../library/math.rst:613 +#: ../../library/math.rst:574 msgid "" "For float and mixed int/float inputs, the intermediate products and sums are " "computed with extended precision." @@ -1305,41 +1228,41 @@ msgstr "" "對浮點數或混合整數及浮點數的傳入物件,其過程中的乘積及總和皆使用延伸精密度計" "算。" -#: ../../library/math.rst:620 +#: ../../library/math.rst:581 msgid "Angular conversion" msgstr "角度轉換" -#: ../../library/math.rst:624 +#: ../../library/math.rst:585 msgid "Convert angle *x* from radians to degrees." msgstr "將角度 *x* 從弧度轉換為度。" -#: ../../library/math.rst:629 +#: ../../library/math.rst:590 msgid "Convert angle *x* from degrees to radians." msgstr "將角度 *x* 從度轉換為弧度。" -#: ../../library/math.rst:633 +#: ../../library/math.rst:594 msgid "Trigonometric functions" msgstr "三角函式" -#: ../../library/math.rst:637 +#: ../../library/math.rst:598 msgid "" "Return the arc cosine of *x*, in radians. The result is between ``0`` and " "``pi``." msgstr "回傳 *x* 的反餘弦值,以弧度表示。結果介於 ``0`` 與 ``pi`` 之間。" -#: ../../library/math.rst:643 +#: ../../library/math.rst:604 msgid "" "Return the arc sine of *x*, in radians. The result is between ``-pi/2`` and " "``pi/2``." msgstr "回傳 *x* 的反正弦值,以弧度表示。結果介於 ``-pi/2`` 與 ``pi/2`` 之間。" -#: ../../library/math.rst:649 +#: ../../library/math.rst:610 msgid "" "Return the arc tangent of *x*, in radians. The result is between ``-pi/2`` " "and ``pi/2``." msgstr "回傳 *x* 的反正切值,以弧度表示。結果介於 ``-pi/2`` 與 ``pi/2`` 之間。" -#: ../../library/math.rst:655 +#: ../../library/math.rst:616 msgid "" "Return ``atan(y / x)``, in radians. The result is between ``-pi`` and " "``pi``. The vector in the plane from the origin to point ``(x, y)`` makes " @@ -1353,23 +1276,23 @@ msgstr "" "個輸入的正負號,因此能計算出角度所在的正確象限。例如,``atan(1)`` 和 " "``atan2(1, 1)`` 都是 ``pi/4``,但 ``atan2(-1, -1)`` 是 ``-3*pi/4``。" -#: ../../library/math.rst:665 +#: ../../library/math.rst:626 msgid "Return the cosine of *x* radians." msgstr "回傳 *x* 弧度的餘弦值。" -#: ../../library/math.rst:670 +#: ../../library/math.rst:631 msgid "Return the sine of *x* radians." msgstr "回傳 *x* 弧度的正弦值。" -#: ../../library/math.rst:675 +#: ../../library/math.rst:636 msgid "Return the tangent of *x* radians." msgstr "回傳 *x* 弧度的正切值。" -#: ../../library/math.rst:679 +#: ../../library/math.rst:640 msgid "Hyperbolic functions" msgstr "雙曲函式" -#: ../../library/math.rst:681 +#: ../../library/math.rst:642 msgid "" "`Hyperbolic functions `_ " "are analogs of trigonometric functions that are based on hyperbolas instead " @@ -1378,35 +1301,35 @@ msgstr "" "`雙曲函式 `_\\ 是三角函式" "的類似物,但基於雙曲線而非圓。" -#: ../../library/math.rst:687 +#: ../../library/math.rst:648 msgid "Return the inverse hyperbolic cosine of *x*." msgstr "回傳 *x* 的反雙曲餘弦值。" -#: ../../library/math.rst:692 +#: ../../library/math.rst:653 msgid "Return the inverse hyperbolic sine of *x*." msgstr "回傳 *x* 的反雙曲正弦值。" -#: ../../library/math.rst:697 +#: ../../library/math.rst:658 msgid "Return the inverse hyperbolic tangent of *x*." msgstr "回傳 *x* 的反雙曲正切值。" -#: ../../library/math.rst:702 +#: ../../library/math.rst:663 msgid "Return the hyperbolic cosine of *x*." msgstr "回傳 *x* 的雙曲餘弦值。" -#: ../../library/math.rst:707 +#: ../../library/math.rst:668 msgid "Return the hyperbolic sine of *x*." msgstr "回傳 *x* 的雙曲正弦值。" -#: ../../library/math.rst:712 +#: ../../library/math.rst:673 msgid "Return the hyperbolic tangent of *x*." msgstr "回傳 *x* 的雙曲正切值。" -#: ../../library/math.rst:716 +#: ../../library/math.rst:677 msgid "Special functions" msgstr "特殊函式" -#: ../../library/math.rst:720 +#: ../../library/math.rst:681 msgid "" "Return the `error function `_ " "at *x*." @@ -1414,7 +1337,7 @@ msgstr "" "回傳在 *x* 處的\\ `誤差函式 `_\\ 值。" -#: ../../library/math.rst:723 +#: ../../library/math.rst:684 msgid "" "The :func:`erf` function can be used to compute traditional statistical " "functions such as the `cumulative standard normal distribution `_: ::" -#: ../../library/math.rst:727 +#: ../../library/math.rst:688 msgid "" "def phi(x):\n" " 'Cumulative distribution function for the standard normal distribution'\n" @@ -1433,7 +1356,7 @@ msgstr "" " '標準常態分布的累積分布函式'\n" " return (1.0 + erf(x / sqrt(2.0))) / 2.0" -#: ../../library/math.rst:736 +#: ../../library/math.rst:697 msgid "" "Return the complementary error function at *x*. The `complementary error " "function `_ is defined as " @@ -1446,7 +1369,7 @@ msgstr "" "該情況下從一減去會導致\\ `顯著性損失 `_。" -#: ../../library/math.rst:747 +#: ../../library/math.rst:708 msgid "" "Return the `Gamma function `_ " "at *x*." @@ -1454,25 +1377,116 @@ msgstr "" "回傳在 *x* 處的 `Gamma 函式 `_\\ 值。" -#: ../../library/math.rst:755 +#: ../../library/math.rst:716 msgid "" "Return the natural logarithm of the absolute value of the Gamma function at " "*x*." msgstr "回傳在 *x* 處 Gamma 函式絕對值的自然對數。" -#: ../../library/math.rst:762 +#: ../../library/math.rst:723 +msgid "Number-theoretic functions" +msgstr "數論函式" + +#: ../../library/math.rst:725 +msgid "" +"For backward compatibility, the :mod:`!math` module provides also aliases of " +"the following functions from the :mod:`math.integer` module:" +msgstr "" + +#: ../../library/math.rst:733 +msgid ":func:`comb(n, k) `" +msgstr ":func:`comb(n, k) `" + +#: ../../library/math.rst:734 +msgid "" +"Number of ways to choose *k* items from *n* items without repetition and " +"without order" +msgstr "從 *n* 個物品中不重複且不考慮排序地取出 *k* 個物品的方法數。" + +#: ../../library/math.rst:740 +msgid ":func:`factorial(n) `" +msgstr ":func:`factorial(n) `" + +#: ../../library/math.rst:741 +msgid "*n* factorial" +msgstr "*n* 的階乘" + +#: ../../library/math.rst:746 +msgid ":func:`gcd(*integers) `" +msgstr ":func:`gcd(*integers) `" + +#: ../../library/math.rst:747 +msgid "Greatest common divisor of the integer arguments" +msgstr "整數引數的最大公因數" + +#: ../../library/math.rst:752 +msgid ":func:`isqrt(n) `" +msgstr ":func:`isqrt(n) `" + +#: ../../library/math.rst:753 +msgid "Integer square root of a nonnegative integer *n*" +msgstr "非負整數 *n* 的整數平方根" + +#: ../../library/math.rst:758 +msgid ":func:`lcm(*integers) `" +msgstr ":func:`lcm(*integers) `" + +#: ../../library/math.rst:759 +msgid "Least common multiple of the integer arguments" +msgstr "整數引數的最小公倍數" + +#: ../../library/math.rst:764 +msgid ":func:`perm(n, k) `" +msgstr ":func:`perm(n, k) `" + +#: ../../library/math.rst:765 +msgid "" +"Number of ways to choose *k* items from *n* items without repetition and " +"with order" +msgstr "從 *n* 個物品中不重複但考慮排序地取出 *k* 個物品的方法數。" + +#: ../../library/math.rst:768 +msgid "The :func:`gcd` function." +msgstr "" + +#: ../../library/math.rst:771 +msgid "The :func:`comb`, :func:`perm` and :func:`isqrt` functions." +msgstr "" + +#: ../../library/math.rst:774 +msgid "The :func:`lcm` function." +msgstr "" + +#: ../../library/math.rst:777 +msgid "" +"Added support for an arbitrary number of arguments in the :func:`gcd` " +"function. Formerly, only two arguments were supported." +msgstr "在 :func:`gcd` 函式中新增支援任意數量的引數。先前僅支援兩個引數。" + +#: ../../library/math.rst:782 +msgid "" +"Floats with integral values (like ``5.0``) are no longer accepted in the :" +"func:`factorial` function." +msgstr "" +":func:`factorial` 函式現在已經不允許傳入其值為整數的浮點數(如:``5.0``)。" + +#: ../../library/math.rst:786 +msgid "Use the :mod:`math.integer` functions instead of these aliases." +msgstr "" + +#: ../../library/math.rst:791 msgid "Constants" msgstr "常數" -#: ../../library/math.rst:766 +#: ../../library/math.rst:795 msgid "The mathematical constant *π* = 3.141592..., to available precision." msgstr "數學常數 *π* = 3.141592...,精確至可用精密度。" -#: ../../library/math.rst:771 +#: ../../library/math.rst:800 msgid "The mathematical constant *e* = 2.718281..., to available precision." msgstr "數學常數 *e* = 2.718281...,精確至可用精密度。" -#: ../../library/math.rst:776 +#: ../../library/math.rst:805 msgid "" "The mathematical constant *τ* = 6.283185..., to available precision. Tau is " "a circle constant equal to 2\\ *π*, the ratio of a circle's circumference to " @@ -1485,7 +1499,7 @@ msgstr "" "片 `Pi is (still) Wrong `_,並開始慶祝 `Tau 日 " "`_,吃兩倍的派吧!" -#: ../../library/math.rst:787 +#: ../../library/math.rst:816 msgid "" "A floating-point positive infinity. (For negative infinity, use ``-math." "inf``.) Equivalent to the output of ``float('inf')``." @@ -1493,7 +1507,7 @@ msgstr "" "浮點數正無限值。(對於負無限值,請使用 ``-math.inf``。)等同於 " "``float('inf')`` 的輸出。" -#: ../../library/math.rst:795 +#: ../../library/math.rst:824 msgid "" "A floating-point \"not a number\" (NaN) value. Equivalent to the output of " "``float('nan')``. Due to the requirements of the `IEEE-754 standard n``." +#~ msgstr "當 ``k <= n`` 時其值為 ``n! / (k! * (n - k)!)``,否則其值為 ``0``。" + +#~ msgid "" +#~ "Also called the binomial coefficient because it is equivalent to the " +#~ "coefficient of k-th term in polynomial expansion of ``(1 + x)ⁿ``." +#~ msgstr "" +#~ "因為此值等同於 ``(1 + x)ⁿ`` 進行多項式展開後第 k 項的係數,所以又稱為二項" +#~ "式係數。" + +#~ msgid "" +#~ "Raises :exc:`TypeError` if either of the arguments are not integers. " +#~ "Raises :exc:`ValueError` if either of the arguments are negative." +#~ msgstr "" +#~ "當任一參數非整數型別時會引發 :exc:`TypeError`。當任一參數為負數時會引發 :" +#~ "exc:`ValueError`。" + +#~ msgid "Return factorial of the nonnegative integer *n*." +#~ msgstr "回傳非負整數 *n* 的階乘。" + +#~ msgid "" +#~ "Return the greatest common divisor of the specified integer arguments. If " +#~ "any of the arguments is nonzero, then the returned value is the largest " +#~ "positive integer that is a divisor of all arguments. If all arguments " +#~ "are zero, then the returned value is ``0``. ``gcd()`` without arguments " +#~ "returns ``0``." +#~ msgstr "" +#~ "回傳指定整數引數的最大公因數。若存在任一非零引數,回傳值為所有引數共有因數" +#~ "中最大的正整數。若所有引數皆為零,則回傳值為 ``0``。``gcd()`` 若未傳入任何" +#~ "引數也將回傳 ``0``。" + +#~ msgid "" +#~ "Return the integer square root of the nonnegative integer *n*. This is " +#~ "the floor of the exact square root of *n*, or equivalently the greatest " +#~ "integer *a* such that *a*\\ ² |nbsp| ≤ |nbsp| *n*." +#~ msgstr "" +#~ "回傳非負整數 *n* 的整數平方根。此值為 *n* 精確平方根經下取整的值,亦等同於" +#~ "滿足 *a*\\ ² |nbsp| ≤ |nbsp| *n* 的最大整數值 *a*。" + +#~ msgid "" +#~ "For some applications, it may be more convenient to have the least " +#~ "integer *a* such that *n* |nbsp| ≤ |nbsp| *a*\\ ², or in other words the " +#~ "ceiling of the exact square root of *n*. For positive *n*, this can be " +#~ "computed using ``a = 1 + isqrt(n - 1)``." +#~ msgstr "" +#~ "於有些應用程式中,取得滿足 *n* |nbsp| ≤ |nbsp| *a*\\ ² 的最小整數值 *a* " +#~ "── 或者說 *n* 精確平方根經上取整的值 ── 會更加方便。對正數 *n*,此值可使" +#~ "用 ``a = 1 + isqrt(n - 1)`` 計算。" + +#~ msgid "" +#~ "Return the least common multiple of the specified integer arguments. If " +#~ "all arguments are nonzero, then the returned value is the smallest " +#~ "positive integer that is a multiple of all arguments. If any of the " +#~ "arguments is zero, then the returned value is ``0``. ``lcm()`` without " +#~ "arguments returns ``1``." +#~ msgstr "" +#~ "回傳指定整數引數的最小公倍數。若所有引數值皆非零,回傳值為所有引數共有倍數" +#~ "中最小的正整數。若存在任一引數值為零,則回傳值為 ``0``。``lcm()`` 若未傳入" +#~ "任何引數將回傳 ``1``。" + +#~ msgid "" +#~ "Return the number of ways to choose *k* items from *n* items without " +#~ "repetition and with order." +#~ msgstr "回傳從 *n* 個物品中不重複且考慮排序地取出 *k* 個物品的方法數。" + +#~ msgid "" +#~ "Evaluates to ``n! / (n - k)!`` when ``k <= n`` and evaluates to zero when " +#~ "``k > n``." +#~ msgstr "當 ``k <= n`` 時其值為 ``n! / (n - k)!``,否則其值為 ``0``。" + +#~ msgid "" +#~ "If *k* is not specified or is ``None``, then *k* defaults to *n* and the " +#~ "function returns ``n!``." +#~ msgstr "" +#~ "若未給定 *k* 或其值為 ``None``,則 *k* 值預設為 *n*,且函式回傳 ``n!``。" diff --git a/library/mimetypes.po b/library/mimetypes.po index 592d08eff1b..75cdbd69e29 100644 --- a/library/mimetypes.po +++ b/library/mimetypes.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-31 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2016-11-19 00:32+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!mimetypes` --- Map filenames to MIME types" msgstr ":mod:`!mimetypes` --- 將檔案名稱對映到 MIME 類型" -#: ../../library/mimetypes.rst:9 +#: ../../library/mimetypes.rst:7 msgid "**Source code:** :source:`Lib/mimetypes.py`" msgstr "**原始碼:**\\ :source:`Lib/mimetypes.py`" -#: ../../library/mimetypes.rst:15 +#: ../../library/mimetypes.rst:13 msgid "" "The :mod:`!mimetypes` module converts between a filename or URL and the MIME " "type associated with the filename extension. Conversions are provided from " @@ -33,34 +33,34 @@ msgid "" "are not supported for the latter conversion." msgstr "" -#: ../../library/mimetypes.rst:20 +#: ../../library/mimetypes.rst:18 msgid "" "The module provides one class and a number of convenience functions. The " "functions are the normal interface to this module, but some applications may " "be interested in the class as well." msgstr "" -#: ../../library/mimetypes.rst:24 +#: ../../library/mimetypes.rst:22 msgid "" "The functions described below provide the primary interface for this " "module. If the module has not been initialized, they will call :func:`init` " "if they rely on the information :func:`init` sets up." msgstr "" -#: ../../library/mimetypes.rst:33 +#: ../../library/mimetypes.rst:31 msgid "" "Guess the type of a file based on its filename, path or URL, given by *url*. " "URL can be a string or a :term:`path-like object`." msgstr "" -#: ../../library/mimetypes.rst:36 +#: ../../library/mimetypes.rst:34 msgid "" "The return value is a tuple ``(type, encoding)`` where *type* is ``None`` if " "the type can't be guessed (missing or unknown suffix) or a string of the " "form ``'type/subtype'``, usable for a MIME :mailheader:`content-type` header." msgstr "" -#: ../../library/mimetypes.rst:40 +#: ../../library/mimetypes.rst:38 msgid "" "*encoding* is ``None`` for no encoding or the name of the program used to " "encode (e.g. :program:`compress` or :program:`gzip`). The encoding is " @@ -70,7 +70,7 @@ msgid "" "case sensitively, then case insensitively." msgstr "" -#: ../../library/mimetypes.rst:47 +#: ../../library/mimetypes.rst:45 msgid "" "The optional *strict* argument is a flag specifying whether the list of " "known MIME types is limited to only the official types `registered with IANA " @@ -83,23 +83,23 @@ msgid "" "recognized." msgstr "" -#: ../../library/mimetypes.rst:56 +#: ../../library/mimetypes.rst:54 msgid "Added support for *url* being a :term:`path-like object`." msgstr "新增 *url* 做為 :term:`path-like object` 的支援。" -#: ../../library/mimetypes.rst:59 +#: ../../library/mimetypes.rst:57 msgid "" "Passing a file path instead of URL. Use :func:`guess_file_type` for this." msgstr "" -#: ../../library/mimetypes.rst:68 +#: ../../library/mimetypes.rst:66 msgid "" "Guess the type of a file based on its path, given by *path*. Similar to the :" "func:`guess_type` function, but accepts a path instead of URL. Path can be a " "string, a bytes object or a :term:`path-like object`." msgstr "" -#: ../../library/mimetypes.rst:77 +#: ../../library/mimetypes.rst:75 msgid "" "Guess the extensions for a file based on its MIME type, given by *type*. The " "return value is a list of strings giving all possible filename extensions, " @@ -108,13 +108,13 @@ msgid "" "the MIME type *type* by :func:`guess_type` and :func:`guess_file_type`." msgstr "" -#: ../../library/mimetypes.rst:83 ../../library/mimetypes.rst:95 +#: ../../library/mimetypes.rst:81 ../../library/mimetypes.rst:93 msgid "" "The optional *strict* argument has the same meaning as with the :func:" "`guess_type` function." msgstr "" -#: ../../library/mimetypes.rst:88 +#: ../../library/mimetypes.rst:86 msgid "" "Guess the extension for a file based on its MIME type, given by *type*. The " "return value is a string giving a filename extension, including the leading " @@ -124,13 +124,13 @@ msgid "" "guessed for *type*, ``None`` is returned." msgstr "" -#: ../../library/mimetypes.rst:97 +#: ../../library/mimetypes.rst:95 msgid "" "Some additional functions and data items are available for controlling the " "behavior of the module." msgstr "" -#: ../../library/mimetypes.rst:103 +#: ../../library/mimetypes.rst:101 msgid "" "Initialize the internal data structures. If given, *files* must be a " "sequence of file names which should be used to augment the default type " @@ -140,25 +140,25 @@ msgid "" "Calling :func:`init` repeatedly is allowed." msgstr "" -#: ../../library/mimetypes.rst:110 +#: ../../library/mimetypes.rst:108 msgid "" "Specifying an empty list for *files* will prevent the system defaults from " "being applied: only the well-known values will be present from a built-in " "list." msgstr "" -#: ../../library/mimetypes.rst:113 +#: ../../library/mimetypes.rst:111 msgid "" "If *files* is ``None`` the internal data structure is completely rebuilt to " "its initial default value. This is a stable operation and will produce the " "same results when called multiple times." msgstr "" -#: ../../library/mimetypes.rst:117 +#: ../../library/mimetypes.rst:115 msgid "Previously, Windows registry settings were ignored." msgstr "先前 Windows 登錄設定會被忽略。" -#: ../../library/mimetypes.rst:123 +#: ../../library/mimetypes.rst:121 msgid "" "Load the type map given in the file named by *file*, if it exists. *file* " "must be a string specifying the name of the file to read. The type map is " @@ -167,7 +167,7 @@ msgid "" "exist or cannot be read, ``None`` is returned." msgstr "" -#: ../../library/mimetypes.rst:132 +#: ../../library/mimetypes.rst:130 msgid "" "Add a mapping from the MIME type *type* to the extension *ext*. When the " "extension is already known, the new type will replace the old one. When the " @@ -175,26 +175,26 @@ msgid "" "extensions." msgstr "" -#: ../../library/mimetypes.rst:136 ../../library/mimetypes.rst:312 +#: ../../library/mimetypes.rst:134 ../../library/mimetypes.rst:310 msgid "" "When *strict* is ``True`` (the default), the mapping will be added to the " "official MIME types, otherwise to the non-standard ones." msgstr "" -#: ../../library/mimetypes.rst:142 +#: ../../library/mimetypes.rst:140 msgid "" "Flag indicating whether or not the global data structures have been " "initialized. This is set to ``True`` by :func:`init`." msgstr "" -#: ../../library/mimetypes.rst:150 +#: ../../library/mimetypes.rst:148 msgid "" "List of type map file names commonly installed. These files are typically " "named :file:`mime.types` and are installed in different locations by " "different packages." msgstr "" -#: ../../library/mimetypes.rst:157 +#: ../../library/mimetypes.rst:155 msgid "" "Dictionary mapping suffixes to suffixes. This is used to allow recognition " "of encoded files for which the encoding and the type are indicated by the " @@ -202,25 +202,25 @@ msgid "" "`.tar.gz` to allow the encoding and type to be recognized separately." msgstr "" -#: ../../library/mimetypes.rst:165 +#: ../../library/mimetypes.rst:163 msgid "Dictionary mapping filename extensions to encoding types." msgstr "" -#: ../../library/mimetypes.rst:170 +#: ../../library/mimetypes.rst:168 msgid "Dictionary mapping filename extensions to MIME types." msgstr "" -#: ../../library/mimetypes.rst:175 +#: ../../library/mimetypes.rst:173 msgid "" "Dictionary mapping filename extensions to non-standard, but commonly found " "MIME types." msgstr "" -#: ../../library/mimetypes.rst:179 +#: ../../library/mimetypes.rst:177 msgid "An example usage of the module::" msgstr "模組的使用範例: ::" -#: ../../library/mimetypes.rst:181 +#: ../../library/mimetypes.rst:179 msgid "" ">>> import mimetypes\n" ">>> mimetypes.init()\n" @@ -244,18 +244,18 @@ msgstr "" ">>> mimetypes.types_map['.tgz']\n" "'application/x-tar-gz'" -#: ../../library/mimetypes.rst:196 +#: ../../library/mimetypes.rst:194 msgid "MimeTypes objects" msgstr "MimeTypes 物件" -#: ../../library/mimetypes.rst:198 +#: ../../library/mimetypes.rst:196 msgid "" "The :class:`MimeTypes` class may be useful for applications which may want " "more than one MIME-type database; it provides an interface similar to the " "one of the :mod:`!mimetypes` module." msgstr "" -#: ../../library/mimetypes.rst:205 +#: ../../library/mimetypes.rst:203 msgid "" "This class represents a MIME-types database. By default, it provides access " "to the same database as the rest of this module. The initial database is " @@ -266,13 +266,13 @@ msgid "" "desired." msgstr "" -#: ../../library/mimetypes.rst:212 +#: ../../library/mimetypes.rst:210 msgid "" "The optional *filenames* parameter can be used to cause additional files to " "be loaded \"on top\" of the default database." msgstr "" -#: ../../library/mimetypes.rst:218 +#: ../../library/mimetypes.rst:216 msgid "" "Dictionary mapping suffixes to suffixes. This is used to allow recognition " "of encoded files for which the encoding and the type are indicated by the " @@ -281,13 +281,13 @@ msgid "" "is initialized with some predefined values." msgstr "" -#: ../../library/mimetypes.rst:227 +#: ../../library/mimetypes.rst:225 msgid "" "Dictionary mapping filename extensions to encoding types. This is " "initialized with some predefined values." msgstr "" -#: ../../library/mimetypes.rst:233 +#: ../../library/mimetypes.rst:231 msgid "" "Tuple containing two dictionaries, mapping filename extensions to MIME " "types: the first dictionary is for the non-standards types and the second " @@ -296,7 +296,7 @@ msgid "" "*filenames* argument." msgstr "" -#: ../../library/mimetypes.rst:242 +#: ../../library/mimetypes.rst:240 msgid "" "Tuple containing two dictionaries, mapping MIME types to a list of filename " "extensions: the first dictionary is for the non-standards types and the " @@ -305,63 +305,63 @@ msgid "" "the *filenames* argument." msgstr "" -#: ../../library/mimetypes.rst:251 +#: ../../library/mimetypes.rst:249 msgid "" "Similar to the :func:`guess_extension` function, using the tables stored as " "part of the object." msgstr "" -#: ../../library/mimetypes.rst:257 +#: ../../library/mimetypes.rst:255 msgid "" "Similar to the :func:`guess_type` function, using the tables stored as part " "of the object." msgstr "" -#: ../../library/mimetypes.rst:263 +#: ../../library/mimetypes.rst:261 msgid "" "Similar to the :func:`guess_file_type` function, using the tables stored as " "part of the object." msgstr "" -#: ../../library/mimetypes.rst:271 +#: ../../library/mimetypes.rst:269 msgid "" "Similar to the :func:`guess_all_extensions` function, using the tables " "stored as part of the object." msgstr "" -#: ../../library/mimetypes.rst:277 +#: ../../library/mimetypes.rst:275 msgid "" "Load MIME information from a file named *filename*. This uses :meth:" "`readfp` to parse the file." msgstr "" -#: ../../library/mimetypes.rst:280 +#: ../../library/mimetypes.rst:278 msgid "" "If *strict* is ``True``, information will be added to list of standard " "types, else to the list of non-standard types." msgstr "" -#: ../../library/mimetypes.rst:286 +#: ../../library/mimetypes.rst:284 msgid "" "Load MIME type information from an open file *fp*. The file must have the " "format of the standard :file:`mime.types` files." msgstr "" -#: ../../library/mimetypes.rst:289 ../../library/mimetypes.rst:299 +#: ../../library/mimetypes.rst:287 ../../library/mimetypes.rst:297 msgid "" "If *strict* is ``True``, information will be added to the list of standard " "types, else to the list of non-standard types." msgstr "" -#: ../../library/mimetypes.rst:295 +#: ../../library/mimetypes.rst:293 msgid "Load MIME type information from the Windows registry." msgstr "" -#: ../../library/mimetypes.rst:297 +#: ../../library/mimetypes.rst:295 msgid "Availability" msgstr "可用性" -#: ../../library/mimetypes.rst:307 +#: ../../library/mimetypes.rst:305 msgid "" "Add a mapping from the MIME type *type* to the extension *ext*. Valid " "extensions start with a '.' or are empty. When the extension is already " @@ -369,65 +369,65 @@ msgid "" "the extension will be added to the list of known extensions." msgstr "" -#: ../../library/mimetypes.rst:315 +#: ../../library/mimetypes.rst:313 msgid "" "Invalid, undotted extensions will raise a :exc:`ValueError` in Python 3.16." msgstr "" -#: ../../library/mimetypes.rst:323 +#: ../../library/mimetypes.rst:321 msgid "Command-line usage" msgstr "命令列用法" -#: ../../library/mimetypes.rst:325 +#: ../../library/mimetypes.rst:323 msgid "" "The :mod:`!mimetypes` module can be executed as a script from the command " "line." msgstr "" -#: ../../library/mimetypes.rst:327 +#: ../../library/mimetypes.rst:325 msgid "python -m mimetypes [-h] [-e] [-l] type [type ...]" msgstr "python -m mimetypes [-h] [-e] [-l] type [type ...]" -#: ../../library/mimetypes.rst:331 +#: ../../library/mimetypes.rst:329 msgid "The following options are accepted:" msgstr "" -#: ../../library/mimetypes.rst:338 +#: ../../library/mimetypes.rst:336 msgid "Show the help message and exit." msgstr "" -#: ../../library/mimetypes.rst:343 +#: ../../library/mimetypes.rst:341 msgid "Guess extension instead of type." msgstr "" -#: ../../library/mimetypes.rst:348 +#: ../../library/mimetypes.rst:346 msgid "Additionally search for some common, but non-standard types." msgstr "" -#: ../../library/mimetypes.rst:350 +#: ../../library/mimetypes.rst:348 msgid "" "By default the script converts MIME types to file extensions. However, if " "``--extension`` is specified, it converts file extensions to MIME types." msgstr "" -#: ../../library/mimetypes.rst:354 +#: ../../library/mimetypes.rst:352 msgid "" "For each ``type`` entry, the script writes a line into the standard output " "stream. If an unknown type occurs, it writes an error message into the " "standard output stream and exits with the return code ``1``." msgstr "" -#: ../../library/mimetypes.rst:362 +#: ../../library/mimetypes.rst:360 msgid "Command-line example" msgstr "" -#: ../../library/mimetypes.rst:364 +#: ../../library/mimetypes.rst:362 msgid "" "Here are some examples of typical usage of the :mod:`!mimetypes` command-" "line interface:" msgstr "" -#: ../../library/mimetypes.rst:367 +#: ../../library/mimetypes.rst:365 msgid "" "$ # get a MIME type by a file name\n" "$ python -m mimetypes filename.png\n" @@ -476,23 +476,23 @@ msgid "" "error: unknown type audio/future" msgstr "" -#: ../../library/mimetypes.rst:11 ../../library/mimetypes.rst:31 -#: ../../library/mimetypes.rst:66 +#: ../../library/mimetypes.rst:9 ../../library/mimetypes.rst:29 +#: ../../library/mimetypes.rst:64 msgid "MIME" msgstr "MIME" -#: ../../library/mimetypes.rst:11 +#: ../../library/mimetypes.rst:9 msgid "content type" msgstr "content type(內容類型)" -#: ../../library/mimetypes.rst:31 ../../library/mimetypes.rst:66 +#: ../../library/mimetypes.rst:29 ../../library/mimetypes.rst:64 msgid "headers" msgstr "headers(標頭)" -#: ../../library/mimetypes.rst:148 +#: ../../library/mimetypes.rst:146 msgid "file" msgstr "file(檔案)" -#: ../../library/mimetypes.rst:148 +#: ../../library/mimetypes.rst:146 msgid "mime.types" msgstr "mime.types" diff --git a/library/mmap.po b/library/mmap.po index dfb1c505647..9742975610d 100644 --- a/library/mmap.po +++ b/library/mmap.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-22 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,7 +21,7 @@ msgstr "" msgid ":mod:`!mmap` --- Memory-mapped file support" msgstr ":mod:`!mmap` --- 記憶體對映檔案的支援" -#: ../../includes/wasm-notavail.rst:3 +#: ../../library/mmap.rst:347 ../../includes/wasm-notavail.rst:3 msgid "Availability" msgstr "可用性" @@ -112,21 +112,22 @@ msgid "" "length." msgstr "要對映匿名記憶體,應將 -1 與長度一起作為 fileno 傳入。" -#: ../../library/mmap.rst:53 +#: ../../library/mmap.rst:54 msgid "" "**(Windows version)** Maps *length* bytes from the file specified by the " -"file handle *fileno*, and creates a mmap object. If *length* is larger than " -"the current size of the file, the file is extended to contain *length* " +"file descriptor *fileno*, and creates a mmap object. If *length* is larger " +"than the current size of the file, the file is extended to contain *length* " "bytes. If *length* is ``0``, the maximum length of the map is the current " "size of the file, except that if the file is empty Windows raises an " "exception (you cannot create an empty mapping on Windows)." msgstr "" -"**(Windows 版本)** 從檔案控制代碼 (file handle) *fileno* 指定的檔案來對映 " -"*length* 個位元組,並建立一個 mmap 物件。如果 *length* 大於檔案目前的大小,檔案" -"會被擴充為能夠包含 *length* 個位元組。如果 *length* 為 ``0``,對映的最大長度就是" -"檔案目前的大小,但如果檔案為空,Windows 會引發例外(因無法在 Windows 上建立空白的對映)。" +"**(Windows 版本)** 從檔案描述器 (file descriptor) *fileno* 指定的檔案來對" +"映 *length* 個位元組,並建立一個 mmap 物件。如果 *length* 大於檔案目前的大" +"小,檔案會被擴充為能夠包含 *length* 個位元組。如果 *length* 為 ``0``,對映的" +"最大長度就是檔案目前的大小,但如果檔案為空,Windows 會引發例外(因無法在 " +"Windows 上建立空白的對映)。" -#: ../../library/mmap.rst:60 +#: ../../library/mmap.rst:61 msgid "" "*tagname*, if specified and not ``None``, is a string giving a tag name for " "the mapping. Windows allows you to have many different mappings against the " @@ -142,7 +143,7 @@ msgstr "" "在沒有名稱的情況下建立。避免使用 *tagname* 參數將有助於保持你的程式碼在 Unix " "和 Windows 之間的可移植性。" -#: ../../library/mmap.rst:68 +#: ../../library/mmap.rst:69 msgid "" "*offset* may be specified as a non-negative integer offset. mmap references " "will be relative to the offset from the beginning of the file. *offset* " @@ -153,7 +154,26 @@ msgstr "" "量。*offset* 預設為 0。*offset* 必須是 :const:`ALLOCATIONGRANULARITY` 的倍" "數。" -#: ../../library/mmap.rst:72 ../../library/mmap.rst:174 +#: ../../library/mmap.rst:73 +msgid "" +"If *trackfd* is ``False``, the file handle corresponding to *fileno* will " +"not be duplicated, and the resulting :class:`!mmap` object will not be " +"associated with the map's underlying file. This means that the :meth:`~mmap." +"mmap.size` and :meth:`~mmap.mmap.resize` methods will fail. This mode is " +"useful to limit the number of open file handles. The original file can be " +"renamed (but not deleted) after closing *fileno*." +msgstr "" +"如果 *trackfd* 為 ``False``,對應於 *fileno* 的檔案控制代碼 (file handle) 將" +"不會被複製,且產生的 :class:`!mmap` 物件將不會與對映的底層檔案關聯。這意味" +"著 :meth:`~mmap.mmap.size` 和 :meth:`~mmap.mmap.resize` 方法會失敗。此模式對" +"於限制開啟的檔案控制代碼數量很有用。關閉 *fileno* 後,原始檔案可以被重新命名" +"(但不能被刪除)。" + +#: ../../library/mmap.rst:81 ../../library/mmap.rst:129 +msgid "The *trackfd* parameter was added." +msgstr "新增 *trackfd* 參數。" + +#: ../../library/mmap.rst:84 ../../library/mmap.rst:186 msgid "" "Raises an :ref:`auditing event ` ``mmap.__new__`` with arguments " "``fileno``, ``length``, ``access``, ``offset``." @@ -161,7 +181,7 @@ msgstr "" "引發一個附帶引數 ``fileno``、``length``、``access``、``offset`` 的\\ :ref:`稽" "核事件 ` ``mmap.__new__``。" -#: ../../library/mmap.rst:78 +#: ../../library/mmap.rst:90 msgid "" "**(Unix version)** Maps *length* bytes from the file specified by the file " "descriptor *fileno*, and returns a mmap object. If *length* is ``0``, the " @@ -172,7 +192,7 @@ msgstr "" "回傳一個 mmap 物件。如果 *length* 為 ``0``,對映的最大長度將是呼叫 :class:" "`~mmap.mmap` 時檔案的目前大小。" -#: ../../library/mmap.rst:83 +#: ../../library/mmap.rst:95 msgid "" "*flags* specifies the nature of the mapping. :const:`MAP_PRIVATE` creates a " "private copy-on-write mapping, so changes to the contents of the mmap object " @@ -187,7 +207,7 @@ msgstr "" "對映相同檔案區域之行程共享的對映。預設值為 :const:`MAP_SHARED`。某些系統有額" "外的可用旗標,完整列表請參閱 :ref:`MAP_* 常數 `。" -#: ../../library/mmap.rst:91 +#: ../../library/mmap.rst:103 msgid "" "*prot*, if specified, gives the desired memory protection; the two most " "useful values are :const:`PROT_READ` and :const:`PROT_WRITE`, to specify " @@ -198,7 +218,7 @@ msgstr "" "和 :const:`PROT_WRITE`,用於指定分頁可以被讀取或寫入。*prot* 預設為 :const:" "`PROT_READ \\| PROT_WRITE`。" -#: ../../library/mmap.rst:96 +#: ../../library/mmap.rst:108 msgid "" "*access* may be specified in lieu of *flags* and *prot* as an optional " "keyword parameter. It is an error to specify both *flags*, *prot* and " @@ -209,7 +229,7 @@ msgstr "" "*flags*、*prot* 和 *access* 會產生錯誤。關於如何使用此參數的資訊,請參閱上面 " "*access* 的說明。" -#: ../../library/mmap.rst:101 +#: ../../library/mmap.rst:113 msgid "" "*offset* may be specified as a non-negative integer offset. mmap references " "will be relative to the offset from the beginning of the file. *offset* " @@ -220,7 +240,7 @@ msgstr "" "量。*offset* 預設為 0。*offset* 必須是 :const:`ALLOCATIONGRANULARITY` 的倍數," "且在 Unix 系統上等於 :const:`PAGESIZE`。" -#: ../../library/mmap.rst:106 +#: ../../library/mmap.rst:118 msgid "" "If *trackfd* is ``False``, the file descriptor specified by *fileno* will " "not be duplicated, and the resulting :class:`!mmap` object will not be " @@ -233,7 +253,7 @@ msgstr "" "size` 和 :meth:`~mmap.mmap.resize` 方法會失敗。此模式對於限制開啟的檔案描述器" "數量很有用。" -#: ../../library/mmap.rst:113 +#: ../../library/mmap.rst:125 msgid "" "To ensure validity of the created memory mapping the file specified by the " "descriptor *fileno* is internally automatically synchronized with the " @@ -242,15 +262,11 @@ msgstr "" "為了確保建立的記憶體對映有效,在 macOS 上由描述器 *fileno* 指定的檔案會在內部" "自動與實體備份儲存同步。" -#: ../../library/mmap.rst:117 -msgid "The *trackfd* parameter was added." -msgstr "新增 *trackfd* 參數。" - -#: ../../library/mmap.rst:120 +#: ../../library/mmap.rst:132 msgid "This example shows a simple way of using :class:`~mmap.mmap`::" msgstr "這個範例示範了使用 :class:`~mmap.mmap` 的簡單方式: ::" -#: ../../library/mmap.rst:122 +#: ../../library/mmap.rst:134 msgid "" "import mmap\n" "\n" @@ -296,13 +312,13 @@ msgstr "" " # 關閉對映\n" " mm.close()" -#: ../../library/mmap.rst:145 +#: ../../library/mmap.rst:157 msgid "" ":class:`~mmap.mmap` can also be used as a context manager in a :keyword:" "`with` statement::" msgstr ":class:`~mmap.mmap` 也可以在 :keyword:`with` 陳述式中作為情境管理器使用: ::" -#: ../../library/mmap.rst:148 +#: ../../library/mmap.rst:160 msgid "" "import mmap\n" "\n" @@ -314,17 +330,17 @@ msgstr "" "with mmap.mmap(-1, 13) as mm:\n" " mm.write(b\"Hello world!\")" -#: ../../library/mmap.rst:153 +#: ../../library/mmap.rst:165 msgid "Context manager support." msgstr "情境管理器的支援。" -#: ../../library/mmap.rst:157 +#: ../../library/mmap.rst:169 msgid "" "The next example demonstrates how to create an anonymous map and exchange " "data between the parent and child processes::" msgstr "下一個範例展示了如何建立匿名對映並在父行程與子行程之間交換資料: ::" -#: ../../library/mmap.rst:160 +#: ../../library/mmap.rst:172 msgid "" "import mmap\n" "import os\n" @@ -354,11 +370,11 @@ msgstr "" "\n" " mm.close()" -#: ../../library/mmap.rst:176 +#: ../../library/mmap.rst:188 msgid "Memory-mapped file objects support the following methods:" msgstr "記憶體對映檔案物件支援以下方法:" -#: ../../library/mmap.rst:180 +#: ../../library/mmap.rst:192 msgid "" "Closes the mmap. Subsequent calls to other methods of the object will result " "in a ValueError exception being raised. This will not close the open file." @@ -366,11 +382,11 @@ msgstr "" "關閉 mmap。後續對物件其他方法的呼叫將導致 ValueError 例外被引發。這不會關閉已" "開啟的檔案。" -#: ../../library/mmap.rst:187 +#: ../../library/mmap.rst:199 msgid "``True`` if the file is closed." msgstr "若檔案已關閉則回傳 ``True``。" -#: ../../library/mmap.rst:194 +#: ../../library/mmap.rst:206 msgid "" "Returns the lowest index in the object where the subsequence *sub* is found, " "such that *sub* is contained in the range [*start*, *end*]. Optional " @@ -381,12 +397,12 @@ msgstr "" "*end*] 中。可選引數 *start* 和 *end* 的直譯方式與切片標記法相同。失敗時回傳 " "``-1``。" -#: ../../library/mmap.rst:199 ../../library/mmap.rst:292 -#: ../../library/mmap.rst:332 +#: ../../library/mmap.rst:211 ../../library/mmap.rst:320 +#: ../../library/mmap.rst:375 msgid "Writable :term:`bytes-like object` is now accepted." msgstr "現在接受可寫入的\\ :term:`類位元組物件 `。" -#: ../../library/mmap.rst:206 +#: ../../library/mmap.rst:217 msgid "" "Flushes changes made to the in-memory copy of a file back to disk. Without " "use of this call there is no guarantee that changes are written back before " @@ -400,13 +416,23 @@ msgstr "" "更會被排清到磁碟;否則會排清整個對映範圍。*offset* 必須是 :const:`PAGESIZE` " "或 :const:`ALLOCATIONGRANULARITY` 的倍數。" -#: ../../library/mmap.rst:213 +#: ../../library/mmap.rst:224 +msgid "" +"The *flags* parameter specifies the synchronization behavior. *flags* must " +"be one of the :ref:`MS_* constants ` available on the system." +msgstr "" + +#: ../../library/mmap.rst:228 +msgid "On Windows, the *flags* parameter is ignored." +msgstr "" + +#: ../../library/mmap.rst:230 msgid "" "``None`` is returned to indicate success. An exception is raised when the " "call failed." msgstr "回傳 ``None`` 表示成功。呼叫失敗時會引發例外。" -#: ../../library/mmap.rst:216 +#: ../../library/mmap.rst:233 msgid "" "Previously, a nonzero value was returned on success; zero was returned on " "error under Windows. A zero value was returned on success; an exception was " @@ -415,7 +441,19 @@ msgstr "" "以前在 Windows 上成功時會回傳非零值,錯誤時回傳零。在 Unix 上成功時回傳零值," "錯誤時引發例外。" -#: ../../library/mmap.rst:224 +#: ../../library/mmap.rst:238 +msgid "" +"Allow specifying *offset* without *size*. Previously, both *offset* and " +"*size* parameters were required together. Now *offset* can be specified " +"alone, and the flush operation will extend from *offset* to the end of the " +"mmap." +msgstr "" + +#: ../../library/mmap.rst:244 +msgid "Added *flags* parameter to control synchronization behavior." +msgstr "" + +#: ../../library/mmap.rst:250 msgid "" "Send advice *option* to the kernel about the memory region beginning at " "*start* and extending *length* bytes. *option* must be one of the :ref:" @@ -428,11 +466,11 @@ msgstr "" "之一。如果省略 *start* 和 *length*,則會涵蓋整個對映。在某些系統(包括 " "Linux)上,*start* 必須是 :const:`PAGESIZE` 的倍數。" -#: ../../library/mmap.rst:231 +#: ../../library/mmap.rst:257 msgid "Availability: Systems with the ``madvise()`` system call." msgstr "可用性:具有 ``madvise()`` 系統呼叫的系統。" -#: ../../library/mmap.rst:238 +#: ../../library/mmap.rst:264 msgid "" "Copy the *count* bytes starting at offset *src* to the destination index " "*dest*. If the mmap was created with :const:`ACCESS_READ`, then calls to " @@ -442,7 +480,7 @@ msgstr "" "是以 :const:`ACCESS_READ` 建立的,則對 move 的呼叫會引發 :exc:`TypeError` 例" "外。" -#: ../../library/mmap.rst:245 +#: ../../library/mmap.rst:271 msgid "" "Return a :class:`bytes` containing up to *n* bytes starting from the current " "file position. If the argument is omitted, ``None`` or negative, return all " @@ -453,17 +491,17 @@ msgstr "" "數被省略、為 ``None`` 或為負數,則回傳從目前檔案位置到對映結尾的所有位元組。檔案位" "置會被更新為指向回傳的位元組之後。" -#: ../../library/mmap.rst:251 +#: ../../library/mmap.rst:277 msgid "Argument can be omitted or ``None``." msgstr "引數可以省略或為 ``None``。" -#: ../../library/mmap.rst:256 +#: ../../library/mmap.rst:282 msgid "" "Returns a byte at the current file position as an integer, and advances the " "file position by 1." msgstr "以整數形式回傳目前檔案位置的位元組,並將檔案位置前進 1。" -#: ../../library/mmap.rst:262 +#: ../../library/mmap.rst:288 msgid "" "Returns a single line, starting at the current file position and up to the " "next newline. The file position is updated to point after the bytes that " @@ -472,11 +510,11 @@ msgstr "" "回傳從目前檔案位置開始到下一個換行符號的單一行。檔案位置會被更新為指向回傳的位" "元組之後。" -#: ../../library/mmap.rst:269 +#: ../../library/mmap.rst:295 msgid "Resizes the map and the underlying file, if any." msgstr "調整對映和底層檔案(如果有的話)的大小。" -#: ../../library/mmap.rst:271 +#: ../../library/mmap.rst:297 msgid "" "Resizing a map created with *access* of :const:`ACCESS_READ` or :const:" "`ACCESS_COPY`, will raise a :exc:`TypeError` exception. Resizing a map " @@ -487,7 +525,7 @@ msgstr "" "小會引發 :exc:`TypeError` 例外。調整以 *trackfd* 設定為 ``False`` 建立的對映" "大小會引發 :exc:`ValueError` 例外。" -#: ../../library/mmap.rst:276 +#: ../../library/mmap.rst:302 msgid "" "**On Windows**: Resizing the map will raise an :exc:`OSError` if there are " "other maps against the same named file. Resizing an anonymous map (ie " @@ -498,13 +536,17 @@ msgstr "" "`OSError`。調整匿名對映(即指向分頁檔案)的大小會靜默地建立一個新對映,並將原" "始資料複製到新大小的長度。" -#: ../../library/mmap.rst:281 +#: ../../library/mmap.rst:307 +msgid "Availability: Windows and systems with the ``mremap()`` system call." +msgstr "可用性:Windows 和具有 ``mremap()`` 系統呼叫的系統。" + +#: ../../library/mmap.rst:309 msgid "" "Correctly fails if attempting to resize when another map is held Allows " "resize against an anonymous map on Windows" msgstr "當持有另一個對映時嘗試調整大小會正確失敗;在 Windows 上允許對匿名對映調整大小" -#: ../../library/mmap.rst:287 +#: ../../library/mmap.rst:315 msgid "" "Returns the highest index in the object where the subsequence *sub* is " "found, such that *sub* is contained in the range [*start*, *end*]. Optional " @@ -515,7 +557,7 @@ msgstr "" "*end*] 中。可選引數 *start* 和 *end* 的直譯方式與切片標記法相同。失敗時回傳 " "``-1``。" -#: ../../library/mmap.rst:298 +#: ../../library/mmap.rst:326 msgid "" "Set the file's current position. *whence* argument is optional and defaults " "to ``os.SEEK_SET`` or ``0`` (absolute file positioning); other values are " @@ -526,27 +568,42 @@ msgstr "" "(絕對檔案定位);其他值為 ``os.SEEK_CUR`` 或 ``1``\\ (相對於目前位置的定位)" "和 ``os.SEEK_END`` 或 ``2``\\ (相對於檔案結尾的定位)。" -#: ../../library/mmap.rst:303 +#: ../../library/mmap.rst:331 msgid "Return the new absolute position instead of ``None``." msgstr "回傳新的絕對位置而非 ``None``。" -#: ../../library/mmap.rst:308 +#: ../../library/mmap.rst:336 msgid "" "Return whether the file supports seeking, and the return value is always " "``True``." msgstr "回傳檔案是否支援定位 (seeking),回傳值永遠為 ``True``。" -#: ../../library/mmap.rst:314 +#: ../../library/mmap.rst:342 +msgid "" +"Annotate the memory mapping with the given *name* for easier identification " +"in ``/proc//maps`` if the kernel supports the feature and :option:`-X " +"dev <-X>` is passed to Python or if Python is built in :ref:`debug mode " +"`. The length of *name* must not exceed 67 bytes including the " +"``'\\0'`` terminator." +msgstr "" + +#: ../../library/mmap.rst:353 msgid "" "Return the length of the file, which can be larger than the size of the " -"memory-mapped area." -msgstr "回傳檔案的長度,該長度可以大於記憶體對映區域的大小。" +"memory-mapped area. For an anonymous mapping, return its size." +msgstr "" +"回傳檔案的長度,該長度可以大於記憶體對映區域的大小。對於匿名對映,則回傳其大" +"小。" + +#: ../../library/mmap.rst:357 +msgid "Anonymous mappings are now supported on Unix." +msgstr "" -#: ../../library/mmap.rst:320 +#: ../../library/mmap.rst:363 msgid "Returns the current position of the file pointer." msgstr "回傳檔案指標的目前位置。" -#: ../../library/mmap.rst:325 +#: ../../library/mmap.rst:368 msgid "" "Write the bytes in *bytes* into memory at the current position of the file " "pointer and return the number of bytes written (never less than " @@ -560,11 +617,11 @@ msgstr "" "會被更新為指向寫入的位元組之後。如果 mmap 是以 :const:`ACCESS_READ` 建立的,則" "對其寫入會引發 :exc:`TypeError` 例外。" -#: ../../library/mmap.rst:335 +#: ../../library/mmap.rst:378 msgid "The number of bytes written is now returned." msgstr "現在會回傳寫入的位元組數。" -#: ../../library/mmap.rst:341 +#: ../../library/mmap.rst:384 msgid "" "Write the integer *byte* into memory at the current position of the file " "pointer; the file position is advanced by ``1``. If the mmap was created " @@ -574,26 +631,26 @@ msgstr "" "將整數 *byte* 寫入檔案指標目前位置的記憶體;檔案位置會前進 ``1``。如果 mmap " "是以 :const:`ACCESS_READ` 建立的,則對其寫入會引發 :exc:`TypeError` 例外。" -#: ../../library/mmap.rst:349 +#: ../../library/mmap.rst:392 msgid "MADV_* Constants" msgstr "MADV_* 常數" -#: ../../library/mmap.rst:376 +#: ../../library/mmap.rst:419 msgid "" "These options can be passed to :meth:`mmap.madvise`. Not every option will " "be present on every system." msgstr "" "這些選項可以傳遞給 :meth:`mmap.madvise`。並非每個選項都會出現在每個系統上。" -#: ../../library/mmap.rst:379 +#: ../../library/mmap.rst:422 msgid "Availability: Systems with the madvise() system call." msgstr "可用性:具有 madvise() 系統呼叫的系統。" -#: ../../library/mmap.rst:386 +#: ../../library/mmap.rst:429 msgid "MAP_* Constants" msgstr "MAP_* 常數" -#: ../../library/mmap.rst:410 +#: ../../library/mmap.rst:453 msgid "" "These are the various flags that can be passed to :meth:`mmap.mmap`. :data:" "`MAP_ALIGNED_SUPER` is only available at FreeBSD and :data:`MAP_CONCEAL` is " @@ -604,19 +661,19 @@ msgstr "" "在 FreeBSD 上可用,而 :data:`MAP_CONCEAL` 僅在 OpenBSD 上可用。請注意,某些選" "項可能不會出現在某些系統上。" -#: ../../library/mmap.rst:414 +#: ../../library/mmap.rst:457 msgid "Added :data:`MAP_POPULATE` constant." msgstr "新增 :data:`MAP_POPULATE` 常數。" -#: ../../library/mmap.rst:417 +#: ../../library/mmap.rst:460 msgid "Added :data:`MAP_STACK` constant." msgstr "新增 :data:`MAP_STACK` 常數。" -#: ../../library/mmap.rst:420 +#: ../../library/mmap.rst:463 msgid "Added :data:`MAP_ALIGNED_SUPER` and :data:`MAP_CONCEAL` constants." msgstr "新增 :data:`MAP_ALIGNED_SUPER` 和 :data:`MAP_CONCEAL` 常數。" -#: ../../library/mmap.rst:423 +#: ../../library/mmap.rst:466 msgid "" "Added :data:`MAP_32BIT`, :data:`MAP_HASSEMAPHORE`, :data:`MAP_JIT`, :data:" "`MAP_NOCACHE`, :data:`MAP_NOEXTEND`, :data:`MAP_NORESERVE`, :data:" @@ -627,3 +684,30 @@ msgstr "" "`MAP_NOCACHE`、:data:`MAP_NOEXTEND`、:data:`MAP_NORESERVE`、:data:" "`MAP_RESILIENT_CODESIGN`、:data:`MAP_RESILIENT_MEDIA`、:data:`MAP_TPRO`、:" "data:`MAP_TRANSLATED_ALLOW_EXECUTE` 和 :data:`MAP_UNIX03` 常數。" + +#: ../../library/mmap.rst:476 +msgid "MS_* Constants" +msgstr "MS_* 常數" + +#: ../../library/mmap.rst:482 +msgid "" +"These flags control the synchronization behavior for :meth:`mmap.flush`:" +msgstr "" + +#: ../../library/mmap.rst:484 +msgid "" +":data:`MS_SYNC` - Synchronous flush: writes are scheduled and the call " +"blocks until they are physically written to storage." +msgstr "" + +#: ../../library/mmap.rst:486 +msgid "" +":data:`MS_ASYNC` - Asynchronous flush: writes are scheduled but the call " +"returns immediately without waiting for completion." +msgstr "" + +#: ../../library/mmap.rst:488 +msgid "" +":data:`MS_INVALIDATE` - Invalidate cached data: invalidates other mappings " +"of the same file so they can see the changes." +msgstr "" diff --git a/library/modulefinder.po b/library/modulefinder.po index fd679ecc19a..598bacda860 100644 --- a/library/modulefinder.po +++ b/library/modulefinder.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-05-11 14:42+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!modulefinder` --- Find modules used by a script" msgstr ":mod:`!modulefinder` --- 搜尋腳本所使用的模組" -#: ../../library/modulefinder.rst:9 +#: ../../library/modulefinder.rst:7 msgid "**Source code:** :source:`Lib/modulefinder.py`" msgstr "**原始碼:**\\ :source:`Lib/modulefinder.py`" -#: ../../library/modulefinder.rst:13 +#: ../../library/modulefinder.rst:11 msgid "" "This module provides a :class:`ModuleFinder` class that can be used to " "determine the set of modules imported by a script. ``modulefinder.py`` can " @@ -37,19 +37,19 @@ msgstr "" "``modulefinder.py`` 也可以作為腳本運行,其將 Python 腳本的檔案名稱作為它的引" "數,並在之後會列印出引入模組的報告。" -#: ../../library/modulefinder.rst:21 +#: ../../library/modulefinder.rst:19 msgid "" "Record that the package named *pkg_name* can be found in the specified " "*path*." msgstr "記錄在指定的 *path* 中可以找到名為 *pkg_name* 的套件。" -#: ../../library/modulefinder.rst:26 +#: ../../library/modulefinder.rst:24 msgid "" "Allows specifying that the module named *oldname* is in fact the package " "named *newname*." msgstr "允許指定名為 *oldname* 的模組實際上是名為 *newname* 的套件。" -#: ../../library/modulefinder.rst:32 +#: ../../library/modulefinder.rst:30 msgid "" "This class provides :meth:`run_script` and :meth:`report` methods to " "determine the set of modules imported by a script. *path* can be a list of " @@ -65,7 +65,7 @@ msgstr "" "*excludes* 是要從分析中排除的模組名稱串列。*replace_paths* 是將在模組路徑中替" "換的 ``(oldpath, newpath)`` 元組串列。" -#: ../../library/modulefinder.rst:43 +#: ../../library/modulefinder.rst:41 msgid "" "Print a report to standard output that lists the modules imported by the " "script and their paths, as well as modules that are missing or seem to be " @@ -74,26 +74,26 @@ msgstr "" "將報告列印到標準輸出,其中列出了腳本引入的模組及其路徑,以及丟失或似乎丟失的" "模組。" -#: ../../library/modulefinder.rst:49 +#: ../../library/modulefinder.rst:47 msgid "" "Analyze the contents of the *pathname* file, which must contain Python code." msgstr "分析 *pathname* 檔案的內容,該檔案必須包含 Python 程式碼。" -#: ../../library/modulefinder.rst:54 +#: ../../library/modulefinder.rst:52 msgid "" "A dictionary mapping module names to modules. See :ref:`modulefinder-" "example`." msgstr "將模組名稱對應到模組的字典。請參閱 :ref:`modulefinder-example`。" -#: ../../library/modulefinder.rst:61 +#: ../../library/modulefinder.rst:59 msgid "Example usage of :class:`ModuleFinder`" msgstr ":class:`ModuleFinder` 的用法範例" -#: ../../library/modulefinder.rst:63 +#: ../../library/modulefinder.rst:61 msgid "The script that is going to get analyzed later on (bacon.py)::" msgstr "將被分析的腳本 (bacon.py): ::" -#: ../../library/modulefinder.rst:65 +#: ../../library/modulefinder.rst:63 msgid "" "import re, itertools\n" "\n" @@ -119,11 +119,11 @@ msgstr "" "except ImportError:\n" " pass" -#: ../../library/modulefinder.rst:78 +#: ../../library/modulefinder.rst:76 msgid "The script that will output the report of bacon.py::" msgstr "將輸出 bacon.py 報告的腳本: ::" -#: ../../library/modulefinder.rst:80 +#: ../../library/modulefinder.rst:78 msgid "" "from modulefinder import ModuleFinder\n" "\n" @@ -153,11 +153,11 @@ msgstr "" "print('模組沒有被引入:')\n" "print('\\n'.join(finder.badmodules.keys()))" -#: ../../library/modulefinder.rst:94 +#: ../../library/modulefinder.rst:92 msgid "Sample output (may vary depending on the architecture)::" msgstr "範例輸出(可能因架構而異): ::" -#: ../../library/modulefinder.rst:96 +#: ../../library/modulefinder.rst:94 msgid "" "Loaded modules:\n" "_types:\n" diff --git a/library/msvcrt.po b/library/msvcrt.po index 98bbb389089..2797a57595e 100644 --- a/library/msvcrt.po +++ b/library/msvcrt.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-20 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,6 +21,10 @@ msgstr "" msgid ":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime" msgstr ":mod:`!msvcrt` --- MS VC++ runtime 提供的有用例程" +#: ../../library/msvcrt.rst:7 +msgid "**Source code:** :source:`PC/msvcrtmodule.c`" +msgstr "" + #: ../../library/msvcrt.rst:11 msgid "" "These functions provide access to some useful capabilities on Windows " diff --git a/library/multiprocessing.po b/library/multiprocessing.po index 3bcebadbc21..7f87e8ea89d 100644 --- a/library/multiprocessing.po +++ b/library/multiprocessing.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-14 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -1495,13 +1495,13 @@ msgstr "" #: ../../library/multiprocessing.rst:938 ../../library/multiprocessing.rst:1057 #: ../../library/multiprocessing.rst:1090 -#: ../../library/multiprocessing.rst:1446 #: ../../library/multiprocessing.rst:1456 -#: ../../library/multiprocessing.rst:1479 +#: ../../library/multiprocessing.rst:1466 #: ../../library/multiprocessing.rst:1489 -#: ../../library/multiprocessing.rst:1506 -#: ../../library/multiprocessing.rst:1566 -#: ../../library/multiprocessing.rst:1628 +#: ../../library/multiprocessing.rst:1499 +#: ../../library/multiprocessing.rst:1516 +#: ../../library/multiprocessing.rst:1576 +#: ../../library/multiprocessing.rst:1638 msgid "" "Instantiating this class may set the global start method. See :ref:`global-" "start-method` for more details." @@ -1526,7 +1526,7 @@ msgid "" "multiprocessing semantics, this number is not reliable." msgstr "" -#: ../../library/multiprocessing.rst:953 ../../library/multiprocessing.rst:1639 +#: ../../library/multiprocessing.rst:953 ../../library/multiprocessing.rst:1649 msgid "" "Note that this may raise :exc:`NotImplementedError` on platforms like macOS " "where ``sem_getvalue()`` is not implemented." @@ -1901,24 +1901,37 @@ msgstr "接受一個\\ :term:`類路徑物件 `。" 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 " -"processes. Any :exc:`ImportError` when doing so is silently ignored. This " -"can be used as a performance enhancement to avoid repeated work in every " -"process." +"processes. This can be used as a performance enhancement to avoid repeated " +"work in every process." msgstr "" -#: ../../library/multiprocessing.rst:1256 +#: ../../library/multiprocessing.rst:1255 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:1259 +#: ../../library/multiprocessing.rst:1258 +msgid "" +"The *on_error* parameter controls how :exc:`ImportError` exceptions during " +"module preloading are handled: ``\"ignore\"`` (default) silently ignores " +"failures, ``\"warn\"`` causes the forkserver subprocess to emit an :exc:" +"`ImportWarning` to stderr, and ``\"fail\"`` causes the forkserver subprocess " +"to exit with the exception traceback on stderr, making subsequent process " +"creation fail with :exc:`EOFError` or :exc:`ConnectionError`." +msgstr "" + +#: ../../library/multiprocessing.rst:1266 msgid "" "Only meaningful when using the ``'forkserver'`` start method. See :ref:" "`multiprocessing-start-methods`." msgstr "" -#: ../../library/multiprocessing.rst:1266 +#: ../../library/multiprocessing.rst:1271 +msgid "Added the *on_error* parameter." +msgstr "新增 *on_error* 參數。" + +#: ../../library/multiprocessing.rst:1276 msgid "" "Set the method which should be used to start child processes. The *method* " "argument can be ``'fork'``, ``'spawn'`` or ``'forkserver'``. Raises :exc:" @@ -1928,17 +1941,17 @@ msgid "" "then the context is set to the default context." msgstr "" -#: ../../library/multiprocessing.rst:1273 +#: ../../library/multiprocessing.rst:1283 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:1277 +#: ../../library/multiprocessing.rst:1287 msgid "See :ref:`multiprocessing-start-methods`." msgstr "參閱 :ref:`multiprocessing-start-methods`。" -#: ../../library/multiprocessing.rst:1283 +#: ../../library/multiprocessing.rst:1293 msgid "" ":mod:`!multiprocessing` contains no analogues of :func:`threading." "active_count`, :func:`threading.enumerate`, :func:`threading.settrace`, :" @@ -1946,75 +1959,75 @@ msgid "" "local`." msgstr "" -#: ../../library/multiprocessing.rst:1290 +#: ../../library/multiprocessing.rst:1300 msgid "Connection Objects" msgstr "" -#: ../../library/multiprocessing.rst:1294 +#: ../../library/multiprocessing.rst:1304 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:1297 +#: ../../library/multiprocessing.rst:1307 msgid "" "Connection objects are usually created using :func:`Pipe ` -- see also :ref:`multiprocessing-listeners-clients`." msgstr "" -#: ../../library/multiprocessing.rst:1305 +#: ../../library/multiprocessing.rst:1315 msgid "" "Send an object to the other end of the connection which should be read " "using :meth:`recv`." msgstr "" -#: ../../library/multiprocessing.rst:1308 +#: ../../library/multiprocessing.rst:1318 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:1313 +#: ../../library/multiprocessing.rst:1323 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:1320 +#: ../../library/multiprocessing.rst:1330 msgid "Return the file descriptor or handle used by the connection." msgstr "" -#: ../../library/multiprocessing.rst:1324 +#: ../../library/multiprocessing.rst:1334 msgid "Close the connection." msgstr "" -#: ../../library/multiprocessing.rst:1326 +#: ../../library/multiprocessing.rst:1336 msgid "This is called automatically when the connection is garbage collected." msgstr "" -#: ../../library/multiprocessing.rst:1330 +#: ../../library/multiprocessing.rst:1340 msgid "Return whether there is any data available to be read." msgstr "" -#: ../../library/multiprocessing.rst:1332 +#: ../../library/multiprocessing.rst:1342 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:1336 +#: ../../library/multiprocessing.rst:1346 msgid "" "Note that multiple connection objects may be polled at once by using :func:" "`multiprocessing.connection.wait`." msgstr "" -#: ../../library/multiprocessing.rst:1341 +#: ../../library/multiprocessing.rst:1351 msgid "Send byte data from a :term:`bytes-like object` as a complete message." msgstr "" -#: ../../library/multiprocessing.rst:1343 +#: ../../library/multiprocessing.rst:1353 msgid "" "If *offset* is given then data is read from that position in *buf*. If " "*size* is given then that many bytes will be read from *buf*. Very large " @@ -2022,7 +2035,7 @@ msgid "" "exc:`ValueError` exception" msgstr "" -#: ../../library/multiprocessing.rst:1350 +#: ../../library/multiprocessing.rst:1360 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 :" @@ -2030,19 +2043,19 @@ msgid "" "closed." msgstr "" -#: ../../library/multiprocessing.rst:1355 +#: ../../library/multiprocessing.rst:1365 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:1359 +#: ../../library/multiprocessing.rst:1369 msgid "" "This function used to raise :exc:`IOError`, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/multiprocessing.rst:1366 +#: ../../library/multiprocessing.rst:1376 msgid "" "Read into *buf* a complete message of byte data sent from the other end of " "the connection and return the number of bytes in the message. Blocks until " @@ -2050,38 +2063,38 @@ msgid "" "left to receive and the other end was closed." msgstr "" -#: ../../library/multiprocessing.rst:1372 +#: ../../library/multiprocessing.rst:1382 msgid "" "*buf* 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 *buf* (in bytes)." msgstr "" -#: ../../library/multiprocessing.rst:1377 +#: ../../library/multiprocessing.rst:1387 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:1381 +#: ../../library/multiprocessing.rst:1391 msgid "" "Connection objects themselves can now be transferred between processes " "using :meth:`Connection.send` and :meth:`Connection.recv`." msgstr "" -#: ../../library/multiprocessing.rst:1385 +#: ../../library/multiprocessing.rst:1395 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:1389 +#: ../../library/multiprocessing.rst:1399 msgid "For example:" msgstr "舉例來說:" -#: ../../library/multiprocessing.rst:1391 +#: ../../library/multiprocessing.rst:1401 msgid "" ">>> from multiprocessing import Pipe\n" ">>> a, b = Pipe()\n" @@ -2117,14 +2130,14 @@ msgstr "" ">>> arr2\n" "array('i', [0, 1, 2, 3, 4, 0, 0, 0, 0, 0])" -#: ../../library/multiprocessing.rst:1414 +#: ../../library/multiprocessing.rst:1424 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:1418 +#: ../../library/multiprocessing.rst:1428 msgid "" "Therefore, unless the connection object was produced using :func:`Pipe` you " "should only use the :meth:`~Connection.recv` and :meth:`~Connection.send` " @@ -2132,80 +2145,80 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:1425 +#: ../../library/multiprocessing.rst:1435 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:1431 +#: ../../library/multiprocessing.rst:1441 msgid "Synchronization primitives" msgstr "" -#: ../../library/multiprocessing.rst:1435 +#: ../../library/multiprocessing.rst:1445 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:1439 +#: ../../library/multiprocessing.rst:1449 msgid "" "Note that one can also create synchronization primitives by using a manager " "object -- see :ref:`multiprocessing-managers`." msgstr "" -#: ../../library/multiprocessing.rst:1444 +#: ../../library/multiprocessing.rst:1454 msgid "A barrier object: a clone of :class:`threading.Barrier`." msgstr "" -#: ../../library/multiprocessing.rst:1453 +#: ../../library/multiprocessing.rst:1463 msgid "" "A bounded semaphore object: a close analog of :class:`threading." "BoundedSemaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1459 -#: ../../library/multiprocessing.rst:1631 +#: ../../library/multiprocessing.rst:1469 +#: ../../library/multiprocessing.rst:1641 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:1464 -#: ../../library/multiprocessing.rst:1549 -#: ../../library/multiprocessing.rst:1619 -#: ../../library/multiprocessing.rst:1645 +#: ../../library/multiprocessing.rst:1474 +#: ../../library/multiprocessing.rst:1559 +#: ../../library/multiprocessing.rst:1629 +#: ../../library/multiprocessing.rst:1655 msgid "Return a boolean indicating whether this object is locked right now." msgstr "" -#: ../../library/multiprocessing.rst:1469 +#: ../../library/multiprocessing.rst:1479 msgid "" "On macOS, this is indistinguishable from :class:`Semaphore` because " "``sem_getvalue()`` is not implemented on that platform." msgstr "" -#: ../../library/multiprocessing.rst:1474 +#: ../../library/multiprocessing.rst:1484 msgid "A condition variable: an alias for :class:`threading.Condition`." msgstr "" -#: ../../library/multiprocessing.rst:1476 +#: ../../library/multiprocessing.rst:1486 msgid "" "If *lock* is specified then it should be a :class:`Lock` or :class:`RLock` " "object from :mod:`!multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:1482 -#: ../../library/multiprocessing.rst:2080 +#: ../../library/multiprocessing.rst:1492 +#: ../../library/multiprocessing.rst:2090 msgid "The :meth:`~threading.Condition.wait_for` method was added." msgstr "新增 :meth:`~threading.Condition.wait_for` 方法。" -#: ../../library/multiprocessing.rst:1487 +#: ../../library/multiprocessing.rst:1497 msgid "A clone of :class:`threading.Event`." msgstr "" -#: ../../library/multiprocessing.rst:1494 +#: ../../library/multiprocessing.rst:1504 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 " @@ -2216,25 +2229,25 @@ msgid "" "as noted." msgstr "" -#: ../../library/multiprocessing.rst:1502 +#: ../../library/multiprocessing.rst:1512 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:1509 +#: ../../library/multiprocessing.rst:1519 msgid "" ":class:`Lock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1514 -#: ../../library/multiprocessing.rst:1575 +#: ../../library/multiprocessing.rst:1524 +#: ../../library/multiprocessing.rst:1585 msgid "Acquire a lock, blocking or non-blocking." msgstr "" -#: ../../library/multiprocessing.rst:1516 +#: ../../library/multiprocessing.rst:1526 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 " @@ -2242,14 +2255,14 @@ msgid "" "that in :meth:`threading.Lock.acquire`." msgstr "" -#: ../../library/multiprocessing.rst:1521 +#: ../../library/multiprocessing.rst:1531 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:1525 +#: ../../library/multiprocessing.rst:1535 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 " @@ -2263,19 +2276,19 @@ msgid "" "acquired or ``False`` if the timeout period has elapsed." msgstr "" -#: ../../library/multiprocessing.rst:1540 +#: ../../library/multiprocessing.rst:1550 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:1543 +#: ../../library/multiprocessing.rst:1553 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:1556 +#: ../../library/multiprocessing.rst:1566 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. " @@ -2284,20 +2297,20 @@ msgid "" "release it once for each time it has been acquired." msgstr "" -#: ../../library/multiprocessing.rst:1562 +#: ../../library/multiprocessing.rst:1572 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:1569 +#: ../../library/multiprocessing.rst:1579 msgid "" ":class:`RLock` supports the :term:`context manager` protocol and thus may be " "used in :keyword:`with` statements." msgstr "" -#: ../../library/multiprocessing.rst:1577 +#: ../../library/multiprocessing.rst:1587 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 " @@ -2310,7 +2323,7 @@ msgid "" "itself." msgstr "" -#: ../../library/multiprocessing.rst:1587 +#: ../../library/multiprocessing.rst:1597 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 " @@ -2321,14 +2334,14 @@ msgid "" "a return value of ``True``." msgstr "" -#: ../../library/multiprocessing.rst:1595 +#: ../../library/multiprocessing.rst:1605 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:1602 +#: ../../library/multiprocessing.rst:1612 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 " @@ -2338,7 +2351,7 @@ msgid "" "locked and owned by the calling process or thread." msgstr "" -#: ../../library/multiprocessing.rst:1610 +#: ../../library/multiprocessing.rst:1620 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 " @@ -2347,21 +2360,21 @@ msgid "" "from the implemented behavior in :meth:`threading.RLock.release`." msgstr "" -#: ../../library/multiprocessing.rst:1626 +#: ../../library/multiprocessing.rst:1636 msgid "A semaphore object: a close analog of :class:`threading.Semaphore`." msgstr "" -#: ../../library/multiprocessing.rst:1637 +#: ../../library/multiprocessing.rst:1647 msgid "Return the current value of semaphore." msgstr "" -#: ../../library/multiprocessing.rst:1652 +#: ../../library/multiprocessing.rst:1662 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:1657 +#: ../../library/multiprocessing.rst:1667 msgid "" "Some of this package's functionality requires a functioning shared semaphore " "implementation on the host operating system. Without one, the :mod:" @@ -2370,32 +2383,32 @@ msgid "" "additional information." msgstr "" -#: ../../library/multiprocessing.rst:1665 +#: ../../library/multiprocessing.rst:1675 msgid "Shared :mod:`ctypes` Objects" msgstr "共享的 :mod:`ctypes` 物件" -#: ../../library/multiprocessing.rst:1667 +#: ../../library/multiprocessing.rst:1677 msgid "" "It is possible to create shared objects using shared memory which can be " "inherited by child processes." msgstr "" -#: ../../library/multiprocessing.rst:1672 +#: ../../library/multiprocessing.rst:1682 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:1676 -#: ../../library/multiprocessing.rst:1769 +#: ../../library/multiprocessing.rst:1686 +#: ../../library/multiprocessing.rst:1779 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:1680 +#: ../../library/multiprocessing.rst:1690 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` " @@ -2405,24 +2418,24 @@ msgid "" "\"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1687 +#: ../../library/multiprocessing.rst:1697 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:1691 +#: ../../library/multiprocessing.rst:1701 msgid "counter.value += 1" msgstr "counter.value += 1" -#: ../../library/multiprocessing.rst:1693 +#: ../../library/multiprocessing.rst:1703 msgid "" "Assuming the associated lock is recursive (which it is by default) you can " "instead do ::" msgstr "" -#: ../../library/multiprocessing.rst:1696 +#: ../../library/multiprocessing.rst:1706 msgid "" "with counter.get_lock():\n" " counter.value += 1" @@ -2430,17 +2443,17 @@ msgstr "" "with counter.get_lock():\n" " counter.value += 1" -#: ../../library/multiprocessing.rst:1699 +#: ../../library/multiprocessing.rst:1709 msgid "Note that *lock* is a keyword-only argument." msgstr "" -#: ../../library/multiprocessing.rst:1703 +#: ../../library/multiprocessing.rst:1713 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:1706 +#: ../../library/multiprocessing.rst:1716 msgid "" "*typecode_or_type* determines the type of the elements of the returned " "array: it is either a :ref:`ctypes type ` or " @@ -2453,7 +2466,7 @@ msgid "" "of the array." msgstr "" -#: ../../library/multiprocessing.rst:1716 +#: ../../library/multiprocessing.rst:1726 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:" @@ -2463,11 +2476,11 @@ msgid "" "safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1723 +#: ../../library/multiprocessing.rst:1733 msgid "Note that *lock* is a keyword only argument." msgstr "" -#: ../../library/multiprocessing.rst:1725 +#: ../../library/multiprocessing.rst:1735 msgid "" "Note that an array of :data:`ctypes.c_char` has *value* and *raw* attributes " "which can both be used to store and retrieve byte strings. While *raw* " @@ -2476,18 +2489,18 @@ msgid "" "languages handle strings." msgstr "" -#: ../../library/multiprocessing.rst:1733 +#: ../../library/multiprocessing.rst:1743 msgid "The :mod:`!multiprocessing.sharedctypes` module" msgstr ":mod:`!multiprocessing.sharedctypes` 模組" -#: ../../library/multiprocessing.rst:1738 +#: ../../library/multiprocessing.rst:1748 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:1744 +#: ../../library/multiprocessing.rst:1754 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. " @@ -2496,11 +2509,11 @@ msgid "" "may cause a crash." msgstr "" -#: ../../library/multiprocessing.rst:1752 +#: ../../library/multiprocessing.rst:1762 msgid "Return a ctypes array allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1754 +#: ../../library/multiprocessing.rst:1764 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 " @@ -2510,40 +2523,40 @@ msgid "" "initialize the array and whose length determines the length of the array." msgstr "" -#: ../../library/multiprocessing.rst:1761 +#: ../../library/multiprocessing.rst:1771 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:1767 +#: ../../library/multiprocessing.rst:1777 msgid "Return a ctypes object allocated from shared memory." msgstr "" -#: ../../library/multiprocessing.rst:1773 +#: ../../library/multiprocessing.rst:1783 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:1777 +#: ../../library/multiprocessing.rst:1787 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:1783 +#: ../../library/multiprocessing.rst:1793 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:1787 -#: ../../library/multiprocessing.rst:1807 +#: ../../library/multiprocessing.rst:1797 +#: ../../library/multiprocessing.rst:1817 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." @@ -2553,128 +2566,128 @@ msgid "" "not necessarily be \"process-safe\"." msgstr "" -#: ../../library/multiprocessing.rst:1795 -#: ../../library/multiprocessing.rst:1814 -#: ../../library/multiprocessing.rst:1831 -#: ../../library/multiprocessing.rst:1952 +#: ../../library/multiprocessing.rst:1805 +#: ../../library/multiprocessing.rst:1824 +#: ../../library/multiprocessing.rst:1841 +#: ../../library/multiprocessing.rst:1962 msgid "" "*ctx* is a context object, or ``None`` (use the current context). If " "``None``, calling this may set the global start method. See :ref:`global-" "start-method` for more details." msgstr "" -#: ../../library/multiprocessing.rst:1799 -#: ../../library/multiprocessing.rst:1818 +#: ../../library/multiprocessing.rst:1809 +#: ../../library/multiprocessing.rst:1828 msgid "Note that *lock* and *ctx* are keyword-only parameters." msgstr "" -#: ../../library/multiprocessing.rst:1803 +#: ../../library/multiprocessing.rst:1813 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:1822 +#: ../../library/multiprocessing.rst:1832 msgid "" "Return a ctypes object allocated from shared memory which is a copy of the " "ctypes object *obj*." msgstr "" -#: ../../library/multiprocessing.rst:1827 +#: ../../library/multiprocessing.rst:1837 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:1835 +#: ../../library/multiprocessing.rst:1845 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:1839 +#: ../../library/multiprocessing.rst:1849 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:1842 +#: ../../library/multiprocessing.rst:1852 msgid "Synchronized objects support the :term:`context manager` protocol." msgstr "" -#: ../../library/multiprocessing.rst:1846 +#: ../../library/multiprocessing.rst:1856 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:1851 +#: ../../library/multiprocessing.rst:1861 msgid "ctypes" msgstr "ctypes" -#: ../../library/multiprocessing.rst:1851 +#: ../../library/multiprocessing.rst:1861 msgid "sharedctypes using type" msgstr "" -#: ../../library/multiprocessing.rst:1851 +#: ../../library/multiprocessing.rst:1861 msgid "sharedctypes using typecode" msgstr "" -#: ../../library/multiprocessing.rst:1853 +#: ../../library/multiprocessing.rst:1863 msgid "c_double(2.4)" msgstr "c_double(2.4)" -#: ../../library/multiprocessing.rst:1853 +#: ../../library/multiprocessing.rst:1863 msgid "RawValue(c_double, 2.4)" msgstr "RawValue(c_double, 2.4)" -#: ../../library/multiprocessing.rst:1853 +#: ../../library/multiprocessing.rst:1863 msgid "RawValue('d', 2.4)" msgstr "RawValue('d', 2.4)" -#: ../../library/multiprocessing.rst:1854 +#: ../../library/multiprocessing.rst:1864 msgid "MyStruct(4, 6)" msgstr "MyStruct(4, 6)" -#: ../../library/multiprocessing.rst:1854 +#: ../../library/multiprocessing.rst:1864 msgid "RawValue(MyStruct, 4, 6)" msgstr "RawValue(MyStruct, 4, 6)" -#: ../../library/multiprocessing.rst:1855 +#: ../../library/multiprocessing.rst:1865 msgid "(c_short * 7)()" msgstr "(c_short * 7)()" -#: ../../library/multiprocessing.rst:1855 +#: ../../library/multiprocessing.rst:1865 msgid "RawArray(c_short, 7)" msgstr "RawArray(c_short, 7)" -#: ../../library/multiprocessing.rst:1855 +#: ../../library/multiprocessing.rst:1865 msgid "RawArray('h', 7)" msgstr "RawArray('h', 7)" -#: ../../library/multiprocessing.rst:1856 +#: ../../library/multiprocessing.rst:1866 msgid "(c_int * 3)(9, 2, 8)" msgstr "(c_int * 3)(9, 2, 8)" -#: ../../library/multiprocessing.rst:1856 +#: ../../library/multiprocessing.rst:1866 msgid "RawArray(c_int, (9, 2, 8))" msgstr "RawArray(c_int, (9, 2, 8))" -#: ../../library/multiprocessing.rst:1856 +#: ../../library/multiprocessing.rst:1866 msgid "RawArray('i', (9, 2, 8))" msgstr "RawArray('i', (9, 2, 8))" -#: ../../library/multiprocessing.rst:1860 +#: ../../library/multiprocessing.rst:1870 msgid "" "Below is an example where a number of ctypes objects are modified by a child " "process::" msgstr "" -#: ../../library/multiprocessing.rst:1863 +#: ../../library/multiprocessing.rst:1873 msgid "" "from multiprocessing import Process, Lock\n" "from multiprocessing.sharedctypes import Value, Array\n" @@ -2740,11 +2753,11 @@ msgstr "" " print(s.value)\n" " print([(a.x, a.y) for a in A])" -#: ../../library/multiprocessing.rst:1898 +#: ../../library/multiprocessing.rst:1908 msgid "The results printed are ::" msgstr "" -#: ../../library/multiprocessing.rst:1900 +#: ../../library/multiprocessing.rst:1910 msgid "" "49\n" "0.1111111111111111\n" @@ -2756,11 +2769,11 @@ msgstr "" "HELLO WORLD\n" "[(3.515625, 39.0625), (33.0625, 4.0), (5.640625, 90.25)]" -#: ../../library/multiprocessing.rst:1911 +#: ../../library/multiprocessing.rst:1921 msgid "Managers" msgstr "" -#: ../../library/multiprocessing.rst:1913 +#: ../../library/multiprocessing.rst:1923 msgid "" "Managers provide a way to create data which can be shared between different " "processes, including sharing over a network between processes running on " @@ -2769,7 +2782,7 @@ msgid "" "proxies." msgstr "" -#: ../../library/multiprocessing.rst:1922 +#: ../../library/multiprocessing.rst:1932 msgid "" "Returns a started :class:`~multiprocessing.managers.SyncManager` object " "which can be used for sharing objects between processes. The returned " @@ -2777,31 +2790,31 @@ msgid "" "will create shared objects and return corresponding proxies." msgstr "" -#: ../../library/multiprocessing.rst:1930 +#: ../../library/multiprocessing.rst:1940 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:1936 +#: ../../library/multiprocessing.rst:1946 msgid "Create a BaseManager object." msgstr "建立一個 BaseManager 物件。" -#: ../../library/multiprocessing.rst:1938 +#: ../../library/multiprocessing.rst:1948 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:1941 +#: ../../library/multiprocessing.rst:1951 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:1944 +#: ../../library/multiprocessing.rst:1954 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`` " @@ -2809,13 +2822,13 @@ msgid "" "it must be a byte string." msgstr "" -#: ../../library/multiprocessing.rst:1949 +#: ../../library/multiprocessing.rst:1959 msgid "" "*serializer* must be ``'pickle'`` (use :mod:`pickle` serialization) or " "``'xmlrpclib'`` (use :mod:`xmlrpc.client` serialization)." msgstr "" -#: ../../library/multiprocessing.rst:1956 +#: ../../library/multiprocessing.rst:1966 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 " @@ -2823,24 +2836,24 @@ msgid "" "also times out, the process is killed." msgstr "" -#: ../../library/multiprocessing.rst:1961 +#: ../../library/multiprocessing.rst:1971 msgid "Added the *shutdown_timeout* parameter." msgstr "新增 *shutdown_timeout* 參數。" -#: ../../library/multiprocessing.rst:1966 +#: ../../library/multiprocessing.rst:1976 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:1971 +#: ../../library/multiprocessing.rst:1981 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:1975 +#: ../../library/multiprocessing.rst:1985 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> manager = BaseManager(address=('', 50000), authkey=b'abc')\n" @@ -2852,15 +2865,15 @@ msgstr "" ">>> server = manager.get_server()\n" ">>> server.serve_forever()" -#: ../../library/multiprocessing.rst:1980 +#: ../../library/multiprocessing.rst:1990 msgid ":class:`Server` additionally has an :attr:`address` attribute." msgstr "" -#: ../../library/multiprocessing.rst:1984 +#: ../../library/multiprocessing.rst:1994 msgid "Connect a local manager object to a remote manager process::" msgstr "" -#: ../../library/multiprocessing.rst:1986 +#: ../../library/multiprocessing.rst:1996 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" @@ -2870,29 +2883,29 @@ msgstr "" ">>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')\n" ">>> m.connect()" -#: ../../library/multiprocessing.rst:1992 +#: ../../library/multiprocessing.rst:2002 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:1995 +#: ../../library/multiprocessing.rst:2005 msgid "This can be called multiple times." msgstr "" -#: ../../library/multiprocessing.rst:1999 +#: ../../library/multiprocessing.rst:2009 msgid "" "A classmethod which can be used for registering a type or callable with the " "manager class." msgstr "" -#: ../../library/multiprocessing.rst:2002 +#: ../../library/multiprocessing.rst:2012 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:2005 +#: ../../library/multiprocessing.rst:2015 msgid "" "*callable* is a callable used for creating objects for this type " "identifier. If a manager instance will be connected to the server using " @@ -2900,14 +2913,14 @@ msgid "" "then this can be left as ``None``." msgstr "" -#: ../../library/multiprocessing.rst:2011 +#: ../../library/multiprocessing.rst:2021 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:2015 +#: ../../library/multiprocessing.rst:2025 msgid "" "*exposed* is used to specify a sequence of method names which proxies for " "this typeid should be allowed to access using :meth:`BaseProxy." @@ -2918,7 +2931,7 @@ msgid "" "method and whose name does not begin with ``'_'``.)" msgstr "" -#: ../../library/multiprocessing.rst:2024 +#: ../../library/multiprocessing.rst:2034 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 " @@ -2928,22 +2941,22 @@ msgid "" "returned by the method will be copied by value." msgstr "" -#: ../../library/multiprocessing.rst:2031 +#: ../../library/multiprocessing.rst:2041 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:2035 +#: ../../library/multiprocessing.rst:2045 msgid ":class:`BaseManager` instances also have one read-only property:" msgstr "" -#: ../../library/multiprocessing.rst:2039 +#: ../../library/multiprocessing.rst:2049 msgid "The address used by the manager." msgstr "" -#: ../../library/multiprocessing.rst:2041 +#: ../../library/multiprocessing.rst:2051 msgid "" "Manager objects support the context management protocol -- see :ref:" "`typecontextmanager`. :meth:`~contextmanager.__enter__` starts the server " @@ -2951,129 +2964,129 @@ msgid "" "object. :meth:`~contextmanager.__exit__` calls :meth:`shutdown`." msgstr "" -#: ../../library/multiprocessing.rst:2047 +#: ../../library/multiprocessing.rst:2057 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:2052 +#: ../../library/multiprocessing.rst:2062 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:2056 +#: ../../library/multiprocessing.rst:2066 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:2062 +#: ../../library/multiprocessing.rst:2072 msgid "" "Create a shared :class:`threading.Barrier` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2069 +#: ../../library/multiprocessing.rst:2079 msgid "" "Create a shared :class:`threading.BoundedSemaphore` object and return a " "proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2074 +#: ../../library/multiprocessing.rst:2084 msgid "" "Create a shared :class:`threading.Condition` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:2077 +#: ../../library/multiprocessing.rst:2087 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:2085 +#: ../../library/multiprocessing.rst:2095 msgid "" "Create a shared :class:`threading.Event` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2089 +#: ../../library/multiprocessing.rst:2099 msgid "" "Create a shared :class:`threading.Lock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2093 +#: ../../library/multiprocessing.rst:2103 msgid "Create a shared :class:`Namespace` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2097 +#: ../../library/multiprocessing.rst:2107 msgid "Create a shared :class:`queue.Queue` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2101 +#: ../../library/multiprocessing.rst:2111 msgid "" "Create a shared :class:`threading.RLock` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2105 +#: ../../library/multiprocessing.rst:2115 msgid "" "Create a shared :class:`threading.Semaphore` object and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:2110 +#: ../../library/multiprocessing.rst:2120 msgid "Create an array and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2114 +#: ../../library/multiprocessing.rst:2124 msgid "" "Create an object with a writable ``value`` attribute and return a proxy for " "it." msgstr "" -#: ../../library/multiprocessing.rst:2121 +#: ../../library/multiprocessing.rst:2131 msgid "Create a shared :class:`dict` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2126 +#: ../../library/multiprocessing.rst:2136 msgid "Create a shared :class:`list` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2132 +#: ../../library/multiprocessing.rst:2142 msgid "Create a shared :class:`set` object and return a proxy for it." msgstr "" -#: ../../library/multiprocessing.rst:2134 +#: ../../library/multiprocessing.rst:2144 msgid ":class:`set` support was added." msgstr "已新增對 :class:`set` 的支援。" -#: ../../library/multiprocessing.rst:2137 +#: ../../library/multiprocessing.rst:2147 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:2144 +#: ../../library/multiprocessing.rst:2154 msgid "A type that can register with :class:`SyncManager`." msgstr "" -#: ../../library/multiprocessing.rst:2146 +#: ../../library/multiprocessing.rst:2156 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:2149 +#: ../../library/multiprocessing.rst:2159 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:2153 +#: ../../library/multiprocessing.rst:2163 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -3085,18 +3098,18 @@ msgid "" "Namespace(x=10, y='hello')" msgstr "" -#: ../../library/multiprocessing.rst:2166 +#: ../../library/multiprocessing.rst:2176 msgid "Customized managers" msgstr "" -#: ../../library/multiprocessing.rst:2168 +#: ../../library/multiprocessing.rst:2178 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:2172 +#: ../../library/multiprocessing.rst:2182 msgid "" "from multiprocessing.managers import BaseManager\n" "\n" @@ -3136,23 +3149,23 @@ msgstr "" " print(maths.add(4, 3)) # 印出 7\n" " print(maths.mul(7, 8)) # 印出 56" -#: ../../library/multiprocessing.rst:2193 +#: ../../library/multiprocessing.rst:2203 msgid "Using a remote manager" msgstr "" -#: ../../library/multiprocessing.rst:2195 +#: ../../library/multiprocessing.rst:2205 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:2198 +#: ../../library/multiprocessing.rst:2208 msgid "" "Running the following commands creates a server for a single shared queue " "which remote clients can access::" msgstr "" -#: ../../library/multiprocessing.rst:2201 +#: ../../library/multiprocessing.rst:2211 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> from queue import Queue\n" @@ -3172,11 +3185,11 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2210 +#: ../../library/multiprocessing.rst:2220 msgid "One client can access the server as follows::" msgstr "" -#: ../../library/multiprocessing.rst:2212 +#: ../../library/multiprocessing.rst:2222 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3196,11 +3209,11 @@ msgstr "" ">>> queue = m.get_queue()\n" ">>> queue.put('hello')" -#: ../../library/multiprocessing.rst:2220 +#: ../../library/multiprocessing.rst:2230 msgid "Another client can also use it::" msgstr "" -#: ../../library/multiprocessing.rst:2222 +#: ../../library/multiprocessing.rst:2232 msgid "" ">>> from multiprocessing.managers import BaseManager\n" ">>> class QueueManager(BaseManager): pass\n" @@ -3222,13 +3235,13 @@ msgstr "" ">>> queue.get()\n" "'hello'" -#: ../../library/multiprocessing.rst:2231 +#: ../../library/multiprocessing.rst:2241 msgid "" "Local processes can also access that queue, using the code from above on the " "client to access it remotely::" msgstr "" -#: ../../library/multiprocessing.rst:2234 +#: ../../library/multiprocessing.rst:2244 msgid "" ">>> from multiprocessing import Process, Queue\n" ">>> from multiprocessing.managers import BaseManager\n" @@ -3268,18 +3281,18 @@ msgstr "" ">>> s = m.get_server()\n" ">>> s.serve_forever()" -#: ../../library/multiprocessing.rst:2256 +#: ../../library/multiprocessing.rst:2266 msgid "Proxy Objects" msgstr "" -#: ../../library/multiprocessing.rst:2258 +#: ../../library/multiprocessing.rst:2268 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:2262 +#: ../../library/multiprocessing.rst:2272 msgid "" "A proxy object has methods which invoke corresponding methods of its " "referent (although not every method of the referent will necessarily be " @@ -3287,7 +3300,7 @@ msgid "" "its referent can:" msgstr "" -#: ../../library/multiprocessing.rst:2266 +#: ../../library/multiprocessing.rst:2276 msgid "" ">>> mp_context = multiprocessing.get_context('spawn')\n" ">>> manager = mp_context.Manager()\n" @@ -3313,14 +3326,14 @@ msgstr "" ">>> l[2:5]\n" "[4, 9, 16]" -#: ../../library/multiprocessing.rst:2280 +#: ../../library/multiprocessing.rst:2290 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:2284 +#: ../../library/multiprocessing.rst:2294 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:" @@ -3328,7 +3341,7 @@ msgid "" "lists, dicts, and other :ref:`multiprocessing-proxy_objects`:" msgstr "" -#: ../../library/multiprocessing.rst:2289 +#: ../../library/multiprocessing.rst:2299 msgid "" ">>> a = manager.list()\n" ">>> b = manager.list()\n" @@ -3340,11 +3353,11 @@ msgid "" "['hello'] ['hello']" msgstr "" -#: ../../library/multiprocessing.rst:2300 +#: ../../library/multiprocessing.rst:2310 msgid "Similarly, dict and list proxies may be nested inside one another::" msgstr "" -#: ../../library/multiprocessing.rst:2302 +#: ../../library/multiprocessing.rst:2312 msgid "" ">>> l_outer = manager.list([ manager.dict() for i in range(2) ])\n" ">>> d_first_inner = l_outer[0]\n" @@ -3368,7 +3381,7 @@ msgstr "" ">>> print(l_outer[1])\n" "{'c': 3, 'z': 26}" -#: ../../library/multiprocessing.rst:2313 +#: ../../library/multiprocessing.rst:2323 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 " @@ -3379,7 +3392,7 @@ msgid "" "assign the modified value to the container proxy::" msgstr "" -#: ../../library/multiprocessing.rst:2321 +#: ../../library/multiprocessing.rst:2331 msgid "" "# create a list proxy and append a mutable object (a dictionary)\n" "lproxy = manager.list()\n" @@ -3393,20 +3406,20 @@ msgid "" "lproxy[0] = d" msgstr "" -#: ../../library/multiprocessing.rst:2332 +#: ../../library/multiprocessing.rst:2342 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:2338 +#: ../../library/multiprocessing.rst:2348 msgid "" "The proxy types in :mod:`!multiprocessing` do nothing to support comparisons " "by value. So, for instance, we have:" msgstr "" -#: ../../library/multiprocessing.rst:2341 +#: ../../library/multiprocessing.rst:2351 msgid "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" @@ -3414,48 +3427,48 @@ msgstr "" ">>> manager.list([1,2,3]) == [1,2,3]\n" "False" -#: ../../library/multiprocessing.rst:2346 +#: ../../library/multiprocessing.rst:2356 msgid "" "One should just use a copy of the referent instead when making comparisons." msgstr "" -#: ../../library/multiprocessing.rst:2350 +#: ../../library/multiprocessing.rst:2360 msgid "Proxy objects are instances of subclasses of :class:`BaseProxy`." msgstr "" -#: ../../library/multiprocessing.rst:2354 +#: ../../library/multiprocessing.rst:2364 msgid "Call and return the result of a method of the proxy's referent." msgstr "" -#: ../../library/multiprocessing.rst:2356 +#: ../../library/multiprocessing.rst:2366 msgid "" "If ``proxy`` is a proxy whose referent is ``obj`` then the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2358 +#: ../../library/multiprocessing.rst:2368 msgid "proxy._callmethod(methodname, args, kwds)" msgstr "proxy._callmethod(methodname, args, kwds)" -#: ../../library/multiprocessing.rst:2360 +#: ../../library/multiprocessing.rst:2370 msgid "will evaluate the expression ::" msgstr "" -#: ../../library/multiprocessing.rst:2362 +#: ../../library/multiprocessing.rst:2372 msgid "getattr(obj, methodname)(*args, **kwds)" msgstr "getattr(obj, methodname)(*args, **kwds)" -#: ../../library/multiprocessing.rst:2364 +#: ../../library/multiprocessing.rst:2374 msgid "in the manager's process." msgstr "" -#: ../../library/multiprocessing.rst:2366 +#: ../../library/multiprocessing.rst:2376 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:2370 +#: ../../library/multiprocessing.rst:2380 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 " @@ -3463,17 +3476,17 @@ msgid "" "meth:`_callmethod`." msgstr "" -#: ../../library/multiprocessing.rst:2375 +#: ../../library/multiprocessing.rst:2385 msgid "" "Note in particular that an exception will be raised if *methodname* has not " "been *exposed*." msgstr "" -#: ../../library/multiprocessing.rst:2378 +#: ../../library/multiprocessing.rst:2388 msgid "An example of the usage of :meth:`_callmethod`:" msgstr "" -#: ../../library/multiprocessing.rst:2380 +#: ../../library/multiprocessing.rst:2390 msgid "" ">>> l = manager.list(range(10))\n" ">>> l._callmethod('__len__')\n" @@ -3495,69 +3508,69 @@ msgstr "" "...\n" "IndexError: list index out of range" -#: ../../library/multiprocessing.rst:2394 +#: ../../library/multiprocessing.rst:2404 msgid "Return a copy of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2396 +#: ../../library/multiprocessing.rst:2406 msgid "If the referent is unpicklable then this will raise an exception." msgstr "" -#: ../../library/multiprocessing.rst:2400 +#: ../../library/multiprocessing.rst:2410 msgid "Return a representation of the proxy object." msgstr "" -#: ../../library/multiprocessing.rst:2404 +#: ../../library/multiprocessing.rst:2414 msgid "Return the representation of the referent." msgstr "" -#: ../../library/multiprocessing.rst:2408 +#: ../../library/multiprocessing.rst:2418 msgid "Cleanup" msgstr "" -#: ../../library/multiprocessing.rst:2410 +#: ../../library/multiprocessing.rst:2420 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:2413 +#: ../../library/multiprocessing.rst:2423 msgid "" "A shared object gets deleted from the manager process when there are no " "longer any proxies referring to it." msgstr "" -#: ../../library/multiprocessing.rst:2418 +#: ../../library/multiprocessing.rst:2428 msgid "Process Pools" msgstr "" -#: ../../library/multiprocessing.rst:2423 +#: ../../library/multiprocessing.rst:2433 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:2428 +#: ../../library/multiprocessing.rst:2438 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:2432 +#: ../../library/multiprocessing.rst:2442 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:2435 -#: ../../library/multiprocessing.rst:3011 +#: ../../library/multiprocessing.rst:2445 +#: ../../library/multiprocessing.rst:3021 msgid "" "If *initializer* is not ``None`` then each worker process will call " "``initializer(*initargs)`` when it starts." msgstr "" -#: ../../library/multiprocessing.rst:2438 +#: ../../library/multiprocessing.rst:2448 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 " @@ -3565,7 +3578,7 @@ msgid "" "which means worker processes will live as long as the pool." msgstr "" -#: ../../library/multiprocessing.rst:2443 +#: ../../library/multiprocessing.rst:2453 msgid "" "*context* can be used to specify the context used for starting the worker " "processes. Usually a pool is created using the function :func:" @@ -3575,13 +3588,13 @@ msgid "" "method if it has not been set already. See the :func:`get_context` function." msgstr "" -#: ../../library/multiprocessing.rst:2451 +#: ../../library/multiprocessing.rst:2461 msgid "" "Note that the methods of the pool object should only be called by the " "process which created the pool." msgstr "" -#: ../../library/multiprocessing.rst:2455 +#: ../../library/multiprocessing.rst:2465 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 " @@ -3589,28 +3602,28 @@ msgid "" "to do this can lead to the process hanging on finalization." msgstr "" -#: ../../library/multiprocessing.rst:2460 +#: ../../library/multiprocessing.rst:2470 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:2464 +#: ../../library/multiprocessing.rst:2474 msgid "Added the *maxtasksperchild* parameter." msgstr "新增 *maxtasksperchild* 參數。" -#: ../../library/multiprocessing.rst:2467 +#: ../../library/multiprocessing.rst:2477 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" -#: ../../library/multiprocessing.rst:2470 +#: ../../library/multiprocessing.rst:2480 msgid "" "*processes* uses :func:`os.process_cpu_count` by default, instead of :func:" "`os.cpu_count`." msgstr "" -#: ../../library/multiprocessing.rst:2476 +#: ../../library/multiprocessing.rst:2486 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 " @@ -3621,7 +3634,7 @@ msgid "" "the end user." msgstr "" -#: ../../library/multiprocessing.rst:2486 +#: ../../library/multiprocessing.rst:2496 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 " @@ -3629,14 +3642,14 @@ msgid "" "executed in one of the workers of the pool." msgstr "" -#: ../../library/multiprocessing.rst:2493 +#: ../../library/multiprocessing.rst:2503 msgid "" "A variant of the :meth:`apply` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2496 -#: ../../library/multiprocessing.rst:2527 +#: ../../library/multiprocessing.rst:2506 +#: ../../library/multiprocessing.rst:2537 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, " @@ -3644,60 +3657,60 @@ msgid "" "applied instead." msgstr "" -#: ../../library/multiprocessing.rst:2501 -#: ../../library/multiprocessing.rst:2532 +#: ../../library/multiprocessing.rst:2511 +#: ../../library/multiprocessing.rst:2542 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:2505 -#: ../../library/multiprocessing.rst:2536 +#: ../../library/multiprocessing.rst:2515 +#: ../../library/multiprocessing.rst:2546 msgid "" "Callbacks should complete immediately since otherwise the thread which " "handles the results will get blocked." msgstr "" -#: ../../library/multiprocessing.rst:2510 +#: ../../library/multiprocessing.rst:2520 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:2514 +#: ../../library/multiprocessing.rst:2524 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:2518 +#: ../../library/multiprocessing.rst:2528 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:2524 +#: ../../library/multiprocessing.rst:2534 msgid "" "A variant of the :meth:`.map` method which returns a :class:" "`~multiprocessing.pool.AsyncResult` object." msgstr "" -#: ../../library/multiprocessing.rst:2541 +#: ../../library/multiprocessing.rst:2551 msgid "An iterator-based version of :meth:`.map`." msgstr "" -#: ../../library/multiprocessing.rst:2543 +#: ../../library/multiprocessing.rst:2553 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:2548 +#: ../../library/multiprocessing.rst:2558 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: " @@ -3705,65 +3718,65 @@ msgid "" "result cannot be returned within *timeout* seconds." msgstr "" -#: ../../library/multiprocessing.rst:2555 +#: ../../library/multiprocessing.rst:2565 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:2561 +#: ../../library/multiprocessing.rst:2571 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:2565 +#: ../../library/multiprocessing.rst:2575 msgid "" "Hence an *iterable* of ``[(1,2), (3, 4)]`` results in ``[func(1,2), " "func(3,4)]``." msgstr "" -#: ../../library/multiprocessing.rst:2572 +#: ../../library/multiprocessing.rst:2582 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:2580 +#: ../../library/multiprocessing.rst:2590 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:2585 +#: ../../library/multiprocessing.rst:2595 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:2591 +#: ../../library/multiprocessing.rst:2601 msgid "" "Wait for the worker processes to exit. One must call :meth:`close` or :meth:" "`terminate` before using :meth:`join`." msgstr "" -#: ../../library/multiprocessing.rst:2594 +#: ../../library/multiprocessing.rst:2604 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:2602 +#: ../../library/multiprocessing.rst:2612 msgid "" "The class of the result returned by :meth:`Pool.apply_async` and :meth:`Pool." "map_async`." msgstr "" -#: ../../library/multiprocessing.rst:2607 +#: ../../library/multiprocessing.rst:2617 msgid "" "Return the result when it arrives. If *timeout* is not ``None`` and the " "result does not arrive within *timeout* seconds then :exc:`multiprocessing." @@ -3771,31 +3784,31 @@ msgid "" "exception will be reraised by :meth:`get`." msgstr "" -#: ../../library/multiprocessing.rst:2614 +#: ../../library/multiprocessing.rst:2624 msgid "Wait until the result is available or until *timeout* seconds pass." msgstr "" -#: ../../library/multiprocessing.rst:2618 +#: ../../library/multiprocessing.rst:2628 msgid "Return whether the call has completed." msgstr "" -#: ../../library/multiprocessing.rst:2622 +#: ../../library/multiprocessing.rst:2632 msgid "" "Return whether the call completed without raising an exception. Will raise :" "exc:`ValueError` if the result is not ready." msgstr "" -#: ../../library/multiprocessing.rst:2625 +#: ../../library/multiprocessing.rst:2635 msgid "" "If the result is not ready, :exc:`ValueError` is raised instead of :exc:" "`AssertionError`." msgstr "" -#: ../../library/multiprocessing.rst:2629 +#: ../../library/multiprocessing.rst:2639 msgid "The following example demonstrates the use of a pool::" msgstr "" -#: ../../library/multiprocessing.rst:2631 +#: ../../library/multiprocessing.rst:2641 msgid "" "from multiprocessing import Pool\n" "import time\n" @@ -3823,17 +3836,17 @@ msgid "" "TimeoutError" msgstr "" -#: ../../library/multiprocessing.rst:2656 +#: ../../library/multiprocessing.rst:2666 msgid "Listeners and Clients" msgstr "" -#: ../../library/multiprocessing.rst:2661 +#: ../../library/multiprocessing.rst:2671 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:2665 +#: ../../library/multiprocessing.rst:2675 msgid "" "However, the :mod:`!multiprocessing.connection` module allows some extra " "flexibility. It basically gives a high level message oriented API for " @@ -3842,46 +3855,46 @@ msgid "" "multiple connections at the same time." msgstr "" -#: ../../library/multiprocessing.rst:2674 +#: ../../library/multiprocessing.rst:2684 msgid "" "Send a randomly generated message to the other end of the connection and " "wait for a reply." msgstr "" -#: ../../library/multiprocessing.rst:2677 +#: ../../library/multiprocessing.rst:2687 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:2683 +#: ../../library/multiprocessing.rst:2693 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:2686 +#: ../../library/multiprocessing.rst:2696 msgid "" "If a welcome message is not received, then :exc:`~multiprocessing." "AuthenticationError` is raised." msgstr "" -#: ../../library/multiprocessing.rst:2691 +#: ../../library/multiprocessing.rst:2701 msgid "" "Attempt to set up a connection to the listener which is using address " "*address*, returning a :class:`~Connection`." msgstr "" -#: ../../library/multiprocessing.rst:2694 +#: ../../library/multiprocessing.rst:2704 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:2698 -#: ../../library/multiprocessing.rst:2733 +#: ../../library/multiprocessing.rst:2708 +#: ../../library/multiprocessing.rst:2743 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 " @@ -3890,26 +3903,26 @@ msgid "" "`multiprocessing-auth-keys`." msgstr "" -#: ../../library/multiprocessing.rst:2706 +#: ../../library/multiprocessing.rst:2716 msgid "" "A wrapper for a bound socket or Windows named pipe which is 'listening' for " "connections." msgstr "" -#: ../../library/multiprocessing.rst:2709 +#: ../../library/multiprocessing.rst:2719 msgid "" "*address* is the address to be used by the bound socket or named pipe of the " "listener object." msgstr "" -#: ../../library/multiprocessing.rst:2714 +#: ../../library/multiprocessing.rst:2724 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:2718 +#: ../../library/multiprocessing.rst:2728 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 " @@ -3923,49 +3936,49 @@ msgid "" "using :func:`tempfile.mkstemp`." msgstr "" -#: ../../library/multiprocessing.rst:2729 +#: ../../library/multiprocessing.rst:2739 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:2741 +#: ../../library/multiprocessing.rst:2751 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:2748 +#: ../../library/multiprocessing.rst:2758 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:2752 +#: ../../library/multiprocessing.rst:2762 msgid "Listener objects have the following read-only properties:" msgstr "" -#: ../../library/multiprocessing.rst:2756 +#: ../../library/multiprocessing.rst:2766 msgid "The address which is being used by the Listener object." msgstr "" -#: ../../library/multiprocessing.rst:2760 +#: ../../library/multiprocessing.rst:2770 msgid "" "The address from which the last accepted connection came. If this is " "unavailable then it is ``None``." msgstr "" -#: ../../library/multiprocessing.rst:2763 +#: ../../library/multiprocessing.rst:2773 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:2770 +#: ../../library/multiprocessing.rst:2780 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 " @@ -3974,32 +3987,32 @@ msgid "" "zero timeout." msgstr "" -#: ../../library/multiprocessing.rst:2776 +#: ../../library/multiprocessing.rst:2786 msgid "" "For both POSIX and Windows, an object can appear in *object_list* if it is" msgstr "" -#: ../../library/multiprocessing.rst:2779 +#: ../../library/multiprocessing.rst:2789 msgid "a readable :class:`~multiprocessing.connection.Connection` object;" msgstr "" -#: ../../library/multiprocessing.rst:2780 +#: ../../library/multiprocessing.rst:2790 msgid "a connected and readable :class:`socket.socket` object; or" msgstr "" -#: ../../library/multiprocessing.rst:2781 +#: ../../library/multiprocessing.rst:2791 msgid "" "the :attr:`~multiprocessing.Process.sentinel` attribute of a :class:" "`~multiprocessing.Process` object." msgstr "" -#: ../../library/multiprocessing.rst:2784 +#: ../../library/multiprocessing.rst:2794 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:2787 +#: ../../library/multiprocessing.rst:2797 msgid "" "**POSIX**: ``wait(object_list, timeout)`` almost equivalent ``select." "select(object_list, [], [], timeout)``. The difference is that, if :func:" @@ -4007,7 +4020,7 @@ msgid "" "an error number of ``EINTR``, whereas :func:`wait` will not." msgstr "" -#: ../../library/multiprocessing.rst:2793 +#: ../../library/multiprocessing.rst:2803 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 " @@ -4017,18 +4030,18 @@ msgid "" "handles.)" msgstr "" -#: ../../library/multiprocessing.rst:2803 +#: ../../library/multiprocessing.rst:2813 msgid "**Examples**" msgstr "" -#: ../../library/multiprocessing.rst:2805 +#: ../../library/multiprocessing.rst:2815 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:2809 +#: ../../library/multiprocessing.rst:2819 msgid "" "from multiprocessing.connection import Listener\n" "from array import array\n" @@ -4046,13 +4059,13 @@ msgid "" " conn.send_bytes(array('i', [42, 1729]))" msgstr "" -#: ../../library/multiprocessing.rst:2824 +#: ../../library/multiprocessing.rst:2834 msgid "" "The following code connects to the server and receives some data from the " "server::" msgstr "" -#: ../../library/multiprocessing.rst:2827 +#: ../../library/multiprocessing.rst:2837 msgid "" "from multiprocessing.connection import Client\n" "from array import array\n" @@ -4082,13 +4095,13 @@ msgstr "" " print(conn.recv_bytes_into(arr)) # => 8\n" " print(arr) # => array('i', [42, 1729, 0, 0, 0])" -#: ../../library/multiprocessing.rst:2841 +#: ../../library/multiprocessing.rst:2851 msgid "" "The following code uses :func:`~multiprocessing.connection.wait` to wait for " "messages from multiple processes at once::" msgstr "" -#: ../../library/multiprocessing.rst:2844 +#: ../../library/multiprocessing.rst:2854 msgid "" "from multiprocessing import Process, Pipe, current_process\n" "from multiprocessing.connection import wait\n" @@ -4122,23 +4135,23 @@ msgid "" " print(msg)" msgstr "" -#: ../../library/multiprocessing.rst:2879 +#: ../../library/multiprocessing.rst:2889 msgid "Address Formats" msgstr "" -#: ../../library/multiprocessing.rst:2881 +#: ../../library/multiprocessing.rst:2891 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:2884 +#: ../../library/multiprocessing.rst:2894 msgid "" "An ``'AF_UNIX'`` address is a string representing a filename on the " "filesystem." msgstr "" -#: ../../library/multiprocessing.rst:2887 +#: ../../library/multiprocessing.rst:2897 msgid "" "An ``'AF_PIPE'`` address is a string of the form :samp:`r'\\\\\\\\\\\\.\\" "\\pipe\\\\\\\\{PipeName}'`. To use :func:`Client` to connect to a named " @@ -4147,17 +4160,17 @@ msgid "" "instead." msgstr "" -#: ../../library/multiprocessing.rst:2892 +#: ../../library/multiprocessing.rst:2902 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:2899 +#: ../../library/multiprocessing.rst:2909 msgid "Authentication keys" msgstr "" -#: ../../library/multiprocessing.rst:2901 +#: ../../library/multiprocessing.rst:2911 msgid "" "When one uses :meth:`Connection.recv `, the data received " "is automatically unpickled. Unfortunately unpickling data from an untrusted " @@ -4165,7 +4178,7 @@ msgid "" "use the :mod:`hmac` module to provide digest authentication." msgstr "" -#: ../../library/multiprocessing.rst:2907 +#: ../../library/multiprocessing.rst:2917 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 " @@ -4173,7 +4186,7 @@ msgid "" "using the same key does **not** involve sending the key over the connection.)" msgstr "" -#: ../../library/multiprocessing.rst:2913 +#: ../../library/multiprocessing.rst:2923 msgid "" "If authentication is requested but no authentication key is specified then " "the return value of ``current_process().authkey`` is used (see :class:" @@ -4184,13 +4197,13 @@ msgid "" "setting up connections between themselves." msgstr "" -#: ../../library/multiprocessing.rst:2921 +#: ../../library/multiprocessing.rst:2931 msgid "" "Suitable authentication keys can also be generated by using :func:`os." "urandom`." msgstr "" -#: ../../library/multiprocessing.rst:2923 +#: ../../library/multiprocessing.rst:2933 msgid "" "This authentication protects :class:`Listener` and :func:`Client` " "connections, which are reachable by address. It is not applied to the " @@ -4203,11 +4216,11 @@ msgid "" "under a different user account or in a sandbox." msgstr "" -#: ../../library/multiprocessing.rst:2935 +#: ../../library/multiprocessing.rst:2945 msgid "Logging" msgstr "" -#: ../../library/multiprocessing.rst:2937 +#: ../../library/multiprocessing.rst:2947 msgid "" "Some support for logging is available. Note, however, that the :mod:" "`logging` package does not use process shared locks so it is possible " @@ -4215,27 +4228,27 @@ msgid "" "mixed up." msgstr "" -#: ../../library/multiprocessing.rst:2944 +#: ../../library/multiprocessing.rst:2954 msgid "" "Returns the logger used by :mod:`!multiprocessing`. If necessary, a new one " "will be created." msgstr "" -#: ../../library/multiprocessing.rst:2947 +#: ../../library/multiprocessing.rst:2957 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:2951 +#: ../../library/multiprocessing.rst:2961 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:2958 +#: ../../library/multiprocessing.rst:2968 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 " @@ -4244,11 +4257,11 @@ msgid "" "``level`` argument." msgstr "" -#: ../../library/multiprocessing.rst:2964 +#: ../../library/multiprocessing.rst:2974 msgid "Below is an example session with logging turned on::" msgstr "" -#: ../../library/multiprocessing.rst:2966 +#: ../../library/multiprocessing.rst:2976 msgid "" ">>> import multiprocessing, logging\n" ">>> logger = multiprocessing.log_to_stderr()\n" @@ -4276,21 +4289,21 @@ msgstr "" "[INFO/MainProcess] sending shutdown message to manager\n" "[INFO/SyncManager-...] manager exiting with exitcode 0" -#: ../../library/multiprocessing.rst:2979 +#: ../../library/multiprocessing.rst:2989 msgid "For a full table of logging levels, see the :mod:`logging` module." msgstr "" -#: ../../library/multiprocessing.rst:2983 +#: ../../library/multiprocessing.rst:2993 msgid "The :mod:`!multiprocessing.dummy` module" msgstr ":mod:`!multiprocessing.dummy` 模組" -#: ../../library/multiprocessing.rst:2988 +#: ../../library/multiprocessing.rst:2998 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:2993 +#: ../../library/multiprocessing.rst:3003 msgid "" "In particular, the ``Pool`` function provided by :mod:`!multiprocessing." "dummy` returns an instance of :class:`ThreadPool`, which is a subclass of :" @@ -4298,7 +4311,7 @@ msgid "" "worker threads rather than worker processes." msgstr "" -#: ../../library/multiprocessing.rst:3001 +#: ../../library/multiprocessing.rst:3011 msgid "" "A thread pool object which controls a pool of worker threads to which jobs " "can be submitted. :class:`ThreadPool` instances are fully interface " @@ -4308,18 +4321,18 @@ msgid "" "pool.Pool.terminate` manually." msgstr "" -#: ../../library/multiprocessing.rst:3008 +#: ../../library/multiprocessing.rst:3018 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:3014 +#: ../../library/multiprocessing.rst:3024 msgid "" "Unlike :class:`Pool`, *maxtasksperchild* and *context* cannot be provided." msgstr "" -#: ../../library/multiprocessing.rst:3018 +#: ../../library/multiprocessing.rst:3028 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 :" @@ -4329,7 +4342,7 @@ msgid "" "is not understood by any other libraries." msgstr "" -#: ../../library/multiprocessing.rst:3025 +#: ../../library/multiprocessing.rst:3035 msgid "" "Users should generally prefer to use :class:`concurrent.futures." "ThreadPoolExecutor`, which has a simpler interface that was designed around " @@ -4338,69 +4351,69 @@ msgid "" "`asyncio`." msgstr "" -#: ../../library/multiprocessing.rst:3035 +#: ../../library/multiprocessing.rst:3045 msgid "Programming guidelines" msgstr "" -#: ../../library/multiprocessing.rst:3037 +#: ../../library/multiprocessing.rst:3047 msgid "" "There are certain guidelines and idioms which should be adhered to when " "using :mod:`!multiprocessing`." msgstr "" -#: ../../library/multiprocessing.rst:3042 +#: ../../library/multiprocessing.rst:3052 msgid "All start methods" msgstr "" -#: ../../library/multiprocessing.rst:3044 +#: ../../library/multiprocessing.rst:3054 msgid "The following applies to all start methods." msgstr "" -#: ../../library/multiprocessing.rst:3046 +#: ../../library/multiprocessing.rst:3056 msgid "Avoid shared state" msgstr "" -#: ../../library/multiprocessing.rst:3048 +#: ../../library/multiprocessing.rst:3058 msgid "" "As far as possible one should try to avoid shifting large amounts of data " "between processes." msgstr "" -#: ../../library/multiprocessing.rst:3051 +#: ../../library/multiprocessing.rst:3061 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:3055 +#: ../../library/multiprocessing.rst:3065 msgid "Picklability" msgstr "" -#: ../../library/multiprocessing.rst:3057 +#: ../../library/multiprocessing.rst:3067 msgid "Ensure that the arguments to the methods of proxies are picklable." msgstr "" -#: ../../library/multiprocessing.rst:3059 +#: ../../library/multiprocessing.rst:3069 msgid "Thread safety of proxies" msgstr "" -#: ../../library/multiprocessing.rst:3061 +#: ../../library/multiprocessing.rst:3071 msgid "" "Do not use a proxy object from more than one thread unless you protect it " "with a lock." msgstr "" -#: ../../library/multiprocessing.rst:3064 +#: ../../library/multiprocessing.rst:3074 msgid "" "(There is never a problem with different processes using the *same* proxy.)" msgstr "" -#: ../../library/multiprocessing.rst:3066 +#: ../../library/multiprocessing.rst:3076 msgid "Joining zombie processes" msgstr "" -#: ../../library/multiprocessing.rst:3068 +#: ../../library/multiprocessing.rst:3078 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 " @@ -4411,11 +4424,11 @@ msgid "" "explicitly join all the processes that you start." msgstr "" -#: ../../library/multiprocessing.rst:3076 +#: ../../library/multiprocessing.rst:3086 msgid "Better to inherit than pickle/unpickle" msgstr "" -#: ../../library/multiprocessing.rst:3078 +#: ../../library/multiprocessing.rst:3088 msgid "" "When using the *spawn* or *forkserver* start methods many types from :mod:`!" "multiprocessing` need to be picklable so that child processes can use them. " @@ -4425,11 +4438,11 @@ msgid "" "inherit it from an ancestor process." msgstr "" -#: ../../library/multiprocessing.rst:3086 +#: ../../library/multiprocessing.rst:3096 msgid "Avoid terminating processes" msgstr "" -#: ../../library/multiprocessing.rst:3088 +#: ../../library/multiprocessing.rst:3098 msgid "" "Using the :meth:`Process.terminate ` " "method to stop a process is liable to cause any shared resources (such as " @@ -4437,18 +4450,18 @@ msgid "" "become broken or unavailable to other processes." msgstr "" -#: ../../library/multiprocessing.rst:3094 +#: ../../library/multiprocessing.rst:3104 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:3098 +#: ../../library/multiprocessing.rst:3108 msgid "Joining processes that use queues" msgstr "" -#: ../../library/multiprocessing.rst:3100 +#: ../../library/multiprocessing.rst:3110 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 " @@ -4457,7 +4470,7 @@ msgid "" "queue to avoid this behaviour.)" msgstr "" -#: ../../library/multiprocessing.rst:3106 +#: ../../library/multiprocessing.rst:3116 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 " @@ -4466,11 +4479,11 @@ msgid "" "processes will be joined automatically." msgstr "" -#: ../../library/multiprocessing.rst:3112 +#: ../../library/multiprocessing.rst:3122 msgid "An example which will deadlock is the following::" msgstr "" -#: ../../library/multiprocessing.rst:3114 +#: ../../library/multiprocessing.rst:3124 msgid "" "from multiprocessing import Process, Queue\n" "\n" @@ -4485,17 +4498,17 @@ msgid "" " obj = queue.get()" msgstr "" -#: ../../library/multiprocessing.rst:3126 +#: ../../library/multiprocessing.rst:3136 msgid "" "A fix here would be to swap the last two lines (or simply remove the ``p." "join()`` line)." msgstr "" -#: ../../library/multiprocessing.rst:3129 +#: ../../library/multiprocessing.rst:3139 msgid "Explicitly pass resources to child processes" msgstr "" -#: ../../library/multiprocessing.rst:3131 +#: ../../library/multiprocessing.rst:3141 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. " @@ -4503,7 +4516,7 @@ msgid "" "for the child process." msgstr "" -#: ../../library/multiprocessing.rst:3136 +#: ../../library/multiprocessing.rst:3146 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 " @@ -4512,11 +4525,11 @@ msgid "" "collected in the parent process." msgstr "" -#: ../../library/multiprocessing.rst:3143 +#: ../../library/multiprocessing.rst:3153 msgid "So for instance ::" msgstr "" -#: ../../library/multiprocessing.rst:3145 +#: ../../library/multiprocessing.rst:3155 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4538,11 +4551,11 @@ msgstr "" " for i in range(10):\n" " Process(target=f).start()" -#: ../../library/multiprocessing.rst:3155 +#: ../../library/multiprocessing.rst:3165 msgid "should be rewritten as ::" msgstr "" -#: ../../library/multiprocessing.rst:3157 +#: ../../library/multiprocessing.rst:3167 msgid "" "from multiprocessing import Process, Lock\n" "\n" @@ -4564,25 +4577,25 @@ msgstr "" " for i in range(10):\n" " Process(target=f, args=(lock,)).start()" -#: ../../library/multiprocessing.rst:3167 +#: ../../library/multiprocessing.rst:3177 msgid "Beware of replacing :data:`sys.stdin` with a \"file like object\"" msgstr "" -#: ../../library/multiprocessing.rst:3169 +#: ../../library/multiprocessing.rst:3179 msgid ":mod:`!multiprocessing` originally unconditionally called::" msgstr "" -#: ../../library/multiprocessing.rst:3171 +#: ../../library/multiprocessing.rst:3181 msgid "os.close(sys.stdin.fileno())" msgstr "os.close(sys.stdin.fileno())" -#: ../../library/multiprocessing.rst:3173 +#: ../../library/multiprocessing.rst:3183 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:3176 +#: ../../library/multiprocessing.rst:3186 msgid "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" @@ -4590,7 +4603,7 @@ msgstr "" "sys.stdin.close()\n" "sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)" -#: ../../library/multiprocessing.rst:3179 +#: ../../library/multiprocessing.rst:3189 msgid "" "Which solves the fundamental issue of processes colliding with each other " "resulting in a bad file descriptor error, but introduces a potential danger " @@ -4600,14 +4613,14 @@ msgid "" "data being flushed to the object multiple times, resulting in corruption." msgstr "" -#: ../../library/multiprocessing.rst:3186 +#: ../../library/multiprocessing.rst:3196 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:3190 +#: ../../library/multiprocessing.rst:3200 msgid "" "@property\n" "def cache(self):\n" @@ -4625,26 +4638,26 @@ msgstr "" " self._cache = []\n" " return self._cache" -#: ../../library/multiprocessing.rst:3198 +#: ../../library/multiprocessing.rst:3208 msgid "" "For more information, see :issue:`5155`, :issue:`5313` and :issue:`5331`" msgstr "" -#: ../../library/multiprocessing.rst:3204 +#: ../../library/multiprocessing.rst:3214 msgid "The *spawn* and *forkserver* start methods" msgstr "" -#: ../../library/multiprocessing.rst:3206 +#: ../../library/multiprocessing.rst:3216 msgid "" "There are a few extra restrictions which don't apply to the *fork* start " "method." msgstr "" -#: ../../library/multiprocessing.rst:3209 +#: ../../library/multiprocessing.rst:3219 msgid "More picklability" msgstr "" -#: ../../library/multiprocessing.rst:3211 +#: ../../library/multiprocessing.rst:3221 msgid "" "Ensure that all arguments to :class:`~multiprocessing.Process` are " "picklable. Also, if you subclass ``Process.__init__``, you must make sure " @@ -4652,11 +4665,11 @@ msgid "" "` method is called." msgstr "" -#: ../../library/multiprocessing.rst:3216 +#: ../../library/multiprocessing.rst:3226 msgid "Global variables" msgstr "" -#: ../../library/multiprocessing.rst:3218 +#: ../../library/multiprocessing.rst:3228 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 " @@ -4664,30 +4677,30 @@ msgid "" "Process.start>` was called." msgstr "" -#: ../../library/multiprocessing.rst:3223 +#: ../../library/multiprocessing.rst:3233 msgid "" "However, global variables which are just module level constants cause no " "problems." msgstr "" -#: ../../library/multiprocessing.rst:3228 +#: ../../library/multiprocessing.rst:3238 msgid "Safe importing of main module" msgstr "" -#: ../../library/multiprocessing.rst:3230 +#: ../../library/multiprocessing.rst:3240 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:3234 +#: ../../library/multiprocessing.rst:3244 msgid "" "For example, using the *spawn* or *forkserver* start method running the " "following module would fail with a :exc:`RuntimeError`::" msgstr "" -#: ../../library/multiprocessing.rst:3238 +#: ../../library/multiprocessing.rst:3248 msgid "" "from multiprocessing import Process\n" "\n" @@ -4705,13 +4718,13 @@ msgstr "" "p = Process(target=foo)\n" "p.start()" -#: ../../library/multiprocessing.rst:3246 +#: ../../library/multiprocessing.rst:3256 msgid "" "Instead one should protect the \"entry point\" of the program by using ``if " "__name__ == '__main__':`` as follows::" msgstr "" -#: ../../library/multiprocessing.rst:3249 +#: ../../library/multiprocessing.rst:3259 msgid "" "from multiprocessing import Process, freeze_support, set_start_method\n" "\n" @@ -4735,33 +4748,33 @@ msgstr "" " p = Process(target=foo)\n" " p.start()" -#: ../../library/multiprocessing.rst:3260 +#: ../../library/multiprocessing.rst:3270 msgid "" "(The ``freeze_support()`` line can be omitted if the program will be run " "normally instead of frozen.)" msgstr "" -#: ../../library/multiprocessing.rst:3263 +#: ../../library/multiprocessing.rst:3273 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:3266 +#: ../../library/multiprocessing.rst:3276 msgid "" "Similar restrictions apply if a pool or manager is created in the main " "module." msgstr "" -#: ../../library/multiprocessing.rst:3273 +#: ../../library/multiprocessing.rst:3283 msgid "Examples" msgstr "範例" -#: ../../library/multiprocessing.rst:3275 +#: ../../library/multiprocessing.rst:3285 msgid "Demonstration of how to create and use customized managers and proxies:" msgstr "" -#: ../../library/multiprocessing.rst:3277 +#: ../../library/multiprocessing.rst:3287 msgid "" "from multiprocessing import freeze_support\n" "from multiprocessing.managers import BaseManager, BaseProxy\n" @@ -4855,11 +4868,11 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3281 +#: ../../library/multiprocessing.rst:3291 msgid "Using :class:`~multiprocessing.pool.Pool`:" msgstr "使用 :class:`~multiprocessing.pool.Pool`:" -#: ../../library/multiprocessing.rst:3283 +#: ../../library/multiprocessing.rst:3293 msgid "" "import multiprocessing\n" "import time\n" @@ -5019,13 +5032,13 @@ msgid "" " test()\n" msgstr "" -#: ../../library/multiprocessing.rst:3287 +#: ../../library/multiprocessing.rst:3297 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:3290 +#: ../../library/multiprocessing.rst:3300 msgid "" "import time\n" "import random\n" diff --git a/library/netrc.po b/library/netrc.po index f8c60acade6..d749e49b15c 100644 --- a/library/netrc.po +++ b/library/netrc.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-27 07:36+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:06+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!netrc` --- netrc file processing" msgstr ":mod:`!netrc` --- netrc 檔案處理" -#: ../../library/netrc.rst:10 +#: ../../library/netrc.rst:7 msgid "**Source code:** :source:`Lib/netrc.py`" msgstr "**原始碼:**\\ :source:`Lib/netrc.py`" -#: ../../library/netrc.rst:14 +#: ../../library/netrc.rst:11 msgid "" "The :class:`~netrc.netrc` class parses and encapsulates the netrc file " "format used by the Unix :program:`ftp` program and other FTP clients." @@ -34,7 +34,7 @@ msgstr "" ":class:`~netrc.netrc` 類別能夠剖析 (parse) 並封裝 (encapsulate) netrc 檔案格" "式,以供 Unix :program:`ftp` 程式和其他 FTP 用戶端使用。" -#: ../../library/netrc.rst:20 +#: ../../library/netrc.rst:17 msgid "" "A :class:`~netrc.netrc` instance or subclass instance encapsulates data " "from a netrc file. The initialization argument, if present, specifies the " @@ -50,7 +50,7 @@ msgstr "" "exc:`FileNotFoundError` 例外。剖析錯誤會引發 :exc:`NetrcParseError`,其帶有包" "括檔案名稱、列號和終止 token 的診斷資訊。" -#: ../../library/netrc.rst:28 +#: ../../library/netrc.rst:25 msgid "" "If no argument is specified on a POSIX system, the presence of passwords in " "the :file:`.netrc` file will raise a :exc:`NetrcParseError` if the file " @@ -66,11 +66,11 @@ msgstr "" "`NetrcParseError`。這實作了與 ftp 和其他使用 :file:`.netrc` 程式等效的安全行" "為。這種安全檢查在不支援 :func:`os.getuid` 的平台上不可用。" -#: ../../library/netrc.rst:36 +#: ../../library/netrc.rst:33 msgid "Added the POSIX permission check." msgstr "新增了 POSIX 權限檢查。" -#: ../../library/netrc.rst:38 +#: ../../library/netrc.rst:35 msgid "" ":func:`os.path.expanduser` is used to find the location of the :file:`." "netrc` file when *file* is not passed as argument." @@ -78,7 +78,7 @@ msgstr "" "當未傳遞 *file* 引數時,:func:`os.path.expanduser` 可用於查找 :file:`.netrc` " "檔案的位置。" -#: ../../library/netrc.rst:42 +#: ../../library/netrc.rst:39 msgid "" ":class:`netrc` try UTF-8 encoding before using locale specific encoding. The " "entry in the netrc file no longer needs to contain all tokens. The missing " @@ -92,7 +92,7 @@ msgstr "" "其值都可以包含任意字元,例如空格和非 ASCII 字元。如果登入名稱為匿名,就不會觸" "發安全檢查。" -#: ../../library/netrc.rst:53 +#: ../../library/netrc.rst:50 msgid "" "Exception raised by the :class:`~netrc.netrc` class when syntactical errors " "are encountered in source text. Instances of this exception provide three " @@ -101,27 +101,27 @@ msgstr "" "當原始文本中遇到語法錯誤時,:class:`~netrc.netrc` 類別會引發例外。此例外的實" "例提供了三個有趣的屬性:" -#: ../../library/netrc.rst:59 +#: ../../library/netrc.rst:56 msgid "Textual explanation of the error." msgstr "錯誤的文字解釋。" -#: ../../library/netrc.rst:63 +#: ../../library/netrc.rst:60 msgid "The name of the source file." msgstr "原始檔案的名稱。" -#: ../../library/netrc.rst:67 +#: ../../library/netrc.rst:64 msgid "The line number on which the error was found." msgstr "發現錯誤的列號。" -#: ../../library/netrc.rst:73 +#: ../../library/netrc.rst:70 msgid "netrc Objects" msgstr "netrc 物件" -#: ../../library/netrc.rst:75 +#: ../../library/netrc.rst:72 msgid "A :class:`~netrc.netrc` instance has the following methods:" msgstr ":class:`~netrc.netrc` 實例具有以下方法:" -#: ../../library/netrc.rst:80 +#: ../../library/netrc.rst:77 msgid "" "Return a 3-tuple ``(login, account, password)`` of authenticators for " "*host*. If the netrc file did not contain an entry for the given host, " @@ -132,7 +132,7 @@ msgstr "" "netrc 檔案不包含給定主機的條目,則回傳與 'default' 條目關聯的 tuple。如果並無" "匹配主機且預設條目也不可用則回傳 ``None``。" -#: ../../library/netrc.rst:88 +#: ../../library/netrc.rst:85 msgid "" "Dump the class data as a string in the format of a netrc file. (This " "discards comments and may reorder the entries.)" @@ -140,11 +140,11 @@ msgstr "" "將類別資料傾印 (dump) 為 netrc 檔案格式的字串。(這會將註解移除,並可能會對條" "目重新排序。)" -#: ../../library/netrc.rst:91 +#: ../../library/netrc.rst:88 msgid "Instances of :class:`~netrc.netrc` have public instance variables:" msgstr ":class:`~netrc.netrc` 的實例具有公開實例變數:" -#: ../../library/netrc.rst:96 +#: ../../library/netrc.rst:93 msgid "" "Dictionary mapping host names to ``(login, account, password)`` tuples. The " "'default' entry, if any, is represented as a pseudo-host by that name." @@ -152,6 +152,6 @@ msgstr "" "將主機名稱對映到 ``(login, account, password)`` tuple 的字典。'default' 條目" "(如存在)表示為該名稱對應到的偽主機 (pseudo-host)。" -#: ../../library/netrc.rst:102 +#: ../../library/netrc.rst:99 msgid "Dictionary mapping macro names to string lists." msgstr "巨集 (macro) 名稱與字串 list(串列)的對映字典。" diff --git a/library/operator.po b/library/operator.po index 0778a9f6efa..1812dd27cc7 100644 --- a/library/operator.po +++ b/library/operator.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-09 00:37+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-02-18 14:49+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!operator` --- Standard operators as functions" msgstr ":mod:`!operator` --- 標準運算子替代函式" -#: ../../library/operator.rst:9 +#: ../../library/operator.rst:7 msgid "**Source code:** :source:`Lib/operator.py`" msgstr "**原始碼:**\\ :source:`Lib/operator.py`" -#: ../../library/operator.rst:18 +#: ../../library/operator.rst:16 msgid "" "The :mod:`!operator` module exports a set of efficient functions " "corresponding to the intrinsic operators of Python. For example, ``operator." @@ -43,20 +43,20 @@ msgstr "" "名相同,只是沒有雙底線。為了向後相容,許多包含雙底線的函式被保留了下來,但為" "了易於表達,建議使用沒有雙底線的函式。" -#: ../../library/operator.rst:25 +#: ../../library/operator.rst:23 msgid "" "The functions fall into categories that perform object comparisons, logical " "operations, mathematical operations and sequence operations." msgstr "函式種類有物件的比較運算、邏輯運算、數學運算以及序列運算。" -#: ../../library/operator.rst:28 +#: ../../library/operator.rst:26 msgid "" "The object comparison functions are useful for all objects, and are named " "after the rich comparison operators they support:" msgstr "" "物件比較函式適用於所有物件,函式根據它們對應的 rich comparison 運算子命名:" -#: ../../library/operator.rst:45 +#: ../../library/operator.rst:43 msgid "" "Perform \"rich comparisons\" between *a* and *b*. Specifically, ``lt(a, b)`` " "is equivalent to ``a < b``, ``le(a, b)`` is equivalent to ``a <= b``, " @@ -72,14 +72,14 @@ msgstr "" "b)`` 與 ``a >= b`` 相同。注意這些函式可以回傳任何值,無論它是否可當作 boolean" "(布林)值。關於 rich comparison 的更多資訊請參考 :ref:`comparisons`。" -#: ../../library/operator.rst:54 +#: ../../library/operator.rst:52 msgid "" "The logical operations are also generally applicable to all objects, and " "support truth tests, identity tests, and boolean operations:" msgstr "" "邏輯運算通常也適用於所有物件,並且支援真值檢測、識別性測試和 boolean 運算:" -#: ../../library/operator.rst:61 +#: ../../library/operator.rst:59 msgid "" "Return the outcome of :keyword:`not` *obj*. (Note that there is no :meth:`!" "__not__` method for object instances; only the interpreter core defines this " @@ -90,7 +90,7 @@ msgstr "" "method(方法);只有直譯器核心定義此操作。結果會受 :meth:`~object.__bool__` " "和 :meth:`~object.__len__` method 影響。)" -#: ../../library/operator.rst:69 +#: ../../library/operator.rst:67 msgid "" "Return :const:`True` if *obj* is true, and :const:`False` otherwise. This " "is equivalent to using the :class:`bool` constructor." @@ -98,142 +98,142 @@ msgstr "" "如果 *obj* 為真值則回傳 :const:`True`,否則回傳 :const:`False`。這等價於使" "用 :class:`bool` 建構函式。" -#: ../../library/operator.rst:75 +#: ../../library/operator.rst:73 msgid "Return ``a is b``. Tests object identity." msgstr "回傳 ``a is b``。測試物件識別性。" -#: ../../library/operator.rst:80 +#: ../../library/operator.rst:78 msgid "Return ``a is not b``. Tests object identity." msgstr "回傳 ``a is not b``。測試物件識別性。" -#: ../../library/operator.rst:85 +#: ../../library/operator.rst:83 msgid "Return ``a is None``. Tests object identity." msgstr "回傳 ``a is None``。測試物件識別性。" -#: ../../library/operator.rst:92 +#: ../../library/operator.rst:90 msgid "Return ``a is not None``. Tests object identity." msgstr "回傳 ``a is not None``。測試物件識別性。" -#: ../../library/operator.rst:97 +#: ../../library/operator.rst:95 msgid "The mathematical and bitwise operations are the most numerous:" msgstr "數學和位元運算的種類是最多的:" -#: ../../library/operator.rst:103 +#: ../../library/operator.rst:101 msgid "Return the absolute value of *obj*." msgstr "回傳 *obj* 的絕對值。" -#: ../../library/operator.rst:109 +#: ../../library/operator.rst:107 msgid "Return ``a + b``, for *a* and *b* numbers." msgstr "對於數字 *a* 和 *b*,回傳 ``a + b``。" -#: ../../library/operator.rst:115 +#: ../../library/operator.rst:113 msgid "Return ``a & b``." msgstr "回傳 ``a & b``。" -#: ../../library/operator.rst:121 +#: ../../library/operator.rst:119 msgid "Return ``a // b``." msgstr "回傳 ``a // b``。" -#: ../../library/operator.rst:127 +#: ../../library/operator.rst:125 msgid "Return *a* converted to an integer. Equivalent to ``a.__index__()``." msgstr "回傳 *a* 轉換為整數的結果。等價於 ``a.__index__()``。" -#: ../../library/operator.rst:129 +#: ../../library/operator.rst:127 msgid "" "The result always has exact type :class:`int`. Previously, the result could " "have been an instance of a subclass of ``int``." msgstr "" "結果總是 :class:`int` 型別。在過去的版本中,結果可能為 ``int`` 子類別的實例。" -#: ../../library/operator.rst:139 +#: ../../library/operator.rst:137 msgid "Return ``~obj``." msgstr "回傳 ``~obj``。" -#: ../../library/operator.rst:145 +#: ../../library/operator.rst:143 msgid "Return ``a << b``." msgstr "回傳 ``a << b``。" -#: ../../library/operator.rst:151 +#: ../../library/operator.rst:149 msgid "Return ``a % b``." msgstr "回傳 ``a % b``。" -#: ../../library/operator.rst:157 +#: ../../library/operator.rst:155 msgid "Return ``a * b``." msgstr "回傳 ``a * b``。" -#: ../../library/operator.rst:163 +#: ../../library/operator.rst:161 msgid "Return ``a @ b``." msgstr "回傳 ``a @ b``。" -#: ../../library/operator.rst:171 +#: ../../library/operator.rst:169 msgid "Return *obj* negated (``-obj``)." msgstr "回傳 *obj* 取負值的結果 (\\ ``-obj``\\ )。" -#: ../../library/operator.rst:177 +#: ../../library/operator.rst:175 msgid "Return ``a | b``." msgstr "回傳 ``a | b``。" -#: ../../library/operator.rst:183 +#: ../../library/operator.rst:181 msgid "Return ``+obj``." msgstr "回傳 ``+obj``。" -#: ../../library/operator.rst:189 +#: ../../library/operator.rst:187 msgid "Return ``a ** b``." msgstr "回傳 ``a ** b``。" -#: ../../library/operator.rst:195 +#: ../../library/operator.rst:193 msgid "Return ``a >> b``." msgstr "回傳 ``a >> b``。" -#: ../../library/operator.rst:201 +#: ../../library/operator.rst:199 msgid "Return ``a - b``." msgstr "回傳 ``a - b``。" -#: ../../library/operator.rst:207 +#: ../../library/operator.rst:205 msgid "" "Return ``a / b`` where 2/3 is .66 rather than 0. This is also known as " "\"true\" division." msgstr "回傳 ``a / b``,例如 2/3 將等於 .66 而不是 0。這也被稱為「真」除法。" -#: ../../library/operator.rst:214 +#: ../../library/operator.rst:212 msgid "Return ``a ^ b``." msgstr "回傳 ``a ^ b``。" -#: ../../library/operator.rst:217 +#: ../../library/operator.rst:215 msgid "" "Operations which work with sequences (some of them with mappings too) " "include:" msgstr "適用於序列的操作(其中一些也適用於對映 (mapping)),包括:" -#: ../../library/operator.rst:222 +#: ../../library/operator.rst:220 msgid "Return ``a + b`` for *a* and *b* sequences." msgstr "對於序列 *a* 和 *b*,回傳 ``a + b``。" -#: ../../library/operator.rst:228 +#: ../../library/operator.rst:226 msgid "Return the outcome of the test ``b in a``. Note the reversed operands." msgstr "回傳 ``b in a`` 檢測的結果。請注意運算元是反序的。" -#: ../../library/operator.rst:233 +#: ../../library/operator.rst:231 msgid "Return the number of occurrences of *b* in *a*." msgstr "回傳 *b* 在 *a* 中的出現次數。" -#: ../../library/operator.rst:239 +#: ../../library/operator.rst:237 msgid "Remove the value of *a* at index *b*." msgstr "移除 *a* 中索引為 *b* 的值。" -#: ../../library/operator.rst:245 +#: ../../library/operator.rst:243 msgid "Return the value of *a* at index *b*." msgstr "回傳 *a* 中索引為 *b* 的值。" -#: ../../library/operator.rst:250 +#: ../../library/operator.rst:248 msgid "Return the index of the first of occurrence of *b* in *a*." msgstr "回傳 *b* 在 *a* 中首次出現所在的索引。" -#: ../../library/operator.rst:256 +#: ../../library/operator.rst:254 msgid "Set the value of *a* at index *b* to *c*." msgstr "將 *a* 中索引為 *b* 的值設為 *c*。" -#: ../../library/operator.rst:261 +#: ../../library/operator.rst:259 msgid "" "Return an estimated length for the object *obj*. First try to return its " "actual length, then an estimate using :meth:`object.__length_hint__`, and " @@ -242,15 +242,15 @@ msgstr "" "回傳物件 *obj* 的估計長度。首先嘗試回傳其實際長度,再使用 :meth:`object." "__length_hint__` 得出估計值,最後才是回傳預設值。" -#: ../../library/operator.rst:268 +#: ../../library/operator.rst:266 msgid "The following operation works with callables:" msgstr "以下操作適用於可呼叫物件:" -#: ../../library/operator.rst:273 +#: ../../library/operator.rst:271 msgid "Return ``obj(*args, **kwargs)``." msgstr "回傳 ``obj(*args, **kwargs)``。" -#: ../../library/operator.rst:278 +#: ../../library/operator.rst:276 msgid "" "The :mod:`!operator` module also defines tools for generalized attribute and " "item lookups. These are useful for making fast field extractors as " @@ -261,7 +261,7 @@ msgstr "" "合用來編寫快速欄位提取器以作為 :func:`map`、:func:`sorted`、:meth:`itertools." "groupby` 或其他需要函式引數的函式之引數。" -#: ../../library/operator.rst:287 +#: ../../library/operator.rst:285 msgid "" "Return a callable object that fetches *attr* from its operand. If more than " "one attribute is requested, returns a tuple of attributes. The attribute " @@ -270,11 +270,11 @@ msgstr "" "回傳一個可從運算元中取得 *attr* 的可呼叫 (callable) 物件。如果請求了一個以上" "的屬性,則回傳一個包含屬性的 tupple(元組)。屬性名稱還可包含點號。例如:" -#: ../../library/operator.rst:291 +#: ../../library/operator.rst:289 msgid "After ``f = attrgetter('name')``, the call ``f(b)`` returns ``b.name``." msgstr "在 ``f = attrgetter('name')`` 之後,呼叫 ``f(b)`` 將回傳 ``b.name``。" -#: ../../library/operator.rst:293 +#: ../../library/operator.rst:291 msgid "" "After ``f = attrgetter('name', 'date')``, the call ``f(b)`` returns ``(b." "name, b.date)``." @@ -282,7 +282,7 @@ msgstr "" "在 ``f = attrgetter('name', 'date')`` 之後,呼叫 ``f(b)`` 將回傳 ``(b.name, " "b.date)``。" -#: ../../library/operator.rst:296 +#: ../../library/operator.rst:294 msgid "" "After ``f = attrgetter('name.first', 'name.last')``, the call ``f(b)`` " "returns ``(b.name.first, b.name.last)``." @@ -290,12 +290,12 @@ msgstr "" "在 ``f = attrgetter('name.first', 'name.last')`` 之後,呼叫 ``f(b)`` 將回傳 " "``(b.name.first, b.name.last)``。" -#: ../../library/operator.rst:299 ../../library/operator.rst:331 -#: ../../library/operator.rst:379 +#: ../../library/operator.rst:297 ../../library/operator.rst:329 +#: ../../library/operator.rst:377 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../library/operator.rst:301 +#: ../../library/operator.rst:299 msgid "" "def attrgetter(*items):\n" " if any(not isinstance(item, str) for item in items):\n" @@ -331,7 +331,7 @@ msgstr "" " obj = getattr(obj, name)\n" " return obj" -#: ../../library/operator.rst:322 +#: ../../library/operator.rst:320 msgid "" "Return a callable object that fetches *item* from its operand using the " "operand's :meth:`~object.__getitem__` method. If multiple items are " @@ -340,11 +340,11 @@ msgstr "" "回傳一個使用運算元的 :meth:`~object.__getitem__` 方法從運算元中取得 *item* 的" "可呼叫物件。如果指定了多個條目,則回傳一個查詢值的 tupple。例如:" -#: ../../library/operator.rst:326 +#: ../../library/operator.rst:324 msgid "After ``f = itemgetter(2)``, the call ``f(r)`` returns ``r[2]``." msgstr "在 ``f = itemgetter(2)`` 之後,呼叫 ``f(r)`` 將回傳 ``r[2]``。" -#: ../../library/operator.rst:328 +#: ../../library/operator.rst:326 msgid "" "After ``g = itemgetter(2, 5, 3)``, the call ``g(r)`` returns ``(r[2], r[5], " "r[3])``." @@ -352,7 +352,7 @@ msgstr "" "在 ``g = itemgetter(2, 5, 3)`` 之後,呼叫 ``g(r)`` 將回傳 ``(r[2], r[5], " "r[3])``。" -#: ../../library/operator.rst:333 +#: ../../library/operator.rst:331 msgid "" "def itemgetter(*items):\n" " if len(items) == 1:\n" @@ -374,7 +374,7 @@ msgstr "" " return tuple(obj[item] for item in items)\n" " return g" -#: ../../library/operator.rst:343 +#: ../../library/operator.rst:341 msgid "" "The items can be any type accepted by the operand's :meth:`~object." "__getitem__` method. Dictionaries accept any :term:`hashable` value. " @@ -384,13 +384,13 @@ msgstr "" "dictionary(字典)接受任意\\ :term:`可雜湊 `\\ 的值。list、tupple " "和字串接受索引或切片:" -#: ../../library/operator.rst:357 +#: ../../library/operator.rst:355 msgid "" "Example of using :func:`itemgetter` to retrieve specific fields from a tuple " "record:" msgstr "使用 :func:`itemgetter` 從 tuple 中提取特定欄位的例子:" -#: ../../library/operator.rst:370 +#: ../../library/operator.rst:368 msgid "" "Return a callable object that calls the method *name* on its operand. If " "additional arguments and/or keyword arguments are given, they will be given " @@ -399,13 +399,13 @@ msgstr "" "回傳一個在運算元上呼叫 *name* method 的可呼叫物件。如果給定額外的引數和/或關" "鍵字引數,它們也將被傳給該 method。例如:" -#: ../../library/operator.rst:374 +#: ../../library/operator.rst:372 msgid "" "After ``f = methodcaller('name')``, the call ``f(b)`` returns ``b.name()``." msgstr "" "在 ``f = methodcaller('name')`` 之後,呼叫 ``f(b)`` 將回傳 ``b.name()``。" -#: ../../library/operator.rst:376 +#: ../../library/operator.rst:374 msgid "" "After ``f = methodcaller('name', 'foo', bar=1)``, the call ``f(b)`` returns " "``b.name('foo', bar=1)``." @@ -413,7 +413,7 @@ msgstr "" "在 ``f = methodcaller('name', 'foo', bar=1)`` 之後,呼叫 ``f(b)`` 將回傳 ``b." "name('foo', bar=1)``。" -#: ../../library/operator.rst:381 +#: ../../library/operator.rst:379 msgid "" "def methodcaller(name, /, *args, **kwargs):\n" " def caller(obj):\n" @@ -425,11 +425,11 @@ msgstr "" " return getattr(obj, name)(*args, **kwargs)\n" " return caller" -#: ../../library/operator.rst:390 +#: ../../library/operator.rst:388 msgid "Mapping Operators to Functions" msgstr "運算子與函式間的對映" -#: ../../library/operator.rst:392 +#: ../../library/operator.rst:390 msgid "" "This table shows how abstract operations correspond to operator symbols in " "the Python syntax and the functions in the :mod:`!operator` module." @@ -437,441 +437,441 @@ msgstr "" "以下表格表示了抽象運算是如何對應於 Python 語法中的運算子和 :mod:`!operator` " "module 中的函式。" -#: ../../library/operator.rst:396 +#: ../../library/operator.rst:394 msgid "Operation" msgstr "運算" -#: ../../library/operator.rst:396 +#: ../../library/operator.rst:394 msgid "Syntax" msgstr "語法" -#: ../../library/operator.rst:396 +#: ../../library/operator.rst:394 msgid "Function" msgstr "函式" -#: ../../library/operator.rst:398 +#: ../../library/operator.rst:396 msgid "Addition" msgstr "加法" -#: ../../library/operator.rst:398 +#: ../../library/operator.rst:396 msgid "``a + b``" msgstr "``a + b``" -#: ../../library/operator.rst:398 +#: ../../library/operator.rst:396 msgid "``add(a, b)``" msgstr "``add(a, b)``" -#: ../../library/operator.rst:400 +#: ../../library/operator.rst:398 msgid "Concatenation" msgstr "字串串接" -#: ../../library/operator.rst:400 +#: ../../library/operator.rst:398 msgid "``seq1 + seq2``" msgstr "``seq1 + seq2``" -#: ../../library/operator.rst:400 +#: ../../library/operator.rst:398 msgid "``concat(seq1, seq2)``" msgstr "``concat(seq1, seq2)``" -#: ../../library/operator.rst:402 +#: ../../library/operator.rst:400 msgid "Containment Test" msgstr "包含性檢測" -#: ../../library/operator.rst:402 +#: ../../library/operator.rst:400 msgid "``obj in seq``" msgstr "``obj in seq``" -#: ../../library/operator.rst:402 +#: ../../library/operator.rst:400 msgid "``contains(seq, obj)``" msgstr "``contains(seq, obj)``" -#: ../../library/operator.rst:404 ../../library/operator.rst:406 +#: ../../library/operator.rst:402 ../../library/operator.rst:404 msgid "Division" msgstr "除法" -#: ../../library/operator.rst:404 +#: ../../library/operator.rst:402 msgid "``a / b``" msgstr "``a / b``" -#: ../../library/operator.rst:404 +#: ../../library/operator.rst:402 msgid "``truediv(a, b)``" msgstr "``truediv(a, b)``" -#: ../../library/operator.rst:406 +#: ../../library/operator.rst:404 msgid "``a // b``" msgstr "``a // b``" -#: ../../library/operator.rst:406 +#: ../../library/operator.rst:404 msgid "``floordiv(a, b)``" msgstr "``floordiv(a, b)``" -#: ../../library/operator.rst:408 +#: ../../library/operator.rst:406 msgid "Bitwise And, or Intersection" msgstr "按位元與 (And),或稱交集 (Intersection)" -#: ../../library/operator.rst:408 +#: ../../library/operator.rst:406 msgid "``a & b``" msgstr "``a & b``" -#: ../../library/operator.rst:408 +#: ../../library/operator.rst:406 msgid "``and_(a, b)``" msgstr "``and_(a, b)``" -#: ../../library/operator.rst:411 +#: ../../library/operator.rst:409 msgid "Bitwise Exclusive Or, or Symmetric Difference" msgstr "按位元互斥或 (Exclusive Or),或稱對稱差集 (Symmetric Difference)" -#: ../../library/operator.rst:411 +#: ../../library/operator.rst:409 msgid "``a ^ b``" msgstr "``a ^ b``" -#: ../../library/operator.rst:411 +#: ../../library/operator.rst:409 msgid "``xor(a, b)``" msgstr "``xor(a, b)``" -#: ../../library/operator.rst:415 +#: ../../library/operator.rst:413 msgid "Bitwise Inversion, or Complement" msgstr "按位元取反 (Inversion),或稱補集 (Complement)" -#: ../../library/operator.rst:415 +#: ../../library/operator.rst:413 msgid "``~ a``" msgstr "``~ a``" -#: ../../library/operator.rst:415 +#: ../../library/operator.rst:413 msgid "``invert(a)``" msgstr "``invert(a)``" -#: ../../library/operator.rst:418 +#: ../../library/operator.rst:416 msgid "Bitwise Or, or Union" msgstr "按位元或 (Or),或稱聯集 (Union)" -#: ../../library/operator.rst:418 +#: ../../library/operator.rst:416 msgid "``a | b``" msgstr "``a | b``" -#: ../../library/operator.rst:418 +#: ../../library/operator.rst:416 msgid "``or_(a, b)``" msgstr "``or_(a, b)``" -#: ../../library/operator.rst:421 +#: ../../library/operator.rst:419 msgid "Exponentiation" msgstr "取冪" -#: ../../library/operator.rst:421 +#: ../../library/operator.rst:419 msgid "``a ** b``" msgstr "``a ** b``" -#: ../../library/operator.rst:421 +#: ../../library/operator.rst:419 msgid "``pow(a, b)``" msgstr "``pow(a, b)``" -#: ../../library/operator.rst:423 ../../library/operator.rst:425 -#: ../../library/operator.rst:427 ../../library/operator.rst:429 +#: ../../library/operator.rst:421 ../../library/operator.rst:423 +#: ../../library/operator.rst:425 ../../library/operator.rst:427 msgid "Identity" msgstr "識別性" -#: ../../library/operator.rst:423 +#: ../../library/operator.rst:421 msgid "``a is b``" msgstr "``a is b``" -#: ../../library/operator.rst:423 +#: ../../library/operator.rst:421 msgid "``is_(a, b)``" msgstr "``is_(a, b)``" -#: ../../library/operator.rst:425 +#: ../../library/operator.rst:423 msgid "``a is not b``" msgstr "``a is not b``" -#: ../../library/operator.rst:425 +#: ../../library/operator.rst:423 msgid "``is_not(a, b)``" msgstr "``is_not(a, b)``" -#: ../../library/operator.rst:427 +#: ../../library/operator.rst:425 msgid "``a is None``" msgstr "``a is None``" -#: ../../library/operator.rst:427 +#: ../../library/operator.rst:425 msgid "``is_none(a)``" msgstr "``is_none(a)``" -#: ../../library/operator.rst:429 +#: ../../library/operator.rst:427 msgid "``a is not None``" msgstr "``a is not None``" -#: ../../library/operator.rst:429 +#: ../../library/operator.rst:427 msgid "``is_not_none(a)``" msgstr "``is_not_none(a)``" -#: ../../library/operator.rst:431 +#: ../../library/operator.rst:429 msgid "Indexed Assignment" msgstr "索引賦值" -#: ../../library/operator.rst:431 +#: ../../library/operator.rst:429 msgid "``obj[k] = v``" msgstr "``obj[k] = v``" -#: ../../library/operator.rst:431 +#: ../../library/operator.rst:429 msgid "``setitem(obj, k, v)``" msgstr "``setitem(obj, k, v)``" -#: ../../library/operator.rst:433 +#: ../../library/operator.rst:431 msgid "Indexed Deletion" msgstr "索引刪除" -#: ../../library/operator.rst:433 +#: ../../library/operator.rst:431 msgid "``del obj[k]``" msgstr "``del obj[k]``" -#: ../../library/operator.rst:433 +#: ../../library/operator.rst:431 msgid "``delitem(obj, k)``" msgstr "``delitem(obj, k)``" -#: ../../library/operator.rst:435 +#: ../../library/operator.rst:433 msgid "Indexing" msgstr "索引取值" -#: ../../library/operator.rst:435 +#: ../../library/operator.rst:433 msgid "``obj[k]``" msgstr "``obj[k]``" -#: ../../library/operator.rst:435 +#: ../../library/operator.rst:433 msgid "``getitem(obj, k)``" msgstr "``getitem(obj, k)``" -#: ../../library/operator.rst:437 +#: ../../library/operator.rst:435 msgid "Left Shift" msgstr "左移" -#: ../../library/operator.rst:437 +#: ../../library/operator.rst:435 msgid "``a << b``" msgstr "``a << b``" -#: ../../library/operator.rst:437 +#: ../../library/operator.rst:435 msgid "``lshift(a, b)``" msgstr "``lshift(a, b)``" -#: ../../library/operator.rst:439 +#: ../../library/operator.rst:437 msgid "Modulo" msgstr "模除 (Modulo)" -#: ../../library/operator.rst:439 +#: ../../library/operator.rst:437 msgid "``a % b``" msgstr "``a % b``" -#: ../../library/operator.rst:439 +#: ../../library/operator.rst:437 msgid "``mod(a, b)``" msgstr "``mod(a, b)``" -#: ../../library/operator.rst:441 +#: ../../library/operator.rst:439 msgid "Multiplication" msgstr "乘法" -#: ../../library/operator.rst:441 +#: ../../library/operator.rst:439 msgid "``a * b``" msgstr "``a * b``" -#: ../../library/operator.rst:441 +#: ../../library/operator.rst:439 msgid "``mul(a, b)``" msgstr "``mul(a, b)``" -#: ../../library/operator.rst:443 +#: ../../library/operator.rst:441 msgid "Matrix Multiplication" msgstr "矩陣乘法" -#: ../../library/operator.rst:443 +#: ../../library/operator.rst:441 msgid "``a @ b``" msgstr "``a @ b``" -#: ../../library/operator.rst:443 +#: ../../library/operator.rst:441 msgid "``matmul(a, b)``" msgstr "``matmul(a, b)``" -#: ../../library/operator.rst:445 +#: ../../library/operator.rst:443 msgid "Negation (Arithmetic)" msgstr "反相(算術)" -#: ../../library/operator.rst:445 +#: ../../library/operator.rst:443 msgid "``- a``" msgstr "``- a``" -#: ../../library/operator.rst:445 +#: ../../library/operator.rst:443 msgid "``neg(a)``" msgstr "``neg(a)``" -#: ../../library/operator.rst:447 +#: ../../library/operator.rst:445 msgid "Negation (Logical)" msgstr "反相(邏輯)" -#: ../../library/operator.rst:447 +#: ../../library/operator.rst:445 msgid "``not a``" msgstr "``not a``" -#: ../../library/operator.rst:447 +#: ../../library/operator.rst:445 msgid "``not_(a)``" msgstr "``not_(a)``" -#: ../../library/operator.rst:449 +#: ../../library/operator.rst:447 msgid "Positive" msgstr "正數" -#: ../../library/operator.rst:449 +#: ../../library/operator.rst:447 msgid "``+ a``" msgstr "``+ a``" -#: ../../library/operator.rst:449 +#: ../../library/operator.rst:447 msgid "``pos(a)``" msgstr "``pos(a)``" -#: ../../library/operator.rst:451 +#: ../../library/operator.rst:449 msgid "Right Shift" msgstr "右移" -#: ../../library/operator.rst:451 +#: ../../library/operator.rst:449 msgid "``a >> b``" msgstr "``a >> b``" -#: ../../library/operator.rst:451 +#: ../../library/operator.rst:449 msgid "``rshift(a, b)``" msgstr "``rshift(a, b)``" -#: ../../library/operator.rst:453 +#: ../../library/operator.rst:451 msgid "Slice Assignment" msgstr "切片賦值" -#: ../../library/operator.rst:453 +#: ../../library/operator.rst:451 msgid "``seq[i:j] = values``" msgstr "``seq[i:j] = values``" -#: ../../library/operator.rst:453 +#: ../../library/operator.rst:451 msgid "``setitem(seq, slice(i, j), values)``" msgstr "``setitem(seq, slice(i, j), values)``" -#: ../../library/operator.rst:455 +#: ../../library/operator.rst:453 msgid "Slice Deletion" msgstr "切片刪除" -#: ../../library/operator.rst:455 +#: ../../library/operator.rst:453 msgid "``del seq[i:j]``" msgstr "``del seq[i:j]``" -#: ../../library/operator.rst:455 +#: ../../library/operator.rst:453 msgid "``delitem(seq, slice(i, j))``" msgstr "``delitem(seq, slice(i, j))``" -#: ../../library/operator.rst:457 +#: ../../library/operator.rst:455 msgid "Slicing" msgstr "切片取值" -#: ../../library/operator.rst:457 +#: ../../library/operator.rst:455 msgid "``seq[i:j]``" msgstr "``seq[i:j]``" -#: ../../library/operator.rst:457 +#: ../../library/operator.rst:455 msgid "``getitem(seq, slice(i, j))``" msgstr "``getitem(seq, slice(i, j))``" -#: ../../library/operator.rst:459 +#: ../../library/operator.rst:457 msgid "String Formatting" msgstr "字串格式化" -#: ../../library/operator.rst:459 +#: ../../library/operator.rst:457 msgid "``s % obj``" msgstr "``s % obj``" -#: ../../library/operator.rst:459 +#: ../../library/operator.rst:457 msgid "``mod(s, obj)``" msgstr "``mod(s, obj)``" -#: ../../library/operator.rst:461 +#: ../../library/operator.rst:459 msgid "Subtraction" msgstr "減法" -#: ../../library/operator.rst:461 +#: ../../library/operator.rst:459 msgid "``a - b``" msgstr "``a - b``" -#: ../../library/operator.rst:461 +#: ../../library/operator.rst:459 msgid "``sub(a, b)``" msgstr "``sub(a, b)``" -#: ../../library/operator.rst:463 +#: ../../library/operator.rst:461 msgid "Truth Test" msgstr "真值檢測" -#: ../../library/operator.rst:463 +#: ../../library/operator.rst:461 msgid "``obj``" msgstr "``obj``" -#: ../../library/operator.rst:463 +#: ../../library/operator.rst:461 msgid "``truth(obj)``" msgstr "``truth(obj)``" -#: ../../library/operator.rst:465 ../../library/operator.rst:467 -#: ../../library/operator.rst:473 ../../library/operator.rst:475 +#: ../../library/operator.rst:463 ../../library/operator.rst:465 +#: ../../library/operator.rst:471 ../../library/operator.rst:473 msgid "Ordering" msgstr "比較大小" -#: ../../library/operator.rst:465 +#: ../../library/operator.rst:463 msgid "``a < b``" msgstr "``a < b``" -#: ../../library/operator.rst:465 +#: ../../library/operator.rst:463 msgid "``lt(a, b)``" msgstr "``lt(a, b)``" -#: ../../library/operator.rst:467 +#: ../../library/operator.rst:465 msgid "``a <= b``" msgstr "``a <= b``" -#: ../../library/operator.rst:467 +#: ../../library/operator.rst:465 msgid "``le(a, b)``" msgstr "``le(a, b)``" -#: ../../library/operator.rst:469 +#: ../../library/operator.rst:467 msgid "Equality" msgstr "相等性" -#: ../../library/operator.rst:469 +#: ../../library/operator.rst:467 msgid "``a == b``" msgstr "``a == b``" -#: ../../library/operator.rst:469 +#: ../../library/operator.rst:467 msgid "``eq(a, b)``" msgstr "``eq(a, b)``" -#: ../../library/operator.rst:471 +#: ../../library/operator.rst:469 msgid "Difference" msgstr "不等性" -#: ../../library/operator.rst:471 +#: ../../library/operator.rst:469 msgid "``a != b``" msgstr "``a != b``" -#: ../../library/operator.rst:471 +#: ../../library/operator.rst:469 msgid "``ne(a, b)``" msgstr "``ne(a, b)``" -#: ../../library/operator.rst:473 +#: ../../library/operator.rst:471 msgid "``a >= b``" msgstr "``a >= b``" -#: ../../library/operator.rst:473 +#: ../../library/operator.rst:471 msgid "``ge(a, b)``" msgstr "``ge(a, b)``" -#: ../../library/operator.rst:475 +#: ../../library/operator.rst:473 msgid "``a > b``" msgstr "``a > b``" -#: ../../library/operator.rst:475 +#: ../../library/operator.rst:473 msgid "``gt(a, b)``" msgstr "``gt(a, b)``" -#: ../../library/operator.rst:479 +#: ../../library/operator.rst:477 msgid "In-place Operators" msgstr "原地 (in-place) 運算子" -#: ../../library/operator.rst:481 +#: ../../library/operator.rst:479 msgid "" "Many operations have an \"in-place\" version. Listed below are functions " "providing a more primitive access to in-place operators than the usual " @@ -885,7 +885,7 @@ msgstr "" "iadd(x, y)``。換一種方式來講就是 ``z = operator.iadd(x, y)`` 等價於複合陳述" "式 ``z = x; z += y``。" -#: ../../library/operator.rst:488 +#: ../../library/operator.rst:486 msgid "" "In those examples, note that when an in-place method is called, the " "computation and assignment are performed in two separate steps. The in-" @@ -895,7 +895,7 @@ msgstr "" "在這些例子中,請注意當呼叫一個原地方法時,運算和賦值是分成兩個步驟來執行的。" "下面列出的原地函式只執行第一步,即呼叫原地方法,第二步賦值則不加處理。" -#: ../../library/operator.rst:493 +#: ../../library/operator.rst:491 msgid "" "For immutable targets such as strings, numbers, and tuples, the updated " "value is computed, but not assigned back to the input variable:" @@ -903,7 +903,7 @@ msgstr "" "對於不可變 (immutable) 的目標例如字串、數字和 tupple,更新的值會被計算,但不" "會被再被賦值給輸入變數:" -#: ../../library/operator.rst:502 +#: ../../library/operator.rst:500 msgid "" "For mutable targets such as lists and dictionaries, the in-place method will " "perform the update, so no subsequent assignment is necessary:" @@ -911,60 +911,60 @@ msgstr "" "對於可變 (mutable) 的目標例如 list 和 dictionary,原地方法將執行更新,因此不" "需要後續賦值操作:" -#: ../../library/operator.rst:514 +#: ../../library/operator.rst:512 msgid "``a = iadd(a, b)`` is equivalent to ``a += b``." msgstr "``a = iadd(a, b)`` 等價於 ``a += b``。" -#: ../../library/operator.rst:520 +#: ../../library/operator.rst:518 msgid "``a = iand(a, b)`` is equivalent to ``a &= b``." msgstr "``a = iand(a, b)`` 等價於 ``a &= b``。" -#: ../../library/operator.rst:526 +#: ../../library/operator.rst:524 msgid "" "``a = iconcat(a, b)`` is equivalent to ``a += b`` for *a* and *b* sequences." msgstr "``a = iconcat(a, b)`` 等價於 ``a += b``,其中 *a* 和 *b* 為序列。" -#: ../../library/operator.rst:532 +#: ../../library/operator.rst:530 msgid "``a = ifloordiv(a, b)`` is equivalent to ``a //= b``." msgstr "``a = ifloordiv(a, b)`` 等價於 ``a //= b``。" -#: ../../library/operator.rst:538 +#: ../../library/operator.rst:536 msgid "``a = ilshift(a, b)`` is equivalent to ``a <<= b``." msgstr "``a = ilshift(a, b)`` 等價於 ``a <<= b``。" -#: ../../library/operator.rst:544 +#: ../../library/operator.rst:542 msgid "``a = imod(a, b)`` is equivalent to ``a %= b``." msgstr "``a = imod(a, b)`` 等價於 ``a %= b``。" -#: ../../library/operator.rst:550 +#: ../../library/operator.rst:548 msgid "``a = imul(a, b)`` is equivalent to ``a *= b``." msgstr "``a = imul(a, b)`` 等價於 ``a *= b``。" -#: ../../library/operator.rst:556 +#: ../../library/operator.rst:554 msgid "``a = imatmul(a, b)`` is equivalent to ``a @= b``." msgstr "``a = imatmul(a, b)`` 等價於 ``a @= b``。" -#: ../../library/operator.rst:564 +#: ../../library/operator.rst:562 msgid "``a = ior(a, b)`` is equivalent to ``a |= b``." msgstr "``a = ior(a, b)`` 等價於 ``a |= b``。" -#: ../../library/operator.rst:570 +#: ../../library/operator.rst:568 msgid "``a = ipow(a, b)`` is equivalent to ``a **= b``." msgstr "``a = ipow(a, b)`` 等價於 ``a **= b``。" -#: ../../library/operator.rst:576 +#: ../../library/operator.rst:574 msgid "``a = irshift(a, b)`` is equivalent to ``a >>= b``." msgstr "``a = irshift(a, b)`` 等價於 ``a >>= b``。" -#: ../../library/operator.rst:582 +#: ../../library/operator.rst:580 msgid "``a = isub(a, b)`` is equivalent to ``a -= b``." msgstr "``a = isub(a, b)`` 等價於 ``a -= b``。" -#: ../../library/operator.rst:588 +#: ../../library/operator.rst:586 msgid "``a = itruediv(a, b)`` is equivalent to ``a /= b``." msgstr "``a = itruediv(a, b)`` 等價於 ``a /= b``。" -#: ../../library/operator.rst:594 +#: ../../library/operator.rst:592 msgid "``a = ixor(a, b)`` is equivalent to ``a ^= b``." msgstr "``a = ixor(a, b)`` 等價於 ``a ^= b``。" diff --git a/library/optparse.po b/library/optparse.po index 59b6ff62fbe..c451e55307a 100644 --- a/library/optparse.po +++ b/library/optparse.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-27 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,38 +21,38 @@ msgstr "" msgid ":mod:`!optparse` --- Parser for command line options" msgstr ":mod:`!optparse` --- 命令列選項剖析器" -#: ../../library/optparse.rst:10 +#: ../../library/optparse.rst:7 msgid "**Source code:** :source:`Lib/optparse.py`" msgstr "**原始碼:**\\ :source:`Lib/optparse.py`" -#: ../../library/optparse.rst:17 +#: ../../library/optparse.rst:14 msgid "Choosing an argument parsing library" msgstr "選擇一個命令列參數剖析函式庫" -#: ../../library/optparse.rst:19 +#: ../../library/optparse.rst:16 msgid "The standard library includes three argument parsing libraries:" msgstr "標準函式庫包含三個命令列引數剖析函式庫:" -#: ../../library/optparse.rst:21 +#: ../../library/optparse.rst:18 msgid "" ":mod:`getopt`: a module that closely mirrors the procedural C ``getopt`` API." msgstr "" -#: ../../library/optparse.rst:22 +#: ../../library/optparse.rst:19 msgid "" ":mod:`!optparse`: a declarative replacement for ``getopt`` that provides " "equivalent functionality without requiring each application to implement its " "own procedural option parsing logic." msgstr "" -#: ../../library/optparse.rst:25 +#: ../../library/optparse.rst:22 msgid "" ":mod:`argparse`: a more opinionated alternative to ``optparse`` that " "provides more functionality by default, at the expense of reduced " "application flexibility in controlling exactly how arguments are processed." msgstr "" -#: ../../library/optparse.rst:29 +#: ../../library/optparse.rst:26 msgid "" "In the absence of more specific argument parsing design constraints, :mod:" "`argparse` is the recommended choice for implementing command line " @@ -60,7 +60,7 @@ msgid "" "the least application level code." msgstr "" -#: ../../library/optparse.rst:33 +#: ../../library/optparse.rst:30 msgid "" ":mod:`getopt` is retained almost entirely for backwards compatibility " "reasons. However, it also serves a niche use case as a tool for prototyping " @@ -68,62 +68,62 @@ msgid "" "applications." msgstr "" -#: ../../library/optparse.rst:37 +#: ../../library/optparse.rst:34 msgid "" ":mod:`!optparse` should be considered as an alternative to :mod:`argparse` " "in the following cases:" msgstr "" -#: ../../library/optparse.rst:40 +#: ../../library/optparse.rst:37 msgid "" "an application is already using :mod:`!optparse` and doesn't want to risk " "the subtle behavioural changes that may arise when migrating to :mod:" "`argparse`" msgstr "" -#: ../../library/optparse.rst:42 +#: ../../library/optparse.rst:39 msgid "" "the application requires additional control over the way options and " "positional parameters are interleaved on the command line (including the " "ability to disable the interleaving feature completely)" msgstr "" -#: ../../library/optparse.rst:45 +#: ../../library/optparse.rst:42 msgid "" "the application requires additional control over the incremental parsing of " "command line elements (while ``argparse`` does support this, the exact way " "it works in practice is undesirable for some use cases)" msgstr "" -#: ../../library/optparse.rst:48 +#: ../../library/optparse.rst:45 msgid "" "the application requires additional control over the handling of options " "which accept parameter values that may start with ``-`` (such as delegated " "options to be passed to invoked subprocesses)" msgstr "" -#: ../../library/optparse.rst:51 +#: ../../library/optparse.rst:48 msgid "" "the application requires some other command line parameter processing " "behavior which ``argparse`` does not support, but which can be implemented " "in terms of the lower level interface offered by ``optparse``" msgstr "" -#: ../../library/optparse.rst:55 +#: ../../library/optparse.rst:52 msgid "" "These considerations also mean that :mod:`!optparse` is likely to provide a " "better foundation for library authors writing third party command line " "argument processing libraries." msgstr "" -#: ../../library/optparse.rst:59 +#: ../../library/optparse.rst:56 msgid "" "As a concrete example, consider the following two command line argument " "parsing configurations, the first using ``optparse``, and the second using " "``argparse``:" msgstr "" -#: ../../library/optparse.rst:63 +#: ../../library/optparse.rst:60 msgid "" "import optparse\n" "\n" @@ -143,7 +143,7 @@ msgstr "" " opts, args = parser.parse_args()\n" " process(args, output=opts.output, verbose=opts.verbose)" -#: ../../library/optparse.rst:74 +#: ../../library/optparse.rst:71 msgid "" "import argparse\n" "\n" @@ -165,7 +165,7 @@ msgstr "" " args = parser.parse_args()\n" " process(args.rest, output=args.output, verbose=args.verbose)" -#: ../../library/optparse.rst:86 +#: ../../library/optparse.rst:83 msgid "" "The most obvious difference is that in the ``optparse`` version, the non-" "option arguments are processed separately by the application after the " @@ -173,14 +173,14 @@ msgid "" "arguments are declared and processed in the same way as the named options." msgstr "" -#: ../../library/optparse.rst:91 +#: ../../library/optparse.rst:88 msgid "" "However, the ``argparse`` version will also handle some parameter " "combination differently from the way the ``optparse`` version would handle " "them. For example (amongst other differences):" msgstr "" -#: ../../library/optparse.rst:95 +#: ../../library/optparse.rst:92 msgid "" "supplying ``-o -v`` gives ``output=\"-v\"`` and ``verbose=False`` when using " "``optparse``, but a usage error with ``argparse`` (complaining that no value " @@ -188,7 +188,7 @@ msgid "" "meaning the verbosity flag)" msgstr "" -#: ../../library/optparse.rst:99 +#: ../../library/optparse.rst:96 msgid "" "similarly, supplying ``-o --`` gives ``output=\"--\"`` and ``args=()`` when " "using ``optparse``, but a usage error with ``argparse`` (also complaining " @@ -197,39 +197,39 @@ msgid "" "values as positional arguments)" msgstr "" -#: ../../library/optparse.rst:104 +#: ../../library/optparse.rst:101 msgid "" "supplying ``-o=foo`` gives ``output=\"=foo\"`` when using ``optparse``, but " "gives ``output=\"foo\"`` with ``argparse`` (since ``=`` is special cased as " "an alternative separator for option parameter values)" msgstr "" -#: ../../library/optparse.rst:108 +#: ../../library/optparse.rst:105 msgid "" "Whether these differing behaviors in the ``argparse`` version are considered " "desirable or a problem will depend on the specific command line application " "use case." msgstr "" -#: ../../library/optparse.rst:114 +#: ../../library/optparse.rst:111 msgid "" ":pypi:`click` is a third party argument processing library (originally based " "on ``optparse``), which allows command line applications to be developed as " "a set of decorated command implementation functions." msgstr "" -#: ../../library/optparse.rst:118 +#: ../../library/optparse.rst:115 msgid "" "Other third party libraries, such as :pypi:`typer` or :pypi:`msgspec-click`, " "allow command line interfaces to be specified in ways that more effectively " "integrate with static checking of Python type annotations." msgstr "" -#: ../../library/optparse.rst:124 +#: ../../library/optparse.rst:121 msgid "Introduction" msgstr "" -#: ../../library/optparse.rst:126 +#: ../../library/optparse.rst:123 msgid "" ":mod:`!optparse` is a more convenient, flexible, and powerful library for " "parsing command-line options than the minimalist :mod:`getopt` module. :mod:" @@ -240,11 +240,11 @@ msgid "" "messages for you." msgstr "" -#: ../../library/optparse.rst:134 +#: ../../library/optparse.rst:131 msgid "Here's an example of using :mod:`!optparse` in a simple script::" msgstr "" -#: ../../library/optparse.rst:136 +#: ../../library/optparse.rst:133 msgid "" "from optparse import OptionParser\n" "...\n" @@ -268,17 +268,17 @@ msgstr "" "\n" "(options, args) = parser.parse_args()" -#: ../../library/optparse.rst:147 +#: ../../library/optparse.rst:144 msgid "" "With these few lines of code, users of your script can now do the \"usual " "thing\" on the command-line, for example::" msgstr "" -#: ../../library/optparse.rst:150 +#: ../../library/optparse.rst:147 msgid " --file=outfile -q" msgstr " --file=outfile -q" -#: ../../library/optparse.rst:152 +#: ../../library/optparse.rst:149 msgid "" "As it parses the command line, :mod:`!optparse` sets attributes of the " "``options`` object returned by :meth:`~OptionParser.parse_args` based on " @@ -291,7 +291,7 @@ msgid "" "the above example::" msgstr "" -#: ../../library/optparse.rst:161 +#: ../../library/optparse.rst:158 msgid "" " -f outfile --quiet\n" " --quiet --file outfile\n" @@ -299,11 +299,11 @@ msgid "" " -qfoutfile" msgstr "" -#: ../../library/optparse.rst:166 +#: ../../library/optparse.rst:163 msgid "Additionally, users can run one of the following ::" msgstr "" -#: ../../library/optparse.rst:168 +#: ../../library/optparse.rst:165 msgid "" " -h\n" " --help" @@ -311,12 +311,12 @@ msgstr "" " -h\n" " --help" -#: ../../library/optparse.rst:171 +#: ../../library/optparse.rst:168 msgid "" "and :mod:`!optparse` will print out a brief summary of your script's options:" msgstr "" -#: ../../library/optparse.rst:173 +#: ../../library/optparse.rst:170 msgid "" "Usage: [options]\n" "\n" @@ -332,17 +332,17 @@ msgstr "" " -f FILE, --file=FILE write report to FILE\n" " -q, --quiet don't print status messages to stdout" -#: ../../library/optparse.rst:182 +#: ../../library/optparse.rst:179 msgid "" "where the value of *yourscript* is determined at runtime (normally from " "``sys.argv[0]``)." msgstr "" -#: ../../library/optparse.rst:189 +#: ../../library/optparse.rst:186 msgid "Background" msgstr "背景" -#: ../../library/optparse.rst:191 +#: ../../library/optparse.rst:188 msgid "" ":mod:`!optparse` was explicitly designed to encourage the creation of " "programs with straightforward command-line interfaces that follow the " @@ -353,15 +353,15 @@ msgid "" "to acquaint yourself with them." msgstr "" -#: ../../library/optparse.rst:202 +#: ../../library/optparse.rst:199 msgid "Terminology" msgstr "術語" -#: ../../library/optparse.rst:204 +#: ../../library/optparse.rst:201 msgid "argument" msgstr "引數" -#: ../../library/optparse.rst:205 +#: ../../library/optparse.rst:202 msgid "" "a string entered on the command-line, and passed by the shell to ``execl()`` " "or ``execv()``. In Python, arguments are elements of ``sys.argv[1:]`` " @@ -369,7 +369,7 @@ msgid "" "also use the term \"word\"." msgstr "" -#: ../../library/optparse.rst:210 +#: ../../library/optparse.rst:207 msgid "" "It is occasionally desirable to substitute an argument list other than ``sys." "argv[1:]``, so you should read \"argument\" as \"an element of ``sys." @@ -377,11 +377,11 @@ msgid "" "argv[1:]``\"." msgstr "" -#: ../../library/optparse.rst:215 +#: ../../library/optparse.rst:212 msgid "option" msgstr "選項" -#: ../../library/optparse.rst:216 +#: ../../library/optparse.rst:213 msgid "" "an argument used to supply extra information to guide or customize the " "execution of a program. There are many different syntaxes for options; the " @@ -393,36 +393,36 @@ msgid "" "option syntaxes provided by :mod:`!optparse`." msgstr "" -#: ../../library/optparse.rst:225 +#: ../../library/optparse.rst:222 msgid "Some other option syntaxes that the world has seen include:" msgstr "" -#: ../../library/optparse.rst:227 +#: ../../library/optparse.rst:224 msgid "" "a hyphen followed by a few letters, e.g. ``-pf`` (this is *not* the same as " "multiple options merged into a single argument)" msgstr "" -#: ../../library/optparse.rst:230 +#: ../../library/optparse.rst:227 msgid "" "a hyphen followed by a whole word, e.g. ``-file`` (this is technically " "equivalent to the previous syntax, but they aren't usually seen in the same " "program)" msgstr "" -#: ../../library/optparse.rst:234 +#: ../../library/optparse.rst:231 msgid "" "a plus sign followed by a single letter, or a few letters, or a word, e.g. " "``+f``, ``+rgb``" msgstr "" -#: ../../library/optparse.rst:237 +#: ../../library/optparse.rst:234 msgid "" "a slash followed by a letter, or a few letters, or a word, e.g. ``/f``, ``/" "file``" msgstr "" -#: ../../library/optparse.rst:240 +#: ../../library/optparse.rst:237 msgid "" "These option syntaxes are not supported by :mod:`!optparse`, and they never " "will be. This is deliberate: the first three are non-standard on any " @@ -430,11 +430,11 @@ msgid "" "Windows or certain legacy platforms (e.g. VMS, MS-DOS)." msgstr "" -#: ../../library/optparse.rst:245 +#: ../../library/optparse.rst:242 msgid "option argument" msgstr "選項引數" -#: ../../library/optparse.rst:246 +#: ../../library/optparse.rst:243 msgid "" "an argument that follows an option, is closely associated with that option, " "and is consumed from the argument list when that option is. With :mod:`!" @@ -442,7 +442,7 @@ msgid "" "option:" msgstr "" -#: ../../library/optparse.rst:251 +#: ../../library/optparse.rst:248 msgid "" "-f foo\n" "--file foo" @@ -450,11 +450,11 @@ msgstr "" "-f foo\n" "--file foo" -#: ../../library/optparse.rst:256 +#: ../../library/optparse.rst:253 msgid "or included in the same argument:" msgstr "" -#: ../../library/optparse.rst:258 +#: ../../library/optparse.rst:255 msgid "" "-ffoo\n" "--file=foo" @@ -462,7 +462,7 @@ msgstr "" "-ffoo\n" "--file=foo" -#: ../../library/optparse.rst:263 +#: ../../library/optparse.rst:260 msgid "" "Typically, a given option either takes an argument or it doesn't. Lots of " "people want an \"optional option arguments\" feature, meaning that some " @@ -473,22 +473,22 @@ msgid "" "support this feature." msgstr "" -#: ../../library/optparse.rst:271 +#: ../../library/optparse.rst:268 msgid "positional argument" msgstr "位置引數" -#: ../../library/optparse.rst:272 +#: ../../library/optparse.rst:269 msgid "" "something leftover in the argument list after options have been parsed, i.e. " "after options and their arguments have been parsed and removed from the " "argument list." msgstr "" -#: ../../library/optparse.rst:276 +#: ../../library/optparse.rst:273 msgid "required option" msgstr "" -#: ../../library/optparse.rst:277 +#: ../../library/optparse.rst:274 msgid "" "an option that must be supplied on the command-line; note that the phrase " "\"required option\" is self-contradictory in English. :mod:`!optparse` " @@ -496,26 +496,26 @@ msgid "" "much help at it either." msgstr "" -#: ../../library/optparse.rst:282 +#: ../../library/optparse.rst:279 msgid "For example, consider this hypothetical command-line::" msgstr "" -#: ../../library/optparse.rst:284 +#: ../../library/optparse.rst:281 msgid "prog -v --report report.txt foo bar" msgstr "prog -v --report report.txt foo bar" -#: ../../library/optparse.rst:286 +#: ../../library/optparse.rst:283 msgid "" "``-v`` and ``--report`` are both options. Assuming that ``--report`` takes " "one argument, ``report.txt`` is an option argument. ``foo`` and ``bar`` are " "positional arguments." msgstr "" -#: ../../library/optparse.rst:294 +#: ../../library/optparse.rst:291 msgid "What are options for?" msgstr "" -#: ../../library/optparse.rst:296 +#: ../../library/optparse.rst:293 msgid "" "Options are used to provide extra information to tune or customize the " "execution of a program. In case it wasn't clear, options are usually " @@ -527,7 +527,7 @@ msgid "" "interfaces.)" msgstr "" -#: ../../library/optparse.rst:304 +#: ../../library/optparse.rst:301 msgid "" "Lots of people want their programs to have \"required options\". Think " "about it. If it's required, then it's *not optional*! If there is a piece " @@ -535,7 +535,7 @@ msgid "" "successfully, that's what positional arguments are for." msgstr "" -#: ../../library/optparse.rst:309 +#: ../../library/optparse.rst:306 msgid "" "As an example of good command-line interface design, consider the humble " "``cp`` utility, for copying files. It doesn't make much sense to try to " @@ -544,7 +544,7 @@ msgid "" "useful syntax that does not require any options at all::" msgstr "" -#: ../../library/optparse.rst:315 +#: ../../library/optparse.rst:312 msgid "" "cp SOURCE DEST\n" "cp SOURCE ... DEST-DIR" @@ -552,7 +552,7 @@ msgstr "" "cp SOURCE DEST\n" "cp SOURCE ... DEST-DIR" -#: ../../library/optparse.rst:318 +#: ../../library/optparse.rst:315 msgid "" "You can get pretty far with just that. Most ``cp`` implementations provide " "a bunch of options to tweak exactly how the files are copied: you can " @@ -562,17 +562,17 @@ msgid "" "files to another directory." msgstr "" -#: ../../library/optparse.rst:329 +#: ../../library/optparse.rst:326 msgid "What are positional arguments for?" msgstr "" -#: ../../library/optparse.rst:331 +#: ../../library/optparse.rst:328 msgid "" "Positional arguments are for those pieces of information that your program " "absolutely, positively requires to run." msgstr "" -#: ../../library/optparse.rst:334 +#: ../../library/optparse.rst:331 msgid "" "A good user interface should have as few absolute requirements as possible. " "If your program requires 17 distinct pieces of information in order to run " @@ -583,7 +583,7 @@ msgid "" "most of them will simply give up." msgstr "" -#: ../../library/optparse.rst:342 +#: ../../library/optparse.rst:339 msgid "" "In short, try to minimize the amount of information that users are " "absolutely required to supply---use sensible defaults whenever possible. Of " @@ -596,24 +596,24 @@ msgid "" "make your code much harder to maintain." msgstr "" -#: ../../library/optparse.rst:355 +#: ../../library/optparse.rst:352 msgid "Tutorial" msgstr "教學" -#: ../../library/optparse.rst:357 +#: ../../library/optparse.rst:354 msgid "" "While :mod:`!optparse` is quite flexible and powerful, it's also " "straightforward to use in most cases. This section covers the code patterns " "that are common to any :mod:`!optparse`\\ -based program." msgstr "" -#: ../../library/optparse.rst:361 +#: ../../library/optparse.rst:358 msgid "" "First, you need to import the OptionParser class; then, early in the main " "program, create an OptionParser instance::" msgstr "" -#: ../../library/optparse.rst:364 +#: ../../library/optparse.rst:361 msgid "" "from optparse import OptionParser\n" "...\n" @@ -623,11 +623,11 @@ msgstr "" "...\n" "parser = OptionParser()" -#: ../../library/optparse.rst:368 +#: ../../library/optparse.rst:365 msgid "Then you can start defining options. The basic syntax is::" msgstr "" -#: ../../library/optparse.rst:370 +#: ../../library/optparse.rst:367 msgid "" "parser.add_option(opt_str, ...,\n" " attr=value, ...)" @@ -635,31 +635,31 @@ msgstr "" "parser.add_option(opt_str, ...,\n" " attr=value, ...)" -#: ../../library/optparse.rst:373 +#: ../../library/optparse.rst:370 msgid "" "Each option has one or more option strings, such as ``-f`` or ``--file``, " "and several option attributes that tell :mod:`!optparse` what to expect and " "what to do when it encounters that option on the command line." msgstr "" -#: ../../library/optparse.rst:377 +#: ../../library/optparse.rst:374 msgid "" "Typically, each option will have one short option string and one long option " "string, e.g.::" msgstr "" -#: ../../library/optparse.rst:380 +#: ../../library/optparse.rst:377 msgid "parser.add_option(\"-f\", \"--file\", ...)" msgstr "parser.add_option(\"-f\", \"--file\", ...)" -#: ../../library/optparse.rst:382 +#: ../../library/optparse.rst:379 msgid "" "You're free to define as many short option strings and as many long option " "strings as you like (including zero), as long as there is at least one " "option string overall." msgstr "" -#: ../../library/optparse.rst:386 +#: ../../library/optparse.rst:383 msgid "" "The option strings passed to :meth:`OptionParser.add_option` are effectively " "labels for the option defined by that call. For brevity, we will frequently " @@ -667,28 +667,28 @@ msgid "" "optparse` encounters *option strings* and looks up options from them." msgstr "" -#: ../../library/optparse.rst:392 +#: ../../library/optparse.rst:389 msgid "" "Once all of your options are defined, instruct :mod:`!optparse` to parse " "your program's command line::" msgstr "" -#: ../../library/optparse.rst:395 +#: ../../library/optparse.rst:392 msgid "(options, args) = parser.parse_args()" msgstr "(options, args) = parser.parse_args()" -#: ../../library/optparse.rst:397 +#: ../../library/optparse.rst:394 msgid "" "(If you like, you can pass a custom argument list to :meth:`~OptionParser." "parse_args`, but that's rarely necessary: by default it uses ``sys." "argv[1:]``.)" msgstr "" -#: ../../library/optparse.rst:400 +#: ../../library/optparse.rst:397 msgid ":meth:`~OptionParser.parse_args` returns two values:" msgstr ":meth:`~OptionParser.parse_args` 回傳兩個值:" -#: ../../library/optparse.rst:402 +#: ../../library/optparse.rst:399 msgid "" "``options``, an object containing values for all of your options---e.g. if " "``--file`` takes a single string argument, then ``options.file`` will be the " @@ -696,12 +696,12 @@ msgid "" "option" msgstr "" -#: ../../library/optparse.rst:407 +#: ../../library/optparse.rst:404 msgid "" "``args``, the list of positional arguments leftover after parsing options" msgstr "" -#: ../../library/optparse.rst:409 +#: ../../library/optparse.rst:406 msgid "" "This tutorial section only covers the four most important option " "attributes: :attr:`~Option.action`, :attr:`~Option.type`, :attr:`~Option." @@ -709,11 +709,11 @@ msgid "" "action` is the most fundamental." msgstr "" -#: ../../library/optparse.rst:418 +#: ../../library/optparse.rst:415 msgid "Understanding option actions" msgstr "" -#: ../../library/optparse.rst:420 +#: ../../library/optparse.rst:417 msgid "" "Actions tell :mod:`!optparse` what to do when it encounters an option on the " "command line. There is a fixed set of actions hard-coded into :mod:`!" @@ -723,28 +723,28 @@ msgid "" "and store it in an attribute of ``options``." msgstr "" -#: ../../library/optparse.rst:427 +#: ../../library/optparse.rst:424 msgid "" "If you don't specify an option action, :mod:`!optparse` defaults to " "``store``." msgstr "" -#: ../../library/optparse.rst:433 +#: ../../library/optparse.rst:430 msgid "The store action" msgstr "" -#: ../../library/optparse.rst:435 +#: ../../library/optparse.rst:432 msgid "" "The most common option action is ``store``, which tells :mod:`!optparse` to " "take the next argument (or the remainder of the current argument), ensure " "that it is of the correct type, and store it to your chosen destination." msgstr "" -#: ../../library/optparse.rst:439 +#: ../../library/optparse.rst:436 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/optparse.rst:441 +#: ../../library/optparse.rst:438 msgid "" "parser.add_option(\"-f\", \"--file\",\n" " action=\"store\", type=\"string\", dest=\"filename\")" @@ -752,12 +752,12 @@ msgstr "" "parser.add_option(\"-f\", \"--file\",\n" " action=\"store\", type=\"string\", dest=\"filename\")" -#: ../../library/optparse.rst:444 +#: ../../library/optparse.rst:441 msgid "" "Now let's make up a fake command line and ask :mod:`!optparse` to parse it::" msgstr "" -#: ../../library/optparse.rst:446 +#: ../../library/optparse.rst:443 msgid "" "args = [\"-f\", \"foo.txt\"]\n" "(options, args) = parser.parse_args(args)" @@ -765,7 +765,7 @@ msgstr "" "args = [\"-f\", \"foo.txt\"]\n" "(options, args) = parser.parse_args(args)" -#: ../../library/optparse.rst:449 +#: ../../library/optparse.rst:446 msgid "" "When :mod:`!optparse` sees the option string ``-f``, it consumes the next " "argument, ``foo.txt``, and stores it in ``options.filename``. So, after " @@ -773,30 +773,30 @@ msgid "" "``\"foo.txt\"``." msgstr "" -#: ../../library/optparse.rst:453 +#: ../../library/optparse.rst:450 msgid "" "Some other option types supported by :mod:`!optparse` are ``int`` and " "``float``. Here's an option that expects an integer argument::" msgstr "" -#: ../../library/optparse.rst:456 +#: ../../library/optparse.rst:453 msgid "parser.add_option(\"-n\", type=\"int\", dest=\"num\")" msgstr "parser.add_option(\"-n\", type=\"int\", dest=\"num\")" -#: ../../library/optparse.rst:458 +#: ../../library/optparse.rst:455 msgid "" "Note that this option has no long option string, which is perfectly " "acceptable. Also, there's no explicit action, since the default is ``store``." msgstr "" -#: ../../library/optparse.rst:461 +#: ../../library/optparse.rst:458 msgid "" "Let's parse another fake command-line. This time, we'll jam the option " "argument right up against the option: since ``-n42`` (one argument) is " "equivalent to ``-n 42`` (two arguments), the code ::" msgstr "" -#: ../../library/optparse.rst:465 +#: ../../library/optparse.rst:462 msgid "" "(options, args) = parser.parse_args([\"-n42\"])\n" "print(options.num)" @@ -804,22 +804,22 @@ msgstr "" "(options, args) = parser.parse_args([\"-n42\"])\n" "print(options.num)" -#: ../../library/optparse.rst:468 +#: ../../library/optparse.rst:465 msgid "will print ``42``." msgstr "會印出 ``42``。" -#: ../../library/optparse.rst:470 +#: ../../library/optparse.rst:467 msgid "" "If you don't specify a type, :mod:`!optparse` assumes ``string``. Combined " "with the fact that the default action is ``store``, that means our first " "example can be a lot shorter::" msgstr "" -#: ../../library/optparse.rst:474 +#: ../../library/optparse.rst:471 msgid "parser.add_option(\"-f\", \"--file\", dest=\"filename\")" msgstr "parser.add_option(\"-f\", \"--file\", dest=\"filename\")" -#: ../../library/optparse.rst:476 +#: ../../library/optparse.rst:473 msgid "" "If you don't supply a destination, :mod:`!optparse` figures out a sensible " "default from the option strings: if the first long option string is ``--foo-" @@ -828,17 +828,17 @@ msgid "" "default destination for ``-f`` is ``f``." msgstr "" -#: ../../library/optparse.rst:482 +#: ../../library/optparse.rst:479 msgid "" ":mod:`!optparse` also includes the built-in ``complex`` type. Adding types " "is covered in section :ref:`optparse-extending-optparse`." msgstr "" -#: ../../library/optparse.rst:489 +#: ../../library/optparse.rst:486 msgid "Handling boolean (flag) options" msgstr "" -#: ../../library/optparse.rst:491 +#: ../../library/optparse.rst:488 msgid "" "Flag options---set a variable to true or false when a particular option is " "seen---are quite common. :mod:`!optparse` supports them with two separate " @@ -846,7 +846,7 @@ msgid "" "``verbose`` flag that is turned on with ``-v`` and off with ``-q``::" msgstr "" -#: ../../library/optparse.rst:496 +#: ../../library/optparse.rst:493 msgid "" "parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\")\n" "parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\")" @@ -854,71 +854,71 @@ msgstr "" "parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\")\n" "parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\")" -#: ../../library/optparse.rst:499 +#: ../../library/optparse.rst:496 msgid "" "Here we have two different options with the same destination, which is " "perfectly OK. (It just means you have to be a bit careful when setting " "default values---see below.)" msgstr "" -#: ../../library/optparse.rst:503 +#: ../../library/optparse.rst:500 msgid "" "When :mod:`!optparse` encounters ``-v`` on the command line, it sets " "``options.verbose`` to ``True``; when it encounters ``-q``, ``options." "verbose`` is set to ``False``." msgstr "" -#: ../../library/optparse.rst:511 +#: ../../library/optparse.rst:508 msgid "Other actions" msgstr "" -#: ../../library/optparse.rst:513 +#: ../../library/optparse.rst:510 msgid "Some other actions supported by :mod:`!optparse` are:" msgstr "" -#: ../../library/optparse.rst:515 ../../library/optparse.rst:1037 +#: ../../library/optparse.rst:512 ../../library/optparse.rst:1034 msgid "``\"store_const\"``" msgstr "``\"store_const\"``" -#: ../../library/optparse.rst:516 ../../library/optparse.rst:1038 +#: ../../library/optparse.rst:513 ../../library/optparse.rst:1035 msgid "store a constant value, pre-set via :attr:`Option.const`" msgstr "" -#: ../../library/optparse.rst:518 ../../library/optparse.rst:1046 +#: ../../library/optparse.rst:515 ../../library/optparse.rst:1043 msgid "``\"append\"``" msgstr "``\"append\"``" -#: ../../library/optparse.rst:519 ../../library/optparse.rst:1047 +#: ../../library/optparse.rst:516 ../../library/optparse.rst:1044 msgid "append this option's argument to a list" msgstr "" -#: ../../library/optparse.rst:521 ../../library/optparse.rst:1052 +#: ../../library/optparse.rst:518 ../../library/optparse.rst:1049 msgid "``\"count\"``" msgstr "``\"count\"``" -#: ../../library/optparse.rst:522 ../../library/optparse.rst:1053 +#: ../../library/optparse.rst:519 ../../library/optparse.rst:1050 msgid "increment a counter by one" msgstr "" -#: ../../library/optparse.rst:524 ../../library/optparse.rst:1055 +#: ../../library/optparse.rst:521 ../../library/optparse.rst:1052 msgid "``\"callback\"``" msgstr "``\"callback\"``" -#: ../../library/optparse.rst:525 ../../library/optparse.rst:1056 +#: ../../library/optparse.rst:522 ../../library/optparse.rst:1053 msgid "call a specified function" msgstr "" -#: ../../library/optparse.rst:527 +#: ../../library/optparse.rst:524 msgid "" "These are covered in section :ref:`optparse-reference-guide`, and section :" "ref:`optparse-option-callbacks`." msgstr "" -#: ../../library/optparse.rst:534 +#: ../../library/optparse.rst:531 msgid "Default values" msgstr "預設值" -#: ../../library/optparse.rst:536 +#: ../../library/optparse.rst:533 msgid "" "All of the above examples involve setting some variable (the " "\"destination\") when certain command-line options are seen. What happens " @@ -928,13 +928,13 @@ msgid "" "destination, which is assigned before the command line is parsed." msgstr "" -#: ../../library/optparse.rst:543 +#: ../../library/optparse.rst:540 msgid "" "First, consider the verbose/quiet example. If we want :mod:`!optparse` to " "set ``verbose`` to ``True`` unless ``-q`` is seen, then we can do this::" msgstr "" -#: ../../library/optparse.rst:546 +#: ../../library/optparse.rst:543 msgid "" "parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\", " "default=True)\n" @@ -944,25 +944,25 @@ msgstr "" "default=True)\n" "parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\")" -#: ../../library/optparse.rst:549 +#: ../../library/optparse.rst:546 msgid "" "Since default values apply to the *destination* rather than to any " "particular option, and these two options happen to have the same " "destination, this is exactly equivalent::" msgstr "" -#: ../../library/optparse.rst:553 +#: ../../library/optparse.rst:550 msgid "" "parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\")\n" "parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\", " "default=True)" msgstr "" -#: ../../library/optparse.rst:556 +#: ../../library/optparse.rst:553 msgid "Consider this::" msgstr "" -#: ../../library/optparse.rst:558 +#: ../../library/optparse.rst:555 msgid "" "parser.add_option(\"-v\", action=\"store_true\", dest=\"verbose\", " "default=False)\n" @@ -974,20 +974,20 @@ msgstr "" "parser.add_option(\"-q\", action=\"store_false\", dest=\"verbose\", " "default=True)" -#: ../../library/optparse.rst:561 +#: ../../library/optparse.rst:558 msgid "" "Again, the default value for ``verbose`` will be ``True``: the last default " "value supplied for any particular destination is the one that counts." msgstr "" -#: ../../library/optparse.rst:564 +#: ../../library/optparse.rst:561 msgid "" "A clearer way to specify default values is the :meth:`set_defaults` method " "of OptionParser, which you can call at any time before calling :meth:" "`~OptionParser.parse_args`::" msgstr "" -#: ../../library/optparse.rst:568 +#: ../../library/optparse.rst:565 msgid "" "parser.set_defaults(verbose=True)\n" "parser.add_option(...)\n" @@ -997,18 +997,18 @@ msgstr "" "parser.add_option(...)\n" "(options, args) = parser.parse_args()" -#: ../../library/optparse.rst:572 +#: ../../library/optparse.rst:569 msgid "" "As before, the last value specified for a given option destination is the " "one that counts. For clarity, try to use one method or the other of setting " "default values, not both." msgstr "" -#: ../../library/optparse.rst:580 +#: ../../library/optparse.rst:577 msgid "Generating help" msgstr "" -#: ../../library/optparse.rst:582 +#: ../../library/optparse.rst:579 msgid "" ":mod:`!optparse`'s ability to generate help and usage text automatically is " "useful for creating user-friendly command-line interfaces. All you have to " @@ -1017,7 +1017,7 @@ msgid "" "populated with user-friendly (documented) options::" msgstr "" -#: ../../library/optparse.rst:588 +#: ../../library/optparse.rst:585 msgid "" "usage = \"usage: %prog [options] arg1 arg2\"\n" "parser = OptionParser(usage=usage)\n" @@ -1049,14 +1049,14 @@ msgstr "" " help=\"interaction mode: novice, intermediate, \"\n" " \"or expert [default: %default]\")" -#: ../../library/optparse.rst:603 +#: ../../library/optparse.rst:600 msgid "" "If :mod:`!optparse` encounters either ``-h`` or ``--help`` on the command-" "line, or if you just call :meth:`parser.print_help`, it prints the following " "to standard output:" msgstr "" -#: ../../library/optparse.rst:607 +#: ../../library/optparse.rst:604 msgid "" "Usage: [options] arg1 arg2\n" "\n" @@ -1080,58 +1080,58 @@ msgstr "" " -m MODE, --mode=MODE interaction mode: novice, intermediate, or\n" " expert [default: intermediate]" -#: ../../library/optparse.rst:620 +#: ../../library/optparse.rst:617 msgid "" "(If the help output is triggered by a help option, :mod:`!optparse` exits " "after printing the help text.)" msgstr "" -#: ../../library/optparse.rst:623 +#: ../../library/optparse.rst:620 msgid "" "There's a lot going on here to help :mod:`!optparse` generate the best " "possible help message:" msgstr "" -#: ../../library/optparse.rst:626 +#: ../../library/optparse.rst:623 msgid "the script defines its own usage message::" msgstr "" -#: ../../library/optparse.rst:628 +#: ../../library/optparse.rst:625 msgid "usage = \"usage: %prog [options] arg1 arg2\"" msgstr "usage = \"usage: %prog [options] arg1 arg2\"" -#: ../../library/optparse.rst:630 +#: ../../library/optparse.rst:627 msgid "" ":mod:`!optparse` expands ``%prog`` in the usage string to the name of the " "current program, i.e. ``os.path.basename(sys.argv[0])``. The expanded " "string is then printed before the detailed option help." msgstr "" -#: ../../library/optparse.rst:634 +#: ../../library/optparse.rst:631 msgid "" "If you don't supply a usage string, :mod:`!optparse` uses a bland but " "sensible default: ``\"Usage: %prog [options]\"``, which is fine if your " "script doesn't take any positional arguments." msgstr "" -#: ../../library/optparse.rst:638 +#: ../../library/optparse.rst:635 msgid "" "every option defines a help string, and doesn't worry about line-wrapping---" "\\ :mod:`!optparse` takes care of wrapping lines and making the help output " "look good." msgstr "" -#: ../../library/optparse.rst:642 +#: ../../library/optparse.rst:639 msgid "" "options that take a value indicate this fact in their automatically " "generated help message, e.g. for the \"mode\" option::" msgstr "" -#: ../../library/optparse.rst:645 +#: ../../library/optparse.rst:642 msgid "-m MODE, --mode=MODE" msgstr "-m MODE, --mode=MODE" -#: ../../library/optparse.rst:647 +#: ../../library/optparse.rst:644 msgid "" "Here, \"MODE\" is called the meta-variable: it stands for the argument that " "the user is expected to supply to ``-m``/``--mode``. By default, :mod:`!" @@ -1141,11 +1141,11 @@ msgid "" "this automatically generated option description::" msgstr "" -#: ../../library/optparse.rst:654 +#: ../../library/optparse.rst:651 msgid "-f FILE, --filename=FILE" msgstr "-f FILE, --filename=FILE" -#: ../../library/optparse.rst:656 +#: ../../library/optparse.rst:653 msgid "" "This is important for more than just saving space, though: the manually " "written help text uses the meta-variable ``FILE`` to clue the user in that " @@ -1155,7 +1155,7 @@ msgid "" "users." msgstr "" -#: ../../library/optparse.rst:662 +#: ../../library/optparse.rst:659 msgid "" "options that have a default value can include ``%default`` in the help " "string---\\ :mod:`!optparse` will replace it with :func:`str` of the " @@ -1163,58 +1163,58 @@ msgid "" "value is ``None``), ``%default`` expands to ``none``." msgstr "" -#: ../../library/optparse.rst:668 +#: ../../library/optparse.rst:665 msgid "Grouping Options" msgstr "" -#: ../../library/optparse.rst:670 +#: ../../library/optparse.rst:667 msgid "" "When dealing with many options, it is convenient to group these options for " "better help output. An :class:`OptionParser` can contain several option " "groups, each of which can contain several options." msgstr "" -#: ../../library/optparse.rst:674 +#: ../../library/optparse.rst:671 msgid "An option group is obtained using the class :class:`OptionGroup`:" msgstr "" -#: ../../library/optparse.rst:678 ../../library/optparse.rst:1749 +#: ../../library/optparse.rst:675 ../../library/optparse.rst:1746 msgid "where" msgstr "" -#: ../../library/optparse.rst:680 +#: ../../library/optparse.rst:677 msgid "" "parser is the :class:`OptionParser` instance the group will be inserted in to" msgstr "" -#: ../../library/optparse.rst:682 +#: ../../library/optparse.rst:679 msgid "title is the group title" msgstr "" -#: ../../library/optparse.rst:683 +#: ../../library/optparse.rst:680 msgid "description, optional, is a long description of the group" msgstr "" -#: ../../library/optparse.rst:685 +#: ../../library/optparse.rst:682 msgid "" ":class:`OptionGroup` inherits from :class:`OptionContainer` (like :class:" "`OptionParser`) and so the :meth:`add_option` method can be used to add an " "option to the group." msgstr "" -#: ../../library/optparse.rst:689 +#: ../../library/optparse.rst:686 msgid "" "Once all the options are declared, using the :class:`OptionParser` method :" "meth:`add_option_group` the group is added to the previously defined parser." msgstr "" -#: ../../library/optparse.rst:692 +#: ../../library/optparse.rst:689 msgid "" "Continuing with the parser defined in the previous section, adding an :class:" "`OptionGroup` to a parser is easy::" msgstr "" -#: ../../library/optparse.rst:695 +#: ../../library/optparse.rst:692 msgid "" "group = OptionGroup(parser, \"Dangerous Options\",\n" " \"Caution: use these options at your own risk. \"\n" @@ -1228,11 +1228,11 @@ msgstr "" "group.add_option(\"-g\", action=\"store_true\", help=\"Group option.\")\n" "parser.add_option_group(group)" -#: ../../library/optparse.rst:701 +#: ../../library/optparse.rst:698 msgid "This would result in the following help output:" msgstr "" -#: ../../library/optparse.rst:703 +#: ../../library/optparse.rst:700 msgid "" "Usage: [options] arg1 arg2\n" "\n" @@ -1268,13 +1268,13 @@ msgstr "" "\n" " -g Group option." -#: ../../library/optparse.rst:722 +#: ../../library/optparse.rst:719 msgid "" "A bit more complete example might involve using more than one group: still " "extending the previous example::" msgstr "" -#: ../../library/optparse.rst:725 +#: ../../library/optparse.rst:722 msgid "" "group = OptionGroup(parser, \"Dangerous Options\",\n" " \"Caution: use these options at your own risk. \"\n" @@ -1306,11 +1306,11 @@ msgstr "" "done\")\n" "parser.add_option_group(group)" -#: ../../library/optparse.rst:739 +#: ../../library/optparse.rst:736 msgid "that results in the following output:" msgstr "" -#: ../../library/optparse.rst:741 +#: ../../library/optparse.rst:738 msgid "" "Usage: [options] arg1 arg2\n" "\n" @@ -1356,36 +1356,36 @@ msgstr "" " -s, --sql Print all SQL statements executed\n" " -e Print every action done" -#: ../../library/optparse.rst:765 +#: ../../library/optparse.rst:762 msgid "" "Another interesting method, in particular when working programmatically with " "option groups is:" msgstr "" -#: ../../library/optparse.rst:770 +#: ../../library/optparse.rst:767 msgid "" "Return the :class:`OptionGroup` to which the short or long option string " "*opt_str* (e.g. ``'-o'`` or ``'--option'``) belongs. If there's no such :" "class:`OptionGroup`, return ``None``." msgstr "" -#: ../../library/optparse.rst:777 +#: ../../library/optparse.rst:774 msgid "Printing a version string" msgstr "" -#: ../../library/optparse.rst:779 +#: ../../library/optparse.rst:776 msgid "" "Similar to the brief usage string, :mod:`!optparse` can also print a version " "string for your program. You have to supply the string as the ``version`` " "argument to OptionParser::" msgstr "" -#: ../../library/optparse.rst:783 +#: ../../library/optparse.rst:780 msgid "parser = OptionParser(usage=\"%prog [-f] [-q]\", version=\"%prog 1.0\")" msgstr "" "parser = OptionParser(usage=\"%prog [-f] [-q]\", version=\"%prog 1.0\")" -#: ../../library/optparse.rst:785 +#: ../../library/optparse.rst:782 msgid "" "``%prog`` is expanded just like it is in ``usage``. Apart from that, " "``version`` can contain anything you like. When you supply it, :mod:`!" @@ -1394,11 +1394,11 @@ msgid "" "string (by replacing ``%prog``), prints it to stdout, and exits." msgstr "" -#: ../../library/optparse.rst:791 +#: ../../library/optparse.rst:788 msgid "For example, if your script is called ``/usr/bin/foo``:" msgstr "" -#: ../../library/optparse.rst:793 +#: ../../library/optparse.rst:790 msgid "" "$ /usr/bin/foo --version\n" "foo 1.0" @@ -1406,13 +1406,13 @@ msgstr "" "$ /usr/bin/foo --version\n" "foo 1.0" -#: ../../library/optparse.rst:798 +#: ../../library/optparse.rst:795 msgid "" "The following two methods can be used to print and get the ``version`` " "string:" msgstr "" -#: ../../library/optparse.rst:802 +#: ../../library/optparse.rst:799 msgid "" "Print the version message for the current program (``self.version``) to " "*file* (default stdout). As with :meth:`print_usage`, any occurrence of " @@ -1420,17 +1420,17 @@ msgid "" "program. Does nothing if ``self.version`` is empty or undefined." msgstr "" -#: ../../library/optparse.rst:809 +#: ../../library/optparse.rst:806 msgid "" "Same as :meth:`print_version` but returns the version string instead of " "printing it." msgstr "" -#: ../../library/optparse.rst:816 +#: ../../library/optparse.rst:813 msgid "How :mod:`!optparse` handles errors" msgstr ":mod:`!optparse` 將會設定: ::" -#: ../../library/optparse.rst:818 +#: ../../library/optparse.rst:815 msgid "" "There are two broad classes of errors that :mod:`!optparse` has to worry " "about: programmer errors and user errors. Programmer errors are usually " @@ -1440,7 +1440,7 @@ msgid "" "OptionError` or :exc:`TypeError`) and let the program crash." msgstr "" -#: ../../library/optparse.rst:825 +#: ../../library/optparse.rst:822 msgid "" "Handling user errors is much more important, since they are guaranteed to " "happen no matter how stable your code is. :mod:`!optparse` can " @@ -1451,7 +1451,7 @@ msgid "" "application-defined error condition::" msgstr "" -#: ../../library/optparse.rst:833 +#: ../../library/optparse.rst:830 msgid "" "(options, args) = parser.parse_args()\n" "...\n" @@ -1463,20 +1463,20 @@ msgstr "" "if options.a and options.b:\n" " parser.error(\"options -a and -b are mutually exclusive\")" -#: ../../library/optparse.rst:838 +#: ../../library/optparse.rst:835 msgid "" "In either case, :mod:`!optparse` handles the error the same way: it prints " "the program's usage message and an error message to standard error and exits " "with error status 2." msgstr "" -#: ../../library/optparse.rst:842 +#: ../../library/optparse.rst:839 msgid "" "Consider the first example above, where the user passes ``4x`` to an option " "that takes an integer:" msgstr "" -#: ../../library/optparse.rst:845 +#: ../../library/optparse.rst:842 msgid "" "$ /usr/bin/foo -n 4x\n" "Usage: foo [options]\n" @@ -1488,11 +1488,11 @@ msgstr "" "\n" "foo: error: option -n: invalid integer value: '4x'" -#: ../../library/optparse.rst:852 +#: ../../library/optparse.rst:849 msgid "Or, where the user fails to pass a value at all:" msgstr "" -#: ../../library/optparse.rst:854 +#: ../../library/optparse.rst:851 msgid "" "$ /usr/bin/foo -n\n" "Usage: foo [options]\n" @@ -1504,29 +1504,29 @@ msgstr "" "\n" "foo: error: -n option requires an argument" -#: ../../library/optparse.rst:861 +#: ../../library/optparse.rst:858 msgid "" ":mod:`!optparse`\\ -generated error messages take care always to mention the " "option involved in the error; be sure to do the same when calling :func:" "`OptionParser.error` from your application code." msgstr "" -#: ../../library/optparse.rst:865 +#: ../../library/optparse.rst:862 msgid "" "If :mod:`!optparse`'s default error-handling behaviour does not suit your " "needs, you'll need to subclass OptionParser and override its :meth:" "`~OptionParser.exit` and/or :meth:`~OptionParser.error` methods." msgstr "" -#: ../../library/optparse.rst:873 +#: ../../library/optparse.rst:870 msgid "Putting it all together" msgstr "" -#: ../../library/optparse.rst:875 +#: ../../library/optparse.rst:872 msgid "Here's what :mod:`!optparse`\\ -based scripts usually look like::" msgstr "" -#: ../../library/optparse.rst:877 +#: ../../library/optparse.rst:874 msgid "" "from optparse import OptionParser\n" "...\n" @@ -1572,32 +1572,32 @@ msgstr "" "if __name__ == \"__main__\":\n" " main()" -#: ../../library/optparse.rst:903 +#: ../../library/optparse.rst:900 msgid "Reference Guide" msgstr "" -#: ../../library/optparse.rst:909 +#: ../../library/optparse.rst:906 msgid "Creating the parser" msgstr "建立剖析器" -#: ../../library/optparse.rst:911 +#: ../../library/optparse.rst:908 msgid "" "The first step in using :mod:`!optparse` is to create an OptionParser " "instance." msgstr "" -#: ../../library/optparse.rst:915 +#: ../../library/optparse.rst:912 msgid "" "The OptionParser constructor has no required arguments, but a number of " "optional keyword arguments. You should always pass them as keyword " "arguments, i.e. do not rely on the order in which the arguments are declared." msgstr "" -#: ../../library/optparse.rst:919 +#: ../../library/optparse.rst:916 msgid "``usage`` (default: ``\"%prog [options]\"``)" msgstr "``usage``\\ (預設值:``\"%prog [options]\"``)" -#: ../../library/optparse.rst:920 +#: ../../library/optparse.rst:917 msgid "" "The usage summary to print when your program is run incorrectly or with a " "help option. When :mod:`!optparse` prints the usage string, it expands " @@ -1606,11 +1606,11 @@ msgid "" "value :const:`optparse.SUPPRESS_USAGE`." msgstr "" -#: ../../library/optparse.rst:926 +#: ../../library/optparse.rst:923 msgid "``option_list`` (default: ``[]``)" msgstr "``option_list``\\ (預設值:``[]``)" -#: ../../library/optparse.rst:927 +#: ../../library/optparse.rst:924 msgid "" "A list of Option objects to populate the parser with. The options in " "``option_list`` are added after any options in ``standard_option_list`` (a " @@ -1619,19 +1619,19 @@ msgid "" "the parser instead." msgstr "" -#: ../../library/optparse.rst:933 +#: ../../library/optparse.rst:930 msgid "``option_class`` (default: optparse.Option)" msgstr "``option_class``\\ (預設值:optparse.Option)" -#: ../../library/optparse.rst:934 +#: ../../library/optparse.rst:931 msgid "Class to use when adding options to the parser in :meth:`add_option`." msgstr "在 :meth:`add_option` 中新增選項時要使用的類別。" -#: ../../library/optparse.rst:936 +#: ../../library/optparse.rst:933 msgid "``version`` (default: ``None``)" msgstr "``version``\\ (預設值:``None``)" -#: ../../library/optparse.rst:937 +#: ../../library/optparse.rst:934 msgid "" "A version string to print when the user supplies a version option. If you " "supply a true value for ``version``, :mod:`!optparse` automatically adds a " @@ -1639,21 +1639,21 @@ msgid "" "``%prog`` is expanded the same as for ``usage``." msgstr "" -#: ../../library/optparse.rst:942 +#: ../../library/optparse.rst:939 msgid "``conflict_handler`` (default: ``\"error\"``)" msgstr "``conflict_handler``\\ (預設值:``\"error\"``)" -#: ../../library/optparse.rst:943 +#: ../../library/optparse.rst:940 msgid "" "Specifies what to do when options with conflicting option strings are added " "to the parser; see section :ref:`optparse-conflicts-between-options`." msgstr "" -#: ../../library/optparse.rst:947 +#: ../../library/optparse.rst:944 msgid "``description`` (default: ``None``)" msgstr "``description``\\ (預設值:``None``)" -#: ../../library/optparse.rst:948 +#: ../../library/optparse.rst:945 msgid "" "A paragraph of text giving a brief overview of your program. :mod:`!" "optparse` reformats this paragraph to fit the current terminal width and " @@ -1661,74 +1661,74 @@ msgid "" "of options)." msgstr "" -#: ../../library/optparse.rst:953 +#: ../../library/optparse.rst:950 msgid "``formatter`` (default: a new :class:`IndentedHelpFormatter`)" msgstr "" -#: ../../library/optparse.rst:954 +#: ../../library/optparse.rst:951 msgid "" "An instance of optparse.HelpFormatter that will be used for printing help " "text. :mod:`!optparse` provides two concrete classes for this purpose: " "IndentedHelpFormatter and TitledHelpFormatter." msgstr "" -#: ../../library/optparse.rst:958 +#: ../../library/optparse.rst:955 msgid "``add_help_option`` (default: ``True``)" msgstr "``add_help_option``\\ (預設值:``True``)" -#: ../../library/optparse.rst:959 +#: ../../library/optparse.rst:956 msgid "" "If true, :mod:`!optparse` will add a help option (with option strings ``-h`` " "and ``--help``) to the parser." msgstr "" -#: ../../library/optparse.rst:962 +#: ../../library/optparse.rst:959 msgid "``prog``" msgstr "``prog``" -#: ../../library/optparse.rst:963 +#: ../../library/optparse.rst:960 msgid "" "The string to use when expanding ``%prog`` in ``usage`` and ``version`` " "instead of ``os.path.basename(sys.argv[0])``." msgstr "" -#: ../../library/optparse.rst:966 +#: ../../library/optparse.rst:963 msgid "``epilog`` (default: ``None``)" msgstr "``epilog``\\ (預設值:``None``)" -#: ../../library/optparse.rst:967 +#: ../../library/optparse.rst:964 msgid "A paragraph of help text to print after the option help." msgstr "" -#: ../../library/optparse.rst:972 +#: ../../library/optparse.rst:969 msgid "Populating the parser" msgstr "" -#: ../../library/optparse.rst:974 +#: ../../library/optparse.rst:971 msgid "" "There are several ways to populate the parser with options. The preferred " "way is by using :meth:`OptionParser.add_option`, as shown in section :ref:" "`optparse-tutorial`. :meth:`add_option` can be called in one of two ways:" msgstr "" -#: ../../library/optparse.rst:978 +#: ../../library/optparse.rst:975 msgid "pass it an Option instance (as returned by :func:`make_option`)" msgstr "" -#: ../../library/optparse.rst:980 +#: ../../library/optparse.rst:977 msgid "" "pass it any combination of positional and keyword arguments that are " "acceptable to :func:`make_option` (i.e., to the Option constructor), and it " "will create the Option instance for you" msgstr "" -#: ../../library/optparse.rst:984 +#: ../../library/optparse.rst:981 msgid "" "The other alternative is to pass a list of pre-constructed Option instances " "to the OptionParser constructor, as in::" msgstr "" -#: ../../library/optparse.rst:987 +#: ../../library/optparse.rst:984 msgid "" "option_list = [\n" " make_option(\"-f\", \"--filename\",\n" @@ -1746,7 +1746,7 @@ msgstr "" " ]\n" "parser = OptionParser(option_list=option_list)" -#: ../../library/optparse.rst:995 +#: ../../library/optparse.rst:992 msgid "" "(:func:`make_option` is a factory function for creating Option instances; " "currently it is an alias for the Option constructor. A future version of :" @@ -1755,40 +1755,40 @@ msgid "" "Option directly.)" msgstr "" -#: ../../library/optparse.rst:1004 +#: ../../library/optparse.rst:1001 msgid "Defining options" msgstr "定義選項" -#: ../../library/optparse.rst:1006 +#: ../../library/optparse.rst:1003 msgid "" "Each Option instance represents a set of synonymous command-line option " "strings, e.g. ``-f`` and ``--file``. You can specify any number of short or " "long option strings, but you must specify at least one overall option string." msgstr "" -#: ../../library/optparse.rst:1010 +#: ../../library/optparse.rst:1007 msgid "" "The canonical way to create an :class:`Option` instance is with the :meth:" "`add_option` method of :class:`OptionParser`." msgstr "" -#: ../../library/optparse.rst:1016 +#: ../../library/optparse.rst:1013 msgid "To define an option with only a short option string::" msgstr "" -#: ../../library/optparse.rst:1018 +#: ../../library/optparse.rst:1015 msgid "parser.add_option(\"-f\", attr=value, ...)" msgstr "parser.add_option(\"-f\", attr=value, ...)" -#: ../../library/optparse.rst:1020 +#: ../../library/optparse.rst:1017 msgid "And to define an option with only a long option string::" msgstr "" -#: ../../library/optparse.rst:1022 +#: ../../library/optparse.rst:1019 msgid "parser.add_option(\"--foo\", attr=value, ...)" msgstr "parser.add_option(\"--foo\", attr=value, ...)" -#: ../../library/optparse.rst:1024 +#: ../../library/optparse.rst:1021 msgid "" "The keyword arguments define attributes of the new Option object. The most " "important option attribute is :attr:`~Option.action`, and it largely " @@ -1797,69 +1797,69 @@ msgid "" "optparse` raises an :exc:`OptionError` exception explaining your mistake." msgstr "" -#: ../../library/optparse.rst:1030 +#: ../../library/optparse.rst:1027 msgid "" "An option's *action* determines what :mod:`!optparse` does when it " "encounters this option on the command-line. The standard option actions " "hard-coded into :mod:`!optparse` are:" msgstr "" -#: ../../library/optparse.rst:1034 +#: ../../library/optparse.rst:1031 msgid "``\"store\"``" msgstr "``\"store\"``" -#: ../../library/optparse.rst:1035 +#: ../../library/optparse.rst:1032 msgid "store this option's argument (default)" msgstr "" -#: ../../library/optparse.rst:1040 +#: ../../library/optparse.rst:1037 msgid "``\"store_true\"``" msgstr "``\"store_true\"``" -#: ../../library/optparse.rst:1041 +#: ../../library/optparse.rst:1038 msgid "store ``True``" msgstr "" -#: ../../library/optparse.rst:1043 +#: ../../library/optparse.rst:1040 msgid "``\"store_false\"``" msgstr "``\"store_false\"``" -#: ../../library/optparse.rst:1044 +#: ../../library/optparse.rst:1041 msgid "store ``False``" msgstr "" -#: ../../library/optparse.rst:1049 +#: ../../library/optparse.rst:1046 msgid "``\"append_const\"``" msgstr "``\"append_const\"``" -#: ../../library/optparse.rst:1050 +#: ../../library/optparse.rst:1047 msgid "append a constant value to a list, pre-set via :attr:`Option.const`" msgstr "" -#: ../../library/optparse.rst:1058 ../../library/optparse.rst:1353 +#: ../../library/optparse.rst:1055 ../../library/optparse.rst:1350 msgid "``\"help\"``" msgstr "``\"help\"``" -#: ../../library/optparse.rst:1059 +#: ../../library/optparse.rst:1056 msgid "" "print a usage message including all options and the documentation for them" msgstr "" -#: ../../library/optparse.rst:1061 +#: ../../library/optparse.rst:1058 msgid "" "(If you don't supply an action, the default is ``\"store\"``. For this " "action, you may also supply :attr:`~Option.type` and :attr:`~Option.dest` " "option attributes; see :ref:`optparse-standard-option-actions`.)" msgstr "" -#: ../../library/optparse.rst:1065 +#: ../../library/optparse.rst:1062 msgid "" "As you can see, most actions involve storing or updating a value somewhere. :" "mod:`!optparse` always creates a special object for this, conventionally " "called ``options``, which is an instance of :class:`optparse.Values`." msgstr "" -#: ../../library/optparse.rst:1071 +#: ../../library/optparse.rst:1068 msgid "" "An object holding parsed argument names and values as attributes. Normally " "created by calling when calling :meth:`OptionParser.parse_args`, and can be " @@ -1868,35 +1868,35 @@ msgid "" "arguments`)." msgstr "" -#: ../../library/optparse.rst:1076 +#: ../../library/optparse.rst:1073 msgid "" "Option arguments (and various other values) are stored as attributes of this " "object, according to the :attr:`~Option.dest` (destination) option attribute." msgstr "" -#: ../../library/optparse.rst:1080 +#: ../../library/optparse.rst:1077 msgid "For example, when you call ::" msgstr "例如說,當你呼叫: ::" -#: ../../library/optparse.rst:1082 +#: ../../library/optparse.rst:1079 msgid "parser.parse_args()" msgstr "parser.parse_args()" -#: ../../library/optparse.rst:1084 +#: ../../library/optparse.rst:1081 msgid "" "one of the first things :mod:`!optparse` does is create the ``options`` " "object::" msgstr "" -#: ../../library/optparse.rst:1086 +#: ../../library/optparse.rst:1083 msgid "options = Values()" msgstr "options = Values()" -#: ../../library/optparse.rst:1088 +#: ../../library/optparse.rst:1085 msgid "If one of the options in this parser is defined with ::" msgstr "" -#: ../../library/optparse.rst:1090 +#: ../../library/optparse.rst:1087 msgid "" "parser.add_option(\"-f\", \"--file\", action=\"store\", type=\"string\", " "dest=\"filename\")" @@ -1904,11 +1904,11 @@ msgstr "" "parser.add_option(\"-f\", \"--file\", action=\"store\", type=\"string\", " "dest=\"filename\")" -#: ../../library/optparse.rst:1092 +#: ../../library/optparse.rst:1089 msgid "and the command-line being parsed includes any of the following::" msgstr "" -#: ../../library/optparse.rst:1094 +#: ../../library/optparse.rst:1091 msgid "" "-ffoo\n" "-f foo\n" @@ -1920,27 +1920,27 @@ msgstr "" "--file=foo\n" "--file foo" -#: ../../library/optparse.rst:1099 +#: ../../library/optparse.rst:1096 msgid "" "then :mod:`!optparse`, on seeing this option, will do the equivalent of ::" msgstr "" -#: ../../library/optparse.rst:1101 +#: ../../library/optparse.rst:1098 msgid "options.filename = \"foo\"" msgstr "options.filename = \"foo\"" -#: ../../library/optparse.rst:1103 +#: ../../library/optparse.rst:1100 msgid "" "The :attr:`~Option.type` and :attr:`~Option.dest` option attributes are " "almost as important as :attr:`~Option.action`, but :attr:`~Option.action` is " "the only one that makes sense for *all* options." msgstr "" -#: ../../library/optparse.rst:1111 +#: ../../library/optparse.rst:1108 msgid "Option attributes" msgstr "選項屬性" -#: ../../library/optparse.rst:1115 +#: ../../library/optparse.rst:1112 msgid "" "A single command line argument, with various attributes passed by keyword to " "the constructor. Normally created with :meth:`OptionParser.add_option` " @@ -1948,7 +1948,7 @@ msgid "" "*option_class* argument to :class:`OptionParser`." msgstr "" -#: ../../library/optparse.rst:1121 +#: ../../library/optparse.rst:1118 msgid "" "The following option attributes may be passed as keyword arguments to :meth:" "`OptionParser.add_option`. If you pass an option attribute that is not " @@ -1956,33 +1956,33 @@ msgid "" "attribute, :mod:`!optparse` raises :exc:`OptionError`." msgstr "" -#: ../../library/optparse.rst:1128 +#: ../../library/optparse.rst:1125 msgid "(default: ``\"store\"``)" msgstr "(預設值: ``\"store\"`` )" -#: ../../library/optparse.rst:1130 +#: ../../library/optparse.rst:1127 msgid "" "Determines :mod:`!optparse`'s behaviour when this option is seen on the " "command line; the available options are documented :ref:`here `." msgstr "" -#: ../../library/optparse.rst:1136 +#: ../../library/optparse.rst:1133 msgid "(default: ``\"string\"``)" msgstr "(預設值: ``\"string\"`` )" -#: ../../library/optparse.rst:1138 +#: ../../library/optparse.rst:1135 msgid "" "The argument type expected by this option (e.g., ``\"string\"`` or " "``\"int\"``); the available option types are documented :ref:`here `." msgstr "" -#: ../../library/optparse.rst:1144 ../../library/optparse.rst:1194 +#: ../../library/optparse.rst:1141 ../../library/optparse.rst:1191 msgid "(default: derived from option strings)" msgstr "" -#: ../../library/optparse.rst:1146 +#: ../../library/optparse.rst:1143 msgid "" "If the option's action implies writing or modifying a value somewhere, this " "tells :mod:`!optparse` where to write it: :attr:`~Option.dest` names an " @@ -1990,47 +1990,47 @@ msgid "" "parses the command line." msgstr "" -#: ../../library/optparse.rst:1153 +#: ../../library/optparse.rst:1150 msgid "" "The value to use for this option's destination if the option is not seen on " "the command line. See also :meth:`OptionParser.set_defaults`." msgstr "" -#: ../../library/optparse.rst:1158 +#: ../../library/optparse.rst:1155 msgid "(default: 1)" msgstr "(預設值:1)" -#: ../../library/optparse.rst:1160 +#: ../../library/optparse.rst:1157 msgid "" "How many arguments of type :attr:`~Option.type` should be consumed when this " "option is seen. If > 1, :mod:`!optparse` will store a tuple of values to :" "attr:`~Option.dest`." msgstr "" -#: ../../library/optparse.rst:1166 +#: ../../library/optparse.rst:1163 msgid "For actions that store a constant value, the constant value to store." msgstr "" -#: ../../library/optparse.rst:1170 +#: ../../library/optparse.rst:1167 msgid "" "For options of type ``\"choice\"``, the list of strings the user may choose " "from." msgstr "" -#: ../../library/optparse.rst:1175 +#: ../../library/optparse.rst:1172 msgid "" "For options with action ``\"callback\"``, the callable to call when this " "option is seen. See section :ref:`optparse-option-callbacks` for detail on " "the arguments passed to the callable." msgstr "" -#: ../../library/optparse.rst:1182 +#: ../../library/optparse.rst:1179 msgid "" "Additional positional and keyword arguments to pass to ``callback`` after " "the four standard callback arguments." msgstr "" -#: ../../library/optparse.rst:1187 +#: ../../library/optparse.rst:1184 msgid "" "Help text to print for this option when listing all available options after " "the user supplies a :attr:`~Option.help` option (such as ``--help``). If no " @@ -2038,17 +2038,17 @@ msgid "" "this option, use the special value :const:`optparse.SUPPRESS_HELP`." msgstr "" -#: ../../library/optparse.rst:1196 +#: ../../library/optparse.rst:1193 msgid "" "Stand-in for the option argument(s) to use when printing help text. See " "section :ref:`optparse-tutorial` for an example." msgstr "" -#: ../../library/optparse.rst:1203 +#: ../../library/optparse.rst:1200 msgid "Standard option actions" msgstr "標準選項動作" -#: ../../library/optparse.rst:1205 +#: ../../library/optparse.rst:1202 msgid "" "The various option actions all have slightly different requirements and " "effects. Most actions have several relevant option attributes which you may " @@ -2056,13 +2056,13 @@ msgid "" "attributes, which you must specify for any option using that action." msgstr "" -#: ../../library/optparse.rst:1210 +#: ../../library/optparse.rst:1207 msgid "" "``\"store\"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:" "`~Option.nargs`, :attr:`~Option.choices`]" msgstr "" -#: ../../library/optparse.rst:1213 +#: ../../library/optparse.rst:1210 msgid "" "The option must be followed by an argument, which is converted to a value " "according to :attr:`~Option.type` and stored in :attr:`~Option.dest`. If :" @@ -2072,17 +2072,17 @@ msgid "" "option-types` section." msgstr "" -#: ../../library/optparse.rst:1220 +#: ../../library/optparse.rst:1217 msgid "" "If :attr:`~Option.choices` is supplied (a list or tuple of strings), the " "type defaults to ``\"choice\"``." msgstr "" -#: ../../library/optparse.rst:1223 +#: ../../library/optparse.rst:1220 msgid "If :attr:`~Option.type` is not supplied, it defaults to ``\"string\"``." msgstr "如果沒有提供 :attr:`~Option.type`,它的預設值是 ``\"string\"``。" -#: ../../library/optparse.rst:1225 +#: ../../library/optparse.rst:1222 msgid "" "If :attr:`~Option.dest` is not supplied, :mod:`!optparse` derives a " "destination from the first long option string (e.g., ``--foo-bar`` implies " @@ -2091,13 +2091,13 @@ msgid "" "``f``)." msgstr "" -#: ../../library/optparse.rst:1230 ../../library/optparse.rst:1250 -#: ../../library/optparse.rst:1272 ../../library/optparse.rst:1290 -#: ../../library/optparse.rst:1329 ../../library/optparse.rst:1367 +#: ../../library/optparse.rst:1227 ../../library/optparse.rst:1247 +#: ../../library/optparse.rst:1269 ../../library/optparse.rst:1287 +#: ../../library/optparse.rst:1326 ../../library/optparse.rst:1364 msgid "Example::" msgstr "範例: ::" -#: ../../library/optparse.rst:1232 +#: ../../library/optparse.rst:1229 msgid "" "parser.add_option(\"-f\")\n" "parser.add_option(\"-p\", type=\"float\", nargs=3, dest=\"point\")" @@ -2105,19 +2105,19 @@ msgstr "" "parser.add_option(\"-f\")\n" "parser.add_option(\"-p\", type=\"float\", nargs=3, dest=\"point\")" -#: ../../library/optparse.rst:1235 +#: ../../library/optparse.rst:1232 msgid "As it parses the command line ::" msgstr "" -#: ../../library/optparse.rst:1237 +#: ../../library/optparse.rst:1234 msgid "-f foo.txt -p 1 -3.5 4 -fbar.txt" msgstr "-f foo.txt -p 1 -3.5 4 -fbar.txt" -#: ../../library/optparse.rst:1239 +#: ../../library/optparse.rst:1236 msgid ":mod:`!optparse` will set ::" msgstr ":mod:`!optparse` 將會設定: ::" -#: ../../library/optparse.rst:1241 +#: ../../library/optparse.rst:1238 msgid "" "options.f = \"foo.txt\"\n" "options.point = (1.0, -3.5, 4.0)\n" @@ -2127,17 +2127,17 @@ msgstr "" "options.point = (1.0, -3.5, 4.0)\n" "options.f = \"bar.txt\"" -#: ../../library/optparse.rst:1245 +#: ../../library/optparse.rst:1242 msgid "" "``\"store_const\"`` [required: :attr:`~Option.const`; relevant: :attr:" "`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1248 +#: ../../library/optparse.rst:1245 msgid "The value :attr:`~Option.const` is stored in :attr:`~Option.dest`." msgstr "" -#: ../../library/optparse.rst:1252 +#: ../../library/optparse.rst:1249 msgid "" "parser.add_option(\"-q\", \"--quiet\",\n" " action=\"store_const\", const=0, dest=\"verbose\")\n" @@ -2153,33 +2153,33 @@ msgstr "" "parser.add_option(\"--noisy\",\n" " action=\"store_const\", const=2, dest=\"verbose\")" -#: ../../library/optparse.rst:1259 +#: ../../library/optparse.rst:1256 msgid "If ``--noisy`` is seen, :mod:`!optparse` will set ::" msgstr "如果有看到 ``--noisy``,:mod:`!optparse` 將會被設定: ::" -#: ../../library/optparse.rst:1261 +#: ../../library/optparse.rst:1258 msgid "options.verbose = 2" msgstr "options.verbose = 2" -#: ../../library/optparse.rst:1263 +#: ../../library/optparse.rst:1260 msgid "``\"store_true\"`` [relevant: :attr:`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1265 +#: ../../library/optparse.rst:1262 msgid "" "A special case of ``\"store_const\"`` that stores ``True`` to :attr:`~Option." "dest`." msgstr "" -#: ../../library/optparse.rst:1268 +#: ../../library/optparse.rst:1265 msgid "``\"store_false\"`` [relevant: :attr:`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1270 +#: ../../library/optparse.rst:1267 msgid "Like ``\"store_true\"``, but stores ``False``." msgstr "" -#: ../../library/optparse.rst:1274 +#: ../../library/optparse.rst:1271 msgid "" "parser.add_option(\"--clobber\", action=\"store_true\", dest=\"clobber\")\n" "parser.add_option(\"--no-clobber\", action=\"store_false\", dest=\"clobber\")" @@ -2187,13 +2187,13 @@ msgstr "" "parser.add_option(\"--clobber\", action=\"store_true\", dest=\"clobber\")\n" "parser.add_option(\"--no-clobber\", action=\"store_false\", dest=\"clobber\")" -#: ../../library/optparse.rst:1277 +#: ../../library/optparse.rst:1274 msgid "" "``\"append\"`` [relevant: :attr:`~Option.type`, :attr:`~Option.dest`, :attr:" "`~Option.nargs`, :attr:`~Option.choices`]" msgstr "" -#: ../../library/optparse.rst:1280 +#: ../../library/optparse.rst:1277 msgid "" "The option must be followed by an argument, which is appended to the list " "in :attr:`~Option.dest`. If no default value for :attr:`~Option.dest` is " @@ -2203,25 +2203,25 @@ msgid "" "is appended to :attr:`~Option.dest`." msgstr "" -#: ../../library/optparse.rst:1287 +#: ../../library/optparse.rst:1284 msgid "" "The defaults for :attr:`~Option.type` and :attr:`~Option.dest` are the same " "as for the ``\"store\"`` action." msgstr "" -#: ../../library/optparse.rst:1292 +#: ../../library/optparse.rst:1289 msgid "" "parser.add_option(\"-t\", \"--tracks\", action=\"append\", type=\"int\")" msgstr "" "parser.add_option(\"-t\", \"--tracks\", action=\"append\", type=\"int\")" -#: ../../library/optparse.rst:1294 +#: ../../library/optparse.rst:1291 msgid "" "If ``-t3`` is seen on the command-line, :mod:`!optparse` does the equivalent " "of::" msgstr "" -#: ../../library/optparse.rst:1297 +#: ../../library/optparse.rst:1294 msgid "" "options.tracks = []\n" "options.tracks.append(int(\"3\"))" @@ -2229,15 +2229,15 @@ msgstr "" "options.tracks = []\n" "options.tracks.append(int(\"3\"))" -#: ../../library/optparse.rst:1300 +#: ../../library/optparse.rst:1297 msgid "If, a little later on, ``--tracks=4`` is seen, it does::" msgstr "" -#: ../../library/optparse.rst:1302 +#: ../../library/optparse.rst:1299 msgid "options.tracks.append(int(\"4\"))" msgstr "options.tracks.append(int(\"4\"))" -#: ../../library/optparse.rst:1304 +#: ../../library/optparse.rst:1301 msgid "" "The ``append`` action calls the ``append`` method on the current value of " "the option. This means that any default value specified must have an " @@ -2246,7 +2246,7 @@ msgid "" "with any values from the command line appended after those default values::" msgstr "" -#: ../../library/optparse.rst:1310 +#: ../../library/optparse.rst:1307 msgid "" ">>> parser.add_option(\"--files\", action=\"append\", default=['~/.mypkg/" "defaults'])\n" @@ -2260,13 +2260,13 @@ msgstr "" ">>> opts.files\n" "['~/.mypkg/defaults', 'overrides.mypkg']" -#: ../../library/optparse.rst:1315 +#: ../../library/optparse.rst:1312 msgid "" "``\"append_const\"`` [required: :attr:`~Option.const`; relevant: :attr:" "`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1318 +#: ../../library/optparse.rst:1315 msgid "" "Like ``\"store_const\"``, but the value :attr:`~Option.const` is appended " "to :attr:`~Option.dest`; as with ``\"append\"``, :attr:`~Option.dest` " @@ -2274,28 +2274,28 @@ msgid "" "time the option is encountered." msgstr "" -#: ../../library/optparse.rst:1323 +#: ../../library/optparse.rst:1320 msgid "``\"count\"`` [relevant: :attr:`~Option.dest`]" msgstr "" -#: ../../library/optparse.rst:1325 +#: ../../library/optparse.rst:1322 msgid "" "Increment the integer stored at :attr:`~Option.dest`. If no default value " "is supplied, :attr:`~Option.dest` is set to zero before being incremented " "the first time." msgstr "" -#: ../../library/optparse.rst:1331 +#: ../../library/optparse.rst:1328 msgid "parser.add_option(\"-v\", action=\"count\", dest=\"verbosity\")" msgstr "parser.add_option(\"-v\", action=\"count\", dest=\"verbosity\")" -#: ../../library/optparse.rst:1333 +#: ../../library/optparse.rst:1330 msgid "" "The first time ``-v`` is seen on the command line, :mod:`!optparse` does the " "equivalent of::" msgstr "" -#: ../../library/optparse.rst:1336 +#: ../../library/optparse.rst:1333 msgid "" "options.verbosity = 0\n" "options.verbosity += 1" @@ -2303,36 +2303,36 @@ msgstr "" "options.verbosity = 0\n" "options.verbosity += 1" -#: ../../library/optparse.rst:1339 +#: ../../library/optparse.rst:1336 msgid "Every subsequent occurrence of ``-v`` results in ::" msgstr "" -#: ../../library/optparse.rst:1341 +#: ../../library/optparse.rst:1338 msgid "options.verbosity += 1" msgstr "options.verbosity += 1" -#: ../../library/optparse.rst:1343 +#: ../../library/optparse.rst:1340 msgid "" "``\"callback\"`` [required: :attr:`~Option.callback`; relevant: :attr:" "`~Option.type`, :attr:`~Option.nargs`, :attr:`~Option.callback_args`, :attr:" "`~Option.callback_kwargs`]" msgstr "" -#: ../../library/optparse.rst:1347 +#: ../../library/optparse.rst:1344 msgid "" "Call the function specified by :attr:`~Option.callback`, which is called " "as ::" msgstr "" -#: ../../library/optparse.rst:1349 ../../library/optparse.rst:1747 +#: ../../library/optparse.rst:1346 ../../library/optparse.rst:1744 msgid "func(option, opt_str, value, parser, *args, **kwargs)" msgstr "func(option, opt_str, value, parser, *args, **kwargs)" -#: ../../library/optparse.rst:1351 +#: ../../library/optparse.rst:1348 msgid "See section :ref:`optparse-option-callbacks` for more detail." msgstr "更多細節請見 :ref:`optparse-option-callbacks`。" -#: ../../library/optparse.rst:1355 +#: ../../library/optparse.rst:1352 msgid "" "Prints a complete help message for all the options in the current option " "parser. The help message is constructed from the ``usage`` string passed to " @@ -2340,20 +2340,20 @@ msgid "" "every option." msgstr "" -#: ../../library/optparse.rst:1360 +#: ../../library/optparse.rst:1357 msgid "" "If no :attr:`~Option.help` string is supplied for an option, it will still " "be listed in the help message. To omit an option entirely, use the special " "value :const:`optparse.SUPPRESS_HELP`." msgstr "" -#: ../../library/optparse.rst:1364 +#: ../../library/optparse.rst:1361 msgid "" ":mod:`!optparse` automatically adds a :attr:`~Option.help` option to all " "OptionParsers, so you do not normally need to create one." msgstr "" -#: ../../library/optparse.rst:1369 +#: ../../library/optparse.rst:1366 msgid "" "from optparse import OptionParser, SUPPRESS_HELP\n" "\n" @@ -2369,14 +2369,14 @@ msgid "" "parser.add_option(\"--secret\", help=SUPPRESS_HELP)" msgstr "" -#: ../../library/optparse.rst:1382 +#: ../../library/optparse.rst:1379 msgid "" "If :mod:`!optparse` sees either ``-h`` or ``--help`` on the command line, it " "will print something like the following help message to stdout (assuming " "``sys.argv[0]`` is ``\"foo.py\"``):" msgstr "" -#: ../../library/optparse.rst:1386 +#: ../../library/optparse.rst:1383 msgid "" "Usage: foo.py [options]\n" "\n" @@ -2392,17 +2392,17 @@ msgstr "" " -v Be moderately verbose\n" " --file=FILENAME Input file to read data from" -#: ../../library/optparse.rst:1395 +#: ../../library/optparse.rst:1392 msgid "" "After printing the help message, :mod:`!optparse` terminates your process " "with ``sys.exit(0)``." msgstr "" -#: ../../library/optparse.rst:1398 +#: ../../library/optparse.rst:1395 msgid "``\"version\"``" msgstr "``\"version\"``" -#: ../../library/optparse.rst:1400 +#: ../../library/optparse.rst:1397 msgid "" "Prints the version number supplied to the OptionParser to stdout and exits. " "The version number is actually formatted and printed by the " @@ -2412,58 +2412,58 @@ msgid "" "since :mod:`!optparse` automatically adds them when needed." msgstr "" -#: ../../library/optparse.rst:1411 +#: ../../library/optparse.rst:1408 msgid "Standard option types" msgstr "" -#: ../../library/optparse.rst:1413 +#: ../../library/optparse.rst:1410 msgid "" ":mod:`!optparse` has five built-in option types: ``\"string\"``, " "``\"int\"``, ``\"choice\"``, ``\"float\"`` and ``\"complex\"``. If you need " "to add new option types, see section :ref:`optparse-extending-optparse`." msgstr "" -#: ../../library/optparse.rst:1417 +#: ../../library/optparse.rst:1414 msgid "" "Arguments to string options are not checked or converted in any way: the " "text on the command line is stored in the destination (or passed to the " "callback) as-is." msgstr "" -#: ../../library/optparse.rst:1420 +#: ../../library/optparse.rst:1417 msgid "Integer arguments (type ``\"int\"``) are parsed as follows:" msgstr "" -#: ../../library/optparse.rst:1422 +#: ../../library/optparse.rst:1419 msgid "if the number starts with ``0x``, it is parsed as a hexadecimal number" msgstr "" -#: ../../library/optparse.rst:1424 +#: ../../library/optparse.rst:1421 msgid "if the number starts with ``0``, it is parsed as an octal number" msgstr "" -#: ../../library/optparse.rst:1426 +#: ../../library/optparse.rst:1423 msgid "if the number starts with ``0b``, it is parsed as a binary number" msgstr "" -#: ../../library/optparse.rst:1428 +#: ../../library/optparse.rst:1425 msgid "otherwise, the number is parsed as a decimal number" msgstr "" -#: ../../library/optparse.rst:1431 +#: ../../library/optparse.rst:1428 msgid "" "The conversion is done by calling :func:`int` with the appropriate base (2, " "8, 10, or 16). If this fails, so will :mod:`!optparse`, although with a " "more useful error message." msgstr "" -#: ../../library/optparse.rst:1435 +#: ../../library/optparse.rst:1432 msgid "" "``\"float\"`` and ``\"complex\"`` option arguments are converted directly " "with :func:`float` and :func:`complex`, with similar error-handling." msgstr "" -#: ../../library/optparse.rst:1438 +#: ../../library/optparse.rst:1435 msgid "" "``\"choice\"`` options are a subtype of ``\"string\"`` options. The :attr:" "`~Option.choices` option attribute (a sequence of strings) defines the set " @@ -2472,63 +2472,63 @@ msgid "" "`OptionValueError` if an invalid string is given." msgstr "" -#: ../../library/optparse.rst:1448 +#: ../../library/optparse.rst:1445 msgid "Parsing arguments" msgstr "剖析引數" -#: ../../library/optparse.rst:1450 +#: ../../library/optparse.rst:1447 msgid "" "The whole point of creating and populating an OptionParser is to call its :" "meth:`~OptionParser.parse_args` method." msgstr "" -#: ../../library/optparse.rst:1455 +#: ../../library/optparse.rst:1452 msgid "Parse the command-line options found in *args*." msgstr "" -#: ../../library/optparse.rst:1457 +#: ../../library/optparse.rst:1454 msgid "The input parameters are" msgstr "" -#: ../../library/optparse.rst:1459 ../../library/optparse.rst:1473 -#: ../../library/optparse.rst:1791 +#: ../../library/optparse.rst:1456 ../../library/optparse.rst:1470 +#: ../../library/optparse.rst:1788 msgid "``args``" msgstr "``args``" -#: ../../library/optparse.rst:1460 +#: ../../library/optparse.rst:1457 msgid "the list of arguments to process (default: ``sys.argv[1:]``)" msgstr "" -#: ../../library/optparse.rst:1462 +#: ../../library/optparse.rst:1459 msgid "``values``" msgstr "``values``" -#: ../../library/optparse.rst:1463 +#: ../../library/optparse.rst:1460 msgid "" "a :class:`Values` object to store option arguments in (default: a new " "instance of :class:`Values`) -- if you give an existing object, the option " "defaults will not be initialized on it" msgstr "" -#: ../../library/optparse.rst:1467 +#: ../../library/optparse.rst:1464 msgid "and the return value is a pair ``(options, args)`` where" msgstr "" -#: ../../library/optparse.rst:1469 +#: ../../library/optparse.rst:1466 msgid "``options``" msgstr "``options``" -#: ../../library/optparse.rst:1470 +#: ../../library/optparse.rst:1467 msgid "" "the same object that was passed in as *values*, or the ``optparse.Values`` " "instance created by :mod:`!optparse`" msgstr "" -#: ../../library/optparse.rst:1474 +#: ../../library/optparse.rst:1471 msgid "the leftover positional arguments after all options have been processed" msgstr "" -#: ../../library/optparse.rst:1476 +#: ../../library/optparse.rst:1473 msgid "" "The most common usage is to supply neither keyword argument. If you supply " "``values``, it will be modified with repeated :func:`setattr` calls (roughly " @@ -2536,7 +2536,7 @@ msgid "" "by :meth:`~OptionParser.parse_args`." msgstr "" -#: ../../library/optparse.rst:1481 +#: ../../library/optparse.rst:1478 msgid "" "If :meth:`~OptionParser.parse_args` encounters any errors in the argument " "list, it calls the OptionParser's :meth:`error` method with an appropriate " @@ -2544,69 +2544,69 @@ msgid "" "status of 2 (the traditional Unix exit status for command-line errors)." msgstr "" -#: ../../library/optparse.rst:1490 +#: ../../library/optparse.rst:1487 msgid "Querying and manipulating your option parser" msgstr "" -#: ../../library/optparse.rst:1492 +#: ../../library/optparse.rst:1489 msgid "" "The default behavior of the option parser can be customized slightly, and " "you can also poke around your option parser and see what's there. " "OptionParser provides several methods to help you out:" msgstr "" -#: ../../library/optparse.rst:1498 +#: ../../library/optparse.rst:1495 msgid "" "Set parsing to stop on the first non-option. For example, if ``-a`` and ``-" "b`` are both simple options that take no arguments, :mod:`!optparse` " "normally accepts this syntax::" msgstr "" -#: ../../library/optparse.rst:1502 +#: ../../library/optparse.rst:1499 msgid "prog -a arg1 -b arg2" msgstr "prog -a arg1 -b arg2" -#: ../../library/optparse.rst:1504 +#: ../../library/optparse.rst:1501 msgid "and treats it as equivalent to ::" msgstr "" -#: ../../library/optparse.rst:1506 +#: ../../library/optparse.rst:1503 msgid "prog -a -b arg1 arg2" msgstr "prog -a -b arg1 arg2" -#: ../../library/optparse.rst:1508 +#: ../../library/optparse.rst:1505 msgid "" "To disable this feature, call :meth:`disable_interspersed_args`. This " "restores traditional Unix syntax, where option parsing stops with the first " "non-option argument." msgstr "" -#: ../../library/optparse.rst:1512 +#: ../../library/optparse.rst:1509 msgid "" "Use this if you have a command processor which runs another command which " "has options of its own and you want to make sure these options don't get " "confused. For example, each command might have a different set of options." msgstr "" -#: ../../library/optparse.rst:1518 +#: ../../library/optparse.rst:1515 msgid "" "Set parsing to not stop on the first non-option, allowing interspersing " "switches with command arguments. This is the default behavior." msgstr "" -#: ../../library/optparse.rst:1523 +#: ../../library/optparse.rst:1520 msgid "" "Returns the Option instance with the option string *opt_str*, or ``None`` if " "no options have that option string." msgstr "" -#: ../../library/optparse.rst:1528 +#: ../../library/optparse.rst:1525 msgid "" "Return ``True`` if the OptionParser has an option with option string " "*opt_str* (e.g., ``-q`` or ``--verbose``)." msgstr "" -#: ../../library/optparse.rst:1533 +#: ../../library/optparse.rst:1530 msgid "" "If the :class:`OptionParser` has an option corresponding to *opt_str*, that " "option is removed. If that option provided any other option strings, all of " @@ -2614,17 +2614,17 @@ msgid "" "option belonging to this :class:`OptionParser`, raises :exc:`ValueError`." msgstr "" -#: ../../library/optparse.rst:1542 +#: ../../library/optparse.rst:1539 msgid "Conflicts between options" msgstr "" -#: ../../library/optparse.rst:1544 +#: ../../library/optparse.rst:1541 msgid "" "If you're not careful, it's easy to define options with conflicting option " "strings::" msgstr "" -#: ../../library/optparse.rst:1547 +#: ../../library/optparse.rst:1544 msgid "" "parser.add_option(\"-n\", \"--dry-run\", ...)\n" "...\n" @@ -2634,13 +2634,13 @@ msgstr "" "...\n" "parser.add_option(\"-n\", \"--noisy\", ...)" -#: ../../library/optparse.rst:1551 +#: ../../library/optparse.rst:1548 msgid "" "(This is particularly true if you've defined your own OptionParser subclass " "with some standard options.)" msgstr "" -#: ../../library/optparse.rst:1554 +#: ../../library/optparse.rst:1551 msgid "" "Every time you add an option, :mod:`!optparse` checks for conflicts with " "existing options. If it finds any, it invokes the current conflict-handling " @@ -2648,47 +2648,47 @@ msgid "" "constructor::" msgstr "" -#: ../../library/optparse.rst:1558 +#: ../../library/optparse.rst:1555 msgid "parser = OptionParser(..., conflict_handler=handler)" msgstr "parser = OptionParser(..., conflict_handler=handler)" -#: ../../library/optparse.rst:1560 +#: ../../library/optparse.rst:1557 msgid "or with a separate call::" msgstr "" -#: ../../library/optparse.rst:1562 +#: ../../library/optparse.rst:1559 msgid "parser.set_conflict_handler(handler)" msgstr "parser.set_conflict_handler(handler)" -#: ../../library/optparse.rst:1564 +#: ../../library/optparse.rst:1561 msgid "The available conflict handlers are:" msgstr "" -#: ../../library/optparse.rst:1566 +#: ../../library/optparse.rst:1563 msgid "``\"error\"`` (default)" msgstr "``\"error\"`` (預設值)" -#: ../../library/optparse.rst:1567 +#: ../../library/optparse.rst:1564 msgid "" "assume option conflicts are a programming error and raise :exc:" "`OptionConflictError`" msgstr "" -#: ../../library/optparse.rst:1570 +#: ../../library/optparse.rst:1567 msgid "``\"resolve\"``" msgstr "``\"resolve\"``" -#: ../../library/optparse.rst:1571 +#: ../../library/optparse.rst:1568 msgid "resolve option conflicts intelligently (see below)" msgstr "" -#: ../../library/optparse.rst:1574 +#: ../../library/optparse.rst:1571 msgid "" "As an example, let's define an :class:`OptionParser` that resolves conflicts " "intelligently and add conflicting options to it::" msgstr "" -#: ../../library/optparse.rst:1577 +#: ../../library/optparse.rst:1574 msgid "" "parser = OptionParser(conflict_handler=\"resolve\")\n" "parser.add_option(\"-n\", \"--dry-run\", ..., help=\"do no harm\")\n" @@ -2698,7 +2698,7 @@ msgstr "" "parser.add_option(\"-n\", \"--dry-run\", ..., help=\"do no harm\")\n" "parser.add_option(\"-n\", \"--noisy\", ..., help=\"be noisy\")" -#: ../../library/optparse.rst:1581 +#: ../../library/optparse.rst:1578 msgid "" "At this point, :mod:`!optparse` detects that a previously added option is " "already using the ``-n`` option string. Since ``conflict_handler`` is " @@ -2708,7 +2708,7 @@ msgid "" "message will reflect that::" msgstr "" -#: ../../library/optparse.rst:1587 +#: ../../library/optparse.rst:1584 msgid "" "Options:\n" " --dry-run do no harm\n" @@ -2716,7 +2716,7 @@ msgid "" " -n, --noisy be noisy" msgstr "" -#: ../../library/optparse.rst:1592 +#: ../../library/optparse.rst:1589 msgid "" "It's possible to whittle away the option strings for a previously added " "option until there are none left, and the user has no way of invoking that " @@ -2725,17 +2725,17 @@ msgid "" "Carrying on with our existing OptionParser::" msgstr "" -#: ../../library/optparse.rst:1598 +#: ../../library/optparse.rst:1595 msgid "parser.add_option(\"--dry-run\", ..., help=\"new dry-run option\")" msgstr "parser.add_option(\"--dry-run\", ..., help=\"new dry-run option\")" -#: ../../library/optparse.rst:1600 +#: ../../library/optparse.rst:1597 msgid "" "At this point, the original ``-n``/``--dry-run`` option is no longer " "accessible, so :mod:`!optparse` removes it, leaving this help text::" msgstr "" -#: ../../library/optparse.rst:1603 +#: ../../library/optparse.rst:1600 msgid "" "Options:\n" " ...\n" @@ -2747,11 +2747,11 @@ msgstr "" " -n, --noisy be noisy\n" " --dry-run new dry-run option" -#: ../../library/optparse.rst:1612 +#: ../../library/optparse.rst:1609 msgid "Cleanup" msgstr "" -#: ../../library/optparse.rst:1614 +#: ../../library/optparse.rst:1611 msgid "" "OptionParser instances have several cyclic references. This should not be a " "problem for Python's garbage collector, but you may wish to break the cyclic " @@ -2761,15 +2761,15 @@ msgid "" "OptionParser." msgstr "" -#: ../../library/optparse.rst:1625 +#: ../../library/optparse.rst:1622 msgid "Other methods" msgstr "其他方法" -#: ../../library/optparse.rst:1627 +#: ../../library/optparse.rst:1624 msgid "OptionParser supports several other public methods:" msgstr "" -#: ../../library/optparse.rst:1631 +#: ../../library/optparse.rst:1628 msgid "" "Set the usage string according to the rules described above for the " "``usage`` constructor keyword argument. Passing ``None`` sets the default " @@ -2777,7 +2777,7 @@ msgid "" "message." msgstr "" -#: ../../library/optparse.rst:1637 +#: ../../library/optparse.rst:1634 msgid "" "Print the usage message for the current program (``self.usage``) to *file* " "(default stdout). Any occurrence of the string ``%prog`` in ``self.usage`` " @@ -2785,13 +2785,13 @@ msgid "" "usage`` is empty or not defined." msgstr "" -#: ../../library/optparse.rst:1644 +#: ../../library/optparse.rst:1641 msgid "" "Same as :meth:`print_usage` but returns the usage string instead of printing " "it." msgstr "" -#: ../../library/optparse.rst:1649 +#: ../../library/optparse.rst:1646 msgid "" "Set default values for several option destinations at once. Using :meth:" "`set_defaults` is the preferred way to set default values for options, since " @@ -2800,7 +2800,7 @@ msgid "" "default, and the last one wins::" msgstr "" -#: ../../library/optparse.rst:1655 +#: ../../library/optparse.rst:1652 msgid "" "parser.add_option(\"--advanced\", action=\"store_const\",\n" " dest=\"mode\", const=\"advanced\",\n" @@ -2810,11 +2810,11 @@ msgid "" " default=\"advanced\") # overrides above setting" msgstr "" -#: ../../library/optparse.rst:1662 +#: ../../library/optparse.rst:1659 msgid "To avoid this confusion, use :meth:`set_defaults`::" msgstr "" -#: ../../library/optparse.rst:1664 +#: ../../library/optparse.rst:1661 msgid "" "parser.set_defaults(mode=\"advanced\")\n" "parser.add_option(\"--advanced\", action=\"store_const\",\n" @@ -2828,11 +2828,11 @@ msgstr "" "parser.add_option(\"--novice\", action=\"store_const\",\n" " dest=\"mode\", const=\"novice\")" -#: ../../library/optparse.rst:1674 +#: ../../library/optparse.rst:1671 msgid "Option Callbacks" msgstr "" -#: ../../library/optparse.rst:1676 +#: ../../library/optparse.rst:1673 msgid "" "When :mod:`!optparse`'s built-in actions and types aren't quite enough for " "your needs, you have two choices: extend :mod:`!optparse` or define a " @@ -2840,25 +2840,25 @@ msgid "" "for a lot of simple cases. Quite often a simple callback is all you need." msgstr "" -#: ../../library/optparse.rst:1681 +#: ../../library/optparse.rst:1678 msgid "There are two steps to defining a callback option:" msgstr "" -#: ../../library/optparse.rst:1683 +#: ../../library/optparse.rst:1680 msgid "define the option itself using the ``\"callback\"`` action" msgstr "" -#: ../../library/optparse.rst:1685 +#: ../../library/optparse.rst:1682 msgid "" "write the callback; this is a function (or method) that takes at least four " "arguments, as described below" msgstr "" -#: ../../library/optparse.rst:1692 +#: ../../library/optparse.rst:1689 msgid "Defining a callback option" msgstr "" -#: ../../library/optparse.rst:1694 +#: ../../library/optparse.rst:1691 msgid "" "As always, the easiest way to define a callback option is by using the :meth:" "`OptionParser.add_option` method. Apart from :attr:`~Option.action`, the " @@ -2866,11 +2866,11 @@ msgid "" "call::" msgstr "" -#: ../../library/optparse.rst:1698 +#: ../../library/optparse.rst:1695 msgid "parser.add_option(\"-c\", action=\"callback\", callback=my_callback)" msgstr "parser.add_option(\"-c\", action=\"callback\", callback=my_callback)" -#: ../../library/optparse.rst:1700 +#: ../../library/optparse.rst:1697 msgid "" "``callback`` is a function (or other callable object), so you must have " "already defined ``my_callback()`` when you create this callback option. In " @@ -2882,7 +2882,7 @@ msgid "" "tricky; it's covered later in this section." msgstr "" -#: ../../library/optparse.rst:1709 +#: ../../library/optparse.rst:1706 msgid "" ":mod:`!optparse` always passes four particular arguments to your callback, " "and it will only pass additional arguments if you specify them via :attr:" @@ -2890,25 +2890,25 @@ msgid "" "minimal callback function signature is::" msgstr "" -#: ../../library/optparse.rst:1714 +#: ../../library/optparse.rst:1711 msgid "def my_callback(option, opt, value, parser):" msgstr "def my_callback(option, opt, value, parser):" -#: ../../library/optparse.rst:1716 +#: ../../library/optparse.rst:1713 msgid "The four arguments to a callback are described below." msgstr "" -#: ../../library/optparse.rst:1718 +#: ../../library/optparse.rst:1715 msgid "" "There are several other option attributes that you can supply when you " "define a callback option:" msgstr "" -#: ../../library/optparse.rst:1721 +#: ../../library/optparse.rst:1718 msgid ":attr:`~Option.type`" msgstr ":attr:`~Option.type`" -#: ../../library/optparse.rst:1722 +#: ../../library/optparse.rst:1719 msgid "" "has its usual meaning: as with the ``\"store\"`` or ``\"append\"`` actions, " "it instructs :mod:`!optparse` to consume one argument and convert it to :" @@ -2916,11 +2916,11 @@ msgid "" "though, :mod:`!optparse` passes it to your callback function." msgstr "" -#: ../../library/optparse.rst:1727 +#: ../../library/optparse.rst:1724 msgid ":attr:`~Option.nargs`" msgstr ":attr:`~Option.nargs`" -#: ../../library/optparse.rst:1728 +#: ../../library/optparse.rst:1725 msgid "" "also has its usual meaning: if it is supplied and > 1, :mod:`!optparse` will " "consume :attr:`~Option.nargs` arguments, each of which must be convertible " @@ -2928,43 +2928,43 @@ msgid "" "callback." msgstr "" -#: ../../library/optparse.rst:1733 +#: ../../library/optparse.rst:1730 msgid ":attr:`~Option.callback_args`" msgstr ":attr:`~Option.callback_args`" -#: ../../library/optparse.rst:1734 +#: ../../library/optparse.rst:1731 msgid "a tuple of extra positional arguments to pass to the callback" msgstr "" -#: ../../library/optparse.rst:1736 +#: ../../library/optparse.rst:1733 msgid ":attr:`~Option.callback_kwargs`" msgstr ":attr:`~Option.callback_kwargs`" -#: ../../library/optparse.rst:1737 +#: ../../library/optparse.rst:1734 msgid "a dictionary of extra keyword arguments to pass to the callback" msgstr "" -#: ../../library/optparse.rst:1743 +#: ../../library/optparse.rst:1740 msgid "How callbacks are called" msgstr "" -#: ../../library/optparse.rst:1745 +#: ../../library/optparse.rst:1742 msgid "All callbacks are called as follows::" msgstr "" -#: ../../library/optparse.rst:1751 +#: ../../library/optparse.rst:1748 msgid "``option``" msgstr "``option``" -#: ../../library/optparse.rst:1752 +#: ../../library/optparse.rst:1749 msgid "is the Option instance that's calling the callback" msgstr "" -#: ../../library/optparse.rst:1754 +#: ../../library/optparse.rst:1751 msgid "``opt_str``" msgstr "``opt_str``" -#: ../../library/optparse.rst:1755 +#: ../../library/optparse.rst:1752 msgid "" "is the option string seen on the command-line that's triggering the " "callback. (If an abbreviated long option was used, ``opt_str`` will be the " @@ -2973,11 +2973,11 @@ msgid "" "``\"--foobar\"``.)" msgstr "" -#: ../../library/optparse.rst:1761 +#: ../../library/optparse.rst:1758 msgid "``value``" msgstr "``value``" -#: ../../library/optparse.rst:1762 +#: ../../library/optparse.rst:1759 msgid "" "is the argument to this option seen on the command-line. :mod:`!optparse` " "will only expect an argument if :attr:`~Option.type` is set; the type of " @@ -2987,21 +2987,21 @@ msgid "" "of values of the appropriate type." msgstr "" -#: ../../library/optparse.rst:1768 +#: ../../library/optparse.rst:1765 msgid "``parser``" msgstr "``parser``" -#: ../../library/optparse.rst:1769 +#: ../../library/optparse.rst:1766 msgid "" "is the OptionParser instance driving the whole thing, mainly useful because " "you can access some other interesting data through its instance attributes:" msgstr "" -#: ../../library/optparse.rst:1772 +#: ../../library/optparse.rst:1769 msgid "``parser.largs``" msgstr "``parser.largs``" -#: ../../library/optparse.rst:1773 +#: ../../library/optparse.rst:1770 msgid "" "the current list of leftover arguments, ie. arguments that have been " "consumed but are neither options nor option arguments. Feel free to modify " @@ -3010,22 +3010,22 @@ msgid "" "parse_args`.)" msgstr "" -#: ../../library/optparse.rst:1778 +#: ../../library/optparse.rst:1775 msgid "``parser.rargs``" msgstr "``parser.rargs``" -#: ../../library/optparse.rst:1779 +#: ../../library/optparse.rst:1776 msgid "" "the current list of remaining arguments, ie. with ``opt_str`` and ``value`` " "(if applicable) removed, and only the arguments following them still there. " "Feel free to modify ``parser.rargs``, e.g. by consuming more arguments." msgstr "" -#: ../../library/optparse.rst:1784 +#: ../../library/optparse.rst:1781 msgid "``parser.values``" msgstr "``parser.values``" -#: ../../library/optparse.rst:1785 +#: ../../library/optparse.rst:1782 msgid "" "the object where option values are by default stored (an instance of " "optparse.OptionValues). This lets callbacks use the same mechanism as the " @@ -3034,27 +3034,27 @@ msgid "" "of any options already encountered on the command-line." msgstr "" -#: ../../library/optparse.rst:1792 +#: ../../library/optparse.rst:1789 msgid "" "is a tuple of arbitrary positional arguments supplied via the :attr:`~Option." "callback_args` option attribute." msgstr "" -#: ../../library/optparse.rst:1795 +#: ../../library/optparse.rst:1792 msgid "``kwargs``" msgstr "``kwargs``" -#: ../../library/optparse.rst:1796 +#: ../../library/optparse.rst:1793 msgid "" "is a dictionary of arbitrary keyword arguments supplied via :attr:`~Option." "callback_kwargs`." msgstr "" -#: ../../library/optparse.rst:1803 +#: ../../library/optparse.rst:1800 msgid "Raising errors in a callback" msgstr "" -#: ../../library/optparse.rst:1805 +#: ../../library/optparse.rst:1802 msgid "" "The callback function should raise :exc:`OptionValueError` if there are any " "problems with the option or its argument(s). :mod:`!optparse` catches this " @@ -3064,17 +3064,17 @@ msgid "" "they did wrong." msgstr "" -#: ../../library/optparse.rst:1815 +#: ../../library/optparse.rst:1812 msgid "Callback example 1: trivial callback" msgstr "" -#: ../../library/optparse.rst:1817 +#: ../../library/optparse.rst:1814 msgid "" "Here's an example of a callback option that takes no arguments, and simply " "records that the option was seen::" msgstr "" -#: ../../library/optparse.rst:1820 +#: ../../library/optparse.rst:1817 msgid "" "def record_foo_seen(option, opt_str, value, parser):\n" " parser.values.saw_foo = True\n" @@ -3086,21 +3086,21 @@ msgstr "" "\n" "parser.add_option(\"--foo\", action=\"callback\", callback=record_foo_seen)" -#: ../../library/optparse.rst:1825 +#: ../../library/optparse.rst:1822 msgid "Of course, you could do that with the ``\"store_true\"`` action." msgstr "" -#: ../../library/optparse.rst:1831 +#: ../../library/optparse.rst:1828 msgid "Callback example 2: check option order" msgstr "" -#: ../../library/optparse.rst:1833 +#: ../../library/optparse.rst:1830 msgid "" "Here's a slightly more interesting example: record the fact that ``-a`` is " "seen, but blow up if it comes after ``-b`` in the command-line. ::" msgstr "" -#: ../../library/optparse.rst:1836 +#: ../../library/optparse.rst:1833 msgid "" "def check_order(option, opt_str, value, parser):\n" " if parser.values.b:\n" @@ -3118,18 +3118,18 @@ msgstr "" "parser.add_option(\"-a\", action=\"callback\", callback=check_order)\n" "parser.add_option(\"-b\", action=\"store_true\", dest=\"b\")" -#: ../../library/optparse.rst:1848 +#: ../../library/optparse.rst:1845 msgid "Callback example 3: check option order (generalized)" msgstr "" -#: ../../library/optparse.rst:1850 +#: ../../library/optparse.rst:1847 msgid "" "If you want to reuse this callback for several similar options (set a flag, " "but blow up if ``-b`` has already been seen), it needs a bit of work: the " "error message and the flag that it sets must be generalized. ::" msgstr "" -#: ../../library/optparse.rst:1854 +#: ../../library/optparse.rst:1851 msgid "" "def check_order(option, opt_str, value, parser):\n" " if parser.values.b:\n" @@ -3153,11 +3153,11 @@ msgstr "" "parser.add_option(\"-c\", action=\"callback\", callback=check_order, " "dest='c')" -#: ../../library/optparse.rst:1867 +#: ../../library/optparse.rst:1864 msgid "Callback example 4: check arbitrary condition" msgstr "" -#: ../../library/optparse.rst:1869 +#: ../../library/optparse.rst:1866 msgid "" "Of course, you could put any condition in there---you're not limited to " "checking the values of already-defined options. For example, if you have " @@ -3165,7 +3165,7 @@ msgid "" "is this::" msgstr "" -#: ../../library/optparse.rst:1873 +#: ../../library/optparse.rst:1870 msgid "" "def check_moon(option, opt_str, value, parser):\n" " if is_moon_full():\n" @@ -3185,16 +3185,16 @@ msgstr "" "parser.add_option(\"--foo\",\n" " action=\"callback\", callback=check_moon, dest=\"foo\")" -#: ../../library/optparse.rst:1882 +#: ../../library/optparse.rst:1879 msgid "" "(The definition of ``is_moon_full()`` is left as an exercise for the reader.)" msgstr "" -#: ../../library/optparse.rst:1888 +#: ../../library/optparse.rst:1885 msgid "Callback example 5: fixed arguments" msgstr "" -#: ../../library/optparse.rst:1890 +#: ../../library/optparse.rst:1887 msgid "" "Things get slightly more interesting when you define callback options that " "take a fixed number of arguments. Specifying that a callback option takes " @@ -3204,12 +3204,12 @@ msgid "" "nargs`, then the option takes :attr:`~Option.nargs` arguments." msgstr "" -#: ../../library/optparse.rst:1897 +#: ../../library/optparse.rst:1894 msgid "" "Here's an example that just emulates the standard ``\"store\"`` action::" msgstr "" -#: ../../library/optparse.rst:1899 +#: ../../library/optparse.rst:1896 msgid "" "def store_value(option, opt_str, value, parser):\n" " setattr(parser.values, option.dest, value)\n" @@ -3225,18 +3225,18 @@ msgstr "" " action=\"callback\", callback=store_value,\n" " type=\"int\", nargs=3, dest=\"foo\")" -#: ../../library/optparse.rst:1906 +#: ../../library/optparse.rst:1903 msgid "" "Note that :mod:`!optparse` takes care of consuming 3 arguments and " "converting them to integers for you; all you have to do is store them. (Or " "whatever; obviously you don't need a callback for this example.)" msgstr "" -#: ../../library/optparse.rst:1914 +#: ../../library/optparse.rst:1911 msgid "Callback example 6: variable arguments" msgstr "" -#: ../../library/optparse.rst:1916 +#: ../../library/optparse.rst:1913 msgid "" "Things get hairy when you want an option to take a variable number of " "arguments. For this case, you must write a callback, as :mod:`!optparse` " @@ -3246,23 +3246,23 @@ msgid "" "implement the conventional rules for bare ``--`` and ``-`` arguments:" msgstr "" -#: ../../library/optparse.rst:1923 +#: ../../library/optparse.rst:1920 msgid "either ``--`` or ``-`` can be option arguments" msgstr "" -#: ../../library/optparse.rst:1925 +#: ../../library/optparse.rst:1922 msgid "" "bare ``--`` (if not the argument to some option): halt command-line " "processing and discard the ``--``" msgstr "" -#: ../../library/optparse.rst:1928 +#: ../../library/optparse.rst:1925 msgid "" "bare ``-`` (if not the argument to some option): halt command-line " "processing but keep the ``-`` (append it to ``parser.largs``)" msgstr "" -#: ../../library/optparse.rst:1931 +#: ../../library/optparse.rst:1928 msgid "" "If you want an option that takes a variable number of arguments, there are " "several subtle, tricky issues to worry about. The exact implementation you " @@ -3271,13 +3271,13 @@ msgid "" "thing directly)." msgstr "" -#: ../../library/optparse.rst:1937 +#: ../../library/optparse.rst:1934 msgid "" "Nevertheless, here's a stab at a callback for an option with variable " "arguments::" msgstr "" -#: ../../library/optparse.rst:1940 +#: ../../library/optparse.rst:1937 msgid "" "def vararg_callback(option, opt_str, value, parser):\n" " assert value is None\n" @@ -3307,22 +3307,22 @@ msgid "" " action=\"callback\", callback=vararg_callback)" msgstr "" -#: ../../library/optparse.rst:1971 +#: ../../library/optparse.rst:1968 msgid "Extending :mod:`!optparse`" msgstr "" -#: ../../library/optparse.rst:1973 +#: ../../library/optparse.rst:1970 msgid "" "Since the two major controlling factors in how :mod:`!optparse` interprets " "command-line options are the action and type of each option, the most likely " "direction of extension is to add new actions and new types." msgstr "" -#: ../../library/optparse.rst:1981 +#: ../../library/optparse.rst:1978 msgid "Adding new types" msgstr "" -#: ../../library/optparse.rst:1983 +#: ../../library/optparse.rst:1980 msgid "" "To add new types, you need to define your own subclass of :mod:`!" "optparse`'s :class:`Option` class. This class has a couple of attributes " @@ -3330,23 +3330,23 @@ msgid "" "`~Option.TYPE_CHECKER`." msgstr "" -#: ../../library/optparse.rst:1989 +#: ../../library/optparse.rst:1986 msgid "" "A tuple of type names; in your subclass, simply define a new tuple :attr:" "`TYPES` that builds on the standard one." msgstr "" -#: ../../library/optparse.rst:1994 +#: ../../library/optparse.rst:1991 msgid "" "A dictionary mapping type names to type-checking functions. A type-checking " "function has the following signature::" msgstr "" -#: ../../library/optparse.rst:1997 +#: ../../library/optparse.rst:1994 msgid "def check_mytype(option, opt, value)" msgstr "def check_mytype(option, opt, value)" -#: ../../library/optparse.rst:1999 +#: ../../library/optparse.rst:1996 msgid "" "where ``option`` is an :class:`Option` instance, ``opt`` is an option string " "(e.g., ``-f``), and ``value`` is the string from the command line that must " @@ -3357,7 +3357,7 @@ msgid "" "``value`` parameter." msgstr "" -#: ../../library/optparse.rst:2007 +#: ../../library/optparse.rst:2004 msgid "" "Your type-checking function should raise :exc:`OptionValueError` if it " "encounters any problems. :exc:`OptionValueError` takes a single string " @@ -3366,7 +3366,7 @@ msgid "" "\"`` and prints everything to stderr before terminating the process." msgstr "" -#: ../../library/optparse.rst:2013 +#: ../../library/optparse.rst:2010 msgid "" "Here's a silly example that demonstrates adding a ``\"complex\"`` option " "type to parse Python-style complex numbers on the command line. (This is " @@ -3374,11 +3374,11 @@ msgid "" "support for complex numbers, but never mind.)" msgstr "" -#: ../../library/optparse.rst:2018 +#: ../../library/optparse.rst:2015 msgid "First, the necessary imports::" msgstr "" -#: ../../library/optparse.rst:2020 +#: ../../library/optparse.rst:2017 msgid "" "from copy import copy\n" "from optparse import Option, OptionValueError" @@ -3386,13 +3386,13 @@ msgstr "" "from copy import copy\n" "from optparse import Option, OptionValueError" -#: ../../library/optparse.rst:2023 +#: ../../library/optparse.rst:2020 msgid "" "You need to define your type-checker first, since it's referred to later (in " "the :attr:`~Option.TYPE_CHECKER` class attribute of your Option subclass)::" msgstr "" -#: ../../library/optparse.rst:2026 +#: ../../library/optparse.rst:2023 msgid "" "def check_complex(option, opt, value):\n" " try:\n" @@ -3408,11 +3408,11 @@ msgstr "" " raise OptionValueError(\n" " \"option %s: invalid complex value: %r\" % (opt, value))" -#: ../../library/optparse.rst:2033 +#: ../../library/optparse.rst:2030 msgid "Finally, the Option subclass::" msgstr "" -#: ../../library/optparse.rst:2035 +#: ../../library/optparse.rst:2032 msgid "" "class MyOption (Option):\n" " TYPES = Option.TYPES + (\"complex\",)\n" @@ -3424,7 +3424,7 @@ msgstr "" " TYPE_CHECKER = copy(Option.TYPE_CHECKER)\n" " TYPE_CHECKER[\"complex\"] = check_complex" -#: ../../library/optparse.rst:2040 +#: ../../library/optparse.rst:2037 msgid "" "(If we didn't make a :func:`copy` of :attr:`Option.TYPE_CHECKER`, we would " "end up modifying the :attr:`~Option.TYPE_CHECKER` attribute of :mod:`!" @@ -3432,14 +3432,14 @@ msgid "" "that except good manners and common sense.)" msgstr "" -#: ../../library/optparse.rst:2045 +#: ../../library/optparse.rst:2042 msgid "" "That's it! Now you can write a script that uses the new option type just " "like any other :mod:`!optparse`\\ -based script, except you have to instruct " "your OptionParser to use MyOption instead of Option::" msgstr "" -#: ../../library/optparse.rst:2049 +#: ../../library/optparse.rst:2046 msgid "" "parser = OptionParser(option_class=MyOption)\n" "parser.add_option(\"-c\", type=\"complex\")" @@ -3447,14 +3447,14 @@ msgstr "" "parser = OptionParser(option_class=MyOption)\n" "parser.add_option(\"-c\", type=\"complex\")" -#: ../../library/optparse.rst:2052 +#: ../../library/optparse.rst:2049 msgid "" "Alternately, you can build your own option list and pass it to OptionParser; " "if you don't use :meth:`add_option` in the above way, you don't need to tell " "OptionParser which option class to use::" msgstr "" -#: ../../library/optparse.rst:2056 +#: ../../library/optparse.rst:2053 msgid "" "option_list = [MyOption(\"-c\", action=\"store\", type=\"complex\", " "dest=\"c\")]\n" @@ -3464,32 +3464,32 @@ msgstr "" "dest=\"c\")]\n" "parser = OptionParser(option_list=option_list)" -#: ../../library/optparse.rst:2063 +#: ../../library/optparse.rst:2060 msgid "Adding new actions" msgstr "" -#: ../../library/optparse.rst:2065 +#: ../../library/optparse.rst:2062 msgid "" "Adding new actions is a bit trickier, because you have to understand that :" "mod:`!optparse` has a couple of classifications for actions:" msgstr "" -#: ../../library/optparse.rst:2068 +#: ../../library/optparse.rst:2065 msgid "\"store\" actions" msgstr "" -#: ../../library/optparse.rst:2069 +#: ../../library/optparse.rst:2066 msgid "" "actions that result in :mod:`!optparse` storing a value to an attribute of " "the current OptionValues instance; these options require a :attr:`~Option." "dest` attribute to be supplied to the Option constructor." msgstr "" -#: ../../library/optparse.rst:2073 +#: ../../library/optparse.rst:2070 msgid "\"typed\" actions" msgstr "" -#: ../../library/optparse.rst:2074 +#: ../../library/optparse.rst:2071 msgid "" "actions that take a value from the command line and expect it to be of a " "certain type; or rather, a string that can be converted to a certain type. " @@ -3497,7 +3497,7 @@ msgid "" "constructor." msgstr "" -#: ../../library/optparse.rst:2079 +#: ../../library/optparse.rst:2076 msgid "" "These are overlapping sets: some default \"store\" actions are " "``\"store\"``, ``\"store_const\"``, ``\"append\"``, and ``\"count\"``, while " @@ -3505,25 +3505,25 @@ msgid "" "``\"callback\"``." msgstr "" -#: ../../library/optparse.rst:2083 +#: ../../library/optparse.rst:2080 msgid "" "When you add an action, you need to categorize it by listing it in at least " "one of the following class attributes of Option (all are lists of strings):" msgstr "" -#: ../../library/optparse.rst:2088 +#: ../../library/optparse.rst:2085 msgid "All actions must be listed in ACTIONS." msgstr "" -#: ../../library/optparse.rst:2092 +#: ../../library/optparse.rst:2089 msgid "\"store\" actions are additionally listed here." msgstr "" -#: ../../library/optparse.rst:2096 +#: ../../library/optparse.rst:2093 msgid "\"typed\" actions are additionally listed here." msgstr "" -#: ../../library/optparse.rst:2100 +#: ../../library/optparse.rst:2097 msgid "" "Actions that always take a type (i.e. whose options always take a value) are " "additionally listed here. The only effect of this is that :mod:`!optparse` " @@ -3531,13 +3531,13 @@ msgid "" "whose action is listed in :attr:`ALWAYS_TYPED_ACTIONS`." msgstr "" -#: ../../library/optparse.rst:2105 +#: ../../library/optparse.rst:2102 msgid "" "In order to actually implement your new action, you must override Option's :" "meth:`take_action` method and add a case that recognizes your action." msgstr "" -#: ../../library/optparse.rst:2108 +#: ../../library/optparse.rst:2105 msgid "" "For example, let's add an ``\"extend\"`` action. This is similar to the " "standard ``\"append\"`` action, but instead of taking a single value from " @@ -3547,23 +3547,23 @@ msgid "" "option of type ``\"string\"``, the command line ::" msgstr "" -#: ../../library/optparse.rst:2115 +#: ../../library/optparse.rst:2112 msgid "--names=foo,bar --names blah --names ding,dong" msgstr "--names=foo,bar --names blah --names ding,dong" -#: ../../library/optparse.rst:2117 +#: ../../library/optparse.rst:2114 msgid "would result in a list ::" msgstr "" -#: ../../library/optparse.rst:2119 +#: ../../library/optparse.rst:2116 msgid "[\"foo\", \"bar\", \"blah\", \"ding\", \"dong\"]" msgstr "[\"foo\", \"bar\", \"blah\", \"ding\", \"dong\"]" -#: ../../library/optparse.rst:2121 +#: ../../library/optparse.rst:2118 msgid "Again we define a subclass of Option::" msgstr "" -#: ../../library/optparse.rst:2123 +#: ../../library/optparse.rst:2120 msgid "" "class MyOption(Option):\n" "\n" @@ -3595,43 +3595,43 @@ msgstr "" " Option.take_action(\n" " self, action, dest, opt, value, values, parser)" -#: ../../library/optparse.rst:2138 +#: ../../library/optparse.rst:2135 msgid "Features of note:" msgstr "" -#: ../../library/optparse.rst:2140 +#: ../../library/optparse.rst:2137 msgid "" "``\"extend\"`` both expects a value on the command-line and stores that " "value somewhere, so it goes in both :attr:`~Option.STORE_ACTIONS` and :attr:" "`~Option.TYPED_ACTIONS`." msgstr "" -#: ../../library/optparse.rst:2144 +#: ../../library/optparse.rst:2141 msgid "" "to ensure that :mod:`!optparse` assigns the default type of ``\"string\"`` " "to ``\"extend\"`` actions, we put the ``\"extend\"`` action in :attr:" "`~Option.ALWAYS_TYPED_ACTIONS` as well." msgstr "" -#: ../../library/optparse.rst:2148 +#: ../../library/optparse.rst:2145 msgid "" ":meth:`MyOption.take_action` implements just this one new action, and passes " "control back to :meth:`Option.take_action` for the standard :mod:`!optparse` " "actions." msgstr "" -#: ../../library/optparse.rst:2152 +#: ../../library/optparse.rst:2149 msgid "" "``values`` is an instance of the optparse_parser.Values class, which " "provides the very useful :meth:`ensure_value` method. :meth:`ensure_value` " "is essentially :func:`getattr` with a safety valve; it is called as ::" msgstr "" -#: ../../library/optparse.rst:2156 +#: ../../library/optparse.rst:2153 msgid "values.ensure_value(attr, value)" msgstr "values.ensure_value(attr, value)" -#: ../../library/optparse.rst:2158 +#: ../../library/optparse.rst:2155 msgid "" "If the ``attr`` attribute of ``values`` doesn't exist or is ``None``, then " "ensure_value() first sets it to ``value``, and then returns ``value``. This " @@ -3644,28 +3644,28 @@ msgid "" "meth:`ensure_value` will take care of getting it right when it's needed." msgstr "" -#: ../../library/optparse.rst:2169 +#: ../../library/optparse.rst:2166 msgid "Exceptions" msgstr "例外" -#: ../../library/optparse.rst:2173 +#: ../../library/optparse.rst:2170 msgid "" "Raised if an :class:`Option` instance is created with invalid or " "inconsistent arguments." msgstr "" -#: ../../library/optparse.rst:2178 +#: ../../library/optparse.rst:2175 msgid "Raised if conflicting options are added to an :class:`OptionParser`." msgstr "" -#: ../../library/optparse.rst:2182 +#: ../../library/optparse.rst:2179 msgid "Raised if an invalid option value is encountered on the command line." msgstr "" -#: ../../library/optparse.rst:2186 +#: ../../library/optparse.rst:2183 msgid "Raised if an invalid option is passed on the command line." msgstr "" -#: ../../library/optparse.rst:2190 +#: ../../library/optparse.rst:2187 msgid "Raised if an ambiguous option is passed on the command line." msgstr "" diff --git a/library/os.path.po b/library/os.path.po index 254a46cb58a..9ca91f54032 100644 --- a/library/os.path.po +++ b/library/os.path.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-14 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-07-13 14:06+0800\n" "Last-Translator: Po-Chuan Chen \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -134,18 +134,18 @@ msgid ":func:`os.path.join` and :func:`os.path.normpath`." msgstr ":func:`os.path.join` 和 :func:`os.path.normpath`。" #: ../../library/os.path.rst:76 ../../library/os.path.rst:89 -#: ../../library/os.path.rst:132 ../../library/os.path.rst:141 -#: ../../library/os.path.rst:157 ../../library/os.path.rst:167 -#: ../../library/os.path.rst:193 ../../library/os.path.rst:213 -#: ../../library/os.path.rst:230 ../../library/os.path.rst:242 -#: ../../library/os.path.rst:251 ../../library/os.path.rst:263 -#: ../../library/os.path.rst:277 ../../library/os.path.rst:287 -#: ../../library/os.path.rst:306 ../../library/os.path.rst:326 -#: ../../library/os.path.rst:412 ../../library/os.path.rst:432 -#: ../../library/os.path.rst:475 ../../library/os.path.rst:504 -#: ../../library/os.path.rst:520 ../../library/os.path.rst:531 -#: ../../library/os.path.rst:558 ../../library/os.path.rst:583 -#: ../../library/os.path.rst:647 +#: ../../library/os.path.rst:132 ../../library/os.path.rst:149 +#: ../../library/os.path.rst:165 ../../library/os.path.rst:175 +#: ../../library/os.path.rst:201 ../../library/os.path.rst:221 +#: ../../library/os.path.rst:238 ../../library/os.path.rst:250 +#: ../../library/os.path.rst:259 ../../library/os.path.rst:271 +#: ../../library/os.path.rst:285 ../../library/os.path.rst:295 +#: ../../library/os.path.rst:314 ../../library/os.path.rst:334 +#: ../../library/os.path.rst:420 ../../library/os.path.rst:440 +#: ../../library/os.path.rst:485 ../../library/os.path.rst:521 +#: ../../library/os.path.rst:537 ../../library/os.path.rst:548 +#: ../../library/os.path.rst:575 ../../library/os.path.rst:600 +#: ../../library/os.path.rst:664 msgid "Accepts a :term:`path-like object`." msgstr "接受一個 :term:`path-like object`。" @@ -215,7 +215,17 @@ msgstr "" ">>> os.path.commonpath(['/usr/lib', '/usr/local/lib'])\n" "'/usr'" -#: ../../library/os.path.rst:138 +#: ../../library/os.path.rst:135 +msgid "" +"Deprecated in favor of :func:`os.path.commonpath` for path prefixes. The :" +"func:`os.path.commonprefix` function is being deprecated due to having a " +"misleading name and module. The function is not safe to use for path " +"prefixes despite being included in a module about path manipulation, meaning " +"it is easy to accidentally introduce path traversal vulnerabilities into " +"Python programs by using this function." +msgstr "" + +#: ../../library/os.path.rst:146 msgid "" "Return the directory name of pathname *path*. This is the first element of " "the pair returned by passing *path* to the function :func:`split`." @@ -223,7 +233,7 @@ msgstr "" "回傳路徑名 *path* 的目錄名稱。這是將 *path* 傳遞給函式 :func:`split` 後回傳之" "成對結果中的第一個元素。" -#: ../../library/os.path.rst:147 +#: ../../library/os.path.rst:155 msgid "" "Return ``True`` if *path* refers to an existing path or an open file " "descriptor. Returns ``False`` for broken symbolic links. On some " @@ -235,7 +245,7 @@ msgstr "" "的符號連結則回傳 ``False``。在某些平台上,即使 *path* 實際存在,如果未被授予" "執行 :func:`os.stat` 的權限,此函式仍可能回傳 ``False``。" -#: ../../library/os.path.rst:153 +#: ../../library/os.path.rst:161 msgid "" "*path* can now be an integer: ``True`` is returned if it is an open file " "descriptor, ``False`` otherwise." @@ -243,7 +253,7 @@ msgstr "" "現在 *path* 可以是一個整數:如果它是一個開啟的檔案描述器,則回傳 ``True``;否" "則回傳 ``False``。" -#: ../../library/os.path.rst:163 +#: ../../library/os.path.rst:171 msgid "" "Return ``True`` if *path* refers to an existing path, including broken " "symbolic links. Equivalent to :func:`exists` on platforms lacking :func:" @@ -252,7 +262,7 @@ msgstr "" "如果 *path* 是一個存在的路徑則回傳 ``True``,對已損壞的符號連結也是。在缺乏 :" "func:`os.lstat` 的平台上,與 :func:`exists` 函式等效。" -#: ../../library/os.path.rst:175 +#: ../../library/os.path.rst:183 msgid "" "On Unix and Windows, return the argument with an initial component of ``~`` " "or ``~user`` replaced by that *user*'s home directory." @@ -260,7 +270,7 @@ msgstr "" "在 Unix 和 Windows 上,將引數中以 ``~`` 或 ``~user`` 開頭的部分替換為該 " "*user* 的家目錄。" -#: ../../library/os.path.rst:180 +#: ../../library/os.path.rst:188 msgid "" "On Unix, an initial ``~`` is replaced by the environment variable :envvar:" "`HOME` if it is set; otherwise the current user's home directory is looked " @@ -271,7 +281,7 @@ msgstr "" "數的值;否則將使用內建模組 :mod:`pwd` 在密碼目錄中查找目前使用者的家目錄。對" "於初始的 ``~user``,直接在密碼目錄中查找該使用者的家目錄。" -#: ../../library/os.path.rst:185 +#: ../../library/os.path.rst:193 msgid "" "On Windows, :envvar:`USERPROFILE` will be used if set, otherwise a " "combination of :envvar:`HOMEPATH` and :envvar:`HOMEDRIVE` will be used. An " @@ -284,18 +294,18 @@ msgstr "" "目前使用者的家目錄的最後一個目錄元件是否與 :envvar:`USERNAME` 相符,如果相符" "則替換它。" -#: ../../library/os.path.rst:190 +#: ../../library/os.path.rst:198 msgid "" "If the expansion fails or if the path does not begin with a tilde, the path " "is returned unchanged." msgstr "" "如果展開失敗或路徑不以波浪符號 (tilde) 開頭,則回傳原始路徑,不做任何變更。" -#: ../../library/os.path.rst:196 +#: ../../library/os.path.rst:204 msgid "No longer uses :envvar:`HOME` on Windows." msgstr "在 Windows 上不再使用 :envvar:`HOME` 變數。" -#: ../../library/os.path.rst:205 +#: ../../library/os.path.rst:213 msgid "" "Return the argument with environment variables expanded. Substrings of the " "form ``$name`` or ``${name}`` are replaced by the value of environment " @@ -305,7 +315,7 @@ msgstr "" "回傳已展開環境變數的引數。形如 ``$name`` 或 ``${name}`` 的子字串會被替換為環" "境變數 *name* 的值。無效的變數名稱和對不存在變數的引用保持不變。" -#: ../../library/os.path.rst:210 +#: ../../library/os.path.rst:218 msgid "" "On Windows, ``%name%`` expansions are supported in addition to ``$name`` and " "``${name}``." @@ -313,7 +323,7 @@ msgstr "" "在 Windows 上,除了支援 ``$name`` 和 ``${name}`` 形式的展開外,還支援 " "``%name%`` 形式的展開。" -#: ../../library/os.path.rst:219 +#: ../../library/os.path.rst:227 msgid "" "Return the time of last access of *path*. The return value is a floating-" "point number giving the number of seconds since the epoch (see the :mod:" @@ -323,7 +333,7 @@ msgstr "" "回傳 *path* 的最後存取時間。回傳值是一個浮點數,表示自紀元(參見 :mod:`time` " "模組)以來的秒數。如果檔案不存在或無法存取,則引發 :exc:`OSError`。" -#: ../../library/os.path.rst:226 +#: ../../library/os.path.rst:234 msgid "" "Return the time of last modification of *path*. The return value is a " "floating-point number giving the number of seconds since the epoch (see " @@ -333,7 +343,7 @@ msgstr "" "回傳 *path* 的最後修改時間。回傳值是一個浮點數,表示自紀元(參見 :mod:`time` " "模組)以來的秒數。如果檔案不存在或無法存取,則引發 :exc:`OSError`。" -#: ../../library/os.path.rst:236 +#: ../../library/os.path.rst:244 msgid "" "Return the system's ctime which, on some systems (like Unix) is the time of " "the last metadata change, and, on others (like Windows), is the creation " @@ -346,7 +356,7 @@ msgstr "" "數,表示自紀元(參見 :mod:`time` 模組)以來的秒數。如果檔案不存在或無法存" "取),則引發 :exc:`OSError`。" -#: ../../library/os.path.rst:248 +#: ../../library/os.path.rst:256 msgid "" "Return the size, in bytes, of *path*. Raise :exc:`OSError` if the file does " "not exist or is inaccessible." @@ -354,7 +364,7 @@ msgstr "" "回傳 *path* 的大小(以位元組為單位)。如果檔案不存在或無法存取,則引發 :exc:" "`OSError`。" -#: ../../library/os.path.rst:257 +#: ../../library/os.path.rst:265 msgid "" "Return ``True`` if *path* is an absolute pathname. On Unix, that means it " "begins with a slash, on Windows that it begins with two (back)slashes, or a " @@ -364,17 +374,17 @@ msgstr "" "在 Windows 上,表示這是以兩個(反)斜線開頭或者以一個驅動機字母、冒號和(反)" "斜線開頭。" -#: ../../library/os.path.rst:261 +#: ../../library/os.path.rst:269 msgid ":func:`abspath`" msgstr ":func:`abspath`" -#: ../../library/os.path.rst:266 +#: ../../library/os.path.rst:274 msgid "" "On Windows, returns ``False`` if the given path starts with exactly one " "(back)slash." msgstr "" -#: ../../library/os.path.rst:273 +#: ../../library/os.path.rst:281 msgid "" "Return ``True`` if *path* is an :func:`existing ` regular file. This " "follows symbolic links, so both :func:`islink` and :func:`isfile` can be " @@ -384,7 +394,7 @@ msgstr "" "這將跟隨符號連結,因此同一個路徑可以同時回傳 :func:`islink` 和 :func:" "`isfile` 的結果為真。" -#: ../../library/os.path.rst:283 +#: ../../library/os.path.rst:291 msgid "" "Return ``True`` if *path* is an :func:`existing ` directory. This " "follows symbolic links, so both :func:`islink` and :func:`isdir` can be true " @@ -394,7 +404,7 @@ msgstr "" "跟隨符號連結,因此同一個路徑可以同時回傳 :func:`islink` 和 :func:`isdir` 的結" "果為真。" -#: ../../library/os.path.rst:293 +#: ../../library/os.path.rst:301 msgid "" "Return ``True`` if *path* refers to an :func:`existing ` directory " "entry that is a junction. Always return ``False`` if junctions are not " @@ -403,7 +413,7 @@ msgstr "" "如果 *path* 是指向\\ :func:`已存在的 `\\ 目錄條目且為聯接點 " "(junction),則回傳 ``True``。如果目前平台不支援聯接點,則始終返回 ``False``。" -#: ../../library/os.path.rst:302 +#: ../../library/os.path.rst:310 msgid "" "Return ``True`` if *path* refers to an :func:`existing ` directory " "entry that is a symbolic link. Always ``False`` if symbolic links are not " @@ -412,7 +422,7 @@ msgstr "" "如果 *path* 是指向\\ :func:`已存在的 `\\ 目錄項目且為符號連結,則回" "傳 ``True``。如果 Python 執行時不支援符號連結,則始終回傳 ``False``。" -#: ../../library/os.path.rst:312 +#: ../../library/os.path.rst:320 msgid "" "Return ``True`` if pathname *path* is a :dfn:`mount point`: a point in a " "file system where a different file system has been mounted. On POSIX, the " @@ -435,11 +445,11 @@ msgstr "" "在 Windows 上,以驅動機字母開頭的根目錄和 UNC 共享路徑始終是掛載點,對於任何" "其他路徑,會呼叫 ``GetVolumePathName`` 函式來檢查它是否與輸入路徑不同。" -#: ../../library/os.path.rst:323 +#: ../../library/os.path.rst:331 msgid "Added support for detecting non-root mount points on Windows." msgstr "新增在 Windows 上檢測非根目錄掛載點的支援。" -#: ../../library/os.path.rst:332 +#: ../../library/os.path.rst:340 msgid "" "Return ``True`` if pathname *path* is located on a Windows Dev Drive. A Dev " "Drive is optimized for developer scenarios, and offers faster performance " @@ -451,7 +461,7 @@ msgstr "" "開發人員場景進行了最佳化,提供更快的讀寫檔案性能。建議將其用於原始程式碼、臨" "時建置目錄、封包快取和其他 I/O 密集型操作。" -#: ../../library/os.path.rst:338 +#: ../../library/os.path.rst:346 msgid "" "May raise an error for an invalid path, for example, one without a " "recognizable drive, but returns ``False`` on platforms that do not support " @@ -462,17 +472,17 @@ msgstr "" "碟機的平台上回傳 ``False``。請參閱 `Windows 文件 `_\\ 以了解有關啟用和建立 Dev 驅動機的資訊。" -#: ../../library/os.path.rst:345 +#: ../../library/os.path.rst:353 msgid "" "The function is now available on all platforms, and will always return " "``False`` on those that have no support for Dev Drives" msgstr "" -#: ../../library/os.path.rst:351 +#: ../../library/os.path.rst:359 msgid "Return ``True`` if *path* is a reserved pathname on the current system." msgstr "" -#: ../../library/os.path.rst:353 +#: ../../library/os.path.rst:361 msgid "" "On Windows, reserved filenames include those that end with a space or dot; " "those that contain colons (i.e. file streams such as \"name:stream\"), " @@ -481,7 +491,7 @@ msgid "" "\", \"AUX\", \"PRN\", \"COM1\", and \"LPT1\"." msgstr "" -#: ../../library/os.path.rst:361 +#: ../../library/os.path.rst:369 msgid "" "This function approximates rules for reserved paths on most Windows systems. " "These rules change over time in various Windows releases. This function may " @@ -489,11 +499,11 @@ msgid "" "available." msgstr "" -#: ../../library/os.path.rst:366 +#: ../../library/os.path.rst:374 msgid "Availability" msgstr "可用性" -#: ../../library/os.path.rst:373 +#: ../../library/os.path.rst:381 msgid "" "Join one or more path segments intelligently. The return value is the " "concatenation of *path* and all members of *\\*paths*, with exactly one " @@ -505,14 +515,14 @@ msgstr "" "每個非空部分後面都有一個目錄分隔符號,除了最後一個部分。換句話說,如果最後一" "個部分為空或以分隔符號結尾,結果只會以分隔符號結尾。" -#: ../../library/os.path.rst:379 +#: ../../library/os.path.rst:387 msgid "" "If a segment is an absolute path (which on Windows requires both a drive and " "a root), then all previous segments are ignored and joining continues from " "the absolute path segment. On Linux, for example::" msgstr "" -#: ../../library/os.path.rst:383 +#: ../../library/os.path.rst:391 msgid "" ">>> os.path.join('/home/foo', 'bar')\n" "'/home/foo/bar'\n" @@ -520,7 +530,7 @@ msgid "" "'/home/bar'" msgstr "" -#: ../../library/os.path.rst:388 +#: ../../library/os.path.rst:396 msgid "" "On Windows, the drive is not reset when a rooted path segment (e.g., " "``r'\\foo'``) is encountered. If a segment is on a different drive or is an " @@ -531,7 +541,7 @@ msgstr "" "一個段位於不同的驅動機上,或者是絕對路徑,則將忽略所有之前的段並重置驅動機。" "例如: ::" -#: ../../library/os.path.rst:393 +#: ../../library/os.path.rst:401 msgid "" ">>> os.path.join('c:\\\\', 'foo')\n" "'c:\\\\foo'\n" @@ -539,7 +549,7 @@ msgid "" "'d:\\\\bar'" msgstr "" -#: ../../library/os.path.rst:398 +#: ../../library/os.path.rst:406 msgid "" "Note that since there is a current directory for each drive, ``os.path." "join(\"c:\", \"foo\")`` represents a path relative to the current directory " @@ -549,11 +559,11 @@ msgstr "" "對於驅動機 :file:`C:` 的目前目錄的路徑(:file:`c:foo`),而不是 :file:`c:\\" "\\foo`。" -#: ../../library/os.path.rst:402 +#: ../../library/os.path.rst:410 msgid "Accepts a :term:`path-like object` for *path* and *paths*." msgstr "*path* 和 *paths* 接受 :term:`path-like object` 作為參數。" -#: ../../library/os.path.rst:408 +#: ../../library/os.path.rst:416 msgid "" "Normalize the case of a pathname. On Windows, convert all characters in the " "pathname to lowercase, and also convert forward slashes to backward slashes. " @@ -562,7 +572,7 @@ msgstr "" "將路徑名的大小寫規範化。在 Windows 上,將路徑名中的所有字元轉換為小寫,並將正" "斜線轉換為反斜線。在其他作業系統上,回傳原始路徑。" -#: ../../library/os.path.rst:418 +#: ../../library/os.path.rst:426 msgid "" "Normalize a pathname by collapsing redundant separators and up-level " "references so that ``A//B``, ``A/B/``, ``A/./B`` and ``A/foo/../B`` all " @@ -575,7 +585,7 @@ msgstr "" "結的路徑的含義。在 Windows 上,它將正斜線轉換為反斜線。要標準化大小寫,請使" "用 :func:`normcase`。" -#: ../../library/os.path.rst:425 +#: ../../library/os.path.rst:433 msgid "" "On POSIX systems, in accordance with `IEEE Std 1003.1 2013 Edition; 4.13 " "Pathname Resolution >> splitdrive(\"c:/dir\")\n" "(\"c:\", \"/dir\")" @@ -777,12 +788,12 @@ msgstr "" ">>> splitdrive(\"c:/dir\")\n" "(\"c:\", \"/dir\")" -#: ../../library/os.path.rst:577 +#: ../../library/os.path.rst:594 msgid "" "If the path contains a UNC path, drive will contain the host name and share::" msgstr "如果路徑包含 UNC 路徑,則驅動機將包含主機名和共享名: ::" -#: ../../library/os.path.rst:580 +#: ../../library/os.path.rst:597 msgid "" ">>> splitdrive(\"//host/computer/dir\")\n" "(\"//host/computer\", \"/dir\")" @@ -790,7 +801,7 @@ msgstr "" ">>> splitdrive(\"//host/computer/dir\")\n" "(\"//host/computer\", \"/dir\")" -#: ../../library/os.path.rst:589 +#: ../../library/os.path.rst:606 msgid "" "Split the pathname *path* into a 3-item tuple ``(drive, root, tail)`` where " "*drive* is a device name or mount point, *root* is a string of separators " @@ -803,7 +814,7 @@ msgstr "" "這些項目中的任何一個都可能是空字串。在所有情況下,``drive + root + tail`` 將" "與 *path* 相同。" -#: ../../library/os.path.rst:595 +#: ../../library/os.path.rst:612 msgid "" "On POSIX systems, *drive* is always empty. The *root* may be empty (if " "*path* is relative), a single forward slash (if *path* is absolute), or two " @@ -817,7 +828,7 @@ msgstr "" "onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>`_ 的實作定義)。例" "如: ::" -#: ../../library/os.path.rst:601 +#: ../../library/os.path.rst:618 msgid "" ">>> splitroot('/home/sam')\n" "('', '/', 'home/sam')\n" @@ -833,7 +844,7 @@ msgstr "" ">>> splitroot('///home/sam')\n" "('', '/', '//home/sam')" -#: ../../library/os.path.rst:608 +#: ../../library/os.path.rst:625 msgid "" "On Windows, *drive* may be empty, a drive-letter name, a UNC share, or a " "device name. The *root* may be empty, a forward slash, or a backward slash. " @@ -842,7 +853,7 @@ msgstr "" "在 Windows 上,*drive* 可能為空、驅動機名稱、UNC 共享或設備名稱。*root* 可能" "為空,斜線或反斜線。例如: ::" -#: ../../library/os.path.rst:612 +#: ../../library/os.path.rst:629 msgid "" ">>> splitroot('C:/Users/Sam')\n" "('C:', '/', 'Users/Sam')\n" @@ -854,7 +865,7 @@ msgstr "" ">>> splitroot('//Server/Share/Users/Sam')\n" "('//Server/Share', '/', 'Users/Sam')" -#: ../../library/os.path.rst:622 +#: ../../library/os.path.rst:639 msgid "" "Split the pathname *path* into a pair ``(root, ext)`` such that ``root + " "ext == path``, and the extension, *ext*, is empty or begins with a period " @@ -863,11 +874,11 @@ msgstr "" "將路徑名 *path* 拆分為一對 ``(root, ext)``,使得 ``root + ext == path``,且副" "檔名 *ext* 為空或以點開頭且最多包含一個點 (period)。" -#: ../../library/os.path.rst:626 +#: ../../library/os.path.rst:643 msgid "If the path contains no extension, *ext* will be ``''``::" msgstr "如果路徑不包含副檔名,則 *ext* 將為 ``''``: ::" -#: ../../library/os.path.rst:628 +#: ../../library/os.path.rst:645 msgid "" ">>> splitext('bar')\n" "('bar', '')" @@ -875,7 +886,7 @@ msgstr "" ">>> splitext('bar')\n" "('bar', '')" -#: ../../library/os.path.rst:631 +#: ../../library/os.path.rst:648 msgid "" "If the path contains an extension, then *ext* will be set to this extension, " "including the leading period. Note that previous periods will be ignored::" @@ -883,7 +894,7 @@ msgstr "" "如果路徑包含副檔名,則 *ext* 將設置為該副檔名,包括前導的點。請注意,前面的點" "將被忽略: ::" -#: ../../library/os.path.rst:634 +#: ../../library/os.path.rst:651 msgid "" ">>> splitext('foo.bar.exe')\n" "('foo.bar', '.exe')\n" @@ -895,13 +906,13 @@ msgstr "" ">>> splitext('/foo/bar.exe')\n" "('/foo/bar', '.exe')" -#: ../../library/os.path.rst:639 +#: ../../library/os.path.rst:656 msgid "" "Leading periods of the last component of the path are considered to be part " "of the root::" msgstr "路徑的最後一個部份的前導點被認為是根的一部分: ::" -#: ../../library/os.path.rst:642 +#: ../../library/os.path.rst:659 msgid "" ">>> splitext('.cshrc')\n" "('.cshrc', '')\n" @@ -913,7 +924,7 @@ msgstr "" ">>> splitext('/foo/....jpg')\n" "('/foo/....jpg', '')" -#: ../../library/os.path.rst:653 +#: ../../library/os.path.rst:670 msgid "" "``True`` if arbitrary Unicode strings can be used as file names (within " "limitations imposed by the file system)." @@ -929,34 +940,34 @@ msgstr "path(路徑)" msgid "operations" msgstr "operations(操作)" -#: ../../library/os.path.rst:171 +#: ../../library/os.path.rst:179 msgid "~ (tilde)" msgstr "~ (波浪號)" -#: ../../library/os.path.rst:171 +#: ../../library/os.path.rst:179 msgid "home directory expansion" msgstr "home directory expansion(家目錄展開)" -#: ../../library/os.path.rst:178 +#: ../../library/os.path.rst:186 msgid "module" msgstr "module(模組)" -#: ../../library/os.path.rst:178 +#: ../../library/os.path.rst:186 msgid "pwd" msgstr "pwd" -#: ../../library/os.path.rst:199 +#: ../../library/os.path.rst:207 msgid "$ (dollar)" msgstr "$ (金錢符號)" -#: ../../library/os.path.rst:199 +#: ../../library/os.path.rst:207 msgid "environment variables expansion" msgstr "environment variables expansion(環境變數展開)" -#: ../../library/os.path.rst:199 +#: ../../library/os.path.rst:207 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/os.path.rst:199 +#: ../../library/os.path.rst:207 msgid "environment variables expansion (Windows)" msgstr "environment variables expansion (Windows)(環境變數展開 (Windows))" diff --git a/library/os.po b/library/os.po index e2016af2e3a..c6d98e88bcc 100644 --- a/library/os.po +++ b/library/os.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-15 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-04-29 15:24+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -121,7 +121,7 @@ msgid "" "dependent version information." msgstr "" -#: ../../library/os.rst:66 ../../library/os.rst:804 +#: ../../library/os.rst:66 ../../library/os.rst:813 msgid "" "The :mod:`platform` module provides detailed checks for the system's " "identity." @@ -177,7 +177,14 @@ msgstr "Python UTF-8 模式" msgid "See :pep:`540` for more details." msgstr "更多資訊請見 :pep:`540`。" -#: ../../library/os.rst:111 +#: ../../library/os.rst:113 +msgid "" +"Python UTF-8 mode is now enabled by default (:pep:`686`). It may be disabled " +"by setting :envvar:`PYTHONUTF8=0 ` as an environment variable or " +"by using the :option:`-X utf8=0 <-X>` command line option." +msgstr "" + +#: ../../library/os.rst:117 msgid "" "The Python UTF-8 Mode ignores the :term:`locale encoding` and forces the " "usage of the UTF-8 encoding:" @@ -185,17 +192,17 @@ msgstr "" "Python 在 UTF-8 模式下會忽略 :term:`locale encoding` 並且強制使用 UTF-8 去編" "碼:" -#: ../../library/os.rst:114 +#: ../../library/os.rst:120 msgid "" "Use UTF-8 as the :term:`filesystem encoding `." msgstr "" -#: ../../library/os.rst:116 +#: ../../library/os.rst:122 msgid ":func:`sys.getfilesystemencoding` returns ``'utf-8'``." msgstr ":func:`sys.getfilesystemencoding` 回傳 ``'utf-8'``。" -#: ../../library/os.rst:117 +#: ../../library/os.rst:123 msgid "" ":func:`locale.getpreferredencoding` returns ``'utf-8'`` (the *do_setlocale* " "argument has no effect)." @@ -203,7 +210,7 @@ msgstr "" ":func:`locale.getpreferredencoding` 回傳 ``'utf-8'``\\ (*do_setlocale* 引數" "並無任何效果)。" -#: ../../library/os.rst:119 +#: ../../library/os.rst:125 msgid "" ":data:`sys.stdin`, :data:`sys.stdout`, and :data:`sys.stderr` all use UTF-8 " "as their text encoding, with the ``surrogateescape`` :ref:`error handler " @@ -212,13 +219,13 @@ msgid "" "default locale-aware mode)" msgstr "" -#: ../../library/os.rst:124 +#: ../../library/os.rst:130 msgid "" "On Unix, :func:`os.device_encoding` returns ``'utf-8'`` rather than the " "device encoding." msgstr "在 Unix 中,:func:`os.device_encoding` 回傳 ``'utf-8'`` 而非裝置編碼。" -#: ../../library/os.rst:127 +#: ../../library/os.rst:133 msgid "" "Note that the standard stream settings in UTF-8 mode can be overridden by :" "envvar:`PYTHONIOENCODING` (just as they can be in the default locale-aware " @@ -227,23 +234,23 @@ msgstr "" "請注意,在 UTF-8 模式中,標準的串流設定會被 :envvar:`PYTHONIOENCODING` 覆蓋" "(如同在預設在地化覺察 模式一樣)。" -#: ../../library/os.rst:131 +#: ../../library/os.rst:137 msgid "" "As a consequence of the changes in those lower level APIs, other higher " "level APIs also exhibit different default behaviours:" msgstr "" -#: ../../library/os.rst:134 +#: ../../library/os.rst:140 msgid "" "Command line arguments, environment variables and filenames are decoded to " "text using the UTF-8 encoding." msgstr "命令列引數、環境變數及檔案名稱會以 UTF-8 編碼形式來被解碼成文字。" -#: ../../library/os.rst:136 +#: ../../library/os.rst:142 msgid ":func:`os.fsdecode` and :func:`os.fsencode` use the UTF-8 encoding." msgstr ":func:`os.fsdecode` 和 :func:`os.fsencode` 使用 UTF-8 編碼。" -#: ../../library/os.rst:137 +#: ../../library/os.rst:143 msgid "" ":func:`open`, :func:`io.open`, and :func:`codecs.open` use the UTF-8 " "encoding by default. However, they still use the strict error handler by " @@ -251,161 +258,152 @@ msgid "" "raise an exception rather than producing nonsense data." msgstr "" -#: ../../library/os.rst:142 -msgid "" -"The :ref:`Python UTF-8 Mode ` is enabled if the LC_CTYPE locale " -"is ``C`` or ``POSIX`` at Python startup (see the :c:func:`PyConfig_Read` " -"function)." -msgstr "" - -#: ../../library/os.rst:146 +#: ../../library/os.rst:148 msgid "" -"It can be enabled or disabled using the :option:`-X utf8 <-X>` command line " -"option and the :envvar:`PYTHONUTF8` environment variable." +"The :ref:`Python UTF-8 Mode ` is enabled by default. It can be " +"disabled using the :option:`-X utf8=0 <-X>` command line option or the :" +"envvar:`PYTHONUTF8=0 ` environment variable. The Python UTF-8 " +"Mode can only be disabled at Python startup. Its value can be read from :" +"data:`sys.flags.utf8_mode `." msgstr "" -#: ../../library/os.rst:149 +#: ../../library/os.rst:154 msgid "" -"If the :envvar:`PYTHONUTF8` environment variable is not set at all, then the " -"interpreter defaults to using the current locale settings, *unless* the " -"current locale is identified as a legacy ASCII-based locale (as described " -"for :envvar:`PYTHONCOERCECLOCALE`), and locale coercion is either disabled " -"or fails. In such legacy locales, the interpreter will default to enabling " -"UTF-8 mode unless explicitly instructed not to do so." +"If the UTF-8 mode is disabled, the interpreter defaults to using the current " +"locale settings, *unless* the current locale is identified as a legacy ASCII-" +"based locale (as described for :envvar:`PYTHONCOERCECLOCALE`), and locale " +"coercion is either disabled or fails. In such legacy locales, the " +"interpreter will default to enabling UTF-8 mode unless explicitly instructed " +"not to do so." msgstr "" -#: ../../library/os.rst:156 -msgid "" -"The Python UTF-8 Mode can only be enabled at the Python startup. Its value " -"can be read from :data:`sys.flags.utf8_mode `." -msgstr "" - -#: ../../library/os.rst:159 +#: ../../library/os.rst:161 msgid "" "See also the :ref:`UTF-8 mode on Windows ` and the :term:" "`filesystem encoding and error handler`." msgstr "" -#: ../../library/os.rst:164 -msgid ":pep:`686`" -msgstr ":pep:`686`" - -#: ../../library/os.rst:165 -msgid "Python 3.15 will make :ref:`utf8-mode` default." -msgstr "Python 3.15 預設使用 :ref:`utf8-mode`" - -#: ../../library/os.rst:171 +#: ../../library/os.rst:168 msgid "Process Parameters" msgstr "行程參數" -#: ../../library/os.rst:173 +#: ../../library/os.rst:170 msgid "" "These functions and data items provide information and operate on the " "current process and user." msgstr "" -#: ../../library/os.rst:179 +#: ../../library/os.rst:176 msgid "" "Return the filename corresponding to the controlling terminal of the process." msgstr "" -#: ../../library/os.rst:181 ../../library/os.rst:345 ../../library/os.rst:360 -#: ../../library/os.rst:381 ../../library/os.rst:390 ../../library/os.rst:399 -#: ../../library/os.rst:412 ../../library/os.rst:421 ../../library/os.rst:449 -#: ../../library/os.rst:457 ../../library/os.rst:465 ../../library/os.rst:485 -#: ../../library/os.rst:503 ../../library/os.rst:514 ../../library/os.rst:526 -#: ../../library/os.rst:535 ../../library/os.rst:545 ../../library/os.rst:556 -#: ../../library/os.rst:568 ../../library/os.rst:604 ../../library/os.rst:611 -#: ../../library/os.rst:618 ../../library/os.rst:627 ../../library/os.rst:664 -#: ../../library/os.rst:677 ../../library/os.rst:686 ../../library/os.rst:703 -#: ../../library/os.rst:712 ../../library/os.rst:719 ../../library/os.rst:728 -#: ../../library/os.rst:737 ../../library/os.rst:744 ../../library/os.rst:751 -#: ../../library/os.rst:760 ../../library/os.rst:807 ../../library/os.rst:883 -#: ../../library/os.rst:1005 ../../library/os.rst:1031 -#: ../../library/os.rst:1044 ../../library/os.rst:1061 -#: ../../library/os.rst:1079 ../../library/os.rst:1090 -#: ../../library/os.rst:1110 ../../library/os.rst:1131 -#: ../../library/os.rst:1143 ../../library/os.rst:1154 -#: ../../library/os.rst:1167 ../../library/os.rst:1188 -#: ../../library/os.rst:1209 ../../library/os.rst:1221 -#: ../../library/os.rst:1232 ../../library/os.rst:1293 -#: ../../library/os.rst:1416 ../../library/os.rst:1428 -#: ../../library/os.rst:1442 ../../library/os.rst:1452 -#: ../../library/os.rst:1467 ../../library/os.rst:1482 -#: ../../library/os.rst:1495 ../../library/os.rst:1512 -#: ../../library/os.rst:1538 ../../library/os.rst:1555 -#: ../../library/os.rst:1569 ../../library/os.rst:1584 -#: ../../library/os.rst:1596 ../../library/os.rst:1623 -#: ../../library/os.rst:1635 ../../library/os.rst:1645 -#: ../../library/os.rst:1659 ../../library/os.rst:1738 -#: ../../library/os.rst:1758 ../../library/os.rst:1767 -#: ../../library/os.rst:1779 ../../library/os.rst:1833 -#: ../../library/os.rst:1857 ../../library/os.rst:1867 -#: ../../library/os.rst:1875 ../../library/os.rst:1884 -#: ../../library/os.rst:1895 ../../library/os.rst:1932 -#: ../../library/os.rst:1959 ../../library/os.rst:2011 -#: ../../library/os.rst:2017 ../../library/os.rst:2188 -#: ../../library/os.rst:2265 ../../library/os.rst:2282 -#: ../../library/os.rst:2296 ../../library/os.rst:2322 -#: ../../library/os.rst:2340 ../../library/os.rst:2356 -#: ../../library/os.rst:2373 ../../library/os.rst:2436 -#: ../../library/os.rst:2460 ../../library/os.rst:2480 -#: ../../library/os.rst:2616 ../../library/os.rst:2638 -#: ../../library/os.rst:2682 ../../library/os.rst:2694 -#: ../../library/os.rst:2716 ../../library/os.rst:3422 -#: ../../library/os.rst:3508 ../../library/os.rst:3516 -#: ../../library/os.rst:3524 ../../library/os.rst:3532 -#: ../../library/os.rst:3540 ../../library/os.rst:3548 -#: ../../library/os.rst:3556 ../../library/os.rst:3564 -#: ../../library/os.rst:3572 ../../library/os.rst:3580 -#: ../../library/os.rst:3701 ../../library/os.rst:3724 -#: ../../library/os.rst:3738 ../../library/os.rst:3958 -#: ../../library/os.rst:3983 ../../library/os.rst:4008 -#: ../../library/os.rst:4062 ../../library/os.rst:4071 -#: ../../library/os.rst:4080 ../../library/os.rst:4088 -#: ../../library/os.rst:4097 ../../library/os.rst:4106 -#: ../../library/os.rst:4179 ../../library/os.rst:4241 -#: ../../library/os.rst:4251 ../../library/os.rst:4269 -#: ../../library/os.rst:4278 ../../library/os.rst:4288 -#: ../../library/os.rst:4298 ../../library/os.rst:4308 -#: ../../library/os.rst:4319 ../../library/os.rst:4464 -#: ../../library/os.rst:4533 ../../library/os.rst:4568 -#: ../../library/os.rst:4576 ../../library/os.rst:4583 -#: ../../library/os.rst:4590 ../../library/os.rst:4597 -#: ../../library/os.rst:4604 ../../library/os.rst:4611 -#: ../../library/os.rst:4618 ../../library/os.rst:4626 -#: ../../library/os.rst:4634 ../../library/os.rst:4641 -#: ../../library/os.rst:4648 ../../library/os.rst:4657 -#: ../../library/os.rst:4665 ../../library/os.rst:4673 -#: ../../library/os.rst:4680 ../../library/os.rst:4687 -#: ../../library/os.rst:4736 ../../library/os.rst:4763 -#: ../../library/os.rst:4786 ../../library/os.rst:4802 -#: ../../library/os.rst:4809 ../../library/os.rst:4820 -#: ../../library/os.rst:4830 ../../library/os.rst:4839 -#: ../../library/os.rst:4871 ../../library/os.rst:4982 -#: ../../library/os.rst:4998 ../../library/os.rst:5031 -#: ../../library/os.rst:5100 ../../library/os.rst:5122 -#: ../../library/os.rst:5133 ../../library/os.rst:5145 -#: ../../library/os.rst:5190 ../../library/os.rst:5227 -#: ../../library/os.rst:5250 ../../library/os.rst:5271 -#: ../../library/os.rst:5305 ../../library/os.rst:5346 -#: ../../library/os.rst:5366 ../../library/os.rst:5380 -#: ../../library/os.rst:5397 ../../library/os.rst:5412 -#: ../../library/os.rst:5423 ../../library/os.rst:5435 -#: ../../library/os.rst:5448 ../../library/os.rst:5457 -#: ../../library/os.rst:5467 ../../library/os.rst:5480 -#: ../../library/os.rst:5515 ../../library/os.rst:5531 -#: ../../library/os.rst:5542 ../../library/os.rst:5554 -#: ../../library/os.rst:5561 ../../library/os.rst:5570 -#: ../../library/os.rst:5579 ../../library/os.rst:5588 -#: ../../library/os.rst:5597 ../../library/os.rst:5761 -#: ../../library/os.rst:5770 ../../library/os.rst:5794 -#: ../../library/os.rst:5821 ../../library/os.rst:5830 -#: ../../library/os.rst:5953 +#: ../../library/os.rst:178 ../../library/os.rst:354 ../../library/os.rst:369 +#: ../../library/os.rst:390 ../../library/os.rst:399 ../../library/os.rst:408 +#: ../../library/os.rst:421 ../../library/os.rst:430 ../../library/os.rst:458 +#: ../../library/os.rst:466 ../../library/os.rst:474 ../../library/os.rst:494 +#: ../../library/os.rst:512 ../../library/os.rst:523 ../../library/os.rst:535 +#: ../../library/os.rst:544 ../../library/os.rst:554 ../../library/os.rst:565 +#: ../../library/os.rst:577 ../../library/os.rst:613 ../../library/os.rst:620 +#: ../../library/os.rst:627 ../../library/os.rst:636 ../../library/os.rst:673 +#: ../../library/os.rst:686 ../../library/os.rst:695 ../../library/os.rst:712 +#: ../../library/os.rst:721 ../../library/os.rst:728 ../../library/os.rst:737 +#: ../../library/os.rst:746 ../../library/os.rst:753 ../../library/os.rst:760 +#: ../../library/os.rst:769 ../../library/os.rst:816 ../../library/os.rst:892 +#: ../../library/os.rst:1014 ../../library/os.rst:1040 +#: ../../library/os.rst:1053 ../../library/os.rst:1070 +#: ../../library/os.rst:1088 ../../library/os.rst:1099 +#: ../../library/os.rst:1119 ../../library/os.rst:1140 +#: ../../library/os.rst:1152 ../../library/os.rst:1163 +#: ../../library/os.rst:1176 ../../library/os.rst:1197 +#: ../../library/os.rst:1218 ../../library/os.rst:1230 +#: ../../library/os.rst:1241 ../../library/os.rst:1302 +#: ../../library/os.rst:1425 ../../library/os.rst:1437 +#: ../../library/os.rst:1451 ../../library/os.rst:1461 +#: ../../library/os.rst:1476 ../../library/os.rst:1491 +#: ../../library/os.rst:1504 ../../library/os.rst:1521 +#: ../../library/os.rst:1548 ../../library/os.rst:1565 +#: ../../library/os.rst:1579 ../../library/os.rst:1588 +#: ../../library/os.rst:1597 ../../library/os.rst:1612 +#: ../../library/os.rst:1624 ../../library/os.rst:1653 +#: ../../library/os.rst:1665 ../../library/os.rst:1675 +#: ../../library/os.rst:1689 ../../library/os.rst:1768 +#: ../../library/os.rst:1788 ../../library/os.rst:1797 +#: ../../library/os.rst:1809 ../../library/os.rst:1863 +#: ../../library/os.rst:1887 ../../library/os.rst:1897 +#: ../../library/os.rst:1905 ../../library/os.rst:1914 +#: ../../library/os.rst:1925 ../../library/os.rst:1962 +#: ../../library/os.rst:1989 ../../library/os.rst:2041 +#: ../../library/os.rst:2047 ../../library/os.rst:2218 +#: ../../library/os.rst:2295 ../../library/os.rst:2312 +#: ../../library/os.rst:2326 ../../library/os.rst:2352 +#: ../../library/os.rst:2370 ../../library/os.rst:2386 +#: ../../library/os.rst:2403 ../../library/os.rst:2470 +#: ../../library/os.rst:2494 ../../library/os.rst:2514 +#: ../../library/os.rst:2662 ../../library/os.rst:2684 +#: ../../library/os.rst:2735 ../../library/os.rst:2747 +#: ../../library/os.rst:2769 ../../library/os.rst:3489 +#: ../../library/os.rst:3521 ../../library/os.rst:3531 +#: ../../library/os.rst:3541 ../../library/os.rst:3551 +#: ../../library/os.rst:3625 ../../library/os.rst:3635 +#: ../../library/os.rst:3645 ../../library/os.rst:3674 +#: ../../library/os.rst:3734 ../../library/os.rst:3746 +#: ../../library/os.rst:3775 ../../library/os.rst:3785 +#: ../../library/os.rst:3794 ../../library/os.rst:3806 +#: ../../library/os.rst:3818 ../../library/os.rst:3832 +#: ../../library/os.rst:3918 ../../library/os.rst:3926 +#: ../../library/os.rst:3934 ../../library/os.rst:3942 +#: ../../library/os.rst:3950 ../../library/os.rst:3958 +#: ../../library/os.rst:3966 ../../library/os.rst:3974 +#: ../../library/os.rst:3982 ../../library/os.rst:3990 +#: ../../library/os.rst:4111 ../../library/os.rst:4134 +#: ../../library/os.rst:4148 ../../library/os.rst:4372 +#: ../../library/os.rst:4397 ../../library/os.rst:4422 +#: ../../library/os.rst:4476 ../../library/os.rst:4485 +#: ../../library/os.rst:4494 ../../library/os.rst:4502 +#: ../../library/os.rst:4511 ../../library/os.rst:4520 +#: ../../library/os.rst:4593 ../../library/os.rst:4655 +#: ../../library/os.rst:4665 ../../library/os.rst:4683 +#: ../../library/os.rst:4692 ../../library/os.rst:4702 +#: ../../library/os.rst:4712 ../../library/os.rst:4722 +#: ../../library/os.rst:4733 ../../library/os.rst:4882 +#: ../../library/os.rst:4951 ../../library/os.rst:4986 +#: ../../library/os.rst:4994 ../../library/os.rst:5001 +#: ../../library/os.rst:5008 ../../library/os.rst:5015 +#: ../../library/os.rst:5022 ../../library/os.rst:5029 +#: ../../library/os.rst:5036 ../../library/os.rst:5044 +#: ../../library/os.rst:5052 ../../library/os.rst:5059 +#: ../../library/os.rst:5066 ../../library/os.rst:5075 +#: ../../library/os.rst:5083 ../../library/os.rst:5091 +#: ../../library/os.rst:5098 ../../library/os.rst:5105 +#: ../../library/os.rst:5154 ../../library/os.rst:5186 +#: ../../library/os.rst:5209 ../../library/os.rst:5225 +#: ../../library/os.rst:5232 ../../library/os.rst:5243 +#: ../../library/os.rst:5253 ../../library/os.rst:5262 +#: ../../library/os.rst:5294 ../../library/os.rst:5405 +#: ../../library/os.rst:5421 ../../library/os.rst:5454 +#: ../../library/os.rst:5523 ../../library/os.rst:5545 +#: ../../library/os.rst:5556 ../../library/os.rst:5568 +#: ../../library/os.rst:5613 ../../library/os.rst:5650 +#: ../../library/os.rst:5673 ../../library/os.rst:5694 +#: ../../library/os.rst:5728 ../../library/os.rst:5769 +#: ../../library/os.rst:5789 ../../library/os.rst:5803 +#: ../../library/os.rst:5820 ../../library/os.rst:5835 +#: ../../library/os.rst:5846 ../../library/os.rst:5858 +#: ../../library/os.rst:5871 ../../library/os.rst:5880 +#: ../../library/os.rst:5890 ../../library/os.rst:5903 +#: ../../library/os.rst:5938 ../../library/os.rst:5954 +#: ../../library/os.rst:5965 ../../library/os.rst:5977 +#: ../../library/os.rst:5984 ../../library/os.rst:5993 +#: ../../library/os.rst:6002 ../../library/os.rst:6011 +#: ../../library/os.rst:6020 ../../library/os.rst:6184 +#: ../../library/os.rst:6193 ../../library/os.rst:6217 +#: ../../library/os.rst:6244 ../../library/os.rst:6253 +#: ../../library/os.rst:6376 msgid "Availability" msgstr "可用性" -#: ../../library/os.rst:186 +#: ../../library/os.rst:183 msgid "" "A :term:`mapping` object where keys and values are strings that represent " "the process environment. For example, ``environ['HOME']`` is the pathname " @@ -413,7 +411,7 @@ msgid "" "``getenv(\"HOME\")`` in C." msgstr "" -#: ../../library/os.rst:191 +#: ../../library/os.rst:188 msgid "" "This mapping is captured the first time the :mod:`!os` module is imported, " "typically during Python startup as part of processing :file:`site.py`. " @@ -422,28 +420,28 @@ msgid "" "directly." msgstr "" -#: ../../library/os.rst:196 +#: ../../library/os.rst:193 msgid "" "This mapping may be used to modify the environment as well as query the " "environment. :func:`putenv` will be called automatically when the mapping " "is modified." msgstr "" -#: ../../library/os.rst:200 +#: ../../library/os.rst:197 msgid "" "On Unix, keys and values use :func:`sys.getfilesystemencoding` and " "``'surrogateescape'`` error handler. Use :data:`environb` if you would like " "to use a different encoding." msgstr "" -#: ../../library/os.rst:204 +#: ../../library/os.rst:201 msgid "" "On Windows, the keys are converted to uppercase. This also applies when " "getting, setting, or deleting an item. For example, ``environ['monty'] = " "'python'`` maps the key ``'MONTY'`` to the value ``'python'``." msgstr "" -#: ../../library/os.rst:211 +#: ../../library/os.rst:208 msgid "" "Calling :func:`putenv` directly does not change :data:`os.environ`, so it's " "better to modify :data:`os.environ`." @@ -451,30 +449,55 @@ msgstr "" "呼叫 :func:`putenv` 並不會改變 :data:`os.environ`,所以建議直接修改 :data:" "`os.environ`。" -#: ../../library/os.rst:216 +#: ../../library/os.rst:213 msgid "" "On some platforms, including FreeBSD and macOS, setting ``environ`` may " "cause memory leaks. Refer to the system documentation for :c:func:`!putenv`." msgstr "" -#: ../../library/os.rst:220 +#: ../../library/os.rst:217 msgid "" "You can delete items in this mapping to unset environment variables. :func:" "`unsetenv` will be called automatically when an item is deleted from :data:" -"`os.environ`, and when one of the :meth:`pop` or :meth:`clear` methods is " -"called." +"`os.environ`, and when one of the :meth:`~dict.pop` or :meth:`~dict.clear` " +"methods is called." +msgstr "" + +#: ../../library/os.rst:222 +msgid "" +"If the :manpage:`clearenv(3)` function is available, the :meth:`~dict.clear` " +"method uses it and emits a single ``os._clearenv`` audit event. Otherwise, " +"it emits an ``os.unsetenv`` event on each deleted variable." +msgstr "" + +#: ../../library/os.rst:226 ../../library/os.rst:873 +msgid "" +"Raises an :ref:`auditing event ` ``os.unsetenv`` with argument " +"``key``." msgstr "" +"引發一個附帶引數 ``key`` 的\\ :ref:`稽核事件 ` ``os.unsetenv``。" + +#: ../../library/os.rst:228 +msgid "" +"Raises an :ref:`auditing event ` ``os._clearenv`` with no " +"arguments." +msgstr "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``os._clearenv``。" -#: ../../library/os.rst:227 +#: ../../library/os.rst:232 msgid "The :func:`os.reload_environ` function." msgstr ":func:`os.reload_environ` 函式。" -#: ../../library/os.rst:229 ../../library/os.rst:245 +#: ../../library/os.rst:234 ../../library/os.rst:254 msgid "" "Updated to support :pep:`584`'s merge (``|``) and update (``|=``) operators." msgstr "" -#: ../../library/os.rst:235 +#: ../../library/os.rst:237 +msgid "" +"The :meth:`~dict.clear` method can now emit an ``os._clearenv`` audit event." +msgstr "" + +#: ../../library/os.rst:244 msgid "" "Bytes version of :data:`environ`: a :term:`mapping` object where both keys " "and values are :class:`bytes` objects representing the process environment. :" @@ -482,13 +505,13 @@ msgid "" "`environb` updates :data:`environ`, and vice versa)." msgstr "" -#: ../../library/os.rst:240 +#: ../../library/os.rst:249 msgid "" ":data:`environb` is only available if :const:`supports_bytes_environ` is " "``True``." msgstr "" -#: ../../library/os.rst:251 +#: ../../library/os.rst:260 msgid "" "The :data:`os.environ` and :data:`os.environb` mappings are a cache of " "environment variables at the time that Python started. As such, changes to " @@ -498,7 +521,7 @@ msgid "" "to the current process environment." msgstr "" -#: ../../library/os.rst:259 +#: ../../library/os.rst:268 msgid "" "This function is not thread-safe. Calling it while the environment is being " "modified in another thread is an undefined behavior. Reading from :data:`os." @@ -506,41 +529,41 @@ msgid "" "reloading, may return an empty result." msgstr "" -#: ../../library/os.rst:272 +#: ../../library/os.rst:281 msgid "These functions are described in :ref:`os-file-dir`." msgstr "" -#: ../../library/os.rst:277 +#: ../../library/os.rst:286 msgid "" "Encode :term:`path-like ` *filename* to the :term:" "`filesystem encoding and error handler`; return :class:`bytes` unchanged." msgstr "" -#: ../../library/os.rst:281 +#: ../../library/os.rst:290 msgid ":func:`fsdecode` is the reverse function." msgstr ":func:`fsdecode` 是反函式。" -#: ../../library/os.rst:285 ../../library/os.rst:300 +#: ../../library/os.rst:294 ../../library/os.rst:309 msgid "" "Support added to accept objects implementing the :class:`os.PathLike` " "interface." msgstr "" -#: ../../library/os.rst:292 +#: ../../library/os.rst:301 msgid "" "Decode the :term:`path-like ` *filename* from the :term:" "`filesystem encoding and error handler`; return :class:`str` unchanged." msgstr "" -#: ../../library/os.rst:296 +#: ../../library/os.rst:305 msgid ":func:`fsencode` is the reverse function." msgstr ":func:`fsencode` 是反函式。" -#: ../../library/os.rst:307 +#: ../../library/os.rst:316 msgid "Return the file system representation of the path." msgstr "" -#: ../../library/os.rst:309 +#: ../../library/os.rst:318 msgid "" "If :class:`str` or :class:`bytes` is passed in, it is returned unchanged. " "Otherwise :meth:`~os.PathLike.__fspath__` is called and its value is " @@ -548,23 +571,23 @@ msgid "" "other cases, :exc:`TypeError` is raised." msgstr "" -#: ../../library/os.rst:319 +#: ../../library/os.rst:328 msgid "" "An :term:`abstract base class` for objects representing a file system path, " "e.g. :class:`pathlib.PurePath`." msgstr "" -#: ../../library/os.rst:327 +#: ../../library/os.rst:336 msgid "Return the file system path representation of the object." msgstr "" -#: ../../library/os.rst:329 +#: ../../library/os.rst:338 msgid "" "The method should only return a :class:`str` or :class:`bytes` object, with " "the preference being for :class:`str`." msgstr "" -#: ../../library/os.rst:335 +#: ../../library/os.rst:344 msgid "" "Return the value of the environment variable *key* as a string if it exists, " "or *default* if it doesn't. *key* is a string. Note that since :func:" @@ -573,14 +596,14 @@ msgid "" "changes." msgstr "" -#: ../../library/os.rst:341 +#: ../../library/os.rst:350 msgid "" "On Unix, keys and values are decoded with :func:`sys.getfilesystemencoding` " "and ``'surrogateescape'`` error handler. Use :func:`os.getenvb` if you would " "like to use a different encoding." msgstr "" -#: ../../library/os.rst:350 +#: ../../library/os.rst:359 msgid "" "Return the value of the environment variable *key* as bytes if it exists, or " "*default* if it doesn't. *key* must be bytes. Note that since :func:" @@ -589,13 +612,13 @@ msgid "" "environment changes." msgstr "" -#: ../../library/os.rst:357 +#: ../../library/os.rst:366 msgid "" ":func:`getenvb` is only available if :const:`supports_bytes_environ` is " "``True``." msgstr "" -#: ../../library/os.rst:367 +#: ../../library/os.rst:376 msgid "" "Returns the list of directories that will be searched for a named " "executable, similar to a shell, when launching a process. *env*, when " @@ -603,28 +626,28 @@ msgid "" "in. By default, when *env* is ``None``, :data:`environ` is used." msgstr "" -#: ../../library/os.rst:378 +#: ../../library/os.rst:387 msgid "" "Return the effective group id of the current process. This corresponds to " "the \"set id\" bit on the file being executed in the current process." msgstr "" -#: ../../library/os.rst:388 +#: ../../library/os.rst:397 msgid "Return the current process's effective user id." msgstr "" -#: ../../library/os.rst:397 +#: ../../library/os.rst:406 msgid "Return the real group id of the current process." msgstr "" -#: ../../library/os.rst:401 ../../library/os.rst:474 ../../library/os.rst:558 -#: ../../library/os.rst:783 +#: ../../library/os.rst:410 ../../library/os.rst:483 ../../library/os.rst:567 +#: ../../library/os.rst:792 msgid "" "The function is a stub on WASI, see :ref:`wasm-availability` for more " "information." msgstr "" -#: ../../library/os.rst:407 +#: ../../library/os.rst:416 msgid "" "Return list of group ids that *user* belongs to. If *group* is not in the " "list, it is included; typically, *group* is specified as the group ID field " @@ -632,12 +655,12 @@ msgid "" "potentially omitted." msgstr "" -#: ../../library/os.rst:419 +#: ../../library/os.rst:428 msgid "" "Return list of supplemental group ids associated with the current process." msgstr "" -#: ../../library/os.rst:425 +#: ../../library/os.rst:434 msgid "" "On macOS, :func:`getgroups` behavior differs somewhat from other Unix " "platforms. If the Python interpreter was built with a deployment target of " @@ -649,12 +672,12 @@ msgid "" "access list for the user associated with the effective user id of the " "process; the group access list may change over the lifetime of the process, " "it is not affected by calls to :func:`setgroups`, and its length is not " -"limited to 16. The deployment target value, :const:" -"`MACOSX_DEPLOYMENT_TARGET`, can be obtained with :func:`sysconfig." -"get_config_var`." +"limited to 16. The deployment target value can be obtained with :func:" +"`sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') `." msgstr "" -#: ../../library/os.rst:442 +#: ../../library/os.rst:451 msgid "" "Return the name of the user logged in on the controlling terminal of the " "process. For most purposes, it is more useful to use :func:`getpass." @@ -663,32 +686,32 @@ msgid "" "getpwuid(os.getuid())[0]`` to get the login name of the current real user id." msgstr "" -#: ../../library/os.rst:454 +#: ../../library/os.rst:463 msgid "" "Return the process group id of the process with process id *pid*. If *pid* " "is 0, the process group id of the current process is returned." msgstr "" -#: ../../library/os.rst:463 +#: ../../library/os.rst:472 msgid "Return the id of the current process group." msgstr "" -#: ../../library/os.rst:472 +#: ../../library/os.rst:481 msgid "Return the current process id." msgstr "" -#: ../../library/os.rst:481 +#: ../../library/os.rst:490 msgid "" "Return the parent's process id. When the parent process has exited, on Unix " "the id returned is the one of the init process (1), on Windows it is still " "the same id, which may be already reused by another process." msgstr "" -#: ../../library/os.rst:487 +#: ../../library/os.rst:496 msgid "Added support for Windows." msgstr "新增對 Windows 的支援。" -#: ../../library/os.rst:495 +#: ../../library/os.rst:504 msgid "" "Get program scheduling priority. The value *which* is one of :const:" "`PRIO_PROCESS`, :const:`PRIO_PGRP`, or :const:`PRIO_USER`, and *who* is " @@ -699,42 +722,42 @@ msgid "" "user ID of the calling process." msgstr "" -#: ../../library/os.rst:512 ../../library/os.rst:524 +#: ../../library/os.rst:521 ../../library/os.rst:533 msgid "" "Parameters for the :func:`getpriority` and :func:`setpriority` functions." msgstr "" -#: ../../library/os.rst:532 +#: ../../library/os.rst:541 msgid "" "Return a tuple (ruid, euid, suid) denoting the current process's real, " "effective, and saved user ids." msgstr "" -#: ../../library/os.rst:542 +#: ../../library/os.rst:551 msgid "" "Return a tuple (rgid, egid, sgid) denoting the current process's real, " "effective, and saved group ids." msgstr "" -#: ../../library/os.rst:554 +#: ../../library/os.rst:563 msgid "Return the current process's real user id." msgstr "" -#: ../../library/os.rst:564 +#: ../../library/os.rst:573 msgid "" "Call the system ``initgroups()`` to initialize the group access list with " "all of the groups of which the specified username is a member, plus the " "specified group id." msgstr "" -#: ../../library/os.rst:577 +#: ../../library/os.rst:586 msgid "" "Set the environment variable named *key* to the string *value*. Such " "changes to the environment affect subprocesses started with :func:`os." "system`, :func:`popen` or :func:`fork` and :func:`execv`." msgstr "" -#: ../../library/os.rst:581 +#: ../../library/os.rst:590 msgid "" "Assignments to items in :data:`os.environ` are automatically translated into " "corresponding calls to :func:`putenv`; however, calls to :func:`putenv` " @@ -744,17 +767,17 @@ msgid "" "in their implementations." msgstr "" -#: ../../library/os.rst:587 ../../library/os.rst:862 +#: ../../library/os.rst:596 ../../library/os.rst:871 msgid "See also the :func:`os.reload_environ` function." msgstr "也請見 :func:`os.reload_environ` 函式。" -#: ../../library/os.rst:591 +#: ../../library/os.rst:600 msgid "" "On some platforms, including FreeBSD and macOS, setting ``environ`` may " "cause memory leaks. Refer to the system documentation for :c:func:`!putenv`." msgstr "" -#: ../../library/os.rst:594 +#: ../../library/os.rst:603 msgid "" "Raises an :ref:`auditing event ` ``os.putenv`` with arguments " "``key``, ``value``." @@ -762,23 +785,23 @@ msgstr "" "引發一個附帶引數 ``key``、``value`` 的\\ :ref:`稽核事件 ` ``os." "putenv``。" -#: ../../library/os.rst:596 +#: ../../library/os.rst:605 msgid "The function is now always available." msgstr "此函式現在都會是可用的。" -#: ../../library/os.rst:602 +#: ../../library/os.rst:611 msgid "Set the current process's effective group id." msgstr "" -#: ../../library/os.rst:609 +#: ../../library/os.rst:618 msgid "Set the current process's effective user id." msgstr "" -#: ../../library/os.rst:616 +#: ../../library/os.rst:625 msgid "Set the current process' group id." msgstr "" -#: ../../library/os.rst:623 +#: ../../library/os.rst:632 msgid "" "Set the list of supplemental group ids associated with the current process " "to *groups*. *groups* must be a sequence, and each element must be an " @@ -786,7 +809,7 @@ msgid "" "the superuser." msgstr "" -#: ../../library/os.rst:629 +#: ../../library/os.rst:638 msgid "" "On macOS, the length of *groups* may not exceed the system-defined maximum " "number of effective group ids, typically 16. See the documentation for :func:" @@ -794,13 +817,13 @@ msgid "" "calling setgroups()." msgstr "" -#: ../../library/os.rst:636 +#: ../../library/os.rst:645 msgid "" "Reassociate the current thread with a Linux namespace. See the :manpage:" "`setns(2)` and :manpage:`namespaces(7)` man pages for more details." msgstr "" -#: ../../library/os.rst:640 +#: ../../library/os.rst:649 msgid "" "If *fd* refers to a :file:`/proc/{pid}/ns/` link, ``setns()`` reassociates " "the calling thread with the namespace associated with that link, and " @@ -809,7 +832,7 @@ msgid "" "constraints)." msgstr "" -#: ../../library/os.rst:647 +#: ../../library/os.rst:656 msgid "" "Since Linux 5.8, *fd* may refer to a PID file descriptor obtained from :func:" "`~os.pidfd_open`. In this case, ``setns()`` reassociates the calling thread " @@ -820,19 +843,19 @@ msgid "" "memberships in unspecified namespaces are left unchanged." msgstr "" -#: ../../library/os.rst:656 +#: ../../library/os.rst:665 msgid "" "*fd* can be any object with a :meth:`~io.IOBase.fileno` method, or a raw " "file descriptor." msgstr "" -#: ../../library/os.rst:658 +#: ../../library/os.rst:667 msgid "" "This example reassociates the thread with the ``init`` process's network " "namespace::" msgstr "" -#: ../../library/os.rst:660 +#: ../../library/os.rst:669 msgid "" "fd = os.open(\"/proc/1/ns/net\", os.O_RDONLY)\n" "os.setns(fd, os.CLONE_NEWNET)\n" @@ -842,25 +865,25 @@ msgstr "" "os.setns(fd, os.CLONE_NEWNET)\n" "os.close(fd)" -#: ../../library/os.rst:670 +#: ../../library/os.rst:679 msgid "The :func:`~os.unshare` function." msgstr ":func:`~os.unshare` 函式。" -#: ../../library/os.rst:674 +#: ../../library/os.rst:683 msgid "" "Call the system call :c:func:`!setpgrp` or ``setpgrp(0, 0)`` depending on " "which version is implemented (if any). See the Unix manual for the " "semantics." msgstr "" -#: ../../library/os.rst:682 +#: ../../library/os.rst:691 msgid "" "Call the system call :c:func:`!setpgid` to set the process group id of the " "process with id *pid* to the process group with id *pgrp*. See the Unix " "manual for the semantics." msgstr "" -#: ../../library/os.rst:693 +#: ../../library/os.rst:702 msgid "" "Set program scheduling priority. The value *which* is one of :const:" "`PRIO_PROCESS`, :const:`PRIO_PGRP`, or :const:`PRIO_USER`, and *who* is " @@ -873,62 +896,62 @@ msgid "" "scheduling." msgstr "" -#: ../../library/os.rst:710 +#: ../../library/os.rst:719 msgid "Set the current process's real and effective group ids." msgstr "" -#: ../../library/os.rst:717 +#: ../../library/os.rst:726 msgid "Set the current process's real, effective, and saved group ids." msgstr "" -#: ../../library/os.rst:726 +#: ../../library/os.rst:735 msgid "Set the current process's real, effective, and saved user ids." msgstr "" -#: ../../library/os.rst:735 +#: ../../library/os.rst:744 msgid "Set the current process's real and effective user ids." msgstr "" -#: ../../library/os.rst:742 +#: ../../library/os.rst:751 msgid "" "Call the system call :c:func:`!getsid`. See the Unix manual for the " "semantics." msgstr "" -#: ../../library/os.rst:749 +#: ../../library/os.rst:758 msgid "" "Call the system call :c:func:`!setsid`. See the Unix manual for the " "semantics." msgstr "" -#: ../../library/os.rst:758 +#: ../../library/os.rst:767 msgid "Set the current process's user id." msgstr "" -#: ../../library/os.rst:766 +#: ../../library/os.rst:775 msgid "" "Return the error message corresponding to the error code in *code*. On " "platforms where :c:func:`!strerror` returns ``NULL`` when given an unknown " "error number, :exc:`ValueError` is raised." msgstr "" -#: ../../library/os.rst:773 +#: ../../library/os.rst:782 msgid "" "``True`` if the native OS type of the environment is bytes (eg. ``False`` on " "Windows)." msgstr "" -#: ../../library/os.rst:781 +#: ../../library/os.rst:790 msgid "Set the current numeric umask and return the previous umask." msgstr "" -#: ../../library/os.rst:793 +#: ../../library/os.rst:802 msgid "" "Returns information identifying the current operating system. The return " "value is a :class:`uname_result`." msgstr "" -#: ../../library/os.rst:796 +#: ../../library/os.rst:805 msgid "" "On macOS, iOS and Android, this returns the *kernel* name and release (i.e., " "``'Darwin'`` on macOS and iOS; ``'Linux'`` on Android). :func:`platform." @@ -936,23 +959,23 @@ msgid "" "on iOS and Android." msgstr "" -#: ../../library/os.rst:802 +#: ../../library/os.rst:811 msgid ":data:`sys.platform` which has finer granularity." msgstr "" -#: ../../library/os.rst:809 ../../library/os.rst:5252 +#: ../../library/os.rst:818 ../../library/os.rst:5675 msgid "" "Return type changed from a tuple to a tuple-like object with named " "attributes." msgstr "" -#: ../../library/os.rst:816 +#: ../../library/os.rst:825 msgid "" "Name and information about the system returned by :func:`os.uname`. These " "attributes correspond to the members described in :manpage:`uname(2)`." msgstr "" -#: ../../library/os.rst:819 +#: ../../library/os.rst:828 msgid "" "For backwards compatibility, this object is also iterable, behaving like a " "five-tuple containing :attr:`~uname_result.sysname`, :attr:`~uname_result." @@ -960,11 +983,11 @@ msgid "" "and :attr:`~uname_result.machine` in that order." msgstr "" -#: ../../library/os.rst:827 +#: ../../library/os.rst:836 msgid "Operating system name." msgstr "作業系統名稱。" -#: ../../library/os.rst:831 +#: ../../library/os.rst:840 msgid "" "Name of machine on network. Some systems truncate :attr:`~uname_result." "nodename` to 8 characters or to the leading component; a better way to get " @@ -972,26 +995,26 @@ msgid "" "gethostbyaddr(socket.gethostname())``." msgstr "" -#: ../../library/os.rst:838 +#: ../../library/os.rst:847 msgid "Operating system release." msgstr "" -#: ../../library/os.rst:842 +#: ../../library/os.rst:851 msgid "Operating system version." msgstr "作業系統版本。" -#: ../../library/os.rst:846 +#: ../../library/os.rst:855 msgid "Hardware identifier." msgstr "" -#: ../../library/os.rst:853 +#: ../../library/os.rst:862 msgid "" "Unset (delete) the environment variable named *key*. Such changes to the " "environment affect subprocesses started with :func:`os.system`, :func:" "`popen` or :func:`fork` and :func:`execv`." msgstr "" -#: ../../library/os.rst:857 +#: ../../library/os.rst:866 msgid "" "Deletion of items in :data:`os.environ` is automatically translated into a " "corresponding call to :func:`unsetenv`; however, calls to :func:`unsetenv` " @@ -999,18 +1022,11 @@ msgid "" "items of :data:`os.environ`." msgstr "" -#: ../../library/os.rst:864 -msgid "" -"Raises an :ref:`auditing event ` ``os.unsetenv`` with argument " -"``key``." -msgstr "" -"引發一個附帶引數 ``key`` 的\\ :ref:`稽核事件 ` ``os.unsetenv``。" - -#: ../../library/os.rst:866 +#: ../../library/os.rst:875 msgid "The function is now always available and is also available on Windows." msgstr "" -#: ../../library/os.rst:872 +#: ../../library/os.rst:881 msgid "" "Disassociate parts of the process execution context, and move them into a " "newly created namespace. See the :manpage:`unshare(2)` man page for more " @@ -1021,28 +1037,28 @@ msgid "" "are made to the calling process's execution context." msgstr "" -#: ../../library/os.rst:889 +#: ../../library/os.rst:898 msgid "The :func:`~os.setns` function." msgstr ":func:`~os.setns` 函式。" -#: ../../library/os.rst:893 +#: ../../library/os.rst:902 msgid "" "Flags to the :func:`unshare` function, if the implementation supports them. " "See :manpage:`unshare(2)` in the Linux manual for their exact effect and " "availability." msgstr "" -#: ../../library/os.rst:916 +#: ../../library/os.rst:925 msgid "File Object Creation" msgstr "" -#: ../../library/os.rst:918 +#: ../../library/os.rst:927 msgid "" "These functions create new :term:`file objects `. (See also :" "func:`~os.open` for opening file descriptors.)" msgstr "" -#: ../../library/os.rst:924 +#: ../../library/os.rst:933 msgid "" "Return an open file object connected to the file descriptor *fd*. This is " "an alias of the :func:`open` built-in function and accepts the same " @@ -1050,16 +1066,16 @@ msgid "" "must always be an integer." msgstr "" -#: ../../library/os.rst:933 +#: ../../library/os.rst:942 msgid "File Descriptor Operations" msgstr "" -#: ../../library/os.rst:935 +#: ../../library/os.rst:944 msgid "" "These functions operate on I/O streams referenced using file descriptors." msgstr "" -#: ../../library/os.rst:937 +#: ../../library/os.rst:946 msgid "" "File descriptors are small integers corresponding to a file that has been " "opened by the current process. For example, standard input is usually file " @@ -1069,7 +1085,7 @@ msgid "" "pipes are also referenced by file descriptors." msgstr "" -#: ../../library/os.rst:944 +#: ../../library/os.rst:953 msgid "" "The :meth:`~io.IOBase.fileno` method can be used to obtain the file " "descriptor associated with a :term:`file object` when required. Note that " @@ -1077,11 +1093,11 @@ msgid "" "ignoring aspects such as internal buffering of data." msgstr "" -#: ../../library/os.rst:952 +#: ../../library/os.rst:961 msgid "Close file descriptor *fd*." msgstr "" -#: ../../library/os.rst:956 +#: ../../library/os.rst:965 msgid "" "This function is intended for low-level I/O and must be applied to a file " "descriptor as returned by :func:`os.open` or :func:`pipe`. To close a " @@ -1089,13 +1105,13 @@ msgid "" "`popen` or :func:`fdopen`, use its :meth:`~io.IOBase.close` method." msgstr "" -#: ../../library/os.rst:964 +#: ../../library/os.rst:973 msgid "" "Close all file descriptors from *fd_low* (inclusive) to *fd_high* " "(exclusive), ignoring errors. Equivalent to (but much faster than)::" msgstr "" -#: ../../library/os.rst:967 +#: ../../library/os.rst:976 msgid "" "for fd in range(fd_low, fd_high):\n" " try:\n" @@ -1109,7 +1125,7 @@ msgstr "" " except OSError:\n" " pass" -#: ../../library/os.rst:976 +#: ../../library/os.rst:985 msgid "" "Copy *count* bytes from file descriptor *src*, starting from offset " "*offset_src*, to file descriptor *dst*, starting from offset *offset_dst*. " @@ -1117,14 +1133,14 @@ msgid "" "respectively for *offset_dst*." msgstr "" -#: ../../library/os.rst:981 +#: ../../library/os.rst:990 msgid "" "In Linux kernel older than 5.3, the files pointed to by *src* and *dst* must " "reside in the same filesystem, otherwise an :exc:`OSError` is raised with :" "attr:`~OSError.errno` set to :const:`errno.EXDEV`." msgstr "" -#: ../../library/os.rst:985 +#: ../../library/os.rst:994 msgid "" "This copy is done without the additional cost of transferring data from the " "kernel to user space and then back into the kernel. Additionally, some " @@ -1134,19 +1150,19 @@ msgid "" "(in the case of NFS)." msgstr "" -#: ../../library/os.rst:992 +#: ../../library/os.rst:1001 msgid "" "The function copies bytes between two file descriptors. Text options, like " "the encoding and the line ending, are ignored." msgstr "" -#: ../../library/os.rst:995 +#: ../../library/os.rst:1004 msgid "" "The return value is the amount of bytes copied. This could be less than the " "amount requested." msgstr "" -#: ../../library/os.rst:1000 +#: ../../library/os.rst:1009 msgid "" "On Linux, :func:`os.copy_file_range` should not be used for copying a range " "of a pseudo file from a special filesystem like procfs and sysfs. It will " @@ -1154,39 +1170,39 @@ msgid "" "known Linux kernel issue." msgstr "" -#: ../../library/os.rst:1012 +#: ../../library/os.rst:1021 msgid "" "Return a string describing the encoding of the device associated with *fd* " "if it is connected to a terminal; else return :const:`None`." msgstr "" -#: ../../library/os.rst:1015 +#: ../../library/os.rst:1024 msgid "" "On Unix, if the :ref:`Python UTF-8 Mode ` is enabled, return " "``'UTF-8'`` rather than the device encoding." msgstr "" -#: ../../library/os.rst:1018 +#: ../../library/os.rst:1027 msgid "On Unix, the function now implements the Python UTF-8 Mode." msgstr "" -#: ../../library/os.rst:1024 +#: ../../library/os.rst:1033 msgid "" "Return a duplicate of file descriptor *fd*. The new file descriptor is :ref:" "`non-inheritable `." msgstr "" -#: ../../library/os.rst:1027 +#: ../../library/os.rst:1036 msgid "" "On Windows, when duplicating a standard stream (0: stdin, 1: stdout, 2: " "stderr), the new file descriptor is :ref:`inheritable `." msgstr "" -#: ../../library/os.rst:1033 ../../library/os.rst:1315 +#: ../../library/os.rst:1042 ../../library/os.rst:1324 msgid "The new file descriptor is now non-inheritable." msgstr "" -#: ../../library/os.rst:1039 +#: ../../library/os.rst:1048 msgid "" "Duplicate file descriptor *fd* to *fd2*, closing the latter first if " "necessary. Return *fd2*. The new file descriptor is :ref:`inheritable " @@ -1194,23 +1210,23 @@ msgid "" "``False``." msgstr "" -#: ../../library/os.rst:1046 +#: ../../library/os.rst:1055 msgid "Add the optional *inheritable* parameter." msgstr "新增可選用的參數 *inheritable*。" -#: ../../library/os.rst:1049 +#: ../../library/os.rst:1058 msgid "Return *fd2* on success. Previously, ``None`` was always returned." msgstr "" -#: ../../library/os.rst:1055 +#: ../../library/os.rst:1064 msgid "" "Change the mode of the file given by *fd* to the numeric *mode*. See the " "docs for :func:`chmod` for possible values of *mode*. As of Python 3.3, " "this is equivalent to ``os.chmod(fd, mode)``." msgstr "" -#: ../../library/os.rst:1059 ../../library/os.rst:2237 -#: ../../library/os.rst:2338 +#: ../../library/os.rst:1068 ../../library/os.rst:2267 +#: ../../library/os.rst:2368 msgid "" "Raises an :ref:`auditing event ` ``os.chmod`` with arguments " "``path``, ``mode``, ``dir_fd``." @@ -1218,28 +1234,28 @@ msgstr "" "引發一個附帶引數 ``path``、``mode``、``dir_fd`` 的\\ :ref:`稽核事件 " "` ``os.chmod``。" -#: ../../library/os.rst:1063 ../../library/os.rst:1081 -#: ../../library/os.rst:1169 ../../library/os.rst:1781 -#: ../../library/os.rst:2234 ../../library/os.rst:2267 -#: ../../library/os.rst:3703 +#: ../../library/os.rst:1072 ../../library/os.rst:1090 +#: ../../library/os.rst:1178 ../../library/os.rst:1811 +#: ../../library/os.rst:2264 ../../library/os.rst:2297 +#: ../../library/os.rst:4113 msgid "" "The function is limited on WASI, see :ref:`wasm-availability` for more " "information." msgstr "" -#: ../../library/os.rst:1066 ../../library/os.rst:2345 +#: ../../library/os.rst:1075 ../../library/os.rst:2375 msgid "Added support on Windows." msgstr "新增對 Windows 的支援。" -#: ../../library/os.rst:1072 +#: ../../library/os.rst:1081 msgid "" "Change the owner and group id of the file given by *fd* to the numeric *uid* " "and *gid*. To leave one of the ids unchanged, set it to -1. See :func:" "`chown`. As of Python 3.3, this is equivalent to ``os.chown(fd, uid, gid)``." msgstr "" -#: ../../library/os.rst:1077 ../../library/os.rst:2263 -#: ../../library/os.rst:2354 +#: ../../library/os.rst:1086 ../../library/os.rst:2293 +#: ../../library/os.rst:2384 msgid "" "Raises an :ref:`auditing event ` ``os.chown`` with arguments " "``path``, ``uid``, ``gid``, ``dir_fd``." @@ -1247,13 +1263,13 @@ msgstr "" "引發一個附帶引數 ``path``、``uid``、``gid``、``dir_fd`` 的\\ :ref:`稽核事件 " "` ``os.chown``。" -#: ../../library/os.rst:1087 +#: ../../library/os.rst:1096 msgid "" "Force write of file with filedescriptor *fd* to disk. Does not force update " "of metadata." msgstr "" -#: ../../library/os.rst:1095 +#: ../../library/os.rst:1104 msgid "" "Return system configuration information relevant to an open file. *name* " "specifies the configuration value to retrieve; it may be a string which is " @@ -1264,7 +1280,7 @@ msgid "" "included in that mapping, passing an integer for *name* is also accepted." msgstr "" -#: ../../library/os.rst:1103 ../../library/os.rst:2674 +#: ../../library/os.rst:1112 ../../library/os.rst:2727 msgid "" "If *name* is a string and is not known, :exc:`ValueError` is raised. If a " "specific value for *name* is not supported by the host system, even if it is " @@ -1272,53 +1288,53 @@ msgid "" "`errno.EINVAL` for the error number." msgstr "" -#: ../../library/os.rst:1108 +#: ../../library/os.rst:1117 msgid "As of Python 3.3, this is equivalent to ``os.pathconf(fd, name)``." msgstr "" -#: ../../library/os.rst:1115 +#: ../../library/os.rst:1124 msgid "" "Get the status of the file descriptor *fd*. Return a :class:`stat_result` " "object." msgstr "" -#: ../../library/os.rst:1118 +#: ../../library/os.rst:1127 msgid "As of Python 3.3, this is equivalent to ``os.stat(fd)``." msgstr "" -#: ../../library/os.rst:1122 ../../library/os.rst:2502 +#: ../../library/os.rst:1131 ../../library/os.rst:2536 msgid "The :func:`.stat` function." msgstr "" -#: ../../library/os.rst:1127 +#: ../../library/os.rst:1136 msgid "" "Return information about the filesystem containing the file associated with " "file descriptor *fd* in a :class:`statvfs_result`, like :func:`statvfs`. As " "of Python 3.3, this is equivalent to ``os.statvfs(fd)``." msgstr "" -#: ../../library/os.rst:1136 +#: ../../library/os.rst:1145 msgid "" "Force write of file with filedescriptor *fd* to disk. On Unix, this calls " "the native :c:func:`!fsync` function; on Windows, the MS :c:func:`!_commit` " "function." msgstr "" -#: ../../library/os.rst:1139 +#: ../../library/os.rst:1148 msgid "" "If you're starting with a buffered Python :term:`file object` *f*, first do " "``f.flush()``, and then do ``os.fsync(f.fileno())``, to ensure that all " "internal buffers associated with *f* are written to disk." msgstr "" -#: ../../library/os.rst:1148 +#: ../../library/os.rst:1157 msgid "" "Truncate the file corresponding to file descriptor *fd*, so that it is at " "most *length* bytes in size. As of Python 3.3, this is equivalent to ``os." "truncate(fd, length)``." msgstr "" -#: ../../library/os.rst:1152 +#: ../../library/os.rst:1161 msgid "" "Raises an :ref:`auditing event ` ``os.truncate`` with arguments " "``fd``, ``length``." @@ -1326,46 +1342,46 @@ msgstr "" "引發一個附帶引數 ``fd``、``length`` 的\\ :ref:`稽核事件 ` ``os." "truncate``。" -#: ../../library/os.rst:1156 ../../library/os.rst:3742 +#: ../../library/os.rst:1165 ../../library/os.rst:4152 msgid "Added support for Windows" msgstr "新增對 Windows 的支援" -#: ../../library/os.rst:1162 +#: ../../library/os.rst:1171 msgid "" "Get the blocking mode of the file descriptor: ``False`` if the :data:" "`O_NONBLOCK` flag is set, ``True`` if the flag is cleared." msgstr "" -#: ../../library/os.rst:1165 +#: ../../library/os.rst:1174 msgid "See also :func:`set_blocking` and :meth:`socket.socket.setblocking`." msgstr "另請參閱 :func:`set_blocking` 與 :meth:`socket.socket.setblocking`。" -#: ../../library/os.rst:1172 ../../library/os.rst:1784 +#: ../../library/os.rst:1181 ../../library/os.rst:1814 msgid "On Windows, this function is limited to pipes." msgstr "" -#: ../../library/os.rst:1176 ../../library/os.rst:1788 +#: ../../library/os.rst:1185 ../../library/os.rst:1818 msgid "Added support for pipes on Windows." msgstr "新增對 Windows 上的 pipe 支援。" -#: ../../library/os.rst:1182 +#: ../../library/os.rst:1191 msgid "" "Grant access to the slave pseudo-terminal device associated with the master " "pseudo-terminal device to which the file descriptor *fd* refers. The file " "descriptor *fd* is not closed upon failure." msgstr "" -#: ../../library/os.rst:1186 +#: ../../library/os.rst:1195 msgid "Calls the C standard library function :c:func:`grantpt`." msgstr "" -#: ../../library/os.rst:1195 +#: ../../library/os.rst:1204 msgid "" "Return ``True`` if the file descriptor *fd* is open and connected to a tty(-" "like) device, else ``False``." msgstr "" -#: ../../library/os.rst:1201 +#: ../../library/os.rst:1210 msgid "" "Apply, test or remove a POSIX lock on an open file descriptor. *fd* is an " "open file descriptor. *cmd* specifies the command to use - one of :data:" @@ -1373,7 +1389,7 @@ msgid "" "specifies the section of the file to lock." msgstr "" -#: ../../library/os.rst:1207 +#: ../../library/os.rst:1216 msgid "" "Raises an :ref:`auditing event ` ``os.lockf`` with arguments " "``fd``, ``cmd``, ``len``." @@ -1381,119 +1397,119 @@ msgstr "" "引發一個附帶引數 ``fd``、``cmd``、``len`` 的\\ :ref:`稽核事件 ` " "``os.lockf``。" -#: ../../library/os.rst:1219 +#: ../../library/os.rst:1228 msgid "Flags that specify what action :func:`lockf` will take." msgstr "" -#: ../../library/os.rst:1228 +#: ../../library/os.rst:1237 msgid "" "Prepare the tty of which fd is a file descriptor for a new login session. " "Make the calling process a session leader; make the tty the controlling tty, " "the stdin, the stdout, and the stderr of the calling process; close fd." msgstr "" -#: ../../library/os.rst:1239 +#: ../../library/os.rst:1248 msgid "" "Set the current position of file descriptor *fd* to position *pos*, modified " "by *whence*, and return the new position in bytes relative to the start of " "the file. Valid values for *whence* are:" msgstr "" -#: ../../library/os.rst:1244 +#: ../../library/os.rst:1253 msgid "" ":const:`SEEK_SET` or ``0`` -- set *pos* relative to the beginning of the file" msgstr "" -#: ../../library/os.rst:1245 +#: ../../library/os.rst:1254 msgid "" ":const:`SEEK_CUR` or ``1`` -- set *pos* relative to the current file position" msgstr "" -#: ../../library/os.rst:1246 +#: ../../library/os.rst:1255 msgid ":const:`SEEK_END` or ``2`` -- set *pos* relative to the end of the file" msgstr "" -#: ../../library/os.rst:1247 +#: ../../library/os.rst:1256 msgid "" ":const:`SEEK_HOLE` -- set *pos* to the next data location, relative to *pos*" msgstr "" -#: ../../library/os.rst:1248 +#: ../../library/os.rst:1257 msgid "" ":const:`SEEK_DATA` -- set *pos* to the next data hole, relative to *pos*" msgstr "" -#: ../../library/os.rst:1252 +#: ../../library/os.rst:1261 msgid "Add support for :const:`!SEEK_HOLE` and :const:`!SEEK_DATA`." msgstr "" -#: ../../library/os.rst:1259 +#: ../../library/os.rst:1268 msgid "" "Parameters to the :func:`lseek` function and the :meth:`~io.IOBase.seek` " "method on :term:`file-like objects `, for whence to adjust the " "file position indicator." msgstr "" -#: ../../library/os.rst:1263 +#: ../../library/os.rst:1272 msgid ":const:`SEEK_SET`" msgstr ":const:`SEEK_SET`" -#: ../../library/os.rst:1264 +#: ../../library/os.rst:1273 msgid "Adjust the file position relative to the beginning of the file." msgstr "" -#: ../../library/os.rst:1265 +#: ../../library/os.rst:1274 msgid ":const:`SEEK_CUR`" msgstr ":const:`SEEK_CUR`" -#: ../../library/os.rst:1266 +#: ../../library/os.rst:1275 msgid "Adjust the file position relative to the current file position." msgstr "" -#: ../../library/os.rst:1267 +#: ../../library/os.rst:1276 msgid ":const:`SEEK_END`" msgstr ":const:`SEEK_END`" -#: ../../library/os.rst:1268 +#: ../../library/os.rst:1277 msgid "Adjust the file position relative to the end of the file." msgstr "" -#: ../../library/os.rst:1270 +#: ../../library/os.rst:1279 msgid "Their values are 0, 1, and 2, respectively." msgstr "" -#: ../../library/os.rst:1276 +#: ../../library/os.rst:1285 msgid "" "Parameters to the :func:`lseek` function and the :meth:`~io.IOBase.seek` " "method on :term:`file-like objects `, for seeking file data and " "holes on sparsely allocated files." msgstr "" -#: ../../library/os.rst:1280 +#: ../../library/os.rst:1289 msgid ":data:`!SEEK_DATA`" msgstr ":data:`!SEEK_DATA`" -#: ../../library/os.rst:1281 +#: ../../library/os.rst:1290 msgid "" "Adjust the file offset to the next location containing data, relative to the " "seek position." msgstr "" -#: ../../library/os.rst:1284 +#: ../../library/os.rst:1293 msgid ":data:`!SEEK_HOLE`" msgstr ":data:`!SEEK_HOLE`" -#: ../../library/os.rst:1285 +#: ../../library/os.rst:1294 msgid "" "Adjust the file offset to the next location containing a hole, relative to " "the seek position. A hole is defined as a sequence of zeros." msgstr "" -#: ../../library/os.rst:1291 +#: ../../library/os.rst:1300 msgid "These operations only make sense for filesystems that support them." msgstr "" -#: ../../library/os.rst:1300 +#: ../../library/os.rst:1309 msgid "" "Open the file *path* and set various flags according to *flags* and possibly " "its mode according to *mode*. When computing *mode*, the current umask " @@ -1501,7 +1517,7 @@ msgid "" "file. The new file descriptor is :ref:`non-inheritable `." msgstr "" -#: ../../library/os.rst:1305 +#: ../../library/os.rst:1314 msgid "" "For a description of the flag and mode values, see the C run-time " "documentation; flag constants (like :const:`O_RDONLY` and :const:`O_WRONLY`) " @@ -1509,13 +1525,13 @@ msgid "" "const:`O_BINARY` is needed to open files in binary mode." msgstr "" -#: ../../library/os.rst:1310 +#: ../../library/os.rst:1319 msgid "" "This function can support :ref:`paths relative to directory descriptors " "` with the *dir_fd* parameter." msgstr "" -#: ../../library/os.rst:1313 +#: ../../library/os.rst:1322 msgid "" "Raises an :ref:`auditing event ` ``open`` with arguments ``path``, " "``mode``, ``flags``." @@ -1523,7 +1539,7 @@ msgstr "" "引發一個附帶引數 ``path``、``mode``、``flags`` 的\\ :ref:`稽核事件 " "` ``open``。" -#: ../../library/os.rst:1320 +#: ../../library/os.rst:1329 msgid "" "This function is intended for low-level I/O. For normal usage, use the " "built-in function :func:`open`, which returns a :term:`file object` with :" @@ -1531,41 +1547,41 @@ msgid "" "To wrap a file descriptor in a file object, use :func:`fdopen`." msgstr "" -#: ../../library/os.rst:1325 ../../library/os.rst:2507 -#: ../../library/os.rst:2547 ../../library/os.rst:2618 -#: ../../library/os.rst:2640 ../../library/os.rst:2721 -#: ../../library/os.rst:2751 ../../library/os.rst:2858 -#: ../../library/os.rst:3758 +#: ../../library/os.rst:1334 ../../library/os.rst:2541 +#: ../../library/os.rst:2581 ../../library/os.rst:2664 +#: ../../library/os.rst:2686 ../../library/os.rst:2774 +#: ../../library/os.rst:2804 ../../library/os.rst:2911 +#: ../../library/os.rst:4168 msgid "Added the *dir_fd* parameter." msgstr "新增 *dir_fd* 參數。" -#: ../../library/os.rst:1328 ../../library/os.rst:1679 -#: ../../library/os.rst:1914 ../../library/os.rst:5348 +#: ../../library/os.rst:1337 ../../library/os.rst:1709 +#: ../../library/os.rst:1944 ../../library/os.rst:5771 msgid "" "If the system call is interrupted and the signal handler does not raise an " "exception, the function now retries the system call instead of raising an :" "exc:`InterruptedError` exception (see :pep:`475` for the rationale)." msgstr "" -#: ../../library/os.rst:1333 ../../library/os.rst:2125 -#: ../../library/os.rst:2162 ../../library/os.rst:2193 -#: ../../library/os.rst:2243 ../../library/os.rst:2284 -#: ../../library/os.rst:2324 ../../library/os.rst:2342 -#: ../../library/os.rst:2358 ../../library/os.rst:2418 -#: ../../library/os.rst:2510 ../../library/os.rst:2550 -#: ../../library/os.rst:2594 ../../library/os.rst:2621 -#: ../../library/os.rst:2643 ../../library/os.rst:2684 -#: ../../library/os.rst:2754 ../../library/os.rst:2773 -#: ../../library/os.rst:2861 ../../library/os.rst:3165 -#: ../../library/os.rst:3427 ../../library/os.rst:3745 -#: ../../library/os.rst:3761 ../../library/os.rst:3801 -#: ../../library/os.rst:3901 ../../library/os.rst:3962 -#: ../../library/os.rst:4359 ../../library/os.rst:4539 -#: ../../library/os.rst:5107 +#: ../../library/os.rst:1342 ../../library/os.rst:2155 +#: ../../library/os.rst:2192 ../../library/os.rst:2223 +#: ../../library/os.rst:2273 ../../library/os.rst:2314 +#: ../../library/os.rst:2354 ../../library/os.rst:2372 +#: ../../library/os.rst:2388 ../../library/os.rst:2448 +#: ../../library/os.rst:2544 ../../library/os.rst:2584 +#: ../../library/os.rst:2635 ../../library/os.rst:2667 +#: ../../library/os.rst:2689 ../../library/os.rst:2737 +#: ../../library/os.rst:2807 ../../library/os.rst:2826 +#: ../../library/os.rst:2914 ../../library/os.rst:3222 +#: ../../library/os.rst:3837 ../../library/os.rst:4155 +#: ../../library/os.rst:4171 ../../library/os.rst:4212 +#: ../../library/os.rst:4315 ../../library/os.rst:4376 +#: ../../library/os.rst:4773 ../../library/os.rst:4957 +#: ../../library/os.rst:5530 msgid "Accepts a :term:`path-like object`." msgstr "" -#: ../../library/os.rst:1336 +#: ../../library/os.rst:1345 msgid "" "The following constants are options for the *flags* parameter to the :func:" "`~os.open` function. They can be combined using the bitwise OR operator ``|" @@ -1575,45 +1591,45 @@ msgid "" "on Windows." msgstr "" -#: ../../library/os.rst:1351 +#: ../../library/os.rst:1360 msgid "The above constants are available on Unix and Windows." msgstr "" -#: ../../library/os.rst:1362 +#: ../../library/os.rst:1371 msgid "The above constants are only available on Unix." msgstr "" -#: ../../library/os.rst:1364 +#: ../../library/os.rst:1373 msgid "Add :data:`O_CLOEXEC` constant." msgstr "新增 :data:`O_CLOEXEC` 常數。" -#: ../../library/os.rst:1375 +#: ../../library/os.rst:1384 msgid "The above constants are only available on Windows." msgstr "" -#: ../../library/os.rst:1382 +#: ../../library/os.rst:1391 msgid "The above constants are only available on macOS." msgstr "" -#: ../../library/os.rst:1384 +#: ../../library/os.rst:1393 msgid "" "Add :data:`O_EVTONLY`, :data:`O_FSYNC`, :data:`O_SYMLINK` and :data:" "`O_NOFOLLOW_ANY` constants." msgstr "" -#: ../../library/os.rst:1398 +#: ../../library/os.rst:1407 msgid "" "The above constants are extensions and not present if they are not defined " "by the C library." msgstr "" -#: ../../library/os.rst:1401 +#: ../../library/os.rst:1410 msgid "" "Add :data:`O_PATH` on systems that support it. Add :data:`O_TMPFILE`, only " "available on Linux Kernel 3.11 or newer." msgstr "" -#: ../../library/os.rst:1411 +#: ../../library/os.rst:1420 msgid "" "Open a new pseudo-terminal pair. Return a pair of file descriptors " "``(master, slave)`` for the pty and the tty, respectively. The new file " @@ -1621,18 +1637,18 @@ msgid "" "more portable approach, use the :mod:`pty` module." msgstr "" -#: ../../library/os.rst:1418 ../../library/os.rst:1430 +#: ../../library/os.rst:1427 ../../library/os.rst:1439 msgid "The new file descriptors are now non-inheritable." msgstr "" -#: ../../library/os.rst:1424 +#: ../../library/os.rst:1433 msgid "" "Create a pipe. Return a pair of file descriptors ``(r, w)`` usable for " "reading and writing, respectively. The new file descriptor is :ref:`non-" "inheritable `." msgstr "" -#: ../../library/os.rst:1436 +#: ../../library/os.rst:1445 msgid "" "Create a pipe with *flags* set atomically. *flags* can be constructed by " "ORing together one or more of these values: :data:`O_NONBLOCK`, :data:" @@ -1640,13 +1656,13 @@ msgid "" "and writing, respectively." msgstr "" -#: ../../library/os.rst:1449 +#: ../../library/os.rst:1458 msgid "" "Ensures that enough disk space is allocated for the file specified by *fd* " "starting from *offset* and continuing for *len* bytes." msgstr "" -#: ../../library/os.rst:1459 +#: ../../library/os.rst:1468 msgid "" "Announces an intention to access data in a specific pattern thus allowing " "the kernel to make optimizations. The advice applies to the region of the " @@ -1657,43 +1673,43 @@ msgid "" "`POSIX_FADV_DONTNEED`." msgstr "" -#: ../../library/os.rst:1479 +#: ../../library/os.rst:1488 msgid "" "Flags that can be used in *advice* in :func:`posix_fadvise` that specify the " "access pattern that is likely to be used." msgstr "" -#: ../../library/os.rst:1489 +#: ../../library/os.rst:1498 msgid "" "Read at most *n* bytes from file descriptor *fd* at a position of *offset*, " "leaving the file offset unchanged." msgstr "" -#: ../../library/os.rst:1492 ../../library/os.rst:1668 +#: ../../library/os.rst:1501 ../../library/os.rst:1698 msgid "" "Return a bytestring containing the bytes read. If the end of the file " "referred to by *fd* has been reached, an empty bytes object is returned." msgstr "" -#: ../../library/os.rst:1502 +#: ../../library/os.rst:1511 msgid "Open and return a file descriptor for a master pseudo-terminal device." msgstr "" -#: ../../library/os.rst:1504 +#: ../../library/os.rst:1513 msgid "" "Calls the C standard library function :c:func:`posix_openpt`. The *oflag* " "argument is used to set file status flags and file access modes as specified " "in the manual page of :c:func:`posix_openpt` of your system." msgstr "" -#: ../../library/os.rst:1508 +#: ../../library/os.rst:1517 msgid "" "The returned file descriptor is :ref:`non-inheritable `. If " "the value :data:`O_CLOEXEC` is available on the system, it is added to " "*oflag*." msgstr "" -#: ../../library/os.rst:1519 +#: ../../library/os.rst:1528 msgid "" "Read from a file descriptor *fd* at a position of *offset* into mutable :" "term:`bytes-like objects ` *buffers*, leaving the file " @@ -1701,92 +1717,105 @@ msgid "" "move on to the next buffer in the sequence to hold the rest of the data." msgstr "" -#: ../../library/os.rst:1524 ../../library/os.rst:1609 +#: ../../library/os.rst:1533 ../../library/os.rst:1637 msgid "" "The flags argument contains a bitwise OR of zero or more of the following " "flags:" msgstr "" -#: ../../library/os.rst:1527 +#: ../../library/os.rst:1536 msgid ":data:`RWF_HIPRI`" msgstr ":data:`RWF_HIPRI`" -#: ../../library/os.rst:1528 +#: ../../library/os.rst:1537 msgid ":data:`RWF_NOWAIT`" msgstr ":data:`RWF_NOWAIT`" -#: ../../library/os.rst:1530 ../../library/os.rst:1851 +#: ../../library/os.rst:1538 ../../library/os.rst:1643 +msgid ":data:`RWF_DONTCACHE`" +msgstr ":data:`RWF_DONTCACHE`" + +#: ../../library/os.rst:1540 ../../library/os.rst:1881 msgid "" "Return the total number of bytes actually read which can be less than the " "total capacity of all the objects." msgstr "" -#: ../../library/os.rst:1533 ../../library/os.rst:1618 -#: ../../library/os.rst:1854 ../../library/os.rst:1929 +#: ../../library/os.rst:1543 ../../library/os.rst:1648 +#: ../../library/os.rst:1884 ../../library/os.rst:1959 msgid "" "The operating system may set a limit (:func:`sysconf` value " "``'SC_IOV_MAX'``) on the number of buffers that can be used." msgstr "" -#: ../../library/os.rst:1536 +#: ../../library/os.rst:1546 msgid "Combine the functionality of :func:`os.readv` and :func:`os.pread`." msgstr "" -#: ../../library/os.rst:1540 ../../library/os.rst:1625 +#: ../../library/os.rst:1550 ../../library/os.rst:1655 msgid "Using flags requires Linux >= 4.6." msgstr "" -#: ../../library/os.rst:1547 +#: ../../library/os.rst:1557 msgid "" "Do not wait for data which is not immediately available. If this flag is " "specified, the system call will return instantly if it would have to read " "data from the backing storage or wait for a lock." msgstr "" -#: ../../library/os.rst:1551 +#: ../../library/os.rst:1561 msgid "" "If some data was successfully read, it will return the number of bytes read. " "If no bytes were read, it will return ``-1`` and set errno to :const:`errno." "EAGAIN`." msgstr "" -#: ../../library/os.rst:1562 +#: ../../library/os.rst:1572 msgid "" "High priority read/write. Allows block-based filesystems to use polling of " "the device, which provides lower latency, but may use additional resources." msgstr "" -#: ../../library/os.rst:1566 +#: ../../library/os.rst:1576 msgid "" "Currently, on Linux, this feature is usable only on a file descriptor opened " "using the :data:`O_DIRECT` flag." msgstr "" -#: ../../library/os.rst:1576 +#: ../../library/os.rst:1586 +msgid "Use uncached buffered IO." +msgstr "" + +#: ../../library/os.rst:1595 +msgid "" +"Write data atomically. Requires alignment to the device's atomic write unit." +msgstr "" + +#: ../../library/os.rst:1604 msgid "" "Return the name of the slave pseudo-terminal device associated with the " "master pseudo-terminal device to which the file descriptor *fd* refers. The " "file descriptor *fd* is not closed upon failure." msgstr "" -#: ../../library/os.rst:1580 +#: ../../library/os.rst:1608 msgid "" "Calls the reentrant C standard library function :c:func:`ptsname_r` if it is " "available; otherwise, the C standard library function :c:func:`ptsname`, " "which is not guaranteed to be thread-safe, is called." msgstr "" -#: ../../library/os.rst:1591 +#: ../../library/os.rst:1619 msgid "" "Write the bytestring in *str* to file descriptor *fd* at position of " "*offset*, leaving the file offset unchanged." msgstr "" -#: ../../library/os.rst:1594 ../../library/os.rst:1904 +#: ../../library/os.rst:1622 ../../library/os.rst:1934 msgid "Return the number of bytes actually written." msgstr "" -#: ../../library/os.rst:1603 +#: ../../library/os.rst:1631 msgid "" "Write the *buffers* contents to file descriptor *fd* at an offset *offset*, " "leaving the file offset unchanged. *buffers* must be a sequence of :term:" @@ -1795,39 +1824,43 @@ msgid "" "the second, and so on." msgstr "" -#: ../../library/os.rst:1612 +#: ../../library/os.rst:1640 msgid ":data:`RWF_DSYNC`" msgstr ":data:`RWF_DSYNC`" -#: ../../library/os.rst:1613 +#: ../../library/os.rst:1641 msgid ":data:`RWF_SYNC`" msgstr ":data:`RWF_SYNC`" -#: ../../library/os.rst:1614 +#: ../../library/os.rst:1642 msgid ":data:`RWF_APPEND`" msgstr ":data:`RWF_APPEND`" -#: ../../library/os.rst:1616 +#: ../../library/os.rst:1644 +msgid ":data:`RWF_ATOMIC`" +msgstr ":data:`RWF_ATOMIC`" + +#: ../../library/os.rst:1646 msgid "Return the total number of bytes actually written." msgstr "" -#: ../../library/os.rst:1621 +#: ../../library/os.rst:1651 msgid "Combine the functionality of :func:`os.writev` and :func:`os.pwrite`." msgstr "" -#: ../../library/os.rst:1632 +#: ../../library/os.rst:1662 msgid "" "Provide a per-write equivalent of the :data:`O_DSYNC` :func:`os.open` flag. " "This flag effect applies only to the data range written by the system call." msgstr "" -#: ../../library/os.rst:1642 +#: ../../library/os.rst:1672 msgid "" "Provide a per-write equivalent of the :data:`O_SYNC` :func:`os.open` flag. " "This flag effect applies only to the data range written by the system call." msgstr "" -#: ../../library/os.rst:1652 +#: ../../library/os.rst:1682 msgid "" "Provide a per-write equivalent of the :data:`O_APPEND` :func:`os.open` flag. " "This flag is meaningful only for :func:`os.pwritev`, and its effect applies " @@ -1837,11 +1870,11 @@ msgid "" "*offset* is updated." msgstr "" -#: ../../library/os.rst:1666 +#: ../../library/os.rst:1696 msgid "Read at most *n* bytes from file descriptor *fd*." msgstr "" -#: ../../library/os.rst:1673 +#: ../../library/os.rst:1703 msgid "" "This function is intended for low-level I/O and must be applied to a file " "descriptor as returned by :func:`os.open` or :func:`pipe`. To read a \"file " @@ -1850,13 +1883,13 @@ msgid "" "or :meth:`~io.IOBase.readline` methods." msgstr "" -#: ../../library/os.rst:1687 +#: ../../library/os.rst:1717 msgid "" "Read from a file descriptor *fd* into a mutable :ref:`buffer object " "` *buffer*." msgstr "" -#: ../../library/os.rst:1690 +#: ../../library/os.rst:1720 msgid "" "The *buffer* should be mutable and :term:`bytes-like `. " "On success, returns the number of bytes read. Less bytes may be read than " @@ -1865,14 +1898,14 @@ msgid "" "Other errors will not be retried and an error will be raised." msgstr "" -#: ../../library/os.rst:1696 +#: ../../library/os.rst:1726 msgid "" "Returns 0 if *fd* is at end of file or if the provided *buffer* has length 0 " "(which can be used to check for errors without reading data). Never returns " "negative." msgstr "" -#: ../../library/os.rst:1702 +#: ../../library/os.rst:1732 msgid "" "This function is intended for low-level I/O and must be applied to a file " "descriptor as returned by :func:`os.open` or :func:`os.pipe`. To read a " @@ -1881,26 +1914,26 @@ msgid "" "readinto`, :meth:`io.BufferedIOBase.read`, or :meth:`io.TextIOBase.read`" msgstr "" -#: ../../library/os.rst:1715 +#: ../../library/os.rst:1745 msgid "" "Copy *count* bytes from file descriptor *in_fd* to file descriptor *out_fd* " "starting at *offset*. Return the number of bytes sent. When EOF is reached " "return ``0``." msgstr "" -#: ../../library/os.rst:1719 +#: ../../library/os.rst:1749 msgid "" "The first function notation is supported by all platforms that define :func:" "`sendfile`." msgstr "" -#: ../../library/os.rst:1722 +#: ../../library/os.rst:1752 msgid "" "On Linux, if *offset* is given as ``None``, the bytes are read from the " "current position of *in_fd* and the position of *in_fd* is updated." msgstr "" -#: ../../library/os.rst:1725 +#: ../../library/os.rst:1755 msgid "" "The second case may be used on macOS and FreeBSD where *headers* and " "*trailers* are arbitrary sequences of buffers that are written before and " @@ -1908,91 +1941,91 @@ msgid "" "case." msgstr "" -#: ../../library/os.rst:1729 +#: ../../library/os.rst:1759 msgid "" "On macOS and FreeBSD, a value of ``0`` for *count* specifies to send until " "the end of *in_fd* is reached." msgstr "" -#: ../../library/os.rst:1732 +#: ../../library/os.rst:1762 msgid "" "All platforms support sockets as *out_fd* file descriptor, and some " "platforms allow other types (e.g. regular file, pipe) as well." msgstr "" -#: ../../library/os.rst:1735 +#: ../../library/os.rst:1765 msgid "" "Cross-platform applications should not use *headers*, *trailers* and *flags* " "arguments." msgstr "" -#: ../../library/os.rst:1742 +#: ../../library/os.rst:1772 msgid "" "For a higher-level wrapper of :func:`sendfile`, see :meth:`socket.socket." "sendfile`." msgstr "" -#: ../../library/os.rst:1747 +#: ../../library/os.rst:1777 msgid "Parameters *out* and *in* was renamed to *out_fd* and *in_fd*." msgstr "" -#: ../../library/os.rst:1755 +#: ../../library/os.rst:1785 msgid "" "Parameters to the :func:`sendfile` function, if the implementation supports " "them." msgstr "" -#: ../../library/os.rst:1764 +#: ../../library/os.rst:1794 msgid "" "Parameter to the :func:`sendfile` function, if the implementation supports " "it. The data won't be cached in the virtual memory and will be freed " "afterwards." msgstr "" -#: ../../library/os.rst:1774 +#: ../../library/os.rst:1804 msgid "" "Set the blocking mode of the specified file descriptor. Set the :data:" "`O_NONBLOCK` flag if blocking is ``False``, clear the flag otherwise." msgstr "" -#: ../../library/os.rst:1777 +#: ../../library/os.rst:1807 msgid "See also :func:`get_blocking` and :meth:`socket.socket.setblocking`." msgstr "另請參閱 :func:`get_blocking` 與 :meth:`socket.socket.setblocking`。" -#: ../../library/os.rst:1794 +#: ../../library/os.rst:1824 msgid "" "Transfer *count* bytes from file descriptor *src*, starting from offset " "*offset_src*, to file descriptor *dst*, starting from offset *offset_dst*." msgstr "" -#: ../../library/os.rst:1797 +#: ../../library/os.rst:1827 msgid "" "The splicing behaviour can be modified by specifying a *flags* value. Any of " "the following variables may used, combined using bitwise OR (the ``|`` " "operator):" msgstr "" -#: ../../library/os.rst:1801 +#: ../../library/os.rst:1831 msgid "" "If :const:`SPLICE_F_MOVE` is specified, the kernel is asked to move pages " "instead of copying, but pages may still be copied if the kernel cannot move " "the pages from the pipe." msgstr "" -#: ../../library/os.rst:1805 +#: ../../library/os.rst:1835 msgid "" "If :const:`SPLICE_F_NONBLOCK` is specified, the kernel is asked to not block " "on I/O. This makes the splice pipe operations nonblocking, but splice may " "nevertheless block because the spliced file descriptors may block." msgstr "" -#: ../../library/os.rst:1810 +#: ../../library/os.rst:1840 msgid "" "If :const:`SPLICE_F_MORE` is specified, it hints to the kernel that more " "data will be coming in a subsequent splice." msgstr "" -#: ../../library/os.rst:1813 +#: ../../library/os.rst:1843 msgid "" "At least one of the file descriptors must refer to a pipe. If *offset_src* " "is ``None``, then *src* is read from the current position; respectively for " @@ -2002,7 +2035,7 @@ msgid "" "`~OSError.errno` set to :const:`errno.EXDEV`." msgstr "" -#: ../../library/os.rst:1820 +#: ../../library/os.rst:1850 msgid "" "This copy is done without the additional cost of transferring data from the " "kernel to user space and then back into the kernel. Additionally, some " @@ -2010,7 +2043,7 @@ msgid "" "files are opened as binary." msgstr "" -#: ../../library/os.rst:1825 +#: ../../library/os.rst:1855 msgid "" "Upon successful completion, returns the number of bytes spliced to or from " "the pipe. A return value of 0 means end of input. If *src* refers to a pipe, " @@ -2019,11 +2052,11 @@ msgid "" "the pipe." msgstr "" -#: ../../library/os.rst:1831 +#: ../../library/os.rst:1861 msgid "The :manpage:`splice(2)` man page." msgstr ":manpage:`splice(2)` 使用手冊。" -#: ../../library/os.rst:1846 +#: ../../library/os.rst:1876 msgid "" "Read from a file descriptor *fd* into a number of mutable :term:`bytes-like " "objects ` *buffers*. Transfer data into each buffer until " @@ -2031,41 +2064,41 @@ msgid "" "rest of the data." msgstr "" -#: ../../library/os.rst:1864 +#: ../../library/os.rst:1894 msgid "" "Return the process group associated with the terminal given by *fd* (an open " "file descriptor as returned by :func:`os.open`)." msgstr "" -#: ../../library/os.rst:1872 +#: ../../library/os.rst:1902 msgid "" "Set the process group associated with the terminal given by *fd* (an open " "file descriptor as returned by :func:`os.open`) to *pg*." msgstr "" -#: ../../library/os.rst:1880 +#: ../../library/os.rst:1910 msgid "" "Return a string which specifies the terminal device associated with file " "descriptor *fd*. If *fd* is not associated with a terminal device, an " "exception is raised." msgstr "" -#: ../../library/os.rst:1889 +#: ../../library/os.rst:1919 msgid "" "Unlock the slave pseudo-terminal device associated with the master pseudo-" "terminal device to which the file descriptor *fd* refers. The file " "descriptor *fd* is not closed upon failure." msgstr "" -#: ../../library/os.rst:1893 +#: ../../library/os.rst:1923 msgid "Calls the C standard library function :c:func:`unlockpt`." msgstr "" -#: ../../library/os.rst:1902 +#: ../../library/os.rst:1932 msgid "Write the bytestring in *str* to file descriptor *fd*." msgstr "" -#: ../../library/os.rst:1908 +#: ../../library/os.rst:1938 msgid "" "This function is intended for low-level I/O and must be applied to a file " "descriptor as returned by :func:`os.open` or :func:`pipe`. To write a " @@ -2074,7 +2107,7 @@ msgid "" "its :meth:`~io.TextIOBase.write` method." msgstr "" -#: ../../library/os.rst:1922 +#: ../../library/os.rst:1952 msgid "" "Write the contents of *buffers* to file descriptor *fd*. *buffers* must be a " "sequence of :term:`bytes-like objects `. Buffers are " @@ -2082,64 +2115,64 @@ msgid "" "before proceeding to the second, and so on." msgstr "" -#: ../../library/os.rst:1927 +#: ../../library/os.rst:1957 msgid "Returns the total number of bytes actually written." msgstr "" -#: ../../library/os.rst:1940 +#: ../../library/os.rst:1970 msgid "Querying the size of a terminal" msgstr "" -#: ../../library/os.rst:1946 +#: ../../library/os.rst:1976 msgid "" "Return the size of the terminal window as ``(columns, lines)``, tuple of " "type :class:`terminal_size`." msgstr "" -#: ../../library/os.rst:1949 +#: ../../library/os.rst:1979 msgid "" "The optional argument ``fd`` (default ``STDOUT_FILENO``, or standard output) " "specifies which file descriptor should be queried." msgstr "" -#: ../../library/os.rst:1952 +#: ../../library/os.rst:1982 msgid "" "If the file descriptor is not connected to a terminal, an :exc:`OSError` is " "raised." msgstr "" -#: ../../library/os.rst:1955 +#: ../../library/os.rst:1985 msgid "" ":func:`shutil.get_terminal_size` is the high-level function which should " "normally be used, ``os.get_terminal_size`` is the low-level implementation." msgstr "" -#: ../../library/os.rst:1963 +#: ../../library/os.rst:1993 msgid "" "A subclass of tuple, holding ``(columns, lines)`` of the terminal window " "size." msgstr "" -#: ../../library/os.rst:1967 +#: ../../library/os.rst:1997 msgid "Width of the terminal window in characters." msgstr "" -#: ../../library/os.rst:1971 +#: ../../library/os.rst:2001 msgid "Height of the terminal window in characters." msgstr "" -#: ../../library/os.rst:1977 +#: ../../library/os.rst:2007 msgid "Inheritance of File Descriptors" msgstr "" -#: ../../library/os.rst:1981 +#: ../../library/os.rst:2011 msgid "" "A file descriptor has an \"inheritable\" flag which indicates if the file " "descriptor can be inherited by child processes. Since Python 3.4, file " "descriptors created by Python are non-inheritable by default." msgstr "" -#: ../../library/os.rst:1985 +#: ../../library/os.rst:2015 msgid "" "On UNIX, non-inheritable file descriptors are closed in child processes at " "the execution of a new program, other file descriptors are inherited. Note " @@ -2147,7 +2180,7 @@ msgid "" "processes on :func:`os.fork`." msgstr "" -#: ../../library/os.rst:1989 +#: ../../library/os.rst:2019 msgid "" "On Windows, non-inheritable handles and file descriptors are closed in child " "processes, except for standard streams (file descriptors 0, 1 and 2: stdin, " @@ -2158,38 +2191,38 @@ msgid "" "only inherited if the *close_fds* parameter is ``False``." msgstr "" -#: ../../library/os.rst:1997 +#: ../../library/os.rst:2027 msgid "On WebAssembly platforms, the file descriptor cannot be modified." msgstr "" -#: ../../library/os.rst:2001 +#: ../../library/os.rst:2031 msgid "" "Get the \"inheritable\" flag of the specified file descriptor (a boolean)." msgstr "" -#: ../../library/os.rst:2005 +#: ../../library/os.rst:2035 msgid "Set the \"inheritable\" flag of the specified file descriptor." msgstr "" -#: ../../library/os.rst:2009 +#: ../../library/os.rst:2039 msgid "Get the \"inheritable\" flag of the specified handle (a boolean)." msgstr "" -#: ../../library/os.rst:2015 +#: ../../library/os.rst:2045 msgid "Set the \"inheritable\" flag of the specified handle." msgstr "" -#: ../../library/os.rst:2023 +#: ../../library/os.rst:2053 msgid "Files and Directories" msgstr "" -#: ../../library/os.rst:2025 +#: ../../library/os.rst:2055 msgid "" "On some Unix platforms, many of these functions support one or more of these " "features:" msgstr "" -#: ../../library/os.rst:2030 +#: ../../library/os.rst:2060 msgid "" "**specifying a file descriptor:** Normally the *path* argument provided to " "functions in the :mod:`!os` module must be a string specifying a file path. " @@ -2199,7 +2232,7 @@ msgid "" "function prefixed with ``f`` (e.g. call ``fchdir`` instead of ``chdir``)." msgstr "" -#: ../../library/os.rst:2038 +#: ../../library/os.rst:2068 msgid "" "You can check whether or not *path* can be specified as a file descriptor " "for a particular function on your platform using :data:`os.supports_fd`. If " @@ -2207,13 +2240,13 @@ msgid "" "`NotImplementedError`." msgstr "" -#: ../../library/os.rst:2043 +#: ../../library/os.rst:2073 msgid "" "If the function also supports *dir_fd* or *follow_symlinks* arguments, it's " "an error to specify one of those when supplying *path* as a file descriptor." msgstr "" -#: ../../library/os.rst:2048 +#: ../../library/os.rst:2078 msgid "" "**paths relative to directory descriptors:** If *dir_fd* is not ``None``, it " "should be a file descriptor referring to a directory, and the path to " @@ -2224,14 +2257,14 @@ msgid "" "``access``)." msgstr "" -#: ../../library/os.rst:2055 +#: ../../library/os.rst:2085 msgid "" "You can check whether or not *dir_fd* is supported for a particular function " "on your platform using :data:`os.supports_dir_fd`. If it's unavailable, " "using it will raise a :exc:`NotImplementedError`." msgstr "" -#: ../../library/os.rst:2061 +#: ../../library/os.rst:2091 msgid "" "**not following symlinks:** If *follow_symlinks* is ``False``, and the last " "element of the path to operate on is a symbolic link, the function will " @@ -2240,14 +2273,14 @@ msgid "" "function." msgstr "" -#: ../../library/os.rst:2067 +#: ../../library/os.rst:2097 msgid "" "You can check whether or not *follow_symlinks* is supported for a particular " "function on your platform using :data:`os.supports_follow_symlinks`. If it's " "unavailable, using it will raise a :exc:`NotImplementedError`." msgstr "" -#: ../../library/os.rst:2075 +#: ../../library/os.rst:2105 msgid "" "Use the real uid/gid to test for access to *path*. Note that most " "operations will use the effective uid/gid, therefore this routine can be " @@ -2259,13 +2292,13 @@ msgid "" "manpage:`access(2)` for more information." msgstr "" -#: ../../library/os.rst:2084 +#: ../../library/os.rst:2114 msgid "" "This function can support specifying :ref:`paths relative to directory " "descriptors ` and :ref:`not following symlinks `." msgstr "" -#: ../../library/os.rst:2087 +#: ../../library/os.rst:2117 msgid "" "If *effective_ids* is ``True``, :func:`access` will perform its access " "checks using the effective uid/gid instead of the real uid/gid. " @@ -2274,7 +2307,7 @@ msgid "" "unavailable, using it will raise a :exc:`NotImplementedError`." msgstr "" -#: ../../library/os.rst:2095 +#: ../../library/os.rst:2125 msgid "" "Using :func:`access` to check if a user is authorized to e.g. open a file " "before actually doing so using :func:`open` creates a security hole, because " @@ -2283,7 +2316,7 @@ msgid "" "For example::" msgstr "" -#: ../../library/os.rst:2101 +#: ../../library/os.rst:2131 msgid "" "if os.access(\"myfile\", os.R_OK):\n" " with open(\"myfile\") as fp:\n" @@ -2295,11 +2328,11 @@ msgstr "" " return fp.read()\n" "return \"some default data\"" -#: ../../library/os.rst:2106 +#: ../../library/os.rst:2136 msgid "is better written as::" msgstr "" -#: ../../library/os.rst:2108 +#: ../../library/os.rst:2138 msgid "" "try:\n" " fp = open(\"myfile\")\n" @@ -2317,119 +2350,119 @@ msgstr "" " with fp:\n" " return fp.read()" -#: ../../library/os.rst:2118 +#: ../../library/os.rst:2148 msgid "" "I/O operations may fail even when :func:`access` indicates that they would " "succeed, particularly for operations on network filesystems which may have " "permissions semantics beyond the usual POSIX permission-bit model." msgstr "" -#: ../../library/os.rst:2122 +#: ../../library/os.rst:2152 msgid "Added the *dir_fd*, *effective_ids*, and *follow_symlinks* parameters." msgstr "新增 *dir_fd*、*effective_ids* 與 *follow_symlinks* 參數。" -#: ../../library/os.rst:2134 +#: ../../library/os.rst:2164 msgid "" "Values to pass as the *mode* parameter of :func:`access` to test the " "existence, readability, writability and executability of *path*, " "respectively." msgstr "" -#: ../../library/os.rst:2143 +#: ../../library/os.rst:2173 msgid "Change the current working directory to *path*." msgstr "" -#: ../../library/os.rst:2145 +#: ../../library/os.rst:2175 msgid "" "This function can support :ref:`specifying a file descriptor `. " "The descriptor must refer to an opened directory, not an open file." msgstr "" -#: ../../library/os.rst:2148 +#: ../../library/os.rst:2178 msgid "" "This function can raise :exc:`OSError` and subclasses such as :exc:" "`FileNotFoundError`, :exc:`PermissionError`, and :exc:`NotADirectoryError`." msgstr "" -#: ../../library/os.rst:2151 ../../library/os.rst:2294 +#: ../../library/os.rst:2181 ../../library/os.rst:2324 msgid "" "Raises an :ref:`auditing event ` ``os.chdir`` with argument " "``path``." msgstr "" "引發一個附帶引數 ``path`` 的\\ :ref:`稽核事件 ` ``os.chdir``。" -#: ../../library/os.rst:2155 +#: ../../library/os.rst:2185 msgid "" "The :func:`contextlib.chdir` context manager, which changes the current " "working directory on entering and restores the previous one on exit." msgstr "" -#: ../../library/os.rst:2158 +#: ../../library/os.rst:2188 msgid "" "Added support for specifying *path* as a file descriptor on some platforms." msgstr "" -#: ../../library/os.rst:2168 +#: ../../library/os.rst:2198 msgid "" "Set the flags of *path* to the numeric *flags*. *flags* may take a " "combination (bitwise OR) of the following values (as defined in the :mod:" "`stat` module):" msgstr "" -#: ../../library/os.rst:2171 +#: ../../library/os.rst:2201 msgid ":const:`stat.UF_NODUMP`" msgstr ":const:`stat.UF_NODUMP`" -#: ../../library/os.rst:2172 +#: ../../library/os.rst:2202 msgid ":const:`stat.UF_IMMUTABLE`" msgstr ":const:`stat.UF_IMMUTABLE`" -#: ../../library/os.rst:2173 +#: ../../library/os.rst:2203 msgid ":const:`stat.UF_APPEND`" msgstr ":const:`stat.UF_APPEND`" -#: ../../library/os.rst:2174 +#: ../../library/os.rst:2204 msgid ":const:`stat.UF_OPAQUE`" msgstr ":const:`stat.UF_OPAQUE`" -#: ../../library/os.rst:2175 +#: ../../library/os.rst:2205 msgid ":const:`stat.UF_NOUNLINK`" msgstr ":const:`stat.UF_NOUNLINK`" -#: ../../library/os.rst:2176 +#: ../../library/os.rst:2206 msgid ":const:`stat.UF_COMPRESSED`" msgstr ":const:`stat.UF_COMPRESSED`" -#: ../../library/os.rst:2177 +#: ../../library/os.rst:2207 msgid ":const:`stat.UF_HIDDEN`" msgstr ":const:`stat.UF_HIDDEN`" -#: ../../library/os.rst:2178 +#: ../../library/os.rst:2208 msgid ":const:`stat.SF_ARCHIVED`" msgstr ":const:`stat.SF_ARCHIVED`" -#: ../../library/os.rst:2179 +#: ../../library/os.rst:2209 msgid ":const:`stat.SF_IMMUTABLE`" msgstr ":const:`stat.SF_IMMUTABLE`" -#: ../../library/os.rst:2180 +#: ../../library/os.rst:2210 msgid ":const:`stat.SF_APPEND`" msgstr ":const:`stat.SF_APPEND`" -#: ../../library/os.rst:2181 +#: ../../library/os.rst:2211 msgid ":const:`stat.SF_NOUNLINK`" msgstr ":const:`stat.SF_NOUNLINK`" -#: ../../library/os.rst:2182 +#: ../../library/os.rst:2212 msgid ":const:`stat.SF_SNAPSHOT`" msgstr ":const:`stat.SF_SNAPSHOT`" -#: ../../library/os.rst:2184 +#: ../../library/os.rst:2214 msgid "" "This function can support :ref:`not following symlinks `." msgstr "" -#: ../../library/os.rst:2186 ../../library/os.rst:2320 +#: ../../library/os.rst:2216 ../../library/os.rst:2350 msgid "" "Raises an :ref:`auditing event ` ``os.chflags`` with arguments " "``path``, ``flags``." @@ -2437,102 +2470,102 @@ msgstr "" "引發一個附帶引數 ``path``、``flags`` 的\\ :ref:`稽核事件 ` ``os." "chflags``。" -#: ../../library/os.rst:2190 +#: ../../library/os.rst:2220 msgid "Added the *follow_symlinks* parameter." msgstr "新增 *follow_symlinks* 參數。" -#: ../../library/os.rst:2199 +#: ../../library/os.rst:2229 msgid "" "Change the mode of *path* to the numeric *mode*. *mode* may take one of the " "following values (as defined in the :mod:`stat` module) or bitwise ORed " "combinations of them:" msgstr "" -#: ../../library/os.rst:2203 +#: ../../library/os.rst:2233 msgid ":const:`stat.S_ISUID`" msgstr ":const:`stat.S_ISUID`" -#: ../../library/os.rst:2204 +#: ../../library/os.rst:2234 msgid ":const:`stat.S_ISGID`" msgstr ":const:`stat.S_ISGID`" -#: ../../library/os.rst:2205 +#: ../../library/os.rst:2235 msgid ":const:`stat.S_ENFMT`" msgstr ":const:`stat.S_ENFMT`" -#: ../../library/os.rst:2206 +#: ../../library/os.rst:2236 msgid ":const:`stat.S_ISVTX`" msgstr ":const:`stat.S_ISVTX`" -#: ../../library/os.rst:2207 +#: ../../library/os.rst:2237 msgid ":const:`stat.S_IREAD`" msgstr ":const:`stat.S_IREAD`" -#: ../../library/os.rst:2208 +#: ../../library/os.rst:2238 msgid ":const:`stat.S_IWRITE`" msgstr ":const:`stat.S_IWRITE`" -#: ../../library/os.rst:2209 +#: ../../library/os.rst:2239 msgid ":const:`stat.S_IEXEC`" msgstr ":const:`stat.S_IEXEC`" -#: ../../library/os.rst:2210 +#: ../../library/os.rst:2240 msgid ":const:`stat.S_IRWXU`" msgstr ":const:`stat.S_IRWXU`" -#: ../../library/os.rst:2211 +#: ../../library/os.rst:2241 msgid ":const:`stat.S_IRUSR`" msgstr ":const:`stat.S_IRUSR`" -#: ../../library/os.rst:2212 +#: ../../library/os.rst:2242 msgid ":const:`stat.S_IWUSR`" msgstr ":const:`stat.S_IWUSR`" -#: ../../library/os.rst:2213 +#: ../../library/os.rst:2243 msgid ":const:`stat.S_IXUSR`" msgstr ":const:`stat.S_IXUSR`" -#: ../../library/os.rst:2214 +#: ../../library/os.rst:2244 msgid ":const:`stat.S_IRWXG`" msgstr ":const:`stat.S_IRWXG`" -#: ../../library/os.rst:2215 +#: ../../library/os.rst:2245 msgid ":const:`stat.S_IRGRP`" msgstr ":const:`stat.S_IRGRP`" -#: ../../library/os.rst:2216 +#: ../../library/os.rst:2246 msgid ":const:`stat.S_IWGRP`" msgstr ":const:`stat.S_IWGRP`" -#: ../../library/os.rst:2217 +#: ../../library/os.rst:2247 msgid ":const:`stat.S_IXGRP`" msgstr ":const:`stat.S_IXGRP`" -#: ../../library/os.rst:2218 +#: ../../library/os.rst:2248 msgid ":const:`stat.S_IRWXO`" msgstr ":const:`stat.S_IRWXO`" -#: ../../library/os.rst:2219 +#: ../../library/os.rst:2249 msgid ":const:`stat.S_IROTH`" msgstr ":const:`stat.S_IROTH`" -#: ../../library/os.rst:2220 +#: ../../library/os.rst:2250 msgid ":const:`stat.S_IWOTH`" msgstr ":const:`stat.S_IWOTH`" -#: ../../library/os.rst:2221 +#: ../../library/os.rst:2251 msgid ":const:`stat.S_IXOTH`" msgstr ":const:`stat.S_IXOTH`" -#: ../../library/os.rst:2223 ../../library/os.rst:2256 -#: ../../library/os.rst:3791 +#: ../../library/os.rst:2253 ../../library/os.rst:2286 +#: ../../library/os.rst:4202 msgid "" "This function can support :ref:`specifying a file descriptor `, :" "ref:`paths relative to directory descriptors ` and :ref:`not " "following symlinks `." msgstr "" -#: ../../library/os.rst:2229 +#: ../../library/os.rst:2259 msgid "" "Although Windows supports :func:`chmod`, you can only set the file's read-" "only flag with it (via the ``stat.S_IWRITE`` and ``stat.S_IREAD`` constants " @@ -2540,68 +2573,68 @@ msgid "" "value of *follow_symlinks* is ``False`` on Windows." msgstr "" -#: ../../library/os.rst:2239 ../../library/os.rst:2270 +#: ../../library/os.rst:2269 ../../library/os.rst:2300 msgid "" "Added support for specifying *path* as an open file descriptor, and the " "*dir_fd* and *follow_symlinks* arguments." msgstr "" -#: ../../library/os.rst:2246 +#: ../../library/os.rst:2276 msgid "" "Added support for a file descriptor and the *follow_symlinks* argument on " "Windows." msgstr "" -#: ../../library/os.rst:2253 +#: ../../library/os.rst:2283 msgid "" "Change the owner and group id of *path* to the numeric *uid* and *gid*. To " "leave one of the ids unchanged, set it to -1." msgstr "" -#: ../../library/os.rst:2260 +#: ../../library/os.rst:2290 msgid "" "See :func:`shutil.chown` for a higher-level function that accepts names in " "addition to numeric ids." msgstr "" -#: ../../library/os.rst:2274 +#: ../../library/os.rst:2304 msgid "Supports a :term:`path-like object`." msgstr "" -#: ../../library/os.rst:2280 +#: ../../library/os.rst:2310 msgid "Change the root directory of the current process to *path*." msgstr "" -#: ../../library/os.rst:2290 +#: ../../library/os.rst:2320 msgid "" "Change the current working directory to the directory represented by the " "file descriptor *fd*. The descriptor must refer to an opened directory, not " "an open file. As of Python 3.3, this is equivalent to ``os.chdir(fd)``." msgstr "" -#: ../../library/os.rst:2301 +#: ../../library/os.rst:2331 msgid "Return a string representing the current working directory." msgstr "" -#: ../../library/os.rst:2306 +#: ../../library/os.rst:2336 msgid "Return a bytestring representing the current working directory." msgstr "" -#: ../../library/os.rst:2308 +#: ../../library/os.rst:2338 msgid "" "The function now uses the UTF-8 encoding on Windows, rather than the ANSI " "code page: see :pep:`529` for the rationale. The function is no longer " "deprecated on Windows." msgstr "" -#: ../../library/os.rst:2316 +#: ../../library/os.rst:2346 msgid "" "Set the flags of *path* to the numeric *flags*, like :func:`chflags`, but do " "not follow symbolic links. As of Python 3.3, this is equivalent to ``os." "chflags(path, flags, follow_symlinks=False)``." msgstr "" -#: ../../library/os.rst:2330 +#: ../../library/os.rst:2360 msgid "" "Change the mode of *path* to the numeric *mode*. If path is a symlink, this " "affects the symlink rather than the target. See the docs for :func:`chmod` " @@ -2609,24 +2642,24 @@ msgid "" "chmod(path, mode, follow_symlinks=False)``." msgstr "" -#: ../../library/os.rst:2335 +#: ../../library/os.rst:2365 msgid "" "``lchmod()`` is not part of POSIX, but Unix implementations may have it if " "changing the mode of symbolic links is supported." msgstr "" -#: ../../library/os.rst:2350 +#: ../../library/os.rst:2380 msgid "" "Change the owner and group id of *path* to the numeric *uid* and *gid*. " "This function will not follow symbolic links. As of Python 3.3, this is " "equivalent to ``os.chown(path, uid, gid, follow_symlinks=False)``." msgstr "" -#: ../../library/os.rst:2364 +#: ../../library/os.rst:2394 msgid "Create a hard link pointing to *src* named *dst*." msgstr "" -#: ../../library/os.rst:2366 +#: ../../library/os.rst:2396 msgid "" "This function can support specifying *src_dir_fd* and/or *dst_dir_fd* to " "supply :ref:`paths relative to directory descriptors `, and :ref:" @@ -2634,7 +2667,7 @@ msgid "" "*follow_symlinks* is ``False`` on Windows." msgstr "" -#: ../../library/os.rst:2371 +#: ../../library/os.rst:2401 msgid "" "Raises an :ref:`auditing event ` ``os.link`` with arguments " "``src``, ``dst``, ``src_dir_fd``, ``dst_dir_fd``." @@ -2642,20 +2675,20 @@ msgstr "" "引發一個附帶引數 ``src``、``dst``、``src_dir_fd``、``dst_dir_fd`` 的\\ :ref:`" "稽核事件 ` ``os.link``。" -#: ../../library/os.rst:2375 ../../library/os.rst:4788 +#: ../../library/os.rst:2405 ../../library/os.rst:5211 msgid "Added Windows support." msgstr "新支援 Windows。" -#: ../../library/os.rst:2378 +#: ../../library/os.rst:2408 msgid "Added the *src_dir_fd*, *dst_dir_fd*, and *follow_symlinks* parameters." msgstr "新增 *src_dir_fd*、*dst_dir_fd* 與 *follow_symlinks* 參數。" -#: ../../library/os.rst:2381 ../../library/os.rst:2805 -#: ../../library/os.rst:2842 ../../library/os.rst:3713 +#: ../../library/os.rst:2411 ../../library/os.rst:2858 +#: ../../library/os.rst:2895 ../../library/os.rst:4123 msgid "Accepts a :term:`path-like object` for *src* and *dst*." msgstr "" -#: ../../library/os.rst:2387 +#: ../../library/os.rst:2417 msgid "" "Return a list containing the names of the entries in the directory given by " "*path*. The list is in arbitrary order, and does not include the special " @@ -2664,7 +2697,7 @@ msgid "" "function, whether a name for that file be included is unspecified." msgstr "" -#: ../../library/os.rst:2393 +#: ../../library/os.rst:2423 msgid "" "*path* may be a :term:`path-like object`. If *path* is of type ``bytes`` " "(directly or indirectly through the :class:`PathLike` interface), the " @@ -2672,42 +2705,48 @@ msgid "" "circumstances, they will be of type ``str``." msgstr "" -#: ../../library/os.rst:2398 ../../library/os.rst:2890 +#: ../../library/os.rst:2428 ../../library/os.rst:2943 msgid "" "This function can also support :ref:`specifying a file descriptor " "`; the file descriptor must refer to a directory." msgstr "" -#: ../../library/os.rst:2401 +#: ../../library/os.rst:2431 msgid "" "Raises an :ref:`auditing event ` ``os.listdir`` with argument " "``path``." msgstr "" "引發一個附帶引數 ``path`` 的\\ :ref:`稽核事件 ` ``os.listdir``。" -#: ../../library/os.rst:2404 +#: ../../library/os.rst:2434 msgid "To encode ``str`` filenames to ``bytes``, use :func:`~os.fsencode`." msgstr "" -#: ../../library/os.rst:2408 +#: ../../library/os.rst:2438 msgid "" "The :func:`scandir` function returns directory entries along with file " "attribute information, giving better performance for many common use cases." msgstr "" -#: ../../library/os.rst:2412 +#: ../../library/os.rst:2442 msgid "The *path* parameter became optional." msgstr "*path* 參數變為可選。" -#: ../../library/os.rst:2415 ../../library/os.rst:3424 +#: ../../library/os.rst:2445 ../../library/os.rst:3834 msgid "Added support for specifying *path* as an open file descriptor." msgstr "" -#: ../../library/os.rst:2424 +#: ../../library/os.rst:2451 +msgid "" +"``os.listdir(-1)`` now fails with ``OSError(errno.EBADF)`` rather than " +"listing the current directory." +msgstr "" + +#: ../../library/os.rst:2458 msgid "Return a list containing the names of drives on a Windows system." msgstr "" -#: ../../library/os.rst:2426 +#: ../../library/os.rst:2460 msgid "" "A drive name typically looks like ``'C:\\\\'``. Not every drive name will be " "associated with a volume, and some may be inaccessible for a variety of " @@ -2715,22 +2754,22 @@ msgid "" "function does not test for access." msgstr "" -#: ../../library/os.rst:2431 +#: ../../library/os.rst:2465 msgid "May raise :exc:`OSError` if an error occurs collecting the drive names." msgstr "" -#: ../../library/os.rst:2434 +#: ../../library/os.rst:2468 msgid "" "Raises an :ref:`auditing event ` ``os.listdrives`` with no " "arguments." msgstr "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``os.listdrives``。" -#: ../../library/os.rst:2443 +#: ../../library/os.rst:2477 msgid "" "Return a list containing the mount points for a volume on a Windows system." msgstr "" -#: ../../library/os.rst:2446 +#: ../../library/os.rst:2480 msgid "" "*volume* must be represented as a GUID path, like those returned by :func:" "`os.listvolumes`. Volumes may be mounted in multiple locations or not at " @@ -2738,19 +2777,19 @@ msgid "" "associated with a volume will not be returned by this function." msgstr "" -#: ../../library/os.rst:2452 +#: ../../library/os.rst:2486 msgid "" "The mount points return by this function will be absolute paths, and may be " "longer than the drive name." msgstr "" -#: ../../library/os.rst:2455 +#: ../../library/os.rst:2489 msgid "" "Raises :exc:`OSError` if the volume is not recognized or if an error occurs " "collecting the paths." msgstr "" -#: ../../library/os.rst:2458 +#: ../../library/os.rst:2492 msgid "" "Raises an :ref:`auditing event ` ``os.listmounts`` with argument " "``volume``." @@ -2758,11 +2797,11 @@ msgstr "" "引發一個附帶引數 ``volume`` 的\\ :ref:`稽核事件 ` ``os." "listmounts``。" -#: ../../library/os.rst:2467 +#: ../../library/os.rst:2501 msgid "Return a list containing the volumes in the system." msgstr "" -#: ../../library/os.rst:2469 +#: ../../library/os.rst:2503 msgid "" "Volumes are typically represented as a GUID path that looks like ``\\\\?" "\\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\\``. Files can usually be " @@ -2771,49 +2810,49 @@ msgid "" "function is to retrieve mount points using :func:`os.listmounts`." msgstr "" -#: ../../library/os.rst:2476 +#: ../../library/os.rst:2510 msgid "May raise :exc:`OSError` if an error occurs collecting the volumes." msgstr "" -#: ../../library/os.rst:2478 +#: ../../library/os.rst:2512 msgid "" "Raises an :ref:`auditing event ` ``os.listvolumes`` with no " "arguments." msgstr "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``os.listvolumes``。" -#: ../../library/os.rst:2487 +#: ../../library/os.rst:2521 msgid "" "Perform the equivalent of an :c:func:`!lstat` system call on the given path. " "Similar to :func:`~os.stat`, but does not follow symbolic links. Return a :" "class:`stat_result` object." msgstr "" -#: ../../library/os.rst:2491 +#: ../../library/os.rst:2525 msgid "" "On platforms that do not support symbolic links, this is an alias for :func:" "`~os.stat`." msgstr "" -#: ../../library/os.rst:2494 +#: ../../library/os.rst:2528 msgid "" "As of Python 3.3, this is equivalent to ``os.stat(path, dir_fd=dir_fd, " "follow_symlinks=False)``." msgstr "" -#: ../../library/os.rst:2497 ../../library/os.rst:2539 -#: ../../library/os.rst:2607 ../../library/os.rst:2635 -#: ../../library/os.rst:2709 +#: ../../library/os.rst:2531 ../../library/os.rst:2573 +#: ../../library/os.rst:2653 ../../library/os.rst:2681 +#: ../../library/os.rst:2762 msgid "" "This function can also support :ref:`paths relative to directory descriptors " "`." msgstr "" -#: ../../library/os.rst:2504 ../../library/os.rst:2718 -#: ../../library/os.rst:3706 +#: ../../library/os.rst:2538 ../../library/os.rst:2771 +#: ../../library/os.rst:4116 msgid "Added support for Windows 6.0 (Vista) symbolic links." msgstr "" -#: ../../library/os.rst:2513 +#: ../../library/os.rst:2547 msgid "" "On Windows, now opens reparse points that represent another path (name " "surrogates), including symbolic links and directory junctions. Other kinds " @@ -2821,18 +2860,18 @@ msgid "" "stat`." msgstr "" -#: ../../library/os.rst:2522 +#: ../../library/os.rst:2556 msgid "Create a directory named *path* with numeric mode *mode*." msgstr "" -#: ../../library/os.rst:2524 +#: ../../library/os.rst:2558 msgid "" "If the directory already exists, :exc:`FileExistsError` is raised. If a " "parent directory in the path does not exist, :exc:`FileNotFoundError` is " "raised." msgstr "" -#: ../../library/os.rst:2529 +#: ../../library/os.rst:2563 msgid "" "On some systems, *mode* is ignored. Where it is used, the current umask " "value is first masked out. If bits other than the last 9 (i.e. the last 3 " @@ -2841,20 +2880,20 @@ msgid "" "call :func:`chmod` explicitly to set them." msgstr "" -#: ../../library/os.rst:2535 +#: ../../library/os.rst:2569 msgid "" "On Windows, a *mode* of ``0o700`` is specifically handled to apply access " "control to the new directory such that only the current user and " "administrators have access. Other values of *mode* are ignored." msgstr "" -#: ../../library/os.rst:2542 +#: ../../library/os.rst:2576 msgid "" "It is also possible to create temporary directories; see the :mod:`tempfile` " "module's :func:`tempfile.mkdtemp` function." msgstr "" -#: ../../library/os.rst:2545 ../../library/os.rst:2582 +#: ../../library/os.rst:2579 ../../library/os.rst:2623 msgid "" "Raises an :ref:`auditing event ` ``os.mkdir`` with arguments " "``path``, ``mode``, ``dir_fd``." @@ -2862,17 +2901,17 @@ msgstr "" "引發一個附帶引數 ``path``、``mode``、``dir_fd`` 的\\ :ref:`稽核事件 " "` ``os.mkdir``。" -#: ../../library/os.rst:2553 +#: ../../library/os.rst:2587 msgid "Windows now handles a *mode* of ``0o700``." msgstr "" -#: ../../library/os.rst:2563 +#: ../../library/os.rst:2598 msgid "" "Recursive directory creation function. Like :func:`mkdir`, but makes all " "intermediate-level directories needed to contain the leaf directory." msgstr "" -#: ../../library/os.rst:2566 +#: ../../library/os.rst:2601 msgid "" "The *mode* parameter is passed to :func:`mkdir` for creating the leaf " "directory; see :ref:`the mkdir() description ` for how it is " @@ -2881,27 +2920,36 @@ msgid "" "file permission bits of existing parent directories are not changed." msgstr "" -#: ../../library/os.rst:2572 +#: ../../library/os.rst:2607 msgid "" "If *exist_ok* is ``False`` (the default), a :exc:`FileExistsError` is raised " "if the target directory already exists." msgstr "" -#: ../../library/os.rst:2577 +#: ../../library/os.rst:2610 +msgid "" +"If *parent_mode* is not ``None``, it is used as the mode for any newly-" +"created, intermediate-level directories. Like *mode*, it is combined with " +"the process's umask value; see :ref:`the mkdir() description " +"`. Otherwise, intermediate directories are created with the " +"default mode, which is also subject to the umask." +msgstr "" + +#: ../../library/os.rst:2618 msgid "" ":func:`makedirs` will become confused if the path elements to create " "include :data:`pardir` (eg. \"..\" on UNIX systems)." msgstr "" -#: ../../library/os.rst:2580 +#: ../../library/os.rst:2621 msgid "This function handles UNC paths correctly." msgstr "" -#: ../../library/os.rst:2584 +#: ../../library/os.rst:2625 msgid "Added the *exist_ok* parameter." msgstr "新增 *exist_ok* 參數。" -#: ../../library/os.rst:2589 +#: ../../library/os.rst:2630 msgid "" "Before Python 3.4.1, if *exist_ok* was ``True`` and the directory existed, :" "func:`makedirs` would still raise an error if *mode* did not match the mode " @@ -2909,19 +2957,26 @@ msgid "" "safely, it was removed in Python 3.4.1. See :issue:`21082`." msgstr "" -#: ../../library/os.rst:2597 +#: ../../library/os.rst:2638 msgid "" "The *mode* argument no longer affects the file permission bits of newly " "created intermediate-level directories." msgstr "" -#: ../../library/os.rst:2604 +#: ../../library/os.rst:2642 +msgid "" +"The *parent_mode* parameter. To match the behavior from Python 3.6 and " +"earlier (where *mode* was applied to all created directories), pass " +"``parent_mode=mode``." +msgstr "" + +#: ../../library/os.rst:2650 msgid "" "Create a FIFO (a named pipe) named *path* with numeric mode *mode*. The " "current umask value is first masked out from the mode." msgstr "" -#: ../../library/os.rst:2610 +#: ../../library/os.rst:2656 msgid "" "FIFOs are pipes that can be accessed like regular files. FIFOs exist until " "they are deleted (for example with :func:`os.unlink`). Generally, FIFOs are " @@ -2931,34 +2986,40 @@ msgid "" "rendezvous point." msgstr "" -#: ../../library/os.rst:2627 +#: ../../library/os.rst:2673 msgid "" "Create a filesystem node (file, device special file or named pipe) named " "*path*. *mode* specifies both the permissions to use and the type of node to " -"be created, being combined (bitwise OR) with one of ``stat.S_IFREG``, ``stat." -"S_IFCHR``, ``stat.S_IFBLK``, and ``stat.S_IFIFO`` (those constants are " -"available in :mod:`stat`). For ``stat.S_IFCHR`` and ``stat.S_IFBLK``, " -"*device* defines the newly created device special file (probably using :func:" -"`os.makedev`), otherwise it is ignored." +"be created, being combined (bitwise OR) with one of :const:`stat.S_IFREG`, :" +"const:`stat.S_IFCHR`, :const:`stat.S_IFBLK`, and :const:`stat.S_IFIFO`. For :" +"const:`stat.S_IFCHR` and :const:`stat.S_IFBLK`, *device* defines the newly " +"created device special file (probably using :func:`os.makedev`), otherwise " +"it is ignored." msgstr "" -#: ../../library/os.rst:2649 +#: ../../library/os.rst:2695 msgid "" "Extract the device major number from a raw device number (usually the :attr:" -"`st_dev` or :attr:`st_rdev` field from :c:struct:`stat`)." +"`~stat_result.st_dev` or :attr:`~stat_result.st_rdev` field from :c:struct:" +"`stat`)." msgstr "" -#: ../../library/os.rst:2655 +#: ../../library/os.rst:2701 msgid "" "Extract the device minor number from a raw device number (usually the :attr:" -"`st_dev` or :attr:`st_rdev` field from :c:struct:`stat`)." +"`~stat_result.st_dev` or :attr:`~stat_result.st_rdev` field from :c:struct:" +"`stat`)." msgstr "" -#: ../../library/os.rst:2661 +#: ../../library/os.rst:2707 msgid "Compose a raw device number from the major and minor device numbers." msgstr "" -#: ../../library/os.rst:2666 +#: ../../library/os.rst:2712 +msgid "Non-existent device." +msgstr "" + +#: ../../library/os.rst:2719 msgid "" "Return system configuration information relevant to a named file. *name* " "specifies the configuration value to retrieve; it may be a string which is " @@ -2969,20 +3030,20 @@ msgid "" "included in that mapping, passing an integer for *name* is also accepted." msgstr "" -#: ../../library/os.rst:2679 ../../library/os.rst:3420 -#: ../../library/os.rst:3734 +#: ../../library/os.rst:2732 ../../library/os.rst:3830 +#: ../../library/os.rst:4144 msgid "" "This function can support :ref:`specifying a file descriptor `." msgstr "" -#: ../../library/os.rst:2690 +#: ../../library/os.rst:2743 msgid "" "Dictionary mapping names accepted by :func:`pathconf` and :func:`fpathconf` " "to the integer values defined for those names by the host operating system. " "This can be used to determine the set of names known to the system." msgstr "" -#: ../../library/os.rst:2699 +#: ../../library/os.rst:2752 msgid "" "Return a string representing the path to which the symbolic link points. " "The result may be either an absolute or relative pathname; if it is " @@ -2990,7 +3051,7 @@ msgid "" "join(os.path.dirname(path), result)``." msgstr "" -#: ../../library/os.rst:2704 +#: ../../library/os.rst:2757 msgid "" "If the *path* is a string object (directly or indirectly through a :class:" "`PathLike` interface), the result will also be a string object, and the call " @@ -2998,42 +3059,42 @@ msgid "" "indirectly), the result will be a bytes object." msgstr "" -#: ../../library/os.rst:2712 +#: ../../library/os.rst:2765 msgid "" "When trying to resolve a path that may contain links, use :func:`~os.path." "realpath` to properly handle recursion and platform differences." msgstr "" -#: ../../library/os.rst:2724 +#: ../../library/os.rst:2777 msgid "Accepts a :term:`path-like object` on Unix." msgstr "" -#: ../../library/os.rst:2727 +#: ../../library/os.rst:2780 msgid "Accepts a :term:`path-like object` and a bytes object on Windows." msgstr "" -#: ../../library/os.rst:2730 +#: ../../library/os.rst:2783 msgid "" "Added support for directory junctions, and changed to return the " "substitution path (which typically includes ``\\\\?\\`` prefix) rather than " "the optional \"print name\" field that was previously returned." msgstr "" -#: ../../library/os.rst:2736 +#: ../../library/os.rst:2789 msgid "" "Remove (delete) the file *path*. If *path* is a directory, an :exc:" "`OSError` is raised. Use :func:`rmdir` to remove directories. If the file " "does not exist, a :exc:`FileNotFoundError` is raised." msgstr "" -#: ../../library/os.rst:2740 ../../library/os.rst:2853 -#: ../../library/os.rst:3685 +#: ../../library/os.rst:2793 ../../library/os.rst:2906 +#: ../../library/os.rst:4095 msgid "" "This function can support :ref:`paths relative to directory descriptors " "`." msgstr "" -#: ../../library/os.rst:2743 +#: ../../library/os.rst:2796 msgid "" "On Windows, attempting to remove a file that is in use causes an exception " "to be raised; on Unix, the directory entry is removed but the storage " @@ -3041,12 +3102,12 @@ msgid "" "longer in use." msgstr "" -#: ../../library/os.rst:2747 +#: ../../library/os.rst:2800 msgid "This function is semantically identical to :func:`unlink`." msgstr "" -#: ../../library/os.rst:2749 ../../library/os.rst:2771 -#: ../../library/os.rst:3756 +#: ../../library/os.rst:2802 ../../library/os.rst:2824 +#: ../../library/os.rst:4166 msgid "" "Raises an :ref:`auditing event ` ``os.remove`` with arguments " "``path``, ``dir_fd``." @@ -3054,7 +3115,7 @@ msgstr "" "引發一個附帶引數 ``path``、``dir_fd`` 的\\ :ref:`稽核事件 ` ``os." "remove``。" -#: ../../library/os.rst:2762 +#: ../../library/os.rst:2815 msgid "" "Remove directories recursively. Works like :func:`rmdir` except that, if " "the leaf directory is successfully removed, :func:`removedirs` tries to " @@ -3066,20 +3127,20 @@ msgid "" "could not be successfully removed." msgstr "" -#: ../../library/os.rst:2779 +#: ../../library/os.rst:2832 msgid "" "Rename the file or directory *src* to *dst*. If *dst* exists, the operation " "will fail with an :exc:`OSError` subclass in a number of cases:" msgstr "" -#: ../../library/os.rst:2782 +#: ../../library/os.rst:2835 msgid "" "On Windows, if *dst* exists a :exc:`FileExistsError` is always raised. The " "operation may fail if *src* and *dst* are on different filesystems. Use :" "func:`shutil.move` to support moves to a different filesystem." msgstr "" -#: ../../library/os.rst:2786 +#: ../../library/os.rst:2839 msgid "" "On Unix, if *src* is a file and *dst* is a directory or vice-versa, an :exc:" "`IsADirectoryError` or a :exc:`NotADirectoryError` will be raised " @@ -3091,20 +3152,20 @@ msgid "" "operation (this is a POSIX requirement)." msgstr "" -#: ../../library/os.rst:2795 ../../library/os.rst:2835 +#: ../../library/os.rst:2848 ../../library/os.rst:2888 msgid "" "This function can support specifying *src_dir_fd* and/or *dst_dir_fd* to " "supply :ref:`paths relative to directory descriptors `." msgstr "" -#: ../../library/os.rst:2798 +#: ../../library/os.rst:2851 msgid "" "If you want cross-platform overwriting of the destination, use :func:" "`replace`." msgstr "" -#: ../../library/os.rst:2800 ../../library/os.rst:2821 -#: ../../library/os.rst:2838 +#: ../../library/os.rst:2853 ../../library/os.rst:2874 +#: ../../library/os.rst:2891 msgid "" "Raises an :ref:`auditing event ` ``os.rename`` with arguments " "``src``, ``dst``, ``src_dir_fd``, ``dst_dir_fd``." @@ -3112,11 +3173,11 @@ msgstr "" "引發一個附帶引數 ``src``、``dst``、``src_dir_fd``、``dst_dir_fd`` 的\\ :ref:`" "稽核事件 ` ``os.rename``。" -#: ../../library/os.rst:2802 +#: ../../library/os.rst:2855 msgid "Added the *src_dir_fd* and *dst_dir_fd* parameters." msgstr "新增 *src_dir_fd* 與 *dst_dir_fd* 參數。" -#: ../../library/os.rst:2811 +#: ../../library/os.rst:2864 msgid "" "Recursive directory or file renaming function. Works like :func:`rename`, " "except creation of any intermediate directories needed to make the new " @@ -3125,17 +3186,17 @@ msgid "" "using :func:`removedirs`." msgstr "" -#: ../../library/os.rst:2818 +#: ../../library/os.rst:2871 msgid "" "This function can fail with the new directory structure made if you lack " "permissions needed to remove the leaf directory or file." msgstr "" -#: ../../library/os.rst:2823 +#: ../../library/os.rst:2876 msgid "Accepts a :term:`path-like object` for *old* and *new*." msgstr "" -#: ../../library/os.rst:2829 +#: ../../library/os.rst:2882 msgid "" "Rename the file or directory *src* to *dst*. If *dst* is a non-empty " "directory, :exc:`OSError` will be raised. If *dst* exists and is a file, it " @@ -3144,7 +3205,7 @@ msgid "" "renaming will be an atomic operation (this is a POSIX requirement)." msgstr "" -#: ../../library/os.rst:2848 +#: ../../library/os.rst:2901 msgid "" "Remove (delete) the directory *path*. If the directory does not exist or is " "not empty, a :exc:`FileNotFoundError` or an :exc:`OSError` is raised " @@ -3152,7 +3213,7 @@ msgid "" "rmtree` can be used." msgstr "" -#: ../../library/os.rst:2856 +#: ../../library/os.rst:2909 msgid "" "Raises an :ref:`auditing event ` ``os.rmdir`` with arguments " "``path``, ``dir_fd``." @@ -3160,7 +3221,7 @@ msgstr "" "引發一個附帶引數 ``path``、``dir_fd`` 的\\ :ref:`稽核事件 ` ``os." "rmdir``。" -#: ../../library/os.rst:2867 +#: ../../library/os.rst:2920 msgid "" "Return an iterator of :class:`os.DirEntry` objects corresponding to the " "entries in the directory given by *path*. The entries are yielded in " @@ -3170,7 +3231,7 @@ msgid "" "unspecified." msgstr "" -#: ../../library/os.rst:2874 +#: ../../library/os.rst:2927 msgid "" "Using :func:`scandir` instead of :func:`listdir` can significantly increase " "the performance of code that also needs file type or file attribute " @@ -3182,7 +3243,7 @@ msgid "" "Unix but only requires one for symbolic links on Windows." msgstr "" -#: ../../library/os.rst:2884 +#: ../../library/os.rst:2937 msgid "" "*path* may be a :term:`path-like object`. If *path* is of type ``bytes`` " "(directly or indirectly through the :class:`PathLike` interface), the type " @@ -3191,14 +3252,14 @@ msgid "" "they will be of type ``str``." msgstr "" -#: ../../library/os.rst:2893 +#: ../../library/os.rst:2946 msgid "" "Raises an :ref:`auditing event ` ``os.scandir`` with argument " "``path``." msgstr "" "引發一個附帶引數 ``path`` 的\\ :ref:`稽核事件 ` ``os.scandir``。" -#: ../../library/os.rst:2895 +#: ../../library/os.rst:2948 msgid "" "Sharing a :func:`scandir` iterator between threads will not corrupt the " "iterator, but it is subject to :term:`race conditions `: " @@ -3206,25 +3267,25 @@ msgid "" "while another thread is iterating ends that iteration early." msgstr "" -#: ../../library/os.rst:2900 +#: ../../library/os.rst:2953 msgid "" "The :func:`scandir` iterator supports the :term:`context manager` protocol " "and has the following method:" msgstr "" ":func:`scandir` 疊代器支援 :term:`context manager` 協定,並具有以下方法:" -#: ../../library/os.rst:2905 +#: ../../library/os.rst:2958 msgid "Close the iterator and free acquired resources." msgstr "" -#: ../../library/os.rst:2907 +#: ../../library/os.rst:2960 msgid "" "This is called automatically when the iterator is :term:`exhausted` or " "garbage collected, or when an error happens during iterating. However it is " "advisable to call it explicitly or use the :keyword:`with` statement." msgstr "" -#: ../../library/os.rst:2914 +#: ../../library/os.rst:2967 msgid "" "The following example shows a simple use of :func:`scandir` to display all " "the files (excluding directories) in the given *path* that don't start with " @@ -3232,7 +3293,7 @@ msgid "" "system call::" msgstr "" -#: ../../library/os.rst:2919 +#: ../../library/os.rst:2972 msgid "" "with os.scandir(path) as it:\n" " for entry in it:\n" @@ -3244,7 +3305,7 @@ msgstr "" " if not entry.name.startswith('.') and entry.is_file():\n" " print(entry.name)" -#: ../../library/os.rst:2926 +#: ../../library/os.rst:2979 msgid "" "On Unix-based systems, :func:`scandir` uses the system's `opendir() `_ and " @@ -3255,7 +3316,7 @@ msgid "" "desktop/aa364428(v=vs.85).aspx>`_ functions." msgstr "" -#: ../../library/os.rst:2938 +#: ../../library/os.rst:2991 msgid "" "Added support for the :term:`context manager` protocol and the :func:" "`~scandir.close` method. If a :func:`scandir` iterator is neither exhausted " @@ -3263,28 +3324,34 @@ msgid "" "destructor." msgstr "" -#: ../../library/os.rst:2944 +#: ../../library/os.rst:2997 msgid "The function accepts a :term:`path-like object`." msgstr "" -#: ../../library/os.rst:2946 +#: ../../library/os.rst:2999 msgid "Added support for :ref:`file descriptors ` on Unix." msgstr "新增對 Unix 上的\\ :ref:`檔案描述器 `\\ 的支援。" -#: ../../library/os.rst:2952 +#: ../../library/os.rst:3002 +msgid "" +"``os.scandir(-1)`` now fails with ``OSError(errno.EBADF)`` rather than " +"listing the current directory." +msgstr "" + +#: ../../library/os.rst:3009 msgid "" "Object yielded by :func:`scandir` to expose the file path and other file " "attributes of a directory entry." msgstr "" -#: ../../library/os.rst:2955 +#: ../../library/os.rst:3012 msgid "" ":func:`scandir` will provide as much of this information as possible without " "making additional system calls. When a ``stat()`` or ``lstat()`` system call " "is made, the ``os.DirEntry`` object will cache the result." msgstr "" -#: ../../library/os.rst:2959 +#: ../../library/os.rst:3016 msgid "" "``os.DirEntry`` instances are not intended to be stored in long-lived data " "structures; if you know the file metadata has changed or if a long time has " @@ -3292,7 +3359,7 @@ msgid "" "up-to-date information." msgstr "" -#: ../../library/os.rst:2964 +#: ../../library/os.rst:3021 msgid "" "Because the ``os.DirEntry`` methods can make operating system calls, they " "may also raise :exc:`OSError`. If you need very fine-grained control over " @@ -3300,35 +3367,35 @@ msgid "" "methods and handle as appropriate." msgstr "" -#: ../../library/os.rst:2969 +#: ../../library/os.rst:3026 msgid "" "To be directly usable as a :term:`path-like object`, ``os.DirEntry`` " "implements the :class:`PathLike` interface." msgstr "" -#: ../../library/os.rst:2972 +#: ../../library/os.rst:3029 msgid "" ":class:`!DirEntry` objects are :ref:`generic ` over the type of " "the path (:class:`str` or :class:`bytes`)." msgstr "" -#: ../../library/os.rst:2975 +#: ../../library/os.rst:3032 msgid "Attributes and methods on a ``os.DirEntry`` instance are as follows:" msgstr "" -#: ../../library/os.rst:2979 +#: ../../library/os.rst:3036 msgid "" "The entry's base filename, relative to the :func:`scandir` *path* argument." msgstr "" -#: ../../library/os.rst:2982 +#: ../../library/os.rst:3039 msgid "" "The :attr:`name` attribute will be ``bytes`` if the :func:`scandir` *path* " "argument is of type ``bytes`` and ``str`` otherwise. Use :func:`~os." "fsdecode` to decode byte filenames." msgstr "" -#: ../../library/os.rst:2988 +#: ../../library/os.rst:3045 msgid "" "The entry's path name: equivalent to ``os.path.join(scandir_path, entry." "name)`` where *scandir_path* is the original :func:`scandir` *path* " @@ -3343,51 +3410,51 @@ msgid "" "`path` attribute is the same as the :attr:`name` attribute." msgstr "" -#: ../../library/os.rst:3001 +#: ../../library/os.rst:3058 msgid "" "The :attr:`path` attribute will be ``bytes`` if the :func:`scandir` *path* " "argument is of type ``bytes`` and ``str`` otherwise. Use :func:`~os." "fsdecode` to decode byte filenames." msgstr "" -#: ../../library/os.rst:3007 +#: ../../library/os.rst:3064 msgid "Return the inode number of the entry." msgstr "" -#: ../../library/os.rst:3009 +#: ../../library/os.rst:3066 msgid "" "The result is cached on the ``os.DirEntry`` object. Use ``os.stat(entry." "path, follow_symlinks=False).st_ino`` to fetch up-to-date information." msgstr "" -#: ../../library/os.rst:3013 +#: ../../library/os.rst:3070 msgid "" "On the first, uncached call, a system call is required on Windows but not on " "Unix." msgstr "" -#: ../../library/os.rst:3018 +#: ../../library/os.rst:3075 msgid "" "Return ``True`` if this entry is a directory or a symbolic link pointing to " "a directory; return ``False`` if the entry is or points to any other kind of " "file, or if it doesn't exist anymore." msgstr "" -#: ../../library/os.rst:3022 +#: ../../library/os.rst:3079 msgid "" "If *follow_symlinks* is ``False``, return ``True`` only if this entry is a " "directory (without following symlinks); return ``False`` if the entry is any " "other kind of file or if it doesn't exist anymore." msgstr "" -#: ../../library/os.rst:3026 +#: ../../library/os.rst:3083 msgid "" "The result is cached on the ``os.DirEntry`` object, with a separate cache " "for *follow_symlinks* ``True`` and ``False``. Call :func:`os.stat` along " "with :func:`stat.S_ISDIR` to fetch up-to-date information." msgstr "" -#: ../../library/os.rst:3030 +#: ../../library/os.rst:3087 msgid "" "On the first, uncached call, no system call is required in most cases. " "Specifically, for non-symlinks, neither Windows or Unix require a system " @@ -3397,46 +3464,46 @@ msgid "" "is ``False``." msgstr "" -#: ../../library/os.rst:3037 ../../library/os.rst:3067 +#: ../../library/os.rst:3094 ../../library/os.rst:3124 msgid "" "This method can raise :exc:`OSError`, such as :exc:`PermissionError`, but :" "exc:`FileNotFoundError` is caught and not raised." msgstr "" -#: ../../library/os.rst:3042 +#: ../../library/os.rst:3099 msgid "" "Return ``True`` if this entry is a file or a symbolic link pointing to a " "file; return ``False`` if the entry is or points to a directory or other non-" "file entry, or if it doesn't exist anymore." msgstr "" -#: ../../library/os.rst:3046 +#: ../../library/os.rst:3103 msgid "" "If *follow_symlinks* is ``False``, return ``True`` only if this entry is a " "file (without following symlinks); return ``False`` if the entry is a " "directory or other non-file entry, or if it doesn't exist anymore." msgstr "" -#: ../../library/os.rst:3050 +#: ../../library/os.rst:3107 msgid "" "The result is cached on the ``os.DirEntry`` object. Caching, system calls " "made, and exceptions raised are as per :func:`~os.DirEntry.is_dir`." msgstr "" -#: ../../library/os.rst:3055 +#: ../../library/os.rst:3112 msgid "" "Return ``True`` if this entry is a symbolic link (even if broken); return " "``False`` if the entry points to a directory or any kind of file, or if it " "doesn't exist anymore." msgstr "" -#: ../../library/os.rst:3059 +#: ../../library/os.rst:3116 msgid "" "The result is cached on the ``os.DirEntry`` object. Call :func:`os.path." "islink` to fetch up-to-date information." msgstr "" -#: ../../library/os.rst:3062 +#: ../../library/os.rst:3119 msgid "" "On the first, uncached call, no system call is required in most cases. " "Specifically, neither Windows or Unix require a system call, except on " @@ -3444,48 +3511,48 @@ msgid "" "``dirent.d_type == DT_UNKNOWN``." msgstr "" -#: ../../library/os.rst:3072 +#: ../../library/os.rst:3129 msgid "" "Return ``True`` if this entry is a junction (even if broken); return " "``False`` if the entry points to a regular directory, any kind of file, a " "symlink, or if it doesn't exist anymore." msgstr "" -#: ../../library/os.rst:3076 +#: ../../library/os.rst:3133 msgid "" "The result is cached on the ``os.DirEntry`` object. Call :func:`os.path." "isjunction` to fetch up-to-date information." msgstr "" -#: ../../library/os.rst:3083 +#: ../../library/os.rst:3140 msgid "" "Return a :class:`stat_result` object for this entry. This method follows " "symbolic links by default; to stat a symbolic link add the " "``follow_symlinks=False`` argument." msgstr "" -#: ../../library/os.rst:3087 +#: ../../library/os.rst:3144 msgid "" "On Unix, this method always requires a system call. On Windows, it only " "requires a system call if *follow_symlinks* is ``True`` and the entry is a " "reparse point (for example, a symbolic link or directory junction)." msgstr "" -#: ../../library/os.rst:3092 +#: ../../library/os.rst:3149 msgid "" "On Windows, the ``st_ino``, ``st_dev`` and ``st_nlink`` attributes of the :" "class:`stat_result` are always set to zero. Call :func:`os.stat` to get " "these attributes." msgstr "" -#: ../../library/os.rst:3096 +#: ../../library/os.rst:3153 msgid "" "The result is cached on the ``os.DirEntry`` object, with a separate cache " "for *follow_symlinks* ``True`` and ``False``. Call :func:`os.stat` to fetch " "up-to-date information." msgstr "" -#: ../../library/os.rst:3100 +#: ../../library/os.rst:3157 msgid "" "Note that there is a nice correspondence between several attributes and " "methods of ``os.DirEntry`` and of :class:`pathlib.Path`. In particular, the " @@ -3493,13 +3560,13 @@ msgid "" "``is_file()``, ``is_symlink()``, ``is_junction()``, and ``stat()`` methods." msgstr "" -#: ../../library/os.rst:3108 +#: ../../library/os.rst:3165 msgid "" "Added support for the :class:`~os.PathLike` interface. Added support for :" "class:`bytes` paths on Windows." msgstr "" -#: ../../library/os.rst:3112 +#: ../../library/os.rst:3169 msgid "" "The ``st_ctime`` attribute of a stat result is deprecated on Windows. The " "file creation time is properly available as ``st_birthtime``, and in the " @@ -3507,7 +3574,7 @@ msgid "" "time, if available." msgstr "" -#: ../../library/os.rst:3121 +#: ../../library/os.rst:3178 msgid "" "Get the status of a file or a file descriptor. Perform the equivalent of a :" "c:func:`stat` system call on the given path. *path* may be specified as " @@ -3516,21 +3583,21 @@ msgid "" "`stat_result` object." msgstr "" -#: ../../library/os.rst:3127 +#: ../../library/os.rst:3184 msgid "" "This function normally follows symlinks; to stat a symlink add the argument " "``follow_symlinks=False``, or use :func:`lstat`." msgstr "" -#: ../../library/os.rst:3130 ../../library/os.rst:4338 -#: ../../library/os.rst:4354 ../../library/os.rst:4370 -#: ../../library/os.rst:4390 +#: ../../library/os.rst:3187 ../../library/os.rst:4752 +#: ../../library/os.rst:4768 ../../library/os.rst:4788 +#: ../../library/os.rst:4808 msgid "" "This function can support :ref:`specifying a file descriptor ` and :" "ref:`not following symlinks `." msgstr "" -#: ../../library/os.rst:3133 +#: ../../library/os.rst:3190 msgid "" "On Windows, passing ``follow_symlinks=False`` will disable following all " "name-surrogate reparse points, which includes symlinks and directory " @@ -3544,11 +3611,11 @@ msgid "" "junction points, which will raise the usual exceptions." msgstr "" -#: ../../library/os.rst:3146 ../../library/os.rst:4045 +#: ../../library/os.rst:3203 ../../library/os.rst:4459 msgid "Example::" msgstr "範例: ::" -#: ../../library/os.rst:3148 +#: ../../library/os.rst:3205 msgid "" ">>> import os\n" ">>> statinfo = os.stat('somefile.txt')\n" @@ -3568,17 +3635,17 @@ msgstr "" ">>> statinfo.st_size\n" "264" -#: ../../library/os.rst:3159 +#: ../../library/os.rst:3216 msgid ":func:`fstat` and :func:`lstat` functions." msgstr ":func:`fstat` 和 :func:`lstat` 函式。" -#: ../../library/os.rst:3161 +#: ../../library/os.rst:3218 msgid "" "Added the *dir_fd* and *follow_symlinks* parameters, specifying a file " "descriptor instead of a path." msgstr "新增 *dir_fd* 與 *follow_symlinks* 參數,指定一個檔案描述器而非路徑。" -#: ../../library/os.rst:3168 +#: ../../library/os.rst:3225 msgid "" "On Windows, all reparse points that can be resolved by the operating system " "are now followed, and passing ``follow_symlinks=False`` disables following " @@ -3588,122 +3655,122 @@ msgid "" "of raising an error." msgstr "" -#: ../../library/os.rst:3179 +#: ../../library/os.rst:3236 msgid "" "Object whose attributes correspond roughly to the members of the :c:struct:" "`stat` structure. It is used for the result of :func:`os.stat`, :func:`os." "fstat` and :func:`os.lstat`." msgstr "" -#: ../../library/os.rst:3183 +#: ../../library/os.rst:3240 msgid "Attributes:" msgstr "屬性:" -#: ../../library/os.rst:3187 +#: ../../library/os.rst:3244 ../../library/os.rst:3679 msgid "File mode: file type and file mode bits (permissions)." msgstr "" -#: ../../library/os.rst:3191 +#: ../../library/os.rst:3248 msgid "" "Platform dependent, but if non-zero, uniquely identifies the file for a " "given value of ``st_dev``. Typically:" msgstr "" -#: ../../library/os.rst:3194 +#: ../../library/os.rst:3251 msgid "the inode number on Unix," msgstr "" -#: ../../library/os.rst:3195 +#: ../../library/os.rst:3252 msgid "" "the `file index `_ on " "Windows" msgstr "" -#: ../../library/os.rst:3201 +#: ../../library/os.rst:3258 ../../library/os.rst:3608 msgid "Identifier of the device on which this file resides." msgstr "" -#: ../../library/os.rst:3205 +#: ../../library/os.rst:3262 ../../library/os.rst:3701 msgid "Number of hard links." msgstr "" -#: ../../library/os.rst:3209 +#: ../../library/os.rst:3266 ../../library/os.rst:3739 msgid "User identifier of the file owner." msgstr "" -#: ../../library/os.rst:3213 +#: ../../library/os.rst:3270 ../../library/os.rst:3650 msgid "Group identifier of the file owner." msgstr "" -#: ../../library/os.rst:3217 +#: ../../library/os.rst:3274 ../../library/os.rst:3720 msgid "" "Size of the file in bytes, if it is a regular file or a symbolic link. The " "size of a symbolic link is the length of the pathname it contains, without a " "terminating null byte." msgstr "" -#: ../../library/os.rst:3221 +#: ../../library/os.rst:3278 msgid "Timestamps:" msgstr "" -#: ../../library/os.rst:3225 +#: ../../library/os.rst:3282 ../../library/os.rst:3502 msgid "Time of most recent access expressed in seconds." msgstr "" -#: ../../library/os.rst:3229 +#: ../../library/os.rst:3286 ../../library/os.rst:3686 msgid "Time of most recent content modification expressed in seconds." msgstr "" -#: ../../library/os.rst:3233 +#: ../../library/os.rst:3290 ../../library/os.rst:3593 msgid "Time of most recent metadata change expressed in seconds." msgstr "" -#: ../../library/os.rst:3235 +#: ../../library/os.rst:3292 msgid "" "``st_ctime`` is deprecated on Windows. Use ``st_birthtime`` for the file " "creation time. In the future, ``st_ctime`` will contain the time of the most " "recent metadata change, as for other platforms." msgstr "" -#: ../../library/os.rst:3242 +#: ../../library/os.rst:3299 ../../library/os.rst:3509 msgid "Time of most recent access expressed in nanoseconds as an integer." msgstr "" -#: ../../library/os.rst:3248 +#: ../../library/os.rst:3305 ../../library/os.rst:3693 msgid "" "Time of most recent content modification expressed in nanoseconds as an " "integer." msgstr "" -#: ../../library/os.rst:3255 +#: ../../library/os.rst:3312 ../../library/os.rst:3600 msgid "" "Time of most recent metadata change expressed in nanoseconds as an integer." msgstr "" -#: ../../library/os.rst:3260 +#: ../../library/os.rst:3317 msgid "" "``st_ctime_ns`` is deprecated on Windows. Use ``st_birthtime_ns`` for the " "file creation time. In the future, ``st_ctime`` will contain the time of the " "most recent metadata change, as for other platforms." msgstr "" -#: ../../library/os.rst:3267 +#: ../../library/os.rst:3324 msgid "" "Time of file creation expressed in seconds. This attribute is not always " "available, and may raise :exc:`AttributeError`." msgstr "" -#: ../../library/os.rst:3270 +#: ../../library/os.rst:3327 msgid "``st_birthtime`` is now available on Windows." msgstr "``st_birthtime`` 現在在 Windows 上可用。" -#: ../../library/os.rst:3275 +#: ../../library/os.rst:3332 msgid "" "Time of file creation expressed in nanoseconds as an integer. This attribute " "is not always available, and may raise :exc:`AttributeError`." msgstr "" -#: ../../library/os.rst:3283 +#: ../../library/os.rst:3340 msgid "" "The exact meaning and resolution of the :attr:`st_atime`, :attr:`st_mtime`, :" "attr:`st_ctime` and :attr:`st_birthtime` attributes depend on the operating " @@ -3713,7 +3780,7 @@ msgid "" "details." msgstr "" -#: ../../library/os.rst:3290 +#: ../../library/os.rst:3347 msgid "" "Similarly, although :attr:`st_atime_ns`, :attr:`st_mtime_ns`, :attr:" "`st_ctime_ns` and :attr:`st_birthtime_ns` are always expressed in " @@ -3726,74 +3793,74 @@ msgid "" "`st_birthtime_ns`." msgstr "" -#: ../../library/os.rst:3300 +#: ../../library/os.rst:3357 msgid "" "On some Unix systems (such as Linux), the following attributes may also be " "available:" msgstr "" -#: ../../library/os.rst:3305 +#: ../../library/os.rst:3362 msgid "" "Number of 512-byte blocks allocated for file. This may be smaller than :attr:" "`st_size`/512 when the file has holes." msgstr "" -#: ../../library/os.rst:3310 +#: ../../library/os.rst:3367 ../../library/os.rst:3566 msgid "" "\"Preferred\" blocksize for efficient file system I/O. Writing to a file in " "smaller chunks may cause an inefficient read-modify-rewrite." msgstr "" -#: ../../library/os.rst:3315 +#: ../../library/os.rst:3372 ../../library/os.rst:3708 msgid "Type of device if an inode device." msgstr "" -#: ../../library/os.rst:3319 +#: ../../library/os.rst:3376 msgid "User defined flags for file." msgstr "" -#: ../../library/os.rst:3321 +#: ../../library/os.rst:3378 msgid "" "On other Unix systems (such as FreeBSD), the following attributes may be " "available (but may be only filled out if root tries to use them):" msgstr "" -#: ../../library/os.rst:3326 +#: ../../library/os.rst:3383 msgid "File generation number." msgstr "" -#: ../../library/os.rst:3328 +#: ../../library/os.rst:3385 msgid "" "On Solaris and derivatives, the following attributes may also be available:" msgstr "" -#: ../../library/os.rst:3333 +#: ../../library/os.rst:3390 msgid "" "String that uniquely identifies the type of the filesystem that contains the " "file." msgstr "" -#: ../../library/os.rst:3336 +#: ../../library/os.rst:3393 msgid "On macOS systems, the following attributes may also be available:" msgstr "" -#: ../../library/os.rst:3340 +#: ../../library/os.rst:3397 msgid "Real size of the file." msgstr "" -#: ../../library/os.rst:3344 +#: ../../library/os.rst:3401 msgid "Creator of the file." msgstr "" -#: ../../library/os.rst:3348 +#: ../../library/os.rst:3405 msgid "File type." msgstr "" -#: ../../library/os.rst:3350 +#: ../../library/os.rst:3407 msgid "On Windows systems, the following attributes are also available:" msgstr "" -#: ../../library/os.rst:3354 +#: ../../library/os.rst:3411 msgid "" "Windows file attributes: ``dwFileAttributes`` member of the " "``BY_HANDLE_FILE_INFORMATION`` structure returned by :c:func:`!" @@ -3801,7 +3868,7 @@ msgid "" "FILE_ATTRIBUTE_ARCHIVE>` constants in the :mod:`stat` module." msgstr "" -#: ../../library/os.rst:3364 +#: ../../library/os.rst:3421 msgid "" "When :attr:`st_file_attributes` has the :const:`~stat." "FILE_ATTRIBUTE_REPARSE_POINT` set, this field contains the tag identifying " @@ -3809,14 +3876,14 @@ msgid "" "IO_REPARSE_TAG_SYMLINK>` constants in the :mod:`stat` module." msgstr "" -#: ../../library/os.rst:3369 +#: ../../library/os.rst:3426 msgid "" "The standard module :mod:`stat` defines functions and constants that are " "useful for extracting information from a :c:struct:`stat` structure. (On " "Windows, some items are filled with dummy values.)" msgstr "" -#: ../../library/os.rst:3373 +#: ../../library/os.rst:3430 msgid "" "For backward compatibility, a :class:`stat_result` instance is also " "accessible as a tuple of at least 10 integers giving the most important (and " @@ -3828,97 +3895,355 @@ msgid "" "class:`stat_result` as a tuple always returns integers." msgstr "" -#: ../../library/os.rst:3382 +#: ../../library/os.rst:3439 msgid "Windows now returns the file index as :attr:`st_ino` when available." msgstr "" -#: ../../library/os.rst:3386 +#: ../../library/os.rst:3443 msgid "Added the :attr:`st_fstype` member to Solaris/derivatives." msgstr "" -#: ../../library/os.rst:3389 +#: ../../library/os.rst:3446 msgid "Added the :attr:`st_reparse_tag` member on Windows." msgstr "在 Windows 上新增 :attr:`st_reparse_tag` 成員。" -#: ../../library/os.rst:3392 +#: ../../library/os.rst:3449 msgid "" "On Windows, the :attr:`st_mode` member now identifies special files as :" -"const:`S_IFCHR`, :const:`S_IFIFO` or :const:`S_IFBLK` as appropriate." +"const:`~stat.S_IFCHR`, :const:`~stat.S_IFIFO` or :const:`~stat.S_IFBLK` as " +"appropriate." msgstr "" -#: ../../library/os.rst:3397 +#: ../../library/os.rst:3454 msgid "" "On Windows, :attr:`st_ctime` is deprecated. Eventually, it will contain the " "last metadata change time, for consistency with other platforms, but for now " "still contains creation time. Use :attr:`st_birthtime` for the creation time." msgstr "" -#: ../../library/os.rst:3403 +#: ../../library/os.rst:3460 msgid "" "On Windows, :attr:`st_ino` may now be up to 128 bits, depending on the file " "system. Previously it would not be above 64 bits, and larger file " "identifiers would be arbitrarily packed." msgstr "" -#: ../../library/os.rst:3407 +#: ../../library/os.rst:3464 msgid "" "On Windows, :attr:`st_rdev` no longer returns a value. Previously it would " "contain the same as :attr:`st_dev`, which was incorrect." msgstr "" -#: ../../library/os.rst:3410 +#: ../../library/os.rst:3467 msgid "Added the :attr:`st_birthtime` member on Windows." msgstr "在 Windows 上新增 :attr:`st_birthtime` 成員。" -#: ../../library/os.rst:3415 +#: ../../library/os.rst:3472 msgid "" -"Perform a :manpage:`statvfs(3)` system call on the given path. The return " -"value is a :class:`statvfs_result` whose attributes describe the filesystem " -"on the given path and correspond to the members of the :c:struct:`statvfs` " +"Get the status of a file or file descriptor by performing a :c:func:`!statx` " +"system call on the given path." +msgstr "" + +#: ../../library/os.rst:3475 +msgid "" +"*path* is a :term:`path-like object` or an open file descriptor. *mask* is a " +"combination of the module-level :const:`STATX_* ` constants " +"specifying the information to retrieve. *flags* is a combination of the " +"module-level :const:`AT_STATX_* ` constants and/or :" +"const:`AT_NO_AUTOMOUNT`. Returns a :class:`statx_result` object whose :attr:" +"`~os.statx_result.stx_mask` attribute specifies the information actually " +"retrieved (which may differ from *mask*)." +msgstr "" + +#: ../../library/os.rst:3483 +msgid "" +"This function supports :ref:`specifying a file descriptor `, :ref:" +"`paths relative to directory descriptors `, and :ref:`not following " +"symlinks `." +msgstr "" + +#: ../../library/os.rst:3487 ../../library/os.rst:3744 +msgid "The :manpage:`statx(2)` man page." +msgstr ":manpage:`statx(2)` 使用手冊。" + +#: ../../library/os.rst:3496 +msgid "Information about a file returned by :func:`os.statx`." +msgstr "" + +#: ../../library/os.rst:3498 +msgid ":class:`!statx_result` has the following attributes:" +msgstr "" + +#: ../../library/os.rst:3504 ../../library/os.rst:3511 +msgid "" +"Equal to ``None`` if :data:`STATX_ATIME` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3516 +msgid "Maximum iovecs for direct I/O with torn-write protection." +msgstr "" + +#: ../../library/os.rst:3518 ../../library/os.rst:3528 +#: ../../library/os.rst:3538 ../../library/os.rst:3548 +msgid "" +"Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3526 +msgid "Maximum size for direct I/O with torn-write protection." +msgstr "" + +#: ../../library/os.rst:3536 +msgid "Maximum optimized size for direct I/O with torn-write protection." +msgstr "" + +#: ../../library/os.rst:3546 +msgid "Minimum size for direct I/O with torn-write protection." +msgstr "" + +#: ../../library/os.rst:3556 +msgid "" +"Bitmask of :const:`STATX_ATTR_* ` constants " +"specifying the attributes of this file." +msgstr "" + +#: ../../library/os.rst:3561 +msgid "" +"A mask indicating which bits in :attr:`stx_attributes` are supported by the " +"VFS and the filesystem." +msgstr "" + +#: ../../library/os.rst:3571 +msgid "" +"Number of 512-byte blocks allocated for file. This may be smaller than :attr:" +"`stx_size`/512 when the file has holes." +msgstr "" + +#: ../../library/os.rst:3574 +msgid "" +"Equal to ``None`` if :data:`STATX_BLOCKS` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3579 +msgid "Time of file creation expressed in seconds." +msgstr "" + +#: ../../library/os.rst:3581 ../../library/os.rst:3588 +msgid "" +"Equal to ``None`` if :data:`STATX_BTIME` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3586 +msgid "Time of file creation expressed in nanoseconds as an integer." +msgstr "" + +#: ../../library/os.rst:3595 ../../library/os.rst:3603 +msgid "" +"Equal to ``None`` if :data:`STATX_CTIME` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3612 +msgid "Major number of the device on which this file resides." +msgstr "" + +#: ../../library/os.rst:3616 +msgid "Minor number of the device on which this file resides." +msgstr "" + +#: ../../library/os.rst:3620 +msgid "Direct I/O memory buffer alignment requirement." +msgstr "" + +#: ../../library/os.rst:3622 ../../library/os.rst:3632 +msgid "" +"Equal to ``None`` if :data:`STATX_DIOALIGN` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3630 +msgid "Direct I/O file offset alignment requirement." +msgstr "" + +#: ../../library/os.rst:3640 +msgid "Direct I/O file offset alignment requirement for reads." +msgstr "" + +#: ../../library/os.rst:3642 +msgid "" +"Equal to ``None`` if :data:`STATX_DIO_READ_ALIGN` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3652 +msgid "" +"Equal to ``None`` if :data:`STATX_GID` is missing from :attr:`~statx_result." +"stx_mask`." +msgstr "" + +#: ../../library/os.rst:3657 +msgid "Inode number." +msgstr "" + +#: ../../library/os.rst:3659 +msgid "" +"Equal to ``None`` if :data:`STATX_INO` is missing from :attr:`~statx_result." +"stx_mask`." +msgstr "" + +#: ../../library/os.rst:3664 +msgid "" +"Bitmask of :const:`STATX_* ` constants specifying the " +"information retrieved, which may differ from what was requested." +msgstr "" + +#: ../../library/os.rst:3669 +msgid "Mount identifier." +msgstr "" + +#: ../../library/os.rst:3671 +msgid "" +"Equal to ``None`` if :data:`STATX_MNT_ID` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3681 +msgid "" +"Equal to ``None`` if :data:`STATX_TYPE | STATX_MODE ` is missing " +"from :attr:`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3688 ../../library/os.rst:3696 +msgid "" +"Equal to ``None`` if :data:`STATX_MTIME` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3703 +msgid "" +"Equal to ``None`` if :data:`STATX_NLINK` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3712 +msgid "Major number of the device this file represents." +msgstr "" + +#: ../../library/os.rst:3716 +msgid "Minor number of the device this file represents." +msgstr "" + +#: ../../library/os.rst:3724 +msgid "" +"Equal to ``None`` if :data:`STATX_SIZE` is missing from :attr:`~statx_result." +"stx_mask`." +msgstr "" + +#: ../../library/os.rst:3729 +msgid "Subvolume identifier." +msgstr "" + +#: ../../library/os.rst:3731 +msgid "" +"Equal to ``None`` if :data:`STATX_SUBVOL` is missing from :attr:" +"`~statx_result.stx_mask`." +msgstr "" + +#: ../../library/os.rst:3741 +msgid "" +"Equal to ``None`` if :data:`STATX_UID` is missing from :attr:`~statx_result." +"stx_mask`." +msgstr "" + +#: ../../library/os.rst:3771 +msgid "" +"Bitflags for use in the *mask* parameter to :func:`os.statx`. Some of these " +"flags may be available even when their corresponding members in :class:" +"`statx_result` are not available." +msgstr "" + +#: ../../library/os.rst:3781 +msgid "" +"A flag for the :func:`os.statx` function. Requests that the kernel return " +"up-to-date information even when doing so is expensive (for example, " +"requiring a round trip to the server for a file on a network filesystem)." +msgstr "" + +#: ../../library/os.rst:3791 +msgid "" +"A flag for the :func:`os.statx` function. Requests that the kernel return " +"cached information if possible." +msgstr "" + +#: ../../library/os.rst:3800 +msgid "" +"A flag for the :func:`os.statx` function. This flag is defined as ``0``, so " +"it has no effect, but it can be used to explicitly indicate neither :data:" +"`AT_STATX_FORCE_SYNC` nor :data:`AT_STATX_DONT_SYNC` is being passed. In the " +"absence of the other two flags, the kernel will generally return information " +"as fresh as :func:`os.stat` would return." +msgstr "" + +#: ../../library/os.rst:3813 +msgid "" +"If the final component of a path is an automount point, operate on the " +"automount point instead of performing the automount. On Linux, :func:`os." +"stat`, :func:`os.fstat` and :func:`os.lstat` always behave this way." +msgstr "" + +#: ../../library/os.rst:3825 +msgid "" +"Perform a :manpage:`statvfs(3)` system call on the given path. The return " +"value is a :class:`statvfs_result` whose attributes describe the filesystem " +"on the given path and correspond to the members of the :c:struct:`statvfs` " "structure." msgstr "" -#: ../../library/os.rst:3433 +#: ../../library/os.rst:3843 msgid "" "Filesystem statistics returned by :func:`os.statvfs` and :func:`os." "fstatvfs`. See :manpage:`statvfs(3)` for more details." msgstr "" -#: ../../library/os.rst:3438 +#: ../../library/os.rst:3848 msgid "Block size." msgstr "" -#: ../../library/os.rst:3442 +#: ../../library/os.rst:3852 msgid "Fragment size." msgstr "" -#: ../../library/os.rst:3446 +#: ../../library/os.rst:3856 msgid "" "Number of :attr:`~statvfs_result.f_frsize` sized blocks the filesystem can " "contain." msgstr "" -#: ../../library/os.rst:3451 +#: ../../library/os.rst:3861 msgid "Number of free blocks." msgstr "" -#: ../../library/os.rst:3455 +#: ../../library/os.rst:3865 msgid "Number of free blocks for unprivileged users." msgstr "" -#: ../../library/os.rst:3459 +#: ../../library/os.rst:3869 msgid "Number of file entries, inodes, the filesystem can contain." msgstr "" -#: ../../library/os.rst:3463 +#: ../../library/os.rst:3873 msgid "Number of free files entries." msgstr "" -#: ../../library/os.rst:3467 +#: ../../library/os.rst:3877 msgid "Number of free file entries for unprivileged users." msgstr "" -#: ../../library/os.rst:3471 +#: ../../library/os.rst:3881 msgid "" "Bit-mask of mount flags. The following flags are defined: :data:" "`ST_RDONLY`, :data:`ST_NOSUID`, :data:`ST_NODEV`, :data:`ST_NOEXEC`, :data:" @@ -3927,70 +4252,70 @@ msgid "" "`ST_RELATIME`." msgstr "" -#: ../../library/os.rst:3479 +#: ../../library/os.rst:3889 msgid "" "Filesystem max filename length. OS specific limitations such as :ref:" "`Windows MAX_PATH ` and those described in Linux :manpage:" "`pathname(7)` may exist." msgstr "" -#: ../../library/os.rst:3485 +#: ../../library/os.rst:3895 msgid "Filesystem ID." msgstr "" -#: ../../library/os.rst:3490 +#: ../../library/os.rst:3900 msgid "The following flags are used in :attr:`statvfs_result.f_flag`." msgstr "" -#: ../../library/os.rst:3494 +#: ../../library/os.rst:3904 msgid "Read-only filesystem." msgstr "" -#: ../../library/os.rst:3500 +#: ../../library/os.rst:3910 msgid "Setuid/setgid bits are disabled or not supported." msgstr "" -#: ../../library/os.rst:3506 +#: ../../library/os.rst:3916 msgid "Disallow access to device special files." msgstr "" -#: ../../library/os.rst:3514 +#: ../../library/os.rst:3924 msgid "Disallow program execution." msgstr "" -#: ../../library/os.rst:3522 +#: ../../library/os.rst:3932 msgid "Writes are synced at once." msgstr "" -#: ../../library/os.rst:3530 +#: ../../library/os.rst:3940 msgid "Allow mandatory locks on an FS." msgstr "" -#: ../../library/os.rst:3538 +#: ../../library/os.rst:3948 msgid "Write on file/directory/symlink." msgstr "" -#: ../../library/os.rst:3546 +#: ../../library/os.rst:3956 msgid "Append-only file." msgstr "" -#: ../../library/os.rst:3554 +#: ../../library/os.rst:3964 msgid "Immutable file." msgstr "" -#: ../../library/os.rst:3562 +#: ../../library/os.rst:3972 msgid "Do not update access times." msgstr "" -#: ../../library/os.rst:3570 +#: ../../library/os.rst:3980 msgid "Do not update directory access times." msgstr "" -#: ../../library/os.rst:3578 +#: ../../library/os.rst:3988 msgid "Update atime relative to mtime/ctime." msgstr "" -#: ../../library/os.rst:3587 +#: ../../library/os.rst:3997 msgid "" "A :class:`set` object indicating which functions in the :mod:`!os` module " "accept an open file descriptor for their *dir_fd* parameter. Different " @@ -4002,7 +4327,7 @@ msgid "" "(Specifying ``None`` for *dir_fd* is always supported on all platforms.)" msgstr "" -#: ../../library/os.rst:3597 +#: ../../library/os.rst:4007 msgid "" "To check whether a particular function accepts an open file descriptor for " "its *dir_fd* parameter, use the ``in`` operator on ``supports_dir_fd``. As " @@ -4010,17 +4335,17 @@ msgid "" "open file descriptors for *dir_fd* on the local platform::" msgstr "" -#: ../../library/os.rst:3602 +#: ../../library/os.rst:4012 msgid "os.stat in os.supports_dir_fd" msgstr "os.stat in os.supports_dir_fd" -#: ../../library/os.rst:3604 +#: ../../library/os.rst:4014 msgid "" "Currently *dir_fd* parameters only work on Unix platforms; none of them work " "on Windows." msgstr "" -#: ../../library/os.rst:3612 +#: ../../library/os.rst:4022 msgid "" "A :class:`set` object indicating whether :func:`os.access` permits " "specifying ``True`` for its *effective_ids* parameter on the local platform. " @@ -4029,23 +4354,23 @@ msgid "" "func:`os.access`; otherwise it will be empty." msgstr "" -#: ../../library/os.rst:3618 +#: ../../library/os.rst:4028 msgid "" "This expression evaluates to ``True`` if :func:`os.access` supports " "``effective_ids=True`` on the local platform::" msgstr "" -#: ../../library/os.rst:3621 +#: ../../library/os.rst:4031 msgid "os.access in os.supports_effective_ids" msgstr "os.access in os.supports_effective_ids" -#: ../../library/os.rst:3623 +#: ../../library/os.rst:4033 msgid "" "Currently *effective_ids* is only supported on Unix platforms; it does not " "work on Windows." msgstr "" -#: ../../library/os.rst:3631 +#: ../../library/os.rst:4041 msgid "" "A :class:`set` object indicating which functions in the :mod:`!os` module " "permit specifying their *path* parameter as an open file descriptor on the " @@ -4054,7 +4379,7 @@ msgid "" "*path* arguments is not available on all platforms Python supports." msgstr "" -#: ../../library/os.rst:3638 +#: ../../library/os.rst:4048 msgid "" "To determine whether a particular function permits specifying an open file " "descriptor for its *path* parameter, use the ``in`` operator on " @@ -4063,11 +4388,11 @@ msgid "" "platform::" msgstr "" -#: ../../library/os.rst:3644 +#: ../../library/os.rst:4054 msgid "os.chdir in os.supports_fd" msgstr "os.chdir in os.supports_fd" -#: ../../library/os.rst:3651 +#: ../../library/os.rst:4061 msgid "" "A :class:`set` object indicating which functions in the :mod:`!os` module " "accept ``False`` for their *follow_symlinks* parameter on the local " @@ -4080,7 +4405,7 @@ msgid "" "on all platforms.)" msgstr "" -#: ../../library/os.rst:3661 +#: ../../library/os.rst:4071 msgid "" "To check whether a particular function accepts ``False`` for its " "*follow_symlinks* parameter, use the ``in`` operator on " @@ -4089,21 +4414,21 @@ msgid "" "stat` on the local platform::" msgstr "" -#: ../../library/os.rst:3667 +#: ../../library/os.rst:4077 msgid "os.stat in os.supports_follow_symlinks" msgstr "os.stat in os.supports_follow_symlinks" -#: ../../library/os.rst:3674 +#: ../../library/os.rst:4084 msgid "Create a symbolic link pointing to *src* named *dst*." msgstr "" -#: ../../library/os.rst:3676 +#: ../../library/os.rst:4086 msgid "" "The *src* parameter refers to the target of the link (the file or directory " "being linked to), and *dst* is the name of the link being created." msgstr "" -#: ../../library/os.rst:3679 +#: ../../library/os.rst:4089 msgid "" "On Windows, a symlink represents either a file or a directory, and does not " "morph to the target dynamically. If the target is present, the type of the " @@ -4113,7 +4438,7 @@ msgid "" "ignored." msgstr "" -#: ../../library/os.rst:3690 +#: ../../library/os.rst:4100 msgid "" "On newer versions of Windows 10, unprivileged accounts can create symlinks " "if Developer Mode is enabled. When Developer Mode is not available/enabled, " @@ -4121,12 +4446,12 @@ msgid "" "must be run as an administrator." msgstr "" -#: ../../library/os.rst:3696 +#: ../../library/os.rst:4106 msgid "" ":exc:`OSError` is raised when the function is called by an unprivileged user." msgstr "" -#: ../../library/os.rst:3699 +#: ../../library/os.rst:4109 msgid "" "Raises an :ref:`auditing event ` ``os.symlink`` with arguments " "``src``, ``dst``, ``dir_fd``." @@ -4134,27 +4459,27 @@ msgstr "" "引發一個附帶引數 ``src``、``dst``、``dir_fd`` 的\\ :ref:`稽核事件 " "` ``os.symlink``。" -#: ../../library/os.rst:3709 +#: ../../library/os.rst:4119 msgid "" "Added the *dir_fd* parameter, and now allow *target_is_directory* on non-" "Windows platforms." msgstr "" -#: ../../library/os.rst:3716 +#: ../../library/os.rst:4126 msgid "Added support for unelevated symlinks on Windows with Developer Mode." msgstr "" -#: ../../library/os.rst:3722 +#: ../../library/os.rst:4132 msgid "Force write of everything to disk." msgstr "" -#: ../../library/os.rst:3731 +#: ../../library/os.rst:4141 msgid "" "Truncate the file corresponding to *path*, so that it is at most *length* " "bytes in size." msgstr "" -#: ../../library/os.rst:3736 +#: ../../library/os.rst:4146 msgid "" "Raises an :ref:`auditing event ` ``os.truncate`` with arguments " "``path``, ``length``." @@ -4162,46 +4487,47 @@ msgstr "" "引發一個附帶引數 ``path``、``length`` 的\\ :ref:`稽核事件 ` ``os." "truncate``。" -#: ../../library/os.rst:3751 +#: ../../library/os.rst:4161 msgid "" "Remove (delete) the file *path*. This function is semantically identical " "to :func:`remove`; the ``unlink`` name is its traditional Unix name. Please " "see the documentation for :func:`remove` for further information." msgstr "" -#: ../../library/os.rst:3767 +#: ../../library/os.rst:4177 msgid "Set the access and modified times of the file specified by *path*." msgstr "" -#: ../../library/os.rst:3769 +#: ../../library/os.rst:4179 msgid "" ":func:`utime` takes two optional parameters, *times* and *ns*. These specify " "the times set on *path* and are used as follows:" msgstr "" -#: ../../library/os.rst:3772 +#: ../../library/os.rst:4182 msgid "" "If *ns* is specified, it must be a 2-tuple of the form ``(atime_ns, " "mtime_ns)`` where each member is an int expressing nanoseconds." msgstr "" -#: ../../library/os.rst:3775 +#: ../../library/os.rst:4185 msgid "" "If *times* is not ``None``, it must be a 2-tuple of the form ``(atime, " -"mtime)`` where each member is an int or float expressing seconds." +"mtime)`` where each member is a real number expressing seconds, rounded down " +"to nanoseconds." msgstr "" -#: ../../library/os.rst:3778 +#: ../../library/os.rst:4189 msgid "" "If *times* is ``None`` and *ns* is unspecified, this is equivalent to " "specifying ``ns=(atime_ns, mtime_ns)`` where both times are the current time." msgstr "" -#: ../../library/os.rst:3782 +#: ../../library/os.rst:4193 msgid "It is an error to specify tuples for both *times* and *ns*." msgstr "" -#: ../../library/os.rst:3784 +#: ../../library/os.rst:4195 msgid "" "Note that the exact times you set here may not be returned by a subsequent :" "func:`~os.stat` call, depending on the resolution with which your operating " @@ -4211,7 +4537,7 @@ msgid "" "func:`utime`." msgstr "" -#: ../../library/os.rst:3795 +#: ../../library/os.rst:4206 msgid "" "Raises an :ref:`auditing event ` ``os.utime`` with arguments " "``path``, ``times``, ``ns``, ``dir_fd``." @@ -4219,13 +4545,17 @@ msgstr "" "引發一個附帶引數 ``path``、``times``、``ns``、``dir_fd`` 的\\ :ref:`稽核事件 " "` ``os.utime``。" -#: ../../library/os.rst:3797 +#: ../../library/os.rst:4208 msgid "" "Added support for specifying *path* as an open file descriptor, and the " "*dir_fd*, *follow_symlinks*, and *ns* parameters." msgstr "" -#: ../../library/os.rst:3811 +#: ../../library/os.rst:4215 +msgid "Accepts any real numbers as *times*, not only integers or floats." +msgstr "" + +#: ../../library/os.rst:4225 msgid "" "Generate the file names in a directory tree by walking the tree either top-" "down or bottom-up. For each directory in the tree rooted at directory *top* " @@ -4233,7 +4563,7 @@ msgid "" "filenames)``." msgstr "" -#: ../../library/os.rst:3816 +#: ../../library/os.rst:4230 msgid "" "*dirpath* is a string, the path to the directory. *dirnames* is a list of " "the names of the subdirectories in *dirpath* (including symlinks to " @@ -4247,7 +4577,7 @@ msgid "" "unspecified." msgstr "" -#: ../../library/os.rst:3827 +#: ../../library/os.rst:4241 msgid "" "If optional argument *topdown* is ``True`` or not specified, the triple for " "a directory is generated before the triples for any of its subdirectories " @@ -4258,7 +4588,7 @@ msgid "" "its subdirectories are generated." msgstr "" -#: ../../library/os.rst:3835 +#: ../../library/os.rst:4249 msgid "" "When *topdown* is ``True``, the caller can modify the *dirnames* list in-" "place (perhaps using :keyword:`del` or slice assignment), and :func:`walk` " @@ -4271,7 +4601,7 @@ msgid "" "itself is generated." msgstr "" -#: ../../library/os.rst:3844 +#: ../../library/os.rst:4258 msgid "" "By default, errors from the :func:`scandir` call are ignored. If optional " "argument *onerror* is specified, it should be a function; it will be called " @@ -4281,35 +4611,35 @@ msgid "" "object." msgstr "" -#: ../../library/os.rst:3850 +#: ../../library/os.rst:4264 msgid "" "By default, :func:`walk` will not walk down into symbolic links that resolve " "to directories. Set *followlinks* to ``True`` to visit directories pointed " "to by symlinks, on systems that support them." msgstr "" -#: ../../library/os.rst:3856 +#: ../../library/os.rst:4270 msgid "" "Be aware that setting *followlinks* to ``True`` can lead to infinite " "recursion if a link points to a parent directory of itself. :func:`walk` " "does not keep track of the directories it visited already." msgstr "" -#: ../../library/os.rst:3862 +#: ../../library/os.rst:4276 msgid "" "If you pass a relative pathname, don't change the current working directory " "between resumptions of :func:`walk`. :func:`walk` never changes the current " "directory, and assumes that its caller doesn't either." msgstr "" -#: ../../library/os.rst:3866 ../../library/os.rst:3928 +#: ../../library/os.rst:4280 ../../library/os.rst:4342 msgid "" "This example displays the number of bytes taken by non-directory files in " "each directory under the starting directory, except that it doesn't look " "under any ``__pycache__`` subdirectory::" msgstr "" -#: ../../library/os.rst:3870 +#: ../../library/os.rst:4284 msgid "" "import os\n" "from os.path import join, getsize\n" @@ -4329,14 +4659,14 @@ msgstr "" " if '__pycache__' in dirs:\n" " dirs.remove('__pycache__') # don't visit __pycache__ directories" -#: ../../library/os.rst:3879 +#: ../../library/os.rst:4293 msgid "" "In the next example (simple implementation of :func:`shutil.rmtree`), " "walking the tree bottom-up is essential, :func:`rmdir` doesn't allow " "deleting a directory before the directory is empty::" msgstr "" -#: ../../library/os.rst:3883 +#: ../../library/os.rst:4297 msgid "" "# Delete everything reachable from the directory named in \"top\",\n" "# assuming there are no symbolic links.\n" @@ -4351,7 +4681,7 @@ msgid "" "os.rmdir(top)" msgstr "" -#: ../../library/os.rst:3895 +#: ../../library/os.rst:4309 msgid "" "Raises an :ref:`auditing event ` ``os.walk`` with arguments " "``top``, ``topdown``, ``onerror``, ``followlinks``." @@ -4359,25 +4689,25 @@ msgstr "" "引發一個附帶引數 ``top``、``topdown``、``onerror``、``followlinks`` 的\\ :" "ref:`稽核事件 ` ``os.walk``。" -#: ../../library/os.rst:3897 +#: ../../library/os.rst:4311 msgid "" "This function now calls :func:`os.scandir` instead of :func:`os.listdir`, " "making it faster by reducing the number of calls to :func:`os.stat`." msgstr "" -#: ../../library/os.rst:3911 +#: ../../library/os.rst:4325 msgid "" "This behaves exactly like :func:`walk`, except that it yields a 4-tuple " "``(dirpath, dirnames, filenames, dirfd)``, and it supports ``dir_fd``." msgstr "" -#: ../../library/os.rst:3914 +#: ../../library/os.rst:4328 msgid "" "*dirpath*, *dirnames* and *filenames* are identical to :func:`walk` output, " "and *dirfd* is a file descriptor referring to the directory *dirpath*." msgstr "" -#: ../../library/os.rst:3917 +#: ../../library/os.rst:4331 msgid "" "This function always supports :ref:`paths relative to directory descriptors " "` and :ref:`not following symlinks `. Note however " @@ -4385,14 +4715,14 @@ msgid "" "*follow_symlinks* is ``False``." msgstr "" -#: ../../library/os.rst:3924 +#: ../../library/os.rst:4338 msgid "" "Since :func:`fwalk` yields file descriptors, those are only valid until the " "next iteration step, so you should duplicate them (e.g. with :func:`dup`) if " "you want to keep them longer." msgstr "" -#: ../../library/os.rst:3932 +#: ../../library/os.rst:4346 msgid "" "import os\n" "for root, dirs, files, rootfd in os.fwalk('python/Lib/xml'):\n" @@ -4404,13 +4734,13 @@ msgid "" " dirs.remove('__pycache__') # don't visit __pycache__ directories" msgstr "" -#: ../../library/os.rst:3941 +#: ../../library/os.rst:4355 msgid "" "In the next example, walking the tree bottom-up is essential: :func:`rmdir` " "doesn't allow deleting a directory before the directory is empty::" msgstr "" -#: ../../library/os.rst:3945 +#: ../../library/os.rst:4359 msgid "" "# Delete everything reachable from the directory named in \"top\",\n" "# assuming there are no symbolic links.\n" @@ -4424,7 +4754,7 @@ msgid "" " os.rmdir(name, dir_fd=rootfd)" msgstr "" -#: ../../library/os.rst:3956 +#: ../../library/os.rst:4370 msgid "" "Raises an :ref:`auditing event ` ``os.fwalk`` with arguments " "``top``, ``topdown``, ``onerror``, ``follow_symlinks``, ``dir_fd``." @@ -4432,11 +4762,11 @@ msgstr "" "引發一個附帶引數 ``top``、``topdown``、``onerror``、``follow_symlinks``、" "``dir_fd`` 的\\ :ref:`稽核事件 ` ``os.fwalk``。" -#: ../../library/os.rst:3965 +#: ../../library/os.rst:4379 msgid "Added support for :class:`bytes` paths." msgstr "新增對 :class:`bytes` 路徑的支援。" -#: ../../library/os.rst:3971 +#: ../../library/os.rst:4385 msgid "" "Create an anonymous file and return a file descriptor that refers to it. " "*flags* must be one of the ``os.MFD_*`` constants available on the system " @@ -4444,7 +4774,7 @@ msgid "" "descriptor is :ref:`non-inheritable `." msgstr "" -#: ../../library/os.rst:3976 +#: ../../library/os.rst:4390 msgid "" "The name supplied in *name* is used as a filename and will be displayed as " "the target of the corresponding symbolic link in the directory ``/proc/self/" @@ -4454,15 +4784,15 @@ msgid "" "side effects." msgstr "" -#: ../../library/os.rst:4006 +#: ../../library/os.rst:4420 msgid "These flags can be passed to :func:`memfd_create`." msgstr "這些旗標可以傳給 :func:`memfd_create`。" -#: ../../library/os.rst:4010 +#: ../../library/os.rst:4424 msgid "The ``MFD_HUGE*`` flags are only available since Linux 4.14." msgstr "``MFD_HUGE*`` 旗標僅在 Linux 4.14 以上可用。" -#: ../../library/os.rst:4017 +#: ../../library/os.rst:4431 msgid "" "Create and return an event file descriptor. The file descriptors supports " "raw :func:`read` and :func:`write` with a buffer size of 8, :func:`~select." @@ -4471,7 +4801,7 @@ msgid "" "ref:`non-inheritable `." msgstr "" -#: ../../library/os.rst:4023 +#: ../../library/os.rst:4437 msgid "" "*initval* is the initial value of the event counter. The initial value must " "be a 32 bit unsigned integer. Please note that the initial value is limited " @@ -4479,39 +4809,39 @@ msgid "" "integer with a maximum value of 2\\ :sup:`64`\\ -\\ 2." msgstr "" -#: ../../library/os.rst:4028 +#: ../../library/os.rst:4442 msgid "" "*flags* can be constructed from :const:`EFD_CLOEXEC`, :const:`EFD_NONBLOCK`, " "and :const:`EFD_SEMAPHORE`." msgstr "" -#: ../../library/os.rst:4031 +#: ../../library/os.rst:4445 msgid "" "If :const:`EFD_SEMAPHORE` is specified and the event counter is non-zero, :" "func:`eventfd_read` returns 1 and decrements the counter by one." msgstr "" -#: ../../library/os.rst:4034 +#: ../../library/os.rst:4448 msgid "" "If :const:`EFD_SEMAPHORE` is not specified and the event counter is non-" "zero, :func:`eventfd_read` returns the current event counter value and " "resets the counter to zero." msgstr "" -#: ../../library/os.rst:4038 +#: ../../library/os.rst:4452 msgid "" "If the event counter is zero and :const:`EFD_NONBLOCK` is not specified, :" "func:`eventfd_read` blocks." msgstr "" -#: ../../library/os.rst:4041 +#: ../../library/os.rst:4455 msgid "" ":func:`eventfd_write` increments the event counter. Write blocks if the " "write operation would increment the counter to a value larger than 2\\ :sup:" "`64`\\ -\\ 2." msgstr "" -#: ../../library/os.rst:4047 +#: ../../library/os.rst:4461 msgid "" "import os\n" "\n" @@ -4529,64 +4859,64 @@ msgid "" " os.close(fd)" msgstr "" -#: ../../library/os.rst:4068 +#: ../../library/os.rst:4482 msgid "" "Read value from an :func:`eventfd` file descriptor and return a 64 bit " "unsigned int. The function does not verify that *fd* is an :func:`eventfd`." msgstr "" -#: ../../library/os.rst:4077 +#: ../../library/os.rst:4491 msgid "" "Add value to an :func:`eventfd` file descriptor. *value* must be a 64 bit " "unsigned int. The function does not verify that *fd* is an :func:`eventfd`." msgstr "" -#: ../../library/os.rst:4086 +#: ../../library/os.rst:4500 msgid "Set close-on-exec flag for new :func:`eventfd` file descriptor." msgstr "" -#: ../../library/os.rst:4094 +#: ../../library/os.rst:4508 msgid "" "Set :const:`O_NONBLOCK` status flag for new :func:`eventfd` file descriptor." msgstr "設定新的 :func:`eventfd` 檔案描述器的 :const:`O_NONBLOCK` 狀態旗標。" -#: ../../library/os.rst:4103 +#: ../../library/os.rst:4517 msgid "" "Provide semaphore-like semantics for reads from an :func:`eventfd` file " "descriptor. On read the internal counter is decremented by one." msgstr "" -#: ../../library/os.rst:4114 +#: ../../library/os.rst:4528 msgid "Timer File Descriptors" msgstr "計時器檔案描述器" -#: ../../library/os.rst:4118 +#: ../../library/os.rst:4532 msgid "" "These functions provide support for Linux's *timer file descriptor* API. " "Naturally, they are all only available on Linux." msgstr "" -#: ../../library/os.rst:4123 +#: ../../library/os.rst:4537 msgid "Create and return a timer file descriptor (*timerfd*)." msgstr "" -#: ../../library/os.rst:4125 +#: ../../library/os.rst:4539 msgid "The file descriptor returned by :func:`timerfd_create` supports:" msgstr "" -#: ../../library/os.rst:4127 +#: ../../library/os.rst:4541 msgid ":func:`read`" msgstr ":func:`read`" -#: ../../library/os.rst:4128 +#: ../../library/os.rst:4542 msgid ":func:`~select.select`" msgstr ":func:`~select.select`" -#: ../../library/os.rst:4129 +#: ../../library/os.rst:4543 msgid ":func:`~select.poll`" msgstr ":func:`~select.poll`" -#: ../../library/os.rst:4131 +#: ../../library/os.rst:4545 msgid "" "The file descriptor's :func:`read` method can be called with a buffer size " "of 8. If the timer has already expired one or more times, :func:`read` " @@ -4595,31 +4925,31 @@ msgid "" "byteorder)``." msgstr "" -#: ../../library/os.rst:4136 +#: ../../library/os.rst:4550 msgid "" ":func:`~select.select` and :func:`~select.poll` can be used to wait until " "timer expires and the file descriptor is readable." msgstr "" -#: ../../library/os.rst:4139 +#: ../../library/os.rst:4553 msgid "" "*clockid* must be a valid :ref:`clock ID `, as " "defined in the :py:mod:`time` module:" msgstr "" -#: ../../library/os.rst:4142 +#: ../../library/os.rst:4556 msgid ":const:`time.CLOCK_REALTIME`" msgstr ":const:`time.CLOCK_REALTIME`" -#: ../../library/os.rst:4143 +#: ../../library/os.rst:4557 msgid ":const:`time.CLOCK_MONOTONIC`" msgstr ":const:`time.CLOCK_MONOTONIC`" -#: ../../library/os.rst:4144 +#: ../../library/os.rst:4558 msgid ":const:`time.CLOCK_BOOTTIME` (Since Linux 3.15 for timerfd_create)" msgstr "" -#: ../../library/os.rst:4146 +#: ../../library/os.rst:4560 msgid "" "If *clockid* is :const:`time.CLOCK_REALTIME`, a settable system-wide real-" "time clock is used. If the system clock is changed, the timer setting needs " @@ -4627,35 +4957,35 @@ msgid "" "const:`TFD_TIMER_CANCEL_ON_SET`." msgstr "" -#: ../../library/os.rst:4151 +#: ../../library/os.rst:4565 msgid "" "If *clockid* is :const:`time.CLOCK_MONOTONIC`, a non-settable monotonically " "increasing clock is used. Even if the system clock is changed, the timer " "setting will not be affected." msgstr "" -#: ../../library/os.rst:4155 +#: ../../library/os.rst:4569 msgid "" "If *clockid* is :const:`time.CLOCK_BOOTTIME`, it is the same as :const:`time." "CLOCK_MONOTONIC` except it includes any time that the system is suspended." msgstr "" -#: ../../library/os.rst:4159 +#: ../../library/os.rst:4573 msgid "" "The file descriptor's behaviour can be modified by specifying a *flags* " "value. Any of the following variables may be used, combined using bitwise OR " "(the ``|`` operator):" msgstr "" -#: ../../library/os.rst:4163 +#: ../../library/os.rst:4577 msgid ":const:`TFD_NONBLOCK`" msgstr ":const:`TFD_NONBLOCK`" -#: ../../library/os.rst:4164 +#: ../../library/os.rst:4578 msgid ":const:`TFD_CLOEXEC`" msgstr ":const:`TFD_CLOEXEC`" -#: ../../library/os.rst:4166 +#: ../../library/os.rst:4580 msgid "" "If :const:`TFD_NONBLOCK` is not set as a flag, :func:`read` blocks until the " "timer expires. If it is set as a flag, :func:`read` doesn't block, but if " @@ -4663,46 +4993,46 @@ msgid "" "raises :class:`OSError` with ``errno`` set to :const:`errno.EAGAIN`." msgstr "" -#: ../../library/os.rst:4172 +#: ../../library/os.rst:4586 msgid ":const:`TFD_CLOEXEC` is always set by Python automatically." msgstr ":const:`TFD_CLOEXEC` 總是由 Python 自動設定。" -#: ../../library/os.rst:4174 +#: ../../library/os.rst:4588 msgid "" "The file descriptor must be closed with :func:`os.close` when it is no " "longer needed, or else the file descriptor will be leaked." msgstr "" -#: ../../library/os.rst:4177 +#: ../../library/os.rst:4591 msgid "The :manpage:`timerfd_create(2)` man page." msgstr ":manpage:`timerfd_create(2)` 使用手冊。" -#: ../../library/os.rst:4186 +#: ../../library/os.rst:4600 msgid "" "Alter a timer file descriptor's internal timer. This function operates the " "same interval timer as :func:`timerfd_settime_ns`." msgstr "" -#: ../../library/os.rst:4189 +#: ../../library/os.rst:4603 msgid "*fd* must be a valid timer file descriptor." msgstr "*fd* 必須是有效的計時器檔案描述器。" -#: ../../library/os.rst:4191 +#: ../../library/os.rst:4605 msgid "" "The timer's behaviour can be modified by specifying a *flags* value. Any of " "the following variables may be used, combined using bitwise OR (the ``|`` " "operator):" msgstr "" -#: ../../library/os.rst:4195 +#: ../../library/os.rst:4609 msgid ":const:`TFD_TIMER_ABSTIME`" msgstr ":const:`TFD_TIMER_ABSTIME`" -#: ../../library/os.rst:4196 +#: ../../library/os.rst:4610 msgid ":const:`TFD_TIMER_CANCEL_ON_SET`" msgstr ":const:`TFD_TIMER_CANCEL_ON_SET`" -#: ../../library/os.rst:4198 +#: ../../library/os.rst:4612 msgid "" "The timer is disabled by setting *initial* to zero (``0``). If *initial* is " "greater than zero, the timer is enabled. If *initial* is less than zero, it " @@ -4710,28 +5040,27 @@ msgid "" "EINVAL`." msgstr "" -#: ../../library/os.rst:4203 +#: ../../library/os.rst:4617 msgid "By default the timer will fire when *initial* seconds have elapsed." msgstr "" -#: ../../library/os.rst:4205 +#: ../../library/os.rst:4619 msgid "" "However, if the :const:`TFD_TIMER_ABSTIME` flag is set, the timer will fire " "when the timer's clock (set by *clockid* in :func:`timerfd_create`) reaches " "*initial* seconds." msgstr "" -#: ../../library/os.rst:4209 +#: ../../library/os.rst:4623 msgid "" -"The timer's interval is set by the *interval* :py:class:`float`. If " -"*interval* is zero, the timer only fires once, on the initial expiration. If " -"*interval* is greater than zero, the timer fires every time *interval* " -"seconds have elapsed since the previous expiration. If *interval* is less " -"than zero, it raises :class:`OSError` with ``errno`` set to :const:`errno." -"EINVAL`." +"The timer's interval is set by the *interval* real number. If *interval* is " +"zero, the timer only fires once, on the initial expiration. If *interval* is " +"greater than zero, the timer fires every time *interval* seconds have " +"elapsed since the previous expiration. If *interval* is less than zero, it " +"raises :class:`OSError` with ``errno`` set to :const:`errno.EINVAL`." msgstr "" -#: ../../library/os.rst:4216 +#: ../../library/os.rst:4630 msgid "" "If the :const:`TFD_TIMER_CANCEL_ON_SET` flag is set along with :const:" "`TFD_TIMER_ABSTIME` and the clock for this timer is :const:`time." @@ -4740,86 +5069,86 @@ msgid "" "const:`errno.ECANCELED`." msgstr "" -#: ../../library/os.rst:4222 +#: ../../library/os.rst:4636 msgid "" "Linux manages system clock as UTC. A daylight-savings time transition is " "done by changing time offset only and doesn't cause discontinuous system " "clock change." msgstr "" -#: ../../library/os.rst:4226 +#: ../../library/os.rst:4640 msgid "" "Discontinuous system clock change will be caused by the following events:" msgstr "" -#: ../../library/os.rst:4228 +#: ../../library/os.rst:4642 msgid "``settimeofday``" msgstr "``settimeofday``" -#: ../../library/os.rst:4229 +#: ../../library/os.rst:4643 msgid "``clock_settime``" msgstr "``clock_settime``" -#: ../../library/os.rst:4230 +#: ../../library/os.rst:4644 msgid "set the system date and time by ``date`` command" msgstr "" -#: ../../library/os.rst:4232 +#: ../../library/os.rst:4646 msgid "" "Return a two-item tuple of (``next_expiration``, ``interval``) from the " "previous timer state, before this function executed." msgstr "" -#: ../../library/os.rst:4237 +#: ../../library/os.rst:4651 msgid "" ":manpage:`timerfd_create(2)`, :manpage:`timerfd_settime(2)`, :manpage:" "`settimeofday(2)`, :manpage:`clock_settime(2)`, and :manpage:`date(1)`." msgstr "" -#: ../../library/os.rst:4248 +#: ../../library/os.rst:4662 msgid "" "Similar to :func:`timerfd_settime`, but use time as nanoseconds. This " "function operates the same interval timer as :func:`timerfd_settime`." msgstr "" -#: ../../library/os.rst:4258 +#: ../../library/os.rst:4672 msgid "Return a two-item tuple of floats (``next_expiration``, ``interval``)." msgstr "" -#: ../../library/os.rst:4260 +#: ../../library/os.rst:4674 msgid "" "``next_expiration`` denotes the relative time until the timer next fires, " "regardless of if the :const:`TFD_TIMER_ABSTIME` flag is set." msgstr "" -#: ../../library/os.rst:4263 +#: ../../library/os.rst:4677 msgid "" "``interval`` denotes the timer's interval. If zero, the timer will only fire " "once, after ``next_expiration`` seconds have elapsed." msgstr "" -#: ../../library/os.rst:4267 +#: ../../library/os.rst:4681 msgid ":manpage:`timerfd_gettime(2)`" msgstr ":manpage:`timerfd_gettime(2)`" -#: ../../library/os.rst:4276 +#: ../../library/os.rst:4690 msgid "Similar to :func:`timerfd_gettime`, but return time as nanoseconds." msgstr "" -#: ../../library/os.rst:4284 +#: ../../library/os.rst:4698 msgid "" "A flag for the :func:`timerfd_create` function, which sets the :const:" "`O_NONBLOCK` status flag for the new timer file descriptor. If :const:" "`TFD_NONBLOCK` is not set as a flag, :func:`read` blocks." msgstr "" -#: ../../library/os.rst:4294 +#: ../../library/os.rst:4708 msgid "" "A flag for the :func:`timerfd_create` function, If :const:`TFD_CLOEXEC` is " "set as a flag, set close-on-exec flag for new file descriptor." msgstr "" -#: ../../library/os.rst:4304 +#: ../../library/os.rst:4718 msgid "" "A flag for the :func:`timerfd_settime` and :func:`timerfd_settime_ns` " "functions. If this flag is set, *initial* is interpreted as an absolute " @@ -4827,22 +5156,22 @@ msgid "" "Epoch)." msgstr "" -#: ../../library/os.rst:4314 +#: ../../library/os.rst:4728 msgid "" "A flag for the :func:`timerfd_settime` and :func:`timerfd_settime_ns` " "functions along with :const:`TFD_TIMER_ABSTIME`. The timer is cancelled when " "the time of the underlying clock changes discontinuously." msgstr "" -#: ../../library/os.rst:4325 +#: ../../library/os.rst:4739 msgid "Linux extended attributes" msgstr "" -#: ../../library/os.rst:4329 +#: ../../library/os.rst:4743 msgid "These functions are all available on Linux only." msgstr "" -#: ../../library/os.rst:4333 +#: ../../library/os.rst:4747 msgid "" "Return the value of the extended filesystem attribute *attribute* for " "*path*. *attribute* can be bytes or str (directly or indirectly through the :" @@ -4850,7 +5179,7 @@ msgid "" "encoding." msgstr "" -#: ../../library/os.rst:4341 +#: ../../library/os.rst:4755 msgid "" "Raises an :ref:`auditing event ` ``os.getxattr`` with arguments " "``path``, ``attribute``." @@ -4858,12 +5187,12 @@ msgstr "" "引發一個附帶引數 ``path``、``attribute`` 的\\ :ref:`稽核事件 ` " "``os.getxattr``。" -#: ../../library/os.rst:4343 ../../library/os.rst:4375 -#: ../../library/os.rst:4400 +#: ../../library/os.rst:4757 ../../library/os.rst:4793 +#: ../../library/os.rst:4818 msgid "Accepts a :term:`path-like object` for *path* and *attribute*." msgstr "" -#: ../../library/os.rst:4349 +#: ../../library/os.rst:4763 msgid "" "Return a list of the extended filesystem attributes on *path*. The " "attributes in the list are represented as strings decoded with the " @@ -4871,14 +5200,20 @@ msgid "" "the current directory." msgstr "" -#: ../../library/os.rst:4357 +#: ../../library/os.rst:4771 msgid "" "Raises an :ref:`auditing event ` ``os.listxattr`` with argument " "``path``." msgstr "" "引發一個附帶引數 ``path`` 的\\ :ref:`稽核事件 ` ``os.listxattr``。" -#: ../../library/os.rst:4365 +#: ../../library/os.rst:4776 +msgid "" +"``os.listxattr(-1)`` now fails with ``OSError(errno.EBADF)`` rather than " +"listing extended attributes of the current directory." +msgstr "" + +#: ../../library/os.rst:4783 msgid "" "Removes the extended filesystem attribute *attribute* from *path*. " "*attribute* should be bytes or str (directly or indirectly through the :" @@ -4886,7 +5221,7 @@ msgid "" "`filesystem encoding and error handler`." msgstr "" -#: ../../library/os.rst:4373 +#: ../../library/os.rst:4791 msgid "" "Raises an :ref:`auditing event ` ``os.removexattr`` with arguments " "``path``, ``attribute``." @@ -4894,7 +5229,7 @@ msgstr "" "引發一個附帶引數 ``path``、``attribute`` 的\\ :ref:`稽核事件 ` " "``os.removexattr``。" -#: ../../library/os.rst:4381 +#: ../../library/os.rst:4799 msgid "" "Set the extended filesystem attribute *attribute* on *path* to *value*. " "*attribute* must be a bytes or str with no embedded NULs (directly or " @@ -4906,13 +5241,13 @@ msgid "" "will not be created and ``EEXISTS`` will be raised." msgstr "" -#: ../../library/os.rst:4395 +#: ../../library/os.rst:4813 msgid "" "A bug in Linux kernel versions less than 2.6.39 caused the flags argument to " "be ignored on some filesystems." msgstr "" -#: ../../library/os.rst:4398 +#: ../../library/os.rst:4816 msgid "" "Raises an :ref:`auditing event ` ``os.setxattr`` with arguments " "``path``, ``attribute``, ``value``, ``flags``." @@ -4920,33 +5255,33 @@ msgstr "" "引發一個附帶引數 ``path``、``attribute``、``value``、``flags`` 的\\ :ref:`稽" "核事件 ` ``os.setxattr``。" -#: ../../library/os.rst:4406 +#: ../../library/os.rst:4824 msgid "" "The maximum size the value of an extended attribute can be. Currently, this " "is 64 KiB on Linux." msgstr "" -#: ../../library/os.rst:4412 +#: ../../library/os.rst:4830 msgid "" "This is a possible value for the flags argument in :func:`setxattr`. It " "indicates the operation must create an attribute." msgstr "" -#: ../../library/os.rst:4418 +#: ../../library/os.rst:4836 msgid "" "This is a possible value for the flags argument in :func:`setxattr`. It " "indicates the operation must replace an existing attribute." msgstr "" -#: ../../library/os.rst:4425 +#: ../../library/os.rst:4843 msgid "Process Management" msgstr "行程管理" -#: ../../library/os.rst:4427 +#: ../../library/os.rst:4845 msgid "These functions may be used to create and manage processes." msgstr "" -#: ../../library/os.rst:4429 +#: ../../library/os.rst:4847 msgid "" "The various :func:`exec\\* ` functions take a list of arguments for " "the new program loaded into the process. In each case, the first of these " @@ -4957,40 +5292,40 @@ msgid "" "standard output; ``foo`` will seem to be ignored." msgstr "" -#: ../../library/os.rst:4440 +#: ../../library/os.rst:4858 msgid "" -"Generate a :const:`SIGABRT` signal to the current process. On Unix, the " -"default behavior is to produce a core dump; on Windows, the process " +"Generate a :const:`~signal.SIGABRT` signal to the current process. On Unix, " +"the default behavior is to produce a core dump; on Windows, the process " "immediately returns an exit code of ``3``. Be aware that calling this " "function will not call the Python signal handler registered for :const:" -"`SIGABRT` with :func:`signal.signal`." +"`~signal.SIGABRT` with :func:`signal.signal`." msgstr "" -#: ../../library/os.rst:4449 +#: ../../library/os.rst:4867 msgid "Add a path to the DLL search path." msgstr "" -#: ../../library/os.rst:4451 +#: ../../library/os.rst:4869 msgid "" "This search path is used when resolving dependencies for imported extension " "modules (the module itself is resolved through :data:`sys.path`), and also " "by :mod:`ctypes`." msgstr "" -#: ../../library/os.rst:4455 +#: ../../library/os.rst:4873 msgid "" "Remove the directory by calling **close()** on the returned object or using " "it in a :keyword:`with` statement." msgstr "" -#: ../../library/os.rst:4458 +#: ../../library/os.rst:4876 msgid "" "See the `Microsoft documentation `_ for more information about how " "DLLs are loaded." msgstr "" -#: ../../library/os.rst:4462 +#: ../../library/os.rst:4880 msgid "" "Raises an :ref:`auditing event ` ``os.add_dll_directory`` with " "argument ``path``." @@ -4998,7 +5333,7 @@ msgstr "" "引發一個附帶引數 ``path`` 的\\ :ref:`稽核事件 ` ``os." "add_dll_directory``。" -#: ../../library/os.rst:4466 +#: ../../library/os.rst:4884 msgid "" "Previous versions of CPython would resolve DLLs using the default behavior " "for the current process. This led to inconsistencies, such as only sometimes " @@ -5006,14 +5341,14 @@ msgid "" "such as ``AddDllDirectory`` having no effect." msgstr "" -#: ../../library/os.rst:4473 +#: ../../library/os.rst:4891 msgid "" "In 3.8, the two primary ways DLLs are loaded now explicitly override the " "process-wide behavior to ensure consistency. See the :ref:`porting notes " "` for information on updating libraries." msgstr "" -#: ../../library/os.rst:4488 +#: ../../library/os.rst:4906 msgid "" "These functions all execute a new program, replacing the current process; " "they do not return. On Unix, the new executable is loaded into the current " @@ -5021,7 +5356,7 @@ msgid "" "reported as :exc:`OSError` exceptions." msgstr "" -#: ../../library/os.rst:4493 +#: ../../library/os.rst:4911 msgid "" "The current process is replaced immediately. Open file objects and " "descriptors are not flushed, so if there may be data buffered on these open " @@ -5029,7 +5364,7 @@ msgid "" "fsync` before calling an :func:`exec\\* ` function." msgstr "" -#: ../../library/os.rst:4499 +#: ../../library/os.rst:4917 msgid "" "The \"l\" and \"v\" variants of the :func:`exec\\* ` functions differ " "in how command-line arguments are passed. The \"l\" variants are perhaps " @@ -5042,7 +5377,7 @@ msgid "" "is not enforced." msgstr "" -#: ../../library/os.rst:4508 +#: ../../library/os.rst:4926 msgid "" "The variants which include a \"p\" near the end (:func:`execlp`, :func:" "`execlpe`, :func:`execvp`, and :func:`execvpe`) will use the :envvar:`PATH` " @@ -5056,7 +5391,7 @@ msgid "" "even on Windows, as plain names will not be resolved." msgstr "" -#: ../../library/os.rst:4519 +#: ../../library/os.rst:4937 msgid "" "For :func:`execle`, :func:`execlpe`, :func:`execve`, and :func:`execvpe` " "(note that these all end in \"e\"), the *env* parameter must be a mapping " @@ -5066,7 +5401,7 @@ msgid "" "process to inherit the environment of the current process." msgstr "" -#: ../../library/os.rst:4526 +#: ../../library/os.rst:4944 msgid "" "For :func:`execve` on some platforms, *path* may also be specified as an " "open file descriptor. This functionality may not be supported on your " @@ -5075,7 +5410,7 @@ msgid "" "`NotImplementedError`." msgstr "" -#: ../../library/os.rst:4531 +#: ../../library/os.rst:4949 msgid "" "Raises an :ref:`auditing event ` ``os.exec`` with arguments " "``path``, ``args``, ``env``." @@ -5083,25 +5418,25 @@ msgstr "" "引發一個附帶引數 ``path``、``args``、``env`` 的\\ :ref:`稽核事件 ` " "``os.exec``。" -#: ../../library/os.rst:4535 +#: ../../library/os.rst:4953 msgid "" "Added support for specifying *path* as an open file descriptor for :func:" "`execve`." msgstr "" -#: ../../library/os.rst:4544 +#: ../../library/os.rst:4962 msgid "" "Exit the process with status *n*, without calling cleanup handlers, flushing " "stdio buffers, etc." msgstr "" -#: ../../library/os.rst:4549 +#: ../../library/os.rst:4967 msgid "" "The standard way to exit is :func:`sys.exit(n) `. :func:`!_exit` " "should normally only be used in the child process after a :func:`fork`." msgstr "" -#: ../../library/os.rst:4552 +#: ../../library/os.rst:4970 msgid "" "The following exit codes are defined and can be used with :func:`_exit`, " "although they are not required. These are typically used for system " @@ -5109,139 +5444,139 @@ msgid "" "delivery program." msgstr "" -#: ../../library/os.rst:4558 +#: ../../library/os.rst:4976 msgid "" "Some of these may not be available on all Unix platforms, since there is " "some variation. These constants are defined where they are defined by the " "underlying platform." msgstr "" -#: ../../library/os.rst:4565 +#: ../../library/os.rst:4983 msgid "" "Exit code that means no error occurred. May be taken from the defined value " "of ``EXIT_SUCCESS`` on some platforms. Generally has a value of zero." msgstr "" -#: ../../library/os.rst:4573 +#: ../../library/os.rst:4991 msgid "" "Exit code that means the command was used incorrectly, such as when the " "wrong number of arguments are given." msgstr "" -#: ../../library/os.rst:4581 +#: ../../library/os.rst:4999 msgid "Exit code that means the input data was incorrect." msgstr "" -#: ../../library/os.rst:4588 +#: ../../library/os.rst:5006 msgid "Exit code that means an input file did not exist or was not readable." msgstr "" -#: ../../library/os.rst:4595 +#: ../../library/os.rst:5013 msgid "Exit code that means a specified user did not exist." msgstr "" -#: ../../library/os.rst:4602 +#: ../../library/os.rst:5020 msgid "Exit code that means a specified host did not exist." msgstr "" -#: ../../library/os.rst:4609 +#: ../../library/os.rst:5027 msgid "Exit code that means that a required service is unavailable." msgstr "" -#: ../../library/os.rst:4616 +#: ../../library/os.rst:5034 msgid "Exit code that means an internal software error was detected." msgstr "" -#: ../../library/os.rst:4623 +#: ../../library/os.rst:5041 msgid "" "Exit code that means an operating system error was detected, such as the " "inability to fork or create a pipe." msgstr "" -#: ../../library/os.rst:4631 +#: ../../library/os.rst:5049 msgid "" "Exit code that means some system file did not exist, could not be opened, or " "had some other kind of error." msgstr "" -#: ../../library/os.rst:4639 +#: ../../library/os.rst:5057 msgid "Exit code that means a user specified output file could not be created." msgstr "" -#: ../../library/os.rst:4646 +#: ../../library/os.rst:5064 msgid "" "Exit code that means that an error occurred while doing I/O on some file." msgstr "" -#: ../../library/os.rst:4653 +#: ../../library/os.rst:5071 msgid "" "Exit code that means a temporary failure occurred. This indicates something " "that may not really be an error, such as a network connection that couldn't " "be made during a retryable operation." msgstr "" -#: ../../library/os.rst:4662 +#: ../../library/os.rst:5080 msgid "" "Exit code that means that a protocol exchange was illegal, invalid, or not " "understood." msgstr "" -#: ../../library/os.rst:4670 +#: ../../library/os.rst:5088 msgid "" "Exit code that means that there were insufficient permissions to perform the " "operation (but not intended for file system problems)." msgstr "" -#: ../../library/os.rst:4678 +#: ../../library/os.rst:5096 msgid "Exit code that means that some kind of configuration error occurred." msgstr "" -#: ../../library/os.rst:4685 +#: ../../library/os.rst:5103 msgid "Exit code that means something like \"an entry was not found\"." msgstr "" -#: ../../library/os.rst:4692 +#: ../../library/os.rst:5110 msgid "" "Fork a child process. Return ``0`` in the child and the child's process id " "in the parent. If an error occurs :exc:`OSError` is raised." msgstr "" -#: ../../library/os.rst:4695 +#: ../../library/os.rst:5113 msgid "" "Note that some platforms including FreeBSD <= 6.3 and Cygwin have known " "issues when using ``fork()`` from a thread." msgstr "" -#: ../../library/os.rst:4698 +#: ../../library/os.rst:5116 msgid "" "Raises an :ref:`auditing event ` ``os.fork`` with no arguments." msgstr "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``os.fork``。" -#: ../../library/os.rst:4702 +#: ../../library/os.rst:5120 msgid "" "If you use TLS sockets in an application calling ``fork()``, see the warning " "in the :mod:`ssl` documentation." msgstr "" -#: ../../library/os.rst:4707 ../../library/os.rst:4751 +#: ../../library/os.rst:5125 ../../library/os.rst:5171 msgid "" "On macOS the use of this function is unsafe when mixed with using higher-" "level system APIs, and that includes using :mod:`urllib.request`." msgstr "" -#: ../../library/os.rst:4710 +#: ../../library/os.rst:5128 msgid "" "Calling ``fork()`` in a subinterpreter is no longer supported (:exc:" "`RuntimeError` is raised)." msgstr "" -#: ../../library/os.rst:4714 +#: ../../library/os.rst:5132 msgid "" "If Python is able to detect that your process has multiple threads, :func:" "`os.fork` now raises a :exc:`DeprecationWarning`." msgstr "" -#: ../../library/os.rst:4718 +#: ../../library/os.rst:5136 msgid "" "We chose to surface this as a warning, when detectable, to better inform " "developers of a design problem that the POSIX platform specifically notes as " @@ -5252,21 +5587,21 @@ msgid "" "``free``)." msgstr "" -#: ../../library/os.rst:4727 +#: ../../library/os.rst:5145 msgid "" "Users of macOS or users of libc or malloc implementations other than those " "typically found in glibc to date are among those already more likely to " "experience deadlocks running such code." msgstr "" -#: ../../library/os.rst:4731 +#: ../../library/os.rst:5149 msgid "" "See `this discussion on fork being incompatible with threads `_ for technical details of why we're surfacing " "this longstanding platform compatibility problem to developers." msgstr "" -#: ../../library/os.rst:4741 +#: ../../library/os.rst:5159 msgid "" "Fork a child process, using a new pseudo-terminal as the child's controlling " "terminal. Return a pair of ``(pid, fd)``, where *pid* is ``0`` in the child, " @@ -5275,31 +5610,40 @@ msgid "" "the :mod:`pty` module. If an error occurs :exc:`OSError` is raised." msgstr "" -#: ../../library/os.rst:4747 +#: ../../library/os.rst:5165 +msgid "" +"The returned file descriptor *fd* is :ref:`non-inheritable `." +msgstr "" + +#: ../../library/os.rst:5167 msgid "" "Raises an :ref:`auditing event ` ``os.forkpty`` with no arguments." msgstr "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``os.forkpty``。" -#: ../../library/os.rst:4754 +#: ../../library/os.rst:5174 msgid "" "Calling ``forkpty()`` in a subinterpreter is no longer supported (:exc:" "`RuntimeError` is raised)." msgstr "" -#: ../../library/os.rst:4758 +#: ../../library/os.rst:5178 msgid "" "If Python is able to detect that your process has multiple threads, this now " "raises a :exc:`DeprecationWarning`. See the longer explanation on :func:`os." "fork`." msgstr "" -#: ../../library/os.rst:4772 +#: ../../library/os.rst:5183 +msgid "The returned file descriptor is now made non-inheritable." +msgstr "" + +#: ../../library/os.rst:5195 msgid "" "Send signal *sig* to the process *pid*. Constants for the specific signals " "available on the host platform are defined in the :mod:`signal` module." msgstr "" -#: ../../library/os.rst:4775 +#: ../../library/os.rst:5198 msgid "" "Windows: The :const:`signal.CTRL_C_EVENT` and :const:`signal." "CTRL_BREAK_EVENT` signals are special signals which can only be sent to " @@ -5309,11 +5653,11 @@ msgid "" "be set to *sig*." msgstr "" -#: ../../library/os.rst:4782 +#: ../../library/os.rst:5205 msgid "See also :func:`signal.pthread_kill`." msgstr "另請參閱 :func:`signal.pthread_kill`。" -#: ../../library/os.rst:4784 +#: ../../library/os.rst:5207 msgid "" "Raises an :ref:`auditing event ` ``os.kill`` with arguments " "``pid``, ``sig``." @@ -5321,11 +5665,11 @@ msgstr "" "引發一個附帶引數 ``pid``、``sig`` 的\\ :ref:`稽核事件 ` ``os." "kill``。" -#: ../../library/os.rst:4798 +#: ../../library/os.rst:5221 msgid "Send the signal *sig* to the process group *pgid*." msgstr "" -#: ../../library/os.rst:4800 +#: ../../library/os.rst:5223 msgid "" "Raises an :ref:`auditing event ` ``os.killpg`` with arguments " "``pgid``, ``sig``." @@ -5333,23 +5677,23 @@ msgstr "" "引發一個附帶引數 ``pgid``、``sig`` 的\\ :ref:`稽核事件 ` ``os." "killpg``。" -#: ../../library/os.rst:4807 +#: ../../library/os.rst:5230 msgid "" "Add *increment* to the process's \"niceness\". Return the new niceness." msgstr "" -#: ../../library/os.rst:4814 +#: ../../library/os.rst:5237 msgid "" "Return a file descriptor referring to the process *pid* with *flags* set. " "This descriptor can be used to perform process management without races and " "signals." msgstr "" -#: ../../library/os.rst:4818 +#: ../../library/os.rst:5241 msgid "See the :manpage:`pidfd_open(2)` man page for more details." msgstr "更多細節請見 :manpage:`pidfd_open(2)` 使用手冊。" -#: ../../library/os.rst:4825 +#: ../../library/os.rst:5248 msgid "" "This flag indicates that the file descriptor will be non-blocking. If the " "process referred to by the file descriptor has not yet terminated, then an " @@ -5357,13 +5701,13 @@ msgid "" "immediately return the error :const:`~errno.EAGAIN` rather than blocking." msgstr "" -#: ../../library/os.rst:4836 +#: ../../library/os.rst:5259 msgid "" "Lock program segments into memory. The value of *op* (defined in ````) determines which segments are locked." msgstr "" -#: ../../library/os.rst:4844 +#: ../../library/os.rst:5267 msgid "" "Open a pipe to or from command *cmd*. The return value is an open file " "object connected to the pipe, which can be read or written depending on " @@ -5373,7 +5717,7 @@ msgid "" "rather than bytes." msgstr "" -#: ../../library/os.rst:4852 +#: ../../library/os.rst:5275 msgid "" "The ``close`` method returns :const:`None` if the subprocess exited " "successfully, or the subprocess's return code if there was an error. On " @@ -5385,61 +5729,61 @@ msgid "" "contains the signed integer return code from the child process." msgstr "" -#: ../../library/os.rst:4862 +#: ../../library/os.rst:5285 msgid "" "On Unix, :func:`waitstatus_to_exitcode` can be used to convert the ``close`` " "method result (exit status) into an exit code if it is not ``None``. On " "Windows, the ``close`` method result is directly the exit code (or ``None``)." msgstr "" -#: ../../library/os.rst:4867 +#: ../../library/os.rst:5290 msgid "" "This is implemented using :class:`subprocess.Popen`; see that class's " "documentation for more powerful ways to manage and communicate with " "subprocesses." msgstr "" -#: ../../library/os.rst:4874 +#: ../../library/os.rst:5297 msgid "" "The :ref:`Python UTF-8 Mode ` affects encodings used for *cmd* " "and pipe contents." msgstr "" -#: ../../library/os.rst:4877 +#: ../../library/os.rst:5300 msgid "" ":func:`popen` is a simple wrapper around :class:`subprocess.Popen`. Use :" "class:`subprocess.Popen` or :func:`subprocess.run` to control options like " "encodings." msgstr "" -#: ../../library/os.rst:4881 ../../library/os.rst:5110 +#: ../../library/os.rst:5304 ../../library/os.rst:5533 msgid "The :mod:`subprocess` module is recommended instead." msgstr "" -#: ../../library/os.rst:4889 +#: ../../library/os.rst:5312 msgid "Wraps the :c:func:`!posix_spawn` C library API for use from Python." msgstr "" -#: ../../library/os.rst:4891 +#: ../../library/os.rst:5314 msgid "" "Most users should use :func:`subprocess.run` instead of :func:`posix_spawn`." msgstr "" -#: ../../library/os.rst:4893 +#: ../../library/os.rst:5316 msgid "" "The positional-only arguments *path*, *args*, and *env* are similar to :func:" "`execve`. *env* is allowed to be ``None``, in which case current process' " "environment is used." msgstr "" -#: ../../library/os.rst:4897 +#: ../../library/os.rst:5320 msgid "" "The *path* parameter is the path to the executable file. The *path* should " "contain a directory. Use :func:`posix_spawnp` to pass an executable file " "without directory." msgstr "" -#: ../../library/os.rst:4901 +#: ../../library/os.rst:5324 msgid "" "The *file_actions* argument may be a sequence of tuples describing actions " "to take on specific file descriptors in the child process between the C " @@ -5448,39 +5792,39 @@ msgid "" "describing the remaining tuple elements:" msgstr "" -#: ../../library/os.rst:4909 +#: ../../library/os.rst:5332 msgid "(``os.POSIX_SPAWN_OPEN``, *fd*, *path*, *flags*, *mode*)" msgstr "(``os.POSIX_SPAWN_OPEN``, *fd*, *path*, *flags*, *mode*)" -#: ../../library/os.rst:4911 +#: ../../library/os.rst:5334 msgid "Performs ``os.dup2(os.open(path, flags, mode), fd)``." msgstr "" -#: ../../library/os.rst:4915 +#: ../../library/os.rst:5338 msgid "(``os.POSIX_SPAWN_CLOSE``, *fd*)" msgstr "(``os.POSIX_SPAWN_CLOSE``, *fd*)" -#: ../../library/os.rst:4917 +#: ../../library/os.rst:5340 msgid "Performs ``os.close(fd)``." msgstr "" -#: ../../library/os.rst:4921 +#: ../../library/os.rst:5344 msgid "(``os.POSIX_SPAWN_DUP2``, *fd*, *new_fd*)" msgstr "(``os.POSIX_SPAWN_DUP2``, *fd*, *new_fd*)" -#: ../../library/os.rst:4923 +#: ../../library/os.rst:5346 msgid "Performs ``os.dup2(fd, new_fd)``." msgstr "" -#: ../../library/os.rst:4927 +#: ../../library/os.rst:5350 msgid "(``os.POSIX_SPAWN_CLOSEFROM``, *fd*)" msgstr "(``os.POSIX_SPAWN_CLOSEFROM``, *fd*)" -#: ../../library/os.rst:4929 +#: ../../library/os.rst:5352 msgid "Performs ``os.closerange(fd, INF)``." msgstr "" -#: ../../library/os.rst:4931 +#: ../../library/os.rst:5354 msgid "" "These tuples correspond to the C library :c:func:`!" "posix_spawn_file_actions_addopen`, :c:func:`!" @@ -5490,7 +5834,7 @@ msgid "" "c:func:`!posix_spawn` call itself." msgstr "" -#: ../../library/os.rst:4938 +#: ../../library/os.rst:5361 msgid "" "The *setpgroup* argument will set the process group of the child to the " "value specified. If the value specified is 0, the child's process group ID " @@ -5499,7 +5843,7 @@ msgid "" "corresponds to the C library :c:macro:`!POSIX_SPAWN_SETPGROUP` flag." msgstr "" -#: ../../library/os.rst:4944 +#: ../../library/os.rst:5367 msgid "" "If the *resetids* argument is ``True`` it will reset the effective UID and " "GID of the child to the real UID and GID of the parent process. If the " @@ -5510,7 +5854,7 @@ msgid "" "library :c:macro:`!POSIX_SPAWN_RESETIDS` flag." msgstr "" -#: ../../library/os.rst:4952 +#: ../../library/os.rst:5375 msgid "" "If the *setsid* argument is ``True``, it will create a new session ID for " "``posix_spawn``. *setsid* requires :c:macro:`!POSIX_SPAWN_SETSID` or :c:" @@ -5518,7 +5862,7 @@ msgid "" "is raised." msgstr "" -#: ../../library/os.rst:4957 +#: ../../library/os.rst:5380 msgid "" "The *setsigmask* argument will set the signal mask to the signal set " "specified. If the parameter is not used, then the child inherits the " @@ -5526,14 +5870,14 @@ msgid "" "POSIX_SPAWN_SETSIGMASK` flag." msgstr "" -#: ../../library/os.rst:4962 +#: ../../library/os.rst:5385 msgid "" "The *sigdef* argument will reset the disposition of all signals in the set " "specified. This argument corresponds to the C library :c:macro:`!" "POSIX_SPAWN_SETSIGDEF` flag." msgstr "" -#: ../../library/os.rst:4966 +#: ../../library/os.rst:5389 msgid "" "The *scheduler* argument must be a tuple containing the (optional) scheduler " "policy and an instance of :class:`sched_param` with the scheduler " @@ -5543,7 +5887,7 @@ msgid "" "POSIX_SPAWN_SETSCHEDULER` flags." msgstr "" -#: ../../library/os.rst:4973 ../../library/os.rst:4994 +#: ../../library/os.rst:5396 ../../library/os.rst:5417 msgid "" "Raises an :ref:`auditing event ` ``os.posix_spawn`` with arguments " "``path``, ``argv``, ``env``." @@ -5551,79 +5895,79 @@ msgstr "" "引發一個附帶引數 ``path``、``argv``、``env`` 的\\ :ref:`稽核事件 ` " "``os.posix_spawn``。" -#: ../../library/os.rst:4977 +#: ../../library/os.rst:5400 msgid "" "*env* parameter accepts ``None``. ``os.POSIX_SPAWN_CLOSEFROM`` is available " "on platforms where :c:func:`!posix_spawn_file_actions_addclosefrom_np` " "exists." msgstr "" -#: ../../library/os.rst:4988 +#: ../../library/os.rst:5411 msgid "Wraps the :c:func:`!posix_spawnp` C library API for use from Python." msgstr "" -#: ../../library/os.rst:4990 +#: ../../library/os.rst:5413 msgid "" "Similar to :func:`posix_spawn` except that the system searches for the " "*executable* file in the list of directories specified by the :envvar:`PATH` " "environment variable (in the same way as for ``execvp(3)``)." msgstr "" -#: ../../library/os.rst:5000 +#: ../../library/os.rst:5423 msgid "See :func:`posix_spawn` documentation." msgstr "見 :func:`posix_spawn` 文件。" -#: ../../library/os.rst:5006 +#: ../../library/os.rst:5429 msgid "" "Register callables to be executed when a new child process is forked using :" "func:`os.fork` or similar process cloning APIs. The parameters are optional " "and keyword-only. Each specifies a different call point." msgstr "" -#: ../../library/os.rst:5011 +#: ../../library/os.rst:5434 msgid "*before* is a function called before forking a child process." msgstr "" -#: ../../library/os.rst:5012 +#: ../../library/os.rst:5435 msgid "" "*after_in_parent* is a function called from the parent process after forking " "a child process." msgstr "" -#: ../../library/os.rst:5014 +#: ../../library/os.rst:5437 msgid "*after_in_child* is a function called from the child process." msgstr "" -#: ../../library/os.rst:5016 +#: ../../library/os.rst:5439 msgid "" "These calls are only made if control is expected to return to the Python " "interpreter. A typical :mod:`subprocess` launch will not trigger them as " "the child is not going to re-enter the interpreter." msgstr "" -#: ../../library/os.rst:5020 +#: ../../library/os.rst:5443 msgid "" "Functions registered for execution before forking are called in reverse " "registration order. Functions registered for execution after forking " "(either in the parent or in the child) are called in registration order." msgstr "" -#: ../../library/os.rst:5025 +#: ../../library/os.rst:5448 msgid "" "Note that :c:func:`fork` calls made by third-party C code may not call those " "functions, unless it explicitly calls :c:func:`PyOS_BeforeFork`, :c:func:" "`PyOS_AfterFork_Parent` and :c:func:`PyOS_AfterFork_Child`." msgstr "" -#: ../../library/os.rst:5029 +#: ../../library/os.rst:5452 msgid "There is no way to unregister a function." msgstr "" -#: ../../library/os.rst:5045 +#: ../../library/os.rst:5468 msgid "Execute the program *path* in a new process." msgstr "" -#: ../../library/os.rst:5047 +#: ../../library/os.rst:5470 msgid "" "(Note that the :mod:`subprocess` module provides more powerful facilities " "for spawning new processes and retrieving their results; using that module " @@ -5631,7 +5975,7 @@ msgid "" "`subprocess-replacements` section.)" msgstr "" -#: ../../library/os.rst:5052 +#: ../../library/os.rst:5475 msgid "" "If *mode* is :const:`P_NOWAIT`, this function returns the process id of the " "new process; if *mode* is :const:`P_WAIT`, returns the process's exit code " @@ -5640,13 +5984,13 @@ msgid "" "handle, so can be used with the :func:`waitpid` function." msgstr "" -#: ../../library/os.rst:5058 +#: ../../library/os.rst:5481 msgid "" "Note on VxWorks, this function doesn't return ``-signal`` when the new " "process is killed. Instead it raises OSError exception." msgstr "" -#: ../../library/os.rst:5061 +#: ../../library/os.rst:5484 msgid "" "The \"l\" and \"v\" variants of the :func:`spawn\\* ` functions " "differ in how command-line arguments are passed. The \"l\" variants are " @@ -5658,7 +6002,7 @@ msgid "" "to the child process must start with the name of the command being run." msgstr "" -#: ../../library/os.rst:5070 +#: ../../library/os.rst:5493 msgid "" "The variants which include a second \"p\" near the end (:func:`spawnlp`, :" "func:`spawnlpe`, :func:`spawnvp`, and :func:`spawnvpe`) will use the :envvar:" @@ -5671,7 +6015,7 @@ msgid "" "appropriate absolute or relative path." msgstr "" -#: ../../library/os.rst:5080 +#: ../../library/os.rst:5503 msgid "" "For :func:`spawnle`, :func:`spawnlpe`, :func:`spawnve`, and :func:`spawnvpe` " "(note that these all end in \"e\"), the *env* parameter must be a mapping " @@ -5683,13 +6027,13 @@ msgid "" "values will cause the function to fail, with a return value of ``127``." msgstr "" -#: ../../library/os.rst:5089 +#: ../../library/os.rst:5512 msgid "" "As an example, the following calls to :func:`spawnlp` and :func:`spawnvpe` " "are equivalent::" msgstr "" -#: ../../library/os.rst:5092 +#: ../../library/os.rst:5515 msgid "" "import os\n" "os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')\n" @@ -5703,7 +6047,7 @@ msgstr "" "L = ['cp', 'index.html', '/dev/null']\n" "os.spawnvpe(os.P_WAIT, 'cp', L, os.environ)" -#: ../../library/os.rst:5098 +#: ../../library/os.rst:5521 msgid "" "Raises an :ref:`auditing event ` ``os.spawn`` with arguments " "``mode``, ``path``, ``args``, ``env``." @@ -5711,7 +6055,7 @@ msgstr "" "引發一個附帶引數 ``mode``、``path``、``args``、``env`` 的\\ :ref:`稽核事件 " "` ``os.spawn``。" -#: ../../library/os.rst:5102 +#: ../../library/os.rst:5525 msgid "" ":func:`spawnlp`, :func:`spawnlpe`, :func:`spawnvp` and :func:`spawnvpe` are " "not available on Windows. :func:`spawnle` and :func:`spawnve` are not " @@ -5719,7 +6063,7 @@ msgid "" "instead." msgstr "" -#: ../../library/os.rst:5117 +#: ../../library/os.rst:5540 msgid "" "Possible values for the *mode* parameter to the :func:`spawn\\* ` " "family of functions. If either of these values is given, the :func:" @@ -5727,7 +6071,7 @@ msgid "" "been created, with the process id as the return value." msgstr "" -#: ../../library/os.rst:5127 +#: ../../library/os.rst:5550 msgid "" "Possible value for the *mode* parameter to the :func:`spawn\\* ` " "family of functions. If this is given as *mode*, the :func:`spawn\\* " @@ -5736,7 +6080,7 @@ msgid "" "successful, or ``-signal`` if a signal kills the process." msgstr "" -#: ../../library/os.rst:5139 +#: ../../library/os.rst:5562 msgid "" "Possible values for the *mode* parameter to the :func:`spawn\\* ` " "family of functions. These are less portable than those listed above. :" @@ -5746,11 +6090,11 @@ msgid "" "function will not return." msgstr "" -#: ../../library/os.rst:5150 +#: ../../library/os.rst:5573 msgid "Start a file with its associated application." msgstr "" -#: ../../library/os.rst:5152 +#: ../../library/os.rst:5575 msgid "" "When *operation* is not specified, this acts like double-clicking the file " "in Windows Explorer, or giving the file name as an argument to the :program:" @@ -5758,7 +6102,7 @@ msgid "" "whatever application (if any) its extension is associated." msgstr "" -#: ../../library/os.rst:5157 +#: ../../library/os.rst:5580 msgid "" "When another *operation* is given, it must be a \"command verb\" that " "specifies what should be done with the file. Common verbs documented by " @@ -5766,28 +6110,28 @@ msgid "" "as well as ``'explore'`` and ``'find'`` (to be used on directories)." msgstr "" -#: ../../library/os.rst:5162 +#: ../../library/os.rst:5585 msgid "" "When launching an application, specify *arguments* to be passed as a single " "string. This argument may have no effect when using this function to launch " "a document." msgstr "" -#: ../../library/os.rst:5166 +#: ../../library/os.rst:5589 msgid "" "The default working directory is inherited, but may be overridden by the " "*cwd* argument. This should be an absolute path. A relative *path* will be " "resolved against this argument." msgstr "" -#: ../../library/os.rst:5170 +#: ../../library/os.rst:5593 msgid "" "Use *show_cmd* to override the default window style. Whether this has any " "effect will depend on the application being launched. Values are integers as " "supported by the Win32 :c:func:`!ShellExecute` function." msgstr "" -#: ../../library/os.rst:5174 +#: ../../library/os.rst:5597 msgid "" ":func:`startfile` returns as soon as the associated application is launched. " "There is no option to wait for the application to close, and no way to " @@ -5798,14 +6142,14 @@ msgid "" "encoded for Win32." msgstr "" -#: ../../library/os.rst:5182 +#: ../../library/os.rst:5605 msgid "" "To reduce interpreter startup overhead, the Win32 :c:func:`!ShellExecute` " "function is not resolved until this function is first called. If the " "function cannot be resolved, :exc:`NotImplementedError` will be raised." msgstr "" -#: ../../library/os.rst:5186 +#: ../../library/os.rst:5609 msgid "" "Raises an :ref:`auditing event ` ``os.startfile`` with arguments " "``path``, ``operation``." @@ -5813,7 +6157,7 @@ msgstr "" "引發一個附帶引數 ``path``、``operation`` 的\\ :ref:`稽核事件 ` " "``os.startfile``。" -#: ../../library/os.rst:5188 +#: ../../library/os.rst:5611 msgid "" "Raises an :ref:`auditing event ` ``os.startfile/2`` with arguments " "``path``, ``operation``, ``arguments``, ``cwd``, ``show_cmd``." @@ -5821,13 +6165,13 @@ msgstr "" "引發一個附帶引數 ``path``、``operation``、``arguments``、``cwd``、" "``show_cmd`` 的\\ :ref:`稽核事件 ` ``os.startfile/2``。" -#: ../../library/os.rst:5192 +#: ../../library/os.rst:5615 msgid "" "Added the *arguments*, *cwd* and *show_cmd* arguments, and the ``os." "startfile/2`` audit event." msgstr "" -#: ../../library/os.rst:5199 +#: ../../library/os.rst:5622 msgid "" "Execute the command (a string) in a subshell. This is implemented by " "calling the Standard C function :c:func:`system`, and has the same " @@ -5838,13 +6182,13 @@ msgid "" "value of the Python function is system-dependent." msgstr "" -#: ../../library/os.rst:5207 +#: ../../library/os.rst:5630 msgid "" "On Unix, the return value is the exit status of the process encoded in the " "format specified for :func:`wait`." msgstr "" -#: ../../library/os.rst:5210 +#: ../../library/os.rst:5633 msgid "" "On Windows, the return value is that returned by the system shell after " "running *command*. The shell is given by the Windows environment variable :" @@ -5853,7 +6197,7 @@ msgid "" "shell documentation." msgstr "" -#: ../../library/os.rst:5216 +#: ../../library/os.rst:5639 msgid "" "The :mod:`subprocess` module provides more powerful facilities for spawning " "new processes and retrieving their results; using that module is recommended " @@ -5861,54 +6205,54 @@ msgid "" "the :mod:`subprocess` documentation for some helpful recipes." msgstr "" -#: ../../library/os.rst:5221 +#: ../../library/os.rst:5644 msgid "" "On Unix, :func:`waitstatus_to_exitcode` can be used to convert the result " "(exit status) into an exit code. On Windows, the result is directly the exit " "code." msgstr "" -#: ../../library/os.rst:5225 +#: ../../library/os.rst:5648 msgid "" "Raises an :ref:`auditing event ` ``os.system`` with argument " "``command``." msgstr "" "引發一個附帶引數 ``command`` 的\\ :ref:`稽核事件 ` ``os.system``。" -#: ../../library/os.rst:5232 +#: ../../library/os.rst:5655 msgid "" "Returns the current global process times. The return value is an object with " "five attributes:" msgstr "" -#: ../../library/os.rst:5235 +#: ../../library/os.rst:5658 msgid ":attr:`!user` - user time" msgstr ":attr:`!user` - 使用者時間" -#: ../../library/os.rst:5236 +#: ../../library/os.rst:5659 msgid ":attr:`!system` - system time" msgstr ":attr:`!system` - 系統時間" -#: ../../library/os.rst:5237 +#: ../../library/os.rst:5660 msgid ":attr:`!children_user` - user time of all child processes" msgstr ":attr:`!children_user` - 所有子行程的使用者時間" -#: ../../library/os.rst:5238 +#: ../../library/os.rst:5661 msgid ":attr:`!children_system` - system time of all child processes" msgstr ":attr:`!children_system` - 所有子行程的系統時間" -#: ../../library/os.rst:5239 +#: ../../library/os.rst:5662 msgid ":attr:`!elapsed` - elapsed real time since a fixed point in the past" msgstr "" -#: ../../library/os.rst:5241 +#: ../../library/os.rst:5664 msgid "" "For backwards compatibility, this object also behaves like a five-tuple " "containing :attr:`!user`, :attr:`!system`, :attr:`!children_user`, :attr:`!" "children_system`, and :attr:`!elapsed` in that order." msgstr "" -#: ../../library/os.rst:5245 +#: ../../library/os.rst:5668 msgid "" "See the Unix manual page :manpage:`times(2)` and `times(3) `_ manual page on Unix or `the " @@ -5918,7 +6262,7 @@ msgid "" "attributes are zero." msgstr "" -#: ../../library/os.rst:5259 +#: ../../library/os.rst:5682 msgid "" "Wait for completion of a child process, and return a tuple containing its " "pid and exit status indication: a 16-bit number, whose low byte is the " @@ -5927,87 +6271,87 @@ msgid "" "if a core file was produced." msgstr "" -#: ../../library/os.rst:5265 +#: ../../library/os.rst:5688 msgid "" "If there are no children that could be waited for, :exc:`ChildProcessError` " "is raised." msgstr "" -#: ../../library/os.rst:5268 ../../library/os.rst:5343 +#: ../../library/os.rst:5691 ../../library/os.rst:5766 msgid "" ":func:`waitstatus_to_exitcode` can be used to convert the exit status into " "an exit code." msgstr "" -#: ../../library/os.rst:5275 +#: ../../library/os.rst:5698 msgid "" "The other :func:`!wait*` functions documented below can be used to wait for " "the completion of a specific child process and have more options. :func:" "`waitpid` is the only one also available on Windows." msgstr "" -#: ../../library/os.rst:5282 +#: ../../library/os.rst:5705 msgid "Wait for the completion of a child process." msgstr "" -#: ../../library/os.rst:5284 +#: ../../library/os.rst:5707 msgid "" "*idtype* can be :data:`P_PID`, :data:`P_PGID`, :data:`P_ALL`, or (on Linux) :" "data:`P_PIDFD`. The interpretation of *id* depends on it; see their " "individual descriptions." msgstr "" -#: ../../library/os.rst:5287 +#: ../../library/os.rst:5710 msgid "" "*options* is an OR combination of flags. At least one of :data:`WEXITED`, :" "data:`WSTOPPED` or :data:`WCONTINUED` is required; :data:`WNOHANG` and :data:" "`WNOWAIT` are additional optional flags." msgstr "" -#: ../../library/os.rst:5291 +#: ../../library/os.rst:5714 msgid "" "The return value is an object representing the data contained in the :c:type:" "`siginfo_t` structure with the following attributes:" msgstr "" -#: ../../library/os.rst:5294 +#: ../../library/os.rst:5717 msgid ":attr:`!si_pid` (process ID)" msgstr "" -#: ../../library/os.rst:5295 +#: ../../library/os.rst:5718 msgid ":attr:`!si_uid` (real user ID of the child)" msgstr "" -#: ../../library/os.rst:5296 +#: ../../library/os.rst:5719 msgid ":attr:`!si_signo` (always :const:`~signal.SIGCHLD`)" msgstr "" -#: ../../library/os.rst:5297 +#: ../../library/os.rst:5720 msgid "" ":attr:`!si_status` (the exit status or signal number, depending on :attr:`!" "si_code`)" msgstr "" -#: ../../library/os.rst:5298 +#: ../../library/os.rst:5721 msgid ":attr:`!si_code` (see :data:`CLD_EXITED` for possible values)" msgstr "" -#: ../../library/os.rst:5300 +#: ../../library/os.rst:5723 msgid "" "If :data:`WNOHANG` is specified and there are no matching children in the " "requested state, ``None`` is returned. Otherwise, if there are no matching " "children that could be waited for, :exc:`ChildProcessError` is raised." msgstr "" -#: ../../library/os.rst:5309 +#: ../../library/os.rst:5732 msgid "This function is now available on macOS as well." msgstr "" -#: ../../library/os.rst:5315 +#: ../../library/os.rst:5738 msgid "The details of this function differ on Unix and Windows." msgstr "" -#: ../../library/os.rst:5317 +#: ../../library/os.rst:5740 msgid "" "On Unix: Wait for completion of a child process given by process id *pid*, " "and return a tuple containing its process id and exit status indication " @@ -6016,7 +6360,7 @@ msgid "" "operation." msgstr "" -#: ../../library/os.rst:5322 +#: ../../library/os.rst:5745 msgid "" "If *pid* is greater than ``0``, :func:`waitpid` requests status information " "for that specific process. If *pid* is ``0``, the request is for the status " @@ -6026,7 +6370,7 @@ msgid "" "group ``-pid`` (the absolute value of *pid*)." msgstr "" -#: ../../library/os.rst:5329 +#: ../../library/os.rst:5752 msgid "" "*options* is an OR combination of flags. If it contains :data:`WNOHANG` and " "there are no matching children in the requested state, ``(0, 0)`` is " @@ -6035,7 +6379,7 @@ msgid "" "are :data:`WUNTRACED` and :data:`WCONTINUED`." msgstr "" -#: ../../library/os.rst:5335 +#: ../../library/os.rst:5758 msgid "" "On Windows: Wait for completion of a process given by process handle *pid*, " "and return a tuple containing *pid*, and its exit status shifted left by 8 " @@ -6047,7 +6391,7 @@ msgid "" "process handles." msgstr "" -#: ../../library/os.rst:5356 +#: ../../library/os.rst:5779 msgid "" "Similar to :func:`waitpid`, except no process id argument is given and a 3-" "element tuple containing the child's process id, exit status indication, and " @@ -6056,13 +6400,13 @@ msgid "" "same as that provided to :func:`waitpid` and :func:`wait4`." msgstr "" -#: ../../library/os.rst:5363 ../../library/os.rst:5377 +#: ../../library/os.rst:5786 ../../library/os.rst:5800 msgid "" ":func:`waitstatus_to_exitcode` can be used to convert the exit status into " "an exitcode." msgstr "" -#: ../../library/os.rst:5371 +#: ../../library/os.rst:5794 msgid "" "Similar to :func:`waitpid`, except a 3-element tuple, containing the child's " "process id, exit status indication, and resource usage information is " @@ -6071,118 +6415,118 @@ msgid "" "to :func:`waitpid`." msgstr "" -#: ../../library/os.rst:5388 +#: ../../library/os.rst:5811 msgid "" "These are the possible values for *idtype* in :func:`waitid`. They affect " "how *id* is interpreted:" msgstr "" -#: ../../library/os.rst:5391 +#: ../../library/os.rst:5814 msgid ":data:`!P_PID` - wait for the child whose PID is *id*." msgstr "" -#: ../../library/os.rst:5392 +#: ../../library/os.rst:5815 msgid ":data:`!P_PGID` - wait for any child whose progress group ID is *id*." msgstr "" -#: ../../library/os.rst:5393 +#: ../../library/os.rst:5816 msgid ":data:`!P_ALL` - wait for any child; *id* is ignored." msgstr "" -#: ../../library/os.rst:5394 +#: ../../library/os.rst:5817 msgid "" ":data:`!P_PIDFD` - wait for the child identified by the file descriptor *id* " "(a process file descriptor created with :func:`pidfd_open`)." msgstr "" -#: ../../library/os.rst:5399 +#: ../../library/os.rst:5822 msgid ":data:`!P_PIDFD` is only available on Linux >= 5.4." msgstr "" -#: ../../library/os.rst:5402 +#: ../../library/os.rst:5825 msgid "The :data:`!P_PIDFD` constant." msgstr "" -#: ../../library/os.rst:5408 +#: ../../library/os.rst:5831 msgid "" "This *options* flag for :func:`waitpid`, :func:`wait3`, :func:`wait4`, and :" "func:`waitid` causes child processes to be reported if they have been " "continued from a job control stop since they were last reported." msgstr "" -#: ../../library/os.rst:5417 +#: ../../library/os.rst:5840 msgid "" "This *options* flag for :func:`waitid` causes child processes that have " "terminated to be reported." msgstr "" -#: ../../library/os.rst:5420 +#: ../../library/os.rst:5843 msgid "" "The other ``wait*`` functions always report children that have terminated, " "so this option is not available for them." msgstr "" -#: ../../library/os.rst:5430 +#: ../../library/os.rst:5853 msgid "" "This *options* flag for :func:`waitid` causes child processes that have been " "stopped by the delivery of a signal to be reported." msgstr "" -#: ../../library/os.rst:5433 ../../library/os.rst:5465 +#: ../../library/os.rst:5856 ../../library/os.rst:5888 msgid "This option is not available for the other ``wait*`` functions." msgstr "" -#: ../../library/os.rst:5442 +#: ../../library/os.rst:5865 msgid "" "This *options* flag for :func:`waitpid`, :func:`wait3`, and :func:`wait4` " "causes child processes to also be reported if they have been stopped but " "their current state has not been reported since they were stopped." msgstr "" -#: ../../library/os.rst:5446 +#: ../../library/os.rst:5869 msgid "This option is not available for :func:`waitid`." msgstr "" -#: ../../library/os.rst:5453 +#: ../../library/os.rst:5876 msgid "" "This *options* flag causes :func:`waitpid`, :func:`wait3`, :func:`wait4`, " "and :func:`waitid` to return right away if no child process status is " "available immediately." msgstr "" -#: ../../library/os.rst:5462 +#: ../../library/os.rst:5885 msgid "" "This *options* flag causes :func:`waitid` to leave the child in a waitable " "state, so that a later :func:`!wait*` call can be used to retrieve the child " "status information again." msgstr "" -#: ../../library/os.rst:5477 +#: ../../library/os.rst:5900 msgid "" "These are the possible values for :attr:`!si_code` in the result returned " "by :func:`waitid`." msgstr "" -#: ../../library/os.rst:5484 +#: ../../library/os.rst:5907 msgid "Added :data:`CLD_KILLED` and :data:`CLD_STOPPED` values." msgstr "新增 :data:`CLD_KILLED` 和 :data:`CLD_STOPPED` 值。" -#: ../../library/os.rst:5490 +#: ../../library/os.rst:5913 msgid "Convert a wait status to an exit code." msgstr "" -#: ../../library/os.rst:5492 +#: ../../library/os.rst:5915 msgid "On Unix:" msgstr "在 Unix 上:" -#: ../../library/os.rst:5494 +#: ../../library/os.rst:5917 msgid "" "If the process exited normally (if ``WIFEXITED(status)`` is true), return " "the process exit status (return ``WEXITSTATUS(status)``): result greater " "than or equal to 0." msgstr "" -#: ../../library/os.rst:5497 +#: ../../library/os.rst:5920 msgid "" "If the process was terminated by a signal (if ``WIFSIGNALED(status)`` is " "true), return ``-signum`` where *signum* is the number of the signal that " @@ -6190,15 +6534,15 @@ msgid "" "than 0." msgstr "" -#: ../../library/os.rst:5501 +#: ../../library/os.rst:5924 msgid "Otherwise, raise a :exc:`ValueError`." msgstr "否則,引發 :exc:`ValueError`。" -#: ../../library/os.rst:5503 +#: ../../library/os.rst:5926 msgid "On Windows, return *status* shifted right by 8 bits." msgstr "" -#: ../../library/os.rst:5505 +#: ../../library/os.rst:5928 msgid "" "On Unix, if the process is being traced or if :func:`waitpid` was called " "with :data:`WUNTRACED` option, the caller must first check if " @@ -6206,234 +6550,234 @@ msgid "" "``WIFSTOPPED(status)`` is true." msgstr "" -#: ../../library/os.rst:5512 +#: ../../library/os.rst:5935 msgid "" ":func:`WIFEXITED`, :func:`WEXITSTATUS`, :func:`WIFSIGNALED`, :func:" "`WTERMSIG`, :func:`WIFSTOPPED`, :func:`WSTOPSIG` functions." msgstr "" -#: ../../library/os.rst:5520 +#: ../../library/os.rst:5943 msgid "" "The following functions take a process status code as returned by :func:" "`system`, :func:`wait`, or :func:`waitpid` as a parameter. They may be used " "to determine the disposition of a process." msgstr "" -#: ../../library/os.rst:5526 +#: ../../library/os.rst:5949 msgid "" "Return ``True`` if a core dump was generated for the process, otherwise " "return ``False``." msgstr "" -#: ../../library/os.rst:5529 ../../library/os.rst:5595 +#: ../../library/os.rst:5952 ../../library/os.rst:6018 msgid "This function should be employed only if :func:`WIFSIGNALED` is true." msgstr "" -#: ../../library/os.rst:5536 +#: ../../library/os.rst:5959 msgid "" "Return ``True`` if a stopped child has been resumed by delivery of :const:" "`~signal.SIGCONT` (if the process has been continued from a job control " "stop), otherwise return ``False``." msgstr "" -#: ../../library/os.rst:5540 +#: ../../library/os.rst:5963 msgid "See :data:`WCONTINUED` option." msgstr "參閱 :data:`WCONTINUED` 選項。" -#: ../../library/os.rst:5547 +#: ../../library/os.rst:5970 msgid "" "Return ``True`` if the process was stopped by delivery of a signal, " "otherwise return ``False``." msgstr "" -#: ../../library/os.rst:5550 +#: ../../library/os.rst:5973 msgid "" ":func:`WIFSTOPPED` only returns ``True`` if the :func:`waitpid` call was " "done using :data:`WUNTRACED` option or when the process is being traced " "(see :manpage:`ptrace(2)`)." msgstr "" -#: ../../library/os.rst:5558 +#: ../../library/os.rst:5981 msgid "" "Return ``True`` if the process was terminated by a signal, otherwise return " "``False``." msgstr "" -#: ../../library/os.rst:5566 +#: ../../library/os.rst:5989 msgid "" "Return ``True`` if the process exited terminated normally, that is, by " "calling ``exit()`` or ``_exit()``, or by returning from ``main()``; " "otherwise return ``False``." msgstr "" -#: ../../library/os.rst:5575 +#: ../../library/os.rst:5998 msgid "Return the process exit status." msgstr "" -#: ../../library/os.rst:5577 +#: ../../library/os.rst:6000 msgid "This function should be employed only if :func:`WIFEXITED` is true." msgstr "" -#: ../../library/os.rst:5584 +#: ../../library/os.rst:6007 msgid "Return the signal which caused the process to stop." msgstr "" -#: ../../library/os.rst:5586 +#: ../../library/os.rst:6009 msgid "This function should be employed only if :func:`WIFSTOPPED` is true." msgstr "" -#: ../../library/os.rst:5593 +#: ../../library/os.rst:6016 msgid "Return the number of the signal that caused the process to terminate." msgstr "" -#: ../../library/os.rst:5601 +#: ../../library/os.rst:6024 msgid "Interface to the scheduler" msgstr "排程器介面" -#: ../../library/os.rst:5603 +#: ../../library/os.rst:6026 msgid "" "These functions control how a process is allocated CPU time by the operating " "system. They are only available on some Unix platforms. For more detailed " "information, consult your Unix manpages." msgstr "" -#: ../../library/os.rst:5609 +#: ../../library/os.rst:6032 msgid "" "The following scheduling policies are exposed if they are supported by the " "operating system." msgstr "" -#: ../../library/os.rst:5616 +#: ../../library/os.rst:6039 msgid "The default scheduling policy." msgstr "" -#: ../../library/os.rst:5620 +#: ../../library/os.rst:6043 msgid "" "Scheduling policy for CPU-intensive processes that tries to preserve " "interactivity on the rest of the computer." msgstr "" -#: ../../library/os.rst:5625 +#: ../../library/os.rst:6048 msgid "Scheduling policy for tasks with deadline constraints." msgstr "" -#: ../../library/os.rst:5631 +#: ../../library/os.rst:6054 msgid "Scheduling policy for extremely low priority background tasks." msgstr "" -#: ../../library/os.rst:5635 +#: ../../library/os.rst:6058 msgid "Alias for :data:`SCHED_OTHER`." msgstr ":data:`SCHED_OTHER` 的別名。" -#: ../../library/os.rst:5641 +#: ../../library/os.rst:6064 msgid "Scheduling policy for sporadic server programs." msgstr "" -#: ../../library/os.rst:5645 +#: ../../library/os.rst:6068 msgid "A First In First Out scheduling policy." msgstr "先進先出排程策略。" -#: ../../library/os.rst:5649 +#: ../../library/os.rst:6072 msgid "A round-robin scheduling policy." msgstr "輪轉排程策略。" -#: ../../library/os.rst:5653 +#: ../../library/os.rst:6076 msgid "" "This flag can be OR'ed with any other scheduling policy. When a process with " "this flag set forks, its child's scheduling policy and priority are reset to " "the default." msgstr "" -#: ../../library/os.rst:5660 +#: ../../library/os.rst:6083 msgid "" "This class represents tunable scheduling parameters used in :func:" "`sched_setparam`, :func:`sched_setscheduler`, and :func:`sched_getparam`. It " "is immutable." msgstr "" -#: ../../library/os.rst:5664 +#: ../../library/os.rst:6087 msgid "At the moment, there is only one possible parameter:" msgstr "" -#: ../../library/os.rst:5668 +#: ../../library/os.rst:6091 msgid "The scheduling priority for a scheduling policy." msgstr "" -#: ../../library/os.rst:5673 +#: ../../library/os.rst:6096 msgid "" "Get the minimum priority value for *policy*. *policy* is one of the " "scheduling policy constants above." msgstr "" -#: ../../library/os.rst:5679 +#: ../../library/os.rst:6102 msgid "" "Get the maximum priority value for *policy*. *policy* is one of the " "scheduling policy constants above." msgstr "" -#: ../../library/os.rst:5685 +#: ../../library/os.rst:6108 msgid "" "Set the scheduling policy for the process with PID *pid*. A *pid* of 0 means " "the calling process. *policy* is one of the scheduling policy constants " "above. *param* is a :class:`sched_param` instance." msgstr "" -#: ../../library/os.rst:5692 +#: ../../library/os.rst:6115 msgid "" "Return the scheduling policy for the process with PID *pid*. A *pid* of 0 " "means the calling process. The result is one of the scheduling policy " "constants above." msgstr "" -#: ../../library/os.rst:5699 +#: ../../library/os.rst:6122 msgid "" "Set the scheduling parameters for the process with PID *pid*. A *pid* of 0 " "means the calling process. *param* is a :class:`sched_param` instance." msgstr "" -#: ../../library/os.rst:5705 +#: ../../library/os.rst:6128 msgid "" "Return the scheduling parameters as a :class:`sched_param` instance for the " "process with PID *pid*. A *pid* of 0 means the calling process." msgstr "" -#: ../../library/os.rst:5711 +#: ../../library/os.rst:6134 msgid "" "Return the round-robin quantum in seconds for the process with PID *pid*. A " "*pid* of 0 means the calling process." msgstr "" -#: ../../library/os.rst:5717 +#: ../../library/os.rst:6140 msgid "" "Voluntarily relinquish the CPU. See :manpage:`sched_yield(2)` for details." msgstr "" -#: ../../library/os.rst:5722 +#: ../../library/os.rst:6145 msgid "" "Restrict the process with PID *pid* (or the current process if zero) to a " "set of CPUs. *mask* is an iterable of integers representing the set of CPUs " "to which the process should be restricted." msgstr "" -#: ../../library/os.rst:5729 +#: ../../library/os.rst:6152 msgid "Return the set of CPUs the process with PID *pid* is restricted to." msgstr "" -#: ../../library/os.rst:5731 +#: ../../library/os.rst:6154 msgid "" "If *pid* is zero, return the set of CPUs the calling thread of the current " "process is restricted to." msgstr "" -#: ../../library/os.rst:5734 +#: ../../library/os.rst:6157 msgid "See also the :func:`process_cpu_count` function." msgstr "也請見 :func:`process_cpu_count` 函式。" -#: ../../library/os.rst:5740 +#: ../../library/os.rst:6163 msgid "Miscellaneous System Information" msgstr "" -#: ../../library/os.rst:5745 +#: ../../library/os.rst:6168 msgid "" "Return string-valued system configuration values. *name* specifies the " "configuration value to retrieve; it may be a string which is the name of a " @@ -6444,13 +6788,13 @@ msgid "" "included in that mapping, passing an integer for *name* is also accepted." msgstr "" -#: ../../library/os.rst:5753 +#: ../../library/os.rst:6176 msgid "" "If the configuration value specified by *name* isn't defined, ``None`` is " "returned." msgstr "" -#: ../../library/os.rst:5756 +#: ../../library/os.rst:6179 msgid "" "If *name* is a string and is not known, :exc:`ValueError` is raised. If a " "specific value for *name* is not supported by the host system, even if it is " @@ -6458,62 +6802,62 @@ msgid "" "`errno.EINVAL` for the error number." msgstr "" -#: ../../library/os.rst:5766 +#: ../../library/os.rst:6189 msgid "" "Dictionary mapping names accepted by :func:`confstr` to the integer values " "defined for those names by the host operating system. This can be used to " "determine the set of names known to the system." msgstr "" -#: ../../library/os.rst:5775 +#: ../../library/os.rst:6198 msgid "" "Return the number of logical CPUs in the **system**. Returns ``None`` if " "undetermined." msgstr "" -#: ../../library/os.rst:5778 +#: ../../library/os.rst:6201 msgid "" "The :func:`process_cpu_count` function can be used to get the number of " "logical CPUs usable by the calling thread of the **current process**." msgstr "" -#: ../../library/os.rst:5783 +#: ../../library/os.rst:6206 msgid "" "If :option:`-X cpu_count <-X>` is given or :envvar:`PYTHON_CPU_COUNT` is " "set, :func:`cpu_count` returns the override value *n*." msgstr "" -#: ../../library/os.rst:5790 +#: ../../library/os.rst:6213 msgid "" "Return the number of processes in the system run queue averaged over the " "last 1, 5, and 15 minutes or raises :exc:`OSError` if the load average was " "unobtainable." msgstr "" -#: ../../library/os.rst:5799 +#: ../../library/os.rst:6222 msgid "" "Get the number of logical CPUs usable by the calling thread of the **current " "process**. Returns ``None`` if undetermined. It can be less than :func:" "`cpu_count` depending on the CPU affinity." msgstr "" -#: ../../library/os.rst:5803 +#: ../../library/os.rst:6226 msgid "" "The :func:`cpu_count` function can be used to get the number of logical CPUs " "in the **system**." msgstr "" -#: ../../library/os.rst:5806 +#: ../../library/os.rst:6229 msgid "" "If :option:`-X cpu_count <-X>` is given or :envvar:`PYTHON_CPU_COUNT` is " "set, :func:`process_cpu_count` returns the override value *n*." msgstr "" -#: ../../library/os.rst:5809 +#: ../../library/os.rst:6232 msgid "See also the :func:`sched_getaffinity` function." msgstr "也請見 :func:`sched_getaffinity` 函式。" -#: ../../library/os.rst:5816 +#: ../../library/os.rst:6239 msgid "" "Return integer-valued system configuration values. If the configuration " "value specified by *name* isn't defined, ``-1`` is returned. The comments " @@ -6522,44 +6866,44 @@ msgid "" "``sysconf_names``." msgstr "" -#: ../../library/os.rst:5826 +#: ../../library/os.rst:6249 msgid "" "Dictionary mapping names accepted by :func:`sysconf` to the integer values " "defined for those names by the host operating system. This can be used to " "determine the set of names known to the system." msgstr "" -#: ../../library/os.rst:5832 +#: ../../library/os.rst:6255 msgid "Add ``'SC_MINSIGSTKSZ'`` name." msgstr "新增 ``'SC_MINSIGSTKSZ'`` 名稱。" -#: ../../library/os.rst:5835 +#: ../../library/os.rst:6258 msgid "" "The following data values are used to support path manipulation operations. " "These are defined for all platforms." msgstr "" -#: ../../library/os.rst:5838 +#: ../../library/os.rst:6261 msgid "" "Higher-level operations on pathnames are defined in the :mod:`os.path` " "module." msgstr "" -#: ../../library/os.rst:5844 +#: ../../library/os.rst:6267 msgid "" "The constant string used by the operating system to refer to the current " "directory. This is ``'.'`` for Windows and POSIX. Also available via :mod:" "`os.path`." msgstr "" -#: ../../library/os.rst:5852 +#: ../../library/os.rst:6275 msgid "" "The constant string used by the operating system to refer to the parent " "directory. This is ``'..'`` for Windows and POSIX. Also available via :mod:" "`os.path`." msgstr "" -#: ../../library/os.rst:5861 +#: ../../library/os.rst:6284 msgid "" "The character used by the operating system to separate pathname components. " "This is ``'/'`` for POSIX and ``'\\\\'`` for Windows. Note that knowing " @@ -6568,7 +6912,7 @@ msgid "" "useful. Also available via :mod:`os.path`." msgstr "" -#: ../../library/os.rst:5871 +#: ../../library/os.rst:6294 msgid "" "An alternative character used by the operating system to separate pathname " "components, or ``None`` if only one separator character exists. This is set " @@ -6576,27 +6920,27 @@ msgid "" "via :mod:`os.path`." msgstr "" -#: ../../library/os.rst:5880 +#: ../../library/os.rst:6303 msgid "" "The character which separates the base filename from the extension; for " "example, the ``'.'`` in :file:`os.py`. Also available via :mod:`os.path`." msgstr "" -#: ../../library/os.rst:5888 +#: ../../library/os.rst:6311 msgid "" "The character conventionally used by the operating system to separate search " "path components (as in :envvar:`PATH`), such as ``':'`` for POSIX or ``';'`` " "for Windows. Also available via :mod:`os.path`." msgstr "" -#: ../../library/os.rst:5895 +#: ../../library/os.rst:6318 msgid "" "The default search path used by :func:`exec\\*p\\* ` and :func:" "`spawn\\*p\\* ` if the environment doesn't have a ``'PATH'`` key. " "Also available via :mod:`os.path`." msgstr "" -#: ../../library/os.rst:5902 +#: ../../library/os.rst:6325 msgid "" "The string used to separate (or, rather, terminate) lines on the current " "platform. This may be a single character, such as ``'\\n'`` for POSIX, or " @@ -6605,36 +6949,36 @@ msgid "" "default); use a single ``'\\n'`` instead, on all platforms." msgstr "" -#: ../../library/os.rst:5911 +#: ../../library/os.rst:6334 msgid "" "The file path of the null device. For example: ``'/dev/null'`` for POSIX, " "``'nul'`` for Windows. Also available via :mod:`os.path`." msgstr "" -#: ../../library/os.rst:5922 +#: ../../library/os.rst:6345 msgid "" "Flags for use with the :func:`~sys.setdlopenflags` and :func:`~sys." "getdlopenflags` functions. See the Unix manual page :manpage:`dlopen(3)` " "for what the different flags mean." msgstr "" -#: ../../library/os.rst:5930 +#: ../../library/os.rst:6353 msgid "Random numbers" msgstr "" -#: ../../library/os.rst:5935 +#: ../../library/os.rst:6358 msgid "" "Get up to *size* random bytes. The function can return less bytes than " "requested." msgstr "" -#: ../../library/os.rst:5938 +#: ../../library/os.rst:6361 msgid "" "These bytes can be used to seed user-space random number generators or for " "cryptographic purposes." msgstr "" -#: ../../library/os.rst:5941 +#: ../../library/os.rst:6364 msgid "" "``getrandom()`` relies on entropy gathered from device drivers and other " "sources of environmental noise. Unnecessarily reading large quantities of " @@ -6642,32 +6986,32 @@ msgid "" "``/dev/urandom`` devices." msgstr "" -#: ../../library/os.rst:5946 +#: ../../library/os.rst:6369 msgid "" "The flags argument is a bit mask that can contain zero or more of the " "following values ORed together: :py:const:`os.GRND_RANDOM` and :py:data:" "`GRND_NONBLOCK`." msgstr "" -#: ../../library/os.rst:5950 +#: ../../library/os.rst:6373 msgid "" "See also the `Linux getrandom() manual page `_." msgstr "" -#: ../../library/os.rst:5959 +#: ../../library/os.rst:6382 msgid "" "Return a bytestring of *size* random bytes suitable for cryptographic use." msgstr "" -#: ../../library/os.rst:5961 +#: ../../library/os.rst:6384 msgid "" "This function returns random bytes from an OS-specific randomness source. " "The returned data should be unpredictable enough for cryptographic " "applications, though its exact quality depends on the OS implementation." msgstr "" -#: ../../library/os.rst:5965 +#: ../../library/os.rst:6388 msgid "" "On Linux, if the ``getrandom()`` syscall is available, it is used in " "blocking mode: block until the system urandom entropy pool is initialized " @@ -6677,210 +7021,216 @@ msgid "" "to poll until the system urandom entropy pool is initialized." msgstr "" -#: ../../library/os.rst:5972 +#: ../../library/os.rst:6395 msgid "" "On a Unix-like system, random bytes are read from the ``/dev/urandom`` " "device. If the ``/dev/urandom`` device is not available or not readable, " "the :exc:`NotImplementedError` exception is raised." msgstr "" -#: ../../library/os.rst:5976 +#: ../../library/os.rst:6399 msgid "On Windows, it will use ``BCryptGenRandom()``." msgstr "" -#: ../../library/os.rst:5979 +#: ../../library/os.rst:6402 msgid "" "The :mod:`secrets` module provides higher level functions. For an easy-to-" "use interface to the random number generator provided by your platform, " "please see :class:`random.SystemRandom`." msgstr "" -#: ../../library/os.rst:5983 +#: ../../library/os.rst:6406 msgid "" "On Linux 3.17 and newer, the ``getrandom()`` syscall is now used when " "available. On OpenBSD 5.6 and newer, the C ``getentropy()`` function is now " "used. These functions avoid the usage of an internal file descriptor." msgstr "" -#: ../../library/os.rst:5989 +#: ../../library/os.rst:6412 msgid "" "On Linux, if the ``getrandom()`` syscall blocks (the urandom entropy pool is " "not initialized yet), fall back on reading ``/dev/urandom``." msgstr "" -#: ../../library/os.rst:5993 +#: ../../library/os.rst:6416 msgid "" "On Linux, ``getrandom()`` is now used in blocking mode to increase the " "security." msgstr "" -#: ../../library/os.rst:5997 +#: ../../library/os.rst:6420 msgid "" "On Windows, ``BCryptGenRandom()`` is used instead of ``CryptGenRandom()`` " "which is deprecated." msgstr "" -#: ../../library/os.rst:6003 +#: ../../library/os.rst:6426 msgid "" "By default, when reading from ``/dev/random``, :func:`getrandom` blocks if " "no random bytes are available, and when reading from ``/dev/urandom``, it " "blocks if the entropy pool has not yet been initialized." msgstr "" -#: ../../library/os.rst:6007 +#: ../../library/os.rst:6430 msgid "" "If the :py:data:`GRND_NONBLOCK` flag is set, then :func:`getrandom` does not " "block in these cases, but instead immediately raises :exc:`BlockingIOError`." msgstr "" -#: ../../library/os.rst:6014 +#: ../../library/os.rst:6437 msgid "" "If this bit is set, then random bytes are drawn from the ``/dev/" "random`` pool instead of the ``/dev/urandom`` pool." msgstr "" -#: ../../library/os.rst:386 ../../library/os.rst:552 ../../library/os.rst:756 +#: ../../library/os.rst:395 ../../library/os.rst:561 ../../library/os.rst:765 msgid "user" msgstr "user(使用者)" -#: ../../library/os.rst:386 +#: ../../library/os.rst:395 msgid "effective id" msgstr "" -#: ../../library/os.rst:395 ../../library/os.rst:461 ../../library/os.rst:470 -#: ../../library/os.rst:479 ../../library/os.rst:493 ../../library/os.rst:691 -#: ../../library/os.rst:4768 ../../library/os.rst:4794 +#: ../../library/os.rst:404 ../../library/os.rst:470 ../../library/os.rst:479 +#: ../../library/os.rst:488 ../../library/os.rst:502 ../../library/os.rst:700 +#: ../../library/os.rst:5191 ../../library/os.rst:5217 msgid "process" msgstr "process" -#: ../../library/os.rst:395 ../../library/os.rst:461 +#: ../../library/os.rst:404 ../../library/os.rst:470 msgid "group" msgstr "group(群組)" -#: ../../library/os.rst:470 ../../library/os.rst:552 +#: ../../library/os.rst:479 ../../library/os.rst:561 msgid "id" msgstr "id" -#: ../../library/os.rst:479 +#: ../../library/os.rst:488 msgid "id of parent" msgstr "" -#: ../../library/os.rst:493 ../../library/os.rst:691 +#: ../../library/os.rst:502 ../../library/os.rst:700 msgid "scheduling priority" msgstr "scheduling priority(排程優先權)" -#: ../../library/os.rst:575 ../../library/os.rst:851 +#: ../../library/os.rst:584 ../../library/os.rst:860 msgid "environment variables" msgstr "environment variables(環境變數)" -#: ../../library/os.rst:575 +#: ../../library/os.rst:584 msgid "setting" msgstr "setting(設定)" -#: ../../library/os.rst:756 +#: ../../library/os.rst:765 msgid "id, setting" msgstr "id, setting(設定)" -#: ../../library/os.rst:789 +#: ../../library/os.rst:798 msgid "gethostname() (in module socket)" msgstr "gethostname()(於 socket 模組)" -#: ../../library/os.rst:789 +#: ../../library/os.rst:798 msgid "gethostbyaddr() (in module socket)" msgstr "gethostbyaddr()(於 socket 模組)" -#: ../../library/os.rst:851 ../../library/os.rst:2760 +#: ../../library/os.rst:860 ../../library/os.rst:2813 msgid "deleting" msgstr "deleting(刪除)" -#: ../../library/os.rst:1409 ../../library/os.rst:3144 +#: ../../library/os.rst:1418 ../../library/os.rst:3201 msgid "module" msgstr "module(模組)" -#: ../../library/os.rst:1409 +#: ../../library/os.rst:1418 msgid "pty" msgstr "pty" -#: ../../library/os.rst:2141 ../../library/os.rst:2559 -#: ../../library/os.rst:2760 ../../library/os.rst:3807 -#: ../../library/os.rst:3907 +#: ../../library/os.rst:2171 ../../library/os.rst:2594 +#: ../../library/os.rst:2813 ../../library/os.rst:4221 +#: ../../library/os.rst:4321 msgid "directory" msgstr "directory(目錄)" -#: ../../library/os.rst:2141 +#: ../../library/os.rst:2171 msgid "changing" msgstr "changing(改變)" -#: ../../library/os.rst:2559 +#: ../../library/os.rst:2594 msgid "creating" msgstr "creating(建立)" -#: ../../library/os.rst:2559 +#: ../../library/os.rst:2594 msgid "UNC paths" msgstr "UNC paths(UNC 路徑)" -#: ../../library/os.rst:2559 +#: ../../library/os.rst:2594 msgid "and os.makedirs()" msgstr "以及 os.makedirs()" -#: ../../library/os.rst:3144 +#: ../../library/os.rst:3201 msgid "stat" msgstr "stat" -#: ../../library/os.rst:3807 ../../library/os.rst:3907 +#: ../../library/os.rst:4221 ../../library/os.rst:4321 msgid "walking" msgstr "" -#: ../../library/os.rst:3807 ../../library/os.rst:3907 +#: ../../library/os.rst:4221 ../../library/os.rst:4321 msgid "traversal" msgstr "traversal(遍歷)" -#: ../../library/os.rst:4768 ../../library/os.rst:4794 +#: ../../library/os.rst:5191 ../../library/os.rst:5217 msgid "killing" msgstr "" -#: ../../library/os.rst:4768 ../../library/os.rst:4794 +#: ../../library/os.rst:5191 ../../library/os.rst:5217 msgid "signalling" msgstr "signalling(信號)" -#: ../../library/os.rst:5841 ../../library/os.rst:5877 +#: ../../library/os.rst:6264 ../../library/os.rst:6300 msgid ". (dot)" msgstr ". (點)" -#: ../../library/os.rst:5841 ../../library/os.rst:5849 -#: ../../library/os.rst:5857 ../../library/os.rst:5868 -#: ../../library/os.rst:5877 +#: ../../library/os.rst:6264 ../../library/os.rst:6272 +#: ../../library/os.rst:6280 ../../library/os.rst:6291 +#: ../../library/os.rst:6300 msgid "in pathnames" msgstr "於 pathnames(路徑名稱)中" -#: ../../library/os.rst:5849 +#: ../../library/os.rst:6272 msgid ".." msgstr ".." -#: ../../library/os.rst:5857 ../../library/os.rst:5868 +#: ../../library/os.rst:6280 ../../library/os.rst:6291 msgid "/ (slash)" msgstr "/ (斜線)" -#: ../../library/os.rst:5858 +#: ../../library/os.rst:6281 msgid "\\ (backslash)" msgstr "\\ (反斜線)" -#: ../../library/os.rst:5858 +#: ../../library/os.rst:6281 msgid "in pathnames (Windows)" msgstr "in pathnames (Windows)(在路徑名稱中 (Windows))" -#: ../../library/os.rst:5884 +#: ../../library/os.rst:6307 msgid ": (colon)" msgstr ": (冒號)" -#: ../../library/os.rst:5884 +#: ../../library/os.rst:6307 msgid "path separator (POSIX)" msgstr "path separator (POSIX)(路徑分隔器 (POSIX))" -#: ../../library/os.rst:5884 +#: ../../library/os.rst:6307 msgid "; (semicolon)" msgstr "; (分號)" +#~ msgid ":pep:`686`" +#~ msgstr ":pep:`686`" + +#~ msgid "Python 3.15 will make :ref:`utf8-mode` default." +#~ msgstr "Python 3.15 預設使用 :ref:`utf8-mode`" + #~ msgid "The :const:`ST_RDONLY` and :const:`ST_NOSUID` constants were added." #~ msgstr "新增 :const:`ST_RDONLY` 與 :const:`ST_NOSUID` 常數。" diff --git a/library/pathlib.po b/library/pathlib.po index 21d426325b6..de11de7def9 100644 --- a/library/pathlib.po +++ b/library/pathlib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-23 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-12-23 19:15+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -373,8 +373,8 @@ msgstr "" "PurePosixPath('/etc/hosts')" #: ../../library/pathlib.rst:185 ../../library/pathlib.rst:197 -#: ../../library/pathlib.rst:784 ../../library/pathlib.rst:794 -#: ../../library/pathlib.rst:809 +#: ../../library/pathlib.rst:770 ../../library/pathlib.rst:780 +#: ../../library/pathlib.rst:795 msgid "*pathsegments* is specified similarly to :class:`PurePath`." msgstr "*pathsegments* 的指定方式與 :class:`PurePath` 類似。" @@ -1021,37 +1021,11 @@ msgstr "額外引數的傳入已棄用;如果有的話,它們會與 *other* #: ../../library/pathlib.rst:552 msgid "" -"With :class:`PureWindowsPath`, return ``True`` if the path is considered " -"reserved under Windows, ``False`` otherwise. With :class:`PurePosixPath`, " -"``False`` is always returned." -msgstr "" -"對 :class:`PureWindowsPath` 來說,當路徑在 Windows 下被視為保留的話會回傳 " -"``True``,否則回傳 ``False``。對 :class:`PurePosixPath` 來說,總是回傳 " -"``False``。" - -#: ../../library/pathlib.rst:556 -msgid "" -"Windows path names that contain a colon, or end with a dot or a space, are " -"considered reserved. UNC paths may be reserved." -msgstr "" -"Windows 路徑名稱中包含冒號或結尾為點或空格會被視為保留。UNC 路徑可能被視為保" -"留。" - -#: ../../library/pathlib.rst:560 -msgid "" -"This method is deprecated; use :func:`os.path.isreserved` to detect reserved " -"paths on Windows." -msgstr "" -"此方法已被棄用;請使用 :func:`os.path.isreserved` 來檢測 Windows 上的保留路" -"徑。" - -#: ../../library/pathlib.rst:566 -msgid "" "Calling this method is equivalent to combining the path with each of the " "given *pathsegments* in turn::" msgstr "呼叫此方法會依序結合每個所給定的 *pathsegments* 到路徑上: ::" -#: ../../library/pathlib.rst:569 +#: ../../library/pathlib.rst:555 msgid "" ">>> PurePosixPath('/etc').joinpath('passwd')\n" "PurePosixPath('/etc/passwd')\n" @@ -1071,7 +1045,7 @@ msgstr "" ">>> PureWindowsPath('c:').joinpath('/Program Files')\n" "PureWindowsPath('c:/Program Files')" -#: ../../library/pathlib.rst:581 +#: ../../library/pathlib.rst:567 msgid "" "Match this path against the provided glob-style pattern. Return ``True`` if " "matching is successful, ``False`` otherwise. For example::" @@ -1079,7 +1053,7 @@ msgstr "" "將路徑與 glob 形式的模式 (glob-style pattern) 做比對。如果比對成功則回傳 " "``True``,否則回傳 ``False``,例如: ::" -#: ../../library/pathlib.rst:584 +#: ../../library/pathlib.rst:570 msgid "" ">>> PurePath('a/b.py').full_match('a/*.py')\n" "True\n" @@ -1099,15 +1073,15 @@ msgstr "" ">>> PurePath('/a/b/c.py').full_match('**/*.py')\n" "True" -#: ../../library/pathlib.rst:594 ../../library/pathlib.rst:1360 +#: ../../library/pathlib.rst:580 ../../library/pathlib.rst:1346 msgid ":ref:`pathlib-pattern-language` documentation." msgstr ":ref:`pathlib-pattern-language` 文件。" -#: ../../library/pathlib.rst:596 +#: ../../library/pathlib.rst:582 msgid "As with other methods, case-sensitivity follows platform defaults::" msgstr "像其它方法一樣,是否區分大小寫會遵循平台的預設行為: ::" -#: ../../library/pathlib.rst:598 +#: ../../library/pathlib.rst:584 msgid "" ">>> PurePosixPath('b.py').full_match('*.PY')\n" "False\n" @@ -1119,12 +1093,12 @@ msgstr "" ">>> PureWindowsPath('b.py').full_match('*.PY')\n" "True" -#: ../../library/pathlib.rst:603 +#: ../../library/pathlib.rst:589 msgid "" "Set *case_sensitive* to ``True`` or ``False`` to override this behaviour." msgstr "將 *case_sensitive* 設定成 ``True`` 或 ``False`` 會覆蓋這個行為。" -#: ../../library/pathlib.rst:610 +#: ../../library/pathlib.rst:596 msgid "" "Match this path against the provided non-recursive glob-style pattern. " "Return ``True`` if matching is successful, ``False`` otherwise." @@ -1132,7 +1106,7 @@ msgstr "" "將路徑與非遞迴 glob 形式的模式 (glob-style pattern) 做比對。如果比對成功則回" "傳 ``True``,否則回傳 ``False``。" -#: ../../library/pathlib.rst:613 +#: ../../library/pathlib.rst:599 msgid "" "This method is similar to :meth:`~PurePath.full_match`, but empty patterns " "aren't allowed (:exc:`ValueError` is raised), the recursive wildcard " @@ -1143,7 +1117,7 @@ msgstr "" "`ValueError`)、不支援遞迴萬用字元 \"``**``\"(它會像非遞迴的 \"``*``\" 一" "樣),且如果提供相對模式,則會從右邊進行比對: ::" -#: ../../library/pathlib.rst:618 +#: ../../library/pathlib.rst:604 msgid "" ">>> PurePath('a/b.py').match('*.py')\n" "True\n" @@ -1159,17 +1133,17 @@ msgstr "" ">>> PurePath('/a/b/c.py').match('a/*.py')\n" "False" -#: ../../library/pathlib.rst:625 ../../library/pathlib.rst:1384 -#: ../../library/pathlib.rst:1418 +#: ../../library/pathlib.rst:611 ../../library/pathlib.rst:1370 +#: ../../library/pathlib.rst:1404 msgid "The *pattern* parameter accepts a :term:`path-like object`." msgstr "*pattern* 參數接受\\ :term:`類路徑物件 `。" -#: ../../library/pathlib.rst:628 ../../library/pathlib.rst:1378 -#: ../../library/pathlib.rst:1412 +#: ../../library/pathlib.rst:614 ../../library/pathlib.rst:1364 +#: ../../library/pathlib.rst:1398 msgid "The *case_sensitive* parameter was added." msgstr "新增 *case_sensitive* 參數。" -#: ../../library/pathlib.rst:634 +#: ../../library/pathlib.rst:620 msgid "" "Compute a version of this path relative to the path represented by *other*. " "If it's impossible, :exc:`ValueError` is raised::" @@ -1177,7 +1151,7 @@ msgstr "" "計算這個路徑相對於 *other* 所表示路徑的版本。如果做不到會引發 :exc:" "`ValueError`: ::" -#: ../../library/pathlib.rst:637 +#: ../../library/pathlib.rst:623 msgid "" ">>> p = PurePosixPath('/etc/passwd')\n" ">>> p.relative_to('/')\n" @@ -1205,7 +1179,7 @@ msgstr "" "ValueError: '/etc/passwd' is not in the subpath of '/usr' OR one path is " "relative and the other is absolute." -#: ../../library/pathlib.rst:649 +#: ../../library/pathlib.rst:635 msgid "" "When *walk_up* is false (the default), the path must start with *other*. " "When the argument is true, ``..`` entries may be added to form the relative " @@ -1216,7 +1190,7 @@ msgstr "" "可能會加入 ``..`` 以組成相對路徑。在其他情況下,例如路徑參考到不同的磁碟機," "則會引發 :exc:`ValueError`: ::" -#: ../../library/pathlib.rst:654 +#: ../../library/pathlib.rst:640 msgid "" ">>> p.relative_to('/usr', walk_up=True)\n" "PurePosixPath('../etc/passwd')\n" @@ -1238,7 +1212,7 @@ msgstr "" "ValueError: '/etc/passwd' is not on the same drive as 'foo' OR one path is " "relative and the other is absolute." -#: ../../library/pathlib.rst:664 +#: ../../library/pathlib.rst:650 msgid "" "This function is part of :class:`PurePath` and works with strings. It does " "not check or access the underlying file structure. This can impact the " @@ -1249,19 +1223,19 @@ msgstr "" "的檔案架構。這會影響到 *walk_up* 選項,因為它假設路徑中沒有符號連結;如果需要" "解析符號連結的話可以先呼叫 :meth:`~Path.resolve`。" -#: ../../library/pathlib.rst:670 +#: ../../library/pathlib.rst:656 msgid "" "The *walk_up* parameter was added (old behavior is the same as " "``walk_up=False``)." msgstr "加入 *walk_up* 參數(舊的行為和 ``walk_up=False`` 相同)。" -#: ../../library/pathlib.rst:675 +#: ../../library/pathlib.rst:661 msgid "" "Passing additional positional arguments is deprecated; if supplied, they are " "joined with *other*." msgstr "額外位置引數的傳入已棄用;如果有的話,它們會與 *other* 連接在一起。" -#: ../../library/pathlib.rst:680 +#: ../../library/pathlib.rst:666 msgid "" "Return a new path with the :attr:`name` changed. If the original path " "doesn't have a name, ValueError is raised::" @@ -1269,7 +1243,7 @@ msgstr "" "回傳一個修改 :attr:`name` 後的新路徑。如果原始路徑沒有名稱則引發 " "ValueError: ::" -#: ../../library/pathlib.rst:683 +#: ../../library/pathlib.rst:669 msgid "" ">>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')\n" ">>> p.with_name('setup.py')\n" @@ -1295,7 +1269,7 @@ msgstr "" " raise ValueError(\"%r has an empty name\" % (self,))\n" "ValueError: PureWindowsPath('c:/') has an empty name" -#: ../../library/pathlib.rst:697 +#: ../../library/pathlib.rst:683 msgid "" "Return a new path with the :attr:`stem` changed. If the original path " "doesn't have a name, ValueError is raised::" @@ -1303,7 +1277,7 @@ msgstr "" "回傳一個修改 :attr:`stem` 後的新路徑。如果原始路徑沒有名稱則引發 " "ValueError: ::" -#: ../../library/pathlib.rst:700 +#: ../../library/pathlib.rst:686 msgid "" ">>> p = PureWindowsPath('c:/Downloads/draft.txt')\n" ">>> p.with_stem('final')\n" @@ -1341,7 +1315,7 @@ msgstr "" " raise ValueError(\"%r has an empty name\" % (self,))\n" "ValueError: PureWindowsPath('c:/') has an empty name" -#: ../../library/pathlib.rst:721 +#: ../../library/pathlib.rst:707 msgid "" "Return a new path with the :attr:`suffix` changed. If the original path " "doesn't have a suffix, the new *suffix* is appended instead. If the " @@ -1350,7 +1324,7 @@ msgstr "" "回傳一個修改 :attr:`suffix` 後的新路徑。如果原始路徑沒有後綴,新的 *suffix* " "會附加在後面。如果 *suffix* 是一個空字串,原來的後綴會被移除: ::" -#: ../../library/pathlib.rst:725 +#: ../../library/pathlib.rst:711 msgid "" ">>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')\n" ">>> p.with_suffix('.bz2')\n" @@ -1372,13 +1346,13 @@ msgstr "" ">>> p.with_suffix('')\n" "PureWindowsPath('README')" -#: ../../library/pathlib.rst:737 +#: ../../library/pathlib.rst:723 msgid "" "A single dot (\"``.``\") is considered a valid suffix. In previous " "versions, :exc:`ValueError` is raised if a single dot is supplied." msgstr "" -#: ../../library/pathlib.rst:743 +#: ../../library/pathlib.rst:729 msgid "" "Create a new path object of the same type by combining the given " "*pathsegments*. This method is called whenever a derivative path is created, " @@ -1389,7 +1363,7 @@ msgstr "" "建立的時候會呼叫這個方法,例如從 :attr:`parent` 和 :meth:`relative_to` 建立衍" "生路徑。子類別可以覆寫此方法來傳遞資訊給衍生路徑,例如: ::" -#: ../../library/pathlib.rst:748 +#: ../../library/pathlib.rst:734 msgid "" "from pathlib import PurePosixPath\n" "\n" @@ -1419,11 +1393,11 @@ msgstr "" "hosts = etc / 'hosts'\n" "print(hosts.session_id) # 42" -#: ../../library/pathlib.rst:769 +#: ../../library/pathlib.rst:755 msgid "Concrete paths" msgstr "實體路徑" -#: ../../library/pathlib.rst:771 +#: ../../library/pathlib.rst:757 msgid "" "Concrete paths are subclasses of the pure path classes. In addition to " "operations provided by the latter, they also provide methods to do system " @@ -1432,7 +1406,7 @@ msgstr "" "實體路徑是純路徑類別的子類別。除了後者本來就有提供的操作,它們也提供方法可以" "對路徑物件做系統呼叫。有三種方式可以實例化實體路徑:" -#: ../../library/pathlib.rst:777 +#: ../../library/pathlib.rst:763 msgid "" "A subclass of :class:`PurePath`, this class represents concrete paths of the " "system's path flavour (instantiating it creates either a :class:`PosixPath` " @@ -1441,7 +1415,7 @@ msgstr "" ":class:`PurePath` 的子類別,此類別表示系統的路徑類型的實體路徑(實例化時會建" "立一個 :class:`PosixPath` 或 :class:`WindowsPath`): ::" -#: ../../library/pathlib.rst:781 +#: ../../library/pathlib.rst:767 msgid "" ">>> Path('setup.py')\n" "PosixPath('setup.py')" @@ -1449,7 +1423,7 @@ msgstr "" ">>> Path('setup.py')\n" "PosixPath('setup.py')" -#: ../../library/pathlib.rst:788 +#: ../../library/pathlib.rst:774 msgid "" "A subclass of :class:`Path` and :class:`PurePosixPath`, this class " "represents concrete non-Windows filesystem paths::" @@ -1457,7 +1431,7 @@ msgstr "" ":class:`Path` 和 :class:`PurePosixPath` 的子類別,此類別表示實體非 Windows 檔" "案系統路徑: ::" -#: ../../library/pathlib.rst:791 +#: ../../library/pathlib.rst:777 msgid "" ">>> PosixPath('/etc/hosts')\n" "PosixPath('/etc/hosts')" @@ -1465,7 +1439,7 @@ msgstr "" ">>> PosixPath('/etc/hosts')\n" "PosixPath('/etc/hosts')" -#: ../../library/pathlib.rst:796 +#: ../../library/pathlib.rst:782 msgid "" "Raises :exc:`UnsupportedOperation` on Windows. In previous versions, :exc:" "`NotImplementedError` was raised instead." @@ -1473,7 +1447,7 @@ msgstr "" "在 Windows 上會引發 :exc:`UnsupportedOperation`。在先前版本中,則是引發 :exc:" "`NotImplementedError`。" -#: ../../library/pathlib.rst:803 +#: ../../library/pathlib.rst:789 msgid "" "A subclass of :class:`Path` and :class:`PureWindowsPath`, this class " "represents concrete Windows filesystem paths::" @@ -1481,7 +1455,7 @@ msgstr "" ":class:`Path` 和 :class:`PureWindowsPath` 的子類別,此類別表示實體 Windows 檔" "案系統路徑: ::" -#: ../../library/pathlib.rst:806 +#: ../../library/pathlib.rst:792 msgid "" ">>> WindowsPath('c:/', 'Users', 'Ximénez')\n" "WindowsPath('c:/Users/Ximénez')" @@ -1489,7 +1463,7 @@ msgstr "" ">>> WindowsPath('c:/', 'Users', 'Ximénez')\n" "WindowsPath('c:/Users/Ximénez')" -#: ../../library/pathlib.rst:811 +#: ../../library/pathlib.rst:797 msgid "" "Raises :exc:`UnsupportedOperation` on non-Windows platforms. In previous " "versions, :exc:`NotImplementedError` was raised instead." @@ -1497,7 +1471,7 @@ msgstr "" "在非 Windows 平台上會引發 :exc:`UnsupportedOperation`。在先前版本中,則是引" "發 :exc:`NotImplementedError`。" -#: ../../library/pathlib.rst:816 +#: ../../library/pathlib.rst:802 msgid "" "You can only instantiate the class flavour that corresponds to your system " "(allowing system calls on non-compatible path flavours could lead to bugs or " @@ -1506,7 +1480,7 @@ msgstr "" "你只能實例化對應你的系統的類別類型(允許在不相容的路徑類型上做系統呼叫可能在" "你的應用程式導致漏洞或故障): ::" -#: ../../library/pathlib.rst:820 +#: ../../library/pathlib.rst:806 msgid "" ">>> import os\n" ">>> os.name\n" @@ -1536,18 +1510,18 @@ msgstr "" " % (cls.__name__,))\n" "UnsupportedOperation: cannot instantiate 'WindowsPath' on your system" -#: ../../library/pathlib.rst:834 +#: ../../library/pathlib.rst:820 msgid "" "Some concrete path methods can raise an :exc:`OSError` if a system call " "fails (for example because the path doesn't exist)." msgstr "" "有些實體路徑方法會在系統呼叫失敗(例如因為路徑不存在)時引發 :exc:`OSError`。" -#: ../../library/pathlib.rst:839 +#: ../../library/pathlib.rst:825 msgid "Parsing and generating URIs" msgstr "剖析和產生 URI" -#: ../../library/pathlib.rst:841 +#: ../../library/pathlib.rst:827 msgid "" "Concrete path objects can be created from, and represented as, 'file' URIs " "conforming to :rfc:`8089`." @@ -1555,7 +1529,7 @@ msgstr "" "實體路徑物件可以從符合 :rfc:`8089` 中的 'file' URI 建立,也可以以該形式來表" "示。" -#: ../../library/pathlib.rst:846 +#: ../../library/pathlib.rst:832 msgid "" "File URIs are not portable across machines with different :ref:`filesystem " "encodings `." @@ -1563,11 +1537,11 @@ msgstr "" "檔案 URI 在跨不同\\ :ref:`檔案系統編碼 `\\ 的機器上是無" "法移植的。" -#: ../../library/pathlib.rst:851 +#: ../../library/pathlib.rst:837 msgid "Return a new path object from parsing a 'file' URI. For example::" msgstr "從剖析 'file' URI 回傳新的路徑物件。例如: ::" -#: ../../library/pathlib.rst:853 +#: ../../library/pathlib.rst:839 msgid "" ">>> p = Path.from_uri('file:///etc/hosts')\n" "PosixPath('/etc/hosts')" @@ -1575,11 +1549,11 @@ msgstr "" ">>> p = Path.from_uri('file:///etc/hosts')\n" "PosixPath('/etc/hosts')" -#: ../../library/pathlib.rst:856 +#: ../../library/pathlib.rst:842 msgid "On Windows, DOS device and UNC paths may be parsed from URIs::" msgstr "在 Windows 上,從 URI 可以剖析 DOS 裝置和 UNC 路徑: ::" -#: ../../library/pathlib.rst:858 +#: ../../library/pathlib.rst:844 msgid "" ">>> p = Path.from_uri('file:///c:/windows')\n" "WindowsPath('c:/windows')\n" @@ -1591,11 +1565,11 @@ msgstr "" ">>> p = Path.from_uri('file://server/share')\n" "WindowsPath('//server/share')" -#: ../../library/pathlib.rst:863 +#: ../../library/pathlib.rst:849 msgid "Several variant forms are supported::" msgstr "支援多種變形: ::" -#: ../../library/pathlib.rst:865 +#: ../../library/pathlib.rst:851 msgid "" ">>> p = Path.from_uri('file:////server/share')\n" "WindowsPath('//server/share')\n" @@ -1615,7 +1589,7 @@ msgstr "" ">>> p = Path.from_uri('file:/c|/windows')\n" "WindowsPath('c:/windows')" -#: ../../library/pathlib.rst:874 +#: ../../library/pathlib.rst:860 msgid "" ":exc:`ValueError` is raised if the URI does not start with ``file:``, or the " "parsed path isn't absolute." @@ -1623,21 +1597,21 @@ msgstr "" "如果 URI 不是 ``file:`` 開頭,或是剖析後的路徑不是絕對路徑,則會引發 :exc:" "`ValueError`。" -#: ../../library/pathlib.rst:879 +#: ../../library/pathlib.rst:865 msgid "" "The URL authority is discarded if it matches the local hostname. Otherwise, " "if the authority isn't empty or ``localhost``, then on Windows a UNC path is " "returned (as before), and on other platforms a :exc:`ValueError` is raised." msgstr "" -#: ../../library/pathlib.rst:888 +#: ../../library/pathlib.rst:874 msgid "" "Represent the path as a 'file' URI. :exc:`ValueError` is raised if the path " "isn't absolute." msgstr "" "以 'file' URI 來表示路徑。如果路徑不是絕對的則會引發 :exc:`ValueError`。" -#: ../../library/pathlib.rst:891 +#: ../../library/pathlib.rst:877 msgid "" ">>> p = PosixPath('/etc/passwd')\n" ">>> p.as_uri()\n" @@ -1653,18 +1627,18 @@ msgstr "" ">>> p.as_uri()\n" "'file:///c:/Windows'" -#: ../../library/pathlib.rst:902 +#: ../../library/pathlib.rst:888 msgid "" "Calling this method from :class:`PurePath` rather than :class:`Path` is " "possible but deprecated. The method's use of :func:`os.fsencode` makes it " "strictly impure." msgstr "" -#: ../../library/pathlib.rst:908 +#: ../../library/pathlib.rst:894 msgid "Expanding and resolving paths" msgstr "擴展和解析路徑" -#: ../../library/pathlib.rst:912 +#: ../../library/pathlib.rst:898 msgid "" "Return a new path object representing the user's home directory (as returned " "by :func:`os.path.expanduser` with ``~`` construct). If the home directory " @@ -1673,7 +1647,7 @@ msgstr "" "回傳一個代表使用者家目錄的新的路徑物件(像以 ``~`` 構成的 :func:`os.path." "expanduser` 的回傳一樣)。如果無法解析家目錄,會引發 :exc:`RuntimeError`。" -#: ../../library/pathlib.rst:918 +#: ../../library/pathlib.rst:904 msgid "" ">>> Path.home()\n" "PosixPath('/home/antoine')" @@ -1681,7 +1655,7 @@ msgstr "" ">>> Path.home()\n" "PosixPath('/home/antoine')" -#: ../../library/pathlib.rst:926 +#: ../../library/pathlib.rst:912 msgid "" "Return a new path with expanded ``~`` and ``~user`` constructs, as returned " "by :meth:`os.path.expanduser`. If a home directory can't be resolved, :exc:" @@ -1690,7 +1664,7 @@ msgstr "" "回傳一個展開 ``~`` 和 ``~user`` 構成的新路徑,像 :meth:`os.path.expanduser` " "回傳的一樣。如果無法解析家目錄,會引發 :exc:`RuntimeError`。" -#: ../../library/pathlib.rst:932 +#: ../../library/pathlib.rst:918 msgid "" ">>> p = PosixPath('~/films/Monty Python')\n" ">>> p.expanduser()\n" @@ -1700,14 +1674,14 @@ msgstr "" ">>> p.expanduser()\n" "PosixPath('/home/eric/films/Monty Python')" -#: ../../library/pathlib.rst:941 +#: ../../library/pathlib.rst:927 msgid "" "Return a new path object representing the current directory (as returned by :" "func:`os.getcwd`)::" msgstr "" "回傳一個代表目前目錄的新的路徑物件(像 :func:`os.getcwd` 回傳的一樣): ::" -#: ../../library/pathlib.rst:944 +#: ../../library/pathlib.rst:930 msgid "" ">>> Path.cwd()\n" "PosixPath('/home/antoine/pathlib')" @@ -1715,14 +1689,14 @@ msgstr "" ">>> Path.cwd()\n" "PosixPath('/home/antoine/pathlib')" -#: ../../library/pathlib.rst:950 +#: ../../library/pathlib.rst:936 msgid "" "Make the path absolute, without normalization or resolving symlinks. Returns " "a new path object::" msgstr "" "將路徑轉換為絕對路徑,不進行標準化或解析符號連結。回傳一個新的路徑物件: ::" -#: ../../library/pathlib.rst:953 +#: ../../library/pathlib.rst:939 msgid "" ">>> p = Path('tests')\n" ">>> p\n" @@ -1736,13 +1710,13 @@ msgstr "" ">>> p.absolute()\n" "PosixPath('/home/antoine/pathlib/tests')" -#: ../../library/pathlib.rst:962 +#: ../../library/pathlib.rst:948 msgid "" "Make the path absolute, resolving any symlinks. A new path object is " "returned::" msgstr "將路徑轉換為絕對路徑,解析所有符號連結。回傳一個新的路徑物件: ::" -#: ../../library/pathlib.rst:965 +#: ../../library/pathlib.rst:951 msgid "" ">>> p = Path()\n" ">>> p\n" @@ -1756,13 +1730,13 @@ msgstr "" ">>> p.resolve()\n" "PosixPath('/home/antoine/pathlib')" -#: ../../library/pathlib.rst:971 +#: ../../library/pathlib.rst:957 msgid "" "\"``..``\" components are also eliminated (this is the only method to do " "so)::" msgstr "同時也會消除 \"``..``\" 的路徑組成(只有此方法這樣做): ::" -#: ../../library/pathlib.rst:973 +#: ../../library/pathlib.rst:959 msgid "" ">>> p = Path('docs/../setup.py')\n" ">>> p.resolve()\n" @@ -1772,7 +1746,7 @@ msgstr "" ">>> p.resolve()\n" "PosixPath('/home/antoine/pathlib/setup.py')" -#: ../../library/pathlib.rst:977 +#: ../../library/pathlib.rst:963 msgid "" "If a path doesn't exist or a symlink loop is encountered, and *strict* is " "``True``, :exc:`OSError` is raised. If *strict* is ``False``, the path is " @@ -1783,11 +1757,11 @@ msgstr "" "`OSError`。如果 *strict* 為 ``False``,則將盡可能解析該路徑,並將任何剩餘部分" "追加到路徑中,而不檢查其是否存在。" -#: ../../library/pathlib.rst:982 +#: ../../library/pathlib.rst:968 msgid "The *strict* parameter was added (pre-3.6 behavior is strict)." msgstr "新增 *strict* 參數(在 3.6 版本之前的行為是嚴格的)。" -#: ../../library/pathlib.rst:985 +#: ../../library/pathlib.rst:971 msgid "" "Symlink loops are treated like other errors: :exc:`OSError` is raised in " "strict mode, and no exception is raised in non-strict mode. In previous " @@ -1797,13 +1771,13 @@ msgstr "" "在非嚴格模式下,不會引發任何例外。在先前版本中,不管 *strict* 的值是什麼,都" "會引發 :exc:`RuntimeError`。" -#: ../../library/pathlib.rst:993 +#: ../../library/pathlib.rst:979 msgid "" "Return the path to which the symbolic link points (as returned by :func:`os." "readlink`)::" msgstr "回傳符號連結指向的路徑(如 :func:`os.readlink` 的回傳值): ::" -#: ../../library/pathlib.rst:996 +#: ../../library/pathlib.rst:982 msgid "" ">>> p = Path('mylink')\n" ">>> p.symlink_to('setup.py')\n" @@ -1815,7 +1789,7 @@ msgstr "" ">>> p.readlink()\n" "PosixPath('setup.py')" -#: ../../library/pathlib.rst:1003 +#: ../../library/pathlib.rst:989 msgid "" "Raises :exc:`UnsupportedOperation` if :func:`os.readlink` is not available. " "In previous versions, :exc:`NotImplementedError` was raised." @@ -1823,11 +1797,11 @@ msgstr "" "如果 :func:`os.readlink` 不可用,會引發 :exc:`UnsupportedOperation`。在先前版" "本中,則是引發 :exc:`NotImplementedError`。" -#: ../../library/pathlib.rst:1009 +#: ../../library/pathlib.rst:995 msgid "Querying file type and status" msgstr "查詢檔案類型和狀態" -#: ../../library/pathlib.rst:1013 +#: ../../library/pathlib.rst:999 msgid "" ":meth:`~Path.exists`, :meth:`~Path.is_dir`, :meth:`~Path.is_file`, :meth:" "`~Path.is_mount`, :meth:`~Path.is_symlink`, :meth:`~Path.is_block_device`, :" @@ -1840,7 +1814,7 @@ msgstr "" "meth:`~Path.is_char_device`、:meth:`~Path.is_fifo`、:meth:`~Path.is_socket` " "遇到路徑包含 OS 層無法表示的字元時現在會回傳 ``False`` 而不是引發例外。" -#: ../../library/pathlib.rst:1022 +#: ../../library/pathlib.rst:1008 msgid "" "The methods given above now return ``False`` instead of raising any :exc:" "`OSError` exception from the operating system. In previous versions, some " @@ -1850,7 +1824,7 @@ msgid "" "exceptions." msgstr "" -#: ../../library/pathlib.rst:1032 +#: ../../library/pathlib.rst:1018 msgid "" "Return an :class:`os.stat_result` object containing information about this " "path, like :func:`os.stat`. The result is looked up at each call to this " @@ -1859,7 +1833,7 @@ msgstr "" "回傳一個包含該路徑資訊的 :class:`os.stat_result` 物件,像 :func:`os.stat` 一" "樣。每次呼叫此方法都會重新查詢結果。" -#: ../../library/pathlib.rst:1035 +#: ../../library/pathlib.rst:1021 msgid "" "This method normally follows symlinks; to stat a symlink add the argument " "``follow_symlinks=False``, or use :meth:`~Path.lstat`." @@ -1867,7 +1841,7 @@ msgstr "" "此方法通常會跟隨 (follow) 符號連結;想要取得符號連結的資訊,可以加上引數 " "``follow_symlinks=False`` 或使用 :meth:`~Path.lstat`。" -#: ../../library/pathlib.rst:1040 +#: ../../library/pathlib.rst:1026 msgid "" ">>> p = Path('setup.py')\n" ">>> p.stat().st_size\n" @@ -1881,14 +1855,14 @@ msgstr "" ">>> p.stat().st_mtime\n" "1327883547.852554" -#: ../../library/pathlib.rst:1046 ../../library/pathlib.rst:1078 -#: ../../library/pathlib.rst:1092 ../../library/pathlib.rst:1106 -#: ../../library/pathlib.rst:1745 ../../library/pathlib.rst:1761 -#: ../../library/pathlib.rst:1782 +#: ../../library/pathlib.rst:1032 ../../library/pathlib.rst:1064 +#: ../../library/pathlib.rst:1078 ../../library/pathlib.rst:1092 +#: ../../library/pathlib.rst:1741 ../../library/pathlib.rst:1757 +#: ../../library/pathlib.rst:1778 msgid "The *follow_symlinks* parameter was added." msgstr "新增 *follow_symlinks* 參數。" -#: ../../library/pathlib.rst:1052 +#: ../../library/pathlib.rst:1038 msgid "" "Like :meth:`Path.stat` but, if the path points to a symbolic link, return " "the symbolic link's information rather than its target's." @@ -1896,7 +1870,7 @@ msgstr "" "類似 :meth:`Path.stat`,但如果該路徑指向一個符號連結,則回傳符號連結的資訊而" "不是其指向的目標。" -#: ../../library/pathlib.rst:1058 +#: ../../library/pathlib.rst:1044 msgid "" "Return ``True`` if the path points to an existing file or directory and " "``False`` if the path is invalid, inaccessible or missing. Use :meth:`Path." @@ -1905,7 +1879,7 @@ msgstr "" "如果路徑指向一個存在的檔案或目錄則回傳 ``True``,如果路徑無效、無法存取或不存" "在則回傳 ``False``。請使用 :meth:`Path.stat` 來區分這些情況。" -#: ../../library/pathlib.rst:1062 +#: ../../library/pathlib.rst:1048 msgid "" "This method normally follows symlinks; to check if a symlink exists, add the " "argument ``follow_symlinks=False``." @@ -1913,7 +1887,7 @@ msgstr "" "此方法通常會跟隨符號連結;如果想檢查符號連結是否存在,可以加上引數 " "``follow_symlinks=False``。" -#: ../../library/pathlib.rst:1067 +#: ../../library/pathlib.rst:1053 msgid "" ">>> Path('').exists() # The current directory.\n" "True\n" @@ -1937,7 +1911,7 @@ msgstr "" ">>> Path('nonexistentfile').exists()\n" "False" -#: ../../library/pathlib.rst:1084 +#: ../../library/pathlib.rst:1070 msgid "" "Return ``True`` if the path points to a regular file. ``False`` will be " "returned if the path is invalid, inaccessible or missing, or if it points to " @@ -1945,7 +1919,7 @@ msgid "" "between these cases." msgstr "" -#: ../../library/pathlib.rst:1089 +#: ../../library/pathlib.rst:1075 msgid "" "This method normally follows symlinks; to exclude symlinks, add the argument " "``follow_symlinks=False``." @@ -1953,7 +1927,7 @@ msgstr "" "此方法通常會跟隨符號連結;如果想將符號連結除外,可以加上引數 " "``follow_symlinks=False``。" -#: ../../library/pathlib.rst:1098 +#: ../../library/pathlib.rst:1084 msgid "" "Return ``True`` if the path points to a directory. ``False`` will be " "returned if the path is invalid, inaccessible or missing, or if it points to " @@ -1961,7 +1935,7 @@ msgid "" "between these cases." msgstr "" -#: ../../library/pathlib.rst:1103 +#: ../../library/pathlib.rst:1089 msgid "" "This method normally follows symlinks; to exclude symlinks to directories, " "add the argument ``follow_symlinks=False``." @@ -1969,7 +1943,7 @@ msgstr "" "此方法通常會跟隨符號連結;如果想將對目錄的符號連結除外,可以加上引數 " "``follow_symlinks=False``。" -#: ../../library/pathlib.rst:1112 +#: ../../library/pathlib.rst:1098 msgid "" "Return ``True`` if the path points to a symbolic link, even if that symlink " "is broken. ``False`` will be returned if the path is invalid, inaccessible " @@ -1977,7 +1951,7 @@ msgid "" "meth:`Path.stat` to distinguish between these cases." msgstr "" -#: ../../library/pathlib.rst:1120 +#: ../../library/pathlib.rst:1106 msgid "" "Return ``True`` if the path points to a junction, and ``False`` for any " "other type of file. Currently only Windows supports junctions." @@ -1985,7 +1959,7 @@ msgstr "" "如果該路徑指向一個連接點 (junction) 則回傳 ``True``,對其他類型的檔案則回傳 " "``False``。目前只有 Windows 支援連接點。" -#: ../../library/pathlib.rst:1128 +#: ../../library/pathlib.rst:1114 msgid "" "Return ``True`` if the path is a :dfn:`mount point`: a point in a file " "system where a different file system has been mounted. On POSIX, the " @@ -2003,11 +1977,11 @@ msgstr "" "Windows 上,一個掛載點被視為一個根磁碟機字母(例如 ``c:\\``)、一個 UNC share" "(例如 ``\\\\server\\share``)或是掛載的檔案系統目錄。" -#: ../../library/pathlib.rst:1139 +#: ../../library/pathlib.rst:1125 msgid "Windows support was added." msgstr "加入對 Windows 的支援。" -#: ../../library/pathlib.rst:1144 +#: ../../library/pathlib.rst:1130 msgid "" "Return ``True`` if the path points to a Unix socket. ``False`` will be " "returned if the path is invalid, inaccessible or missing, or if it points to " @@ -2015,14 +1989,14 @@ msgid "" "between these cases." msgstr "" -#: ../../library/pathlib.rst:1152 +#: ../../library/pathlib.rst:1138 msgid "" "Return ``True`` if the path points to a FIFO. ``False`` will be returned if " "the path is invalid, inaccessible or missing, or if it points to something " "other than a FIFO. Use :meth:`Path.stat` to distinguish between these cases." msgstr "" -#: ../../library/pathlib.rst:1160 +#: ../../library/pathlib.rst:1146 msgid "" "Return ``True`` if the path points to a block device. ``False`` will be " "returned if the path is invalid, inaccessible or missing, or if it points to " @@ -2030,7 +2004,7 @@ msgid "" "between these cases." msgstr "" -#: ../../library/pathlib.rst:1168 +#: ../../library/pathlib.rst:1154 msgid "" "Return ``True`` if the path points to a character device. ``False`` will be " "returned if the path is invalid, inaccessible or missing, or if it points to " @@ -2038,7 +2012,7 @@ msgid "" "distinguish between these cases." msgstr "" -#: ../../library/pathlib.rst:1176 +#: ../../library/pathlib.rst:1162 msgid "" "Return whether this path points to the same file as *other_path*, which can " "be either a Path object, or a string. The semantics are similar to :func:" @@ -2048,13 +2022,13 @@ msgstr "" "物件或字串。其語義類似於 :func:`os.path.samefile` 和 :func:`os.path." "samestat`。" -#: ../../library/pathlib.rst:1180 +#: ../../library/pathlib.rst:1166 msgid "" "An :exc:`OSError` can be raised if either file cannot be accessed for some " "reason." msgstr "若任何一個檔案因為某些原因無法存取,則引發 :exc:`OSError`。" -#: ../../library/pathlib.rst:1185 +#: ../../library/pathlib.rst:1171 msgid "" ">>> p = Path('spam')\n" ">>> q = Path('eggs')\n" @@ -2070,7 +2044,7 @@ msgstr "" ">>> p.samefile('spam')\n" "True" -#: ../../library/pathlib.rst:1197 +#: ../../library/pathlib.rst:1183 msgid "" "A :class:`~pathlib.types.PathInfo` object that supports querying file type " "information. The object exposes methods that cache their results, which can " @@ -2078,7 +2052,7 @@ msgid "" "For example::" msgstr "" -#: ../../library/pathlib.rst:1202 +#: ../../library/pathlib.rst:1188 msgid "" ">>> p = Path('src')\n" ">>> if p.info.is_symlink():\n" @@ -2104,7 +2078,7 @@ msgstr "" "...\n" "directory" -#: ../../library/pathlib.rst:1214 +#: ../../library/pathlib.rst:1200 msgid "" "If the path was generated from :meth:`Path.iterdir` then this attribute is " "initialized with some information about the file type gleaned from scanning " @@ -2112,7 +2086,7 @@ msgid "" "any filesystem queries." msgstr "" -#: ../../library/pathlib.rst:1219 +#: ../../library/pathlib.rst:1205 msgid "" "To fetch up-to-date information, it's best to call :meth:`Path.is_dir`, :" "meth:`~Path.is_file` and :meth:`~Path.is_symlink` rather than methods of " @@ -2120,17 +2094,17 @@ msgid "" "new path object with an empty info cache via ``p = Path(p)``." msgstr "" -#: ../../library/pathlib.rst:1228 +#: ../../library/pathlib.rst:1214 msgid "Reading and writing files" msgstr "讀取和寫入檔案" -#: ../../library/pathlib.rst:1233 +#: ../../library/pathlib.rst:1219 msgid "" "Open the file pointed to by the path, like the built-in :func:`open` " "function does::" msgstr "開啟該路徑指向的檔案,像內建的 :func:`open` 函式做的一樣: ::" -#: ../../library/pathlib.rst:1236 +#: ../../library/pathlib.rst:1222 msgid "" ">>> p = Path('setup.py')\n" ">>> with p.open() as f:\n" @@ -2144,11 +2118,11 @@ msgstr "" "...\n" "'#!/usr/bin/env python3\\n'" -#: ../../library/pathlib.rst:1245 +#: ../../library/pathlib.rst:1231 msgid "Return the decoded contents of the pointed-to file as a string::" msgstr "將路徑指向的檔案的解碼內容以字串形式回傳: ::" -#: ../../library/pathlib.rst:1247 ../../library/pathlib.rst:1280 +#: ../../library/pathlib.rst:1233 ../../library/pathlib.rst:1266 msgid "" ">>> p = Path('my_text_file')\n" ">>> p.write_text('Text file contents')\n" @@ -2162,21 +2136,21 @@ msgstr "" ">>> p.read_text()\n" "'Text file contents'" -#: ../../library/pathlib.rst:1253 +#: ../../library/pathlib.rst:1239 msgid "" "The file is opened and then closed. The optional parameters have the same " "meaning as in :func:`open`." msgstr "該檔案被打開並且隨後關閉。可選參數的含義與 :func:`open` 中的相同。" -#: ../../library/pathlib.rst:1258 ../../library/pathlib.rst:1291 +#: ../../library/pathlib.rst:1244 ../../library/pathlib.rst:1277 msgid "The *newline* parameter was added." msgstr "新增 *newline* 參數。" -#: ../../library/pathlib.rst:1264 +#: ../../library/pathlib.rst:1250 msgid "Return the binary contents of the pointed-to file as a bytes object::" msgstr "將路徑指向的檔案的二進位內容以一個位元組物件回傳: ::" -#: ../../library/pathlib.rst:1266 ../../library/pathlib.rst:1300 +#: ../../library/pathlib.rst:1252 ../../library/pathlib.rst:1286 msgid "" ">>> p = Path('my_binary_file')\n" ">>> p.write_bytes(b'Binary file contents')\n" @@ -2190,40 +2164,40 @@ msgstr "" ">>> p.read_bytes()\n" "b'Binary file contents'" -#: ../../library/pathlib.rst:1277 +#: ../../library/pathlib.rst:1263 msgid "" "Open the file pointed to in text mode, write *data* to it, and close the " "file::" msgstr "以文字模式開啟指向的檔案,將 *data* 寫到檔案,並關閉檔案:: :" -#: ../../library/pathlib.rst:1286 +#: ../../library/pathlib.rst:1272 msgid "" "An existing file of the same name is overwritten. The optional parameters " "have the same meaning as in :func:`open`." msgstr "" "一個名稱相同的已存在檔案會被覆寫。可選參數和 :func:`open` 的參數有相同意義。" -#: ../../library/pathlib.rst:1297 +#: ../../library/pathlib.rst:1283 msgid "" "Open the file pointed to in bytes mode, write *data* to it, and close the " "file::" msgstr "以位元組模式開啟指向的檔案,將 *data* 寫到檔案,並關閉檔案:: :" -#: ../../library/pathlib.rst:1306 +#: ../../library/pathlib.rst:1292 msgid "An existing file of the same name is overwritten." msgstr "一個名稱相同的已存在檔案會被覆寫。" -#: ../../library/pathlib.rst:1312 +#: ../../library/pathlib.rst:1298 msgid "Reading directories" msgstr "讀取目錄" -#: ../../library/pathlib.rst:1316 +#: ../../library/pathlib.rst:1302 msgid "" "When the path points to a directory, yield path objects of the directory " "contents::" msgstr "當該路徑指向一個目錄,會 yield 目錄裡面的路徑物件: ::" -#: ../../library/pathlib.rst:1319 +#: ../../library/pathlib.rst:1305 msgid "" ">>> p = Path('docs')\n" ">>> for child in p.iterdir(): child\n" @@ -2247,7 +2221,7 @@ msgstr "" "PosixPath('docs/_static')\n" "PosixPath('docs/Makefile')" -#: ../../library/pathlib.rst:1330 +#: ../../library/pathlib.rst:1316 msgid "" "The children are yielded in arbitrary order, and the special entries ``'.'`` " "and ``'..'`` are not included. If a file is removed from or added to the " @@ -2258,13 +2232,13 @@ msgstr "" "檔案在建立這個疊代器之後加到該目錄或從目錄刪除,這個檔案的路徑物件是否會被包" "含是沒有明定的。" -#: ../../library/pathlib.rst:1335 +#: ../../library/pathlib.rst:1321 msgid "" "If the path is not a directory or otherwise inaccessible, :exc:`OSError` is " "raised." msgstr "如果路徑不是目錄或無法存取,則會引發 :exc:`OSError`。" -#: ../../library/pathlib.rst:1341 +#: ../../library/pathlib.rst:1327 msgid "" "Glob the given relative *pattern* in the directory represented by this path, " "yielding all matching files (of any kind)::" @@ -2272,7 +2246,7 @@ msgstr "" "在該路徑表示的目錄裡,以 glob 方式比對所給定的相對 *pattern*,並 yield 所有比" "對到的檔案(任意類型): ::" -#: ../../library/pathlib.rst:1344 +#: ../../library/pathlib.rst:1330 msgid "" ">>> sorted(Path('.').glob('*.py'))\n" "[PosixPath('pathlib.py'), PosixPath('setup.py'), PosixPath('test_pathlib." @@ -2298,13 +2272,13 @@ msgstr "" " PosixPath('setup.py'),\n" " PosixPath('test_pathlib.py')]" -#: ../../library/pathlib.rst:1356 ../../library/pathlib.rst:1399 +#: ../../library/pathlib.rst:1342 ../../library/pathlib.rst:1385 msgid "" "The paths are returned in no particular order. If you need a specific order, " "sort the results." msgstr "" -#: ../../library/pathlib.rst:1362 +#: ../../library/pathlib.rst:1348 msgid "" "By default, or when the *case_sensitive* keyword-only argument is set to " "``None``, this method matches paths using platform-specific casing rules: " @@ -2316,7 +2290,7 @@ msgstr "" "在 Windows 上不區分大小寫。將 *case_sensitive* 設成 ``True`` 或 ``False`` 會" "覆寫這個行為。" -#: ../../library/pathlib.rst:1367 +#: ../../library/pathlib.rst:1353 msgid "" "By default, or when the *recurse_symlinks* keyword-only argument is set to " "``False``, this method follows symlinks except when expanding \"``**``\" " @@ -2326,7 +2300,7 @@ msgstr "" "候,此方法會跟隨符號連結,除非在擴展 \"``**``\" 萬用字元時。將 " "*recurse_symlinks* 設成 ``True`` 以總是跟隨符號連結。" -#: ../../library/pathlib.rst:1372 ../../library/pathlib.rst:1403 +#: ../../library/pathlib.rst:1358 ../../library/pathlib.rst:1389 msgid "" "Any :exc:`OSError` exceptions raised from scanning the filesystem are " "suppressed. This includes :exc:`PermissionError` when accessing directories " @@ -2335,7 +2309,7 @@ msgstr "" "從掃描檔案系統引發的任何 :exc:`OSError` 例外都會被抑制。這包括在存取沒有讀取" "權限的目錄時引發的 :exc:`PermissionError`。" -#: ../../library/pathlib.rst:1376 +#: ../../library/pathlib.rst:1362 msgid "" "Raises an :ref:`auditing event ` ``pathlib.Path.glob`` with " "arguments ``self``, ``pattern``." @@ -2343,11 +2317,11 @@ msgstr "" "引發一個附帶引數 ``self``、``pattern`` 的\\ :ref:`稽核事件 ` " "``pathlib.Path.glob``。" -#: ../../library/pathlib.rst:1381 ../../library/pathlib.rst:1415 +#: ../../library/pathlib.rst:1367 ../../library/pathlib.rst:1401 msgid "The *recurse_symlinks* parameter was added." msgstr "新增 *recurse_symlinks* 參數。" -#: ../../library/pathlib.rst:1387 +#: ../../library/pathlib.rst:1373 msgid "" "Any :exc:`OSError` exceptions raised from scanning the filesystem are " "suppressed. In previous versions, such exceptions are suppressed in many " @@ -2356,7 +2330,7 @@ msgstr "" "從掃描檔案系統引發的任何 :exc:`OSError` 例外都會被抑制。在先前版本中,在許多" "情況下這種例外都會被抑制,但不是所有情況。" -#: ../../library/pathlib.rst:1395 +#: ../../library/pathlib.rst:1381 msgid "" "Glob the given relative *pattern* recursively. This is like calling :func:" "`Path.glob` with \"``**/``\" added in front of the *pattern*." @@ -2364,11 +2338,11 @@ msgstr "" "遞迴地 glob 給定的相對 *pattern*。這相當於在給定的相對 *pattern* 前面加上 " "\"``**/``\" 並呼叫 :func:`Path.glob`。" -#: ../../library/pathlib.rst:1408 +#: ../../library/pathlib.rst:1394 msgid ":ref:`pathlib-pattern-language` and :meth:`Path.glob` documentation." msgstr ":ref:`pathlib-pattern-language` 和 :meth:`Path.glob` 文件。" -#: ../../library/pathlib.rst:1410 +#: ../../library/pathlib.rst:1396 msgid "" "Raises an :ref:`auditing event ` ``pathlib.Path.rglob`` with " "arguments ``self``, ``pattern``." @@ -2376,13 +2350,13 @@ msgstr "" "引發一個附帶引數 ``self``、``pattern`` 的\\ :ref:`稽核事件 ` " "``pathlib.Path.rglob``。" -#: ../../library/pathlib.rst:1424 +#: ../../library/pathlib.rst:1410 msgid "" "Generate the file names in a directory tree by walking the tree either top-" "down or bottom-up." msgstr "透過由上而下或由下而上地走訪目錄樹產生目錄樹裡的檔案名稱。" -#: ../../library/pathlib.rst:1427 +#: ../../library/pathlib.rst:1413 msgid "" "For each directory in the directory tree rooted at *self* (including *self* " "but excluding '.' and '..'), the method yields a 3-tuple of ``(dirpath, " @@ -2391,7 +2365,7 @@ msgstr "" "對每個以 *self* 為根且在目錄樹裡的目錄(包含 *self* 但不包含 '.' 和 '..' )," "此方法會 yield 一個 ``(dirpath, dirnames, filenames)`` 的三元素元組。" -#: ../../library/pathlib.rst:1431 +#: ../../library/pathlib.rst:1417 msgid "" "*dirpath* is a :class:`Path` to the directory currently being walked, " "*dirnames* is a list of strings for the names of subdirectories in *dirpath* " @@ -2406,7 +2380,7 @@ msgstr "" "裡檔案或目錄的完整路徑(以 *self* 開頭),可以使用 ``dirpath / name``。會根據" "檔案系統來決定串列是否有排序。" -#: ../../library/pathlib.rst:1439 +#: ../../library/pathlib.rst:1425 msgid "" "If the optional argument *top_down* is true (which is the default), the " "triple for a directory is generated before the triples for any of its " @@ -2422,7 +2396,7 @@ msgstr "" "不論 *top_down* 的值是什麼,子目錄的串列會在走訪該目錄及其子目錄的三元素元組" "之前取得。" -#: ../../library/pathlib.rst:1447 +#: ../../library/pathlib.rst:1433 msgid "" "When *top_down* is true, the caller can modify the *dirnames* list in-place " "(for example, using :keyword:`del` or slice assignment), and :meth:`Path." @@ -2442,7 +2416,7 @@ msgstr "" "*dirnames* 對 :meth:`Path.walk` 的行為沒有影響,因為 *dirnames* 裡的目錄已經" "在 *dirnames* yield 給呼叫者之前被產生。" -#: ../../library/pathlib.rst:1457 +#: ../../library/pathlib.rst:1443 msgid "" "By default, errors from :func:`os.scandir` are ignored. If the optional " "argument *on_error* is specified, it should be a callable; it will be called " @@ -2455,7 +2429,7 @@ msgstr "" "這個可呼叫物件可以處理錯誤以繼續走訪,或者再次引發錯誤來停止走訪。注意,檔案" "名稱可以從例外物件的 ``filename`` 屬性來取得。" -#: ../../library/pathlib.rst:1463 +#: ../../library/pathlib.rst:1449 msgid "" "By default, :meth:`Path.walk` does not follow symbolic links, and instead " "adds them to the *filenames* list. Set *follow_symlinks* to true to resolve " @@ -2468,7 +2442,7 @@ msgstr "" "適當的 *dirnames* 和 *filenames*,而因此瀏覽到符號連結指向的目錄(在有支援符" "號連結的地方)。" -#: ../../library/pathlib.rst:1470 +#: ../../library/pathlib.rst:1456 msgid "" "Be aware that setting *follow_symlinks* to true can lead to infinite " "recursion if a link points to a parent directory of itself. :meth:`Path." @@ -2477,7 +2451,7 @@ msgstr "" "需要注意的是如果符號連結指向一個其本身的父目錄,則將 *follow_symlinks* 設定" "為 true 會導致無窮的遞迴。:meth:`Path.walk` 不會紀錄其已經瀏覽過的目錄。" -#: ../../library/pathlib.rst:1475 +#: ../../library/pathlib.rst:1461 msgid "" ":meth:`Path.walk` assumes the directories it walks are not modified during " "execution. For example, if a directory from *dirnames* has been replaced " @@ -2490,7 +2464,7 @@ msgstr "" "meth:`Path.walk` 依然會試著往下進入它。為了防止這樣的行為,可以從 *dirnames* " "適當地移除目錄。" -#: ../../library/pathlib.rst:1483 +#: ../../library/pathlib.rst:1469 msgid "" "Unlike :func:`os.walk`, :meth:`Path.walk` lists symlinks to directories in " "*filenames* if *follow_symlinks* is false." @@ -2498,7 +2472,7 @@ msgstr "" "如果 *follow_symlinks* 是 false,和 :func:`os.walk` 行為不同的是 :meth:`Path." "walk` 會將指向目錄的符號連結放在 *filenames* 串列。" -#: ../../library/pathlib.rst:1486 +#: ../../library/pathlib.rst:1472 msgid "" "This example displays the number of bytes used by all files in each " "directory, while ignoring ``__pycache__`` directories::" @@ -2506,7 +2480,7 @@ msgstr "" "這個範例會顯示在每個目錄裡所有檔案使用的位元組數量,同時間忽略 " "``__pycache__`` 目錄: ::" -#: ../../library/pathlib.rst:1489 +#: ../../library/pathlib.rst:1475 msgid "" "from pathlib import Path\n" "for root, dirs, files in Path(\"cpython/Lib/concurrent\")." @@ -2536,7 +2510,7 @@ msgstr "" " if '__pycache__' in dirs:\n" " dirs.remove('__pycache__')" -#: ../../library/pathlib.rst:1502 +#: ../../library/pathlib.rst:1488 msgid "" "This next example is a simple implementation of :func:`shutil.rmtree`. " "Walking the tree bottom-up is essential as :func:`rmdir` doesn't allow " @@ -2545,7 +2519,7 @@ msgstr "" "下一個範例是 :func:`shutil.rmtree` 的一個簡單的實作方式。由下而上走訪目錄樹是" "必要的,因為 :func:`rmdir` 不允許在目錄為空之前刪除它: ::" -#: ../../library/pathlib.rst:1506 +#: ../../library/pathlib.rst:1492 msgid "" "# Delete everything reachable from the directory \"top\".\n" "# CAUTION: This is dangerous! For example, if top == Path('/'),\n" @@ -2565,11 +2539,11 @@ msgstr "" " for name in dirs:\n" " (root / name).rmdir()" -#: ../../library/pathlib.rst:1519 +#: ../../library/pathlib.rst:1505 msgid "Creating files and directories" msgstr "建立檔案和目錄" -#: ../../library/pathlib.rst:1523 +#: ../../library/pathlib.rst:1509 msgid "" "Create a file at this given path. If *mode* is given, it is combined with " "the process's ``umask`` value to determine the file mode and access flags. " @@ -2581,7 +2555,7 @@ msgstr "" "合,以確定檔案模式和存取旗標。當檔案已經存在時,若 *exist_ok* 為 true 則函式" "不會失敗(其變更時間會被更新為當下時間),否則會引發 :exc:`FileExistsError`。" -#: ../../library/pathlib.rst:1530 +#: ../../library/pathlib.rst:1516 msgid "" "The :meth:`~Path.open`, :meth:`~Path.write_text` and :meth:`~Path." "write_bytes` methods are often used to create files." @@ -2589,7 +2563,7 @@ msgstr "" ":meth:`~Path.open`、:meth:`~Path.write_text` 和 :meth:`~Path.write_bytes` 方" "法通常用於建立檔案。" -#: ../../library/pathlib.rst:1536 +#: ../../library/pathlib.rst:1523 msgid "" "Create a new directory at this given path. If *mode* is given, it is " "combined with the process's ``umask`` value to determine the file mode and " @@ -2599,7 +2573,7 @@ msgstr "" "``umask`` 值來決定檔案模式與存取旗標 (access flag)。如果路徑已經存在,會引" "發 :exc:`FileExistsError`。" -#: ../../library/pathlib.rst:1541 +#: ../../library/pathlib.rst:1528 msgid "" "If *parents* is true, any missing parents of this path are created as " "needed; they are created with the default permissions without taking *mode* " @@ -2608,7 +2582,16 @@ msgstr "" "如果 *parents* 是 true,則任何缺少的父路徑都會依需要被建立;它們不考慮 " "*mode* 而會以預設的權限來建立(模仿 POSIX 的 ``mkdir -p`` 指令)。" -#: ../../library/pathlib.rst:1545 +#: ../../library/pathlib.rst:1532 +msgid "" +"If *parent_mode* is not ``None``, it is used as the mode for any newly-" +"created, intermediate-level directories when *parents* is true. Like *mode*, " +"it is combined with the process's ``umask`` value. Otherwise, intermediate " +"directories are created with the default permissions (also subject to the " +"umask)." +msgstr "" + +#: ../../library/pathlib.rst:1538 msgid "" "If *parents* is false (the default), a missing parent raises :exc:" "`FileNotFoundError`." @@ -2616,7 +2599,7 @@ msgstr "" "如果 *parents* 是 false(預設值),缺少的父路徑會引發 :exc:" "`FileNotFoundError`。" -#: ../../library/pathlib.rst:1548 +#: ../../library/pathlib.rst:1541 msgid "" "If *exist_ok* is false (the default), :exc:`FileExistsError` is raised if " "the target directory already exists." @@ -2624,7 +2607,7 @@ msgstr "" "如果 *exist_ok* 是 false(預設值),則當目標目錄已經存在的話會引發 :exc:" "`FileExistsError`。" -#: ../../library/pathlib.rst:1551 +#: ../../library/pathlib.rst:1544 msgid "" "If *exist_ok* is true, :exc:`FileExistsError` will not be raised unless the " "given path already exists in the file system and is not a directory (same " @@ -2633,15 +2616,19 @@ msgstr "" "如果 *exist_ok* 是 true,只有當最後的路徑組成不是一個已存在的非目錄檔案,:" "exc:`FileExistsError` 例外會被忽略(與 POSIX 的 ``mkdir -p`` 指令行為相同)。" -#: ../../library/pathlib.rst:1555 +#: ../../library/pathlib.rst:1548 msgid "The *exist_ok* parameter was added." msgstr "新增 *exist_ok* 參數。" -#: ../../library/pathlib.rst:1561 +#: ../../library/pathlib.rst:1551 +msgid "The *parent_mode* parameter." +msgstr "*parent_mode* 參數。" + +#: ../../library/pathlib.rst:1557 msgid "Make this path a symbolic link pointing to *target*." msgstr "使這個路徑成為一個指向 *target* 的符號連結。" -#: ../../library/pathlib.rst:1563 +#: ../../library/pathlib.rst:1559 msgid "" "On Windows, a symlink represents either a file or a directory, and does not " "morph to the target dynamically. If the target is present, the type of the " @@ -2654,7 +2641,7 @@ msgstr "" "*target_is_directory* 是 true,該符號連結會被建立成目錄,如果不是則建立成檔案" "(預設值)。在非 Windows 平台上,*target_is_directory* 會被忽略。" -#: ../../library/pathlib.rst:1571 +#: ../../library/pathlib.rst:1567 msgid "" ">>> p = Path('mylink')\n" ">>> p.symlink_to('setup.py')\n" @@ -2674,12 +2661,12 @@ msgstr "" ">>> p.lstat().st_size\n" "8" -#: ../../library/pathlib.rst:1581 +#: ../../library/pathlib.rst:1577 msgid "" "The order of arguments (link, target) is the reverse of :func:`os.symlink`'s." msgstr "引數的順序 (link, target) 和 :func:`os.symlink` 相反。" -#: ../../library/pathlib.rst:1584 +#: ../../library/pathlib.rst:1580 msgid "" "Raises :exc:`UnsupportedOperation` if :func:`os.symlink` is not available. " "In previous versions, :exc:`NotImplementedError` was raised." @@ -2687,16 +2674,16 @@ msgstr "" "如果 :func:`os.symlink` 不可用,會引發 :exc:`UnsupportedOperation`。在先前版" "本中,則是引發 :exc:`NotImplementedError`。" -#: ../../library/pathlib.rst:1591 +#: ../../library/pathlib.rst:1587 msgid "Make this path a hard link to the same file as *target*." msgstr "使這個路徑成為與 *target* 相同檔案的一個硬連結 (hard link)。" -#: ../../library/pathlib.rst:1594 +#: ../../library/pathlib.rst:1590 msgid "" "The order of arguments (link, target) is the reverse of :func:`os.link`'s." msgstr "引數的順序 (link, target) 和 :func:`os.link` 相反。" -#: ../../library/pathlib.rst:1599 +#: ../../library/pathlib.rst:1595 msgid "" "Raises :exc:`UnsupportedOperation` if :func:`os.link` is not available. In " "previous versions, :exc:`NotImplementedError` was raised." @@ -2704,11 +2691,11 @@ msgstr "" "如果 :func:`os.link` 不可用,會引發 :exc:`UnsupportedOperation`。在先前版本" "中,則是引發 :exc:`NotImplementedError`。" -#: ../../library/pathlib.rst:1605 +#: ../../library/pathlib.rst:1601 msgid "Copying, moving and deleting" msgstr "複製、移動和刪除" -#: ../../library/pathlib.rst:1609 +#: ../../library/pathlib.rst:1605 msgid "" "Copy this file or directory tree to the given *target*, and return a new :" "class:`!Path` instance pointing to *target*." @@ -2716,7 +2703,7 @@ msgstr "" "將此檔案或目錄樹複製到給定的 *target*,並回傳一個指向 *target* 的新 :class:`!" "Path` 實例。" -#: ../../library/pathlib.rst:1612 +#: ../../library/pathlib.rst:1608 msgid "" "If the source is a file, the target will be replaced if it is an existing " "file. If the source is a symlink and *follow_symlinks* is true (the " @@ -2724,7 +2711,7 @@ msgid "" "recreated at the destination." msgstr "" -#: ../../library/pathlib.rst:1617 +#: ../../library/pathlib.rst:1613 msgid "" "If *preserve_metadata* is false (the default), only directory structures and " "file data are guaranteed to be copied. Set *preserve_metadata* to true to " @@ -2734,21 +2721,21 @@ msgid "" "always preserved)." msgstr "" -#: ../../library/pathlib.rst:1625 +#: ../../library/pathlib.rst:1621 msgid "" "Where supported by the operating system and file system, this method " "performs a lightweight copy, where data blocks are only copied when " "modified. This is known as copy-on-write." msgstr "" -#: ../../library/pathlib.rst:1635 +#: ../../library/pathlib.rst:1631 msgid "" "Copy this file or directory tree into the given *target_dir*, which should " "be an existing directory. Other arguments are handled identically to :meth:" "`Path.copy`. Returns a new :class:`!Path` instance pointing to the copy." msgstr "" -#: ../../library/pathlib.rst:1645 +#: ../../library/pathlib.rst:1641 msgid "" "Rename this file or directory to the given *target*, and return a new :class:" "`!Path` instance pointing to *target*. On Unix, if *target* exists and is a " @@ -2761,7 +2748,7 @@ msgstr "" "限,則會在不顯示訊息的情況下進行取代。在 Windows 系統上,若 *target* 存在,則" "會引發 :exc:`FileExistsError` 錯誤。*target* 可以是字串或另一個路徑物件: ::" -#: ../../library/pathlib.rst:1651 +#: ../../library/pathlib.rst:1647 msgid "" ">>> p = Path('foo')\n" ">>> p.open('w').write('some text')\n" @@ -2781,7 +2768,7 @@ msgstr "" ">>> target.open().read()\n" "'some text'" -#: ../../library/pathlib.rst:1660 ../../library/pathlib.rst:1676 +#: ../../library/pathlib.rst:1656 ../../library/pathlib.rst:1672 msgid "" "The target path may be absolute or relative. Relative paths are interpreted " "relative to the current working directory, *not* the directory of the :class:" @@ -2790,17 +2777,17 @@ msgstr "" "目標路徑可以是絕對路徑或相對路徑。相對路徑會相對於目前的工作目錄進行解釋,*而" "不是*\\ 相對於 :class:`!Path` 物件所在的目錄。" -#: ../../library/pathlib.rst:1664 +#: ../../library/pathlib.rst:1660 msgid "" "It is implemented in terms of :func:`os.rename` and gives the same " "guarantees." msgstr "此功能是使用 :func:`os.rename` 實現的,並提供相同的保證。" -#: ../../library/pathlib.rst:1666 ../../library/pathlib.rst:1680 +#: ../../library/pathlib.rst:1662 ../../library/pathlib.rst:1676 msgid "Added return value, return the new :class:`!Path` instance." msgstr "新增了回傳值,回傳新的 :class:`!Path` 實例。" -#: ../../library/pathlib.rst:1672 +#: ../../library/pathlib.rst:1668 msgid "" "Rename this file or directory to the given *target*, and return a new :class:" "`!Path` instance pointing to *target*. If *target* points to an existing " @@ -2809,7 +2796,7 @@ msgstr "" "將此檔案或目錄重新命名為給定的 *target*,並回傳一個指向 *target* 的新 :class:" "`!Path` 實例。如果 *target* 指向一個現有的檔案或空目錄,它將被無條件地取代。" -#: ../../library/pathlib.rst:1686 +#: ../../library/pathlib.rst:1682 msgid "" "Move this file or directory tree to the given *target*, and return a new :" "class:`!Path` instance pointing to *target*." @@ -2817,7 +2804,7 @@ msgstr "" "將此檔案或目錄樹移動到給定的 *target*,並回傳一個指向 *target* 的新 :class:`!" "Path` 實例。" -#: ../../library/pathlib.rst:1689 +#: ../../library/pathlib.rst:1685 msgid "" "If the *target* doesn't exist it will be created. If both this path and the " "*target* are existing files, then the target is overwritten. If both paths " @@ -2825,27 +2812,27 @@ msgid "" "directory, then :exc:`OSError` is raised." msgstr "" -#: ../../library/pathlib.rst:1694 +#: ../../library/pathlib.rst:1690 msgid "" "If both paths are on the same filesystem, the move is performed with :func:" "`os.replace`. Otherwise, this path is copied (preserving metadata and " "symlinks) and then deleted." msgstr "" -#: ../../library/pathlib.rst:1703 +#: ../../library/pathlib.rst:1699 msgid "" "Move this file or directory tree into the given *target_dir*, which should " "be an existing directory. Returns a new :class:`!Path` instance pointing to " "the moved path." msgstr "" -#: ../../library/pathlib.rst:1712 +#: ../../library/pathlib.rst:1708 msgid "" "Remove this file or symbolic link. If the path points to a directory, use :" "func:`Path.rmdir` instead." msgstr "移除這個檔案或符號連結。如果路徑指向目錄,請改用 :func:`Path.rmdir`。" -#: ../../library/pathlib.rst:1715 +#: ../../library/pathlib.rst:1711 msgid "" "If *missing_ok* is false (the default), :exc:`FileNotFoundError` is raised " "if the path does not exist." @@ -2853,7 +2840,7 @@ msgstr "" "如果 *missing_ok* 是 false(預設值),:exc:`FileNotFoundError` 會在路徑不存在" "時被引發。" -#: ../../library/pathlib.rst:1718 +#: ../../library/pathlib.rst:1714 msgid "" "If *missing_ok* is true, :exc:`FileNotFoundError` exceptions will be ignored " "(same behavior as the POSIX ``rm -f`` command)." @@ -2861,19 +2848,19 @@ msgstr "" "如果 *missing_ok* 是 true,:exc:`FileNotFoundError` 例外會被忽略(行為與 " "POSIX ``rm -f`` 指令相同)。" -#: ../../library/pathlib.rst:1721 +#: ../../library/pathlib.rst:1717 msgid "The *missing_ok* parameter was added." msgstr "新增 *missing_ok* 參數。" -#: ../../library/pathlib.rst:1727 +#: ../../library/pathlib.rst:1723 msgid "Remove this directory. The directory must be empty." msgstr "移除此目錄。該目錄必須為空。" -#: ../../library/pathlib.rst:1731 +#: ../../library/pathlib.rst:1727 msgid "Permissions and ownership" msgstr "權限和所有權" -#: ../../library/pathlib.rst:1735 +#: ../../library/pathlib.rst:1731 msgid "" "Return the name of the user owning the file. :exc:`KeyError` is raised if " "the file's user identifier (UID) isn't found in the system database." @@ -2881,7 +2868,7 @@ msgstr "" "回傳擁有該檔案的用戶名稱。如果在系統資料庫中找不到該檔案的使用者識別字 " "(UID),則會引發 :exc:`KeyError`。" -#: ../../library/pathlib.rst:1738 +#: ../../library/pathlib.rst:1734 msgid "" "This method normally follows symlinks; to get the owner of the symlink, add " "the argument ``follow_symlinks=False``." @@ -2889,7 +2876,7 @@ msgstr "" "此方法通常會跟隨符號連結;如果想取得符號連結的擁有者,可以加上引數 " "``follow_symlinks=False``。" -#: ../../library/pathlib.rst:1741 +#: ../../library/pathlib.rst:1737 msgid "" "Raises :exc:`UnsupportedOperation` if the :mod:`pwd` module is not " "available. In earlier versions, :exc:`NotImplementedError` was raised." @@ -2897,7 +2884,7 @@ msgstr "" "如果 :mod:`pwd` 模組不可用,會引發 :exc:`UnsupportedOperation`。在先前版本" "中,則是引發 :exc:`NotImplementedError`。" -#: ../../library/pathlib.rst:1751 +#: ../../library/pathlib.rst:1747 msgid "" "Return the name of the group owning the file. :exc:`KeyError` is raised if " "the file's group identifier (GID) isn't found in the system database." @@ -2905,7 +2892,7 @@ msgstr "" "回傳擁有該檔案的群組名稱。如果在系統資料庫裡找不到檔案的群組識別字 (GID) 會引" "發 :exc:`KeyError`。" -#: ../../library/pathlib.rst:1754 +#: ../../library/pathlib.rst:1750 msgid "" "This method normally follows symlinks; to get the group of the symlink, add " "the argument ``follow_symlinks=False``." @@ -2913,7 +2900,7 @@ msgstr "" "此方法通常會跟隨符號連結;如果想取得符號連結的群組,可以加上引數 " "``follow_symlinks=False``。" -#: ../../library/pathlib.rst:1757 +#: ../../library/pathlib.rst:1753 msgid "" "Raises :exc:`UnsupportedOperation` if the :mod:`grp` module is not " "available. In earlier versions, :exc:`NotImplementedError` was raised." @@ -2921,11 +2908,11 @@ msgstr "" "如果 :mod:`grp` 模組不可用,會引發 :exc:`UnsupportedOperation`。在先前版本" "中,則是引發 :exc:`NotImplementedError`。" -#: ../../library/pathlib.rst:1767 +#: ../../library/pathlib.rst:1763 msgid "Change the file mode and permissions, like :func:`os.chmod`." msgstr "修改檔案模式 (file mode) 與權限,像 :func:`os.chmod` 一樣。" -#: ../../library/pathlib.rst:1769 +#: ../../library/pathlib.rst:1765 msgid "" "This method normally follows symlinks. Some Unix flavours support changing " "permissions on the symlink itself; on these platforms you may add the " @@ -2934,7 +2921,7 @@ msgstr "" "此方法通常會跟隨符號連結。一些 Unix 類型支援修改符號連結本身的權限;在這些平" "台上你可以加上引數 ``follow_symlinks=False`` 或使用 :meth:`~Path.lchmod`。" -#: ../../library/pathlib.rst:1775 +#: ../../library/pathlib.rst:1771 msgid "" ">>> p = Path('setup.py')\n" ">>> p.stat().st_mode\n" @@ -2950,7 +2937,7 @@ msgstr "" ">>> p.stat().st_mode\n" "33060" -#: ../../library/pathlib.rst:1788 +#: ../../library/pathlib.rst:1784 msgid "" "Like :meth:`Path.chmod` but, if the path points to a symbolic link, the " "symbolic link's mode is changed rather than its target's." @@ -2958,11 +2945,11 @@ msgstr "" "類似 :meth:`Path.chmod`,但如果該路徑指向一個符號連結,則符號連結的模式 " "(mode) 會被改變而不是其指向的目標。" -#: ../../library/pathlib.rst:1795 +#: ../../library/pathlib.rst:1791 msgid "Pattern language" msgstr "模式語言 (pattern language)" -#: ../../library/pathlib.rst:1797 +#: ../../library/pathlib.rst:1793 msgid "" "The following wildcards are supported in patterns for :meth:`~PurePath." "full_match`, :meth:`~Path.glob` and :meth:`~Path.rglob`:" @@ -2970,43 +2957,43 @@ msgstr "" "以下的萬用字元在 :meth:`~PurePath.full_match`、:meth:`~Path.glob` 和 :meth:" "`~Path.rglob` 的模式中被支援:" -#: ../../library/pathlib.rst:1800 +#: ../../library/pathlib.rst:1796 msgid "``**`` (entire segment)" msgstr "``**``\\(整個片段)" -#: ../../library/pathlib.rst:1801 +#: ../../library/pathlib.rst:1797 msgid "Matches any number of file or directory segments, including zero." msgstr "匹配任何數量的檔案或目錄片段,包括零個。" -#: ../../library/pathlib.rst:1802 +#: ../../library/pathlib.rst:1798 msgid "``*`` (entire segment)" msgstr "``*``\\(整個片段)" -#: ../../library/pathlib.rst:1803 +#: ../../library/pathlib.rst:1799 msgid "Matches one file or directory segment." msgstr "匹配一個檔案或目錄的片段。" -#: ../../library/pathlib.rst:1804 +#: ../../library/pathlib.rst:1800 msgid "``*`` (part of a segment)" msgstr "``*``\\(片段的一部分)" -#: ../../library/pathlib.rst:1805 +#: ../../library/pathlib.rst:1801 msgid "Matches any number of non-separator characters, including zero." msgstr "匹配任意數量的非分隔字元,包括零個。" -#: ../../library/pathlib.rst:1806 +#: ../../library/pathlib.rst:1802 msgid "``?``" msgstr "``?``" -#: ../../library/pathlib.rst:1807 +#: ../../library/pathlib.rst:1803 msgid "Matches one non-separator character." msgstr "匹配一個非分隔字元。" -#: ../../library/pathlib.rst:1808 +#: ../../library/pathlib.rst:1804 msgid "``[seq]``" msgstr "``[seq]``" -#: ../../library/pathlib.rst:1809 +#: ../../library/pathlib.rst:1805 msgid "" "Matches one character in *seq*, where *seq* is a sequence of characters. " "Range expressions are supported; for example, ``[a-z]`` matches any " @@ -3014,17 +3001,17 @@ msgid "" "matches any ASCII letter, digit, or underscore." msgstr "" -#: ../../library/pathlib.rst:1813 +#: ../../library/pathlib.rst:1809 msgid "``[!seq]``" msgstr "``[!seq]``" -#: ../../library/pathlib.rst:1814 +#: ../../library/pathlib.rst:1810 msgid "" "Matches one character not in *seq*, where *seq* follows the same rules as " "above." msgstr "匹配一個不在 *seq* 中的字元,其中 *seq* 遵循上述相同的規則。" -#: ../../library/pathlib.rst:1816 +#: ../../library/pathlib.rst:1812 msgid "" "For a literal match, wrap the meta-characters in brackets. For example, " "``\"[?]\"`` matches the character ``\"?\"``." @@ -3032,52 +3019,52 @@ msgstr "" "對於文本 (literal) 匹配,可以用方括號包裝元字元 (meta-characters)。例如," "``\"[?]\"`` 會匹配字元 ``\"?\"``。" -#: ../../library/pathlib.rst:1819 +#: ../../library/pathlib.rst:1815 msgid "The \"``**``\" wildcard enables recursive globbing. A few examples:" msgstr "\"``**``\" 萬用字元讓它可以做遞迴 glob。例如:" -#: ../../library/pathlib.rst:1822 +#: ../../library/pathlib.rst:1818 msgid "Pattern" msgstr "模式" -#: ../../library/pathlib.rst:1822 +#: ../../library/pathlib.rst:1818 msgid "Meaning" msgstr "意涵" -#: ../../library/pathlib.rst:1824 +#: ../../library/pathlib.rst:1820 msgid "\"``**/*``\"" msgstr "\"``**/*``\"" -#: ../../library/pathlib.rst:1824 +#: ../../library/pathlib.rst:1820 msgid "Any path with at least one segment." msgstr "至少有一個片段的路徑。" -#: ../../library/pathlib.rst:1825 +#: ../../library/pathlib.rst:1821 msgid "\"``**/*.py``\"" msgstr "\"``**/*.py``\"" -#: ../../library/pathlib.rst:1825 +#: ../../library/pathlib.rst:1821 msgid "Any path with a final segment ending \"``.py``\"." msgstr "最後一個片段以 \"``.py``\" 結尾的任何路徑。" -#: ../../library/pathlib.rst:1826 +#: ../../library/pathlib.rst:1822 msgid "\"``assets/**``\"" msgstr "\"``assets/**``\"" -#: ../../library/pathlib.rst:1826 +#: ../../library/pathlib.rst:1822 msgid "Any path starting with \"``assets/``\"." msgstr "任何以 \"``assets/``\" 開頭的路徑。" -#: ../../library/pathlib.rst:1827 +#: ../../library/pathlib.rst:1823 msgid "\"``assets/**/*``\"" msgstr "\"``assets/**/*``\"" -#: ../../library/pathlib.rst:1827 +#: ../../library/pathlib.rst:1823 msgid "" "Any path starting with \"``assets/``\", excluding \"``assets/``\" itself." msgstr "任何以 \"``assets/``\" 開頭的路徑,不包括 \"``assets/``\" 本身。" -#: ../../library/pathlib.rst:1831 +#: ../../library/pathlib.rst:1827 msgid "" "Globbing with the \"``**``\" wildcard visits every directory in the tree. " "Large directory trees may take a long time to search." @@ -3085,7 +3072,7 @@ msgstr "" "Glob 使用 ``**`` 萬用字元會訪問目錄樹中的每個目錄。對於大型的目錄樹,搜尋可能" "需要花費很長的時間。" -#: ../../library/pathlib.rst:1834 +#: ../../library/pathlib.rst:1830 msgid "" "Globbing with a pattern that ends with \"``**``\" returns both files and " "directories. In previous versions, only directories were returned." @@ -3093,7 +3080,7 @@ msgstr "" "Glob 使用結尾為 ``**`` 的模式會同時回傳檔案和目錄。在先前版本中,只會回傳目" "錄。" -#: ../../library/pathlib.rst:1838 +#: ../../library/pathlib.rst:1834 msgid "" "In :meth:`Path.glob` and :meth:`~Path.rglob`, a trailing slash may be added " "to the pattern to match only directories." @@ -3101,7 +3088,7 @@ msgstr "" "在 :meth:`Path.glob` 和 :meth:`~Path.rglob` 中,可以在模式後面加上斜線以只匹" "配目錄。" -#: ../../library/pathlib.rst:1841 +#: ../../library/pathlib.rst:1837 msgid "" "Globbing with a pattern that ends with a pathname components separator (:" "data:`~os.sep` or :data:`~os.altsep`) returns only directories." @@ -3109,11 +3096,11 @@ msgstr "" "Glob 使用以路徑名稱組成的分隔符號(:data:`~os.sep` 或 :data:`~os.altsep`)作" "結尾的模式則只會回傳目錄。" -#: ../../library/pathlib.rst:1847 +#: ../../library/pathlib.rst:1843 msgid "Comparison to the :mod:`glob` module" msgstr "與 :mod:`glob` 模組的比較" -#: ../../library/pathlib.rst:1849 +#: ../../library/pathlib.rst:1845 msgid "" "The patterns accepted and results generated by :meth:`Path.glob` and :meth:" "`Path.rglob` differ slightly from those by the :mod:`glob` module:" @@ -3121,7 +3108,7 @@ msgstr "" ":meth:`Path.glob` 和 :meth:`Path.rglob` 接受的模式和產生的結果與 :mod:`glob` " "模組略有不同:" -#: ../../library/pathlib.rst:1852 +#: ../../library/pathlib.rst:1848 msgid "" "Files beginning with a dot are not special in pathlib. This is like passing " "``include_hidden=True`` to :func:`glob.glob`." @@ -3129,7 +3116,7 @@ msgstr "" "pathlib 中以點開頭的檔案並不特別。這和將 ``include_hidden=True`` 傳遞給 :" "func:`glob.glob` 相同。" -#: ../../library/pathlib.rst:1854 +#: ../../library/pathlib.rst:1850 msgid "" "\"``**``\" pattern components are always recursive in pathlib. This is like " "passing ``recursive=True`` to :func:`glob.glob`." @@ -3137,7 +3124,7 @@ msgstr "" "``**`` 模式組成在 pathlib 中總是遞迴的。這與將 ``recursive=True`` 傳遞給 :" "func:`glob.glob` 相同。" -#: ../../library/pathlib.rst:1856 +#: ../../library/pathlib.rst:1852 msgid "" "\"``**``\" pattern components do not follow symlinks by default in pathlib. " "This behaviour has no equivalent in :func:`glob.glob`, but you can pass " @@ -3147,7 +3134,7 @@ msgstr "" "有等效的行為,但你可以將 ``recurse_symlinks=True`` 傳遞給 :meth:`Path.glob` " "以獲得相容的行為。" -#: ../../library/pathlib.rst:1859 +#: ../../library/pathlib.rst:1855 msgid "" "Like all :class:`PurePath` and :class:`Path` objects, the values returned " "from :meth:`Path.glob` and :meth:`Path.rglob` don't include trailing slashes." @@ -3155,7 +3142,7 @@ msgstr "" "與所有 :class:`PurePath` 和 :class:`Path` 物件一樣,從 :meth:`Path.glob` 和 :" "meth:`Path.rglob` 回傳的值不包含結尾斜線。" -#: ../../library/pathlib.rst:1862 +#: ../../library/pathlib.rst:1858 msgid "" "The values returned from pathlib's ``path.glob()`` and ``path.rglob()`` " "include the *path* as a prefix, unlike the results of ``glob." @@ -3164,7 +3151,7 @@ msgstr "" "pathlib 的 ``path.glob()`` 和 ``path.rglob()`` 回傳的值包含了 *path* 作為前" "綴,而 ``glob.glob(root_dir=path)`` 的結果則不會如此。" -#: ../../library/pathlib.rst:1865 +#: ../../library/pathlib.rst:1861 msgid "" "The values returned from pathlib's ``path.glob()`` and ``path.rglob()`` may " "include *path* itself, for example when globbing \"``**``\", whereas the " @@ -3175,11 +3162,11 @@ msgstr "" "例如當使用 \"``**``\" 做 glob 的時候,然而 ``glob.glob(root_dir=path)`` 的結" "果則永遠不會包含一個對應到 *path* 的空字串。" -#: ../../library/pathlib.rst:1872 +#: ../../library/pathlib.rst:1868 msgid "Comparison to the :mod:`os` and :mod:`os.path` modules" msgstr "與 :mod:`os` 和 :mod:`os.path` 模組的比較" -#: ../../library/pathlib.rst:1874 +#: ../../library/pathlib.rst:1870 msgid "" "pathlib implements path operations using :class:`PurePath` and :class:`Path` " "objects, and so it's said to be *object-oriented*. On the other hand, the :" @@ -3192,7 +3179,7 @@ msgstr "" "與底層 ``str`` 和 ``bytes`` 物件互動的函式,這是一種更\\ *程序式*\\ 的方法。" "有些使用者認為物件導向的風格更易讀。" -#: ../../library/pathlib.rst:1880 +#: ../../library/pathlib.rst:1876 msgid "" "Many functions in :mod:`os` and :mod:`os.path` support ``bytes`` paths and :" "ref:`paths relative to directory descriptors `. These features " @@ -3202,7 +3189,7 @@ msgstr "" "徑的目錄描述器 (paths relative to directory descriptors) `。這些功能" "在 pathlib 中不可用。" -#: ../../library/pathlib.rst:1884 +#: ../../library/pathlib.rst:1880 msgid "" "Python's ``str`` and ``bytes`` types, and portions of the :mod:`os` and :mod:" "`os.path` modules, are written in C and are very speedy. pathlib is written " @@ -3212,7 +3199,7 @@ msgstr "" "一些部分,是用 C 寫的且非常快速。pathlib 是用純 Python 寫的且通常比較慢,但很" "少會慢到足以產生影響。" -#: ../../library/pathlib.rst:1888 +#: ../../library/pathlib.rst:1884 msgid "" "pathlib's path normalization is slightly more opinionated and consistent " "than :mod:`os.path`. For example, whereas :func:`os.path.abspath` eliminates " @@ -3224,12 +3211,12 @@ msgstr "" "path.abspath` 會從路徑中移除 \"``..``\" 片段,如果包含符號連結的話這可能會改" "變其意義,而 :meth:`Path.absolute` 則會保留這些片段以增加安全性。" -#: ../../library/pathlib.rst:1893 +#: ../../library/pathlib.rst:1889 msgid "" "pathlib's path normalization may render it unsuitable for some applications:" msgstr "pathlib 的路徑正規化可能會使它不適合某些應用程式:" -#: ../../library/pathlib.rst:1895 +#: ../../library/pathlib.rst:1891 msgid "" "pathlib normalizes ``Path(\"my_folder/\")`` to ``Path(\"my_folder\")``, " "which changes a path's meaning when supplied to various operating system " @@ -3241,7 +3228,7 @@ msgstr "" "提供給各種作業系統 API 和命令列工具時改變路徑的意義。具體來說,缺少結尾分隔符" "號可能會允許該路徑被解析為檔案或目錄,而不只是目錄。" -#: ../../library/pathlib.rst:1900 +#: ../../library/pathlib.rst:1896 msgid "" "pathlib normalizes ``Path(\"./my_program\")`` to ``Path(\"my_program\")``, " "which changes a path's meaning when used as an executable search path, such " @@ -3254,17 +3241,17 @@ msgstr "" "程時。具體來說,在路徑中缺少分隔符號可能會使其強制在 :envvar:`PATH` 中尋找," "而不是目前目錄。" -#: ../../library/pathlib.rst:1906 +#: ../../library/pathlib.rst:1902 msgid "" "As a consequence of these differences, pathlib is not a drop-in replacement " "for :mod:`os.path`." msgstr "因為這些差異,pathlib 不是 :mod:`os.path` 的直接替代品。" -#: ../../library/pathlib.rst:1911 +#: ../../library/pathlib.rst:1907 msgid "Corresponding tools" msgstr "對應工具" -#: ../../library/pathlib.rst:1913 +#: ../../library/pathlib.rst:1909 msgid "" "Below is a table mapping various :mod:`os` functions to their corresponding :" "class:`PurePath`/:class:`Path` equivalent." @@ -3272,267 +3259,267 @@ msgstr "" "以下是一張表格,對應許多 :mod:`os` 函式及其相符於 :class:`PurePath`/:class:" "`Path` 的項目。" -#: ../../library/pathlib.rst:1917 +#: ../../library/pathlib.rst:1913 msgid ":mod:`os` and :mod:`os.path`" msgstr ":mod:`os` 和 :mod:`os.path`" -#: ../../library/pathlib.rst:1917 +#: ../../library/pathlib.rst:1913 msgid ":mod:`!pathlib`" msgstr ":mod:`!pathlib`" -#: ../../library/pathlib.rst:1919 +#: ../../library/pathlib.rst:1915 msgid ":func:`os.path.dirname`" msgstr ":func:`os.path.dirname`" -#: ../../library/pathlib.rst:1919 +#: ../../library/pathlib.rst:1915 msgid ":attr:`PurePath.parent`" msgstr ":attr:`PurePath.parent`" -#: ../../library/pathlib.rst:1920 +#: ../../library/pathlib.rst:1916 msgid ":func:`os.path.basename`" msgstr ":func:`os.path.basename`" -#: ../../library/pathlib.rst:1920 +#: ../../library/pathlib.rst:1916 msgid ":attr:`PurePath.name`" msgstr ":attr:`PurePath.name`" -#: ../../library/pathlib.rst:1921 +#: ../../library/pathlib.rst:1917 msgid ":func:`os.path.splitext`" msgstr ":func:`os.path.splitext`" -#: ../../library/pathlib.rst:1921 +#: ../../library/pathlib.rst:1917 msgid ":attr:`PurePath.stem`, :attr:`PurePath.suffix`" msgstr ":attr:`PurePath.stem` 和 :attr:`PurePath.suffix`" -#: ../../library/pathlib.rst:1922 +#: ../../library/pathlib.rst:1918 msgid ":func:`os.path.join`" msgstr ":func:`os.path.join`" -#: ../../library/pathlib.rst:1922 +#: ../../library/pathlib.rst:1918 msgid ":meth:`PurePath.joinpath`" msgstr ":meth:`PurePath.joinpath`" -#: ../../library/pathlib.rst:1923 +#: ../../library/pathlib.rst:1919 msgid ":func:`os.path.isabs`" msgstr ":func:`os.path.isabs`" -#: ../../library/pathlib.rst:1923 +#: ../../library/pathlib.rst:1919 msgid ":meth:`PurePath.is_absolute`" msgstr ":meth:`PurePath.is_absolute`" -#: ../../library/pathlib.rst:1924 +#: ../../library/pathlib.rst:1920 msgid ":func:`os.path.relpath`" msgstr ":func:`os.path.relpath`" -#: ../../library/pathlib.rst:1924 +#: ../../library/pathlib.rst:1920 msgid ":meth:`PurePath.relative_to` [1]_" msgstr ":meth:`PurePath.relative_to` [1]_" -#: ../../library/pathlib.rst:1925 +#: ../../library/pathlib.rst:1921 msgid ":func:`os.path.expanduser`" msgstr ":func:`os.path.expanduser`" -#: ../../library/pathlib.rst:1925 +#: ../../library/pathlib.rst:1921 msgid ":meth:`Path.expanduser` [2]_" msgstr ":meth:`Path.expanduser` [2]_" -#: ../../library/pathlib.rst:1926 +#: ../../library/pathlib.rst:1922 msgid ":func:`os.path.realpath`" msgstr ":func:`os.path.realpath`" -#: ../../library/pathlib.rst:1926 +#: ../../library/pathlib.rst:1922 msgid ":meth:`Path.resolve`" msgstr ":meth:`Path.resolve`" -#: ../../library/pathlib.rst:1927 +#: ../../library/pathlib.rst:1923 msgid ":func:`os.path.abspath`" msgstr ":func:`os.path.abspath`" -#: ../../library/pathlib.rst:1927 +#: ../../library/pathlib.rst:1923 msgid ":meth:`Path.absolute` [3]_" msgstr ":meth:`Path.absolute` [3]_" -#: ../../library/pathlib.rst:1928 +#: ../../library/pathlib.rst:1924 msgid ":func:`os.path.exists`" msgstr ":func:`os.path.exists`" -#: ../../library/pathlib.rst:1928 +#: ../../library/pathlib.rst:1924 msgid ":meth:`Path.exists`" msgstr ":meth:`Path.exists`" -#: ../../library/pathlib.rst:1929 +#: ../../library/pathlib.rst:1925 msgid ":func:`os.path.isfile`" msgstr ":func:`os.path.isfile`" -#: ../../library/pathlib.rst:1929 +#: ../../library/pathlib.rst:1925 msgid ":meth:`Path.is_file`" msgstr ":meth:`Path.is_file`" -#: ../../library/pathlib.rst:1930 +#: ../../library/pathlib.rst:1926 msgid ":func:`os.path.isdir`" msgstr ":func:`os.path.isdir`" -#: ../../library/pathlib.rst:1930 +#: ../../library/pathlib.rst:1926 msgid ":meth:`Path.is_dir`" msgstr ":meth:`Path.is_dir`" -#: ../../library/pathlib.rst:1931 +#: ../../library/pathlib.rst:1927 msgid ":func:`os.path.islink`" msgstr ":func:`os.path.islink`" -#: ../../library/pathlib.rst:1931 +#: ../../library/pathlib.rst:1927 msgid ":meth:`Path.is_symlink`" msgstr ":meth:`Path.is_symlink`" -#: ../../library/pathlib.rst:1932 +#: ../../library/pathlib.rst:1928 msgid ":func:`os.path.isjunction`" msgstr ":func:`os.path.isjunction`" -#: ../../library/pathlib.rst:1932 +#: ../../library/pathlib.rst:1928 msgid ":meth:`Path.is_junction`" msgstr ":meth:`Path.is_junction`" -#: ../../library/pathlib.rst:1933 +#: ../../library/pathlib.rst:1929 msgid ":func:`os.path.ismount`" msgstr ":func:`os.path.ismount`" -#: ../../library/pathlib.rst:1933 +#: ../../library/pathlib.rst:1929 msgid ":meth:`Path.is_mount`" msgstr ":meth:`Path.is_mount`" -#: ../../library/pathlib.rst:1934 +#: ../../library/pathlib.rst:1930 msgid ":func:`os.path.samefile`" msgstr ":func:`os.path.samefile`" -#: ../../library/pathlib.rst:1934 +#: ../../library/pathlib.rst:1930 msgid ":meth:`Path.samefile`" msgstr ":meth:`Path.samefile`" -#: ../../library/pathlib.rst:1935 +#: ../../library/pathlib.rst:1931 msgid ":func:`os.getcwd`" msgstr ":func:`os.getcwd`" -#: ../../library/pathlib.rst:1935 +#: ../../library/pathlib.rst:1931 msgid ":meth:`Path.cwd`" msgstr ":meth:`Path.cwd`" -#: ../../library/pathlib.rst:1936 +#: ../../library/pathlib.rst:1932 msgid ":func:`os.stat`" msgstr ":func:`os.stat`" -#: ../../library/pathlib.rst:1936 +#: ../../library/pathlib.rst:1932 msgid ":meth:`Path.stat`" msgstr ":meth:`Path.stat`" -#: ../../library/pathlib.rst:1937 +#: ../../library/pathlib.rst:1933 msgid ":func:`os.lstat`" msgstr ":func:`os.lstat`" -#: ../../library/pathlib.rst:1937 +#: ../../library/pathlib.rst:1933 msgid ":meth:`Path.lstat`" msgstr ":meth:`Path.lstat`" -#: ../../library/pathlib.rst:1938 +#: ../../library/pathlib.rst:1934 msgid ":func:`os.listdir`" msgstr ":func:`os.listdir`" -#: ../../library/pathlib.rst:1938 +#: ../../library/pathlib.rst:1934 msgid ":meth:`Path.iterdir`" msgstr ":meth:`Path.iterdir`" -#: ../../library/pathlib.rst:1939 +#: ../../library/pathlib.rst:1935 msgid ":func:`os.walk`" msgstr ":func:`os.walk`" -#: ../../library/pathlib.rst:1939 +#: ../../library/pathlib.rst:1935 msgid ":meth:`Path.walk` [4]_" msgstr ":meth:`Path.walk` [4]_" -#: ../../library/pathlib.rst:1940 +#: ../../library/pathlib.rst:1936 msgid ":func:`os.mkdir`, :func:`os.makedirs`" msgstr ":func:`os.mkdir`、:func:`os.makedirs`" -#: ../../library/pathlib.rst:1940 +#: ../../library/pathlib.rst:1936 msgid ":meth:`Path.mkdir`" msgstr ":meth:`Path.mkdir`" -#: ../../library/pathlib.rst:1941 +#: ../../library/pathlib.rst:1937 msgid ":func:`os.link`" msgstr ":func:`os.link`" -#: ../../library/pathlib.rst:1941 +#: ../../library/pathlib.rst:1937 msgid ":meth:`Path.hardlink_to`" msgstr ":meth:`Path.hardlink_to`" -#: ../../library/pathlib.rst:1942 +#: ../../library/pathlib.rst:1938 msgid ":func:`os.symlink`" msgstr ":func:`os.symlink`" -#: ../../library/pathlib.rst:1942 +#: ../../library/pathlib.rst:1938 msgid ":meth:`Path.symlink_to`" msgstr ":meth:`Path.symlink_to`" -#: ../../library/pathlib.rst:1943 +#: ../../library/pathlib.rst:1939 msgid ":func:`os.readlink`" msgstr ":func:`os.readlink`" -#: ../../library/pathlib.rst:1943 +#: ../../library/pathlib.rst:1939 msgid ":meth:`Path.readlink`" msgstr ":meth:`Path.readlink`" -#: ../../library/pathlib.rst:1944 +#: ../../library/pathlib.rst:1940 msgid ":func:`os.rename`" msgstr ":func:`os.rename`" -#: ../../library/pathlib.rst:1944 +#: ../../library/pathlib.rst:1940 msgid ":meth:`Path.rename`" msgstr ":meth:`Path.rename`" -#: ../../library/pathlib.rst:1945 +#: ../../library/pathlib.rst:1941 msgid ":func:`os.replace`" msgstr ":func:`os.replace`" -#: ../../library/pathlib.rst:1945 +#: ../../library/pathlib.rst:1941 msgid ":meth:`Path.replace`" msgstr ":meth:`Path.replace`" -#: ../../library/pathlib.rst:1946 +#: ../../library/pathlib.rst:1942 msgid ":func:`os.remove`, :func:`os.unlink`" msgstr ":func:`os.remove`、:func:`os.unlink`" -#: ../../library/pathlib.rst:1946 +#: ../../library/pathlib.rst:1942 msgid ":meth:`Path.unlink`" msgstr ":meth:`Path.unlink`" -#: ../../library/pathlib.rst:1947 +#: ../../library/pathlib.rst:1943 msgid ":func:`os.rmdir`" msgstr ":func:`os.rmdir`" -#: ../../library/pathlib.rst:1947 +#: ../../library/pathlib.rst:1943 msgid ":meth:`Path.rmdir`" msgstr ":meth:`Path.rmdir`" -#: ../../library/pathlib.rst:1948 +#: ../../library/pathlib.rst:1944 msgid ":func:`os.chmod`" msgstr ":func:`os.chmod`" -#: ../../library/pathlib.rst:1948 +#: ../../library/pathlib.rst:1944 msgid ":meth:`Path.chmod`" msgstr ":meth:`Path.chmod`" -#: ../../library/pathlib.rst:1949 +#: ../../library/pathlib.rst:1945 msgid ":func:`os.lchmod`" msgstr ":func:`os.lchmod`" -#: ../../library/pathlib.rst:1949 +#: ../../library/pathlib.rst:1945 msgid ":meth:`Path.lchmod`" msgstr ":meth:`Path.lchmod`" -#: ../../library/pathlib.rst:1953 +#: ../../library/pathlib.rst:1949 msgid "Footnotes" msgstr "註腳" -#: ../../library/pathlib.rst:1954 +#: ../../library/pathlib.rst:1950 msgid "" ":func:`os.path.relpath` calls :func:`~os.path.abspath` to make paths " "absolute and remove \"``..``\" parts, whereas :meth:`PurePath.relative_to` " @@ -3544,7 +3531,7 @@ msgstr "" "當它輸入的錨點不同時(例如一個是絕對路徑,另一個則是相對路徑)會引發 :exc:" "`ValueError`。" -#: ../../library/pathlib.rst:1958 +#: ../../library/pathlib.rst:1954 msgid "" ":func:`os.path.expanduser` returns the path unchanged if the home directory " "can't be resolved, whereas :meth:`Path.expanduser` raises :exc:" @@ -3553,7 +3540,7 @@ msgstr "" ":func:`os.path.expanduser` 會在無法解析家目錄時回傳原始路徑,而 :meth:`Path." "expanduser` 則會引發 :exc:`RuntimeError`。" -#: ../../library/pathlib.rst:1961 +#: ../../library/pathlib.rst:1957 msgid "" ":func:`os.path.abspath` removes \"``..``\" components without resolving " "symlinks, which may change the meaning of the path, whereas :meth:`Path." @@ -3562,7 +3549,7 @@ msgstr "" ":func:`os.path.abspath` 將 \"``..``\" 組成移除而不解析符號連結,這可能會改變" "路徑的意義,而 :meth:`Path.absolute` 則會保留路徑中任何 \"``..``\" 組成。" -#: ../../library/pathlib.rst:1964 +#: ../../library/pathlib.rst:1960 msgid "" ":func:`os.walk` always follows symlinks when categorizing paths into " "*dirnames* and *filenames*, whereas :meth:`Path.walk` categorizes all " @@ -3572,23 +3559,23 @@ msgstr "" "而 :meth:`Path.walk` 在 *follow_symlinks* 為 false(預設值)時,會將所有符號" "連結都分類為 *filenames*。" -#: ../../library/pathlib.rst:1970 +#: ../../library/pathlib.rst:1966 msgid "Protocols" msgstr "" -#: ../../library/pathlib.rst:1976 +#: ../../library/pathlib.rst:1972 msgid "" "The :mod:`!pathlib.types` module provides types for static type checking." msgstr "" -#: ../../library/pathlib.rst:1983 +#: ../../library/pathlib.rst:1979 msgid "" "A :class:`typing.Protocol` describing the :attr:`Path.info ` attribute. Implementations may return cached results from their " "methods." msgstr "" -#: ../../library/pathlib.rst:1989 +#: ../../library/pathlib.rst:1985 msgid "" "Return ``True`` if the path is an existing file or directory, or any other " "kind of file; return ``False`` if the path doesn't exist." @@ -3596,41 +3583,41 @@ msgstr "" "如果路徑是個存在的檔案、目錄或任何其他類型的檔案則回傳 ``True``,如果路徑不存" "在則回傳 ``False``。" -#: ../../library/pathlib.rst:1992 +#: ../../library/pathlib.rst:1988 msgid "" "If *follow_symlinks* is ``False``, return ``True`` for symlinks without " "checking if their targets exist." msgstr "" -#: ../../library/pathlib.rst:1997 +#: ../../library/pathlib.rst:1993 msgid "" "Return ``True`` if the path is a directory, or a symbolic link pointing to a " "directory; return ``False`` if the path is (or points to) any other kind of " "file, or if it doesn't exist." msgstr "" -#: ../../library/pathlib.rst:2001 +#: ../../library/pathlib.rst:1997 msgid "" "If *follow_symlinks* is ``False``, return ``True`` only if the path is a " "directory (without following symlinks); return ``False`` if the path is any " "other kind of file, or if it doesn't exist." msgstr "" -#: ../../library/pathlib.rst:2007 +#: ../../library/pathlib.rst:2003 msgid "" "Return ``True`` if the path is a file, or a symbolic link pointing to a " "file; return ``False`` if the path is (or points to) a directory or other " "non-file, or if it doesn't exist." msgstr "" -#: ../../library/pathlib.rst:2011 +#: ../../library/pathlib.rst:2007 msgid "" "If *follow_symlinks* is ``False``, return ``True`` only if the path is a " "file (without following symlinks); return ``False`` if the path is a " "directory or other non-file, or if it doesn't exist." msgstr "" -#: ../../library/pathlib.rst:2017 +#: ../../library/pathlib.rst:2013 msgid "" "Return ``True`` if the path is a symbolic link (even if broken); return " "``False`` if the path is a directory or any kind of file, or if it doesn't " @@ -3645,6 +3632,29 @@ msgstr "path(路徑)" msgid "operations" msgstr "operations(操作)" +#~ msgid "" +#~ "With :class:`PureWindowsPath`, return ``True`` if the path is considered " +#~ "reserved under Windows, ``False`` otherwise. With :class:" +#~ "`PurePosixPath`, ``False`` is always returned." +#~ msgstr "" +#~ "對 :class:`PureWindowsPath` 來說,當路徑在 Windows 下被視為保留的話會回傳 " +#~ "``True``,否則回傳 ``False``。對 :class:`PurePosixPath` 來說,總是回傳 " +#~ "``False``。" + +#~ msgid "" +#~ "Windows path names that contain a colon, or end with a dot or a space, " +#~ "are considered reserved. UNC paths may be reserved." +#~ msgstr "" +#~ "Windows 路徑名稱中包含冒號或結尾為點或空格會被視為保留。UNC 路徑可能被視為" +#~ "保留。" + +#~ msgid "" +#~ "This method is deprecated; use :func:`os.path.isreserved` to detect " +#~ "reserved paths on Windows." +#~ msgstr "" +#~ "此方法已被棄用;請使用 :func:`os.path.isreserved` 來檢測 Windows 上的保留" +#~ "路徑。" + #~ msgid "" #~ ">>> PurePath()\n" #~ "PurePosixPath('.')" diff --git a/library/pdb.po b/library/pdb.po index b73cbe96f40..39a4866df4a 100644 --- a/library/pdb.po +++ b/library/pdb.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-10 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-10-19 17:39+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -864,10 +864,12 @@ msgstr "" #: ../../library/pdb.rst:523 msgid "" -"With no *bpnumber* argument, ``commands`` refers to the last breakpoint set." -msgstr "不帶有 *bpnumber* 引數則 ``commands`` 會關聯到上一個設定的斷點。" +"With no *bpnumber* argument, ``commands`` refers to the most recently set " +"breakpoint that still exists." +msgstr "" +"不帶有 *bpnumber* 引數則 ``commands`` 會關聯到最近一個設定且仍存在的斷點。" -#: ../../library/pdb.rst:525 +#: ../../library/pdb.rst:526 msgid "" "You can use breakpoint commands to start your program up again. Simply use " "the :pdbcmd:`continue` command, or :pdbcmd:`step`, or any other command that " @@ -876,7 +878,7 @@ msgstr "" "可以使用斷點命令來重新啟動程式,只需使用 :pdbcmd:`continue` 或 :pdbcmd:" "`step` 命令,或其他可以繼續執行程式的命令。" -#: ../../library/pdb.rst:529 +#: ../../library/pdb.rst:530 msgid "" "Specifying any command resuming execution (currently :pdbcmd:`continue`, :" "pdbcmd:`step`, :pdbcmd:`next`, :pdbcmd:`return`, :pdbcmd:`until`, :pdbcmd:" @@ -892,20 +894,20 @@ msgstr "" "在任何時候繼續執行下去(即使是簡單的 next 或 step),都可能會遇到另一個斷點," "該斷點可能具有自己的命令列表,這會導致無法確定要執行哪個列表。" -#: ../../library/pdb.rst:538 +#: ../../library/pdb.rst:539 msgid "" "If the list of commands contains the ``silent`` command, or a command that " "resumes execution, then the breakpoint message containing information about " "the frame is not displayed." msgstr "" -#: ../../library/pdb.rst:542 +#: ../../library/pdb.rst:543 msgid "" "Frame information will not be displayed if a command that resumes execution " "is present in the command list." msgstr "" -#: ../../library/pdb.rst:548 +#: ../../library/pdb.rst:549 msgid "" "Execute the current line, stop at the first possible occasion (either in a " "function that is called or on the next line in the current function)." @@ -913,7 +915,7 @@ msgstr "" "執行目前列,在第一個可以停止的位置(在被呼叫的函式內部或在目前函式的下一列)" "停止。" -#: ../../library/pdb.rst:553 +#: ../../library/pdb.rst:554 msgid "" "Continue execution until the next line in the current function is reached or " "it returns. (The difference between :pdbcmd:`next` and :pdbcmd:`step` is " @@ -926,13 +928,13 @@ msgstr "" "而 :pdbcmd:`next`\\ (幾乎)全速執行被呼叫的函式,並僅在目前函式的下一列停" "止。)" -#: ../../library/pdb.rst:561 +#: ../../library/pdb.rst:562 msgid "" "Without argument, continue execution until the line with a number greater " "than the current one is reached." msgstr "如果不帶引數則繼續執行,直到列號比目前的列大時停止。" -#: ../../library/pdb.rst:564 +#: ../../library/pdb.rst:565 msgid "" "With *lineno*, continue execution until a line with a number greater or " "equal to *lineno* is reached. In both cases, also stop when the current " @@ -941,19 +943,19 @@ msgstr "" "如帶有 *lineno* 則繼續執行,直到到達列號大於或等於 *lineno* 的那一列。在這兩" "種情況下,目前 frame 回傳時也會停止。" -#: ../../library/pdb.rst:568 +#: ../../library/pdb.rst:569 msgid "Allow giving an explicit line number." msgstr "允許明確給定一個列號。" -#: ../../library/pdb.rst:573 +#: ../../library/pdb.rst:574 msgid "Continue execution until the current function returns." msgstr "繼續執行,直到目前的函式回傳。" -#: ../../library/pdb.rst:577 +#: ../../library/pdb.rst:578 msgid "Continue execution, only stop when a breakpoint is encountered." msgstr "繼續執行,除非遇到斷點才停下來。" -#: ../../library/pdb.rst:581 +#: ../../library/pdb.rst:582 msgid "" "Set the next line that will be executed. Only available in the bottom-most " "frame. This lets you jump back and execute code again, or jump forward to " @@ -962,7 +964,7 @@ msgstr "" "設定即將執行的下一列,僅可用於堆疊中最底部的 frame。這讓你可以跳回去並再次執" "行程式碼,或者往前跳以跳過不想執行的程式碼。" -#: ../../library/pdb.rst:585 +#: ../../library/pdb.rst:586 msgid "" "It should be noted that not all jumps are allowed -- for instance it is not " "possible to jump into the middle of a :keyword:`for` loop or out of a :" @@ -971,7 +973,7 @@ msgstr "" "需要注意的是,不是所有的跳轉都是被允許的 -- 例如不能跳轉到 :keyword:`for` 迴" "圈的中間或跳出 :keyword:`finally` 子句。" -#: ../../library/pdb.rst:591 +#: ../../library/pdb.rst:592 msgid "" "List source code for the current file. Without arguments, list 11 lines " "around the current line or continue the previous listing. With ``.`` as " @@ -984,7 +986,7 @@ msgstr "" "列出那一列周圍的 11 列。如果帶有兩個引數,則列出給定範圍中的程式碼;如果第二" "個引數小於第一個引數,則將其直譯為要列出的列數。" -#: ../../library/pdb.rst:597 +#: ../../library/pdb.rst:598 msgid "" "The current line in the current frame is indicated by ``->``. If an " "exception is being debugged, the line where the exception was originally " @@ -994,26 +996,26 @@ msgstr "" "目前 frame 中的目前列會用 ``->`` 標記出來。如果正在偵錯一個例外,且引發或傳遞" "該例外的那一列不是目前列,則會用 ``>>`` 來標記該列。" -#: ../../library/pdb.rst:602 +#: ../../library/pdb.rst:603 msgid "Added the ``>>`` marker." msgstr "新增了 ``>>`` 標記。" -#: ../../library/pdb.rst:607 +#: ../../library/pdb.rst:608 msgid "" "List all source code for the current function or frame. Interesting lines " "are marked as for :pdbcmd:`list`." msgstr "" "列出目前函式或 frame 的所有原始碼。相關列的標記方式與 :pdbcmd:`list` 相同。" -#: ../../library/pdb.rst:614 +#: ../../library/pdb.rst:615 msgid "Print the arguments of the current function and their current values." msgstr "印出目前函式的引數及它們目前的值。" -#: ../../library/pdb.rst:618 +#: ../../library/pdb.rst:619 msgid "Evaluate *expression* in the current context and print its value." msgstr "在目前情境中為 *expression* 求值並印出其值。" -#: ../../library/pdb.rst:622 +#: ../../library/pdb.rst:623 msgid "" "``print()`` can also be used, but is not a debugger command --- this " "executes the Python :func:`print` function." @@ -1021,7 +1023,7 @@ msgstr "" "也可以使用 ``print()``,但它不是一個偵錯器命令 --- 它會執行 Python :func:" "`print` 函式。" -#: ../../library/pdb.rst:628 +#: ../../library/pdb.rst:629 msgid "" "Like the :pdbcmd:`p` command, except the value of *expression* is pretty-" "printed using the :mod:`pprint` module." @@ -1029,26 +1031,26 @@ msgstr "" "與 :pdbcmd:`p` 命令類似,除了 *expression* 的值是使用 :mod:`pprint` 模組美化" "後印出來的。" -#: ../../library/pdb.rst:633 +#: ../../library/pdb.rst:634 msgid "Print the type of *expression*." msgstr "印出 *expression* 的型別。" -#: ../../library/pdb.rst:637 +#: ../../library/pdb.rst:638 msgid "Try to get source code of *expression* and display it." msgstr "嘗試取得 *expression* 的原始碼並顯示它。" -#: ../../library/pdb.rst:643 +#: ../../library/pdb.rst:644 msgid "" "Display the value of *expression* if it changed, each time execution stops " "in the current frame." msgstr "每次在目前 frame 中停止執行時,顯示 *expression* 的值(如果有變更)。" -#: ../../library/pdb.rst:646 +#: ../../library/pdb.rst:647 msgid "" "Without *expression*, list all display expressions for the current frame." msgstr "如果不帶有 *expression*,則列出目前 frame 的所有運算式。" -#: ../../library/pdb.rst:650 +#: ../../library/pdb.rst:651 msgid "" "Display evaluates *expression* and compares to the result of the previous " "evaluation of *expression*, so when the result is mutable, display may not " @@ -1057,11 +1059,11 @@ msgstr "" "display 會對 *expression* 求值並將結果與之前 *expression* 的求值結果進行比" "較,因此當結果可變時,display 可能無法取得其變更。" -#: ../../library/pdb.rst:654 ../../library/pdb.rst:819 +#: ../../library/pdb.rst:655 ../../library/pdb.rst:820 msgid "Example::" msgstr "範例如下: ::" -#: ../../library/pdb.rst:656 +#: ../../library/pdb.rst:657 msgid "" "lst = []\n" "breakpoint()\n" @@ -1075,7 +1077,7 @@ msgstr "" "lst.append(1)\n" "print(lst)" -#: ../../library/pdb.rst:662 +#: ../../library/pdb.rst:663 msgid "" "Display won't realize ``lst`` has been changed because the result of " "evaluation is modified in place by ``lst.append(1)`` before being compared::" @@ -1083,7 +1085,7 @@ msgstr "" "display 不會意識到 ``lst`` 已更改,因為其求值結果在比較之前已被 ``lst." "append(1)`` 原地 (in place) 修改: ::" -#: ../../library/pdb.rst:665 +#: ../../library/pdb.rst:666 msgid "" "> example.py(3)()\n" "-> pass\n" @@ -1109,11 +1111,11 @@ msgstr "" "-> print(lst)\n" "(Pdb)" -#: ../../library/pdb.rst:677 +#: ../../library/pdb.rst:678 msgid "You can do some tricks with copy mechanism to make it work::" msgstr "你可以運用複製機制的一些技巧來使其能夠運作: ::" -#: ../../library/pdb.rst:679 +#: ../../library/pdb.rst:680 msgid "" "> example.py(3)()\n" "-> pass\n" @@ -1141,7 +1143,7 @@ msgstr "" "display lst[:]: [1] [old: []]\n" "(Pdb)" -#: ../../library/pdb.rst:696 +#: ../../library/pdb.rst:697 msgid "" "Do not display *expression* anymore in the current frame. Without " "*expression*, clear all display expressions for the current frame." @@ -1149,7 +1151,7 @@ msgstr "" "不再顯示目前 frame 中的 *expression*。如果不帶有 *expression*,則清除目前 " "frame 的所有顯示運算式。" -#: ../../library/pdb.rst:703 +#: ../../library/pdb.rst:704 msgid "" "Start an interactive interpreter (using the :mod:`code` module) in a new " "global namespace initialised from the local and global namespaces for the " @@ -1160,7 +1162,7 @@ msgstr "" "(使用 :mod:`code` 模組)。可使用 ``exit()`` 或 ``quit()`` 退出直譯器並回到偵" "錯器。" -#: ../../library/pdb.rst:710 +#: ../../library/pdb.rst:711 msgid "" "As ``interact`` creates a new dedicated namespace for code execution, " "assignments to variables will not affect the original namespaces. However, " @@ -1171,12 +1173,12 @@ msgstr "" "影響原始命名空間,但是對任何被參照的可變物件的修改將像往常一樣反映在原始命名" "空間中。" -#: ../../library/pdb.rst:717 +#: ../../library/pdb.rst:718 msgid "" "``exit()`` and ``quit()`` can be used to exit the :pdbcmd:`interact` command." msgstr "``exit()`` 和 ``quit()`` 可用來退出 :pdbcmd:`interact` 命令。" -#: ../../library/pdb.rst:721 +#: ../../library/pdb.rst:722 msgid "" ":pdbcmd:`interact` directs its output to the debugger's output channel " "rather than :data:`sys.stderr`." @@ -1184,7 +1186,7 @@ msgstr "" ":pdbcmd:`interact` 將其輸出導向到偵錯器的輸出通道 (output channel),而不是 :" "data:`sys.stderr`。" -#: ../../library/pdb.rst:729 +#: ../../library/pdb.rst:730 msgid "" "Create an alias called *name* that executes *command*. The *command* must " "*not* be enclosed in quotes. Replaceable parameters can be indicated by " @@ -1197,7 +1199,7 @@ msgstr "" "有參數替換。如果省略 *command*,則顯示 *name* 的目前別名。如果未給定引數,則" "列出所有別名。" -#: ../../library/pdb.rst:735 +#: ../../library/pdb.rst:736 msgid "" "Aliases may be nested and can contain anything that can be legally typed at " "the pdb prompt. Note that internal pdb commands *can* be overridden by " @@ -1209,14 +1211,14 @@ msgstr "" "部 pdb 命令\\ *可以*\\ 被別名所覆蓋。這樣的命令在別名被移除前都將被隱藏。別名" "會遞迴地應用到命令列的第一個單詞;該列內的其他單詞則不會受影響。" -#: ../../library/pdb.rst:741 +#: ../../library/pdb.rst:742 msgid "" "As an example, here are two useful aliases (especially when placed in the :" "file:`.pdbrc` file)::" msgstr "" "作為範例,這裡列出了兩個有用的別名(特別是放在 :file:`.pdbrc` 檔案中時): ::" -#: ../../library/pdb.rst:744 +#: ../../library/pdb.rst:745 msgid "" "# Print instance variables (usage \"pi classInst\")\n" "alias pi for k in %1.__dict__.keys(): print(f\"%1.{k} = {%1.__dict__[k]}\")\n" @@ -1228,11 +1230,11 @@ msgstr "" "# 印出 self 中的實例變數\n" "alias ps pi self" -#: ../../library/pdb.rst:751 +#: ../../library/pdb.rst:752 msgid "Delete the specified alias *name*." msgstr "刪除指定的別名 *name*。" -#: ../../library/pdb.rst:755 +#: ../../library/pdb.rst:756 msgid "" "Execute the (one-line) *statement* in the context of the current stack " "frame. The exclamation point can be omitted unless the first word of the " @@ -1241,7 +1243,7 @@ msgstr "" "在目前 stack frame 的情境中執行(單列)\\ *statement*。除非陳述式的第一個單詞" "類似於偵錯器命令,否則可以省略驚嘆號,例如:" -#: ../../library/pdb.rst:759 +#: ../../library/pdb.rst:760 msgid "" "(Pdb) ! n=42\n" "(Pdb)" @@ -1249,7 +1251,7 @@ msgstr "" "(Pdb) ! n=42\n" "(Pdb)" -#: ../../library/pdb.rst:764 +#: ../../library/pdb.rst:765 msgid "" "To set a global variable, you can prefix the assignment command with a :" "keyword:`global` statement on the same line, e.g.:" @@ -1257,7 +1259,7 @@ msgstr "" "要設定全域變數,你可以在同一列的賦值命令前面加上 :keyword:`global` 陳述式,例" "如:" -#: ../../library/pdb.rst:767 +#: ../../library/pdb.rst:768 msgid "" "(Pdb) global list_options; list_options = ['-l']\n" "(Pdb)" @@ -1265,7 +1267,7 @@ msgstr "" "(Pdb) global list_options; list_options = ['-l']\n" "(Pdb)" -#: ../../library/pdb.rst:775 +#: ../../library/pdb.rst:776 msgid "" "Restart the debugged Python program. If *args* is supplied, it is split " "with :mod:`shlex` and the result is used as the new :data:`sys.argv`. " @@ -1276,13 +1278,13 @@ msgstr "" "割,並將結果用作新的 :data:`sys.argv`。歷史記錄、斷點、操作和偵錯器選項均會被" "保留。:pdbcmd:`restart` 是 :pdbcmd:`run` 的別名。" -#: ../../library/pdb.rst:780 +#: ../../library/pdb.rst:781 msgid "" ":pdbcmd:`run` and :pdbcmd:`restart` commands are disabled when the debugger " "is invoked in ``'inline'`` mode." msgstr "" -#: ../../library/pdb.rst:786 +#: ../../library/pdb.rst:787 msgid "" "Quit from the debugger. The program being executed is aborted. An end-of-" "file input is equivalent to :pdbcmd:`quit`." @@ -1290,14 +1292,14 @@ msgstr "" "離開偵錯器,執行中的程式會被中止。輸入檔案結尾 (end-of-file) 相當於 :pdbcmd:" "`quit`。" -#: ../../library/pdb.rst:789 +#: ../../library/pdb.rst:790 msgid "" "A confirmation prompt will be shown if the debugger is invoked in " "``'inline'`` mode. Either ``y``, ``Y``, ```` or ``EOF`` will confirm " "the quit." msgstr "" -#: ../../library/pdb.rst:793 +#: ../../library/pdb.rst:794 msgid "" "A confirmation prompt will be shown if the debugger is invoked in " "``'inline'`` mode. After the confirmation, the debugger will call :func:`sys." @@ -1305,7 +1307,7 @@ msgid "" "event." msgstr "" -#: ../../library/pdb.rst:801 +#: ../../library/pdb.rst:802 msgid "" "Enter a recursive debugger that steps through *code* (which is an arbitrary " "expression or statement to be executed in the current environment)." @@ -1313,15 +1315,15 @@ msgstr "" "進入一個遞迴偵錯器,逐步執行 *code*\\ (這是要在目前環境中執行的任意運算式或" "陳述式)。" -#: ../../library/pdb.rst:807 +#: ../../library/pdb.rst:808 msgid "Print the return value for the last return of the current function." msgstr "印出目前函式最後一次回傳的回傳值。" -#: ../../library/pdb.rst:811 +#: ../../library/pdb.rst:812 msgid "List or jump between chained exceptions." msgstr "列出鏈接例外 (chained exceptions),或在其間跳轉。" -#: ../../library/pdb.rst:813 +#: ../../library/pdb.rst:814 msgid "" "When using ``pdb.pm()`` or ``Pdb.post_mortem(...)`` with a chained " "exception instead of a traceback, it allows the user to move between the " @@ -1332,7 +1334,7 @@ msgstr "" "許使用者在鏈接例外之間移動,使用 ``exceptions`` 命令以列出例外,並使用 " "``exceptions `` 切換到該例外。" -#: ../../library/pdb.rst:821 +#: ../../library/pdb.rst:822 msgid "" "def out():\n" " try:\n" @@ -1368,11 +1370,11 @@ msgstr "" "\n" "out()" -#: ../../library/pdb.rst:838 +#: ../../library/pdb.rst:839 msgid "calling ``pdb.pm()`` will allow to move between exceptions::" msgstr "呼叫 ``pdb.pm()`` 將允許在例外之間移動: ::" -#: ../../library/pdb.rst:840 +#: ../../library/pdb.rst:841 msgid "" "> example.py(5)out()\n" "-> raise ValueError(\"reraise middle() error\") from e\n" @@ -1406,11 +1408,11 @@ msgstr "" "> example.py(10)middle()\n" "-> return inner(0)" -#: ../../library/pdb.rst:859 +#: ../../library/pdb.rst:860 msgid "Footnotes" msgstr "註腳" -#: ../../library/pdb.rst:860 +#: ../../library/pdb.rst:861 msgid "" "Whether a frame is considered to originate in a certain module is determined " "by the ``__name__`` in the frame globals." diff --git a/library/pickle.po b/library/pickle.po index 6d3ab10512c..2b7573d4f94 100644 --- a/library/pickle.po +++ b/library/pickle.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-13 00:36+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:07+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,7 +22,7 @@ msgstr "" msgid ":mod:`!pickle` --- Python object serialization" msgstr ":mod:`!pickle` --- Python 物件序列化" -#: ../../library/pickle.rst:10 +#: ../../library/pickle.rst:7 msgid "**Source code:** :source:`Lib/pickle.py`" msgstr "**原始碼:**\\ :source:`Lib/pickle.py`" @@ -34,7 +34,7 @@ msgstr "**原始碼:**\\ :source:`Lib/pickle.py`" # 無論如何似乎沒有一個定論。 # 因為不確定是否與醃漬的這個梗有關,我暫時選擇使用 `封裝` 與 `拆封` 作為譯文,大致保存那個把東西處裡後裝起來的感覺但又不至於太奇怪。 # 唯一需要擔心的是是否有與 `encapsulation` (封裝,網路協定名詞)或 `package`(封包,網路協定名詞)搞混的可能。 -#: ../../library/pickle.rst:22 +#: ../../library/pickle.rst:19 msgid "" "The :mod:`!pickle` module implements binary protocols for serializing and de-" "serializing a Python object structure. *\"Pickling\"* is the process " @@ -53,11 +53,11 @@ msgstr "" "\"serialization\", \"marshalling,\" [#]_ 或 \"flattening\"。不過,為了避免混" "淆,本文件將統一稱作封裝(pickling)、拆封(unpickling)。" -#: ../../library/pickle.rst:33 +#: ../../library/pickle.rst:30 msgid "The ``pickle`` module **is not secure**. Only unpickle data you trust." msgstr "``pickle`` 模組\\ **並不安全**,切記只拆封你信任的資料。" -#: ../../library/pickle.rst:35 +#: ../../library/pickle.rst:32 msgid "" "It is possible to construct malicious pickle data which will **execute " "arbitrary code during unpickling**. Never unpickle data that could have come " @@ -66,13 +66,13 @@ msgstr "" "pickle 封包是有可能被建立來在拆封的時候\\ **執行任意惡意程式碼**\\ 的。絕對不" "要拆封任何你無法信任其來源、或可能被修改過的 pickle 封包。" -#: ../../library/pickle.rst:39 +#: ../../library/pickle.rst:36 msgid "" "Consider signing data with :mod:`hmac` if you need to ensure that it has not " "been tampered with." msgstr "建議你可以使用 :mod:`hmac` 模組來簽署這個封包,以確保其未被修改過。" -#: ../../library/pickle.rst:42 +#: ../../library/pickle.rst:39 msgid "" "Safer serialization formats such as :mod:`json` may be more appropriate if " "you are processing untrusted data. See :ref:`comparison-with-json`." @@ -80,15 +80,15 @@ msgstr "" "如果你在處理不受信任的資料,其他比較安全的序列化格式(例如 :mod:`json`)可能" "會更適合。請參照 See :ref:`comparison-with-json` 的說明。" -#: ../../library/pickle.rst:47 +#: ../../library/pickle.rst:44 msgid "Relationship to other Python modules" msgstr "和其他 Python 模組的關係" -#: ../../library/pickle.rst:50 +#: ../../library/pickle.rst:47 msgid "Comparison with ``marshal``" msgstr "和 ``marshal`` 的比較" -#: ../../library/pickle.rst:52 +#: ../../library/pickle.rst:49 msgid "" "Python has a more primitive serialization module called :mod:`marshal`, but " "in general :mod:`!pickle` should always be the preferred way to serialize " @@ -99,13 +99,13 @@ msgstr "" "援 Python 的預編譯功能 :file:`.pyc` 的運作。總地來說,請盡可能地使用 :mod:`!" "pickle`,沒事不要用 :mod:`marshal`。" -#: ../../library/pickle.rst:57 +#: ../../library/pickle.rst:54 msgid "" "The :mod:`!pickle` module differs from :mod:`marshal` in several significant " "ways:" msgstr ":mod:`!pickle` 和 :mod:`marshal` 有幾個明顯不同的地方:" -#: ../../library/pickle.rst:59 +#: ../../library/pickle.rst:56 msgid "" ":mod:`marshal` cannot be used to serialize user-defined classes and their " "instances. :mod:`!pickle` can save and restore class instances " @@ -116,7 +116,7 @@ msgstr "" "用者儲存並還原自訂的類別實例,前提是儲存時該類別的定義存在於與要被 pickle 的" "物件所在的模組中、且可以被引入(import)。" -#: ../../library/pickle.rst:64 +#: ../../library/pickle.rst:61 msgid "" "The :mod:`marshal` serialization format is not guaranteed to be portable " "across Python versions. Because its primary job in life is to support :file:" @@ -134,11 +134,11 @@ msgstr "" "3 之間的資料類型差異,:mod:`!pickle` 序列化協定能保證在不同 Python 版本間的相" "容性。" -#: ../../library/pickle.rst:77 +#: ../../library/pickle.rst:74 msgid "Comparison with ``json``" msgstr "和 ``json`` 的比較" -#: ../../library/pickle.rst:79 +#: ../../library/pickle.rst:76 msgid "" "There are fundamental differences between the pickle protocols and `JSON " "(JavaScript Object Notation) `_:" @@ -146,7 +146,7 @@ msgstr "" "pickle 協定和 `JSON (JavaScript Object Notation) `_ 有一些" "根本上的不同:" -#: ../../library/pickle.rst:82 +#: ../../library/pickle.rst:79 msgid "" "JSON is a text serialization format (it outputs unicode text, although most " "of the time it is then encoded to ``utf-8``), while pickle is a binary " @@ -155,11 +155,11 @@ msgstr "" "JSON 以文字形式作為序列化的輸出(輸出 unicode 文字,但大多數又會被編碼為 " "``UTF-8``),而 pickle 則是以二進位形式作為序列化的輸出;" -#: ../../library/pickle.rst:86 +#: ../../library/pickle.rst:83 msgid "JSON is human-readable, while pickle is not;" msgstr "JSON 是人類可讀的,而 pickle 則無法;" -#: ../../library/pickle.rst:88 +#: ../../library/pickle.rst:85 msgid "" "JSON is interoperable and widely used outside of the Python ecosystem, while " "pickle is Python-specific;" @@ -173,7 +173,7 @@ msgstr "" # https://zh.wikipedia.org/wiki/%E5%86%85%E7%9C%81_(%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%A7%91%E5%AD%A6) # https://book.pythontips.com/en/latest/object_introspection.html # https://www.geeksforgeeks.org/code-introspection-in-python/ -#: ../../library/pickle.rst:91 +#: ../../library/pickle.rst:88 msgid "" "JSON, by default, can only represent a subset of the Python built-in types, " "and no custom classes; pickle can represent an extremely large number of " @@ -185,7 +185,7 @@ msgstr "" "透過 Python 的自省措施,pickle 可以紀錄絕大多數的 Python 型別(其他比較複雜的" "狀況也可以透過實作 :ref:`specific object APIs ` 來解決);" -#: ../../library/pickle.rst:97 +#: ../../library/pickle.rst:94 msgid "" "Unlike pickle, deserializing untrusted JSON does not in itself create an " "arbitrary code execution vulnerability." @@ -193,7 +193,7 @@ msgstr "" "去序列化不安全的 JSON 不會產生任意程式執行的風險,但去序列化不安全的 pickle " "會。" -#: ../../library/pickle.rst:101 +#: ../../library/pickle.rst:98 msgid "" "The :mod:`json` module: a standard library module allowing JSON " "serialization and deserialization." @@ -201,11 +201,11 @@ msgstr "" ":mod:`json` module: 是標準函式庫的一部分,可讓使用者進行 JSON 的序列化與去序" "列化。" -#: ../../library/pickle.rst:108 +#: ../../library/pickle.rst:105 msgid "Data stream format" msgstr "資料串流格式" -#: ../../library/pickle.rst:113 +#: ../../library/pickle.rst:110 msgid "" "The data format used by :mod:`!pickle` is Python-specific. This has the " "advantage that there are no restrictions imposed by external standards such " @@ -216,7 +216,7 @@ msgstr "" "(像是 JSON,無法紀錄指標共用)的限制;不過這也代表其他不是 Python 的程式可能" "無法重建 pickle 封裝的 Python 物件。" -#: ../../library/pickle.rst:118 +#: ../../library/pickle.rst:115 msgid "" "By default, the :mod:`!pickle` data format uses a relatively compact binary " "representation. If you need optimal size characteristics, you can " @@ -225,7 +225,7 @@ msgstr "" "以預設設定來說,:mod:`!pickle` 使用相對緊湊的二進位形式來儲存資料。如果你需要" "盡可能地縮小檔案大小,你可以\\ :doc:`壓縮 `\\ 封裝的資料。" -#: ../../library/pickle.rst:122 +#: ../../library/pickle.rst:119 msgid "" "The module :mod:`pickletools` contains tools for analyzing data streams " "generated by :mod:`!pickle`. :mod:`pickletools` source code has extensive " @@ -234,7 +234,7 @@ msgstr "" ":mod:`pickletools` 含有工具可分析 :mod:`!pickle` 所產生的資料流。:mod:" "`pickletools` 的源始碼詳細地記載了所有 pickle 協定的操作碼(opcode)。" -#: ../../library/pickle.rst:126 +#: ../../library/pickle.rst:123 msgid "" "There are currently 6 different protocols which can be used for pickling. " "The higher the protocol used, the more recent the version of Python needed " @@ -243,20 +243,20 @@ msgstr "" "截至目前為止,共有六種不同版本的協定可用於封裝 pickle。數字越大版本代表你需要" "使用越新的 Python 版本來拆封相應的 pickle 封裝。" -#: ../../library/pickle.rst:130 +#: ../../library/pickle.rst:127 msgid "" "Protocol version 0 is the original \"human-readable\" protocol and is " "backwards compatible with earlier versions of Python." msgstr "" "版本 0 的協定是最初「人類可讀」的版本,且可以向前支援早期版本的 Python。" -#: ../../library/pickle.rst:133 +#: ../../library/pickle.rst:130 msgid "" "Protocol version 1 is an old binary format which is also compatible with " "earlier versions of Python." msgstr "版本 1 的協定使用舊的二進位格式,一樣能向前支援早期版本的 Python。" -#: ../../library/pickle.rst:136 +#: ../../library/pickle.rst:133 msgid "" "Protocol version 2 was introduced in Python 2.3. It provides much more " "efficient pickling of :term:`new-style classes `. Refer " @@ -266,7 +266,7 @@ msgstr "" "classes ` 封裝過程。請參閱 :pep:`307` 以了解版本 2 帶來的改" "進。" -#: ../../library/pickle.rst:140 +#: ../../library/pickle.rst:137 msgid "" "Protocol version 3 was added in Python 3.0. It has explicit support for :" "class:`bytes` objects and cannot be unpickled by Python 2.x. This was the " @@ -275,7 +275,7 @@ msgstr "" "版本 3 的協定在 Python 3.0 被新增。現在能支援封裝 :class:`bytes` 的物件且無法" "被 2.x 版本的 Python 拆封。在 3.0~3.7 的 Python 預設使用 3 版協定。" -#: ../../library/pickle.rst:144 +#: ../../library/pickle.rst:141 msgid "" "Protocol version 4 was added in Python 3.4. It adds support for very large " "objects, pickling more kinds of objects, and some data format " @@ -286,7 +286,7 @@ msgstr "" "以及針對部份資料格式的儲存進行最佳化。從 Python 3.8 到 3.13,預設使用第 4 版" "協定。請參閱 :pep:`3154` 以了解第 4 版協定改進的細節。" -#: ../../library/pickle.rst:150 +#: ../../library/pickle.rst:147 msgid "" "Protocol version 5 was added in Python 3.8. It adds support for out-of-band " "data and speedup for in-band data. It is the default protocol starting with " @@ -304,7 +304,7 @@ msgstr "" # tw/%E5%8F%AF%E6%8C%81%E4%B9%85%E5%8C%96%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84 # https://1fly2sky.wordpress.com/2016/04/05/%E6%8C%81%E4%B9%85%E5%B1%A4data- # persistence-layer/ -#: ../../library/pickle.rst:156 +#: ../../library/pickle.rst:153 msgid "" "Serialization is a more primitive notion than persistence; although :mod:`!" "pickle` reads and writes file objects, it does not handle the issue of " @@ -325,11 +325,11 @@ msgstr "" "組提供了一個簡單的介面來讓使用者在 DBM 風格的資料庫檔案中對物件進行封裝和拆封" "的操作。" -#: ../../library/pickle.rst:169 +#: ../../library/pickle.rst:166 msgid "Module Interface" msgstr "模組介面" -#: ../../library/pickle.rst:171 +#: ../../library/pickle.rst:168 msgid "" "To serialize an object hierarchy, you simply call the :func:`dumps` " "function. Similarly, to de-serialize a data stream, you call the :func:" @@ -342,11 +342,11 @@ msgstr "" "化的過程中有更多的掌控度,你可以自訂一個 :class:`Pickler` 或 :class:" "`Unpickler` 物件。" -#: ../../library/pickle.rst:176 +#: ../../library/pickle.rst:173 msgid "The :mod:`!pickle` module provides the following constants:" msgstr ":mod:`!pickle` 模組提供以下常數:" -#: ../../library/pickle.rst:181 +#: ../../library/pickle.rst:178 msgid "" "An integer, the highest :ref:`protocol version ` " "available. This value can be passed as a *protocol* value to functions :" @@ -356,7 +356,7 @@ msgstr "" "為 *protocol* 的數值傳給 :func:`dump` 和 :func:`dumps` 函式以及 :class:" "`Pickler` 建構式。" -#: ../../library/pickle.rst:188 +#: ../../library/pickle.rst:185 msgid "" "An integer, the default :ref:`protocol version ` used for " "pickling. May be less than :data:`HIGHEST_PROTOCOL`. Currently the default " @@ -370,25 +370,25 @@ msgstr "" "不相容。此版本引入了對 out-of-band buffer 的支援,其中 :pep:`3118` 相容的資料" "可以與主要 pickle 串流分開傳輸。" -#: ../../library/pickle.rst:197 +#: ../../library/pickle.rst:194 msgid "The default protocol is 3." msgstr "預設協定版本為 3。" -#: ../../library/pickle.rst:201 +#: ../../library/pickle.rst:198 msgid "The default protocol is 4." msgstr "預設協定版本為 4。" -#: ../../library/pickle.rst:205 +#: ../../library/pickle.rst:202 msgid "The default protocol is 5." msgstr "預設協定是 5。" -#: ../../library/pickle.rst:207 +#: ../../library/pickle.rst:204 msgid "" "The :mod:`!pickle` module provides the following functions to make the " "pickling process more convenient:" msgstr ":mod:`!pickle` 模組提供下列函式來簡化封裝的過程:" -#: ../../library/pickle.rst:212 +#: ../../library/pickle.rst:209 msgid "" "Write the pickled representation of the object *obj* to the open :term:`file " "object` *file*. This is equivalent to ``Pickler(file, protocol).dump(obj)``." @@ -396,7 +396,7 @@ msgstr "" "將被封裝成 pickle 形式的物件 *obj* 寫入到已開啟的\\ :term:`file object` " "*file*。這等效於\\ ``Pickler(file, protocol).dump(obj)``。" -#: ../../library/pickle.rst:216 +#: ../../library/pickle.rst:213 msgid "" "Arguments *file*, *protocol*, *fix_imports* and *buffer_callback* have the " "same meaning as in the :class:`Pickler` constructor." @@ -404,12 +404,12 @@ msgstr "" "引數 *file*、*protocol*、*fix_imports* 和 *buffer_callback* 的意義與 :class:" "`Pickler` 建構式中的相同。" -#: ../../library/pickle.rst:219 ../../library/pickle.rst:230 -#: ../../library/pickle.rst:322 +#: ../../library/pickle.rst:216 ../../library/pickle.rst:227 +#: ../../library/pickle.rst:319 msgid "The *buffer_callback* argument was added." msgstr "新增 *buffer_callback* 引數。" -#: ../../library/pickle.rst:224 +#: ../../library/pickle.rst:221 msgid "" "Return the pickled representation of the object *obj* as a :class:`bytes` " "object, instead of writing it to a file." @@ -417,7 +417,7 @@ msgstr "" "將被封裝為 pickle 形式的物件 *obj* 以 :class:`bytes` 類別回傳,而非寫入進檔" "案。" -#: ../../library/pickle.rst:227 +#: ../../library/pickle.rst:224 msgid "" "Arguments *protocol*, *fix_imports* and *buffer_callback* have the same " "meaning as in the :class:`Pickler` constructor." @@ -425,7 +425,7 @@ msgstr "" "引數 *protocol*、*fix_imports* 和 *buffer_callback* 的意義和 :class:" "`Pickler` 建構式中的相同。" -#: ../../library/pickle.rst:235 +#: ../../library/pickle.rst:232 msgid "" "Read the pickled representation of an object from the open :term:`file " "object` *file* and return the reconstituted object hierarchy specified " @@ -434,7 +434,7 @@ msgstr "" "從已開啟的 :term:`檔案物件 ` *file* 中讀取已序列化的物件,並傳回" "其重建後的物件階層。這相當於呼叫 ``Unpickler(file).load()``。" -#: ../../library/pickle.rst:239 ../../library/pickle.rst:254 +#: ../../library/pickle.rst:236 ../../library/pickle.rst:251 msgid "" "The protocol version of the pickle is detected automatically, so no protocol " "argument is needed. Bytes past the pickled representation of the object are " @@ -443,7 +443,7 @@ msgstr "" "模組會自動偵測 pickle 封包所使用的協定版本,所以無須另外指定。超出 pickle 封" "包表示範圍的位元組將被忽略。" -#: ../../library/pickle.rst:243 +#: ../../library/pickle.rst:240 msgid "" "Arguments *file*, *fix_imports*, *encoding*, *errors*, *strict* and " "*buffers* have the same meaning as in the :class:`Unpickler` constructor." @@ -451,12 +451,12 @@ msgstr "" "引數 *file*、*fix_imports*、*encoding*、*errors*、*strict* 和 *buffers* 的意" "義和 :class:`Unpickler` 建構式中的相同。" -#: ../../library/pickle.rst:246 ../../library/pickle.rst:261 -#: ../../library/pickle.rst:436 +#: ../../library/pickle.rst:243 ../../library/pickle.rst:258 +#: ../../library/pickle.rst:433 msgid "The *buffers* argument was added." msgstr "新增 *buffer* 引數。" -#: ../../library/pickle.rst:251 +#: ../../library/pickle.rst:248 msgid "" "Return the reconstituted object hierarchy of the pickled representation " "*data* of an object. *data* must be a :term:`bytes-like object`." @@ -464,7 +464,7 @@ msgstr "" "回傳從 *data* 的 pickle 封包重建後的物件階層。*data* 必須是一個 :term:`bytes-" "like object`。" -#: ../../library/pickle.rst:258 +#: ../../library/pickle.rst:255 msgid "" "Arguments *fix_imports*, *encoding*, *errors*, *strict* and *buffers* have " "the same meaning as in the :class:`Unpickler` constructor." @@ -472,18 +472,18 @@ msgstr "" "引數 *fix_imports*、*encoding*、*errors*、*strict* 和 *buffers* 的意義與 :" "class:`Unpickler` 建構式所用的相同。" -#: ../../library/pickle.rst:265 +#: ../../library/pickle.rst:262 msgid "The :mod:`!pickle` module defines three exceptions:" msgstr ":mod:`!pickle` 模組定義了以下三種例外:" -#: ../../library/pickle.rst:269 +#: ../../library/pickle.rst:266 msgid "" "Common base class for the other pickling exceptions. It inherits from :exc:" "`Exception`." msgstr "" "繼承 :exc:`Exception` 類別。一個在封裝或拆封時遭遇其他例外時通用的基底類別。" -#: ../../library/pickle.rst:274 +#: ../../library/pickle.rst:271 msgid "" "Error raised when an unpicklable object is encountered by :class:`Pickler`. " "It inherits from :exc:`PickleError`." @@ -491,13 +491,13 @@ msgstr "" "當 :class:`Pickler` 遭遇無法封裝物件時會引發的例外。繼承 :exc:`PickleError` " "類別。" -#: ../../library/pickle.rst:277 +#: ../../library/pickle.rst:274 msgid "" "Refer to :ref:`pickle-picklable` to learn what kinds of objects can be " "pickled." msgstr "請參閱 :ref:`pickle-picklable` 以了解哪些物件是可以被封裝的。" -#: ../../library/pickle.rst:282 +#: ../../library/pickle.rst:279 msgid "" "Error raised when there is a problem unpickling an object, such as a data " "corruption or a security violation. It inherits from :exc:`PickleError`." @@ -505,7 +505,7 @@ msgstr "" "拆封物件時遇到問題(如資料毀損或違反安全性原則等)所引發的意外。繼承自 :exc:" "`PickleError` 類別。" -#: ../../library/pickle.rst:285 +#: ../../library/pickle.rst:282 msgid "" "Note that other exceptions may also be raised during unpickling, including " "(but not necessarily limited to) AttributeError, EOFError, ImportError, and " @@ -514,7 +514,7 @@ msgstr "" "拆封的時候還是可能會遭遇其他不在此列的例外(例如:AttributeError、EOFError、" "ImportError、或 IndexError),請注意。" -#: ../../library/pickle.rst:290 +#: ../../library/pickle.rst:287 msgid "" "The :mod:`!pickle` module exports three classes, :class:`Pickler`, :class:" "`Unpickler` and :class:`PickleBuffer`:" @@ -522,11 +522,11 @@ msgstr "" "引入模組 :mod:`!pickle` 時會帶來三個類別::class:`Pickler`、:class:" "`Unpickler` 和 :class:`PickleBuffer`:" -#: ../../library/pickle.rst:295 +#: ../../library/pickle.rst:292 msgid "This takes a binary file for writing a pickle data stream." msgstr "接受一個用以寫入 pickle 資料流的二進位檔案。" -#: ../../library/pickle.rst:297 +#: ../../library/pickle.rst:294 msgid "" "The optional *protocol* argument, an integer, tells the pickler to use the " "given protocol; supported protocols are 0 to :data:`HIGHEST_PROTOCOL`. If " @@ -537,7 +537,7 @@ msgstr "" "從 0 版起到 :data:`HIGHEST_PROTOCOL` 版的協定。如未指定,則預設為 :data:" "`DEFAULT_PROTOCOL`。若指定了負數,則視為選擇 :data:`HIGHEST_PROTOCOL`。" -#: ../../library/pickle.rst:302 +#: ../../library/pickle.rst:299 msgid "" "The *file* argument must have a write() method that accepts a single bytes " "argument. It can thus be an on-disk file opened for binary writing, an :" @@ -548,7 +548,7 @@ msgstr "" "的物件可以是一個硬碟上二進位檔案、一個 :class:`io.BytesIO` 實例或任何其他滿足" "這個介面要求的物件。" -#: ../../library/pickle.rst:307 +#: ../../library/pickle.rst:304 msgid "" "If *fix_imports* is true and *protocol* is less than 3, pickle will try to " "map the new Python 3 names to the old module names used in Python 2, so that " @@ -562,7 +562,7 @@ msgstr "" # 應作何翻譯? # out-of-band 目前參考 https://kb.synology.com/zh- # tw/DSM/tutorial/Quick_Start_OOB_Management `帶外管理` 譯作 `帶外` -#: ../../library/pickle.rst:311 +#: ../../library/pickle.rst:308 msgid "" "If *buffer_callback* is ``None`` (the default), buffer views are serialized " "into *file* as part of the pickle stream." @@ -570,7 +570,7 @@ msgstr "" "如果 *buffer_callback* 是 ``None``\\ (預設值),緩衝區的視圖會作為 pickle 封" "裝串流的一部分被序列化進 *file* 中。" -#: ../../library/pickle.rst:314 +#: ../../library/pickle.rst:311 msgid "" "If *buffer_callback* is not ``None``, then it can be called any number of " "times with a buffer view. If the callback returns a false value (such as " @@ -582,7 +582,7 @@ msgstr "" "帶外資料 `;否則,該緩衝區將被視為 pickle 串流的帶內資料被序列" "化。" -#: ../../library/pickle.rst:319 +#: ../../library/pickle.rst:316 msgid "" "It is an error if *buffer_callback* is not ``None`` and *protocol* is " "``None`` or smaller than 5." @@ -590,19 +590,19 @@ msgstr "" "如果 *buffer_callback* 不是 ``None`` 且 *protocol* 是 ``None`` 或小於 5 則會" "報錯。" -#: ../../library/pickle.rst:327 +#: ../../library/pickle.rst:324 msgid "" "Write the pickled representation of *obj* to the open file object given in " "the constructor." msgstr "將已封裝(pickled)的 *obj* 寫入已在建構式中開啟的對應檔案。" -#: ../../library/pickle.rst:332 +#: ../../library/pickle.rst:329 msgid "Do nothing by default. This exists so a subclass can override it." msgstr "" "預設不進行任何動作。這是一種抽象方法,用於讓後續繼承這個類別的物件可以覆寫本" "方法函式。" -#: ../../library/pickle.rst:334 +#: ../../library/pickle.rst:331 msgid "" "If :meth:`persistent_id` returns ``None``, *obj* is pickled as usual. Any " "other value causes :class:`Pickler` to emit the returned value as a " @@ -615,11 +615,11 @@ msgstr "" "碼回傳。此永久識別碼的意義應由 :meth:`Unpickler.persistent_load` 定義。請注" "意 :meth:`persistent_id` 回傳的值本身不能擁有自己的永久識別碼。" -#: ../../library/pickle.rst:340 ../../library/pickle.rst:454 +#: ../../library/pickle.rst:337 ../../library/pickle.rst:451 msgid "See :ref:`pickle-persistent` for details and examples of uses." msgstr "關於細節與用法範例請見 :ref:`pickle-persistent`。" -#: ../../library/pickle.rst:342 +#: ../../library/pickle.rst:339 msgid "" "Add the default implementation of this method in the C implementation of :" "class:`!Pickler`." @@ -632,7 +632,7 @@ msgstr "在 C 的 :class:`!Pickler` 實作中的增加了這個方法的預設 # reduction function -> 縮減函式 # 這個是指reduce()函式類型的運算,類似sql的aggregation類型運算,故參閱以下內文,譯為縮減 # https://support.google.com/docs/answer/12657238?hl=zh-Hant -#: ../../library/pickle.rst:348 +#: ../../library/pickle.rst:345 msgid "" "A pickler object's dispatch table is a registry of *reduction functions* of " "the kind which can be declared using :func:`copyreg.pickle`. It is a " @@ -645,7 +645,7 @@ msgstr "" "一個以類別為鍵、還原函式為值的映射表。縮減函式應準備接收一個對應類別的引數," "並應遵循與 :meth:`~object.__reduce__` 方法相同的介面。" -#: ../../library/pickle.rst:356 +#: ../../library/pickle.rst:353 msgid "" "By default, a pickler object will not have a :attr:`dispatch_table` " "attribute, and it will instead use the global dispatch table managed by the :" @@ -661,11 +661,11 @@ msgstr "" "如果 :class:`Pickler` 的子類別具有 :attr:`dispatch_table` 屬性,那麼這個屬性" "將作為該子類別實例的預設調度表。" -#: ../../library/pickle.rst:365 +#: ../../library/pickle.rst:362 msgid "See :ref:`pickle-dispatch` for usage examples." msgstr "關於用法範例請見 :ref:`pickle-dispatch`。" -#: ../../library/pickle.rst:371 +#: ../../library/pickle.rst:368 msgid "" "Special reducer that can be defined in :class:`Pickler` subclasses. This " "method has priority over any reducer in the :attr:`dispatch_table`. It " @@ -679,11 +679,11 @@ msgstr "" "`NotImplemented` 以後備(fallback)使用 :attr:`分派表 ` 中登" "錄的縮減方法來封裝 ``obj``。" -#: ../../library/pickle.rst:377 +#: ../../library/pickle.rst:374 msgid "For a detailed example, see :ref:`reducer_override`." msgstr "請查閱 :ref:`reducer_override` 來參考其他較詳細的範例。" -#: ../../library/pickle.rst:383 +#: ../../library/pickle.rst:380 msgid "" "Deprecated. Enable fast mode if set to a true value. The fast mode disables " "the usage of memo, therefore speeding the pickling process by not generating " @@ -694,15 +694,15 @@ msgstr "" "過不產生多餘的 PUT 操作碼(OpCode)來加速封裝過程。它不應被用於自我參照物件," "否則將導致 :class:`Pickler` 陷入無限遞迴。" -#: ../../library/pickle.rst:389 +#: ../../library/pickle.rst:386 msgid "Use :func:`pickletools.optimize` if you need more compact pickles." msgstr "使用 :func:`pickletools.optimize` 以獲得更緊湊的 pickle 輸出。" -#: ../../library/pickle.rst:393 +#: ../../library/pickle.rst:390 msgid "Clears the pickler's \"memo\"." msgstr "清除 pickler 的「memo」。" -#: ../../library/pickle.rst:395 +#: ../../library/pickle.rst:392 msgid "" "The memo is the data structure that remembers which objects the pickler has " "already seen, so that shared or recursive objects are pickled by reference " @@ -711,17 +711,17 @@ msgstr "" "memo 是一種資料結構,用來記錄 pickler 已經處理過的物件,以便共享或遞迴的物件" "能以參照而非值的方式進行 pickle。此方法在重複使用 pickler 時很有用。" -#: ../../library/pickle.rst:403 +#: ../../library/pickle.rst:400 msgid "This takes a binary file for reading a pickle data stream." msgstr "這個物件接受一個二進位檔案 *file* 來從中讀取 pickle 資料流。" -#: ../../library/pickle.rst:405 +#: ../../library/pickle.rst:402 msgid "" "The protocol version of the pickle is detected automatically, so no protocol " "argument is needed." msgstr "協定版本號會被自動偵測,所以不需要在這邊手動輸入。" -#: ../../library/pickle.rst:408 +#: ../../library/pickle.rst:405 msgid "" "The argument *file* must have three methods, a read() method that takes an " "integer argument, a readinto() method that takes a buffer argument and a " @@ -735,7 +735,7 @@ msgstr "" "`io.BufferedIOBase` 的介面一樣。因此,*file* 可以是一個以二進位讀取模式開啟的" "檔案、一個 :class:`io.BytesIO` 物件、或任何符合此介面的自訂物件。" -#: ../../library/pickle.rst:415 +#: ../../library/pickle.rst:412 msgid "" "The optional arguments *fix_imports*, *encoding* and *errors* are used to " "control compatibility support for pickle stream generated by Python 2. If " @@ -757,7 +757,7 @@ msgstr "" "datetime`、:class:`~datetime.date` 和 :class:`~datetime.time` 的實例則必須使" "用 ``encoding='latin1'`` 來拆封。" -#: ../../library/pickle.rst:426 +#: ../../library/pickle.rst:423 msgid "" "If *buffers* is ``None`` (the default), then all data necessary for " "deserialization must be contained in the pickle stream. This means that the " @@ -768,7 +768,7 @@ msgstr "" "包含在 pickle 串流中。這意味著當初在建立對應的 :class:`Pickler` 時(或在呼" "叫 :func:`dump` 或 :func:`dumps` 時)*buffer_callback* 引數必須為 ``None``。" -#: ../../library/pickle.rst:431 +#: ../../library/pickle.rst:428 msgid "" "If *buffers* is not ``None``, it should be an iterable of buffer-enabled " "objects that is consumed each time the pickle stream references an :ref:`out-" @@ -780,7 +780,7 @@ msgstr "" "將會被照順序消耗。這些緩衝資料當初建立時應已按照順序給定於 Pickler 物件中的 " "*buffer_callback*。" -#: ../../library/pickle.rst:441 +#: ../../library/pickle.rst:438 msgid "" "Read the pickled representation of an object from the open file object given " "in the constructor, and return the reconstituted object hierarchy specified " @@ -789,11 +789,11 @@ msgstr "" "開啟先前被傳入建構子的檔案,從中讀取一個被 pickle 封裝的物件,並回傳重建完成" "的物件階層。超過 pickle 表示範圍的位元組會被忽略。" -#: ../../library/pickle.rst:448 +#: ../../library/pickle.rst:445 msgid "Raise an :exc:`UnpicklingError` by default." msgstr "預設會引發 :exc:`UnpicklingError` 例外。" -#: ../../library/pickle.rst:450 +#: ../../library/pickle.rst:447 msgid "" "If defined, :meth:`persistent_load` should return the object specified by " "the persistent ID *pid*. If an invalid persistent ID is encountered, an :" @@ -802,13 +802,13 @@ msgstr "" "若有定義,則 :meth:`persistent_load` 將回傳符合持久化識別碼 *pid* 的物件。如" "果遭遇了無效的持久化識別碼,則會引發 :exc:`UnpicklingError`。" -#: ../../library/pickle.rst:456 +#: ../../library/pickle.rst:453 msgid "" "Add the default implementation of this method in the C implementation of :" "class:`!Unpickler`." msgstr "在 C 的 :class:`!Unpickler` 實作中的增加了這個方法的預設實作。" -#: ../../library/pickle.rst:462 +#: ../../library/pickle.rst:459 msgid "" "Import *module* if necessary and return the object called *name* from it, " "where the *module* and *name* arguments are :class:`str` objects. Note, " @@ -819,7 +819,7 @@ msgstr "" "*name* 引數接受的輸入是 :class:`str` 物件。注意,雖然名稱上看起來不像,但 :" "meth:`find_class` 亦可被用於尋找其他函式。" -#: ../../library/pickle.rst:467 +#: ../../library/pickle.rst:464 msgid "" "Subclasses may override this to gain control over what type of objects and " "how they can be loaded, potentially reducing security risks. Refer to :ref:" @@ -828,7 +828,7 @@ msgstr "" "子類別可以覆寫此方法以控制可以載入哪些類型的物件、以及如何載入它們,從而潛在" "地降低安全性風險。詳情請參考\\ :ref:`pickle-restrict`。" -#: ../../library/pickle.rst:471 +#: ../../library/pickle.rst:468 msgid "" "Raises an :ref:`auditing event ` ``pickle.find_class`` with " "arguments ``module``, ``name``." @@ -839,7 +839,7 @@ msgstr "" # SkyLull: [T] # 參見 #729 # wrapper -> 包裝器 -#: ../../library/pickle.rst:475 +#: ../../library/pickle.rst:472 msgid "" "A wrapper for a buffer representing picklable data. *buffer* must be a :ref:" "`buffer-providing ` object, such as a :term:`bytes-like " @@ -849,7 +849,7 @@ msgstr "" "一個 :ref:`提供緩衝區 ` 的物件,例如一個 :term:`類位元組物件 " "` 或 N 維陣列。" -#: ../../library/pickle.rst:479 +#: ../../library/pickle.rst:476 msgid "" ":class:`PickleBuffer` is itself a buffer provider, therefore it is possible " "to pass it to other APIs expecting a buffer-providing object, such as :class:" @@ -858,7 +858,7 @@ msgstr "" ":class:`PickleBuffer` 本身就是一個提供緩衝區的物件,所以是能夠將其提供給其它" "「預期收到含有緩衝物件的 API」的,比如 :class:`memoryview`。" -#: ../../library/pickle.rst:483 +#: ../../library/pickle.rst:480 msgid "" ":class:`PickleBuffer` objects can only be serialized using pickle protocol 5 " "or higher. They are eligible for :ref:`out-of-band serialization 限定名稱 -#: ../../library/pickle.rst:532 +#: ../../library/pickle.rst:529 msgid "" "Note that functions (built-in and user-defined) are pickled by fully :term:" "`qualified name`, not by value. [#]_ This means that only the function name " @@ -969,7 +969,7 @@ msgstr "" "拆封該物件的環境中,定義此函式的模組必須可被引入,且該模組必須包含具此命名之" "物件,否則將引發例外。 [#]_" -#: ../../library/pickle.rst:539 +#: ../../library/pickle.rst:536 msgid "" "Similarly, classes are pickled by fully qualified name, so the same " "restrictions in the unpickling environment apply. Note that none of the " @@ -980,7 +980,7 @@ msgstr "" "上的限制。類別中的程式碼或資料皆不會被封裝,因此在以下範例中,注意到類別屬性 " "``attr`` 在拆封的環境中不會被還原::" -#: ../../library/pickle.rst:544 +#: ../../library/pickle.rst:541 msgid "" "class Foo:\n" " attr = 'A class attribute'\n" @@ -992,13 +992,13 @@ msgstr "" "\n" "picklestring = pickle.dumps(Foo)" -#: ../../library/pickle.rst:549 +#: ../../library/pickle.rst:546 msgid "" "These restrictions are why picklable functions and classes must be defined " "at the top level of a module." msgstr "這些限制就是可封裝的函式和類別必須被定義在模組頂層的原因。" -#: ../../library/pickle.rst:552 +#: ../../library/pickle.rst:549 msgid "" "Similarly, when class instances are pickled, their class's code and data are " "not pickled along with them. Only the instance data are pickled. This is " @@ -1015,11 +1015,11 @@ msgstr "" "計將有長期存在的物件、且該物件將經歷許多版本的更替,你可以在物件中存放一個版" "本號,以便未來能透過 :meth:`~object.__setstate__` 方法來進行適當的版本轉換。" -#: ../../library/pickle.rst:564 +#: ../../library/pickle.rst:561 msgid "Pickling Class Instances" msgstr "Pickling 類別實例" -#: ../../library/pickle.rst:568 +#: ../../library/pickle.rst:565 msgid "" "In this section, we describe the general mechanisms available to you to " "define, customize, and control how class instances are pickled and unpickled." @@ -1027,7 +1027,7 @@ msgstr "" "在這一個章節,我們會講述如何封裝或拆封一個物件實例的相關機制,以方便你進行自" "訂。" -#: ../../library/pickle.rst:571 +#: ../../library/pickle.rst:568 msgid "" "In most cases, no additional code is needed to make instances picklable. By " "default, pickle will retrieve the class and the attributes of an instance " @@ -1041,7 +1041,7 @@ msgstr "" "`~object.__init__` 方法通常\\ *不會*\\ 被呼叫。預設行為首先會建立一個未初始化" "的實例,然後還原紀錄中的屬性。以下程式碼的實作展示了前述行為: ::" -#: ../../library/pickle.rst:578 +#: ../../library/pickle.rst:575 msgid "" "def save(obj):\n" " return (obj.__class__, obj.__dict__)\n" @@ -1059,14 +1059,14 @@ msgstr "" " obj.__dict__.update(attributes)\n" " return obj" -#: ../../library/pickle.rst:586 +#: ../../library/pickle.rst:583 msgid "" "Classes can alter the default behaviour by providing one or several special " "methods:" msgstr "" "被封裝的目標類別可以提供一個或數個下列特殊方法來改變 pickle 的預設行為:" -#: ../../library/pickle.rst:591 +#: ../../library/pickle.rst:588 msgid "" "In protocols 2 and newer, classes that implement the :meth:" "`__getnewargs_ex__` method can dictate the values passed to the :meth:" @@ -1080,7 +1080,7 @@ msgstr "" "kwargs)`` 的組合,其中 *args* 是一個位置引數的元組(tuple),*kwargs* 是一個" "用於建構物件的命名引數字典。這些資訊將在拆封時傳遞給 :meth:`__new__` 方法。" -#: ../../library/pickle.rst:599 +#: ../../library/pickle.rst:596 msgid "" "You should implement this method if the :meth:`__new__` method of your class " "requires keyword-only arguments. Otherwise, it is recommended for " @@ -1089,11 +1089,11 @@ msgstr "" "如果目標類別的方法 :meth:`__new__` 需要僅限關鍵字的參數時,你應該實作此方法。" "否則,為了提高相容性,建議你改為實作 :meth:`__getnewargs__`。" -#: ../../library/pickle.rst:603 +#: ../../library/pickle.rst:600 msgid ":meth:`__getnewargs_ex__` is now used in protocols 2 and 3." msgstr "在第 2、3 版的協定中現在改為使用 :meth:`__getnewargs_ex__`。" -#: ../../library/pickle.rst:609 +#: ../../library/pickle.rst:606 msgid "" "This method serves a similar purpose as :meth:`__getnewargs_ex__`, but " "supports only positional arguments. It must return a tuple of arguments " @@ -1103,14 +1103,14 @@ msgstr "" "個由傳入引數所組成的元組(tuple)\\ ``args``,這些引數會在拆封時傳遞給 :meth:" "`__new__` 方法。" -#: ../../library/pickle.rst:613 +#: ../../library/pickle.rst:610 msgid "" ":meth:`__getnewargs__` will not be called if :meth:`__getnewargs_ex__` is " "defined." msgstr "" "當有定義 :meth:`__getnewargs_ex__` 的時候便不會呼叫 :meth:`__getnewargs__`。" -#: ../../library/pickle.rst:616 +#: ../../library/pickle.rst:613 msgid "" "Before Python 3.6, :meth:`__getnewargs__` was called instead of :meth:" "`__getnewargs_ex__` in protocols 2 and 3." @@ -1118,7 +1118,7 @@ msgstr "" "在 Python 3.6 之前、版本 2 和版本 3 的協定中,會呼叫 :meth:`__getnewargs__` " "而非 :meth:`__getnewargs_ex__`。" -#: ../../library/pickle.rst:623 +#: ../../library/pickle.rst:620 msgid "" "Classes can further influence how their instances are pickled by overriding " "the method :meth:`__getstate__`. It is called and the returned object is " @@ -1129,7 +1129,7 @@ msgstr "" "封裝時,呼叫該方法所回傳的物件將作為該實例的內容被封裝、而非一個預設狀態。以" "下列出幾種預設狀態:" -#: ../../library/pickle.rst:628 +#: ../../library/pickle.rst:625 msgid "" "For a class that has no instance :attr:`~object.__dict__` and no :attr:" "`~object.__slots__`, the default state is ``None``." @@ -1137,7 +1137,7 @@ msgstr "" "沒有 :attr:`~object.__dict__` 和 :attr:`~object.__slots__` 實例的類別,其預設" "狀態為 ``None``。" -#: ../../library/pickle.rst:631 +#: ../../library/pickle.rst:628 msgid "" "For a class that has an instance :attr:`~object.__dict__` and no :attr:" "`~object.__slots__`, the default state is ``self.__dict__``." @@ -1145,7 +1145,7 @@ msgstr "" "有 :attr:`~object.__dict__` 實例、但沒有 :attr:`~object.__slots__` 實例的類" "別,其預設狀態為 ``self.__dict__``。" -#: ../../library/pickle.rst:634 +#: ../../library/pickle.rst:631 msgid "" "For a class that has an instance :attr:`~object.__dict__` and :attr:`~object." "__slots__`, the default state is a tuple consisting of two dictionaries: " @@ -1157,7 +1157,7 @@ msgstr "" "和紀錄欄位(slot)名稱和值對應關係的字典(只有含有值的欄位(slot)會被紀錄其" "中)。" -#: ../../library/pickle.rst:640 +#: ../../library/pickle.rst:637 msgid "" "For a class that has :attr:`~object.__slots__` and no instance :attr:" "`~object.__dict__`, the default state is a tuple whose first item is " @@ -1168,13 +1168,13 @@ msgstr "" "設狀態是一個二元組(tuple),元組中的第一個值是 ``None``,第二個值則是紀錄欄" "位(slot)名稱和值對應關係的字典(與前一項提到的字典是同一個)。" -#: ../../library/pickle.rst:645 +#: ../../library/pickle.rst:642 msgid "" "Added the default implementation of the ``__getstate__()`` method in the :" "class:`object` class." msgstr "在 :class:`object` 類別中增加預設的 ``__getstate__()`` 實作。" -#: ../../library/pickle.rst:652 +#: ../../library/pickle.rst:649 msgid "" "Upon unpickling, if the class defines :meth:`__setstate__`, it is called " "with the unpickled state. In that case, there is no requirement for the " @@ -1185,7 +1185,7 @@ msgstr "" "這種情況下,紀錄狀態的物件不需要是字典(dictionary)。否則,封裝時的狀態紀錄" "必須是一個字典,其紀錄的項目將被賦值給新實例的字典。" -#: ../../library/pickle.rst:659 +#: ../../library/pickle.rst:656 msgid "" "If :meth:`__reduce__` returns a state with value ``None`` at pickling, the :" "meth:`__setstate__` method will not be called upon unpickling." @@ -1193,7 +1193,7 @@ msgstr "" "如果 :meth:`__reduce__` 在封裝時回傳了 ``None`` 狀態,則拆封時就不會去呼叫 :" "meth:`__setstate__`。" -#: ../../library/pickle.rst:663 +#: ../../library/pickle.rst:660 msgid "" "Refer to the section :ref:`pickle-state` for more information about how to " "use the methods :meth:`~object.__getstate__` and :meth:`~object." @@ -1202,7 +1202,7 @@ msgstr "" "參閱 :ref:`pickle-state` 以了解 :meth:`~object.__getstate__` 和 :meth:" "`~object.__setstate__` 的使用方法。" -#: ../../library/pickle.rst:668 +#: ../../library/pickle.rst:665 msgid "" "At unpickling time, some methods like :meth:`~object.__getattr__`, :meth:" "`~object.__getattribute__`, or :meth:`~object.__setattr__` may be called " @@ -1216,7 +1216,7 @@ msgstr "" "果這些方法依賴了某些實例內部的不變性,則應實作 :meth:`~object.__new__` 以建立" "此不變性,因為在拆封實例時不會呼叫 :meth:`~object.__init__`。" -#: ../../library/pickle.rst:677 +#: ../../library/pickle.rst:674 msgid "" "As we shall see, pickle does not use directly the methods described above. " "In fact, these methods are part of the copy protocol which implements the :" @@ -1228,7 +1228,7 @@ msgstr "" "`~object.__reduce__` 特殊方法的拷貝協定(copy protocol)。拷貝協定提供了統一" "的介面,以檢索進行封裝及複製物件時所需的資料。 [#]_" -#: ../../library/pickle.rst:683 +#: ../../library/pickle.rst:680 msgid "" "Although powerful, implementing :meth:`~object.__reduce__` directly in your " "classes is error prone. For this reason, class designers should use the " @@ -1243,7 +1243,7 @@ msgstr "" "__setstate__`)。不過,我們也將展示一些特例狀況,在這些狀況中,使用 :meth:`!" "__reduce__` 可能是唯一的選擇、是更有效率的封裝方法或二者兼備。" -#: ../../library/pickle.rst:692 +#: ../../library/pickle.rst:689 msgid "" "The interface is currently defined as follows. The :meth:`__reduce__` " "method takes no argument and shall return either a string or preferably a " @@ -1252,7 +1252,7 @@ msgstr "" "目前的介面定義如下。 :meth:`__reduce__` 方法不接受引數,且應回傳一個字串或一" "個元組(元組一般而言是較佳的選擇;所回傳的物件通常稱為「縮減值」)。" -#: ../../library/pickle.rst:696 +#: ../../library/pickle.rst:693 msgid "" "If a string is returned, the string should be interpreted as the name of a " "global variable. It should be the object's local name relative to its " @@ -1268,7 +1268,7 @@ msgstr "" "沒有設定 ``__module__`` 實例屬性,則退而查找 ``obj`` 的型別。這種行為通常對於" "單例物件特別有用。" -#: ../../library/pickle.rst:704 +#: ../../library/pickle.rst:701 msgid "" "When a tuple is returned, it must be between two and six items long. " "Optional items can either be omitted, or ``None`` can be provided as their " @@ -1277,13 +1277,13 @@ msgstr "" "當回傳一個元組時,其長度必須介於兩至六項元素之間。可選項可以被省略,或者其值" "可以被設為 ``None``。各項物件的語意依序為:" -#: ../../library/pickle.rst:710 +#: ../../library/pickle.rst:707 msgid "" "A callable object that will be called to create the initial version of the " "object." msgstr "一個將會被呼叫來建立初始版本物件的可呼叫物件。" -#: ../../library/pickle.rst:713 +#: ../../library/pickle.rst:710 msgid "" "A tuple of arguments for the callable object. An empty tuple must be given " "if the callable does not accept any argument." @@ -1291,7 +1291,7 @@ msgstr "" "一個用於傳遞引數給前述物件的元組。如果前述物件不接受引數輸入,則你仍應在這裡" "給定一個空元組。" -#: ../../library/pickle.rst:716 +#: ../../library/pickle.rst:713 msgid "" "Optionally, the object's state, which will be passed to the object's :meth:" "`__setstate__` method as previously described. If the object has no such " @@ -1304,7 +1304,7 @@ msgstr "" # SkyLull: [T] # signature: https://jo-jo.medium.com/c-c-%E5%B9%BC%E5%B9%BC%E7%8F%AD-%E7%B0%BD%E7%AB%A0signature-fa9b04e1a3e2 -#: ../../library/pickle.rst:721 +#: ../../library/pickle.rst:718 msgid "" "Optionally, an iterator (and not a sequence) yielding successive items. " "These items will be appended to the object either using ``obj.append(item)`` " @@ -1323,7 +1323,7 @@ msgstr "" "方法將取決於所選用的 pickle 協定版本以及要附加的項目數量,因此必須同時支援這" "兩種方法。)" -#: ../../library/pickle.rst:731 +#: ../../library/pickle.rst:728 msgid "" "Optionally, an iterator (not a sequence) yielding successive key-value " "pairs. These items will be stored to the object using ``obj[key] = " @@ -1334,7 +1334,7 @@ msgstr "" "value`` 方式被儲存到物件中。主要用於字典(dictionary)子類別,但只要有實現" "了 :meth:`__setitem__` 的其他類別也可以使用。" -#: ../../library/pickle.rst:736 +#: ../../library/pickle.rst:733 msgid "" "Optionally, a callable with a ``(obj, state)`` signature. This callable " "allows the user to programmatically control the state-updating behavior of a " @@ -1347,11 +1347,11 @@ msgstr "" "法去控制特定物件的狀態更新方式。如果這個物件不是 ``None``,這個物件的呼叫優先" "權將優於物件 ``obj`` 的 :meth:`__setstate__`。" -#: ../../library/pickle.rst:742 +#: ../../library/pickle.rst:739 msgid "The optional sixth tuple item, ``(obj, state)``, was added." msgstr "加入第六個可選項(一個 ``(obj, state)`` 元組)。" -#: ../../library/pickle.rst:748 +#: ../../library/pickle.rst:745 msgid "" "Alternatively, a :meth:`__reduce_ex__` method may be defined. The only " "difference is this method should take a single integer argument, the " @@ -1365,11 +1365,11 @@ msgstr "" "meth:`__reduce__` 。此外,呼叫 :meth:`__reduce__` 時也會自動變成呼叫這個變體" "版本。此方法主要是為了向後相容的舊的 Python 版本而存在。" -#: ../../library/pickle.rst:760 +#: ../../library/pickle.rst:757 msgid "Persistence of External Objects" msgstr "外部物件持久化" -#: ../../library/pickle.rst:766 +#: ../../library/pickle.rst:763 msgid "" "For the benefit of object persistence, the :mod:`!pickle` module supports " "the notion of a reference to an object outside the pickled data stream. " @@ -1382,7 +1382,7 @@ msgstr "" "(alphanumeric)組成的字串(協定 0) [#]_ 或者是任意的物件(任何較新的協" "定)。" -#: ../../library/pickle.rst:772 +#: ../../library/pickle.rst:769 msgid "" "The resolution of such persistent IDs is not defined by the :mod:`!pickle` " "module; it will delegate this resolution to the user-defined methods on the " @@ -1393,7 +1393,7 @@ msgstr "" "使用者自行定義在封裝器(pickler)以及拆封器(unpickler)中。方法的名稱各自" "為 :meth:`~Pickler.persistent_id` 和 :meth:`~Unpickler.persistent_load`。" -#: ../../library/pickle.rst:777 +#: ../../library/pickle.rst:774 msgid "" "To pickle objects that have an external persistent ID, the pickler must have " "a custom :meth:`~Pickler.persistent_id` method that takes an object as an " @@ -1409,7 +1409,7 @@ msgstr "" "當回傳一個持久化 ID 字串時,封裝器會封裝該物件並加上一個標記,讓拆封器" "(unpickler)能識別它是一個持久化 ID。" -#: ../../library/pickle.rst:784 +#: ../../library/pickle.rst:781 msgid "" "To unpickle external objects, the unpickler must have a custom :meth:" "`~Unpickler.persistent_load` method that takes a persistent ID object and " @@ -1418,14 +1418,14 @@ msgstr "" "要拆封外部物件,拆封器(unpickler)必須有一個自訂的 :meth:`~Unpickler." "persistent_load` 方法,該方法應接受一個持久化 ID 物件,並回傳相對應的物件。" -#: ../../library/pickle.rst:788 +#: ../../library/pickle.rst:785 msgid "" "Here is a comprehensive example presenting how persistent ID can be used to " "pickle external objects by reference." msgstr "" "以下是一個完整的範例,用以說明如何使用持久化 ID 來封裝具外部參照的物件。" -#: ../../library/pickle.rst:791 +#: ../../library/pickle.rst:788 msgid "" "# Simple example presenting how persistent ID can be used to pickle\n" "# external objects by reference.\n" @@ -1609,11 +1609,11 @@ msgstr "" "if __name__ == '__main__':\n" " main()\n" -#: ../../library/pickle.rst:796 +#: ../../library/pickle.rst:793 msgid "Dispatch Tables" msgstr "調度表" -#: ../../library/pickle.rst:798 +#: ../../library/pickle.rst:795 msgid "" "If one wants to customize pickling of some classes without disturbing any " "other code which depends on pickling, then one can create a pickler with a " @@ -1622,7 +1622,7 @@ msgstr "" "如果你希望在不干擾其他物件正常封裝的前提下建立一個針對特定物件的封裝器,你可" "建立一個有私密調度表的封裝器。" -#: ../../library/pickle.rst:802 +#: ../../library/pickle.rst:799 msgid "" "The global dispatch table managed by the :mod:`copyreg` module is available " "as :data:`!copyreg.dispatch_table`. Therefore, one may choose to use a " @@ -1632,11 +1632,11 @@ msgstr "" "叫。你可以透過這個方式來基於原始 :data:`!copyreg.dispatch_table` 建立一個修改" "過的版本,作為你的專屬用途的調度表。" -#: ../../library/pickle.rst:807 +#: ../../library/pickle.rst:804 msgid "For example ::" msgstr "舉例來說: ::" -#: ../../library/pickle.rst:809 +#: ../../library/pickle.rst:806 msgid "" "f = io.BytesIO()\n" "p = pickle.Pickler(f)\n" @@ -1648,7 +1648,7 @@ msgstr "" "p.dispatch_table = copyreg.dispatch_table.copy()\n" "p.dispatch_table[SomeClass] = reduce_SomeClass" -#: ../../library/pickle.rst:814 +#: ../../library/pickle.rst:811 msgid "" "creates an instance of :class:`pickle.Pickler` with a private dispatch table " "which handles the ``SomeClass`` class specially. Alternatively, the code ::" @@ -1656,7 +1656,7 @@ msgstr "" "建立了一個 :class:`pickle.Pickler`,其中含有專門處裡 ``SomeClass`` 類別的專屬" "調度表。此外,你也可以寫作:::" -#: ../../library/pickle.rst:818 +#: ../../library/pickle.rst:815 msgid "" "class MyPickler(pickle.Pickler):\n" " dispatch_table = copyreg.dispatch_table.copy()\n" @@ -1670,7 +1670,7 @@ msgstr "" "f = io.BytesIO()\n" "p = MyPickler(f)" -#: ../../library/pickle.rst:824 +#: ../../library/pickle.rst:821 msgid "" "does the same but all instances of ``MyPickler`` will by default share the " "private dispatch table. On the other hand, the code ::" @@ -1678,7 +1678,7 @@ msgstr "" "這樣可產生相似的結果,唯一不同的是往後所有 ``MyPickler`` 預設都會使用這個專屬" "調度表。最後,如果將程式寫為:::" -#: ../../library/pickle.rst:827 +#: ../../library/pickle.rst:824 msgid "" "copyreg.pickle(SomeClass, reduce_SomeClass)\n" "f = io.BytesIO()\n" @@ -1688,17 +1688,17 @@ msgstr "" "f = io.BytesIO()\n" "p = pickle.Pickler(f)" -#: ../../library/pickle.rst:831 +#: ../../library/pickle.rst:828 msgid "" "modifies the global dispatch table shared by all users of the :mod:`copyreg` " "module." msgstr "則會改變 :mod:`copyreg` 模組內建、所有使用者共通的調度表。" -#: ../../library/pickle.rst:836 +#: ../../library/pickle.rst:833 msgid "Handling Stateful Objects" msgstr "處裡紀錄大量狀態的物件" -#: ../../library/pickle.rst:842 +#: ../../library/pickle.rst:839 msgid "" "Here's an example that shows how to modify pickling behavior for a class. " "The :class:`!TextReader` class below opens a text file, and returns the line " @@ -1716,7 +1716,7 @@ msgstr "" "上次的位置繼續讀取。這個行為的達成是透過 :meth:`!__setstate__` 和 :meth:`!" "__getstate__` 方法來實作的。::" -#: ../../library/pickle.rst:850 +#: ../../library/pickle.rst:847 msgid "" "class TextReader:\n" " \"\"\"Print and number lines in a text file.\"\"\"\n" @@ -1791,11 +1791,11 @@ msgstr "" " # 存檔。\n" " self.file = file" -#: ../../library/pickle.rst:888 +#: ../../library/pickle.rst:885 msgid "A sample usage might be something like this::" msgstr "可以這樣實際使用:::" -#: ../../library/pickle.rst:890 +#: ../../library/pickle.rst:887 msgid "" ">>> reader = TextReader(\"hello.txt\")\n" ">>> reader.readline()\n" @@ -1815,11 +1815,11 @@ msgstr "" ">>> new_reader.readline()\n" "'3: Goodbye!'" -#: ../../library/pickle.rst:902 +#: ../../library/pickle.rst:899 msgid "Custom Reduction for Types, Functions, and Other Objects" msgstr "針對型別、函式或特定物件定製縮減函式" -#: ../../library/pickle.rst:906 +#: ../../library/pickle.rst:903 msgid "" "Sometimes, :attr:`~Pickler.dispatch_table` may not be flexible enough. In " "particular we may want to customize pickling based on another criterion than " @@ -1830,7 +1830,7 @@ msgstr "" "用型別以外的方式來判斷如何使用自訂封裝、或者我們想要自訂特定函式和類別的封裝" "方法時。" -#: ../../library/pickle.rst:911 +#: ../../library/pickle.rst:908 msgid "" "For those cases, it is possible to subclass from the :class:`Pickler` class " "and implement a :meth:`~Pickler.reducer_override` method. This method can " @@ -1842,7 +1842,7 @@ msgstr "" "reducer_override` 方法。此方法可以回傳任意的縮減元組(參閱 :meth:`~object." "__reduce__`)、也可以回傳 :data:`NotImplemented` 以使用後備的原始行為方案。" -#: ../../library/pickle.rst:916 +#: ../../library/pickle.rst:913 msgid "" "If both the :attr:`~Pickler.dispatch_table` and :meth:`~Pickler." "reducer_override` are defined, then :meth:`~Pickler.reducer_override` method " @@ -1851,7 +1851,7 @@ msgstr "" "如果 :attr:`~Pickler.dispatch_table` 和 :meth:`~Pickler.reducer_override` 都" "被定義了的話,:meth:`~Pickler.reducer_override` 的優先度較高。" -#: ../../library/pickle.rst:921 +#: ../../library/pickle.rst:918 msgid "" "For performance reasons, :meth:`~Pickler.reducer_override` may not be called " "for the following objects: ``None``, ``True``, ``False``, and exact " @@ -1864,13 +1864,13 @@ msgstr "" "`bytes`、:class:`str`、:class:`dict`、:class:`set`、:class:`frozenset`、:" "class:`list` 和 :class:`tuple` 的實例。" -#: ../../library/pickle.rst:927 +#: ../../library/pickle.rst:924 msgid "" "Here is a simple example where we allow pickling and reconstructing a given " "class::" msgstr "以下是一個簡單的例子,我們示範如何允許封裝和重建給定的類別:::" -#: ../../library/pickle.rst:930 +#: ../../library/pickle.rst:927 msgid "" "import io\n" "import pickle\n" @@ -1928,11 +1928,11 @@ msgstr "" "assert unpickled_class.__name__ == \"MyClass\"\n" "assert unpickled_class.my_attribute == 1" -#: ../../library/pickle.rst:962 +#: ../../library/pickle.rst:959 msgid "Out-of-band Buffers" msgstr "帶外(Out-of-band)資料緩衝區" -#: ../../library/pickle.rst:966 +#: ../../library/pickle.rst:963 msgid "" "In some contexts, the :mod:`!pickle` module is used to transfer massive " "amounts of data. Therefore, it can be important to minimize the number of " @@ -1946,7 +1946,7 @@ msgstr "" "的圖狀結構(graph-like structure)轉換為連續的位元組串流時,本質上就涉及將資" "料複製到封裝流以及從封裝流複製資料。" -#: ../../library/pickle.rst:973 +#: ../../library/pickle.rst:970 msgid "" "This constraint can be eschewed if both the *provider* (the implementation " "of the object types to be transferred) and the *consumer* (the " @@ -1957,11 +1957,11 @@ msgstr "" "實作)都支援由 pickle 協定 5 或更高版本提供的帶外傳輸功能,則可以避免此一先天" "限制。" -#: ../../library/pickle.rst:979 +#: ../../library/pickle.rst:976 msgid "Provider API" msgstr "供給者 API" -#: ../../library/pickle.rst:981 +#: ../../library/pickle.rst:978 msgid "" "The large data objects to be pickled must implement a :meth:`~object." "__reduce_ex__` method specialized for protocol 5 and higher, which returns " @@ -1972,7 +1972,7 @@ msgstr "" "__reduce_ex__` 方法,該方法應回傳一個 :class:`PickleBuffer` 實例來處理任何大" "型資料(而非回傳如 :class:`bytes` 物件)。" -#: ../../library/pickle.rst:986 +#: ../../library/pickle.rst:983 msgid "" "A :class:`PickleBuffer` object *signals* that the underlying buffer is " "eligible for out-of-band data transfer. Those objects remain compatible " @@ -1984,11 +1984,11 @@ msgstr "" "資料傳輸。這些物件仍然相容 :mod:`!pickle` 模組的一般使用方式。消費者程式也可" "以選擇介入,指示 :mod:`!pickle` 他們將自行處理這些緩衝區。" -#: ../../library/pickle.rst:993 +#: ../../library/pickle.rst:990 msgid "Consumer API" msgstr "消費者 API" -#: ../../library/pickle.rst:995 +#: ../../library/pickle.rst:992 msgid "" "A communications system can enable custom handling of the :class:" "`PickleBuffer` objects generated when serializing an object graph." @@ -1996,7 +1996,7 @@ msgstr "" "一個資訊交換系統可以決定要自行處裡序列化物件圖時產生的 :class:`PickleBuffer` " "物件。" -#: ../../library/pickle.rst:998 +#: ../../library/pickle.rst:995 msgid "" "On the sending side, it needs to pass a *buffer_callback* argument to :class:" "`Pickler` (or to the :func:`dump` or :func:`dumps` function), which will be " @@ -2009,7 +2009,7 @@ msgstr "" "`PickleBuffer` 時,該物件在處理物件圖時能被呼叫。除了一個簡易標記以外,由 " "*buffer_callback* 累積的緩衝區資料不會被複製到 pickle 串流中。" -#: ../../library/pickle.rst:1005 +#: ../../library/pickle.rst:1002 msgid "" "On the receiving side, it needs to pass a *buffers* argument to :class:" "`Unpickler` (or to the :func:`load` or :func:`loads` function), which is an " @@ -2026,7 +2026,7 @@ msgstr "" "緩衝區將提供物件重建所需的資料,以使重建器能還原出那個當時產生了 :class:" "`PickleBuffer` 的物件。" -#: ../../library/pickle.rst:1013 +#: ../../library/pickle.rst:1010 msgid "" "Between the sending side and the receiving side, the communications system " "is free to implement its own transfer mechanism for out-of-band buffers. " @@ -2036,11 +2036,11 @@ msgstr "" "在傳送與接收端之間,通訊系統可以自由實作轉移帶外緩衝區資料的機制。該機制可能" "可以利用共用記憶體機制或根據資料類型特定的壓縮方式來最佳化執行速度。" -#: ../../library/pickle.rst:1019 +#: ../../library/pickle.rst:1016 msgid "Example" msgstr "範例" -#: ../../library/pickle.rst:1021 +#: ../../library/pickle.rst:1018 msgid "" "Here is a trivial example where we implement a :class:`bytearray` subclass " "able to participate in out-of-band buffer pickling::" @@ -2048,7 +2048,7 @@ msgstr "" "這一個簡單的範例展示了如何實作一個可以參與帶外緩衝區封裝的 :class:" "`bytearray` 子類別:::" -#: ../../library/pickle.rst:1024 +#: ../../library/pickle.rst:1021 msgid "" "class ZeroCopyByteArray(bytearray):\n" "\n" @@ -2091,7 +2091,7 @@ msgstr "" " else:\n" " return cls(obj)" -#: ../../library/pickle.rst:1045 +#: ../../library/pickle.rst:1042 msgid "" "The reconstructor (the ``_reconstruct`` class method) returns the buffer's " "providing object if it has the right type. This is an easy way to simulate " @@ -2100,7 +2100,7 @@ msgstr "" "如果型別正確,重建器(``_reconstruct`` 類別方法)會回傳當時提供緩衝區的物件。" "這個簡易實作可以模擬一個無複製行為的重建器。" -#: ../../library/pickle.rst:1049 +#: ../../library/pickle.rst:1046 msgid "" "On the consumer side, we can pickle those objects the usual way, which when " "unserialized will give us a copy of the original object::" @@ -2108,7 +2108,7 @@ msgstr "" "在使用端,我們可以用一般的方式封裝這些物件,當我們拆封時會得到一個原始物件的" "副本:::" -#: ../../library/pickle.rst:1052 +#: ../../library/pickle.rst:1049 msgid "" "b = ZeroCopyByteArray(b\"abc\")\n" "data = pickle.dumps(b, protocol=5)\n" @@ -2122,7 +2122,7 @@ msgstr "" "print(b == new_b) # True\n" "print(b is new_b) # False: 曾進行過複製運算" -#: ../../library/pickle.rst:1058 +#: ../../library/pickle.rst:1055 msgid "" "But if we pass a *buffer_callback* and then give back the accumulated " "buffers when unserializing, we are able to get back the original object::" @@ -2130,7 +2130,7 @@ msgstr "" "但如果我們傳一個 *buffer_callback* 並在去序列化時正確回傳積累的緩衝資料,我們" "就能拿回原始的物件:::" -#: ../../library/pickle.rst:1061 +#: ../../library/pickle.rst:1058 msgid "" "b = ZeroCopyByteArray(b\"abc\")\n" "buffers = []\n" @@ -2146,7 +2146,7 @@ msgstr "" "print(b == new_b) # True\n" "print(b is new_b) # True: 沒有進行過複製" -#: ../../library/pickle.rst:1068 +#: ../../library/pickle.rst:1065 msgid "" "This example is limited by the fact that :class:`bytearray` allocates its " "own memory: you cannot create a :class:`bytearray` instance that is backed " @@ -2160,15 +2160,15 @@ msgstr "" "則可能沒有這個限制,而允許在不同程序或系統之間傳輸資料時使用零拷貝封裝(或儘" "可能地減少拷貝次數)。" -#: ../../library/pickle.rst:1075 +#: ../../library/pickle.rst:1072 msgid ":pep:`574` -- Pickle protocol 5 with out-of-band data" msgstr ":pep:`574` -- 第 5 版 Pickle 協定的帶外資料(out-of-band data)處裡" -#: ../../library/pickle.rst:1081 +#: ../../library/pickle.rst:1078 msgid "Restricting Globals" msgstr "限制全域物件" -#: ../../library/pickle.rst:1086 +#: ../../library/pickle.rst:1083 msgid "" "By default, unpickling will import any class or function that it finds in " "the pickle data. For many applications, this behaviour is unacceptable as " @@ -2179,7 +2179,7 @@ msgstr "" "用程式來說,這種行為是不可接受的,因為它讓拆封器能夠引入並執行任意程式碼。請" "參見以下 pickle 資料流在載入時的行為:::" -#: ../../library/pickle.rst:1091 +#: ../../library/pickle.rst:1088 msgid "" ">>> import pickle\n" ">>> pickle.loads(b\"cos\\nsystem\\n(S'echo hello world'\\ntR.\")\n" @@ -2191,7 +2191,7 @@ msgstr "" "hello world\n" "0" -#: ../../library/pickle.rst:1096 +#: ../../library/pickle.rst:1093 msgid "" "In this example, the unpickler imports the :func:`os.system` function and " "then apply the string argument \"echo hello world\". Although this example " @@ -2202,7 +2202,7 @@ msgstr "" "world」。雖然這個例子是無害的,但不難想像可以這個方式輕易執行任意可能對系統造" "成損害的命令。" -#: ../../library/pickle.rst:1100 +#: ../../library/pickle.rst:1097 msgid "" "For this reason, you may want to control what gets unpickled by customizing :" "meth:`Unpickler.find_class`. Unlike its name suggests, :meth:`Unpickler." @@ -2215,7 +2215,7 @@ msgstr "" "(例如,類別或函式)時,就會呼叫 :meth:`Unpickler.find_class`。因此,可以透過" "這個方法完全禁止全域物件或將其限制在安全的子集合。" -#: ../../library/pickle.rst:1106 +#: ../../library/pickle.rst:1103 msgid "" "Here is an example of an unpickler allowing only few safe classes from the :" "mod:`builtins` module to be loaded::" @@ -2223,7 +2223,7 @@ msgstr "" "以下是一個僅允許從 :mod:`builtins` 模組中載入少數安全類別的拆封器" "(unpickler)的例子:::" -#: ../../library/pickle.rst:1109 +#: ../../library/pickle.rst:1106 msgid "" "import builtins\n" "import io\n" @@ -2277,11 +2277,11 @@ msgstr "" " \"\"\"一個模擬 pickle.loads() 的輔助函式\"\"\"\n" " return RestrictedUnpickler(io.BytesIO(s)).load()" -#: ../../library/pickle.rst:1135 +#: ../../library/pickle.rst:1132 msgid "A sample usage of our unpickler working as intended::" msgstr "我們剛才實作的的拆封器範例正常運作的樣子:::" -#: ../../library/pickle.rst:1137 +#: ../../library/pickle.rst:1134 msgid "" ">>> restricted_loads(pickle.dumps([1, 2, range(15)]))\n" "[1, 2, range(0, 15)]\n" @@ -2309,7 +2309,7 @@ msgstr "" " ...\n" "pickle.UnpicklingError: global 'builtins.eval' is forbidden" -#: ../../library/pickle.rst:1154 +#: ../../library/pickle.rst:1151 msgid "" "As our examples shows, you have to be careful with what you allow to be " "unpickled. Therefore if security is a concern, you may want to consider " @@ -2320,11 +2320,11 @@ msgstr "" "心安全性,你可能需要考慮其他選擇,例如 :mod:`xmlrpc.client` 中的 marshalling " "API 或其他第三方解決方案。" -#: ../../library/pickle.rst:1161 +#: ../../library/pickle.rst:1158 msgid "Performance" msgstr "效能" -#: ../../library/pickle.rst:1163 +#: ../../library/pickle.rst:1160 msgid "" "Recent versions of the pickle protocol (from protocol 2 and upwards) feature " "efficient binary encodings for several common features and built-in types. " @@ -2334,16 +2334,16 @@ msgstr "" "率的二進位編碼。此外,:mod:`!pickle` 模組還具備一個透明化的、以 C 語言編寫的" "最佳化工具。" -#: ../../library/pickle.rst:1171 +#: ../../library/pickle.rst:1168 msgid "Examples" msgstr "範例" -#: ../../library/pickle.rst:1173 +#: ../../library/pickle.rst:1170 msgid "" "For the simplest code, use the :func:`dump` and :func:`load` functions. ::" msgstr "最簡單的使用方式,呼叫 :func:`dump` 和 :func:`load` 函式。::" -#: ../../library/pickle.rst:1175 +#: ../../library/pickle.rst:1172 msgid "" "import pickle\n" "\n" @@ -2371,11 +2371,11 @@ msgstr "" " # 使用可用的最高協定來封裝 'data' 字典。\n" " pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)" -#: ../../library/pickle.rst:1189 +#: ../../library/pickle.rst:1186 msgid "The following example reads the resulting pickled data. ::" msgstr "以下範例可以讀取前述程式所封裝的 pickle 資料。::" -#: ../../library/pickle.rst:1191 +#: ../../library/pickle.rst:1188 msgid "" "import pickle\n" "\n" @@ -2390,11 +2390,11 @@ msgstr "" " # 會自動檢測資料使用的協定版本,因此我們不需要手動指定。\n" " data = pickle.load(f)" -#: ../../library/pickle.rst:1206 +#: ../../library/pickle.rst:1203 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/pickle.rst:1208 +#: ../../library/pickle.rst:1205 msgid "" "The :mod:`!pickle` module can be invoked as a script from the command line, " "it will display contents of the pickle files. However, when the pickle file " @@ -2407,68 +2407,68 @@ msgstr "" "全的選項,因為它不會執行 pickle 位元組碼,請參閱 :ref:`pickletools CLI 用法 " "`。" -#: ../../library/pickle.rst:1214 +#: ../../library/pickle.rst:1211 msgid "python -m pickle pickle_file [pickle_file ...]" msgstr "python -m pickle pickle_file [pickle_file ...]" -#: ../../library/pickle.rst:1218 +#: ../../library/pickle.rst:1215 msgid "The following option is accepted:" msgstr "接受以下選項:" -#: ../../library/pickle.rst:1224 +#: ../../library/pickle.rst:1221 msgid "" "A pickle file to read, or ``-`` to indicate reading from standard input." msgstr "要讀取的 pickle 檔案,或以 ``-`` 表示從標準輸入讀取。" -#: ../../library/pickle.rst:1229 +#: ../../library/pickle.rst:1226 msgid "Module :mod:`copyreg`" msgstr ":mod:`copyreg` 模組" -#: ../../library/pickle.rst:1230 +#: ../../library/pickle.rst:1227 msgid "Pickle interface constructor registration for extension types." msgstr "註冊擴充型別的 Pickle 介面建構子。" -#: ../../library/pickle.rst:1232 +#: ../../library/pickle.rst:1229 msgid "Module :mod:`pickletools`" msgstr ":mod:`pickletools` 模組" -#: ../../library/pickle.rst:1233 +#: ../../library/pickle.rst:1230 msgid "Tools for working with and analyzing pickled data." msgstr "用於分析或處裡被封裝資料的工具。" -#: ../../library/pickle.rst:1235 +#: ../../library/pickle.rst:1232 msgid "Module :mod:`shelve`" msgstr ":mod:`shelve` 模組" -#: ../../library/pickle.rst:1236 +#: ../../library/pickle.rst:1233 msgid "Indexed databases of objects; uses :mod:`!pickle`." msgstr "索引式資料庫;使用 :mod:`!pickle` 實作。" -#: ../../library/pickle.rst:1238 +#: ../../library/pickle.rst:1235 msgid "Module :mod:`copy`" msgstr ":mod:`copy` 模組" -#: ../../library/pickle.rst:1239 +#: ../../library/pickle.rst:1236 msgid "Shallow and deep object copying." msgstr "物件的淺層或深度拷貝。" -#: ../../library/pickle.rst:1241 +#: ../../library/pickle.rst:1238 msgid "Module :mod:`marshal`" msgstr ":mod:`marshal` 模組" -#: ../../library/pickle.rst:1242 +#: ../../library/pickle.rst:1239 msgid "High-performance serialization of built-in types." msgstr "內建型別的高效能序列化。" -#: ../../library/pickle.rst:1246 +#: ../../library/pickle.rst:1243 msgid "Footnotes" msgstr "註解" -#: ../../library/pickle.rst:1247 +#: ../../library/pickle.rst:1244 msgid "Don't confuse this with the :mod:`marshal` module" msgstr "不要將此模組與 :mod:`marshal` 模組混淆" -#: ../../library/pickle.rst:1249 +#: ../../library/pickle.rst:1246 msgid "" "This is why :keyword:`lambda` functions cannot be pickled: all :keyword:`!" "lambda` functions share the same name: ````." @@ -2476,7 +2476,7 @@ msgstr "" "這就是為什麼 :keyword:`lambda` 函式無法被封裝:所有 :keyword:`!lambda` 函式共" "享相同的名稱:````。" -#: ../../library/pickle.rst:1252 +#: ../../library/pickle.rst:1249 msgid "" "The exception raised will likely be an :exc:`ImportError` or an :exc:" "`AttributeError` but it could be something else." @@ -2484,13 +2484,13 @@ msgstr "" "引發的例外應該是 :exc:`ImportError` 或 :exc:`AttributeError`,但也可能是其他" "例外。" -#: ../../library/pickle.rst:1255 +#: ../../library/pickle.rst:1252 msgid "" "The :mod:`copy` module uses this protocol for shallow and deep copying " "operations." msgstr ":mod:`copy` 模組使用此協定進行淺層及深層複製操作。" -#: ../../library/pickle.rst:1258 +#: ../../library/pickle.rst:1255 msgid "" "The limitation on alphanumeric characters is due to the fact that persistent " "IDs in protocol 0 are delimited by the newline character. Therefore if any " @@ -2501,63 +2501,63 @@ msgstr "" "行符號所分隔的。因此,如果持久化 ID 中出現任何形式的換行字元,將導致封裝資料" "變得無法讀取。" -#: ../../library/pickle.rst:12 +#: ../../library/pickle.rst:9 msgid "persistence" msgstr "persistence(持續性)" -#: ../../library/pickle.rst:12 +#: ../../library/pickle.rst:9 msgid "persistent" msgstr "persistent(持續)" -#: ../../library/pickle.rst:12 +#: ../../library/pickle.rst:9 msgid "objects" msgstr "objects(物件)" -#: ../../library/pickle.rst:12 +#: ../../library/pickle.rst:9 msgid "serializing" msgstr "serializing(序列化)" -#: ../../library/pickle.rst:12 +#: ../../library/pickle.rst:9 msgid "marshalling" msgstr "marshalling" -#: ../../library/pickle.rst:12 +#: ../../library/pickle.rst:9 msgid "flattening" msgstr "flattening(攤平)" -#: ../../library/pickle.rst:12 +#: ../../library/pickle.rst:9 msgid "pickling" msgstr "pickling" -#: ../../library/pickle.rst:110 +#: ../../library/pickle.rst:107 msgid "External Data Representation" msgstr "External Data Representation(外部資料表現)" -#: ../../library/pickle.rst:675 +#: ../../library/pickle.rst:672 msgid "copy" msgstr "copy(複製)" -#: ../../library/pickle.rst:675 +#: ../../library/pickle.rst:672 msgid "protocol" msgstr "protocol(協定)" -#: ../../library/pickle.rst:762 +#: ../../library/pickle.rst:759 msgid "persistent_id (pickle protocol)" msgstr "persistent_id(pickle 協定)" -#: ../../library/pickle.rst:762 +#: ../../library/pickle.rst:759 msgid "persistent_load (pickle protocol)" msgstr "persistent_load(pickle 協定)" -#: ../../library/pickle.rst:838 +#: ../../library/pickle.rst:835 msgid "__getstate__() (copy protocol)" msgstr "__getstate__()(copy 協定)" -#: ../../library/pickle.rst:838 +#: ../../library/pickle.rst:835 msgid "__setstate__() (copy protocol)" msgstr "__setstate__()(copy 協定)" -#: ../../library/pickle.rst:1083 +#: ../../library/pickle.rst:1080 msgid "find_class() (pickle protocol)" msgstr "find_class()(pickle 協定)" diff --git a/library/pickletools.po b/library/pickletools.po index 32b32aad732..73ca13d5ee7 100644 --- a/library/pickletools.po +++ b/library/pickletools.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:07+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -123,11 +123,17 @@ msgid "" "A pickle file to read, or ``-`` to indicate reading from standard input." msgstr "" -#: ../../library/pickletools.rst:85 +#: ../../library/pickletools.rst:82 +msgid "" +"Output is in color by default and can be :ref:`controlled using environment " +"variables `." +msgstr "" + +#: ../../library/pickletools.rst:88 msgid "Programmatic interface" msgstr "程式化介面" -#: ../../library/pickletools.rst:90 +#: ../../library/pickletools.rst:93 msgid "" "Outputs a symbolic disassembly of the pickle to the file-like object *out*, " "defaulting to ``sys.stdout``. *pickle* can be a string or a file-like " @@ -146,11 +152,11 @@ msgstr "" "*annotate* 指定非零值,則輸出中的每個操作碼都會用簡短的描述進行註釋。" "*annotate* 的值用作為註釋之起始行提示。" -#: ../../library/pickletools.rst:101 +#: ../../library/pickletools.rst:104 msgid "Added the *annotate* parameter." msgstr "新增 *annotate* 參數。" -#: ../../library/pickletools.rst:106 +#: ../../library/pickletools.rst:109 msgid "" "Provides an :term:`iterator` over all of the opcodes in a pickle, returning " "a sequence of ``(opcode, arg, pos)`` triples. *opcode* is an instance of " @@ -163,7 +169,7 @@ msgstr "" "引數的解碼值(作為 Python 物件);*pos* 是該操作碼所在的位置。*pickle* 可以是" "字串或類檔案物件。" -#: ../../library/pickletools.rst:114 +#: ../../library/pickletools.rst:117 msgid "" "Returns a new equivalent pickle string after eliminating unused ``PUT`` " "opcodes. The optimized pickle is shorter, takes less transmission time, " diff --git a/library/pkgutil.po b/library/pkgutil.po index fd61cbf7f92..b57552531bb 100644 --- a/library/pkgutil.po +++ b/library/pkgutil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-04-08 00:24+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-03-08 16:07+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -346,7 +346,11 @@ msgstr "``W(.W)*``" msgid "``W(.W)*:(W(.W)*)?``" msgstr "``W(.W)*:(W(.W)*)?``" -#: ../../library/pkgutil.rst:212 +#: ../../library/pkgutil.rst:211 +msgid "``W(.W)*:(W(.W)*)``" +msgstr "``W(.W)*:(W(.W)*)``" + +#: ../../library/pkgutil.rst:213 msgid "" "The first form is intended for backward compatibility only. It assumes that " "some part of the dotted name is a package, and the rest is an object " @@ -360,7 +364,7 @@ msgstr "" "於無法透過檢查 (inspection) 來推斷出套件停止的位置和物件層次結構的開始位置," "因此必須使用此形式來重複嘗試引入。" -#: ../../library/pkgutil.rst:219 +#: ../../library/pkgutil.rst:220 msgid "" "In the second form, the caller makes the division point clear through the " "provision of a single colon: the dotted name to the left of the colon is a " @@ -372,24 +376,38 @@ msgstr "" "引入的套件,右側的點名稱是該套件內的物件層次結構。這種形式只需要一次引入。如" "果它以冒號結尾,則回傳一個模組物件。" -#: ../../library/pkgutil.rst:225 +#: ../../library/pkgutil.rst:226 +msgid "The first two forms are accepted when ``strict=False`` (the default)." +msgstr "" + +#: ../../library/pkgutil.rst:228 +msgid "" +"The third form requires both the module name and callable, separated by a " +"colon. Only this form is accepted when ``strict=True``." +msgstr "" + +#: ../../library/pkgutil.rst:231 msgid "" "The function will return an object (which might be a module), or raise one " "of the following exceptions:" msgstr "此函式會回傳一個物件(可能是一個模組),或引發以下其中一個例外:" -#: ../../library/pkgutil.rst:228 +#: ../../library/pkgutil.rst:234 msgid ":exc:`ValueError` -- if *name* isn't in a recognised format." msgstr ":exc:`ValueError` -- 如果 *name* 不是可辨識的格式。" -#: ../../library/pkgutil.rst:230 +#: ../../library/pkgutil.rst:236 msgid ":exc:`ImportError` -- if an import failed when it shouldn't have." msgstr ":exc:`ImportError` -- 如果在不應該失敗的情況下引入失敗。" -#: ../../library/pkgutil.rst:232 +#: ../../library/pkgutil.rst:238 msgid "" ":exc:`AttributeError` -- If a failure occurred when traversing the object " "hierarchy within the imported package to get to the desired object." msgstr "" ":exc:`AttributeError` -- 如果在遍歷引入套件中的物件層次結構以取得所需物件時發" "生失敗。" + +#: ../../library/pkgutil.rst:245 +msgid "The optional keyword-only ``strict`` flag was added." +msgstr "" diff --git a/library/platform.po b/library/platform.po index 29630c82ca4..7a12896e465 100644 --- a/library/platform.po +++ b/library/platform.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-31 00:31+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-06-11 14:03+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,28 +24,28 @@ msgstr "" msgid ":mod:`!platform` --- Access to underlying platform's identifying data" msgstr ":mod:`!platform` --- 對底層平臺識別資料的存取" -#: ../../library/platform.rst:10 +#: ../../library/platform.rst:7 msgid "**Source code:** :source:`Lib/platform.py`" msgstr "**原始碼:**\\ :source:`Lib/platform.py`" -#: ../../library/platform.rst:16 +#: ../../library/platform.rst:13 msgid "" "Specific platforms listed alphabetically, with Linux included in the Unix " "section." msgstr "特定平臺清單為按字母順序排列,Linux 包括在 Unix 小節之中。" -#: ../../library/platform.rst:21 +#: ../../library/platform.rst:18 msgid "Cross platform" msgstr "跨平台" -#: ../../library/platform.rst:26 +#: ../../library/platform.rst:23 msgid "" "Queries the given executable (defaults to the Python interpreter binary) for " "various architecture information." msgstr "" "查詢給定的可執行檔案(預設為 Python 直譯器二進位制檔案)來取得各種架構資訊。" -#: ../../library/platform.rst:29 +#: ../../library/platform.rst:26 msgid "" "Returns a tuple ``(bits, linkage)`` which contain information about the bit " "architecture and the linkage format used for the executable. Both values are " @@ -54,7 +54,7 @@ msgstr "" "回傳一個 tuple(元組) ``(bits, linkage)``,其中包含可執行檔案所使用的位元架" "構和連結格式資訊。這兩個值均以字串形式回傳。" -#: ../../library/platform.rst:33 +#: ../../library/platform.rst:30 msgid "" "Values that cannot be determined are returned as given by the parameter " "presets. If bits is given as ``''``, the ``sizeof(pointer)`` (or " @@ -65,7 +65,7 @@ msgstr "" "``sizeof(pointer)``\\ (或者當 Python 版本 < 1.5.2 時為 ``sizeof(long)``\\ )" "作為所支援指標大小的指示器 (indicator)。" -#: ../../library/platform.rst:38 +#: ../../library/platform.rst:35 msgid "" "The function relies on the system's :file:`file` command to do the actual " "work. This is available on most if not all Unix platforms and some non-Unix " @@ -76,14 +76,14 @@ msgstr "" "和某些非 Unix 平臺上,只有當可執行檔案指向 Python 直譯器時才可使用。當以上要" "求不滿足時將會使用合理的預設值。" -#: ../../library/platform.rst:45 +#: ../../library/platform.rst:42 msgid "" "On macOS (and perhaps other platforms), executable files may be universal " "files containing multiple architectures." msgstr "" "在 macOS(也許還有其他平臺)上,可執行檔案可能是包含多種架構的通用檔案。" -#: ../../library/platform.rst:48 +#: ../../library/platform.rst:45 msgid "" "To get at the \"64-bitness\" of the current interpreter, it is more reliable " "to query the :data:`sys.maxsize` attribute::" @@ -91,23 +91,23 @@ msgstr "" "要取得目前直譯器的 \"64 位元性 (64-bitness)\",更可靠的做法是查詢 :data:`sys." "maxsize` 屬性: ::" -#: ../../library/platform.rst:51 +#: ../../library/platform.rst:48 msgid "is_64bits = sys.maxsize > 2**32" msgstr "is_64bits = sys.maxsize > 2**32" -#: ../../library/platform.rst:56 +#: ../../library/platform.rst:53 msgid "" "Returns the machine type, e.g. ``'AMD64'``. An empty string is returned if " "the value cannot be determined." msgstr "回傳機器種類,例如 ``'AMD64'``。如果該值無法確定則會回傳一個空字串。" -#: ../../library/platform.rst:59 +#: ../../library/platform.rst:56 msgid "" "The output is platform-dependent and may differ in casing and naming " "conventions." msgstr "" -#: ../../library/platform.rst:64 +#: ../../library/platform.rst:61 msgid "" "Returns the computer's network name (may not be fully qualified!). An empty " "string is returned if the value cannot be determined." @@ -115,13 +115,13 @@ msgstr "" "回傳電腦的網路名稱(可能不是完整名稱!)。如果該值無法確定則會回傳一個空字" "串。" -#: ../../library/platform.rst:70 +#: ../../library/platform.rst:67 msgid "" "Returns a single string identifying the underlying platform with as much " "useful information as possible." msgstr "會儘可能附帶有用資訊地回傳一個標識底層平臺的字串。" -#: ../../library/platform.rst:73 +#: ../../library/platform.rst:70 msgid "" "The output is intended to be *human readable* rather than machine parseable. " "It may look different on different platforms and this is intended." @@ -129,7 +129,7 @@ msgstr "" "輸出應為\\ *人類易讀的 (human readable)*,而非機器易剖析的 (machine " "parseable)。它在不同平臺上看起來可能不一致,這是有意為之的。" -#: ../../library/platform.rst:76 +#: ../../library/platform.rst:73 msgid "" "If *aliased* is true, the function will use aliases for various platforms " "that report system names which differ from their common names, for example " @@ -140,13 +140,13 @@ msgstr "" "稱,例如 SunOS 將被回報為 Solaris。:func:`system_alias` 函式被用於實作此功" "能。" -#: ../../library/platform.rst:81 +#: ../../library/platform.rst:78 msgid "" "Setting *terse* to true causes the function to return only the absolute " "minimum information needed to identify the platform." msgstr "將 *terse* 設為真值將導致此函式只回傳標識平臺所需的最小量資訊。" -#: ../../library/platform.rst:84 +#: ../../library/platform.rst:81 msgid "" "On macOS, the function now uses :func:`mac_ver`, if it returns a non-empty " "release string, to get the macOS version rather than the darwin version." @@ -154,11 +154,11 @@ msgstr "" "在 macOS 上,如果 :func:`mac_ver` 回傳的釋出版字串非空字串,此函式現在會使用" "它以取得 macOS 版本而非 darwin 版本。" -#: ../../library/platform.rst:92 +#: ../../library/platform.rst:89 msgid "Returns the (real) processor name, e.g. ``'amdk6'``." msgstr "回傳(真實的)處理器名稱,例如 ``'amdk6'``。" -#: ../../library/platform.rst:94 +#: ../../library/platform.rst:91 msgid "" "An empty string is returned if the value cannot be determined. Note that " "many platforms do not provide this information or simply return the same " @@ -167,7 +167,7 @@ msgstr "" "如果該值無法確定則將回傳空字串。請注意,許多平臺都不提供此資訊或是簡單地回傳" "與 :func:`machine` 相同的值。NetBSD 則會提供此資訊。" -#: ../../library/platform.rst:101 +#: ../../library/platform.rst:98 msgid "" "Returns a tuple ``(buildno, builddate)`` stating the Python build number and " "date as strings." @@ -175,15 +175,15 @@ msgstr "" "回傳一個 tuple ``(buildno, builddate)``,表示字串形式的 Python 建置編號和日" "期。" -#: ../../library/platform.rst:107 +#: ../../library/platform.rst:104 msgid "Returns a string identifying the compiler used for compiling Python." msgstr "回傳一個標識用於編譯 Python 的編譯器的字串。" -#: ../../library/platform.rst:112 +#: ../../library/platform.rst:109 msgid "Returns a string identifying the Python implementation SCM branch." msgstr "回傳一個標識 Python 實作 SCM 分支的字串。" -#: ../../library/platform.rst:117 +#: ../../library/platform.rst:114 msgid "" "Returns a string identifying the Python implementation. Possible return " "values are: 'CPython', 'IronPython', 'Jython', 'PyPy'." @@ -191,15 +191,15 @@ msgstr "" "回傳一個標識 Python 實作的字串。可能的回傳值" "有:'CPython'、'IronPython'、'Jython'、'PyPy'。" -#: ../../library/platform.rst:123 +#: ../../library/platform.rst:120 msgid "Returns a string identifying the Python implementation SCM revision." msgstr "回傳一個標識 Python 實作 SCM 修訂版的字串。" -#: ../../library/platform.rst:128 +#: ../../library/platform.rst:125 msgid "Returns the Python version as string ``'major.minor.patchlevel'``." msgstr "將 Python 版本以字串 ``'major.minor.patchlevel'`` 形式回傳。" -#: ../../library/platform.rst:130 +#: ../../library/platform.rst:127 msgid "" "Note that unlike the Python ``sys.version``, the returned value will always " "include the patchlevel (it defaults to 0)." @@ -207,13 +207,13 @@ msgstr "" "請注意此回傳值不同於 Python ``sys.version``,它總是會包括 patchlevel(預設為 " "``'0'``\\ )。" -#: ../../library/platform.rst:136 +#: ../../library/platform.rst:133 msgid "" "Returns the Python version as tuple ``(major, minor, patchlevel)`` of " "strings." msgstr "將 Python 版本以字串 tuple ``(major, minor, patchlevel)`` 形式回傳。" -#: ../../library/platform.rst:138 +#: ../../library/platform.rst:135 msgid "" "Note that unlike the Python ``sys.version``, the returned value will always " "include the patchlevel (it defaults to ``'0'``)." @@ -221,7 +221,7 @@ msgstr "" "請注意此回傳值不同於 Python ``sys.version``,它總是會包括 patchlevel(預設為 " "``'0'``\\ )。" -#: ../../library/platform.rst:144 +#: ../../library/platform.rst:141 msgid "" "Returns the system's release, e.g. ``'2.2.0'`` or ``'NT'``. An empty string " "is returned if the value cannot be determined." @@ -229,13 +229,13 @@ msgstr "" "回傳系統的釋出版本,例如 ``'2.2.0'`` 或 ``'NT'``,如果該值無法確定則將回傳一" "個空字串。" -#: ../../library/platform.rst:147 +#: ../../library/platform.rst:144 msgid "" "On iOS and Android, this is the user-facing OS release. To obtain the Darwin " "or Linux kernel release, use :func:`os.uname`." msgstr "" -#: ../../library/platform.rst:152 +#: ../../library/platform.rst:149 msgid "" "Returns the system/OS name, such as ``'Linux'``, ``'Darwin'``, ``'Java'``, " "``'Windows'``. An empty string is returned if the value cannot be determined." @@ -243,14 +243,14 @@ msgstr "" "回傳系統/OS 的名稱,例如 ``'Linux'``、``'Darwin'``、``'Java'``、" "``'Windows'``。如果該值無法確定則回傳一個空字串。" -#: ../../library/platform.rst:155 +#: ../../library/platform.rst:152 msgid "" "On iOS and Android, this returns the user-facing OS name (i.e, ``'iOS``, " "``'iPadOS'`` or ``'Android'``). To obtain the kernel name (``'Darwin'`` or " "``'Linux'``), use :func:`os.uname`." msgstr "" -#: ../../library/platform.rst:161 +#: ../../library/platform.rst:158 msgid "" "Returns ``(system, release, version)`` aliased to common marketing names " "used for some systems. It also does some reordering of the information in " @@ -259,7 +259,7 @@ msgstr "" "回傳做為某些系統所使用的常見行銷名稱之別名的 ``(system, release, version)``。" "它還會在可能導致混淆的情況下對資訊進行一些重新排序。" -#: ../../library/platform.rst:168 +#: ../../library/platform.rst:165 msgid "" "Returns the system's release version, e.g. ``'#3 on degas'``. An empty " "string is returned if the value cannot be determined." @@ -267,7 +267,7 @@ msgstr "" "回傳系統的釋出版本資訊,例如 ``'#3 on degas'``。如果該值無法確定則將回傳一個" "空字串。" -#: ../../library/platform.rst:173 +#: ../../library/platform.rst:170 msgid "" "Fairly portable uname interface. Returns a :func:`~collections.namedtuple` " "containing six attributes: :attr:`system`, :attr:`node`, :attr:`release`, :" @@ -277,11 +277,11 @@ msgstr "" "`~collections.namedtuple`::attr:`system`、:attr:`node`、:attr:`release`、:" "attr:`version`、:attr:`machine` 和 :attr:`processor`。" -#: ../../library/platform.rst:177 +#: ../../library/platform.rst:174 msgid ":attr:`processor` is resolved late, on demand." msgstr ":attr:`processor` 會延遲解析,有需求時才會解析" -#: ../../library/platform.rst:179 +#: ../../library/platform.rst:176 msgid "" "Note: the first two attribute names differ from the names presented by :func:" "`os.uname`, where they are named :attr:`!sysname` and :attr:`!nodename`." @@ -289,56 +289,30 @@ msgstr "" "注意:前兩個屬性名稱與 :func:`os.uname` 提供的名稱不同,它們分別命名為 :attr:" "`!sysname` 和 :attr:`!nodename`。" -#: ../../library/platform.rst:183 +#: ../../library/platform.rst:180 msgid "Entries which cannot be determined are set to ``''``." msgstr "無法確定的條目會被設為 ``''``。" -#: ../../library/platform.rst:185 +#: ../../library/platform.rst:182 msgid "Result changed from a tuple to a :func:`~collections.namedtuple`." msgstr "將結果從 tuple 改為 :func:`~collections.namedtuple`。" -#: ../../library/platform.rst:188 +#: ../../library/platform.rst:185 msgid ":attr:`processor` is resolved late instead of immediately." msgstr ":attr:`processor` 會延遲解析,並非立即解析。" -#: ../../library/platform.rst:193 +#: ../../library/platform.rst:190 msgid "" "Clear out the internal cache of information, such as the :func:`uname`. This " "is typically useful when the platform's :func:`node` is changed by an " "external process and one needs to retrieve the updated value." msgstr "" -#: ../../library/platform.rst:201 -msgid "Java platform" -msgstr "Java 平台" - -#: ../../library/platform.rst:206 -msgid "Version interface for Jython." -msgstr "Jython 的版本介面。" - -#: ../../library/platform.rst:208 -msgid "" -"Returns a tuple ``(release, vendor, vminfo, osinfo)`` with *vminfo* being a " -"tuple ``(vm_name, vm_release, vm_vendor)`` and *osinfo* being a tuple " -"``(os_name, os_version, os_arch)``. Values which cannot be determined are " -"set to the defaults given as parameters (which all default to ``''``)." -msgstr "" -"回傳一個 tuple ``(release, vendor, vminfo, osinfo)``,其中 *vminfo* 為 tuple " -"``(vm_name, vm_release, vm_vendor)`` 而 *osinfo* 為 tuple ``(os_name, " -"os_version, os_arch)``。無法確定的值將被設為由參數所給定的預設值(預設均為 " -"``''``\\ )。" - -#: ../../library/platform.rst:213 -msgid "" -"It was largely untested, had a confusing API, and was only useful for Jython " -"support." -msgstr "" - -#: ../../library/platform.rst:219 +#: ../../library/platform.rst:198 msgid "Windows platform" msgstr "Windows 平台" -#: ../../library/platform.rst:224 +#: ../../library/platform.rst:203 msgid "" "Get additional version information from the Windows Registry and return a " "tuple ``(release, version, csd, ptype)`` referring to OS release, version " @@ -350,7 +324,7 @@ msgstr "" "``(release, version, csd, ptype)``,它代表 OS 發行版、版本號、CSD 級別 " "(service pack) 和 OS 類型(多個/單個處理器)。" -#: ../../library/platform.rst:230 +#: ../../library/platform.rst:209 msgid "" "As a hint: *ptype* is ``'Uniprocessor Free'`` on single processor NT " "machines and ``'Multiprocessor Free'`` on multi processor machines. The " @@ -363,7 +337,7 @@ msgstr "" "錯程式。它也可能以 ``'Checked'`` 表示,代表該 OS 版本使用了除錯程式,即檢查引" "數、範圍等的程式。" -#: ../../library/platform.rst:238 +#: ../../library/platform.rst:217 msgid "" "Returns a string representing the current Windows edition, or ``None`` if " "the value cannot be determined. Possible values include but are not limited " @@ -373,7 +347,7 @@ msgstr "" "回傳一個代表目前 Windows 版本的字串。可能的值包括但不限於 ``'Enterprise'``、" "``'IoTUAP'``、``'ServerStandard'`` 和 ``'nanoserver'``。" -#: ../../library/platform.rst:246 +#: ../../library/platform.rst:225 msgid "" "Return ``True`` if the Windows edition returned by :func:`win32_edition` is " "recognized as an IoT edition." @@ -381,11 +355,11 @@ msgstr "" "如果 :func:`win32_edition` 回傳的 Windows 版本被識別為 IoT 版則回傳 " "``True``。" -#: ../../library/platform.rst:253 +#: ../../library/platform.rst:232 msgid "macOS platform" msgstr "macOS 平台" -#: ../../library/platform.rst:257 +#: ../../library/platform.rst:236 msgid "" "Get macOS version information and return it as tuple ``(release, " "versioninfo, machine)`` with *versioninfo* being a tuple ``(version, " @@ -395,53 +369,53 @@ msgstr "" "其中 *versioninfo* 是一個 tuple ``(version, dev_stage, " "non_release_version)``。" -#: ../../library/platform.rst:261 +#: ../../library/platform.rst:240 msgid "" "Entries which cannot be determined are set to ``''``. All tuple entries are " "strings." msgstr "無法確定的條目會被設為 ``''``。所有 tuple 條目均為字串。" -#: ../../library/platform.rst:265 +#: ../../library/platform.rst:244 msgid "iOS platform" msgstr "iOS 平台" -#: ../../library/platform.rst:269 +#: ../../library/platform.rst:248 msgid "" "Get iOS version information and return it as a :func:`~collections." "namedtuple` with the following attributes:" msgstr "" -#: ../../library/platform.rst:272 +#: ../../library/platform.rst:251 msgid "``system`` is the OS name; either ``'iOS'`` or ``'iPadOS'``." msgstr "``system`` 是 OS 名稱;可能是 ``'iOS'`` 或 ``'iPadOS'``。" -#: ../../library/platform.rst:273 +#: ../../library/platform.rst:252 msgid "``release`` is the iOS version number as a string (e.g., ``'17.2'``)." msgstr "" -#: ../../library/platform.rst:274 +#: ../../library/platform.rst:253 msgid "" "``model`` is the device model identifier; this will be a string like " "``'iPhone13,2'`` for a physical device, or ``'iPhone'`` on a simulator." msgstr "" -#: ../../library/platform.rst:276 +#: ../../library/platform.rst:255 msgid "" "``is_simulator`` is a boolean describing if the app is running on a " "simulator or a physical device." msgstr "" -#: ../../library/platform.rst:279 +#: ../../library/platform.rst:258 msgid "" "Entries which cannot be determined are set to the defaults given as " "parameters." msgstr "無法確定的條目會被設定為以參數給定的預設值。" -#: ../../library/platform.rst:284 +#: ../../library/platform.rst:263 msgid "Unix platforms" msgstr "Unix 平台" -#: ../../library/platform.rst:288 +#: ../../library/platform.rst:267 msgid "" "Tries to determine the libc version against which the file executable " "(defaults to the Python interpreter) is linked. Returns a tuple of strings " @@ -451,7 +425,7 @@ msgstr "" "嘗試確認可執行檔案(預設為 Python 直譯器)所連結到的 libc 版本。回傳一個字串 " "tuple ``(lib, version)``,當查詢失敗時其預設值將被設為給定的參數值。" -#: ../../library/platform.rst:292 +#: ../../library/platform.rst:271 msgid "" "Note that this function has intimate knowledge of how different libc " "versions add symbols to the executable is probably only usable for " @@ -460,15 +434,15 @@ msgstr "" "請注意,此函式對於不同 libc 版本如何為可執行檔案新增符號的方式有深層的關聯," "可能僅適用於以 :program:`gcc` 編譯出來的可執行檔案。" -#: ../../library/platform.rst:296 +#: ../../library/platform.rst:275 msgid "The file is read and scanned in chunks of *chunksize* bytes." msgstr "檔案會以 *chunksize* 位元組大小的分塊 (chunk) 來讀取和掃描。" -#: ../../library/platform.rst:300 +#: ../../library/platform.rst:279 msgid "Linux platforms" msgstr "Linux 平台" -#: ../../library/platform.rst:304 +#: ../../library/platform.rst:283 msgid "" "Get operating system identification from ``os-release`` file and return it " "as a dict. The ``os-release`` file is a `freedesktop.org standard `_、並在大多數 Linux 發行版上可用。一個重要的例外" "是 Android 和基於 Android 的發行版。" -#: ../../library/platform.rst:310 +#: ../../library/platform.rst:289 msgid "" "Raises :exc:`OSError` or subclass when neither ``/etc/os-release`` nor ``/" "usr/lib/os-release`` can be read." @@ -489,7 +463,7 @@ msgstr "" "當 ``/etc/os-release`` 與 ``/usr/lib/os-release`` 均無法被讀取時將引發 :exc:" "`OSError` 或其子類別。" -#: ../../library/platform.rst:313 +#: ../../library/platform.rst:292 msgid "" "On success, the function returns a dictionary where keys and values are " "strings. Values have their special characters like ``\"`` and ``$`` " @@ -502,7 +476,7 @@ msgstr "" "``PRETTY_NAME`` 總會按照標準來定義。所有其他欄位都是可選的。根據不同廠商可能" "會包括額外的欄位。" -#: ../../library/platform.rst:319 +#: ../../library/platform.rst:298 msgid "" "Note that fields like ``NAME``, ``VERSION``, and ``VARIANT`` are strings " "suitable for presentation to users. Programs should use fields like ``ID``, " @@ -513,11 +487,11 @@ msgstr "" "串。程式應當使用 ``ID``、``ID_LIKE``、``VERSION_ID`` 或 ``VARIANT_ID`` 等欄位" "來標識 Linux 發行版。" -#: ../../library/platform.rst:324 +#: ../../library/platform.rst:303 msgid "Example::" msgstr "範例: ::" -#: ../../library/platform.rst:326 +#: ../../library/platform.rst:305 msgid "" "def get_like_distro():\n" " info = platform.freedesktop_os_release()\n" @@ -528,92 +502,109 @@ msgid "" " return ids" msgstr "" -#: ../../library/platform.rst:338 +#: ../../library/platform.rst:317 msgid "Android platform" msgstr "Android 平台" -#: ../../library/platform.rst:343 +#: ../../library/platform.rst:322 msgid "" "Get Android device information. Returns a :func:`~collections.namedtuple` " "with the following attributes. Values which cannot be determined are set to " "the defaults given as parameters." msgstr "" -#: ../../library/platform.rst:347 +#: ../../library/platform.rst:326 msgid "``release`` - Android version, as a string (e.g. ``\"14\"``)." msgstr "" -#: ../../library/platform.rst:349 +#: ../../library/platform.rst:328 msgid "" "``api_level`` - API level of the running device, as an integer (e.g. ``34`` " "for Android 14). To get the API level which Python was built against, see :" "func:`sys.getandroidapilevel`." msgstr "" -#: ../../library/platform.rst:353 +#: ../../library/platform.rst:332 msgid "" "``manufacturer`` - `Manufacturer name `__." msgstr "" -#: ../../library/platform.rst:356 +#: ../../library/platform.rst:335 msgid "" "``model`` - `Model name `__ – typically the marketing name or model number." msgstr "" -#: ../../library/platform.rst:360 +#: ../../library/platform.rst:339 msgid "" "``device`` - `Device name `__ – typically the model number or a codename." msgstr "" -#: ../../library/platform.rst:364 +#: ../../library/platform.rst:343 msgid "" "``is_emulator`` - ``True`` if the device is an emulator; ``False`` if it's a " "physical device." msgstr "" -#: ../../library/platform.rst:367 +#: ../../library/platform.rst:346 msgid "" "Google maintains a `list of known model and device names `__." msgstr "" -#: ../../library/platform.rst:375 +#: ../../library/platform.rst:354 msgid "Command-line usage" msgstr "命令列用法" -#: ../../library/platform.rst:377 +#: ../../library/platform.rst:356 msgid "" ":mod:`!platform` can also be invoked directly using the :option:`-m` switch " "of the interpreter::" msgstr "" -#: ../../library/platform.rst:380 +#: ../../library/platform.rst:359 msgid "python -m platform [--terse] [--nonaliased] [{nonaliased,terse} ...]" msgstr "python -m platform [--terse] [--nonaliased] [{nonaliased,terse} ...]" -#: ../../library/platform.rst:382 +#: ../../library/platform.rst:361 msgid "The following options are accepted:" msgstr "可接受以下選項:" -#: ../../library/platform.rst:388 +#: ../../library/platform.rst:367 msgid "" "Print terse information about the platform. This is equivalent to calling :" "func:`platform.platform` with the *terse* argument set to ``True``." msgstr "" -#: ../../library/platform.rst:393 +#: ../../library/platform.rst:372 msgid "" "Print platform information without system/OS name aliasing. This is " "equivalent to calling :func:`platform.platform` with the *aliased* argument " "set to ``True``." msgstr "" -#: ../../library/platform.rst:397 +#: ../../library/platform.rst:376 msgid "" "You can also pass one or more positional arguments (``terse``, " "``nonaliased``) to explicitly control the output format. These behave " "similarly to their corresponding options." msgstr "" + +#~ msgid "Java platform" +#~ msgstr "Java 平台" + +#~ msgid "Version interface for Jython." +#~ msgstr "Jython 的版本介面。" + +#~ msgid "" +#~ "Returns a tuple ``(release, vendor, vminfo, osinfo)`` with *vminfo* being " +#~ "a tuple ``(vm_name, vm_release, vm_vendor)`` and *osinfo* being a tuple " +#~ "``(os_name, os_version, os_arch)``. Values which cannot be determined are " +#~ "set to the defaults given as parameters (which all default to ``''``)." +#~ msgstr "" +#~ "回傳一個 tuple ``(release, vendor, vminfo, osinfo)``,其中 *vminfo* 為 " +#~ "tuple ``(vm_name, vm_release, vm_vendor)`` 而 *osinfo* 為 tuple " +#~ "``(os_name, os_version, os_arch)``。無法確定的值將被設為由參數所給定的預設" +#~ "值(預設均為 ``''``\\ )。" diff --git a/library/plistlib.po b/library/plistlib.po index 1af9ae5a788..3b4c4d058f5 100644 --- a/library/plistlib.po +++ b/library/plistlib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-22 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2016-01-31 07:27+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,107 +21,108 @@ msgstr "" msgid ":mod:`!plistlib` --- Generate and parse Apple ``.plist`` files" msgstr ":mod:`!plistlib` --- 產生和剖析 Apple ``.plist`` 檔案" -#: ../../library/plistlib.rst:11 +#: ../../library/plistlib.rst:7 msgid "**Source code:** :source:`Lib/plistlib.py`" msgstr "**原始碼:**\\ :source:`Lib/plistlib.py`" -#: ../../library/plistlib.rst:19 +#: ../../library/plistlib.rst:15 msgid "" "This module provides an interface for reading and writing the \"property " "list\" files used by Apple, primarily on macOS and iOS. This module supports " "both binary and XML plist files." msgstr "" -#: ../../library/plistlib.rst:23 +#: ../../library/plistlib.rst:19 msgid "" "The property list (``.plist``) file format is a simple serialization " "supporting basic object types, like dictionaries, lists, numbers and " -"strings. Usually the top level object is a dictionary." +"strings. Usually the top level object is a dictionary or a frozen " +"dictionary." msgstr "" -#: ../../library/plistlib.rst:27 +#: ../../library/plistlib.rst:23 msgid "" "To write out and to parse a plist file, use the :func:`dump` and :func:" "`load` functions." msgstr "" -#: ../../library/plistlib.rst:30 +#: ../../library/plistlib.rst:26 msgid "" "To work with plist data in bytes or string objects, use :func:`dumps` and :" "func:`loads`." msgstr "" -#: ../../library/plistlib.rst:33 +#: ../../library/plistlib.rst:29 msgid "" "Values can be strings, integers, floats, booleans, tuples, lists, " "dictionaries (but only with string keys), :class:`bytes`, :class:`bytearray` " "or :class:`datetime.datetime` objects." msgstr "" -#: ../../library/plistlib.rst:37 +#: ../../library/plistlib.rst:33 msgid "New API, old API deprecated. Support for binary format plists added." msgstr "" -#: ../../library/plistlib.rst:40 +#: ../../library/plistlib.rst:36 msgid "" "Support added for reading and writing :class:`UID` tokens in binary plists " "as used by NSKeyedArchiver and NSKeyedUnarchiver." msgstr "" -#: ../../library/plistlib.rst:44 +#: ../../library/plistlib.rst:40 msgid "Old API removed." msgstr "" -#: ../../library/plistlib.rst:49 +#: ../../library/plistlib.rst:45 msgid "" "`PList manual page `_" msgstr "" -#: ../../library/plistlib.rst:50 +#: ../../library/plistlib.rst:46 msgid "Apple's documentation of the file format." msgstr "" -#: ../../library/plistlib.rst:53 +#: ../../library/plistlib.rst:49 msgid "This module defines the following functions:" msgstr "此模組定義了以下函式:" -#: ../../library/plistlib.rst:57 +#: ../../library/plistlib.rst:53 msgid "" "Read a plist file. *fp* should be a readable and binary file object. Return " "the unpacked root object (which usually is a dictionary)." msgstr "" -#: ../../library/plistlib.rst:61 +#: ../../library/plistlib.rst:57 msgid "The *fmt* is the format of the file and the following values are valid:" msgstr "" -#: ../../library/plistlib.rst:63 +#: ../../library/plistlib.rst:59 msgid ":data:`None`: Autodetect the file format" msgstr ":data:`None`:自動偵測檔案格式" -#: ../../library/plistlib.rst:65 +#: ../../library/plistlib.rst:61 msgid ":data:`FMT_XML`: XML file format" msgstr ":data:`FMT_XML`:XML 檔案格式" -#: ../../library/plistlib.rst:67 +#: ../../library/plistlib.rst:63 msgid ":data:`FMT_BINARY`: Binary plist format" msgstr ":data:`FMT_BINARY`:二進位 plist 格式" -#: ../../library/plistlib.rst:69 +#: ../../library/plistlib.rst:65 msgid "" "The *dict_type* is the type used for dictionaries that are read from the " "plist file." msgstr "" -#: ../../library/plistlib.rst:72 +#: ../../library/plistlib.rst:68 msgid "" "When *aware_datetime* is true, fields with type ``datetime.datetime`` will " "be created as :ref:`aware object `, with :attr:`!" "tzinfo` as :const:`datetime.UTC`." msgstr "" -#: ../../library/plistlib.rst:76 +#: ../../library/plistlib.rst:72 msgid "" "XML data for the :data:`FMT_XML` format is parsed using the Expat parser " "from :mod:`xml.parsers.expat` -- see its documentation for possible " @@ -129,125 +130,125 @@ msgid "" "the plist parser." msgstr "" -#: ../../library/plistlib.rst:81 +#: ../../library/plistlib.rst:77 msgid "" "The parser raises :exc:`InvalidFileException` when the file cannot be parsed." msgstr "" -#: ../../library/plistlib.rst:85 ../../library/plistlib.rst:130 +#: ../../library/plistlib.rst:81 ../../library/plistlib.rst:126 msgid "The keyword-only parameter *aware_datetime* has been added." msgstr "新增僅限關鍵字參數 *aware_datetime*。" -#: ../../library/plistlib.rst:91 +#: ../../library/plistlib.rst:87 msgid "" "Load a plist from a bytes or string object. See :func:`load` for an " "explanation of the keyword arguments." msgstr "" -#: ../../library/plistlib.rst:96 +#: ../../library/plistlib.rst:92 msgid "*data* can be a string when *fmt* equals :data:`FMT_XML`." msgstr "*data* 在 *fmt* 等於 :data:`FMT_XML` 時可以是一個字串。" -#: ../../library/plistlib.rst:101 +#: ../../library/plistlib.rst:97 msgid "" "Write *value* to a plist file. *fp* should be a writable, binary file object." msgstr "" -#: ../../library/plistlib.rst:104 +#: ../../library/plistlib.rst:100 msgid "" "The *fmt* argument specifies the format of the plist file and can be one of " "the following values:" msgstr "" -#: ../../library/plistlib.rst:107 +#: ../../library/plistlib.rst:103 msgid ":data:`FMT_XML`: XML formatted plist file" msgstr "" -#: ../../library/plistlib.rst:109 +#: ../../library/plistlib.rst:105 msgid ":data:`FMT_BINARY`: Binary formatted plist file" msgstr "" -#: ../../library/plistlib.rst:111 +#: ../../library/plistlib.rst:107 msgid "" "When *sort_keys* is true (the default) the keys for dictionaries will be " "written to the plist in sorted order, otherwise they will be written in the " "iteration order of the dictionary." msgstr "" -#: ../../library/plistlib.rst:115 +#: ../../library/plistlib.rst:111 msgid "" "When *skipkeys* is false (the default) the function raises :exc:`TypeError` " "when a key of a dictionary is not a string, otherwise such keys are skipped." msgstr "" -#: ../../library/plistlib.rst:118 +#: ../../library/plistlib.rst:114 msgid "" "When *aware_datetime* is true and any field with type ``datetime.datetime`` " "is set as an :ref:`aware object `, it will convert to " "UTC timezone before writing it." msgstr "" -#: ../../library/plistlib.rst:122 +#: ../../library/plistlib.rst:118 msgid "" "A :exc:`TypeError` will be raised if the object is of an unsupported type or " "a container that contains objects of unsupported types." msgstr "" -#: ../../library/plistlib.rst:125 +#: ../../library/plistlib.rst:121 msgid "" "An :exc:`OverflowError` will be raised for integer values that cannot be " "represented in (binary) plist files." msgstr "" -#: ../../library/plistlib.rst:136 +#: ../../library/plistlib.rst:132 msgid "" "Return *value* as a plist-formatted bytes object. See the documentation for :" "func:`dump` for an explanation of the keyword arguments of this function." msgstr "" -#: ../../library/plistlib.rst:143 +#: ../../library/plistlib.rst:139 msgid "The following classes are available:" msgstr "" -#: ../../library/plistlib.rst:147 +#: ../../library/plistlib.rst:143 msgid "" "Wraps an :class:`int`. This is used when reading or writing NSKeyedArchiver " "encoded data, which contains UID (see PList manual)." msgstr "" -#: ../../library/plistlib.rst:152 +#: ../../library/plistlib.rst:148 msgid "Int value of the UID. It must be in the range ``0 <= data < 2**64``." msgstr "" -#: ../../library/plistlib.rst:157 +#: ../../library/plistlib.rst:153 msgid "The following constants are available:" msgstr "以下常數可供使用:" -#: ../../library/plistlib.rst:161 +#: ../../library/plistlib.rst:157 msgid "The XML format for plist files." msgstr "" -#: ../../library/plistlib.rst:168 +#: ../../library/plistlib.rst:164 msgid "The binary format for plist files" msgstr "" -#: ../../library/plistlib.rst:173 +#: ../../library/plistlib.rst:169 msgid "The module defines the following exceptions:" msgstr "這個模組定義了以下例外:" -#: ../../library/plistlib.rst:177 +#: ../../library/plistlib.rst:173 msgid "Raised when a file cannot be parsed." msgstr "當檔案無法被剖析時引發。" -#: ../../library/plistlib.rst:183 +#: ../../library/plistlib.rst:179 msgid "Examples" msgstr "範例" -#: ../../library/plistlib.rst:185 +#: ../../library/plistlib.rst:181 msgid "Generating a plist::" msgstr "" -#: ../../library/plistlib.rst:187 +#: ../../library/plistlib.rst:183 msgid "" "import datetime as dt\n" "import plistlib\n" @@ -289,11 +290,11 @@ msgstr "" ")\n" "print(plistlib.dumps(pl).decode())" -#: ../../library/plistlib.rst:207 +#: ../../library/plistlib.rst:203 msgid "Parsing a plist::" msgstr "" -#: ../../library/plistlib.rst:209 +#: ../../library/plistlib.rst:205 msgid "" "import plistlib\n" "\n" @@ -317,14 +318,14 @@ msgstr "" "pl = plistlib.loads(plist)\n" "print(pl[\"foo\"])" -#: ../../library/plistlib.rst:13 +#: ../../library/plistlib.rst:9 msgid "plist" msgstr "plist" -#: ../../library/plistlib.rst:13 +#: ../../library/plistlib.rst:9 msgid "file" msgstr "file(檔案)" -#: ../../library/plistlib.rst:13 +#: ../../library/plistlib.rst:9 msgid "property list" msgstr "property list(屬性清單)" diff --git a/library/poplib.po b/library/poplib.po index 21fcfb55f49..62c4d1cfc43 100644 --- a/library/poplib.po +++ b/library/poplib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!poplib` --- POP3 protocol client" msgstr ":mod:`!poplib` --- POP3 協定用戶端" -#: ../../library/poplib.rst:10 +#: ../../library/poplib.rst:7 msgid "**Source code:** :source:`Lib/poplib.py`" msgstr "**原始碼:**\\ :source:`Lib/poplib.py`" -#: ../../library/poplib.rst:16 +#: ../../library/poplib.rst:13 msgid "" "This module defines a class, :class:`POP3`, which encapsulates a connection " "to a POP3 server and implements the protocol as defined in :rfc:`1939`. The :" @@ -35,14 +35,14 @@ msgid "" "established connection." msgstr "" -#: ../../library/poplib.rst:22 +#: ../../library/poplib.rst:19 msgid "" "Additionally, this module provides a class :class:`POP3_SSL`, which provides " "support for connecting to POP3 servers that use SSL as an underlying " "protocol layer." msgstr "" -#: ../../library/poplib.rst:26 +#: ../../library/poplib.rst:23 msgid "" "Note that POP3, though widely supported, is obsolescent. The implementation " "quality of POP3 servers varies widely, and too many are quite poor. If your " @@ -62,11 +62,11 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/poplib.rst:33 +#: ../../library/poplib.rst:30 msgid "The :mod:`!poplib` module provides two classes:" msgstr "" -#: ../../library/poplib.rst:38 +#: ../../library/poplib.rst:35 msgid "" "This class implements the actual POP3 protocol. The connection is created " "when the instance is initialized. If *port* is omitted, the standard POP3 " @@ -75,7 +75,7 @@ msgid "" "timeout setting will be used)." msgstr "" -#: ../../library/poplib.rst:44 ../../library/poplib.rst:66 +#: ../../library/poplib.rst:41 ../../library/poplib.rst:63 msgid "" "Raises an :ref:`auditing event ` ``poplib.connect`` with arguments " "``self``, ``host``, ``port``." @@ -83,8 +83,8 @@ msgstr "" "引發一個附帶引數 ``self``、``host``、``port`` 的\\ :ref:`稽核事件 " "` ``poplib.connect``。" -#: ../../library/poplib.rst:46 ../../library/poplib.rst:48 -#: ../../library/poplib.rst:68 ../../library/poplib.rst:70 +#: ../../library/poplib.rst:43 ../../library/poplib.rst:45 +#: ../../library/poplib.rst:65 ../../library/poplib.rst:67 msgid "" "All commands will raise an :ref:`auditing event ` ``poplib." "putline`` with arguments ``self`` and ``line``, where ``line`` is the bytes " @@ -93,13 +93,13 @@ msgstr "" "引發一個附帶引數 ``self``、``line`` 的\\ :ref:`稽核事件 ` ``poplib." "putline``。其中 ``line`` 為即將傳送給遠端的位元組。" -#: ../../library/poplib.rst:52 ../../library/poplib.rst:82 +#: ../../library/poplib.rst:49 ../../library/poplib.rst:79 msgid "" "If the *timeout* parameter is set to be zero, it will raise a :class:" "`ValueError` to prevent the creation of a non-blocking socket." msgstr "" -#: ../../library/poplib.rst:58 +#: ../../library/poplib.rst:55 msgid "" "This is a subclass of :class:`POP3` that connects to the server over an SSL " "encrypted socket. If *port* is not specified, 995, the standard POP3-over-" @@ -110,40 +110,40 @@ msgid "" "for best practices." msgstr "" -#: ../../library/poplib.rst:74 +#: ../../library/poplib.rst:71 msgid "*context* parameter added." msgstr "新增 *context* 參數。" -#: ../../library/poplib.rst:77 +#: ../../library/poplib.rst:74 msgid "" "The class now supports hostname check with :attr:`ssl.SSLContext." "check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." msgstr "" -#: ../../library/poplib.rst:86 +#: ../../library/poplib.rst:83 msgid "The deprecated *keyfile* and *certfile* parameters have been removed." msgstr "" -#: ../../library/poplib.rst:89 +#: ../../library/poplib.rst:86 msgid "One exception is defined as an attribute of the :mod:`!poplib` module:" msgstr "" -#: ../../library/poplib.rst:94 +#: ../../library/poplib.rst:91 msgid "" "Exception raised on any errors from this module (errors from :mod:`socket` " "module are not caught). The reason for the exception is passed to the " "constructor as a string." msgstr "" -#: ../../library/poplib.rst:101 +#: ../../library/poplib.rst:98 msgid "Module :mod:`imaplib`" msgstr ":mod:`imaplib` 模組" -#: ../../library/poplib.rst:102 +#: ../../library/poplib.rst:99 msgid "The standard Python IMAP module." msgstr "" -#: ../../library/poplib.rst:104 +#: ../../library/poplib.rst:101 msgid "" "`Frequently Asked Questions About Fetchmail `_" @@ -151,28 +151,28 @@ msgstr "" "`關於 Fetchmail 的常見問題 `_" -#: ../../library/poplib.rst:105 +#: ../../library/poplib.rst:102 msgid "" "The FAQ for the :program:`fetchmail` POP/IMAP client collects information on " "POP3 server variations and RFC noncompliance that may be useful if you need " "to write an application based on the POP protocol." msgstr "" -#: ../../library/poplib.rst:113 +#: ../../library/poplib.rst:110 msgid "POP3 Objects" msgstr "POP3 物件" -#: ../../library/poplib.rst:115 +#: ../../library/poplib.rst:112 msgid "" "All POP3 commands are represented by methods of the same name, in lowercase; " "most return the response text sent by the server." msgstr "" -#: ../../library/poplib.rst:118 +#: ../../library/poplib.rst:115 msgid "A :class:`POP3` instance has the following methods:" msgstr ":class:`POP3` 實例擁有以下方法:" -#: ../../library/poplib.rst:123 +#: ../../library/poplib.rst:120 msgid "" "Set the instance's debugging level. This controls the amount of debugging " "output printed. The default, ``0``, produces no debugging output. A value " @@ -182,81 +182,81 @@ msgid "" "connection." msgstr "" -#: ../../library/poplib.rst:132 +#: ../../library/poplib.rst:129 msgid "Returns the greeting string sent by the POP3 server." msgstr "回傳 POP3 伺服器傳送的歡迎字串。" -#: ../../library/poplib.rst:137 +#: ../../library/poplib.rst:134 msgid "" "Query the server's capabilities as specified in :rfc:`2449`. Returns a " "dictionary in the form ``{'name': ['param'...]}``." msgstr "" -#: ../../library/poplib.rst:145 +#: ../../library/poplib.rst:142 msgid "" "Send user command, response should indicate that a password is required." msgstr "" -#: ../../library/poplib.rst:150 +#: ../../library/poplib.rst:147 msgid "" "Send password, response includes message count and mailbox size. Note: the " "mailbox on the server is locked until :meth:`~POP3.quit` is called." msgstr "" -#: ../../library/poplib.rst:156 +#: ../../library/poplib.rst:153 msgid "Use the more secure APOP authentication to log into the POP3 server." msgstr "" -#: ../../library/poplib.rst:161 +#: ../../library/poplib.rst:158 msgid "" "Use RPOP authentication (similar to UNIX r-commands) to log into POP3 server." msgstr "" -#: ../../library/poplib.rst:166 +#: ../../library/poplib.rst:163 msgid "" "Get mailbox status. The result is a tuple of 2 integers: ``(message count, " "mailbox size)``." msgstr "" -#: ../../library/poplib.rst:172 +#: ../../library/poplib.rst:169 msgid "" "Request message list, result is in the form ``(response, ['mesg_num " "octets', ...], octets)``. If *which* is set, it is the message to list." msgstr "" -#: ../../library/poplib.rst:178 +#: ../../library/poplib.rst:175 msgid "" "Retrieve whole message number *which*, and set its seen flag. Result is in " "form ``(response, ['line', ...], octets)``." msgstr "" -#: ../../library/poplib.rst:184 +#: ../../library/poplib.rst:181 msgid "" "Flag message number *which* for deletion. On most servers deletions are not " "actually performed until QUIT (the major exception is Eudora QPOP, which " "deliberately violates the RFCs by doing pending deletes on any disconnect)." msgstr "" -#: ../../library/poplib.rst:191 +#: ../../library/poplib.rst:188 msgid "Remove any deletion marks for the mailbox." msgstr "" -#: ../../library/poplib.rst:196 +#: ../../library/poplib.rst:193 msgid "Do nothing. Might be used as a keep-alive." msgstr "" -#: ../../library/poplib.rst:201 +#: ../../library/poplib.rst:198 msgid "Signoff: commit changes, unlock mailbox, drop connection." msgstr "" -#: ../../library/poplib.rst:206 +#: ../../library/poplib.rst:203 msgid "" "Retrieves the message header plus *howmuch* lines of the message after the " "header of message number *which*. Result is in form ``(response, " "['line', ...], octets)``." msgstr "" -#: ../../library/poplib.rst:210 +#: ../../library/poplib.rst:207 msgid "" "The POP3 TOP command this method uses, unlike the RETR command, doesn't set " "the message's seen flag; unfortunately, TOP is poorly specified in the RFCs " @@ -264,26 +264,26 @@ msgid "" "against the POP3 servers you will use before trusting it." msgstr "" -#: ../../library/poplib.rst:218 +#: ../../library/poplib.rst:215 msgid "" "Return message digest (unique id) list. If *which* is specified, result " "contains the unique id for that message in the form ``'response mesgnum " "uid``, otherwise result is list ``(response, ['mesgnum uid', ...], octets)``." msgstr "" -#: ../../library/poplib.rst:225 +#: ../../library/poplib.rst:222 msgid "" "Try to switch to UTF-8 mode. Returns the server response if successful, " "raises :class:`error_proto` if not. Specified in :RFC:`6856`." msgstr "" -#: ../../library/poplib.rst:233 +#: ../../library/poplib.rst:230 msgid "" "Start a TLS session on the active connection as specified in :rfc:`2595`. " "This is only allowed before user authentication" msgstr "" -#: ../../library/poplib.rst:236 +#: ../../library/poplib.rst:233 msgid "" "*context* parameter is a :class:`ssl.SSLContext` object which allows " "bundling SSL configuration options, certificates and private keys into a " @@ -291,29 +291,29 @@ msgid "" "for best practices." msgstr "" -#: ../../library/poplib.rst:241 +#: ../../library/poplib.rst:238 msgid "" "This method supports hostname checking via :attr:`ssl.SSLContext." "check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." msgstr "" -#: ../../library/poplib.rst:248 +#: ../../library/poplib.rst:245 msgid "" "Instances of :class:`POP3_SSL` have no additional methods. The interface of " "this subclass is identical to its parent." msgstr "" -#: ../../library/poplib.rst:255 +#: ../../library/poplib.rst:252 msgid "POP3 Example" msgstr "POP3 範例" -#: ../../library/poplib.rst:257 +#: ../../library/poplib.rst:254 msgid "" "Here is a minimal example (without error checking) that opens a mailbox and " "retrieves and prints all messages::" msgstr "" -#: ../../library/poplib.rst:260 +#: ../../library/poplib.rst:257 msgid "" "import getpass, poplib\n" "\n" @@ -335,16 +335,16 @@ msgstr "" " for j in M.retr(i+1)[1]:\n" " print(j)" -#: ../../library/poplib.rst:270 +#: ../../library/poplib.rst:267 msgid "" "At the end of the module, there is a test section that contains a more " "extensive example of usage." msgstr "" -#: ../../library/poplib.rst:12 +#: ../../library/poplib.rst:9 msgid "POP3" msgstr "POP3" -#: ../../library/poplib.rst:12 +#: ../../library/poplib.rst:9 msgid "protocol" msgstr "protocol(協定)" diff --git a/library/posix.po b/library/posix.po index a0ee85120a9..5d1d8e74c22 100644 --- a/library/posix.po +++ b/library/posix.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-20 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-01-24 00:05+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -67,7 +67,7 @@ msgstr "" msgid "Large File Support" msgstr "對大檔案 (Large File) 的支援" -#: ../../library/posix.rst:41 +#: ../../library/posix.rst:39 msgid "" "Several operating systems (including AIX and Solaris) provide support for " "files that are larger than 2 GiB from a C programming model where :c:expr:" @@ -80,7 +80,7 @@ msgstr "" "大小和偏移量 (offset) 種類定義為 64-bit 值來實作。此類檔案有時被稱為「大檔案 " "(:dfn:`large files`)」。" -#: ../../library/posix.rst:47 +#: ../../library/posix.rst:45 msgid "" "Large file support is enabled in Python when the size of an :c:type:`off_t` " "is larger than a :c:expr:`long` and the :c:expr:`long long` is at least as " @@ -93,7 +93,7 @@ msgstr "" "標來配置和編譯 Python 以啟用此模式。例如,對於 Solaris 2.6 和 2.7,你需要執行" "如下操作: ::" -#: ../../library/posix.rst:54 +#: ../../library/posix.rst:52 msgid "" "CFLAGS=\"`getconf LFS_CFLAGS`\" OPT=\"-g -O2 $CFLAGS\" \\\n" " ./configure" @@ -101,11 +101,11 @@ msgstr "" "CFLAGS=\"`getconf LFS_CFLAGS`\" OPT=\"-g -O2 $CFLAGS\" \\\n" " ./configure" -#: ../../library/posix.rst:57 +#: ../../library/posix.rst:55 msgid "On large-file-capable Linux systems, this might work::" msgstr "在支援大檔案的 Linux 系統上,這可能有效: ::" -#: ../../library/posix.rst:59 +#: ../../library/posix.rst:57 msgid "" "CFLAGS='-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64' OPT=\"-g -O2 $CFLAGS\" " "\\\n" @@ -115,11 +115,11 @@ msgstr "" "\\\n" " ./configure" -#: ../../library/posix.rst:66 +#: ../../library/posix.rst:64 msgid "Notable Module Contents" msgstr "值得注意的模組內容" -#: ../../library/posix.rst:68 +#: ../../library/posix.rst:66 msgid "" "In addition to many functions described in the :mod:`os` module " "documentation, :mod:`!posix` defines the following data item:" @@ -127,7 +127,7 @@ msgstr "" "除了 :mod:`os` 模組說明文件中描述的許多函式外,:mod:`!posix` 還定義了以下資料" "項目:" -#: ../../library/posix.rst:73 +#: ../../library/posix.rst:71 msgid "" "A dictionary representing the string environment at the time the interpreter " "was started. Keys and values are bytes on Unix and str on Windows. For " @@ -138,7 +138,7 @@ msgstr "" "str。例如,``environ[b'HOME']``\\ (Windows 上為 ``environ['HOME']``\\ )是你" "的主目錄的路徑名,等同於 C 語言中的 ``getenv(\"HOME\")``。" -#: ../../library/posix.rst:78 +#: ../../library/posix.rst:76 msgid "" "Modifying this dictionary does not affect the string environment passed on " "by :func:`~os.execv`, :func:`~os.popen` or :func:`~os.system`; if you need " @@ -151,11 +151,11 @@ msgstr "" "`~os.execve` 或將變數賦值和匯出陳述句新增到 :func:`~os.system` 或 :func:`~os." "popen` 的指令字串中。" -#: ../../library/posix.rst:84 +#: ../../library/posix.rst:82 msgid "On Unix, keys and values are bytes." msgstr "在 Unix 上,鍵和值是位元組。" -#: ../../library/posix.rst:89 +#: ../../library/posix.rst:87 msgid "" "The :mod:`os` module provides an alternate implementation of ``environ`` " "which updates the environment on modification. Note also that updating :data:" diff --git a/library/pprint.po b/library/pprint.po index c5a5f8e1ff4..1a20885dfb1 100644 --- a/library/pprint.po +++ b/library/pprint.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!pprint` --- Data pretty printer" msgstr ":mod:`!pprint` --- 資料美化列印器" -#: ../../library/pprint.rst:10 +#: ../../library/pprint.rst:7 msgid "**Source code:** :source:`Lib/pprint.py`" msgstr "**原始碼:**\\ :source:`Lib/pprint.py`" -#: ../../library/pprint.rst:14 +#: ../../library/pprint.rst:11 msgid "" "The :mod:`!pprint` module provides a capability to \"pretty-print\" " "arbitrary Python data structures in a form which can be used as input to the " @@ -35,26 +35,26 @@ msgid "" "well as many other objects which are not representable as Python literals." msgstr "" -#: ../../library/pprint.rst:21 +#: ../../library/pprint.rst:18 msgid "" "The formatted representation keeps objects on a single line if it can, and " "breaks them onto multiple lines if they don't fit within the allowed width, " "adjustable by the *width* parameter defaulting to 80 characters." msgstr "" -#: ../../library/pprint.rst:25 +#: ../../library/pprint.rst:22 msgid "Added support for pretty-printing :class:`types.SimpleNamespace`." msgstr "" -#: ../../library/pprint.rst:28 +#: ../../library/pprint.rst:25 msgid "Added support for pretty-printing :class:`dataclasses.dataclass`." msgstr "" -#: ../../library/pprint.rst:34 +#: ../../library/pprint.rst:31 msgid "Functions" msgstr "函式" -#: ../../library/pprint.rst:39 +#: ../../library/pprint.rst:37 msgid "" "Prints the formatted representation of *object*, followed by a newline. This " "function may be used in the interactive interpreter instead of the :func:" @@ -66,28 +66,28 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../library/pprint.rst:44 +#: ../../library/pprint.rst:42 msgid "The object to be printed." msgstr "將被印出的物件。" -#: ../../library/pprint.rst:47 +#: ../../library/pprint.rst:45 msgid "" "A file-like object to which the output will be written by calling its :meth:" "`!write` method. If ``None`` (the default), :data:`sys.stdout` is used." msgstr "" -#: ../../library/pprint.rst:53 +#: ../../library/pprint.rst:51 msgid "The amount of indentation added for each nesting level." msgstr "" -#: ../../library/pprint.rst:56 +#: ../../library/pprint.rst:54 msgid "" "The desired maximum number of characters per line in the output. If a " "structure cannot be formatted within the width constraint, a best effort " "will be made." msgstr "" -#: ../../library/pprint.rst:61 +#: ../../library/pprint.rst:59 msgid "" "The number of nesting levels which may be printed. If the data structure " "being printed is too deep, the next contained level is replaced by ``...``. " @@ -95,56 +95,63 @@ msgid "" "objects being formatted." msgstr "" -#: ../../library/pprint.rst:69 +#: ../../library/pprint.rst:67 msgid "" "Control the way long :term:`sequences ` are formatted. If " "``False`` (the default), each item of a sequence will be formatted on a " "separate line, otherwise as many items as will fit within the *width* will " -"be formatted on each output line." +"be formatted on each output line. Incompatible with *expand*." +msgstr "" + +#: ../../library/pprint.rst:75 +msgid "" +"If ``True``, opening parentheses and brackets will be followed by a newline " +"and the following content will be indented by one level, similar to pretty-" +"printed JSON. Incompatible with *compact*." msgstr "" -#: ../../library/pprint.rst:76 +#: ../../library/pprint.rst:81 msgid "" "If ``True``, dictionaries will be formatted with their keys sorted, " "otherwise they will be displayed in insertion order (the default)." msgstr "" -#: ../../library/pprint.rst:81 +#: ../../library/pprint.rst:86 msgid "" "If ``True``, integers will be formatted with the ``_`` character for a " "thousands separator, otherwise underscores are not displayed (the default)." msgstr "" -#: ../../library/pprint.rst:103 +#: ../../library/pprint.rst:109 msgid "" "Alias for :func:`~pprint.pp` with *sort_dicts* set to ``True`` by default, " "which would automatically sort the dictionaries' keys, you might want to " "use :func:`~pprint.pp` instead where it is ``False`` by default." msgstr "" -#: ../../library/pprint.rst:111 +#: ../../library/pprint.rst:118 msgid "" "Return the formatted representation of *object* as a string. *indent*, " -"*width*, *depth*, *compact*, *sort_dicts* and *underscore_numbers* are " -"passed to the :class:`PrettyPrinter` constructor as formatting parameters " -"and their meanings are as described in the documentation above." +"*width*, *depth*, *compact*, *expand*, *sort_dicts* and *underscore_numbers* " +"are passed to the :class:`PrettyPrinter` constructor as formatting " +"parameters and their meanings are as described in the documentation above." msgstr "" -#: ../../library/pprint.rst:121 +#: ../../library/pprint.rst:128 msgid "" "Determine if the formatted representation of *object* is \"readable\", or " "can be used to reconstruct the value using :func:`eval`. This always " "returns ``False`` for recursive objects." msgstr "" -#: ../../library/pprint.rst:131 +#: ../../library/pprint.rst:138 msgid "" "Determine if *object* requires a recursive representation. This function is " "subject to the same limitations as noted in :func:`saferepr` below and may " "raise an :exc:`RecursionError` if it fails to detect a recursive object." msgstr "" -#: ../../library/pprint.rst:138 +#: ../../library/pprint.rst:145 msgid "" "Return a string representation of *object*, protected against recursion in " "some common data structures, namely instances of :class:`dict`, :class:" @@ -154,53 +161,57 @@ msgid "" "id=number>``. The representation is not otherwise formatted." msgstr "" -#: ../../library/pprint.rst:151 +#: ../../library/pprint.rst:158 msgid "PrettyPrinter Objects" msgstr "PrettyPrinter 物件" -#: ../../library/pprint.rst:158 +#: ../../library/pprint.rst:166 msgid "Construct a :class:`PrettyPrinter` instance." msgstr "建立一個 :class:`PrettyPrinter` 實例。" -#: ../../library/pprint.rst:160 +#: ../../library/pprint.rst:168 msgid "" "Arguments have the same meaning as for :func:`~pprint.pp`. Note that they " "are in a different order, and that *sort_dicts* defaults to ``True``." msgstr "" -#: ../../library/pprint.rst:187 +#: ../../library/pprint.rst:211 msgid "Added the *compact* parameter." msgstr "新增 *compact* 參數。" -#: ../../library/pprint.rst:190 +#: ../../library/pprint.rst:214 msgid "Added the *sort_dicts* parameter." msgstr "新增 *sort_dicts* 參數。" -#: ../../library/pprint.rst:193 +#: ../../library/pprint.rst:217 msgid "Added the *underscore_numbers* parameter." msgstr "新增 *underscore_numbers* 參數。" -#: ../../library/pprint.rst:196 +#: ../../library/pprint.rst:220 msgid "No longer attempts to write to :data:`!sys.stdout` if it is ``None``." msgstr "" -#: ../../library/pprint.rst:200 +#: ../../library/pprint.rst:223 +msgid "Added the *expand* parameter." +msgstr "新增 *expand* 參數。" + +#: ../../library/pprint.rst:227 msgid ":class:`PrettyPrinter` instances have the following methods:" msgstr ":class:`PrettyPrinter` 實例有以下方法:" -#: ../../library/pprint.rst:205 +#: ../../library/pprint.rst:232 msgid "" "Return the formatted representation of *object*. This takes into account " "the options passed to the :class:`PrettyPrinter` constructor." msgstr "" -#: ../../library/pprint.rst:211 +#: ../../library/pprint.rst:238 msgid "" "Print the formatted representation of *object* on the configured stream, " "followed by a newline." msgstr "" -#: ../../library/pprint.rst:214 +#: ../../library/pprint.rst:241 msgid "" "The following methods provide the implementations for the corresponding " "functions of the same names. Using these methods on an instance is slightly " @@ -208,7 +219,7 @@ msgid "" "created." msgstr "" -#: ../../library/pprint.rst:224 +#: ../../library/pprint.rst:251 msgid "" "Determine if the formatted representation of the object is \"readable,\" or " "can be used to reconstruct the value using :func:`eval`. Note that this " @@ -217,18 +228,18 @@ msgid "" "returns ``False``." msgstr "" -#: ../../library/pprint.rst:233 +#: ../../library/pprint.rst:260 msgid "Determine if the object requires a recursive representation." msgstr "" -#: ../../library/pprint.rst:235 +#: ../../library/pprint.rst:262 msgid "" "This method is provided as a hook to allow subclasses to modify the way " "objects are converted to strings. The default implementation uses the " "internals of the :func:`saferepr` implementation." msgstr "" -#: ../../library/pprint.rst:242 +#: ../../library/pprint.rst:269 msgid "" "Returns three values: the formatted version of *object* as a string, a flag " "indicating whether the result is readable, and a flag indicating whether " @@ -246,18 +257,18 @@ msgid "" "of the current call." msgstr "" -#: ../../library/pprint.rst:260 +#: ../../library/pprint.rst:287 msgid "Example" msgstr "範例" -#: ../../library/pprint.rst:262 +#: ../../library/pprint.rst:289 msgid "" "To demonstrate several uses of the :func:`~pprint.pp` function and its " "parameters, let's fetch information about a project from `PyPI `_::" msgstr "" -#: ../../library/pprint.rst:265 +#: ../../library/pprint.rst:292 msgid "" ">>> import json\n" ">>> import pprint\n" @@ -271,11 +282,11 @@ msgstr "" ">>> with urlopen('https://pypi.org/pypi/sampleproject/1.2.0/json') as resp:\n" "... project_info = json.load(resp)['info']" -#: ../../library/pprint.rst:271 +#: ../../library/pprint.rst:298 msgid "In its basic form, :func:`~pprint.pp` shows the whole object::" msgstr "" -#: ../../library/pprint.rst:273 +#: ../../library/pprint.rst:300 msgid "" ">>> pprint.pp(project_info)\n" "{'author': 'The Python Packaging Authority',\n" @@ -391,13 +402,13 @@ msgstr "" " 'summary': 'A sample Python project',\n" " 'version': '1.2.0'}" -#: ../../library/pprint.rst:327 +#: ../../library/pprint.rst:354 msgid "" "The result can be limited to a certain *depth* (ellipsis is used for deeper " "contents)::" msgstr "" -#: ../../library/pprint.rst:330 +#: ../../library/pprint.rst:357 msgid "" ">>> pprint.pp(project_info, depth=1)\n" "{'author': 'The Python Packaging Authority',\n" @@ -491,13 +502,13 @@ msgstr "" " 'summary': 'A sample Python project',\n" " 'version': '1.2.0'}" -#: ../../library/pprint.rst:373 +#: ../../library/pprint.rst:400 msgid "" "Additionally, maximum character *width* can be suggested. If a long object " "cannot be split, the specified width will be exceeded::" msgstr "" -#: ../../library/pprint.rst:376 +#: ../../library/pprint.rst:403 msgid "" ">>> pprint.pp(project_info, depth=1, width=60)\n" "{'author': 'The Python Packaging Authority',\n" @@ -591,18 +602,164 @@ msgstr "" " 'summary': 'A sample Python project',\n" " 'version': '1.2.0'}" -#: ../../library/pprint.rst:119 ../../library/pprint.rst:222 +#: ../../library/pprint.rst:449 +msgid "" +"Lastly, we can format like pretty-printed JSON with the *expand* parameter. " +"Best results are achieved with a higher *indent* value::" +msgstr "" + +#: ../../library/pprint.rst:452 +msgid "" +">>> pprint.pp(project_info, indent=4, expand=True)\n" +"{\n" +" 'author': 'The Python Packaging Authority',\n" +" 'author_email': 'pypa-dev@googlegroups.com',\n" +" 'bugtrack_url': None,\n" +" 'classifiers': [\n" +" 'Development Status :: 3 - Alpha',\n" +" 'Intended Audience :: Developers',\n" +" 'License :: OSI Approved :: MIT License',\n" +" 'Programming Language :: Python :: 2',\n" +" 'Programming Language :: Python :: 2.6',\n" +" 'Programming Language :: Python :: 2.7',\n" +" 'Programming Language :: Python :: 3',\n" +" 'Programming Language :: Python :: 3.2',\n" +" 'Programming Language :: Python :: 3.3',\n" +" 'Programming Language :: Python :: 3.4',\n" +" 'Topic :: Software Development :: Build Tools',\n" +" ],\n" +" 'description': 'A sample Python project\\n'\n" +" '=======================\\n'\n" +" '\\n'\n" +" 'This is the description file for the project.\\n'\n" +" '\\n'\n" +" 'The file should use UTF-8 encoding and be written using ReStructured '\n" +" 'Text. It\\n'\n" +" 'will be used to generate the project webpage on PyPI, and should be '\n" +" 'written for\\n'\n" +" 'that purpose.\\n'\n" +" '\\n'\n" +" 'Typical contents for this file would include an overview of the project, " +"'\n" +" 'basic\\n'\n" +" 'usage examples, etc. Generally, including the project changelog in here " +"'\n" +" 'is not\\n'\n" +" 'a good idea, although a simple \"What\\'s New\" section for the most " +"recent '\n" +" 'version\\n'\n" +" 'may be appropriate.',\n" +" 'description_content_type': None,\n" +" 'docs_url': None,\n" +" 'download_url': 'UNKNOWN',\n" +" 'downloads': {'last_day': -1, 'last_month': -1, 'last_week': -1},\n" +" 'dynamic': None,\n" +" 'home_page': 'https://github.com/pypa/sampleproject',\n" +" 'keywords': 'sample setuptools development',\n" +" 'license': 'MIT',\n" +" 'license_expression': None,\n" +" 'license_files': None,\n" +" 'maintainer': None,\n" +" 'maintainer_email': None,\n" +" 'name': 'sampleproject',\n" +" 'package_url': 'https://pypi.org/project/sampleproject/',\n" +" 'platform': 'UNKNOWN',\n" +" 'project_url': 'https://pypi.org/project/sampleproject/',\n" +" 'project_urls': {\n" +" 'Download': 'UNKNOWN',\n" +" 'Homepage': 'https://github.com/pypa/sampleproject',\n" +" },\n" +" 'provides_extra': None,\n" +" 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',\n" +" 'requires_dist': None,\n" +" 'requires_python': None,\n" +" 'summary': 'A sample Python project',\n" +" 'version': '1.2.0',\n" +" 'yanked': False,\n" +" 'yanked_reason': None,\n" +"}" +msgstr "" +">>> pprint.pp(project_info, indent=4, expand=True)\n" +"{\n" +" 'author': 'The Python Packaging Authority',\n" +" 'author_email': 'pypa-dev@googlegroups.com',\n" +" 'bugtrack_url': None,\n" +" 'classifiers': [\n" +" 'Development Status :: 3 - Alpha',\n" +" 'Intended Audience :: Developers',\n" +" 'License :: OSI Approved :: MIT License',\n" +" 'Programming Language :: Python :: 2',\n" +" 'Programming Language :: Python :: 2.6',\n" +" 'Programming Language :: Python :: 2.7',\n" +" 'Programming Language :: Python :: 3',\n" +" 'Programming Language :: Python :: 3.2',\n" +" 'Programming Language :: Python :: 3.3',\n" +" 'Programming Language :: Python :: 3.4',\n" +" 'Topic :: Software Development :: Build Tools',\n" +" ],\n" +" 'description': 'A sample Python project\\n'\n" +" '=======================\\n'\n" +" '\\n'\n" +" 'This is the description file for the project.\\n'\n" +" '\\n'\n" +" 'The file should use UTF-8 encoding and be written using ReStructured '\n" +" 'Text. It\\n'\n" +" 'will be used to generate the project webpage on PyPI, and should be '\n" +" 'written for\\n'\n" +" 'that purpose.\\n'\n" +" '\\n'\n" +" 'Typical contents for this file would include an overview of the project, " +"'\n" +" 'basic\\n'\n" +" 'usage examples, etc. Generally, including the project changelog in here " +"'\n" +" 'is not\\n'\n" +" 'a good idea, although a simple \"What\\'s New\" section for the most " +"recent '\n" +" 'version\\n'\n" +" 'may be appropriate.',\n" +" 'description_content_type': None,\n" +" 'docs_url': None,\n" +" 'download_url': 'UNKNOWN',\n" +" 'downloads': {'last_day': -1, 'last_month': -1, 'last_week': -1},\n" +" 'dynamic': None,\n" +" 'home_page': 'https://github.com/pypa/sampleproject',\n" +" 'keywords': 'sample setuptools development',\n" +" 'license': 'MIT',\n" +" 'license_expression': None,\n" +" 'license_files': None,\n" +" 'maintainer': None,\n" +" 'maintainer_email': None,\n" +" 'name': 'sampleproject',\n" +" 'package_url': 'https://pypi.org/project/sampleproject/',\n" +" 'platform': 'UNKNOWN',\n" +" 'project_url': 'https://pypi.org/project/sampleproject/',\n" +" 'project_urls': {\n" +" 'Download': 'UNKNOWN',\n" +" 'Homepage': 'https://github.com/pypa/sampleproject',\n" +" },\n" +" 'provides_extra': None,\n" +" 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',\n" +" 'requires_dist': None,\n" +" 'requires_python': None,\n" +" 'summary': 'A sample Python project',\n" +" 'version': '1.2.0',\n" +" 'yanked': False,\n" +" 'yanked_reason': None,\n" +"}" + +#: ../../library/pprint.rst:126 ../../library/pprint.rst:249 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../library/pprint.rst:119 ../../library/pprint.rst:222 +#: ../../library/pprint.rst:126 ../../library/pprint.rst:249 msgid "eval" msgstr "eval" -#: ../../library/pprint.rst:153 +#: ../../library/pprint.rst:160 msgid "..." msgstr "..." -#: ../../library/pprint.rst:153 +#: ../../library/pprint.rst:160 msgid "placeholder" msgstr "placeholder(佔位符號)" diff --git a/library/profile.po b/library/profile.po index 32479dfba97..6f2bc48a903 100644 --- a/library/profile.po +++ b/library/profile.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-12 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -18,400 +18,103 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/profile.rst:5 -msgid "The Python Profilers" -msgstr "Python 的分析器" - -#: ../../library/profile.rst:7 -msgid "**Source code:** :source:`Lib/profile.py` and :source:`Lib/pstats.py`" -msgstr "**原始碼:**\\ :source:`Lib/profile.py` 與 :source:`Lib/pstats.py`" - -#: ../../library/profile.rst:14 -msgid "Introduction to the profilers" -msgstr "分析器簡介" - -#: ../../library/profile.rst:20 -msgid "" -":mod:`cProfile` and :mod:`profile` provide :dfn:`deterministic profiling` of " -"Python programs. A :dfn:`profile` is a set of statistics that describes how " -"often and for how long various parts of the program executed. These " -"statistics can be formatted into reports via the :mod:`pstats` module." +msgid ":mod:`!profile` --- Pure Python profiler" msgstr "" -#: ../../library/profile.rst:25 -msgid "" -"The Python standard library provides two different implementations of the " -"same profiling interface:" -msgstr "" +#: ../../library/profile.rst:11 +msgid "**Source code:** :source:`Lib/profile.py`" +msgstr "**原始碼:**\\ :source:`Lib/profile.py`" -#: ../../library/profile.rst:28 +#: ../../library/profile.rst:17 msgid "" -":mod:`cProfile` is recommended for most users; it's a C extension with " -"reasonable overhead that makes it suitable for profiling long-running " -"programs. Based on :mod:`lsprof`, contributed by Brett Rosen and Ted " -"Czotter." +"The :mod:`!profile` module is deprecated and will be removed in Python 3.17. " +"Use :mod:`profiling.tracing` instead." 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." -msgstr "" - -#: ../../library/profile.rst:40 +#: ../../library/profile.rst:20 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." +"The :mod:`!profile` module provides a pure Python implementation of a " +"deterministic profiler. While useful for understanding profiler internals or " +"extending profiler behavior through subclassing, its pure Python " +"implementation introduces significant overhead compared to the C-based :mod:" +"`profiling.tracing` module." msgstr "" -#: ../../library/profile.rst:51 -msgid "Instant User's Manual" +#: ../../library/profile.rst:26 +msgid "For most profiling tasks, use:" msgstr "" -#: ../../library/profile.rst:53 -msgid "" -"This section is provided for users that \"don't want to read the manual.\" " -"It provides a very brief overview, and allows a user to rapidly perform " -"profiling on an existing application." -msgstr "" - -#: ../../library/profile.rst:57 -msgid "To profile a function that takes a single argument, you can do::" +#: ../../library/profile.rst:28 +msgid ":mod:`profiling.sampling` for production debugging with zero overhead" msgstr "" -#: ../../library/profile.rst:59 -msgid "" -"import cProfile\n" -"import re\n" -"cProfile.run('re.compile(\"foo|bar\")')" +#: ../../library/profile.rst:29 +msgid ":mod:`profiling.tracing` for development and testing" msgstr "" -"import cProfile\n" -"import re\n" -"cProfile.run('re.compile(\"foo|bar\")')" -#: ../../library/profile.rst:63 -msgid "" -"(Use :mod:`profile` instead of :mod:`cProfile` if the latter is not " -"available on your system.)" -msgstr "" +#: ../../library/profile.rst:33 +msgid "Migration" +msgstr "遷移" -#: ../../library/profile.rst:66 +#: ../../library/profile.rst:35 msgid "" -"The above action would run :func:`re.compile` and print profile results like " -"the following::" +"Migrating from :mod:`!profile` to :mod:`profiling.tracing` is " +"straightforward. The APIs are compatible::" msgstr "" -#: ../../library/profile.rst:69 +#: ../../library/profile.rst:38 msgid "" -" 214 function calls (207 primitive calls) in 0.002 seconds\n" -"\n" -"Ordered by: cumulative time\n" +"# Old (deprecated)\n" +"import profile\n" +"profile.run('my_function()')\n" "\n" -"ncalls tottime percall cumtime percall filename:lineno(function)\n" -" 1 0.000 0.000 0.002 0.002 {built-in method builtins.exec}\n" -" 1 0.000 0.000 0.001 0.001 :1()\n" -" 1 0.000 0.000 0.001 0.001 __init__.py:250(compile)\n" -" 1 0.000 0.000 0.001 0.001 __init__.py:289(_compile)\n" -" 1 0.000 0.000 0.000 0.000 _compiler.py:759(compile)\n" -" 1 0.000 0.000 0.000 0.000 _parser.py:937(parse)\n" -" 1 0.000 0.000 0.000 0.000 _compiler.py:598(_code)\n" -" 1 0.000 0.000 0.000 0.000 _parser.py:435(_parse_sub)" +"# New (recommended)\n" +"import profiling.tracing\n" +"profiling.tracing.run('my_function()')" msgstr "" -" 214 function calls (207 primitive calls) in 0.002 seconds\n" -"\n" -"Ordered by: cumulative time\n" +"# 舊式(已棄用)\n" +"import profile\n" +"profile.run('my_function()')\n" "\n" -"ncalls tottime percall cumtime percall filename:lineno(function)\n" -" 1 0.000 0.000 0.002 0.002 {built-in method builtins.exec}\n" -" 1 0.000 0.000 0.001 0.001 :1()\n" -" 1 0.000 0.000 0.001 0.001 __init__.py:250(compile)\n" -" 1 0.000 0.000 0.001 0.001 __init__.py:289(_compile)\n" -" 1 0.000 0.000 0.000 0.000 _compiler.py:759(compile)\n" -" 1 0.000 0.000 0.000 0.000 _parser.py:937(parse)\n" -" 1 0.000 0.000 0.000 0.000 _compiler.py:598(_code)\n" -" 1 0.000 0.000 0.000 0.000 _parser.py:435(_parse_sub)" - -#: ../../library/profile.rst:83 -msgid "" -"The first line indicates that 214 calls were monitored. Of those calls, 207 " -"were :dfn:`primitive`, meaning that the call was not induced via recursion. " -"The next line: ``Ordered by: cumulative time`` indicates the output is " -"sorted by the ``cumtime`` values. The column headings include:" -msgstr "" - -#: ../../library/profile.rst:88 -msgid "ncalls" -msgstr "ncalls" - -#: ../../library/profile.rst:89 -msgid "for the number of calls." -msgstr "" - -#: ../../library/profile.rst:91 -msgid "tottime" -msgstr "tottime" - -#: ../../library/profile.rst:92 -msgid "" -"for the total time spent in the given function (and excluding time made in " -"calls to sub-functions)" -msgstr "" - -#: ../../library/profile.rst:95 ../../library/profile.rst:102 -msgid "percall" -msgstr "percall" - -#: ../../library/profile.rst:96 -msgid "is the quotient of ``tottime`` divided by ``ncalls``" -msgstr "" - -#: ../../library/profile.rst:98 -msgid "cumtime" -msgstr "cumtime" - -#: ../../library/profile.rst:99 -msgid "" -"is the cumulative time spent in this and all subfunctions (from invocation " -"till exit). This figure is accurate *even* for recursive functions." -msgstr "" - -#: ../../library/profile.rst:103 -msgid "is the quotient of ``cumtime`` divided by primitive calls" -msgstr "" - -#: ../../library/profile.rst:105 -msgid "filename:lineno(function)" -msgstr "filename:lineno(function)" - -#: ../../library/profile.rst:106 -msgid "provides the respective data of each function" -msgstr "" - -#: ../../library/profile.rst:108 -msgid "" -"When there are two numbers in the first column (for example ``3/1``), it " -"means that the function recursed. The second value is the number of " -"primitive calls and the former is the total number of calls. Note that when " -"the function does not recurse, these two values are the same, and only the " -"single figure is printed." -msgstr "" - -#: ../../library/profile.rst:114 -msgid "" -"Instead of printing the output at the end of the profile run, you can save " -"the results to a file by specifying a filename to the :func:`run` function::" -msgstr "" - -#: ../../library/profile.rst:117 -msgid "" -"import cProfile\n" -"import re\n" -"cProfile.run('re.compile(\"foo|bar\")', 'restats')" -msgstr "" -"import cProfile\n" -"import re\n" -"cProfile.run('re.compile(\"foo|bar\")', 'restats')" +"# 新式(建議使用)\n" +"import profiling.tracing\n" +"profiling.tracing.run('my_function()')" -#: ../../library/profile.rst:121 +#: ../../library/profile.rst:46 msgid "" -"The :class:`pstats.Stats` class reads profile results from a file and " -"formats them in various ways." +"For most code, replacing ``import profile`` with ``import profiling." +"tracing`` (and using ``profiling.tracing`` instead of ``profile`` " +"throughout) provides a straightforward migration path." msgstr "" -#: ../../library/profile.rst:128 +#: ../../library/profile.rst:52 msgid "" -"The files :mod:`cProfile` and :mod:`profile` can also be invoked as a script " -"to profile another script. For example::" +"The ``cProfile`` module remains available as a backward-compatible alias to :" +"mod:`profiling.tracing`. Existing code using ``import cProfile`` will " +"continue to work without modification." msgstr "" -#: ../../library/profile.rst:131 -msgid "" -"python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript.py)" -msgstr "" -"python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript.py)" - -#: ../../library/profile.rst:135 -msgid "Writes the profile results to a file instead of to stdout." -msgstr "" +#: ../../library/profile.rst:58 +msgid ":mod:`!profile` and :mod:`!profiling.tracing` module reference" +msgstr ":mod:`!profile` 與 :mod:`!profiling.tracing` 模組參考文件" -#: ../../library/profile.rst:139 +#: ../../library/profile.rst:60 msgid "" -"Specifies one of the :func:`~pstats.Stats.sort_stats` sort values to sort " -"the output by. This only applies when :option:`-o ` is not " -"supplied." -msgstr "" - -#: ../../library/profile.rst:145 -msgid "Specifies that a module is being profiled instead of a script." -msgstr "" - -#: ../../library/profile.rst:147 -msgid "Added the ``-m`` option to :mod:`cProfile`." -msgstr "新增 ``-m`` 選項到 :mod:`cProfile`。" +"Both the :mod:`!profile` and :mod:`profiling.tracing` modules provide the " +"following functions:" +msgstr ":mod:`!profile` 與 :mod:`profiling.tracing` 模組都提供以下函式:" -#: ../../library/profile.rst:150 -msgid "Added the ``-m`` option to :mod:`profile`." -msgstr "新增 ``-m`` 選項到 :mod:`profile`。" - -#: ../../library/profile.rst:153 -msgid "" -"The :mod:`pstats` module's :class:`~pstats.Stats` class has a variety of " -"methods for manipulating and printing the data saved into a profile results " -"file::" -msgstr "" - -#: ../../library/profile.rst:156 -msgid "" -"import pstats\n" -"from pstats import SortKey\n" -"p = pstats.Stats('restats')\n" -"p.strip_dirs().sort_stats(-1).print_stats()" -msgstr "" -"import pstats\n" -"from pstats import SortKey\n" -"p = pstats.Stats('restats')\n" -"p.strip_dirs().sort_stats(-1).print_stats()" - -#: ../../library/profile.rst:161 -msgid "" -"The :meth:`~pstats.Stats.strip_dirs` method removed the extraneous path from " -"all the module names. The :meth:`~pstats.Stats.sort_stats` method sorted all " -"the entries according to the standard module/line/name string that is " -"printed. The :meth:`~pstats.Stats.print_stats` method printed out all the " -"statistics. You might try the following sort calls::" -msgstr "" - -#: ../../library/profile.rst:167 -msgid "" -"p.sort_stats(SortKey.NAME)\n" -"p.print_stats()" -msgstr "" -"p.sort_stats(SortKey.NAME)\n" -"p.print_stats()" - -#: ../../library/profile.rst:170 -msgid "" -"The first call will actually sort the list by function name, and the second " -"call will print out the statistics. The following are some interesting " -"calls to experiment with::" -msgstr "" - -#: ../../library/profile.rst:174 -msgid "p.sort_stats(SortKey.CUMULATIVE).print_stats(10)" -msgstr "p.sort_stats(SortKey.CUMULATIVE).print_stats(10)" - -#: ../../library/profile.rst:176 -msgid "" -"This sorts the profile by cumulative time in a function, and then only " -"prints the ten most significant lines. If you want to understand what " -"algorithms are taking time, the above line is what you would use." -msgstr "" - -#: ../../library/profile.rst:180 -msgid "" -"If you were looking to see what functions were looping a lot, and taking a " -"lot of time, you would do::" -msgstr "" - -#: ../../library/profile.rst:183 -msgid "p.sort_stats(SortKey.TIME).print_stats(10)" -msgstr "p.sort_stats(SortKey.TIME).print_stats(10)" - -#: ../../library/profile.rst:185 -msgid "" -"to sort according to time spent within each function, and then print the " -"statistics for the top ten functions." -msgstr "" - -#: ../../library/profile.rst:188 -msgid "You might also try::" -msgstr "" - -#: ../../library/profile.rst:190 -msgid "p.sort_stats(SortKey.FILENAME).print_stats('__init__')" -msgstr "p.sort_stats(SortKey.FILENAME).print_stats('__init__')" - -#: ../../library/profile.rst:192 -msgid "" -"This will sort all the statistics by file name, and then print out " -"statistics for only the class init methods (since they are spelled with " -"``__init__`` in them). As one final example, you could try::" -msgstr "" - -#: ../../library/profile.rst:196 -msgid "p.sort_stats(SortKey.TIME, SortKey.CUMULATIVE).print_stats(.5, 'init')" -msgstr "p.sort_stats(SortKey.TIME, SortKey.CUMULATIVE).print_stats(.5, 'init')" - -#: ../../library/profile.rst:198 -msgid "" -"This line sorts statistics with a primary key of time, and a secondary key " -"of cumulative time, and then prints out some of the statistics. To be " -"specific, the list is first culled down to 50% (re: ``.5``) of its original " -"size, then only lines containing ``init`` are maintained, and that sub-sub-" -"list is printed." -msgstr "" - -#: ../../library/profile.rst:203 -msgid "" -"If you wondered what functions called the above functions, you could now " -"(``p`` is still sorted according to the last criteria) do::" -msgstr "" - -#: ../../library/profile.rst:206 -msgid "p.print_callers(.5, 'init')" -msgstr "p.print_callers(.5, 'init')" - -#: ../../library/profile.rst:208 -msgid "and you would get a list of callers for each of the listed functions." -msgstr "" - -#: ../../library/profile.rst:210 -msgid "" -"If you want more functionality, you're going to have to read the manual, or " -"guess what the following functions do::" -msgstr "" - -#: ../../library/profile.rst:213 -msgid "" -"p.print_callees()\n" -"p.add('restats')" -msgstr "" -"p.print_callees()\n" -"p.add('restats')" - -#: ../../library/profile.rst:216 -msgid "" -"Invoked as a script, the :mod:`pstats` module is a statistics browser for " -"reading and examining profile dumps. It has a simple line-oriented " -"interface (implemented using :mod:`cmd`) and interactive help." -msgstr "" - -#: ../../library/profile.rst:221 -msgid ":mod:`profile` and :mod:`!cProfile` Module Reference" -msgstr ":mod:`profile` 與 :mod:`!cProfile` 模組參考文件" - -#: ../../library/profile.rst:227 -msgid "" -"Both the :mod:`profile` and :mod:`!cProfile` modules provide the following " -"functions:" -msgstr ":mod:`profile` 與 :mod:`!cProfile` 模組都提供以下函式:" - -#: ../../library/profile.rst:232 +#: ../../library/profile.rst:65 msgid "" "This function takes a single argument that can be passed to the :func:`exec` " "function, and an optional file name. In all cases this routine executes::" msgstr "" -#: ../../library/profile.rst:235 +#: ../../library/profile.rst:68 msgid "exec(command, __main__.__dict__, __main__.__dict__)" msgstr "exec(command, __main__.__dict__, __main__.__dict__)" -#: ../../library/profile.rst:237 +#: ../../library/profile.rst:70 msgid "" "and gathers profiling statistics from the execution. If no file name is " "present, then this function automatically creates a :class:`~pstats.Stats` " @@ -420,27 +123,27 @@ msgid "" "how the results are sorted." msgstr "" -#: ../../library/profile.rst:245 +#: ../../library/profile.rst:78 msgid "" "This function is similar to :func:`run`, with added arguments to supply the " "globals and locals mappings for the *command* string. This routine executes::" msgstr "" -#: ../../library/profile.rst:249 +#: ../../library/profile.rst:82 msgid "exec(command, globals, locals)" msgstr "exec(command, globals, locals)" -#: ../../library/profile.rst:251 +#: ../../library/profile.rst:84 msgid "and gathers profiling statistics as in the :func:`run` function above." msgstr "" -#: ../../library/profile.rst:255 +#: ../../library/profile.rst:88 msgid "" "This class is normally only used if more precise control over profiling is " -"needed than what the :func:`cProfile.run` function provides." +"needed than what the :func:`profiling.tracing.run` function provides." msgstr "" -#: ../../library/profile.rst:258 +#: ../../library/profile.rst:91 msgid "" "A custom timer can be supplied for measuring how long code takes to run via " "the *timer* argument. This must be a function that returns a single number " @@ -450,17 +153,20 @@ msgid "" "time unit would be ``.001``." msgstr "" -#: ../../library/profile.rst:265 +#: ../../library/profile.rst:98 msgid "" "Directly using the :class:`Profile` class allows formatting profile results " "without writing the profile data to a file::" msgstr "" -#: ../../library/profile.rst:268 +#: ../../library/profile.rst:101 msgid "" -"import cProfile, pstats, io\n" +"import profiling.tracing\n" +"import pstats\n" +"import io\n" "from pstats import SortKey\n" -"pr = cProfile.Profile()\n" +"\n" +"pr = profiling.tracing.Profile()\n" "pr.enable()\n" "# ... do something ...\n" "pr.disable()\n" @@ -470,9 +176,12 @@ msgid "" "ps.print_stats()\n" "print(s.getvalue())" msgstr "" -"import cProfile, pstats, io\n" +"import profiling.tracing\n" +"import pstats\n" +"import io\n" "from pstats import SortKey\n" -"pr = cProfile.Profile()\n" +"\n" +"pr = profiling.tracing.Profile()\n" "pr.enable()\n" "# ... do something ...\n" "pr.disable()\n" @@ -482,82 +191,83 @@ msgstr "" "ps.print_stats()\n" "print(s.getvalue())" -#: ../../library/profile.rst:280 +#: ../../library/profile.rst:116 msgid "" "The :class:`Profile` class can also be used as a context manager (supported " -"only in :mod:`!cProfile` module. see :ref:`typecontextmanager`)::" +"only in :mod:`profiling.tracing`, not in the deprecated :mod:`!profile` " +"module; see :ref:`typecontextmanager`)::" msgstr "" -#: ../../library/profile.rst:283 +#: ../../library/profile.rst:120 msgid "" -"import cProfile\n" +"import profiling.tracing\n" "\n" -"with cProfile.Profile() as pr:\n" +"with profiling.tracing.Profile() as pr:\n" " # ... do something ...\n" "\n" " pr.print_stats()" msgstr "" -"import cProfile\n" +"import profiling.tracing\n" "\n" -"with cProfile.Profile() as pr:\n" +"with profiling.tracing.Profile() as pr:\n" " # ... do something ...\n" "\n" " pr.print_stats()" -#: ../../library/profile.rst:290 +#: ../../library/profile.rst:127 msgid "Added context manager support." msgstr "新增情境管理器的支援。" -#: ../../library/profile.rst:295 -msgid "Start collecting profiling data. Only in :mod:`!cProfile`." +#: ../../library/profile.rst:132 +msgid "Start collecting profiling data. Only in :mod:`profiling.tracing`." msgstr "" -#: ../../library/profile.rst:299 -msgid "Stop collecting profiling data. Only in :mod:`!cProfile`." +#: ../../library/profile.rst:136 +msgid "Stop collecting profiling data. Only in :mod:`profiling.tracing`." msgstr "" -#: ../../library/profile.rst:303 +#: ../../library/profile.rst:140 msgid "" "Stop collecting profiling data and record the results internally as the " "current profile." msgstr "" -#: ../../library/profile.rst:308 +#: ../../library/profile.rst:145 msgid "" "Create a :class:`~pstats.Stats` object based on the current profile and " "print the results to stdout." msgstr "" -#: ../../library/profile.rst:311 +#: ../../library/profile.rst:148 msgid "" "The *sort* parameter specifies the sorting order of the displayed " "statistics. It accepts a single key or a tuple of keys to enable multi-level " -"sorting, as in :func:`Stats.sort_stats `." +"sorting, as in :meth:`pstats.Stats.sort_stats`." msgstr "" -#: ../../library/profile.rst:315 +#: ../../library/profile.rst:152 msgid ":meth:`~Profile.print_stats` now accepts a tuple of keys." msgstr "" -#: ../../library/profile.rst:320 +#: ../../library/profile.rst:157 msgid "Write the results of the current profile to *filename*." msgstr "" -#: ../../library/profile.rst:324 +#: ../../library/profile.rst:161 msgid "Profile the cmd via :func:`exec`." msgstr "" -#: ../../library/profile.rst:328 +#: ../../library/profile.rst:165 msgid "" "Profile the cmd via :func:`exec` with the specified global and local " "environment." msgstr "" -#: ../../library/profile.rst:333 +#: ../../library/profile.rst:170 msgid "Profile ``func(*args, **kwargs)``" msgstr "" -#: ../../library/profile.rst:335 +#: ../../library/profile.rst:172 msgid "" "Note that profiling will only work if the called command/function actually " "returns. If the interpreter is terminated (e.g. via a :func:`sys.exit` call " @@ -565,398 +275,61 @@ msgid "" "printed." msgstr "" -#: ../../library/profile.rst:343 -msgid "The :class:`Stats` Class" -msgstr ":class:`Stats` 類別" - -#: ../../library/profile.rst:345 -msgid "" -"Analysis of the profiler data is done using the :class:`~pstats.Stats` class." +#: ../../library/profile.rst:179 +msgid "Differences from :mod:`!profiling.tracing`" msgstr "" -#: ../../library/profile.rst:352 +#: ../../library/profile.rst:181 msgid "" -"This class constructor creates an instance of a \"statistics object\" from a " -"*filename* (or list of filenames) or from a :class:`Profile` instance. " -"Output will be printed to the stream specified by *stream*." +"The :mod:`!profile` module differs from :mod:`profiling.tracing` in several " +"ways:" msgstr "" -#: ../../library/profile.rst:356 +#: ../../library/profile.rst:184 msgid "" -"The file selected by the above constructor must have been created by the " -"corresponding version of :mod:`profile` or :mod:`cProfile`. To be specific, " -"there is *no* file compatibility guaranteed with future versions of this " -"profiler, and there is no compatibility with files produced by other " -"profilers, or the same profiler run on a different operating system. If " -"several files are provided, all the statistics for identical functions will " -"be coalesced, so that an overall view of several processes can be considered " -"in a single report. If additional files need to be combined with data in an " -"existing :class:`~pstats.Stats` object, the :meth:`~pstats.Stats.add` method " -"can be used." +"**Higher overhead.** The pure Python implementation is significantly slower " +"than the C implementation, making it unsuitable for profiling long-running " +"programs or performance-sensitive code." msgstr "" -#: ../../library/profile.rst:367 -msgid "" -"Instead of reading the profile data from a file, a :class:`cProfile.Profile` " -"or :class:`profile.Profile` object can be used as the profile data source." -msgstr "" - -#: ../../library/profile.rst:370 -msgid ":class:`Stats` objects have the following methods:" -msgstr ":class:`Stats` 物件有以下方法:" - -#: ../../library/profile.rst:374 -msgid "" -"This method for the :class:`Stats` class removes all leading path " -"information from file names. It is very useful in reducing the size of the " -"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." -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." -msgstr "" - -#: ../../library/profile.rst:398 -msgid "" -"Save the data loaded into the :class:`Stats` object to a file named " -"*filename*. The file is created if it does not exist, and is overwritten if " -"it already exists. This is equivalent to the method of the same name on " -"the :class:`profile.Profile` and :class:`cProfile.Profile` classes." -msgstr "" - -#: ../../library/profile.rst:406 -msgid "" -"This method modifies the :class:`Stats` object by sorting it according to " -"the supplied criteria. The argument can be either a string or a SortKey " -"enum identifying the basis of a sort (example: ``'time'``, ``'name'``, " -"``SortKey.TIME`` or ``SortKey.NAME``). The SortKey enums argument have " -"advantage over the string argument in that it is more robust and less error " -"prone." -msgstr "" - -#: ../../library/profile.rst:413 -msgid "" -"When more than one key is provided, then additional keys are used as " -"secondary criteria when there is equality in all keys selected before them. " -"For example, ``sort_stats(SortKey.NAME, SortKey.FILE)`` will sort all the " -"entries according to their function name, and resolve all ties (identical " -"function names) by sorting by file name." -msgstr "" - -#: ../../library/profile.rst:419 -msgid "" -"For the string argument, abbreviations can be used for any key names, as " -"long as the abbreviation is unambiguous." -msgstr "" - -#: ../../library/profile.rst:422 -msgid "The following are the valid string and SortKey:" -msgstr "" - -#: ../../library/profile.rst:425 -msgid "Valid String Arg" -msgstr "" - -#: ../../library/profile.rst:425 -msgid "Valid enum Arg" -msgstr "" - -#: ../../library/profile.rst:425 -msgid "Meaning" -msgstr "含義" - -#: ../../library/profile.rst:427 -msgid "``'calls'``" -msgstr "``'calls'``" - -#: ../../library/profile.rst:427 -msgid "SortKey.CALLS" -msgstr "SortKey.CALLS" - -#: ../../library/profile.rst:427 ../../library/profile.rst:439 -msgid "call count" -msgstr "" - -#: ../../library/profile.rst:429 -msgid "``'cumulative'``" -msgstr "``'cumulative'``" - -#: ../../library/profile.rst:429 -msgid "SortKey.CUMULATIVE" -msgstr "SortKey.CUMULATIVE" - -#: ../../library/profile.rst:429 ../../library/profile.rst:431 -msgid "cumulative time" -msgstr "" - -#: ../../library/profile.rst:431 -msgid "``'cumtime'``" -msgstr "``'cumtime'``" - -#: ../../library/profile.rst:431 ../../library/profile.rst:433 -#: ../../library/profile.rst:437 ../../library/profile.rst:439 -#: ../../library/profile.rst:453 -msgid "N/A" -msgstr "N/A" - -#: ../../library/profile.rst:433 -msgid "``'file'``" -msgstr "``'file'``" - -#: ../../library/profile.rst:433 ../../library/profile.rst:435 -#: ../../library/profile.rst:437 -msgid "file name" -msgstr "file name(檔案名稱)" - -#: ../../library/profile.rst:435 -msgid "``'filename'``" -msgstr "``'filename'``" - -#: ../../library/profile.rst:435 -msgid "SortKey.FILENAME" -msgstr "SortKey.FILENAME" - -#: ../../library/profile.rst:437 -msgid "``'module'``" -msgstr "``'module'``" - -#: ../../library/profile.rst:439 -msgid "``'ncalls'``" -msgstr "``'ncalls'``" - -#: ../../library/profile.rst:441 -msgid "``'pcalls'``" -msgstr "``'pcalls'``" - -#: ../../library/profile.rst:441 -msgid "SortKey.PCALLS" -msgstr "SortKey.PCALLS" - -#: ../../library/profile.rst:441 -msgid "primitive call count" -msgstr "" - -#: ../../library/profile.rst:443 -msgid "``'line'``" -msgstr "``'line'``" - -#: ../../library/profile.rst:443 -msgid "SortKey.LINE" -msgstr "SortKey.LINE" - -#: ../../library/profile.rst:443 -msgid "line number" -msgstr "列號" - -#: ../../library/profile.rst:445 -msgid "``'name'``" -msgstr "``'name'``" - -#: ../../library/profile.rst:445 -msgid "SortKey.NAME" -msgstr "SortKey.NAME" - -#: ../../library/profile.rst:445 -msgid "function name" -msgstr "" - -#: ../../library/profile.rst:447 -msgid "``'nfl'``" -msgstr "``'nfl'``" - -#: ../../library/profile.rst:447 -msgid "SortKey.NFL" -msgstr "SortKey.NFL" - -#: ../../library/profile.rst:447 -msgid "name/file/line" -msgstr "" - -#: ../../library/profile.rst:449 -msgid "``'stdname'``" -msgstr "``'stdname'``" - -#: ../../library/profile.rst:449 -msgid "SortKey.STDNAME" -msgstr "SortKey.STDNAME" - -#: ../../library/profile.rst:449 -msgid "standard name" -msgstr "" - -#: ../../library/profile.rst:451 -msgid "``'time'``" -msgstr "``'time'``" - -#: ../../library/profile.rst:451 -msgid "SortKey.TIME" -msgstr "SortKey.TIME" - -#: ../../library/profile.rst:451 ../../library/profile.rst:453 -msgid "internal time" -msgstr "" - -#: ../../library/profile.rst:453 -msgid "``'tottime'``" -msgstr "``'tottime'``" - -#: ../../library/profile.rst:456 -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, " -"``sort_stats(SortKey.NFL)`` is the same as ``sort_stats(SortKey.NAME, " -"SortKey.FILENAME, SortKey.LINE)``." -msgstr "" - -#: ../../library/profile.rst:467 -msgid "" -"For backward-compatibility reasons, the numeric arguments ``-1``, ``0``, " -"``1``, and ``2`` are permitted. They are interpreted as ``'stdname'``, " -"``'calls'``, ``'time'``, and ``'cumulative'`` respectively. If this old " -"style format (numeric) is used, only one sort key (the numeric key) will be " -"used, and additional arguments will be silently ignored." -msgstr "" - -#: ../../library/profile.rst:475 -msgid "Added the SortKey enum." -msgstr "" - -#: ../../library/profile.rst:480 -msgid "" -"This method for the :class:`Stats` class reverses the ordering of the basic " -"list within the object. Note that by default ascending vs descending order " -"is properly selected based on the sort key of choice." -msgstr "" - -#: ../../library/profile.rst:490 -msgid "" -"This method for the :class:`Stats` class prints out a report as described in " -"the :func:`profile.run` definition." -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`)." -msgstr "" - -#: ../../library/profile.rst:498 -msgid "" -"The arguments provided (if any) can be used to limit the list down to the " -"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 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::" -msgstr "" - -#: ../../library/profile.rst:507 -msgid "print_stats(.1, 'foo:')" -msgstr "print_stats(.1, 'foo:')" - -#: ../../library/profile.rst:509 -msgid "" -"would first limit the printing to first 10% of list, and then only print " -"functions that were part of filename :file:`.\\*foo:`. In contrast, the " -"command::" -msgstr "" - -#: ../../library/profile.rst:513 -msgid "print_stats('foo:', .1)" -msgstr "print_stats('foo:', .1)" - -#: ../../library/profile.rst:515 -msgid "" -"would limit the list to all functions having file names :file:`.\\*foo:`, " -"and then proceed to only print the first 10% of them." -msgstr "" - -#: ../../library/profile.rst:521 -msgid "" -"This method for the :class:`Stats` class prints a list of all functions that " -"called each function in the profiled database. The ordering is identical to " -"that provided by :meth:`~pstats.Stats.print_stats`, and the definition of " -"the restricting argument is also identical. Each caller is reported on its " -"own line. The format differs slightly depending on the profiler that " -"produced the stats:" -msgstr "" - -#: ../../library/profile.rst:528 -msgid "" -"With :mod:`profile`, a number is shown in parentheses after each caller to " -"show how many times this specific call was made. For convenience, a second " -"non-parenthesized number repeats the cumulative time spent in the function " -"at the right." -msgstr "" - -#: ../../library/profile.rst:533 -msgid "" -"With :mod:`cProfile`, each caller is preceded by three numbers: the number " -"of times this specific call was made, and the total and cumulative times " -"spent in the current function while it was invoked by this specific caller." -msgstr "" - -#: ../../library/profile.rst:541 +#: ../../library/profile.rst:188 msgid "" -"This method for the :class:`Stats` class prints a list of all function that " -"were called by the indicated function. Aside from this reversal of " -"direction of calls (re: called vs was called by), the arguments and ordering " -"are identical to the :meth:`~pstats.Stats.print_callers` method." +"**Calibration support.** The :mod:`!profile` module supports calibration to " +"compensate for profiling overhead. This is not needed in :mod:`profiling." +"tracing` because the C implementation has negligible overhead." msgstr "" -#: ../../library/profile.rst:549 +#: ../../library/profile.rst:192 msgid "" -"This method returns an instance of StatsProfile, which contains a mapping of " -"function names to instances of FunctionProfile. Each FunctionProfile " -"instance holds information related to the function's profile such as how " -"long the function took to run, how many times it was called, etc..." +"**Custom timers.** Both modules support custom timers, but :mod:`!profile` " +"accepts timer functions that return tuples (like :func:`os.times`), while :" +"mod:`profiling.tracing` requires a function returning a single number." msgstr "" -#: ../../library/profile.rst:554 +#: ../../library/profile.rst:196 msgid "" -"Added the following dataclasses: StatsProfile, FunctionProfile. Added the " -"following function: get_stats_profile." +"**Subclassing.** The pure Python implementation is easier to subclass and " +"extend for custom profiling behavior." msgstr "" -#: ../../library/profile.rst:561 -msgid "What Is Deterministic Profiling?" +#: ../../library/profile.rst:203 +msgid "What is deterministic profiling?" msgstr "" -#: ../../library/profile.rst:563 +#: ../../library/profile.rst:205 msgid "" ":dfn:`Deterministic profiling` is meant to reflect the fact that all " "*function call*, *function return*, and *exception* events are monitored, " "and precise timings are made for the intervals between these events (during " "which time the user's code is executing). In contrast, :dfn:`statistical " -"profiling` (which is not done by this module) randomly samples the effective " -"instruction pointer, and deduces where time is being spent. The latter " -"technique traditionally involves less overhead (as the code does not need to " -"be instrumented), but provides only relative indications of where time is " -"being spent." +"profiling` (which is provided by the :mod:`profiling.sampling` module) " +"periodically samples the effective instruction pointer, and deduces where " +"time is being spent. The latter technique traditionally involves less " +"overhead (as the code does not need to be instrumented), but provides only " +"relative indications of where time is being spent." msgstr "" -#: ../../library/profile.rst:572 +#: ../../library/profile.rst:215 msgid "" "In Python, since there is an interpreter active during execution, the " "presence of instrumented code is not required in order to do deterministic " @@ -968,7 +341,7 @@ msgid "" "time statistics about the execution of a Python program." msgstr "" -#: ../../library/profile.rst:581 +#: ../../library/profile.rst:224 msgid "" "Call count statistics can be used to identify bugs in code (surprising " "counts), and to identify possible inline-expansion points (high call " @@ -980,11 +353,11 @@ msgid "" "compared to iterative implementations." msgstr "" -#: ../../library/profile.rst:594 +#: ../../library/profile.rst:237 msgid "Limitations" msgstr "限制" -#: ../../library/profile.rst:596 +#: ../../library/profile.rst:239 msgid "" "One limitation has to do with accuracy of timing information. There is a " "fundamental problem with deterministic profilers involving accuracy. The " @@ -995,7 +368,7 @@ msgid "" "first error induces a second source of error." msgstr "" -#: ../../library/profile.rst:604 +#: ../../library/profile.rst:247 msgid "" "The second problem is that it \"takes a while\" from when an event is " "dispatched until the profiler's call to get the time actually *gets* the " @@ -1008,34 +381,34 @@ msgid "" "clock tick), but it *can* accumulate and become very significant." msgstr "" -#: ../../library/profile.rst:614 +#: ../../library/profile.rst:257 msgid "" -"The problem is more important with :mod:`profile` than with the lower-" -"overhead :mod:`cProfile`. For this reason, :mod:`profile` provides a means " -"of calibrating itself for a given platform so that this error can be " -"probabilistically (on the average) removed. After the profiler is " -"calibrated, it will be more accurate (in a least square sense), but it will " -"sometimes produce negative numbers (when call counts are exceptionally low, " -"and the gods of probability work against you :-). ) Do *not* be alarmed by " -"negative numbers in the profile. They should *only* appear if you have " -"calibrated your profiler, and the results are actually better than without " -"calibration." +"The problem is more important with the deprecated :mod:`!profile` module " +"than with the lower-overhead :mod:`profiling.tracing`. For this reason, :" +"mod:`!profile` provides a means of calibrating itself for a given platform " +"so that this error can be probabilistically (on the average) removed. After " +"the profiler is calibrated, it will be more accurate (in a least square " +"sense), but it will sometimes produce negative numbers (when call counts are " +"exceptionally low, and the gods of probability work against you :-). ) Do " +"*not* be alarmed by negative numbers in the profile. They should *only* " +"appear if you have calibrated your profiler, and the results are actually " +"better than without calibration." msgstr "" -#: ../../library/profile.rst:628 +#: ../../library/profile.rst:272 msgid "Calibration" msgstr "校正" -#: ../../library/profile.rst:630 +#: ../../library/profile.rst:274 msgid "" -"The profiler of the :mod:`profile` module subtracts a constant from each " +"The profiler of the :mod:`!profile` module subtracts a constant from each " "event handling time to compensate for the overhead of calling the time " "function, and socking away the results. By default, the constant is 0. The " "following procedure can be used to obtain a better constant for a given " "platform (see :ref:`profile-limitations`). ::" msgstr "" -#: ../../library/profile.rst:636 +#: ../../library/profile.rst:280 msgid "" "import profile\n" "pr = profile.Profile()\n" @@ -1047,7 +420,7 @@ msgstr "" "for i in range(5):\n" " print(pr.calibrate(10000))" -#: ../../library/profile.rst:641 +#: ../../library/profile.rst:285 msgid "" "The method executes the number of Python calls given by the argument, " "directly and again under the profiler, measuring the time for both. It then " @@ -1057,19 +430,19 @@ msgid "" "4.04e-6." msgstr "" -#: ../../library/profile.rst:647 +#: ../../library/profile.rst:291 msgid "" "The object of this exercise is to get a fairly consistent result. If your " "computer is *very* fast, or your timer function has poor resolution, you " "might have to pass 100000, or even 1000000, to get consistent results." msgstr "" -#: ../../library/profile.rst:651 +#: ../../library/profile.rst:295 msgid "" "When you have a consistent answer, there are three ways you can use it::" msgstr "" -#: ../../library/profile.rst:653 +#: ../../library/profile.rst:297 msgid "" "import profile\n" "\n" @@ -1084,40 +457,40 @@ msgid "" "pr = profile.Profile(bias=your_computed_bias)" msgstr "" -#: ../../library/profile.rst:665 +#: ../../library/profile.rst:309 msgid "" "If you have a choice, you are better off choosing a smaller constant, and " "then your results will \"less often\" show up as negative in profile " "statistics." msgstr "" -#: ../../library/profile.rst:671 +#: ../../library/profile.rst:316 msgid "Using a custom timer" msgstr "" -#: ../../library/profile.rst:673 +#: ../../library/profile.rst:318 msgid "" "If you want to change how current time is determined (for example, to force " "use of wall-clock time or elapsed process time), pass the timing function " "you want to the :class:`Profile` class constructor::" msgstr "" -#: ../../library/profile.rst:677 +#: ../../library/profile.rst:322 msgid "pr = profile.Profile(your_time_func)" msgstr "pr = profile.Profile(your_time_func)" -#: ../../library/profile.rst:679 +#: ../../library/profile.rst:324 msgid "" "The resulting profiler will then call ``your_time_func``. Depending on " -"whether you are using :class:`profile.Profile` or :class:`cProfile.Profile`, " -"``your_time_func``'s return value will be interpreted differently:" +"whether you are using :class:`profile.Profile` or :class:`profiling.tracing." +"Profile`, ``your_time_func``'s return value will be interpreted differently:" msgstr "" -#: ../../library/profile.rst:683 +#: ../../library/profile.rst:328 msgid ":class:`profile.Profile`" msgstr ":class:`profile.Profile`" -#: ../../library/profile.rst:684 +#: ../../library/profile.rst:329 msgid "" "``your_time_func`` should return a single number, or a list of numbers whose " "sum is the current time (like what :func:`os.times` returns). If the " @@ -1126,7 +499,7 @@ msgid "" "routine." msgstr "" -#: ../../library/profile.rst:690 +#: ../../library/profile.rst:335 msgid "" "Be warned that you should calibrate the profiler class for the timer " "function that you choose (see :ref:`profile-calibration`). For most " @@ -1138,11 +511,11 @@ msgid "" "along with the appropriate calibration constant." msgstr "" -#: ../../library/profile.rst:699 -msgid ":class:`cProfile.Profile`" -msgstr ":class:`cProfile.Profile`" +#: ../../library/profile.rst:344 +msgid ":class:`profiling.tracing.Profile`" +msgstr ":class:`profiling.tracing.Profile`" -#: ../../library/profile.rst:700 +#: ../../library/profile.rst:345 msgid "" "``your_time_func`` should return a single number. If it returns integers, " "you can also invoke the class constructor with a second argument specifying " @@ -1151,29 +524,266 @@ msgid "" "you would construct the :class:`Profile` instance as follows::" msgstr "" -#: ../../library/profile.rst:706 -msgid "pr = cProfile.Profile(your_integer_time_func, 0.001)" -msgstr "pr = cProfile.Profile(your_integer_time_func, 0.001)" +#: ../../library/profile.rst:351 +msgid "pr = profiling.tracing.Profile(your_integer_time_func, 0.001)" +msgstr "pr = profiling.tracing.Profile(your_integer_time_func, 0.001)" -#: ../../library/profile.rst:708 +#: ../../library/profile.rst:353 msgid "" -"As the :class:`cProfile.Profile` class cannot be calibrated, custom timer " -"functions should be used with care and should be as fast as possible. For " -"the best results with a custom timer, it might be necessary to hard-code it " -"in the C source of the internal :mod:`!_lsprof` module." +"As the :class:`profiling.tracing.Profile` class cannot be calibrated, custom " +"timer functions should be used with care and should be as fast as possible. " +"For the best results with a custom timer, it might be necessary to hard-code " +"it in the C source of the internal :mod:`!_lsprof` module." msgstr "" -#: ../../library/profile.rst:713 +#: ../../library/profile.rst:358 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`." msgstr "" -#: ../../library/profile.rst:16 -msgid "deterministic profiling" -msgstr "" +#: ../../library/profile.rst:365 +msgid ":mod:`profiling`" +msgstr ":mod:`profiling`" + +#: ../../library/profile.rst:366 +msgid "Overview of Python profiling tools." +msgstr "" + +#: ../../library/profile.rst:368 +msgid ":mod:`profiling.tracing`" +msgstr ":mod:`profiling.tracing`" + +#: ../../library/profile.rst:369 +msgid "Recommended replacement for this module." +msgstr "" + +#: ../../library/profile.rst:371 +msgid ":mod:`pstats`" +msgstr ":mod:`pstats`" + +#: ../../library/profile.rst:372 +msgid "Statistical analysis and formatting for profile data." +msgstr "" + +#~ msgid "The Python Profilers" +#~ msgstr "Python 的分析器" + +#~ msgid "Introduction to the profilers" +#~ msgstr "分析器簡介" + +#~ msgid "" +#~ "import cProfile\n" +#~ "import re\n" +#~ "cProfile.run('re.compile(\"foo|bar\")')" +#~ msgstr "" +#~ "import cProfile\n" +#~ "import re\n" +#~ "cProfile.run('re.compile(\"foo|bar\")')" + +#~ msgid "" +#~ " 214 function calls (207 primitive calls) in 0.002 seconds\n" +#~ "\n" +#~ "Ordered by: cumulative time\n" +#~ "\n" +#~ "ncalls tottime percall cumtime percall filename:lineno(function)\n" +#~ " 1 0.000 0.000 0.002 0.002 {built-in method builtins." +#~ "exec}\n" +#~ " 1 0.000 0.000 0.001 0.001 :1()\n" +#~ " 1 0.000 0.000 0.001 0.001 __init__.py:250(compile)\n" +#~ " 1 0.000 0.000 0.001 0.001 __init__.py:289(_compile)\n" +#~ " 1 0.000 0.000 0.000 0.000 _compiler.py:759(compile)\n" +#~ " 1 0.000 0.000 0.000 0.000 _parser.py:937(parse)\n" +#~ " 1 0.000 0.000 0.000 0.000 _compiler.py:598(_code)\n" +#~ " 1 0.000 0.000 0.000 0.000 _parser.py:435(_parse_sub)" +#~ msgstr "" +#~ " 214 function calls (207 primitive calls) in 0.002 seconds\n" +#~ "\n" +#~ "Ordered by: cumulative time\n" +#~ "\n" +#~ "ncalls tottime percall cumtime percall filename:lineno(function)\n" +#~ " 1 0.000 0.000 0.002 0.002 {built-in method builtins." +#~ "exec}\n" +#~ " 1 0.000 0.000 0.001 0.001 :1()\n" +#~ " 1 0.000 0.000 0.001 0.001 __init__.py:250(compile)\n" +#~ " 1 0.000 0.000 0.001 0.001 __init__.py:289(_compile)\n" +#~ " 1 0.000 0.000 0.000 0.000 _compiler.py:759(compile)\n" +#~ " 1 0.000 0.000 0.000 0.000 _parser.py:937(parse)\n" +#~ " 1 0.000 0.000 0.000 0.000 _compiler.py:598(_code)\n" +#~ " 1 0.000 0.000 0.000 0.000 _parser.py:435(_parse_sub)" + +#~ msgid "ncalls" +#~ msgstr "ncalls" + +#~ msgid "tottime" +#~ msgstr "tottime" + +#~ msgid "percall" +#~ msgstr "percall" + +#~ msgid "cumtime" +#~ msgstr "cumtime" + +#~ msgid "filename:lineno(function)" +#~ msgstr "filename:lineno(function)" + +#~ msgid "" +#~ "import cProfile\n" +#~ "import re\n" +#~ "cProfile.run('re.compile(\"foo|bar\")', 'restats')" +#~ msgstr "" +#~ "import cProfile\n" +#~ "import re\n" +#~ "cProfile.run('re.compile(\"foo|bar\")', 'restats')" + +#~ msgid "" +#~ "python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript." +#~ "py)" +#~ msgstr "" +#~ "python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript." +#~ "py)" + +#~ msgid "Added the ``-m`` option to :mod:`cProfile`." +#~ msgstr "新增 ``-m`` 選項到 :mod:`cProfile`。" + +#~ msgid "Added the ``-m`` option to :mod:`profile`." +#~ msgstr "新增 ``-m`` 選項到 :mod:`profile`。" + +#~ msgid "" +#~ "import pstats\n" +#~ "from pstats import SortKey\n" +#~ "p = pstats.Stats('restats')\n" +#~ "p.strip_dirs().sort_stats(-1).print_stats()" +#~ msgstr "" +#~ "import pstats\n" +#~ "from pstats import SortKey\n" +#~ "p = pstats.Stats('restats')\n" +#~ "p.strip_dirs().sort_stats(-1).print_stats()" + +#~ msgid "" +#~ "p.sort_stats(SortKey.NAME)\n" +#~ "p.print_stats()" +#~ msgstr "" +#~ "p.sort_stats(SortKey.NAME)\n" +#~ "p.print_stats()" + +#~ msgid "p.sort_stats(SortKey.CUMULATIVE).print_stats(10)" +#~ msgstr "p.sort_stats(SortKey.CUMULATIVE).print_stats(10)" + +#~ msgid "p.sort_stats(SortKey.TIME).print_stats(10)" +#~ msgstr "p.sort_stats(SortKey.TIME).print_stats(10)" + +#~ msgid "p.sort_stats(SortKey.FILENAME).print_stats('__init__')" +#~ msgstr "p.sort_stats(SortKey.FILENAME).print_stats('__init__')" + +#~ msgid "" +#~ "p.sort_stats(SortKey.TIME, SortKey.CUMULATIVE).print_stats(.5, 'init')" +#~ msgstr "" +#~ "p.sort_stats(SortKey.TIME, SortKey.CUMULATIVE).print_stats(.5, 'init')" + +#~ msgid "p.print_callers(.5, 'init')" +#~ msgstr "p.print_callers(.5, 'init')" + +#~ msgid "" +#~ "p.print_callees()\n" +#~ "p.add('restats')" +#~ msgstr "" +#~ "p.print_callees()\n" +#~ "p.add('restats')" -#: ../../library/profile.rst:16 -msgid "profiling, deterministic" -msgstr "" +#~ msgid "The :class:`Stats` Class" +#~ msgstr ":class:`Stats` 類別" + +#~ msgid ":class:`Stats` objects have the following methods:" +#~ msgstr ":class:`Stats` 物件有以下方法:" + +#~ msgid "Meaning" +#~ msgstr "含義" + +#~ msgid "``'calls'``" +#~ msgstr "``'calls'``" + +#~ msgid "SortKey.CALLS" +#~ msgstr "SortKey.CALLS" + +#~ msgid "``'cumulative'``" +#~ msgstr "``'cumulative'``" + +#~ msgid "SortKey.CUMULATIVE" +#~ msgstr "SortKey.CUMULATIVE" + +#~ msgid "``'cumtime'``" +#~ msgstr "``'cumtime'``" + +#~ msgid "N/A" +#~ msgstr "N/A" + +#~ msgid "``'file'``" +#~ msgstr "``'file'``" + +#~ msgid "file name" +#~ msgstr "file name(檔案名稱)" + +#~ msgid "``'filename'``" +#~ msgstr "``'filename'``" + +#~ msgid "SortKey.FILENAME" +#~ msgstr "SortKey.FILENAME" + +#~ msgid "``'module'``" +#~ msgstr "``'module'``" + +#~ msgid "``'ncalls'``" +#~ msgstr "``'ncalls'``" + +#~ msgid "``'pcalls'``" +#~ msgstr "``'pcalls'``" + +#~ msgid "SortKey.PCALLS" +#~ msgstr "SortKey.PCALLS" + +#~ msgid "``'line'``" +#~ msgstr "``'line'``" + +#~ msgid "SortKey.LINE" +#~ msgstr "SortKey.LINE" + +#~ msgid "line number" +#~ msgstr "列號" + +#~ msgid "``'name'``" +#~ msgstr "``'name'``" + +#~ msgid "SortKey.NAME" +#~ msgstr "SortKey.NAME" + +#~ msgid "``'nfl'``" +#~ msgstr "``'nfl'``" + +#~ msgid "SortKey.NFL" +#~ msgstr "SortKey.NFL" + +#~ msgid "``'stdname'``" +#~ msgstr "``'stdname'``" + +#~ msgid "SortKey.STDNAME" +#~ msgstr "SortKey.STDNAME" + +#~ msgid "``'time'``" +#~ msgstr "``'time'``" + +#~ msgid "SortKey.TIME" +#~ msgstr "SortKey.TIME" + +#~ msgid "``'tottime'``" +#~ msgstr "``'tottime'``" + +#~ msgid "print_stats(.1, 'foo:')" +#~ msgstr "print_stats(.1, 'foo:')" + +#~ msgid "print_stats('foo:', .1)" +#~ msgstr "print_stats('foo:', .1)" + +#~ msgid ":class:`cProfile.Profile`" +#~ msgstr ":class:`cProfile.Profile`" diff --git a/library/profiling.po b/library/profiling.po new file mode 100644 index 00000000000..a3629b31830 --- /dev/null +++ b/library/profiling.po @@ -0,0 +1,487 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../library/profiling.rst:7 +msgid ":mod:`!profiling` --- Python profilers" +msgstr "" + +#: ../../library/profiling.rst:14 +msgid "**Source code:** :source:`Lib/profiling/`" +msgstr "" + +#: ../../library/profiling.rst:26 +msgid "Introduction to profiling" +msgstr "" + +#: ../../library/profiling.rst:28 +msgid "" +"A :dfn:`profile` is a set of statistics that describes how often and for how " +"long various parts of a program execute. These statistics help identify " +"performance bottlenecks and guide optimization efforts. Python provides two " +"fundamentally different approaches to collecting this information: " +"statistical sampling and deterministic tracing." +msgstr "" + +#: ../../library/profiling.rst:34 +msgid "" +"The :mod:`!profiling` package organizes Python's built-in profiling tools " +"under a single namespace. It contains two submodules, each implementing a " +"different profiling methodology:" +msgstr "" + +#: ../../library/profiling.rst:38 ../../library/profiling.rst:250 +msgid ":mod:`profiling.sampling`" +msgstr ":mod:`profiling.sampling`" + +#: ../../library/profiling.rst:39 +msgid "" +"A statistical profiler that periodically samples the call stack. Run scripts " +"directly or attach to running processes by PID. Provides multiple output " +"formats (flame graphs, heatmaps, Firefox Profiler), GIL analysis, GC " +"tracking, and multiple profiling modes (wall-clock, CPU, GIL) with virtually " +"no overhead." +msgstr "" + +#: ../../library/profiling.rst:44 ../../library/profiling.rst:254 +msgid ":mod:`profiling.tracing`" +msgstr ":mod:`profiling.tracing`" + +#: ../../library/profiling.rst:45 +msgid "" +"A deterministic profiler that traces every function call, return, and " +"exception event. Provides exact call counts and precise timing information, " +"capturing every invocation including very fast functions." +msgstr "" + +#: ../../library/profiling.rst:51 +msgid "" +"The profiler modules are designed to provide an execution profile for a " +"given program, not for benchmarking purposes. For benchmarking, use the :mod:" +"`timeit` module, which provides reasonably accurate timing measurements. " +"This distinction is particularly important when comparing Python code " +"against C code: deterministic profilers introduce overhead for Python code " +"but not for C-level functions, which can skew comparisons." +msgstr "" + +#: ../../library/profiling.rst:62 +msgid "Choosing a profiler" +msgstr "" + +#: ../../library/profiling.rst:64 +msgid "" +"For most performance analysis, use the statistical profiler (:mod:`profiling." +"sampling`). It has minimal overhead, works for both development and " +"production, and provides rich visualization options including flame graphs, " +"heatmaps, GIL analysis, and more." +msgstr "" + +#: ../../library/profiling.rst:69 +msgid "" +"Use the deterministic profiler (:mod:`profiling.tracing`) when you need " +"**exact call counts** and cannot afford to miss any function calls. Since it " +"instruments every function call and return, it will capture even very fast " +"functions that complete between sampling intervals. The tradeoff is higher " +"overhead." +msgstr "" + +#: ../../library/profiling.rst:74 +msgid "The following table summarizes the key differences:" +msgstr "" + +#: ../../library/profiling.rst:77 +msgid "Feature" +msgstr "" + +#: ../../library/profiling.rst:77 +msgid "Statistical sampling (:mod:`profiling.sampling`)" +msgstr "" + +#: ../../library/profiling.rst:77 +msgid "Deterministic (:mod:`profiling.tracing`)" +msgstr "" + +#: ../../library/profiling.rst:80 +msgid "**Overhead**" +msgstr "" + +#: ../../library/profiling.rst:80 +msgid "Virtually none" +msgstr "" + +#: ../../library/profiling.rst:80 +msgid "Moderate" +msgstr "" + +#: ../../library/profiling.rst:82 +msgid "**Accuracy**" +msgstr "" + +#: ../../library/profiling.rst:82 +msgid "Statistical estimate" +msgstr "" + +#: ../../library/profiling.rst:82 +msgid "Exact call counts" +msgstr "" + +#: ../../library/profiling.rst:84 +msgid "**Output formats**" +msgstr "" + +#: ../../library/profiling.rst:84 +msgid "pstats, flame graph, heatmap, gecko, collapsed" +msgstr "" + +#: ../../library/profiling.rst:84 +msgid "pstats" +msgstr "" + +#: ../../library/profiling.rst:87 +msgid "**Profiling modes**" +msgstr "" + +#: ../../library/profiling.rst:87 +msgid "Wall-clock, CPU, GIL" +msgstr "" + +#: ../../library/profiling.rst:87 +msgid "Wall-clock" +msgstr "" + +#: ../../library/profiling.rst:89 +msgid "**Special frames**" +msgstr "" + +#: ../../library/profiling.rst:89 +msgid "GC, native (C extensions)" +msgstr "" + +#: ../../library/profiling.rst:89 +msgid "N/A" +msgstr "N/A" + +#: ../../library/profiling.rst:91 +msgid "**Attach to PID**" +msgstr "" + +#: ../../library/profiling.rst:91 +msgid "Yes" +msgstr "" + +#: ../../library/profiling.rst:91 +msgid "No" +msgstr "" + +#: ../../library/profiling.rst:96 +msgid "When to use statistical sampling" +msgstr "" + +#: ../../library/profiling.rst:98 +msgid "" +"The statistical profiler (:mod:`profiling.sampling`) is recommended for most " +"performance analysis tasks. Use it the same way you would use :mod:" +"`profiling.tracing`::" +msgstr "" + +#: ../../library/profiling.rst:102 +msgid "python -m profiling.sampling run script.py" +msgstr "python -m profiling.sampling run script.py" + +#: ../../library/profiling.rst:104 +msgid "" +"One of the main strengths of the sampling profiler is its variety of output " +"formats. Beyond traditional pstats tables, it can generate interactive flame " +"graphs that visualize call hierarchies, line-level source heatmaps that show " +"exactly where time is spent in your code, and Firefox Profiler output for " +"timeline-based analysis." +msgstr "" + +#: ../../library/profiling.rst:110 +msgid "" +"The profiler also provides insight into Python interpreter behavior that " +"deterministic profiling cannot capture. Use ``--mode gil`` to identify GIL " +"contention in multi-threaded code, ``--mode cpu`` to measure actual CPU time " +"excluding I/O waits, or inspect ```` frames to understand garbage " +"collection overhead. The ``--native`` option reveals time spent in C " +"extensions, helping distinguish Python overhead from library performance." +msgstr "" + +#: ../../library/profiling.rst:117 +msgid "" +"For multi-threaded applications, the ``-a`` option samples all threads " +"simultaneously, showing how work is distributed. And for production " +"debugging, the ``attach`` command connects to any running Python process by " +"PID without requiring a restart or code changes." +msgstr "" + +#: ../../library/profiling.rst:124 +msgid "When to use deterministic tracing" +msgstr "" + +#: ../../library/profiling.rst:126 +msgid "" +"The deterministic profiler (:mod:`profiling.tracing`) instruments every " +"function call and return. This approach has higher overhead than sampling, " +"but guarantees complete coverage of program execution." +msgstr "" + +#: ../../library/profiling.rst:130 +msgid "" +"The primary reason to choose deterministic tracing is when you need exact " +"call counts. Statistical profiling estimates frequency based on sampling, " +"which may undercount short-lived functions that complete between samples. If " +"you need to verify that an optimization actually reduced the number of " +"function calls, or if you want to trace the complete call graph to " +"understand caller-callee relationships, deterministic tracing is the right " +"choice." +msgstr "" + +#: ../../library/profiling.rst:137 +msgid "" +"Deterministic tracing also excels at capturing functions that execute in " +"microseconds. Such functions may not appear frequently enough in statistical " +"samples, but deterministic tracing records every invocation regardless of " +"duration." +msgstr "" + +#: ../../library/profiling.rst:144 +msgid "Quick start" +msgstr "" + +#: ../../library/profiling.rst:146 +msgid "" +"This section provides the minimal steps needed to start profiling. For " +"complete documentation, see the dedicated pages for each profiler." +msgstr "" + +#: ../../library/profiling.rst:151 +msgid "Statistical profiling" +msgstr "" + +#: ../../library/profiling.rst:153 +msgid "" +"To profile a script, use the :mod:`profiling.sampling` module with the " +"``run`` command::" +msgstr "" + +#: ../../library/profiling.rst:156 +msgid "" +"python -m profiling.sampling run script.py\n" +"python -m profiling.sampling run -m mypackage.module" +msgstr "" +"python -m profiling.sampling run script.py\n" +"python -m profiling.sampling run -m mypackage.module" + +#: ../../library/profiling.rst:159 +msgid "" +"This runs the script under the profiler and prints a summary of where time " +"was spent. For an interactive flame graph::" +msgstr "" + +#: ../../library/profiling.rst:162 +msgid "python -m profiling.sampling run --flamegraph script.py" +msgstr "python -m profiling.sampling run --flamegraph script.py" + +#: ../../library/profiling.rst:164 +msgid "" +"To profile an already-running process, use the ``attach`` command with the " +"process ID::" +msgstr "" + +#: ../../library/profiling.rst:167 +msgid "python -m profiling.sampling attach 1234" +msgstr "python -m profiling.sampling attach 1234" + +#: ../../library/profiling.rst:169 +msgid "" +"For custom settings, specify the sampling interval (in microseconds) and " +"duration (in seconds)::" +msgstr "" + +#: ../../library/profiling.rst:172 +msgid "python -m profiling.sampling run -i 50 -d 30 script.py" +msgstr "python -m profiling.sampling run -i 50 -d 30 script.py" + +#: ../../library/profiling.rst:176 +msgid "Deterministic profiling" +msgstr "" + +#: ../../library/profiling.rst:178 +msgid "To profile a script from the command line::" +msgstr "" + +#: ../../library/profiling.rst:180 +msgid "python -m profiling.tracing script.py" +msgstr "python -m profiling.tracing script.py" + +#: ../../library/profiling.rst:182 +msgid "To profile a piece of code programmatically:" +msgstr "" + +#: ../../library/profiling.rst:184 +msgid "" +"import profiling.tracing\n" +"profiling.tracing.run('my_function()')" +msgstr "" +"import profiling.tracing\n" +"profiling.tracing.run('my_function()')" + +#: ../../library/profiling.rst:189 +msgid "" +"This executes the given code under the profiler and prints a summary showing " +"exact function call counts and timing." +msgstr "" + +#: ../../library/profiling.rst:196 +msgid "Understanding profile output" +msgstr "" + +#: ../../library/profiling.rst:198 +msgid "" +"Both profilers collect function-level statistics, though they present them " +"in different formats. The sampling profiler offers multiple visualizations " +"(flame graphs, heatmaps, Firefox Profiler, pstats tables), while the " +"deterministic profiler produces pstats-compatible output. Regardless of " +"format, the underlying concepts are the same." +msgstr "" + +#: ../../library/profiling.rst:204 +msgid "Key profiling concepts:" +msgstr "" + +#: ../../library/profiling.rst:206 +msgid "**Direct time** (also called *self time* or *tottime*)" +msgstr "" + +#: ../../library/profiling.rst:207 +msgid "" +"Time spent executing code in the function itself, excluding time spent in " +"functions it called. High direct time indicates the function contains " +"expensive operations." +msgstr "" + +#: ../../library/profiling.rst:211 +msgid "**Cumulative time** (also called *total time* or *cumtime*)" +msgstr "" + +#: ../../library/profiling.rst:212 +msgid "" +"Time spent in the function and all functions it called. This measures the " +"total cost of calling a function, including its entire call subtree." +msgstr "" + +#: ../../library/profiling.rst:215 +msgid "**Call count** (also called *ncalls* or *samples*)" +msgstr "" + +#: ../../library/profiling.rst:216 +msgid "" +"How many times the function was called (deterministic) or sampled " +"(statistical). In deterministic profiling, this is exact. In statistical " +"profiling, it represents the number of times the function appeared in a " +"stack sample." +msgstr "" + +#: ../../library/profiling.rst:221 +msgid "**Primitive calls**" +msgstr "" + +#: ../../library/profiling.rst:222 +msgid "" +"Calls that are not induced by recursion. When a function recurses, the total " +"call count includes recursive invocations, but primitive calls counts only " +"the initial entry. Displayed as ``total/primitive`` (for example, ``3/1`` " +"means three total calls, one primitive)." +msgstr "" + +#: ../../library/profiling.rst:227 +msgid "**Caller/Callee relationships**" +msgstr "" + +#: ../../library/profiling.rst:228 +msgid "" +"Which functions called a given function (callers) and which functions it " +"called (callees). Flame graphs visualize this as nested rectangles; pstats " +"can display it via the :meth:`~pstats.Stats.print_callers` and :meth:" +"`~pstats.Stats.print_callees` methods." +msgstr "" + +#: ../../library/profiling.rst:235 +msgid "Legacy compatibility" +msgstr "" + +#: ../../library/profiling.rst:237 +msgid "" +"For backward compatibility, the ``cProfile`` module remains available as an " +"alias to :mod:`profiling.tracing`. Existing code using ``import cProfile`` " +"will continue to work without modification in all future Python versions." +msgstr "" + +#: ../../library/profiling.rst:243 +msgid "" +"The pure Python :mod:`profile` module is deprecated and will be removed in " +"Python 3.17. Use :mod:`profiling.tracing` (or its alias ``cProfile``) " +"instead. See :mod:`profile` for migration guidance." +msgstr "" + +#: ../../library/profiling.rst:251 +msgid "" +"Statistical sampling profiler with flame graphs, heatmaps, and GIL analysis. " +"Recommended for most users." +msgstr "" + +#: ../../library/profiling.rst:255 +msgid "Deterministic tracing profiler for exact call counts." +msgstr "" + +#: ../../library/profiling.rst:257 +msgid ":mod:`pstats`" +msgstr ":mod:`pstats`" + +#: ../../library/profiling.rst:258 +msgid "Statistics analysis and formatting for profile data." +msgstr "" + +#: ../../library/profiling.rst:260 +msgid ":mod:`timeit`" +msgstr ":mod:`timeit`" + +#: ../../library/profiling.rst:261 +msgid "Module for measuring execution time of small code snippets." +msgstr "" + +#: ../../library/profiling.rst:265 +msgid "Submodules" +msgstr "子模組" + +#: ../../library/profiling.rst:18 +msgid "statistical profiling" +msgstr "" + +#: ../../library/profiling.rst:18 +msgid "profiling, statistical" +msgstr "" + +#: ../../library/profiling.rst:18 +msgid "deterministic profiling" +msgstr "" + +#: ../../library/profiling.rst:18 +msgid "profiling, deterministic" +msgstr "" diff --git a/library/profiling.sampling.po b/library/profiling.sampling.po new file mode 100644 index 00000000000..3f16653d364 --- /dev/null +++ b/library/profiling.sampling.po @@ -0,0 +1,2915 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../library/profiling.sampling.rst:7 +msgid ":mod:`!profiling.sampling` --- Statistical profiler" +msgstr "" + +#: ../../library/profiling.sampling.rst:14 +msgid "**Source code:** :source:`Lib/profiling/sampling/`" +msgstr "" + +#: ../../library/profiling.sampling.rst:20 +msgid "Tachyon logo" +msgstr "" + +#: ../../library/profiling.sampling.rst:25 +msgid "" +"The :mod:`!profiling.sampling` module, named **Tachyon**, provides " +"statistical profiling of Python programs through periodic stack sampling. " +"Tachyon can run scripts directly or attach to any running Python process " +"without requiring code changes or restarts. Because sampling occurs " +"externally to the target process, overhead is virtually zero, making Tachyon " +"suitable for both development and production environments." +msgstr "" + +#: ../../library/profiling.sampling.rst:34 +msgid "What is statistical profiling?" +msgstr "" + +#: ../../library/profiling.sampling.rst:36 +msgid "" +"Statistical profiling builds a picture of program behavior by periodically " +"capturing snapshots of the call stack. Rather than instrumenting every " +"function call and return as deterministic profilers do, Tachyon reads the " +"call stack at regular intervals to record what code is currently running." +msgstr "" + +#: ../../library/profiling.sampling.rst:41 +msgid "" +"This approach rests on a simple principle: functions that consume " +"significant CPU time will appear frequently in the collected samples. By " +"gathering thousands of samples over a profiling session, Tachyon constructs " +"an accurate statistical estimate of where time is spent. The more samples " +"collected, the more precise this estimate becomes." +msgstr "" + +#: ../../library/profiling.sampling.rst:49 +msgid "" +"The following interactive visualization demonstrates how sampling profiling " +"works. Press **Play** to watch a Python program execute, and observe how the " +"profiler periodically captures snapshots of the call stack. Adjust the " +"**sample interval** to see how sampling frequency affects the results." +msgstr "" + +#: ../../library/profiling.sampling.rst:61 +msgid "" +"An interactive visualization of sampling profiling is available in the HTML " +"version of this documentation." +msgstr "" + +#: ../../library/profiling.sampling.rst:66 +msgid "How time is estimated" +msgstr "" + +#: ../../library/profiling.sampling.rst:68 +msgid "" +"The time values shown in Tachyon's output are **estimates derived from " +"sample counts**, not direct measurements. Tachyon counts how many times each " +"function appears in the collected samples, then multiplies by the sampling " +"interval to estimate time." +msgstr "" + +#: ../../library/profiling.sampling.rst:73 +msgid "" +"For example, with a 10 kHz sampling rate over a 10-second profile, Tachyon " +"collects approximately 100,000 samples. If a function appears in 5,000 " +"samples (5% of total), Tachyon estimates it consumed 5% of the 10-second " +"duration, or about 500 milliseconds. This is a statistical estimate, not a " +"precise measurement." +msgstr "" + +#: ../../library/profiling.sampling.rst:79 +msgid "" +"The accuracy of these estimates depends on sample count. With 100,000 " +"samples, a function showing 5% has a margin of error of roughly ±0.5%. With " +"only 1,000 samples, the same 5% measurement could actually represent " +"anywhere from 3% to 7% of real time." +msgstr "" + +#: ../../library/profiling.sampling.rst:84 +msgid "" +"This is why longer profiling durations and shorter sampling intervals " +"produce more reliable results---they collect more samples. For most " +"performance analysis, the default settings provide sufficient accuracy to " +"identify bottlenecks and guide optimization efforts." +msgstr "" + +#: ../../library/profiling.sampling.rst:89 +msgid "" +"Because sampling is statistical, results will vary slightly between runs. A " +"function showing 12% in one run might show 11% or 13% in the next. This is " +"normal and expected. Focus on the overall pattern rather than exact " +"percentages, and don't worry about small variations between runs." +msgstr "" + +#: ../../library/profiling.sampling.rst:96 +msgid "When to use a different approach" +msgstr "" + +#: ../../library/profiling.sampling.rst:98 +msgid "Statistical sampling is not ideal for every situation." +msgstr "" + +#: ../../library/profiling.sampling.rst:100 +msgid "" +"For very short scripts that complete in under one second, the profiler may " +"not collect enough samples for reliable results. Use :mod:`profiling." +"tracing` instead, or run the script in a loop to extend profiling time." +msgstr "" + +#: ../../library/profiling.sampling.rst:104 +msgid "" +"When you need exact call counts, sampling cannot provide them. Sampling " +"estimates frequency from snapshots, so if you need to know precisely how " +"many times a function was called, use :mod:`profiling.tracing`." +msgstr "" + +#: ../../library/profiling.sampling.rst:108 +msgid "" +"When comparing two implementations where the difference might be only 1-2%, " +"sampling noise can obscure real differences. Use :mod:`timeit` for micro-" +"benchmarks or :mod:`profiling.tracing` for precise measurements." +msgstr "" + +#: ../../library/profiling.sampling.rst:113 +msgid "" +"The key difference from :mod:`profiling.tracing` is how measurement happens. " +"A tracing profiler instruments your code, recording every function call and " +"return. This provides exact call counts and precise timing but adds overhead " +"to every function call. A sampling profiler, by contrast, observes the " +"program from outside at fixed intervals without modifying its execution. " +"Think of the difference like this: tracing is like having someone follow you " +"and write down every step you take, while sampling is like taking " +"photographs every second and inferring your path from those snapshots." +msgstr "" + +#: ../../library/profiling.sampling.rst:122 +msgid "" +"This external observation model is what makes sampling profiling practical " +"for production use. The profiled program runs at full speed because there is " +"no instrumentation code running inside it, and the target process is never " +"stopped or paused during sampling---Tachyon reads the call stack directly " +"from the process's memory while it continues to run. You can attach to a " +"live server, collect data, and detach without the application ever knowing " +"it was observed. The trade-off is that very short-lived functions may be " +"missed if they happen to complete between samples." +msgstr "" + +#: ../../library/profiling.sampling.rst:131 +msgid "" +"Statistical profiling excels at answering the question, \"Where is my " +"program spending time?\" It reveals hotspots and bottlenecks in production " +"code where deterministic profiling overhead would be unacceptable. For exact " +"call counts and complete call graphs, use :mod:`profiling.tracing` instead." +msgstr "" + +#: ../../library/profiling.sampling.rst:138 +msgid "Quick examples" +msgstr "" + +#: ../../library/profiling.sampling.rst:140 +msgid "Profile a script and see the results immediately::" +msgstr "" + +#: ../../library/profiling.sampling.rst:142 +msgid "python -m profiling.sampling run script.py" +msgstr "python -m profiling.sampling run script.py" + +#: ../../library/profiling.sampling.rst:144 +msgid "Profile a module with arguments::" +msgstr "" + +#: ../../library/profiling.sampling.rst:146 +msgid "python -m profiling.sampling run -m mypackage.module arg1 arg2" +msgstr "python -m profiling.sampling run -m mypackage.module arg1 arg2" + +#: ../../library/profiling.sampling.rst:148 +msgid "Generate an interactive flame graph::" +msgstr "" + +#: ../../library/profiling.sampling.rst:150 +msgid "python -m profiling.sampling run --flamegraph -o profile.html script.py" +msgstr "" +"python -m profiling.sampling run --flamegraph -o profile.html script.py" + +#: ../../library/profiling.sampling.rst:152 +msgid "Attach to a running process by PID::" +msgstr "" + +#: ../../library/profiling.sampling.rst:154 +#: ../../library/profiling.sampling.rst:209 +msgid "python -m profiling.sampling attach 12345" +msgstr "python -m profiling.sampling attach 12345" + +#: ../../library/profiling.sampling.rst:156 +msgid "Print a single snapshot of a running process's stack::" +msgstr "" + +#: ../../library/profiling.sampling.rst:158 +#: ../../library/profiling.sampling.rst:233 +msgid "python -m profiling.sampling dump 12345" +msgstr "python -m profiling.sampling dump 12345" + +#: ../../library/profiling.sampling.rst:160 +msgid "Use live mode for real-time monitoring (press ``q`` to quit)::" +msgstr "" + +#: ../../library/profiling.sampling.rst:162 +msgid "python -m profiling.sampling run --live script.py" +msgstr "python -m profiling.sampling run --live script.py" + +#: ../../library/profiling.sampling.rst:164 +msgid "Profile for 60 seconds with a faster sampling rate::" +msgstr "" + +#: ../../library/profiling.sampling.rst:166 +msgid "python -m profiling.sampling run -d 60 -r 20khz script.py" +msgstr "python -m profiling.sampling run -d 60 -r 20khz script.py" + +#: ../../library/profiling.sampling.rst:168 +msgid "Generate a line-by-line heatmap::" +msgstr "" + +#: ../../library/profiling.sampling.rst:170 +msgid "python -m profiling.sampling run --heatmap script.py" +msgstr "python -m profiling.sampling run --heatmap script.py" + +#: ../../library/profiling.sampling.rst:172 +msgid "" +"Enable opcode-level profiling to see which bytecode instructions are " +"executing::" +msgstr "" + +#: ../../library/profiling.sampling.rst:174 +#: ../../library/profiling.sampling.rst:569 +msgid "python -m profiling.sampling run --opcodes --flamegraph script.py" +msgstr "python -m profiling.sampling run --opcodes --flamegraph script.py" + +#: ../../library/profiling.sampling.rst:178 +msgid "Commands" +msgstr "" + +#: ../../library/profiling.sampling.rst:180 +msgid "" +"Tachyon operates through several subcommands. ``run`` and ``attach`` collect " +"samples over time; ``dump`` captures a single snapshot; ``replay`` converts " +"binary profiles to other formats." +msgstr "" + +#: ../../library/profiling.sampling.rst:186 +msgid "The ``run`` command" +msgstr "" + +#: ../../library/profiling.sampling.rst:188 +msgid "" +"The ``run`` command launches a Python script or module and profiles it from " +"startup::" +msgstr "" + +#: ../../library/profiling.sampling.rst:191 +msgid "" +"python -m profiling.sampling run script.py\n" +"python -m profiling.sampling run -m mypackage.module" +msgstr "" +"python -m profiling.sampling run script.py\n" +"python -m profiling.sampling run -m mypackage.module" + +#: ../../library/profiling.sampling.rst:194 +msgid "" +"When profiling a script, the profiler starts the target in a subprocess, " +"waits for it to initialize, then begins collecting samples. The ``-m`` flag " +"indicates that the target should be run as a module (equivalent to ``python -" +"m``). Arguments after the target are passed through to the profiled program::" +msgstr "" + +#: ../../library/profiling.sampling.rst:200 +msgid "python -m profiling.sampling run script.py --config settings.yaml" +msgstr "python -m profiling.sampling run script.py --config settings.yaml" + +#: ../../library/profiling.sampling.rst:204 +msgid "The ``attach`` command" +msgstr "" + +#: ../../library/profiling.sampling.rst:206 +msgid "" +"The ``attach`` command connects to an already-running Python process by its " +"process ID::" +msgstr "" + +#: ../../library/profiling.sampling.rst:211 +msgid "" +"This command is particularly valuable for investigating performance issues " +"in production systems. The target process requires no modification and need " +"not be restarted. The profiler attaches, collects samples for the specified " +"duration, then detaches and produces output." +msgstr "" + +#: ../../library/profiling.sampling.rst:218 +msgid "" +"python -m profiling.sampling attach --live 12345\n" +"python -m profiling.sampling attach --flamegraph -d 30 -o profile.html 12345" +msgstr "" +"python -m profiling.sampling attach --live 12345\n" +"python -m profiling.sampling attach --flamegraph -d 30 -o profile.html 12345" + +#: ../../library/profiling.sampling.rst:221 +msgid "" +"On most systems, attaching to another process requires appropriate " +"permissions. See :ref:`profiling-permissions` for platform-specific " +"requirements." +msgstr "" + +#: ../../library/profiling.sampling.rst:228 +msgid "The ``dump`` command" +msgstr "" + +#: ../../library/profiling.sampling.rst:230 +msgid "" +"The ``dump`` command prints a single snapshot of a running process's Python " +"stack and exits, similar to a traceback::" +msgstr "" + +#: ../../library/profiling.sampling.rst:235 +msgid "" +"Unlike ``attach``, ``dump`` does not run a sampling loop: it reads the stack " +"once. This is useful for investigating hung or unresponsive processes, or " +"for answering \"what is this process doing right now?\"." +msgstr "" + +#: ../../library/profiling.sampling.rst:239 +msgid "" +"The output mirrors a traceback (most recent call last) and annotates each " +"thread with its current state (main thread, has GIL, on CPU, waiting for " +"GIL, has exception, or idle):" +msgstr "" + +#: ../../library/profiling.sampling.rst:243 +msgid "" +"Stack dump for PID 12345, thread 140735 (main thread, has GIL, on CPU; most " +"recent call last):\n" +" File \"server.py\", line 28, in serve\n" +" await handle_request(req)\n" +" File \"handler.py\", line 91, in handle_request\n" +" result = expensive_call(req)" +msgstr "" +"Stack dump for PID 12345, thread 140735 (main thread, has GIL, on CPU; most " +"recent call last):\n" +" File \"server.py\", line 28, in serve\n" +" await handle_request(req)\n" +" File \"handler.py\", line 91, in handle_request\n" +" result = expensive_call(req)" + +#: ../../library/profiling.sampling.rst:251 +msgid "" +"When the target's source files are readable, ``dump`` prints the source line " +"for each frame and highlights the executing expression." +msgstr "" + +#: ../../library/profiling.sampling.rst:254 +msgid "" +"Like ``attach``, ``dump`` requires permission to read the target process's " +"memory. See :ref:`profiling-permissions`." +msgstr "" + +#: ../../library/profiling.sampling.rst:257 +msgid "The ``dump`` command supports the following options:" +msgstr "" + +#: ../../library/profiling.sampling.rst:259 +msgid "``-a``, ``--all-threads``" +msgstr "``-a``, ``--all-threads``" + +#: ../../library/profiling.sampling.rst:260 +msgid "" +"Dump every thread in the target process. Without this flag only the main " +"thread is shown." +msgstr "" + +#: ../../library/profiling.sampling.rst:263 +msgid "``--native``" +msgstr "``--native``" + +#: ../../library/profiling.sampling.rst:264 +msgid "" +"Include synthetic ```` frames marking transitions into C extensions " +"or other non-Python code." +msgstr "" + +#: ../../library/profiling.sampling.rst:267 +msgid "``--no-gc``" +msgstr "``--no-gc``" + +#: ../../library/profiling.sampling.rst:268 +msgid "Hide the synthetic ```` frames that mark active garbage collection." +msgstr "" + +#: ../../library/profiling.sampling.rst:270 +msgid "``--opcodes``" +msgstr "``--opcodes``" + +#: ../../library/profiling.sampling.rst:271 +msgid "" +"Annotate each frame with the bytecode opcode the thread is currently " +"executing (for example, ``opcode=CALL_KW``). Useful for instruction-level " +"investigation, including identifying specializations chosen by the adaptive " +"interpreter." +msgstr "" + +#: ../../library/profiling.sampling.rst:276 +msgid "``--async-aware``" +msgstr "``--async-aware``" + +#: ../../library/profiling.sampling.rst:277 +msgid "" +"Reconstruct stacks across ``await`` boundaries. ``dump`` walks the task " +"graph and emits one section per task, with ```` markers separating " +"coroutines awaiting each other." +msgstr "" + +#: ../../library/profiling.sampling.rst:281 +msgid "``--async-mode {running,all}``" +msgstr "``--async-mode {running,all}``" + +#: ../../library/profiling.sampling.rst:282 +msgid "" +"Controls which tasks are included when ``--async-aware`` is enabled. " +"``running`` shows only the task currently executing on each thread; ``all`` " +"(the default for ``dump``) also includes tasks suspended on a wait. " +"``attach``'s default for this flag is ``running``; ``dump`` defaults to " +"``all`` because a single snapshot is most useful when it shows the full task " +"graph." +msgstr "" + +#: ../../library/profiling.sampling.rst:289 +msgid "``--blocking``" +msgstr "``--blocking``" + +#: ../../library/profiling.sampling.rst:290 +msgid "" +"Pause every thread in the target while reading its stack and resume them " +"after. Guarantees a fully consistent snapshot at the cost of briefly " +"stopping the target. Without it, ``dump`` reads memory while the target " +"keeps running, which is faster but can occasionally produce a torn stack." +msgstr "" + +#: ../../library/profiling.sampling.rst:300 +msgid "The ``replay`` command" +msgstr "" + +#: ../../library/profiling.sampling.rst:302 +msgid "" +"The ``replay`` command converts binary profile files to other output " +"formats::" +msgstr "" + +#: ../../library/profiling.sampling.rst:304 +msgid "" +"python -m profiling.sampling replay profile.bin\n" +"python -m profiling.sampling replay --flamegraph -o profile.html profile.bin" +msgstr "" +"python -m profiling.sampling replay profile.bin\n" +"python -m profiling.sampling replay --flamegraph -o profile.html profile.bin" + +#: ../../library/profiling.sampling.rst:307 +msgid "" +"This command is useful when you have captured profiling data in binary " +"format and want to analyze it later or convert it to a visualization format. " +"Binary profiles can be replayed multiple times to different formats without " +"re-profiling." +msgstr "" + +#: ../../library/profiling.sampling.rst:314 +msgid "" +"# Convert binary to pstats (default, prints to stdout)\n" +"python -m profiling.sampling replay profile.bin\n" +"\n" +"# Convert binary to flame graph\n" +"python -m profiling.sampling replay --flamegraph -o output.html profile.bin\n" +"\n" +"# Convert binary to gecko format for Firefox Profiler\n" +"python -m profiling.sampling replay --gecko -o profile.json profile.bin\n" +"\n" +"# Convert binary to heatmap\n" +"python -m profiling.sampling replay --heatmap -o my_heatmap profile.bin" +msgstr "" +"# 將二進位檔轉換為 pstats(預設,輸出至 stdout)\n" +"python -m profiling.sampling replay profile.bin\n" +"\n" +"# 將二進位檔轉換為火焰圖\n" +"python -m profiling.sampling replay --flamegraph -o output.html profile.bin\n" +"\n" +"# 將二進位檔轉換為供 Firefox Profiler 使用的 gecko 格式\n" +"python -m profiling.sampling replay --gecko -o profile.json profile.bin\n" +"\n" +"# 將二進位檔轉換為熱圖\n" +"python -m profiling.sampling replay --heatmap -o my_heatmap profile.bin" + +#: ../../library/profiling.sampling.rst:328 +msgid "Profiling in production" +msgstr "" + +#: ../../library/profiling.sampling.rst:330 +msgid "" +"The sampling profiler is designed for production use. It imposes no " +"measurable overhead on the target process because it reads memory externally " +"rather than instrumenting code. The target application continues running at " +"full speed and is unaware it is being profiled." +msgstr "" + +#: ../../library/profiling.sampling.rst:335 +msgid "When profiling production systems, keep these guidelines in mind:" +msgstr "" + +#: ../../library/profiling.sampling.rst:337 +msgid "" +"Start with shorter durations (10-30 seconds) to get quick results, then " +"extend if you need more statistical accuracy. By default, profiling runs " +"until the target process completes, which is usually sufficient to identify " +"major hotspots." +msgstr "" + +#: ../../library/profiling.sampling.rst:341 +msgid "" +"If possible, profile during representative load rather than peak traffic. " +"Profiles collected during normal operation are easier to interpret than " +"those collected during unusual spikes." +msgstr "" + +#: ../../library/profiling.sampling.rst:345 +msgid "" +"The profiler itself consumes some CPU on the machine where it runs (not on " +"the target process). On the same machine, this is typically negligible. When " +"profiling remote processes, network latency does not affect the target." +msgstr "" + +#: ../../library/profiling.sampling.rst:349 +msgid "" +"Results from production may differ from development due to different data " +"sizes, concurrent load, or caching effects. This is expected and is often " +"exactly what you want to capture." +msgstr "" + +#: ../../library/profiling.sampling.rst:357 +msgid "Platform requirements" +msgstr "" + +#: ../../library/profiling.sampling.rst:359 +msgid "" +"The profiler reads the target process's memory to capture stack traces. This " +"requires elevated permissions on most operating systems." +msgstr "" + +#: ../../library/profiling.sampling.rst:362 +msgid "**Linux**" +msgstr "" + +#: ../../library/profiling.sampling.rst:364 +msgid "" +"On Linux, the profiler uses ``ptrace`` or ``process_vm_readv`` to read the " +"target process's memory. This typically requires one of:" +msgstr "" + +#: ../../library/profiling.sampling.rst:367 +#: ../../library/profiling.sampling.rst:381 +msgid "Running as root" +msgstr "" + +#: ../../library/profiling.sampling.rst:368 +msgid "Having the ``CAP_SYS_PTRACE`` capability" +msgstr "" + +#: ../../library/profiling.sampling.rst:369 +msgid "Adjusting the Yama ptrace scope: ``/proc/sys/kernel/yama/ptrace_scope``" +msgstr "" + +#: ../../library/profiling.sampling.rst:371 +msgid "" +"The default ptrace_scope of 1 restricts ptrace to parent processes only. To " +"allow attaching to any process owned by the same user, set it to 0::" +msgstr "" + +#: ../../library/profiling.sampling.rst:374 +msgid "echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope" +msgstr "echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope" + +#: ../../library/profiling.sampling.rst:376 +msgid "**macOS**" +msgstr "" + +#: ../../library/profiling.sampling.rst:378 +msgid "" +"On macOS, the profiler uses ``task_for_pid()`` to access the target process. " +"This requires one of:" +msgstr "" + +#: ../../library/profiling.sampling.rst:382 +msgid "" +"The profiler binary having the ``com.apple.security.cs.debugger`` entitlement" +msgstr "" + +#: ../../library/profiling.sampling.rst:383 +msgid "System Integrity Protection (SIP) being disabled (not recommended)" +msgstr "" + +#: ../../library/profiling.sampling.rst:385 +msgid "**Windows**" +msgstr "" + +#: ../../library/profiling.sampling.rst:387 +msgid "" +"On Windows, the profiler requires administrative privileges or the " +"``SeDebugPrivilege`` privilege to read another process's memory." +msgstr "" + +#: ../../library/profiling.sampling.rst:392 +msgid "Version compatibility" +msgstr "" + +#: ../../library/profiling.sampling.rst:394 +msgid "" +"The profiler and target process must run the same Python minor version (for " +"example, both Python 3.15). Attaching from Python 3.14 to a Python 3.15 " +"process is not supported." +msgstr "" + +#: ../../library/profiling.sampling.rst:398 +msgid "" +"Additional restrictions apply to pre-release Python versions: if either the " +"profiler or target is running a pre-release (alpha, beta, or release " +"candidate), both must run the exact same version." +msgstr "" + +#: ../../library/profiling.sampling.rst:402 +msgid "" +"On free-threaded Python builds, the profiler cannot attach from a free-" +"threaded build to a standard build, or vice versa." +msgstr "" + +#: ../../library/profiling.sampling.rst:407 +msgid "Sampling configuration" +msgstr "" + +#: ../../library/profiling.sampling.rst:409 +msgid "" +"Before exploring the various output formats and visualization options, it is " +"important to understand how to configure the sampling process itself. The " +"profiler offers several options that control how frequently samples are " +"collected, how long profiling runs, which threads are observed, and what " +"additional context is captured in each sample." +msgstr "" + +#: ../../library/profiling.sampling.rst:415 +msgid "The default configuration works well for most use cases:" +msgstr "" + +#: ../../library/profiling.sampling.rst:421 +msgid "Option" +msgstr "選項" + +#: ../../library/profiling.sampling.rst:422 +msgid "Default" +msgstr "預設" + +#: ../../library/profiling.sampling.rst:423 +msgid "Default for ``--sampling-rate`` / ``-r``" +msgstr "" + +#: ../../library/profiling.sampling.rst:424 +msgid "1 kHz" +msgstr "" + +#: ../../library/profiling.sampling.rst:425 +msgid "Default for ``--duration`` / ``-d``" +msgstr "" + +#: ../../library/profiling.sampling.rst:426 +msgid "Run to completion" +msgstr "" + +#: ../../library/profiling.sampling.rst:427 +msgid "Default for ``--all-threads`` / ``-a``" +msgstr "" + +#: ../../library/profiling.sampling.rst:428 +msgid "Main thread only" +msgstr "" + +#: ../../library/profiling.sampling.rst:429 +msgid "Default for ``--native``" +msgstr "" + +#: ../../library/profiling.sampling.rst:430 +msgid "No ```` frames (C code time attributed to caller)" +msgstr "" + +#: ../../library/profiling.sampling.rst:431 +msgid "Default for ``--no-gc``" +msgstr "" + +#: ../../library/profiling.sampling.rst:432 +msgid "```` frames included when garbage collection is active" +msgstr "" + +#: ../../library/profiling.sampling.rst:433 +msgid "Default for ``--mode``" +msgstr "" + +#: ../../library/profiling.sampling.rst:434 +msgid "Wall-clock mode (all samples recorded)" +msgstr "" + +#: ../../library/profiling.sampling.rst:435 +msgid "Default for ``--realtime-stats``" +msgstr "" + +#: ../../library/profiling.sampling.rst:436 +#: ../../library/profiling.sampling.rst:438 +msgid "Disabled" +msgstr "" + +#: ../../library/profiling.sampling.rst:437 +msgid "Default for ``--subprocesses``" +msgstr "" + +#: ../../library/profiling.sampling.rst:439 +msgid "Default for ``--blocking``" +msgstr "" + +#: ../../library/profiling.sampling.rst:440 +msgid "Disabled (non-blocking sampling)" +msgstr "" + +#: ../../library/profiling.sampling.rst:444 +msgid "Sampling rate and duration" +msgstr "" + +#: ../../library/profiling.sampling.rst:446 +msgid "" +"The two most fundamental parameters are the sampling rate and duration. " +"Together, these determine how many samples will be collected during a " +"profiling session." +msgstr "" + +#: ../../library/profiling.sampling.rst:450 +msgid "" +"The :option:`--sampling-rate` option (:option:`-r`) sets how frequently " +"samples are collected. The default is 1 kHz (1,000 samples per second)::" +msgstr "" + +#: ../../library/profiling.sampling.rst:453 +msgid "python -m profiling.sampling run -r 20khz script.py" +msgstr "python -m profiling.sampling run -r 20khz script.py" + +#: ../../library/profiling.sampling.rst:455 +msgid "" +"Higher rates capture more samples and provide finer-grained data at the cost " +"of slightly higher profiler CPU usage. Lower rates reduce profiler overhead " +"but may miss short-lived functions. For most applications, the default rate " +"provides a good balance between accuracy and overhead." +msgstr "" + +#: ../../library/profiling.sampling.rst:460 +msgid "" +"The :option:`--duration` option (:option:`-d`) sets how long to profile in " +"seconds. By default, profiling continues until the target process exits or " +"is interrupted::" +msgstr "" + +#: ../../library/profiling.sampling.rst:463 +msgid "python -m profiling.sampling run -d 60 script.py" +msgstr "python -m profiling.sampling run -d 60 script.py" + +#: ../../library/profiling.sampling.rst:465 +msgid "" +"Specifying a duration is useful when attaching to long-running processes or " +"when you want to limit profiling to a specific time window. When profiling a " +"script, the default behavior of running to completion is usually what you " +"want." +msgstr "" + +#: ../../library/profiling.sampling.rst:471 +msgid "Thread selection" +msgstr "" + +#: ../../library/profiling.sampling.rst:473 +msgid "" +"Python programs often use multiple threads, whether explicitly through the :" +"mod:`threading` module or implicitly through libraries that manage thread " +"pools." +msgstr "" + +#: ../../library/profiling.sampling.rst:477 +msgid "" +"By default, the profiler samples only the main thread. The :option:`--all-" +"threads` option (:option:`-a`) enables sampling of all threads in the " +"process::" +msgstr "" + +#: ../../library/profiling.sampling.rst:480 +msgid "python -m profiling.sampling run -a script.py" +msgstr "python -m profiling.sampling run -a script.py" + +#: ../../library/profiling.sampling.rst:482 +msgid "" +"Multi-thread profiling reveals how work is distributed across threads and " +"can identify threads that are blocked or starved. Each thread's samples are " +"combined in the output, with the ability to filter by thread in some " +"formats. This option is particularly useful when investigating concurrency " +"issues or when work is distributed across a thread pool." +msgstr "" + +#: ../../library/profiling.sampling.rst:492 +msgid "Blocking mode" +msgstr "" + +#: ../../library/profiling.sampling.rst:494 +msgid "" +"By default, Tachyon reads the target process's memory without stopping it. " +"This non-blocking approach is ideal for most profiling scenarios because it " +"imposes virtually zero overhead on the target application: the profiled " +"program runs at full speed and is unaware it is being observed." +msgstr "" + +#: ../../library/profiling.sampling.rst:499 +msgid "" +"However, non-blocking sampling can occasionally produce incomplete or " +"inconsistent stack traces in applications with many generators or coroutines " +"that rapidly switch between yield points, or in programs with very fast-" +"changing call stacks where functions enter and exit between the start and " +"end of a single stack read, resulting in reconstructed stacks that mix " +"frames from different execution states or that never actually existed." +msgstr "" + +#: ../../library/profiling.sampling.rst:506 +msgid "" +"For these cases, the :option:`--blocking` option stops the target process " +"during each sample::" +msgstr "" + +#: ../../library/profiling.sampling.rst:509 +msgid "" +"python -m profiling.sampling run --blocking script.py\n" +"python -m profiling.sampling attach --blocking 12345" +msgstr "" +"python -m profiling.sampling run --blocking script.py\n" +"python -m profiling.sampling attach --blocking 12345" + +#: ../../library/profiling.sampling.rst:512 +msgid "" +"When blocking mode is enabled, the profiler suspends the target process, " +"reads its stack, then resumes it. This guarantees that each captured stack " +"represents a real, consistent snapshot of what the process was doing at that " +"instant. The trade-off is that the target process runs slower because it is " +"repeatedly paused." +msgstr "" + +#: ../../library/profiling.sampling.rst:520 +msgid "" +"Do not use very high sample rates (low ``--interval`` values) with blocking " +"mode. Suspending and resuming a process takes time, and if the sampling " +"interval is too short, the target will spend more time stopped than running. " +"For blocking mode, intervals of 1000 microseconds (1 millisecond) or higher " +"are recommended. The default 100 microsecond interval may cause noticeable " +"slowdown in the target application." +msgstr "" + +#: ../../library/profiling.sampling.rst:527 +msgid "" +"Use blocking mode only when you observe inconsistent stacks in your " +"profiles, particularly with generator-heavy or coroutine-heavy code. For " +"most applications, the default non-blocking mode provides accurate results " +"with zero impact on the target process." +msgstr "" + +#: ../../library/profiling.sampling.rst:534 +msgid "Special frames" +msgstr "" + +#: ../../library/profiling.sampling.rst:536 +msgid "" +"The profiler can inject artificial frames into the captured stacks to " +"provide additional context about what the interpreter is doing at the moment " +"each sample is taken. These synthetic frames help distinguish different " +"types of execution that would otherwise be invisible." +msgstr "" + +#: ../../library/profiling.sampling.rst:541 +msgid "" +"The :option:`--native` option adds ```` frames to indicate when " +"Python has called into C code (extension modules, built-in functions, or the " +"interpreter itself)::" +msgstr "" + +#: ../../library/profiling.sampling.rst:545 +msgid "python -m profiling.sampling run --native script.py" +msgstr "python -m profiling.sampling run --native script.py" + +#: ../../library/profiling.sampling.rst:547 +msgid "" +"These frames help distinguish time spent in Python code versus time spent in " +"native libraries. Without this option, native code execution appears as time " +"in the Python function that made the call. This is useful when optimizing " +"code that makes heavy use of C extensions like NumPy or database drivers." +msgstr "" + +#: ../../library/profiling.sampling.rst:552 +msgid "" +"By default, the profiler includes ```` frames when garbage collection is " +"active. The :option:`--no-gc` option suppresses these frames::" +msgstr "" + +#: ../../library/profiling.sampling.rst:555 +msgid "python -m profiling.sampling run --no-gc script.py" +msgstr "python -m profiling.sampling run --no-gc script.py" + +#: ../../library/profiling.sampling.rst:557 +msgid "" +"GC frames help identify programs where garbage collection consumes " +"significant time, which may indicate memory allocation patterns worth " +"optimizing. If you see substantial time in ```` frames, consider " +"investigating object allocation rates or using object pooling." +msgstr "" + +#: ../../library/profiling.sampling.rst:564 +msgid "Opcode-aware profiling" +msgstr "" + +#: ../../library/profiling.sampling.rst:566 +msgid "" +"The :option:`--opcodes` option enables instruction-level profiling that " +"captures which Python bytecode instructions are executing at each sample::" +msgstr "" + +#: ../../library/profiling.sampling.rst:571 +msgid "" +"This feature provides visibility into Python's bytecode execution, including " +"adaptive specialization optimizations. When a generic instruction like " +"``LOAD_ATTR`` is specialized at runtime into a more efficient variant like " +"``LOAD_ATTR_INSTANCE_VALUE``, the profiler shows both the specialized name " +"and the base instruction." +msgstr "" + +#: ../../library/profiling.sampling.rst:577 +msgid "Opcode information appears in several output formats:" +msgstr "" + +#: ../../library/profiling.sampling.rst:579 +msgid "" +"**Flame graphs**: Hovering over a frame displays a tooltip with a bytecode " +"instruction breakdown, showing which opcodes consumed time in that function" +msgstr "" + +#: ../../library/profiling.sampling.rst:581 +msgid "" +"**Heatmap**: Expandable bytecode panels per source line show instruction " +"breakdown with specialization percentages" +msgstr "" + +#: ../../library/profiling.sampling.rst:583 +msgid "" +"**Live mode**: An opcode panel shows instruction-level statistics for the " +"selected function, accessible via keyboard navigation" +msgstr "" + +#: ../../library/profiling.sampling.rst:585 +msgid "" +"**Gecko format**: Opcode transitions are emitted as interval markers in the " +"Firefox Profiler timeline" +msgstr "" + +#: ../../library/profiling.sampling.rst:588 +msgid "This level of detail is particularly useful for:" +msgstr "" + +#: ../../library/profiling.sampling.rst:590 +msgid "" +"Understanding the performance impact of Python's adaptive specialization" +msgstr "" + +#: ../../library/profiling.sampling.rst:591 +msgid "" +"Identifying hot bytecode instructions that might benefit from optimization" +msgstr "" + +#: ../../library/profiling.sampling.rst:592 +msgid "" +"Analyzing the effectiveness of different code patterns at the instruction " +"level" +msgstr "" + +#: ../../library/profiling.sampling.rst:593 +msgid "Debugging performance issues that occur at the bytecode level" +msgstr "" + +#: ../../library/profiling.sampling.rst:595 +msgid "" +"The :option:`--opcodes` option is compatible with :option:`--live`, :option:" +"`--flamegraph`, :option:`--heatmap`, and :option:`--gecko` formats. It " +"requires additional memory to store opcode information and may slightly " +"reduce sampling performance, but provides unprecedented visibility into " +"Python's execution model." +msgstr "" + +#: ../../library/profiling.sampling.rst:602 +msgid "Real-time statistics" +msgstr "" + +#: ../../library/profiling.sampling.rst:604 +msgid "" +"The :option:`--realtime-stats` option displays sampling rate statistics " +"during profiling::" +msgstr "" + +#: ../../library/profiling.sampling.rst:607 +msgid "python -m profiling.sampling run --realtime-stats script.py" +msgstr "python -m profiling.sampling run --realtime-stats script.py" + +#: ../../library/profiling.sampling.rst:609 +msgid "" +"This shows the actual achieved sampling rate, which may be lower than " +"requested if the profiler cannot keep up. The statistics help verify that " +"profiling is working correctly and that sufficient samples are being " +"collected. See :ref:`sampling-efficiency` for details on interpreting these " +"metrics." +msgstr "" + +#: ../../library/profiling.sampling.rst:616 +msgid "Subprocess profiling" +msgstr "" + +#: ../../library/profiling.sampling.rst:618 +msgid "" +"The :option:`--subprocesses` option enables automatic profiling of " +"subprocesses spawned by the target::" +msgstr "" + +#: ../../library/profiling.sampling.rst:621 +msgid "" +"python -m profiling.sampling run --subprocesses script.py\n" +"python -m profiling.sampling attach --subprocesses 12345" +msgstr "" +"python -m profiling.sampling run --subprocesses script.py\n" +"python -m profiling.sampling attach --subprocesses 12345" + +#: ../../library/profiling.sampling.rst:624 +msgid "" +"When enabled, the profiler monitors the target process for child process " +"creation. When a new Python child process is detected, a separate profiler " +"instance is automatically spawned to profile it. This is useful for " +"applications that use :mod:`multiprocessing`, :mod:`subprocess`, :mod:" +"`concurrent.futures` with :class:`~concurrent.futures.ProcessPoolExecutor`, " +"or other process spawning mechanisms." +msgstr "" + +#: ../../library/profiling.sampling.rst:631 +msgid "worker_pool.py" +msgstr "worker_pool.py" + +#: ../../library/profiling.sampling.rst:631 +msgid "" +"from concurrent.futures import ProcessPoolExecutor\n" +"import math\n" +"\n" +"def compute_factorial(n):\n" +" total = 0\n" +" for i in range(50):\n" +" total += math.factorial(n)\n" +" return total\n" +"\n" +"if __name__ == \"__main__\":\n" +" numbers = [5000 + i * 100 for i in range(50)]\n" +" with ProcessPoolExecutor(max_workers=4) as executor:\n" +" results = list(executor.map(compute_factorial, numbers))\n" +" print(f\"Computed {len(results)} factorials\")" +msgstr "" +"from concurrent.futures import ProcessPoolExecutor\n" +"import math\n" +"\n" +"def compute_factorial(n):\n" +" total = 0\n" +" for i in range(50):\n" +" total += math.factorial(n)\n" +" return total\n" +"\n" +"if __name__ == \"__main__\":\n" +" numbers = [5000 + i * 100 for i in range(50)]\n" +" with ProcessPoolExecutor(max_workers=4) as executor:\n" +" results = list(executor.map(compute_factorial, numbers))\n" +" print(f\"Computed {len(results)} factorials\")" + +#: ../../library/profiling.sampling.rst:651 +msgid "" +"python -m profiling.sampling run --subprocesses --flamegraph worker_pool.py" +msgstr "" +"python -m profiling.sampling run --subprocesses --flamegraph worker_pool.py" + +#: ../../library/profiling.sampling.rst:653 +msgid "" +"This produces separate flame graphs for the main process and each worker " +"process: ``flamegraph_.html``, ``flamegraph_.html``, " +"and so on." +msgstr "" + +#: ../../library/profiling.sampling.rst:657 +msgid "" +"Each subprocess receives its own output file. The filename is derived from " +"the specified output path (or the default) with the subprocess's process ID " +"appended:" +msgstr "" + +#: ../../library/profiling.sampling.rst:661 +msgid "" +"If you specify ``-o profile.html``, subprocesses produce ``profile_12345." +"html``, ``profile_12346.html``, and so on" +msgstr "" + +#: ../../library/profiling.sampling.rst:663 +msgid "" +"With default output, subprocesses produce files like ``flamegraph_12345." +"html`` or directories like ``heatmap_12345``" +msgstr "" + +#: ../../library/profiling.sampling.rst:665 +msgid "" +"For pstats format (which defaults to stdout), subprocesses produce files " +"like ``profile_12345.pstats``" +msgstr "" + +#: ../../library/profiling.sampling.rst:668 +msgid "" +"The subprocess profilers inherit most sampling options from the parent " +"(sampling rate, duration, thread selection, native frames, GC frames, async-" +"aware mode, and output format). All Python descendant processes are profiled " +"recursively, including grandchildren and further descendants." +msgstr "" + +#: ../../library/profiling.sampling.rst:673 +msgid "" +"Subprocess detection works by periodically scanning for new descendants of " +"the target process and checking whether each new process is a Python process " +"by probing the process memory for Python runtime structures. Non-Python " +"subprocesses (such as shell commands or external tools) are ignored." +msgstr "" + +#: ../../library/profiling.sampling.rst:678 +msgid "" +"There is a limit of 100 concurrent subprocess profilers to prevent resource " +"exhaustion in programs that spawn many processes. If this limit is reached, " +"additional subprocesses are not profiled and a warning is printed." +msgstr "" + +#: ../../library/profiling.sampling.rst:682 +msgid "" +"The :option:`--subprocesses` option is incompatible with :option:`--live` " +"mode because live mode uses an interactive terminal interface that cannot " +"accommodate multiple concurrent profiler displays." +msgstr "" + +#: ../../library/profiling.sampling.rst:690 +msgid "Sampling efficiency" +msgstr "" + +#: ../../library/profiling.sampling.rst:692 +msgid "" +"Sampling efficiency metrics help assess the quality of the collected data. " +"These metrics appear in the profiler's terminal output and in the flame " +"graph sidebar." +msgstr "" + +#: ../../library/profiling.sampling.rst:696 +msgid "" +"**Sampling efficiency** is the percentage of sample attempts that succeeded. " +"Each sample attempt reads the target process's call stack from memory. An " +"attempt can fail if the process is in an inconsistent state at the moment of " +"reading, such as during a context switch or while the interpreter is " +"updating its internal structures. A low efficiency may indicate that the " +"profiler could not keep up with the requested sampling rate, often due to " +"system load or an overly aggressive interval setting." +msgstr "" + +#: ../../library/profiling.sampling.rst:704 +msgid "" +"**Missed samples** is the percentage of expected samples that were not " +"collected. Based on the configured interval and duration, the profiler " +"expects to collect a certain number of samples. Some samples may be missed " +"if the profiler falls behind schedule, for example when the system is under " +"heavy load. A small percentage of missed samples is normal and does not " +"significantly affect the statistical accuracy of the profile." +msgstr "" + +#: ../../library/profiling.sampling.rst:711 +msgid "" +"Both metrics are informational. Even with some failed attempts or missed " +"samples, the profile remains statistically valid as long as enough samples " +"were collected. The profiler reports the actual number of samples captured, " +"which you can use to judge whether the data is sufficient for your analysis." +msgstr "" + +#: ../../library/profiling.sampling.rst:718 +msgid "Profiling modes" +msgstr "" + +#: ../../library/profiling.sampling.rst:720 +msgid "" +"The sampling profiler supports four modes that control which samples are " +"recorded. The mode determines what the profile measures: total elapsed time, " +"CPU execution time, time spent holding the global interpreter lock, or " +"exception handling." +msgstr "" + +#: ../../library/profiling.sampling.rst:727 +msgid "Wall-clock mode" +msgstr "" + +#: ../../library/profiling.sampling.rst:729 +msgid "" +"Wall-clock mode (:option:`--mode`\\ ``=wall``) captures all samples " +"regardless of what the thread is doing. This is the default mode and " +"provides a complete picture of where time passes during program execution::" +msgstr "" + +#: ../../library/profiling.sampling.rst:733 +msgid "python -m profiling.sampling run --mode=wall script.py" +msgstr "python -m profiling.sampling run --mode=wall script.py" + +#: ../../library/profiling.sampling.rst:735 +msgid "" +"In wall-clock mode, samples are recorded whether the thread is actively " +"executing Python code, waiting for I/O, blocked on a lock, or sleeping. This " +"makes wall-clock profiling ideal for understanding the overall time " +"distribution in your program, including time spent waiting." +msgstr "" + +#: ../../library/profiling.sampling.rst:740 +msgid "" +"If your program spends significant time in I/O operations, network calls, or " +"sleep, wall-clock mode will show these waits as time attributed to the " +"calling function. This is often exactly what you want when optimizing end-to-" +"end latency." +msgstr "" + +#: ../../library/profiling.sampling.rst:747 +msgid "CPU mode" +msgstr "" + +#: ../../library/profiling.sampling.rst:749 +msgid "" +"CPU mode (:option:`--mode`\\ ``=cpu``) records samples only when the thread " +"is actually executing on a CPU core::" +msgstr "" + +#: ../../library/profiling.sampling.rst:752 +msgid "python -m profiling.sampling run --mode=cpu script.py" +msgstr "python -m profiling.sampling run --mode=cpu script.py" + +#: ../../library/profiling.sampling.rst:754 +msgid "" +"Samples taken while the thread is sleeping, blocked on I/O, or waiting for a " +"lock are discarded. The resulting profile shows where CPU cycles are " +"consumed, filtering out idle time." +msgstr "" + +#: ../../library/profiling.sampling.rst:758 +msgid "" +"CPU mode is useful when you want to focus on computational hotspots without " +"being distracted by I/O waits. If your program alternates between " +"computation and network calls, CPU mode reveals which computational sections " +"are most expensive." +msgstr "" + +#: ../../library/profiling.sampling.rst:765 +msgid "Comparing wall-clock and CPU profiles" +msgstr "" + +#: ../../library/profiling.sampling.rst:767 +msgid "" +"Running both wall-clock and CPU mode profiles can reveal whether a " +"function's time is spent computing or waiting." +msgstr "" + +#: ../../library/profiling.sampling.rst:770 +msgid "" +"If a function appears prominently in both profiles, it is a true " +"computational hotspot---actively using the CPU. Optimization should focus on " +"algorithmic improvements or more efficient code." +msgstr "" + +#: ../../library/profiling.sampling.rst:774 +msgid "" +"If a function is high in wall-clock mode but low or absent in CPU mode, it " +"is I/O-bound or waiting. The function spends most of its time waiting for " +"network, disk, locks, or sleep. CPU optimization won't help here; consider " +"async I/O, connection pooling, or reducing wait time instead." +msgstr "" + +#: ../../library/profiling.sampling.rst:779 +msgid "" +"import time\n" +"\n" +"def do_sleep():\n" +" time.sleep(2)\n" +"\n" +"def do_compute():\n" +" sum(i**2 for i in range(1000000))\n" +"\n" +"if __name__ == \"__main__\":\n" +" do_sleep()\n" +" do_compute()" +msgstr "" +"import time\n" +"\n" +"def do_sleep():\n" +" time.sleep(2)\n" +"\n" +"def do_compute():\n" +" sum(i**2 for i in range(1000000))\n" +"\n" +"if __name__ == \"__main__\":\n" +" do_sleep()\n" +" do_compute()" + +#: ../../library/profiling.sampling.rst:795 +msgid "" +"python -m profiling.sampling run --mode=wall script.py # do_sleep ~98%, " +"do_compute ~1%\n" +"python -m profiling.sampling run --mode=cpu script.py # do_sleep absent, " +"do_compute dominates" +msgstr "" +"python -m profiling.sampling run --mode=wall script.py # do_sleep 約 98%," +"do_compute 約 1%\n" +"python -m profiling.sampling run --mode=cpu script.py # 沒有 do_sleep," +"do_compute 佔主導" + +#: ../../library/profiling.sampling.rst:800 +msgid "GIL mode" +msgstr "" + +#: ../../library/profiling.sampling.rst:802 +msgid "" +"GIL mode (:option:`--mode`\\ ``=gil``) records samples only when the thread " +"holds Python's global interpreter lock::" +msgstr "" + +#: ../../library/profiling.sampling.rst:805 +msgid "python -m profiling.sampling run --mode=gil script.py" +msgstr "python -m profiling.sampling run --mode=gil script.py" + +#: ../../library/profiling.sampling.rst:807 +msgid "" +"The GIL is held only while executing Python bytecode. When Python calls into " +"C extensions, performs I/O operations, or executes native code, the GIL is " +"typically released. This means GIL mode effectively measures time spent " +"running Python code specifically, filtering out time in native libraries." +msgstr "" + +#: ../../library/profiling.sampling.rst:812 +msgid "" +"In multi-threaded programs, GIL mode reveals which code is preventing other " +"threads from running Python bytecode. Since only one thread can hold the GIL " +"at a time, functions that appear frequently in GIL mode profiles are " +"monopolizing the interpreter." +msgstr "" + +#: ../../library/profiling.sampling.rst:817 +msgid "" +"GIL mode helps answer questions like \"which functions are monopolizing the " +"GIL?\" and \"why are my other threads starving?\" It can also be useful in " +"single-threaded programs to distinguish Python execution time from time " +"spent in C extensions or I/O." +msgstr "" + +#: ../../library/profiling.sampling.rst:822 +msgid "" +"import hashlib\n" +"\n" +"def hash_work():\n" +" # C extension - releases GIL during computation\n" +" for _ in range(200):\n" +" hashlib.sha256(b\"data\" * 250000).hexdigest()\n" +"\n" +"def python_work():\n" +" # Pure Python - holds GIL during computation\n" +" for _ in range(3):\n" +" sum(i**2 for i in range(1000000))\n" +"\n" +"if __name__ == \"__main__\":\n" +" hash_work()\n" +" python_work()" +msgstr "" +"import hashlib\n" +"\n" +"def hash_work():\n" +" # C 擴充 - 計算期間會釋放 GIL\n" +" for _ in range(200):\n" +" hashlib.sha256(b\"data\" * 250000).hexdigest()\n" +"\n" +"def python_work():\n" +" # 純 Python - 計算期間持有 GIL\n" +" for _ in range(3):\n" +" sum(i**2 for i in range(1000000))\n" +"\n" +"if __name__ == \"__main__\":\n" +" hash_work()\n" +" python_work()" + +#: ../../library/profiling.sampling.rst:842 +msgid "" +"python -m profiling.sampling run --mode=cpu script.py # hash_work ~42%, " +"python_work ~38%\n" +"python -m profiling.sampling run --mode=gil script.py # hash_work ~5%, " +"python_work ~60%" +msgstr "" +"python -m profiling.sampling run --mode=cpu script.py # hash_work 約 42%," +"python_work 約 38%\n" +"python -m profiling.sampling run --mode=gil script.py # hash_work 約 5%," +"python_work 約 60%" + +#: ../../library/profiling.sampling.rst:847 +msgid "Exception mode" +msgstr "" + +#: ../../library/profiling.sampling.rst:849 +msgid "" +"Exception mode (``--mode=exception``) records samples only when a thread has " +"an active exception::" +msgstr "" + +#: ../../library/profiling.sampling.rst:852 +msgid "python -m profiling.sampling run --mode=exception script.py" +msgstr "python -m profiling.sampling run --mode=exception script.py" + +#: ../../library/profiling.sampling.rst:854 +msgid "" +"Samples are recorded in two situations: when an exception is being " +"propagated up the call stack (after ``raise`` but before being caught), or " +"when code is executing inside an ``except`` block where exception " +"information is still present in the thread state." +msgstr "" + +#: ../../library/profiling.sampling.rst:859 +msgid "The following example illustrates which code regions are captured:" +msgstr "" + +#: ../../library/profiling.sampling.rst:861 +msgid "" +"def example():\n" +" try:\n" +" raise ValueError(\"error\") # Captured: exception being raised\n" +" except ValueError:\n" +" process_error() # Captured: inside except block\n" +" finally:\n" +" cleanup() # NOT captured: exception already " +"handled\n" +"\n" +"def example_propagating():\n" +" try:\n" +" try:\n" +" raise ValueError(\"error\")\n" +" finally:\n" +" cleanup() # Captured: exception propagating " +"through\n" +" except ValueError:\n" +" pass\n" +"\n" +"def example_no_exception():\n" +" try:\n" +" do_work()\n" +" finally:\n" +" cleanup() # NOT captured: no exception involved" +msgstr "" +"def example():\n" +" try:\n" +" raise ValueError(\"error\") # 會被捕捉:正在引發例外\n" +" except ValueError:\n" +" process_error() # 會被捕捉:在 except 區塊內\n" +" finally:\n" +" cleanup() # 不會被捕捉:例外已被處理\n" +"\n" +"def example_propagating():\n" +" try:\n" +" try:\n" +" raise ValueError(\"error\")\n" +" finally:\n" +" cleanup() # 會被捕捉:例外正在向外傳遞\n" +" except ValueError:\n" +" pass\n" +"\n" +"def example_no_exception():\n" +" try:\n" +" do_work()\n" +" finally:\n" +" cleanup() # 不會被捕捉:未涉及例外" + +#: ../../library/profiling.sampling.rst:886 +msgid "" +"Note that ``finally`` blocks are only captured when an exception is actively " +"propagating through them. Once an ``except`` block finishes executing, " +"Python clears the exception information before running any subsequent " +"``finally`` block. Similarly, ``finally`` blocks that run during normal " +"execution (when no exception was raised) are not captured because no " +"exception state is present." +msgstr "" + +#: ../../library/profiling.sampling.rst:892 +msgid "" +"This mode is useful for understanding where your program spends time " +"handling errors. Exception handling can be a significant source of overhead " +"in code that uses exceptions for flow control (such as ``StopIteration`` in " +"iterators) or in applications that process many error conditions (such as " +"network servers handling connection failures)." +msgstr "" + +#: ../../library/profiling.sampling.rst:898 +msgid "" +"Exception mode helps answer questions like \"how much time is spent handling " +"exceptions?\" and \"which exception handlers are the most expensive?\" It " +"can reveal hidden performance costs in code that catches and processes many " +"exceptions, even when those exceptions are handled gracefully. For example, " +"if a parsing library uses exceptions internally to signal format errors, " +"this mode will capture time spent in those handlers even if the calling code " +"never sees the exceptions." +msgstr "" + +#: ../../library/profiling.sampling.rst:908 +msgid "Output formats" +msgstr "" + +#: ../../library/profiling.sampling.rst:910 +msgid "" +"The profiler produces output in several formats, each suited to different " +"analysis workflows. The format is selected with a command-line flag, and " +"output goes to stdout, a file, or a directory depending on the format." +msgstr "" + +#: ../../library/profiling.sampling.rst:916 +msgid "pstats format" +msgstr "" + +#: ../../library/profiling.sampling.rst:918 +msgid "" +"The pstats format (:option:`--pstats`) produces a text table similar to what " +"deterministic profilers generate. This is the default output format::" +msgstr "" + +#: ../../library/profiling.sampling.rst:921 +msgid "" +"python -m profiling.sampling run script.py\n" +"python -m profiling.sampling run --pstats script.py" +msgstr "" +"python -m profiling.sampling run script.py\n" +"python -m profiling.sampling run --pstats script.py" + +#: ../../library/profiling.sampling.rst:924 +msgid "Tachyon pstats terminal output" +msgstr "" + +#: ../../library/profiling.sampling.rst:929 +msgid "" +"The pstats format displays profiling results in a color-coded table showing " +"function hotspots, sample counts, and timing estimates." +msgstr "" + +#: ../../library/profiling.sampling.rst:932 +msgid "Output appears on stdout by default::" +msgstr "" + +#: ../../library/profiling.sampling.rst:934 +msgid "" +"Profile Stats (Mode: wall):\n" +" nsamples sample% tottime (ms) cumul% cumtime (ms) filename:" +"lineno(function)\n" +" 234/892 11.7% 234.00 44.6% 892.00 server." +"py:145(handle_request)\n" +" 156/156 7.8% 156.00 7.8% 156.00 :0(socket.recv)\n" +" 98/421 4.9% 98.00 21.1% 421.00 parser." +"py:67(parse_message)" +msgstr "" +"Profile Stats (Mode: wall):\n" +" nsamples sample% tottime (ms) cumul% cumtime (ms) " +"filename:lineno(function)\n" +" 234/892 11.7% 234.00 44.6% 892.00 " +"server.py:145(handle_request)\n" +" 156/156 7.8% 156.00 7.8% 156.00 :0(socket.recv)\n" +" 98/421 4.9% 98.00 21.1% 421.00 " +"parser.py:67(parse_message)" + +#: ../../library/profiling.sampling.rst:940 +msgid "The columns show sampling counts and estimated times:" +msgstr "" + +#: ../../library/profiling.sampling.rst:942 +msgid "" +"**nsamples**: Displayed as ``direct/cumulative`` (for example, ``10/50``). " +"Direct samples are when the function was at the top of the stack, actively " +"executing. Cumulative samples are when the function appeared anywhere on the " +"stack, including when it was waiting for functions it called. If a function " +"shows ``10/50``, it was directly executing in 10 samples and was on the call " +"stack in 50 samples total." +msgstr "" + +#: ../../library/profiling.sampling.rst:949 +msgid "" +"**sample%** and **cumul%**: Percentages of total samples for direct and " +"cumulative counts respectively." +msgstr "" + +#: ../../library/profiling.sampling.rst:952 +msgid "" +"**tottime** and **cumtime**: Estimated wall-clock time based on sample " +"counts and the profiling duration. Time units are selected automatically " +"based on the magnitude: seconds for large values, milliseconds for moderate " +"values, or microseconds for small values." +msgstr "" + +#: ../../library/profiling.sampling.rst:957 +msgid "" +"The output includes a legend explaining each column and a summary of " +"interesting functions that highlights:" +msgstr "" + +#: ../../library/profiling.sampling.rst:960 +msgid "" +"**Hot spots**: Functions with high direct/cumulative sample ratio (ratio " +"close to 1.0). These functions spend most of their time executing their own " +"code rather than waiting for callees. High ratios indicate where CPU time is " +"actually consumed." +msgstr "" + +#: ../../library/profiling.sampling.rst:965 +msgid "" +"**Indirect calls**: Functions with large differences between cumulative and " +"direct samples. These are orchestration functions that delegate work to " +"other functions. They appear frequently on the stack but rarely at the top." +msgstr "" + +#: ../../library/profiling.sampling.rst:969 +msgid "" +"**Call magnification**: Functions where cumulative samples far exceed direct " +"samples (high cumulative/direct multiplier). These are frequently-nested " +"functions that appear deep in many call chains." +msgstr "" + +#: ../../library/profiling.sampling.rst:973 +msgid "" +"Use :option:`--no-summary` to suppress both the legend and summary sections." +msgstr "" + +#: ../../library/profiling.sampling.rst:975 +msgid "To save pstats output to a binary file instead of stdout::" +msgstr "" + +#: ../../library/profiling.sampling.rst:977 +msgid "python -m profiling.sampling run -o profile.pstats script.py" +msgstr "python -m profiling.sampling run -o profile.pstats script.py" + +#: ../../library/profiling.sampling.rst:979 +msgid "" +"The pstats format supports several options for controlling the display. The :" +"option:`--sort` option determines the column used for ordering results::" +msgstr "" + +#: ../../library/profiling.sampling.rst:982 +msgid "" +"python -m profiling.sampling run --sort=tottime script.py\n" +"python -m profiling.sampling run --sort=cumtime script.py\n" +"python -m profiling.sampling run --sort=nsamples script.py" +msgstr "" +"python -m profiling.sampling run --sort=tottime script.py\n" +"python -m profiling.sampling run --sort=cumtime script.py\n" +"python -m profiling.sampling run --sort=nsamples script.py" + +#: ../../library/profiling.sampling.rst:986 +msgid "The :option:`--limit` option restricts output to the top N entries::" +msgstr "" + +#: ../../library/profiling.sampling.rst:988 +msgid "python -m profiling.sampling run --limit=30 script.py" +msgstr "python -m profiling.sampling run --limit=30 script.py" + +#: ../../library/profiling.sampling.rst:990 +msgid "" +"The :option:`--no-summary` option suppresses the header summary that " +"precedes the statistics table." +msgstr "" + +#: ../../library/profiling.sampling.rst:995 +msgid "Collapsed stacks format" +msgstr "" + +#: ../../library/profiling.sampling.rst:997 +msgid "" +"Collapsed stacks format (:option:`--collapsed`) produces one line per unique " +"call stack, with a count of how many times that stack was sampled::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1000 +msgid "python -m profiling.sampling run --collapsed script.py" +msgstr "python -m profiling.sampling run --collapsed script.py" + +#: ../../library/profiling.sampling.rst:1002 +msgid "The output looks like:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1004 +msgid "" +"main;process_data;parse_json;decode_utf8 42\n" +"main;process_data;parse_json 156\n" +"main;handle_request;send_response 89" +msgstr "" +"main;process_data;parse_json;decode_utf8 42\n" +"main;process_data;parse_json 156\n" +"main;handle_request;send_response 89" + +#: ../../library/profiling.sampling.rst:1010 +msgid "" +"Each line contains semicolon-separated function names representing the call " +"stack from bottom to top, followed by a space and the sample count. This " +"format is designed for compatibility with external flame graph tools, " +"particularly Brendan Gregg's ``flamegraph.pl`` script." +msgstr "" + +#: ../../library/profiling.sampling.rst:1015 +msgid "To generate a flame graph from collapsed stacks::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1017 +msgid "" +"python -m profiling.sampling run --collapsed script.py > stacks.txt\n" +"flamegraph.pl stacks.txt > profile.svg" +msgstr "" +"python -m profiling.sampling run --collapsed script.py > stacks.txt\n" +"flamegraph.pl stacks.txt > profile.svg" + +#: ../../library/profiling.sampling.rst:1020 +msgid "" +"The resulting SVG can be viewed in any web browser and provides an " +"interactive visualization where you can click to zoom into specific call " +"paths." +msgstr "" + +#: ../../library/profiling.sampling.rst:1025 +msgid "Flame graph format" +msgstr "" + +#: ../../library/profiling.sampling.rst:1027 +msgid "" +"Flame graph format (:option:`--flamegraph`) produces a self-contained HTML " +"file with an interactive flame graph visualization::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1030 +msgid "" +"python -m profiling.sampling run --flamegraph script.py\n" +"python -m profiling.sampling run --flamegraph -o profile.html script.py" +msgstr "" +"python -m profiling.sampling run --flamegraph script.py\n" +"python -m profiling.sampling run --flamegraph -o profile.html script.py" + +#: ../../library/profiling.sampling.rst:1033 +msgid "Tachyon interactive flame graph" +msgstr "" + +#: ../../library/profiling.sampling.rst:1038 +msgid "" +"The flame graph visualization shows call stacks as nested rectangles, with " +"width proportional to time spent. The sidebar displays runtime statistics, " +"GIL metrics, and hotspot functions." +msgstr "" + +#: ../../library/profiling.sampling.rst:1044 +msgid "" +"`Try the interactive example <../_static/tachyon-example-flamegraph.html>`__!" +msgstr "" +"`Try the interactive example <../_static/tachyon-example-flamegraph.html>`__!" + +#: ../../library/profiling.sampling.rst:1046 +msgid "" +"If no output file is specified, the profiler generates a filename based on " +"the process ID (for example, ``flamegraph.12345.html``)." +msgstr "" + +#: ../../library/profiling.sampling.rst:1049 +msgid "" +"The generated HTML file requires no external dependencies and can be opened " +"directly in a web browser. The visualization displays call stacks as nested " +"rectangles, with width proportional to time spent. Hovering over a rectangle " +"shows details about that function including source code context, and " +"clicking zooms into that portion of the call tree." +msgstr "" + +#: ../../library/profiling.sampling.rst:1055 +msgid "The flame graph interface includes:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1057 +msgid "" +"A sidebar showing profile summary, thread statistics, sampling efficiency " +"metrics (see :ref:`sampling-efficiency`), and top hotspot functions" +msgstr "" + +#: ../../library/profiling.sampling.rst:1059 +msgid "" +"Search functionality supporting both function name matching and ``file." +"py:42`` line patterns" +msgstr "" + +#: ../../library/profiling.sampling.rst:1061 +msgid "Per-thread filtering via dropdown" +msgstr "" + +#: ../../library/profiling.sampling.rst:1062 +msgid "Dark/light theme toggle (preference saved across sessions)" +msgstr "" + +#: ../../library/profiling.sampling.rst:1063 +msgid "SVG export for saving the current view" +msgstr "" + +#: ../../library/profiling.sampling.rst:1065 +msgid "The thread statistics section shows runtime behavior metrics:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1067 +msgid "" +"**GIL Held**: percentage of samples where a thread held the global " +"interpreter lock (actively running Python code)" +msgstr "" + +#: ../../library/profiling.sampling.rst:1069 +msgid "**GIL Released**: percentage of samples where no thread held the GIL" +msgstr "" + +#: ../../library/profiling.sampling.rst:1070 +msgid "" +"**Waiting GIL**: percentage of samples where a thread was waiting to acquire " +"the GIL" +msgstr "" + +#: ../../library/profiling.sampling.rst:1072 +msgid "**GC**: percentage of samples during garbage collection" +msgstr "" + +#: ../../library/profiling.sampling.rst:1074 +msgid "" +"These statistics help identify GIL contention and understand how time is " +"distributed between Python execution, native code, and waiting." +msgstr "" + +#: ../../library/profiling.sampling.rst:1077 +msgid "" +"Flame graphs are particularly effective for identifying deep call stacks and " +"understanding the hierarchical structure of time consumption. Wide " +"rectangles at the top indicate functions that consume significant time " +"either directly or through their callees." +msgstr "" + +#: ../../library/profiling.sampling.rst:1084 +msgid "Differential flame graphs" +msgstr "" + +#: ../../library/profiling.sampling.rst:1086 +msgid "" +"Differential flame graphs compare two profiling runs to highlight where " +"performance changed. This helps identify regressions introduced by code " +"changes and validate that optimizations achieved their intended effect::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1090 +msgid "" +"# Capture baseline profile\n" +"python -m profiling.sampling run --binary -o baseline.bin script.py\n" +"\n" +"# After modifying code, generate differential flamegraph\n" +"python -m profiling.sampling run --diff-flamegraph baseline.bin -o diff.html " +"script.py" +msgstr "" +"# 擷取基準分析資料\n" +"python -m profiling.sampling run --binary -o baseline.bin script.py\n" +"\n" +"# 修改程式碼後,產生差異火焰圖\n" +"python -m profiling.sampling run --diff-flamegraph baseline.bin -o diff.html " +"script.py" + +#: ../../library/profiling.sampling.rst:1096 +msgid "" +"The visualization draws the current profile with frame widths showing " +"current time consumption, then applies color to indicate how each function " +"changed relative to the baseline." +msgstr "" + +#: ../../library/profiling.sampling.rst:1100 +msgid "**Color coding**:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1102 +msgid "" +"**Red**: Functions consuming more time (regressions). Lighter shades " +"indicate modest increases, while darker shades show severe regressions." +msgstr "" + +#: ../../library/profiling.sampling.rst:1105 +msgid "" +"**Blue**: Functions consuming less time (improvements). Lighter shades for " +"modest reductions, darker shades for significant speedups." +msgstr "" + +#: ../../library/profiling.sampling.rst:1108 +msgid "**Gray**: Minimal or no change." +msgstr "" + +#: ../../library/profiling.sampling.rst:1110 +msgid "**Purple**: New functions not present in the baseline." +msgstr "" + +#: ../../library/profiling.sampling.rst:1112 +msgid "" +"Frame colors indicate changes in **direct time** (time when the function was " +"at the top of the stack, actively executing), not cumulative time including " +"callees. Hovering over a frame shows comparison details including baseline " +"time, current time, and the percentage change." +msgstr "" + +#: ../../library/profiling.sampling.rst:1117 +msgid "" +"Some call paths may disappear entirely between profiles. These are called " +"**elided stacks** and occur when optimizations eliminate code paths or " +"certain branches stop executing. If elided stacks are present, an elided " +"toggle appears allowing you to switch between the main differential view and " +"an elided-only view that shows just the removed paths (colored purple)." +msgstr "" + +#: ../../library/profiling.sampling.rst:1125 +msgid "Gecko format" +msgstr "" + +#: ../../library/profiling.sampling.rst:1127 +msgid "" +"Gecko format (:option:`--gecko`) produces JSON output compatible with the " +"Firefox Profiler::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1130 +msgid "" +"python -m profiling.sampling run --gecko script.py\n" +"python -m profiling.sampling run --gecko -o profile.json script.py" +msgstr "" +"python -m profiling.sampling run --gecko script.py\n" +"python -m profiling.sampling run --gecko -o profile.json script.py" + +#: ../../library/profiling.sampling.rst:1133 +msgid "" +"The `Firefox Profiler `__ is a sophisticated " +"web-based tool originally built for profiling Firefox itself. It provides " +"features beyond basic flame graphs, including a timeline view, call tree " +"exploration, and marker visualization. See the `Firefox Profiler " +"documentation `__ for detailed usage " +"instructions." +msgstr "" + +#: ../../library/profiling.sampling.rst:1140 +msgid "" +"To use the output, open the Firefox Profiler in your browser and load the " +"JSON file. The profiler runs entirely client-side, so your profiling data " +"never leaves your machine." +msgstr "" + +#: ../../library/profiling.sampling.rst:1144 +msgid "" +"Gecko format automatically collects additional metadata about GIL state and " +"CPU activity, enabling analysis features specific to Python's threading " +"model. The profiler emits interval markers that appear as colored bands in " +"the Firefox Profiler timeline:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1149 +msgid "" +"**GIL markers**: show when threads hold or release the global interpreter " +"lock" +msgstr "" + +#: ../../library/profiling.sampling.rst:1150 +msgid "**CPU markers**: show when threads are executing on CPU versus idle" +msgstr "" + +#: ../../library/profiling.sampling.rst:1151 +msgid "" +"**Code type markers**: distinguish Python code from native (C extension) code" +msgstr "" + +#: ../../library/profiling.sampling.rst:1152 +msgid "**GC markers**: indicate garbage collection activity" +msgstr "" + +#: ../../library/profiling.sampling.rst:1154 +msgid "" +"For this reason, the :option:`--mode` option is not available with Gecko " +"format; all relevant data is captured automatically." +msgstr "" + +#: ../../library/profiling.sampling.rst:1157 +msgid "Firefox Profiler Call Tree view" +msgstr "" + +#: ../../library/profiling.sampling.rst:1162 +msgid "" +"The Call Tree view shows the complete call hierarchy with sample counts and " +"percentages. The sidebar displays detailed statistics for the selected " +"function including running time and sample distribution." +msgstr "" + +#: ../../library/profiling.sampling.rst:1166 +msgid "Firefox Profiler Flame Graph view" +msgstr "" + +#: ../../library/profiling.sampling.rst:1171 +msgid "" +"The Flame Graph visualization shows call stacks as nested rectangles. " +"Functions names are visible in the call hierarchy." +msgstr "" + +#: ../../library/profiling.sampling.rst:1174 +msgid "Firefox Profiler Marker Chart with opcodes" +msgstr "" + +#: ../../library/profiling.sampling.rst:1179 +msgid "" +"The Marker Chart displays interval markers including CPU state, GIL status, " +"and opcodes. With ``--opcodes`` enabled, bytecode instructions like " +"``BINARY_OP_ADD_FLOAT``, ``CALL_PY_EXACT_ARGS``, and ``CALL_LIST_APPEND`` " +"appear as markers showing execution over time." +msgstr "" + +#: ../../library/profiling.sampling.rst:1186 +msgid "Heatmap format" +msgstr "" + +#: ../../library/profiling.sampling.rst:1188 +msgid "" +"Heatmap format (:option:`--heatmap`) generates an interactive HTML " +"visualization showing sample counts at the source line level::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1191 +msgid "" +"python -m profiling.sampling run --heatmap script.py\n" +"python -m profiling.sampling run --heatmap -o my_heatmap script.py" +msgstr "" +"python -m profiling.sampling run --heatmap script.py\n" +"python -m profiling.sampling run --heatmap -o my_heatmap script.py" + +#: ../../library/profiling.sampling.rst:1194 +msgid "Tachyon heatmap visualization" +msgstr "" + +#: ../../library/profiling.sampling.rst:1199 +msgid "" +"The heatmap overlays sample counts directly on your source code. Lines are " +"color-coded from cool (few samples) to hot (many samples). Navigation " +"buttons (▲▼) let you jump between callers and callees." +msgstr "" + +#: ../../library/profiling.sampling.rst:1203 +msgid "" +"Unlike other formats that produce a single file, heatmap output creates a " +"directory containing HTML files for each profiled source file. If no output " +"path is specified, the directory is named ``heatmap_PID``." +msgstr "" + +#: ../../library/profiling.sampling.rst:1207 +msgid "" +"The heatmap visualization displays your source code with a color gradient " +"indicating how many samples were collected at each line. Hot lines (many " +"samples) appear in warm colors, while cold lines (few or no samples) appear " +"in cool colors. This view helps pinpoint exactly which lines of code are " +"responsible for time consumption." +msgstr "" + +#: ../../library/profiling.sampling.rst:1213 +msgid "The heatmap interface provides several interactive features:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1215 +msgid "" +"**Coloring modes**: toggle between \"Self Time\" (direct execution) and " +"\"Total Time\" (cumulative, including time in called functions)" +msgstr "" + +#: ../../library/profiling.sampling.rst:1217 +msgid "**Cold code filtering**: show all lines or only lines with samples" +msgstr "" + +#: ../../library/profiling.sampling.rst:1218 +msgid "" +"**Call graph navigation**: each line shows navigation buttons (▲ for " +"callers, ▼ for callees) that let you trace execution paths through your " +"code. When multiple functions called or were called from a line, a menu " +"appears showing all options with their sample counts." +msgstr "" + +#: ../../library/profiling.sampling.rst:1222 +msgid "" +"**Scroll minimap**: a vertical overview showing the heat distribution across " +"the entire file" +msgstr "" + +#: ../../library/profiling.sampling.rst:1224 +msgid "" +"**Hierarchical index**: files organized by type (stdlib, site-packages, " +"project) with aggregate sample counts per folder" +msgstr "" + +#: ../../library/profiling.sampling.rst:1226 +msgid "**Dark/light theme**: toggle with preference saved across sessions" +msgstr "" + +#: ../../library/profiling.sampling.rst:1227 +msgid "**Line linking**: click line numbers to create shareable URLs" +msgstr "" + +#: ../../library/profiling.sampling.rst:1229 +msgid "" +"When opcode-level profiling is enabled with :option:`--opcodes`, each hot " +"line can be expanded to show which bytecode instructions consumed time:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1232 +msgid "Heatmap with expanded bytecode panel" +msgstr "" + +#: ../../library/profiling.sampling.rst:1237 +msgid "" +"Expanding a hot line reveals the bytecode instructions executed, including " +"specialized variants. The panel shows sample counts per instruction and the " +"overall specialization percentage for the line." +msgstr "" + +#: ../../library/profiling.sampling.rst:1243 +msgid "" +"`Try the interactive example <../_static/tachyon-example-heatmap.html>`__!" +msgstr "" +"`Try the interactive example <../_static/tachyon-example-heatmap.html>`__!" + +#: ../../library/profiling.sampling.rst:1245 +msgid "" +"Heatmaps are especially useful when you know which file contains a " +"performance issue but need to identify the specific lines. Many developers " +"prefer this format because it maps directly to their source code, making it " +"easy to read and navigate. For smaller scripts and focused analysis, " +"heatmaps provide an intuitive view that shows exactly where time is spent " +"without requiring interpretation of hierarchical visualizations." +msgstr "" + +#: ../../library/profiling.sampling.rst:1254 +msgid "Binary format" +msgstr "" + +#: ../../library/profiling.sampling.rst:1256 +msgid "" +"Binary format (:option:`--binary`) produces a compact binary file for " +"efficient storage of profiling data::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1259 +msgid "" +"python -m profiling.sampling run --binary -o profile.bin script.py\n" +"python -m profiling.sampling attach --binary -o profile.bin 12345" +msgstr "" +"python -m profiling.sampling run --binary -o profile.bin script.py\n" +"python -m profiling.sampling attach --binary -o profile.bin 12345" + +#: ../../library/profiling.sampling.rst:1262 +msgid "The :option:`--compression` option controls data compression:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1264 +msgid "" +"``auto`` (default): Use zstd compression if available, otherwise no " +"compression" +msgstr "" + +#: ../../library/profiling.sampling.rst:1266 +msgid "" +"``zstd``: Force zstd compression (requires :mod:`compression.zstd` support)" +msgstr "" + +#: ../../library/profiling.sampling.rst:1267 +msgid "``none``: Disable compression" +msgstr "" + +#: ../../library/profiling.sampling.rst:1271 +msgid "" +"python -m profiling.sampling run --binary --compression=zstd -o profile.bin " +"script.py" +msgstr "" +"python -m profiling.sampling run --binary --compression=zstd -o profile.bin " +"script.py" + +#: ../../library/profiling.sampling.rst:1273 +msgid "" +"To analyze binary profiles, use the :ref:`replay-command` to convert them to " +"other formats like flame graphs or pstats output." +msgstr "" + +#: ../../library/profiling.sampling.rst:1278 +msgid "Record and replay workflow" +msgstr "" + +#: ../../library/profiling.sampling.rst:1280 +msgid "" +"The binary format combined with the replay command enables a record-and-" +"replay workflow that separates data capture from analysis. Rather than " +"generating visualizations during profiling, you capture raw data to a " +"compact binary file and convert it to different formats later." +msgstr "" + +#: ../../library/profiling.sampling.rst:1285 +msgid "This approach has three main benefits:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1287 +msgid "" +"Sampling runs faster because the work of building data structures for " +"visualization is deferred until replay." +msgstr "" + +#: ../../library/profiling.sampling.rst:1289 +msgid "" +"A single binary capture can be converted to multiple output formats without " +"re-profiling: pstats for a quick overview, flame graph for visual " +"exploration, heatmap for line-level detail." +msgstr "" + +#: ../../library/profiling.sampling.rst:1292 +msgid "" +"Binary files are compact and easy to share with colleagues who can convert " +"them to their preferred format." +msgstr "" + +#: ../../library/profiling.sampling.rst:1295 +msgid "A typical workflow::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1297 +msgid "" +"# Capture profile in production or during tests\n" +"python -m profiling.sampling attach --binary -o profile.bin 12345\n" +"\n" +"# Later, analyze with different formats\n" +"python -m profiling.sampling replay profile.bin\n" +"python -m profiling.sampling replay --flamegraph -o profile.html profile." +"bin\n" +"python -m profiling.sampling replay --heatmap -o heatmap profile.bin" +msgstr "" +"# 在正式環境或測試期間擷取分析資料\n" +"python -m profiling.sampling attach --binary -o profile.bin 12345\n" +"\n" +"# 之後再以不同格式進行分析\n" +"python -m profiling.sampling replay profile.bin\n" +"python -m profiling.sampling replay --flamegraph -o profile.html " +"profile.bin\n" +"python -m profiling.sampling replay --heatmap -o heatmap profile.bin" + +#: ../../library/profiling.sampling.rst:1307 +msgid "Live mode" +msgstr "" + +#: ../../library/profiling.sampling.rst:1309 +msgid "" +"Live mode (:option:`--live`) provides a terminal-based real-time view of " +"profiling data, similar to the ``top`` command for system processes::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1312 +msgid "" +"python -m profiling.sampling run --live script.py\n" +"python -m profiling.sampling attach --live 12345" +msgstr "" +"python -m profiling.sampling run --live script.py\n" +"python -m profiling.sampling attach --live 12345" + +#: ../../library/profiling.sampling.rst:1317 +msgid "Tachyon live mode showing all threads" +msgstr "" + +#: ../../library/profiling.sampling.rst:1322 +msgid "" +"Live mode displays real-time profiling statistics, showing combined data " +"from multiple threads in a multi-threaded application." +msgstr "" + +#: ../../library/profiling.sampling.rst:1325 +msgid "" +"The display updates continuously as new samples arrive, showing the current " +"hottest functions. This mode requires the :mod:`curses` module, which is " +"available on Unix-like systems but not on Windows. The terminal must be at " +"least 60 columns wide and 12 lines tall; larger terminals display more " +"columns." +msgstr "" + +#: ../../library/profiling.sampling.rst:1330 +msgid "" +"The header displays the top 3 hottest functions, sampling efficiency " +"metrics, and thread status statistics (GIL held percentage, CPU usage, GC " +"time). The main table shows function statistics with the currently sorted " +"column indicated by an arrow (▼)." +msgstr "" + +#: ../../library/profiling.sampling.rst:1335 +msgid "" +"When :option:`--opcodes` is enabled, an additional opcode panel appears " +"below the main table, showing instruction-level statistics for the currently " +"selected function. This panel displays which bytecode instructions are " +"executing most frequently, including specialized variants and their base " +"opcodes." +msgstr "" + +#: ../../library/profiling.sampling.rst:1342 +msgid "Tachyon live mode with opcode panel" +msgstr "" + +#: ../../library/profiling.sampling.rst:1347 +msgid "" +"Live mode with ``--opcodes`` enabled shows an opcode panel with a bytecode " +"instruction breakdown for the selected function." +msgstr "" + +#: ../../library/profiling.sampling.rst:1352 +msgid "Keyboard commands" +msgstr "" + +#: ../../library/profiling.sampling.rst:1354 +msgid "Within live mode, keyboard commands control the display:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1356 +msgid ":kbd:`q`" +msgstr ":kbd:`q`" + +#: ../../library/profiling.sampling.rst:1357 +msgid "Quit the profiler and return to the shell." +msgstr "" + +#: ../../library/profiling.sampling.rst:1359 +msgid ":kbd:`s` / :kbd:`S`" +msgstr ":kbd:`s` / :kbd:`S`" + +#: ../../library/profiling.sampling.rst:1360 +msgid "" +"Cycle through sort orders forward/backward (sample count, percentage, total " +"time, cumulative percentage, cumulative time)." +msgstr "" + +#: ../../library/profiling.sampling.rst:1363 +msgid ":kbd:`p`" +msgstr ":kbd:`p`" + +#: ../../library/profiling.sampling.rst:1364 +msgid "" +"Pause or resume display updates. Sampling continues in the background while " +"the display is paused, so you can freeze the view to examine results without " +"stopping data collection." +msgstr "" + +#: ../../library/profiling.sampling.rst:1368 +msgid ":kbd:`r`" +msgstr ":kbd:`r`" + +#: ../../library/profiling.sampling.rst:1369 +msgid "" +"Reset all statistics and start fresh. This is disabled after profiling " +"finishes to prevent accidental data loss." +msgstr "" + +#: ../../library/profiling.sampling.rst:1372 +msgid ":kbd:`/`" +msgstr ":kbd:`/`" + +#: ../../library/profiling.sampling.rst:1373 +msgid "" +"Enter filter mode to search for functions by name. The filter uses case-" +"insensitive substring matching against the filename and function name. Type " +"a pattern and press Enter to apply, or Escape to cancel. Glob patterns and " +"regular expressions are not supported." +msgstr "" + +#: ../../library/profiling.sampling.rst:1378 +msgid ":kbd:`c`" +msgstr ":kbd:`c`" + +#: ../../library/profiling.sampling.rst:1379 +msgid "Clear the current filter and show all functions again." +msgstr "" + +#: ../../library/profiling.sampling.rst:1381 +msgid ":kbd:`t`" +msgstr ":kbd:`t`" + +#: ../../library/profiling.sampling.rst:1382 +msgid "" +"Toggle between viewing all threads combined or per-thread statistics. In per-" +"thread mode, a thread counter (for example, ``1/4``) appears showing your " +"position among the available threads." +msgstr "" + +#: ../../library/profiling.sampling.rst:1386 +msgid ":kbd:`←` :kbd:`→` or :kbd:`↑` :kbd:`↓`" +msgstr "" + +#: ../../library/profiling.sampling.rst:1387 +msgid "" +"In per-thread view, navigate between threads. Navigation wraps around from " +"the last thread to the first and vice versa." +msgstr "" + +#: ../../library/profiling.sampling.rst:1390 +msgid ":kbd:`+` / :kbd:`-`" +msgstr ":kbd:`+` / :kbd:`-`" + +#: ../../library/profiling.sampling.rst:1391 +msgid "" +"Increase or decrease the display refresh rate. The range is 0.05 seconds (20 " +"Hz, very responsive) to 1.0 second (1 Hz, lower overhead). Faster refresh " +"rates use more CPU. The default is 0.1 seconds (10 Hz)." +msgstr "" + +#: ../../library/profiling.sampling.rst:1395 +msgid ":kbd:`x`" +msgstr ":kbd:`x`" + +#: ../../library/profiling.sampling.rst:1396 +msgid "" +"Toggle trend indicators that show whether functions are becoming hotter or " +"cooler over time. When enabled, increasing metrics appear in green and " +"decreasing metrics appear in red, comparing each update to the previous one." +msgstr "" + +#: ../../library/profiling.sampling.rst:1400 +msgid ":kbd:`h` or :kbd:`?`" +msgstr "" + +#: ../../library/profiling.sampling.rst:1401 +msgid "Show the help screen with all available commands." +msgstr "" + +#: ../../library/profiling.sampling.rst:1403 +msgid ":kbd:`j` / :kbd:`k` (or :kbd:`Up` / :kbd:`Down`)" +msgstr "" + +#: ../../library/profiling.sampling.rst:1404 +msgid "" +"Navigate through opcode entries in the opcode panel (when ``--opcodes`` is " +"enabled). These keys scroll through the instruction-level statistics for the " +"currently selected function." +msgstr "" + +#: ../../library/profiling.sampling.rst:1408 +msgid "" +"When profiling finishes (duration expires or target process exits), the " +"display shows a \"PROFILING COMPLETE\" banner and freezes the final results. " +"You can still navigate, sort, and filter the results before pressing :kbd:" +"`q` to exit." +msgstr "" + +#: ../../library/profiling.sampling.rst:1412 +msgid "" +"Live mode is incompatible with output format options (:option:`--" +"collapsed`, :option:`--flamegraph`, and so on) because it uses an " +"interactive terminal interface rather than producing file output." +msgstr "" + +#: ../../library/profiling.sampling.rst:1418 +msgid "Async-aware profiling" +msgstr "" + +#: ../../library/profiling.sampling.rst:1420 +msgid "" +"For programs using :mod:`asyncio`, the profiler offers async-aware mode (:" +"option:`--async-aware`) that reconstructs call stacks based on the task " +"structure rather than the raw Python frames::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1424 +msgid "python -m profiling.sampling run --async-aware async_script.py" +msgstr "python -m profiling.sampling run --async-aware async_script.py" + +#: ../../library/profiling.sampling.rst:1426 +msgid "" +"Standard profiling of async code can be confusing because the physical call " +"stack often shows event loop internals rather than the logical flow of your " +"coroutines. Async-aware mode addresses this by tracking which task is " +"running and presenting stacks that reflect the ``await`` chain." +msgstr "" + +#: ../../library/profiling.sampling.rst:1431 +msgid "" +"import asyncio\n" +"\n" +"async def fetch(url):\n" +" await asyncio.sleep(0.1)\n" +" return url\n" +"\n" +"async def main():\n" +" for _ in range(50):\n" +" await asyncio.gather(fetch(\"a\"), fetch(\"b\"), fetch(\"c\"))\n" +"\n" +"if __name__ == \"__main__\":\n" +" asyncio.run(main())" +msgstr "" +"import asyncio\n" +"\n" +"async def fetch(url):\n" +" await asyncio.sleep(0.1)\n" +" return url\n" +"\n" +"async def main():\n" +" for _ in range(50):\n" +" await asyncio.gather(fetch(\"a\"), fetch(\"b\"), fetch(\"c\"))\n" +"\n" +"if __name__ == \"__main__\":\n" +" asyncio.run(main())" + +#: ../../library/profiling.sampling.rst:1448 +msgid "" +"python -m profiling.sampling run --async-aware --flamegraph -o out.html " +"script.py" +msgstr "" +"python -m profiling.sampling run --async-aware --flamegraph -o out.html " +"script.py" + +#: ../../library/profiling.sampling.rst:1452 +msgid "" +"Async-aware profiling requires the target process to have the :mod:`asyncio` " +"module loaded. If you profile a script before it imports asyncio, async-" +"aware mode will not be able to capture task information." +msgstr "" + +#: ../../library/profiling.sampling.rst:1458 +msgid "Async modes" +msgstr "" + +#: ../../library/profiling.sampling.rst:1460 +msgid "" +"The :option:`--async-mode` option controls which tasks appear in the " +"profile::" +msgstr "" + +#: ../../library/profiling.sampling.rst:1462 +msgid "" +"python -m profiling.sampling run --async-aware --async-mode=running " +"async_script.py\n" +"python -m profiling.sampling run --async-aware --async-mode=all async_script." +"py" +msgstr "" +"python -m profiling.sampling run --async-aware --async-mode=running " +"async_script.py\n" +"python -m profiling.sampling run --async-aware --async-mode=all " +"async_script.py" + +#: ../../library/profiling.sampling.rst:1465 +msgid "" +"With :option:`--async-mode`\\ ``=running`` (the default), only the task " +"currently executing on the CPU is profiled. This shows where your program is " +"actively spending time and is the typical choice for performance analysis." +msgstr "" + +#: ../../library/profiling.sampling.rst:1469 +msgid "" +"With :option:`--async-mode`\\ ``=all``, tasks that are suspended (awaiting I/" +"O, locks, or other tasks) are also included. This mode is useful for " +"understanding what your program is waiting on, but produces larger profiles " +"since every suspended task appears in each sample." +msgstr "" + +#: ../../library/profiling.sampling.rst:1476 +msgid "Task markers and stack reconstruction" +msgstr "" + +#: ../../library/profiling.sampling.rst:1478 +msgid "" +"In async-aware profiles, you will see ```` frames that mark boundaries " +"between asyncio tasks. These are synthetic frames inserted by the profiler " +"to show the task structure. The task name appears as the function name in " +"these frames." +msgstr "" + +#: ../../library/profiling.sampling.rst:1483 +msgid "" +"When a task awaits another task, the profiler reconstructs the logical call " +"chain by following the ``await`` relationships. Only \"leaf\" tasks (tasks " +"that no other task is currently awaiting) generate their own stack entries. " +"Tasks being awaited by other tasks appear as part of their awaiter's stack " +"instead." +msgstr "" + +#: ../../library/profiling.sampling.rst:1488 +msgid "" +"If a task has multiple awaiters (a diamond pattern in the task graph), the " +"profiler deterministically selects one parent and annotates the task marker " +"with the number of parents, for example ``MyTask (2 parents)``. This " +"indicates that alternate execution paths exist but are not shown in this " +"particular stack." +msgstr "" + +#: ../../library/profiling.sampling.rst:1495 +msgid "Option restrictions" +msgstr "" + +#: ../../library/profiling.sampling.rst:1497 +msgid "" +"Async-aware mode uses a different stack reconstruction mechanism and is " +"incompatible with: :option:`--native`, :option:`--no-gc`, :option:`--all-" +"threads`, and :option:`--mode`\\ ``=cpu`` or :option:`--mode`\\ ``=gil``." +msgstr "" + +#: ../../library/profiling.sampling.rst:1503 +msgid "Command-line interface" +msgstr "命令列介面" + +#: ../../library/profiling.sampling.rst:1507 +msgid "The complete command-line interface for reference." +msgstr "" + +#: ../../library/profiling.sampling.rst:1511 +msgid "Global options" +msgstr "" + +#: ../../library/profiling.sampling.rst:1515 +msgid "Run and profile a Python script or module." +msgstr "" + +#: ../../library/profiling.sampling.rst:1519 +msgid "Attach to and profile a running process by PID." +msgstr "" + +#: ../../library/profiling.sampling.rst:1523 +msgid "Print a single one-shot snapshot of a running process's Python stack." +msgstr "" + +#: ../../library/profiling.sampling.rst:1527 +msgid "Convert a binary profile file to another output format." +msgstr "" + +#: ../../library/profiling.sampling.rst:1531 +msgid "Dump options" +msgstr "" + +#: ../../library/profiling.sampling.rst:1533 +msgid "The following options apply to the ``dump`` subcommand:" +msgstr "" + +#: ../../library/profiling.sampling.rst:1537 +msgid "Dump all threads in the target process instead of just the main thread." +msgstr "" + +#: ../../library/profiling.sampling.rst:1541 +#: ../../library/profiling.sampling.rst:1588 +msgid "Include ```` frames for non-Python code." +msgstr "" + +#: ../../library/profiling.sampling.rst:1545 +msgid "Exclude ```` frames for active garbage collection." +msgstr "" + +#: ../../library/profiling.sampling.rst:1549 +msgid "Show bytecode opcode names when available." +msgstr "" + +#: ../../library/profiling.sampling.rst:1553 +msgid "" +"Reconstruct the stack across ``await`` boundaries for asyncio applications." +msgstr "" + +#: ../../library/profiling.sampling.rst:1558 +msgid "" +"Async stack mode: ``running`` (only the running task) or ``all`` (all tasks " +"including waiting). Defaults to ``all`` for ``dump``. Requires :option:`--" +"async-aware`." +msgstr "" + +#: ../../library/profiling.sampling.rst:1564 +msgid "Pause all threads in the target process while reading the stack." +msgstr "" + +#: ../../library/profiling.sampling.rst:1568 +msgid "Sampling options" +msgstr "" + +#: ../../library/profiling.sampling.rst:1572 +msgid "" +"Sampling rate (for example, ``10000``, ``10khz``, ``10k``). Default: " +"``1khz``." +msgstr "" + +#: ../../library/profiling.sampling.rst:1576 +msgid "Profiling duration in seconds. Default: run to completion." +msgstr "" + +#: ../../library/profiling.sampling.rst:1580 +msgid "Sample all threads, not just the main thread." +msgstr "" + +#: ../../library/profiling.sampling.rst:1584 +msgid "Display sampling statistics during profiling." +msgstr "" + +#: ../../library/profiling.sampling.rst:1592 +msgid "Exclude ```` frames for garbage collection." +msgstr "" + +#: ../../library/profiling.sampling.rst:1596 +msgid "Enable async-aware profiling for asyncio programs." +msgstr "" + +#: ../../library/profiling.sampling.rst:1600 +msgid "" +"Gather bytecode opcode information for instruction-level profiling. Shows " +"which bytecode instructions are executing, including specializations. " +"Compatible with ``--live``, ``--flamegraph``, ``--heatmap``, and ``--gecko`` " +"formats only." +msgstr "" + +#: ../../library/profiling.sampling.rst:1607 +msgid "" +"Also profile subprocesses. Each subprocess gets its own profiler instance " +"and output file. Incompatible with ``--live``." +msgstr "" + +#: ../../library/profiling.sampling.rst:1612 +msgid "" +"Pause the target process during each sample. This ensures consistent stack " +"traces at the cost of slowing down the target. Use with longer intervals " +"(1000 µs or higher) to minimize impact. See :ref:`blocking-mode` for details." +msgstr "" + +#: ../../library/profiling.sampling.rst:1619 +msgid "Mode options" +msgstr "" + +#: ../../library/profiling.sampling.rst:1623 +msgid "" +"Sampling mode: ``wall`` (default), ``cpu``, ``gil``, or ``exception``. The " +"``cpu``, ``gil``, and ``exception`` modes are incompatible with ``--async-" +"aware``." +msgstr "" + +#: ../../library/profiling.sampling.rst:1629 +msgid "" +"Async profiling mode: ``running`` (default) or ``all``. Requires ``--async-" +"aware``." +msgstr "" + +#: ../../library/profiling.sampling.rst:1634 +msgid "Output options" +msgstr "" + +#: ../../library/profiling.sampling.rst:1638 +msgid "" +"Generate pstats statistics. This is the default. When written to stdout, the " +"output is a text table; with :option:`-o`, it is a binary pstats file." +msgstr "" + +#: ../../library/profiling.sampling.rst:1644 +msgid "Generate collapsed stack format for external flame graph tools." +msgstr "" + +#: ../../library/profiling.sampling.rst:1648 +msgid "Generate self-contained HTML flame graph." +msgstr "" + +#: ../../library/profiling.sampling.rst:1652 +msgid "" +"Generate differential flamegraph comparing to a baseline binary profile." +msgstr "" + +#: ../../library/profiling.sampling.rst:1656 +msgid "Generate Gecko JSON format for Firefox Profiler." +msgstr "" + +#: ../../library/profiling.sampling.rst:1660 +msgid "Generate HTML heatmap with line-level sample counts." +msgstr "" + +#: ../../library/profiling.sampling.rst:1664 +msgid "" +"Generate high-performance binary format for later conversion with the " +"``replay`` command." +msgstr "" + +#: ../../library/profiling.sampling.rst:1669 +msgid "" +"Compression for binary format: ``auto`` (use zstd if available, default), " +"``zstd``, or ``none``." +msgstr "" + +#: ../../library/profiling.sampling.rst:1674 +msgid "" +"Output file or directory path. Default behavior varies by format: :option:`--" +"pstats` prints a text table to stdout, while ``-o`` writes a binary pstats " +"file. Other formats generate a file named ``_.`` (for " +"example, ``flamegraph_12345.html``). :option:`--heatmap` creates a directory " +"named ``heatmap_``." +msgstr "" + +#: ../../library/profiling.sampling.rst:1682 +msgid "" +"Automatically open HTML output (:option:`--flamegraph` and :option:`--" +"heatmap`) in your default web browser after generation. When profiling with :" +"option:`--subprocesses`, only the main process opens the browser; subprocess " +"outputs are never auto-opened." +msgstr "" + +#: ../../library/profiling.sampling.rst:1689 +msgid "pstats display options" +msgstr "" + +#: ../../library/profiling.sampling.rst:1691 +msgid "These options apply only to pstats format output." +msgstr "" + +#: ../../library/profiling.sampling.rst:1695 +msgid "" +"Sort order: ``nsamples``, ``tottime``, ``cumtime``, ``sample-pct``, ``cumul-" +"pct``, ``nsamples-cumul``, or ``name``. Default: ``nsamples``." +msgstr "" + +#: ../../library/profiling.sampling.rst:1700 +msgid "Maximum number of entries to display. Default: 15." +msgstr "" + +#: ../../library/profiling.sampling.rst:1704 +msgid "" +"Omit the Legend and Summary of Interesting Functions sections from output." +msgstr "" + +#: ../../library/profiling.sampling.rst:1708 +msgid "Run command options" +msgstr "" + +#: ../../library/profiling.sampling.rst:1712 +msgid "Treat the target as a module name rather than a script path." +msgstr "" + +#: ../../library/profiling.sampling.rst:1716 +msgid "Start interactive terminal interface instead of batch profiling." +msgstr "" + +#: ../../library/profiling.sampling.rst:1721 +msgid ":mod:`profiling`" +msgstr ":mod:`profiling`" + +#: ../../library/profiling.sampling.rst:1722 +msgid "Overview of Python profiling tools and guidance on choosing a profiler." +msgstr "" + +#: ../../library/profiling.sampling.rst:1724 +msgid ":mod:`profiling.tracing`" +msgstr ":mod:`profiling.tracing`" + +#: ../../library/profiling.sampling.rst:1725 +msgid "Deterministic tracing profiler for exact call counts and timing." +msgstr "" + +#: ../../library/profiling.sampling.rst:1727 +msgid ":mod:`pstats`" +msgstr ":mod:`pstats`" + +#: ../../library/profiling.sampling.rst:1728 +msgid "Statistics analysis for profile data." +msgstr "" + +#: ../../library/profiling.sampling.rst:1730 +msgid "`Firefox Profiler `__" +msgstr "`Firefox Profiler `__" + +#: ../../library/profiling.sampling.rst:1731 +msgid "" +"Web-based profiler that accepts Gecko format output. See the `documentation " +"`__ for usage details." +msgstr "" + +#: ../../library/profiling.sampling.rst:1734 +msgid "`FlameGraph `__" +msgstr "`FlameGraph `__" + +#: ../../library/profiling.sampling.rst:1735 +msgid "Tools for generating flame graphs from collapsed stack format." +msgstr "" diff --git a/library/profiling.tracing.po b/library/profiling.tracing.po new file mode 100644 index 00000000000..9dd84f8a783 --- /dev/null +++ b/library/profiling.tracing.po @@ -0,0 +1,522 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../library/profiling.tracing.rst:5 +msgid ":mod:`!profiling.tracing` --- Deterministic profiler" +msgstr "" + +#: ../../library/profiling.tracing.rst:16 +msgid "**Source code:** :source:`Lib/profiling/tracing/`" +msgstr "" + +#: ../../library/profiling.tracing.rst:20 +msgid "" +"The :mod:`!profiling.tracing` module provides deterministic profiling of " +"Python programs. It monitors every function call, function return, and " +"exception event, recording precise timing for each. This approach provides " +"exact call counts and complete visibility into program execution, making it " +"ideal for development and testing scenarios." +msgstr "" + +#: ../../library/profiling.tracing.rst:28 +msgid "" +"This module is also available as ``cProfile`` for backward compatibility. " +"The ``cProfile`` name will continue to work in all future Python versions. " +"Use whichever import style suits your codebase::" +msgstr "" + +#: ../../library/profiling.tracing.rst:32 +msgid "" +"# Preferred (new style)\n" +"import profiling.tracing\n" +"profiling.tracing.run('my_function()')\n" +"\n" +"# Also works (backward compatible)\n" +"import cProfile\n" +"cProfile.run('my_function()')" +msgstr "" +"# 建議做法(新式)\n" +"import profiling.tracing\n" +"profiling.tracing.run('my_function()')\n" +"\n" +"# 也可行(向後相容)\n" +"import cProfile\n" +"cProfile.run('my_function()')" + +#: ../../library/profiling.tracing.rst:42 +msgid "What is deterministic profiling?" +msgstr "" + +#: ../../library/profiling.tracing.rst:44 +msgid "" +":dfn:`Deterministic profiling` captures every function call, function " +"return, and exception event during program execution. The profiler measures " +"the precise time intervals between these events, providing exact statistics " +"about how the program behaves." +msgstr "" + +#: ../../library/profiling.tracing.rst:49 +msgid "" +"In contrast to :ref:`statistical profiling `, which " +"samples the call stack periodically to estimate where time is spent, " +"deterministic profiling records every event. This means you get exact call " +"counts rather than statistical approximations. The trade-off is that " +"instrumenting every event introduces overhead that can slow down program " +"execution." +msgstr "" + +#: ../../library/profiling.tracing.rst:55 +msgid "" +"Python's interpreted nature makes deterministic profiling practical. The " +"interpreter already dispatches events for function calls and returns, so the " +"profiler can hook into this mechanism without requiring code modification. " +"The overhead tends to be moderate relative to the inherent cost of " +"interpretation, making deterministic profiling suitable for most development " +"workflows." +msgstr "" + +#: ../../library/profiling.tracing.rst:61 +msgid "Deterministic profiling helps answer questions like:" +msgstr "" + +#: ../../library/profiling.tracing.rst:63 +msgid "How many times was this function called?" +msgstr "" + +#: ../../library/profiling.tracing.rst:64 +msgid "What is the complete call graph of my program?" +msgstr "" + +#: ../../library/profiling.tracing.rst:65 +msgid "Which functions are called by a particular function?" +msgstr "" + +#: ../../library/profiling.tracing.rst:66 +msgid "Are there unexpected function calls happening?" +msgstr "" + +#: ../../library/profiling.tracing.rst:68 +msgid "" +"Call count statistics can identify bugs (surprising counts) and inline " +"expansion opportunities (high call counts). Internal time statistics reveal " +"\"hot loops\" that warrant optimization. Cumulative time statistics help " +"identify algorithmic inefficiencies. The handling of cumulative times in " +"this profiler allows direct comparison of recursive and iterative " +"implementations." +msgstr "" + +#: ../../library/profiling.tracing.rst:78 +msgid "Command-line interface" +msgstr "命令列介面" + +#: ../../library/profiling.tracing.rst:82 +msgid "" +"The :mod:`!profiling.tracing` module can be invoked as a script to profile " +"another script or module:" +msgstr "" + +#: ../../library/profiling.tracing.rst:85 +msgid "" +"python -m profiling.tracing [-o output_file] [-s sort_order] (-m module | " +"script.py)" +msgstr "" +"python -m profiling.tracing [-o output_file] [-s sort_order] (-m module | " +"script.py)" + +#: ../../library/profiling.tracing.rst:89 +msgid "" +"This runs the specified script or module under the profiler and prints the " +"results to standard output (or saves them to a file)." +msgstr "" + +#: ../../library/profiling.tracing.rst:94 +msgid "" +"Write the profile results to a file instead of standard output. The output " +"file can be read by the :mod:`pstats` module for later analysis." +msgstr "" + +#: ../../library/profiling.tracing.rst:99 +msgid "" +"Sort the output by the specified key. This accepts any of the sort keys " +"recognized by :meth:`pstats.Stats.sort_stats`, such as ``cumulative``, " +"``time``, ``calls``, or ``name``. This option only applies when :option:`-o " +"` is not specified." +msgstr "" + +#: ../../library/profiling.tracing.rst:106 +msgid "" +"Profile a module instead of a script. The module is located using the " +"standard import mechanism." +msgstr "" + +#: ../../library/profiling.tracing.rst:109 +msgid "The ``-m`` option for ``cProfile``." +msgstr "" + +#: ../../library/profiling.tracing.rst:112 +msgid "The ``-m`` option for :mod:`profile`." +msgstr "" + +#: ../../library/profiling.tracing.rst:117 +msgid "Programmatic usage examples" +msgstr "" + +#: ../../library/profiling.tracing.rst:119 +msgid "" +"For more control over profiling, use the module's functions and classes " +"directly." +msgstr "" + +#: ../../library/profiling.tracing.rst:124 +msgid "Basic profiling" +msgstr "" + +#: ../../library/profiling.tracing.rst:126 +msgid "The simplest approach uses the :func:`!run` function::" +msgstr "" + +#: ../../library/profiling.tracing.rst:128 +msgid "" +"import profiling.tracing\n" +"profiling.tracing.run('my_function()')" +msgstr "" +"import profiling.tracing\n" +"profiling.tracing.run('my_function()')" + +#: ../../library/profiling.tracing.rst:131 +msgid "" +"This profiles the given code string and prints a summary to standard output. " +"To save results for later analysis::" +msgstr "" + +#: ../../library/profiling.tracing.rst:134 +msgid "profiling.tracing.run('my_function()', 'output.prof')" +msgstr "profiling.tracing.run('my_function()', 'output.prof')" + +#: ../../library/profiling.tracing.rst:138 +msgid "Using the :class:`!Profile` class" +msgstr "" + +#: ../../library/profiling.tracing.rst:140 +msgid "The :class:`!Profile` class provides fine-grained control::" +msgstr "" + +#: ../../library/profiling.tracing.rst:142 +msgid "" +"import profiling.tracing\n" +"import pstats\n" +"from io import StringIO\n" +"\n" +"pr = profiling.tracing.Profile()\n" +"pr.enable()\n" +"# ... code to profile ...\n" +"pr.disable()\n" +"\n" +"# Print results\n" +"s = StringIO()\n" +"ps = pstats.Stats(pr, stream=s).sort_stats(pstats.SortKey.CUMULATIVE)\n" +"ps.print_stats()\n" +"print(s.getvalue())" +msgstr "" +"import profiling.tracing\n" +"import pstats\n" +"from io import StringIO\n" +"\n" +"pr = profiling.tracing.Profile()\n" +"pr.enable()\n" +"# ... 要分析的程式碼 ...\n" +"pr.disable()\n" +"\n" +"# 印出結果\n" +"s = StringIO()\n" +"ps = pstats.Stats(pr, stream=s).sort_stats(pstats.SortKey.CUMULATIVE)\n" +"ps.print_stats()\n" +"print(s.getvalue())" + +#: ../../library/profiling.tracing.rst:157 +msgid "The :class:`!Profile` class also works as a context manager::" +msgstr "" + +#: ../../library/profiling.tracing.rst:159 +msgid "" +"import profiling.tracing\n" +"\n" +"with profiling.tracing.Profile() as pr:\n" +" # ... code to profile ...\n" +"\n" +"pr.print_stats()" +msgstr "" +"import profiling.tracing\n" +"\n" +"with profiling.tracing.Profile() as pr:\n" +" # ... 要分析的程式碼 ...\n" +"\n" +"pr.print_stats()" + +#: ../../library/profiling.tracing.rst:168 +msgid "Module reference" +msgstr "" + +#: ../../library/profiling.tracing.rst:174 +msgid "Profile execution of a command and print or save the results." +msgstr "" + +#: ../../library/profiling.tracing.rst:176 +msgid "" +"This function executes the *command* string using :func:`exec` in the " +"``__main__`` module's namespace::" +msgstr "" + +#: ../../library/profiling.tracing.rst:179 +msgid "exec(command, __main__.__dict__, __main__.__dict__)" +msgstr "exec(command, __main__.__dict__, __main__.__dict__)" + +#: ../../library/profiling.tracing.rst:181 +msgid "" +"If *filename* is not provided, the function creates a :class:`pstats.Stats` " +"instance and prints a summary to standard output. If *filename* is provided, " +"the raw profile data is saved to that file for later analysis with :mod:" +"`pstats`." +msgstr "" + +#: ../../library/profiling.tracing.rst:186 +msgid "" +"The *sort* argument specifies the sort order for printed output, accepting " +"any value recognized by :meth:`pstats.Stats.sort_stats`." +msgstr "" + +#: ../../library/profiling.tracing.rst:192 +msgid "Profile execution of a command with explicit namespaces." +msgstr "" + +#: ../../library/profiling.tracing.rst:194 +msgid "" +"Like :func:`run`, but executes the command with the specified *globals* and " +"*locals* mappings instead of using the ``__main__`` module's namespace::" +msgstr "" + +#: ../../library/profiling.tracing.rst:197 +msgid "exec(command, globals, locals)" +msgstr "exec(command, globals, locals)" + +#: ../../library/profiling.tracing.rst:202 +msgid "A profiler object that collects execution statistics." +msgstr "" + +#: ../../library/profiling.tracing.rst:204 +msgid "" +"The optional *timer* argument specifies a custom timing function. If not " +"provided, the profiler uses a platform-appropriate default timer. When " +"supplying a custom timer, it must return a single number representing the " +"current time. If the timer returns integers, use *timeunit* to specify the " +"duration of one time unit (for example, ``0.001`` for milliseconds)." +msgstr "" + +#: ../../library/profiling.tracing.rst:210 +msgid "" +"The *subcalls* argument controls whether the profiler tracks call " +"relationships between functions. The *builtins* argument controls whether " +"built-in functions are profiled." +msgstr "" + +#: ../../library/profiling.tracing.rst:214 +msgid "Added context manager support." +msgstr "新增情境管理器的支援。" + +#: ../../library/profiling.tracing.rst:219 +msgid "Start collecting profiling data." +msgstr "" + +#: ../../library/profiling.tracing.rst:223 +msgid "Stop collecting profiling data." +msgstr "" + +#: ../../library/profiling.tracing.rst:227 +msgid "" +"Stop collecting data and record the results internally as the current " +"profile." +msgstr "" + +#: ../../library/profiling.tracing.rst:232 +msgid "" +"Create a :class:`pstats.Stats` object from the current profile and print the " +"results to standard output." +msgstr "" + +#: ../../library/profiling.tracing.rst:235 +msgid "" +"The *sort* argument specifies the sorting order. It accepts a single key or " +"a tuple of keys for multi-level sorting, using the same values as :meth:" +"`pstats.Stats.sort_stats`." +msgstr "" + +#: ../../library/profiling.tracing.rst:239 +msgid "Support for a tuple of sort keys." +msgstr "" + +#: ../../library/profiling.tracing.rst:244 +msgid "" +"Write the current profile data to *filename*. The file can be read by :class:" +"`pstats.Stats` for later analysis." +msgstr "" + +#: ../../library/profiling.tracing.rst:249 +msgid "Profile the command string via :func:`exec`." +msgstr "" + +#: ../../library/profiling.tracing.rst:253 +msgid "" +"Profile the command string via :func:`exec` with the specified namespaces." +msgstr "" + +#: ../../library/profiling.tracing.rst:258 +msgid "Profile a function call. Returns whatever *func* returns::" +msgstr "" + +#: ../../library/profiling.tracing.rst:260 +msgid "result = pr.runcall(my_function, arg1, arg2, keyword=value)" +msgstr "result = pr.runcall(my_function, arg1, arg2, keyword=value)" + +#: ../../library/profiling.tracing.rst:264 +msgid "" +"Profiling requires that the profiled code returns normally. If the " +"interpreter terminates (for example, via :func:`sys.exit`) during profiling, " +"no results will be available." +msgstr "" + +#: ../../library/profiling.tracing.rst:270 +msgid "Using a custom timer" +msgstr "" + +#: ../../library/profiling.tracing.rst:272 +msgid "" +"The :class:`Profile` class accepts a custom timing function, allowing you to " +"measure different aspects of execution such as wall-clock time or CPU time. " +"Pass the timing function to the constructor::" +msgstr "" + +#: ../../library/profiling.tracing.rst:276 +msgid "pr = profiling.tracing.Profile(my_timer_function)" +msgstr "pr = profiling.tracing.Profile(my_timer_function)" + +#: ../../library/profiling.tracing.rst:278 +msgid "" +"The timer function must return a single number representing the current " +"time. If it returns integers, also specify *timeunit* to indicate the " +"duration of one unit::" +msgstr "" + +#: ../../library/profiling.tracing.rst:282 +msgid "" +"# Timer returns time in milliseconds\n" +"pr = profiling.tracing.Profile(my_ms_timer, 0.001)" +msgstr "" +"# 計時器回傳以毫秒為單位的時間\n" +"pr = profiling.tracing.Profile(my_ms_timer, 0.001)" + +#: ../../library/profiling.tracing.rst:285 +msgid "" +"For best performance, the timer function should be as fast as possible. The " +"profiler calls it frequently, so timer overhead directly affects profiling " +"overhead." +msgstr "" + +#: ../../library/profiling.tracing.rst:289 +msgid "" +"The :mod:`time` module provides several functions suitable for use as custom " +"timers:" +msgstr "" + +#: ../../library/profiling.tracing.rst:292 +msgid ":func:`time.perf_counter` for high-resolution wall-clock time" +msgstr "" + +#: ../../library/profiling.tracing.rst:293 +msgid ":func:`time.process_time` for CPU time (excluding sleep)" +msgstr "" + +#: ../../library/profiling.tracing.rst:294 +msgid ":func:`time.monotonic` for monotonic clock time" +msgstr "" + +#: ../../library/profiling.tracing.rst:298 +msgid "Limitations" +msgstr "限制" + +#: ../../library/profiling.tracing.rst:300 +msgid "" +"Deterministic profiling has inherent limitations related to timing accuracy." +msgstr "" + +#: ../../library/profiling.tracing.rst:302 +msgid "" +"The underlying timer typically has a resolution of about one millisecond. " +"Measurements cannot be more accurate than this resolution. With enough " +"measurements, timing errors tend to average out, but individual measurements " +"may be imprecise." +msgstr "" + +#: ../../library/profiling.tracing.rst:307 +msgid "" +"There is also latency between when an event occurs and when the profiler " +"captures the timestamp. Similarly, there is latency after reading the " +"timestamp before user code resumes. Functions called frequently accumulate " +"this latency, which can make them appear slower than they actually are. This " +"error is typically less than one clock tick per call but can become " +"significant for functions called many times." +msgstr "" + +#: ../../library/profiling.tracing.rst:314 +msgid "" +"The :mod:`!profiling.tracing` module (and its ``cProfile`` alias) is " +"implemented as a C extension with low overhead, so these timing issues are " +"less pronounced than with the deprecated pure Python :mod:`profile` module." +msgstr "" + +#: ../../library/profiling.tracing.rst:321 +msgid ":mod:`profiling`" +msgstr ":mod:`profiling`" + +#: ../../library/profiling.tracing.rst:322 +msgid "Overview of Python profiling tools and guidance on choosing a profiler." +msgstr "" + +#: ../../library/profiling.tracing.rst:324 +msgid ":mod:`profiling.sampling`" +msgstr ":mod:`profiling.sampling`" + +#: ../../library/profiling.tracing.rst:325 +msgid "Statistical sampling profiler for production use." +msgstr "" + +#: ../../library/profiling.tracing.rst:327 +msgid ":mod:`pstats`" +msgstr ":mod:`pstats`" + +#: ../../library/profiling.tracing.rst:328 +msgid "Statistics analysis and formatting for profile data." +msgstr "" + +#: ../../library/profiling.tracing.rst:330 +msgid ":mod:`profile`" +msgstr ":mod:`profile`" + +#: ../../library/profiling.tracing.rst:331 +msgid "Deprecated pure Python profiler (includes calibration documentation)." +msgstr "" diff --git a/library/pstats.po b/library/pstats.po new file mode 100644 index 00000000000..90d0a2982c8 --- /dev/null +++ b/library/pstats.po @@ -0,0 +1,684 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001 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.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../library/pstats.rst:5 +msgid ":mod:`!pstats` --- Statistics for profilers" +msgstr "" + +#: ../../library/pstats.rst:10 +msgid "**Source code:** :source:`Lib/pstats.py`" +msgstr "" + +#: ../../library/pstats.rst:14 +msgid "" +"The :mod:`!pstats` module provides tools for reading, manipulating, and " +"displaying profiling statistics generated by Python's profilers. It reads " +"output from both :mod:`profiling.tracing` (deterministic profiler) and :mod:" +"`profiling.sampling` (statistical profiler)." +msgstr "" + +#: ../../library/pstats.rst:21 +msgid "Reading and displaying profile data" +msgstr "" + +#: ../../library/pstats.rst:23 +msgid "" +"The :class:`Stats` class is the primary interface for working with profile " +"data. It can read statistics from files or directly from a :class:" +"`~profiling.tracing.Profile` object." +msgstr "" + +#: ../../library/pstats.rst:27 +msgid "Load statistics from a file and print a basic report::" +msgstr "" + +#: ../../library/pstats.rst:29 +msgid "" +"import pstats\n" +"\n" +"p = pstats.Stats('profile_output.prof')\n" +"p.print_stats()" +msgstr "" +"import pstats\n" +"\n" +"p = pstats.Stats('profile_output.prof')\n" +"p.print_stats()" + +#: ../../library/pstats.rst:34 +msgid "" +"The :class:`Stats` object provides methods for sorting and filtering the " +"data before printing. For example, to see the ten functions with the highest " +"cumulative time::" +msgstr "" + +#: ../../library/pstats.rst:38 +msgid "" +"from pstats import SortKey\n" +"\n" +"p = pstats.Stats('profile_output.prof')\n" +"p.sort_stats(SortKey.CUMULATIVE).print_stats(10)" +msgstr "" +"from pstats import SortKey\n" +"\n" +"p = pstats.Stats('profile_output.prof')\n" +"p.sort_stats(SortKey.CUMULATIVE).print_stats(10)" + +#: ../../library/pstats.rst:45 +msgid "Working with statistics" +msgstr "" + +#: ../../library/pstats.rst:47 +msgid "" +"The :class:`Stats` class supports method chaining, making it convenient to " +"perform multiple operations::" +msgstr "" + +#: ../../library/pstats.rst:50 +msgid "" +"p = pstats.Stats('restats')\n" +"p.strip_dirs().sort_stats(-1).print_stats()" +msgstr "" +"p = pstats.Stats('restats')\n" +"p.strip_dirs().sort_stats(-1).print_stats()" + +#: ../../library/pstats.rst:53 +msgid "" +"The :meth:`~Stats.strip_dirs` method removes directory paths from filenames, " +"making the output more compact. The :meth:`~Stats.sort_stats` method accepts " +"various keys to control the sort order." +msgstr "" + +#: ../../library/pstats.rst:57 +msgid "Different sort keys highlight different aspects of performance::" +msgstr "" + +#: ../../library/pstats.rst:59 +msgid "" +"from pstats import SortKey\n" +"\n" +"# Functions that consume the most cumulative time\n" +"p.sort_stats(SortKey.CUMULATIVE).print_stats(10)\n" +"\n" +"# Functions that consume the most time in their own code\n" +"p.sort_stats(SortKey.TIME).print_stats(10)\n" +"\n" +"# Functions sorted by name\n" +"p.sort_stats(SortKey.NAME).print_stats()" +msgstr "" +"from pstats import SortKey\n" +"\n" +"# 累計耗時最多的函式\n" +"p.sort_stats(SortKey.CUMULATIVE).print_stats(10)\n" +"\n" +"# 自身程式碼耗時最多的函式\n" +"p.sort_stats(SortKey.TIME).print_stats(10)\n" +"\n" +"# 依名稱排序的函式\n" +"p.sort_stats(SortKey.NAME).print_stats()" + +#: ../../library/pstats.rst:72 +msgid "Filtering output" +msgstr "" + +#: ../../library/pstats.rst:74 +msgid "" +"The :meth:`~Stats.print_stats` method accepts restrictions that filter which " +"functions are displayed. Restrictions can be integers (limiting the count), " +"floats between 0 and 1 (selecting a percentage), or strings (matching " +"function names via regular expression)." +msgstr "" + +#: ../../library/pstats.rst:79 +msgid "Print only the top 10%::" +msgstr "" + +#: ../../library/pstats.rst:81 +msgid "p.print_stats(.1)" +msgstr "p.print_stats(.1)" + +#: ../../library/pstats.rst:83 +msgid "Print only functions whose names contain \"init\"::" +msgstr "" + +#: ../../library/pstats.rst:85 +msgid "p.print_stats('init')" +msgstr "p.print_stats('init')" + +#: ../../library/pstats.rst:87 +msgid "Combine restrictions (they apply sequentially)::" +msgstr "" + +#: ../../library/pstats.rst:89 +msgid "" +"# Top 10%, then only those containing \"init\"\n" +"p.print_stats(.1, 'init')\n" +"\n" +"# Functions in files matching \"foo:\", limited to top 50%\n" +"p.sort_stats(SortKey.FILENAME).print_stats('foo:', .5)" +msgstr "" +"# 前 10%,再從中只保留包含 \"init\" 的項目\n" +"p.print_stats(.1, 'init')\n" +"\n" +"# 位於符合 \"foo:\" 之檔案中的函式,限制為前 50%\n" +"p.sort_stats(SortKey.FILENAME).print_stats('foo:', .5)" + +#: ../../library/pstats.rst:97 +msgid "Analyzing call relationships" +msgstr "" + +#: ../../library/pstats.rst:99 +msgid "" +"The :meth:`~Stats.print_callers` method shows which functions called each " +"displayed function::" +msgstr "" + +#: ../../library/pstats.rst:102 +msgid "p.print_callers()" +msgstr "p.print_callers()" + +#: ../../library/pstats.rst:104 +msgid "" +"The :meth:`~Stats.print_callees` method shows the opposite relationship, " +"listing which functions each displayed function called::" +msgstr "" + +#: ../../library/pstats.rst:107 +msgid "p.print_callees()" +msgstr "p.print_callees()" + +#: ../../library/pstats.rst:109 +msgid "" +"Both methods accept the same restriction arguments as :meth:`~Stats." +"print_stats`." +msgstr "" + +#: ../../library/pstats.rst:113 +msgid "Combining multiple profiles" +msgstr "" + +#: ../../library/pstats.rst:115 +msgid "" +"Statistics from multiple profiling runs can be combined into a single :class:" +"`Stats` object::" +msgstr "" + +#: ../../library/pstats.rst:118 +msgid "" +"# Load multiple files at once\n" +"p = pstats.Stats('run1.prof', 'run2.prof', 'run3.prof')\n" +"\n" +"# Or add files incrementally\n" +"p = pstats.Stats('run1.prof')\n" +"p.add('run2.prof')\n" +"p.add('run3.prof')" +msgstr "" +"# 一次載入多個檔案\n" +"p = pstats.Stats('run1.prof', 'run2.prof', 'run3.prof')\n" +"\n" +"# 或逐一加入檔案\n" +"p = pstats.Stats('run1.prof')\n" +"p.add('run2.prof')\n" +"p.add('run3.prof')" + +#: ../../library/pstats.rst:126 +msgid "" +"When files are combined, statistics for identical functions (same file, " +"line, and name) are accumulated, giving an aggregate view across all " +"profiling runs." +msgstr "" + +#: ../../library/pstats.rst:131 +msgid "The :class:`!Stats` class" +msgstr "" + +#: ../../library/pstats.rst:135 +msgid "Create a statistics object from profile data." +msgstr "" + +#: ../../library/pstats.rst:137 +msgid "" +"The arguments can be filenames (strings or path-like objects) or :class:" +"`~profiling.tracing.Profile` objects. If multiple sources are provided, " +"their statistics are combined." +msgstr "" + +#: ../../library/pstats.rst:141 +msgid "" +"The *stream* argument specifies where output from :meth:`print_stats` and " +"related methods is written. It defaults to :data:`sys.stdout`." +msgstr "" + +#: ../../library/pstats.rst:144 +msgid "" +"The profile data format is specific to the Python version that created it. " +"There is no compatibility guarantee between Python versions or between " +"different profilers." +msgstr "" + +#: ../../library/pstats.rst:150 +msgid "Remove leading path information from all filenames." +msgstr "" + +#: ../../library/pstats.rst:152 +msgid "" +"This method modifies the object in place and returns it for method chaining. " +"After stripping, the statistics are considered to be in random order." +msgstr "" + +#: ../../library/pstats.rst:156 +msgid "" +"If stripping causes two functions to become indistinguishable (same " +"filename, line number, and function name), their statistics are combined " +"into a single entry." +msgstr "" + +#: ../../library/pstats.rst:162 +msgid "Add profiling data from additional files." +msgstr "" + +#: ../../library/pstats.rst:164 +msgid "" +"The files must have been created by the same profiler type. Statistics for " +"identical functions are accumulated." +msgstr "" + +#: ../../library/pstats.rst:169 +msgid "Save the current statistics to a file." +msgstr "" + +#: ../../library/pstats.rst:171 +msgid "" +"The file is created if it does not exist and overwritten if it does. The " +"saved data can be loaded by creating a new :class:`Stats` object." +msgstr "" + +#: ../../library/pstats.rst:176 +msgid "Sort the statistics according to the specified criteria." +msgstr "" + +#: ../../library/pstats.rst:178 +msgid "" +"Each key can be a string or a :class:`SortKey` enum member. When multiple " +"keys are provided, later keys break ties in earlier keys." +msgstr "" + +#: ../../library/pstats.rst:181 +msgid "" +"Using :class:`SortKey` enum members is preferred over strings as it provides " +"better error checking::" +msgstr "" + +#: ../../library/pstats.rst:184 +msgid "" +"from pstats import SortKey\n" +"p.sort_stats(SortKey.CUMULATIVE)" +msgstr "" +"from pstats import SortKey\n" +"p.sort_stats(SortKey.CUMULATIVE)" + +#: ../../library/pstats.rst:187 +msgid "Valid sort keys:" +msgstr "" + +#: ../../library/pstats.rst:190 +msgid "String" +msgstr "" + +#: ../../library/pstats.rst:190 +msgid "Enum" +msgstr "" + +#: ../../library/pstats.rst:190 +msgid "Meaning" +msgstr "" + +#: ../../library/pstats.rst:192 +msgid "``'calls'``" +msgstr "``'calls'``" + +#: ../../library/pstats.rst:192 +msgid "``SortKey.CALLS``" +msgstr "``SortKey.CALLS``" + +#: ../../library/pstats.rst:192 ../../library/pstats.rst:204 +msgid "call count" +msgstr "" + +#: ../../library/pstats.rst:194 +msgid "``'cumulative'``" +msgstr "``'cumulative'``" + +#: ../../library/pstats.rst:194 +msgid "``SortKey.CUMULATIVE``" +msgstr "``SortKey.CUMULATIVE``" + +#: ../../library/pstats.rst:194 ../../library/pstats.rst:196 +msgid "cumulative time" +msgstr "" + +#: ../../library/pstats.rst:196 +msgid "``'cumtime'``" +msgstr "``'cumtime'``" + +#: ../../library/pstats.rst:196 ../../library/pstats.rst:198 +#: ../../library/pstats.rst:202 ../../library/pstats.rst:204 +#: ../../library/pstats.rst:218 +msgid "N/A" +msgstr "N/A" + +#: ../../library/pstats.rst:198 +msgid "``'file'``" +msgstr "``'file'``" + +#: ../../library/pstats.rst:198 ../../library/pstats.rst:200 +#: ../../library/pstats.rst:202 +msgid "file name" +msgstr "檔案名稱" + +#: ../../library/pstats.rst:200 +msgid "``'filename'``" +msgstr "``'filename'``" + +#: ../../library/pstats.rst:200 +msgid "``SortKey.FILENAME``" +msgstr "``SortKey.FILENAME``" + +#: ../../library/pstats.rst:202 +msgid "``'module'``" +msgstr "``'module'``" + +#: ../../library/pstats.rst:204 +msgid "``'ncalls'``" +msgstr "``'ncalls'``" + +#: ../../library/pstats.rst:206 +msgid "``'pcalls'``" +msgstr "``'pcalls'``" + +#: ../../library/pstats.rst:206 +msgid "``SortKey.PCALLS``" +msgstr "``SortKey.PCALLS``" + +#: ../../library/pstats.rst:206 +msgid "primitive call count" +msgstr "" + +#: ../../library/pstats.rst:208 +msgid "``'line'``" +msgstr "``'line'``" + +#: ../../library/pstats.rst:208 +msgid "``SortKey.LINE``" +msgstr "``SortKey.LINE``" + +#: ../../library/pstats.rst:208 +msgid "line number" +msgstr "列號" + +#: ../../library/pstats.rst:210 +msgid "``'name'``" +msgstr "``'name'``" + +#: ../../library/pstats.rst:210 +msgid "``SortKey.NAME``" +msgstr "``SortKey.NAME``" + +#: ../../library/pstats.rst:210 +msgid "function name" +msgstr "" + +#: ../../library/pstats.rst:212 +msgid "``'nfl'``" +msgstr "``'nfl'``" + +#: ../../library/pstats.rst:212 +msgid "``SortKey.NFL``" +msgstr "``SortKey.NFL``" + +#: ../../library/pstats.rst:212 +msgid "name/file/line" +msgstr "" + +#: ../../library/pstats.rst:214 +msgid "``'stdname'``" +msgstr "``'stdname'``" + +#: ../../library/pstats.rst:214 +msgid "``SortKey.STDNAME``" +msgstr "``SortKey.STDNAME``" + +#: ../../library/pstats.rst:214 +msgid "standard name" +msgstr "" + +#: ../../library/pstats.rst:216 +msgid "``'time'``" +msgstr "``'time'``" + +#: ../../library/pstats.rst:216 +msgid "``SortKey.TIME``" +msgstr "``SortKey.TIME``" + +#: ../../library/pstats.rst:216 ../../library/pstats.rst:218 +msgid "internal time" +msgstr "" + +#: ../../library/pstats.rst:218 +msgid "``'tottime'``" +msgstr "``'tottime'``" + +#: ../../library/pstats.rst:221 +msgid "" +"All sorts on statistics are in descending order (most time consuming first), " +"while name, file, and line number sorts are ascending (alphabetical)." +msgstr "" + +#: ../../library/pstats.rst:225 +msgid "" +"The difference between ``SortKey.NFL`` and ``SortKey.STDNAME`` is that NFL " +"sorts line numbers numerically while STDNAME sorts them as strings. " +"``sort_stats(SortKey.NFL)`` is equivalent to ``sort_stats(SortKey.NAME, " +"SortKey.FILENAME, SortKey.LINE)``." +msgstr "" + +#: ../../library/pstats.rst:230 +msgid "" +"For backward compatibility, the numeric arguments ``-1``, ``0``, ``1``, and " +"``2`` are also accepted, meaning ``'stdname'``, ``'calls'``, ``'time'``, and " +"``'cumulative'`` respectively." +msgstr "" + +#: ../../library/pstats.rst:234 +msgid "The :class:`SortKey` enum." +msgstr "" + +#: ../../library/pstats.rst:239 +msgid "Reverse the current sort order." +msgstr "" + +#: ../../library/pstats.rst:241 +msgid "" +"By default, the sort direction is chosen appropriately for the sort key " +"(descending for time-based keys, ascending for name-based keys). This method " +"inverts that choice." +msgstr "" + +#: ../../library/pstats.rst:247 +msgid "Print a report of the profiling statistics." +msgstr "" + +#: ../../library/pstats.rst:249 +msgid "" +"The output includes a header line summarizing the data, followed by a table " +"of function statistics sorted according to the last :meth:`sort_stats` call." +msgstr "" + +#: ../../library/pstats.rst:253 +msgid "Restrictions filter the output. Each restriction is either:" +msgstr "" + +#: ../../library/pstats.rst:255 +msgid "An integer: limits output to that many entries" +msgstr "" + +#: ../../library/pstats.rst:256 +msgid "A float between 0.0 and 1.0: selects that fraction of entries" +msgstr "" + +#: ../../library/pstats.rst:257 +msgid "A string: matches function names via regular expression" +msgstr "" + +#: ../../library/pstats.rst:259 +msgid "Restrictions are applied sequentially. For example::" +msgstr "" + +#: ../../library/pstats.rst:261 +msgid "print_stats(.1, 'foo:')" +msgstr "print_stats(.1, 'foo:')" + +#: ../../library/pstats.rst:263 +msgid "First limits to the top 10%, then filters to functions matching 'foo:'." +msgstr "" + +#: ../../library/pstats.rst:267 +msgid "Print the callers of each function in the statistics." +msgstr "" + +#: ../../library/pstats.rst:269 +msgid "" +"For each function in the filtered results, shows which functions called it " +"and how often." +msgstr "" + +#: ../../library/pstats.rst:272 +msgid "" +"With :mod:`profiling.tracing` (or ``cProfile``), each caller line shows " +"three numbers: the number of calls from that caller, and the total and " +"cumulative times for those specific calls." +msgstr "" + +#: ../../library/pstats.rst:276 ../../library/pstats.rst:285 +msgid "Accepts the same restriction arguments as :meth:`print_stats`." +msgstr "" + +#: ../../library/pstats.rst:280 +msgid "Print the functions called by each function in the statistics." +msgstr "" + +#: ../../library/pstats.rst:282 +msgid "" +"This is the inverse of :meth:`print_callers`, showing which functions each " +"listed function called." +msgstr "" + +#: ../../library/pstats.rst:289 +msgid "Return a ``StatsProfile`` object containing the statistics." +msgstr "" + +#: ../../library/pstats.rst:291 +msgid "" +"The returned object provides programmatic access to the profile data, with " +"function names mapped to ``FunctionProfile`` objects containing timing and " +"call count information." +msgstr "" + +#: ../../library/pstats.rst:300 +msgid "An enumeration of valid sort keys for :meth:`Stats.sort_stats`." +msgstr "" + +#: ../../library/pstats.rst:304 +msgid "Sort by call count." +msgstr "" + +#: ../../library/pstats.rst:308 +msgid "Sort by cumulative time." +msgstr "" + +#: ../../library/pstats.rst:312 +msgid "Sort by file name." +msgstr "" + +#: ../../library/pstats.rst:316 +msgid "Sort by line number." +msgstr "" + +#: ../../library/pstats.rst:320 +msgid "Sort by function name." +msgstr "" + +#: ../../library/pstats.rst:324 +msgid "Sort by name, then file, then line number (numeric line sort)." +msgstr "" + +#: ../../library/pstats.rst:328 +msgid "Sort by primitive (non-recursive) call count." +msgstr "" + +#: ../../library/pstats.rst:332 +msgid "Sort by standard name (string-based line sort)." +msgstr "" + +#: ../../library/pstats.rst:336 +msgid "Sort by internal time (time in function excluding subcalls)." +msgstr "" + +#: ../../library/pstats.rst:342 +msgid "Command-line interface" +msgstr "命令列介面" + +#: ../../library/pstats.rst:344 +msgid "" +"The :mod:`!pstats` module can be invoked as a script to interactively browse " +"profile data::" +msgstr "" + +#: ../../library/pstats.rst:347 +msgid "python -m pstats profile_output.prof" +msgstr "python -m pstats profile_output.prof" + +#: ../../library/pstats.rst:349 +msgid "" +"This opens a line-oriented interface (built on :mod:`cmd`) for examining the " +"statistics. Type ``help`` at the prompt for available commands." +msgstr "" + +#: ../../library/pstats.rst:355 +msgid ":mod:`profiling`" +msgstr ":mod:`profiling`" + +#: ../../library/pstats.rst:356 +msgid "Overview of Python profiling tools." +msgstr "" + +#: ../../library/pstats.rst:358 +msgid ":mod:`profiling.tracing`" +msgstr ":mod:`profiling.tracing`" + +#: ../../library/pstats.rst:359 +msgid "Deterministic tracing profiler." +msgstr "" + +#: ../../library/pstats.rst:361 +msgid ":mod:`profiling.sampling`" +msgstr ":mod:`profiling.sampling`" + +#: ../../library/pstats.rst:362 +msgid "Statistical sampling profiler." +msgstr "" diff --git a/library/pty.po b/library/pty.po index 0cccf13a6eb..6986a3e2f25 100644 --- a/library/pty.po +++ b/library/pty.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-20 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2016-11-19 00:33+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,33 +21,33 @@ msgstr "" msgid ":mod:`!pty` --- Pseudo-terminal utilities" msgstr ":mod:`!pty` --- 偽終端工具" -#: ../../library/pty.rst:10 +#: ../../library/pty.rst:7 msgid "**Source code:** :source:`Lib/pty.py`" msgstr "**原始碼:**\\ :source:`Lib/pty.py`" -#: ../../library/pty.rst:14 +#: ../../library/pty.rst:11 msgid "" "The :mod:`!pty` module defines operations for handling the pseudo-terminal " "concept: starting another process and being able to write to and read from " "its controlling terminal programmatically." msgstr "" -#: ../../library/pty.rst:18 +#: ../../library/pty.rst:15 msgid "Availability" msgstr "可用性" -#: ../../library/pty.rst:20 +#: ../../library/pty.rst:17 msgid "" "Pseudo-terminal handling is highly platform dependent. This code is mainly " "tested on Linux, FreeBSD, and macOS (it is supposed to work on other POSIX " "platforms but it's not been thoroughly tested)." msgstr "" -#: ../../library/pty.rst:24 +#: ../../library/pty.rst:21 msgid "The :mod:`!pty` module defines the following functions:" msgstr ":mod:`!pty` 模組定義了以下函式:" -#: ../../library/pty.rst:29 +#: ../../library/pty.rst:26 msgid "" "Fork. Connect the child's controlling terminal to a pseudo-terminal. Return " "value is ``(pid, fd)``. Note that the child gets *pid* 0, and the *fd* is " @@ -56,20 +56,29 @@ msgid "" "the child's standard input and output)." msgstr "" -#: ../../library/pty.rst:35 +#: ../../library/pty.rst:32 +msgid "" +"The returned file descriptor *fd* is :ref:`non-inheritable `." +msgstr "" + +#: ../../library/pty.rst:34 msgid "" "On macOS the use of this function is unsafe when mixed with using higher-" "level system APIs, and that includes using :mod:`urllib.request`." msgstr "" -#: ../../library/pty.rst:41 +#: ../../library/pty.rst:37 +msgid "The returned file descriptor is now made non-inheritable." +msgstr "" + +#: ../../library/pty.rst:43 msgid "" "Open a new pseudo-terminal pair, using :func:`os.openpty` if possible, or " "emulation code for generic Unix systems. Return a pair of file descriptors " "``(master, slave)``, for the master and the slave end, respectively." msgstr "" -#: ../../library/pty.rst:48 +#: ../../library/pty.rst:50 msgid "" "Spawn a process, and connect its controlling terminal with the current " "process's standard io. This is often used to baffle programs which insist on " @@ -78,14 +87,14 @@ msgid "" "will return." msgstr "" -#: ../../library/pty.rst:54 +#: ../../library/pty.rst:56 msgid "" "A loop copies STDIN of the current process to the child and data received " "from the child to STDOUT of the current process. It is not signaled to the " "child if STDIN of the current process closes down." msgstr "" -#: ../../library/pty.rst:58 +#: ../../library/pty.rst:60 msgid "" "The functions *master_read* and *stdin_read* are passed a file descriptor " "which they should read from, and they should always return a byte string. In " @@ -93,7 +102,7 @@ msgid "" "array should be returned to signal end of file." msgstr "" -#: ../../library/pty.rst:63 +#: ../../library/pty.rst:65 msgid "" "The default implementation for both functions will read and return up to " "1024 bytes each time the function is called. The *master_read* callback is " @@ -102,7 +111,7 @@ msgid "" "the parent process's standard input." msgstr "" -#: ../../library/pty.rst:69 +#: ../../library/pty.rst:71 msgid "" "Returning an empty byte string from either callback is interpreted as an end-" "of-file (EOF) condition, and that callback will not be called after that. If " @@ -112,31 +121,31 @@ msgid "" "signals EOF the same behavior results (on linux at least)." msgstr "" -#: ../../library/pty.rst:76 +#: ../../library/pty.rst:78 msgid "" "Return the exit status value from :func:`os.waitpid` on the child process." msgstr "" -#: ../../library/pty.rst:78 +#: ../../library/pty.rst:80 msgid "" ":func:`os.waitstatus_to_exitcode` can be used to convert the exit status " "into an exit code." msgstr "" -#: ../../library/pty.rst:81 +#: ../../library/pty.rst:83 msgid "" "Raises an :ref:`auditing event ` ``pty.spawn`` with argument " "``argv``." msgstr "" "引發一個附帶引數 ``argv`` 的\\ :ref:`稽核事件 ` ``pty.spawn``。" -#: ../../library/pty.rst:83 +#: ../../library/pty.rst:85 msgid "" ":func:`spawn` now returns the status value from :func:`os.waitpid` on the " "child process." msgstr "" -#: ../../library/pty.rst:88 +#: ../../library/pty.rst:90 msgid "Example" msgstr "範例" diff --git a/library/py_compile.po b/library/py_compile.po index 7ab3b0d0e98..8c7986346fc 100644 --- a/library/py_compile.po +++ b/library/py_compile.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,30 +21,30 @@ msgstr "" msgid ":mod:`!py_compile` --- Compile Python source files" msgstr ":mod:`!py_compile` — 編譯 Python 來源檔案" -#: ../../library/py_compile.rst:10 +#: ../../library/py_compile.rst:7 msgid "**Source code:** :source:`Lib/py_compile.py`" msgstr "**原始碼:**\\ :source:`Lib/py_compile.py`" -#: ../../library/py_compile.rst:16 +#: ../../library/py_compile.rst:13 msgid "" "The :mod:`!py_compile` module provides a function to generate a byte-code " "file from a source file, and another function used when the module source " "file is invoked as a script." msgstr "" -#: ../../library/py_compile.rst:20 +#: ../../library/py_compile.rst:17 msgid "" "Though not often needed, this function can be useful when installing modules " "for shared use, especially if some of the users may not have permission to " "write the byte-code cache files in the directory containing the source code." msgstr "" -#: ../../library/py_compile.rst:27 +#: ../../library/py_compile.rst:24 msgid "" "Exception raised when an error occurs while attempting to compile the file." msgstr "" -#: ../../library/py_compile.rst:32 +#: ../../library/py_compile.rst:29 msgid "" "Compile a source file to byte-code and write out the byte-code cache file. " "The source code is loaded from the file named *file*. The byte-code is " @@ -60,7 +60,7 @@ msgid "" "*cfile* value was used." msgstr "" -#: ../../library/py_compile.rst:46 +#: ../../library/py_compile.rst:43 msgid "" "The *doraise* and *quiet* arguments determine how errors are handled while " "compiling file. If *quiet* is 0 or 1, and *doraise* is false, the default " @@ -70,7 +70,7 @@ msgid "" "written, and *doraise* has no effect." msgstr "" -#: ../../library/py_compile.rst:53 +#: ../../library/py_compile.rst:50 msgid "" "If the path that *cfile* becomes (either explicitly specified or computed) " "is a symlink or non-regular file, :exc:`FileExistsError` will be raised. " @@ -80,14 +80,14 @@ msgid "" "file into place to prevent concurrent file writing issues." msgstr "" -#: ../../library/py_compile.rst:60 +#: ../../library/py_compile.rst:57 msgid "" "*optimize* controls the optimization level and is passed to the built-in :" "func:`compile` function. The default of ``-1`` selects the optimization " "level of the current interpreter." msgstr "" -#: ../../library/py_compile.rst:64 +#: ../../library/py_compile.rst:61 msgid "" "*invalidation_mode* should be a member of the :class:`PycInvalidationMode` " "enum and controls how the generated bytecode cache is invalidated at " @@ -96,14 +96,14 @@ msgid "" "default is :attr:`PycInvalidationMode.TIMESTAMP`." msgstr "" -#: ../../library/py_compile.rst:70 +#: ../../library/py_compile.rst:67 msgid "" "Changed default value of *cfile* to be :PEP:`3147`-compliant. Previous " "default was *file* + ``'c'`` (``'o'`` if optimization was enabled). Also " "added the *optimize* parameter." msgstr "" -#: ../../library/py_compile.rst:75 +#: ../../library/py_compile.rst:72 msgid "" "Changed code to use :mod:`importlib` for the byte-code cache file writing. " "This means file creation/writing semantics now match what :mod:`importlib` " @@ -112,7 +112,7 @@ msgid "" "file." msgstr "" -#: ../../library/py_compile.rst:82 +#: ../../library/py_compile.rst:79 msgid "" "The *invalidation_mode* parameter was added as specified in :pep:`552`. If " "the :envvar:`SOURCE_DATE_EPOCH` environment variable is set, " @@ -120,18 +120,18 @@ msgid "" "CHECKED_HASH`." msgstr "" -#: ../../library/py_compile.rst:88 +#: ../../library/py_compile.rst:85 msgid "" "The :envvar:`SOURCE_DATE_EPOCH` environment variable no longer overrides the " "value of the *invalidation_mode* argument, and determines its default value " "instead." msgstr "" -#: ../../library/py_compile.rst:93 +#: ../../library/py_compile.rst:90 msgid "The *quiet* parameter was added." msgstr "新增 *quiet* 參數。" -#: ../../library/py_compile.rst:99 +#: ../../library/py_compile.rst:96 msgid "" "An enumeration of possible methods the interpreter can use to determine " "whether a bytecode file is up to date with a source file. The ``.pyc`` file " @@ -140,38 +140,38 @@ msgid "" "at runtime." msgstr "" -#: ../../library/py_compile.rst:109 +#: ../../library/py_compile.rst:106 msgid "" "The ``.pyc`` file includes the timestamp and size of the source file, which " "Python will compare against the metadata of the source file at runtime to " "determine if the ``.pyc`` file needs to be regenerated." msgstr "" -#: ../../library/py_compile.rst:115 +#: ../../library/py_compile.rst:112 msgid "" "The ``.pyc`` file includes a hash of the source file content, which Python " "will compare against the source at runtime to determine if the ``.pyc`` file " "needs to be regenerated." msgstr "" -#: ../../library/py_compile.rst:121 +#: ../../library/py_compile.rst:118 msgid "" "Like :attr:`CHECKED_HASH`, the ``.pyc`` file includes a hash of the source " "file content. However, Python will at runtime assume the ``.pyc`` file is up " "to date and not validate the ``.pyc`` against the source file at all." msgstr "" -#: ../../library/py_compile.rst:125 +#: ../../library/py_compile.rst:122 msgid "" "This option is useful when the ``.pycs`` are kept up to date by some system " "external to Python like a build system." msgstr "" -#: ../../library/py_compile.rst:131 +#: ../../library/py_compile.rst:128 msgid "Command-Line Interface" msgstr "命令列介面" -#: ../../library/py_compile.rst:133 +#: ../../library/py_compile.rst:130 msgid "" "This module can be invoked as a script to compile several source files. The " "files named in *filenames* are compiled and the resulting bytecode is cached " @@ -180,36 +180,36 @@ msgid "" "status is nonzero if one of the files could not be compiled." msgstr "" -#: ../../library/py_compile.rst:145 +#: ../../library/py_compile.rst:142 msgid "" "Positional arguments are files to compile. If ``-`` is the only parameter, " "the list of files is taken from standard input." msgstr "" -#: ../../library/py_compile.rst:150 +#: ../../library/py_compile.rst:147 msgid "Suppress errors output." msgstr "" -#: ../../library/py_compile.rst:152 +#: ../../library/py_compile.rst:149 msgid "Added support for ``-``." msgstr "新增對 ``-`` 的支援。" -#: ../../library/py_compile.rst:155 +#: ../../library/py_compile.rst:152 msgid "Added support for :option:`-q`." msgstr "新增對 :option:`-q` 的支援。" -#: ../../library/py_compile.rst:161 +#: ../../library/py_compile.rst:158 msgid "Module :mod:`compileall`" msgstr ":mod:`compileall` 模組" -#: ../../library/py_compile.rst:162 +#: ../../library/py_compile.rst:159 msgid "Utilities to compile all Python source files in a directory tree." msgstr "" -#: ../../library/py_compile.rst:12 +#: ../../library/py_compile.rst:9 msgid "file" msgstr "file(檔案)" -#: ../../library/py_compile.rst:12 +#: ../../library/py_compile.rst:9 msgid "byte-code" msgstr "byte-code(位元組碼)" diff --git a/library/pyclbr.po b/library/pyclbr.po index 4f506db0112..5b76051c0fe 100644 --- a/library/pyclbr.po +++ b/library/pyclbr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-07-09 13:16+0800\n" "Last-Translator: Weilin Du <1372449351@qq.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!pyclbr` --- Python module browser support" msgstr ":mod:`!pyclbr` --- Python 模組瀏覽器支援" -#: ../../library/pyclbr.rst:9 +#: ../../library/pyclbr.rst:7 msgid "**Source code:** :source:`Lib/pyclbr.py`" msgstr "**原始碼:**\\ :source:`Lib/pyclbr.py`" -#: ../../library/pyclbr.rst:13 +#: ../../library/pyclbr.rst:11 msgid "" "The :mod:`!pyclbr` module provides limited information about the functions, " "classes, and methods defined in a Python-coded module. The information is " @@ -43,7 +43,7 @@ msgstr "" "此限制使得此模組無法與非 Python 實作的模組一起使用,包括所有標準與可選的擴充" "模組。" -#: ../../library/pyclbr.rst:25 +#: ../../library/pyclbr.rst:23 msgid "" "Return a dictionary mapping module-level class names to class descriptors. " "If possible, descriptors for imported base classes are included. Parameter " @@ -57,7 +57,7 @@ msgstr "" "名稱。如果給定,*path* 是以 ``sys.path`` 為前綴的目錄路徑序列,用來定位模組原" "始碼。" -#: ../../library/pyclbr.rst:32 +#: ../../library/pyclbr.rst:30 msgid "" "This function is the original interface and is only kept for back " "compatibility. It returns a filtered version of the following." @@ -65,7 +65,7 @@ msgstr "" "此函式為原始介面,僅保留用於向後相容性。它回傳的會是 readmodule_ex 回傳結果的" "篩選後版本。" -#: ../../library/pyclbr.rst:38 +#: ../../library/pyclbr.rst:36 msgid "" "Return a dictionary-based tree containing a function or class descriptors " "for each function and class defined in the module with a ``def`` or " @@ -83,7 +83,7 @@ msgstr "" "組是一個套件,回傳的字典有一個 key ``'__path__'``,其值是一個包含套件搜尋路徑" "的串列。" -#: ../../library/pyclbr.rst:48 +#: ../../library/pyclbr.rst:46 msgid "" "Descriptors for nested definitions. They are accessed through the new " "children attribute. Each has a new parent attribute." @@ -91,7 +91,7 @@ msgstr "" "巢狀定義(nested definitions)的描述器。這些描述器可透過新的子屬性來存取。每" "個描述器都有一個新的父屬性。" -#: ../../library/pyclbr.rst:52 +#: ../../library/pyclbr.rst:50 msgid "" "The descriptors returned by these functions are instances of Function and " "Class classes. Users are not expected to create instances of these classes." @@ -99,45 +99,45 @@ msgstr "" "這些函式所回傳的描述器是 Function 和 Class 類別的實例。使用者不需要建立這些類" "別的實例。" -#: ../../library/pyclbr.rst:60 +#: ../../library/pyclbr.rst:58 msgid "Function Objects" msgstr "函式物件" -#: ../../library/pyclbr.rst:64 +#: ../../library/pyclbr.rst:62 msgid "" "Class :class:`!Function` instances describe functions defined by def " "statements. They have the following attributes:" msgstr "" "Class :class:`!Function` 實例描述由 def 陳述式定義的函式。它們具有以下屬性:" -#: ../../library/pyclbr.rst:70 +#: ../../library/pyclbr.rst:68 msgid "Name of the file in which the function is defined." msgstr "定義函式的檔案名稱。" -#: ../../library/pyclbr.rst:75 +#: ../../library/pyclbr.rst:73 msgid "The name of the module defining the function described." msgstr "定義所述函式的模組名稱。" -#: ../../library/pyclbr.rst:80 +#: ../../library/pyclbr.rst:78 msgid "The name of the function." msgstr "函式的名稱。" -#: ../../library/pyclbr.rst:85 ../../library/pyclbr.rst:140 +#: ../../library/pyclbr.rst:83 ../../library/pyclbr.rst:138 msgid "The line number in the file where the definition starts." msgstr "檔案中定義開始的行號。" -#: ../../library/pyclbr.rst:90 +#: ../../library/pyclbr.rst:88 msgid "For top-level functions, ``None``. For nested functions, the parent." msgstr "" "對於頂層函式(top-level functions)為 ``None``。對於巢狀函式,則使用父函式。" -#: ../../library/pyclbr.rst:97 +#: ../../library/pyclbr.rst:95 msgid "" "A :class:`dictionary ` mapping names to descriptors for nested " "functions and classes." msgstr "一個 :class:`dictionary ` 將名稱對應到巢狀函式和類別的描述器。" -#: ../../library/pyclbr.rst:105 +#: ../../library/pyclbr.rst:103 msgid "" "``True`` for functions that are defined with the :keyword:`async ` prefix, ``False`` otherwise." @@ -145,11 +145,11 @@ msgstr "" "對於使用 :keyword:`async ` 前綴定義的函式是 ``True``,否則是 " "``False``。" -#: ../../library/pyclbr.rst:114 +#: ../../library/pyclbr.rst:112 msgid "Class Objects" msgstr "類別物件" -#: ../../library/pyclbr.rst:118 +#: ../../library/pyclbr.rst:116 msgid "" "Class :class:`!Class` instances describe classes defined by class " "statements. They have the same attributes as :class:`Functions ` " @@ -158,28 +158,28 @@ msgstr "" "Class :class:`!Class` 實例描述由 class 陳述式定義的類別。它們具有與 :class:" "`Functions ` 相同的屬性,以及另外兩個屬性。" -#: ../../library/pyclbr.rst:125 +#: ../../library/pyclbr.rst:123 msgid "Name of the file in which the class is defined." msgstr "定義類別的檔案名稱。" -#: ../../library/pyclbr.rst:130 +#: ../../library/pyclbr.rst:128 msgid "The name of the module defining the class described." msgstr "定義所述類別的模組名稱。" -#: ../../library/pyclbr.rst:135 +#: ../../library/pyclbr.rst:133 msgid "The name of the class." msgstr "類別的名稱。" -#: ../../library/pyclbr.rst:145 +#: ../../library/pyclbr.rst:143 msgid "For top-level classes, ``None``. For nested classes, the parent." msgstr "對於頂層類別為 ``None``。對於巢狀類別,則使用父類別。" -#: ../../library/pyclbr.rst:152 +#: ../../library/pyclbr.rst:150 msgid "" "A dictionary mapping names to descriptors for nested functions and classes." msgstr "將名稱對應到巢狀函式和類別的描述器的字典。" -#: ../../library/pyclbr.rst:160 +#: ../../library/pyclbr.rst:158 msgid "" "A list of :class:`!Class` objects which describe the immediate base classes " "of the class being described. Classes which are named as superclasses but " @@ -190,7 +190,7 @@ msgstr "" "(superclasses)但無法被 :func:`readmodule_ex` 發現的類別會以類別名稱的字串形" "式列出,而不是 :class:`!Class` 物件。" -#: ../../library/pyclbr.rst:169 +#: ../../library/pyclbr.rst:167 msgid "" "A :class:`dictionary ` mapping method names to line numbers. This can " "be derived from the newer :attr:`children` dictionary, but remains for back-" diff --git a/library/pydoc.po b/library/pydoc.po index d9b6272f62e..b0468ea17ae 100644 --- a/library/pydoc.po +++ b/library/pydoc.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-30 00:38+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-07-17 17:00+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!pydoc` --- Documentation generator and online help system" msgstr ":mod:`!pydoc` --- 文件產生器與線上幫助系統" -#: ../../library/pydoc.rst:10 +#: ../../library/pydoc.rst:7 msgid "**Source code:** :source:`Lib/pydoc.py`" msgstr "**原始碼:**\\ :source:`Lib/pydoc.py`" -#: ../../library/pydoc.rst:19 +#: ../../library/pydoc.rst:16 msgid "" "The :mod:`!pydoc` module automatically generates documentation from Python " "modules. The documentation can be presented as pages of text on the " @@ -36,7 +36,7 @@ msgstr "" ":mod:`!pydoc` 模組會自動從 Python 模組產生文件。文件可以以文字頁面的形式呈現" "在主控台上、提供給網頁瀏覽器,或儲存為 HTML 檔案。" -#: ../../library/pydoc.rst:23 +#: ../../library/pydoc.rst:20 msgid "" "For modules, classes, functions and methods, the displayed documentation is " "derived from the docstring (i.e. the :attr:`~definition.__doc__` attribute) " @@ -51,7 +51,7 @@ msgstr "" "如果沒有說明字串,:mod:`!pydoc` 會嘗試從原始碼檔案中,類別、函式或方法定義正" "上方的註解區塊,或從模組的頂部取得描述(參見 :func:`inspect.getcomments`)。" -#: ../../library/pydoc.rst:30 +#: ../../library/pydoc.rst:27 msgid "" "The built-in function :func:`help` invokes the online help system in the " "interactive interpreter, which uses :mod:`!pydoc` to generate its " @@ -64,11 +64,11 @@ msgstr "" "檢視,方法是在作業系統的命令提示字元中,將 :program:`pydoc` 當作腳本執行。例" "如,執行: ::" -#: ../../library/pydoc.rst:36 +#: ../../library/pydoc.rst:33 msgid "python -m pydoc sys" msgstr "python -m pydoc sys" -#: ../../library/pydoc.rst:38 +#: ../../library/pydoc.rst:35 msgid "" "at a shell prompt will display documentation on the :mod:`sys` module, in a " "style similar to the manual pages shown by the Unix :program:`man` command. " @@ -86,7 +86,7 @@ msgstr "" "它包含你作業系統的路徑分隔符,例如 Unix 中的斜線),並且指向一個已存在的 " "Python 原始碼檔案,那麼就會為該檔案產生文件。" -#: ../../library/pydoc.rst:49 +#: ../../library/pydoc.rst:46 msgid "" "In order to find objects and their documentation, :mod:`!pydoc` imports the " "module(s) to be documented. Therefore, any code on module level will be " @@ -97,7 +97,7 @@ msgstr "" "級的程式碼都會在那個時候被執行。使用 ``if __name__ == '__main__':`` 的防護措" "施,可以確保程式碼只在檔案作為腳本被呼叫時執行,而不會在被引入時就執行。" -#: ../../library/pydoc.rst:54 +#: ../../library/pydoc.rst:51 msgid "" "When printing output to the console, :program:`pydoc` attempts to paginate " "the output for easier reading. If either the :envvar:`MANPAGER` or the :" @@ -109,7 +109,7 @@ msgstr "" "`pydoc` 將會使用其值作為分頁程式。當兩者都被設定時,會使用 :envvar:" "`MANPAGER`。" -#: ../../library/pydoc.rst:59 +#: ../../library/pydoc.rst:56 msgid "" "Specifying a ``-w`` flag before the argument will cause HTML documentation " "to be written out to a file in the current directory, instead of displaying " @@ -118,7 +118,7 @@ msgstr "" "在引數前指定一個 ``-w`` 旗標,將會使 HTML 文件被寫入目前目錄的一個檔案中,而" "不是在主控台上顯示文字。" -#: ../../library/pydoc.rst:63 +#: ../../library/pydoc.rst:60 msgid "" "Specifying a ``-k`` flag before the argument will search the synopsis lines " "of all available modules for the keyword given as the argument, again in a " @@ -129,7 +129,7 @@ msgstr "" "尋找作為引數給出的關鍵字,其方式同樣類似於 Unix 的 :program:`man` 命令。一個" "模組的摘要行是其說明字串的第一行。" -#: ../../library/pydoc.rst:68 +#: ../../library/pydoc.rst:65 msgid "" "You can also use :program:`pydoc` to start an HTTP server on the local " "machine that will serve documentation to visiting web browsers. :program:" @@ -143,13 +143,13 @@ msgstr "" "HTTP 伺服器,讓你可以用你偏好的網頁瀏覽器在 ``http://localhost:1234/`` 瀏覽文" "件。指定 ``0`` 作為通訊埠編號將會選擇一個任意未使用的通訊埠。" -#: ../../library/pydoc.rst:76 +#: ../../library/pydoc.rst:73 msgid "" "The :mod:`!pydoc` HTTP server is intended for local use during development " "and is not suitable for production use." msgstr "" -#: ../../library/pydoc.rst:79 +#: ../../library/pydoc.rst:76 msgid "" ":program:`python -m pydoc -n ` will start the server listening at " "the given hostname. By default the hostname is 'localhost' but if you want " @@ -162,7 +162,7 @@ msgstr "" "會想改變伺服器回應的主機名稱。在開發期間,如果你想在容器內執行 pydoc,這點特" "別有用。" -#: ../../library/pydoc.rst:85 +#: ../../library/pydoc.rst:82 msgid "" ":program:`python -m pydoc -b` will start the server and additionally open a " "web browser to a module index page. Each served page has a navigation bar " @@ -176,7 +176,7 @@ msgstr "" "*Module index*\\ (模組索引)、*Topics*\\ (主題)和 *Keywords*\\ (關鍵字)" "頁面。" -#: ../../library/pydoc.rst:91 +#: ../../library/pydoc.rst:88 msgid "" "When :program:`pydoc` generates documentation, it uses the current " "environment and path to locate modules. Thus, invoking :program:`pydoc " @@ -187,7 +187,7 @@ msgstr "" "叫 :program:`pydoc spam` 所產生的文件,會完全對應到你啟動 Python 直譯器並輸" "入 ``import spam`` 時所取得的模組版本。" -#: ../../library/pydoc.rst:96 +#: ../../library/pydoc.rst:93 msgid "" "Module docs for core modules are assumed to reside in ``https://docs.python." "org/X.Y/library/`` where ``X`` and ``Y`` are the major and minor version " @@ -200,15 +200,15 @@ msgstr "" "PYTHONDOCS` 環境變數設定為不同的 URL 或包含函式庫參考使用手冊的本機目錄來覆" "寫。" -#: ../../library/pydoc.rst:103 +#: ../../library/pydoc.rst:100 msgid "Added the ``-b`` option." msgstr "新增 ``-b`` 選項。" -#: ../../library/pydoc.rst:106 +#: ../../library/pydoc.rst:103 msgid "The ``-g`` command line option was removed." msgstr "移除 ``-g`` 命令列選項。" -#: ../../library/pydoc.rst:109 +#: ../../library/pydoc.rst:106 msgid "" ":mod:`!pydoc` now uses :func:`inspect.signature` rather than :func:`inspect." "getfullargspec` to extract signature information from callables." @@ -216,22 +216,22 @@ msgstr "" ":mod:`!pydoc` 現在使用 :func:`inspect.signature` 而不是 :func:`inspect." "getfullargspec` 來從可呼叫物件中提取簽章資訊。" -#: ../../library/pydoc.rst:114 +#: ../../library/pydoc.rst:111 msgid "Added the ``-n`` option." msgstr "新增 ``-n`` 選項。" -#: ../../library/pydoc.rst:12 +#: ../../library/pydoc.rst:9 msgid "documentation" msgstr "documentation(文件)" -#: ../../library/pydoc.rst:12 +#: ../../library/pydoc.rst:9 msgid "generation" msgstr "generation(產生)" -#: ../../library/pydoc.rst:12 +#: ../../library/pydoc.rst:9 msgid "online" msgstr "online(線上)" -#: ../../library/pydoc.rst:12 +#: ../../library/pydoc.rst:9 msgid "help" msgstr "help(幫助)" diff --git a/library/pyexpat.po b/library/pyexpat.po index 0e6cd70b568..5709e90be71 100644 --- a/library/pyexpat.po +++ b/library/pyexpat.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-03 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,13 +21,13 @@ msgstr "" msgid ":mod:`!xml.parsers.expat` --- Fast XML parsing using Expat" msgstr ":mod:`!xml.parsers.expat` --- 使用 Expat 進行快速 XML 剖析" -#: ../../library/pyexpat.rst:21 +#: ../../library/pyexpat.rst:19 msgid "" "If you need to parse untrusted or unauthenticated data, see :ref:`xml-" "security`." msgstr "如果你需要剖析不受信任或未經驗證的資料,請參閱 :ref:`xml-security`。" -#: ../../library/pyexpat.rst:27 +#: ../../library/pyexpat.rst:25 msgid "" "The :mod:`!xml.parsers.expat` module is a Python interface to the Expat non-" "validating XML parser. The module provides a single extension type, :class:" @@ -38,44 +38,44 @@ msgid "" "in the XML document." msgstr "" -#: ../../library/pyexpat.rst:37 +#: ../../library/pyexpat.rst:35 msgid "" "This module uses the :mod:`pyexpat` module to provide access to the Expat " "parser. Direct use of the :mod:`pyexpat` module is deprecated." msgstr "" -#: ../../library/pyexpat.rst:40 +#: ../../library/pyexpat.rst:38 msgid "" "This module provides the following exception, type object and data items:" msgstr "這個模組提供以下例外、型別物件和資料項目:" -#: ../../library/pyexpat.rst:45 +#: ../../library/pyexpat.rst:43 msgid "" "The exception raised when Expat reports an error. See section :ref:" "`expaterror-objects` for more information on interpreting Expat errors." msgstr "" -#: ../../library/pyexpat.rst:51 +#: ../../library/pyexpat.rst:49 msgid "Alias for :exc:`ExpatError`." msgstr ":exc:`ExpatError` 的別名。" -#: ../../library/pyexpat.rst:56 +#: ../../library/pyexpat.rst:54 msgid "The type of the return values from the :func:`ParserCreate` function." msgstr "" -#: ../../library/pyexpat.rst:61 +#: ../../library/pyexpat.rst:59 msgid "" "The version string of the Expat library loaded by the interpreter, like " "``'expat_2.8.4'``." msgstr "" -#: ../../library/pyexpat.rst:67 +#: ../../library/pyexpat.rst:65 msgid "" "The version of the Expat library loaded by the interpreter, as a tuple of " "three integers: major, minor and micro version." msgstr "" -#: ../../library/pyexpat.rst:73 +#: ../../library/pyexpat.rst:71 msgid "" "The list of the features with which the loaded Expat library was compiled, " "as ``(name, value)`` pairs. The value is only meaningful for features which " @@ -85,15 +85,15 @@ msgid "" "the name is significant." msgstr "" -#: ../../library/pyexpat.rst:81 +#: ../../library/pyexpat.rst:79 msgid "The :mod:`!xml.parsers.expat` module contains two functions:" msgstr ":mod:`!xml.parsers.expat` 模組包含兩個函式:" -#: ../../library/pyexpat.rst:86 +#: ../../library/pyexpat.rst:84 msgid "Returns an explanatory string for a given error number *errno*." msgstr "回傳一個給定錯誤編號 *errno* 的解釋字串。" -#: ../../library/pyexpat.rst:91 +#: ../../library/pyexpat.rst:89 msgid "" "Creates and returns a new :class:`xmlparser` object. *encoding*, if " "specified, must be a string naming the encoding used by the XML data. " @@ -103,7 +103,7 @@ msgid "" "implicit or explicit encoding of the document." msgstr "" -#: ../../library/pyexpat.rst:100 +#: ../../library/pyexpat.rst:98 msgid "" "Parsers created through :func:`!ParserCreate` are called \"root\" parsers, " "in the sense that they do not have any parent parser attached. Non-root " @@ -111,7 +111,7 @@ msgid "" "ExternalEntityParserCreate>`." msgstr "" -#: ../../library/pyexpat.rst:105 +#: ../../library/pyexpat.rst:103 msgid "" "Expat can optionally do XML namespace processing for you, enabled by " "providing a value for *namespace_separator*. The value must be a one-" @@ -126,13 +126,13 @@ msgid "" "concatenated without any separator." msgstr "" -#: ../../library/pyexpat.rst:117 +#: ../../library/pyexpat.rst:115 msgid "" "For example, if *namespace_separator* is set to a space character (``' '``) " "and the following document is parsed:" msgstr "" -#: ../../library/pyexpat.rst:120 +#: ../../library/pyexpat.rst:118 msgid "" "\n" "\n" "" -#: ../../library/pyexpat.rst:129 +#: ../../library/pyexpat.rst:127 msgid "" ":attr:`StartElementHandler` will receive the following strings for each " "element::" msgstr ":attr:`StartElementHandler` 將會收到每個元素的以下字串: ::" -#: ../../library/pyexpat.rst:132 +#: ../../library/pyexpat.rst:130 msgid "" "http://default-namespace.org/ root\n" "http://www.python.org/ns/ elem1\n" @@ -164,14 +164,14 @@ msgstr "" "http://www.python.org/ns/ elem1\n" "elem2" -#: ../../library/pyexpat.rst:136 +#: ../../library/pyexpat.rst:134 msgid "" "*intern*, if given, must be a dictionary. It is used to intern the names of " "elements and attributes, and is available as the :attr:`~xmlparser.intern` " "attribute. By default a new empty dictionary is created for every parser." msgstr "" -#: ../../library/pyexpat.rst:141 +#: ../../library/pyexpat.rst:139 msgid "" "Due to limitations in the ``Expat`` library used by :mod:`pyexpat`, the :" "class:`xmlparser` instance returned can only be used to parse a single XML " @@ -179,23 +179,23 @@ msgid "" "instances." msgstr "" -#: ../../library/pyexpat.rst:149 +#: ../../library/pyexpat.rst:147 msgid "`The Expat XML Parser `_" msgstr "`Expat XML 剖析器 `_" -#: ../../library/pyexpat.rst:150 +#: ../../library/pyexpat.rst:148 msgid "Home page of the Expat project." msgstr "Expat 專案的首頁。" -#: ../../library/pyexpat.rst:156 +#: ../../library/pyexpat.rst:154 msgid "XMLParser Objects" msgstr "XMLParser 物件" -#: ../../library/pyexpat.rst:158 +#: ../../library/pyexpat.rst:156 msgid ":class:`xmlparser` objects have the following methods:" msgstr ":class:`xmlparser` 物件擁有以下方法:" -#: ../../library/pyexpat.rst:163 +#: ../../library/pyexpat.rst:161 msgid "" "Parses the contents of *data*, calling the appropriate handler functions to " "process the parsed data. *data* can be a :term:`bytes-like object` or a " @@ -206,7 +206,7 @@ msgid "" "at any time." msgstr "" -#: ../../library/pyexpat.rst:176 +#: ../../library/pyexpat.rst:174 msgid "" "Parse XML data reading from the object *file*. *file* only needs to provide " "the ``read(nbytes)`` method, which returns bytes, and an empty bytes object " @@ -214,7 +214,7 @@ msgid "" "for data which is already decoded." msgstr "" -#: ../../library/pyexpat.rst:185 +#: ../../library/pyexpat.rst:183 msgid "" "Sets the base to be used for resolving relative URIs in system identifiers " "in declarations. Resolving relative identifiers is left to the application: " @@ -223,13 +223,13 @@ msgid "" "`UnparsedEntityDeclHandler` functions." msgstr "" -#: ../../library/pyexpat.rst:194 +#: ../../library/pyexpat.rst:192 msgid "" "Returns a string containing the base set by a previous call to :meth:" "`SetBase`, or ``None`` if :meth:`SetBase` hasn't been called." msgstr "" -#: ../../library/pyexpat.rst:200 +#: ../../library/pyexpat.rst:198 msgid "" "Returns the input data which generated the current event as a :class:`bytes` " "object. The data is in the encoding of the entity which contains the text. " @@ -239,7 +239,7 @@ msgid "" "called while an event handler is not active, the return value is ``None``." msgstr "" -#: ../../library/pyexpat.rst:213 +#: ../../library/pyexpat.rst:211 msgid "" "Create a \"child\" parser which can be used to parse an external parsed " "entity referred to by content parsed by the parent parser. The *context* " @@ -249,7 +249,7 @@ msgid "" "`specified_attributes` set to the values of this parser." msgstr "" -#: ../../library/pyexpat.rst:222 +#: ../../library/pyexpat.rst:220 msgid "" "Control parsing of parameter entities (including the external DTD subset). " "Possible *flag* values are :const:`XML_PARAM_ENTITY_PARSING_NEVER`, :const:" @@ -258,7 +258,7 @@ msgid "" "successful." msgstr "" -#: ../../library/pyexpat.rst:230 +#: ../../library/pyexpat.rst:228 msgid "" "Calling this with a true value for *flag* (the default) will cause Expat to " "call the :attr:`ExternalEntityRefHandler` with :const:`None` for all " @@ -268,13 +268,13 @@ msgid "" "`EndDoctypeDeclHandler` will not be called." msgstr "" -#: ../../library/pyexpat.rst:237 +#: ../../library/pyexpat.rst:235 msgid "" "Passing a false value for *flag* will cancel a previous call that passed a " "true value, but otherwise has no effect." msgstr "" -#: ../../library/pyexpat.rst:240 +#: ../../library/pyexpat.rst:238 msgid "" "This method can only be called before the :meth:`Parse` or :meth:`ParseFile` " "methods are called; calling it after either of those have been called " @@ -282,14 +282,14 @@ msgid "" "``errors.codes[errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING]``." msgstr "" -#: ../../library/pyexpat.rst:249 +#: ../../library/pyexpat.rst:247 msgid "" "Calling ``SetReparseDeferralEnabled(False)`` has security implications, as " "detailed below; please make sure to understand these consequences prior to " "using the ``SetReparseDeferralEnabled`` method." msgstr "" -#: ../../library/pyexpat.rst:253 +#: ../../library/pyexpat.rst:251 msgid "" "Expat 2.6.0 introduced a security mechanism called \"reparse deferral\" " "where instead of causing denial of service through quadratic runtime from " @@ -304,64 +304,71 @@ msgid "" "``SetReparseDeferralEnabled(True)`` allows re-enabling reparse deferral." msgstr "" -#: ../../library/pyexpat.rst:266 +#: ../../library/pyexpat.rst:264 msgid "" -"Note that :meth:`SetReparseDeferralEnabled` has been backported to some " -"prior releases of CPython as a security fix. Check for availability of :" -"meth:`SetReparseDeferralEnabled` using :func:`hasattr` if used in code " -"running across a variety of Python versions." +":meth:`!SetReparseDeferralEnabled` has been backported to some prior " +"releases of CPython as a security fix. Check for availability using :func:" +"`hasattr` if used in code running across a variety of Python versions." msgstr "" -#: ../../library/pyexpat.rst:275 +#: ../../library/pyexpat.rst:273 msgid "" "Returns whether reparse deferral is currently enabled for the given Expat " "parser instance." msgstr "" -#: ../../library/pyexpat.rst:281 +#: ../../library/pyexpat.rst:279 msgid "" ":class:`!xmlparser` objects have the following methods to tune protections " "against some common XML vulnerabilities." msgstr ":class:`!xmlparser` 物件擁有以下方法來調整對一些常見 XML 漏洞的防護。" -#: ../../library/pyexpat.rst:286 +#: ../../library/pyexpat.rst:284 msgid "" "Sets the number of output bytes needed to activate protection against " "`billion laughs`_ attacks." msgstr "" -#: ../../library/pyexpat.rst:289 +#: ../../library/pyexpat.rst:287 msgid "" "The number of output bytes includes amplification from entity expansion and " "reading DTD files." msgstr "" -#: ../../library/pyexpat.rst:292 +#: ../../library/pyexpat.rst:290 msgid "" "Parser objects usually have a protection activation threshold of 8 MiB, but " "the actual default value depends on the underlying Expat library." msgstr "" -#: ../../library/pyexpat.rst:295 ../../library/pyexpat.rst:347 +#: ../../library/pyexpat.rst:293 ../../library/pyexpat.rst:355 msgid "" "An :exc:`ExpatError` is raised if this method is called on a |xml-non-root-" "parser| parser. The corresponding :attr:`~ExpatError.lineno` and :attr:" "`~ExpatError.offset` should not be used as they may have no special meaning." msgstr "" -#: ../../library/pyexpat.rst:302 +#: ../../library/pyexpat.rst:298 +msgid "" +":meth:`!SetBillionLaughsAttackProtectionActivationThreshold` has been " +"backported to some prior releases of CPython as a security fix. Check for " +"availability using :func:`hasattr` if used in code running across a variety " +"of Python versions." +msgstr "" + +#: ../../library/pyexpat.rst:305 msgid "" "Activation thresholds below 4 MiB are known to break support for DITA 1.3 " "payload and are hence not recommended." msgstr "" -#: ../../library/pyexpat.rst:309 +#: ../../library/pyexpat.rst:312 msgid "" "Sets the maximum tolerated amplification factor for protection against " "`billion laughs`_ attacks." msgstr "" -#: ../../library/pyexpat.rst:312 +#: ../../library/pyexpat.rst:315 msgid "" "The amplification factor is calculated as ``(direct + indirect) / direct`` " "while parsing, where ``direct`` is the number of bytes read from the primary " @@ -369,7 +376,7 @@ msgid "" "expanding entities and reading of external DTD files." msgstr "" -#: ../../library/pyexpat.rst:317 +#: ../../library/pyexpat.rst:320 msgid "" "The *max_factor* value must be a non-NaN :class:`float` value greater than " "or equal to 1.0. Peak amplifications of factor 15,000 for the entire payload " @@ -378,13 +385,13 @@ msgid "" "carefully chosen to avoid false positives." msgstr "" -#: ../../library/pyexpat.rst:323 ../../library/pyexpat.rst:369 +#: ../../library/pyexpat.rst:326 ../../library/pyexpat.rst:382 msgid "" "Parser objects usually have a maximum amplification factor of 100, but the " "actual default value depends on the underlying Expat library." msgstr "" -#: ../../library/pyexpat.rst:326 ../../library/pyexpat.rst:372 +#: ../../library/pyexpat.rst:329 ../../library/pyexpat.rst:385 msgid "" "An :exc:`ExpatError` is raised if this method is called on a |xml-non-root-" "parser| parser or if *max_factor* is outside the valid range. The " @@ -392,32 +399,47 @@ msgid "" "should not be used as they may have no special meaning." msgstr "" -#: ../../library/pyexpat.rst:333 +#: ../../library/pyexpat.rst:334 +msgid "" +":meth:`!SetBillionLaughsAttackProtectionMaximumAmplification` has been " +"backported to some prior releases of CPython as a security fix. Check for " +"availability using :func:`hasattr` if used in code running across a variety " +"of Python versions." +msgstr "" + +#: ../../library/pyexpat.rst:341 msgid "" "The maximum amplification factor is only considered if the threshold that " "can be adjusted by :meth:`." "SetBillionLaughsAttackProtectionActivationThreshold` is exceeded." msgstr "" -#: ../../library/pyexpat.rst:341 +#: ../../library/pyexpat.rst:349 msgid "" "Sets the number of allocated bytes of dynamic memory needed to activate " "protection against disproportionate use of RAM." msgstr "" -#: ../../library/pyexpat.rst:344 +#: ../../library/pyexpat.rst:352 msgid "" "Parser objects usually have an allocation activation threshold of 64 MiB, " "but the actual default value depends on the underlying Expat library." msgstr "" -#: ../../library/pyexpat.rst:356 +#: ../../library/pyexpat.rst:360 +msgid "" +":meth:`!SetAllocTrackerActivationThreshold` has been backported to some " +"prior releases of CPython as a security fix. Check for availability using :" +"func:`hasattr` if used in code running across a variety of Python versions." +msgstr "" + +#: ../../library/pyexpat.rst:369 msgid "" "Sets the maximum amplification factor between direct input and bytes of " "dynamic memory allocated." msgstr "" -#: ../../library/pyexpat.rst:359 +#: ../../library/pyexpat.rst:372 msgid "" "The amplification factor is calculated as ``allocated / direct`` while " "parsing, where ``direct`` is the number of bytes read from the primary " @@ -425,7 +447,7 @@ msgid "" "memory allocated in the parser hierarchy." msgstr "" -#: ../../library/pyexpat.rst:364 +#: ../../library/pyexpat.rst:377 msgid "" "The *max_factor* value must be a non-NaN :class:`float` value greater than " "or equal to 1.0. Amplification factors greater than 100.0 can be observed " @@ -433,24 +455,31 @@ msgid "" "the activation threshold should be carefully chosen to avoid false positives." msgstr "" -#: ../../library/pyexpat.rst:379 +#: ../../library/pyexpat.rst:390 +msgid "" +":meth:`!SetAllocTrackerMaximumAmplification` has been backported to some " +"prior releases of CPython as a security fix. Check for availability using :" +"func:`hasattr` if used in code running across a variety of Python versions." +msgstr "" + +#: ../../library/pyexpat.rst:397 msgid "" "The maximum amplification factor is only considered if the threshold that " "can be adjusted by :meth:`.SetAllocTrackerActivationThreshold` is exceeded." msgstr "" -#: ../../library/pyexpat.rst:386 +#: ../../library/pyexpat.rst:404 msgid ":class:`xmlparser` objects have the following attributes:" msgstr ":class:`xmlparser` 物件擁有以下屬性:" -#: ../../library/pyexpat.rst:391 +#: ../../library/pyexpat.rst:409 msgid "" "The size of the buffer used when :attr:`buffer_text` is true. A new buffer " "size can be set by assigning a new integer value to this attribute. When the " "size is changed, the buffer will be flushed." msgstr "" -#: ../../library/pyexpat.rst:399 +#: ../../library/pyexpat.rst:417 msgid "" "Setting this to true causes the :class:`xmlparser` object to buffer textual " "content returned by Expat to avoid multiple calls to the :meth:" @@ -461,14 +490,14 @@ msgid "" "newlines may be chunked too." msgstr "" -#: ../../library/pyexpat.rst:410 +#: ../../library/pyexpat.rst:428 msgid "" "If :attr:`buffer_text` is enabled, the number of bytes stored in the buffer. " "These bytes represent UTF-8 encoded text. This attribute has no meaningful " "interpretation when :attr:`buffer_text` is false." msgstr "" -#: ../../library/pyexpat.rst:417 +#: ../../library/pyexpat.rst:435 msgid "" "Setting this attribute to a non-zero integer causes the attributes to be " "reported as a list rather than a dictionary. The attributes are presented " @@ -478,7 +507,7 @@ msgid "" "is false; it may be changed at any time." msgstr "" -#: ../../library/pyexpat.rst:427 +#: ../../library/pyexpat.rst:445 msgid "" "If set to a non-zero integer, the parser will report only those attributes " "which were specified in the document instance and not those which were " @@ -489,14 +518,14 @@ msgid "" "time." msgstr "" -#: ../../library/pyexpat.rst:437 +#: ../../library/pyexpat.rst:455 msgid "" "The dictionary used to intern the names of elements and attributes. It is " "either the dictionary passed as the *intern* argument of :func:" "`ParserCreate`, or a new dictionary created for this parser." msgstr "" -#: ../../library/pyexpat.rst:444 +#: ../../library/pyexpat.rst:462 msgid "" "If set to a true value, and namespace processing is enabled, the namespace " "prefix is reported as the third part of the expanded name, separated by the " @@ -504,7 +533,7 @@ msgid "" "default, this attribute is false; it may be changed at any time." msgstr "" -#: ../../library/pyexpat.rst:451 +#: ../../library/pyexpat.rst:469 msgid "" "The following attributes contain values relating to the most recent error " "encountered by an :class:`xmlparser` object, and will only have correct " @@ -512,26 +541,26 @@ msgid "" "`xml.parsers.expat.ExpatError` exception." msgstr "" -#: ../../library/pyexpat.rst:459 +#: ../../library/pyexpat.rst:477 msgid "Byte index at which an error occurred." msgstr "" -#: ../../library/pyexpat.rst:464 +#: ../../library/pyexpat.rst:482 msgid "" "Numeric code specifying the problem. This value can be passed to the :func:" "`ErrorString` function, or compared to one of the constants defined in the " "``errors`` object." msgstr "" -#: ../../library/pyexpat.rst:471 +#: ../../library/pyexpat.rst:489 msgid "Column number at which an error occurred." msgstr "" -#: ../../library/pyexpat.rst:476 +#: ../../library/pyexpat.rst:494 msgid "Line number at which an error occurred." msgstr "" -#: ../../library/pyexpat.rst:478 +#: ../../library/pyexpat.rst:496 msgid "" "The following attributes contain values relating to the current parse " "location in an :class:`xmlparser` object. During a callback reporting a " @@ -541,19 +570,19 @@ msgid "" "whether there was an associated callback)." msgstr "" -#: ../../library/pyexpat.rst:488 +#: ../../library/pyexpat.rst:506 msgid "Current byte index in the parser input." msgstr "" -#: ../../library/pyexpat.rst:493 +#: ../../library/pyexpat.rst:511 msgid "Current column number in the parser input." msgstr "" -#: ../../library/pyexpat.rst:498 +#: ../../library/pyexpat.rst:516 msgid "Current line number in the parser input." msgstr "" -#: ../../library/pyexpat.rst:500 +#: ../../library/pyexpat.rst:518 msgid "" "Here is the list of handlers that can be set. To set a handler on an :class:" "`xmlparser` object *o*, use ``o.handlername = func``. *handlername* must be " @@ -562,7 +591,7 @@ msgid "" "unless otherwise stated." msgstr "" -#: ../../library/pyexpat.rst:509 +#: ../../library/pyexpat.rst:527 msgid "" "Called when the XML declaration is parsed. The XML declaration is the " "(optional) declaration of the applicable version of the XML recommendation, " @@ -572,7 +601,7 @@ msgid "" "to be standalone, or ``-1`` if the standalone clause was omitted." msgstr "" -#: ../../library/pyexpat.rst:519 +#: ../../library/pyexpat.rst:537 msgid "" "Called when Expat begins parsing the document type declaration (``'``." msgstr "" -#: ../../library/pyexpat.rst:637 +#: ../../library/pyexpat.rst:655 msgid "" "Called at the start of a CDATA section. This and :attr:" "`EndCdataSectionHandler` are needed to be able to identify the syntactical " "start and end for CDATA sections." msgstr "" -#: ../../library/pyexpat.rst:644 +#: ../../library/pyexpat.rst:662 msgid "Called at the end of a CDATA section." msgstr "在 CDATA 區塊結束時呼叫。" -#: ../../library/pyexpat.rst:649 +#: ../../library/pyexpat.rst:667 msgid "" "Called for any characters in the XML document for which no applicable " "handler has been specified. This means characters that are part of a " @@ -703,14 +732,14 @@ msgid "" "supplied." msgstr "" -#: ../../library/pyexpat.rst:656 +#: ../../library/pyexpat.rst:674 msgid "" "This is the same as the :attr:`DefaultHandler`, but doesn't inhibit " "expansion of internal entities. The entity reference will not be passed to " "the default handler." msgstr "" -#: ../../library/pyexpat.rst:663 +#: ../../library/pyexpat.rst:681 msgid "" "Called if the XML document hasn't been declared as being a standalone " "document. This happens when there is an external subset or a reference to a " @@ -720,7 +749,7 @@ msgid "" "set, no exception is raised by the parser for this condition." msgstr "" -#: ../../library/pyexpat.rst:675 +#: ../../library/pyexpat.rst:693 msgid "" "Implementing a handler that accesses local files and/or the network may " "create a vulnerability to `external entity attacks `_ before implementing this handler." msgstr "" -#: ../../library/pyexpat.rst:682 +#: ../../library/pyexpat.rst:700 msgid "" "Called for references to external entities. *base* is the current base, as " "set by a previous call to :meth:`SetBase`. The public and system " @@ -738,7 +767,7 @@ msgid "" "is opaque and should only be used as described below." msgstr "" -#: ../../library/pyexpat.rst:688 +#: ../../library/pyexpat.rst:706 msgid "" "For external entities to be parsed, this handler must be implemented. It is " "responsible for creating the sub-parser using " @@ -748,13 +777,13 @@ msgid "" "`XML_ERROR_EXTERNAL_ENTITY_HANDLING` error, otherwise parsing will continue." msgstr "" -#: ../../library/pyexpat.rst:696 +#: ../../library/pyexpat.rst:714 msgid "" "If this handler is not provided, external entities are reported by the :attr:" "`DefaultHandler` callback, if provided." msgstr "" -#: ../../library/pyexpat.rst:702 +#: ../../library/pyexpat.rst:720 msgid "" "Called for entity references which are not expanded, because the parser did " "not read the declaration of the entity. This happens when the external DTD " @@ -762,22 +791,22 @@ msgid "" "is true for a parameter entity and false for a general entity." msgstr "" -#: ../../library/pyexpat.rst:713 +#: ../../library/pyexpat.rst:731 msgid "ExpatError Exceptions" msgstr "ExpatError 例外" -#: ../../library/pyexpat.rst:718 +#: ../../library/pyexpat.rst:733 msgid ":exc:`ExpatError` exceptions have a number of interesting attributes:" msgstr "" -#: ../../library/pyexpat.rst:723 +#: ../../library/pyexpat.rst:738 msgid "" "Expat's internal error number for the specific error. The :data:`errors." "messages ` dictionary maps these error " "numbers to Expat's error messages. For example::" msgstr "" -#: ../../library/pyexpat.rst:727 +#: ../../library/pyexpat.rst:742 msgid "" "from xml.parsers.expat import ParserCreate, ExpatError, errors\n" "\n" @@ -795,36 +824,36 @@ msgstr "" "except ExpatError as err:\n" " print(\"Error:\", errors.messages[err.code])" -#: ../../library/pyexpat.rst:735 +#: ../../library/pyexpat.rst:750 msgid "" "The :mod:`~xml.parsers.expat.errors` module also provides error message " "constants and a dictionary :data:`~xml.parsers.expat.errors.codes` mapping " "these messages back to the error codes, see below." msgstr "" -#: ../../library/pyexpat.rst:742 +#: ../../library/pyexpat.rst:757 msgid "" "Line number on which the error was detected. The first line is numbered " "``1``." msgstr "" -#: ../../library/pyexpat.rst:747 +#: ../../library/pyexpat.rst:762 msgid "" "Character offset into the line where the error occurred. The first column " "is numbered ``0``." msgstr "" -#: ../../library/pyexpat.rst:754 +#: ../../library/pyexpat.rst:769 msgid "Example" msgstr "範例" -#: ../../library/pyexpat.rst:756 +#: ../../library/pyexpat.rst:771 msgid "" "The following program defines three handlers that just print out their " "arguments. ::" msgstr "" -#: ../../library/pyexpat.rst:759 +#: ../../library/pyexpat.rst:774 msgid "" "import xml.parsers.expat\n" "\n" @@ -868,11 +897,11 @@ msgstr "" "More text\n" "\"\"\", 1)" -#: ../../library/pyexpat.rst:780 +#: ../../library/pyexpat.rst:795 msgid "The output from this program is::" msgstr "這個程式的輸出是: ::" -#: ../../library/pyexpat.rst:782 +#: ../../library/pyexpat.rst:797 msgid "" "Start element: parent {'id': 'top'}\n" "Start element: child1 {'name': 'paul'}\n" @@ -896,87 +925,87 @@ msgstr "" "Character data: '\\n'\n" "End element: parent" -#: ../../library/pyexpat.rst:797 +#: ../../library/pyexpat.rst:812 msgid "Content Model Descriptions" msgstr "" -#: ../../library/pyexpat.rst:803 +#: ../../library/pyexpat.rst:816 msgid "" "Content models are described using nested tuples. Each tuple contains four " "values: the type, the quantifier, the name, and a tuple of children. " "Children are simply additional content model descriptions." msgstr "" -#: ../../library/pyexpat.rst:807 +#: ../../library/pyexpat.rst:820 msgid "" "The values of the first two fields are constants defined in the :mod:`!xml." "parsers.expat.model` module. These constants can be collected in two " "groups: the model type group and the quantifier group." msgstr "" -#: ../../library/pyexpat.rst:811 +#: ../../library/pyexpat.rst:824 msgid "The constants in the model type group are:" msgstr "" -#: ../../library/pyexpat.rst:816 +#: ../../library/pyexpat.rst:829 msgid "" "The element named by the model name was declared to have a content model of " "``ANY``." msgstr "" -#: ../../library/pyexpat.rst:822 +#: ../../library/pyexpat.rst:835 msgid "" "The named element allows a choice from a number of options; this is used for " "content models such as ``(A | B | C)``." msgstr "" -#: ../../library/pyexpat.rst:828 +#: ../../library/pyexpat.rst:841 msgid "Elements which are declared to be ``EMPTY`` have this model type." msgstr "" -#: ../../library/pyexpat.rst:833 +#: ../../library/pyexpat.rst:846 msgid "" "The named element allows character data, optionally interspersed with the " "named children; this is used for content models such as ``(#PCDATA)`` and " "``(#PCDATA | A | B)*``." msgstr "" -#: ../../library/pyexpat.rst:840 +#: ../../library/pyexpat.rst:853 msgid "The model names a single element, as for ``A``." msgstr "" -#: ../../library/pyexpat.rst:845 +#: ../../library/pyexpat.rst:858 msgid "" "Models which represent a series of models which follow one after the other " "are indicated with this model type. This is used for models such as ``(A, " "B, C)``." msgstr "" -#: ../../library/pyexpat.rst:848 +#: ../../library/pyexpat.rst:861 msgid "The constants in the quantifier group are:" msgstr "" -#: ../../library/pyexpat.rst:853 +#: ../../library/pyexpat.rst:866 msgid "No modifier is given, so it can appear exactly once, as for ``A``." msgstr "" -#: ../../library/pyexpat.rst:858 +#: ../../library/pyexpat.rst:871 msgid "The model is optional: it can appear once or not at all, as for ``A?``." msgstr "" -#: ../../library/pyexpat.rst:863 +#: ../../library/pyexpat.rst:876 msgid "The model must occur one or more times (like ``A+``)." msgstr "" -#: ../../library/pyexpat.rst:868 +#: ../../library/pyexpat.rst:881 msgid "The model must occur zero or more times, as for ``A*``." msgstr "" -#: ../../library/pyexpat.rst:874 +#: ../../library/pyexpat.rst:887 msgid "Expat error constants" msgstr "Expat 錯誤常數" -#: ../../library/pyexpat.rst:878 +#: ../../library/pyexpat.rst:891 msgid "" "The following constants are provided in the :mod:`!xml.parsers.expat.errors` " "module. These constants are useful in interpreting some of the attributes " @@ -987,210 +1016,210 @@ msgid "" "XML_ERROR_{CONSTANT_NAME}]`." msgstr "" -#: ../../library/pyexpat.rst:886 +#: ../../library/pyexpat.rst:899 msgid "The ``errors`` module has the following attributes:" msgstr "``errors`` 模組有以下屬性:" -#: ../../library/pyexpat.rst:890 +#: ../../library/pyexpat.rst:903 msgid "A dictionary mapping string descriptions to their error codes." msgstr "" -#: ../../library/pyexpat.rst:897 +#: ../../library/pyexpat.rst:910 msgid "A dictionary mapping numeric error codes to their string descriptions." msgstr "" -#: ../../library/pyexpat.rst:907 +#: ../../library/pyexpat.rst:920 msgid "" "An entity reference in an attribute value referred to an external entity " "instead of an internal entity." msgstr "" -#: ../../library/pyexpat.rst:913 +#: ../../library/pyexpat.rst:926 msgid "" "A character reference referred to a character which is illegal in XML (for " "example, character ``0``, or '``�``')." msgstr "" -#: ../../library/pyexpat.rst:919 +#: ../../library/pyexpat.rst:932 msgid "" "An entity reference referred to an entity which was declared with a " "notation, so cannot be parsed." msgstr "" -#: ../../library/pyexpat.rst:925 +#: ../../library/pyexpat.rst:938 msgid "An attribute was used more than once in a start tag." msgstr "" -#: ../../library/pyexpat.rst:933 +#: ../../library/pyexpat.rst:946 msgid "" "Raised when an input byte could not properly be assigned to a character; for " "example, a NUL byte (value ``0``) in a UTF-8 input stream." msgstr "" -#: ../../library/pyexpat.rst:939 +#: ../../library/pyexpat.rst:952 msgid "Something other than whitespace occurred after the document element." msgstr "" -#: ../../library/pyexpat.rst:944 +#: ../../library/pyexpat.rst:957 msgid "" "An XML declaration was found somewhere other than the start of the input " "data." msgstr "" -#: ../../library/pyexpat.rst:949 +#: ../../library/pyexpat.rst:962 msgid "" "The document contains no elements (XML requires all documents to contain " "exactly one top-level element)." msgstr "" -#: ../../library/pyexpat.rst:955 +#: ../../library/pyexpat.rst:968 msgid "Expat was not able to allocate memory internally." msgstr "" -#: ../../library/pyexpat.rst:960 +#: ../../library/pyexpat.rst:973 msgid "A parameter entity reference was found where it was not allowed." msgstr "" -#: ../../library/pyexpat.rst:965 +#: ../../library/pyexpat.rst:978 msgid "An incomplete character was found in the input." msgstr "" -#: ../../library/pyexpat.rst:970 +#: ../../library/pyexpat.rst:983 msgid "" "An entity reference contained another reference to the same entity; possibly " "via a different name, and possibly indirectly." msgstr "" -#: ../../library/pyexpat.rst:976 +#: ../../library/pyexpat.rst:989 msgid "Some unspecified syntax error was encountered." msgstr "" -#: ../../library/pyexpat.rst:981 +#: ../../library/pyexpat.rst:994 msgid "An end tag did not match the innermost open start tag." msgstr "" -#: ../../library/pyexpat.rst:986 +#: ../../library/pyexpat.rst:999 msgid "" "Some token (such as a start tag) was not closed before the end of the stream " "or the next token was encountered." msgstr "" -#: ../../library/pyexpat.rst:992 +#: ../../library/pyexpat.rst:1005 msgid "A reference was made to an entity which was not defined." msgstr "" -#: ../../library/pyexpat.rst:997 +#: ../../library/pyexpat.rst:1010 msgid "The document encoding is not supported by Expat." msgstr "" -#: ../../library/pyexpat.rst:1002 +#: ../../library/pyexpat.rst:1015 msgid "A CDATA marked section was not closed." msgstr "以 CDATA 標記的區塊未被關閉。" -#: ../../library/pyexpat.rst:1010 +#: ../../library/pyexpat.rst:1023 msgid "" "The parser determined that the document was not \"standalone\" though it " "declared itself to be in the XML declaration, and the :attr:" "`NotStandaloneHandler` was set and returned ``0``." msgstr "" -#: ../../library/pyexpat.rst:1023 +#: ../../library/pyexpat.rst:1036 msgid "" "An operation was requested that requires DTD support to be compiled in, but " "Expat was configured without DTD support. This should never be reported by " "a standard build of the :mod:`!xml.parsers.expat` module." msgstr "" -#: ../../library/pyexpat.rst:1030 +#: ../../library/pyexpat.rst:1043 msgid "" "A behavioral change was requested after parsing started that can only be " "changed before parsing has started. This is (currently) only raised by :" "meth:`UseForeignDTD`." msgstr "" -#: ../../library/pyexpat.rst:1037 +#: ../../library/pyexpat.rst:1050 msgid "An undeclared prefix was found when namespace processing was enabled." msgstr "" -#: ../../library/pyexpat.rst:1042 +#: ../../library/pyexpat.rst:1055 msgid "" "The document attempted to remove the namespace declaration associated with a " "prefix." msgstr "" -#: ../../library/pyexpat.rst:1048 +#: ../../library/pyexpat.rst:1061 msgid "A parameter entity contained incomplete markup." msgstr "" -#: ../../library/pyexpat.rst:1053 +#: ../../library/pyexpat.rst:1066 msgid "There was an error parsing the XML declaration." msgstr "" -#: ../../library/pyexpat.rst:1058 +#: ../../library/pyexpat.rst:1071 msgid "There was an error parsing a text declaration in an external entity." msgstr "" -#: ../../library/pyexpat.rst:1063 +#: ../../library/pyexpat.rst:1076 msgid "Characters were found in the public id that are not allowed." msgstr "" -#: ../../library/pyexpat.rst:1068 +#: ../../library/pyexpat.rst:1081 msgid "" "The requested operation was made on a suspended parser, but isn't allowed. " "This includes attempts to provide additional input or to stop the parser." msgstr "" -#: ../../library/pyexpat.rst:1074 +#: ../../library/pyexpat.rst:1087 msgid "" "An attempt to resume the parser was made when the parser had not been " "suspended." msgstr "" -#: ../../library/pyexpat.rst:1079 ../../library/pyexpat.rst:1112 -#: ../../library/pyexpat.rst:1117 +#: ../../library/pyexpat.rst:1092 ../../library/pyexpat.rst:1125 +#: ../../library/pyexpat.rst:1130 msgid "This should not be reported to Python applications." msgstr "" -#: ../../library/pyexpat.rst:1084 +#: ../../library/pyexpat.rst:1097 msgid "" "The requested operation was made on a parser which was finished parsing " "input, but isn't allowed. This includes attempts to provide additional " "input or to stop the parser." msgstr "" -#: ../../library/pyexpat.rst:1094 +#: ../../library/pyexpat.rst:1107 msgid "" "An attempt was made to undeclare reserved namespace prefix ``xml`` or to " "bind it to another namespace URI." msgstr "" -#: ../../library/pyexpat.rst:1101 +#: ../../library/pyexpat.rst:1114 msgid "" "An attempt was made to declare or undeclare reserved namespace prefix " "``xmlns``." msgstr "" -#: ../../library/pyexpat.rst:1106 +#: ../../library/pyexpat.rst:1119 msgid "" "An attempt was made to bind the URI of one the reserved namespace prefixes " "``xml`` and ``xmlns`` to another namespace prefix." msgstr "" -#: ../../library/pyexpat.rst:1122 +#: ../../library/pyexpat.rst:1135 msgid "" "The limit on input amplification factor (from DTD and entities) has been " "breached." msgstr "" -#: ../../library/pyexpat.rst:1128 +#: ../../library/pyexpat.rst:1141 msgid "The parser was tried to be stopped or suspended before it started." msgstr "" -#: ../../library/pyexpat.rst:1134 +#: ../../library/pyexpat.rst:1147 msgid "Footnotes" msgstr "註腳" -#: ../../library/pyexpat.rst:1135 +#: ../../library/pyexpat.rst:1148 msgid "" "The encoding string included in XML output should conform to the appropriate " "standards. For example, \"UTF-8\" is valid, but \"UTF8\" is not. See https://" @@ -1198,14 +1227,14 @@ msgid "" "org/assignments/character-sets/character-sets.xhtml." msgstr "" -#: ../../library/pyexpat.rst:25 +#: ../../library/pyexpat.rst:23 msgid "Expat" msgstr "Expat" -#: ../../library/pyexpat.rst:35 +#: ../../library/pyexpat.rst:33 msgid "module" msgstr "module(模組)" -#: ../../library/pyexpat.rst:35 +#: ../../library/pyexpat.rst:33 msgid "pyexpat" msgstr "pyexpat" diff --git a/library/random.po b/library/random.po index a2214cde561..cef6bd6e912 100644 --- a/library/random.po +++ b/library/random.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-03-07 19:17+0800\n" "Last-Translator: Dr.XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1096,12 +1096,13 @@ msgstr "使用方案" #: ../../library/random.rst:632 msgid "" "These recipes show how to efficiently make random selections from the " -"combinatoric iterators in the :mod:`itertools` module:" +"combinatoric iterators in the :mod:`itertools` module or the :pypi:`more-" +"itertools` project:" msgstr "" -"這些使用方案展示了如何有效地從 :mod:`itertools` 模組的組合疊代器 " -"(combinatoric iterators) 中進行隨機選擇:" +"這些使用方案展示了如何有效地從 :mod:`itertools` 模組或 :pypi:`more-" +"itertools` 專案的組合疊代器 (combinatoric iterators) 中進行隨機選擇:" -#: ../../library/random.rst:635 +#: ../../library/random.rst:636 msgid "" "import random\n" "\n" @@ -1190,7 +1191,7 @@ msgstr "" " if all(p != q for p, q in zip(start, perm)):\n" " return tuple([seq[i] for i in perm])" -#: ../../library/random.rst:750 +#: ../../library/random.rst:751 msgid "" "The default :func:`.random` returns multiples of 2⁻⁵³ in the range *0.0 ≤ x " "< 1.0*. All such numbers are evenly spaced and are exactly representable as " @@ -1202,7 +1203,7 @@ msgstr "" "均勻分佈的,並且可以完全表示為 Python float。但是,該間隔中的許多其他可表示" "的 float 不是可能的選擇。 例如 ``0.05954861408025609`` 不是 2⁻⁵³ 的整數倍。" -#: ../../library/random.rst:756 +#: ../../library/random.rst:757 msgid "" "The following recipe takes a different approach. All floats in the interval " "are possible selections. The mantissa comes from a uniform distribution of " @@ -1214,7 +1215,7 @@ msgstr "" "數 < 2⁵³* 範圍內的整數均勻分佈。指數來自幾何分佈,其中小於 *-53* 的指數的出現" "頻率是下一個較大指數的一半。" -#: ../../library/random.rst:764 +#: ../../library/random.rst:765 msgid "" "from random import Random\n" "from math import ldexp\n" @@ -1244,7 +1245,7 @@ msgstr "" " exponent += x.bit_length() - 32\n" " return ldexp(mantissa, exponent)" -#: ../../library/random.rst:778 +#: ../../library/random.rst:779 msgid "" "All :ref:`real valued distributions ` in the " "class will use the new method::" @@ -1252,7 +1253,7 @@ msgstr "" "Class 中的所有\\ :ref:`實數分佈 `\\ 都將使用新方" "法: ::" -#: ../../library/random.rst:781 +#: ../../library/random.rst:782 msgid "" ">>> fr = FullRandom()\n" ">>> fr.random()\n" @@ -1266,7 +1267,7 @@ msgstr "" ">>> fr.expovariate(0.25)\n" "8.87925541791544" -#: ../../library/random.rst:787 +#: ../../library/random.rst:788 msgid "" "The recipe is conceptually equivalent to an algorithm that chooses from all " "the multiples of 2⁻¹⁰⁷⁴ in the range *0.0 ≤ x < 1.0*. All such numbers are " @@ -1279,7 +1280,7 @@ msgstr "" "示的 Python float。(2⁻¹⁰⁷⁴ 是最小為正的非正規化 float,等於 ``math." "ulp(0.0)``)" -#: ../../library/random.rst:796 +#: ../../library/random.rst:797 msgid "" "`Generating Pseudo-random Floating-Point Values `_ a paper by Allen B. Downey describing " @@ -1290,68 +1291,68 @@ msgstr "" "pdf>`_ Allen B. Downey 的一篇論文描述了產生比通常由 :func:`.random` 產生的 " "float 更 fine-grained(細粒的)的方法。" -#: ../../library/random.rst:804 +#: ../../library/random.rst:805 msgid "Command-line usage" msgstr "命令列用法" -#: ../../library/random.rst:808 +#: ../../library/random.rst:809 msgid "The :mod:`!random` module can be executed from the command line." msgstr ":mod:`!random` 模組可以從命令列執行。" -#: ../../library/random.rst:810 +#: ../../library/random.rst:811 msgid "" "python -m random [-h] [-c CHOICE [CHOICE ...] | -i N | -f N] [input ...]" msgstr "" "python -m random [-h] [-c CHOICE [CHOICE ...] | -i N | -f N] [input ...]" -#: ../../library/random.rst:814 +#: ../../library/random.rst:815 msgid "The following options are accepted:" msgstr "接受以下選項:" -#: ../../library/random.rst:820 +#: ../../library/random.rst:821 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/random.rst:825 +#: ../../library/random.rst:826 msgid "Print a random choice, using :meth:`choice`." msgstr "列印一個隨機選擇,使用 :meth:`choice`。" -#: ../../library/random.rst:830 +#: ../../library/random.rst:831 msgid "" "Print a random integer between 1 and N inclusive, using :meth:`randint`." msgstr "列印 1 到 N(含)之間的隨機整數,使用 :meth:`randint`。" -#: ../../library/random.rst:835 +#: ../../library/random.rst:836 msgid "" "Print a random floating-point number between 0 and N inclusive, using :meth:" "`uniform`." msgstr "列印 0 到 N(含)之間的隨機浮點數,使用 :meth:`uniform`。" -#: ../../library/random.rst:838 +#: ../../library/random.rst:839 msgid "If no options are given, the output depends on the input:" msgstr "如果未給定選項,則輸出取決於輸入:" -#: ../../library/random.rst:840 +#: ../../library/random.rst:841 msgid "String or multiple: same as :option:`--choice`." msgstr "字串或多個:與 :option:`--choice` 相同。" -#: ../../library/random.rst:841 +#: ../../library/random.rst:842 msgid "Integer: same as :option:`--integer`." msgstr "整數:與 :option:`--integer` 相同。" -#: ../../library/random.rst:842 +#: ../../library/random.rst:843 msgid "Float: same as :option:`--float`." msgstr "浮點數:與 :option:`--float` 相同。" -#: ../../library/random.rst:847 +#: ../../library/random.rst:848 msgid "Command-line example" msgstr "命令列範例" -#: ../../library/random.rst:849 +#: ../../library/random.rst:850 msgid "Here are some examples of the :mod:`!random` command-line interface:" msgstr "以下是 :mod:`!random` 命令列介面的一些範例:" -#: ../../library/random.rst:851 +#: ../../library/random.rst:852 msgid "" "$ # Choose one at random\n" "$ python -m random egg bacon sausage spam \"Lobster Thermidor aux crevettes " diff --git a/library/re.po b/library/re.po index ce10f450e0a..08bc0434af6 100644 --- a/library/re.po +++ b/library/re.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-06 00:35+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-09-16 14:49+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,17 +23,17 @@ msgstr "" msgid ":mod:`!re` --- Regular expression operations" msgstr ":mod:`!re` --- 正規表示式 (regular expression) 操作" -#: ../../library/re.rst:10 +#: ../../library/re.rst:7 msgid "**Source code:** :source:`Lib/re/`" msgstr "**原始碼:**\\ :source:`Lib/re/`" -#: ../../library/re.rst:14 +#: ../../library/re.rst:11 msgid "" "This module provides regular expression matching operations similar to those " "found in Perl." msgstr "此模組提供類似於 Perl 中正規表示式的匹配操作。" -#: ../../library/re.rst:17 +#: ../../library/re.rst:14 msgid "" "Both patterns and strings to be searched can be Unicode strings (:class:" "`str`) as well as 8-bit strings (:class:`bytes`). However, Unicode strings " @@ -47,7 +47,7 @@ msgstr "" "你不能用 byte 模式匹配 Unicode 字串,反之亦然;同樣地,替換時,用來替換的字串" "必須與模式和搜尋字串是相同的型別 (type)。" -#: ../../library/re.rst:24 +#: ../../library/re.rst:21 msgid "" "Regular expressions use the backslash character (``'\\'``) to indicate " "special forms or to allow special characters to be used without invoking " @@ -70,7 +70,7 @@ msgstr "" "成一個 :exc:`SyntaxError`。儘管它對正規表示式是一個有效的跳脫序列,這種行為也" "會發生。" -#: ../../library/re.rst:36 +#: ../../library/re.rst:33 msgid "" "The solution is to use Python's raw string notation for regular expression " "patterns; backslashes are not handled in any special way in a string literal " @@ -84,7 +84,7 @@ msgstr "" "元的字串,包含 ``'\\'`` 和 ``'n'``,同時 ``\"\\n\"`` 是一個單個字元的字串,包" "含一個換行符號。通常模式在 Python 程式中會使用這個原始字串符號表示。" -#: ../../library/re.rst:43 +#: ../../library/re.rst:40 msgid "" "It is important to note that most regular expression operations are " "available as module-level functions and methods on :ref:`compiled regular " @@ -95,7 +95,7 @@ msgstr "" "regular expressions ` 中的方法使用的。這些函式是個捷徑且讓你不需" "要先編譯一個正規表示式物件,但是會缺少一些微調參數。" -#: ../../library/re.rst:51 +#: ../../library/re.rst:48 msgid "" "The third-party :pypi:`regex` module, which has an API compatible with the " "standard library :mod:`!re` module, but offers additional functionality and " @@ -104,11 +104,11 @@ msgstr "" "第三方的 :pypi:`regex` 模組,有著和標準函式庫 :mod:`!re` 模組相容的 API,但是" "提供額外的功能以及更完整的 Unicode 支援。" -#: ../../library/re.rst:59 -msgid "Regular Expression Syntax" +#: ../../library/re.rst:56 +msgid "Regular expression syntax" msgstr "正規表示式語法" -#: ../../library/re.rst:61 +#: ../../library/re.rst:58 msgid "" "A regular expression (or RE) specifies a set of strings that matches it; the " "functions in this module let you check if a particular string matches a " @@ -119,7 +119,7 @@ msgstr "" "特定的字串是否匹配給定的正規表示式(或是給定的正規表示式是否匹配特定的字串," "說到底是一樣的)。" -#: ../../library/re.rst:66 +#: ../../library/re.rst:63 msgid "" "Regular expressions can be concatenated to form new regular expressions; if " "*A* and *B* are both regular expressions, then *AB* is also a regular " @@ -140,7 +140,7 @@ msgstr "" "規表示式可以輕鬆地從此處提到的簡單原始正規表示式建立。關於正規表示式的理論和" "實作,請參考 Friedl 書 [Frie09]_,或任何有關建構編譯器的書籍。" -#: ../../library/re.rst:76 +#: ../../library/re.rst:73 msgid "" "A brief explanation of the format of regular expressions follows. For " "further information and a gentler presentation, consult the :ref:`regex-" @@ -149,7 +149,7 @@ msgstr "" "一個簡短的正規表示式格式解釋如下。如需更多資訊或以較平易的方式了解,請參閱 :" "ref:`regex-howto`。" -#: ../../library/re.rst:79 +#: ../../library/re.rst:76 msgid "" "Regular expressions can contain both special and ordinary characters. Most " "ordinary characters, like ``'A'``, ``'a'``, or ``'0'``, are the simplest " @@ -163,7 +163,7 @@ msgstr "" "``last`` 匹配字串 ``'last'``。(在本節的其餘部分,我們會用通常沒有引號的 ``這" "種特殊樣式`` 來書寫正規表示式,而被匹配的字串會 ``'在單引號中'``。)" -#: ../../library/re.rst:86 +#: ../../library/re.rst:83 msgid "" "Some characters, like ``'|'`` or ``'('``, are special. Special characters " "either stand for classes of ordinary characters, or affect how the regular " @@ -172,7 +172,7 @@ msgstr "" "某些字元是特殊的,像 ``'|'`` 或 ``'('``。特殊字元會代表一般字元的類別,或是會" "影響它們周圍正規表示式的解讀方法。" -#: ../../library/re.rst:90 +#: ../../library/re.rst:87 msgid "" "Repetition operators or quantifiers (``*``, ``+``, ``?``, ``{m,n}``, etc) " "cannot be directly nested. This avoids ambiguity with the non-greedy " @@ -186,15 +186,15 @@ msgstr "" "要在一個重複正規表示式內添加第二個重複,可以使用括號。例如:正規表示式 ``(?:" "a{6})*`` 會匹配任何六的倍數個 ``a`` 字元。" -#: ../../library/re.rst:97 +#: ../../library/re.rst:94 msgid "The special characters are:" msgstr "特殊字元包含:" -#: ../../library/re.rst:101 ../../library/re.rst:1670 +#: ../../library/re.rst:98 ../../library/re.rst:1704 msgid "``.``" msgstr "``.``" -#: ../../library/re.rst:102 +#: ../../library/re.rst:99 msgid "" "(Dot.) In the default mode, this matches any character except a newline. " "If the :const:`DOTALL` flag has been specified, this matches any character " @@ -204,11 +204,11 @@ msgstr "" "`DOTALL` 旗標,這會匹配包含換行符號的任何字元。無論旗標為何,``(?s:.)`` 都會" "匹配任何字元。" -#: ../../library/re.rst:108 +#: ../../library/re.rst:105 msgid "``^``" msgstr "``^``" -#: ../../library/re.rst:109 +#: ../../library/re.rst:106 msgid "" "(Caret.) Matches the start of the string, and in :const:`MULTILINE` mode " "also matches immediately after each newline." @@ -216,11 +216,11 @@ msgstr "" "(插入符號) 會匹配字串的開頭,並且在 :const:`MULTILINE` 模式下,也會立即匹" "配緊接在每個換行符號之後的位置。" -#: ../../library/re.rst:114 +#: ../../library/re.rst:111 msgid "``$``" msgstr "``$``" -#: ../../library/re.rst:115 +#: ../../library/re.rst:112 msgid "" "Matches the end of the string or just before the newline at the end of the " "string, and in :const:`MULTILINE` mode also matches before a newline. " @@ -238,11 +238,11 @@ msgstr "" "在 ``'foo\\n'`` 中搜尋單一個 ``$`` 會找到兩個(空的)匹配:一個在換行符號之" "前,一個在字串結尾。" -#: ../../library/re.rst:125 +#: ../../library/re.rst:122 msgid "``*``" msgstr "``*``" -#: ../../library/re.rst:126 +#: ../../library/re.rst:123 msgid "" "Causes the resulting RE to match 0 or more repetitions of the preceding RE, " "as many repetitions as are possible. ``ab*`` will match 'a', 'ab', or 'a' " @@ -251,11 +251,11 @@ msgstr "" "使得到的正規表示式匹配前面正規表示式的 0 或多次的重複,盡可能多次的重複。" "``ab*`` 會匹配 'a'、'ab',或後面跟著任何數量個 'b' 的 'a'。" -#: ../../library/re.rst:132 +#: ../../library/re.rst:129 msgid "``+``" msgstr "``+``" -#: ../../library/re.rst:133 +#: ../../library/re.rst:130 msgid "" "Causes the resulting RE to match 1 or more repetitions of the preceding RE. " "``ab+`` will match 'a' followed by any non-zero number of 'b's; it will not " @@ -264,11 +264,11 @@ msgstr "" "使得到的正規表示式匹配前面正規表示式的 1 或多次的重複。``ab+`` 會匹配後面跟著" "任何非零數量個 'b' 的 'a';它不會匹配 'a'。" -#: ../../library/re.rst:139 +#: ../../library/re.rst:136 msgid "``?``" msgstr "``?``" -#: ../../library/re.rst:140 +#: ../../library/re.rst:137 msgid "" "Causes the resulting RE to match 0 or 1 repetitions of the preceding RE. " "``ab?`` will match either 'a' or 'ab'." @@ -276,11 +276,11 @@ msgstr "" "使得到的正規表示式匹配前面正規表示式的 0 或 1 次的重複。``ab?`` 會匹配 'a' " "或 'ab'。" -#: ../../library/re.rst:148 +#: ../../library/re.rst:145 msgid "``*?``, ``+?``, ``??``" msgstr "``*?``, ``+?``, ``??``" -#: ../../library/re.rst:149 +#: ../../library/re.rst:146 msgid "" "The ``'*'``, ``'+'``, and ``'?'`` quantifiers are all :dfn:`greedy`; they " "match as much text as possible. Sometimes this behaviour isn't desired; if " @@ -297,11 +297,11 @@ msgstr "" "`minimal`\\ (最小的)方式進行匹配;盡可能匹配\\ *更少*\\ 的字元。使用正規表" "示式 ``<.*?>`` 只會匹配到 ``''``。" -#: ../../library/re.rst:162 +#: ../../library/re.rst:159 msgid "``*+``, ``++``, ``?+``" msgstr "``*+``, ``++``, ``?+``" -#: ../../library/re.rst:163 +#: ../../library/re.rst:160 msgid "" "Like the ``'*'``, ``'+'``, and ``'?'`` quantifiers, those where ``'+'`` is " "appended also match as many times as possible. However, unlike the true " @@ -327,11 +327,11 @@ msgstr "" "找更多字元匹配失敗時,此正規表示式不能回溯並會因此匹配失敗。``x*+``、``x++`` " "和 ``x?+`` 分別等同於 ``(?>x*)``、``(?>x+)`` 和 ``(?>x?)``。" -#: ../../library/re.rst:184 +#: ../../library/re.rst:181 msgid "``{m}``" msgstr "``{m}``" -#: ../../library/re.rst:185 +#: ../../library/re.rst:182 msgid "" "Specifies that exactly *m* copies of the previous RE should be matched; " "fewer matches cause the entire RE not to match. For example, ``a{6}`` will " @@ -340,11 +340,11 @@ msgstr "" "指定應該恰好匹配 *m* 個前面的正規表示式;太少的匹配會造成整個正規表示式匹配失" "敗。例如,``a{6}`` 會匹配恰好六個 ``'a'`` 字元,但不匹配五個。" -#: ../../library/re.rst:189 +#: ../../library/re.rst:186 msgid "``{m,n}``" msgstr "``{m,n}``" -#: ../../library/re.rst:190 +#: ../../library/re.rst:187 msgid "" "Causes the resulting RE to match from *m* to *n* repetitions of the " "preceding RE, attempting to match as many repetitions as possible. For " @@ -361,11 +361,11 @@ msgstr "" "一千個 ``'a'`` 字元加上一個 ``'b'``,但是不匹配 ``'aaab'``。不可以忽略逗號," "否則量詞會與前述的形式混淆。" -#: ../../library/re.rst:198 +#: ../../library/re.rst:195 msgid "``{m,n}?``" msgstr "``{m,n}?``" -#: ../../library/re.rst:199 +#: ../../library/re.rst:196 msgid "" "Causes the resulting RE to match from *m* to *n* repetitions of the " "preceding RE, attempting to match as *few* repetitions as possible. This is " @@ -378,17 +378,17 @@ msgstr "" "``'aaaaaa'``,``a{3,5}`` 會匹配 5 個 ``'a'`` 字元,而 ``a{3,5}?`` 只會匹配 3 " "個字元。" -#: ../../library/re.rst:205 +#: ../../library/re.rst:202 msgid "``{m,n}+``" msgstr "``{m,n}+``" -#: ../../library/re.rst:206 +#: ../../library/re.rst:203 msgid "" "Causes the resulting RE to match from *m* to *n* repetitions of the " "preceding RE, attempting to match as many repetitions as possible *without* " "establishing any backtracking points. This is the possessive version of the " "quantifier above. For example, on the 6-character string ``'aaaaaa'``, " -"``a{3,5}+aa`` attempt to match 5 ``'a'`` characters, then, requiring 2 more " +"``a{3,5}+aa`` attempts to match 5 ``'a'`` characters, then, requiring 2 more " "``'a'``\\ s, will need more characters than available and thus fail, while " "``a{3,5}aa`` will match with ``a{3,5}`` capturing 5, then 4 ``'a'``\\ s by " "backtracking and then the final 2 ``'a'``\\ s are matched by the final " @@ -397,15 +397,15 @@ msgstr "" "使得到的正規表示式重複匹配前面的正規表示式 *m* 到 *n* 次,並嘗試盡可能更多次" "的匹配而\\ *不*\\ 建立任何回溯點。這是上述量詞的佔有版本。例如,對六個字元的" "字串 ``'aaaaaa'``,``a{3,5}+aa`` 嘗試匹配 5 個 ``'a'`` 字元,然後需要再 2 個 " -"``'a'``,會需要比可用的字元更多所以失敗,而 ``a{3,5}aa`` 會捕捉到 5 個 " -"``'a'``,然後回溯成 4 個 ``'a'``,接著最後兩個 ``'a'`` 會被模式中最後的 " +"``'a'``,會需要比可用的字元更多所以失敗,而 ``a{3,5}aa`` 會以 ``a{3,5}`` 捕捉" +"到 5 個,然後回溯成 4 個 ``'a'``,接著最後兩個 ``'a'`` 會被模式中最後的 " "``aa`` 匹配。``x{m,n}+`` 等同於 ``(?>x{m,n})``。" -#: ../../library/re.rst:222 +#: ../../library/re.rst:219 msgid "``\\``" msgstr "``\\``" -#: ../../library/re.rst:223 +#: ../../library/re.rst:220 msgid "" "Either escapes special characters (permitting you to match characters like " "``'*'``, ``'?'``, and so forth), or signals a special sequence; special " @@ -414,7 +414,7 @@ msgstr "" "用來跳脫特殊字元(允許你匹配如 ``'*'``、``'?'`` 等字元),或是表示一個特殊序" "列;特殊序列將在下方討論。" -#: ../../library/re.rst:227 +#: ../../library/re.rst:224 msgid "" "If you're not using a raw string to express the pattern, remember that " "Python also uses the backslash as an escape sequence in string literals; if " @@ -430,22 +430,22 @@ msgstr "" "兩次。這很複雜並且難以理解,所以強烈建議,除了最簡單的正規表示式,都應該使用" "原始字串。" -#: ../../library/re.rst:238 +#: ../../library/re.rst:235 msgid "``[]``" msgstr "``[]``" -#: ../../library/re.rst:239 +#: ../../library/re.rst:236 msgid "Used to indicate a set of characters. In a set:" msgstr "用來表示一個字元集合。在一個集合中:" -#: ../../library/re.rst:241 +#: ../../library/re.rst:238 msgid "" "Characters can be listed individually, e.g. ``[amk]`` will match ``'a'``, " "``'m'``, or ``'k'``." msgstr "" "字元可以獨立列出,例如: ``[amk]`` 會匹配 ``'a'``、``'m'`` 或 ``'k'``。" -#: ../../library/re.rst:246 +#: ../../library/re.rst:243 msgid "" "Ranges of characters can be indicated by giving two characters and " "separating them by a ``'-'``, for example ``[a-z]`` will match any lowercase " @@ -460,7 +460,7 @@ msgstr "" "(如: ``[a\\-z]``) 或是放在第一或最後一個位置(如: ``[-a]`` 或 " "``[a-]``),它將會匹配字面的 ``'-'``。" -#: ../../library/re.rst:253 +#: ../../library/re.rst:250 msgid "" "Special characters except backslash lose their special meaning inside sets. " "For example, ``[(+*)]`` will match any of the literal characters ``'('``, " @@ -469,7 +469,7 @@ msgstr "" "除反斜線外的特殊字元會在集合內失去它們的特殊意義。例如,``[(+*)]`` 會匹配任何" "字面字元 ``'('``、``'+'``、``'*'``,或 ``')'``。" -#: ../../library/re.rst:260 +#: ../../library/re.rst:257 msgid "" "Backslash either escapes characters which have special meaning in a set such " "as ``'-'``, ``']'``, ``'^'`` and ``'\\\\'`` itself or signals a special " @@ -487,7 +487,7 @@ msgstr "" "的數值跳脫總是代表八進位數字的跳脫,而不是群組的參照。不匹配單一字元的特殊序" "列是不被允許的,像是 ``\\A`` 和 ``\\Z``。" -#: ../../library/re.rst:273 +#: ../../library/re.rst:270 msgid "" "Characters that are not within a range can be matched by :dfn:" "`complementing` the set. If the first character of the set is ``'^'``, all " @@ -501,7 +501,7 @@ msgstr "" "配。例如, ``[^5]`` 會匹配任何除了 ``'5'`` 的字元,而 ``[^^]`` 會匹配任何除" "了 ``'^'`` 的字元。如果 ``^`` 不是集合中的第一個字元的話,沒有特殊意義。" -#: ../../library/re.rst:280 +#: ../../library/re.rst:277 msgid "" "To match a literal ``']'`` inside a set, precede it with a backslash, or " "place it at the beginning of the set. For example, both ``[()[\\]{}]`` and " @@ -512,7 +512,7 @@ msgstr "" "面。例如,``[()[\\]{}]`` 和 ``[]()[{}]`` 都會匹配右方括號、左方括號、花括號和" "括號。" -#: ../../library/re.rst:290 +#: ../../library/re.rst:287 msgid "" "Support of nested sets and set operations as in `Unicode Technical Standard " "#18`_ might be added in the future. This would change the syntax, so to " @@ -526,7 +526,7 @@ msgstr "" "`FutureWarning`。包含了以字面 ``'['`` 開頭,或是包含字面的字元序列 ``'--'``、" "``'&&'``、``'~~'`` 和 ``'||'`` 的集合。為了避免警告,請用反斜線跳脫它們。" -#: ../../library/re.rst:300 +#: ../../library/re.rst:297 msgid "" ":exc:`FutureWarning` is raised if a character set contains constructs that " "will change semantically in the future." @@ -534,11 +534,11 @@ msgstr "" "如果一個字元集合包含了其語義未來會被改變的結構,:exc:`FutureWarning` 會被引" "發。" -#: ../../library/re.rst:306 +#: ../../library/re.rst:303 msgid "``|``" msgstr "``|``" -#: ../../library/re.rst:307 +#: ../../library/re.rst:304 msgid "" "``A|B``, where *A* and *B* can be arbitrary REs, creates a regular " "expression that will match either *A* or *B*. An arbitrary number of REs " @@ -558,11 +558,11 @@ msgstr "" "匹配字面的 ``'|'``,使用 ``\\|``,或是將它包圍在一個字元類別中,就像 " "``[|]``。" -#: ../../library/re.rst:320 +#: ../../library/re.rst:317 msgid "``(...)``" msgstr "``(...)``" -#: ../../library/re.rst:321 +#: ../../library/re.rst:318 msgid "" "Matches whatever regular expression is inside the parentheses, and indicates " "the start and end of a group; the contents of a group can be retrieved after " @@ -576,11 +576,11 @@ msgstr "" "述。要匹配字面的 ``'('`` 或 ``')'``,用 ``\\(`` 或 ``\\)``,或是將它們包圍在" "一個字元類別中: ``[(``、``[)]``。" -#: ../../library/re.rst:329 +#: ../../library/re.rst:326 msgid "``(?...)``" msgstr "``(?...)``" -#: ../../library/re.rst:330 +#: ../../library/re.rst:327 msgid "" "This is an extension notation (a ``'?'`` following a ``'('`` is not " "meaningful otherwise). The first character after the ``'?'`` determines " @@ -592,11 +592,11 @@ msgstr "" "``'?'`` 後面的第一個字元決定了這個結構的意義和進一步的語法。擴充通常不會創造" "新的群組;``(?P...)`` 是這個規則的唯一例外。以下是目前支援的擴充。" -#: ../../library/re.rst:336 +#: ../../library/re.rst:333 msgid "``(?aiLmsux)``" msgstr "``(?aiLmsux)``" -#: ../../library/re.rst:337 +#: ../../library/re.rst:334 msgid "" "(One or more letters from the set ``'a'``, ``'i'``, ``'L'``, ``'m'``, " "``'s'``, ``'u'``, ``'x'``.) The group matches the empty string; the letters " @@ -605,35 +605,35 @@ msgstr "" "(集合 ``'a'``、``'i'``、``'L'``、``'m'``、``'s'``、``'u'``、 ``'x'`` 中的一" "或多個字母。)該群組會匹配空字串;這些字母會為整個正規表示式設定對應的旗標。" -#: ../../library/re.rst:342 ../../library/re.rst:374 +#: ../../library/re.rst:339 ../../library/re.rst:371 msgid ":const:`re.A` (ASCII-only matching)" msgstr ":const:`re.A`\\ (僅限 ASCII 字元匹配)" -#: ../../library/re.rst:343 ../../library/re.rst:375 +#: ../../library/re.rst:340 ../../library/re.rst:372 msgid ":const:`re.I` (ignore case)" msgstr ":const:`re.I`\\ (忽略大小寫)" -#: ../../library/re.rst:344 ../../library/re.rst:376 +#: ../../library/re.rst:341 ../../library/re.rst:373 msgid ":const:`re.L` (locale dependent)" msgstr ":const:`re.L`\\ (依賴區域設定)" -#: ../../library/re.rst:345 ../../library/re.rst:377 +#: ../../library/re.rst:342 ../../library/re.rst:374 msgid ":const:`re.M` (multi-line)" msgstr ":const:`re.M`\\ (多行)" -#: ../../library/re.rst:346 ../../library/re.rst:378 +#: ../../library/re.rst:343 ../../library/re.rst:375 msgid ":const:`re.S` (dot matches all)" msgstr ":const:`re.S`\\ (點會匹配所有字元)" -#: ../../library/re.rst:347 ../../library/re.rst:379 +#: ../../library/re.rst:344 ../../library/re.rst:376 msgid ":const:`re.U` (Unicode matching)" msgstr ":const:`re.U`\\ (匹配 Unicode)" -#: ../../library/re.rst:348 ../../library/re.rst:380 +#: ../../library/re.rst:345 ../../library/re.rst:377 msgid ":const:`re.X` (verbose)" msgstr ":const:`re.X`\\ (詳盡模式)" -#: ../../library/re.rst:350 +#: ../../library/re.rst:347 msgid "" "(The flags are described in :ref:`contents-of-module-re`.) This is useful if " "you wish to include the flags as part of the regular expression, instead of " @@ -644,15 +644,15 @@ msgstr "" "示式的一部分,而不是傳遞一個 *flag* 引數給 :func:`re.compile` 函式的話,這會" "有幫助。旗標應該首先在正規表示式字串中使用。" -#: ../../library/re.rst:356 +#: ../../library/re.rst:353 msgid "This construction can only be used at the start of the expression." msgstr "此結構只能用於正規表示式的開頭。" -#: ../../library/re.rst:361 +#: ../../library/re.rst:358 msgid "``(?:...)``" msgstr "``(?:...)``" -#: ../../library/re.rst:362 +#: ../../library/re.rst:359 msgid "" "A non-capturing version of regular parentheses. Matches whatever regular " "expression is inside the parentheses, but the substring matched by the group " @@ -662,11 +662,11 @@ msgstr "" "一個非捕捉版本的普通括號。匹配括號內的任何正規表示式,但是被群組匹配到的子字" "串\\ *不能*\\ 在執行匹配後被取得,或是在之後的模式中被參照。" -#: ../../library/re.rst:367 +#: ../../library/re.rst:364 msgid "``(?aiLmsux-imsx:...)``" msgstr "``(?aiLmsux-imsx:...)``" -#: ../../library/re.rst:368 +#: ../../library/re.rst:365 msgid "" "(Zero or more letters from the set ``'a'``, ``'i'``, ``'L'``, ``'m'``, " "``'s'``, ``'u'``, ``'x'``, optionally followed by ``'-'`` followed by one or " @@ -678,11 +678,11 @@ msgstr "" "``'x'`` 中的字母。)該字母集合會為那一部分的正規表示式設定或是移除對應的旗" "標。" -#: ../../library/re.rst:382 +#: ../../library/re.rst:379 msgid "(The flags are described in :ref:`contents-of-module-re`.)" msgstr "(這些旗標在 :ref:`contents-of-module-re` 中說明。)" -#: ../../library/re.rst:384 +#: ../../library/re.rst:381 msgid "" "The letters ``'a'``, ``'L'`` and ``'u'`` are mutually exclusive when used as " "inline flags, so they can't be combined or follow ``'-'``. Instead, when " @@ -702,15 +702,15 @@ msgstr "" "配 ASCII 模式(預設)。這個覆蓋只會在嵌入群組中作用,而原本的匹配模式會在群組" "外恢復。" -#: ../../library/re.rst:396 +#: ../../library/re.rst:393 msgid "The letters ``'a'``, ``'L'`` and ``'u'`` also can be used in a group." msgstr "字母 ``'a'``、``'L'`` 和 ``'u'`` 也可以被用在群組中。" -#: ../../library/re.rst:399 +#: ../../library/re.rst:396 msgid "``(?>...)``" msgstr "``(?>...)``" -#: ../../library/re.rst:400 +#: ../../library/re.rst:397 msgid "" "Attempts to match ``...`` as if it was a separate regular expression, and if " "successful, continues to match the rest of the pattern following it. If the " @@ -731,11 +731,11 @@ msgstr "" "配,導致最終的 ``.`` 匹配失敗。因為原子群組中沒有儲存回溯點,而且群組之前也沒" "有回溯點,整個正規表示式都會匹配失敗。" -#: ../../library/re.rst:416 +#: ../../library/re.rst:413 msgid "``(?P...)``" msgstr "``(?P...)``" -#: ../../library/re.rst:417 +#: ../../library/re.rst:414 msgid "" "Similar to regular parentheses, but the substring matched by the group is " "accessible via the symbolic group name *name*. Group names must be valid " @@ -749,7 +749,7 @@ msgstr "" "中,它們只能包含 ASCII 範圍中的位元組。每個群組名稱在正規表示式中只能定義一" "次。一個符號群組同時也是一個編號群組,只是等同於該群組沒有名稱。" -#: ../../library/re.rst:424 +#: ../../library/re.rst:421 msgid "" "Named groups can be referenced in three contexts. If the pattern is ``(?" "P['\"]).*?(?P=quote)`` (i.e. matching a string quoted with either " @@ -759,51 +759,51 @@ msgstr "" "P['\"]).*?(?P=quote)``\\ (也就是匹配一個用單引號或雙引號包圍的字" "串):" -#: ../../library/re.rst:429 +#: ../../library/re.rst:426 msgid "Context of reference to group \"quote\"" msgstr "對 \"quote\" 群組參照的情境" -#: ../../library/re.rst:429 +#: ../../library/re.rst:426 msgid "Ways to reference it" msgstr "參照方式" -#: ../../library/re.rst:431 +#: ../../library/re.rst:428 msgid "in the same pattern itself" msgstr "在同一個模式中" -#: ../../library/re.rst:431 +#: ../../library/re.rst:428 msgid "``(?P=quote)`` (as shown)" msgstr "``(?P=quote)``\\ (如上例所示)" -#: ../../library/re.rst:432 ../../library/re.rst:439 +#: ../../library/re.rst:429 ../../library/re.rst:436 msgid "``\\1``" msgstr "``\\1``" -#: ../../library/re.rst:434 +#: ../../library/re.rst:431 msgid "when processing match object *m*" msgstr "在處理匹配物件 *m* 時" -#: ../../library/re.rst:434 +#: ../../library/re.rst:431 msgid "``m.group('quote')``" msgstr "``m.group('quote')``" -#: ../../library/re.rst:435 +#: ../../library/re.rst:432 msgid "``m.end('quote')`` (etc.)" msgstr "``m.end('quote')``\\ (等)" -#: ../../library/re.rst:437 +#: ../../library/re.rst:434 msgid "in a string passed to the *repl* argument of ``re.sub()``" msgstr "在被當成 ``re.sub()`` 的 *repl* 引數傳入的字串中" -#: ../../library/re.rst:437 +#: ../../library/re.rst:434 msgid "``\\g``" msgstr "``\\g``" -#: ../../library/re.rst:438 +#: ../../library/re.rst:435 msgid "``\\g<1>``" msgstr "``\\g<1>``" -#: ../../library/re.rst:442 +#: ../../library/re.rst:439 msgid "" "In :class:`bytes` patterns, group *name* can only contain bytes in the ASCII " "range (``b'\\x00'``-``b'\\x7f'``)." @@ -811,11 +811,11 @@ msgstr "" "在 :class:`bytes` 模式中,群組的\\ *名稱*\\ 只能包含 ASCII 範圍中的位元組" "(``b'\\x00'``-``b'\\x7f'``)。" -#: ../../library/re.rst:448 +#: ../../library/re.rst:445 msgid "``(?P=name)``" msgstr "``(?P=name)``" -#: ../../library/re.rst:449 +#: ../../library/re.rst:446 msgid "" "A backreference to a named group; it matches whatever text was matched by " "the earlier group named *name*." @@ -823,19 +823,19 @@ msgstr "" "對於命名群組的反向參照;它會匹配任何之前被命名為 *name* 的群組所匹配到的文" "字。" -#: ../../library/re.rst:454 +#: ../../library/re.rst:451 msgid "``(?#...)``" msgstr "``(?#...)``" -#: ../../library/re.rst:455 +#: ../../library/re.rst:452 msgid "A comment; the contents of the parentheses are simply ignored." msgstr "一個註解;括號中的內容會被忽略。" -#: ../../library/re.rst:459 +#: ../../library/re.rst:456 msgid "``(?=...)``" msgstr "``(?=...)``" -#: ../../library/re.rst:460 +#: ../../library/re.rst:457 msgid "" "Matches if ``...`` matches next, but doesn't consume any of the string. " "This is called a :dfn:`lookahead assertion`. For example, ``Isaac (?" @@ -845,11 +845,11 @@ msgstr "" "作 :dfn:`lookahead assertion`。例如,``Isaac (?=Asimov)`` 只在後面跟著 " "``'Asimov'`` 時才會匹配 ``'Isaac '``。" -#: ../../library/re.rst:466 +#: ../../library/re.rst:463 msgid "``(?!...)``" msgstr "``(?!...)``" -#: ../../library/re.rst:467 +#: ../../library/re.rst:464 msgid "" "Matches if ``...`` doesn't match next. This is a :dfn:`negative lookahead " "assertion`. For example, ``Isaac (?!Asimov)`` will match ``'Isaac '`` only " @@ -860,11 +860,11 @@ msgstr "" "``Isaac (?!Asimov)`` 只在後面\\ *不*\\ 跟著 ``'Asimov'`` 時才會匹配 ``'Isaac " "'``。" -#: ../../library/re.rst:473 +#: ../../library/re.rst:470 msgid "``(?<=...)``" msgstr "``(?<=...)``" -#: ../../library/re.rst:474 +#: ../../library/re.rst:471 msgid "" "Matches if the current position in the string is preceded by a match for " "``...`` that ends at the current position. This is called a :dfn:`positive " @@ -885,19 +885,19 @@ msgstr "" "斷言開頭的模式不會匹配被搜尋字串的開頭;你更可能想要使用 :func:`search` 函式" "而不是 :func:`match` 函式:" -#: ../../library/re.rst:489 +#: ../../library/re.rst:486 msgid "This example looks for a word following a hyphen:" msgstr "這個範例在尋找連字號後的單字:" -#: ../../library/re.rst:495 +#: ../../library/re.rst:492 msgid "Added support for group references of fixed length." msgstr "新增固定長度群組參照的支援。" -#: ../../library/re.rst:500 +#: ../../library/re.rst:497 msgid "``(?'``\\ (對於前" "者,:func:`re.search` 只會找到 ``'user@host.com'``)。" -#: ../../library/re.rst:519 +#: ../../library/re.rst:516 msgid "" "Group *id* can only contain ASCII digits. In :class:`bytes` patterns, group " "*name* can only contain bytes in the ASCII range (``b'\\x00'``-``b'\\x7f'``)." @@ -939,7 +939,7 @@ msgstr "" "群組 *id* 只能包含 ASCII 數字。在 :class:`bytes` 模式中,群組 *name* 只能包" "含 ASCII 範圍中的位元組 (``b'\\x00'``-``b'\\x7f'``)。" -#: ../../library/re.rst:527 +#: ../../library/re.rst:524 msgid "" "The special sequences consist of ``'\\'`` and a character from the list " "below. If the ordinary character is not an ASCII digit or an ASCII letter, " @@ -950,11 +950,11 @@ msgstr "" "ASCII 數字或是一個 ASCII 字母,那麼產生的的正規表示式會匹配第二個字元。例如," "``\\$`` 會匹配字元 ``'$'``。" -#: ../../library/re.rst:534 +#: ../../library/re.rst:531 msgid "``\\number``" msgstr "``\\number``" -#: ../../library/re.rst:535 +#: ../../library/re.rst:532 msgid "" "Matches the contents of the group of the same number. Groups are numbered " "starting from 1. For example, ``(.+) \\1`` matches ``'the the'`` or ``'55 " @@ -972,19 +972,19 @@ msgstr "" "位數值 *number* 的字元。在一個字元類別中的 ``'['`` 和 ``']'``,所有數值的跳脫" "字元都會被當作字元。" -#: ../../library/re.rst:546 +#: ../../library/re.rst:543 msgid "``\\A``" msgstr "``\\A``" -#: ../../library/re.rst:547 +#: ../../library/re.rst:544 msgid "Matches only at the start of the string." msgstr "只在字串的開頭匹配。" -#: ../../library/re.rst:551 +#: ../../library/re.rst:548 msgid "``\\b``" msgstr "``\\b``" -#: ../../library/re.rst:552 +#: ../../library/re.rst:549 msgid "" "Matches the empty string, but only at the beginning or end of a word. A word " "is defined as a sequence of word characters. Note that formally, ``\\b`` is " @@ -999,7 +999,7 @@ msgstr "" "``r'\\bat\\b'`` 會匹配 ``'at'``、``'at.'``、``'(at)'``,以及 ``'as at ay'``," "但是不匹配 ``'attempt'`` 或 ``'atlas'``。" -#: ../../library/re.rst:560 +#: ../../library/re.rst:557 msgid "" "The default word characters in Unicode (str) patterns are Unicode " "alphanumerics and the underscore, but this can be changed by using the :py:" @@ -1010,18 +1010,18 @@ msgstr "" "和底線,但是這可以透過使用 :py:const:`~re.ASCII` 旗標來改變。如果使用了 :py:" "const:`~re.LOCALE` 旗標,單字的邊界會由目前的區域設定決定。" -#: ../../library/re.rst:568 +#: ../../library/re.rst:565 msgid "" "Inside a character range, ``\\b`` represents the backspace character, for " "compatibility with Python's string literals." msgstr "" "在字元範圍中,為了與 Python 的字串文本的相容性,``\\b`` 表示 backspace 字元。" -#: ../../library/re.rst:573 +#: ../../library/re.rst:570 msgid "``\\B``" msgstr "``\\B``" -#: ../../library/re.rst:574 +#: ../../library/re.rst:571 msgid "" "Matches the empty string, but only when it is *not* at the beginning or end " "of a word. This means that ``r'at\\B'`` matches ``'athens'``, ``'atom'``, " @@ -1038,19 +1038,19 @@ msgstr "" "const:`~re.ASCII` 旗標來改變。如果使用了 :py:const:`~re.LOCALE` 旗標,單字的" "邊界會由目前的區域設定決定。" -#: ../../library/re.rst:585 +#: ../../library/re.rst:582 msgid "``\\B`` now matches empty input string." msgstr "``\\B`` 現在會匹配空的輸入字串。" -#: ../../library/re.rst:590 +#: ../../library/re.rst:587 msgid "``\\d``" msgstr "``\\d``" -#: ../../library/re.rst:591 ../../library/re.rst:615 ../../library/re.rst:637 +#: ../../library/re.rst:588 ../../library/re.rst:612 ../../library/re.rst:634 msgid "For Unicode (str) patterns:" msgstr "對於 Unicode(字串)模式:" -#: ../../library/re.rst:592 +#: ../../library/re.rst:589 msgid "" "Matches any Unicode decimal digit (that is, any character in Unicode " "character category `[Nd]`__). This includes ``[0-9]``, and also many other " @@ -1059,39 +1059,39 @@ msgstr "" "匹配任何 Unicode 十進位數字(也就是 Unicode 字元類別中的任何字元 `[Nd]`__)。" "這包含了 ``[0-9]``,以及許多許多其他的數字字元。" -#: ../../library/re.rst:596 +#: ../../library/re.rst:593 msgid "Matches ``[0-9]`` if the :py:const:`~re.ASCII` flag is used." msgstr "如果使用了 :py:const:`~re.ASCII` 旗標,匹配 ``[0-9]``。" -#: ../../library/re.rst:600 ../../library/re.rst:622 ../../library/re.rst:645 +#: ../../library/re.rst:597 ../../library/re.rst:619 ../../library/re.rst:642 msgid "For 8-bit (bytes) patterns:" msgstr "對於 8 位元(位元組)模式:" -#: ../../library/re.rst:601 +#: ../../library/re.rst:598 msgid "" "Matches any decimal digit in the ASCII character set; this is equivalent to " "``[0-9]``." msgstr "匹配任何 ASCII 字元集合中的十進位數字;這等同於 ``[0-9]``。" -#: ../../library/re.rst:606 +#: ../../library/re.rst:603 msgid "``\\D``" msgstr "``\\D``" -#: ../../library/re.rst:607 +#: ../../library/re.rst:604 msgid "" "Matches any character which is not a decimal digit. This is the opposite of " "``\\d``." msgstr "匹配任何不是十進位數字的字元。這是 ``\\d`` 的相反。" -#: ../../library/re.rst:610 +#: ../../library/re.rst:607 msgid "Matches ``[^0-9]`` if the :py:const:`~re.ASCII` flag is used." msgstr "如果使用了 :py:const:`~re.ASCII` 旗標,會匹配 ``[^0-9]``。" -#: ../../library/re.rst:614 +#: ../../library/re.rst:611 msgid "``\\s``" msgstr "``\\s``" -#: ../../library/re.rst:616 +#: ../../library/re.rst:613 msgid "" "Matches Unicode whitespace characters (as defined by :py:meth:`str." "isspace`). This includes ``[ \\t\\n\\r\\f\\v]``, and also many other " @@ -1102,37 +1102,37 @@ msgstr "" "``[ \\t\\n\\r\\f\\v]``,還有許多其他的字元,例如許多語言的排版規則中要求的不" "換行空格。" -#: ../../library/re.rst:620 +#: ../../library/re.rst:617 msgid "" "Matches ``[ \\t\\n\\r\\f\\v]`` if the :py:const:`~re.ASCII` flag is used." msgstr "如果使用了 :py:const:`~re.ASCII` 旗標,匹配 ``[ \\t\\n\\r\\f\\v]``。" -#: ../../library/re.rst:623 +#: ../../library/re.rst:620 msgid "" "Matches characters considered whitespace in the ASCII character set; this is " "equivalent to ``[ \\t\\n\\r\\f\\v]``." msgstr "匹配 ASCII 字元集合中認定的空格;這等同於 ``[ \\t\\n\\r\\f\\v]``。" -#: ../../library/re.rst:628 +#: ../../library/re.rst:625 msgid "``\\S``" msgstr "``\\S``" -#: ../../library/re.rst:629 +#: ../../library/re.rst:626 msgid "" "Matches any character which is not a whitespace character. This is the " "opposite of ``\\s``." msgstr "匹配任何不是空格字元的字元。這是 ``\\s`` 的相反。" -#: ../../library/re.rst:632 +#: ../../library/re.rst:629 msgid "" "Matches ``[^ \\t\\n\\r\\f\\v]`` if the :py:const:`~re.ASCII` flag is used." msgstr "如果使用了 :py:const:`~re.ASCII` 旗標,匹配 ``[^ \\t\\n\\r\\f\\v]``。" -#: ../../library/re.rst:636 +#: ../../library/re.rst:633 msgid "``\\w``" msgstr "``\\w``" -#: ../../library/re.rst:638 +#: ../../library/re.rst:635 msgid "" "Matches Unicode word characters; this includes all Unicode alphanumeric " "characters (as defined by :py:meth:`str.isalnum`), as well as the underscore " @@ -1141,11 +1141,11 @@ msgstr "" "匹配 Unicode 單字字元;這包含全部 Unicode 的字母數字字元(在 :py:meth:`str." "isalnum` 中定義),以及底線 (``_``)。" -#: ../../library/re.rst:643 +#: ../../library/re.rst:640 msgid "Matches ``[a-zA-Z0-9_]`` if the :py:const:`~re.ASCII` flag is used." msgstr "如果使用了 :py:const:`~re.ASCII` 旗標,匹配 ``[a-zA-Z0-9_]``。" -#: ../../library/re.rst:646 +#: ../../library/re.rst:643 msgid "" "Matches characters considered alphanumeric in the ASCII character set; this " "is equivalent to ``[a-zA-Z0-9_]``. If the :py:const:`~re.LOCALE` flag is " @@ -1156,11 +1156,11 @@ msgstr "" "如果使用了 :py:const:`~re.LOCALE` 旗標,會匹配目前區域設定中被認定為字母或數" "字的字元,以及底線。" -#: ../../library/re.rst:653 +#: ../../library/re.rst:650 msgid "``\\W``" msgstr "``\\W``" -#: ../../library/re.rst:654 +#: ../../library/re.rst:651 msgid "" "Matches any character which is not a word character. This is the opposite of " "``\\w``. By default, matches non-underscore (``_``) characters for which :py:" @@ -1169,11 +1169,11 @@ msgstr "" "匹配任何不是單字字元的字元。這是 ``\\w`` 的相反。預設情況下,會匹配任何不是底" "線 (``_``),並且 :py:meth:`str.isalnum` 會回傳 ``False`` 的字元。" -#: ../../library/re.rst:659 +#: ../../library/re.rst:656 msgid "Matches ``[^a-zA-Z0-9_]`` if the :py:const:`~re.ASCII` flag is used." msgstr "如果使用了 :py:const:`~re.ASCII` 旗標,會匹配 ``[^a-zA-Z0-9_]``。" -#: ../../library/re.rst:661 +#: ../../library/re.rst:658 msgid "" "If the :py:const:`~re.LOCALE` flag is used, matches characters which are " "neither alphanumeric in the current locale nor the underscore." @@ -1181,23 +1181,23 @@ msgstr "" "如果使用了 :py:const:`~re.LOCALE` 旗標,會匹配目前區域中不是字母數字,也不是" "底線的字元。" -#: ../../library/re.rst:668 +#: ../../library/re.rst:665 msgid "``\\z``" msgstr "``\\z``" -#: ../../library/re.rst:669 +#: ../../library/re.rst:666 msgid "Matches only at the end of the string." msgstr "只在字串的結尾匹配。" -#: ../../library/re.rst:673 +#: ../../library/re.rst:670 msgid "``\\Z``" msgstr "``\\Z``" -#: ../../library/re.rst:674 +#: ../../library/re.rst:671 msgid "The same as ``\\z``. For compatibility with old Python versions." msgstr "和 ``\\z`` 相同。為了與舊版的 Python 相容而保留。" -#: ../../library/re.rst:690 +#: ../../library/re.rst:687 msgid "" "Most of the :ref:`escape sequences ` supported by Python " "string literals are also accepted by the regular expression parser::" @@ -1205,7 +1205,7 @@ msgstr "" "大多數 Python 的字串文本支援的\\ :ref:`跳脫序列 `\\ 也能被" "正規表示式剖析器接受: ::" -#: ../../library/re.rst:693 +#: ../../library/re.rst:690 msgid "" "\\a \\b \\f \\n\n" "\\N \\r \\t \\u\n" @@ -1215,14 +1215,14 @@ msgstr "" "\\N \\r \\t \\u\n" "\\U \\v \\x \\\\" -#: ../../library/re.rst:697 +#: ../../library/re.rst:694 msgid "" "(Note that ``\\b`` is used to represent word boundaries, and means " "\"backspace\" only inside character classes.)" msgstr "" "(請注意 ``\\b`` 被用來表示單字邊界,並且只在字元類別內表示 \"backspace\"。)" -#: ../../library/re.rst:700 +#: ../../library/re.rst:697 msgid "" "``'\\u'``, ``'\\U'``, and ``'\\N'`` escape sequences are only recognized in " "Unicode (str) patterns. In bytes patterns they are errors. Unknown escapes " @@ -1232,7 +1232,7 @@ msgstr "" "認。在位元組模式中,它們是錯誤。未知的跳脫 ASCII 字母被保留於未來使用,並且會" "被當成錯誤。" -#: ../../library/re.rst:706 +#: ../../library/re.rst:703 msgid "" "Octal escapes are included in a limited form. If the first digit is a 0, or " "if there are three octal digits, it is considered an octal escape. " @@ -1243,16 +1243,16 @@ msgstr "" "數字,它就會被當作是一個八進位跳脫。否則,它是一個群組參照。至於字串文本,八" "進位跳脫最多只能包含三個數字。" -#: ../../library/re.rst:711 +#: ../../library/re.rst:708 msgid "The ``'\\u'`` and ``'\\U'`` escape sequences have been added." msgstr "``'\\u'`` 和 ``'\\U'`` 跳脫序列已經被添加。" -#: ../../library/re.rst:714 +#: ../../library/re.rst:711 msgid "" "Unknown escapes consisting of ``'\\'`` and an ASCII letter now are errors." msgstr "由 ``'\\'`` 和一個 ASCII 字母組成的未知跳脫現在會是錯誤。" -#: ../../library/re.rst:717 +#: ../../library/re.rst:714 msgid "" "The :samp:`'\\\\N\\\\{{name}\\\\}'` escape sequence has been added. As in " "string literals, it expands to the named Unicode character (e.g. ``'\\N{EM " @@ -1261,11 +1261,11 @@ msgstr "" ":samp:`'\\\\N\\\\{{name}\\\\}'` 跳脫序列已經被添加。如同字串文本,它會展開成" "命名的 Unicode 字元(如 ``'\\N{EM DASH}'``)。" -#: ../../library/re.rst:725 -msgid "Module Contents" +#: ../../library/re.rst:722 +msgid "Module contents" msgstr "模組內容" -#: ../../library/re.rst:727 +#: ../../library/re.rst:724 msgid "" "The module defines several functions, constants, and an exception. Some of " "the functions are simplified versions of the full featured methods for " @@ -1273,11 +1273,11 @@ msgid "" "compiled form." msgstr "" -#: ../../library/re.rst:734 +#: ../../library/re.rst:731 msgid "Flags" msgstr "旗標" -#: ../../library/re.rst:736 +#: ../../library/re.rst:733 msgid "" "Flag constants are now instances of :class:`RegexFlag`, which is a subclass " "of :class:`enum.IntFlag`." @@ -1285,16 +1285,16 @@ msgstr "" "Flag 常數現在是 :class:`RegexFlag` 的實例,其為 :class:`enum.IntFlag` 的子類" "別。" -#: ../../library/re.rst:743 +#: ../../library/re.rst:740 msgid "" "An :class:`enum.IntFlag` class containing the regex options listed below." msgstr "包含下列正規表示式選項的一個 :class:`enum.IntFlag` 類別。" -#: ../../library/re.rst:745 +#: ../../library/re.rst:742 msgid "- added to ``__all__``" msgstr "- 新增至 ``__all__``" -#: ../../library/re.rst:750 +#: ../../library/re.rst:747 msgid "" "Make ``\\w``, ``\\W``, ``\\b``, ``\\B``, ``\\d``, ``\\D``, ``\\s`` and " "``\\S`` perform ASCII-only matching instead of full Unicode matching. This " @@ -1305,11 +1305,11 @@ msgstr "" "執行僅限 ASCII 的匹配,而不是完整的 Unicode 匹配。這只對 Unicode(字串)模式" "有意義,並且在位元組模式中會被忽略。" -#: ../../library/re.rst:754 +#: ../../library/re.rst:751 msgid "Corresponds to the inline flag ``(?a)``." msgstr "對應到內嵌旗標 ``(?a)``。" -#: ../../library/re.rst:758 +#: ../../library/re.rst:755 msgid "" "The :py:const:`~re.U` flag still exists for backward compatibility, but is " "redundant in Python 3 since matches are Unicode by default for ``str`` " @@ -1320,15 +1320,15 @@ msgstr "" "為對於 ``str`` 模式,匹配預設是 Unicode,並且不允許位元組模式進行 Unicode 匹" "配。:py:const:`~re.UNICODE` 和內嵌旗標 ``(?u)`` 也是類似的冗餘。" -#: ../../library/re.rst:767 +#: ../../library/re.rst:764 msgid "Display debug information about compiled expression." msgstr "顯示關於已編譯表示式的偵錯資訊。" -#: ../../library/re.rst:769 +#: ../../library/re.rst:766 msgid "No corresponding inline flag." msgstr "沒有對應的內嵌旗標。" -#: ../../library/re.rst:775 +#: ../../library/re.rst:772 msgid "" "Perform case-insensitive matching; expressions like ``[A-Z]`` will also " "match lowercase letters. Full Unicode matching (such as ``Ü`` matching " @@ -1341,11 +1341,11 @@ msgstr "" "ASCII` 旗標來停用非 ASCII 的匹配。除非也使用了 :py:const:`~re.LOCALE` 旗標," "否則目前的區域設定不會改變這個旗標的效果。" -#: ../../library/re.rst:783 +#: ../../library/re.rst:780 msgid "Corresponds to the inline flag ``(?i)``." msgstr "對應到內嵌旗標 ``(?i)``。" -#: ../../library/re.rst:785 +#: ../../library/re.rst:782 msgid "" "Note that when the Unicode patterns ``[a-z]`` or ``[A-Z]`` are used in " "combination with the :const:`IGNORECASE` flag, they will match the 52 ASCII " @@ -1361,7 +1361,7 @@ msgstr "" "丁小寫長 s)和 'K' (U+212A,開爾文符號)。如果使用了 :py:const:`~re.ASCII` " "旗標,則只會匹配字母 'a' 到 'z' 和 'A' 到 'Z'。" -#: ../../library/re.rst:796 +#: ../../library/re.rst:793 msgid "" "Make ``\\w``, ``\\W``, ``\\b``, ``\\B`` and case-insensitive matching " "dependent on the current locale. This flag can be used only with bytes " @@ -1370,11 +1370,11 @@ msgstr "" "使 ``\\w``、``\\W``、``\\b``、``\\B`` 和不區分大小寫的匹配依賴於目前的區域設" "定。這個旗標只能用在位元組模式中。" -#: ../../library/re.rst:800 +#: ../../library/re.rst:797 msgid "Corresponds to the inline flag ``(?L)``." msgstr "對應到內嵌旗標 ``(?L)``。" -#: ../../library/re.rst:804 +#: ../../library/re.rst:801 msgid "" "This flag is discouraged; consider Unicode matching instead. The locale " "mechanism is very unreliable as it only handles one \"culture\" at a time " @@ -1386,7 +1386,7 @@ msgstr "" "次只處理一種「文化」,並且只適用於 8 位元的區域設定。Unicode 匹配在 Unicode" "(字串)模式中預設是啟用的,並且能夠處理不同的區域設定和語言。" -#: ../../library/re.rst:811 +#: ../../library/re.rst:808 msgid "" ":py:const:`~re.LOCALE` can be used only with bytes patterns and is not " "compatible with :py:const:`~re.ASCII`." @@ -1394,7 +1394,7 @@ msgstr "" ":py:const:`~re.LOCALE` 只能用在位元組模式中,並且與 :py:const:`~re.ASCII` 不" "相容。" -#: ../../library/re.rst:815 +#: ../../library/re.rst:812 msgid "" "Compiled regular expression objects with the :py:const:`~re.LOCALE` flag no " "longer depend on the locale at compile time. Only the locale at matching " @@ -1403,7 +1403,7 @@ msgstr "" "使用 :py:const:`~re.LOCALE` 旗標的已編譯正規表示式物件不再依賴於編譯時的區域" "設定。只有匹配時的區域設定會影響匹配的結果。" -#: ../../library/re.rst:824 +#: ../../library/re.rst:821 msgid "" "When specified, the pattern character ``'^'`` matches at the beginning of " "the string and at the beginning of each line (immediately following each " @@ -1418,11 +1418,11 @@ msgstr "" "符號之前)匹配。預設情況下,``'^'`` 只會在字串的開頭匹配,而 ``'$'`` 只會在字" "串的結尾以及字串結尾(如果有的話)緊接在換行符號之前匹配。" -#: ../../library/re.rst:831 +#: ../../library/re.rst:828 msgid "Corresponds to the inline flag ``(?m)``." msgstr "對應到內嵌旗標 ``(?m)``。" -#: ../../library/re.rst:835 +#: ../../library/re.rst:832 msgid "" "Indicates no flag being applied, the value is ``0``. This flag may be used " "as a default value for a function keyword argument or as a base value that " @@ -1433,15 +1433,15 @@ msgstr "" "是作為一個基底值,將會有條件地與其他旗標進行 OR 運算。作為預設值使用的範" "例: ::" -#: ../../library/re.rst:840 +#: ../../library/re.rst:837 msgid "" -"def myfunc(text, flag=re.NOFLAG):\n" -" return re.match(text, flag)" +"def myfunc(pattern, text, flag=re.NOFLAG):\n" +" return re.search(pattern, text, flag)" msgstr "" -"def myfunc(text, flag=re.NOFLAG):\n" -" return re.match(text, flag)" +"def myfunc(pattern, text, flag=re.NOFLAG):\n" +" return re.search(pattern, text, flag)" -#: ../../library/re.rst:848 +#: ../../library/re.rst:845 msgid "" "Make the ``'.'`` special character match any character at all, including a " "newline; without this flag, ``'.'`` will match anything *except* a newline." @@ -1449,11 +1449,11 @@ msgstr "" "使 ``'.'`` 特殊字元能夠匹配任何字元,包括換行符號;如果沒有這個旗標,``'.'`` " "只會匹配除了換行符號以外的任何字元。" -#: ../../library/re.rst:851 +#: ../../library/re.rst:848 msgid "Corresponds to the inline flag ``(?s)``." msgstr "對應到內嵌旗標 ``(?s)``。" -#: ../../library/re.rst:857 +#: ../../library/re.rst:854 msgid "" "In Python 3, Unicode characters are matched by default for ``str`` patterns. " "This flag is therefore redundant with **no effect** and is only kept for " @@ -1462,12 +1462,12 @@ msgstr "" "在 Python 3 中,Unicode 字元在 ``str`` 模式中預設會被匹配。因此這個旗標是多餘" "的,**沒有任何效果**,並且僅為了向後相容而保留。" -#: ../../library/re.rst:862 +#: ../../library/re.rst:859 msgid "" "See :py:const:`~re.ASCII` to restrict matching to ASCII characters instead." msgstr "請參閱 :py:const:`~re.ASCII` 以將匹配限制為 ASCII 字元。" -#: ../../library/re.rst:869 +#: ../../library/re.rst:866 msgid "" "This flag allows you to write regular expressions that look nicer and are " "more readable by allowing you to visually separate logical sections of the " @@ -1485,13 +1485,13 @@ msgstr "" "如,``(? :`` 和 ``* ?`` 是不允許的。當一行包含一個不在字元類別中且前面沒有未" "跳脫反斜線的 ``#`` 時,從最左邊的這個 ``#`` 到行尾的所有字元都會被忽略。" -#: ../../library/re.rst:879 +#: ../../library/re.rst:876 msgid "" "This means that the two following regular expression objects that match a " "decimal number are functionally equal::" msgstr "這表示下面兩個匹配十進位數字的正規表示式物件在功能上是相等的: ::" -#: ../../library/re.rst:882 +#: ../../library/re.rst:879 msgid "" "a = re.compile(r\"\"\"\\d + # the integral part\n" " \\. # the decimal point\n" @@ -1503,27 +1503,28 @@ msgstr "" " \\d * # 一些小數位\"\"\", re.X)\n" "b = re.compile(r\"\\d+\\.\\d*\")" -#: ../../library/re.rst:887 +#: ../../library/re.rst:884 msgid "Corresponds to the inline flag ``(?x)``." msgstr "對應到內嵌旗標 ``(?x)``。" -#: ../../library/re.rst:891 +#: ../../library/re.rst:888 msgid "Functions" msgstr "函式" -#: ../../library/re.rst:895 +#: ../../library/re.rst:892 msgid "" "Compile a regular expression pattern into a :ref:`regular expression object " "`, which can be used for matching using its :func:`~Pattern." -"match`, :func:`~Pattern.search` and other methods, described below." +"prefixmatch`, :func:`~Pattern.search`, and other methods, described below." msgstr "" -"將正規表示式模式編譯成\\ :ref:`正規表示式物件 `,可以使用它的 :" -"func:`~Pattern.match`、:func:`~Pattern.search` 等方法來匹配,如下所述。" +"將正規表示式模式編譯成\\ :ref:`正規表示式物件 `,可以使用它" +"的 :func:`~Pattern.prefixmatch`、:func:`~Pattern.search` 等方法來匹配,如下所" +"述。" -#: ../../library/re.rst:900 ../../library/re.rst:932 ../../library/re.rst:950 -#: ../../library/re.rst:961 ../../library/re.rst:1007 ../../library/re.rst:1041 -#: ../../library/re.rst:1056 ../../library/re.rst:1118 -#: ../../library/re.rst:1153 +#: ../../library/re.rst:897 ../../library/re.rst:929 ../../library/re.rst:949 +#: ../../library/re.rst:977 ../../library/re.rst:1023 ../../library/re.rst:1057 +#: ../../library/re.rst:1072 ../../library/re.rst:1134 +#: ../../library/re.rst:1169 msgid "" "The expression's behaviour can be modified by specifying a *flags* value. " "Values can be any of the `flags`_ variables, combined using bitwise OR (the " @@ -1532,27 +1533,27 @@ msgstr "" "可以透過指定 *flags* 值來修改正規表示式的行為,值可以是任何 `flags`_ 變數,使" "用位元 OR(bitwise OR、``|`` 運算子)組合。" -#: ../../library/re.rst:904 +#: ../../library/re.rst:901 msgid "The sequence ::" msgstr "序列為: ::" -#: ../../library/re.rst:906 +#: ../../library/re.rst:903 msgid "" "prog = re.compile(pattern)\n" -"result = prog.match(string)" +"result = prog.search(string)" msgstr "" "prog = re.compile(pattern)\n" -"result = prog.match(string)" +"result = prog.search(string)" -#: ../../library/re.rst:909 +#: ../../library/re.rst:906 msgid "is equivalent to ::" msgstr "等價於: ::" -#: ../../library/re.rst:911 -msgid "result = re.match(pattern, string)" -msgstr "result = re.match(pattern, string)" +#: ../../library/re.rst:908 +msgid "result = re.search(pattern, string)" +msgstr "result = re.search(pattern, string)" -#: ../../library/re.rst:913 +#: ../../library/re.rst:910 msgid "" "but using :func:`re.compile` and saving the resulting regular expression " "object for reuse is more efficient when the expression will be used several " @@ -1561,7 +1562,7 @@ msgstr "" "但是當表示式在單一程式中多次使用時,使用 :func:`re.compile` 並保存產生的正規" "表示式物件以供重複使用會更有效率。" -#: ../../library/re.rst:919 +#: ../../library/re.rst:916 msgid "" "The compiled versions of the most recent patterns passed to :func:`re." "compile` and the module-level matching functions are cached, so programs " @@ -1571,7 +1572,7 @@ msgstr "" "傳遞給 :func:`re.compile` 之最新模式的編譯版本和模組層級匹配函式都會被快取," "因此一次僅使用幾個正規表示式的程式不必去擔心編譯正規表示式。" -#: ../../library/re.rst:927 +#: ../../library/re.rst:924 msgid "" "Scan through *string* looking for the first location where the regular " "expression *pattern* produces a match, and return a corresponding :class:" @@ -1583,7 +1584,7 @@ msgstr "" "class:`~re.Match`。如果字串中沒有與模式匹配的位置則回傳 ``None``;請注意,這" "與在字串中的某個點查找零長度匹配不同。" -#: ../../library/re.rst:939 +#: ../../library/re.rst:936 msgid "" "If zero or more characters at the beginning of *string* match the regular " "expression *pattern*, return a corresponding :class:`~re.Match`. Return " @@ -1594,15 +1595,15 @@ msgstr "" "class:`~re.Match`。如果字串與模式不匹配,則回傳 ``None``;請注意,這與零長度" "匹配不同。" -#: ../../library/re.rst:944 +#: ../../library/re.rst:943 msgid "" -"Note that even in :const:`MULTILINE` mode, :func:`re.match` will only match " -"at the beginning of the string and not at the beginning of each line." +"Even in :const:`MULTILINE` mode, this will only match at the beginning of " +"the string and not at the beginning of each line." msgstr "" -"請注意,即使在 :const:`MULTILINE` 模式 (mode) 下,:func:`re.match` 只會於字串" -"的開頭匹配,而非每行的開頭。" +"即使在 :const:`MULTILINE` 模式 (mode) 下,這也只會於字串的開頭匹配,而非每行" +"的開頭。" -#: ../../library/re.rst:947 +#: ../../library/re.rst:946 msgid "" "If you want to locate a match anywhere in *string*, use :func:`search` " "instead (see also :ref:`search-vs-match`)." @@ -1610,7 +1611,24 @@ msgstr "" "如果你想在 *string* 中的任何位置找到匹配項,請使用 :func:`search`\\ (另請參" "閱 :ref:`search-vs-match`)。" -#: ../../library/re.rst:957 +#: ../../library/re.rst:953 +msgid "" +"This function now has two names and has long been known as :func:`~re." +"match`. Use that name when you need to retain compatibility with older " +"Python versions." +msgstr "" + +#: ../../library/re.rst:961 +msgid "" +":func:`~re.match` has been :term:`soft deprecated` in favor of the " +"alternate :func:`~re.prefixmatch` name of this API which is more explicitly " +"descriptive. Use it to better express intent. The norm in other languages " +"and regular expression implementations is to use the term *match* to refer " +"to the behavior of what Python has always called :func:`~re.search`. See :" +"ref:`prefixmatch-vs-match`." +msgstr "" + +#: ../../library/re.rst:973 msgid "" "If the whole *string* matches the regular expression *pattern*, return a " "corresponding :class:`~re.Match`. Return ``None`` if the string does not " @@ -1619,7 +1637,7 @@ msgstr "" "如果整個 *string* 與正規表示式 *pattern* 匹配,則回傳對應的 :class:`~re." "Match`。如果字串與模式不匹配,則回傳 ``None``;請注意,這與零長度匹配不同。" -#: ../../library/re.rst:970 +#: ../../library/re.rst:986 msgid "" "Split *string* by the occurrences of *pattern*. If capturing parentheses " "are used in *pattern*, then the text of all groups in the pattern are also " @@ -1631,7 +1649,7 @@ msgstr "" "中所有群組的文字也會作為結果串列的一部分回傳。如果 *maxsplit* 非零,則最多發" "生 *maxsplit* 次拆分,並且字串的其餘部分會作為串列的最終元素回傳。 ::" -#: ../../library/re.rst:976 +#: ../../library/re.rst:992 msgid "" ">>> re.split(r'\\W+', 'Words, words, words.')\n" "['Words', 'words', 'words', '']\n" @@ -1651,7 +1669,7 @@ msgstr "" ">>> re.split('[a-f]+', '0a3B9', flags=re.IGNORECASE)\n" "['0', '3', '9']" -#: ../../library/re.rst:985 +#: ../../library/re.rst:1001 msgid "" "If there are capturing groups in the separator and it matches at the start " "of the string, the result will start with an empty string. The same holds " @@ -1660,7 +1678,7 @@ msgstr "" "如果分隔符號中有捕獲群組並且它在字串的開頭匹配,則結果將以空字串開頭。這同樣" "適用於字串的結尾: ::" -#: ../../library/re.rst:989 +#: ../../library/re.rst:1005 msgid "" ">>> re.split(r'(\\W+)', '...words, words...')\n" "['', '...', 'words', ', ', 'words', '...', '']" @@ -1668,19 +1686,19 @@ msgstr "" ">>> re.split(r'(\\W+)', '...words, words...')\n" "['', '...', 'words', ', ', 'words', '...', '']" -#: ../../library/re.rst:992 +#: ../../library/re.rst:1008 msgid "" "That way, separator components are always found at the same relative indices " "within the result list." msgstr "如此一來,分隔符號元件始終可以在結果串列中的相同相對索引處找到。" -#: ../../library/re.rst:995 +#: ../../library/re.rst:1011 msgid "" "Adjacent empty matches are not possible, but an empty match can occur " "immediately after a non-empty match." msgstr "" -#: ../../library/re.rst:998 +#: ../../library/re.rst:1014 msgid "" ">>> re.split(r'\\b', 'Words, words, words.')\n" "['', 'Words', ', ', 'words', ', ', 'words', '.']\n" @@ -1698,16 +1716,16 @@ msgstr "" "['', '...', '', '', 'w', '', 'o', '', 'r', '', 'd', '', 's', '...', '', '', " "'']" -#: ../../library/re.rst:1011 ../../library/re.rst:1122 +#: ../../library/re.rst:1027 ../../library/re.rst:1138 msgid "Added the optional flags argument." msgstr "新增可選旗標引數。" -#: ../../library/re.rst:1014 +#: ../../library/re.rst:1030 msgid "" "Added support of splitting on a pattern that could match an empty string." msgstr "新增了對可以匹配空字串之模式進行拆分的支援。" -#: ../../library/re.rst:1017 +#: ../../library/re.rst:1033 msgid "" "Passing *maxsplit* and *flags* as positional arguments is deprecated. In " "future Python versions they will be :ref:`keyword-only parameters `。" -#: ../../library/re.rst:1025 +#: ../../library/re.rst:1041 msgid "" "Return all non-overlapping matches of *pattern* in *string*, as a list of " "strings or tuples. The *string* is scanned left-to-right, and matches are " @@ -1725,7 +1743,7 @@ msgstr "" "以字串或元組串列的形式回傳 *string* 中 *pattern* 的所有非重疊匹配項。從左到右" "掃描 *string*,並按找到的順序回傳符合項目。結果中會包含空匹配項。" -#: ../../library/re.rst:1029 +#: ../../library/re.rst:1045 msgid "" "The result depends on the number of capturing groups in the pattern. If " "there are no groups, return a list of strings matching the whole pattern. " @@ -1738,11 +1756,11 @@ msgstr "" "列。如果恰好存在一個群組,則回傳與該群組匹配的字串串列。如果存在多個群組,則" "回傳與群組匹配的字串元組串列。非捕獲群組則不影響結果的形式。" -#: ../../library/re.rst:1045 ../../library/re.rst:1060 +#: ../../library/re.rst:1061 ../../library/re.rst:1076 msgid "Non-empty matches can now start just after a previous empty match." msgstr "非空匹配現在可以剛好在前一個空匹配的後面開始。" -#: ../../library/re.rst:1051 +#: ../../library/re.rst:1067 msgid "" "Return an :term:`iterator` yielding :class:`~re.Match` objects over all non-" "overlapping matches for the RE *pattern* in *string*. The *string* is " @@ -1753,7 +1771,7 @@ msgstr "" "yield :class:`~re.Match` 物件。從左到右掃描 *string*,並按找到的順序回傳匹配" "項目。結果中包含空匹配項。" -#: ../../library/re.rst:1066 +#: ../../library/re.rst:1082 msgid "" "Return the string obtained by replacing the leftmost non-overlapping " "occurrences of *pattern* in *string* by the replacement *repl*. If the " @@ -1773,7 +1791,7 @@ msgstr "" "留以供將來使用並被視為錯誤。其他未知跳脫符例如 ``\\&`` 會被單獨保留。例如 " "``\\6`` 的反向參照將被替換為模式中第 6 組匹配的子字串。例如: ::" -#: ../../library/re.rst:1077 +#: ../../library/re.rst:1093 msgid "" ">>> re.sub(r'def\\s+([a-zA-Z_][a-zA-Z_0-9]*)\\s*\\(\\s*\\):',\n" "... r'static PyObject*\\npy_\\1(void)\\n{',\n" @@ -1785,7 +1803,7 @@ msgstr "" "... 'def myfunc():')\n" "'static PyObject*\\npy_myfunc(void)\\n{'" -#: ../../library/re.rst:1082 +#: ../../library/re.rst:1098 msgid "" "If *repl* is a function, it is called for every non-overlapping occurrence " "of *pattern*. The function takes a single :class:`~re.Match` argument, and " @@ -1794,7 +1812,7 @@ msgstr "" "如果 *repl* 是一個函式,則 *pattern* 的每個不重疊出現之處都會呼叫它。此函式接" "收單一 :class:`~re.Match` 引數,並回傳替換字串。例如: ::" -#: ../../library/re.rst:1086 +#: ../../library/re.rst:1102 msgid "" ">>> def dashrepl(matchobj):\n" "... if matchobj.group(0) == '-': return ' '\n" @@ -1816,11 +1834,11 @@ msgstr "" "IGNORECASE)\n" "'Baked Beans & Spam'" -#: ../../library/re.rst:1095 +#: ../../library/re.rst:1111 msgid "The pattern may be a string or a :class:`~re.Pattern`." msgstr "此模式可以是字串或 :class:`~re.Pattern`。" -#: ../../library/re.rst:1097 +#: ../../library/re.rst:1113 msgid "" "The optional argument *count* is the maximum number of pattern occurrences " "to be replaced; *count* must be a non-negative integer. If omitted or zero, " @@ -1829,14 +1847,14 @@ msgstr "" "可選引數 *count* 是要替換的模式出現的最大次數;*count* 必須是非負整數。如果省" "略或為零,則所有出現的內容都將被替換。" -#: ../../library/re.rst:1101 +#: ../../library/re.rst:1117 msgid "" "Adjacent empty matches are not possible, but an empty match can occur " "immediately after a non-empty match. As a result, ``sub('x*', '-', 'abxd')`` " "returns ``'-a-b--d-'`` instead of ``'-a-b-d-'``." msgstr "" -#: ../../library/re.rst:1108 +#: ../../library/re.rst:1124 msgid "" "In string-type *repl* arguments, in addition to the character escapes and " "backreferences described above, ``\\g`` will use the substring matched " @@ -1855,18 +1873,18 @@ msgstr "" "群組 20 的參照,而不是對後面跟著字面字元 ``'0'`` 的群組 2 的參照。反向參照 " "``\\g<0>`` 會取代以 RE 所匹配到的整個子字串。" -#: ../../library/re.rst:1125 ../../library/re.rst:1408 +#: ../../library/re.rst:1141 ../../library/re.rst:1443 msgid "Unmatched groups are replaced with an empty string." msgstr "不匹配的群組將被替換為空字串。" -#: ../../library/re.rst:1128 +#: ../../library/re.rst:1144 msgid "" "Unknown escapes in *pattern* consisting of ``'\\'`` and an ASCII letter now " "are errors." msgstr "" "在由 ``'\\'`` 和一個 ASCII 字母組成之 *pattern* 中的未知跳脫符現在為錯誤。" -#: ../../library/re.rst:1132 +#: ../../library/re.rst:1148 msgid "" "Unknown escapes in *repl* consisting of ``'\\'`` and an ASCII letter now are " "errors. An empty match can occur immediately after a non-empty match." @@ -1874,7 +1892,7 @@ msgstr "" "由 ``'\\'`` 和一個 ASCII 字母組成之 *repl* 中的未知跳脫符現在為錯誤。非空匹配" "後可以緊接著出現空匹配。" -#: ../../library/re.rst:1137 +#: ../../library/re.rst:1153 msgid "" "Group *id* can only contain ASCII digits. In :class:`bytes` replacement " "strings, group *name* can only contain bytes in the ASCII range " @@ -1883,7 +1901,7 @@ msgstr "" "群組 *id* 只能包含 ASCII 數字。在 :class:`bytes` 替換字串中,群組 *name* 只能" "包含 ASCII 範圍內的位元組 (``b'\\x00'``-``b'\\x7f'``)。" -#: ../../library/re.rst:1142 +#: ../../library/re.rst:1158 msgid "" "Passing *count* and *flags* as positional arguments is deprecated. In future " "Python versions they will be :ref:`keyword-only parameters `。" -#: ../../library/re.rst:1150 +#: ../../library/re.rst:1166 msgid "" "Perform the same operation as :func:`sub`, but return a tuple ``(new_string, " "number_of_subs_made)``." @@ -1900,7 +1918,7 @@ msgstr "" "執行與 :func:`sub` 相同的操作,但回傳一個元組 ``(new_string, " "number_of_subs_made)``。" -#: ../../library/re.rst:1160 +#: ../../library/re.rst:1176 msgid "" "Escape special characters in *pattern*. This is useful if you want to match " "an arbitrary literal string that may have regular expression metacharacters " @@ -1909,7 +1927,7 @@ msgstr "" "對 *pattern* 中的特殊字元進行跳脫。如果你想要匹配其中可能包含正規表示式元字" "元 (metacharacter) 的任何文本字串,這會非常有用。例如: ::" -#: ../../library/re.rst:1164 +#: ../../library/re.rst:1180 msgid "" ">>> print(re.escape('https://www.python.org'))\n" "https://www\\.python\\.org\n" @@ -1935,7 +1953,7 @@ msgstr "" ">>> print('|'.join(map(re.escape, sorted(operators, reverse=True))))\n" "/|\\-|\\+|\\*\\*|\\*" -#: ../../library/re.rst:1175 +#: ../../library/re.rst:1191 msgid "" "This function must not be used for the replacement string in :func:`sub` " "and :func:`subn`, only backslashes should be escaped. For example::" @@ -1943,7 +1961,7 @@ msgstr "" "此函式不得用於 :func:`sub` 和 :func:`subn` 中的替換字串,僅應跳脫反斜線。例" "如: ::" -#: ../../library/re.rst:1178 +#: ../../library/re.rst:1194 msgid "" ">>> digits_re = r'\\d+'\n" ">>> sample = '/usr/sbin/sendmail - 0 errors, 12 warnings'\n" @@ -1955,11 +1973,11 @@ msgstr "" ">>> print(re.sub(digits_re, digits_re.replace('\\\\', r'\\\\'), sample))\n" "/usr/sbin/sendmail - \\d+ errors, \\d+ warnings" -#: ../../library/re.rst:1183 +#: ../../library/re.rst:1199 msgid "The ``'_'`` character is no longer escaped." msgstr "``'_'`` 字元不再被跳脫。" -#: ../../library/re.rst:1186 +#: ../../library/re.rst:1202 msgid "" "Only characters that can have special meaning in a regular expression are " "escaped. As a result, ``'!'``, ``'\"'``, ``'%'``, ``\"'\"``, ``','``, " @@ -1967,15 +1985,15 @@ msgid "" "are no longer escaped." msgstr "" -#: ../../library/re.rst:1195 +#: ../../library/re.rst:1211 msgid "Clear the regular expression cache." msgstr "清除正規表示式快取。" -#: ../../library/re.rst:1199 +#: ../../library/re.rst:1215 msgid "Exceptions" msgstr "例外" -#: ../../library/re.rst:1203 +#: ../../library/re.rst:1219 msgid "" "Exception raised when a string passed to one of the functions here is not a " "valid regular expression (for example, it might contain unmatched " @@ -1988,52 +2006,52 @@ msgstr "" "或在編譯或匹配期間發生某些其他錯誤時,將引發例外。如果字串不包含模式匹配項," "則絕不是錯誤。``PatternError`` 實例具有以下附加屬性:" -#: ../../library/re.rst:1211 +#: ../../library/re.rst:1227 msgid "The unformatted error message." msgstr "未格式化的錯誤訊息。" -#: ../../library/re.rst:1215 +#: ../../library/re.rst:1231 msgid "The regular expression pattern." msgstr "正規表示式模式。" -#: ../../library/re.rst:1219 +#: ../../library/re.rst:1235 msgid "The index in *pattern* where compilation failed (may be ``None``)." msgstr "*pattern* 中編譯失敗的索引(可能是 ``None``)。" -#: ../../library/re.rst:1223 +#: ../../library/re.rst:1239 msgid "The line corresponding to *pos* (may be ``None``)." msgstr "對應 *pos* 的列(可能是 ``None``)。" -#: ../../library/re.rst:1227 +#: ../../library/re.rst:1243 msgid "The column corresponding to *pos* (may be ``None``)." msgstr "對應 *pos* 的欄(可能是 ``None``)。" -#: ../../library/re.rst:1229 +#: ../../library/re.rst:1245 msgid "Added additional attributes." msgstr "新增額外屬性。" -#: ../../library/re.rst:1232 +#: ../../library/re.rst:1248 msgid "" "``PatternError`` was originally named ``error``; the latter is kept as an " "alias for backward compatibility." msgstr "" "``PatternError`` 最初被命名為 ``error``;後者為了向後相容性而被保留為別名。" -#: ../../library/re.rst:1239 -msgid "Regular Expression Objects" +#: ../../library/re.rst:1255 +msgid "Regular expression objects" msgstr "正規表示式物件" -#: ../../library/re.rst:1243 +#: ../../library/re.rst:1259 msgid "Compiled regular expression object returned by :func:`re.compile`." msgstr "由 :func:`re.compile` 回傳的已編譯正規表示式物件。" -#: ../../library/re.rst:1245 +#: ../../library/re.rst:1261 msgid "" "Patterns are :ref:`generic ` over the type of string they handle (:" "class:`str` or :class:`bytes`)." msgstr "" -#: ../../library/re.rst:1248 +#: ../../library/re.rst:1264 msgid "" ":py:class:`re.Pattern` supports ``[]`` to indicate a Unicode (str) or bytes " "pattern. See :ref:`types-genericalias`." @@ -2041,7 +2059,7 @@ msgstr "" ":py:class:`re.Pattern` 支援 ``[]`` 以表示 Unicode(字串)或位元組模式。請參" "閱 :ref:`types-genericalias`。" -#: ../../library/re.rst:1254 +#: ../../library/re.rst:1270 msgid "" "Scan through *string* looking for the first location where this regular " "expression produces a match, and return a corresponding :class:`~re.Match`. " @@ -2053,7 +2071,7 @@ msgstr "" "`~re.Match`。如果字串中沒有與模式匹配的位置則回傳 ``None``;請注意,這與在字" "串中的某個點查找零長度匹配不同。" -#: ../../library/re.rst:1259 +#: ../../library/re.rst:1275 msgid "" "The optional second parameter *pos* gives an index in the string where the " "search is to start; it defaults to ``0``. This is not completely equivalent " @@ -2065,7 +2083,7 @@ msgstr "" "``0``。這並不完全等同於對字串進行切片;``'^'`` 模式字元會在字串的實際開頭和換" "行之後的位置匹配,但不一定是在要開始搜尋的索引處。" -#: ../../library/re.rst:1265 +#: ../../library/re.rst:1281 msgid "" "The optional parameter *endpos* limits how far the string will be searched; " "it will be as if the string is *endpos* characters long, so only the " @@ -2080,7 +2098,7 @@ msgstr "" "式物件,則 ``rx.search(string, 0, 50)`` 等價於 ``rx.search(string[:50], " "0)``。 ::" -#: ../../library/re.rst:1272 +#: ../../library/re.rst:1288 msgid "" ">>> pattern = re.compile(\"d\")\n" ">>> pattern.search(\"dog\") # Match at index 0\n" @@ -2092,7 +2110,7 @@ msgstr "" "\n" ">>> pattern.search(\"dog\", 1) # 無匹配;搜尋不包含 \"d\"" -#: ../../library/re.rst:1280 +#: ../../library/re.rst:1296 msgid "" "If zero or more characters at the *beginning* of *string* match this regular " "expression, return a corresponding :class:`~re.Match`. Return ``None`` if " @@ -2103,7 +2121,15 @@ msgstr "" "應的 :class:`~re.Match`。如果字串與模式不匹配,則回傳 ``None``;請注意,這與" "零長度匹配不同。" -#: ../../library/re.rst:1285 ../../library/re.rst:1303 +#: ../../library/re.rst:1301 +msgid "" +"Note that even in :const:`MULTILINE` mode, this will only match at the " +"beginning of the string and not at the beginning of each line." +msgstr "" +"請注意,即使在 :const:`MULTILINE` 模式 (mode) 下,這也只會於字串的開頭匹配," +"而非每行的開頭。" + +#: ../../library/re.rst:1304 ../../library/re.rst:1339 msgid "" "The optional *pos* and *endpos* parameters have the same meaning as for the :" "meth:`~Pattern.search` method. ::" @@ -2111,22 +2137,23 @@ msgstr "" "可選的 *pos* 和 *endpos* 參數與 :meth:`~Pattern.search` 方法中的參數具有相同" "的意義。 ::" -#: ../../library/re.rst:1288 +#: ../../library/re.rst:1307 msgid "" ">>> pattern = re.compile(\"o\")\n" -">>> pattern.match(\"dog\") # No match as \"o\" is not at the start of " -"\"dog\".\n" -">>> pattern.match(\"dog\", 1) # Match as \"o\" is the 2nd character of " -"\"dog\".\n" +">>> pattern.prefixmatch(\"dog\") # No match as \"o\" is not at the start " +"of \"dog\".\n" +">>> pattern.prefixmatch(\"dog\", 1) # Match as \"o\" is the 2nd character " +"of \"dog\".\n" "" msgstr "" ">>> pattern = re.compile(\"o\")\n" -">>> pattern.match(\"dog\") # 無匹配,因為 \"o\" 不在 \"dog\" 的開頭。\n" -">>> pattern.match(\"dog\", 1) # 匹配,因為 \"o\" 是 \"dog\" 的第二個字" +">>> pattern.prefixmatch(\"dog\") # 無匹配,因為 \"o\" 不在 \"dog\" 的開" +"頭。\n" +">>> pattern.prefixmatch(\"dog\", 1) # 匹配,因為 \"o\" 是 \"dog\" 的第二個字" "元。\n" "" -#: ../../library/re.rst:1293 +#: ../../library/re.rst:1312 msgid "" "If you want to locate a match anywhere in *string*, use :meth:`~Pattern." "search` instead (see also :ref:`search-vs-match`)." @@ -2134,7 +2161,24 @@ msgstr "" "如果你想在 *string* 中的任何位置找到匹配,請改用 :meth:`~Pattern.search`\\ " "(另請參閱 :ref:`search-vs-match`)。" -#: ../../library/re.rst:1299 +#: ../../library/re.rst:1315 +msgid "" +"This method now has two names and has long been known as :meth:`~Pattern." +"match`. Use that name when you need to retain compatibility with older " +"Python versions." +msgstr "" + +#: ../../library/re.rst:1323 +msgid "" +":meth:`~Pattern.match` has been :term:`soft deprecated` in favor of the " +"alternate :meth:`~Pattern.prefixmatch` name of this API which is more " +"explicitly descriptive. Use it to better express intent. The norm in other " +"languages and regular expression implementations is to use the term *match* " +"to refer to the behavior of what Python has always called :meth:`~Pattern." +"search`. See :ref:`prefixmatch-vs-match`." +msgstr "" + +#: ../../library/re.rst:1335 msgid "" "If the whole *string* matches this regular expression, return a " "corresponding :class:`~re.Match`. Return ``None`` if the string does not " @@ -2143,7 +2187,7 @@ msgstr "" "如果整個 *string* 與此正規表示式匹配,則回傳對應的 :class:`~re.Match`。如果字" "串與模式不匹配,則回傳 ``None``;請注意,這與零長度匹配不同。" -#: ../../library/re.rst:1306 +#: ../../library/re.rst:1342 msgid "" ">>> pattern = re.compile(\"o[gh]\")\n" ">>> pattern.fullmatch(\"dog\") # No match as \"o\" is not at the start " @@ -2160,11 +2204,11 @@ msgstr "" ">>> pattern.fullmatch(\"doggie\", 1, 3) # 在給定限制內匹配。\n" "" -#: ../../library/re.rst:1317 +#: ../../library/re.rst:1353 msgid "Identical to the :func:`split` function, using the compiled pattern." msgstr "和 :func:`split` 函式相同,使用已編譯的模式。" -#: ../../library/re.rst:1322 +#: ../../library/re.rst:1358 msgid "" "Similar to the :func:`findall` function, using the compiled pattern, but " "also accepts optional *pos* and *endpos* parameters that limit the search " @@ -2173,7 +2217,7 @@ msgstr "" "類似於 :func:`findall` 函式,使用已編譯的模式,但也接受可選的 *pos* 和 " "*endpos* 參數,這些參數會像 :meth:`search` 一樣限制搜尋區域。" -#: ../../library/re.rst:1329 +#: ../../library/re.rst:1365 msgid "" "Similar to the :func:`finditer` function, using the compiled pattern, but " "also accepts optional *pos* and *endpos* parameters that limit the search " @@ -2182,15 +2226,15 @@ msgstr "" "類似於 :func:`finditer` 函式,使用已編譯的模式,但也接受可選的 *pos* 和 " "*endpos* 參數,這些參數會像 :meth:`search` 一樣限制搜尋區域。" -#: ../../library/re.rst:1336 +#: ../../library/re.rst:1372 msgid "Identical to the :func:`sub` function, using the compiled pattern." msgstr "和 :func:`sub` 函式相同,使用已編譯的模式。" -#: ../../library/re.rst:1341 +#: ../../library/re.rst:1377 msgid "Identical to the :func:`subn` function, using the compiled pattern." msgstr "和 :func:`subn` 函式相同,使用已編譯的模式。" -#: ../../library/re.rst:1346 +#: ../../library/re.rst:1382 msgid "" "The regex matching flags. This is a combination of the flags given to :func:" "`.compile`, any ``(?...)`` inline flags in the pattern, and implicit flags " @@ -2200,11 +2244,11 @@ msgstr "" "``(?...)`` 內嵌旗標以及隱含旗標(例如如果模式是 Unicode 字串則為 :py:const:" "`~re.UNICODE`)的組合。" -#: ../../library/re.rst:1353 +#: ../../library/re.rst:1389 msgid "The number of capturing groups in the pattern." msgstr "模式中捕獲群組的數量。" -#: ../../library/re.rst:1358 +#: ../../library/re.rst:1394 msgid "" "A dictionary mapping any symbolic group names defined by ``(?P)`` to " "group numbers. The dictionary is empty if no symbolic groups were used in " @@ -2213,11 +2257,11 @@ msgstr "" "一個字典,將任何由 ``(?P)`` 定義的符號群組名稱對映到群組編號。如果模式中" "未使用符號群組,則字典為空。" -#: ../../library/re.rst:1365 +#: ../../library/re.rst:1401 msgid "The pattern string from which the pattern object was compiled." msgstr "從中編譯出模式物件的模式字串。" -#: ../../library/re.rst:1368 +#: ../../library/re.rst:1404 msgid "" "Added support of :func:`copy.copy` and :func:`copy.deepcopy`. Compiled " "regular expression objects are considered atomic." @@ -2225,44 +2269,42 @@ msgstr "" "新增對 :func:`copy.copy` 和 :func:`copy.deepcopy` 的支援。已編譯的正規表示式" "物件被視為不可分割的 (atomic)。" -#: ../../library/re.rst:1376 -msgid "Match Objects" +#: ../../library/re.rst:1412 +msgid "Match objects" msgstr "" -#: ../../library/re.rst:1378 +#: ../../library/re.rst:1414 msgid "" "Match objects always have a boolean value of ``True``. Since :meth:`~Pattern." "match` and :meth:`~Pattern.search` return ``None`` when there is no match, " "you can test whether there was a match with a simple ``if`` statement::" msgstr "" -#: ../../library/re.rst:1383 +#: ../../library/re.rst:1419 msgid "" -"match = re.search(pattern, string)\n" -"if match:\n" +"if match := re.search(pattern, string):\n" " process(match)" msgstr "" -"match = re.search(pattern, string)\n" -"if match:\n" +"if match := re.search(pattern, string):\n" " process(match)" -#: ../../library/re.rst:1389 +#: ../../library/re.rst:1424 msgid "Match object returned by successful ``match``\\ es and ``search``\\ es." msgstr "" -#: ../../library/re.rst:1391 +#: ../../library/re.rst:1426 msgid "" "Matches are :ref:`generic ` over the type of string which was " "matched (:class:`str` or :class:`bytes`)." msgstr "" -#: ../../library/re.rst:1394 +#: ../../library/re.rst:1429 msgid "" ":py:class:`re.Match` supports ``[]`` to indicate a Unicode (str) or bytes " "match. See :ref:`types-genericalias`." msgstr "" -#: ../../library/re.rst:1400 +#: ../../library/re.rst:1435 msgid "" "Return the string obtained by doing backslash substitution on the template " "string *template*, as done by the :meth:`~Pattern.sub` method. Escapes such " @@ -2272,7 +2314,7 @@ msgid "" "backreference ``\\g<0>`` will be replaced by the entire match." msgstr "" -#: ../../library/re.rst:1413 +#: ../../library/re.rst:1448 msgid "" "Returns one or more subgroups of the match. If there is a single argument, " "the result is a single string; if there are multiple arguments, the result " @@ -2287,20 +2329,31 @@ msgid "" "matched multiple times, the last match is returned. ::" msgstr "" -#: ../../library/re.rst:1425 +#: ../../library/re.rst:1460 msgid "" -">>> m = re.match(r\"(\\w+) (\\w+)\", \"Isaac Newton, physicist\")\n" +">>> m = re.search(r\"\\A(\\w+) (\\w+)\", \"Norwegian Blue, pining for the " +"fjords\")\n" ">>> m.group(0) # The entire match\n" -"'Isaac Newton'\n" +"'Norwegian Blue'\n" ">>> m.group(1) # The first parenthesized subgroup.\n" -"'Isaac'\n" +"'Norwegian'\n" ">>> m.group(2) # The second parenthesized subgroup.\n" -"'Newton'\n" +"'Blue'\n" ">>> m.group(1, 2) # Multiple arguments give us a tuple.\n" -"('Isaac', 'Newton')" +"('Norwegian', 'Blue')" msgstr "" +">>> m = re.search(r\"\\A(\\w+) (\\w+)\", \"Norwegian Blue, pining for the " +"fjords\")\n" +">>> m.group(0) # 整個匹配\n" +"'Norwegian Blue'\n" +">>> m.group(1) # 第一個括號子群組。\n" +"'Norwegian'\n" +">>> m.group(2) # 第二個括號子群組。\n" +"'Blue'\n" +">>> m.group(1, 2) # 多個引數會回傳一個 tuple。\n" +"('Norwegian', 'Blue')" -#: ../../library/re.rst:1435 +#: ../../library/re.rst:1470 msgid "" "If the regular expression uses the ``(?P...)`` syntax, the *groupN* " "arguments may also be strings identifying groups by their group name. If a " @@ -2308,147 +2361,164 @@ msgid "" "`IndexError` exception is raised." msgstr "" -#: ../../library/re.rst:1440 +#: ../../library/re.rst:1475 msgid "A moderately complicated example::" msgstr "" -#: ../../library/re.rst:1442 +#: ../../library/re.rst:1477 msgid "" -">>> m = re.match(r\"(?P\\w+) (?P\\w+)\", \"Malcolm " -"Reynolds\")\n" -">>> m.group('first_name')\n" -"'Malcolm'\n" -">>> m.group('last_name')\n" -"'Reynolds'" -msgstr "" -">>> m = re.match(r\"(?P\\w+) (?P\\w+)\", \"Malcolm " -"Reynolds\")\n" -">>> m.group('first_name')\n" -"'Malcolm'\n" -">>> m.group('last_name')\n" -"'Reynolds'" - -#: ../../library/re.rst:1448 +">>> m = re.search(r\"(?P\\w+) (?P\\w+)\", \"killer " +"rabbit\")\n" +">>> m.group('adjective')\n" +"'killer'\n" +">>> m.group('animal')\n" +"'rabbit'" +msgstr "" +">>> m = re.search(r\"(?P\\w+) (?P\\w+)\", \"killer " +"rabbit\")\n" +">>> m.group('adjective')\n" +"'killer'\n" +">>> m.group('animal')\n" +"'rabbit'" + +#: ../../library/re.rst:1483 msgid "Named groups can also be referred to by their index::" msgstr "" -#: ../../library/re.rst:1450 +#: ../../library/re.rst:1485 msgid "" ">>> m.group(1)\n" -"'Malcolm'\n" +"'killer'\n" ">>> m.group(2)\n" -"'Reynolds'" +"'rabbit'" msgstr "" ">>> m.group(1)\n" -"'Malcolm'\n" +"'killer'\n" ">>> m.group(2)\n" -"'Reynolds'" +"'rabbit'" -#: ../../library/re.rst:1455 +#: ../../library/re.rst:1490 msgid "If a group matches multiple times, only the last match is accessible::" msgstr "" -#: ../../library/re.rst:1457 +#: ../../library/re.rst:1492 msgid "" -">>> m = re.match(r\"(..)+\", \"a1b2c3\") # Matches 3 times.\n" -">>> m.group(1) # Returns only the last match.\n" +">>> m = re.search(r\"(..)+\", \"a1b2c3\") # Matches 3 times.\n" +">>> m.group(1) # Returns only the last match.\n" "'c3'" msgstr "" +">>> m = re.search(r\"(..)+\", \"a1b2c3\") # 匹配 3 次。\n" +">>> m.group(1) # 只回傳最後一次匹配。\n" +"'c3'" -#: ../../library/re.rst:1464 +#: ../../library/re.rst:1499 msgid "" "This is identical to ``m.group(g)``. This allows easier access to an " "individual group from a match::" msgstr "" -#: ../../library/re.rst:1467 +#: ../../library/re.rst:1502 msgid "" -">>> m = re.match(r\"(\\w+) (\\w+)\", \"Isaac Newton, physicist\")\n" +">>> m = re.search(r\"(\\w+) (\\w+)\", \"Norwegian Blue, pining for the " +"fjords\")\n" ">>> m[0] # The entire match\n" -"'Isaac Newton'\n" +"'Norwegian Blue'\n" ">>> m[1] # The first parenthesized subgroup.\n" -"'Isaac'\n" +"'Norwegian'\n" ">>> m[2] # The second parenthesized subgroup.\n" -"'Newton'" -msgstr "" - -#: ../../library/re.rst:1475 +"'Blue'" +msgstr "" +">>> m = re.search(r\"(\\w+) (\\w+)\", \"Norwegian Blue, pining for the " +"fjords\")\n" +">>> m[0] # 整個匹配\n" +"'Norwegian Blue'\n" +">>> m[1] # 第一個括號子群組。\n" +"'Norwegian'\n" +">>> m[2] # 第二個括號子群組。\n" +"'Blue'" + +#: ../../library/re.rst:1510 msgid "Named groups are supported as well::" msgstr "" -#: ../../library/re.rst:1477 +#: ../../library/re.rst:1512 msgid "" -">>> m = re.match(r\"(?P\\w+) (?P\\w+)\", \"Isaac " -"Newton\")\n" -">>> m['first_name']\n" -"'Isaac'\n" -">>> m['last_name']\n" -"'Newton'" +">>> m = re.search(r\"(?P\\w+) (?P\\w+)\", \"killer " +"rabbit\")\n" +">>> m['adjective']\n" +"'killer'\n" +">>> m['animal']\n" +"'rabbit'" msgstr "" -">>> m = re.match(r\"(?P\\w+) (?P\\w+)\", \"Isaac " -"Newton\")\n" -">>> m['first_name']\n" -"'Isaac'\n" -">>> m['last_name']\n" -"'Newton'" +">>> m = re.search(r\"(?P\\w+) (?P\\w+)\", \"killer " +"rabbit\")\n" +">>> m['adjective']\n" +"'killer'\n" +">>> m['animal']\n" +"'rabbit'" -#: ../../library/re.rst:1488 +#: ../../library/re.rst:1523 msgid "" "Return a tuple containing all the subgroups of the match, from 1 up to " "however many groups are in the pattern. The *default* argument is used for " "groups that did not participate in the match; it defaults to ``None``." msgstr "" -#: ../../library/re.rst:1492 ../../library/re.rst:1717 +#: ../../library/re.rst:1527 ../../library/re.rst:1754 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/re.rst:1494 +#: ../../library/re.rst:1529 msgid "" -">>> m = re.match(r\"(\\d+)\\.(\\d+)\", \"24.1632\")\n" +">>> m = re.search(r\"(\\d+)\\.(\\d+)\", \"24.1632\")\n" ">>> m.groups()\n" "('24', '1632')" msgstr "" -">>> m = re.match(r\"(\\d+)\\.(\\d+)\", \"24.1632\")\n" +">>> m = re.search(r\"(\\d+)\\.(\\d+)\", \"24.1632\")\n" ">>> m.groups()\n" "('24', '1632')" -#: ../../library/re.rst:1498 +#: ../../library/re.rst:1533 msgid "" "If we make the decimal place and everything after it optional, not all " "groups might participate in the match. These groups will default to " "``None`` unless the *default* argument is given::" msgstr "" -#: ../../library/re.rst:1502 +#: ../../library/re.rst:1537 msgid "" -">>> m = re.match(r\"(\\d+)\\.?(\\d+)?\", \"24\")\n" +">>> m = re.search(r\"(\\d+)\\.?(\\d+)?\", \"24\")\n" ">>> m.groups() # Second group defaults to None.\n" "('24', None)\n" ">>> m.groups('0') # Now, the second group defaults to '0'.\n" "('24', '0')" msgstr "" +">>> m = re.search(r\"(\\d+)\\.?(\\d+)?\", \"24\")\n" +">>> m.groups() # 第二個群組預設為 None。\n" +"('24', None)\n" +">>> m.groups('0') # 現在第二個群組預設為 '0'。\n" +"('24', '0')" -#: ../../library/re.rst:1511 +#: ../../library/re.rst:1546 msgid "" "Return a dictionary containing all the *named* subgroups of the match, keyed " "by the subgroup name. The *default* argument is used for groups that did " "not participate in the match; it defaults to ``None``. For example::" msgstr "" -#: ../../library/re.rst:1515 +#: ../../library/re.rst:1550 msgid "" -">>> m = re.match(r\"(?P\\w+) (?P\\w+)\", \"Malcolm " -"Reynolds\")\n" +">>> m = re.search(r\"(?P\\w+) (?P\\w+)\", \"killer " +"rabbit\")\n" ">>> m.groupdict()\n" -"{'first_name': 'Malcolm', 'last_name': 'Reynolds'}" +"{'adjective': 'killer', 'animal': 'rabbit'}" msgstr "" -">>> m = re.match(r\"(?P\\w+) (?P\\w+)\", \"Malcolm " -"Reynolds\")\n" +">>> m = re.search(r\"(?P\\w+) (?P\\w+)\", \"killer " +"rabbit\")\n" ">>> m.groupdict()\n" -"{'first_name': 'Malcolm', 'last_name': 'Reynolds'}" +"{'adjective': 'killer', 'animal': 'rabbit'}" -#: ../../library/re.rst:1523 +#: ../../library/re.rst:1558 msgid "" "Return the indices of the start and end of the substring matched by *group*; " "*group* defaults to zero (meaning the whole matched substring). Return " @@ -2457,11 +2527,11 @@ msgid "" "matched by group *g* (equivalent to ``m.group(g)``) is ::" msgstr "" -#: ../../library/re.rst:1529 +#: ../../library/re.rst:1564 msgid "m.string[m.start(g):m.end(g)]" msgstr "m.string[m.start(g):m.end(g)]" -#: ../../library/re.rst:1531 +#: ../../library/re.rst:1566 msgid "" "Note that ``m.start(group)`` will equal ``m.end(group)`` if *group* matched " "a null string. For example, after ``m = re.search('b(c?)', 'cba')``, ``m." @@ -2469,11 +2539,11 @@ msgid "" "2, and ``m.start(2)`` raises an :exc:`IndexError` exception." msgstr "" -#: ../../library/re.rst:1536 +#: ../../library/re.rst:1571 msgid "An example that will remove *remove_this* from email addresses::" msgstr "" -#: ../../library/re.rst:1538 +#: ../../library/re.rst:1573 msgid "" ">>> email = \"tony@tiremove_thisger.net\"\n" ">>> m = re.search(\"remove_this\", email)\n" @@ -2485,28 +2555,28 @@ msgstr "" ">>> email[:m.start()] + email[m.end():]\n" "'tony@tiger.net'" -#: ../../library/re.rst:1546 +#: ../../library/re.rst:1581 msgid "" "For a match *m*, return the 2-tuple ``(m.start(group), m.end(group))``. Note " "that if *group* did not contribute to the match, this is ``(-1, -1)``. " "*group* defaults to zero, the entire match." msgstr "" -#: ../../library/re.rst:1553 +#: ../../library/re.rst:1588 msgid "" "The value of *pos* which was passed to the :meth:`~Pattern.search` or :meth:" "`~Pattern.match` method of a :ref:`regex object `. This is the " "index into the string at which the RE engine started looking for a match." msgstr "" -#: ../../library/re.rst:1560 +#: ../../library/re.rst:1595 msgid "" "The value of *endpos* which was passed to the :meth:`~Pattern.search` or :" "meth:`~Pattern.match` method of a :ref:`regex object `. This is " "the index into the string beyond which the RE engine will not go." msgstr "" -#: ../../library/re.rst:1567 +#: ../../library/re.rst:1602 msgid "" "The integer index of the last matched capturing group, or ``None`` if no " "group was matched at all. For example, the expressions ``(a)b``, ``((a)" @@ -2515,43 +2585,43 @@ msgid "" "applied to the same string." msgstr "" -#: ../../library/re.rst:1576 +#: ../../library/re.rst:1611 msgid "" "The name of the last matched capturing group, or ``None`` if the group " "didn't have a name, or if no group was matched at all." msgstr "" -#: ../../library/re.rst:1582 +#: ../../library/re.rst:1617 msgid "" "The :ref:`regular expression object ` whose :meth:`~Pattern." "match` or :meth:`~Pattern.search` method produced this match instance." msgstr "" -#: ../../library/re.rst:1588 +#: ../../library/re.rst:1623 msgid "The string passed to :meth:`~Pattern.match` or :meth:`~Pattern.search`." msgstr "" -#: ../../library/re.rst:1591 +#: ../../library/re.rst:1626 msgid "" "Added support of :func:`copy.copy` and :func:`copy.deepcopy`. Match objects " "are considered atomic." msgstr "" -#: ../../library/re.rst:1599 -msgid "Regular Expression Examples" -msgstr "" +#: ../../library/re.rst:1634 +msgid "Regular expression examples" +msgstr "正規表示式範例" -#: ../../library/re.rst:1603 -msgid "Checking for a Pair" +#: ../../library/re.rst:1638 +msgid "Checking for a pair" msgstr "" -#: ../../library/re.rst:1605 +#: ../../library/re.rst:1640 msgid "" "In this example, we'll use the following helper function to display match " "objects a little more gracefully::" msgstr "" -#: ../../library/re.rst:1608 +#: ../../library/re.rst:1643 msgid "" "def displaymatch(match):\n" " if match is None:\n" @@ -2563,7 +2633,7 @@ msgstr "" " return None\n" " return '' % (match.group(), match.groups())" -#: ../../library/re.rst:1613 +#: ../../library/re.rst:1648 msgid "" "Suppose you are writing a poker program where a player's hand is represented " "as a 5-character string with each character representing a card, \"a\" for " @@ -2571,67 +2641,93 @@ msgid "" "\"2\" through \"9\" representing the card with that value." msgstr "" -#: ../../library/re.rst:1618 +#: ../../library/re.rst:1653 msgid "To see if a given string is a valid hand, one could do the following::" msgstr "" -#: ../../library/re.rst:1620 +#: ../../library/re.rst:1655 msgid "" -">>> valid = re.compile(r\"^[a2-9tjqk]{5}$\")\n" -">>> displaymatch(valid.match(\"akt5q\")) # Valid.\n" +">>> valid_hand_re = re.compile(r\"^[a2-9tjqk]{5}$\")\n" +">>> displaymatch(valid_hand_re.search(\"akt5q\")) # Valid.\n" "\"\"\n" -">>> displaymatch(valid.match(\"akt5e\")) # Invalid.\n" -">>> displaymatch(valid.match(\"akt\")) # Invalid.\n" -">>> displaymatch(valid.match(\"727ak\")) # Valid.\n" +">>> displaymatch(valid_hand_re.search(\"akt5e\")) # Invalid.\n" +">>> displaymatch(valid_hand_re.search(\"akt\")) # Invalid.\n" +">>> displaymatch(valid_hand_re.search(\"727ak\")) # Valid.\n" "\"\"" msgstr "" +">>> valid_hand_re = re.compile(r\"^[a2-9tjqk]{5}$\")\n" +">>> displaymatch(valid_hand_re.search(\"akt5q\")) # 有效。\n" +"\"\"\n" +">>> displaymatch(valid_hand_re.search(\"akt5e\")) # 無效。\n" +">>> displaymatch(valid_hand_re.search(\"akt\")) # 無效。\n" +">>> displaymatch(valid_hand_re.search(\"727ak\")) # 有效。\n" +"\"\"" -#: ../../library/re.rst:1628 +#: ../../library/re.rst:1663 msgid "" "That last hand, ``\"727ak\"``, contained a pair, or two of the same valued " "cards. To match this with a regular expression, one could use backreferences " "as such::" msgstr "" -#: ../../library/re.rst:1631 +#: ../../library/re.rst:1666 msgid "" -">>> pair = re.compile(r\".*(.).*\\1\")\n" -">>> displaymatch(pair.match(\"717ak\")) # Pair of 7s.\n" +">>> pair_re = re.compile(r\".*(.).*\\1\")\n" +">>> displaymatch(pair_re.prefixmatch(\"717ak\")) # Pair of 7s.\n" "\"\"\n" -">>> displaymatch(pair.match(\"718ak\")) # No pairs.\n" -">>> displaymatch(pair.match(\"354aa\")) # Pair of aces.\n" +">>> displaymatch(pair_re.prefixmatch(\"718ak\")) # No pairs.\n" +">>> displaymatch(pair_re.prefixmatch(\"354aa\")) # Pair of aces.\n" "\"\"" msgstr "" +">>> pair_re = re.compile(r\".*(.).*\\1\")\n" +">>> displaymatch(pair_re.prefixmatch(\"717ak\")) # 一對 7。\n" +"\"\"\n" +">>> displaymatch(pair_re.prefixmatch(\"718ak\")) # 沒有成對。\n" +">>> displaymatch(pair_re.prefixmatch(\"354aa\")) # 一對 A。\n" +"\"\"" -#: ../../library/re.rst:1638 +#: ../../library/re.rst:1673 msgid "" "To find out what card the pair consists of, one could use the :meth:`~Match." "group` method of the match object in the following manner::" msgstr "" -#: ../../library/re.rst:1641 +#: ../../library/re.rst:1676 msgid "" -">>> pair = re.compile(r\".*(.).*\\1\")\n" -">>> pair.match(\"717ak\").group(1)\n" +">>> pair_re = re.compile(r\".*(.).*\\1\")\n" +">>> pair_re.prefixmatch(\"717ak\").group(1)\n" "'7'\n" "\n" -"# Error because re.match() returns None, which doesn't have a group() " +"# Error because prefixmatch() returns None, which doesn't have a group() " "method:\n" -">>> pair.match(\"718ak\").group(1)\n" +">>> pair_re.prefixmatch(\"718ak\").group(1)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" -" re.match(r\".*(.).*\\1\", \"718ak\").group(1)\n" +" pair_re.prefixmatch(\"718ak\").group(1)\n" "AttributeError: 'NoneType' object has no attribute 'group'\n" "\n" -">>> pair.match(\"354aa\").group(1)\n" +">>> pair_re.prefixmatch(\"354aa\").group(1)\n" "'a'" msgstr "" +">>> pair_re = re.compile(r\".*(.).*\\1\")\n" +">>> pair_re.prefixmatch(\"717ak\").group(1)\n" +"'7'\n" +"\n" +"# 會出錯,因為 prefixmatch() 回傳 None,而 None 沒有 group() 方法:\n" +">>> pair_re.prefixmatch(\"718ak\").group(1)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" pair_re.prefixmatch(\"718ak\").group(1)\n" +"AttributeError: 'NoneType' object has no attribute 'group'\n" +"\n" +">>> pair_re.prefixmatch(\"354aa\").group(1)\n" +"'a'" -#: ../../library/re.rst:1657 +#: ../../library/re.rst:1691 msgid "Simulating scanf()" msgstr "模擬 scanf()" -#: ../../library/re.rst:1661 +#: ../../library/re.rst:1695 msgid "" "Python does not currently have an equivalent to :c:func:`!scanf`. Regular " "expressions are generally more powerful, though also more verbose, than :c:" @@ -2640,173 +2736,236 @@ msgid "" "expressions." msgstr "" -#: ../../library/re.rst:1668 +#: ../../library/re.rst:1702 msgid ":c:func:`!scanf` Token" msgstr "" -#: ../../library/re.rst:1668 +#: ../../library/re.rst:1702 msgid "Regular Expression" msgstr "" -#: ../../library/re.rst:1670 +#: ../../library/re.rst:1704 msgid "``%c``" msgstr "``%c``" -#: ../../library/re.rst:1672 +#: ../../library/re.rst:1706 msgid "``%5c``" msgstr "``%5c``" -#: ../../library/re.rst:1672 +#: ../../library/re.rst:1706 msgid "``.{5}``" msgstr "``.{5}``" -#: ../../library/re.rst:1674 +#: ../../library/re.rst:1708 msgid "``%d``" msgstr "``%d``" -#: ../../library/re.rst:1674 +#: ../../library/re.rst:1708 msgid "``[-+]?\\d+``" msgstr "``[-+]?\\d+``" -#: ../../library/re.rst:1676 +#: ../../library/re.rst:1710 msgid "``%e``, ``%E``, ``%f``, ``%g``" msgstr "``%e``, ``%E``, ``%f``, ``%g``" -#: ../../library/re.rst:1676 +#: ../../library/re.rst:1710 msgid "``[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?``" msgstr "``[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?``" -#: ../../library/re.rst:1678 +#: ../../library/re.rst:1712 msgid "``%i``" msgstr "``%i``" -#: ../../library/re.rst:1678 +#: ../../library/re.rst:1712 msgid "``[-+]?(0[xX][\\dA-Fa-f]+|0[0-7]*|\\d+)``" msgstr "``[-+]?(0[xX][\\dA-Fa-f]+|0[0-7]*|\\d+)``" -#: ../../library/re.rst:1680 +#: ../../library/re.rst:1714 msgid "``%o``" msgstr "``%o``" -#: ../../library/re.rst:1680 +#: ../../library/re.rst:1714 msgid "``[-+]?[0-7]+``" msgstr "``[-+]?[0-7]+``" -#: ../../library/re.rst:1682 +#: ../../library/re.rst:1716 msgid "``%s``" msgstr "``%s``" -#: ../../library/re.rst:1682 +#: ../../library/re.rst:1716 msgid "``\\S+``" msgstr "``\\S+``" -#: ../../library/re.rst:1684 +#: ../../library/re.rst:1718 msgid "``%u``" msgstr "``%u``" -#: ../../library/re.rst:1684 +#: ../../library/re.rst:1718 msgid "``\\d+``" msgstr "``\\d+``" -#: ../../library/re.rst:1686 +#: ../../library/re.rst:1720 msgid "``%x``, ``%X``" msgstr "``%x``、``%X``" -#: ../../library/re.rst:1686 +#: ../../library/re.rst:1720 msgid "``[-+]?(0[xX])?[\\dA-Fa-f]+``" msgstr "``[-+]?(0[xX])?[\\dA-Fa-f]+``" -#: ../../library/re.rst:1689 -msgid "To extract the filename and numbers from a string like ::" +#: ../../library/re.rst:1723 +msgid "To extract the filename and numbers from a string like:" msgstr "" -#: ../../library/re.rst:1691 +#: ../../library/re.rst:1725 msgid "/usr/sbin/sendmail - 0 errors, 4 warnings" msgstr "/usr/sbin/sendmail - 0 errors, 4 warnings" -#: ../../library/re.rst:1693 -msgid "you would use a :c:func:`!scanf` format like ::" +#: ../../library/re.rst:1729 +msgid "you would use a :c:func:`!scanf` format like:" msgstr "" -#: ../../library/re.rst:1695 +#: ../../library/re.rst:1731 msgid "%s - %d errors, %d warnings" msgstr "" -#: ../../library/re.rst:1697 -msgid "The equivalent regular expression would be ::" -msgstr "" +#: ../../library/re.rst:1735 +msgid "The equivalent regular expression would be:" +msgstr "等價的正規表示式會是:" -#: ../../library/re.rst:1699 +#: ../../library/re.rst:1737 msgid "(\\S+) - (\\d+) errors, (\\d+) warnings" msgstr "" -#: ../../library/re.rst:1705 -msgid "search() vs. match()" -msgstr "search() vs. match()" +#: ../../library/re.rst:1745 +msgid "search() vs. prefixmatch()" +msgstr "search() vs. prefixmatch()" -#: ../../library/re.rst:1709 +#: ../../library/re.rst:1747 msgid "" "Python offers different primitive operations based on regular expressions:" msgstr "" -#: ../../library/re.rst:1711 -msgid ":func:`re.match` checks for a match only at the beginning of the string" -msgstr "" +#: ../../library/re.rst:1749 +msgid "" +":func:`re.prefixmatch` checks for a match only at the beginning of the string" +msgstr ":func:`re.prefixmatch` 只在字串的開頭檢查是否匹配" -#: ../../library/re.rst:1712 +#: ../../library/re.rst:1750 msgid "" ":func:`re.search` checks for a match anywhere in the string (this is what " "Perl does by default)" msgstr "" -#: ../../library/re.rst:1714 +#: ../../library/re.rst:1752 msgid ":func:`re.fullmatch` checks for entire string to be a match" msgstr "" -#: ../../library/re.rst:1719 +#: ../../library/re.rst:1756 msgid "" -">>> re.match(\"c\", \"abcdef\") # No match\n" -">>> re.search(\"c\", \"abcdef\") # Match\n" +">>> re.prefixmatch(\"c\", \"abcdef\") # No match\n" +">>> re.search(\"c\", \"abcdef\") # Match\n" "\n" ">>> re.fullmatch(\"p.*n\", \"python\") # Match\n" "\n" ">>> re.fullmatch(\"r.*n\", \"python\") # No match" msgstr "" +">>> re.prefixmatch(\"c\", \"abcdef\") # 不匹配\n" +">>> re.search(\"c\", \"abcdef\") # 匹配\n" +"\n" +">>> re.fullmatch(\"p.*n\", \"python\") # 匹配\n" +"\n" +">>> re.fullmatch(\"r.*n\", \"python\") # 不匹配" -#: ../../library/re.rst:1726 +#: ../../library/re.rst:1763 msgid "" "Regular expressions beginning with ``'^'`` can be used with :func:`search` " "to restrict the match at the beginning of the string::" msgstr "" -#: ../../library/re.rst:1729 +#: ../../library/re.rst:1766 msgid "" -">>> re.match(\"c\", \"abcdef\") # No match\n" -">>> re.search(\"^c\", \"abcdef\") # No match\n" -">>> re.search(\"^a\", \"abcdef\") # Match\n" +">>> re.prefixmatch(\"c\", \"abcdef\") # No match\n" +">>> re.search(\"^c\", \"abcdef\") # No match\n" +">>> re.search(\"^a\", \"abcdef\") # Match\n" "" msgstr "" +">>> re.prefixmatch(\"c\", \"abcdef\") # No match\n" +">>> re.search(\"^c\", \"abcdef\") # No match\n" +">>> re.search(\"^a\", \"abcdef\") # Match\n" +"" -#: ../../library/re.rst:1734 +#: ../../library/re.rst:1771 msgid "" -"Note however that in :const:`MULTILINE` mode :func:`match` only matches at " -"the beginning of the string, whereas using :func:`search` with a regular " -"expression beginning with ``'^'`` will match at the beginning of each " -"line. ::" +"Note however that in :const:`MULTILINE` mode :func:`prefixmatch` only " +"matches at the beginning of the string, whereas using :func:`search` with a " +"regular expression beginning with ``'^'`` will match at the beginning of " +"each line. ::" msgstr "" +"但請注意,在 :const:`MULTILINE` 模式下,:func:`prefixmatch` 只會於字串的開頭" +"匹配,而使用 :func:`search` 搭配以 ``'^'`` 開頭的正規表示式則會在每行的開頭匹" +"配。 ::" -#: ../../library/re.rst:1738 +#: ../../library/re.rst:1775 msgid "" -">>> re.match(\"X\", \"A\\nB\\nX\", re.MULTILINE) # No match\n" +">>> re.prefixmatch(\"X\", \"A\\nB\\nX\", re.MULTILINE) # No match\n" ">>> re.search(\"^X\", \"A\\nB\\nX\", re.MULTILINE) # Match\n" "" msgstr "" +">>> re.prefixmatch(\"X\", \"A\\nB\\nX\", re.MULTILINE) # No match\n" +">>> re.search(\"^X\", \"A\\nB\\nX\", re.MULTILINE) # Match\n" +"" -#: ../../library/re.rst:1744 -msgid "Making a Phonebook" +#: ../../library/re.rst:1782 +msgid "prefixmatch() vs. match()" +msgstr "prefixmatch() vs. match()" + +#: ../../library/re.rst:1784 +msgid "" +"Why is the :func:`~re.match` function and method discouraged in favor of the " +"longer :func:`~re.prefixmatch` spelling?" +msgstr "" + +#: ../../library/re.rst:1787 +msgid "" +"Many other languages have gained regex support libraries since regular " +"expressions were added to Python. However in the most popular of those, they " +"use the term *match* in their APIs to mean the unanchored behavior provided " +"in Python by :func:`~re.search`. Thus use of the plain term *match* can be " +"unclear to those used to other languages when reading or writing code and " +"not familiar with the Python API's divergence from what otherwise become the " +"industry norm." msgstr "" -#: ../../library/re.rst:1746 +#: ../../library/re.rst:1795 +msgid "" +"Quoting from the Zen Of Python (``python3 -m this``): *\"Explicit is better " +"than implicit\"*. Anyone reading the name :func:`!prefixmatch` is likely to " +"understand the intended semantics. When reading :func:`!match` there remains " +"a seed of doubt about the intended behavior to anyone not already familiar " +"with this old Python gotcha." +msgstr "" + +#: ../../library/re.rst:1801 +msgid "" +"We **do not** plan to remove the older :func:`!match` name, as it has been " +"used in code for over 30 years. It has been :term:`soft deprecated`: code " +"supporting older versions of Python should continue to use :func:`!match`, " +"while new code should prefer :func:`!prefixmatch`." +msgstr "" + +#: ../../library/re.rst:1807 +msgid ":func:`!prefixmatch`" +msgstr ":func:`!prefixmatch`" + +#: ../../library/re.rst:1810 +msgid ":func:`!match`" +msgstr ":func:`!match`" + +#: ../../library/re.rst:1814 +msgid "Making a phonebook" +msgstr "" + +#: ../../library/re.rst:1816 msgid "" ":func:`split` splits a string into a list delimited by the passed pattern. " "The method is invaluable for converting textual data into data structures " @@ -2814,13 +2973,13 @@ msgid "" "following example that creates a phonebook." msgstr "" -#: ../../library/re.rst:1751 +#: ../../library/re.rst:1821 msgid "" "First, here is the input. Normally it may come from a file, here we are " "using triple-quoted string syntax" msgstr "" -#: ../../library/re.rst:1754 +#: ../../library/re.rst:1824 msgid "" ">>> text = \"\"\"Ross McFluff: 834.345.1254 155 Elm Street\n" "...\n" @@ -2838,13 +2997,13 @@ msgstr "" "...\n" "... Heather Albrecht: 548.326.4584 919 Park Place\"\"\"" -#: ../../library/re.rst:1764 +#: ../../library/re.rst:1834 msgid "" "The entries are separated by one or more newlines. Now we convert the string " "into a list with each nonempty line having its own entry:" msgstr "" -#: ../../library/re.rst:1767 +#: ../../library/re.rst:1837 msgid "" ">>> entries = re.split(\"\\n+\", text)\n" ">>> entries\n" @@ -2860,14 +3019,14 @@ msgstr "" "'Frank Burger: 925.541.7625 662 South Dogwood Way',\n" "'Heather Albrecht: 548.326.4584 919 Park Place']" -#: ../../library/re.rst:1777 +#: ../../library/re.rst:1847 msgid "" "Finally, split each entry into a list with first name, last name, telephone " "number, and address. We use the ``maxsplit`` parameter of :func:`split` " "because the address has spaces, our splitting pattern, in it:" msgstr "" -#: ../../library/re.rst:1781 +#: ../../library/re.rst:1851 msgid "" ">>> [re.split(\":? \", entry, maxsplit=3) for entry in entries]\n" "[['Ross', 'McFluff', '834.345.1254', '155 Elm Street'],\n" @@ -2881,14 +3040,14 @@ msgstr "" "['Frank', 'Burger', '925.541.7625', '662 South Dogwood Way'],\n" "['Heather', 'Albrecht', '548.326.4584', '919 Park Place']]" -#: ../../library/re.rst:1790 +#: ../../library/re.rst:1860 msgid "" "The ``:?`` pattern matches the colon after the last name, so that it does " "not occur in the result list. With a ``maxsplit`` of ``4``, we could " "separate the house number from the street name:" msgstr "" -#: ../../library/re.rst:1794 +#: ../../library/re.rst:1864 msgid "" ">>> [re.split(\":? \", entry, maxsplit=4) for entry in entries]\n" "[['Ross', 'McFluff', '834.345.1254', '155', 'Elm Street'],\n" @@ -2902,11 +3061,11 @@ msgstr "" "['Frank', 'Burger', '925.541.7625', '662', 'South Dogwood Way'],\n" "['Heather', 'Albrecht', '548.326.4584', '919', 'Park Place']]" -#: ../../library/re.rst:1805 -msgid "Text Munging" +#: ../../library/re.rst:1875 +msgid "Text munging" msgstr "" -#: ../../library/re.rst:1807 +#: ../../library/re.rst:1877 msgid "" ":func:`sub` replaces every occurrence of a pattern with a string or the " "result of a function. This example demonstrates using :func:`sub` with a " @@ -2914,7 +3073,7 @@ msgid "" "each word of a sentence except for the first and last characters::" msgstr "" -#: ../../library/re.rst:1812 +#: ../../library/re.rst:1882 msgid "" ">>> def repl(m):\n" "... inner_word = list(m.group(2))\n" @@ -2938,11 +3097,11 @@ msgstr "" ">>> re.sub(r\"(\\w)(\\w+)(\\w)\", repl, text)\n" "'Pofsroser Aodlambelk, plasee reoprt yuor asnebces potlmrpy.'" -#: ../../library/re.rst:1825 -msgid "Finding all Adverbs" +#: ../../library/re.rst:1895 +msgid "Finding all adverbs" msgstr "" -#: ../../library/re.rst:1827 +#: ../../library/re.rst:1897 msgid "" ":func:`findall` matches *all* occurrences of a pattern, not just the first " "one as :func:`search` does. For example, if a writer wanted to find all of " @@ -2950,7 +3109,7 @@ msgid "" "manner::" msgstr "" -#: ../../library/re.rst:1832 +#: ../../library/re.rst:1902 msgid "" ">>> text = \"He was carefully disguised but captured quickly by police.\"\n" ">>> re.findall(r\"\\w+ly\\b\", text)\n" @@ -2960,11 +3119,11 @@ msgstr "" ">>> re.findall(r\"\\w+ly\\b\", text)\n" "['carefully', 'quickly']" -#: ../../library/re.rst:1838 -msgid "Finding all Adverbs and their Positions" +#: ../../library/re.rst:1908 +msgid "Finding all adverbs and their positions" msgstr "" -#: ../../library/re.rst:1840 +#: ../../library/re.rst:1910 msgid "" "If one wants more information about all matches of a pattern than the " "matched text, :func:`finditer` is useful as it provides :class:`~re.Match` " @@ -2973,7 +3132,7 @@ msgid "" "they would use :func:`finditer` in the following manner::" msgstr "" -#: ../../library/re.rst:1846 +#: ../../library/re.rst:1916 msgid "" ">>> text = \"He was carefully disguised but captured quickly by police.\"\n" ">>> for m in re.finditer(r\"\\w+ly\\b\", text):\n" @@ -2987,11 +3146,11 @@ msgstr "" "07-16: carefully\n" "40-47: quickly" -#: ../../library/re.rst:1854 -msgid "Raw String Notation" +#: ../../library/re.rst:1924 +msgid "Raw string notation" msgstr "" -#: ../../library/re.rst:1856 +#: ../../library/re.rst:1926 msgid "" "Raw string notation (``r\"text\"``) keeps regular expressions sane. Without " "it, every backslash (``'\\'``) in a regular expression would have to be " @@ -2999,19 +3158,19 @@ msgid "" "lines of code are functionally identical::" msgstr "" -#: ../../library/re.rst:1861 +#: ../../library/re.rst:1931 msgid "" -">>> re.match(r\"\\W(.)\\1\\W\", \" ff \")\n" +">>> re.search(r\"\\W(.)\\1\\W\", \" ff \")\n" "\n" -">>> re.match(\"\\\\W(.)\\\\1\\\\W\", \" ff \")\n" +">>> re.search(\"\\\\W(.)\\\\1\\\\W\", \" ff \")\n" "" msgstr "" -">>> re.match(r\"\\W(.)\\1\\W\", \" ff \")\n" +">>> re.search(r\"\\W(.)\\1\\W\", \" ff \")\n" "\n" -">>> re.match(\"\\\\W(.)\\\\1\\\\W\", \" ff \")\n" +">>> re.search(\"\\\\W(.)\\\\1\\\\W\", \" ff \")\n" "" -#: ../../library/re.rst:1866 +#: ../../library/re.rst:1936 msgid "" "When one wants to match a literal backslash, it must be escaped in the " "regular expression. With raw string notation, this means ``r\"\\\\\"``. " @@ -3019,37 +3178,37 @@ msgid "" "following lines of code functionally identical::" msgstr "" -#: ../../library/re.rst:1871 +#: ../../library/re.rst:1941 msgid "" -">>> re.match(r\"\\\\\", r\"\\\\\")\n" +">>> re.search(r\"\\\\\", r\"\\\\\")\n" "\n" -">>> re.match(\"\\\\\\\\\", r\"\\\\\")\n" +">>> re.search(\"\\\\\\\\\", r\"\\\\\")\n" "" msgstr "" -">>> re.match(r\"\\\\\", r\"\\\\\")\n" +">>> re.search(r\"\\\\\", r\"\\\\\")\n" "\n" -">>> re.match(\"\\\\\\\\\", r\"\\\\\")\n" +">>> re.search(\"\\\\\\\\\", r\"\\\\\")\n" "" -#: ../../library/re.rst:1878 -msgid "Writing a Tokenizer" +#: ../../library/re.rst:1948 +msgid "Writing a tokenizer" msgstr "" -#: ../../library/re.rst:1880 +#: ../../library/re.rst:1950 msgid "" "A `tokenizer or scanner `_ " "analyzes a string to categorize groups of characters. This is a useful " "first step in writing a compiler or interpreter." msgstr "" -#: ../../library/re.rst:1884 +#: ../../library/re.rst:1954 msgid "" "The text categories are specified with regular expressions. The technique " "is to combine those into a single master regular expression and to loop over " "successive matches::" msgstr "" -#: ../../library/re.rst:1888 +#: ../../library/re.rst:1958 msgid "" "from typing import NamedTuple\n" "import re\n" @@ -3105,11 +3264,11 @@ msgid "" " print(token)" msgstr "" -#: ../../library/re.rst:1940 +#: ../../library/re.rst:2010 msgid "The tokenizer produces the following output::" msgstr "" -#: ../../library/re.rst:1942 +#: ../../library/re.rst:2012 msgid "" "Token(type='IF', value='IF', line=2, column=4)\n" "Token(type='ID', value='quantity', line=2, column=7)\n" @@ -3151,7 +3310,7 @@ msgstr "" "Token(type='ENDIF', value='ENDIF', line=5, column=4)\n" "Token(type='END', value=';', line=5, column=9)" -#: ../../library/re.rst:1963 +#: ../../library/re.rst:2033 msgid "" "Friedl, Jeffrey. Mastering Regular Expressions. 3rd ed., O'Reilly Media, " "2009. The third edition of the book no longer covers Python at all, but the " @@ -3159,232 +3318,232 @@ msgid "" "detail." msgstr "" -#: ../../library/re.rst:99 +#: ../../library/re.rst:96 msgid ". (dot)" msgstr ". (點)" -#: ../../library/re.rst:99 ../../library/re.rst:106 ../../library/re.rst:112 -#: ../../library/re.rst:123 ../../library/re.rst:130 ../../library/re.rst:137 -#: ../../library/re.rst:143 ../../library/re.rst:157 ../../library/re.rst:181 -#: ../../library/re.rst:220 ../../library/re.rst:235 ../../library/re.rst:244 -#: ../../library/re.rst:258 ../../library/re.rst:271 ../../library/re.rst:304 -#: ../../library/re.rst:317 ../../library/re.rst:327 ../../library/re.rst:359 -#: ../../library/re.rst:414 ../../library/re.rst:446 ../../library/re.rst:452 -#: ../../library/re.rst:457 ../../library/re.rst:464 ../../library/re.rst:471 -#: ../../library/re.rst:498 ../../library/re.rst:508 ../../library/re.rst:532 -#: ../../library/re.rst:544 ../../library/re.rst:549 ../../library/re.rst:571 -#: ../../library/re.rst:588 ../../library/re.rst:604 ../../library/re.rst:612 -#: ../../library/re.rst:626 ../../library/re.rst:634 ../../library/re.rst:651 -#: ../../library/re.rst:665 ../../library/re.rst:676 ../../library/re.rst:867 -#: ../../library/re.rst:1106 +#: ../../library/re.rst:96 ../../library/re.rst:103 ../../library/re.rst:109 +#: ../../library/re.rst:120 ../../library/re.rst:127 ../../library/re.rst:134 +#: ../../library/re.rst:140 ../../library/re.rst:154 ../../library/re.rst:178 +#: ../../library/re.rst:217 ../../library/re.rst:232 ../../library/re.rst:241 +#: ../../library/re.rst:255 ../../library/re.rst:268 ../../library/re.rst:301 +#: ../../library/re.rst:314 ../../library/re.rst:324 ../../library/re.rst:356 +#: ../../library/re.rst:411 ../../library/re.rst:443 ../../library/re.rst:449 +#: ../../library/re.rst:454 ../../library/re.rst:461 ../../library/re.rst:468 +#: ../../library/re.rst:495 ../../library/re.rst:505 ../../library/re.rst:529 +#: ../../library/re.rst:541 ../../library/re.rst:546 ../../library/re.rst:568 +#: ../../library/re.rst:585 ../../library/re.rst:601 ../../library/re.rst:609 +#: ../../library/re.rst:623 ../../library/re.rst:631 ../../library/re.rst:648 +#: ../../library/re.rst:662 ../../library/re.rst:673 ../../library/re.rst:864 +#: ../../library/re.rst:1122 msgid "in regular expressions" msgstr "於正規表示式中" -#: ../../library/re.rst:106 ../../library/re.rst:271 +#: ../../library/re.rst:103 ../../library/re.rst:268 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../library/re.rst:112 +#: ../../library/re.rst:109 msgid "$ (dollar)" msgstr "$ (金錢符號)" -#: ../../library/re.rst:123 +#: ../../library/re.rst:120 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/re.rst:130 +#: ../../library/re.rst:127 msgid "+ (plus)" msgstr "+ (加號)" -#: ../../library/re.rst:137 +#: ../../library/re.rst:134 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/re.rst:143 +#: ../../library/re.rst:140 msgid "*?" msgstr "*?" -#: ../../library/re.rst:143 +#: ../../library/re.rst:140 msgid "+?" msgstr "+?" -#: ../../library/re.rst:143 +#: ../../library/re.rst:140 msgid "??" msgstr "??" -#: ../../library/re.rst:157 +#: ../../library/re.rst:154 msgid "*+" msgstr "*+" -#: ../../library/re.rst:157 +#: ../../library/re.rst:154 msgid "++" msgstr "++" -#: ../../library/re.rst:157 +#: ../../library/re.rst:154 msgid "?+" msgstr "?+" -#: ../../library/re.rst:181 +#: ../../library/re.rst:178 msgid "{} (curly brackets)" msgstr "{} (花括號)" -#: ../../library/re.rst:220 ../../library/re.rst:258 ../../library/re.rst:532 +#: ../../library/re.rst:217 ../../library/re.rst:255 ../../library/re.rst:529 msgid "\\ (backslash)" msgstr "\\ (反斜線)" -#: ../../library/re.rst:235 +#: ../../library/re.rst:232 msgid "[] (square brackets)" msgstr "[] (方括號)" -#: ../../library/re.rst:244 +#: ../../library/re.rst:241 msgid "- (minus)" msgstr "- (減號)" -#: ../../library/re.rst:304 +#: ../../library/re.rst:301 msgid "| (vertical bar)" msgstr "| (垂直線)" -#: ../../library/re.rst:317 +#: ../../library/re.rst:314 msgid "() (parentheses)" msgstr "() (圓括號)" -#: ../../library/re.rst:327 +#: ../../library/re.rst:324 msgid "(?" msgstr "(?" -#: ../../library/re.rst:359 +#: ../../library/re.rst:356 msgid "(?:" msgstr "(?:" -#: ../../library/re.rst:414 +#: ../../library/re.rst:411 msgid "(?P<" msgstr "(?P<" -#: ../../library/re.rst:446 +#: ../../library/re.rst:443 msgid "(?P=" msgstr "(?P=" -#: ../../library/re.rst:452 +#: ../../library/re.rst:449 msgid "(?#" msgstr "(?#" -#: ../../library/re.rst:457 +#: ../../library/re.rst:454 msgid "(?=" msgstr "(?=" -#: ../../library/re.rst:464 +#: ../../library/re.rst:461 msgid "(?!" msgstr "(?!" -#: ../../library/re.rst:471 +#: ../../library/re.rst:468 msgid "(?<=" msgstr "(?<=" -#: ../../library/re.rst:498 +#: ../../library/re.rst:495 msgid "(?\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,7 +21,7 @@ msgstr "" msgid ":mod:`!readline` --- GNU readline interface" msgstr ":mod:`!readline` --- GNU readline 介面" -#: ../../library/readline.rst:11 +#: ../../library/readline.rst:9 msgid "" "The :mod:`!readline` module defines a number of functions to facilitate " "completion and reading/writing of history files from the Python interpreter. " @@ -32,7 +32,7 @@ msgid "" "func:`input` function." msgstr "" -#: ../../library/readline.rst:19 +#: ../../library/readline.rst:17 msgid "" "Readline keybindings may be configured via an initialization file, typically " "``.inputrc`` in your home directory. See `Readline Init File ` (see :ref:`rlcompleter-config`)." msgstr "" -#: ../../library/readline.rst:351 +#: ../../library/readline.rst:358 msgid "" "The following example achieves the same goal but supports concurrent " "interactive sessions, by only appending the new history. ::" msgstr "" -#: ../../library/readline.rst:354 +#: ../../library/readline.rst:361 msgid "" "import atexit\n" "import os\n" @@ -440,13 +447,13 @@ msgstr "" " readline.append_history_file(new_h_len - prev_h_len, histfile)\n" "atexit.register(save, h_len, histfile)" -#: ../../library/readline.rst:372 +#: ../../library/readline.rst:379 msgid "" "The following example extends the :class:`code.InteractiveConsole` class to " "support history save/restore. ::" msgstr "" -#: ../../library/readline.rst:375 +#: ../../library/readline.rst:382 msgid "" "import atexit\n" "import code\n" @@ -496,7 +503,7 @@ msgstr "" " readline.set_history_length(1000)\n" " readline.write_history_file(histfile)" -#: ../../library/readline.rst:401 +#: ../../library/readline.rst:408 msgid "" "The new :term:`REPL` introduced in version 3.13 doesn't support readline. " "However, readline can still be used by setting the :envvar:" diff --git a/library/reprlib.po b/library/reprlib.po index cdd7b781f3f..f184f06905e 100644 --- a/library/reprlib.po +++ b/library/reprlib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,22 +21,22 @@ msgstr "" msgid ":mod:`!reprlib` --- Alternate :func:`repr` implementation" msgstr ":mod:`!reprlib` --- :func:`repr` 的替代實作" -#: ../../library/reprlib.rst:9 +#: ../../library/reprlib.rst:7 msgid "**Source code:** :source:`Lib/reprlib.py`" msgstr "**原始碼:**\\ :source:`Lib/reprlib.py`" -#: ../../library/reprlib.rst:13 +#: ../../library/reprlib.rst:11 msgid "" "The :mod:`!reprlib` module provides a means for producing object " "representations with limits on the size of the resulting strings. This is " "used in the Python debugger and may be useful in other contexts as well." msgstr "" -#: ../../library/reprlib.rst:17 +#: ../../library/reprlib.rst:15 msgid "This module provides a class, an instance, and a function:" msgstr "" -#: ../../library/reprlib.rst:24 +#: ../../library/reprlib.rst:22 msgid "" "Class which provides formatting services useful in implementing functions " "similar to the built-in :func:`repr`; size limits for different object " @@ -44,22 +44,22 @@ msgid "" "excessively long." msgstr "" -#: ../../library/reprlib.rst:28 +#: ../../library/reprlib.rst:26 msgid "" "The keyword arguments of the constructor can be used as a shortcut to set " "the attributes of the :class:`Repr` instance. Which means that the following " "initialization::" msgstr "" -#: ../../library/reprlib.rst:32 +#: ../../library/reprlib.rst:30 msgid "aRepr = reprlib.Repr(maxlevel=3)" msgstr "aRepr = reprlib.Repr(maxlevel=3)" -#: ../../library/reprlib.rst:34 +#: ../../library/reprlib.rst:32 msgid "Is equivalent to::" msgstr "等價於: ::" -#: ../../library/reprlib.rst:36 +#: ../../library/reprlib.rst:34 msgid "" "aRepr = reprlib.Repr()\n" "aRepr.maxlevel = 3" @@ -67,45 +67,45 @@ msgstr "" "aRepr = reprlib.Repr()\n" "aRepr.maxlevel = 3" -#: ../../library/reprlib.rst:39 +#: ../../library/reprlib.rst:37 msgid "" "See section `Repr Objects`_ for more information about :class:`Repr` " "attributes." msgstr "" -#: ../../library/reprlib.rst:42 +#: ../../library/reprlib.rst:40 msgid "Allow attributes to be set via keyword arguments." msgstr "" -#: ../../library/reprlib.rst:48 +#: ../../library/reprlib.rst:46 msgid "" "This is an instance of :class:`Repr` which is used to provide the :func:`." "repr` function described below. Changing the attributes of this object will " "affect the size limits used by :func:`.repr` and the Python debugger." msgstr "" -#: ../../library/reprlib.rst:56 +#: ../../library/reprlib.rst:54 msgid "" "This is the :meth:`~Repr.repr` method of ``aRepr``. It returns a string " "similar to that returned by the built-in function of the same name, but with " "limits on most sizes." msgstr "" -#: ../../library/reprlib.rst:60 +#: ../../library/reprlib.rst:58 msgid "" "In addition to size-limiting tools, the module also provides a decorator for " "detecting recursive calls to :meth:`~object.__repr__` and substituting a " "placeholder string instead." msgstr "" -#: ../../library/reprlib.rst:69 +#: ../../library/reprlib.rst:67 msgid "" "Decorator for :meth:`~object.__repr__` methods to detect recursive calls " "within the same thread. If a recursive call is made, the *fillvalue* is " "returned, otherwise, the usual :meth:`!__repr__` call is made. For example:" msgstr "" -#: ../../library/reprlib.rst:73 +#: ../../library/reprlib.rst:71 msgid "" ">>> from reprlib import recursive_repr\n" ">>> class MyList(list):\n" @@ -131,42 +131,42 @@ msgstr "" ">>> print(m)\n" "<'a'|'b'|'c'|...|'x'>" -#: ../../library/reprlib.rst:93 +#: ../../library/reprlib.rst:91 msgid "Repr Objects" msgstr "Repr 物件" -#: ../../library/reprlib.rst:95 +#: ../../library/reprlib.rst:93 msgid "" ":class:`Repr` instances provide several attributes which can be used to " "provide size limits for the representations of different object types, and " "methods which format specific object types." msgstr "" -#: ../../library/reprlib.rst:102 +#: ../../library/reprlib.rst:100 msgid "" "This string is displayed for recursive references. It defaults to ``...``." msgstr "" -#: ../../library/reprlib.rst:110 +#: ../../library/reprlib.rst:108 msgid "" "Depth limit on the creation of recursive representations. The default is " "``6``." msgstr "" -#: ../../library/reprlib.rst:121 +#: ../../library/reprlib.rst:119 msgid "" "Limits on the number of entries represented for the named object type. The " "default is ``4`` for :attr:`maxdict`, ``5`` for :attr:`maxarray`, and ``6`` " "for the others." msgstr "" -#: ../../library/reprlib.rst:128 +#: ../../library/reprlib.rst:126 msgid "" "Maximum number of characters in the representation for an integer. Digits " "are dropped from the middle. The default is ``40``." msgstr "" -#: ../../library/reprlib.rst:134 +#: ../../library/reprlib.rst:132 msgid "" "Limit on the number of characters in the representation of the string. Note " "that the \"normal\" representation of the string is used as the character " @@ -174,21 +174,21 @@ msgid "" "mangled when the representation is shortened. The default is ``30``." msgstr "" -#: ../../library/reprlib.rst:142 +#: ../../library/reprlib.rst:140 msgid "" "This limit is used to control the size of object types for which no specific " "formatting method is available on the :class:`Repr` object. It is applied in " "a similar manner as :attr:`maxstring`. The default is ``20``." msgstr "" -#: ../../library/reprlib.rst:149 +#: ../../library/reprlib.rst:147 msgid "" "If this attribute is set to ``None`` (the default), the output is formatted " "with no line breaks or indentation, like the standard :func:`repr`. For " "example:" msgstr "" -#: ../../library/reprlib.rst:153 +#: ../../library/reprlib.rst:151 msgid "" ">>> example = [\n" "... 1, 'spam', {'a': 2, 'b': 'spam eggs', 'c': {3: 4.5, 6: []}}, 'ham']\n" @@ -204,13 +204,13 @@ msgstr "" ">>> print(aRepr.repr(example))\n" "[1, 'spam', {'a': 2, 'b': 'spam eggs', 'c': {3: 4.5, 6: []}}, 'ham']" -#: ../../library/reprlib.rst:162 +#: ../../library/reprlib.rst:160 msgid "" "If :attr:`~Repr.indent` is set to a string, each recursion level is placed " "on its own line, indented by that string:" msgstr "" -#: ../../library/reprlib.rst:165 +#: ../../library/reprlib.rst:163 msgid "" ">>> aRepr.indent = '-->'\n" ">>> print(aRepr.repr(example))\n" @@ -244,13 +244,13 @@ msgstr "" "-->'ham',\n" "]" -#: ../../library/reprlib.rst:183 +#: ../../library/reprlib.rst:181 msgid "" "Setting :attr:`~Repr.indent` to a positive integer value behaves as if it " "was set to a string with that number of spaces:" msgstr "" -#: ../../library/reprlib.rst:186 +#: ../../library/reprlib.rst:184 msgid "" ">>> aRepr.indent = 4\n" ">>> print(aRepr.repr(example))\n" @@ -284,13 +284,13 @@ msgstr "" " 'ham',\n" "]" -#: ../../library/reprlib.rst:209 +#: ../../library/reprlib.rst:207 msgid "" "The equivalent to the built-in :func:`repr` that uses the formatting imposed " "by the instance." msgstr "" -#: ../../library/reprlib.rst:215 +#: ../../library/reprlib.rst:213 msgid "" "Recursive implementation used by :meth:`.repr`. This uses the type of *obj* " "to determine which formatting method to call, passing it *obj* and *level*. " @@ -299,7 +299,7 @@ msgid "" "call." msgstr "" -#: ../../library/reprlib.rst:224 +#: ../../library/reprlib.rst:222 msgid "" "Formatting methods for specific types are implemented as methods with a name " "based on the type name. In the method name, **TYPE** is replaced by ``'_'." @@ -308,11 +308,11 @@ msgid "" "should call ``self.repr1(subobj, level - 1)``." msgstr "" -#: ../../library/reprlib.rst:234 +#: ../../library/reprlib.rst:232 msgid "Subclassing Repr Objects" msgstr "" -#: ../../library/reprlib.rst:236 +#: ../../library/reprlib.rst:234 msgid "" "The use of dynamic dispatching by :meth:`Repr.repr1` allows subclasses of :" "class:`Repr` to add support for additional built-in object types or to " @@ -320,7 +320,7 @@ msgid "" "special support for file objects could be added:" msgstr "" -#: ../../library/reprlib.rst:241 +#: ../../library/reprlib.rst:239 msgid "" "import reprlib\n" "import sys\n" @@ -348,14 +348,14 @@ msgstr "" "aRepr = MyRepr()\n" "print(aRepr.repr(sys.stdin)) # 印出 ''" -#: ../../library/reprlib.rst:256 +#: ../../library/reprlib.rst:254 msgid "" msgstr "" -#: ../../library/reprlib.rst:65 +#: ../../library/reprlib.rst:63 msgid "..." msgstr "..." -#: ../../library/reprlib.rst:65 +#: ../../library/reprlib.rst:63 msgid "placeholder" msgstr "placeholder(佔位符號)" diff --git a/library/resource.po b/library/resource.po index ff609497d00..43d43871097 100644 --- a/library/resource.po +++ b/library/resource.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-20 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:09+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,44 +21,46 @@ msgstr "" msgid ":mod:`!resource` --- Resource usage information" msgstr ":mod:`!resource` --- 資源使用資訊" -#: ../../library/resource.rst:12 +#: ../../library/resource.rst:9 msgid "" "This module provides basic mechanisms for measuring and controlling system " "resources utilized by a program." msgstr "" -#: ../../library/resource.rst:15 ../../library/resource.rst:103 -#: ../../library/resource.rst:180 ../../library/resource.rst:192 -#: ../../library/resource.rst:201 ../../library/resource.rst:210 -#: ../../library/resource.rst:220 ../../library/resource.rst:229 -#: ../../library/resource.rst:240 ../../library/resource.rst:254 -#: ../../library/resource.rst:263 ../../library/resource.rst:272 +#: ../../library/resource.rst:12 ../../library/resource.rst:114 +#: ../../library/resource.rst:191 ../../library/resource.rst:203 +#: ../../library/resource.rst:212 ../../library/resource.rst:221 +#: ../../library/resource.rst:231 ../../library/resource.rst:240 +#: ../../library/resource.rst:251 ../../library/resource.rst:265 +#: ../../library/resource.rst:274 ../../library/resource.rst:283 +#: ../../library/resource.rst:293 ../../library/resource.rst:303 +#: ../../library/resource.rst:312 ../../library/resource.rst:322 msgid "Availability" msgstr "可用性" -#: ../../library/resource.rst:17 +#: ../../library/resource.rst:14 msgid "" "Symbolic constants are used to specify particular system resources and to " "request usage information about either the current process or its children." msgstr "" -#: ../../library/resource.rst:20 +#: ../../library/resource.rst:17 msgid "An :exc:`OSError` is raised on syscall failure." msgstr "" -#: ../../library/resource.rst:25 +#: ../../library/resource.rst:22 msgid "A deprecated alias of :exc:`OSError`." msgstr "" -#: ../../library/resource.rst:27 +#: ../../library/resource.rst:24 msgid "Following :pep:`3151`, this class was made an alias of :exc:`OSError`." msgstr "" -#: ../../library/resource.rst:32 +#: ../../library/resource.rst:29 msgid "Resource Limits" msgstr "" -#: ../../library/resource.rst:34 +#: ../../library/resource.rst:31 msgid "" "Resources usage can be limited using the :func:`setrlimit` function " "described below. Each resource is controlled by a pair of limits: a soft " @@ -69,7 +71,7 @@ msgid "" "super-user can raise a hard limit.)" msgstr "" -#: ../../library/resource.rst:42 +#: ../../library/resource.rst:39 msgid "" "The specific resources that can be limited are system dependent. They are " "described in the :manpage:`getrlimit(2)` man page. The resources listed " @@ -78,18 +80,31 @@ msgid "" "not defined in this module for those platforms." msgstr "" -#: ../../library/resource.rst:51 +#: ../../library/resource.rst:48 msgid "Constant used to represent the limit for an unlimited resource." msgstr "" -#: ../../library/resource.rst:56 +#: ../../library/resource.rst:50 +msgid "" +"It is now always positive. Previously, it could be negative, such as -1 or " +"-3." +msgstr "" + +#: ../../library/resource.rst:58 +msgid "" +"Constants used to represent the soft and hard limit values if they cannot be " +"represented in the ``rlim_t`` value in C. Can be equal to :data:" +"`RLIM_INFINITY`." +msgstr "" + +#: ../../library/resource.rst:67 msgid "" "Returns a tuple ``(soft, hard)`` with the current soft and hard limits of " "*resource*. Raises :exc:`ValueError` if an invalid resource is specified, " "or :exc:`error` if the underlying system call fails unexpectedly." msgstr "" -#: ../../library/resource.rst:63 +#: ../../library/resource.rst:74 msgid "" "Sets new limits of consumption of *resource*. The *limits* argument must be " "a tuple ``(soft, hard)`` of two integers describing the new limits. A value " @@ -97,7 +112,7 @@ msgid "" "unlimited." msgstr "" -#: ../../library/resource.rst:68 +#: ../../library/resource.rst:79 msgid "" "Raises :exc:`ValueError` if an invalid resource is specified, if the new " "soft limit exceeds the hard limit, or if a process tries to raise its hard " @@ -108,17 +123,17 @@ msgid "" "be raised if the requested limit exceeds the system imposed limit." msgstr "" -#: ../../library/resource.rst:77 +#: ../../library/resource.rst:88 msgid "" "``setrlimit`` may also raise :exc:`error` if the underlying system call " "fails." msgstr "" -#: ../../library/resource.rst:80 +#: ../../library/resource.rst:91 msgid "VxWorks only supports setting :const:`RLIMIT_NOFILE`." msgstr "" -#: ../../library/resource.rst:82 +#: ../../library/resource.rst:93 msgid "" "Raises an :ref:`auditing event ` ``resource.setrlimit`` with " "arguments ``resource``, ``limits``." @@ -126,7 +141,7 @@ msgstr "" "引發一個附帶引數 ``resource``、``limits`` 的\\ :ref:`稽核事件 ` " "``resource.setrlimit``。" -#: ../../library/resource.rst:87 +#: ../../library/resource.rst:98 msgid "" "Combines :func:`setrlimit` and :func:`getrlimit` in one function and " "supports to get and set the resources limits of an arbitrary process. If " @@ -135,21 +150,21 @@ msgid "" "is optional." msgstr "" -#: ../../library/resource.rst:93 +#: ../../library/resource.rst:104 msgid "" "When *limits* is not given the function returns the *resource* limit of the " "process *pid*. When *limits* is given the *resource* limit of the process is " "set and the former resource limit is returned." msgstr "" -#: ../../library/resource.rst:97 +#: ../../library/resource.rst:108 msgid "" "Raises :exc:`ProcessLookupError` when *pid* can't be found and :exc:" "`PermissionError` when the user doesn't have ``CAP_SYS_RESOURCE`` for the " "process." msgstr "" -#: ../../library/resource.rst:101 +#: ../../library/resource.rst:112 msgid "" "Raises an :ref:`auditing event ` ``resource.prlimit`` with " "arguments ``pid``, ``resource``, ``limits``." @@ -157,14 +172,14 @@ msgstr "" "引發一個附帶引數 ``pid``、``resource``、``limits`` 的\\ :ref:`稽核事件 " "` ``resource.prlimit``。" -#: ../../library/resource.rst:108 +#: ../../library/resource.rst:119 msgid "" "These symbols define resources whose consumption can be controlled using " "the :func:`setrlimit` and :func:`getrlimit` functions described below. The " "values of these symbols are exactly the constants used by C programs." msgstr "" -#: ../../library/resource.rst:112 +#: ../../library/resource.rst:123 msgid "" "The Unix man page for :manpage:`getrlimit(2)` lists the available resources. " "Note that not all systems use the same symbol or same value to denote the " @@ -173,14 +188,14 @@ msgid "" "module on that platform." msgstr "" -#: ../../library/resource.rst:121 +#: ../../library/resource.rst:132 msgid "" "The maximum size (in bytes) of a core file that the current process can " "create. This may result in the creation of a partial core file if a larger " "core would be required to contain the entire process image." msgstr "" -#: ../../library/resource.rst:128 +#: ../../library/resource.rst:139 msgid "" "The maximum amount of processor time (in seconds) that a process can use. If " "this limit is exceeded, a :const:`~signal.SIGXCPU` signal is sent to the " @@ -189,83 +204,83 @@ msgid "" "disk.)" msgstr "" -#: ../../library/resource.rst:136 +#: ../../library/resource.rst:147 msgid "The maximum size of a file which the process may create." msgstr "" -#: ../../library/resource.rst:141 +#: ../../library/resource.rst:152 msgid "The maximum size (in bytes) of the process's heap." msgstr "" -#: ../../library/resource.rst:146 +#: ../../library/resource.rst:157 msgid "" "The maximum size (in bytes) of the call stack for the current process. This " "only affects the stack of the main thread in a multi-threaded process." msgstr "" -#: ../../library/resource.rst:152 +#: ../../library/resource.rst:163 msgid "" "The maximum resident set size that should be made available to the process." msgstr "" -#: ../../library/resource.rst:157 +#: ../../library/resource.rst:168 msgid "The maximum number of processes the current process may create." msgstr "" -#: ../../library/resource.rst:162 +#: ../../library/resource.rst:173 msgid "The maximum number of open file descriptors for the current process." msgstr "" -#: ../../library/resource.rst:167 +#: ../../library/resource.rst:178 msgid "The BSD name for :const:`RLIMIT_NOFILE`." msgstr "" -#: ../../library/resource.rst:172 +#: ../../library/resource.rst:183 msgid "The maximum address space which may be locked in memory." msgstr "" -#: ../../library/resource.rst:177 +#: ../../library/resource.rst:188 msgid "" "The largest area of mapped memory which the process may occupy. Usually an " "alias of :const:`RLIMIT_AS`." msgstr "" -#: ../../library/resource.rst:185 +#: ../../library/resource.rst:196 msgid "" "The maximum area (in bytes) of address space which may be taken by the " "process." msgstr "" -#: ../../library/resource.rst:190 +#: ../../library/resource.rst:201 msgid "The number of bytes that can be allocated for POSIX message queues." msgstr "" -#: ../../library/resource.rst:199 +#: ../../library/resource.rst:210 msgid "The ceiling for the process's nice level (calculated as 20 - rlim_cur)." msgstr "" -#: ../../library/resource.rst:208 +#: ../../library/resource.rst:219 msgid "The ceiling of the real-time priority." msgstr "" -#: ../../library/resource.rst:217 +#: ../../library/resource.rst:228 msgid "" "The time limit (in microseconds) on CPU time that a process can spend under " "real-time scheduling without making a blocking syscall." msgstr "" -#: ../../library/resource.rst:227 +#: ../../library/resource.rst:238 msgid "The number of signals which the process may queue." msgstr "" -#: ../../library/resource.rst:236 +#: ../../library/resource.rst:247 msgid "" "The maximum size (in bytes) of socket buffer usage for this user. This " "limits the amount of network memory, and hence the amount of mbufs, that " "this user may hold at any time." msgstr "" -#: ../../library/resource.rst:247 +#: ../../library/resource.rst:258 msgid "" "The maximum size (in bytes) of the swap space that may be reserved or used " "by all of this user id's processes. This limit is enforced only if bit 1 of " @@ -274,23 +289,45 @@ msgid "" "this sysctl." msgstr "" -#: ../../library/resource.rst:261 +#: ../../library/resource.rst:272 msgid "The maximum number of pseudo-terminals created by this user id." msgstr "" -#: ../../library/resource.rst:270 +#: ../../library/resource.rst:281 msgid "The maximum number of kqueues this user id is allowed to create." msgstr "" -#: ../../library/resource.rst:278 +#: ../../library/resource.rst:290 +msgid "" +"The maximum number of threads for this user id, not counting the main and " +"kernel threads." +msgstr "" + +#: ../../library/resource.rst:300 +msgid "" +"The maximum total size of in-kernel buffers for bi-directional pipes/fifos " +"that this user id is allowed to consume." +msgstr "" + +#: ../../library/resource.rst:310 +msgid "The maximum number of threads each process can create." +msgstr "" + +#: ../../library/resource.rst:319 +msgid "" +"The limit of the number of process-shared Posix thread library objects " +"allocated by user id." +msgstr "" + +#: ../../library/resource.rst:328 msgid "Resource Usage" msgstr "" -#: ../../library/resource.rst:280 +#: ../../library/resource.rst:330 msgid "These functions are used to retrieve resource usage information:" msgstr "" -#: ../../library/resource.rst:285 +#: ../../library/resource.rst:335 msgid "" "This function returns an object that describes the resources consumed by " "either the current process or its children, as specified by the *who* " @@ -298,11 +335,11 @@ msgid "" "`!RUSAGE_\\*` constants described below." msgstr "" -#: ../../library/resource.rst:290 +#: ../../library/resource.rst:340 msgid "A simple example::" msgstr "一個簡單範例: ::" -#: ../../library/resource.rst:292 +#: ../../library/resource.rst:342 msgid "" "from resource import *\n" "import time\n" @@ -317,7 +354,7 @@ msgid "" "print(getrusage(RUSAGE_SELF))" msgstr "" -#: ../../library/resource.rst:304 +#: ../../library/resource.rst:354 msgid "" "The fields of the return value each describe how a particular system " "resource has been used, e.g. amount of time spent running in user mode or " @@ -326,13 +363,13 @@ msgid "" "is using." msgstr "" -#: ../../library/resource.rst:309 +#: ../../library/resource.rst:359 msgid "" "For backward compatibility, the return value is also accessible as a tuple " "of 16 elements." msgstr "" -#: ../../library/resource.rst:312 +#: ../../library/resource.rst:362 msgid "" "The fields :attr:`!ru_utime` and :attr:`!ru_stime` of the return value are " "floating-point values representing the amount of time spent executing in " @@ -342,249 +379,249 @@ msgid "" "summary is presented here:" msgstr "" -#: ../../library/resource.rst:319 +#: ../../library/resource.rst:369 msgid "Index" msgstr "" -#: ../../library/resource.rst:319 +#: ../../library/resource.rst:369 msgid "Field" msgstr "" -#: ../../library/resource.rst:319 +#: ../../library/resource.rst:369 msgid "Resource" msgstr "" -#: ../../library/resource.rst:321 +#: ../../library/resource.rst:371 msgid "``0``" msgstr "``0``" -#: ../../library/resource.rst:321 +#: ../../library/resource.rst:371 msgid ":attr:`!ru_utime`" msgstr ":attr:`!ru_utime`" -#: ../../library/resource.rst:321 +#: ../../library/resource.rst:371 msgid "time in user mode (float seconds)" msgstr "" -#: ../../library/resource.rst:323 +#: ../../library/resource.rst:373 msgid "``1``" msgstr "``1``" -#: ../../library/resource.rst:323 +#: ../../library/resource.rst:373 msgid ":attr:`!ru_stime`" msgstr ":attr:`!ru_stime`" -#: ../../library/resource.rst:323 +#: ../../library/resource.rst:373 msgid "time in system mode (float seconds)" msgstr "" -#: ../../library/resource.rst:325 +#: ../../library/resource.rst:375 msgid "``2``" msgstr "``2``" -#: ../../library/resource.rst:325 +#: ../../library/resource.rst:375 msgid ":attr:`!ru_maxrss`" msgstr ":attr:`!ru_maxrss`" -#: ../../library/resource.rst:325 +#: ../../library/resource.rst:375 msgid "maximum resident set size" msgstr "" -#: ../../library/resource.rst:327 +#: ../../library/resource.rst:377 msgid "``3``" msgstr "``3``" -#: ../../library/resource.rst:327 +#: ../../library/resource.rst:377 msgid ":attr:`!ru_ixrss`" msgstr ":attr:`!ru_ixrss`" -#: ../../library/resource.rst:327 +#: ../../library/resource.rst:377 msgid "shared memory size" msgstr "" -#: ../../library/resource.rst:329 +#: ../../library/resource.rst:379 msgid "``4``" msgstr "``4``" -#: ../../library/resource.rst:329 +#: ../../library/resource.rst:379 msgid ":attr:`!ru_idrss`" msgstr ":attr:`!ru_idrss`" -#: ../../library/resource.rst:329 +#: ../../library/resource.rst:379 msgid "unshared memory size" msgstr "" -#: ../../library/resource.rst:331 +#: ../../library/resource.rst:381 msgid "``5``" msgstr "``5``" -#: ../../library/resource.rst:331 +#: ../../library/resource.rst:381 msgid ":attr:`!ru_isrss`" msgstr ":attr:`!ru_isrss`" -#: ../../library/resource.rst:331 +#: ../../library/resource.rst:381 msgid "unshared stack size" msgstr "" -#: ../../library/resource.rst:333 +#: ../../library/resource.rst:383 msgid "``6``" msgstr "``6``" -#: ../../library/resource.rst:333 +#: ../../library/resource.rst:383 msgid ":attr:`!ru_minflt`" msgstr ":attr:`!ru_minflt`" -#: ../../library/resource.rst:333 +#: ../../library/resource.rst:383 msgid "page faults not requiring I/O" msgstr "" -#: ../../library/resource.rst:335 +#: ../../library/resource.rst:385 msgid "``7``" msgstr "``7``" -#: ../../library/resource.rst:335 +#: ../../library/resource.rst:385 msgid ":attr:`!ru_majflt`" msgstr ":attr:`!ru_majflt`" -#: ../../library/resource.rst:335 +#: ../../library/resource.rst:385 msgid "page faults requiring I/O" msgstr "" -#: ../../library/resource.rst:337 +#: ../../library/resource.rst:387 msgid "``8``" msgstr "``8``" -#: ../../library/resource.rst:337 +#: ../../library/resource.rst:387 msgid ":attr:`!ru_nswap`" msgstr ":attr:`!ru_nswap`" -#: ../../library/resource.rst:337 +#: ../../library/resource.rst:387 msgid "number of swap outs" msgstr "" -#: ../../library/resource.rst:339 +#: ../../library/resource.rst:389 msgid "``9``" msgstr "``9``" -#: ../../library/resource.rst:339 +#: ../../library/resource.rst:389 msgid ":attr:`!ru_inblock`" msgstr ":attr:`!ru_inblock`" -#: ../../library/resource.rst:339 +#: ../../library/resource.rst:389 msgid "block input operations" msgstr "" -#: ../../library/resource.rst:341 +#: ../../library/resource.rst:391 msgid "``10``" msgstr "``10``" -#: ../../library/resource.rst:341 +#: ../../library/resource.rst:391 msgid ":attr:`!ru_oublock`" msgstr ":attr:`!ru_oublock`" -#: ../../library/resource.rst:341 +#: ../../library/resource.rst:391 msgid "block output operations" msgstr "" -#: ../../library/resource.rst:343 +#: ../../library/resource.rst:393 msgid "``11``" msgstr "``11``" -#: ../../library/resource.rst:343 +#: ../../library/resource.rst:393 msgid ":attr:`!ru_msgsnd`" msgstr ":attr:`!ru_msgsnd`" -#: ../../library/resource.rst:343 +#: ../../library/resource.rst:393 msgid "messages sent" msgstr "" -#: ../../library/resource.rst:345 +#: ../../library/resource.rst:395 msgid "``12``" msgstr "``12``" -#: ../../library/resource.rst:345 +#: ../../library/resource.rst:395 msgid ":attr:`!ru_msgrcv`" msgstr ":attr:`!ru_msgrcv`" -#: ../../library/resource.rst:345 +#: ../../library/resource.rst:395 msgid "messages received" msgstr "" -#: ../../library/resource.rst:347 +#: ../../library/resource.rst:397 msgid "``13``" msgstr "``13``" -#: ../../library/resource.rst:347 +#: ../../library/resource.rst:397 msgid ":attr:`!ru_nsignals`" msgstr ":attr:`!ru_nsignals`" -#: ../../library/resource.rst:347 +#: ../../library/resource.rst:397 msgid "signals received" msgstr "" -#: ../../library/resource.rst:349 +#: ../../library/resource.rst:399 msgid "``14``" msgstr "``14``" -#: ../../library/resource.rst:349 +#: ../../library/resource.rst:399 msgid ":attr:`!ru_nvcsw`" msgstr ":attr:`!ru_nvcsw`" -#: ../../library/resource.rst:349 +#: ../../library/resource.rst:399 msgid "voluntary context switches" msgstr "" -#: ../../library/resource.rst:351 +#: ../../library/resource.rst:401 msgid "``15``" msgstr "``15``" -#: ../../library/resource.rst:351 +#: ../../library/resource.rst:401 msgid ":attr:`!ru_nivcsw`" msgstr ":attr:`!ru_nivcsw`" -#: ../../library/resource.rst:351 +#: ../../library/resource.rst:401 msgid "involuntary context switches" msgstr "" -#: ../../library/resource.rst:354 +#: ../../library/resource.rst:404 msgid "" "This function will raise a :exc:`ValueError` if an invalid *who* parameter " "is specified. It may also raise :exc:`error` exception in unusual " "circumstances." msgstr "" -#: ../../library/resource.rst:360 +#: ../../library/resource.rst:410 msgid "" "Returns the number of bytes in a system page. (This need not be the same as " "the hardware page size.)" msgstr "" -#: ../../library/resource.rst:363 +#: ../../library/resource.rst:413 msgid "" "The following :const:`!RUSAGE_\\*` symbols are passed to the :func:" "`getrusage` function to specify which processes information should be " "provided for." msgstr "" -#: ../../library/resource.rst:369 +#: ../../library/resource.rst:419 msgid "" "Pass to :func:`getrusage` to request resources consumed by the calling " "process, which is the sum of resources used by all threads in the process." msgstr "" -#: ../../library/resource.rst:375 +#: ../../library/resource.rst:425 msgid "" "Pass to :func:`getrusage` to request resources consumed by child processes " "of the calling process which have been terminated and waited for." msgstr "" -#: ../../library/resource.rst:381 +#: ../../library/resource.rst:431 msgid "" "Pass to :func:`getrusage` to request resources consumed by both the current " "process and child processes. May not be available on all systems." msgstr "" -#: ../../library/resource.rst:387 +#: ../../library/resource.rst:437 msgid "" "Pass to :func:`getrusage` to request resources consumed by the current " "thread. May not be available on all systems." diff --git a/library/rlcompleter.po b/library/rlcompleter.po index aecd565c788..db638f0261a 100644 --- a/library/rlcompleter.po +++ b/library/rlcompleter.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,17 +21,17 @@ msgstr "" msgid ":mod:`!rlcompleter` --- Completion function for GNU readline" msgstr ":mod:`!rlcompleter` --- GNU readline 的補全函式" -#: ../../library/rlcompleter.rst:9 +#: ../../library/rlcompleter.rst:7 msgid "**Source code:** :source:`Lib/rlcompleter.py`" msgstr "**原始碼:**\\ :source:`Lib/rlcompleter.py`" -#: ../../library/rlcompleter.rst:13 +#: ../../library/rlcompleter.rst:11 msgid "" "The :mod:`!rlcompleter` module defines a completion function suitable to be " "passed to :func:`~readline.set_completer` in the :mod:`readline` module." msgstr "" -#: ../../library/rlcompleter.rst:16 +#: ../../library/rlcompleter.rst:14 msgid "" "When this module is imported on a Unix platform with the :mod:`readline` " "module available, an instance of the :class:`Completer` class is " @@ -40,11 +40,11 @@ msgid "" "completion of valid Python :ref:`identifiers and keywords `." msgstr "" -#: ../../library/rlcompleter.rst:22 +#: ../../library/rlcompleter.rst:20 msgid "Example::" msgstr "範例: ::" -#: ../../library/rlcompleter.rst:24 +#: ../../library/rlcompleter.rst:22 msgid "" ">>> import rlcompleter\n" ">>> import readline\n" @@ -68,7 +68,7 @@ msgstr "" "readline.__name__ readline.parse_and_bind(\n" ">>> readline." -#: ../../library/rlcompleter.rst:33 +#: ../../library/rlcompleter.rst:31 msgid "" "The :mod:`!rlcompleter` module is designed for use with Python's :ref:" "`interactive mode `. Unless Python is run with the :option:" @@ -76,35 +76,35 @@ msgid "" "`rlcompleter-config`)." msgstr "" -#: ../../library/rlcompleter.rst:38 +#: ../../library/rlcompleter.rst:36 msgid "" "On platforms without :mod:`readline`, the :class:`Completer` class defined " "by this module can still be used for custom purposes." msgstr "" -#: ../../library/rlcompleter.rst:46 +#: ../../library/rlcompleter.rst:44 msgid "Completer objects have the following method:" msgstr "" -#: ../../library/rlcompleter.rst:50 +#: ../../library/rlcompleter.rst:48 msgid "Return the next possible completion for *text*." msgstr "" -#: ../../library/rlcompleter.rst:52 +#: ../../library/rlcompleter.rst:50 msgid "" "When called by the :mod:`readline` module, this method is called " "successively with ``state == 0, 1, 2, ...`` until the method returns " "``None``." msgstr "" -#: ../../library/rlcompleter.rst:56 +#: ../../library/rlcompleter.rst:54 msgid "" "If called for *text* that doesn't include a period character (``'.'``), it " "will complete from names currently defined in :mod:`__main__`, :mod:" "`builtins` and keywords (as defined by the :mod:`keyword` module)." msgstr "" -#: ../../library/rlcompleter.rst:60 +#: ../../library/rlcompleter.rst:58 msgid "" "If called for a dotted name, it will try to evaluate anything without " "obvious side-effects (functions will not be evaluated, but it can generate " diff --git a/library/runpy.po b/library/runpy.po index b106ed0a20e..8280dd3ac6e 100644 --- a/library/runpy.po +++ b/library/runpy.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2016-11-19 00:33+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!runpy` --- Locating and executing Python modules" msgstr ":mod:`!runpy` --- 定位並執行 Python 模組" -#: ../../library/runpy.rst:9 +#: ../../library/runpy.rst:7 msgid "**Source code:** :source:`Lib/runpy.py`" msgstr "**原始碼:**\\ :source:`Lib/runpy.py`" -#: ../../library/runpy.rst:13 +#: ../../library/runpy.rst:11 msgid "" "The :mod:`!runpy` module is used to locate and run Python modules without " "importing them first. Its main use is to implement the :option:`-m` command " @@ -33,14 +33,14 @@ msgid "" "namespace rather than the filesystem." msgstr "" -#: ../../library/runpy.rst:18 +#: ../../library/runpy.rst:16 msgid "" "Note that this is *not* a sandbox module - all code is executed in the " "current process, and any side effects (such as cached imports of other " "modules) will remain in place after the functions have returned." msgstr "" -#: ../../library/runpy.rst:22 +#: ../../library/runpy.rst:20 msgid "" "Furthermore, any functions and classes defined by the executed code are not " "guaranteed to work correctly after a :mod:`!runpy` function has returned. If " @@ -48,11 +48,11 @@ msgid "" "likely to be a more suitable choice than this module." msgstr "" -#: ../../library/runpy.rst:27 +#: ../../library/runpy.rst:25 msgid "The :mod:`!runpy` module provides two functions:" msgstr "" -#: ../../library/runpy.rst:35 +#: ../../library/runpy.rst:33 msgid "" "Execute the code of the specified module and return the resulting module's " "globals dictionary. The module's code is first located using the standard " @@ -60,7 +60,7 @@ msgid "" "fresh module namespace." msgstr "" -#: ../../library/runpy.rst:40 +#: ../../library/runpy.rst:38 msgid "" "The *mod_name* argument should be an absolute module name. If the module " "name refers to a package rather than a normal module, then that package is " @@ -68,7 +68,7 @@ msgid "" "executed and the resulting module globals dictionary returned." msgstr "" -#: ../../library/runpy.rst:46 +#: ../../library/runpy.rst:44 msgid "" "The optional dictionary argument *init_globals* may be used to pre-populate " "the module's globals dictionary before the code is executed. *init_globals* " @@ -77,36 +77,36 @@ msgid "" "`run_module`." msgstr "" -#: ../../library/runpy.rst:52 ../../library/runpy.rst:127 +#: ../../library/runpy.rst:50 ../../library/runpy.rst:128 msgid "" "The special global variables ``__name__``, ``__spec__``, ``__file__``, " -"``__cached__``, ``__loader__`` and ``__package__`` are set in the globals " -"dictionary before the module code is executed. (Note that this is a minimal " -"set of variables - other variables may be set implicitly as an interpreter " -"implementation detail.)" +"``__loader__`` and ``__package__`` are set in the globals dictionary before " +"the module code is executed. (Note that this is a minimal set of variables - " +"other variables may be set implicitly as an interpreter implementation " +"detail.)" msgstr "" -#: ../../library/runpy.rst:58 +#: ../../library/runpy.rst:56 msgid "" "``__name__`` is set to *run_name* if this optional argument is not :const:" "`None`, to ``mod_name + '.__main__'`` if the named module is a package and " "to the *mod_name* argument otherwise." msgstr "" -#: ../../library/runpy.rst:62 +#: ../../library/runpy.rst:60 msgid "" "``__spec__`` will be set appropriately for the *actually* imported module " "(that is, ``__spec__.name`` will always be *mod_name* or ``mod_name + '." "__main__'``, never *run_name*)." msgstr "" -#: ../../library/runpy.rst:66 +#: ../../library/runpy.rst:64 msgid "" -"``__file__``, ``__cached__``, ``__loader__`` and ``__package__`` are :ref:" -"`set as normal ` based on the module spec." +"``__file__``, ``__loader__`` and ``__package__`` are :ref:`set as normal " +"` based on the module spec." msgstr "" -#: ../../library/runpy.rst:69 +#: ../../library/runpy.rst:67 msgid "" "If the argument *alter_sys* is supplied and evaluates to :const:`True`, then " "``sys.argv[0]`` is updated with the value of ``__file__`` and ``sys." @@ -115,7 +115,7 @@ msgid "" "restored to their original values before the function returns." msgstr "" -#: ../../library/runpy.rst:75 +#: ../../library/runpy.rst:73 msgid "" "Note that this manipulation of :mod:`sys` is not thread-safe. Other threads " "may see the partially initialised module, as well as the altered list of " @@ -123,22 +123,22 @@ msgid "" "invoking this function from threaded code." msgstr "" -#: ../../library/runpy.rst:81 +#: ../../library/runpy.rst:79 msgid "" "The :option:`-m` option offering equivalent functionality from the command " "line." msgstr "" -#: ../../library/runpy.rst:84 +#: ../../library/runpy.rst:82 msgid "" "Added ability to execute packages by looking for a :mod:`__main__` submodule." msgstr "" -#: ../../library/runpy.rst:87 +#: ../../library/runpy.rst:85 msgid "Added ``__cached__`` global variable (see :pep:`3147`)." msgstr "新增 ``__cached__`` 全域變數(請參閱 :pep:`3147`)。" -#: ../../library/runpy.rst:90 +#: ../../library/runpy.rst:88 msgid "" "Updated to take advantage of the module spec feature added by :pep:`451`. " "This allows ``__cached__`` to be set correctly for modules run this way, as " @@ -146,13 +146,17 @@ msgid "" "name``." msgstr "" -#: ../../library/runpy.rst:96 +#: ../../library/runpy.rst:94 msgid "" "The setting of ``__cached__``, ``__loader__``, and ``__package__`` are " "deprecated. See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" -#: ../../library/runpy.rst:106 +#: ../../library/runpy.rst:99 ../../library/runpy.rst:177 +msgid "The global variable ``__cached__`` is no longer set." +msgstr "" + +#: ../../library/runpy.rst:107 msgid "" "Execute the code at the named filesystem location and return the resulting " "module's globals dictionary. As with a script name supplied to the CPython " @@ -161,7 +165,7 @@ msgid "" "module (e.g. a zipfile containing a top-level :file:`__main__.py` file)." msgstr "" -#: ../../library/runpy.rst:113 +#: ../../library/runpy.rst:114 msgid "" "For a simple script, the specified code is simply executed in a fresh module " "namespace. For a valid :data:`sys.path` entry (typically a zipfile or " @@ -172,7 +176,7 @@ msgid "" "such module at the specified location." msgstr "" -#: ../../library/runpy.rst:121 +#: ../../library/runpy.rst:122 msgid "" "The optional dictionary argument *init_globals* may be used to pre-populate " "the module's globals dictionary before the code is executed. *init_globals* " @@ -181,30 +185,30 @@ msgid "" "`run_path`." msgstr "" -#: ../../library/runpy.rst:133 +#: ../../library/runpy.rst:134 msgid "" "``__name__`` is set to *run_name* if this optional argument is not :const:" "`None` and to ``''`` otherwise." msgstr "" -#: ../../library/runpy.rst:136 +#: ../../library/runpy.rst:137 msgid "" "If *file_path* directly references a script file (whether as source or as " "precompiled byte code), then ``__file__`` will be set to *file_path*, and " -"``__spec__``, ``__cached__``, ``__loader__`` and ``__package__`` will all be " -"set to :const:`None`." +"``__spec__``, ``__loader__`` and ``__package__`` will all be set to :const:" +"`None`." msgstr "" -#: ../../library/runpy.rst:141 +#: ../../library/runpy.rst:142 msgid "" "If *file_path* is a reference to a valid :data:`sys.path` entry, then " "``__spec__`` will be set appropriately for the imported :mod:`__main__` " "module (that is, ``__spec__.name`` will always be ``__main__``). " -"``__file__``, ``__cached__``, ``__loader__`` and ``__package__`` will be :" -"ref:`set as normal ` based on the module spec." +"``__file__``, ``__loader__`` and ``__package__`` will be :ref:`set as normal " +"` based on the module spec." msgstr "" -#: ../../library/runpy.rst:147 +#: ../../library/runpy.rst:148 msgid "" "A number of alterations are also made to the :mod:`sys` module. Firstly, :" "data:`sys.path` may be altered as described above. ``sys.argv[0]`` is " @@ -214,7 +218,7 @@ msgid "" "returns." msgstr "" -#: ../../library/runpy.rst:154 +#: ../../library/runpy.rst:155 msgid "" "Note that, unlike :func:`run_module`, the alterations made to :mod:`sys` are " "not optional in this function as these adjustments are essential to allowing " @@ -223,13 +227,13 @@ msgid "" "serialised with the import lock or delegated to a separate process." msgstr "" -#: ../../library/runpy.rst:161 +#: ../../library/runpy.rst:162 msgid "" ":ref:`using-on-interface-options` for equivalent functionality on the " "command line (``python path/to/script``)." msgstr "" -#: ../../library/runpy.rst:166 +#: ../../library/runpy.rst:167 msgid "" "Updated to take advantage of the module spec feature added by :pep:`451`. " "This allows ``__cached__`` to be set correctly in the case where " @@ -237,44 +241,44 @@ msgid "" "being executed directly." msgstr "" -#: ../../library/runpy.rst:172 +#: ../../library/runpy.rst:173 msgid "" "The setting of ``__cached__``, ``__loader__``, and ``__package__`` are " "deprecated." msgstr "" -#: ../../library/runpy.rst:178 +#: ../../library/runpy.rst:182 msgid ":pep:`338` -- Executing modules as scripts" msgstr "" -#: ../../library/runpy.rst:179 ../../library/runpy.rst:182 +#: ../../library/runpy.rst:183 ../../library/runpy.rst:186 msgid "PEP written and implemented by Nick Coghlan." msgstr "" -#: ../../library/runpy.rst:181 +#: ../../library/runpy.rst:185 msgid ":pep:`366` -- Main module explicit relative imports" msgstr "" -#: ../../library/runpy.rst:184 +#: ../../library/runpy.rst:188 msgid ":pep:`451` -- A ModuleSpec Type for the Import System" msgstr "" -#: ../../library/runpy.rst:185 +#: ../../library/runpy.rst:189 msgid "PEP written and implemented by Eric Snow" msgstr "" -#: ../../library/runpy.rst:187 +#: ../../library/runpy.rst:191 msgid ":ref:`using-on-general` - CPython command line details" msgstr "" -#: ../../library/runpy.rst:189 +#: ../../library/runpy.rst:193 msgid "The :func:`importlib.import_module` function" msgstr "" -#: ../../library/runpy.rst:32 ../../library/runpy.rst:103 +#: ../../library/runpy.rst:30 ../../library/runpy.rst:104 msgid "module" msgstr "module(模組)" -#: ../../library/runpy.rst:32 ../../library/runpy.rst:103 +#: ../../library/runpy.rst:30 ../../library/runpy.rst:104 msgid "__main__" msgstr "__main__" diff --git a/library/sched.po b/library/sched.po index 829489c88ea..e2c1905a676 100644 --- a/library/sched.po +++ b/library/sched.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-01 00:42+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-05-09 16:09+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,17 +22,17 @@ msgstr "" msgid ":mod:`!sched` --- Event scheduler" msgstr ":mod:`!sched` --- 事件排程器" -#: ../../library/sched.rst:9 +#: ../../library/sched.rst:7 msgid "**Source code:** :source:`Lib/sched.py`" msgstr "**原始碼:**\\ :source:`Lib/sched.py`" -#: ../../library/sched.rst:15 +#: ../../library/sched.rst:13 msgid "" "The :mod:`!sched` module defines a class which implements a general purpose " "event scheduler:" msgstr ":mod:`!sched` 模組定義了一個有實作通用事件排程器的類別:" -#: ../../library/sched.rst:20 +#: ../../library/sched.rst:18 msgid "" "The :class:`scheduler` class defines a generic interface to scheduling " "events. It needs two functions to actually deal with the \"outside world\" " @@ -49,20 +49,20 @@ msgstr "" "延遲其指定的時間單位。每個事件運行後,也會以引數 ``0`` 呼叫 *delayfunc*,來使" "得其他執行緒有機會在多執行緒應用程式中運行。" -#: ../../library/sched.rst:29 +#: ../../library/sched.rst:27 msgid "*timefunc* and *delayfunc* parameters are optional." msgstr "*timefunc* 和 *delayfunc* 參數是可選的。" -#: ../../library/sched.rst:32 +#: ../../library/sched.rst:30 msgid "" ":class:`scheduler` class can be safely used in multi-threaded environments." msgstr ":class:`scheduler` 類別可以安全地在多執行緒環境中使用。" -#: ../../library/sched.rst:36 +#: ../../library/sched.rst:34 msgid "Example::" msgstr "範例: ::" -#: ../../library/sched.rst:38 +#: ../../library/sched.rst:36 msgid "" ">>> import sched, time\n" ">>> s = sched.scheduler(time.time, time.sleep)\n" @@ -120,15 +120,15 @@ msgstr "" "From print_time 1652342840.369612 default\n" "1652342840.3697174" -#: ../../library/sched.rst:67 +#: ../../library/sched.rst:65 msgid "Scheduler Objects" msgstr "排程器物件" -#: ../../library/sched.rst:69 +#: ../../library/sched.rst:67 msgid ":class:`scheduler` instances have the following methods and attributes:" msgstr ":class:`scheduler` 實例具有以下方法和屬性:" -#: ../../library/sched.rst:74 +#: ../../library/sched.rst:72 msgid "" "Schedule a new event. The *time* argument should be a numeric type " "compatible with the return value of the *timefunc* function passed to the " @@ -139,7 +139,7 @@ msgstr "" "容的數字型別。安排在相同 *time* 的事件將按照其 *priority* 的順序執行。數字越" "小代表優先順序越高。" -#: ../../library/sched.rst:79 +#: ../../library/sched.rst:77 msgid "" "Executing the event means executing ``action(*argument, **kwargs)``. " "*argument* is a sequence holding the positional arguments for *action*. " @@ -148,21 +148,21 @@ msgstr "" "執行事件意味著執行 ``action(*argument, **kwargs)``。*argument* 是一個包含 " "*action* 之位置引數的序列。*kwargs* 是一個字典,帶有 *action* 的關鍵字引數。" -#: ../../library/sched.rst:83 +#: ../../library/sched.rst:81 msgid "" "Return value is an event which may be used for later cancellation of the " "event (see :meth:`cancel`)." msgstr "回傳值是一個事件,可用於後續取消該事件(請見 :meth:`cancel`)。" -#: ../../library/sched.rst:86 ../../library/sched.rst:99 +#: ../../library/sched.rst:84 ../../library/sched.rst:97 msgid "*argument* parameter is optional." msgstr "*argument* 參數是可選的。" -#: ../../library/sched.rst:89 ../../library/sched.rst:102 +#: ../../library/sched.rst:87 ../../library/sched.rst:100 msgid "*kwargs* parameter was added." msgstr "新增 *kwargs* 參數。" -#: ../../library/sched.rst:95 +#: ../../library/sched.rst:93 msgid "" "Schedule an event for *delay* more time units. Other than the relative time, " "the other arguments, the effect and the return value are the same as those " @@ -171,7 +171,7 @@ msgstr "" "為一個排程事件延期 *delay* 個時間單位。除了相對時間之外,其他引數、效果和回傳" "值皆與 :meth:`enterabs` 的相同。" -#: ../../library/sched.rst:107 +#: ../../library/sched.rst:105 msgid "" "Remove the event from the queue. If *event* is not an event currently in the " "queue, this method will raise a :exc:`ValueError`." @@ -179,11 +179,11 @@ msgstr "" "從佇列中刪除該事件。如果 *event* 不是目前佇列中的事件,此方法將引發 :exc:" "`ValueError`。" -#: ../../library/sched.rst:113 +#: ../../library/sched.rst:111 msgid "Return ``True`` if the event queue is empty." msgstr "如果事件佇列為空,則回傳 ``True``。" -#: ../../library/sched.rst:118 +#: ../../library/sched.rst:116 msgid "" "Run all scheduled events. This method will wait (using the *delayfunc* " "function passed to the constructor) for the next event, then execute it and " @@ -192,7 +192,7 @@ msgstr "" "運行所有已排程的事件。此方法將會等待(使用傳遞給建構函式的 *delayfunc* 函式)" "下一個事件,然後執行它,並依此類推,直到不再有排程好的事件。" -#: ../../library/sched.rst:122 +#: ../../library/sched.rst:120 msgid "" "If *blocking* is false, immediately executes all events in the queue which " "have a time value less than or equal to the current *timefunc* value (if " @@ -201,7 +201,7 @@ msgid "" "the queue is empty, returns ``None``." msgstr "" -#: ../../library/sched.rst:128 +#: ../../library/sched.rst:126 msgid "" "Either *action* or *delayfunc* can raise an exception. In either case, the " "scheduler will maintain a consistent state and propagate the exception. If " @@ -212,7 +212,7 @@ msgstr "" "態並傳遞例外。如果是由 *action* 引發例外,則後續呼叫 :meth:`run` 時將不會嘗試" "運行該事件。" -#: ../../library/sched.rst:133 +#: ../../library/sched.rst:131 msgid "" "If a sequence of events takes longer to run than the time available before " "the next event, the scheduler will simply fall behind. No events will be " @@ -223,11 +223,11 @@ msgstr "" "那麼排程器就單純會落後。不會有事件被丟棄;呼叫程式碼也要負責取消不再相關的事" "件。" -#: ../../library/sched.rst:138 +#: ../../library/sched.rst:136 msgid "*blocking* parameter was added." msgstr "新增 *blocking* 參數。" -#: ../../library/sched.rst:143 +#: ../../library/sched.rst:141 msgid "" "Read-only attribute returning a list of upcoming events in the order they " "will be run. Each event is shown as a :term:`named tuple` with the " @@ -237,7 +237,7 @@ msgstr "" "元組 (named tuple) ` 表示,並包含以下欄位:時間、優先順序、動作 " "(action)、引數、kwargs。" -#: ../../library/sched.rst:11 +#: ../../library/sched.rst:9 msgid "event scheduling" msgstr "event scheduling(事件排程)" diff --git a/library/secrets.po b/library/secrets.po index ff4d8e4b699..a152dfdff8d 100644 --- a/library/secrets.po +++ b/library/secrets.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-21 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-11-30 13:42+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!secrets` --- Generate secure random numbers for managing secrets" msgstr ":mod:`!secrets` --- 產生用於管理機密的安全亂數" -#: ../../library/secrets.rst:16 +#: ../../library/secrets.rst:14 msgid "**Source code:** :source:`Lib/secrets.py`" msgstr "**原始碼:**\\ :source:`Lib/secrets.py`" -#: ../../library/secrets.rst:20 +#: ../../library/secrets.rst:18 msgid "" "The :mod:`!secrets` module is used for generating cryptographically strong " "random numbers suitable for managing data such as passwords, account " @@ -36,7 +36,7 @@ msgstr "" ":mod:`!secrets` 模組可用於產生高加密強度的亂數,適合用來管理諸如密碼、帳號認" "證、安全性權杖(security tokens)這類資料,以及管理其他相關的機密資料。" -#: ../../library/secrets.rst:24 +#: ../../library/secrets.rst:22 msgid "" "In particular, :mod:`!secrets` should be used in preference to the default " "pseudo-random number generator in the :mod:`random` module, which is " @@ -46,21 +46,21 @@ msgstr "" "數產生器(pseudo-random number generator),該模組被設計用於建模和模擬,而非" "用於安全性和加密。" -#: ../../library/secrets.rst:30 +#: ../../library/secrets.rst:28 msgid ":pep:`506`" msgstr ":pep:`506`" -#: ../../library/secrets.rst:34 +#: ../../library/secrets.rst:32 msgid "Random numbers" msgstr "亂數" -#: ../../library/secrets.rst:36 +#: ../../library/secrets.rst:34 msgid "" "The :mod:`!secrets` module provides access to the most secure source of " "randomness that your operating system provides." msgstr ":mod:`!secrets` 模組使你得以存取作業系統所提供安全性最高的亂數產生器。" -#: ../../library/secrets.rst:41 +#: ../../library/secrets.rst:39 msgid "" "A class for generating random numbers using the highest-quality sources " "provided by the operating system. See :class:`random.SystemRandom` for " @@ -69,23 +69,23 @@ msgstr "" "一個用來產生亂數的類別,用的是作業系統提供的最高品質來源。 請參閱 :class:" "`random.SystemRandom` 以取得更多細節。" -#: ../../library/secrets.rst:47 +#: ../../library/secrets.rst:45 msgid "Return a randomly chosen element from a non-empty sequence." msgstr "從一非空序列中,回傳一個隨機選取的元素。" -#: ../../library/secrets.rst:51 +#: ../../library/secrets.rst:49 msgid "Return a random int in the range [0, *exclusive_upper_bound*)." msgstr "回傳一個 [0, *exclusive_upper_bound*) 範圍之內的隨機整數。" -#: ../../library/secrets.rst:55 +#: ../../library/secrets.rst:53 msgid "Return a non-negative int with *k* random bits." msgstr "回傳一個具 *k* 個隨機位元的非負整數。" -#: ../../library/secrets.rst:59 +#: ../../library/secrets.rst:57 msgid "Generating tokens" msgstr "產生權杖(token)" -#: ../../library/secrets.rst:61 +#: ../../library/secrets.rst:59 msgid "" "The :mod:`!secrets` module provides functions for generating secure tokens, " "suitable for applications such as password resets, hard-to-guess URLs, and " @@ -94,19 +94,19 @@ msgstr "" ":mod:`!secrets` 模組提供了一些產生安全性權杖的函式,適合用於諸如重設密碼、難" "以猜測的 URL,或類似的應用。" -#: ../../library/secrets.rst:67 +#: ../../library/secrets.rst:65 msgid "Return a random byte string containing *nbytes* number of bytes." msgstr "回傳一個隨機位元組字串,其中含有 *nbytes* 位元組的數字。" -#: ../../library/secrets.rst:69 ../../library/secrets.rst:83 -#: ../../library/secrets.rst:97 +#: ../../library/secrets.rst:67 ../../library/secrets.rst:81 +#: ../../library/secrets.rst:95 msgid "" "If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY` is used " "instead." msgstr "" " 如果 *nbytes* 未指定或為 ``None`` ,則會改用 :const:`DEFAULT_ENTROPY`。" -#: ../../library/secrets.rst:72 +#: ../../library/secrets.rst:70 msgid "" ">>> token_bytes(16)\n" "b'\\xebr\\x17D*t\\xae\\xd4\\xe3S\\xb6\\xe2\\xebP1\\x8b'" @@ -114,7 +114,7 @@ msgstr "" ">>> token_bytes(16)\n" "b'\\xebr\\x17D*t\\xae\\xd4\\xe3S\\xb6\\xe2\\xebP1\\x8b'" -#: ../../library/secrets.rst:80 +#: ../../library/secrets.rst:78 msgid "" "Return a random text string, in hexadecimal. The string has *nbytes* random " "bytes, each byte converted to two hex digits." @@ -122,7 +122,7 @@ msgstr "" "回傳一以十六進位表示的隨機字串。 字串具有 *nbytes* 個隨機位元組,每個位元組會" "轉成兩個十六進位的數字。" -#: ../../library/secrets.rst:86 +#: ../../library/secrets.rst:84 msgid "" ">>> token_hex(16)\n" "'f9bf78b9a18ce6d46a0cd2b0b86df9da'" @@ -130,7 +130,7 @@ msgstr "" ">>> token_hex(16)\n" "'f9bf78b9a18ce6d46a0cd2b0b86df9da'" -#: ../../library/secrets.rst:93 +#: ../../library/secrets.rst:91 msgid "" "Return a random URL-safe text string, containing *nbytes* random bytes. The " "text is Base64 encoded, so on average each byte results in approximately 1.3 " @@ -139,7 +139,7 @@ msgstr "" "回傳一個 URL 安全的隨機文本字串,包含 *nbytes* 個隨機位元組。 文本將使用 " "Base64 編碼,因此平均來說每個位元組會對應到約 1.3 個字元。" -#: ../../library/secrets.rst:100 +#: ../../library/secrets.rst:98 msgid "" ">>> token_urlsafe(16)\n" "'Drmhze6EPcv0fN_81Bj-nA'" @@ -147,11 +147,11 @@ msgstr "" ">>> token_urlsafe(16)\n" "'Drmhze6EPcv0fN_81Bj-nA'" -#: ../../library/secrets.rst:107 +#: ../../library/secrets.rst:105 msgid "How many bytes should tokens use?" msgstr "權杖應當使用多少個位元組?" -#: ../../library/secrets.rst:109 +#: ../../library/secrets.rst:107 msgid "" "To be secure against `brute-force attacks `_, tokens need to have sufficient randomness. " @@ -167,7 +167,7 @@ msgstr "" "高。在 2015 年時,人們認為 32 位元組(256 位元)的隨機性對於 :mod:`!secrets` " "模組所預期的一般使用場景來說是足夠的。" -#: ../../library/secrets.rst:117 +#: ../../library/secrets.rst:115 msgid "" "For those who want to manage their own token length, you can explicitly " "specify how much randomness is used for tokens by giving an :class:`int` " @@ -178,7 +178,7 @@ msgstr "" "class:`int` 引數(argument)來指定權杖要使用的隨機性程度。 該引數以位元組數來" "表示要使用的隨機性程度。" -#: ../../library/secrets.rst:122 +#: ../../library/secrets.rst:120 msgid "" "Otherwise, if no argument is provided, or if the argument is ``None``, the " "``token_*`` functions use :const:`DEFAULT_ENTROPY` instead." @@ -186,22 +186,22 @@ msgstr "" "否則,如未提供引數,或者如果引數為 ``None``,則 ``token_*`` 函式則會改用 :" "const:`DEFAULT_ENTROPY`。" -#: ../../library/secrets.rst:127 +#: ../../library/secrets.rst:125 msgid "" "Default number of bytes of randomness used by the ``token_*`` functions." msgstr "" -#: ../../library/secrets.rst:129 +#: ../../library/secrets.rst:127 msgid "" "The exact value is subject to change at any time, including during " "maintenance releases." msgstr "該確切值可能在任何時候被改變,包括在維護版本更新的時候。" -#: ../../library/secrets.rst:134 +#: ../../library/secrets.rst:132 msgid "Other functions" msgstr "其他函式" -#: ../../library/secrets.rst:138 +#: ../../library/secrets.rst:136 msgid "" "Return ``True`` if strings or :term:`bytes-like objects ` " "*a* and *b* are equal, otherwise ``False``, using a \"constant-time " @@ -215,22 +215,22 @@ msgstr "" "20250815071532/https://codahale.com/a-lesson-in-timing-attacks/>`__\\ 的風" "險。請參閱 :func:`hmac.compare_digest` 以了解更多細節。" -#: ../../library/secrets.rst:147 +#: ../../library/secrets.rst:145 msgid "Recipes and best practices" msgstr "應用技巧和典範實務(best practices)" -#: ../../library/secrets.rst:149 +#: ../../library/secrets.rst:147 msgid "" "This section shows recipes and best practices for using :mod:`!secrets` to " "manage a basic level of security." msgstr "" "本節展示了一些使用 :mod:`!secrets` 來管理基本安全等級的應用技巧和典範實務。" -#: ../../library/secrets.rst:152 +#: ../../library/secrets.rst:150 msgid "Generate an eight-character alphanumeric password:" msgstr "產生八個字元長的字母數字密碼:" -#: ../../library/secrets.rst:154 +#: ../../library/secrets.rst:152 msgid "" "import string\n" "import secrets\n" @@ -242,7 +242,7 @@ msgstr "" "alphabet = string.ascii_letters + string.digits\n" "password = ''.join(secrets.choice(alphabet) for i in range(8))" -#: ../../library/secrets.rst:164 +#: ../../library/secrets.rst:162 msgid "" "Applications should not :cwe:`store passwords in a recoverable format " "<257>`, whether plain text or encrypted. They should be salted and hashed " @@ -252,7 +252,7 @@ msgstr "" "密。 它們應當先加鹽(salt),再使用高加密強度的單向(不可逆)雜湊函式來產生雜" "湊值。" -#: ../../library/secrets.rst:170 +#: ../../library/secrets.rst:168 msgid "" "Generate a ten-character alphanumeric password with at least one lowercase " "character, at least one uppercase character, and at least three digits:" @@ -260,7 +260,7 @@ msgstr "" "產生十個字元長的字母數字密碼,其中包含至少一個小寫字母,至少一個大寫字母以及" "至少三個數字:" -#: ../../library/secrets.rst:174 +#: ../../library/secrets.rst:172 msgid "" "import string\n" "import secrets\n" @@ -282,11 +282,11 @@ msgstr "" " and sum(c.isdigit() for c in password) >= 3):\n" " break" -#: ../../library/secrets.rst:187 +#: ../../library/secrets.rst:185 msgid "Generate an `XKCD-style passphrase `_:" msgstr "產生 `XKCD 風格的 passphrase `_:" -#: ../../library/secrets.rst:189 +#: ../../library/secrets.rst:187 msgid "" "import secrets\n" "# On standard Linux systems, use a convenient dictionary file.\n" @@ -302,13 +302,13 @@ msgstr "" " words = [word.strip() for word in f]\n" " password = ' '.join(secrets.choice(words) for i in range(4))" -#: ../../library/secrets.rst:199 +#: ../../library/secrets.rst:197 msgid "" "Generate a hard-to-guess temporary URL containing a security token suitable " "for password recovery applications:" msgstr "產生難以猜測的暫時性 URL,內含回復密碼時所用的一個安全性權杖:" -#: ../../library/secrets.rst:202 +#: ../../library/secrets.rst:200 msgid "" "import secrets\n" "url = 'https://example.com/reset=' + secrets.token_urlsafe()" diff --git a/library/select.po b/library/select.po index e7f1afbb708..6ab3ecbc180 100644 --- a/library/select.po +++ b/library/select.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-16 00:33+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:09+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -40,9 +40,9 @@ msgid "" "precise control over the OS-level primitives used." msgstr "" -#: ../../library/select.rst:57 ../../library/select.rst:94 -#: ../../library/select.rst:104 ../../library/select.rst:117 -#: ../../library/select.rst:125 ../../library/select.rst:188 +#: ../../library/select.rst:57 ../../library/select.rst:99 +#: ../../library/select.rst:109 ../../library/select.rst:122 +#: ../../library/select.rst:130 ../../library/select.rst:196 #: ../../includes/wasm-notavail.rst:3 msgid "Availability" msgstr "可用性" @@ -82,11 +82,11 @@ msgid "" msgstr "" #: ../../library/select.rst:50 ../../library/select.rst:81 -#: ../../library/select.rst:112 +#: ../../library/select.rst:117 msgid "The new file descriptor is :ref:`non-inheritable `." msgstr "" -#: ../../library/select.rst:54 ../../library/select.rst:114 +#: ../../library/select.rst:54 ../../library/select.rst:119 msgid "The new file descriptor is now non-inheritable." msgstr "" @@ -100,7 +100,7 @@ msgstr "" msgid "" "*sizehint* informs epoll about the expected number of events to be " "registered. It must be positive, or ``-1`` to use the default. It is only " -"used on older systems where :c:func:`!epoll_create1` is not available; " +"used on older systems where :manpage:`epoll_create1(2)` is not available; " "otherwise it has no effect (though its value is still checked)." msgstr "" @@ -140,26 +140,32 @@ msgid "" "Use :func:`os.set_inheritable` to make the file descriptor inheritable." msgstr "" -#: ../../library/select.rst:99 +#: ../../library/select.rst:96 +msgid "" +"When CPython is built, this function may be disabled using :option:`--" +"disable-epoll`." +msgstr "" + +#: ../../library/select.rst:104 msgid "" "Returns a polling object, which supports registering and unregistering file " "descriptors, and then polling them for I/O events; see section :ref:`poll-" "objects` below for the methods supported by polling objects." msgstr "" -#: ../../library/select.rst:109 +#: ../../library/select.rst:114 msgid "" "Returns a kernel queue object; see section :ref:`kqueue-objects` below for " "the methods supported by kqueue objects." msgstr "" -#: ../../library/select.rst:122 +#: ../../library/select.rst:127 msgid "" "Returns a kernel event object; see section :ref:`kevent-objects` below for " "the methods supported by kevent objects." msgstr "" -#: ../../library/select.rst:130 +#: ../../library/select.rst:135 msgid "" "This is a straightforward interface to the Unix :c:func:`!select` system " "call. The first three arguments are iterables of 'waitable objects': either " @@ -167,38 +173,38 @@ msgid "" "method named :meth:`~io.IOBase.fileno` returning such an integer:" msgstr "" -#: ../../library/select.rst:135 +#: ../../library/select.rst:140 msgid "*rlist*: wait until ready for reading" msgstr "" -#: ../../library/select.rst:136 +#: ../../library/select.rst:141 msgid "*wlist*: wait until ready for writing" msgstr "" -#: ../../library/select.rst:137 +#: ../../library/select.rst:142 msgid "" "*xlist*: wait for an \"exceptional condition\" (see the manual page for what " "your system considers such a condition)" msgstr "" -#: ../../library/select.rst:140 +#: ../../library/select.rst:145 msgid "" "Empty iterables are allowed, but acceptance of three empty iterables is " "platform-dependent. (It is known to work on Unix but not on Windows.) The " -"optional *timeout* argument specifies a time-out as a floating-point number " -"in seconds. When the *timeout* argument is omitted or ``None``, the function " -"blocks until at least one file descriptor is ready. A time-out value of " -"zero specifies a poll and never blocks." +"optional *timeout* argument specifies a time-out in seconds; it may be a non-" +"integer to specify fractions of seconds. When the *timeout* argument is " +"omitted or ``None``, the function blocks until at least one file descriptor " +"is ready. A time-out value of zero specifies a poll and never blocks." msgstr "" -#: ../../library/select.rst:148 +#: ../../library/select.rst:153 msgid "" "The return value is a triple of lists of objects that are ready: subsets of " "the first three arguments. When the time-out is reached without a file " "descriptor becoming ready, three empty lists are returned." msgstr "" -#: ../../library/select.rst:156 +#: ../../library/select.rst:161 msgid "" "Among the acceptable object types in the iterables are Python :term:`file " "objects ` (e.g. ``sys.stdin``, or objects returned by :func:" @@ -208,7 +214,7 @@ msgid "" "file descriptor, not just a random integer)." msgstr "" -#: ../../library/select.rst:167 +#: ../../library/select.rst:172 msgid "" "File objects on Windows are not acceptable, but sockets are. On Windows, " "the underlying :c:func:`!select` function is provided by the WinSock " @@ -216,16 +222,21 @@ msgid "" "WinSock." msgstr "" -#: ../../library/select.rst:172 ../../library/select.rst:278 -#: ../../library/select.rst:384 ../../library/select.rst:472 -#: ../../library/select.rst:513 +#: ../../library/select.rst:177 ../../library/select.rst:286 +#: ../../library/select.rst:397 ../../library/select.rst:488 +#: ../../library/select.rst:534 msgid "" "The function is now retried with a recomputed timeout when interrupted by a " "signal, except if the signal handler raises an exception (see :pep:`475` for " "the rationale), instead of raising :exc:`InterruptedError`." msgstr "" -#: ../../library/select.rst:181 +#: ../../library/select.rst:183 ../../library/select.rst:292 +#: ../../library/select.rst:403 ../../library/select.rst:540 +msgid "Accepts any real number as *timeout*, not only integer or float." +msgstr "" + +#: ../../library/select.rst:189 msgid "" "The minimum number of bytes which can be written without blocking to a pipe " "when the pipe has been reported as ready for writing by :func:`~select." @@ -233,39 +244,39 @@ msgid "" "apply to other kinds of file-like objects such as sockets." msgstr "" -#: ../../library/select.rst:186 +#: ../../library/select.rst:194 msgid "This value is guaranteed by POSIX to be at least 512." msgstr "" -#: ../../library/select.rst:196 +#: ../../library/select.rst:204 msgid "``/dev/poll`` polling objects" msgstr "" -#: ../../library/select.rst:198 +#: ../../library/select.rst:206 msgid "" "Solaris and derivatives have ``/dev/poll``. While :c:func:`!select` is *O*\\ " "(*highest file descriptor*) and :c:func:`!poll` is *O*\\ (*number of file " "descriptors*), ``/dev/poll`` is *O*\\ (*active file descriptors*)." msgstr "" -#: ../../library/select.rst:202 +#: ../../library/select.rst:210 msgid "" "``/dev/poll`` behaviour is very close to the standard :c:func:`!poll` object." msgstr "" -#: ../../library/select.rst:208 +#: ../../library/select.rst:216 msgid "Close the file descriptor of the polling object." msgstr "" -#: ../../library/select.rst:215 +#: ../../library/select.rst:223 msgid "``True`` if the polling object is closed." msgstr "" -#: ../../library/select.rst:222 +#: ../../library/select.rst:230 msgid "Return the file descriptor number of the polling object." msgstr "" -#: ../../library/select.rst:229 ../../library/select.rst:407 +#: ../../library/select.rst:237 ../../library/select.rst:423 msgid "" "Register a file descriptor with the polling object. Future calls to the :" "meth:`poll` method will then check whether the file descriptor has any " @@ -274,7 +285,7 @@ msgid "" "implement :meth:`!fileno`, so they can also be used as the argument." msgstr "" -#: ../../library/select.rst:235 +#: ../../library/select.rst:243 msgid "" "*eventmask* is an optional bitmask describing the type of events you want to " "check for. The constants are the same as with :c:func:`!poll` object. The " @@ -282,33 +293,33 @@ msgid "" "`POLLPRI`, and :const:`POLLOUT`." msgstr "" -#: ../../library/select.rst:242 +#: ../../library/select.rst:250 msgid "" "Registering a file descriptor that's already registered is not an error, but " "the result is undefined. The appropriate action is to unregister or modify " "it first. This is an important difference compared with :c:func:`!poll`." msgstr "" -#: ../../library/select.rst:250 +#: ../../library/select.rst:258 msgid "" "This method does an :meth:`unregister` followed by a :meth:`register`. It is " "(a bit) more efficient than doing the same explicitly." msgstr "" -#: ../../library/select.rst:257 ../../library/select.rst:451 +#: ../../library/select.rst:265 ../../library/select.rst:467 msgid "" "Remove a file descriptor being tracked by a polling object. Just like the :" "meth:`register` method, *fd* can be an integer or an object with a :meth:" "`~io.IOBase.fileno` method that returns an integer." msgstr "" -#: ../../library/select.rst:261 +#: ../../library/select.rst:269 msgid "" "Attempting to remove a file descriptor that was never registered is safely " "ignored." msgstr "" -#: ../../library/select.rst:267 +#: ../../library/select.rst:275 msgid "" "Polls the set of registered file descriptors, and returns a possibly empty " "list containing ``(fd, event)`` 2-tuples for the descriptors that have " @@ -322,210 +333,213 @@ msgid "" "the call will block until there is an event for this poll object." msgstr "" -#: ../../library/select.rst:288 +#: ../../library/select.rst:299 msgid "Edge and level trigger polling (epoll) objects" msgstr "" -#: ../../library/select.rst:290 +#: ../../library/select.rst:301 msgid "https://linux.die.net/man/4/epoll" msgstr "https://linux.die.net/man/4/epoll" -#: ../../library/select.rst:292 +#: ../../library/select.rst:303 msgid "The *eventmask* is a bit mask using the following constants:" msgstr "" -#: ../../library/select.rst:295 ../../library/select.rst:419 -#: ../../library/select.rst:539 ../../library/select.rst:568 -#: ../../library/select.rst:599 ../../library/select.rst:607 -#: ../../library/select.rst:627 ../../library/select.rst:650 +#: ../../library/select.rst:306 ../../library/select.rst:435 +#: ../../library/select.rst:563 ../../library/select.rst:592 +#: ../../library/select.rst:623 ../../library/select.rst:631 +#: ../../library/select.rst:651 ../../library/select.rst:674 msgid "Constant" msgstr "常數" -#: ../../library/select.rst:295 ../../library/select.rst:419 -#: ../../library/select.rst:539 ../../library/select.rst:568 -#: ../../library/select.rst:599 ../../library/select.rst:607 -#: ../../library/select.rst:627 ../../library/select.rst:650 +#: ../../library/select.rst:306 ../../library/select.rst:435 +#: ../../library/select.rst:563 ../../library/select.rst:592 +#: ../../library/select.rst:623 ../../library/select.rst:631 +#: ../../library/select.rst:651 ../../library/select.rst:674 msgid "Meaning" msgstr "含義" -#: ../../library/select.rst:297 +#: ../../library/select.rst:308 msgid ":const:`EPOLLIN`" msgstr ":const:`EPOLLIN`" -#: ../../library/select.rst:297 +#: ../../library/select.rst:308 msgid "Available for read." msgstr "" -#: ../../library/select.rst:299 +#: ../../library/select.rst:310 msgid ":const:`EPOLLOUT`" msgstr ":const:`EPOLLOUT`" -#: ../../library/select.rst:299 +#: ../../library/select.rst:310 msgid "Available for write." msgstr "可供寫入。" -#: ../../library/select.rst:301 +#: ../../library/select.rst:312 msgid ":const:`EPOLLPRI`" msgstr ":const:`EPOLLPRI`" -#: ../../library/select.rst:301 +#: ../../library/select.rst:312 msgid "Urgent data for read." msgstr "" -#: ../../library/select.rst:303 +#: ../../library/select.rst:314 msgid ":const:`EPOLLERR`" msgstr ":const:`EPOLLERR`" -#: ../../library/select.rst:303 +#: ../../library/select.rst:314 msgid "Error condition happened on the associated fd." msgstr "" -#: ../../library/select.rst:305 +#: ../../library/select.rst:316 msgid ":const:`EPOLLHUP`" msgstr ":const:`EPOLLHUP`" -#: ../../library/select.rst:305 +#: ../../library/select.rst:316 msgid "Hang up happened on the associated fd." msgstr "" -#: ../../library/select.rst:307 +#: ../../library/select.rst:318 msgid ":const:`EPOLLET`" msgstr ":const:`EPOLLET`" -#: ../../library/select.rst:307 +#: ../../library/select.rst:318 msgid "Set Edge Trigger behavior, the default is Level Trigger behavior." msgstr "" -#: ../../library/select.rst:310 +#: ../../library/select.rst:321 msgid ":const:`EPOLLONESHOT`" msgstr ":const:`EPOLLONESHOT`" -#: ../../library/select.rst:310 +#: ../../library/select.rst:321 msgid "" "Set one-shot behavior. After one event is pulled out, the fd is internally " "disabled." msgstr "" -#: ../../library/select.rst:313 +#: ../../library/select.rst:324 msgid ":const:`EPOLLEXCLUSIVE`" msgstr ":const:`EPOLLEXCLUSIVE`" -#: ../../library/select.rst:313 +#: ../../library/select.rst:324 msgid "" "Wake only one epoll object when the associated fd has an event. The default " "(if this flag is not set) is to wake all epoll objects polling on an fd." msgstr "" -#: ../../library/select.rst:318 +#: ../../library/select.rst:329 msgid ":const:`EPOLLRDHUP`" msgstr ":const:`EPOLLRDHUP`" -#: ../../library/select.rst:318 +#: ../../library/select.rst:329 msgid "" "Stream socket peer closed connection or shut down writing half of connection." msgstr "" -#: ../../library/select.rst:321 +#: ../../library/select.rst:332 msgid ":const:`EPOLLRDNORM`" msgstr ":const:`EPOLLRDNORM`" -#: ../../library/select.rst:321 +#: ../../library/select.rst:332 msgid "Equivalent to :const:`EPOLLIN`" msgstr "等價於 :const:`EPOLLIN`" -#: ../../library/select.rst:323 +#: ../../library/select.rst:334 msgid ":const:`EPOLLRDBAND`" msgstr ":const:`EPOLLRDBAND`" -#: ../../library/select.rst:323 +#: ../../library/select.rst:334 msgid "Priority data band can be read." msgstr "" -#: ../../library/select.rst:325 +#: ../../library/select.rst:336 msgid ":const:`EPOLLWRNORM`" msgstr ":const:`EPOLLWRNORM`" -#: ../../library/select.rst:325 +#: ../../library/select.rst:336 msgid "Equivalent to :const:`EPOLLOUT`." msgstr "等價於 :const:`EPOLLOUT`。" -#: ../../library/select.rst:327 +#: ../../library/select.rst:338 msgid ":const:`EPOLLWRBAND`" msgstr ":const:`EPOLLWRBAND`" -#: ../../library/select.rst:327 +#: ../../library/select.rst:338 msgid "Priority data may be written." msgstr "" -#: ../../library/select.rst:329 +#: ../../library/select.rst:340 msgid ":const:`EPOLLMSG`" msgstr ":const:`EPOLLMSG`" -#: ../../library/select.rst:329 +#: ../../library/select.rst:340 msgid "Ignored." msgstr "" -#: ../../library/select.rst:331 +#: ../../library/select.rst:342 msgid ":const:`EPOLLWAKEUP`" msgstr ":const:`EPOLLWAKEUP`" -#: ../../library/select.rst:331 +#: ../../library/select.rst:342 msgid "Prevents sleep during event waiting." msgstr "" -#: ../../library/select.rst:334 +#: ../../library/select.rst:345 msgid "" ":const:`EPOLLEXCLUSIVE` was added. It's only supported by Linux Kernel 4.5 " "or later." msgstr "" -#: ../../library/select.rst:338 +#: ../../library/select.rst:349 msgid "" ":const:`EPOLLWAKEUP` was added. It's only supported by Linux Kernel 3.5 or " "later." msgstr "" -#: ../../library/select.rst:344 +#: ../../library/select.rst:355 msgid "Close the control file descriptor of the epoll object." msgstr "" -#: ../../library/select.rst:349 +#: ../../library/select.rst:360 msgid "``True`` if the epoll object is closed." msgstr "" -#: ../../library/select.rst:354 ../../library/select.rst:496 +#: ../../library/select.rst:365 ../../library/select.rst:517 msgid "Return the file descriptor number of the control fd." msgstr "" -#: ../../library/select.rst:359 +#: ../../library/select.rst:370 msgid "Create an epoll object from a given file descriptor." msgstr "" -#: ../../library/select.rst:364 +#: ../../library/select.rst:375 msgid "Register a file descriptor *fd* with the epoll object." msgstr "" -#: ../../library/select.rst:369 +#: ../../library/select.rst:380 msgid "Modify a registered file descriptor *fd*." msgstr "" -#: ../../library/select.rst:374 +#: ../../library/select.rst:385 msgid "Remove a registered file descriptor from the epoll object." msgstr "" -#: ../../library/select.rst:376 +#: ../../library/select.rst:387 msgid "The method no longer ignores the :data:`~errno.EBADF` error." msgstr "" -#: ../../library/select.rst:382 -msgid "Wait for events. timeout in seconds (float)" +#: ../../library/select.rst:393 +msgid "" +"Wait for events. If *timeout* is given, it specifies the length of time in " +"seconds (may be non-integer) which the system will wait for events before " +"returning." msgstr "" -#: ../../library/select.rst:394 +#: ../../library/select.rst:410 msgid "Polling objects" msgstr "" -#: ../../library/select.rst:396 +#: ../../library/select.rst:412 msgid "" "The :c:func:`!poll` system call, supported on most Unix systems, provides " "better scalability for network servers that service many, many clients at " @@ -537,7 +551,7 @@ msgid "" "of file descriptors*)." msgstr "" -#: ../../library/select.rst:413 +#: ../../library/select.rst:429 msgid "" "*eventmask* is an optional bitmask describing the type of events you want to " "check for, and can be a combination of the constants :const:`POLLIN`, :const:" @@ -545,71 +559,71 @@ msgid "" "specified, the default value used will check for all 3 types of events." msgstr "" -#: ../../library/select.rst:421 +#: ../../library/select.rst:437 msgid ":const:`POLLIN`" msgstr ":const:`POLLIN`" -#: ../../library/select.rst:421 +#: ../../library/select.rst:437 msgid "There is data to read." msgstr "" -#: ../../library/select.rst:423 +#: ../../library/select.rst:439 msgid ":const:`POLLPRI`" msgstr ":const:`POLLPRI`" -#: ../../library/select.rst:423 +#: ../../library/select.rst:439 msgid "There is urgent data to read." msgstr "" -#: ../../library/select.rst:425 +#: ../../library/select.rst:441 msgid ":const:`POLLOUT`" msgstr ":const:`POLLOUT`" -#: ../../library/select.rst:425 +#: ../../library/select.rst:441 msgid "Ready for output: writing will not block." msgstr "" -#: ../../library/select.rst:427 +#: ../../library/select.rst:443 msgid ":const:`POLLERR`" msgstr ":const:`POLLERR`" -#: ../../library/select.rst:427 +#: ../../library/select.rst:443 msgid "Error condition of some sort." msgstr "" -#: ../../library/select.rst:429 +#: ../../library/select.rst:445 msgid ":const:`POLLHUP`" msgstr ":const:`POLLHUP`" -#: ../../library/select.rst:429 +#: ../../library/select.rst:445 msgid "Hung up." msgstr "" -#: ../../library/select.rst:431 +#: ../../library/select.rst:447 msgid ":const:`POLLRDHUP`" msgstr ":const:`POLLRDHUP`" -#: ../../library/select.rst:431 +#: ../../library/select.rst:447 msgid "" "Stream socket peer closed connection, or shut down writing half of " "connection." msgstr "" -#: ../../library/select.rst:434 +#: ../../library/select.rst:450 msgid ":const:`POLLNVAL`" msgstr ":const:`POLLNVAL`" -#: ../../library/select.rst:434 +#: ../../library/select.rst:450 msgid "Invalid request: descriptor not open." msgstr "" -#: ../../library/select.rst:437 +#: ../../library/select.rst:453 msgid "" "Registering a file descriptor that's already registered is not an error, and " "has the same effect as registering the descriptor exactly once." msgstr "" -#: ../../library/select.rst:443 +#: ../../library/select.rst:459 msgid "" "Modifies an already registered fd. This has the same effect as " "``register(fd, eventmask)``. Attempting to modify a file descriptor that " @@ -617,13 +631,13 @@ msgid "" "`ENOENT` to be raised." msgstr "" -#: ../../library/select.rst:455 +#: ../../library/select.rst:471 msgid "" "Attempting to remove a file descriptor that was never registered causes a :" "exc:`KeyError` exception to be raised." msgstr "" -#: ../../library/select.rst:461 +#: ../../library/select.rst:477 msgid "" "Polls the set of registered file descriptors, and returns a possibly empty " "list containing ``(fd, event)`` 2-tuples for the descriptors that have " @@ -637,49 +651,56 @@ msgid "" "`None`, the call will block until there is an event for this poll object." msgstr "" -#: ../../library/select.rst:482 +#: ../../library/select.rst:494 +msgid "" +"Accepts any real number as *timeout*, not only integer or float. If " +"``ppoll()`` function is available, *timeout* has a resolution of ``1`` ns " +"(``1e-6`` ms) instead of ``1`` ms." +msgstr "" + +#: ../../library/select.rst:503 msgid "Kqueue objects" msgstr "" -#: ../../library/select.rst:486 +#: ../../library/select.rst:507 msgid "Close the control file descriptor of the kqueue object." msgstr "" -#: ../../library/select.rst:491 +#: ../../library/select.rst:512 msgid "``True`` if the kqueue object is closed." msgstr "" -#: ../../library/select.rst:501 +#: ../../library/select.rst:522 msgid "Create a kqueue object from a given file descriptor." msgstr "" -#: ../../library/select.rst:506 +#: ../../library/select.rst:527 msgid "Low level interface to kevent" msgstr "" -#: ../../library/select.rst:508 +#: ../../library/select.rst:529 msgid "changelist must be an iterable of kevent objects or ``None``" msgstr "" -#: ../../library/select.rst:509 +#: ../../library/select.rst:530 msgid "max_events must be 0 or a positive integer" msgstr "" -#: ../../library/select.rst:510 +#: ../../library/select.rst:531 msgid "" -"timeout in seconds (floats possible); the default is ``None``, to wait " -"forever" +"timeout in seconds (non-integers are possible); the default is ``None``, to " +"wait forever" msgstr "" -#: ../../library/select.rst:523 +#: ../../library/select.rst:547 msgid "Kevent objects" msgstr "" -#: ../../library/select.rst:525 +#: ../../library/select.rst:549 msgid "https://man.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2" msgstr "https://man.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2" -#: ../../library/select.rst:529 +#: ../../library/select.rst:553 msgid "" "Value used to identify the event. The interpretation depends on the filter " "but it's usually the file descriptor. In the constructor ident can either be " @@ -687,341 +708,341 @@ msgid "" "the integer internally." msgstr "" -#: ../../library/select.rst:536 +#: ../../library/select.rst:560 msgid "Name of the kernel filter." msgstr "" -#: ../../library/select.rst:541 +#: ../../library/select.rst:565 msgid ":const:`KQ_FILTER_READ`" msgstr ":const:`KQ_FILTER_READ`" -#: ../../library/select.rst:541 +#: ../../library/select.rst:565 msgid "" "Takes a descriptor and returns whenever there is data available to read." msgstr "" -#: ../../library/select.rst:544 +#: ../../library/select.rst:568 msgid ":const:`KQ_FILTER_WRITE`" msgstr ":const:`KQ_FILTER_WRITE`" -#: ../../library/select.rst:544 +#: ../../library/select.rst:568 msgid "" "Takes a descriptor and returns whenever there is data available to write." msgstr "" -#: ../../library/select.rst:547 +#: ../../library/select.rst:571 msgid ":const:`KQ_FILTER_AIO`" msgstr ":const:`KQ_FILTER_AIO`" -#: ../../library/select.rst:547 +#: ../../library/select.rst:571 msgid "AIO requests." msgstr "" -#: ../../library/select.rst:549 +#: ../../library/select.rst:573 msgid ":const:`KQ_FILTER_VNODE`" msgstr ":const:`KQ_FILTER_VNODE`" -#: ../../library/select.rst:549 +#: ../../library/select.rst:573 msgid "" "Returns when one or more of the requested events watched in *fflag* occurs." msgstr "" -#: ../../library/select.rst:552 +#: ../../library/select.rst:576 msgid ":const:`KQ_FILTER_PROC`" msgstr ":const:`KQ_FILTER_PROC`" -#: ../../library/select.rst:552 +#: ../../library/select.rst:576 msgid "Watch for events on a process ID." msgstr "" -#: ../../library/select.rst:554 +#: ../../library/select.rst:578 msgid ":const:`KQ_FILTER_NETDEV`" msgstr ":const:`KQ_FILTER_NETDEV`" -#: ../../library/select.rst:554 +#: ../../library/select.rst:578 msgid "Watch for events on a network device (not available on macOS)." msgstr "" -#: ../../library/select.rst:557 +#: ../../library/select.rst:581 msgid ":const:`KQ_FILTER_SIGNAL`" msgstr ":const:`KQ_FILTER_SIGNAL`" -#: ../../library/select.rst:557 +#: ../../library/select.rst:581 msgid "Returns whenever the watched signal is delivered to the process." msgstr "" -#: ../../library/select.rst:560 +#: ../../library/select.rst:584 msgid ":const:`KQ_FILTER_TIMER`" msgstr ":const:`KQ_FILTER_TIMER`" -#: ../../library/select.rst:560 +#: ../../library/select.rst:584 msgid "Establishes an arbitrary timer." msgstr "" -#: ../../library/select.rst:565 +#: ../../library/select.rst:589 msgid "Filter action." msgstr "" -#: ../../library/select.rst:570 +#: ../../library/select.rst:594 msgid ":const:`KQ_EV_ADD`" msgstr ":const:`KQ_EV_ADD`" -#: ../../library/select.rst:570 +#: ../../library/select.rst:594 msgid "Adds or modifies an event." msgstr "" -#: ../../library/select.rst:572 +#: ../../library/select.rst:596 msgid ":const:`KQ_EV_DELETE`" msgstr ":const:`KQ_EV_DELETE`" -#: ../../library/select.rst:572 +#: ../../library/select.rst:596 msgid "Removes an event from the queue." msgstr "" -#: ../../library/select.rst:574 +#: ../../library/select.rst:598 msgid ":const:`KQ_EV_ENABLE`" msgstr ":const:`KQ_EV_ENABLE`" -#: ../../library/select.rst:574 +#: ../../library/select.rst:598 msgid "Permits control() to return the event." msgstr "" -#: ../../library/select.rst:576 +#: ../../library/select.rst:600 msgid ":const:`KQ_EV_DISABLE`" msgstr ":const:`KQ_EV_DISABLE`" -#: ../../library/select.rst:576 +#: ../../library/select.rst:600 msgid "Disables event." msgstr "" -#: ../../library/select.rst:578 +#: ../../library/select.rst:602 msgid ":const:`KQ_EV_ONESHOT`" msgstr ":const:`KQ_EV_ONESHOT`" -#: ../../library/select.rst:578 +#: ../../library/select.rst:602 msgid "Removes event after first occurrence." msgstr "" -#: ../../library/select.rst:580 +#: ../../library/select.rst:604 msgid ":const:`KQ_EV_CLEAR`" msgstr ":const:`KQ_EV_CLEAR`" -#: ../../library/select.rst:580 +#: ../../library/select.rst:604 msgid "Reset the state after an event is retrieved." msgstr "" -#: ../../library/select.rst:582 +#: ../../library/select.rst:606 msgid ":const:`KQ_EV_SYSFLAGS`" msgstr ":const:`KQ_EV_SYSFLAGS`" -#: ../../library/select.rst:582 ../../library/select.rst:584 +#: ../../library/select.rst:606 ../../library/select.rst:608 msgid "Internal event." msgstr "" -#: ../../library/select.rst:584 +#: ../../library/select.rst:608 msgid ":const:`KQ_EV_FLAG1`" msgstr ":const:`KQ_EV_FLAG1`" -#: ../../library/select.rst:586 +#: ../../library/select.rst:610 msgid ":const:`KQ_EV_EOF`" msgstr ":const:`KQ_EV_EOF`" -#: ../../library/select.rst:586 +#: ../../library/select.rst:610 msgid "Filter-specific EOF condition." msgstr "" -#: ../../library/select.rst:588 +#: ../../library/select.rst:612 msgid ":const:`KQ_EV_ERROR`" msgstr ":const:`KQ_EV_ERROR`" -#: ../../library/select.rst:588 +#: ../../library/select.rst:612 msgid "See return values." msgstr "" -#: ../../library/select.rst:594 +#: ../../library/select.rst:618 msgid "Filter-specific flags." msgstr "" -#: ../../library/select.rst:596 +#: ../../library/select.rst:620 msgid ":const:`KQ_FILTER_READ` and :const:`KQ_FILTER_WRITE` filter flags:" msgstr ":const:`KQ_FILTER_READ` 和 :const:`KQ_FILTER_WRITE` 篩選旗標:" -#: ../../library/select.rst:601 +#: ../../library/select.rst:625 msgid ":const:`KQ_NOTE_LOWAT`" msgstr ":const:`KQ_NOTE_LOWAT`" -#: ../../library/select.rst:601 +#: ../../library/select.rst:625 msgid "Low water mark of a socket buffer." msgstr "" -#: ../../library/select.rst:604 +#: ../../library/select.rst:628 msgid ":const:`KQ_FILTER_VNODE` filter flags:" msgstr ":const:`KQ_FILTER_VNODE` 篩選旗標:" -#: ../../library/select.rst:609 +#: ../../library/select.rst:633 msgid ":const:`KQ_NOTE_DELETE`" msgstr ":const:`KQ_NOTE_DELETE`" -#: ../../library/select.rst:609 +#: ../../library/select.rst:633 msgid "*unlink()* was called." msgstr "" -#: ../../library/select.rst:611 +#: ../../library/select.rst:635 msgid ":const:`KQ_NOTE_WRITE`" msgstr ":const:`KQ_NOTE_WRITE`" -#: ../../library/select.rst:611 +#: ../../library/select.rst:635 msgid "A write occurred." msgstr "" -#: ../../library/select.rst:613 +#: ../../library/select.rst:637 msgid ":const:`KQ_NOTE_EXTEND`" msgstr ":const:`KQ_NOTE_EXTEND`" -#: ../../library/select.rst:613 +#: ../../library/select.rst:637 msgid "The file was extended." msgstr "" -#: ../../library/select.rst:615 +#: ../../library/select.rst:639 msgid ":const:`KQ_NOTE_ATTRIB`" msgstr ":const:`KQ_NOTE_ATTRIB`" -#: ../../library/select.rst:615 +#: ../../library/select.rst:639 msgid "An attribute was changed." msgstr "" -#: ../../library/select.rst:617 +#: ../../library/select.rst:641 msgid ":const:`KQ_NOTE_LINK`" msgstr ":const:`KQ_NOTE_LINK`" -#: ../../library/select.rst:617 +#: ../../library/select.rst:641 msgid "The link count has changed." msgstr "" -#: ../../library/select.rst:619 +#: ../../library/select.rst:643 msgid ":const:`KQ_NOTE_RENAME`" msgstr ":const:`KQ_NOTE_RENAME`" -#: ../../library/select.rst:619 +#: ../../library/select.rst:643 msgid "The file was renamed." msgstr "" -#: ../../library/select.rst:621 +#: ../../library/select.rst:645 msgid ":const:`KQ_NOTE_REVOKE`" msgstr ":const:`KQ_NOTE_REVOKE`" -#: ../../library/select.rst:621 +#: ../../library/select.rst:645 msgid "Access to the file was revoked." msgstr "" -#: ../../library/select.rst:624 +#: ../../library/select.rst:648 msgid ":const:`KQ_FILTER_PROC` filter flags:" msgstr ":const:`KQ_FILTER_PROC` 篩選旗標:" -#: ../../library/select.rst:629 +#: ../../library/select.rst:653 msgid ":const:`KQ_NOTE_EXIT`" msgstr ":const:`KQ_NOTE_EXIT`" -#: ../../library/select.rst:629 +#: ../../library/select.rst:653 msgid "The process has exited." msgstr "" -#: ../../library/select.rst:631 +#: ../../library/select.rst:655 msgid ":const:`KQ_NOTE_FORK`" msgstr ":const:`KQ_NOTE_FORK`" -#: ../../library/select.rst:631 +#: ../../library/select.rst:655 msgid "The process has called *fork()*." msgstr "" -#: ../../library/select.rst:633 +#: ../../library/select.rst:657 msgid ":const:`KQ_NOTE_EXEC`" msgstr ":const:`KQ_NOTE_EXEC`" -#: ../../library/select.rst:633 +#: ../../library/select.rst:657 msgid "The process has executed a new process." msgstr "" -#: ../../library/select.rst:635 +#: ../../library/select.rst:659 msgid ":const:`KQ_NOTE_PCTRLMASK`" msgstr ":const:`KQ_NOTE_PCTRLMASK`" -#: ../../library/select.rst:635 ../../library/select.rst:637 +#: ../../library/select.rst:659 ../../library/select.rst:661 msgid "Internal filter flag." msgstr "" -#: ../../library/select.rst:637 +#: ../../library/select.rst:661 msgid ":const:`KQ_NOTE_PDATAMASK`" msgstr ":const:`KQ_NOTE_PDATAMASK`" -#: ../../library/select.rst:639 +#: ../../library/select.rst:663 msgid ":const:`KQ_NOTE_TRACK`" msgstr ":const:`KQ_NOTE_TRACK`" -#: ../../library/select.rst:639 +#: ../../library/select.rst:663 msgid "Follow a process across *fork()*." msgstr "" -#: ../../library/select.rst:641 +#: ../../library/select.rst:665 msgid ":const:`KQ_NOTE_CHILD`" msgstr ":const:`KQ_NOTE_CHILD`" -#: ../../library/select.rst:641 +#: ../../library/select.rst:665 msgid "Returned on the child process for *NOTE_TRACK*." msgstr "" -#: ../../library/select.rst:644 +#: ../../library/select.rst:668 msgid ":const:`KQ_NOTE_TRACKERR`" msgstr ":const:`KQ_NOTE_TRACKERR`" -#: ../../library/select.rst:644 +#: ../../library/select.rst:668 msgid "Unable to attach to a child." msgstr "" -#: ../../library/select.rst:647 +#: ../../library/select.rst:671 msgid ":const:`KQ_FILTER_NETDEV` filter flags (not available on macOS):" msgstr ":const:`KQ_FILTER_NETDEV` 篩選旗標(macOS 上不可用):" -#: ../../library/select.rst:652 +#: ../../library/select.rst:676 msgid ":const:`KQ_NOTE_LINKUP`" msgstr ":const:`KQ_NOTE_LINKUP`" -#: ../../library/select.rst:652 +#: ../../library/select.rst:676 msgid "Link is up." msgstr "" -#: ../../library/select.rst:654 +#: ../../library/select.rst:678 msgid ":const:`KQ_NOTE_LINKDOWN`" msgstr ":const:`KQ_NOTE_LINKDOWN`" -#: ../../library/select.rst:654 +#: ../../library/select.rst:678 msgid "Link is down." msgstr "" -#: ../../library/select.rst:656 +#: ../../library/select.rst:680 msgid ":const:`KQ_NOTE_LINKINV`" msgstr ":const:`KQ_NOTE_LINKINV`" -#: ../../library/select.rst:656 +#: ../../library/select.rst:680 msgid "Link state is invalid." msgstr "" -#: ../../library/select.rst:662 +#: ../../library/select.rst:686 msgid "Filter-specific data." msgstr "" -#: ../../library/select.rst:667 +#: ../../library/select.rst:691 msgid "User-defined value." msgstr "" -#: ../../library/select.rst:152 +#: ../../library/select.rst:157 msgid "socket() (in module socket)" msgstr "socket() (於 socket 模組)" -#: ../../library/select.rst:152 +#: ../../library/select.rst:157 msgid "popen() (in module os)" msgstr "popen() (於 os 模組)" -#: ../../library/select.rst:165 +#: ../../library/select.rst:170 msgid "WinSock" msgstr "WinSock" diff --git a/library/shelve.po b/library/shelve.po index a7e5fb4c7ec..7c9c266b0b8 100644 --- a/library/shelve.po +++ b/library/shelve.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-18 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:09+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -35,7 +35,7 @@ msgid "" "strings." msgstr "" -#: ../../library/shelve.rst:22 +#: ../../library/shelve.rst:23 msgid "" "Open a persistent dictionary. The filename specified is the base filename " "for the underlying database. As a side-effect, an extension may be added to " @@ -45,14 +45,14 @@ msgid "" "func:`dbm.open`." msgstr "" -#: ../../library/shelve.rst:28 +#: ../../library/shelve.rst:29 msgid "" "By default, pickles created with :const:`pickle.DEFAULT_PROTOCOL` are used " "to serialize values. The version of the pickle protocol can be specified " "with the *protocol* parameter." msgstr "" -#: ../../library/shelve.rst:32 +#: ../../library/shelve.rst:33 msgid "" "Because of Python semantics, a shelf cannot know when a mutable persistent-" "dictionary entry is modified. By default modified objects are written " @@ -67,23 +67,56 @@ msgid "" "mutated)." msgstr "" -#: ../../library/shelve.rst:44 ../../library/shelve.rst:148 +#: ../../library/shelve.rst:45 +msgid "" +"By default, :mod:`!shelve` uses :func:`pickle.dumps` and :func:`pickle." +"loads` for serializing and deserializing. This can be changed by supplying " +"*serializer* and *deserializer*, respectively." +msgstr "" + +#: ../../library/shelve.rst:49 +msgid "" +"The *serializer* argument must be a callable which takes an object ``obj`` " +"and the *protocol* as inputs and returns the representation ``obj`` as a :" +"term:`bytes-like object`; the *protocol* value may be ignored by the " +"serializer." +msgstr "" + +#: ../../library/shelve.rst:54 +msgid "" +"The *deserializer* argument must be a callable which takes a serialized " +"object given as a :class:`bytes` object and returns the corresponding object." +msgstr "" + +#: ../../library/shelve.rst:57 +msgid "" +"A :exc:`ShelveError` is raised if *serializer* is given but *deserializer* " +"is not, or vice-versa." +msgstr "" + +#: ../../library/shelve.rst:60 ../../library/shelve.rst:184 msgid "" ":const:`pickle.DEFAULT_PROTOCOL` is now used as the default pickle protocol." msgstr "" -#: ../../library/shelve.rst:48 +#: ../../library/shelve.rst:64 msgid "Accepts :term:`path-like object` for filename." msgstr "" -#: ../../library/shelve.rst:53 +#: ../../library/shelve.rst:67 +msgid "" +"Accepts custom *serializer* and *deserializer* functions in place of :func:" +"`pickle.dumps` and :func:`pickle.loads`." +msgstr "" + +#: ../../library/shelve.rst:73 msgid "" "Do not rely on the shelf being closed automatically; always call :meth:" "`~Shelf.close` explicitly when you don't need it any more, or use :func:" "`shelve.open` as a context manager::" msgstr "" -#: ../../library/shelve.rst:57 +#: ../../library/shelve.rst:77 msgid "" "with shelve.open('spam') as db:\n" " db['eggs'] = 'eggs'" @@ -91,14 +124,14 @@ msgstr "" "with shelve.open('spam') as db:\n" " db['eggs'] = 'eggs'" -#: ../../library/shelve.rst:64 +#: ../../library/shelve.rst:84 msgid "" "Because the :mod:`!shelve` module is backed by :mod:`pickle`, it is insecure " "to load a shelf from an untrusted source. Like with pickle, loading a shelf " "can execute arbitrary code." msgstr "" -#: ../../library/shelve.rst:68 +#: ../../library/shelve.rst:88 msgid "" "Shelf objects support most of the methods and operations supported by " "dictionaries (except copying, constructors and operators ``|`` and ``|=``). " @@ -106,36 +139,42 @@ msgid "" "persistent storage." msgstr "" -#: ../../library/shelve.rst:72 +#: ../../library/shelve.rst:92 msgid "Two additional methods are supported:" msgstr "" -#: ../../library/shelve.rst:76 +#: ../../library/shelve.rst:96 msgid "" "Write back all entries in the cache if the shelf was opened with *writeback* " "set to :const:`True`. Also empty the cache and synchronize the persistent " -"dictionary on disk, if feasible. This is called automatically when the " -"shelf is closed with :meth:`close`." +"dictionary on disk, if feasible. This is called automatically when :meth:" +"`reorganize` is called or the shelf is closed with :meth:`close`." +msgstr "" + +#: ../../library/shelve.rst:103 +msgid "" +"Calls :meth:`sync` and attempts to shrink space used on disk by removing " +"empty space resulting from deletions." msgstr "" -#: ../../library/shelve.rst:83 +#: ../../library/shelve.rst:110 msgid "" "Synchronize and close the persistent *dict* object. Operations on a closed " "shelf will fail with a :exc:`ValueError`." msgstr "" -#: ../../library/shelve.rst:89 +#: ../../library/shelve.rst:116 msgid "" "`Persistent dictionary recipe `_ with widely supported " "storage formats and having the speed of native dictionaries." msgstr "" -#: ../../library/shelve.rst:95 +#: ../../library/shelve.rst:122 msgid "Restrictions" msgstr "" -#: ../../library/shelve.rst:101 +#: ../../library/shelve.rst:128 msgid "" "The choice of which database package will be used (such as :mod:`dbm.ndbm` " "or :mod:`dbm.gnu`) depends on which interface is available. Therefore it is " @@ -146,7 +185,7 @@ msgid "" "cause the database to refuse updates." msgstr "" -#: ../../library/shelve.rst:109 +#: ../../library/shelve.rst:136 msgid "" "The :mod:`!shelve` module does not support *concurrent* read/write access to " "shelved objects. (Multiple simultaneous read accesses are safe.) When a " @@ -156,19 +195,27 @@ msgid "" "implementation used." msgstr "" -#: ../../library/shelve.rst:116 +#: ../../library/shelve.rst:143 msgid "" "On macOS :mod:`dbm.ndbm` can silently corrupt the database file on updates, " "which can cause hard crashes when trying to read from the database." msgstr "" -#: ../../library/shelve.rst:122 +#: ../../library/shelve.rst:146 +msgid "" +":meth:`Shelf.reorganize` may not be available for all database packages and " +"may temporarily increase resource usage (especially disk space) when called. " +"Additionally, it will never run automatically and instead needs to be called " +"explicitly." +msgstr "" + +#: ../../library/shelve.rst:155 msgid "" "A subclass of :class:`collections.abc.MutableMapping` which stores pickled " "values in the *dict* object." msgstr "" -#: ../../library/shelve.rst:125 +#: ../../library/shelve.rst:158 msgid "" "By default, pickles created with :const:`pickle.DEFAULT_PROTOCOL` are used " "to serialize values. The version of the pickle protocol can be specified " @@ -176,7 +223,7 @@ msgid "" "discussion of the pickle protocols." msgstr "" -#: ../../library/shelve.rst:130 +#: ../../library/shelve.rst:163 msgid "" "If the *writeback* parameter is ``True``, the object will hold a cache of " "all entries accessed and write them back to the *dict* at sync and close " @@ -184,29 +231,40 @@ msgid "" "much more memory and make sync and close take a long time." msgstr "" -#: ../../library/shelve.rst:135 +#: ../../library/shelve.rst:168 msgid "" "The *keyencoding* parameter is the encoding used to encode keys before they " "are used with the underlying dict." msgstr "" -#: ../../library/shelve.rst:138 +#: ../../library/shelve.rst:171 +msgid "" +"The *serializer* and *deserializer* parameters have the same interpretation " +"as in :func:`~shelve.open`." +msgstr "" + +#: ../../library/shelve.rst:174 msgid "" "A :class:`Shelf` object can also be used as a context manager, in which case " "it will be automatically closed when the :keyword:`with` block ends." msgstr "" -#: ../../library/shelve.rst:141 +#: ../../library/shelve.rst:177 msgid "" "Added the *keyencoding* parameter; previously, keys were always encoded in " "UTF-8." msgstr "" -#: ../../library/shelve.rst:145 +#: ../../library/shelve.rst:181 msgid "Added context manager support." msgstr "新增情境管理器的支援。" -#: ../../library/shelve.rst:155 +#: ../../library/shelve.rst:188 ../../library/shelve.rst:207 +#: ../../library/shelve.rst:223 +msgid "Added the *serializer* and *deserializer* parameters." +msgstr "" + +#: ../../library/shelve.rst:196 msgid "" "A subclass of :class:`Shelf` which exposes :meth:`!first`, :meth:`!next`, :" "meth:`!previous`, :meth:`!last` and :meth:`!set_location` methods. These are " @@ -215,31 +273,32 @@ msgid "" "*dict* object passed to the constructor must support those methods. This is " "generally accomplished by calling one of :func:`!bsddb.hashopen`, :func:`!" "bsddb.btopen` or :func:`!bsddb.rnopen`. The optional *protocol*, " -"*writeback*, and *keyencoding* parameters have the same interpretation as " -"for the :class:`Shelf` class." +"*writeback*, *keyencoding*, *serializer* and *deserializer* parameters have " +"the same interpretation as in :func:`~shelve.open`." msgstr "" -#: ../../library/shelve.rst:169 +#: ../../library/shelve.rst:215 msgid "" "A subclass of :class:`Shelf` which accepts a *filename* instead of a dict-" "like object. The underlying file will be opened using :func:`dbm.open`. By " "default, the file will be created and opened for both read and write. The " "optional *flag* parameter has the same interpretation as for the :func:`." -"open` function. The optional *protocol* and *writeback* parameters have the " -"same interpretation as for the :class:`Shelf` class." +"open` function. The optional *protocol*, *writeback*, *serializer* and " +"*deserializer* parameters have the same interpretation as in :func:`~shelve." +"open`." msgstr "" -#: ../../library/shelve.rst:180 +#: ../../library/shelve.rst:230 msgid "Example" msgstr "範例" -#: ../../library/shelve.rst:182 +#: ../../library/shelve.rst:232 msgid "" "To summarize the interface (``key`` is a string, ``data`` is an arbitrary " "object)::" msgstr "" -#: ../../library/shelve.rst:185 +#: ../../library/shelve.rst:235 msgid "" "import shelve\n" "\n" @@ -272,23 +331,38 @@ msgid "" "d.close() # close it" msgstr "" -#: ../../library/shelve.rst:218 +#: ../../library/shelve.rst:267 +msgid "Exceptions" +msgstr "" + +#: ../../library/shelve.rst:271 +msgid "" +"Exception raised when one of the arguments *deserializer* and *serializer* " +"is missing in the :func:`~shelve.open`, :class:`Shelf`, :class:`BsdDbShelf` " +"and :class:`DbfilenameShelf`." +msgstr "" + +#: ../../library/shelve.rst:275 +msgid "The *deserializer* and *serializer* arguments must be given together." +msgstr "" + +#: ../../library/shelve.rst:282 msgid "Module :mod:`dbm`" msgstr ":mod:`dbm` 模組" -#: ../../library/shelve.rst:219 +#: ../../library/shelve.rst:283 msgid "Generic interface to ``dbm``-style databases." msgstr "" -#: ../../library/shelve.rst:221 +#: ../../library/shelve.rst:285 msgid "Module :mod:`pickle`" msgstr ":mod:`pickle` 模組" -#: ../../library/shelve.rst:222 +#: ../../library/shelve.rst:286 msgid "Object serialization used by :mod:`!shelve`." msgstr ":mod:`!shelve` 使用的物件序列化。" -#: ../../library/shelve.rst:9 ../../library/shelve.rst:97 +#: ../../library/shelve.rst:9 ../../library/shelve.rst:124 msgid "module" msgstr "module(模組)" @@ -296,10 +370,10 @@ msgstr "module(模組)" msgid "pickle" msgstr "pickle" -#: ../../library/shelve.rst:97 +#: ../../library/shelve.rst:124 msgid "dbm.ndbm" msgstr "dbm.ndbm" -#: ../../library/shelve.rst:97 +#: ../../library/shelve.rst:124 msgid "dbm.gnu" msgstr "dbm.gnu" diff --git a/library/shlex.po b/library/shlex.po index 470ac3225be..333d9cbbee7 100644 --- a/library/shlex.po +++ b/library/shlex.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-18 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:09+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!shlex` --- Simple lexical analysis" msgstr ":mod:`!shlex` --- 簡單的語法分析" -#: ../../library/shlex.rst:12 +#: ../../library/shlex.rst:7 msgid "**Source code:** :source:`Lib/shlex.py`" msgstr "**原始碼:**\\ :source:`Lib/shlex.py`" -#: ../../library/shlex.rst:16 +#: ../../library/shlex.rst:11 msgid "" "The :class:`~shlex.shlex` class makes it easy to write lexical analyzers for " "simple syntaxes resembling that of the Unix shell. This will often be " @@ -33,11 +33,11 @@ msgid "" "Python applications) or for parsing quoted strings." msgstr "" -#: ../../library/shlex.rst:21 +#: ../../library/shlex.rst:16 msgid "The :mod:`!shlex` module defines the following functions:" msgstr ":mod:`!shlex` 模組定義了以下函式:" -#: ../../library/shlex.rst:26 +#: ../../library/shlex.rst:21 msgid "" "Split the string *s* using shell-like syntax. If *comments* is :const:" "`False` (the default), the parsing of comments in the given string will be " @@ -47,36 +47,36 @@ msgid "" "false." msgstr "" -#: ../../library/shlex.rst:33 +#: ../../library/shlex.rst:28 msgid "" "Passing ``None`` for *s* argument now raises an exception, rather than " "reading :data:`sys.stdin`." msgstr "" -#: ../../library/shlex.rst:39 +#: ../../library/shlex.rst:34 msgid "" "Concatenate the tokens of the list *split_command* and return a string. This " "function is the inverse of :func:`split`." msgstr "" -#: ../../library/shlex.rst:46 +#: ../../library/shlex.rst:41 msgid "" "The returned value is shell-escaped to protect against injection " "vulnerabilities (see :func:`quote`)." msgstr "" -#: ../../library/shlex.rst:54 +#: ../../library/shlex.rst:49 msgid "" "Return a shell-escaped version of the string *s*. The returned value is a " "string that can safely be used as one token in a shell command line, for " "cases where you cannot use a list." msgstr "" -#: ../../library/shlex.rst:62 +#: ../../library/shlex.rst:57 msgid "The ``shlex`` module is **only designed for Unix shells**." msgstr "" -#: ../../library/shlex.rst:64 +#: ../../library/shlex.rst:59 msgid "" "The :func:`quote` function is not guaranteed to be correct on non-POSIX " "compliant shells or shells from other operating systems such as Windows. " @@ -84,29 +84,29 @@ msgid "" "possibility of a command injection vulnerability." msgstr "" -#: ../../library/shlex.rst:69 +#: ../../library/shlex.rst:64 msgid "" "Consider using functions that pass command arguments with lists such as :" "func:`subprocess.run` with ``shell=False``." msgstr "" -#: ../../library/shlex.rst:72 +#: ../../library/shlex.rst:67 msgid "This idiom would be unsafe:" msgstr "" -#: ../../library/shlex.rst:79 +#: ../../library/shlex.rst:74 msgid ":func:`quote` lets you plug the security hole:" msgstr "" -#: ../../library/shlex.rst:89 +#: ../../library/shlex.rst:84 msgid "The quoting is compatible with UNIX shells and with :func:`split`:" msgstr "" -#: ../../library/shlex.rst:101 +#: ../../library/shlex.rst:96 msgid "The :mod:`!shlex` module defines the following class:" msgstr ":mod:`!shlex` 模組定義了以下類別:" -#: ../../library/shlex.rst:106 +#: ../../library/shlex.rst:101 msgid "" "A :class:`~shlex.shlex` instance or subclass instance is a lexical analyzer " "object. The initialization argument, if present, specifies where to read " @@ -133,28 +133,28 @@ msgid "" "creation and can't be modified later." msgstr "" -#: ../../library/shlex.rst:131 +#: ../../library/shlex.rst:126 msgid "The *punctuation_chars* parameter was added." msgstr "新增 *punctuation_chars* 參數。" -#: ../../library/shlex.rst:136 +#: ../../library/shlex.rst:131 msgid "Module :mod:`configparser`" msgstr ":mod:`configparser` 模組" -#: ../../library/shlex.rst:137 +#: ../../library/shlex.rst:132 msgid "" "Parser for configuration files similar to the Windows :file:`.ini` files." msgstr "" -#: ../../library/shlex.rst:143 +#: ../../library/shlex.rst:138 msgid "shlex Objects" msgstr "shlex 物件" -#: ../../library/shlex.rst:145 +#: ../../library/shlex.rst:140 msgid "A :class:`~shlex.shlex` instance has the following methods:" msgstr ":class:`~shlex.shlex` 實例有以下方法:" -#: ../../library/shlex.rst:150 +#: ../../library/shlex.rst:145 msgid "" "Return a token. If tokens have been stacked using :meth:`push_token`, pop a " "token off the stack. Otherwise, read one from the input stream. If reading " @@ -162,25 +162,25 @@ msgid "" "string (``''``) in non-POSIX mode, and ``None`` in POSIX mode)." msgstr "" -#: ../../library/shlex.rst:158 +#: ../../library/shlex.rst:153 msgid "Push the argument onto the token stack." msgstr "" -#: ../../library/shlex.rst:163 +#: ../../library/shlex.rst:158 msgid "" "Read a raw token. Ignore the pushback stack, and do not interpret source " "requests. (This is not ordinarily a useful entry point, and is documented " "here only for the sake of completeness.)" msgstr "" -#: ../../library/shlex.rst:170 +#: ../../library/shlex.rst:165 msgid "" "When :class:`~shlex.shlex` detects a source request (see :attr:`source` " "below) this method is given the following token as argument, and expected to " "return a tuple consisting of a filename and an open file-like object." msgstr "" -#: ../../library/shlex.rst:174 +#: ../../library/shlex.rst:169 msgid "" "Normally, this method first strips any quotes off the argument. If the " "result is an absolute pathname, or there was no previous source request in " @@ -191,7 +191,7 @@ msgid "" "preprocessor handles ``#include \"file.h\"``)." msgstr "" -#: ../../library/shlex.rst:182 +#: ../../library/shlex.rst:177 msgid "" "The result of the manipulations is treated as a filename, and returned as " "the first component of the tuple, with :func:`open` called on it to yield " @@ -199,7 +199,7 @@ msgid "" "in instance initialization!)" msgstr "" -#: ../../library/shlex.rst:187 +#: ../../library/shlex.rst:182 msgid "" "This hook is exposed so that you can use it to implement directory search " "paths, addition of file extensions, and other namespace hacks. There is no " @@ -207,26 +207,26 @@ msgid "" "IOBase.close` method of the sourced input stream when it returns EOF." msgstr "" -#: ../../library/shlex.rst:193 +#: ../../library/shlex.rst:188 msgid "" "For more explicit control of source stacking, use the :meth:`push_source` " "and :meth:`pop_source` methods." msgstr "" -#: ../../library/shlex.rst:199 +#: ../../library/shlex.rst:194 msgid "" "Push an input source stream onto the input stack. If the filename argument " "is specified it will later be available for use in error messages. This is " "the same method used internally by the :meth:`sourcehook` method." msgstr "" -#: ../../library/shlex.rst:206 +#: ../../library/shlex.rst:201 msgid "" "Pop the last-pushed input source from the input stack. This is the same " "method used internally when the lexer reaches EOF on a stacked input stream." msgstr "" -#: ../../library/shlex.rst:212 +#: ../../library/shlex.rst:207 msgid "" "This method generates an error message leader in the format of a Unix C " "compiler error label; the format is ``'\"%s\", line %d: '``, where the " @@ -235,27 +235,27 @@ msgid "" "override these)." msgstr "" -#: ../../library/shlex.rst:217 +#: ../../library/shlex.rst:212 msgid "" "This convenience is provided to encourage :mod:`!shlex` users to generate " "error messages in the standard, parseable format understood by Emacs and " "other Unix tools." msgstr "" -#: ../../library/shlex.rst:221 +#: ../../library/shlex.rst:216 msgid "" "Instances of :class:`~shlex.shlex` subclasses have some public instance " "variables which either control lexical analysis or can be used for debugging:" msgstr "" -#: ../../library/shlex.rst:227 +#: ../../library/shlex.rst:222 msgid "" "The string of characters that are recognized as comment beginners. All " "characters from the comment beginner to end of line are ignored. Includes " "just ``'#'`` by default." msgstr "" -#: ../../library/shlex.rst:234 +#: ../../library/shlex.rst:229 msgid "" "The string of characters that will accumulate into multi-character tokens. " "By default, includes all ASCII alphanumerics and underscore. In POSIX mode, " @@ -268,20 +268,20 @@ msgid "" "effect." msgstr "" -#: ../../library/shlex.rst:247 +#: ../../library/shlex.rst:242 msgid "" "Characters that will be considered whitespace and skipped. Whitespace " "bounds tokens. By default, includes space, tab, linefeed and carriage-" "return." msgstr "" -#: ../../library/shlex.rst:253 +#: ../../library/shlex.rst:248 msgid "" "Characters that will be considered as escape. This will be only used in " "POSIX mode, and includes just ``'\\'`` by default." msgstr "" -#: ../../library/shlex.rst:259 +#: ../../library/shlex.rst:254 msgid "" "Characters that will be considered string quotes. The token accumulates " "until the same quote is encountered again (thus, different quote types " @@ -289,14 +289,14 @@ msgid "" "double quotes." msgstr "" -#: ../../library/shlex.rst:266 +#: ../../library/shlex.rst:261 msgid "" "Characters in :attr:`quotes` that will interpret escape characters defined " "in :attr:`escape`. This is only used in POSIX mode, and includes just " "``'\"'`` by default." msgstr "" -#: ../../library/shlex.rst:273 +#: ../../library/shlex.rst:268 msgid "" "If ``True``, tokens will only be split in whitespaces. This is useful, for " "example, for parsing command lines with :class:`~shlex.shlex`, getting " @@ -305,26 +305,26 @@ msgid "" "those characters." msgstr "" -#: ../../library/shlex.rst:279 +#: ../../library/shlex.rst:274 msgid "" "The :attr:`punctuation_chars` attribute was made compatible with the :attr:" "`whitespace_split` attribute." msgstr "" -#: ../../library/shlex.rst:286 +#: ../../library/shlex.rst:281 msgid "" "The name of the current input file, as initially set at class instantiation " "time or stacked by later source requests. It may be useful to examine this " "when constructing error messages." msgstr "" -#: ../../library/shlex.rst:293 +#: ../../library/shlex.rst:288 msgid "" "The input stream from which this :class:`~shlex.shlex` instance is reading " "characters." msgstr "" -#: ../../library/shlex.rst:299 +#: ../../library/shlex.rst:294 msgid "" "This attribute is ``None`` by default. If you assign a string to it, that " "string will be recognized as a lexical-level inclusion request similar to " @@ -336,29 +336,29 @@ msgid "" "deep." msgstr "" -#: ../../library/shlex.rst:310 +#: ../../library/shlex.rst:305 msgid "" "If this attribute is numeric and ``1`` or more, a :class:`~shlex.shlex` " "instance will print verbose progress output on its behavior. If you need to " "use this, you can read the module source code to learn the details." msgstr "" -#: ../../library/shlex.rst:317 +#: ../../library/shlex.rst:312 msgid "Source line number (count of newlines seen so far plus one)." msgstr "" -#: ../../library/shlex.rst:322 +#: ../../library/shlex.rst:317 msgid "" "The token buffer. It may be useful to examine this when catching exceptions." msgstr "" -#: ../../library/shlex.rst:327 +#: ../../library/shlex.rst:322 msgid "" "Token used to determine end of file. This will be set to the empty string " "(``''``), in non-POSIX mode, and to ``None`` in POSIX mode." msgstr "" -#: ../../library/shlex.rst:333 +#: ../../library/shlex.rst:328 msgid "" "A read-only property. Characters that will be considered punctuation. Runs " "of punctuation characters will be returned as a single token. However, note " @@ -367,39 +367,39 @@ msgid "" "by shells." msgstr "" -#: ../../library/shlex.rst:344 +#: ../../library/shlex.rst:339 msgid "Parsing Rules" msgstr "" -#: ../../library/shlex.rst:346 +#: ../../library/shlex.rst:341 msgid "" "When operating in non-POSIX mode, :class:`~shlex.shlex` will try to obey the " "following rules." msgstr "" -#: ../../library/shlex.rst:349 +#: ../../library/shlex.rst:344 msgid "" "Quote characters are not recognized within words (``Do\"Not\"Separate`` is " "parsed as the single word ``Do\"Not\"Separate``);" msgstr "" -#: ../../library/shlex.rst:352 +#: ../../library/shlex.rst:347 msgid "Escape characters are not recognized;" msgstr "" -#: ../../library/shlex.rst:354 +#: ../../library/shlex.rst:349 msgid "" "Enclosing characters in quotes preserve the literal value of all characters " "within the quotes;" msgstr "" -#: ../../library/shlex.rst:357 +#: ../../library/shlex.rst:352 msgid "" "Closing quotes separate words (``\"Do\"Separate`` is parsed as ``\"Do\"`` " "and ``Separate``);" msgstr "" -#: ../../library/shlex.rst:360 +#: ../../library/shlex.rst:355 msgid "" "If :attr:`~shlex.whitespace_split` is ``False``, any character not declared " "to be a word character, whitespace, or a quote will be returned as a single-" @@ -407,40 +407,40 @@ msgid "" "words in whitespaces;" msgstr "" -#: ../../library/shlex.rst:365 +#: ../../library/shlex.rst:360 msgid "EOF is signaled with an empty string (``''``);" msgstr "" -#: ../../library/shlex.rst:367 +#: ../../library/shlex.rst:362 msgid "It's not possible to parse empty strings, even if quoted." msgstr "" -#: ../../library/shlex.rst:369 +#: ../../library/shlex.rst:364 msgid "" "When operating in POSIX mode, :class:`~shlex.shlex` will try to obey the " "following parsing rules." msgstr "" -#: ../../library/shlex.rst:372 +#: ../../library/shlex.rst:367 msgid "" "Quotes are stripped out, and do not separate words " "(``\"Do\"Not\"Separate\"`` is parsed as the single word ``DoNotSeparate``);" msgstr "" -#: ../../library/shlex.rst:375 +#: ../../library/shlex.rst:370 msgid "" "Non-quoted escape characters (e.g. ``'\\'``) preserve the literal value of " "the next character that follows;" msgstr "" -#: ../../library/shlex.rst:378 +#: ../../library/shlex.rst:373 msgid "" "Enclosing characters in quotes which are not part of :attr:`~shlex." "escapedquotes` (e.g. ``\"'\"``) preserve the literal value of all characters " "within the quotes;" msgstr "" -#: ../../library/shlex.rst:382 +#: ../../library/shlex.rst:377 msgid "" "Enclosing characters in quotes which are part of :attr:`~shlex." "escapedquotes` (e.g. ``'\"'``) preserves the literal value of all characters " @@ -450,19 +450,19 @@ msgid "" "the escape character will be considered a normal character." msgstr "" -#: ../../library/shlex.rst:390 +#: ../../library/shlex.rst:385 msgid "EOF is signaled with a :const:`None` value;" msgstr "" -#: ../../library/shlex.rst:392 +#: ../../library/shlex.rst:387 msgid "Quoted empty strings (``''``) are allowed." msgstr "" -#: ../../library/shlex.rst:397 +#: ../../library/shlex.rst:392 msgid "Improved Compatibility with Shells" msgstr "" -#: ../../library/shlex.rst:401 +#: ../../library/shlex.rst:396 msgid "" "The :class:`shlex` class provides compatibility with the parsing performed " "by common Unix shells like ``bash``, ``dash``, and ``sh``. To take " @@ -477,7 +477,7 @@ msgid "" "following snippet:" msgstr "" -#: ../../library/shlex.rst:412 +#: ../../library/shlex.rst:407 msgid "" ">>> import shlex\n" ">>> text = \"a && b; c && d || e; f >'abc'; (def \\\"ghi\\\")\"\n" @@ -503,20 +503,20 @@ msgstr "" "['a', '&&', 'b', ';', 'c', '&&', 'd', '||', 'e', ';', 'f', '>', 'abc', ';',\n" "'(', 'def', 'ghi', ')']" -#: ../../library/shlex.rst:427 +#: ../../library/shlex.rst:422 msgid "" "Of course, tokens will be returned which are not valid for shells, and " "you'll need to implement your own error checks on the returned tokens." msgstr "" -#: ../../library/shlex.rst:430 +#: ../../library/shlex.rst:425 msgid "" "Instead of passing ``True`` as the value for the punctuation_chars " "parameter, you can pass a string with specific characters, which will be " "used to determine which characters constitute punctuation. For example::" msgstr "" -#: ../../library/shlex.rst:434 +#: ../../library/shlex.rst:429 msgid "" ">>> import shlex\n" ">>> s = shlex.shlex(\"a && b || c\", punctuation_chars=\"|\")\n" @@ -528,7 +528,7 @@ msgstr "" ">>> list(s)\n" "['a', '&', '&', 'b', '||', 'c']" -#: ../../library/shlex.rst:439 +#: ../../library/shlex.rst:434 msgid "" "When ``punctuation_chars`` is specified, the :attr:`~shlex.wordchars` " "attribute is augmented with the characters ``~-./*?=``. That is because " @@ -536,7 +536,7 @@ msgid "" "line arguments (e.g. ``--color=auto``). Hence::" msgstr "" -#: ../../library/shlex.rst:444 +#: ../../library/shlex.rst:439 msgid "" ">>> import shlex\n" ">>> s = shlex.shlex('~/a && b-c --color=auto || d *.py?',\n" @@ -550,7 +550,7 @@ msgstr "" ">>> list(s)\n" "['~/a', '&&', 'b-c', '--color=auto', '||', 'd', '*.py?']" -#: ../../library/shlex.rst:450 +#: ../../library/shlex.rst:445 msgid "" "However, to match the shell as closely as possible, it is recommended to " "always use ``posix`` and :attr:`~shlex.whitespace_split` when using :attr:" @@ -558,7 +558,7 @@ msgid "" "entirely." msgstr "" -#: ../../library/shlex.rst:455 +#: ../../library/shlex.rst:450 msgid "" "For best effect, ``punctuation_chars`` should be set in conjunction with " "``posix=True``. (Note that ``posix=False`` is the default for :class:`~shlex." diff --git a/library/shutil.po b/library/shutil.po index 7d987d1731e..d74168cab54 100644 --- a/library/shutil.po +++ b/library/shutil.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-10 00:43+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:10+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!shutil` --- High-level file operations" msgstr ":mod:`!shutil` — 高階檔案操作" -#: ../../library/shutil.rst:10 +#: ../../library/shutil.rst:7 msgid "**Source code:** :source:`Lib/shutil.py`" msgstr "**原始碼:**\\ :source:`Lib/shutil.py`" -#: ../../library/shutil.rst:18 +#: ../../library/shutil.rst:15 msgid "" "The :mod:`!shutil` module offers a number of high-level operations on files " "and collections of files. In particular, functions are provided which " @@ -33,13 +33,13 @@ msgid "" "also the :mod:`os` module." msgstr "" -#: ../../library/shutil.rst:25 +#: ../../library/shutil.rst:22 msgid "" "Even the higher-level file copying functions (:func:`shutil.copy`, :func:" "`shutil.copy2`) cannot copy all file metadata." msgstr "" -#: ../../library/shutil.rst:28 +#: ../../library/shutil.rst:25 msgid "" "On POSIX platforms, this means that file owner and group are lost as well as " "ACLs. On Mac OS, the resource fork and other metadata are not used. This " @@ -48,11 +48,11 @@ msgid "" "copied." msgstr "" -#: ../../library/shutil.rst:38 +#: ../../library/shutil.rst:35 msgid "Directory and files operations" msgstr "目錄和檔案操作" -#: ../../library/shutil.rst:42 +#: ../../library/shutil.rst:39 msgid "" "Copy the contents of the :term:`file-like object ` *fsrc* to " "the file-like object *fdst*. The integer *length*, if given, is the buffer " @@ -63,7 +63,7 @@ msgid "" "current file position to the end of the file will be copied." msgstr "" -#: ../../library/shutil.rst:50 +#: ../../library/shutil.rst:47 msgid "" ":func:`copyfileobj` will *not* guarantee that the destination stream has " "been flushed on completion of the copy. If you want to read from the " @@ -74,7 +74,7 @@ msgid "" "destination file." msgstr "" -#: ../../library/shutil.rst:60 +#: ../../library/shutil.rst:57 msgid "" "Copy the contents (no metadata) of the file named *src* to a file named " "*dst* and return *dst* in the most efficient way possible. *src* and *dst* " @@ -82,14 +82,14 @@ msgid "" "strings." msgstr "" -#: ../../library/shutil.rst:64 +#: ../../library/shutil.rst:61 msgid "" "*dst* must be the complete target file name; look at :func:`~shutil.copy` " "for a copy that accepts a target directory path. If *src* and *dst* specify " "the same file, :exc:`SameFileError` is raised." msgstr "" -#: ../../library/shutil.rst:68 +#: ../../library/shutil.rst:65 msgid "" "The destination location must be writable; otherwise, an :exc:`OSError` " "exception will be raised. If *dst* already exists, it will be replaced. " @@ -97,14 +97,14 @@ msgid "" "with this function." msgstr "" -#: ../../library/shutil.rst:73 +#: ../../library/shutil.rst:70 msgid "" "If *follow_symlinks* is false and *src* is a symbolic link, a new symbolic " "link will be created instead of copying the file *src* points to." msgstr "" -#: ../../library/shutil.rst:77 ../../library/shutil.rst:191 -#: ../../library/shutil.rst:222 +#: ../../library/shutil.rst:74 ../../library/shutil.rst:188 +#: ../../library/shutil.rst:219 msgid "" "Raises an :ref:`auditing event ` ``shutil.copyfile`` with " "arguments ``src``, ``dst``." @@ -112,40 +112,40 @@ msgstr "" "引發一個附帶引數 ``src``、``dst`` 的\\ :ref:`稽核事件 ` ``shutil." "copyfile``。" -#: ../../library/shutil.rst:79 +#: ../../library/shutil.rst:76 msgid "" ":exc:`IOError` used to be raised instead of :exc:`OSError`. Added " "*follow_symlinks* argument. Now returns *dst*." msgstr "" -#: ../../library/shutil.rst:84 +#: ../../library/shutil.rst:81 msgid "" "Raise :exc:`SameFileError` instead of :exc:`Error`. Since the former is a " "subclass of the latter, this change is backward compatible." msgstr "" -#: ../../library/shutil.rst:88 ../../library/shutil.rst:199 -#: ../../library/shutil.rst:231 ../../library/shutil.rst:301 -#: ../../library/shutil.rst:418 +#: ../../library/shutil.rst:85 ../../library/shutil.rst:196 +#: ../../library/shutil.rst:228 ../../library/shutil.rst:298 +#: ../../library/shutil.rst:415 msgid "" "Platform-specific fast-copy syscalls may be used internally in order to copy " "the file more efficiently. See :ref:`shutil-platform-dependent-efficient-" "copy-operations` section." msgstr "" -#: ../../library/shutil.rst:95 +#: ../../library/shutil.rst:92 msgid "" "This exception is raised when :func:`copyfile` or :func:`copytree` attempt " "to copy a named pipe." msgstr "" -#: ../../library/shutil.rst:102 +#: ../../library/shutil.rst:99 msgid "" "This exception is raised if source and destination in :func:`copyfile` are " "the same file." msgstr "" -#: ../../library/shutil.rst:110 +#: ../../library/shutil.rst:107 msgid "" "Copy the permission bits from *src* to *dst*. The file contents, owner, and " "group are unaffected. *src* and *dst* are :term:`path-like objects ` ``shutil.copymode`` with " "arguments ``src``, ``dst``." @@ -166,11 +166,11 @@ msgstr "" "引發一個附帶引數 ``src``、``dst`` 的\\ :ref:`稽核事件 ` ``shutil." "copymode``。" -#: ../../library/shutil.rst:122 +#: ../../library/shutil.rst:119 msgid "Added *follow_symlinks* argument." msgstr "新增 *follow_symlinks* 引數。" -#: ../../library/shutil.rst:127 +#: ../../library/shutil.rst:124 msgid "" "Copy the permission bits, last access time, last modification time, and " "flags from *src* to *dst*. On Linux, :func:`copystat` also copies the " @@ -179,7 +179,7 @@ msgid "" "object>` or path names given as strings." msgstr "" -#: ../../library/shutil.rst:133 +#: ../../library/shutil.rst:130 msgid "" "If *follow_symlinks* is false, and *src* and *dst* both refer to symbolic " "links, :func:`copystat` will operate on the symbolic links themselves rather " @@ -187,43 +187,43 @@ msgid "" "*src* symbolic link, and writing the information to the *dst* symbolic link." msgstr "" -#: ../../library/shutil.rst:142 +#: ../../library/shutil.rst:139 msgid "" "Not all platforms provide the ability to examine and modify symbolic links. " "Python itself can tell you what functionality is locally available." msgstr "" -#: ../../library/shutil.rst:146 +#: ../../library/shutil.rst:143 msgid "" "If ``os.chmod in os.supports_follow_symlinks`` is ``True``, :func:`copystat` " "can modify the permission bits of a symbolic link." msgstr "" -#: ../../library/shutil.rst:150 +#: ../../library/shutil.rst:147 msgid "" "If ``os.utime in os.supports_follow_symlinks`` is ``True``, :func:`copystat` " "can modify the last access and modification times of a symbolic link." msgstr "" -#: ../../library/shutil.rst:154 +#: ../../library/shutil.rst:151 msgid "" "If ``os.chflags in os.supports_follow_symlinks`` is ``True``, :func:" "`copystat` can modify the flags of a symbolic link. (``os.chflags`` is not " "available on all platforms.)" msgstr "" -#: ../../library/shutil.rst:159 +#: ../../library/shutil.rst:156 msgid "" "On platforms where some or all of this functionality is unavailable, when " "asked to modify a symbolic link, :func:`copystat` will copy everything it " "can. :func:`copystat` never returns failure." msgstr "" -#: ../../library/shutil.rst:164 +#: ../../library/shutil.rst:161 msgid "Please see :data:`os.supports_follow_symlinks` for more information." msgstr "更多資訊請見 :data:`os.supports_follow_symlinks`。" -#: ../../library/shutil.rst:167 ../../library/shutil.rst:224 +#: ../../library/shutil.rst:164 ../../library/shutil.rst:221 msgid "" "Raises an :ref:`auditing event ` ``shutil.copystat`` with " "arguments ``src``, ``dst``." @@ -231,12 +231,12 @@ msgstr "" "引發一個附帶引數 ``src``、``dst`` 的\\ :ref:`稽核事件 ` ``shutil." "copystat``。" -#: ../../library/shutil.rst:169 +#: ../../library/shutil.rst:166 msgid "" "Added *follow_symlinks* argument and support for Linux extended attributes." msgstr "" -#: ../../library/shutil.rst:174 +#: ../../library/shutil.rst:171 msgid "" "Copies the file *src* to the file or directory *dst*. *src* and *dst* " "should be :term:`path-like objects ` or strings. If *dst* " @@ -245,14 +245,14 @@ msgid "" "be replaced. Returns the path to the newly created file." msgstr "" -#: ../../library/shutil.rst:180 +#: ../../library/shutil.rst:177 msgid "" "If *follow_symlinks* is false, and *src* is a symbolic link, *dst* will be " "created as a symbolic link. If *follow_symlinks* is true and *src* is a " "symbolic link, *dst* will be a copy of the file *src* refers to." msgstr "" -#: ../../library/shutil.rst:185 +#: ../../library/shutil.rst:182 msgid "" ":func:`~shutil.copy` copies the file data and the file's permission mode " "(see :func:`os.chmod`). Other metadata, like the file's creation and " @@ -260,18 +260,18 @@ msgid "" "original, use :func:`~shutil.copy2` instead." msgstr "" -#: ../../library/shutil.rst:195 +#: ../../library/shutil.rst:192 msgid "" "Added *follow_symlinks* argument. Now returns path to the newly created file." msgstr "" -#: ../../library/shutil.rst:206 +#: ../../library/shutil.rst:203 msgid "" "Identical to :func:`~shutil.copy` except that :func:`copy2` also attempts to " "preserve file metadata." msgstr "" -#: ../../library/shutil.rst:209 +#: ../../library/shutil.rst:206 msgid "" "When *follow_symlinks* is false, and *src* is a symbolic link, :func:`copy2` " "attempts to copy all metadata from the *src* symbolic link to the newly " @@ -281,41 +281,41 @@ msgid "" "`copy2` never raises an exception because it cannot preserve file metadata." msgstr "" -#: ../../library/shutil.rst:218 +#: ../../library/shutil.rst:215 msgid "" ":func:`copy2` uses :func:`copystat` to copy the file metadata. Please see :" "func:`copystat` for more information about platform support for modifying " "symbolic link metadata." msgstr "" -#: ../../library/shutil.rst:226 +#: ../../library/shutil.rst:223 msgid "" "Added *follow_symlinks* argument, try to copy extended file system " "attributes too (currently Linux only). Now returns path to the newly created " "file." msgstr "" -#: ../../library/shutil.rst:238 +#: ../../library/shutil.rst:235 msgid "" "This factory function creates a function that can be used as a callable for :" "func:`copytree`\\'s *ignore* argument, ignoring files and directories that " "match one of the glob-style *patterns* provided. See the example below." msgstr "" -#: ../../library/shutil.rst:247 +#: ../../library/shutil.rst:244 msgid "" "Recursively copy an entire directory tree rooted at *src* to a directory " "named *dst* and return the destination directory. All intermediate " "directories needed to contain *dst* will also be created by default." msgstr "" -#: ../../library/shutil.rst:251 +#: ../../library/shutil.rst:248 msgid "" "Permissions and times of directories are copied with :func:`copystat`, " "individual files are copied using :func:`~shutil.copy2`." msgstr "" -#: ../../library/shutil.rst:254 +#: ../../library/shutil.rst:251 msgid "" "If *symlinks* is true, symbolic links in the source tree are represented as " "symbolic links in the new tree and the metadata of the original links will " @@ -323,7 +323,7 @@ msgid "" "and metadata of the linked files are copied to the new tree." msgstr "" -#: ../../library/shutil.rst:259 +#: ../../library/shutil.rst:256 msgid "" "When *symlinks* is false, if the file pointed to by the symlink doesn't " "exist, an exception will be added in the list of errors raised in an :exc:" @@ -333,7 +333,7 @@ msgid "" "support :func:`os.symlink`." msgstr "" -#: ../../library/shutil.rst:266 +#: ../../library/shutil.rst:263 msgid "" "If *ignore* is given, it must be a callable that will receive as its " "arguments the directory being visited by :func:`copytree`, and a list of its " @@ -346,12 +346,12 @@ msgid "" "ignores names based on glob-style patterns." msgstr "" -#: ../../library/shutil.rst:276 +#: ../../library/shutil.rst:273 msgid "" "If exception(s) occur, an :exc:`Error` is raised with a list of reasons." msgstr "" -#: ../../library/shutil.rst:278 +#: ../../library/shutil.rst:275 msgid "" "If *copy_function* is given, it must be a callable that will be used to copy " "each file. It will be called with the source path and the destination path " @@ -359,7 +359,7 @@ msgid "" "that supports the same signature (like :func:`~shutil.copy`) can be used." msgstr "" -#: ../../library/shutil.rst:283 +#: ../../library/shutil.rst:280 msgid "" "If *dirs_exist_ok* is false (the default) and *dst* already exists, a :exc:" "`FileExistsError` is raised. If *dirs_exist_ok* is true, the copying " @@ -368,7 +368,7 @@ msgid "" "*src* tree." msgstr "" -#: ../../library/shutil.rst:289 +#: ../../library/shutil.rst:286 msgid "" "Raises an :ref:`auditing event ` ``shutil.copytree`` with " "arguments ``src``, ``dst``." @@ -376,22 +376,22 @@ msgstr "" "引發一個附帶引數 ``src``、``dst`` 的\\ :ref:`稽核事件 ` ``shutil." "copytree``。" -#: ../../library/shutil.rst:291 +#: ../../library/shutil.rst:288 msgid "" "Added the *copy_function* argument to be able to provide a custom copy " "function. Added the *ignore_dangling_symlinks* argument to silence dangling " "symlinks errors when *symlinks* is false." msgstr "" -#: ../../library/shutil.rst:297 +#: ../../library/shutil.rst:294 msgid "Copy metadata when *symlinks* is false. Now returns *dst*." msgstr "" -#: ../../library/shutil.rst:306 +#: ../../library/shutil.rst:303 msgid "Added the *dirs_exist_ok* parameter." msgstr "新增 *dirs_exist_ok* 參數。" -#: ../../library/shutil.rst:313 +#: ../../library/shutil.rst:310 msgid "" "Delete an entire directory tree; *path* must point to a directory (but not a " "symbolic link to a directory). If *ignore_errors* is true, errors resulting " @@ -400,13 +400,13 @@ msgid "" "are omitted, exceptions are propagated to the caller." msgstr "" -#: ../../library/shutil.rst:319 +#: ../../library/shutil.rst:316 msgid "" "This function can support :ref:`paths relative to directory descriptors " "`." msgstr "" -#: ../../library/shutil.rst:324 +#: ../../library/shutil.rst:321 msgid "" "On platforms that support the necessary fd-based functions a symlink attack " "resistant version of :func:`rmtree` is used by default. On other platforms, " @@ -417,13 +417,13 @@ msgid "" "attribute to determine which case applies." msgstr "" -#: ../../library/shutil.rst:332 +#: ../../library/shutil.rst:329 msgid "" "If *onexc* is provided, it must be a callable that accepts three parameters: " "*function*, *path*, and *excinfo*." msgstr "" -#: ../../library/shutil.rst:335 +#: ../../library/shutil.rst:332 msgid "" "The first parameter, *function*, is the function which raised the exception; " "it depends on the platform and implementation. The second parameter, " @@ -432,19 +432,19 @@ msgid "" "will not be caught." msgstr "" -#: ../../library/shutil.rst:341 +#: ../../library/shutil.rst:338 msgid "" "The deprecated *onerror* is similar to *onexc*, except that the third " "parameter it receives is the tuple returned from :func:`sys.exc_info`." msgstr "" -#: ../../library/shutil.rst:345 +#: ../../library/shutil.rst:342 msgid "" ":ref:`shutil-rmtree-example` for an example of handling the removal of a " "directory tree that contains read-only files." msgstr "" -#: ../../library/shutil.rst:348 +#: ../../library/shutil.rst:345 msgid "" "Raises an :ref:`auditing event ` ``shutil.rmtree`` with arguments " "``path``, ``dir_fd``." @@ -452,60 +452,60 @@ msgstr "" "引發一個附帶引數 ``path``、``dir_fd`` 的\\ :ref:`稽核事件 ` " "``shutil.rmtree``。" -#: ../../library/shutil.rst:350 +#: ../../library/shutil.rst:347 msgid "" "Added a symlink attack resistant version that is used automatically if " "platform supports fd-based functions." msgstr "" -#: ../../library/shutil.rst:354 +#: ../../library/shutil.rst:351 msgid "" "On Windows, will no longer delete the contents of a directory junction " "before removing the junction." msgstr "" -#: ../../library/shutil.rst:358 +#: ../../library/shutil.rst:355 msgid "Added the *dir_fd* parameter." msgstr "新增 *dir_fd* 參數。" -#: ../../library/shutil.rst:361 +#: ../../library/shutil.rst:358 msgid "Added the *onexc* parameter, deprecated *onerror*." msgstr "新增 *onexc* 參數並棄用 *onerror*。" -#: ../../library/shutil.rst:364 +#: ../../library/shutil.rst:361 msgid "" ":func:`!rmtree` now ignores :exc:`FileNotFoundError` exceptions for all but " "the top-level path. Exceptions other than :exc:`OSError` and subclasses of :" "exc:`!OSError` are now always propagated to the caller." msgstr "" -#: ../../library/shutil.rst:372 +#: ../../library/shutil.rst:369 msgid "" "Indicates whether the current platform and implementation provides a symlink " "attack resistant version of :func:`rmtree`. Currently this is only true for " "platforms supporting fd-based directory access functions." msgstr "" -#: ../../library/shutil.rst:381 +#: ../../library/shutil.rst:378 msgid "" "Recursively move a file or directory (*src*) to another location and return " "the destination." msgstr "" -#: ../../library/shutil.rst:384 +#: ../../library/shutil.rst:381 msgid "" "If *dst* is an existing directory or a symlink to a directory, then *src* is " "moved inside that directory. The destination path in that directory must not " "already exist." msgstr "" -#: ../../library/shutil.rst:388 +#: ../../library/shutil.rst:385 msgid "" "If *dst* already exists but is not a directory, it may be overwritten " "depending on :func:`os.rename` semantics." msgstr "" -#: ../../library/shutil.rst:391 +#: ../../library/shutil.rst:388 msgid "" ":func:`os.rename` is preferably used internally when *src* and the " "destination are on the same filesystem. In case :func:`os.rename` fails due " @@ -515,13 +515,13 @@ msgid "" "*copy_function* and then removed." msgstr "" -#: ../../library/shutil.rst:397 +#: ../../library/shutil.rst:394 msgid "" "In case of symlinks, a new symlink pointing to the target of *src* will be " "created in or as the destination, and *src* will be removed." msgstr "" -#: ../../library/shutil.rst:400 +#: ../../library/shutil.rst:397 msgid "" "If *copy_function* is given, it must be a callable that takes two arguments, " "*src* and the destination, and will be used to copy *src* to the destination " @@ -532,7 +532,7 @@ msgid "" "copy the metadata, at the expense of not copying any of the metadata." msgstr "" -#: ../../library/shutil.rst:408 +#: ../../library/shutil.rst:405 msgid "" "Raises an :ref:`auditing event ` ``shutil.move`` with arguments " "``src``, ``dst``." @@ -540,57 +540,57 @@ msgstr "" "引發一個附帶引數 ``src``、``dst`` 的\\ :ref:`稽核事件 ` ``shutil." "move``。" -#: ../../library/shutil.rst:410 +#: ../../library/shutil.rst:407 msgid "" "Added explicit symlink handling for foreign filesystems, thus adapting it to " "the behavior of GNU's :program:`mv`. Now returns *dst*." msgstr "" -#: ../../library/shutil.rst:415 +#: ../../library/shutil.rst:412 msgid "Added the *copy_function* keyword argument." msgstr "新增 *copy_function* 關鍵字引數。" -#: ../../library/shutil.rst:423 +#: ../../library/shutil.rst:420 msgid "Accepts a :term:`path-like object` for both *src* and *dst*." msgstr "" -#: ../../library/shutil.rst:428 +#: ../../library/shutil.rst:425 msgid "" "Return disk usage statistics about the given path as a :term:`named tuple` " "with the attributes *total*, *used* and *free*, which are the amount of " "total, used and free space, in bytes. *path* may be a file or a directory." msgstr "" -#: ../../library/shutil.rst:435 +#: ../../library/shutil.rst:432 msgid "" "On Unix filesystems, *path* must point to a path within a **mounted** " "filesystem partition. On those platforms, CPython doesn't attempt to " "retrieve disk usage information from non-mounted filesystems." msgstr "" -#: ../../library/shutil.rst:441 +#: ../../library/shutil.rst:438 msgid "On Windows, *path* can now be a file or directory." msgstr "" -#: ../../library/shutil.rst:444 ../../library/shutil.rst:458 +#: ../../library/shutil.rst:441 ../../library/shutil.rst:455 msgid "Availability" msgstr "可用性" -#: ../../library/shutil.rst:449 +#: ../../library/shutil.rst:446 msgid "Change owner *user* and/or *group* of the given *path*." msgstr "" -#: ../../library/shutil.rst:451 +#: ../../library/shutil.rst:448 msgid "" "*user* can be a system user name or a uid; the same applies to *group*. At " "least one argument is required." msgstr "" -#: ../../library/shutil.rst:454 +#: ../../library/shutil.rst:451 msgid "See also :func:`os.chown`, the underlying function." msgstr "另請參閱 :func:`os.chown`,它是底層函式。" -#: ../../library/shutil.rst:456 +#: ../../library/shutil.rst:453 msgid "" "Raises an :ref:`auditing event ` ``shutil.chown`` with arguments " "``path``, ``user``, ``group``." @@ -598,23 +598,23 @@ msgstr "" "引發一個附帶引數 ``path``、``user``、``group`` 的\\ :ref:`稽核事件 " "` ``shutil.chown``。" -#: ../../library/shutil.rst:462 +#: ../../library/shutil.rst:459 msgid "Added *dir_fd* and *follow_symlinks* parameters." msgstr "新增 *dir_fd* 和 *follow_symlinks* 參數。" -#: ../../library/shutil.rst:468 +#: ../../library/shutil.rst:465 msgid "" "Return the path to an executable which would be run if the given *cmd* was " "called. If no *cmd* would be called, return ``None``." msgstr "" -#: ../../library/shutil.rst:471 +#: ../../library/shutil.rst:468 msgid "" "*mode* is a permission mask passed to :func:`os.access`, by default " "determining if the file exists and is executable." msgstr "" -#: ../../library/shutil.rst:474 +#: ../../library/shutil.rst:471 msgid "" "*path* is a \"``PATH`` string\" specifying the directories to look in, " "delimited by :data:`os.pathsep`. When no *path* is specified, the :envvar:" @@ -622,14 +622,14 @@ msgid "" "to :data:`os.defpath` if it is not set." msgstr "" -#: ../../library/shutil.rst:479 +#: ../../library/shutil.rst:476 msgid "" "If *cmd* contains a directory component, :func:`!which` only checks the " "specified path directly and does not search the directories listed in *path* " "or in the system's :envvar:`PATH` environment variable." msgstr "" -#: ../../library/shutil.rst:483 +#: ../../library/shutil.rst:480 msgid "" "On Windows, the current directory is prepended to the *path* if *mode* does " "not include ``os.X_OK``. When the *mode* does include ``os.X_OK``, the " @@ -639,7 +639,7 @@ msgid "" "environment variable ``NoDefaultCurrentDirectoryInExePath``." msgstr "" -#: ../../library/shutil.rst:490 +#: ../../library/shutil.rst:487 msgid "" "Also on Windows, the :envvar:`PATHEXT` environment variable is used to " "resolve commands that may not already include an extension. For example, if " @@ -648,7 +648,7 @@ msgid "" "directories. For example, on Windows::" msgstr "" -#: ../../library/shutil.rst:496 +#: ../../library/shutil.rst:493 msgid "" ">>> shutil.which(\"python\")\n" "'C:\\\\Python33\\\\python.EXE'" @@ -656,13 +656,13 @@ msgstr "" ">>> shutil.which(\"python\")\n" "'C:\\\\Python33\\\\python.EXE'" -#: ../../library/shutil.rst:499 +#: ../../library/shutil.rst:496 msgid "" "This is also applied when *cmd* is a path that contains a directory " "component::" msgstr "" -#: ../../library/shutil.rst:502 +#: ../../library/shutil.rst:499 msgid "" ">>> shutil.which(\"C:\\\\Python33\\\\python\")\n" "'C:\\\\Python33\\\\python.EXE'" @@ -670,13 +670,13 @@ msgstr "" ">>> shutil.which(\"C:\\\\Python33\\\\python\")\n" "'C:\\\\Python33\\\\python.EXE'" -#: ../../library/shutil.rst:507 +#: ../../library/shutil.rst:504 msgid "" "The :class:`bytes` type is now accepted. If *cmd* type is :class:`bytes`, " "the result type is also :class:`bytes`." msgstr "" -#: ../../library/shutil.rst:511 +#: ../../library/shutil.rst:508 msgid "" "On Windows, the current directory is no longer prepended to the search path " "if *mode* includes ``os.X_OK`` and WinAPI " @@ -687,18 +687,18 @@ msgid "" "now be found." msgstr "" -#: ../../library/shutil.rst:522 +#: ../../library/shutil.rst:519 msgid "" -"This exception collects exceptions that are raised during a multi-file " +"Subclass of :exc:`OSError` collecting exceptions raised during a multi-file " "operation. For :func:`copytree`, the exception argument is a list of 3-" "tuples (*srcname*, *dstname*, *exception*)." msgstr "" -#: ../../library/shutil.rst:529 +#: ../../library/shutil.rst:526 msgid "Platform-dependent efficient copy operations" msgstr "" -#: ../../library/shutil.rst:531 +#: ../../library/shutil.rst:528 msgid "" "Starting from Python 3.8, all functions involving a file copy (:func:" "`copyfile`, :func:`~shutil.copy`, :func:`copy2`, :func:`copytree`, and :func:" @@ -708,51 +708,53 @@ msgid "" "buffers in Python as in \"``outfd.write(infd.read())``\"." msgstr "" -#: ../../library/shutil.rst:539 +#: ../../library/shutil.rst:536 msgid "On macOS `fcopyfile`_ is used to copy the file content (not metadata)." msgstr "" -#: ../../library/shutil.rst:541 +#: ../../library/shutil.rst:538 msgid "On Linux :func:`os.copy_file_range` or :func:`os.sendfile` is used." msgstr "Linux 上會使用 :func:`os.copy_file_range` 或 :func:`os.sendfile`。" -#: ../../library/shutil.rst:543 +#: ../../library/shutil.rst:540 msgid "On Solaris :func:`os.sendfile` is used." msgstr "Solaris 上會使用 :func:`os.sendfile`。" -#: ../../library/shutil.rst:545 +#: ../../library/shutil.rst:542 msgid "" "On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB " "instead of 64 KiB) and a :func:`memoryview`-based variant of :func:`shutil." -"copyfileobj` is used." +"copyfileobj` is used, which still reads and writes in a loop. :func:`shutil." +"copy2` uses the native ``CopyFile2`` call on Windows, which is the most " +"efficient method, supports copy-on-write, and preserves metadata." msgstr "" -#: ../../library/shutil.rst:549 +#: ../../library/shutil.rst:548 msgid "" "If the fast-copy operation fails and no data was written in the destination " "file then shutil will silently fall back to less efficient :func:" "`copyfileobj` function internally." msgstr "" -#: ../../library/shutil.rst:555 +#: ../../library/shutil.rst:554 msgid "Solaris now uses :func:`os.sendfile`." msgstr "" -#: ../../library/shutil.rst:558 +#: ../../library/shutil.rst:557 msgid "" "Copy-on-write or server-side copy may be used internally via :func:`os." "copy_file_range` on supported Linux filesystems." msgstr "" -#: ../../library/shutil.rst:565 +#: ../../library/shutil.rst:564 msgid "copytree example" msgstr "copytree 範例" -#: ../../library/shutil.rst:567 +#: ../../library/shutil.rst:566 msgid "An example that uses the :func:`ignore_patterns` helper::" msgstr "" -#: ../../library/shutil.rst:569 +#: ../../library/shutil.rst:568 msgid "" "from shutil import copytree, ignore_patterns\n" "\n" @@ -762,17 +764,17 @@ msgstr "" "\n" "copytree(source, destination, ignore=ignore_patterns('*.pyc', 'tmp*'))" -#: ../../library/shutil.rst:573 +#: ../../library/shutil.rst:572 msgid "" "This will copy everything except ``.pyc`` files and files or directories " "whose name starts with ``tmp``." msgstr "" -#: ../../library/shutil.rst:576 +#: ../../library/shutil.rst:575 msgid "Another example that uses the *ignore* argument to add a logging call::" msgstr "" -#: ../../library/shutil.rst:578 +#: ../../library/shutil.rst:577 msgid "" "from shutil import copytree\n" "import logging\n" @@ -792,11 +794,11 @@ msgstr "" "\n" "copytree(source, destination, ignore=_logpath)" -#: ../../library/shutil.rst:591 +#: ../../library/shutil.rst:590 msgid "rmtree example" msgstr "rmtree 範例" -#: ../../library/shutil.rst:593 +#: ../../library/shutil.rst:592 msgid "" "This example shows how to remove a directory tree on Windows where some of " "the files have their read-only bit set. It uses the onexc callback to clear " @@ -804,7 +806,7 @@ msgid "" "propagate. ::" msgstr "" -#: ../../library/shutil.rst:598 +#: ../../library/shutil.rst:597 msgid "" "import os, stat\n" "import shutil\n" @@ -817,31 +819,31 @@ msgid "" "shutil.rmtree(directory, onexc=remove_readonly)" msgstr "" -#: ../../library/shutil.rst:611 +#: ../../library/shutil.rst:610 msgid "Archiving operations" msgstr "" -#: ../../library/shutil.rst:615 +#: ../../library/shutil.rst:614 msgid "Added support for the *xztar* format." msgstr "新增 *xztar* 格式的支援。" -#: ../../library/shutil.rst:619 +#: ../../library/shutil.rst:618 msgid "" "High-level utilities to create and read compressed and archived files are " "also provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules." msgstr "" -#: ../../library/shutil.rst:624 +#: ../../library/shutil.rst:623 msgid "Create an archive file (such as zip or tar) and return its name." msgstr "" -#: ../../library/shutil.rst:626 +#: ../../library/shutil.rst:625 msgid "" -"*base_name* is the name of the file to create, including the path, minus any " -"format-specific extension." +"*base_name* is a string or :term:`path-like object` specifying the name of " +"the file to create, including the path, minus any format-specific extension." msgstr "" -#: ../../library/shutil.rst:629 +#: ../../library/shutil.rst:628 msgid "" "*format* is the archive format: one of \"zip\" (if the :mod:`zlib` module is " "available), \"tar\", \"gztar\" (if the :mod:`zlib` module is available), " @@ -850,19 +852,21 @@ msgid "" "module is available)." msgstr "" -#: ../../library/shutil.rst:635 +#: ../../library/shutil.rst:634 msgid "" -"*root_dir* is a directory that will be the root directory of the archive, " -"all paths in the archive will be relative to it; for example, we typically " -"chdir into *root_dir* before creating the archive." +"*root_dir* is a string or :term:`path-like object` specifying a directory " +"that will be the root directory of the archive, all paths in the archive " +"will be relative to it; for example, we typically chdir into *root_dir* " +"before creating the archive." msgstr "" #: ../../library/shutil.rst:639 msgid "" -"*base_dir* is the directory where we start archiving from; i.e. *base_dir* " -"will be the common prefix of all files and directories in the archive. " -"*base_dir* must be given relative to *root_dir*. See :ref:`shutil-archiving-" -"example-with-basedir` for how to use *base_dir* and *root_dir* together." +"*base_dir* is a string or :term:`path-like object` specifying a directory " +"where we start archiving from; i.e. *base_dir* will be the common prefix of " +"all files and directories in the archive. *base_dir* must be given relative " +"to *root_dir*. See :ref:`shutil-archiving-example-with-basedir` for how to " +"use *base_dir* and *root_dir* together." msgstr "" #: ../../library/shutil.rst:645 @@ -921,54 +925,60 @@ msgid "" "and tar archives." msgstr "" -#: ../../library/shutil.rst:678 +#: ../../library/shutil.rst:676 +msgid "" +"Accepts a :term:`path-like object` for *base_name*, *root_dir* and " +"*base_dir*." +msgstr "" + +#: ../../library/shutil.rst:682 msgid "" "Return a list of supported formats for archiving. Each element of the " "returned sequence is a tuple ``(name, description)``." msgstr "" -#: ../../library/shutil.rst:681 ../../library/shutil.rst:798 +#: ../../library/shutil.rst:685 ../../library/shutil.rst:802 msgid "By default :mod:`!shutil` provides these formats:" msgstr "預設情況下 :mod:`!shutil` 提供這些格式:" -#: ../../library/shutil.rst:683 +#: ../../library/shutil.rst:687 msgid "*zip*: ZIP file (if the :mod:`zlib` module is available)." msgstr "" -#: ../../library/shutil.rst:684 +#: ../../library/shutil.rst:688 msgid "" "*tar*: Uncompressed tar file. Uses POSIX.1-2001 pax format for new archives." msgstr "" -#: ../../library/shutil.rst:685 ../../library/shutil.rst:803 +#: ../../library/shutil.rst:689 ../../library/shutil.rst:807 msgid "*gztar*: gzip'ed tar-file (if the :mod:`zlib` module is available)." msgstr "" -#: ../../library/shutil.rst:686 ../../library/shutil.rst:804 +#: ../../library/shutil.rst:690 ../../library/shutil.rst:808 msgid "*bztar*: bzip2'ed tar-file (if the :mod:`bz2` module is available)." msgstr "" -#: ../../library/shutil.rst:687 ../../library/shutil.rst:805 +#: ../../library/shutil.rst:691 ../../library/shutil.rst:809 msgid "*xztar*: xz'ed tar-file (if the :mod:`lzma` module is available)." msgstr "" -#: ../../library/shutil.rst:688 ../../library/shutil.rst:806 +#: ../../library/shutil.rst:692 ../../library/shutil.rst:810 msgid "" "*zstdtar*: Zstandard compressed tar-file (if the :mod:`compression.zstd` " "module is available)." msgstr "" -#: ../../library/shutil.rst:691 +#: ../../library/shutil.rst:695 msgid "" "You can register new formats or provide your own archiver for any existing " "formats, by using :func:`register_archive_format`." msgstr "" -#: ../../library/shutil.rst:697 +#: ../../library/shutil.rst:701 msgid "Register an archiver for the format *name*." msgstr "" -#: ../../library/shutil.rst:699 +#: ../../library/shutil.rst:703 msgid "" "*function* is the callable that will be used to create archives. The " "callable will receive the *base_name* of the file to create, followed by the " @@ -977,7 +987,7 @@ msgid "" "*dry_run* and *logger* (as passed in :func:`make_archive`)." msgstr "" -#: ../../library/shutil.rst:705 +#: ../../library/shutil.rst:709 msgid "" "If *function* has the custom attribute ``function.supports_root_dir`` set to " "``True``, the *root_dir* argument is passed as a keyword argument. Otherwise " @@ -986,37 +996,37 @@ msgid "" "not thread-safe." msgstr "" -#: ../../library/shutil.rst:711 +#: ../../library/shutil.rst:715 msgid "" "If given, *extra_args* is a sequence of ``(name, value)`` pairs that will be " "used as extra keywords arguments when the archiver callable is used." msgstr "" -#: ../../library/shutil.rst:714 +#: ../../library/shutil.rst:718 msgid "" "*description* is used by :func:`get_archive_formats` which returns the list " "of archivers. Defaults to an empty string." msgstr "" -#: ../../library/shutil.rst:717 +#: ../../library/shutil.rst:721 msgid "Added support for functions supporting the *root_dir* argument." msgstr "" -#: ../../library/shutil.rst:723 +#: ../../library/shutil.rst:727 msgid "Remove the archive format *name* from the list of supported formats." msgstr "" -#: ../../library/shutil.rst:728 +#: ../../library/shutil.rst:732 msgid "Unpack an archive. *filename* is the full path of the archive." msgstr "" -#: ../../library/shutil.rst:730 +#: ../../library/shutil.rst:734 msgid "" "*extract_dir* is the name of the target directory where the archive is " "unpacked. If not provided, the current working directory is used." msgstr "" -#: ../../library/shutil.rst:733 +#: ../../library/shutil.rst:737 msgid "" "*format* is the archive format: one of \"zip\", \"tar\", \"gztar\", " "\"bztar\", \"xztar\", or \"zstdtar\". Or any other format registered with :" @@ -1025,7 +1035,7 @@ msgid "" "for that extension. In case none is found, a :exc:`ValueError` is raised." msgstr "" -#: ../../library/shutil.rst:740 +#: ../../library/shutil.rst:744 msgid "" "The keyword-only *filter* argument is passed to the underlying unpacking " "function. For zip files, *filter* is not accepted. For tar files, it is " @@ -1034,7 +1044,7 @@ msgid "" "extraction-filter` for details.)" msgstr "" -#: ../../library/shutil.rst:746 +#: ../../library/shutil.rst:750 msgid "" "Raises an :ref:`auditing event ` ``shutil.unpack_archive`` with " "arguments ``filename``, ``extract_dir``, ``format``." @@ -1042,7 +1052,7 @@ msgstr "" "引發一個附帶引數 ``filename``、``extract_dir``、``format`` 的\\ :ref:`稽核事" "件 ` ``shutil.unpack_archive``。" -#: ../../library/shutil.rst:750 +#: ../../library/shutil.rst:754 msgid "" "Never extract archives from untrusted sources without prior inspection. It " "is possible that files are created outside of the path specified in the " @@ -1050,7 +1060,7 @@ msgid "" "filenames with \"..\" components." msgstr "" -#: ../../library/shutil.rst:755 +#: ../../library/shutil.rst:759 msgid "" "Since Python 3.14, the defaults for both built-in formats (zip and tar " "files) will prevent the most dangerous of such security issues, but will not " @@ -1058,91 +1068,91 @@ msgid "" "verification` section for tar-specific details." msgstr "" -#: ../../library/shutil.rst:761 +#: ../../library/shutil.rst:765 msgid "Accepts a :term:`path-like object` for *filename* and *extract_dir*." msgstr "" -#: ../../library/shutil.rst:764 +#: ../../library/shutil.rst:768 msgid "Added the *filter* argument." msgstr "新增 *filter* 引數。" -#: ../../library/shutil.rst:769 +#: ../../library/shutil.rst:773 msgid "" "Registers an unpack format. *name* is the name of the format and " "*extensions* is a list of extensions corresponding to the format, like ``." "zip`` for Zip files." msgstr "" -#: ../../library/shutil.rst:773 +#: ../../library/shutil.rst:777 msgid "" "*function* is the callable that will be used to unpack archives. The " "callable will receive:" msgstr "" -#: ../../library/shutil.rst:776 +#: ../../library/shutil.rst:780 msgid "the path of the archive, as a positional argument;" msgstr "" -#: ../../library/shutil.rst:777 +#: ../../library/shutil.rst:781 msgid "" "the directory the archive must be extracted to, as a positional argument;" msgstr "" -#: ../../library/shutil.rst:778 +#: ../../library/shutil.rst:782 msgid "" "possibly a *filter* keyword argument, if it was given to :func:" "`unpack_archive`;" msgstr "" -#: ../../library/shutil.rst:780 +#: ../../library/shutil.rst:784 msgid "" "additional keyword arguments, specified by *extra_args* as a sequence of " "``(name, value)`` tuples." msgstr "" -#: ../../library/shutil.rst:783 +#: ../../library/shutil.rst:787 msgid "" "*description* can be provided to describe the format, and will be returned " "by the :func:`get_unpack_formats` function." msgstr "" -#: ../../library/shutil.rst:789 +#: ../../library/shutil.rst:793 msgid "Unregister an unpack format. *name* is the name of the format." msgstr "" -#: ../../library/shutil.rst:794 +#: ../../library/shutil.rst:798 msgid "" "Return a list of all registered formats for unpacking. Each element of the " "returned sequence is a tuple ``(name, extensions, description)``." msgstr "" -#: ../../library/shutil.rst:800 +#: ../../library/shutil.rst:804 msgid "" "*zip*: ZIP file (unpacking compressed files works only if the corresponding " "module is available)." msgstr "" -#: ../../library/shutil.rst:802 +#: ../../library/shutil.rst:806 msgid "*tar*: uncompressed tar file." msgstr "" -#: ../../library/shutil.rst:809 +#: ../../library/shutil.rst:813 msgid "" "You can register new formats or provide your own unpacker for any existing " "formats, by using :func:`register_unpack_format`." msgstr "" -#: ../../library/shutil.rst:816 +#: ../../library/shutil.rst:820 msgid "Archiving example" msgstr "" -#: ../../library/shutil.rst:818 +#: ../../library/shutil.rst:822 msgid "" "In this example, we create a gzip'ed tar-file archive containing all files " "found in the :file:`.ssh` directory of the user::" msgstr "" -#: ../../library/shutil.rst:821 +#: ../../library/shutil.rst:825 msgid "" ">>> from shutil import make_archive\n" ">>> import os\n" @@ -1158,11 +1168,11 @@ msgstr "" ">>> make_archive(archive_name, 'gztar', root_dir)\n" "'/Users/tarek/myarchive.tar.gz'" -#: ../../library/shutil.rst:828 +#: ../../library/shutil.rst:832 msgid "The resulting archive contains:" msgstr "" -#: ../../library/shutil.rst:830 +#: ../../library/shutil.rst:834 msgid "" "$ tar -tzvf /Users/tarek/myarchive.tar.gz\n" "drwx------ tarek/staff 0 2010-02-01 16:23:40 ./\n" @@ -1184,18 +1194,18 @@ msgstr "" "-rw-r--r-- tarek/staff 397 2008-06-09 13:26:54 ./id_rsa.pub\n" "-rw-r--r-- tarek/staff 37192 2010-02-06 18:23:10 ./known_hosts" -#: ../../library/shutil.rst:846 +#: ../../library/shutil.rst:850 msgid "Archiving example with *base_dir*" msgstr "" -#: ../../library/shutil.rst:848 +#: ../../library/shutil.rst:852 msgid "" "In this example, similar to the `one above `_, we " "show how to use :func:`make_archive`, but this time with the usage of " "*base_dir*. We now have the following directory structure:" msgstr "" -#: ../../library/shutil.rst:852 +#: ../../library/shutil.rst:856 msgid "" "$ tree tmp\n" "tmp\n" @@ -1213,13 +1223,13 @@ msgstr "" " └── please_add.txt\n" " └── do_not_add.txt" -#: ../../library/shutil.rst:862 +#: ../../library/shutil.rst:866 msgid "" "In the final archive, :file:`please_add.txt` should be included, but :file:" "`do_not_add.txt` should not. Therefore we use the following::" msgstr "" -#: ../../library/shutil.rst:865 +#: ../../library/shutil.rst:869 msgid "" ">>> from shutil import make_archive\n" ">>> import os\n" @@ -1243,11 +1253,11 @@ msgstr "" "... )\n" "'/Users/tarek/myarchive.tar'" -#: ../../library/shutil.rst:876 +#: ../../library/shutil.rst:880 msgid "Listing the files in the resulting archive gives us:" msgstr "" -#: ../../library/shutil.rst:878 +#: ../../library/shutil.rst:882 msgid "" "$ python -m tarfile -l /Users/tarek/myarchive.tar\n" "structure/content/\n" @@ -1257,29 +1267,29 @@ msgstr "" "structure/content/\n" "structure/content/please_add.txt" -#: ../../library/shutil.rst:886 +#: ../../library/shutil.rst:890 msgid "Querying the size of the output terminal" msgstr "" -#: ../../library/shutil.rst:890 +#: ../../library/shutil.rst:894 msgid "Get the size of the terminal window." msgstr "" -#: ../../library/shutil.rst:892 +#: ../../library/shutil.rst:896 msgid "" "For each of the two dimensions, the environment variable, ``COLUMNS`` and " "``LINES`` respectively, is checked. If the variable is defined and the value " "is a positive integer, it is used." msgstr "" -#: ../../library/shutil.rst:896 +#: ../../library/shutil.rst:900 msgid "" "When ``COLUMNS`` or ``LINES`` is not defined, which is the common case, the " "terminal connected to :data:`sys.__stdout__` is queried by invoking :func:" "`os.get_terminal_size`." msgstr "" -#: ../../library/shutil.rst:900 +#: ../../library/shutil.rst:904 msgid "" "If the terminal size cannot be successfully queried, either because the " "system doesn't support querying, or because we are not connected to a " @@ -1288,38 +1298,38 @@ msgid "" "emulators." msgstr "" -#: ../../library/shutil.rst:906 +#: ../../library/shutil.rst:910 msgid "The value returned is a named tuple of type :class:`os.terminal_size`." msgstr "" -#: ../../library/shutil.rst:908 +#: ../../library/shutil.rst:912 msgid "" "See also: The Single UNIX Specification, Version 2, `Other Environment " "Variables`_." msgstr "" -#: ../../library/shutil.rst:913 +#: ../../library/shutil.rst:917 msgid "" "The ``fallback`` values are also used if :func:`os.get_terminal_size` " "returns zeroes." msgstr "" -#: ../../library/shutil.rst:12 +#: ../../library/shutil.rst:9 msgid "file" msgstr "file(檔案)" -#: ../../library/shutil.rst:12 +#: ../../library/shutil.rst:9 msgid "copying" msgstr "copying(複製)" -#: ../../library/shutil.rst:12 +#: ../../library/shutil.rst:9 msgid "copying files" msgstr "copying files(複製檔案)" -#: ../../library/shutil.rst:311 +#: ../../library/shutil.rst:308 msgid "directory" msgstr "directory(目錄)" -#: ../../library/shutil.rst:311 +#: ../../library/shutil.rst:308 msgid "deleting" msgstr "deleting(刪除)" diff --git a/library/signal.po b/library/signal.po index 3a0f2e0f099..0839ec9f2d7 100644 --- a/library/signal.po +++ b/library/signal.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-27 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:10+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -204,10 +204,10 @@ msgstr "" #: ../../library/signal.rst:307 ../../library/signal.rst:386 #: ../../library/signal.rst:425 ../../library/signal.rst:449 #: ../../library/signal.rst:472 ../../library/signal.rst:506 -#: ../../library/signal.rst:536 ../../library/signal.rst:543 -#: ../../library/signal.rst:598 ../../library/signal.rst:640 -#: ../../library/signal.rst:655 ../../library/signal.rst:680 -#: ../../library/signal.rst:700 +#: ../../library/signal.rst:537 ../../library/signal.rst:548 +#: ../../library/signal.rst:603 ../../library/signal.rst:645 +#: ../../library/signal.rst:660 ../../library/signal.rst:685 +#: ../../library/signal.rst:705 msgid "Availability" msgstr "可用性" @@ -681,16 +681,17 @@ msgstr "另請參閱 :func:`pause`、:func:`sigpending` 與 :func:`sigwait`。" msgid "" "Sets given interval timer (one of :const:`signal.ITIMER_REAL`, :const:" "`signal.ITIMER_VIRTUAL` or :const:`signal.ITIMER_PROF`) specified by *which* " -"to fire after *seconds* (float is accepted, different from :func:`alarm`) " -"and after that every *interval* seconds (if *interval* is non-zero). The " -"interval timer specified by *which* can be cleared by setting *seconds* to " -"zero." -msgstr "" -"設定由 *which* 指定的間隔計時器(:const:`signal.ITIMER_REAL`、:const:`signal." -"ITIMER_VIRTUAL` 或 :const:`signal.ITIMER_PROF` 之一)並在*seconds*\\ (接受浮" -"點數,與 :func:`alarm` 不同)之後啟動,在之後的每 *interval* 秒啟動一次(如" -"果 *interval* 非零)。*which* 指定的間隔計時器可透過將 *seconds* 設定為零來清" -"除它。" +"to fire after *seconds* (rounded up to microseconds, different from :func:" +"`alarm`) and after that every *interval* seconds (if *interval* is non-" +"zero). The interval timer specified by *which* can be cleared by setting " +"*seconds* to zero." +msgstr "" +"設定由 *which* 指定的間隔計時器" +"(:const:`signal.ITIMER_REAL`、:const:`signal.ITIMER_VIRTUAL` " +"或 :const:`signal.ITIMER_PROF` 之一)並在 *seconds*\\ (無條件進位至微秒," +"與 :func:`alarm` 不同)之後啟動,在之後的每 *interval* 秒啟動一次(如果 " +"*interval* 非零)。*which* 指定的間隔計時器可透過將 *seconds* 設定為零來清除" +"它。" #: ../../library/signal.rst:525 msgid "" @@ -705,20 +706,28 @@ msgstr "" "傳送 :const:`SIGPROF`。" #: ../../library/signal.rst:531 -msgid "The old values are returned as a tuple: (delay, interval)." -msgstr "舊值會以一個元組回傳:(delay, interval)。" +msgid "" +"The old values are returned as a two-tuple of floats: (``delay``, " +"``interval``)." +msgstr "舊值會以一個由兩個浮點數組成的元組回傳:(``delay``, ``interval``)。" -#: ../../library/signal.rst:533 +#: ../../library/signal.rst:534 msgid "" "Attempting to pass an invalid interval timer will cause an :exc:" "`ItimerError`." msgstr "嘗試傳入無效的間隔計時器會導致 :exc:`ItimerError`。" -#: ../../library/signal.rst:541 +#: ../../library/signal.rst:539 +msgid "" +"Accepts any real numbers as *seconds* and *interval*, not only integers or " +"floats." +msgstr "" + +#: ../../library/signal.rst:546 msgid "Returns current value of a given interval timer specified by *which*." msgstr "回傳由 *which* 指定之間隔計時器的目前值。" -#: ../../library/signal.rst:548 +#: ../../library/signal.rst:553 msgid "" "Set the wakeup file descriptor to *fd*. When a signal your program has " "registered a signal handler for is received, the signal number is written as " @@ -732,7 +741,7 @@ msgstr "" "fd。這可被函式庫用來喚醒輪詢 (wakeup a poll) 或 select 呼叫,讓訊號得以完全處" "理。" -#: ../../library/signal.rst:555 +#: ../../library/signal.rst:560 msgid "" "The old wakeup fd is returned (or -1 if file descriptor wakeup was not " "enabled). If *fd* is -1, file descriptor wakeup is disabled. If not -1, " @@ -743,7 +752,7 @@ msgstr "" "停用檔案描述器喚醒。如果不是 -1,*fd* 必須是非阻塞的。在再次呼叫輪詢或 " "select 之前,由函式庫來決定是否移除 *fd* 中的任何位元組。" -#: ../../library/signal.rst:560 ../../library/signal.rst:615 +#: ../../library/signal.rst:565 ../../library/signal.rst:620 msgid "" "When threads are enabled, this function can only be called from :ref:`the " "main thread of the main interpreter `; attempting to " @@ -753,7 +762,7 @@ msgstr "" "當啟用執行緒時,這個函式只能從\\ :ref:`主直譯器 `\\ 的主" "執行緒來呼叫;嘗試從其他執行緒呼叫它將會引發 :exc:`ValueError` 例外。" -#: ../../library/signal.rst:565 +#: ../../library/signal.rst:570 msgid "" "There are two common ways to use this function. In both approaches, you use " "the fd to wake up when a signal arrives, but then they differ in how they " @@ -762,7 +771,7 @@ msgstr "" "使用這個函式有兩種常見的方式。在這兩種方法中,當訊號抵達時,你都要使用 fd 來" "喚醒,但它們的不同之處在於如何判斷\\ *哪個或哪些*\\ 訊號有抵達。" -#: ../../library/signal.rst:570 +#: ../../library/signal.rst:575 msgid "" "In the first approach, we read the data out of the fd's buffer, and the byte " "values give you the signal numbers. This is simple, but in rare cases it can " @@ -778,7 +787,7 @@ msgstr "" "法,那麼你應該設定 ``warn_on_full_buffer=True``,這至少會在訊號丟失時將警告印" "出到 stderr。" -#: ../../library/signal.rst:579 +#: ../../library/signal.rst:584 msgid "" "In the second approach, we use the wakeup fd *only* for wakeups, and ignore " "the actual byte values. In this case, all we care about is whether the fd's " @@ -792,15 +801,15 @@ msgstr "" "如果你使用這種方法,那麼你應該設定 ``warn_on_full_buffer=False``,這樣你的使" "用者就不會被虛假的警告訊息所混淆。" -#: ../../library/signal.rst:586 +#: ../../library/signal.rst:591 msgid "On Windows, the function now also supports socket handles." msgstr "在 Windows 上,此功能現在也支援 socket 處理程式。" -#: ../../library/signal.rst:589 +#: ../../library/signal.rst:594 msgid "Added ``warn_on_full_buffer`` parameter." msgstr "新增 ``warn_on_full_buffer`` 參數。" -#: ../../library/signal.rst:594 +#: ../../library/signal.rst:599 msgid "" "Change system call restart behaviour: if *flag* is :const:`False`, system " "calls will be restarted when interrupted by signal *signalnum*, otherwise " @@ -809,11 +818,11 @@ msgstr "" "改變系統呼叫重新啟動的行為:如果 *flag* 是 :const:`False`,系統呼叫會在被訊" "號 *signalnum* 中斷時重新啟動,否則系統呼叫會被中斷。不會回傳任何東西。" -#: ../../library/signal.rst:600 +#: ../../library/signal.rst:605 msgid "See the man page :manpage:`siginterrupt(3)` for further information." msgstr "更多資訊請見 :manpage:`siginterrupt(3)` 線上手冊。" -#: ../../library/signal.rst:602 +#: ../../library/signal.rst:607 msgid "" "Note that installing a signal handler with :func:`signal` will reset the " "restart behaviour to interruptible by implicitly calling :c:func:`!" @@ -822,7 +831,7 @@ msgstr "" "請注意,使用 :func:`signal` 安裝訊號處理程式,會透過隱式呼叫 :c:func:`!" "siginterrupt` 來將重新啟動的行為重設為可中斷,且指定訊號的 *flag* 值為 true。" -#: ../../library/signal.rst:609 +#: ../../library/signal.rst:614 msgid "" "Set the handler for signal *signalnum* to the function *handler*. *handler* " "can be a callable Python object taking two arguments (see below), or one of " @@ -836,7 +845,7 @@ msgstr "" "`signal.SIG_DFL` 之一。先前的訊號處理程式將會被回傳(請參閱上面 :func:" "`getsignal` 的說明)。(更多資訊請參閱 Unix 線上手冊 :manpage:`signal(2)`)。" -#: ../../library/signal.rst:620 +#: ../../library/signal.rst:625 msgid "" "The *handler* is called with two arguments: the signal number and the " "current stack frame (``None`` or a frame object; for a description of frame " @@ -847,7 +856,7 @@ msgstr "" "frame 物件;關於 frame 物件的描述,請參閱\\ :ref:`型別階層中的描述 `\\ 或 :mod:`inspect` 模組中的屬性描述)。" -#: ../../library/signal.rst:625 +#: ../../library/signal.rst:630 msgid "" "On Windows, :func:`signal` can only be called with :const:`SIGABRT`, :const:" "`SIGFPE`, :const:`SIGILL`, :const:`SIGINT`, :const:`SIGSEGV`, :const:" @@ -862,7 +871,7 @@ msgstr "" "有系統都定義相同的訊號名稱;如果訊號名稱沒有被定義為 ``SIG*`` 模組層級常數," "則會引發 :exc:`AttributeError` 錯誤。" -#: ../../library/signal.rst:636 +#: ../../library/signal.rst:641 msgid "" "Examine the set of signals that are pending for delivery to the calling " "thread (i.e., the signals which have been raised while blocked). Return the " @@ -871,15 +880,15 @@ msgstr "" "檢查待傳送至呼叫執行緒的訊號集合(即阻檔時已被提出的訊號)。回傳待定訊號的集" "合。" -#: ../../library/signal.rst:642 +#: ../../library/signal.rst:647 msgid "See the man page :manpage:`sigpending(2)` for further information." msgstr "更多資訊請見 :manpage:`sigpending(2)` 線上手冊。" -#: ../../library/signal.rst:644 +#: ../../library/signal.rst:649 msgid "See also :func:`pause`, :func:`pthread_sigmask` and :func:`sigwait`." msgstr "另請參閱 :func:`pause`、:func:`pthread_sigmask` 與 :func:`sigwait`。" -#: ../../library/signal.rst:651 +#: ../../library/signal.rst:656 msgid "" "Suspend execution of the calling thread until the delivery of one of the " "signals specified in the signal set *sigset*. The function accepts the " @@ -889,11 +898,11 @@ msgstr "" "暫停呼叫執行緒的執行,直到送出訊號集合 *sigset* 中指定的一個訊號。函式接受訊" "號(將其從待定訊號清單中移除),並回傳訊號編號。" -#: ../../library/signal.rst:657 +#: ../../library/signal.rst:662 msgid "See the man page :manpage:`sigwait(3)` for further information." msgstr "更多資訊請見 :manpage:`sigwait(3)` 線上手冊。" -#: ../../library/signal.rst:659 +#: ../../library/signal.rst:664 msgid "" "See also :func:`pause`, :func:`pthread_sigmask`, :func:`sigpending`, :func:" "`sigwaitinfo` and :func:`sigtimedwait`." @@ -901,7 +910,7 @@ msgstr "" "另也請見 :func:`pause`、:func:`pthread_sigmask`、:func:`sigpending`、:func:" "`sigwaitinfo` 和 :func:`sigtimedwait`。" -#: ../../library/signal.rst:667 +#: ../../library/signal.rst:672 msgid "" "Suspend execution of the calling thread until the delivery of one of the " "signals specified in the signal set *sigset*. The function accepts the " @@ -917,7 +926,7 @@ msgstr "" "會被呼叫。如果被不在 *sigset* 中的訊號中斷,函式會引發 :exc:" "`InterruptedError`。" -#: ../../library/signal.rst:676 +#: ../../library/signal.rst:681 msgid "" "The return value is an object representing the data contained in the " "``siginfo_t`` structure, namely: ``si_signo``, ``si_code``, ``si_errno``, " @@ -927,15 +936,15 @@ msgstr "" "``si_code``、``si_errno``、``si_pid``、``si_uid``、``si_status``、" "``si_band``。" -#: ../../library/signal.rst:682 +#: ../../library/signal.rst:687 msgid "See the man page :manpage:`sigwaitinfo(2)` for further information." msgstr "更多資訊請見 :manpage:`sigwaitinfo(2)` 線上手冊。" -#: ../../library/signal.rst:684 +#: ../../library/signal.rst:689 msgid "See also :func:`pause`, :func:`sigwait` and :func:`sigtimedwait`." msgstr "另請參閱 :func:`pause`、:func:`sigwait` 與 :func:`sigtimedwait`。" -#: ../../library/signal.rst:688 +#: ../../library/signal.rst:693 msgid "" "The function is now retried if interrupted by a signal not in *sigset* and " "the signal handler does not raise an exception (see :pep:`475` for the " @@ -944,7 +953,7 @@ msgstr "" "現在如果被不在 *sigset* 中的訊號中斷,且訊號處理程式沒有引發例外,則會重試函" "式(理由請參閱 :pep:`475`)。" -#: ../../library/signal.rst:696 +#: ../../library/signal.rst:701 msgid "" "Like :func:`sigwaitinfo`, but takes an additional *timeout* argument " "specifying a timeout. If *timeout* is specified as ``0``, a poll is " @@ -953,15 +962,15 @@ msgstr "" "類似 :func:`sigwaitinfo`,但需要額外的 *timeout* 引數指定逾時時間。如果 " "*timeout* 指定為 ``0``,會執行輪詢。如果發生逾時則會回傳 :const:`None`。" -#: ../../library/signal.rst:702 +#: ../../library/signal.rst:707 msgid "See the man page :manpage:`sigtimedwait(2)` for further information." msgstr "更多資訊請見 :manpage:`sigtimedwait(2)` 線上手冊。" -#: ../../library/signal.rst:704 +#: ../../library/signal.rst:709 msgid "See also :func:`pause`, :func:`sigwait` and :func:`sigwaitinfo`." msgstr "另請參閱 :func:`pause`、:func:`sigwait` 與 :func:`sigwaitinfo`。" -#: ../../library/signal.rst:708 +#: ../../library/signal.rst:713 msgid "" "The function is now retried with the recomputed *timeout* if interrupted by " "a signal not in *sigset* and the signal handler does not raise an exception " @@ -970,11 +979,15 @@ msgstr "" "現在如果被不在 *sigset* 中的訊號中斷,且訊號處理程式沒有引發例外,則會使用重" "新計算的 *timeout* 重試函式(理由請參閱 :pep:`475`)。" -#: ../../library/signal.rst:717 +#: ../../library/signal.rst:718 +msgid "Accepts any real number as *timeout*, not only integer or float." +msgstr "" + +#: ../../library/signal.rst:725 msgid "Examples" msgstr "範例" -#: ../../library/signal.rst:719 +#: ../../library/signal.rst:727 msgid "" "Here is a minimal example program. It uses the :func:`alarm` function to " "limit the time spent waiting to open a file; this is useful if the file is " @@ -988,7 +1001,7 @@ msgstr "" "無限期地被擱置。解決方法是在開啟檔案前設定一個 5 秒的警報;如果操作時間過長," "警報訊號就會被送出,而處理程式會產生例外。 ::" -#: ../../library/signal.rst:726 +#: ../../library/signal.rst:734 msgid "" "import signal, os\n" "\n" @@ -1022,11 +1035,11 @@ msgstr "" "\n" "signal.alarm(0) # 停用警報" -#: ../../library/signal.rst:743 +#: ../../library/signal.rst:751 msgid "Note on SIGPIPE" msgstr "關於 SIGPIPE 的說明" -#: ../../library/signal.rst:745 +#: ../../library/signal.rst:753 msgid "" "Piping output of your program to tools like :manpage:`head(1)` will cause a :" "const:`SIGPIPE` signal to be sent to your process when the receiver of its " @@ -1039,7 +1052,7 @@ msgstr "" "`BrokenPipeError: [Errno 32] Broken pipe` 的例外。要處理這種情況,請將你的進" "入點包裝成如下的樣子來捕捉這個例外: ::" -#: ../../library/signal.rst:751 +#: ../../library/signal.rst:759 msgid "" "import os\n" "import sys\n" @@ -1084,7 +1097,7 @@ msgstr "" "if __name__ == '__main__':\n" " main()" -#: ../../library/signal.rst:772 +#: ../../library/signal.rst:780 msgid "" "Do not set :const:`SIGPIPE`'s disposition to :const:`SIG_DFL` in order to " "avoid :exc:`BrokenPipeError`. Doing that would cause your program to exit " @@ -1095,11 +1108,11 @@ msgstr "" "(disposition) 設定為 :const:`SIG_DFL`。這樣做會導致你的程式在寫入任何 socket " "連線時被中斷而意外退出。" -#: ../../library/signal.rst:781 +#: ../../library/signal.rst:789 msgid "Note on Signal Handlers and Exceptions" msgstr "訊號處理程式與例外的說明" -#: ../../library/signal.rst:783 +#: ../../library/signal.rst:791 msgid "" "If a signal handler raises an exception, the exception will be propagated to " "the main thread and may be raised after any :term:`bytecode` instruction. " @@ -1115,11 +1128,11 @@ msgstr "" "exc:`KeyboardInterrupt`\\ (或任何其他由訊號處理程式產生的例外)可能會在罕見" "的情況下使程式處於預期之外的狀態。" -#: ../../library/signal.rst:790 +#: ../../library/signal.rst:798 msgid "To illustrate this issue, consider the following code::" msgstr "為了說明這個問題,請參考以下程式碼: ::" -#: ../../library/signal.rst:792 +#: ../../library/signal.rst:800 msgid "" "class SpamContext:\n" " def __init__(self):\n" @@ -1151,7 +1164,7 @@ msgstr "" " ...\n" " self.lock.release()" -#: ../../library/signal.rst:807 +#: ../../library/signal.rst:815 msgid "" "For many programs, especially those that merely want to exit on :exc:" "`KeyboardInterrupt`, this is not a problem, but applications that are " @@ -1168,7 +1181,7 @@ msgstr "" "`SIGINT` 處理程式。以下是 HTTP 伺服器避免 :exc:`KeyboardInterrupt` 的範" "例: ::" -#: ../../library/signal.rst:815 +#: ../../library/signal.rst:823 msgid "" "import signal\n" "import socket\n" diff --git a/library/site.po b/library/site.po index 3493944b0f6..76c0b48a00c 100644 --- a/library/site.po +++ b/library/site.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-31 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:10+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -37,7 +37,7 @@ msgid "" "Importing this module normally appends site-specific paths to the module " "search path and adds :ref:`callables `, including :func:`help` " "to the built-in namespace. However, Python startup option :option:`-S` " -"blocks this and this module can be safely imported with no automatic " +"blocks this, and this module can be safely imported with no automatic " "modifications to the module search path or additions to the builtins. To " "explicitly trigger the usual site-specific additions, call the :func:`main` " "function." @@ -90,50 +90,166 @@ msgid "" "environments>`, the ``pyvenv.cfg`` file in :data:`sys.prefix` is checked for " "site-specific configurations. If the ``include-system-site-packages`` key " "exists and is set to ``true`` (case-insensitive), the system-level prefixes " -"will be searched for site-packages, otherwise they won't." +"will be searched for site-packages, otherwise they won't. If the system-" +"level prefixes are not searched then the user site prefixes are also " +"implicitly not searched for site-packages." msgstr "" -#: ../../library/site.rst:73 +#: ../../library/site.rst:74 msgid "" -"A path configuration file is a file whose name has the form :file:`{name}." -"pth` and exists in one of the four directories mentioned above; its contents " -"are additional items (one per line) to be added to ``sys.path``. Non-" -"existing items are never added to ``sys.path``, and no check is made that " -"the item refers to a directory rather than a file. No item is added to " -"``sys.path`` more than once. Blank lines and lines beginning with ``#`` are " -"skipped. Lines starting with ``import`` (followed by space or tab) are " -"executed." +"The :mod:`!site` module recognizes two startup configuration files of the " +"form :file:`{name}.pth` for path configurations, and :file:`{name}.start` " +"for pre-first-line code execution. Both files can exist in one of the four " +"directories mentioned above. Within each directory, these files are sorted " +"alphabetically by filename, then parsed in sorted order." msgstr "" #: ../../library/site.rst:83 +msgid "Path extensions (:file:`.pth` files)" +msgstr "" + +#: ../../library/site.rst:85 +msgid "" +":file:`{name}.pth` contains additional items (one per line) to be appended " +"to ``sys.path``. Items that name non-existing directories are never added " +"to ``sys.path``, and no check is made that the item refers to a directory " +"rather than a file. No item is added to ``sys.path`` more than once. Blank " +"lines and lines beginning with ``#`` are skipped." +msgstr "" + +#: ../../library/site.rst:91 msgid "" -"An executable line in a :file:`.pth` file is run at every Python startup, " -"regardless of whether a particular module is actually going to be used. Its " -"impact should thus be kept to a minimum. The primary intended purpose of " -"executable lines is to make the corresponding module(s) importable (load 3rd-" -"party import hooks, adjust :envvar:`PATH` etc). Any other initialization is " -"supposed to be done upon a module's actual import, if and when it happens. " -"Limiting a code chunk to a single line is a deliberate measure to discourage " -"putting anything more complex here." +"For backward compatibility, lines starting with ``import`` (followed by " +"space or tab) are executed with :func:`exec`." msgstr "" -#: ../../library/site.rst:94 +#: ../../library/site.rst:96 msgid "" "The :file:`.pth` files are now decoded by UTF-8 at first and then by the :" "term:`locale encoding` if it fails." msgstr "" -#: ../../library/site.rst:102 +#: ../../library/site.rst:101 +msgid "" +":file:`.pth` file lines starting with ``import`` are deprecated. During the " +"deprecation period, such lines are still executed (except in the case " +"below), but a diagnostic message is emitted only when the :option:`-v` flag " +"is given." +msgstr "" + +#: ../../library/site.rst:106 +msgid "" +"``import`` lines in :file:`{name}.pth` are silently ignored when a :ref:" +"`matching ` :file:`{name}.start` file exists." +msgstr "" + +#: ../../library/site.rst:109 +msgid "" +"Errors on individual lines no longer abort processing of the rest of the " +"file. Each error is reported and the remaining lines continue to be " +"processed." +msgstr "" + +#: ../../library/site.rst:115 +msgid "" +"Decoding :file:`{name}.pth` files in any encoding other than ``utf-8-sig`` " +"is deprecated in Python 3.15, and support for decoding from the locale " +"encoding will be removed in Python 3.20." +msgstr "" + +#: ../../library/site.rst:119 +msgid "" +"``import`` lines in :file:`{name}.pth` files are deprecated and will be " +"silently ignored in Python 3.18 and 3.19. In Python 3.20 a warning will be " +"produced for ``import`` lines in :file:`{name}.pth` files." +msgstr "" + +#: ../../library/site.rst:127 +msgid "Startup entry points (:file:`.start` files)" +msgstr "" + +#: ../../library/site.rst:131 +msgid "" +"A startup entry point file is a file whose name has the form :file:`{name}." +"start` and exists in one of the site-packages directories described above. " +"Each file specifies entry points to be called during interpreter startup, " +"using the ``pkg.mod:callable`` syntax understood by :func:`pkgutil." +"resolve_name`." +msgstr "" + +#: ../../library/site.rst:137 +msgid "" +"Each non-blank line that does not begin with ``#`` must contain an entry " +"point reference in the form ``pkg.mod:callable``. The colon and callable " +"portion are mandatory. Each callable is invoked with no arguments, and any " +"return value is discarded." +msgstr "" + +#: ../../library/site.rst:142 +msgid "" +":file:`.start` files are processed after all :file:`.pth` path extensions " +"have been applied to :data:`sys.path`, ensuring that paths are available " +"before any startup code runs." +msgstr "" + +#: ../../library/site.rst:146 +msgid "" +"Unlike :data:`sys.path` extensions from :file:`.pth` files, duplicate entry " +"points are **not** de-duplicated --- if an entry point appears more than " +"once, it will be called more than once." +msgstr "" + +#: ../../library/site.rst:150 +msgid "" +"If an exception occurs during resolution or invocation of an entry point, a " +"traceback is printed to :data:`sys.stderr` and processing continues with the " +"remaining entry points." +msgstr "" + +#: ../../library/site.rst:154 +msgid ":file:`.start` files must be encoded in UTF-8." +msgstr "" + +#: ../../library/site.rst:156 +msgid ":pep:`829` defined the original specification for these features." +msgstr "" + +#: ../../library/site.rst:160 +msgid "" +"If a :file:`{name}.start` file exists alongside a :file:`{name}.pth` file " +"with the same base name, any ``import`` lines in the :file:`.pth` file are " +"ignored in favor of the entry points in the :file:`.start` file." +msgstr "" + +#: ../../library/site.rst:166 +msgid "" +"Executable lines (``import`` lines in :file:`{name}.pth` files and :file:" +"`{name}.start` file entry points) are always run at Python startup (unless :" +"option:`-S` is given to disable the ``site.py`` module entirely), regardless " +"of whether a particular module is actually going to be used." +msgstr "" + +#: ../../library/site.rst:173 +msgid "" +":file:`{name}.start` files invoke :func:`pkgutil.resolve_name` with " +"``strict=True``, which requires the full ``pkg.mod:callable`` form." +msgstr "" + +#: ../../library/site.rst:182 +msgid "Startup file examples" +msgstr "" + +#: ../../library/site.rst:184 msgid "" "For example, suppose ``sys.prefix`` and ``sys.exec_prefix`` are set to :file:" "`/usr/local`. The Python X.Y library is then installed in :file:`/usr/local/" "lib/python{X.Y}`. Suppose this has a subdirectory :file:`/usr/local/lib/" -"python{X.Y}/site-packages` with three subsubdirectories, :file:`foo`, :file:" +"python{X.Y}/site-packages` with three sub-subdirectories, :file:`foo`, :file:" "`bar` and :file:`spam`, and two path configuration files, :file:`foo.pth` " "and :file:`bar.pth`. Assume :file:`foo.pth` contains the following::" msgstr "" -#: ../../library/site.rst:110 +#: ../../library/site.rst:192 msgid "" "# foo package configuration\n" "\n" @@ -142,24 +258,24 @@ msgid "" "bletch" msgstr "" -#: ../../library/site.rst:116 +#: ../../library/site.rst:198 msgid "and :file:`bar.pth` contains::" msgstr "" -#: ../../library/site.rst:118 +#: ../../library/site.rst:200 msgid "" "# bar package configuration\n" "\n" "bar" msgstr "" -#: ../../library/site.rst:122 +#: ../../library/site.rst:204 msgid "" "Then the following version-specific directories are added to ``sys.path``, " "in this order::" msgstr "" -#: ../../library/site.rst:125 +#: ../../library/site.rst:207 msgid "" "/usr/local/lib/pythonX.Y/site-packages/bar\n" "/usr/local/lib/pythonX.Y/site-packages/foo" @@ -167,7 +283,7 @@ msgstr "" "/usr/local/lib/pythonX.Y/site-packages/bar\n" "/usr/local/lib/pythonX.Y/site-packages/foo" -#: ../../library/site.rst:128 +#: ../../library/site.rst:210 msgid "" "Note that :file:`bletch` is omitted because it doesn't exist; the :file:" "`bar` directory precedes the :file:`foo` directory because :file:`bar.pth` " @@ -175,11 +291,71 @@ msgid "" "because it is not mentioned in either path configuration file." msgstr "" -#: ../../library/site.rst:134 +#: ../../library/site.rst:215 +msgid "" +"Let's say that there is also a :file:`foo.start` file containing the " +"following::" +msgstr "" + +#: ../../library/site.rst:218 +msgid "" +"# foo package startup code\n" +"\n" +"foo.submod:initialize" +msgstr "" +"# foo 套件啟動程式碼\n" +"\n" +"foo.submod:initialize" + +#: ../../library/site.rst:222 +msgid "" +"Now, after ``sys.path`` has been extended as above, and before Python turns " +"control over to user code, the ``foo.submod`` module is imported and the " +"``initialize()`` function from that module is called." +msgstr "" + +#: ../../library/site.rst:230 +msgid "Migrating from ``import`` lines in ``.pth`` files to ``.start`` files" +msgstr "" + +#: ../../library/site.rst:232 +msgid "" +"If your package currently ships a :file:`{name}.pth` file, you can keep all " +"``sys.path`` extension lines unchanged. Only ``import`` lines need to be " +"migrated." +msgstr "" + +#: ../../library/site.rst:236 +msgid "" +"To migrate, create a callable (taking zero arguments) within an importable " +"module in your package. Reference it as a ``pkg.mod:callable`` entry point " +"in a matching :file:`{name}.start` file. Move everything on your ``import`` " +"line after the first semi-colon into the ``callable()`` function." +msgstr "" + +#: ../../library/site.rst:241 +msgid "" +"If your package must straddle older Pythons that do not support :pep:`829` " +"and newer Pythons that do, change the ``import`` lines in your :file:`{name}." +"pth` to use the following form:" +msgstr "" + +#: ../../library/site.rst:245 +msgid "import pkg.mod; pkg.mod.callable()" +msgstr "import pkg.mod; pkg.mod.callable()" + +#: ../../library/site.rst:249 +msgid "" +"Older Pythons will execute these ``import`` lines, while newer Pythons will " +"ignore them in favor of the :file:`{name}.start` file. After the straddling " +"period, remove all ``import`` lines from your :file:`.pth` files." +msgstr "" + +#: ../../library/site.rst:255 msgid ":mod:`!sitecustomize`" msgstr ":mod:`!sitecustomize`" -#: ../../library/site.rst:138 +#: ../../library/site.rst:259 msgid "" "After these path manipulations, an attempt is made to import a module named :" "mod:`!sitecustomize`, which can perform arbitrary site-specific " @@ -193,11 +369,11 @@ msgid "" "perhaps mysterious failure of the process." msgstr "" -#: ../../library/site.rst:150 +#: ../../library/site.rst:271 msgid ":mod:`!usercustomize`" msgstr ":mod:`!usercustomize`" -#: ../../library/site.rst:154 +#: ../../library/site.rst:275 msgid "" "After this, an attempt is made to import a module named :mod:`!" "usercustomize`, which can perform arbitrary user-specific customizations, " @@ -209,18 +385,18 @@ msgid "" "ignored." msgstr "" -#: ../../library/site.rst:162 +#: ../../library/site.rst:283 msgid "" "Note that for some non-Unix systems, ``sys.prefix`` and ``sys.exec_prefix`` " "are empty, and the path manipulations are skipped; however the import of :" "mod:`sitecustomize` and :mod:`!usercustomize` is still attempted." msgstr "" -#: ../../library/site.rst:171 +#: ../../library/site.rst:292 msgid "Readline configuration" msgstr "" -#: ../../library/site.rst:173 +#: ../../library/site.rst:294 msgid "" "On systems that support :mod:`readline`, this module will also import and " "configure the :mod:`rlcompleter` module, if Python is started in :ref:" @@ -232,19 +408,19 @@ msgid "" "`PYTHONSTARTUP` file." msgstr "" -#: ../../library/site.rst:182 +#: ../../library/site.rst:303 msgid "Activation of rlcompleter and history was made automatic." msgstr "" -#: ../../library/site.rst:187 +#: ../../library/site.rst:308 msgid "Module contents" msgstr "模組內容" -#: ../../library/site.rst:191 +#: ../../library/site.rst:312 msgid "A list of prefixes for site-packages directories." msgstr "" -#: ../../library/site.rst:196 +#: ../../library/site.rst:317 msgid "" "Flag showing the status of the user site-packages directory. ``True`` means " "that it is enabled and was added to ``sys.path``. ``False`` means that it " @@ -253,7 +429,7 @@ msgid "" "(mismatch between user or group id and effective id) or by an administrator." msgstr "" -#: ../../library/site.rst:206 +#: ../../library/site.rst:327 msgid "" "Path to the user site-packages for the running Python. Can be ``None`` if :" "func:`getusersitepackages` hasn't been called yet. Default value is :file:" @@ -265,7 +441,7 @@ msgid "" "files in it will be processed." msgstr "" -#: ../../library/site.rst:218 +#: ../../library/site.rst:339 msgid "" "Path to the base directory for the user site-packages. Can be ``None`` if :" "func:`getuserbase` hasn't been called yet. Default value is :file:`~/." @@ -276,28 +452,136 @@ msgid "" "scheme `. See also :envvar:`PYTHONUSERBASE`." msgstr "" -#: ../../library/site.rst:230 +#: ../../library/site.rst:351 msgid "" "Adds all the standard site-specific directories to the module search path. " "This function is called automatically when this module is imported, unless " "the Python interpreter was started with the :option:`-S` flag." msgstr "" -#: ../../library/site.rst:234 +#: ../../library/site.rst:355 msgid "This function used to be called unconditionally." msgstr "" -#: ../../library/site.rst:240 +#: ../../library/site.rst:361 msgid "" -"Add a directory to sys.path and process its :file:`.pth` files. Typically " -"used in :mod:`sitecustomize` or :mod:`usercustomize` (see above)." +"Join *paths* with :func:`os.path.join`, attempt to make the result absolute " +"with :func:`os.path.abspath`, and return a 2-tuple containing the absolute " +"path and its case-normalized form as produced by :func:`os.path.normcase`. " +"If :func:`os.path.abspath` raises :exc:`OSError`, the joined path is used " +"unchanged for the case-normalization step." msgstr "" -#: ../../library/site.rst:246 +#: ../../library/site.rst:368 +msgid "" +"The second element of the returned tuple is the form used throughout the :" +"mod:`!site` module to compare paths on case-insensitive file systems, and is " +"what populates the ``known_paths`` sets that prevent duplicate :data:`sys." +"path` entries in various APIs within this module." +msgstr "" + +#: ../../library/site.rst:376 +msgid "" +"Instances of this class accumulate interpreter startup configuration data " +"from one or more site directories. They are the preferred interface for " +"batching the processing of :file:`.pth` and :file:`.start` files across " +"multiple site directories, so that every :data:`sys.path` extension is " +"visible before any startup code runs." +msgstr "" + +#: ../../library/site.rst:382 +msgid "" +"The optional *known_paths* argument is a set of case-normalized paths (which " +"can be produced by :func:`makepath`) used to prevent duplicate :data:`sys." +"path` entries. When ``None`` (the default), the set is built from the " +"current :data:`sys.path`. :func:`main` implicitly uses an instance of this " +"class." +msgstr "" + +#: ../../library/site.rst:388 +msgid "Typical use:" +msgstr "" + +#: ../../library/site.rst:390 +msgid "" +"state = site.StartupState()\n" +"for sitedir in site_dirs:\n" +" state.addsitedir(sitedir)\n" +"state.process()" +msgstr "" +"state = site.StartupState()\n" +"for sitedir in site_dirs:\n" +" state.addsitedir(sitedir)\n" +"state.process()" + +#: ../../library/site.rst:401 +msgid "" +"Read the :file:`.pth` and :file:`.start` files in *sitedir* and record " +"their :data:`sys.path` extensions, deprecated :file:`.pth` ``import`` lines, " +"and :file:`.start` entry points on this state. The recorded data is not " +"applied until :meth:`process` is called." +msgstr "" + +#: ../../library/site.rst:408 +msgid "" +"Add the per-user site-packages directory, if enabled and if it exists. The " +"directory's startup data is accumulated for later processing by :meth:" +"`process`." +msgstr "" + +#: ../../library/site.rst:414 +msgid "" +"Add global site-packages directories, computed from *prefixes* or from the " +"global :data:`PREFIXES` when *prefixes* is ``None``. Each directory's " +"startup data is accumulated for later processing by :meth:`process`." +msgstr "" + +#: ../../library/site.rst:421 +msgid "" +"Apply the accumulated state by first adding the path extensions to :data:" +"`sys.path`, then executing the :file:`.start` file entry points and :file:`." +"pth` file ``import`` lines (:ref:`deprecated `)." +msgstr "" + +#: ../../library/site.rst:426 +msgid "" +"This method is not idempotent and must not be called more than once on the " +"same instance. Doing so will apply the accumulated state more than once, re-" +"running entry points and ``import`` lines." +msgstr "" + +#: ../../library/site.rst:433 +msgid "" +"Add a directory to sys.path and parse the :file:`.pth` and :file:`.start` " +"files found in that directory. Typically used in :mod:`sitecustomize` or :" +"mod:`usercustomize` (see above)." +msgstr "" + +#: ../../library/site.rst:437 +msgid "" +"The *known_paths* argument is an optional set of case-normalized paths used " +"to prevent duplicate :data:`sys.path` entries. When ``None`` (the default), " +"the set is built from the current :data:`sys.path`." +msgstr "" + +#: ../../library/site.rst:441 +msgid "" +"For batched processing across multiple site directories, build a :class:" +"`StartupState` explicitly and call :meth:`StartupState.addsitedir` on it; " +"that defers :file:`.pth` and :file:`.start` processing until a single :meth:" +"`StartupState.process` call, ensuring every :data:`sys.path` extension is " +"visible before any startup code runs." +msgstr "" + +#: ../../library/site.rst:449 +msgid "Also processes :file:`.start` files. See :ref:`site-start-files`." +msgstr "" + +#: ../../library/site.rst:454 msgid "Return a list containing all global site-packages directories." msgstr "" -#: ../../library/site.rst:248 +#: ../../library/site.rst:456 msgid "" "For each directory given in *prefixes* (or :data:`PREFIXES` if *prefixes* is " "``None``), this function will compute its site-packages subdirectory " @@ -305,18 +589,18 @@ msgid "" "which are not checked for existence." msgstr "" -#: ../../library/site.rst:255 +#: ../../library/site.rst:463 msgid "Added the optional *prefixes* parameter." msgstr "" -#: ../../library/site.rst:261 +#: ../../library/site.rst:469 msgid "" "Return the path of the user base directory, :data:`USER_BASE`. If it is not " "initialized yet, this function will also set it, respecting :envvar:" "`PYTHONUSERBASE`." msgstr "" -#: ../../library/site.rst:270 +#: ../../library/site.rst:478 msgid "" "Return the path of the user-specific site-packages directory, :data:" "`USER_SITE`. If it is not initialized yet, this function will also set it, " @@ -324,17 +608,17 @@ msgid "" "packages was added to ``sys.path`` :data:`ENABLE_USER_SITE` should be used." msgstr "" -#: ../../library/site.rst:282 +#: ../../library/site.rst:490 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/site.rst:286 +#: ../../library/site.rst:494 msgid "" "The :mod:`!site` module also provides a way to get the user directories from " "the command line:" msgstr "" -#: ../../library/site.rst:289 +#: ../../library/site.rst:497 msgid "" "$ python -m site --user-site\n" "/home/user/.local/lib/python3.11/site-packages" @@ -342,7 +626,7 @@ msgstr "" "$ python -m site --user-site\n" "/home/user/.local/lib/python3.11/site-packages" -#: ../../library/site.rst:294 +#: ../../library/site.rst:502 msgid "" "If it is called without arguments, it will print the contents of :data:`sys." "path` on the standard output, followed by the value of :data:`USER_BASE` and " @@ -350,21 +634,21 @@ msgid "" "finally the value of :data:`ENABLE_USER_SITE`." msgstr "" -#: ../../library/site.rst:301 +#: ../../library/site.rst:509 msgid "Print the path to the user base directory." msgstr "" -#: ../../library/site.rst:305 +#: ../../library/site.rst:513 msgid "Print the path to the user site-packages directory." msgstr "" -#: ../../library/site.rst:307 +#: ../../library/site.rst:515 msgid "" "If both options are given, user base and user site will be printed (always " "in this order), separated by :data:`os.pathsep`." msgstr "" -#: ../../library/site.rst:310 +#: ../../library/site.rst:518 msgid "" "If any option is given, the script will exit with one of these values: ``0`` " "if the user site-packages directory is enabled, ``1`` if it was disabled by " @@ -372,11 +656,17 @@ msgid "" "administrator, and a value greater than 2 if there is an error." msgstr "" -#: ../../library/site.rst:317 +#: ../../library/site.rst:525 msgid ":pep:`370` -- Per user site-packages directory" msgstr "" -#: ../../library/site.rst:318 +#: ../../library/site.rst:526 +msgid "" +":pep:`829` -- Startup entry points and the deprecation of import lines in ``." +"pth`` files" +msgstr "" + +#: ../../library/site.rst:527 msgid ":ref:`sys-path-init` -- The initialization of :data:`sys.path`." msgstr ":ref:`sys-path-init` -- :data:`sys.path` 的初始化。" @@ -388,7 +678,7 @@ msgstr "module(模組)" msgid "search" msgstr "search(搜尋)" -#: ../../library/site.rst:16 ../../library/site.rst:98 +#: ../../library/site.rst:16 ../../library/site.rst:176 msgid "path" msgstr "path(路徑)" @@ -400,30 +690,30 @@ msgstr "site-packages" msgid "directory" msgstr "directory(目錄)" -#: ../../library/site.rst:69 +#: ../../library/site.rst:70 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/site.rst:69 +#: ../../library/site.rst:70 msgid "comment" msgstr "comment(註解)" -#: ../../library/site.rst:69 +#: ../../library/site.rst:70 msgid "statement" msgstr "statement(陳述式)" -#: ../../library/site.rst:69 +#: ../../library/site.rst:70 msgid "import" msgstr "import(引入)" -#: ../../library/site.rst:98 +#: ../../library/site.rst:176 msgid "package" msgstr "package(套件)" -#: ../../library/site.rst:98 +#: ../../library/site.rst:176 msgid "configuration" msgstr "configuration(設定)" -#: ../../library/site.rst:98 +#: ../../library/site.rst:176 msgid "file" msgstr "file(檔案)" diff --git a/library/smtplib.po b/library/smtplib.po index 1d8bf56c5c3..8aff2a47c6b 100644 --- a/library/smtplib.po +++ b/library/smtplib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:10+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!smtplib` --- SMTP protocol client" msgstr ":mod:`!smtplib` --- SMTP 協定用戶端" -#: ../../library/smtplib.rst:9 +#: ../../library/smtplib.rst:7 msgid "**Source code:** :source:`Lib/smtplib.py`" msgstr "**原始碼:**\\ :source:`Lib/smtplib.py`" -#: ../../library/smtplib.rst:17 +#: ../../library/smtplib.rst:15 msgid "" "The :mod:`!smtplib` module defines an SMTP client session object that can be " "used to send mail to any internet machine with an SMTP or ESMTP listener " @@ -49,39 +49,46 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/smtplib.rst:26 +#: ../../library/smtplib.rst:24 msgid "" "An :class:`SMTP` instance encapsulates an SMTP connection. It has methods " -"that support a full repertoire of SMTP and ESMTP operations. If the optional " -"*host* and *port* parameters are given, the SMTP :meth:`connect` method is " -"called with those parameters during initialization. If specified, " -"*local_hostname* is used as the FQDN of the local host in the HELO/EHLO " -"command. Otherwise, the local hostname is found using :func:`socket." -"getfqdn`. If the :meth:`connect` call returns anything other than a success " -"code, an :exc:`SMTPConnectError` is raised. The optional *timeout* parameter " -"specifies a timeout in seconds for blocking operations like the connection " -"attempt (if not specified, the global default timeout setting will be " -"used). If the timeout expires, :exc:`TimeoutError` is raised. The optional " -"*source_address* parameter allows binding to some specific source address in " -"a machine with multiple network interfaces, and/or to some specific source " -"TCP port. It takes a 2-tuple ``(host, port)``, for the socket to bind to as " -"its source address before connecting. If omitted (or if *host* or *port* are " -"``''`` and/or ``0`` respectively) the OS default behavior will be used." -msgstr "" -":class:`SMTP` 實例封裝了一個 SMTP 連線。它擁有支援完整 SMTP 和 ESMTP 操作的各" -"種方法。如果有給定選用的 *host* 和 *port* 參數,初始化期間會以這些參數呼叫 " -"SMTP 的 :meth:`connect` 方法。如果有指定 *local_hostname*,則會將其用作 HELO/" -"EHLO 指令中本地主機的 FQDN。否則,會使用 :func:`socket.getfqdn` 來尋找本地主" -"機名稱。如果 :meth:`connect` 呼叫回傳的不是成功碼,則會引" -"發 :exc:`SMTPConnectError`。選用的 *timeout* 參數會以秒為單位指定阻塞操作(例" -"如連線嘗試)的逾時時間(如果未指定,則會使用全域預設的逾時設定)。如果逾時," -"則會引發 :exc:`TimeoutError`。選用的 *source_address* 參數允許在具有多個網路" -"介面的機器中綁定到某個特定的來源位址,和/或綁定到某個特定的來源 TCP 連接埠。" -"它接受一個 2-tuple ``(host, port)``,供 socket 在連線前綁定為其來源位址。如果" -"省略(或者 *host* 或 *port* 分別為 ``''`` 和/或 ``0``),則會使用作業系統的預" -"設行為。" - -#: ../../library/smtplib.rst:44 +"that support a full repertoire of SMTP and ESMTP operations." +msgstr "" + +#: ../../library/smtplib.rst:27 +msgid "" +"If the host parameter is set to a truthy value, :meth:`SMTP.connect` is " +"called with host and port automatically when the object is created; " +"otherwise, :meth:`!connect` must be called manually." +msgstr "" + +#: ../../library/smtplib.rst:31 +msgid "" +"If specified, *local_hostname* is used as the FQDN of the local host in the " +"HELO/EHLO command. Otherwise, the local hostname is found using :func:" +"`socket.getfqdn`. If the :meth:`connect` call returns anything other than a " +"success code, an :exc:`SMTPConnectError` is raised. The optional *timeout* " +"parameter specifies a timeout in seconds for blocking operations like the " +"connection attempt (if not specified, the global default timeout setting " +"will be used). If the timeout expires, :exc:`TimeoutError` is raised. The " +"optional *source_address* parameter allows binding to some specific source " +"address in a machine with multiple network interfaces, and/or to some " +"specific source TCP port. It takes a 2-tuple ``(host, port)``, for the " +"socket to bind to as its source address before connecting. If omitted (or if " +"*host* or *port* are ``''`` and/or ``0`` respectively) the OS default " +"behavior will be used." +msgstr "" +"如果有指定 *local_hostname*,則會將其用作 HELO/EHLO 指令中本地主機的 FQDN。否" +"則,會使用 :func:`socket.getfqdn` 來尋找本地主機名稱。如果 :meth:`connect` 呼" +"叫回傳的不是成功碼,則會引發 :exc:`SMTPConnectError`。選用的 *timeout* 參數會" +"以秒為單位指定阻塞操作(例如連線嘗試)的逾時時間(如果未指定,則會使用全域預" +"設的逾時設定)。如果逾時,則會引發 :exc:`TimeoutError`。選用的 " +"*source_address* 參數允許在具有多個網路介面的機器中綁定到某個特定的來源位址," +"和/或綁定到某個特定的來源 TCP 連接埠。它接受一個 2-tuple ``(host, port)``," +"供 socket 在連線前綁定為其來源位址。如果省略(或者 *host* 或 *port* 分別為 " +"``''`` 和/或 ``0``),則會使用作業系統的預設行為。" + +#: ../../library/smtplib.rst:45 msgid "" "For normal use, you should only require the initialization/connect, :meth:" "`sendmail`, and :meth:`SMTP.quit` methods. An example is included below." @@ -89,7 +96,7 @@ msgstr "" "一般使用上,你應該只會需要初始化/連線、:meth:`sendmail` 和 :meth:`SMTP.quit` " "等方法。以下附上一個範例。" -#: ../../library/smtplib.rst:48 +#: ../../library/smtplib.rst:49 msgid "" "The :class:`SMTP` class supports the :keyword:`with` statement. When used " "like this, the SMTP ``QUIT`` command is issued automatically when the :" @@ -98,7 +105,7 @@ msgstr "" ":class:`SMTP` 類別支援 :keyword:`with` 陳述式。當這樣使用時,在 :keyword:`!" "with` 陳述式結束時會自動發出 SMTP ``QUIT`` 指令。例如: ::" -#: ../../library/smtplib.rst:52 +#: ../../library/smtplib.rst:53 msgid "" ">>> from smtplib import SMTP\n" ">>> with SMTP(\"domain.org\") as smtp:\n" @@ -114,7 +121,7 @@ msgstr "" "(250, b'Ok')\n" ">>>" -#: ../../library/smtplib.rst:59 ../../library/smtplib.rst:61 +#: ../../library/smtplib.rst:60 ../../library/smtplib.rst:62 msgid "" "All commands will raise an :ref:`auditing event ` ``smtplib.SMTP." "send`` with arguments ``self`` and ``data``, where ``data`` is the bytes " @@ -123,19 +130,23 @@ msgstr "" "所有指令都會引發一個附帶引數 ``self``、``data`` 的\\ :ref:`稽核事件 " "` ``smtplib.SMTP.send``,其中 ``data`` 為即將傳送至遠端的位元組。" -#: ../../library/smtplib.rst:65 +#: ../../library/smtplib.rst:68 +msgid "The default port used for SMTP connections (25)." +msgstr "" + +#: ../../library/smtplib.rst:70 msgid "Support for the :keyword:`with` statement was added." msgstr "新增對 :keyword:`with` 陳述式的支援。" -#: ../../library/smtplib.rst:68 +#: ../../library/smtplib.rst:73 msgid "*source_address* argument was added." msgstr "新增 source_address 引數。" -#: ../../library/smtplib.rst:71 +#: ../../library/smtplib.rst:76 msgid "The SMTPUTF8 extension (:rfc:`6531`) is now supported." msgstr "現在支援 SMTPUTF8 擴充(:rfc:`6531`)。" -#: ../../library/smtplib.rst:74 +#: ../../library/smtplib.rst:79 msgid "" "If the *timeout* parameter is set to be zero, it will raise a :class:" "`ValueError` to prevent the creation of a non-blocking socket." @@ -143,36 +154,47 @@ msgstr "" "如果 *timeout* 參數被設為零,則會引發 :class:`ValueError`,以防止建立非阻塞" "的 socket。" -#: ../../library/smtplib.rst:81 +#: ../../library/smtplib.rst:86 msgid "" "An :class:`SMTP_SSL` instance behaves exactly the same as instances of :" "class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is " -"required from the beginning of the connection and using :meth:`~SMTP." -"starttls` is not appropriate. If *host* is not specified, the local host is " -"used. If *port* is zero, the standard SMTP-over-SSL port (465) is used. The " -"optional arguments *local_hostname*, *timeout* and *source_address* have the " -"same meaning as they do in the :class:`SMTP` class. *context*, also " +"required from the beginning of the connection and using :meth:`SMTP." +"starttls` is not appropriate." +msgstr "" + +#: ../../library/smtplib.rst:91 +msgid "" +"If the host parameter is set to a truthy value, :meth:`SMTP.connect` is " +"called with host and port automatically when the object is created; " +"otherwise, :meth:`!SMTP.connect` must be called manually." +msgstr "" + +#: ../../library/smtplib.rst:95 +msgid "" +"The optional arguments *local_hostname*, *timeout* and *source_address* have " +"the same meaning as they do in the :class:`SMTP` class. *context*, also " "optional, can contain a :class:`~ssl.SSLContext` and allows configuring " "various aspects of the secure connection. Please read :ref:`ssl-security` " "for best practices." msgstr "" -":class:`SMTP_SSL` 實例的行為與 :class:`SMTP` 的實例完全相" -"同。:class:`SMTP_SSL` 應該用於從連線一開始就需要 SSL、且不適合使" -"用 :meth:`~SMTP.starttls` 的情況。如果未指定 *host*,則會使用本地主機。如果 " -"*port* 為零,則會使用標準的 SMTP-over-SSL 連接埠(465)。選用引數 " -"*local_hostname*、*timeout* 和 *source_address* 的意義與它們在 :class:`SMTP` " -"類別中的相同。同樣為選用的 *context* 可以包含一個 :class:`~ssl.SSLContext`," -"並允許設定安全連線的各個面向。最佳做法請參閱 :ref:`ssl-security`。" +"選用引數 *local_hostname*、*timeout* 和 *source_address* 的意義與它們" +"在 :class:`SMTP` 類別中的相同。同樣為選用的 *context* 可以包含一" +"個 :class:`~ssl.SSLContext`,並允許設定安全連線的各個面向。最佳做法請參" +"閱 :ref:`ssl-security`。" -#: ../../library/smtplib.rst:92 ../../library/smtplib.rst:424 +#: ../../library/smtplib.rst:103 +msgid "The default port used for SMTP-over-SSL connections (465)." +msgstr "" + +#: ../../library/smtplib.rst:105 ../../library/smtplib.rst:440 msgid "*context* was added." msgstr "新增 *context*。" -#: ../../library/smtplib.rst:95 +#: ../../library/smtplib.rst:108 msgid "The *source_address* argument was added." msgstr "新增 *source_address* 引數。" -#: ../../library/smtplib.rst:98 +#: ../../library/smtplib.rst:111 msgid "" "The class now supports hostname check with :attr:`ssl.SSLContext." "check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." @@ -180,7 +202,7 @@ msgstr "" "此類別現在支援以 :attr:`ssl.SSLContext.check_hostname` 進行主機名稱檢查以及 " "*伺服器名稱指示 (Server Name Indication)*\\ (請參閱 :const:`ssl.HAS_SNI`)。" -#: ../../library/smtplib.rst:103 +#: ../../library/smtplib.rst:116 msgid "" "If the *timeout* parameter is set to be zero, it will raise a :class:" "`ValueError` to prevent the creation of a non-blocking socket" @@ -188,11 +210,11 @@ msgstr "" "如果 *timeout* 參數被設為零,則會引發 :class:`ValueError`,以防止建立非阻塞" "的 socket" -#: ../../library/smtplib.rst:107 ../../library/smtplib.rst:412 +#: ../../library/smtplib.rst:120 ../../library/smtplib.rst:428 msgid "The deprecated *keyfile* and *certfile* parameters have been removed." msgstr "已棄用的 *keyfile* 和 *certfile* 參數已被移除。" -#: ../../library/smtplib.rst:113 +#: ../../library/smtplib.rst:126 msgid "" "The LMTP protocol, which is very similar to ESMTP, is heavily based on the " "standard SMTP client. It's common to use Unix sockets for LMTP, so our :meth:" @@ -207,7 +229,7 @@ msgstr "" "在 :class:`SMTP` 類別中的相同。要指定一個 Unix socket,你必須為 *host* 使用" "以 '/' 開頭的絕對路徑。" -#: ../../library/smtplib.rst:120 +#: ../../library/smtplib.rst:133 msgid "" "Authentication is supported, using the regular SMTP mechanism. When using a " "Unix socket, LMTP generally don't support or require any authentication, but " @@ -216,25 +238,25 @@ msgstr "" "支援使用一般的 SMTP 機制進行身分驗證。當使用 Unix socket 時,LMTP 通常不支援或" "不需要任何身分驗證,但實際情況可能因人而異。" -#: ../../library/smtplib.rst:124 +#: ../../library/smtplib.rst:137 msgid "The optional *timeout* parameter was added." msgstr "新增 *timeout* 選用參數。" -#: ../../library/smtplib.rst:128 +#: ../../library/smtplib.rst:141 msgid "A nice selection of exceptions is defined as well:" msgstr "此外也定義了一系列例外:" -#: ../../library/smtplib.rst:133 +#: ../../library/smtplib.rst:146 msgid "" "Subclass of :exc:`OSError` that is the base exception class for all the " "other exceptions provided by this module." msgstr ":exc:`OSError` 的子類別,是此模組所提供之所有其他例外的基底例外類別。" -#: ../../library/smtplib.rst:136 +#: ../../library/smtplib.rst:149 msgid "SMTPException became subclass of :exc:`OSError`" msgstr "SMTPException 成為 :exc:`OSError` 的子類別" -#: ../../library/smtplib.rst:142 +#: ../../library/smtplib.rst:155 msgid "" "This exception is raised when the server unexpectedly disconnects, or when " "an attempt is made to use the :class:`SMTP` instance before connecting it to " @@ -243,7 +265,7 @@ msgstr "" "當伺服器意外斷線時,或者當嘗試在將 :class:`SMTP` 實例連線至伺服器之前" "就使用它時,會引發此例外。" -#: ../../library/smtplib.rst:149 +#: ../../library/smtplib.rst:162 msgid "" "Base class for all exceptions that include an SMTP error code. These " "exceptions are generated in some instances when the SMTP server returns an " @@ -252,15 +274,15 @@ msgstr "" "所有包含 SMTP 錯誤碼的例外的基底類別。當 SMTP 伺服器回傳錯誤碼時,在某些情況" "下會產生這些例外。" -#: ../../library/smtplib.rst:154 +#: ../../library/smtplib.rst:167 msgid "The error code." msgstr "錯誤碼。" -#: ../../library/smtplib.rst:158 +#: ../../library/smtplib.rst:171 msgid "The error message." msgstr "錯誤訊息。" -#: ../../library/smtplib.rst:163 +#: ../../library/smtplib.rst:176 msgid "" "Sender address refused. In addition to the attributes set by on all :exc:" "`SMTPResponseException` exceptions, this sets 'sender' to the string that " @@ -269,11 +291,11 @@ msgstr "" "寄件者位址被拒絕。除了所有 :exc:`SMTPResponseException` 例外所設定的屬性外," "這還會將 'sender' 設定為 SMTP 伺服器所拒絕的字串。" -#: ../../library/smtplib.rst:170 +#: ../../library/smtplib.rst:183 msgid "All recipient addresses refused." msgstr "所有收件者位址都被拒絕。" -#: ../../library/smtplib.rst:174 +#: ../../library/smtplib.rst:187 msgid "" "A dictionary of exactly the same sort as returned by :meth:`SMTP.sendmail` " "containing the errors for each recipient." @@ -281,43 +303,43 @@ msgstr "" "一個 dictionary,其類型與 :meth:`SMTP.sendmail` 所回傳的完全相同,包含每個收" "件者的錯誤。" -#: ../../library/smtplib.rst:181 +#: ../../library/smtplib.rst:194 msgid "The SMTP server refused to accept the message data." msgstr "SMTP 伺服器拒絕接受訊息資料。" -#: ../../library/smtplib.rst:186 +#: ../../library/smtplib.rst:199 msgid "Error occurred during establishment of a connection with the server." msgstr "與伺服器建立連線的過程中發生錯誤。" -#: ../../library/smtplib.rst:191 +#: ../../library/smtplib.rst:204 msgid "The server refused our ``HELO`` message." msgstr "伺服器拒絕了我們的 ``HELO`` 訊息。" -#: ../../library/smtplib.rst:196 +#: ../../library/smtplib.rst:209 msgid "The command or option attempted is not supported by the server." msgstr "所嘗試的指令或選項不被伺服器支援。" -#: ../../library/smtplib.rst:203 +#: ../../library/smtplib.rst:216 msgid "" "SMTP authentication went wrong. Most probably the server didn't accept the " "username/password combination provided." msgstr "SMTP 身分驗證出錯。最有可能是伺服器不接受所提供的使用者名稱/密碼組合。" -#: ../../library/smtplib.rst:209 +#: ../../library/smtplib.rst:222 msgid ":rfc:`821` - Simple Mail Transfer Protocol" msgstr ":rfc:`821` - 簡易郵件傳輸協定" -#: ../../library/smtplib.rst:210 +#: ../../library/smtplib.rst:223 msgid "" "Protocol definition for SMTP. This document covers the model, operating " "procedure, and protocol details for SMTP." msgstr "SMTP 的協定定義。本文件涵蓋了 SMTP 的模型、操作流程和協定細節。" -#: ../../library/smtplib.rst:213 +#: ../../library/smtplib.rst:226 msgid ":rfc:`1869` - SMTP Service Extensions" msgstr ":rfc:`1869` - SMTP 服務擴充" -#: ../../library/smtplib.rst:214 +#: ../../library/smtplib.rst:227 msgid "" "Definition of the ESMTP extensions for SMTP. This describes a framework for " "extending SMTP with new commands, supporting dynamic discovery of the " @@ -326,15 +348,15 @@ msgstr "" "SMTP 的 ESMTP 擴充定義。這描述了一個以新指令擴充 SMTP 的框架,支援動態探查伺" "服器所提供的指令,並定義了一些額外的指令。" -#: ../../library/smtplib.rst:222 +#: ../../library/smtplib.rst:235 msgid "SMTP Objects" msgstr "SMTP 物件" -#: ../../library/smtplib.rst:224 +#: ../../library/smtplib.rst:237 msgid "An :class:`SMTP` instance has the following methods:" msgstr ":class:`SMTP` 實例擁有以下方法:" -#: ../../library/smtplib.rst:228 +#: ../../library/smtplib.rst:241 msgid "" "Set the debug output level. A value of 1 or ``True`` for *level* results in " "debug messages for connection and for all messages sent to and received from " @@ -344,18 +366,18 @@ msgstr "" "設定除錯輸出的層級。*level* 為 1 或 ``True`` 會為連線以及所有傳送至伺服器和從" "伺服器接收的訊息產生除錯訊息。*level* 為 2 則會為這些訊息加上時間戳記。" -#: ../../library/smtplib.rst:233 +#: ../../library/smtplib.rst:246 msgid "Added debuglevel 2." msgstr "新增 debuglevel 2。" -#: ../../library/smtplib.rst:238 +#: ../../library/smtplib.rst:251 msgid "" "Send a command *cmd* to the server. The optional argument *args* is simply " "concatenated to the command, separated by a space." msgstr "" "傳送一個指令 *cmd* 給伺服器。選用引數 *args* 只會以一個空格分隔串接到指令後。" -#: ../../library/smtplib.rst:241 +#: ../../library/smtplib.rst:254 msgid "" "This returns a 2-tuple composed of a numeric response code and the actual " "response line (multiline responses are joined into one long line.)" @@ -363,7 +385,7 @@ msgstr "" "這會回傳一個 2-tuple,由數值回應碼和實際的回應行所組成(多行回應會被合併為一" "長行)。" -#: ../../library/smtplib.rst:244 +#: ../../library/smtplib.rst:257 msgid "" "In normal operation it should not be necessary to call this method " "explicitly. It is used to implement other methods and may be useful for " @@ -372,14 +394,14 @@ msgstr "" "在正常操作中,應該不需要明確地呼叫此方法。它被用於實作其他方法,並可能對測試" "私有擴充很有用。" -#: ../../library/smtplib.rst:248 +#: ../../library/smtplib.rst:261 msgid "" "If the connection to the server is lost while waiting for the reply, :exc:" "`SMTPServerDisconnected` will be raised." msgstr "" "如果在等待回覆時與伺服器的連線中斷,則會引發 :exc:`SMTPServerDisconnected`。" -#: ../../library/smtplib.rst:254 +#: ../../library/smtplib.rst:267 msgid "" "Connect to a host on a given port. The defaults are to connect to the local " "host at the standard SMTP port (25). If the hostname ends with a colon " @@ -394,7 +416,13 @@ msgstr "" "將該數字解釋為要使用的連接埠號。如果在實例化期間有指定主機,建構函式會自動叫" "用此方法。回傳一個 2-tuple,內容為伺服器在其連線回應中所傳送的回應碼和訊息。" -#: ../../library/smtplib.rst:262 +#: ../../library/smtplib.rst:275 +msgid "" +"If port is not changed from its default value of 0, the value of the :attr:" +"`default_port` attribute is used." +msgstr "" + +#: ../../library/smtplib.rst:278 msgid "" "Raises an :ref:`auditing event ` ``smtplib.connect`` with " "arguments ``self``, ``host``, ``port``." @@ -402,7 +430,7 @@ msgstr "" "引發一個附帶引數 ``self``、``host``、``port`` 的\\ :ref:`稽核事件 " "` ``smtplib.connect``。" -#: ../../library/smtplib.rst:267 +#: ../../library/smtplib.rst:283 msgid "" "Identify yourself to the SMTP server using ``HELO``. The hostname argument " "defaults to the fully qualified domain name of the local host. The message " @@ -413,7 +441,7 @@ msgstr "" "域名稱(fully qualified domain name)。伺服器回傳的訊息會被儲存為物件" "的 :attr:`helo_resp` 屬性。" -#: ../../library/smtplib.rst:272 +#: ../../library/smtplib.rst:288 msgid "" "In normal operation it should not be necessary to call this method " "explicitly. It will be implicitly called by the :meth:`sendmail` when " @@ -422,7 +450,7 @@ msgstr "" "在正常操作中,應該不需要明確地呼叫此方法。必要時它會被 :meth:`sendmail` 隱式" "地呼叫。" -#: ../../library/smtplib.rst:278 +#: ../../library/smtplib.rst:294 msgid "" "Identify yourself to an ESMTP server using ``EHLO``. The hostname argument " "defaults to the fully qualified domain name of the local host. Examine the " @@ -440,7 +468,7 @@ msgstr "" "被設為 ``True`` 或 ``False``,而 :attr:`esmtp_features` 會是一個 dictionary," "包含此伺服器所支援的 SMTP 服務擴充名稱以及它們的參數(如果有的話)。" -#: ../../library/smtplib.rst:288 +#: ../../library/smtplib.rst:304 msgid "" "Unless you wish to use :meth:`has_extn` before sending mail, it should not " "be necessary to call this method explicitly. It will be implicitly called " @@ -449,7 +477,7 @@ msgstr "" "除非你想在寄送郵件前使用 :meth:`has_extn`,否則應該不需要明確地呼叫此方法。必" "要時它會被 :meth:`sendmail` 隱式地呼叫。" -#: ../../library/smtplib.rst:294 +#: ../../library/smtplib.rst:310 msgid "" "This method calls :meth:`ehlo` and/or :meth:`helo` if there has been no " "previous ``EHLO`` or ``HELO`` command this session. It tries ESMTP ``EHLO`` " @@ -458,17 +486,17 @@ msgstr "" "如果此 session 之前沒有過 ``EHLO`` 或 ``HELO`` 指令,此方法會呼" "叫 :meth:`ehlo` 和/或 :meth:`helo`。它會先嘗試 ESMTP 的 ``EHLO``。" -#: ../../library/smtplib.rst:298 ../../library/smtplib.rst:327 -#: ../../library/smtplib.rst:415 ../../library/smtplib.rst:483 +#: ../../library/smtplib.rst:314 ../../library/smtplib.rst:343 +#: ../../library/smtplib.rst:431 ../../library/smtplib.rst:499 msgid ":exc:`SMTPHeloError`" msgstr ":exc:`SMTPHeloError`" -#: ../../library/smtplib.rst:299 ../../library/smtplib.rst:328 -#: ../../library/smtplib.rst:416 ../../library/smtplib.rst:484 +#: ../../library/smtplib.rst:315 ../../library/smtplib.rst:344 +#: ../../library/smtplib.rst:432 ../../library/smtplib.rst:500 msgid "The server didn't reply properly to the ``HELO`` greeting." msgstr "伺服器沒有正確地回覆 ``HELO`` 問候。" -#: ../../library/smtplib.rst:303 +#: ../../library/smtplib.rst:319 msgid "" "Return :const:`True` if *name* is in the set of SMTP service extensions " "returned by the server, :const:`False` otherwise. Case is ignored." @@ -476,7 +504,7 @@ msgstr "" "如果 *name* 在伺服器回傳的 SMTP 服務擴充集合中,則回傳 :const:`True`,否則回" "傳 :const:`False`。大小寫會被忽略。" -#: ../../library/smtplib.rst:309 +#: ../../library/smtplib.rst:325 msgid "" "Check the validity of an address on this server using SMTP ``VRFY``. Returns " "a tuple consisting of code 250 and a full :rfc:`822` address (including " @@ -487,11 +515,11 @@ msgstr "" "則回傳一個由代號 250 和一個完整的 :rfc:`822` 位址(包含人名)組成的 " "tuple。否則回傳一個 400 或更大的 SMTP 錯誤碼以及一個錯誤字串。" -#: ../../library/smtplib.rst:316 +#: ../../library/smtplib.rst:332 msgid "Many sites disable SMTP ``VRFY`` in order to foil spammers." msgstr "許多網站會停用 SMTP 的 ``VRFY`` 以阻擋垃圾郵件發送者。" -#: ../../library/smtplib.rst:321 +#: ../../library/smtplib.rst:337 msgid "" "Log in on an SMTP server that requires authentication. The arguments are the " "username and the password to authenticate with. If there has been no " @@ -503,32 +531,32 @@ msgstr "" "session 之前沒有過 ``EHLO`` 或 ``HELO`` 指令,此方法會先嘗試 ESMTP 的 " "``EHLO``。如果身分驗證成功,此方法會正常回傳,否則可能引發以下例外:" -#: ../../library/smtplib.rst:330 +#: ../../library/smtplib.rst:346 msgid ":exc:`SMTPAuthenticationError`" msgstr ":exc:`SMTPAuthenticationError`" -#: ../../library/smtplib.rst:331 +#: ../../library/smtplib.rst:347 msgid "The server didn't accept the username/password combination." msgstr "伺服器不接受該使用者名稱/密碼組合。" -#: ../../library/smtplib.rst:333 ../../library/smtplib.rst:418 -#: ../../library/smtplib.rst:493 +#: ../../library/smtplib.rst:349 ../../library/smtplib.rst:434 +#: ../../library/smtplib.rst:509 msgid ":exc:`SMTPNotSupportedError`" msgstr ":exc:`SMTPNotSupportedError`" -#: ../../library/smtplib.rst:334 +#: ../../library/smtplib.rst:350 msgid "The ``AUTH`` command is not supported by the server." msgstr "伺服器不支援 ``AUTH`` 指令。" -#: ../../library/smtplib.rst:336 +#: ../../library/smtplib.rst:352 msgid ":exc:`SMTPException`" msgstr ":exc:`SMTPException`" -#: ../../library/smtplib.rst:337 +#: ../../library/smtplib.rst:353 msgid "No suitable authentication method was found." msgstr "找不到合適的身分驗證方法。" -#: ../../library/smtplib.rst:339 +#: ../../library/smtplib.rst:355 msgid "" "Each of the authentication methods supported by :mod:`!smtplib` are tried in " "turn if they are advertised as supported by the server. See :meth:`auth` " @@ -539,7 +567,7 @@ msgstr "" "序嘗試。支援的身分驗證方法清單請參閱 :meth:`auth`。*initial_response_ok* 會被" "傳遞給 :meth:`auth`。" -#: ../../library/smtplib.rst:344 +#: ../../library/smtplib.rst:360 msgid "" "Optional keyword argument *initial_response_ok* specifies whether, for " "authentication methods that support it, an \"initial response\" as specified " @@ -550,7 +578,7 @@ msgstr "" "將 :rfc:`4954` 中所指定的「initial response(初始回應)」隨 ``AUTH`` 指令一起" "傳送,而非要求進行 challenge(質詢)/response(回應)。" -#: ../../library/smtplib.rst:349 +#: ../../library/smtplib.rst:365 msgid "" ":exc:`SMTPNotSupportedError` may be raised, and the *initial_response_ok* " "parameter was added." @@ -558,7 +586,7 @@ msgstr "" "可能會引發 :exc:`SMTPNotSupportedError`,並新增了 *initial_response_ok* 參" "數。" -#: ../../library/smtplib.rst:356 +#: ../../library/smtplib.rst:372 msgid "" "Issue an ``SMTP`` ``AUTH`` command for the specified authentication " "*mechanism*, and handle the challenge response via *authobject*." @@ -566,7 +594,7 @@ msgstr "" "為指定的身分驗證 *mechanism* 發出一個 ``SMTP`` ``AUTH`` 指令,並透過 " "*authobject* 處理 challenge 回應。" -#: ../../library/smtplib.rst:359 +#: ../../library/smtplib.rst:375 msgid "" "*mechanism* specifies which authentication mechanism is to be used as " "argument to the ``AUTH`` command; the valid values are those listed in the " @@ -575,16 +603,16 @@ msgstr "" "*mechanism* 指定要用作 ``AUTH`` 指令引數的身分驗證機制;有效值" "為 :attr:`esmtp_features` 的 ``auth`` 元素中所列出的那些。" -#: ../../library/smtplib.rst:363 +#: ../../library/smtplib.rst:379 msgid "" "*authobject* must be a callable object taking an optional single argument::" msgstr "*authobject* 必須是一個接受單一選用引數的可呼叫物件: ::" -#: ../../library/smtplib.rst:365 +#: ../../library/smtplib.rst:381 msgid "data = authobject(challenge=None)" msgstr "data = authobject(challenge=None)" -#: ../../library/smtplib.rst:367 +#: ../../library/smtplib.rst:383 msgid "" "If optional keyword argument *initial_response_ok* is true, ``authobject()`` " "will be called first with no argument. It can return the :rfc:`4954` " @@ -601,7 +629,7 @@ msgstr "" "``challenge=None`` 被呼叫時應回傳 ``None``。如果 *initial_response_ok* 為假," "則 ``authobject()`` 不會先以 ``None`` 被呼叫。" -#: ../../library/smtplib.rst:375 +#: ../../library/smtplib.rst:391 msgid "" "If the initial response check returns ``None``, or if *initial_response_ok* " "is false, ``authobject()`` will be called to process the server's challenge " @@ -614,7 +642,7 @@ msgstr "" "*challenge* 引數會是一個 ``bytes``。它應回傳會被 base64 編碼並傳送至伺服器的 " "ASCII ``str`` *data*。" -#: ../../library/smtplib.rst:381 +#: ../../library/smtplib.rst:397 msgid "" "The ``SMTP`` class provides ``authobjects`` for the ``CRAM-MD5``, ``PLAIN``, " "and ``LOGIN`` mechanisms; they are named ``SMTP.auth_cram_md5``, ``SMTP." @@ -627,7 +655,7 @@ msgstr "" "``SMTP.auth_plain`` 和 ``SMTP.auth_login``。它們都要求 ``SMTP`` 實例的 " "``user`` 和 ``password`` 屬性被設定為適當的值。" -#: ../../library/smtplib.rst:387 +#: ../../library/smtplib.rst:403 msgid "" "User code does not normally need to call ``auth`` directly, but can instead " "call the :meth:`login` method, which will try each of the above mechanisms " @@ -639,7 +667,7 @@ msgstr "" "法,它會依所列順序依序嘗試上述每一種機制。``auth`` 被公開出來是為了方便實" "作 :mod:`!smtplib` 尚未(或還沒有)直接支援的身分驗證方法。" -#: ../../library/smtplib.rst:398 +#: ../../library/smtplib.rst:414 msgid "" "Put the SMTP connection in TLS (Transport Layer Security) mode. All SMTP " "commands that follow will be encrypted. You should then call :meth:`ehlo` " @@ -648,7 +676,7 @@ msgstr "" "將 SMTP 連線置於 TLS(Transport Layer Security,傳輸層安全性)模式。後續所有" "的 SMTP 指令都會被加密。接著你應該再次呼叫 :meth:`ehlo`。" -#: ../../library/smtplib.rst:402 +#: ../../library/smtplib.rst:418 msgid "" "If *keyfile* and *certfile* are provided, they are used to create an :class:" "`ssl.SSLContext`." @@ -656,7 +684,7 @@ msgstr "" "如果有提供 *keyfile* 和 *certfile*,它們會被用來建立一" "個 :class:`ssl.SSLContext`。" -#: ../../library/smtplib.rst:405 +#: ../../library/smtplib.rst:421 msgid "" "Optional *context* parameter is an :class:`ssl.SSLContext` object; This is " "an alternative to using a keyfile and a certfile and if specified both " @@ -666,7 +694,7 @@ msgstr "" "和 certfile 的替代方案,如果有指定它,則 *keyfile* 和 *certfile* 都應為 " "``None``。" -#: ../../library/smtplib.rst:409 +#: ../../library/smtplib.rst:425 msgid "" "If there has been no previous ``EHLO`` or ``HELO`` command this session, " "this method tries ESMTP ``EHLO`` first." @@ -674,19 +702,19 @@ msgstr "" "如果此 session 之前沒有過 ``EHLO`` 或 ``HELO`` 指令,此方法會先嘗試 ESMTP 的 " "``EHLO``。" -#: ../../library/smtplib.rst:419 +#: ../../library/smtplib.rst:435 msgid "The server does not support the STARTTLS extension." msgstr "伺服器不支援 STARTTLS 擴充。" -#: ../../library/smtplib.rst:421 +#: ../../library/smtplib.rst:437 msgid ":exc:`RuntimeError`" msgstr ":exc:`RuntimeError`" -#: ../../library/smtplib.rst:422 +#: ../../library/smtplib.rst:438 msgid "SSL/TLS support is not available to your Python interpreter." msgstr "你的 Python 直譯器無法使用 SSL/TLS 支援。" -#: ../../library/smtplib.rst:427 +#: ../../library/smtplib.rst:443 msgid "" "The method now supports hostname check with :attr:`ssl.SSLContext." "check_hostname` and *Server Name Indicator* (see :const:`~ssl.HAS_SNI`)." @@ -694,7 +722,7 @@ msgstr "" "此方法現在支援以 :attr:`ssl.SSLContext.check_hostname` 進行主機名稱檢查以及 " "*Server Name Indicator*\\ (請參閱 :const:`~ssl.HAS_SNI`)。" -#: ../../library/smtplib.rst:432 +#: ../../library/smtplib.rst:448 msgid "" "The error raised for lack of STARTTLS support is now the :exc:" "`SMTPNotSupportedError` subclass instead of the base :exc:`SMTPException`." @@ -702,7 +730,7 @@ msgstr "" "針對缺乏 STARTTLS 支援所引發的錯誤現在是 :exc:`SMTPNotSupportedError` 子類" "別,而非基底的 :exc:`SMTPException`。" -#: ../../library/smtplib.rst:440 +#: ../../library/smtplib.rst:456 msgid "" "Send mail. The required arguments are an :rfc:`822` from-address string, a " "list of :rfc:`822` to-address strings (a bare string will be treated as a " @@ -725,7 +753,7 @@ msgstr "" "(如果你需要對不同的收件者使用不同的 ESMTP 選項,你必須使用如 :meth:`!" "mail`、:meth:`!rcpt` 和 :meth:`!data` 等低階方法來寄送訊息。)" -#: ../../library/smtplib.rst:453 +#: ../../library/smtplib.rst:469 msgid "" "The *from_addr* and *to_addrs* parameters are used to construct the message " "envelope used by the transport agents. ``sendmail`` does not modify the " @@ -734,7 +762,7 @@ msgstr "" "*from_addr* 和 *to_addrs* 參數用來建構傳輸代理(transport agent)所使用的訊息" "信封(message envelope)。``sendmail`` 不會以任何方式修改訊息標頭。" -#: ../../library/smtplib.rst:457 +#: ../../library/smtplib.rst:473 msgid "" "*msg* may be a string containing characters in the ASCII range, or a byte " "string. A string is encoded to bytes using the ascii codec, and lone " @@ -745,7 +773,7 @@ msgstr "" "ascii codec 被編碼為位元組,而單獨的 ``\\r`` 和 ``\\n`` 字元會被轉換為 " "``\\r\\n`` 字元。位元組字串不會被修改。" -#: ../../library/smtplib.rst:462 +#: ../../library/smtplib.rst:478 msgid "" "If there has been no previous ``EHLO`` or ``HELO`` command this session, " "this method tries ESMTP ``EHLO`` first. If the server does ESMTP, message " @@ -758,7 +786,7 @@ msgstr "" "該選項在伺服器宣告的功能集合中)。如果 ``EHLO`` 失敗,則會嘗試 ``HELO`` 並抑" "制 ESMTP 選項。" -#: ../../library/smtplib.rst:468 +#: ../../library/smtplib.rst:484 msgid "" "This method will return normally if the mail is accepted for at least one " "recipient. Otherwise it will raise an exception. That is, if this method " @@ -772,7 +800,7 @@ msgstr "" "外,它會回傳一個 dictionary,其中每個被拒絕的收件者都有一個條目。每個條目都包" "含一個由 SMTP 錯誤碼和伺服器所傳送的隨附錯誤訊息組成的 tuple。" -#: ../../library/smtplib.rst:475 +#: ../../library/smtplib.rst:491 msgid "" "If ``SMTPUTF8`` is included in *mail_options*, and the server supports it, " "*from_addr* and *to_addrs* may contain non-ASCII characters." @@ -780,53 +808,53 @@ msgstr "" "如果 ``SMTPUTF8`` 被包含在 *mail_options* 中且伺服器支援它,則 *from_addr* " "和 *to_addrs* 可以包含非 ASCII 字元。" -#: ../../library/smtplib.rst:478 +#: ../../library/smtplib.rst:494 msgid "This method may raise the following exceptions:" msgstr "此方法可能引發以下例外:" -#: ../../library/smtplib.rst:480 +#: ../../library/smtplib.rst:496 msgid ":exc:`SMTPRecipientsRefused`" msgstr ":exc:`SMTPRecipientsRefused`" -#: ../../library/smtplib.rst:481 +#: ../../library/smtplib.rst:497 msgid "All recipients were refused. Nobody got the mail." msgstr "所有收件者都被拒絕。沒有人收到郵件。" -#: ../../library/smtplib.rst:486 +#: ../../library/smtplib.rst:502 msgid ":exc:`SMTPSenderRefused`" msgstr ":exc:`SMTPSenderRefused`" -#: ../../library/smtplib.rst:487 +#: ../../library/smtplib.rst:503 msgid "The server didn't accept the *from_addr*." msgstr "伺服器不接受 *from_addr*。" -#: ../../library/smtplib.rst:489 +#: ../../library/smtplib.rst:505 msgid ":exc:`SMTPDataError`" msgstr ":exc:`SMTPDataError`" -#: ../../library/smtplib.rst:490 +#: ../../library/smtplib.rst:506 msgid "" "The server replied with an unexpected error code (other than a refusal of a " "recipient)." msgstr "伺服器以一個非預期的錯誤碼回覆(而非拒絕某個收件者)。" -#: ../../library/smtplib.rst:494 +#: ../../library/smtplib.rst:510 msgid "" "``SMTPUTF8`` was given in the *mail_options* but is not supported by the " "server." msgstr "*mail_options* 中有給定 ``SMTPUTF8``,但伺服器不支援它。" -#: ../../library/smtplib.rst:497 +#: ../../library/smtplib.rst:513 msgid "" "Unless otherwise noted, the connection will be open even after an exception " "is raised." msgstr "除非另有說明,否則即使在引發例外後,連線仍會保持開啟。" -#: ../../library/smtplib.rst:500 +#: ../../library/smtplib.rst:516 msgid "*msg* may be a byte string." msgstr "*msg* 可以是一個位元組字串。" -#: ../../library/smtplib.rst:503 +#: ../../library/smtplib.rst:519 msgid "" "``SMTPUTF8`` support added, and :exc:`SMTPNotSupportedError` may be raised " "if ``SMTPUTF8`` is specified but the server does not support it." @@ -834,7 +862,7 @@ msgstr "" "新增 ``SMTPUTF8`` 支援,且如果指定了 ``SMTPUTF8`` 但伺服器不支援它,可能會引" "發 :exc:`SMTPNotSupportedError`。" -#: ../../library/smtplib.rst:511 +#: ../../library/smtplib.rst:527 msgid "" "This is a convenience method for calling :meth:`sendmail` with the message " "represented by an :class:`email.message.Message` object. The arguments have " @@ -845,7 +873,7 @@ msgstr "" "呼叫 :meth:`sendmail`。引數的意義與 :meth:`sendmail` 的相同,但 *msg* 是一個 " "``Message`` 物件。" -#: ../../library/smtplib.rst:516 +#: ../../library/smtplib.rst:532 msgid "" "If *from_addr* is ``None`` or *to_addrs* is ``None``, ``send_message`` fills " "those arguments with addresses extracted from the headers of *msg* as " @@ -869,7 +897,7 @@ msgstr "" "組 :mailheader:`Resent-*` 標頭,則會引發 :exc:`ValueError`,因為無法明確地偵" "測出最近的那組 :mailheader:`Resent-` 標頭。" -#: ../../library/smtplib.rst:528 +#: ../../library/smtplib.rst:544 msgid "" "``send_message`` serializes *msg* using :class:`~email.generator." "BytesGenerator` with ``\\r\\n`` as the *linesep*, and calls :meth:`sendmail` " @@ -893,17 +921,17 @@ msgstr "" "屬性被設為 ``True``)進行序列化,且 ``SMTPUTF8`` 和 ``BODY=8BITMIME`` 會被新" "增到 *mail_options*。" -#: ../../library/smtplib.rst:542 +#: ../../library/smtplib.rst:558 msgid "Support for internationalized addresses (``SMTPUTF8``)." msgstr "對國際化位址(``SMTPUTF8``)的支援。" -#: ../../library/smtplib.rst:548 +#: ../../library/smtplib.rst:564 msgid "" "Terminate the SMTP session and close the connection. Return the result of " "the SMTP ``QUIT`` command." msgstr "終止 SMTP session 並關閉連線。回傳 SMTP ``QUIT`` 指令的結果。" -#: ../../library/smtplib.rst:552 +#: ../../library/smtplib.rst:568 msgid "" "Low-level methods corresponding to the standard SMTP/ESMTP commands " "``HELP``, ``RSET``, ``NOOP``, ``MAIL``, ``RCPT``, and ``DATA`` are also " @@ -914,36 +942,36 @@ msgstr "" "``RCPT`` 和 ``DATA`` 的低階方法。通常這些方法不需要被直接呼叫,因此這裡不對它" "們加以說明。詳情請參閱模組程式碼。" -#: ../../library/smtplib.rst:557 +#: ../../library/smtplib.rst:573 msgid "Additionally, an SMTP instance has the following attributes:" msgstr "此外,SMTP 實例擁有以下屬性:" -#: ../../library/smtplib.rst:562 +#: ../../library/smtplib.rst:578 msgid "The response to the ``HELO`` command, see :meth:`helo`." msgstr "對 ``HELO`` 指令的回應,請參閱 :meth:`helo`。" -#: ../../library/smtplib.rst:567 +#: ../../library/smtplib.rst:583 msgid "The response to the ``EHLO`` command, see :meth:`ehlo`." msgstr "對 ``EHLO`` 指令的回應,請參閱 :meth:`ehlo`。" -#: ../../library/smtplib.rst:572 +#: ../../library/smtplib.rst:588 msgid "" "A boolean value indicating whether the server supports ESMTP, see :meth:" "`ehlo`." msgstr "一個 boolean 值,指出伺服器是否支援 ESMTP,請參閱 :meth:`ehlo`。" -#: ../../library/smtplib.rst:578 +#: ../../library/smtplib.rst:594 msgid "" "A dictionary of the names of SMTP service extensions supported by the " "server, see :meth:`ehlo`." msgstr "" "一個包含伺服器所支援之 SMTP 服務擴充名稱的 dictionary,請參閱 :meth:`ehlo`。" -#: ../../library/smtplib.rst:585 +#: ../../library/smtplib.rst:601 msgid "SMTP Example" msgstr "SMTP 範例" -#: ../../library/smtplib.rst:587 +#: ../../library/smtplib.rst:603 msgid "" "This example prompts the user for addresses needed in the message envelope " "('To' and 'From' addresses), and the message to be delivered. Note that the " @@ -957,7 +985,7 @@ msgstr "" "例不會對 :rfc:`822` 標頭做任何處理。特別是,「To」和「From」位址必須明確地包" "含在訊息標頭中: ::" -#: ../../library/smtplib.rst:593 +#: ../../library/smtplib.rst:609 msgid "" "import smtplib\n" "\n" @@ -995,7 +1023,7 @@ msgstr "" "to_addrs = prompt(\"To: \").split()\n" "print(\"Enter message, end with ^D (Unix) or ^Z (Windows):\")\n" "\n" -"# 在開頭加上 From: 和 To: 標頭!\n" +"# 在開頭加上 From: 和 To: 標頭!\n" "lines = [f\"From: {from_addr}\", f\"To: {', '.join(to_addrs)}\", \"\"]\n" "while True:\n" " try:\n" @@ -1013,7 +1041,7 @@ msgstr "" "server.sendmail(from_addr, to_addrs, msg)\n" "server.quit()" -#: ../../library/smtplib.rst:622 +#: ../../library/smtplib.rst:638 msgid "" "In general, you will want to use the :mod:`email` package's features to " "construct an email message, which you can then send via :meth:`~smtplib.SMTP." @@ -1023,14 +1051,14 @@ msgstr "" "過 :meth:`~smtplib.SMTP.send_message` 來寄送它;請參閱 :ref:`email-" "examples`。" -#: ../../library/smtplib.rst:11 +#: ../../library/smtplib.rst:9 msgid "SMTP" msgstr "SMTP" -#: ../../library/smtplib.rst:11 +#: ../../library/smtplib.rst:9 msgid "protocol" msgstr "protocol(協定)" -#: ../../library/smtplib.rst:11 +#: ../../library/smtplib.rst:9 msgid "Simple Mail Transfer Protocol" msgstr "Simple Mail Transfer Protocol(簡易郵件傳輸協定)" diff --git a/library/socket.po b/library/socket.po index 9f3a2e47fd1..2499a6b6c51 100644 --- a/library/socket.po +++ b/library/socket.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-16 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-12-30 23:45+0800\n" "Last-Translator: Jay \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -44,34 +44,34 @@ msgstr "由於是呼叫作業系統的 socket API,某些行為可能會因平 #: ../../library/socket.rst:198 ../../library/socket.rst:208 #: ../../library/socket.rst:236 ../../library/socket.rst:243 #: ../../library/socket.rst:260 ../../library/socket.rst:410 -#: ../../library/socket.rst:496 ../../library/socket.rst:513 -#: ../../library/socket.rst:528 ../../library/socket.rst:539 -#: ../../library/socket.rst:548 ../../library/socket.rst:557 -#: ../../library/socket.rst:568 ../../library/socket.rst:580 -#: ../../library/socket.rst:591 ../../library/socket.rst:604 -#: ../../library/socket.rst:632 ../../library/socket.rst:644 -#: ../../library/socket.rst:650 ../../library/socket.rst:682 -#: ../../library/socket.rst:735 ../../library/socket.rst:747 -#: ../../library/socket.rst:756 ../../library/socket.rst:771 -#: ../../library/socket.rst:780 ../../library/socket.rst:788 -#: ../../library/socket.rst:805 ../../library/socket.rst:820 -#: ../../library/socket.rst:830 ../../library/socket.rst:962 -#: ../../library/socket.rst:1081 ../../library/socket.rst:1097 -#: ../../library/socket.rst:1110 ../../library/socket.rst:1125 -#: ../../library/socket.rst:1142 ../../library/socket.rst:1153 -#: ../../library/socket.rst:1164 ../../library/socket.rst:1175 -#: ../../library/socket.rst:1264 ../../library/socket.rst:1284 -#: ../../library/socket.rst:1310 ../../library/socket.rst:1333 -#: ../../library/socket.rst:1362 ../../library/socket.rst:1373 -#: ../../library/socket.rst:1400 ../../library/socket.rst:1417 -#: ../../library/socket.rst:1434 ../../library/socket.rst:1448 -#: ../../library/socket.rst:1559 ../../library/socket.rst:1606 -#: ../../library/socket.rst:1620 ../../library/socket.rst:1640 -#: ../../library/socket.rst:1687 ../../library/socket.rst:1720 -#: ../../library/socket.rst:1733 ../../library/socket.rst:1859 -#: ../../library/socket.rst:1903 ../../library/socket.rst:2011 -#: ../../library/socket.rst:2029 ../../library/socket.rst:2110 -#: ../../library/socket.rst:2120 ../../library/socket.rst:2132 +#: ../../library/socket.rst:500 ../../library/socket.rst:517 +#: ../../library/socket.rst:532 ../../library/socket.rst:543 +#: ../../library/socket.rst:552 ../../library/socket.rst:561 +#: ../../library/socket.rst:572 ../../library/socket.rst:584 +#: ../../library/socket.rst:595 ../../library/socket.rst:608 +#: ../../library/socket.rst:636 ../../library/socket.rst:648 +#: ../../library/socket.rst:654 ../../library/socket.rst:686 +#: ../../library/socket.rst:739 ../../library/socket.rst:751 +#: ../../library/socket.rst:760 ../../library/socket.rst:775 +#: ../../library/socket.rst:784 ../../library/socket.rst:792 +#: ../../library/socket.rst:809 ../../library/socket.rst:824 +#: ../../library/socket.rst:834 ../../library/socket.rst:966 +#: ../../library/socket.rst:1091 ../../library/socket.rst:1107 +#: ../../library/socket.rst:1120 ../../library/socket.rst:1135 +#: ../../library/socket.rst:1152 ../../library/socket.rst:1163 +#: ../../library/socket.rst:1174 ../../library/socket.rst:1185 +#: ../../library/socket.rst:1274 ../../library/socket.rst:1294 +#: ../../library/socket.rst:1320 ../../library/socket.rst:1343 +#: ../../library/socket.rst:1375 ../../library/socket.rst:1386 +#: ../../library/socket.rst:1413 ../../library/socket.rst:1430 +#: ../../library/socket.rst:1447 ../../library/socket.rst:1461 +#: ../../library/socket.rst:1572 ../../library/socket.rst:1619 +#: ../../library/socket.rst:1633 ../../library/socket.rst:1653 +#: ../../library/socket.rst:1700 ../../library/socket.rst:1733 +#: ../../library/socket.rst:1746 ../../library/socket.rst:1872 +#: ../../library/socket.rst:1916 ../../library/socket.rst:2024 +#: ../../library/socket.rst:2042 ../../library/socket.rst:2126 +#: ../../library/socket.rst:2136 ../../library/socket.rst:2148 #: ../../includes/wasm-notavail.rst:3 msgid "Availability" msgstr "可用性" @@ -150,8 +150,8 @@ msgid "" "Previously, :const:`AF_UNIX` socket paths were assumed to use UTF-8 encoding." msgstr "" -#: ../../library/socket.rst:68 ../../library/socket.rst:1247 -#: ../../library/socket.rst:1289 ../../library/socket.rst:2104 +#: ../../library/socket.rst:68 ../../library/socket.rst:1257 +#: ../../library/socket.rst:1299 ../../library/socket.rst:2120 msgid "Writable :term:`bytes-like object` is now accepted." msgstr "" @@ -726,182 +726,188 @@ msgstr "" msgid "Added support for ``TCP_QUICKACK`` on Windows platforms when available." msgstr "" -#: ../../library/socket.rst:493 ../../library/socket.rst:577 -#: ../../library/socket.rst:601 +#: ../../library/socket.rst:487 +msgid "" +"``IPV6_HDRINCL`` was added. Added support for ``SO_PASSRIGHTS`` on Linux " +"platforms when available." +msgstr "" + +#: ../../library/socket.rst:497 ../../library/socket.rst:581 +#: ../../library/socket.rst:605 msgid "" "Many constants of these forms, documented in the Linux documentation, are " "also defined in the socket module." msgstr "" -#: ../../library/socket.rst:500 +#: ../../library/socket.rst:504 msgid "NetBSD support was added." msgstr "新增對 NetBSD 的支援。" -#: ../../library/socket.rst:503 +#: ../../library/socket.rst:507 msgid "Restored missing ``CAN_RAW_ERR_FILTER`` on Linux." msgstr "" -#: ../../library/socket.rst:509 +#: ../../library/socket.rst:513 msgid "" "CAN_BCM, in the CAN protocol family, is the broadcast manager (BCM) " "protocol. Broadcast manager constants, documented in the Linux " "documentation, are also defined in the socket module." msgstr "" -#: ../../library/socket.rst:516 +#: ../../library/socket.rst:520 msgid "" "The :data:`CAN_BCM_CAN_FD_FRAME` flag is only available on Linux >= 4.8." msgstr "" -#: ../../library/socket.rst:522 +#: ../../library/socket.rst:526 msgid "" "Enables CAN FD support in a CAN_RAW socket. This is disabled by default. " "This allows your application to send both CAN and CAN FD frames; however, " "you must accept both CAN and CAN FD frames when reading from the socket." msgstr "" -#: ../../library/socket.rst:526 ../../library/socket.rst:537 +#: ../../library/socket.rst:530 ../../library/socket.rst:541 msgid "This constant is documented in the Linux documentation." msgstr "" -#: ../../library/socket.rst:534 +#: ../../library/socket.rst:538 msgid "" "Joins the applied CAN filters such that only CAN frames that match all given " "CAN filters are passed to user space." msgstr "" -#: ../../library/socket.rst:545 +#: ../../library/socket.rst:549 msgid "" "CAN_ISOTP, in the CAN protocol family, is the ISO-TP (ISO 15765-2) protocol. " "ISO-TP constants, documented in the Linux documentation." msgstr "" -#: ../../library/socket.rst:554 +#: ../../library/socket.rst:558 msgid "" "CAN_J1939, in the CAN protocol family, is the SAE J1939 protocol. J1939 " "constants, documented in the Linux documentation." msgstr "" -#: ../../library/socket.rst:565 +#: ../../library/socket.rst:569 msgid "" "These two constants, documented in the FreeBSD divert(4) manual page, are " "also defined in the socket module." msgstr "" -#: ../../library/socket.rst:585 +#: ../../library/socket.rst:589 msgid "" ":data:`!ETH_P_ALL` can be used in the :class:`~socket.socket` constructor as " "*proto* for the :const:`AF_PACKET` family in order to capture every packet, " "regardless of protocol." msgstr "" -#: ../../library/socket.rst:589 +#: ../../library/socket.rst:593 msgid "For more information, see the :manpage:`packet(7)` manpage." msgstr "" -#: ../../library/socket.rst:614 +#: ../../library/socket.rst:618 msgid "" "Constants for Windows' WSAIoctl(). The constants are used as arguments to " "the :meth:`~socket.socket.ioctl` method of socket objects." msgstr "" -#: ../../library/socket.rst:617 ../../library/socket.rst:1722 +#: ../../library/socket.rst:621 ../../library/socket.rst:1735 msgid "``SIO_LOOPBACK_FAST_PATH`` was added." msgstr "加入 ``SIO_LOOPBACK_FAST_PATH``。" -#: ../../library/socket.rst:623 +#: ../../library/socket.rst:627 msgid "" "TIPC related constants, matching the ones exported by the C socket API. See " "the TIPC documentation for more information." msgstr "" -#: ../../library/socket.rst:630 +#: ../../library/socket.rst:634 msgid "Constants for Linux Kernel cryptography." msgstr "" -#: ../../library/socket.rst:642 +#: ../../library/socket.rst:646 msgid "Constants for Linux host/guest communication." msgstr "" -#: ../../library/socket.rst:656 +#: ../../library/socket.rst:660 msgid "" "This constant contains a boolean value which indicates if IPv6 is supported " "on this platform." msgstr "" -#: ../../library/socket.rst:665 +#: ../../library/socket.rst:669 msgid "Integer constants for use with Bluetooth addresses." msgstr "" -#: ../../library/socket.rst:670 +#: ../../library/socket.rst:674 msgid "" "These are string constants containing Bluetooth addresses with special " "meanings. For example, :const:`BDADDR_ANY` can be used to indicate any " "address when specifying the binding socket with :const:`BTPROTO_RFCOMM`." msgstr "" -#: ../../library/socket.rst:679 +#: ../../library/socket.rst:683 msgid "" "These constants describe the Bluetooth address type when binding or " "connecting a :const:`BTPROTO_L2CAP` socket." msgstr "" -#: ../../library/socket.rst:692 +#: ../../library/socket.rst:696 msgid "" "Used in the level argument to the :meth:`~socket.setsockopt` and :meth:" "`~socket.getsockopt` methods of Bluetooth socket objects." msgstr "" -#: ../../library/socket.rst:695 +#: ../../library/socket.rst:699 msgid "" ":const:`SOL_BLUETOOTH` is only available on Linux. Other constants are " "available if the corresponding protocol is supported." msgstr "" -#: ../../library/socket.rst:707 +#: ../../library/socket.rst:711 msgid "" "Used in the option name and value argument to the :meth:`~socket.setsockopt` " "and :meth:`~socket.getsockopt` methods of Bluetooth socket objects." msgstr "" -#: ../../library/socket.rst:710 +#: ../../library/socket.rst:714 msgid "" ":const:`!BT_*` and :const:`L2CAP_LM` are only available on Linux. :const:`!" "SO_BTH_*` are only available on Windows. Other constants may be available on " "Linux and various BSD platforms." msgstr "" -#: ../../library/socket.rst:722 +#: ../../library/socket.rst:726 msgid "" "Option names for use with :const:`BTPROTO_HCI`. Availability and format of " "the option values depend on platform." msgstr "" -#: ../../library/socket.rst:725 +#: ../../library/socket.rst:729 msgid "" "Added :const:`!SO_HCI_EVT_FILTER` and :const:`!SO_HCI_PKT_FILTER` on NetBSD " "and DragonFly BSD. Added :const:`!HCI_DATA_DIR` on FreeBSD, NetBSD and " "DragonFly BSD." msgstr "" -#: ../../library/socket.rst:732 +#: ../../library/socket.rst:736 msgid "" "The ``device_id`` value used to create an HCI socket that isn't specific to " "a single Bluetooth adapter." msgstr "" -#: ../../library/socket.rst:745 +#: ../../library/socket.rst:749 msgid "" "Possible values for ``channel`` field in the :const:`BTPROTO_HCI` address." msgstr "" -#: ../../library/socket.rst:753 +#: ../../library/socket.rst:757 msgid "" "Constant for Qualcomm's IPC router protocol, used to communicate with " "service providing remote processors." msgstr "" -#: ../../library/socket.rst:762 +#: ../../library/socket.rst:766 msgid "" "LOCAL_CREDS and LOCAL_CREDS_PERSISTENT can be used with SOCK_DGRAM, " "SOCK_STREAM sockets, equivalent to Linux/DragonFlyBSD SO_PASSCRED, while " @@ -910,53 +916,53 @@ msgid "" "message type." msgstr "" -#: ../../library/socket.rst:775 +#: ../../library/socket.rst:779 msgid "" "Constant to optimize CPU locality, to be used in conjunction with :data:" "`SO_REUSEPORT`." msgstr "" -#: ../../library/socket.rst:784 +#: ../../library/socket.rst:788 msgid "" "Constant to enable duplicate address and port bindings with load balancing." msgstr "" -#: ../../library/socket.rst:803 +#: ../../library/socket.rst:807 msgid "Constants for Windows Hyper-V sockets for host/guest communications." msgstr "" -#: ../../library/socket.rst:816 +#: ../../library/socket.rst:820 msgid "" "`IEEE 802.3 protocol number `_. constants." msgstr "" -#: ../../library/socket.rst:828 +#: ../../library/socket.rst:832 msgid "" "These constants are used by the :meth:`~socket.socket.shutdown` method of " "socket objects." msgstr "" -#: ../../library/socket.rst:833 +#: ../../library/socket.rst:837 msgid "Functions" msgstr "函式" -#: ../../library/socket.rst:836 +#: ../../library/socket.rst:840 msgid "Creating sockets" msgstr "建立 sockets" -#: ../../library/socket.rst:838 +#: ../../library/socket.rst:842 msgid "" "The following functions all create :ref:`socket objects `." msgstr "" -#: ../../library/socket.rst:841 +#: ../../library/socket.rst:845 msgid "" "The :class:`socket ` class constructor creates a new socket " "directly; see :ref:`socket-objects` for its parameters and full description." msgstr "" -#: ../../library/socket.rst:846 +#: ../../library/socket.rst:850 msgid "" "Build a pair of connected socket objects using the given address family, " "socket type, and protocol number. Address family, socket type, and protocol " @@ -965,25 +971,25 @@ msgid "" "const:`AF_INET`." msgstr "" -#: ../../library/socket.rst:851 +#: ../../library/socket.rst:855 msgid "The newly created sockets are :ref:`non-inheritable `." msgstr "" -#: ../../library/socket.rst:853 +#: ../../library/socket.rst:857 msgid "" "The returned socket objects now support the whole socket API, rather than a " "subset." msgstr "" -#: ../../library/socket.rst:857 +#: ../../library/socket.rst:861 msgid "The returned sockets are now non-inheritable." msgstr "" -#: ../../library/socket.rst:860 +#: ../../library/socket.rst:864 msgid "Windows support added." msgstr "新增對 Windows 的支援。" -#: ../../library/socket.rst:866 +#: ../../library/socket.rst:870 msgid "" "Connect to a TCP service listening on the internet *address* (a 2-tuple " "``(host, port)``), and return the socket object. This is a higher-level " @@ -994,21 +1000,21 @@ msgid "" "IPv4 and IPv6." msgstr "" -#: ../../library/socket.rst:874 +#: ../../library/socket.rst:878 msgid "" "Passing the optional *timeout* parameter will set the timeout on the socket " "instance before attempting to connect. If no *timeout* is supplied, the " "global default timeout setting returned by :func:`getdefaulttimeout` is used." msgstr "" -#: ../../library/socket.rst:879 +#: ../../library/socket.rst:883 msgid "" "If supplied, *source_address* must be a 2-tuple ``(host, port)`` for the " "socket to bind to as its source address before connecting. If host or port " "are '' or 0 respectively the OS default behavior will be used." msgstr "" -#: ../../library/socket.rst:883 +#: ../../library/socket.rst:887 msgid "" "When a connection cannot be created, an exception is raised. By default, it " "is the exception from the last address in the list. If *all_errors* is " @@ -1016,21 +1022,21 @@ msgid "" "attempts." msgstr "" -#: ../../library/socket.rst:888 +#: ../../library/socket.rst:892 msgid "*source_address* was added." msgstr "新增 *source_address*。" -#: ../../library/socket.rst:891 +#: ../../library/socket.rst:895 msgid "*all_errors* was added." msgstr "新增 *all_errors*。" -#: ../../library/socket.rst:897 +#: ../../library/socket.rst:901 msgid "" "Convenience function which creates a TCP socket bound to *address* (a 2-" "tuple ``(host, port)``) and returns the socket object." msgstr "" -#: ../../library/socket.rst:900 +#: ../../library/socket.rst:904 msgid "" "*family* should be either :data:`AF_INET` or :data:`AF_INET6`. *backlog* is " "the queue size passed to :meth:`socket.listen`; if not specified , a default " @@ -1038,7 +1044,7 @@ msgid "" "`SO_REUSEPORT` socket option." msgstr "" -#: ../../library/socket.rst:905 +#: ../../library/socket.rst:909 msgid "" "If *dualstack_ipv6* is true, *family* is :data:`AF_INET6` and the platform " "supports it the socket will be able to accept both IPv4 and IPv6 " @@ -1051,7 +1057,7 @@ msgid "" "parameter can be used in conjunction with :func:`has_dualstack_ipv6`:" msgstr "" -#: ../../library/socket.rst:918 +#: ../../library/socket.rst:922 msgid "" "import socket\n" "\n" @@ -1071,20 +1077,20 @@ msgstr "" "else:\n" " s = socket.create_server(addr)" -#: ../../library/socket.rst:927 +#: ../../library/socket.rst:931 msgid "" "On POSIX platforms the :data:`SO_REUSEADDR` socket option is set in order to " "immediately reuse previous sockets which were bound on the same *address* " "and remained in TIME_WAIT state." msgstr "" -#: ../../library/socket.rst:935 +#: ../../library/socket.rst:939 msgid "" "Return ``True`` if the platform supports creating a TCP socket which can " "handle both IPv4 and IPv6 connections." msgstr "" -#: ../../library/socket.rst:942 +#: ../../library/socket.rst:946 msgid "" "Duplicate the file descriptor *fd* (an integer as returned by a file " "object's :meth:`~io.IOBase.fileno` method) and build a socket object from " @@ -1097,42 +1103,42 @@ msgid "" "daemon). The socket is assumed to be in blocking mode." msgstr "" -#: ../../library/socket.rst:951 ../../library/socket.rst:1486 -#: ../../library/socket.rst:1541 ../../library/socket.rst:1635 +#: ../../library/socket.rst:955 ../../library/socket.rst:1499 +#: ../../library/socket.rst:1554 ../../library/socket.rst:1648 msgid "The newly created socket is :ref:`non-inheritable `." msgstr "" -#: ../../library/socket.rst:953 ../../library/socket.rst:1497 +#: ../../library/socket.rst:957 ../../library/socket.rst:1510 msgid "The returned socket is now non-inheritable." msgstr "" -#: ../../library/socket.rst:959 +#: ../../library/socket.rst:963 msgid "" "Instantiate a socket from data obtained from the :meth:`socket.share` " "method. The socket is assumed to be in blocking mode." msgstr "" -#: ../../library/socket.rst:968 +#: ../../library/socket.rst:972 msgid "Other functions" msgstr "其他函式" -#: ../../library/socket.rst:970 +#: ../../library/socket.rst:974 msgid "The :mod:`!socket` module also offers various network-related services:" msgstr "" -#: ../../library/socket.rst:975 +#: ../../library/socket.rst:979 msgid "" "Close a socket file descriptor. This is like :func:`os.close`, but for " "sockets. On some platforms (most notably Windows) :func:`os.close` does not " "work for socket file descriptors." msgstr "" -#: ../../library/socket.rst:983 +#: ../../library/socket.rst:987 msgid "" "This function wraps the C function ``getaddrinfo`` of the underlying system." msgstr "" -#: ../../library/socket.rst:985 +#: ../../library/socket.rst:989 msgid "" "Translate the *host*/*port* argument into a sequence of 5-tuples that " "contain all the necessary arguments for creating a socket connected to that " @@ -1142,7 +1148,7 @@ msgid "" "and *port*, you can pass ``NULL`` to the underlying C API." msgstr "" -#: ../../library/socket.rst:992 +#: ../../library/socket.rst:996 msgid "" "The *family*, *type* and *proto* arguments can be optionally specified in " "order to provide options and limit the list of addresses returned. Pass " @@ -1150,7 +1156,7 @@ msgid "" "limit the results. See the note below for details." msgstr "" -#: ../../library/socket.rst:997 +#: ../../library/socket.rst:1001 msgid "" "The *flags* argument can be one or several of the ``AI_*`` constants, and " "will influence how results are computed and returned. For example, :const:" @@ -1158,27 +1164,46 @@ msgid "" "if *host* is a domain name." msgstr "" -#: ../../library/socket.rst:1002 +#: ../../library/socket.rst:1006 msgid "The function returns a list of 5-tuples with the following structure:" msgstr "" -#: ../../library/socket.rst:1004 +#: ../../library/socket.rst:1008 msgid "``(family, type, proto, canonname, sockaddr)``" msgstr "``(family, type, proto, canonname, sockaddr)``" -#: ../../library/socket.rst:1006 +#: ../../library/socket.rst:1010 msgid "" "In these tuples, *family*, *type*, *proto* are all integers and are meant to " "be passed to the :func:`~socket.socket` function. *canonname* will be a " "string representing the canonical name of the *host* if :const:" "`AI_CANONNAME` is part of the *flags* argument; else *canonname* will be " "empty. *sockaddr* is a tuple describing a socket address, whose format " -"depends on the returned *family* (a ``(address, port)`` 2-tuple for :const:" -"`AF_INET`, a ``(address, port, flowinfo, scope_id)`` 4-tuple for :const:" -"`AF_INET6`), and is meant to be passed to the :meth:`socket.connect` method." +"depends on the returned *family* and flags Python was compiled with, and is " +"meant to be passed to the :meth:`socket.connect` method." msgstr "" #: ../../library/socket.rst:1018 +msgid "*sockaddr* can be one of the following:" +msgstr "" + +#: ../../library/socket.rst:1020 +msgid "a ``(address, port)`` 2-tuple for :const:`AF_INET`" +msgstr "" + +#: ../../library/socket.rst:1021 +msgid "" +"a ``(address, port, flowinfo, scope_id)`` 4-tuple for :const:`AF_INET6` if " +"Python was compiled with ``--enable-ipv6`` (the default)" +msgstr "" + +#: ../../library/socket.rst:1023 +msgid "" +"a 2-tuple containing raw data for :const:`AF_INET6` if Python was compiled " +"with ``--disable-ipv6``" +msgstr "" + +#: ../../library/socket.rst:1028 msgid "" "If you intend to use results from :func:`!getaddrinfo` to create a socket " "(rather than, for example, retrieve *canonname*), consider limiting the " @@ -1187,13 +1212,13 @@ msgid "" "application can handle." msgstr "" -#: ../../library/socket.rst:1024 +#: ../../library/socket.rst:1034 msgid "" "The behavior with default values of *family*, *type*, *proto* and *flags* is " "system-specific." msgstr "" -#: ../../library/socket.rst:1027 +#: ../../library/socket.rst:1037 msgid "" "Many systems (for example, most Linux configurations) will return a sorted " "list of all matching addresses. These addresses should generally be tried in " @@ -1203,14 +1228,14 @@ msgid "" "attempts." msgstr "" -#: ../../library/socket.rst:1034 +#: ../../library/socket.rst:1044 msgid "" "Some systems will, however, only return a single address. (For example, this " "was reported on Solaris and AIX configurations.) On these systems, limiting " "the *type* and/or *proto* helps ensure that this address is usable." msgstr "" -#: ../../library/socket.rst:1039 +#: ../../library/socket.rst:1049 msgid "" "Raises an :ref:`auditing event ` ``socket.getaddrinfo`` with " "arguments ``host``, ``port``, ``family``, ``type``, ``protocol``." @@ -1218,14 +1243,14 @@ msgstr "" "引發一個附帶引數 ``host``、``port``、``family``、``type``、``protocol`` 的" "\\ :ref:`稽核事件 ` ``socket.getaddrinfo``。" -#: ../../library/socket.rst:1041 +#: ../../library/socket.rst:1051 msgid "" "The following example fetches address information for a hypothetical TCP " "connection to ``example.org`` on port 80 (results may differ on your system " "if IPv6 isn't enabled)::" msgstr "" -#: ../../library/socket.rst:1045 +#: ../../library/socket.rst:1055 msgid "" ">>> socket.getaddrinfo(\"example.org\", 80, proto=socket.IPPROTO_TCP)\n" "[(socket.AF_INET6, socket.SOCK_STREAM,\n" @@ -1239,17 +1264,17 @@ msgstr "" " (socket.AF_INET, socket.SOCK_STREAM,\n" " 6, '', ('93.184.216.34', 80))]" -#: ../../library/socket.rst:1051 +#: ../../library/socket.rst:1061 msgid "parameters can now be passed using keyword arguments." msgstr "" -#: ../../library/socket.rst:1054 +#: ../../library/socket.rst:1064 msgid "" "for IPv6 multicast addresses, string representing an address will not " "contain ``%scope_id`` part." msgstr "" -#: ../../library/socket.rst:1062 +#: ../../library/socket.rst:1072 msgid "" "Return a fully qualified domain name for *name*. If *name* is omitted or " "empty, it is interpreted as the local host. To find the fully qualified " @@ -1260,7 +1285,7 @@ msgid "" "``'0.0.0.0'``, the hostname from :func:`gethostname` is returned." msgstr "" -#: ../../library/socket.rst:1073 +#: ../../library/socket.rst:1083 msgid "" "Translate a host name to IPv4 address format. The IPv4 address is returned " "as a string, such as ``'100.50.200.5'``. If the host name is an IPv4 " @@ -1270,7 +1295,7 @@ msgid "" "stack support." msgstr "" -#: ../../library/socket.rst:1079 ../../library/socket.rst:1095 +#: ../../library/socket.rst:1089 ../../library/socket.rst:1105 msgid "" "Raises an :ref:`auditing event ` ``socket.gethostbyname`` with " "argument ``hostname``." @@ -1278,7 +1303,7 @@ msgstr "" "引發一個附帶引數 ``hostname`` 的\\ :ref:`稽核事件 ` ``socket." "gethostbyname``。" -#: ../../library/socket.rst:1086 +#: ../../library/socket.rst:1096 msgid "" "Translate a host name to IPv4 address format, extended interface. Return a 3-" "tuple ``(hostname, aliaslist, ipaddrlist)`` where *hostname* is the host's " @@ -1290,26 +1315,26 @@ msgid "" "stack support." msgstr "" -#: ../../library/socket.rst:1102 +#: ../../library/socket.rst:1112 msgid "" "Return a string containing the hostname of the machine where the Python " "interpreter is currently executing." msgstr "" -#: ../../library/socket.rst:1105 +#: ../../library/socket.rst:1115 msgid "" "Raises an :ref:`auditing event ` ``socket.gethostname`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``socket.gethostname``。" -#: ../../library/socket.rst:1107 +#: ../../library/socket.rst:1117 msgid "" "Note: :func:`gethostname` doesn't always return the fully qualified domain " "name; use :func:`getfqdn` for that." msgstr "" -#: ../../library/socket.rst:1115 +#: ../../library/socket.rst:1125 msgid "" "Return a 3-tuple ``(hostname, aliaslist, ipaddrlist)`` where *hostname* is " "the primary host name responding to the given *ip_address*, *aliaslist* is a " @@ -1320,7 +1345,7 @@ msgid "" "`gethostbyaddr` supports both IPv4 and IPv6." msgstr "" -#: ../../library/socket.rst:1123 +#: ../../library/socket.rst:1133 msgid "" "Raises an :ref:`auditing event ` ``socket.gethostbyaddr`` with " "argument ``ip_address``." @@ -1328,7 +1353,7 @@ msgstr "" "引發一個附帶引數 ``ip_address`` 的\\ :ref:`稽核事件 ` ``socket." "gethostbyaddr``。" -#: ../../library/socket.rst:1130 +#: ../../library/socket.rst:1140 msgid "" "Translate a socket address *sockaddr* into a 2-tuple ``(host, port)``. " "Depending on the settings of *flags*, the result can contain a fully " @@ -1336,18 +1361,18 @@ msgid "" "Similarly, *port* can contain a string port name or a numeric port number." msgstr "" -#: ../../library/socket.rst:1135 +#: ../../library/socket.rst:1145 msgid "" "For IPv6 addresses, ``%scope_id`` is appended to the host part if *sockaddr* " "contains meaningful *scope_id*. Usually this happens for multicast addresses." msgstr "" -#: ../../library/socket.rst:1138 +#: ../../library/socket.rst:1148 msgid "" "For more information about *flags* you can consult :manpage:`getnameinfo(3)`." msgstr "" -#: ../../library/socket.rst:1140 +#: ../../library/socket.rst:1150 msgid "" "Raises an :ref:`auditing event ` ``socket.getnameinfo`` with " "argument ``sockaddr``." @@ -1355,7 +1380,7 @@ msgstr "" "引發一個附帶引數 ``sockaddr`` 的\\ :ref:`稽核事件 ` ``socket." "getnameinfo``。" -#: ../../library/socket.rst:1147 +#: ../../library/socket.rst:1157 msgid "" "Translate an internet protocol name (for example, ``'icmp'``) to a constant " "suitable for passing as the (optional) third argument to the :func:`~socket." @@ -1364,14 +1389,14 @@ msgid "" "is chosen automatically if the protocol is omitted or zero." msgstr "" -#: ../../library/socket.rst:1158 +#: ../../library/socket.rst:1168 msgid "" "Translate an internet service name and protocol name to a port number for " "that service. The optional protocol name, if given, should be ``'tcp'`` or " "``'udp'``, otherwise any protocol will match." msgstr "" -#: ../../library/socket.rst:1162 +#: ../../library/socket.rst:1172 msgid "" "Raises an :ref:`auditing event ` ``socket.getservbyname`` with " "arguments ``servicename``, ``protocolname``." @@ -1379,14 +1404,14 @@ msgstr "" "引發一個附帶引數 ``sockaddr``、``protocolname`` 的\\ :ref:`稽核事件 " "` ``socket.getservbyname``。" -#: ../../library/socket.rst:1169 +#: ../../library/socket.rst:1179 msgid "" "Translate an internet port number and protocol name to a service name for " "that service. The optional protocol name, if given, should be ``'tcp'`` or " "``'udp'``, otherwise any protocol will match." msgstr "" -#: ../../library/socket.rst:1173 +#: ../../library/socket.rst:1183 msgid "" "Raises an :ref:`auditing event ` ``socket.getservbyport`` with " "arguments ``port``, ``protocolname``." @@ -1394,40 +1419,40 @@ msgstr "" "引發一個附帶引數 ``port``、``protocolname`` 的\\ :ref:`稽核事件 ` " "``socket.getservbyport``。" -#: ../../library/socket.rst:1180 +#: ../../library/socket.rst:1190 msgid "" "Convert 32-bit positive integers from network to host byte order. On " "machines where the host byte order is the same as network byte order, this " "is a no-op; otherwise, it performs a 4-byte swap operation." msgstr "" -#: ../../library/socket.rst:1187 +#: ../../library/socket.rst:1197 msgid "" "Convert 16-bit positive integers from network to host byte order. On " "machines where the host byte order is the same as network byte order, this " "is a no-op; otherwise, it performs a 2-byte swap operation." msgstr "" -#: ../../library/socket.rst:1191 ../../library/socket.rst:1209 +#: ../../library/socket.rst:1201 ../../library/socket.rst:1219 msgid "" "Raises :exc:`OverflowError` if *x* does not fit in a 16-bit unsigned integer." msgstr "" -#: ../../library/socket.rst:1198 +#: ../../library/socket.rst:1208 msgid "" "Convert 32-bit positive integers from host to network byte order. On " "machines where the host byte order is the same as network byte order, this " "is a no-op; otherwise, it performs a 4-byte swap operation." msgstr "" -#: ../../library/socket.rst:1205 +#: ../../library/socket.rst:1215 msgid "" "Convert 16-bit positive integers from host to network byte order. On " "machines where the host byte order is the same as network byte order, this " "is a no-op; otherwise, it performs a 2-byte swap operation." msgstr "" -#: ../../library/socket.rst:1216 +#: ../../library/socket.rst:1226 msgid "" "Convert an IPv4 address from dotted-quad string format (for example, " "'123.45.67.89') to 32-bit packed binary format, as a bytes object four " @@ -1436,26 +1461,26 @@ msgid "" "which is the C type for the 32-bit packed binary this function returns." msgstr "" -#: ../../library/socket.rst:1222 +#: ../../library/socket.rst:1232 msgid "" ":func:`inet_aton` also accepts strings with less than three dots; see the " "Unix manual page :manpage:`inet(3)` for details." msgstr "" -#: ../../library/socket.rst:1225 +#: ../../library/socket.rst:1235 msgid "" "If the IPv4 address string passed to this function is invalid, :exc:" "`OSError` will be raised. Note that exactly what is valid depends on the " "underlying C implementation of :c:func:`inet_aton`." msgstr "" -#: ../../library/socket.rst:1229 +#: ../../library/socket.rst:1239 msgid "" ":func:`inet_aton` does not support IPv6, and :func:`inet_pton` should be " "used instead for IPv4/v6 dual stack support." msgstr "" -#: ../../library/socket.rst:1235 +#: ../../library/socket.rst:1245 msgid "" "Convert a 32-bit packed IPv4 address (a :term:`bytes-like object` four bytes " "in length) to its standard dotted-quad string representation (for example, " @@ -1465,7 +1490,7 @@ msgid "" "argument." msgstr "" -#: ../../library/socket.rst:1242 +#: ../../library/socket.rst:1252 msgid "" "If the byte sequence passed to this function is not exactly 4 bytes in " "length, :exc:`OSError` will be raised. :func:`inet_ntoa` does not support " @@ -1473,7 +1498,7 @@ msgid "" "support." msgstr "" -#: ../../library/socket.rst:1253 +#: ../../library/socket.rst:1263 msgid "" "Convert an IP address from its family-specific string format to a packed, " "binary format. :func:`inet_pton` is useful when a library or network " @@ -1481,7 +1506,7 @@ msgid "" "`inet_aton`) or :c:struct:`in6_addr`." msgstr "" -#: ../../library/socket.rst:1258 +#: ../../library/socket.rst:1268 msgid "" "Supported values for *address_family* are currently :const:`AF_INET` and :" "const:`AF_INET6`. If the IP address string *ip_string* is invalid, :exc:" @@ -1490,11 +1515,11 @@ msgid "" "`inet_pton`." msgstr "" -#: ../../library/socket.rst:1266 ../../library/socket.rst:1286 +#: ../../library/socket.rst:1276 ../../library/socket.rst:1296 msgid "Windows support added" msgstr "" -#: ../../library/socket.rst:1272 +#: ../../library/socket.rst:1282 msgid "" "Convert a packed IP address (a :term:`bytes-like object` of some number of " "bytes) to its standard, family-specific string representation (for example, " @@ -1503,7 +1528,7 @@ msgid "" "(similar to :func:`inet_ntoa`) or :c:struct:`in6_addr`." msgstr "" -#: ../../library/socket.rst:1279 +#: ../../library/socket.rst:1289 msgid "" "Supported values for *address_family* are currently :const:`AF_INET` and :" "const:`AF_INET6`. If the bytes object *packed_ip* is not the correct length " @@ -1511,7 +1536,7 @@ msgid "" "`OSError` is raised for errors from the call to :func:`inet_ntop`." msgstr "" -#: ../../library/socket.rst:1301 +#: ../../library/socket.rst:1311 msgid "" "Return the total length, without trailing padding, of an ancillary data item " "with associated data of the given *length*. This value can often be used as " @@ -1522,12 +1547,12 @@ msgid "" "the permissible range of values." msgstr "" -#: ../../library/socket.rst:1312 ../../library/socket.rst:1861 -#: ../../library/socket.rst:1905 ../../library/socket.rst:2013 +#: ../../library/socket.rst:1322 ../../library/socket.rst:1874 +#: ../../library/socket.rst:1918 ../../library/socket.rst:2026 msgid "Most Unix platforms." msgstr "" -#: ../../library/socket.rst:1319 +#: ../../library/socket.rst:1329 msgid "" "Return the buffer size needed for :meth:`~socket.recvmsg` to receive an " "ancillary data item with associated data of the given *length*, along with " @@ -1537,7 +1562,7 @@ msgid "" "values." msgstr "" -#: ../../library/socket.rst:1327 +#: ../../library/socket.rst:1337 msgid "" "Note that some systems might support ancillary data without providing this " "function. Also note that setting the buffer size using the results of this " @@ -1545,31 +1570,35 @@ msgid "" "received, since additional data may be able to fit into the padding area." msgstr "" -#: ../../library/socket.rst:1335 +#: ../../library/socket.rst:1345 msgid "most Unix platforms." msgstr "" -#: ../../library/socket.rst:1342 +#: ../../library/socket.rst:1352 msgid "" "Return the default timeout in seconds (float) for new socket objects. A " "value of ``None`` indicates that new socket objects have no timeout. When " "the socket module is first imported, the default is ``None``." msgstr "" -#: ../../library/socket.rst:1349 +#: ../../library/socket.rst:1359 msgid "" -"Set the default timeout in seconds (float) for new socket objects. When the " -"socket module is first imported, the default is ``None``. See :meth:" -"`~socket.settimeout` for possible values and their respective meanings." +"Set the default timeout in seconds (real number) for new socket objects. " +"When the socket module is first imported, the default is ``None``. See :" +"meth:`~socket.settimeout` for possible values and their respective meanings." msgstr "" -#: ../../library/socket.rst:1357 +#: ../../library/socket.rst:1364 ../../library/socket.rst:2101 +msgid "Accepts any real number, not only integer or float." +msgstr "" + +#: ../../library/socket.rst:1370 msgid "" "Set the machine's hostname to *name*. This will raise an :exc:`OSError` if " "you don't have enough rights." msgstr "" -#: ../../library/socket.rst:1360 +#: ../../library/socket.rst:1373 msgid "" "Raises an :ref:`auditing event ` ``socket.sethostname`` with " "argument ``name``." @@ -1577,96 +1606,96 @@ msgstr "" "引發一個附帶引數 ``name`` 的\\ :ref:`稽核事件 ` ``socket." "sethostname``。" -#: ../../library/socket.rst:1369 +#: ../../library/socket.rst:1382 msgid "" "Return a list of network interface information (index int, name string) " "tuples. :exc:`OSError` if the system call fails." msgstr "" -#: ../../library/socket.rst:1377 ../../library/socket.rst:1404 -#: ../../library/socket.rst:1421 +#: ../../library/socket.rst:1390 ../../library/socket.rst:1417 +#: ../../library/socket.rst:1434 msgid "Windows support was added." msgstr "增加對 Windows 的支援。" -#: ../../library/socket.rst:1382 +#: ../../library/socket.rst:1395 msgid "" "On Windows network interfaces have different names in different contexts " "(all names are examples):" msgstr "" -#: ../../library/socket.rst:1385 +#: ../../library/socket.rst:1398 msgid "UUID: ``{FB605B73-AAC2-49A6-9A2F-25416AEA0573}``" msgstr "UUID: ``{FB605B73-AAC2-49A6-9A2F-25416AEA0573}``" -#: ../../library/socket.rst:1386 +#: ../../library/socket.rst:1399 msgid "name: ``ethernet_32770``" msgstr "" -#: ../../library/socket.rst:1387 +#: ../../library/socket.rst:1400 msgid "friendly name: ``vEthernet (nat)``" msgstr "" -#: ../../library/socket.rst:1388 +#: ../../library/socket.rst:1401 msgid "description: ``Hyper-V Virtual Ethernet Adapter``" msgstr "" -#: ../../library/socket.rst:1390 +#: ../../library/socket.rst:1403 msgid "" "This function returns names of the second form from the list, " "``ethernet_32770`` in this example case." msgstr "" -#: ../../library/socket.rst:1396 +#: ../../library/socket.rst:1409 msgid "" "Return a network interface index number corresponding to an interface name. :" "exc:`OSError` if no interface with the given name exists." msgstr "" -#: ../../library/socket.rst:1408 ../../library/socket.rst:1425 +#: ../../library/socket.rst:1421 ../../library/socket.rst:1438 msgid "\"Interface name\" is a name as documented in :func:`if_nameindex`." msgstr "" -#: ../../library/socket.rst:1413 +#: ../../library/socket.rst:1426 msgid "" "Return a network interface name corresponding to an interface index number. :" "exc:`OSError` if no interface with the given index exists." msgstr "" -#: ../../library/socket.rst:1430 +#: ../../library/socket.rst:1443 msgid "" "Send the list of file descriptors *fds* over an :const:`AF_UNIX` socket " "*sock*. The *fds* parameter is a sequence of file descriptors. Consult :meth:" "`~socket.sendmsg` for the documentation of these parameters." msgstr "" -#: ../../library/socket.rst:1436 +#: ../../library/socket.rst:1449 msgid "" "Unix platforms supporting :meth:`~socket.sendmsg` and :const:`SCM_RIGHTS` " "mechanism." msgstr "" -#: ../../library/socket.rst:1444 +#: ../../library/socket.rst:1457 msgid "" "Receive up to *maxfds* file descriptors from an :const:`AF_UNIX` socket " "*sock*. Return ``(msg, list(fds), flags, addr)``. Consult :meth:`~socket." "recvmsg` for the documentation of these parameters." msgstr "" -#: ../../library/socket.rst:1450 +#: ../../library/socket.rst:1463 msgid "" "Unix platforms supporting :meth:`~socket.recvmsg` and :const:`SCM_RIGHTS` " "mechanism." msgstr "" -#: ../../library/socket.rst:1457 +#: ../../library/socket.rst:1470 msgid "Any truncated integers at the end of the list of file descriptors." msgstr "" -#: ../../library/socket.rst:1463 +#: ../../library/socket.rst:1476 msgid "Socket Objects" msgstr "Socket 物件" -#: ../../library/socket.rst:1467 +#: ../../library/socket.rst:1480 msgid "" "Create a new socket using the given address family, socket type and protocol " "number. The address family should be :const:`AF_INET` (the default), :const:" @@ -1679,7 +1708,7 @@ msgid "" "`CAN_J1939`." msgstr "" -#: ../../library/socket.rst:1477 +#: ../../library/socket.rst:1490 msgid "" "If *fileno* is specified, the values for *family*, *type*, and *proto* are " "auto-detected from the specified file descriptor. Auto-detection can be " @@ -1690,7 +1719,7 @@ msgid "" "This may help close a detached socket using :meth:`~socket.socket.close`." msgstr "" -#: ../../library/socket.rst:1488 +#: ../../library/socket.rst:1501 msgid "" "Raises an :ref:`auditing event ` ``socket.__new__`` with arguments " "``self``, ``family``, ``type``, ``protocol``." @@ -1698,26 +1727,26 @@ msgstr "" "引發一個附帶引數 ``self``、``family``、``type``、``protocol`` 的\\ :ref:`稽核" "事件 ` ``socket.__new__``。" -#: ../../library/socket.rst:1490 +#: ../../library/socket.rst:1503 msgid "The AF_CAN family was added. The AF_RDS family was added." msgstr "" -#: ../../library/socket.rst:1494 +#: ../../library/socket.rst:1507 msgid "The CAN_BCM protocol was added." msgstr "新增 CAN_BCM 協定。" -#: ../../library/socket.rst:1500 +#: ../../library/socket.rst:1513 msgid "The CAN_ISOTP protocol was added." msgstr "新增 CAN_ISOTP 協定。" -#: ../../library/socket.rst:1503 +#: ../../library/socket.rst:1516 msgid "" "When :const:`SOCK_NONBLOCK` or :const:`SOCK_CLOEXEC` bit flags are applied " "to *type* they are cleared, and :attr:`socket.type` will not reflect them. " "They are still passed to the underlying system ``socket()`` call. Therefore," msgstr "" -#: ../../library/socket.rst:1511 +#: ../../library/socket.rst:1524 msgid "" "sock = socket.socket(\n" " socket.AF_INET,\n" @@ -1727,33 +1756,33 @@ msgstr "" " socket.AF_INET,\n" " socket.SOCK_STREAM | socket.SOCK_NONBLOCK)" -#: ../../library/socket.rst:1515 +#: ../../library/socket.rst:1528 msgid "" "will still create a non-blocking socket on OSes that support " "``SOCK_NONBLOCK``, but ``sock.type`` will be set to ``socket.SOCK_STREAM``." msgstr "" -#: ../../library/socket.rst:1519 +#: ../../library/socket.rst:1532 msgid "The CAN_J1939 protocol was added." msgstr "新增 CAN_J1939 協定。" -#: ../../library/socket.rst:1522 +#: ../../library/socket.rst:1535 msgid "The IPPROTO_MPTCP protocol was added." msgstr "新增 IPPROTO_MPTCP 協定。" -#: ../../library/socket.rst:1525 +#: ../../library/socket.rst:1538 msgid "" "Socket objects have the following methods. Except for :meth:`~socket." "makefile`, these correspond to Unix system calls applicable to sockets." msgstr "" -#: ../../library/socket.rst:1529 +#: ../../library/socket.rst:1542 msgid "" "Support for the :term:`context manager` protocol was added. Exiting the " "context manager is equivalent to calling :meth:`~socket.socket.close`." msgstr "" -#: ../../library/socket.rst:1536 +#: ../../library/socket.rst:1549 msgid "" "Accept a connection. The socket must be bound to an address and listening " "for connections. The return value is a pair ``(conn, address)`` where *conn* " @@ -1762,28 +1791,28 @@ msgid "" "connection." msgstr "" -#: ../../library/socket.rst:1543 ../../library/socket.rst:1637 +#: ../../library/socket.rst:1556 ../../library/socket.rst:1650 msgid "The socket is now non-inheritable." msgstr "" -#: ../../library/socket.rst:1546 ../../library/socket.rst:1773 -#: ../../library/socket.rst:1788 ../../library/socket.rst:1865 -#: ../../library/socket.rst:1938 ../../library/socket.rst:1957 -#: ../../library/socket.rst:1974 ../../library/socket.rst:2019 +#: ../../library/socket.rst:1559 ../../library/socket.rst:1786 +#: ../../library/socket.rst:1801 ../../library/socket.rst:1878 +#: ../../library/socket.rst:1951 ../../library/socket.rst:1970 +#: ../../library/socket.rst:1987 ../../library/socket.rst:2032 msgid "" "If the system call is interrupted and the signal handler does not raise an " "exception, the method now retries the system call instead of raising an :exc:" "`InterruptedError` exception (see :pep:`475` for the rationale)." msgstr "" -#: ../../library/socket.rst:1554 +#: ../../library/socket.rst:1567 msgid "" "Bind the socket to *address*. The socket must not already be bound. The " "format of *address* depends on the address family --- see :ref:`socket-" "addresses`." msgstr "" -#: ../../library/socket.rst:1557 +#: ../../library/socket.rst:1570 msgid "" "Raises an :ref:`auditing event ` ``socket.bind`` with arguments " "``self``, ``address``." @@ -1791,7 +1820,7 @@ msgstr "" "引發一個附帶引數 ``self``、``address`` 的\\ :ref:`稽核事件 ` " "``socket.bind``。" -#: ../../library/socket.rst:1564 +#: ../../library/socket.rst:1577 msgid "" "Mark the socket closed. The underlying system resource (e.g. a file " "descriptor) is also closed when all file objects from :meth:`makefile` are " @@ -1800,33 +1829,33 @@ msgid "" "flushed)." msgstr "" -#: ../../library/socket.rst:1570 +#: ../../library/socket.rst:1583 msgid "" "Sockets are automatically closed when they are garbage-collected, but it is " "recommended to :meth:`close` them explicitly, or to use a :keyword:`with` " "statement around them." msgstr "" -#: ../../library/socket.rst:1574 +#: ../../library/socket.rst:1587 msgid "" ":exc:`OSError` is now raised if an error occurs when the underlying :c:func:" "`!close` call is made." msgstr "" -#: ../../library/socket.rst:1580 +#: ../../library/socket.rst:1593 msgid "" ":meth:`close` releases the resource associated with a connection but does " "not necessarily close the connection immediately. If you want to close the " "connection in a timely fashion, call :meth:`shutdown` before :meth:`close`." msgstr "" -#: ../../library/socket.rst:1588 +#: ../../library/socket.rst:1601 msgid "" "Connect to a remote socket at *address*. The format of *address* depends on " "the address family --- see :ref:`socket-addresses`." msgstr "" -#: ../../library/socket.rst:1591 +#: ../../library/socket.rst:1604 msgid "" "If the connection is interrupted by a signal, the method waits until the " "connection completes, or raises a :exc:`TimeoutError` on timeout, if the " @@ -1836,7 +1865,7 @@ msgid "" "(or the exception raised by the signal handler)." msgstr "" -#: ../../library/socket.rst:1598 ../../library/socket.rst:1618 +#: ../../library/socket.rst:1611 ../../library/socket.rst:1631 msgid "" "Raises an :ref:`auditing event ` ``socket.connect`` with arguments " "``self``, ``address``." @@ -1844,7 +1873,7 @@ msgstr "" "引發一個附帶引數 ``self``、``address`` 的\\ :ref:`稽核事件 ` " "``socket.connect``。" -#: ../../library/socket.rst:1600 +#: ../../library/socket.rst:1613 msgid "" "The method now waits until the connection completes instead of raising an :" "exc:`InterruptedError` exception if the connection is interrupted by a " @@ -1852,7 +1881,7 @@ msgid "" "blocking or has a timeout (see the :pep:`475` for the rationale)." msgstr "" -#: ../../library/socket.rst:1611 +#: ../../library/socket.rst:1624 msgid "" "Like ``connect(address)``, but return an error indicator instead of raising " "an exception for errors returned by the C-level :c:func:`!connect` call " @@ -1862,38 +1891,38 @@ msgid "" "asynchronous connects." msgstr "" -#: ../../library/socket.rst:1624 +#: ../../library/socket.rst:1637 msgid "" "Put the socket object into closed state without actually closing the " "underlying file descriptor. The file descriptor is returned, and can be " "reused for other purposes." msgstr "" -#: ../../library/socket.rst:1633 +#: ../../library/socket.rst:1646 msgid "Duplicate the socket." msgstr "" -#: ../../library/socket.rst:1645 +#: ../../library/socket.rst:1658 msgid "" "Return the socket's file descriptor (a small integer), or -1 on failure. " "This is useful with :func:`select.select`." msgstr "" -#: ../../library/socket.rst:1648 +#: ../../library/socket.rst:1661 msgid "" "Under Windows the small integer returned by this method cannot be used where " "a file descriptor can be used (such as :func:`os.fdopen`). Unix does not " "have this limitation." msgstr "" -#: ../../library/socket.rst:1654 +#: ../../library/socket.rst:1667 msgid "" "Get the :ref:`inheritable flag ` of the socket's file " "descriptor or socket's handle: ``True`` if the socket can be inherited in " "child processes, ``False`` if it cannot." msgstr "" -#: ../../library/socket.rst:1663 +#: ../../library/socket.rst:1676 msgid "" "Return the remote address to which the socket is connected. This is useful " "to find out the port number of a remote IPv4/v6 socket, for instance. The " @@ -1901,14 +1930,14 @@ msgid "" "`socket-addresses`. On some systems this function is not supported." msgstr "" -#: ../../library/socket.rst:1671 +#: ../../library/socket.rst:1684 msgid "" "Return the socket's own address. This is useful to find out the port number " "of an IPv4/v6 socket, for instance. The format of the address returned " "depends on the address family --- see :ref:`socket-addresses`." msgstr "" -#: ../../library/socket.rst:1678 +#: ../../library/socket.rst:1691 msgid "" "Return the value of the given socket option (see the Unix man page :manpage:" "`getsockopt(2)`). The needed symbolic constants (:ref:`SO_\\* etc. `_ for more information." msgstr "" -#: ../../library/socket.rst:1714 +#: ../../library/socket.rst:1727 msgid "" "On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl` " "functions may be used; they accept a socket object as their first argument." msgstr "" -#: ../../library/socket.rst:1717 +#: ../../library/socket.rst:1730 msgid "" "Currently only the following control codes are supported: ``SIO_RCVALL``, " "``SIO_KEEPALIVE_VALS``, and ``SIO_LOOPBACK_FAST_PATH``." msgstr "" -#: ../../library/socket.rst:1728 +#: ../../library/socket.rst:1741 msgid "" "Enable a server to accept connections. If *backlog* is specified, it must " "be at least 0 (if it is lower, it is set to 0); it specifies the number of " @@ -1964,11 +1993,11 @@ msgid "" "connections. If not specified, a default reasonable value is chosen." msgstr "" -#: ../../library/socket.rst:1735 +#: ../../library/socket.rst:1748 msgid "The *backlog* parameter is now optional." msgstr "" -#: ../../library/socket.rst:1744 +#: ../../library/socket.rst:1757 msgid "" "Return a :term:`file object` associated with the socket. The exact returned " "type depends on the arguments given to :meth:`makefile`. These arguments " @@ -1977,28 +2006,28 @@ msgid "" "``'b'``, or a combination of those." msgstr "" -#: ../../library/socket.rst:1750 +#: ../../library/socket.rst:1763 msgid "" "The socket must be in blocking mode; it can have a timeout, but the file " "object's internal buffer may end up in an inconsistent state if a timeout " "occurs." msgstr "" -#: ../../library/socket.rst:1754 +#: ../../library/socket.rst:1767 msgid "" "Closing the file object returned by :meth:`makefile` won't close the " "original socket unless all other file objects have been closed and :meth:" "`~socket.socket.close` has been called on the socket object." msgstr "" -#: ../../library/socket.rst:1760 +#: ../../library/socket.rst:1773 msgid "" "On Windows, the file-like object created by :meth:`makefile` cannot be used " "where a file object with a file descriptor is expected, such as the stream " "arguments of :meth:`subprocess.Popen`." msgstr "" -#: ../../library/socket.rst:1767 +#: ../../library/socket.rst:1780 msgid "" "Receive data from the socket. The return value is a bytes object " "representing the data received. The maximum amount of data to be received " @@ -2008,7 +2037,7 @@ msgid "" "zero." msgstr "" -#: ../../library/socket.rst:1781 +#: ../../library/socket.rst:1794 msgid "" "Receive data from the socket. The return value is a pair ``(bytes, " "address)`` where *bytes* is a bytes object representing the data received " @@ -2018,14 +2047,14 @@ msgid "" "family --- see :ref:`socket-addresses`." msgstr "" -#: ../../library/socket.rst:1793 +#: ../../library/socket.rst:1806 msgid "" "For multicast IPv6 address, first item of *address* does not contain " "``%scope_id`` part anymore. In order to get full IPv6 address use :func:" "`getnameinfo`." msgstr "" -#: ../../library/socket.rst:1800 +#: ../../library/socket.rst:1813 msgid "" "Receive normal data (up to *bufsize* bytes) and ancillary data from the " "socket. The *ancbufsize* argument sets the size in bytes of the internal " @@ -2036,7 +2065,7 @@ msgid "" "*flags* argument defaults to 0 and has the same meaning as for :meth:`recv`." msgstr "" -#: ../../library/socket.rst:1810 +#: ../../library/socket.rst:1823 msgid "" "The return value is a 4-tuple: ``(data, ancdata, msg_flags, address)``. The " "*data* item is a :class:`bytes` object holding the non-ancillary data " @@ -2051,7 +2080,7 @@ msgid "" "socket, if available; otherwise, its value is unspecified." msgstr "" -#: ../../library/socket.rst:1824 +#: ../../library/socket.rst:1837 msgid "" "On some systems, :meth:`sendmsg` and :meth:`recvmsg` can be used to pass " "file descriptors between processes over an :const:`AF_UNIX` socket. When " @@ -2064,7 +2093,7 @@ msgid "" "descriptors received via this mechanism." msgstr "" -#: ../../library/socket.rst:1835 +#: ../../library/socket.rst:1848 msgid "" "Some systems do not indicate the truncated length of ancillary data items " "which have been only partially received. If an item appears to extend " @@ -2073,7 +2102,7 @@ msgid "" "provided it has not been truncated before the start of its associated data." msgstr "" -#: ../../library/socket.rst:1842 +#: ../../library/socket.rst:1855 msgid "" "On systems which support the :const:`!SCM_RIGHTS` mechanism, the following " "function will receive up to *maxfds* file descriptors, returning the message " @@ -2082,7 +2111,7 @@ msgid "" "meth:`sendmsg`. ::" msgstr "" -#: ../../library/socket.rst:1848 +#: ../../library/socket.rst:1861 msgid "" "import socket, array\n" "\n" @@ -2099,7 +2128,7 @@ msgid "" " return msg, list(fds)" msgstr "" -#: ../../library/socket.rst:1873 +#: ../../library/socket.rst:1886 msgid "" "Receive normal data and ancillary data from the socket, behaving as :meth:" "`recvmsg` would, but scatter the non-ancillary data into a series of buffers " @@ -2112,7 +2141,7 @@ msgid "" "arguments have the same meaning as for :meth:`recvmsg`." msgstr "" -#: ../../library/socket.rst:1884 +#: ../../library/socket.rst:1897 msgid "" "The return value is a 4-tuple: ``(nbytes, ancdata, msg_flags, address)``, " "where *nbytes* is the total number of bytes of non-ancillary data written " @@ -2120,11 +2149,11 @@ msgid "" "for :meth:`recvmsg`." msgstr "" -#: ../../library/socket.rst:1889 +#: ../../library/socket.rst:1902 msgid "Example::" msgstr "範例: ::" -#: ../../library/socket.rst:1891 +#: ../../library/socket.rst:1904 msgid "" ">>> import socket\n" ">>> s1, s2 = socket.socketpair()\n" @@ -2150,7 +2179,7 @@ msgstr "" ">>> [b1, b2, b3]\n" "[bytearray(b'Mary'), bytearray(b'01 had a 9'), bytearray(b'little lamb---')]" -#: ../../library/socket.rst:1912 +#: ../../library/socket.rst:1925 msgid "" "Receive data from the socket, writing it into *buffer* instead of creating a " "new bytestring. The return value is a pair ``(nbytes, address)`` where " @@ -2161,7 +2190,7 @@ msgid "" "addresses`." msgstr "" -#: ../../library/socket.rst:1922 +#: ../../library/socket.rst:1935 msgid "" "Receive up to *nbytes* bytes from the socket, storing the data into a buffer " "rather than creating a new bytestring. If *nbytes* is not specified (or 0), " @@ -2170,7 +2199,7 @@ msgid "" "of the optional argument *flags*; it defaults to zero." msgstr "" -#: ../../library/socket.rst:1931 +#: ../../library/socket.rst:1944 msgid "" "Send data to the socket. The socket must be connected to a remote socket. " "The optional *flags* argument has the same meaning as for :meth:`recv`. " @@ -2180,7 +2209,7 @@ msgid "" "information on this topic, consult the :ref:`socket-howto`." msgstr "" -#: ../../library/socket.rst:1946 +#: ../../library/socket.rst:1959 msgid "" "Send data to the socket. The socket must be connected to a remote socket. " "The optional *flags* argument has the same meaning as for :meth:`recv`. " @@ -2190,13 +2219,13 @@ msgid "" "how much data, if any, was successfully sent." msgstr "" -#: ../../library/socket.rst:1953 +#: ../../library/socket.rst:1966 msgid "" "The socket timeout is no longer reset each time data is sent successfully. " "The socket timeout is now the maximum total duration to send all data." msgstr "" -#: ../../library/socket.rst:1966 +#: ../../library/socket.rst:1979 msgid "" "Send data to the socket. The socket should not be connected to a remote " "socket, since the destination socket is specified by *address*. The " @@ -2205,7 +2234,7 @@ msgid "" "family --- see :ref:`socket-addresses`." msgstr "" -#: ../../library/socket.rst:1972 +#: ../../library/socket.rst:1985 msgid "" "Raises an :ref:`auditing event ` ``socket.sendto`` with arguments " "``self``, ``address``." @@ -2213,7 +2242,7 @@ msgstr "" "引發一個附帶引數 ``self``、``address`` 的\\ :ref:`稽核事件 ` " "``socket.sendto``。" -#: ../../library/socket.rst:1982 +#: ../../library/socket.rst:1995 msgid "" "Send normal and ancillary data to the socket, gathering the non-ancillary " "data from a series of buffers and concatenating it into a single message. " @@ -2233,14 +2262,14 @@ msgid "" "bytes of non-ancillary data sent." msgstr "" -#: ../../library/socket.rst:2002 +#: ../../library/socket.rst:2015 msgid "" "The following function sends the list of file descriptors *fds* over an :" "const:`AF_UNIX` socket, on systems which support the :const:`!SCM_RIGHTS` " "mechanism. See also :meth:`recvmsg`. ::" msgstr "" -#: ../../library/socket.rst:2006 +#: ../../library/socket.rst:2019 msgid "" "import socket, array\n" "\n" @@ -2254,7 +2283,7 @@ msgstr "" " return sock.sendmsg([msg], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array." "array(\"i\", fds))])" -#: ../../library/socket.rst:2015 +#: ../../library/socket.rst:2028 msgid "" "Raises an :ref:`auditing event ` ``socket.sendmsg`` with arguments " "``self``, ``address``." @@ -2262,14 +2291,14 @@ msgstr "" "引發一個附帶引數 ``self``、``address`` 的\\ :ref:`稽核事件 ` " "``socket.sendmsg``。" -#: ../../library/socket.rst:2026 +#: ../../library/socket.rst:2039 msgid "" "Specialized version of :meth:`~socket.sendmsg` for :const:`AF_ALG` socket. " "Set mode, IV, AEAD associated data length and flags for :const:`AF_ALG` " "socket." msgstr "" -#: ../../library/socket.rst:2035 +#: ../../library/socket.rst:2048 msgid "" "Send a file until EOF is reached by using high-performance :mod:`os." "sendfile` and return the total number of bytes which were sent. *file* must " @@ -2283,38 +2312,38 @@ msgid "" "be of :const:`SOCK_STREAM` type. Non-blocking sockets are not supported." msgstr "" -#: ../../library/socket.rst:2051 +#: ../../library/socket.rst:2064 msgid "" "Set the :ref:`inheritable flag ` of the socket's file " "descriptor or socket's handle." msgstr "" -#: ../../library/socket.rst:2059 +#: ../../library/socket.rst:2072 msgid "" "Set blocking or non-blocking mode of the socket: if *flag* is false, the " "socket is set to non-blocking, else to blocking mode." msgstr "" -#: ../../library/socket.rst:2062 +#: ../../library/socket.rst:2075 msgid "" "This method is a shorthand for certain :meth:`~socket.settimeout` calls:" msgstr "" -#: ../../library/socket.rst:2064 +#: ../../library/socket.rst:2077 msgid "``sock.setblocking(True)`` is equivalent to ``sock.settimeout(None)``" msgstr "``sock.setblocking(True)`` 等價於 ``sock.settimeout(None)``" -#: ../../library/socket.rst:2066 +#: ../../library/socket.rst:2079 msgid "``sock.setblocking(False)`` is equivalent to ``sock.settimeout(0.0)``" msgstr "``sock.setblocking(False)`` 等價於 ``sock.settimeout(0.0)``" -#: ../../library/socket.rst:2068 +#: ../../library/socket.rst:2081 msgid "" "The method no longer applies :const:`SOCK_NONBLOCK` flag on :attr:`socket." "type`." msgstr "" -#: ../../library/socket.rst:2075 +#: ../../library/socket.rst:2088 msgid "" "Set a timeout on blocking socket operations. The *value* argument can be a " "nonnegative real number expressing seconds, or ``None``. If a non-zero value " @@ -2324,19 +2353,19 @@ msgid "" "``None`` is given, the socket is put in blocking mode." msgstr "" -#: ../../library/socket.rst:2082 +#: ../../library/socket.rst:2095 msgid "" "For further information, please consult the :ref:`notes on socket timeouts " "`." msgstr "" -#: ../../library/socket.rst:2084 +#: ../../library/socket.rst:2097 msgid "" "The method no longer toggles :const:`SOCK_NONBLOCK` flag on :attr:`socket." "type`." msgstr "" -#: ../../library/socket.rst:2094 +#: ../../library/socket.rst:2110 msgid "" "Set the value of the given socket option (see the Unix manual page :manpage:" "`setsockopt(2)`). The needed symbolic constants are defined in this module " @@ -2349,11 +2378,11 @@ msgid "" "setsockopt` C function with ``optval=NULL`` and ``optlen=optlen``." msgstr "" -#: ../../library/socket.rst:2107 +#: ../../library/socket.rst:2123 msgid "setsockopt(level, optname, None, optlen: int) form added." msgstr "" -#: ../../library/socket.rst:2115 +#: ../../library/socket.rst:2131 msgid "" "Shut down one or both halves of the connection. If *how* is :const:" "`SHUT_RD`, further receives are disallowed. If *how* is :const:`SHUT_WR`, " @@ -2361,7 +2390,7 @@ msgid "" "and receives are disallowed." msgstr "" -#: ../../library/socket.rst:2125 +#: ../../library/socket.rst:2141 msgid "" "Duplicate a socket and prepare it for sharing with a target process. The " "target process must be provided with *process_id*. The resulting bytes " @@ -2372,31 +2401,31 @@ msgid "" "process." msgstr "" -#: ../../library/socket.rst:2137 +#: ../../library/socket.rst:2153 msgid "" "Note that there are no methods :meth:`!read` or :meth:`!write`; use :meth:" "`~socket.recv` and :meth:`~socket.send` without *flags* argument instead." msgstr "" -#: ../../library/socket.rst:2140 +#: ../../library/socket.rst:2156 msgid "" "Socket objects also have these (read-only) attributes that correspond to the " "values given to the :class:`~socket.socket` constructor." msgstr "" -#: ../../library/socket.rst:2146 +#: ../../library/socket.rst:2162 msgid "The socket family." msgstr "" -#: ../../library/socket.rst:2151 +#: ../../library/socket.rst:2167 msgid "The socket type." msgstr "" -#: ../../library/socket.rst:2156 +#: ../../library/socket.rst:2172 msgid "The socket protocol." msgstr "" -#: ../../library/socket.rst:2161 +#: ../../library/socket.rst:2177 msgid "" "The base class of the :class:`~socket.socket` type, re-exported from :mod:`!" "_socket`. An instance check such as ``isinstance(socket(...), SocketType)`` " @@ -2404,24 +2433,24 @@ msgid "" "is :class:`~socket.socket` itself." msgstr "" -#: ../../library/socket.rst:2170 +#: ../../library/socket.rst:2186 msgid "Notes on socket timeouts" msgstr "" -#: ../../library/socket.rst:2172 +#: ../../library/socket.rst:2188 msgid "" "A socket object can be in one of three modes: blocking, non-blocking, or " "timeout. Sockets are by default always created in blocking mode, but this " "can be changed by calling :func:`setdefaulttimeout`." msgstr "" -#: ../../library/socket.rst:2176 +#: ../../library/socket.rst:2192 msgid "" "In *blocking mode*, operations block until complete or the system returns an " "error (such as connection timed out)." msgstr "" -#: ../../library/socket.rst:2179 +#: ../../library/socket.rst:2195 msgid "" "In *non-blocking mode*, operations fail (with an error that is unfortunately " "system-dependent) if they cannot be completed immediately: functions from " @@ -2429,14 +2458,14 @@ msgid "" "available for reading or writing." msgstr "" -#: ../../library/socket.rst:2184 +#: ../../library/socket.rst:2200 msgid "" "In *timeout mode*, operations fail if they cannot be completed within the " "timeout specified for the socket (they raise a :exc:`timeout` exception) or " "if the system returns an error." msgstr "" -#: ../../library/socket.rst:2189 +#: ../../library/socket.rst:2205 msgid "" "At the operating system level, sockets in *timeout mode* are internally set " "in non-blocking mode. Also, the blocking and timeout modes are shared " @@ -2445,11 +2474,11 @@ msgid "" "you decide to use the :meth:`~socket.fileno` of a socket." msgstr "" -#: ../../library/socket.rst:2196 +#: ../../library/socket.rst:2212 msgid "Timeouts and the ``connect`` method" msgstr "" -#: ../../library/socket.rst:2198 +#: ../../library/socket.rst:2214 msgid "" "The :meth:`~socket.connect` operation is also subject to the timeout " "setting, and in general it is recommended to call :meth:`~socket.settimeout` " @@ -2459,24 +2488,24 @@ msgid "" "setting." msgstr "" -#: ../../library/socket.rst:2206 +#: ../../library/socket.rst:2222 msgid "Timeouts and the ``accept`` method" msgstr "" -#: ../../library/socket.rst:2208 +#: ../../library/socket.rst:2224 msgid "" "If :func:`getdefaulttimeout` is not :const:`None`, sockets returned by the :" "meth:`~socket.accept` method inherit that timeout. Otherwise, the behaviour " "depends on settings of the listening socket:" msgstr "" -#: ../../library/socket.rst:2212 +#: ../../library/socket.rst:2228 msgid "" "if the listening socket is in *blocking mode* or in *timeout mode*, the " "socket returned by :meth:`~socket.accept` is in *blocking mode*;" msgstr "" -#: ../../library/socket.rst:2215 +#: ../../library/socket.rst:2231 msgid "" "if the listening socket is in *non-blocking mode*, whether the socket " "returned by :meth:`~socket.accept` is in blocking or non-blocking mode is " @@ -2484,11 +2513,11 @@ msgid "" "it is recommended you manually override this setting." msgstr "" -#: ../../library/socket.rst:2224 +#: ../../library/socket.rst:2240 msgid "Example" msgstr "範例" -#: ../../library/socket.rst:2226 +#: ../../library/socket.rst:2242 msgid "" "Here are four minimal example programs using the TCP/IP protocol: a server " "that echoes all data that it receives back (servicing only one client), and " @@ -2501,11 +2530,11 @@ msgid "" "on the new socket returned by :meth:`~socket.accept`." msgstr "" -#: ../../library/socket.rst:2236 +#: ../../library/socket.rst:2252 msgid "The first two examples support IPv4 only. ::" msgstr "前兩個範例只支援 IPv4: ::" -#: ../../library/socket.rst:2238 +#: ../../library/socket.rst:2254 msgid "" "# Echo server program\n" "import socket\n" @@ -2524,7 +2553,7 @@ msgid "" " conn.sendall(data)" msgstr "" -#: ../../library/socket.rst:2256 +#: ../../library/socket.rst:2272 msgid "" "# Echo client program\n" "import socket\n" @@ -2538,7 +2567,7 @@ msgid "" "print('Received', repr(data))" msgstr "" -#: ../../library/socket.rst:2267 +#: ../../library/socket.rst:2283 msgid "" "The next two examples are identical to the above two, but support both IPv4 " "and IPv6. The server side will listen to the first address family available " @@ -2548,7 +2577,7 @@ msgid "" "resolution, and sends traffic to the first one connected successfully. ::" msgstr "" -#: ../../library/socket.rst:2274 +#: ../../library/socket.rst:2290 msgid "" "# Echo server program\n" "import socket\n" @@ -2585,7 +2614,7 @@ msgid "" " conn.send(data)" msgstr "" -#: ../../library/socket.rst:2310 +#: ../../library/socket.rst:2326 msgid "" "# Echo client program\n" "import socket\n" @@ -2618,14 +2647,14 @@ msgid "" "print('Received', repr(data))" msgstr "" -#: ../../library/socket.rst:2339 +#: ../../library/socket.rst:2355 msgid "" "The next example shows how to write a very simple network sniffer with raw " "sockets on Windows. The example requires administrator privileges to modify " "the interface::" msgstr "" -#: ../../library/socket.rst:2343 +#: ../../library/socket.rst:2359 msgid "" "import socket\n" "\n" @@ -2649,29 +2678,29 @@ msgid "" "s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)" msgstr "" -#: ../../library/socket.rst:2364 +#: ../../library/socket.rst:2380 msgid "" "The next example shows how to use the socket interface to communicate to a " "CAN network using the raw socket protocol. To use CAN with the broadcast " "manager protocol instead, open a socket with::" msgstr "" -#: ../../library/socket.rst:2368 +#: ../../library/socket.rst:2384 msgid "socket.socket(socket.AF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM)" msgstr "socket.socket(socket.AF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM)" -#: ../../library/socket.rst:2370 +#: ../../library/socket.rst:2386 msgid "" "After binding (:const:`CAN_RAW`) or connecting (:const:`CAN_BCM`) the " "socket, you can use the :meth:`socket.send` and :meth:`socket.recv` " "operations (and their counterparts) on the socket object as usual." msgstr "" -#: ../../library/socket.rst:2374 +#: ../../library/socket.rst:2390 msgid "This last example might require special privileges::" msgstr "" -#: ../../library/socket.rst:2376 +#: ../../library/socket.rst:2392 msgid "" "import socket\n" "import struct\n" @@ -2713,29 +2742,29 @@ msgid "" " print('Error sending CAN frame')" msgstr "" -#: ../../library/socket.rst:2414 +#: ../../library/socket.rst:2430 msgid "" "Running an example several times with too small delay between executions, " "could lead to this error::" msgstr "" -#: ../../library/socket.rst:2417 +#: ../../library/socket.rst:2433 msgid "OSError: [Errno 98] Address already in use" msgstr "OSError: [Errno 98] Address already in use" -#: ../../library/socket.rst:2419 +#: ../../library/socket.rst:2435 msgid "" "This is because the previous execution has left the socket in a " "``TIME_WAIT`` state, and can't be immediately reused." msgstr "" -#: ../../library/socket.rst:2422 +#: ../../library/socket.rst:2438 msgid "" "There is a :mod:`!socket` flag to set, in order to prevent this, :const:" "`socket.SO_REUSEADDR`::" msgstr "" -#: ../../library/socket.rst:2425 +#: ../../library/socket.rst:2441 msgid "" "s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" "s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n" @@ -2745,30 +2774,30 @@ msgstr "" "s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n" "s.bind((HOST, PORT))" -#: ../../library/socket.rst:2429 +#: ../../library/socket.rst:2445 msgid "" "the :data:`SO_REUSEADDR` flag tells the kernel to reuse a local socket in " "``TIME_WAIT`` state, without waiting for its natural timeout to expire." msgstr "" -#: ../../library/socket.rst:2435 +#: ../../library/socket.rst:2451 msgid "" "For an introduction to socket programming (in C), see the following papers:" msgstr "" -#: ../../library/socket.rst:2437 +#: ../../library/socket.rst:2453 msgid "" "*An Introductory 4.3BSD Interprocess Communication Tutorial*, by Stuart " "Sechrest" msgstr "" -#: ../../library/socket.rst:2439 +#: ../../library/socket.rst:2455 msgid "" "*An Advanced 4.3BSD Interprocess Communication Tutorial*, by Samuel J. " "Leffler et al," msgstr "" -#: ../../library/socket.rst:2442 +#: ../../library/socket.rst:2458 msgid "" "both in the UNIX Programmer's Manual, Supplementary Documents 1 (sections " "PS1:7 and PS1:8). The platform-specific reference material for the various " @@ -2787,19 +2816,19 @@ msgstr "object(物件)" msgid "socket" msgstr "socket" -#: ../../library/socket.rst:1742 +#: ../../library/socket.rst:1755 msgid "I/O control" msgstr "I/O control(I/O 控制)" -#: ../../library/socket.rst:1742 +#: ../../library/socket.rst:1755 msgid "buffering" msgstr "buffering(緩衝)" -#: ../../library/socket.rst:2092 +#: ../../library/socket.rst:2108 msgid "module" msgstr "module(模組)" -#: ../../library/socket.rst:2092 +#: ../../library/socket.rst:2108 msgid "struct" msgstr "struct" diff --git a/library/socketserver.po b/library/socketserver.po index 137cbd3bff4..cfa24e9a2b0 100644 --- a/library/socketserver.po +++ b/library/socketserver.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:10+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -56,21 +56,27 @@ msgid "" "the :class:`BaseServer` base class." msgstr "" -#: ../../library/socketserver.rst:30 +#: ../../library/socketserver.rst:27 +msgid "" +"The default queue size is now ``socket.SOMAXCONN`` for :class:`socketserver." +"TCPServer`." +msgstr "" + +#: ../../library/socketserver.rst:32 msgid "" "This uses datagrams, which are discrete packets of information that may " "arrive out of order or be lost while in transit. The parameters are the " "same as for :class:`TCPServer`." msgstr "" -#: ../../library/socketserver.rst:38 +#: ../../library/socketserver.rst:40 msgid "" "These more infrequently used classes are similar to the TCP and UDP classes, " "but use Unix domain sockets; they're not available on non-Unix platforms. " "The parameters are the same as for :class:`TCPServer`." msgstr "" -#: ../../library/socketserver.rst:44 +#: ../../library/socketserver.rst:46 msgid "" "These four classes process requests :dfn:`synchronously`; each request must " "be completed before the next request can be started. This isn't suitable if " @@ -81,7 +87,7 @@ msgid "" "classes can be used to support asynchronous behaviour." msgstr "" -#: ../../library/socketserver.rst:52 +#: ../../library/socketserver.rst:54 msgid "" "Creating a server requires several steps. First, you must create a request " "handler class by subclassing the :class:`BaseRequestHandler` class and " @@ -95,7 +101,7 @@ msgid "" "keyword:`!with` statement)." msgstr "" -#: ../../library/socketserver.rst:64 +#: ../../library/socketserver.rst:66 msgid "" "When inheriting from :class:`ThreadingMixIn` for threaded connection " "behavior, you should explicitly declare how you want your threads to behave " @@ -107,23 +113,23 @@ msgid "" "`ThreadingMixIn` have exited." msgstr "" -#: ../../library/socketserver.rst:73 +#: ../../library/socketserver.rst:75 msgid "" "Server classes have the same external methods and attributes, no matter what " "network protocol they use." msgstr "" -#: ../../library/socketserver.rst:78 +#: ../../library/socketserver.rst:80 msgid "Server Creation Notes" msgstr "" -#: ../../library/socketserver.rst:80 +#: ../../library/socketserver.rst:82 msgid "" "There are five classes in an inheritance diagram, four of which represent " "synchronous servers of four types::" msgstr "" -#: ../../library/socketserver.rst:83 +#: ../../library/socketserver.rst:85 msgid "" "+------------+\n" "| BaseServer |\n" @@ -153,21 +159,21 @@ msgstr "" "| UDPServer |------->| UnixDatagramServer |\n" "+-----------+ +--------------------+" -#: ../../library/socketserver.rst:97 +#: ../../library/socketserver.rst:99 msgid "" "Note that :class:`UnixDatagramServer` derives from :class:`UDPServer`, not " "from :class:`UnixStreamServer` --- the only difference between an IP and a " "Unix server is the address family." msgstr "" -#: ../../library/socketserver.rst:105 +#: ../../library/socketserver.rst:107 msgid "" "Forking and threading versions of each type of server can be created using " "these mix-in classes. For instance, :class:`ThreadingUDPServer` is created " "as follows::" msgstr "" -#: ../../library/socketserver.rst:109 +#: ../../library/socketserver.rst:111 msgid "" "class ThreadingUDPServer(ThreadingMixIn, UDPServer):\n" " pass" @@ -175,48 +181,48 @@ msgstr "" "class ThreadingUDPServer(ThreadingMixIn, UDPServer):\n" " pass" -#: ../../library/socketserver.rst:112 +#: ../../library/socketserver.rst:114 msgid "" "The mix-in class comes first, since it overrides a method defined in :class:" "`UDPServer`. Setting the various attributes also changes the behavior of " "the underlying server mechanism." msgstr "" -#: ../../library/socketserver.rst:116 +#: ../../library/socketserver.rst:118 msgid "" ":class:`ForkingMixIn` and the Forking classes mentioned below are only " "available on POSIX platforms that support :func:`~os.fork`." msgstr "" -#: ../../library/socketserver.rst:121 +#: ../../library/socketserver.rst:123 msgid "" ":meth:`ForkingMixIn.server_close ` waits until all " "child processes complete, except if :attr:`block_on_close` attribute is " "``False``." msgstr "" -#: ../../library/socketserver.rst:125 +#: ../../library/socketserver.rst:127 msgid "" ":meth:`ThreadingMixIn.server_close ` waits until " "all non-daemon threads complete, except if :attr:`block_on_close` attribute " "is ``False``." msgstr "" -#: ../../library/socketserver.rst:131 +#: ../../library/socketserver.rst:133 msgid "" "Specify how many child processes will exist to handle requests at a time " "for :class:`ForkingMixIn`. If the limit is reached, new requests will wait " "until one child process has finished." msgstr "" -#: ../../library/socketserver.rst:137 +#: ../../library/socketserver.rst:139 msgid "" "For :class:`ThreadingMixIn` use daemonic threads by setting :data:" "`ThreadingMixIn.daemon_threads ` to ``True`` to not wait " "until threads complete." msgstr "" -#: ../../library/socketserver.rst:143 +#: ../../library/socketserver.rst:145 msgid "" ":meth:`ForkingMixIn.server_close ` and :meth:" "`ThreadingMixIn.server_close ` now waits until all " @@ -225,17 +231,17 @@ msgid "" "the pre-3.7 behaviour." msgstr "" -#: ../../library/socketserver.rst:159 +#: ../../library/socketserver.rst:161 msgid "These classes are pre-defined using the mix-in classes." msgstr "" -#: ../../library/socketserver.rst:161 +#: ../../library/socketserver.rst:163 msgid "" "The ``ForkingUnixStreamServer`` and ``ForkingUnixDatagramServer`` classes " "were added." msgstr "" -#: ../../library/socketserver.rst:165 +#: ../../library/socketserver.rst:167 msgid "" "To implement a service, you must derive a class from :class:" "`BaseRequestHandler` and redefine its :meth:`~BaseRequestHandler.handle` " @@ -246,7 +252,7 @@ msgid "" "`DatagramRequestHandler`." msgstr "" -#: ../../library/socketserver.rst:173 +#: ../../library/socketserver.rst:175 msgid "" "Of course, you still have to use your head! For instance, it makes no sense " "to use a forking server if the service contains state in memory that can be " @@ -256,7 +262,7 @@ msgid "" "probably have to use locks to protect the integrity of the shared data." msgstr "" -#: ../../library/socketserver.rst:180 +#: ../../library/socketserver.rst:182 msgid "" "On the other hand, if you are building an HTTP server where all data is " "stored externally (for instance, in the file system), a synchronous class " @@ -266,7 +272,7 @@ msgid "" "appropriate." msgstr "" -#: ../../library/socketserver.rst:186 +#: ../../library/socketserver.rst:188 msgid "" "In some cases, it may be appropriate to process part of a request " "synchronously, but to finish processing in a forked child depending on the " @@ -275,7 +281,7 @@ msgid "" "`~BaseRequestHandler.handle` method." msgstr "" -#: ../../library/socketserver.rst:191 +#: ../../library/socketserver.rst:193 msgid "" "Another approach to handling multiple simultaneous requests in an " "environment that supports neither threads nor :func:`~os.fork` (or where " @@ -287,11 +293,11 @@ msgid "" "subprocesses cannot be used)." msgstr "" -#: ../../library/socketserver.rst:204 +#: ../../library/socketserver.rst:206 msgid "Server Objects" msgstr "" -#: ../../library/socketserver.rst:208 +#: ../../library/socketserver.rst:210 msgid "" "This is the superclass of all Server objects in the module. It defines the " "interface, given below, but does not implement most of the methods, which is " @@ -299,14 +305,14 @@ msgid "" "`server_address` and :attr:`RequestHandlerClass` attributes." msgstr "" -#: ../../library/socketserver.rst:216 +#: ../../library/socketserver.rst:218 msgid "" "Return an integer file descriptor for the socket on which the server is " "listening. This function is most commonly passed to :mod:`selectors`, to " "allow monitoring multiple servers in the same process." msgstr "" -#: ../../library/socketserver.rst:223 +#: ../../library/socketserver.rst:225 msgid "" "Process a single request. This function calls the following methods in " "order: :meth:`get_request`, :meth:`verify_request`, and :meth:" @@ -317,7 +323,7 @@ msgid "" "`handle_request` will return." msgstr "" -#: ../../library/socketserver.rst:235 +#: ../../library/socketserver.rst:237 msgid "" "Handle requests until an explicit :meth:`shutdown` request. Poll for " "shutdown every *poll_interval* seconds. Ignores the :attr:`timeout` " @@ -327,29 +333,29 @@ msgid "" "clean up zombie child processes." msgstr "" -#: ../../library/socketserver.rst:243 +#: ../../library/socketserver.rst:245 msgid "Added ``service_actions`` call to the ``serve_forever`` method." msgstr "" -#: ../../library/socketserver.rst:249 +#: ../../library/socketserver.rst:251 msgid "" "This is called in the :meth:`serve_forever` loop. This method can be " "overridden by subclasses or mixin classes to perform actions specific to a " "given service, such as cleanup actions." msgstr "" -#: ../../library/socketserver.rst:257 +#: ../../library/socketserver.rst:259 msgid "" "Tell the :meth:`serve_forever` loop to stop and wait until it does. :meth:" "`shutdown` must be called while :meth:`serve_forever` is running in a " "different thread otherwise it will deadlock." msgstr "" -#: ../../library/socketserver.rst:264 +#: ../../library/socketserver.rst:266 msgid "Clean up the server. May be overridden." msgstr "" -#: ../../library/socketserver.rst:269 +#: ../../library/socketserver.rst:271 msgid "" "The family of protocols to which the server's socket belongs. Common " "examples are :const:`socket.AF_INET`, :const:`socket.AF_INET6`, and :const:" @@ -358,13 +364,13 @@ msgid "" "server classes." msgstr "" -#: ../../library/socketserver.rst:278 +#: ../../library/socketserver.rst:280 msgid "" "The user-provided request handler class; an instance of this class is " "created for each request." msgstr "" -#: ../../library/socketserver.rst:284 +#: ../../library/socketserver.rst:286 msgid "" "The address on which the server is listening. The format of addresses " "varies depending on the protocol family; see the documentation for the :mod:" @@ -373,22 +379,22 @@ msgid "" "``('127.0.0.1', 80)``, for example." msgstr "" -#: ../../library/socketserver.rst:293 +#: ../../library/socketserver.rst:295 msgid "" "The socket object on which the server will listen for incoming requests." msgstr "" -#: ../../library/socketserver.rst:296 +#: ../../library/socketserver.rst:298 msgid "The server classes support the following class variables:" msgstr "" -#: ../../library/socketserver.rst:302 +#: ../../library/socketserver.rst:304 msgid "" "Whether the server will allow the reuse of an address. This defaults to :" "const:`False`, and can be set in subclasses to change the policy." msgstr "" -#: ../../library/socketserver.rst:308 +#: ../../library/socketserver.rst:310 msgid "" "The size of the request queue. If it takes a long time to process a single " "request, any requests that arrive while the server is busy are placed into a " @@ -397,40 +403,40 @@ msgid "" "default value is usually 5, but this can be overridden by subclasses." msgstr "" -#: ../../library/socketserver.rst:317 +#: ../../library/socketserver.rst:319 msgid "" "The type of socket used by the server; :const:`socket.SOCK_STREAM` and :" "const:`socket.SOCK_DGRAM` are two common values." msgstr "" -#: ../../library/socketserver.rst:323 +#: ../../library/socketserver.rst:325 msgid "" "Timeout duration, measured in seconds, or :const:`None` if no timeout is " "desired. If :meth:`handle_request` receives no incoming requests within the " "timeout period, the :meth:`handle_timeout` method is called." msgstr "" -#: ../../library/socketserver.rst:328 +#: ../../library/socketserver.rst:330 msgid "" "There are various server methods that can be overridden by subclasses of " "base server classes like :class:`TCPServer`; these methods aren't useful to " "external users of the server object." msgstr "" -#: ../../library/socketserver.rst:337 +#: ../../library/socketserver.rst:339 msgid "" "Actually processes the request by instantiating :attr:`RequestHandlerClass` " "and calling its :meth:`~BaseRequestHandler.handle` method." msgstr "" -#: ../../library/socketserver.rst:343 +#: ../../library/socketserver.rst:345 msgid "" "Must accept a request from the socket, and return a 2-tuple containing the " "*new* socket object to be used to communicate with the client, and the " "client's address." msgstr "" -#: ../../library/socketserver.rst:350 +#: ../../library/socketserver.rst:352 msgid "" "This function is called if the :meth:`~BaseRequestHandler.handle` method of " "a :attr:`RequestHandlerClass` instance raises an exception. The default " @@ -438,11 +444,11 @@ msgid "" "further requests." msgstr "" -#: ../../library/socketserver.rst:355 +#: ../../library/socketserver.rst:357 msgid "Now only called for exceptions derived from the :exc:`Exception` class." msgstr "" -#: ../../library/socketserver.rst:362 +#: ../../library/socketserver.rst:364 msgid "" "This function is called when the :attr:`timeout` attribute has been set to a " "value other than :const:`None` and the timeout period has passed with no " @@ -451,7 +457,7 @@ msgid "" "threading servers this method does nothing." msgstr "" -#: ../../library/socketserver.rst:371 +#: ../../library/socketserver.rst:373 msgid "" "Calls :meth:`finish_request` to create an instance of the :attr:" "`RequestHandlerClass`. If desired, this function can create a new process " @@ -459,20 +465,20 @@ msgid "" "`ThreadingMixIn` classes do this." msgstr "" -#: ../../library/socketserver.rst:383 +#: ../../library/socketserver.rst:385 msgid "" "Called by the server's constructor to activate the server. The default " "behavior for a TCP server just invokes :meth:`~socket.socket.listen` on the " "server's socket. May be overridden." msgstr "" -#: ../../library/socketserver.rst:390 +#: ../../library/socketserver.rst:392 msgid "" "Called by the server's constructor to bind the socket to the desired " "address. May be overridden." msgstr "" -#: ../../library/socketserver.rst:396 +#: ../../library/socketserver.rst:398 msgid "" "Must return a Boolean value; if the value is :const:`True`, the request will " "be processed, and if it's :const:`False`, the request will be denied. This " @@ -480,17 +486,17 @@ msgid "" "default implementation always returns :const:`True`." msgstr "" -#: ../../library/socketserver.rst:402 +#: ../../library/socketserver.rst:404 msgid "" "Support for the :term:`context manager` protocol was added. Exiting the " "context manager is equivalent to calling :meth:`server_close`." msgstr "" -#: ../../library/socketserver.rst:408 +#: ../../library/socketserver.rst:410 msgid "Request Handler Objects" msgstr "" -#: ../../library/socketserver.rst:412 +#: ../../library/socketserver.rst:414 msgid "" "This is the superclass of all request handler objects. It defines the " "interface, given below. A concrete request handler subclass must define a " @@ -498,13 +504,13 @@ msgid "" "instance of the subclass is created for each request." msgstr "" -#: ../../library/socketserver.rst:421 +#: ../../library/socketserver.rst:423 msgid "" "Called before the :meth:`handle` method to perform any initialization " "actions required. The default implementation does nothing." msgstr "" -#: ../../library/socketserver.rst:427 +#: ../../library/socketserver.rst:429 msgid "" "This function must do all the work required to service a request. The " "default implementation does nothing. Several instance attributes are " @@ -513,72 +519,72 @@ msgid "" "`server`, in case it needs access to per-server information." msgstr "" -#: ../../library/socketserver.rst:433 +#: ../../library/socketserver.rst:435 msgid "" "The type of :attr:`request` is different for datagram or stream services. " "For stream services, :attr:`request` is a socket object; for datagram " "services, :attr:`request` is a pair of string and socket." msgstr "" -#: ../../library/socketserver.rst:440 +#: ../../library/socketserver.rst:442 msgid "" "Called after the :meth:`handle` method to perform any clean-up actions " "required. The default implementation does nothing. If :meth:`setup` raises " "an exception, this function will not be called." msgstr "" -#: ../../library/socketserver.rst:447 +#: ../../library/socketserver.rst:449 msgid "" "The *new* :class:`socket.socket` object to be used to communicate with the " "client." msgstr "" -#: ../../library/socketserver.rst:453 +#: ../../library/socketserver.rst:455 msgid "Client address returned by :meth:`BaseServer.get_request`." msgstr "" -#: ../../library/socketserver.rst:458 +#: ../../library/socketserver.rst:460 msgid ":class:`BaseServer` object used for handling the request." msgstr "" -#: ../../library/socketserver.rst:464 +#: ../../library/socketserver.rst:466 msgid "" "These :class:`BaseRequestHandler` subclasses override the :meth:" "`~BaseRequestHandler.setup` and :meth:`~BaseRequestHandler.finish` methods, " "and provide :attr:`rfile` and :attr:`wfile` attributes." msgstr "" -#: ../../library/socketserver.rst:470 +#: ../../library/socketserver.rst:472 msgid "" "A file object from which receives the request is read. Support the :class:" "`io.BufferedIOBase` readable interface." msgstr "" -#: ../../library/socketserver.rst:475 +#: ../../library/socketserver.rst:477 msgid "" "A file object to which the reply is written. Support the :class:`io." "BufferedIOBase` writable interface" msgstr "" -#: ../../library/socketserver.rst:479 +#: ../../library/socketserver.rst:481 msgid "" ":attr:`wfile` also supports the :class:`io.BufferedIOBase` writable " "interface." msgstr "" -#: ../../library/socketserver.rst:485 +#: ../../library/socketserver.rst:487 msgid "Examples" msgstr "範例" -#: ../../library/socketserver.rst:488 +#: ../../library/socketserver.rst:490 msgid ":class:`socketserver.TCPServer` Example" msgstr ":class:`socketserver.TCPServer` 範例" -#: ../../library/socketserver.rst:490 ../../library/socketserver.rst:601 +#: ../../library/socketserver.rst:492 ../../library/socketserver.rst:603 msgid "This is the server side::" msgstr "" -#: ../../library/socketserver.rst:492 +#: ../../library/socketserver.rst:494 msgid "" "import socketserver\n" "\n" @@ -615,14 +621,14 @@ msgid "" " server.serve_forever()" msgstr "" -#: ../../library/socketserver.rst:526 +#: ../../library/socketserver.rst:528 msgid "" "An alternative request handler class that makes use of streams (file-like " "objects that simplify communication by providing the standard file " "interface)::" msgstr "" -#: ../../library/socketserver.rst:529 +#: ../../library/socketserver.rst:531 msgid "" "class MyTCPHandler(socketserver.StreamRequestHandler):\n" "\n" @@ -638,7 +644,7 @@ msgid "" " self.wfile.write(self.data.upper())" msgstr "" -#: ../../library/socketserver.rst:542 +#: ../../library/socketserver.rst:544 msgid "" "The difference is that the ``readline()`` call in the second handler will " "call ``recv()`` multiple times until it encounters a newline character, " @@ -650,11 +656,11 @@ msgid "" "the number of ``recv()`` calls on the server required to receive it." msgstr "" -#: ../../library/socketserver.rst:552 ../../library/socketserver.rst:625 +#: ../../library/socketserver.rst:554 ../../library/socketserver.rst:627 msgid "This is the client side::" msgstr "" -#: ../../library/socketserver.rst:554 +#: ../../library/socketserver.rst:556 msgid "" "import socket\n" "import sys\n" @@ -676,15 +682,15 @@ msgid "" "print(\"Received:\", received)" msgstr "" -#: ../../library/socketserver.rst:574 ../../library/socketserver.rst:700 +#: ../../library/socketserver.rst:576 ../../library/socketserver.rst:702 msgid "The output of the example should look something like this:" msgstr "" -#: ../../library/socketserver.rst:576 +#: ../../library/socketserver.rst:578 msgid "Server:" msgstr "" -#: ../../library/socketserver.rst:578 +#: ../../library/socketserver.rst:580 msgid "" "$ python TCPServer.py\n" "127.0.0.1 wrote:\n" @@ -698,11 +704,11 @@ msgstr "" "127.0.0.1 wrote:\n" "b'python is nice'" -#: ../../library/socketserver.rst:586 +#: ../../library/socketserver.rst:588 msgid "Client:" msgstr "" -#: ../../library/socketserver.rst:588 +#: ../../library/socketserver.rst:590 msgid "" "$ python TCPClient.py hello world with TCP\n" "Sent: hello world with TCP\n" @@ -718,11 +724,11 @@ msgstr "" "Sent: python is nice\n" "Received: PYTHON IS NICE" -#: ../../library/socketserver.rst:599 +#: ../../library/socketserver.rst:601 msgid ":class:`socketserver.UDPServer` Example" msgstr ":class:`socketserver.UDPServer` 範例" -#: ../../library/socketserver.rst:603 +#: ../../library/socketserver.rst:605 msgid "" "import socketserver\n" "\n" @@ -747,7 +753,7 @@ msgid "" " server.serve_forever()" msgstr "" -#: ../../library/socketserver.rst:627 +#: ../../library/socketserver.rst:629 msgid "" "import socket\n" "import sys\n" @@ -767,27 +773,27 @@ msgid "" "print(\"Received:\", received)" msgstr "" -#: ../../library/socketserver.rst:644 +#: ../../library/socketserver.rst:646 msgid "" "The output of the example should look exactly like for the TCP server " "example." msgstr "" -#: ../../library/socketserver.rst:648 +#: ../../library/socketserver.rst:650 msgid "Asynchronous Mixins" msgstr "" -#: ../../library/socketserver.rst:650 +#: ../../library/socketserver.rst:652 msgid "" "To build asynchronous handlers, use the :class:`ThreadingMixIn` and :class:" "`ForkingMixIn` classes." msgstr "" -#: ../../library/socketserver.rst:653 +#: ../../library/socketserver.rst:655 msgid "An example for the :class:`ThreadingMixIn` class::" msgstr "" -#: ../../library/socketserver.rst:655 +#: ../../library/socketserver.rst:657 msgid "" "import socket\n" "import threading\n" @@ -835,7 +841,7 @@ msgid "" " server.shutdown()" msgstr "" -#: ../../library/socketserver.rst:702 +#: ../../library/socketserver.rst:704 msgid "" "$ python ThreadedTCPServer.py\n" "Server loop running in thread: Thread-1\n" @@ -849,7 +855,7 @@ msgstr "" "Received: Thread-3: Hello World 2\n" "Received: Thread-4: Hello World 3" -#: ../../library/socketserver.rst:711 +#: ../../library/socketserver.rst:713 msgid "" "The :class:`ForkingMixIn` class is used in the same way, except that the " "server will spawn a new process for each request. Available only on POSIX " diff --git a/library/sqlite3.po b/library/sqlite3.po index 0a85afeb7ad..7105b7d9d68 100644 --- a/library/sqlite3.po +++ b/library/sqlite3.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-03 00:49+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:10+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!sqlite3` --- DB-API 2.0 interface for SQLite databases" msgstr ":mod:`!sqlite3` --- SQLite 資料庫的 DB-API 2.0 介面" -#: ../../library/sqlite3.rst:9 +#: ../../library/sqlite3.rst:7 msgid "**Source code:** :source:`Lib/sqlite3/`" msgstr "**原始碼:**\\ :source:`Lib/sqlite3/`" -#: ../../library/sqlite3.rst:25 +#: ../../library/sqlite3.rst:23 msgid "" "SQLite is a C library that provides a lightweight disk-based database that " "doesn't require a separate server process and allows accessing the database " @@ -35,7 +35,7 @@ msgid "" "PostgreSQL or Oracle." msgstr "" -#: ../../library/sqlite3.rst:32 +#: ../../library/sqlite3.rst:30 msgid "" "The :mod:`!sqlite3` module was written by Gerhard Häring. It provides an " "SQL interface compliant with the DB-API 2.0 specification described by :pep:" @@ -50,68 +50,68 @@ msgid "" "module-requirements`." msgstr "" -#: ../../library/sqlite3.rst:38 +#: ../../library/sqlite3.rst:36 msgid "This document includes four main sections:" msgstr "此文件包含四個主要章節:" -#: ../../library/sqlite3.rst:40 +#: ../../library/sqlite3.rst:38 msgid ":ref:`sqlite3-tutorial` teaches how to use the :mod:`!sqlite3` module." msgstr ":ref:`sqlite3-tutorial` 教導如何使用 :mod:`!sqlite3` 模組。" -#: ../../library/sqlite3.rst:41 +#: ../../library/sqlite3.rst:39 msgid "" ":ref:`sqlite3-reference` describes the classes and functions this module " "defines." msgstr ":ref:`sqlite3-reference` 描述此模組定義的類別與函式。" -#: ../../library/sqlite3.rst:43 +#: ../../library/sqlite3.rst:41 msgid ":ref:`sqlite3-howtos` details how to handle specific tasks." msgstr ":ref:`sqlite3-howtos` 詳細說明如何處理特定工作。" -#: ../../library/sqlite3.rst:44 +#: ../../library/sqlite3.rst:42 msgid "" ":ref:`sqlite3-explanation` provides in-depth background on transaction " "control." msgstr ":ref:`sqlite3-explanation` 深入提供交易 (transaction) 控制的背景。" -#: ../../library/sqlite3.rst:49 +#: ../../library/sqlite3.rst:47 msgid "https://www.sqlite.org" msgstr "https://www.sqlite.org" -#: ../../library/sqlite3.rst:50 +#: ../../library/sqlite3.rst:48 msgid "" "The SQLite web page; the documentation describes the syntax and the " "available data types for the supported SQL dialect." msgstr "" -#: ../../library/sqlite3.rst:53 +#: ../../library/sqlite3.rst:51 msgid "https://www.w3schools.com/sql/" msgstr "https://www.w3schools.com/sql/" -#: ../../library/sqlite3.rst:54 +#: ../../library/sqlite3.rst:52 msgid "Tutorial, reference and examples for learning SQL syntax." msgstr "" -#: ../../library/sqlite3.rst:56 +#: ../../library/sqlite3.rst:54 msgid ":pep:`249` - Database API Specification 2.0" msgstr ":pep:`249` - 資料庫 API 規格 2.0" -#: ../../library/sqlite3.rst:57 +#: ../../library/sqlite3.rst:55 msgid "PEP written by Marc-André Lemburg." msgstr "PEP 由 Marc-André Lemburg 撰寫。" -#: ../../library/sqlite3.rst:70 +#: ../../library/sqlite3.rst:68 msgid "Tutorial" msgstr "教學" -#: ../../library/sqlite3.rst:72 +#: ../../library/sqlite3.rst:70 msgid "" "In this tutorial, you will create a database of Monty Python movies using " "basic :mod:`!sqlite3` functionality. It assumes a fundamental understanding " "of database concepts, including `cursors`_ and `transactions`_." msgstr "" -#: ../../library/sqlite3.rst:77 +#: ../../library/sqlite3.rst:75 msgid "" "First, we need to create a new database and open a database connection to " "allow :mod:`!sqlite3` to work with it. Call :func:`sqlite3.connect` to " @@ -119,7 +119,7 @@ msgid "" "working directory, implicitly creating it if it does not exist:" msgstr "" -#: ../../library/sqlite3.rst:83 +#: ../../library/sqlite3.rst:81 msgid "" "import sqlite3\n" "con = sqlite3.connect(\"tutorial.db\")" @@ -127,24 +127,24 @@ msgstr "" "import sqlite3\n" "con = sqlite3.connect(\"tutorial.db\")" -#: ../../library/sqlite3.rst:88 +#: ../../library/sqlite3.rst:86 msgid "" "The returned :class:`Connection` object ``con`` represents the connection to " "the on-disk database." msgstr "" -#: ../../library/sqlite3.rst:91 +#: ../../library/sqlite3.rst:89 msgid "" "In order to execute SQL statements and fetch results from SQL queries, we " "will need to use a database cursor. Call :meth:`con.cursor() ` to create the :class:`Cursor`:" msgstr "" -#: ../../library/sqlite3.rst:95 +#: ../../library/sqlite3.rst:93 msgid "cur = con.cursor()" msgstr "cur = con.cursor()" -#: ../../library/sqlite3.rst:99 +#: ../../library/sqlite3.rst:97 msgid "" "Now that we've got a database connection and a cursor, we can create a " "database table ``movie`` with columns for title, release year, and review " @@ -154,11 +154,11 @@ msgid "" "`cur.execute(...) `:" msgstr "" -#: ../../library/sqlite3.rst:108 +#: ../../library/sqlite3.rst:106 msgid "cur.execute(\"CREATE TABLE movie(title, year, score)\")" msgstr "cur.execute(\"CREATE TABLE movie(title, year, score)\")" -#: ../../library/sqlite3.rst:115 +#: ../../library/sqlite3.rst:113 msgid "" "We can verify that the new table has been created by querying the " "``sqlite_master`` table built-in to SQLite, which should now contain an " @@ -168,7 +168,7 @@ msgid "" "` to fetch the resulting row:" msgstr "" -#: ../../library/sqlite3.rst:123 +#: ../../library/sqlite3.rst:121 msgid "" ">>> res = cur.execute(\"SELECT name FROM sqlite_master\")\n" ">>> res.fetchone()\n" @@ -178,14 +178,14 @@ msgstr "" ">>> res.fetchone()\n" "('movie',)" -#: ../../library/sqlite3.rst:129 +#: ../../library/sqlite3.rst:127 msgid "" "We can see that the table has been created, as the query returns a :class:" "`tuple` containing the table's name. If we query ``sqlite_master`` for a non-" "existent table ``spam``, :meth:`!res.fetchone` will return ``None``:" msgstr "" -#: ../../library/sqlite3.rst:134 +#: ../../library/sqlite3.rst:132 msgid "" ">>> res = cur.execute(\"SELECT name FROM sqlite_master WHERE name='spam'\")\n" ">>> res.fetchone() is None\n" @@ -195,14 +195,14 @@ msgstr "" ">>> res.fetchone() is None\n" "True" -#: ../../library/sqlite3.rst:140 +#: ../../library/sqlite3.rst:138 msgid "" "Now, add two rows of data supplied as SQL literals by executing an " "``INSERT`` statement, once again by calling :meth:`cur.execute(...) `:" msgstr "" -#: ../../library/sqlite3.rst:144 +#: ../../library/sqlite3.rst:142 msgid "" "cur.execute(\"\"\"\n" " INSERT INTO movie VALUES\n" @@ -216,7 +216,7 @@ msgstr "" " ('And Now for Something Completely Different', 1971, 7.5)\n" "\"\"\")" -#: ../../library/sqlite3.rst:152 +#: ../../library/sqlite3.rst:150 msgid "" "The ``INSERT`` statement implicitly opens a transaction, which needs to be " "committed before changes are saved in the database (see :ref:`sqlite3-" @@ -224,11 +224,11 @@ msgid "" "commit>` on the connection object to commit the transaction:" msgstr "" -#: ../../library/sqlite3.rst:158 +#: ../../library/sqlite3.rst:156 msgid "con.commit()" msgstr "con.commit()" -#: ../../library/sqlite3.rst:162 +#: ../../library/sqlite3.rst:160 msgid "" "We can verify that the data was inserted correctly by executing a ``SELECT`` " "query. Use the now-familiar :meth:`cur.execute(...) ` to " @@ -236,7 +236,7 @@ msgid "" "fetchall>` to return all resulting rows:" msgstr "" -#: ../../library/sqlite3.rst:168 +#: ../../library/sqlite3.rst:166 msgid "" ">>> res = cur.execute(\"SELECT score FROM movie\")\n" ">>> res.fetchall()\n" @@ -246,19 +246,19 @@ msgstr "" ">>> res.fetchall()\n" "[(8.2,), (7.5,)]" -#: ../../library/sqlite3.rst:174 +#: ../../library/sqlite3.rst:172 msgid "" "The result is a :class:`list` of two :class:`!tuple`\\s, one per row, each " "containing that row's ``score`` value." msgstr "" -#: ../../library/sqlite3.rst:177 +#: ../../library/sqlite3.rst:175 msgid "" "Now, insert three more rows by calling :meth:`cur.executemany(...) `:" msgstr "" -#: ../../library/sqlite3.rst:180 +#: ../../library/sqlite3.rst:178 msgid "" "data = [\n" " (\"Monty Python Live at the Hollywood Bowl\", 1982, 7.9),\n" @@ -269,7 +269,7 @@ msgid "" "con.commit() # Remember to commit the transaction after executing INSERT." msgstr "" -#: ../../library/sqlite3.rst:190 +#: ../../library/sqlite3.rst:188 msgid "" "Notice that ``?`` placeholders are used to bind ``data`` to the query. " "Always use placeholders instead of :ref:`string formatting ` " @@ -277,13 +277,13 @@ msgid "" "(see :ref:`sqlite3-placeholders` for more details)." msgstr "" -#: ../../library/sqlite3.rst:196 +#: ../../library/sqlite3.rst:194 msgid "" "We can verify that the new rows were inserted by executing a ``SELECT`` " "query, this time iterating over the results of the query:" msgstr "" -#: ../../library/sqlite3.rst:200 +#: ../../library/sqlite3.rst:198 msgid "" ">>> for row in cur.execute(\"SELECT year, title FROM movie ORDER BY " "year\"):\n" @@ -303,20 +303,20 @@ msgstr "" "(1982, 'Monty Python Live at the Hollywood Bowl')\n" "(1983, \"Monty Python's The Meaning of Life\")" -#: ../../library/sqlite3.rst:210 +#: ../../library/sqlite3.rst:208 msgid "" "Each row is a two-item :class:`tuple` of ``(year, title)``, matching the " "columns selected in the query." msgstr "" -#: ../../library/sqlite3.rst:213 +#: ../../library/sqlite3.rst:211 msgid "" "Finally, verify that the database has been written to disk by calling :meth:" "`con.close() ` to close the existing connection, opening a " "new one, creating a new cursor, then querying the database:" msgstr "" -#: ../../library/sqlite3.rst:218 +#: ../../library/sqlite3.rst:216 msgid "" ">>> con.close()\n" ">>> new_con = sqlite3.connect(\"tutorial.db\")\n" @@ -342,50 +342,50 @@ msgstr "" "released in 1975\n" ">>> new_con.close()" -#: ../../library/sqlite3.rst:229 +#: ../../library/sqlite3.rst:227 msgid "" "You've now created an SQLite database using the :mod:`!sqlite3` module, " "inserted data and retrieved values from it in multiple ways." msgstr "" -#: ../../library/sqlite3.rst:241 +#: ../../library/sqlite3.rst:239 msgid ":ref:`sqlite3-howtos` for further reading:" msgstr "進一步參考 :ref:`sqlite3-howtos`:" -#: ../../library/sqlite3.rst:243 +#: ../../library/sqlite3.rst:241 msgid ":ref:`sqlite3-placeholders`" msgstr ":ref:`sqlite3-placeholders`" -#: ../../library/sqlite3.rst:244 +#: ../../library/sqlite3.rst:242 msgid ":ref:`sqlite3-adapters`" msgstr ":ref:`sqlite3-adapters`" -#: ../../library/sqlite3.rst:245 +#: ../../library/sqlite3.rst:243 msgid ":ref:`sqlite3-converters`" msgstr ":ref:`sqlite3-converters`" -#: ../../library/sqlite3.rst:246 ../../library/sqlite3.rst:602 +#: ../../library/sqlite3.rst:244 ../../library/sqlite3.rst:606 msgid ":ref:`sqlite3-connection-context-manager`" msgstr ":ref:`sqlite3-connection-context-manager`" -#: ../../library/sqlite3.rst:247 +#: ../../library/sqlite3.rst:245 msgid ":ref:`sqlite3-howto-row-factory`" msgstr ":ref:`sqlite3-howto-row-factory`" -#: ../../library/sqlite3.rst:249 +#: ../../library/sqlite3.rst:247 msgid "" ":ref:`sqlite3-explanation` for in-depth background on transaction control." msgstr "" -#: ../../library/sqlite3.rst:254 +#: ../../library/sqlite3.rst:252 msgid "Reference" msgstr "" -#: ../../library/sqlite3.rst:262 +#: ../../library/sqlite3.rst:260 msgid "Module functions" msgstr "" -#: ../../library/sqlite3.rst:270 +#: ../../library/sqlite3.rst:268 msgid "Open a connection to an SQLite database." msgstr "" @@ -393,14 +393,14 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../library/sqlite3.rst:272 +#: ../../library/sqlite3.rst:270 msgid "" "The path to the database file to be opened. You can pass ``\":memory:\"`` to " "create an `SQLite database existing only in memory `_, and open a connection to it." msgstr "" -#: ../../library/sqlite3.rst:279 +#: ../../library/sqlite3.rst:277 msgid "" "How many seconds the connection should wait before raising an :exc:" "`OperationalError` when a table is locked. If another connection opens a " @@ -408,7 +408,7 @@ msgid "" "transaction is committed. Default five seconds." msgstr "" -#: ../../library/sqlite3.rst:286 +#: ../../library/sqlite3.rst:284 msgid "" "Control whether and how data types not :ref:`natively supported by SQLite " "` are looked up to be converted to Python types, using the " @@ -418,7 +418,7 @@ msgid "" "types if both flags are set. By default (``0``), type detection is disabled." msgstr "" -#: ../../library/sqlite3.rst:297 +#: ../../library/sqlite3.rst:295 msgid "" "Control legacy transaction handling behaviour. See :attr:`Connection." "isolation_level` and :ref:`sqlite3-transaction-control-isolation-level` for " @@ -428,7 +428,7 @@ msgid "" "`~sqlite3.LEGACY_TRANSACTION_CONTROL` (the default)." msgstr "" -#: ../../library/sqlite3.rst:307 +#: ../../library/sqlite3.rst:305 msgid "" "If ``True`` (default), :exc:`ProgrammingError` will be raised if the " "database connection is used by a thread other than the one that created it. " @@ -437,19 +437,19 @@ msgid "" "See :attr:`threadsafety` for more information." msgstr "" -#: ../../library/sqlite3.rst:316 +#: ../../library/sqlite3.rst:314 msgid "" "A custom subclass of :class:`Connection` to create the connection with, if " "not the default :class:`Connection` class." msgstr "" -#: ../../library/sqlite3.rst:320 +#: ../../library/sqlite3.rst:318 msgid "" "The number of statements that :mod:`!sqlite3` should internally cache for " "this connection, to avoid parsing overhead. By default, 128 statements." msgstr "" -#: ../../library/sqlite3.rst:325 +#: ../../library/sqlite3.rst:323 msgid "" "If set to ``True``, *database* is interpreted as a :abbr:`URI (Uniform " "Resource Identifier)` with a file path and an optional query string. The " @@ -458,7 +458,7 @@ msgid "" "various :ref:`sqlite3-uri-tricks`." msgstr "" -#: ../../library/sqlite3.rst:334 +#: ../../library/sqlite3.rst:332 msgid "" "Control :pep:`249` transaction handling behaviour. See :attr:`Connection." "autocommit` and :ref:`sqlite3-transaction-control-autocommit` for more " @@ -471,7 +471,7 @@ msgstr "" msgid "Return type" msgstr "" -#: ../../library/sqlite3.rst:345 +#: ../../library/sqlite3.rst:343 msgid "" "Raises an :ref:`auditing event ` ``sqlite3.connect`` with argument " "``database``." @@ -479,7 +479,7 @@ msgstr "" "引發一個附帶引數 ``database`` 的\\ :ref:`稽核事件 ` ``sqlite3." "connect``。" -#: ../../library/sqlite3.rst:346 +#: ../../library/sqlite3.rst:344 msgid "" "Raises an :ref:`auditing event ` ``sqlite3.connect/handle`` with " "argument ``connection_handle``." @@ -487,31 +487,28 @@ msgstr "" "引發一個附帶引數 ``connection_handle`` 的\\ :ref:`稽核事件 ` " "``sqlite3.connect/handle``。" -#: ../../library/sqlite3.rst:348 +#: ../../library/sqlite3.rst:346 msgid "Added the *uri* parameter." msgstr "新增 *uri* 參數。" -#: ../../library/sqlite3.rst:351 +#: ../../library/sqlite3.rst:349 msgid "" "*database* can now also be a :term:`path-like object`, not only a string." msgstr "" -#: ../../library/sqlite3.rst:354 +#: ../../library/sqlite3.rst:352 msgid "Added the ``sqlite3.connect/handle`` auditing event." msgstr "新增 ``sqlite3.connect/handle`` 稽核事件。" -#: ../../library/sqlite3.rst:357 +#: ../../library/sqlite3.rst:355 msgid "Added the *autocommit* parameter." msgstr "新增 *autocommit* 參數。" -#: ../../library/sqlite3.rst:360 -msgid "" -"Positional use of the parameters *timeout*, *detect_types*, " -"*isolation_level*, *check_same_thread*, *factory*, *cached_statements*, and " -"*uri* is deprecated. They will become keyword-only parameters in Python 3.15." +#: ../../library/sqlite3.rst:358 +msgid "All parameters except *database* are now keyword-only." msgstr "" -#: ../../library/sqlite3.rst:368 +#: ../../library/sqlite3.rst:363 msgid "" "Return ``True`` if the string *statement* appears to contain one or more " "complete SQL statements. No syntactic verification or parsing of any kind is " @@ -519,11 +516,11 @@ msgid "" "and the statement is terminated by a semicolon." msgstr "" -#: ../../library/sqlite3.rst:374 +#: ../../library/sqlite3.rst:369 msgid "For example:" msgstr "範例:" -#: ../../library/sqlite3.rst:376 +#: ../../library/sqlite3.rst:371 msgid "" ">>> sqlite3.complete_statement(\"SELECT foo FROM bar;\")\n" "True\n" @@ -535,20 +532,20 @@ msgstr "" ">>> sqlite3.complete_statement(\"SELECT foo\")\n" "False" -#: ../../library/sqlite3.rst:383 +#: ../../library/sqlite3.rst:378 msgid "" "This function may be useful during command-line input to determine if the " "entered text seems to form a complete SQL statement, or if additional input " "is needed before calling :meth:`~Cursor.execute`." msgstr "" -#: ../../library/sqlite3.rst:387 +#: ../../library/sqlite3.rst:382 msgid "" "See :func:`!runsource` in :source:`Lib/sqlite3/__main__.py` for real-world " "use." msgstr "" -#: ../../library/sqlite3.rst:392 +#: ../../library/sqlite3.rst:387 msgid "" "Enable or disable callback tracebacks. By default you will not get any " "tracebacks in user-defined functions, aggregates, converters, authorizer " @@ -557,14 +554,14 @@ msgid "" "on :data:`sys.stderr`. Use ``False`` to disable the feature again." msgstr "" -#: ../../library/sqlite3.rst:401 +#: ../../library/sqlite3.rst:396 msgid "" "Errors in user-defined function callbacks are logged as unraisable " "exceptions. Use an :func:`unraisable hook handler ` for " "introspection of the failed callback." msgstr "" -#: ../../library/sqlite3.rst:407 +#: ../../library/sqlite3.rst:402 msgid "" "Register an *adapter* :term:`callable` to adapt the Python type *type* into " "an SQLite type. The adapter is called with a Python object of type *type* as " @@ -572,7 +569,7 @@ msgid "" "natively understands `." msgstr "" -#: ../../library/sqlite3.rst:415 +#: ../../library/sqlite3.rst:410 msgid "" "Register the *converter* :term:`callable` to convert SQLite objects of type " "*typename* into a Python object of a specific type. The converter is invoked " @@ -582,24 +579,24 @@ msgid "" "type detection works." msgstr "" -#: ../../library/sqlite3.rst:423 +#: ../../library/sqlite3.rst:418 msgid "" "Note: *typename* and the name of the type in your query are matched case-" "insensitively." msgstr "" -#: ../../library/sqlite3.rst:430 +#: ../../library/sqlite3.rst:425 msgid "Module constants" msgstr "" -#: ../../library/sqlite3.rst:434 +#: ../../library/sqlite3.rst:429 msgid "" "Set :attr:`~Connection.autocommit` to this constant to select old style (pre-" "Python 3.12) transaction control behaviour. See :ref:`sqlite3-transaction-" "control-isolation-level` for more information." msgstr "" -#: ../../library/sqlite3.rst:440 +#: ../../library/sqlite3.rst:435 msgid "" "Pass this flag value to the *detect_types* parameter of :func:`connect` to " "look up a converter function using the declared types for each column. The " @@ -608,7 +605,7 @@ msgid "" "the converter dictionary key. For example:" msgstr "" -#: ../../library/sqlite3.rst:448 +#: ../../library/sqlite3.rst:443 msgid "" "CREATE TABLE test(\n" " i integer primary key, ! will look up a converter named \"integer\"\n" @@ -617,19 +614,19 @@ msgid "" " )" msgstr "" -#: ../../library/sqlite3.rst:456 +#: ../../library/sqlite3.rst:451 msgid "" "This flag may be combined with :const:`PARSE_COLNAMES` using the ``|`` " "(bitwise or) operator." msgstr "" -#: ../../library/sqlite3.rst:461 +#: ../../library/sqlite3.rst:456 msgid "" "Generated fields (for example ``MAX(p)``) are returned as :class:`str`. Use :" "const:`!PARSE_COLNAMES` to enforce types for such queries." msgstr "" -#: ../../library/sqlite3.rst:466 +#: ../../library/sqlite3.rst:461 msgid "" "Pass this flag value to the *detect_types* parameter of :func:`connect` to " "look up a converter function by using the type name, parsed from the query " @@ -638,66 +635,76 @@ msgid "" "square brackets (``[]``)." msgstr "" -#: ../../library/sqlite3.rst:473 +#: ../../library/sqlite3.rst:468 msgid "" "SELECT MAX(p) as \"p [point]\" FROM test; ! will look up converter \"point\"" msgstr "" -#: ../../library/sqlite3.rst:477 +#: ../../library/sqlite3.rst:472 msgid "" "This flag may be combined with :const:`PARSE_DECLTYPES` using the ``|`` " "(bitwise or) operator." msgstr "" -#: ../../library/sqlite3.rst:484 +#: ../../library/sqlite3.rst:479 msgid "" "Flags that should be returned by the *authorizer_callback* :term:`callable` " "passed to :meth:`Connection.set_authorizer`, to indicate whether:" msgstr "" -#: ../../library/sqlite3.rst:487 +#: ../../library/sqlite3.rst:482 msgid "Access is allowed (:const:`!SQLITE_OK`)," msgstr "" -#: ../../library/sqlite3.rst:488 +#: ../../library/sqlite3.rst:483 msgid "" "The SQL statement should be aborted with an error (:const:`!SQLITE_DENY`)" msgstr "" -#: ../../library/sqlite3.rst:489 +#: ../../library/sqlite3.rst:484 msgid "" "The column should be treated as a ``NULL`` value (:const:`!SQLITE_IGNORE`)" msgstr "" -#: ../../library/sqlite3.rst:493 +#: ../../library/sqlite3.rst:488 msgid "" "String constant stating the supported DB-API level. Required by the DB-API. " "Hard-coded to ``\"2.0\"``." msgstr "" -#: ../../library/sqlite3.rst:498 +#: ../../library/sqlite3.rst:493 msgid "" "String constant stating the type of parameter marker formatting expected by " "the :mod:`!sqlite3` module. Required by the DB-API. Hard-coded to " "``\"qmark\"``." msgstr "" -#: ../../library/sqlite3.rst:504 +#: ../../library/sqlite3.rst:499 msgid "The ``named`` DB-API parameter style is also supported." msgstr "" -#: ../../library/sqlite3.rst:508 +#: ../../library/sqlite3.rst:503 msgid "" "Version number of the runtime SQLite library as a :class:`string `." msgstr "" -#: ../../library/sqlite3.rst:512 +#: ../../library/sqlite3.rst:507 msgid "" "Version number of the runtime SQLite library as a :class:`tuple` of :class:" "`integers `." msgstr "" -#: ../../library/sqlite3.rst:517 +#: ../../library/sqlite3.rst:512 +msgid "A :class:`tuple` containing all SQLite keywords." +msgstr "" + +#: ../../library/sqlite3.rst:514 +msgid "" +"This constant is only available if Python was compiled with SQLite 3.24.0 or " +"greater." +msgstr "" + +#: ../../library/sqlite3.rst:521 msgid "" "Integer constant required by the DB-API 2.0, stating the level of thread " "safety the :mod:`!sqlite3` module supports. This attribute is set based on " @@ -705,172 +712,172 @@ msgid "" "underlying SQLite library is compiled with. The SQLite threading modes are:" msgstr "" -#: ../../library/sqlite3.rst:522 +#: ../../library/sqlite3.rst:526 msgid "" "**Single-thread**: In this mode, all mutexes are disabled and SQLite is " "unsafe to use in more than a single thread at once." msgstr "" -#: ../../library/sqlite3.rst:524 +#: ../../library/sqlite3.rst:528 msgid "" "**Multi-thread**: In this mode, SQLite can be safely used by multiple " "threads provided that no single database connection is used simultaneously " "in two or more threads." msgstr "" -#: ../../library/sqlite3.rst:527 +#: ../../library/sqlite3.rst:531 msgid "" "**Serialized**: In serialized mode, SQLite can be safely used by multiple " "threads with no restriction." msgstr "" -#: ../../library/sqlite3.rst:530 +#: ../../library/sqlite3.rst:534 msgid "" "The mappings from SQLite threading modes to DB-API 2.0 threadsafety levels " "are as follows:" msgstr "" -#: ../../library/sqlite3.rst:534 +#: ../../library/sqlite3.rst:538 msgid "SQLite threading mode" msgstr "SQLite 執行緒模式" -#: ../../library/sqlite3.rst:534 +#: ../../library/sqlite3.rst:538 msgid ":pep:`threadsafety <0249#threadsafety>`" msgstr ":pep:`執行緒安全 <0249#threadsafety>`" -#: ../../library/sqlite3.rst:534 +#: ../../library/sqlite3.rst:538 msgid "`SQLITE_THREADSAFE`_" msgstr "`SQLITE_THREADSAFE`_" -#: ../../library/sqlite3.rst:534 +#: ../../library/sqlite3.rst:538 msgid "DB-API 2.0 meaning" msgstr "" -#: ../../library/sqlite3.rst:537 +#: ../../library/sqlite3.rst:541 msgid "single-thread" msgstr "" -#: ../../library/sqlite3.rst:537 +#: ../../library/sqlite3.rst:541 msgid "0" msgstr "0" -#: ../../library/sqlite3.rst:537 +#: ../../library/sqlite3.rst:541 msgid "Threads may not share the module" msgstr "" -#: ../../library/sqlite3.rst:540 +#: ../../library/sqlite3.rst:544 msgid "multi-thread" msgstr "" -#: ../../library/sqlite3.rst:540 ../../library/sqlite3.rst:543 +#: ../../library/sqlite3.rst:544 ../../library/sqlite3.rst:547 msgid "1" msgstr "1" -#: ../../library/sqlite3.rst:540 +#: ../../library/sqlite3.rst:544 msgid "2" msgstr "2" -#: ../../library/sqlite3.rst:540 +#: ../../library/sqlite3.rst:544 msgid "Threads may share the module, but not connections" msgstr "" -#: ../../library/sqlite3.rst:543 +#: ../../library/sqlite3.rst:547 msgid "serialized" msgstr "" -#: ../../library/sqlite3.rst:543 +#: ../../library/sqlite3.rst:547 msgid "3" msgstr "3" -#: ../../library/sqlite3.rst:543 +#: ../../library/sqlite3.rst:547 msgid "Threads may share the module, connections and cursors" msgstr "" -#: ../../library/sqlite3.rst:549 +#: ../../library/sqlite3.rst:553 msgid "Set *threadsafety* dynamically instead of hard-coding it to ``1``." msgstr "" -#: ../../library/sqlite3.rst:571 +#: ../../library/sqlite3.rst:575 msgid "" "These constants are used for the :meth:`Connection.setconfig` and :meth:" "`~Connection.getconfig` methods." msgstr "" -#: ../../library/sqlite3.rst:574 +#: ../../library/sqlite3.rst:578 msgid "" "The availability of these constants varies depending on the version of " "SQLite Python was compiled with." msgstr "" -#: ../../library/sqlite3.rst:581 +#: ../../library/sqlite3.rst:585 msgid "https://www.sqlite.org/c3ref/c_dbconfig_defensive.html" msgstr "https://www.sqlite.org/c3ref/c_dbconfig_defensive.html" -#: ../../library/sqlite3.rst:582 +#: ../../library/sqlite3.rst:586 msgid "SQLite docs: Database Connection Configuration Options" msgstr "" -#: ../../library/sqlite3.rst:584 +#: ../../library/sqlite3.rst:588 msgid "The :data:`!version` and :data:`!version_info` constants." msgstr "" -#: ../../library/sqlite3.rst:590 +#: ../../library/sqlite3.rst:594 msgid "Connection objects" msgstr "Connection 物件" -#: ../../library/sqlite3.rst:594 +#: ../../library/sqlite3.rst:598 msgid "" "Each open SQLite database is represented by a ``Connection`` object, which " "is created using :func:`sqlite3.connect`. Their main purpose is creating :" "class:`Cursor` objects, and :ref:`sqlite3-controlling-transactions`." msgstr "" -#: ../../library/sqlite3.rst:601 +#: ../../library/sqlite3.rst:605 msgid ":ref:`sqlite3-connection-shortcuts`" msgstr ":ref:`sqlite3-connection-shortcuts`" -#: ../../library/sqlite3.rst:607 +#: ../../library/sqlite3.rst:611 msgid "" "A :exc:`ResourceWarning` is emitted if :meth:`close` is not called before a :" "class:`!Connection` object is deleted." msgstr "" -#: ../../library/sqlite3.rst:610 +#: ../../library/sqlite3.rst:614 msgid "An SQLite database connection has the following attributes and methods:" msgstr "一個 SQLite 資料庫連線具有以下屬性和方法:" -#: ../../library/sqlite3.rst:614 +#: ../../library/sqlite3.rst:618 msgid "" "Create and return a :class:`Cursor` object. The cursor method accepts a " "single optional parameter *factory*. If supplied, this must be a :term:" "`callable` returning an instance of :class:`Cursor` or its subclasses." msgstr "" -#: ../../library/sqlite3.rst:621 +#: ../../library/sqlite3.rst:625 msgid "" "Open a :class:`Blob` handle to an existing :abbr:`BLOB (Binary Large " "OBject)`." msgstr "" -#: ../../library/sqlite3.rst:624 +#: ../../library/sqlite3.rst:628 msgid "The name of the table where the blob is located." msgstr "" -#: ../../library/sqlite3.rst:627 +#: ../../library/sqlite3.rst:631 msgid "The name of the column where the blob is located." msgstr "" -#: ../../library/sqlite3.rst:630 +#: ../../library/sqlite3.rst:634 msgid "The row id where the blob is located." msgstr "" -#: ../../library/sqlite3.rst:633 +#: ../../library/sqlite3.rst:637 msgid "" "Set to ``True`` if the blob should be opened without write permissions. " "Defaults to ``False``." msgstr "" -#: ../../library/sqlite3.rst:638 +#: ../../library/sqlite3.rst:642 msgid "" "The name of the database where the blob is located. Defaults to ``\"main\"``." msgstr "" @@ -879,17 +886,17 @@ msgstr "" msgid "Raises" msgstr "" -#: ../../library/sqlite3.rst:642 +#: ../../library/sqlite3.rst:646 msgid "When trying to open a blob in a ``WITHOUT ROWID`` table." msgstr "" -#: ../../library/sqlite3.rst:649 +#: ../../library/sqlite3.rst:653 msgid "" "The blob size cannot be changed using the :class:`Blob` class. Use the SQL " "function ``zeroblob`` to create a blob with a fixed size." msgstr "" -#: ../../library/sqlite3.rst:656 +#: ../../library/sqlite3.rst:660 msgid "" "Commit any pending transaction to the database. If :attr:`autocommit` is " "``True``, or there is no open transaction, this method does nothing. If :" @@ -897,7 +904,7 @@ msgid "" "pending transaction was committed by this method." msgstr "" -#: ../../library/sqlite3.rst:664 +#: ../../library/sqlite3.rst:668 msgid "" "Roll back to the start of any pending transaction. If :attr:`autocommit` is " "``True``, or there is no open transaction, this method does nothing. If :" @@ -905,7 +912,7 @@ msgid "" "pending transaction was rolled back by this method." msgstr "" -#: ../../library/sqlite3.rst:672 +#: ../../library/sqlite3.rst:676 msgid "" "Close the database connection. If :attr:`autocommit` is ``False``, any " "pending transaction is implicitly rolled back. If :attr:`!autocommit` is " @@ -914,63 +921,67 @@ msgid "" "losing pending changes." msgstr "" -#: ../../library/sqlite3.rst:682 +#: ../../library/sqlite3.rst:686 msgid "" "Create a new :class:`Cursor` object and call :meth:`~Cursor.execute` on it " "with the given *sql* and *parameters*. Return the new cursor object." msgstr "" -#: ../../library/sqlite3.rst:688 +#: ../../library/sqlite3.rst:692 msgid "" "Create a new :class:`Cursor` object and call :meth:`~Cursor.executemany` on " "it with the given *sql* and *parameters*. Return the new cursor object." msgstr "" -#: ../../library/sqlite3.rst:694 +#: ../../library/sqlite3.rst:698 msgid "" "Create a new :class:`Cursor` object and call :meth:`~Cursor.executescript` " "on it with the given *sql_script*. Return the new cursor object." msgstr "" -#: ../../library/sqlite3.rst:700 +#: ../../library/sqlite3.rst:704 msgid "Create or remove a user-defined SQL function." msgstr "" -#: ../../library/sqlite3.rst:702 +#: ../../library/sqlite3.rst:706 msgid "The name of the SQL function." msgstr "" -#: ../../library/sqlite3.rst:705 +#: ../../library/sqlite3.rst:709 msgid "" "The number of arguments the SQL function can accept. If ``-1``, it may take " "any number of arguments." msgstr "" -#: ../../library/sqlite3.rst:709 +#: ../../library/sqlite3.rst:713 msgid "" "A :term:`callable` that is called when the SQL function is invoked. The " "callable must return :ref:`a type natively supported by SQLite `. Set to ``None`` to remove an existing SQL function." msgstr "" -#: ../../library/sqlite3.rst:716 +#: ../../library/sqlite3.rst:720 msgid "" "If ``True``, the created SQL function is marked as `deterministic `_, which allows SQLite to perform additional " "optimizations." msgstr "" -#: ../../library/sqlite3.rst:721 +#: ../../library/sqlite3.rst:725 msgid "Added the *deterministic* parameter." msgstr "新增 *deterministic* 參數。" -#: ../../library/sqlite3.rst:724 ../../library/sqlite3.rst:768 -#: ../../library/sqlite3.rst:836 ../../library/sqlite3.rst:1115 -#: ../../library/sqlite3.rst:1545 ../../library/sqlite3.rst:1586 +#: ../../library/sqlite3.rst:728 +msgid "The first three parameters are now positional-only." +msgstr "" + +#: ../../library/sqlite3.rst:731 ../../library/sqlite3.rst:773 +#: ../../library/sqlite3.rst:836 ../../library/sqlite3.rst:1112 +#: ../../library/sqlite3.rst:1542 ../../library/sqlite3.rst:1583 msgid "Example:" msgstr "範例:" -#: ../../library/sqlite3.rst:726 +#: ../../library/sqlite3.rst:733 msgid "" ">>> import hashlib\n" ">>> def md5sum(t):\n" @@ -992,27 +1003,21 @@ msgstr "" "('acbd18db4cc2f85cedef654fccc4a4d8',)\n" ">>> con.close()" -#: ../../library/sqlite3.rst:740 -msgid "" -"Passing *name*, *narg*, and *func* as keyword arguments is deprecated. These " -"parameters will become positional-only in Python 3.15." -msgstr "" - -#: ../../library/sqlite3.rst:746 +#: ../../library/sqlite3.rst:748 msgid "Create or remove a user-defined SQL aggregate function." msgstr "" -#: ../../library/sqlite3.rst:748 +#: ../../library/sqlite3.rst:750 msgid "The name of the SQL aggregate function." msgstr "" -#: ../../library/sqlite3.rst:751 +#: ../../library/sqlite3.rst:753 msgid "" "The number of arguments the SQL aggregate function can accept. If ``-1``, it " "may take any number of arguments." msgstr "" -#: ../../library/sqlite3.rst:755 +#: ../../library/sqlite3.rst:757 msgid "" "A class must implement the following methods: * ``step()``: Add a row to " "the aggregate. * ``finalize()``: Return the final result of the aggregate " @@ -1021,31 +1026,35 @@ msgid "" "*n_arg*. Set to ``None`` to remove an existing SQL aggregate function." msgstr "" -#: ../../library/sqlite3.rst:756 +#: ../../library/sqlite3.rst:758 msgid "A class must implement the following methods:" msgstr "" -#: ../../library/sqlite3.rst:758 +#: ../../library/sqlite3.rst:760 msgid "``step()``: Add a row to the aggregate." msgstr "" -#: ../../library/sqlite3.rst:759 ../../library/sqlite3.rst:820 +#: ../../library/sqlite3.rst:761 ../../library/sqlite3.rst:820 msgid "" "``finalize()``: Return the final result of the aggregate as :ref:`a type " "natively supported by SQLite `." msgstr "" -#: ../../library/sqlite3.rst:762 +#: ../../library/sqlite3.rst:764 msgid "" "The number of arguments that the ``step()`` method must accept is controlled " "by *n_arg*." msgstr "" -#: ../../library/sqlite3.rst:765 +#: ../../library/sqlite3.rst:767 msgid "Set to ``None`` to remove an existing SQL aggregate function." msgstr "" #: ../../library/sqlite3.rst:770 +msgid "All three parameters are now positional-only." +msgstr "" + +#: ../../library/sqlite3.rst:775 msgid "" "class MySum:\n" " def __init__(self):\n" @@ -1087,12 +1096,6 @@ msgstr "" "\n" "con.close()" -#: ../../library/sqlite3.rst:799 -msgid "" -"Passing *name*, *n_arg*, and *aggregate_class* as keyword arguments is " -"deprecated. These parameters will become positional-only in Python 3.15." -msgstr "" - #: ../../library/sqlite3.rst:805 msgid "Create or remove a user-defined aggregate window function." msgstr "" @@ -1313,12 +1316,10 @@ msgid "Added support for disabling the authorizer using ``None``." msgstr "新增使用 ``None`` 來停用授權器的支援。" #: ../../library/sqlite3.rst:967 -msgid "" -"Passing *authorizer_callback* as a keyword argument is deprecated. The " -"parameter will become positional-only in Python 3.15." +msgid "The only parameter is now positional-only." msgstr "" -#: ../../library/sqlite3.rst:974 +#: ../../library/sqlite3.rst:973 msgid "" "Register :term:`callable` *progress_handler* to be invoked for every *n* " "instructions of the SQLite virtual machine. This is useful if you want to " @@ -1326,32 +1327,30 @@ msgid "" "a GUI." msgstr "" -#: ../../library/sqlite3.rst:979 +#: ../../library/sqlite3.rst:978 msgid "" "If you want to clear any previously installed progress handler, call the " "method with ``None`` for *progress_handler*." msgstr "" -#: ../../library/sqlite3.rst:982 +#: ../../library/sqlite3.rst:981 msgid "" "Returning a non-zero value from the handler function will terminate the " "currently executing query and cause it to raise a :exc:`DatabaseError` " "exception." msgstr "" -#: ../../library/sqlite3.rst:986 -msgid "" -"Passing *progress_handler* as a keyword argument is deprecated. The " -"parameter will become positional-only in Python 3.15." -msgstr "" +#: ../../library/sqlite3.rst:985 ../../library/sqlite3.rst:1012 +msgid "The first parameter is now positional-only." +msgstr "第一個參數現在為僅限位置參數。" -#: ../../library/sqlite3.rst:993 +#: ../../library/sqlite3.rst:991 msgid "" "Register :term:`callable` *trace_callback* to be invoked for each SQL " "statement that is actually executed by the SQLite backend." msgstr "" -#: ../../library/sqlite3.rst:996 +#: ../../library/sqlite3.rst:994 msgid "" "The only argument passed to the callback is the statement (as :class:`str`) " "that is being executed. The return value of the callback is ignored. Note " @@ -1361,24 +1360,18 @@ msgid "" "execution of triggers defined in the current database." msgstr "" -#: ../../library/sqlite3.rst:1004 +#: ../../library/sqlite3.rst:1002 msgid "Passing ``None`` as *trace_callback* will disable the trace callback." msgstr "" -#: ../../library/sqlite3.rst:1007 +#: ../../library/sqlite3.rst:1005 msgid "" "Exceptions raised in the trace callback are not propagated. As a development " "and debugging aid, use :meth:`~sqlite3.enable_callback_tracebacks` to enable " "printing tracebacks from exceptions raised in the trace callback." msgstr "" -#: ../../library/sqlite3.rst:1014 -msgid "" -"Passing *trace_callback* as a keyword argument is deprecated. The parameter " -"will become positional-only in Python 3.15." -msgstr "" - -#: ../../library/sqlite3.rst:1021 +#: ../../library/sqlite3.rst:1018 msgid "" "Enable the SQLite engine to load SQLite extensions from shared libraries if " "*enabled* is ``True``; else, disallow loading SQLite extensions. SQLite " @@ -1387,7 +1380,7 @@ msgid "" "distributed with SQLite." msgstr "" -#: ../../library/sqlite3.rst:1030 +#: ../../library/sqlite3.rst:1027 msgid "" "The :mod:`!sqlite3` module is not built with loadable extension support by " "default, because some platforms (notably macOS) have SQLite libraries which " @@ -1396,7 +1389,7 @@ msgid "" "program:`configure`." msgstr "" -#: ../../library/sqlite3.rst:1037 +#: ../../library/sqlite3.rst:1034 msgid "" "Raises an :ref:`auditing event ` ``sqlite3.enable_load_extension`` " "with arguments ``connection``, ``enabled``." @@ -1404,11 +1397,11 @@ msgstr "" "引發一個附帶引數 ``connection``、``enabled`` 的\\ :ref:`稽核事件 ` " "``sqlite3.enable_load_extension``。" -#: ../../library/sqlite3.rst:1041 +#: ../../library/sqlite3.rst:1038 msgid "Added the ``sqlite3.enable_load_extension`` auditing event." msgstr "加入 ``sqlite3.enable_load_extension`` 稽核事件。" -#: ../../library/sqlite3.rst:1047 +#: ../../library/sqlite3.rst:1044 msgid "" "con.enable_load_extension(True)\n" "\n" @@ -1438,24 +1431,24 @@ msgid "" " print(row)" msgstr "" -#: ../../library/sqlite3.rst:1073 +#: ../../library/sqlite3.rst:1070 msgid "" "Load an SQLite extension from a shared library. Enable extension loading " "with :meth:`enable_load_extension` before calling this method." msgstr "" -#: ../../library/sqlite3.rst:1077 +#: ../../library/sqlite3.rst:1074 msgid "The path to the SQLite extension." msgstr "" -#: ../../library/sqlite3.rst:1081 +#: ../../library/sqlite3.rst:1078 msgid "" "Entry point name. If ``None`` (the default), SQLite will come up with an " "entry point name of its own; see the SQLite docs `Loading an Extension`_ for " "details." msgstr "" -#: ../../library/sqlite3.rst:1090 +#: ../../library/sqlite3.rst:1087 msgid "" "Raises an :ref:`auditing event ` ``sqlite3.load_extension`` with " "arguments ``connection``, ``path``." @@ -1463,29 +1456,29 @@ msgstr "" "引發一個附帶引數 ``connection``、``path`` 的\\ :ref:`稽核事件 ` " "``sqlite3.load_extension``。" -#: ../../library/sqlite3.rst:1094 +#: ../../library/sqlite3.rst:1091 msgid "Added the ``sqlite3.load_extension`` auditing event." msgstr "加入 ``sqlite3.load_extension`` 稽核事件。" -#: ../../library/sqlite3.rst:1097 +#: ../../library/sqlite3.rst:1094 msgid "Added the *entrypoint* parameter." msgstr "新增 *entrypoint* 參數。" -#: ../../library/sqlite3.rst:1104 +#: ../../library/sqlite3.rst:1101 msgid "" "Return an :term:`iterator` to dump the database as SQL source code. Useful " "when saving an in-memory database for later restoration. Similar to the ``." "dump`` command in the :program:`sqlite3` shell." msgstr "" -#: ../../library/sqlite3.rst:1108 +#: ../../library/sqlite3.rst:1105 msgid "" "An optional ``LIKE`` pattern for database objects to dump, e.g. " "``prefix_%``. If ``None`` (the default), all database objects will be " "included." msgstr "" -#: ../../library/sqlite3.rst:1117 +#: ../../library/sqlite3.rst:1114 msgid "" "# Convert file example.db to SQL dump file dump.sql\n" "con = sqlite3.connect('example.db')\n" @@ -1495,35 +1488,35 @@ msgid "" "con.close()" msgstr "" -#: ../../library/sqlite3.rst:1128 ../../library/sqlite3.rst:1202 +#: ../../library/sqlite3.rst:1125 ../../library/sqlite3.rst:1199 msgid ":ref:`sqlite3-howto-encoding`" msgstr ":ref:`sqlite3-howto-encoding`" -#: ../../library/sqlite3.rst:1130 +#: ../../library/sqlite3.rst:1127 msgid "Added the *filter* parameter." msgstr "新增 *filter* 參數。" -#: ../../library/sqlite3.rst:1135 +#: ../../library/sqlite3.rst:1132 msgid "Create a backup of an SQLite database." msgstr "" -#: ../../library/sqlite3.rst:1137 +#: ../../library/sqlite3.rst:1134 msgid "" "Works even if the database is being accessed by other clients or " "concurrently by the same connection." msgstr "" -#: ../../library/sqlite3.rst:1140 +#: ../../library/sqlite3.rst:1137 msgid "The database connection to save the backup to." msgstr "" -#: ../../library/sqlite3.rst:1143 +#: ../../library/sqlite3.rst:1140 msgid "" "The number of pages to copy at a time. If equal to or less than ``0``, the " "entire database is copied in a single step. Defaults to ``-1``." msgstr "" -#: ../../library/sqlite3.rst:1149 +#: ../../library/sqlite3.rst:1146 msgid "" "If set to a :term:`callable`, it is invoked with three integer arguments for " "every backup iteration: the *status* of the last iteration, the *remaining* " @@ -1531,24 +1524,24 @@ msgid "" "Defaults to ``None``." msgstr "" -#: ../../library/sqlite3.rst:1158 +#: ../../library/sqlite3.rst:1155 msgid "" "The name of the database to back up. Either ``\"main\"`` (the default) for " "the main database, ``\"temp\"`` for the temporary database, or the name of a " "custom database as attached using the ``ATTACH DATABASE`` SQL statement." msgstr "" -#: ../../library/sqlite3.rst:1165 +#: ../../library/sqlite3.rst:1162 msgid "" "The number of seconds to sleep between successive attempts to back up " "remaining pages." msgstr "" -#: ../../library/sqlite3.rst:1169 +#: ../../library/sqlite3.rst:1166 msgid "Example 1, copy an existing database into another:" msgstr "" -#: ../../library/sqlite3.rst:1171 +#: ../../library/sqlite3.rst:1168 msgid "" "def progress(status, remaining, total):\n" " print(f'Copied {total-remaining} of {total} pages...')\n" @@ -1570,11 +1563,11 @@ msgstr "" "dst.close()\n" "src.close()" -#: ../../library/sqlite3.rst:1188 +#: ../../library/sqlite3.rst:1185 msgid "Example 2, copy an existing database into a transient copy:" msgstr "" -#: ../../library/sqlite3.rst:1190 +#: ../../library/sqlite3.rst:1187 msgid "" "src = sqlite3.connect('example.db')\n" "dst = sqlite3.connect(':memory:')\n" @@ -1588,25 +1581,25 @@ msgstr "" "dst.close()\n" "src.close()" -#: ../../library/sqlite3.rst:1206 +#: ../../library/sqlite3.rst:1203 msgid "Get a connection runtime limit." msgstr "" -#: ../../library/sqlite3.rst:1208 +#: ../../library/sqlite3.rst:1205 msgid "The `SQLite limit category`_ to be queried." msgstr "" -#: ../../library/sqlite3.rst:1213 ../../library/sqlite3.rst:1250 +#: ../../library/sqlite3.rst:1210 ../../library/sqlite3.rst:1247 msgid "If *category* is not recognised by the underlying SQLite library." msgstr "" -#: ../../library/sqlite3.rst:1216 +#: ../../library/sqlite3.rst:1213 msgid "" "Example, query the maximum length of an SQL statement for :class:" "`Connection` ``con`` (the default is 1000000000):" msgstr "" -#: ../../library/sqlite3.rst:1226 +#: ../../library/sqlite3.rst:1223 msgid "" ">>> con.getlimit(sqlite3.SQLITE_LIMIT_SQL_LENGTH)\n" "1000000000" @@ -1614,7 +1607,7 @@ msgstr "" ">>> con.getlimit(sqlite3.SQLITE_LIMIT_SQL_LENGTH)\n" "1000000000" -#: ../../library/sqlite3.rst:1236 +#: ../../library/sqlite3.rst:1233 msgid "" "Set a connection runtime limit. Attempts to increase a limit above its hard " "upper bound are silently truncated to the hard upper bound. Regardless of " @@ -1622,22 +1615,22 @@ msgid "" "returned." msgstr "" -#: ../../library/sqlite3.rst:1241 +#: ../../library/sqlite3.rst:1238 msgid "The `SQLite limit category`_ to be set." msgstr "" -#: ../../library/sqlite3.rst:1244 +#: ../../library/sqlite3.rst:1241 msgid "" "The value of the new limit. If negative, the current limit is unchanged." msgstr "" -#: ../../library/sqlite3.rst:1253 +#: ../../library/sqlite3.rst:1250 msgid "" "Example, limit the number of attached databases to 1 for :class:`Connection` " "``con`` (the default limit is 10):" msgstr "" -#: ../../library/sqlite3.rst:1256 +#: ../../library/sqlite3.rst:1253 msgid "" ">>> con.setlimit(sqlite3.SQLITE_LIMIT_ATTACHED, 1)\n" "10\n" @@ -1649,25 +1642,25 @@ msgstr "" ">>> con.getlimit(sqlite3.SQLITE_LIMIT_ATTACHED)\n" "1" -#: ../../library/sqlite3.rst:1274 +#: ../../library/sqlite3.rst:1271 msgid "Query a boolean connection configuration option." msgstr "" -#: ../../library/sqlite3.rst:1276 ../../library/sqlite3.rst:1287 +#: ../../library/sqlite3.rst:1273 ../../library/sqlite3.rst:1284 msgid "A :ref:`SQLITE_DBCONFIG code `." msgstr "" -#: ../../library/sqlite3.rst:1285 +#: ../../library/sqlite3.rst:1282 msgid "Set a boolean connection configuration option." msgstr "" -#: ../../library/sqlite3.rst:1290 +#: ../../library/sqlite3.rst:1287 msgid "" "``True`` if the configuration option should be enabled (default); ``False`` " "if it should be disabled." msgstr "" -#: ../../library/sqlite3.rst:1298 +#: ../../library/sqlite3.rst:1295 msgid "" "Serialize a database into a :class:`bytes` object. For an ordinary on-disk " "database file, the serialization is just a copy of the disk file. For an in-" @@ -1676,17 +1669,17 @@ msgid "" "backed up to disk." msgstr "" -#: ../../library/sqlite3.rst:1304 +#: ../../library/sqlite3.rst:1301 msgid "The database name to be serialized. Defaults to ``\"main\"``." msgstr "" -#: ../../library/sqlite3.rst:1312 +#: ../../library/sqlite3.rst:1309 msgid "" "This method is only available if the underlying SQLite library has the " "serialize API." msgstr "" -#: ../../library/sqlite3.rst:1320 +#: ../../library/sqlite3.rst:1317 msgid "" "Deserialize a :meth:`serialized ` database into a :class:" "`Connection`. This method causes the database connection to disconnect from " @@ -1694,96 +1687,96 @@ msgid "" "serialization contained in *data*." msgstr "" -#: ../../library/sqlite3.rst:1326 +#: ../../library/sqlite3.rst:1323 msgid "A serialized database." msgstr "" -#: ../../library/sqlite3.rst:1329 +#: ../../library/sqlite3.rst:1326 msgid "The database name to deserialize into. Defaults to ``\"main\"``." msgstr "" -#: ../../library/sqlite3.rst:1333 +#: ../../library/sqlite3.rst:1330 msgid "" "If the database connection is currently involved in a read transaction or a " "backup operation." msgstr "" -#: ../../library/sqlite3.rst:1337 +#: ../../library/sqlite3.rst:1334 msgid "If *data* does not contain a valid SQLite database." msgstr "" -#: ../../library/sqlite3.rst:1340 +#: ../../library/sqlite3.rst:1337 msgid "If :func:`len(data) ` is larger than ``2**63 - 1``." msgstr "" -#: ../../library/sqlite3.rst:1345 +#: ../../library/sqlite3.rst:1342 msgid "" "This method is only available if the underlying SQLite library has the " "deserialize API." msgstr "" -#: ../../library/sqlite3.rst:1352 +#: ../../library/sqlite3.rst:1349 msgid "" "This attribute controls :pep:`249`-compliant transaction behaviour. :attr:`!" "autocommit` has three allowed values:" msgstr "" -#: ../../library/sqlite3.rst:1355 +#: ../../library/sqlite3.rst:1352 msgid "" "``False``: Select :pep:`249`-compliant transaction behaviour, implying that :" "mod:`!sqlite3` ensures a transaction is always open. Use :meth:`commit` and :" "meth:`rollback` to close transactions." msgstr "" -#: ../../library/sqlite3.rst:1359 +#: ../../library/sqlite3.rst:1356 msgid "This is the recommended value of :attr:`!autocommit`." msgstr "" -#: ../../library/sqlite3.rst:1361 +#: ../../library/sqlite3.rst:1358 msgid "" "``True``: Use SQLite's `autocommit mode`_. :meth:`commit` and :meth:" "`rollback` have no effect in this mode." msgstr "" -#: ../../library/sqlite3.rst:1364 +#: ../../library/sqlite3.rst:1361 msgid "" ":data:`LEGACY_TRANSACTION_CONTROL`: Pre-Python 3.12 (non-:pep:`249`-" "compliant) transaction control. See :attr:`isolation_level` for more details." msgstr "" -#: ../../library/sqlite3.rst:1368 +#: ../../library/sqlite3.rst:1365 msgid "This is currently the default value of :attr:`!autocommit`." msgstr "" -#: ../../library/sqlite3.rst:1370 +#: ../../library/sqlite3.rst:1367 msgid "" "Changing :attr:`!autocommit` to ``False`` will open a new transaction, and " "changing it to ``True`` will commit any pending transaction." msgstr "" -#: ../../library/sqlite3.rst:1373 +#: ../../library/sqlite3.rst:1370 msgid "See :ref:`sqlite3-transaction-control-autocommit` for more details." msgstr "更多詳情請見 :ref:`sqlite3-transaction-control-autocommit`。" -#: ../../library/sqlite3.rst:1377 +#: ../../library/sqlite3.rst:1374 msgid "" "The :attr:`isolation_level` attribute has no effect unless :attr:" "`autocommit` is :data:`LEGACY_TRANSACTION_CONTROL`." msgstr "" -#: ../../library/sqlite3.rst:1384 +#: ../../library/sqlite3.rst:1381 msgid "" "This read-only attribute corresponds to the low-level SQLite `autocommit " "mode`_." msgstr "" -#: ../../library/sqlite3.rst:1387 +#: ../../library/sqlite3.rst:1384 msgid "" "``True`` if a transaction is active (there are uncommitted changes), " "``False`` otherwise." msgstr "" -#: ../../library/sqlite3.rst:1394 +#: ../../library/sqlite3.rst:1391 msgid "" "Controls the :ref:`legacy transaction handling mode ` of :mod:`!sqlite3`. If set to ``None``, " @@ -1793,13 +1786,13 @@ msgid "" "` is performed." msgstr "" -#: ../../library/sqlite3.rst:1402 +#: ../../library/sqlite3.rst:1399 msgid "" "If not overridden by the *isolation_level* parameter of :func:`connect`, the " "default is ``\"\"``, which is an alias for ``\"DEFERRED\"``." msgstr "" -#: ../../library/sqlite3.rst:1407 +#: ../../library/sqlite3.rst:1404 msgid "" "Using :attr:`autocommit` to control transaction handling is recommended over " "using :attr:`!isolation_level`. :attr:`!isolation_level` has no effect " @@ -1807,7 +1800,7 @@ msgid "" "default)." msgstr "" -#: ../../library/sqlite3.rst:1414 +#: ../../library/sqlite3.rst:1411 msgid "" "The initial :attr:`~Cursor.row_factory` for :class:`Cursor` objects created " "from this connection. Assigning to this attribute does not affect the :attr:" @@ -1816,41 +1809,41 @@ msgid "" "`tuple`." msgstr "" -#: ../../library/sqlite3.rst:1421 ../../library/sqlite3.rst:1719 -#: ../../library/sqlite3.rst:1745 +#: ../../library/sqlite3.rst:1418 ../../library/sqlite3.rst:1716 +#: ../../library/sqlite3.rst:1742 msgid "See :ref:`sqlite3-howto-row-factory` for more details." msgstr "更多詳情請見 :ref:`sqlite3-howto-row-factory`。" -#: ../../library/sqlite3.rst:1423 ../../library/sqlite3.rst:1721 +#: ../../library/sqlite3.rst:1420 ../../library/sqlite3.rst:1718 msgid "Deleting the ``row_factory`` attribute is no longer allowed." msgstr "" -#: ../../library/sqlite3.rst:1428 +#: ../../library/sqlite3.rst:1425 msgid "" "A :term:`callable` that accepts a :class:`bytes` parameter and returns a " "text representation of it. The callable is invoked for SQLite values with " "the ``TEXT`` data type. By default, this attribute is set to :class:`str`." msgstr "" -#: ../../library/sqlite3.rst:1433 +#: ../../library/sqlite3.rst:1430 msgid "See :ref:`sqlite3-howto-encoding` for more details." msgstr "更多詳情請見 :ref:`sqlite3-howto-encoding`。" -#: ../../library/sqlite3.rst:1435 +#: ../../library/sqlite3.rst:1432 msgid "Deleting the ``text_factory`` attribute is no longer allowed." msgstr "" -#: ../../library/sqlite3.rst:1440 +#: ../../library/sqlite3.rst:1437 msgid "" "Return the total number of database rows that have been modified, inserted, " "or deleted since the database connection was opened." msgstr "" -#: ../../library/sqlite3.rst:1447 +#: ../../library/sqlite3.rst:1444 msgid "Cursor objects" msgstr "Cursor 物件" -#: ../../library/sqlite3.rst:1449 +#: ../../library/sqlite3.rst:1446 msgid "" "A ``Cursor`` object represents a `database cursor`_ which is used to execute " "SQL statements, and manage the context of a fetch operation. Cursors are " @@ -1858,14 +1851,14 @@ msgid "" "`connection shortcut methods `." msgstr "" -#: ../../library/sqlite3.rst:1456 +#: ../../library/sqlite3.rst:1453 msgid "" "Cursor objects are :term:`iterators `, meaning that if you :meth:" "`~Cursor.execute` a ``SELECT`` query, you can simply iterate over the cursor " "to fetch the resulting rows:" msgstr "" -#: ../../library/sqlite3.rst:1467 +#: ../../library/sqlite3.rst:1464 msgid "" "for row in cur.execute(\"SELECT t FROM data\"):\n" " print(row)" @@ -1873,35 +1866,35 @@ msgstr "" "for row in cur.execute(\"SELECT t FROM data\"):\n" " print(row)" -#: ../../library/sqlite3.rst:1481 +#: ../../library/sqlite3.rst:1478 msgid "A :class:`Cursor` instance has the following attributes and methods." msgstr ":class:`Cursor` 實例具有以下屬性和方法。" -#: ../../library/sqlite3.rst:1488 +#: ../../library/sqlite3.rst:1485 msgid "" "Execute a single SQL statement, optionally binding Python values using :ref:" "`placeholders `." msgstr "" -#: ../../library/sqlite3.rst:1492 +#: ../../library/sqlite3.rst:1489 msgid "A single SQL statement." msgstr "單一個 SQL 陳述式。" -#: ../../library/sqlite3.rst:1495 +#: ../../library/sqlite3.rst:1492 msgid "" "Python values to bind to placeholders in *sql*. A :class:`!dict` if named " "placeholders are used. A :term:`!sequence` if unnamed placeholders are used. " "See :ref:`sqlite3-placeholders`." msgstr "" -#: ../../library/sqlite3.rst:1502 +#: ../../library/sqlite3.rst:1499 msgid "" "When *sql* contains more than one SQL statement. When :ref:`named " "placeholders ` are used and *parameters* is a sequence " "instead of a :class:`dict`." msgstr "" -#: ../../library/sqlite3.rst:1507 +#: ../../library/sqlite3.rst:1504 msgid "" "If :attr:`~Connection.autocommit` is :data:`LEGACY_TRANSACTION_CONTROL`, :" "attr:`~Connection.isolation_level` is not ``None``, *sql* is an ``INSERT``, " @@ -1909,46 +1902,46 @@ msgid "" "transaction, a transaction is implicitly opened before executing *sql*." msgstr "" -#: ../../library/sqlite3.rst:1516 +#: ../../library/sqlite3.rst:1513 msgid "" ":exc:`ProgrammingError` is emitted if :ref:`named placeholders ` are used and *parameters* is a sequence instead of a :class:" "`dict`." msgstr "" -#: ../../library/sqlite3.rst:1520 +#: ../../library/sqlite3.rst:1517 msgid "Use :meth:`executescript` to execute multiple SQL statements." msgstr "" -#: ../../library/sqlite3.rst:1524 +#: ../../library/sqlite3.rst:1521 msgid "" "For every item in *parameters*, repeatedly execute the :ref:`parameterized " "` :abbr:`DML (Data Manipulation Language)` SQL " "statement *sql*." msgstr "" -#: ../../library/sqlite3.rst:1528 +#: ../../library/sqlite3.rst:1525 msgid "Uses the same implicit transaction handling as :meth:`~Cursor.execute`." msgstr "" -#: ../../library/sqlite3.rst:1530 +#: ../../library/sqlite3.rst:1527 msgid "A single SQL DML statement." msgstr "" -#: ../../library/sqlite3.rst:1533 +#: ../../library/sqlite3.rst:1530 msgid "" "An :term:`!iterable` of parameters to bind with the placeholders in *sql*. " "See :ref:`sqlite3-placeholders`." msgstr "" -#: ../../library/sqlite3.rst:1539 +#: ../../library/sqlite3.rst:1536 msgid "" "When *sql* contains more than one SQL statement or is not a DML statement, " "When :ref:`named placeholders ` are used and the items " "in *parameters* are sequences instead of :class:`dict`\\s." msgstr "" -#: ../../library/sqlite3.rst:1547 +#: ../../library/sqlite3.rst:1544 msgid "" "rows = [\n" " (\"row1\",),\n" @@ -1964,20 +1957,20 @@ msgstr "" "# cur 是一個 sqlite3.Cursor 物件\n" "cur.executemany(\"INSERT INTO data VALUES(?)\", rows)" -#: ../../library/sqlite3.rst:1562 +#: ../../library/sqlite3.rst:1559 msgid "" "Any resulting rows are discarded, including DML statements with `RETURNING " "clauses`_." msgstr "" -#: ../../library/sqlite3.rst:1569 +#: ../../library/sqlite3.rst:1566 msgid "" ":exc:`ProgrammingError` is emitted if :ref:`named placeholders ` are used and the items in *parameters* are sequences instead " "of :class:`dict`\\s." msgstr "" -#: ../../library/sqlite3.rst:1576 +#: ../../library/sqlite3.rst:1573 msgid "" "Execute the SQL statements in *sql_script*. If the :attr:`~Connection." "autocommit` is :data:`LEGACY_TRANSACTION_CONTROL` and there is a pending " @@ -1986,11 +1979,11 @@ msgid "" "added to *sql_script*." msgstr "" -#: ../../library/sqlite3.rst:1584 +#: ../../library/sqlite3.rst:1581 msgid "*sql_script* must be a :class:`string `." msgstr "*sql_script* 必須是一個 :class:`string `。" -#: ../../library/sqlite3.rst:1588 +#: ../../library/sqlite3.rst:1585 msgid "" "# cur is an sqlite3.Cursor object\n" "cur.executescript(\"\"\"\n" @@ -2010,20 +2003,20 @@ msgstr "" " COMMIT;\n" "\"\"\")" -#: ../../library/sqlite3.rst:1601 +#: ../../library/sqlite3.rst:1598 msgid "" "If :attr:`~Cursor.row_factory` is ``None``, return the next row query result " "set as a :class:`tuple`. Else, pass it to the row factory and return its " "result. Return ``None`` if no more data is available." msgstr "" -#: ../../library/sqlite3.rst:1609 +#: ../../library/sqlite3.rst:1606 msgid "" "Return the next set of rows of a query result as a :class:`list`. Return an " "empty list if no more rows are available." msgstr "" -#: ../../library/sqlite3.rst:1612 +#: ../../library/sqlite3.rst:1609 msgid "" "The number of rows to fetch per call is specified by the *size* parameter. " "If *size* is not given, :attr:`arraysize` determines the number of rows to " @@ -2031,7 +2024,7 @@ msgid "" "available are returned." msgstr "" -#: ../../library/sqlite3.rst:1618 +#: ../../library/sqlite3.rst:1615 msgid "" "Note there are performance considerations involved with the *size* " "parameter. For optimal performance, it is usually best to use the arraysize " @@ -2039,44 +2032,44 @@ msgid "" "the same value from one :meth:`fetchmany` call to the next." msgstr "" -#: ../../library/sqlite3.rst:1623 +#: ../../library/sqlite3.rst:1620 msgid "Negative *size* values are rejected by raising :exc:`ValueError`." msgstr "" -#: ../../library/sqlite3.rst:1628 +#: ../../library/sqlite3.rst:1625 msgid "" "Return all (remaining) rows of a query result as a :class:`list`. Return an " "empty list if no rows are available. Note that the :attr:`arraysize` " "attribute can affect the performance of this operation." msgstr "" -#: ../../library/sqlite3.rst:1635 +#: ../../library/sqlite3.rst:1632 msgid "Close the cursor now (rather than whenever ``__del__`` is called)." msgstr "" -#: ../../library/sqlite3.rst:1637 +#: ../../library/sqlite3.rst:1634 msgid "" "The cursor will be unusable from this point forward; a :exc:" "`ProgrammingError` exception will be raised if any operation is attempted " "with the cursor." msgstr "" -#: ../../library/sqlite3.rst:1642 ../../library/sqlite3.rst:1646 +#: ../../library/sqlite3.rst:1639 ../../library/sqlite3.rst:1643 msgid "Required by the DB-API. Does nothing in :mod:`!sqlite3`." msgstr "" -#: ../../library/sqlite3.rst:1650 +#: ../../library/sqlite3.rst:1647 msgid "" "Read/write attribute that controls the number of rows returned by :meth:" "`fetchmany`. The default value is 1 which means a single row would be " "fetched per call." msgstr "" -#: ../../library/sqlite3.rst:1653 +#: ../../library/sqlite3.rst:1650 msgid "Negative values are rejected by raising :exc:`ValueError`." msgstr "" -#: ../../library/sqlite3.rst:1658 +#: ../../library/sqlite3.rst:1655 msgid "" "Read-only attribute that provides the SQLite database :class:`Connection` " "belonging to the cursor. A :class:`Cursor` object created by calling :meth:" @@ -2084,7 +2077,7 @@ msgid "" "that refers to *con*:" msgstr "" -#: ../../library/sqlite3.rst:1663 +#: ../../library/sqlite3.rst:1660 msgid "" ">>> con = sqlite3.connect(\":memory:\")\n" ">>> cur = con.cursor()\n" @@ -2098,18 +2091,18 @@ msgstr "" "True\n" ">>> con.close()" -#: ../../library/sqlite3.rst:1673 +#: ../../library/sqlite3.rst:1670 msgid "" "Read-only attribute that provides the column names of the last query. To " "remain compatible with the Python DB API, it returns a 7-tuple for each " "column where the last six items of each tuple are ``None``." msgstr "" -#: ../../library/sqlite3.rst:1677 +#: ../../library/sqlite3.rst:1674 msgid "It is set for ``SELECT`` statements without any matching rows as well." msgstr "" -#: ../../library/sqlite3.rst:1681 +#: ../../library/sqlite3.rst:1678 msgid "" "Read-only attribute that provides the row id of the last inserted row. It is " "only updated after successful ``INSERT`` or ``REPLACE`` statements using " @@ -2119,15 +2112,15 @@ msgid "" "``None``." msgstr "" -#: ../../library/sqlite3.rst:1689 +#: ../../library/sqlite3.rst:1686 msgid "Inserts into ``WITHOUT ROWID`` tables are not recorded." msgstr "" -#: ../../library/sqlite3.rst:1691 +#: ../../library/sqlite3.rst:1688 msgid "Added support for the ``REPLACE`` statement." msgstr "新增 ``REPLACE`` 陳述式的支援。" -#: ../../library/sqlite3.rst:1696 +#: ../../library/sqlite3.rst:1693 msgid "" "Read-only attribute that provides the number of modified rows for " "``INSERT``, ``UPDATE``, ``DELETE``, and ``REPLACE`` statements; is ``-1`` " @@ -2137,7 +2130,7 @@ msgid "" "resulting rows must be fetched in order for :attr:`!rowcount` to be updated." msgstr "" -#: ../../library/sqlite3.rst:1707 +#: ../../library/sqlite3.rst:1704 msgid "" "Control how a row fetched from this :class:`!Cursor` is represented. If " "``None``, a row is represented as a :class:`tuple`. Can be set to the " @@ -2146,18 +2139,18 @@ msgid "" "and returns a custom object representing an SQLite row." msgstr "" -#: ../../library/sqlite3.rst:1714 +#: ../../library/sqlite3.rst:1711 msgid "" "Defaults to what :attr:`Connection.row_factory` was set to when the :class:`!" "Cursor` was created. Assigning to this attribute does not affect :attr:" "`Connection.row_factory` of the parent connection." msgstr "" -#: ../../library/sqlite3.rst:1733 +#: ../../library/sqlite3.rst:1730 msgid "Row objects" msgstr "Row 物件" -#: ../../library/sqlite3.rst:1737 +#: ../../library/sqlite3.rst:1734 msgid "" "A :class:`!Row` instance serves as a highly optimized :attr:`~Connection." "row_factory` for :class:`Connection` objects. It supports iteration, " @@ -2165,28 +2158,28 @@ msgid "" "index." msgstr "" -#: ../../library/sqlite3.rst:1742 +#: ../../library/sqlite3.rst:1739 msgid "" "Two :class:`!Row` objects compare equal if they have identical column names " "and values." msgstr "" -#: ../../library/sqlite3.rst:1749 +#: ../../library/sqlite3.rst:1746 msgid "" "Return a :class:`list` of column names as :class:`strings `. " "Immediately after a query, it is the first member of each tuple in :attr:" "`Cursor.description`." msgstr "" -#: ../../library/sqlite3.rst:1753 +#: ../../library/sqlite3.rst:1750 msgid "Added support of slicing." msgstr "新增對切片的支援。" -#: ../../library/sqlite3.rst:1760 +#: ../../library/sqlite3.rst:1757 msgid "Blob objects" msgstr "Blob 物件" -#: ../../library/sqlite3.rst:1766 +#: ../../library/sqlite3.rst:1763 msgid "" "A :class:`Blob` instance is a :term:`file-like object` that can read and " "write data in an SQLite :abbr:`BLOB (Binary Large OBject)`. Call :func:" @@ -2194,13 +2187,13 @@ msgid "" "and :term:`slices ` for direct access to the blob data." msgstr "" -#: ../../library/sqlite3.rst:1771 +#: ../../library/sqlite3.rst:1768 msgid "" "Use the :class:`Blob` as a :term:`context manager` to ensure that the blob " "handle is closed after use." msgstr "" -#: ../../library/sqlite3.rst:1774 +#: ../../library/sqlite3.rst:1771 msgid "" "con = sqlite3.connect(\":memory:\")\n" "con.execute(\"CREATE TABLE test(blob_col blob)\")\n" @@ -2222,18 +2215,18 @@ msgid "" "con.close()" msgstr "" -#: ../../library/sqlite3.rst:1802 +#: ../../library/sqlite3.rst:1799 msgid "Close the blob." msgstr "" -#: ../../library/sqlite3.rst:1804 +#: ../../library/sqlite3.rst:1801 msgid "" "The blob will be unusable from this point onward. An :class:`~sqlite3." "Error` (or subclass) exception will be raised if any further operation is " "attempted with the blob." msgstr "" -#: ../../library/sqlite3.rst:1810 +#: ../../library/sqlite3.rst:1807 msgid "" "Read *length* bytes of data from the blob at the current offset position. If " "the end of the blob is reached, the data up to :abbr:`EOF (End of File)` " @@ -2241,18 +2234,18 @@ msgid "" "`~Blob.read` will read until the end of the blob." msgstr "" -#: ../../library/sqlite3.rst:1818 +#: ../../library/sqlite3.rst:1815 msgid "" "Write *data* to the blob at the current offset. This function cannot change " "the blob length. Writing beyond the end of the blob will raise :exc:" "`ValueError`." msgstr "" -#: ../../library/sqlite3.rst:1824 +#: ../../library/sqlite3.rst:1821 msgid "Return the current access position of the blob." msgstr "" -#: ../../library/sqlite3.rst:1828 +#: ../../library/sqlite3.rst:1825 msgid "" "Set the current access position of the blob to *offset*. The *origin* " "argument defaults to :const:`os.SEEK_SET` (absolute blob positioning). Other " @@ -2260,26 +2253,26 @@ msgid "" "position) and :const:`os.SEEK_END` (seek relative to the blob’s end)." msgstr "" -#: ../../library/sqlite3.rst:1836 +#: ../../library/sqlite3.rst:1833 msgid "PrepareProtocol objects" msgstr "PrepareProtocol 物件" -#: ../../library/sqlite3.rst:1840 +#: ../../library/sqlite3.rst:1837 msgid "" "The PrepareProtocol type's single purpose is to act as a :pep:`246` style " "adaption protocol for objects that can :ref:`adapt themselves ` to :ref:`native SQLite types `." msgstr "" -#: ../../library/sqlite3.rst:1848 +#: ../../library/sqlite3.rst:1845 msgid "Exceptions" msgstr "例外" -#: ../../library/sqlite3.rst:1850 +#: ../../library/sqlite3.rst:1847 msgid "The exception hierarchy is defined by the DB-API 2.0 (:pep:`249`)." msgstr "" -#: ../../library/sqlite3.rst:1854 +#: ../../library/sqlite3.rst:1851 msgid "" "This exception is not currently raised by the :mod:`!sqlite3` module, but " "may be raised by applications using :mod:`!sqlite3`, for example if a user-" @@ -2287,39 +2280,39 @@ msgid "" "of :exc:`Exception`." msgstr "" -#: ../../library/sqlite3.rst:1861 +#: ../../library/sqlite3.rst:1858 msgid "" "The base class of the other exceptions in this module. Use this to catch all " "errors with one single :keyword:`except` statement. ``Error`` is a subclass " "of :exc:`Exception`." msgstr "" -#: ../../library/sqlite3.rst:1865 +#: ../../library/sqlite3.rst:1862 msgid "" "If the exception originated from within the SQLite library, the following " "two attributes are added to the exception:" msgstr "" -#: ../../library/sqlite3.rst:1870 +#: ../../library/sqlite3.rst:1867 msgid "" "The numeric error code from the `SQLite API `_" msgstr "" -#: ../../library/sqlite3.rst:1877 +#: ../../library/sqlite3.rst:1874 msgid "" "The symbolic name of the numeric error code from the `SQLite API `_" msgstr "" -#: ../../library/sqlite3.rst:1884 +#: ../../library/sqlite3.rst:1881 msgid "" "Exception raised for misuse of the low-level SQLite C API. In other words, " "if this exception is raised, it probably indicates a bug in the :mod:`!" "sqlite3` module. ``InterfaceError`` is a subclass of :exc:`Error`." msgstr "" -#: ../../library/sqlite3.rst:1891 +#: ../../library/sqlite3.rst:1888 msgid "" "Exception raised for errors that are related to the database. This serves as " "the base exception for several types of database errors. It is only raised " @@ -2327,14 +2320,14 @@ msgid "" "subclass of :exc:`Error`." msgstr "" -#: ../../library/sqlite3.rst:1898 +#: ../../library/sqlite3.rst:1895 msgid "" "Exception raised for errors caused by problems with the processed data, like " "numeric values out of range, and strings which are too long. ``DataError`` " "is a subclass of :exc:`DatabaseError`." msgstr "" -#: ../../library/sqlite3.rst:1904 +#: ../../library/sqlite3.rst:1901 msgid "" "Exception raised for errors that are related to the database's operation, " "and not necessarily under the control of the programmer. For example, the " @@ -2342,20 +2335,20 @@ msgid "" "``OperationalError`` is a subclass of :exc:`DatabaseError`." msgstr "" -#: ../../library/sqlite3.rst:1912 +#: ../../library/sqlite3.rst:1909 msgid "" "Exception raised when the relational integrity of the database is affected, " "e.g. a foreign key check fails. It is a subclass of :exc:`DatabaseError`." msgstr "" -#: ../../library/sqlite3.rst:1917 +#: ../../library/sqlite3.rst:1914 msgid "" "Exception raised when SQLite encounters an internal error. If this is " "raised, it may indicate that there is a problem with the runtime SQLite " "library. ``InternalError`` is a subclass of :exc:`DatabaseError`." msgstr "" -#: ../../library/sqlite3.rst:1924 +#: ../../library/sqlite3.rst:1921 msgid "" "Exception raised for :mod:`!sqlite3` API programming errors, for example " "supplying the wrong number of bindings to a query, or trying to operate on a " @@ -2363,7 +2356,7 @@ msgid "" "`DatabaseError`." msgstr "" -#: ../../library/sqlite3.rst:1931 +#: ../../library/sqlite3.rst:1928 msgid "" "Exception raised in case a method or database API is not supported by the " "underlying SQLite library. For example, setting *deterministic* to ``True`` " @@ -2372,78 +2365,78 @@ msgid "" "subclass of :exc:`DatabaseError`." msgstr "" -#: ../../library/sqlite3.rst:1941 +#: ../../library/sqlite3.rst:1938 msgid "SQLite and Python types" msgstr "" -#: ../../library/sqlite3.rst:1943 +#: ../../library/sqlite3.rst:1940 msgid "" "SQLite natively supports the following types: ``NULL``, ``INTEGER``, " "``REAL``, ``TEXT``, ``BLOB``." msgstr "" -#: ../../library/sqlite3.rst:1946 +#: ../../library/sqlite3.rst:1943 msgid "" "The following Python types can thus be sent to SQLite without any problem:" msgstr "" -#: ../../library/sqlite3.rst:1949 ../../library/sqlite3.rst:1966 +#: ../../library/sqlite3.rst:1946 ../../library/sqlite3.rst:1963 msgid "Python type" msgstr "" -#: ../../library/sqlite3.rst:1949 ../../library/sqlite3.rst:1966 +#: ../../library/sqlite3.rst:1946 ../../library/sqlite3.rst:1963 msgid "SQLite type" msgstr "" -#: ../../library/sqlite3.rst:1951 ../../library/sqlite3.rst:1968 +#: ../../library/sqlite3.rst:1948 ../../library/sqlite3.rst:1965 msgid "``None``" msgstr "``None``" -#: ../../library/sqlite3.rst:1951 ../../library/sqlite3.rst:1968 +#: ../../library/sqlite3.rst:1948 ../../library/sqlite3.rst:1965 msgid "``NULL``" msgstr "``NULL``" -#: ../../library/sqlite3.rst:1953 ../../library/sqlite3.rst:1970 +#: ../../library/sqlite3.rst:1950 ../../library/sqlite3.rst:1967 msgid ":class:`int`" msgstr ":class:`int`" -#: ../../library/sqlite3.rst:1953 ../../library/sqlite3.rst:1970 +#: ../../library/sqlite3.rst:1950 ../../library/sqlite3.rst:1967 msgid "``INTEGER``" msgstr "``INTEGER``" -#: ../../library/sqlite3.rst:1955 ../../library/sqlite3.rst:1972 +#: ../../library/sqlite3.rst:1952 ../../library/sqlite3.rst:1969 msgid ":class:`float`" msgstr ":class:`float`" -#: ../../library/sqlite3.rst:1955 ../../library/sqlite3.rst:1972 +#: ../../library/sqlite3.rst:1952 ../../library/sqlite3.rst:1969 msgid "``REAL``" msgstr "``REAL``" -#: ../../library/sqlite3.rst:1957 +#: ../../library/sqlite3.rst:1954 msgid ":class:`str`" msgstr ":class:`str`" -#: ../../library/sqlite3.rst:1957 ../../library/sqlite3.rst:1974 +#: ../../library/sqlite3.rst:1954 ../../library/sqlite3.rst:1971 msgid "``TEXT``" msgstr "``TEXT``" -#: ../../library/sqlite3.rst:1959 ../../library/sqlite3.rst:1977 +#: ../../library/sqlite3.rst:1956 ../../library/sqlite3.rst:1974 msgid ":class:`bytes`" msgstr ":class:`bytes`" -#: ../../library/sqlite3.rst:1959 ../../library/sqlite3.rst:1977 +#: ../../library/sqlite3.rst:1956 ../../library/sqlite3.rst:1974 msgid "``BLOB``" msgstr "``BLOB``" -#: ../../library/sqlite3.rst:1963 +#: ../../library/sqlite3.rst:1960 msgid "This is how SQLite types are converted to Python types by default:" msgstr "" -#: ../../library/sqlite3.rst:1974 +#: ../../library/sqlite3.rst:1971 msgid "depends on :attr:`~Connection.text_factory`, :class:`str` by default" msgstr "" -#: ../../library/sqlite3.rst:1980 +#: ../../library/sqlite3.rst:1977 msgid "" "The type system of the :mod:`!sqlite3` module is extensible in two ways: you " "can store additional Python types in an SQLite database via :ref:`object " @@ -2452,47 +2445,47 @@ msgid "" "converters>`." msgstr "" -#: ../../library/sqlite3.rst:1990 +#: ../../library/sqlite3.rst:1987 msgid "Default adapters and converters (deprecated)" msgstr "" -#: ../../library/sqlite3.rst:1994 +#: ../../library/sqlite3.rst:1991 msgid "" "The default adapters and converters are deprecated as of Python 3.12. " "Instead, use the :ref:`sqlite3-adapter-converter-recipes` and tailor them to " "your needs." msgstr "" -#: ../../library/sqlite3.rst:1998 +#: ../../library/sqlite3.rst:1995 msgid "The deprecated default adapters and converters consist of:" msgstr "" -#: ../../library/sqlite3.rst:2000 +#: ../../library/sqlite3.rst:1997 msgid "" "An adapter for :class:`datetime.date` objects to :class:`strings ` in " "`ISO 8601`_ format." msgstr "" -#: ../../library/sqlite3.rst:2002 +#: ../../library/sqlite3.rst:1999 msgid "" "An adapter for :class:`datetime.datetime` objects to strings in ISO 8601 " "format." msgstr "" -#: ../../library/sqlite3.rst:2004 +#: ../../library/sqlite3.rst:2001 msgid "" "A converter for :ref:`declared ` \"date\" types to :" "class:`datetime.date` objects." msgstr "" -#: ../../library/sqlite3.rst:2006 +#: ../../library/sqlite3.rst:2003 msgid "" "A converter for declared \"timestamp\" types to :class:`datetime.datetime` " "objects. Fractional parts will be truncated to 6 digits (microsecond " "precision)." msgstr "" -#: ../../library/sqlite3.rst:2012 +#: ../../library/sqlite3.rst:2009 msgid "" "The default \"timestamp\" converter ignores UTC offsets in the database and " "always returns a naive :class:`datetime.datetime` object. To preserve UTC " @@ -2500,42 +2493,42 @@ msgid "" "offset-aware converter with :func:`register_converter`." msgstr "" -#: ../../library/sqlite3.rst:2025 +#: ../../library/sqlite3.rst:2022 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/sqlite3.rst:2027 +#: ../../library/sqlite3.rst:2024 msgid "" "The :mod:`!sqlite3` module can be invoked as a script, using the " "interpreter's :option:`-m` switch, in order to provide a simple SQLite " "shell. The argument signature is as follows::" msgstr "" -#: ../../library/sqlite3.rst:2032 +#: ../../library/sqlite3.rst:2029 msgid "python -m sqlite3 [-h] [-v] [filename] [sql]" msgstr "python -m sqlite3 [-h] [-v] [filename] [sql]" -#: ../../library/sqlite3.rst:2034 +#: ../../library/sqlite3.rst:2031 msgid "Type ``.quit`` or CTRL-D to exit the shell." msgstr "" -#: ../../library/sqlite3.rst:2040 +#: ../../library/sqlite3.rst:2037 msgid "Print CLI help." msgstr "" -#: ../../library/sqlite3.rst:2044 +#: ../../library/sqlite3.rst:2041 msgid "Print underlying SQLite library version." msgstr "" -#: ../../library/sqlite3.rst:2052 +#: ../../library/sqlite3.rst:2049 msgid "How-to guides" msgstr "" -#: ../../library/sqlite3.rst:2057 +#: ../../library/sqlite3.rst:2054 msgid "How to use placeholders to bind values in SQL queries" msgstr "" -#: ../../library/sqlite3.rst:2059 +#: ../../library/sqlite3.rst:2056 msgid "" "SQL operations usually need to use values from Python variables. However, " "beware of using Python's string operations to assemble queries, as they are " @@ -2543,7 +2536,7 @@ msgid "" "close the single quote and inject ``OR TRUE`` to select all rows::" msgstr "" -#: ../../library/sqlite3.rst:2064 +#: ../../library/sqlite3.rst:2061 msgid "" ">>> # Never do this -- insecure!\n" ">>> symbol = input()\n" @@ -2561,7 +2554,7 @@ msgstr "" "SELECT * FROM stocks WHERE symbol = '' OR TRUE; --'\n" ">>> cur.execute(sql)" -#: ../../library/sqlite3.rst:2072 +#: ../../library/sqlite3.rst:2069 msgid "" "Instead, use the DB-API's parameter substitution. To insert a variable into " "a query string, use a placeholder in the string, and substitute the actual " @@ -2569,7 +2562,7 @@ msgid "" "second argument of the cursor's :meth:`~Cursor.execute` method." msgstr "" -#: ../../library/sqlite3.rst:2077 +#: ../../library/sqlite3.rst:2074 msgid "" "An SQL statement may use one of two kinds of placeholders: question marks " "(qmark style) or named placeholders (named style). For the qmark style, " @@ -2580,7 +2573,7 @@ msgid "" "ignored. Here's an example of both styles:" msgstr "" -#: ../../library/sqlite3.rst:2088 +#: ../../library/sqlite3.rst:2085 msgid "" "con = sqlite3.connect(\":memory:\")\n" "cur = con.execute(\"CREATE TABLE lang(name, first_appeared)\")\n" @@ -2601,24 +2594,24 @@ msgid "" "con.close()" msgstr "" -#: ../../library/sqlite3.rst:2115 +#: ../../library/sqlite3.rst:2112 msgid "" ":pep:`249` numeric placeholders are *not* supported. If used, they will be " "interpreted as named placeholders." msgstr "" -#: ../../library/sqlite3.rst:2122 +#: ../../library/sqlite3.rst:2119 msgid "How to adapt custom Python types to SQLite values" msgstr "" -#: ../../library/sqlite3.rst:2124 +#: ../../library/sqlite3.rst:2121 msgid "" "SQLite supports only a limited set of data types natively. To store custom " "Python types in SQLite databases, *adapt* them to one of the :ref:`Python " "types SQLite natively understands `." msgstr "" -#: ../../library/sqlite3.rst:2128 +#: ../../library/sqlite3.rst:2125 msgid "" "There are two ways to adapt Python objects to SQLite types: letting your " "object adapt itself, or using an *adapter callable*. The latter will take " @@ -2628,11 +2621,11 @@ msgid "" "custom adapter functions." msgstr "" -#: ../../library/sqlite3.rst:2140 +#: ../../library/sqlite3.rst:2137 msgid "How to write adaptable objects" msgstr "" -#: ../../library/sqlite3.rst:2142 +#: ../../library/sqlite3.rst:2139 msgid "" "Suppose we have a :class:`!Point` class that represents a pair of " "coordinates, ``x`` and ``y``, in a Cartesian coordinate system. The " @@ -2642,7 +2635,7 @@ msgid "" "object passed to *protocol* will be of type :class:`PrepareProtocol`." msgstr "" -#: ../../library/sqlite3.rst:2150 +#: ../../library/sqlite3.rst:2147 msgid "" "class Point:\n" " def __init__(self, x, y):\n" @@ -2674,18 +2667,18 @@ msgstr "" "print(cur.fetchone()[0])\n" "con.close()" -#: ../../library/sqlite3.rst:2174 +#: ../../library/sqlite3.rst:2171 msgid "How to register adapter callables" msgstr "" -#: ../../library/sqlite3.rst:2176 +#: ../../library/sqlite3.rst:2173 msgid "" "The other possibility is to create a function that converts the Python " "object to an SQLite-compatible type. This function can then be registered " "using :func:`register_adapter`." msgstr "" -#: ../../library/sqlite3.rst:2180 +#: ../../library/sqlite3.rst:2177 msgid "" "class Point:\n" " def __init__(self, x, y):\n" @@ -2719,36 +2712,36 @@ msgstr "" "print(cur.fetchone()[0])\n" "con.close()" -#: ../../library/sqlite3.rst:2207 +#: ../../library/sqlite3.rst:2204 msgid "How to convert SQLite values to custom Python types" msgstr "" -#: ../../library/sqlite3.rst:2209 +#: ../../library/sqlite3.rst:2206 msgid "" "Writing an adapter lets you convert *from* custom Python types *to* SQLite " "values. To be able to convert *from* SQLite values *to* custom Python types, " "we use *converters*." msgstr "" -#: ../../library/sqlite3.rst:2214 +#: ../../library/sqlite3.rst:2211 msgid "" "Let's go back to the :class:`!Point` class. We stored the x and y " "coordinates separated via semicolons as strings in SQLite." msgstr "" -#: ../../library/sqlite3.rst:2217 +#: ../../library/sqlite3.rst:2214 msgid "" "First, we'll define a converter function that accepts the string as a " "parameter and constructs a :class:`!Point` object from it." msgstr "" -#: ../../library/sqlite3.rst:2222 +#: ../../library/sqlite3.rst:2219 msgid "" "Converter functions are **always** passed a :class:`bytes` object, no matter " "the underlying SQLite data type." msgstr "" -#: ../../library/sqlite3.rst:2225 +#: ../../library/sqlite3.rst:2222 msgid "" "def convert_point(s):\n" " x, y = map(float, s.split(b\";\"))\n" @@ -2758,32 +2751,32 @@ msgstr "" " x, y = map(float, s.split(b\";\"))\n" " return Point(x, y)" -#: ../../library/sqlite3.rst:2231 +#: ../../library/sqlite3.rst:2228 msgid "" "We now need to tell :mod:`!sqlite3` when it should convert a given SQLite " "value. This is done when connecting to a database, using the *detect_types* " "parameter of :func:`connect`. There are three options:" msgstr "" -#: ../../library/sqlite3.rst:2235 +#: ../../library/sqlite3.rst:2232 msgid "Implicit: set *detect_types* to :const:`PARSE_DECLTYPES`" msgstr "" -#: ../../library/sqlite3.rst:2236 +#: ../../library/sqlite3.rst:2233 msgid "Explicit: set *detect_types* to :const:`PARSE_COLNAMES`" msgstr "" -#: ../../library/sqlite3.rst:2237 +#: ../../library/sqlite3.rst:2234 msgid "" "Both: set *detect_types* to ``sqlite3.PARSE_DECLTYPES | sqlite3." "PARSE_COLNAMES``. Column names take precedence over declared types." msgstr "" -#: ../../library/sqlite3.rst:2241 +#: ../../library/sqlite3.rst:2238 msgid "The following example illustrates the implicit and explicit approaches:" msgstr "" -#: ../../library/sqlite3.rst:2243 +#: ../../library/sqlite3.rst:2240 msgid "" "class Point:\n" " def __init__(self, x, y):\n" @@ -2825,15 +2818,15 @@ msgid "" "con.close()" msgstr "" -#: ../../library/sqlite3.rst:2294 +#: ../../library/sqlite3.rst:2291 msgid "Adapter and converter recipes" msgstr "" -#: ../../library/sqlite3.rst:2296 +#: ../../library/sqlite3.rst:2293 msgid "This section shows recipes for common adapters and converters." msgstr "" -#: ../../library/sqlite3.rst:2298 +#: ../../library/sqlite3.rst:2295 msgid "" "import datetime as dt\n" "import sqlite3\n" @@ -2871,11 +2864,11 @@ msgid "" "sqlite3.register_converter(\"timestamp\", convert_timestamp)" msgstr "" -#: ../../library/sqlite3.rst:2358 +#: ../../library/sqlite3.rst:2355 msgid "How to use connection shortcut methods" msgstr "" -#: ../../library/sqlite3.rst:2360 +#: ../../library/sqlite3.rst:2357 msgid "" "Using the :meth:`~Connection.execute`, :meth:`~Connection.executemany`, and :" "meth:`~Connection.executescript` methods of the :class:`Connection` class, " @@ -2887,7 +2880,7 @@ msgid "" "object." msgstr "" -#: ../../library/sqlite3.rst:2369 +#: ../../library/sqlite3.rst:2366 msgid "" "# Create and fill the table.\n" "con = sqlite3.connect(\":memory:\")\n" @@ -2911,11 +2904,11 @@ msgid "" "con.close()" msgstr "" -#: ../../library/sqlite3.rst:2401 +#: ../../library/sqlite3.rst:2398 msgid "How to use the connection context manager" msgstr "" -#: ../../library/sqlite3.rst:2403 +#: ../../library/sqlite3.rst:2400 msgid "" "A :class:`Connection` object can be used as a context manager that " "automatically commits or rolls back open transactions when leaving the body " @@ -2927,21 +2920,21 @@ msgid "" "rolling back." msgstr "" -#: ../../library/sqlite3.rst:2414 +#: ../../library/sqlite3.rst:2411 msgid "" "If there is no open transaction upon leaving the body of the ``with`` " "statement, or if :attr:`~Connection.autocommit` is ``True``, the context " "manager does nothing." msgstr "" -#: ../../library/sqlite3.rst:2419 +#: ../../library/sqlite3.rst:2416 msgid "" "The context manager neither implicitly opens a new transaction nor closes " "the connection. If you need a closing context manager, consider using :meth:" "`contextlib.closing`." msgstr "" -#: ../../library/sqlite3.rst:2423 +#: ../../library/sqlite3.rst:2420 msgid "" "con = sqlite3.connect(\":memory:\")\n" "con.execute(\"CREATE TABLE lang(id INTEGER PRIMARY KEY, name VARCHAR " @@ -2965,19 +2958,19 @@ msgid "" "con.close()" msgstr "" -#: ../../library/sqlite3.rst:2453 +#: ../../library/sqlite3.rst:2450 msgid "How to work with SQLite URIs" msgstr "" -#: ../../library/sqlite3.rst:2455 +#: ../../library/sqlite3.rst:2452 msgid "Some useful URI tricks include:" msgstr "" -#: ../../library/sqlite3.rst:2457 +#: ../../library/sqlite3.rst:2454 msgid "Open a database in read-only mode:" msgstr "以唯讀模式開啟資料庫:" -#: ../../library/sqlite3.rst:2459 +#: ../../library/sqlite3.rst:2456 msgid "" ">>> con = sqlite3.connect(\"file:tutorial.db?mode=ro\", uri=True)\n" ">>> con.execute(\"CREATE TABLE readonly(data)\")\n" @@ -2991,13 +2984,13 @@ msgstr "" "OperationalError: attempt to write a readonly database\n" ">>> con.close()" -#: ../../library/sqlite3.rst:2467 +#: ../../library/sqlite3.rst:2464 msgid "" "Do not implicitly create a new database file if it does not already exist; " "will raise :exc:`~sqlite3.OperationalError` if unable to create a new file:" msgstr "" -#: ../../library/sqlite3.rst:2470 +#: ../../library/sqlite3.rst:2467 msgid "" ">>> con = sqlite3.connect(\"file:nosuchdb.db?mode=rw\", uri=True)\n" "Traceback (most recent call last):\n" @@ -3007,11 +3000,11 @@ msgstr "" "Traceback (most recent call last):\n" "OperationalError: unable to open database file" -#: ../../library/sqlite3.rst:2477 +#: ../../library/sqlite3.rst:2474 msgid "Create a shared named in-memory database:" msgstr "" -#: ../../library/sqlite3.rst:2479 +#: ../../library/sqlite3.rst:2476 msgid "" "db = \"file:mem1?mode=memory&cache=shared\"\n" "con1 = sqlite3.connect(db, uri=True)\n" @@ -3037,24 +3030,24 @@ msgstr "" "con1.close()\n" "con2.close()" -#: ../../library/sqlite3.rst:2493 +#: ../../library/sqlite3.rst:2490 msgid "" "More information about this feature, including a list of parameters, can be " "found in the `SQLite URI documentation`_." msgstr "" -#: ../../library/sqlite3.rst:2502 +#: ../../library/sqlite3.rst:2499 msgid "How to create and use row factories" msgstr "" -#: ../../library/sqlite3.rst:2504 +#: ../../library/sqlite3.rst:2501 msgid "" "By default, :mod:`!sqlite3` represents each row as a :class:`tuple`. If a :" "class:`!tuple` does not suit your needs, you can use the :class:`sqlite3." "Row` class or a custom :attr:`~Cursor.row_factory`." msgstr "" -#: ../../library/sqlite3.rst:2509 +#: ../../library/sqlite3.rst:2506 msgid "" "While :attr:`!row_factory` exists as an attribute both on the :class:" "`Cursor` and the :class:`Connection`, it is recommended to set :class:" @@ -3062,7 +3055,7 @@ msgid "" "use the same row factory." msgstr "" -#: ../../library/sqlite3.rst:2514 +#: ../../library/sqlite3.rst:2511 msgid "" ":class:`!Row` provides indexed and case-insensitive named access to columns, " "with minimal memory overhead and performance impact over a :class:`!tuple`. " @@ -3070,7 +3063,7 @@ msgid "" "attribute:" msgstr "" -#: ../../library/sqlite3.rst:2519 +#: ../../library/sqlite3.rst:2516 msgid "" ">>> con = sqlite3.connect(\":memory:\")\n" ">>> con.row_factory = sqlite3.Row" @@ -3078,11 +3071,11 @@ msgstr "" ">>> con = sqlite3.connect(\":memory:\")\n" ">>> con.row_factory = sqlite3.Row" -#: ../../library/sqlite3.rst:2524 +#: ../../library/sqlite3.rst:2521 msgid "Queries now return :class:`!Row` objects:" msgstr "" -#: ../../library/sqlite3.rst:2526 +#: ../../library/sqlite3.rst:2523 msgid "" ">>> res = con.execute(\"SELECT 'Earth' AS name, 6378 AS radius\")\n" ">>> row = res.fetchone()\n" @@ -3097,7 +3090,7 @@ msgid "" ">>> con.close()" msgstr "" -#: ../../library/sqlite3.rst:2542 +#: ../../library/sqlite3.rst:2539 msgid "" "The ``FROM`` clause can be omitted in the ``SELECT`` statement, as in the " "above example. In such cases, SQLite returns a single row with columns " @@ -3105,13 +3098,13 @@ msgid "" "alias``." msgstr "" -#: ../../library/sqlite3.rst:2547 +#: ../../library/sqlite3.rst:2544 msgid "" "You can create a custom :attr:`~Cursor.row_factory` that returns each row as " "a :class:`dict`, with column names mapped to values:" msgstr "" -#: ../../library/sqlite3.rst:2550 +#: ../../library/sqlite3.rst:2547 msgid "" "def dict_factory(cursor, row):\n" " fields = [column[0] for column in cursor.description]\n" @@ -3121,12 +3114,12 @@ msgstr "" " fields = [column[0] for column in cursor.description]\n" " return {key: value for key, value in zip(fields, row)}" -#: ../../library/sqlite3.rst:2556 +#: ../../library/sqlite3.rst:2553 msgid "" "Using it, queries now return a :class:`!dict` instead of a :class:`!tuple`:" msgstr "" -#: ../../library/sqlite3.rst:2558 +#: ../../library/sqlite3.rst:2555 msgid "" ">>> con = sqlite3.connect(\":memory:\")\n" ">>> con.row_factory = dict_factory\n" @@ -3142,11 +3135,11 @@ msgstr "" "{'a': 1, 'b': 2}\n" ">>> con.close()" -#: ../../library/sqlite3.rst:2567 +#: ../../library/sqlite3.rst:2564 msgid "The following row factory returns a :term:`named tuple`:" msgstr "" -#: ../../library/sqlite3.rst:2569 +#: ../../library/sqlite3.rst:2566 msgid "" "from collections import namedtuple\n" "\n" @@ -3162,11 +3155,11 @@ msgstr "" " cls = namedtuple(\"Row\", fields)\n" " return cls._make(row)" -#: ../../library/sqlite3.rst:2578 +#: ../../library/sqlite3.rst:2575 msgid ":func:`!namedtuple_factory` can be used as follows:" msgstr ":func:`!namedtuple_factory` 可以如下使用:" -#: ../../library/sqlite3.rst:2580 +#: ../../library/sqlite3.rst:2577 msgid "" ">>> con = sqlite3.connect(\":memory:\")\n" ">>> con.row_factory = namedtuple_factory\n" @@ -3192,18 +3185,18 @@ msgstr "" "2\n" ">>> con.close()" -#: ../../library/sqlite3.rst:2594 +#: ../../library/sqlite3.rst:2591 msgid "" "With some adjustments, the above recipe can be adapted to use a :class:" "`~dataclasses.dataclass`, or any other custom class, instead of a :class:" "`~collections.namedtuple`." msgstr "" -#: ../../library/sqlite3.rst:2602 +#: ../../library/sqlite3.rst:2599 msgid "How to handle non-UTF-8 text encodings" msgstr "如何處理非 UTF-8 的文字編碼" -#: ../../library/sqlite3.rst:2604 +#: ../../library/sqlite3.rst:2601 msgid "" "By default, :mod:`!sqlite3` uses :class:`str` to adapt SQLite values with " "the ``TEXT`` data type. This works well for UTF-8 encoded text, but it might " @@ -3211,7 +3204,7 @@ msgid "" "`~Connection.text_factory` to handle such cases." msgstr "" -#: ../../library/sqlite3.rst:2610 +#: ../../library/sqlite3.rst:2607 msgid "" "Because of SQLite's `flexible typing`_, it is not uncommon to encounter " "table columns with the ``TEXT`` data type containing non-UTF-8 encodings, or " @@ -3222,39 +3215,39 @@ msgid "" "text using this :attr:`~Connection.text_factory`:" msgstr "" -#: ../../library/sqlite3.rst:2619 +#: ../../library/sqlite3.rst:2616 msgid "con.text_factory = lambda data: str(data, encoding=\"latin2\")" msgstr "con.text_factory = lambda data: str(data, encoding=\"latin2\")" -#: ../../library/sqlite3.rst:2623 +#: ../../library/sqlite3.rst:2620 msgid "" "For invalid UTF-8 or arbitrary data in stored in ``TEXT`` table columns, you " "can use the following technique, borrowed from the :ref:`unicode-howto`:" msgstr "" -#: ../../library/sqlite3.rst:2626 +#: ../../library/sqlite3.rst:2623 msgid "con.text_factory = lambda data: str(data, errors=\"surrogateescape\")" msgstr "con.text_factory = lambda data: str(data, errors=\"surrogateescape\")" -#: ../../library/sqlite3.rst:2632 +#: ../../library/sqlite3.rst:2629 msgid "" "The :mod:`!sqlite3` module API does not support strings containing " "surrogates." msgstr "" -#: ../../library/sqlite3.rst:2637 +#: ../../library/sqlite3.rst:2634 msgid ":ref:`unicode-howto`" msgstr ":ref:`unicode-howto`" -#: ../../library/sqlite3.rst:2643 +#: ../../library/sqlite3.rst:2640 msgid "Explanation" msgstr "解釋" -#: ../../library/sqlite3.rst:2649 +#: ../../library/sqlite3.rst:2646 msgid "Transaction control" msgstr "" -#: ../../library/sqlite3.rst:2651 +#: ../../library/sqlite3.rst:2648 msgid "" ":mod:`!sqlite3` offers multiple methods of controlling whether, when and how " "database transactions are opened and closed. :ref:`sqlite3-transaction-" @@ -3262,24 +3255,24 @@ msgid "" "isolation-level` retains the pre-Python 3.12 behaviour." msgstr "" -#: ../../library/sqlite3.rst:2660 +#: ../../library/sqlite3.rst:2657 msgid "Transaction control via the ``autocommit`` attribute" msgstr "" -#: ../../library/sqlite3.rst:2662 +#: ../../library/sqlite3.rst:2659 msgid "" "The recommended way of controlling transaction behaviour is through the :" "attr:`Connection.autocommit` attribute, which should preferably be set using " "the *autocommit* parameter of :func:`connect`." msgstr "" -#: ../../library/sqlite3.rst:2667 +#: ../../library/sqlite3.rst:2664 msgid "" "It is suggested to set *autocommit* to ``False``, which implies :pep:`249`-" "compliant transaction control. This means:" msgstr "" -#: ../../library/sqlite3.rst:2671 +#: ../../library/sqlite3.rst:2668 msgid "" ":mod:`!sqlite3` ensures that a transaction is always open, so :func:" "`connect`, :meth:`Connection.commit`, and :meth:`Connection.rollback` will " @@ -3288,21 +3281,21 @@ msgid "" "when opening transactions." msgstr "" -#: ../../library/sqlite3.rst:2676 +#: ../../library/sqlite3.rst:2673 msgid "Transactions should be committed explicitly using :meth:`!commit`." msgstr "" -#: ../../library/sqlite3.rst:2677 +#: ../../library/sqlite3.rst:2674 msgid "Transactions should be rolled back explicitly using :meth:`!rollback`." msgstr "" -#: ../../library/sqlite3.rst:2678 +#: ../../library/sqlite3.rst:2675 msgid "" "An implicit rollback is performed if the database is :meth:`~Connection." "close`-ed with pending changes." msgstr "" -#: ../../library/sqlite3.rst:2681 +#: ../../library/sqlite3.rst:2678 msgid "" "Set *autocommit* to ``True`` to enable SQLite's `autocommit mode`_. In this " "mode, :meth:`Connection.commit` and :meth:`Connection.rollback` have no " @@ -3311,25 +3304,25 @@ msgid "" "in_transaction` to query the low-level SQLite autocommit mode." msgstr "" -#: ../../library/sqlite3.rst:2689 +#: ../../library/sqlite3.rst:2686 msgid "" "Set *autocommit* to :data:`LEGACY_TRANSACTION_CONTROL` to leave transaction " "control behaviour to the :attr:`Connection.isolation_level` attribute. See :" "ref:`sqlite3-transaction-control-isolation-level` for more information." msgstr "" -#: ../../library/sqlite3.rst:2698 +#: ../../library/sqlite3.rst:2695 msgid "Transaction control via the ``isolation_level`` attribute" msgstr "" -#: ../../library/sqlite3.rst:2702 +#: ../../library/sqlite3.rst:2699 msgid "" "The recommended way of controlling transactions is via the :attr:" "`~Connection.autocommit` attribute. See :ref:`sqlite3-transaction-control-" "autocommit`." msgstr "" -#: ../../library/sqlite3.rst:2706 +#: ../../library/sqlite3.rst:2703 msgid "" "If :attr:`Connection.autocommit` is set to :data:" "`LEGACY_TRANSACTION_CONTROL` (the default), transaction behaviour is " @@ -3337,7 +3330,7 @@ msgid "" "Otherwise, :attr:`!isolation_level` has no effect." msgstr "" -#: ../../library/sqlite3.rst:2712 +#: ../../library/sqlite3.rst:2709 msgid "" "If the connection attribute :attr:`~Connection.isolation_level` is not " "``None``, new transactions are implicitly opened before :meth:`~Cursor." @@ -3351,7 +3344,7 @@ msgid "" "attribute." msgstr "" -#: ../../library/sqlite3.rst:2725 +#: ../../library/sqlite3.rst:2722 msgid "" "If :attr:`~Connection.isolation_level` is set to ``None``, no transactions " "are implicitly opened at all. This leaves the underlying SQLite library in " @@ -3361,33 +3354,33 @@ msgid "" "in_transaction` attribute." msgstr "" -#: ../../library/sqlite3.rst:2733 +#: ../../library/sqlite3.rst:2730 msgid "" "The :meth:`~Cursor.executescript` method implicitly commits any pending " "transaction before execution of the given SQL script, regardless of the " "value of :attr:`~Connection.isolation_level`." msgstr "" -#: ../../library/sqlite3.rst:2737 +#: ../../library/sqlite3.rst:2734 msgid "" ":mod:`!sqlite3` used to implicitly commit an open transaction before DDL " "statements. This is no longer the case." msgstr "" -#: ../../library/sqlite3.rst:2741 +#: ../../library/sqlite3.rst:2738 msgid "" "The recommended way of controlling transactions is now via the :attr:" "`~Connection.autocommit` attribute." msgstr "" -#: ../../library/sqlite3.rst:1483 +#: ../../library/sqlite3.rst:1480 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/sqlite3.rst:1483 ../../library/sqlite3.rst:1484 +#: ../../library/sqlite3.rst:1480 ../../library/sqlite3.rst:1481 msgid "in SQL statements" msgstr "於 SQL 陳述式中" -#: ../../library/sqlite3.rst:1484 +#: ../../library/sqlite3.rst:1481 msgid ": (colon)" msgstr ": (冒號)" diff --git a/library/ssl.po b/library/ssl.po index 16c41156aa7..28166d062fd 100644 --- a/library/ssl.po +++ b/library/ssl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-01 00:24+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!ssl` --- TLS/SSL wrapper for socket objects" msgstr ":mod:`!ssl` --- socket 物件的 TLS/SSL 包裝器" -#: ../../library/ssl.rst:10 +#: ../../library/ssl.rst:7 msgid "**Source code:** :source:`Lib/ssl.py`" msgstr "**原始碼:**\\ :source:`Lib/ssl.py`" -#: ../../library/ssl.rst:18 +#: ../../library/ssl.rst:15 msgid "" "This module provides access to Transport Layer Security (often known as " "\"Secure Sockets Layer\") encryption and peer authentication facilities for " @@ -45,7 +45,7 @@ msgid "" "module-requirements`." msgstr "" -#: ../../library/ssl.rst:27 +#: ../../library/ssl.rst:24 msgid "" "Some behavior may be platform dependent, since calls are made to the " "operating system socket APIs. The installed version of OpenSSL may also " @@ -55,7 +55,7 @@ msgstr "" "由於呼叫了作業系統的 socket APIs,有些行為會根據平台而有所不同。OpenSSL 的安" "裝版本也會對模組的運作產生影響。例如,OpenSSL 版本 1.1.1 附帶 TLSv1.3。" -#: ../../library/ssl.rst:33 +#: ../../library/ssl.rst:30 msgid "" "Don't use this module without reading the :ref:`ssl-security`. Doing so may " "lead to a false sense of security, as the default settings of the ssl module " @@ -64,7 +64,7 @@ msgstr "" "在使用此模組之前,請閱讀 :ref:`ssl-security`。如果不這樣做,可能會產生錯誤的" "安全性認知,因為 ssl 模組的預設設定未必適合你的應用程式。" -#: ../../library/ssl.rst:456 ../../library/ssl.rst:471 +#: ../../library/ssl.rst:471 ../../library/ssl.rst:486 #: ../../includes/wasm-notavail.rst:3 msgid "Availability" msgstr "可用性" @@ -77,7 +77,7 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/ssl.rst:39 +#: ../../library/ssl.rst:36 msgid "" "This section documents the objects and functions in the ``ssl`` module; for " "more general information about TLS, SSL, and certificates, the reader is " @@ -86,7 +86,7 @@ msgstr "" "這個章節記錄了 ``ssl`` 模組的物件及函式;關於 TSL、SSL、以及憑證的更多資訊," "可以去參考此章節底部的「詳情」部分。" -#: ../../library/ssl.rst:43 +#: ../../library/ssl.rst:40 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 " @@ -104,7 +104,7 @@ msgstr "" "(cipher);和 :meth:`get_verified_chain`、:meth:`get_unverified_chain` 能用於" "取得憑證鏈。" -#: ../../library/ssl.rst:52 +#: ../../library/ssl.rst:49 msgid "" "For more sophisticated applications, the :class:`ssl.SSLContext` class helps " "manage settings and certificates, which can then be inherited by SSL sockets " @@ -114,11 +114,11 @@ msgstr "" "可以透過 :meth:`SSLContext.wrap_socket` 方法建立的 SSL socket 繼承這些設定和" "認證。" -#: ../../library/ssl.rst:56 +#: ../../library/ssl.rst:53 msgid "Updated to support linking with OpenSSL 1.1.0" msgstr "更新以支援與 OpenSSL 1.1.0 進行連結" -#: ../../library/ssl.rst:61 +#: ../../library/ssl.rst:58 msgid "" "OpenSSL 0.9.8, 1.0.0 and 1.0.1 are deprecated and no longer supported. In " "the future the ssl module will require at least OpenSSL 1.0.2 or 1.1.0." @@ -126,26 +126,26 @@ msgstr "" "OpenSSL 0.9.8, 1.0.0 及 1.0.1 版本已被棄用且不再支援。在未來 ssl 模組將需要至" "少 OpenSSL 1.0.2 版本或 1.1.0 版本。" -#: ../../library/ssl.rst:67 +#: ../../library/ssl.rst:64 msgid "" ":pep:`644` has been implemented. The ssl module requires OpenSSL 1.1.1 or " "newer." msgstr ":pep:`644` 已經被實作。ssl 模組需要 OpenSSL 1.1.1 以上的版本才能使用。" -#: ../../library/ssl.rst:70 +#: ../../library/ssl.rst:67 msgid "" "Use of deprecated constants and functions result in deprecation warnings." msgstr "使用已經被棄用的常數或函式將會導致棄用警示。" -#: ../../library/ssl.rst:74 +#: ../../library/ssl.rst:71 msgid "Functions, constants, and exceptions" msgstr "函式、常數與例外" -#: ../../library/ssl.rst:78 +#: ../../library/ssl.rst:75 msgid "Socket creation" msgstr "Socket 建立" -#: ../../library/ssl.rst:80 +#: ../../library/ssl.rst:77 msgid "" "Instances of :class:`SSLSocket` must be created using the :meth:`SSLContext." "wrap_socket` method. The helper function :func:`create_default_context` " @@ -155,11 +155,11 @@ msgstr "" "助函式 :func:`create_default_context` 會回傳有安全預設設定的新語境 " "(context)。" -#: ../../library/ssl.rst:85 +#: ../../library/ssl.rst:82 msgid "Client socket example with default context and IPv4/IPv6 dual stack::" msgstr "使用預設語境及 IPv4/IPv6 雙協定堆疊的用戶端 socket 範例: ::" -#: ../../library/ssl.rst:87 +#: ../../library/ssl.rst:84 msgid "" "import socket\n" "import ssl\n" @@ -181,11 +181,11 @@ msgstr "" " with context.wrap_socket(sock, server_hostname=hostname) as ssock:\n" " print(ssock.version())" -#: ../../library/ssl.rst:98 +#: ../../library/ssl.rst:95 msgid "Client socket example with custom context and IPv4::" msgstr "使用自訂語境及 IPv4 的用戶端 socket範例: ::" -#: ../../library/ssl.rst:100 +#: ../../library/ssl.rst:97 msgid "" "hostname = 'www.python.org'\n" "# PROTOCOL_TLS_CLIENT requires valid cert chain and hostname\n" @@ -197,11 +197,11 @@ msgid "" " print(ssock.version())" msgstr "" -#: ../../library/ssl.rst:110 +#: ../../library/ssl.rst:107 msgid "Server socket example listening on localhost IPv4::" msgstr "在本地 IPv4 上監聽伺服器 socket 的範例: ::" -#: ../../library/ssl.rst:112 +#: ../../library/ssl.rst:109 msgid "" "context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)\n" "context.load_cert_chain('/path/to/certchain.pem', '/path/to/private.key')\n" @@ -223,17 +223,17 @@ msgstr "" " conn, addr = ssock.accept()\n" " ..." -#: ../../library/ssl.rst:124 +#: ../../library/ssl.rst:121 msgid "Context creation" msgstr "語境建立" -#: ../../library/ssl.rst:126 +#: ../../library/ssl.rst:123 msgid "" "A convenience function helps create :class:`SSLContext` objects for common " "purposes." msgstr "一個可以幫忙建立出 :class:`SSLContext` 物件以用於一般目的的方便函式。" -#: ../../library/ssl.rst:132 +#: ../../library/ssl.rst:129 msgid "" "Return a new :class:`SSLContext` object with default settings for the given " "*purpose*. The settings are chosen by the :mod:`!ssl` module, and usually " @@ -244,7 +244,7 @@ msgstr "" "是由 :mod:`!ssl` 模組選擇,通常比直接呼叫 :class:`SSLContext` 建構函式有更高" "的安全性。" -#: ../../library/ssl.rst:137 +#: ../../library/ssl.rst:134 msgid "" "*cafile*, *capath*, *cadata* represent optional CA certificates to trust for " "certificate verification, as in :meth:`SSLContext.load_verify_locations`. " @@ -261,7 +261,7 @@ msgstr "" # 其文中表示可能是指 128bit 以上 key length 的加密算法,需要其他來源佐證。 # 或是 https://help.fortinet.com/fweb/582/Content/FortiWeb/fortiweb- # admin/supported_cipher_suites.htm#ssl_414712646_1189301 -#: ../../library/ssl.rst:143 +#: ../../library/ssl.rst:140 msgid "" "The settings are: :data:`PROTOCOL_TLS_CLIENT` or :data:" "`PROTOCOL_TLS_SERVER`, :data:`OP_NO_SSLv2`, and :data:`OP_NO_SSLv3` with " @@ -280,7 +280,7 @@ msgstr "" "個值有被設定時) 或使用預設的 CA 憑證 :meth:`SSLContext." "load_default_certs` 。" -#: ../../library/ssl.rst:152 +#: ../../library/ssl.rst:149 msgid "" "When :attr:`~SSLContext.keylog_filename` is supported and the environment " "variable :envvar:`SSLKEYLOGFILE` is set, :func:`create_default_context` " @@ -290,7 +290,7 @@ msgstr "" "`SSLKEYLOGFILE` 時 :func:`create_default_context` 會啟用密鑰日誌記錄 " "(logging)。" -#: ../../library/ssl.rst:156 +#: ../../library/ssl.rst:153 msgid "" "The default settings for this context include :data:" "`VERIFY_X509_PARTIAL_CHAIN` and :data:`VERIFY_X509_STRICT`. These make the " @@ -299,7 +299,7 @@ msgid "" "incompatibility with older X.509 certificates." msgstr "" -#: ../../library/ssl.rst:163 +#: ../../library/ssl.rst:160 msgid "" "The protocol, options, cipher and other settings may change to more " "restrictive values anytime without prior deprecation. The values represent " @@ -308,7 +308,7 @@ msgstr "" "協定、選項、加密方式和其它設定可以在不捨棄舊值的情況下直接更改成新的值,這些" "值代表了在相容性和安全性之間取得的合理平衡。" -#: ../../library/ssl.rst:167 +#: ../../library/ssl.rst:164 msgid "" "If your application needs specific settings, you should create a :class:" "`SSLContext` and apply the settings yourself." @@ -316,7 +316,7 @@ msgstr "" "如果你的應用程式需要特殊的設定,你應該要自行建立一個 :class:`SSLContext` 並自" "行調整設定。" -#: ../../library/ssl.rst:171 +#: ../../library/ssl.rst:168 msgid "" "If you find that when certain older clients or servers attempt to connect " "with a :class:`SSLContext` created by this function that they get an error " @@ -332,7 +332,7 @@ msgstr "" "SSL3.0 已經\\ `被完全破解 `_。如果你仍" "然希望在允許 SSL3.0 連線的情況下使用此函式,可以使用下面的方法: ::" -#: ../../library/ssl.rst:180 +#: ../../library/ssl.rst:177 msgid "" "ctx = ssl.create_default_context(Purpose.CLIENT_AUTH)\n" "ctx.options &= ~ssl.OP_NO_SSLv3" @@ -340,7 +340,7 @@ msgstr "" "ctx = ssl.create_default_context(Purpose.CLIENT_AUTH)\n" "ctx.options &= ~ssl.OP_NO_SSLv3" -#: ../../library/ssl.rst:184 +#: ../../library/ssl.rst:181 msgid "" "This context enables :data:`VERIFY_X509_STRICT` by default, which may reject " "pre-:rfc:`5280` or malformed certificates that the underlying OpenSSL " @@ -348,7 +348,7 @@ msgid "" "recommended, you can do so using::" msgstr "" -#: ../../library/ssl.rst:189 +#: ../../library/ssl.rst:186 msgid "" "ctx = ssl.create_default_context()\n" "ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT" @@ -356,23 +356,23 @@ msgstr "" "ctx = ssl.create_default_context()\n" "ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT" -#: ../../library/ssl.rst:196 +#: ../../library/ssl.rst:193 msgid "RC4 was dropped from the default cipher string." msgstr "把 RC4 從預設加密方法字串中捨棄。" -#: ../../library/ssl.rst:200 +#: ../../library/ssl.rst:197 msgid "ChaCha20/Poly1305 was added to the default cipher string." msgstr "把 ChaCha20/Poly1305 加入預設加密方法字串。" -#: ../../library/ssl.rst:202 +#: ../../library/ssl.rst:199 msgid "3DES was dropped from the default cipher string." msgstr "把 3DES 從預設加密方法字串中捨棄。" -#: ../../library/ssl.rst:206 +#: ../../library/ssl.rst:203 msgid "Support for key logging to :envvar:`SSLKEYLOGFILE` was added." msgstr "增加了 :envvar:`SSLKEYLOGFILE` 對密鑰日誌記錄 (logging) 的支援。" -#: ../../library/ssl.rst:210 +#: ../../library/ssl.rst:207 msgid "" "The context now uses :data:`PROTOCOL_TLS_CLIENT` or :data:" "`PROTOCOL_TLS_SERVER` protocol instead of generic :data:`PROTOCOL_TLS`." @@ -380,17 +380,43 @@ msgstr "" "目前語境使用 :data:`PROTOCOL_TLS_CLIENT` 協定或 :data:`PROTOCOL_TLS_SERVER` " "協定而非通用的 :data:`PROTOCOL_TLS`。" -#: ../../library/ssl.rst:216 +#: ../../library/ssl.rst:213 msgid "" "The context now uses :data:`VERIFY_X509_PARTIAL_CHAIN` and :data:" "`VERIFY_X509_STRICT` in its default verify flags." msgstr "" -#: ../../library/ssl.rst:221 +#: ../../library/ssl.rst:218 +msgid "Signature algorithms" +msgstr "" + +#: ../../library/ssl.rst:222 +msgid "" +"Return a list of available TLS signature algorithm names used by servers to " +"complete the TLS handshake or clients requesting certificate-based " +"authentication. For example::" +msgstr "" + +#: ../../library/ssl.rst:226 +msgid "" +">>> ssl.get_sigalgs()\n" +"['ecdsa_secp256r1_sha256', 'ecdsa_secp384r1_sha384', ...]" +msgstr "" +">>> ssl.get_sigalgs()\n" +"['ecdsa_secp256r1_sha256', 'ecdsa_secp384r1_sha384', ...]" + +#: ../../library/ssl.rst:229 +msgid "" +"These names can be used when building string values to pass to the :meth:" +"`SSLContext.set_client_sigalgs` and :meth:`SSLContext.set_server_sigalgs` " +"methods." +msgstr "" + +#: ../../library/ssl.rst:237 msgid "Exceptions" msgstr "例外" -#: ../../library/ssl.rst:225 +#: ../../library/ssl.rst:241 msgid "" "Raised to signal an error from the underlying SSL implementation (currently " "provided by the OpenSSL library). This signifies some problem in the higher-" @@ -404,11 +430,11 @@ msgstr "" "`OSError` 的一個子型別。:exc:`SSLError` 實例的錯誤程式代碼和訊息是由 OpenSSL " "函式庫提供。" -#: ../../library/ssl.rst:232 +#: ../../library/ssl.rst:248 msgid ":exc:`SSLError` used to be a subtype of :exc:`socket.error`." msgstr ":exc:`SSLError` 曾經是 :exc:`socket.error` 的一個子型別。" -#: ../../library/ssl.rst:237 +#: ../../library/ssl.rst:253 msgid "" "A string mnemonic designating the OpenSSL submodule in which the error " "occurred, such as ``SSL``, ``PEM`` or ``X509``. The range of possible " @@ -417,7 +443,7 @@ msgstr "" "一個字串符號 (string mnemonic),用來指定發生錯誤的 OpenSSL 子模組,如:" "``SSL``、``PEM`` 或 ``X509``。可能值的範圍取決於 OpenSSL 的版本。" -#: ../../library/ssl.rst:245 +#: ../../library/ssl.rst:261 msgid "" "A string mnemonic designating the reason this error occurred, for example " "``CERTIFICATE_VERIFY_FAILED``. The range of possible values depends on the " @@ -426,7 +452,7 @@ msgstr "" "一個字串符號,用來指定發生錯誤的原因,如:``CERTIFICATE_VERIFY_FAILED``。可能" "值的範圍取決於 OpenSSL 的版本。" -#: ../../library/ssl.rst:253 +#: ../../library/ssl.rst:269 msgid "" "A subclass of :exc:`SSLError` raised when trying to read or write and the " "SSL connection has been closed cleanly. Note that this doesn't mean that " @@ -435,7 +461,7 @@ msgstr "" "一個 :exc:`SSLError` 的子類別,當嘗試去讀寫已經被完全關閉的 SSL 連線時會被引" "發。請注意,這並不表示底層傳輸(例如 TCP)已經被關閉。" -#: ../../library/ssl.rst:261 +#: ../../library/ssl.rst:277 msgid "" "A subclass of :exc:`SSLError` raised by a :ref:`non-blocking SSL socket ` when trying to read or write data, but more data needs to be " @@ -444,7 +470,7 @@ msgstr "" "一個 :exc:`SSLError` 的子類別,當嘗試去讀寫資料前,底層 TCP 傳輸需要先接收更" "多資料時會由\\ :ref:`非阻塞的 SSL socket ` 引發該錯誤。" -#: ../../library/ssl.rst:270 +#: ../../library/ssl.rst:286 msgid "" "A subclass of :exc:`SSLError` raised by a :ref:`non-blocking SSL socket ` when trying to read or write data, but more data needs to be " @@ -453,7 +479,7 @@ msgstr "" "一個 :exc:`SSLError` 的子類別,當嘗試去讀寫資料前,底層 TCP 傳輸需要先發送更" "多資料時會由\\ :ref:`非阻塞的 SSL socket ` 引發該錯誤。" -#: ../../library/ssl.rst:279 +#: ../../library/ssl.rst:295 msgid "" "A subclass of :exc:`SSLError` raised when a system error was encountered " "while trying to fulfill an operation on a SSL socket. Unfortunately, there " @@ -462,7 +488,7 @@ msgstr "" "一個 :exc:`SSLError` 的子類別,當嘗試去操作 SSL socket 時有系統錯誤產生會引發" "此錯誤。不幸的是,目前沒有任何簡單的方法可以去檢查原本的的 errno 編號。" -#: ../../library/ssl.rst:287 +#: ../../library/ssl.rst:303 msgid "" "A subclass of :exc:`SSLError` raised when the SSL connection has been " "terminated abruptly. Generally, you shouldn't try to reuse the underlying " @@ -471,32 +497,32 @@ msgstr "" "一個 :exc:`SSLError` 的子類別,當 SSL 連線被突然終止時會引發此錯誤。通常,當" "此錯誤發生時,你不該再去重新使用底層傳輸。" -#: ../../library/ssl.rst:295 +#: ../../library/ssl.rst:311 msgid "" "A subclass of :exc:`SSLError` raised when certificate validation has failed." msgstr "當憑證驗證失敗時會引發的一個 :exc:`SSLError` 子類別。" -#: ../../library/ssl.rst:302 +#: ../../library/ssl.rst:318 msgid "A numeric error number that denotes the verification error." msgstr "一個表示驗證錯誤的錯誤數值編號。" -#: ../../library/ssl.rst:306 +#: ../../library/ssl.rst:322 msgid "A human readable string of the verification error." msgstr "一個人類可讀的驗證錯誤字串。" -#: ../../library/ssl.rst:310 +#: ../../library/ssl.rst:326 msgid "An alias for :exc:`SSLCertVerificationError`." msgstr ":exc:`SSLCertVerificationError` 的別名。" -#: ../../library/ssl.rst:312 +#: ../../library/ssl.rst:328 msgid "The exception is now an alias for :exc:`SSLCertVerificationError`." msgstr "此例外現在是 :exc:`SSLCertVerificationError` 的別名。" -#: ../../library/ssl.rst:317 +#: ../../library/ssl.rst:333 msgid "Random generation" msgstr "隨機產生" -#: ../../library/ssl.rst:321 +#: ../../library/ssl.rst:337 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 " @@ -509,11 +535,11 @@ msgstr "" "func:`RAND_status` 函式可以用來檢查 PRNG 函式,而 :func:`RAND_add` 則可以用來" "為 PRNG 設定隨機種子。" -#: ../../library/ssl.rst:327 +#: ../../library/ssl.rst:343 msgid "For almost all applications :func:`os.urandom` is preferable." msgstr "在幾乎所有的應用程式中,:func:`os.urandom` 會是較好的選擇。" -#: ../../library/ssl.rst:329 +#: ../../library/ssl.rst:345 msgid "" "Read the Wikipedia article, `Cryptographically secure pseudorandom number " "generator (CSPRNG) `_\\ 文章來了" "解密碼學安全偽隨機數產生器的需求。" -#: ../../library/ssl.rst:338 +#: ../../library/ssl.rst:354 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. Use :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_add` 函式來增加偽隨機數" +"產生器的隨機性。" -#: ../../library/ssl.rst:345 +#: ../../library/ssl.rst:360 msgid "" "Mix the given *bytes* into the SSL pseudo-random number generator. The " "parameter *entropy* (a float) is a lower bound on the entropy contained in " @@ -546,15 +571,15 @@ msgstr "" "指字串中包含熵值的下限(因此你可以將其設為 ``0.0``\\ )。請參閱 :rfc:`1750` " "了解有關熵源的更多資訊。" -#: ../../library/ssl.rst:350 +#: ../../library/ssl.rst:365 msgid "Writable :term:`bytes-like object` is now accepted." msgstr "可寫入的\\ :term:`類位元組物件 `\\ 現在可被接受。" -#: ../../library/ssl.rst:354 +#: ../../library/ssl.rst:369 msgid "Certificate handling" msgstr "認證處理" -#: ../../library/ssl.rst:362 +#: ../../library/ssl.rst:377 msgid "" "Return the time in seconds since the epoch, given the ``cert_time`` string " "representing the \"notBefore\" or \"notAfter\" date from a certificate in " @@ -564,11 +589,11 @@ msgstr "" "\"notAfter\" 日期,字串採用 ``\"%b %d %H:%M:%S %Y %Z\"`` 格式(C 語言區域設" "定)。" -#: ../../library/ssl.rst:367 +#: ../../library/ssl.rst:382 msgid "Here's an example:" msgstr "以下是一個範例:" -#: ../../library/ssl.rst:369 +#: ../../library/ssl.rst:384 msgid "" ">>> import ssl\n" ">>> import datetime as dt\n" @@ -586,11 +611,11 @@ msgstr "" ">>> print(dt.datetime.fromtimestamp(timestamp, dt.UTC))\n" "2018-01-05 09:34:43+00:00" -#: ../../library/ssl.rst:379 +#: ../../library/ssl.rst:394 msgid "\"notBefore\" or \"notAfter\" dates must use GMT (:rfc:`5280`)." msgstr "\"notBefore\" 或 \"notAfter\" 日期必須使用 GMT (:rfc:`5280`)。" -#: ../../library/ssl.rst:381 +#: ../../library/ssl.rst:396 msgid "" "Interpret the input time as a time in UTC as specified by 'GMT' timezone in " "the input string. Local timezone was used previously. Return an integer (no " @@ -599,7 +624,7 @@ msgstr "" "將輸入的時間直譯為 UTC 時間,如輸入字串中指定的 'GMT' 時區。在之前是使用本地" "的時區。回傳一個整數(在輸入格式中不包括秒的小數部分)。" -#: ../../library/ssl.rst:390 +#: ../../library/ssl.rst:405 msgid "" "Given the address ``addr`` of an SSL-protected server, as a (*hostname*, " "*port-number*) pair, fetches the server's certificate, and returns it as a " @@ -620,11 +645,11 @@ msgstr "" "組根憑證對伺服器憑證進行驗證,如果驗證失敗,呼叫將失敗。可以使用 ``timeout`` " "參數指定超時時間。" -#: ../../library/ssl.rst:401 +#: ../../library/ssl.rst:416 msgid "This function is now IPv6-compatible." msgstr "此函式現在是與 IPv6 相容的。" -#: ../../library/ssl.rst:404 +#: ../../library/ssl.rst:419 msgid "" "The default *ssl_version* is changed from :data:`PROTOCOL_SSLv3` to :data:" "`PROTOCOL_TLS` for maximum compatibility with modern servers." @@ -632,11 +657,11 @@ msgstr "" "預設的 *ssl_version* 已經從 :data:`PROTOCOL_SSLv3` 改為 :data:" "`PROTOCOL_TLS`,已確保與現今的伺服器有最大的相容性。" -#: ../../library/ssl.rst:408 +#: ../../library/ssl.rst:423 msgid "The *timeout* parameter was added." msgstr "新增 *timeout* 參數。" -#: ../../library/ssl.rst:413 +#: ../../library/ssl.rst:428 msgid "" "Given a certificate as a DER-encoded blob of bytes, returns a PEM-encoded " "string version of the same certificate." @@ -644,14 +669,14 @@ msgstr "" "給定一個以 DER 編碼的位元組 blob 作為憑證,回傳以 PEM 編碼字串版本的相同憑" "證。" -#: ../../library/ssl.rst:418 +#: ../../library/ssl.rst:433 msgid "" "Given a certificate as an ASCII PEM string, returns a DER-encoded sequence " "of bytes for that same certificate." msgstr "" "給定一個以 ASCII PEM 的字串作為憑證,回傳以 DER 編碼的位元組序列的相同憑證。" -#: ../../library/ssl.rst:423 +#: ../../library/ssl.rst:438 msgid "" "Returns a named tuple with paths to OpenSSL's default cafile and capath. The " "paths are the same as used by :meth:`SSLContext.set_default_verify_paths`. " @@ -661,39 +686,39 @@ msgstr "" "meth:`SSLContext.set_default_verify_paths` 使用的相同。回傳值是一個 :term:" "`named tuple` ``DefaultVerifyPaths``:" -#: ../../library/ssl.rst:428 +#: ../../library/ssl.rst:443 msgid "" ":attr:`cafile` - resolved path to cafile or ``None`` if the file doesn't " "exist," msgstr ":attr:`cafile` - 解析後的 cafile 路徑,如果檔案不存在則為 ``None``," -#: ../../library/ssl.rst:429 +#: ../../library/ssl.rst:444 msgid "" ":attr:`capath` - resolved path to capath or ``None`` if the directory " "doesn't exist," msgstr ":attr:`capath` - 解析後的 capath 路徑,如果目錄不存在則為 ``None``," -#: ../../library/ssl.rst:430 +#: ../../library/ssl.rst:445 msgid "" ":attr:`openssl_cafile_env` - OpenSSL's environment key that points to a " "cafile," msgstr ":attr:`openssl_cafile_env` - 指向 cafile 的 OpenSSL 環境密鑰," -#: ../../library/ssl.rst:431 +#: ../../library/ssl.rst:446 msgid ":attr:`openssl_cafile` - hard coded path to a cafile," msgstr ":attr:`openssl_cafile` - hard coded 的 cafile 路徑," -#: ../../library/ssl.rst:432 +#: ../../library/ssl.rst:447 msgid "" ":attr:`openssl_capath_env` - OpenSSL's environment key that points to a " "capath," msgstr ":attr:`openssl_capath_env` - 指向 capath 的 OpenSSL 環境密鑰," -#: ../../library/ssl.rst:433 +#: ../../library/ssl.rst:448 msgid ":attr:`openssl_capath` - hard coded path to a capath directory" msgstr ":attr:`openssl_capath` - hard coded 的 capath 目錄路徑" -#: ../../library/ssl.rst:439 +#: ../../library/ssl.rst:454 msgid "" "Retrieve certificates from Windows' system cert store. *store_name* may be " "one of ``CA``, ``ROOT`` or ``MY``. Windows may provide additional cert " @@ -702,7 +727,7 @@ msgstr "" "從 Windows 的系統憑證儲存庫中搜尋憑證。*store_name* 可以是 ``CA``、``ROOT`` " "或 ``MY`` 的其中一個。Windows 也可能會提供額外的憑證儲存庫。" -#: ../../library/ssl.rst:443 +#: ../../library/ssl.rst:458 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:" @@ -715,12 +740,12 @@ msgstr "" "`x509_asn` 或是用來表示 PKCS#7 ASN.1 資料的 :const:`pkcs_7_asn`。Trust 透過一" "組 OIDS 來指定憑證的用途,或是如果憑證對所有用途都可以使用則回傳 ``True``。" -#: ../../library/ssl.rst:450 ../../library/ssl.rst:1610 -#: ../../library/ssl.rst:1932 +#: ../../library/ssl.rst:465 ../../library/ssl.rst:1661 +#: ../../library/ssl.rst:2058 msgid "Example::" msgstr "範例: ::" -#: ../../library/ssl.rst:452 +#: ../../library/ssl.rst:467 msgid "" ">>> ssl.enum_certificates(\"CA\")\n" "[(b'data...', 'x509_asn', {'1.3.6.1.5.5.7.3.1', '1.3.6.1.5.5.7.3.2'}),\n" @@ -730,7 +755,7 @@ msgstr "" "[(b'data...', 'x509_asn', {'1.3.6.1.5.5.7.3.1', '1.3.6.1.5.5.7.3.2'}),\n" " (b'data...', 'x509_asn', True)]" -#: ../../library/ssl.rst:462 +#: ../../library/ssl.rst:477 msgid "" "Retrieve CRLs from Windows' system cert store. *store_name* may be one of " "``CA``, ``ROOT`` or ``MY``. Windows may provide additional cert stores, too." @@ -738,7 +763,7 @@ msgstr "" "從 Windows 的系統憑證儲存庫中搜尋 CRLs。*store_name* 可以是 ``CA``、``ROOT`` " "或 ``MY`` 的其中一個。Windows 也可能會提供額外的憑證儲存庫。" -#: ../../library/ssl.rst:466 +#: ../../library/ssl.rst:481 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:" @@ -748,18 +773,18 @@ msgstr "" "指定了 cert_bytes 的編碼格式。它可以是用來表示 X.509 ASN.1 資料的 :const:" "`x509_asn` 或是用來表示 PKCS#7 ASN.1 資料的 :const:`pkcs_7_asn`。" -#: ../../library/ssl.rst:477 +#: ../../library/ssl.rst:492 msgid "Constants" msgstr "常數" -#: ../../library/ssl.rst:479 +#: ../../library/ssl.rst:494 msgid "" "All constants are now :class:`enum.IntEnum` or :class:`enum.IntFlag` " "collections." msgstr "" "所有的常數現在都是 :class:`enum.IntEnum` 或 :class:`enum.IntFlag` 的集合。" -#: ../../library/ssl.rst:485 +#: ../../library/ssl.rst:500 msgid "" "Possible value for :attr:`SSLContext.verify_mode`. Except for :const:" "`PROTOCOL_TLS_CLIENT`, it is the default mode. With client-side sockets, " @@ -770,7 +795,7 @@ msgstr "" "外,這是預設的模式。對於用戶端的 sockets,幾乎任何憑證都能被允許。驗證錯誤," "像是不被信任或是過期的憑證,會被忽略並不會中止 TLS/SSL 握手。" -#: ../../library/ssl.rst:491 +#: ../../library/ssl.rst:506 msgid "" "In server mode, no certificate is requested from the client, so the client " "does not send any for client cert authentication." @@ -778,11 +803,11 @@ msgstr "" "在伺服器模式下,不會從用戶端請求任何憑證,所以用戶端不用發送任何用於用戶端憑" "證身分驗證的憑證。" -#: ../../library/ssl.rst:494 ../../library/ssl.rst:2434 +#: ../../library/ssl.rst:509 ../../library/ssl.rst:2560 msgid "See the discussion of :ref:`ssl-security` below." msgstr "參閱下方 :ref:`ssl-security` 的討論。" -#: ../../library/ssl.rst:498 +#: ../../library/ssl.rst:513 msgid "" "Possible value for :attr:`SSLContext.verify_mode`. In client mode, :const:" "`CERT_OPTIONAL` has the same meaning as :const:`CERT_REQUIRED`. It is " @@ -792,7 +817,7 @@ msgstr "" "`CERT_OPTIONAL` 具有與 :const:`CERT_REQUIRED` 相同的含意。對於客戶端 sockets " "推薦改用 :const:`CERT_REQUIRED`。" -#: ../../library/ssl.rst:503 +#: ../../library/ssl.rst:518 msgid "" "In server mode, a client certificate request is sent to the client. The " "client may either ignore the request or send a certificate in order perform " @@ -804,7 +829,7 @@ msgstr "" "發送憑證來執行 TLS 用戶端憑證身分驗證。如果用戶端選擇發送憑證,則會對其進行驗" "證。任何驗證錯誤都會立刻終止 TLS 握手。" -#: ../../library/ssl.rst:509 ../../library/ssl.rst:528 +#: ../../library/ssl.rst:524 ../../library/ssl.rst:543 msgid "" "Use of this setting requires a valid set of CA certificates to be passed to :" "meth:`SSLContext.load_verify_locations`." @@ -812,7 +837,7 @@ msgstr "" "使用此設定需要將一組有效的 CA 憑證傳送給 :meth:`SSLContext." "load_verify_locations`。" -#: ../../library/ssl.rst:514 +#: ../../library/ssl.rst:529 msgid "" "Possible value for :attr:`SSLContext.verify_mode`. In this mode, " "certificates are required from the other side of the socket connection; an :" @@ -830,7 +855,7 @@ msgstr "" "`PROTOCOL_TLS_CLIENT` 會使用 :const:`CERT_REQUIRED` 並預設開啟 :attr:" "`~SSLContext.check_hostname`。" -#: ../../library/ssl.rst:524 +#: ../../library/ssl.rst:539 msgid "" "With server socket, this mode provides mandatory TLS client cert " "authentication. A client certificate request is sent to the client and the " @@ -839,11 +864,11 @@ msgstr "" "對於 socket 伺服器,此模式會提供強制的 TLS 用戶端憑證驗證。用戶端憑證請求會被" "發送給用戶端並且用戶端必須提供有效且被信任的憑證。" -#: ../../library/ssl.rst:533 +#: ../../library/ssl.rst:548 msgid ":class:`enum.IntEnum` collection of CERT_* constants." msgstr ":class:`enum.IntEnum` 為 CERT_* 常數的一個集合。" -#: ../../library/ssl.rst:539 +#: ../../library/ssl.rst:554 msgid "" "Possible value for :attr:`SSLContext.verify_flags`. In this mode, " "certificate revocation lists (CRLs) are not checked. By default OpenSSL does " @@ -852,7 +877,7 @@ msgstr "" ":attr:`SSLContext.verify_flags` 可能的值。在此模式下,不會檢查憑證吊銷列表 " "(CRLs)。預設的 OpenSSL 並不會請求及驗證 CRLs。" -#: ../../library/ssl.rst:547 +#: ../../library/ssl.rst:562 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 " @@ -865,7 +890,7 @@ msgstr "" "效的 CRL 簽名。如果沒有用 :attr:`SSLContext.load_verify_locations` 載入適當" "的 CRL,則會驗證失敗。" -#: ../../library/ssl.rst:557 +#: ../../library/ssl.rst:572 msgid "" "Possible value for :attr:`SSLContext.verify_flags`. In this mode, CRLs of " "all certificates in the peer cert chain are checked." @@ -873,7 +898,7 @@ msgstr "" ":attr:`SSLContext.verify_flags` 可能的值。在此模式下,會檢查對等憑證鍊中所有" "憑證的 CRLs。" -#: ../../library/ssl.rst:564 +#: ../../library/ssl.rst:579 msgid "" "Possible value for :attr:`SSLContext.verify_flags` to disable workarounds " "for broken X.509 certificates." @@ -881,13 +906,13 @@ msgstr "" ":attr:`SSLContext.verify_flags` 可能的值,用來禁用已損壞的 X.509 憑證的解決方" "法。" -#: ../../library/ssl.rst:571 +#: ../../library/ssl.rst:586 msgid "" "Possible value for :attr:`SSLContext.verify_flags` to enables proxy " "certificate verification." msgstr ":attr:`SSLContext.verify_flags` 可能的值,用來啟用憑證代理驗證。" -#: ../../library/ssl.rst:578 +#: ../../library/ssl.rst:593 msgid "" "Possible value for :attr:`SSLContext.verify_flags`. It instructs OpenSSL to " "prefer trusted certificates when building the trust chain to validate a " @@ -896,7 +921,7 @@ msgstr "" ":attr:`SSLContext.verify_flags` 可能的值。它指示 OpenSSL 在構建信任鍊來驗證憑" "證時會優先使用被信任的憑證。此旗標預設開啟。" -#: ../../library/ssl.rst:586 +#: ../../library/ssl.rst:601 msgid "" "Possible value for :attr:`SSLContext.verify_flags`. It instructs OpenSSL to " "accept intermediate CAs in the trust store to be treated as trust-anchors, " @@ -908,11 +933,11 @@ msgstr "" "間 CAs 作為信任錨,就像自簽名的根 CA 憑證。這樣就能去信任中間 CA 所頒發的憑" "證,而不一定非要去信任其祖先的根 CA。" -#: ../../library/ssl.rst:597 +#: ../../library/ssl.rst:612 msgid ":class:`enum.IntFlag` collection of VERIFY_* constants." msgstr ":class:`enum.IntFlag` 為 VERIFY_* 常數的其中一個集合。" -#: ../../library/ssl.rst:603 +#: ../../library/ssl.rst:618 msgid "" "Selects the highest protocol version that both the client and server " "support. Despite the name, this option can select both \"SSL\" and \"TLS\" " @@ -921,7 +946,7 @@ msgstr "" "選擇用戶端及伺服器均可以支援最高協定版本。儘管名稱只有 「TLS」,但實際上" "「SSL」和「TLS」均可以選擇。" -#: ../../library/ssl.rst:610 +#: ../../library/ssl.rst:625 msgid "" "TLS clients and servers require different default settings for secure " "communication. The generic TLS protocol constant is deprecated in favor of :" @@ -930,7 +955,7 @@ msgstr "" "TLS 的用戶端及伺服器端需要不同的預設值來實現安全通訊。通用的 TLS 協定常數已被" "廢除,並改用 :data:`PROTOCOL_TLS_CLIENT` 和 :data:`PROTOCOL_TLS_SERVER`。" -#: ../../library/ssl.rst:616 +#: ../../library/ssl.rst:631 msgid "" "Auto-negotiate the highest protocol version that both the client and server " "support, and configure the context client-side connections. The protocol " @@ -940,35 +965,35 @@ msgstr "" "自動協商用戶端和伺服器服務器都支援的最高協定版本,並配置用戶端語境連線。該協" "定預設啟用 :data:`CERT_REQUIRED` 和 :attr:`~SSLContext.check_hostname`。" -#: ../../library/ssl.rst:625 +#: ../../library/ssl.rst:640 msgid "" "Auto-negotiate the highest protocol version that both the client and server " "support, and configure the context server-side connections." msgstr "自動協商用戶端和伺服器都支援的最高協定版本,並配置用戶端語境連線。" -#: ../../library/ssl.rst:632 +#: ../../library/ssl.rst:647 msgid "Alias for :data:`PROTOCOL_TLS`." msgstr ":data:`PROTOCOL_TLS` 的別名。" -#: ../../library/ssl.rst:636 +#: ../../library/ssl.rst:651 msgid "Use :data:`PROTOCOL_TLS` instead." msgstr "請改用 :data:`PROTOCOL_TLS`。" -#: ../../library/ssl.rst:640 +#: ../../library/ssl.rst:655 msgid "Selects SSL version 3 as the channel encryption protocol." msgstr "選擇第三版的 SSL 做為通道加密協定。" -#: ../../library/ssl.rst:642 +#: ../../library/ssl.rst:657 msgid "" "This protocol is not available if OpenSSL is compiled with the ``no-ssl3`` " "option." msgstr "如果 OpenSSL 是用 ``no-ssl3`` 編譯的,則此項協定無法使用。" -#: ../../library/ssl.rst:647 +#: ../../library/ssl.rst:662 msgid "SSL version 3 is insecure. Its use is highly discouraged." msgstr "第三版的 SSL 是不安全的,強烈建議不要使用。" -#: ../../library/ssl.rst:651 +#: ../../library/ssl.rst:666 msgid "" "OpenSSL has deprecated all version specific protocols. Use the default " "protocol :data:`PROTOCOL_TLS_SERVER` or :data:`PROTOCOL_TLS_CLIENT` with :" @@ -979,16 +1004,16 @@ msgstr "" "`PROTOCOL_TLS_SERVER` 協定或帶有 :attr:`SSLContext.minimum_version` 和 :attr:" "`SSLContext.maximum_version` 的 :data:`PROTOCOL_TLS_CLIENT`。" -#: ../../library/ssl.rst:659 +#: ../../library/ssl.rst:674 msgid "Selects TLS version 1.0 as the channel encryption protocol." msgstr "選擇 1.0 版的 TLS 做為通道加密協定。" -#: ../../library/ssl.rst:663 ../../library/ssl.rst:674 -#: ../../library/ssl.rst:685 +#: ../../library/ssl.rst:678 ../../library/ssl.rst:689 +#: ../../library/ssl.rst:700 msgid "OpenSSL has deprecated all version specific protocols." msgstr "OpenSSL 已經將所有版本特定的協定棄用。" -#: ../../library/ssl.rst:667 +#: ../../library/ssl.rst:682 msgid "" "Selects TLS version 1.1 as the channel encryption protocol. Available only " "with openssl version 1.0.1+." @@ -996,7 +1021,7 @@ msgstr "" "選擇 1.1 版的 TLS 做為通道加密協定。只有在 1.0.1 版本以上的 OpenSSL 才可以選" "用。" -#: ../../library/ssl.rst:678 +#: ../../library/ssl.rst:693 msgid "" "Selects TLS version 1.2 as the channel encryption protocol. Available only " "with openssl version 1.0.1+." @@ -1004,7 +1029,7 @@ msgstr "" "選擇 1.2 版的 TLS 做為通道加密協定。只有在 1.0.1 版本以上的 OpenSSL 才可以選" "用。" -#: ../../library/ssl.rst:689 +#: ../../library/ssl.rst:704 msgid "" "Enables workarounds for various bugs present in other SSL implementations. " "This option is set by default. It does not necessarily set the same flags " @@ -1013,7 +1038,7 @@ msgstr "" "啟用對 SSL 實作時所產生的各種錯誤的緩解措施。此選項預設被設定。它不一定設定" "與 OpenSSL 的 ``SSL_OP_ALL`` 常數相同的旗標。" -#: ../../library/ssl.rst:697 +#: ../../library/ssl.rst:712 msgid "" "Prevents an SSLv2 connection. This option is only applicable in conjunction " "with :const:`PROTOCOL_TLS`. It prevents the peers from choosing SSLv2 as " @@ -1022,11 +1047,11 @@ msgstr "" "防止 SSLv2 連線。此選項只可以跟 :const:`PROTOCOL_TLS` 一起使用。它會防止同級 " "(peer)選用 SSLv2 做為協定版本。" -#: ../../library/ssl.rst:705 +#: ../../library/ssl.rst:720 msgid "SSLv2 is deprecated" msgstr "SSLv2 已被棄用" -#: ../../library/ssl.rst:709 +#: ../../library/ssl.rst:724 msgid "" "Prevents an SSLv3 connection. This option is only applicable in conjunction " "with :const:`PROTOCOL_TLS`. It prevents the peers from choosing SSLv3 as " @@ -1035,11 +1060,11 @@ msgstr "" "防止 SSLv3 連線。此選項只可以跟 :const:`PROTOCOL_TLS` 一起使用。它會防止同級" "選用 SSLv3 做為協定版本。" -#: ../../library/ssl.rst:717 +#: ../../library/ssl.rst:732 msgid "SSLv3 is deprecated" msgstr "SSLv3 已被棄用" -#: ../../library/ssl.rst:721 +#: ../../library/ssl.rst:736 msgid "" "Prevents a TLSv1 connection. This option is only applicable in conjunction " "with :const:`PROTOCOL_TLS`. It prevents the peers from choosing TLSv1 as " @@ -1048,7 +1073,7 @@ msgstr "" "防止 TLSv1 連線。此選項只可以跟 :const:`PROTOCOL_TLS` 一起使用。它會防止同級" "選用 TLSv1 做為協定版本。" -#: ../../library/ssl.rst:727 +#: ../../library/ssl.rst:742 msgid "" "The option is deprecated since OpenSSL 1.1.0, use the new :attr:`SSLContext." "minimum_version` and :attr:`SSLContext.maximum_version` instead." @@ -1056,7 +1081,7 @@ msgstr "" "該選項自從 OpenSSL 1.1.0 以後已被棄用,請改用新的 :attr:`SSLContext." "minimum_version` 及 :attr:`SSLContext.maximum_version` 代替。" -#: ../../library/ssl.rst:734 +#: ../../library/ssl.rst:749 msgid "" "Prevents a TLSv1.1 connection. This option is only applicable in conjunction " "with :const:`PROTOCOL_TLS`. It prevents the peers from choosing TLSv1.1 as " @@ -1065,11 +1090,11 @@ msgstr "" "防止 TLSv1.1 連線。此選項只可以跟 :const:`PROTOCOL_TLS` 一起使用。它會防止同" "級選用 TLSv1.1 做為協定版本。只有 1.0.1 版後的 OpenSSL 版本才能使用。" -#: ../../library/ssl.rst:740 ../../library/ssl.rst:751 +#: ../../library/ssl.rst:755 ../../library/ssl.rst:766 msgid "The option is deprecated since OpenSSL 1.1.0." msgstr "此選項自 OpenSSL 1.1.0 版已被棄用。" -#: ../../library/ssl.rst:745 +#: ../../library/ssl.rst:760 msgid "" "Prevents a TLSv1.2 connection. This option is only applicable in conjunction " "with :const:`PROTOCOL_TLS`. It prevents the peers from choosing TLSv1.2 as " @@ -1078,7 +1103,7 @@ msgstr "" "防止 TLSv1.2 連線。此選項只可以跟 :const:`PROTOCOL_TLS` 一起使用。它會防止同" "級選用 TLSv1.2 做為協定版本。只有 1.0.1 版後的 OpenSSL 版本才能使用。" -#: ../../library/ssl.rst:756 +#: ../../library/ssl.rst:771 msgid "" "Prevents a TLSv1.3 connection. This option is only applicable in conjunction " "with :const:`PROTOCOL_TLS`. It prevents the peers from choosing TLSv1.3 as " @@ -1090,7 +1115,7 @@ msgstr "" "級選用 TLSv1.3 做為協定版本。TSL1.3 只適用於 1.1.1 版以後的 OpenSSL。當使用 " "Python 編譯舊版的 OpenSSL 時,該標志預設為 *0*。" -#: ../../library/ssl.rst:764 +#: ../../library/ssl.rst:779 msgid "" "The option is deprecated since OpenSSL 1.1.0. It was added to 2.7.15 and " "3.6.3 for backwards compatibility with OpenSSL 1.0.2." @@ -1098,7 +1123,7 @@ msgstr "" "此選項自 OpenSSL 1.1.0 以後已被棄用。它被添加到 2.7.15 和 3.6.3 中,以向後相" "容 OpenSSL 1.0.2。" -#: ../../library/ssl.rst:770 +#: ../../library/ssl.rst:785 msgid "" "Disable all renegotiation in TLSv1.2 and earlier. Do not send HelloRequest " "messages, and ignore renegotiation requests via ClientHello." @@ -1106,11 +1131,11 @@ msgstr "" "停用所有在 TLSv1.2 及更早版本的重協商 (renegotiation)。不發送 HelloRequest 訊" "息,並忽略透過 ClientHello 的重協商請求。" -#: ../../library/ssl.rst:773 +#: ../../library/ssl.rst:788 msgid "This option is only available with OpenSSL 1.1.0h and later." msgstr "此選項僅適用於 OpenSSL 1.1.0h 及更新版本。" -#: ../../library/ssl.rst:779 +#: ../../library/ssl.rst:794 msgid "" "Use the server's cipher ordering preference, rather than the client's. This " "option has no effect on client sockets and SSLv2 server sockets." @@ -1118,7 +1143,7 @@ msgstr "" "使用伺服器的加密方法名稱字串排序優先順序,而不是用戶端的。此選項並不會影響到" "用戶端及 SSLv2 伺服器的 sockets。" -#: ../../library/ssl.rst:786 +#: ../../library/ssl.rst:801 msgid "" "Prevents reuse of the same DH key for distinct SSL sessions. This improves " "forward secrecy but requires more computational resources. This option only " @@ -1127,7 +1152,7 @@ msgstr "" "防止對不同的 SSL 會談重複使用相同的 DH 密鑰。這會加強向前保密但需要更多的運算" "資源。此選項只適用於伺服器 sockets。" -#: ../../library/ssl.rst:794 +#: ../../library/ssl.rst:809 msgid "" "Prevents reuse of the same ECDH key for distinct SSL sessions. This " "improves forward secrecy but requires more computational resources. This " @@ -1136,7 +1161,7 @@ msgstr "" "防止對不同的 SSL 會談重複使用相同的 ECDH 密鑰。這會加強向前保密但需要更多的運" "算資源。此選項只適用於伺服器 sockets。" -#: ../../library/ssl.rst:802 +#: ../../library/ssl.rst:817 msgid "" "Send dummy Change Cipher Spec (CCS) messages in TLS 1.3 handshake to make a " "TLS 1.3 connection look more like a TLS 1.2 connection." @@ -1144,34 +1169,34 @@ msgstr "" "在 TLS 1.3 握手中發送虛擬的變更加密方法規範 (CCS) 消息,以使 TLS 1.3 連接看起" "來更像 TLS 1.2 連線。" -#: ../../library/ssl.rst:805 +#: ../../library/ssl.rst:820 msgid "This option is only available with OpenSSL 1.1.1 and later." msgstr "此選項僅適用於 OpenSSL 1.1.1 及更新版本。" -#: ../../library/ssl.rst:811 +#: ../../library/ssl.rst:826 msgid "" "Disable compression on the SSL channel. This is useful if the application " "protocol supports its own compression scheme." msgstr "" "在 SSL 通道上禁用壓縮。如果應用程序協定支援自己的壓縮方案,這會很有用。" -#: ../../library/ssl.rst:818 +#: ../../library/ssl.rst:833 msgid ":class:`enum.IntFlag` collection of OP_* constants." msgstr ":class:`enum.IntFlag` 為 OP_* 常數中的一個集合。" -#: ../../library/ssl.rst:822 +#: ../../library/ssl.rst:837 msgid "Prevent client side from requesting a session ticket." msgstr "防止用戶端請求會談票據。" -#: ../../library/ssl.rst:828 +#: ../../library/ssl.rst:843 msgid "Ignore unexpected shutdown of TLS connections." msgstr "忽略意外關閉的 TLS 連線。" -#: ../../library/ssl.rst:830 ../../library/ssl.rst:846 +#: ../../library/ssl.rst:845 ../../library/ssl.rst:861 msgid "This option is only available with OpenSSL 3.0.0 and later." msgstr "此選項僅適用於 OpenSSL 3.0.0 及更新版本。" -#: ../../library/ssl.rst:836 +#: ../../library/ssl.rst:851 msgid "" "Enable the use of the kernel TLS. To benefit from the feature, OpenSSL must " "have been compiled with support for it, and the negotiated cipher suites and " @@ -1182,7 +1207,7 @@ msgstr "" "的加密套件及擴充套件也必須被該功能支援 (該功能所支援的列表可能會因平台及核心" "而有所差異)。" -#: ../../library/ssl.rst:841 +#: ../../library/ssl.rst:856 msgid "" "Note that with enabled kernel TLS some cryptographic operations are " "performed by the kernel directly and not via any available OpenSSL " @@ -1193,13 +1218,13 @@ msgstr "" "的 OpenSSL 所提供的程序,而這可能並非你所想使用的,例如:當應用程式要求所有的" "加密操作由 FIPS 提供執行。" -#: ../../library/ssl.rst:852 +#: ../../library/ssl.rst:867 msgid "" "Allow legacy insecure renegotiation between OpenSSL and unpatched servers " "only." msgstr "只允許 OpenSSL 與未修補的伺服器進行遺留 (legacy) 不安全重協商。" -#: ../../library/ssl.rst:859 +#: ../../library/ssl.rst:874 msgid "" "Whether the OpenSSL library has built-in support for the *Application-Layer " "Protocol Negotiation* TLS extension as described in :rfc:`7301`." @@ -1207,7 +1232,7 @@ msgstr "" "OpenSSL 函式庫是否內建支援 *應用層協定協商* TLS 擴充套件,該擴充套件描述在 :" "rfc:`7301` 中。" -#: ../../library/ssl.rst:866 +#: ../../library/ssl.rst:881 msgid "" "Whether the OpenSSL library has built-in support not checking subject common " "name and :attr:`SSLContext.hostname_checks_common_name` is writeable." @@ -1215,7 +1240,7 @@ msgstr "" "OpenSSL 函式庫是否內建支援不檢查主題通用名稱及 :attr:`SSLContext." "hostname_checks_common_name` 是否可寫。" -#: ../../library/ssl.rst:874 +#: ../../library/ssl.rst:889 msgid "" "Whether the OpenSSL library has built-in support for the Elliptic Curve-" "based Diffie-Hellman key exchange. This should be true unless the feature " @@ -1224,7 +1249,7 @@ msgstr "" "OpenSSL 函式庫是否內建支援基於橢圓曲線的 (Elliptic Curve-based) Diffie-" "Hellman 金鑰交換。此回傳值應該要為 true 除非發布者明確禁用此功能。" -#: ../../library/ssl.rst:882 +#: ../../library/ssl.rst:897 msgid "" "Whether the OpenSSL library has built-in support for the *Server Name " "Indication* extension (as defined in :rfc:`6066`)." @@ -1232,7 +1257,7 @@ msgstr "" "OpenSSL 函式庫是否內建支援 *伺服器名稱提示* 擴充套件 (在 :rfc:`6066` 中定" "義)。" -#: ../../library/ssl.rst:889 +#: ../../library/ssl.rst:904 msgid "" "Whether the OpenSSL library has built-in support for the *Next Protocol " "Negotiation* as described in the `Application Layer Protocol Negotiation " @@ -1245,45 +1270,53 @@ msgstr "" "描述。當此值為 true 時,你可以使用 :meth:`SSLContext.set_npn_protocols` 方法" "來公告你想支援的協定。" -#: ../../library/ssl.rst:899 +#: ../../library/ssl.rst:914 msgid "" "Whether the OpenSSL library has built-in support for the SSL 2.0 protocol." msgstr "此 OpenSSL 函式庫是否內建支援 SSL 2.0 協定。" -#: ../../library/ssl.rst:905 +#: ../../library/ssl.rst:920 msgid "" "Whether the OpenSSL library has built-in support for the SSL 3.0 protocol." msgstr "此 OpenSSL 函式庫是否內建支援 SSL 3.0 協定。" -#: ../../library/ssl.rst:911 +#: ../../library/ssl.rst:926 msgid "" "Whether the OpenSSL library has built-in support for the TLS 1.0 protocol." msgstr "此 OpenSSL 函式庫是否內建支援 TLS 1.0 協定。" -#: ../../library/ssl.rst:917 +#: ../../library/ssl.rst:932 msgid "" "Whether the OpenSSL library has built-in support for the TLS 1.1 protocol." msgstr "此 OpenSSL 函式庫是否內建支援 TLS 1.1 協定。" -#: ../../library/ssl.rst:923 +#: ../../library/ssl.rst:938 msgid "" "Whether the OpenSSL library has built-in support for the TLS 1.2 protocol." msgstr "此 OpenSSL 函式庫是否內建支援 TLS 1.2 協定。" -#: ../../library/ssl.rst:929 +#: ../../library/ssl.rst:944 msgid "" "Whether the OpenSSL library has built-in support for the TLS 1.3 protocol." msgstr "此 OpenSSL 函式庫是否內建支援 TLS 1.3 協定。" -#: ../../library/ssl.rst:935 +#: ../../library/ssl.rst:950 msgid "Whether the OpenSSL library has built-in support for TLS-PSK." msgstr "此 OpenSSL 函式庫是否內建支援 TLS-PSK。" -#: ../../library/ssl.rst:941 +#: ../../library/ssl.rst:956 +msgid "" +"Whether the OpenSSL library has built-in support for External PSKs in TLS " +"1.3 as described in :rfc:`9258`." +msgstr "" +"OpenSSL 函式庫是否內建支援 :rfc:`9258` 中所描述的 TLS 1.3 外部 PSK (External " +"PSK)。" + +#: ../../library/ssl.rst:963 msgid "Whether the OpenSSL library has built-in support for TLS-PHA." msgstr "此 OpenSSL 函式庫是否內建支援 TLS-PHA。" -#: ../../library/ssl.rst:947 +#: ../../library/ssl.rst:969 msgid "" "List of supported TLS channel binding types. Strings in this list can be " "used as arguments to :meth:`SSLSocket.get_channel_binding`." @@ -1291,11 +1324,11 @@ msgstr "" "支援的 TLS 通道綁定類型列表。列表中的字串可以作為 :meth:`SSLSocket." "get_channel_binding` 的參數。" -#: ../../library/ssl.rst:954 +#: ../../library/ssl.rst:976 msgid "The version string of the OpenSSL library loaded by the interpreter::" msgstr "直譯器所加載的 OpenSSL 函式庫的版本字串::" -#: ../../library/ssl.rst:956 +#: ../../library/ssl.rst:978 msgid "" ">>> ssl.OPENSSL_VERSION\n" "'OpenSSL 1.0.2k 26 Jan 2017'" @@ -1303,13 +1336,13 @@ msgstr "" ">>> ssl.OPENSSL_VERSION\n" "'OpenSSL 1.0.2k 26 Jan 2017'" -#: ../../library/ssl.rst:963 +#: ../../library/ssl.rst:985 msgid "" "A tuple of five integers representing version information about the OpenSSL " "library::" msgstr "代表 OpenSSL 函式庫版本資訊的五個整數的元組: ::" -#: ../../library/ssl.rst:966 +#: ../../library/ssl.rst:988 msgid "" ">>> ssl.OPENSSL_VERSION_INFO\n" "(1, 0, 2, 11, 15)" @@ -1317,11 +1350,11 @@ msgstr "" ">>> ssl.OPENSSL_VERSION_INFO\n" "(1, 0, 2, 11, 15)" -#: ../../library/ssl.rst:973 +#: ../../library/ssl.rst:995 msgid "The raw version number of the OpenSSL library, as a single integer::" msgstr "OpenSSL 函式庫的初始版本,以單一整數表示::" -#: ../../library/ssl.rst:975 +#: ../../library/ssl.rst:997 msgid "" ">>> ssl.OPENSSL_VERSION_NUMBER\n" "268443839\n" @@ -1333,7 +1366,7 @@ msgstr "" ">>> hex(ssl.OPENSSL_VERSION_NUMBER)\n" "'0x100020bf'" -#: ../../library/ssl.rst:986 +#: ../../library/ssl.rst:1008 msgid "" "Alert Descriptions from :rfc:`5246` and others. The `IANA TLS Alert Registry " "`_ 包" "含了此列表以及其含義定義所在的 RFC 的引用。" -#: ../../library/ssl.rst:990 +#: ../../library/ssl.rst:1012 msgid "" "Used as the return value of the callback function in :meth:`SSLContext." "set_servername_callback`." msgstr "" "被用來做為 :meth:`SSLContext.set_servername_callback` 中回呼函式的回傳值。" -#: ../../library/ssl.rst:997 +#: ../../library/ssl.rst:1019 msgid ":class:`enum.IntEnum` collection of ALERT_DESCRIPTION_* constants." msgstr ":class:`enum.IntEnum` 為 ALERT_DESCRIPTION_* 常數中的一個集合。" -#: ../../library/ssl.rst:1003 +#: ../../library/ssl.rst:1025 msgid "" "Option for :func:`create_default_context` and :meth:`SSLContext." "load_default_certs`. This value indicates that the context may be used to " @@ -1365,7 +1398,7 @@ msgstr "" ":func:`create_default_context` 和 :meth:`SSLContext.load_default_certs` 的選" "項。此值表示該語境可能會用於驗證網頁伺服器 (因此它將用於建立用戶端 socket)。" -#: ../../library/ssl.rst:1012 +#: ../../library/ssl.rst:1034 msgid "" "Option for :func:`create_default_context` and :meth:`SSLContext." "load_default_certs`. This value indicates that the context may be used to " @@ -1376,11 +1409,11 @@ msgstr "" "項。此值表示該語境可能會用於驗證網頁用戶端 (因此,它將用於建立伺服器端的 " "socket)。" -#: ../../library/ssl.rst:1021 +#: ../../library/ssl.rst:1043 msgid ":class:`enum.IntEnum` collection of SSL_ERROR_* constants." msgstr ":class:`enum.IntEnum` 為 SSL_ERROR_* 常數中的一個集合。" -#: ../../library/ssl.rst:1027 +#: ../../library/ssl.rst:1049 msgid "" ":class:`enum.IntEnum` collection of SSL and TLS versions for :attr:" "`SSLContext.maximum_version` and :attr:`SSLContext.minimum_version`." @@ -1388,7 +1421,7 @@ msgstr "" "用於 :attr:`SSLContext.maximum_version` 和 :attr:`SSLContext." "minimum_version` 的 SSL 和 TLS 版本 :class:`enum.IntEnum` 集合。" -#: ../../library/ssl.rst:1035 +#: ../../library/ssl.rst:1057 msgid "" "The minimum or maximum supported SSL or TLS version. These are magic " "constants. Their values don't reflect the lowest and highest available TLS/" @@ -1397,11 +1430,11 @@ msgstr "" "最低或最高支援的 SSL 或 TLS 版本。這些是特殊常數。它們的值並不反映可用的最低" "和最高 TLS/SSL 版本。" -#: ../../library/ssl.rst:1045 +#: ../../library/ssl.rst:1067 msgid "SSL 3.0 to TLS 1.3." msgstr "SSL 3.0 到 TLS 1.3。" -#: ../../library/ssl.rst:1049 +#: ../../library/ssl.rst:1071 msgid "" "All :class:`TLSVersion` members except :attr:`TLSVersion.TLSv1_2` and :attr:" "`TLSVersion.TLSv1_3` are deprecated." @@ -1409,47 +1442,47 @@ msgstr "" "除了 :attr:`TLSVersion.TLSv1_2` 和 :attr:`TLSVersion.TLSv1_3` 之外,所有的 :" "class:`TLSVersion` 成員都已被棄用。" -#: ../../library/ssl.rst:1054 +#: ../../library/ssl.rst:1076 msgid "SSL sockets" msgstr "SSL sockets" -#: ../../library/ssl.rst:1058 +#: ../../library/ssl.rst:1080 msgid "SSL sockets provide the following methods of :ref:`socket-objects`:" msgstr "SSL sockets 提供以下 :ref:`socket-objects` 方法:" -#: ../../library/ssl.rst:1060 +#: ../../library/ssl.rst:1082 msgid ":meth:`~socket.socket.accept`" msgstr ":meth:`~socket.socket.accept`" -#: ../../library/ssl.rst:1061 +#: ../../library/ssl.rst:1083 msgid ":meth:`~socket.socket.bind`" msgstr ":meth:`~socket.socket.bind`" -#: ../../library/ssl.rst:1062 +#: ../../library/ssl.rst:1084 msgid ":meth:`~socket.socket.close`" msgstr ":meth:`~socket.socket.close`" -#: ../../library/ssl.rst:1063 +#: ../../library/ssl.rst:1085 msgid ":meth:`~socket.socket.connect`" msgstr ":meth:`~socket.socket.connect`" -#: ../../library/ssl.rst:1064 +#: ../../library/ssl.rst:1086 msgid ":meth:`~socket.socket.detach`" msgstr ":meth:`~socket.socket.detach`" -#: ../../library/ssl.rst:1065 +#: ../../library/ssl.rst:1087 msgid ":meth:`~socket.socket.fileno`" msgstr ":meth:`~socket.socket.fileno`" -#: ../../library/ssl.rst:1066 +#: ../../library/ssl.rst:1088 msgid ":meth:`~socket.socket.getpeername`, :meth:`~socket.socket.getsockname`" msgstr ":meth:`~socket.socket.getpeername`、:meth:`~socket.socket.getsockname`" -#: ../../library/ssl.rst:1067 +#: ../../library/ssl.rst:1089 msgid ":meth:`~socket.socket.getsockopt`, :meth:`~socket.socket.setsockopt`" msgstr ":meth:`~socket.socket.getsockopt`、:meth:`~socket.socket.setsockopt`" -#: ../../library/ssl.rst:1068 +#: ../../library/ssl.rst:1090 msgid "" ":meth:`~socket.socket.gettimeout`, :meth:`~socket.socket.settimeout`, :meth:" "`~socket.socket.setblocking`" @@ -1457,15 +1490,15 @@ msgstr "" ":meth:`~socket.socket.gettimeout`、:meth:`~socket.socket.settimeout`、:meth:" "`~socket.socket.setblocking`" -#: ../../library/ssl.rst:1070 +#: ../../library/ssl.rst:1092 msgid ":meth:`~socket.socket.listen`" msgstr ":meth:`~socket.socket.listen`" -#: ../../library/ssl.rst:1071 +#: ../../library/ssl.rst:1093 msgid ":meth:`~socket.socket.makefile`" msgstr ":meth:`~socket.socket.makefile`" -#: ../../library/ssl.rst:1072 +#: ../../library/ssl.rst:1094 msgid "" ":meth:`~socket.socket.recv`, :meth:`~socket.socket.recv_into` (but passing a " "non-zero ``flags`` argument is not allowed)" @@ -1473,7 +1506,7 @@ msgstr "" ":meth:`~socket.socket.recv`、:meth:`~socket.socket.recv_into` (但不允許傳遞" "非零的 ``flags`` 引數)" -#: ../../library/ssl.rst:1074 +#: ../../library/ssl.rst:1096 msgid "" ":meth:`~socket.socket.send`, :meth:`~socket.socket.sendall` (with the same " "limitation)" @@ -1481,19 +1514,21 @@ msgstr "" ":meth:`~socket.socket.send`、:meth:`~socket.socket.sendall` (同樣不允許傳遞" "非零的 ``flags`` 引數)" -#: ../../library/ssl.rst:1076 +#: ../../library/ssl.rst:1098 msgid "" -":meth:`~socket.socket.sendfile` (but :mod:`os.sendfile` will be used for " -"plain-text sockets only, else :meth:`~socket.socket.send` will be used)" +":meth:`~socket.socket.sendfile` (it may be high-performant only when the " +"kernel TLS is enabled by setting :data:`~ssl.OP_ENABLE_KTLS` or when a " +"socket is plain-text, else :meth:`~socket.socket.send` will be used)" msgstr "" -":meth:`~socket.socket.sendfile` (但 :mod:`os.sendfile` 只能用於純文本 " -"sockets,其餘則會使用 :meth:`~socket.socket.send`)" +":meth:`~socket.socket.sendfile`\\ (只有在透過設" +"定 :data:`~ssl.OP_ENABLE_KTLS` 啟用核心 TLS 或 socket 為純文字時才可能有高效" +"能,其餘則會使用 :meth:`~socket.socket.send`)" -#: ../../library/ssl.rst:1078 +#: ../../library/ssl.rst:1101 msgid ":meth:`~socket.socket.shutdown`" msgstr ":meth:`~socket.socket.shutdown`" -#: ../../library/ssl.rst:1080 +#: ../../library/ssl.rst:1103 msgid "" "However, since the SSL (and TLS) protocol has its own framing atop of TCP, " "the SSL sockets abstraction can, in certain respects, diverge from the " @@ -1504,18 +1539,18 @@ msgstr "" "sockets 的抽象可能會與普通作業系統級別的 sockets 規範有所不同。特別是請參閱" "\\ :ref:`關於 non-blocking sockets 的說明 `。" -#: ../../library/ssl.rst:1085 +#: ../../library/ssl.rst:1108 msgid "" "Instances of :class:`SSLSocket` must be created using the :meth:`SSLContext." "wrap_socket` method." msgstr "" ":class:`SSLSocket` 的實例必須使用 :meth:`SSLContext.wrap_socket` 方法建立。" -#: ../../library/ssl.rst:1088 +#: ../../library/ssl.rst:1111 msgid "The :meth:`sendfile` method was added." msgstr "新增 :meth:`sendfile` 方法。" -#: ../../library/ssl.rst:1091 +#: ../../library/ssl.rst:1114 msgid "" "The :meth:`shutdown` does not reset the socket timeout each time bytes are " "received or sent. The socket timeout is now the maximum total duration of " @@ -1524,7 +1559,7 @@ msgstr "" ":meth:`shutdown` 不會在每次接收或發送位元組時重置 socket 超時時間。現在," "socket 超時時間是關閉操作的最大總持續時間。" -#: ../../library/ssl.rst:1096 +#: ../../library/ssl.rst:1119 msgid "" "It is deprecated to create a :class:`SSLSocket` instance directly, use :meth:" "`SSLContext.wrap_socket` to wrap a socket." @@ -1532,7 +1567,7 @@ msgstr "" "直接建立 :class:`SSLSocket` 實例的方式已被棄用,請使用 :meth:`SSLContext." "wrap_socket` 來包裝 socket。" -#: ../../library/ssl.rst:1100 +#: ../../library/ssl.rst:1123 msgid "" ":class:`SSLSocket` instances must be created with :meth:`~SSLContext." "wrap_socket`. In earlier versions, it was possible to create instances " @@ -1541,7 +1576,7 @@ msgstr "" ":class:`SSLSocket` 實例必須使用 :meth:`~SSLContext.wrap_socket` 建立。在較早" "的版本中,可以直接建立實例。這從未被記錄或正式支援。" -#: ../../library/ssl.rst:1106 +#: ../../library/ssl.rst:1129 msgid "" "Python now uses ``SSL_read_ex`` and ``SSL_write_ex`` internally. The " "functions support reading and writing of data larger than 2 GB. Writing zero-" @@ -1550,11 +1585,18 @@ msgstr "" "Python 現在內部使用了 ``SSL_read_ex`` 和 ``SSL_write_ex`` 函式。這些函式支援" "讀取和寫入大於 2 GB 的資料。寫入零長度的資料不再會導致協定違規錯誤。" -#: ../../library/ssl.rst:1111 +#: ../../library/ssl.rst:1134 +msgid "" +"Python now uses ``SSL_sendfile`` internally when possible. The function " +"sends a file more efficiently because it performs TLS encryption in the " +"kernel to avoid additional context switches." +msgstr "" + +#: ../../library/ssl.rst:1139 msgid "SSL sockets also have the following additional methods and attributes:" msgstr "SSL sockets 還具有以下附加方法和屬性:" -#: ../../library/ssl.rst:1115 +#: ../../library/ssl.rst:1143 msgid "" "Read up to *len* bytes of data from the SSL socket and return the result as " "a ``bytes`` instance. If *buffer* is specified, then read into the buffer " @@ -1563,7 +1605,7 @@ msgstr "" "從 SSL socket 讀取 *len* 位元組的資料,並將結果以 ``bytes`` 實例的形式回傳。" "如果指定了 *buffer*,則將資料讀入緩衝區,並回傳讀取的位元組。" -#: ../../library/ssl.rst:1119 +#: ../../library/ssl.rst:1147 msgid "" "Raise :exc:`SSLWantReadError` or :exc:`SSLWantWriteError` if the socket is :" "ref:`non-blocking ` and the read would block." @@ -1571,14 +1613,14 @@ msgstr "" "如果 socket 是\\ :ref:`非阻塞的 `\\ 則會引發 :exc:" "`SSLWantReadError` 或 :exc:`SSLWantWriteError` 並且讀取操作將會被阻塞。" -#: ../../library/ssl.rst:1122 +#: ../../library/ssl.rst:1150 msgid "" "As at any time a re-negotiation is possible, a call to :meth:`read` can also " "cause write operations." msgstr "" "由於在任何時刻都可能發生重新協商,呼叫 :meth:`read` 也可能觸發寫入操作。" -#: ../../library/ssl.rst:1125 +#: ../../library/ssl.rst:1153 msgid "" "The socket timeout is no longer reset each time bytes are received or sent. " "The socket timeout is now the maximum total duration to read up to *len* " @@ -1587,11 +1629,11 @@ msgstr "" "當接收或發送位元組時,socket 的超時時間將不再重置。現在,socket 超時時間是讀" "取最多 *len* 位元組的總最大持續時間。" -#: ../../library/ssl.rst:1130 +#: ../../library/ssl.rst:1158 msgid "Use :meth:`~SSLSocket.recv` instead of :meth:`~SSLSocket.read`." msgstr "請改用 :meth:`~SSLSocket.recv` 來替換掉 :meth:`~SSLSocket.read`。" -#: ../../library/ssl.rst:1135 +#: ../../library/ssl.rst:1163 msgid "" "Write *data* to the SSL socket and return the number of bytes written. The " "*data* argument must be an object supporting the buffer interface." @@ -1599,7 +1641,7 @@ msgstr "" "將 *data* 寫入 SSL socket 並回傳寫入的位元組數量。*data* 引數必須是支援緩衝區" "介面的物件。" -#: ../../library/ssl.rst:1138 +#: ../../library/ssl.rst:1166 msgid "" "Raise :exc:`SSLWantReadError` or :exc:`SSLWantWriteError` if the socket is :" "ref:`non-blocking ` and the write would block." @@ -1607,14 +1649,14 @@ msgstr "" "如果 socket 是\\ :ref:`非阻塞的 `\\ 則會引發 :exc:" "`SSLWantReadError` 或 :exc:`SSLWantWriteError` 並且寫入操作將會被阻塞。" -#: ../../library/ssl.rst:1141 +#: ../../library/ssl.rst:1169 msgid "" "As at any time a re-negotiation is possible, a call to :meth:`write` can " "also cause read operations." msgstr "" "由於在任何時刻都可能發生重新協商,呼叫 :meth:`write` 也可能觸發讀取操作。" -#: ../../library/ssl.rst:1144 +#: ../../library/ssl.rst:1172 msgid "" "The socket timeout is no longer reset each time bytes are received or sent. " "The socket timeout is now the maximum total duration to write *data*." @@ -1622,11 +1664,11 @@ msgstr "" "當接收或發送位元組時,socket 的超時時間將不再重置。現在,socket 超時時間是寫" "入 *data* 的總最大持續時間。" -#: ../../library/ssl.rst:1148 +#: ../../library/ssl.rst:1176 msgid "Use :meth:`~SSLSocket.send` instead of :meth:`~SSLSocket.write`." msgstr "請改用 :meth:`~SSLSocket.send` 來替換掉 :meth:`~SSLSocket.write`。" -#: ../../library/ssl.rst:1153 +#: ../../library/ssl.rst:1181 msgid "" "The :meth:`~SSLSocket.read` and :meth:`~SSLSocket.write` methods are the low-" "level methods that read and write unencrypted, application-level data and " @@ -1638,7 +1680,7 @@ msgstr "" "讀取和寫入未加密的應用層資料,並將其加密/解密為加密的寫入層資料。這些方法需要" "一個已建立的 SSL 連接,即握手已完成,且未呼叫 :meth:`SSLSocket.unwrap`。" -#: ../../library/ssl.rst:1159 +#: ../../library/ssl.rst:1187 msgid "" "Normally you should use the socket API methods like :meth:`~socket.socket." "recv` and :meth:`~socket.socket.send` instead of these methods." @@ -1646,18 +1688,18 @@ msgstr "" "通常你應該使用像 :meth:`~socket.socket.recv` 和 :meth:`~socket.socket.send` " "這樣的 socket API 方法,而不是直接使用這些方法。" -#: ../../library/ssl.rst:1165 +#: ../../library/ssl.rst:1193 msgid "Perform the SSL setup handshake." msgstr "執行 SSL 設定握手。" -#: ../../library/ssl.rst:1167 +#: ../../library/ssl.rst:1195 msgid "" "If *block* is true and the timeout obtained by :meth:`~socket.socket." "gettimeout` is zero, the socket is set in blocking mode until the handshake " "is performed." msgstr "" -#: ../../library/ssl.rst:1170 +#: ../../library/ssl.rst:1198 msgid "" "The handshake method also performs :func:`!match_hostname` when the :attr:" "`~SSLContext.check_hostname` attribute of the socket's :attr:`~SSLSocket." @@ -1666,7 +1708,7 @@ msgstr "" "當 socket 的 :attr:`~SSLSocket.context` 的 :attr:`~SSLContext." "check_hostname` 屬性質為 true 時,握手方法也會執行 :func:`!match_hostname`。" -#: ../../library/ssl.rst:1175 +#: ../../library/ssl.rst:1203 msgid "" "The socket timeout is no longer reset each time bytes are received or sent. " "The socket timeout is now the maximum total duration of the handshake." @@ -1674,7 +1716,7 @@ msgstr "" "Socket 超時時間已經不會在每次接收或傳送位元組時重置。現在,超時時間是握手過程" "的最大總持續時間。" -#: ../../library/ssl.rst:1179 +#: ../../library/ssl.rst:1207 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 " @@ -1685,7 +1727,7 @@ msgstr "" "match_hostname` 函式。如果 OpenSSL 拒絕某個主機名稱或 IP 地址,握手將會提前中" "止,並向對方發送 TLS 警報訊息。" -#: ../../library/ssl.rst:1187 +#: ../../library/ssl.rst:1215 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:" @@ -1694,7 +1736,7 @@ msgstr "" "如果連線端沒有證書,則回傳 ``None``。如果 SSL 握手尚未完成,則引發 :exc:" "`ValueError`。" -#: ../../library/ssl.rst:1191 +#: ../../library/ssl.rst:1219 msgid "" "If the ``binary_form`` parameter is :const:`False`, and a certificate was " "received from the peer, this method returns a :class:`dict` instance. If " @@ -1711,7 +1753,7 @@ msgstr "" "``issuer`` (簽發證書的主體)。如果證書中包含 *Subject Alternative Name* 擴充 " "(參考\\ :rfc:`3280`\\ ),字典中還會有一個 ``subjectAltName`` 鍵。" -#: ../../library/ssl.rst:1200 +#: ../../library/ssl.rst:1228 msgid "" "The ``subject`` and ``issuer`` fields are tuples containing the sequence of " "relative distinguished names (RDNs) given in the certificate's data " @@ -1722,7 +1764,7 @@ msgstr "" "names, RDNs) 序列的元組,這些 RDN 來自證書資料結構中的相應欄位。每個 RDN 都是" "一組名稱與值的對。以下是現實中的範例: ::" -#: ../../library/ssl.rst:1205 +#: ../../library/ssl.rst:1233 msgid "" "{'issuer': ((('countryName', 'IL'),),\n" " (('organizationName', 'StartCom Ltd.'),),\n" @@ -1764,7 +1806,7 @@ msgstr "" " 'subjectAltName': (('DNS', '*.eff.org'), ('DNS', 'eff.org')),\n" " 'version': 3}" -#: ../../library/ssl.rst:1224 +#: ../../library/ssl.rst:1252 msgid "" "If the ``binary_form`` parameter is :const:`True`, and a certificate was " "provided, this method returns the DER-encoded form of the entire certificate " @@ -1776,13 +1818,13 @@ msgstr "" "以 DER 編碼形式 將整個證書以位元組序列形式回傳。如果對等未提供證書,則回傳 :" "const:`None`。對等是否提供證書取決於 SSL socket 的腳色:" -#: ../../library/ssl.rst:1230 +#: ../../library/ssl.rst:1258 msgid "" "for a client SSL socket, the server will always provide a certificate, " "regardless of whether validation was required;" msgstr "對於用戶端 SSL socket,伺服器將永遠提供證書,無論是否需要進行驗證;" -#: ../../library/ssl.rst:1233 +#: ../../library/ssl.rst:1261 msgid "" "for a server SSL socket, the client will only provide a certificate when " "requested by the server; therefore :meth:`getpeercert` will return :const:" @@ -1793,41 +1835,41 @@ msgstr "" "是 :const:`CERT_NONE` (而非 :const:`CERT_OPTIONAL` 或 :const:" "`CERT_REQUIRED`),則 :meth:`getpeercert` 會回傳 :const:`None`。" -#: ../../library/ssl.rst:1238 +#: ../../library/ssl.rst:1266 msgid "See also :attr:`SSLContext.check_hostname`." msgstr "請見 :attr:`SSLContext.check_hostname`。" -#: ../../library/ssl.rst:1240 +#: ../../library/ssl.rst:1268 msgid "" "The returned dictionary includes additional items such as ``issuer`` and " "``notBefore``." msgstr "" -#: ../../library/ssl.rst:1244 +#: ../../library/ssl.rst:1272 msgid "" ":exc:`ValueError` is raised when the handshake isn't done. The returned " "dictionary includes additional X509v3 extension items such as " "``crlDistributionPoints``, ``caIssuers`` and ``OCSP`` URIs." msgstr "" -#: ../../library/ssl.rst:1249 +#: ../../library/ssl.rst:1277 msgid "IPv6 address strings no longer have a trailing new line." msgstr "" -#: ../../library/ssl.rst:1254 +#: ../../library/ssl.rst:1282 msgid "" "Returns verified certificate chain provided by the other end of the SSL " "channel as a list of DER-encoded bytes. If certificate verification was " "disabled method acts the same as :meth:`~SSLSocket.get_unverified_chain`." msgstr "" -#: ../../library/ssl.rst:1263 +#: ../../library/ssl.rst:1291 msgid "" "Returns raw certificate chain provided by the other end of the SSL channel " "as a list of DER-encoded bytes." msgstr "" -#: ../../library/ssl.rst:1270 +#: ../../library/ssl.rst:1298 msgid "" "Returns a three-value tuple containing the name of the cipher being used, " "the version of the SSL protocol that defines its use, and the number of " @@ -1835,7 +1877,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/ssl.rst:1276 +#: ../../library/ssl.rst:1304 msgid "" "Return the list of ciphers available in both the client and server. Each " "entry of the returned list is a three-value tuple containing the name of the " @@ -1845,25 +1887,45 @@ msgid "" "socket." msgstr "" -#: ../../library/ssl.rst:1287 +#: ../../library/ssl.rst:1315 +msgid "" +"Return the group used for doing key agreement on this connection. If no " +"connection has been established, returns ``None``." +msgstr "" + +#: ../../library/ssl.rst:1322 +msgid "" +"Return the signature algorithm used for performing certificate-based client " +"authentication on this connection, or ``None`` if no connection has been " +"established or client authentication didn't occur." +msgstr "" + +#: ../../library/ssl.rst:1330 +msgid "" +"Return the signature algorithm used by the server to complete the TLS " +"handshake on this connection, or ``None`` if no connection has been " +"established or the cipher suite has no signature." +msgstr "" + +#: ../../library/ssl.rst:1338 msgid "" "Return the compression algorithm being used as a string, or ``None`` if the " "connection isn't compressed." msgstr "" -#: ../../library/ssl.rst:1290 +#: ../../library/ssl.rst:1341 msgid "" "If the higher-level protocol supports its own compression mechanism, you can " "use :data:`OP_NO_COMPRESSION` to disable SSL-level compression." msgstr "" -#: ../../library/ssl.rst:1297 +#: ../../library/ssl.rst:1348 msgid "" "Get channel binding data for current connection, as a bytes object. Returns " "``None`` if not connected or the handshake has not been completed." msgstr "" -#: ../../library/ssl.rst:1300 +#: ../../library/ssl.rst:1351 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` " @@ -1872,7 +1934,7 @@ msgid "" "channel binding type is requested." msgstr "" -#: ../../library/ssl.rst:1310 +#: ../../library/ssl.rst:1361 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 " @@ -1880,7 +1942,7 @@ msgid "" "protocols, or if the handshake has not happened yet, ``None`` is returned." msgstr "" -#: ../../library/ssl.rst:1320 +#: ../../library/ssl.rst:1371 msgid "" "Return the higher-level protocol that was selected during the TLS/SSL " "handshake. If :meth:`SSLContext.set_npn_protocols` was not called, or if the " @@ -1888,11 +1950,11 @@ msgid "" "this will return ``None``." msgstr "" -#: ../../library/ssl.rst:1329 ../../library/ssl.rst:1698 +#: ../../library/ssl.rst:1380 ../../library/ssl.rst:1824 msgid "NPN has been superseded by ALPN" msgstr "" -#: ../../library/ssl.rst:1333 +#: ../../library/ssl.rst:1384 msgid "" "Performs the SSL shutdown handshake, which removes the TLS layer from the " "underlying socket, and returns the underlying socket object. This can be " @@ -1901,7 +1963,7 @@ msgid "" "other side of the connection, rather than the original socket." msgstr "" -#: ../../library/ssl.rst:1341 +#: ../../library/ssl.rst:1392 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 " @@ -1909,26 +1971,26 @@ msgid "" "`SSLContext.post_handshake_auth`." msgstr "" -#: ../../library/ssl.rst:1346 +#: ../../library/ssl.rst:1397 msgid "" "The method does not perform a cert exchange immediately. The server-side " "sends a CertificateRequest during the next write event and expects the " "client to respond with a certificate on the next read event." msgstr "" -#: ../../library/ssl.rst:1350 +#: ../../library/ssl.rst:1401 msgid "" "If any precondition isn't met (e.g. not TLS 1.3, PHA not enabled), an :exc:" "`SSLError` is raised." msgstr "" -#: ../../library/ssl.rst:1354 +#: ../../library/ssl.rst:1405 msgid "" "Only available with OpenSSL 1.1.1 and TLS 1.3 enabled. Without TLS 1.3 " "support, the method raises :exc:`NotImplementedError`." msgstr "" -#: ../../library/ssl.rst:1361 +#: ../../library/ssl.rst:1412 msgid "" "Return the actual SSL protocol version negotiated by the connection as a " "string, or ``None`` if no secure connection is established. As of this " @@ -1937,29 +1999,29 @@ msgid "" "may define more return values." msgstr "" -#: ../../library/ssl.rst:1371 +#: ../../library/ssl.rst:1422 msgid "" "Returns the number of already decrypted bytes available for read, pending on " "the connection." msgstr "" -#: ../../library/ssl.rst:1376 +#: ../../library/ssl.rst:1427 msgid "The :class:`SSLContext` object this SSL socket is tied to." msgstr "" -#: ../../library/ssl.rst:1382 +#: ../../library/ssl.rst:1433 msgid "" "A boolean which is ``True`` for server-side sockets and ``False`` for client-" "side sockets." msgstr "" -#: ../../library/ssl.rst:1389 +#: ../../library/ssl.rst:1440 msgid "" "Hostname of the server: :class:`str` type, or ``None`` for server-side " "socket or if the hostname was not specified in the constructor." msgstr "" -#: ../../library/ssl.rst:1394 +#: ../../library/ssl.rst:1445 msgid "" "The attribute is now always ASCII text. When ``server_hostname`` is an " "internationalized domain name (IDN), this attribute now stores the A-label " @@ -1967,7 +2029,7 @@ msgid "" "org\"``)." msgstr "" -#: ../../library/ssl.rst:1402 +#: ../../library/ssl.rst:1453 msgid "" "The :class:`SSLSession` for this SSL connection. The session is available " "for client and server side sockets after the TLS handshake has been " @@ -1975,11 +2037,11 @@ msgid "" "`~SSLSocket.do_handshake` has been called to reuse a session." msgstr "" -#: ../../library/ssl.rst:1415 +#: ../../library/ssl.rst:1466 msgid "SSL contexts" msgstr "SSL contexts" -#: ../../library/ssl.rst:1419 +#: ../../library/ssl.rst:1470 msgid "" "An SSL context holds various data longer-lived than single SSL connections, " "such as SSL configuration options, certificate(s) and private key(s). It " @@ -1987,7 +2049,7 @@ msgid "" "speed up repeated connections from the same clients." msgstr "" -#: ../../library/ssl.rst:1426 +#: ../../library/ssl.rst:1477 msgid "" "Create a new SSL context. You may pass *protocol* which must be one of the " "``PROTOCOL_*`` constants defined in this module. The parameter specifies " @@ -1998,109 +2060,109 @@ msgid "" "provides the most compatibility with other versions." msgstr "" -#: ../../library/ssl.rst:1435 +#: ../../library/ssl.rst:1486 msgid "" "Here's a table showing which versions in a client (down the side) can " "connect to which versions in a server (along the top):" msgstr "" -#: ../../library/ssl.rst:1441 +#: ../../library/ssl.rst:1492 msgid "*client* / **server**" msgstr "*client* / **server**" -#: ../../library/ssl.rst:1441 +#: ../../library/ssl.rst:1492 msgid "**SSLv2**" msgstr "**SSLv2**" -#: ../../library/ssl.rst:1441 +#: ../../library/ssl.rst:1492 msgid "**SSLv3**" msgstr "**SSLv3**" -#: ../../library/ssl.rst:1441 +#: ../../library/ssl.rst:1492 msgid "**TLS** [3]_" msgstr "**TLS** [3]_" -#: ../../library/ssl.rst:1441 +#: ../../library/ssl.rst:1492 msgid "**TLSv1**" msgstr "**TLSv1**" -#: ../../library/ssl.rst:1441 +#: ../../library/ssl.rst:1492 msgid "**TLSv1.1**" msgstr "**TLSv1.1**" -#: ../../library/ssl.rst:1441 +#: ../../library/ssl.rst:1492 msgid "**TLSv1.2**" msgstr "**TLSv1.2**" -#: ../../library/ssl.rst:1443 +#: ../../library/ssl.rst:1494 msgid "*SSLv2*" msgstr "*SSLv2*" -#: ../../library/ssl.rst:1443 ../../library/ssl.rst:1444 -#: ../../library/ssl.rst:1445 ../../library/ssl.rst:1446 -#: ../../library/ssl.rst:1447 ../../library/ssl.rst:1448 +#: ../../library/ssl.rst:1494 ../../library/ssl.rst:1495 +#: ../../library/ssl.rst:1496 ../../library/ssl.rst:1497 +#: ../../library/ssl.rst:1498 ../../library/ssl.rst:1499 msgid "yes" msgstr "" -#: ../../library/ssl.rst:1443 ../../library/ssl.rst:1444 -#: ../../library/ssl.rst:1446 ../../library/ssl.rst:1447 -#: ../../library/ssl.rst:1448 +#: ../../library/ssl.rst:1494 ../../library/ssl.rst:1495 +#: ../../library/ssl.rst:1497 ../../library/ssl.rst:1498 +#: ../../library/ssl.rst:1499 msgid "no" msgstr "" -#: ../../library/ssl.rst:1443 ../../library/ssl.rst:1445 +#: ../../library/ssl.rst:1494 ../../library/ssl.rst:1496 msgid "no [1]_" msgstr "" -#: ../../library/ssl.rst:1444 +#: ../../library/ssl.rst:1495 msgid "*SSLv3*" msgstr "*SSLv3*" -#: ../../library/ssl.rst:1444 ../../library/ssl.rst:1445 +#: ../../library/ssl.rst:1495 ../../library/ssl.rst:1496 msgid "no [2]_" msgstr "" -#: ../../library/ssl.rst:1445 +#: ../../library/ssl.rst:1496 msgid "*TLS* (*SSLv23*) [3]_" msgstr "*TLS* (*SSLv23*) [3]_" -#: ../../library/ssl.rst:1446 +#: ../../library/ssl.rst:1497 msgid "*TLSv1*" msgstr "*TLSv1*" -#: ../../library/ssl.rst:1447 +#: ../../library/ssl.rst:1498 msgid "*TLSv1.1*" msgstr "*TLSv1.1*" -#: ../../library/ssl.rst:1448 +#: ../../library/ssl.rst:1499 msgid "*TLSv1.2*" msgstr "*TLSv1.2*" -#: ../../library/ssl.rst:1451 +#: ../../library/ssl.rst:1502 msgid "Footnotes" msgstr "註腳" -#: ../../library/ssl.rst:1452 +#: ../../library/ssl.rst:1503 msgid ":class:`SSLContext` disables SSLv2 with :data:`OP_NO_SSLv2` by default." msgstr ":class:`SSLContext` 預設會關閉 SSLv2 的 :data:`OP_NO_SSLv2`。" -#: ../../library/ssl.rst:1453 +#: ../../library/ssl.rst:1504 msgid ":class:`SSLContext` disables SSLv3 with :data:`OP_NO_SSLv3` by default." msgstr ":class:`SSLContext` 預設會關閉 SSLv3 的 :data:`OP_NO_SSLv3`。" -#: ../../library/ssl.rst:1454 +#: ../../library/ssl.rst:1505 msgid "" "TLS 1.3 protocol will be available with :data:`PROTOCOL_TLS` in OpenSSL >= " "1.1.1. There is no dedicated PROTOCOL constant for just TLS 1.3." msgstr "" -#: ../../library/ssl.rst:1459 +#: ../../library/ssl.rst:1510 msgid "" ":func:`create_default_context` lets the :mod:`!ssl` module choose security " "settings for a given purpose." msgstr "" -#: ../../library/ssl.rst:1464 +#: ../../library/ssl.rst:1515 msgid "" "The context is created with secure default values. The options :data:" "`OP_NO_COMPRESSION`, :data:`OP_CIPHER_SERVER_PREFERENCE`, :data:" @@ -2110,14 +2172,14 @@ msgid "" "ciphers and no ``MD5`` ciphers." msgstr "" -#: ../../library/ssl.rst:1474 +#: ../../library/ssl.rst:1525 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." msgstr "" -#: ../../library/ssl.rst:1480 +#: ../../library/ssl.rst:1531 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 " @@ -2126,7 +2188,7 @@ msgid "" "use TLS 1.2 as minimum TLS version." msgstr "" -#: ../../library/ssl.rst:1488 +#: ../../library/ssl.rst:1539 msgid "" ":class:`SSLContext` only supports limited mutation once it has been used by " "a connection. Adding new certificates to the internal trust store is " @@ -2134,29 +2196,29 @@ msgid "" "may result in surprising behavior." msgstr "" -#: ../../library/ssl.rst:1495 +#: ../../library/ssl.rst:1546 msgid "" ":class:`SSLContext` is designed to be shared and used by multiple " "connections. Thus, it is thread-safe as long as it is not reconfigured after " "being used by a connection." msgstr "" -#: ../../library/ssl.rst:1500 +#: ../../library/ssl.rst:1551 msgid ":class:`SSLContext` objects have the following methods and attributes:" msgstr ":class:`SSLContext` 物件具有以下方法和屬性:" -#: ../../library/ssl.rst:1504 +#: ../../library/ssl.rst:1555 msgid "" "Get statistics about quantities of loaded X.509 certificates, count of X.509 " "certificates flagged as CA certificates and certificate revocation lists as " "dictionary." msgstr "" -#: ../../library/ssl.rst:1508 +#: ../../library/ssl.rst:1559 msgid "Example for a context with one CA cert and one other cert::" msgstr "" -#: ../../library/ssl.rst:1510 +#: ../../library/ssl.rst:1561 msgid "" ">>> context.cert_store_stats()\n" "{'crl': 0, 'x509_ca': 1, 'x509': 2}" @@ -2164,7 +2226,7 @@ msgstr "" ">>> context.cert_store_stats()\n" "{'crl': 0, 'x509_ca': 1, 'x509': 2}" -#: ../../library/ssl.rst:1518 +#: ../../library/ssl.rst:1569 msgid "" "Load a private key and the corresponding certificate. The *certfile* string " "must be the path to a single file in PEM format containing the certificate " @@ -2175,7 +2237,7 @@ msgid "" "more information on how the certificate is stored in the *certfile*." msgstr "" -#: ../../library/ssl.rst:1527 +#: ../../library/ssl.rst:1578 msgid "" "The *password* argument may be a function to call to get the password for " "decrypting the private key. It will only be called if the private key is " @@ -2187,24 +2249,24 @@ msgid "" "encrypted and no password is needed." msgstr "" -#: ../../library/ssl.rst:1536 +#: ../../library/ssl.rst:1587 msgid "" "If the *password* argument is not specified and a password is required, " "OpenSSL's built-in password prompting mechanism will be used to " "interactively prompt the user for a password." msgstr "" -#: ../../library/ssl.rst:1540 +#: ../../library/ssl.rst:1591 msgid "" "An :class:`SSLError` is raised if the private key doesn't match with the " "certificate." msgstr "" -#: ../../library/ssl.rst:1543 +#: ../../library/ssl.rst:1594 msgid "New optional argument *password*." msgstr "新增可選引數 *password*。" -#: ../../library/ssl.rst:1548 +#: ../../library/ssl.rst:1599 msgid "" "Load a set of default \"certification authority\" (CA) certificates from " "default locations. On Windows it loads CA certs from the ``CA`` and ``ROOT`` " @@ -2213,7 +2275,7 @@ msgid "" "from other locations, too." msgstr "" -#: ../../library/ssl.rst:1554 +#: ../../library/ssl.rst:1605 msgid "" "The *purpose* flag specifies what kind of CA certificates are loaded. The " "default settings :const:`Purpose.SERVER_AUTH` loads certificates, that are " @@ -2222,35 +2284,35 @@ msgid "" "certificate verification on the server side." msgstr "" -#: ../../library/ssl.rst:1564 +#: ../../library/ssl.rst:1615 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." msgstr "" -#: ../../library/ssl.rst:1568 +#: ../../library/ssl.rst:1619 msgid "" "This method can also load certification revocation lists (CRLs) in PEM or " "DER format. In order to make use of CRLs, :attr:`SSLContext.verify_flags` " "must be configured properly." msgstr "" -#: ../../library/ssl.rst:1572 +#: ../../library/ssl.rst:1623 msgid "" "The *cafile* string, if present, is the path to a file of concatenated CA " "certificates in PEM format. See the discussion of :ref:`ssl-certificates` " "for more information about how to arrange the certificates in this file." msgstr "" -#: ../../library/ssl.rst:1577 +#: ../../library/ssl.rst:1628 msgid "" "The *capath* string, if present, is the path to a directory containing " "several CA certificates in PEM format, following an `OpenSSL specific layout " "`_." msgstr "" -#: ../../library/ssl.rst:1582 +#: ../../library/ssl.rst:1633 msgid "" "The *cadata* object, if present, is either an ASCII string of one or more " "PEM-encoded certificates or a :term:`bytes-like object` of DER-encoded " @@ -2258,11 +2320,11 @@ msgid "" "are ignored but at least one certificate must be present." msgstr "" -#: ../../library/ssl.rst:1587 +#: ../../library/ssl.rst:1638 msgid "New optional argument *cadata*" msgstr "新增可選引數 *cadata*" -#: ../../library/ssl.rst:1592 +#: ../../library/ssl.rst:1643 msgid "" "Get a list of loaded \"certification authority\" (CA) certificates. If the " "``binary_form`` parameter is :const:`False` each list entry is a dict like " @@ -2272,19 +2334,19 @@ msgid "" "a SSL connection." msgstr "" -#: ../../library/ssl.rst:1600 +#: ../../library/ssl.rst:1651 msgid "" "Certificates in a capath directory aren't loaded unless they have been used " "at least once." msgstr "" -#: ../../library/ssl.rst:1607 +#: ../../library/ssl.rst:1658 msgid "" "Get a list of enabled ciphers. The list is in order of cipher priority. See :" "meth:`SSLContext.set_ciphers`." msgstr "" -#: ../../library/ssl.rst:1612 +#: ../../library/ssl.rst:1663 msgid "" ">>> ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)\n" ">>> ctx.set_ciphers('ECDHE+AESGCM:!ECDSA')\n" @@ -2342,7 +2404,39 @@ msgstr "" " 'strength_bits': 128,\n" " 'symmetric': 'aes-128-gcm'}]" -#: ../../library/ssl.rst:1644 +#: ../../library/ssl.rst:1695 +msgid "" +"Get a list of groups implemented for key agreement, taking into account the " +"current TLS :attr:`~SSLContext.minimum_version` and :attr:`~SSLContext." +"maximum_version` values. For example::" +msgstr "" +"取得為金鑰協商 (key agreement) 所實作的群組清單,並會考慮目前 TLS " +"的 :attr:`~SSLContext.minimum_version` " +"和 :attr:`~SSLContext.maximum_version` 值。例如: ::" + +#: ../../library/ssl.rst:1699 +msgid "" +">>> ctx = ssl.create_default_context()\n" +">>> ctx.minimum_version = ssl.TLSVersion.TLSv1_3\n" +">>> ctx.maximum_version = ssl.TLSVersion.TLSv1_3\n" +">>> ctx.get_groups()\n" +"['secp256r1', 'secp384r1', 'secp521r1', 'x25519', 'x448', ...]" +msgstr "" +">>> ctx = ssl.create_default_context()\n" +">>> ctx.minimum_version = ssl.TLSVersion.TLSv1_3\n" +">>> ctx.maximum_version = ssl.TLSVersion.TLSv1_3\n" +">>> ctx.get_groups()\n" +"['secp256r1', 'secp384r1', 'secp521r1', 'x25519', 'x448', ...]" + +#: ../../library/ssl.rst:1705 +msgid "" +"By default, this method returns only the preferred IANA names for the " +"available groups. However, if the ``include_aliases`` parameter is set to :" +"const:`True` this method will also return any associated aliases such as the " +"ECDH curve names supported in older versions of OpenSSL." +msgstr "" + +#: ../../library/ssl.rst:1714 msgid "" "Load a set of default \"certification authority\" (CA) certificates from a " "filesystem path defined when building the OpenSSL library. Unfortunately, " @@ -2352,28 +2446,80 @@ msgid "" "configured properly." msgstr "" -#: ../../library/ssl.rst:1653 +#: ../../library/ssl.rst:1723 msgid "" -"Set the available ciphers for sockets created with this context. It should " -"be a string in the `OpenSSL cipher list format `_. If no cipher can be selected (because compile-time " -"options or other configuration forbids use of all the specified ciphers), " -"an :class:`SSLError` will be raised." +"Set the allowed ciphers for sockets created with this context when " +"connecting using TLS 1.2 and earlier. The *ciphers* argument should be a " +"string in the `OpenSSL cipher list format `_. To set allowed TLS 1.3 ciphers, use :meth:`SSLContext." +"set_ciphersuites`." msgstr "" -#: ../../library/ssl.rst:1661 +#: ../../library/ssl.rst:1729 msgid "" -"when connected, the :meth:`SSLSocket.cipher` method of SSL sockets will give " -"the currently selected cipher." +"If no cipher can be selected (because compile-time options or other " +"configuration forbids use of all the specified ciphers), an :class:" +"`SSLError` will be raised." msgstr "" -#: ../../library/ssl.rst:1664 +#: ../../library/ssl.rst:1734 ../../library/ssl.rst:1746 msgid "" -"TLS 1.3 cipher suites cannot be disabled with :meth:`~SSLContext." -"set_ciphers`." +"When connected, the :meth:`SSLSocket.cipher` method of SSL sockets will " +"return details about the negotiated cipher." msgstr "" -#: ../../library/ssl.rst:1669 +#: ../../library/ssl.rst:1739 +msgid "" +"Set the allowed ciphers for sockets created with this context when " +"connecting using TLS 1.3. The *ciphersuites* argument should be a colon-" +"separate string of TLS 1.3 cipher names. If no cipher can be selected " +"(because compile-time options or other configuration forbids use of all the " +"specified ciphers), an :class:`SSLError` will be raised." +msgstr "" + +#: ../../library/ssl.rst:1753 +msgid "" +"Set the groups allowed for key agreement for sockets created with this " +"context. It should be a string in the `OpenSSL group list format `_." +msgstr "" + +#: ../../library/ssl.rst:1759 +msgid "" +"When connected, the :meth:`SSLSocket.group` method of SSL sockets will " +"return the group used for key agreement on that connection." +msgstr "" + +#: ../../library/ssl.rst:1766 +msgid "" +"Set the signature algorithms allowed for certificate-based client " +"authentication. It should be a string in the `OpenSSL client sigalgs list " +"format `_." +msgstr "" + +#: ../../library/ssl.rst:1773 +msgid "" +"When connected, the :meth:`SSLSocket.client_sigalg` method of SSL sockets " +"will return the signature algorithm used for performing certificate-based " +"client authentication on that connection." +msgstr "" + +#: ../../library/ssl.rst:1781 +msgid "" +"Set the signature algorithms allowed for the server to complete the TLS " +"handshake. It should be a string in the `OpenSSL sigalgs list format " +"`_." +msgstr "" + +#: ../../library/ssl.rst:1787 +msgid "" +"When connected, the :meth:`SSLSocket.server_sigalg` method of SSL sockets " +"will return the signature algorithm used by the server to complete the TLS " +"handshake on that connection." +msgstr "" + +#: ../../library/ssl.rst:1795 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', " @@ -2383,14 +2529,14 @@ msgid "" "will return the agreed-upon protocol." msgstr "" -#: ../../library/ssl.rst:1676 +#: ../../library/ssl.rst:1802 msgid "" "This method will raise :exc:`NotImplementedError` if :data:`HAS_ALPN` is " "``False``." msgstr "" "此方法會在 :data:`HAS_ALPN` 為 ``False`` 時引發 :exc:`NotImplementedError`。" -#: ../../library/ssl.rst:1683 +#: ../../library/ssl.rst:1809 msgid "" "Specify which protocols the socket should advertise during the SSL/TLS " "handshake. It should be a list of strings, like ``['http/1.1', 'spdy/2']``, " @@ -2402,14 +2548,14 @@ msgid "" "protocol." msgstr "" -#: ../../library/ssl.rst:1691 +#: ../../library/ssl.rst:1817 msgid "" "This method will raise :exc:`NotImplementedError` if :data:`HAS_NPN` is " "``False``." msgstr "" "此方法會在 :data:`HAS_NPN` 為 ``False`` 時引發 :exc:`NotImplementedError`。" -#: ../../library/ssl.rst:1702 +#: ../../library/ssl.rst:1828 msgid "" "Register a callback function that will be called after the TLS Client Hello " "handshake message has been received by the SSL/TLS server when the TLS " @@ -2417,14 +2563,14 @@ msgid "" "mechanism is specified in :rfc:`6066` section 3 - Server Name Indication." msgstr "" -#: ../../library/ssl.rst:1707 +#: ../../library/ssl.rst:1833 msgid "" "Only one callback can be set per ``SSLContext``. If *sni_callback* is set " "to ``None`` then the callback is disabled. Calling this function a " "subsequent time will disable the previously registered callback." msgstr "" -#: ../../library/ssl.rst:1711 +#: ../../library/ssl.rst:1837 msgid "" "The callback function will be called with three arguments; the first being " "the :class:`ssl.SSLSocket`, the second is a string that represents the " @@ -2435,14 +2581,14 @@ msgid "" "pythn-mua.org\"``)." msgstr "" -#: ../../library/ssl.rst:1719 +#: ../../library/ssl.rst:1845 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." msgstr "" -#: ../../library/ssl.rst:1724 +#: ../../library/ssl.rst:1850 msgid "" "If the callback assigns a new context to :attr:`SSLSocket.context`, any " "further ClientHello message on the same connection (for example after a TLS " @@ -2450,7 +2596,7 @@ msgid "" "it has one; the original callback is not called again for that connection." msgstr "" -#: ../../library/ssl.rst:1730 +#: ../../library/ssl.rst:1856 msgid "" "Due to the early negotiation phase of the TLS connection, only limited " "methods and attributes are usable like :meth:`SSLSocket." @@ -2462,7 +2608,7 @@ msgid "" "they be called safely." msgstr "" -#: ../../library/ssl.rst:1739 +#: ../../library/ssl.rst:1865 msgid "" "The *sni_callback* function must return ``None`` to allow the TLS " "negotiation to continue. If a TLS failure is required, a constant :const:" @@ -2471,27 +2617,27 @@ msgid "" "`ALERT_DESCRIPTION_INTERNAL_ERROR`." msgstr "" -#: ../../library/ssl.rst:1745 +#: ../../library/ssl.rst:1871 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`." msgstr "" -#: ../../library/ssl.rst:1749 +#: ../../library/ssl.rst:1875 msgid "" "This method will raise :exc:`NotImplementedError` if the OpenSSL library had " "OPENSSL_NO_TLSEXT defined when it was built." msgstr "" -#: ../../library/ssl.rst:1754 +#: ../../library/ssl.rst:1880 msgid "" "After the callback assigns a new :attr:`SSLSocket.context`, later " "ClientHello messages on the connection are dispatched to the new context's " "*sni_callback*." msgstr "" -#: ../../library/ssl.rst:1761 +#: ../../library/ssl.rst:1887 msgid "" "This is a legacy API retained for backwards compatibility. When possible, " "you should use :attr:`sni_callback` instead. The given " @@ -2500,14 +2646,14 @@ msgid "" "*server_name_callback* receives a decoded U-label (``\"pythön.org\"``)." msgstr "" -#: ../../library/ssl.rst:1767 +#: ../../library/ssl.rst:1893 msgid "" "If there is a decoding error on the server name, the TLS connection will " "terminate with an :const:`ALERT_DESCRIPTION_INTERNAL_ERROR` fatal TLS alert " "message to the client." msgstr "" -#: ../../library/ssl.rst:1775 +#: ../../library/ssl.rst:1901 msgid "" "Load the key generation parameters for Diffie-Hellman (DH) key exchange. " "Using DH key exchange improves forward secrecy at the expense of " @@ -2516,13 +2662,13 @@ msgid "" "format." msgstr "" -#: ../../library/ssl.rst:1781 +#: ../../library/ssl.rst:1907 msgid "" "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:1788 +#: ../../library/ssl.rst:1914 msgid "" "Set the curve name for Elliptic Curve-based Diffie-Hellman (ECDH) key " "exchange. ECDH is significantly faster than regular DH while arguably as " @@ -2531,27 +2677,27 @@ msgid "" "curve." msgstr "" -#: ../../library/ssl.rst:1794 +#: ../../library/ssl.rst:1920 msgid "" "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:1797 +#: ../../library/ssl.rst:1923 msgid "This method is not available if :data:`HAS_ECDH` is ``False``." msgstr "此方法在 :data:`HAS_ECDH` 為 ``False`` 時不可用。" -#: ../../library/ssl.rst:1802 +#: ../../library/ssl.rst:1928 msgid "" "`SSL/TLS & Perfect Forward Secrecy `_" msgstr "" -#: ../../library/ssl.rst:1803 +#: ../../library/ssl.rst:1929 msgid "Vincent Bernat." msgstr "" -#: ../../library/ssl.rst:1809 +#: ../../library/ssl.rst:1935 msgid "" "Wrap an existing Python socket *sock* and return an instance of :attr:" "`SSLContext.sslsocket_class` (default :class:`SSLSocket`). The returned SSL " @@ -2559,13 +2705,13 @@ msgid "" "a :const:`~socket.SOCK_STREAM` socket; other socket types are unsupported." msgstr "" -#: ../../library/ssl.rst:1815 +#: ../../library/ssl.rst:1941 msgid "" "The parameter ``server_side`` is a boolean which identifies whether server-" "side or client-side behavior is desired from this socket." msgstr "" -#: ../../library/ssl.rst:1818 +#: ../../library/ssl.rst:1944 msgid "" "For client-side sockets, the context construction is lazy; if the underlying " "socket isn't connected yet, the context construction will be performed " @@ -2576,7 +2722,7 @@ msgid "" "exc:`SSLError`." msgstr "" -#: ../../library/ssl.rst:1826 +#: ../../library/ssl.rst:1952 msgid "" "On client connections, the optional parameter *server_hostname* specifies " "the hostname of the service which we are connecting to. This allows a " @@ -2585,7 +2731,7 @@ msgid "" "*server_hostname* will raise a :exc:`ValueError` if *server_side* is true." msgstr "" -#: ../../library/ssl.rst:1832 +#: ../../library/ssl.rst:1958 msgid "" "The parameter ``do_handshake_on_connect`` specifies whether to do the SSL " "handshake automatically after doing a :meth:`socket.connect`, or whether the " @@ -2595,7 +2741,7 @@ msgid "" "socket I/O involved in the handshake." msgstr "" -#: ../../library/ssl.rst:1839 +#: ../../library/ssl.rst:1965 msgid "" "The parameter ``suppress_ragged_eofs`` specifies how the :meth:`SSLSocket." "recv` method should signal unexpected EOF from the other end of the " @@ -2605,40 +2751,40 @@ msgid "" "exceptions back to the caller." msgstr "" -#: ../../library/ssl.rst:1846 +#: ../../library/ssl.rst:1972 msgid "*session*, see :attr:`~SSLSocket.session`." msgstr "" -#: ../../library/ssl.rst:1848 +#: ../../library/ssl.rst:1974 msgid "" "To wrap an :class:`SSLSocket` in another :class:`SSLSocket`, use :meth:" "`SSLContext.wrap_bio`." msgstr "" -#: ../../library/ssl.rst:1851 +#: ../../library/ssl.rst:1977 msgid "" "Always allow a server_hostname to be passed, even if OpenSSL does not have " "SNI." msgstr "" -#: ../../library/ssl.rst:1855 ../../library/ssl.rst:1886 +#: ../../library/ssl.rst:1981 ../../library/ssl.rst:2012 msgid "*session* argument was added." msgstr "新增 *session* 引數。" -#: ../../library/ssl.rst:1858 +#: ../../library/ssl.rst:1984 msgid "" "The method returns an instance of :attr:`SSLContext.sslsocket_class` instead " "of hard-coded :class:`SSLSocket`." msgstr "" -#: ../../library/ssl.rst:1864 +#: ../../library/ssl.rst:1990 msgid "" "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:1874 +#: ../../library/ssl.rst:2000 msgid "" "Wrap the BIO objects *incoming* and *outgoing* and return an instance of :" "attr:`SSLContext.sslobject_class` (default :class:`SSLObject`). The SSL " @@ -2646,7 +2792,7 @@ msgid "" "outgoing BIO." msgstr "" -#: ../../library/ssl.rst:1879 +#: ../../library/ssl.rst:2005 msgid "" "The *server_side*, *server_hostname* and *session* parameters have the same " "meaning as in :meth:`SSLContext.wrap_socket`, and are validated in the same " @@ -2655,13 +2801,13 @@ msgid "" "would be no name to match the peer's certificate against." msgstr "" -#: ../../library/ssl.rst:1889 +#: ../../library/ssl.rst:2015 msgid "" "The method returns an instance of :attr:`SSLContext.sslobject_class` instead " "of hard-coded :class:`SSLObject`." msgstr "" -#: ../../library/ssl.rst:1893 +#: ../../library/ssl.rst:2019 msgid "" "The *server_side*, *server_hostname* and *session* parameters are now " "validated as :meth:`SSLContext.wrap_socket` validates them. Previously a " @@ -2670,14 +2816,14 @@ msgid "" "the peer's identity." msgstr "" -#: ../../library/ssl.rst:1902 +#: ../../library/ssl.rst:2028 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`." msgstr "" -#: ../../library/ssl.rst:1910 +#: ../../library/ssl.rst:2036 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 " @@ -2686,7 +2832,7 @@ msgid "" "the session cache since the context was created::" msgstr "" -#: ../../library/ssl.rst:1915 +#: ../../library/ssl.rst:2041 msgid "" ">>> stats = context.session_stats()\n" ">>> stats['hits'], stats['misses']\n" @@ -2696,7 +2842,7 @@ msgstr "" ">>> stats['hits'], stats['misses']\n" "(0, 0)" -#: ../../library/ssl.rst:1921 +#: ../../library/ssl.rst:2047 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:" @@ -2709,7 +2855,7 @@ msgid "" "With other protocols, hostname checking must be enabled explicitly." msgstr "" -#: ../../library/ssl.rst:1934 +#: ../../library/ssl.rst:2060 msgid "" "import socket, ssl\n" "\n" @@ -2733,7 +2879,7 @@ msgstr "" "ssl_sock = context.wrap_socket(s, server_hostname='www.verisign.com')\n" "ssl_sock.connect(('www.verisign.com', 443))" -#: ../../library/ssl.rst:1949 +#: ../../library/ssl.rst:2075 msgid "" ":attr:`~SSLContext.verify_mode` is now automatically changed to :data:" "`CERT_REQUIRED` when hostname checking is enabled and :attr:`~SSLContext." @@ -2741,7 +2887,7 @@ msgid "" "failed with a :exc:`ValueError`." msgstr "" -#: ../../library/ssl.rst:1956 +#: ../../library/ssl.rst:2082 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 " @@ -2750,7 +2896,7 @@ msgid "" "synchronized between threads, but not between processes." msgstr "" -#: ../../library/ssl.rst:1966 +#: ../../library/ssl.rst:2092 msgid "" "A :class:`TLSVersion` enum member representing the highest supported TLS " "version. The value defaults to :attr:`TLSVersion.MAXIMUM_SUPPORTED`. The " @@ -2758,7 +2904,7 @@ msgid "" "const:`PROTOCOL_TLS_CLIENT`, and :const:`PROTOCOL_TLS_SERVER`." msgstr "" -#: ../../library/ssl.rst:1971 +#: ../../library/ssl.rst:2097 msgid "" "The attributes :attr:`~SSLContext.maximum_version`, :attr:`~SSLContext." "minimum_version` and :attr:`SSLContext.options` all affect the supported SSL " @@ -2768,38 +2914,38 @@ msgid "" "`TLSVersion.TLSv1_2` will not be able to establish a TLS 1.2 connection." msgstr "" -#: ../../library/ssl.rst:1984 +#: ../../library/ssl.rst:2110 msgid "" "Like :attr:`SSLContext.maximum_version` except it is the lowest supported " "version or :attr:`TLSVersion.MINIMUM_SUPPORTED`." msgstr "" -#: ../../library/ssl.rst:1991 +#: ../../library/ssl.rst:2117 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." msgstr "" -#: ../../library/ssl.rst:1999 +#: ../../library/ssl.rst:2125 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." msgstr "" -#: ../../library/ssl.rst:2003 +#: ../../library/ssl.rst:2129 msgid ":attr:`SSLContext.options` returns :class:`Options` flags:" msgstr ":attr:`SSLContext.options` 會回傳 :class:`Options` 旗標:" -#: ../../library/ssl.rst:2011 +#: ../../library/ssl.rst:2137 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." msgstr "" -#: ../../library/ssl.rst:2017 +#: ../../library/ssl.rst:2143 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 " @@ -2807,13 +2953,13 @@ msgid "" "client certificate at any time after the handshake." msgstr "" -#: ../../library/ssl.rst:2022 +#: ../../library/ssl.rst:2148 msgid "" "When enabled on client-side sockets, the client signals the server that it " "supports post-handshake authentication." msgstr "" -#: ../../library/ssl.rst:2025 +#: ../../library/ssl.rst:2151 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 " @@ -2821,66 +2967,66 @@ msgid "" "verify_client_post_handshake` is called and some I/O is performed." msgstr "" -#: ../../library/ssl.rst:2035 +#: ../../library/ssl.rst:2161 msgid "" "The protocol version chosen when constructing the context. This attribute " "is read-only." msgstr "" -#: ../../library/ssl.rst:2040 +#: ../../library/ssl.rst:2166 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:2048 +#: ../../library/ssl.rst:2174 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:2053 +#: ../../library/ssl.rst:2179 msgid "" "An integer representing the `security level `_ for the context. This attribute is read-" "only." msgstr "" -#: ../../library/ssl.rst:2061 +#: ../../library/ssl.rst:2187 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)." msgstr "" -#: ../../library/ssl.rst:2067 +#: ../../library/ssl.rst:2193 msgid ":attr:`SSLContext.verify_flags` returns :class:`VerifyFlags` flags:" msgstr ":attr:`SSLContext.verify_flags` 會回傳 :class:`VerifyFlags` 旗標:" -#: ../../library/ssl.rst:2075 +#: ../../library/ssl.rst:2201 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`." msgstr "" -#: ../../library/ssl.rst:2079 +#: ../../library/ssl.rst:2205 msgid ":attr:`SSLContext.verify_mode` returns :class:`VerifyMode` enum:" msgstr ":attr:`SSLContext.verify_mode` 會回傳 :class:`VerifyMode` 列舉:" -#: ../../library/ssl.rst:2087 +#: ../../library/ssl.rst:2213 msgid "" "Enables TLS-PSK (pre-shared key) authentication on a client-side connection." msgstr "" -#: ../../library/ssl.rst:2089 ../../library/ssl.rst:2138 +#: ../../library/ssl.rst:2215 ../../library/ssl.rst:2264 msgid "" "In general, certificate based authentication should be preferred over this " "method." msgstr "" -#: ../../library/ssl.rst:2091 +#: ../../library/ssl.rst:2217 msgid "" "The parameter ``callback`` is a callable object with the signature: ``def " "callback(hint: str | None) -> tuple[str | None, bytes]``. The ``hint`` " @@ -2892,27 +3038,27 @@ msgid "" "shared key. Return a zero length PSK to reject the connection." msgstr "" -#: ../../library/ssl.rst:2101 ../../library/ssl.rst:2147 +#: ../../library/ssl.rst:2227 ../../library/ssl.rst:2273 msgid "Setting ``callback`` to :const:`None` removes any existing callback." msgstr "" -#: ../../library/ssl.rst:2104 +#: ../../library/ssl.rst:2230 msgid "When using TLS 1.3:" msgstr "使用 TLS 1.3 時:" -#: ../../library/ssl.rst:2106 +#: ../../library/ssl.rst:2232 msgid "the ``hint`` parameter is always :const:`None`." msgstr "``hint`` 參數始終為 :const:`None`。" -#: ../../library/ssl.rst:2107 +#: ../../library/ssl.rst:2233 msgid "client-identity must be a non-empty string." msgstr "" -#: ../../library/ssl.rst:2109 ../../library/ssl.rst:2156 +#: ../../library/ssl.rst:2235 ../../library/ssl.rst:2282 msgid "Example usage::" msgstr "範例用法: ::" -#: ../../library/ssl.rst:2111 +#: ../../library/ssl.rst:2237 msgid "" "context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n" "context.check_hostname = False\n" @@ -2933,18 +3079,18 @@ msgid "" "context.set_psk_client_callback(callback)" msgstr "" -#: ../../library/ssl.rst:2129 ../../library/ssl.rst:2174 +#: ../../library/ssl.rst:2255 ../../library/ssl.rst:2300 msgid "" "This method will raise :exc:`NotImplementedError` if :data:`HAS_PSK` is " "``False``." msgstr "" -#: ../../library/ssl.rst:2136 +#: ../../library/ssl.rst:2262 msgid "" "Enables TLS-PSK (pre-shared key) authentication on a server-side connection." msgstr "" -#: ../../library/ssl.rst:2140 +#: ../../library/ssl.rst:2266 msgid "" "The parameter ``callback`` is a callable object with the signature: ``def " "callback(identity: str | None) -> bytes``. The ``identity`` parameter is an " @@ -2954,19 +3100,19 @@ msgid "" "connection." msgstr "" -#: ../../library/ssl.rst:2149 +#: ../../library/ssl.rst:2275 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:2154 +#: ../../library/ssl.rst:2280 msgid "" "When using TLS 1.3 the ``identity_hint`` parameter is not sent to the client." msgstr "" -#: ../../library/ssl.rst:2158 +#: ../../library/ssl.rst:2284 msgid "" "context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)\n" "context.maximum_version = ssl.TLSVersion.TLSv1_2\n" @@ -2985,11 +3131,11 @@ msgid "" "context.set_psk_server_callback(callback, 'ServerId_1')" msgstr "" -#: ../../library/ssl.rst:2186 +#: ../../library/ssl.rst:2312 msgid "Certificates" msgstr "" -#: ../../library/ssl.rst:2188 +#: ../../library/ssl.rst:2314 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 " @@ -3000,7 +3146,7 @@ msgid "" "other part, and **only** with the other part." msgstr "" -#: ../../library/ssl.rst:2196 +#: ../../library/ssl.rst:2322 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 " @@ -3014,7 +3160,7 @@ msgid "" "as two fields, called \"notBefore\" and \"notAfter\"." msgstr "" -#: ../../library/ssl.rst:2206 +#: ../../library/ssl.rst:2332 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 " @@ -3027,14 +3173,14 @@ msgid "" "take place." msgstr "" -#: ../../library/ssl.rst:2216 +#: ../../library/ssl.rst:2342 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:2220 +#: ../../library/ssl.rst:2346 msgid "" "-----BEGIN CERTIFICATE-----\n" "... (certificate in base64 PEM encoding) ...\n" @@ -3044,11 +3190,11 @@ msgstr "" "... (certificate in base64 PEM encoding) ...\n" "-----END CERTIFICATE-----" -#: ../../library/ssl.rst:2225 +#: ../../library/ssl.rst:2351 msgid "Certificate chains" msgstr "" -#: ../../library/ssl.rst:2227 +#: ../../library/ssl.rst:2353 msgid "" "The Python files which contain certificates can contain a sequence of " "certificates, sometimes called a *certificate chain*. This chain should " @@ -3064,7 +3210,7 @@ msgid "" "agency which issued the certification authority's certificate::" msgstr "" -#: ../../library/ssl.rst:2240 +#: ../../library/ssl.rst:2366 msgid "" "-----BEGIN CERTIFICATE-----\n" "... (certificate for your server)...\n" @@ -3086,11 +3232,11 @@ msgstr "" "... (the root certificate for the CA's issuer)...\n" "-----END CERTIFICATE-----" -#: ../../library/ssl.rst:2251 +#: ../../library/ssl.rst:2377 msgid "CA certificates" msgstr "" -#: ../../library/ssl.rst:2253 +#: ../../library/ssl.rst:2379 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 " @@ -3102,11 +3248,11 @@ msgid "" "create_default_context`." msgstr "" -#: ../../library/ssl.rst:2262 +#: ../../library/ssl.rst:2388 msgid "Combined key and certificate" msgstr "" -#: ../../library/ssl.rst:2264 +#: ../../library/ssl.rst:2390 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` " @@ -3114,7 +3260,7 @@ msgid "" "should come before the first certificate in the certificate chain::" msgstr "" -#: ../../library/ssl.rst:2270 +#: ../../library/ssl.rst:2396 msgid "" "-----BEGIN RSA PRIVATE KEY-----\n" "... (private key in base64 encoding) ...\n" @@ -3130,11 +3276,11 @@ msgstr "" "... (certificate in base64 PEM encoding) ...\n" "-----END CERTIFICATE-----" -#: ../../library/ssl.rst:2278 +#: ../../library/ssl.rst:2404 msgid "Self-signed certificates" msgstr "" -#: ../../library/ssl.rst:2280 +#: ../../library/ssl.rst:2406 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 " @@ -3144,7 +3290,7 @@ msgid "" "package, using something like the following::" msgstr "" -#: ../../library/ssl.rst:2287 +#: ../../library/ssl.rst:2413 msgid "" "% openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem\n" "Generating a 1024 bit RSA private key\n" @@ -3170,28 +3316,28 @@ msgid "" "%" msgstr "" -#: ../../library/ssl.rst:2309 +#: ../../library/ssl.rst:2435 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:2315 +#: ../../library/ssl.rst:2441 msgid "Examples" msgstr "範例" -#: ../../library/ssl.rst:2318 +#: ../../library/ssl.rst:2444 msgid "Testing for SSL support" msgstr "" -#: ../../library/ssl.rst:2320 +#: ../../library/ssl.rst:2446 msgid "" "To test for the presence of SSL support in a Python installation, user code " "should use the following idiom::" msgstr "" -#: ../../library/ssl.rst:2323 +#: ../../library/ssl.rst:2449 msgid "" "try:\n" " import ssl\n" @@ -3201,27 +3347,27 @@ msgid "" " ... # do something that requires SSL support" msgstr "" -#: ../../library/ssl.rst:2331 +#: ../../library/ssl.rst:2457 msgid "Client-side operation" msgstr "" -#: ../../library/ssl.rst:2333 +#: ../../library/ssl.rst:2459 msgid "" "This example creates a SSL context with the recommended security settings " "for client sockets, including automatic certificate verification::" msgstr "" -#: ../../library/ssl.rst:2336 +#: ../../library/ssl.rst:2462 msgid ">>> context = ssl.create_default_context()" msgstr ">>> context = ssl.create_default_context()" -#: ../../library/ssl.rst:2338 +#: ../../library/ssl.rst:2464 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:2342 +#: ../../library/ssl.rst:2468 msgid "" ">>> context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n" ">>> context.load_verify_locations(\"/etc/ssl/certs/ca-bundle.crt\")" @@ -3229,14 +3375,14 @@ msgstr "" ">>> context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n" ">>> context.load_verify_locations(\"/etc/ssl/certs/ca-bundle.crt\")" -#: ../../library/ssl.rst:2345 +#: ../../library/ssl.rst:2471 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:2349 +#: ../../library/ssl.rst:2475 msgid "" "The :data:`PROTOCOL_TLS_CLIENT` protocol configures the context for cert " "validation and hostname verification. :attr:`~SSLContext.verify_mode` is set " @@ -3244,7 +3390,7 @@ msgid "" "``True``. All other protocols create SSL contexts with insecure defaults." msgstr "" -#: ../../library/ssl.rst:2354 +#: ../../library/ssl.rst:2480 msgid "" "When you use the context to connect to a server, :const:`CERT_REQUIRED` and :" "attr:`~SSLContext.check_hostname` validate the server certificate: it " @@ -3253,7 +3399,7 @@ msgid "" "properties like validity and identity of the hostname::" msgstr "" -#: ../../library/ssl.rst:2360 +#: ../../library/ssl.rst:2486 msgid "" ">>> conn = context.wrap_socket(socket.socket(socket.AF_INET),\n" "... server_hostname=\"www.python.org\")\n" @@ -3263,21 +3409,21 @@ msgstr "" "... server_hostname=\"www.python.org\")\n" ">>> conn.connect((\"www.python.org\", 443))" -#: ../../library/ssl.rst:2364 +#: ../../library/ssl.rst:2490 msgid "You may then fetch the certificate::" msgstr "" -#: ../../library/ssl.rst:2366 +#: ../../library/ssl.rst:2492 msgid ">>> cert = conn.getpeercert()" msgstr ">>> cert = conn.getpeercert()" -#: ../../library/ssl.rst:2368 +#: ../../library/ssl.rst:2494 msgid "" "Visual inspection shows that the certificate does identify the desired " "service (that is, the HTTPS host ``www.python.org``)::" msgstr "" -#: ../../library/ssl.rst:2371 +#: ../../library/ssl.rst:2497 msgid "" ">>> pprint.pprint(cert)\n" "{'OCSP': ('http://ocsp.digicert.com',),\n" @@ -3367,13 +3513,13 @@ msgstr "" " ('DNS', 'id.python.org')),\n" " 'version': 3}" -#: ../../library/ssl.rst:2411 +#: ../../library/ssl.rst:2537 msgid "" "Now the SSL channel is established and the certificate verified, you can " "proceed to talk with the server::" msgstr "" -#: ../../library/ssl.rst:2414 +#: ../../library/ssl.rst:2540 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" @@ -3415,11 +3561,11 @@ msgstr "" " b'',\n" " b'']" -#: ../../library/ssl.rst:2438 +#: ../../library/ssl.rst:2564 msgid "Server-side operation" msgstr "伺服器端操作" -#: ../../library/ssl.rst:2440 +#: ../../library/ssl.rst:2566 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 " @@ -3428,7 +3574,7 @@ msgid "" "start waiting for clients to connect::" msgstr "" -#: ../../library/ssl.rst:2446 +#: ../../library/ssl.rst:2572 msgid "" "import socket, ssl\n" "\n" @@ -3448,14 +3594,14 @@ msgstr "" "bindsocket.bind(('myaddr.example.com', 10023))\n" "bindsocket.listen(5)" -#: ../../library/ssl.rst:2455 +#: ../../library/ssl.rst:2581 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::" msgstr "" -#: ../../library/ssl.rst:2459 +#: ../../library/ssl.rst:2585 msgid "" "while True:\n" " newsocket, fromaddr = bindsocket.accept()\n" @@ -3475,13 +3621,13 @@ msgstr "" " connstream.shutdown(socket.SHUT_RDWR)\n" " connstream.close()" -#: ../../library/ssl.rst:2468 +#: ../../library/ssl.rst:2594 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:2471 +#: ../../library/ssl.rst:2597 msgid "" "def deal_with_client(connstream):\n" " data = connstream.recv(1024)\n" @@ -3495,7 +3641,7 @@ msgid "" " # finished with client" msgstr "" -#: ../../library/ssl.rst:2482 +#: ../../library/ssl.rst:2608 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 " @@ -3503,18 +3649,18 @@ msgid "" "event loop)." msgstr "" -#: ../../library/ssl.rst:2490 +#: ../../library/ssl.rst:2616 msgid "Notes on non-blocking sockets" msgstr "" -#: ../../library/ssl.rst:2492 +#: ../../library/ssl.rst:2618 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:2496 +#: ../../library/ssl.rst:2622 msgid "" "Most :class:`SSLSocket` methods will raise either :exc:`SSLWantWriteError` " "or :exc:`SSLWantReadError` instead of :exc:`BlockingIOError` if an I/O " @@ -3526,13 +3672,13 @@ msgid "" "require a prior *write* to the underlying socket." msgstr "" -#: ../../library/ssl.rst:2508 +#: ../../library/ssl.rst:2634 msgid "" "In earlier Python versions, the :meth:`!SSLSocket.send` method returned zero " "instead of raising :exc:`SSLWantWriteError` or :exc:`SSLWantReadError`." msgstr "" -#: ../../library/ssl.rst:2512 +#: ../../library/ssl.rst:2638 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 " @@ -3542,7 +3688,7 @@ msgid "" "`~select.select`." msgstr "" -#: ../../library/ssl.rst:2519 +#: ../../library/ssl.rst:2645 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 " @@ -3551,13 +3697,13 @@ msgid "" "call if still necessary." msgstr "" -#: ../../library/ssl.rst:2525 +#: ../../library/ssl.rst:2651 msgid "" "(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:2528 +#: ../../library/ssl.rst:2654 msgid "" "The SSL handshake itself will be non-blocking: the :meth:`SSLSocket." "do_handshake` method has to be retried until it returns successfully. Here " @@ -3565,7 +3711,7 @@ msgid "" "readiness::" msgstr "" -#: ../../library/ssl.rst:2533 +#: ../../library/ssl.rst:2659 msgid "" "while True:\n" " try:\n" @@ -3585,7 +3731,7 @@ msgstr "" " except ssl.SSLWantWriteError:\n" " select.select([], [sock], [])" -#: ../../library/ssl.rst:2544 +#: ../../library/ssl.rst:2670 msgid "" "The :mod:`asyncio` module supports :ref:`non-blocking SSL sockets ` and provides a higher level :ref:`Streams API `. " "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:2647 +#: ../../library/ssl.rst:2773 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." msgstr "" -#: ../../library/ssl.rst:2653 +#: ../../library/ssl.rst:2779 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:2659 +#: ../../library/ssl.rst:2785 msgid "" "A memory buffer that can be used to pass data between Python and an SSL " "protocol instance." msgstr "" -#: ../../library/ssl.rst:2664 +#: ../../library/ssl.rst:2790 msgid "Return the number of bytes currently in the memory buffer." msgstr "" -#: ../../library/ssl.rst:2668 +#: ../../library/ssl.rst:2794 msgid "" "A boolean indicating whether the memory BIO is current at the end-of-file " "position." msgstr "" -#: ../../library/ssl.rst:2673 +#: ../../library/ssl.rst:2799 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:2678 +#: ../../library/ssl.rst:2804 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:2681 +#: ../../library/ssl.rst:2807 msgid "" "The return value is the number of bytes written, which is always equal to " "the length of *buf*." msgstr "" -#: ../../library/ssl.rst:2686 +#: ../../library/ssl.rst:2812 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:2692 +#: ../../library/ssl.rst:2818 msgid "SSL session" msgstr "" -#: ../../library/ssl.rst:2698 +#: ../../library/ssl.rst:2824 msgid "Session object used by :attr:`~SSLSocket.session`." msgstr "" -#: ../../library/ssl.rst:2710 +#: ../../library/ssl.rst:2836 msgid "Security considerations" msgstr "" -#: ../../library/ssl.rst:2713 +#: ../../library/ssl.rst:2839 msgid "Best defaults" msgstr "" -#: ../../library/ssl.rst:2715 +#: ../../library/ssl.rst:2841 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:" @@ -3877,13 +4023,13 @@ msgid "" "settings." msgstr "" -#: ../../library/ssl.rst:2722 +#: ../../library/ssl.rst:2848 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:2725 +#: ../../library/ssl.rst:2851 msgid "" ">>> import ssl, smtplib\n" ">>> smtp = smtplib.SMTP(\"mail.python.org\", port=587)\n" @@ -3897,13 +4043,13 @@ msgstr "" ">>> smtp.starttls(context=context)\n" "(220, b'2.0.0 Ready to start TLS')" -#: ../../library/ssl.rst:2731 +#: ../../library/ssl.rst:2857 msgid "" "If a client certificate is needed for the connection, it can be added with :" "meth:`SSLContext.load_cert_chain`." msgstr "" -#: ../../library/ssl.rst:2734 +#: ../../library/ssl.rst:2860 msgid "" "By contrast, if you create the SSL context by calling the :class:" "`SSLContext` constructor yourself, it will not have certificate validation " @@ -3911,15 +4057,15 @@ msgid "" "paragraphs below to achieve a good security level." msgstr "" -#: ../../library/ssl.rst:2740 +#: ../../library/ssl.rst:2866 msgid "Manual settings" msgstr "手動設定" -#: ../../library/ssl.rst:2743 +#: ../../library/ssl.rst:2869 msgid "Verifying certificates" msgstr "驗證憑證" -#: ../../library/ssl.rst:2745 +#: ../../library/ssl.rst:2871 msgid "" "When calling the :class:`SSLContext` constructor directly, :const:" "`CERT_NONE` is the default. Since it does not authenticate the other peer, " @@ -3934,13 +4080,13 @@ msgid "" "enabled." msgstr "" -#: ../../library/ssl.rst:2757 +#: ../../library/ssl.rst:2883 msgid "" "Hostname matchings is now performed by OpenSSL. Python no longer uses :func:" "`!match_hostname`." msgstr "" -#: ../../library/ssl.rst:2761 +#: ../../library/ssl.rst:2887 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 " @@ -3948,11 +4094,11 @@ msgid "" "certificate." msgstr "" -#: ../../library/ssl.rst:2767 +#: ../../library/ssl.rst:2893 msgid "Protocol versions" msgstr "協定版本" -#: ../../library/ssl.rst:2769 +#: ../../library/ssl.rst:2895 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 " @@ -3961,7 +4107,7 @@ msgid "" "by default." msgstr "" -#: ../../library/ssl.rst:2777 +#: ../../library/ssl.rst:2903 msgid "" ">>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n" ">>> client_context.minimum_version = ssl.TLSVersion.TLSv1_2\n" @@ -3971,7 +4117,7 @@ msgstr "" ">>> client_context.minimum_version = ssl.TLSVersion.TLSv1_2\n" ">>> client_context.maximum_version = ssl.TLSVersion.TLSv1_3" -#: ../../library/ssl.rst:2782 +#: ../../library/ssl.rst:2908 msgid "" "The SSL client context created above will only allow TLSv1.2 and TLSv1.3 (if " "supported by your system) connections to a server. :const:" @@ -3979,11 +4125,11 @@ msgid "" "default. You have to load certificates into the context." msgstr "" -#: ../../library/ssl.rst:2789 +#: ../../library/ssl.rst:2915 msgid "Cipher selection" msgstr "" -#: ../../library/ssl.rst:2791 +#: ../../library/ssl.rst:2917 msgid "" "If you have advanced security requirements, fine-tuning of the ciphers " "enabled when negotiating a SSL session is possible through the :meth:" @@ -3996,11 +4142,11 @@ msgid "" "command on your system." msgstr "" -#: ../../library/ssl.rst:2802 +#: ../../library/ssl.rst:2928 msgid "Multi-processing" msgstr "" -#: ../../library/ssl.rst:2804 +#: ../../library/ssl.rst:2930 msgid "" "If using this module as part of a multi-processed application (using, for " "example the :mod:`multiprocessing` or :mod:`concurrent.futures` modules), be " @@ -4011,32 +4157,37 @@ msgid "" "sufficient." msgstr "" -#: ../../library/ssl.rst:2816 +#: ../../library/ssl.rst:2942 msgid "TLS 1.3" msgstr "TLS 1.3" -#: ../../library/ssl.rst:2820 +#: ../../library/ssl.rst:2946 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:2823 +#: ../../library/ssl.rst:2949 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." +"TLS 1.3 uses a disjunct set of cipher suites. All AES-GCM and ChaCha20 " +"cipher suites are enabled by default. To restrict which TLS 1.3 ciphers are " +"allowed, the :meth:`SSLContext.set_ciphersuites` method should be called " +"instead of :meth:`SSLContext.set_ciphers`, which only affects ciphers in " +"older TLS versions. The :meth:`SSLContext.get_ciphers` method returns " +"information about ciphers for both TLS 1.3 and earlier versions and the " +"method :meth:`SSLSocket.cipher` returns information about the negotiated " +"cipher for both TLS 1.3 and earlier versions once a connection is " +"established." msgstr "" -#: ../../library/ssl.rst:2827 +#: ../../library/ssl.rst:2958 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:2830 +#: ../../library/ssl.rst:2961 msgid "" "Client-side certificates are also no longer verified during the initial " "handshake. A server can request a certificate at any time. Clients process " @@ -4044,21 +4195,21 @@ msgid "" "server." msgstr "" -#: ../../library/ssl.rst:2834 +#: ../../library/ssl.rst:2965 msgid "" -"TLS 1.3 features like early data, deferred TLS client cert request, " -"signature algorithm configuration, and rekeying are not supported yet." +"TLS 1.3 features like early data, deferred TLS client cert request, and " +"rekeying are not supported yet." msgstr "" -#: ../../library/ssl.rst:2840 +#: ../../library/ssl.rst:2971 msgid "Class :class:`socket.socket`" msgstr ":class:`socket.socket` 類別" -#: ../../library/ssl.rst:2841 +#: ../../library/ssl.rst:2972 msgid "Documentation of underlying :mod:`socket` class" msgstr "底層 :mod:`socket` 類別的文件" -#: ../../library/ssl.rst:2843 +#: ../../library/ssl.rst:2974 msgid "" "`SSL/TLS Strong Encryption: An Introduction `_" @@ -4066,11 +4217,11 @@ msgstr "" "`SSL/TLS Strong Encryption: An Introduction `_" -#: ../../library/ssl.rst:2844 +#: ../../library/ssl.rst:2975 msgid "Intro from the Apache HTTP Server documentation" msgstr "Apache HTTP Server 文件的介紹" -#: ../../library/ssl.rst:2846 +#: ../../library/ssl.rst:2977 msgid "" ":rfc:`RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: " "Certificate-Based Key Management <1422>`" @@ -4078,19 +4229,19 @@ msgstr "" ":rfc:`RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: " "Certificate-Based Key Management <1422>`" -#: ../../library/ssl.rst:2847 +#: ../../library/ssl.rst:2978 msgid "Steve Kent" msgstr "Steve Kent" -#: ../../library/ssl.rst:2849 +#: ../../library/ssl.rst:2980 msgid ":rfc:`RFC 4086: Randomness Requirements for Security <4086>`" msgstr ":rfc:`RFC 4086: Randomness Requirements for Security <4086>`" -#: ../../library/ssl.rst:2850 +#: ../../library/ssl.rst:2981 msgid "Donald E. Eastlake, Jeffrey I. Schiller, Steve Crocker" msgstr "Donald E. Eastlake, Jeffrey I. Schiller, Steve Crocker" -#: ../../library/ssl.rst:2852 +#: ../../library/ssl.rst:2983 msgid "" ":rfc:`RFC 5280: Internet X.509 Public Key Infrastructure Certificate and " "Certificate Revocation List (CRL) Profile <5280>`" @@ -4098,11 +4249,11 @@ msgstr "" ":rfc:`RFC 5280: Internet X.509 Public Key Infrastructure Certificate and " "Certificate Revocation List (CRL) Profile <5280>`" -#: ../../library/ssl.rst:2853 +#: ../../library/ssl.rst:2984 msgid "David Cooper et al." msgstr "David Cooper et al." -#: ../../library/ssl.rst:2855 +#: ../../library/ssl.rst:2986 msgid "" ":rfc:`RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 " "<5246>`" @@ -4110,19 +4261,19 @@ msgstr "" ":rfc:`RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 " "<5246>`" -#: ../../library/ssl.rst:2856 +#: ../../library/ssl.rst:2987 msgid "Tim Dierks and Eric Rescorla." msgstr "Tim Dierks 與 Eric Rescorla." -#: ../../library/ssl.rst:2858 +#: ../../library/ssl.rst:2989 msgid ":rfc:`RFC 6066: Transport Layer Security (TLS) Extensions <6066>`" msgstr ":rfc:`RFC 6066: Transport Layer Security (TLS) Extensions <6066>`" -#: ../../library/ssl.rst:2859 +#: ../../library/ssl.rst:2990 msgid "Donald E. Eastlake" msgstr "Donald E. Eastlake" -#: ../../library/ssl.rst:2861 +#: ../../library/ssl.rst:2992 msgid "" "`IANA TLS: Transport Layer Security (TLS) Parameters `_" @@ -4130,11 +4281,11 @@ msgstr "" "`IANA TLS: Transport Layer Security (TLS) Parameters `_" -#: ../../library/ssl.rst:2862 +#: ../../library/ssl.rst:2993 msgid "IANA" msgstr "IANA" -#: ../../library/ssl.rst:2864 +#: ../../library/ssl.rst:2995 msgid "" ":rfc:`RFC 7525: Recommendations for Secure Use of Transport Layer Security " "(TLS) and Datagram Transport Layer Security (DTLS) <7525>`" @@ -4142,11 +4293,11 @@ msgstr "" ":rfc:`RFC 7525: Recommendations for Secure Use of Transport Layer Security " "(TLS) and Datagram Transport Layer Security (DTLS) <7525>`" -#: ../../library/ssl.rst:2865 +#: ../../library/ssl.rst:2996 msgid "IETF" msgstr "IETF" -#: ../../library/ssl.rst:2867 +#: ../../library/ssl.rst:2998 msgid "" "`Mozilla's Server Side TLS recommendations `_" @@ -4154,38 +4305,38 @@ msgstr "" "`Mozilla's Server Side TLS recommendations `_" -#: ../../library/ssl.rst:2868 +#: ../../library/ssl.rst:2999 msgid "Mozilla" msgstr "Mozilla" -#: ../../library/ssl.rst:12 +#: ../../library/ssl.rst:9 msgid "OpenSSL" msgstr "OpenSSL" -#: ../../library/ssl.rst:12 +#: ../../library/ssl.rst:9 msgid "(use in module ssl)" msgstr "(用於 ssl 模組)" -#: ../../library/ssl.rst:14 +#: ../../library/ssl.rst:11 msgid "TLS" msgstr "TLS" -#: ../../library/ssl.rst:14 +#: ../../library/ssl.rst:11 msgid "SSL" msgstr "SSL" -#: ../../library/ssl.rst:14 +#: ../../library/ssl.rst:11 msgid "Transport Layer Security" msgstr "Transport Layer Security(傳輸層安全)" -#: ../../library/ssl.rst:14 +#: ../../library/ssl.rst:11 msgid "Secure Sockets Layer" msgstr "Secure Sockets Layer(安全 socket 層)" -#: ../../library/ssl.rst:2179 +#: ../../library/ssl.rst:2305 msgid "certificates" msgstr "certificates(憑證)" -#: ../../library/ssl.rst:2181 +#: ../../library/ssl.rst:2307 msgid "X509 certificate" msgstr "X509 certificate(X509 憑證)" diff --git a/library/stat.po b/library/stat.po index 82c29d751e9..5a62c820a03 100644 --- a/library/stat.po +++ b/library/stat.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2016-11-19 00:34+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!stat` --- Interpreting :func:`~os.stat` results" msgstr ":mod:`!stat` --- 直譯 :func:`~os.stat` 的結果" -#: ../../library/stat.rst:10 +#: ../../library/stat.rst:8 msgid "**Source code:** :source:`Lib/stat.py`" msgstr "**原始碼:**\\ :source:`Lib/stat.py`" -#: ../../library/stat.rst:14 +#: ../../library/stat.rst:12 msgid "" "The :mod:`!stat` module defines constants and functions for interpreting the " "results of :func:`os.stat`, :func:`os.fstat` and :func:`os.lstat` (if they " @@ -33,76 +33,76 @@ msgid "" "and :c:func:`!lstat` calls, consult the documentation for your system." msgstr "" -#: ../../library/stat.rst:19 +#: ../../library/stat.rst:17 msgid "The stat module is backed by a C implementation." msgstr "" -#: ../../library/stat.rst:22 +#: ../../library/stat.rst:20 msgid "" "The :mod:`!stat` module defines the following functions to test for specific " "file types:" msgstr ":mod:`!stat` 模組定義了以下函式,用於測試特定檔案類型:" -#: ../../library/stat.rst:28 +#: ../../library/stat.rst:26 msgid "Return non-zero if the mode is from a directory." msgstr "" -#: ../../library/stat.rst:33 +#: ../../library/stat.rst:31 msgid "Return non-zero if the mode is from a character special device file." msgstr "" -#: ../../library/stat.rst:38 +#: ../../library/stat.rst:36 msgid "Return non-zero if the mode is from a block special device file." msgstr "" -#: ../../library/stat.rst:43 +#: ../../library/stat.rst:41 msgid "Return non-zero if the mode is from a regular file." msgstr "" -#: ../../library/stat.rst:48 +#: ../../library/stat.rst:46 msgid "Return non-zero if the mode is from a FIFO (named pipe)." msgstr "" -#: ../../library/stat.rst:53 +#: ../../library/stat.rst:51 msgid "Return non-zero if the mode is from a symbolic link." msgstr "" -#: ../../library/stat.rst:58 +#: ../../library/stat.rst:56 msgid "Return non-zero if the mode is from a socket." msgstr "" -#: ../../library/stat.rst:62 +#: ../../library/stat.rst:60 msgid "Return non-zero if the mode is from a door." msgstr "" -#: ../../library/stat.rst:68 +#: ../../library/stat.rst:66 msgid "Return non-zero if the mode is from an event port." msgstr "" -#: ../../library/stat.rst:74 +#: ../../library/stat.rst:72 msgid "Return non-zero if the mode is from a whiteout." msgstr "" -#: ../../library/stat.rst:78 +#: ../../library/stat.rst:76 msgid "" "Two additional functions are defined for more general manipulation of the " "file's mode:" msgstr "" -#: ../../library/stat.rst:84 +#: ../../library/stat.rst:82 msgid "" "Return the portion of the file's mode that can be set by :func:`os.chmod`\\ " "---that is, the file's permission bits, plus the sticky bit, set-group-id, " "and set-user-id bits (on systems that support them)." msgstr "" -#: ../../library/stat.rst:91 +#: ../../library/stat.rst:89 msgid "" "Return the portion of the file's mode that describes the file type (used by " "the :func:`!S_IS\\*` functions above)." msgstr "" -#: ../../library/stat.rst:94 +#: ../../library/stat.rst:92 msgid "" "Normally, you would use the :func:`!os.path.is\\*` functions for testing the " "type of a file; the functions here are useful when you are doing multiple " @@ -112,11 +112,11 @@ msgid "" "tests for block and character devices." msgstr "" -#: ../../library/stat.rst:101 +#: ../../library/stat.rst:99 msgid "Example::" msgstr "範例: ::" -#: ../../library/stat.rst:103 +#: ../../library/stat.rst:101 msgid "" "import os, sys\n" "from stat import *\n" @@ -145,72 +145,72 @@ msgid "" " walktree(sys.argv[1], visitfile)" msgstr "" -#: ../../library/stat.rst:129 +#: ../../library/stat.rst:127 msgid "" "An additional utility function is provided to convert a file's mode in a " "human readable string:" msgstr "" -#: ../../library/stat.rst:134 +#: ../../library/stat.rst:132 msgid "Convert a file's mode to a string of the form '-rwxrwxrwx'." msgstr "" -#: ../../library/stat.rst:138 +#: ../../library/stat.rst:136 msgid "" "The function supports :data:`S_IFDOOR`, :data:`S_IFPORT` and :data:`S_IFWHT`." msgstr "" -#: ../../library/stat.rst:143 +#: ../../library/stat.rst:141 msgid "" "All the variables below are simply symbolic indexes into the 10-tuple " "returned by :func:`os.stat`, :func:`os.fstat` or :func:`os.lstat`." msgstr "" -#: ../../library/stat.rst:149 +#: ../../library/stat.rst:147 msgid "Inode protection mode." msgstr "" -#: ../../library/stat.rst:154 +#: ../../library/stat.rst:152 msgid "Inode number." msgstr "" -#: ../../library/stat.rst:159 +#: ../../library/stat.rst:157 msgid "Device inode resides on." msgstr "" -#: ../../library/stat.rst:164 +#: ../../library/stat.rst:162 msgid "Number of links to the inode." msgstr "" -#: ../../library/stat.rst:169 +#: ../../library/stat.rst:167 msgid "User id of the owner." msgstr "" -#: ../../library/stat.rst:174 +#: ../../library/stat.rst:172 msgid "Group id of the owner." msgstr "" -#: ../../library/stat.rst:179 +#: ../../library/stat.rst:177 msgid "" "Size in bytes of a plain file; amount of data waiting on some special files." msgstr "" -#: ../../library/stat.rst:184 +#: ../../library/stat.rst:182 msgid "Time of last access." msgstr "" -#: ../../library/stat.rst:189 +#: ../../library/stat.rst:187 msgid "Time of last modification." msgstr "" -#: ../../library/stat.rst:194 +#: ../../library/stat.rst:192 msgid "" "The \"ctime\" as reported by the operating system. On some systems (like " "Unix) is the time of the last metadata change, and, on others (like " "Windows), is the creation time (see platform documentation for details)." msgstr "" -#: ../../library/stat.rst:198 +#: ../../library/stat.rst:196 msgid "" "The interpretation of \"file size\" changes according to the file type. For " "plain files this is the size of the file in bytes. For FIFOs and sockets " @@ -222,73 +222,73 @@ msgid "" "varies more, depending on the implementation of the underlying system call." msgstr "" -#: ../../library/stat.rst:207 +#: ../../library/stat.rst:205 msgid "The variables below define the flags used in the :data:`ST_MODE` field." msgstr "" -#: ../../library/stat.rst:209 +#: ../../library/stat.rst:207 msgid "" "Use of the functions above is more portable than use of the first set of " "flags:" msgstr "" -#: ../../library/stat.rst:213 +#: ../../library/stat.rst:211 msgid "Socket." msgstr "" -#: ../../library/stat.rst:217 +#: ../../library/stat.rst:215 msgid "Symbolic link." msgstr "" -#: ../../library/stat.rst:221 +#: ../../library/stat.rst:219 msgid "Regular file." msgstr "" -#: ../../library/stat.rst:225 +#: ../../library/stat.rst:223 msgid "Block device." msgstr "" -#: ../../library/stat.rst:229 +#: ../../library/stat.rst:227 msgid "Directory." msgstr "" -#: ../../library/stat.rst:233 +#: ../../library/stat.rst:231 msgid "Character device." msgstr "" -#: ../../library/stat.rst:237 +#: ../../library/stat.rst:235 msgid "FIFO." msgstr "" -#: ../../library/stat.rst:241 +#: ../../library/stat.rst:239 msgid "Door." msgstr "" -#: ../../library/stat.rst:247 +#: ../../library/stat.rst:245 msgid "Event port." msgstr "" -#: ../../library/stat.rst:253 +#: ../../library/stat.rst:251 msgid "Whiteout." msgstr "" -#: ../../library/stat.rst:259 +#: ../../library/stat.rst:257 msgid "" ":data:`S_IFDOOR`, :data:`S_IFPORT` or :data:`S_IFWHT` are defined as 0 when " "the platform does not have support for the file types." msgstr "" -#: ../../library/stat.rst:262 +#: ../../library/stat.rst:260 msgid "" "The following flags can also be used in the *mode* argument of :func:`os." "chmod`:" msgstr "" -#: ../../library/stat.rst:266 +#: ../../library/stat.rst:264 msgid "Set UID bit." msgstr "" -#: ../../library/stat.rst:270 +#: ../../library/stat.rst:268 msgid "" "Set-group-ID bit. This bit has several special uses. For a directory it " "indicates that BSD semantics is to be used for that directory: files created " @@ -299,169 +299,169 @@ msgid "" "mandatory file/record locking (see also :data:`S_ENFMT`)." msgstr "" -#: ../../library/stat.rst:281 +#: ../../library/stat.rst:279 msgid "" "Sticky bit. When this bit is set on a directory it means that a file in " "that directory can be renamed or deleted only by the owner of the file, by " "the owner of the directory, or by a privileged process." msgstr "" -#: ../../library/stat.rst:287 +#: ../../library/stat.rst:285 msgid "Mask for file owner permissions." msgstr "" -#: ../../library/stat.rst:291 +#: ../../library/stat.rst:289 msgid "Owner has read permission." msgstr "" -#: ../../library/stat.rst:295 +#: ../../library/stat.rst:293 msgid "Owner has write permission." msgstr "" -#: ../../library/stat.rst:299 +#: ../../library/stat.rst:297 msgid "Owner has execute permission." msgstr "" -#: ../../library/stat.rst:303 +#: ../../library/stat.rst:301 msgid "Mask for group permissions." msgstr "" -#: ../../library/stat.rst:307 +#: ../../library/stat.rst:305 msgid "Group has read permission." msgstr "" -#: ../../library/stat.rst:311 +#: ../../library/stat.rst:309 msgid "Group has write permission." msgstr "" -#: ../../library/stat.rst:315 +#: ../../library/stat.rst:313 msgid "Group has execute permission." msgstr "" -#: ../../library/stat.rst:319 +#: ../../library/stat.rst:317 msgid "Mask for permissions for others (not in group)." msgstr "" -#: ../../library/stat.rst:323 +#: ../../library/stat.rst:321 msgid "Others have read permission." msgstr "" -#: ../../library/stat.rst:327 +#: ../../library/stat.rst:325 msgid "Others have write permission." msgstr "" -#: ../../library/stat.rst:331 +#: ../../library/stat.rst:329 msgid "Others have execute permission." msgstr "" -#: ../../library/stat.rst:335 +#: ../../library/stat.rst:333 msgid "" "System V file locking enforcement. This flag is shared with :data:" "`S_ISGID`: file/record locking is enforced on files that do not have the " "group execution bit (:data:`S_IXGRP`) set." msgstr "" -#: ../../library/stat.rst:341 +#: ../../library/stat.rst:339 msgid "Unix V7 synonym for :data:`S_IRUSR`." msgstr "" -#: ../../library/stat.rst:345 +#: ../../library/stat.rst:343 msgid "Unix V7 synonym for :data:`S_IWUSR`." msgstr "" -#: ../../library/stat.rst:349 +#: ../../library/stat.rst:347 msgid "Unix V7 synonym for :data:`S_IXUSR`." msgstr "" -#: ../../library/stat.rst:351 +#: ../../library/stat.rst:349 msgid "" "The following flags can be used in the *flags* argument of :func:`os." "chflags`:" msgstr "" -#: ../../library/stat.rst:355 +#: ../../library/stat.rst:353 msgid "All user settable flags." msgstr "" -#: ../../library/stat.rst:361 +#: ../../library/stat.rst:359 msgid "Do not dump the file." msgstr "" -#: ../../library/stat.rst:365 ../../library/stat.rst:427 +#: ../../library/stat.rst:363 ../../library/stat.rst:425 msgid "The file may not be changed." msgstr "" -#: ../../library/stat.rst:369 ../../library/stat.rst:431 +#: ../../library/stat.rst:367 ../../library/stat.rst:429 msgid "The file may only be appended to." msgstr "" -#: ../../library/stat.rst:373 +#: ../../library/stat.rst:371 msgid "The directory is opaque when viewed through a union stack." msgstr "" -#: ../../library/stat.rst:377 ../../library/stat.rst:441 +#: ../../library/stat.rst:375 ../../library/stat.rst:439 msgid "The file may not be renamed or deleted." msgstr "" -#: ../../library/stat.rst:381 +#: ../../library/stat.rst:379 msgid "The file is stored compressed (macOS 10.6+)." msgstr "" -#: ../../library/stat.rst:385 +#: ../../library/stat.rst:383 msgid "Used for handling document IDs (macOS)" msgstr "" -#: ../../library/stat.rst:391 +#: ../../library/stat.rst:389 msgid "The file needs an entitlement for reading or writing (macOS 10.13+)" msgstr "" -#: ../../library/stat.rst:397 +#: ../../library/stat.rst:395 msgid "The file should not be displayed in a GUI (macOS 10.5+)." msgstr "" -#: ../../library/stat.rst:401 +#: ../../library/stat.rst:399 msgid "All super-user changeable flags" msgstr "" -#: ../../library/stat.rst:407 +#: ../../library/stat.rst:405 msgid "All super-user supported flags" msgstr "" -#: ../../library/stat.rst:409 ../../library/stat.rst:417 +#: ../../library/stat.rst:407 ../../library/stat.rst:415 msgid "Availability" msgstr "可用性" -#: ../../library/stat.rst:415 +#: ../../library/stat.rst:413 msgid "All super-user read-only synthetic flags" msgstr "" -#: ../../library/stat.rst:423 +#: ../../library/stat.rst:421 msgid "The file may be archived." msgstr "" -#: ../../library/stat.rst:435 +#: ../../library/stat.rst:433 msgid "The file needs an entitlement to write to (macOS 10.13+)" msgstr "" -#: ../../library/stat.rst:445 +#: ../../library/stat.rst:443 msgid "The file is a snapshot file." msgstr "" -#: ../../library/stat.rst:449 +#: ../../library/stat.rst:447 msgid "The file is a firmlink (macOS 10.15+)" msgstr "" -#: ../../library/stat.rst:455 +#: ../../library/stat.rst:453 msgid "The file is a dataless object (macOS 10.15+)" msgstr "" -#: ../../library/stat.rst:459 +#: ../../library/stat.rst:457 msgid "" "See the \\*BSD or macOS systems man page :manpage:`chflags(2)` for more " "information." msgstr "" -#: ../../library/stat.rst:461 +#: ../../library/stat.rst:459 msgid "" "On Windows, the following file attribute constants are available for use " "when testing bits in the ``st_file_attributes`` member returned by :func:`os." @@ -470,9 +470,18 @@ msgid "" "these constants." msgstr "" -#: ../../library/stat.rst:487 +#: ../../library/stat.rst:485 msgid "" "On Windows, the following constants are available for comparing against the " "``st_reparse_tag`` member returned by :func:`os.lstat`. These are well-known " "constants, but are not an exhaustive list." msgstr "" + +#: ../../library/stat.rst:495 +msgid "" +"On Linux, the following file attribute constants are available for use when " +"testing bits in the :attr:`~os.statx_result.stx_attributes` and :attr:`~os." +"statx_result.stx_attributes_mask` members returned by :func:`os.statx`. See " +"the :manpage:`statx(2)` man page for more detail on the meaning of these " +"constants." +msgstr "" diff --git a/library/statistics.po b/library/statistics.po index 983754c4fe6..b20b5cf00d5 100644 --- a/library/statistics.po +++ b/library/statistics.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-22 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-07-22 21:15+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,18 +23,18 @@ msgstr "" msgid ":mod:`!statistics` --- Mathematical statistics functions" msgstr ":mod:`!statistics` --- 數學統計函式" -#: ../../library/statistics.rst:12 +#: ../../library/statistics.rst:9 msgid "**Source code:** :source:`Lib/statistics.py`" msgstr "**原始碼:**\\ :source:`Lib/statistics.py`" -#: ../../library/statistics.rst:22 +#: ../../library/statistics.rst:19 msgid "" "This module provides functions for calculating mathematical statistics of " "numeric (:class:`~numbers.Real`-valued) data." msgstr "" "這個模組提供計算數值 (:class:`~numbers.Real`-valued) 資料的數學統計函式。" -#: ../../library/statistics.rst:25 +#: ../../library/statistics.rst:22 msgid "" "The module is not intended to be a competitor to third-party libraries such " "as `NumPy `_, `SciPy `_, or " @@ -46,7 +46,7 @@ msgstr "" ">`_ 等第三方函式庫,或者像 Minitab、SAS 和 Matlab 等專門設計給專業統計學家的" "高階統計軟體互相競爭。此模組的目標在於繪圖和科學計算。" -#: ../../library/statistics.rst:31 +#: ../../library/statistics.rst:28 msgid "" "Unless explicitly noted, these functions support :class:`int`, :class:" "`float`, :class:`~decimal.Decimal` and :class:`~fractions.Fraction`. " @@ -62,7 +62,7 @@ msgstr "" "輸入資料含有混合型別,你可以考慮使用 :func:`map` 來確保結果是一致的,例如:" "``map(float, input_data)``。" -#: ../../library/statistics.rst:39 +#: ../../library/statistics.rst:36 msgid "" "Some datasets use ``NaN`` (not a number) values to represent missing data. " "Since NaNs have unusual comparison semantics, they cause surprising or " @@ -78,7 +78,7 @@ msgstr "" "``median_grouped()``、 ``mode()``、 ``multimode()`` 以及 ``quantiles()``。在" "呼叫這些函數之前,應該先移除 NaN 值:" -#: ../../library/statistics.rst:47 +#: ../../library/statistics.rst:44 msgid "" ">>> from statistics import median\n" ">>> from math import isnan\n" @@ -101,202 +101,202 @@ msgid "" "18.75" msgstr "" -#: ../../library/statistics.rst:69 +#: ../../library/statistics.rst:66 msgid "Averages and measures of central location" msgstr "平均值與中央位置量數" -#: ../../library/statistics.rst:71 +#: ../../library/statistics.rst:68 msgid "" "These functions calculate an average or typical value from a population or " "sample." msgstr "這些函式計算來自一個母體或樣本的平均值或代表值。" -#: ../../library/statistics.rst:75 +#: ../../library/statistics.rst:72 msgid ":func:`mean`" msgstr ":func:`mean`" -#: ../../library/statistics.rst:75 +#: ../../library/statistics.rst:72 msgid "Arithmetic mean (\"average\") of data." msgstr "資料的算術平均數(平均值)。" -#: ../../library/statistics.rst:76 +#: ../../library/statistics.rst:73 msgid ":func:`fmean`" msgstr ":func:`fmean`" -#: ../../library/statistics.rst:76 +#: ../../library/statistics.rst:73 msgid "Fast, floating-point arithmetic mean, with optional weighting." msgstr "快速浮點數算數平均數,可調整權重。" -#: ../../library/statistics.rst:77 +#: ../../library/statistics.rst:74 msgid ":func:`geometric_mean`" msgstr ":func:`geometric_mean`" -#: ../../library/statistics.rst:77 +#: ../../library/statistics.rst:74 msgid "Geometric mean of data." msgstr "資料的幾何平均數。" -#: ../../library/statistics.rst:78 +#: ../../library/statistics.rst:75 msgid ":func:`harmonic_mean`" msgstr ":func:`harmonic_mean`" -#: ../../library/statistics.rst:78 +#: ../../library/statistics.rst:75 msgid "Harmonic mean of data." msgstr "資料的調和平均數。" -#: ../../library/statistics.rst:79 +#: ../../library/statistics.rst:76 msgid ":func:`kde`" msgstr ":func:`kde`" -#: ../../library/statistics.rst:79 +#: ../../library/statistics.rst:76 msgid "Estimate the probability density distribution of the data." msgstr "" -#: ../../library/statistics.rst:80 +#: ../../library/statistics.rst:77 msgid ":func:`kde_random`" msgstr ":func:`kde_random`" -#: ../../library/statistics.rst:80 +#: ../../library/statistics.rst:77 msgid "Random sampling from the PDF generated by kde()." msgstr "" -#: ../../library/statistics.rst:81 +#: ../../library/statistics.rst:78 msgid ":func:`median`" msgstr ":func:`median`" -#: ../../library/statistics.rst:81 +#: ../../library/statistics.rst:78 msgid "Median (middle value) of data." msgstr "資料的中位數(中間值)。" -#: ../../library/statistics.rst:82 +#: ../../library/statistics.rst:79 msgid ":func:`median_low`" msgstr ":func:`median_low`" -#: ../../library/statistics.rst:82 +#: ../../library/statistics.rst:79 msgid "Low median of data." msgstr "資料中較小的中位數。" -#: ../../library/statistics.rst:83 +#: ../../library/statistics.rst:80 msgid ":func:`median_high`" msgstr ":func:`median_high`" -#: ../../library/statistics.rst:83 +#: ../../library/statistics.rst:80 msgid "High median of data." msgstr "資料中較大的中位數。" -#: ../../library/statistics.rst:84 +#: ../../library/statistics.rst:81 msgid ":func:`median_grouped`" msgstr ":func:`median_grouped`" -#: ../../library/statistics.rst:84 +#: ../../library/statistics.rst:81 msgid "Median (50th percentile) of grouped data." msgstr "分組資料的中位數(第 50 百分位數)。" -#: ../../library/statistics.rst:85 +#: ../../library/statistics.rst:82 msgid ":func:`mode`" msgstr ":func:`mode`" -#: ../../library/statistics.rst:85 +#: ../../library/statistics.rst:82 msgid "Single mode (most common value) of discrete or nominal data." msgstr "" "離散 (discrete) 或名目 (nomial) 資料中的眾數(出現次數最多次的值),只回傳一" "個。" -#: ../../library/statistics.rst:86 +#: ../../library/statistics.rst:83 msgid ":func:`multimode`" msgstr ":func:`multimode`" -#: ../../library/statistics.rst:86 +#: ../../library/statistics.rst:83 msgid "List of modes (most common values) of discrete or nominal data." msgstr "離散或名目資料中的眾數(出現次數最多次的值)組成的 list。" -#: ../../library/statistics.rst:87 +#: ../../library/statistics.rst:84 msgid ":func:`quantiles`" msgstr ":func:`quantiles`" -#: ../../library/statistics.rst:87 +#: ../../library/statistics.rst:84 msgid "Divide data into intervals with equal probability." msgstr "將資料分成數個具有相等機率的區間,即分位數 (quantile)。" -#: ../../library/statistics.rst:91 +#: ../../library/statistics.rst:88 msgid "Measures of spread" msgstr "離度 (spread) 的測量" -#: ../../library/statistics.rst:93 +#: ../../library/statistics.rst:90 msgid "" "These functions calculate a measure of how much the population or sample " "tends to deviate from the typical or average values." msgstr "這些函式計算母體或樣本偏離平均值的程度。" -#: ../../library/statistics.rst:97 +#: ../../library/statistics.rst:94 msgid ":func:`pstdev`" msgstr ":func:`pstdev`" -#: ../../library/statistics.rst:97 +#: ../../library/statistics.rst:94 msgid "Population standard deviation of data." msgstr "資料的母體標準差。" -#: ../../library/statistics.rst:98 +#: ../../library/statistics.rst:95 msgid ":func:`pvariance`" msgstr ":func:`pvariance`" -#: ../../library/statistics.rst:98 +#: ../../library/statistics.rst:95 msgid "Population variance of data." msgstr "資料的母體變異數。" -#: ../../library/statistics.rst:99 +#: ../../library/statistics.rst:96 msgid ":func:`stdev`" msgstr ":func:`stdev`" -#: ../../library/statistics.rst:99 +#: ../../library/statistics.rst:96 msgid "Sample standard deviation of data." msgstr "資料的樣本標準差。" -#: ../../library/statistics.rst:100 +#: ../../library/statistics.rst:97 msgid ":func:`variance`" msgstr ":func:`variance`" -#: ../../library/statistics.rst:100 +#: ../../library/statistics.rst:97 msgid "Sample variance of data." msgstr "資料的樣本變異數。" -#: ../../library/statistics.rst:104 +#: ../../library/statistics.rst:101 msgid "Statistics for relations between two inputs" msgstr "兩個輸入之間的關係統計" -#: ../../library/statistics.rst:106 +#: ../../library/statistics.rst:103 msgid "" "These functions calculate statistics regarding relations between two inputs." msgstr "這些函式計算兩個輸入之間的關係統計數據。" -#: ../../library/statistics.rst:109 +#: ../../library/statistics.rst:106 msgid ":func:`covariance`" msgstr ":func:`covariance`" -#: ../../library/statistics.rst:109 +#: ../../library/statistics.rst:106 msgid "Sample covariance for two variables." msgstr "兩變數的樣本共變異數。" -#: ../../library/statistics.rst:110 +#: ../../library/statistics.rst:107 msgid ":func:`correlation`" msgstr ":func:`correlation`" -#: ../../library/statistics.rst:110 +#: ../../library/statistics.rst:107 msgid "Pearson and Spearman's correlation coefficients." msgstr "Pearson 與 Spearman 相關係數 (correlation coefficient)。" -#: ../../library/statistics.rst:111 +#: ../../library/statistics.rst:108 msgid ":func:`linear_regression`" msgstr ":func:`linear_regression`" -#: ../../library/statistics.rst:111 +#: ../../library/statistics.rst:108 msgid "Slope and intercept for simple linear regression." msgstr "簡單線性迴歸的斜率和截距。" -#: ../../library/statistics.rst:116 +#: ../../library/statistics.rst:113 msgid "Function details" msgstr "函式細節" -#: ../../library/statistics.rst:118 +#: ../../library/statistics.rst:115 msgid "" "Note: The functions do not require the data given to them to be sorted. " "However, for reading convenience, most of the examples show sorted sequences." @@ -304,13 +304,13 @@ msgstr "" "註:這些函數並不要求輸入的資料必須排序過。為了閱讀方便,大部份的範例仍已排序" "過。" -#: ../../library/statistics.rst:123 +#: ../../library/statistics.rst:120 msgid "" "Return the sample arithmetic mean of *data* which can be a sequence or " "iterable." msgstr "回傳 *data* 的樣本算數平均數,輸入可為一個 sequence 或者 iterable。" -#: ../../library/statistics.rst:125 +#: ../../library/statistics.rst:122 msgid "" "The arithmetic mean is the sum of the data divided by the number of data " "points. It is commonly called \"the average\", although it is only one of " @@ -320,15 +320,15 @@ msgstr "" "算數平均數為資料總和除以資料點的數目。他通常被稱為「平均值」,儘管它只是眾多" "不同的數學平均值之一。它是衡量資料集中位置的一種指標。" -#: ../../library/statistics.rst:130 +#: ../../library/statistics.rst:127 msgid "If *data* is empty, :exc:`StatisticsError` will be raised." msgstr "若 *data* 為空,則會引發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:132 +#: ../../library/statistics.rst:129 msgid "Some examples of use:" msgstr "使用範例:" -#: ../../library/statistics.rst:134 +#: ../../library/statistics.rst:131 msgid "" ">>> mean([1, 2, 3, 4, 4])\n" "2.8\n" @@ -356,7 +356,7 @@ msgstr "" ">>> mean([D(\"0.5\"), D(\"0.75\"), D(\"0.625\"), D(\"0.375\")])\n" "Decimal('0.5625')" -#: ../../library/statistics.rst:151 +#: ../../library/statistics.rst:148 msgid "" "The mean is strongly affected by `outliers `_ and is not necessarily a typical example of the data points. For " @@ -368,7 +368,7 @@ msgstr "" "低的\\ `集中趨勢 (central tendency) `_ 度量,請參考 :func:`median`。" -#: ../../library/statistics.rst:157 +#: ../../library/statistics.rst:154 msgid "" "The sample mean gives an unbiased estimate of the true population mean, so " "that when taken on average over all the possible samples, ``mean(sample)`` " @@ -381,11 +381,11 @@ msgstr "" "*data* 為整個母體而非單一樣本,則 ``mean(data)`` 等同於計算真實的母體平均數 " "μ。" -#: ../../library/statistics.rst:166 +#: ../../library/statistics.rst:163 msgid "Convert *data* to floats and compute the arithmetic mean." msgstr "將 *data* 轉換為浮點數並計算其算數平均數。" -#: ../../library/statistics.rst:168 +#: ../../library/statistics.rst:165 msgid "" "This runs faster than the :func:`mean` function and it always returns a :" "class:`float`. The *data* may be a sequence or iterable. If the input " @@ -395,7 +395,7 @@ msgstr "" "可以是一個 sequence 或者 iterable。如果輸入的資料為空,則引發 :exc:" "`StatisticsError`。" -#: ../../library/statistics.rst:172 +#: ../../library/statistics.rst:169 msgid "" ">>> fmean([3.5, 4.0, 5.25])\n" "4.25" @@ -403,7 +403,7 @@ msgstr "" ">>> fmean([3.5, 4.0, 5.25])\n" "4.25" -#: ../../library/statistics.rst:177 +#: ../../library/statistics.rst:174 msgid "" "Optional weighting is supported. For example, a professor assigns a grade " "for a course by weighting quizzes at 20%, homework at 20%, a midterm exam at " @@ -412,7 +412,7 @@ msgstr "" "支援選擇性的加權。例如,一位教授以 20% 的比重計算小考分數,20% 的比重計算作業" "分數,30% 的比重計算期中考試分數,以及 30% 的比重計算期末考試分數:" -#: ../../library/statistics.rst:181 +#: ../../library/statistics.rst:178 msgid "" ">>> grades = [85, 92, 83, 91]\n" ">>> weights = [0.20, 0.20, 0.30, 0.30]\n" @@ -424,7 +424,7 @@ msgstr "" ">>> fmean(grades, weights)\n" "87.6" -#: ../../library/statistics.rst:188 +#: ../../library/statistics.rst:185 msgid "" "If *weights* is supplied, it must be the same length as the *data* or a :exc:" "`ValueError` will be raised." @@ -432,15 +432,15 @@ msgstr "" "如果有提供 *weights*,它必須與 *data* 長度相同,否則將引發 :exc:" "`ValueError`。" -#: ../../library/statistics.rst:193 ../../library/statistics.rst:261 +#: ../../library/statistics.rst:190 ../../library/statistics.rst:258 msgid "Added support for *weights*." msgstr "新增 *weights* 的支援。" -#: ../../library/statistics.rst:199 +#: ../../library/statistics.rst:196 msgid "Convert *data* to floats and compute the geometric mean." msgstr "將 *data* 轉換成浮點數並計算其幾何平均數。" -#: ../../library/statistics.rst:201 +#: ../../library/statistics.rst:198 msgid "" "The geometric mean indicates the central tendency or typical value of the " "*data* using the product of the values (as opposed to the arithmetic mean " @@ -449,7 +449,7 @@ msgstr "" "幾何平均數使用數值的乘積(與之對照,算數平均數使用的是數值的和)來表示 " "*data* 的集中趨勢或典型值。" -#: ../../library/statistics.rst:205 +#: ../../library/statistics.rst:202 msgid "" "Raises a :exc:`StatisticsError` if the input dataset is empty, if it " "contains a zero, or if it contains a negative value. The *data* may be a " @@ -458,13 +458,13 @@ msgstr "" "若輸入的資料集為空、包含零、包含負值,則引發 :exc:`StatisticsError`。*data* " "可為 sequence 或者 iterable。" -#: ../../library/statistics.rst:209 +#: ../../library/statistics.rst:206 msgid "" "No special efforts are made to achieve exact results. (However, this may " "change in the future.)" msgstr "目前沒有特別為了精確結果而特別多下什麼工夫。(然而,未來或許會有。)" -#: ../../library/statistics.rst:212 +#: ../../library/statistics.rst:209 msgid "" ">>> round(geometric_mean([54, 24, 36]), 1)\n" "36.0" @@ -472,7 +472,7 @@ msgstr "" ">>> round(geometric_mean([54, 24, 36]), 1)\n" "36.0" -#: ../../library/statistics.rst:222 +#: ../../library/statistics.rst:219 msgid "" "Return the harmonic mean of *data*, a sequence or iterable of real-valued " "numbers. If *weights* is omitted or ``None``, then equal weighting is " @@ -481,7 +481,7 @@ msgstr "" "回傳 *data* 的調和平均數。*data* 可為實數 (real-valued) sequence 或者 " "iterable。如果省略 *weights* 或者 *weights* 為 ``None``,則假設各權重相等。" -#: ../../library/statistics.rst:226 +#: ../../library/statistics.rst:223 msgid "" "The harmonic mean is the reciprocal of the arithmetic :func:`mean` of the " "reciprocals of the data. For example, the harmonic mean of three values *a*, " @@ -492,7 +492,7 @@ msgstr "" "三個數 *a*,*b* 與 *c* 的調和平均數等於 ``3/(1/a + 1/b + 1/c)``。若其中一個值" "為零,結果將為零。" -#: ../../library/statistics.rst:231 +#: ../../library/statistics.rst:228 msgid "" "The harmonic mean is a type of average, a measure of the central location of " "the data. It is often appropriate when averaging ratios or rates, for " @@ -501,7 +501,7 @@ msgstr "" "調和平均數是一種平均數,是衡量資料中心位置的一種方法。它通常用於計算比率 " "(ratio) 或率 (rate) 的平均,例如速率(speed)。" -#: ../../library/statistics.rst:235 +#: ../../library/statistics.rst:232 msgid "" "Suppose a car travels 10 km at 40 km/hr, then another 10 km at 60 km/hr. " "What is the average speed?" @@ -509,7 +509,7 @@ msgstr "" "假設一輛汽車以時速 40 公里的速率行駛 10 公里,然後再以時速 60 公里的速率行駛 " "10 公里,求汽車的平均速率?" -#: ../../library/statistics.rst:238 +#: ../../library/statistics.rst:235 msgid "" ">>> harmonic_mean([40, 60])\n" "48.0" @@ -517,7 +517,7 @@ msgstr "" ">>> harmonic_mean([40, 60])\n" "48.0" -#: ../../library/statistics.rst:243 +#: ../../library/statistics.rst:240 msgid "" "Suppose a car travels 40 km/hr for 5 km, and when traffic clears, speeds-up " "to 60 km/hr for the remaining 30 km of the journey. What is the average " @@ -526,7 +526,7 @@ msgstr "" "假設一輛汽車以時速 40 公里的速率行駛 5 公里,然後在交通順暢時,加速到時速 60 " "公里,以此速度行駛剩下的 30 公里。求汽車的平均速率?" -#: ../../library/statistics.rst:247 +#: ../../library/statistics.rst:244 msgid "" ">>> harmonic_mean([40, 60], weights=[5, 30])\n" "56.0" @@ -534,7 +534,7 @@ msgstr "" ">>> harmonic_mean([40, 60], weights=[5, 30])\n" "56.0" -#: ../../library/statistics.rst:252 +#: ../../library/statistics.rst:249 msgid "" ":exc:`StatisticsError` is raised if *data* is empty, any element is less " "than zero, or if the weighted sum isn't positive." @@ -542,7 +542,7 @@ msgstr "" "若 *data* 為空、含有任何小於零的元素、或者加權總和不為正數,則引發 :exc:" "`StatisticsError`。" -#: ../../library/statistics.rst:255 +#: ../../library/statistics.rst:252 msgid "" "The current algorithm has an early-out when it encounters a zero in the " "input. This means that the subsequent inputs are not tested for validity. " @@ -551,7 +551,7 @@ msgstr "" "目前的演算法設計為,若在輸入當中遇到零,則會提前退出。這意味著後續的輸入並未" "進行有效性檢查。(這種行為在未來可能會改變。)" -#: ../../library/statistics.rst:267 +#: ../../library/statistics.rst:264 msgid "" "`Kernel Density Estimation (KDE) `_: Create a continuous " @@ -559,51 +559,51 @@ msgid "" "discrete samples." msgstr "" -#: ../../library/statistics.rst:272 +#: ../../library/statistics.rst:269 msgid "" "The basic idea is to smooth the data using `a kernel function `_. to help draw inferences about a " "population from a sample." msgstr "" -#: ../../library/statistics.rst:276 +#: ../../library/statistics.rst:273 msgid "" "The degree of smoothing is controlled by the scaling parameter *h* which is " "called the bandwidth. Smaller values emphasize local features while larger " "values give smoother results." msgstr "" -#: ../../library/statistics.rst:280 +#: ../../library/statistics.rst:277 msgid "" "The *kernel* determines the relative weights of the sample data points. " "Generally, the choice of kernel shape does not matter as much as the more " "influential bandwidth smoothing parameter." msgstr "" -#: ../../library/statistics.rst:284 +#: ../../library/statistics.rst:281 msgid "" "Kernels that give some weight to every sample point include *normal* " "(*gauss*), *logistic*, and *sigmoid*." msgstr "" -#: ../../library/statistics.rst:287 +#: ../../library/statistics.rst:284 msgid "" "Kernels that only give weight to sample points within the bandwidth include " "*rectangular* (*uniform*), *triangular*, *parabolic* (*epanechnikov*), " "*quartic* (*biweight*), *triweight*, and *cosine*." msgstr "" -#: ../../library/statistics.rst:291 +#: ../../library/statistics.rst:288 msgid "" "If *cumulative* is true, will return a cumulative distribution function." msgstr "" -#: ../../library/statistics.rst:293 ../../library/statistics.rst:329 +#: ../../library/statistics.rst:290 ../../library/statistics.rst:321 msgid "" "A :exc:`StatisticsError` will be raised if the *data* sequence is empty." msgstr "若 *data* 為空,則引發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:295 +#: ../../library/statistics.rst:292 msgid "" "`Wikipedia has an example `_ where we can use :func:`kde` to " @@ -614,7 +614,7 @@ msgstr "" "Kernel_density_estimation#Example>`_,我們可以使用 :func:`kde` 來從一個小樣本" "生成並繪製估計的機率密度函數:" -#: ../../library/statistics.rst:300 +#: ../../library/statistics.rst:297 msgid "" ">>> sample = [-2.1, -1.3, -0.4, 1.9, 5.1, 6.2]\n" ">>> f_hat = kde(sample, h=1.5)\n" @@ -626,43 +626,35 @@ msgstr "" ">>> xarr = [i/100 for i in range(-750, 1100)]\n" ">>> yarr = [f_hat(x) for x in xarr]" -#: ../../library/statistics.rst:307 +#: ../../library/statistics.rst:304 msgid "The points in ``xarr`` and ``yarr`` can be used to make a PDF plot:" msgstr "``xarr`` 和 ``yarr`` 中的點可用於繪製 PDF 圖:" -#: ../../library/statistics.rst:309 +#: ../../library/statistics.rst:306 msgid "Scatter plot of the estimated probability density function." msgstr "估計機率密度函式的散點圖 (scatter plot)。" -#: ../../library/statistics.rst:312 -msgid "" -"Because the returned ``f_hat`` function is typically called many times, it " -"caches the *data* for performance. To support dynamic datasets, this cache " -"automatically refreshes whenever the length of the *data* changes. This " -"allows new samples to be added as they become available." -msgstr "" - -#: ../../library/statistics.rst:322 +#: ../../library/statistics.rst:314 msgid "" "Return a function that makes a random selection from the estimated " "probability density function produced by ``kde(data, h, kernel)``." msgstr "" -#: ../../library/statistics.rst:325 +#: ../../library/statistics.rst:317 msgid "" "Providing a *seed* allows reproducible selections. In the future, the values " "may change slightly as more accurate kernel inverse CDF estimates are " "implemented. The seed may be an integer, float, str, or bytes." msgstr "" -#: ../../library/statistics.rst:331 +#: ../../library/statistics.rst:323 msgid "" "Continuing the example for :func:`kde`, we can use :func:`kde_random` to " "generate new random selections from an estimated probability density " "function:" msgstr "" -#: ../../library/statistics.rst:346 +#: ../../library/statistics.rst:338 msgid "" "Return the median (middle value) of numeric data, using the common \"mean of " "middle two\" method. If *data* is empty, :exc:`StatisticsError` is raised. " @@ -671,7 +663,7 @@ msgstr "" "使用常見的「中間兩數取平均」方法回傳數值資料的中位數 (中間值)。若 *data* 為" "空,則會引發 :exc:`StatisticsError`。*data* 可為一個 sequence 或者 iterable。" -#: ../../library/statistics.rst:350 +#: ../../library/statistics.rst:342 msgid "" "The median is a robust measure of central location and is less affected by " "the presence of outliers. When the number of data points is odd, the middle " @@ -680,7 +672,7 @@ msgstr "" "中位數是一種穩健的衡量資料中心位置的方法,較不易被離群值影響。當資料點數量為" "奇數時,會回傳中間的資料點:" -#: ../../library/statistics.rst:354 +#: ../../library/statistics.rst:346 msgid "" ">>> median([1, 3, 5])\n" "3" @@ -688,13 +680,13 @@ msgstr "" ">>> median([1, 3, 5])\n" "3" -#: ../../library/statistics.rst:359 +#: ../../library/statistics.rst:351 msgid "" "When the number of data points is even, the median is interpolated by taking " "the average of the two middle values:" msgstr "當資料點數量為偶數時,中位數透過中間兩個值的平均數來插值計算:" -#: ../../library/statistics.rst:362 +#: ../../library/statistics.rst:354 msgid "" ">>> median([1, 3, 5, 7])\n" "4.0" @@ -702,7 +694,7 @@ msgstr "" ">>> median([1, 3, 5, 7])\n" "4.0" -#: ../../library/statistics.rst:367 +#: ../../library/statistics.rst:359 msgid "" "This is suited for when your data is discrete, and you don't mind that the " "median may not be an actual data point." @@ -710,7 +702,7 @@ msgstr "" "若你的資料為離散資料,並且你不介意中位數可能並非真實的資料點,那這函式適合" "你。" -#: ../../library/statistics.rst:370 +#: ../../library/statistics.rst:362 msgid "" "If the data is ordinal (supports order operations) but not numeric (doesn't " "support addition), consider using :func:`median_low` or :func:`median_high` " @@ -719,7 +711,7 @@ msgstr "" "若你的資料為順序 (ordinal) 資料(支援排序操作)但並非數值型(不支援加法),可" "以考慮改用 :func:`median_low` 或是 :func:`median_high` 代替。" -#: ../../library/statistics.rst:376 +#: ../../library/statistics.rst:368 msgid "" "Return the low median of numeric data. If *data* is empty, :exc:" "`StatisticsError` is raised. *data* can be a sequence or iterable." @@ -727,7 +719,7 @@ msgstr "" "回傳數值型資料的低中位數 (low median)。若 *data* 為空,則引發 :exc:" "`StatisticsError`。*data* 可為 sequence 或者 iterable。" -#: ../../library/statistics.rst:379 +#: ../../library/statistics.rst:371 msgid "" "The low median is always a member of the data set. When the number of data " "points is odd, the middle value is returned. When it is even, the smaller " @@ -736,7 +728,7 @@ msgstr "" "低中位數一定會在原本的資料集當中。當資料點數量為奇數時,回傳中間值。當數量為" "偶數時,回傳兩個中間值當中較小的值。" -#: ../../library/statistics.rst:383 +#: ../../library/statistics.rst:375 msgid "" ">>> median_low([1, 3, 5])\n" "3\n" @@ -748,7 +740,7 @@ msgstr "" ">>> median_low([1, 3, 5, 7])\n" "3" -#: ../../library/statistics.rst:390 +#: ../../library/statistics.rst:382 msgid "" "Use the low median when your data are discrete and you prefer the median to " "be an actual data point rather than interpolated." @@ -756,7 +748,7 @@ msgstr "" "當你的資料為離散資料,且你希望中位數是實際的資料點而不是插值時,可以用低中位" "數。" -#: ../../library/statistics.rst:396 +#: ../../library/statistics.rst:388 msgid "" "Return the high median of data. If *data* is empty, :exc:`StatisticsError` " "is raised. *data* can be a sequence or iterable." @@ -764,7 +756,7 @@ msgstr "" "回傳數值型資料的高中位數 (high median)。若 *data* 為空,則引發 :exc:" "`StatisticsError`。*data* 可為 sequence 或者 iterable。" -#: ../../library/statistics.rst:399 +#: ../../library/statistics.rst:391 msgid "" "The high median is always a member of the data set. When the number of data " "points is odd, the middle value is returned. When it is even, the larger of " @@ -773,7 +765,7 @@ msgstr "" "高中位數一定會在原本的資料集當中。當資料點數量為奇數時,回傳中間值。當數量為" "偶數時,回傳兩個中間值當中較大的值。" -#: ../../library/statistics.rst:403 +#: ../../library/statistics.rst:395 msgid "" ">>> median_high([1, 3, 5])\n" "3\n" @@ -785,7 +777,7 @@ msgstr "" ">>> median_high([1, 3, 5, 7])\n" "5" -#: ../../library/statistics.rst:410 +#: ../../library/statistics.rst:402 msgid "" "Use the high median when your data are discrete and you prefer the median to " "be an actual data point rather than interpolated." @@ -793,31 +785,31 @@ msgstr "" "當你的資料為離散資料,且你希望中位數是實際的資料點而不是插值時,可以用高中位" "數。" -#: ../../library/statistics.rst:416 +#: ../../library/statistics.rst:408 msgid "" "Estimates the median for numeric data that has been `grouped or binned " "`_ around the midpoints of " "consecutive, fixed-width intervals." msgstr "" -#: ../../library/statistics.rst:420 +#: ../../library/statistics.rst:412 msgid "" "The *data* can be any iterable of numeric data with each value being exactly " "the midpoint of a bin. At least one value must be present." msgstr "" -#: ../../library/statistics.rst:423 +#: ../../library/statistics.rst:415 msgid "The *interval* is the width of each bin." msgstr "" -#: ../../library/statistics.rst:425 +#: ../../library/statistics.rst:417 msgid "" "For example, demographic information may have been summarized into " "consecutive ten-year age groups with each group being represented by the 5-" "year midpoints of the intervals:" msgstr "" -#: ../../library/statistics.rst:429 +#: ../../library/statistics.rst:421 msgid "" ">>> from collections import Counter\n" ">>> demographics = Counter({\n" @@ -839,13 +831,13 @@ msgstr "" "... })\n" "..." -#: ../../library/statistics.rst:441 +#: ../../library/statistics.rst:433 msgid "" "The 50th percentile (median) is the 536th person out of the 1071 member " "cohort. That person is in the 30 to 40 year old age group." msgstr "" -#: ../../library/statistics.rst:444 +#: ../../library/statistics.rst:436 msgid "" "The regular :func:`median` function would assume that everyone in the " "tricenarian age group was exactly 35 years old. A more tenable assumption " @@ -853,7 +845,7 @@ msgid "" "and 40. For that, we use :func:`median_grouped`:" msgstr "" -#: ../../library/statistics.rst:450 +#: ../../library/statistics.rst:442 msgid "" ">>> data = list(demographics.elements())\n" ">>> median(data)\n" @@ -867,20 +859,20 @@ msgstr "" ">>> round(median_grouped(data, interval=10), 1)\n" "37.5" -#: ../../library/statistics.rst:458 +#: ../../library/statistics.rst:450 msgid "" "The caller is responsible for making sure the data points are separated by " "exact multiples of *interval*. This is essential for getting a correct " "result. The function does not check this precondition." msgstr "" -#: ../../library/statistics.rst:462 +#: ../../library/statistics.rst:454 msgid "" "Inputs may be any numeric type that can be coerced to a float during the " "interpolation step." msgstr "" -#: ../../library/statistics.rst:468 +#: ../../library/statistics.rst:460 msgid "" "Return the single most common data point from discrete or nominal *data*. " "The mode (when it exists) is the most typical value and serves as a measure " @@ -889,7 +881,7 @@ msgstr "" "回傳離散或名目 *data* 中出現次數最多次的值,只回傳一個。眾數(如果存在)是最" "典型的值,並用來衡量資料的中心位置。" -#: ../../library/statistics.rst:472 +#: ../../library/statistics.rst:464 msgid "" "If there are multiple modes with the same frequency, returns the first one " "encountered in the *data*. If the smallest or largest of those is desired " @@ -901,14 +893,14 @@ msgstr "" "``max(multimode(data))``。如果輸入的 *data* 為空,則會引發 :exc:" "`StatisticsError`。" -#: ../../library/statistics.rst:477 +#: ../../library/statistics.rst:469 msgid "" "``mode`` assumes discrete data and returns a single value. This is the " "standard treatment of the mode as commonly taught in schools:" msgstr "" "``mode`` 假定為離散資料,並回傳單一的值。這也是一般學校教授的標準眾數定義:" -#: ../../library/statistics.rst:480 +#: ../../library/statistics.rst:472 msgid "" ">>> mode([1, 1, 2, 3, 3, 3, 3, 4])\n" "3" @@ -916,13 +908,13 @@ msgstr "" ">>> mode([1, 1, 2, 3, 3, 3, 3, 4])\n" "3" -#: ../../library/statistics.rst:485 +#: ../../library/statistics.rst:477 msgid "" "The mode is unique in that it is the only statistic in this package that " "also applies to nominal (non-numeric) data:" msgstr "眾數特別之處在於它是此套件中唯一也適用於名目(非數值型)資料的統計量:" -#: ../../library/statistics.rst:488 +#: ../../library/statistics.rst:480 msgid "" ">>> mode([\"red\", \"blue\", \"blue\", \"red\", \"green\", \"red\", " "\"red\"])\n" @@ -932,7 +924,7 @@ msgstr "" "\"red\"])\n" "'red'" -#: ../../library/statistics.rst:493 +#: ../../library/statistics.rst:485 msgid "" "Only hashable inputs are supported. To handle type :class:`set`, consider " "casting to :class:`frozenset`. To handle type :class:`list`, consider " @@ -941,7 +933,7 @@ msgid "" "key=data.count)``." msgstr "" -#: ../../library/statistics.rst:499 +#: ../../library/statistics.rst:491 msgid "" "Now handles multimodal datasets by returning the first mode encountered. " "Formerly, it raised :exc:`StatisticsError` when more than one mode was found." @@ -949,7 +941,7 @@ msgstr "" "現在,遇到資料中有多個眾數時,會回傳第一個遇到的眾數。在以前,當找到大於一個" "眾數時,會引發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:507 +#: ../../library/statistics.rst:499 msgid "" "Return a list of the most frequently occurring values in the order they were " "first encountered in the *data*. Will return more than one result if there " @@ -959,7 +951,7 @@ msgstr "" "次出現的順序排列。如果有多個眾數,將會回傳所有結果。若 *data* 為空,則回傳空" "的 list:" -#: ../../library/statistics.rst:511 +#: ../../library/statistics.rst:503 msgid "" ">>> multimode('aabbbbccddddeeffffgg')\n" "['b', 'd', 'f']\n" @@ -971,7 +963,7 @@ msgstr "" ">>> multimode('')\n" "[]" -#: ../../library/statistics.rst:523 +#: ../../library/statistics.rst:515 msgid "" "Return the population standard deviation (the square root of the population " "variance). See :func:`pvariance` for arguments and other details." @@ -979,7 +971,7 @@ msgstr "" "回傳母體標準差(即母體變異數的平方根)。有關引數以及其他細節,請參見 :func:" "`pvariance`。" -#: ../../library/statistics.rst:526 +#: ../../library/statistics.rst:518 msgid "" ">>> pstdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75])\n" "0.986893273527251" @@ -987,7 +979,7 @@ msgstr "" ">>> pstdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75])\n" "0.986893273527251" -#: ../../library/statistics.rst:534 +#: ../../library/statistics.rst:526 msgid "" "Return the population variance of *data*, a non-empty sequence or iterable " "of real-valued numbers. Variance, or second moment about the mean, is a " @@ -999,7 +991,7 @@ msgstr "" "數,或者以平均數為中心的二階動差,用於衡量資料的變異性(離度或分散程度)。變" "異數大表示資料分散,變異數小表示資料集中在平均數附近。" -#: ../../library/statistics.rst:540 +#: ../../library/statistics.rst:532 msgid "" "If the optional second argument *mu* is given, it should be the *population* " "mean of the *data*. It can also be used to compute the second moment around " @@ -1010,7 +1002,7 @@ msgstr "" "(population mean)。它也可以用於計算非以平均值為中心的第二動差。如果沒有傳入此" "引數或者引數為 ``None`` (預設值),則自動計算資料的算數平均數。" -#: ../../library/statistics.rst:545 +#: ../../library/statistics.rst:537 msgid "" "Use this function to calculate the variance from the entire population. To " "estimate the variance from a sample, the :func:`variance` function is " @@ -1019,16 +1011,16 @@ msgstr "" "使用此函式來計算整個母體的變異數。如果要從樣本估算變異數,:func:`variance` 通" "常是較好的選擇。" -#: ../../library/statistics.rst:549 +#: ../../library/statistics.rst:541 msgid "Raises :exc:`StatisticsError` if *data* is empty." msgstr "若 *data* 為空,則引發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:551 ../../library/statistics.rst:621 -#: ../../library/statistics.rst:730 +#: ../../library/statistics.rst:543 ../../library/statistics.rst:613 +#: ../../library/statistics.rst:722 msgid "Examples:" msgstr "範例:" -#: ../../library/statistics.rst:553 +#: ../../library/statistics.rst:545 msgid "" ">>> data = [0.0, 0.25, 0.25, 1.25, 1.5, 1.75, 2.75, 3.25]\n" ">>> pvariance(data)\n" @@ -1038,7 +1030,7 @@ msgstr "" ">>> pvariance(data)\n" "1.25" -#: ../../library/statistics.rst:559 +#: ../../library/statistics.rst:551 msgid "" "If you have already calculated the mean of your data, you can pass it as the " "optional second argument *mu* to avoid recalculation:" @@ -1046,7 +1038,7 @@ msgstr "" "如果已經計算出資料的平均值,你可以將其作為選擇性的第二個引數 *mu* 傳遞以避免" "重新計算:" -#: ../../library/statistics.rst:562 +#: ../../library/statistics.rst:554 msgid "" ">>> mu = mean(data)\n" ">>> pvariance(data, mu)\n" @@ -1056,11 +1048,11 @@ msgstr "" ">>> pvariance(data, mu)\n" "1.25" -#: ../../library/statistics.rst:568 +#: ../../library/statistics.rst:560 msgid "Decimals and Fractions are supported:" msgstr "支援小數 (decimal) 與分數 (fraction):" -#: ../../library/statistics.rst:570 +#: ../../library/statistics.rst:562 msgid "" ">>> from decimal import Decimal as D\n" ">>> pvariance([D(\"27.5\"), D(\"30.25\"), D(\"30.25\"), D(\"34.5\"), " @@ -1080,7 +1072,7 @@ msgstr "" ">>> pvariance([F(1, 4), F(5, 4), F(1, 2)])\n" "Fraction(13, 72)" -#: ../../library/statistics.rst:582 +#: ../../library/statistics.rst:574 msgid "" "When called with the entire population, this gives the population variance " "σ². When called on a sample instead, this is the biased sample variance s², " @@ -1089,7 +1081,7 @@ msgstr "" "當在整個母體上呼叫此函式時,會回傳母體變異數 σ²。當在樣本上呼叫此函式時,會回" "傳有偏差的樣本變異數 s²,也就是具有 N 個自由度的變異數。" -#: ../../library/statistics.rst:586 +#: ../../library/statistics.rst:578 msgid "" "If you somehow know the true population mean μ, you may use this function to " "calculate the variance of a sample, giving the known population mean as the " @@ -1101,7 +1093,7 @@ msgstr "" "引數提供給此函式,用以計算樣本的變異數。只要資料點是母體的隨機樣本,結果將是" "母體變異數的不偏估計。" -#: ../../library/statistics.rst:595 +#: ../../library/statistics.rst:587 msgid "" "Return the sample standard deviation (the square root of the sample " "variance). See :func:`variance` for arguments and other details." @@ -1109,7 +1101,7 @@ msgstr "" "回傳樣本標準差(即樣本變異數的平方根)。有關引數以及其他細節,請參見 :func:" "`variance`。" -#: ../../library/statistics.rst:598 +#: ../../library/statistics.rst:590 msgid "" ">>> stdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75])\n" "1.0810874155219827" @@ -1117,7 +1109,7 @@ msgstr "" ">>> stdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75])\n" "1.0810874155219827" -#: ../../library/statistics.rst:606 +#: ../../library/statistics.rst:598 msgid "" "Return the sample variance of *data*, an iterable of at least two real-" "valued numbers. Variance, or second moment about the mean, is a measure of " @@ -1129,7 +1121,7 @@ msgstr "" "平均數為中心的二階動差,用於衡量資料的變異性(離度或分散程度)。變異數大表示" "資料分散,變異數小表示資料集中在平均數附近。" -#: ../../library/statistics.rst:612 +#: ../../library/statistics.rst:604 msgid "" "If the optional second argument *xbar* is given, it should be the *sample* " "mean of *data*. If it is missing or ``None`` (the default), the mean is " @@ -1139,7 +1131,7 @@ msgstr "" "(sample mean)。如果沒有傳入或者為 ``None`` (預設值),則自動計算資料的平均" "值。" -#: ../../library/statistics.rst:616 +#: ../../library/statistics.rst:608 msgid "" "Use this function when your data is a sample from a population. To calculate " "the variance from the entire population, see :func:`pvariance`." @@ -1147,11 +1139,11 @@ msgstr "" "當你的資料是來自母體的樣本時,請使用此函式。若要從整個母體計算變異數,請參" "見 :func:`pvariance`。" -#: ../../library/statistics.rst:619 +#: ../../library/statistics.rst:611 msgid "Raises :exc:`StatisticsError` if *data* has fewer than two values." msgstr "若 *data* 內少於兩個值,則引發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:623 +#: ../../library/statistics.rst:615 msgid "" ">>> data = [2.75, 1.75, 1.25, 0.25, 0.5, 1.25, 3.5]\n" ">>> variance(data)\n" @@ -1161,7 +1153,7 @@ msgstr "" ">>> variance(data)\n" "1.3720238095238095" -#: ../../library/statistics.rst:629 +#: ../../library/statistics.rst:621 msgid "" "If you have already calculated the sample mean of your data, you can pass it " "as the optional second argument *xbar* to avoid recalculation:" @@ -1169,7 +1161,7 @@ msgstr "" "如果已經計算出資料的樣本平均值,你可以將其作為選擇性的第二個引數 *mu* 傳遞以" "避免重新計算:" -#: ../../library/statistics.rst:632 +#: ../../library/statistics.rst:624 msgid "" ">>> m = mean(data)\n" ">>> variance(data, m)\n" @@ -1179,7 +1171,7 @@ msgstr "" ">>> variance(data, m)\n" "1.3720238095238095" -#: ../../library/statistics.rst:638 +#: ../../library/statistics.rst:630 msgid "" "This function does not attempt to verify that you have passed the actual " "mean as *xbar*. Using arbitrary values for *xbar* can lead to invalid or " @@ -1188,11 +1180,11 @@ msgstr "" "此函式不會驗證你傳入的 *xbar* 是否為實際的平均數。傳入任意的 *xbar* 會導致無" "效或不可能的結果。" -#: ../../library/statistics.rst:642 +#: ../../library/statistics.rst:634 msgid "Decimal and Fraction values are supported:" msgstr "支援小數 (decimal) 與分數 (fraction):" -#: ../../library/statistics.rst:644 +#: ../../library/statistics.rst:636 msgid "" ">>> from decimal import Decimal as D\n" ">>> variance([D(\"27.5\"), D(\"30.25\"), D(\"30.25\"), D(\"34.5\"), " @@ -1212,7 +1204,7 @@ msgstr "" ">>> variance([F(1, 6), F(1, 2), F(5, 3)])\n" "Fraction(67, 108)" -#: ../../library/statistics.rst:656 +#: ../../library/statistics.rst:648 msgid "" "This is the sample variance s² with Bessel's correction, also known as " "variance with N-1 degrees of freedom. Provided that the data points are " @@ -1223,7 +1215,7 @@ msgstr "" "為 N-1 的變異數。只要資料點具有代表性(例如:獨立且具有相同分布),結果應該會" "是對真實母體變異數的不偏估計。" -#: ../../library/statistics.rst:661 +#: ../../library/statistics.rst:653 msgid "" "If you somehow know the actual population mean μ you should pass it to the :" "func:`pvariance` function as the *mu* parameter to get the variance of a " @@ -1232,7 +1224,7 @@ msgstr "" "若你剛好知道真正的母體平均數 μ,你應該將其作為 *mu* 參數傳入 :func:" "`pvariance` 函式來計算樣本變異數。" -#: ../../library/statistics.rst:667 +#: ../../library/statistics.rst:659 msgid "" "Divide *data* into *n* continuous intervals with equal probability. Returns " "a list of ``n - 1`` cut points separating the intervals." @@ -1240,7 +1232,7 @@ msgstr "" "將 *data* 分成 *n* 個具有相等機率的連續區間。回傳一個包含 ``n - 1`` 個用於切" "分各區間的分隔點的 list。" -#: ../../library/statistics.rst:670 +#: ../../library/statistics.rst:662 msgid "" "Set *n* to 4 for quartiles (the default). Set *n* to 10 for deciles. Set " "*n* to 100 for percentiles which gives the 99 cuts points that separate " @@ -1251,7 +1243,7 @@ msgstr "" "分位數 (percentile),這將給出 99 個分隔點將 *data* 分成 100 個大小相等的組。" "如果 *n* 不是至少為 1,則引發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:675 +#: ../../library/statistics.rst:667 msgid "" "The *data* can be any iterable containing sample data. For meaningful " "results, the number of data points in *data* should be larger than *n*. " @@ -1260,7 +1252,7 @@ msgstr "" "*data* 可以是包含樣本資料的任何 iterable。為了取得有意義的結果,*data* 中的資" "料點數量應大於 *n*。如果連一個資料點都沒有,則引發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:679 +#: ../../library/statistics.rst:671 msgid "" "The cut points are linearly interpolated from the two nearest data points. " "For example, if a cut point falls one-third of the distance between two " @@ -1269,7 +1261,7 @@ msgstr "" "分隔點是從兩個最近的資料點線性內插值計算出來的。舉例來說,如果分隔點落在兩個" "樣本值 ``100`` 與 ``112`` 之間的距離三分之一處,則分隔點的值將為 ``104``。" -#: ../../library/statistics.rst:684 +#: ../../library/statistics.rst:676 msgid "" "The *method* for computing quantiles can be varied depending on whether the " "*data* includes or excludes the lowest and highest possible values from the " @@ -1278,7 +1270,7 @@ msgstr "" "計算分位數的 *method* 可以根據 *data* 是否包含或排除來自母體的最小與最大可能" "的值而改變。" -#: ../../library/statistics.rst:688 +#: ../../library/statistics.rst:680 msgid "" "The default *method* is \"exclusive\" and is used for data sampled from a " "population that can have more extreme values than found in the samples. The " @@ -1292,7 +1284,7 @@ msgstr "" "1)``。給定九個樣本資料,此方法將對資料排序且計算下列百分位數:10%、20%、30%、" "40%、50%、60%、70%、80%、90%。" -#: ../../library/statistics.rst:695 +#: ../../library/statistics.rst:687 msgid "" "Setting the *method* to \"inclusive\" is used for describing population data " "or for samples that are known to include the most extreme values from the " @@ -1309,7 +1301,7 @@ msgstr "" "給定十一個個樣本資料,此方法將對資料排序且計算下列百分位數:0%、10%、20%、" "30%、40%、50%、60%、70%、80%、90%、100%。" -#: ../../library/statistics.rst:704 +#: ../../library/statistics.rst:696 msgid "" "# Decile cut points for empirically sampled data\n" ">>> data = [105, 129, 87, 86, 111, 111, 89, 81, 108, 92, 110,\n" @@ -1321,29 +1313,29 @@ msgid "" "[81.0, 86.2, 89.0, 99.4, 102.5, 103.6, 106.0, 109.8, 111.0]" msgstr "" -#: ../../library/statistics.rst:717 +#: ../../library/statistics.rst:709 msgid "" "No longer raises an exception for an input with only a single data point. " "This allows quantile estimates to be built up one sample point at a time " "becoming gradually more refined with each new data point." msgstr "" -#: ../../library/statistics.rst:724 +#: ../../library/statistics.rst:716 msgid "" -"Return the sample covariance of two inputs *x* and *y*. Covariance is a " -"measure of the joint variability of two inputs." +"Return the sample covariance of two sequence inputs *x* and *y*. Covariance " +"is a measure of the joint variability of two inputs." msgstr "" -"回傳兩輸入 *x* 與 *y* 的樣本共變異數 (sample covariance)。共變異數是衡量兩輸" -"入的聯合變異性 (joint variability) 的指標。" +"回傳兩序列輸入 *x* 與 *y* 的樣本共變異數 (sample covariance)。共變異數是衡量" +"兩輸入的聯合變異性 (joint variability) 的指標。" -#: ../../library/statistics.rst:727 +#: ../../library/statistics.rst:719 msgid "" "Both inputs must be of the same length (no less than two), otherwise :exc:" "`StatisticsError` is raised." msgstr "" "兩輸入必須具有相同長度(至少兩個),否則會引發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:732 +#: ../../library/statistics.rst:724 msgid "" ">>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n" ">>> y = [1, 2, 3, 1, 2, 3, 1, 2, 3]\n" @@ -1365,18 +1357,18 @@ msgstr "" ">>> covariance(z, x)\n" "-7.5" -#: ../../library/statistics.rst:748 +#: ../../library/statistics.rst:740 msgid "" "Return the `Pearson's correlation coefficient `_ for two inputs. Pearson's correlation " -"coefficient *r* takes values between -1 and +1. It measures the strength and " -"direction of a linear relationship." +"Pearson_correlation_coefficient>`_ for two sequence inputs. Pearson's " +"correlation coefficient *r* takes values between -1 and +1. It measures the " +"strength and direction of a linear relationship." msgstr "" -"回傳兩輸入的 `Pearson 相關係數 (Pearson’s correlation coefficient) `_。Pearson 相關係數 " -"*r* 的值介於 -1 與 +1 之間。它衡量線性關係的強度與方向。" +"回傳兩序列輸入的 `Pearson 相關係數 (Pearson’s correlation coefficient) " +"`_。Pearson 相" +"關係數 *r* 的值介於 -1 與 +1 之間。它衡量線性關係的強度與方向。" -#: ../../library/statistics.rst:754 +#: ../../library/statistics.rst:746 msgid "" "If *method* is \"ranked\", computes `Spearman's rank correlation coefficient " "`_ " @@ -1390,7 +1382,7 @@ msgstr "" "則取平均,令相同的值排名也相同。所得係數衡量單調關係 (monotonic " "relationship) 的強度。" -#: ../../library/statistics.rst:760 +#: ../../library/statistics.rst:752 msgid "" "Spearman's correlation coefficient is appropriate for ordinal data or for " "continuous data that doesn't meet the linear proportion requirement for " @@ -1399,7 +1391,7 @@ msgstr "" "Spearman 相關係數適用於順序型資料,或者不符合 Pearson 相關係數要求的線性比例" "關係的連續型 (continuous) 資料。" -#: ../../library/statistics.rst:764 +#: ../../library/statistics.rst:756 msgid "" "Both inputs must be of the same length (no less than two), and need not to " "be constant, otherwise :exc:`StatisticsError` is raised." @@ -1407,7 +1399,7 @@ msgstr "" "兩輸入必須具有相同長度(至少兩個),且不須為常數,否則會引發 :exc:" "`StatisticsError`。" -#: ../../library/statistics.rst:767 +#: ../../library/statistics.rst:759 msgid "" "Example with `Kepler's laws of planetary motion `_:" @@ -1415,7 +1407,7 @@ msgstr "" "以 `Kepler 行星運動定律 `_\\ 為例:" -#: ../../library/statistics.rst:770 +#: ../../library/statistics.rst:762 msgid "" ">>> # Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune\n" ">>> orbital_period = [88, 225, 365, 687, 4331, 10_756, 30_687, 60_190] # " @@ -1440,11 +1432,11 @@ msgid "" "1.0" msgstr "" -#: ../../library/statistics.rst:794 +#: ../../library/statistics.rst:786 msgid "Added support for Spearman's rank correlation coefficient." msgstr "新增了對 Spearman 等級相關係數的支援。" -#: ../../library/statistics.rst:799 +#: ../../library/statistics.rst:791 msgid "" "Return the slope and intercept of `simple linear regression `_ parameters estimated using " @@ -1458,11 +1450,11 @@ msgstr "" "迴歸描述自變數 (independent variable) *x* 與應變數 (dependent variable) *y* " "之間的關係,用以下的線性函式表示:" -#: ../../library/statistics.rst:805 +#: ../../library/statistics.rst:797 msgid "*y = slope \\* x + intercept + noise*" msgstr "*y = slope \\* x + intercept + noise*" -#: ../../library/statistics.rst:807 +#: ../../library/statistics.rst:799 msgid "" "where ``slope`` and ``intercept`` are the regression parameters that are " "estimated, and ``noise`` represents the variability of the data that was not " @@ -1472,16 +1464,16 @@ msgstr "" "其中 ``slope`` 和 ``intercept`` 是被估計的迴歸參數,而 ``noise`` 表示由線性迴" "歸未解釋的資料變異性(它等於應變數的預測值與實際值之差)。" -#: ../../library/statistics.rst:813 +#: ../../library/statistics.rst:805 msgid "" -"Both inputs must be of the same length (no less than two), and the " +"Both inputs must be sequences of the same length (no less than two), and the " "independent variable *x* cannot be constant; otherwise a :exc:" "`StatisticsError` is raised." msgstr "" -"兩輸入必須具有相同長度(至少兩個),且自變數 *x* 不得為常數,否則會引發 :exc:" -"`StatisticsError`。" +"兩輸入必須是具有相同長度的序列(至少兩個),且自變數 *x* 不得為常數,否則會引" +"發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:817 +#: ../../library/statistics.rst:809 msgid "" "For example, we can use the `release dates of the Monty Python films " "`_ to predict the " @@ -1492,7 +1484,7 @@ msgstr "" "wikipedia.org/wiki/Monty_Python#Films>`_\\ 來預測至 2019 年為止,假設他們保持" "固定的製作速度,應該會產生的 Monty Python 電影的累計數量。" -#: ../../library/statistics.rst:823 +#: ../../library/statistics.rst:815 msgid "" ">>> year = [1971, 1975, 1979, 1982, 1983]\n" ">>> films_total = [1, 2, 3, 4, 5]\n" @@ -1506,7 +1498,7 @@ msgstr "" ">>> round(slope * 2019 + intercept)\n" "16" -#: ../../library/statistics.rst:831 +#: ../../library/statistics.rst:823 msgid "" "If *proportional* is true, the independent variable *x* and the dependent " "variable *y* are assumed to be directly proportional. The data is fit to a " @@ -1517,11 +1509,11 @@ msgstr "" "資料座落在通過原點的一直線上。由於 *intercept* 始終為 0.0,因此線性函式可簡化" "如下:" -#: ../../library/statistics.rst:837 +#: ../../library/statistics.rst:829 msgid "*y = slope \\* x + noise*" msgstr "*y = slope \\* x + noise*" -#: ../../library/statistics.rst:839 +#: ../../library/statistics.rst:831 msgid "" "Continuing the example from :func:`correlation`, we look to see how well a " "model based on major planets can predict the orbital distances for dwarf " @@ -1530,7 +1522,7 @@ msgstr "" "繼續 :func:`correlation` 中的範例,我們看看基於主要行星的模型可以如何很好地預" "測矮行星的軌道距離:" -#: ../../library/statistics.rst:843 +#: ../../library/statistics.rst:835 msgid "" ">>> model = linear_regression(period_squared, dist_cubed, " "proportional=True)\n" @@ -1558,27 +1550,27 @@ msgstr "" ">>> [5_906, 10_152, 6_796, 6_450, 414] # 以百萬公里為單位的實際距離\n" "[5906, 10152, 6796, 6450, 414]" -#: ../../library/statistics.rst:859 +#: ../../library/statistics.rst:851 msgid "Added support for *proportional*." msgstr "新增 *proportional* 的支援。" -#: ../../library/statistics.rst:863 +#: ../../library/statistics.rst:855 msgid "Exceptions" msgstr "例外" -#: ../../library/statistics.rst:865 +#: ../../library/statistics.rst:857 msgid "A single exception is defined:" msgstr "定義了一個單一的例外:" -#: ../../library/statistics.rst:869 +#: ../../library/statistics.rst:861 msgid "Subclass of :exc:`ValueError` for statistics-related exceptions." msgstr ":exc:`ValueError` 的子類別,用於和統計相關的例外。" -#: ../../library/statistics.rst:873 +#: ../../library/statistics.rst:865 msgid ":class:`NormalDist` objects" msgstr ":class:`NormalDist` 物件" -#: ../../library/statistics.rst:875 +#: ../../library/statistics.rst:867 msgid "" ":class:`NormalDist` is a tool for creating and manipulating normal " "distributions of a `random variable `_ 的常態分布的工" "具。它是一個將量測資料的平均數與標準差視為單一實體的類別。" -#: ../../library/statistics.rst:881 +#: ../../library/statistics.rst:873 msgid "" "Normal distributions arise from the `Central Limit Theorem `_ and have a wide range of " @@ -1598,7 +1590,7 @@ msgstr "" "常態分布源自於\\ `中央極限定理 (Central Limit Theorem) `_,在統計學中有著廣泛的應用。" -#: ../../library/statistics.rst:887 +#: ../../library/statistics.rst:879 msgid "" "Returns a new *NormalDist* object where *mu* represents the `arithmetic mean " "`_ and *sigma* represents the " @@ -1608,11 +1600,11 @@ msgstr "" "en.wikipedia.org/wiki/Arithmetic_mean>`_\\ 而 *sigma* 代表\\ `標準差 " "`_。" -#: ../../library/statistics.rst:892 +#: ../../library/statistics.rst:884 msgid "If *sigma* is negative, raises :exc:`StatisticsError`." msgstr "若 *sigma* 為負值,則引發 :exc:`StatisticsError`。" -#: ../../library/statistics.rst:896 +#: ../../library/statistics.rst:888 msgid "" "A read-only property for the `arithmetic mean `_ of a normal distribution." @@ -1620,14 +1612,14 @@ msgstr "" "常態分布中的\\ `算數平均數 `_\\ 唯讀屬性。" -#: ../../library/statistics.rst:902 +#: ../../library/statistics.rst:894 msgid "" "A read-only property for the `median `_ of a normal distribution." msgstr "" "常態分布中的\\ `中位數 `_\\ 唯讀屬性。" -#: ../../library/statistics.rst:908 +#: ../../library/statistics.rst:900 msgid "" "A read-only property for the `mode `_ of a normal distribution." @@ -1635,7 +1627,7 @@ msgstr "" "常態分布中的\\ `眾數 `_\\ 唯" "讀屬性。" -#: ../../library/statistics.rst:914 +#: ../../library/statistics.rst:906 msgid "" "A read-only property for the `standard deviation `_ of a normal distribution." @@ -1643,7 +1635,7 @@ msgstr "" "常態分布中的\\ `標準差 `_\\ 唯讀屬性。" -#: ../../library/statistics.rst:920 +#: ../../library/statistics.rst:912 msgid "" "A read-only property for the `variance `_ of a normal distribution. Equal to the square of the standard " @@ -1652,7 +1644,7 @@ msgstr "" "常態分布中的\\ `變異數 `_\\ 唯讀屬" "性。" -#: ../../library/statistics.rst:926 +#: ../../library/statistics.rst:918 msgid "" "Makes a normal distribution instance with *mu* and *sigma* parameters " "estimated from the *data* using :func:`fmean` and :func:`stdev`." @@ -1660,7 +1652,7 @@ msgstr "" "利用 :func:`fmean` 與 :func:`stdev` 函式,估計 *data* 的 *mu* 與 *sigma* 參" "數,建立一個常態分布的實例。" -#: ../../library/statistics.rst:929 +#: ../../library/statistics.rst:921 msgid "" "The *data* can be any :term:`iterable` and should consist of values that can " "be converted to type :class:`float`. If *data* does not contain at least " @@ -1672,7 +1664,7 @@ msgstr "" "若 *data* 沒有包含至少兩個以上的元素在內,則引發 :exc:`StatisticsError`,因為" "至少需要一個點來估計中央值且至少需要兩個點來估計分散情形。" -#: ../../library/statistics.rst:937 +#: ../../library/statistics.rst:929 msgid "" "Generates *n* random samples for a given mean and standard deviation. " "Returns a :class:`list` of :class:`float` values." @@ -1680,7 +1672,7 @@ msgstr "" "給定平均值與標準差,產生 *n* 個隨機樣本。回傳一個由 :class:`float` 組成的 :" "class:`list`。" -#: ../../library/statistics.rst:940 +#: ../../library/statistics.rst:932 msgid "" "If *seed* is given, creates a new instance of the underlying random number " "generator. This is useful for creating reproducible results, even in a " @@ -1689,13 +1681,13 @@ msgstr "" "若有給定 *seed*,則會建立一個以此為基礎的亂數產生器實例。這對於建立可重現的結" "果很有幫助,即使在多執行緒情境下也是如此。" -#: ../../library/statistics.rst:946 +#: ../../library/statistics.rst:938 msgid "" "Switched to a faster algorithm. To reproduce samples from previous " "versions, use :func:`random.seed` and :func:`random.gauss`." msgstr "" -#: ../../library/statistics.rst:951 +#: ../../library/statistics.rst:943 msgid "" "Using a `probability density function (pdf) `_, compute the relative likelihood that a " @@ -1707,7 +1699,7 @@ msgstr "" "值 *x* 的相對概度 (relative likelihood)。數學上,它是比率 ``P(x <= X < " "x+dx) / dx`` 在 *dx* 趨近於零時的極限值。" -#: ../../library/statistics.rst:957 +#: ../../library/statistics.rst:949 msgid "" "The relative likelihood is computed as the probability of a sample occurring " "in a narrow range divided by the width of the range (hence the word " @@ -1717,7 +1709,7 @@ msgstr "" "相對概度是樣本出現在狹窄範圍的機率,除以該範圍的寬度(故稱為「密度」)計算而" "得。由於概度是相對於其它點,故其值可大於 ``1.0``。" -#: ../../library/statistics.rst:964 +#: ../../library/statistics.rst:956 msgid "" "Using a `cumulative distribution function (cdf) `_, compute the probability that a " @@ -1728,7 +1720,7 @@ msgstr "" "wikipedia.org/wiki/Cumulative_distribution_function>`_ 計算隨機變數 *X* 小於" "或等於 *x* 的機率。數學上,它記為 ``P(X <= x)``。" -#: ../../library/statistics.rst:971 +#: ../../library/statistics.rst:963 msgid "" "Compute the inverse cumulative distribution function, also known as the " "`quantile function `_ or " @@ -1742,7 +1734,7 @@ msgstr "" "org/web/20190203145224/https://www.statisticshowto.datasciencecentral.com/" "inverse-distribution-function/>`_ 函式。數學上記為 ``x : P(X <= x) = p``。" -#: ../../library/statistics.rst:977 +#: ../../library/statistics.rst:969 msgid "" "Finds the value *x* of the random variable *X* such that the probability of " "the variable being less than or equal to that value equals the given " @@ -1750,7 +1742,7 @@ msgid "" msgstr "" "找出一個值 *x*,使得隨機變數 *X* 小於或等於該值的機率等於給定的機率 *p*。" -#: ../../library/statistics.rst:983 +#: ../../library/statistics.rst:975 msgid "" "Measures the agreement between two normal probability distributions. Returns " "a value between 0.0 and 1.0 giving `the overlapping area for the two " @@ -1759,7 +1751,7 @@ msgstr "" "衡量兩常態分布之間的一致性。回傳一個介於 0.0 與 1.0 之間的值,表示\\ `兩機率" "密度函式的重疊區域 `_。" -#: ../../library/statistics.rst:990 +#: ../../library/statistics.rst:982 msgid "" "Divide the normal distribution into *n* continuous intervals with equal " "probability. Returns a list of (n - 1) cut points separating the intervals." @@ -1767,7 +1759,7 @@ msgstr "" "將常態分布分割成 *n* 個具有相等機率的連續區間。回傳一個 list,包含 (n-1) 個切" "割區間的分隔點。" -#: ../../library/statistics.rst:994 +#: ../../library/statistics.rst:986 msgid "" "Set *n* to 4 for quartiles (the default). Set *n* to 10 for deciles. Set " "*n* to 100 for percentiles which gives the 99 cuts points that separate the " @@ -1777,7 +1769,7 @@ msgstr "" "*n* 設定為 100 表示百分位數,這會產生 99 個分隔點,將常態分布切割成大小相等的" "群組。" -#: ../../library/statistics.rst:1000 +#: ../../library/statistics.rst:992 msgid "" "Compute the `Standard Score `_ describing *x* in terms of the number of standard " @@ -1788,7 +1780,7 @@ msgstr "" "probability-and-statistics/z-score/>`_,用以描述在常態分布中,*x* 高出或低於" "平均數幾個標準差:``(x - mean) / stdev``。" -#: ../../library/statistics.rst:1008 +#: ../../library/statistics.rst:1000 msgid "" "Instances of :class:`NormalDist` support addition, subtraction, " "multiplication and division by a constant. These operations are used for " @@ -1797,7 +1789,7 @@ msgstr "" ":class:`NormalDist` 的實例支援對常數的加法、減法、乘法與除法。這些操作用於平" "移與縮放。例如:" -#: ../../library/statistics.rst:1012 +#: ../../library/statistics.rst:1004 msgid "" ">>> temperature_february = NormalDist(5, 2.5) # Celsius\n" ">>> temperature_february * (9/5) + 32 # Fahrenheit\n" @@ -1807,14 +1799,14 @@ msgstr "" ">>> temperature_february * (9/5) + 32 # 華氏\n" "NormalDist(mu=41.0, sigma=4.5)" -#: ../../library/statistics.rst:1018 +#: ../../library/statistics.rst:1010 msgid "" "Dividing a constant by an instance of :class:`NormalDist` is not supported " "because the result wouldn't be normally distributed." msgstr "" "不支援將常數除以 :class:`NormalDist` 的實例,因為結果將不符合常態分布。" -#: ../../library/statistics.rst:1021 +#: ../../library/statistics.rst:1013 msgid "" "Since normal distributions arise from additive effects of independent " "variables, it is possible to `add and subtract two independent normally " @@ -1827,7 +1819,7 @@ msgstr "" "Sum_of_normally_distributed_random_variables>`_,並且表示為 :class:" "`NormalDist` 的實例。例如:" -#: ../../library/statistics.rst:1027 +#: ../../library/statistics.rst:1019 msgid "" ">>> birth_weights = NormalDist.from_samples([2.5, 3.1, 2.1, 2.4, 2.7, 3.5])\n" ">>> drug_effects = NormalDist(0.4, 0.15)\n" @@ -1845,19 +1837,19 @@ msgstr "" ">>> round(combined.stdev, 1)\n" "0.5" -#: ../../library/statistics.rst:1041 +#: ../../library/statistics.rst:1033 msgid "Examples and Recipes" msgstr "範例與錦囊妙計" -#: ../../library/statistics.rst:1045 +#: ../../library/statistics.rst:1037 msgid "Classic probability problems" msgstr "經典機率問題" -#: ../../library/statistics.rst:1047 +#: ../../library/statistics.rst:1039 msgid ":class:`NormalDist` readily solves classic probability problems." msgstr ":class:`NormalDist` 可以輕易地解決經典的機率問題。" -#: ../../library/statistics.rst:1049 +#: ../../library/statistics.rst:1041 msgid "" "For example, given `historical data for SAT exams `_ showing that scores are " @@ -1869,7 +1861,7 @@ msgstr "" "tables/dt17_226.40.asp>`_,顯示成績為平均 1060、標準差 195 的常態分布。我們要" "求出分數在 1100 與 1200 之間(四捨五入至最接近的整數)的學生的百分比:" -#: ../../library/statistics.rst:1055 +#: ../../library/statistics.rst:1047 msgid "" ">>> sat = NormalDist(1060, 195)\n" ">>> fraction = sat.cdf(1200 + 0.5) - sat.cdf(1100 - 0.5)\n" @@ -1881,7 +1873,7 @@ msgstr "" ">>> round(fraction * 100.0, 1)\n" "18.4" -#: ../../library/statistics.rst:1062 +#: ../../library/statistics.rst:1054 msgid "" "Find the `quartiles `_ and `deciles " "`_ for the SAT scores:" @@ -1889,7 +1881,7 @@ msgstr "" "找出 SAT 分數的\\ `四分位數 `_\\ 以及" "\\ `十分位數 `_:" -#: ../../library/statistics.rst:1065 +#: ../../library/statistics.rst:1057 msgid "" ">>> list(map(round, sat.quantiles()))\n" "[928, 1060, 1192]\n" @@ -1901,11 +1893,11 @@ msgstr "" ">>> list(map(round, sat.quantiles(n=10)))\n" "[810, 896, 958, 1011, 1060, 1109, 1162, 1224, 1310]" -#: ../../library/statistics.rst:1074 +#: ../../library/statistics.rst:1066 msgid "Monte Carlo inputs for simulations" msgstr "用於模擬的蒙地卡羅 (Monte Carlo) 輸入" -#: ../../library/statistics.rst:1076 +#: ../../library/statistics.rst:1068 msgid "" "To estimate the distribution for a model that isn't easy to solve " "analytically, :class:`NormalDist` can generate input samples for a `Monte " @@ -1915,7 +1907,7 @@ msgstr "" "樣本以進行\\ `蒙地卡羅模擬 `_:" -#: ../../library/statistics.rst:1080 +#: ../../library/statistics.rst:1072 msgid "" ">>> def model(x, y, z):\n" "... return (3*x + 7*x*y - 5*y) / (11 * z)\n" @@ -1937,11 +1929,11 @@ msgstr "" ">>> quantiles(map(model, X, Y, Z))\n" "[1.4591308524824727, 1.8035946855390597, 2.175091447274739]" -#: ../../library/statistics.rst:1093 +#: ../../library/statistics.rst:1085 msgid "Approximating binomial distributions" msgstr "近似二項分布" -#: ../../library/statistics.rst:1095 +#: ../../library/statistics.rst:1087 msgid "" "Normal distributions can be used to approximate `Binomial distributions " "`_ when the sample " @@ -1951,7 +1943,7 @@ msgstr "" "(Binomial distributions) `_。" -#: ../../library/statistics.rst:1100 +#: ../../library/statistics.rst:1092 msgid "" "For example, an open source conference has 750 attendees and two rooms with " "a 500 person capacity. There is a talk about Python and another about Ruby. " @@ -1964,7 +1956,7 @@ msgstr "" "向參與 Python 講座。假設參與者的偏好沒有改變,那麼 Python 會議室未超過自身容" "量限制的機率是?" -#: ../../library/statistics.rst:1106 +#: ../../library/statistics.rst:1098 msgid "" ">>> n = 750 # Sample size\n" ">>> p = 0.65 # Preference for Python\n" @@ -1988,15 +1980,15 @@ msgid "" "0.8406" msgstr "" -#: ../../library/statistics.rst:1131 +#: ../../library/statistics.rst:1123 msgid "Naive bayesian classifier" msgstr "單純貝氏分類器 (Naive bayesian classifier)" -#: ../../library/statistics.rst:1133 +#: ../../library/statistics.rst:1125 msgid "Normal distributions commonly arise in machine learning problems." msgstr "常態分布常在機器學習問題中出現。" -#: ../../library/statistics.rst:1135 +#: ../../library/statistics.rst:1127 msgid "" "Wikipedia has a `nice example of a Naive Bayesian Classifier `_. The " @@ -2007,7 +1999,7 @@ msgstr "" "wiki/Naive_Bayes_classifier#Person_classification>`_。課題為從身高、體重與鞋" "子尺寸等符合常態分布的特徵量測值中判斷一個人的性別。" -#: ../../library/statistics.rst:1140 +#: ../../library/statistics.rst:1132 msgid "" "We're given a training dataset with measurements for eight people. The " "measurements are assumed to be normally distributed, so we summarize the " @@ -2016,7 +2008,7 @@ msgstr "" "給定一組包含八個人的量測值的訓練資料集。假設這些量測值服從常態分布,我們可以" "利用 :class:`NormalDist` 來總結資料:" -#: ../../library/statistics.rst:1144 +#: ../../library/statistics.rst:1136 msgid "" ">>> height_male = NormalDist.from_samples([6, 5.92, 5.58, 5.92])\n" ">>> height_female = NormalDist.from_samples([5, 5.5, 5.42, 5.75])\n" @@ -2032,20 +2024,20 @@ msgstr "" ">>> foot_size_male = NormalDist.from_samples([12, 11, 12, 10])\n" ">>> foot_size_female = NormalDist.from_samples([6, 8, 7, 9])" -#: ../../library/statistics.rst:1153 +#: ../../library/statistics.rst:1145 msgid "" "Next, we encounter a new person whose feature measurements are known but " "whose gender is unknown:" msgstr "接著,我們遇到一個新的人,他的特徵量測值已知,但性別未知:" -#: ../../library/statistics.rst:1156 +#: ../../library/statistics.rst:1148 msgid "" ">>> ht = 6.0 # height\n" ">>> wt = 130 # weight\n" ">>> fs = 8 # foot size" msgstr "" -#: ../../library/statistics.rst:1162 +#: ../../library/statistics.rst:1154 msgid "" "Starting with a 50% `prior probability `_ of being male or female, we compute the posterior as " @@ -2056,7 +2048,7 @@ msgstr "" "org/wiki/Prior_probability>`_ 為開端,我們將後驗機率 (posterior probability) " "計算為先驗機率乘以給定性別下,各特徵量測值的概度乘積:" -#: ../../library/statistics.rst:1167 +#: ../../library/statistics.rst:1159 msgid "" ">>> prior_male = 0.5\n" ">>> prior_female = 0.5\n" @@ -2074,7 +2066,7 @@ msgstr "" ">>> posterior_female = (prior_female * height_female.pdf(ht) *\n" "... weight_female.pdf(wt) * foot_size_female.pdf(fs))" -#: ../../library/statistics.rst:1177 +#: ../../library/statistics.rst:1169 msgid "" "The final prediction goes to the largest posterior. This is known as the " "`maximum a posteriori `_ 或者 MAP:" -#: ../../library/statistics.rst:1181 +#: ../../library/statistics.rst:1173 msgid "" ">>> 'male' if posterior_male > posterior_female else 'female'\n" "'female'" diff --git a/library/stringprep.po b/library/stringprep.po index f34b6590c50..0a9e42e5d72 100644 --- a/library/stringprep.po +++ b/library/stringprep.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-02-17 00:34+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!stringprep` --- Internet String Preparation" msgstr ":mod:`!stringprep` --- 網際網路字串的準備" -#: ../../library/stringprep.rst:10 +#: ../../library/stringprep.rst:7 msgid "**Source code:** :source:`Lib/stringprep.py`" msgstr "**原始碼:**\\ :source:`Lib/stringprep.py`" -#: ../../library/stringprep.rst:14 +#: ../../library/stringprep.rst:11 msgid "" "When identifying things (such as host names) in the internet, it is often " "necessary to compare such identifications for \"equality\". Exactly how this " @@ -41,7 +41,7 @@ msgstr "" "小寫。也可能有必要限制可能的識別器,只允許由「可列印 (printable)」字元組成的" "識別器。" -#: ../../library/stringprep.rst:21 +#: ../../library/stringprep.rst:18 msgid "" ":rfc:`3454` defines a procedure for \"preparing\" Unicode strings in " "internet protocols. Before passing strings onto the wire, they are processed " @@ -58,7 +58,7 @@ msgstr "" "定義它使用哪些表以及 ``stringprep`` 程序的哪些其他可選部分是設定檔的一部分。" "``stringprep`` 配置文件的一個例子是 ``nameprep``,它被用於國際化網域名稱。" -#: ../../library/stringprep.rst:29 +#: ../../library/stringprep.rst:26 msgid "" "The module :mod:`!stringprep` only exposes the tables from :rfc:`3454`. As " "these tables would be very large to represent as dictionaries or lists, the " @@ -69,7 +69,7 @@ msgstr "" "方式來表示的話會非常大,因此模組內部使用 Unicode 字元資料庫。模組原始碼本身是" "使用 ``mkstringprep.py`` 工具來產生的。" -#: ../../library/stringprep.rst:34 +#: ../../library/stringprep.rst:31 msgid "" "As a result, these tables are exposed as functions, not as data structures. " "There are two kinds of tables in the RFC: sets and mappings. For a set, :mod:" @@ -83,7 +83,7 @@ msgstr "" "function)」,也就是如果參數是集合的一部分就回傳 ``True`` 的函式。對於對映,它" "提供了對映函式:給定鍵,它會回傳相關的值。以下是模組中所有可用函式的清單。" -#: ../../library/stringprep.rst:44 +#: ../../library/stringprep.rst:41 msgid "" "Determine whether *code* is in tableA.1 (Unassigned code points in Unicode " "3.2)." @@ -91,11 +91,11 @@ msgstr "" "判斷 *code* 是否在 tableA.1(Unicode 3.2 中未指定的編碼位置 (code point))" "中。" -#: ../../library/stringprep.rst:49 +#: ../../library/stringprep.rst:46 msgid "Determine whether *code* is in tableB.1 (Commonly mapped to nothing)." msgstr "判斷 *code* 是否在 tableB.1(通常沒有對映到任何東西)中。" -#: ../../library/stringprep.rst:54 +#: ../../library/stringprep.rst:51 msgid "" "Return the mapped value for *code* according to tableB.2 (Mapping for case-" "folding used with NFKC)." @@ -103,60 +103,60 @@ msgstr "" "根據 tableB.2(使用 NFKC 形式的大小寫折疊 (case-folding) 對映)回傳 *code* 的" "對映值。" -#: ../../library/stringprep.rst:60 +#: ../../library/stringprep.rst:57 msgid "" "Return the mapped value for *code* according to tableB.3 (Mapping for case-" "folding used with no normalization)." msgstr "根據 tableB.3(使用沒有規範化的大小寫折疊對映)回傳 *code* 的對映值。" -#: ../../library/stringprep.rst:66 +#: ../../library/stringprep.rst:63 msgid "Determine whether *code* is in tableC.1.1 (ASCII space characters)." msgstr "判斷 *code* 是否在 tableC.1.1(ASCII 空格字元)中。" -#: ../../library/stringprep.rst:71 +#: ../../library/stringprep.rst:68 msgid "" "Determine whether *code* is in tableC.1.2 (Non-ASCII space characters)." msgstr "判斷 *code* 是否在 tableC.1.2(非 ASCII 空格字元)中。" -#: ../../library/stringprep.rst:76 +#: ../../library/stringprep.rst:73 msgid "" "Determine whether *code* is in tableC.1 (Space characters, union of C.1.1 " "and C.1.2)." msgstr "判斷 *code* 是否在 tableC.1(空格字元,為 C.1.1 和 C.1.2 的聯集)中。" -#: ../../library/stringprep.rst:82 +#: ../../library/stringprep.rst:79 msgid "Determine whether *code* is in tableC.2.1 (ASCII control characters)." msgstr "判斷 *code* 是否在 tableC.2.1(ASCII 控制字元)中。" -#: ../../library/stringprep.rst:87 +#: ../../library/stringprep.rst:84 msgid "" "Determine whether *code* is in tableC.2.2 (Non-ASCII control characters)." msgstr "判斷 *code* 是否在 tableC.2.2(非 ASCII 控制字元)中。" -#: ../../library/stringprep.rst:92 +#: ../../library/stringprep.rst:89 msgid "" "Determine whether *code* is in tableC.2 (Control characters, union of C.2.1 " "and C.2.2)." msgstr "判斷 *code* 是否在 tableC.2(控制字元,為 C.2.1 和 C.2.2 的聯集)中。" -#: ../../library/stringprep.rst:98 +#: ../../library/stringprep.rst:95 msgid "Determine whether *code* is in tableC.3 (Private use)." msgstr "判斷 *code* 是否在 tableC.3(私有使用)中。" -#: ../../library/stringprep.rst:103 +#: ../../library/stringprep.rst:100 msgid "Determine whether *code* is in tableC.4 (Non-character code points)." msgstr "判斷 *code* 是否在 tableC.4(非字元編碼位置)中。" -#: ../../library/stringprep.rst:108 +#: ../../library/stringprep.rst:105 msgid "Determine whether *code* is in tableC.5 (Surrogate codes)." msgstr "判斷 *code* 是否在 tableC.5(代理碼)中。" -#: ../../library/stringprep.rst:113 +#: ../../library/stringprep.rst:110 msgid "" "Determine whether *code* is in tableC.6 (Inappropriate for plain text)." msgstr "判斷 *code* 是否在 tableC.6(不適用於純文字)中。" -#: ../../library/stringprep.rst:118 +#: ../../library/stringprep.rst:115 msgid "" "Determine whether *code* is in tableC.7 (Inappropriate for canonical " "representation)." @@ -164,23 +164,23 @@ msgstr "" "判斷 *code* 是否在 tableC.7(不適用於規範表示法 (canonical representation))" "中。" -#: ../../library/stringprep.rst:124 +#: ../../library/stringprep.rst:121 msgid "" "Determine whether *code* is in tableC.8 (Change display properties or are " "deprecated)." msgstr "判斷 *code* 是否在 tableC.8(變更顯示屬性或已棄用)中。" -#: ../../library/stringprep.rst:130 +#: ../../library/stringprep.rst:127 msgid "Determine whether *code* is in tableC.9 (Tagging characters)." msgstr "判斷 *code* 是否在 tableC.9(標記字元 (tagging characters))中。" -#: ../../library/stringprep.rst:135 +#: ../../library/stringprep.rst:132 msgid "" "Determine whether *code* is in tableD.1 (Characters with bidirectional " "property \"R\" or \"AL\")." msgstr "判斷 *code* 是否在 tableD.1(具有雙向屬性 \"R\" 或 \"AL\" 的字元)中。" -#: ../../library/stringprep.rst:141 +#: ../../library/stringprep.rst:138 msgid "" "Determine whether *code* is in tableD.2 (Characters with bidirectional " "property \"L\")." diff --git a/library/struct.po b/library/struct.po index 9cddbc4a5c1..ee547822c85 100644 --- a/library/struct.po +++ b/library/struct.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-16 00:27+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:11+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -337,7 +337,7 @@ msgstr "" "沒有方法來指示非原生位元組順序(強制位元組交換);請使用適當的 ``'<'`` 或 " "``'>'`` 選擇。" -#: ../../library/struct.rst:200 ../../library/struct.rst:292 +#: ../../library/struct.rst:200 ../../library/struct.rst:296 msgid "Notes:" msgstr "註解:" @@ -623,8 +623,8 @@ msgid ":c:expr:`double`" msgstr ":c:expr:`double`" #: ../../library/struct.rst:265 -msgid "``F``" -msgstr "``F``" +msgid "``Zf``" +msgstr "``Zf``" #: ../../library/struct.rst:265 msgid ":c:expr:`float complex`" @@ -639,8 +639,8 @@ msgid "\\(10)" msgstr "\\(10)" #: ../../library/struct.rst:267 -msgid "``D``" -msgstr "``D``" +msgid "``Zd``" +msgstr "``Zd``" #: ../../library/struct.rst:267 msgid ":c:expr:`double complex`" @@ -698,7 +698,15 @@ msgstr "新增 ``'e'`` 格式的支援。" msgid "Added support for the ``'F'`` and ``'D'`` formats." msgstr "新增 ``'F'`` 與 ``'D'`` 格式的支援。" -#: ../../library/struct.rst:287 +#: ../../library/struct.rst:285 +msgid "" +"Added support for the ``'Zf'`` and ``'Zd'`` formats. ``'F'`` and ``'D'`` " +"formats are :term:`soft deprecated`." +msgstr "" +"新增 ``'Zf'`` 與 ``'Zd'`` 格式的支援。``'F'`` 與 ``'D'`` 格式已被\\ :term:`軟" +"性棄用 `。" + +#: ../../library/struct.rst:291 msgid "" "The :mod:`array` and :ref:`ctypes ` modules, " "as well as third-party modules like `numpy `_. It has a sign " @@ -781,11 +789,11 @@ msgstr "" "可以用於儲存但不能用於數學運算。請參見 Wikipedia 上的\\ `半精度浮點數格式 " "`_\\ 頁面以取得更多資訊。" -#: ../../library/struct.rst:341 +#: ../../library/struct.rst:345 msgid "When packing, ``'x'`` inserts one NUL byte." msgstr "打包時,``'x'`` 插入一個 NUL 位元組。" -#: ../../library/struct.rst:344 +#: ../../library/struct.rst:348 msgid "" "The ``'p'`` format character encodes a \"Pascal string\", meaning a short " "variable-length string stored in a *fixed number of bytes*, given by the " @@ -808,7 +816,7 @@ msgstr "" "`!bytes` 物件永遠不能包含超過 255 個位元組。打包時,接受 :class:`bytes` 和 :" "class:`bytearray` 型別的引數。" -#: ../../library/struct.rst:358 +#: ../../library/struct.rst:362 msgid "" "For the ``'s'`` format character, the count is interpreted as the length of " "the byte string, not a repeat count like for the other format characters; " @@ -833,22 +841,24 @@ msgstr "" "的位元組數。作為特殊情況,``'0s'`` 表示單一空位元組字串(而 ``'0c'`` 表示 0 " "個字元)。打包時,接受 :class:`bytes` 和 :class:`bytearray` 型別的引數。" -#: ../../library/struct.rst:374 +#: ../../library/struct.rst:378 msgid "" -"For the ``'F'`` and ``'D'`` format characters, the packed representation " -"uses the IEEE 754 binary32 and binary64 format for components of the complex " -"number, regardless of the floating-point format used by the platform. Note " -"that complex types (``F`` and ``D``) are available unconditionally, despite " -"complex types being an optional feature in C. As specified in the C11 " -"standard, each complex type is represented by a two-element C array " -"containing, respectively, the real and imaginary parts." +"For the ``'Zf'`` and ``'Zd'`` type codes, the packed representation uses the " +"IEEE 754 binary32 and binary64 format for components of the complex number, " +"regardless of the floating-point format used by the platform. Note that " +"complex types are available unconditionally, despite complex types being an " +"optional feature in C. As specified in the C11 standard, each complex type " +"is represented by a two-element C array containing, respectively, the real " +"and imaginary parts. The ``'F'`` and ``'D'`` (for ``'Zf'`` and ``'Zd'``, " +"respectively) format characters are supported for compatibility." msgstr "" -"``'F'`` 和 ``'D'`` 格式字元的封裝表示法會以 IEEE 754 binary32 及 binary64 格" +"``'Zf'`` 和 ``'Zd'`` 型別碼的封裝表示法會以 IEEE 754 binary32 及 binary64 格" "式處理複數的實部與虛部,與平台所使用的浮點數格式無關。請注意,即使複數型別在 " -"C 中屬於可選功能,``F`` 和 ``D`` 仍然可以無條件使用。根據 C11 標準,每個複數" -"型別由一個含有二個元素的 C 陣列表示,分別存放實部與虛部。" +"C 中屬於可選功能,複數型別仍然可以無條件使用。根據 C11 標準,每個複數型別由一" +"個含有二個元素的 C 陣列表示,分別存放實部與虛部。為了相容性,也支援 ``'F'`` " +"和 ``'D'``\\ (分別對應 ``'Zf'`` 和 ``'Zd'``)格式字元。" -#: ../../library/struct.rst:383 +#: ../../library/struct.rst:389 msgid "" "A format character may be preceded by an integral repeat count. For " "example, the format string ``'4h'`` means exactly the same as ``'hhhh'``." @@ -856,13 +866,13 @@ msgstr "" "格式字元前面可以加上整數重複次數。例如,格式字串 ``'4h'`` 與 ``'hhhh'`` 意思" "完全相同。" -#: ../../library/struct.rst:386 +#: ../../library/struct.rst:392 msgid "" "Whitespace characters between formats are ignored; a count and its format " "must not contain whitespace though." msgstr "格式之間的空白字元會被忽略;但是計數和其格式不能包含空白字元。" -#: ../../library/struct.rst:389 +#: ../../library/struct.rst:395 msgid "" "When packing a value ``x`` using one of the integer formats (``'b'``, " "``'B'``, ``'h'``, ``'H'``, ``'i'``, ``'I'``, ``'l'``, ``'L'``, ``'q'``, " @@ -873,7 +883,7 @@ msgstr "" "``'l'``、``'L'``、``'q'``、``'Q'``)打包數值 ``x`` 時,如果 ``x`` 超出該格式" "的有效範圍,則會觸發 :exc:`struct.error`。" -#: ../../library/struct.rst:394 +#: ../../library/struct.rst:400 msgid "" "Previously, some of the integer formats wrapped out-of-range values and " "raised :exc:`DeprecationWarning` instead of :exc:`struct.error`." @@ -881,7 +891,7 @@ msgstr "" "以前一些整數格式會環繞超出範圍的數值並引發 :exc:`DeprecationWarning` 而不是 :" "exc:`struct.error`。" -#: ../../library/struct.rst:400 +#: ../../library/struct.rst:406 msgid "" "For the ``'?'`` format character, the return value is either :const:`True` " "or :const:`False`. When packing, the truth value of the argument object is " @@ -892,11 +902,11 @@ msgstr "" "引數物件的真值。原生或標準布林值表示法中的 0 或 1 將被打包,解包時任何非零值" "都將為 ``True``。" -#: ../../library/struct.rst:410 +#: ../../library/struct.rst:416 msgid "Examples" msgstr "範例" -#: ../../library/struct.rst:413 +#: ../../library/struct.rst:419 msgid "" "Native byte order examples (designated by the ``'@'`` format prefix or lack " "of any prefix character) may not match what the reader's machine produces as " @@ -905,13 +915,13 @@ msgstr "" "原生位元組順序範例(由 ``'@'`` 格式前綴或缺少任何前綴字元指定)可能與讀者機器" "產生的結果不符,因為這取決於平台和編譯器。" -#: ../../library/struct.rst:418 +#: ../../library/struct.rst:424 msgid "" "Pack and unpack integers of three different sizes, using big endian " "ordering::" msgstr "使用大端序打包和解包三種不同大小的整數: ::" -#: ../../library/struct.rst:421 +#: ../../library/struct.rst:427 msgid "" ">>> from struct import *\n" ">>> pack(\">bhl\", 1, 2, 3)\n" @@ -929,11 +939,11 @@ msgstr "" ">>> calcsize('>bhl')\n" "7" -#: ../../library/struct.rst:429 +#: ../../library/struct.rst:435 msgid "Attempt to pack an integer which is too large for the defined field::" msgstr "嘗試打包對於定義欄位來說太大的整數: ::" -#: ../../library/struct.rst:431 +#: ../../library/struct.rst:437 msgid "" ">>> pack(\">h\", 99999)\n" "Traceback (most recent call last):\n" @@ -945,12 +955,12 @@ msgstr "" " File \"\", line 1, in \n" "struct.error: 'h' format requires -32768 <= number <= 32767" -#: ../../library/struct.rst:436 +#: ../../library/struct.rst:442 msgid "" "Demonstrate the difference between ``'s'`` and ``'c'`` format characters::" msgstr "示範 ``'s'`` 和 ``'c'`` 格式字元之間的差異: ::" -#: ../../library/struct.rst:439 +#: ../../library/struct.rst:445 msgid "" ">>> pack(\"@ccc\", b'1', b'2', b'3')\n" "b'123'\n" @@ -962,13 +972,13 @@ msgstr "" ">>> pack(\"@3s\", b'123')\n" "b'123'" -#: ../../library/struct.rst:444 +#: ../../library/struct.rst:450 msgid "" "Unpacked fields can be named by assigning them to variables or by wrapping " "the result in a named tuple::" msgstr "解包的欄位可以透過將其指派給變數或將結果包裝在具名元組中來命名: ::" -#: ../../library/struct.rst:447 +#: ../../library/struct.rst:453 msgid "" ">>> record = b'raymond \\x32\\x12\\x08\\x01\\x08'\n" ">>> name, serialnum, school, gradelevel = unpack('<10sHHb', record)\n" @@ -986,7 +996,7 @@ msgstr "" ">>> Student._make(unpack('<10sHHb', record))\n" "Student(name=b'raymond ', serialnum=4658, school=264, gradelevel=8)" -#: ../../library/struct.rst:455 +#: ../../library/struct.rst:461 msgid "" "The ordering of format characters may have an impact on size in native mode " "since padding is implicit. In standard mode, the user is responsible for " @@ -1000,7 +1010,7 @@ msgstr "" "``'#'`` 之後加入了三個 NUL 位元組,以將後續整數對齊到四位元組邊界。在此範例" "中,輸出是在小端序機器上產生的: ::" -#: ../../library/struct.rst:463 +#: ../../library/struct.rst:469 msgid "" ">>> pack('@ci', b'#', 0x12131415)\n" "b'#\\x00\\x00\\x00\\x15\\x14\\x13\\x12'\n" @@ -1020,7 +1030,7 @@ msgstr "" ">>> calcsize('@ic')\n" "5" -#: ../../library/struct.rst:472 +#: ../../library/struct.rst:478 msgid "" "The following format ``'llh0l'`` results in two pad bytes being added at the " "end, assuming the platform's longs are aligned on 4-byte boundaries::" @@ -1028,7 +1038,7 @@ msgstr "" "假設平台的 long 對齊到 4 位元組邊界,以下格式 ``'llh0l'`` 會在結尾加入兩個填" "充位元組: ::" -#: ../../library/struct.rst:475 +#: ../../library/struct.rst:481 msgid "" ">>> pack('@llh0l', 1, 2, 3)\n" "b'\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x03\\x00\\x00'" @@ -1036,35 +1046,35 @@ msgstr "" ">>> pack('@llh0l', 1, 2, 3)\n" "b'\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x03\\x00\\x00'" -#: ../../library/struct.rst:481 +#: ../../library/struct.rst:487 msgid "Module :mod:`array`" msgstr ":mod:`array` 模組" -#: ../../library/struct.rst:482 +#: ../../library/struct.rst:488 msgid "Packed binary storage of homogeneous data." msgstr "同質資料的打包二進位儲存。" -#: ../../library/struct.rst:484 +#: ../../library/struct.rst:490 msgid "Module :mod:`json`" msgstr ":mod:`json` 模組" -#: ../../library/struct.rst:485 +#: ../../library/struct.rst:491 msgid "JSON encoder and decoder." msgstr "JSON 編碼器和解碼器。" -#: ../../library/struct.rst:487 +#: ../../library/struct.rst:493 msgid "Module :mod:`pickle`" msgstr ":mod:`pickle` 模組" -#: ../../library/struct.rst:488 +#: ../../library/struct.rst:494 msgid "Python object serialization." msgstr "Python 物件序列化。" -#: ../../library/struct.rst:494 +#: ../../library/struct.rst:500 msgid "Applications" msgstr "應用" -#: ../../library/struct.rst:496 +#: ../../library/struct.rst:502 msgid "" "Two main applications for the :mod:`!struct` module exist, data interchange " "between Python and C code within an application or another application " @@ -1079,11 +1089,11 @@ msgstr "" "格式 `)。一般來說,為這兩個領域建構的格式字串是不同" "的。" -#: ../../library/struct.rst:507 +#: ../../library/struct.rst:513 msgid "Native Formats" msgstr "原生格式" -#: ../../library/struct.rst:509 +#: ../../library/struct.rst:515 msgid "" "When constructing format strings which mimic native layouts, the compiler " "and machine architecture determine byte ordering and padding. In such cases, " @@ -1098,12 +1108,12 @@ msgstr "" "組通常會自動插入。可能需要在格式字串的結尾使用零重複格式碼來向上舍入到正確的" "位元組邊界,以便正確對齊連續的資料區塊 (chunks)。" -#: ../../library/struct.rst:517 +#: ../../library/struct.rst:523 msgid "" "Consider these two simple examples (on a 64-bit, little-endian machine)::" msgstr "考慮這兩個簡單範例(在 64 位元小端序機器上): ::" -#: ../../library/struct.rst:520 +#: ../../library/struct.rst:526 msgid "" ">>> calcsize('@lhl')\n" "24\n" @@ -1115,7 +1125,7 @@ msgstr "" ">>> calcsize('@llh')\n" "18" -#: ../../library/struct.rst:525 +#: ../../library/struct.rst:531 msgid "" "Data is not padded to an 8-byte boundary at the end of the second format " "string without the use of extra padding. A zero-repeat format code solves " @@ -1124,7 +1134,7 @@ msgstr "" "在第二個格式字串的結尾,如果不使用額外填充,資料不會填充到 8 位元組邊界。零重" "複格式碼解決了這個問題: ::" -#: ../../library/struct.rst:529 +#: ../../library/struct.rst:535 msgid "" ">>> calcsize('@llh0l')\n" "24" @@ -1132,7 +1142,7 @@ msgstr "" ">>> calcsize('@llh0l')\n" "24" -#: ../../library/struct.rst:532 +#: ../../library/struct.rst:538 msgid "" "The ``'x'`` format code can be used to specify the repeat, but for native " "formats it is better to use a zero-repeat format like ``'0l'``." @@ -1140,17 +1150,17 @@ msgstr "" "``'x'`` 格式碼可以用來指定重複,但對於原生格式來說最好使用像 ``'0l'`` 這樣的" "零重複格式。" -#: ../../library/struct.rst:535 +#: ../../library/struct.rst:541 msgid "" "By default, native byte ordering and alignment is used, but it is better to " "be explicit and use the ``'@'`` prefix character." msgstr "預設使用原生位元組順序和對齊,但最好明確使用 ``'@'`` 前綴字元。" -#: ../../library/struct.rst:542 +#: ../../library/struct.rst:548 msgid "Standard Formats" msgstr "標準格式" -#: ../../library/struct.rst:544 +#: ../../library/struct.rst:550 msgid "" "When exchanging data beyond your process such as networking or storage, be " "precise. Specify the exact byte order, size, and alignment. Do not assume " @@ -1170,7 +1180,7 @@ msgstr "" "計師的責任。零重複格式字元不會起作用。取而代之的是使用者必須在需要的地方明確" "加入 ``'x'`` 填充位元組。重新檢視上一節的範例,我們有: ::" -#: ../../library/struct.rst:556 +#: ../../library/struct.rst:562 msgid "" ">>> calcsize('>> pack('@llh0l', 1, 2, 3) == pack('>> calcsize('>> pack('@llh0l', 1, 2, 3) == pack(' (大於)" msgid "! (exclamation)" msgstr "! (驚嘆號)" -#: ../../library/struct.rst:295 ../../library/struct.rst:398 +#: ../../library/struct.rst:299 ../../library/struct.rst:404 msgid "? (question mark)" msgstr "? (問號)" +#~ msgid "``F``" +#~ msgstr "``F``" + +#~ msgid "``D``" +#~ msgstr "``D``" + #~ msgid "\\(3)" #~ msgstr "\\(3)" diff --git a/library/subprocess.po b/library/subprocess.po index d39000874cd..2f2487f1c28 100644 --- a/library/subprocess.po +++ b/library/subprocess.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-18 00:10+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:11+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,18 +21,18 @@ msgstr "" msgid ":mod:`!subprocess` --- Subprocess management" msgstr ":mod:`!subprocess` --- 子行程管理" -#: ../../library/subprocess.rst:10 +#: ../../library/subprocess.rst:7 msgid "**Source code:** :source:`Lib/subprocess.py`" msgstr "**原始碼:**:source:`Lib/subprocess.py`" -#: ../../library/subprocess.rst:14 +#: ../../library/subprocess.rst:11 msgid "" "The :mod:`!subprocess` module allows you to spawn new processes, connect to " "their input/output/error pipes, and obtain their return codes. This module " "intends to replace several older modules and functions::" msgstr "" -#: ../../library/subprocess.rst:18 +#: ../../library/subprocess.rst:15 msgid "" "os.system\n" "os.spawn*" @@ -40,20 +40,20 @@ msgstr "" "os.system\n" "os.spawn*" -#: ../../library/subprocess.rst:21 +#: ../../library/subprocess.rst:18 msgid "" "Information about how the :mod:`!subprocess` module can be used to replace " "these modules and functions can be found in the following sections." msgstr "" -#: ../../library/subprocess.rst:26 +#: ../../library/subprocess.rst:23 msgid ":pep:`324` -- PEP proposing the subprocess module" msgstr ":pep:`324` -- 提議 subprocess 模組的 PEP" -#: ../../library/subprocess.rst:598 ../../library/subprocess.rst:605 -#: ../../library/subprocess.rst:615 ../../library/subprocess.rst:624 -#: ../../library/subprocess.rst:639 ../../library/subprocess.rst:645 -#: ../../library/subprocess.rst:1512 ../../library/subprocess.rst:1534 +#: ../../library/subprocess.rst:595 ../../library/subprocess.rst:602 +#: ../../library/subprocess.rst:612 ../../library/subprocess.rst:621 +#: ../../library/subprocess.rst:636 ../../library/subprocess.rst:642 +#: ../../library/subprocess.rst:1524 ../../library/subprocess.rst:1546 #: ../../includes/wasm-mobile-notavail.rst:3 msgid "Availability" msgstr "可用性" @@ -66,24 +66,24 @@ msgstr "" "此模組在\\ :ref:`行動平台 `\\ 或 :ref:`WebAssembly 平台 " "`\\ 上不支援。" -#: ../../library/subprocess.rst:31 +#: ../../library/subprocess.rst:28 msgid "Using the :mod:`!subprocess` Module" msgstr "使用 :mod:`!subprocess` 模組" -#: ../../library/subprocess.rst:33 +#: ../../library/subprocess.rst:30 msgid "" "The recommended approach to invoking subprocesses is to use the :func:`run` " "function for all use cases it can handle. For more advanced use cases, the " "underlying :class:`Popen` interface can be used directly." msgstr "" -#: ../../library/subprocess.rst:43 +#: ../../library/subprocess.rst:40 msgid "" "Run the command described by *args*. Wait for command to complete, then " "return a :class:`CompletedProcess` instance." msgstr "" -#: ../../library/subprocess.rst:46 +#: ../../library/subprocess.rst:43 msgid "" "The arguments shown above are merely the most common ones, described below " "in :ref:`frequently-used-arguments` (hence the use of keyword-only notation " @@ -93,7 +93,7 @@ msgid "" "*check*, and *capture_output* are not.)" msgstr "" -#: ../../library/subprocess.rst:53 +#: ../../library/subprocess.rst:50 msgid "" "If *capture_output* is true, stdout and stderr will be captured. When used, " "the internal :class:`Popen` object is automatically created with *stdout* " @@ -104,7 +104,7 @@ msgid "" "using *capture_output*." msgstr "" -#: ../../library/subprocess.rst:62 +#: ../../library/subprocess.rst:59 msgid "" "A *timeout* may be specified in seconds, it is internally passed on to :meth:" "`Popen.communicate`. If the timeout expires, the child process will be " @@ -114,7 +114,7 @@ msgid "" "a timeout exception until at least after however long process creation takes." msgstr "" -#: ../../library/subprocess.rst:70 +#: ../../library/subprocess.rst:67 msgid "" "The *input* argument is passed to :meth:`Popen.communicate` and thus to the " "subprocess's stdin. If used it must be a byte sequence, or a string if " @@ -123,7 +123,7 @@ msgid "" "data:`~subprocess.PIPE`, and the *stdin* argument may not be used as well." msgstr "" -#: ../../library/subprocess.rst:77 +#: ../../library/subprocess.rst:74 msgid "" "If *check* is true, and the process exits with a non-zero exit code, a :exc:" "`CalledProcessError` exception will be raised. Attributes of that exception " @@ -131,7 +131,7 @@ msgid "" "captured." msgstr "" -#: ../../library/subprocess.rst:82 +#: ../../library/subprocess.rst:79 msgid "" "If *encoding* or *errors* are specified, or *text* is true, file objects for " "stdin, stdout and stderr are opened in text mode using the specified " @@ -140,7 +140,7 @@ msgid "" "backwards compatibility. By default, file objects are opened in binary mode." msgstr "" -#: ../../library/subprocess.rst:88 +#: ../../library/subprocess.rst:85 msgid "" "If *env* is not ``None``, it must be a mapping that defines the environment " "variables for the new process; these are used instead of the default " @@ -150,11 +150,11 @@ msgid "" "`os.environb`." msgstr "" -#: ../../library/subprocess.rst:95 +#: ../../library/subprocess.rst:92 msgid "Examples::" msgstr "範例: ::" -#: ../../library/subprocess.rst:97 +#: ../../library/subprocess.rst:94 msgid "" ">>> subprocess.run([\"ls\", \"-l\"]) # doesn't capture output\n" "CompletedProcess(args=['ls', '-l'], returncode=0)\n" @@ -182,19 +182,19 @@ msgstr "" "CompletedProcess(args=['ls', '-l', '/dev/null'], returncode=0,\n" "stdout=b'crw-rw-rw- 1 root root 1, 3 Jan 23 16:23 /dev/null\\n', stderr=b'')" -#: ../../library/subprocess.rst:113 +#: ../../library/subprocess.rst:110 msgid "Added *encoding* and *errors* parameters" msgstr "新增 *encoding* 與 *errors* 參數。" -#: ../../library/subprocess.rst:117 +#: ../../library/subprocess.rst:114 msgid "" "Added the *text* parameter, as a more understandable alias of " "*universal_newlines*. Added the *capture_output* parameter." msgstr "" -#: ../../library/subprocess.rst:122 ../../library/subprocess.rst:506 -#: ../../library/subprocess.rst:1232 ../../library/subprocess.rst:1272 -#: ../../library/subprocess.rst:1335 +#: ../../library/subprocess.rst:119 ../../library/subprocess.rst:503 +#: ../../library/subprocess.rst:1244 ../../library/subprocess.rst:1284 +#: ../../library/subprocess.rst:1347 msgid "" "Changed Windows shell search order for ``shell=True``. The current directory " "and ``%PATH%`` are replaced with ``%COMSPEC%`` and ``%SystemRoot%" @@ -202,92 +202,92 @@ msgid "" "exe`` into a current directory no longer works." msgstr "" -#: ../../library/subprocess.rst:130 +#: ../../library/subprocess.rst:127 msgid "" "The return value from :func:`run`, representing a process that has finished." msgstr "" -#: ../../library/subprocess.rst:134 +#: ../../library/subprocess.rst:131 msgid "" "The arguments used to launch the process. This may be a list or a string." msgstr "" -#: ../../library/subprocess.rst:138 +#: ../../library/subprocess.rst:135 msgid "" "Exit status of the child process. Typically, an exit status of 0 indicates " "that it ran successfully." msgstr "" -#: ../../library/subprocess.rst:141 ../../library/subprocess.rst:958 +#: ../../library/subprocess.rst:138 ../../library/subprocess.rst:970 msgid "" "A negative value ``-N`` indicates that the child was terminated by signal " "``N`` (POSIX only)." msgstr "" -#: ../../library/subprocess.rst:146 +#: ../../library/subprocess.rst:143 msgid "" "Captured stdout from the child process. A bytes sequence, or a string if :" "func:`run` was called with an encoding, errors, or text=True. ``None`` if " "stdout was not captured." msgstr "" -#: ../../library/subprocess.rst:150 +#: ../../library/subprocess.rst:147 msgid "" "If you ran the process with ``stderr=subprocess.STDOUT``, stdout and stderr " "will be combined in this attribute, and :attr:`stderr` will be ``None``." msgstr "" -#: ../../library/subprocess.rst:156 +#: ../../library/subprocess.rst:153 msgid "" "Captured stderr from the child process. A bytes sequence, or a string if :" "func:`run` was called with an encoding, errors, or text=True. ``None`` if " "stderr was not captured." msgstr "" -#: ../../library/subprocess.rst:162 +#: ../../library/subprocess.rst:159 msgid "If :attr:`returncode` is non-zero, raise a :exc:`CalledProcessError`." msgstr "" -#: ../../library/subprocess.rst:168 +#: ../../library/subprocess.rst:165 msgid "" "Special value that can be used as the *stdin*, *stdout* or *stderr* argument " "to :class:`Popen` and indicates that the special file :data:`os.devnull` " "will be used." msgstr "" -#: ../../library/subprocess.rst:177 +#: ../../library/subprocess.rst:174 msgid "" "Special value that can be used as the *stdin*, *stdout* or *stderr* argument " "to :class:`Popen` and indicates that a pipe to the standard stream should be " "opened. Most useful with :meth:`Popen.communicate`." msgstr "" -#: ../../library/subprocess.rst:184 +#: ../../library/subprocess.rst:181 msgid "" "Special value that can be used as the *stderr* argument to :class:`Popen` " "and indicates that standard error should go into the same handle as standard " "output." msgstr "" -#: ../../library/subprocess.rst:191 +#: ../../library/subprocess.rst:188 msgid "Base class for all other exceptions from this module." msgstr "" -#: ../../library/subprocess.rst:198 +#: ../../library/subprocess.rst:195 msgid "" "Subclass of :exc:`SubprocessError`, raised when a timeout expires while " "waiting for a child process." msgstr "" -#: ../../library/subprocess.rst:203 ../../library/subprocess.rst:247 +#: ../../library/subprocess.rst:200 ../../library/subprocess.rst:244 msgid "Command that was used to spawn the child process." msgstr "" -#: ../../library/subprocess.rst:207 +#: ../../library/subprocess.rst:204 msgid "Timeout in seconds." msgstr "" -#: ../../library/subprocess.rst:211 +#: ../../library/subprocess.rst:208 msgid "" "Output of the child process if it was captured by :func:`run` or :func:" "`check_output`. Otherwise, ``None``. This is always :class:`bytes` when " @@ -295,11 +295,11 @@ msgid "" "remain ``None`` instead of ``b''`` when no output was observed." msgstr "" -#: ../../library/subprocess.rst:219 ../../library/subprocess.rst:256 +#: ../../library/subprocess.rst:216 ../../library/subprocess.rst:253 msgid "Alias for output, for symmetry with :attr:`stderr`." msgstr "" -#: ../../library/subprocess.rst:223 +#: ../../library/subprocess.rst:220 msgid "" "Stderr output of the child process if it was captured by :func:`run`. " "Otherwise, ``None``. This is always :class:`bytes` when stderr output was " @@ -307,40 +307,40 @@ msgid "" "instead of ``b''`` when no stderr output was observed." msgstr "" -#: ../../library/subprocess.rst:230 ../../library/subprocess.rst:263 +#: ../../library/subprocess.rst:227 ../../library/subprocess.rst:260 msgid "*stdout* and *stderr* attributes added" msgstr "" -#: ../../library/subprocess.rst:235 +#: ../../library/subprocess.rst:232 msgid "" "Subclass of :exc:`SubprocessError`, raised when a process run by :func:" "`check_call`, :func:`check_output`, or :func:`run` (with ``check=True``) " "returns a non-zero exit status." msgstr "" -#: ../../library/subprocess.rst:242 +#: ../../library/subprocess.rst:239 msgid "" "Exit status of the child process, an integer. If the process exited due to " "a signal, this will be the negative signal number." msgstr "" -#: ../../library/subprocess.rst:251 +#: ../../library/subprocess.rst:248 msgid "" "Output of the child process if it was captured by :func:`run` or :func:" "`check_output`. Otherwise, ``None``." msgstr "" -#: ../../library/subprocess.rst:260 +#: ../../library/subprocess.rst:257 msgid "" "Stderr output of the child process if it was captured by :func:`run`. " "Otherwise, ``None``." msgstr "" -#: ../../library/subprocess.rst:270 +#: ../../library/subprocess.rst:267 msgid "Frequently Used Arguments" msgstr "" -#: ../../library/subprocess.rst:272 +#: ../../library/subprocess.rst:269 msgid "" "To support a wide variety of use cases, the :class:`Popen` constructor (and " "the convenience functions) accept a large number of optional arguments. For " @@ -348,7 +348,7 @@ msgid "" "default values. The arguments that are most commonly needed are:" msgstr "" -#: ../../library/subprocess.rst:277 +#: ../../library/subprocess.rst:274 msgid "" "*args* is required for all calls and should be a string, or a sequence of " "program arguments. Providing a sequence of arguments is generally preferred, " @@ -358,7 +358,7 @@ msgid "" "simply name the program to be executed without specifying any arguments." msgstr "" -#: ../../library/subprocess.rst:285 +#: ../../library/subprocess.rst:282 msgid "" "*stdin*, *stdout* and *stderr* specify the executed program's standard " "input, standard output and standard error file handles, respectively. Valid " @@ -372,7 +372,7 @@ msgid "" "captured into the same file handle as for *stdout*." msgstr "" -#: ../../library/subprocess.rst:299 +#: ../../library/subprocess.rst:296 msgid "" "If *encoding* or *errors* are specified, or *text* (also known as " "*universal_newlines*) is true, the file objects *stdin*, *stdout* and " @@ -380,7 +380,7 @@ msgid "" "specified in the call or the defaults for :class:`io.TextIOWrapper`." msgstr "" -#: ../../library/subprocess.rst:305 +#: ../../library/subprocess.rst:302 msgid "" "For *stdin*, line ending characters ``'\\n'`` in the input will be converted " "to the default line separator :data:`os.linesep`. For *stdout* and *stderr*, " @@ -389,29 +389,29 @@ msgid "" "when the *newline* argument to its constructor is ``None``." msgstr "" -#: ../../library/subprocess.rst:311 +#: ../../library/subprocess.rst:308 msgid "" "If text mode is not used, *stdin*, *stdout* and *stderr* will be opened as " "binary streams. No encoding or line ending conversion is performed." msgstr "" -#: ../../library/subprocess.rst:314 ../../library/subprocess.rst:1521 -#: ../../library/subprocess.rst:1539 +#: ../../library/subprocess.rst:311 ../../library/subprocess.rst:1533 +#: ../../library/subprocess.rst:1551 msgid "Added the *encoding* and *errors* parameters." msgstr "新增 *encoding* 與 *errors* 參數。" -#: ../../library/subprocess.rst:317 +#: ../../library/subprocess.rst:314 msgid "Added the *text* parameter as an alias for *universal_newlines*." msgstr "新增 *text* 參數作為 *universal_newlines* 的別名。" -#: ../../library/subprocess.rst:322 +#: ../../library/subprocess.rst:319 msgid "" "The newlines attribute of the file objects :attr:`Popen.stdin`, :attr:`Popen." "stdout` and :attr:`Popen.stderr` are not updated by the :meth:`Popen." "communicate` method." msgstr "" -#: ../../library/subprocess.rst:326 +#: ../../library/subprocess.rst:323 msgid "" "If *shell* is ``True``, the specified command will be executed through the " "shell. This can be useful if you are using Python primarily for the " @@ -424,7 +424,7 @@ msgid "" "expanduser`, and :mod:`shutil`)." msgstr "" -#: ../../library/subprocess.rst:336 +#: ../../library/subprocess.rst:333 msgid "" "When *universal_newlines* is ``True``, the class uses the encoding :func:" "`locale.getpreferredencoding(False) ` instead " @@ -432,22 +432,22 @@ msgid "" "class for more information on this change." msgstr "" -#: ../../library/subprocess.rst:344 ../../library/subprocess.rst:465 +#: ../../library/subprocess.rst:341 ../../library/subprocess.rst:462 msgid "" "Read the `Security Considerations`_ section before using ``shell=True``." msgstr "" -#: ../../library/subprocess.rst:346 +#: ../../library/subprocess.rst:343 msgid "" "These options, along with all of the other options, are described in more " "detail in the :class:`Popen` constructor documentation." msgstr "" -#: ../../library/subprocess.rst:351 +#: ../../library/subprocess.rst:348 msgid "Popen Constructor" msgstr "" -#: ../../library/subprocess.rst:353 +#: ../../library/subprocess.rst:350 msgid "" "The underlying process creation and management in this module is handled by " "the :class:`Popen` class. It offers a lot of flexibility so that developers " @@ -455,7 +455,7 @@ msgid "" "functions." msgstr "" -#: ../../library/subprocess.rst:368 +#: ../../library/subprocess.rst:365 msgid "" "Execute a child program in a new process. On POSIX, the class uses :meth:" "`os.execvpe`-like behavior to execute the child program. On Windows, the " @@ -463,7 +463,7 @@ msgid "" "class:`Popen` are as follows." msgstr "" -#: ../../library/subprocess.rst:373 +#: ../../library/subprocess.rst:370 msgid "" "*args* should be a sequence of program arguments or else a single string or :" "term:`path-like object`. By default, the program to execute is the first " @@ -474,7 +474,7 @@ msgid "" "sequence." msgstr "" -#: ../../library/subprocess.rst:383 +#: ../../library/subprocess.rst:380 msgid "" "For maximum reliability, use a fully qualified path for the executable. To " "search for an unqualified name on :envvar:`PATH`, use :meth:`shutil.which`. " @@ -483,7 +483,7 @@ msgid "" "format to launch an installed module." msgstr "" -#: ../../library/subprocess.rst:389 +#: ../../library/subprocess.rst:386 msgid "" "Resolving the path of *executable* (or the first item of *args*) is platform " "dependent. For POSIX, see :meth:`os.execvpe`, and note that when resolving " @@ -497,31 +497,31 @@ msgid "" "variations." msgstr "" -#: ../../library/subprocess.rst:400 +#: ../../library/subprocess.rst:397 msgid "" "An example of passing some arguments to an external program as a sequence " "is::" msgstr "" -#: ../../library/subprocess.rst:403 +#: ../../library/subprocess.rst:400 msgid "Popen([\"/usr/bin/git\", \"commit\", \"-m\", \"Fixes a bug.\"])" msgstr "Popen([\"/usr/bin/git\", \"commit\", \"-m\", \"Fixes a bug.\"])" -#: ../../library/subprocess.rst:405 +#: ../../library/subprocess.rst:402 msgid "" "On POSIX, if *args* is a string, the string is interpreted as the name or " "path of the program to execute. However, this can only be done if not " "passing arguments to the program." msgstr "" -#: ../../library/subprocess.rst:411 +#: ../../library/subprocess.rst:408 msgid "" "It may not be obvious how to break a shell command into a sequence of " "arguments, especially in complex cases. :meth:`shlex.split` can illustrate " "how to determine the correct tokenization for *args*::" msgstr "" -#: ../../library/subprocess.rst:415 +#: ../../library/subprocess.rst:412 msgid "" ">>> import shlex, subprocess\n" ">>> command_line = input()\n" @@ -543,7 +543,7 @@ msgstr "" "\"echo '$MONEY'\"]\n" ">>> p = subprocess.Popen(args) # 成功!" -#: ../../library/subprocess.rst:423 +#: ../../library/subprocess.rst:420 msgid "" "Note in particular that options (such as *-input*) and arguments (such as " "*eggs.txt*) that are separated by whitespace in the shell go in separate " @@ -552,33 +552,33 @@ msgid "" "shown above) are single list elements." msgstr "" -#: ../../library/subprocess.rst:429 +#: ../../library/subprocess.rst:426 msgid "" "On Windows, if *args* is a sequence, it will be converted to a string in a " "manner described in :ref:`converting-argument-sequence`. This is because " "the underlying ``CreateProcess()`` operates on strings." msgstr "" -#: ../../library/subprocess.rst:433 +#: ../../library/subprocess.rst:430 msgid "" "*args* parameter accepts a :term:`path-like object` if *shell* is ``False`` " "and a sequence containing path-like objects on POSIX." msgstr "" -#: ../../library/subprocess.rst:437 +#: ../../library/subprocess.rst:434 msgid "" "*args* parameter accepts a :term:`path-like object` if *shell* is ``False`` " "and a sequence containing bytes and path-like objects on Windows." msgstr "" -#: ../../library/subprocess.rst:442 +#: ../../library/subprocess.rst:439 msgid "" "The *shell* argument (which defaults to ``False``) specifies whether to use " "the shell as the program to execute. If *shell* is ``True``, it is " "recommended to pass *args* as a string rather than as a sequence." msgstr "" -#: ../../library/subprocess.rst:446 +#: ../../library/subprocess.rst:443 msgid "" "On POSIX with ``shell=True``, the shell defaults to :file:`/bin/sh`. If " "*args* is a string, the string specifies the command to execute through the " @@ -590,11 +590,11 @@ msgid "" "class:`Popen` does the equivalent of::" msgstr "" -#: ../../library/subprocess.rst:455 +#: ../../library/subprocess.rst:452 msgid "Popen(['/bin/sh', '-c', args[0], args[1], ...])" msgstr "Popen(['/bin/sh', '-c', args[0], args[1], ...])" -#: ../../library/subprocess.rst:457 +#: ../../library/subprocess.rst:454 msgid "" "On Windows with ``shell=True``, the :envvar:`COMSPEC` environment variable " "specifies the default shell. The only time you need to specify " @@ -603,35 +603,35 @@ msgid "" "``shell=True`` to run a batch file or console-based executable." msgstr "" -#: ../../library/subprocess.rst:467 +#: ../../library/subprocess.rst:464 msgid "" "*bufsize* will be supplied as the corresponding argument to the :func:`open` " "function when creating the stdin/stdout/stderr pipe file objects:" msgstr "" -#: ../../library/subprocess.rst:471 +#: ../../library/subprocess.rst:468 msgid "" "``0`` means unbuffered (read and write are one system call and can return " "short)" msgstr "" -#: ../../library/subprocess.rst:473 +#: ../../library/subprocess.rst:470 msgid "" "``1`` means line buffered (only usable if ``text=True`` or " "``universal_newlines=True``)" msgstr "" -#: ../../library/subprocess.rst:475 +#: ../../library/subprocess.rst:472 msgid "any other positive value means use a buffer of approximately that size" msgstr "" -#: ../../library/subprocess.rst:477 +#: ../../library/subprocess.rst:474 msgid "" "negative bufsize (the default) means the system default of io." "DEFAULT_BUFFER_SIZE will be used." msgstr "" -#: ../../library/subprocess.rst:480 +#: ../../library/subprocess.rst:477 msgid "" "*bufsize* now defaults to -1 to enable buffering by default to match the " "behavior that most code expects. In versions prior to Python 3.2.4 and " @@ -640,7 +640,7 @@ msgid "" "Python 2 as most code expected." msgstr "" -#: ../../library/subprocess.rst:487 +#: ../../library/subprocess.rst:484 msgid "" "The *executable* argument specifies a replacement program to execute. It " "is very seldom needed. When ``shell=False``, *executable* replaces the " @@ -653,17 +653,17 @@ msgid "" "default :file:`/bin/sh`." msgstr "" -#: ../../library/subprocess.rst:497 +#: ../../library/subprocess.rst:494 msgid "*executable* parameter accepts a :term:`path-like object` on POSIX." msgstr "" -#: ../../library/subprocess.rst:500 +#: ../../library/subprocess.rst:497 msgid "" "*executable* parameter accepts a bytes and :term:`path-like object` on " "Windows." msgstr "" -#: ../../library/subprocess.rst:512 +#: ../../library/subprocess.rst:509 msgid "" "*stdin*, *stdout* and *stderr* specify the executed program's standard " "input, standard output and standard error file handles, respectively. Valid " @@ -677,19 +677,19 @@ msgid "" "captured into the same file handle as for *stdout*." msgstr "" -#: ../../library/subprocess.rst:523 +#: ../../library/subprocess.rst:520 msgid "" "If *preexec_fn* is set to a callable object, this object will be called in " "the child process just before the child is executed. (POSIX only)" msgstr "" -#: ../../library/subprocess.rst:529 +#: ../../library/subprocess.rst:526 msgid "" "The *preexec_fn* parameter is NOT SAFE to use in the presence of threads in " "your application. The child process could deadlock before exec is called." msgstr "" -#: ../../library/subprocess.rst:535 +#: ../../library/subprocess.rst:532 msgid "" "If you need to modify the environment for the child use the *env* parameter " "rather than doing it in a *preexec_fn*. The *start_new_session* and " @@ -697,7 +697,7 @@ msgid "" "to call :func:`os.setsid` or :func:`os.setpgid` in the child." msgstr "" -#: ../../library/subprocess.rst:542 +#: ../../library/subprocess.rst:539 msgid "" "The *preexec_fn* parameter is no longer supported in subinterpreters. The " "use of the parameter in a subinterpreter raises :exc:`RuntimeError`. The new " @@ -705,7 +705,7 @@ msgid "" "and other embedded environments." msgstr "" -#: ../../library/subprocess.rst:547 +#: ../../library/subprocess.rst:544 msgid "" "If *close_fds* is true, all file descriptors except ``0``, ``1`` and ``2`` " "will be closed before the child process is executed. Otherwise when " @@ -713,38 +713,38 @@ msgid "" "described in :ref:`fd_inheritance`." msgstr "" -#: ../../library/subprocess.rst:552 +#: ../../library/subprocess.rst:549 msgid "" "On Windows, if *close_fds* is true then no handles will be inherited by the " "child process unless explicitly passed in the ``handle_list`` element of :" "attr:`STARTUPINFO.lpAttributeList`, or by standard handle redirection." msgstr "" -#: ../../library/subprocess.rst:556 +#: ../../library/subprocess.rst:553 msgid "" "The default for *close_fds* was changed from :const:`False` to what is " "described above." msgstr "" -#: ../../library/subprocess.rst:560 +#: ../../library/subprocess.rst:557 msgid "" "On Windows the default for *close_fds* was changed from :const:`False` to :" "const:`True` when redirecting the standard handles. It's now possible to set " "*close_fds* to :const:`True` when redirecting the standard handles." msgstr "" -#: ../../library/subprocess.rst:565 +#: ../../library/subprocess.rst:562 msgid "" "*pass_fds* is an optional sequence of file descriptors to keep open between " "the parent and child. Providing any *pass_fds* forces *close_fds* to be :" "const:`True`. (POSIX only)" msgstr "" -#: ../../library/subprocess.rst:569 +#: ../../library/subprocess.rst:566 msgid "The *pass_fds* parameter was added." msgstr "新增 *pass_fds* 參數。" -#: ../../library/subprocess.rst:572 +#: ../../library/subprocess.rst:569 msgid "" "If *cwd* is not ``None``, the function changes the working directory to " "*cwd* before executing the child. *cwd* can be a string, bytes or :term:" @@ -753,51 +753,51 @@ msgid "" "executable path is a relative path." msgstr "" -#: ../../library/subprocess.rst:578 +#: ../../library/subprocess.rst:575 msgid "*cwd* parameter accepts a :term:`path-like object` on POSIX." msgstr "*cwd* 參數在 POSIX 上接受 :term:`path-like object`。" -#: ../../library/subprocess.rst:581 +#: ../../library/subprocess.rst:578 msgid "*cwd* parameter accepts a :term:`path-like object` on Windows." msgstr "*cwd* 參數在 Windows 上接受 :term:`path-like object`。" -#: ../../library/subprocess.rst:584 +#: ../../library/subprocess.rst:581 msgid "*cwd* parameter accepts a bytes object on Windows." msgstr "*cwd* 參數在 Windows 上接受 bytes 物件。" -#: ../../library/subprocess.rst:587 +#: ../../library/subprocess.rst:584 msgid "" "If *restore_signals* is true (the default) all signals that Python has set " "to SIG_IGN are restored to SIG_DFL in the child process before the exec. " "Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals. (POSIX only)" msgstr "" -#: ../../library/subprocess.rst:592 +#: ../../library/subprocess.rst:589 msgid "*restore_signals* was added." msgstr "新增 *restore_signals*。" -#: ../../library/subprocess.rst:595 +#: ../../library/subprocess.rst:592 msgid "" "If *start_new_session* is true the ``setsid()`` system call will be made in " "the child process prior to the execution of the subprocess." msgstr "" -#: ../../library/subprocess.rst:599 +#: ../../library/subprocess.rst:596 msgid "*start_new_session* was added." msgstr "新增 *start_new_session*。" -#: ../../library/subprocess.rst:602 +#: ../../library/subprocess.rst:599 msgid "" "If *process_group* is a non-negative integer, the ``setpgid(0, value)`` " "system call will be made in the child process prior to the execution of the " "subprocess." msgstr "" -#: ../../library/subprocess.rst:606 +#: ../../library/subprocess.rst:603 msgid "*process_group* was added." msgstr "新增 *process_group*。" -#: ../../library/subprocess.rst:609 +#: ../../library/subprocess.rst:606 msgid "" "If *group* is not ``None``, the setregid() system call will be made in the " "child process prior to the execution of the subprocess. If the provided " @@ -806,7 +806,7 @@ msgid "" "passed verbatim. (POSIX only)" msgstr "" -#: ../../library/subprocess.rst:618 +#: ../../library/subprocess.rst:615 msgid "" "If *extra_groups* is not ``None``, the setgroups() system call will be made " "in the child process prior to the execution of the subprocess. Strings " @@ -815,7 +815,7 @@ msgid "" "verbatim. (POSIX only)" msgstr "" -#: ../../library/subprocess.rst:627 +#: ../../library/subprocess.rst:624 msgid "" "If *user* is not ``None``, the setreuid() system call will be made in the " "child process prior to the execution of the subprocess. If the provided " @@ -824,20 +824,20 @@ msgid "" "passed verbatim. (POSIX only)" msgstr "" -#: ../../library/subprocess.rst:635 +#: ../../library/subprocess.rst:632 msgid "" "Specifying *user* will not drop existing supplementary group memberships! " "The caller must also pass ``extra_groups=()`` to reduce the group membership " "of the child process for security purposes." msgstr "" -#: ../../library/subprocess.rst:642 +#: ../../library/subprocess.rst:639 msgid "" "If *umask* is not negative, the umask() system call will be made in the " "child process prior to the execution of the subprocess." msgstr "" -#: ../../library/subprocess.rst:648 +#: ../../library/subprocess.rst:645 msgid "" "If *env* is not ``None``, it must be a mapping that defines the environment " "variables for the new process; these are used instead of the default " @@ -846,14 +846,14 @@ msgid "" "data:`os.environ` or :data:`os.environb`." msgstr "" -#: ../../library/subprocess.rst:656 +#: ../../library/subprocess.rst:653 msgid "" "If specified, *env* must provide any variables required for the program to " "execute. On Windows, in order to run a `side-by-side assembly`_ the " "specified *env* **must** include a valid ``%SystemRoot%``." msgstr "" -#: ../../library/subprocess.rst:662 +#: ../../library/subprocess.rst:659 msgid "" "If *encoding* or *errors* are specified, or *text* is true, the file objects " "*stdin*, *stdout* and *stderr* are opened in text mode with the specified " @@ -863,73 +863,73 @@ msgid "" "in binary mode." msgstr "" -#: ../../library/subprocess.rst:668 +#: ../../library/subprocess.rst:665 msgid "*encoding* and *errors* were added." msgstr "新增 *encoding* 與 *errors*。" -#: ../../library/subprocess.rst:671 ../../library/subprocess.rst:1330 +#: ../../library/subprocess.rst:668 ../../library/subprocess.rst:1342 msgid "*text* was added as a more readable alias for *universal_newlines*." msgstr "" -#: ../../library/subprocess.rst:674 +#: ../../library/subprocess.rst:671 msgid "" "If given, *startupinfo* will be a :class:`STARTUPINFO` object, which is " "passed to the underlying ``CreateProcess`` function." msgstr "" -#: ../../library/subprocess.rst:677 +#: ../../library/subprocess.rst:674 msgid "If given, *creationflags*, can be one or more of the following flags:" msgstr "" -#: ../../library/subprocess.rst:679 +#: ../../library/subprocess.rst:676 msgid ":data:`CREATE_NEW_CONSOLE`" msgstr ":data:`CREATE_NEW_CONSOLE`" -#: ../../library/subprocess.rst:680 +#: ../../library/subprocess.rst:677 msgid ":data:`CREATE_NEW_PROCESS_GROUP`" msgstr ":data:`CREATE_NEW_PROCESS_GROUP`" -#: ../../library/subprocess.rst:681 +#: ../../library/subprocess.rst:678 msgid ":data:`ABOVE_NORMAL_PRIORITY_CLASS`" msgstr ":data:`ABOVE_NORMAL_PRIORITY_CLASS`" -#: ../../library/subprocess.rst:682 +#: ../../library/subprocess.rst:679 msgid ":data:`BELOW_NORMAL_PRIORITY_CLASS`" msgstr ":data:`BELOW_NORMAL_PRIORITY_CLASS`" -#: ../../library/subprocess.rst:683 +#: ../../library/subprocess.rst:680 msgid ":data:`HIGH_PRIORITY_CLASS`" msgstr ":data:`HIGH_PRIORITY_CLASS`" -#: ../../library/subprocess.rst:684 +#: ../../library/subprocess.rst:681 msgid ":data:`IDLE_PRIORITY_CLASS`" msgstr ":data:`IDLE_PRIORITY_CLASS`" -#: ../../library/subprocess.rst:685 +#: ../../library/subprocess.rst:682 msgid ":data:`NORMAL_PRIORITY_CLASS`" msgstr ":data:`NORMAL_PRIORITY_CLASS`" -#: ../../library/subprocess.rst:686 +#: ../../library/subprocess.rst:683 msgid ":data:`REALTIME_PRIORITY_CLASS`" msgstr ":data:`REALTIME_PRIORITY_CLASS`" -#: ../../library/subprocess.rst:687 +#: ../../library/subprocess.rst:684 msgid ":data:`CREATE_NO_WINDOW`" msgstr ":data:`CREATE_NO_WINDOW`" -#: ../../library/subprocess.rst:688 +#: ../../library/subprocess.rst:685 msgid ":data:`DETACHED_PROCESS`" msgstr ":data:`DETACHED_PROCESS`" -#: ../../library/subprocess.rst:689 +#: ../../library/subprocess.rst:686 msgid ":data:`CREATE_DEFAULT_ERROR_MODE`" msgstr ":data:`CREATE_DEFAULT_ERROR_MODE`" -#: ../../library/subprocess.rst:690 +#: ../../library/subprocess.rst:687 msgid ":data:`CREATE_BREAKAWAY_FROM_JOB`" msgstr ":data:`CREATE_BREAKAWAY_FROM_JOB`" -#: ../../library/subprocess.rst:692 +#: ../../library/subprocess.rst:689 msgid "" "*pipesize* can be used to change the size of the pipe when :data:`PIPE` is " "used for *stdin*, *stdout* or *stderr*. The size of the pipe is only changed " @@ -937,18 +937,18 @@ msgid "" "platforms will ignore this parameter." msgstr "" -#: ../../library/subprocess.rst:697 +#: ../../library/subprocess.rst:694 msgid "Added the *pipesize* parameter." msgstr "新增 ``pipesize`` 參數。" -#: ../../library/subprocess.rst:700 +#: ../../library/subprocess.rst:697 msgid "" "Popen objects are supported as context managers via the :keyword:`with` " "statement: on exit, standard file descriptors are closed, and the process is " "waited for. ::" msgstr "" -#: ../../library/subprocess.rst:704 +#: ../../library/subprocess.rst:701 msgid "" "with Popen([\"ifconfig\"], stdout=PIPE) as proc:\n" " log.write(proc.stdout.read())" @@ -956,7 +956,7 @@ msgstr "" "with Popen([\"ifconfig\"], stdout=PIPE) as proc:\n" " log.write(proc.stdout.read())" -#: ../../library/subprocess.rst:707 ../../library/subprocess.rst:709 +#: ../../library/subprocess.rst:704 ../../library/subprocess.rst:706 msgid "" "Popen and the other functions in this module that use it raise an :ref:" "`auditing event ` ``subprocess.Popen`` with arguments " @@ -964,17 +964,17 @@ msgid "" "be a single string or a list of strings, depending on platform." msgstr "" -#: ../../library/subprocess.rst:714 +#: ../../library/subprocess.rst:711 msgid "Added context manager support." msgstr "新增情境管理器的支援。" -#: ../../library/subprocess.rst:717 +#: ../../library/subprocess.rst:714 msgid "" "Popen destructor now emits a :exc:`ResourceWarning` warning if the child " "process is still running." msgstr "" -#: ../../library/subprocess.rst:721 +#: ../../library/subprocess.rst:718 msgid "" "Popen can use :func:`os.posix_spawn` in some cases for better performance. " "On Windows Subsystem for Linux and QEMU User Emulation, Popen constructor " @@ -983,17 +983,17 @@ msgid "" "returncode`." msgstr "" -#: ../../library/subprocess.rst:730 +#: ../../library/subprocess.rst:727 msgid "Exceptions" msgstr "例外" -#: ../../library/subprocess.rst:732 +#: ../../library/subprocess.rst:729 msgid "" "Exceptions raised in the child process, before the new program has started " "to execute, will be re-raised in the parent." msgstr "" -#: ../../library/subprocess.rst:735 +#: ../../library/subprocess.rst:732 msgid "" "The most common exception raised is :exc:`OSError`. This occurs, for " "example, when trying to execute a non-existent file. Applications should " @@ -1004,39 +1004,39 @@ msgid "" "subprocess." msgstr "" -#: ../../library/subprocess.rst:742 +#: ../../library/subprocess.rst:739 msgid "" "A :exc:`ValueError` will be raised if :class:`Popen` is called with invalid " "arguments." msgstr "" -#: ../../library/subprocess.rst:745 +#: ../../library/subprocess.rst:742 msgid "" ":func:`check_call` and :func:`check_output` will raise :exc:" "`CalledProcessError` if the called process returns a non-zero return code." msgstr "" -#: ../../library/subprocess.rst:749 +#: ../../library/subprocess.rst:746 msgid "" "All of the functions and methods that accept a *timeout* parameter, such as :" "func:`run` and :meth:`Popen.communicate` will raise :exc:`TimeoutExpired` if " "the timeout expires before the process exits." msgstr "" -#: ../../library/subprocess.rst:753 +#: ../../library/subprocess.rst:750 msgid "" "Exceptions defined in this module all inherit from :exc:`SubprocessError`." msgstr "" -#: ../../library/subprocess.rst:755 +#: ../../library/subprocess.rst:752 msgid "The :exc:`SubprocessError` base class was added." msgstr "新增 :exc:`SubprocessError` 基底類別。" -#: ../../library/subprocess.rst:761 +#: ../../library/subprocess.rst:758 msgid "Security Considerations" msgstr "安全性注意事項" -#: ../../library/subprocess.rst:763 +#: ../../library/subprocess.rst:760 msgid "" "Unlike some other popen functions, this library will not implicitly choose " "to call a system shell. This means that all characters, including shell " @@ -1049,7 +1049,7 @@ msgid "" "escaping." msgstr "" -#: ../../library/subprocess.rst:773 +#: ../../library/subprocess.rst:770 msgid "" "On Windows, batch files (:file:`*.bat` or :file:`*.cmd`) may be launched by " "the operating system in a system shell regardless of the arguments passed to " @@ -1060,34 +1060,34 @@ msgid "" "`114539` for additional discussion." msgstr "" -#: ../../library/subprocess.rst:783 +#: ../../library/subprocess.rst:780 msgid "Popen Objects" msgstr "" -#: ../../library/subprocess.rst:785 +#: ../../library/subprocess.rst:782 msgid "Instances of the :class:`Popen` class have the following methods:" msgstr "" -#: ../../library/subprocess.rst:790 +#: ../../library/subprocess.rst:787 msgid "" "Check if child process has terminated. Set and return :attr:`~Popen." "returncode` attribute. Otherwise, returns ``None``." msgstr "" -#: ../../library/subprocess.rst:796 +#: ../../library/subprocess.rst:793 msgid "" "Wait for child process to terminate. Set and return :attr:`~Popen." "returncode` attribute." msgstr "" -#: ../../library/subprocess.rst:799 +#: ../../library/subprocess.rst:796 msgid "" "If the process does not terminate after *timeout* seconds, raise a :exc:" "`TimeoutExpired` exception. It is safe to catch this exception and retry " "the wait." msgstr "" -#: ../../library/subprocess.rst:805 +#: ../../library/subprocess.rst:802 msgid "" "This will deadlock when using ``stdout=PIPE`` or ``stderr=PIPE`` and the " "child process generates enough output to a pipe such that it blocks waiting " @@ -1095,21 +1095,51 @@ msgid "" "when using pipes to avoid that." msgstr "" +#: ../../library/subprocess.rst:809 +msgid "" +"When ``timeout`` is not ``None`` and the platform supports it, an efficient " +"event-driven mechanism is used to wait for process termination:" +msgstr "" + #: ../../library/subprocess.rst:812 +msgid "Linux >= 5.3 uses :func:`os.pidfd_open` + :func:`select.poll`" +msgstr "" + +#: ../../library/subprocess.rst:813 +msgid "" +"macOS and other BSD variants use :func:`select.kqueue` + ``KQ_FILTER_PROC`` " +"+ ``KQ_NOTE_EXIT``" +msgstr "" + +#: ../../library/subprocess.rst:815 +msgid "Windows uses ``WaitForSingleObject``" +msgstr "" + +#: ../../library/subprocess.rst:817 msgid "" -"When the ``timeout`` parameter is not ``None``, then (on POSIX) the function " -"is implemented using a busy loop (non-blocking call and short sleeps). Use " -"the :mod:`asyncio` module for an asynchronous wait: see :class:`asyncio." +"If none of these mechanisms are available, the function falls back to a busy " +"loop (non-blocking call and short sleeps)." +msgstr "" + +#: ../../library/subprocess.rst:822 +msgid "" +"Use the :mod:`asyncio` module for an asynchronous wait: see :class:`asyncio." "create_subprocess_exec`." msgstr "" -#: ../../library/subprocess.rst:817 ../../library/subprocess.rst:865 -#: ../../library/subprocess.rst:1227 ../../library/subprocess.rst:1267 -#: ../../library/subprocess.rst:1321 +#: ../../library/subprocess.rst:825 ../../library/subprocess.rst:877 +#: ../../library/subprocess.rst:1239 ../../library/subprocess.rst:1279 +#: ../../library/subprocess.rst:1333 msgid "*timeout* was added." msgstr "新增 *timeout*。" -#: ../../library/subprocess.rst:822 +#: ../../library/subprocess.rst:828 +msgid "" +"if *timeout* is not ``None``, use efficient event-driven implementation on " +"Linux >= 5.3 and macOS / BSD." +msgstr "" + +#: ../../library/subprocess.rst:834 msgid "" "Interact with process: Send data to stdin. Read data from stdout and " "stderr, until end-of-file is reached. Wait for process to terminate and set " @@ -1119,13 +1149,13 @@ msgid "" "must be a string. Otherwise, it must be bytes." msgstr "" -#: ../../library/subprocess.rst:829 +#: ../../library/subprocess.rst:841 msgid "" ":meth:`communicate` returns a tuple ``(stdout_data, stderr_data)``. The data " "will be strings if streams were opened in text mode; otherwise, bytes." msgstr "" -#: ../../library/subprocess.rst:833 +#: ../../library/subprocess.rst:845 msgid "" "Note that if you want to send data to the process's stdin, you need to " "create the Popen object with ``stdin=PIPE``. Similarly, to get anything " @@ -1133,7 +1163,7 @@ msgid "" "and/or ``stderr=PIPE`` too." msgstr "" -#: ../../library/subprocess.rst:838 +#: ../../library/subprocess.rst:850 msgid "" "If the process does not terminate after *timeout* seconds, a :exc:" "`TimeoutExpired` exception will be raised. Catching this exception and " @@ -1142,14 +1172,14 @@ msgid "" "and may become an error in the future." msgstr "" -#: ../../library/subprocess.rst:844 +#: ../../library/subprocess.rst:856 msgid "" "The child process is not killed if the timeout expires, so in order to " "cleanup properly a well-behaved application should kill the child process " "and finish communication::" msgstr "" -#: ../../library/subprocess.rst:848 +#: ../../library/subprocess.rst:860 msgid "" "proc = subprocess.Popen(...)\n" "try:\n" @@ -1165,7 +1195,7 @@ msgstr "" " proc.kill()\n" " outs, errs = proc.communicate()" -#: ../../library/subprocess.rst:855 +#: ../../library/subprocess.rst:867 msgid "" "After a call to :meth:`~Popen.communicate` raises :exc:`TimeoutExpired`, do " "not call :meth:`~Popen.wait`. Use an additional :meth:`~Popen.communicate` " @@ -1173,53 +1203,53 @@ msgid "" "attribute." msgstr "" -#: ../../library/subprocess.rst:862 +#: ../../library/subprocess.rst:874 msgid "" "The data read is buffered in memory, so do not use this method if the data " "size is large or unlimited." msgstr "" -#: ../../library/subprocess.rst:871 +#: ../../library/subprocess.rst:883 msgid "Sends the signal *signal* to the child." msgstr "" -#: ../../library/subprocess.rst:873 +#: ../../library/subprocess.rst:885 msgid "Do nothing if the process completed." msgstr "" -#: ../../library/subprocess.rst:877 +#: ../../library/subprocess.rst:889 msgid "" "On Windows, SIGTERM is an alias for :meth:`terminate`. CTRL_C_EVENT and " "CTRL_BREAK_EVENT can be sent to processes started with a *creationflags* " "parameter which includes ``CREATE_NEW_PROCESS_GROUP``." msgstr "" -#: ../../library/subprocess.rst:884 +#: ../../library/subprocess.rst:896 msgid "" "Stop the child. On POSIX OSs the method sends :py:const:`~signal.SIGTERM` to " "the child. On Windows the Win32 API function :c:func:`!TerminateProcess` is " "called to stop the child." msgstr "" -#: ../../library/subprocess.rst:891 +#: ../../library/subprocess.rst:903 msgid "" "Kills the child. On POSIX OSs the function sends SIGKILL to the child. On " "Windows :meth:`kill` is an alias for :meth:`terminate`." msgstr "" -#: ../../library/subprocess.rst:895 +#: ../../library/subprocess.rst:907 msgid "" "The following attributes are also set by the class for you to access. " "Reassigning them to new values is unsupported:" msgstr "" -#: ../../library/subprocess.rst:900 +#: ../../library/subprocess.rst:912 msgid "" "The *args* argument as it was passed to :class:`Popen` -- a sequence of " "program arguments or else a single string." msgstr "" -#: ../../library/subprocess.rst:907 +#: ../../library/subprocess.rst:919 msgid "" "If the *stdin* argument was :data:`PIPE`, this attribute is a writeable " "stream object as returned by :func:`open`. If the *encoding* or *errors* " @@ -1228,7 +1258,7 @@ msgid "" "*stdin* argument was not :data:`PIPE`, this attribute is ``None``." msgstr "" -#: ../../library/subprocess.rst:916 +#: ../../library/subprocess.rst:928 msgid "" "If the *stdout* argument was :data:`PIPE`, this attribute is a readable " "stream object as returned by :func:`open`. Reading from the stream provides " @@ -1238,7 +1268,7 @@ msgid "" "argument was not :data:`PIPE`, this attribute is ``None``." msgstr "" -#: ../../library/subprocess.rst:926 +#: ../../library/subprocess.rst:938 msgid "" "If the *stderr* argument was :data:`PIPE`, this attribute is a readable " "stream object as returned by :func:`open`. Reading from the stream provides " @@ -1248,7 +1278,7 @@ msgid "" "argument was not :data:`PIPE`, this attribute is ``None``." msgstr "" -#: ../../library/subprocess.rst:935 +#: ../../library/subprocess.rst:947 msgid "" "Use :meth:`~Popen.communicate` rather than :attr:`.stdin.write `, :attr:`.stdout.read ` or :attr:`.stderr.read `__ structure is used for :class:`Popen` " @@ -1305,17 +1335,17 @@ msgid "" "only arguments." msgstr "" -#: ../../library/subprocess.rst:981 +#: ../../library/subprocess.rst:993 msgid "Keyword-only argument support was added." msgstr "" -#: ../../library/subprocess.rst:986 +#: ../../library/subprocess.rst:998 msgid "" "A bit field that determines whether certain :class:`STARTUPINFO` attributes " "are used when the process creates a window. ::" msgstr "" -#: ../../library/subprocess.rst:989 +#: ../../library/subprocess.rst:1001 msgid "" "si = subprocess.STARTUPINFO()\n" "si.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess." @@ -1325,28 +1355,28 @@ msgstr "" "si.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess." "STARTF_USESHOWWINDOW" -#: ../../library/subprocess.rst:994 +#: ../../library/subprocess.rst:1006 msgid "" "If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this attribute is " "the standard input handle for the process. If :data:`STARTF_USESTDHANDLES` " "is not specified, the default for standard input is the keyboard buffer." msgstr "" -#: ../../library/subprocess.rst:1001 +#: ../../library/subprocess.rst:1013 msgid "" "If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this attribute is " "the standard output handle for the process. Otherwise, this attribute is " "ignored and the default for standard output is the console window's buffer." msgstr "" -#: ../../library/subprocess.rst:1008 +#: ../../library/subprocess.rst:1020 msgid "" "If :attr:`dwFlags` specifies :data:`STARTF_USESTDHANDLES`, this attribute is " "the standard error handle for the process. Otherwise, this attribute is " "ignored and the default for standard error is the console window's buffer." msgstr "" -#: ../../library/subprocess.rst:1014 +#: ../../library/subprocess.rst:1026 msgid "" "If :attr:`dwFlags` specifies :data:`STARTF_USESHOWWINDOW`, this attribute " "can be any of the values that can be specified in the ``nCmdShow`` parameter " @@ -1355,34 +1385,34 @@ msgid "" "Otherwise, this attribute is ignored." msgstr "" -#: ../../library/subprocess.rst:1021 +#: ../../library/subprocess.rst:1033 msgid "" ":data:`SW_HIDE` is provided for this attribute. It is used when :class:" "`Popen` is called with ``shell=True``." msgstr "" -#: ../../library/subprocess.rst:1026 +#: ../../library/subprocess.rst:1038 msgid "" "A dictionary of additional attributes for process creation as given in " "``STARTUPINFOEX``, see `UpdateProcThreadAttribute `__." msgstr "" -#: ../../library/subprocess.rst:1030 +#: ../../library/subprocess.rst:1042 msgid "Supported attributes:" msgstr "" -#: ../../library/subprocess.rst:1032 +#: ../../library/subprocess.rst:1044 msgid "**handle_list**" msgstr "**handle_list**" -#: ../../library/subprocess.rst:1033 +#: ../../library/subprocess.rst:1045 msgid "" "Sequence of handles that will be inherited. *close_fds* must be true if non-" "empty." msgstr "" -#: ../../library/subprocess.rst:1036 +#: ../../library/subprocess.rst:1048 msgid "" "The handles must be temporarily made inheritable by :func:`os." "set_handle_inheritable` when passed to the :class:`Popen` constructor, else :" @@ -1390,7 +1420,7 @@ msgid "" "``ERROR_INVALID_PARAMETER`` (87)." msgstr "" -#: ../../library/subprocess.rst:1043 +#: ../../library/subprocess.rst:1055 msgid "" "In a multithreaded process, use caution to avoid leaking handles that are " "marked inheritable when combining this feature with concurrent calls to " @@ -1399,110 +1429,110 @@ msgid "" "temporarily creates inheritable handles." msgstr "" -#: ../../library/subprocess.rst:1053 +#: ../../library/subprocess.rst:1065 msgid "Windows Constants" msgstr "" -#: ../../library/subprocess.rst:1055 +#: ../../library/subprocess.rst:1067 msgid "The :mod:`!subprocess` module exposes the following constants." msgstr "" -#: ../../library/subprocess.rst:1059 +#: ../../library/subprocess.rst:1071 msgid "" "The standard input device. Initially, this is the console input buffer, " "``CONIN$``." msgstr "" -#: ../../library/subprocess.rst:1064 +#: ../../library/subprocess.rst:1076 msgid "" "The standard output device. Initially, this is the active console screen " "buffer, ``CONOUT$``." msgstr "" -#: ../../library/subprocess.rst:1069 +#: ../../library/subprocess.rst:1081 msgid "" "The standard error device. Initially, this is the active console screen " "buffer, ``CONOUT$``." msgstr "" -#: ../../library/subprocess.rst:1074 +#: ../../library/subprocess.rst:1086 msgid "Hides the window. Another window will be activated." msgstr "" -#: ../../library/subprocess.rst:1078 +#: ../../library/subprocess.rst:1090 msgid "" "Specifies that the :attr:`STARTUPINFO.hStdInput`, :attr:`STARTUPINFO." "hStdOutput`, and :attr:`STARTUPINFO.hStdError` attributes contain additional " "information." msgstr "" -#: ../../library/subprocess.rst:1084 +#: ../../library/subprocess.rst:1096 msgid "" "Specifies that the :attr:`STARTUPINFO.wShowWindow` attribute contains " "additional information." msgstr "" -#: ../../library/subprocess.rst:1089 +#: ../../library/subprocess.rst:1101 msgid "" "A :attr:`STARTUPINFO.dwFlags` parameter to specify that the *Working in " "Background* mouse cursor will be displayed while a process is launching. " "This is the default behavior for GUI processes." msgstr "" -#: ../../library/subprocess.rst:1098 +#: ../../library/subprocess.rst:1110 msgid "" "A :attr:`STARTUPINFO.dwFlags` parameter to specify that the mouse cursor " "will not be changed when launching a process." msgstr "" -#: ../../library/subprocess.rst:1105 +#: ../../library/subprocess.rst:1117 msgid "" "The new process has a new console, instead of inheriting its parent's " "console (the default)." msgstr "" -#: ../../library/subprocess.rst:1110 +#: ../../library/subprocess.rst:1122 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "group will be created. This flag is necessary for using :func:`os.kill` on " "the subprocess." msgstr "" -#: ../../library/subprocess.rst:1114 +#: ../../library/subprocess.rst:1126 msgid "This flag is ignored if :data:`CREATE_NEW_CONSOLE` is specified." msgstr "" -#: ../../library/subprocess.rst:1118 +#: ../../library/subprocess.rst:1130 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "will have an above average priority." msgstr "" -#: ../../library/subprocess.rst:1125 +#: ../../library/subprocess.rst:1137 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "will have a below average priority." msgstr "" -#: ../../library/subprocess.rst:1132 +#: ../../library/subprocess.rst:1144 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "will have a high priority." msgstr "" -#: ../../library/subprocess.rst:1139 +#: ../../library/subprocess.rst:1151 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "will have an idle (lowest) priority." msgstr "" -#: ../../library/subprocess.rst:1146 +#: ../../library/subprocess.rst:1158 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "will have a normal priority. (default)" msgstr "" -#: ../../library/subprocess.rst:1153 +#: ../../library/subprocess.rst:1165 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "will have realtime priority. You should almost never use " @@ -1512,20 +1542,20 @@ msgid "" "perform brief tasks that should have limited interruptions." msgstr "" -#: ../../library/subprocess.rst:1164 +#: ../../library/subprocess.rst:1176 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "will not create a window." msgstr "" -#: ../../library/subprocess.rst:1171 +#: ../../library/subprocess.rst:1183 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "will not inherit its parent's console. This value cannot be used with " "CREATE_NEW_CONSOLE." msgstr "" -#: ../../library/subprocess.rst:1179 +#: ../../library/subprocess.rst:1191 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "does not inherit the error mode of the calling process. Instead, the new " @@ -1533,43 +1563,43 @@ msgid "" "multithreaded shell applications that run with hard errors disabled." msgstr "" -#: ../../library/subprocess.rst:1189 +#: ../../library/subprocess.rst:1201 msgid "" "A :class:`Popen` ``creationflags`` parameter to specify that a new process " "is not associated with the job." msgstr "" -#: ../../library/subprocess.rst:1197 +#: ../../library/subprocess.rst:1209 msgid "Older high-level API" msgstr "" -#: ../../library/subprocess.rst:1199 +#: ../../library/subprocess.rst:1211 msgid "" "Prior to Python 3.5, these three functions comprised the high level API to " "subprocess. You can now use :func:`run` in many cases, but lots of existing " "code calls these functions." msgstr "" -#: ../../library/subprocess.rst:1206 +#: ../../library/subprocess.rst:1218 msgid "" "Run the command described by *args*. Wait for command to complete, then " "return the :attr:`~Popen.returncode` attribute." msgstr "" -#: ../../library/subprocess.rst:1209 ../../library/subprocess.rst:1249 +#: ../../library/subprocess.rst:1221 ../../library/subprocess.rst:1261 msgid "" "Code needing to capture stdout or stderr should use :func:`run` instead::" msgstr "" -#: ../../library/subprocess.rst:1211 +#: ../../library/subprocess.rst:1223 msgid "run(...).returncode" msgstr "run(...).returncode" -#: ../../library/subprocess.rst:1213 ../../library/subprocess.rst:1253 +#: ../../library/subprocess.rst:1225 ../../library/subprocess.rst:1265 msgid "To suppress stdout or stderr, supply a value of :data:`DEVNULL`." msgstr "" -#: ../../library/subprocess.rst:1215 ../../library/subprocess.rst:1255 +#: ../../library/subprocess.rst:1227 ../../library/subprocess.rst:1267 msgid "" "The arguments shown above are merely some common ones. The full function " "signature is the same as that of the :class:`Popen` constructor - this " @@ -1577,14 +1607,14 @@ msgid "" "to that interface." msgstr "" -#: ../../library/subprocess.rst:1222 ../../library/subprocess.rst:1262 +#: ../../library/subprocess.rst:1234 ../../library/subprocess.rst:1274 msgid "" "Do not use ``stdout=PIPE`` or ``stderr=PIPE`` with this function. The child " "process will block if it generates enough output to a pipe to fill up the OS " "pipe buffer as the pipes are not being read from." msgstr "" -#: ../../library/subprocess.rst:1242 +#: ../../library/subprocess.rst:1254 msgid "" "Run command with arguments. Wait for command to complete. If the return " "code was zero then return, otherwise raise :exc:`CalledProcessError`. The :" @@ -1593,15 +1623,15 @@ msgid "" "to start the process it will propagate the exception that was raised." msgstr "" -#: ../../library/subprocess.rst:1251 +#: ../../library/subprocess.rst:1263 msgid "run(..., check=True)" msgstr "run(..., check=True)" -#: ../../library/subprocess.rst:1284 +#: ../../library/subprocess.rst:1296 msgid "Run command with arguments and return its output." msgstr "" -#: ../../library/subprocess.rst:1286 +#: ../../library/subprocess.rst:1298 msgid "" "If the return code was non-zero it raises a :exc:`CalledProcessError`. The :" "exc:`CalledProcessError` object will have the return code in the :attr:" @@ -1609,15 +1639,15 @@ msgid "" "`~CalledProcessError.output` attribute." msgstr "" -#: ../../library/subprocess.rst:1291 +#: ../../library/subprocess.rst:1303 msgid "This is equivalent to::" msgstr "這等同於: ::" -#: ../../library/subprocess.rst:1293 +#: ../../library/subprocess.rst:1305 msgid "run(..., check=True, stdout=PIPE).stdout" msgstr "run(..., check=True, stdout=PIPE).stdout" -#: ../../library/subprocess.rst:1295 +#: ../../library/subprocess.rst:1307 msgid "" "The arguments shown above are merely some common ones. The full function " "signature is largely the same as that of :func:`run` - most arguments are " @@ -1627,27 +1657,27 @@ msgid "" "using the parent's standard input file handle." msgstr "" -#: ../../library/subprocess.rst:1302 +#: ../../library/subprocess.rst:1314 msgid "" "By default, this function will return the data as encoded bytes. The actual " "encoding of the output data may depend on the command being invoked, so the " "decoding to text will often need to be handled at the application level." msgstr "" -#: ../../library/subprocess.rst:1306 +#: ../../library/subprocess.rst:1318 msgid "" "This behaviour may be overridden by setting *text*, *encoding*, *errors*, or " "*universal_newlines* to ``True`` as described in :ref:`frequently-used-" "arguments` and :func:`run`." msgstr "" -#: ../../library/subprocess.rst:1310 +#: ../../library/subprocess.rst:1322 msgid "" "To also capture standard error in the result, use ``stderr=subprocess." "STDOUT``::" msgstr "" -#: ../../library/subprocess.rst:1313 +#: ../../library/subprocess.rst:1325 msgid "" ">>> subprocess.check_output(\n" "... \"ls non_existent_file; exit 0\",\n" @@ -1661,32 +1691,32 @@ msgstr "" "... shell=True)\n" "'ls: non_existent_file: No such file or directory\\n'" -#: ../../library/subprocess.rst:1324 +#: ../../library/subprocess.rst:1336 msgid "Support for the *input* keyword argument was added." msgstr "新增 *input* 關鍵字引數的支援。" -#: ../../library/subprocess.rst:1327 +#: ../../library/subprocess.rst:1339 msgid "*encoding* and *errors* were added. See :func:`run` for details." msgstr "新增 *encoding* 與 *errors*。細節請見 :func:`run`。" -#: ../../library/subprocess.rst:1345 +#: ../../library/subprocess.rst:1357 msgid "Replacing Older Functions with the :mod:`!subprocess` Module" msgstr "" -#: ../../library/subprocess.rst:1347 +#: ../../library/subprocess.rst:1359 msgid "" "In this section, \"a becomes b\" means that b can be used as a replacement " "for a." msgstr "" -#: ../../library/subprocess.rst:1351 +#: ../../library/subprocess.rst:1363 msgid "" "All \"a\" functions in this section fail (more or less) silently if the " "executed program cannot be found; the \"b\" replacements raise :exc:" "`OSError` instead." msgstr "" -#: ../../library/subprocess.rst:1355 +#: ../../library/subprocess.rst:1367 msgid "" "In addition, the replacements using :func:`check_output` will fail with a :" "exc:`CalledProcessError` if the requested operation produces a non-zero " @@ -1694,38 +1724,38 @@ msgid "" "output` attribute of the raised exception." msgstr "" -#: ../../library/subprocess.rst:1360 +#: ../../library/subprocess.rst:1372 msgid "" "In the following examples, we assume that the relevant functions have " "already been imported from the :mod:`!subprocess` module." msgstr "" -#: ../../library/subprocess.rst:1365 +#: ../../library/subprocess.rst:1377 msgid "Replacing :program:`/bin/sh` shell command substitution" msgstr "" -#: ../../library/subprocess.rst:1367 +#: ../../library/subprocess.rst:1379 msgid "output=$(mycmd myarg)" msgstr "output=$(mycmd myarg)" -#: ../../library/subprocess.rst:1371 ../../library/subprocess.rst:1382 -#: ../../library/subprocess.rst:1399 +#: ../../library/subprocess.rst:1383 ../../library/subprocess.rst:1394 +#: ../../library/subprocess.rst:1411 msgid "becomes::" msgstr "變成: ::" -#: ../../library/subprocess.rst:1373 +#: ../../library/subprocess.rst:1385 msgid "output = check_output([\"mycmd\", \"myarg\"])" msgstr "output = check_output([\"mycmd\", \"myarg\"])" -#: ../../library/subprocess.rst:1376 +#: ../../library/subprocess.rst:1388 msgid "Replacing shell pipeline" msgstr "" -#: ../../library/subprocess.rst:1378 ../../library/subprocess.rst:1395 +#: ../../library/subprocess.rst:1390 ../../library/subprocess.rst:1407 msgid "output=$(dmesg | grep hda)" msgstr "output=$(dmesg | grep hda)" -#: ../../library/subprocess.rst:1384 +#: ../../library/subprocess.rst:1396 msgid "" "p1 = Popen([\"dmesg\"], stdout=PIPE)\n" "p2 = Popen([\"grep\", \"hda\"], stdin=p1.stdout, stdout=PIPE)\n" @@ -1733,27 +1763,27 @@ msgid "" "output = p2.communicate()[0]" msgstr "" -#: ../../library/subprocess.rst:1389 +#: ../../library/subprocess.rst:1401 msgid "" "The ``p1.stdout.close()`` call after starting the p2 is important in order " "for p1 to receive a SIGPIPE if p2 exits before p1." msgstr "" -#: ../../library/subprocess.rst:1392 +#: ../../library/subprocess.rst:1404 msgid "" "Alternatively, for trusted input, the shell's own pipeline support may still " "be used directly:" msgstr "" -#: ../../library/subprocess.rst:1401 +#: ../../library/subprocess.rst:1413 msgid "output = check_output(\"dmesg | grep hda\", shell=True)" msgstr "output = check_output(\"dmesg | grep hda\", shell=True)" -#: ../../library/subprocess.rst:1405 +#: ../../library/subprocess.rst:1417 msgid "Replacing :func:`os.system`" msgstr "取代 :func:`os.system`" -#: ../../library/subprocess.rst:1409 +#: ../../library/subprocess.rst:1421 msgid "" "sts = os.system(\"mycmd\" + \" myarg\")\n" "# becomes\n" @@ -1763,32 +1793,32 @@ msgstr "" "# 變成\n" "retcode = call(\"mycmd\" + \" myarg\", shell=True)" -#: ../../library/subprocess.rst:1413 +#: ../../library/subprocess.rst:1425 msgid "Notes:" msgstr "註解:" -#: ../../library/subprocess.rst:1415 +#: ../../library/subprocess.rst:1427 msgid "Calling the program through the shell is usually not required." msgstr "" -#: ../../library/subprocess.rst:1416 +#: ../../library/subprocess.rst:1428 msgid "" "The :func:`call` return value is encoded differently to that of :func:`os." "system`." msgstr "" -#: ../../library/subprocess.rst:1419 +#: ../../library/subprocess.rst:1431 msgid "" "The :func:`os.system` function ignores SIGINT and SIGQUIT signals while the " "command is running, but the caller must do this separately when using the :" "mod:`!subprocess` module." msgstr "" -#: ../../library/subprocess.rst:1423 +#: ../../library/subprocess.rst:1435 msgid "A more realistic example would look like this::" msgstr "" -#: ../../library/subprocess.rst:1425 +#: ../../library/subprocess.rst:1437 msgid "" "try:\n" " retcode = call(\"mycmd\" + \" myarg\", shell=True)\n" @@ -1810,15 +1840,15 @@ msgstr "" "except OSError as e:\n" " print(\"Execution failed:\", e, file=sys.stderr)" -#: ../../library/subprocess.rst:1436 +#: ../../library/subprocess.rst:1448 msgid "Replacing the :func:`os.spawn ` family" msgstr "" -#: ../../library/subprocess.rst:1438 +#: ../../library/subprocess.rst:1450 msgid "P_NOWAIT example::" msgstr "P_NOWAIT 範例: ::" -#: ../../library/subprocess.rst:1440 +#: ../../library/subprocess.rst:1452 msgid "" "pid = os.spawnlp(os.P_NOWAIT, \"/bin/mycmd\", \"mycmd\", \"myarg\")\n" "==>\n" @@ -1828,11 +1858,11 @@ msgstr "" "==>\n" "pid = Popen([\"/bin/mycmd\", \"myarg\"]).pid" -#: ../../library/subprocess.rst:1444 +#: ../../library/subprocess.rst:1456 msgid "P_WAIT example::" msgstr "P_WAIT 範例: ::" -#: ../../library/subprocess.rst:1446 +#: ../../library/subprocess.rst:1458 msgid "" "retcode = os.spawnlp(os.P_WAIT, \"/bin/mycmd\", \"mycmd\", \"myarg\")\n" "==>\n" @@ -1842,11 +1872,11 @@ msgstr "" "==>\n" "retcode = call([\"/bin/mycmd\", \"myarg\"])" -#: ../../library/subprocess.rst:1450 +#: ../../library/subprocess.rst:1462 msgid "Vector example::" msgstr "向量範例: ::" -#: ../../library/subprocess.rst:1452 +#: ../../library/subprocess.rst:1464 msgid "" "os.spawnvp(os.P_NOWAIT, path, args)\n" "==>\n" @@ -1856,11 +1886,11 @@ msgstr "" "==>\n" "Popen([path] + args[1:])" -#: ../../library/subprocess.rst:1456 +#: ../../library/subprocess.rst:1468 msgid "Environment example::" msgstr "環境範例: ::" -#: ../../library/subprocess.rst:1458 +#: ../../library/subprocess.rst:1470 msgid "" "os.spawnlpe(os.P_NOWAIT, \"/bin/mycmd\", \"mycmd\", \"myarg\", env)\n" "==>\n" @@ -1870,15 +1900,15 @@ msgstr "" "==>\n" "Popen([\"/bin/mycmd\", \"myarg\"], env={\"PATH\": \"/usr/bin\"})" -#: ../../library/subprocess.rst:1465 +#: ../../library/subprocess.rst:1477 msgid "Replacing :func:`os.popen`" msgstr "取代 :func:`os.popen`" -#: ../../library/subprocess.rst:1467 +#: ../../library/subprocess.rst:1479 msgid "Return code handling translates as follows::" msgstr "" -#: ../../library/subprocess.rst:1469 +#: ../../library/subprocess.rst:1481 msgid "" "pipe = os.popen(cmd, 'w')\n" "...\n" @@ -1904,11 +1934,11 @@ msgstr "" "if process.wait() != 0:\n" " print(\"There were some errors\")" -#: ../../library/subprocess.rst:1483 +#: ../../library/subprocess.rst:1495 msgid "Legacy Shell Invocation Functions" msgstr "" -#: ../../library/subprocess.rst:1485 +#: ../../library/subprocess.rst:1497 msgid "" "This module also provides the following legacy functions from the 2.x " "``commands`` module. These operations implicitly invoke the system shell and " @@ -1916,24 +1946,24 @@ msgid "" "handling consistency are valid for these functions." msgstr "" -#: ../../library/subprocess.rst:1492 +#: ../../library/subprocess.rst:1504 msgid "Return ``(exitcode, output)`` of executing *cmd* in a shell." msgstr "" -#: ../../library/subprocess.rst:1494 +#: ../../library/subprocess.rst:1506 msgid "" "Execute the string *cmd* in a shell with :func:`check_output` and return a 2-" "tuple ``(exitcode, output)``. *encoding* and *errors* are used to decode " "output; see the notes on :ref:`frequently-used-arguments` for more details." msgstr "" -#: ../../library/subprocess.rst:1499 +#: ../../library/subprocess.rst:1511 msgid "" "A trailing newline is stripped from the output. The exit code for the " "command can be interpreted as the return code of subprocess. Example::" msgstr "" -#: ../../library/subprocess.rst:1503 +#: ../../library/subprocess.rst:1515 msgid "" ">>> subprocess.getstatusoutput('ls /bin/ls')\n" "(0, '/bin/ls')\n" @@ -1953,28 +1983,28 @@ msgstr "" ">>> subprocess.getstatusoutput('/bin/kill $$')\n" "(-15, '')" -#: ../../library/subprocess.rst:1514 +#: ../../library/subprocess.rst:1526 msgid "Windows support was added." msgstr "新增對 Windows 的支援。" -#: ../../library/subprocess.rst:1517 +#: ../../library/subprocess.rst:1529 msgid "" "The function now returns (exitcode, output) instead of (status, output) as " "it did in Python 3.3.3 and earlier. exitcode has the same value as :attr:" "`~Popen.returncode`." msgstr "" -#: ../../library/subprocess.rst:1526 +#: ../../library/subprocess.rst:1538 msgid "Return output (stdout and stderr) of executing *cmd* in a shell." msgstr "" -#: ../../library/subprocess.rst:1528 +#: ../../library/subprocess.rst:1540 msgid "" "Like :func:`getstatusoutput`, except the exit code is ignored and the return " "value is a string containing the command's output. Example::" msgstr "" -#: ../../library/subprocess.rst:1531 +#: ../../library/subprocess.rst:1543 msgid "" ">>> subprocess.getoutput('ls /bin/ls')\n" "'/bin/ls'" @@ -1982,26 +2012,26 @@ msgstr "" ">>> subprocess.getoutput('ls /bin/ls')\n" "'/bin/ls'" -#: ../../library/subprocess.rst:1536 +#: ../../library/subprocess.rst:1548 msgid "Windows support added" msgstr "新增對 Windows 的支援" -#: ../../library/subprocess.rst:1544 +#: ../../library/subprocess.rst:1556 msgid "Notes" msgstr "註解" -#: ../../library/subprocess.rst:1549 +#: ../../library/subprocess.rst:1561 msgid "Timeout Behavior" msgstr "" -#: ../../library/subprocess.rst:1551 +#: ../../library/subprocess.rst:1563 msgid "" "When using the ``timeout`` parameter in functions like :func:`run`, :meth:" "`Popen.wait`, or :meth:`Popen.communicate`, users should be aware of the " "following behaviors:" msgstr "" -#: ../../library/subprocess.rst:1555 +#: ../../library/subprocess.rst:1567 msgid "" "**Process Creation Delay**: The initial process creation itself cannot be " "interrupted on many platform APIs. This means that even when specifying a " @@ -2009,7 +2039,7 @@ msgid "" "after however long process creation takes." msgstr "" -#: ../../library/subprocess.rst:1560 +#: ../../library/subprocess.rst:1572 msgid "" "**Extremely Small Timeout Values**: Setting very small timeout values (such " "as a few milliseconds) may result in almost immediate :exc:`TimeoutExpired` " @@ -2017,42 +2047,42 @@ msgid "" "time." msgstr "" -#: ../../library/subprocess.rst:1567 +#: ../../library/subprocess.rst:1579 msgid "Converting an argument sequence to a string on Windows" msgstr "" -#: ../../library/subprocess.rst:1569 +#: ../../library/subprocess.rst:1581 msgid "" "On Windows, an *args* sequence is converted to a string that can be parsed " "using the following rules (which correspond to the rules used by the MS C " "runtime):" msgstr "" -#: ../../library/subprocess.rst:1573 +#: ../../library/subprocess.rst:1585 msgid "" "Arguments are delimited by white space, which is either a space or a tab." msgstr "" -#: ../../library/subprocess.rst:1576 +#: ../../library/subprocess.rst:1588 msgid "" "A string surrounded by double quotation marks is interpreted as a single " "argument, regardless of white space contained within. A quoted string can " "be embedded in an argument." msgstr "" -#: ../../library/subprocess.rst:1581 +#: ../../library/subprocess.rst:1593 msgid "" "A double quotation mark preceded by a backslash is interpreted as a literal " "double quotation mark." msgstr "" -#: ../../library/subprocess.rst:1584 +#: ../../library/subprocess.rst:1596 msgid "" "Backslashes are interpreted literally, unless they immediately precede a " "double quotation mark." msgstr "" -#: ../../library/subprocess.rst:1587 +#: ../../library/subprocess.rst:1599 msgid "" "If backslashes immediately precede a double quotation mark, every pair of " "backslashes is interpreted as a literal backslash. If the number of " @@ -2060,19 +2090,19 @@ msgid "" "mark as described in rule 3." msgstr "" -#: ../../library/subprocess.rst:1596 +#: ../../library/subprocess.rst:1608 msgid ":mod:`shlex`" msgstr ":mod:`shlex`" -#: ../../library/subprocess.rst:1597 +#: ../../library/subprocess.rst:1609 msgid "Module which provides function to parse and escape command lines." msgstr "" -#: ../../library/subprocess.rst:1603 +#: ../../library/subprocess.rst:1615 msgid "Disable use of ``posix_spawn()``" msgstr "停用 ``posix_spawn()``" -#: ../../library/subprocess.rst:1605 +#: ../../library/subprocess.rst:1617 msgid "" "On Linux, :mod:`!subprocess` defaults to using the ``vfork()`` system call " "internally when it is safe to do so rather than ``fork()``. This greatly " @@ -2081,11 +2111,11 @@ msgstr "" "在 Linux 上,:mod:`!subprocess` 在安全的情況下預設會在內部使用 ``vfork()`` 系" "統呼叫,而不是 ``fork()``,這顯著地提高了性能。" -#: ../../library/subprocess.rst:1611 +#: ../../library/subprocess.rst:1623 msgid "subprocess._USE_POSIX_SPAWN = False # See CPython issue gh-NNNNNN." msgstr "subprocess._USE_POSIX_SPAWN = False # 見 CPython 問題 gh-NNNNNN。" -#: ../../library/subprocess.rst:1613 +#: ../../library/subprocess.rst:1625 msgid "" "It is safe to set this to false on any Python version. It will have no " "effect on older or newer versions where unsupported. Do not assume the " @@ -2096,7 +2126,7 @@ msgstr "" "沒有支援的新版本沒有影響。不要假設屬性可供讀取。儘管它的名稱是這樣,真實值並" "不表示將使用相應的函式,而只是表示可能會使用。" -#: ../../library/subprocess.rst:1618 +#: ../../library/subprocess.rst:1630 msgid "" "Please file issues any time you have to use these private knobs with a way " "to reproduce the issue you were seeing. Link to that issue from a comment in " @@ -2105,14 +2135,14 @@ msgstr "" "每當你需要使用這些私有開關以重現你所看到的問題時,請隨時提出問題 (file " "issues)。從程式碼中的註解連結到該問題。" -#: ../../library/subprocess.rst:1622 +#: ../../library/subprocess.rst:1634 msgid "``_USE_POSIX_SPAWN``" msgstr "``_USE_POSIX_SPAWN``" -#: ../../library/subprocess.rst:296 +#: ../../library/subprocess.rst:293 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/subprocess.rst:296 +#: ../../library/subprocess.rst:293 msgid "subprocess module" msgstr "subprocess 模組" diff --git a/library/superseded.po b/library/superseded.po index 1691e7d24c7..b68bf5e28e4 100644 --- a/library/superseded.po +++ b/library/superseded.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-29 11:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-06-28 12:28+0800\n" "Last-Translator: Weilin Du \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,7 +20,7 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/superseded.rst:5 -msgid "Superseded Modules" +msgid "Superseded modules" msgstr "已被取代的模組" #: ../../library/superseded.rst:7 diff --git a/library/symtable.po b/library/symtable.po index 4ee9a1773b9..34b8f225b09 100644 --- a/library/symtable.po +++ b/library/symtable.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -26,7 +26,7 @@ msgstr ":mod:`!symtable` --- 存取編譯器的符號表" msgid "**Source code:** :source:`Lib/symtable.py`" msgstr "**原始碼:**\\ :source:`Lib/symtable.py`" -#: ../../library/symtable.rst:15 +#: ../../library/symtable.rst:11 msgid "" "Symbol tables are generated by the compiler from AST just before bytecode is " "generated. The symbol table is responsible for calculating the scope of " @@ -37,55 +37,63 @@ msgstr "" "符號表負責計算程式碼中每個識別器 (identifier) 的作用域。:mod:`!symtable` 提供" "了一個介面來檢查這些表。" -#: ../../library/symtable.rst:22 +#: ../../library/symtable.rst:18 msgid "Generating Symbol Tables" msgstr "產生符號表" -#: ../../library/symtable.rst:26 +#: ../../library/symtable.rst:22 msgid "" "Return the toplevel :class:`SymbolTable` for the Python source *code*. " "*filename* is the name of the file containing the code. *compile_type* is " -"like the *mode* argument to :func:`compile`." +"like the *mode* argument to :func:`compile`. The optional argument *module* " +"specifies the module name. It is needed to unambiguous :ref:`filter ` syntax warnings by module name." msgstr "" "回傳 Python 原始 *code* 的頂層 :class:`SymbolTable`。*filename* 是包含程式碼" -"之檔案之名稱。*compile_type* 類似於 :func:`compile` 的 *mode* 引數。" +"之檔案之名稱。*compile_type* 類似於 :func:`compile` 的 *mode* 引數。選擇性引" +"數 *module* 指定模組名稱,需要它才能依模組名稱明確地\\ :ref:`過濾 `\\ 語法警告。" -#: ../../library/symtable.rst:32 +#: ../../library/symtable.rst:29 +msgid "Added the *module* parameter." +msgstr "新增 *module* 參數。" + +#: ../../library/symtable.rst:34 msgid "Examining Symbol Tables" msgstr "檢查符號表" -#: ../../library/symtable.rst:36 +#: ../../library/symtable.rst:38 msgid "An enumeration indicating the type of a :class:`SymbolTable` object." msgstr "表明 :class:`SymbolTable` 物件型別的列舉。" -#: ../../library/symtable.rst:41 +#: ../../library/symtable.rst:43 msgid "Used for the symbol table of a module." msgstr "用於模組的符號表。" -#: ../../library/symtable.rst:46 +#: ../../library/symtable.rst:48 msgid "Used for the symbol table of a function." msgstr "用於函式的符號表。" -#: ../../library/symtable.rst:51 +#: ../../library/symtable.rst:53 msgid "Used for the symbol table of a class." msgstr "用於類別的符號表。" -#: ../../library/symtable.rst:53 +#: ../../library/symtable.rst:55 msgid "" "The following members refer to different flavors of :ref:`annotation scopes " "`." msgstr "以下成員代表不同風格的\\ :ref:`註釋作用域 `。" -#: ../../library/symtable.rst:59 +#: ../../library/symtable.rst:61 msgid "" "Used for annotations if ``from __future__ import annotations`` is active." msgstr "如果 ``from __future__ import annotations`` 處於活動狀態,則用於註解。" -#: ../../library/symtable.rst:64 +#: ../../library/symtable.rst:66 msgid "Used for the symbol table of :keyword:`type` constructions." msgstr "用於 :keyword:`type` 結構的符號表。" -#: ../../library/symtable.rst:69 +#: ../../library/symtable.rst:71 msgid "" "Used for the symbol table of :ref:`generic functions ` " "or :ref:`generic classes `." @@ -93,7 +101,7 @@ msgstr "" "用於\\ :ref:`泛型函式 (generic functions) `\\ 或\\ :ref:`" "泛型類別 (generic classes) `\\ 的符號表。" -#: ../../library/symtable.rst:75 +#: ../../library/symtable.rst:77 msgid "" "Used for the symbol table of the bound, the constraint tuple or the default " "value of a single type variable in the formal sense, i.e., a TypeVar, a " @@ -104,19 +112,19 @@ msgstr "" "變數的預設值的符號表,即 TypeVar、TypeVarTuple 或 ParamSpec 物件(後兩者不支" "援繫結或約束元組)。" -#: ../../library/symtable.rst:84 +#: ../../library/symtable.rst:86 msgid "A namespace table for a block. The constructor is not public." msgstr "" "一個區塊 (block) 的命名空間表 (namespace table) 。建構函式 (constructor) 並不" "公開。" -#: ../../library/symtable.rst:88 +#: ../../library/symtable.rst:90 msgid "" "Return the type of the symbol table. Possible values are members of the :" "class:`SymbolTableType` enumeration." msgstr "回傳符號表的類型。可能的值為 :class:`SymbolTableType` 列舉的成員。" -#: ../../library/symtable.rst:91 +#: ../../library/symtable.rst:93 msgid "" "Added ``'annotation'``, ``'TypeVar bound'``, ``'type alias'``, and ``'type " "parameter'`` as possible return values." @@ -124,11 +132,11 @@ msgstr "" "新增了 ``'annotation'``、``'TypeVar bound'``、``'type alias'`` 和 ``'type " "parameter'`` 作為可能的回傳值。" -#: ../../library/symtable.rst:95 +#: ../../library/symtable.rst:97 msgid "Return values are members of the :class:`SymbolTableType` enumeration." msgstr "回傳值是 :class:`SymbolTableType` 列舉的成員。" -#: ../../library/symtable.rst:98 +#: ../../library/symtable.rst:100 msgid "" "The exact values of the returned string may change in the future, and thus, " "it is recommended to use :class:`SymbolTableType` members instead of hard-" @@ -137,11 +145,11 @@ msgstr "" "回傳字串的確切值在未來可能會發生變化,因此建議使用 :class:`SymbolTableType` " "成員而不是寫死 (hard-coded) 字串。" -#: ../../library/symtable.rst:104 +#: ../../library/symtable.rst:106 msgid "Return the table's identifier." msgstr "回傳表的識別器。" -#: ../../library/symtable.rst:108 +#: ../../library/symtable.rst:110 msgid "" "Return the table's name. This is the name of the class if the table is for " "a class, the name of the function if the table is for a function, or " @@ -157,19 +165,19 @@ msgstr "" "類別、函式或型別別名的名稱。對於型別別名作用域,它是型別別名的名稱。對於 :" "class:`~typing.TypeVar` 綁定作用域,它會是 ``TypeVar`` 的名稱。" -#: ../../library/symtable.rst:118 +#: ../../library/symtable.rst:120 msgid "Return the number of the first line in the block this table represents." msgstr "回傳此表所代表的區塊中第一行的編號。" -#: ../../library/symtable.rst:122 +#: ../../library/symtable.rst:124 msgid "Return ``True`` if the locals in this table can be optimized." msgstr "如果可以最佳化該表中的區域變數,則回傳 ``True``。" -#: ../../library/symtable.rst:126 +#: ../../library/symtable.rst:128 msgid "Return ``True`` if the block is a nested class or function." msgstr "如果區塊是巢狀類別或函式,則回傳 ``True``。" -#: ../../library/symtable.rst:130 +#: ../../library/symtable.rst:132 msgid "" "Return ``True`` if the block has nested namespaces within it. These can be " "obtained with :meth:`get_children`." @@ -177,7 +185,7 @@ msgstr "" "如果區塊內有巢狀命名空間,則回傳 ``True``。這些可以透過 :meth:`get_children` " "獲得。" -#: ../../library/symtable.rst:135 +#: ../../library/symtable.rst:137 msgid "" "Return a view object containing the names of symbols in the table. See the :" "ref:`documentation of view objects `." @@ -185,43 +193,43 @@ msgstr "" "回傳包含表中符號之名稱的視圖物件 (view object)。請參閱\\ :ref:`視圖物件的文" "件 `。" -#: ../../library/symtable.rst:140 +#: ../../library/symtable.rst:142 msgid "Lookup *name* in the table and return a :class:`Symbol` instance." msgstr "在表中查找 *name* 並回傳一個 :class:`Symbol` 實例。" -#: ../../library/symtable.rst:144 +#: ../../library/symtable.rst:146 msgid "Return a list of :class:`Symbol` instances for names in the table." msgstr "回傳表中名稱的 :class:`Symbol` 實例串列。" -#: ../../library/symtable.rst:148 +#: ../../library/symtable.rst:150 msgid "Return a list of the nested symbol tables." msgstr "回傳巢狀符號表的串列。" -#: ../../library/symtable.rst:153 +#: ../../library/symtable.rst:155 msgid "" "A namespace for a function or method. This class inherits from :class:" "`SymbolTable`." msgstr "一個函式或方法的命名空間。該類別繼承自 :class:`SymbolTable`。" -#: ../../library/symtable.rst:158 +#: ../../library/symtable.rst:160 msgid "Return a tuple containing names of parameters to this function." msgstr "回傳一個包含此函式參數名稱的元組 (tuple)。" -#: ../../library/symtable.rst:162 +#: ../../library/symtable.rst:164 msgid "Return a tuple containing names of locals in this function." msgstr "回傳一個包含此函式中區域變數 (locals) 名稱的元組。" -#: ../../library/symtable.rst:166 +#: ../../library/symtable.rst:168 msgid "Return a tuple containing names of globals in this function." msgstr "回傳一個包含此函式中全域變數 (globals) 名稱的元組。" -#: ../../library/symtable.rst:170 +#: ../../library/symtable.rst:172 msgid "" "Return a tuple containing names of explicitly declared nonlocals in this " "function." msgstr "回傳一個包含此函式中明確宣告的非區域變數 (nonlocals) 名稱的元組。" -#: ../../library/symtable.rst:174 +#: ../../library/symtable.rst:176 msgid "" "Return a tuple containing names of :term:`free (closure) variables ` in this function." @@ -229,17 +237,25 @@ msgstr "" "回傳一個包含此函式中的\\ :term:`自由(閉包)變數 (free (closure) variables) " "` 名稱的元組。" -#: ../../library/symtable.rst:180 +#: ../../library/symtable.rst:181 +msgid "" +"Return a tuple containing names of :term:`cell variables ` " +"in this table." +msgstr "" +"回傳一個包含此表中的\\ :term:`cell 變數 (cell variables) ` " +"名稱的元組。" + +#: ../../library/symtable.rst:188 msgid "A namespace of a class. This class inherits from :class:`SymbolTable`." msgstr "一個類別的命名空間。該類別繼承自 :class:`SymbolTable`。" -#: ../../library/symtable.rst:184 +#: ../../library/symtable.rst:192 msgid "" "Return a tuple containing the names of method-like functions declared in the " "class." msgstr "回傳一個包含類別中聲明的類似方法之函式名稱的元組。" -#: ../../library/symtable.rst:187 +#: ../../library/symtable.rst:195 msgid "" "Here, the term 'method' designates *any* function defined in the class body " "via :keyword:`def` or :keyword:`async def`." @@ -247,18 +263,18 @@ msgstr "" "在這裡,術語「方法 (method)」表示透過 :keyword:`def` 或 :keyword:`async def` " "在類別主體中定義的\\ *任何*\\ 函式。" -#: ../../library/symtable.rst:190 +#: ../../library/symtable.rst:198 msgid "" "Functions defined in a deeper scope (e.g., in an inner class) are not picked " "up by :meth:`get_methods`." msgstr "" ":meth:`get_methods` 不會取得更深作用域內定義的函式(例如在內部類別中)。" -#: ../../library/symtable.rst:193 +#: ../../library/symtable.rst:201 msgid "For example:" msgstr "舉例來說:" -#: ../../library/symtable.rst:206 +#: ../../library/symtable.rst:214 msgid "" ">>> import symtable\n" ">>> st = symtable.symtable('''\n" @@ -300,7 +316,7 @@ msgstr "" ">>> class_A.get_methods()\n" "('f', 'g', 'h')" -#: ../../library/symtable.rst:228 +#: ../../library/symtable.rst:236 msgid "" "Although ``A().f()`` raises :exc:`TypeError` at runtime, ``A.f`` is still " "considered as a method-like function." @@ -308,55 +324,55 @@ msgstr "" "儘管 ``A().f()`` 會在 runtime 引發 :exc:`TypeError`,但 ``A.f`` 仍然被視為類" "似方法的函式。" -#: ../../library/symtable.rst:236 +#: ../../library/symtable.rst:244 msgid "" "An entry in a :class:`SymbolTable` corresponding to an identifier in the " "source. The constructor is not public." msgstr "" ":class:`SymbolTable` 中的條目對應於來源中的識別器。建構函式不是公開的。" -#: ../../library/symtable.rst:241 +#: ../../library/symtable.rst:249 msgid "Return the symbol's name." msgstr "回傳符號的名稱。" -#: ../../library/symtable.rst:245 +#: ../../library/symtable.rst:253 msgid "Return ``True`` if the symbol is used in its block." msgstr "如果該符號在其區塊中使用,則回傳 ``True``。" -#: ../../library/symtable.rst:249 +#: ../../library/symtable.rst:257 msgid "Return ``True`` if the symbol is created from an import statement." msgstr "如果符號是從 import 陳述式建立的,則回傳 ``True``。" -#: ../../library/symtable.rst:253 +#: ../../library/symtable.rst:261 msgid "Return ``True`` if the symbol is a parameter." msgstr "如果符號是一個參數,則回傳 ``True``。" -#: ../../library/symtable.rst:257 +#: ../../library/symtable.rst:265 msgid "Return ``True`` if the symbol is a type parameter." msgstr "如果符號是一個型別參數,則回傳 ``True``。" -#: ../../library/symtable.rst:263 +#: ../../library/symtable.rst:271 msgid "Return ``True`` if the symbol is global." msgstr "如果符號是全域的,則回傳 ``True``。" -#: ../../library/symtable.rst:267 +#: ../../library/symtable.rst:275 msgid "Return ``True`` if the symbol is nonlocal." msgstr "如果符號是非區域的,則回傳 ``True``。" -#: ../../library/symtable.rst:271 +#: ../../library/symtable.rst:279 msgid "" "Return ``True`` if the symbol is declared global with a global statement." msgstr "如果使用全域陳述式將符號聲明為全域的,則回傳 ``True``。" -#: ../../library/symtable.rst:275 +#: ../../library/symtable.rst:283 msgid "Return ``True`` if the symbol is local to its block." msgstr "如果符號是其區塊的區域符號,則回傳 ``True``。" -#: ../../library/symtable.rst:279 +#: ../../library/symtable.rst:287 msgid "Return ``True`` if the symbol is annotated." msgstr "如果符號有被註釋,則回傳 ``True``。" -#: ../../library/symtable.rst:285 +#: ../../library/symtable.rst:293 msgid "" "Return ``True`` if the symbol is referenced in its block, but not assigned " "to." @@ -364,17 +380,25 @@ msgstr "" "如果該符號在其區塊中被參照 (referenced) 但未被賦值 (assigned),則回傳 " "``True``。" -#: ../../library/symtable.rst:290 +#: ../../library/symtable.rst:298 +msgid "" +"Return ``True`` if the symbol is referenced but not assigned in a nested " +"block." +msgstr "" +"如果該符號在巢狀區塊中被參照 (referenced) 但未被賦值 (assigned),則回傳 " +"``True``。" + +#: ../../library/symtable.rst:304 msgid "" "Return *True* if a class-scoped symbol is free from the perspective of a " "method." msgstr "" -#: ../../library/symtable.rst:293 +#: ../../library/symtable.rst:307 msgid "Consider the following example::" msgstr "參考以下範例: ::" -#: ../../library/symtable.rst:295 +#: ../../library/symtable.rst:309 msgid "" "def f():\n" " x = 1 # function-scoped\n" @@ -390,40 +414,40 @@ msgstr "" " def method(self):\n" " return x" -#: ../../library/symtable.rst:302 +#: ../../library/symtable.rst:316 msgid "" "In this example, the class-scoped symbol ``x`` is considered to be free from " "the perspective of ``C.method``, thereby allowing the latter to return *1* " "at runtime and not *2*." msgstr "" -#: ../../library/symtable.rst:310 +#: ../../library/symtable.rst:324 msgid "Return ``True`` if the symbol is assigned to in its block." msgstr "如果該符號被賦值到其區塊中,則回傳 ``True``。" -#: ../../library/symtable.rst:314 +#: ../../library/symtable.rst:328 msgid "Return ``True`` if the symbol is a comprehension iteration variable." msgstr "" -#: ../../library/symtable.rst:320 +#: ../../library/symtable.rst:334 msgid "Return ``True`` if the symbol is a cell in an inlined comprehension." msgstr "" -#: ../../library/symtable.rst:326 +#: ../../library/symtable.rst:340 msgid "Return ``True`` if name binding introduces new namespace." msgstr "如果名稱綁定引入 (introduce) 新的命名空間,則回傳 ``True``。" -#: ../../library/symtable.rst:328 +#: ../../library/symtable.rst:342 msgid "" "If the name is used as the target of a function or class statement, this " "will be true." msgstr "如果名稱用作函式或類別陳述式的目標,則這將會是 true。" -#: ../../library/symtable.rst:331 +#: ../../library/symtable.rst:345 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/symtable.rst:333 +#: ../../library/symtable.rst:347 msgid "" ">>> table = symtable.symtable(\"def some_func(): pass\", \"string\", " "\"exec\")\n" @@ -435,7 +459,7 @@ msgstr "" ">>> table.lookup(\"some_func\").is_namespace()\n" "True" -#: ../../library/symtable.rst:337 +#: ../../library/symtable.rst:351 msgid "" "Note that a single name can be bound to multiple objects. If the result is " "``True``, the name may also be bound to other objects, like an int or list, " @@ -444,11 +468,11 @@ msgstr "" "請注意,單個名稱可以綁定到多個物件。如果結果為 ``True``,則該名稱也可能被綁定" "到其他物件,例如 int 或 list,而不會引入新的命名空間。" -#: ../../library/symtable.rst:343 +#: ../../library/symtable.rst:357 msgid "Return a list of namespaces bound to this name." msgstr "回傳綁定到該名稱的命名空間的串列。" -#: ../../library/symtable.rst:347 +#: ../../library/symtable.rst:361 msgid "" "Return the namespace bound to this name. If more than one or no namespace is " "bound to this name, a :exc:`ValueError` is raised." @@ -456,21 +480,21 @@ msgstr "" "回傳綁定到該名稱的命名空間。如果該名稱綁定了多個命名空間或沒有命名空間,則會" "引發 :exc:`ValueError`。" -#: ../../library/symtable.rst:354 +#: ../../library/symtable.rst:368 msgid "Command-Line Usage" msgstr "命令列用法" -#: ../../library/symtable.rst:358 +#: ../../library/symtable.rst:372 msgid "" "The :mod:`!symtable` module can be executed as a script from the command " "line." msgstr ":mod:`!symtable` 模組可以從命令列作為腳本執行。" -#: ../../library/symtable.rst:360 +#: ../../library/symtable.rst:374 msgid "python -m symtable [infile...]" msgstr "python -m symtable [infile...]" -#: ../../library/symtable.rst:364 +#: ../../library/symtable.rst:378 msgid "" "Symbol tables are generated for the specified Python source files and dumped " "to stdout. If no input file is specified, the content is read from stdin." diff --git a/library/sys.monitoring.po b/library/sys.monitoring.po index d08aa8a3e67..ccb6ee9d1a5 100644 --- a/library/sys.monitoring.po +++ b/library/sys.monitoring.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-15 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-11-07 17:51+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -300,11 +300,11 @@ msgstr "區域事件" #: ../../library/sys.monitoring.rst:189 msgid "" "Local events are associated with normal execution of the program and happen " -"at clearly defined locations. All local events can be disabled. The local " -"events are:" +"at clearly defined locations. All local events can be disabled per location. " +"The local events are:" msgstr "" -"區域事件與程式的正常執行相關,並發生在明確定義的位置。所有區域事件都可以被停" -"用。區域事件有:" +"區域事件與程式的正常執行相關,並發生在明確定義的位置。所有區域事件都可以針對" +"個別位置停用。區域事件有:" #: ../../library/sys.monitoring.rst:193 msgid ":monitoring-event:`PY_START`" @@ -365,25 +365,25 @@ msgid "" "better performance as they can be disabled independently." msgstr "" -#: ../../library/sys.monitoring.rst:216 +#: ../../library/sys.monitoring.rst:218 msgid "Ancillary events" msgstr "附屬事件 (ancillary events)" -#: ../../library/sys.monitoring.rst:218 +#: ../../library/sys.monitoring.rst:220 msgid "" "Ancillary events can be monitored like other events, but are controlled by " "another event:" msgstr "附屬事件可以像其他事件一樣被監控,但由另一個事件所控制:" -#: ../../library/sys.monitoring.rst:221 +#: ../../library/sys.monitoring.rst:223 msgid ":monitoring-event:`C_RAISE`" msgstr ":monitoring-event:`C_RAISE`" -#: ../../library/sys.monitoring.rst:222 +#: ../../library/sys.monitoring.rst:224 msgid ":monitoring-event:`C_RETURN`" msgstr ":monitoring-event:`C_RETURN`" -#: ../../library/sys.monitoring.rst:224 +#: ../../library/sys.monitoring.rst:226 msgid "" "The :monitoring-event:`C_RETURN` and :monitoring-event:`C_RAISE` events are " "controlled by the :monitoring-event:`CALL` event. :monitoring-event:" @@ -395,42 +395,54 @@ msgstr "" "受到監控時,才會看到 :monitoring-event:`C_RETURN` 和 :monitoring-event:" "`C_RAISE` 事件。" -#: ../../library/sys.monitoring.rst:233 +#: ../../library/sys.monitoring.rst:235 msgid "Other events" msgstr "其他事件" -#: ../../library/sys.monitoring.rst:235 +#: ../../library/sys.monitoring.rst:237 msgid "" "Other events are not necessarily tied to a specific location in the program " -"and cannot be individually disabled via :data:`DISABLE`." -msgstr "" -"其他事件不一定與程式中的特定位置相關聯,也不能透過 :data:`DISABLE` 單獨停用。" +"and cannot be individually disabled per location." +msgstr "其他事件不一定與程式中的特定位置相關聯,也不能針對個別位置單獨停用。" -#: ../../library/sys.monitoring.rst:238 +#: ../../library/sys.monitoring.rst:240 msgid "The other events that can be monitored are:" msgstr "其他可以監控的事件有:" -#: ../../library/sys.monitoring.rst:240 +#: ../../library/sys.monitoring.rst:242 msgid ":monitoring-event:`PY_THROW`" msgstr ":monitoring-event:`PY_THROW`" -#: ../../library/sys.monitoring.rst:241 +#: ../../library/sys.monitoring.rst:243 msgid ":monitoring-event:`PY_UNWIND`" msgstr ":monitoring-event:`PY_UNWIND`" -#: ../../library/sys.monitoring.rst:242 +#: ../../library/sys.monitoring.rst:244 msgid ":monitoring-event:`RAISE`" msgstr ":monitoring-event:`RAISE`" -#: ../../library/sys.monitoring.rst:243 +#: ../../library/sys.monitoring.rst:245 msgid ":monitoring-event:`EXCEPTION_HANDLED`" msgstr ":monitoring-event:`EXCEPTION_HANDLED`" -#: ../../library/sys.monitoring.rst:247 +#: ../../library/sys.monitoring.rst:246 +msgid ":monitoring-event:`RERAISE`" +msgstr ":monitoring-event:`RERAISE`" + +#: ../../library/sys.monitoring.rst:248 +msgid "" +"Other events can now be turned on and disabled on a per code object basis. " +"Returning :data:`DISABLE` from a callback disables the event for the entire " +"code object (for the current tool)." +msgstr "" +"其他事件現在可以針對個別程式碼物件開啟和停用。從回呼函式回傳 :data:`DISABLE` " +"會為整個程式碼物件停用該事件(針對目前的工具)。" + +#: ../../library/sys.monitoring.rst:255 msgid "The STOP_ITERATION event" msgstr "STOP_ITERATION 事件" -#: ../../library/sys.monitoring.rst:249 +#: ../../library/sys.monitoring.rst:257 msgid "" ":pep:`PEP 380 <380#use-of-stopiteration-to-return-values>` specifies that a :" "exc:`StopIteration` exception is raised when returning a value from a " @@ -443,18 +455,17 @@ msgstr "" "式,因此有一些 Python 實作(特別是 CPython 3.12+)不會引發例外,除非它對其他" "程式碼是可見的。" -#: ../../library/sys.monitoring.rst:255 +#: ../../library/sys.monitoring.rst:263 msgid "" "To allow tools to monitor for real exceptions without slowing down " "generators and coroutines, the :monitoring-event:`STOP_ITERATION` event is " -"provided. :monitoring-event:`STOP_ITERATION` can be locally disabled, " -"unlike :monitoring-event:`RAISE`." +"provided. :monitoring-event:`STOP_ITERATION` can be locally disabled." msgstr "" "為了允許工具去監控真正的例外而不減慢產生器和協程的速度,提供了 :monitoring-" -"event:`STOP_ITERATION` 事件。與 :monitoring-event:`RAISE` 不同,:monitoring-" -"event:`STOP_ITERATION` 可以區域停用。" +"event:`STOP_ITERATION` 事件。:monitoring-event:`STOP_ITERATION` 可以區域停" +"用。" -#: ../../library/sys.monitoring.rst:260 +#: ../../library/sys.monitoring.rst:267 msgid "" "Note that the :monitoring-event:`STOP_ITERATION` event and the :monitoring-" "event:`RAISE` event for a :exc:`StopIteration` exception are equivalent, and " @@ -463,11 +474,11 @@ msgid "" "generate a :monitoring-event:`RAISE` event with a :exc:`StopIteration`." msgstr "" -#: ../../library/sys.monitoring.rst:268 +#: ../../library/sys.monitoring.rst:275 msgid "Turning events on and off" msgstr "開啟和關閉事件" -#: ../../library/sys.monitoring.rst:270 +#: ../../library/sys.monitoring.rst:277 msgid "" "In order to monitor an event, it must be turned on and a corresponding " "callback must be registered. Events can be turned on or off by setting the " @@ -478,21 +489,21 @@ msgstr "" "為特定程式碼物件來開啟或關閉事件。即使事件在全域和區域都被打開,事件也只會觸" "發一次。" -#: ../../library/sys.monitoring.rst:277 +#: ../../library/sys.monitoring.rst:284 msgid "Setting events globally" msgstr "全域設定事件" -#: ../../library/sys.monitoring.rst:279 +#: ../../library/sys.monitoring.rst:286 msgid "" "Events can be controlled globally by modifying the set of events being " "monitored." msgstr "可以透過修改正在監控的事件集合來全域地控制事件。" -#: ../../library/sys.monitoring.rst:283 +#: ../../library/sys.monitoring.rst:290 msgid "Returns the ``int`` representing all the active events." msgstr "回傳代表所有有效事件的 ``int``。" -#: ../../library/sys.monitoring.rst:287 +#: ../../library/sys.monitoring.rst:294 msgid "" "Activates all events which are set in *event_set*. Raises a :exc:" "`ValueError` if *tool_id* is not in use." @@ -500,15 +511,15 @@ msgstr "" "啟動 *event_set* 中設定的所有事件。如果 *tool_id* 並未正在被使用,則引發 :" "exc:`ValueError`。" -#: ../../library/sys.monitoring.rst:290 +#: ../../library/sys.monitoring.rst:297 msgid "No events are active by default." msgstr "預設沒有有效事件。" -#: ../../library/sys.monitoring.rst:293 +#: ../../library/sys.monitoring.rst:300 msgid "Per code object events" msgstr "各別程式碼物件事件" -#: ../../library/sys.monitoring.rst:295 +#: ../../library/sys.monitoring.rst:302 msgid "" "Events can also be controlled on a per code object basis. The functions " "defined below which accept a :class:`types.CodeType` should be prepared to " @@ -519,11 +530,11 @@ msgstr "" "CodeType` 的函式應該準備好接受來自 Python 中未定義函式的類似物件(請參閱 :" "ref:`c-api-monitoring`)。" -#: ../../library/sys.monitoring.rst:302 +#: ../../library/sys.monitoring.rst:309 msgid "Returns all the :ref:`local events ` for *code*" msgstr "回傳 *code* 的所有\\ :ref:`區域事件 `" -#: ../../library/sys.monitoring.rst:306 +#: ../../library/sys.monitoring.rst:313 msgid "" "Activates all the :ref:`local events ` for *code* " "which are set in *event_set*. Raises a :exc:`ValueError` if *tool_id* is not " @@ -532,17 +543,17 @@ msgstr "" "啟動 *event_set* 中針對 *code* 設定的所有\\ :ref:`區域事件 `。如果 *tool_id* 並未正在被使用,則引發 :exc:`ValueError`。" -#: ../../library/sys.monitoring.rst:312 +#: ../../library/sys.monitoring.rst:319 msgid "Disabling events" msgstr "停用事件" -#: ../../library/sys.monitoring.rst:316 +#: ../../library/sys.monitoring.rst:323 msgid "" "A special value that can be returned from a callback function to disable " "events for the current code location." msgstr "可以從回呼函式回傳的特殊值,以停用目前程式碼位置的事件。" -#: ../../library/sys.monitoring.rst:319 +#: ../../library/sys.monitoring.rst:326 msgid "" ":ref:`Local events ` can be disabled for a specific " "code location by returning :data:`sys.monitoring.DISABLE` from a callback " @@ -553,7 +564,18 @@ msgstr "" "ref:`區域事件 `。這不會改變被設定的事件,或相同事件的" "任何其他程式碼位置。" -#: ../../library/sys.monitoring.rst:324 +#: ../../library/sys.monitoring.rst:331 +msgid "" +":ref:`Other events ` can be disabled on a per code " +"object basis by returning :data:`sys.monitoring.DISABLE` from a callback " +"function. This disables the event for the entire code object (for the " +"current tool)." +msgstr "" +"可透過回呼函式回傳 :data:`sys.monitoring.DISABLE` 來針對個別程式碼物件停用" +"\\ :ref:`其他事件 `。這會為整個程式碼物件停用該事件" +"(針對目前的工具)。" + +#: ../../library/sys.monitoring.rst:336 msgid "" "Disabling events for specific locations is very important for high " "performance monitoring. For example, a program can be run under a debugger " @@ -563,32 +585,21 @@ msgstr "" "停用特定位置的事件對於高效能監控非常重要。舉例來說,如果除少數斷點外,偵錯器" "可以停用所有監控,那麼在偵錯器下執行程式就不會有任何開銷 (overhead)。" -#: ../../library/sys.monitoring.rst:329 -msgid "" -"If :data:`DISABLE` is returned by a callback for a :ref:`global event " -"`, :exc:`ValueError` will be raised by the " -"interpreter in a non-specific location (that is, no traceback will be " -"provided)." -msgstr "" -"如果回呼是為一個\\ :ref:`全域事件 `\\ 回傳 :data:" -"`DISABLE`,則直譯器會在非特定位置引發 :exc:`ValueError`\\ (也就是不會提供回" -"溯 (traceback))。" - -#: ../../library/sys.monitoring.rst:336 +#: ../../library/sys.monitoring.rst:342 msgid "" "Enable all the events that were disabled by :data:`sys.monitoring.DISABLE` " "for all tools." msgstr "為所有工具啟用由 :data:`sys.monitoring.DISABLE` 停用的所有事件。" -#: ../../library/sys.monitoring.rst:343 +#: ../../library/sys.monitoring.rst:349 msgid "Registering callback functions" msgstr "註冊回呼函式" -#: ../../library/sys.monitoring.rst:347 +#: ../../library/sys.monitoring.rst:353 msgid "Registers the callable *func* for the *event* with the given *tool_id*" msgstr "使用給定的 *tool_id* 來註冊對 *event* 的可呼叫物件 *func*" -#: ../../library/sys.monitoring.rst:349 +#: ../../library/sys.monitoring.rst:355 msgid "" "If another callback was registered for the given *tool_id* and *event*, it " "is unregistered and returned. Otherwise :func:`register_callback` returns " @@ -597,7 +608,7 @@ msgstr "" "如果給定的 *tool_id* 和 *event* 已經註冊了另一個回呼,則會取消註冊並回傳。否" "則 :func:`register_callback` 會回傳 ``None``。" -#: ../../library/sys.monitoring.rst:353 +#: ../../library/sys.monitoring.rst:359 msgid "" "Raises an :ref:`auditing event ` ``sys.monitoring." "register_callback`` with argument ``func``." @@ -605,7 +616,7 @@ msgstr "" "以 ``func`` 引數引發一個\\ :ref:`稽核事件 (auditing event) ` ``sys." "monitoring.register_callback``。" -#: ../../library/sys.monitoring.rst:355 +#: ../../library/sys.monitoring.rst:361 msgid "" "Functions can be unregistered by calling ``sys.monitoring." "register_callback(tool_id, event, None)``." @@ -613,11 +624,11 @@ msgstr "" "可以透過呼叫 ``sys.monitoring.register_callback(tool_id, event, None)`` 來取" "消註冊函式。" -#: ../../library/sys.monitoring.rst:358 +#: ../../library/sys.monitoring.rst:364 msgid "Callback functions can be registered and unregistered at any time." msgstr "回呼函式可以隨時被註冊和取消註冊。" -#: ../../library/sys.monitoring.rst:360 +#: ../../library/sys.monitoring.rst:366 msgid "" "Callbacks are called only once regardless if the event is turned on both " "globally and locally. As such, if an event could be turned on for both " @@ -625,17 +636,17 @@ msgid "" "to handle either trigger." msgstr "" -#: ../../library/sys.monitoring.rst:367 +#: ../../library/sys.monitoring.rst:373 msgid "Callback function arguments" msgstr "回呼函式引數" -#: ../../library/sys.monitoring.rst:371 +#: ../../library/sys.monitoring.rst:377 msgid "" "A special value that is passed to a callback function to indicate that there " "are no arguments to the call." msgstr "傳遞給回呼函式的特殊值,表示該呼叫沒有引數。" -#: ../../library/sys.monitoring.rst:374 +#: ../../library/sys.monitoring.rst:380 msgid "" "When an active event occurs, the registered callback function is called. " "Callback functions returning an object other than :data:`DISABLE` will have " @@ -645,24 +656,24 @@ msgstr "" "當有效事件發生時,已註冊的回呼函式會被呼叫。回傳非 :data:`DISABLE` 物件的回呼" "函式將不會有任何效果。不同的事件會為回呼函式提供不同的引數,如下所示:" -#: ../../library/sys.monitoring.rst:378 +#: ../../library/sys.monitoring.rst:384 msgid ":monitoring-event:`PY_START` and :monitoring-event:`PY_RESUME`::" msgstr ":monitoring-event:`PY_START` 和 :monitoring-event:`PY_RESUME`: ::" -#: ../../library/sys.monitoring.rst:380 ../../library/sys.monitoring.rst:417 +#: ../../library/sys.monitoring.rst:386 ../../library/sys.monitoring.rst:423 msgid "func(code: CodeType, instruction_offset: int) -> object" msgstr "func(code: CodeType, instruction_offset: int) -> object" -#: ../../library/sys.monitoring.rst:382 +#: ../../library/sys.monitoring.rst:388 msgid ":monitoring-event:`PY_RETURN` and :monitoring-event:`PY_YIELD`::" msgstr ":monitoring-event:`PY_RETURN` 和 :monitoring-event:`PY_YIELD`: ::" -#: ../../library/sys.monitoring.rst:384 +#: ../../library/sys.monitoring.rst:390 msgid "func(code: CodeType, instruction_offset: int, retval: object) -> object" msgstr "" "func(code: CodeType, instruction_offset: int, retval: object) -> object" -#: ../../library/sys.monitoring.rst:386 +#: ../../library/sys.monitoring.rst:392 msgid "" ":monitoring-event:`CALL`, :monitoring-event:`C_RAISE` and :monitoring-event:" "`C_RETURN` (*arg0* can be :data:`MISSING` specifically)::" @@ -670,7 +681,7 @@ msgstr "" ":monitoring-event:`CALL`、:monitoring-event:`C_RAISE` 和 :monitoring-event:" "`C_RETURN`\\ (*arg0* 可以特別是 :data:`MISSING`): ::" -#: ../../library/sys.monitoring.rst:389 +#: ../../library/sys.monitoring.rst:395 msgid "" "func(code: CodeType, instruction_offset: int, callable: object, arg0: " "object) -> object" @@ -678,7 +689,7 @@ msgstr "" "func(code: CodeType, instruction_offset: int, callable: object, arg0: " "object) -> object" -#: ../../library/sys.monitoring.rst:391 +#: ../../library/sys.monitoring.rst:397 msgid "" "*code* represents the code object where the call is being made, while " "*callable* is the object that is about to be called (and thus triggered the " @@ -686,14 +697,14 @@ msgid "" "MISSING`." msgstr "" -#: ../../library/sys.monitoring.rst:396 +#: ../../library/sys.monitoring.rst:402 msgid "" "For instance methods, *callable* will be the function object as found on the " "class with *arg0* set to the instance (i.e. the ``self`` argument to the " "method)." msgstr "" -#: ../../library/sys.monitoring.rst:400 +#: ../../library/sys.monitoring.rst:406 msgid "" ":monitoring-event:`RAISE`, :monitoring-event:`RERAISE`, :monitoring-event:" "`EXCEPTION_HANDLED`, :monitoring-event:`PY_UNWIND`, :monitoring-event:" @@ -703,7 +714,7 @@ msgstr "" "`EXCEPTION_HANDLED`、:monitoring-event:`PY_UNWIND`、:monitoring-event:" "`PY_THROW` 和 :monitoring-event:`STOP_ITERATION`: ::" -#: ../../library/sys.monitoring.rst:403 +#: ../../library/sys.monitoring.rst:409 msgid "" "func(code: CodeType, instruction_offset: int, exception: BaseException) -> " "object" @@ -711,15 +722,15 @@ msgstr "" "func(code: CodeType, instruction_offset: int, exception: BaseException) -> " "object" -#: ../../library/sys.monitoring.rst:405 +#: ../../library/sys.monitoring.rst:411 msgid ":monitoring-event:`LINE`::" msgstr ":monitoring-event:`LINE`: ::" -#: ../../library/sys.monitoring.rst:407 +#: ../../library/sys.monitoring.rst:413 msgid "func(code: CodeType, line_number: int) -> object" msgstr "func(code: CodeType, line_number: int) -> object" -#: ../../library/sys.monitoring.rst:409 +#: ../../library/sys.monitoring.rst:415 msgid "" ":monitoring-event:`BRANCH_LEFT`, :monitoring-event:`BRANCH_RIGHT` and :" "monitoring-event:`JUMP`::" @@ -727,7 +738,7 @@ msgstr "" ":monitoring-event:`BRANCH_LEFT`, :monitoring-event:`BRANCH_RIGHT` and :" "monitoring-event:`JUMP`::" -#: ../../library/sys.monitoring.rst:411 +#: ../../library/sys.monitoring.rst:417 msgid "" "func(code: CodeType, instruction_offset: int, destination_offset: int) -> " "object" @@ -735,10 +746,20 @@ msgstr "" "func(code: CodeType, instruction_offset: int, destination_offset: int) -> " "object" -#: ../../library/sys.monitoring.rst:413 +#: ../../library/sys.monitoring.rst:419 msgid "Note that the *destination_offset* is where the code will next execute." msgstr "請注意,*destination_offset* 是程式碼接下來要執行的地方。" -#: ../../library/sys.monitoring.rst:415 +#: ../../library/sys.monitoring.rst:421 msgid ":monitoring-event:`INSTRUCTION`::" msgstr ":monitoring-event:`INSTRUCTION`: ::" + +#~ msgid "" +#~ "If :data:`DISABLE` is returned by a callback for a :ref:`global event " +#~ "`, :exc:`ValueError` will be raised by the " +#~ "interpreter in a non-specific location (that is, no traceback will be " +#~ "provided)." +#~ msgstr "" +#~ "如果回呼是為一個\\ :ref:`全域事件 `\\ 回傳 :data:" +#~ "`DISABLE`,則直譯器會在非特定位置引發 :exc:`ValueError`\\ (也就是不會提供" +#~ "回溯 (traceback))。" diff --git a/library/sys.po b/library/sys.po index af3f13c9930..3224229a7ee 100644 --- a/library/sys.po +++ b/library/sys.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-17 00:09+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-04-26 02:54+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -30,34 +30,78 @@ msgid "" "read-only." msgstr "" -#: ../../library/sys.rst:16 +#: ../../library/sys.rst:18 +msgid "" +"An object containing information about the ABI of the currently running " +"Python interpreter. It should include information that affect the CPython " +"ABI in ways that require a specific build of the interpreter chosen from " +"variants that can co-exist on a single machine. For example, it does not " +"encode the base OS (Linux or Windows), but does include pointer size since " +"some systems support both 32- and 64-bit builds. The available entries are " +"the same on all platforms; e.g. *pointer_size* is available even on 64-bit-" +"only architectures." +msgstr "" + +#: ../../library/sys.rst:28 +msgid "The following attributes are available:" +msgstr "" + +#: ../../library/sys.rst:32 +msgid "" +"The width of pointers in bits, as an integer, equivalent to ``8 * " +"sizeof(void *)``. Usually, this is ``32`` or ``64``." +msgstr "" + +#: ../../library/sys.rst:38 +msgid "" +"A Boolean indicating whether the interpreter was built with :term:`free " +"threading` support. This reflects either the presence of the :option:`--" +"disable-gil` :file:`configure` option (on Unix) or setting the " +"``DisableGil`` property (on Windows)." +msgstr "" + +#: ../../library/sys.rst:46 +msgid "" +"A Boolean indicating whether the interpreter was built in :ref:`debug mode " +"`. This reflects either the presence of the :option:`--with-" +"pydebug` :file:`configure` option (on Unix) or the ``Debug`` configuration " +"(on Windows)." +msgstr "" + +#: ../../library/sys.rst:54 +msgid "" +"A string indicating the native byte order, either ``'big'`` or ``'little'``. " +"This is the same as the :data:`byteorder` attribute." +msgstr "" + +#: ../../library/sys.rst:61 msgid "" "On POSIX systems where Python was built with the standard ``configure`` " "script, this contains the ABI flags as specified by :pep:`3149`." msgstr "" -#: ../../library/sys.rst:21 +#: ../../library/sys.rst:66 msgid "" "Default flags became an empty string (``m`` flag for pymalloc has been " "removed)." msgstr "" -#: ../../library/sys.rst:25 ../../library/sys.rst:298 ../../library/sys.rst:368 -#: ../../library/sys.rst:789 ../../library/sys.rst:807 -#: ../../library/sys.rst:1056 ../../library/sys.rst:1666 -#: ../../library/sys.rst:1909 ../../library/sys.rst:1924 -#: ../../library/sys.rst:1932 ../../library/sys.rst:1973 -#: ../../library/sys.rst:1990 ../../library/sys.rst:2237 +#: ../../library/sys.rst:70 ../../library/sys.rst:343 ../../library/sys.rst:413 +#: ../../library/sys.rst:835 ../../library/sys.rst:853 +#: ../../library/sys.rst:1129 ../../library/sys.rst:1767 +#: ../../library/sys.rst:2065 ../../library/sys.rst:2080 +#: ../../library/sys.rst:2088 ../../library/sys.rst:2129 +#: ../../library/sys.rst:2146 ../../library/sys.rst:2399 msgid "Availability" msgstr "可用性" -#: ../../library/sys.rst:30 +#: ../../library/sys.rst:75 msgid "" "Append the callable *hook* to the list of active auditing hooks for the " "current (sub)interpreter." msgstr "" -#: ../../library/sys.rst:33 +#: ../../library/sys.rst:78 msgid "" "When an auditing event is raised through the :func:`sys.audit` function, " "each hook will be called in the order it was added with the event name and " @@ -67,7 +111,7 @@ msgid "" "terminate the process entirely." msgstr "" -#: ../../library/sys.rst:40 +#: ../../library/sys.rst:85 msgid "" "Note that audit hooks are primarily for collecting information about " "internal or otherwise unobservable actions, whether by Python or libraries " @@ -79,7 +123,7 @@ msgid "" "mod:`ctypes`) should be completely removed or closely monitored." msgstr "" -#: ../../library/sys.rst:49 ../../library/sys.rst:51 +#: ../../library/sys.rst:94 ../../library/sys.rst:96 msgid "" "Calling :func:`sys.addaudithook` will itself raise an auditing event named " "``sys.addaudithook`` with no arguments. If any existing hooks raise an " @@ -92,7 +136,7 @@ msgstr "" "衍生的例外,則不會添加新的 hook 並抑制異常。因此,除非呼叫者控制所有已存在的 " "hook,他們不能假設他們的 hook 已被添加。" -#: ../../library/sys.rst:58 +#: ../../library/sys.rst:103 msgid "" "See the :ref:`audit events table ` for all events raised by " "CPython, and :pep:`578` for the original design discussion." @@ -100,20 +144,20 @@ msgstr "" "所有會被 CPython 所引發的事件請參考\\ :ref:`稽核事件總表 `、設" "計相關討論請見 :pep:`578`。" -#: ../../library/sys.rst:65 +#: ../../library/sys.rst:110 msgid "" "Exceptions derived from :class:`Exception` but not :class:`RuntimeError` are " "no longer suppressed." msgstr "" -#: ../../library/sys.rst:70 +#: ../../library/sys.rst:115 msgid "" "When tracing is enabled (see :func:`settrace`), Python hooks are only traced " "if the callable has a ``__cantrace__`` member that is set to a true value. " "Otherwise, trace functions will skip the hook." msgstr "" -#: ../../library/sys.rst:77 +#: ../../library/sys.rst:122 msgid "" "The list of command line arguments passed to a Python script. ``argv[0]`` is " "the script name (it is operating system dependent whether this is a full " @@ -123,17 +167,17 @@ msgid "" "is the empty string." msgstr "" -#: ../../library/sys.rst:83 +#: ../../library/sys.rst:128 msgid "" "To loop over the standard input, or the list of files given on the command " "line, see the :mod:`fileinput` module." msgstr "" -#: ../../library/sys.rst:86 +#: ../../library/sys.rst:131 msgid "See also :data:`sys.orig_argv`." msgstr "另請參閱 :data:`sys.orig_argv`。" -#: ../../library/sys.rst:89 +#: ../../library/sys.rst:134 msgid "" "On Unix, command line arguments are passed by bytes from OS. Python decodes " "them with filesystem encoding and \"surrogateescape\" error handler. When " @@ -141,7 +185,7 @@ msgid "" "sys.argv]``." msgstr "" -#: ../../library/sys.rst:101 +#: ../../library/sys.rst:146 msgid "" "Raise an auditing event and trigger any active auditing hooks. *event* is a " "string identifying the event, and *args* may contain optional arguments with " @@ -150,7 +194,7 @@ msgid "" "modified between releases." msgstr "" -#: ../../library/sys.rst:107 +#: ../../library/sys.rst:152 msgid "" "For example, one auditing event is named ``os.chdir``. This event has one " "argument called *path* that will contain the requested new working directory." @@ -158,7 +202,7 @@ msgstr "" "舉例來說,一個名為 ``os.chdir`` 的稽核事件擁有一個引數 *path*,其內容為所要求" "的新工作目錄。" -#: ../../library/sys.rst:111 +#: ../../library/sys.rst:156 msgid "" ":func:`sys.audit` will call the existing auditing hooks, passing the event " "name and arguments, and will re-raise the first exception from any hook. In " @@ -168,32 +212,32 @@ msgid "" "merely log the event or abort the operation by raising an exception." msgstr "" -#: ../../library/sys.rst:119 +#: ../../library/sys.rst:164 msgid "" "Hooks are added using the :func:`sys.addaudithook` or :c:func:" "`PySys_AddAuditHook` functions." msgstr "" -#: ../../library/sys.rst:122 +#: ../../library/sys.rst:167 msgid "" "The native equivalent of this function is :c:func:`PySys_Audit`. Using the " "native function is preferred when possible." msgstr "" -#: ../../library/sys.rst:125 +#: ../../library/sys.rst:170 msgid "" "See the :ref:`audit events table ` for all events raised by " "CPython." msgstr "" "所有會被 CPython 所引發的事件請參考\\ :ref:`稽核事件總表 `。" -#: ../../library/sys.rst:133 +#: ../../library/sys.rst:178 msgid "" "Equivalent to :data:`exec_prefix`, but referring to the base Python " "installation." msgstr "" -#: ../../library/sys.rst:135 +#: ../../library/sys.rst:180 msgid "" "When running under :ref:`sys-path-init-virtual-environments`, :data:" "`exec_prefix` gets overwritten to the virtual environment prefix. :data:" @@ -202,12 +246,12 @@ msgid "" "for more information." msgstr "" -#: ../../library/sys.rst:146 +#: ../../library/sys.rst:191 msgid "" "Equivalent to :data:`prefix`, but referring to the base Python installation." msgstr "" -#: ../../library/sys.rst:148 +#: ../../library/sys.rst:193 msgid "" "When running under :ref:`virtual environment `, :data:`prefix` " "gets overwritten to the virtual environment prefix. :data:`base_prefix`, " @@ -216,66 +260,66 @@ msgid "" "information." msgstr "" -#: ../../library/sys.rst:159 +#: ../../library/sys.rst:204 msgid "" "An indicator of the native byte order. This will have the value ``'big'`` " "on big-endian (most-significant byte first) platforms, and ``'little'`` on " "little-endian (least-significant byte first) platforms." msgstr "" -#: ../../library/sys.rst:166 +#: ../../library/sys.rst:211 msgid "" "A tuple of strings containing the names of all modules that are compiled " "into this Python interpreter. (This information is not available in any " "other way --- ``modules.keys()`` only lists the imported modules.)" msgstr "" -#: ../../library/sys.rst:170 +#: ../../library/sys.rst:215 msgid "See also the :data:`sys.stdlib_module_names` list." msgstr "另請參閱 :data:`sys.stdlib_module_names` 清單。" -#: ../../library/sys.rst:175 +#: ../../library/sys.rst:220 msgid "" "Call ``func(*args)``, while tracing is enabled. The tracing state is saved, " "and restored afterwards. This is intended to be called from a debugger from " "a checkpoint, to recursively debug or profile some other code." msgstr "" -#: ../../library/sys.rst:179 +#: ../../library/sys.rst:224 msgid "" "Tracing is suspended while calling a tracing function set by :func:" "`settrace` or :func:`setprofile` to avoid infinite recursion. :func:`!" "call_tracing` enables explicit recursion of the tracing function." msgstr "" -#: ../../library/sys.rst:186 +#: ../../library/sys.rst:231 msgid "A string containing the copyright pertaining to the Python interpreter." msgstr "" -#: ../../library/sys.rst:191 +#: ../../library/sys.rst:236 msgid "" "Clear the internal type cache. The type cache is used to speed up attribute " "and method lookups. Use the function *only* to drop unnecessary references " "during reference leak debugging." msgstr "" -#: ../../library/sys.rst:195 ../../library/sys.rst:222 -#: ../../library/sys.rst:235 +#: ../../library/sys.rst:240 ../../library/sys.rst:267 +#: ../../library/sys.rst:280 msgid "" "This function should be used for internal and specialized purposes only." msgstr "" -#: ../../library/sys.rst:197 +#: ../../library/sys.rst:242 msgid "Use the more general :func:`_clear_internal_caches` function instead." msgstr "" -#: ../../library/sys.rst:203 +#: ../../library/sys.rst:248 msgid "" "Clear all internal performance-related caches. Use this function *only* to " "release unnecessary references and memory blocks when hunting for leaks." msgstr "" -#: ../../library/sys.rst:211 +#: ../../library/sys.rst:256 msgid "" "Return a dictionary mapping each thread's identifier to the topmost stack " "frame currently active in that thread at the time the function is called. " @@ -283,7 +327,7 @@ msgid "" "given such a frame." msgstr "" -#: ../../library/sys.rst:216 +#: ../../library/sys.rst:261 msgid "" "This is most useful for debugging deadlock: this function does not require " "the deadlocked threads' cooperation, and such threads' call stacks are " @@ -292,14 +336,14 @@ msgid "" "by the time calling code examines the frame." msgstr "" -#: ../../library/sys.rst:224 +#: ../../library/sys.rst:269 msgid "" "Raises an :ref:`auditing event ` ``sys._current_frames`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``sys._current_frames``。" -#: ../../library/sys.rst:228 +#: ../../library/sys.rst:273 msgid "" "Return a dictionary mapping each thread's identifier to the topmost " "exception currently active in that thread at the time the function is " @@ -307,11 +351,11 @@ msgid "" "included in the result dictionary." msgstr "" -#: ../../library/sys.rst:233 +#: ../../library/sys.rst:278 msgid "This is most useful for statistical profiling." msgstr "" -#: ../../library/sys.rst:237 +#: ../../library/sys.rst:282 msgid "" "Raises an :ref:`auditing event ` ``sys._current_exceptions`` with " "no arguments." @@ -319,20 +363,20 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``sys." "_current_exceptions``。" -#: ../../library/sys.rst:239 +#: ../../library/sys.rst:284 msgid "" "Each value in the dictionary is now a single exception instance, rather than " "a 3-tuple as returned from ``sys.exc_info()``." msgstr "" -#: ../../library/sys.rst:245 +#: ../../library/sys.rst:290 msgid "" "This hook function is called by built-in :func:`breakpoint`. By default, it " "drops you into the :mod:`pdb` debugger, but it can be set to any other " "function so that you can choose which debugger gets used." msgstr "" -#: ../../library/sys.rst:249 +#: ../../library/sys.rst:294 msgid "" "The signature of this function is dependent on what it calls. For example, " "the default binding (e.g. ``pdb.set_trace()``) expects no arguments, but you " @@ -342,7 +386,7 @@ msgid "" "returns is returned from ``breakpoint()``." msgstr "" -#: ../../library/sys.rst:256 +#: ../../library/sys.rst:301 msgid "" "The default implementation first consults the environment variable :envvar:" "`PYTHONBREAKPOINT`. If that is set to ``\"0\"`` then this function returns " @@ -356,43 +400,43 @@ msgid "" "breakpointhook()`` returns to the built-in :func:`breakpoint` function." msgstr "" -#: ../../library/sys.rst:268 +#: ../../library/sys.rst:313 msgid "" "Note that if anything goes wrong while importing the callable named by :" "envvar:`PYTHONBREAKPOINT`, a :exc:`RuntimeWarning` is reported and the " "breakpoint is ignored." msgstr "" -#: ../../library/sys.rst:272 +#: ../../library/sys.rst:317 msgid "" "Also note that if ``sys.breakpointhook()`` is overridden programmatically, :" "envvar:`PYTHONBREAKPOINT` is *not* consulted." msgstr "" -#: ../../library/sys.rst:279 +#: ../../library/sys.rst:324 msgid "" "Print low-level information to stderr about the state of CPython's memory " "allocator." msgstr "" -#: ../../library/sys.rst:282 +#: ../../library/sys.rst:327 msgid "" "If Python is :ref:`built in debug mode ` (:option:`configure --" "with-pydebug option <--with-pydebug>`), it also performs some expensive " "internal consistency checks." msgstr "" -#: ../../library/sys.rst:290 +#: ../../library/sys.rst:335 msgid "" "This function is specific to CPython. The exact output format is not " "defined here, and may change." msgstr "" -#: ../../library/sys.rst:296 +#: ../../library/sys.rst:341 msgid "Integer specifying the handle of the Python DLL." msgstr "" -#: ../../library/sys.rst:303 +#: ../../library/sys.rst:348 msgid "" "If *value* is not ``None``, this function prints ``repr(value)`` to ``sys." "stdout``, and saves *value* in ``builtins._``. If ``repr(value)`` is not " @@ -401,7 +445,7 @@ msgid "" "encoding`` with ``'backslashreplace'`` error handler." msgstr "" -#: ../../library/sys.rst:309 +#: ../../library/sys.rst:354 msgid "" "``sys.displayhook`` is called on the result of evaluating an :term:" "`expression` entered in an interactive Python session. The display of these " @@ -409,11 +453,11 @@ msgid "" "displayhook``." msgstr "" -#: ../../library/sys.rst:313 +#: ../../library/sys.rst:358 msgid "Pseudo-code::" msgstr "" -#: ../../library/sys.rst:315 +#: ../../library/sys.rst:360 msgid "" "def displayhook(value):\n" " if value is None:\n" @@ -434,11 +478,11 @@ msgid "" " builtins._ = value" msgstr "" -#: ../../library/sys.rst:333 +#: ../../library/sys.rst:378 msgid "Use ``'backslashreplace'`` error handler on :exc:`UnicodeEncodeError`." msgstr "" -#: ../../library/sys.rst:339 +#: ../../library/sys.rst:384 msgid "" "If this is true, Python won't try to write ``.pyc`` files on the import of " "source modules. This value is initially set to ``True`` or ``False`` " @@ -447,20 +491,20 @@ msgid "" "to control bytecode file generation." msgstr "" -#: ../../library/sys.rst:348 +#: ../../library/sys.rst:393 msgid "" "A :term:`named tuple` holding information about the environment on the " "*wasm32-emscripten* platform. The named tuple is provisional and may change " "in the future." msgstr "" -#: ../../library/sys.rst:354 +#: ../../library/sys.rst:399 msgid "" "Emscripten version as tuple of ints (major, minor, micro), e.g. ``(3, 1, " "8)``." msgstr "" -#: ../../library/sys.rst:358 +#: ../../library/sys.rst:403 msgid "" "Runtime string, e.g. browser user agent, ``'Node.js v14.18.2'``, or " "``'UNKNOWN'``." @@ -468,15 +512,15 @@ msgstr "" "運行環境字串,例如瀏覽器使用者代理 (browser user agent) ``'Node.js " "v14.18.2'`` 或 ``'UNKNOWN'``。" -#: ../../library/sys.rst:362 +#: ../../library/sys.rst:407 msgid "``True`` if Python is compiled with Emscripten pthreads support." msgstr "" -#: ../../library/sys.rst:366 +#: ../../library/sys.rst:411 msgid "``True`` if Python is compiled with shared memory support." msgstr "" -#: ../../library/sys.rst:375 +#: ../../library/sys.rst:420 msgid "" "If this is set (not ``None``), Python will write bytecode-cache ``.pyc`` " "files to (and read them from) a parallel directory tree rooted at this " @@ -487,12 +531,12 @@ msgid "" "with the same pycache prefix (if any) that you will use at runtime." msgstr "" -#: ../../library/sys.rst:383 +#: ../../library/sys.rst:428 msgid "" "A relative path is interpreted relative to the current working directory." msgstr "" -#: ../../library/sys.rst:385 +#: ../../library/sys.rst:430 msgid "" "This value is initially set based on the value of the :option:`-X` " "``pycache_prefix=PATH`` command-line option or the :envvar:" @@ -500,12 +544,12 @@ msgid "" "If neither are set, it is ``None``." msgstr "" -#: ../../library/sys.rst:395 +#: ../../library/sys.rst:440 msgid "" "This function prints out a given traceback and exception to ``sys.stderr``." msgstr "" -#: ../../library/sys.rst:397 +#: ../../library/sys.rst:442 msgid "" "When an exception other than :exc:`SystemExit` is raised and uncaught, the " "interpreter calls ``sys.excepthook`` with three arguments, the exception " @@ -516,7 +560,7 @@ msgid "" "argument function to ``sys.excepthook``." msgstr "" -#: ../../library/sys.rst:404 ../../library/sys.rst:406 +#: ../../library/sys.rst:449 ../../library/sys.rst:451 msgid "" "Raise an auditing event ``sys.excepthook`` with arguments ``hook``, " "``type``, ``value``, ``traceback`` when an uncaught exception occurs. If no " @@ -526,14 +570,14 @@ msgid "" "excepthook`` will be called." msgstr "" -#: ../../library/sys.rst:415 +#: ../../library/sys.rst:460 msgid "" "The :func:`sys.unraisablehook` function handles unraisable exceptions and " "the :func:`threading.excepthook` function handles exception raised by :func:" "`threading.Thread.run`." msgstr "" -#: ../../library/sys.rst:425 +#: ../../library/sys.rst:470 msgid "" "These objects contain the original values of ``breakpointhook``, " "``displayhook``, ``excepthook``, and ``unraisablehook`` at the start of the " @@ -542,15 +586,15 @@ msgid "" "get replaced with broken or alternative objects." msgstr "" -#: ../../library/sys.rst:431 +#: ../../library/sys.rst:476 msgid "__breakpointhook__" msgstr "__breakpointhook__" -#: ../../library/sys.rst:434 +#: ../../library/sys.rst:479 msgid "__unraisablehook__" msgstr "__unraisablehook__" -#: ../../library/sys.rst:440 +#: ../../library/sys.rst:485 msgid "" "This function, when called while an exception handler is executing (such as " "an ``except`` or ``except*`` clause), returns the exception instance that " @@ -558,11 +602,11 @@ msgid "" "another, only the exception handled by the innermost handler is accessible." msgstr "" -#: ../../library/sys.rst:445 +#: ../../library/sys.rst:490 msgid "If no exception handler is executing, this function returns ``None``." msgstr "" -#: ../../library/sys.rst:452 +#: ../../library/sys.rst:497 msgid "" "This function returns the old-style representation of the handled exception. " "If an exception ``e`` is currently handled (so :func:`exception` would " @@ -573,13 +617,13 @@ msgid "" "stack at the point where the exception last occurred." msgstr "" -#: ../../library/sys.rst:463 +#: ../../library/sys.rst:508 msgid "" "If no exception is being handled anywhere on the stack, this function return " "a tuple containing three ``None`` values." msgstr "" -#: ../../library/sys.rst:466 +#: ../../library/sys.rst:511 msgid "" "The ``type`` and ``traceback`` fields are now derived from the ``value`` " "(the exception instance), so when an exception is modified while it is being " @@ -587,7 +631,7 @@ msgid "" "func:`exc_info`." msgstr "" -#: ../../library/sys.rst:474 +#: ../../library/sys.rst:519 msgid "" "A string giving the site-specific directory prefix where the platform-" "dependent Python files are installed; by default, this is also ``'/usr/" @@ -599,7 +643,7 @@ msgid "" "is the version number of Python, for example ``3.2``." msgstr "" -#: ../../library/sys.rst:485 +#: ../../library/sys.rst:530 msgid "" "If a :ref:`virtual environment ` is in effect, this :data:" "`exec_prefix` will point to the virtual environment. The value for the " @@ -607,7 +651,7 @@ msgid "" "Refer to :ref:`sys-path-init-virtual-environments` for more information." msgstr "" -#: ../../library/sys.rst:492 ../../library/sys.rst:1631 +#: ../../library/sys.rst:537 ../../library/sys.rst:1732 msgid "" "When running under a :ref:`virtual environment `, :data:`prefix` " "and :data:`exec_prefix` are now set to the virtual environment prefix by " @@ -616,7 +660,7 @@ msgid "" "virtual environment, even when :mod:`site` is disabled (:option:`-S`)." msgstr "" -#: ../../library/sys.rst:501 +#: ../../library/sys.rst:546 msgid "" "A string giving the absolute path of the executable binary for the Python " "interpreter, on systems where this makes sense. If Python is unable to " @@ -624,13 +668,13 @@ msgid "" "empty string or ``None``." msgstr "" -#: ../../library/sys.rst:509 +#: ../../library/sys.rst:554 msgid "" "Raise a :exc:`SystemExit` exception, signaling an intention to exit the " "interpreter." msgstr "" -#: ../../library/sys.rst:511 +#: ../../library/sys.rst:556 msgid "" "The optional argument *arg* can be an integer giving the exit status " "(defaulting to zero), or another type of object. If it is an integer, zero " @@ -646,139 +690,139 @@ msgid "" "way to exit a program when an error occurs." msgstr "" -#: ../../library/sys.rst:524 +#: ../../library/sys.rst:569 msgid "" "Since :func:`exit` ultimately \"only\" raises an exception, it will only " "exit the process when called from the main thread, and the exception is not " -"intercepted. Cleanup actions specified by finally clauses of :keyword:`try` " -"statements are honored, and it is possible to intercept the exit attempt at " -"an outer level." +"intercepted. Cleanup actions specified by :keyword:`finally` clauses of :" +"keyword:`try` statements are honored, and it is possible to intercept the " +"exit attempt at an outer level." msgstr "" -#: ../../library/sys.rst:529 +#: ../../library/sys.rst:575 msgid "" "If an error occurs in the cleanup after the Python interpreter has caught :" "exc:`SystemExit` (such as an error flushing buffered data in the standard " "streams), the exit status is changed to 120." msgstr "" -#: ../../library/sys.rst:537 +#: ../../library/sys.rst:583 msgid "" "The :term:`named tuple` *flags* exposes the status of command line flags. " "Flags should only be accessed only by name and not by index. The attributes " "are read only." msgstr "" -#: ../../library/sys.rst:544 +#: ../../library/sys.rst:590 msgid ":option:`-d`" msgstr ":option:`-d`" -#: ../../library/sys.rst:547 ../../library/sys.rst:550 +#: ../../library/sys.rst:593 ../../library/sys.rst:596 msgid ":option:`-i`" msgstr ":option:`-i`" -#: ../../library/sys.rst:553 +#: ../../library/sys.rst:599 msgid ":option:`-I`" msgstr ":option:`-I`" -#: ../../library/sys.rst:556 +#: ../../library/sys.rst:602 msgid ":option:`-O` or :option:`-OO`" msgstr ":option:`-O` 或 :option:`-OO`" -#: ../../library/sys.rst:559 +#: ../../library/sys.rst:605 msgid ":option:`-B`" msgstr ":option:`-B`" -#: ../../library/sys.rst:562 +#: ../../library/sys.rst:608 msgid ":option:`-s`" msgstr ":option:`-s`" -#: ../../library/sys.rst:565 +#: ../../library/sys.rst:611 msgid ":option:`-S`" msgstr ":option:`-S`" -#: ../../library/sys.rst:568 +#: ../../library/sys.rst:614 msgid ":option:`-E`" msgstr ":option:`-E`" -#: ../../library/sys.rst:571 +#: ../../library/sys.rst:617 msgid ":option:`-v`" msgstr ":option:`-v`" -#: ../../library/sys.rst:574 +#: ../../library/sys.rst:620 msgid ":option:`-b`" msgstr ":option:`-b`" -#: ../../library/sys.rst:577 +#: ../../library/sys.rst:623 msgid ":option:`-q`" msgstr ":option:`-q`" -#: ../../library/sys.rst:580 +#: ../../library/sys.rst:626 msgid ":option:`-R`" msgstr ":option:`-R`" -#: ../../library/sys.rst:583 +#: ../../library/sys.rst:629 msgid ":option:`-X dev <-X>` (:ref:`Python Development Mode `)" msgstr ":option:`-X dev <-X>` (:ref:`Python 開發模式 `)" -#: ../../library/sys.rst:586 +#: ../../library/sys.rst:632 msgid ":option:`-X utf8 <-X>`" msgstr ":option:`-X utf8 <-X>`" -#: ../../library/sys.rst:589 +#: ../../library/sys.rst:635 msgid ":option:`-P`" msgstr ":option:`-P`" -#: ../../library/sys.rst:592 +#: ../../library/sys.rst:638 msgid "" ":option:`-X int_max_str_digits <-X>` (:ref:`integer string conversion length " "limitation `)" msgstr "" -#: ../../library/sys.rst:596 +#: ../../library/sys.rst:642 msgid ":option:`-X warn_default_encoding <-X>`" msgstr ":option:`-X warn_default_encoding <-X>`" -#: ../../library/sys.rst:599 +#: ../../library/sys.rst:645 msgid ":option:`-X gil <-X>` and :envvar:`PYTHON_GIL`" msgstr ":option:`-X gil <-X>` 和 :envvar:`PYTHON_GIL`" -#: ../../library/sys.rst:602 +#: ../../library/sys.rst:648 msgid "" ":option:`-X thread_inherit_context <-X>` and :envvar:" "`PYTHON_THREAD_INHERIT_CONTEXT`" msgstr "" -#: ../../library/sys.rst:606 +#: ../../library/sys.rst:652 msgid "" ":option:`-X context_aware_warnings <-X>` and :envvar:" "`PYTHON_CONTEXT_AWARE_WARNINGS`" msgstr "" -#: ../../library/sys.rst:610 +#: ../../library/sys.rst:656 msgid "Added ``quiet`` attribute for the new :option:`-q` flag." msgstr "新增 ``quiet`` 屬性,用於新的 :option:`-q` 旗標。" -#: ../../library/sys.rst:613 +#: ../../library/sys.rst:659 msgid "The ``hash_randomization`` attribute." msgstr "``hash_randomization`` 屬性。" -#: ../../library/sys.rst:616 +#: ../../library/sys.rst:662 msgid "Removed obsolete ``division_warning`` attribute." msgstr "移除過時的 ``division_warning`` 屬性。" -#: ../../library/sys.rst:619 +#: ../../library/sys.rst:665 msgid "Added ``isolated`` attribute for :option:`-I` ``isolated`` flag." msgstr "新增 ``isolated`` 屬性,用於 :option:`-I` ``isolated`` 旗標。" -#: ../../library/sys.rst:622 +#: ../../library/sys.rst:668 msgid "" "Added the ``dev_mode`` attribute for the new :ref:`Python Development Mode " "` and the ``utf8_mode`` attribute for the new :option:`-X` " "``utf8`` flag." msgstr "" -#: ../../library/sys.rst:627 +#: ../../library/sys.rst:673 msgid "" "Added ``warn_default_encoding`` attribute for :option:`-X` " "``warn_default_encoding`` flag." @@ -786,27 +830,27 @@ msgstr "" "新增 ``warn_default_encoding`` 屬性,用於 :option:`-X` " "``warn_default_encoding`` 旗標。" -#: ../../library/sys.rst:630 +#: ../../library/sys.rst:676 msgid "Added the ``safe_path`` attribute for :option:`-P` option." msgstr "新增 ``safe_path`` 屬性,用於 :option:`-P` 選項。" -#: ../../library/sys.rst:633 +#: ../../library/sys.rst:679 msgid "Added the ``int_max_str_digits`` attribute." msgstr "新增 ``int_max_str_digits`` 屬性。" -#: ../../library/sys.rst:636 +#: ../../library/sys.rst:682 msgid "Added the ``gil`` attribute." msgstr "新增 ``gil`` 屬性。" -#: ../../library/sys.rst:639 +#: ../../library/sys.rst:685 msgid "Added the ``thread_inherit_context`` attribute." msgstr "新增 ``thread_inherit_context`` 屬性。" -#: ../../library/sys.rst:642 +#: ../../library/sys.rst:688 msgid "Added the ``context_aware_warnings`` attribute." msgstr "新增 ``context_aware_warnings`` 屬性。" -#: ../../library/sys.rst:648 +#: ../../library/sys.rst:694 msgid "" "A :term:`named tuple` holding information about the float type. It contains " "low level information about the precision and internal representation. The " @@ -816,161 +860,161 @@ msgid "" "floating types', for details." msgstr "" -#: ../../library/sys.rst:655 +#: ../../library/sys.rst:701 msgid "Attributes of the :data:`!float_info` :term:`named tuple`" msgstr "" -#: ../../library/sys.rst:658 +#: ../../library/sys.rst:704 msgid "attribute" msgstr "屬性" -#: ../../library/sys.rst:659 +#: ../../library/sys.rst:705 msgid "float.h macro" msgstr "float.h macro" -#: ../../library/sys.rst:660 +#: ../../library/sys.rst:706 msgid "explanation" msgstr "解釋" -#: ../../library/sys.rst:663 +#: ../../library/sys.rst:709 msgid ":c:macro:`!DBL_EPSILON`" msgstr ":c:macro:`!DBL_EPSILON`" -#: ../../library/sys.rst:664 +#: ../../library/sys.rst:710 msgid "" "difference between 1.0 and the least value greater than 1.0 that is " "representable as a float." msgstr "" -#: ../../library/sys.rst:667 +#: ../../library/sys.rst:713 msgid "See also :func:`math.ulp`." msgstr "另請參閱 :func:`math.ulp`。" -#: ../../library/sys.rst:670 +#: ../../library/sys.rst:716 msgid ":c:macro:`!DBL_DIG`" msgstr ":c:macro:`!DBL_DIG`" -#: ../../library/sys.rst:671 +#: ../../library/sys.rst:717 msgid "" "The maximum number of decimal digits that can be faithfully represented in a " "float; see below." msgstr "" -#: ../../library/sys.rst:675 +#: ../../library/sys.rst:721 msgid ":c:macro:`!DBL_MANT_DIG`" msgstr ":c:macro:`!DBL_MANT_DIG`" -#: ../../library/sys.rst:676 +#: ../../library/sys.rst:722 msgid "" "Float precision: the number of base-``radix`` digits in the significand of a " "float." msgstr "" -#: ../../library/sys.rst:680 +#: ../../library/sys.rst:726 msgid ":c:macro:`!DBL_MAX`" msgstr ":c:macro:`!DBL_MAX`" -#: ../../library/sys.rst:681 +#: ../../library/sys.rst:727 msgid "The maximum representable positive finite float." msgstr "" -#: ../../library/sys.rst:684 +#: ../../library/sys.rst:730 msgid ":c:macro:`!DBL_MAX_EXP`" msgstr ":c:macro:`!DBL_MAX_EXP`" -#: ../../library/sys.rst:685 +#: ../../library/sys.rst:731 msgid "" "The maximum integer *e* such that ``radix**(e-1)`` is a representable finite " "float." msgstr "" -#: ../../library/sys.rst:689 +#: ../../library/sys.rst:735 msgid ":c:macro:`!DBL_MAX_10_EXP`" msgstr ":c:macro:`!DBL_MAX_10_EXP`" -#: ../../library/sys.rst:690 +#: ../../library/sys.rst:736 msgid "" "The maximum integer *e* such that ``10**e`` is in the range of representable " "finite floats." msgstr "" -#: ../../library/sys.rst:694 +#: ../../library/sys.rst:740 msgid ":c:macro:`!DBL_MIN`" msgstr ":c:macro:`!DBL_MIN`" -#: ../../library/sys.rst:695 +#: ../../library/sys.rst:741 msgid "The minimum representable positive *normalized* float." msgstr "" -#: ../../library/sys.rst:697 +#: ../../library/sys.rst:743 msgid "" "Use :func:`math.ulp(0.0) ` to get the smallest positive " "*denormalized* representable float." msgstr "" -#: ../../library/sys.rst:701 +#: ../../library/sys.rst:747 msgid ":c:macro:`!DBL_MIN_EXP`" msgstr ":c:macro:`!DBL_MIN_EXP`" -#: ../../library/sys.rst:702 +#: ../../library/sys.rst:748 msgid "" "The minimum integer *e* such that ``radix**(e-1)`` is a normalized float." msgstr "" -#: ../../library/sys.rst:706 +#: ../../library/sys.rst:752 msgid ":c:macro:`!DBL_MIN_10_EXP`" msgstr ":c:macro:`!DBL_MIN_10_EXP`" -#: ../../library/sys.rst:707 +#: ../../library/sys.rst:753 msgid "The minimum integer *e* such that ``10**e`` is a normalized float." msgstr "" -#: ../../library/sys.rst:710 +#: ../../library/sys.rst:756 msgid ":c:macro:`!FLT_RADIX`" msgstr ":c:macro:`!FLT_RADIX`" -#: ../../library/sys.rst:711 +#: ../../library/sys.rst:757 msgid "The radix of exponent representation." msgstr "" -#: ../../library/sys.rst:714 +#: ../../library/sys.rst:760 msgid ":c:macro:`!FLT_ROUNDS`" msgstr ":c:macro:`!FLT_ROUNDS`" -#: ../../library/sys.rst:715 +#: ../../library/sys.rst:761 msgid "" "An integer representing the rounding mode for floating-point arithmetic. " "This reflects the value of the system :c:macro:`!FLT_ROUNDS` macro at " "interpreter startup time:" msgstr "" -#: ../../library/sys.rst:719 +#: ../../library/sys.rst:765 msgid "``-1``: indeterminable" msgstr "" -#: ../../library/sys.rst:720 +#: ../../library/sys.rst:766 msgid "``0``: toward zero" msgstr "" -#: ../../library/sys.rst:721 +#: ../../library/sys.rst:767 msgid "``1``: to nearest" msgstr "" -#: ../../library/sys.rst:722 +#: ../../library/sys.rst:768 msgid "``2``: toward positive infinity" msgstr "" -#: ../../library/sys.rst:723 +#: ../../library/sys.rst:769 msgid "``3``: toward negative infinity" msgstr "" -#: ../../library/sys.rst:725 +#: ../../library/sys.rst:771 msgid "" "All other values for :c:macro:`!FLT_ROUNDS` characterize implementation-" "defined rounding behavior." msgstr "" -#: ../../library/sys.rst:728 +#: ../../library/sys.rst:774 msgid "" "The attribute :attr:`sys.float_info.dig` needs further explanation. If " "``s`` is any string representing a decimal number with at most :attr:`!sys." @@ -978,7 +1022,7 @@ msgid "" "back again will recover a string representing the same decimal value::" msgstr "" -#: ../../library/sys.rst:734 +#: ../../library/sys.rst:780 msgid "" ">>> import sys\n" ">>> sys.float_info.dig\n" @@ -988,20 +1032,20 @@ msgid "" "'3.14159265358979'" msgstr "" -#: ../../library/sys.rst:741 +#: ../../library/sys.rst:787 msgid "" "But for strings with more than :attr:`sys.float_info.dig` significant " "digits, this isn't always true::" msgstr "" -#: ../../library/sys.rst:744 +#: ../../library/sys.rst:790 msgid "" ">>> s = '9876543211234567' # 16 significant digits is too many!\n" ">>> format(float(s), '.16g') # conversion changes value\n" "'9876543211234568'" msgstr "" -#: ../../library/sys.rst:750 +#: ../../library/sys.rst:796 msgid "" "A string indicating how the :func:`repr` function behaves for floats. If " "the string has value ``'short'`` then for a finite float ``x``, ``repr(x)`` " @@ -1011,7 +1055,7 @@ msgid "" "same way as it did in versions of Python prior to 3.1." msgstr "" -#: ../../library/sys.rst:763 +#: ../../library/sys.rst:809 msgid "" "Return the number of memory blocks currently allocated by the interpreter, " "regardless of their size. This function is mainly useful for tracking and " @@ -1021,37 +1065,37 @@ msgid "" "results." msgstr "" -#: ../../library/sys.rst:770 +#: ../../library/sys.rst:816 msgid "" "If a Python build or implementation cannot reasonably compute this " "information, :func:`getallocatedblocks` is allowed to return 0 instead." msgstr "" -#: ../../library/sys.rst:778 +#: ../../library/sys.rst:824 msgid "Return the number of unicode objects that have been interned." msgstr "" -#: ../../library/sys.rst:785 +#: ../../library/sys.rst:831 msgid "" "Return the build-time API level of Android as an integer. This represents " "the minimum version of Android this build of Python can run on. For runtime " "version information, see :func:`platform.android_ver`." msgstr "" -#: ../../library/sys.rst:796 +#: ../../library/sys.rst:842 msgid "" "Return ``'utf-8'``. This is the name of the default string encoding, used in " "methods like :meth:`str.encode`." msgstr "" -#: ../../library/sys.rst:802 +#: ../../library/sys.rst:848 msgid "" "Return the current value of the flags that are used for :c:func:`dlopen` " "calls. Symbolic names for the flag values can be found in the :mod:`os` " "module (:samp:`RTLD_{xxx}` constants, e.g. :const:`os.RTLD_LAZY`)." msgstr "" -#: ../../library/sys.rst:812 +#: ../../library/sys.rst:858 msgid "" "Get the :term:`filesystem encoding `: " "the encoding used with the :term:`filesystem error handler ` is enabled." msgstr "" -#: ../../library/sys.rst:845 +#: ../../library/sys.rst:891 msgid "" "Get the :term:`filesystem error handler `: the error handler used with the :term:`filesystem encoding " @@ -1106,20 +1150,51 @@ msgid "" "func:`getfilesystemencoding`." msgstr "" -#: ../../library/sys.rst:863 +#: ../../library/sys.rst:909 msgid "" "Returns the current value for the :ref:`integer string conversion length " "limitation `. See also :func:`set_int_max_str_digits`." msgstr "" -#: ../../library/sys.rst:870 +#: ../../library/sys.rst:917 +msgid "Returns the current lazy imports mode as a string." +msgstr "" + +#: ../../library/sys.rst:919 ../../library/sys.rst:1783 +msgid "" +"``\"normal\"``: Only imports explicitly marked with the ``lazy`` keyword are " +"lazy" +msgstr "" + +#: ../../library/sys.rst:921 +msgid "``\"all\"``: All top-level imports are potentially lazy" +msgstr "" + +#: ../../library/sys.rst:923 ../../library/sys.rst:1507 +msgid "See also :func:`set_lazy_imports` and :pep:`810`." +msgstr "" + +#: ../../library/sys.rst:930 +msgid "" +"Returns the current lazy imports filter function, or ``None`` if no filter " +"is set." +msgstr "" + +#: ../../library/sys.rst:933 +msgid "" +"The filter function is called for every potentially lazy import to determine " +"whether it should actually be lazy. See :func:`set_lazy_imports_filter` for " +"details on the filter function signature." +msgstr "" + +#: ../../library/sys.rst:943 msgid "" "Return the reference count of the *object*. The count returned is generally " "one higher than you might expect, because it includes the (temporary) " "reference as an argument to :func:`getrefcount`." msgstr "" -#: ../../library/sys.rst:874 +#: ../../library/sys.rst:947 msgid "" "Note that the returned value may not actually reflect how many references to " "the object are actually held. For example, some objects are :term:" @@ -1128,19 +1203,19 @@ msgid "" "accurate, other than a value of 0 or 1." msgstr "" -#: ../../library/sys.rst:882 +#: ../../library/sys.rst:955 msgid "" ":term:`Immortal ` objects with a large reference count can be " "identified via :func:`_is_immortal`." msgstr "" -#: ../../library/sys.rst:885 +#: ../../library/sys.rst:958 msgid "" "Immortal objects have very large refcounts that do not match the actual " "number of references to the object." msgstr "" -#: ../../library/sys.rst:891 +#: ../../library/sys.rst:964 msgid "" "Return the current value of the recursion limit, the maximum depth of the " "Python interpreter stack. This limit prevents infinite recursion from " @@ -1148,33 +1223,33 @@ msgid "" "func:`setrecursionlimit`." msgstr "" -#: ../../library/sys.rst:899 +#: ../../library/sys.rst:972 msgid "" "Return the size of an object in bytes. The object can be any type of object. " "All built-in objects will return correct results, but this does not have to " "hold true for third-party extensions as it is implementation specific." msgstr "" -#: ../../library/sys.rst:904 +#: ../../library/sys.rst:977 msgid "" "Only the memory consumption directly attributed to the object is accounted " "for, not the memory consumption of objects it refers to." msgstr "" -#: ../../library/sys.rst:907 +#: ../../library/sys.rst:980 msgid "" "If given, *default* will be returned if the object does not provide means to " "retrieve the size. Otherwise a :exc:`TypeError` will be raised." msgstr "" -#: ../../library/sys.rst:910 +#: ../../library/sys.rst:983 msgid "" ":func:`getsizeof` calls the object's ``__sizeof__`` method and adds an " "additional garbage collector overhead if the object is managed by the " "garbage collector." msgstr "" -#: ../../library/sys.rst:914 +#: ../../library/sys.rst:987 msgid "" "See `recursive sizeof recipe `_ for an example of " @@ -1182,13 +1257,13 @@ msgid "" "their contents." msgstr "" -#: ../../library/sys.rst:920 +#: ../../library/sys.rst:993 msgid "" "Return the interpreter's \"thread switch interval\" in seconds; see :func:" "`setswitchinterval`." msgstr "" -#: ../../library/sys.rst:928 +#: ../../library/sys.rst:1001 msgid "" "Return a frame object from the call stack. If optional integer *depth* is " "given, return the frame object that many calls below the top of the stack. " @@ -1197,7 +1272,7 @@ msgid "" "stack." msgstr "" -#: ../../library/sys.rst:933 +#: ../../library/sys.rst:1006 msgid "" "Raises an :ref:`auditing event ` ``sys._getframe`` with argument " "``frame``." @@ -1205,13 +1280,13 @@ msgstr "" "引發一個附帶引數 ``frame`` 的\\ :ref:`稽核事件 ` ``sys." "_getframe``。" -#: ../../library/sys.rst:937 ../../library/sys.rst:953 +#: ../../library/sys.rst:1010 ../../library/sys.rst:1026 msgid "" "This function should be used for internal and specialized purposes only. It " "is not guaranteed to exist in all implementations of Python." msgstr "" -#: ../../library/sys.rst:943 +#: ../../library/sys.rst:1016 msgid "" "Return the name of a module from the call stack. If optional integer " "*depth* is given, return the module that many calls below the top of the " @@ -1220,7 +1295,7 @@ msgid "" "returning the module at the top of the call stack." msgstr "" -#: ../../library/sys.rst:949 +#: ../../library/sys.rst:1022 msgid "" "Raises an :ref:`auditing event ` ``sys._getframemodulename`` with " "argument ``depth``." @@ -1228,20 +1303,20 @@ msgstr "" "引發一個附帶引數 ``depth`` 的\\ :ref:`稽核事件 ` ``sys." "_getframemodulename``。" -#: ../../library/sys.rst:961 +#: ../../library/sys.rst:1034 msgid "" "This function only exists if CPython was built using the specialized " "configure option :option:`--with-trace-refs`. It is intended only for " "debugging garbage-collection issues." msgstr "" -#: ../../library/sys.rst:965 +#: ../../library/sys.rst:1038 msgid "" "Return a list of up to *limit* dynamically allocated Python objects. If " "*type* is given, only objects of that exact type (not subtypes) are included." msgstr "" -#: ../../library/sys.rst:969 +#: ../../library/sys.rst:1042 msgid "" "Objects from the list are not safe to use. Specifically, the result will " "include objects from all interpreters that share their object allocator " @@ -1251,25 +1326,25 @@ msgid "" "different interpreters may lead to crashes or other unexpected behavior." msgstr "" -#: ../../library/sys.rst:980 ../../library/sys.rst:1388 +#: ../../library/sys.rst:1053 ../../library/sys.rst:1461 msgid "" "This function should be used for specialized purposes only. It is not " "guaranteed to exist in all implementations of Python." msgstr "" -#: ../../library/sys.rst:985 +#: ../../library/sys.rst:1058 msgid "The result may include objects from other interpreters." msgstr "" -#: ../../library/sys.rst:994 +#: ../../library/sys.rst:1067 msgid "Get the profiler function as set by :func:`setprofile`." msgstr "" -#: ../../library/sys.rst:1003 +#: ../../library/sys.rst:1076 msgid "Get the trace function as set by :func:`settrace`." msgstr "" -#: ../../library/sys.rst:1007 +#: ../../library/sys.rst:1080 msgid "" "The :func:`gettrace` function is intended only for implementing debuggers, " "profilers, coverage tools and the like. Its behavior is part of the " @@ -1277,7 +1352,7 @@ msgid "" "thus may not be available in all Python implementations." msgstr "" -#: ../../library/sys.rst:1015 +#: ../../library/sys.rst:1088 msgid "" "Return a named tuple describing the Windows version currently running. The " "named elements are *major*, *minor*, *build*, *platform*, *service_pack*, " @@ -1289,54 +1364,54 @@ msgid "" "first 5 elements are retrievable by indexing." msgstr "" -#: ../../library/sys.rst:1026 +#: ../../library/sys.rst:1099 msgid "*platform* will be ``2`` (VER_PLATFORM_WIN32_NT)." msgstr "" -#: ../../library/sys.rst:1028 +#: ../../library/sys.rst:1101 msgid "*product_type* may be one of the following values:" msgstr "" -#: ../../library/sys.rst:1031 +#: ../../library/sys.rst:1104 msgid "Constant" msgstr "" -#: ../../library/sys.rst:1031 +#: ../../library/sys.rst:1104 msgid "Meaning" msgstr "含義" -#: ../../library/sys.rst:1033 +#: ../../library/sys.rst:1106 msgid "``1`` (VER_NT_WORKSTATION)" msgstr "``1`` (VER_NT_WORKSTATION)" -#: ../../library/sys.rst:1033 +#: ../../library/sys.rst:1106 msgid "The system is a workstation." msgstr "" -#: ../../library/sys.rst:1035 +#: ../../library/sys.rst:1108 msgid "``2`` (VER_NT_DOMAIN_CONTROLLER)" msgstr "``2`` (VER_NT_DOMAIN_CONTROLLER)" -#: ../../library/sys.rst:1035 +#: ../../library/sys.rst:1108 msgid "The system is a domain controller." msgstr "" -#: ../../library/sys.rst:1038 +#: ../../library/sys.rst:1111 msgid "``3`` (VER_NT_SERVER)" msgstr "``3`` (VER_NT_SERVER)" -#: ../../library/sys.rst:1038 +#: ../../library/sys.rst:1111 msgid "The system is a server, but not a domain controller." msgstr "" -#: ../../library/sys.rst:1042 +#: ../../library/sys.rst:1115 msgid "" "This function wraps the Win32 :c:func:`!GetVersionEx` function; see the " "Microsoft documentation on :c:func:`!OSVERSIONINFOEX` for more information " "about these fields." msgstr "" -#: ../../library/sys.rst:1046 +#: ../../library/sys.rst:1119 msgid "" "*platform_version* returns the major version, minor version and build number " "of the current operating system, rather than the version that is being " @@ -1344,24 +1419,24 @@ msgid "" "feature detection." msgstr "" -#: ../../library/sys.rst:1052 +#: ../../library/sys.rst:1125 msgid "" "*platform_version* derives the version from kernel32.dll which can be of a " "different version than the OS version. Please use :mod:`platform` module for " "achieving accurate OS version." msgstr "" -#: ../../library/sys.rst:1058 +#: ../../library/sys.rst:1131 msgid "" "Changed to a named tuple and added *service_pack_minor*, " "*service_pack_major*, *suite_mask*, and *product_type*." msgstr "" -#: ../../library/sys.rst:1062 +#: ../../library/sys.rst:1135 msgid "Added *platform_version*" msgstr "新增 *platform_version*" -#: ../../library/sys.rst:1068 +#: ../../library/sys.rst:1141 msgid "" "Returns an *asyncgen_hooks* object, which is similar to a :class:" "`~collections.namedtuple` of the form ``(firstiter, finalizer)``, where " @@ -1371,75 +1446,75 @@ msgid "" "loop." msgstr "" -#: ../../library/sys.rst:1075 +#: ../../library/sys.rst:1148 msgid "See :pep:`525` for more details." msgstr "更多細節請見 :pep:`525`。" -#: ../../library/sys.rst:1079 ../../library/sys.rst:1878 +#: ../../library/sys.rst:1152 ../../library/sys.rst:2034 msgid "" "This function has been added on a provisional basis (see :pep:`411` for " "details.)" msgstr "" -#: ../../library/sys.rst:1085 +#: ../../library/sys.rst:1158 msgid "" "Get the current coroutine origin tracking depth, as set by :func:" "`set_coroutine_origin_tracking_depth`." msgstr "" -#: ../../library/sys.rst:1091 ../../library/sys.rst:1899 +#: ../../library/sys.rst:1164 ../../library/sys.rst:2055 msgid "" "This function has been added on a provisional basis (see :pep:`411` for " "details.) Use it only for debugging purposes." msgstr "" -#: ../../library/sys.rst:1097 +#: ../../library/sys.rst:1170 msgid "" "A :term:`named tuple` giving parameters of the numeric hash implementation. " "For more details about hashing of numeric types, see :ref:`numeric-hash`." msgstr "" -#: ../../library/sys.rst:1103 +#: ../../library/sys.rst:1176 msgid "The width in bits used for hash values" msgstr "" -#: ../../library/sys.rst:1107 +#: ../../library/sys.rst:1180 msgid "The prime modulus P used for numeric hash scheme" msgstr "" -#: ../../library/sys.rst:1111 +#: ../../library/sys.rst:1184 msgid "The hash value returned for a positive infinity" msgstr "" -#: ../../library/sys.rst:1115 +#: ../../library/sys.rst:1188 msgid "(This attribute is no longer used)" msgstr "" -#: ../../library/sys.rst:1119 +#: ../../library/sys.rst:1192 msgid "The multiplier used for the imaginary part of a complex number" msgstr "" -#: ../../library/sys.rst:1123 +#: ../../library/sys.rst:1196 msgid "The name of the algorithm for hashing of str, bytes, and memoryview" msgstr "" -#: ../../library/sys.rst:1127 +#: ../../library/sys.rst:1200 msgid "The internal output size of the hash algorithm" msgstr "" -#: ../../library/sys.rst:1131 +#: ../../library/sys.rst:1204 msgid "The size of the seed key of the hash algorithm" msgstr "" -#: ../../library/sys.rst:1135 +#: ../../library/sys.rst:1208 msgid "Cutoff for small string DJBX33A optimization in range ``[1, cutoff)``." msgstr "" -#: ../../library/sys.rst:1139 +#: ../../library/sys.rst:1212 msgid "Added *algorithm*, *hash_bits*, *seed_bits*, and *cutoff*." msgstr "新增 *algorithm*、*hash_bits*、*seed_bits* 與 *cutoff*。" -#: ../../library/sys.rst:1145 +#: ../../library/sys.rst:1218 msgid "" "The version number encoded as a single integer. This is guaranteed to " "increase with each version, including proper support for non-production " @@ -1447,7 +1522,7 @@ msgid "" "version 1.5.2, use::" msgstr "" -#: ../../library/sys.rst:1149 +#: ../../library/sys.rst:1222 msgid "" "if sys.hexversion >= 0x010502F0:\n" " # use some advanced feature\n" @@ -1457,7 +1532,7 @@ msgid "" " ..." msgstr "" -#: ../../library/sys.rst:1156 +#: ../../library/sys.rst:1229 msgid "" "This is called ``hexversion`` since it only really looks meaningful when " "viewed as the result of passing it to the built-in :func:`hex` function. " @@ -1465,25 +1540,25 @@ msgid "" "human-friendly encoding of the same information." msgstr "" -#: ../../library/sys.rst:1161 +#: ../../library/sys.rst:1234 msgid "More details of ``hexversion`` can be found at :ref:`apiabiversion`." msgstr "" -#: ../../library/sys.rst:1166 +#: ../../library/sys.rst:1239 msgid "" "An object containing information about the implementation of the currently " "running Python interpreter. The following attributes are required to exist " "in all Python implementations." msgstr "" -#: ../../library/sys.rst:1170 +#: ../../library/sys.rst:1243 msgid "" "*name* is the implementation's identifier, e.g. ``'cpython'``. The actual " "string is defined by the Python implementation, but it is guaranteed to be " "lower case." msgstr "" -#: ../../library/sys.rst:1174 +#: ../../library/sys.rst:1247 msgid "" "*version* is a named tuple, in the same format as :data:`sys.version_info`. " "It represents the version of the Python *implementation*. This has a " @@ -1495,13 +1570,13 @@ msgid "" "the same value, since it is the reference implementation." msgstr "" -#: ../../library/sys.rst:1184 +#: ../../library/sys.rst:1257 msgid "" "*hexversion* is the implementation version in hexadecimal format, like :data:" "`sys.hexversion`." msgstr "" -#: ../../library/sys.rst:1187 +#: ../../library/sys.rst:1260 msgid "" "*cache_tag* is the tag used by the import machinery in the filenames of " "cached modules. By convention, it would be a composite of the " @@ -1510,7 +1585,7 @@ msgid "" "set to ``None``, it indicates that module caching should be disabled." msgstr "" -#: ../../library/sys.rst:1194 +#: ../../library/sys.rst:1267 msgid "" "*supports_isolated_interpreters* is a boolean value, whether this " "implementation supports multiple isolated interpreters. It is ``True`` for " @@ -1518,11 +1593,11 @@ msgid "" "level :mod:`!_interpreters` module." msgstr "" -#: ../../library/sys.rst:1201 +#: ../../library/sys.rst:1274 msgid ":pep:`684`, :pep:`734`, and :mod:`concurrent.interpreters`." msgstr ":pep:`684`、:pep:`734` 和 :mod:`concurrent.interpreters`。" -#: ../../library/sys.rst:1203 +#: ../../library/sys.rst:1276 msgid "" ":data:`sys.implementation` may contain additional attributes specific to the " "Python implementation. These non-standard attributes must start with an " @@ -1532,45 +1607,45 @@ msgid "" "versions, however.) See :pep:`421` for more information." msgstr "" -#: ../../library/sys.rst:1212 +#: ../../library/sys.rst:1285 msgid "Added ``supports_isolated_interpreters`` field." msgstr "" -#: ../../library/sys.rst:1217 +#: ../../library/sys.rst:1290 msgid "" "The addition of new required attributes must go through the normal PEP " "process. See :pep:`421` for more information." msgstr "" -#: ../../library/sys.rst:1222 +#: ../../library/sys.rst:1295 msgid "" "A :term:`named tuple` that holds information about Python's internal " "representation of integers. The attributes are read only." msgstr "" -#: ../../library/sys.rst:1227 +#: ../../library/sys.rst:1300 msgid "" "The number of bits held in each digit. Python integers are stored internally " "in base ``2**int_info.bits_per_digit``." msgstr "" -#: ../../library/sys.rst:1232 +#: ../../library/sys.rst:1305 msgid "The size in bytes of the C type used to represent a digit." msgstr "" -#: ../../library/sys.rst:1236 +#: ../../library/sys.rst:1309 msgid "" "The default value for :func:`sys.get_int_max_str_digits` when it is not " "otherwise explicitly configured." msgstr "" -#: ../../library/sys.rst:1241 +#: ../../library/sys.rst:1314 msgid "" "The minimum non-zero value for :func:`sys.set_int_max_str_digits`, :envvar:" "`PYTHONINTMAXSTRDIGITS`, or :option:`-X int_max_str_digits <-X>`." msgstr "" -#: ../../library/sys.rst:1248 +#: ../../library/sys.rst:1321 msgid "" "Added :attr:`~int_info.default_max_str_digits` and :attr:`~int_info." "str_digits_check_threshold`." @@ -1578,7 +1653,7 @@ msgstr "" "新增 :attr:`~int_info.default_max_str_digits` 和 :attr:`~int_info." "str_digits_check_threshold`。" -#: ../../library/sys.rst:1254 +#: ../../library/sys.rst:1327 msgid "" "When this attribute exists, its value is automatically called (with no " "arguments) when the interpreter is launched in :ref:`interactive mode `." msgstr "" -#: ../../library/sys.rst:1260 ../../library/sys.rst:1262 +#: ../../library/sys.rst:1333 ../../library/sys.rst:1335 msgid "" "Raises an :ref:`auditing event ` ``cpython.run_interactivehook`` " "with the hook object as the argument when the hook is called on startup." msgstr "" -#: ../../library/sys.rst:1271 +#: ../../library/sys.rst:1344 msgid "" "Enter *string* in the table of \"interned\" strings and return the interned " "string -- which is *string* itself or a copy. Interning strings is useful to " @@ -1605,44 +1680,44 @@ msgid "" "attributes have interned keys." msgstr "" -#: ../../library/sys.rst:1279 +#: ../../library/sys.rst:1352 msgid "" "Interned strings are not :term:`immortal`; you must keep a reference to the " "return value of :func:`intern` around to benefit from it." msgstr "" -#: ../../library/sys.rst:1285 +#: ../../library/sys.rst:1358 msgid "" "Return :const:`True` if the :term:`GIL` is enabled and :const:`False` if it " "is disabled." msgstr "" -#: ../../library/sys.rst:1292 ../../library/sys.rst:1400 +#: ../../library/sys.rst:1365 ../../library/sys.rst:1473 msgid "It is not guaranteed to exist in all implementations of Python." msgstr "" -#: ../../library/sys.rst:1296 +#: ../../library/sys.rst:1369 msgid "" "Return :const:`True` if the main Python interpreter is :term:`shutting down " "`. Return :const:`False` otherwise." msgstr "" -#: ../../library/sys.rst:1299 +#: ../../library/sys.rst:1372 msgid "See also the :exc:`PythonFinalizationError` exception." msgstr "另請參閱 :exc:`PythonFinalizationError` 例外。" -#: ../../library/sys.rst:1305 +#: ../../library/sys.rst:1378 msgid "Utilities for observing just-in-time compilation." msgstr "" -#: ../../library/sys.rst:1309 +#: ../../library/sys.rst:1382 msgid "" "JIT compilation is an *experimental implementation detail* of CPython. ``sys." "_jit`` is not guaranteed to exist or behave the same way in all Python " "implementations, versions, or build configurations." msgstr "" -#: ../../library/sys.rst:1317 +#: ../../library/sys.rst:1390 msgid "" "Return ``True`` if the current Python executable supports JIT compilation, " "and ``False`` otherwise. This can be controlled by building CPython with " @@ -1650,7 +1725,7 @@ msgid "" "experimental-jit` option on all other platforms." msgstr "" -#: ../../library/sys.rst:1324 +#: ../../library/sys.rst:1397 msgid "" "Return ``True`` if JIT compilation is enabled for the current Python process " "(implies :func:`sys._jit.is_available`), and ``False`` otherwise. If JIT " @@ -1659,19 +1734,19 @@ msgid "" "interpreter startup." msgstr "" -#: ../../library/sys.rst:1332 +#: ../../library/sys.rst:1405 msgid "" "Return ``True`` if the topmost Python frame is currently executing JIT code " "(implies :func:`sys._jit.is_enabled`), and ``False`` otherwise." msgstr "" -#: ../../library/sys.rst:1337 +#: ../../library/sys.rst:1410 msgid "" "This function is intended for testing and debugging the JIT itself. It " "should be avoided for any other purpose." msgstr "" -#: ../../library/sys.rst:1342 +#: ../../library/sys.rst:1415 msgid "" "Due to the nature of tracing JIT compilers, repeated calls to this function " "may give surprising results. For example, branching on its return value will " @@ -1679,7 +1754,7 @@ msgid "" "entered or exited):" msgstr "" -#: ../../library/sys.rst:1347 +#: ../../library/sys.rst:1420 msgid "" ">>> for warmup in range(BIG_NUMBER):\n" "... # This line is \"hot\", and is eventually JIT-compiled:\n" @@ -1694,7 +1769,7 @@ msgid "" "AssertionError" msgstr "" -#: ../../library/sys.rst:1363 +#: ../../library/sys.rst:1436 msgid "" "This variable is not always defined; it is set to the exception instance " "when an exception is not handled and the interpreter prints an error message " @@ -1705,53 +1780,87 @@ msgid "" "more information.)" msgstr "" -#: ../../library/sys.rst:1375 +#: ../../library/sys.rst:1448 msgid "" "Return :const:`True` if the given object is :term:`immortal`, :const:`False` " "otherwise." msgstr "" -#: ../../library/sys.rst:1380 +#: ../../library/sys.rst:1453 msgid "" "Objects that are immortal (and thus return ``True`` upon being passed to " "this function) are not guaranteed to be immortal in future versions, and " "vice versa for mortal objects." msgstr "" -#: ../../library/sys.rst:1393 +#: ../../library/sys.rst:1466 msgid "" "Return :const:`True` if the given string is \"interned\", :const:`False` " "otherwise." msgstr "" -#: ../../library/sys.rst:1407 +#: ../../library/sys.rst:1480 msgid "" "These three variables are deprecated; use :data:`sys.last_exc` instead. They " "hold the legacy representation of ``sys.last_exc``, as returned from :func:" "`exc_info` above." msgstr "" -#: ../../library/sys.rst:1413 +#: ../../library/sys.rst:1487 +msgid "" +"A :class:`set` of fully qualified module name strings that have been lazily " +"imported in the current interpreter but not yet loaded. When a lazily " +"imported module is accessed for the first time, its name is typically " +"removed from this set." +msgstr "" + +#: ../../library/sys.rst:1492 +msgid "" +"The set may contain some additional strings. It is intended for debugging " +"and introspection, and consumers are expected to verify each entry's status." +msgstr "" + +#: ../../library/sys.rst:1498 +msgid "Currently, :data:`!lazy_modules` may also contain:" +msgstr "" + +#: ../../library/sys.rst:1500 +msgid "" +"names of *attributes* (non-modules), such as ``\"pathlib.Path\"`` after " +"running ``lazy from pathlib import Path``, and" +msgstr "" + +#: ../../library/sys.rst:1502 +msgid "names of items than have already been accessed." +msgstr "" + +#: ../../library/sys.rst:1504 +msgid "" +"In future versions of Python, these may be removed, and/or additional extras " +"may be added." +msgstr "" + +#: ../../library/sys.rst:1514 msgid "" "An integer giving the maximum value a variable of type :c:type:`Py_ssize_t` " "can take. It's usually ``2**31 - 1`` on a 32-bit platform and ``2**63 - 1`` " "on a 64-bit platform." msgstr "" -#: ../../library/sys.rst:1420 +#: ../../library/sys.rst:1521 msgid "" "An integer giving the value of the largest Unicode code point, i.e. " "``1114111`` (``0x10FFFF`` in hexadecimal)." msgstr "" -#: ../../library/sys.rst:1423 +#: ../../library/sys.rst:1524 msgid "" "Before :pep:`393`, ``sys.maxunicode`` used to be either ``0xFFFF`` or " "``0x10FFFF``, depending on the configuration option that specified whether " "Unicode characters were stored as UCS-2 or UCS-4." msgstr "" -#: ../../library/sys.rst:1431 +#: ../../library/sys.rst:1532 msgid "" "A list of :term:`meta path finder` objects that have their :meth:`~importlib." "abc.MetaPathFinder.find_spec` methods called to see if one of the objects " @@ -1764,40 +1873,40 @@ msgid "" "``None`` if the module cannot be found." msgstr "" -#: ../../library/sys.rst:1444 +#: ../../library/sys.rst:1545 msgid ":class:`importlib.abc.MetaPathFinder`" msgstr ":class:`importlib.abc.MetaPathFinder`" -#: ../../library/sys.rst:1445 +#: ../../library/sys.rst:1546 msgid "" "The abstract base class defining the interface of finder objects on :data:" "`meta_path`." msgstr "" -#: ../../library/sys.rst:1447 +#: ../../library/sys.rst:1548 msgid ":class:`importlib.machinery.ModuleSpec`" msgstr ":class:`importlib.machinery.ModuleSpec`" -#: ../../library/sys.rst:1448 +#: ../../library/sys.rst:1549 msgid "" "The concrete class which :meth:`~importlib.abc.MetaPathFinder.find_spec` " "should return instances of." msgstr "" -#: ../../library/sys.rst:1454 +#: ../../library/sys.rst:1555 msgid "" ":term:`Module specs ` were introduced in Python 3.4, by :pep:" "`451`." msgstr "" -#: ../../library/sys.rst:1459 +#: ../../library/sys.rst:1560 msgid "" "Removed the fallback that looked for a :meth:`!find_module` method if a :" "data:`meta_path` entry didn't have a :meth:`~importlib.abc.MetaPathFinder." "find_spec` method." msgstr "" -#: ../../library/sys.rst:1465 +#: ../../library/sys.rst:1566 msgid "" "This is a dictionary that maps module names to modules which have already " "been loaded. This can be manipulated to force reloading of modules and " @@ -1809,13 +1918,13 @@ msgid "" "other threads." msgstr "" -#: ../../library/sys.rst:1477 +#: ../../library/sys.rst:1578 msgid "" "The list of the original command line arguments passed to the Python " "executable." msgstr "" -#: ../../library/sys.rst:1480 +#: ../../library/sys.rst:1581 msgid "" "The elements of :data:`sys.orig_argv` are the arguments to the Python " "interpreter, while the elements of :data:`sys.argv` are the arguments to the " @@ -1823,68 +1932,68 @@ msgid "" "in :data:`sys.orig_argv` and missing from :data:`sys.argv`." msgstr "" -#: ../../library/sys.rst:1492 +#: ../../library/sys.rst:1593 msgid "" "A list of strings that specifies the search path for modules. Initialized " "from the environment variable :envvar:`PYTHONPATH`, plus an installation-" "dependent default." msgstr "" -#: ../../library/sys.rst:1496 +#: ../../library/sys.rst:1597 msgid "" "By default, as initialized upon program startup, a potentially unsafe path " "is prepended to :data:`sys.path` (*before* the entries inserted as a result " "of :envvar:`PYTHONPATH`):" msgstr "" -#: ../../library/sys.rst:1500 +#: ../../library/sys.rst:1601 msgid "" "``python -m module`` command line: prepend the current working directory." msgstr "" -#: ../../library/sys.rst:1502 +#: ../../library/sys.rst:1603 msgid "" "``python script.py`` command line: prepend the script's directory. If it's a " "symbolic link, resolve symbolic links." msgstr "" -#: ../../library/sys.rst:1504 +#: ../../library/sys.rst:1605 msgid "" "``python -c code`` and ``python`` (REPL) command lines: prepend an empty " "string, which means the current working directory." msgstr "" -#: ../../library/sys.rst:1507 +#: ../../library/sys.rst:1608 msgid "" "To not prepend this potentially unsafe path, use the :option:`-P` command " "line option or the :envvar:`PYTHONSAFEPATH` environment variable." msgstr "" -#: ../../library/sys.rst:1510 +#: ../../library/sys.rst:1611 msgid "" "A program is free to modify this list for its own purposes. Only strings " "should be added to :data:`sys.path`; all other data types are ignored during " "import." msgstr "" -#: ../../library/sys.rst:1516 +#: ../../library/sys.rst:1617 msgid "" "Module :mod:`site` This describes how to use .pth files to extend :data:`sys." "path`." msgstr "" -#: ../../library/sys.rst:1521 +#: ../../library/sys.rst:1622 msgid "" "A list of callables that take a path argument to try to create a :term:" "`finder` for the path. If a finder can be created, it is to be returned by " "the callable, else raise :exc:`ImportError`." msgstr "" -#: ../../library/sys.rst:1525 ../../library/sys.rst:1536 +#: ../../library/sys.rst:1626 ../../library/sys.rst:1637 msgid "Originally specified in :pep:`302`." msgstr "" -#: ../../library/sys.rst:1530 +#: ../../library/sys.rst:1631 msgid "" "A dictionary acting as a cache for :term:`finder` objects. The keys are " "paths that have been passed to :data:`sys.path_hooks` and the values are the " @@ -1892,99 +2001,99 @@ msgid "" "is found on :data:`sys.path_hooks` then ``None`` is stored." msgstr "" -#: ../../library/sys.rst:1541 +#: ../../library/sys.rst:1642 msgid "A string containing a platform identifier. Known values are:" msgstr "" -#: ../../library/sys.rst:1544 +#: ../../library/sys.rst:1645 msgid "System" msgstr "系統" -#: ../../library/sys.rst:1544 +#: ../../library/sys.rst:1645 msgid "``platform`` value" msgstr "``platform`` 值" -#: ../../library/sys.rst:1546 +#: ../../library/sys.rst:1647 msgid "AIX" msgstr "AIX" -#: ../../library/sys.rst:1546 +#: ../../library/sys.rst:1647 msgid "``'aix'``" msgstr "``'aix'``" -#: ../../library/sys.rst:1547 +#: ../../library/sys.rst:1648 msgid "Android" msgstr "Android" -#: ../../library/sys.rst:1547 +#: ../../library/sys.rst:1648 msgid "``'android'``" msgstr "``'android'``" -#: ../../library/sys.rst:1548 +#: ../../library/sys.rst:1649 msgid "Emscripten" msgstr "Emscripten" -#: ../../library/sys.rst:1548 +#: ../../library/sys.rst:1649 msgid "``'emscripten'``" msgstr "``'emscripten'``" -#: ../../library/sys.rst:1549 +#: ../../library/sys.rst:1650 msgid "FreeBSD" msgstr "FreeBSD" -#: ../../library/sys.rst:1549 +#: ../../library/sys.rst:1650 msgid "``'freebsd'``" msgstr "``'freebsd'``" -#: ../../library/sys.rst:1550 +#: ../../library/sys.rst:1651 msgid "iOS" msgstr "iOS" -#: ../../library/sys.rst:1550 +#: ../../library/sys.rst:1651 msgid "``'ios'``" msgstr "``'ios'``" -#: ../../library/sys.rst:1551 +#: ../../library/sys.rst:1652 msgid "Linux" msgstr "Linux" -#: ../../library/sys.rst:1551 +#: ../../library/sys.rst:1652 msgid "``'linux'``" msgstr "``'linux'``" -#: ../../library/sys.rst:1552 +#: ../../library/sys.rst:1653 msgid "macOS" msgstr "macOS" -#: ../../library/sys.rst:1552 +#: ../../library/sys.rst:1653 msgid "``'darwin'``" msgstr "``'darwin'``" -#: ../../library/sys.rst:1553 +#: ../../library/sys.rst:1654 msgid "Windows" msgstr "Windows" -#: ../../library/sys.rst:1553 +#: ../../library/sys.rst:1654 msgid "``'win32'``" msgstr "``'win32'``" -#: ../../library/sys.rst:1554 +#: ../../library/sys.rst:1655 msgid "Windows/Cygwin" msgstr "Windows/Cygwin" -#: ../../library/sys.rst:1554 +#: ../../library/sys.rst:1655 msgid "``'cygwin'``" msgstr "``'cygwin'``" -#: ../../library/sys.rst:1555 +#: ../../library/sys.rst:1656 msgid "WASI" msgstr "WASI" -#: ../../library/sys.rst:1555 +#: ../../library/sys.rst:1656 msgid "``'wasi'``" msgstr "``'wasi'``" -#: ../../library/sys.rst:1558 +#: ../../library/sys.rst:1659 msgid "" "On Unix systems not listed in the table, the value is the lowercased OS name " "as returned by ``uname -s``, with the first part of the version as returned " @@ -1993,7 +2102,7 @@ msgid "" "therefore recommended to use the following idiom::" msgstr "" -#: ../../library/sys.rst:1564 +#: ../../library/sys.rst:1665 msgid "" "if sys.platform.startswith('sunos'):\n" " # SunOS-specific code here..." @@ -2001,81 +2110,81 @@ msgstr "" "if sys.platform.startswith('sunos'):\n" " # 這裡會是 SunOS 專屬的程式碼..." -#: ../../library/sys.rst:1567 +#: ../../library/sys.rst:1668 msgid "" "On Linux, :data:`sys.platform` doesn't contain the major version anymore. It " "is always ``'linux'``, instead of ``'linux2'`` or ``'linux3'``." msgstr "" -#: ../../library/sys.rst:1571 +#: ../../library/sys.rst:1672 msgid "" "On AIX, :data:`sys.platform` doesn't contain the major version anymore. It " "is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``." msgstr "" -#: ../../library/sys.rst:1575 +#: ../../library/sys.rst:1676 msgid "" "On Android, :data:`sys.platform` now returns ``'android'`` rather than " "``'linux'``." msgstr "" -#: ../../library/sys.rst:1579 +#: ../../library/sys.rst:1680 msgid "" "On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore. " "It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``." msgstr "" -#: ../../library/sys.rst:1585 +#: ../../library/sys.rst:1686 msgid "" ":data:`os.name` has a coarser granularity. :func:`os.uname` gives system-" "dependent version information." msgstr "" -#: ../../library/sys.rst:1588 +#: ../../library/sys.rst:1689 msgid "" "The :mod:`platform` module provides detailed checks for the system's " "identity." msgstr "" -#: ../../library/sys.rst:1594 +#: ../../library/sys.rst:1695 msgid "" "Name of the platform-specific library directory. It is used to build the " "path of standard library and the paths of installed extension modules." msgstr "" -#: ../../library/sys.rst:1597 +#: ../../library/sys.rst:1698 msgid "" "It is equal to ``\"lib\"`` on most platforms. On Fedora and SuSE, it is " "equal to ``\"lib64\"`` on 64-bit platforms which gives the following ``sys." "path`` paths (where ``X.Y`` is the Python ``major.minor`` version):" msgstr "" -#: ../../library/sys.rst:1601 +#: ../../library/sys.rst:1702 msgid "" "``/usr/lib64/pythonX.Y/``: Standard library (like ``os.py`` of the :mod:`os` " "module)" msgstr "" -#: ../../library/sys.rst:1603 +#: ../../library/sys.rst:1704 msgid "" "``/usr/lib64/pythonX.Y/lib-dynload/``: C extension modules of the standard " "library (like the :mod:`errno` module, the exact filename is platform " "specific)" msgstr "" -#: ../../library/sys.rst:1606 +#: ../../library/sys.rst:1707 msgid "" "``/usr/lib/pythonX.Y/site-packages/`` (always use ``lib``, not :data:`sys." "platlibdir`): Third-party modules" msgstr "" -#: ../../library/sys.rst:1608 +#: ../../library/sys.rst:1709 msgid "" "``/usr/lib64/pythonX.Y/site-packages/``: C extension modules of third-party " "packages" msgstr "" -#: ../../library/sys.rst:1616 +#: ../../library/sys.rst:1717 msgid "" "A string giving the site-specific directory prefix where the platform " "independent Python files are installed; on Unix, the default is :file:`/usr/" @@ -2084,7 +2193,7 @@ msgid "" "derived paths." msgstr "" -#: ../../library/sys.rst:1624 +#: ../../library/sys.rst:1725 msgid "" "If a :ref:`virtual environment ` is in effect, this :data:`prefix` " "will point to the virtual environment. The value for the Python installation " @@ -2092,7 +2201,7 @@ msgid "" "init-virtual-environments` for more information." msgstr "" -#: ../../library/sys.rst:1648 +#: ../../library/sys.rst:1749 msgid "" "Strings specifying the primary and secondary prompt of the interpreter. " "These are only defined if the interpreter is in interactive mode. Their " @@ -2102,7 +2211,7 @@ msgid "" "used to implement a dynamic prompt." msgstr "" -#: ../../library/sys.rst:1658 +#: ../../library/sys.rst:1759 msgid "" "Set the flags used by the interpreter for :c:func:`dlopen` calls, such as " "when the interpreter loads extension modules. Among other things, this will " @@ -2113,14 +2222,97 @@ msgid "" "g. :const:`os.RTLD_LAZY`)." msgstr "" -#: ../../library/sys.rst:1670 +#: ../../library/sys.rst:1771 msgid "" "Set the :ref:`integer string conversion length limitation " "` used by this interpreter. See also :func:" "`get_int_max_str_digits`." msgstr "" -#: ../../library/sys.rst:1682 +#: ../../library/sys.rst:1780 +msgid "" +"Sets the global lazy imports mode. The *mode* parameter must be one of the " +"following strings:" +msgstr "" + +#: ../../library/sys.rst:1785 +msgid "``\"all\"``: All top-level imports become potentially lazy" +msgstr "" + +#: ../../library/sys.rst:1787 +msgid "" +"This function is intended for advanced users who need to control lazy " +"imports across their entire application. Library developers should generally " +"not use this function as it affects the runtime execution of applications." +msgstr "" + +#: ../../library/sys.rst:1792 +msgid "" +"In addition to the mode, lazy imports can be controlled via the filter " +"provided by :func:`set_lazy_imports_filter`." +msgstr "" + +#: ../../library/sys.rst:1795 +msgid "See also :func:`get_lazy_imports` and :pep:`810`." +msgstr "" + +#: ../../library/sys.rst:1802 +msgid "" +"Sets the lazy imports filter callback. The *filter* parameter must be a " +"callable or ``None`` to clear the filter." +msgstr "" + +#: ../../library/sys.rst:1805 +msgid "" +"The filter function is called for every potentially lazy import to determine " +"whether it should actually be lazy. It should have the following signature::" +msgstr "" + +#: ../../library/sys.rst:1809 +msgid "" +"def filter(importing_module: str, imported_module: str,\n" +" fromlist: tuple[str, ...] | None) -> bool" +msgstr "" +"def filter(importing_module: str, imported_module: str,\n" +" fromlist: tuple[str, ...] | None) -> bool" + +#: ../../library/sys.rst:1812 +msgid "The function is called with three positional arguments:" +msgstr "" + +#: ../../library/sys.rst:1814 +msgid "*importing_module* is the name of the module doing the import" +msgstr "" + +#: ../../library/sys.rst:1815 +msgid "" +"*imported_module* is the resolved name of the module being imported (for " +"example, ``lazy from .spam import eggs`` passes ``package.spam``)" +msgstr "" + +#: ../../library/sys.rst:1818 +msgid "" +"*fromlist* is the tuple of names being imported (for ``from ... import`` " +"statements), or ``None`` for regular imports" +msgstr "" + +#: ../../library/sys.rst:1821 +msgid "" +"The filter should return ``True`` to allow the import to be lazy, or " +"``False`` to force an eager import." +msgstr "" + +#: ../../library/sys.rst:1824 +msgid "" +"This is an advanced feature intended for specialized users who need fine-" +"grained control over lazy import behavior." +msgstr "" + +#: ../../library/sys.rst:1827 +msgid "See also :func:`get_lazy_imports_filter` and :pep:`810`." +msgstr "" + +#: ../../library/sys.rst:1838 msgid "" "Set the system's profile function, which allows you to implement a Python " "source code profiler in Python. See chapter :ref:`profile` for more " @@ -2135,14 +2327,14 @@ msgid "" "in the profile function will cause itself unset." msgstr "" -#: ../../library/sys.rst:1694 +#: ../../library/sys.rst:1850 msgid "" "The same tracing mechanism is used for :func:`!setprofile` as :func:" "`settrace`. To trace calls with :func:`!setprofile` inside a tracing " "function (e.g. in a debugger breakpoint), see :func:`call_tracing`." msgstr "" -#: ../../library/sys.rst:1698 +#: ../../library/sys.rst:1854 msgid "" "Profile functions should have three arguments: *frame*, *event*, and *arg*. " "*frame* is the current stack frame. *event* is a string: ``'call'``, " @@ -2150,71 +2342,71 @@ msgid "" "depends on the event type." msgstr "" -#: ../../library/sys.rst:1703 ../../library/sys.rst:1790 +#: ../../library/sys.rst:1859 ../../library/sys.rst:1946 msgid "The events have the following meaning:" msgstr "" -#: ../../library/sys.rst:1705 ../../library/sys.rst:1792 +#: ../../library/sys.rst:1861 ../../library/sys.rst:1948 msgid "``'call'``" msgstr "``'call'``" -#: ../../library/sys.rst:1706 +#: ../../library/sys.rst:1862 msgid "" "A function is called (or some other code block entered). The profile " "function is called; *arg* is ``None``." msgstr "" -#: ../../library/sys.rst:1709 ../../library/sys.rst:1807 +#: ../../library/sys.rst:1865 ../../library/sys.rst:1963 msgid "``'return'``" msgstr "``'return'``" -#: ../../library/sys.rst:1710 +#: ../../library/sys.rst:1866 msgid "" "A function (or other code block) is about to return. The profile function " "is called; *arg* is the value that will be returned, or ``None`` if the " "event is caused by an exception being raised." msgstr "" -#: ../../library/sys.rst:1714 +#: ../../library/sys.rst:1870 msgid "``'c_call'``" msgstr "``'c_call'``" -#: ../../library/sys.rst:1715 +#: ../../library/sys.rst:1871 msgid "" "A C function is about to be called. This may be an extension function or a " "built-in. *arg* is the C function object." msgstr "" -#: ../../library/sys.rst:1718 +#: ../../library/sys.rst:1874 msgid "``'c_return'``" msgstr "``'c_return'``" -#: ../../library/sys.rst:1719 +#: ../../library/sys.rst:1875 msgid "A C function has returned. *arg* is the C function object." msgstr "" -#: ../../library/sys.rst:1721 +#: ../../library/sys.rst:1877 msgid "``'c_exception'``" msgstr "``'c_exception'``" -#: ../../library/sys.rst:1722 +#: ../../library/sys.rst:1878 msgid "A C function has raised an exception. *arg* is the C function object." msgstr "" -#: ../../library/sys.rst:1724 +#: ../../library/sys.rst:1880 msgid "" "Raises an :ref:`auditing event ` ``sys.setprofile`` with no " "arguments." msgstr "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``sys.setprofile``。" -#: ../../library/sys.rst:1729 +#: ../../library/sys.rst:1885 msgid "" "Set the maximum depth of the Python interpreter stack to *limit*. This " "limit prevents infinite recursion from causing an overflow of the C stack " "and crashing Python." msgstr "" -#: ../../library/sys.rst:1733 +#: ../../library/sys.rst:1889 msgid "" "The highest possible limit is platform-dependent. A user may need to set " "the limit higher when they have a program that requires deep recursion and a " @@ -2222,19 +2414,19 @@ msgid "" "because a too-high limit can lead to a crash." msgstr "" -#: ../../library/sys.rst:1738 +#: ../../library/sys.rst:1894 msgid "" "If the new limit is too low at the current recursion depth, a :exc:" "`RecursionError` exception is raised." msgstr "" -#: ../../library/sys.rst:1741 +#: ../../library/sys.rst:1897 msgid "" "A :exc:`RecursionError` exception is now raised if the new limit is too low " "at the current recursion depth." msgstr "" -#: ../../library/sys.rst:1748 +#: ../../library/sys.rst:1904 msgid "" "Set the interpreter's thread switch interval (in seconds). This floating-" "point value determines the ideal duration of the \"timeslices\" allocated to " @@ -2245,7 +2437,7 @@ msgid "" "scheduler." msgstr "" -#: ../../library/sys.rst:1765 +#: ../../library/sys.rst:1921 msgid "" "Set the system's trace function, which allows you to implement a Python " "source code debugger in Python. The function is thread-specific; for a " @@ -2254,7 +2446,7 @@ msgid "" "`threading.settrace`." msgstr "" -#: ../../library/sys.rst:1770 +#: ../../library/sys.rst:1926 msgid "" "Trace functions should have three arguments: *frame*, *event*, and *arg*. " "*frame* is the :ref:`current stack frame `. *event* is a " @@ -2262,7 +2454,7 @@ msgid "" "``'opcode'``. *arg* depends on the event type." msgstr "" -#: ../../library/sys.rst:1775 +#: ../../library/sys.rst:1931 msgid "" "The trace function is invoked (with *event* set to ``'call'``) whenever a " "new local scope is entered; it should return a reference to a local trace " @@ -2270,36 +2462,36 @@ msgid "" "traced." msgstr "" -#: ../../library/sys.rst:1780 +#: ../../library/sys.rst:1936 msgid "" "The local trace function should return a reference to itself, or to another " "function which would then be used as the local trace function for the scope." msgstr "" -#: ../../library/sys.rst:1783 +#: ../../library/sys.rst:1939 msgid "" "If there is any error occurred in the trace function, it will be unset, just " "like ``settrace(None)`` is called." msgstr "" -#: ../../library/sys.rst:1787 +#: ../../library/sys.rst:1943 msgid "" "Tracing is disabled while calling the trace function (e.g. a function set " "by :func:`!settrace`). For recursive tracing see :func:`call_tracing`." msgstr "" -#: ../../library/sys.rst:1793 +#: ../../library/sys.rst:1949 msgid "" "A function is called (or some other code block entered). The global trace " "function is called; *arg* is ``None``; the return value specifies the local " "trace function." msgstr "" -#: ../../library/sys.rst:1797 +#: ../../library/sys.rst:1953 msgid "``'line'``" msgstr "``'line'``" -#: ../../library/sys.rst:1798 +#: ../../library/sys.rst:1954 msgid "" "The interpreter is about to execute a new line of code or re-execute the " "condition of a loop. The local trace function is called; *arg* is ``None``; " @@ -2309,7 +2501,7 @@ msgid "" "f_trace_lines` to :const:`False` on that :ref:`frame `." msgstr "" -#: ../../library/sys.rst:1808 +#: ../../library/sys.rst:1964 msgid "" "A function (or other code block) is about to return. The local trace " "function is called; *arg* is the value that will be returned, or ``None`` if " @@ -2317,22 +2509,22 @@ msgid "" "return value is ignored." msgstr "" -#: ../../library/sys.rst:1813 +#: ../../library/sys.rst:1969 msgid "``'exception'``" msgstr "``'exception'``" -#: ../../library/sys.rst:1814 +#: ../../library/sys.rst:1970 msgid "" "An exception has occurred. The local trace function is called; *arg* is a " "tuple ``(exception, value, traceback)``; the return value specifies the new " "local trace function." msgstr "" -#: ../../library/sys.rst:1818 +#: ../../library/sys.rst:1974 msgid "``'opcode'``" msgstr "``'opcode'``" -#: ../../library/sys.rst:1819 +#: ../../library/sys.rst:1975 msgid "" "The interpreter is about to execute a new opcode (see :mod:`dis` for opcode " "details). The local trace function is called; *arg* is ``None``; the return " @@ -2342,13 +2534,13 @@ msgid "" "objects>`." msgstr "" -#: ../../library/sys.rst:1826 +#: ../../library/sys.rst:1982 msgid "" "Note that as an exception is propagated down the chain of callers, an " "``'exception'`` event is generated at each level." msgstr "" -#: ../../library/sys.rst:1829 +#: ../../library/sys.rst:1985 msgid "" "For more fine-grained usage, it's possible to set a trace function by " "assigning ``frame.f_trace = tracefunc`` explicitly, rather than relying on " @@ -2362,17 +2554,17 @@ msgid "" "on each frame)." msgstr "" -#: ../../library/sys.rst:1840 +#: ../../library/sys.rst:1996 msgid "For more information on code and frame objects, refer to :ref:`types`." msgstr "" -#: ../../library/sys.rst:1842 +#: ../../library/sys.rst:1998 msgid "" "Raises an :ref:`auditing event ` ``sys.settrace`` with no " "arguments." msgstr "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``sys.settrace``。" -#: ../../library/sys.rst:1846 +#: ../../library/sys.rst:2002 msgid "" "The :func:`settrace` function is intended only for implementing debuggers, " "profilers, coverage tools and the like. Its behavior is part of the " @@ -2380,13 +2572,13 @@ msgid "" "thus may not be available in all Python implementations." msgstr "" -#: ../../library/sys.rst:1853 +#: ../../library/sys.rst:2009 msgid "" "``'opcode'`` event type added; :attr:`~frame.f_trace_lines` and :attr:" "`~frame.f_trace_opcodes` attributes added to frames" msgstr "" -#: ../../library/sys.rst:1858 +#: ../../library/sys.rst:2014 msgid "" "Accepts two optional keyword arguments which are callables that accept an :" "term:`asynchronous generator iterator` as an argument. The *firstiter* " @@ -2395,7 +2587,7 @@ msgid "" "about to be garbage collected." msgstr "" -#: ../../library/sys.rst:1864 +#: ../../library/sys.rst:2020 msgid "" "Raises an :ref:`auditing event ` ``sys." "set_asyncgen_hooks_firstiter`` with no arguments." @@ -2403,7 +2595,7 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``sys." "set_asyncgen_hooks_firstiter``。" -#: ../../library/sys.rst:1866 +#: ../../library/sys.rst:2022 msgid "" "Raises an :ref:`auditing event ` ``sys." "set_asyncgen_hooks_finalizer`` with no arguments." @@ -2411,20 +2603,20 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``sys." "set_asyncgen_hooks_finalizer``。" -#: ../../library/sys.rst:1868 +#: ../../library/sys.rst:2024 msgid "" "Two auditing events are raised because the underlying API consists of two " "calls, each of which must raise its own event." msgstr "" -#: ../../library/sys.rst:1871 +#: ../../library/sys.rst:2027 msgid "" "See :pep:`525` for more details, and for a reference example of a " "*finalizer* method see the implementation of ``asyncio.Loop." "shutdown_asyncgens`` in :source:`Lib/asyncio/base_events.py`" msgstr "" -#: ../../library/sys.rst:1883 +#: ../../library/sys.rst:2039 msgid "" "Allows enabling or disabling coroutine origin tracking. When enabled, the " "``cr_origin`` attribute on coroutine objects will contain a tuple of " @@ -2433,53 +2625,53 @@ msgid "" "disabled, ``cr_origin`` will be ``None``." msgstr "" -#: ../../library/sys.rst:1890 +#: ../../library/sys.rst:2046 msgid "" "To enable, pass a *depth* value greater than zero; this sets the number of " "frames whose information will be captured. To disable, set *depth* to zero." msgstr "" -#: ../../library/sys.rst:1894 +#: ../../library/sys.rst:2050 msgid "This setting is thread-specific." msgstr "" -#: ../../library/sys.rst:1904 +#: ../../library/sys.rst:2060 msgid "" "Activate the stack profiler trampoline *backend*. The only supported backend " "is ``\"perf\"``." msgstr "" -#: ../../library/sys.rst:1907 +#: ../../library/sys.rst:2063 msgid "Stack trampolines cannot be activated if the JIT is active." msgstr "" -#: ../../library/sys.rst:1915 +#: ../../library/sys.rst:2071 msgid ":ref:`perf_profiling`" msgstr ":ref:`perf_profiling`" -#: ../../library/sys.rst:1916 +#: ../../library/sys.rst:2072 msgid "https://perf.wiki.kernel.org" msgstr "https://perf.wiki.kernel.org" -#: ../../library/sys.rst:1920 +#: ../../library/sys.rst:2076 msgid "Deactivate the current stack profiler trampoline backend." msgstr "" -#: ../../library/sys.rst:1922 +#: ../../library/sys.rst:2078 msgid "If no stack profiler is activated, this function has no effect." msgstr "" -#: ../../library/sys.rst:1930 +#: ../../library/sys.rst:2086 msgid "Return ``True`` if a stack profiler trampoline is active." msgstr "" -#: ../../library/sys.rst:1939 +#: ../../library/sys.rst:2095 msgid "" "Executes *script*, a file containing Python code in the remote process with " "the given *pid*." msgstr "" -#: ../../library/sys.rst:1942 +#: ../../library/sys.rst:2098 msgid "" "This function returns immediately, and the code will be executed by the " "target process's main thread at the next available opportunity, similarly to " @@ -2489,7 +2681,7 @@ msgid "" "been overwritten." msgstr "" -#: ../../library/sys.rst:1949 +#: ../../library/sys.rst:2105 msgid "" "The remote process must be running a CPython interpreter of the same major " "and minor version as the local process. If either the local or remote " @@ -2497,13 +2689,13 @@ msgid "" "local and remote interpreters must be the same exact version." msgstr "" -#: ../../library/sys.rst:1954 +#: ../../library/sys.rst:2110 msgid "" "See :ref:`remote-debugging` for more information about the remote debugging " "mechanism." msgstr "" -#: ../../library/sys.rst:1957 ../../library/sys.rst:1959 +#: ../../library/sys.rst:2113 ../../library/sys.rst:2115 msgid "" "When the code is executed in the remote process, an :ref:`auditing event " "` ``sys.remote_exec`` is raised with the *pid* and the path to the " @@ -2511,7 +2703,7 @@ msgid "" "remote_exec`." msgstr "" -#: ../../library/sys.rst:1964 ../../library/sys.rst:1966 +#: ../../library/sys.rst:2120 ../../library/sys.rst:2122 msgid "" "When the script is executed in the remote process, an :ref:`auditing event " "` ``cpython.remote_debugger_script`` is raised with the path in " @@ -2519,78 +2711,78 @@ msgid "" "that called :func:`sys.remote_exec`." msgstr "" -#: ../../library/sys.rst:1974 +#: ../../library/sys.rst:2130 msgid "See :pep:`768` for more details." msgstr "更多細節請見 :pep:`768`。" -#: ../../library/sys.rst:1980 +#: ../../library/sys.rst:2136 msgid "" "Changes the :term:`filesystem encoding and error handler` to 'mbcs' and " "'replace' respectively, for consistency with versions of Python prior to 3.6." msgstr "" -#: ../../library/sys.rst:1984 +#: ../../library/sys.rst:2140 msgid "" "This is equivalent to defining the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " "environment variable before launching Python." msgstr "" -#: ../../library/sys.rst:1987 +#: ../../library/sys.rst:2143 msgid "" "See also :func:`sys.getfilesystemencoding` and :func:`sys." "getfilesystemencodeerrors`." msgstr "" -#: ../../library/sys.rst:1993 +#: ../../library/sys.rst:2149 msgid "" "Changing the filesystem encoding after Python startup is risky because the " "old fsencoding or paths encoded by the old fsencoding may be cached " "somewhere. Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead." msgstr "" -#: ../../library/sys.rst:1997 +#: ../../library/sys.rst:2153 msgid "See :pep:`529` for more details." msgstr "更多細節請見 :pep:`529`。" -#: ../../library/sys.rst:2000 +#: ../../library/sys.rst:2156 msgid "Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead." msgstr "" -#: ../../library/sys.rst:2007 +#: ../../library/sys.rst:2163 msgid "" ":term:`File objects ` used by the interpreter for standard " "input, output and errors:" msgstr "" -#: ../../library/sys.rst:2010 +#: ../../library/sys.rst:2166 msgid "" "``stdin`` is used for all interactive input (including calls to :func:" "`input`);" msgstr "" -#: ../../library/sys.rst:2012 +#: ../../library/sys.rst:2168 msgid "" "``stdout`` is used for the output of :func:`print` and :term:`expression` " "statements and for the prompts of :func:`input`;" msgstr "" -#: ../../library/sys.rst:2014 +#: ../../library/sys.rst:2170 msgid "The interpreter's own prompts and its error messages go to ``stderr``." msgstr "" -#: ../../library/sys.rst:2016 +#: ../../library/sys.rst:2172 msgid "" "These streams are regular :term:`text files ` like those returned " "by the :func:`open` function. Their parameters are chosen as follows:" msgstr "" -#: ../../library/sys.rst:2020 +#: ../../library/sys.rst:2176 msgid "" "The encoding and error handling are initialized from :c:member:`PyConfig." "stdio_encoding` and :c:member:`PyConfig.stdio_errors`." msgstr "" -#: ../../library/sys.rst:2023 +#: ../../library/sys.rst:2179 msgid "" "On Windows, UTF-8 is used for the console device. Non-character devices " "such as disk files and pipes use the system locale encoding (i.e. the ANSI " @@ -2601,14 +2793,14 @@ msgid "" "initially attached to a console." msgstr "" -#: ../../library/sys.rst:2032 +#: ../../library/sys.rst:2188 msgid "" "The special behaviour of the console can be overridden by setting the " "environment variable PYTHONLEGACYWINDOWSSTDIO before starting Python. In " "that case, the console codepages are used as for any other character device." msgstr "" -#: ../../library/sys.rst:2037 +#: ../../library/sys.rst:2193 msgid "" "Under all platforms, you can override the character encoding by setting the :" "envvar:`PYTHONIOENCODING` environment variable before starting Python or by " @@ -2617,7 +2809,7 @@ msgid "" "only applies when :envvar:`PYTHONLEGACYWINDOWSSTDIO` is also set." msgstr "" -#: ../../library/sys.rst:2044 +#: ../../library/sys.rst:2200 msgid "" "When interactive, the ``stdout`` stream is line-buffered. Otherwise, it is " "block-buffered like regular text files. The ``stderr`` stream is line-" @@ -2626,19 +2818,19 @@ msgid "" "`PYTHONUNBUFFERED` environment variable." msgstr "" -#: ../../library/sys.rst:2050 +#: ../../library/sys.rst:2206 msgid "" "Non-interactive ``stderr`` is now line-buffered instead of fully buffered." msgstr "" -#: ../../library/sys.rst:2056 +#: ../../library/sys.rst:2212 msgid "" "To write or read binary data from/to the standard streams, use the " "underlying binary :data:`~io.TextIOBase.buffer` object. For example, to " "write bytes to :data:`stdout`, use ``sys.stdout.buffer.write(b'abc')``." msgstr "" -#: ../../library/sys.rst:2060 +#: ../../library/sys.rst:2216 msgid "" "However, if you are writing a library (and do not control in which context " "its code will be executed), be aware that the standard streams may be " @@ -2646,7 +2838,7 @@ msgid "" "support the :attr:`!buffer` attribute." msgstr "" -#: ../../library/sys.rst:2070 +#: ../../library/sys.rst:2226 msgid "" "These objects contain the original values of ``stdin``, ``stderr`` and " "``stdout`` at the start of the program. They are used during finalization, " @@ -2654,7 +2846,7 @@ msgid "" "``sys.std*`` object has been redirected." msgstr "" -#: ../../library/sys.rst:2075 +#: ../../library/sys.rst:2231 msgid "" "It can also be used to restore the actual files to known working file " "objects in case they have been overwritten with a broken object. However, " @@ -2662,7 +2854,7 @@ msgid "" "before replacing it, and restore the saved object." msgstr "" -#: ../../library/sys.rst:2081 +#: ../../library/sys.rst:2237 msgid "" "Under some conditions ``stdin``, ``stdout`` and ``stderr`` as well as the " "original values ``__stdin__``, ``__stdout__`` and ``__stderr__`` can be " @@ -2670,12 +2862,12 @@ msgid "" "to a console and Python apps started with :program:`pythonw`." msgstr "" -#: ../../library/sys.rst:2089 +#: ../../library/sys.rst:2245 msgid "" "A frozenset of strings containing the names of standard library modules." msgstr "" -#: ../../library/sys.rst:2091 +#: ../../library/sys.rst:2247 msgid "" "It is the same on all platforms. Modules which are not available on some " "platforms and modules disabled at Python build are also listed. All module " @@ -2683,7 +2875,7 @@ msgid "" "modules are excluded." msgstr "" -#: ../../library/sys.rst:2096 +#: ../../library/sys.rst:2252 msgid "" "For packages, only the main package is listed: sub-packages and sub-modules " "are not listed. For example, the ``email`` package is listed, but the " @@ -2691,60 +2883,68 @@ msgid "" "listed." msgstr "" -#: ../../library/sys.rst:2101 +#: ../../library/sys.rst:2257 msgid "See also the :data:`sys.builtin_module_names` list." msgstr "另請參閱 :data:`sys.builtin_module_names` 清單。" -#: ../../library/sys.rst:2108 +#: ../../library/sys.rst:2264 msgid "" "A :term:`named tuple` holding information about the thread implementation." msgstr "" -#: ../../library/sys.rst:2113 +#: ../../library/sys.rst:2269 msgid "The name of the thread implementation:" msgstr "" -#: ../../library/sys.rst:2115 +#: ../../library/sys.rst:2271 msgid "``\"nt\"``: Windows threads" msgstr "``\"nt\"``: Windows 執行緒" -#: ../../library/sys.rst:2116 +#: ../../library/sys.rst:2272 msgid "``\"pthread\"``: POSIX threads" msgstr "``\"pthread\"``: POSIX 執行緒" -#: ../../library/sys.rst:2117 +#: ../../library/sys.rst:2273 msgid "" "``\"pthread-stubs\"``: stub POSIX threads (on WebAssembly platforms without " "threading support)" msgstr "" -#: ../../library/sys.rst:2119 +#: ../../library/sys.rst:2275 msgid "``\"solaris\"``: Solaris threads" msgstr "" -#: ../../library/sys.rst:2123 +#: ../../library/sys.rst:2279 msgid "The name of the lock implementation:" msgstr "" -#: ../../library/sys.rst:2125 -msgid "``\"semaphore\"``: a lock uses a semaphore" +#: ../../library/sys.rst:2281 +msgid "``\"semaphore\"``: a lock uses a semaphore (Python 3.14 and older)" msgstr "" -#: ../../library/sys.rst:2126 -msgid "``\"mutex+cond\"``: a lock uses a mutex and a condition variable" +#: ../../library/sys.rst:2282 +msgid "" +"``\"mutex+cond\"``: a lock uses a mutex and a condition variable (Python " +"3.14 and older)" msgstr "" -#: ../../library/sys.rst:2127 +#: ../../library/sys.rst:2283 +msgid "" +"``\"pymutex\"``: a lock uses the :c:type:`PyMutex` implementation (Python " +"3.15 and newer)" +msgstr "" + +#: ../../library/sys.rst:2284 msgid "``None`` if this information is unknown" msgstr "為 ``None`` 表示此資訊未知" -#: ../../library/sys.rst:2131 +#: ../../library/sys.rst:2288 msgid "" "The name and version of the thread library. It is a string, or ``None`` if " "this information is unknown." msgstr "" -#: ../../library/sys.rst:2139 +#: ../../library/sys.rst:2296 msgid "" "When this variable is set to an integer value, it determines the maximum " "number of levels of traceback information printed when an unhandled " @@ -2753,73 +2953,79 @@ msgid "" "are printed." msgstr "" -#: ../../library/sys.rst:2147 +#: ../../library/sys.rst:2304 msgid "Handle an unraisable exception." msgstr "處理一個不可被引發的例外。" -#: ../../library/sys.rst:2149 +#: ../../library/sys.rst:2306 msgid "" "Called when an exception has occurred but there is no way for Python to " "handle it. For example, when a destructor raises an exception or during " "garbage collection (:func:`gc.collect`)." msgstr "" -#: ../../library/sys.rst:2153 +#: ../../library/sys.rst:2310 msgid "The *unraisable* argument has the following attributes:" msgstr "*unraisable* 引數具有以下屬性:" -#: ../../library/sys.rst:2155 +#: ../../library/sys.rst:2312 msgid ":attr:`!exc_type`: Exception type." msgstr ":attr:`!exc_type`: 例外型別。" -#: ../../library/sys.rst:2156 +#: ../../library/sys.rst:2313 msgid ":attr:`!exc_value`: Exception value, can be ``None``." msgstr ":attr:`!exc_value`: 例外值,可以為 ``None``。" -#: ../../library/sys.rst:2157 +#: ../../library/sys.rst:2314 msgid ":attr:`!exc_traceback`: Exception traceback, can be ``None``." msgstr ":attr:`!exc_traceback`: 例外追蹤,可以為 ``None``。" -#: ../../library/sys.rst:2158 +#: ../../library/sys.rst:2315 msgid ":attr:`!err_msg`: Error message, can be ``None``." msgstr ":attr:`!err_msg`: 錯誤訊息,可以為 ``None``。" -#: ../../library/sys.rst:2159 +#: ../../library/sys.rst:2316 msgid ":attr:`!object`: Object causing the exception, can be ``None``." msgstr ":attr:`!object`: 導致例外的物件,可以為 ``None``。" -#: ../../library/sys.rst:2161 +#: ../../library/sys.rst:2318 msgid "" "The default hook formats :attr:`!err_msg` and :attr:`!object` as: " "``f'{err_msg}: {object!r}'``; use \"Exception ignored in\" error message if :" -"attr:`!err_msg` is ``None``." +"attr:`!err_msg` is ``None``. Similar to the :mod:`traceback` module, this " +"adds color to exceptions by default. This can be disabled using :ref:" +"`environment variables `." msgstr "" -#: ../../library/sys.rst:2165 +#: ../../library/sys.rst:2324 msgid "" ":func:`sys.unraisablehook` can be overridden to control how unraisable " "exceptions are handled." msgstr "" -#: ../../library/sys.rst:2170 +#: ../../library/sys.rst:2327 +msgid "Exceptions are now printed with colorful text." +msgstr "" + +#: ../../library/sys.rst:2332 msgid ":func:`excepthook` which handles uncaught exceptions." msgstr "處理未被捕捉到例外的 :func:`excepthook`。" -#: ../../library/sys.rst:2174 +#: ../../library/sys.rst:2336 msgid "" "Storing :attr:`!exc_value` using a custom hook can create a reference cycle. " "It should be cleared explicitly to break the reference cycle when the " "exception is no longer needed." msgstr "" -#: ../../library/sys.rst:2178 +#: ../../library/sys.rst:2340 msgid "" "Storing :attr:`!object` using a custom hook can resurrect it if it is set to " "an object which is being finalized. Avoid storing :attr:`!object` after the " "custom hook completes to avoid resurrecting objects." msgstr "" -#: ../../library/sys.rst:2182 ../../library/sys.rst:2184 +#: ../../library/sys.rst:2344 ../../library/sys.rst:2346 msgid "" "Raise an auditing event ``sys.unraisablehook`` with arguments *hook*, " "*unraisable* when an exception that cannot be handled occurs. The " @@ -2827,7 +3033,7 @@ msgid "" "hook has been set, *hook* may be ``None``." msgstr "" -#: ../../library/sys.rst:2193 +#: ../../library/sys.rst:2355 msgid "" "A string containing the version number of the Python interpreter plus " "additional information on the build number and compiler used. This string " @@ -2836,19 +3042,19 @@ msgid "" "functions provided by the :mod:`platform` module." msgstr "" -#: ../../library/sys.rst:2202 +#: ../../library/sys.rst:2364 msgid "" "The C API version, equivalent to the C macro :c:macro:`PYTHON_API_VERSION`. " "Defined for backwards compatibility." msgstr "" -#: ../../library/sys.rst:2205 +#: ../../library/sys.rst:2367 msgid "" "Currently, this constant is not updated in new Python versions, and is not " "useful for versioning. This may change in the future." msgstr "" -#: ../../library/sys.rst:2211 +#: ../../library/sys.rst:2373 msgid "" "A tuple containing the five components of the version number: *major*, " "*minor*, *micro*, *releaselevel*, and *serial*. All values except " @@ -2859,18 +3065,18 @@ msgid "" "version_info.major`` and so on." msgstr "" -#: ../../library/sys.rst:2219 +#: ../../library/sys.rst:2381 msgid "Added named component attributes." msgstr "新增了附名的元件屬性。" -#: ../../library/sys.rst:2224 +#: ../../library/sys.rst:2386 msgid "" "This is an implementation detail of the warnings framework; do not modify " "this value. Refer to the :mod:`warnings` module for more information on the " "warnings framework." msgstr "" -#: ../../library/sys.rst:2231 +#: ../../library/sys.rst:2393 msgid "" "The version number used to form registry keys on Windows platforms. This is " "stored as string resource 1000 in the Python DLL. The value is normally the " @@ -2879,20 +3085,20 @@ msgid "" "has no effect on the registry keys used by Python." msgstr "" -#: ../../library/sys.rst:2243 +#: ../../library/sys.rst:2405 msgid "" "Namespace containing functions and constants for register callbacks and " "controlling monitoring events. See :mod:`sys.monitoring` for details." msgstr "" -#: ../../library/sys.rst:2249 +#: ../../library/sys.rst:2411 msgid "" "A dictionary of the various implementation-specific flags passed through " "the :option:`-X` command-line option. Option names are either mapped to " "their values, if given explicitly, or to :const:`True`. Example:" msgstr "" -#: ../../library/sys.rst:2253 +#: ../../library/sys.rst:2415 msgid "" "$ ./python -Xa=b -Xc\n" "Python 3.2a3+ (py3k, Oct 16 2010, 20:14:50)\n" @@ -2912,18 +3118,18 @@ msgstr "" ">>> sys._xoptions\n" "{'a': 'b', 'c': True}" -#: ../../library/sys.rst:2265 +#: ../../library/sys.rst:2427 msgid "" "This is a CPython-specific way of accessing options passed through :option:`-" "X`. Other implementations may export them through other means, or not at " "all." msgstr "" -#: ../../library/sys.rst:2273 +#: ../../library/sys.rst:2435 msgid "Citations" msgstr "引用" -#: ../../library/sys.rst:2274 +#: ../../library/sys.rst:2436 msgid "" "ISO/IEC 9899:1999. \"Programming languages -- C.\" A public draft of this " "standard is available at https://www.open-std.org/jtc1/sc22/wg14/www/docs/" @@ -2932,62 +3138,62 @@ msgstr "" "ISO/IEC 9899:1999. \"Programming languages -- C.\" 公開草案可在以下網址取" "得 https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf。" -#: ../../library/sys.rst:99 +#: ../../library/sys.rst:144 msgid "auditing" msgstr "" -#: ../../library/sys.rst:461 +#: ../../library/sys.rst:506 msgid "object" msgstr "object(物件)" -#: ../../library/sys.rst:461 +#: ../../library/sys.rst:506 msgid "traceback" msgstr "traceback" -#: ../../library/sys.rst:990 ../../library/sys.rst:1678 +#: ../../library/sys.rst:1063 ../../library/sys.rst:1834 msgid "profile function" msgstr "" -#: ../../library/sys.rst:990 ../../library/sys.rst:1678 +#: ../../library/sys.rst:1063 ../../library/sys.rst:1834 msgid "profiler" msgstr "" -#: ../../library/sys.rst:999 ../../library/sys.rst:1761 +#: ../../library/sys.rst:1072 ../../library/sys.rst:1917 msgid "trace function" msgstr "" -#: ../../library/sys.rst:999 ../../library/sys.rst:1761 +#: ../../library/sys.rst:1072 ../../library/sys.rst:1917 msgid "debugger" msgstr "debugger(除錯器)" -#: ../../library/sys.rst:1490 +#: ../../library/sys.rst:1591 msgid "module" msgstr "module(模組)" -#: ../../library/sys.rst:1490 +#: ../../library/sys.rst:1591 msgid "search" msgstr "search(搜尋)" -#: ../../library/sys.rst:1490 +#: ../../library/sys.rst:1591 msgid "path" msgstr "path(路徑)" -#: ../../library/sys.rst:1642 +#: ../../library/sys.rst:1743 msgid "interpreter prompts" msgstr "interpreter prompts(直譯器提示)" -#: ../../library/sys.rst:1642 +#: ../../library/sys.rst:1743 msgid "prompts, interpreter" msgstr "prompts, interpreter(提示、直譯器)" -#: ../../library/sys.rst:1642 +#: ../../library/sys.rst:1743 msgid ">>>" msgstr ">>>" -#: ../../library/sys.rst:1642 +#: ../../library/sys.rst:1743 msgid "interpreter prompt" msgstr "interpreter prompt(直譯器提示)" -#: ../../library/sys.rst:1642 +#: ../../library/sys.rst:1743 msgid "..." msgstr "..." diff --git a/library/sys_path_init.po b/library/sys_path_init.po index 544a5913067..b4d821987c0 100644 --- a/library/sys_path_init.po +++ b/library/sys_path_init.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -107,43 +107,46 @@ msgstr "" #: ../../library/sys_path_init.rst:60 msgid "" "Finally, the :mod:`site` module is processed and :file:`site-packages` " -"directories are added to the module search path. A common way to customize " -"the search path is to create :mod:`sitecustomize` or :mod:`usercustomize` " -"modules as described in the :mod:`site` module documentation." +"directories are added to the module search path. The :envvar:" +"`PYTHONUSERBASE` environment variable controls where is searched for user " +"site-packages and the :envvar:`PYTHONNOUSERSITE` environment variable " +"prevents searching for user site-packages all together. A common way to " +"customize the search path is to create :mod:`sitecustomize` or :mod:" +"`usercustomize` modules as described in the :mod:`site` module documentation." msgstr "" -#: ../../library/sys_path_init.rst:67 +#: ../../library/sys_path_init.rst:70 msgid "" -"Certain command line options may further affect path calculations. " -"See :option:`-E`, :option:`-I`, :option:`-s` and :option:`-S` for further " -"details." +"The command line options :option:`-E`, :option:`-P`, :option:`-I`, :option:`-" +"S` and :option:`-s` further affect path calculations, see their " +"documentation for details." msgstr "" -#: ../../library/sys_path_init.rst:72 +#: ../../library/sys_path_init.rst:76 msgid "" ":data:`sys.prefix` and :data:`sys.exec_prefix` are now set to the " "``pyvenv.cfg`` directory during the path initialization. This was previously " "done by :mod:`site`, therefore affected by :option:`-S`." msgstr "" -#: ../../library/sys_path_init.rst:79 +#: ../../library/sys_path_init.rst:83 msgid "Virtual Environments" msgstr "虛擬環境" -#: ../../library/sys_path_init.rst:81 +#: ../../library/sys_path_init.rst:85 msgid "" "Virtual environments place a ``pyvenv.cfg`` file in their prefix, which " "causes :data:`sys.prefix` and :data:`sys.exec_prefix` to point to them, " "instead of the base installation." msgstr "" -#: ../../library/sys_path_init.rst:85 +#: ../../library/sys_path_init.rst:89 msgid "" "The ``prefix`` and ``exec_prefix`` values of the base installation are " "available at :data:`sys.base_prefix` and :data:`sys.base_exec_prefix`." msgstr "" -#: ../../library/sys_path_init.rst:88 +#: ../../library/sys_path_init.rst:92 msgid "" "As well as being used as a marker to identify virtual environments, " "``pyvenv.cfg`` may also be used to configure the :mod:`site` initialization. " @@ -151,24 +154,23 @@ msgid "" "virtual-environments-configuration>`." msgstr "" -#: ../../library/sys_path_init.rst:95 +#: ../../library/sys_path_init.rst:99 msgid ":envvar:`PYTHONHOME` overrides the ``pyvenv.cfg`` detection." msgstr "" -#: ../../library/sys_path_init.rst:99 +#: ../../library/sys_path_init.rst:103 msgid "" -"There are other ways how \"virtual environments\" could be implemented, this " -"documentation refers implementations based on the ``pyvenv.cfg`` mechanism, " -"such as :mod:`venv`. Most virtual environment implementations follow the " -"model set by :mod:`venv`, but there may be exotic implementations that " -"diverge from it." +"There are other ways \"virtual environments\" could be implemented. This " +"documentation refers to implementations based on the ``pyvenv.cfg`` " +"mechanism, such as :mod:`venv`, that many virtual environment " +"implementations follow." msgstr "" -#: ../../library/sys_path_init.rst:106 +#: ../../library/sys_path_init.rst:111 msgid "_pth files" msgstr "_pth 檔案" -#: ../../library/sys_path_init.rst:108 +#: ../../library/sys_path_init.rst:113 msgid "" "To completely override :data:`sys.path` create a ``._pth`` file with the " "same name as the shared library or executable (``python._pth`` or " @@ -179,7 +181,7 @@ msgid "" "allows paths to be restricted for any program loading the runtime if desired." msgstr "" -#: ../../library/sys_path_init.rst:116 +#: ../../library/sys_path_init.rst:121 msgid "" "When the file exists, all registry and environment variables are ignored, " "isolated mode is enabled, and :mod:`site` is not imported unless one line in " @@ -189,17 +191,17 @@ msgid "" "arbitrary code cannot be specified." msgstr "" -#: ../../library/sys_path_init.rst:123 +#: ../../library/sys_path_init.rst:128 msgid "" "Note that ``.pth`` files (without leading underscore) will be processed " "normally by the :mod:`site` module when ``import site`` has been specified." msgstr "" -#: ../../library/sys_path_init.rst:127 +#: ../../library/sys_path_init.rst:132 msgid "Embedded Python" msgstr "" -#: ../../library/sys_path_init.rst:129 +#: ../../library/sys_path_init.rst:134 msgid "" "If Python is embedded within another " "application :c:func:`Py_InitializeFromConfig` and the :c:type:`PyConfig` " @@ -207,10 +209,10 @@ msgid "" "described at :ref:`init-path-config`." msgstr "" -#: ../../library/sys_path_init.rst:135 +#: ../../library/sys_path_init.rst:140 msgid ":ref:`windows_finding_modules` for detailed Windows notes." msgstr ":ref:`windows_finding_modules` 有關於 Windows 的詳細資訊。" -#: ../../library/sys_path_init.rst:136 +#: ../../library/sys_path_init.rst:141 msgid ":ref:`using-on-unix` for Unix details." msgstr ":ref:`using-on-unix` 有關於 Unix 的詳細資訊。" diff --git a/library/sysconfig.po b/library/sysconfig.po index 965c5d55479..447cdf0bb83 100644 --- a/library/sysconfig.po +++ b/library/sysconfig.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:12+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,69 +22,69 @@ msgid "" ":mod:`!sysconfig` --- Provide access to Python's configuration information" msgstr ":mod:`!sysconfig` --- 提供 Python 設定資訊的存取" -#: ../../library/sysconfig.rst:12 +#: ../../library/sysconfig.rst:9 msgid "**Source code:** :source:`Lib/sysconfig`" msgstr "**原始碼:**\\ :source:`Lib/sysconfig`" -#: ../../library/sysconfig.rst:19 +#: ../../library/sysconfig.rst:16 msgid "" "The :mod:`!sysconfig` module provides access to Python's configuration " "information like the list of installation paths and the configuration " "variables relevant for the current platform." msgstr "" -#: ../../library/sysconfig.rst:25 +#: ../../library/sysconfig.rst:22 msgid "Configuration variables" msgstr "" -#: ../../library/sysconfig.rst:27 +#: ../../library/sysconfig.rst:24 msgid "" "A Python distribution contains a :file:`Makefile` and a :file:`pyconfig.h` " "header file that are necessary to build both the Python binary itself and " "third-party C extensions compiled using ``setuptools``." msgstr "" -#: ../../library/sysconfig.rst:31 +#: ../../library/sysconfig.rst:28 msgid "" ":mod:`!sysconfig` puts all variables found in these files in a dictionary " "that can be accessed using :func:`get_config_vars` or :func:`get_config_var`." msgstr "" -#: ../../library/sysconfig.rst:34 +#: ../../library/sysconfig.rst:31 msgid "Notice that on Windows, it's a much smaller set." msgstr "" -#: ../../library/sysconfig.rst:38 +#: ../../library/sysconfig.rst:35 msgid "" "With no arguments, return a dictionary of all configuration variables " "relevant for the current platform." msgstr "" -#: ../../library/sysconfig.rst:41 +#: ../../library/sysconfig.rst:38 msgid "" "With arguments, return a list of values that result from looking up each " "argument in the configuration variable dictionary." msgstr "" -#: ../../library/sysconfig.rst:44 +#: ../../library/sysconfig.rst:41 msgid "For each argument, if the value is not found, return ``None``." msgstr "" -#: ../../library/sysconfig.rst:49 +#: ../../library/sysconfig.rst:46 msgid "" "Return the value of a single variable *name*. Equivalent to " "``get_config_vars().get(name)``." msgstr "" -#: ../../library/sysconfig.rst:52 +#: ../../library/sysconfig.rst:49 msgid "If *name* is not found, return ``None``." msgstr "" -#: ../../library/sysconfig.rst:54 +#: ../../library/sysconfig.rst:51 msgid "Example of usage::" msgstr "用法範例: ::" -#: ../../library/sysconfig.rst:56 +#: ../../library/sysconfig.rst:53 msgid "" ">>> import sysconfig\n" ">>> sysconfig.get_config_var('Py_ENABLE_SHARED')\n" @@ -102,11 +102,11 @@ msgstr "" ">>> sysconfig.get_config_vars('AR', 'CXX')\n" "['ar', 'g++']" -#: ../../library/sysconfig.rst:68 +#: ../../library/sysconfig.rst:65 msgid "Installation paths" msgstr "" -#: ../../library/sysconfig.rst:70 +#: ../../library/sysconfig.rst:67 msgid "" "Python uses an installation scheme that differs depending on the platform " "and on the installation options. These schemes are stored in :mod:`!" @@ -115,121 +115,121 @@ msgid "" "copy files to." msgstr "" -#: ../../library/sysconfig.rst:75 +#: ../../library/sysconfig.rst:72 msgid "Python currently supports nine schemes:" msgstr "" -#: ../../library/sysconfig.rst:77 +#: ../../library/sysconfig.rst:74 msgid "" "*posix_prefix*: scheme for POSIX platforms like Linux or macOS. This is the " "default scheme used when Python or a component is installed." msgstr "" -#: ../../library/sysconfig.rst:79 +#: ../../library/sysconfig.rst:76 msgid "" "*posix_home*: scheme for POSIX platforms, when the *home* option is used. " "This scheme defines paths located under a specific home prefix." msgstr "" -#: ../../library/sysconfig.rst:81 +#: ../../library/sysconfig.rst:78 msgid "" "*posix_user*: scheme for POSIX platforms, when the *user* option is used. " "This scheme defines paths located under the user's home directory (:const:" "`site.USER_BASE`)." msgstr "" -#: ../../library/sysconfig.rst:84 +#: ../../library/sysconfig.rst:81 msgid "" "*posix_venv*: scheme for :mod:`Python virtual environments ` on POSIX " "platforms; by default it is the same as *posix_prefix*." msgstr "" -#: ../../library/sysconfig.rst:86 +#: ../../library/sysconfig.rst:83 msgid "" "*nt*: scheme for Windows. This is the default scheme used when Python or a " "component is installed." msgstr "" -#: ../../library/sysconfig.rst:88 +#: ../../library/sysconfig.rst:85 msgid "*nt_user*: scheme for Windows, when the *user* option is used." msgstr "" -#: ../../library/sysconfig.rst:89 +#: ../../library/sysconfig.rst:86 msgid "" "*nt_venv*: scheme for :mod:`Python virtual environments ` on Windows; " "by default it is the same as *nt*." msgstr "" -#: ../../library/sysconfig.rst:91 +#: ../../library/sysconfig.rst:88 msgid "" "*venv*: a scheme with values from either *posix_venv* or *nt_venv* depending " "on the platform Python runs on." msgstr "" -#: ../../library/sysconfig.rst:93 +#: ../../library/sysconfig.rst:90 msgid "*osx_framework_user*: scheme for macOS, when the *user* option is used." msgstr "" -#: ../../library/sysconfig.rst:95 +#: ../../library/sysconfig.rst:92 msgid "" "Each scheme is itself composed of a series of paths and each path has a " "unique identifier. Python currently uses eight paths:" msgstr "" -#: ../../library/sysconfig.rst:98 +#: ../../library/sysconfig.rst:95 msgid "" "*stdlib*: directory containing the standard Python library files that are " "not platform-specific." msgstr "" -#: ../../library/sysconfig.rst:100 +#: ../../library/sysconfig.rst:97 msgid "" "*platstdlib*: directory containing the standard Python library files that " "are platform-specific." msgstr "" -#: ../../library/sysconfig.rst:102 +#: ../../library/sysconfig.rst:99 msgid "*platlib*: directory for site-specific, platform-specific files." msgstr "" -#: ../../library/sysconfig.rst:103 +#: ../../library/sysconfig.rst:100 msgid "" "*purelib*: directory for site-specific, non-platform-specific files ('pure' " "Python)." msgstr "" -#: ../../library/sysconfig.rst:104 +#: ../../library/sysconfig.rst:101 msgid "" "*include*: directory for non-platform-specific header files for the Python C-" "API." msgstr "" -#: ../../library/sysconfig.rst:106 +#: ../../library/sysconfig.rst:103 msgid "" "*platinclude*: directory for platform-specific header files for the Python C-" "API." msgstr "" -#: ../../library/sysconfig.rst:108 +#: ../../library/sysconfig.rst:105 msgid "*scripts*: directory for script files." msgstr "" -#: ../../library/sysconfig.rst:109 +#: ../../library/sysconfig.rst:106 msgid "*data*: directory for data files." msgstr "" -#: ../../library/sysconfig.rst:115 +#: ../../library/sysconfig.rst:112 msgid "User scheme" msgstr "" -#: ../../library/sysconfig.rst:117 +#: ../../library/sysconfig.rst:114 msgid "" "This scheme is designed to be the most convenient solution for users that " "don't have write permission to the global site-packages directory or don't " "want to install into it." msgstr "" -#: ../../library/sysconfig.rst:121 +#: ../../library/sysconfig.rst:118 msgid "" "Files will be installed into subdirectories of :const:`site.USER_BASE` " "(written as :file:`{userbase}` hereafter). This scheme installs pure Python " @@ -237,122 +237,122 @@ msgid "" "`site.USER_SITE`)." msgstr "" -#: ../../library/sysconfig.rst:126 +#: ../../library/sysconfig.rst:123 msgid "``posix_user``" msgstr "``posix_user``" -#: ../../library/sysconfig.rst:129 ../../library/sysconfig.rst:144 -#: ../../library/sysconfig.rst:159 ../../library/sysconfig.rst:187 -#: ../../library/sysconfig.rst:229 ../../library/sysconfig.rst:245 +#: ../../library/sysconfig.rst:126 ../../library/sysconfig.rst:141 +#: ../../library/sysconfig.rst:156 ../../library/sysconfig.rst:184 +#: ../../library/sysconfig.rst:226 ../../library/sysconfig.rst:242 msgid "Path" msgstr "" -#: ../../library/sysconfig.rst:129 ../../library/sysconfig.rst:144 -#: ../../library/sysconfig.rst:159 ../../library/sysconfig.rst:187 -#: ../../library/sysconfig.rst:229 ../../library/sysconfig.rst:245 +#: ../../library/sysconfig.rst:126 ../../library/sysconfig.rst:141 +#: ../../library/sysconfig.rst:156 ../../library/sysconfig.rst:184 +#: ../../library/sysconfig.rst:226 ../../library/sysconfig.rst:242 msgid "Installation directory" msgstr "" -#: ../../library/sysconfig.rst:131 ../../library/sysconfig.rst:146 -#: ../../library/sysconfig.rst:161 ../../library/sysconfig.rst:189 -#: ../../library/sysconfig.rst:231 ../../library/sysconfig.rst:247 +#: ../../library/sysconfig.rst:128 ../../library/sysconfig.rst:143 +#: ../../library/sysconfig.rst:158 ../../library/sysconfig.rst:186 +#: ../../library/sysconfig.rst:228 ../../library/sysconfig.rst:244 msgid "*stdlib*" msgstr "*stdlib*" -#: ../../library/sysconfig.rst:131 ../../library/sysconfig.rst:132 +#: ../../library/sysconfig.rst:128 ../../library/sysconfig.rst:129 msgid ":file:`{userbase}/lib/python{X.Y}`" msgstr ":file:`{userbase}/lib/python{X.Y}`" -#: ../../library/sysconfig.rst:132 ../../library/sysconfig.rst:147 -#: ../../library/sysconfig.rst:162 ../../library/sysconfig.rst:190 -#: ../../library/sysconfig.rst:232 ../../library/sysconfig.rst:248 +#: ../../library/sysconfig.rst:129 ../../library/sysconfig.rst:144 +#: ../../library/sysconfig.rst:159 ../../library/sysconfig.rst:187 +#: ../../library/sysconfig.rst:229 ../../library/sysconfig.rst:245 msgid "*platstdlib*" msgstr "*platstdlib*" -#: ../../library/sysconfig.rst:133 ../../library/sysconfig.rst:148 -#: ../../library/sysconfig.rst:163 ../../library/sysconfig.rst:191 -#: ../../library/sysconfig.rst:233 ../../library/sysconfig.rst:249 +#: ../../library/sysconfig.rst:130 ../../library/sysconfig.rst:145 +#: ../../library/sysconfig.rst:160 ../../library/sysconfig.rst:188 +#: ../../library/sysconfig.rst:230 ../../library/sysconfig.rst:246 msgid "*platlib*" msgstr "*platlib*" -#: ../../library/sysconfig.rst:133 ../../library/sysconfig.rst:134 +#: ../../library/sysconfig.rst:130 ../../library/sysconfig.rst:131 msgid ":file:`{userbase}/lib/python{X.Y}/site-packages`" msgstr ":file:`{userbase}/lib/python{X.Y}/site-packages`" -#: ../../library/sysconfig.rst:134 ../../library/sysconfig.rst:149 -#: ../../library/sysconfig.rst:164 ../../library/sysconfig.rst:192 -#: ../../library/sysconfig.rst:234 ../../library/sysconfig.rst:250 +#: ../../library/sysconfig.rst:131 ../../library/sysconfig.rst:146 +#: ../../library/sysconfig.rst:161 ../../library/sysconfig.rst:189 +#: ../../library/sysconfig.rst:231 ../../library/sysconfig.rst:247 msgid "*purelib*" msgstr "*purelib*" -#: ../../library/sysconfig.rst:135 ../../library/sysconfig.rst:150 -#: ../../library/sysconfig.rst:165 ../../library/sysconfig.rst:193 -#: ../../library/sysconfig.rst:235 ../../library/sysconfig.rst:251 +#: ../../library/sysconfig.rst:132 ../../library/sysconfig.rst:147 +#: ../../library/sysconfig.rst:162 ../../library/sysconfig.rst:190 +#: ../../library/sysconfig.rst:232 ../../library/sysconfig.rst:248 msgid "*include*" msgstr "*include*" -#: ../../library/sysconfig.rst:135 ../../library/sysconfig.rst:165 +#: ../../library/sysconfig.rst:132 ../../library/sysconfig.rst:162 msgid ":file:`{userbase}/include/python{X.Y}`" msgstr ":file:`{userbase}/include/python{X.Y}`" -#: ../../library/sysconfig.rst:136 ../../library/sysconfig.rst:151 -#: ../../library/sysconfig.rst:166 ../../library/sysconfig.rst:195 -#: ../../library/sysconfig.rst:237 ../../library/sysconfig.rst:253 +#: ../../library/sysconfig.rst:133 ../../library/sysconfig.rst:148 +#: ../../library/sysconfig.rst:163 ../../library/sysconfig.rst:192 +#: ../../library/sysconfig.rst:234 ../../library/sysconfig.rst:250 msgid "*scripts*" msgstr "*scripts*" -#: ../../library/sysconfig.rst:136 ../../library/sysconfig.rst:166 +#: ../../library/sysconfig.rst:133 ../../library/sysconfig.rst:163 msgid ":file:`{userbase}/bin`" msgstr ":file:`{userbase}/bin`" -#: ../../library/sysconfig.rst:137 ../../library/sysconfig.rst:152 -#: ../../library/sysconfig.rst:167 ../../library/sysconfig.rst:196 -#: ../../library/sysconfig.rst:238 ../../library/sysconfig.rst:254 +#: ../../library/sysconfig.rst:134 ../../library/sysconfig.rst:149 +#: ../../library/sysconfig.rst:164 ../../library/sysconfig.rst:193 +#: ../../library/sysconfig.rst:235 ../../library/sysconfig.rst:251 msgid "*data*" msgstr "*data*" -#: ../../library/sysconfig.rst:137 ../../library/sysconfig.rst:152 -#: ../../library/sysconfig.rst:167 +#: ../../library/sysconfig.rst:134 ../../library/sysconfig.rst:149 +#: ../../library/sysconfig.rst:164 msgid ":file:`{userbase}`" msgstr ":file:`{userbase}`" -#: ../../library/sysconfig.rst:141 +#: ../../library/sysconfig.rst:138 msgid "``nt_user``" msgstr "``nt_user``" -#: ../../library/sysconfig.rst:146 ../../library/sysconfig.rst:147 +#: ../../library/sysconfig.rst:143 ../../library/sysconfig.rst:144 msgid ":file:`{userbase}\\\\Python{XY}`" msgstr ":file:`{userbase}\\\\Python{XY}`" -#: ../../library/sysconfig.rst:148 ../../library/sysconfig.rst:149 +#: ../../library/sysconfig.rst:145 ../../library/sysconfig.rst:146 msgid ":file:`{userbase}\\\\Python{XY}\\\\site-packages`" msgstr ":file:`{userbase}\\\\Python{XY}\\\\site-packages`" -#: ../../library/sysconfig.rst:150 +#: ../../library/sysconfig.rst:147 msgid ":file:`{userbase}\\\\Python{XY}\\\\Include`" msgstr ":file:`{userbase}\\\\Python{XY}\\\\Include`" -#: ../../library/sysconfig.rst:151 +#: ../../library/sysconfig.rst:148 msgid ":file:`{userbase}\\\\Python{XY}\\\\Scripts`" msgstr ":file:`{userbase}\\\\Python{XY}\\\\Scripts`" -#: ../../library/sysconfig.rst:156 +#: ../../library/sysconfig.rst:153 msgid "``osx_framework_user``" msgstr "``osx_framework_user``" -#: ../../library/sysconfig.rst:161 ../../library/sysconfig.rst:162 +#: ../../library/sysconfig.rst:158 ../../library/sysconfig.rst:159 msgid ":file:`{userbase}/lib/python`" msgstr ":file:`{userbase}/lib/python`" -#: ../../library/sysconfig.rst:163 ../../library/sysconfig.rst:164 +#: ../../library/sysconfig.rst:160 ../../library/sysconfig.rst:161 msgid ":file:`{userbase}/lib/python/site-packages`" msgstr ":file:`{userbase}/lib/python/site-packages`" -#: ../../library/sysconfig.rst:174 +#: ../../library/sysconfig.rst:171 msgid "Home scheme" msgstr "" -#: ../../library/sysconfig.rst:176 +#: ../../library/sysconfig.rst:173 msgid "" "The idea behind the \"home scheme\" is that you build and maintain a " "personal stash of Python modules. This scheme's name is derived from the " @@ -362,37 +362,37 @@ msgid "" "operating system they are installing for." msgstr "" -#: ../../library/sysconfig.rst:184 +#: ../../library/sysconfig.rst:181 msgid "``posix_home``" msgstr "``posix_home``" -#: ../../library/sysconfig.rst:189 ../../library/sysconfig.rst:190 -#: ../../library/sysconfig.rst:191 ../../library/sysconfig.rst:192 +#: ../../library/sysconfig.rst:186 ../../library/sysconfig.rst:187 +#: ../../library/sysconfig.rst:188 ../../library/sysconfig.rst:189 msgid ":file:`{home}/lib/python`" msgstr ":file:`{home}/lib/python`" -#: ../../library/sysconfig.rst:193 ../../library/sysconfig.rst:194 +#: ../../library/sysconfig.rst:190 ../../library/sysconfig.rst:191 msgid ":file:`{home}/include/python`" msgstr ":file:`{home}/include/python`" -#: ../../library/sysconfig.rst:194 ../../library/sysconfig.rst:236 -#: ../../library/sysconfig.rst:252 +#: ../../library/sysconfig.rst:191 ../../library/sysconfig.rst:233 +#: ../../library/sysconfig.rst:249 msgid "*platinclude*" msgstr "*platinclude*" -#: ../../library/sysconfig.rst:195 +#: ../../library/sysconfig.rst:192 msgid ":file:`{home}/bin`" msgstr ":file:`{home}/bin`" -#: ../../library/sysconfig.rst:196 +#: ../../library/sysconfig.rst:193 msgid ":file:`{home}`" msgstr ":file:`{home}`" -#: ../../library/sysconfig.rst:203 +#: ../../library/sysconfig.rst:200 msgid "Prefix scheme" msgstr "" -#: ../../library/sysconfig.rst:205 +#: ../../library/sysconfig.rst:202 msgid "" "The \"prefix scheme\" is useful when you wish to use one Python installation " "to perform the build/install (i.e., to run the setup script), but install " @@ -403,7 +403,7 @@ msgid "" "where the prefix scheme will be useful." msgstr "" -#: ../../library/sysconfig.rst:212 +#: ../../library/sysconfig.rst:209 msgid "" "First, consider that many Linux distributions put Python in :file:`/usr`, " "rather than the more traditional :file:`/usr/local`. This is entirely " @@ -413,7 +413,7 @@ msgid "" "rather than :file:`/usr/lib/python2.{X}`." msgstr "" -#: ../../library/sysconfig.rst:219 +#: ../../library/sysconfig.rst:216 msgid "" "Another possibility is a network filesystem where the name used to write to " "a remote directory is different from the name used to read it: for example, " @@ -423,104 +423,104 @@ msgid "" "{X}`." msgstr "" -#: ../../library/sysconfig.rst:226 +#: ../../library/sysconfig.rst:223 msgid "``posix_prefix``" msgstr "``posix_prefix``" -#: ../../library/sysconfig.rst:231 ../../library/sysconfig.rst:232 +#: ../../library/sysconfig.rst:228 ../../library/sysconfig.rst:229 msgid ":file:`{prefix}/lib/python{X.Y}`" msgstr ":file:`{prefix}/lib/python{X.Y}`" -#: ../../library/sysconfig.rst:233 ../../library/sysconfig.rst:234 +#: ../../library/sysconfig.rst:230 ../../library/sysconfig.rst:231 msgid ":file:`{prefix}/lib/python{X.Y}/site-packages`" msgstr ":file:`{prefix}/lib/python{X.Y}/site-packages`" -#: ../../library/sysconfig.rst:235 ../../library/sysconfig.rst:236 +#: ../../library/sysconfig.rst:232 ../../library/sysconfig.rst:233 msgid ":file:`{prefix}/include/python{X.Y}`" msgstr ":file:`{prefix}/include/python{X.Y}`" -#: ../../library/sysconfig.rst:237 +#: ../../library/sysconfig.rst:234 msgid ":file:`{prefix}/bin`" msgstr ":file:`{prefix}/bin`" -#: ../../library/sysconfig.rst:238 ../../library/sysconfig.rst:254 +#: ../../library/sysconfig.rst:235 ../../library/sysconfig.rst:251 msgid ":file:`{prefix}`" msgstr ":file:`{prefix}`" -#: ../../library/sysconfig.rst:242 +#: ../../library/sysconfig.rst:239 msgid "``nt``" msgstr "``nt``" -#: ../../library/sysconfig.rst:247 ../../library/sysconfig.rst:248 +#: ../../library/sysconfig.rst:244 ../../library/sysconfig.rst:245 msgid ":file:`{prefix}\\\\Lib`" msgstr ":file:`{prefix}\\\\Lib`" -#: ../../library/sysconfig.rst:249 ../../library/sysconfig.rst:250 +#: ../../library/sysconfig.rst:246 ../../library/sysconfig.rst:247 msgid ":file:`{prefix}\\\\Lib\\\\site-packages`" msgstr ":file:`{prefix}\\\\Lib\\\\site-packages`" -#: ../../library/sysconfig.rst:251 ../../library/sysconfig.rst:252 +#: ../../library/sysconfig.rst:248 ../../library/sysconfig.rst:249 msgid ":file:`{prefix}\\\\Include`" msgstr ":file:`{prefix}\\\\Include`" -#: ../../library/sysconfig.rst:253 +#: ../../library/sysconfig.rst:250 msgid ":file:`{prefix}\\\\Scripts`" msgstr ":file:`{prefix}\\\\Scripts`" -#: ../../library/sysconfig.rst:259 +#: ../../library/sysconfig.rst:256 msgid "Installation path functions" msgstr "安裝路徑函式" -#: ../../library/sysconfig.rst:261 +#: ../../library/sysconfig.rst:258 msgid "" ":mod:`!sysconfig` provides some functions to determine these installation " "paths." msgstr "" -#: ../../library/sysconfig.rst:265 +#: ../../library/sysconfig.rst:262 msgid "" "Return a tuple containing all schemes currently supported in :mod:`!" "sysconfig`." msgstr "" -#: ../../library/sysconfig.rst:271 +#: ../../library/sysconfig.rst:268 msgid "Return the default scheme name for the current platform." msgstr "" -#: ../../library/sysconfig.rst:273 +#: ../../library/sysconfig.rst:270 msgid "" "This function was previously named ``_get_default_scheme()`` and considered " "an implementation detail." msgstr "" -#: ../../library/sysconfig.rst:277 +#: ../../library/sysconfig.rst:274 msgid "" "When Python runs from a virtual environment, the *venv* scheme is returned." msgstr "" -#: ../../library/sysconfig.rst:283 +#: ../../library/sysconfig.rst:280 msgid "" "Return a preferred scheme name for an installation layout specified by *key*." msgstr "" -#: ../../library/sysconfig.rst:285 +#: ../../library/sysconfig.rst:282 msgid "*key* must be either ``\"prefix\"``, ``\"home\"``, or ``\"user\"``." msgstr "" -#: ../../library/sysconfig.rst:287 +#: ../../library/sysconfig.rst:284 msgid "" "The return value is a scheme name listed in :func:`get_scheme_names`. It can " "be passed to :mod:`!sysconfig` functions that take a *scheme* argument, such " "as :func:`get_paths`." msgstr "" -#: ../../library/sysconfig.rst:293 +#: ../../library/sysconfig.rst:290 msgid "" "When Python runs from a virtual environment and ``key=\"prefix\"``, the " "*venv* scheme is returned." msgstr "" -#: ../../library/sysconfig.rst:300 +#: ../../library/sysconfig.rst:297 msgid "" "Return a dict containing preferred scheme names on the current platform. " "Python implementers and redistributors may add their preferred schemes to " @@ -530,99 +530,99 @@ msgid "" "mix with those by the other." msgstr "" -#: ../../library/sysconfig.rst:307 +#: ../../library/sysconfig.rst:304 msgid "" "End users should not use this function, but :func:`get_default_scheme` and :" "func:`get_preferred_scheme` instead." msgstr "" -#: ../../library/sysconfig.rst:315 +#: ../../library/sysconfig.rst:312 msgid "" "Return a tuple containing all path names currently supported in :mod:`!" "sysconfig`." msgstr "" -#: ../../library/sysconfig.rst:321 +#: ../../library/sysconfig.rst:318 msgid "" "Return an installation path corresponding to the path *name*, from the " "install scheme named *scheme*." msgstr "" -#: ../../library/sysconfig.rst:324 +#: ../../library/sysconfig.rst:321 msgid "" "*name* has to be a value from the list returned by :func:`get_path_names`." msgstr "" -#: ../../library/sysconfig.rst:326 +#: ../../library/sysconfig.rst:323 msgid "" ":mod:`!sysconfig` stores installation paths corresponding to each path name, " "for each platform, with variables to be expanded. For instance the *stdlib* " "path for the *nt* scheme is: ``{base}/Lib``." msgstr "" -#: ../../library/sysconfig.rst:330 +#: ../../library/sysconfig.rst:327 msgid "" ":func:`get_path` will use the variables returned by :func:`get_config_vars` " "to expand the path. All variables have default values for each platform so " "one may call this function and get the default value." msgstr "" -#: ../../library/sysconfig.rst:334 +#: ../../library/sysconfig.rst:331 msgid "" "If *scheme* is provided, it must be a value from the list returned by :func:" "`get_scheme_names`. Otherwise, the default scheme for the current platform " "is used." msgstr "" -#: ../../library/sysconfig.rst:338 +#: ../../library/sysconfig.rst:335 msgid "" "If *vars* is provided, it must be a dictionary of variables that will update " "the dictionary returned by :func:`get_config_vars`." msgstr "" -#: ../../library/sysconfig.rst:341 +#: ../../library/sysconfig.rst:338 msgid "" "If *expand* is set to ``False``, the path will not be expanded using the " "variables." msgstr "" -#: ../../library/sysconfig.rst:344 +#: ../../library/sysconfig.rst:341 msgid "If *name* is not found, raise a :exc:`KeyError`." msgstr "如果找不到 *name*,則引發 :exc:`KeyError`。" -#: ../../library/sysconfig.rst:349 +#: ../../library/sysconfig.rst:346 msgid "" "Return a dictionary containing all installation paths corresponding to an " "installation scheme. See :func:`get_path` for more information." msgstr "" -#: ../../library/sysconfig.rst:352 +#: ../../library/sysconfig.rst:349 msgid "" "If *scheme* is not provided, will use the default scheme for the current " "platform." msgstr "" -#: ../../library/sysconfig.rst:355 +#: ../../library/sysconfig.rst:352 msgid "" "If *vars* is provided, it must be a dictionary of variables that will update " "the dictionary used to expand the paths." msgstr "" -#: ../../library/sysconfig.rst:358 +#: ../../library/sysconfig.rst:355 msgid "If *expand* is set to false, the paths will not be expanded." msgstr "" -#: ../../library/sysconfig.rst:360 +#: ../../library/sysconfig.rst:357 msgid "" "If *scheme* is not an existing scheme, :func:`get_paths` will raise a :exc:" "`KeyError`." msgstr "" -#: ../../library/sysconfig.rst:365 +#: ../../library/sysconfig.rst:362 msgid "Other functions" msgstr "其他函式" -#: ../../library/sysconfig.rst:369 +#: ../../library/sysconfig.rst:366 msgid "" "Return the ``MAJOR.MINOR`` Python version number as a string. Similar to " "``'%d.%d' % sys.version_info[:2]``." @@ -630,11 +630,11 @@ msgstr "" "回傳 ``MAJOR.MINOR`` Python 版本號碼字串。類似於 ``'%d.%d' % sys." "version_info[:2]``。" -#: ../../library/sysconfig.rst:375 +#: ../../library/sysconfig.rst:372 msgid "Return a string that identifies the current platform." msgstr "" -#: ../../library/sysconfig.rst:377 +#: ../../library/sysconfig.rst:374 msgid "" "This is used mainly to distinguish platform-specific build directories and " "platform-specific built distributions. Typically includes the OS name and " @@ -643,10 +643,22 @@ msgid "" "version isn't particularly important." msgstr "" -#: ../../library/sysconfig.rst:383 +#: ../../library/sysconfig.rst:380 msgid "Examples of returned values:" msgstr "" +#: ../../library/sysconfig.rst:382 ../../library/sysconfig.rst:394 +msgid "linux-x86_64" +msgstr "linux-x86_64" + +#: ../../library/sysconfig.rst:383 +msgid "linux-aarch64" +msgstr "linux-aarch64" + +#: ../../library/sysconfig.rst:384 +msgid "solaris-2.6-sun4u" +msgstr "solaris-2.6-sun4u" + #: ../../library/sysconfig.rst:386 msgid "Windows:" msgstr "Windows:" @@ -667,10 +679,6 @@ msgstr "" msgid "POSIX based OS:" msgstr "" -#: ../../library/sysconfig.rst:394 -msgid "linux-x86_64" -msgstr "linux-x86_64" - #: ../../library/sysconfig.rst:395 msgid "macosx-15.5-arm64" msgstr "macosx-15.5-arm64" @@ -780,16 +788,13 @@ msgid "" "`get_config_vars`." msgstr "" -#: ../../library/sysconfig.rst:14 +#: ../../library/sysconfig.rst:11 msgid "configuration information" msgstr "configuration information(設定資訊)" #~ msgid "linux-alpha (?)" #~ msgstr "linux-alpha (?)" -#~ msgid "solaris-2.6-sun4u" -#~ msgstr "solaris-2.6-sun4u" - #~ msgid "macosx-10.6-ppc" #~ msgstr "macosx-10.6-ppc" diff --git a/library/tabnanny.po b/library/tabnanny.po index 2fda3195607..367b53e3330 100644 --- a/library/tabnanny.po +++ b/library/tabnanny.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-11-17 21:19+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!tabnanny` --- Detection of ambiguous indentation" msgstr ":mod:`!tabnanny` --- 偵測不良縮排" -#: ../../library/tabnanny.rst:13 +#: ../../library/tabnanny.rst:8 msgid "**Source code:** :source:`Lib/tabnanny.py`" msgstr "**原始碼:**\\ :source:`Lib/tabnanny.py`" -#: ../../library/tabnanny.rst:17 +#: ../../library/tabnanny.rst:12 msgid "" "For the time being this module is intended to be called as a script. However " "it is possible to import it into an IDE and use the function :func:`check` " @@ -37,7 +37,7 @@ msgstr "" "目前現況是此模組打算以腳本方式被呼叫使用,但也可以將其引入於 IDE 中並使用下方" "敘述的 :func:`check` 函式。" -#: ../../library/tabnanny.rst:23 +#: ../../library/tabnanny.rst:18 msgid "" "The API provided by this module is likely to change in future releases; such " "changes may not be backward compatible." @@ -45,7 +45,7 @@ msgstr "" "此模組所提供的 API 很有可能會在未來的發佈版本中有所變更,且有可能不具有向後相" "容性。" -#: ../../library/tabnanny.rst:29 +#: ../../library/tabnanny.rst:24 msgid "" "If *file_or_dir* is a directory and not a symbolic link, then recursively " "descend the directory tree named by *file_or_dir*, checking all :file:`.py` " @@ -58,7 +58,7 @@ msgstr "" "如果 *file_or_dir* 是個一般 Python 原始檔案,則為其檢查空格相關問題。診斷訊息" "會以 :func:`print` 函式輸出至標準輸出 (standard output) 當中。" -#: ../../library/tabnanny.rst:38 +#: ../../library/tabnanny.rst:33 msgid "" "Flag indicating whether to print verbose messages. This is incremented by " "the ``-v`` option if called as a script." @@ -66,7 +66,7 @@ msgstr "" "標示是否要印出詳細訊息 (verbose message) 的旗標,若是以腳本方式呼叫的話則可以" "用 ``-v`` 選項來增加。" -#: ../../library/tabnanny.rst:44 +#: ../../library/tabnanny.rst:39 msgid "" "Flag indicating whether to print only the filenames of files containing " "whitespace related problems. This is set to true by the ``-q`` option if " @@ -75,7 +75,7 @@ msgstr "" "標示是否要只印出那些有空白相關問題檔案之檔名的旗標,若是以腳本方式呼叫的話則" "可以用 ``-q`` 選項來設為真值。" -#: ../../library/tabnanny.rst:51 +#: ../../library/tabnanny.rst:46 msgid "" "Raised by :func:`process_tokens` if detecting an ambiguous indent. Captured " "and handled in :func:`check`." @@ -83,16 +83,16 @@ msgstr "" "當偵測到不良縮排時,此例外會被 :func:`process_tokens` 引發,會在 :func:" "`check` 中捕獲與處理。" -#: ../../library/tabnanny.rst:57 +#: ../../library/tabnanny.rst:52 msgid "" "This function is used by :func:`check` to process tokens generated by the :" "mod:`tokenize` module." msgstr "此函式被 :func:`check` 用來處理由 :mod:`tokenize` 產生的標記 (token)。" -#: ../../library/tabnanny.rst:66 +#: ../../library/tabnanny.rst:61 msgid "Module :mod:`tokenize`" msgstr ":mod:`tokenize` 模組" -#: ../../library/tabnanny.rst:67 +#: ../../library/tabnanny.rst:62 msgid "Lexical scanner for Python source code." msgstr "Python 原始程式碼的詞彙掃描器 (lexical scanner)。" diff --git a/library/tarfile.po b/library/tarfile.po index bb24f9047e7..f8f3e058332 100644 --- a/library/tarfile.po +++ b/library/tarfile.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-20 00:10+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:12+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!tarfile` --- Read and write tar archive files" msgstr ":mod:`!tarfile` --- 讀取與寫入 tar 封存檔案" -#: ../../library/tarfile.rst:10 +#: ../../library/tarfile.rst:7 msgid "**Source code:** :source:`Lib/tarfile.py`" msgstr "**原始碼:**\\ :source:`Lib/tarfile.py`" -#: ../../library/tarfile.rst:14 +#: ../../library/tarfile.rst:11 msgid "" "The :mod:`!tarfile` module makes it possible to read and write tar archives, " "including those using gzip, bz2 and lzma compression. Use the :mod:`zipfile` " @@ -38,11 +38,11 @@ msgstr "" "壓縮的檔案。使用 :mod:`zipfile` 模組來讀取或寫入 :file:`.zip` 檔案,或使用 :" "ref:`shutil ` 中的更高階函式。" -#: ../../library/tarfile.rst:19 +#: ../../library/tarfile.rst:16 msgid "Some facts and figures:" msgstr "一些事實和數據:" -#: ../../library/tarfile.rst:21 +#: ../../library/tarfile.rst:18 msgid "" "reads and writes :mod:`gzip`, :mod:`bz2`, :mod:`compression.zstd`, and :mod:" "`lzma` compressed archives if the respective modules are available." @@ -50,7 +50,7 @@ msgstr "" "若相對應的模組可用,則可讀取與寫入 :mod:`gzip`、:mod:`bz2`、:mod:" "`compression.zstd` 和 :mod:`lzma` 壓縮的封存檔。" -#: ../../library/tarfile.rst:27 +#: ../../library/tarfile.rst:24 msgid "" "If any of these :term:`optional modules ` are missing from " "your copy of CPython, look for documentation from your distributor (that is, " @@ -61,11 +61,11 @@ msgstr "" "`,請查閱你的發行者(即提供 Python 給你的人)的文件。如果你" "就是發行者,請參閱 :ref:`optional-module-requirements`。" -#: ../../library/tarfile.rst:32 +#: ../../library/tarfile.rst:29 msgid "read/write support for the POSIX.1-1988 (ustar) format." msgstr "支援 POSIX.1-1988 (ustar) 格式的讀取與寫入。" -#: ../../library/tarfile.rst:34 +#: ../../library/tarfile.rst:31 msgid "" "read/write support for the GNU tar format including *longname* and " "*longlink* extensions, read-only support for all variants of the *sparse* " @@ -74,11 +74,11 @@ msgstr "" "支援 GNU tar 格式的讀取與寫入,包括 *longname* 和 *longlink* 擴充功能,以及所" "有 *sparse* 擴充功能變體的唯讀支援,包括還原稀疏檔案 (sparse files)。" -#: ../../library/tarfile.rst:38 +#: ../../library/tarfile.rst:35 msgid "read/write support for the POSIX.1-2001 (pax) format." msgstr "支援 POSIX.1-2001 (pax) 格式的讀取與寫入。" -#: ../../library/tarfile.rst:40 +#: ../../library/tarfile.rst:37 msgid "" "handles directories, regular files, hardlinks, symbolic links, fifos, " "character devices and block devices and is able to acquire and restore file " @@ -88,11 +88,11 @@ msgstr "" "元裝置 (character devices) 和區塊裝置 (block devices),並能夠取得與還原檔案資" "訊,如時間戳記、存取權限和擁有者。" -#: ../../library/tarfile.rst:44 +#: ../../library/tarfile.rst:41 msgid "Added support for :mod:`lzma` compression." msgstr "新增對 :mod:`lzma` 壓縮的支援。" -#: ../../library/tarfile.rst:47 +#: ../../library/tarfile.rst:44 msgid "" "Archives are extracted using a :ref:`filter `, " "which makes it possible to either limit surprising/dangerous features, or to " @@ -102,7 +102,7 @@ msgstr "" "可以用它來限制一些意外或危險的功能,或是明確表示這些功能是你預期的,而且封存" "檔是完全可信任的。" -#: ../../library/tarfile.rst:52 +#: ../../library/tarfile.rst:49 msgid "" "Set the default extraction filter to :func:`data `, which " "disallows some dangerous features such as links to absolute paths or paths " @@ -113,11 +113,11 @@ msgstr "" "如指向絕對路徑或目的地之外路徑的連結。在此之前,篩選器策略等同於 :func:" "`fully_trusted `。" -#: ../../library/tarfile.rst:60 +#: ../../library/tarfile.rst:57 msgid "Added support for Zstandard compression using :mod:`compression.zstd`." msgstr "新增對 Zstandard 壓縮的支援(使用 :mod:`compression.zstd`)。" -#: ../../library/tarfile.rst:64 +#: ../../library/tarfile.rst:61 msgid "" "Return a :class:`TarFile` object for the pathname *name*. For detailed " "information on :class:`TarFile` objects and the keyword arguments that are " @@ -126,7 +126,7 @@ msgstr "" "回傳路徑名稱 *name* 的 :class:`TarFile` 物件。關於 :class:`TarFile` 物件與允" "許的關鍵字引數的詳細資訊,請參閱 :ref:`tarfile-objects`。" -#: ../../library/tarfile.rst:68 +#: ../../library/tarfile.rst:65 msgid "" "*mode* has to be a string of the form ``'filemode[:compression]'``, it " "defaults to ``'r'``. Here is a full list of mode combinations:" @@ -134,67 +134,67 @@ msgstr "" "*mode* 必須是 ``'filemode[:compression]'`` 形式的字串,預設為 ``'r'``。以下是" "所有可能的模式組合:" -#: ../../library/tarfile.rst:72 +#: ../../library/tarfile.rst:69 msgid "mode" msgstr "模式" -#: ../../library/tarfile.rst:72 +#: ../../library/tarfile.rst:69 msgid "action" msgstr "操作" -#: ../../library/tarfile.rst:74 +#: ../../library/tarfile.rst:71 msgid "``'r'`` or ``'r:*'``" msgstr "``'r'`` 或 ``'r:*'``" -#: ../../library/tarfile.rst:74 +#: ../../library/tarfile.rst:71 msgid "Open for reading with transparent compression (recommended)." msgstr "開啟以讀取,自動偵測壓縮格式(建議使用)。" -#: ../../library/tarfile.rst:77 +#: ../../library/tarfile.rst:74 msgid "``'r:'``" msgstr "``'r:'``" -#: ../../library/tarfile.rst:77 +#: ../../library/tarfile.rst:74 msgid "Open for reading exclusively without compression." msgstr "開啟以讀取未壓縮的檔案。" -#: ../../library/tarfile.rst:80 +#: ../../library/tarfile.rst:77 msgid "``'r:gz'``" msgstr "``'r:gz'``" -#: ../../library/tarfile.rst:80 +#: ../../library/tarfile.rst:77 msgid "Open for reading with gzip compression." msgstr "開啟以讀取 gzip 壓縮的檔案。" -#: ../../library/tarfile.rst:82 +#: ../../library/tarfile.rst:79 msgid "``'r:bz2'``" msgstr "``'r:bz2'``" -#: ../../library/tarfile.rst:82 +#: ../../library/tarfile.rst:79 msgid "Open for reading with bzip2 compression." msgstr "開啟以讀取 bzip2 壓縮的檔案。" -#: ../../library/tarfile.rst:84 +#: ../../library/tarfile.rst:81 msgid "``'r:xz'``" msgstr "``'r:xz'``" -#: ../../library/tarfile.rst:84 +#: ../../library/tarfile.rst:81 msgid "Open for reading with lzma compression." msgstr "開啟以讀取 lzma 壓縮的檔案。" -#: ../../library/tarfile.rst:86 +#: ../../library/tarfile.rst:83 msgid "``'r:zst'``" msgstr "``'r:zst'``" -#: ../../library/tarfile.rst:86 +#: ../../library/tarfile.rst:83 msgid "Open for reading with Zstandard compression." msgstr "開啟以讀取 Zstandard 壓縮的檔案。" -#: ../../library/tarfile.rst:88 +#: ../../library/tarfile.rst:85 msgid "``'x'`` or ``'x:'``" msgstr "``'x'`` 或 ``'x:'``" -#: ../../library/tarfile.rst:88 +#: ../../library/tarfile.rst:85 msgid "" "Create a tarfile exclusively without compression. Raise a :exc:" "`FileExistsError` exception if it already exists." @@ -202,11 +202,11 @@ msgstr "" "建立一個不壓縮的 tarfile(獨佔模式)。如果檔案已存在,則引發 :exc:" "`FileExistsError` 例外。" -#: ../../library/tarfile.rst:93 +#: ../../library/tarfile.rst:90 msgid "``'x:gz'``" msgstr "``'x:gz'``" -#: ../../library/tarfile.rst:93 +#: ../../library/tarfile.rst:90 msgid "" "Create a tarfile with gzip compression. Raise a :exc:`FileExistsError` " "exception if it already exists." @@ -214,11 +214,11 @@ msgstr "" "建立一個使用 gzip 壓縮的 tar 檔案。如果檔案已存在則引發 :exc:" "`FileExistsError` 例外。" -#: ../../library/tarfile.rst:97 +#: ../../library/tarfile.rst:94 msgid "``'x:bz2'``" msgstr "``'x:bz2'``" -#: ../../library/tarfile.rst:97 +#: ../../library/tarfile.rst:94 msgid "" "Create a tarfile with bzip2 compression. Raise a :exc:`FileExistsError` " "exception if it already exists." @@ -226,11 +226,11 @@ msgstr "" "建立一個使用 bzip2 壓縮的 tar 檔案。如果檔案已存在,則引發 :exc:" "`FileExistsError` 例外。" -#: ../../library/tarfile.rst:101 +#: ../../library/tarfile.rst:98 msgid "``'x:xz'``" msgstr "``'x:xz'``" -#: ../../library/tarfile.rst:101 +#: ../../library/tarfile.rst:98 msgid "" "Create a tarfile with lzma compression. Raise a :exc:`FileExistsError` " "exception if it already exists." @@ -238,11 +238,11 @@ msgstr "" "建立一個使用 lzma 壓縮的 tar 檔案。如果檔案已存在,則引發 :exc:" "`FileExistsError` 例外。" -#: ../../library/tarfile.rst:105 +#: ../../library/tarfile.rst:102 msgid "``'x:zst'``" msgstr "``'x:zst'``" -#: ../../library/tarfile.rst:105 +#: ../../library/tarfile.rst:102 msgid "" "Create a tarfile with Zstandard compression. Raise a :exc:`FileExistsError` " "exception if it already exists." @@ -250,57 +250,57 @@ msgstr "" "建立一個使用 Zstandard 壓縮的 tar 檔案。如果檔案已存在,則引發 :exc:" "`FileExistsError` 例外。" -#: ../../library/tarfile.rst:109 +#: ../../library/tarfile.rst:106 msgid "``'a'`` or ``'a:'``" msgstr "``'a'`` 或 ``'a:'``" -#: ../../library/tarfile.rst:109 +#: ../../library/tarfile.rst:106 msgid "" "Open for appending with no compression. The file is created if it does not " "exist." msgstr "開啟以附加內容且不使用壓縮。如果檔案不存在則建立它。" -#: ../../library/tarfile.rst:112 +#: ../../library/tarfile.rst:109 msgid "``'w'`` or ``'w:'``" msgstr "``'w'`` 或 ``'w:'``" -#: ../../library/tarfile.rst:112 +#: ../../library/tarfile.rst:109 msgid "Open for uncompressed writing." msgstr "開啟以寫入未壓縮的內容。" -#: ../../library/tarfile.rst:115 +#: ../../library/tarfile.rst:112 msgid "``'w:gz'``" msgstr "``'w:gz'``" -#: ../../library/tarfile.rst:115 +#: ../../library/tarfile.rst:112 msgid "Open for gzip compressed writing." msgstr "開啟以進行 gzip 壓縮寫入。" -#: ../../library/tarfile.rst:117 +#: ../../library/tarfile.rst:114 msgid "``'w:bz2'``" msgstr "``'w:bz2'``" -#: ../../library/tarfile.rst:117 +#: ../../library/tarfile.rst:114 msgid "Open for bzip2 compressed writing." msgstr "開啟以進行 bzip2 壓縮寫入。" -#: ../../library/tarfile.rst:119 +#: ../../library/tarfile.rst:116 msgid "``'w:xz'``" msgstr "``'w:xz'``" -#: ../../library/tarfile.rst:119 +#: ../../library/tarfile.rst:116 msgid "Open for lzma compressed writing." msgstr "開啟以進行 lzma 壓縮寫入。" -#: ../../library/tarfile.rst:121 +#: ../../library/tarfile.rst:118 msgid "``'w:zst'``" msgstr "``'w:zst'``" -#: ../../library/tarfile.rst:121 +#: ../../library/tarfile.rst:118 msgid "Open for Zstandard compressed writing." msgstr "開啟以進行 Zstandard 壓縮寫入。" -#: ../../library/tarfile.rst:124 +#: ../../library/tarfile.rst:121 msgid "" "Note that ``'a:gz'``, ``'a:bz2'`` or ``'a:xz'`` is not possible. If *mode* " "is not suitable to open a certain (compressed) file for reading, :exc:" @@ -311,7 +311,7 @@ msgstr "" "啟特定(壓縮)檔案以進行讀取,則會引發 :exc:`ReadError`。使用 *mode* ``'r'`` " "可避免此問題。如果不支援某個壓縮方法,則會引發 :exc:`CompressionError`。" -#: ../../library/tarfile.rst:129 +#: ../../library/tarfile.rst:126 msgid "" "If *fileobj* is specified, it is used as an alternative to a :term:`file " "object` opened in binary mode for *name*. It is supposed to be at position 0." @@ -319,17 +319,17 @@ msgstr "" "如果指定了 *fileobj*,則它會被用作 *name* 以二進位模式開啟的\\ :term:`檔案物" "件 ` 的替代方案。它應該位於位置 0。" -#: ../../library/tarfile.rst:132 +#: ../../library/tarfile.rst:129 msgid "" "For modes ``'w:gz'``, ``'x:gz'``, ``'w|gz'``, ``'w:bz2'``, ``'x:bz2'``, ``'w|" "bz2'``, :func:`tarfile.open` accepts the keyword argument *compresslevel* " -"(default ``9``) to specify the compression level of the file." +"(default ``6``) to specify the compression level of the file." msgstr "" "對於模式 ``'w:gz'``、``'x:gz'``、``'w|gz'``、``'w:bz2'``、``'x:bz2'``、``'w|" "bz2'``,:func:`tarfile.open` 接受關鍵字引數 *compresslevel*\\ (預設為 " -"``9``)來指定檔案的壓縮等級。" +"``6``)來指定檔案的壓縮等級。" -#: ../../library/tarfile.rst:136 +#: ../../library/tarfile.rst:133 msgid "" "For modes ``'w:xz'``, ``'x:xz'`` and ``'w|xz'``, :func:`tarfile.open` " "accepts the keyword argument *preset* to specify the compression level of " @@ -338,7 +338,7 @@ msgstr "" "對於模式 ``'w:xz'``、``'x:xz'`` 和 ``'w|xz'``,:func:`tarfile.open` 接受關鍵" "字引數 *preset* 來指定檔案的壓縮等級。" -#: ../../library/tarfile.rst:139 +#: ../../library/tarfile.rst:136 msgid "" "For modes ``'w:zst'``, ``'x:zst'`` and ``'w|zst'``, :func:`tarfile.open` " "accepts the keyword argument *level* to specify the compression level of the " @@ -354,7 +354,16 @@ msgstr "" "參數。可以傳遞關鍵字引數 *zstd_dict* 以提供 :class:`~compression.zstd." "ZstdDict`,這是一個用於改善較小資料量壓縮效果的 Zstandard 字典。" -#: ../../library/tarfile.rst:148 +#: ../../library/tarfile.rst:145 +msgid "" +"For modes ``'w:gz'`` and ``'w|gz'``, :func:`tarfile.open` accepts the " +"keyword argument *mtime* to create a gzip archive header with that mtime. By " +"default, the mtime is set to the time of creation of the archive. Use " +"*mtime* ``0`` to generate a compressed stream that does not depend on " +"creation time, for reproducible output." +msgstr "" + +#: ../../library/tarfile.rst:151 msgid "" "For special purposes, there is a second format for *mode*: ``'filemode|" "[compression]'``. :func:`tarfile.open` will return a :class:`TarFile` " @@ -376,120 +385,127 @@ msgstr "" "結合使用。但是,這樣的 :class:`TarFile` 物件受到限制,因為它不允許隨機存取," "請參閱 :ref:`tar-examples`。目前可能的模式:" -#: ../../library/tarfile.rst:162 +#: ../../library/tarfile.rst:165 msgid "Mode" msgstr "模式" -#: ../../library/tarfile.rst:162 +#: ../../library/tarfile.rst:165 msgid "Action" msgstr "操作" -#: ../../library/tarfile.rst:164 +#: ../../library/tarfile.rst:167 msgid "``'r|*'``" msgstr "``'r|*'``" -#: ../../library/tarfile.rst:164 +#: ../../library/tarfile.rst:167 msgid "Open a *stream* of tar blocks for reading with transparent compression." msgstr "開啟以讀取 tar 區塊的\\ *串流*,自動偵測壓縮格式。" -#: ../../library/tarfile.rst:167 +#: ../../library/tarfile.rst:170 msgid "``'r|'``" msgstr "``'r|'``" -#: ../../library/tarfile.rst:167 +#: ../../library/tarfile.rst:170 msgid "Open a *stream* of uncompressed tar blocks for reading." msgstr "開啟以讀取未壓縮的 tar 區塊\\ *串流*。" -#: ../../library/tarfile.rst:170 +#: ../../library/tarfile.rst:173 msgid "``'r|gz'``" msgstr "``'r|gz'``" -#: ../../library/tarfile.rst:170 +#: ../../library/tarfile.rst:173 msgid "Open a gzip compressed *stream* for reading." msgstr "開啟以讀取 gzip 壓縮的\\ *串流*。" -#: ../../library/tarfile.rst:173 +#: ../../library/tarfile.rst:176 msgid "``'r|bz2'``" msgstr "``'r|bz2'``" -#: ../../library/tarfile.rst:173 +#: ../../library/tarfile.rst:176 msgid "Open a bzip2 compressed *stream* for reading." msgstr "開啟以讀取 bzip2 壓縮的\\ *串流*。" -#: ../../library/tarfile.rst:176 +#: ../../library/tarfile.rst:179 msgid "``'r|xz'``" msgstr "``'r|xz'``" -#: ../../library/tarfile.rst:176 +#: ../../library/tarfile.rst:179 msgid "Open an lzma compressed *stream* for reading." msgstr "開啟以讀取 lzma 壓縮的\\ *串流*。" -#: ../../library/tarfile.rst:179 +#: ../../library/tarfile.rst:182 msgid "``'r|zst'``" msgstr "``'r|zst'``" -#: ../../library/tarfile.rst:179 +#: ../../library/tarfile.rst:182 msgid "Open a Zstandard compressed *stream* for reading." msgstr "開啟以讀取 Zstandard 壓縮的\\ *串流*。" -#: ../../library/tarfile.rst:182 +#: ../../library/tarfile.rst:185 msgid "``'w|'``" msgstr "``'w|'``" -#: ../../library/tarfile.rst:182 +#: ../../library/tarfile.rst:185 msgid "Open an uncompressed *stream* for writing." msgstr "開啟以寫入未壓縮的\\ *串流*。" -#: ../../library/tarfile.rst:184 +#: ../../library/tarfile.rst:187 msgid "``'w|gz'``" msgstr "``'w|gz'``" -#: ../../library/tarfile.rst:184 +#: ../../library/tarfile.rst:187 msgid "Open a gzip compressed *stream* for writing." msgstr "開啟以寫入 gzip 壓縮的\\ *串流*。" -#: ../../library/tarfile.rst:187 +#: ../../library/tarfile.rst:190 msgid "``'w|bz2'``" msgstr "``'w|bz2'``" -#: ../../library/tarfile.rst:187 +#: ../../library/tarfile.rst:190 msgid "Open a bzip2 compressed *stream* for writing." msgstr "開啟以寫入 bzip2 壓縮的\\ *串流*。" -#: ../../library/tarfile.rst:190 +#: ../../library/tarfile.rst:193 msgid "``'w|xz'``" msgstr "``'w|xz'``" -#: ../../library/tarfile.rst:190 +#: ../../library/tarfile.rst:193 msgid "Open an lzma compressed *stream* for writing." msgstr "開啟以寫入 lzma 壓縮的\\ *串流*。" -#: ../../library/tarfile.rst:193 +#: ../../library/tarfile.rst:196 msgid "``'w|zst'``" msgstr "``'w|zst'``" -#: ../../library/tarfile.rst:193 +#: ../../library/tarfile.rst:196 msgid "Open a Zstandard compressed *stream* for writing." msgstr "開啟以寫入 Zstandard 壓縮的\\ *串流*。" -#: ../../library/tarfile.rst:197 ../../library/tarfile.rst:476 +#: ../../library/tarfile.rst:200 ../../library/tarfile.rst:483 msgid "The ``'x'`` (exclusive creation) mode was added." msgstr "新增了 ``'x'``\\ (獨佔建立)模式。" -#: ../../library/tarfile.rst:200 ../../library/tarfile.rst:479 -#: ../../library/tarfile.rst:727 +#: ../../library/tarfile.rst:203 ../../library/tarfile.rst:486 +#: ../../library/tarfile.rst:734 msgid "The *name* parameter accepts a :term:`path-like object`." msgstr "*name* 參數接受\\ :term:`類路徑物件 `。" -#: ../../library/tarfile.rst:203 +#: ../../library/tarfile.rst:206 msgid "The *compresslevel* keyword argument also works for streams." msgstr "*compresslevel* 關鍵字引數也適用於串流。" -#: ../../library/tarfile.rst:206 +#: ../../library/tarfile.rst:209 msgid "The *preset* keyword argument also works for streams." msgstr "*preset* 關鍵字引數也適用於串流。" -#: ../../library/tarfile.rst:213 +#: ../../library/tarfile.rst:212 +msgid "" +"The default compression level was reduced to 6 (down from 9). It is the " +"default level used by most compression tools and a better tradeoff between " +"speed and performance." +msgstr "" + +#: ../../library/tarfile.rst:220 msgid "" "Class for reading and writing tar archives. Do not use this class directly: " "use :func:`tarfile.open` instead. See :ref:`tarfile-objects`." @@ -497,7 +513,7 @@ msgstr "" "用於讀取和寫入 tar 封存檔的類別。請勿直接使用此類別:請改用 :func:`tarfile." "open`。請參閱 :ref:`tarfile-objects`。" -#: ../../library/tarfile.rst:219 +#: ../../library/tarfile.rst:226 msgid "" "Return :const:`True` if *name* is a tar archive file, that the :mod:`!" "tarfile` module can read. *name* may be a :class:`str`, file, or file-like " @@ -506,38 +522,38 @@ msgstr "" "如果 *name* 是一個 :mod:`!tarfile` 模組可以讀取的 tar 封存檔,則回傳 :const:" "`True`。*name* 可以是 :class:`str`、檔案或類檔案物件。" -#: ../../library/tarfile.rst:222 +#: ../../library/tarfile.rst:229 msgid "Support for file and file-like objects." msgstr "對檔案和類檔案物件的支援。" -#: ../../library/tarfile.rst:226 +#: ../../library/tarfile.rst:233 msgid "The :mod:`!tarfile` module defines the following exceptions:" msgstr ":mod:`!tarfile` 模組定義了以下例外:" -#: ../../library/tarfile.rst:231 +#: ../../library/tarfile.rst:238 msgid "Base class for all :mod:`!tarfile` exceptions." msgstr "所有 :mod:`!tarfile` 例外的基底類別。" -#: ../../library/tarfile.rst:236 +#: ../../library/tarfile.rst:243 msgid "" "Is raised when a tar archive is opened, that either cannot be handled by " "the :mod:`!tarfile` module or is somehow invalid." msgstr "" "當開啟的 tar 封存檔無法被 :mod:`!tarfile` 模組處理或以某種方式無效時引發。" -#: ../../library/tarfile.rst:242 +#: ../../library/tarfile.rst:249 msgid "" "Is raised when a compression method is not supported or when the data cannot " "be decoded properly." msgstr "當壓縮方法不被支援或資料無法正確解碼時引發。" -#: ../../library/tarfile.rst:248 +#: ../../library/tarfile.rst:255 msgid "" "Is raised for the limitations that are typical for stream-like :class:" "`TarFile` objects." msgstr "當遇到類似串流的 :class:`TarFile` 物件的典型限制時引發。" -#: ../../library/tarfile.rst:254 +#: ../../library/tarfile.rst:261 msgid "" "Is raised for *non-fatal* errors when using :meth:`TarFile.extract`, but " "only if :attr:`TarFile.errorlevel`\\ ``== 2``." @@ -545,45 +561,45 @@ msgstr "" "在使用 :meth:`TarFile.extract` 時針對\\ *非致命*\\ 錯誤引發,但僅限於 :attr:" "`TarFile.errorlevel`\\ ``== 2`` 時。" -#: ../../library/tarfile.rst:260 +#: ../../library/tarfile.rst:267 msgid "Is raised by :meth:`TarInfo.frombuf` if the buffer it gets is invalid." msgstr "如果 :meth:`TarInfo.frombuf` 得到的緩衝區無效,則引發此例外。" -#: ../../library/tarfile.rst:265 +#: ../../library/tarfile.rst:272 msgid "" "Base class for members :ref:`refused ` by filters." msgstr "" "被篩選器\\ :ref:`拒絕 `\\ 的成員的基底類別。" -#: ../../library/tarfile.rst:270 +#: ../../library/tarfile.rst:277 msgid "" "Information about the member that the filter refused to extract, as :ref:" "`TarInfo `." msgstr "篩選器拒絕解壓縮的成員資訊,以 :ref:`TarInfo ` 表示。" -#: ../../library/tarfile.rst:275 +#: ../../library/tarfile.rst:282 msgid "Raised to refuse extracting a member with an absolute path." msgstr "當拒絕解壓縮具有絕對路徑的成員時引發。" -#: ../../library/tarfile.rst:279 +#: ../../library/tarfile.rst:286 msgid "Raised to refuse extracting a member outside the destination directory." msgstr "當拒絕解壓縮位於目的地目錄之外的成員時引發。" -#: ../../library/tarfile.rst:283 +#: ../../library/tarfile.rst:290 msgid "Raised to refuse extracting a special file (e.g. a device or pipe)." msgstr "當拒絕解壓縮特殊檔案(例如裝置或管道)時引發。" -#: ../../library/tarfile.rst:287 +#: ../../library/tarfile.rst:294 msgid "Raised to refuse extracting a symbolic link with an absolute path." msgstr "當拒絕解壓縮具有絕對路徑的符號連結時引發。" -#: ../../library/tarfile.rst:291 +#: ../../library/tarfile.rst:298 msgid "" "Raised to refuse extracting a symbolic link pointing outside the destination " "directory." msgstr "當拒絕解壓縮指向目的地目錄之外的符號連結時引發。" -#: ../../library/tarfile.rst:296 +#: ../../library/tarfile.rst:303 msgid "" "Raised to refuse emulating a link (hard or symbolic) by extracting another " "archive member, when that member would be rejected by the filter location. " @@ -594,11 +610,11 @@ msgstr "" "篩選器位置拒絕,則引發此例外。用於拒絕替代成員的例外可作為 :attr:`!" "BaseException.__context__` 取得。" -#: ../../library/tarfile.rst:304 +#: ../../library/tarfile.rst:311 msgid "The following constants are available at the module level:" msgstr "以下常數可在模組層級使用:" -#: ../../library/tarfile.rst:308 +#: ../../library/tarfile.rst:315 msgid "" "The default character encoding: ``'utf-8'`` on Windows, the value returned " "by :func:`sys.getfilesystemencoding` otherwise." @@ -606,51 +622,51 @@ msgstr "" "預設字元編碼:在 Windows 上為 ``'utf-8'``,否則為 :func:`sys." "getfilesystemencoding` 回傳的值。" -#: ../../library/tarfile.rst:314 +#: ../../library/tarfile.rst:321 msgid "A regular file :attr:`~TarInfo.type`." msgstr "一個普通檔案 :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:318 +#: ../../library/tarfile.rst:325 msgid "A link (inside tarfile) :attr:`~TarInfo.type`." msgstr "一個連結(在 tar 檔案內)\\ :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:322 +#: ../../library/tarfile.rst:329 msgid "A symbolic link :attr:`~TarInfo.type`." msgstr "一個符號連結 :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:326 +#: ../../library/tarfile.rst:333 msgid "A character special device :attr:`~TarInfo.type`." msgstr "一個字元特殊裝置 :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:330 +#: ../../library/tarfile.rst:337 msgid "A block special device :attr:`~TarInfo.type`." msgstr "一個區塊特殊裝置 :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:334 +#: ../../library/tarfile.rst:341 msgid "A directory :attr:`~TarInfo.type`." msgstr "一個目錄 :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:338 +#: ../../library/tarfile.rst:345 msgid "A FIFO special device :attr:`~TarInfo.type`." msgstr "一個 FIFO 特殊裝置 :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:342 +#: ../../library/tarfile.rst:349 msgid "A contiguous file :attr:`~TarInfo.type`." msgstr "一個連續檔案 :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:346 +#: ../../library/tarfile.rst:353 msgid "A GNU tar longname :attr:`~TarInfo.type`." msgstr "一個 GNU tar longname :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:350 +#: ../../library/tarfile.rst:357 msgid "A GNU tar longlink :attr:`~TarInfo.type`." msgstr "一個 GNU tar longlink :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:354 +#: ../../library/tarfile.rst:361 msgid "A GNU tar sparse file :attr:`~TarInfo.type`." msgstr "一個 GNU tar 稀疏檔案 :attr:`~TarInfo.type`。" -#: ../../library/tarfile.rst:357 +#: ../../library/tarfile.rst:364 msgid "" "Each of the following constants defines a tar archive format that the :mod:`!" "tarfile` module is able to create. See section :ref:`tar-formats` for " @@ -659,50 +675,50 @@ msgstr "" "以下每個常數定義了 :mod:`!tarfile` 模組能夠建立的 tar 封存檔格式。詳細資訊請" "參閱 :ref:`tar-formats` 一節。" -#: ../../library/tarfile.rst:364 +#: ../../library/tarfile.rst:371 msgid "POSIX.1-1988 (ustar) format." msgstr "POSIX.1-1988 (ustar) 格式。" -#: ../../library/tarfile.rst:369 +#: ../../library/tarfile.rst:376 msgid "GNU tar format." msgstr "GNU tar 格式。" -#: ../../library/tarfile.rst:374 +#: ../../library/tarfile.rst:381 msgid "POSIX.1-2001 (pax) format." msgstr "POSIX.1-2001 (pax) 格式。" -#: ../../library/tarfile.rst:379 +#: ../../library/tarfile.rst:386 msgid "" "The default format for creating archives. This is currently :const:" "`PAX_FORMAT`." msgstr "建立封存檔的預設格式。目前為 :const:`PAX_FORMAT`。" -#: ../../library/tarfile.rst:381 +#: ../../library/tarfile.rst:388 msgid "" "The default format for new archives was changed to :const:`PAX_FORMAT` from :" "const:`GNU_FORMAT`." msgstr "" "新封存檔的預設格式已從 :const:`GNU_FORMAT` 變更為 :const:`PAX_FORMAT`。" -#: ../../library/tarfile.rst:388 +#: ../../library/tarfile.rst:395 msgid "Module :mod:`zipfile`" msgstr ":mod:`zipfile` 模組" -#: ../../library/tarfile.rst:389 +#: ../../library/tarfile.rst:396 msgid "Documentation of the :mod:`zipfile` standard module." msgstr ":mod:`zipfile` 標準模組的文件。" -#: ../../library/tarfile.rst:391 +#: ../../library/tarfile.rst:398 msgid ":ref:`archiving-operations`" msgstr ":ref:`archiving-operations`" -#: ../../library/tarfile.rst:392 +#: ../../library/tarfile.rst:399 msgid "" "Documentation of the higher-level archiving facilities provided by the " "standard :mod:`shutil` module." msgstr "標準 :mod:`shutil` 模組所提供的更高階封存功能的文件。" -#: ../../library/tarfile.rst:395 +#: ../../library/tarfile.rst:402 msgid "" "`GNU tar manual, Basic Tar Format `_" @@ -710,15 +726,15 @@ msgstr "" "`GNU tar 手冊,基本 Tar 格式 `_" -#: ../../library/tarfile.rst:396 +#: ../../library/tarfile.rst:403 msgid "Documentation for tar archive files, including GNU tar extensions." msgstr "tar 封存檔案的文件,包括 GNU tar 擴充功能。" -#: ../../library/tarfile.rst:402 +#: ../../library/tarfile.rst:409 msgid "TarFile Objects" msgstr "TarFile 物件" -#: ../../library/tarfile.rst:404 +#: ../../library/tarfile.rst:411 msgid "" "The :class:`TarFile` object provides an interface to a tar archive. A tar " "archive is a sequence of blocks. An archive member (a stored file) is made " @@ -731,7 +747,7 @@ msgstr "" "封存檔中多次儲存一個檔案。每個封存檔成員由一個 :class:`TarInfo` 物件表示,詳" "細資訊請參閱 :ref:`tarinfo-objects`。" -#: ../../library/tarfile.rst:410 +#: ../../library/tarfile.rst:417 msgid "" "A :class:`TarFile` object can be used as a context manager in a :keyword:" "`with` statement. It will automatically be closed when the block is " @@ -744,17 +760,17 @@ msgstr "" "化 (finalized);只有內部使用的檔案物件會被關閉。使用案例請參閱 :ref:`tar-" "examples` 一節。" -#: ../../library/tarfile.rst:416 +#: ../../library/tarfile.rst:423 msgid "Added support for the context management protocol." msgstr "新增對情境管理協定的支援。" -#: ../../library/tarfile.rst:421 +#: ../../library/tarfile.rst:428 msgid "" "All following arguments are optional and can be accessed as instance " "attributes as well." msgstr "以下所有引數都是可選的,也可以作為實例屬性存取。" -#: ../../library/tarfile.rst:424 +#: ../../library/tarfile.rst:431 msgid "" "*name* is the pathname of the archive. *name* may be a :term:`path-like " "object`. It can be omitted if *fileobj* is given. In this case, the file " @@ -764,7 +780,7 @@ msgstr "" "object>`。如果提供了 *fileobj* 則可以省略它。在這種情況下,如果檔案物件的 :" "attr:`!name` 屬性存在,則會使用該屬性。" -#: ../../library/tarfile.rst:428 +#: ../../library/tarfile.rst:435 msgid "" "*mode* is either ``'r'`` to read from an existing archive, ``'a'`` to append " "data to an existing file, ``'w'`` to create a new file overwriting an " @@ -774,7 +790,7 @@ msgstr "" "*mode* 可以是 ``'r'`` 以從現有封存檔讀取、``'a'`` 以附加資料到現有檔案、" "``'w'`` 以建立新檔案覆蓋現有檔案,或 ``'x'`` 以僅在檔案不存在時建立新檔案。" -#: ../../library/tarfile.rst:432 +#: ../../library/tarfile.rst:439 msgid "" "If *fileobj* is given, it is used for reading or writing data. If it can be " "determined, *mode* is overridden by *fileobj*'s mode. *fileobj* will be used " @@ -783,11 +799,11 @@ msgstr "" "如果提供了 *fileobj*,它會被用於讀取或寫入資料。如果可以確定,*mode* 會被 " "*fileobj* 的模式覆蓋。*fileobj* 將從位置 0 開始使用。" -#: ../../library/tarfile.rst:438 +#: ../../library/tarfile.rst:445 msgid "*fileobj* is not closed, when :class:`TarFile` is closed." msgstr "當 :class:`TarFile` 關閉時,*fileobj* 不會被關閉。" -#: ../../library/tarfile.rst:440 +#: ../../library/tarfile.rst:447 msgid "" "*format* controls the archive format for writing. It must be one of the " "constants :const:`USTAR_FORMAT`, :const:`GNU_FORMAT` or :const:`PAX_FORMAT` " @@ -798,13 +814,13 @@ msgstr "" "`USTAR_FORMAT`、:const:`GNU_FORMAT` 或 :const:`PAX_FORMAT` 之一。讀取時,即使" "單一封存檔中存在不同格式,格式也會自動偵測。" -#: ../../library/tarfile.rst:445 +#: ../../library/tarfile.rst:452 msgid "" "The *tarinfo* argument can be used to replace the default :class:`TarInfo` " "class with a different one." msgstr "*tarinfo* 引數可用於將預設的 :class:`TarInfo` 類別替換為不同的類別。" -#: ../../library/tarfile.rst:448 +#: ../../library/tarfile.rst:455 msgid "" "If *dereference* is :const:`False`, add symbolic and hard links to the " "archive. If it is :const:`True`, add the content of the target files to the " @@ -814,7 +830,7 @@ msgstr "" "為 :const:`True`,則將目標檔案的內容新增到封存檔。這在不支援符號連結的系統上" "沒有效果。" -#: ../../library/tarfile.rst:452 +#: ../../library/tarfile.rst:459 msgid "" "If *ignore_zeros* is :const:`False`, treat an empty block as the end of the " "archive. If it is :const:`True`, skip empty (and invalid) blocks and try to " @@ -825,7 +841,7 @@ msgstr "" "const:`True`,則跳過空的(和無效的)區塊並嘗試取得盡可能多的成員。這僅對讀取" "串聯或損壞的封存檔有用。" -#: ../../library/tarfile.rst:456 +#: ../../library/tarfile.rst:463 msgid "" "*debug* can be set from ``0`` (no debug messages) up to ``3`` (all debug " "messages). The messages are written to ``sys.stderr``." @@ -833,7 +849,7 @@ msgstr "" "*debug* 可設定從 ``0``\\ (無偵錯訊息)到 ``3``\\ (所有偵錯訊息)。訊息會寫" "入 ``sys.stderr``。" -#: ../../library/tarfile.rst:459 +#: ../../library/tarfile.rst:466 msgid "" "*errorlevel* controls how extraction errors are handled, see :attr:`the " "corresponding attribute `." @@ -841,7 +857,7 @@ msgstr "" "*errorlevel* 控制如何處理解壓縮錯誤,請參閱\\ :attr:`對應的屬性 `。" -#: ../../library/tarfile.rst:462 +#: ../../library/tarfile.rst:469 msgid "" "The *encoding* and *errors* arguments define the character encoding to be " "used for reading or writing the archive and how conversion errors are going " @@ -851,7 +867,7 @@ msgstr "" "*encoding* 和 *errors* 引數定義用於讀取或寫入封存檔的字元編碼以及如何處理轉換" "錯誤。預設設定適用於大多數使用者。深入資訊請參閱 :ref:`tar-unicode` 一節。" -#: ../../library/tarfile.rst:467 +#: ../../library/tarfile.rst:474 msgid "" "The *pax_headers* argument is an optional dictionary of strings which will " "be added as a pax global header if *format* is :const:`PAX_FORMAT`." @@ -859,7 +875,7 @@ msgstr "" "*pax_headers* 引數是一個可選的字串字典,如果 *format* 為 :const:" "`PAX_FORMAT`,則會作為 pax 全域標頭新增。" -#: ../../library/tarfile.rst:470 +#: ../../library/tarfile.rst:477 msgid "" "If *stream* is set to :const:`True` then while reading the archive info " "about files in the archive are not cached, saving memory." @@ -867,21 +883,21 @@ msgstr "" "如果 *stream* 設為 :const:`True`,則讀取封存檔時不會快取封存檔中關於檔案的資" "訊,從而節省記憶體。" -#: ../../library/tarfile.rst:473 ../../library/tarfile.rst:796 +#: ../../library/tarfile.rst:480 ../../library/tarfile.rst:803 msgid "Use ``'surrogateescape'`` as the default for the *errors* argument." msgstr "使用 ``'surrogateescape'`` 作為 *errors* 引數的預設值。" -#: ../../library/tarfile.rst:482 +#: ../../library/tarfile.rst:489 msgid "Add the *stream* parameter." msgstr "新增 *stream* 參數。" -#: ../../library/tarfile.rst:487 +#: ../../library/tarfile.rst:494 msgid "" "Alternative constructor. The :func:`tarfile.open` function is actually a " "shortcut to this classmethod." msgstr "替代建構函式。:func:`tarfile.open` 函式實際上是此類別方法的捷徑。" -#: ../../library/tarfile.rst:493 +#: ../../library/tarfile.rst:500 msgid "" "Return a :class:`TarInfo` object for member *name*. If *name* can not be " "found in the archive, :exc:`KeyError` is raised." @@ -889,13 +905,13 @@ msgstr "" "回傳成員 *name* 的 :class:`TarInfo` 物件。如果在封存檔中找不到 *name*,則引" "發 :exc:`KeyError`。" -#: ../../library/tarfile.rst:498 +#: ../../library/tarfile.rst:505 msgid "" "If a member occurs more than once in the archive, its last occurrence is " "assumed to be the most up-to-date version." msgstr "如果一個成員在封存檔中出現多次,則假定其最後一次出現是最新版本。" -#: ../../library/tarfile.rst:504 +#: ../../library/tarfile.rst:511 msgid "" "Return the members of the archive as a list of :class:`TarInfo` objects. The " "list has the same order as the members in the archive." @@ -903,14 +919,14 @@ msgstr "" "以 :class:`TarInfo` 物件串列的形式回傳封存檔的成員。串列的順序與封存檔中成員" "的順序相同。" -#: ../../library/tarfile.rst:510 +#: ../../library/tarfile.rst:517 msgid "" "Return the members as a list of their names. It has the same order as the " "list returned by :meth:`getmembers`." msgstr "" "以名稱串列的形式回傳成員。其順序與 :meth:`getmembers` 回傳的串列順序相同。" -#: ../../library/tarfile.rst:516 +#: ../../library/tarfile.rst:523 msgid "" "Print a table of contents to ``sys.stdout``. If *verbose* is :const:`False`, " "only the names of the members are printed. If it is :const:`True`, output " @@ -921,11 +937,11 @@ msgstr "" "的名稱。如果為 :const:`True`,則產生類似於 :program:`ls -l` 的輸出。如果提供" "了可選的 *members*,它必須是 :meth:`getmembers` 回傳串列的子集合。" -#: ../../library/tarfile.rst:521 +#: ../../library/tarfile.rst:528 msgid "Added the *members* parameter." msgstr "新增 *members* 參數。" -#: ../../library/tarfile.rst:527 +#: ../../library/tarfile.rst:534 msgid "" "Return the next member of the archive as a :class:`TarInfo` object, when :" "class:`TarFile` is opened for reading. Return :const:`None` if there is no " @@ -934,7 +950,7 @@ msgstr "" "當 :class:`TarFile` 以讀取方式開啟時,以 :class:`TarInfo` 物件的形式回傳封存" "檔的下一個成員。如果沒有更多成員可用,則回傳 :const:`None`。" -#: ../../library/tarfile.rst:534 +#: ../../library/tarfile.rst:541 msgid "" "Extract all members from the archive to the current working directory or " "directory *path*. If optional *members* is given, it must be a subset of the " @@ -951,7 +967,7 @@ msgstr "" "在目錄中建立檔案時,目錄的修改時間都會被重設。而且,如果目錄的權限不允許寫" "入,則無法將檔案解壓縮到其中。" -#: ../../library/tarfile.rst:542 +#: ../../library/tarfile.rst:549 msgid "" "If *numeric_owner* is :const:`True`, the uid and gid numbers from the " "tarfile are used to set the owner/group for the extracted files. Otherwise, " @@ -960,7 +976,7 @@ msgstr "" "如果 *numeric_owner* 為 :const:`True`,則使用 tar 檔案中的 uid 和 gid 數字來" "設定解壓縮檔案的擁有者/群組。否則,使用 tar 檔案中的名稱值。" -#: ../../library/tarfile.rst:546 +#: ../../library/tarfile.rst:553 msgid "" "The *filter* argument specifies how ``members`` are modified or rejected " "before extraction. See :ref:`tarfile-extraction-filter` for details. It is " @@ -973,11 +989,11 @@ msgstr "" "``filter='data'`` 以支援預設安全性較低的 Python 版本(3.13 及更低版本)時明確" "設定此項。" -#: ../../library/tarfile.rst:555 +#: ../../library/tarfile.rst:562 msgid "Never extract archives from untrusted sources without prior inspection." msgstr "切勿在未事先檢查的情況下解壓縮來自不受信任來源的封存檔。" -#: ../../library/tarfile.rst:557 +#: ../../library/tarfile.rst:564 msgid "" "Since Python 3.14, the default (:func:`data `) will prevent the " "most dangerous security issues. However, it will not prevent *all* " @@ -988,24 +1004,24 @@ msgstr "" "題。但是,它不會防止\\ *所有*\\ 意外或不安全的行為。詳細資訊請閱讀 :ref:" "`tarfile-extraction-filter` 一節。" -#: ../../library/tarfile.rst:562 ../../library/tarfile.rst:599 +#: ../../library/tarfile.rst:569 ../../library/tarfile.rst:606 msgid "Added the *numeric_owner* parameter." msgstr "新增 *numeric_owner* 參數。" -#: ../../library/tarfile.rst:565 ../../library/tarfile.rst:602 +#: ../../library/tarfile.rst:572 ../../library/tarfile.rst:609 msgid "The *path* parameter accepts a :term:`path-like object`." msgstr "*path* 參數接受\\ :term:`類路徑物件 `。" -#: ../../library/tarfile.rst:568 ../../library/tarfile.rst:605 -#: ../../library/tarfile.rst:689 +#: ../../library/tarfile.rst:575 ../../library/tarfile.rst:612 +#: ../../library/tarfile.rst:696 msgid "Added the *filter* parameter." msgstr "新增 *filter* 參數。" -#: ../../library/tarfile.rst:571 +#: ../../library/tarfile.rst:578 msgid "The *filter* parameter now defaults to ``'data'``." msgstr "*filter* 參數現在預設為 ``'data'``。" -#: ../../library/tarfile.rst:577 +#: ../../library/tarfile.rst:584 msgid "" "Extract a member from the archive to the current working directory, using " "its full name. Its file information is extracted as accurately as possible. " @@ -1018,13 +1034,13 @@ msgstr "" "指定不同的目錄。*path* 可以是\\ :term:`類路徑物件 `。除非 " "*set_attrs* 為 false,否則會設定檔案屬性 (owner, mtime, mode)。" -#: ../../library/tarfile.rst:583 +#: ../../library/tarfile.rst:590 msgid "" "The *numeric_owner* and *filter* arguments are the same as for :meth:" "`extractall`." msgstr "*numeric_owner* 和 *filter* 引數與 :meth:`extractall` 相同。" -#: ../../library/tarfile.rst:588 +#: ../../library/tarfile.rst:595 msgid "" "The :meth:`extract` method does not take care of several extraction issues. " "In most cases you should consider using the :meth:`extractall` method." @@ -1032,7 +1048,7 @@ msgstr "" ":meth:`extract` 方法不處理多個解壓縮問題。在大多數情況下,你應該考慮使用 :" "meth:`extractall` 方法。" -#: ../../library/tarfile.rst:593 +#: ../../library/tarfile.rst:600 msgid "" "Never extract archives from untrusted sources without prior inspection. See " "the warning for :meth:`extractall` for details." @@ -1040,11 +1056,11 @@ msgstr "" "切勿在事先檢查之前從不受信任的來源解壓縮封存檔。詳細資訊請參閱 :meth:" "`extractall` 的警告。" -#: ../../library/tarfile.rst:596 +#: ../../library/tarfile.rst:603 msgid "Added the *set_attrs* parameter." msgstr "增加 *set_attrs* 參數。" -#: ../../library/tarfile.rst:611 +#: ../../library/tarfile.rst:618 msgid "" "Extract a member from the archive as a file object. *member* may be a " "filename or a :class:`TarInfo` object. If *member* is a regular file or a " @@ -1057,11 +1073,11 @@ msgstr "" "BufferedReader` 物件。對於所有其他現有成員,回傳 :const:`None`。如果 " "*member* 未出現在封存檔中,則引發 :exc:`KeyError`。" -#: ../../library/tarfile.rst:617 +#: ../../library/tarfile.rst:624 msgid "Return an :class:`io.BufferedReader` object." msgstr "回傳 :class:`io.BufferedReader` 物件。" -#: ../../library/tarfile.rst:620 +#: ../../library/tarfile.rst:627 msgid "" "The returned :class:`io.BufferedReader` object has the :attr:`!mode` " "attribute which is always equal to ``'rb'``." @@ -1069,7 +1085,7 @@ msgstr "" "回傳的 :class:`io.BufferedReader` 物件具有 :attr:`!mode` 屬性,該屬性始終等" "於 ``'rb'``。" -#: ../../library/tarfile.rst:627 +#: ../../library/tarfile.rst:634 msgid "" "If *errorlevel* is ``0``, errors are ignored when using :meth:`TarFile." "extract` and :meth:`TarFile.extractall`. Nevertheless, they appear as error " @@ -1084,13 +1100,13 @@ msgstr "" "`OSError` 或 :exc:`FilterError` 例外的形式引發。如果為 ``2``,所有\\ *非致命" "*\\ 錯誤也會以 :exc:`TarError` 例外的形式引發。" -#: ../../library/tarfile.rst:635 +#: ../../library/tarfile.rst:642 msgid "" "Some exceptions, e.g. ones caused by wrong argument types or data " "corruption, are always raised." msgstr "某些例外,例如由錯誤的引數型別或資料損壞引起的例外,總是會被引發。" -#: ../../library/tarfile.rst:638 +#: ../../library/tarfile.rst:645 msgid "" "Custom :ref:`extraction filters ` should raise :" "exc:`FilterError` for *fatal* errors and :exc:`ExtractError` for *non-fatal* " @@ -1099,13 +1115,13 @@ msgstr "" "自訂的\\ :ref:`解壓縮篩選器 `\\ 應該對\\ *致命*\\ " "錯誤引發 :exc:`FilterError`,對\\ *非致命*\\ 錯誤引發 :exc:`ExtractError`。" -#: ../../library/tarfile.rst:642 +#: ../../library/tarfile.rst:649 msgid "" "Note that when an exception is raised, the archive may be partially " "extracted. It is the user’s responsibility to clean up." msgstr "請注意,當引發例外時,封存檔可能已部分解壓縮。清理是使用者的責任。" -#: ../../library/tarfile.rst:649 +#: ../../library/tarfile.rst:656 msgid "" "The :ref:`extraction filter ` used as a default " "for the *filter* argument of :meth:`~TarFile.extract` and :meth:`~TarFile." @@ -1114,7 +1130,7 @@ msgstr "" "用作 :meth:`~TarFile.extract` 和 :meth:`~TarFile.extractall` 的 *filter* 引數" "預設的\\ :ref:`解壓縮篩選器 `。" -#: ../../library/tarfile.rst:653 +#: ../../library/tarfile.rst:660 msgid "" "The attribute may be ``None`` or a callable. String names are not allowed " "for this attribute, unlike the *filter* argument to :meth:`~TarFile.extract`." @@ -1122,7 +1138,7 @@ msgstr "" "此屬性可以是 ``None`` 或可呼叫物件。與 :meth:`~TarFile.extract` 的 *filter* " "引數不同,此屬性不允許使用字串名稱。" -#: ../../library/tarfile.rst:657 +#: ../../library/tarfile.rst:664 msgid "" "If ``extraction_filter`` is ``None`` (the default), extraction methods will " "use the :func:`data ` filter by default." @@ -1130,7 +1146,7 @@ msgstr "" "如果 ``extraction_filter`` 為 ``None``\\ (預設值),解壓縮方法將預設使用 :" "func:`data ` 篩選器。" -#: ../../library/tarfile.rst:660 +#: ../../library/tarfile.rst:667 msgid "" "The attribute may be set on instances or overridden in subclasses. It also " "is possible to set it on the ``TarFile`` class itself to set a global " @@ -1144,7 +1160,7 @@ msgstr "" "用程式或 :mod:`site 組態 `\\ 中這樣做。要以這種方式設定全域預設值,需要" "將篩選器函式包裝在 :deco:`staticmethod` 中以防止注入 ``self`` 引數。" -#: ../../library/tarfile.rst:670 +#: ../../library/tarfile.rst:677 msgid "" "The default filter is set to :func:`data `, which disallows " "some dangerous features such as links to absolute paths or paths outside of " @@ -1155,7 +1171,7 @@ msgstr "" "對路徑或目的地之外路徑的連結。在此之前,預設值等同於 :func:`fully_trusted " "`。" -#: ../../library/tarfile.rst:678 +#: ../../library/tarfile.rst:685 msgid "" "Add the file *name* to the archive. *name* may be any type of file " "(directory, fifo, symbolic link, etc.). If given, *arcname* specifies an " @@ -1174,11 +1190,11 @@ msgstr "" "回傳變更後的 :class:`TarInfo` 物件的函式。如果它回傳 :const:`None`,則 :" "class:`TarInfo` 物件將從封存檔中排除。範例請參閱 :ref:`tar-examples`。" -#: ../../library/tarfile.rst:692 +#: ../../library/tarfile.rst:699 msgid "Recursion adds entries in sorted order." msgstr "遞迴以排序後的順序新增條目。" -#: ../../library/tarfile.rst:698 +#: ../../library/tarfile.rst:705 msgid "" "Add the :class:`TarInfo` object *tarinfo* to the archive. If *tarinfo* " "represents a non zero-size regular file, the *fileobj* argument should be a :" @@ -1191,11 +1207,11 @@ msgstr "" "中讀取 ``tarinfo.size`` 位元組並新增到封存檔。你可以直接建立 :class:" "`TarInfo` 物件,或使用 :meth:`gettarinfo`。" -#: ../../library/tarfile.rst:705 +#: ../../library/tarfile.rst:712 msgid "*fileobj* must be given for non-zero-sized regular files." msgstr "對於非零大小的一般檔案,必須提供 *fileobj*。" -#: ../../library/tarfile.rst:710 +#: ../../library/tarfile.rst:717 msgid "" "Create a :class:`TarInfo` object from the result of :func:`os.stat` or " "equivalent on an existing file. The file is either named by *name*, or " @@ -1211,7 +1227,7 @@ msgstr "" "*arcname*,則為封存檔中的檔案指定替代名稱,否則,名稱取自 *fileobj* 的 :attr:" "`~io.FileIO.name` 屬性或 *name* 引數。名稱應該是文字字串。" -#: ../../library/tarfile.rst:719 +#: ../../library/tarfile.rst:726 msgid "" "You can modify some of the :class:`TarInfo`’s attributes before you add it " "using :meth:`addfile`. If the file object is not an ordinary file object " @@ -1226,22 +1242,22 @@ msgstr "" "`~TarInfo.name` 也可以被修改,在這種情況下 *arcname* 可以是一個虛設字串 " "(dummy string)。" -#: ../../library/tarfile.rst:733 +#: ../../library/tarfile.rst:740 msgid "" "Close the :class:`TarFile`. In write mode, two finishing zero blocks are " "appended to the archive." msgstr "" "關閉 :class:`TarFile`。在寫入模式下,會在封存檔末尾附加兩個結束零區塊。" -#: ../../library/tarfile.rst:740 +#: ../../library/tarfile.rst:747 msgid "A dictionary containing key-value pairs of pax global headers." msgstr "包含 pax 全域標頭鍵值對的字典。" -#: ../../library/tarfile.rst:747 +#: ../../library/tarfile.rst:754 msgid "TarInfo Objects" msgstr "TarInfo 物件" -#: ../../library/tarfile.rst:749 +#: ../../library/tarfile.rst:756 msgid "" "A :class:`TarInfo` object represents one member in a :class:`TarFile`. Aside " "from storing all required attributes of a file (like file type, size, time, " @@ -1252,7 +1268,7 @@ msgstr "" "要屬性(如檔案型別、大小、時間、權限、擁有者等)之外,它還提供一些有用的方法" "來確定其型別。它\\ *不*\\ 包含檔案的資料本身。" -#: ../../library/tarfile.rst:754 +#: ../../library/tarfile.rst:761 msgid "" ":class:`TarInfo` objects are returned by :class:`TarFile`'s methods :meth:" "`~TarFile.getmember`, :meth:`~TarFile.getmembers` and :meth:`~TarFile." @@ -1261,7 +1277,7 @@ msgstr "" ":class:`TarInfo` 物件由 :class:`TarFile` 的方法 :meth:`~TarFile.getmember`、:" "meth:`~TarFile.getmembers` 和 :meth:`~TarFile.gettarinfo` 回傳。" -#: ../../library/tarfile.rst:758 +#: ../../library/tarfile.rst:765 msgid "" "Modifying the objects returned by :meth:`~TarFile.getmember` or :meth:" "`~TarFile.getmembers` will affect all subsequent operations on the archive. " @@ -1274,7 +1290,7 @@ msgstr "" "`copy.copy() ` 或呼叫 :meth:`~TarInfo.replace` 方法來一步建立修改後的副" "本。" -#: ../../library/tarfile.rst:764 +#: ../../library/tarfile.rst:771 msgid "" "Several attributes can be set to ``None`` to indicate that a piece of " "metadata is unused or unknown. Different :class:`TarInfo` methods handle " @@ -1283,7 +1299,7 @@ msgstr "" "可以將多個屬性設為 ``None`` 以表示一段中介資料 (metadata) 未被使用或未知。不" "同的 :class:`TarInfo` 方法會以不同的方式處理 ``None``:" -#: ../../library/tarfile.rst:768 +#: ../../library/tarfile.rst:775 msgid "" "The :meth:`~TarFile.extract` or :meth:`~TarFile.extractall` methods will " "ignore the corresponding metadata, leaving it set to a default." @@ -1291,27 +1307,27 @@ msgstr "" ":meth:`~TarFile.extract` 或 :meth:`~TarFile.extractall` 方法將忽略對應的中介" "資料,使其保持預設值。" -#: ../../library/tarfile.rst:770 +#: ../../library/tarfile.rst:777 msgid ":meth:`~TarFile.addfile` will fail." msgstr ":meth:`~TarFile.addfile` 將失敗。" -#: ../../library/tarfile.rst:771 +#: ../../library/tarfile.rst:778 msgid ":meth:`~TarFile.list` will print a placeholder string." msgstr ":meth:`~TarFile.list` 將印出一個佔位字串 (placeholder string)。" -#: ../../library/tarfile.rst:775 +#: ../../library/tarfile.rst:782 msgid "Create a :class:`TarInfo` object." msgstr "建立 :class:`TarInfo` 物件。" -#: ../../library/tarfile.rst:780 +#: ../../library/tarfile.rst:787 msgid "Create and return a :class:`TarInfo` object from string buffer *buf*." msgstr "從字串緩衝區 *buf* 建立並回傳 :class:`TarInfo` 物件。" -#: ../../library/tarfile.rst:782 +#: ../../library/tarfile.rst:789 msgid "Raises :exc:`HeaderError` if the buffer is invalid." msgstr "如果緩衝區無效,則引發 :exc:`HeaderError`。" -#: ../../library/tarfile.rst:787 +#: ../../library/tarfile.rst:794 msgid "" "Read the next member from the :class:`TarFile` object *tarfile* and return " "it as a :class:`TarInfo` object." @@ -1319,7 +1335,7 @@ msgstr "" "從 :class:`TarFile` 物件 *tarfile* 讀取下一個成員並將其作為 :class:`TarInfo` " "物件回傳。" -#: ../../library/tarfile.rst:793 +#: ../../library/tarfile.rst:800 msgid "" "Create a string buffer from a :class:`TarInfo` object. For information on " "the arguments see the constructor of the :class:`TarFile` class." @@ -1327,19 +1343,19 @@ msgstr "" "從 :class:`TarInfo` 物件建立字串緩衝區。關於引數的資訊,請參閱 :class:" "`TarFile` 類別的建構函式。" -#: ../../library/tarfile.rst:800 +#: ../../library/tarfile.rst:807 msgid "A ``TarInfo`` object has the following public data attributes:" msgstr "一個 ``TarInfo`` 物件具有以下公開資料屬性:" -#: ../../library/tarfile.rst:806 +#: ../../library/tarfile.rst:813 msgid "Name of the archive member." msgstr "封存檔成員的名稱。" -#: ../../library/tarfile.rst:812 +#: ../../library/tarfile.rst:819 msgid "Size in bytes." msgstr "大小(以位元組為單位)。" -#: ../../library/tarfile.rst:818 +#: ../../library/tarfile.rst:825 msgid "" "Time of last modification in seconds since the :ref:`epoch `, as in :" "attr:`os.stat_result.st_mtime`." @@ -1347,9 +1363,9 @@ msgstr "" "自\\ :ref:`epoch ` 以來的最後修改時間(以秒為單位),如 :attr:`os." "stat_result.st_mtime`。" -#: ../../library/tarfile.rst:823 ../../library/tarfile.rst:834 -#: ../../library/tarfile.rst:866 ../../library/tarfile.rst:877 -#: ../../library/tarfile.rst:888 ../../library/tarfile.rst:899 +#: ../../library/tarfile.rst:830 ../../library/tarfile.rst:841 +#: ../../library/tarfile.rst:873 ../../library/tarfile.rst:884 +#: ../../library/tarfile.rst:895 ../../library/tarfile.rst:906 msgid "" "Can be set to ``None`` for :meth:`~TarFile.extract` and :meth:`~TarFile." "extractall`, causing extraction to skip applying this attribute." @@ -1357,11 +1373,11 @@ msgstr "" "對於 :meth:`~TarFile.extract` 和 :meth:`~TarFile.extractall`,可以設為 " "``None``,讓解壓縮跳過套用此屬性。" -#: ../../library/tarfile.rst:830 +#: ../../library/tarfile.rst:837 msgid "Permission bits, as for :func:`os.chmod`." msgstr "權限位元 (permission bits),如 :func:`os.chmod` 所用。" -#: ../../library/tarfile.rst:840 +#: ../../library/tarfile.rst:847 msgid "" "File type. *type* is usually one of these constants: :const:`REGTYPE`, :" "const:`AREGTYPE`, :const:`LNKTYPE`, :const:`SYMTYPE`, :const:`DIRTYPE`, :" @@ -1375,7 +1391,7 @@ msgstr "" "`GNUTYPE_SPARSE`。要更方便地確定 :class:`TarInfo` 物件的類型,請使用下面的 " "``is*()`` 方法。" -#: ../../library/tarfile.rst:850 +#: ../../library/tarfile.rst:857 msgid "" "Name of the target file name, which is only present in :class:`TarInfo` " "objects of type :const:`LNKTYPE` and :const:`SYMTYPE`." @@ -1383,7 +1399,7 @@ msgstr "" "目標檔案名稱的名稱,僅存在於型別為 :const:`LNKTYPE` 和 :const:`SYMTYPE` 的 :" "class:`TarInfo` 物件中。" -#: ../../library/tarfile.rst:853 +#: ../../library/tarfile.rst:860 msgid "" "For symbolic links (``SYMTYPE``), the *linkname* is relative to the " "directory that contains the link. For hard links (``LNKTYPE``), the " @@ -1392,52 +1408,52 @@ msgstr "" "對於符號連結(``SYMTYPE``),*linkname* 相對於包含連結的目錄。對於硬連結" "(``LNKTYPE``),*linkname* 相對於封存檔的根。" -#: ../../library/tarfile.rst:862 +#: ../../library/tarfile.rst:869 msgid "User ID of the user who originally stored this member." msgstr "最初儲存此成員的使用者的使用者 ID。" -#: ../../library/tarfile.rst:873 +#: ../../library/tarfile.rst:880 msgid "Group ID of the user who originally stored this member." msgstr "最初儲存此成員的使用者的群組 ID。" -#: ../../library/tarfile.rst:884 +#: ../../library/tarfile.rst:891 msgid "User name." msgstr "使用者名稱。" -#: ../../library/tarfile.rst:895 +#: ../../library/tarfile.rst:902 msgid "Group name." msgstr "群組名稱。" -#: ../../library/tarfile.rst:906 +#: ../../library/tarfile.rst:913 msgid "Header checksum." msgstr "標頭校驗和 (checksum)。" -#: ../../library/tarfile.rst:912 +#: ../../library/tarfile.rst:919 msgid "Device major number." msgstr "裝置主號碼。" -#: ../../library/tarfile.rst:918 +#: ../../library/tarfile.rst:925 msgid "Device minor number." msgstr "裝置副號碼。" -#: ../../library/tarfile.rst:924 +#: ../../library/tarfile.rst:931 msgid "The tar header starts here." msgstr "tar 標頭從這裡開始。" -#: ../../library/tarfile.rst:930 +#: ../../library/tarfile.rst:937 msgid "The file's data starts here." msgstr "檔案的資料從這裡開始。" -#: ../../library/tarfile.rst:935 +#: ../../library/tarfile.rst:942 msgid "Sparse member information." msgstr "稀疏成員資訊。" -#: ../../library/tarfile.rst:941 +#: ../../library/tarfile.rst:948 msgid "" "A dictionary containing key-value pairs of an associated pax extended header." msgstr "包含關聯的 pax 擴充標頭鍵值對的字典。" -#: ../../library/tarfile.rst:949 +#: ../../library/tarfile.rst:956 msgid "" "Return a *new* copy of the :class:`!TarInfo` object with the given " "attributes changed. For example, to return a ``TarInfo`` with the group name " @@ -1446,11 +1462,11 @@ msgstr "" "回傳具有給定屬性變更的 :class:`!TarInfo` 物件的\\ *新*\\ 副本。例如,要回傳群" "組名稱設為 ``'staff'`` 的 ``TarInfo``,請使用: ::" -#: ../../library/tarfile.rst:953 +#: ../../library/tarfile.rst:960 msgid "new_tarinfo = old_tarinfo.replace(gname='staff')" msgstr "new_tarinfo = old_tarinfo.replace(gname='staff')" -#: ../../library/tarfile.rst:955 +#: ../../library/tarfile.rst:962 msgid "" "By default, a deep copy is made. If *deep* is false, the copy is shallow, i." "e. ``pax_headers`` and any custom attributes are shared with the original " @@ -1459,52 +1475,52 @@ msgstr "" "預設情況下,會進行深度複製。如果 *deep* 為 false,則複製為淺複製,即 " "``pax_headers`` 和任何自訂屬性與原始 ``TarInfo`` 物件共用。" -#: ../../library/tarfile.rst:959 +#: ../../library/tarfile.rst:966 msgid "A :class:`TarInfo` object also provides some convenient query methods:" msgstr ":class:`TarInfo` 物件也提供一些方便的查詢方法:" -#: ../../library/tarfile.rst:964 +#: ../../library/tarfile.rst:971 msgid "Return :const:`True` if the :class:`TarInfo` object is a regular file." msgstr "如果 :class:`TarInfo` 物件是一般檔案,則回傳 :const:`True`。" -#: ../../library/tarfile.rst:969 +#: ../../library/tarfile.rst:976 msgid "Same as :meth:`isfile`." msgstr "與 :meth:`isfile` 相同。" -#: ../../library/tarfile.rst:974 +#: ../../library/tarfile.rst:981 msgid "Return :const:`True` if it is a directory." msgstr "如果它是一個目錄,則回傳 :const:`True`。" -#: ../../library/tarfile.rst:979 +#: ../../library/tarfile.rst:986 msgid "Return :const:`True` if it is a symbolic link." msgstr "如果它是一個符號連結,則回傳 :const:`True`。" -#: ../../library/tarfile.rst:984 +#: ../../library/tarfile.rst:991 msgid "Return :const:`True` if it is a hard link." msgstr "如果它是一個硬連結,則回傳 :const:`True`。" -#: ../../library/tarfile.rst:989 +#: ../../library/tarfile.rst:996 msgid "Return :const:`True` if it is a character device." msgstr "如果它是一個字元裝置,則回傳 :const:`True`。" -#: ../../library/tarfile.rst:994 +#: ../../library/tarfile.rst:1001 msgid "Return :const:`True` if it is a block device." msgstr "如果它是一個區塊裝置,則回傳 :const:`True`。" -#: ../../library/tarfile.rst:999 +#: ../../library/tarfile.rst:1006 msgid "Return :const:`True` if it is a FIFO." msgstr "如果它是一個 FIFO,則回傳 :const:`True`。" -#: ../../library/tarfile.rst:1004 +#: ../../library/tarfile.rst:1011 msgid "" "Return :const:`True` if it is one of character device, block device or FIFO." msgstr "如果它是一個字元裝置、區塊裝置或 FIFO,則回傳 :const:`True`。" -#: ../../library/tarfile.rst:1010 +#: ../../library/tarfile.rst:1017 msgid "Extraction filters" msgstr "解壓縮篩選器" -#: ../../library/tarfile.rst:1014 +#: ../../library/tarfile.rst:1021 msgid "" "The *tar* format is designed to capture all details of a UNIX-like " "filesystem, which makes it very powerful. Unfortunately, the features make " @@ -1518,7 +1534,7 @@ msgstr "" "很容易。例如,解壓縮 tar 檔案可以透過各種方式覆寫任意檔案(例如使用絕對路徑、" "``..`` 路徑元件,或影響後續成員的符號連結)。" -#: ../../library/tarfile.rst:1022 +#: ../../library/tarfile.rst:1029 msgid "" "In most cases, the full functionality is not needed. Therefore, *tarfile* " "supports extraction filters: a mechanism to limit functionality, and thus " @@ -1527,7 +1543,7 @@ msgstr "" "在大多數情況下,不需要完整功能。因此,*tarfile* 支援解壓縮篩選器:一種限制功" "能的機制,從而減輕某些安全性問題。" -#: ../../library/tarfile.rst:1028 +#: ../../library/tarfile.rst:1035 msgid "" "None of the available filters blocks *all* dangerous archive features. Never " "extract archives from untrusted sources without prior inspection. See also :" @@ -1537,15 +1553,15 @@ msgstr "" "查的情況下從不受信任的來源解壓縮封存檔。另請參閱 :ref:`tarfile-further-" "verification`。" -#: ../../library/tarfile.rst:1034 +#: ../../library/tarfile.rst:1041 msgid ":pep:`706`" msgstr ":pep:`706`" -#: ../../library/tarfile.rst:1035 +#: ../../library/tarfile.rst:1042 msgid "Contains further motivation and rationale behind the design." msgstr "包含此設計背後的進一步動機和理由。" -#: ../../library/tarfile.rst:1037 +#: ../../library/tarfile.rst:1044 msgid "" "The *filter* argument to :meth:`TarFile.extract` or :meth:`~TarFile." "extractall` can be:" @@ -1553,7 +1569,7 @@ msgstr "" ":meth:`TarFile.extract` 或 :meth:`~TarFile.extractall` 的 *filter* 引數可以" "是:" -#: ../../library/tarfile.rst:1040 +#: ../../library/tarfile.rst:1047 msgid "" "the string ``'fully_trusted'``: Honor all metadata as specified in the " "archive. Should be used if the user trusts the archive completely, or " @@ -1562,7 +1578,7 @@ msgstr "" "``'fully_trusted'`` 字串:遵守封存檔中指定的所有中介資料。應在使用者完全信任" "封存檔或實作自己的複雜驗證時使用。" -#: ../../library/tarfile.rst:1045 +#: ../../library/tarfile.rst:1052 msgid "" "the string ``'tar'``: Honor most *tar*-specific features (i.e. features of " "UNIX-like filesystems), but block features that are very likely to be " @@ -1571,7 +1587,7 @@ msgstr "" "``'tar'`` 字串:遵守大多數 *tar* 特定功能(即 UNIX-like 檔案系統的功能),但" "阻擋很可能令人驚訝或惡意的功能。詳見 :func:`tar_filter`。" -#: ../../library/tarfile.rst:1049 +#: ../../library/tarfile.rst:1056 msgid "" "the string ``'data'``: Ignore or block most features specific to UNIX-like " "filesystems. Intended for extracting cross-platform data archives. See :func:" @@ -1580,16 +1596,16 @@ msgstr "" "``'data'`` 字串:忽略或阻擋大多數 UNIX-like 檔案系統特定功能。用於解壓縮跨平" "台資料封存檔。詳見 :func:`data_filter`。" -#: ../../library/tarfile.rst:1053 +#: ../../library/tarfile.rst:1060 msgid "``None`` (default): Use :attr:`TarFile.extraction_filter`." msgstr "``None``\\ (預設):使用 :attr:`TarFile.extraction_filter`。" -#: ../../library/tarfile.rst:1055 +#: ../../library/tarfile.rst:1062 msgid "" "If that is also ``None`` (the default), the ``'data'`` filter will be used." msgstr "如果該值也是 ``None``\\ (預設值),則會使用 ``'data'`` 篩選器。" -#: ../../library/tarfile.rst:1059 +#: ../../library/tarfile.rst:1066 msgid "" "The default filter is set to :func:`data `. Previously, the " "default was equivalent to :func:`fully_trusted `." @@ -1597,7 +1613,7 @@ msgstr "" "預設篩選器設為 :func:`data `。在此之前,預設等同於 :func:" "`fully_trusted `。" -#: ../../library/tarfile.rst:1063 +#: ../../library/tarfile.rst:1070 msgid "" "A callable which will be called for each extracted member with a :ref:" "`TarInfo ` describing the member and the destination path " @@ -1608,28 +1624,28 @@ msgstr "" "` 和封存檔解壓縮目的地路徑來呼叫它(即所有成員使用相同的路" "徑): ::" -#: ../../library/tarfile.rst:1068 +#: ../../library/tarfile.rst:1075 msgid "filter(member: TarInfo, path: str, /) -> TarInfo | None" msgstr "filter(member: TarInfo, path: str, /) -> TarInfo | None" -#: ../../library/tarfile.rst:1070 +#: ../../library/tarfile.rst:1077 msgid "" "The callable is called just before each member is extracted, so it can take " "the current state of the disk into account. It can:" msgstr "" "此可呼叫物件在每個成員解壓縮之前被呼叫,因此可以考慮磁碟的目前狀態。它可以:" -#: ../../library/tarfile.rst:1074 +#: ../../library/tarfile.rst:1081 msgid "" "return a :class:`TarInfo` object which will be used instead of the metadata " "in the archive, or" msgstr "回傳一個 :class:`TarInfo` 物件,該物件將用於替代封存檔中的中介資料,或" -#: ../../library/tarfile.rst:1076 +#: ../../library/tarfile.rst:1083 msgid "return ``None``, in which case the member will be skipped, or" msgstr "回傳 ``None``,在此情況下該成員會被跳過,或" -#: ../../library/tarfile.rst:1077 +#: ../../library/tarfile.rst:1084 msgid "" "raise an exception to abort the operation or skip the member, depending on :" "attr:`~TarFile.errorlevel`. Note that when extraction is aborted, :meth:" @@ -1640,33 +1656,33 @@ msgstr "" "當解壓縮被中止時,:meth:`~TarFile.extractall` 可能會留下部分解壓縮的封存檔。" "它不會嘗試清理。" -#: ../../library/tarfile.rst:1083 +#: ../../library/tarfile.rst:1090 msgid "Default named filters" msgstr "預設具名篩選器" -#: ../../library/tarfile.rst:1085 +#: ../../library/tarfile.rst:1092 msgid "" "The pre-defined, named filters are available as functions, so they can be " "reused in custom filters:" msgstr "預先定義的具名篩選器可作為函式使用,因此可以在自訂篩選器中重複使用:" -#: ../../library/tarfile.rst:1090 +#: ../../library/tarfile.rst:1097 msgid "Return *member* unchanged." msgstr "回傳未經修改的 *member*。" -#: ../../library/tarfile.rst:1092 +#: ../../library/tarfile.rst:1099 msgid "This implements the ``'fully_trusted'`` filter." msgstr "這實作了 ``'fully_trusted'`` 篩選器。" -#: ../../library/tarfile.rst:1096 +#: ../../library/tarfile.rst:1103 msgid "Implements the ``'tar'`` filter." msgstr "實作 ``'tar'`` 篩選器。" -#: ../../library/tarfile.rst:1098 +#: ../../library/tarfile.rst:1105 msgid "Strip leading slashes (``/`` and :data:`os.sep`) from filenames." msgstr "從檔名中移除開頭的斜線(``/`` 和 :data:`os.sep`)。" -#: ../../library/tarfile.rst:1099 +#: ../../library/tarfile.rst:1106 msgid "" ":ref:`Refuse ` to extract files with absolute " "paths (in case the name is absolute even after stripping slashes, e.g. ``C:/" @@ -1676,7 +1692,7 @@ msgstr "" "線後名稱仍是絕對路徑的情況下,例如 Windows 上的 ``C:/foo``)。這會引發 :" "class:`~tarfile.AbsolutePathError`。" -#: ../../library/tarfile.rst:1103 +#: ../../library/tarfile.rst:1110 msgid "" "Normalize filenames (:attr:`TarInfo.name`) that contain ``..`` components " "using :func:`os.path.normpath`. Note that this removes internal ``..`` " @@ -1687,7 +1703,7 @@ msgstr "" "(:attr:`TarInfo.name`)。請注意,這會移除內部的 ``..`` 元件,如果名稱會遍歷" "符號連結,這可能會改變名稱的意義。" -#: ../../library/tarfile.rst:1107 +#: ../../library/tarfile.rst:1114 msgid "" ":ref:`Refuse ` to extract files whose absolute " "path (after following symlinks) would end up outside the destination. This " @@ -1697,7 +1713,7 @@ msgstr "" "後)會位於目的地之外的檔案。這會引發 :class:`~tarfile." "OutsideDestinationError`。" -#: ../../library/tarfile.rst:1110 +#: ../../library/tarfile.rst:1117 msgid "" "Clear high mode bits (setuid, setgid, sticky) and group/other write bits (:" "const:`~stat.S_IWGRP` | :const:`~stat.S_IWOTH`)." @@ -1705,20 +1721,20 @@ msgstr "" "清除高位模式位元 (setuid, setgid, sticky) 以及群組/其他人的寫入位元(:const:" "`~stat.S_IWGRP` | :const:`~stat.S_IWOTH`)。" -#: ../../library/tarfile.rst:1113 ../../library/tarfile.rst:1156 +#: ../../library/tarfile.rst:1120 ../../library/tarfile.rst:1163 msgid "Return the modified ``TarInfo`` member." msgstr "回傳修改後的 ``TarInfo`` 成員。" -#: ../../library/tarfile.rst:1117 +#: ../../library/tarfile.rst:1124 msgid "Filenames containing ``..`` components are now normalized." msgstr "包含 ``..`` 元件的檔案名稱現在會被正規化。" -#: ../../library/tarfile.rst:1121 +#: ../../library/tarfile.rst:1128 msgid "" "Implements the ``'data'`` filter. In addition to what ``tar_filter`` does:" msgstr "實作 ``'data'`` 篩選器。除了 ``tar_filter`` 的功能外,還包括:" -#: ../../library/tarfile.rst:1124 +#: ../../library/tarfile.rst:1131 msgid "" "Normalize link targets (:attr:`TarInfo.linkname`) using :func:`os.path." "normpath`. Note that this removes internal ``..`` components, which may " @@ -1729,7 +1745,7 @@ msgstr "" "注意,這會移除內部的 ``..`` 元件,如果 :attr:`!TarInfo.linkname` 中的路徑會遍" "歷符號連結,這可能會改變連結的意義。" -#: ../../library/tarfile.rst:1130 +#: ../../library/tarfile.rst:1137 msgid "" ":ref:`Refuse ` to extract links (hard or soft) " "that link to absolute paths, or ones that link outside the destination." @@ -1737,7 +1753,7 @@ msgstr "" ":ref:`拒絕 `\\ 解壓縮指向絕對路徑的連結(硬連結或" "軟連結),或指向目的地之外的連結。" -#: ../../library/tarfile.rst:1133 +#: ../../library/tarfile.rst:1140 msgid "" "This raises :class:`~tarfile.AbsoluteLinkError` or :class:`~tarfile." "LinkOutsideDestinationError`." @@ -1745,13 +1761,13 @@ msgstr "" "這會引發 :class:`~tarfile.AbsoluteLinkError` 或 :class:`~tarfile." "LinkOutsideDestinationError`。" -#: ../../library/tarfile.rst:1136 +#: ../../library/tarfile.rst:1143 msgid "" "Note that such files are refused even on platforms that do not support " "symbolic links." msgstr "請注意,即使在不支援符號連結的平台上,這類檔案也會被拒絕。" -#: ../../library/tarfile.rst:1139 +#: ../../library/tarfile.rst:1146 msgid "" ":ref:`Refuse ` to extract device files (including " "pipes). This raises :class:`~tarfile.SpecialFileError`." @@ -1759,11 +1775,11 @@ msgstr "" ":ref:`拒絕 `\\ 解壓縮裝置檔案(包括 pipe)。這會引" "發 :class:`~tarfile.SpecialFileError`。" -#: ../../library/tarfile.rst:1143 +#: ../../library/tarfile.rst:1150 msgid "For regular files, including hard links:" msgstr "對於一般檔案,包括硬連結:" -#: ../../library/tarfile.rst:1145 +#: ../../library/tarfile.rst:1152 msgid "" "Set the owner read and write permissions (:const:`~stat.S_IRUSR` | :const:" "`~stat.S_IWUSR`)." @@ -1771,7 +1787,7 @@ msgstr "" "設定擁有者的讀取和寫入權限(:const:`~stat.S_IRUSR` | :const:`~stat." "S_IWUSR`)。" -#: ../../library/tarfile.rst:1147 +#: ../../library/tarfile.rst:1154 msgid "" "Remove the group & other executable permission (:const:`~stat.S_IXGRP` | :" "const:`~stat.S_IXOTH`) if the owner doesn’t have it (:const:`~stat.S_IXUSR`)." @@ -1779,7 +1795,7 @@ msgstr "" "如果擁有者沒有執行權限(:const:`~stat.S_IXUSR`),則移除群組和其他人的執行權" "限(:const:`~stat.S_IXGRP` | :const:`~stat.S_IXOTH`)。" -#: ../../library/tarfile.rst:1151 +#: ../../library/tarfile.rst:1158 msgid "" "For other files (directories), set ``mode`` to ``None``, so that extraction " "methods skip applying permission bits." @@ -1787,7 +1803,7 @@ msgstr "" "對於其他檔案(目錄),將 ``mode`` 設為 ``None``,讓解壓縮方法跳過套用權限位" "元。" -#: ../../library/tarfile.rst:1153 +#: ../../library/tarfile.rst:1160 msgid "" "Set user and group info (``uid``, ``gid``, ``uname``, ``gname``) to " "``None``, so that extraction methods skip setting it." @@ -1795,7 +1811,7 @@ msgstr "" "將使用者和群組資訊 (``uid``, ``gid``, ``uname``, ``gname``) 設為 ``None``,讓" "解壓縮方法跳過設定它們。" -#: ../../library/tarfile.rst:1158 +#: ../../library/tarfile.rst:1165 msgid "" "Note that this filter does not block *all* dangerous archive features. See :" "ref:`tarfile-further-verification` for details." @@ -1803,15 +1819,15 @@ msgstr "" "請注意,此篩選器並未阻擋\\ *所有*\\ 危險的封存檔功能。詳細資訊請參閱 :ref:" "`tarfile-further-verification`。" -#: ../../library/tarfile.rst:1163 +#: ../../library/tarfile.rst:1170 msgid "Link targets are now normalized." msgstr "連結目標現在會被正規化。" -#: ../../library/tarfile.rst:1169 +#: ../../library/tarfile.rst:1176 msgid "Filter errors" msgstr "篩選器錯誤" -#: ../../library/tarfile.rst:1171 +#: ../../library/tarfile.rst:1178 msgid "" "When a filter refuses to extract a file, it will raise an appropriate " "exception, a subclass of :class:`~tarfile.FilterError`. This will abort the " @@ -1824,11 +1840,11 @@ msgstr "" "解壓縮。使用 ``errorlevel=0`` 時,錯誤將被記錄並跳過該成員,但解壓縮將繼續進" "行。" -#: ../../library/tarfile.rst:1181 +#: ../../library/tarfile.rst:1188 msgid "Hints for further verification" msgstr "進一步驗證的提示" -#: ../../library/tarfile.rst:1183 +#: ../../library/tarfile.rst:1190 msgid "" "Even with ``filter='data'``, *tarfile* is not suited for extracting " "untrusted files without prior inspection. Among other issues, the pre-" @@ -1839,11 +1855,11 @@ msgstr "" "受信任的檔案。除了其他問題外,預先定義的篩選器不會防止阻斷服務攻擊。使用者應" "進行額外檢查。" -#: ../../library/tarfile.rst:1188 +#: ../../library/tarfile.rst:1195 msgid "Here is an incomplete list of things to consider:" msgstr "以下是需要考慮的不完整清單:" -#: ../../library/tarfile.rst:1190 +#: ../../library/tarfile.rst:1197 msgid "" "Extract to a :func:`new temporary directory ` to prevent e." "g. exploiting pre-existing links, and to make it easier to clean up after a " @@ -1852,11 +1868,11 @@ msgstr "" "解壓縮到\\ :func:`新的臨時目錄 `\\ 以防止例如利用預先存在的" "連結,並使解壓縮失敗後更容易清理。" -#: ../../library/tarfile.rst:1193 +#: ../../library/tarfile.rst:1200 msgid "Disallow symbolic links if you do not need the functionality." msgstr "如果不需要符號連結功能,請禁止它。" -#: ../../library/tarfile.rst:1194 +#: ../../library/tarfile.rst:1201 msgid "" "When working with untrusted data, use external (e.g. OS-level) limits on " "disk, memory and CPU usage." @@ -1864,14 +1880,14 @@ msgstr "" "處理不受信任的資料時,請使用外部(例如作業系統層級)的磁碟、記憶體和 CPU 使用" "量限制。" -#: ../../library/tarfile.rst:1196 +#: ../../library/tarfile.rst:1203 msgid "" "Check filenames against an allow-list of characters (to filter out control " "characters, confusables, foreign path separators, and so on)." msgstr "" "根據字元白名單檢查檔名(以過濾掉控制字元、易混淆字元、外部路徑分隔符號等)。" -#: ../../library/tarfile.rst:1199 +#: ../../library/tarfile.rst:1206 msgid "" "Check that filenames have expected extensions (discouraging files that " "execute when you “click on them”, or extension-less files like Windows " @@ -1880,7 +1896,7 @@ msgstr "" "檢查檔名是否具有預期的副檔名(避免點擊時會執行的檔案,或像 Windows 特殊裝置名" "稱這樣的無副檔名檔案)。" -#: ../../library/tarfile.rst:1202 +#: ../../library/tarfile.rst:1209 msgid "" "Limit the number of extracted files, total size of extracted data, filename " "length (including symlink length), and size of individual files." @@ -1888,15 +1904,15 @@ msgstr "" "限制解壓縮檔案的數量、解壓縮資料的總大小、檔名長度(包括符號連結長度)以及個" "別檔案的大小。" -#: ../../library/tarfile.rst:1204 +#: ../../library/tarfile.rst:1211 msgid "Check for files that would be shadowed on case-insensitive filesystems." msgstr "檢查在不區分大小寫的檔案系統上會被遮蔽的檔案。" -#: ../../library/tarfile.rst:1206 +#: ../../library/tarfile.rst:1213 msgid "Also note that:" msgstr "另請注意:" -#: ../../library/tarfile.rst:1208 +#: ../../library/tarfile.rst:1215 msgid "" "Tar files may contain multiple versions of the same file. Later ones are " "expected to overwrite any earlier ones. This feature is crucial to allow " @@ -1905,7 +1921,7 @@ msgstr "" "Tar 檔案可能包含同一檔案的多個版本。較晚的版本預期會覆蓋較早的版本。此功能對" "於允許更新磁帶封存檔至關重要,但可能被惡意濫用。" -#: ../../library/tarfile.rst:1212 +#: ../../library/tarfile.rst:1219 msgid "" "*tarfile* does not protect against issues with “live” data, e.g. an attacker " "tinkering with the destination (or source) directory while extraction (or " @@ -1914,11 +1930,11 @@ msgstr "" "*tarfile* 不會防止「即時」資料的問題,例如攻擊者在解壓縮(或封存)進行中時篡" "改目的地(或來源)目錄。" -#: ../../library/tarfile.rst:1218 +#: ../../library/tarfile.rst:1225 msgid "Supporting older Python versions" msgstr "支援舊版 Python" -#: ../../library/tarfile.rst:1220 +#: ../../library/tarfile.rst:1227 msgid "" "Extraction filters were added to Python 3.12, but may be backported to older " "versions as security updates. To check whether the feature is available, use " @@ -1929,7 +1945,7 @@ msgstr "" "查此功能是否可用,請使用 ``hasattr(tarfile, 'data_filter')`` 而不是檢查 " "Python 版本。" -#: ../../library/tarfile.rst:1225 +#: ../../library/tarfile.rst:1232 msgid "" "The following examples show how to support Python versions with and without " "the feature. Note that setting ``extraction_filter`` will affect any " @@ -1938,11 +1954,11 @@ msgstr "" "以下範例顯示如何支援有此功能和沒有此功能的 Python 版本。請注意,設定 " "``extraction_filter`` 會影響任何後續操作。" -#: ../../library/tarfile.rst:1229 +#: ../../library/tarfile.rst:1236 msgid "Fully trusted archive::" msgstr "完全信任的封存檔: ::" -#: ../../library/tarfile.rst:1231 +#: ../../library/tarfile.rst:1238 msgid "" "my_tarfile.extraction_filter = (lambda member, path: member)\n" "my_tarfile.extractall()" @@ -1950,7 +1966,7 @@ msgstr "" "my_tarfile.extraction_filter = (lambda member, path: member)\n" "my_tarfile.extractall()" -#: ../../library/tarfile.rst:1234 +#: ../../library/tarfile.rst:1241 msgid "" "Use the ``'data'`` filter if available, but revert to Python 3.11 behavior " "(``'fully_trusted'``) if this feature is not available::" @@ -1958,7 +1974,7 @@ msgstr "" "如果可用則使用 ``'data'`` 篩選器,但如果此功能不可用則使用後備的 Python 3.11 " "的行為(``'fully_trusted'``):" -#: ../../library/tarfile.rst:1237 +#: ../../library/tarfile.rst:1244 msgid "" "my_tarfile.extraction_filter = getattr(tarfile, 'data_filter',\n" " (lambda member, path: member))\n" @@ -1968,19 +1984,19 @@ msgstr "" " (lambda member, path: member))\n" "my_tarfile.extractall()" -#: ../../library/tarfile.rst:1241 +#: ../../library/tarfile.rst:1248 msgid "Use the ``'data'`` filter; *fail* if it is not available::" msgstr "使用 ``'data'`` 篩選器;如果不可用則\\ *失敗*\\ : ::" -#: ../../library/tarfile.rst:1243 +#: ../../library/tarfile.rst:1250 msgid "my_tarfile.extractall(filter=tarfile.data_filter)" msgstr "my_tarfile.extractall(filter=tarfile.data_filter)" -#: ../../library/tarfile.rst:1245 +#: ../../library/tarfile.rst:1252 msgid "or::" msgstr "或: ::" -#: ../../library/tarfile.rst:1247 +#: ../../library/tarfile.rst:1254 msgid "" "my_tarfile.extraction_filter = tarfile.data_filter\n" "my_tarfile.extractall()" @@ -1988,11 +2004,11 @@ msgstr "" "my_tarfile.extraction_filter = tarfile.data_filter\n" "my_tarfile.extractall()" -#: ../../library/tarfile.rst:1250 +#: ../../library/tarfile.rst:1257 msgid "Use the ``'data'`` filter; *warn* if it is not available::" msgstr "使用 ``'data'`` 篩選器;如果不可用則\\ *警告*\\ : ::" -#: ../../library/tarfile.rst:1252 +#: ../../library/tarfile.rst:1259 msgid "" "if hasattr(tarfile, 'data_filter'):\n" " my_tarfile.extractall(filter='data')\n" @@ -2008,11 +2024,11 @@ msgstr "" " warn_the_user('Extracting may be unsafe; consider updating Python')\n" " my_tarfile.extractall()" -#: ../../library/tarfile.rst:1261 +#: ../../library/tarfile.rst:1268 msgid "Stateful extraction filter example" msgstr "有狀態的解壓縮篩選器範例" -#: ../../library/tarfile.rst:1263 +#: ../../library/tarfile.rst:1270 msgid "" "While *tarfile*'s extraction methods take a simple *filter* callable, custom " "filters may be more complex objects with an internal state. It may be useful " @@ -2021,7 +2037,7 @@ msgstr "" "雖然 *tarfile* 的解壓縮方法接受一個簡單的 *filter* 可呼叫物件,但自訂篩選器可" "能是具有內部狀態的更複雜物件。將這些寫成情境管理器可能很有用,像這樣使用: ::" -#: ../../library/tarfile.rst:1267 +#: ../../library/tarfile.rst:1274 msgid "" "with StatefulFilter() as filter_func:\n" " tar.extractall(path, filter=filter_func)" @@ -2029,11 +2045,11 @@ msgstr "" "with StatefulFilter() as filter_func:\n" " tar.extractall(path, filter=filter_func)" -#: ../../library/tarfile.rst:1270 +#: ../../library/tarfile.rst:1277 msgid "Such a filter can be written as, for example::" msgstr "例如,這樣的篩選器可以寫成: ::" -#: ../../library/tarfile.rst:1272 +#: ../../library/tarfile.rst:1279 msgid "" "class StatefulFilter:\n" " def __init__(self):\n" @@ -2063,17 +2079,17 @@ msgstr "" " def __exit__(self, *exc_info):\n" " print(f'{self.file_count} files extracted')" -#: ../../library/tarfile.rst:1292 +#: ../../library/tarfile.rst:1299 msgid "Command-Line Interface" msgstr "命令列介面" -#: ../../library/tarfile.rst:1296 +#: ../../library/tarfile.rst:1303 msgid "" "The :mod:`!tarfile` module provides a simple command-line interface to " "interact with tar archives." msgstr ":mod:`!tarfile` 模組提供了簡單的命令列介面來與 tar 封存檔互動。" -#: ../../library/tarfile.rst:1299 +#: ../../library/tarfile.rst:1306 msgid "" "If you want to create a new tar archive, specify its name after the :option:" "`-c` option and then list the filename(s) that should be included:" @@ -2081,72 +2097,72 @@ msgstr "" "如果你要建立新的 tar 封存檔,請在 :option:`-c` 選項後指定其名稱,然後列出應包" "含的檔案名稱:" -#: ../../library/tarfile.rst:1302 +#: ../../library/tarfile.rst:1309 msgid "$ python -m tarfile -c monty.tar spam.txt eggs.txt" msgstr "$ python -m tarfile -c monty.tar spam.txt eggs.txt" -#: ../../library/tarfile.rst:1306 +#: ../../library/tarfile.rst:1313 msgid "Passing a directory is also acceptable:" msgstr "也可以傳遞目錄:" -#: ../../library/tarfile.rst:1308 +#: ../../library/tarfile.rst:1315 msgid "$ python -m tarfile -c monty.tar life-of-brian_1979/" msgstr "$ python -m tarfile -c monty.tar life-of-brian_1979/" -#: ../../library/tarfile.rst:1312 +#: ../../library/tarfile.rst:1319 msgid "" "If you want to extract a tar archive into the current directory, use the :" "option:`-e` option:" msgstr "如果你要將 tar 封存檔解壓縮到目前目錄,請使用 :option:`-e` 選項:" -#: ../../library/tarfile.rst:1315 +#: ../../library/tarfile.rst:1322 msgid "$ python -m tarfile -e monty.tar" msgstr "$ python -m tarfile -e monty.tar" -#: ../../library/tarfile.rst:1319 +#: ../../library/tarfile.rst:1326 msgid "" "You can also extract a tar archive into a different directory by passing the " "directory's name:" msgstr "你也可以透過傳遞目錄名稱,將 tar 封存檔解壓縮到不同的目錄:" -#: ../../library/tarfile.rst:1322 +#: ../../library/tarfile.rst:1329 msgid "$ python -m tarfile -e monty.tar other-dir/" msgstr "$ python -m tarfile -e monty.tar other-dir/" -#: ../../library/tarfile.rst:1326 +#: ../../library/tarfile.rst:1333 msgid "For a list of the files in a tar archive, use the :option:`-l` option:" msgstr "若要列出 tar 封存檔中的檔案,請使用 :option:`-l` 選項:" -#: ../../library/tarfile.rst:1328 +#: ../../library/tarfile.rst:1335 msgid "$ python -m tarfile -l monty.tar" msgstr "$ python -m tarfile -l monty.tar" -#: ../../library/tarfile.rst:1334 +#: ../../library/tarfile.rst:1341 msgid "Command-line options" msgstr "命令列選項" -#: ../../library/tarfile.rst:1339 +#: ../../library/tarfile.rst:1346 msgid "List files in a tarfile." msgstr "列出 tarfile 中的檔案。" -#: ../../library/tarfile.rst:1344 +#: ../../library/tarfile.rst:1351 msgid "Create tarfile from source files." msgstr "從來源檔案建立 tarfile。" -#: ../../library/tarfile.rst:1349 +#: ../../library/tarfile.rst:1356 msgid "" "Extract tarfile into the current directory if *output_dir* is not specified." msgstr "如果未指定 *output_dir*,則將 tarfile 解壓縮到目前目錄。" -#: ../../library/tarfile.rst:1354 +#: ../../library/tarfile.rst:1361 msgid "Test whether the tarfile is valid or not." msgstr "測試 tarfile 是否有效。" -#: ../../library/tarfile.rst:1358 +#: ../../library/tarfile.rst:1365 msgid "Verbose output." msgstr "詳細輸出。" -#: ../../library/tarfile.rst:1362 +#: ../../library/tarfile.rst:1369 msgid "" "Specifies the *filter* for ``--extract``. See :ref:`tarfile-extraction-" "filter` for details. Only string names are accepted (that is, " @@ -2155,19 +2171,19 @@ msgstr "" "為 ``--extract`` 指定 *filter*。詳見 :ref:`tarfile-extraction-filter`。僅接受" "字串名稱(即 ``fully_trusted``、``tar`` 和 ``data``)。" -#: ../../library/tarfile.rst:1370 +#: ../../library/tarfile.rst:1377 msgid "Examples" msgstr "範例" -#: ../../library/tarfile.rst:1373 +#: ../../library/tarfile.rst:1380 msgid "Reading examples" msgstr "讀取範例" -#: ../../library/tarfile.rst:1375 +#: ../../library/tarfile.rst:1382 msgid "How to extract an entire tar archive to the current working directory::" msgstr "如何將整個 tar 封存檔解壓縮到目前的工作目錄: ::" -#: ../../library/tarfile.rst:1377 +#: ../../library/tarfile.rst:1384 msgid "" "import tarfile\n" "tar = tarfile.open(\"sample.tar.gz\")\n" @@ -2179,7 +2195,7 @@ msgstr "" "tar.extractall(filter='data')\n" "tar.close()" -#: ../../library/tarfile.rst:1382 +#: ../../library/tarfile.rst:1389 msgid "" "How to extract a subset of a tar archive with :meth:`TarFile.extractall` " "using a generator function instead of a list::" @@ -2187,7 +2203,7 @@ msgstr "" "如何使用產生器函式而非串列,來以 :meth:`TarFile.extractall` 解壓縮 tar 封存檔" "的子集: ::" -#: ../../library/tarfile.rst:1385 +#: ../../library/tarfile.rst:1392 msgid "" "import os\n" "import tarfile\n" @@ -2213,13 +2229,13 @@ msgstr "" "tar.extractall(members=py_files(tar))\n" "tar.close()" -#: ../../library/tarfile.rst:1397 +#: ../../library/tarfile.rst:1404 msgid "" "How to read a gzip compressed tar archive and display some member " "information::" msgstr "如何讀取 gzip 壓縮的 tar 封存檔並顯示部分成員資訊: ::" -#: ../../library/tarfile.rst:1399 +#: ../../library/tarfile.rst:1406 msgid "" "import tarfile\n" "tar = tarfile.open(\"sample.tar.gz\", \"r:gz\")\n" @@ -2247,15 +2263,15 @@ msgstr "" " print(\"something else.\")\n" "tar.close()" -#: ../../library/tarfile.rst:1412 +#: ../../library/tarfile.rst:1419 msgid "Writing examples" msgstr "寫入範例" -#: ../../library/tarfile.rst:1414 +#: ../../library/tarfile.rst:1421 msgid "How to create an uncompressed tar archive from a list of filenames::" msgstr "如何從檔案名稱串列建立未壓縮的 tar 封存檔: ::" -#: ../../library/tarfile.rst:1416 +#: ../../library/tarfile.rst:1423 msgid "" "import tarfile\n" "tar = tarfile.open(\"sample.tar\", \"w\")\n" @@ -2269,11 +2285,11 @@ msgstr "" " tar.add(name)\n" "tar.close()" -#: ../../library/tarfile.rst:1422 +#: ../../library/tarfile.rst:1429 msgid "The same example using the :keyword:`with` statement::" msgstr "使用 :keyword:`with` 陳述式的相同範例: ::" -#: ../../library/tarfile.rst:1424 +#: ../../library/tarfile.rst:1431 msgid "" "import tarfile\n" "with tarfile.open(\"sample.tar\", \"w\") as tar:\n" @@ -2285,7 +2301,7 @@ msgstr "" " for name in [\"foo\", \"bar\", \"quux\"]:\n" " tar.add(name)" -#: ../../library/tarfile.rst:1429 +#: ../../library/tarfile.rst:1436 msgid "" "How to create and write an archive to stdout using :data:`sys.stdout.buffer " "` in the *fileobj* parameter in :meth:`TarFile.add`::" @@ -2293,7 +2309,7 @@ msgstr "" "如何在 :meth:`TarFile.add` 的 *fileobj* 參數中使用 :data:`sys.stdout.buffer " "` 建立封存檔並寫入標準輸出:" -#: ../../library/tarfile.rst:1433 +#: ../../library/tarfile.rst:1440 msgid "" "import sys\n" "import tarfile\n" @@ -2309,7 +2325,7 @@ msgstr "" " for name in [\"foo\", \"bar\", \"quux\"]:\n" " tar.add(name)" -#: ../../library/tarfile.rst:1439 +#: ../../library/tarfile.rst:1446 msgid "" "How to create an archive and reset the user information using the *filter* " "parameter in :meth:`TarFile.add`::" @@ -2317,7 +2333,7 @@ msgstr "" "如何在 :meth:`TarFile.add` 中使用 *filter* 參數來建立封存檔並重設使用者資" "訊: ::" -#: ../../library/tarfile.rst:1442 +#: ../../library/tarfile.rst:1449 msgid "" "import tarfile\n" "def reset(tarinfo):\n" @@ -2337,17 +2353,17 @@ msgstr "" "tar.add(\"foo\", filter=reset)\n" "tar.close()" -#: ../../library/tarfile.rst:1455 +#: ../../library/tarfile.rst:1462 msgid "Supported tar formats" msgstr "支援的 tar 格式" -#: ../../library/tarfile.rst:1457 +#: ../../library/tarfile.rst:1464 msgid "" "There are three tar formats that can be created with the :mod:`!tarfile` " "module:" msgstr "使用 :mod:`!tarfile` 模組可以建立三種 tar 格式:" -#: ../../library/tarfile.rst:1459 +#: ../../library/tarfile.rst:1466 msgid "" "The POSIX.1-1988 ustar format (:const:`USTAR_FORMAT`). It supports filenames " "up to a length of at best 256 characters and linknames up to 100 characters. " @@ -2358,7 +2374,7 @@ msgstr "" "和最多 100 個字元的連結名稱。檔案大小上限為 8 GiB。這是一種老舊且受限的格式," "但廣受支援。" -#: ../../library/tarfile.rst:1464 +#: ../../library/tarfile.rst:1471 msgid "" "The GNU tar format (:const:`GNU_FORMAT`). It supports long filenames and " "linknames, files bigger than 8 GiB and sparse files. It is the de facto " @@ -2369,7 +2385,7 @@ msgstr "" "檔案以及稀疏檔案。這是 GNU/Linux 系統上的實際標準。:mod:`!tarfile` 完全支援 " "GNU tar 對長名稱的擴充,但稀疏檔案僅有唯讀支援。" -#: ../../library/tarfile.rst:1469 +#: ../../library/tarfile.rst:1476 msgid "" "The POSIX.1-2001 pax format (:const:`PAX_FORMAT`). It is the most flexible " "format with virtually no limits. It supports long filenames and linknames, " @@ -2385,7 +2401,7 @@ msgstr "" "能;某些舊的或未維護的函式庫可能不支援,但應將 *pax* 封存檔視為普遍支援的 " "*ustar* 格式。這是目前建立新封存檔的預設格式。" -#: ../../library/tarfile.rst:1477 +#: ../../library/tarfile.rst:1484 msgid "" "It extends the existing *ustar* format with extra headers for information " "that cannot be stored otherwise. There are two flavours of pax headers: " @@ -2398,13 +2414,13 @@ msgstr "" "頭(global headers)則對整個封存檔有效並影響所有後續檔案。為了可攜性,pax 標" "頭中的所有資料都使用 *UTF-8* 編碼。" -#: ../../library/tarfile.rst:1483 +#: ../../library/tarfile.rst:1490 msgid "" "There are some more variants of the tar format which can be read, but not " "created:" msgstr "還有一些 tar 格式的變體可以讀取,但無法建立:" -#: ../../library/tarfile.rst:1486 +#: ../../library/tarfile.rst:1493 msgid "" "The ancient V7 format. This is the first tar format from Unix Seventh " "Edition, storing only regular files and directories. Names must not be " @@ -2416,17 +2432,17 @@ msgstr "" "稱不得超過 100 個字元,且沒有使用者/群組名稱資訊。某些封存檔在欄位包含非 " "ASCII 字元時,標頭檢查碼會計算錯誤。" -#: ../../library/tarfile.rst:1491 +#: ../../library/tarfile.rst:1498 msgid "" "The SunOS tar extended format. This format is a variant of the POSIX.1-2001 " "pax format, but is not compatible." msgstr "SunOS tar 擴充格式。此格式是 POSIX.1-2001 pax 格式的變體,但並不相容。" -#: ../../library/tarfile.rst:1497 +#: ../../library/tarfile.rst:1504 msgid "Unicode issues" msgstr "Unicode 議題" -#: ../../library/tarfile.rst:1499 +#: ../../library/tarfile.rst:1506 msgid "" "The tar format was originally conceived to make backups on tape drives with " "the main focus on preserving file system information. Nowadays tar archives " @@ -2448,7 +2464,7 @@ msgstr "" "無法自動偵測封存檔的編碼。pax 格式就是為了解決此問題而設計的。它使用通用字元" "編碼 *UTF-8* 來儲存非 ASCII 中介資料。" -#: ../../library/tarfile.rst:1511 +#: ../../library/tarfile.rst:1518 msgid "" "The details of character conversion in :mod:`!tarfile` are controlled by the " "*encoding* and *errors* keyword arguments of the :class:`TarFile` class." @@ -2456,7 +2472,7 @@ msgstr "" ":mod:`!tarfile` 中字元轉換的細節由 :class:`TarFile` 類別的 *encoding* 和 " "*errors* 關鍵字引數控制。" -#: ../../library/tarfile.rst:1514 +#: ../../library/tarfile.rst:1521 msgid "" "*encoding* defines the character encoding to use for the metadata in the " "archive. The default value is :func:`sys.getfilesystemencoding` or " @@ -2469,7 +2485,7 @@ msgstr "" "取還是寫入,中介資料必須被解碼或編碼。如果 *encoding* 設定不當,此轉換可能會" "失敗。" -#: ../../library/tarfile.rst:1520 +#: ../../library/tarfile.rst:1527 msgid "" "The *errors* argument defines how characters are treated that cannot be " "converted. Possible values are listed in section :ref:`error-handlers`. The " @@ -2480,7 +2496,7 @@ msgstr "" "一節。預設方案是 ``'surrogateescape'``,這也是 Python 用於檔案系統呼叫的方" "案,參見 :ref:`os-filenames`。" -#: ../../library/tarfile.rst:1525 +#: ../../library/tarfile.rst:1532 msgid "" "For :const:`PAX_FORMAT` archives (the default), *encoding* is generally not " "needed because all the metadata is stored using *UTF-8*. *encoding* is only " diff --git a/library/tempfile.po b/library/tempfile.po index ecc07c005e6..818599d8c2d 100644 --- a/library/tempfile.po +++ b/library/tempfile.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-10 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-06-12 15:17+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!tempfile` --- Generate temporary files and directories" msgstr ":mod:`!tempfile` --- 生成臨時檔案和目錄" -#: ../../library/tempfile.rst:9 +#: ../../library/tempfile.rst:7 msgid "**Source code:** :source:`Lib/tempfile.py`" msgstr "**原始碼:**\\ :source:`Lib/tempfile.py`" -#: ../../library/tempfile.rst:17 +#: ../../library/tempfile.rst:15 msgid "" "This module creates temporary files and directories. It works on all " "supported platforms. :class:`TemporaryFile`, :class:`NamedTemporaryFile`, :" @@ -43,7 +43,7 @@ msgstr "" "介面,可作為\\ :term:`情境管理器 (context manager) ` 使用。:" "func:`mkstemp` 和 :func:`mkdtemp` 是低階函式,使用完畢後需手動清理。" -#: ../../library/tempfile.rst:24 +#: ../../library/tempfile.rst:22 msgid "" "All the user-callable functions and constructors take additional arguments " "which allow direct control over the location and name of temporary files and " @@ -58,11 +58,11 @@ msgstr "" "地在共享的臨時目錄中被建立。為了維持向後相容性,引數的順序會稍微奇怪,所以為" "了讓程式更容易被理解,建議使用關鍵字引數。" -#: ../../library/tempfile.rst:32 +#: ../../library/tempfile.rst:30 msgid "The module defines the following user-callable items:" msgstr "這個 module 定義了以下可供使用者呼叫的項目:" -#: ../../library/tempfile.rst:36 +#: ../../library/tempfile.rst:34 msgid "" "Return a :term:`file-like object` that can be used as a temporary storage " "area. The file is created securely, using the same rules as :func:`mkstemp`. " @@ -80,7 +80,7 @@ msgstr "" "不應依賴使用此功能建立的臨時檔案名稱,因為它在檔案系統中的名稱有可能是不可見" "的。" -#: ../../library/tempfile.rst:44 +#: ../../library/tempfile.rst:42 msgid "" "The resulting object can be used as a :term:`context manager` (see :ref:" "`tempfile-examples`). On completion of the context or destruction of the " @@ -90,7 +90,7 @@ msgstr "" "`tempfile-examples`)。完成情境或銷毀臨時檔案物件後,臨時檔案將從檔案系統中刪" "除。" -#: ../../library/tempfile.rst:49 +#: ../../library/tempfile.rst:47 msgid "" "The *mode* parameter defaults to ``'w+b'`` so that the file created can be " "read and written without being closed. Binary mode is used so that it " @@ -103,7 +103,7 @@ msgstr "" "*buffering*、*encoding*、*errors* 和 *newline* 的含義與 :func:`open` 中的相" "同。" -#: ../../library/tempfile.rst:55 +#: ../../library/tempfile.rst:53 msgid "" "The *dir*, *prefix* and *suffix* parameters have the same meaning and " "defaults as with :func:`mkstemp`." @@ -111,7 +111,7 @@ msgstr "" "參數 *dir*、*prefix* 和 *suffix* 的含義和預設值都與它們在 :func:`mkstemp` 中" "的相同。" -#: ../../library/tempfile.rst:58 +#: ../../library/tempfile.rst:56 msgid "" "The returned object is a true file object on POSIX platforms. On other " "platforms, it is a file-like object whose :attr:`!file` attribute is the " @@ -120,7 +120,7 @@ msgstr "" "在 POSIX 平臺上,回傳物件是真實的檔案物件。在其他平臺上,它是一個 file-like " "object,它的 :attr:`!file` 屬性為底層的真實檔案物件。" -#: ../../library/tempfile.rst:62 +#: ../../library/tempfile.rst:60 msgid "" "The :py:const:`os.O_TMPFILE` flag is used if it is available and works " "(Linux-specific, requires Linux kernel 3.11 or later)." @@ -128,15 +128,15 @@ msgstr "" "如果可用且可運作,則使用 :py:const:`os.O_TMPFILE` 旗標(僅限於 Linux,需要 " "3.11 版本以上的核心)。" -#: ../../library/tempfile.rst:65 +#: ../../library/tempfile.rst:63 msgid "" "On platforms that are neither Posix nor Cygwin, TemporaryFile is an alias " "for NamedTemporaryFile." msgstr "" "在不是 Posix 或 Cygwin 的平臺上,TemporaryFile 是 NamedTemporaryFile 的別名。" -#: ../../library/tempfile.rst:68 ../../library/tempfile.rst:137 -#: ../../library/tempfile.rst:275 +#: ../../library/tempfile.rst:66 ../../library/tempfile.rst:135 +#: ../../library/tempfile.rst:273 msgid "" "Raises an :ref:`auditing event ` ``tempfile.mkstemp`` with " "argument ``fullpath``." @@ -144,28 +144,28 @@ msgstr "" "引發一個附帶引數 ``fullpath`` 的 ``tempfile.mkstemp`` :ref:`稽核事件 " "`。" -#: ../../library/tempfile.rst:72 +#: ../../library/tempfile.rst:70 msgid "The :py:const:`os.O_TMPFILE` flag is now used if available." msgstr "如果可用,自此開始使用 :py:const:`os.O_TMPFILE` 旗標。" -#: ../../library/tempfile.rst:74 ../../library/tempfile.rst:139 -#: ../../library/tempfile.rst:169 +#: ../../library/tempfile.rst:72 ../../library/tempfile.rst:137 +#: ../../library/tempfile.rst:167 msgid "Added *errors* parameter." msgstr "新增 *errors* 參數。" -#: ../../library/tempfile.rst:80 +#: ../../library/tempfile.rst:78 msgid "" "This function operates exactly as :func:`TemporaryFile` does, except the " "following differences:" msgstr "此函式的操作與 :func:`TemporaryFile` 完全相同,但存在以下差異:" -#: ../../library/tempfile.rst:83 +#: ../../library/tempfile.rst:81 msgid "" "This function returns a file that is guaranteed to have a visible name in " "the file system." msgstr "此函式回傳一個保證在檔案系統中具有可見名稱的檔案。" -#: ../../library/tempfile.rst:85 +#: ../../library/tempfile.rst:83 msgid "" "To manage the named file, it extends the parameters of :func:`TemporaryFile` " "with *delete* and *delete_on_close* parameters that determine whether and " @@ -174,7 +174,7 @@ msgstr "" "為了管理指定檔案,它使用 *delete* 和 *delete_on_close* 參數擴充 :func:" "`TemporaryFile` 來指定是否以及如何自動刪除指定檔案。" -#: ../../library/tempfile.rst:89 +#: ../../library/tempfile.rst:87 msgid "" "The returned object is always a :term:`file-like object` whose :attr:`!file` " "attribute is the underlying true file object. This file-like object can be " @@ -190,7 +190,7 @@ msgstr "" "屬性中取得。在 Unix 上則與 :func:`TemporaryFile` 不同,目錄條目不會在檔案建立" "後立即被取消鏈接 (unlink)。" -#: ../../library/tempfile.rst:97 +#: ../../library/tempfile.rst:95 msgid "" "If *delete* is true (the default) and *delete_on_close* is true (the " "default), the file is deleted as soon as it is closed. If *delete* is true " @@ -206,7 +206,7 @@ msgstr "" "meth:`object.__del__`\\ )。如果 *delete* 為 false,則會忽略 " "*delete_on_close* 的值。" -#: ../../library/tempfile.rst:104 +#: ../../library/tempfile.rst:102 msgid "" "Therefore to use the name of the temporary file to reopen the file after " "closing it, either make sure not to delete the file upon closure (set the " @@ -220,27 +220,27 @@ msgstr "" "建立,要將 *delete_on_close* 參數設定為 false。建議使用後者,因為它有助於在情" "境管理器退出時自動清理臨時檔案。" -#: ../../library/tempfile.rst:111 +#: ../../library/tempfile.rst:109 msgid "" "Opening the temporary file again by its name while it is still open works as " "follows:" msgstr "在臨時檔案仍處於打開狀態時再次按其名稱打開它,其作用方式如下:" -#: ../../library/tempfile.rst:114 +#: ../../library/tempfile.rst:112 msgid "On POSIX the file can always be opened again." msgstr "在 POSIX 上,檔案始終可以再次打開。" -#: ../../library/tempfile.rst:115 +#: ../../library/tempfile.rst:113 msgid "" "On Windows, make sure that at least one of the following conditions are " "fulfilled:" msgstr "在 Windows 上,確保至少滿足以下條件之一:" -#: ../../library/tempfile.rst:118 +#: ../../library/tempfile.rst:116 msgid "*delete* is false" msgstr "*delete* 為 false" -#: ../../library/tempfile.rst:119 +#: ../../library/tempfile.rst:117 msgid "" "additional open shares delete access (e.g. by calling :func:`os.open` with " "the flag ``O_TEMPORARY``)" @@ -248,7 +248,7 @@ msgstr "" "額外的 open 會共享刪除存取權限(例如,透過使用旗標 ``O_TEMPORARY`` 來呼叫 :" "func:`os.open`\\ )" -#: ../../library/tempfile.rst:121 +#: ../../library/tempfile.rst:119 msgid "" "*delete* is true but *delete_on_close* is false. Note, that in this case the " "additional opens that do not share delete access (e.g. created via builtin :" @@ -261,7 +261,7 @@ msgstr "" "之前關閉,否則情境管理器上的 :func:`os.unlink` 呼叫退出將失敗並出現 :exc:" "`PermissionError`。" -#: ../../library/tempfile.rst:127 +#: ../../library/tempfile.rst:125 msgid "" "On Windows, if *delete_on_close* is false, and the file is created in a " "directory for which the user lacks delete access, then the :func:`os.unlink` " @@ -275,7 +275,7 @@ msgstr "" "發 :exc:`PermissionError`。當 *delete_on_close* 為 true 時,不會發生這種情" "況,因為刪除存取權限是由 open 來要求的,如果未授予存取權限則會立即失敗。" -#: ../../library/tempfile.rst:134 +#: ../../library/tempfile.rst:132 msgid "" "On POSIX (only), a process that is terminated abruptly with SIGKILL cannot " "automatically delete any NamedTemporaryFiles it created." @@ -283,11 +283,11 @@ msgstr "" "(僅)在 POSIX 上,因使用 SIGKILL 而被終止的行程無法自動刪除它建立的任何 " "NamedTemporaryFiles。" -#: ../../library/tempfile.rst:142 +#: ../../library/tempfile.rst:140 msgid "Added *delete_on_close* parameter." msgstr "新增 *delete_on_close* 參數。" -#: ../../library/tempfile.rst:148 +#: ../../library/tempfile.rst:146 msgid "" "This class operates exactly as :func:`TemporaryFile` does, except that data " "is spooled in memory until the file size exceeds *max_size*, or until the " @@ -300,7 +300,7 @@ msgstr "" "方法被呼叫為止,此時資料會被寫入磁碟,並且之後的操作與 :func:`TemporaryFile` " "相同。" -#: ../../library/tempfile.rst:156 +#: ../../library/tempfile.rst:154 msgid "" "The resulting file has one additional method, :meth:`!rollover`, which " "causes the file to roll over to an on-disk file regardless of its size." @@ -308,7 +308,7 @@ msgstr "" "生成的檔案物件有一個額外的方法 :meth:`!rollover`,忽略檔案大小並立即將其寫入" "磁碟。" -#: ../../library/tempfile.rst:159 +#: ../../library/tempfile.rst:157 msgid "" "The returned object is a file-like object whose :attr:`!_file` attribute is " "either an :class:`io.BytesIO` or :class:`io.TextIOWrapper` object (depending " @@ -321,11 +321,11 @@ msgstr "" "字模式)或真實的檔案物件(取決於是否已呼叫 :meth:`rollover`)。file-like " "object 可以像普通檔案一樣在 :keyword:`with` 陳述式中使用。" -#: ../../library/tempfile.rst:166 +#: ../../library/tempfile.rst:164 msgid "the truncate method now accepts a *size* argument." msgstr "現在,檔案的截斷方法 (truncate method) 可接受一個 *size* 引數。" -#: ../../library/tempfile.rst:172 +#: ../../library/tempfile.rst:170 msgid "" "Fully implements the :class:`io.BufferedIOBase` and :class:`io.TextIOBase` " "abstract base classes (depending on whether binary or text *mode* was " @@ -334,7 +334,7 @@ msgstr "" "完全實作 :class:`io.BufferedIOBase` 和 :class:`io.TextIOBase` 抽象基底類別" "(取決於指定的是二進位還是文本 *mode*\\ )。" -#: ../../library/tempfile.rst:180 +#: ../../library/tempfile.rst:178 msgid "" "This class securely creates a temporary directory using the same rules as :" "func:`mkdtemp`. The resulting object can be used as a :term:`context " @@ -347,7 +347,7 @@ msgstr "" "examples`)。在完成情境或銷毀臨時目錄物件時,新建立的臨時目錄及其所有內容會從" "檔案系統中被移除。" -#: ../../library/tempfile.rst:188 +#: ../../library/tempfile.rst:186 msgid "" "The directory name can be retrieved from the :attr:`!name` attribute of the " "returned object. When the returned object is used as a :term:`context " @@ -358,7 +358,7 @@ msgstr "" "term:`情境管理器 `\\ 時,這個 :attr:`!name` 會作為 :keyword:" "`with` 陳述句中 :keyword:`!as` 子句的目標(如果有 as 的話)。" -#: ../../library/tempfile.rst:195 +#: ../../library/tempfile.rst:193 msgid "" "The directory can be explicitly cleaned up by calling the :meth:`!cleanup` " "method. If *ignore_cleanup_errors* is true, any unhandled exceptions during " @@ -376,7 +376,7 @@ msgstr "" "被引發(:meth:`!cleanup` 呼叫、退出情境管理器、物件被作為垃圾回收或直譯器關閉" "等)。" -#: ../../library/tempfile.rst:204 +#: ../../library/tempfile.rst:202 msgid "" "The *delete* parameter can be used to disable cleanup of the directory tree " "upon exiting the context. While it may seem unusual for a context manager " @@ -388,20 +388,20 @@ msgstr "" "時所採取的操作似乎不常見,但它在除錯期間或當你需要基於其他邏輯的清理行為時會" "非常有用。" -#: ../../library/tempfile.rst:212 +#: ../../library/tempfile.rst:210 msgid "" "Cleanup is not robust against the tree being modified while it is removed. " "Files outside of the tree may have their permissions and file flags reset." msgstr "" -#: ../../library/tempfile.rst:215 +#: ../../library/tempfile.rst:213 msgid "" "On systems where :data:`shutil.rmtree.avoids_symlink_attacks` is false, " "manipulating symbolic links during cleanup may cause files outside of the " "tree to be removed." msgstr "" -#: ../../library/tempfile.rst:219 ../../library/tempfile.rst:301 +#: ../../library/tempfile.rst:217 ../../library/tempfile.rst:299 msgid "" "Raises an :ref:`auditing event ` ``tempfile.mkdtemp`` with " "argument ``fullpath``." @@ -409,15 +409,15 @@ msgstr "" "引發一個附帶引數 ``fullpath`` 的 ``tempfile.mkdtemp`` :ref:`稽核事件 " "`。" -#: ../../library/tempfile.rst:223 +#: ../../library/tempfile.rst:221 msgid "Added *ignore_cleanup_errors* parameter." msgstr "新增 *ignore_cleanup_errors* 參數。" -#: ../../library/tempfile.rst:226 +#: ../../library/tempfile.rst:224 msgid "Added the *delete* parameter." msgstr "新增 *delete* 參數。" -#: ../../library/tempfile.rst:232 +#: ../../library/tempfile.rst:230 msgid "" "Creates a temporary file in the most secure manner possible. There are no " "race conditions in the file's creation, assuming that the platform properly " @@ -431,13 +431,13 @@ msgstr "" "況。該檔案只能由建立者讀寫,如果所在平臺用 permission bit(許可權位元)來表示" "檔案是否可執行,則沒有人有執行權。" -#: ../../library/tempfile.rst:239 +#: ../../library/tempfile.rst:237 msgid "" "The file descriptor is :ref:`not inherited by child processes " "`." msgstr "檔案描述器\\ :ref:`不會被子行程繼承 `。" -#: ../../library/tempfile.rst:241 +#: ../../library/tempfile.rst:239 msgid "" "Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible for " "closing the file descriptor (for example, using :func:`os.close`) and " @@ -447,7 +447,7 @@ msgstr "" "述器(例如使用 :func:`os.close`)並刪除該臨時檔案(例如使" "用 :func:`os.remove`)。" -#: ../../library/tempfile.rst:245 +#: ../../library/tempfile.rst:243 msgid "" "If *suffix* is not ``None``, the file name will end with that suffix, " "otherwise there will be no suffix. :func:`mkstemp` does not put a dot " @@ -458,7 +458,7 @@ msgstr "" "func:`mkstemp` 不會在檔名和後綴之間加點 (dot),如果需要加一個點號,請將其放" "在 *suffix* 的開頭。" -#: ../../library/tempfile.rst:250 +#: ../../library/tempfile.rst:248 msgid "" "If *prefix* is not ``None``, the file name will begin with that prefix; " "otherwise, a default prefix is used. The default is the return value of :" @@ -468,7 +468,7 @@ msgstr "" "綴。預設前綴是 :func:`gettempprefix` 或 :func:`gettempprefixb` 函式的回傳值" "(自動呼叫合適的函式)。" -#: ../../library/tempfile.rst:254 +#: ../../library/tempfile.rst:252 msgid "" "If *dir* is not ``None``, the file will be created in that directory; " "otherwise, a default directory is used. The default directory is chosen " @@ -484,7 +484,7 @@ msgstr "" "檔案路徑是使用者友善的,比如透過 ``os.popen()`` 將路徑傳遞給外部命令時仍需要" "加引號 (quoting)。" -#: ../../library/tempfile.rst:262 +#: ../../library/tempfile.rst:260 msgid "" "If any of *suffix*, *prefix*, and *dir* are not ``None``, they must be the " "same type. If they are bytes, the returned name will be bytes instead of " @@ -495,7 +495,7 @@ msgstr "" "型別相同。如果它們是位元組串,則回傳名稱的型別就是位元組串而非字串。如果不想" "遵循預設行為但又想要回傳值是位元組串型別,請傳入 ``suffix=b''``。" -#: ../../library/tempfile.rst:268 +#: ../../library/tempfile.rst:266 msgid "" "If *text* is specified and true, the file is opened in text mode. Otherwise, " "(the default) the file is opened in binary mode." @@ -503,7 +503,7 @@ msgstr "" "如果指定了 *text* 且為真值,檔案會以文字模式開啟。否則,檔案(預設)以二進位" "制模式開啟。" -#: ../../library/tempfile.rst:271 +#: ../../library/tempfile.rst:269 msgid "" ":func:`mkstemp` returns a tuple containing an OS-level handle to an open " "file (as would be returned by :func:`os.open`) and the absolute pathname of " @@ -513,7 +513,7 @@ msgstr "" "level) 控制代碼,指向一個開啟的檔案(如同 :func:`os.open` 的回傳值),第二元" "素是該檔案的絕對路徑。" -#: ../../library/tempfile.rst:277 ../../library/tempfile.rst:303 +#: ../../library/tempfile.rst:275 ../../library/tempfile.rst:301 msgid "" "*suffix*, *prefix*, and *dir* may now be supplied in bytes in order to " "obtain a bytes return value. Prior to this, only str was allowed. *suffix* " @@ -524,11 +524,11 @@ msgstr "" "串型別的回傳值。在之前只允許使用字串。*suffix* 和 *prefix* 現在可以接受 " "``None``,並且預設為 ``None`` 以使用合適的預設值。" -#: ../../library/tempfile.rst:283 ../../library/tempfile.rst:309 +#: ../../library/tempfile.rst:281 ../../library/tempfile.rst:307 msgid "The *dir* parameter now accepts a :term:`path-like object`." msgstr "*dir* 參數現在可接受一個類路徑物件 (:term:`path-like object`)。" -#: ../../library/tempfile.rst:289 +#: ../../library/tempfile.rst:287 msgid "" "Creates a temporary directory in the most secure manner possible. There are " "no race conditions in the directory's creation. The directory is readable, " @@ -537,60 +537,60 @@ msgstr "" "盡可能以最安全的方式建立一個臨時目錄,建立該目錄時不會有 race condition 的情" "況,該目錄只能由建立者讀取、寫入和搜尋。" -#: ../../library/tempfile.rst:293 +#: ../../library/tempfile.rst:291 msgid "" "The user of :func:`mkdtemp` is responsible for deleting the temporary " "directory and its contents when done with it." msgstr ":func:`mkdtemp` 的使用者用完臨時目錄後需要自行將其刪除。" -#: ../../library/tempfile.rst:296 +#: ../../library/tempfile.rst:294 msgid "" "The *prefix*, *suffix*, and *dir* arguments are the same as for :func:" "`mkstemp`." msgstr "" "引數 *prefix*、*suffix* 和 *dir* 的含義與它們在 :func:`mkstemp` 中相同。" -#: ../../library/tempfile.rst:299 +#: ../../library/tempfile.rst:297 msgid ":func:`mkdtemp` returns the absolute pathname of the new directory." msgstr ":func:`mkdtemp` 回傳新目錄的絕對路徑名稱。" -#: ../../library/tempfile.rst:312 +#: ../../library/tempfile.rst:310 msgid "" ":func:`mkdtemp` now always returns an absolute path, even if *dir* is " "relative." msgstr ":func:`mkdtemp` 現在都會回傳絕對路徑,即使 *dir* 是相對路徑。" -#: ../../library/tempfile.rst:318 +#: ../../library/tempfile.rst:316 msgid "" "Return the name of the directory used for temporary files. This defines the " "default value for the *dir* argument to all functions in this module." msgstr "" "回傳儲存臨時檔案的目錄名稱。這設定了此 module 所有函式 *dir* 引數的預設值。" -#: ../../library/tempfile.rst:322 +#: ../../library/tempfile.rst:320 msgid "" "Python searches a standard list of directories to find one which the calling " "user can create files in. The list is:" msgstr "" "Python 搜尋標準目錄列表來找到呼叫者可以在其中建立檔案的目錄。這個列表是:" -#: ../../library/tempfile.rst:325 +#: ../../library/tempfile.rst:323 msgid "The directory named by the :envvar:`TMPDIR` environment variable." msgstr ":envvar:`TMPDIR` 環境變數指向的目錄。" -#: ../../library/tempfile.rst:327 +#: ../../library/tempfile.rst:325 msgid "The directory named by the :envvar:`TEMP` environment variable." msgstr ":envvar:`TEMP` 環境變數指向的目錄。" -#: ../../library/tempfile.rst:329 +#: ../../library/tempfile.rst:327 msgid "The directory named by the :envvar:`TMP` environment variable." msgstr ":envvar:`TMP` 環境變數指向的目錄。" -#: ../../library/tempfile.rst:331 +#: ../../library/tempfile.rst:329 msgid "A platform-specific location:" msgstr "與平臺相關的位置:" -#: ../../library/tempfile.rst:333 +#: ../../library/tempfile.rst:331 msgid "" "On Windows, the directories :file:`%USERPROFILE%\\\\AppData\\\\Local\\" "\\Temp`, :file:`%SYSTEMROOT%\\\\Temp`, :file:`C:\\\\TEMP`, :file:`C:\\" @@ -600,7 +600,7 @@ msgstr "" "\\Temp`、:file:`%SYSTEMROOT%\\\\Temp`、:file:`C:\\\\TEMP`、:file:`C:\\" "\\TMP`、:file:`\\\\TEMP` 和 :file:`\\\\TMP`。" -#: ../../library/tempfile.rst:339 +#: ../../library/tempfile.rst:337 msgid "" "On all other platforms, the directories :file:`/tmp`, :file:`/var/tmp`, and :" "file:`/usr/tmp`, in that order." @@ -608,17 +608,17 @@ msgstr "" "在所有其他平臺上,目錄依次為 :file:`/tmp`、:file:`/var/tmp` 和 :file:`/usr/" "tmp`。" -#: ../../library/tempfile.rst:342 +#: ../../library/tempfile.rst:340 msgid "As a last resort, the current working directory." msgstr "不得已時,使用目前工作目錄。" -#: ../../library/tempfile.rst:344 +#: ../../library/tempfile.rst:342 msgid "" "The result of this search is cached, see the description of :data:`tempdir` " "below." msgstr "搜尋的結果會被 cache(快取)起來,請見下面 :data:`tempdir` 的描述。" -#: ../../library/tempfile.rst:349 +#: ../../library/tempfile.rst:347 msgid "" "Always returns a str. Previously it would return any :data:`tempdir` value " "regardless of type so long as it was not ``None``." @@ -626,21 +626,21 @@ msgstr "" "回傳一個字串。在之前的版本中它會回傳任意 :data:`tempdir` 的值而不考慮它的型" "別,只要它不為 ``None``。" -#: ../../library/tempfile.rst:354 +#: ../../library/tempfile.rst:352 msgid "Same as :func:`gettempdir` but the return value is in bytes." msgstr "與 :func:`gettempdir` 相同,但回傳值為位元組串型別。" -#: ../../library/tempfile.rst:360 +#: ../../library/tempfile.rst:358 msgid "" "Return the filename prefix used to create temporary files. This does not " "contain the directory component." msgstr "回傳用於建立臨時檔案的檔名前綴,它不包含目錄部分。" -#: ../../library/tempfile.rst:365 +#: ../../library/tempfile.rst:363 msgid "Same as :func:`gettempprefix` but the return value is in bytes." msgstr "與 :func:`gettempprefix` 相同,但回傳值為位元組串型別。" -#: ../../library/tempfile.rst:369 +#: ../../library/tempfile.rst:367 msgid "" "The module uses a global variable to store the name of the directory used " "for temporary files returned by :func:`gettempdir`. It can be set directly " @@ -654,7 +654,7 @@ msgstr "" "式都接受一個 *dir* 引數,它可被用於指定目錄。這是個推薦的做法,它不會透過改變" "全域性 API 行為而對其他不預期此行為的程式造成影響。" -#: ../../library/tempfile.rst:378 +#: ../../library/tempfile.rst:376 msgid "" "When set to a value other than ``None``, this variable defines the default " "value for the *dir* argument to the functions defined in this module, " @@ -664,7 +664,7 @@ msgstr "" "預設值,包括確定其型別為位元組串還是字串。它不可以為 :term:`path-like " "object`。" -#: ../../library/tempfile.rst:383 +#: ../../library/tempfile.rst:381 msgid "" "If ``tempdir`` is ``None`` (the default) at any call to any of the above " "functions except :func:`gettempprefix` it is initialized following the " @@ -673,7 +673,7 @@ msgstr "" "如果在呼叫除 :func:`gettempprefix` 外的上述任何函式時 ``tempdir`` 為 " "``None`` (預設值) 則它會按照 :func:`gettempdir` 中所描述的演算法來初始化。" -#: ../../library/tempfile.rst:389 +#: ../../library/tempfile.rst:387 msgid "" "Beware that if you set ``tempdir`` to a bytes value, there is a nasty side " "effect: The global default return type of :func:`mkstemp` and :func:" @@ -687,16 +687,16 @@ msgstr "" "``prefix``、``suffix`` 或 ``dir`` 時被改為位元組串。請不要編寫預期此行為或依" "賴於此行為的程式。這個奇怪的行為是為了維持與以往實作版本的相容性。" -#: ../../library/tempfile.rst:400 +#: ../../library/tempfile.rst:398 msgid "Examples" msgstr "範例" -#: ../../library/tempfile.rst:402 +#: ../../library/tempfile.rst:400 msgid "" "Here are some examples of typical usage of the :mod:`!tempfile` module::" msgstr "以下是 :mod:`!tempfile` module 的一些常見用法範例: ::" -#: ../../library/tempfile.rst:404 +#: ../../library/tempfile.rst:402 msgid "" ">>> import tempfile\n" "\n" @@ -778,11 +778,11 @@ msgstr "" ">>>\n" "# 目錄及其內容已被刪除" -#: ../../library/tempfile.rst:447 +#: ../../library/tempfile.rst:445 msgid "Deprecated functions and variables" msgstr "已棄用的函式和變數" -#: ../../library/tempfile.rst:449 +#: ../../library/tempfile.rst:447 msgid "" "A historical way to create temporary files was to first generate a file name " "with the :func:`mktemp` function and then create a file using this name. " @@ -797,11 +797,11 @@ msgstr "" "之間的時間裡,其他程式可能會使用該名稱建立檔案。解決方案是將兩個步驟結合起" "來,並立即建立檔案。這個方案目前被 :func:`mkstemp` 和上述其他函式所採用。" -#: ../../library/tempfile.rst:460 +#: ../../library/tempfile.rst:458 msgid "Use :func:`mkstemp` instead." msgstr "使用 :func:`mkstemp` 代替。" -#: ../../library/tempfile.rst:463 +#: ../../library/tempfile.rst:461 msgid "" "Return an absolute pathname of a file that did not exist at the time the " "call is made. The *prefix*, *suffix*, and *dir* arguments are similar to " @@ -812,7 +812,7 @@ msgstr "" "與 :func:`mkstemp` 中所用的類似,除了在於不支援位元組串型別的檔名且不支援 " "``suffix=None`` 和 ``prefix=None``。" -#: ../../library/tempfile.rst:470 +#: ../../library/tempfile.rst:468 msgid "" "Use of this function may introduce a security hole in your program. By the " "time you get around to doing anything with the file name it returns, someone " @@ -824,7 +824,7 @@ msgstr "" "作時,可能有人已經捷足先登了。:func:`mktemp` 的功能可以很輕鬆地用帶有 " "``delete=False`` 參數的 :func:`NamedTemporaryFile` 代替: ::" -#: ../../library/tempfile.rst:476 +#: ../../library/tempfile.rst:474 msgid "" ">>> f = NamedTemporaryFile(delete=False)\n" ">>> f.name\n" @@ -846,14 +846,14 @@ msgstr "" ">>> os.path.exists(f.name)\n" "False" -#: ../../library/tempfile.rst:11 +#: ../../library/tempfile.rst:9 msgid "temporary" msgstr "temporary(臨時)" -#: ../../library/tempfile.rst:11 +#: ../../library/tempfile.rst:9 msgid "file name" msgstr "file name(檔案名稱)" -#: ../../library/tempfile.rst:11 +#: ../../library/tempfile.rst:9 msgid "file" msgstr "file(檔案)" diff --git a/library/test.po b/library/test.po index 7fcbea31632..c7eee0085a5 100644 --- a/library/test.po +++ b/library/test.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-12 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:12+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,7 +21,7 @@ msgstr "" msgid ":mod:`!test` --- Regression tests package for Python" msgstr ":mod:`!test` --- Python 的回歸測試 (regression tests) 套件" -#: ../../library/test.rst:10 +#: ../../library/test.rst:8 msgid "" "The :mod:`!test` package is meant for internal use by Python only. It is " "documented for the benefit of the core developers of Python. Any use of this " @@ -30,7 +30,7 @@ msgid "" "Python." msgstr "" -#: ../../library/test.rst:18 +#: ../../library/test.rst:16 msgid "" "The :mod:`!test` package contains all regression tests for Python as well as " "the modules :mod:`test.support` and :mod:`test.regrtest`. :mod:`test." @@ -38,7 +38,7 @@ msgid "" "testing suite." msgstr "" -#: ../../library/test.rst:23 +#: ../../library/test.rst:21 msgid "" "Each module in the :mod:`!test` package whose name starts with ``test_`` is " "a testing suite for a specific module or feature. All new tests should be " @@ -47,27 +47,27 @@ msgid "" "printed to ``sys.stdout``; this style of test is considered deprecated." msgstr "" -#: ../../library/test.rst:32 +#: ../../library/test.rst:30 msgid "Module :mod:`unittest`" msgstr ":mod:`unittest` 模組" -#: ../../library/test.rst:33 +#: ../../library/test.rst:31 msgid "Writing PyUnit regression tests." msgstr "撰寫 PyUnit 回歸測試。" -#: ../../library/test.rst:35 +#: ../../library/test.rst:33 msgid "Module :mod:`doctest`" msgstr ":mod:`doctest` 模組" -#: ../../library/test.rst:36 +#: ../../library/test.rst:34 msgid "Tests embedded in documentation strings." msgstr "鑲嵌在文件字串中的測試。" -#: ../../library/test.rst:42 +#: ../../library/test.rst:40 msgid "Writing Unit Tests for the :mod:`!test` package" msgstr "撰寫 :mod:`!test` 套件的單元測試" -#: ../../library/test.rst:44 +#: ../../library/test.rst:42 msgid "" "It is preferred that tests that use the :mod:`unittest` module follow a few " "guidelines. One is to name the test module by starting it with ``test_`` and " @@ -81,11 +81,11 @@ msgid "" "exist and thus what test is being run is not stated." msgstr "" -#: ../../library/test.rst:55 +#: ../../library/test.rst:53 msgid "A basic boilerplate is often used::" msgstr "" -#: ../../library/test.rst:57 +#: ../../library/test.rst:55 msgid "" "import unittest\n" "from test import support\n" @@ -119,27 +119,27 @@ msgid "" " unittest.main()" msgstr "" -#: ../../library/test.rst:88 +#: ../../library/test.rst:86 msgid "" "This code pattern allows the testing suite to be run by :mod:`test." "regrtest`, on its own as a script that supports the :mod:`unittest` CLI, or " "via the ``python -m unittest`` CLI." msgstr "" -#: ../../library/test.rst:92 +#: ../../library/test.rst:90 msgid "" "The goal for regression testing is to try to break code. This leads to a few " "guidelines to be followed:" msgstr "" -#: ../../library/test.rst:95 +#: ../../library/test.rst:93 msgid "" "The testing suite should exercise all classes, functions, and constants. " "This includes not just the external API that is to be presented to the " "outside world but also \"private\" code." msgstr "" -#: ../../library/test.rst:99 +#: ../../library/test.rst:97 msgid "" "Whitebox testing (examining the code being tested when the tests are being " "written) is preferred. Blackbox testing (testing only the published user " @@ -147,53 +147,53 @@ msgid "" "are tested." msgstr "" -#: ../../library/test.rst:104 +#: ../../library/test.rst:102 msgid "" "Make sure all possible values are tested including invalid ones. This makes " "sure that not only all valid values are acceptable but also that improper " "values are handled correctly." msgstr "" -#: ../../library/test.rst:108 +#: ../../library/test.rst:106 msgid "" "Exhaust as many code paths as possible. Test where branching occurs and thus " "tailor input to make sure as many different paths through the code are taken." msgstr "" -#: ../../library/test.rst:111 +#: ../../library/test.rst:109 msgid "" "Add an explicit test for any bugs discovered for the tested code. This will " "make sure that the error does not crop up again if the code is changed in " "the future." msgstr "" -#: ../../library/test.rst:115 +#: ../../library/test.rst:113 msgid "" "Make sure to clean up after your tests (such as close and remove all " "temporary files)." msgstr "" -#: ../../library/test.rst:118 +#: ../../library/test.rst:116 msgid "" "If a test is dependent on a specific condition of the operating system then " "verify the condition already exists before attempting the test." msgstr "" -#: ../../library/test.rst:121 +#: ../../library/test.rst:119 msgid "" "Import as few modules as possible and do it as soon as possible. This " "minimizes external dependencies of tests and also minimizes possible " "anomalous behavior from side-effects of importing a module." msgstr "" -#: ../../library/test.rst:125 +#: ../../library/test.rst:123 msgid "" "Try to maximize code reuse. On occasion, tests will vary by something as " "small as what type of input is used. Minimize code duplication by " "subclassing a basic test class with a class that specifies the input::" msgstr "" -#: ../../library/test.rst:129 +#: ../../library/test.rst:127 msgid "" "class TestFuncAcceptsSequencesMixin:\n" "\n" @@ -227,7 +227,7 @@ msgstr "" "class AcceptTuples(TestFuncAcceptsSequencesMixin, unittest.TestCase):\n" " arg = (1, 2, 3)" -#: ../../library/test.rst:145 +#: ../../library/test.rst:143 msgid "" "When using this pattern, remember that all classes that inherit from :class:" "`unittest.TestCase` are run as tests. The :class:`!" @@ -236,19 +236,19 @@ msgid "" "`unittest.TestCase`." msgstr "" -#: ../../library/test.rst:153 +#: ../../library/test.rst:151 msgid "Test Driven Development" msgstr "測試驅動開發" -#: ../../library/test.rst:154 +#: ../../library/test.rst:152 msgid "A book by Kent Beck on writing tests before code." msgstr "由 Kent Beck 所著,關於先寫測試再寫程式的書籍。" -#: ../../library/test.rst:160 +#: ../../library/test.rst:158 msgid "Running tests using the command-line interface" msgstr "使用命令列介面執行測試" -#: ../../library/test.rst:165 +#: ../../library/test.rst:163 msgid "" "The :mod:`!test` package can be run as a script to drive Python's regression " "test suite, thanks to the :option:`-m` option: :program:`python -m test`. " @@ -264,7 +264,7 @@ msgid "" "and only print whether the test passed or failed." msgstr "" -#: ../../library/test.rst:178 +#: ../../library/test.rst:176 msgid "" "Running :mod:`!test` directly allows what resources are available for tests " "to use to be set. You do this by using the ``-u`` command-line option. " @@ -277,7 +277,7 @@ msgid "" "resources and more command-line options, run :program:`python -m test -h`." msgstr "" -#: ../../library/test.rst:189 +#: ../../library/test.rst:187 msgid "" "Some other ways to execute the regression tests depend on what platform the " "tests are being executed on. On Unix, you can run :program:`make test` at " @@ -286,167 +286,167 @@ msgid "" "tests." msgstr "" -#: ../../library/test.rst:195 +#: ../../library/test.rst:193 msgid "" "Output is colorized by default and can be :ref:`controlled using environment " "variables `." msgstr "" -#: ../../library/test.rst:201 +#: ../../library/test.rst:199 msgid ":mod:`!test.support` --- Utilities for the Python test suite" msgstr ":mod:`!test.support` --- Python 測試套件的工具" -#: ../../library/test.rst:207 +#: ../../library/test.rst:205 msgid "" "The :mod:`!test.support` module provides support for Python's regression " "test suite." msgstr ":mod:`!test.support` 模組提供 Python 回歸測試套件的支援。" -#: ../../library/test.rst:212 +#: ../../library/test.rst:210 msgid "" ":mod:`!test.support` is not a public module. It is documented here to help " "Python developers write tests. The API of this module is subject to change " "without backwards compatibility concerns between releases." msgstr "" -#: ../../library/test.rst:217 +#: ../../library/test.rst:215 msgid "This module defines the following exceptions:" msgstr "此模組定義了以下例外:" -#: ../../library/test.rst:221 +#: ../../library/test.rst:219 msgid "" "Exception to be raised when a test fails. This is deprecated in favor of :" "mod:`unittest`\\ -based tests and :class:`unittest.TestCase`'s assertion " "methods." msgstr "" -#: ../../library/test.rst:228 +#: ../../library/test.rst:226 msgid "" "Subclass of :exc:`unittest.SkipTest`. Raised when a resource (such as a " "network connection) is not available. Raised by the :func:`requires` " "function." msgstr "" -#: ../../library/test.rst:233 +#: ../../library/test.rst:231 msgid "The :mod:`!test.support` module defines the following constants:" msgstr ":mod:`!test.support` 模組定義了以下常數:" -#: ../../library/test.rst:237 +#: ../../library/test.rst:235 msgid "" "``True`` when verbose output is enabled. Should be checked when more " "detailed information is desired about a running test. *verbose* is set by :" "mod:`test.regrtest`." msgstr "" -#: ../../library/test.rst:244 +#: ../../library/test.rst:242 msgid "``True`` if the running interpreter is Jython." msgstr "如果執行的直譯器是 Jython,則為 ``True``。" -#: ../../library/test.rst:249 +#: ../../library/test.rst:247 msgid "``True`` if ``sys.platform`` is ``android``." msgstr "如果 ``sys.platform`` 是 ``android`` 則為 ``True``。" -#: ../../library/test.rst:254 +#: ../../library/test.rst:252 msgid "``True`` if ``sys.platform`` is ``emscripten``." msgstr "如果 ``sys.platform`` 是 ``emscripten`` 則為 ``True``。" -#: ../../library/test.rst:259 +#: ../../library/test.rst:257 msgid "``True`` if ``sys.platform`` is ``wasi``." msgstr "如果 ``sys.platform`` 是 ``wasi`` 則為 ``True``。" -#: ../../library/test.rst:264 +#: ../../library/test.rst:262 msgid "``True`` if ``sys.platform`` is ``ios``, ``tvos``, or ``watchos``." msgstr "" "如果 ``sys.platform`` 是 ``ios``、``tvos`` 或 ``watchos`` 則為 ``True``。" -#: ../../library/test.rst:269 +#: ../../library/test.rst:267 msgid "" "``True`` if ``sys.platform`` is ``darwin`` or ``is_apple_mobile`` is " "``True``." msgstr "" -#: ../../library/test.rst:274 +#: ../../library/test.rst:272 msgid "Path for shell if not on Windows; otherwise ``None``." msgstr "" -#: ../../library/test.rst:279 +#: ../../library/test.rst:277 msgid "" "Timeout in seconds for tests using a network server listening on the network " "local loopback interface like ``127.0.0.1``." msgstr "" -#: ../../library/test.rst:282 +#: ../../library/test.rst:280 msgid "" "The timeout is long enough to prevent test failure: it takes into account " "that the client and the server can run in different threads or even " "different processes." msgstr "" -#: ../../library/test.rst:286 +#: ../../library/test.rst:284 msgid "" "The timeout should be long enough for :meth:`~socket.socket.connect`, :meth:" "`~socket.socket.recv` and :meth:`~socket.socket.send` methods of :class:" "`socket.socket`." msgstr "" -#: ../../library/test.rst:290 +#: ../../library/test.rst:288 msgid "Its default value is 10 seconds." msgstr "預設值為 10 秒。" -#: ../../library/test.rst:292 +#: ../../library/test.rst:290 msgid "See also :data:`INTERNET_TIMEOUT`." msgstr "另請參閱 :data:`INTERNET_TIMEOUT`。" -#: ../../library/test.rst:297 +#: ../../library/test.rst:295 msgid "Timeout in seconds for network requests going to the internet." msgstr "" -#: ../../library/test.rst:299 +#: ../../library/test.rst:297 msgid "" "The timeout is short enough to prevent a test to wait for too long if the " "internet request is blocked for whatever reason." msgstr "" -#: ../../library/test.rst:302 +#: ../../library/test.rst:300 msgid "" "Usually, a timeout using :data:`INTERNET_TIMEOUT` should not mark a test as " "failed, but skip the test instead: see :func:`~test.support.socket_helper." "transient_internet`." msgstr "" -#: ../../library/test.rst:306 +#: ../../library/test.rst:304 msgid "Its default value is 1 minute." msgstr "預設值為 1 分鐘。" -#: ../../library/test.rst:308 +#: ../../library/test.rst:306 msgid "See also :data:`LOOPBACK_TIMEOUT`." msgstr "另請參閱 :data:`LOOPBACK_TIMEOUT`。" -#: ../../library/test.rst:313 +#: ../../library/test.rst:311 msgid "" "Timeout in seconds to mark a test as failed if the test takes \"too long\"." msgstr "" -#: ../../library/test.rst:315 +#: ../../library/test.rst:313 msgid "" "The timeout value depends on the regrtest ``--timeout`` command line option." msgstr "" -#: ../../library/test.rst:317 +#: ../../library/test.rst:315 msgid "" "If a test using :data:`SHORT_TIMEOUT` starts to fail randomly on slow " "buildbots, use :data:`LONG_TIMEOUT` instead." msgstr "" -#: ../../library/test.rst:320 +#: ../../library/test.rst:318 msgid "Its default value is 30 seconds." msgstr "預設值為 30 秒。" -#: ../../library/test.rst:325 +#: ../../library/test.rst:323 msgid "Timeout in seconds to detect when a test hangs." msgstr "" -#: ../../library/test.rst:327 +#: ../../library/test.rst:325 msgid "" "It is long enough to reduce the risk of test failure on the slowest Python " "buildbots. It should not be used to mark a test as failed if the test takes " @@ -454,11 +454,11 @@ msgid "" "command line option." msgstr "" -#: ../../library/test.rst:332 +#: ../../library/test.rst:330 msgid "Its default value is 5 minutes." msgstr "預設值為 5 分鐘。" -#: ../../library/test.rst:334 +#: ../../library/test.rst:332 msgid "" "See also :data:`LOOPBACK_TIMEOUT`, :data:`INTERNET_TIMEOUT` and :data:" "`SHORT_TIMEOUT`." @@ -466,123 +466,123 @@ msgstr "" "請參閱 :data:`LOOPBACK_TIMEOUT`、:data:`INTERNET_TIMEOUT` 和 :data:" "`SHORT_TIMEOUT`。" -#: ../../library/test.rst:340 +#: ../../library/test.rst:338 msgid "Set when tests can be skipped when they are not useful for PGO." msgstr "" -#: ../../library/test.rst:345 +#: ../../library/test.rst:343 msgid "" "A constant that is likely larger than the underlying OS pipe buffer size, to " "make writes blocking." msgstr "" -#: ../../library/test.rst:351 +#: ../../library/test.rst:349 msgid "" "``True`` if Python was built with the :c:macro:`Py_DEBUG` macro defined, " "that is, if Python was :ref:`built in debug mode `." msgstr "" -#: ../../library/test.rst:360 +#: ../../library/test.rst:358 msgid "" "A constant that is likely larger than the underlying OS socket buffer size, " "to make writes blocking." msgstr "" -#: ../../library/test.rst:366 +#: ../../library/test.rst:364 msgid "Set to the top level directory that contains :mod:`!test.support`." msgstr "設定為包含 :mod:`!test.support` 的頂層目錄。" -#: ../../library/test.rst:371 +#: ../../library/test.rst:369 msgid "Set to the top level directory for the test package." msgstr "設定為測試套件的頂層目錄。" -#: ../../library/test.rst:376 +#: ../../library/test.rst:374 msgid "Set to the ``data`` directory within the test package." msgstr "設定為測試套件中的 ``data`` 目錄。" -#: ../../library/test.rst:381 +#: ../../library/test.rst:379 msgid "Set to :data:`sys.maxsize` for big memory tests." msgstr "設定為 :data:`sys.maxsize` 以進行大記憶體測試。" -#: ../../library/test.rst:386 +#: ../../library/test.rst:384 msgid "" "Set by :func:`set_memlimit` as the memory limit for big memory tests. " "Limited by :data:`MAX_Py_ssize_t`." msgstr "" -#: ../../library/test.rst:392 +#: ../../library/test.rst:390 msgid "" "Set by :func:`set_memlimit` as the memory limit for big memory tests. Not " "limited by :data:`MAX_Py_ssize_t`." msgstr "" -#: ../../library/test.rst:398 +#: ../../library/test.rst:396 msgid "" "Set to ``True`` if Python is built without docstrings (the :c:macro:" "`WITH_DOC_STRINGS` macro is not defined). See the :option:`configure --" "without-doc-strings <--without-doc-strings>` option." msgstr "" -#: ../../library/test.rst:402 +#: ../../library/test.rst:400 msgid "See also the :data:`HAVE_DOCSTRINGS` variable." msgstr "另請參閱 :data:`HAVE_DOCSTRINGS` 變數。" -#: ../../library/test.rst:407 +#: ../../library/test.rst:405 msgid "" "Set to ``True`` if function docstrings are available. See the :option:" "`python -OO <-O>` option, which strips docstrings of functions implemented " "in Python." msgstr "" -#: ../../library/test.rst:410 +#: ../../library/test.rst:408 msgid "See also the :data:`MISSING_C_DOCSTRINGS` variable." msgstr "請參閱 :data:`MISSING_C_DOCSTRINGS` 變數。" -#: ../../library/test.rst:415 +#: ../../library/test.rst:413 msgid "Define the URL of a dedicated HTTP server for the network tests." msgstr "" -#: ../../library/test.rst:420 +#: ../../library/test.rst:418 msgid "Object that is equal to anything. Used to test mixed type comparison." msgstr "" -#: ../../library/test.rst:425 +#: ../../library/test.rst:423 msgid "" "Object that is not equal to anything (even to :data:`ALWAYS_EQ`). Used to " "test mixed type comparison." msgstr "" -#: ../../library/test.rst:431 +#: ../../library/test.rst:429 msgid "" "Object that is greater than anything (except itself). Used to test mixed " "type comparison." msgstr "" -#: ../../library/test.rst:437 +#: ../../library/test.rst:435 msgid "" "Object that is less than anything (except itself). Used to test mixed type " "comparison." msgstr "" -#: ../../library/test.rst:441 +#: ../../library/test.rst:439 msgid "The :mod:`!test.support` module defines the following functions:" msgstr ":mod:`!test.support` 模組定義了以下函式:" -#: ../../library/test.rst:445 +#: ../../library/test.rst:443 msgid "Run the loop body until ``break`` stops the loop." msgstr "執行迴圈主體直到 ``break`` 停止迴圈。" -#: ../../library/test.rst:447 +#: ../../library/test.rst:445 msgid "" "After *timeout* seconds, raise an :exc:`AssertionError` if *error* is true, " "or just stop the loop if *error* is false." msgstr "" -#: ../../library/test.rst:450 +#: ../../library/test.rst:448 msgid "Example::" msgstr "範例: ::" -#: ../../library/test.rst:452 +#: ../../library/test.rst:450 msgid "" "for _ in support.busy_retry(support.SHORT_TIMEOUT):\n" " if check():\n" @@ -592,11 +592,11 @@ msgstr "" " if check():\n" " break" -#: ../../library/test.rst:456 ../../library/test.rst:480 +#: ../../library/test.rst:454 ../../library/test.rst:478 msgid "Example of error=False usage::" msgstr "error=False 用法範例: ::" -#: ../../library/test.rst:458 +#: ../../library/test.rst:456 msgid "" "for _ in support.busy_retry(support.SHORT_TIMEOUT, error=False):\n" " if check():\n" @@ -610,26 +610,26 @@ msgstr "" "else:\n" " raise RuntimeError('my custom error')" -#: ../../library/test.rst:466 +#: ../../library/test.rst:464 msgid "Wait strategy that applies exponential backoff." msgstr "" -#: ../../library/test.rst:468 +#: ../../library/test.rst:466 msgid "" "Run the loop body until ``break`` stops the loop. Sleep at each loop " "iteration, but not at the first iteration. The sleep delay is doubled at " "each iteration (up to *max_delay* seconds)." msgstr "" -#: ../../library/test.rst:472 +#: ../../library/test.rst:470 msgid "See :func:`busy_retry` documentation for the parameters usage." msgstr "請見 :func:`busy_retry` 文件以瞭解參數用法。" -#: ../../library/test.rst:474 +#: ../../library/test.rst:472 msgid "Example raising an exception after SHORT_TIMEOUT seconds::" msgstr "在 SHORT_TIMEOUT 秒後引發例外的範例: ::" -#: ../../library/test.rst:476 +#: ../../library/test.rst:474 msgid "" "for _ in support.sleeping_retry(support.SHORT_TIMEOUT):\n" " if check():\n" @@ -639,7 +639,7 @@ msgstr "" " if check():\n" " break" -#: ../../library/test.rst:482 +#: ../../library/test.rst:480 msgid "" "for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):\n" " if check():\n" @@ -653,28 +653,28 @@ msgstr "" "else:\n" " raise RuntimeError('my custom error')" -#: ../../library/test.rst:490 +#: ../../library/test.rst:488 msgid "" "Return ``True`` if *resource* is enabled and available. The list of " "available resources is only set when :mod:`test.regrtest` is executing the " "tests." msgstr "" -#: ../../library/test.rst:497 +#: ../../library/test.rst:495 msgid "" "Return the value specified for *resource* (as :samp:`-u {resource}={value}" "`). Return ``None`` if *resource* is disabled or no value is specified." msgstr "" -#: ../../library/test.rst:503 +#: ../../library/test.rst:501 msgid "Return ``True`` if Python was not built with ``-O0`` or ``-Og``." msgstr "如果 Python 不是使用 ``-O0`` 或 ``-Og`` 建置則回傳 ``True``。" -#: ../../library/test.rst:508 +#: ../../library/test.rst:506 msgid "Return :const:`_testcapi.WITH_PYMALLOC`." msgstr "回傳 :const:`_testcapi.WITH_PYMALLOC`。" -#: ../../library/test.rst:513 +#: ../../library/test.rst:511 msgid "" "Raise :exc:`ResourceDenied` if *resource* is not available. *msg* is the " "argument to :exc:`ResourceDenied` if it is raised. Always returns ``True`` " @@ -682,88 +682,88 @@ msgid "" "tests are executed by :mod:`test.regrtest`." msgstr "" -#: ../../library/test.rst:521 +#: ../../library/test.rst:519 msgid "Return a repr of *dict* with keys sorted." msgstr "" -#: ../../library/test.rst:526 +#: ../../library/test.rst:524 msgid "" "Return the path to the file named *filename*. If no match is found " "*filename* is returned. This does not equal a failure since it could be the " "path to the file." msgstr "" -#: ../../library/test.rst:530 +#: ../../library/test.rst:528 msgid "" "Setting *subdir* indicates a relative path to use to find the file rather " "than looking directly in the path directories." msgstr "" -#: ../../library/test.rst:536 +#: ../../library/test.rst:534 msgid "Get size of a page in bytes." msgstr "" -#: ../../library/test.rst:543 +#: ../../library/test.rst:541 msgid "" "Set the :func:`sys.setswitchinterval` to the given *interval*. Defines a " "minimum interval for Android systems to prevent the system from hanging." msgstr "" -#: ../../library/test.rst:549 +#: ../../library/test.rst:547 msgid "" "Use this check to guard CPython's implementation-specific tests or to run " "them only on the implementations guarded by the arguments. This function " "returns ``True`` or ``False`` depending on the host platform. Example usage::" msgstr "" -#: ../../library/test.rst:554 +#: ../../library/test.rst:552 msgid "" "check_impl_detail() # Only on CPython (default).\n" "check_impl_detail(jython=True) # Only on Jython.\n" "check_impl_detail(cpython=False) # Everywhere except CPython." msgstr "" -#: ../../library/test.rst:561 +#: ../../library/test.rst:559 msgid "" "Set the values for :data:`max_memuse` and :data:`real_max_memuse` for big " "memory tests." msgstr "" -#: ../../library/test.rst:567 +#: ../../library/test.rst:565 msgid "" "Store the value from *stdout*. It is meant to hold the stdout at the time " "the regrtest began." msgstr "" -#: ../../library/test.rst:573 +#: ../../library/test.rst:571 msgid "" "Return the original stdout set by :func:`record_original_stdout` or ``sys." "stdout`` if it's not set." msgstr "" -#: ../../library/test.rst:579 +#: ../../library/test.rst:577 msgid "" "Return a list of command line arguments reproducing the current settings in " "``sys.flags`` and ``sys.warnoptions``." msgstr "" -#: ../../library/test.rst:585 +#: ../../library/test.rst:583 msgid "" "Return a list of command line arguments reproducing the current optimization " "settings in ``sys.flags``." msgstr "" -#: ../../library/test.rst:593 +#: ../../library/test.rst:591 msgid "" "A context managers that temporarily replaces the named stream with :class:" "`io.StringIO` object." msgstr "" -#: ../../library/test.rst:596 +#: ../../library/test.rst:594 msgid "Example use with output streams::" msgstr "使用輸出串流的範例: ::" -#: ../../library/test.rst:598 +#: ../../library/test.rst:596 msgid "" "with captured_stdout() as stdout, captured_stderr() as stderr:\n" " print(\"hello\")\n" @@ -777,11 +777,11 @@ msgstr "" "assert stdout.getvalue() == \"hello\\n\"\n" "assert stderr.getvalue() == \"error\\n\"" -#: ../../library/test.rst:604 +#: ../../library/test.rst:602 msgid "Example use with input stream::" msgstr "使用輸入串流的範例: ::" -#: ../../library/test.rst:606 +#: ../../library/test.rst:604 msgid "" "with captured_stdin() as stdin:\n" " stdin.write('hello\\n')\n" @@ -791,11 +791,11 @@ msgid "" "self.assertEqual(captured, \"hello\")" msgstr "" -#: ../../library/test.rst:616 +#: ../../library/test.rst:614 msgid "A context manager that temporary disables :mod:`faulthandler`." msgstr "" -#: ../../library/test.rst:621 +#: ../../library/test.rst:619 msgid "" "Force as many objects as possible to be collected. This is needed because " "timely deallocation is not guaranteed by the garbage collector. This means " @@ -803,22 +803,22 @@ msgid "" "remain alive for longer than expected." msgstr "" -#: ../../library/test.rst:629 +#: ../../library/test.rst:627 msgid "" "A context manager that disables the garbage collector on entry. On exit, the " "garbage collector is restored to its prior state." msgstr "" -#: ../../library/test.rst:635 +#: ../../library/test.rst:633 msgid "Context manager to swap out an attribute with a new object." msgstr "" -#: ../../library/test.rst:637 ../../library/test.rst:655 -#: ../../library/test.rst:910 ../../library/test.rst:1442 +#: ../../library/test.rst:635 ../../library/test.rst:653 +#: ../../library/test.rst:908 ../../library/test.rst:1440 msgid "Usage::" msgstr "用法: ::" -#: ../../library/test.rst:639 +#: ../../library/test.rst:637 msgid "" "with swap_attr(obj, \"attr\", 5):\n" " ..." @@ -826,24 +826,24 @@ msgstr "" "with swap_attr(obj, \"attr\", 5):\n" " ..." -#: ../../library/test.rst:642 +#: ../../library/test.rst:640 msgid "" "This will set ``obj.attr`` to 5 for the duration of the ``with`` block, " "restoring the old value at the end of the block. If ``attr`` doesn't exist " "on ``obj``, it will be created and then deleted at the end of the block." msgstr "" -#: ../../library/test.rst:647 ../../library/test.rst:665 +#: ../../library/test.rst:645 ../../library/test.rst:663 msgid "" "The old value (or ``None`` if it doesn't exist) will be assigned to the " "target of the \"as\" clause, if there is one." msgstr "" -#: ../../library/test.rst:653 +#: ../../library/test.rst:651 msgid "Context manager to swap out an item with a new object." msgstr "" -#: ../../library/test.rst:657 +#: ../../library/test.rst:655 msgid "" "with swap_item(obj, \"item\", 5):\n" " ..." @@ -851,80 +851,80 @@ msgstr "" "with swap_item(obj, \"item\", 5):\n" " ..." -#: ../../library/test.rst:660 +#: ../../library/test.rst:658 msgid "" "This will set ``obj[\"item\"]`` to 5 for the duration of the ``with`` block, " "restoring the old value at the end of the block. If ``item`` doesn't exist " "on ``obj``, it will be created and then deleted at the end of the block." msgstr "" -#: ../../library/test.rst:671 +#: ../../library/test.rst:669 msgid "" "Call the ``flush()`` method on :data:`sys.stdout` and then on :data:`sys." "stderr`. It can be used to make sure that the logs order is consistent " "before writing into stderr." msgstr "" -#: ../../library/test.rst:680 +#: ../../library/test.rst:678 msgid "" "Print a warning into :data:`sys.__stderr__`. Format the message as: " "``f\"Warning -- {msg}\"``. If *msg* is made of multiple lines, add " "``\"Warning -- \"`` prefix to each line." msgstr "" -#: ../../library/test.rst:689 +#: ../../library/test.rst:687 msgid "" "Wait until process *pid* completes and check that the process exit code is " "*exitcode*." msgstr "" -#: ../../library/test.rst:692 +#: ../../library/test.rst:690 msgid "" "Raise an :exc:`AssertionError` if the process exit code is not equal to " "*exitcode*." msgstr "如果行程退出代號不等於 *exitcode* 則引發 :exc:`AssertionError`。" -#: ../../library/test.rst:695 +#: ../../library/test.rst:693 msgid "" "If the process runs longer than *timeout* seconds (:data:`SHORT_TIMEOUT` by " "default), kill the process and raise an :exc:`AssertionError`. The timeout " "feature is not available on Windows." msgstr "" -#: ../../library/test.rst:704 +#: ../../library/test.rst:702 msgid "" "Return the size of the :c:type:`PyObject` whose structure members are " "defined by *fmt*. The returned value includes the size of the Python object " "header and alignment." msgstr "" -#: ../../library/test.rst:710 +#: ../../library/test.rst:708 msgid "" "Return the size of the :c:type:`PyVarObject` whose structure members are " "defined by *fmt*. The returned value includes the size of the Python object " "header and alignment." msgstr "" -#: ../../library/test.rst:716 +#: ../../library/test.rst:714 msgid "" "For testcase *test*, assert that the ``sys.getsizeof`` for *o* plus the GC " "header size equals *size*." msgstr "" -#: ../../library/test.rst:722 +#: ../../library/test.rst:720 msgid "" "A decorator to conditionally mark tests with :deco:`unittest." "expectedFailure`. Any use of this decorator should have an associated " "comment identifying the relevant tracker issue." msgstr "" -#: ../../library/test.rst:729 +#: ../../library/test.rst:727 msgid "" "A decorator that skips the decorated test on TLS certification validation " "failures." msgstr "" -#: ../../library/test.rst:734 +#: ../../library/test.rst:732 msgid "" "A decorator for running a function in a different locale, correctly " "resetting it after it has finished. *catstr* is the locale category as a " @@ -932,91 +932,91 @@ msgid "" "sequentially, and the first valid locale will be used." msgstr "" -#: ../../library/test.rst:742 +#: ../../library/test.rst:740 msgid "" "A decorator for running a function in a specific timezone, correctly " "resetting it after it has finished." msgstr "" -#: ../../library/test.rst:748 +#: ../../library/test.rst:746 msgid "" "Decorator for the minimum version when running test on FreeBSD. If the " "FreeBSD version is less than the minimum, the test is skipped." msgstr "" -#: ../../library/test.rst:754 +#: ../../library/test.rst:752 msgid "" "Decorator for the minimum version when running test on Linux. If the Linux " "version is less than the minimum, the test is skipped." msgstr "" -#: ../../library/test.rst:760 +#: ../../library/test.rst:758 msgid "" "Decorator for the minimum version when running test on macOS. If the macOS " "version is less than the minimum, the test is skipped." msgstr "" -#: ../../library/test.rst:766 +#: ../../library/test.rst:764 msgid "" "Decorator for skipping tests on the free-threaded build. If the :term:`GIL` " "is disabled, the test is skipped." msgstr "" -#: ../../library/test.rst:772 +#: ../../library/test.rst:770 msgid "Decorator for skipping tests on non-IEEE 754 platforms." msgstr "" -#: ../../library/test.rst:777 +#: ../../library/test.rst:775 msgid "Decorator for skipping tests if :mod:`zlib` doesn't exist." msgstr "如果 :mod:`zlib` 不存在則跳過測試的裝飾器。" -#: ../../library/test.rst:782 +#: ../../library/test.rst:780 msgid "Decorator for skipping tests if :mod:`gzip` doesn't exist." msgstr "如果 :mod:`gzip` 不存在則跳過測試的裝飾器。" -#: ../../library/test.rst:787 +#: ../../library/test.rst:785 msgid "Decorator for skipping tests if :mod:`bz2` doesn't exist." msgstr "如果 :mod:`bz2` 不存在則跳過測試的裝飾器。" -#: ../../library/test.rst:792 +#: ../../library/test.rst:790 msgid "Decorator for skipping tests if :mod:`lzma` doesn't exist." msgstr "如果 :mod:`lzma` 不存在則跳過測試的裝飾器。" -#: ../../library/test.rst:797 +#: ../../library/test.rst:795 msgid "Decorator for skipping tests if *resource* is not available." msgstr "如果 *resource* 不可用則跳過測試的裝飾器。" -#: ../../library/test.rst:802 +#: ../../library/test.rst:800 msgid "Decorator for only running the test if :data:`HAVE_DOCSTRINGS`." msgstr "" -#: ../../library/test.rst:807 +#: ../../library/test.rst:805 msgid "" "Decorator for only running the test if :ref:`Limited C API ` " "is available." msgstr "" -#: ../../library/test.rst:813 +#: ../../library/test.rst:811 msgid "Decorator for tests only applicable to CPython." msgstr "" -#: ../../library/test.rst:818 +#: ../../library/test.rst:816 msgid "" "Decorator for invoking :func:`check_impl_detail` on *guards*. If that " "returns ``False``, then uses *msg* as the reason for skipping the test." msgstr "" -#: ../../library/test.rst:823 +#: ../../library/test.rst:821 msgid "" "Decorator for marking tests as thread-unsafe. This test always runs in one " "thread even when invoked with ``--parallel-threads``." msgstr "" -#: ../../library/test.rst:829 +#: ../../library/test.rst:827 msgid "Decorator to temporarily turn off tracing for the duration of the test." msgstr "" -#: ../../library/test.rst:834 +#: ../../library/test.rst:832 msgid "" "Decorator for tests which involve reference counting. The decorator does " "not run the test if it is not run by CPython. Any trace function is unset " @@ -1024,11 +1024,11 @@ msgid "" "trace function." msgstr "" -#: ../../library/test.rst:842 +#: ../../library/test.rst:840 msgid "Decorator for bigmem tests." msgstr "大記憶體測試的裝飾器。" -#: ../../library/test.rst:844 +#: ../../library/test.rst:842 msgid "" "*size* is a requested size for the test (in arbitrary, test-interpreted " "units.) *memuse* is the number of bytes per unit for the test, or a good " @@ -1036,7 +1036,7 @@ msgid "" "each, could be decorated with ``@bigmemtest(size=_4G, memuse=2)``." msgstr "" -#: ../../library/test.rst:849 +#: ../../library/test.rst:847 msgid "" "The *size* argument is normally passed to the decorated test method as an " "extra argument. If *dry_run* is ``True``, the value passed to the test " @@ -1044,11 +1044,11 @@ msgid "" "means the test doesn't support dummy runs when ``-M`` is not specified." msgstr "" -#: ../../library/test.rst:857 +#: ../../library/test.rst:855 msgid "Decorator for tests that fill the address space." msgstr "" -#: ../../library/test.rst:862 +#: ../../library/test.rst:860 msgid "" "Return ``False`` if there is no evidence the interpreter was compiled with " "``musl``, otherwise return a version triple, either ``(0, 0, 0)`` if the " @@ -1057,7 +1057,7 @@ msgid "" "compiled with ``musl``; otherwise ``platform.libc_ver`` is checked." msgstr "" -#: ../../library/test.rst:871 +#: ../../library/test.rst:869 msgid "" "Test for syntax errors in *statement* by attempting to compile *statement*. " "*testcase* is the :mod:`unittest` instance for the test. *errtext* is the " @@ -1067,44 +1067,44 @@ msgid "" "of the exception." msgstr "" -#: ../../library/test.rst:881 +#: ../../library/test.rst:879 msgid "Open *url*. If open fails, raises :exc:`TestFailed`." msgstr "" -#: ../../library/test.rst:886 +#: ../../library/test.rst:884 msgid "" "Use this at the end of ``test_main`` whenever sub-processes are started. " "This will help ensure that no extra children (zombies) stick around to hog " "resources and create problems when looking for refleaks." msgstr "" -#: ../../library/test.rst:893 +#: ../../library/test.rst:891 msgid "" "Get an attribute, raising :exc:`unittest.SkipTest` if :exc:`AttributeError` " "is raised." msgstr "" -#: ../../library/test.rst:899 +#: ../../library/test.rst:897 msgid "" "Context manager catching unraisable exception using :func:`sys." "unraisablehook`." msgstr "" -#: ../../library/test.rst:902 +#: ../../library/test.rst:900 msgid "" "Storing the exception value (``cm.unraisable.exc_value``) creates a " "reference cycle. The reference cycle is broken explicitly when the context " "manager exits." msgstr "" -#: ../../library/test.rst:906 +#: ../../library/test.rst:904 msgid "" "Storing the object (``cm.unraisable.object``) can resurrect it if it is set " "to an object which is being finalized. Exiting the context manager clears " "the stored object." msgstr "" -#: ../../library/test.rst:912 +#: ../../library/test.rst:910 msgid "" "with support.catch_unraisable_exception() as cm:\n" " # code creating an \"unraisable exception\"\n" @@ -1117,7 +1117,7 @@ msgid "" "# (to break a reference cycle)" msgstr "" -#: ../../library/test.rst:927 +#: ../../library/test.rst:925 msgid "" "Generic implementation of the :mod:`unittest` ``load_tests`` protocol for " "use in test packages. *pkg_dir* is the root directory of the package; " @@ -1126,7 +1126,7 @@ msgid "" "the following::" msgstr "" -#: ../../library/test.rst:933 +#: ../../library/test.rst:931 msgid "" "import os\n" "from test.support import load_package_tests\n" @@ -1140,14 +1140,14 @@ msgstr "" "def load_tests(*args):\n" " return load_package_tests(os.path.dirname(__file__), *args)" -#: ../../library/test.rst:942 +#: ../../library/test.rst:940 msgid "" "Returns the set of attributes, functions or methods of *ref_api* not found " "on *other_api*, except for a defined list of items to be ignored in this " "check specified in *ignore*." msgstr "" -#: ../../library/test.rst:946 +#: ../../library/test.rst:944 msgid "" "By default this skips private attributes beginning with '_' but includes all " "magic methods, i.e. those starting and ending in '__'." @@ -1155,20 +1155,20 @@ msgstr "" "這預設會跳過以 '_' 開頭的私有屬性,但會包含所有魔術方法,即以 '__' 開頭和結尾" "的方法。" -#: ../../library/test.rst:954 +#: ../../library/test.rst:952 msgid "" "Override *object_to_patch.attr_name* with *new_value*. Also add cleanup " "procedure to *test_instance* to restore *object_to_patch* for *attr_name*. " "The *attr_name* should be a valid attribute for *object_to_patch*." msgstr "" -#: ../../library/test.rst:962 +#: ../../library/test.rst:960 msgid "" "Run *code* in subinterpreter. Raise :exc:`unittest.SkipTest` if :mod:" "`tracemalloc` is enabled." msgstr "" -#: ../../library/test.rst:970 +#: ../../library/test.rst:968 msgid "" "Decorator that runs the decorated test in a fresh interpreter subprocess, in " "isolation, so that it does not share global or interpreter state with the " @@ -1181,7 +1181,7 @@ msgid "" "exception." msgstr "" -#: ../../library/test.rst:980 +#: ../../library/test.rst:978 msgid "" "When a **method** is decorated, only that method runs in a subprocess; all " "fixtures (:meth:`~unittest.TestCase.setUp` / :meth:`~unittest.TestCase." @@ -1190,7 +1190,7 @@ msgid "" "parent process (as usual) and in the subprocess around the method." msgstr "" -#: ../../library/test.rst:986 +#: ../../library/test.rst:984 msgid "" "When a **class** is decorated, the whole class runs in a single subprocess, " "and :meth:`~unittest.TestCase.setUpClass`, :meth:`~unittest.TestCase." @@ -1202,7 +1202,7 @@ msgid "" "too; test it with :data:`runningInSubprocess` if needed." msgstr "" -#: ../../library/test.rst:996 +#: ../../library/test.rst:994 msgid "" "The subprocess inherits the enabled resources (``-u``), memory limit (``-" "M``) and verbosity (``-v``) of the parent test run, so that :func:`~test." @@ -1210,7 +1210,7 @@ msgid "" "support.bigmemtest` and the like behave consistently in both processes." msgstr "" -#: ../../library/test.rst:1002 +#: ../../library/test.rst:1000 msgid "" "*options* is a sequence of interpreter command line options to run the " "subprocess with, and *env* is a mapping of environment variables to set in " @@ -1219,18 +1219,18 @@ msgid "" "ignore the ``PYTHON*`` environment variables, including :envvar:`PYTHONPATH`." msgstr "" -#: ../../library/test.rst:1010 +#: ../../library/test.rst:1008 msgid "" "*timeout* is the number of seconds to wait for the subprocess; the test is " "reported as an error if it does not complete in time. By default there is no " "timeout, and a hung test is left to the timeout of the test runner." msgstr "" -#: ../../library/test.rst:1015 +#: ../../library/test.rst:1013 msgid "The test is skipped on platforms without subprocess support." msgstr "" -#: ../../library/test.rst:1020 +#: ../../library/test.rst:1018 msgid "" "``True`` while the code runs in the isolated subprocess spawned by :func:" "`runInSubprocess`, and ``False`` otherwise (including in the parent process " @@ -1241,29 +1241,29 @@ msgid "" "to run in the subprocess." msgstr "" -#: ../../library/test.rst:1034 +#: ../../library/test.rst:1032 msgid "Assert instances of *cls* are deallocated after iterating." msgstr "" -#: ../../library/test.rst:1039 +#: ../../library/test.rst:1037 msgid "" "Check for the existence of the compiler executables whose names are listed " "in *cmd_names* or all the compiler executables when *cmd_names* is empty and " "return the first missing executable or ``None`` when none is found missing." msgstr "" -#: ../../library/test.rst:1047 +#: ../../library/test.rst:1045 msgid "" "Assert that the ``__all__`` variable of *module* contains all public names." msgstr "" -#: ../../library/test.rst:1049 +#: ../../library/test.rst:1047 msgid "" "The module's public names (its API) are detected automatically based on " "whether they match the public name convention and were defined in *module*." msgstr "" -#: ../../library/test.rst:1053 +#: ../../library/test.rst:1051 msgid "" "The *name_of_module* argument can specify (as a string or tuple thereof) " "what module(s) an API could be defined in order to be detected as a public " @@ -1271,7 +1271,7 @@ msgid "" "other modules, possibly a C backend (like ``csv`` and its ``_csv``)." msgstr "" -#: ../../library/test.rst:1058 +#: ../../library/test.rst:1056 msgid "" "The *extra* argument can be a set of names that wouldn't otherwise be " "automatically detected as \"public\", like objects without a proper :attr:" @@ -1279,17 +1279,17 @@ msgid "" "automatically detected ones." msgstr "" -#: ../../library/test.rst:1062 +#: ../../library/test.rst:1060 msgid "" "The *not_exported* argument can be a set of names that must not be treated " "as part of the public API even though their names indicate otherwise." msgstr "" -#: ../../library/test.rst:1065 ../../library/test.rst:1702 +#: ../../library/test.rst:1063 ../../library/test.rst:1726 msgid "Example use::" msgstr "用法範例: ::" -#: ../../library/test.rst:1067 +#: ../../library/test.rst:1065 msgid "" "import bar\n" "import foo\n" @@ -1309,18 +1309,18 @@ msgid "" " extra=extra, not_exported=not_exported)" msgstr "" -#: ../../library/test.rst:1088 +#: ../../library/test.rst:1086 msgid "" "Skip tests if the :mod:`multiprocessing.synchronize` module is missing, if " "there is no available semaphore implementation, or if creating a lock raises " "an :exc:`OSError`." msgstr "" -#: ../../library/test.rst:1097 +#: ../../library/test.rst:1095 msgid "Assert that type *tp* cannot be instantiated using *args* and *kwds*." msgstr "" -#: ../../library/test.rst:1104 +#: ../../library/test.rst:1102 msgid "" "This function returns a context manager that will change the global :func:" "`sys.set_int_max_str_digits` setting for the duration of the context to " @@ -1328,73 +1328,73 @@ msgid "" "digits when converting between an integer and string." msgstr "" -#: ../../library/test.rst:1112 +#: ../../library/test.rst:1110 msgid "The :mod:`!test.support` module defines the following classes:" msgstr ":mod:`!test.support` 模組定義了以下類別:" -#: ../../library/test.rst:1117 +#: ../../library/test.rst:1115 msgid "" "A context manager used to try to prevent crash dialog popups on tests that " "are expected to crash a subprocess." msgstr "" -#: ../../library/test.rst:1120 +#: ../../library/test.rst:1118 msgid "" "On Windows, it disables Windows Error Reporting dialogs using `SetErrorMode " "`_." msgstr "" -#: ../../library/test.rst:1123 +#: ../../library/test.rst:1121 msgid "" "On UNIX, :func:`resource.setrlimit` is used to set :const:`resource." "RLIMIT_CORE`'s soft limit to 0 to prevent coredump file creation." msgstr "" -#: ../../library/test.rst:1127 +#: ../../library/test.rst:1125 msgid "" "On both platforms, the old value is restored by :meth:`~object.__exit__`." msgstr "在兩個平台上,舊值會被 :meth:`~object.__exit__` 還原。" -#: ../../library/test.rst:1132 +#: ../../library/test.rst:1130 msgid "" "Class to save and restore signal handlers registered by the Python signal " "handler." msgstr "" -#: ../../library/test.rst:1137 +#: ../../library/test.rst:1135 msgid "" "Save the signal handlers to a dictionary mapping signal numbers to the " "current signal handler." msgstr "" -#: ../../library/test.rst:1142 +#: ../../library/test.rst:1140 msgid "" "Set the signal numbers from the :meth:`save` dictionary to the saved handler." msgstr "" -#: ../../library/test.rst:1150 +#: ../../library/test.rst:1148 msgid "Try to match a single dict with the supplied arguments." msgstr "" -#: ../../library/test.rst:1155 +#: ../../library/test.rst:1153 msgid "Try to match a single stored value (*dv*) with a supplied value (*v*)." msgstr "" -#: ../../library/test.rst:1159 +#: ../../library/test.rst:1157 msgid ":mod:`!test.support.socket_helper` --- Utilities for socket tests" msgstr ":mod:`!test.support.socket_helper` --- 用於 socket 測試的工具" -#: ../../library/test.rst:1165 +#: ../../library/test.rst:1163 msgid "" "The :mod:`!test.support.socket_helper` module provides support for socket " "tests." msgstr ":mod:`!test.support.socket_helper` 模組提供 socket 測試的支援。" -#: ../../library/test.rst:1172 +#: ../../library/test.rst:1170 msgid "Set to ``True`` if IPv6 is enabled on this host, ``False`` otherwise." msgstr "" -#: ../../library/test.rst:1177 +#: ../../library/test.rst:1175 msgid "" "Returns an unused port that should be suitable for binding. This is " "achieved by creating a temporary socket with the same family and type as the " @@ -1405,7 +1405,7 @@ msgid "" "port is returned." msgstr "" -#: ../../library/test.rst:1186 +#: ../../library/test.rst:1184 msgid "" "Either this method or :func:`bind_port` should be used for any tests where a " "server socket needs to be bound to a particular port for the duration of the " @@ -1418,7 +1418,7 @@ msgid "" "simultaneously, which is a problem for buildbots." msgstr "" -#: ../../library/test.rst:1200 +#: ../../library/test.rst:1198 msgid "" "Bind the socket to a free port and return the port number. Relies on " "ephemeral ports in order to ensure we are using an unbound port. This is " @@ -1431,7 +1431,7 @@ msgid "" "testing multicasting via multiple UDP sockets." msgstr "" -#: ../../library/test.rst:1211 +#: ../../library/test.rst:1209 msgid "" "Additionally, if the :const:`~socket.SO_EXCLUSIVEADDRUSE` socket option is " "available (i.e. on Windows), it will be set on the socket. This will " @@ -1439,59 +1439,59 @@ msgid "" "test." msgstr "" -#: ../../library/test.rst:1219 +#: ../../library/test.rst:1217 msgid "" "Bind a Unix socket, raising :exc:`unittest.SkipTest` if :exc:" "`PermissionError` is raised." msgstr "" -#: ../../library/test.rst:1225 +#: ../../library/test.rst:1223 msgid "" "A decorator for running tests that require a functional ``bind()`` for Unix " "sockets." msgstr "" -#: ../../library/test.rst:1231 +#: ../../library/test.rst:1229 msgid "" "A context manager that raises :exc:`~test.support.ResourceDenied` when " "various issues with the internet connection manifest themselves as " "exceptions." msgstr "" -#: ../../library/test.rst:1237 +#: ../../library/test.rst:1235 msgid "" ":mod:`!test.support.script_helper` --- Utilities for the Python execution " "tests" msgstr ":mod:`!test.support.script_helper` --- 用於 Python 執行測試的工具" -#: ../../library/test.rst:1243 +#: ../../library/test.rst:1241 msgid "" "The :mod:`!test.support.script_helper` module provides support for Python's " "script execution tests." msgstr "" ":mod:`!test.support.script_helper` 模組提供 Python 的腳本執行測試的支援。" -#: ../../library/test.rst:1248 +#: ../../library/test.rst:1246 msgid "" "Return ``True`` if ``sys.executable interpreter`` requires environment " "variables in order to be able to run at all." msgstr "" -#: ../../library/test.rst:1251 +#: ../../library/test.rst:1249 msgid "" "This is designed to be used with ``@unittest.skipIf()`` to annotate tests " "that need to use an ``assert_python*()`` function to launch an isolated mode " "(``-I``) or no environment mode (``-E``) sub-interpreter process." msgstr "" -#: ../../library/test.rst:1255 +#: ../../library/test.rst:1253 msgid "" "A normal build & test does not run into this situation but it can happen " "when trying to run the standard library test suite from an interpreter that " "doesn't have an obvious home with Python's current home finding logic." msgstr "" -#: ../../library/test.rst:1259 +#: ../../library/test.rst:1257 msgid "" "Setting :envvar:`PYTHONHOME` is one way to get most of the testsuite to run " "in that situation. :envvar:`PYTHONPATH` or :envvar:`PYTHONUSERSITE` are " @@ -1499,85 +1499,85 @@ msgid "" "interpreter can start." msgstr "" -#: ../../library/test.rst:1267 +#: ../../library/test.rst:1265 msgid "" "Set up the environment based on *env_vars* for running the interpreter in a " "subprocess. The values can include ``__isolated``, ``__cleanenv``, " "``__cwd``, and ``TERM``." msgstr "" -#: ../../library/test.rst:1271 ../../library/test.rst:1287 -#: ../../library/test.rst:1299 +#: ../../library/test.rst:1269 ../../library/test.rst:1285 +#: ../../library/test.rst:1297 msgid "The function no longer strips whitespaces from *stderr*." msgstr "此函式不再從 *stderr* 中移除空白。" -#: ../../library/test.rst:1277 +#: ../../library/test.rst:1275 msgid "" "Assert that running the interpreter with *args* and optional environment " "variables *env_vars* succeeds (``rc == 0``) and return a ``(return code, " "stdout, stderr)`` tuple." msgstr "" -#: ../../library/test.rst:1281 +#: ../../library/test.rst:1279 msgid "" "If the *__cleanenv* keyword-only parameter is set, *env_vars* is used as a " "fresh environment." msgstr "" -#: ../../library/test.rst:1284 +#: ../../library/test.rst:1282 msgid "" "Python is started in isolated mode (command line option ``-I``), except if " "the *__isolated* keyword-only parameter is set to ``False``." msgstr "" -#: ../../library/test.rst:1293 +#: ../../library/test.rst:1291 msgid "" "Assert that running the interpreter with *args* and optional environment " "variables *env_vars* fails (``rc != 0``) and return a ``(return code, " "stdout, stderr)`` tuple." msgstr "" -#: ../../library/test.rst:1297 +#: ../../library/test.rst:1295 msgid "See :func:`assert_python_ok` for more options." msgstr "更多選項請見 :func:`assert_python_ok`。" -#: ../../library/test.rst:1305 +#: ../../library/test.rst:1303 msgid "Run a Python subprocess with the given arguments." msgstr "" -#: ../../library/test.rst:1307 +#: ../../library/test.rst:1305 msgid "" "*kw* is extra keyword args to pass to :func:`subprocess.Popen`. Returns a :" "class:`subprocess.Popen` object." msgstr "" -#: ../../library/test.rst:1313 +#: ../../library/test.rst:1311 msgid "" "Run the given :class:`subprocess.Popen` process until completion and return " "stdout." msgstr "" -#: ../../library/test.rst:1319 +#: ../../library/test.rst:1317 msgid "" "Create script containing *source* in path *script_dir* and " "*script_basename*. If *omit_suffix* is ``False``, append ``.py`` to the " "name. Return the full script path." msgstr "" -#: ../../library/test.rst:1326 +#: ../../library/test.rst:1324 msgid "" "Create zip file at *zip_dir* and *zip_basename* with extension ``zip`` which " "contains the files in *script_name*. *name_in_zip* is the archive name. " "Return a tuple containing ``(full path, full path of archive name)``." msgstr "" -#: ../../library/test.rst:1333 +#: ../../library/test.rst:1331 msgid "" "Create a directory named *pkg_dir* containing an ``__init__`` file with " "*init_source* as its contents." msgstr "" -#: ../../library/test.rst:1340 +#: ../../library/test.rst:1338 msgid "" "Create a zip package directory with a path of *zip_dir* and *zip_basename* " "containing an empty ``__init__`` file and a file *script_basename* " @@ -1586,62 +1586,62 @@ msgid "" "path and the archive name for the zip file." msgstr "" -#: ../../library/test.rst:1348 +#: ../../library/test.rst:1346 msgid "" ":mod:`!test.support.bytecode_helper` --- Support tools for testing correct " "bytecode generation" msgstr "" ":mod:`!test.support.bytecode_helper` --- 用於測試位元組碼能正確產生的支援工具" -#: ../../library/test.rst:1353 +#: ../../library/test.rst:1351 msgid "" "The :mod:`!test.support.bytecode_helper` module provides support for testing " "and inspecting bytecode generation." msgstr "" ":mod:`!test.support.bytecode_helper` 模組提供測試和檢查位元組碼產生的支援。" -#: ../../library/test.rst:1358 +#: ../../library/test.rst:1356 msgid "The module defines the following class:" msgstr "此模組定義了以下類別:" -#: ../../library/test.rst:1362 +#: ../../library/test.rst:1360 msgid "This class has custom assertion methods for inspecting bytecode." msgstr "" -#: ../../library/test.rst:1366 +#: ../../library/test.rst:1364 msgid "Return the disassembly of *co* as string." msgstr "" -#: ../../library/test.rst:1371 +#: ../../library/test.rst:1369 msgid "" "Return instr if *opname* is found, otherwise throws :exc:`AssertionError`." msgstr "" -#: ../../library/test.rst:1376 +#: ../../library/test.rst:1374 msgid "Throws :exc:`AssertionError` if *opname* is found." msgstr "" -#: ../../library/test.rst:1380 +#: ../../library/test.rst:1378 msgid ":mod:`!test.support.threading_helper` --- Utilities for threading tests" msgstr ":mod:`!test.support.threading_helper` --- 用於 threading 測試的工具" -#: ../../library/test.rst:1385 +#: ../../library/test.rst:1383 msgid "" "The :mod:`!test.support.threading_helper` module provides support for " "threading tests." msgstr ":mod:`!test.support.threading_helper` 模組提供 threading 測試的支援。" -#: ../../library/test.rst:1392 +#: ../../library/test.rst:1390 msgid "" "Join a *thread* within *timeout*. Raise an :exc:`AssertionError` if thread " "is still alive after *timeout* seconds." msgstr "" -#: ../../library/test.rst:1398 +#: ../../library/test.rst:1396 msgid "Decorator to ensure the threads are cleaned up even if the test fails." msgstr "" -#: ../../library/test.rst:1403 +#: ../../library/test.rst:1401 msgid "" "Context manager to start *threads*, which is a sequence of threads. *unlock* " "is a function called after the threads are started, even if an exception was " @@ -1649,57 +1649,57 @@ msgid "" "will attempt to join the started threads upon exit." msgstr "" -#: ../../library/test.rst:1411 +#: ../../library/test.rst:1409 msgid "" "Cleanup up threads not specified in *original_values*. Designed to emit a " "warning if a test leaves running threads in the background." msgstr "" -#: ../../library/test.rst:1417 +#: ../../library/test.rst:1415 msgid "Return current thread count and copy of dangling threads." msgstr "" -#: ../../library/test.rst:1422 +#: ../../library/test.rst:1420 msgid "" "Context manager to wait until all threads created in the ``with`` statement " "exit." msgstr "" -#: ../../library/test.rst:1428 +#: ../../library/test.rst:1426 msgid "" "Context manager catching :class:`threading.Thread` exception using :func:" "`threading.excepthook`." msgstr "" -#: ../../library/test.rst:1431 +#: ../../library/test.rst:1429 msgid "Attributes set when an exception is caught:" msgstr "當捕捉到例外時會設定的屬性:" -#: ../../library/test.rst:1433 +#: ../../library/test.rst:1431 msgid "``exc_type``" msgstr "``exc_type``" -#: ../../library/test.rst:1434 +#: ../../library/test.rst:1432 msgid "``exc_value``" msgstr "``exc_value``" -#: ../../library/test.rst:1435 +#: ../../library/test.rst:1433 msgid "``exc_traceback``" msgstr "``exc_traceback``" -#: ../../library/test.rst:1436 +#: ../../library/test.rst:1434 msgid "``thread``" msgstr "``thread``" -#: ../../library/test.rst:1438 +#: ../../library/test.rst:1436 msgid "See :func:`threading.excepthook` documentation." msgstr "參閱 :func:`threading.excepthook` 文件。" -#: ../../library/test.rst:1440 +#: ../../library/test.rst:1438 msgid "These attributes are deleted at the context manager exit." msgstr "這些屬性會在離開情境管理器時被刪除。" -#: ../../library/test.rst:1444 +#: ../../library/test.rst:1442 msgid "" "with threading_helper.catch_threading_exception() as cm:\n" " # code spawning a thread which raises an exception\n" @@ -1714,36 +1714,36 @@ msgid "" "# (to avoid reference cycles)" msgstr "" -#: ../../library/test.rst:1461 +#: ../../library/test.rst:1459 msgid "" "Run the worker function concurrently in multiple threads. Re-raises an " "exception if any thread raises one, after all threads have finished." msgstr "" -#: ../../library/test.rst:1467 +#: ../../library/test.rst:1465 msgid ":mod:`!test.support.os_helper` --- Utilities for os tests" msgstr ":mod:`!test.support.os_helper` --- 用於 os 測試的工具" -#: ../../library/test.rst:1472 +#: ../../library/test.rst:1470 msgid "" "The :mod:`!test.support.os_helper` module provides support for os tests." msgstr ":mod:`!test.support.os_helper` 模組提供 os 測試的支援。" -#: ../../library/test.rst:1479 +#: ../../library/test.rst:1477 msgid "A non-ASCII character encodable by :func:`os.fsencode`." msgstr "" -#: ../../library/test.rst:1484 +#: ../../library/test.rst:1482 msgid "Set to :func:`os.getcwd`." msgstr "設定為 :func:`os.getcwd`。" -#: ../../library/test.rst:1489 +#: ../../library/test.rst:1487 msgid "" "Set to a name that is safe to use as the name of a temporary file. Any " "temporary file that is created should be closed and unlinked (removed)." msgstr "" -#: ../../library/test.rst:1495 +#: ../../library/test.rst:1493 msgid "" "Set to a filename containing the :data:`FS_NONASCII` character, if it " "exists. This guarantees that if the filename exists, it can be encoded and " @@ -1751,25 +1751,25 @@ msgid "" "a non-ASCII filename to be easily skipped on platforms where they can't work." msgstr "" -#: ../../library/test.rst:1503 +#: ../../library/test.rst:1501 msgid "" "Set to a filename (str type) that should not be able to be encoded by file " "system encoding in strict mode. It may be ``None`` if it's not possible to " "generate such a filename." msgstr "" -#: ../../library/test.rst:1510 +#: ../../library/test.rst:1508 msgid "" "Set to a filename (bytes type) that should not be able to be decoded by file " "system encoding in strict mode. It may be ``None`` if it's not possible to " "generate such a filename." msgstr "" -#: ../../library/test.rst:1517 +#: ../../library/test.rst:1515 msgid "Set to a non-ASCII name for a temporary file." msgstr "" -#: ../../library/test.rst:1522 +#: ../../library/test.rst:1520 msgid "" "Class used to temporarily set or unset environment variables. Instances can " "be used as a context manager and have a complete dictionary interface for " @@ -1778,79 +1778,79 @@ msgid "" "instance will be rolled back." msgstr "" -#: ../../library/test.rst:1528 +#: ../../library/test.rst:1526 msgid "Added dictionary interface." msgstr "新增字典介面。" -#: ../../library/test.rst:1534 +#: ../../library/test.rst:1532 msgid "" "Simple :term:`path-like object`. It implements the :meth:`~os.PathLike." "__fspath__` method which just returns the *path* argument. If *path* is an " "exception, it will be raised in :meth:`!__fspath__`." msgstr "" -#: ../../library/test.rst:1542 +#: ../../library/test.rst:1540 msgid "" "Temporarily set the environment variable ``envvar`` to the value of " "``value``." msgstr "" -#: ../../library/test.rst:1548 +#: ../../library/test.rst:1546 msgid "Temporarily unset one or more environment variables." msgstr "暫時取消一個或多個環境變數。" -#: ../../library/test.rst:1550 +#: ../../library/test.rst:1548 msgid "More than one environment variable can be unset." msgstr "可以取消多於一個環境變數。" -#: ../../library/test.rst:1556 +#: ../../library/test.rst:1554 msgid "Return ``True`` if the OS supports symbolic links, ``False`` otherwise." msgstr "如果作業系統支援符號連結則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/test.rst:1562 +#: ../../library/test.rst:1560 msgid "Return ``True`` if the OS supports xattr, ``False`` otherwise." msgstr "如果作業系統支援 xattr 則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/test.rst:1568 +#: ../../library/test.rst:1566 msgid "" "A context manager that temporarily changes the current working directory to " "*path* and yields the directory." msgstr "" -#: ../../library/test.rst:1571 +#: ../../library/test.rst:1569 msgid "" "If *quiet* is ``False``, the context manager raises an exception on error. " "Otherwise, it issues only a warning and keeps the current working directory " "the same." msgstr "" -#: ../../library/test.rst:1578 +#: ../../library/test.rst:1576 msgid "" "Create an empty file with *filename*. If it already exists, truncate it." msgstr "" -#: ../../library/test.rst:1583 +#: ../../library/test.rst:1581 msgid "Count the number of open file descriptors." msgstr "" -#: ../../library/test.rst:1588 +#: ../../library/test.rst:1586 msgid "Return ``True`` if the file system for *directory* is case-insensitive." msgstr "" -#: ../../library/test.rst:1593 +#: ../../library/test.rst:1591 msgid "" "Create an invalid file descriptor by opening and closing a temporary file, " "and returning its descriptor." msgstr "" -#: ../../library/test.rst:1599 +#: ../../library/test.rst:1597 msgid "" "Call :func:`os.rmdir` on *filename*. On Windows platforms, this is wrapped " "with a wait loop that checks for the existence of the file, which is needed " "due to antivirus programs that can hold files open and prevent deletion." msgstr "" -#: ../../library/test.rst:1607 +#: ../../library/test.rst:1605 msgid "" "Call :func:`shutil.rmtree` on *path* or call :func:`os.lstat` and :func:`os." "rmdir` to remove a path and its contents. As with :func:`rmdir`, on Windows " @@ -1858,21 +1858,21 @@ msgid "" "the files." msgstr "" -#: ../../library/test.rst:1615 +#: ../../library/test.rst:1613 msgid "A decorator for running tests that require support for symbolic links." msgstr "" -#: ../../library/test.rst:1620 +#: ../../library/test.rst:1618 msgid "A decorator for running tests that require support for xattr." msgstr "" -#: ../../library/test.rst:1625 +#: ../../library/test.rst:1623 msgid "" "A context manager that temporarily creates a new directory and changes the " "current working directory (CWD)." msgstr "" -#: ../../library/test.rst:1628 +#: ../../library/test.rst:1626 msgid "" "The context manager creates a temporary directory in the current directory " "with name *name* before temporarily changing the current working directory. " @@ -1880,20 +1880,20 @@ msgid "" "`tempfile.mkdtemp`." msgstr "" -#: ../../library/test.rst:1633 +#: ../../library/test.rst:1631 msgid "" "If *quiet* is ``False`` and it is not possible to create or change the CWD, " "an error is raised. Otherwise, only a warning is raised and the original " "CWD is used." msgstr "" -#: ../../library/test.rst:1640 +#: ../../library/test.rst:1638 msgid "" "A context manager that creates a temporary directory at *path* and yields " "the directory." msgstr "" -#: ../../library/test.rst:1643 +#: ../../library/test.rst:1641 msgid "" "If *path* is ``None``, the temporary directory is created using :func:" "`tempfile.mkdtemp`. If *quiet* is ``False``, the context manager raises an " @@ -1901,34 +1901,65 @@ msgid "" "created, only a warning is issued." msgstr "" -#: ../../library/test.rst:1651 +#: ../../library/test.rst:1649 msgid "A context manager that temporarily sets the process umask." msgstr "" -#: ../../library/test.rst:1656 +#: ../../library/test.rst:1654 msgid "" "Call :func:`os.unlink` on *filename*. As with :func:`rmdir`, on Windows " "platforms, this is wrapped with a wait loop that checks for the existence of " "the file." msgstr "" -#: ../../library/test.rst:1662 +#: ../../library/test.rst:1661 +msgid "" +"A decorator for running tests with the :envvar:`SOURCE_DATE_EPOCH` " +"environment variable set to *epoch*." +msgstr "" + +#: ../../library/test.rst:1667 +msgid "" +"A decorator for running tests with the :envvar:`SOURCE_DATE_EPOCH` " +"environment variable unset." +msgstr "" + +#: ../../library/test.rst:1673 +msgid "" +"Metaclass wrapping all test methods of the class with :func:" +"`with_source_date_epoch` if the *source_date_epoch* keyword class argument " +"is true, or with :func:`without_source_date_epoch` otherwise. For example::" +msgstr "" + +#: ../../library/test.rst:1678 +msgid "" +"class TestsWithSourceEpoch(Tests,\n" +" metaclass=SourceDateEpochTestMeta,\n" +" source_date_epoch=True):\n" +" pass" +msgstr "" +"class TestsWithSourceEpoch(Tests,\n" +" metaclass=SourceDateEpochTestMeta,\n" +" source_date_epoch=True):\n" +" pass" + +#: ../../library/test.rst:1686 msgid ":mod:`!test.support.import_helper` --- Utilities for import tests" msgstr ":mod:`!test.support.import_helper` --- 用於 import 測試的工具" -#: ../../library/test.rst:1667 +#: ../../library/test.rst:1691 msgid "" "The :mod:`!test.support.import_helper` module provides support for import " "tests." msgstr ":mod:`!test.support.import_helper` 模組提供 import 測試的支援。" -#: ../../library/test.rst:1674 +#: ../../library/test.rst:1698 msgid "" "Remove the module named *module_name* from ``sys.modules`` and delete any " "byte-compiled files of the module." msgstr "" -#: ../../library/test.rst:1680 +#: ../../library/test.rst:1704 msgid "" "This function imports and returns a fresh copy of the named Python module by " "removing the named module from ``sys.modules`` before doing the import. Note " @@ -1936,39 +1967,39 @@ msgid "" "operation." msgstr "" -#: ../../library/test.rst:1685 +#: ../../library/test.rst:1709 msgid "" "*fresh* is an iterable of additional module names that are also removed from " "the ``sys.modules`` cache before doing the import." msgstr "" -#: ../../library/test.rst:1688 +#: ../../library/test.rst:1712 msgid "" "*blocked* is an iterable of module names that are replaced with ``None`` in " "the module cache during the import to ensure that attempts to import them " "raise :exc:`ImportError`." msgstr "" -#: ../../library/test.rst:1692 +#: ../../library/test.rst:1716 msgid "" "The named module and any modules named in the *fresh* and *blocked* " "parameters are saved before starting the import and then reinserted into " "``sys.modules`` when the fresh import is complete." msgstr "" -#: ../../library/test.rst:1696 +#: ../../library/test.rst:1720 msgid "" "Module and package deprecation messages are suppressed during this import if " "*deprecated* is ``True``." msgstr "" -#: ../../library/test.rst:1699 +#: ../../library/test.rst:1723 msgid "" "This function will raise :exc:`ImportError` if the named module cannot be " "imported." msgstr "如果無法引入指定的模組則此函式會引發 :exc:`ImportError`。" -#: ../../library/test.rst:1704 +#: ../../library/test.rst:1728 msgid "" "# Get copies of the warnings module for testing without affecting the\n" "# version being used by the rest of the test suite. One copy uses the\n" @@ -1978,14 +2009,14 @@ msgid "" "c_warnings = import_fresh_module('warnings', fresh=['_warnings'])" msgstr "" -#: ../../library/test.rst:1716 +#: ../../library/test.rst:1740 msgid "" "This function imports and returns the named module. Unlike a normal import, " "this function raises :exc:`unittest.SkipTest` if the module cannot be " "imported." msgstr "" -#: ../../library/test.rst:1720 +#: ../../library/test.rst:1744 msgid "" "Module and package deprecation messages are suppressed during this import if " "*deprecated* is ``True``. If a module is required on a platform but " @@ -1993,21 +2024,21 @@ msgid "" "which will be compared against :data:`sys.platform`." msgstr "" -#: ../../library/test.rst:1730 +#: ../../library/test.rst:1754 msgid "Return a copy of :data:`sys.modules`." msgstr "回傳 :data:`sys.modules` 的複本。" -#: ../../library/test.rst:1735 +#: ../../library/test.rst:1759 msgid "" "Remove modules except for *oldmodules* and ``encodings`` in order to " "preserve internal cache." msgstr "" -#: ../../library/test.rst:1741 +#: ../../library/test.rst:1765 msgid "Delete *name* from ``sys.modules``." msgstr "從 ``sys.modules`` 中刪除 *name*。" -#: ../../library/test.rst:1746 +#: ../../library/test.rst:1770 msgid "" "Move a :pep:`3147`/:pep:`488` pyc file to its legacy pyc location and return " "the file system path to the legacy pyc file. The *source* value is the file " @@ -2015,48 +2046,48 @@ msgid "" "3147/488 pyc file must exist." msgstr "" -#: ../../library/test.rst:1754 +#: ../../library/test.rst:1778 msgid "" "A context manager to force import to return a new module reference. This is " "useful for testing module-level behaviors, such as the emission of a :exc:" "`DeprecationWarning` on import. Example usage::" msgstr "" -#: ../../library/test.rst:1758 +#: ../../library/test.rst:1782 msgid "" "with CleanImport('foo'):\n" " importlib.import_module('foo') # New reference." msgstr "" -#: ../../library/test.rst:1764 +#: ../../library/test.rst:1788 msgid "A context manager to temporarily add directories to :data:`sys.path`." msgstr "" -#: ../../library/test.rst:1766 +#: ../../library/test.rst:1790 msgid "" "This makes a copy of :data:`sys.path`, appends any directories given as " "positional arguments, then reverts :data:`sys.path` to the copied settings " "when the context ends." msgstr "" -#: ../../library/test.rst:1770 +#: ../../library/test.rst:1794 msgid "" "Note that *all* :data:`sys.path` modifications in the body of the context " "manager, including replacement of the object, will be reverted at the end of " "the block." msgstr "" -#: ../../library/test.rst:1776 +#: ../../library/test.rst:1800 msgid ":mod:`!test.support.warnings_helper` --- Utilities for warnings tests" msgstr ":mod:`!test.support.warnings_helper` --- 用於 warnings 測試的工具" -#: ../../library/test.rst:1781 +#: ../../library/test.rst:1805 msgid "" "The :mod:`!test.support.warnings_helper` module provides support for " "warnings tests." msgstr ":mod:`!test.support.warnings_helper` 模組提供 warnings 測試的支援。" -#: ../../library/test.rst:1788 +#: ../../library/test.rst:1812 msgid "" "Suppress warnings that are instances of *category*, which must be :exc:" "`Warning` or a subclass. Roughly equivalent to :func:`warnings." @@ -2064,21 +2095,21 @@ msgid "" "category=category) `. For example::" msgstr "" -#: ../../library/test.rst:1794 +#: ../../library/test.rst:1818 msgid "" "@warning_helper.ignore_warnings(category=DeprecationWarning)\n" "def test_suppress_warning():\n" " # do something" msgstr "" -#: ../../library/test.rst:1803 +#: ../../library/test.rst:1827 msgid "" "Context manager to check that no :exc:`ResourceWarning` was raised. You " "must remove the object which may emit :exc:`ResourceWarning` before the end " "of the context manager." msgstr "" -#: ../../library/test.rst:1810 +#: ../../library/test.rst:1834 msgid "" "Test for syntax warning in *statement* by attempting to compile *statement*. " "Test also that the :exc:`SyntaxWarning` is emitted only once, and that it " @@ -2090,7 +2121,7 @@ msgid "" "``None``, compares to the offset of the exception." msgstr "" -#: ../../library/test.rst:1824 +#: ../../library/test.rst:1848 msgid "" "A convenience wrapper for :func:`warnings.catch_warnings` that makes it " "easier to test that a warning was correctly raised. It is approximately " @@ -2099,7 +2130,7 @@ msgid "" "automatically validate the results that are recorded." msgstr "" -#: ../../library/test.rst:1830 +#: ../../library/test.rst:1854 msgid "" "``check_warnings`` accepts 2-tuples of the form ``(\"message regexp\", " "WarningCategory)`` as positional arguments. If one or more *filters* are " @@ -2111,19 +2142,19 @@ msgid "" "*quiet* to ``True``." msgstr "" -#: ../../library/test.rst:1839 +#: ../../library/test.rst:1863 msgid "If no arguments are specified, it defaults to::" msgstr "如果沒有指定引數,預設為: ::" -#: ../../library/test.rst:1841 +#: ../../library/test.rst:1865 msgid "check_warnings((\"\", Warning), quiet=True)" msgstr "check_warnings((\"\", Warning), quiet=True)" -#: ../../library/test.rst:1843 +#: ../../library/test.rst:1867 msgid "In this case all warnings are caught and no errors are raised." msgstr "" -#: ../../library/test.rst:1845 +#: ../../library/test.rst:1869 msgid "" "On entry to the context manager, a :class:`WarningRecorder` instance is " "returned. The underlying warnings list from :func:`~warnings.catch_warnings` " @@ -2135,17 +2166,17 @@ msgid "" "return ``None``." msgstr "" -#: ../../library/test.rst:1854 +#: ../../library/test.rst:1878 msgid "" "The recorder object also has a :meth:`reset` method, which clears the " "warnings list." msgstr "" -#: ../../library/test.rst:1857 +#: ../../library/test.rst:1881 msgid "The context manager is designed to be used like this::" msgstr "" -#: ../../library/test.rst:1859 +#: ../../library/test.rst:1883 msgid "" "with check_warnings((\"assertion is always true\", SyntaxWarning),\n" " (\"\", UserWarning)):\n" @@ -2153,19 +2184,19 @@ msgid "" " warnings.warn(UserWarning(\"Hide me!\"))" msgstr "" -#: ../../library/test.rst:1864 +#: ../../library/test.rst:1888 msgid "" "In this case if either warning was not raised, or some other warning was " "raised, :func:`check_warnings` would raise an error." msgstr "" -#: ../../library/test.rst:1867 +#: ../../library/test.rst:1891 msgid "" "When a test needs to look more deeply into the warnings, rather than just " "checking whether or not they occurred, code like this can be used::" msgstr "" -#: ../../library/test.rst:1870 +#: ../../library/test.rst:1894 msgid "" "with check_warnings(quiet=True) as w:\n" " warnings.warn(\"foo\")\n" @@ -2187,17 +2218,17 @@ msgstr "" " w.reset()\n" " assert len(w.warnings) == 0" -#: ../../library/test.rst:1881 +#: ../../library/test.rst:1905 msgid "" "Here all warnings will be caught, and the test code tests the captured " "warnings directly." msgstr "" -#: ../../library/test.rst:1884 +#: ../../library/test.rst:1908 msgid "New optional arguments *filters* and *quiet*." msgstr "新的可選引數 *filters* 和 *quiet*。" -#: ../../library/test.rst:1890 +#: ../../library/test.rst:1914 msgid "" "Class used to record warnings for unit tests. See documentation of :func:" "`check_warnings` above for more details." diff --git a/library/textwrap.po b/library/textwrap.po index 6c425137d35..5d8d0c2ca75 100644 --- a/library/textwrap.po +++ b/library/textwrap.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!textwrap` --- Text wrapping and filling" msgstr ":mod:`!textwrap` --- 文字包裝與填充" -#: ../../library/textwrap.rst:10 +#: ../../library/textwrap.rst:7 msgid "**Source code:** :source:`Lib/textwrap.py`" msgstr "**原始碼:**\\ :source:`Lib/textwrap.py`" -#: ../../library/textwrap.rst:14 +#: ../../library/textwrap.rst:11 msgid "" "The :mod:`!textwrap` module provides some convenience functions, as well as :" "class:`TextWrapper`, the class that does all the work. If you're just " @@ -34,46 +34,46 @@ msgid "" "`TextWrapper` for efficiency." msgstr "" -#: ../../library/textwrap.rst:27 +#: ../../library/textwrap.rst:24 msgid "" "Wraps the single paragraph in *text* (a string) so every line is at most " "*width* characters long. Returns a list of output lines, without final " "newlines." msgstr "" -#: ../../library/textwrap.rst:31 +#: ../../library/textwrap.rst:28 msgid "" "Optional keyword arguments correspond to the instance attributes of :class:" "`TextWrapper`, documented below." msgstr "" -#: ../../library/textwrap.rst:34 +#: ../../library/textwrap.rst:31 msgid "" "See the :meth:`TextWrapper.wrap` method for additional details on how :func:" "`wrap` behaves." msgstr "" -#: ../../library/textwrap.rst:45 +#: ../../library/textwrap.rst:42 msgid "" "Wraps the single paragraph in *text*, and returns a single string containing " "the wrapped paragraph. :func:`fill` is shorthand for ::" msgstr "" -#: ../../library/textwrap.rst:48 +#: ../../library/textwrap.rst:45 msgid "\"\\n\".join(wrap(text, ...))" msgstr "\"\\n\".join(wrap(text, ...))" -#: ../../library/textwrap.rst:50 +#: ../../library/textwrap.rst:47 msgid "" "In particular, :func:`fill` accepts exactly the same keyword arguments as :" "func:`wrap`." msgstr "" -#: ../../library/textwrap.rst:58 +#: ../../library/textwrap.rst:55 msgid "Collapse and truncate the given *text* to fit in the given *width*." msgstr "" -#: ../../library/textwrap.rst:60 +#: ../../library/textwrap.rst:57 msgid "" "First the whitespace in *text* is collapsed (all whitespace is replaced by " "single spaces). If the result fits in the *width*, it is returned. " @@ -81,7 +81,7 @@ msgid "" "plus the *placeholder* fit within *width*::" msgstr "" -#: ../../library/textwrap.rst:65 +#: ../../library/textwrap.rst:62 msgid "" ">>> textwrap.shorten(\"Hello world!\", width=12)\n" "'Hello world!'\n" @@ -97,7 +97,7 @@ msgstr "" ">>> textwrap.shorten(\"Hello world\", width=10, placeholder=\"...\")\n" "'Hello...'" -#: ../../library/textwrap.rst:72 +#: ../../library/textwrap.rst:69 msgid "" "Optional keyword arguments correspond to the instance attributes of :class:" "`TextWrapper`, documented below. Note that the whitespace is collapsed " @@ -106,34 +106,34 @@ msgid "" "drop_whitespace`, and :attr:`.replace_whitespace` will have no effect." msgstr "" -#: ../../library/textwrap.rst:82 +#: ../../library/textwrap.rst:79 msgid "Remove any common leading whitespace from every line in *text*." msgstr "" -#: ../../library/textwrap.rst:84 +#: ../../library/textwrap.rst:81 msgid "" "This can be used to make triple-quoted strings line up with the left edge of " "the display, while still presenting them in the source code in indented form." msgstr "" -#: ../../library/textwrap.rst:87 +#: ../../library/textwrap.rst:84 msgid "" "Note that tabs and spaces are both treated as whitespace, but they are not " "equal: the lines ``\" hello\"`` and ``\"\\thello\"`` are considered to have " "no common leading whitespace." msgstr "" -#: ../../library/textwrap.rst:91 +#: ../../library/textwrap.rst:88 msgid "" "Lines containing only whitespace are ignored in the input and normalized to " "a single newline character in the output." msgstr "" -#: ../../library/textwrap.rst:94 ../../library/textwrap.rst:119 +#: ../../library/textwrap.rst:91 ../../library/textwrap.rst:116 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/textwrap.rst:96 +#: ../../library/textwrap.rst:93 msgid "" "def test():\n" " # end first line with \\ to avoid the empty line!\n" @@ -145,28 +145,28 @@ msgid "" " print(repr(dedent(s))) # prints 'hello\\n world\\n'" msgstr "" -#: ../../library/textwrap.rst:105 +#: ../../library/textwrap.rst:102 msgid "" "The :func:`!dedent` function now correctly normalizes blank lines containing " "only whitespace characters. Previously, the implementation only normalized " "blank lines containing tabs and spaces." msgstr "" -#: ../../library/textwrap.rst:112 +#: ../../library/textwrap.rst:109 msgid "Add *prefix* to the beginning of selected lines in *text*." msgstr "" -#: ../../library/textwrap.rst:114 +#: ../../library/textwrap.rst:111 msgid "Lines are separated by calling ``text.splitlines(True)``." msgstr "" -#: ../../library/textwrap.rst:116 +#: ../../library/textwrap.rst:113 msgid "" "By default, *prefix* is added to all lines that do not consist solely of " "whitespace (including any line endings)." msgstr "" -#: ../../library/textwrap.rst:121 +#: ../../library/textwrap.rst:118 msgid "" ">>> s = 'hello\\n\\n \\nworld'\n" ">>> indent(s, ' ')\n" @@ -176,14 +176,14 @@ msgstr "" ">>> indent(s, ' ')\n" "' hello\\n\\n \\n world'" -#: ../../library/textwrap.rst:125 +#: ../../library/textwrap.rst:122 msgid "" "The optional *predicate* argument can be used to control which lines are " "indented. For example, it is easy to add *prefix* to even empty and " "whitespace-only lines::" msgstr "" -#: ../../library/textwrap.rst:129 +#: ../../library/textwrap.rst:126 msgid "" ">>> print(indent(s, '+ ', lambda line: True))\n" "+ hello\n" @@ -197,7 +197,7 @@ msgstr "" "+\n" "+ world" -#: ../../library/textwrap.rst:138 +#: ../../library/textwrap.rst:135 msgid "" ":func:`wrap`, :func:`fill` and :func:`shorten` work by creating a :class:" "`TextWrapper` instance and calling a single method on it. That instance is " @@ -206,29 +206,29 @@ msgid "" "class:`TextWrapper` object." msgstr "" -#: ../../library/textwrap.rst:144 +#: ../../library/textwrap.rst:141 msgid "" "Text is preferably wrapped on whitespaces and right after the hyphens in " "hyphenated words; only then will long words be broken if necessary, unless :" "attr:`TextWrapper.break_long_words` is set to false." msgstr "" -#: ../../library/textwrap.rst:150 +#: ../../library/textwrap.rst:147 msgid "" "The :class:`TextWrapper` constructor accepts a number of optional keyword " "arguments. Each keyword argument corresponds to an instance attribute, so " "for example ::" msgstr "" -#: ../../library/textwrap.rst:154 +#: ../../library/textwrap.rst:151 msgid "wrapper = TextWrapper(initial_indent=\"* \")" msgstr "wrapper = TextWrapper(initial_indent=\"* \")" -#: ../../library/textwrap.rst:156 +#: ../../library/textwrap.rst:153 msgid "is the same as ::" msgstr "" -#: ../../library/textwrap.rst:158 +#: ../../library/textwrap.rst:155 msgid "" "wrapper = TextWrapper()\n" "wrapper.initial_indent = \"* \"" @@ -236,20 +236,20 @@ msgstr "" "wrapper = TextWrapper()\n" "wrapper.initial_indent = \"* \"" -#: ../../library/textwrap.rst:161 +#: ../../library/textwrap.rst:158 msgid "" "You can reuse the same :class:`TextWrapper` object many times, and you can " "change any of its options through direct assignment to instance attributes " "between uses." msgstr "" -#: ../../library/textwrap.rst:165 +#: ../../library/textwrap.rst:162 msgid "" "The :class:`TextWrapper` instance attributes (and keyword arguments to the " "constructor) are as follows:" msgstr "" -#: ../../library/textwrap.rst:171 +#: ../../library/textwrap.rst:168 msgid "" "(default: ``70``) The maximum length of wrapped lines. As long as there are " "no individual words in the input text longer than :attr:`width`, :class:" @@ -257,20 +257,20 @@ msgid "" "`width` characters." msgstr "" -#: ../../library/textwrap.rst:179 +#: ../../library/textwrap.rst:176 msgid "" "(default: ``True``) If true, then all tab characters in *text* will be " "expanded to spaces using the :meth:`~str.expandtabs` method of *text*." msgstr "" -#: ../../library/textwrap.rst:185 +#: ../../library/textwrap.rst:182 msgid "" "(default: ``8``) If :attr:`expand_tabs` is true, then all tab characters in " "*text* will be expanded to zero or more spaces, depending on the current " "column and the given tab size." msgstr "" -#: ../../library/textwrap.rst:194 +#: ../../library/textwrap.rst:191 msgid "" "(default: ``True``) If true, after tab expansion but before wrapping, the :" "meth:`wrap` method will replace each whitespace character with a single " @@ -278,14 +278,14 @@ msgid "" "vertical tab, formfeed, and carriage return (``'\\t\\n\\v\\f\\r'``)." msgstr "" -#: ../../library/textwrap.rst:202 +#: ../../library/textwrap.rst:199 msgid "" "If :attr:`expand_tabs` is false and :attr:`replace_whitespace` is true, each " "tab character will be replaced by a single space, which is *not* the same as " "tab expansion." msgstr "" -#: ../../library/textwrap.rst:208 +#: ../../library/textwrap.rst:205 msgid "" "If :attr:`replace_whitespace` is false, newlines may appear in the middle of " "a line and cause strange output. For this reason, text should be split into " @@ -293,7 +293,7 @@ msgid "" "separately." msgstr "" -#: ../../library/textwrap.rst:216 +#: ../../library/textwrap.rst:213 msgid "" "(default: ``True``) If true, whitespace at the beginning and ending of every " "line (after wrapping but before indenting) is dropped. Whitespace at the " @@ -302,21 +302,21 @@ msgid "" "line is dropped." msgstr "" -#: ../../library/textwrap.rst:225 +#: ../../library/textwrap.rst:222 msgid "" "(default: ``''``) String that will be prepended to the first line of wrapped " "output. Counts towards the length of the first line. The empty string is " "not indented." msgstr "" -#: ../../library/textwrap.rst:232 +#: ../../library/textwrap.rst:229 msgid "" "(default: ``''``) String that will be prepended to all lines of wrapped " "output except the first. Counts towards the length of each line except the " "first." msgstr "" -#: ../../library/textwrap.rst:239 +#: ../../library/textwrap.rst:236 msgid "" "(default: ``False``) If true, :class:`TextWrapper` attempts to detect " "sentence endings and ensure that sentences are always separated by exactly " @@ -328,23 +328,23 @@ msgid "" "to detect the difference between \"Dr.\" in ::" msgstr "" -#: ../../library/textwrap.rst:248 +#: ../../library/textwrap.rst:245 msgid "[...] Dr. Frankenstein's monster [...]" msgstr "[...] Dr. Frankenstein's monster [...]" -#: ../../library/textwrap.rst:250 +#: ../../library/textwrap.rst:247 msgid "and \"Spot.\" in ::" msgstr "" -#: ../../library/textwrap.rst:252 +#: ../../library/textwrap.rst:249 msgid "[...] See Spot. See Spot run [...]" msgstr "[...] See Spot. See Spot run [...]" -#: ../../library/textwrap.rst:254 +#: ../../library/textwrap.rst:251 msgid ":attr:`fix_sentence_endings` is false by default." msgstr ":attr:`fix_sentence_endings` 預設為 false。" -#: ../../library/textwrap.rst:256 +#: ../../library/textwrap.rst:253 msgid "" "Since the sentence detection algorithm relies on ``string.lowercase`` for " "the definition of \"lowercase letter\", and a convention of using two spaces " @@ -352,7 +352,7 @@ msgid "" "English-language texts." msgstr "" -#: ../../library/textwrap.rst:264 +#: ../../library/textwrap.rst:261 msgid "" "(default: ``True``) If true, then words longer than :attr:`width` will be " "broken in order to ensure that no lines are longer than :attr:`width`. If " @@ -361,7 +361,7 @@ msgid "" "order to minimize the amount by which :attr:`width` is exceeded.)" msgstr "" -#: ../../library/textwrap.rst:273 +#: ../../library/textwrap.rst:270 msgid "" "(default: ``True``) If true, wrapping will occur preferably on whitespaces " "and right after hyphens in compound words, as it is customary in English. If " @@ -371,25 +371,25 @@ msgid "" "always allow breaking hyphenated words." msgstr "" -#: ../../library/textwrap.rst:283 +#: ../../library/textwrap.rst:280 msgid "" "(default: ``None``) If not ``None``, then the output will contain at most " "*max_lines* lines, with *placeholder* appearing at the end of the output." msgstr "" -#: ../../library/textwrap.rst:293 +#: ../../library/textwrap.rst:290 msgid "" "(default: ``' [...]'``) String that will appear at the end of the output " "text if it has been truncated." msgstr "" -#: ../../library/textwrap.rst:299 +#: ../../library/textwrap.rst:296 msgid "" ":class:`TextWrapper` also provides some public methods, analogous to the " "module-level convenience functions:" msgstr "" -#: ../../library/textwrap.rst:304 +#: ../../library/textwrap.rst:301 msgid "" "Wraps the single paragraph in *text* (a string) so every line is at most :" "attr:`width` characters long. All wrapping options are taken from instance " @@ -398,16 +398,16 @@ msgid "" "returned list is empty." msgstr "" -#: ../../library/textwrap.rst:313 +#: ../../library/textwrap.rst:310 msgid "" "Wraps the single paragraph in *text*, and returns a single string containing " "the wrapped paragraph." msgstr "" -#: ../../library/textwrap.rst:289 +#: ../../library/textwrap.rst:286 msgid "..." msgstr "..." -#: ../../library/textwrap.rst:289 +#: ../../library/textwrap.rst:286 msgid "placeholder" msgstr "placeholder(佔位符號)" diff --git a/library/threading.po b/library/threading.po index e7de03a12b4..4a00f547f56 100644 --- a/library/threading.po +++ b/library/threading.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-24 00:37+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:12+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,8 +33,8 @@ msgstr "" "此模組在較低層的 :mod:`_thread` 模組之上,建構了較高層的執行緒(threading)介" "面。" -#: ../../library/threading.rst:194 ../../library/threading.rst:293 -#: ../../library/threading.rst:678 ../../includes/wasm-notavail.rst:3 +#: ../../library/threading.rst:194 ../../library/threading.rst:296 +#: ../../library/threading.rst:684 ../../includes/wasm-notavail.rst:3 msgid "Availability" msgstr "可用性" @@ -291,7 +291,11 @@ msgstr "" msgid "Added support for GNU/kFreeBSD." msgstr "新增對 GNU/kFreeBSD 的支援。" -#: ../../library/threading.rst:204 +#: ../../library/threading.rst:201 +msgid "Added support for Solaris." +msgstr "新增對 Solaris 的支援。" + +#: ../../library/threading.rst:207 msgid "" "Return a list of all :class:`Thread` objects currently active. The list " "includes daemonic threads and dummy thread objects created by :func:" @@ -300,59 +304,59 @@ msgid "" "even when terminated." msgstr "" -#: ../../library/threading.rst:213 +#: ../../library/threading.rst:216 msgid "" "Return the main :class:`Thread` object. In normal conditions, the main " "thread is the thread from which the Python interpreter was started." msgstr "" -#: ../../library/threading.rst:224 +#: ../../library/threading.rst:227 msgid "" "Set a trace function for all threads started from the :mod:`!threading` " "module. The *func* will be passed to :func:`sys.settrace` for each thread, " "before its :meth:`~Thread.run` method is called." msgstr "" -#: ../../library/threading.rst:230 +#: ../../library/threading.rst:233 msgid "" "Set a trace function for all threads started from the :mod:`!threading` " "module and all Python threads that are currently executing." msgstr "" -#: ../../library/threading.rst:233 +#: ../../library/threading.rst:236 msgid "" "The *func* will be passed to :func:`sys.settrace` for each thread, before " "its :meth:`~Thread.run` method is called." msgstr "" -#: ../../library/threading.rst:244 +#: ../../library/threading.rst:247 msgid "Get the trace function as set by :func:`settrace`." msgstr "" -#: ../../library/threading.rst:253 +#: ../../library/threading.rst:256 msgid "" "Set a profile function for all threads started from the :mod:`!threading` " "module. The *func* will be passed to :func:`sys.setprofile` for each " "thread, before its :meth:`~Thread.run` method is called." msgstr "" -#: ../../library/threading.rst:259 +#: ../../library/threading.rst:262 msgid "" "Set a profile function for all threads started from the :mod:`!threading` " "module and all Python threads that are currently executing." msgstr "" -#: ../../library/threading.rst:262 +#: ../../library/threading.rst:265 msgid "" "The *func* will be passed to :func:`sys.setprofile` for each thread, before " "its :meth:`~Thread.run` method is called." msgstr "" -#: ../../library/threading.rst:271 +#: ../../library/threading.rst:274 msgid "Get the profiler function as set by :func:`setprofile`." msgstr "取得由 :func:`setprofile` 設定的剖析函式。" -#: ../../library/threading.rst:278 +#: ../../library/threading.rst:281 msgid "" "Return the thread stack size used when creating new threads. The optional " "*size* argument specifies the stack size to be used for subsequently created " @@ -371,15 +375,15 @@ msgid "" "information)." msgstr "" -#: ../../library/threading.rst:295 +#: ../../library/threading.rst:298 msgid "Unix platforms with POSIX threads support." msgstr "" -#: ../../library/threading.rst:298 +#: ../../library/threading.rst:301 msgid "This module also defines the following constant:" msgstr "此模組也定義了以下常數:" -#: ../../library/threading.rst:302 +#: ../../library/threading.rst:305 msgid "" "The maximum value allowed for the *timeout* parameter of blocking functions " "(:meth:`Lock.acquire`, :meth:`RLock.acquire`, :meth:`Condition.wait`, etc.). " @@ -387,13 +391,13 @@ msgid "" "`OverflowError`." msgstr "" -#: ../../library/threading.rst:310 +#: ../../library/threading.rst:313 msgid "" "This module defines a number of classes, which are detailed in the sections " "below." msgstr "" -#: ../../library/threading.rst:313 +#: ../../library/threading.rst:316 msgid "" "The design of this module is loosely based on Java's threading model. " "However, where Java makes locks and condition variables basic behavior of " @@ -404,22 +408,22 @@ msgid "" "Thread class, when implemented, are mapped to module-level functions." msgstr "" -#: ../../library/threading.rst:321 +#: ../../library/threading.rst:324 msgid "All of the methods described below are executed atomically." msgstr "" -#: ../../library/threading.rst:325 +#: ../../library/threading.rst:328 msgid "Thread-local data" msgstr "" -#: ../../library/threading.rst:327 +#: ../../library/threading.rst:330 msgid "" "Thread-local data is data whose values are thread specific. If you have data " "that you want to be local to a thread, create a :class:`local` object and " "use its attributes::" msgstr "" -#: ../../library/threading.rst:331 +#: ../../library/threading.rst:334 msgid "" ">>> mydata = local()\n" ">>> mydata.number = 42\n" @@ -431,11 +435,11 @@ msgstr "" ">>> mydata.number\n" "42" -#: ../../library/threading.rst:336 +#: ../../library/threading.rst:339 msgid "You can also access the :class:`local`-object's dictionary::" msgstr "" -#: ../../library/threading.rst:338 +#: ../../library/threading.rst:341 msgid "" ">>> mydata.__dict__\n" "{'number': 42}\n" @@ -451,11 +455,11 @@ msgstr "" ">>> mydata.widgets\n" "[]" -#: ../../library/threading.rst:345 +#: ../../library/threading.rst:348 msgid "If we access the data in a different thread::" msgstr "" -#: ../../library/threading.rst:347 +#: ../../library/threading.rst:350 msgid "" ">>> log = []\n" ">>> def f():\n" @@ -485,13 +489,13 @@ msgstr "" ">>> log\n" "[[], 11]" -#: ../../library/threading.rst:361 +#: ../../library/threading.rst:364 msgid "" "we get different data. Furthermore, changes made in the other thread don't " "affect data seen in this thread::" msgstr "" -#: ../../library/threading.rst:364 +#: ../../library/threading.rst:367 msgid "" ">>> mydata.number\n" "42" @@ -499,7 +503,7 @@ msgstr "" ">>> mydata.number\n" "42" -#: ../../library/threading.rst:367 +#: ../../library/threading.rst:370 msgid "" "Of course, values you get from a :class:`local` object, including their :" "attr:`~object.__dict__` attribute, are for whatever thread was current at " @@ -508,13 +512,13 @@ msgid "" "came from." msgstr "" -#: ../../library/threading.rst:373 +#: ../../library/threading.rst:376 msgid "" "You can create custom :class:`local` objects by subclassing the :class:" "`local` class::" msgstr "" -#: ../../library/threading.rst:376 +#: ../../library/threading.rst:379 msgid "" ">>> class MyLocal(local):\n" "... number = 2\n" @@ -530,7 +534,7 @@ msgstr "" "... def squared(self):\n" "... return self.number ** 2" -#: ../../library/threading.rst:383 +#: ../../library/threading.rst:386 msgid "" "This can be useful to support default values, methods and initialization. " "Note that if you define an :py:meth:`~object.__init__` method, it will be " @@ -538,19 +542,19 @@ msgid "" "This is necessary to initialize each thread's dictionary." msgstr "" -#: ../../library/threading.rst:389 +#: ../../library/threading.rst:392 msgid "Now if we create a :class:`local` object::" msgstr "現在如果我們建立一個 :class:`local` 物件: ::" -#: ../../library/threading.rst:391 +#: ../../library/threading.rst:394 msgid ">>> mydata = MyLocal(color='red')" msgstr ">>> mydata = MyLocal(color='red')" -#: ../../library/threading.rst:393 +#: ../../library/threading.rst:396 msgid "we have a default number::" msgstr "會有一個預設的數字: ::" -#: ../../library/threading.rst:395 +#: ../../library/threading.rst:398 msgid "" ">>> mydata.number\n" "2" @@ -558,11 +562,11 @@ msgstr "" ">>> mydata.number\n" "2" -#: ../../library/threading.rst:398 +#: ../../library/threading.rst:401 msgid "an initial color::" msgstr "和一個初始顏色: ::" -#: ../../library/threading.rst:400 +#: ../../library/threading.rst:403 msgid "" ">>> mydata.color\n" "'red'\n" @@ -572,11 +576,11 @@ msgstr "" "'red'\n" ">>> del mydata.color" -#: ../../library/threading.rst:404 +#: ../../library/threading.rst:407 msgid "And a method that operates on the data::" msgstr "和一個操作資料的方法: ::" -#: ../../library/threading.rst:406 +#: ../../library/threading.rst:409 msgid "" ">>> mydata.squared()\n" "4" @@ -584,11 +588,11 @@ msgstr "" ">>> mydata.squared()\n" "4" -#: ../../library/threading.rst:409 +#: ../../library/threading.rst:412 msgid "As before, we can access the data in a separate thread::" msgstr "" -#: ../../library/threading.rst:411 +#: ../../library/threading.rst:414 msgid "" ">>> log = []\n" ">>> thread = threading.Thread(target=f)\n" @@ -604,11 +608,11 @@ msgstr "" ">>> log\n" "[[('color', 'red')], 11]" -#: ../../library/threading.rst:418 +#: ../../library/threading.rst:421 msgid "without affecting this thread's data::" msgstr "" -#: ../../library/threading.rst:420 +#: ../../library/threading.rst:423 msgid "" ">>> mydata.number\n" "2\n" @@ -624,13 +628,13 @@ msgstr "" "...\n" "AttributeError: 'MyLocal' object has no attribute 'color'" -#: ../../library/threading.rst:427 +#: ../../library/threading.rst:430 msgid "" "Note that subclasses can define :term:`__slots__`, but they are not thread " "local. They are shared across threads::" msgstr "" -#: ../../library/threading.rst:430 +#: ../../library/threading.rst:433 msgid "" ">>> class MyLocal(local):\n" "... __slots__ = 'number'\n" @@ -646,11 +650,11 @@ msgstr "" ">>> mydata.number = 42\n" ">>> mydata.color = 'red'" -#: ../../library/threading.rst:437 +#: ../../library/threading.rst:440 msgid "So, the separate thread::" msgstr "" -#: ../../library/threading.rst:439 +#: ../../library/threading.rst:442 msgid "" ">>> thread = threading.Thread(target=f)\n" ">>> thread.start()\n" @@ -660,11 +664,11 @@ msgstr "" ">>> thread.start()\n" ">>> thread.join()" -#: ../../library/threading.rst:443 +#: ../../library/threading.rst:446 msgid "affects what we see::" msgstr "" -#: ../../library/threading.rst:445 +#: ../../library/threading.rst:448 msgid "" ">>> mydata.number\n" "11" @@ -672,15 +676,15 @@ msgstr "" ">>> mydata.number\n" "11" -#: ../../library/threading.rst:451 +#: ../../library/threading.rst:454 msgid "A class that represents thread-local data." msgstr "" -#: ../../library/threading.rst:457 +#: ../../library/threading.rst:460 msgid "Thread objects" msgstr "Thread 物件" -#: ../../library/threading.rst:459 +#: ../../library/threading.rst:462 msgid "" "The :class:`Thread` class represents an activity that is run in a separate " "thread of control. There are two ways to specify the activity: by passing a " @@ -690,14 +694,14 @@ msgid "" "``__init__()`` and :meth:`~Thread.run` methods of this class." msgstr "" -#: ../../library/threading.rst:466 +#: ../../library/threading.rst:469 msgid "" "Once a thread object is created, its activity must be started by calling the " "thread's :meth:`~Thread.start` method. This invokes the :meth:`~Thread.run` " "method in a separate thread of control." msgstr "" -#: ../../library/threading.rst:470 +#: ../../library/threading.rst:473 msgid "" "Once the thread's activity is started, the thread is considered 'alive'. It " "stops being alive when its :meth:`~Thread.run` method terminates -- either " @@ -705,27 +709,27 @@ msgid "" "is_alive` method tests whether the thread is alive." msgstr "" -#: ../../library/threading.rst:475 +#: ../../library/threading.rst:478 msgid "" "Other threads can call a thread's :meth:`~Thread.join` method. This blocks " "the calling thread until the thread whose :meth:`~Thread.join` method is " "called is terminated." msgstr "" -#: ../../library/threading.rst:479 +#: ../../library/threading.rst:482 msgid "" "A thread has a name. The name can be passed to the constructor, and read or " "changed through the :attr:`~Thread.name` attribute." msgstr "" -#: ../../library/threading.rst:482 +#: ../../library/threading.rst:485 msgid "" "If the :meth:`~Thread.run` method raises an exception, :func:`threading." "excepthook` is called to handle it. By default, :func:`threading.excepthook` " "ignores silently :exc:`SystemExit`." msgstr "" -#: ../../library/threading.rst:486 +#: ../../library/threading.rst:489 msgid "" "A thread can be flagged as a \"daemon thread\". The significance of this " "flag is that the entire Python program exits when only daemon threads are " @@ -734,7 +738,7 @@ msgid "" "constructor argument." msgstr "" -#: ../../library/threading.rst:493 +#: ../../library/threading.rst:496 msgid "" "Daemon threads are abruptly stopped at shutdown. Their resources (such as " "open files, database transactions, etc.) may not be released properly. If " @@ -742,13 +746,13 @@ msgid "" "suitable signalling mechanism such as an :class:`Event`." msgstr "" -#: ../../library/threading.rst:498 +#: ../../library/threading.rst:501 msgid "" "There is a \"main thread\" object; this corresponds to the initial thread of " "control in the Python program. It is not a daemon thread." msgstr "" -#: ../../library/threading.rst:501 +#: ../../library/threading.rst:504 msgid "" "There is the possibility that \"dummy thread objects\" are created. These " "are thread objects corresponding to \"alien threads\", which are threads of " @@ -759,25 +763,25 @@ msgid "" "threads." msgstr "" -#: ../../library/threading.rst:512 +#: ../../library/threading.rst:515 msgid "" "This constructor should always be called with keyword arguments. Arguments " "are:" msgstr "" -#: ../../library/threading.rst:515 +#: ../../library/threading.rst:518 msgid "" "*group* must be ``None`` as it is reserved for future extension when a :" "class:`!ThreadGroup` class is implemented." msgstr "" -#: ../../library/threading.rst:518 +#: ../../library/threading.rst:521 msgid "" "*target* is the callable object to be invoked by the :meth:`run` method. " "Defaults to ``None``, meaning nothing is called." msgstr "" -#: ../../library/threading.rst:521 +#: ../../library/threading.rst:524 msgid "" "*name* is the thread name. By default, a unique name is constructed of the " "form \"Thread-*N*\" where *N* is a small decimal number, or \"Thread-*N* " @@ -785,26 +789,26 @@ msgid "" "is specified." msgstr "" -#: ../../library/threading.rst:526 +#: ../../library/threading.rst:529 msgid "" "*args* is a list or tuple of arguments for the target invocation. Defaults " "to ``()``." msgstr "" -#: ../../library/threading.rst:528 +#: ../../library/threading.rst:531 msgid "" "*kwargs* is a dictionary of keyword arguments for the target invocation. " "Defaults to ``{}``." msgstr "" -#: ../../library/threading.rst:531 +#: ../../library/threading.rst:534 msgid "" "If not ``None``, *daemon* explicitly sets whether the thread is daemonic. If " "``None`` (the default), the daemonic property is inherited from the current " "thread." msgstr "" -#: ../../library/threading.rst:535 +#: ../../library/threading.rst:538 msgid "" "*context* is the :class:`~contextvars.Context` value to use when starting " "the thread. The default value is ``None`` which indicates that the :data:" @@ -817,58 +821,58 @@ msgid "" "defaults true on free-threaded builds and false otherwise." msgstr "" -#: ../../library/threading.rst:545 +#: ../../library/threading.rst:548 msgid "" "If the subclass overrides the constructor, it must make sure to invoke the " "base class constructor (``Thread.__init__()``) before doing anything else to " "the thread." msgstr "" -#: ../../library/threading.rst:549 +#: ../../library/threading.rst:552 msgid "Added the *daemon* parameter." msgstr "新增 *daemon* 參數。" -#: ../../library/threading.rst:552 +#: ../../library/threading.rst:555 msgid "Use the *target* name if *name* argument is omitted." msgstr "" -#: ../../library/threading.rst:555 +#: ../../library/threading.rst:558 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" -#: ../../library/threading.rst:560 +#: ../../library/threading.rst:563 msgid "Start the thread's activity." msgstr "" -#: ../../library/threading.rst:562 +#: ../../library/threading.rst:565 msgid "" "It must be called at most once per thread object. It arranges for the " "object's :meth:`~Thread.run` method to be invoked in a separate thread of " "control." msgstr "" -#: ../../library/threading.rst:566 +#: ../../library/threading.rst:569 msgid "" "This method will raise a :exc:`RuntimeError` if called more than once on the " "same thread object." msgstr "" -#: ../../library/threading.rst:569 +#: ../../library/threading.rst:572 msgid "" "If supported, set the operating system thread name to :attr:`threading." "Thread.name`. The name can be truncated depending on the operating system " "thread name limits." msgstr "" -#: ../../library/threading.rst:573 +#: ../../library/threading.rst:576 msgid "Set the operating system thread name." msgstr "" -#: ../../library/threading.rst:578 +#: ../../library/threading.rst:581 msgid "Method representing the thread's activity." msgstr "" -#: ../../library/threading.rst:580 +#: ../../library/threading.rst:583 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 " @@ -876,17 +880,17 @@ msgid "" "the *args* and *kwargs* arguments, respectively." msgstr "" -#: ../../library/threading.rst:585 +#: ../../library/threading.rst:588 msgid "" "Using list or tuple as the *args* argument which passed to the :class:" "`Thread` could achieve the same effect." msgstr "" -#: ../../library/threading.rst:588 +#: ../../library/threading.rst:591 msgid "Example::" msgstr "舉例來說: ::" -#: ../../library/threading.rst:590 +#: ../../library/threading.rst:593 msgid "" ">>> from threading import Thread\n" ">>> t = Thread(target=print, args=[1])\n" @@ -904,7 +908,7 @@ msgstr "" ">>> t.run()\n" "1" -#: ../../library/threading.rst:602 +#: ../../library/threading.rst:605 msgid "" "Wait until the thread terminates. This blocks the calling thread until the " "thread whose :meth:`~Thread.join` method is called terminates -- either " @@ -912,27 +916,27 @@ msgid "" "occurs." msgstr "" -#: ../../library/threading.rst:607 +#: ../../library/threading.rst:610 msgid "" -"When the *timeout* argument is present and not ``None``, it should be a " -"floating-point number specifying a timeout for the operation in seconds (or " -"fractions thereof). As :meth:`~Thread.join` always returns ``None``, you " -"must call :meth:`~Thread.is_alive` after :meth:`~Thread.join` to decide " -"whether a timeout happened -- if the thread is still alive, the :meth:" -"`~Thread.join` call timed out." +"When the *timeout* argument is present and not ``None``, it should be a real " +"number specifying a timeout for the operation in seconds (or fractions " +"thereof). As :meth:`~Thread.join` always returns ``None``, you must call :" +"meth:`~Thread.is_alive` after :meth:`~Thread.join` to decide whether a " +"timeout happened -- if the thread is still alive, the :meth:`~Thread.join` " +"call timed out." msgstr "" -#: ../../library/threading.rst:614 +#: ../../library/threading.rst:617 msgid "" "When the *timeout* argument is not present or ``None``, the operation will " "block until the thread terminates." msgstr "" -#: ../../library/threading.rst:617 +#: ../../library/threading.rst:620 msgid "A thread can be joined many times." msgstr "" -#: ../../library/threading.rst:619 +#: ../../library/threading.rst:622 msgid "" ":meth:`~Thread.join` raises a :exc:`RuntimeError` if an attempt is made to " "join the current thread as that would cause a deadlock. It is also an error " @@ -940,25 +944,30 @@ msgid "" "do so raise the same exception." msgstr "" -#: ../../library/threading.rst:624 +#: ../../library/threading.rst:627 msgid "" "If an attempt is made to join a running daemonic thread in late stages of :" "term:`Python finalization ` :meth:`!join` raises a :" "exc:`PythonFinalizationError`." msgstr "" -#: ../../library/threading.rst:630 +#: ../../library/threading.rst:633 msgid "May raise :exc:`PythonFinalizationError`." msgstr "可能引發 :exc:`PythonFinalizationError`。" -#: ../../library/threading.rst:634 +#: ../../library/threading.rst:635 ../../library/threading.rst:789 +#: ../../library/threading.rst:899 ../../library/threading.rst:1162 +msgid "Accepts any real number as *timeout*, not only integer or float." +msgstr "" + +#: ../../library/threading.rst:640 msgid "" "A string used for identification purposes only. It has no semantics. " "Multiple threads may be given the same name. The initial name is set by the " "constructor." msgstr "" -#: ../../library/threading.rst:638 +#: ../../library/threading.rst:644 msgid "" "On some platforms, the thread name is set at the operating system level when " "the thread starts, so that it is visible in task managers. This name may be " @@ -966,20 +975,20 @@ msgid "" "or 63 bytes on macOS)." msgstr "" -#: ../../library/threading.rst:643 +#: ../../library/threading.rst:649 msgid "" "Changes to *name* are only reflected at the OS level when the currently " "running thread is renamed. (Setting the *name* attribute of a different " "thread only updates the Python Thread object.)" msgstr "" -#: ../../library/threading.rst:650 +#: ../../library/threading.rst:656 msgid "" "Deprecated getter/setter API for :attr:`~Thread.name`; use it directly as a " "property instead." msgstr "" -#: ../../library/threading.rst:657 +#: ../../library/threading.rst:663 msgid "" "The 'thread identifier' of this thread or ``None`` if the thread has not " "been started. This is a nonzero integer. See the :func:`get_ident` " @@ -988,7 +997,7 @@ msgid "" "thread has exited." msgstr "" -#: ../../library/threading.rst:665 +#: ../../library/threading.rst:671 msgid "" "The Thread ID (``TID``) of this thread, as assigned by the OS (kernel). This " "is a non-negative integer, or ``None`` if the thread has not been started. " @@ -997,25 +1006,25 @@ msgid "" "after which the value may be recycled by the OS)." msgstr "" -#: ../../library/threading.rst:674 +#: ../../library/threading.rst:680 msgid "" "Similar to Process IDs, Thread IDs are only valid (guaranteed unique system-" "wide) from the time the thread is created until the thread has been " "terminated." msgstr "" -#: ../../library/threading.rst:684 +#: ../../library/threading.rst:690 msgid "Return whether the thread is alive." msgstr "" -#: ../../library/threading.rst:686 +#: ../../library/threading.rst:692 msgid "" "This method returns ``True`` just before the :meth:`~Thread.run` method " "starts until just after the :meth:`~Thread.run` method terminates. The " "module function :func:`.enumerate` returns a list of all alive threads." msgstr "" -#: ../../library/threading.rst:692 +#: ../../library/threading.rst:698 msgid "" "A boolean value indicating whether this thread is a daemon thread (``True``) " "or not (``False``). This must be set before :meth:`~Thread.start` is " @@ -1025,22 +1034,22 @@ msgid "" "`~Thread.daemon` = ``False``." msgstr "" -#: ../../library/threading.rst:699 +#: ../../library/threading.rst:705 msgid "" "The entire Python program exits when no alive non-daemon threads are left." msgstr "" -#: ../../library/threading.rst:704 +#: ../../library/threading.rst:710 msgid "" "Deprecated getter/setter API for :attr:`~Thread.daemon`; use it directly as " "a property instead." msgstr "" -#: ../../library/threading.rst:713 +#: ../../library/threading.rst:719 msgid "Lock objects" msgstr "Lock 物件" -#: ../../library/threading.rst:715 +#: ../../library/threading.rst:721 msgid "" "A primitive lock is a synchronization primitive that is not owned by a " "particular thread when locked. In Python, it is currently the lowest level " @@ -1051,7 +1060,7 @@ msgstr "" "不屬於特定執行緒。在 Python 中,它是目前可用的最低階同步原語,直接由 :mod:" "`_thread` 擴充模組實作。" -#: ../../library/threading.rst:720 +#: ../../library/threading.rst:726 msgid "" "A primitive lock is in one of two states, \"locked\" or \"unlocked\". It is " "created in the unlocked state. It has two basic methods, :meth:`~Lock." @@ -1073,11 +1082,11 @@ msgstr "" "下呼叫;它將狀態更改為未鎖定並立即回傳。如果嘗試釋放未鎖定的鎖,則會引發 :" "exc:`RuntimeError`。" -#: ../../library/threading.rst:731 +#: ../../library/threading.rst:737 msgid "Locks also support the :ref:`context management protocol `." msgstr "鎖也支援\\ :ref:`情境管理協定 `。" -#: ../../library/threading.rst:733 +#: ../../library/threading.rst:739 msgid "" "When more than one thread is blocked in :meth:`~Lock.acquire` waiting for " "the state to turn to unlocked, only one thread proceeds when a :meth:`~Lock." @@ -1088,11 +1097,11 @@ msgstr "" "meth:`~Lock.release` 將狀態重置為未鎖定,則只會有一個執行緒繼續進行;哪一個等" "待執行緒會繼續進行是未定義的,並且可能因實作而異。" -#: ../../library/threading.rst:738 +#: ../../library/threading.rst:744 msgid "All methods are executed atomically." msgstr "所有方法均以最小不可分割的操作方式 (atomically) 執行。" -#: ../../library/threading.rst:743 +#: ../../library/threading.rst:749 msgid "" "The class implementing primitive lock objects. Once a thread has acquired a " "lock, subsequent attempts to acquire it block, until it is released; any " @@ -1101,7 +1110,7 @@ msgstr "" "實作原語鎖物件的類別。一旦執行緒獲得了鎖,後續再嘗試獲得它就會被阻塞,直到鎖" "被釋放;任何執行緒都可以去釋放它。" -#: ../../library/threading.rst:747 +#: ../../library/threading.rst:753 msgid "" "``Lock`` is now a class. In earlier Pythons, ``Lock`` was a factory function " "which returned an instance of the underlying private lock type." @@ -1109,11 +1118,11 @@ msgstr "" "``Lock`` 現在是一個類別。在早期的 Python 中,``Lock`` 是一個會回傳底層私有鎖" "型別實例的工廠函式。" -#: ../../library/threading.rst:755 ../../library/threading.rst:849 +#: ../../library/threading.rst:761 ../../library/threading.rst:858 msgid "Acquire a lock, blocking or non-blocking." msgstr "阻塞或非阻塞地取得鎖。" -#: ../../library/threading.rst:757 +#: ../../library/threading.rst:763 msgid "" "When invoked with the *blocking* argument set to ``True`` (the default), " "block until the lock is unlocked, then set it to locked and return ``True``." @@ -1121,7 +1130,7 @@ msgstr "" "當以 *blocking* 引數設為 ``True``\\ (預設值)來叫用,將會阻塞直到鎖被解鎖," "然後將其設為鎖定並回傳 ``True``。" -#: ../../library/threading.rst:760 +#: ../../library/threading.rst:766 msgid "" "When invoked with the *blocking* argument set to ``False``, do not block. If " "a call with *blocking* set to ``True`` would block, return ``False`` " @@ -1131,19 +1140,18 @@ msgstr "" "``True`` 的呼叫會阻塞,則立即回傳 ``False``;否則將鎖設為鎖定並回傳 " "``True``。" -#: ../../library/threading.rst:764 +#: ../../library/threading.rst:770 msgid "" -"When invoked with the floating-point *timeout* argument set to a positive " -"value, block for at most the number of seconds specified by *timeout* and as " -"long as the lock cannot be acquired. A *timeout* argument of ``-1`` " -"specifies an unbounded wait. It is forbidden to specify a *timeout* when " -"*blocking* is ``False``." +"When invoked with the *timeout* argument set to a positive value, block for " +"at most the number of seconds specified by *timeout* and as long as the lock " +"cannot be acquired. A *timeout* argument of ``-1`` specifies an unbounded " +"wait. It is forbidden to specify a *timeout* when *blocking* is ``False``." msgstr "" -"當使用設定為正值的浮點 *timeout* 引數進行叫用,只要持續無法取得鎖,最多會阻" -"塞 *timeout* 指定的秒數。``-1`` 的 *timeout* 引數代表指定為不會停止的等待。" -"當 *blocking* 為 ``False`` 時禁止指定 *timeout*。" +"當使用設定為正值的 *timeout* 引數進行叫用,只要持續無法取得鎖,最多會阻塞 " +"*timeout* 指定的秒數。``-1`` 的 *timeout* 引數代表指定為不會停止的等待。當 " +"*blocking* 為 ``False`` 時禁止指定 *timeout*。" -#: ../../library/threading.rst:770 +#: ../../library/threading.rst:776 msgid "" "The return value is ``True`` if the lock is acquired successfully, ``False`` " "if not (for example if the *timeout* expired)." @@ -1151,28 +1159,28 @@ msgstr "" "如果成功取得鎖,則回傳值為 ``True``,否則回傳值為 ``False``\\ (例如像是 " "*timeout* 已逾期)。" -#: ../../library/threading.rst:773 ../../library/threading.rst:887 -#: ../../library/threading.rst:1147 +#: ../../library/threading.rst:779 ../../library/threading.rst:896 +#: ../../library/threading.rst:1159 msgid "The *timeout* parameter is new." msgstr "新的 *timeout* 參數。" -#: ../../library/threading.rst:776 +#: ../../library/threading.rst:782 msgid "" "Lock acquisition can now be interrupted by signals on POSIX if the " "underlying threading implementation supports it." msgstr "如果底層執行緒實作支援的話,鎖的取得現在可以被 POSIX 上的訊號中斷。" -#: ../../library/threading.rst:780 +#: ../../library/threading.rst:786 msgid "Lock acquisition can now be interrupted by signals on Windows." msgstr "" -#: ../../library/threading.rst:786 +#: ../../library/threading.rst:795 msgid "" "Release a lock. This can be called from any thread, not only the thread " "which has acquired the lock." msgstr "釋放鎖。這可以從任何執行緒呼叫,而不是只有獲得鎖的執行緒。" -#: ../../library/threading.rst:789 +#: ../../library/threading.rst:798 msgid "" "When the lock is locked, reset it to unlocked, and return. If any other " "threads are blocked waiting for the lock to become unlocked, allow exactly " @@ -1181,23 +1189,23 @@ msgstr "" "當鎖被鎖定時,將其重置為未鎖定然後回傳。如果任何其他執行緒在等待鎖被解鎖時被" "阻塞,只允許其中一個執行緒繼續進行。" -#: ../../library/threading.rst:793 +#: ../../library/threading.rst:802 msgid "When invoked on an unlocked lock, a :exc:`RuntimeError` is raised." msgstr "當在未鎖定的鎖上叫用時,會引發 :exc:`RuntimeError`" -#: ../../library/threading.rst:795 ../../library/threading.rst:903 +#: ../../library/threading.rst:804 ../../library/threading.rst:915 msgid "There is no return value." msgstr "沒有回傳值。" -#: ../../library/threading.rst:799 +#: ../../library/threading.rst:808 msgid "Return ``True`` if the lock is acquired." msgstr "如果有取得了鎖,則回傳 ``True``。" -#: ../../library/threading.rst:806 +#: ../../library/threading.rst:815 msgid "RLock objects" msgstr "RLock 物件" -#: ../../library/threading.rst:808 +#: ../../library/threading.rst:817 msgid "" "A reentrant lock is a synchronization primitive that may be acquired " "multiple times by the same thread. Internally, it uses the concepts of " @@ -1210,7 +1218,7 @@ msgstr "" "「遞迴等級 (recursion level)」的概念。在鎖定狀態下,某個執行緒會擁有鎖;在未" "鎖定狀態下則沒有執行緒擁有它。" -#: ../../library/threading.rst:814 +#: ../../library/threading.rst:823 msgid "" "Threads call a lock's :meth:`~RLock.acquire` method to lock it, and its :" "meth:`~Lock.release` method to unlock it." @@ -1218,7 +1226,7 @@ msgstr "" "執行緒呼叫鎖的 :meth:`~RLock.acquire` 方法來鎖定它,並呼叫它的 :meth:`~Lock." "release` 方法來解鎖它。" -#: ../../library/threading.rst:819 +#: ../../library/threading.rst:828 msgid "" "Reentrant locks support the :ref:`context management protocol `, " "so it is recommended to use :keyword:`with` instead of manually calling :" @@ -1229,7 +1237,7 @@ msgstr "" "而不是手動呼叫 :meth:`~RLock.acquire` 和 :meth:`~RLock.release` 來對程式碼區" "塊處理鎖的獲得和釋放。" -#: ../../library/threading.rst:824 +#: ../../library/threading.rst:833 msgid "" "RLock's :meth:`~RLock.acquire`/:meth:`~RLock.release` call pairs may be " "nested, unlike Lock's :meth:`~Lock.acquire`/:meth:`~Lock.release`. Only the " @@ -1242,7 +1250,7 @@ msgstr "" "個 :meth:`~RLock.release`\\ (最外面一對的 :meth:`~Lock.release`)會將鎖重置" "為未鎖定狀態,並允許在 :meth:`~RLock.acquire` 中阻塞的另一個執行緒繼續進行。" -#: ../../library/threading.rst:830 +#: ../../library/threading.rst:839 msgid "" ":meth:`~RLock.acquire`/:meth:`~RLock.release` must be used in pairs: each " "acquire must have a release in the thread that has acquired the lock. " @@ -1253,7 +1261,7 @@ msgstr "" "已獲得鎖的執行緒中有一個釋放。如果鎖釋放的次數不能和取得的次數一樣的話,可能" "會導致死鎖 (deadlock)。" -#: ../../library/threading.rst:837 +#: ../../library/threading.rst:846 msgid "" "This class implements reentrant lock objects. A reentrant lock must be " "released by the thread that acquired it. Once a thread has acquired a " @@ -1264,7 +1272,7 @@ msgstr "" "得了可重入鎖,同一個執行緒可以再次獲得它而不會阻塞;執行緒每次獲得它也都必須" "釋放它一次。" -#: ../../library/threading.rst:842 +#: ../../library/threading.rst:851 msgid "" "Note that ``RLock`` is actually a factory function which returns an instance " "of the most efficient version of the concrete RLock class that is supported " @@ -1273,11 +1281,11 @@ msgstr "" "請注意,``RLock`` 實際上是一個工廠函式,它會回傳平台有支援的特定 RLock 類別的" "最高效率版本的實例。" -#: ../../library/threading.rst:853 +#: ../../library/threading.rst:862 msgid ":ref:`Using RLock as a context manager `" msgstr ":ref:`將 RLock 用作為情境管理器 `" -#: ../../library/threading.rst:854 +#: ../../library/threading.rst:863 msgid "" "Recommended over manual :meth:`!acquire` and :meth:`release` calls whenever " "practical." @@ -1285,24 +1293,24 @@ msgstr "" "若是使用場景合理,和手動呼叫 :meth:`!acquire` 和 :meth:`release` 相比,會是更" "為推薦的使用方式。" -#: ../../library/threading.rst:858 +#: ../../library/threading.rst:867 msgid "" "When invoked with the *blocking* argument set to ``True`` (the default):" msgstr "當以 *blocking* 引數設為 ``True``\\ (預設值)來呼叫:" -#: ../../library/threading.rst:860 ../../library/threading.rst:872 +#: ../../library/threading.rst:869 ../../library/threading.rst:881 msgid "If no thread owns the lock, acquire the lock and return immediately." msgstr "如果沒有執行緒擁有鎖,則獲得鎖並立即回傳。" -#: ../../library/threading.rst:862 +#: ../../library/threading.rst:871 msgid "" "If another thread owns the lock, block until we are able to acquire lock, or " -"*timeout*, if set to a positive float value." +"*timeout*, if set to a positive value." msgstr "" "如果另一個執行緒擁有鎖,則阻塞直到能夠取得鎖,或者達到 *timeout*\\ (如果設定" -"為正浮點值)。" +"為正值)。" -#: ../../library/threading.rst:865 +#: ../../library/threading.rst:874 msgid "" "If the same thread owns the lock, acquire the lock again, and return " "immediately. This is the difference between :class:`Lock` and :class:`!" @@ -1313,21 +1321,21 @@ msgstr "" "class:`!RLock` 之間的差別;:class:`Lock` 處理方式與上一種情況相同,會阻塞直到" "能夠取得鎖。" -#: ../../library/threading.rst:870 +#: ../../library/threading.rst:879 msgid "When invoked with the *blocking* argument set to ``False``:" msgstr "當以 *blocking* 引數設為 ``False`` 來呼叫:" -#: ../../library/threading.rst:874 +#: ../../library/threading.rst:883 msgid "If another thread owns the lock, return immediately." msgstr "如果另一個執行緒擁有該鎖,則立即回傳。" -#: ../../library/threading.rst:876 +#: ../../library/threading.rst:885 msgid "" "If the same thread owns the lock, acquire the lock again and return " "immediately." msgstr "如果同一個執行緒擁有鎖,則再次取得鎖並立即回傳。" -#: ../../library/threading.rst:879 +#: ../../library/threading.rst:888 msgid "" "In all cases, if the thread was able to acquire the lock, return ``True``. " "If the thread was unable to acquire the lock (i.e. if not blocking or the " @@ -1336,7 +1344,7 @@ msgstr "" "在所有情況下,如果執行緒能夠取得鎖則回傳 ``True``。如果執行緒無法取得鎖(即沒" "有阻塞或已達超時限制)則回傳 ``False``。" -#: ../../library/threading.rst:883 +#: ../../library/threading.rst:892 msgid "" "If called multiple times, failing to call :meth:`~RLock.release` as many " "times may lead to deadlock. Consider using :class:`!RLock` as a context " @@ -1345,7 +1353,7 @@ msgstr "" "如果多次呼叫,又未能呼叫相同次數的 :meth:`~RLock.release`,則可能會導致死鎖。" "考慮將 :class:`!RLock` 作為情境管理器使用,而不是直接呼叫 acquire/release。" -#: ../../library/threading.rst:893 +#: ../../library/threading.rst:905 msgid "" "Release a lock, decrementing the recursion level. If after the decrement it " "is zero, reset the lock to unlocked (not owned by any thread), and if any " @@ -1357,7 +1365,7 @@ msgstr "" "並且如果任何其他執行緒被阻塞以等待鎖變成未鎖定狀態,則僅允許其中一個執行緒繼" "續進行。如果遞減後遞迴等級仍然非零,則鎖會保持鎖定並由呼叫它的執行緒所擁有。" -#: ../../library/threading.rst:899 +#: ../../library/threading.rst:911 msgid "" "Only call this method when the calling thread owns the lock. A :exc:" "`RuntimeError` is raised if this method is called when the lock is not " @@ -1366,15 +1374,15 @@ msgstr "" "僅當呼叫的執行緒擁有鎖時才能呼叫此方法。如果在未取得鎖時呼叫此方法則會引發 :" "exc:`RuntimeError`。" -#: ../../library/threading.rst:908 ../../library/threading.rst:1007 +#: ../../library/threading.rst:920 ../../library/threading.rst:1019 msgid "Return a boolean indicating whether this object is locked right now." msgstr "" -#: ../../library/threading.rst:916 +#: ../../library/threading.rst:928 msgid "Condition objects" msgstr "" -#: ../../library/threading.rst:918 +#: ../../library/threading.rst:930 msgid "" "A condition variable is always associated with some kind of lock; this can " "be passed in or one will be created by default. Passing one in is useful " @@ -1382,7 +1390,7 @@ msgid "" "of the condition object: you don't have to track it separately." msgstr "" -#: ../../library/threading.rst:923 +#: ../../library/threading.rst:935 msgid "" "A condition variable obeys the :ref:`context management protocol `: using the ``with`` statement acquires the associated lock for the " @@ -1391,7 +1399,7 @@ msgid "" "associated lock." msgstr "" -#: ../../library/threading.rst:929 +#: ../../library/threading.rst:941 msgid "" "Other methods must be called with the associated lock held. The :meth:" "`~Condition.wait` method releases the lock, and then blocks until another " @@ -1400,14 +1408,14 @@ msgid "" "and returns. It is also possible to specify a timeout." msgstr "" -#: ../../library/threading.rst:935 +#: ../../library/threading.rst:947 msgid "" "The :meth:`~Condition.notify` method wakes up one of the threads waiting for " "the condition variable, if any are waiting. The :meth:`~Condition." "notify_all` method wakes up all threads waiting for the condition variable." msgstr "" -#: ../../library/threading.rst:939 +#: ../../library/threading.rst:951 msgid "" "Note: the :meth:`~Condition.notify` and :meth:`~Condition.notify_all` " "methods don't release the lock; this means that the thread or threads " @@ -1416,7 +1424,7 @@ msgid "" "or :meth:`~Condition.notify_all` finally relinquishes ownership of the lock." msgstr "" -#: ../../library/threading.rst:945 +#: ../../library/threading.rst:957 msgid "" "The typical programming style using condition variables uses the lock to " "synchronize access to some shared state; threads that are interested in a " @@ -1428,7 +1436,7 @@ msgid "" "situation with unlimited buffer capacity::" msgstr "" -#: ../../library/threading.rst:954 +#: ../../library/threading.rst:966 msgid "" "# Consume one item\n" "with cv:\n" @@ -1442,7 +1450,7 @@ msgid "" " cv.notify()" msgstr "" -#: ../../library/threading.rst:965 +#: ../../library/threading.rst:977 msgid "" "The ``while`` loop checking for the application's condition is necessary " "because :meth:`~Condition.wait` can return after an arbitrary long time, and " @@ -1452,7 +1460,7 @@ msgid "" "checking, and eases the computation of timeouts::" msgstr "" -#: ../../library/threading.rst:972 +#: ../../library/threading.rst:984 msgid "" "# Consume an item\n" "with cv:\n" @@ -1460,7 +1468,7 @@ msgid "" " get_an_available_item()" msgstr "" -#: ../../library/threading.rst:977 +#: ../../library/threading.rst:989 msgid "" "To choose between :meth:`~Condition.notify` and :meth:`~Condition." "notify_all`, consider whether one state change can be interesting for only " @@ -1469,45 +1477,45 @@ msgid "" "thread." msgstr "" -#: ../../library/threading.rst:985 +#: ../../library/threading.rst:997 msgid "" "This class implements condition variable objects. A condition variable " "allows one or more threads to wait until they are notified by another thread." msgstr "" -#: ../../library/threading.rst:988 +#: ../../library/threading.rst:1000 msgid "" "If the *lock* argument is given and not ``None``, it must be a :class:`Lock` " "or :class:`RLock` object, and it is used as the underlying lock. Otherwise, " "a new :class:`RLock` object is created and used as the underlying lock." msgstr "" -#: ../../library/threading.rst:992 ../../library/threading.rst:1122 -#: ../../library/threading.rst:1168 ../../library/threading.rst:1220 -#: ../../library/threading.rst:1288 +#: ../../library/threading.rst:1004 ../../library/threading.rst:1134 +#: ../../library/threading.rst:1183 ../../library/threading.rst:1235 +#: ../../library/threading.rst:1303 msgid "changed from a factory function to a class." msgstr "" -#: ../../library/threading.rst:997 +#: ../../library/threading.rst:1009 msgid "" "Acquire the underlying lock. This method calls the corresponding method on " "the underlying lock; the return value is whatever that method returns." msgstr "" -#: ../../library/threading.rst:1002 +#: ../../library/threading.rst:1014 msgid "" "Release the underlying lock. This method calls the corresponding method on " "the underlying lock; there is no return value." msgstr "" -#: ../../library/threading.rst:1013 +#: ../../library/threading.rst:1025 msgid "" "Wait until notified or until a timeout occurs. If the calling thread has not " "acquired the lock when this method is called, a :exc:`RuntimeError` is " "raised." msgstr "" -#: ../../library/threading.rst:1017 +#: ../../library/threading.rst:1029 msgid "" "This method releases the underlying lock, and then blocks until it is " "awakened by a :meth:`notify` or :meth:`notify_all` call for the same " @@ -1515,14 +1523,14 @@ msgid "" "Once awakened or timed out, it re-acquires the lock and returns." msgstr "" -#: ../../library/threading.rst:1022 +#: ../../library/threading.rst:1034 msgid "" -"When the *timeout* argument is present and not ``None``, it should be a " -"floating-point number specifying a timeout for the operation in seconds (or " -"fractions thereof)." +"When the *timeout* argument is present and not ``None``, it should be a real " +"number specifying a timeout for the operation in seconds (or fractions " +"thereof)." msgstr "" -#: ../../library/threading.rst:1026 +#: ../../library/threading.rst:1038 msgid "" "When the underlying lock is an :class:`RLock`, it is not released using its :" "meth:`release` method, since this may not actually unlock the lock when it " @@ -1532,24 +1540,24 @@ msgid "" "used to restore the recursion level when the lock is reacquired." msgstr "" -#: ../../library/threading.rst:1034 +#: ../../library/threading.rst:1046 msgid "" "The return value is ``True`` unless a given *timeout* expired, in which case " "it is ``False``." msgstr "" -#: ../../library/threading.rst:1037 ../../library/threading.rst:1253 +#: ../../library/threading.rst:1049 ../../library/threading.rst:1268 msgid "Previously, the method always returned ``None``." msgstr "先前此方法總是回傳 ``None``。" -#: ../../library/threading.rst:1042 +#: ../../library/threading.rst:1054 msgid "" "Wait until a condition evaluates to true. *predicate* should be a callable " "which result will be interpreted as a boolean value. A *timeout* may be " "provided giving the maximum time to wait." msgstr "" -#: ../../library/threading.rst:1046 +#: ../../library/threading.rst:1058 msgid "" "This utility method may call :meth:`wait` repeatedly until the predicate is " "satisfied, or until a timeout occurs. The return value is the last return " @@ -1557,13 +1565,13 @@ msgid "" "out." msgstr "" -#: ../../library/threading.rst:1051 +#: ../../library/threading.rst:1063 msgid "" "Ignoring the timeout feature, calling this method is roughly equivalent to " "writing::" msgstr "" -#: ../../library/threading.rst:1054 +#: ../../library/threading.rst:1066 msgid "" "while not predicate():\n" " cv.wait()" @@ -1571,27 +1579,27 @@ msgstr "" "while not predicate():\n" " cv.wait()" -#: ../../library/threading.rst:1057 +#: ../../library/threading.rst:1069 msgid "" "Therefore, the same rules apply as with :meth:`wait`: The lock must be held " "when called and is re-acquired on return. The predicate is evaluated with " "the lock held." msgstr "" -#: ../../library/threading.rst:1065 +#: ../../library/threading.rst:1077 msgid "" "By default, wake up one thread waiting on this condition, if any. If the " "calling thread has not acquired the lock when this method is called, a :exc:" "`RuntimeError` is raised." msgstr "" -#: ../../library/threading.rst:1069 +#: ../../library/threading.rst:1081 msgid "" "This method wakes up at most *n* of the threads waiting for the condition " "variable; it is a no-op if no threads are waiting." msgstr "" -#: ../../library/threading.rst:1072 +#: ../../library/threading.rst:1084 msgid "" "The current implementation wakes up exactly *n* threads, if at least *n* " "threads are waiting. However, it's not safe to rely on this behavior. A " @@ -1599,14 +1607,14 @@ msgid "" "threads." msgstr "" -#: ../../library/threading.rst:1077 +#: ../../library/threading.rst:1089 msgid "" "Note: an awakened thread does not actually return from its :meth:`wait` call " "until it can reacquire the lock. Since :meth:`notify` does not release the " "lock, its caller should." msgstr "" -#: ../../library/threading.rst:1083 +#: ../../library/threading.rst:1095 msgid "" "Wake up all threads waiting on this condition. This method acts like :meth:" "`notify`, but wakes up all waiting threads instead of one. If the calling " @@ -1614,15 +1622,15 @@ msgid "" "`RuntimeError` is raised." msgstr "" -#: ../../library/threading.rst:1088 +#: ../../library/threading.rst:1100 msgid "The method ``notifyAll`` is a deprecated alias for this method." msgstr "" -#: ../../library/threading.rst:1094 +#: ../../library/threading.rst:1106 msgid "Semaphore objects" msgstr "Semaphore 物件" -#: ../../library/threading.rst:1096 +#: ../../library/threading.rst:1108 msgid "" "This is one of the oldest synchronization primitives in the history of " "computer science, invented by the early Dutch computer scientist Edsger W. " @@ -1630,7 +1638,7 @@ msgid "" "acquire` and :meth:`~Semaphore.release`)." msgstr "" -#: ../../library/threading.rst:1101 +#: ../../library/threading.rst:1113 msgid "" "A semaphore manages an internal counter which is decremented by each :meth:" "`~Semaphore.acquire` call and incremented by each :meth:`~Semaphore.release` " @@ -1639,12 +1647,12 @@ msgid "" "meth:`~Semaphore.release`." msgstr "" -#: ../../library/threading.rst:1107 +#: ../../library/threading.rst:1119 msgid "" "Semaphores also support the :ref:`context management protocol `." msgstr "" -#: ../../library/threading.rst:1112 +#: ../../library/threading.rst:1124 msgid "" "This class implements semaphore objects. A semaphore manages an atomic " "counter representing the number of :meth:`release` calls minus the number " @@ -1653,28 +1661,28 @@ msgid "" "If not given, *value* defaults to 1." msgstr "" -#: ../../library/threading.rst:1118 +#: ../../library/threading.rst:1130 msgid "" "The optional argument gives the initial *value* for the internal counter; it " "defaults to ``1``. If the *value* given is less than 0, :exc:`ValueError` is " "raised." msgstr "" -#: ../../library/threading.rst:1127 +#: ../../library/threading.rst:1139 msgid "Acquire a semaphore." msgstr "" -#: ../../library/threading.rst:1129 +#: ../../library/threading.rst:1141 msgid "When invoked without arguments:" msgstr "" -#: ../../library/threading.rst:1131 +#: ../../library/threading.rst:1143 msgid "" "If the internal counter is larger than zero on entry, decrement it by one " "and return ``True`` immediately." msgstr "" -#: ../../library/threading.rst:1133 +#: ../../library/threading.rst:1145 msgid "" "If the internal counter is zero on entry, block until awoken by a call to :" "meth:`~Semaphore.release`. Once awoken (and the counter is greater than 0), " @@ -1683,32 +1691,32 @@ msgid "" "threads are awoken should not be relied on." msgstr "" -#: ../../library/threading.rst:1139 +#: ../../library/threading.rst:1151 msgid "" "When invoked with *blocking* set to ``False``, do not block. If a call " "without an argument would block, return ``False`` immediately; otherwise, do " "the same thing as when called without arguments, and return ``True``." msgstr "" -#: ../../library/threading.rst:1143 +#: ../../library/threading.rst:1155 msgid "" "When invoked with a *timeout* other than ``None``, it will block for at most " "*timeout* seconds. If acquire does not complete successfully in that " "interval, return ``False``. Return ``True`` otherwise." msgstr "" -#: ../../library/threading.rst:1152 +#: ../../library/threading.rst:1167 msgid "" "Release a semaphore, incrementing the internal counter by *n*. When it was " "zero on entry and other threads are waiting for it to become larger than " "zero again, wake up *n* of those threads." msgstr "" -#: ../../library/threading.rst:1156 +#: ../../library/threading.rst:1171 msgid "Added the *n* parameter to release multiple waiting threads at once." msgstr "" -#: ../../library/threading.rst:1162 +#: ../../library/threading.rst:1177 msgid "" "Class implementing bounded semaphore objects. A bounded semaphore checks to " "make sure its current value doesn't exceed its initial value. If it does, :" @@ -1717,11 +1725,11 @@ msgid "" "times it's a sign of a bug. If not given, *value* defaults to 1." msgstr "" -#: ../../library/threading.rst:1175 +#: ../../library/threading.rst:1190 msgid ":class:`Semaphore` example" msgstr ":class:`Semaphore` 範例" -#: ../../library/threading.rst:1177 +#: ../../library/threading.rst:1192 msgid "" "Semaphores are often used to guard resources with limited capacity, for " "example, a database server. In any situation where the size of the resource " @@ -1729,7 +1737,7 @@ msgid "" "threads, your main thread would initialize the semaphore::" msgstr "" -#: ../../library/threading.rst:1182 +#: ../../library/threading.rst:1197 msgid "" "maxconnections = 5\n" "# ...\n" @@ -1739,13 +1747,13 @@ msgstr "" "# ...\n" "pool_sema = BoundedSemaphore(value=maxconnections)" -#: ../../library/threading.rst:1186 +#: ../../library/threading.rst:1201 msgid "" "Once spawned, worker threads call the semaphore's acquire and release " "methods when they need to connect to the server::" msgstr "" -#: ../../library/threading.rst:1189 +#: ../../library/threading.rst:1204 msgid "" "with pool_sema:\n" " conn = connectdb()\n" @@ -1761,31 +1769,31 @@ msgstr "" " finally:\n" " conn.close()" -#: ../../library/threading.rst:1196 +#: ../../library/threading.rst:1211 msgid "" "The use of a bounded semaphore reduces the chance that a programming error " "which causes the semaphore to be released more than it's acquired will go " "undetected." msgstr "" -#: ../../library/threading.rst:1203 +#: ../../library/threading.rst:1218 msgid "Event objects" msgstr "" -#: ../../library/threading.rst:1205 +#: ../../library/threading.rst:1220 msgid "" "This is one of the simplest mechanisms for communication between threads: " "one thread signals an event and other threads wait for it." msgstr "" -#: ../../library/threading.rst:1208 +#: ../../library/threading.rst:1223 msgid "" "An event object manages an internal flag that can be set to true with the :" "meth:`~Event.set` method and reset to false with the :meth:`~Event.clear` " "method. The :meth:`~Event.wait` method blocks until the flag is true." msgstr "" -#: ../../library/threading.rst:1215 +#: ../../library/threading.rst:1230 msgid "" "Class implementing event objects. An event manages a flag that can be set " "to true with the :meth:`~Event.set` method and reset to false with the :meth:" @@ -1793,29 +1801,29 @@ msgid "" "flag is initially false." msgstr "" -#: ../../library/threading.rst:1225 +#: ../../library/threading.rst:1240 msgid "Return ``True`` if and only if the internal flag is true." msgstr "" -#: ../../library/threading.rst:1227 +#: ../../library/threading.rst:1242 msgid "The method ``isSet`` is a deprecated alias for this method." msgstr "" -#: ../../library/threading.rst:1231 +#: ../../library/threading.rst:1246 msgid "" "Set the internal flag to true. All threads waiting for it to become true are " "awakened. Threads that call :meth:`wait` once the flag is true will not " "block at all." msgstr "" -#: ../../library/threading.rst:1237 +#: ../../library/threading.rst:1252 msgid "" "Reset the internal flag to false. Subsequently, threads calling :meth:`wait` " "will block until :meth:`.set` is called to set the internal flag to true " "again." msgstr "" -#: ../../library/threading.rst:1243 +#: ../../library/threading.rst:1258 msgid "" "Block as long as the internal flag is false and the timeout, if given, has " "not expired. The return value represents the reason that this blocking " @@ -1824,18 +1832,18 @@ msgid "" "become true within the given wait time." msgstr "" -#: ../../library/threading.rst:1249 +#: ../../library/threading.rst:1264 msgid "" -"When the timeout argument is present and not ``None``, it should be a " -"floating-point number specifying a timeout for the operation in seconds, or " -"fractions thereof." +"When the timeout argument is present and not ``None``, it should be a real " +"number specifying a timeout for the operation in seconds, or fractions " +"thereof." msgstr "" -#: ../../library/threading.rst:1260 +#: ../../library/threading.rst:1275 msgid "Timer objects" msgstr "Timer 物件" -#: ../../library/threading.rst:1262 +#: ../../library/threading.rst:1277 msgid "" "This class represents an action that should be run only after a certain " "amount of time has passed --- a timer. :class:`Timer` is a subclass of :" @@ -1843,7 +1851,7 @@ msgid "" "threads." msgstr "" -#: ../../library/threading.rst:1266 +#: ../../library/threading.rst:1281 msgid "" "Timers are started, as with threads, by calling their :meth:`Timer.start " "` method. The timer can be stopped (before its action has " @@ -1852,11 +1860,11 @@ msgid "" "interval specified by the user." msgstr "" -#: ../../library/threading.rst:1272 +#: ../../library/threading.rst:1287 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/threading.rst:1274 +#: ../../library/threading.rst:1289 msgid "" "def hello():\n" " print(\"hello, world\")\n" @@ -1870,7 +1878,7 @@ msgstr "" "t = Timer(30.0, hello)\n" "t.start() # 30 秒後會印出 \"hello, world\"" -#: ../../library/threading.rst:1283 +#: ../../library/threading.rst:1298 msgid "" "Create a timer that will run *function* with arguments *args* and keyword " "arguments *kwargs*, after *interval* seconds have passed. If *args* is " @@ -1878,17 +1886,17 @@ msgid "" "``None`` (the default) then an empty dict will be used." msgstr "" -#: ../../library/threading.rst:1293 +#: ../../library/threading.rst:1308 msgid "" "Stop the timer, and cancel the execution of the timer's action. This will " "only work if the timer is still in its waiting stage." msgstr "" -#: ../../library/threading.rst:1298 +#: ../../library/threading.rst:1313 msgid "Barrier objects" msgstr "Barrier 物件" -#: ../../library/threading.rst:1302 +#: ../../library/threading.rst:1317 msgid "" "This class provides a simple synchronization primitive for use by a fixed " "number of threads that need to wait for each other. Each of the threads " @@ -1897,18 +1905,18 @@ msgid "" "calls. At this point, the threads are released simultaneously." msgstr "" -#: ../../library/threading.rst:1308 +#: ../../library/threading.rst:1323 msgid "" "The barrier can be reused any number of times for the same number of threads." msgstr "" -#: ../../library/threading.rst:1310 +#: ../../library/threading.rst:1325 msgid "" "As an example, here is a simple way to synchronize a client and server " "thread::" msgstr "" -#: ../../library/threading.rst:1312 +#: ../../library/threading.rst:1327 msgid "" "b = Barrier(2, timeout=5)\n" "\n" @@ -1940,7 +1948,7 @@ msgstr "" " connection = make_connection()\n" " process_client_connection(connection)" -#: ../../library/threading.rst:1330 +#: ../../library/threading.rst:1345 msgid "" "Create a barrier object for *parties* number of threads. An *action*, when " "provided, is a callable to be called by one of the threads when they are " @@ -1948,7 +1956,7 @@ msgid "" "the :meth:`wait` method." msgstr "" -#: ../../library/threading.rst:1337 +#: ../../library/threading.rst:1352 msgid "" "Pass the barrier. When all the threads party to the barrier have called " "this function, they are all released simultaneously. If a *timeout* is " @@ -1956,14 +1964,14 @@ msgid "" "constructor." msgstr "" -#: ../../library/threading.rst:1342 +#: ../../library/threading.rst:1357 msgid "" "The return value is an integer in the range 0 to *parties* -- 1, different " "for each thread. This can be used to select a thread to do some special " "housekeeping, e.g.::" msgstr "" -#: ../../library/threading.rst:1346 +#: ../../library/threading.rst:1361 msgid "" "i = barrier.wait()\n" "if i == 0:\n" @@ -1975,37 +1983,37 @@ msgstr "" " # 只會有一個執行緒會印出這個\n" " print(\"passed the barrier\")" -#: ../../library/threading.rst:1351 +#: ../../library/threading.rst:1366 msgid "" "If an *action* was provided to the constructor, one of the threads will have " "called it prior to being released. Should this call raise an error, the " "barrier is put into the broken state." msgstr "" -#: ../../library/threading.rst:1355 +#: ../../library/threading.rst:1370 msgid "If the call times out, the barrier is put into the broken state." msgstr "" -#: ../../library/threading.rst:1357 +#: ../../library/threading.rst:1372 msgid "" "This method may raise a :class:`BrokenBarrierError` exception if the barrier " "is broken or reset while a thread is waiting." msgstr "" -#: ../../library/threading.rst:1362 +#: ../../library/threading.rst:1377 msgid "" "Return the barrier to the default, empty state. Any threads waiting on it " "will receive the :class:`BrokenBarrierError` exception." msgstr "" -#: ../../library/threading.rst:1365 +#: ../../library/threading.rst:1380 msgid "" "Note that using this function may require some external synchronization if " "there are other threads whose state is unknown. If a barrier is broken it " "may be better to just leave it and create a new one." msgstr "" -#: ../../library/threading.rst:1371 +#: ../../library/threading.rst:1386 msgid "" "Put the barrier into a broken state. This causes any active or future calls " "to :meth:`wait` to fail with the :class:`BrokenBarrierError`. Use this for " @@ -2013,36 +2021,36 @@ msgid "" "application." msgstr "" -#: ../../library/threading.rst:1376 +#: ../../library/threading.rst:1391 msgid "" "It may be preferable to simply create the barrier with a sensible *timeout* " "value to automatically guard against one of the threads going awry." msgstr "" -#: ../../library/threading.rst:1382 +#: ../../library/threading.rst:1397 msgid "The number of threads required to pass the barrier." msgstr "" -#: ../../library/threading.rst:1386 +#: ../../library/threading.rst:1401 msgid "The number of threads currently waiting in the barrier." msgstr "" -#: ../../library/threading.rst:1390 +#: ../../library/threading.rst:1405 msgid "A boolean that is ``True`` if the barrier is in the broken state." msgstr "" -#: ../../library/threading.rst:1395 +#: ../../library/threading.rst:1410 msgid "" "This exception, a subclass of :exc:`RuntimeError`, is raised when the :class:" "`Barrier` object is reset or broken." msgstr "" -#: ../../library/threading.rst:1402 +#: ../../library/threading.rst:1417 msgid "" "Using locks, conditions, and semaphores in the :keyword:`!with` statement" msgstr "" -#: ../../library/threading.rst:1404 +#: ../../library/threading.rst:1419 msgid "" "All of the objects provided by this module that have ``acquire`` and " "``release`` methods can be used as context managers for a :keyword:`with` " @@ -2051,7 +2059,7 @@ msgid "" "following snippet::" msgstr "" -#: ../../library/threading.rst:1410 +#: ../../library/threading.rst:1425 msgid "" "with some_lock:\n" " # do something..." @@ -2059,11 +2067,11 @@ msgstr "" "with some_lock:\n" " # 做某些事情..." -#: ../../library/threading.rst:1413 +#: ../../library/threading.rst:1428 msgid "is equivalent to::" msgstr "" -#: ../../library/threading.rst:1415 +#: ../../library/threading.rst:1430 msgid "" "some_lock.acquire()\n" "try:\n" @@ -2077,22 +2085,273 @@ msgstr "" "finally:\n" " some_lock.release()" -#: ../../library/threading.rst:1421 +#: ../../library/threading.rst:1436 msgid "" "Currently, :class:`Lock`, :class:`RLock`, :class:`Condition`, :class:" "`Semaphore`, and :class:`BoundedSemaphore` objects may be used as :keyword:" "`with` statement context managers." msgstr "" -#: ../../library/threading.rst:222 ../../library/threading.rst:240 +#: ../../library/threading.rst:1442 +msgid "Iterator synchronization" +msgstr "" + +#: ../../library/threading.rst:1444 +msgid "" +"By default, Python iterators do not support concurrent access. Most " +"iterators make no guarantees when accessed simultaneously from multiple " +"threads. Generator iterators, for example, raise :exc:`ValueError` if one of " +"their iterator methods is called while the generator is already executing. " +"The tools in this section allow reliable concurrency support to be added to " +"ordinary iterators and iterator-producing callables." +msgstr "" + +#: ../../library/threading.rst:1451 +msgid "" +"The :class:`serialize_iterator` wrapper lets multiple threads share a single " +"iterator and take turns consuming from it. While one thread is running " +"``__next__()``, the others block until the iterator becomes available. Each " +"value produced by the underlying iterator is delivered to exactly one caller." +msgstr "" + +#: ../../library/threading.rst:1456 +msgid "" +"The :func:`concurrent_tee` function lets multiple threads each receive the " +"full stream of values from one underlying iterator. It creates independent " +"iterators that all draw from the same source. Values are buffered until " +"consumed by all of the derived iterators." +msgstr "" + +#: ../../library/threading.rst:1463 +msgid "" +"Return an iterator wrapper that serializes concurrent calls to :meth:" +"`~iterator.__next__` using a lock." +msgstr "" + +#: ../../library/threading.rst:1466 +msgid "" +"If the wrapped iterator also defines :meth:`~generator.send`, :meth:" +"`~generator.throw`, or :meth:`~generator.close`, those calls are serialized " +"as well." +msgstr "" + +#: ../../library/threading.rst:1470 +msgid "" +"This makes it possible to share a single iterator, including a generator " +"iterator, between multiple threads. A lock ensures that calls are handled " +"one at a time. No values are duplicated or skipped by the wrapper itself. " +"Each item from the underlying iterator is given to exactly one caller." +msgstr "" + +#: ../../library/threading.rst:1475 +msgid "" +"This wrapper does not copy or buffer values. Threads that call :func:`next` " +"while another thread is already advancing the iterator will block until the " +"active call completes." +msgstr "" + +#: ../../library/threading.rst:1479 ../../library/threading.rst:1516 +#: ../../library/threading.rst:1567 +msgid "Example:" +msgstr "舉例來說:" + +#: ../../library/threading.rst:1481 +msgid "" +"import threading\n" +"\n" +"def squares(n):\n" +" for x in range(n):\n" +" yield x * x\n" +"\n" +"def consume(name, iterable):\n" +" for item in iterable:\n" +" print(name, item)\n" +"\n" +"source = threading.serialize_iterator(squares(5))\n" +"\n" +"t1 = threading.Thread(target=consume, args=(\"left\", source))\n" +"t2 = threading.Thread(target=consume, args=(\"right\", source))\n" +"t1.start()\n" +"t2.start()\n" +"t1.join()\n" +"t2.join()" +msgstr "" +"import threading\n" +"\n" +"def squares(n):\n" +" for x in range(n):\n" +" yield x * x\n" +"\n" +"def consume(name, iterable):\n" +" for item in iterable:\n" +" print(name, item)\n" +"\n" +"source = threading.serialize_iterator(squares(5))\n" +"\n" +"t1 = threading.Thread(target=consume, args=(\"left\", source))\n" +"t2 = threading.Thread(target=consume, args=(\"right\", source))\n" +"t1.start()\n" +"t2.start()\n" +"t1.join()\n" +"t2.join()" + +#: ../../library/threading.rst:1502 +msgid "" +"In this example, each number is printed exactly once, but the work is shared " +"between the two threads." +msgstr "" + +#: ../../library/threading.rst:1510 +msgid "" +"Wrap an iterator-producing callable so that each iterator it returns is " +"automatically passed through :class:`serialize_iterator`." +msgstr "" + +#: ../../library/threading.rst:1513 +msgid "" +"This is especially useful as a :term:`decorator` for generator functions, " +"allowing their generator-iterators to be consumed from multiple threads." +msgstr "" + +#: ../../library/threading.rst:1518 +msgid "" +"import threading\n" +"\n" +"@threading.synchronized_iterator\n" +"def squares(n):\n" +" for x in range(n):\n" +" yield x * x\n" +"\n" +"def consume(name, iterable):\n" +" for item in iterable:\n" +" print(name, item)\n" +"\n" +"source = squares(5)\n" +"\n" +"t1 = threading.Thread(target=consume, args=(\"left\", source))\n" +"t2 = threading.Thread(target=consume, args=(\"right\", source))\n" +"t1.start()\n" +"t2.start()\n" +"t1.join()\n" +"t2.join()" +msgstr "" +"import threading\n" +"\n" +"@threading.synchronized_iterator\n" +"def squares(n):\n" +" for x in range(n):\n" +" yield x * x\n" +"\n" +"def consume(name, iterable):\n" +" for item in iterable:\n" +" print(name, item)\n" +"\n" +"source = squares(5)\n" +"\n" +"t1 = threading.Thread(target=consume, args=(\"left\", source))\n" +"t2 = threading.Thread(target=consume, args=(\"right\", source))\n" +"t1.start()\n" +"t2.start()\n" +"t1.join()\n" +"t2.join()" + +#: ../../library/threading.rst:1540 +msgid "" +"The returned wrapper preserves the metadata of *func*, such as its name and " +"wrapped function reference." +msgstr "" + +#: ../../library/threading.rst:1548 +msgid "" +"Return *n* independent iterators from a single input *iterable*, with " +"guaranteed behavior when the derived iterators are consumed concurrently." +msgstr "" + +#: ../../library/threading.rst:1551 +msgid "" +"This function is similar to :func:`itertools.tee`, but is intended for cases " +"where the source iterator may feed consumers running in different threads. " +"Each returned iterator yields every value from the underlying iterable, in " +"the same order." +msgstr "" + +#: ../../library/threading.rst:1556 +msgid "" +"Internally, values are buffered until every derived iterator has consumed " +"them." +msgstr "" + +#: ../../library/threading.rst:1559 +msgid "" +"The returned iterators share the same underlying synchronization lock. Each " +"individual derived iterator is intended to be consumed by one thread at a " +"time. If a single derived iterator must itself be shared by multiple " +"threads, wrap it with :class:`serialize_iterator`." +msgstr "" + +#: ../../library/threading.rst:1564 +msgid "" +"If *n* is ``0``, return an empty tuple. If *n* is negative, raise :exc:" +"`ValueError`." +msgstr "" + +#: ../../library/threading.rst:1569 +msgid "" +"import threading\n" +"\n" +"def squares(n):\n" +" for x in range(n):\n" +" yield x * x\n" +"\n" +"def consume(name, iterable):\n" +" for item in iterable:\n" +" print(name, item)\n" +"\n" +"source = squares(5)\n" +"left, right = threading.concurrent_tee(source)\n" +"\n" +"t1 = threading.Thread(target=consume, args=(\"left\", left))\n" +"t2 = threading.Thread(target=consume, args=(\"right\", right))\n" +"t1.start()\n" +"t2.start()\n" +"t1.join()\n" +"t2.join()" +msgstr "" +"import threading\n" +"\n" +"def squares(n):\n" +" for x in range(n):\n" +" yield x * x\n" +"\n" +"def consume(name, iterable):\n" +" for item in iterable:\n" +" print(name, item)\n" +"\n" +"source = squares(5)\n" +"left, right = threading.concurrent_tee(source)\n" +"\n" +"t1 = threading.Thread(target=consume, args=(\"left\", left))\n" +"t2 = threading.Thread(target=consume, args=(\"right\", right))\n" +"t1.start()\n" +"t2.start()\n" +"t1.join()\n" +"t2.join()" + +#: ../../library/threading.rst:1591 +msgid "" +"In this example, both consumer threads see the full sequence of squares from " +"a single generator expression." +msgstr "" + +#: ../../library/threading.rst:225 ../../library/threading.rst:243 msgid "trace function" msgstr "" -#: ../../library/threading.rst:240 +#: ../../library/threading.rst:243 msgid "debugger" msgstr "debugger(除錯器)" -#: ../../library/threading.rst:251 ../../library/threading.rst:269 +#: ../../library/threading.rst:254 ../../library/threading.rst:272 msgid "profile function" msgstr "" diff --git a/library/time.po b/library/time.po index e0304eb5227..1e8bb34aaa4 100644 --- a/library/time.po +++ b/library/time.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-16 00:10+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -267,15 +267,15 @@ msgstr "" #: ../../library/time.rst:154 ../../library/time.rst:166 #: ../../library/time.rst:179 ../../library/time.rst:188 -#: ../../library/time.rst:201 ../../library/time.rst:210 -#: ../../library/time.rst:760 ../../library/time.rst:784 -#: ../../library/time.rst:880 ../../library/time.rst:891 -#: ../../library/time.rst:901 ../../library/time.rst:911 -#: ../../library/time.rst:920 ../../library/time.rst:929 -#: ../../library/time.rst:938 ../../library/time.rst:949 -#: ../../library/time.rst:957 ../../library/time.rst:968 -#: ../../library/time.rst:979 ../../library/time.rst:988 -#: ../../library/time.rst:1001 +#: ../../library/time.rst:201 ../../library/time.rst:213 +#: ../../library/time.rst:774 ../../library/time.rst:798 +#: ../../library/time.rst:894 ../../library/time.rst:905 +#: ../../library/time.rst:915 ../../library/time.rst:925 +#: ../../library/time.rst:934 ../../library/time.rst:943 +#: ../../library/time.rst:952 ../../library/time.rst:963 +#: ../../library/time.rst:971 ../../library/time.rst:982 +#: ../../library/time.rst:993 ../../library/time.rst:1002 +#: ../../library/time.rst:1015 msgid "Availability" msgstr "可用性" @@ -328,11 +328,15 @@ msgid "" msgstr "" "使用 :func:`clock_settime_ns` 以避免 :class:`float` 型別造成的精確度損失。" -#: ../../library/time.rst:208 +#: ../../library/time.rst:205 +msgid "Accepts any real number as *time*, not only integer or float." +msgstr "" + +#: ../../library/time.rst:211 msgid "Similar to :func:`clock_settime` but set time with nanoseconds." msgstr "類似於 :func:`clock_settime`,但設定以奈秒為單位的時間。" -#: ../../library/time.rst:217 +#: ../../library/time.rst:220 msgid "" "Convert a time expressed in seconds since the epoch_ to a string of a form: " "``'Sun Jun 20 23:21:05 1993'`` representing local time. The day field is two " @@ -343,7 +347,7 @@ msgstr "" "Jun 20 23:21:05 1993'``。日期欄位為兩個字元長,如果日期是個位數,則用空格填" "充,例如:``'Wed Jun 9 04:26:40 1993'``。" -#: ../../library/time.rst:222 +#: ../../library/time.rst:225 msgid "" "If *seconds* is not provided or :const:`None`, the current time as returned " "by :func:`.time` is used. ``ctime(seconds)`` is equivalent to " @@ -354,7 +358,12 @@ msgstr "" "時間。``ctime(seconds)`` 等同於 " "``asctime(localtime(seconds))``。:func:`ctime` 不使用區域資訊。" -#: ../../library/time.rst:230 +#: ../../library/time.rst:230 ../../library/time.rst:268 +#: ../../library/time.rst:285 ../../library/time.rst:448 +msgid "Accepts any real number, not only integer or float." +msgstr "" + +#: ../../library/time.rst:236 msgid "" "Get information on the specified clock as a namespace object. Supported " "clock names and the corresponding functions to read their value are:" @@ -362,31 +371,31 @@ msgstr "" "取得指定時鐘的資訊作為命名空間物件。支援的時鐘名稱及讀取他們的值的對應函式如" "下:" -#: ../../library/time.rst:234 +#: ../../library/time.rst:240 msgid "``'monotonic'``: :func:`time.monotonic`" msgstr "``'monotonic'``::func:`time.monotonic`" -#: ../../library/time.rst:235 +#: ../../library/time.rst:241 msgid "``'perf_counter'``: :func:`time.perf_counter`" msgstr "``'perf_counter'``::func:`time.perf_counter`" -#: ../../library/time.rst:236 +#: ../../library/time.rst:242 msgid "``'process_time'``: :func:`time.process_time`" msgstr "``'process_time'``::func:`time.process_time`" -#: ../../library/time.rst:237 +#: ../../library/time.rst:243 msgid "``'thread_time'``: :func:`time.thread_time`" msgstr "``'thread_time'``::func:`time.thread_time`" -#: ../../library/time.rst:238 +#: ../../library/time.rst:244 msgid "``'time'``: :func:`time.time`" msgstr "``'time'``::func:`time.time`" -#: ../../library/time.rst:240 +#: ../../library/time.rst:246 msgid "The result has the following attributes:" msgstr "其結果具有以下屬性:" -#: ../../library/time.rst:242 +#: ../../library/time.rst:248 msgid "" "*adjustable*: ``True`` if the clock can be set to jump forward or backward " "in time, ``False`` otherwise. Does not refer to gradual NTP rate adjustments." @@ -394,7 +403,7 @@ msgstr "" "*adjustable*: 如果時鐘可以設定為向前或向後跳轉時間則為 ``True``,否則為 " "``False``。不指漸進式的 NTP 速率調整。" -#: ../../library/time.rst:244 +#: ../../library/time.rst:250 msgid "" "*implementation*: The name of the underlying C function used to get the " "clock value. Refer to :ref:`time-clock-id-constants` for possible values." @@ -402,16 +411,16 @@ msgstr "" "*implementation*: 用於取得時鐘的值的底層 C 函式名稱。有關可能的值,請參閱 :" "ref:`time-clock-id-constants`。" -#: ../../library/time.rst:246 +#: ../../library/time.rst:252 msgid "" "*monotonic*: ``True`` if the clock cannot go backward, ``False`` otherwise" msgstr "*monotonic*: 如果時鐘不能倒轉,則為 ``True``,否則為 ``False``" -#: ../../library/time.rst:248 +#: ../../library/time.rst:254 msgid "*resolution*: The resolution of the clock in seconds (:class:`float`)" msgstr "*resolution*: 以秒 (:class:`float`) 為單位的時鐘的解析度" -#: ../../library/time.rst:255 +#: ../../library/time.rst:261 msgid "" "Convert a time expressed in seconds since the epoch_ to a :class:" "`struct_time` in UTC in which the dst flag is always zero. If *seconds* is " @@ -425,7 +434,7 @@ msgstr "" "由 :func:`.time` 回傳的目前時間。忽略秒的分數部分。關於 :class:`struct_time` " "物件的描述,請參閱上文。此函式的反運算請參閱 :func:`calendar.timegm`。" -#: ../../library/time.rst:265 +#: ../../library/time.rst:274 msgid "" "Like :func:`gmtime` but converts to local time. If *seconds* is not provided " "or :const:`None`, the current time as returned by :func:`.time` is used. The " @@ -435,7 +444,7 @@ msgstr "" "為 :const:`None`,則使用由 :func:`.time` 回傳的目前時間。當 DST 適用於給定時" "間時,dst 旗標會被設定為 ``1``。" -#: ../../library/time.rst:270 +#: ../../library/time.rst:279 msgid "" ":func:`localtime` may raise :exc:`OverflowError`, if the timestamp is " "outside the range of values supported by the platform C :c:func:`localtime` " @@ -448,7 +457,7 @@ msgstr "" "`localtime` 或 :c:func:`gmtime` 失敗時,會引發 :exc:`OSError`。通常會把年份限" "制在 1970 年到 2038 年之間。" -#: ../../library/time.rst:279 +#: ../../library/time.rst:291 msgid "" "This is the inverse function of :func:`localtime`. Its argument is the :" "class:`struct_time` or full 9-tuple (since the dst flag is needed; use " @@ -467,7 +476,7 @@ msgstr "" "(取決於無效值是被 Python 還是底層 C 函式庫捕獲)。它能生成時間的最早日期根據" "平台而有所不同。" -#: ../../library/time.rst:291 +#: ../../library/time.rst:303 msgid "" "Return the value (in fractional seconds) of a monotonic clock, i.e. a clock " "that cannot go backwards. The clock is not affected by system clock " @@ -478,11 +487,11 @@ msgstr "" "示)。該時鐘不受系統時鐘更新的影響。回傳值的參考點沒有定義,因此只有兩次呼叫" "結果之間的差異才是有效的。" -#: ../../library/time.rst:296 ../../library/time.rst:721 +#: ../../library/time.rst:308 ../../library/time.rst:735 msgid "Clock:" msgstr "時鐘:" -#: ../../library/time.rst:298 +#: ../../library/time.rst:310 msgid "" "On Windows, call ``QueryPerformanceCounter()`` and " "``QueryPerformanceFrequency()``." @@ -490,44 +499,44 @@ msgstr "" "在 Windows 上,呼叫 ``QueryPerformanceCounter()`` 和 " "``QueryPerformanceFrequency()``。" -#: ../../library/time.rst:300 +#: ../../library/time.rst:312 msgid "On macOS, call ``mach_absolute_time()`` and ``mach_timebase_info()``." msgstr "" "在 macOS 上,呼叫 ``mach_absolute_time()`` 和 ``mach_timebase_info()``。" -#: ../../library/time.rst:301 +#: ../../library/time.rst:313 msgid "On HP-UX, call ``gethrtime()``." msgstr "在 HP-UX 上,呼叫 ``gethrtime()``。" -#: ../../library/time.rst:302 +#: ../../library/time.rst:314 msgid "Call ``clock_gettime(CLOCK_HIGHRES)`` if available." msgstr "如果可以的話,呼叫 ``clock_gettime(CLOCK_HIGHRES)``。" -#: ../../library/time.rst:303 +#: ../../library/time.rst:315 msgid "Otherwise, call ``clock_gettime(CLOCK_MONOTONIC)``." msgstr "否則,呼叫 ``clock_gettime(CLOCK_MONOTONIC)``。" -#: ../../library/time.rst:305 +#: ../../library/time.rst:317 msgid "" "Use :func:`monotonic_ns` to avoid the precision loss caused by the :class:" "`float` type." msgstr "使用 :func:`monotonic_ns` 以避免 :class:`float` 型別造成的精確度損失。" -#: ../../library/time.rst:310 +#: ../../library/time.rst:322 msgid "" "The function is now always available and the clock is now the same for all " "processes." msgstr "此函式現在始終可用且時鐘對於所有行程都會是相同。" -#: ../../library/time.rst:314 +#: ../../library/time.rst:326 msgid "On macOS, the clock is now the same for all processes." msgstr "在 macOS 上,時鐘對於所有行程都會是相同。" -#: ../../library/time.rst:320 +#: ../../library/time.rst:332 msgid "Similar to :func:`monotonic`, but return time as nanoseconds." msgstr "類似於 :func:`monotonic`,但回傳以奈秒為單位的時間。" -#: ../../library/time.rst:329 +#: ../../library/time.rst:341 msgid "" "Return the value (in fractional seconds) of a performance counter, i.e. a " "clock with the highest available resolution to measure a short duration. It " @@ -539,7 +548,7 @@ msgstr "" "間隔的時鐘。它包括睡眠時經過的時間,且時鐘對於所有行程都會是相同。回傳值的參" "考點沒有定義,因此只有兩次呼叫結果之間的差異才是有效的。" -#: ../../library/time.rst:338 +#: ../../library/time.rst:350 msgid "" "On CPython, use the same clock as :func:`time.monotonic` and is a monotonic " "clock, i.e. a clock that cannot go backwards." @@ -547,26 +556,26 @@ msgstr "" "在 CPython 上,使用與 :func:`time.monotonic` 相同的時鐘,且其為單調時鐘(即不" "能倒轉的時鐘)。" -#: ../../library/time.rst:341 +#: ../../library/time.rst:353 msgid "" "Use :func:`perf_counter_ns` to avoid the precision loss caused by the :class:" "`float` type." msgstr "" "使用 :func:`perf_counter_ns` 以避免 :class:`float` 型別造成的精確度損失。" -#: ../../library/time.rst:346 +#: ../../library/time.rst:358 msgid "On Windows, the clock is now the same for all processes." msgstr "在 Windows 上,時鐘對於所有行程都會是相同。" -#: ../../library/time.rst:349 +#: ../../library/time.rst:361 msgid "Use the same clock as :func:`time.monotonic`." msgstr "使用與 :func:`time.monotonic` 相同的時鐘。" -#: ../../library/time.rst:355 +#: ../../library/time.rst:367 msgid "Similar to :func:`perf_counter`, but return time as nanoseconds." msgstr "類似於 :func:`perf_counter`,但回傳以奈秒為單位的時間。" -#: ../../library/time.rst:367 +#: ../../library/time.rst:379 msgid "" "Return the value (in fractional seconds) of the sum of the system and user " "CPU time of the current process. It does not include time elapsed during " @@ -578,27 +587,26 @@ msgstr "" "經過的時間。根據定義,它涵蓋整個行程。回傳值的參考點沒有定義,因此只有兩次呼" "叫結果之間的差異才是有效的。" -#: ../../library/time.rst:373 +#: ../../library/time.rst:385 msgid "" "Use :func:`process_time_ns` to avoid the precision loss caused by the :class:" "`float` type." msgstr "" "使用 :func:`process_time_ns` 以避免 :class:`float` 型別造成的精確度損失。" -#: ../../library/time.rst:380 +#: ../../library/time.rst:392 msgid "Similar to :func:`process_time` but return time as nanoseconds." msgstr "類似於 :func:`process_time`,但回傳以奈秒為單位的時間。" -#: ../../library/time.rst:386 +#: ../../library/time.rst:398 msgid "" "Suspend execution of the calling thread for the given number of seconds. The " -"argument may be a floating-point number to indicate a more precise sleep " -"time." +"argument may be a non-integer to indicate a more precise sleep time." msgstr "" -"在一個給定的秒數內暫停呼叫執行緒 (calling thread) 的執行。引數可以是浮點數," +"在一個給定的秒數內暫停呼叫執行緒 (calling thread) 的執行。引數可以是非整數," "以表示更精確的睡眠時間。" -#: ../../library/time.rst:390 +#: ../../library/time.rst:401 msgid "" "If the sleep is interrupted by a signal and no exception is raised by the " "signal handler, the sleep is restarted with a recomputed timeout." @@ -606,17 +614,17 @@ msgstr "" "如果睡眠被訊號中斷且訊號處理器未引發例外,則睡眠將以重新計算過的逾時 " "(timeout) 重新開始。" -#: ../../library/time.rst:393 +#: ../../library/time.rst:404 msgid "" "The suspension time may be longer than requested by an arbitrary amount, " "because of the scheduling of other activity in the system." msgstr "由於系統中其他活動的調度,暫停時間可能會比請求的時間長任意的量。" -#: ../../library/time.rst:397 +#: ../../library/time.rst:408 msgid "Windows implementation" msgstr "Windows 實作" -#: ../../library/time.rst:398 +#: ../../library/time.rst:409 msgid "" "On Windows, if *seconds* is zero, the thread relinquishes the remainder of " "its time slice to any other thread that is ready to run. If there are no " @@ -633,29 +641,29 @@ msgstr "" "createwaitabletimerexw>`_,其解析度為 100 奈秒。如果 *seconds* 為零,則使用 " "``Sleep(0)``。" -#: ../../library/time.rst:410 +#: ../../library/time.rst:421 msgid "Unix implementation" msgstr "Unix 實作" -#: ../../library/time.rst:411 +#: ../../library/time.rst:422 msgid "Use ``clock_nanosleep()`` if available (resolution: 1 nanosecond);" msgstr "如果可以,使用 ``clock_nanosleep()``\\ (解析度:1 奈秒);" -#: ../../library/time.rst:412 +#: ../../library/time.rst:423 msgid "Or use ``nanosleep()`` if available (resolution: 1 nanosecond);" msgstr "或者使用 ``nanosleep()``\\ (解析度:1 奈秒);" -#: ../../library/time.rst:413 +#: ../../library/time.rst:424 msgid "Or use ``select()`` (resolution: 1 microsecond)." msgstr "或使用 ``select()``\\ (解析度:1 微秒)。" -#: ../../library/time.rst:417 +#: ../../library/time.rst:428 msgid "" "To emulate a \"no-op\", use :keyword:`pass` instead of ``time.sleep(0)``." msgstr "" "要模擬「無動作 (no-op)」,請使用 :keyword:`pass` 而不是 ``time.sleep(0)``。" -#: ../../library/time.rst:419 +#: ../../library/time.rst:430 msgid "" "To voluntarily relinquish the CPU, specify a real-time :ref:`scheduling " "policy ` and use :func:`os.sched_yield` instead." @@ -663,7 +671,7 @@ msgstr "" "要自願釋放 CPU,請指定即時的\\ :ref:`排程政策 `\\ 並改" "用 :func:`os.sched_yield`。" -#: ../../library/time.rst:422 +#: ../../library/time.rst:433 msgid "" "Raises an :ref:`auditing event ` ``time.sleep`` with argument " "``seconds``." @@ -671,7 +679,7 @@ msgstr "" "引發一個帶有引數 ``seconds`` 的\\ :ref:`稽核事件 (auditing event) " "` ``time.sleep``。" -#: ../../library/time.rst:424 +#: ../../library/time.rst:435 msgid "" "The function now sleeps at least *seconds* even if the sleep is interrupted " "by a signal, except if the signal handler raises an exception (see :pep:" @@ -680,7 +688,7 @@ msgstr "" "即使睡眠被訊號中斷,此函式現在至少還是會睡眠 *seconds*,除非訊號處理器引發例" "外(理由請參閱 :pep:`475`)。" -#: ../../library/time.rst:430 +#: ../../library/time.rst:441 msgid "" "On Unix, the ``clock_nanosleep()`` and ``nanosleep()`` functions are now " "used if available. On Windows, a waitable timer is now used." @@ -688,11 +696,11 @@ msgstr "" "在 Unix 上,如果可以的話現在會使用 ``clock_nanosleep()`` 和 ``nanosleep()`` " "函式。在 Windows 上,現在使用可等待的計時器。" -#: ../../library/time.rst:434 +#: ../../library/time.rst:445 msgid "Raises an auditing event." msgstr "引發一個稽核事件。" -#: ../../library/time.rst:442 +#: ../../library/time.rst:456 msgid "" "Convert a tuple or :class:`struct_time` representing a time as returned by :" "func:`gmtime` or :func:`localtime` to a string as specified by the *format* " @@ -706,7 +714,7 @@ msgstr "" "字串。如果 *time_tuple* 中的任何欄位超出允許範圍,將會引" "發 :exc:`ValueError`。" -#: ../../library/time.rst:448 +#: ../../library/time.rst:462 msgid "" "0 is a legal argument for any position in the time tuple; if it is normally " "illegal the value is forced to a correct one." @@ -714,7 +722,7 @@ msgstr "" "0 在時間元組中的任何位置都是合法引數;如果元組中出現常見的錯誤,該值將被強制" "更改為正確的值。" -#: ../../library/time.rst:451 +#: ../../library/time.rst:465 msgid "" "The following directives can be embedded in the *format* string. They are " "shown without the optional field width and precision specification, and are " @@ -723,151 +731,151 @@ msgstr "" "以下指令可以嵌入在 *format* 字串中。它們顯示時不帶可選的欄位寬度和精度規範," "並在 :func:`strftime` 的結果中被標示的字元替換:" -#: ../../library/time.rst:456 +#: ../../library/time.rst:470 msgid "Directive" msgstr "指令" -#: ../../library/time.rst:456 +#: ../../library/time.rst:470 msgid "Meaning" msgstr "意義" -#: ../../library/time.rst:456 +#: ../../library/time.rst:470 msgid "Notes" msgstr "註解" -#: ../../library/time.rst:458 +#: ../../library/time.rst:472 msgid "``%a``" msgstr "``%a``" -#: ../../library/time.rst:458 +#: ../../library/time.rst:472 msgid "Locale's abbreviated weekday name." msgstr "區域設定的週間日 (weekday) 縮寫名稱。" -#: ../../library/time.rst:461 +#: ../../library/time.rst:475 msgid "``%A``" msgstr "``%A``" -#: ../../library/time.rst:461 +#: ../../library/time.rst:475 msgid "Locale's full weekday name." msgstr "區域設定的完整週間日名稱。" -#: ../../library/time.rst:463 +#: ../../library/time.rst:477 msgid "``%b``" msgstr "``%b``" -#: ../../library/time.rst:463 +#: ../../library/time.rst:477 msgid "Locale's abbreviated month name." msgstr "區域設定的縮寫月份名稱。" -#: ../../library/time.rst:466 +#: ../../library/time.rst:480 msgid "``%B``" msgstr "``%B``" -#: ../../library/time.rst:466 +#: ../../library/time.rst:480 msgid "Locale's full month name." msgstr "區域設定的完整月份名稱。" -#: ../../library/time.rst:468 +#: ../../library/time.rst:482 msgid "``%c``" msgstr "``%c``" -#: ../../library/time.rst:468 +#: ../../library/time.rst:482 msgid "Locale's appropriate date and time representation." msgstr "區域設定的合適的日期和時間的表示法。" -#: ../../library/time.rst:471 +#: ../../library/time.rst:485 msgid "``%d``" msgstr "``%d``" -#: ../../library/time.rst:471 +#: ../../library/time.rst:485 msgid "Day of the month as a decimal number [01,31]." msgstr "月份中的日期,表示為十進位數 [01,31]。" -#: ../../library/time.rst:474 +#: ../../library/time.rst:488 msgid "``%f``" msgstr "``%f``" -#: ../../library/time.rst:474 +#: ../../library/time.rst:488 msgid "Microseconds as a decimal number" msgstr "微秒,表示為十進位數" -#: ../../library/time.rst:475 +#: ../../library/time.rst:489 msgid "[000000,999999]." msgstr "[000000,999999]。" -#: ../../library/time.rst:474 +#: ../../library/time.rst:488 msgid "\\(1)" msgstr "\\(1)" -#: ../../library/time.rst:478 +#: ../../library/time.rst:492 msgid "``%H``" msgstr "``%H``" -#: ../../library/time.rst:478 +#: ../../library/time.rst:492 msgid "Hour (24-hour clock) as a decimal number [00,23]." msgstr "小時(24 小時制),表示為十進位數 [00,23]。" -#: ../../library/time.rst:481 +#: ../../library/time.rst:495 msgid "``%I``" msgstr "``%I``" -#: ../../library/time.rst:481 +#: ../../library/time.rst:495 msgid "Hour (12-hour clock) as a decimal number [01,12]." msgstr "小時(12 小時制),表示為十進位數 [01,12]。" -#: ../../library/time.rst:484 +#: ../../library/time.rst:498 msgid "``%j``" msgstr "``%j``" -#: ../../library/time.rst:484 +#: ../../library/time.rst:498 msgid "Day of the year as a decimal number [001,366]." msgstr "一年中的第幾天,表示為十進位數 [001,366]。" -#: ../../library/time.rst:487 +#: ../../library/time.rst:501 msgid "``%m``" msgstr "``%m``" -#: ../../library/time.rst:487 +#: ../../library/time.rst:501 msgid "Month as a decimal number [01,12]." msgstr "月份,表示為十進位數 [01,12]。" -#: ../../library/time.rst:490 +#: ../../library/time.rst:504 msgid "``%M``" msgstr "``%M``" -#: ../../library/time.rst:490 +#: ../../library/time.rst:504 msgid "Minute as a decimal number [00,59]." msgstr "分鐘,表示為十進位數 [00,59]。" -#: ../../library/time.rst:493 +#: ../../library/time.rst:507 msgid "``%p``" msgstr "``%p``" -#: ../../library/time.rst:493 +#: ../../library/time.rst:507 msgid "Locale's equivalent of either AM or PM." msgstr "區域設定中相當於 AM 或 PM 的表示。" -#: ../../library/time.rst:493 +#: ../../library/time.rst:507 msgid "\\(2)" msgstr "\\(2)" -#: ../../library/time.rst:496 +#: ../../library/time.rst:510 msgid "``%S``" msgstr "``%S``" -#: ../../library/time.rst:496 +#: ../../library/time.rst:510 msgid "Second as a decimal number [00,61]." msgstr "秒,表示為十進位數 [00,61]。" -#: ../../library/time.rst:496 +#: ../../library/time.rst:510 msgid "\\(3)" msgstr "\\(3)" -#: ../../library/time.rst:499 +#: ../../library/time.rst:513 msgid "``%U``" msgstr "``%U``" -#: ../../library/time.rst:499 +#: ../../library/time.rst:513 msgid "" "Week number of the year (Sunday as the first day of the week) as a decimal " "number [00,53]. All days in a new year preceding the first Sunday are " @@ -876,31 +884,31 @@ msgstr "" "一年中的週數(星期天作為一週的第一天),表示為十進位數 [00,53]。新的一年中," "在第一個星期天之前的所有日子都被認定為第 0 週。" -#: ../../library/time.rst:499 ../../library/time.rst:513 +#: ../../library/time.rst:513 ../../library/time.rst:527 msgid "\\(4)" msgstr "\\(4)" -#: ../../library/time.rst:507 +#: ../../library/time.rst:521 msgid "``%u``" msgstr "``%u``" -#: ../../library/time.rst:507 +#: ../../library/time.rst:521 msgid "Day of the week (Monday is 1; Sunday is 7) as a decimal number [1, 7]." msgstr "一週中的日期(周一為 1;週日為 7),表示為十進位數 [1,7]。" -#: ../../library/time.rst:510 +#: ../../library/time.rst:524 msgid "``%w``" msgstr "``%w``" -#: ../../library/time.rst:510 +#: ../../library/time.rst:524 msgid "Weekday as a decimal number [0(Sunday),6]." msgstr "週間日,表示為十進位數 [0(星期天),6]。" -#: ../../library/time.rst:513 +#: ../../library/time.rst:527 msgid "``%W``" msgstr "``%W``" -#: ../../library/time.rst:513 +#: ../../library/time.rst:527 msgid "" "Week number of the year (Monday as the first day of the week) as a decimal " "number [00,53]. All days in a new year preceding the first Monday are " @@ -909,43 +917,43 @@ msgstr "" "一年中的週數(星期一作為一週的第一天),表示為十進位數 [00,53]。新的一年中," "在第一個星期一之前的所有日子都被認定為第 0 週。" -#: ../../library/time.rst:521 +#: ../../library/time.rst:535 msgid "``%x``" msgstr "``%x``" -#: ../../library/time.rst:521 +#: ../../library/time.rst:535 msgid "Locale's appropriate date representation." msgstr "區域設定的合適的日期表示法。" -#: ../../library/time.rst:524 +#: ../../library/time.rst:538 msgid "``%X``" msgstr "``%X``" -#: ../../library/time.rst:524 +#: ../../library/time.rst:538 msgid "Locale's appropriate time representation." msgstr "區域設定的合適的時間表示法。" -#: ../../library/time.rst:527 +#: ../../library/time.rst:541 msgid "``%y``" msgstr "``%y``" -#: ../../library/time.rst:527 +#: ../../library/time.rst:541 msgid "Year without century as a decimal number [00,99]." msgstr "去掉世紀的年份,表示為十進位數 [00,99]。" -#: ../../library/time.rst:530 +#: ../../library/time.rst:544 msgid "``%Y``" msgstr "``%Y``" -#: ../../library/time.rst:530 +#: ../../library/time.rst:544 msgid "Year with century as a decimal number." msgstr "帶世紀的年份,表示為十進位數。" -#: ../../library/time.rst:533 +#: ../../library/time.rst:547 msgid "``%z``" msgstr "``%z``" -#: ../../library/time.rst:533 +#: ../../library/time.rst:547 msgid "" "Time zone offset indicating a positive or negative time difference from UTC/" "GMT of the form +HHMM or -HHMM, where H represents decimal hour digits and M " @@ -954,19 +962,19 @@ msgstr "" "時區偏移量,表示與 UTC/GMT 的正或負時間差,形式為 +HHMM 或 -HHMM,其中 H 代表" "十進位的小時數碼 (digits),M 代表十進位的分鐘數碼 [-23:59, +23:59]。 [1]_" -#: ../../library/time.rst:539 +#: ../../library/time.rst:553 msgid "``%Z``" msgstr "``%Z``" -#: ../../library/time.rst:539 +#: ../../library/time.rst:553 msgid "Time zone name (no characters if no time zone exists). Deprecated. [1]_" msgstr "時區名稱(如果不存在時區,則無字元)。已被棄用。 [1]_" -#: ../../library/time.rst:542 +#: ../../library/time.rst:556 msgid "``%G``" msgstr "``%G``" -#: ../../library/time.rst:542 +#: ../../library/time.rst:556 msgid "" "ISO 8601 year (similar to ``%Y`` but follows the rules for the ISO 8601 " "calendar year). The year starts with the week that contains the first " @@ -975,11 +983,11 @@ msgstr "" "ISO 8601 年(類似於 ``%Y``,但遵循 ISO 8601 日曆年的規則)。年份從包含該日曆" "年第一個星期四的那一週開始。" -#: ../../library/time.rst:547 +#: ../../library/time.rst:561 msgid "``%V``" msgstr "``%V``" -#: ../../library/time.rst:547 +#: ../../library/time.rst:561 msgid "" "ISO 8601 week number (as a decimal number [01,53]). The first week of the " "year is the one that contains the first Thursday of the year. Weeks start on " @@ -988,19 +996,19 @@ msgstr "" "ISO 8601 週數(以十進位數表示 [01,53])。年份的第一週是包含該年第一個星期四的" "那一週。每週從星期一開始。" -#: ../../library/time.rst:552 +#: ../../library/time.rst:566 msgid "``%%``" msgstr "``%%``" -#: ../../library/time.rst:552 +#: ../../library/time.rst:566 msgid "A literal ``'%'`` character." msgstr "字面意義上的 ``'%'`` 字元。" -#: ../../library/time.rst:555 +#: ../../library/time.rst:569 msgid "Notes:" msgstr "註解:" -#: ../../library/time.rst:558 +#: ../../library/time.rst:572 msgid "" "The ``%f`` format directive only applies to :func:`strptime`, not to :func:" "`strftime`. However, see also :meth:`datetime.datetime.strptime` and :meth:" @@ -1011,7 +1019,7 @@ msgstr "" "在 :meth:`datetime.datetime.strptime` 和 :meth:`datetime.datetime.strftime` " "其中的 ``%f`` 格式的指令\\ :ref:`適用於微秒 `。" -#: ../../library/time.rst:564 +#: ../../library/time.rst:578 msgid "" "When used with the :func:`strptime` function, the ``%p`` directive only " "affects the output hour field if the ``%I`` directive is used to parse the " @@ -1020,7 +1028,7 @@ msgstr "" "當與 :func:`strptime` 函式一起使用時,``%p`` 指令僅在使用 ``%I`` 指令剖析小時" "時影響輸出小時的欄位。" -#: ../../library/time.rst:570 +#: ../../library/time.rst:584 msgid "" "The range really is ``0`` to ``61``; value ``60`` is valid in timestamps " "representing `leap seconds`_ and value ``61`` is supported for historical " @@ -1029,7 +1037,7 @@ msgstr "" "範圍確實是從 ``0`` 到 ``61``;數值 ``60`` 在表示 `leap seconds`_ 的時間戳中是" "有效的,而數值 ``61`` 是出於歷史因素而被支援。" -#: ../../library/time.rst:575 +#: ../../library/time.rst:589 msgid "" "When used with the :func:`strptime` function, ``%U`` and ``%W`` are only " "used in calculations when the day of the week and the year are specified." @@ -1037,7 +1045,7 @@ msgstr "" "當與 :func:`strptime` 函式一起使用時,``%U`` 和 ``%W`` 僅在指定週間的某天和年" "份時用於計算中。" -#: ../../library/time.rst:578 +#: ../../library/time.rst:592 msgid "" "Here is an example, a format for dates compatible with that specified in " "the :rfc:`5322` Internet email standard. [1]_ ::" @@ -1045,7 +1053,7 @@ msgstr "" "以下是一個範例,其為一種與 :rfc:`5322` 網際網路電子郵件標準中指定的日期格式兼" "容的格式。 [1]_: ::" -#: ../../library/time.rst:581 +#: ../../library/time.rst:595 msgid "" ">>> from time import gmtime, strftime\n" ">>> strftime(\"%a, %d %b %Y %H:%M:%S +0000\", gmtime())\n" @@ -1055,7 +1063,7 @@ msgstr "" ">>> strftime(\"%a, %d %b %Y %H:%M:%S +0000\", gmtime())\n" "'Thu, 28 Jun 2001 14:17:15 +0000'" -#: ../../library/time.rst:585 +#: ../../library/time.rst:599 msgid "" "Additional directives may be supported on certain platforms, but only the " "ones listed here have a meaning standardized by ANSI C. To see the full set " @@ -1065,7 +1073,7 @@ msgstr "" "某些平台可能支援額外的指令,但只有這裡列出的指令具有 ANSI C 標準化的意義。要" "查看你的平台上支援的完整格式碼集,請參閱 :manpage:`strftime(3)` 文件。" -#: ../../library/time.rst:590 +#: ../../library/time.rst:604 msgid "" "On some platforms, an optional field width and precision specification can " "immediately follow the initial ``'%'`` of a directive in the following " @@ -1075,7 +1083,7 @@ msgstr "" "在某些平台上,可選的欄位寬度和精度規範可以以此順序緊跟在指令初始的 ``'%'`` 之" "後;這也是不可攜 (portable) 的。欄位寬度通常為 2,除了 ``%j`` 為 3。" -#: ../../library/time.rst:601 +#: ../../library/time.rst:615 msgid "" "Parse a string representing a time according to a format. The return value " "is a :class:`struct_time` as returned by :func:`gmtime` or :func:`localtime`." @@ -1083,7 +1091,7 @@ msgstr "" "根據格式剖析表示時間的字串。回傳值是 :class:`struct_time`,如同由 :func:" "`gmtime` 或 :func:`localtime` 回傳的一樣。" -#: ../../library/time.rst:605 +#: ../../library/time.rst:619 msgid "" "The *format* parameter uses the same directives as those used by :func:" "`strftime`; it defaults to ``\"%a %b %d %H:%M:%S %Y\"`` which matches the " @@ -1099,11 +1107,11 @@ msgstr "" "時,用來填充任何缺失資料的預設值為 ``(1900, 1, 1, 0, 0, 0, 0, 1, -1)``。" "*string* 和 *format* 都必須是字串。" -#: ../../library/time.rst:613 +#: ../../library/time.rst:627 msgid "For example:" msgstr "例如:" -#: ../../library/time.rst:620 +#: ../../library/time.rst:634 msgid "" "Support for the ``%Z`` directive is based on the values contained in " "``tzname`` and whether ``daylight`` is true. Because of this, it is " @@ -1114,7 +1122,7 @@ msgstr "" "因此,除了識別始終已知的 UTC 和 GMT(且被考慮為非日光節約時區)外,這是特定於" "平台的。" -#: ../../library/time.rst:625 +#: ../../library/time.rst:639 msgid "" "Only the directives specified in the documentation are supported. Because " "``strftime()`` is implemented per platform it can sometimes offer more " @@ -1126,7 +1134,7 @@ msgstr "" "提供比列出的還要更多的指令。但是 ``strptime()`` 與任何平台無關,因此不一定支" "援所有未記載為支援的指令。" -#: ../../library/time.rst:634 +#: ../../library/time.rst:648 msgid "" "The type of the time value sequence returned by :func:`gmtime`, :func:" "`localtime`, and :func:`strptime`. It is an object with a :term:`named " @@ -1137,110 +1145,110 @@ msgstr "" "別。它是一個具有 :term:`named tuple` 介面的物件:值可以透過索引和屬性名稱存" "取。包含以下值:" -#: ../../library/time.rst:641 +#: ../../library/time.rst:655 msgid "Index" msgstr "索引" -#: ../../library/time.rst:642 +#: ../../library/time.rst:656 msgid "Attribute" msgstr "屬性" -#: ../../library/time.rst:643 +#: ../../library/time.rst:657 msgid "Values" msgstr "值" -#: ../../library/time.rst:645 +#: ../../library/time.rst:659 msgid "0" msgstr "0" -#: ../../library/time.rst:647 +#: ../../library/time.rst:661 msgid "(for example, 1993)" msgstr "(例如 1993)" -#: ../../library/time.rst:649 +#: ../../library/time.rst:663 msgid "1" msgstr "1" -#: ../../library/time.rst:651 +#: ../../library/time.rst:665 msgid "range [1, 12]" msgstr "範圍 [1, 12]" -#: ../../library/time.rst:653 +#: ../../library/time.rst:667 msgid "2" msgstr "2" -#: ../../library/time.rst:655 +#: ../../library/time.rst:669 msgid "range [1, 31]" msgstr "範圍 [1, 31]" -#: ../../library/time.rst:657 +#: ../../library/time.rst:671 msgid "3" msgstr "3" -#: ../../library/time.rst:659 +#: ../../library/time.rst:673 msgid "range [0, 23]" msgstr "範圍 [0, 23]" -#: ../../library/time.rst:661 +#: ../../library/time.rst:675 msgid "4" msgstr "4" -#: ../../library/time.rst:663 +#: ../../library/time.rst:677 msgid "range [0, 59]" msgstr "範圍 [0, 59]" -#: ../../library/time.rst:665 +#: ../../library/time.rst:679 msgid "5" msgstr "5" -#: ../../library/time.rst:667 +#: ../../library/time.rst:681 msgid "range [0, 61]; see :ref:`Note (2) ` in :func:`strftime`" msgstr "" "範圍 [0, 61];參見 :func:`strftime` 中的\\ :ref:`註釋 (2) `" -#: ../../library/time.rst:669 +#: ../../library/time.rst:683 msgid "6" msgstr "6" -#: ../../library/time.rst:671 +#: ../../library/time.rst:685 msgid "range [0, 6]; Monday is 0" msgstr "範圍 [0, 6];星期一是 0" -#: ../../library/time.rst:673 +#: ../../library/time.rst:687 msgid "7" msgstr "7" -#: ../../library/time.rst:675 +#: ../../library/time.rst:689 msgid "range [1, 366]" msgstr "範圍 [1, 366]" -#: ../../library/time.rst:677 +#: ../../library/time.rst:691 msgid "8" msgstr "8" -#: ../../library/time.rst:679 +#: ../../library/time.rst:693 msgid "0, 1 or -1; see below" msgstr "0、1 或 -1;見下文" -#: ../../library/time.rst:681 ../../library/time.rst:685 +#: ../../library/time.rst:695 ../../library/time.rst:699 msgid "N/A" msgstr "N/A" -#: ../../library/time.rst:683 +#: ../../library/time.rst:697 msgid "abbreviation of timezone name" msgstr "時區名稱的縮寫" -#: ../../library/time.rst:687 +#: ../../library/time.rst:701 msgid "offset east of UTC in seconds" msgstr "UTC 向東的偏移量(以秒為單位)" -#: ../../library/time.rst:689 +#: ../../library/time.rst:703 msgid "" "Note that unlike the C structure, the month value is a range of [1, 12], not " "[0, 11]." msgstr "請注意,與 C 結構不同,月份值的範圍是 [1, 12],而不是 [0, 11]。" -#: ../../library/time.rst:692 +#: ../../library/time.rst:706 msgid "" "In calls to :func:`mktime`, :attr:`tm_isdst` may be set to 1 when daylight " "savings time is in effect, and 0 when it is not. A value of -1 indicates " @@ -1250,7 +1258,7 @@ msgstr "" "在呼叫 :func:`mktime` 時,當日光節約時間生效的時候,:attr:`tm_isdst` 可以設定" "為 1,不生效時設定為 0。值 -1 表示未知是否生效,通常結果會填入正確的狀態。" -#: ../../library/time.rst:696 +#: ../../library/time.rst:710 msgid "" "When a tuple with an incorrect length is passed to a function expecting a :" "class:`struct_time`, or having elements of the wrong type, a :exc:" @@ -1259,7 +1267,7 @@ msgstr "" "當一個長度不正確的元組被傳遞給預期得到 :class:`struct_time` 的函式時,或者其" "中有元素型別錯誤時,將引發 :exc:`TypeError`。" -#: ../../library/time.rst:702 +#: ../../library/time.rst:716 msgid "" "Return the time in seconds since the epoch_ as a floating-point number. The " "handling of `leap seconds`_ is platform dependent. On Windows and most Unix " @@ -1271,7 +1279,7 @@ msgstr "" "關的。在 Windows 和大多數 Unix 系統上,閏秒不計入自 epoch_ 起的秒數中。這通常" "被稱為 `Unix 時間 `_。" -#: ../../library/time.rst:708 +#: ../../library/time.rst:722 msgid "" "Note that even though the time is always returned as a floating-point " "number, not all systems provide time with a better precision than 1 second. " @@ -1283,7 +1291,7 @@ msgstr "" "間。雖然此函式通常回傳非遞減的值,但如果在兩次呼叫之間系統時鐘被回調,則它可" "能回傳比之前呼叫更小的值。" -#: ../../library/time.rst:714 +#: ../../library/time.rst:728 msgid "" "The number returned by :func:`.time` may be converted into a more common " "time format (i.e. year, month, day, hour, etc...) in UTC by passing it to :" @@ -1297,25 +1305,25 @@ msgstr "" "為當地時間。在這兩種情況下都會回傳一個 :class:`struct_time` 物件,從中可以作" "為屬性存取日曆日期的組成部分。" -#: ../../library/time.rst:723 +#: ../../library/time.rst:737 msgid "On Windows, call ``GetSystemTimePreciseAsFileTime()``." msgstr "在 Windows 上,呼叫 ``GetSystemTimePreciseAsFileTime()``。" -#: ../../library/time.rst:724 +#: ../../library/time.rst:738 msgid "Call ``clock_gettime(CLOCK_REALTIME)`` if available." msgstr "如果可以的話,呼叫 ``clock_gettime(CLOCK_REALTIME)``。" -#: ../../library/time.rst:725 +#: ../../library/time.rst:739 msgid "Otherwise, call ``gettimeofday()``." msgstr "否則,呼叫 ``gettimeofday()``。" -#: ../../library/time.rst:727 +#: ../../library/time.rst:741 msgid "" "Use :func:`time_ns` to avoid the precision loss caused by the :class:`float` " "type." msgstr "使用 :func:`time_ns` 以避免 :class:`float` 型別造成的精確度損失。" -#: ../../library/time.rst:732 +#: ../../library/time.rst:746 msgid "" "On Windows, calls ``GetSystemTimePreciseAsFileTime()`` instead of " "``GetSystemTimeAsFileTime()``." @@ -1323,13 +1331,13 @@ msgstr "" "在 Windows 上,呼叫 ``GetSystemTimePreciseAsFileTime()`` 而不是 " "``GetSystemTimeAsFileTime()``。" -#: ../../library/time.rst:738 +#: ../../library/time.rst:752 msgid "" "Similar to :func:`~time.time` but returns time as an integer number of " "nanoseconds since the epoch_." msgstr "類似於 :func:`~time.time`,但回傳自 epoch_ 起的以奈秒為單位的整數。" -#: ../../library/time.rst:751 +#: ../../library/time.rst:765 msgid "" "Return the value (in fractional seconds) of the sum of the system and user " "CPU time of the current thread. It does not include time elapsed during " @@ -1341,22 +1349,22 @@ msgstr "" "期間經過的時間。根據定義,這是執行緒特定 (thread-specific) 的。回傳值的參照點" "未定義,因此只有同一執行緒中兩次呼叫結果之間的差異才是有效的。" -#: ../../library/time.rst:757 +#: ../../library/time.rst:771 msgid "" "Use :func:`thread_time_ns` to avoid the precision loss caused by the :class:" "`float` type." msgstr "" "使用 :func:`thread_time_ns` 以避免 :class:`float` 型別造成的精確度損失。" -#: ../../library/time.rst:762 +#: ../../library/time.rst:776 msgid "Unix systems supporting ``CLOCK_THREAD_CPUTIME_ID``." msgstr "有支援 ``CLOCK_THREAD_CPUTIME_ID`` 的 Unix 系統。" -#: ../../library/time.rst:769 +#: ../../library/time.rst:783 msgid "Similar to :func:`thread_time` but return time as nanoseconds." msgstr "類似於 :func:`thread_time`,但回傳以奈秒為單位的時間。" -#: ../../library/time.rst:776 +#: ../../library/time.rst:790 msgid "" "Reset the time conversion rules used by the library routines. The " "environment variable :envvar:`TZ` specifies how this is done. It will also " @@ -1373,7 +1381,7 @@ msgstr "" "``daylight``\\ (如果該時區沒有日光節約時間規則,則設定為 0;如果在過去、現在" "或未來的某個時間有日光節約時間規則,則設置為非零的值)。" -#: ../../library/time.rst:788 +#: ../../library/time.rst:802 msgid "" "Although in many cases, changing the :envvar:`TZ` environment variable may " "affect the output of functions like :func:`localtime` without calling :func:" @@ -1382,30 +1390,30 @@ msgstr "" "雖然在許多情況下,更改 :envvar:`TZ` 環境變數可能會在沒有呼叫 :func:`tzset` 的" "情況下影響 :func:`localtime` 等函式的輸出,但是這種行為是不該被依賴的。" -#: ../../library/time.rst:792 +#: ../../library/time.rst:806 msgid "The :envvar:`TZ` environment variable should contain no whitespace." msgstr ":envvar:`TZ` 環境變數不應包含空格字元。" -#: ../../library/time.rst:794 +#: ../../library/time.rst:808 msgid "" "The standard format of the :envvar:`TZ` environment variable is (whitespace " "added for clarity)::" msgstr "" ":envvar:`TZ` 環境變數的標準格式為(為了清楚表達,中間增加了空格字元): ::" -#: ../../library/time.rst:797 +#: ../../library/time.rst:811 msgid "std offset [dst [offset [,start[/time], end[/time]]]]" msgstr "std offset [dst [offset [,start[/time], end[/time]]]]" -#: ../../library/time.rst:799 +#: ../../library/time.rst:813 msgid "Where the components are:" msgstr "其中各個組成部分為:" -#: ../../library/time.rst:801 +#: ../../library/time.rst:815 msgid "``std`` and ``dst``" msgstr "``std`` 和 ``dst``" -#: ../../library/time.rst:802 +#: ../../library/time.rst:816 msgid "" "Three or more alphanumerics giving the timezone abbreviations. These will be " "propagated into time.tzname" @@ -1413,11 +1421,11 @@ msgstr "" "三個或更多字母與數字 (alphanumerics) 組成的時區縮寫。這些縮寫會被傳播到 time." "tzname 中。" -#: ../../library/time.rst:805 +#: ../../library/time.rst:819 msgid "``offset``" msgstr "``offset``" -#: ../../library/time.rst:806 +#: ../../library/time.rst:820 msgid "" "The offset has the form: ``± hh[:mm[:ss]]``. This indicates the value added " "the local time to arrive at UTC. If preceded by a '-', the timezone is east " @@ -1428,22 +1436,22 @@ msgstr "" "果以 '-' 開頭,則表示該時區位於本初子午線以東;否則,位於其西。如果 dst 之後" "沒有偏移量,則假定日光時間比標準時間快一小時。" -#: ../../library/time.rst:811 +#: ../../library/time.rst:825 msgid "``start[/time], end[/time]``" msgstr "``start[/time], end[/time]``" -#: ../../library/time.rst:812 +#: ../../library/time.rst:826 msgid "" "Indicates when to change to and back from DST. The format of the start and " "end dates are one of the following:" msgstr "" "表示何時切換至日光節約時間及何時切換回來。開始和結束日期的格式如以下其一:" -#: ../../library/time.rst:815 +#: ../../library/time.rst:829 msgid ":samp:`J{n}`" msgstr ":samp:`J{n}`" -#: ../../library/time.rst:816 +#: ../../library/time.rst:830 msgid "" "The Julian day *n* (1 <= *n* <= 365). Leap days are not counted, so in all " "years February 28 is day 59 and March 1 is day 60." @@ -1451,22 +1459,22 @@ msgstr "" "儒略日 (Julian day) *n*\\ (1 <= *n* <= 365)。閏日不計算,因此在所有年份中," "2 月 28 日是第 59 天,3 月 1 日是第 60 天。" -#: ../../library/time.rst:819 +#: ../../library/time.rst:833 msgid ":samp:`{n}`" msgstr ":samp:`{n}`" -#: ../../library/time.rst:820 +#: ../../library/time.rst:834 msgid "" "The zero-based Julian day (0 <= *n* <= 365). Leap days are counted, and it " "is possible to refer to February 29." msgstr "" "從 0 開始的儒略日 (0 <= *n* <= 365)。閏日會計算,因此可以適用至 2 月 29 日。" -#: ../../library/time.rst:823 +#: ../../library/time.rst:837 msgid ":samp:`M{m}.{n}.{d}`" msgstr ":samp:`M{m}.{n}.{d}`" -#: ../../library/time.rst:824 +#: ../../library/time.rst:838 msgid "" "The *d*'th day (0 <= *d* <= 6) of week *n* of month *m* of the year (1 <= " "*n* <= 5, 1 <= *m* <= 12, where week 5 means \"the last *d* day in month " @@ -1477,7 +1485,7 @@ msgstr "" "*m* <= 12,其中 *n* 為 5 表示「該月的最後一個第 *d* 天」,這可能出現在第四或" "第五週)。第 1 週是 *d* 天首次出現的那一週。第零天為星期天。" -#: ../../library/time.rst:830 +#: ../../library/time.rst:844 msgid "" "``time`` has the same format as ``offset`` except that no leading sign ('-' " "or '+') is allowed. The default, if time is not given, is 02:00:00." @@ -1485,7 +1493,7 @@ msgstr "" "``time`` 的格式與 ``offset`` 相同,但不允許出現前導符號('-' 或 '+')。如果未" "指定時間,則預設為 02:00:00。" -#: ../../library/time.rst:835 +#: ../../library/time.rst:849 msgid "" ">>> os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'\n" ">>> time.tzset()\n" @@ -1505,7 +1513,7 @@ msgstr "" ">>> time.strftime('%X %x %Z')\n" "'16:08:12 05/08/03 AEST'" -#: ../../library/time.rst:844 +#: ../../library/time.rst:858 msgid "" "On many Unix systems (including \\*BSD, Linux, Solaris, and Darwin), it is " "more convenient to use the system's zoneinfo (:manpage:`tzfile(5)`) " @@ -1522,7 +1530,7 @@ msgstr "" "Eastern'``、``'Australia/Melbourne'``、``'Egypt'`` 或 ``'Europe/" "Amsterdam'``。 ::" -#: ../../library/time.rst:852 +#: ../../library/time.rst:866 msgid "" ">>> os.environ['TZ'] = 'US/Eastern'\n" ">>> time.tzset()\n" @@ -1542,24 +1550,24 @@ msgstr "" ">>> time.tzname\n" "('EET', 'EEST')" -#: ../../library/time.rst:865 +#: ../../library/time.rst:879 msgid "Clock ID Constants" msgstr "時鐘 ID 常數" -#: ../../library/time.rst:867 +#: ../../library/time.rst:881 msgid "" "These constants are used as parameters for :func:`clock_getres` and :func:" "`clock_gettime`." msgstr "這些常數用作 :func:`clock_getres` 和 :func:`clock_gettime` 的參數。" -#: ../../library/time.rst:872 +#: ../../library/time.rst:886 msgid "" "Identical to :data:`CLOCK_MONOTONIC`, except it also includes any time that " "the system is suspended." msgstr "" "與 :data:`CLOCK_MONOTONIC` 基本相同,不同之處在於它還包括系統暫停的任何時間。" -#: ../../library/time.rst:875 +#: ../../library/time.rst:889 msgid "" "This allows applications to get a suspend-aware monotonic clock without " "having to deal with the complications of :data:`CLOCK_REALTIME`, which may " @@ -1570,7 +1578,7 @@ msgstr "" "`CLOCK_REALTIME` 的複雜情況,後者在使用 ``settimeofday()`` 或類似函式更改時間" "時可能會出現不連續的情況。" -#: ../../library/time.rst:887 +#: ../../library/time.rst:901 msgid "" "The Solaris OS has a ``CLOCK_HIGHRES`` timer that attempts to use an optimal " "hardware source, and may give close to nanosecond resolution. " @@ -1579,13 +1587,13 @@ msgstr "" "Solaris 作業系統具有 ``CLOCK_HIGHRES`` 計時器,它嘗試使用最佳的硬體資源,並可" "能提供接近奈秒的解析度。``CLOCK_HIGHRES`` 是不可調整且高解析度的時鐘。" -#: ../../library/time.rst:898 +#: ../../library/time.rst:912 msgid "" "Clock that cannot be set and represents monotonic time since some " "unspecified starting point." msgstr "該時鐘無法被設定,其表示自某個未指定起點以來的單調時間。" -#: ../../library/time.rst:908 +#: ../../library/time.rst:922 msgid "" "Similar to :data:`CLOCK_MONOTONIC`, but provides access to a raw hardware-" "based time that is not subject to NTP adjustments." @@ -1593,7 +1601,7 @@ msgstr "" "類似於 :data:`CLOCK_MONOTONIC`,但提供對基於硬體的原始時間的存取,此時間不受 " "NTP 調整的影響。" -#: ../../library/time.rst:917 +#: ../../library/time.rst:931 msgid "" "Similar to :data:`CLOCK_MONOTONIC_RAW`, but reads a value cached by the " "system at context switch and hence has less accuracy." @@ -1601,11 +1609,11 @@ msgstr "" "類似於 :data:`CLOCK_MONOTONIC_RAW`,但讀取的是系統在情境切換時快取的值,因此" "精準度較低。" -#: ../../library/time.rst:927 ../../library/time.rst:936 +#: ../../library/time.rst:941 ../../library/time.rst:950 msgid "High-resolution per-process timer from the CPU." msgstr "來自 CPU 的高解析度每個行程的計時器。" -#: ../../library/time.rst:944 +#: ../../library/time.rst:958 msgid "" "`International Atomic Time `_" @@ -1613,18 +1621,18 @@ msgstr "" "`國際原子時間 `_" -#: ../../library/time.rst:946 +#: ../../library/time.rst:960 msgid "" "The system must have a current leap second table in order for this to give " "the correct answer. PTP or NTP software can maintain a leap second table." msgstr "" "系統必須擁有目前的閏秒表才能給出正確答案。PTP 或 NTP 軟體可以維護閏秒表。" -#: ../../library/time.rst:955 +#: ../../library/time.rst:969 msgid "Thread-specific CPU-time clock." msgstr "執行緒相關的 CPU 時間時鐘。" -#: ../../library/time.rst:964 +#: ../../library/time.rst:978 msgid "" "Time whose absolute value is the time the system has been running and not " "suspended, providing accurate uptime measurement, both absolute and interval." @@ -1632,7 +1640,7 @@ msgstr "" "表示系統運作且無暫停的絕對時間,提供包括絕對時間 (absolute) 和時間區間 " "(interval) 的精確的正常上線時間 (uptime) 測量。" -#: ../../library/time.rst:975 +#: ../../library/time.rst:989 msgid "" "Clock that increments monotonically, tracking the time since an arbitrary " "point, unaffected by frequency or time adjustments and not incremented while " @@ -1641,7 +1649,7 @@ msgstr "" "單調增量的時鐘,從某個任意點開始計時,不受頻率或時間調整影響,並且在系統休眠" "時不增量。" -#: ../../library/time.rst:985 +#: ../../library/time.rst:999 msgid "" "Like :data:`CLOCK_UPTIME_RAW`, but the value is cached by the system at " "context switches and therefore has less accuracy." @@ -1649,23 +1657,23 @@ msgstr "" "類似於 :data:`CLOCK_UPTIME_RAW`,但該值在情境切換時由系統快取,因此精準度較" "低。" -#: ../../library/time.rst:992 +#: ../../library/time.rst:1006 msgid "" "The following constant is the only parameter that can be sent to :func:" "`clock_settime`." msgstr "以下常數是唯一可以傳遞給 :func:`clock_settime` 的參數。" -#: ../../library/time.rst:998 +#: ../../library/time.rst:1012 msgid "" "Real-time clock. Setting this clock requires appropriate privileges. The " "clock is the same for all processes." msgstr "即時時鐘。設定此時鐘需要適當的權限。時鐘對於所有行程都會是相同。" -#: ../../library/time.rst:1009 +#: ../../library/time.rst:1023 msgid "Timezone Constants" msgstr "時區常數" -#: ../../library/time.rst:1013 +#: ../../library/time.rst:1027 msgid "" "The offset of the local DST timezone, in seconds west of UTC, if one is " "defined. This is negative if the local DST timezone is east of UTC (as in " @@ -1676,11 +1684,11 @@ msgstr "" "為單位)。若本地 DST 時區位於 UTC 以東(例如包括英國在內的西歐),則此值為負" "值。僅在 ``daylight`` 為非零時使用此值。詳情請參見下方註釋。" -#: ../../library/time.rst:1019 +#: ../../library/time.rst:1033 msgid "Nonzero if a DST timezone is defined. See note below." msgstr "如果定義了 DST 時區,則為非零值。詳情請參見下方註釋。" -#: ../../library/time.rst:1023 +#: ../../library/time.rst:1037 msgid "" "The offset of the local (non-DST) timezone, in seconds west of UTC (negative " "in most of Western Europe, positive in the US, zero in the UK). See note " @@ -1689,7 +1697,7 @@ msgstr "" "本地(非 DST)時區相對於 UTC 以西的偏移量(以秒為單位),西歐大多數地區為負," "美國為正,英國為零。詳情請參見下方註釋。" -#: ../../library/time.rst:1028 +#: ../../library/time.rst:1042 msgid "" "A tuple of two strings: the first is the name of the local non-DST timezone, " "the second is the name of the local DST timezone. If no DST timezone is " @@ -1698,7 +1706,7 @@ msgstr "" "一個包含兩個字串的元組:第一個是本地非 DST 時區的名稱,第二個是本地 DST 時區" "的名稱。如果沒有定義 DST 時區,則不應使用第二個字串。詳情請參見下方註釋。" -#: ../../library/time.rst:1034 +#: ../../library/time.rst:1048 msgid "" "For the above Timezone constants (:data:`altzone`, :data:`daylight`, :data:" "`timezone`, and :data:`tzname`), the value is determined by the timezone " @@ -1712,19 +1720,19 @@ msgstr "" "決定,且過去的時間可能會不準確。建議使用 :func:`localtime` 回傳的 :attr:" "`~struct_time.tm_gmtoff` 和 :attr:`~struct_time.tm_zone` 來取得時區資訊。" -#: ../../library/time.rst:1043 +#: ../../library/time.rst:1057 msgid "Module :mod:`datetime`" msgstr ":mod:`datetime` 模組" -#: ../../library/time.rst:1044 +#: ../../library/time.rst:1058 msgid "More object-oriented interface to dates and times." msgstr "更多物件導向的日期和時間介面。" -#: ../../library/time.rst:1046 +#: ../../library/time.rst:1060 msgid "Module :mod:`locale`" msgstr ":mod:`locale` 模組" -#: ../../library/time.rst:1047 +#: ../../library/time.rst:1061 msgid "" "Internationalization services. The locale setting affects the " "interpretation of many format specifiers in :func:`strftime` and :func:" @@ -1733,11 +1741,11 @@ msgstr "" "國際化服務。區域設定會影響 :func:`strftime` 和 :func:`strptime` 中許多格式指" "定符號 (format specifiers) 的解譯。" -#: ../../library/time.rst:1050 +#: ../../library/time.rst:1064 msgid "Module :mod:`calendar`" msgstr ":mod:`calendar` 模組" -#: ../../library/time.rst:1051 +#: ../../library/time.rst:1065 msgid "" "General calendar-related functions. :func:`~calendar.timegm` is the " "inverse of :func:`gmtime` from this module." @@ -1745,11 +1753,11 @@ msgstr "" "通用的日曆相關函式。:func:`~calendar.timegm` 是本模組中 :func:`gmtime` 的反函" "式。" -#: ../../library/time.rst:1055 +#: ../../library/time.rst:1069 msgid "Footnotes" msgstr "註腳" -#: ../../library/time.rst:1056 +#: ../../library/time.rst:1070 msgid "" "The use of ``%Z`` is now deprecated, but the ``%z`` escape that expands to " "the preferred hour/minute offset is not supported by all ANSI C libraries. " @@ -1793,23 +1801,23 @@ msgstr "Greenwich Mean Time(格林威治標準時間)" msgid "Daylight Saving Time" msgstr "Daylight Saving Time(日光節約時間)" -#: ../../library/time.rst:326 ../../library/time.rst:362 -#: ../../library/time.rst:746 +#: ../../library/time.rst:338 ../../library/time.rst:374 +#: ../../library/time.rst:760 msgid "benchmarking" msgstr "benchmarking(基準測試)" -#: ../../library/time.rst:362 ../../library/time.rst:746 +#: ../../library/time.rst:374 ../../library/time.rst:760 msgid "CPU time" msgstr "CPU time(CPU 時間)" -#: ../../library/time.rst:362 ../../library/time.rst:746 +#: ../../library/time.rst:374 ../../library/time.rst:760 msgid "processor time" msgstr "processor time(處理器時間)" -#: ../../library/time.rst:437 ../../library/time.rst:596 +#: ../../library/time.rst:451 ../../library/time.rst:610 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/time.rst:437 ../../library/time.rst:596 +#: ../../library/time.rst:451 ../../library/time.rst:610 msgid "datetime format" msgstr "datetime format(日期時間格式)" diff --git a/library/timeit.po b/library/timeit.po index f3f488f7c0a..523e7794251 100644 --- a/library/timeit.po +++ b/library/timeit.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-05-20 13:21+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -43,7 +43,7 @@ msgstr "" "的介紹。" #: ../../library/timeit.rst:23 -msgid "Basic Examples" +msgid "Basic examples" msgstr "基礎範例" #: ../../library/timeit.rst:25 @@ -114,7 +114,7 @@ msgstr "" "ref:`timeit-examples`\\ 章節中有更進階的範例。" #: ../../library/timeit.rst:60 -msgid "Python Interface" +msgid "Python interface" msgstr "Python 介面" #: ../../library/timeit.rst:62 @@ -148,7 +148,7 @@ msgstr "" "並使用給定的 *repeat* 計數和 *number* 來運行其 :meth:`.repeat` 方法。可選的 " "*globals* 引數指定會在其中執行程式碼的命名空間。" -#: ../../library/timeit.rst:86 ../../library/timeit.rst:183 +#: ../../library/timeit.rst:86 ../../library/timeit.rst:186 msgid "Default value of *repeat* changed from 3 to 5." msgstr "*repeat* 的預設值從 3 更改為 5。" @@ -248,14 +248,15 @@ msgstr "自動決定呼叫 :meth:`.timeit` 次數。" #: ../../library/timeit.rst:150 msgid "" "This is a convenience function that calls :meth:`.timeit` repeatedly so that " -"the total time >= 0.2 second, returning the eventual (number of loops, time " -"taken for that number of loops). It calls :meth:`.timeit` with increasing " -"numbers from the sequence 1, 2, 5, 10, 20, 50, ... until the time taken is " -"at least 0.2 seconds." +"the total time >= *Timer.target_time* seconds, returning the eventual " +"(number of loops, time taken for that number of loops). It calls :meth:`." +"timeit` with increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... " +"until the time taken is at least *target_time* seconds." msgstr "" -"這是一個便捷函式,它重複呼叫 :meth:`.timeit` 以使得總時間 >= 0.2 秒,再回傳最" -"終結果(迴圈數、該迴圈數所花費的時間)。它以 1、2、5、10、20、50... 的順序遞" -"增數字來呼叫 :meth:`.timeit` 直到所用時間至少為 0.2 秒。" +"這是一個便捷函式,它重複呼叫 :meth:`.timeit` 以使得總時間 >= " +"*Timer.target_time* 秒,再回傳最終結果(迴圈數、該迴圈數所花費的時間)。它以 " +"1、2、5、10、20、50... 的順序遞增數字來呼叫 :meth:`.timeit` 直到所用時間至少" +"為 *target_time* 秒。" #: ../../library/timeit.rst:156 msgid "" @@ -265,11 +266,15 @@ msgstr "" "如果有給定 *callback* 且不是 ``None``,則每次試驗後都會使用兩個引數來呼叫它:" "``callback(number, time_taken)``。" -#: ../../library/timeit.rst:164 +#: ../../library/timeit.rst:161 +msgid "The optional *target_time* parameter was added." +msgstr "新增 *target_time* 選用參數。" + +#: ../../library/timeit.rst:167 msgid "Call :meth:`.timeit` a few times." msgstr "呼叫 :meth:`.timeit` 數次。" -#: ../../library/timeit.rst:166 +#: ../../library/timeit.rst:169 msgid "" "This is a convenience function that calls the :meth:`.timeit` repeatedly, " "returning a list of results. The first argument specifies how many times to " @@ -280,7 +285,7 @@ msgstr "" "定呼叫 :meth:`.timeit` 的次數,第二個引數指定 :meth:`.timeit` 的 *number* 引" "數。" -#: ../../library/timeit.rst:173 +#: ../../library/timeit.rst:176 msgid "" "It's tempting to calculate mean and standard deviation from the result " "vector and report these. However, this is not very useful. In a typical " @@ -297,15 +302,15 @@ msgstr "" "的。因此,結果中的 :func:`min` 可能是你應該感興趣的唯一數字。在解讀該數據後," "你應該查看整個向量並以常識判讀而非單純仰賴統計資訊。" -#: ../../library/timeit.rst:189 +#: ../../library/timeit.rst:192 msgid "Helper to print a traceback from the timed code." msgstr "從計時程式碼印出回溯 (traceback) 的輔助函式。" -#: ../../library/timeit.rst:191 +#: ../../library/timeit.rst:194 msgid "Typical use::" msgstr "典型用法: ::" -#: ../../library/timeit.rst:193 +#: ../../library/timeit.rst:196 msgid "" "t = Timer(...) # outside the try/except\n" "try:\n" @@ -319,7 +324,7 @@ msgstr "" "except Exception:\n" " t.print_exc()" -#: ../../library/timeit.rst:199 +#: ../../library/timeit.rst:202 msgid "" "The advantage over the standard traceback is that source lines in the " "compiled template will be displayed. The optional *file* argument directs " @@ -328,38 +333,38 @@ msgstr "" "相對於標準回溯的優點是,已編譯模板中的原始程式碼會被顯示出來。可選的 *file* " "引數指定回溯的發送位置;它預設為 :data:`sys.stderr`。" -#: ../../library/timeit.rst:207 -msgid "Command-Line Interface" +#: ../../library/timeit.rst:210 +msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/timeit.rst:209 +#: ../../library/timeit.rst:212 msgid "" "When called as a program from the command line, the following form is used::" msgstr "當從命令列作為程式呼叫時,請使用以下形式: ::" -#: ../../library/timeit.rst:211 +#: ../../library/timeit.rst:214 msgid "" "python -m timeit [-n N] [-r N] [-u U] [-s S] [-p] [-v] [-h] [statement ...]" msgstr "" "python -m timeit [-n N] [-r N] [-u U] [-s S] [-p] [-v] [-h] [statement ...]" -#: ../../library/timeit.rst:213 +#: ../../library/timeit.rst:216 msgid "Where the following options are understood:" msgstr "其中之以下選項:" -#: ../../library/timeit.rst:219 +#: ../../library/timeit.rst:222 msgid "how many times to execute 'statement'" msgstr "執行 'statement' 多少次" -#: ../../library/timeit.rst:223 +#: ../../library/timeit.rst:226 msgid "how many times to repeat the timer (default 5)" msgstr "計時器重複多少次(預設 5)" -#: ../../library/timeit.rst:227 +#: ../../library/timeit.rst:230 msgid "statement to be executed once initially (default ``pass``)" msgstr "會在一開始執行一次的陳述式(預設為 ``pass``)" -#: ../../library/timeit.rst:231 +#: ../../library/timeit.rst:234 msgid "" "measure process time, not wallclock time, using :func:`time.process_time` " "instead of :func:`time.perf_counter`, which is the default" @@ -367,22 +372,28 @@ msgstr "" "若要測量行程時間 (process time) 而非掛鐘時間 (wallclock time),請使用 :func:" "`time.process_time` 而不是預設的 :func:`time.perf_counter`" -#: ../../library/timeit.rst:238 +#: ../../library/timeit.rst:241 msgid "" "specify a time unit for timer output; can select ``nsec``, ``usec``, " "``msec``, or ``sec``" msgstr "" "指定定時器輸出的時間單位;可以選擇 ``nsec``、``usec``、``msec`` 或 ``sec``" -#: ../../library/timeit.rst:244 +#: ../../library/timeit.rst:247 +msgid "" +"if :option:`--number` is 0, the code will run until it takes at least this " +"many seconds (default: 0.2)" +msgstr "" + +#: ../../library/timeit.rst:254 msgid "print raw timing results; repeat for more digits precision" msgstr "印出原始計時結果;重複執行以獲得更高的數字精度" -#: ../../library/timeit.rst:248 +#: ../../library/timeit.rst:258 msgid "print a short usage message and exit" msgstr "印出一條簡短的使用訊息並退出" -#: ../../library/timeit.rst:250 +#: ../../library/timeit.rst:260 msgid "" "A multi-line statement may be given by specifying each line as a separate " "statement argument; indented lines are possible by enclosing an argument in " @@ -393,16 +404,17 @@ msgstr "" "並使用前導空格以實現縮進列 (indented lines)。多個 :option:`-s` 選項的作用類" "似。" -#: ../../library/timeit.rst:255 +#: ../../library/timeit.rst:265 msgid "" "If :option:`-n` is not given, a suitable number of loops is calculated by " "trying increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... until " -"the total time is at least 0.2 seconds." +"the total time is at least :option:`--target-time` seconds (default: 0.2)." msgstr "" -"如果沒有給定 :option:`-n`,則透過嘗試從序列 1, 2, 5, 10, 20, 50, ... 中增加數" -"字來計算合適的迴圈次數,直到總時間至少為 0.2 秒。" +"如果沒有給定 :option:`-n`,則透過嘗試從序列 1、2、5、10、20、50... 中增加數字" +"來計算合適的迴圈次數,直到總時間至少為 :option:`--target-time` 秒(預設值:" +"0.2)。" -#: ../../library/timeit.rst:259 +#: ../../library/timeit.rst:269 msgid "" ":func:`default_timer` measurements can be affected by other programs running " "on the same machine, so the best thing to do when accurate timing is " @@ -416,7 +428,7 @@ msgstr "" "此很有用;在大多數情況下,預設的重複 5 次可能就足夠了。你可以使用 :func:" "`time.process_time` 來測量 CPU 時間。" -#: ../../library/timeit.rst:267 +#: ../../library/timeit.rst:277 msgid "" "There is a certain baseline overhead associated with executing a pass " "statement. The code here doesn't try to hide it, but you should be aware of " @@ -427,17 +439,23 @@ msgstr "" "識到它的存在。可以透過不帶引數呼叫程式來測量這個基本開銷,且不同 Python 版本" "之間的基本開銷可能有所不同。" -#: ../../library/timeit.rst:276 +#: ../../library/timeit.rst:282 +msgid "" +"Output is in color by default and can be :ref:`controlled using environment " +"variables `." +msgstr "" + +#: ../../library/timeit.rst:289 msgid "Examples" msgstr "範例" -#: ../../library/timeit.rst:278 +#: ../../library/timeit.rst:291 msgid "" "It is possible to provide a setup statement that is executed only once at " "the beginning:" msgstr "可以提供一個僅會在開始時執行一次的設定陳述式:" -#: ../../library/timeit.rst:280 +#: ../../library/timeit.rst:293 msgid "" "$ python -m timeit -s \"text = 'sample string'; char = 'g'\" \"char in " "text\"\n" @@ -453,7 +471,7 @@ msgstr "" "find(char)\"\n" "1000000 loops, best of 5: 0.342 usec per loop" -#: ../../library/timeit.rst:287 +#: ../../library/timeit.rst:300 msgid "" "In the output, there are three fields. The loop count, which tells you how " "many times the statement body was run per timing loop repetition. The " @@ -467,7 +485,7 @@ msgstr "" "在計時迴圈的最佳的幾次重複執行內平均花費的時間。也就是說,最快的幾次重複執行" "所花費的總時間除以迴圈計數。" -#: ../../library/timeit.rst:296 +#: ../../library/timeit.rst:309 msgid "" ">>> import timeit\n" ">>> timeit.timeit('char in text', setup='text = \"sample string\"; char = " @@ -485,11 +503,11 @@ msgstr "" "\"g\"')\n" "1.7246671520006203" -#: ../../library/timeit.rst:302 +#: ../../library/timeit.rst:315 msgid "The same can be done using the :class:`Timer` class and its methods::" msgstr "同樣可以使用 :class:`Timer` 類別及其方法來完成: ::" -#: ../../library/timeit.rst:304 +#: ../../library/timeit.rst:317 msgid "" ">>> import timeit\n" ">>> t = timeit.Timer('char in text', setup='text = \"sample string\"; char = " @@ -509,7 +527,7 @@ msgstr "" "[0.40183617287970225, 0.37027556854118704, 0.38344867356679524, " "0.3712595970846668, 0.37866875250654886]" -#: ../../library/timeit.rst:312 +#: ../../library/timeit.rst:325 msgid "" "The following examples show how to time expressions that contain multiple " "lines. Here we compare the cost of using :func:`hasattr` vs. :keyword:`try`/:" @@ -519,7 +537,7 @@ msgstr "" "keyword:`try`/:keyword:`except` 來測試缺失和存在之物件屬性並比較其花費 " "(cost):" -#: ../../library/timeit.rst:316 +#: ../../library/timeit.rst:329 msgid "" "$ python -m timeit \"try:\" \" str.__bool__\" \"except AttributeError:\" " "\" pass\"\n" @@ -545,7 +563,7 @@ msgstr "" "$ python -m timeit \"if hasattr(int, '__bool__'): pass\"\n" "100000 loops, best of 5: 2.23 usec per loop" -#: ../../library/timeit.rst:330 +#: ../../library/timeit.rst:343 msgid "" ">>> import timeit\n" ">>> # attribute is missing\n" @@ -601,7 +619,7 @@ msgstr "" ">>> timeit.timeit(stmt=s, number=100000)\n" "0.08588060699912603" -#: ../../library/timeit.rst:358 +#: ../../library/timeit.rst:371 msgid "" "To give the :mod:`!timeit` module access to functions you define, you can " "pass a *setup* parameter which contains an import statement::" @@ -609,7 +627,7 @@ msgstr "" "要讓 :mod:`!timeit` 模組存取你定義的函式,你可以傳遞一個包含 import 陳述式的 " "*setup* 參數: ::" -#: ../../library/timeit.rst:361 +#: ../../library/timeit.rst:374 msgid "" "def test():\n" " \"\"\"Stupid test function\"\"\"\n" @@ -627,7 +645,7 @@ msgstr "" " import timeit\n" " print(timeit.timeit(\"test()\", setup=\"from __main__ import test\"))" -#: ../../library/timeit.rst:369 +#: ../../library/timeit.rst:382 msgid "" "Another option is to pass :func:`globals` to the *globals* parameter, which " "will cause the code to be executed within your current global namespace. " @@ -636,7 +654,7 @@ msgstr "" "另一種選擇是將 :func:`globals` 傳遞給 *globals* 參數,這將導致程式碼在目前的" "全域命名空間中執行,這比單獨指定 import 更方便: ::" -#: ../../library/timeit.rst:373 +#: ../../library/timeit.rst:386 msgid "" "def f(x):\n" " return x**2\n" diff --git a/library/tkinter.po b/library/tkinter.po index 3b483827de6..af5cd829167 100644 --- a/library/tkinter.po +++ b/library/tkinter.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-16 00:27+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-07-13 20:00+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!tkinter` --- Python interface to Tcl/Tk" msgstr ":mod:`!tkinter` --- Tcl/Tk 的 Python 介面" -#: ../../library/tkinter.rst:9 +#: ../../library/tkinter.rst:7 msgid "**Source code:** :source:`Lib/tkinter/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/tkinter/__init__.py`" -#: ../../library/tkinter.rst:13 +#: ../../library/tkinter.rst:11 msgid "" "The :mod:`!tkinter` package (\"Tk interface\") is the standard Python " "interface to the Tcl/Tk GUI toolkit. Both Tk and :mod:`!tkinter` are " @@ -38,7 +38,7 @@ msgstr "" "Tk 和 :mod:`!tkinter` 在大多數 Unix 平台(包含 macOS)以及 Windows 系統上都可" "以使用。" -#: ../../library/tkinter.rst:17 +#: ../../library/tkinter.rst:15 msgid "" "Running ``python -m tkinter`` from the command line should open a window " "demonstrating a simple Tk interface, letting you know that :mod:`!tkinter` " @@ -50,22 +50,22 @@ msgstr "" "知道 :mod:`!tkinter` 已正確安裝在你的系統上,並且也會顯示已安裝的 Tcl/Tk 版" "本,這樣你就可以閱讀該版本專屬的 Tcl/Tk 文件。" -#: ../../library/tkinter.rst:22 +#: ../../library/tkinter.rst:20 msgid "" "Tkinter supports a range of Tcl/Tk versions, built either with or without " "thread support. Tcl/Tk 8.5.12 is the minimum supported version; the official " -"Python binary release bundles Tcl/Tk 8.6. See the source code for the :mod:" +"Python binary release bundles Tcl/Tk 9.0. See the source code for the :mod:" "`_tkinter` module for more information about supported versions." msgstr "" "Tkinter 支援一系列的 Tcl/Tk 版本,這些版本可以是有或沒有執行緒支援的建構版" "本。Tcl/Tk 8.5.12 為最低支援版本;官方的 Python 二進位發行版捆綁了 Tcl/Tk " -"8.6。關於支援版本的更多資訊,請參閱 :mod:`_tkinter` 模組的原始碼。" +"9.0。關於支援版本的更多資訊,請參閱 :mod:`_tkinter` 模組的原始碼。" -#: ../../library/tkinter.rst:29 +#: ../../library/tkinter.rst:27 msgid "Support for Tcl/Tk versions older than 8.5.12 was removed." msgstr "" -#: ../../library/tkinter.rst:32 +#: ../../library/tkinter.rst:30 msgid "" "Tkinter is not a thin wrapper, but adds a fair amount of its own logic to " "make the experience more pythonic. This documentation will concentrate on " @@ -76,7 +76,7 @@ msgstr "" "Python 風格(pythonic)。本文件將著重於這些新增和變更,對於未變更的細節,則會" "引導讀者參閱官方的 Tcl/Tk 文件。" -#: ../../library/tkinter.rst:39 +#: ../../library/tkinter.rst:37 msgid "" "Tcl/Tk 8.5 (2007) introduced a modern set of themed user interface " "components along with a new API to use them (see :mod:`tkinter.ttk`). Both " @@ -98,11 +98,11 @@ msgstr "" "它,請查閱你的發行者(即提供 Python 給你的人)的文件。如果你就是發行者,請參" "閱 :ref:`optional-module-requirements`。" -#: ../../library/tkinter.rst:49 +#: ../../library/tkinter.rst:47 msgid "`TkDocs `_" msgstr "`TkDocs `_" -#: ../../library/tkinter.rst:50 +#: ../../library/tkinter.rst:48 msgid "" "Extensive tutorial on creating user interfaces with Tkinter. Explains key " "concepts, and illustrates recommended approaches using the modern API." @@ -110,55 +110,55 @@ msgstr "" "關於使用 Tkinter 建立使用者介面的詳盡教學。內容解釋了關鍵概念,並使用現代 " "API 來說明建議的方法。" -#: ../../library/tkinter.rst:53 +#: ../../library/tkinter.rst:51 msgid "" "`Tkinter 8.5 reference: a GUI for Python `_" msgstr "" "`Tkinter 8.5 reference: a GUI for Python `_" -#: ../../library/tkinter.rst:54 +#: ../../library/tkinter.rst:52 msgid "" "Reference documentation for Tkinter 8.5 detailing available classes, " "methods, and options." msgstr "Tkinter 8.5 的參考文件,詳細說明了可用的類別、方法和選項。" -#: ../../library/tkinter.rst:56 +#: ../../library/tkinter.rst:54 msgid "Tcl/Tk Resources:" msgstr "Tcl/Tk 相關資源:" -#: ../../library/tkinter.rst:58 +#: ../../library/tkinter.rst:56 msgid "`Tk commands `_" msgstr "`Tk 指令 `_" -#: ../../library/tkinter.rst:59 +#: ../../library/tkinter.rst:57 msgid "" "Comprehensive reference to each of the underlying Tcl/Tk commands used by " "Tkinter." msgstr "Tkinter 所使用的每個底層 Tcl/Tk 指令的綜合參考資料。" -#: ../../library/tkinter.rst:61 +#: ../../library/tkinter.rst:59 msgid "`Tcl/Tk Home Page `_" msgstr "`Tcl/Tk 首頁 `_" -#: ../../library/tkinter.rst:62 +#: ../../library/tkinter.rst:60 msgid "Additional documentation, and links to Tcl/Tk core development." msgstr "額外的文件,以及連至 Tcl/Tk 核心開發的連結。" -#: ../../library/tkinter.rst:64 +#: ../../library/tkinter.rst:62 msgid "Books:" msgstr "書籍:" -#: ../../library/tkinter.rst:66 +#: ../../library/tkinter.rst:64 msgid "" "`Modern Tkinter for Busy Python Developers `_" msgstr "" "`Modern Tkinter for Busy Python Developers `_" -#: ../../library/tkinter.rst:67 +#: ../../library/tkinter.rst:65 msgid "By Mark Roseman. (ISBN 978-1999149567)" msgstr "由 Mark Roseman 所著。(ISBN 978-1999149567)" -#: ../../library/tkinter.rst:69 +#: ../../library/tkinter.rst:67 msgid "" "`Python GUI programming with Tkinter `_" @@ -166,19 +166,19 @@ msgstr "" "`Python GUI programming with Tkinter `_" -#: ../../library/tkinter.rst:70 +#: ../../library/tkinter.rst:68 msgid "By Alan D. Moore. (ISBN 978-1788835886)" msgstr "由 Alan D. Moore 所著。(ISBN 978-1788835886)" -#: ../../library/tkinter.rst:72 +#: ../../library/tkinter.rst:70 msgid "`Programming Python `_" msgstr "`Programming Python `_" -#: ../../library/tkinter.rst:73 +#: ../../library/tkinter.rst:71 msgid "By Mark Lutz; has excellent coverage of Tkinter. (ISBN 978-0596158101)" msgstr "由 Mark Lutz 所著;對 Tkinter 有極佳的涵蓋。(ISBN 978-0596158101)" -#: ../../library/tkinter.rst:75 +#: ../../library/tkinter.rst:73 msgid "" "`Tcl and the Tk Toolkit (2nd edition) `_" @@ -186,7 +186,7 @@ msgstr "" "`Tcl and the Tk Toolkit (2nd edition) `_" -#: ../../library/tkinter.rst:76 +#: ../../library/tkinter.rst:74 msgid "" "By John Ousterhout, inventor of Tcl/Tk, and Ken Jones; does not cover " "Tkinter. (ISBN 978-0321336330)" @@ -194,11 +194,11 @@ msgstr "" "由 Tcl/Tk 發明者 John Ousterhout 與 Ken Jones 所著;不包含 Tkinter。(ISBN " "978-0321336330)" -#: ../../library/tkinter.rst:80 +#: ../../library/tkinter.rst:78 msgid "Architecture" msgstr "架構" -#: ../../library/tkinter.rst:82 +#: ../../library/tkinter.rst:80 msgid "" "Tcl/Tk is not a single library but rather consists of a few distinct " "modules, each with separate functionality and its own official " @@ -208,11 +208,11 @@ msgstr "" "Tcl/Tk 並非單一函式庫,而是由幾個不同的模組所組成,每個模組都有獨立的功能和官" "方文件。Python 的二進位發行版也隨附了一個附加模組。" -#: ../../library/tkinter.rst:87 +#: ../../library/tkinter.rst:85 msgid "Tcl" msgstr "Tcl" -#: ../../library/tkinter.rst:88 +#: ../../library/tkinter.rst:86 msgid "" "Tcl is a dynamic interpreted programming language, just like Python. Though " "it can be used on its own as a general-purpose programming language, it is " @@ -233,11 +233,11 @@ msgstr "" "繞著協同多工(cooperative multitasking)設計的,而 Tkinter 則彌合了這種差異" "(詳情請參閱 `Threading model`_)。" -#: ../../library/tkinter.rst:100 ../../library/tkinter.rst:900 +#: ../../library/tkinter.rst:98 ../../library/tkinter.rst:898 msgid "Tk" msgstr "Tk" -#: ../../library/tkinter.rst:101 +#: ../../library/tkinter.rst:99 msgid "" "Tk is a `Tcl package `_ implemented in C " "that adds custom commands to create and manipulate GUI widgets. Each :class:" @@ -250,11 +250,11 @@ msgstr "" "Tcl 直譯器實例。Tk 的元件非常可自訂,但代價是外觀較為過時。Tk 使用 Tcl 的事件" "佇列來產生和處理 GUI 事件。" -#: ../../library/tkinter.rst:107 +#: ../../library/tkinter.rst:105 msgid "Ttk" msgstr "Ttk" -#: ../../library/tkinter.rst:108 +#: ../../library/tkinter.rst:106 msgid "" "Themed Tk (Ttk) is a newer family of Tk widgets that provide a much better " "appearance on different platforms than many of the classic Tk widgets. Ttk " @@ -265,7 +265,7 @@ msgstr "" "上提供了更好的外觀。從 Tk 8.5 版開始,Ttk 作為 Tk 的一部分發行。Python 的繫結" "(bindings)則在一個獨立的模組 :mod:`tkinter.ttk` 中提供。" -#: ../../library/tkinter.rst:113 +#: ../../library/tkinter.rst:111 msgid "" "Internally, Tk and Ttk use facilities of the underlying operating system, " "that is, Xlib on Unix/X11, Cocoa on macOS, GDI on Windows." @@ -273,7 +273,7 @@ msgstr "" "在內部,Tk 和 Ttk 使用底層作業系統的設施,即 Unix/X11 上的 Xlib、macOS 上的 " "Cocoa、Windows 上的 GDI。" -#: ../../library/tkinter.rst:116 +#: ../../library/tkinter.rst:114 msgid "" "When your Python application uses a class in Tkinter, for example, to create " "a widget, the :mod:`!tkinter` module first assembles a Tcl/Tk command " @@ -287,11 +287,11 @@ msgstr "" "的 :mod:`_tkinter` 二進位模組,後者再呼叫 Tcl 直譯器來對其進行計算。Tcl 直譯" "器接著會呼叫 Tk 和/或 Ttk 套件,而這些套件又會再呼叫 Xlib、Cocoa 或 GDI。" -#: ../../library/tkinter.rst:124 +#: ../../library/tkinter.rst:122 msgid "Tkinter modules" msgstr "Tkinter 模組" -#: ../../library/tkinter.rst:126 +#: ../../library/tkinter.rst:124 msgid "" "Support for Tkinter is spread across several modules. Most applications will " "need the main :mod:`!tkinter` module, as well as the :mod:`tkinter.ttk` " @@ -301,7 +301,7 @@ msgstr "" "tkinter` 模組,以及 :mod:`tkinter.ttk` 模組,後者提供了現代主題式元件集和 " "API: ::" -#: ../../library/tkinter.rst:131 +#: ../../library/tkinter.rst:129 msgid "" "from tkinter import *\n" "from tkinter import ttk" @@ -309,79 +309,79 @@ msgstr "" "from tkinter import *\n" "from tkinter import ttk" -#: ../../library/tkinter.rst:135 +#: ../../library/tkinter.rst:133 msgid "The modules that provide Tk support include:" msgstr "提供 Tk 支援的模組包括:" -#: ../../library/tkinter.rst:137 +#: ../../library/tkinter.rst:135 msgid ":mod:`!tkinter`" msgstr ":mod:`!tkinter`" -#: ../../library/tkinter.rst:138 +#: ../../library/tkinter.rst:136 msgid "Main Tkinter module." msgstr "主要的 Tkinter 模組。" -#: ../../library/tkinter.rst:140 +#: ../../library/tkinter.rst:138 msgid ":mod:`tkinter.colorchooser`" msgstr ":mod:`tkinter.colorchooser`" -#: ../../library/tkinter.rst:141 +#: ../../library/tkinter.rst:139 msgid "Dialog to let the user choose a color." msgstr "讓使用者選擇顏色的對話方塊。" -#: ../../library/tkinter.rst:143 +#: ../../library/tkinter.rst:141 msgid ":mod:`tkinter.commondialog`" msgstr ":mod:`tkinter.commondialog`" -#: ../../library/tkinter.rst:144 +#: ../../library/tkinter.rst:142 msgid "Base class for the dialogs defined in the other modules listed here." msgstr "此處列出的其他模組中定義的對話方塊的基底類別。" -#: ../../library/tkinter.rst:146 +#: ../../library/tkinter.rst:144 msgid ":mod:`tkinter.filedialog`" msgstr ":mod:`tkinter.filedialog`" -#: ../../library/tkinter.rst:147 +#: ../../library/tkinter.rst:145 msgid "Common dialogs to allow the user to specify a file to open or save." msgstr "讓使用者指定要開啟或儲存的檔案的通用對話方塊。" -#: ../../library/tkinter.rst:149 +#: ../../library/tkinter.rst:147 msgid ":mod:`tkinter.font`" msgstr ":mod:`tkinter.font`" -#: ../../library/tkinter.rst:150 +#: ../../library/tkinter.rst:148 msgid "Utilities to help work with fonts." msgstr "協助處理字型的工具程式。" -#: ../../library/tkinter.rst:152 +#: ../../library/tkinter.rst:150 msgid ":mod:`tkinter.messagebox`" msgstr ":mod:`tkinter.messagebox`" -#: ../../library/tkinter.rst:153 +#: ../../library/tkinter.rst:151 msgid "Access to standard Tk dialog boxes." msgstr "存取標準的 Tk 對話方塊。" -#: ../../library/tkinter.rst:155 +#: ../../library/tkinter.rst:153 msgid ":mod:`tkinter.scrolledtext`" msgstr ":mod:`tkinter.scrolledtext`" -#: ../../library/tkinter.rst:156 +#: ../../library/tkinter.rst:154 msgid "Text widget with a vertical scroll bar built in." msgstr "內建垂直捲軸的文字元件。" -#: ../../library/tkinter.rst:158 +#: ../../library/tkinter.rst:156 msgid ":mod:`tkinter.simpledialog`" msgstr ":mod:`tkinter.simpledialog`" -#: ../../library/tkinter.rst:159 +#: ../../library/tkinter.rst:157 msgid "Basic dialogs and convenience functions." msgstr "基本的對話方塊和便利函式。" -#: ../../library/tkinter.rst:161 +#: ../../library/tkinter.rst:159 msgid ":mod:`tkinter.ttk`" msgstr ":mod:`tkinter.ttk`" -#: ../../library/tkinter.rst:162 +#: ../../library/tkinter.rst:160 msgid "" "Themed widget set introduced in Tk 8.5, providing modern alternatives for " "many of the classic widgets in the main :mod:`!tkinter` module." @@ -389,15 +389,15 @@ msgstr "" "在 Tk 8.5 中引入的主題式元件集,為主 :mod:`!tkinter` 模組中的許多傳統元件提供" "了現代化的替代方案。" -#: ../../library/tkinter.rst:165 +#: ../../library/tkinter.rst:163 msgid "Additional modules:" msgstr "額外模組:" -#: ../../library/tkinter.rst:170 +#: ../../library/tkinter.rst:168 msgid ":mod:`_tkinter`" msgstr ":mod:`_tkinter`" -#: ../../library/tkinter.rst:171 +#: ../../library/tkinter.rst:169 msgid "" "A binary module that contains the low-level interface to Tcl/Tk. It is " "automatically imported by the main :mod:`!tkinter` module, and should never " @@ -409,21 +409,21 @@ msgstr "" "用程式開發者不應直接使用它。它通常是一個共享函式庫(或 DLL),但在某些情況下" "可能會與 Python 直譯器靜態連結。" -#: ../../library/tkinter.rst:177 +#: ../../library/tkinter.rst:175 msgid ":mod:`idlelib`" msgstr ":mod:`idlelib`" -#: ../../library/tkinter.rst:178 +#: ../../library/tkinter.rst:176 msgid "" "Python's Integrated Development and Learning Environment (IDLE). Based on :" "mod:`!tkinter`." msgstr "Python 的整合開發與學習環境(IDLE)。基於 :mod:`!tkinter`。" -#: ../../library/tkinter.rst:181 +#: ../../library/tkinter.rst:179 msgid ":mod:`!tkinter.constants`" msgstr ":mod:`!tkinter.constants`" -#: ../../library/tkinter.rst:182 +#: ../../library/tkinter.rst:180 msgid "" "Symbolic constants that can be used in place of strings when passing various " "parameters to Tkinter calls. Automatically imported by the main :mod:`!" @@ -432,30 +432,30 @@ msgstr "" "在將各種參數傳遞給 Tkinter 呼叫時,可用於替代字串的符號常數。由主 :mod:`!" "tkinter` 模組自動引入。" -#: ../../library/tkinter.rst:186 +#: ../../library/tkinter.rst:184 msgid ":mod:`tkinter.dnd`" msgstr ":mod:`tkinter.dnd`" -#: ../../library/tkinter.rst:187 +#: ../../library/tkinter.rst:185 msgid "" "(experimental) Drag-and-drop support for :mod:`!tkinter`. This will become " "deprecated when it is replaced with the Tk DND." msgstr "" "(實驗性)對 :mod:`!tkinter` 的拖放支援。當它被 Tk DND 取代時,將會被棄用。" -#: ../../library/tkinter.rst:190 +#: ../../library/tkinter.rst:188 msgid ":mod:`turtle`" msgstr ":mod:`turtle`" -#: ../../library/tkinter.rst:191 +#: ../../library/tkinter.rst:189 msgid "Turtle graphics in a Tk window." msgstr "在 Tk 視窗中的海龜繪圖。" -#: ../../library/tkinter.rst:197 +#: ../../library/tkinter.rst:195 msgid "Tkinter life preserver" msgstr "Tkinter 應急指南" -#: ../../library/tkinter.rst:199 +#: ../../library/tkinter.rst:197 msgid "" "This section is not designed to be an exhaustive tutorial on either Tk or " "Tkinter. For that, refer to one of the external resources noted earlier. " @@ -467,7 +467,7 @@ msgstr "" "一。相反地,本節提供了一個快速導覽,介紹 Tkinter 應用程式的外觀、識別基礎的 " "Tk 概念,並解釋 Tkinter 包裝器的結構。" -#: ../../library/tkinter.rst:205 +#: ../../library/tkinter.rst:203 msgid "" "The remainder of this section will help you to identify the classes, " "methods, and options you'll need in your Tkinter application, and where to " @@ -477,11 +477,11 @@ msgstr "" "本節的其餘部分將幫助你識別在 Tkinter 應用程式中所需的類別、方法和選項,以及在" "哪裡可以找到關於它們的更詳細文件,包括在官方的 Tcl/Tk 參考手冊中。" -#: ../../library/tkinter.rst:212 +#: ../../library/tkinter.rst:210 msgid "A Hello World program" msgstr "一個 Hello World 程式" -#: ../../library/tkinter.rst:214 +#: ../../library/tkinter.rst:212 msgid "" "We'll start by walking through a \"Hello World\" application in Tkinter. " "This isn't the smallest one we could write, but has enough to illustrate " @@ -490,7 +490,7 @@ msgstr "" "我們將從一個 Tkinter 的 \"Hello World\" 應用程式開始。這不是我們能寫出的最小" "程式,但足以說明一些你需要知道的關鍵概念。" -#: ../../library/tkinter.rst:220 +#: ../../library/tkinter.rst:218 msgid "" "from tkinter import *\n" "from tkinter import ttk\n" @@ -510,7 +510,7 @@ msgstr "" "ttk.Button(frm, text=\"Quit\", command=root.destroy).grid(column=1, row=0)\n" "root.mainloop()" -#: ../../library/tkinter.rst:230 +#: ../../library/tkinter.rst:228 msgid "" "After the imports, the next line creates an instance of the :class:`Tk` " "class, which initializes Tk and creates its associated Tcl interpreter. It " @@ -520,7 +520,7 @@ msgstr "" "在引入之後,下一行建立了一個 :class:`Tk` 類別的實例,它會初始化 Tk 並建立其關" "聯的 Tcl 直譯器。它還會建立一個頂層視窗,稱為根視窗,作為應用程式的主視窗。" -#: ../../library/tkinter.rst:235 +#: ../../library/tkinter.rst:233 msgid "" "The following line creates a frame widget, which in this case will contain a " "label and a button we'll create next. The frame is fit inside the root " @@ -529,7 +529,7 @@ msgstr "" "接下來的一行建立了一個框架元件,在本例中,它將包含我們接下來要建立的一個標籤" "和一個按鈕。該框架被放置在根視窗內。" -#: ../../library/tkinter.rst:239 +#: ../../library/tkinter.rst:237 msgid "" "The next line creates a label widget holding a static text string. The :meth:" "`~Grid.grid` method is used to specify the relative layout (position) of the " @@ -538,7 +538,7 @@ msgstr "" "下一行建立了一個包含靜態文字字串的標籤元件。:meth:`~Grid.grid` 方法用於指定標" "籤在其包含的框架元件中的相對佈局(位置),類似於 HTML 中表格的運作方式。" -#: ../../library/tkinter.rst:244 +#: ../../library/tkinter.rst:242 msgid "" "A button widget is then created, and placed to the right of the label. When " "pressed, it will call the :meth:`~Misc.destroy` method of the root window." @@ -546,7 +546,7 @@ msgstr "" "然後建立一個按鈕元件,並放置在標籤的右側。當按下時,它將呼叫根視窗的 :meth:" "`~Misc.destroy` 方法。" -#: ../../library/tkinter.rst:247 +#: ../../library/tkinter.rst:245 msgid "" "Finally, the :meth:`mainloop` method puts everything on the display, and " "responds to user input until the program terminates." @@ -554,19 +554,19 @@ msgstr "" "最後,:meth:`mainloop` 方法將所有內容顯示在螢幕上,並回應使用者輸入,直到程式" "終止。" -#: ../../library/tkinter.rst:253 +#: ../../library/tkinter.rst:251 msgid "Important Tk concepts" msgstr "重要的 Tk 概念" -#: ../../library/tkinter.rst:255 +#: ../../library/tkinter.rst:253 msgid "Even this simple program illustrates the following key Tk concepts:" msgstr "即使是這個簡單的程式也說明了以下關鍵的 Tk 概念:" -#: ../../library/tkinter.rst:257 +#: ../../library/tkinter.rst:255 msgid "widgets" msgstr "元件(widgets)" -#: ../../library/tkinter.rst:258 +#: ../../library/tkinter.rst:256 msgid "" "A Tkinter user interface is made up of individual *widgets*. Each widget is " "represented as a Python object, instantiated from classes like :class:`ttk." @@ -576,11 +576,11 @@ msgstr "" "Python 物件,從 :class:`ttk.Frame`、:class:`ttk.Label` 和 :class:`ttk." "Button` 等類別實例化而來。" -#: ../../library/tkinter.rst:262 +#: ../../library/tkinter.rst:260 msgid "widget hierarchy" msgstr "元件階層(widget hierarchy)" -#: ../../library/tkinter.rst:263 +#: ../../library/tkinter.rst:261 msgid "" "Widgets are arranged in a *hierarchy*. The label and button were contained " "within a frame, which in turn was contained within the root window. When " @@ -591,11 +591,11 @@ msgstr "" "在根視窗內。在建立每個\\ *子*\\ 元件時,其\\ *父*\\ 元件會作為第一個引數傳遞" "給元件的建構函式。" -#: ../../library/tkinter.rst:268 +#: ../../library/tkinter.rst:266 msgid "configuration options" msgstr "設定選項(configuration options)" -#: ../../library/tkinter.rst:269 +#: ../../library/tkinter.rst:267 msgid "" "Widgets have *configuration options*, which modify their appearance and " "behavior, such as the text to display in a label or button. Different " @@ -604,11 +604,11 @@ msgstr "" "元件具有\\ *設定選項*,可以修改其外觀和行為,例如在標籤或按鈕中顯示的文字。不" "同類別的元件會有不同的選項集。" -#: ../../library/tkinter.rst:273 +#: ../../library/tkinter.rst:271 msgid "geometry management" msgstr "佈局管理(geometry management)" -#: ../../library/tkinter.rst:274 +#: ../../library/tkinter.rst:272 msgid "" "Widgets aren't automatically added to the user interface when they are " "created. A *geometry manager* like ``grid`` controls where in the user " @@ -617,11 +617,11 @@ msgstr "" "元件在建立時不會自動新增到使用者介面中。像 ``grid`` 這樣的\\ *佈局管理器*\\ " "(geometry manager)會控制它們在使用者介面中的放置位置。" -#: ../../library/tkinter.rst:278 +#: ../../library/tkinter.rst:276 msgid "event loop" msgstr "事件迴圈(event loop)" -#: ../../library/tkinter.rst:279 +#: ../../library/tkinter.rst:277 msgid "" "Tkinter reacts to user input, changes from your program, and even refreshes " "the display only when actively running an *event loop*. If your program " @@ -630,11 +630,11 @@ msgstr "" "Tkinter 只有在主動執行\\ *事件迴圈*\\ 時,才會對使用者輸入、程式的變更,甚至" "螢幕刷新做出反應。如果你的程式沒有執行事件迴圈,你的使用者介面將不會更新。" -#: ../../library/tkinter.rst:285 +#: ../../library/tkinter.rst:283 msgid "Understanding how Tkinter wraps Tcl/Tk" msgstr "了解 Tkinter 如何包裝 Tcl/Tk" -#: ../../library/tkinter.rst:287 +#: ../../library/tkinter.rst:285 msgid "" "When your application uses Tkinter's classes and methods, internally Tkinter " "is assembling strings representing Tcl/Tk commands, and executing those " @@ -644,7 +644,7 @@ msgstr "" "當你的應用程式使用 Tkinter 的類別和方法時,Tkinter 內部正在組合代表 Tcl/Tk 指" "令的字串,並在附加到你應用程式 :class:`Tk` 實例的 Tcl 直譯器中執行這些指令。" -#: ../../library/tkinter.rst:292 +#: ../../library/tkinter.rst:290 msgid "" "Whether it's trying to navigate reference documentation, trying to find the " "right method or option, adapting some existing code, or debugging your " @@ -654,13 +654,13 @@ msgstr "" "無論是試圖瀏覽參考文件、尋找正確的方法或選項、改寫一些現有程式碼,還是偵錯你" "的 Tkinter 應用程式,在某些時候,了解那些底層 Tcl/Tk 指令的樣貌會很有幫助。" -#: ../../library/tkinter.rst:297 +#: ../../library/tkinter.rst:295 msgid "" "To illustrate, here is the Tcl/Tk equivalent of the main part of the Tkinter " "script above." msgstr "為了說明,以下是上面 Tkinter 腳本主要部分的 Tcl/Tk 對等程式碼。" -#: ../../library/tkinter.rst:302 +#: ../../library/tkinter.rst:300 msgid "" "ttk::frame .frm -padding 10\n" "grid .frm\n" @@ -674,7 +674,7 @@ msgstr "" "grid [ttk::button .frm.btn -text \"Quit\" -command \"destroy .\"] -column 1 -" "row 0" -#: ../../library/tkinter.rst:308 +#: ../../library/tkinter.rst:306 msgid "" "Tcl's syntax is similar to many shell languages, where the first word is the " "command to be executed, with arguments to that command following it, " @@ -684,19 +684,19 @@ msgstr "" "Tcl 的語法類似於許多 shell 語言,第一個字是要執行的指令,後面跟著該指令的引" "數,以空格分隔。在不深入太多細節的情況下,請注意以下幾點:" -#: ../../library/tkinter.rst:312 +#: ../../library/tkinter.rst:310 msgid "" "The commands used to create widgets (like ``ttk::frame``) correspond to " "widget classes in Tkinter." msgstr "用於建立元件的指令(如 ``ttk::frame``)對應於 Tkinter 中的元件類別。" -#: ../../library/tkinter.rst:315 +#: ../../library/tkinter.rst:313 msgid "" "Tcl widget options (like ``-text``) correspond to keyword arguments in " "Tkinter." msgstr "Tcl 元件選項(如 ``-text``)對應於 Tkinter 中的關鍵字引數。" -#: ../../library/tkinter.rst:318 +#: ../../library/tkinter.rst:316 msgid "" "Widgets are referred to by a *pathname* in Tcl (like ``.frm.btn``), whereas " "Tkinter doesn't use names but object references." @@ -704,7 +704,7 @@ msgstr "" "在 Tcl 中,元件是透過\\ *路徑名稱*\\ (如 ``.frm.btn``)來參照,而 Tkinter 不" "使用名稱,而是使用物件參照。" -#: ../../library/tkinter.rst:321 +#: ../../library/tkinter.rst:319 msgid "" "A widget's place in the widget hierarchy is encoded in its (hierarchical) " "pathname, which uses a ``.`` (dot) as a path separator. The pathname for the " @@ -715,7 +715,7 @@ msgstr "" "(點)作為路徑分隔符。根視窗的路徑名稱就是 ``.``\\ (點)。在 Tkinter 中,階" "層不是由路徑名稱定義的,而是在建立每個子元件時指定父元件來定義的。" -#: ../../library/tkinter.rst:327 +#: ../../library/tkinter.rst:325 msgid "" "Operations which are implemented as separate *commands* in Tcl (like " "``grid`` or ``destroy``) are represented as *methods* on Tkinter widget " @@ -727,11 +727,11 @@ msgstr "" "Tkinter 中則表示為元件物件上的\\ *方法*。正如你稍後會看到的,在其他時候,Tcl " "使用的看起來像是對元件物件的方法呼叫,這更接近 Tkinter 中的用法。" -#: ../../library/tkinter.rst:335 +#: ../../library/tkinter.rst:333 msgid "How do I...? What option does...?" msgstr "我該如何...?哪個選項可以...?" -#: ../../library/tkinter.rst:337 +#: ../../library/tkinter.rst:335 msgid "" "If you're not sure how to do something in Tkinter, and you can't immediately " "find it in the tutorial or reference documentation you're using, there are a " @@ -740,7 +740,7 @@ msgstr "" "如果你不確定如何在 Tkinter 中做某件事,並且無法立即在你正在使用的教學或參考文" "件中找到它,這裡有一些可能有幫助的策略。" -#: ../../library/tkinter.rst:341 +#: ../../library/tkinter.rst:339 msgid "" "First, remember that the details of how individual widgets work may vary " "across different versions of both Tkinter and Tcl/Tk. If you're searching " @@ -750,7 +750,7 @@ msgstr "" "首先,請記住,個別元件的運作細節可能會因 Tkinter 和 Tcl/Tk 的不同版本而異。如" "果你正在搜尋文件,請確保它對應於你系統上安裝的 Python 和 Tcl/Tk 版本。" -#: ../../library/tkinter.rst:346 +#: ../../library/tkinter.rst:344 msgid "" "When searching for how to use an API, it helps to know the exact name of the " "class, option, or method that you're using. Introspection, either in an " @@ -761,7 +761,7 @@ msgstr "" "自省(Introspection),無論是在互動式 Python shell 中還是使用 :func:`print`," "都可以幫助你識別所需內容。" -#: ../../library/tkinter.rst:351 +#: ../../library/tkinter.rst:349 msgid "" "To find out what configuration options are available on any widget, call " "its :meth:`~Misc.configure` method, which returns a dictionary containing a " @@ -772,7 +772,7 @@ msgstr "" "該方法會回傳一個字典,其中包含有關每個物件的各種資訊,包括其預設值和目前值。" "使用 :meth:`~Misc.keys` 僅取得每個選項的名稱。" -#: ../../library/tkinter.rst:358 +#: ../../library/tkinter.rst:356 msgid "" "btn = ttk.Button(frm, ...)\n" "print(btn.configure().keys())" @@ -780,7 +780,7 @@ msgstr "" "btn = ttk.Button(frm, ...)\n" "print(btn.configure().keys())" -#: ../../library/tkinter.rst:361 +#: ../../library/tkinter.rst:359 msgid "" "As most widgets have many configuration options in common, it can be useful " "to find out which are specific to a particular widget class. Comparing the " @@ -790,11 +790,11 @@ msgstr "" "由於大多數元件有許多共通的設定選項,找出特定於某個元件類別的選項會很有用。將" "選項串列與像框架這樣較簡單的元件的選項串列進行比較,是做到這一點的一種方法。" -#: ../../library/tkinter.rst:368 +#: ../../library/tkinter.rst:366 msgid "print(set(btn.configure().keys()) - set(frm.configure().keys()))" msgstr "print(set(btn.configure().keys()) - set(frm.configure().keys()))" -#: ../../library/tkinter.rst:370 +#: ../../library/tkinter.rst:368 msgid "" "Similarly, you can find the available methods for a widget object using the " "standard :func:`dir` function. If you try it, you'll see there are over 200 " @@ -805,7 +805,7 @@ msgstr "" "下,你會看到有超過 200 個常見的元件方法,所以再次強調,識別特定於某個元件類別" "的方法是很有幫助的。" -#: ../../library/tkinter.rst:377 +#: ../../library/tkinter.rst:375 msgid "" "print(dir(btn))\n" "print(set(dir(btn)) - set(dir(frm)))" @@ -813,11 +813,11 @@ msgstr "" "print(dir(btn))\n" "print(set(dir(btn)) - set(dir(frm)))" -#: ../../library/tkinter.rst:382 +#: ../../library/tkinter.rst:380 msgid "Navigating the Tcl/Tk reference manual" msgstr "瀏覽 Tcl/Tk 參考手冊" -#: ../../library/tkinter.rst:384 +#: ../../library/tkinter.rst:382 msgid "" "As noted, the official `Tk commands `_ reference manual (man pages) is often the most accurate " @@ -829,7 +829,7 @@ msgstr "" "index.html>`_\\ 參考手冊(man pages)通常是對元件上特定操作作用的最準確描述。" "即使你知道所需選項或方法的名稱,你可能仍有幾個地方需要查看。" -#: ../../library/tkinter.rst:391 +#: ../../library/tkinter.rst:389 msgid "" "While all operations in Tkinter are implemented as method calls on widget " "objects, you've seen that many Tcl/Tk operations appear as commands that " @@ -840,7 +840,7 @@ msgstr "" "Tk 操作顯示為指令,這些指令將元件路徑名稱作為其第一個參數,後面跟著可選的參" "數,例如:" -#: ../../library/tkinter.rst:398 +#: ../../library/tkinter.rst:396 msgid "" "destroy .\n" "grid .frm.btn -column 0 -row 0" @@ -848,7 +848,7 @@ msgstr "" "destroy .\n" "grid .frm.btn -column 0 -row 0" -#: ../../library/tkinter.rst:401 +#: ../../library/tkinter.rst:399 msgid "" "Others, however, look more like methods called on a widget object (in fact, " "when you create a widget in Tcl/Tk, it creates a Tcl command with the name " @@ -859,7 +859,7 @@ msgstr "" "個元件時,它會建立一個以元件路徑名稱為名的 Tcl 指令,該指令的第一個參數是要呼" "叫的方法名稱)。" -#: ../../library/tkinter.rst:408 +#: ../../library/tkinter.rst:406 msgid "" ".frm.btn invoke\n" ".frm.lbl configure -text \"Goodbye\"" @@ -867,7 +867,7 @@ msgstr "" ".frm.btn invoke\n" ".frm.lbl configure -text \"Goodbye\"" -#: ../../library/tkinter.rst:412 +#: ../../library/tkinter.rst:410 msgid "" "In the official Tcl/Tk reference documentation, you'll find most operations " "that look like method calls on the man page for a specific widget (for " @@ -883,7 +883,7 @@ msgstr "" "invoke` 方法),而將元件作為參數的函式通常有自己的 man page(例如 `grid " "`_)。" -#: ../../library/tkinter.rst:420 +#: ../../library/tkinter.rst:418 msgid "" "You'll find many common options and methods in the `options `_ or `ttk::widget `_ man page 中找到許多常見的選項和方法,而其他的則在特定元件類別的 man " "page 中找到。" -#: ../../library/tkinter.rst:425 +#: ../../library/tkinter.rst:423 msgid "" "You'll also find that many Tkinter methods have compound names, for " "example, :meth:`~Misc.winfo_x`, :meth:`~Misc.winfo_height`, :meth:`~Misc." @@ -907,7 +907,7 @@ msgstr "" "www.tcl-lang.org/man/tcl9.0/TkCmd/winfo.html>`_ man page 中找到所有這些文件的" "說明。" -#: ../../library/tkinter.rst:432 +#: ../../library/tkinter.rst:430 msgid "" "Somewhat confusingly, there are also methods on all Tkinter widgets that " "don't actually operate on the widget, but operate at a global scope, " @@ -920,11 +920,11 @@ msgstr "" "法。(它們恰好被實作為所有 Tkinter 元件都繼承的基底 :class:`Widget` 類別中的" "方法)。" -#: ../../library/tkinter.rst:441 +#: ../../library/tkinter.rst:439 msgid "Threading model" msgstr "執行緒模型" -#: ../../library/tkinter.rst:443 +#: ../../library/tkinter.rst:441 msgid "" "Python and Tcl/Tk have very different threading models, which :mod:`!" "tkinter` tries to bridge. If you use threads, you may need to be aware of " @@ -933,7 +933,7 @@ msgstr "" "Python 和 Tcl/Tk 有非常不同的執行緒模型,:mod:`!tkinter` 試圖彌合這種差異。如" "果你使用執行緒,你可能需要意識到這一點。" -#: ../../library/tkinter.rst:446 +#: ../../library/tkinter.rst:444 msgid "" "A Python interpreter may have many threads associated with it. In Tcl, " "multiple threads can be created, but each thread has a separate Tcl " @@ -945,7 +945,7 @@ msgstr "" "但每個執行緒都有一個獨立的 Tcl 直譯器實例與之關聯。執行緒也可以建立多個直譯器" "實例,但每個直譯器實例只能由建立它的那個執行緒使用。" -#: ../../library/tkinter.rst:451 +#: ../../library/tkinter.rst:449 msgid "" "Each :class:`Tk` object created by :mod:`!tkinter` contains a Tcl " "interpreter. It also keeps track of which thread created that interpreter. " @@ -959,7 +959,7 @@ msgstr "" "在內部,如果呼叫來自建立 :class:`Tk` 物件的執行緒以外的執行緒,則會將一個事件" "發佈到直譯器的事件佇列中,執行後,結果會回傳給呼叫的 Python 執行緒。" -#: ../../library/tkinter.rst:458 +#: ../../library/tkinter.rst:456 msgid "" "Tcl/Tk applications are normally event-driven, meaning that after " "initialization, the interpreter runs an event loop (that is, :meth:`Tk." @@ -978,7 +978,7 @@ msgstr "" "分,或在另一個執行緒中執行。這與許多 GUI 工具集不同,在那些工具集中,GUI 在一" "個與所有應用程式碼(包括事件處理常式)完全分離的執行緒中執行。" -#: ../../library/tkinter.rst:469 +#: ../../library/tkinter.rst:467 msgid "" "If the Tcl interpreter is not running the event loop and processing events, " "any :mod:`!tkinter` calls made from threads other than the one running the " @@ -987,25 +987,25 @@ msgstr "" "如果 Tcl 直譯器沒有在執行事件迴圈和處理事件,那麼從執行 Tcl 直譯器的執行緒以" "外的執行緒發出的任何 :mod:`!tkinter` 呼叫都將失敗。" -#: ../../library/tkinter.rst:473 +#: ../../library/tkinter.rst:471 msgid "A number of special cases exist:" msgstr "存在一些特殊情況:" -#: ../../library/tkinter.rst:475 +#: ../../library/tkinter.rst:473 msgid "" -"Tcl/Tk libraries built without thread support are now rare: the bundled Tcl/" -"Tk 8.6 is built with thread support, so this case only arises with some " -"older non-threaded builds. When the library is not thread-aware, :mod:`!" -"tkinter` calls the library from the originating Python thread, even if this " -"is different than the thread that created the Tcl interpreter. A global lock " +"Tcl/Tk libraries built without thread support are now rare: Tcl/Tk 9.0 (the " +"bundled version) is always thread-aware, so this case only arises with some " +"older 8.x builds. When the library is not thread-aware, :mod:`!tkinter` " +"calls the library from the originating Python thread, even if this is " +"different than the thread that created the Tcl interpreter. A global lock " "ensures only one call occurs at a time." msgstr "" -"不具備執行緒支援的 Tcl/Tk 函式庫目前已很少見:捆綁的 Tcl/Tk 8.6 是以執行緒支" -"援建構的,因此這種情況只在某些較舊的非執行緒建構版本中出現。當函式庫不具備執" -"行緒感知能力時,:mod:`!tkinter` 會從原始的 Python 執行緒呼叫該函式庫,即使這" -"與建立 Tcl 直譯器的執行緒不同。一個全域鎖確保一次只發生一個呼叫。" +"不具備執行緒支援的 Tcl/Tk 函式庫目前已很少見:Tcl/Tk 9.0(捆綁的版本)一定具" +"備執行緒感知能力,因此這種情況只在某些較舊的 8.x 建構版本中出現。當函式庫不具" +"備執行緒感知能力時,:mod:`!tkinter` 會從原始的 Python 執行緒呼叫該函式庫,即" +"使這與建立 Tcl 直譯器的執行緒不同。一個全域鎖確保一次只發生一個呼叫。" -#: ../../library/tkinter.rst:482 +#: ../../library/tkinter.rst:480 msgid "" "While :mod:`!tkinter` allows you to create more than one instance of a :" "class:`Tk` object (with its own interpreter), all interpreters that are part " @@ -1019,7 +1019,7 @@ msgstr "" "混亂。在實務上,不要一次建立多個 :class:`Tk` 的實例。否則,最好在不同的執行緒" "中建立它們,並確保你正在執行一個具備執行緒感知能力的 Tcl/Tk 建構版本。" -#: ../../library/tkinter.rst:488 +#: ../../library/tkinter.rst:486 msgid "" "Blocking event handlers are not the only way to prevent the Tcl interpreter " "from reentering the event loop. It is even possible to run multiple nested " @@ -1030,7 +1030,7 @@ msgstr "" "多個巢狀的事件迴圈或完全放棄事件迴圈。如果你在事件或執行緒方面做任何複雜的操" "作,請注意這些可能性。" -#: ../../library/tkinter.rst:493 +#: ../../library/tkinter.rst:491 msgid "" "There are a few select :mod:`!tkinter` functions that presently work only " "when called from the thread that created the Tcl interpreter." @@ -1038,33 +1038,33 @@ msgstr "" "目前有少數幾個 :mod:`!tkinter` 函式只有在從建立 Tcl 直譯器的執行緒中呼叫時才" "能正常運作。" -#: ../../library/tkinter.rst:498 +#: ../../library/tkinter.rst:496 msgid "Handy reference" msgstr "實用參考" -#: ../../library/tkinter.rst:504 +#: ../../library/tkinter.rst:502 msgid "Setting options" msgstr "設定選項" -#: ../../library/tkinter.rst:506 +#: ../../library/tkinter.rst:504 msgid "" "Options control things like the color and border width of a widget. Options " "can be set in three ways:" msgstr "選項控制著諸如元件的顏色和邊框寬度等。選項可以透過三種方式設定:" -#: ../../library/tkinter.rst:509 +#: ../../library/tkinter.rst:507 msgid "At object creation time, using keyword arguments" msgstr "在物件建立時,使用關鍵字引數" -#: ../../library/tkinter.rst:512 +#: ../../library/tkinter.rst:510 msgid "fred = Button(self, fg=\"red\", bg=\"blue\")" msgstr "fred = Button(self, fg=\"red\", bg=\"blue\")" -#: ../../library/tkinter.rst:514 +#: ../../library/tkinter.rst:512 msgid "After object creation, treating the option name like a dictionary index" msgstr "在物件建立後,將選項名稱視為字典索引" -#: ../../library/tkinter.rst:517 +#: ../../library/tkinter.rst:515 msgid "" "fred[\"fg\"] = \"red\"\n" "fred[\"bg\"] = \"blue\"" @@ -1072,17 +1072,17 @@ msgstr "" "fred[\"fg\"] = \"red\"\n" "fred[\"bg\"] = \"blue\"" -#: ../../library/tkinter.rst:520 +#: ../../library/tkinter.rst:518 msgid "" "Use the config() method to update multiple attrs subsequent to object " "creation" msgstr "在物件建立後,使用 config() 方法更新多個屬性" -#: ../../library/tkinter.rst:523 +#: ../../library/tkinter.rst:521 msgid "fred.config(fg=\"red\", bg=\"blue\")" msgstr "fred.config(fg=\"red\", bg=\"blue\")" -#: ../../library/tkinter.rst:527 +#: ../../library/tkinter.rst:525 msgid "" "The ``fg`` and ``bg`` options used here, and other options that control a " "widget's appearance, belong to the classic :mod:`!tkinter` widgets. The " @@ -1092,13 +1092,13 @@ msgid "" "apply to both widget sets." msgstr "" -#: ../../library/tkinter.rst:536 +#: ../../library/tkinter.rst:534 msgid "" "For a complete explanation of a given option and its behavior, see the Tk " "man pages for the widget in question." msgstr "有關給定選項及其行為的完整解釋,請參閱相關元件的 Tk man pages。" -#: ../../library/tkinter.rst:539 +#: ../../library/tkinter.rst:537 msgid "" "Note that the man pages list \"STANDARD OPTIONS\" and \"WIDGET SPECIFIC " "OPTIONS\" for each widget. The former is a list of options that are common " @@ -1110,7 +1110,7 @@ msgstr "" "元件共有的選項串列,後者是該特定元件特有的選項。標準選項記錄在 :manpage:" "`options(3)` man page 中。" -#: ../../library/tkinter.rst:545 +#: ../../library/tkinter.rst:543 msgid "" "No distinction between standard and widget-specific options is made in this " "document. Some options don't apply to some kinds of widgets. Whether a " @@ -1121,7 +1121,7 @@ msgstr "" "給定元件是否回應特定選項取決於該元件的類別;按鈕有 ``command`` 選項,標籤則沒" "有。" -#: ../../library/tkinter.rst:550 +#: ../../library/tkinter.rst:548 msgid "" "The options supported by a given widget are listed in that widget's man " "page, or can be queried at runtime by calling the :meth:`~Misc.config` " @@ -1135,85 +1135,85 @@ msgstr "" "這些呼叫的回傳值是一個字典,其鍵是選項名稱的字串(例如 ``'relief'``),其值" "是 5-tuples。" -#: ../../library/tkinter.rst:556 +#: ../../library/tkinter.rst:554 msgid "" "Some options, like ``bg``, are synonyms for common options with long names " "(``bg`` is shorthand for \"background\")." msgstr "" -#: ../../library/tkinter.rst:560 +#: ../../library/tkinter.rst:558 msgid "Index" msgstr "索引" -#: ../../library/tkinter.rst:560 +#: ../../library/tkinter.rst:558 msgid "Meaning" msgstr "含義" -#: ../../library/tkinter.rst:560 +#: ../../library/tkinter.rst:558 msgid "Example" msgstr "範例" -#: ../../library/tkinter.rst:562 +#: ../../library/tkinter.rst:560 msgid "0" msgstr "0" -#: ../../library/tkinter.rst:562 +#: ../../library/tkinter.rst:560 msgid "option name" msgstr "選項名稱" -#: ../../library/tkinter.rst:562 ../../library/tkinter.rst:564 +#: ../../library/tkinter.rst:560 ../../library/tkinter.rst:562 msgid "``'relief'``" msgstr "``'relief'``" -#: ../../library/tkinter.rst:564 +#: ../../library/tkinter.rst:562 msgid "1" msgstr "1" -#: ../../library/tkinter.rst:564 +#: ../../library/tkinter.rst:562 msgid "option name for database lookup" msgstr "用於資料庫查詢的選項名稱" -#: ../../library/tkinter.rst:566 +#: ../../library/tkinter.rst:564 msgid "2" msgstr "2" -#: ../../library/tkinter.rst:566 +#: ../../library/tkinter.rst:564 msgid "option class for database lookup" msgstr "用於資料庫查詢的選項類別" -#: ../../library/tkinter.rst:566 +#: ../../library/tkinter.rst:564 msgid "``'Relief'``" msgstr "``'Relief'``" -#: ../../library/tkinter.rst:569 +#: ../../library/tkinter.rst:567 msgid "3" msgstr "3" -#: ../../library/tkinter.rst:569 +#: ../../library/tkinter.rst:567 msgid "default value" msgstr "預設值" -#: ../../library/tkinter.rst:569 +#: ../../library/tkinter.rst:567 msgid "``'raised'``" msgstr "``'raised'``" -#: ../../library/tkinter.rst:571 +#: ../../library/tkinter.rst:569 msgid "4" msgstr "4" -#: ../../library/tkinter.rst:571 +#: ../../library/tkinter.rst:569 msgid "current value" msgstr "目前值" -#: ../../library/tkinter.rst:571 +#: ../../library/tkinter.rst:569 msgid "``'groove'``" msgstr "``'groove'``" -#: ../../library/tkinter.rst:574 +#: ../../library/tkinter.rst:572 msgid "Example::" msgstr "範例: ::" -#: ../../library/tkinter.rst:576 +#: ../../library/tkinter.rst:574 msgid "" ">>> print(fred.config())\n" "{'relief': ('relief', 'relief', 'Relief', 'raised', 'groove')}" @@ -1221,17 +1221,17 @@ msgstr "" ">>> print(fred.config())\n" "{'relief': ('relief', 'relief', 'Relief', 'raised', 'groove')}" -#: ../../library/tkinter.rst:579 +#: ../../library/tkinter.rst:577 msgid "" "Of course, the dictionary printed will include all the options available and " "their values. This is meant only as an example." msgstr "當然,印出的字典將包含所有可用的選項及其值。這僅作為一個範例。" -#: ../../library/tkinter.rst:589 +#: ../../library/tkinter.rst:587 msgid "Geometry management" msgstr "佈局管理 (geometry management)" -#: ../../library/tkinter.rst:595 +#: ../../library/tkinter.rst:593 msgid "" "Creating a widget does not display it. A widget appears only after it has " "been handed to a *geometry manager*, which works out its size and position " @@ -1240,7 +1240,7 @@ msgid "" "common early mistake: the widget is created, but nothing shows up." msgstr "" -#: ../../library/tkinter.rst:602 +#: ../../library/tkinter.rst:600 msgid "" "Tk provides three geometry managers. Each is inherited by every widget, so " "any widget can be managed by any of them (but see the warning below about " @@ -1248,11 +1248,11 @@ msgid "" "layout you want." msgstr "" -#: ../../library/tkinter.rst:607 +#: ../../library/tkinter.rst:605 msgid ":meth:`grid `" msgstr ":meth:`grid `" -#: ../../library/tkinter.rst:608 +#: ../../library/tkinter.rst:606 msgid "" "Arranges widgets in a two-dimensional table of rows and columns. It is the " "most flexible manager and the one to reach for by default: layouts that " @@ -1260,7 +1260,7 @@ msgid "" "single grid, and rows and columns can be told how to absorb extra space." msgstr "" -#: ../../library/tkinter.rst:616 +#: ../../library/tkinter.rst:614 msgid "" "ttk.Label(frm, text=\"Name:\").grid(column=0, row=0, sticky=\"w\")\n" "ttk.Entry(frm).grid(column=1, row=0)\n" @@ -1270,11 +1270,11 @@ msgstr "" "ttk.Entry(frm).grid(column=1, row=0)\n" "ttk.Button(frm, text=\"OK\").grid(column=1, row=1, sticky=\"e\")" -#: ../../library/tkinter.rst:620 +#: ../../library/tkinter.rst:618 msgid ":meth:`pack `" msgstr ":meth:`pack `" -#: ../../library/tkinter.rst:621 +#: ../../library/tkinter.rst:619 msgid "" "Stacks widgets against one side of their container -- ``\"top\"`` (the " "default), ``\"bottom\"``, ``\"left\"`` or ``\"right\"`` -- and can make them " @@ -1283,7 +1283,7 @@ msgid "" "framed by a toolbar and a status bar." msgstr "" -#: ../../library/tkinter.rst:630 +#: ../../library/tkinter.rst:628 msgid "" "toolbar.pack(side=\"top\", fill=\"x\")\n" "status.pack(side=\"bottom\", fill=\"x\")\n" @@ -1293,11 +1293,11 @@ msgstr "" "status.pack(side=\"bottom\", fill=\"x\")\n" "body.pack(side=\"left\", expand=True, fill=\"both\")" -#: ../../library/tkinter.rst:634 +#: ../../library/tkinter.rst:632 msgid ":meth:`place `" msgstr ":meth:`place `" -#: ../../library/tkinter.rst:635 +#: ../../library/tkinter.rst:633 msgid "" "Positions each widget at an explicit spot, given either as absolute screen " "distances or as a fraction of the container's size. It offers the most " @@ -1305,7 +1305,7 @@ msgid "" "special cases such as overlapping widgets or precise custom layouts." msgstr "" -#: ../../library/tkinter.rst:642 +#: ../../library/tkinter.rst:640 msgid "" "background.place(x=0, y=0, relwidth=1.0, relheight=1.0)\n" "badge.place(relx=1.0, rely=0.0, anchor=\"ne\")" @@ -1313,14 +1313,14 @@ msgstr "" "background.place(x=0, y=0, relwidth=1.0, relheight=1.0)\n" "badge.place(relx=1.0, rely=0.0, anchor=\"ne\")" -#: ../../library/tkinter.rst:645 +#: ../../library/tkinter.rst:643 msgid "" "Layouts are built up by nesting: grid or pack widgets, including frames, " "inside a frame or toplevel. Toplevels are managed by the OS window manager. " "Classic and themed :mod:`tkinter.ttk` widgets can be managed interchangeably." msgstr "" -#: ../../library/tkinter.rst:652 +#: ../../library/tkinter.rst:650 msgid "" "Do not apply :meth:`!pack` and :meth:`!grid` to two widgets that share the " "same container. The two managers negotiate sizes in incompatible ways, and " @@ -1328,7 +1328,7 @@ msgid "" "each other. To combine them, keep each manager's widgets in a separate frame." msgstr "" -#: ../../library/tkinter.rst:657 +#: ../../library/tkinter.rst:655 msgid "" "The full set of options accepted by each manager, with their values and " "defaults, is documented under :meth:`Grid.grid_configure`, :meth:`Pack." @@ -1336,11 +1336,11 @@ msgid "" "`grid(3tk)`, :manpage:`pack(3tk)` and :manpage:`place(3tk)` man pages." msgstr "" -#: ../../library/tkinter.rst:667 +#: ../../library/tkinter.rst:665 msgid "Coupling widget variables" msgstr "耦合元件變數" -#: ../../library/tkinter.rst:669 +#: ../../library/tkinter.rst:667 msgid "" "Some widgets can tie their current value directly to a program variable, so " "that the two stay in sync. Options such as ``variable``, ``textvariable``, " @@ -1353,7 +1353,7 @@ msgstr "" "結:當使用者變更元件時,變數會隨之更新;而當變數被設定時,元件也會重新繪製以" "反映該值。" -#: ../../library/tkinter.rst:676 +#: ../../library/tkinter.rst:674 msgid "" "A widget can be linked only to a :class:`Variable` object, not to an " "ordinary Python variable. This is not a limitation of :mod:`!tkinter` but a " @@ -1364,7 +1364,7 @@ msgid "" "explicit :meth:`~Variable.get` and :meth:`~Variable.set` methods." msgstr "" -#: ../../library/tkinter.rst:685 +#: ../../library/tkinter.rst:683 msgid "" "Ready-made subclasses cover the common types: :class:`StringVar`, :class:" "`IntVar`, :class:`DoubleVar` and :class:`BooleanVar`. Pass one as a widget's " @@ -1378,7 +1378,7 @@ msgstr "" "``variable``)選項,然後使用 :meth:`~Variable.get` 和 :meth:`~Variable.set` " "來讀取和更新它;元件會自動追蹤它,不需要你再做其他事。" -#: ../../library/tkinter.rst:691 +#: ../../library/tkinter.rst:689 msgid "" "Keep a reference to the variable for as long as the widget uses it -- for " "example by storing it as an attribute. A :class:`Variable` that is garbage " @@ -1386,12 +1386,12 @@ msgid "" "the widget (see :class:`Variable`)." msgstr "" -#: ../../library/tkinter.rst:696 ../../library/tkinter.rst:746 -#: ../../library/tkinter.rst:887 +#: ../../library/tkinter.rst:694 ../../library/tkinter.rst:744 +#: ../../library/tkinter.rst:885 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/tkinter.rst:698 +#: ../../library/tkinter.rst:696 msgid "" "import tkinter as tk\n" "from tkinter import ttk\n" @@ -1447,11 +1447,11 @@ msgstr "" "\n" "root.mainloop()" -#: ../../library/tkinter.rst:728 +#: ../../library/tkinter.rst:726 msgid "The window manager" msgstr "視窗管理器" -#: ../../library/tkinter.rst:732 +#: ../../library/tkinter.rst:730 msgid "" "The *window manager* is the part of the desktop responsible for the title " "bar, border and controls drawn around each top-level window, and for such " @@ -1463,7 +1463,7 @@ msgid "" "`~Wm.wm_title`." msgstr "" -#: ../../library/tkinter.rst:741 +#: ../../library/tkinter.rst:739 msgid "" "These methods act on the top-level window whether its content is built from " "the classic widgets or the themed :mod:`tkinter.ttk` widgets. To reach the " @@ -1471,7 +1471,7 @@ msgid "" "winfo_toplevel` method." msgstr "" -#: ../../library/tkinter.rst:748 +#: ../../library/tkinter.rst:746 msgid "" "import tkinter as tk\n" "from tkinter import ttk\n" @@ -1497,25 +1497,25 @@ msgstr "" "\n" "root.mainloop()" -#: ../../library/tkinter.rst:760 +#: ../../library/tkinter.rst:758 msgid "See :class:`Wm` for the full set of window-manager methods." msgstr "" -#: ../../library/tkinter.rst:766 +#: ../../library/tkinter.rst:764 msgid "Tk option data types" msgstr "Tk 選項資料型別" -#: ../../library/tkinter.rst:770 +#: ../../library/tkinter.rst:768 msgid "" "Many widget options documented in the reference accept values of a small " "number of common types, described here." msgstr "" -#: ../../library/tkinter.rst:773 +#: ../../library/tkinter.rst:771 msgid "anchor" msgstr "anchor" -#: ../../library/tkinter.rst:774 +#: ../../library/tkinter.rst:772 msgid "" "Legal values are points of the compass: ``\"n\"``, ``\"ne\"``, ``\"e\"``, " "``\"se\"``, ``\"s\"``, ``\"sw\"``, ``\"w\"``, ``\"nw\"``, and also " @@ -1524,11 +1524,11 @@ msgstr "" "合法值為羅盤方位點:``\"n\"``、``\"ne\"``、``\"e\"``、``\"se\"``、``\"s\"``、" "``\"sw\"``、``\"w\"``、``\"nw\"``,以及 ``\"center\"``。" -#: ../../library/tkinter.rst:777 +#: ../../library/tkinter.rst:775 msgid "bitmap" msgstr "bitmap" -#: ../../library/tkinter.rst:778 +#: ../../library/tkinter.rst:776 msgid "" "There are ten built-in, named bitmaps: ``'error'``, ``'gray12'``, " "``'gray25'``, ``'gray50'``, ``'gray75'``, ``'hourglass'``, ``'info'``, " @@ -1541,23 +1541,23 @@ msgstr "" "``'question'``、``'warning'``。要指定一個 X 點陣圖檔名,請給出檔案的完整路" "徑,並在前面加上一個 ``@``,例如 ``\"@/usr/contrib/bitmap/gumby.bit\"``。" -#: ../../library/tkinter.rst:784 +#: ../../library/tkinter.rst:782 msgid "boolean" msgstr "boolean" -#: ../../library/tkinter.rst:785 +#: ../../library/tkinter.rst:783 msgid "You can pass integers 0 or 1 or the strings ``\"yes\"`` or ``\"no\"``." msgstr "你可以傳遞整數 0 或 1,或字串 ``\"yes\"`` 或 ``\"no\"``。" -#: ../../library/tkinter.rst:787 +#: ../../library/tkinter.rst:785 msgid "callback" msgstr "callback" -#: ../../library/tkinter.rst:788 +#: ../../library/tkinter.rst:786 msgid "This is any Python function that takes no arguments. For example::" msgstr "這是任何不帶引數的 Python 函式。例如: ::" -#: ../../library/tkinter.rst:790 +#: ../../library/tkinter.rst:788 msgid "" "def print_it():\n" " print(\"hi there\")\n" @@ -1567,11 +1567,11 @@ msgstr "" " print(\"hi there\")\n" "fred[\"command\"] = print_it" -#: ../../library/tkinter.rst:794 +#: ../../library/tkinter.rst:792 msgid "color" msgstr "color" -#: ../../library/tkinter.rst:795 +#: ../../library/tkinter.rst:793 msgid "" "Colors can be given as the names of X colors in the rgb.txt file, or as " "strings representing RGB values in 4 bit: ``\"#RGB\"``, 8 bit: " @@ -1585,11 +1585,11 @@ msgstr "" "何合法的十六進位數字。已命名顏色的清單請參閱 :manpage:`colors(3tk)` man " "page。" -#: ../../library/tkinter.rst:801 +#: ../../library/tkinter.rst:799 msgid "cursor" msgstr "cursor" -#: ../../library/tkinter.rst:802 +#: ../../library/tkinter.rst:800 msgid "" "The name of the mouse cursor to display while the pointer is over the " "widget. Tk provides a portable set of cursor names available on all " @@ -1611,11 +1611,11 @@ msgstr "" "或 :file:`.ani`),在其路徑前加上 ``@`` 即可,例如 ``\"@C:/cursors/" "bart.ani\"``。" -#: ../../library/tkinter.rst:813 +#: ../../library/tkinter.rst:811 msgid "distance" msgstr "distance" -#: ../../library/tkinter.rst:814 +#: ../../library/tkinter.rst:812 msgid "" "Screen distances can be specified in either pixels or absolute distances. " "Pixels are given as numbers and absolute distances as strings, with the " @@ -1627,11 +1627,11 @@ msgstr "" "元表示單位:``c`` 代表公分,``i`` 代表英寸,``m`` 代表毫米,``p`` 代表印刷的" "點。例如,3.5 英寸表示為 ``\"3.5i\"``。" -#: ../../library/tkinter.rst:820 +#: ../../library/tkinter.rst:818 msgid "font" msgstr "font" -#: ../../library/tkinter.rst:821 +#: ../../library/tkinter.rst:819 msgid "" "Tk uses a font description such as ``{courier 10 bold}``; in :mod:`!tkinter` " "this is most naturally passed as a tuple of ``(family, size, *styles)`` (or " @@ -1644,11 +1644,11 @@ msgstr "" "``\"Courier 10 bold\"``)。正數的字型大小以點 (point) 為單位;負數的大小則以" "像素為單位。" -#: ../../library/tkinter.rst:827 +#: ../../library/tkinter.rst:825 msgid "geometry" msgstr "geometry" -#: ../../library/tkinter.rst:828 +#: ../../library/tkinter.rst:826 msgid "" "This is a string of the form ``widthxheight``, where width and height are " "measured in pixels for most widgets (in characters for widgets displaying " @@ -1658,21 +1658,21 @@ msgstr "" "像素為單位(對於顯示文字的元件則以字元為單位)。例如:``fred[\"geometry\"] = " "\"200x100\"``。" -#: ../../library/tkinter.rst:832 +#: ../../library/tkinter.rst:830 msgid "justify" msgstr "justify" -#: ../../library/tkinter.rst:833 +#: ../../library/tkinter.rst:831 msgid "" "Legal values are the strings: ``\"left\"``, ``\"center\"``, and " "``\"right\"``." msgstr "合法值為字串:``\"left\"``、``\"center\"`` 和 ``\"right\"``。" -#: ../../library/tkinter.rst:835 +#: ../../library/tkinter.rst:833 msgid "region" msgstr "region" -#: ../../library/tkinter.rst:836 +#: ../../library/tkinter.rst:834 msgid "" "This is a string with four space-delimited elements, each of which is a " "legal distance (see above). For example: ``\"2 3 4 5\"`` and ``\"3i 2i 4.5i " @@ -1682,11 +1682,11 @@ msgstr "" "文)。例如:``\"2 3 4 5\"``、``\"3i 2i 4.5i 2i\"`` 和 ``\"3c 2c 4c " "10.43c\"`` 都是合法的區域。" -#: ../../library/tkinter.rst:840 +#: ../../library/tkinter.rst:838 msgid "relief" msgstr "relief" -#: ../../library/tkinter.rst:841 +#: ../../library/tkinter.rst:839 msgid "" "Determines what the border style of a widget will be. Legal values are: " "``\"raised\"``, ``\"sunken\"``, ``\"flat\"``, ``\"groove\"``, ``\"ridge\"``, " @@ -1695,11 +1695,11 @@ msgstr "" "決定元件的邊框樣式。合法值為:``\"raised\"``、``\"sunken\"``、``\"flat\"``、" "``\"groove\"``、``\"ridge\"`` 和 ``\"solid\"``。" -#: ../../library/tkinter.rst:845 +#: ../../library/tkinter.rst:843 msgid "scrollcommand" msgstr "scrollcommand" -#: ../../library/tkinter.rst:846 +#: ../../library/tkinter.rst:844 msgid "" "This is almost always the :meth:`!set` method of some scrollbar widget, but " "can be any widget method that takes a single argument." @@ -1707,19 +1707,19 @@ msgstr "" "這幾乎總是某個捲軸元件的 :meth:`!set` 方法,但也可以是任何接受單一引數的元件" "方法。" -#: ../../library/tkinter.rst:849 +#: ../../library/tkinter.rst:847 msgid "wrap" msgstr "wrap" -#: ../../library/tkinter.rst:850 +#: ../../library/tkinter.rst:848 msgid "Must be one of: ``\"none\"``, ``\"char\"``, or ``\"word\"``." msgstr "必須是以下之一:``\"none\"``、``\"char\"`` 或 ``\"word\"``。" -#: ../../library/tkinter.rst:855 +#: ../../library/tkinter.rst:853 msgid "Bindings and events" msgstr "繫結與事件" -#: ../../library/tkinter.rst:861 +#: ../../library/tkinter.rst:859 msgid "" "The bind method from the widget command allows you to watch for certain " "events and to have a callback function trigger when that event type occurs. " @@ -1728,19 +1728,19 @@ msgstr "" "來自元件指令的 bind 方法允許你監視某些事件,並在該事件類型發生時觸發一個回呼" "函式。bind 方法的形式是: ::" -#: ../../library/tkinter.rst:865 +#: ../../library/tkinter.rst:863 msgid "def bind(self, sequence, func, add=''):" msgstr "def bind(self, sequence, func, add=''):" -#: ../../library/tkinter.rst:867 +#: ../../library/tkinter.rst:865 msgid "where:" msgstr "其中:" -#: ../../library/tkinter.rst:869 +#: ../../library/tkinter.rst:867 msgid "sequence" msgstr "sequence" -#: ../../library/tkinter.rst:870 +#: ../../library/tkinter.rst:868 msgid "" "is a string that denotes the target kind of event. Physical events use the " "```` form (for example ``\"\"`` or " @@ -1753,11 +1753,11 @@ msgstr "" "式定義的虛擬事件使用雙角括號,如 ``\"<>\"``。(詳情請參" "閱 :manpage:`bind(3tk)` man page。)" -#: ../../library/tkinter.rst:876 +#: ../../library/tkinter.rst:874 msgid "func" msgstr "func" -#: ../../library/tkinter.rst:877 +#: ../../library/tkinter.rst:875 msgid "" "is a Python function, taking one argument, to be invoked when the event " "occurs. An Event instance will be passed as the argument. (Functions " @@ -1766,11 +1766,11 @@ msgstr "" "是一個 Python 函式,接受一個引數,在事件發生時被呼叫。一個 Event 實例將作為引" "數傳遞。(以這種方式部署的函式通常稱為\\ *回呼*。)" -#: ../../library/tkinter.rst:881 +#: ../../library/tkinter.rst:879 msgid "add" msgstr "add" -#: ../../library/tkinter.rst:882 +#: ../../library/tkinter.rst:880 msgid "" "is optional, either ``''`` or ``'+'``. Passing an empty string denotes that " "this binding is to replace any other bindings that this event is associated " @@ -1781,7 +1781,7 @@ msgstr "" "聯的任何其他繫結。傳遞一個 ``'+'`` 意味著此函式將被新增到繫結到此事件類型的函" "式串列中。" -#: ../../library/tkinter.rst:889 +#: ../../library/tkinter.rst:887 msgid "" "def turn_red(self, event):\n" " event.widget[\"activeforeground\"] = \"red\"\n" @@ -1793,7 +1793,7 @@ msgstr "" "\n" "self.button.bind(\"\", self.turn_red)" -#: ../../library/tkinter.rst:894 +#: ../../library/tkinter.rst:892 msgid "" "Notice how the widget field of the event is being accessed in the " "``turn_red()`` callback. This field contains the widget that caught the X " @@ -1805,171 +1805,171 @@ msgstr "" "件的元件。下表列出了你可以存取的其他事件欄位,以及它們在 Tk 中的表示方式,這" "在參閱 Tk man pages 時可能很有用。" -#: ../../library/tkinter.rst:900 +#: ../../library/tkinter.rst:898 msgid "Tkinter Event Field" msgstr "Tkinter 事件欄位" -#: ../../library/tkinter.rst:902 +#: ../../library/tkinter.rst:900 msgid "%f" msgstr "%f" -#: ../../library/tkinter.rst:902 +#: ../../library/tkinter.rst:900 msgid "focus" msgstr "focus" -#: ../../library/tkinter.rst:902 +#: ../../library/tkinter.rst:900 msgid "%A" msgstr "%A" -#: ../../library/tkinter.rst:902 +#: ../../library/tkinter.rst:900 msgid "char" msgstr "char" -#: ../../library/tkinter.rst:904 +#: ../../library/tkinter.rst:902 msgid "%h" msgstr "%h" -#: ../../library/tkinter.rst:904 +#: ../../library/tkinter.rst:902 msgid "height" msgstr "height" -#: ../../library/tkinter.rst:904 +#: ../../library/tkinter.rst:902 msgid "%E" msgstr "%E" -#: ../../library/tkinter.rst:904 +#: ../../library/tkinter.rst:902 msgid "send_event" msgstr "send_event" -#: ../../library/tkinter.rst:906 +#: ../../library/tkinter.rst:904 msgid "%k" msgstr "%k" -#: ../../library/tkinter.rst:906 +#: ../../library/tkinter.rst:904 msgid "keycode" msgstr "keycode" -#: ../../library/tkinter.rst:906 +#: ../../library/tkinter.rst:904 msgid "%K" msgstr "%K" -#: ../../library/tkinter.rst:906 +#: ../../library/tkinter.rst:904 msgid "keysym" msgstr "keysym" -#: ../../library/tkinter.rst:908 +#: ../../library/tkinter.rst:906 msgid "%s" msgstr "%s" -#: ../../library/tkinter.rst:908 +#: ../../library/tkinter.rst:906 msgid "state" msgstr "state" -#: ../../library/tkinter.rst:908 +#: ../../library/tkinter.rst:906 msgid "%N" msgstr "%N" -#: ../../library/tkinter.rst:908 +#: ../../library/tkinter.rst:906 msgid "keysym_num" msgstr "keysym_num" -#: ../../library/tkinter.rst:910 +#: ../../library/tkinter.rst:908 msgid "%t" msgstr "%t" -#: ../../library/tkinter.rst:910 +#: ../../library/tkinter.rst:908 msgid "time" msgstr "time" -#: ../../library/tkinter.rst:910 +#: ../../library/tkinter.rst:908 msgid "%T" msgstr "%T" -#: ../../library/tkinter.rst:910 +#: ../../library/tkinter.rst:908 msgid "type" msgstr "type" -#: ../../library/tkinter.rst:912 +#: ../../library/tkinter.rst:910 msgid "%w" msgstr "%w" -#: ../../library/tkinter.rst:912 +#: ../../library/tkinter.rst:910 msgid "width" msgstr "width" -#: ../../library/tkinter.rst:912 +#: ../../library/tkinter.rst:910 msgid "%W" msgstr "%W" -#: ../../library/tkinter.rst:912 +#: ../../library/tkinter.rst:910 msgid "widget" msgstr "widget" -#: ../../library/tkinter.rst:914 +#: ../../library/tkinter.rst:912 msgid "%x" msgstr "%x" -#: ../../library/tkinter.rst:914 +#: ../../library/tkinter.rst:912 msgid "x" msgstr "x" -#: ../../library/tkinter.rst:914 +#: ../../library/tkinter.rst:912 msgid "%X" msgstr "%X" -#: ../../library/tkinter.rst:914 +#: ../../library/tkinter.rst:912 msgid "x_root" msgstr "x_root" -#: ../../library/tkinter.rst:916 +#: ../../library/tkinter.rst:914 msgid "%y" msgstr "%y" -#: ../../library/tkinter.rst:916 +#: ../../library/tkinter.rst:914 msgid "y" msgstr "y" -#: ../../library/tkinter.rst:916 +#: ../../library/tkinter.rst:914 msgid "%Y" msgstr "%Y" -#: ../../library/tkinter.rst:916 +#: ../../library/tkinter.rst:914 msgid "y_root" msgstr "y_root" -#: ../../library/tkinter.rst:918 +#: ../../library/tkinter.rst:916 msgid "%#" msgstr "%#" -#: ../../library/tkinter.rst:918 +#: ../../library/tkinter.rst:916 msgid "serial" msgstr "" -#: ../../library/tkinter.rst:918 +#: ../../library/tkinter.rst:916 msgid "%b" msgstr "%b" -#: ../../library/tkinter.rst:918 +#: ../../library/tkinter.rst:916 msgid "num" msgstr "" -#: ../../library/tkinter.rst:920 +#: ../../library/tkinter.rst:918 msgid "%d" msgstr "%d" -#: ../../library/tkinter.rst:920 +#: ../../library/tkinter.rst:918 msgid "detail" msgstr "" -#: ../../library/tkinter.rst:920 +#: ../../library/tkinter.rst:918 msgid "%D" msgstr "%D" -#: ../../library/tkinter.rst:920 +#: ../../library/tkinter.rst:918 msgid "delta" msgstr "" -#: ../../library/tkinter.rst:923 +#: ../../library/tkinter.rst:921 msgid "" "The ``add`` parameter above only affects the bindings you make yourself. " "Every widget also inherits *class bindings* that implement its standard " @@ -1978,7 +1978,7 @@ msgid "" "widget's Tk man page (such as :manpage:`text(3tk)` or :manpage:`entry(3tk)`)." msgstr "" -#: ../../library/tkinter.rst:931 +#: ../../library/tkinter.rst:929 msgid "" "Class bindings are processed separately from your own, so binding an event " "yourself does not replace the default; both run. To suppress an unwanted " @@ -1986,11 +1986,11 @@ msgid "" "``\"break\"`` from your callback." msgstr "" -#: ../../library/tkinter.rst:939 +#: ../../library/tkinter.rst:937 msgid "The index parameter" msgstr "index 參數" -#: ../../library/tkinter.rst:941 +#: ../../library/tkinter.rst:939 msgid "" "A number of widgets require \"index\" parameters to be passed. These are " "used to point at a specific place in a Text widget, or to particular " @@ -1999,11 +1999,11 @@ msgstr "" "許多元件需要傳遞 \"index\" 參數。這些參數用於指向 Text 元件中的特定位置、" "Entry 元件中的特定字元,或 Menu 元件中的特定選單項目。" -#: ../../library/tkinter.rst:945 +#: ../../library/tkinter.rst:943 msgid "Entry widget indexes (index, view index, etc.)" msgstr "Entry 元件索引(index、view index 等)" -#: ../../library/tkinter.rst:946 +#: ../../library/tkinter.rst:944 msgid "" "Entry widgets have methods and options that refer to character positions in " "the text being displayed. Anytime an index is needed, you may pass in:" @@ -2011,39 +2011,39 @@ msgstr "" "Entry 元件具有參照其顯示文字中字元位置的方法和選項。每當需要索引時,你都可以" "傳入:" -#: ../../library/tkinter.rst:950 +#: ../../library/tkinter.rst:948 msgid "" "an integer which refers to the numeric position of a character, counted from " "the beginning of the text, starting with 0;" msgstr "一個整數,它參照字元從文字開頭起算的數字位置,從 0 開始計數;" -#: ../../library/tkinter.rst:953 +#: ../../library/tkinter.rst:951 msgid "" "the string ``\"anchor\"``, which refers to the anchor point of the " "selection, set with the widget's selection methods;" msgstr "" "字串 ``\"anchor\"``,它參照選取範圍的錨點,該錨點由元件的選取方法設定;" -#: ../../library/tkinter.rst:957 +#: ../../library/tkinter.rst:955 msgid "" "the string ``\"end\"``, which refers to the position just after the last " "character;" msgstr "字串 ``\"end\"``,它參照緊接在最後一個字元之後的位置;" -#: ../../library/tkinter.rst:960 +#: ../../library/tkinter.rst:958 msgid "" "the string ``\"insert\"``, which refers to the character just after the " "insertion cursor;" msgstr "字串 ``\"insert\"``,它參照緊接在插入游標之後的字元;" -#: ../../library/tkinter.rst:963 +#: ../../library/tkinter.rst:961 msgid "" "the strings ``\"sel.first\"`` and ``\"sel.last\"``, which refer to the first " "character in the selection and the position just after the last (it is an " "error to use these if there is no selection);" msgstr "" -#: ../../library/tkinter.rst:968 +#: ../../library/tkinter.rst:966 msgid "" "a string consisting of ``@`` followed by an integer, as in ``\"@6\"``, where " "the integer is interpreted as an x pixel coordinate in the entry's " @@ -2052,21 +2052,21 @@ msgstr "" "一個以 ``@`` 為前綴的整數所組成的字串,如 ``\"@6\"``,其中該整數被解釋為 " "Entry 元件座標系統中的 x 像素座標,用以選取該點所在範圍內的字元。" -#: ../../library/tkinter.rst:973 +#: ../../library/tkinter.rst:971 msgid "Text widget indexes" msgstr "Text 元件索引" -#: ../../library/tkinter.rst:974 +#: ../../library/tkinter.rst:972 msgid "" "The index notation for Text widgets is very rich and is best described in " "the Tk man pages." msgstr "Text 元件的索引表示法非常豐富,在 Tk man pages 中有最好的描述。" -#: ../../library/tkinter.rst:977 +#: ../../library/tkinter.rst:975 msgid "Menu indexes (menu.invoke(), menu.entryconfig(), etc.)" msgstr "選單索引(menu.invoke()、menu.entryconfig() 等)" -#: ../../library/tkinter.rst:978 +#: ../../library/tkinter.rst:976 msgid "" "Some options and methods for menus manipulate specific menu entries. Anytime " "a menu index is needed for an option or a parameter, you may pass in:" @@ -2074,23 +2074,23 @@ msgstr "" "選單的某些選項和方法會操作特定的選單項目。每當選項或參數需要選單索引時,你可" "以傳入:" -#: ../../library/tkinter.rst:981 +#: ../../library/tkinter.rst:979 msgid "" "an integer which refers to the numeric position of the entry in the widget, " "counted from the top, starting with 0;" msgstr "一個整數,它參照元件中項目的數字位置,從頂部開始計數,從 0 開始;" -#: ../../library/tkinter.rst:984 +#: ../../library/tkinter.rst:982 msgid "" "the string ``\"active\"``, which refers to the menu position that is " "currently under the cursor;" msgstr "字串 ``\"active\"``,它參照目前在游標下的選單位置;" -#: ../../library/tkinter.rst:987 +#: ../../library/tkinter.rst:985 msgid "the string ``\"last\"`` which refers to the last menu item;" msgstr "字串 ``\"last\"``,它參照最後一個選單項目;" -#: ../../library/tkinter.rst:989 +#: ../../library/tkinter.rst:987 msgid "" "a string consisting of ``@`` followed by an integer, as in ``\"@6\"``, where " "the integer is interpreted as a y pixel coordinate in the menu's coordinate " @@ -2099,7 +2099,7 @@ msgstr "" "一個由 ``@`` 後接整數所組成的字串,如 ``\"@6\"``,其中該整數被解釋為選單座標" "系統中的 y 像素座標;" -#: ../../library/tkinter.rst:993 +#: ../../library/tkinter.rst:991 msgid "" "the string ``\"none\"``, which indicates no menu entry at all, most often " "used with menu.activate() to deactivate all entries, and finally," @@ -2107,7 +2107,7 @@ msgstr "" "字串 ``\"none\"``,表示完全沒有選單項目,最常用於 menu.activate() 以停用所有" "項目,最後," -#: ../../library/tkinter.rst:996 +#: ../../library/tkinter.rst:994 msgid "" "a text string that is pattern matched against the label of the menu entry, " "as scanned from the top of the menu to the bottom. Note that this index " @@ -2119,21 +2119,21 @@ msgstr "" "此索引類型在所有其他類型之後考慮,這意味著標籤為 ``last``、``active`` 或 " "``none`` 的選單項目的匹配可能會被解釋為上述的字面值。" -#: ../../library/tkinter.rst:1004 +#: ../../library/tkinter.rst:1002 msgid "Images" msgstr "圖片" -#: ../../library/tkinter.rst:1006 +#: ../../library/tkinter.rst:1004 msgid "" "Images of different formats can be created through the corresponding " "subclass of :class:`tkinter.Image`:" msgstr "可以透過 :class:`tkinter.Image` 的相應子類別來建立不同格式的圖片:" -#: ../../library/tkinter.rst:1009 +#: ../../library/tkinter.rst:1007 msgid ":class:`BitmapImage` for images in XBM format." msgstr ":class:`BitmapImage` 用於 XBM 格式的圖片。" -#: ../../library/tkinter.rst:1011 +#: ../../library/tkinter.rst:1009 msgid "" ":class:`PhotoImage` for images in PGM, PPM, GIF and PNG formats. The latter " "is supported starting with Tk 8.6." @@ -2141,14 +2141,14 @@ msgstr "" ":class:`PhotoImage` 用於 PGM、PPM、GIF 和 PNG 格式的圖片。後者從 Tk 8.6 開始" "支援。" -#: ../../library/tkinter.rst:1014 +#: ../../library/tkinter.rst:1012 msgid "" "Either type of image is created through either the ``file`` or the ``data`` " "option (other options are available as well)." msgstr "" "任一類型的圖片都是透過 ``file`` 或 ``data`` 選項建立的(也有其他選項可用)。" -#: ../../library/tkinter.rst:1017 +#: ../../library/tkinter.rst:1015 msgid "" "Added the :class:`!PhotoImage` method :meth:`!copy_replace` to copy a region " "from one image to other image, possibly with pixel zooming and/or " @@ -2162,7 +2162,7 @@ msgstr "" "subsample`。將 *zoom* 和 *subsample* 參數新增到 :class:`!PhotoImage` 方法 :" "meth:`!copy`。" -#: ../../library/tkinter.rst:1026 +#: ../../library/tkinter.rst:1024 msgid "" "The image object can then be used wherever an ``image`` option is supported " "by some widget (for example, labels, buttons, menus). In these cases, Tk " @@ -2174,7 +2174,7 @@ msgstr "" "用。在這些情況下,Tk 將不會保留對圖片的參照。當對圖片物件的最後一個 Python 參" "照被刪除時,圖片資料也會被刪除,Tk 將在使用該圖片的任何地方顯示一個空框。" -#: ../../library/tkinter.rst:1034 +#: ../../library/tkinter.rst:1032 msgid "" "The `Pillow `_ package adds support for formats " "such as BMP, JPEG, TIFF, and WebP, among others." @@ -2182,11 +2182,11 @@ msgstr "" "`Pillow `_ 套件新增了對 BMP、JPEG、TIFF 和 WebP " "等格式的支援。" -#: ../../library/tkinter.rst:1039 +#: ../../library/tkinter.rst:1037 msgid "Reference" msgstr "參考" -#: ../../library/tkinter.rst:1043 +#: ../../library/tkinter.rst:1041 msgid "" "This section documents the classes, methods, functions and constants of the :" "mod:`!tkinter` module. Most of them wrap Tcl/Tk commands; consult the " @@ -2194,17 +2194,17 @@ msgid "" "details." msgstr "" -#: ../../library/tkinter.rst:1050 +#: ../../library/tkinter.rst:1048 msgid "" "The exception raised when a call into the Tcl interpreter fails, for example " "when a widget is given an unknown option or an invalid value." msgstr "" -#: ../../library/tkinter.rst:1054 +#: ../../library/tkinter.rst:1052 msgid "Base and mixin classes" msgstr "" -#: ../../library/tkinter.rst:1058 +#: ../../library/tkinter.rst:1056 msgid "" "The :class:`!Misc` class is a mix-in inherited by :class:`Tk` and, through :" "class:`BaseWidget`, by every widget. It provides the large set of methods " @@ -2216,14 +2216,14 @@ msgid "" "object, and are documented here once rather than repeated for each widget." msgstr "" -#: ../../library/tkinter.rst:1070 +#: ../../library/tkinter.rst:1068 msgid "" "Return the current value of the configuration option named *key* for this " "widget, as a string. The expression ``widget[key]`` is equivalent and may be " "used instead." msgstr "" -#: ../../library/tkinter.rst:1079 +#: ../../library/tkinter.rst:1077 msgid "" "Query or modify the configuration options of the widget. With no arguments, " "return a dictionary mapping every available option name to a tuple " @@ -2235,15 +2235,15 @@ msgid "" "same way." msgstr "" -#: ../../library/tkinter.rst:1089 +#: ../../library/tkinter.rst:1087 msgid ":meth:`config` is an alias of :meth:`!configure`." msgstr "" -#: ../../library/tkinter.rst:1093 +#: ../../library/tkinter.rst:1091 msgid "Return a list of the names of all configuration options of this widget." msgstr "" -#: ../../library/tkinter.rst:1097 +#: ../../library/tkinter.rst:1095 msgid "" "Interpret the string *s* as a Tcl boolean and return the corresponding :" "class:`bool`. Tcl accepts values such as ``'1'``, ``'0'``, ``'yes'``, " @@ -2251,27 +2251,27 @@ msgid "" "a valid boolean." msgstr "" -#: ../../library/tkinter.rst:1105 +#: ../../library/tkinter.rst:1103 msgid "" "Interpret the string *s* as a Tcl floating-point number and return it as a :" "class:`float`. Raise :exc:`ValueError` if *s* is not a valid number." msgstr "" -#: ../../library/tkinter.rst:1114 +#: ../../library/tkinter.rst:1112 msgid "" "Interpret the string *s* as a Tcl integer and return it as an :class:`int`. " "Raise :exc:`ValueError` if *s* is not a valid integer." msgstr "" -#: ../../library/tkinter.rst:1120 +#: ../../library/tkinter.rst:1118 msgid "Return the value of the Tcl global variable named *name*." msgstr "" -#: ../../library/tkinter.rst:1124 +#: ../../library/tkinter.rst:1122 msgid "Set the Tcl global variable named *name* to *value*." msgstr "" -#: ../../library/tkinter.rst:1126 +#: ../../library/tkinter.rst:1124 msgid "" "The :meth:`!getvar` and :meth:`!setvar` methods give direct access to Tcl " "variables. In most code you will instead use a :class:`Variable` subclass " @@ -2279,7 +2279,7 @@ msgid "" "and converts its value to and from a Python type." msgstr "" -#: ../../library/tkinter.rst:1134 +#: ../../library/tkinter.rst:1132 msgid "" "Register the Python callable *func* as a Tcl command and return the name of " "the new command as a string. Whenever Tcl invokes that command, *func* is " @@ -2289,73 +2289,73 @@ msgid "" "is false, the command is deleted automatically when the widget is destroyed." msgstr "" -#: ../../library/tkinter.rst:1143 +#: ../../library/tkinter.rst:1141 msgid "The arguments passed to *func* are no longer converted to strings." msgstr "" -#: ../../library/tkinter.rst:1148 +#: ../../library/tkinter.rst:1146 msgid "" "Delete the Tcl command named *name*, such as one previously returned by :" "meth:`register`." msgstr "" -#: ../../library/tkinter.rst:1153 +#: ../../library/tkinter.rst:1151 msgid "Return the widget instance corresponding to the Tk pathname *name*." msgstr "" -#: ../../library/tkinter.rst:1157 +#: ../../library/tkinter.rst:1155 msgid "" "Send the Tcl command *cmd*, with the given *args*, to the Tcl interpreter " "registered under the name *interp*, and return its result. This is not " "available on all platforms." msgstr "" -#: ../../library/tkinter.rst:1163 +#: ../../library/tkinter.rst:1161 msgid "" "Destroy this widget and all of its descendant widgets, and delete the Tcl " "commands associated with them." msgstr "" -#: ../../library/tkinter.rst:1171 +#: ../../library/tkinter.rst:1169 msgid "" "Raise this widget in the stacking order so that it is drawn on top of its " "siblings. If *aboveThis* is given, the widget is moved to be just above it " "in the stacking order instead." msgstr "" -#: ../../library/tkinter.rst:1176 +#: ../../library/tkinter.rst:1174 msgid ":meth:`lift` is an alias of :meth:`!tkraise`." msgstr "" -#: ../../library/tkinter.rst:1180 +#: ../../library/tkinter.rst:1178 msgid "" "Lower this widget in the stacking order so that it is drawn beneath its " "siblings. If *belowThis* is given, the widget is moved to be just below it " "in the stacking order instead." msgstr "" -#: ../../library/tkinter.rst:1185 +#: ../../library/tkinter.rst:1183 msgid "" ":meth:`tkraise`/:meth:`lift` and :meth:`lower` are overridden by the :class:" "`Canvas` widget, where they restack canvas items instead." msgstr "" -#: ../../library/tkinter.rst:1191 +#: ../../library/tkinter.rst:1189 msgid "" "Return the names of all images that currently exist in the Tcl interpreter." msgstr "" -#: ../../library/tkinter.rst:1194 +#: ../../library/tkinter.rst:1192 msgid "" "This is overridden by the :class:`Text` widget, where :meth:`!image_names` " "returns the names of its embedded images instead." msgstr "" -#: ../../library/tkinter.rst:1200 +#: ../../library/tkinter.rst:1198 msgid "Return the available image types, such as ``'photo'`` and ``'bitmap'``." msgstr "" -#: ../../library/tkinter.rst:1207 +#: ../../library/tkinter.rst:1205 msgid "" "Set the anchor that controls where the grid is placed inside this container " "when the container is larger than the grid and no row or column has a non-" @@ -2364,11 +2364,11 @@ msgid "" "effect." msgstr "" -#: ../../library/tkinter.rst:1214 +#: ../../library/tkinter.rst:1212 msgid ":meth:`anchor` is an alias of :meth:`!grid_anchor`." msgstr "" -#: ../../library/tkinter.rst:1223 +#: ../../library/tkinter.rst:1221 msgid "" "Return the bounding box, in pixels, of a region of the grid laid out in this " "container, as a 4-tuple ``(xoffset, yoffset, width, height)``. With no " @@ -2378,7 +2378,7 @@ msgid "" "*row*) to the cell (*col2*, *row2*)." msgstr "" -#: ../../library/tkinter.rst:1230 +#: ../../library/tkinter.rst:1228 msgid "" ":meth:`bbox` is an alias of :meth:`!grid_bbox`, except on :class:`Canvas`, :" "class:`Listbox`, :class:`Spinbox`, :class:`Text`, :class:`ttk.Entry '`` (a mouse click) or " "``''``, optionally a concatenation of several such patterns that " @@ -2536,28 +2564,28 @@ msgid "" "are invoked." msgstr "" -#: ../../library/tkinter.rst:1362 +#: ../../library/tkinter.rst:1391 msgid "" "If *add* is true, *func* is added to any functions already bound to " "*sequence*; otherwise it replaces them. The binding applies only to this " "widget." msgstr "" -#: ../../library/tkinter.rst:1366 +#: ../../library/tkinter.rst:1395 msgid "" ":meth:`!bind` returns a string identifier (a *funcid*) that can later be " "passed to :meth:`unbind` to remove the binding without leaking the " "associated Tcl command." msgstr "" -#: ../../library/tkinter.rst:1370 +#: ../../library/tkinter.rst:1399 msgid "" "If *func* is omitted, return the binding currently associated with " "*sequence*; if *sequence* is also omitted, return a list of all the " "sequences for which bindings exist on this widget." msgstr "" -#: ../../library/tkinter.rst:1376 +#: ../../library/tkinter.rst:1405 msgid "" "Like :meth:`bind`, but bind *func* to the binding tag *className* rather " "than to a single widget, so that the binding applies to every widget having " @@ -2567,21 +2595,21 @@ msgid "" "`bindtags`." msgstr "" -#: ../../library/tkinter.rst:1384 ../../library/tkinter.rst:1391 +#: ../../library/tkinter.rst:1413 ../../library/tkinter.rst:1420 msgid "The remaining arguments and the return value are as for :meth:`bind`." msgstr "" -#: ../../library/tkinter.rst:1388 +#: ../../library/tkinter.rst:1417 msgid "" "Like :meth:`bind`, but bind *func* to the special binding tag ``'all'``, so " "that the binding applies to every widget in the application." msgstr "" -#: ../../library/tkinter.rst:1395 +#: ../../library/tkinter.rst:1424 msgid "Remove bindings for the event pattern *sequence* on this widget." msgstr "" -#: ../../library/tkinter.rst:1397 +#: ../../library/tkinter.rst:1426 msgid "" "If *funcid* is given, only the function identified by it (a value returned " "from a previous call to :meth:`bind`) is removed, and its associated Tcl " @@ -2589,25 +2617,25 @@ msgid "" "leaving it unbound." msgstr "" -#: ../../library/tkinter.rst:1402 +#: ../../library/tkinter.rst:1431 msgid "" "If *funcid* is given, only that callback is unbound; other callbacks bound " "to *sequence* are kept." msgstr "" -#: ../../library/tkinter.rst:1409 +#: ../../library/tkinter.rst:1438 msgid "" "Remove all bindings for the event pattern *sequence* from the binding tag " "*className*. See :meth:`bind_class`." msgstr "" -#: ../../library/tkinter.rst:1415 +#: ../../library/tkinter.rst:1444 msgid "" "Remove all bindings for the event pattern *sequence* from the special " "binding tag ``'all'``. See :meth:`bind_all`." msgstr "" -#: ../../library/tkinter.rst:1421 +#: ../../library/tkinter.rst:1450 msgid "" "If *tagList* is omitted, return a tuple of the binding tags associated with " "this widget. When an event occurs in a widget, it is applied to each of the " @@ -2617,20 +2645,20 @@ msgid "" "and ``'all'``, in that order." msgstr "" -#: ../../library/tkinter.rst:1430 +#: ../../library/tkinter.rst:1459 msgid "" "If *tagList* is given, it must be a sequence of strings; the widget's " "binding tags are set to its elements, which determines the order in which " "bindings are evaluated." msgstr "" -#: ../../library/tkinter.rst:1434 +#: ../../library/tkinter.rst:1463 msgid "" "The methods with the ``event_`` prefix define virtual events and generate " "events programmatically." msgstr "" -#: ../../library/tkinter.rst:1439 +#: ../../library/tkinter.rst:1468 msgid "" "Associate the virtual event *virtual*, whose name has the form " "``'<>'``, with each of the physical event patterns given by " @@ -2639,7 +2667,7 @@ msgid "" "ones." msgstr "" -#: ../../library/tkinter.rst:1448 +#: ../../library/tkinter.rst:1477 msgid "" "Remove each of *sequences* from those associated with the virtual event " "*virtual*. Sequences that are not currently associated with *virtual* are " @@ -2647,7 +2675,7 @@ msgid "" "removed, so that *virtual* no longer triggers." msgstr "" -#: ../../library/tkinter.rst:1456 +#: ../../library/tkinter.rst:1485 msgid "" "Generate the event *sequence* on this widget and arrange for it to be " "processed just as if it had come from the window system. *sequence* must be " @@ -2658,7 +2686,7 @@ msgid "" "for the full list." msgstr "" -#: ../../library/tkinter.rst:1466 +#: ../../library/tkinter.rst:1495 msgid "" "If *virtual* is omitted, return a tuple of all the virtual events that are " "currently defined. If *virtual* is given, return a tuple of the physical " @@ -2666,34 +2694,34 @@ msgid "" "defined." msgstr "" -#: ../../library/tkinter.rst:1471 +#: ../../library/tkinter.rst:1500 msgid "" "The methods with the ``after`` prefix schedule callbacks to run after a " "delay or when the application is idle." msgstr "" -#: ../../library/tkinter.rst:1476 +#: ../../library/tkinter.rst:1505 msgid "" "Schedule the callable *func* to be called after *ms* milliseconds, with " "*args* and *kw* passed to it as positional and keyword arguments. Return an " "identifier that can be passed to :meth:`after_cancel` to cancel the call." msgstr "" -#: ../../library/tkinter.rst:1481 +#: ../../library/tkinter.rst:1510 msgid "" "If *func* is omitted, sleep for *ms* milliseconds instead, processing no " "events during that time, and return ``None``." msgstr "" -#: ../../library/tkinter.rst:1484 +#: ../../library/tkinter.rst:1513 msgid "*func* can now be any callable object, not only a function." msgstr "" -#: ../../library/tkinter.rst:1487 ../../library/tkinter.rst:1512 +#: ../../library/tkinter.rst:1516 ../../library/tkinter.rst:1541 msgid "Keyword arguments are now passed to *func*." msgstr "" -#: ../../library/tkinter.rst:1493 +#: ../../library/tkinter.rst:1522 msgid "" "Cancel a callback previously scheduled with :meth:`after` or :meth:" "`after_idle`. *id* must be an identifier returned by one of those methods; " @@ -2701,12 +2729,12 @@ msgid "" "the callback has already run or been cancelled, this has no effect." msgstr "" -#: ../../library/tkinter.rst:1499 +#: ../../library/tkinter.rst:1528 msgid "" "Passing ``None`` (or any false value) as *id* now raises :exc:`ValueError`." msgstr "" -#: ../../library/tkinter.rst:1506 +#: ../../library/tkinter.rst:1535 msgid "" "Schedule the callable *func* to be called, with *args* and *kw* passed to " "it, when the Tk main loop next becomes idle, that is, when it has no other " @@ -2714,14 +2742,14 @@ msgid "" "`after_cancel` to cancel the call." msgstr "" -#: ../../library/tkinter.rst:1518 +#: ../../library/tkinter.rst:1547 msgid "" "If *id* is omitted, return a tuple of the identifiers of all callbacks " "currently scheduled with :meth:`after` and :meth:`after_idle` for this " "interpreter." msgstr "" -#: ../../library/tkinter.rst:1522 +#: ../../library/tkinter.rst:1551 msgid "" "If *id* is given, it must identify a callback that has not yet run or been " "cancelled, and the return value is a tuple ``(script, type)``, where " @@ -2729,32 +2757,32 @@ msgid "" "or ``'timer'``. A :exc:`TclError` is raised if *id* does not exist." msgstr "" -#: ../../library/tkinter.rst:1533 +#: ../../library/tkinter.rst:1562 msgid "" "Enter the Tk event loop, which processes events until all windows are " "destroyed. This is normally called once, on the root window, to run the " "application." msgstr "" -#: ../../library/tkinter.rst:1539 +#: ../../library/tkinter.rst:1568 msgid "Quit the Tcl interpreter, causing :meth:`mainloop` to return." msgstr "" -#: ../../library/tkinter.rst:1543 +#: ../../library/tkinter.rst:1572 msgid "" "Enter the event loop until all pending events, including idle callbacks, " "have been processed. This brings the display up to date and handles any " "events that are already queued, then returns." msgstr "" -#: ../../library/tkinter.rst:1550 +#: ../../library/tkinter.rst:1579 msgid "" "Enter the event loop until all pending idle callbacks have been called. This " "updates the display of windows, for example after geometry changes, but does " "not process events caused by the user." msgstr "" -#: ../../library/tkinter.rst:1559 +#: ../../library/tkinter.rst:1588 msgid "" "Wait until the Tcl variable *name* is modified, continuing to process events " "in the meantime so that the application stays responsive. *name* is usually " @@ -2762,18 +2790,18 @@ msgid "" "`StringVar`." msgstr "" -#: ../../library/tkinter.rst:1564 +#: ../../library/tkinter.rst:1593 msgid ":meth:`waitvar` is an alias of :meth:`!wait_variable`." msgstr "" -#: ../../library/tkinter.rst:1568 +#: ../../library/tkinter.rst:1597 msgid "" "Wait until *window* is destroyed, continuing to process events in the " "meantime. If *window* is omitted, this widget is used. This is typically " "used to wait for the user to finish interacting with a dialog box." msgstr "" -#: ../../library/tkinter.rst:1576 +#: ../../library/tkinter.rst:1605 msgid "" "Wait until the visibility state of *window* changes, for example when it " "first appears on the screen, continuing to process events in the meantime. " @@ -2781,11 +2809,11 @@ msgid "" "for a newly created window to become visible before acting on it." msgstr "" -#: ../../library/tkinter.rst:1583 +#: ../../library/tkinter.rst:1612 msgid "The methods with the ``focus_`` prefix manage the keyboard focus." msgstr "" -#: ../../library/tkinter.rst:1590 +#: ../../library/tkinter.rst:1619 msgid "" "Direct the keyboard input focus for this widget's display to this widget. If " "the application does not currently have the input focus on this widget's " @@ -2796,7 +2824,7 @@ msgid "" "Treeview>` widgets, which provide their own :meth:`!focus` method." msgstr "" -#: ../../library/tkinter.rst:1602 +#: ../../library/tkinter.rst:1631 msgid "" "Direct the keyboard input focus to this widget even if the application does " "not currently have the input focus for the widget's display. This method " @@ -2804,21 +2832,21 @@ msgid "" "the window manager to give it the focus rather than claiming it." msgstr "" -#: ../../library/tkinter.rst:1610 +#: ../../library/tkinter.rst:1639 msgid "" "Return the widget that currently has the keyboard focus in the application, " "or ``None`` if no widget in the application has the focus. Use :meth:" "`focus_displayof` to work correctly with several displays." msgstr "" -#: ../../library/tkinter.rst:1616 +#: ../../library/tkinter.rst:1645 msgid "" "Return the widget that currently has the keyboard focus on the display where " "this widget is located, or ``None`` if no widget in the application has the " "focus on that display." msgstr "" -#: ../../library/tkinter.rst:1622 +#: ../../library/tkinter.rst:1651 msgid "" "Return the most recent widget to have had the keyboard focus among all the " "widgets in the same top level as this widget; this is the widget that will " @@ -2827,14 +2855,14 @@ msgid "" "most recent focus widget has been deleted, the top level itself is returned." msgstr "" -#: ../../library/tkinter.rst:1631 +#: ../../library/tkinter.rst:1660 msgid "" "Reconfigure Tk to use an implicit focus model in which the focus is set to a " "widget whenever the mouse pointer enters it. This cannot easily be disabled " "once enabled." msgstr "" -#: ../../library/tkinter.rst:1637 +#: ../../library/tkinter.rst:1666 msgid "" "Return the next widget after this one in the keyboard traversal order, or " "``None`` if there is none. The traversal order goes first to the next child, " @@ -2844,7 +2872,7 @@ msgid "" "kbd:`Tab` key." msgstr "" -#: ../../library/tkinter.rst:1647 +#: ../../library/tkinter.rst:1676 msgid "" "Return the previous widget before this one in the keyboard traversal order, " "or ``None`` if there is none. See :meth:`tk_focusNext` for how the order is " @@ -2852,13 +2880,13 @@ msgid "" "Tab` key." msgstr "" -#: ../../library/tkinter.rst:1652 +#: ../../library/tkinter.rst:1681 msgid "" "The methods with the ``grab_`` prefix set and query the input grab, which " "directs all input events to a single widget." msgstr "" -#: ../../library/tkinter.rst:1657 +#: ../../library/tkinter.rst:1686 msgid "" "Set a local grab on this widget. A grab confines pointer events to this " "widget and its descendants: while the pointer is outside the widget's " @@ -2871,7 +2899,7 @@ msgid "" "windows of the application." msgstr "" -#: ../../library/tkinter.rst:1671 +#: ../../library/tkinter.rst:1700 msgid "" "Set a global grab on this widget. A global grab is like the local grab set " "by :meth:`grab_set`, but it locks out all other applications on the screen, " @@ -2881,29 +2909,29 @@ msgid "" "until it is released." msgstr "" -#: ../../library/tkinter.rst:1682 +#: ../../library/tkinter.rst:1711 msgid "Release the grab on this widget if there is one; otherwise do nothing." msgstr "" -#: ../../library/tkinter.rst:1686 +#: ../../library/tkinter.rst:1715 msgid "" "Return the widget that currently holds the grab in this application for this " "widget's display, or ``None`` if there is no such widget." msgstr "" -#: ../../library/tkinter.rst:1691 +#: ../../library/tkinter.rst:1720 msgid "" "Return ``None`` if no grab is currently set on this widget, ``\"local\"`` if " "a local grab is set, or ``\"global\"`` if a global grab is set." msgstr "" -#: ../../library/tkinter.rst:1694 +#: ../../library/tkinter.rst:1723 msgid "" "The methods with the ``selection_`` prefix retrieve and manage the X " "selection." msgstr "" -#: ../../library/tkinter.rst:1699 +#: ../../library/tkinter.rst:1728 msgid "" "Clear the X selection, so that no window owns it anymore. The selection to " "clear is given by the keyword argument *selection*, an atom name such as " @@ -2912,14 +2940,14 @@ msgid "" "which to operate, and defaults to this widget." msgstr "" -#: ../../library/tkinter.rst:1706 +#: ../../library/tkinter.rst:1735 msgid "" "This is overridden by the :class:`Entry`, :class:`Listbox` and :class:" "`Spinbox` widgets, where :meth:`!selection_clear` clears the widget's own " "selection instead." msgstr "" -#: ../../library/tkinter.rst:1712 +#: ../../library/tkinter.rst:1741 msgid "" "Return the contents of the current X selection. The keyword argument " "*selection* names the selection and defaults to ``PRIMARY``. The keyword " @@ -2931,7 +2959,7 @@ msgid "" "which to retrieve the selection, and defaults to this widget." msgstr "" -#: ../../library/tkinter.rst:1726 +#: ../../library/tkinter.rst:1755 msgid "" "Register *command* as a handler to supply the X selection owned by this " "widget when another application requests it. When the selection is " @@ -2944,14 +2972,14 @@ msgid "" "supplies (such as ``'STRING'`` or ``'FILE_NAME'``, default ``STRING``)." msgstr "" -#: ../../library/tkinter.rst:1740 +#: ../../library/tkinter.rst:1769 msgid "" "Make this widget the owner of the X selection on its display. The previous " "owner, if any, is notified that it has lost the selection. The keyword " "argument *selection* names the selection and defaults to ``PRIMARY``." msgstr "" -#: ../../library/tkinter.rst:1747 +#: ../../library/tkinter.rst:1776 msgid "" "Return the widget in this application that owns the X selection on the " "display containing this widget, or ``None`` if no widget in this application " @@ -2960,11 +2988,11 @@ msgid "" "that determines the display to query, and defaults to this widget." msgstr "" -#: ../../library/tkinter.rst:1755 +#: ../../library/tkinter.rst:1784 msgid "The methods with the ``clipboard_`` prefix manage the clipboard." msgstr "" -#: ../../library/tkinter.rst:1759 +#: ../../library/tkinter.rst:1788 msgid "" "Append *string* to the Tk clipboard and claim ownership of the clipboard on " "this widget's display. Before appending, the clipboard should be emptied " @@ -2978,14 +3006,14 @@ msgid "" "retrieved with :meth:`clipboard_get` or :meth:`selection_get`." msgstr "" -#: ../../library/tkinter.rst:1775 +#: ../../library/tkinter.rst:1804 msgid "" "Claim ownership of the clipboard on this widget's display and remove any " "previous contents. The *displayof* keyword argument names a widget that " "determines the target display, and defaults to this widget." msgstr "" -#: ../../library/tkinter.rst:1782 +#: ../../library/tkinter.rst:1811 msgid "" "Retrieve data from the clipboard on this widget's display. The keyword " "argument *type* specifies the form in which the data is to be returned, an " @@ -2996,13 +3024,13 @@ msgid "" "application. This is equivalent to ``selection_get(selection='CLIPBOARD')``." msgstr "" -#: ../../library/tkinter.rst:1791 +#: ../../library/tkinter.rst:1820 msgid "" "The methods with the ``option_`` prefix query and modify the Tk option " "database." msgstr "" -#: ../../library/tkinter.rst:1796 +#: ../../library/tkinter.rst:1825 msgid "" "Add an option to the Tk option database that associates *value* with " "*pattern*. *pattern* consists of names and/or classes separated by asterisks " @@ -3012,7 +3040,7 @@ msgid "" "``interactive``." msgstr "" -#: ../../library/tkinter.rst:1806 +#: ../../library/tkinter.rst:1835 msgid "" "Clear the Tk option database. Default options from the :envvar:`!" "RESOURCE_MANAGER` property or the :file:`.Xdefaults` file are reloaded " @@ -3020,7 +3048,7 @@ msgid "" "database." msgstr "" -#: ../../library/tkinter.rst:1813 +#: ../../library/tkinter.rst:1842 msgid "" "Return the value of the option matching this widget under *name* and " "*className* from the Tk option database, or an empty string if there is no " @@ -3029,7 +3057,7 @@ msgid "" "added one." msgstr "" -#: ../../library/tkinter.rst:1822 +#: ../../library/tkinter.rst:1851 msgid "" "Read the file named *fileName*, which should have the standard format for an " "X resource database such as :file:`.Xdefaults`, and add all the options it " @@ -3037,7 +3065,7 @@ msgid "" "`option_add` and defaults to ``interactive``." msgstr "" -#: ../../library/tkinter.rst:1830 +#: ../../library/tkinter.rst:1859 msgid "" "Ring the bell on the display for this widget, using the display's current " "bell-related settings, and reset the screen saver for the screen. If " @@ -3045,7 +3073,7 @@ msgid "" "instead." msgstr "" -#: ../../library/tkinter.rst:1838 +#: ../../library/tkinter.rst:1867 msgid "" "Set a new color scheme for all Tk widget elements. Existing widgets are " "updated and the option database is changed so that future widgets use the " @@ -3060,26 +3088,26 @@ msgid "" "for any that are not specified." msgstr "" -#: ../../library/tkinter.rst:1854 +#: ../../library/tkinter.rst:1883 msgid "" "Restore the application's colors to the light brown (bisque) color scheme " "used in Tk 3.6 and earlier versions. Provided for backward compatibility." msgstr "" -#: ../../library/tkinter.rst:1860 +#: ../../library/tkinter.rst:1889 msgid "" "Query or set whether Tk's look and feel should strictly adhere to Motif. A " "true *boolean* value enables strict Motif compliance (for example, no color " "change when the mouse passes over a slider). Return the resulting setting." msgstr "" -#: ../../library/tkinter.rst:1865 +#: ../../library/tkinter.rst:1894 msgid "" "The methods with the ``busy_`` prefix manage the busy state of a window, " "which shows a busy cursor and ignores user input." msgstr "" -#: ../../library/tkinter.rst:1879 +#: ../../library/tkinter.rst:1908 msgid "" "Make this widget appear busy. A transparent window is placed in front of the " "widget, so that it and all of its descendants in the widget hierarchy are " @@ -3088,20 +3116,20 @@ msgid "" "operation is in effect before the application starts its processing." msgstr "" -#: ../../library/tkinter.rst:1887 +#: ../../library/tkinter.rst:1916 msgid "" "The only supported configuration option is *cursor*, the cursor to be " "displayed while the widget is busy; it may have any of the values accepted " "by :meth:`!configure`." msgstr "" -#: ../../library/tkinter.rst:1891 +#: ../../library/tkinter.rst:1920 msgid "" ":meth:`busy_hold`, :meth:`busy` and :meth:`tk_busy` are aliases of :meth:`!" "tk_busy_hold`." msgstr "" -#: ../../library/tkinter.rst:1908 +#: ../../library/tkinter.rst:1937 msgid "" "Query or modify the configuration options of the busy window. The widget " "must have been previously made busy by :meth:`tk_busy_hold`. With no " @@ -3111,14 +3139,14 @@ msgid "" "the values accepted by :meth:`tk_busy_hold`." msgstr "" -#: ../../library/tkinter.rst:1916 +#: ../../library/tkinter.rst:1945 msgid "" "The option database is referenced through the widget name or class. For " "example, if a :class:`Frame` widget named ``frame`` is to be made busy, the " "busy cursor can be specified for it by either of the calls::" msgstr "" -#: ../../library/tkinter.rst:1920 +#: ../../library/tkinter.rst:1949 msgid "" "w.option_add('*frame.busyCursor', 'gumby')\n" "w.option_add('*Frame.BusyCursor', 'gumby')" @@ -3126,24 +3154,24 @@ msgstr "" "w.option_add('*frame.busyCursor', 'gumby')\n" "w.option_add('*Frame.BusyCursor', 'gumby')" -#: ../../library/tkinter.rst:1923 +#: ../../library/tkinter.rst:1952 msgid "" ":meth:`busy_configure`, :meth:`busy_config` and :meth:`tk_busy_config` are " "aliases of :meth:`!tk_busy_configure`." msgstr "" -#: ../../library/tkinter.rst:1934 +#: ../../library/tkinter.rst:1963 msgid "" "Return the current value of the busy configuration *option*. The widget must " "have been previously made busy by :meth:`tk_busy_hold`, and *option* may " "have any of the values accepted by that method." msgstr "" -#: ../../library/tkinter.rst:1938 +#: ../../library/tkinter.rst:1967 msgid ":meth:`busy_cget` is an alias of :meth:`!tk_busy_cget`." msgstr "" -#: ../../library/tkinter.rst:1948 +#: ../../library/tkinter.rst:1977 msgid "" "Make this widget no longer busy, releasing the resources (including the " "transparent window) allocated when it was made busy. User events will again " @@ -3151,35 +3179,35 @@ msgid "" "is destroyed." msgstr "" -#: ../../library/tkinter.rst:1953 +#: ../../library/tkinter.rst:1982 msgid ":meth:`busy_forget` is an alias of :meth:`!tk_busy_forget`." msgstr "" -#: ../../library/tkinter.rst:1963 +#: ../../library/tkinter.rst:1992 msgid "Return ``True`` if the widget is currently busy, ``False`` otherwise." msgstr "" -#: ../../library/tkinter.rst:1965 +#: ../../library/tkinter.rst:1994 msgid ":meth:`busy_status` is an alias of :meth:`!tk_busy_status`." msgstr "" -#: ../../library/tkinter.rst:1975 +#: ../../library/tkinter.rst:2004 msgid "" "Return a list of widgets that are currently busy. If *pattern* is given, " "only busy widgets whose path names match the pattern are returned." msgstr "" -#: ../../library/tkinter.rst:1979 +#: ../../library/tkinter.rst:2008 msgid ":meth:`busy_current` is an alias of :meth:`!tk_busy_current`." msgstr "" -#: ../../library/tkinter.rst:1983 +#: ../../library/tkinter.rst:2012 msgid "" "The methods with the ``winfo_`` prefix retrieve information about windows " "managed by Tk." msgstr "" -#: ../../library/tkinter.rst:1988 +#: ../../library/tkinter.rst:2017 msgid "" "Return the integer identifier for the atom whose name is *name*, creating a " "new atom if none exists. If *displayof* is given, the atom is looked up on " @@ -3187,7 +3215,7 @@ msgid "" "application's main window." msgstr "" -#: ../../library/tkinter.rst:1996 +#: ../../library/tkinter.rst:2025 msgid "" "Return the textual name for the atom whose integer identifier is *id*. This " "is the inverse of :meth:`winfo_atom`. If *displayof* is given, the " @@ -3195,28 +3223,28 @@ msgid "" "looked up on the display of the application's main window." msgstr "" -#: ../../library/tkinter.rst:2004 +#: ../../library/tkinter.rst:2033 msgid "Return the number of cells in the colormap for the widget." msgstr "" -#: ../../library/tkinter.rst:2008 +#: ../../library/tkinter.rst:2037 msgid "" "Return a list containing the widgets that are children of the widget, in " "stacking order from lowest to highest. Toplevel windows are returned as " "children of their logical parents." msgstr "" -#: ../../library/tkinter.rst:2014 +#: ../../library/tkinter.rst:2043 msgid "Return the class name of the widget." msgstr "" -#: ../../library/tkinter.rst:2018 +#: ../../library/tkinter.rst:2047 msgid "" "Return ``True`` if the colormap for the widget is known to be full, " "``False`` otherwise." msgstr "" -#: ../../library/tkinter.rst:2023 +#: ../../library/tkinter.rst:2052 msgid "" "Return the widget containing the point given by *rootX* and *rootY*, or " "``None`` if no window in this application contains the point. The " @@ -3225,15 +3253,15 @@ msgid "" "window; otherwise they refer to the screen of the application's main window." msgstr "" -#: ../../library/tkinter.rst:2033 +#: ../../library/tkinter.rst:2062 msgid "Return the depth of the widget, that is, the number of bits per pixel." msgstr "" -#: ../../library/tkinter.rst:2037 +#: ../../library/tkinter.rst:2066 msgid "Return true if the widget exists, false otherwise." msgstr "" -#: ../../library/tkinter.rst:2041 +#: ../../library/tkinter.rst:2070 msgid "" "Return a floating-point value giving the number of pixels in the widget " "corresponding to the screen distance *number* (for example, ``\"2.0c\"`` or " @@ -3241,27 +3269,27 @@ msgid "" "meth:`winfo_pixels`." msgstr "" -#: ../../library/tkinter.rst:2049 +#: ../../library/tkinter.rst:2078 msgid "" "Return the geometry of the widget, in the form ``widthxheight+x+y``. All " "dimensions are in pixels. An offset can be negative; see :meth:`~Wm." "geometry`." msgstr "" -#: ../../library/tkinter.rst:2055 +#: ../../library/tkinter.rst:2084 msgid "" "Return the height of the widget in pixels. When a window is first created " "its height is 1 pixel; it is eventually changed by a geometry manager. See " "also :meth:`winfo_reqheight`." msgstr "" -#: ../../library/tkinter.rst:2062 +#: ../../library/tkinter.rst:2091 msgid "" "Return a low-level platform-specific identifier for the widget. On Unix this " "is the X window identifier, and on Windows it is the window handle." msgstr "" -#: ../../library/tkinter.rst:2068 +#: ../../library/tkinter.rst:2097 msgid "" "Return a tuple of the names of all Tcl interpreters currently registered for " "a particular display. If *displayof* is given, the return value refers to " @@ -3269,35 +3297,35 @@ msgid "" "application's main window." msgstr "" -#: ../../library/tkinter.rst:2076 +#: ../../library/tkinter.rst:2105 msgid "Return true if the widget is currently mapped, false otherwise." msgstr "" -#: ../../library/tkinter.rst:2080 +#: ../../library/tkinter.rst:2109 msgid "" "Return the name of the geometry manager currently responsible for the " "widget, or an empty string if it is not managed by any geometry manager." msgstr "" -#: ../../library/tkinter.rst:2085 +#: ../../library/tkinter.rst:2114 msgid "" "Return the widget's name within its parent, as opposed to its full path name." msgstr "" -#: ../../library/tkinter.rst:2090 +#: ../../library/tkinter.rst:2119 msgid "" "Return the path name of the widget's parent, or an empty string if the " "widget is the main window of the application." msgstr "" -#: ../../library/tkinter.rst:2095 +#: ../../library/tkinter.rst:2124 msgid "" "Return the path name of the window whose identifier is *id*. If *displayof* " "is given, the identifier is looked up on the display of that window; " "otherwise it is looked up on the display of the application's main window." msgstr "" -#: ../../library/tkinter.rst:2102 +#: ../../library/tkinter.rst:2131 msgid "" "Return the number of pixels in the widget corresponding to the screen " "distance *number* (for example, ``\"2.0c\"`` or ``\"1i\"``). The result is " @@ -3305,14 +3333,14 @@ msgid "" "`winfo_fpixels`." msgstr "" -#: ../../library/tkinter.rst:2109 +#: ../../library/tkinter.rst:2138 msgid "" "Return the pointer's *x* coordinate, in pixels, relative to the screen's " "root window (or virtual root, if one is in use). Return ``-1`` if the " "pointer is not on the same screen as the widget." msgstr "" -#: ../../library/tkinter.rst:2115 +#: ../../library/tkinter.rst:2144 msgid "" "Return the pointer's coordinates as an ``(x, y)`` tuple, in pixels, relative " "to the screen's root window (or virtual root, if one is in use). Both " @@ -3320,116 +3348,116 @@ msgid "" "widget." msgstr "" -#: ../../library/tkinter.rst:2122 +#: ../../library/tkinter.rst:2151 msgid "" "Return the pointer's *y* coordinate, in pixels, relative to the screen's " "root window (or virtual root, if one is in use). Return ``-1`` if the " "pointer is not on the same screen as the widget." msgstr "" -#: ../../library/tkinter.rst:2128 +#: ../../library/tkinter.rst:2157 msgid "" "Return the widget's requested height in pixels. This is the value used by " "the widget's geometry manager to compute its geometry." msgstr "" -#: ../../library/tkinter.rst:2134 +#: ../../library/tkinter.rst:2163 msgid "" "Return the widget's requested width in pixels. This is the value used by the " "widget's geometry manager to compute its geometry." msgstr "" -#: ../../library/tkinter.rst:2140 +#: ../../library/tkinter.rst:2169 msgid "" "Return an ``(r, g, b)`` tuple of the red, green, and blue intensities, in " "the range 0 to 65535, that correspond to *color* in the widget. *color* may " "be specified in any of the forms acceptable for a color option." msgstr "" -#: ../../library/tkinter.rst:2147 +#: ../../library/tkinter.rst:2176 msgid "" "Return the *x* coordinate, in the root window of the screen, of the upper-" "left corner of the widget's border (or of the widget itself if it has no " "border)." msgstr "" -#: ../../library/tkinter.rst:2153 +#: ../../library/tkinter.rst:2182 msgid "" "Return the *y* coordinate, in the root window of the screen, of the upper-" "left corner of the widget's border (or of the widget itself if it has no " "border)." msgstr "" -#: ../../library/tkinter.rst:2159 +#: ../../library/tkinter.rst:2188 msgid "" "Return the name of the screen associated with the widget, in the form " "``displayName.screenIndex``." msgstr "" -#: ../../library/tkinter.rst:2164 +#: ../../library/tkinter.rst:2193 msgid "" "Return the number of cells in the default colormap for the widget's screen." msgstr "" -#: ../../library/tkinter.rst:2169 +#: ../../library/tkinter.rst:2198 msgid "" "Return the depth of the root window of the widget's screen, that is, the " "number of bits per pixel." msgstr "" -#: ../../library/tkinter.rst:2174 +#: ../../library/tkinter.rst:2203 msgid "Return the height of the widget's screen in pixels." msgstr "" -#: ../../library/tkinter.rst:2178 +#: ../../library/tkinter.rst:2207 msgid "Return the height of the widget's screen in millimeters." msgstr "" -#: ../../library/tkinter.rst:2182 +#: ../../library/tkinter.rst:2211 msgid "Return the width of the widget's screen in millimeters." msgstr "" -#: ../../library/tkinter.rst:2186 +#: ../../library/tkinter.rst:2215 msgid "" "Return the default visual class for the widget's screen, one of " "``\"directcolor\"``, ``\"grayscale\"``, ``\"pseudocolor\"``, " "``\"staticcolor\"``, ``\"staticgray\"``, or ``\"truecolor\"``." msgstr "" -#: ../../library/tkinter.rst:2192 +#: ../../library/tkinter.rst:2221 msgid "Return the width of the widget's screen in pixels." msgstr "" -#: ../../library/tkinter.rst:2196 +#: ../../library/tkinter.rst:2225 msgid "" "Return a string containing information about the server for the widget's " "display. The exact format of this string may vary from platform to platform." msgstr "" -#: ../../library/tkinter.rst:2202 +#: ../../library/tkinter.rst:2231 msgid "" "Return the top-of-hierarchy window containing the widget. In standard Tk " "this is always a :class:`Toplevel` widget." msgstr "" -#: ../../library/tkinter.rst:2207 +#: ../../library/tkinter.rst:2236 msgid "" "Return true if the widget and all of its ancestors up through the nearest " "toplevel window are mapped, false otherwise." msgstr "" -#: ../../library/tkinter.rst:2212 +#: ../../library/tkinter.rst:2241 msgid "" "Return the visual class for the widget, one of ``\"directcolor\"``, " "``\"grayscale\"``, ``\"pseudocolor\"``, ``\"staticcolor\"``, " "``\"staticgray\"``, or ``\"truecolor\"``." msgstr "" -#: ../../library/tkinter.rst:2218 +#: ../../library/tkinter.rst:2247 msgid "Return the X identifier for the visual for the widget." msgstr "" -#: ../../library/tkinter.rst:2222 +#: ../../library/tkinter.rst:2251 msgid "" "Return a list describing the visuals available for the widget's screen. Each " "item consists of a visual class (see :meth:`winfo_visual`) followed by an " @@ -3437,52 +3465,52 @@ msgid "" "also included." msgstr "" -#: ../../library/tkinter.rst:2230 +#: ../../library/tkinter.rst:2259 msgid "" "Return the height of the virtual root window associated with the widget if " "there is one; otherwise return the height of the widget's screen." msgstr "" -#: ../../library/tkinter.rst:2235 +#: ../../library/tkinter.rst:2264 msgid "" "Return the width of the virtual root window associated with the widget if " "there is one; otherwise return the width of the widget's screen." msgstr "" -#: ../../library/tkinter.rst:2240 +#: ../../library/tkinter.rst:2269 msgid "" "Return the *x* offset of the virtual root window associated with the widget, " "relative to the root window of its screen. This is normally zero or " "negative, and is ``0`` if there is no virtual root window." msgstr "" -#: ../../library/tkinter.rst:2247 +#: ../../library/tkinter.rst:2276 msgid "" "Return the *y* offset of the virtual root window associated with the widget, " "relative to the root window of its screen. This is normally zero or " "negative, and is ``0`` if there is no virtual root window." msgstr "" -#: ../../library/tkinter.rst:2254 +#: ../../library/tkinter.rst:2283 msgid "" "Return the width of the widget in pixels. When a window is first created its " "width is 1 pixel; it is eventually changed by a geometry manager. See also :" "meth:`winfo_reqwidth`." msgstr "" -#: ../../library/tkinter.rst:2261 +#: ../../library/tkinter.rst:2290 msgid "" "Return the *x* coordinate, in the widget's parent, of the upper-left corner " "of the widget's border (or of the widget itself if it has no border)." msgstr "" -#: ../../library/tkinter.rst:2267 +#: ../../library/tkinter.rst:2296 msgid "" "Return the *y* coordinate, in the widget's parent, of the upper-left corner " "of the widget's border (or of the widget itself if it has no border)." msgstr "" -#: ../../library/tkinter.rst:2273 +#: ../../library/tkinter.rst:2302 msgid "" "Return the Tcl/Tk patch level as a named tuple with the same five fields as :" "data:`sys.version_info`: *major*, *minor*, *micro*, *releaselevel* and " @@ -3491,7 +3519,7 @@ msgid "" "for example ``'9.0.3'`` for a final release or ``'9.1b2'`` for a pre-release." msgstr "" -#: ../../library/tkinter.rst:2287 +#: ../../library/tkinter.rst:2316 msgid "" "The :class:`!Wm` mixin provides access to the window manager, allowing an " "application to control such things as the title, geometry and icon of a top-" @@ -3503,7 +3531,7 @@ msgid "" "manager`." msgstr "" -#: ../../library/tkinter.rst:2302 +#: ../../library/tkinter.rst:2331 msgid "" "Constrain the aspect ratio (the ratio of width to height) of the window. If " "all four arguments are given, the window manager keeps the ratio between " @@ -3513,7 +3541,7 @@ msgid "" "meth:`wm_aspect` is an alias of :meth:`!aspect`." msgstr "" -#: ../../library/tkinter.rst:2315 +#: ../../library/tkinter.rst:2344 msgid "" "Query or set platform-specific attributes of the window. With no arguments, " "return the platform-specific flags and their values; pass " @@ -3522,201 +3550,201 @@ msgid "" "set using keyword arguments (``alpha=0.5``)." msgstr "" -#: ../../library/tkinter.rst:2321 +#: ../../library/tkinter.rst:2350 msgid "The available attributes differ by platform. All platforms support:" msgstr "" -#: ../../library/tkinter.rst:2324 +#: ../../library/tkinter.rst:2353 msgid "*alpha*" msgstr "" -#: ../../library/tkinter.rst:2325 +#: ../../library/tkinter.rst:2354 msgid "" "The window's opacity, from ``0.0`` (fully transparent) to ``1.0`` (opaque). " "Where transparency is unsupported the value stays at ``1.0``." msgstr "" -#: ../../library/tkinter.rst:2329 +#: ../../library/tkinter.rst:2358 msgid "*appearance*" msgstr "" -#: ../../library/tkinter.rst:2330 +#: ../../library/tkinter.rst:2359 msgid "" "Whether the window is rendered in dark mode on Windows and macOS: " "``'auto'``, ``'light'`` or ``'dark'`` (this has no effect on X11)." msgstr "" -#: ../../library/tkinter.rst:2333 +#: ../../library/tkinter.rst:2362 msgid "*fullscreen*" msgstr "*fullscreen*" -#: ../../library/tkinter.rst:2334 +#: ../../library/tkinter.rst:2363 msgid "Whether the window takes up the entire screen and has no borders." msgstr "" -#: ../../library/tkinter.rst:2336 +#: ../../library/tkinter.rst:2365 msgid "*topmost*" msgstr "" -#: ../../library/tkinter.rst:2337 +#: ../../library/tkinter.rst:2366 msgid "Whether the window is displayed above all other windows." msgstr "" -#: ../../library/tkinter.rst:2339 +#: ../../library/tkinter.rst:2368 msgid "Windows additionally supports:" msgstr "" -#: ../../library/tkinter.rst:2341 +#: ../../library/tkinter.rst:2370 msgid "*disabled*" msgstr "" -#: ../../library/tkinter.rst:2342 +#: ../../library/tkinter.rst:2371 msgid "Whether the window is in a disabled state." msgstr "" -#: ../../library/tkinter.rst:2344 +#: ../../library/tkinter.rst:2373 msgid "*toolwindow*" msgstr "" -#: ../../library/tkinter.rst:2345 +#: ../../library/tkinter.rst:2374 msgid "Whether the window uses the tool window style." msgstr "" -#: ../../library/tkinter.rst:2347 +#: ../../library/tkinter.rst:2376 msgid "*transparentcolor*" msgstr "" -#: ../../library/tkinter.rst:2348 +#: ../../library/tkinter.rst:2377 msgid "The color that is made fully transparent, or an empty string for none." msgstr "" -#: ../../library/tkinter.rst:2350 +#: ../../library/tkinter.rst:2379 msgid "macOS additionally supports:" msgstr "" -#: ../../library/tkinter.rst:2352 +#: ../../library/tkinter.rst:2381 msgid "*class*" msgstr "*class*" -#: ../../library/tkinter.rst:2353 +#: ../../library/tkinter.rst:2382 msgid "" "Whether the underlying Aqua window is an ``nswindow`` or an ``nspanel``; " "this can only be set before the window is created." msgstr "" -#: ../../library/tkinter.rst:2356 +#: ../../library/tkinter.rst:2385 msgid "*modified*" msgstr "" -#: ../../library/tkinter.rst:2357 +#: ../../library/tkinter.rst:2386 msgid "" "The modification state shown by the window's close button and proxy icon." msgstr "" -#: ../../library/tkinter.rst:2360 +#: ../../library/tkinter.rst:2389 msgid "*notify*" msgstr "" -#: ../../library/tkinter.rst:2361 +#: ../../library/tkinter.rst:2390 msgid "Whether the application's dock icon bounces to request attention." msgstr "" -#: ../../library/tkinter.rst:2363 +#: ../../library/tkinter.rst:2392 msgid "*stylemask*" msgstr "" -#: ../../library/tkinter.rst:2364 +#: ../../library/tkinter.rst:2393 msgid "" "The style mask of the underlying Aqua window, given as a list of bit names " "such as ``titled`` or ``resizable``." msgstr "" -#: ../../library/tkinter.rst:2367 +#: ../../library/tkinter.rst:2396 msgid "*tabbingid*" msgstr "" -#: ../../library/tkinter.rst:2368 +#: ../../library/tkinter.rst:2397 msgid "The identifier of the tab group that the window belongs to." msgstr "" -#: ../../library/tkinter.rst:2370 +#: ../../library/tkinter.rst:2399 msgid "*tabbingmode*" msgstr "" -#: ../../library/tkinter.rst:2371 +#: ../../library/tkinter.rst:2400 msgid "" "Whether the window may be opened as a tab: ``'auto'``, ``'preferred'`` or " "``'disallowed'``." msgstr "" -#: ../../library/tkinter.rst:2374 +#: ../../library/tkinter.rst:2403 msgid "*titlepath*" msgstr "" -#: ../../library/tkinter.rst:2375 +#: ../../library/tkinter.rst:2404 msgid "The path of the file represented by the window's proxy icon." msgstr "" -#: ../../library/tkinter.rst:2377 +#: ../../library/tkinter.rst:2406 msgid "*transparent*" msgstr "" -#: ../../library/tkinter.rst:2378 +#: ../../library/tkinter.rst:2407 msgid "" "Whether the content area is transparent and the window shadow is turned off." msgstr "" -#: ../../library/tkinter.rst:2381 +#: ../../library/tkinter.rst:2410 msgid "X11 additionally supports:" msgstr "" -#: ../../library/tkinter.rst:2383 +#: ../../library/tkinter.rst:2412 msgid "*type*" msgstr "*type*" -#: ../../library/tkinter.rst:2384 +#: ../../library/tkinter.rst:2413 msgid "" "The window type, or a list of types in order of preference, that the window " "manager should use to interpret the window, such as ``'dialog'`` or " "``'splash'``." msgstr "" -#: ../../library/tkinter.rst:2388 +#: ../../library/tkinter.rst:2417 msgid "*zoomed*" msgstr "" -#: ../../library/tkinter.rst:2389 +#: ../../library/tkinter.rst:2418 msgid "Whether the window is maximized." msgstr "" -#: ../../library/tkinter.rst:2393 +#: ../../library/tkinter.rst:2422 msgid "" "Tk 8.6 added the *type* attribute, and Tk 9.0 added the *appearance*, " "*class*, *stylemask*, *tabbingid* and *tabbingmode* attributes." msgstr "" -#: ../../library/tkinter.rst:2396 +#: ../../library/tkinter.rst:2425 msgid "" "On X11 changes are applied asynchronously, so a queried value may not yet " "reflect the most recent request. :meth:`wm_attributes` is an alias of :meth:" "`!attributes`." msgstr "" -#: ../../library/tkinter.rst:2400 +#: ../../library/tkinter.rst:2429 msgid "" "A single attribute may now be queried by name without the leading ``-``, and " "attributes may be set using keyword arguments. The *return_python_dict* " "parameter was added." msgstr "" -#: ../../library/tkinter.rst:2405 +#: ../../library/tkinter.rst:2434 msgid "" "Setting an attribute by passing the option name (with a leading ``-``) and " "its value as two positional arguments, as in ``w.attributes('-alpha', " "0.5)``, is deprecated; use keyword arguments instead." msgstr "" -#: ../../library/tkinter.rst:2417 +#: ../../library/tkinter.rst:2446 msgid "" "Store *name*, which should be the name of the host on which the application " "is running, in the window's ``WM_CLIENT_MACHINE`` property for use by the " @@ -3725,7 +3753,7 @@ msgid "" "an alias of :meth:`!client`." msgstr "" -#: ../../library/tkinter.rst:2429 +#: ../../library/tkinter.rst:2458 msgid "" "Manipulate the ``WM_COLORMAP_WINDOWS`` property, which tells the window " "manager about windows that have private colormaps. If *wlist* is given, " @@ -3735,7 +3763,7 @@ msgid "" "meth:`!colormapwindows`." msgstr "" -#: ../../library/tkinter.rst:2442 +#: ../../library/tkinter.rst:2471 msgid "" "Store *value* in the window's ``WM_COMMAND`` property for use by the window " "or session manager; it should be a list giving the words of the command used " @@ -3744,7 +3772,7 @@ msgid "" "is an alias of :meth:`!command`." msgstr "" -#: ../../library/tkinter.rst:2454 +#: ../../library/tkinter.rst:2483 msgid "" "Display the window in normal (non-iconified) form by mapping it. If the " "window has never been mapped, this ensures it appears de-iconified when it " @@ -3752,7 +3780,7 @@ msgid "" "meth:`wm_deiconify` is an alias of :meth:`!deiconify`." msgstr "" -#: ../../library/tkinter.rst:2465 +#: ../../library/tkinter.rst:2494 msgid "" "Set or query the focus model for the window. *model* is either ``'active'`` " "(the window claims the input focus for itself or its descendants, even when " @@ -3763,7 +3791,7 @@ msgid "" "focusmodel`." msgstr "" -#: ../../library/tkinter.rst:2480 +#: ../../library/tkinter.rst:2509 msgid "" "Unmap *window* from the screen so that it is no longer managed by the window " "manager. A :class:`Toplevel` is then treated like a :class:`Frame`, although " @@ -3771,11 +3799,11 @@ msgid "" "widget is managed again. :meth:`wm_forget` is an alias of :meth:`!forget`." msgstr "" -#: ../../library/tkinter.rst:2487 +#: ../../library/tkinter.rst:2516 msgid "Not to be confused with :meth:`Pack.forget`." msgstr "" -#: ../../library/tkinter.rst:2496 +#: ../../library/tkinter.rst:2525 msgid "" "Return the platform-specific window identifier for the outermost decorative " "frame containing the window, if the window manager has reparented it into " @@ -3783,7 +3811,7 @@ msgid "" "`wm_frame` is an alias of :meth:`!frame`." msgstr "" -#: ../../library/tkinter.rst:2507 +#: ../../library/tkinter.rst:2536 msgid "" "Set or query the geometry of the window. *newGeometry* has the form " "``=widthxheight+x+y``, where any of ``=``, ``widthxheight`` and the ``+x+y`` " @@ -3798,7 +3826,7 @@ msgid "" "geometry`." msgstr "" -#: ../../library/tkinter.rst:2526 +#: ../../library/tkinter.rst:2555 msgid "" "Manage the window as a gridded window and define the relationship between " "grid units and pixels. *baseWidth* and *baseHeight* are the numbers of grid " @@ -3809,11 +3837,11 @@ msgid "" "`wm_grid` is an alias of :meth:`!grid`." msgstr "" -#: ../../library/tkinter.rst:2536 +#: ../../library/tkinter.rst:2565 msgid "Not to be confused with the grid geometry manager :meth:`Grid.grid`." msgstr "" -#: ../../library/tkinter.rst:2543 +#: ../../library/tkinter.rst:2572 msgid "" "Set or query the leader of a group of related windows. *pathName* gives the " "path name of the group leader; the window manager may, for example, unmap " @@ -3823,7 +3851,7 @@ msgid "" "of :meth:`!group`." msgstr "" -#: ../../library/tkinter.rst:2557 +#: ../../library/tkinter.rst:2586 msgid "" "Set or query the bitmap used by the window manager for the window's icon. " "*bitmap* names a bitmap in one of the standard forms accepted by Tk; an " @@ -3834,14 +3862,14 @@ msgid "" "is an alias of :meth:`!iconbitmap`." msgstr "" -#: ../../library/tkinter.rst:2571 +#: ../../library/tkinter.rst:2600 msgid "" "Iconify the window. If the window has not yet been mapped for the first " "time, arrange for it to appear in the iconified state when it is eventually " "mapped. :meth:`wm_iconify` is an alias of :meth:`!iconify`." msgstr "" -#: ../../library/tkinter.rst:2581 +#: ../../library/tkinter.rst:2610 msgid "" "Set or query the bitmap used as a mask for the icon (see :meth:" "`iconbitmap`). Where the mask is zero no icon is displayed; where it is one, " @@ -3851,7 +3879,7 @@ msgid "" "iconmask`." msgstr "" -#: ../../library/tkinter.rst:2595 +#: ../../library/tkinter.rst:2624 msgid "" "Set or query the name displayed by the window manager inside the window's " "icon. With no argument, return the current icon name, or an empty string if " @@ -3859,7 +3887,7 @@ msgid "" "window's title). :meth:`wm_iconname` is an alias of :meth:`!iconname`." msgstr "" -#: ../../library/tkinter.rst:2607 +#: ../../library/tkinter.rst:2636 msgid "" "Set the titlebar icon for the window from one or more :class:`PhotoImage` " "objects given in *images*. Several images of different sizes (for example " @@ -3871,7 +3899,7 @@ msgid "" "meth:`!iconphoto`." msgstr "" -#: ../../library/tkinter.rst:2625 +#: ../../library/tkinter.rst:2654 msgid "" "Set or query a hint to the window manager about where the window's icon " "should be positioned. Empty strings cancel an existing hint. With no " @@ -3879,7 +3907,7 @@ msgid "" "is in effect. :meth:`wm_iconposition` is an alias of :meth:`!iconposition`." msgstr "" -#: ../../library/tkinter.rst:2637 +#: ../../library/tkinter.rst:2666 msgid "" "Set or query the window used as the icon for the window. When the window is " "iconified, *pathName* is mapped to serve as its icon and unmapped again when " @@ -3890,7 +3918,7 @@ msgid "" "`!iconwindow`." msgstr "" -#: ../../library/tkinter.rst:2652 +#: ../../library/tkinter.rst:2681 msgid "" "Make *widget* a stand-alone top-level window, decorated by the window " "manager with a title bar and so on. Only :class:`Frame`, :class:`LabelFrame` " @@ -3899,7 +3927,7 @@ msgid "" "`wm_manage` is an alias of :meth:`!manage`." msgstr "" -#: ../../library/tkinter.rst:2666 +#: ../../library/tkinter.rst:2695 msgid "" "Set or query the maximum permissible dimensions of the window, in pixels (or " "grid units for a gridded window). The window manager restricts the window to " @@ -3908,7 +3936,7 @@ msgid "" "of the screen. :meth:`wm_maxsize` is an alias of :meth:`!maxsize`." msgstr "" -#: ../../library/tkinter.rst:2680 +#: ../../library/tkinter.rst:2709 msgid "" "Set or query the minimum permissible dimensions of the window, in pixels (or " "grid units for a gridded window). The window manager restricts the window to " @@ -3917,7 +3945,7 @@ msgid "" "pixel in each dimension. :meth:`wm_minsize` is an alias of :meth:`!minsize`." msgstr "" -#: ../../library/tkinter.rst:2694 +#: ../../library/tkinter.rst:2723 msgid "" "Set or query the override-redirect flag for the window. When this flag is " "set, the window is ignored by the window manager: it is not reparented into " @@ -3929,7 +3957,7 @@ msgid "" "overrideredirect`." msgstr "" -#: ../../library/tkinter.rst:2709 +#: ../../library/tkinter.rst:2738 msgid "" "Set or query the source of the window's current position. *who* is either " "``'program'`` or ``'user'`` and indicates whether the position was requested " @@ -3940,7 +3968,7 @@ msgid "" "meth:`wm_positionfrom` is an alias of :meth:`!positionfrom`." msgstr "" -#: ../../library/tkinter.rst:2724 +#: ../../library/tkinter.rst:2753 msgid "" "Register *func* as the handler for the window manager protocol *name*, an " "atom such as ``'WM_DELETE_WINDOW'``, ``'WM_SAVE_YOURSELF'`` or " @@ -3954,7 +3982,7 @@ msgid "" "meth:`wm_protocol` is an alias of :meth:`!protocol`." msgstr "" -#: ../../library/tkinter.rst:2742 +#: ../../library/tkinter.rst:2771 msgid "" "Control whether the user may interactively resize the window. *width* and " "*height* are boolean values that determine whether the window's width and " @@ -3964,7 +3992,7 @@ msgid "" "of :meth:`!resizable`." msgstr "" -#: ../../library/tkinter.rst:2755 +#: ../../library/tkinter.rst:2784 msgid "" "Set or query the source of the window's current size. *who* is either " "``'program'`` or ``'user'`` and indicates whether the size was requested by " @@ -3973,7 +4001,7 @@ msgid "" "set. :meth:`wm_sizefrom` is an alias of :meth:`!sizefrom`." msgstr "" -#: ../../library/tkinter.rst:2768 +#: ../../library/tkinter.rst:2797 msgid "" "Set or query the state of the window. With no argument, return the current " "state: one of ``'normal'``, ``'iconic'``, ``'withdrawn'``, ``'icon'`` or, on " @@ -3983,12 +4011,12 @@ msgid "" "set. :meth:`wm_state` is an alias of :meth:`!state`." msgstr "" -#: ../../library/tkinter.rst:2777 +#: ../../library/tkinter.rst:2806 msgid "" "Not to be confused with :meth:`ttk.Widget.state `." msgstr "" -#: ../../library/tkinter.rst:2785 +#: ../../library/tkinter.rst:2814 msgid "" "Set or query the title for the window, which the window manager should " "display in the window's title bar. With no argument, return the current " @@ -3996,7 +4024,7 @@ msgid "" "of :meth:`!title`." msgstr "" -#: ../../library/tkinter.rst:2796 +#: ../../library/tkinter.rst:2825 msgid "" "Mark the window as a transient window (such as a pull-down menu or dialog) " "working on behalf of *master*, the path name of another top-level window. An " @@ -4007,7 +4035,7 @@ msgid "" "`wm_transient` is an alias of :meth:`!transient`." msgstr "" -#: ../../library/tkinter.rst:2812 +#: ../../library/tkinter.rst:2841 msgid "" "Withdraw the window from the screen, unmapping it and causing the window " "manager to forget about it. If the window has never been mapped, it is " @@ -4017,7 +4045,7 @@ msgid "" "`wm_withdraw` is an alias of :meth:`!withdraw`." msgstr "" -#: ../../library/tkinter.rst:2824 +#: ../../library/tkinter.rst:2853 msgid "" "Geometry manager that arranges widgets by packing them against the sides of " "their container. The :class:`!Pack` mix-in is inherited by all widgets " @@ -4026,7 +4054,7 @@ msgid "" "management`." msgstr "" -#: ../../library/tkinter.rst:2833 +#: ../../library/tkinter.rst:2862 msgid "" ":class:`Pack`, :class:`Place` and :class:`Grid` all define the short method " "names :meth:`!forget`, :meth:`!info`, :meth:`!slaves`, :meth:`!content` and :" @@ -4039,112 +4067,112 @@ msgid "" "``place`` for geometry configuration) to act on a specific geometry manager." msgstr "" -#: ../../library/tkinter.rst:2855 +#: ../../library/tkinter.rst:2884 msgid "" "Pack the widget inside its container, positioning it relative to the " "siblings already packed there. The supported options are:" msgstr "" -#: ../../library/tkinter.rst:2859 +#: ../../library/tkinter.rst:2888 msgid "*side*" msgstr "*side*" -#: ../../library/tkinter.rst:2860 +#: ../../library/tkinter.rst:2889 msgid "" "Which side of the container to pack the widget against: ``'top'`` (the " "default), ``'bottom'``, ``'left'`` or ``'right'``." msgstr "" -#: ../../library/tkinter.rst:2863 ../../library/tkinter.rst:3487 +#: ../../library/tkinter.rst:2892 ../../library/tkinter.rst:3544 msgid "*fill*" msgstr "*fill*" -#: ../../library/tkinter.rst:2864 +#: ../../library/tkinter.rst:2893 msgid "" "Whether to stretch the widget to fill its parcel: ``'none'`` (the default), " "``'x'``, ``'y'`` or ``'both'``." msgstr "" -#: ../../library/tkinter.rst:2867 +#: ../../library/tkinter.rst:2896 msgid "*expand*" msgstr "*expand*" -#: ../../library/tkinter.rst:2868 +#: ../../library/tkinter.rst:2897 msgid "" "Whether the widget should expand to consume any extra space in its container " "(a boolean, default false)." msgstr "" -#: ../../library/tkinter.rst:2871 ../../library/tkinter.rst:2977 -#: ../../library/tkinter.rst:3597 ../../library/tkinter.rst:3616 -#: ../../library/tkinter.rst:3631 ../../library/tkinter.rst:3644 +#: ../../library/tkinter.rst:2900 ../../library/tkinter.rst:3016 +#: ../../library/tkinter.rst:3654 ../../library/tkinter.rst:3673 +#: ../../library/tkinter.rst:3688 ../../library/tkinter.rst:3701 msgid "*anchor*" msgstr "*anchor*" -#: ../../library/tkinter.rst:2872 +#: ../../library/tkinter.rst:2901 msgid "" "Where to position the widget in its parcel when the parcel is larger than " "the widget: an anchor such as ``'n'`` or ``'sw'`` (default ``'center'``)." msgstr "" -#: ../../library/tkinter.rst:2876 ../../library/tkinter.rst:3071 +#: ../../library/tkinter.rst:2905 ../../library/tkinter.rst:3119 msgid "*ipadx*, *ipady*" msgstr "*ipadx*, *ipady*" -#: ../../library/tkinter.rst:2877 ../../library/tkinter.rst:3072 +#: ../../library/tkinter.rst:2906 ../../library/tkinter.rst:3120 msgid "" "Internal padding added on the left and right (*ipadx*) or top and bottom " "(*ipady*) of the widget, as a screen distance (default ``0``)." msgstr "" -#: ../../library/tkinter.rst:2880 ../../library/tkinter.rst:3075 +#: ../../library/tkinter.rst:2909 ../../library/tkinter.rst:3123 msgid "*padx*, *pady*" msgstr "*padx*, *pady*" -#: ../../library/tkinter.rst:2881 ../../library/tkinter.rst:3076 +#: ../../library/tkinter.rst:2910 ../../library/tkinter.rst:3124 msgid "" "External padding left on the left and right (*padx*) or top and bottom " "(*pady*) of the widget, as a screen distance or a pair of two distances for " "the two sides (default ``0``)." msgstr "" -#: ../../library/tkinter.rst:2885 +#: ../../library/tkinter.rst:2914 msgid "*after*" msgstr "" -#: ../../library/tkinter.rst:2886 +#: ../../library/tkinter.rst:2915 msgid "" "Pack the widget after the given widget in the packing order, using the same " "container." msgstr "" -#: ../../library/tkinter.rst:2889 +#: ../../library/tkinter.rst:2918 msgid "*before*" msgstr "" -#: ../../library/tkinter.rst:2890 +#: ../../library/tkinter.rst:2919 msgid "" "Pack the widget before the given widget in the packing order, using the same " "container." msgstr "" -#: ../../library/tkinter.rst:2893 ../../library/tkinter.rst:2997 -#: ../../library/tkinter.rst:3080 +#: ../../library/tkinter.rst:2922 ../../library/tkinter.rst:3036 +#: ../../library/tkinter.rst:3128 msgid "*in_*" msgstr "" -#: ../../library/tkinter.rst:2894 +#: ../../library/tkinter.rst:2923 msgid "" "The container in which to pack the widget; it defaults to the parent widget." msgstr "" -#: ../../library/tkinter.rst:2897 +#: ../../library/tkinter.rst:2926 msgid "" ":meth:`pack`, :meth:`configure` and :meth:`config` are aliases of :meth:`!" "pack_configure`." msgstr "" -#: ../../library/tkinter.rst:2905 +#: ../../library/tkinter.rst:2934 msgid "" "Unmap the widget and remove it from the packing order, forgetting its " "packing options. It can be packed again later with :meth:`pack_configure`. :" @@ -4154,57 +4182,63 @@ msgid "" "forget` method." msgstr "" -#: ../../library/tkinter.rst:2914 +#: ../../library/tkinter.rst:2943 msgid "Not to be confused with :meth:`Wm.forget`." msgstr "" -#: ../../library/tkinter.rst:2921 +#: ../../library/tkinter.rst:2950 msgid "" "Return a dictionary of the widget's current packing options. :meth:`info` is " "an alias of :meth:`!pack_info`." msgstr "" -#: ../../library/tkinter.rst:2931 +#: ../../library/tkinter.rst:2960 msgid "" "Same as :meth:`Misc.pack_propagate`, treating this widget as a container: " "enable or disable geometry propagation. :meth:`propagate` is an alias of :" "meth:`!pack_propagate`." msgstr "" -#: ../../library/tkinter.rst:2940 +#: ../../library/tkinter.rst:2969 msgid "" "Same as :meth:`Misc.pack_slaves`: return the list of widgets packed in this " "widget. :meth:`slaves` is an alias of :meth:`!pack_slaves`." msgstr "" -#: ../../library/tkinter.rst:2947 +#: ../../library/tkinter.rst:2978 +msgid "" +"Same as :meth:`Misc.pack_content`. :meth:`content` is an alias of :meth:`!" +"pack_content`." +msgstr "" + +#: ../../library/tkinter.rst:2986 msgid "" "Geometry manager that places widgets at explicit positions and sizes within " "their container. The :class:`!Place` mix-in is inherited by all widgets " "(through :class:`Widget`). See also :ref:`tkinter-geometry-management`." msgstr "" -#: ../../library/tkinter.rst:2962 +#: ../../library/tkinter.rst:3001 msgid "" "Place the widget inside its container at an absolute or relative position. " "The supported options are:" msgstr "" -#: ../../library/tkinter.rst:2966 +#: ../../library/tkinter.rst:3005 msgid "*x*, *y*" msgstr "*x*, *y*" -#: ../../library/tkinter.rst:2967 +#: ../../library/tkinter.rst:3006 msgid "" "The absolute horizontal and vertical position of the widget's anchor point, " "as a screen distance (default ``0``)." msgstr "" -#: ../../library/tkinter.rst:2970 +#: ../../library/tkinter.rst:3009 msgid "*relx*, *rely*" msgstr "" -#: ../../library/tkinter.rst:2971 +#: ../../library/tkinter.rst:3010 msgid "" "The horizontal and vertical position of the widget's anchor point as a " "fraction of the container's width and height, where ``0.0`` is the left or " @@ -4212,73 +4246,77 @@ msgid "" "the relative option are given, their values are summed." msgstr "" -#: ../../library/tkinter.rst:2978 +#: ../../library/tkinter.rst:3017 msgid "" "Which point of the widget is placed at the given position: an anchor such as " "``'n'`` or ``'se'`` (default ``'nw'``)." msgstr "" -#: ../../library/tkinter.rst:2981 ../../library/tkinter.rst:3647 +#: ../../library/tkinter.rst:3020 ../../library/tkinter.rst:3704 msgid "*width*, *height*" msgstr "" -#: ../../library/tkinter.rst:2982 +#: ../../library/tkinter.rst:3021 msgid "" "The absolute width and height of the widget, as a screen distance. By " "default the widget's requested size is used." msgstr "" -#: ../../library/tkinter.rst:2985 +#: ../../library/tkinter.rst:3024 msgid "*relwidth*, *relheight*" msgstr "" -#: ../../library/tkinter.rst:2986 +#: ../../library/tkinter.rst:3025 msgid "" "The width and height of the widget as a fraction of the container's width " "and height. If both the absolute and the relative option are given, their " "values are summed." msgstr "" -#: ../../library/tkinter.rst:2991 +#: ../../library/tkinter.rst:3030 msgid "*bordermode*" msgstr "" -#: ../../library/tkinter.rst:2992 +#: ../../library/tkinter.rst:3031 msgid "" "How the container's border affects placement: ``'inside'`` (the default) " "measures the area inside the border, ``'outside'`` measures the area " "including the border, and ``'ignore'`` uses the official X area." msgstr "" -#: ../../library/tkinter.rst:2998 +#: ../../library/tkinter.rst:3037 msgid "" "The container relative to which the widget is placed; it must be the " "widget's parent or a descendant of the parent, and defaults to the parent." msgstr "" -#: ../../library/tkinter.rst:3002 +#: ../../library/tkinter.rst:3041 msgid "" ":meth:`place`, :meth:`configure` and :meth:`config` are aliases of :meth:`!" "place_configure`." msgstr "" -#: ../../library/tkinter.rst:3010 +#: ../../library/tkinter.rst:3049 msgid "" "Unmap the widget and remove it from the placement, forgetting its place " "options." msgstr "" -#: ../../library/tkinter.rst:3018 +#: ../../library/tkinter.rst:3057 msgid "Return a dictionary of the widget's current place options." msgstr "" -#: ../../library/tkinter.rst:3025 +#: ../../library/tkinter.rst:3064 msgid "" "Same as :meth:`Misc.place_slaves`: return the list of widgets placed in this " "widget." msgstr "" -#: ../../library/tkinter.rst:3031 +#: ../../library/tkinter.rst:3072 +msgid "Same as :meth:`Misc.place_content`." +msgstr "" + +#: ../../library/tkinter.rst:3079 msgid "" "Geometry manager that arranges widgets in a two-dimensional grid of rows and " "columns within their container. The :class:`!Grid` mix-in is inherited by " @@ -4286,23 +4324,23 @@ msgid "" "management`." msgstr "" -#: ../../library/tkinter.rst:3046 +#: ../../library/tkinter.rst:3094 msgid "Position the widget in a cell of its container's grid." msgstr "" -#: ../../library/tkinter.rst:3048 +#: ../../library/tkinter.rst:3096 msgid "Not to be confused with :meth:`Wm.grid`." msgstr "" -#: ../../library/tkinter.rst:3050 +#: ../../library/tkinter.rst:3098 msgid "The supported options are:" msgstr "" -#: ../../library/tkinter.rst:3052 +#: ../../library/tkinter.rst:3100 msgid "*row*, *column*" msgstr "" -#: ../../library/tkinter.rst:3053 +#: ../../library/tkinter.rst:3101 msgid "" "The row and column of the cell to place the widget in, counting from ``0``. " "*column* defaults to the column after the previous widget placed in the " @@ -4310,19 +4348,19 @@ msgid "" "empty row." msgstr "" -#: ../../library/tkinter.rst:3059 +#: ../../library/tkinter.rst:3107 msgid "*rowspan*, *columnspan*" msgstr "" -#: ../../library/tkinter.rst:3060 +#: ../../library/tkinter.rst:3108 msgid "The number of rows and columns the widget should span (default ``1``)." msgstr "" -#: ../../library/tkinter.rst:3062 +#: ../../library/tkinter.rst:3110 msgid "*sticky*" msgstr "" -#: ../../library/tkinter.rst:3063 +#: ../../library/tkinter.rst:3111 msgid "" "How to position or stretch the widget when its cell is larger than the " "widget: a string containing zero or more of the characters ``'n'``, ``'s'``, " @@ -4332,34 +4370,34 @@ msgid "" "the widget at its requested size." msgstr "" -#: ../../library/tkinter.rst:3081 +#: ../../library/tkinter.rst:3129 msgid "" "The container in whose grid to place the widget; it defaults to the parent " "widget." msgstr "" -#: ../../library/tkinter.rst:3084 +#: ../../library/tkinter.rst:3132 msgid "" ":meth:`grid`, :meth:`configure` and :meth:`config` are aliases of :meth:`!" "grid_configure`." msgstr "" -#: ../../library/tkinter.rst:3092 +#: ../../library/tkinter.rst:3140 msgid "" "Unmap the widget and remove it from the grid, forgetting its grid options." msgstr "" -#: ../../library/tkinter.rst:3097 +#: ../../library/tkinter.rst:3145 msgid "" "Unmap the widget and remove it from the grid, but remember its grid options " "so that it is restored to the same cell if it is gridded again." msgstr "" -#: ../../library/tkinter.rst:3105 +#: ../../library/tkinter.rst:3153 msgid "Return a dictionary of the widget's current grid options." msgstr "" -#: ../../library/tkinter.rst:3112 +#: ../../library/tkinter.rst:3160 msgid "" "Same as :meth:`Misc.grid_bbox`. :meth:`bbox` is an alias of :meth:`!" "grid_bbox`, except on :class:`Canvas`, :class:`Listbox`, :class:`Spinbox`, :" @@ -4368,44 +4406,48 @@ msgid "" "method." msgstr "" -#: ../../library/tkinter.rst:3124 +#: ../../library/tkinter.rst:3172 msgid "" "Same as :meth:`Misc.grid_columnconfigure`: query or set the options (such as " "*weight*, *minsize*, *pad* and *uniform*) of a grid column. :meth:" "`columnconfigure` is an alias of :meth:`!grid_columnconfigure`." msgstr "" -#: ../../library/tkinter.rst:3133 +#: ../../library/tkinter.rst:3181 msgid "" "Same as :meth:`Misc.grid_rowconfigure`: query or set the options of a grid " "row. :meth:`rowconfigure` is an alias of :meth:`!grid_rowconfigure`." msgstr "" -#: ../../library/tkinter.rst:3142 +#: ../../library/tkinter.rst:3190 msgid "" "Same as :meth:`Misc.grid_location`: return the ``(column, row)`` of the cell " "that covers the pixel at *x*, *y*. :meth:`location` is an alias of :meth:`!" "grid_location`." msgstr "" -#: ../../library/tkinter.rst:3151 +#: ../../library/tkinter.rst:3199 msgid "" "Same as :meth:`Misc.grid_size`: return a ``(columns, rows)`` tuple giving " "the size of the grid. :meth:`size` is an alias of :meth:`!grid_size`, except " "on the :class:`Listbox` widget, which provides its own :meth:`!size` method." msgstr "" -#: ../../library/tkinter.rst:3164 +#: ../../library/tkinter.rst:3212 msgid "Same as :meth:`Misc.grid_propagate`." msgstr "" -#: ../../library/tkinter.rst:3171 +#: ../../library/tkinter.rst:3219 msgid "" "Same as :meth:`Misc.grid_slaves`: return the widgets managed in the grid, " "optionally restricted to a *row* and/or *column*." msgstr "" -#: ../../library/tkinter.rst:3177 +#: ../../library/tkinter.rst:3227 +msgid "Same as :meth:`Misc.grid_content`." +msgstr "" + +#: ../../library/tkinter.rst:3234 msgid "" "Mix-in providing the horizontal-scrolling interface shared by widgets such " "as :class:`Entry`, :class:`Canvas`, :class:`Listbox`, :class:`Text` and :" @@ -4413,7 +4455,7 @@ msgid "" "*command* of a horizontal :class:`Scrollbar`." msgstr "" -#: ../../library/tkinter.rst:3185 +#: ../../library/tkinter.rst:3242 msgid "" "Query or change the horizontal position of the view. With no arguments, " "return a tuple ``(first, last)`` of two fractions between 0 and 1 giving the " @@ -4423,27 +4465,27 @@ msgid "" "convenient interface." msgstr "" -#: ../../library/tkinter.rst:3195 +#: ../../library/tkinter.rst:3252 msgid "" "Adjust the view so that *fraction* of the total width of the document is off-" "screen to the left. *fraction* is a number between 0 and 1." msgstr "" -#: ../../library/tkinter.rst:3201 +#: ../../library/tkinter.rst:3258 msgid "" "Shift the view left or right by *number* units. *what* is either ``'units'`` " "or ``'pages'``; a negative *number* scrolls left and a positive one scrolls " "right." msgstr "" -#: ../../library/tkinter.rst:3208 +#: ../../library/tkinter.rst:3265 msgid "" "Mix-in providing the vertical-scrolling interface shared by widgets such as :" "class:`Canvas`, :class:`Listbox` and :class:`Text`. A widget's :meth:`yview` " "method is registered as the *command* of a vertical :class:`Scrollbar`." msgstr "" -#: ../../library/tkinter.rst:3215 +#: ../../library/tkinter.rst:3272 msgid "" "Query or change the vertical position of the view. With no arguments, return " "a tuple ``(first, last)`` of two fractions between 0 and 1 giving the " @@ -4453,19 +4495,19 @@ msgid "" "convenient interface." msgstr "" -#: ../../library/tkinter.rst:3225 +#: ../../library/tkinter.rst:3282 msgid "" "Adjust the view so that *fraction* of the total height of the document is " "off-screen above the top. *fraction* is a number between 0 and 1." msgstr "" -#: ../../library/tkinter.rst:3231 +#: ../../library/tkinter.rst:3288 msgid "" "Shift the view up or down by *number* units. *what* is either ``'units'`` or " "``'pages'``; a negative *number* scrolls up and a positive one scrolls down." msgstr "" -#: ../../library/tkinter.rst:3238 +#: ../../library/tkinter.rst:3295 msgid "" "Internal base class for all widgets. It inherits from :class:`Misc` and adds " "the machinery that creates the underlying Tk widget; application code " @@ -4473,13 +4515,13 @@ msgid "" "instantiating :class:`!BaseWidget` directly." msgstr "" -#: ../../library/tkinter.rst:3246 +#: ../../library/tkinter.rst:3303 msgid "" "Destroy this widget and all of its children, removing the corresponding Tk " "widgets and deleting the associated Tcl commands." msgstr "" -#: ../../library/tkinter.rst:3252 +#: ../../library/tkinter.rst:3309 msgid "" "Internal base class for the standard widgets. It combines :class:" "`BaseWidget` with the geometry-manager mix-ins :class:`Pack`, :class:`Place` " @@ -4488,11 +4530,11 @@ msgid "" "`Label`, and so on) derive from :class:`!Widget`." msgstr "" -#: ../../library/tkinter.rst:3261 +#: ../../library/tkinter.rst:3318 msgid "Toplevel widgets" msgstr "Toplevel 元件" -#: ../../library/tkinter.rst:3265 +#: ../../library/tkinter.rst:3322 msgid "" "Construct a toplevel Tk widget, which is usually the main window of an " "application, and initialize a Tcl interpreter for this widget. Each " @@ -4503,34 +4545,34 @@ msgstr "" "器。每個實例都有其自己關聯的 Tcl 直譯器。繼承自 :class:`Misc` " "和 :class:`Wm`。" -#: ../../library/tkinter.rst:3270 +#: ../../library/tkinter.rst:3327 msgid "" "To create a Tcl interpreter without initializing the Tk subsystem, use the :" "func:`Tcl` factory function instead." msgstr "" -#: ../../library/tkinter.rst:3273 +#: ../../library/tkinter.rst:3330 msgid "" "The :class:`Tk` class is typically instantiated using all default values. " "However, the following keyword arguments are currently recognized:" msgstr "" ":class:`Tk` 類別通常使用所有預設值來實例化。然而,目前可辨識下列關鍵字引數:" -#: ../../library/tkinter.rst:3276 +#: ../../library/tkinter.rst:3333 msgid "*screenName*" msgstr "*screenName*" -#: ../../library/tkinter.rst:3277 +#: ../../library/tkinter.rst:3334 msgid "" "When given (as a string), sets the :envvar:`DISPLAY` environment variable. " "(X11 only)" msgstr "當給定(作為字串)時,設定 :envvar:`DISPLAY` 環境變數。(僅限 X11)" -#: ../../library/tkinter.rst:3279 +#: ../../library/tkinter.rst:3336 msgid "*baseName*" msgstr "*baseName*" -#: ../../library/tkinter.rst:3280 +#: ../../library/tkinter.rst:3337 msgid "" "Name of the profile file. By default, *baseName* is derived from the " "program name (``sys.argv[0]``)." @@ -4538,11 +4580,11 @@ msgstr "" "設定檔的名稱。預設情況下,*baseName* 是從程式名稱(``sys.argv[0]``)衍生而" "來。" -#: ../../library/tkinter.rst:3282 +#: ../../library/tkinter.rst:3339 msgid "*className*" msgstr "*className*" -#: ../../library/tkinter.rst:3283 +#: ../../library/tkinter.rst:3340 msgid "" "Name of the widget class. Used as a profile file and also as the name with " "which Tcl is invoked (*argv0* in *interp*)." @@ -4550,11 +4592,11 @@ msgstr "" "元件類別的名稱。用作設定檔,也用作呼叫 Tcl 時的名稱(*interp* 中的 " "*argv0*)。" -#: ../../library/tkinter.rst:3285 +#: ../../library/tkinter.rst:3342 msgid "*useTk*" msgstr "*useTk*" -#: ../../library/tkinter.rst:3286 +#: ../../library/tkinter.rst:3343 msgid "" "If ``True``, initialize the Tk subsystem. The :func:`tkinter.Tcl() ` " "function sets this to ``False``." @@ -4562,11 +4604,11 @@ msgstr "" "若為 ``True``,則初始化 Tk 子系統。:func:`tkinter.Tcl() ` 函式會將此設定" "為 ``False``。" -#: ../../library/tkinter.rst:3288 +#: ../../library/tkinter.rst:3345 msgid "*sync*" msgstr "*sync*" -#: ../../library/tkinter.rst:3289 +#: ../../library/tkinter.rst:3346 msgid "" "If ``True``, execute all X server commands synchronously, so that errors are " "reported immediately. Can be used for debugging. (X11 only)" @@ -4574,11 +4616,11 @@ msgstr "" "若為 ``True``,則同步執行所有 X 伺服器指令,以便立即回報錯誤。可用於偵錯。" "(僅限 X11)" -#: ../../library/tkinter.rst:3291 +#: ../../library/tkinter.rst:3348 msgid "*use*" msgstr "*use*" -#: ../../library/tkinter.rst:3292 +#: ../../library/tkinter.rst:3349 msgid "" "Specifies the *id* of the window in which to embed the application, instead " "of it being created as an independent toplevel window. *id* must be " @@ -4590,7 +4632,7 @@ msgstr "" "頂層元件的 -use 選項值相同的方式指定(也就是說,其形式類似 :meth:`~Misc." "winfo_id` 回傳的形式)。" -#: ../../library/tkinter.rst:3298 +#: ../../library/tkinter.rst:3355 msgid "" "Note that on some platforms this will only work correctly if *id* refers to " "a Tk frame or toplevel that has its -container option enabled." @@ -4598,7 +4640,7 @@ msgstr "" "請注意,在某些平台上,只有當 *id* 指向一個已啟用 -container 選項的 Tk 框架或" "頂層視窗時,此功能才能正常運作。" -#: ../../library/tkinter.rst:3301 +#: ../../library/tkinter.rst:3358 msgid "" ":class:`Tk` reads and interprets profile files, named :file:`.{className}." "tcl` and :file:`.{baseName}.tcl`, into the Tcl interpreter and calls :func:" @@ -4611,7 +4653,7 @@ msgstr "" "{baseName}.py` 的內容呼叫 :func:`exec`。設定檔的路徑是 :envvar:`HOME` 環境變" "數,如果未定義,則是 :data:`os.curdir`。" -#: ../../library/tkinter.rst:3310 +#: ../../library/tkinter.rst:3367 msgid "" "On Windows, creating a Tcl interpreter (by instantiating :class:`Tk` or " "calling :func:`Tcl`) sets the :envvar:`HOME` environment variable for the " @@ -4620,7 +4662,7 @@ msgid "" "that reads :envvar:`HOME`." msgstr "" -#: ../../library/tkinter.rst:3318 +#: ../../library/tkinter.rst:3375 msgid "" "The Tk application object created by instantiating :class:`Tk`. This " "provides access to the Tcl interpreter. Each widget that is attached the " @@ -4629,7 +4671,7 @@ msgstr "" "透過實例化 :class:`Tk` 建立的 Tk 應用程式物件。這提供了對 Tcl 直譯器的存取。" "每個附加到同一個 :class:`Tk` 實例的元件,其 :attr:`tk` 屬性都具有相同的值。" -#: ../../library/tkinter.rst:3325 +#: ../../library/tkinter.rst:3382 msgid "" "The widget object that contains this widget. For :class:`Tk`, the :attr:`!" "master` is :const:`None` because it is the main window. The terms *master* " @@ -4645,7 +4687,7 @@ msgstr "" "master` 則回傳物件。*parent*/*child* 反映了樹狀關係,而 *master*\\ (或 " "*container*)/*content* 反映了容器結構。" -#: ../../library/tkinter.rst:3337 +#: ../../library/tkinter.rst:3394 msgid "" "The immediate descendants of this widget as a :class:`dict` with the child " "widget names as the keys and the child instance objects as the values." @@ -4653,20 +4695,20 @@ msgstr "" "此元件的直接子代,形式為一個 :class:`dict`,其中鍵為子元件的名稱,值為子實例" "物件。" -#: ../../library/tkinter.rst:3343 +#: ../../library/tkinter.rst:3400 msgid "" "Destroy this and all descendant widgets and, for the main window, end the " "connection to the underlying Tcl interpreter." msgstr "" -#: ../../library/tkinter.rst:3348 +#: ../../library/tkinter.rst:3405 msgid "" "Finish loading and initializing the Tk subsystem. This is needed only when " "the interpreter was created without Tk (for example through :func:`Tcl`); it " "is called automatically when *useTk* is true." msgstr "" -#: ../../library/tkinter.rst:3355 +#: ../../library/tkinter.rst:3412 msgid "" "Read and source the user's profile files :file:`.{className}.tcl` and :file:" "`.{baseName}.tcl` into the Tcl interpreter, and execute the corresponding :" @@ -4677,7 +4719,7 @@ msgstr "" "到 Tcl 直譯器中,並執行對應的 :file:`.{className}.py` 和 :file:`.{baseName}." "py` 檔案。這在初始化期間被呼叫;請參閱上方建構函式的說明。" -#: ../../library/tkinter.rst:3363 +#: ../../library/tkinter.rst:3420 msgid "" "Report a callback exception. This is called when an exception propagates out " "of a Tkinter callback; *exc*, *val* and *tb* are the exception type, value " @@ -4687,7 +4729,7 @@ msgid "" "in a dialog." msgstr "" -#: ../../library/tkinter.rst:3374 +#: ../../library/tkinter.rst:3431 msgid "" "A :class:`!Toplevel` widget is a top-level window, similar to a :class:" "`Frame` except that its X parent is the root window of a screen rather than " @@ -4700,11 +4742,11 @@ msgid "" "options." msgstr "" -#: ../../library/tkinter.rst:3388 +#: ../../library/tkinter.rst:3445 msgid "Widget classes" msgstr "" -#: ../../library/tkinter.rst:3392 +#: ../../library/tkinter.rst:3449 msgid "" "A :class:`!Button` widget displays a textual string, bitmap or image and " "invokes a command when the user presses it (by clicking mouse button 1 over " @@ -4715,14 +4757,14 @@ msgid "" "*textvariable*, *state* and *default*." msgstr "" -#: ../../library/tkinter.rst:3402 +#: ../../library/tkinter.rst:3459 msgid "" "Invoke the command associated with the button, if there is one, and return " "its result, or an empty string if no command is associated with the button. " "This is ignored if the button's state is ``disabled``." msgstr "" -#: ../../library/tkinter.rst:3409 +#: ../../library/tkinter.rst:3466 msgid "" "Flash the button by redisplaying it several times, alternating between the " "active and normal colors. At the end of the flash the button is left in the " @@ -4730,7 +4772,7 @@ msgid "" "if the button's state is ``disabled``." msgstr "" -#: ../../library/tkinter.rst:3418 +#: ../../library/tkinter.rst:3475 msgid "" "A :class:`!Canvas` widget implements structured graphics. It displays any " "number of *items*, such as arcs, lines, ovals, polygons, rectangles, text, " @@ -4741,7 +4783,7 @@ msgid "" "manual page for the full list of widget and item options." msgstr "" -#: ../../library/tkinter.rst:3428 +#: ../../library/tkinter.rst:3485 msgid "" "Each item has a unique integer *id*, assigned when it is created, and zero " "or more string *tags*. A tag is an arbitrary string that does not have the " @@ -4757,7 +4799,7 @@ msgid "" "in the display list." msgstr "" -#: ../../library/tkinter.rst:3443 +#: ../../library/tkinter.rst:3500 msgid "" "The items are kept in a *display list* that determines drawing order: items " "later in the list are drawn on top of earlier ones. A newly created item is " @@ -4765,7 +4807,7 @@ msgid "" "`tag_raise` and :meth:`tag_lower`." msgstr "" -#: ../../library/tkinter.rst:3458 +#: ../../library/tkinter.rst:3515 msgid "" "Create a new item of the corresponding type and return its integer id. Each " "method is called as ``create_TYPE(coord..., **options)``: the leading " @@ -4778,7 +4820,7 @@ msgid "" "in pixels." msgstr "" -#: ../../library/tkinter.rst:3468 +#: ../../library/tkinter.rst:3525 msgid "" "The item types are: ``arc`` (an arc-shaped region that is a section of an " "oval, defined by two diagonally opposite corners ``x1, y1, x2, y2`` of the " @@ -4793,48 +4835,48 @@ msgid "" "*window* option)." msgstr "" -#: ../../library/tkinter.rst:3480 +#: ../../library/tkinter.rst:3537 msgid "" "Most item types accept a common set of *standard item options*, plus a few " "options specific to each type. Option names are passed as keyword arguments, " "without the leading hyphen." msgstr "" -#: ../../library/tkinter.rst:3485 +#: ../../library/tkinter.rst:3542 msgid "The standard item options are:" msgstr "" -#: ../../library/tkinter.rst:3488 +#: ../../library/tkinter.rst:3545 msgid "" "The color used to fill the item's interior, or to draw a *line* item or the " "characters of a *text* item. An empty string (the default for all types " "except *line* and *text*) leaves the item unfilled." msgstr "" -#: ../../library/tkinter.rst:3493 +#: ../../library/tkinter.rst:3550 msgid "*outline*" msgstr "" -#: ../../library/tkinter.rst:3494 +#: ../../library/tkinter.rst:3551 msgid "" "The color used to draw the item's outline. An empty string draws no outline." msgstr "" -#: ../../library/tkinter.rst:3497 ../../library/tkinter.rst:3601 +#: ../../library/tkinter.rst:3554 ../../library/tkinter.rst:3658 msgid "*width*" msgstr "*width*" -#: ../../library/tkinter.rst:3498 +#: ../../library/tkinter.rst:3555 msgid "" "The width of the outline, defaulting to ``1.0``. Has no effect if *outline* " "is empty." msgstr "" -#: ../../library/tkinter.rst:3501 +#: ../../library/tkinter.rst:3558 msgid "*dash*" msgstr "" -#: ../../library/tkinter.rst:3502 +#: ../../library/tkinter.rst:3559 msgid "" "A dash pattern for the outline, given either as a sequence of segment " "lengths in pixels or as a string of the characters ``'.'``, ``','``, " @@ -4842,68 +4884,68 @@ msgid "" "outline." msgstr "" -#: ../../library/tkinter.rst:3507 +#: ../../library/tkinter.rst:3564 msgid "*dashoffset*" msgstr "" -#: ../../library/tkinter.rst:3508 +#: ../../library/tkinter.rst:3565 msgid "" "The starting offset in pixels into the *dash* pattern. Ignored if there is " "no *dash* pattern." msgstr "" -#: ../../library/tkinter.rst:3511 +#: ../../library/tkinter.rst:3568 msgid "*stipple*" msgstr "" -#: ../../library/tkinter.rst:3512 +#: ../../library/tkinter.rst:3569 msgid "" "A bitmap used as a stipple pattern when filling the item. Only well " "supported on X11." msgstr "" -#: ../../library/tkinter.rst:3515 +#: ../../library/tkinter.rst:3572 msgid "*outlinestipple*" msgstr "" -#: ../../library/tkinter.rst:3516 +#: ../../library/tkinter.rst:3573 msgid "" "A bitmap used as a stipple pattern when drawing the outline. Has no effect " "if *outline* is empty." msgstr "" -#: ../../library/tkinter.rst:3519 +#: ../../library/tkinter.rst:3576 msgid "*offset*, *outlineoffset*" msgstr "" -#: ../../library/tkinter.rst:3520 +#: ../../library/tkinter.rst:3577 msgid "" "The offset of the fill and outline stipple patterns, given as ``'x,y'`` or " "as a side such as ``'n'``, ``'se'`` or ``'center'``. Stipple offsets are " "only supported on X11." msgstr "" -#: ../../library/tkinter.rst:3524 ../../library/tkinter.rst:4474 +#: ../../library/tkinter.rst:3581 ../../library/tkinter.rst:4531 msgid "*state*" msgstr "*state*" -#: ../../library/tkinter.rst:3525 +#: ../../library/tkinter.rst:3582 msgid "" "Overrides the canvas state for this item; one of ``'normal'``, " "``'disabled'`` or ``'hidden'``." msgstr "" -#: ../../library/tkinter.rst:3528 +#: ../../library/tkinter.rst:3585 msgid "*tags*" msgstr "" -#: ../../library/tkinter.rst:3529 +#: ../../library/tkinter.rst:3586 msgid "" "A single tag or a sequence of tags to associate with the item, replacing any " "existing tags." msgstr "" -#: ../../library/tkinter.rst:3532 +#: ../../library/tkinter.rst:3589 msgid "" "Many of these options have *active...* and *disabled...* variants (such as " "*activefill*, *disabledfill*, *activewidth*, *disableddash*, " @@ -4912,196 +4954,196 @@ msgid "" "state." msgstr "" -#: ../../library/tkinter.rst:3538 +#: ../../library/tkinter.rst:3595 msgid "The following item types support additional options." msgstr "" -#: ../../library/tkinter.rst:3540 +#: ../../library/tkinter.rst:3597 msgid "For ``arc`` items:" msgstr "" -#: ../../library/tkinter.rst:3542 +#: ../../library/tkinter.rst:3599 msgid "*start*" msgstr "" -#: ../../library/tkinter.rst:3543 +#: ../../library/tkinter.rst:3600 msgid "" "The start of the arc's angular range, in degrees measured counter-clockwise " "from the 3-o'clock position." msgstr "" -#: ../../library/tkinter.rst:3546 +#: ../../library/tkinter.rst:3603 msgid "*extent*" msgstr "" -#: ../../library/tkinter.rst:3547 +#: ../../library/tkinter.rst:3604 msgid "" "The size of the angular range, in degrees counter-clockwise from *start*." msgstr "" -#: ../../library/tkinter.rst:3550 +#: ../../library/tkinter.rst:3607 msgid "*style*" msgstr "" -#: ../../library/tkinter.rst:3551 +#: ../../library/tkinter.rst:3608 msgid "" "How the arc is drawn: ``'pieslice'`` (the default), ``'chord'`` or ``'arc'``." msgstr "" -#: ../../library/tkinter.rst:3554 +#: ../../library/tkinter.rst:3611 msgid "For ``line`` items:" msgstr "" -#: ../../library/tkinter.rst:3556 +#: ../../library/tkinter.rst:3613 msgid "*arrow*" msgstr "" -#: ../../library/tkinter.rst:3557 +#: ../../library/tkinter.rst:3614 msgid "" "Where to draw arrowheads: ``'none'`` (the default), ``'first'``, ``'last'`` " "or ``'both'``." msgstr "" -#: ../../library/tkinter.rst:3560 +#: ../../library/tkinter.rst:3617 msgid "*arrowshape*" msgstr "" -#: ../../library/tkinter.rst:3561 +#: ../../library/tkinter.rst:3618 msgid "A sequence of three distances describing the shape of the arrowheads." msgstr "" -#: ../../library/tkinter.rst:3564 +#: ../../library/tkinter.rst:3621 msgid "*capstyle*" msgstr "" -#: ../../library/tkinter.rst:3565 +#: ../../library/tkinter.rst:3622 msgid "" "How line ends are drawn: ``'butt'`` (the default), ``'projecting'`` or " "``'round'``." msgstr "" -#: ../../library/tkinter.rst:3568 +#: ../../library/tkinter.rst:3625 msgid "*joinstyle*" msgstr "" -#: ../../library/tkinter.rst:3569 +#: ../../library/tkinter.rst:3626 msgid "" "How line vertices are drawn: ``'round'`` (the default), ``'bevel'`` or " "``'miter'``." msgstr "" -#: ../../library/tkinter.rst:3572 +#: ../../library/tkinter.rst:3629 msgid "*smooth*" msgstr "" -#: ../../library/tkinter.rst:3573 +#: ../../library/tkinter.rst:3630 msgid "" "The smoothing method: a false value (the default) for no smoothing, or " "``'true'``/``'bezier'`` or ``'raw'`` to draw the line as a curve." msgstr "" -#: ../../library/tkinter.rst:3576 +#: ../../library/tkinter.rst:3633 msgid "*splinesteps*" msgstr "" -#: ../../library/tkinter.rst:3577 +#: ../../library/tkinter.rst:3634 msgid "" "The number of line segments approximating each spline when *smooth* is " "enabled." msgstr "" -#: ../../library/tkinter.rst:3580 +#: ../../library/tkinter.rst:3637 msgid "For ``polygon`` items:" msgstr "" -#: ../../library/tkinter.rst:3582 +#: ../../library/tkinter.rst:3639 msgid "*joinstyle*, *smooth*, *splinesteps*" msgstr "" -#: ../../library/tkinter.rst:3583 +#: ../../library/tkinter.rst:3640 msgid "As for ``line`` items, applied to the polygon's outline." msgstr "" -#: ../../library/tkinter.rst:3585 +#: ../../library/tkinter.rst:3642 msgid "For ``text`` items:" msgstr "" -#: ../../library/tkinter.rst:3587 +#: ../../library/tkinter.rst:3644 msgid "*text*" msgstr "" -#: ../../library/tkinter.rst:3588 +#: ../../library/tkinter.rst:3645 msgid "The string to display; newline characters start new lines." msgstr "" -#: ../../library/tkinter.rst:3590 ../../library/tkinter.rst:4488 -#: ../../library/tkinter.rst:5372 +#: ../../library/tkinter.rst:3647 ../../library/tkinter.rst:4545 +#: ../../library/tkinter.rst:5429 msgid "*font*" msgstr "*font*" -#: ../../library/tkinter.rst:3591 +#: ../../library/tkinter.rst:3648 msgid "The font used for the text." msgstr "" -#: ../../library/tkinter.rst:3593 ../../library/tkinter.rst:5412 +#: ../../library/tkinter.rst:3650 ../../library/tkinter.rst:5469 msgid "*justify*" msgstr "*justify*" -#: ../../library/tkinter.rst:3594 +#: ../../library/tkinter.rst:3651 msgid "" "How lines are justified: ``'left'`` (the default), ``'right'`` or " "``'center'``." msgstr "對齊方式:``'left'``\\ (預設)、``'right'`` 或 ``'center'``。" -#: ../../library/tkinter.rst:3598 +#: ../../library/tkinter.rst:3655 msgid "" "How the text is positioned relative to its point, defaulting to ``'center'``." msgstr "" -#: ../../library/tkinter.rst:3602 +#: ../../library/tkinter.rst:3659 msgid "The maximum line length; if non-zero, lines are wrapped at spaces." msgstr "" -#: ../../library/tkinter.rst:3604 +#: ../../library/tkinter.rst:3661 msgid "*angle*" msgstr "" -#: ../../library/tkinter.rst:3605 +#: ../../library/tkinter.rst:3662 msgid "" "How many degrees to rotate the text counter-clockwise about its positioning " "point, from ``0.0`` to ``360.0`` (default ``0.0``)." msgstr "" -#: ../../library/tkinter.rst:3608 ../../library/tkinter.rst:4470 -#: ../../library/tkinter.rst:5397 +#: ../../library/tkinter.rst:3665 ../../library/tkinter.rst:4527 +#: ../../library/tkinter.rst:5454 msgid "*underline*" msgstr "" -#: ../../library/tkinter.rst:3609 +#: ../../library/tkinter.rst:3666 msgid "The index of a character to underline, or ``-1`` for none." msgstr "" -#: ../../library/tkinter.rst:3611 +#: ../../library/tkinter.rst:3668 msgid "For ``bitmap`` items:" msgstr "" -#: ../../library/tkinter.rst:3613 ../../library/tkinter.rst:4485 +#: ../../library/tkinter.rst:3670 ../../library/tkinter.rst:4542 msgid "*bitmap*" msgstr "*bitmap*" -#: ../../library/tkinter.rst:3614 +#: ../../library/tkinter.rst:3671 msgid "The bitmap to display." msgstr "" -#: ../../library/tkinter.rst:3617 +#: ../../library/tkinter.rst:3674 msgid "How the bitmap is positioned relative to its point." msgstr "" -#: ../../library/tkinter.rst:3619 ../../library/tkinter.rst:4491 +#: ../../library/tkinter.rst:3676 ../../library/tkinter.rst:4548 msgid "*background*, *foreground*" msgstr "" -#: ../../library/tkinter.rst:3620 +#: ../../library/tkinter.rst:3677 msgid "" "The colors used for the bitmap's ``0`` and ``1`` pixels; an empty " "*background* makes the ``0`` pixels transparent. Both have *active...* and " @@ -5109,65 +5151,65 @@ msgid "" "variants." msgstr "" -#: ../../library/tkinter.rst:3625 +#: ../../library/tkinter.rst:3682 msgid "For ``image`` items:" msgstr "" -#: ../../library/tkinter.rst:3627 ../../library/tkinter.rst:4477 +#: ../../library/tkinter.rst:3684 ../../library/tkinter.rst:4534 msgid "*image*" msgstr "*image*" -#: ../../library/tkinter.rst:3628 +#: ../../library/tkinter.rst:3685 msgid "The Tk image to display, previously created with the image protocols." msgstr "" -#: ../../library/tkinter.rst:3632 +#: ../../library/tkinter.rst:3689 msgid "How the image is positioned relative to its point." msgstr "" -#: ../../library/tkinter.rst:3634 +#: ../../library/tkinter.rst:3691 msgid "" "Both options have *active...* and *disabled...* variants (*activeimage*, " "*disabledimage*) used in the active and disabled states." msgstr "" -#: ../../library/tkinter.rst:3638 +#: ../../library/tkinter.rst:3695 msgid "For ``window`` items:" msgstr "" -#: ../../library/tkinter.rst:3640 +#: ../../library/tkinter.rst:3697 msgid "*window*" msgstr "" -#: ../../library/tkinter.rst:3641 +#: ../../library/tkinter.rst:3698 msgid "" "The widget to embed; it must be a child of the canvas or of one of its " "ancestors, and may not be a top-level window." msgstr "" -#: ../../library/tkinter.rst:3645 +#: ../../library/tkinter.rst:3702 msgid "How the window is positioned relative to its point." msgstr "" -#: ../../library/tkinter.rst:3648 +#: ../../library/tkinter.rst:3705 msgid "" "The size to assign to the window; if zero (the default), the window is given " "its requested size." msgstr "" -#: ../../library/tkinter.rst:3651 +#: ../../library/tkinter.rst:3708 msgid "" "``oval`` and ``rectangle`` items have no type-specific options; they use " "only the standard item options." msgstr "" -#: ../../library/tkinter.rst:3656 +#: ../../library/tkinter.rst:3713 msgid "" "Tk 8.6 added the *angle* option and Tk 9.0 added the *underline* option for " "``text`` items." msgstr "" -#: ../../library/tkinter.rst:3663 +#: ../../library/tkinter.rst:3720 msgid "" "Query or modify the coordinates of an item. With only *tagOrId*, return a " "list of the floating-point coordinates of the item given by *tagOrId* (the " @@ -5179,21 +5221,21 @@ msgid "" "ordered left, top, right, bottom." msgstr "" -#: ../../library/tkinter.rst:3674 +#: ../../library/tkinter.rst:3731 msgid "" "The arguments are now flattened: the coordinates may be given as separate " "arguments, as a single sequence, or grouped in pairs, like the ``create_*`` " "methods." msgstr "" -#: ../../library/tkinter.rst:3682 +#: ../../library/tkinter.rst:3739 msgid "" "Move each of the items given by *tagOrId* in the canvas coordinate space by " "adding *xAmount* to every x-coordinate and *yAmount* to every y-coordinate " "of the item." msgstr "" -#: ../../library/tkinter.rst:3688 +#: ../../library/tkinter.rst:3745 msgid "" "Move the items given by *tagOrId* so that the first coordinate pair (the " "upper-left corner of the bounding box) of the lowest matching item is at " @@ -5202,7 +5244,7 @@ msgid "" "positions relative to each other." msgstr "" -#: ../../library/tkinter.rst:3700 +#: ../../library/tkinter.rst:3757 msgid "" "Rescale the coordinates of all items given by *tagOrId* in canvas coordinate " "space. Each x-coordinate is adjusted so that its distance from *xOrigin* " @@ -5211,11 +5253,11 @@ msgid "" "the coordinate unchanged)." msgstr "" -#: ../../library/tkinter.rst:3709 +#: ../../library/tkinter.rst:3766 msgid "Delete each of the items given by the *tagOrIds* arguments." msgstr "" -#: ../../library/tkinter.rst:3714 +#: ../../library/tkinter.rst:3771 msgid "" "Delete from each of the items given by *tagOrId* the characters (for text " "items) or coordinates (for line and polygon items) in the range from *first* " @@ -5223,21 +5265,21 @@ msgid "" "indexing ignore this operation." msgstr "" -#: ../../library/tkinter.rst:3721 +#: ../../library/tkinter.rst:3778 msgid "" "Insert *string* into each of the items given by *tagOrId* just before the " "character or coordinate whose index is *beforeThis*. For line and polygon " "items *string* must be a valid sequence of coordinates." msgstr "" -#: ../../library/tkinter.rst:3728 +#: ../../library/tkinter.rst:3785 msgid "" "Return the current value of the configuration option *option* for the item " "given by *tagOrId* (the lowest matching item if it matches several). This is " "like :meth:`~Misc.cget` but applies to an individual item." msgstr "" -#: ../../library/tkinter.rst:3737 +#: ../../library/tkinter.rst:3794 msgid "" "Query or modify the configuration options of the items given by *tagOrId*. " "This mirrors :meth:`~Misc.configure`, except that it applies to individual " @@ -5248,27 +5290,27 @@ msgid "" "`itemconfig` is an alias of :meth:`!itemconfigure`." msgstr "" -#: ../../library/tkinter.rst:3750 +#: ../../library/tkinter.rst:3807 msgid "" "Return the type of the item given by *tagOrId* (the first matching item if " "it matches several), such as ``'rectangle'`` or ``'text'``, or ``None`` if " "*tagOrId* does not match any item." msgstr "" -#: ../../library/tkinter.rst:3756 +#: ../../library/tkinter.rst:3813 msgid "" "Return a tuple of the tags associated with the item given by *tagOrId* (the " "first matching item in display-list order if it matches several). Return an " "empty tuple if no item matches or the item has no tags." msgstr "" -#: ../../library/tkinter.rst:3763 +#: ../../library/tkinter.rst:3820 msgid "" "Remove the tag *tagToDelete* (which defaults to *tagOrId*) from each of the " "items given by *tagOrId*. Items that do not have that tag are unaffected." msgstr "" -#: ../../library/tkinter.rst:3769 +#: ../../library/tkinter.rst:3826 msgid "" "Add the tag *newtag* to each item selected by the search specification " "*searchSpec* (and any further *args*). *searchSpec* is one of ``'above'``, " @@ -5277,23 +5319,23 @@ msgid "" "supply each of these forms." msgstr "" -#: ../../library/tkinter.rst:3778 +#: ../../library/tkinter.rst:3835 msgid "" "Add the tag *newtag* to the item just above (after) *tagOrId* in the display " "list." msgstr "" -#: ../../library/tkinter.rst:3783 +#: ../../library/tkinter.rst:3840 msgid "Add the tag *newtag* to all items in the canvas." msgstr "" -#: ../../library/tkinter.rst:3787 +#: ../../library/tkinter.rst:3844 msgid "" "Add the tag *newtag* to the item just below (before) *tagOrId* in the " "display list." msgstr "" -#: ../../library/tkinter.rst:3792 +#: ../../library/tkinter.rst:3849 msgid "" "Add the tag *newtag* to the item closest to the point (*x*, *y*). If *halo* " "is given, any item within that distance of the point is treated as " @@ -5302,23 +5344,23 @@ msgid "" "to step through all the closest items." msgstr "" -#: ../../library/tkinter.rst:3801 +#: ../../library/tkinter.rst:3858 msgid "" "Add the tag *newtag* to every item completely enclosed within the rectangle " "(*x1*, *y1*, *x2*, *y2*), where *x1* <= *x2* and *y1* <= *y2*." msgstr "" -#: ../../library/tkinter.rst:3806 +#: ../../library/tkinter.rst:3863 msgid "" "Add the tag *newtag* to every item that overlaps or is enclosed within the " "rectangle (*x1*, *y1*, *x2*, *y2*), where *x1* <= *x2* and *y1* <= *y2*." msgstr "" -#: ../../library/tkinter.rst:3812 +#: ../../library/tkinter.rst:3869 msgid "Add the tag *newtag* to every item given by *tagOrId*." msgstr "" -#: ../../library/tkinter.rst:3816 +#: ../../library/tkinter.rst:3873 msgid "" "Return a tuple of the ids of all items selected by the search specification " "*searchSpec* (and any further *args*), in stacking order with the lowest " @@ -5327,46 +5369,46 @@ msgid "" "it." msgstr "" -#: ../../library/tkinter.rst:3824 +#: ../../library/tkinter.rst:3881 msgid "" "Return a tuple containing the id of the item just above *tagOrId* in the " "display list." msgstr "" -#: ../../library/tkinter.rst:3829 +#: ../../library/tkinter.rst:3886 msgid "" "Return a tuple of the ids of all items in the canvas, in stacking order." msgstr "" -#: ../../library/tkinter.rst:3833 +#: ../../library/tkinter.rst:3890 msgid "" "Return a tuple containing the id of the item just below *tagOrId* in the " "display list." msgstr "" -#: ../../library/tkinter.rst:3838 +#: ../../library/tkinter.rst:3895 msgid "" "Return a tuple containing the id of the item closest to the point (*x*, " "*y*). *halo* and *start* are interpreted as for :meth:`addtag_closest`." msgstr "" -#: ../../library/tkinter.rst:3844 +#: ../../library/tkinter.rst:3901 msgid "" "Return a tuple of the ids of all items completely enclosed within the " "rectangle (*x1*, *y1*, *x2*, *y2*)." msgstr "" -#: ../../library/tkinter.rst:3849 +#: ../../library/tkinter.rst:3906 msgid "" "Return a tuple of the ids of all items that overlap or are enclosed within " "the rectangle (*x1*, *y1*, *x2*, *y2*)." msgstr "" -#: ../../library/tkinter.rst:3854 +#: ../../library/tkinter.rst:3911 msgid "Return a tuple of the ids of all items given by *tagOrId*." msgstr "" -#: ../../library/tkinter.rst:3864 +#: ../../library/tkinter.rst:3921 msgid "" "Move all items given by *tagOrId* to a new position in the display list just " "above the item given by *aboveThis*, or to the top of the display list if " @@ -5376,7 +5418,7 @@ msgid "" "`lift` and :meth:`tkraise` are aliases of :meth:`!tag_raise`." msgstr "" -#: ../../library/tkinter.rst:3877 +#: ../../library/tkinter.rst:3934 msgid "" "Move all items given by *tagOrId* to a new position in the display list just " "below the item given by *belowThis*, or to the bottom of the display list if " @@ -5385,7 +5427,7 @@ msgid "" "alias of :meth:`!tag_lower`." msgstr "" -#: ../../library/tkinter.rst:3886 +#: ../../library/tkinter.rst:3943 msgid "" "On a :class:`Canvas`, :meth:`tkraise`/:meth:`lift` and :meth:`lower` restack " "canvas items, shadowing the inherited :meth:`Misc.tkraise`/:meth:`Misc.lift` " @@ -5393,7 +5435,7 @@ msgid "" "therefore not available." msgstr "" -#: ../../library/tkinter.rst:3894 +#: ../../library/tkinter.rst:3951 msgid "" "Bind the callback *func* to the event *sequence* for all items given by " "*tagOrId*, so that *func* is invoked whenever that event occurs for one of " @@ -5406,18 +5448,18 @@ msgid "" "be passed to :meth:`tag_unbind`." msgstr "" -#: ../../library/tkinter.rst:3909 +#: ../../library/tkinter.rst:3966 msgid "" "Remove for all items given by *tagOrId* the binding for the event " "*sequence*. If *funcid* is given, only that callback (as returned by :meth:" "`tag_bind`) is unbound and deregistered." msgstr "" -#: ../../library/tkinter.rst:3914 ../../library/tkinter.rst:5518 +#: ../../library/tkinter.rst:3971 ../../library/tkinter.rst:5575 msgid "If *funcid* is given, only that callback is unbound." msgstr "" -#: ../../library/tkinter.rst:3920 +#: ../../library/tkinter.rst:3977 msgid "" "Return a 4-tuple ``(x1, y1, x2, y2)`` giving an approximate bounding box, in " "pixels, that encloses all the items given by *tagOrId* and any further " @@ -5426,28 +5468,28 @@ msgid "" "nothing to display." msgstr "" -#: ../../library/tkinter.rst:3927 ../../library/tkinter.rst:4320 -#: ../../library/tkinter.rst:5061 ../../library/tkinter.rst:5288 +#: ../../library/tkinter.rst:3984 ../../library/tkinter.rst:4377 +#: ../../library/tkinter.rst:5118 ../../library/tkinter.rst:5345 msgid "" "This shadows the inherited :meth:`!Misc.bbox`; use :meth:`~Misc.grid_bbox` " "for the grid bounding box." msgstr "" -#: ../../library/tkinter.rst:3932 +#: ../../library/tkinter.rst:3989 msgid "" "Given a window x-coordinate *screenx*, return the canvas x-coordinate " "displayed at that location. If *gridspacing* is given, the result is rounded " "to the nearest multiple of *gridspacing* units." msgstr "" -#: ../../library/tkinter.rst:3939 +#: ../../library/tkinter.rst:3996 msgid "" "Given a window y-coordinate *screeny*, return the canvas y-coordinate " "displayed at that location. If *gridspacing* is given, the result is rounded " "to the nearest multiple of *gridspacing* units." msgstr "" -#: ../../library/tkinter.rst:3947 +#: ../../library/tkinter.rst:4004 msgid "" "With *tagOrId*, set the keyboard focus for the canvas to the first item " "given by *tagOrId* that supports the insertion cursor; the focus is left " @@ -5458,13 +5500,13 @@ msgid "" "has the input focus." msgstr "" -#: ../../library/tkinter.rst:3956 +#: ../../library/tkinter.rst:4013 msgid "" "This shadows the inherited :meth:`!Misc.focus`; use :meth:`~Misc.focus_set` " "to focus the widget itself." msgstr "" -#: ../../library/tkinter.rst:3961 +#: ../../library/tkinter.rst:4018 msgid "" "Set the insertion cursor of the items given by *tagOrId* to just before the " "character given by *index*. Items that do not support an insertion cursor " @@ -5472,7 +5514,7 @@ msgid "" "but its position may be set at any time." msgstr "" -#: ../../library/tkinter.rst:3969 +#: ../../library/tkinter.rst:4026 msgid "" "Return as an integer the numerical index within *tagOrId* corresponding to " "*index*, which is a textual description of a position (for text items an " @@ -5481,7 +5523,7 @@ msgid "" "supports indexing is used." msgstr "" -#: ../../library/tkinter.rst:3978 +#: ../../library/tkinter.rst:4035 msgid "" "Adjust the end of the selection in *tagOrId* nearest to *index* so that it " "is at *index*, and make the other end the anchor point for future :meth:" @@ -5489,39 +5531,39 @@ msgid "" "behaves like :meth:`select_to`." msgstr "" -#: ../../library/tkinter.rst:3986 +#: ../../library/tkinter.rst:4043 msgid "Clear the selection if it is in this canvas; otherwise do nothing." msgstr "" -#: ../../library/tkinter.rst:3990 +#: ../../library/tkinter.rst:4047 msgid "" "Set the selection anchor point to just before the character given by *index* " "in the item given by *tagOrId*. This does not change the selection itself; " "it sets the fixed end for future :meth:`select_to` calls." msgstr "" -#: ../../library/tkinter.rst:3997 +#: ../../library/tkinter.rst:4054 msgid "" "Return the id of the item that holds the selection, or ``None`` if the " "selection is not in this canvas. Unlike :meth:`find` and the ``find_*`` " "methods, this returns the id as a string rather than an integer." msgstr "" -#: ../../library/tkinter.rst:4004 +#: ../../library/tkinter.rst:4061 msgid "" "Set the selection to the characters of *tagOrId* between the selection " "anchor point and *index*, inclusive of *index*. The anchor point is the one " "set by the most recent :meth:`select_adjust` or :meth:`select_from` call." msgstr "" -#: ../../library/tkinter.rst:4011 ../../library/tkinter.rst:4416 -#: ../../library/tkinter.rst:5642 +#: ../../library/tkinter.rst:4068 ../../library/tkinter.rst:4473 +#: ../../library/tkinter.rst:5717 msgid "" "Record *x*, *y* and the current view, for use with later :meth:`scan_dragto` " "calls. This is typically bound to a mouse button press in the widget." msgstr "" -#: ../../library/tkinter.rst:4017 +#: ../../library/tkinter.rst:4074 msgid "" "Scroll the canvas by *gain* times the difference between *x*, *y* and the " "coordinates passed to the last :meth:`scan_mark` call. This is typically " @@ -5529,7 +5571,7 @@ msgid "" "the canvas at high speed through its window." msgstr "" -#: ../../library/tkinter.rst:4024 +#: ../../library/tkinter.rst:4081 msgid "" "Generate a PostScript (Encapsulated PostScript, version 3.0) representation " "of part or all of the canvas. If the *file* or *channel* option is given, " @@ -5542,7 +5584,7 @@ msgid "" "*width*, *x* and *y*." msgstr "" -#: ../../library/tkinter.rst:4039 +#: ../../library/tkinter.rst:4096 msgid "" "A :class:`!Checkbutton` widget displays a textual string, bitmap or image " "together with a square indicator, and toggles a boolean selection when " @@ -5555,7 +5597,7 @@ msgid "" "page, such as *variable*, *onvalue*, *offvalue* and *command*." msgstr "" -#: ../../library/tkinter.rst:4053 +#: ../../library/tkinter.rst:4110 msgid "" "Do just what would happen if the user pressed the checkbutton with the " "mouse: toggle the selection state of the button and invoke the associated " @@ -5564,23 +5606,23 @@ msgid "" "the checkbutton's state is ``disabled``." msgstr "" -#: ../../library/tkinter.rst:4062 +#: ../../library/tkinter.rst:4119 msgid "" "Select the checkbutton and set the associated variable to its ``onvalue``." msgstr "" -#: ../../library/tkinter.rst:4067 +#: ../../library/tkinter.rst:4124 msgid "" "Deselect the checkbutton and set the associated variable to its ``offvalue``." msgstr "" -#: ../../library/tkinter.rst:4072 +#: ../../library/tkinter.rst:4129 msgid "" "Toggle the selection state of the button, redisplaying it and modifying its " "associated variable to reflect the new state." msgstr "" -#: ../../library/tkinter.rst:4077 +#: ../../library/tkinter.rst:4134 msgid "" "Flash the checkbutton by redisplaying it several times, alternating between " "the active and normal colors. At the end of the flash the checkbutton is " @@ -5588,7 +5630,7 @@ msgid "" "is ignored if the checkbutton's state is ``disabled``." msgstr "" -#: ../../library/tkinter.rst:4086 +#: ../../library/tkinter.rst:4143 msgid "" "An :class:`!Entry` widget displays a single line of text and lets the user " "edit it. Inherits from :class:`Widget` and :class:`XView`; since entries can " @@ -5596,7 +5638,7 @@ msgid "" "scrolling through :meth:`~XView.xview`." msgstr "" -#: ../../library/tkinter.rst:4092 +#: ../../library/tkinter.rst:4149 msgid "" "In addition to the standard widget options, an entry accepts the options " "documented in the Tk ``entry`` manual page. Notable ones are *textvariable* " @@ -5607,7 +5649,7 @@ msgid "" "``'normal'``, ``'disabled'`` or ``'readonly'``)." msgstr "" -#: ../../library/tkinter.rst:4101 +#: ../../library/tkinter.rst:4158 msgid "" "Many of the methods below take an *index* argument that selects a character " "in the entry's string. As described in the Tk ``entry`` manual page, *index* " @@ -5619,32 +5661,32 @@ msgid "" "nearest legal value." msgstr "" -#: ../../library/tkinter.rst:4113 +#: ../../library/tkinter.rst:4170 msgid "" "Delete the characters from index *first* up to but not including index " "*last*. If *last* is omitted, only the single character at *first* is " "deleted." msgstr "" -#: ../../library/tkinter.rst:4119 +#: ../../library/tkinter.rst:4176 msgid "Return the entry's current string." msgstr "" -#: ../../library/tkinter.rst:4123 +#: ../../library/tkinter.rst:4180 msgid "Insert *string* just before the character given by *index*." msgstr "" -#: ../../library/tkinter.rst:4127 ../../library/tkinter.rst:5044 +#: ../../library/tkinter.rst:4184 ../../library/tkinter.rst:5101 msgid "" "Arrange for the insertion cursor to be displayed just before the character " "given by *index*." msgstr "" -#: ../../library/tkinter.rst:4132 +#: ../../library/tkinter.rst:4189 msgid "Return the numerical index corresponding to *index*." msgstr "" -#: ../../library/tkinter.rst:4139 +#: ../../library/tkinter.rst:4196 msgid "" "Locate the end of the selection nearest to the character given by *index*, " "and adjust that end to be at *index* (including but not going beyond it); " @@ -5654,33 +5696,33 @@ msgid "" "is an alias of :meth:`!selection_adjust`." msgstr "" -#: ../../library/tkinter.rst:4152 +#: ../../library/tkinter.rst:4209 msgid "" "Clear the selection if it is currently in this widget. If the selection is " "not in this widget the method has no effect. :meth:`select_clear` is an " "alias of :meth:`!selection_clear`." msgstr "" -#: ../../library/tkinter.rst:4158 +#: ../../library/tkinter.rst:4215 msgid "" "This shadows the inherited :meth:`Misc.selection_clear`, which clears the X " "selection; that method is not available on an :class:`Entry`." msgstr "" -#: ../../library/tkinter.rst:4167 +#: ../../library/tkinter.rst:4224 msgid "" "Set the selection anchor point to just before the character given by " "*index*, without changing the selection. :meth:`select_from` is an alias of :" "meth:`!selection_from`." msgstr "" -#: ../../library/tkinter.rst:4176 +#: ../../library/tkinter.rst:4233 msgid "" "Return ``True`` if there are characters selected in the entry, ``False`` " "otherwise. :meth:`select_present` is an alias of :meth:`!selection_present`." msgstr "" -#: ../../library/tkinter.rst:4185 +#: ../../library/tkinter.rst:4242 msgid "" "Set the selection to include the characters starting with the one indexed by " "*start* and ending with the one just before *end*. If *end* refers to the " @@ -5688,7 +5730,7 @@ msgid "" "`select_range` is an alias of :meth:`!selection_range`." msgstr "" -#: ../../library/tkinter.rst:4196 +#: ../../library/tkinter.rst:4253 msgid "" "Set the selection between the anchor point and *index*: if *index* is before " "the anchor point, the selection runs from *index* up to but not including " @@ -5699,14 +5741,14 @@ msgid "" "recent anchor point. :meth:`select_to` is an alias of :meth:`!selection_to`." msgstr "" -#: ../../library/tkinter.rst:4208 +#: ../../library/tkinter.rst:4265 msgid "" "Record *x* and the current view in the entry window, for use with later :" "meth:`scan_dragto` calls. Typically associated with a mouse button press in " "the widget." msgstr "" -#: ../../library/tkinter.rst:4214 +#: ../../library/tkinter.rst:4271 msgid "" "Compute the difference between *x* and the *x* given to the last :meth:" "`scan_mark` call, and adjust the view left or right by 10 times that " @@ -5714,7 +5756,7 @@ msgid "" "effect of dragging the entry at high speed through the window." msgstr "" -#: ../../library/tkinter.rst:4223 +#: ../../library/tkinter.rst:4280 msgid "" "A :class:`!Frame` widget is a simple container. Its primary purpose is to " "act as a spacer or container for complex window layouts; its only features " @@ -5723,7 +5765,7 @@ msgid "" "manual page for the full list of options." msgstr "" -#: ../../library/tkinter.rst:4233 +#: ../../library/tkinter.rst:4290 msgid "" "A :class:`!Label` widget displays a non-interactive textual string, bitmap " "or image. The displayed text is set with the *text* option or linked to a " @@ -5734,7 +5776,7 @@ msgid "" "options." msgstr "" -#: ../../library/tkinter.rst:4245 +#: ../../library/tkinter.rst:4302 msgid "" "A :class:`!LabelFrame` widget is a container that has the features of a :" "class:`Frame` plus the ability to display a label. The label text is set " @@ -5744,7 +5786,7 @@ msgid "" "for the full list of options." msgstr "" -#: ../../library/tkinter.rst:4256 +#: ../../library/tkinter.rst:4313 msgid "" "A :class:`!Listbox` widget displays a list of single-line text items, one " "per line, of which the user can select one or more. The way the selection " @@ -5758,7 +5800,7 @@ msgid "" "the Tk ``listbox`` manual page for the full list of options." msgstr "" -#: ../../library/tkinter.rst:4268 +#: ../../library/tkinter.rst:4325 msgid "" "Many of the methods take an *index* argument identifying a particular item. " "As described in the Tk ``listbox`` manual page, *index* may be a numeric " @@ -5770,20 +5812,20 @@ msgid "" "named *first* and *last* are indices of the same forms." msgstr "" -#: ../../library/tkinter.rst:4279 +#: ../../library/tkinter.rst:4336 msgid "" "Insert the given *elements* as new items just before the item given by " "*index*. If *index* is ``'end'``, the new items are appended to the end of " "the list." msgstr "" -#: ../../library/tkinter.rst:4286 +#: ../../library/tkinter.rst:4343 msgid "" "Delete the items in the range from *first* to *last* inclusive. If *last* is " "omitted, it defaults to *first*, so that a single item is deleted." msgstr "" -#: ../../library/tkinter.rst:4292 +#: ../../library/tkinter.rst:4349 msgid "" "If *last* is omitted, return the contents of the item given by *first*, or " "an empty string if *first* refers to a non-existent item. If *last* is " @@ -5791,24 +5833,24 @@ msgid "" "inclusive." msgstr "" -#: ../../library/tkinter.rst:4299 +#: ../../library/tkinter.rst:4356 msgid "Return the total number of items in the listbox." msgstr "" -#: ../../library/tkinter.rst:4301 +#: ../../library/tkinter.rst:4358 msgid "" "This shadows the inherited :meth:`!Misc.size`; use :meth:`~Misc.grid_size` " "for the grid size." msgstr "" -#: ../../library/tkinter.rst:4306 +#: ../../library/tkinter.rst:4363 msgid "" "Return the integer index value corresponding to *index*, or ``None`` if " "*index* is out of range. If *index* is ``'end'``, the result is a count of " "the number of items in the listbox (not the index of the last item)." msgstr "" -#: ../../library/tkinter.rst:4313 +#: ../../library/tkinter.rst:4370 msgid "" "Return a tuple ``(x, y, width, height)`` describing the bounding box, in " "pixels relative to the widget, of the text of the item given by *index*. " @@ -5818,13 +5860,13 @@ msgid "" "are not visible." msgstr "" -#: ../../library/tkinter.rst:4325 +#: ../../library/tkinter.rst:4382 msgid "" "Given a y-coordinate within the listbox window, return the index of the " "visible item nearest to that y-coordinate." msgstr "" -#: ../../library/tkinter.rst:4330 +#: ../../library/tkinter.rst:4387 msgid "" "Adjust the view so that the item given by *index* is visible. If the item is " "already visible the method has no effect; if it is near an edge of the " @@ -5832,7 +5874,7 @@ msgid "" "otherwise the listbox scrolls to center the item." msgstr "" -#: ../../library/tkinter.rst:4337 +#: ../../library/tkinter.rst:4394 msgid "" "Set the active item to the one given by *index*. If *index* is outside the " "range of items, the closest item is activated instead. The active item is " @@ -5840,13 +5882,13 @@ msgid "" "focus, and its index may be retrieved with the ``'active'`` index." msgstr "" -#: ../../library/tkinter.rst:4346 +#: ../../library/tkinter.rst:4403 msgid "" "Return a tuple containing the numerical indices of all of the items that are " "currently selected, or an empty tuple if no items are selected." msgstr "" -#: ../../library/tkinter.rst:4354 +#: ../../library/tkinter.rst:4411 msgid "" "Set the selection anchor to the item given by *index*. If *index* refers to " "a non-existent item, the closest item is used. The selection anchor is the " @@ -5855,40 +5897,40 @@ msgid "" "`select_anchor` is an alias of :meth:`!selection_anchor`." msgstr "" -#: ../../library/tkinter.rst:4366 +#: ../../library/tkinter.rst:4423 msgid "" "Deselect any of the items in the range from *first* to *last* inclusive that " "are selected. The selection state of items outside this range is not " "changed. :meth:`select_clear` is an alias of :meth:`!selection_clear`." msgstr "" -#: ../../library/tkinter.rst:4373 +#: ../../library/tkinter.rst:4430 msgid "" "This shadows the inherited :meth:`Misc.selection_clear`, which clears the X " "selection; that method is not available on a :class:`Listbox`." msgstr "" -#: ../../library/tkinter.rst:4382 +#: ../../library/tkinter.rst:4439 msgid "" "Return ``True`` if the item given by *index* is currently selected, " "``False`` otherwise. :meth:`select_includes` is an alias of :meth:`!" "selection_includes`." msgstr "" -#: ../../library/tkinter.rst:4391 +#: ../../library/tkinter.rst:4448 msgid "" "Select all of the items in the range from *first* to *last* inclusive, " "without affecting the selection state of items outside that range. :meth:" "`select_set` is an alias of :meth:`!selection_set`." msgstr "" -#: ../../library/tkinter.rst:4397 +#: ../../library/tkinter.rst:4454 msgid "" "Return the current value of the configuration option *option* for the item " "given by *index*." msgstr "" -#: ../../library/tkinter.rst:4405 +#: ../../library/tkinter.rst:4462 msgid "" "Query or modify the configuration options of the item given by *index*. This " "mirrors :meth:`~Misc.configure`, except that it applies to an individual " @@ -5899,7 +5941,7 @@ msgid "" "of :meth:`!itemconfigure`." msgstr "" -#: ../../library/tkinter.rst:4422 +#: ../../library/tkinter.rst:4479 msgid "" "Scroll the listbox by 10 times the difference between *x*, *y* and the " "coordinates passed to the last :meth:`scan_mark` call. This is typically " @@ -5907,7 +5949,7 @@ msgid "" "the list at high speed through the window." msgstr "" -#: ../../library/tkinter.rst:4430 +#: ../../library/tkinter.rst:4487 msgid "" "A :class:`!Menu` widget displays a column of entries, each of which may be a " "command, a checkbutton, a radiobutton, a cascade (which posts an associated " @@ -5916,7 +5958,7 @@ msgid "" "menus. Inherits from :class:`Widget`." msgstr "" -#: ../../library/tkinter.rst:4437 +#: ../../library/tkinter.rst:4494 msgid "" "Many of the entry methods take an *index* argument that selects which entry " "to operate on. As described in the Tk ``menu`` manual page, *index* may be a " @@ -5927,7 +5969,7 @@ msgid "" "of the entries from the top down." msgstr "" -#: ../../library/tkinter.rst:4448 +#: ../../library/tkinter.rst:4505 msgid "" "Add a new entry to the bottom of the menu. *itemType* is one of " "``'command'``, ``'cascade'``, ``'checkbutton'``, ``'radiobutton'`` or " @@ -5937,177 +5979,177 @@ msgid "" "convenience methods call this method with the corresponding *itemType*." msgstr "" -#: ../../library/tkinter.rst:4456 +#: ../../library/tkinter.rst:4513 msgid "" "The entry is configured by the following options, although not every option " "applies to every entry type (a separator accepts none of them):" msgstr "" -#: ../../library/tkinter.rst:4459 +#: ../../library/tkinter.rst:4516 msgid "*label*" msgstr "" -#: ../../library/tkinter.rst:4460 +#: ../../library/tkinter.rst:4517 msgid "The text to display in the entry." msgstr "" -#: ../../library/tkinter.rst:4462 +#: ../../library/tkinter.rst:4519 msgid "*command*" msgstr "*command*" -#: ../../library/tkinter.rst:4463 +#: ../../library/tkinter.rst:4520 msgid "" "The function to call when the entry is invoked (command, checkbutton and " "radiobutton entries)." msgstr "" -#: ../../library/tkinter.rst:4466 +#: ../../library/tkinter.rst:4523 msgid "*accelerator*" msgstr "" -#: ../../library/tkinter.rst:4467 +#: ../../library/tkinter.rst:4524 msgid "" "A string displayed at the right of the entry to advertise an accelerator " "keystroke; it does not itself create the binding." msgstr "" -#: ../../library/tkinter.rst:4471 +#: ../../library/tkinter.rst:4528 msgid "" "The index of a character in the label to underline for keyboard traversal." msgstr "" -#: ../../library/tkinter.rst:4475 +#: ../../library/tkinter.rst:4532 msgid "One of ``'normal'``, ``'active'`` or ``'disabled'``." msgstr "" -#: ../../library/tkinter.rst:4478 +#: ../../library/tkinter.rst:4535 msgid "An image to display instead of, or together with, the text label." msgstr "" -#: ../../library/tkinter.rst:4480 +#: ../../library/tkinter.rst:4537 msgid "*compound*" msgstr "" -#: ../../library/tkinter.rst:4481 +#: ../../library/tkinter.rst:4538 msgid "" "Where to show the image relative to the text: ``'none'`` (the default), " "``'text'``, ``'image'``, ``'top'``, ``'bottom'``, ``'left'`` or ``'right'``." msgstr "" -#: ../../library/tkinter.rst:4486 +#: ../../library/tkinter.rst:4543 msgid "A bitmap to display instead of the text label." msgstr "" -#: ../../library/tkinter.rst:4489 ../../library/tkinter.rst:5373 +#: ../../library/tkinter.rst:4546 ../../library/tkinter.rst:5430 msgid "The font to use for the text." msgstr "" -#: ../../library/tkinter.rst:4492 +#: ../../library/tkinter.rst:4549 msgid "" "The entry's background and foreground colors in its normal state (ignored on " "macOS)." msgstr "" -#: ../../library/tkinter.rst:4495 +#: ../../library/tkinter.rst:4552 msgid "*activebackground*, *activeforeground*" msgstr "" -#: ../../library/tkinter.rst:4496 +#: ../../library/tkinter.rst:4553 msgid "" "The background and foreground colors used when the entry is active (ignored " "on macOS)." msgstr "" -#: ../../library/tkinter.rst:4499 +#: ../../library/tkinter.rst:4556 msgid "*columnbreak*" msgstr "" -#: ../../library/tkinter.rst:4500 +#: ../../library/tkinter.rst:4557 msgid "" "If true, the entry starts a new column instead of being placed below the " "previous entry." msgstr "" -#: ../../library/tkinter.rst:4503 +#: ../../library/tkinter.rst:4560 msgid "*hidemargin*" msgstr "" -#: ../../library/tkinter.rst:4504 +#: ../../library/tkinter.rst:4561 msgid "" "If true, the standard margin around the entry is omitted, which is useful " "when a menu is used as a palette." msgstr "" -#: ../../library/tkinter.rst:4507 +#: ../../library/tkinter.rst:4564 msgid "*menu*" msgstr "" -#: ../../library/tkinter.rst:4508 +#: ../../library/tkinter.rst:4565 msgid "The submenu posted by a cascade entry; it must be a child of this menu." msgstr "" -#: ../../library/tkinter.rst:4511 +#: ../../library/tkinter.rst:4568 msgid "*variable*" msgstr "" -#: ../../library/tkinter.rst:4512 +#: ../../library/tkinter.rst:4569 msgid "The variable associated with a checkbutton or radiobutton entry." msgstr "" -#: ../../library/tkinter.rst:4514 +#: ../../library/tkinter.rst:4571 msgid "*onvalue*, *offvalue*" msgstr "" -#: ../../library/tkinter.rst:4515 +#: ../../library/tkinter.rst:4572 msgid "" "The values stored in *variable* when a checkbutton entry is selected or " "cleared." msgstr "" -#: ../../library/tkinter.rst:4518 +#: ../../library/tkinter.rst:4575 msgid "*value*" msgstr "" -#: ../../library/tkinter.rst:4519 +#: ../../library/tkinter.rst:4576 msgid "The value stored in *variable* when a radiobutton entry is selected." msgstr "" -#: ../../library/tkinter.rst:4521 +#: ../../library/tkinter.rst:4578 msgid "*indicatoron*" msgstr "" -#: ../../library/tkinter.rst:4522 +#: ../../library/tkinter.rst:4579 msgid "Whether to display the indicator of a checkbutton or radiobutton entry." msgstr "" -#: ../../library/tkinter.rst:4525 +#: ../../library/tkinter.rst:4582 msgid "*selectcolor*" msgstr "" -#: ../../library/tkinter.rst:4526 +#: ../../library/tkinter.rst:4583 msgid "" "The color of the indicator of a checkbutton or radiobutton entry when it is " "selected." msgstr "" -#: ../../library/tkinter.rst:4529 +#: ../../library/tkinter.rst:4586 msgid "*selectimage*" msgstr "" -#: ../../library/tkinter.rst:4530 +#: ../../library/tkinter.rst:4587 msgid "" "The image displayed when a checkbutton or radiobutton entry is selected and " "*image* is also given." msgstr "" -#: ../../library/tkinter.rst:4535 +#: ../../library/tkinter.rst:4592 msgid "" "Add a new cascade entry to the bottom of the menu. A cascade entry has an " "associated submenu, given by its *menu* option, which must be a child of " "this menu; posting the entry posts the submenu next to it." msgstr "" -#: ../../library/tkinter.rst:4542 +#: ../../library/tkinter.rst:4599 msgid "" "Add a new checkbutton entry to the bottom of the menu. When invoked, a " "checkbutton entry toggles between its *onvalue* and *offvalue*, storing the " @@ -6115,27 +6157,27 @@ msgid "" "whether it is selected." msgstr "" -#: ../../library/tkinter.rst:4549 +#: ../../library/tkinter.rst:4606 msgid "" "Add a new command entry to the bottom of the menu. A command entry behaves " "much like a button: when it is invoked, the callback given by its *command* " "option is called." msgstr "" -#: ../../library/tkinter.rst:4555 +#: ../../library/tkinter.rst:4612 msgid "" "Add a new radiobutton entry to the bottom of the menu. Radiobutton entries " "sharing the same *variable* form a group of which only one may be selected " "at a time; selecting an entry stores its *value* in the variable." msgstr "" -#: ../../library/tkinter.rst:4562 +#: ../../library/tkinter.rst:4619 msgid "" "Add a separator to the bottom of the menu. A separator is displayed as a " "horizontal dividing line and cannot be activated or invoked." msgstr "" -#: ../../library/tkinter.rst:4568 +#: ../../library/tkinter.rst:4625 msgid "" "Same as :meth:`add`, except that the new entry is inserted just before the " "entry given by *index* instead of being appended to the end of the menu. " @@ -6146,37 +6188,37 @@ msgid "" "corresponding *itemType*." msgstr "" -#: ../../library/tkinter.rst:4580 +#: ../../library/tkinter.rst:4637 msgid "" "Insert a new cascade entry before the entry given by *index* (see :meth:" "`add_cascade`)." msgstr "" -#: ../../library/tkinter.rst:4585 +#: ../../library/tkinter.rst:4642 msgid "" "Insert a new checkbutton entry before the entry given by *index* (see :meth:" "`add_checkbutton`)." msgstr "" -#: ../../library/tkinter.rst:4590 +#: ../../library/tkinter.rst:4647 msgid "" "Insert a new command entry before the entry given by *index* (see :meth:" "`add_command`)." msgstr "" -#: ../../library/tkinter.rst:4595 +#: ../../library/tkinter.rst:4652 msgid "" "Insert a new radiobutton entry before the entry given by *index* (see :meth:" "`add_radiobutton`)." msgstr "" -#: ../../library/tkinter.rst:4600 +#: ../../library/tkinter.rst:4657 msgid "" "Insert a separator before the entry given by *index* (see :meth:" "`add_separator`)." msgstr "" -#: ../../library/tkinter.rst:4605 +#: ../../library/tkinter.rst:4662 msgid "" "Delete all of the menu entries between *index1* and *index2* inclusive. If " "*index2* is omitted, it defaults to *index1*, so that a single entry is " @@ -6184,13 +6226,13 @@ msgid "" "changing the *tearoff* option instead." msgstr "" -#: ../../library/tkinter.rst:4613 +#: ../../library/tkinter.rst:4670 msgid "" "Return the current value of the configuration option *option* for the entry " "given by *index*." msgstr "" -#: ../../library/tkinter.rst:4621 +#: ../../library/tkinter.rst:4678 msgid "" "Query or modify the configuration options of the entry given by *index*. " "This mirrors :meth:`~Misc.configure`, except that it applies to an " @@ -6201,20 +6243,20 @@ msgid "" "entryconfigure`." msgstr "" -#: ../../library/tkinter.rst:4632 +#: ../../library/tkinter.rst:4689 msgid "" "Return the numerical index corresponding to *index*, or ``None`` if *index* " "selects no entry." msgstr "" -#: ../../library/tkinter.rst:4637 +#: ../../library/tkinter.rst:4694 msgid "" "Return the type of the entry given by *index*: one of ``'command'``, " "``'cascade'``, ``'checkbutton'``, ``'radiobutton'``, ``'separator'`` or " "``'tearoff'`` (for the tear-off entry)." msgstr "" -#: ../../library/tkinter.rst:4643 +#: ../../library/tkinter.rst:4700 msgid "" "Make the entry given by *index* the active entry, redisplaying it with its " "active colors, and deactivate any previously active entry. If *index* " @@ -6222,7 +6264,7 @@ msgid "" "no active entry." msgstr "" -#: ../../library/tkinter.rst:4650 +#: ../../library/tkinter.rst:4707 msgid "" "Invoke the action of the entry given by *index*, as if it had been clicked. " "Nothing happens if the entry is disabled. If the entry has a *command* " @@ -6230,7 +6272,7 @@ msgid "" "result is an empty string." msgstr "" -#: ../../library/tkinter.rst:4658 +#: ../../library/tkinter.rst:4715 msgid "" "Display the menu on the screen at the root-window coordinates *x* and *y*, " "adjusting them if necessary so that the whole menu is visible. If the " @@ -6238,33 +6280,33 @@ msgid "" "posted." msgstr "" -#: ../../library/tkinter.rst:4665 +#: ../../library/tkinter.rst:4722 msgid "" "Post the menu as a popup at the root-window coordinates *x* and *y*. If " "*entry* is given, the menu is positioned so that this entry is displayed " "under the pointer." msgstr "" -#: ../../library/tkinter.rst:4671 +#: ../../library/tkinter.rst:4728 msgid "" "Unmap the menu so that it is no longer displayed, also unposting any posted " "lower-level cascaded submenu. This has no effect on Windows and macOS, which " "manage the unposting of menus themselves." msgstr "" -#: ../../library/tkinter.rst:4678 +#: ../../library/tkinter.rst:4735 msgid "" "Return the x-coordinate, within the menu window, of the leftmost pixel of " "the entry given by *index*." msgstr "" -#: ../../library/tkinter.rst:4685 +#: ../../library/tkinter.rst:4742 msgid "" "Return the y-coordinate, within the menu window, of the topmost pixel of the " "entry given by *index*." msgstr "" -#: ../../library/tkinter.rst:4691 +#: ../../library/tkinter.rst:4748 msgid "" "A :class:`!Menubutton` widget displays a textual string, bitmap or image and " "posts an associated :class:`Menu`, given by its *menu* option, when the user " @@ -6274,7 +6316,7 @@ msgid "" "``menubutton`` manual page for the full list of options." msgstr "" -#: ../../library/tkinter.rst:4703 +#: ../../library/tkinter.rst:4760 msgid "" "A :class:`!Message` widget displays a non-interactive textual string, given " "by the *text* option or linked to a variable through *textvariable*. Unlike " @@ -6285,7 +6327,7 @@ msgid "" "options." msgstr "" -#: ../../library/tkinter.rst:4714 +#: ../../library/tkinter.rst:4771 msgid "" "A helper subclass of :class:`Menubutton` that displays a pop-up menu of " "mutually exclusive choices. *variable* is a :class:`Variable` kept in sync " @@ -6295,15 +6337,15 @@ msgid "" "*name* sets the Tk widget name." msgstr "" -#: ../../library/tkinter.rst:4723 +#: ../../library/tkinter.rst:4780 msgid "Destroy the widget, also cleaning up the associated pop-up menu." msgstr "" -#: ../../library/tkinter.rst:4725 +#: ../../library/tkinter.rst:4782 msgid "Added support for the *name* keyword argument." msgstr "" -#: ../../library/tkinter.rst:4732 +#: ../../library/tkinter.rst:4789 msgid "" "A :class:`!PanedWindow` is a geometry-manager widget that arranges any " "number of child *panes* in a row (when *orient* is ``'horizontal'``) or a " @@ -6313,7 +6355,7 @@ msgid "" "from :class:`Widget`." msgstr "" -#: ../../library/tkinter.rst:4740 +#: ../../library/tkinter.rst:4797 msgid "" "The *orient* option selects the layout direction, *sashwidth* sets the width " "of each sash and *sashrelief* its relief. When *showhandle* is true a small " @@ -6321,14 +6363,14 @@ msgid "" "Tk ``panedwindow`` manual page for the full list of options." msgstr "" -#: ../../library/tkinter.rst:4748 +#: ../../library/tkinter.rst:4805 msgid "" "Add *child* to the panedwindow as a new pane, placed after any existing " "panes. The keyword arguments specify per-pane management options for " "*child*; they may be any of the options accepted by :meth:`paneconfigure`." msgstr "" -#: ../../library/tkinter.rst:4758 +#: ../../library/tkinter.rst:4815 msgid "" "Remove the pane containing *child* from the panedwindow. All geometry " "management options for *child* are forgotten. :meth:`forget` is an alias of :" @@ -6337,20 +6379,20 @@ msgid "" "place_forget` to remove the widget itself from its manager." msgstr "" -#: ../../library/tkinter.rst:4767 +#: ../../library/tkinter.rst:4824 msgid "" "Return a tuple of the widgets managed by the panedwindow, one per pane, in " "order." msgstr "" -#: ../../library/tkinter.rst:4772 +#: ../../library/tkinter.rst:4829 msgid "" "Return the current value of the management option *option* for the pane " "containing *child*. *option* may be any value allowed by :meth:" "`paneconfigure`." msgstr "" -#: ../../library/tkinter.rst:4781 +#: ../../library/tkinter.rst:4838 msgid "" "Query or modify the management options of the pane containing the widget " "*tagOrId*. With no options, it returns a dictionary describing all of the " @@ -6368,7 +6410,7 @@ msgid "" "an alias of :meth:`!paneconfigure`." msgstr "" -#: ../../library/tkinter.rst:4799 +#: ../../library/tkinter.rst:4856 msgid "" "Identify the panedwindow component underneath the point given by *x* and " "*y*, in window coordinates. If the point is over a sash or a sash handle, " @@ -6378,7 +6420,7 @@ msgid "" "panedwindow, the result is an empty string." msgstr "" -#: ../../library/tkinter.rst:4810 +#: ../../library/tkinter.rst:4867 msgid "" "Query or change the position of the sashes in the panedwindow. This is a " "thin wrapper around the Tk ``sash`` subcommand; the convenience methods :" @@ -6386,7 +6428,7 @@ msgid "" "be used instead." msgstr "" -#: ../../library/tkinter.rst:4817 +#: ../../library/tkinter.rst:4874 msgid "" "Return the current x and y coordinate pair for the sash given by *index*, " "which must be an integer between 0 and one less than the number of panes in " @@ -6394,17 +6436,17 @@ msgid "" "of the region containing the sash." msgstr "" -#: ../../library/tkinter.rst:4825 +#: ../../library/tkinter.rst:4882 msgid "" "Record the current mouse position for the sash given by *index*, for use " "together with later sash-drag operations to move the sash." msgstr "" -#: ../../library/tkinter.rst:4830 +#: ../../library/tkinter.rst:4887 msgid "Place the sash given by *index* at the coordinates *x* and *y*." msgstr "" -#: ../../library/tkinter.rst:4834 +#: ../../library/tkinter.rst:4891 msgid "" "Query or change the position of the sash proxy, the \"ghost\" sash shown " "while a sash is being dragged with non-opaque resizing. This is a thin " @@ -6413,21 +6455,21 @@ msgid "" "be used instead." msgstr "" -#: ../../library/tkinter.rst:4842 +#: ../../library/tkinter.rst:4899 msgid "" "Return a tuple containing the x and y coordinates of the most recent proxy " "location." msgstr "" -#: ../../library/tkinter.rst:4847 +#: ../../library/tkinter.rst:4904 msgid "Remove the proxy from the display." msgstr "" -#: ../../library/tkinter.rst:4851 +#: ../../library/tkinter.rst:4908 msgid "Place the proxy at the coordinates *x* and *y*." msgstr "" -#: ../../library/tkinter.rst:4856 +#: ../../library/tkinter.rst:4913 msgid "" "A :class:`!Radiobutton` widget displays a textual string, bitmap or image " "together with a diamond or circular indicator, and selects one choice out of " @@ -6441,7 +6483,7 @@ msgid "" "*variable*, *value* and *command*." msgstr "" -#: ../../library/tkinter.rst:4871 +#: ../../library/tkinter.rst:4928 msgid "" "Do just what would happen if the user pressed the radiobutton with the " "mouse: select the button and invoke the associated command, if there is one. " @@ -6450,19 +6492,19 @@ msgid "" "is ``disabled``." msgstr "" -#: ../../library/tkinter.rst:4880 +#: ../../library/tkinter.rst:4937 msgid "" "Select the radiobutton and set the associated variable to the value " "corresponding to this widget." msgstr "" -#: ../../library/tkinter.rst:4885 +#: ../../library/tkinter.rst:4942 msgid "" "Deselect the radiobutton and set the associated variable to an empty string. " "If this radiobutton was not currently selected, this has no effect." msgstr "" -#: ../../library/tkinter.rst:4891 +#: ../../library/tkinter.rst:4948 msgid "" "Flash the radiobutton by redisplaying it several times, alternating between " "the active and normal colors. At the end of the flash the radiobutton is " @@ -6470,7 +6512,7 @@ msgid "" "is ignored if the radiobutton's state is ``disabled``." msgstr "" -#: ../../library/tkinter.rst:4900 +#: ../../library/tkinter.rst:4957 msgid "" "A :class:`!Scale` widget lets the user select a numerical value by moving a " "slider along a trough. It can be oriented vertically or horizontally and can " @@ -6478,7 +6520,7 @@ msgid "" "`Widget`." msgstr "" -#: ../../library/tkinter.rst:4906 +#: ../../library/tkinter.rst:4963 msgid "" "In addition to the standard widget options, a scale accepts the options " "documented in the Tk ``scale`` manual page, such as *from_*, *to*, " @@ -6488,32 +6530,32 @@ msgid "" "keyword." msgstr "" -#: ../../library/tkinter.rst:4913 +#: ../../library/tkinter.rst:4970 msgid "" "With a non-integer *resolution*, see :ref:`numeric values and the locale " "`." msgstr "" -#: ../../library/tkinter.rst:4918 +#: ../../library/tkinter.rst:4975 msgid "" "Return the current value of the scale. The result is an integer if the " "scale's *resolution* yields whole numbers, and a float otherwise." msgstr "" -#: ../../library/tkinter.rst:4924 +#: ../../library/tkinter.rst:4981 msgid "" "Set the scale to *value*, moving the slider accordingly. This has no effect " "if the scale is disabled." msgstr "" -#: ../../library/tkinter.rst:4929 +#: ../../library/tkinter.rst:4986 msgid "" "Return a tuple ``(x, y)`` giving the pixel coordinates, relative to the " "widget, of the point on the centerline of the trough that corresponds to " "*value*. If *value* is omitted, the scale's current value is used." msgstr "" -#: ../../library/tkinter.rst:4936 +#: ../../library/tkinter.rst:4993 msgid "" "Return a string describing the part of the scale at the pixel coordinates " "*x*, *y*: ``'slider'``, ``'trough1'`` (the part of the trough above or to " @@ -6521,7 +6563,7 @@ msgid "" "slider), or an empty string if the point is not over any of these elements." msgstr "" -#: ../../library/tkinter.rst:4945 +#: ../../library/tkinter.rst:5002 msgid "" "A :class:`!Scrollbar` widget displays a slider and two arrows that let the " "user scroll an associated widget, such as a :class:`Listbox`, :class:" @@ -6532,14 +6574,14 @@ msgid "" "method. Inherits from :class:`Widget`." msgstr "" -#: ../../library/tkinter.rst:4956 +#: ../../library/tkinter.rst:5013 msgid "" "Return the current scrollbar settings as a tuple ``(first, last)`` of two " "fractions between 0 and 1, describing the portion of the document that is " "currently visible, as last passed to :meth:`set`." msgstr "" -#: ../../library/tkinter.rst:4962 +#: ../../library/tkinter.rst:5019 msgid "" "Set the scrollbar. *first* and *last* are fractions between 0 and 1 giving " "the positions of the start and end of the visible portion of the associated " @@ -6547,7 +6589,7 @@ msgid "" "*xscrollcommand* or *yscrollcommand* and called by that widget." msgstr "" -#: ../../library/tkinter.rst:4970 +#: ../../library/tkinter.rst:5027 msgid "" "Mark the element *index* (one of ``'arrow1'``, ``'slider'`` or ``'arrow2'``) " "as active, displaying it according to the *activebackground* and " @@ -6555,11 +6597,11 @@ msgid "" "currently active element, or ``None`` if no element is active." msgstr "" -#: ../../library/tkinter.rst:4976 +#: ../../library/tkinter.rst:5033 msgid "The *index* argument is now optional." msgstr "" -#: ../../library/tkinter.rst:4981 +#: ../../library/tkinter.rst:5038 msgid "" "Return a float indicating the fractional change in the scrollbar setting " "that corresponds to moving the slider by *deltax* pixels horizontally (for " @@ -6567,21 +6609,21 @@ msgid "" "scrollbars)." msgstr "" -#: ../../library/tkinter.rst:4988 +#: ../../library/tkinter.rst:5045 msgid "" "Return a float between 0 and 1 indicating where the point at pixel " "coordinates *x*, *y* lies in the trough: 0 corresponds to the top or left of " "the trough and 1 to the bottom or right." msgstr "" -#: ../../library/tkinter.rst:4994 +#: ../../library/tkinter.rst:5051 msgid "" "Return the name of the element under the pixel coordinates *x*, *y* (such as " "``'arrow1'``), or an empty string if the point does not lie in any element " "of the scrollbar." msgstr "" -#: ../../library/tkinter.rst:5001 +#: ../../library/tkinter.rst:5058 msgid "" "A :class:`!Spinbox` widget is an :class:`Entry`-like widget with a pair of " "up/down arrow buttons that let the user step through a range of values in " @@ -6595,13 +6637,13 @@ msgid "" "of the entered text. Inherits from :class:`Widget` and :class:`XView`." msgstr "" -#: ../../library/tkinter.rst:5014 +#: ../../library/tkinter.rst:5071 msgid "" "With a non-integer *increment*, see :ref:`numeric values and the locale " "`." msgstr "" -#: ../../library/tkinter.rst:5017 +#: ../../library/tkinter.rst:5074 msgid "" "Many of the methods take an *index* argument identifying a character in the " "spinbox's string. As described in the Tk ``spinbox`` manual page, *index* " @@ -6612,17 +6654,17 @@ msgid "" "x-coordinate *x* in the window)." msgstr "" -#: ../../library/tkinter.rst:5028 +#: ../../library/tkinter.rst:5085 msgid "Return the spinbox's string." msgstr "" -#: ../../library/tkinter.rst:5032 +#: ../../library/tkinter.rst:5089 msgid "" "Insert the characters of the string *s* just before the character given by " "*index*." msgstr "" -#: ../../library/tkinter.rst:5037 +#: ../../library/tkinter.rst:5094 msgid "" "Delete one or more characters of the spinbox. *first* is the index of the " "first character to delete, and *last* is the index of the character just " @@ -6630,11 +6672,11 @@ msgid "" "*first* is deleted." msgstr "" -#: ../../library/tkinter.rst:5049 +#: ../../library/tkinter.rst:5106 msgid "Return the numerical index corresponding to *index*, as a string." msgstr "" -#: ../../library/tkinter.rst:5053 +#: ../../library/tkinter.rst:5110 msgid "" "Return a tuple of four integers ``(x, y, width, height)`` describing the " "bounding box of the character given by *index*. *x* and *y* are the pixel " @@ -6643,19 +6685,19 @@ msgid "" "may refer to a region outside the visible area of the window." msgstr "" -#: ../../library/tkinter.rst:5066 +#: ../../library/tkinter.rst:5123 msgid "" "Return the name of the window element at the pixel coordinates *x*, *y*: one " "of ``'buttondown'``, ``'buttonup'``, ``'entry'`` or ``'none'``." msgstr "" -#: ../../library/tkinter.rst:5071 +#: ../../library/tkinter.rst:5128 msgid "" "Invoke the spin button given by *element*, either ``'buttonup'`` or " "``'buttondown'``, triggering the action associated with it." msgstr "" -#: ../../library/tkinter.rst:5076 +#: ../../library/tkinter.rst:5133 msgid "" "A thin wrapper around the Tk ``scan`` widget subcommand, used to implement " "fast dragging of the view: ``scan('mark', x)`` records *x* and the current " @@ -6663,14 +6705,14 @@ msgid "" "meth:`scan_mark` and :meth:`scan_dragto` methods wrap the two forms." msgstr "" -#: ../../library/tkinter.rst:5084 +#: ../../library/tkinter.rst:5141 msgid "" "Record *x* and the current view in the spinbox window, for use with a later :" "meth:`scan_dragto` call. This is typically associated with a mouse button " "press in the widget." msgstr "" -#: ../../library/tkinter.rst:5090 +#: ../../library/tkinter.rst:5147 msgid "" "Adjust the view by 10 times the difference between *x* and the *x* passed to " "the last :meth:`scan_mark` call. This is typically associated with mouse " @@ -6678,7 +6720,7 @@ msgid "" "through the window." msgstr "" -#: ../../library/tkinter.rst:5097 +#: ../../library/tkinter.rst:5154 msgid "" "A thin wrapper around the Tk ``selection`` widget subcommand, used to adjust " "the selection within the spinbox. It has several forms depending on the " @@ -6691,7 +6733,7 @@ msgid "" "methods wrap these forms." msgstr "" -#: ../../library/tkinter.rst:5111 +#: ../../library/tkinter.rst:5168 msgid "" "Locate the end of the selection nearest to the character given by *index* " "and adjust that end of the selection to be at *index* (including but not " @@ -6701,19 +6743,19 @@ msgid "" "most recent anchor point, inclusive." msgstr "" -#: ../../library/tkinter.rst:5122 +#: ../../library/tkinter.rst:5179 msgid "" "Clear the selection if it is currently in this widget. If the selection is " "not in this widget, the method has no effect." msgstr "" -#: ../../library/tkinter.rst:5127 +#: ../../library/tkinter.rst:5184 msgid "" "This shadows the inherited :meth:`Misc.selection_clear`, which clears the X " "selection; that method is not available on a :class:`Spinbox`." msgstr "" -#: ../../library/tkinter.rst:5133 +#: ../../library/tkinter.rst:5190 msgid "" "Set or get the currently selected element. If *element* (one of " "``'buttonup'``, ``'buttondown'`` or ``'none'``) is given, that spin button " @@ -6721,26 +6763,26 @@ msgid "" "selected element is returned." msgstr "" -#: ../../library/tkinter.rst:5140 +#: ../../library/tkinter.rst:5197 msgid "" "Set the selection anchor point to just before the character given by " "*index*, without changing the selection itself." msgstr "" -#: ../../library/tkinter.rst:5148 +#: ../../library/tkinter.rst:5205 msgid "" "Return ``True`` if there are characters selected in the spinbox, ``False`` " "otherwise." msgstr "" -#: ../../library/tkinter.rst:5156 +#: ../../library/tkinter.rst:5213 msgid "" "Set the selection to include the characters starting with the one indexed by " "*start* and ending with the one just before *end*. If *end* refers to the " "same character as *start* or an earlier one, the selection is cleared." msgstr "" -#: ../../library/tkinter.rst:5166 +#: ../../library/tkinter.rst:5223 msgid "" "Set the selection between *index* and the anchor point. If *index* is before " "the anchor point, the selection runs from *index* up to but not including " @@ -6751,7 +6793,7 @@ msgid "" "selection is created using the most recent anchor point." msgstr "" -#: ../../library/tkinter.rst:5182 +#: ../../library/tkinter.rst:5239 msgid "" "A :class:`!Text` widget displays and edits multi-line text. Portions of the " "text may be styled with **tags**, particular positions may be annotated with " @@ -6764,7 +6806,7 @@ msgid "" "options." msgstr "" -#: ../../library/tkinter.rst:5193 +#: ../../library/tkinter.rst:5250 msgid "" "Most of the methods take one or more *index* arguments that identify a " "position within the text. As described in the Tk ``text`` manual page, an " @@ -6782,7 +6824,7 @@ msgid "" "right, for example ``'insert wordstart - 1 c'``." msgstr "" -#: ../../library/tkinter.rst:5211 +#: ../../library/tkinter.rst:5268 msgid "" "Insert the string *chars* just before the character at *index* (if *index* " "is ``'end'``, just before the final newline). By default the new text " @@ -6792,7 +6834,7 @@ msgid "" "name or a sequence of names), overriding the surrounding tags." msgstr "" -#: ../../library/tkinter.rst:5222 +#: ../../library/tkinter.rst:5279 msgid "" "Delete the range of characters from *index1* up to but not including " "*index2*. If *index2* is omitted, the single character at *index1* is " @@ -6800,34 +6842,34 @@ msgid "" "deletion that would remove it is adjusted accordingly." msgstr "" -#: ../../library/tkinter.rst:5230 +#: ../../library/tkinter.rst:5287 msgid "" "Replace the range of characters from *index1* up to but not including " "*index2* with *chars*. This is equivalent to a :meth:`delete` followed by " "an :meth:`insert` at *index1*; *args* is interpreted as for :meth:`insert`." msgstr "" -#: ../../library/tkinter.rst:5239 +#: ../../library/tkinter.rst:5296 msgid "" "Return the text from *index1* up to but not including *index2* as a string. " "If *index2* is omitted, return the single character at *index1*. Embedded " "images and windows are omitted from the result." msgstr "" -#: ../../library/tkinter.rst:5246 +#: ../../library/tkinter.rst:5303 msgid "" "Return the position corresponding to *index* in the canonical ``'line." "char'`` form." msgstr "" -#: ../../library/tkinter.rst:5251 +#: ../../library/tkinter.rst:5308 msgid "" "Compare the positions of *index1* and *index2* using the relational operator " "*op*, which must be one of ``'<'``, ``'<='``, ``'=='``, ``'>='``, ``'>'`` or " "``'!='``, and return the boolean result." msgstr "" -#: ../../library/tkinter.rst:5257 +#: ../../library/tkinter.rst:5314 msgid "" "Count the number of items of the requested kinds between *index1* and " "*index2*; the count is negative if *index1* is after *index2*. Each of " @@ -6841,11 +6883,11 @@ msgid "" "counting option (or ``None`` if the result is empty)." msgstr "" -#: ../../library/tkinter.rst:5271 +#: ../../library/tkinter.rst:5328 msgid "Added the *return_ints* parameter." msgstr "" -#: ../../library/tkinter.rst:5277 +#: ../../library/tkinter.rst:5334 msgid "" "Adjust the view so that the character given by *index* is visible. If it is " "already visible the method has no effect; if it is a short distance out of " @@ -6853,14 +6895,14 @@ msgid "" "otherwise it scrolls to center *index* in the window." msgstr "" -#: ../../library/tkinter.rst:5284 +#: ../../library/tkinter.rst:5341 msgid "" "Return a tuple ``(x, y, width, height)`` giving the bounding box, in pixels, " "of the visible part of the character at *index*, or ``None`` if that " "character is not visible on the screen." msgstr "" -#: ../../library/tkinter.rst:5293 +#: ../../library/tkinter.rst:5350 msgid "" "Return a tuple ``(x, y, width, height, baseline)`` describing the display " "line that contains *index*: the first four values give the bounding box of " @@ -6869,24 +6911,24 @@ msgid "" "visible on the screen." msgstr "" -#: ../../library/tkinter.rst:5301 +#: ../../library/tkinter.rst:5358 msgid "" "Set the mark named *markName* to the position just before the character at " "*index*, creating the mark if it does not already exist. A mark created this " "way has right gravity by default." msgstr "" -#: ../../library/tkinter.rst:5307 +#: ../../library/tkinter.rst:5364 msgid "" "Remove each of the marks named in *markNames*. The special ``insert`` and " "``current`` marks may not be removed." msgstr "" -#: ../../library/tkinter.rst:5312 +#: ../../library/tkinter.rst:5369 msgid "Return a tuple of the names of all marks currently set in the widget." msgstr "" -#: ../../library/tkinter.rst:5316 +#: ../../library/tkinter.rst:5373 msgid "" "If *direction* is omitted, return the gravity of mark *markName*, either " "``'left'`` or ``'right'``. Otherwise set its gravity to *direction*. The " @@ -6895,21 +6937,21 @@ msgid "" "of such text." msgstr "" -#: ../../library/tkinter.rst:5325 +#: ../../library/tkinter.rst:5382 msgid "" "Return the name of the first mark at or after *index*, or ``None`` if there " "is none. When *index* is the name of a mark, the search starts just after " "that mark." msgstr "" -#: ../../library/tkinter.rst:5332 +#: ../../library/tkinter.rst:5389 msgid "" "Return the name of the last mark at or before *index*, or ``None`` if there " "is none. When *index* is the name of a mark, the search starts just before " "that mark." msgstr "" -#: ../../library/tkinter.rst:5339 +#: ../../library/tkinter.rst:5396 msgid "" "Add the tag *tagName* to the range of characters from *index1* up to but not " "including the next index in *args*. Further pairs of indices may follow in " @@ -6917,20 +6959,20 @@ msgid "" "character at that index." msgstr "" -#: ../../library/tkinter.rst:5346 +#: ../../library/tkinter.rst:5403 msgid "" "Remove the tag *tagName* from the characters from *index1* up to but not " "including *index2* (or from the single character at *index1* if *index2* is " "omitted). The tag itself continues to exist even if no characters carry it." msgstr "" -#: ../../library/tkinter.rst:5353 +#: ../../library/tkinter.rst:5410 msgid "" "Delete each of the tags named in *tagNames*, removing them from all " "characters and discarding their options and bindings." msgstr "" -#: ../../library/tkinter.rst:5361 +#: ../../library/tkinter.rst:5418 msgid "" "Query or modify the configuration options of the tag *tagName*. This " "mirrors :meth:`~Misc.configure`, except that it applies to a tag rather than " @@ -6939,226 +6981,226 @@ msgid "" "this way also gives it a priority higher than any existing tag." msgstr "" -#: ../../library/tkinter.rst:5369 +#: ../../library/tkinter.rst:5426 msgid "" "The supported tag options, all controlling the appearance of the tagged " "text, are:" msgstr "" -#: ../../library/tkinter.rst:5375 +#: ../../library/tkinter.rst:5432 msgid "*foreground*" msgstr "" -#: ../../library/tkinter.rst:5376 +#: ../../library/tkinter.rst:5433 msgid "The color to use for the text." msgstr "" -#: ../../library/tkinter.rst:5378 +#: ../../library/tkinter.rst:5435 msgid "*background*" msgstr "" -#: ../../library/tkinter.rst:5379 +#: ../../library/tkinter.rst:5436 msgid "The color to use for the area behind the text." msgstr "" -#: ../../library/tkinter.rst:5381 +#: ../../library/tkinter.rst:5438 msgid "*fgstipple*, *bgstipple*" msgstr "" -#: ../../library/tkinter.rst:5382 +#: ../../library/tkinter.rst:5439 msgid "" "Bitmaps used to stipple the foreground (text) and the background; only well " "supported on X11." msgstr "" -#: ../../library/tkinter.rst:5385 +#: ../../library/tkinter.rst:5442 msgid "*borderwidth*" msgstr "" -#: ../../library/tkinter.rst:5386 +#: ../../library/tkinter.rst:5443 msgid "" "The width of the border drawn around the text according to *relief* (default " "``0``)." msgstr "" -#: ../../library/tkinter.rst:5389 +#: ../../library/tkinter.rst:5446 msgid "*relief*" msgstr "*relief*" -#: ../../library/tkinter.rst:5390 +#: ../../library/tkinter.rst:5447 msgid "" "The 3-D appearance of the text's border: ``'flat'`` (the default), " "``'raised'``, ``'sunken'``, ``'ridge'``, ``'groove'`` or ``'solid'``." msgstr "" -#: ../../library/tkinter.rst:5393 +#: ../../library/tkinter.rst:5450 msgid "*offset*" msgstr "" -#: ../../library/tkinter.rst:5394 +#: ../../library/tkinter.rst:5451 msgid "" "How far the text is raised above (or, if negative, lowered below) the " "baseline, for superscripts and subscripts." msgstr "" -#: ../../library/tkinter.rst:5398 +#: ../../library/tkinter.rst:5455 msgid "Whether to underline the text." msgstr "" -#: ../../library/tkinter.rst:5400 +#: ../../library/tkinter.rst:5457 msgid "*underlinefg*" msgstr "" -#: ../../library/tkinter.rst:5401 +#: ../../library/tkinter.rst:5458 msgid "The color of the underline; it defaults to the text color." msgstr "" -#: ../../library/tkinter.rst:5403 +#: ../../library/tkinter.rst:5460 msgid "*overstrike*" msgstr "" -#: ../../library/tkinter.rst:5404 +#: ../../library/tkinter.rst:5461 msgid "Whether to draw a line through the middle of the text." msgstr "" -#: ../../library/tkinter.rst:5406 +#: ../../library/tkinter.rst:5463 msgid "*overstrikefg*" msgstr "" -#: ../../library/tkinter.rst:5407 +#: ../../library/tkinter.rst:5464 msgid "The color of the overstrike line; it defaults to the text color." msgstr "" -#: ../../library/tkinter.rst:5409 +#: ../../library/tkinter.rst:5466 msgid "*elide*" msgstr "" -#: ../../library/tkinter.rst:5410 +#: ../../library/tkinter.rst:5467 msgid "Whether the text is elided (hidden)." msgstr "" -#: ../../library/tkinter.rst:5413 +#: ../../library/tkinter.rst:5470 msgid "" "How to justify the first character of a display line: ``'left'`` (the " "default), ``'right'`` or ``'center'``." msgstr "" -#: ../../library/tkinter.rst:5416 +#: ../../library/tkinter.rst:5473 msgid "*wrap*" msgstr "*wrap*" -#: ../../library/tkinter.rst:5417 +#: ../../library/tkinter.rst:5474 msgid "" "How to wrap lines that are too long: ``'char'``, ``'word'`` or ``'none'``." msgstr "" -#: ../../library/tkinter.rst:5420 +#: ../../library/tkinter.rst:5477 msgid "*lmargin1*, *lmargin2*" msgstr "" -#: ../../library/tkinter.rst:5421 +#: ../../library/tkinter.rst:5478 msgid "" "The indentation, in pixels, of the first display line of a logical line and " "of the remaining display lines." msgstr "" -#: ../../library/tkinter.rst:5424 +#: ../../library/tkinter.rst:5481 msgid "*lmargincolor*" msgstr "" -#: ../../library/tkinter.rst:5425 +#: ../../library/tkinter.rst:5482 msgid "The color of the left margin area." msgstr "" -#: ../../library/tkinter.rst:5427 +#: ../../library/tkinter.rst:5484 msgid "*rmargin*" msgstr "" -#: ../../library/tkinter.rst:5428 +#: ../../library/tkinter.rst:5485 msgid "The right-hand margin, in pixels." msgstr "" -#: ../../library/tkinter.rst:5430 +#: ../../library/tkinter.rst:5487 msgid "*rmargincolor*" msgstr "" -#: ../../library/tkinter.rst:5431 +#: ../../library/tkinter.rst:5488 msgid "The color of the right margin area." msgstr "" -#: ../../library/tkinter.rst:5433 +#: ../../library/tkinter.rst:5490 msgid "*spacing1*, *spacing2*, *spacing3*" msgstr "" -#: ../../library/tkinter.rst:5434 +#: ../../library/tkinter.rst:5491 msgid "" "Extra space, in pixels, above the first display line of a logical line, " "between its display lines, and below its last display line." msgstr "" -#: ../../library/tkinter.rst:5437 +#: ../../library/tkinter.rst:5494 msgid "*tabs*" msgstr "" -#: ../../library/tkinter.rst:5438 +#: ../../library/tkinter.rst:5495 msgid "The set of tab stops, in the same form as the widget's *tabs* option." msgstr "" -#: ../../library/tkinter.rst:5440 +#: ../../library/tkinter.rst:5497 msgid "*tabstyle*" msgstr "" -#: ../../library/tkinter.rst:5441 +#: ../../library/tkinter.rst:5498 msgid "How tab stops are interpreted: ``'tabular'`` or ``'wordprocessor'``." msgstr "" -#: ../../library/tkinter.rst:5443 +#: ../../library/tkinter.rst:5500 msgid "*selectbackground*, *selectforeground*" msgstr "" -#: ../../library/tkinter.rst:5444 +#: ../../library/tkinter.rst:5501 msgid "" "The background and foreground colors used for the text while it is selected." msgstr "" -#: ../../library/tkinter.rst:5449 +#: ../../library/tkinter.rst:5506 msgid "" "Tk 8.6 added the *lmargincolor*, *overstrikefg*, *rmargincolor*, " "*selectbackground*, *selectforeground* and *underlinefg* options." msgstr "" -#: ../../library/tkinter.rst:5452 +#: ../../library/tkinter.rst:5509 msgid ":meth:`tag_config` is an alias of :meth:`!tag_configure`." msgstr "" -#: ../../library/tkinter.rst:5456 +#: ../../library/tkinter.rst:5513 msgid "" "Return the current value of the configuration option *option* for the tag " "*tagName*." msgstr "" -#: ../../library/tkinter.rst:5461 +#: ../../library/tkinter.rst:5518 msgid "" "If *index* is omitted, return a tuple of the names of all tags defined in " "the widget; otherwise return only the names of the tags applied to the " "character at *index*. The names are ordered from lowest to highest priority." msgstr "" -#: ../../library/tkinter.rst:5468 +#: ../../library/tkinter.rst:5525 msgid "" "Return a tuple of indices describing all ranges of text tagged with " "*tagName*. The result alternates start and end indices, so that elements " "``2*i`` and ``2*i+1`` bound the *i*-th range." msgstr "" -#: ../../library/tkinter.rst:5475 +#: ../../library/tkinter.rst:5532 msgid "" "Search forward from *index1* (up to *index2* if given) for the first range " "of characters tagged with *tagName*, and return a two-element tuple of its " "start and end indices, or an empty tuple if there is no such range." msgstr "" -#: ../../library/tkinter.rst:5482 +#: ../../library/tkinter.rst:5539 msgid "" "Search backward from *index1* (down to *index2* if given) for the nearest " "preceding range of characters tagged with *tagName*, and return a two-" @@ -7166,7 +7208,7 @@ msgid "" "such range." msgstr "" -#: ../../library/tkinter.rst:5489 +#: ../../library/tkinter.rst:5546 msgid "" "Raise the priority of tag *tagName* so that it is just above the priority of " "*aboveThis*, or to the highest priority of all tags if *aboveThis* is " @@ -7174,13 +7216,13 @@ msgid "" "priority tag wins." msgstr "" -#: ../../library/tkinter.rst:5497 +#: ../../library/tkinter.rst:5554 msgid "" "Lower the priority of tag *tagName* so that it is just below the priority of " "*belowThis*, or to the lowest priority of all tags if *belowThis* is omitted." msgstr "" -#: ../../library/tkinter.rst:5503 +#: ../../library/tkinter.rst:5560 msgid "" "Bind the event *sequence* on characters tagged with *tagName* to the " "callback *func*, so that *func* is invoked when that event occurs over such " @@ -7189,14 +7231,14 @@ msgid "" "bind` and returns the identifier of the new binding." msgstr "" -#: ../../library/tkinter.rst:5513 +#: ../../library/tkinter.rst:5570 msgid "" "Remove the bindings of the event *sequence* on characters tagged with " "*tagName*. If *funcid* is given, only that binding (as returned by :meth:" "`tag_bind`) is removed and its callback is unregistered." msgstr "" -#: ../../library/tkinter.rst:5524 +#: ../../library/tkinter.rst:5581 msgid "" "Embed an image at *index* and return the name assigned to this image " "instance, which may then be used as an index or passed to the other " @@ -7205,30 +7247,30 @@ msgid "" "*padx* and *pady*." msgstr "" -#: ../../library/tkinter.rst:5533 +#: ../../library/tkinter.rst:5590 msgid "" "Return the current value of the configuration option *option* for the " "embedded image at *index*." msgstr "" -#: ../../library/tkinter.rst:5538 +#: ../../library/tkinter.rst:5595 msgid "" "Query or modify the configuration options of the embedded image at *index*, " "like :meth:`~Misc.configure` but applied to that image." msgstr "" -#: ../../library/tkinter.rst:5543 +#: ../../library/tkinter.rst:5600 msgid "Return a tuple of the names of all images embedded in the widget." msgstr "" -#: ../../library/tkinter.rst:5547 +#: ../../library/tkinter.rst:5604 msgid "" "This shadows the inherited :meth:`Misc.image_names`, which returns the names " "of all images in the Tcl interpreter; that method is not available on a :" "class:`Text`." msgstr "" -#: ../../library/tkinter.rst:5553 +#: ../../library/tkinter.rst:5610 msgid "" "Embed a window (any widget) at *index*. The options, given in *cnf* and " "*kw*, include *window* (the widget to embed), *create* (a callback that " @@ -7236,27 +7278,27 @@ msgid "" "embedded widget must be a descendant of the text widget's parent." msgstr "" -#: ../../library/tkinter.rst:5561 +#: ../../library/tkinter.rst:5618 msgid "" "Return the current value of the configuration option *option* for the " "embedded window at *index*." msgstr "" -#: ../../library/tkinter.rst:5569 +#: ../../library/tkinter.rst:5626 msgid "" "Query or modify the configuration options of the embedded window at *index*, " "like :meth:`~Misc.configure` but applied to that window." msgstr "" -#: ../../library/tkinter.rst:5572 +#: ../../library/tkinter.rst:5629 msgid ":meth:`window_config` is an alias of :meth:`!window_configure`." msgstr "" -#: ../../library/tkinter.rst:5576 +#: ../../library/tkinter.rst:5633 msgid "Return a tuple of the names of all windows embedded in the widget." msgstr "" -#: ../../library/tkinter.rst:5580 +#: ../../library/tkinter.rst:5637 msgid "" "Low-level wrapper around the Tk ``edit`` widget command that controls the " "undo/redo mechanism and the modified flag; *args* is the ``edit`` subcommand " @@ -7264,14 +7306,14 @@ msgid "" "around it and are usually more convenient." msgstr "" -#: ../../library/tkinter.rst:5588 +#: ../../library/tkinter.rst:5645 msgid "" "If *arg* is omitted, return the current state of the modified flag as true " "or false; the flag is set automatically whenever the text is inserted or " "deleted. Otherwise set the flag to the boolean *arg*." msgstr "" -#: ../../library/tkinter.rst:5595 +#: ../../library/tkinter.rst:5652 msgid "" "Undo the most recent edit action, that is, all the inserts and deletes " "recorded on the undo stack since the previous separator, and move it to the " @@ -7280,7 +7322,7 @@ msgid "" "delimiting the ranges of text that were changed." msgstr "" -#: ../../library/tkinter.rst:5605 +#: ../../library/tkinter.rst:5662 msgid "" "Reapply the most recently undone edit action, provided no further edits have " "been made since, and move it back to the undo stack. Raises :exc:`TclError` " @@ -7289,11 +7331,11 @@ msgid "" "were changed." msgstr "" -#: ../../library/tkinter.rst:5614 +#: ../../library/tkinter.rst:5671 msgid "Clear the undo and redo stacks." msgstr "" -#: ../../library/tkinter.rst:5618 +#: ../../library/tkinter.rst:5675 msgid "" "Push a separator onto the undo stack, marking a boundary between edit " "actions for undo and redo. Has no effect unless the *undo* option is true. " @@ -7301,7 +7343,7 @@ msgid "" "true." msgstr "" -#: ../../library/tkinter.rst:5626 +#: ../../library/tkinter.rst:5683 msgid "" "Search for *pattern* starting at *index* and return the index of the first " "character of the first match, or an empty string if there is no match. " @@ -7310,12 +7352,27 @@ msgid "" "boolean keyword flags control the search: *forwards* or *backwards* select " "the direction (forward is the default); *exact* (the default) or *regexp* " "select literal or regular-expression matching; *nocase* makes the match case-" -"insensitive; and *elide* causes hidden text to be searched as well. If " -"*count* is a :class:`Variable`, the number of index positions in the match " -"is stored in it." +"insensitive; *elide* causes hidden text to be searched as well; *nolinestop* " +"(regexp only) lets ``.`` and ``[^`` match newlines; and *strictlimits* " +"requires the whole match to lie within *index* and *stopindex*. If *count* " +"is a :class:`Variable`, the number of index positions in the match is stored " +"in it." +msgstr "" + +#: ../../library/tkinter.rst:5698 +msgid "Added the *nolinestop* and *strictlimits* parameters." +msgstr "" + +#: ../../library/tkinter.rst:5704 +msgid "" +"Like :meth:`search`, but find every match in the searched range and return a " +"tuple of the starting indices of all matches (empty if there are none). By " +"default overlapping matches are not reported; passing a true *overlap* " +"returns every match that is not wholly contained in another. If *count* is " +"a :class:`Variable`, it receives a list with one element per match." msgstr "" -#: ../../library/tkinter.rst:5648 +#: ../../library/tkinter.rst:5723 msgid "" "Scroll the widget by 10 times the difference between *x*, *y* and the " "coordinates passed to the last :meth:`scan_mark` call. This is typically " @@ -7323,7 +7380,7 @@ msgid "" "high speed through the window." msgstr "" -#: ../../library/tkinter.rst:5655 +#: ../../library/tkinter.rst:5730 msgid "" "If *boolean* is omitted, return whether internal consistency checks of the B-" "tree data structure are enabled. Otherwise enable or disable them. The " @@ -7331,7 +7388,7 @@ msgid "" "holding large amounts of text." msgstr "" -#: ../../library/tkinter.rst:5663 +#: ../../library/tkinter.rst:5738 msgid "" "Return the contents of the widget from *index1* up to but not including " "*index2* (or just the segment at *index1* if *index2* is omitted), including " @@ -7344,7 +7401,7 @@ msgid "" "three values as arguments and nothing is returned." msgstr "" -#: ../../library/tkinter.rst:5677 +#: ../../library/tkinter.rst:5752 msgid "" "Create a peer text widget with the path name *newPathName* that shares this " "widget's underlying data (text, marks, tags, images and the undo stack). " @@ -7353,23 +7410,23 @@ msgid "" "*startline* and *endline*, may be given to override this." msgstr "" -#: ../../library/tkinter.rst:5689 +#: ../../library/tkinter.rst:5764 msgid "" "Return a tuple of the path names of this widget's peers, not including the " "widget itself." msgstr "" -#: ../../library/tkinter.rst:5696 +#: ../../library/tkinter.rst:5771 msgid "" "Adjust the view so that the location given by *what* is visible. This is an " "obsolete equivalent of :meth:`see`, which should be used instead." msgstr "" -#: ../../library/tkinter.rst:5702 +#: ../../library/tkinter.rst:5777 msgid "Variable classes" msgstr "" -#: ../../library/tkinter.rst:5706 +#: ../../library/tkinter.rst:5781 msgid "" "The base class for the Tk variable wrappers. A Tk variable is a value stored " "in the Tcl interpreter that can be linked to widgets through their " @@ -7378,7 +7435,7 @@ msgid "" "widget bound to it, and a user editing such a widget updates the variable." msgstr "" -#: ../../library/tkinter.rst:5713 +#: ../../library/tkinter.rst:5788 msgid "" "*master* is the widget whose Tcl interpreter owns the variable; if omitted, " "the default root window is used. *value* is the initial value; if omitted, a " @@ -7388,14 +7445,14 @@ msgid "" "the existing value is retained." msgstr "" -#: ../../library/tkinter.rst:5721 +#: ../../library/tkinter.rst:5796 msgid "" "In most cases you should use one of the typed subclasses below -- :class:" "`StringVar`, :class:`IntVar`, :class:`DoubleVar` or :class:`BooleanVar` -- " "rather than :class:`!Variable` directly." msgstr "" -#: ../../library/tkinter.rst:5727 +#: ../../library/tkinter.rst:5802 msgid "" "When a :class:`!Variable` is garbage collected, its Tcl variable is unset. " "Keep a reference to it for as long as a widget is linked to it, for example " @@ -7404,63 +7461,63 @@ msgid "" "again, leaking one Tcl variable per dropped wrapper." msgstr "" -#: ../../library/tkinter.rst:5733 +#: ../../library/tkinter.rst:5808 msgid "" "Two variables now compare equal (``==``) only when they have the same name, " "are of the same class, and belong to the same Tcl interpreter." msgstr "" -#: ../../library/tkinter.rst:5739 +#: ../../library/tkinter.rst:5814 msgid "" "Return the current value of the variable. For the base class the value is " "returned as a string; the typed subclasses convert it to the appropriate " "Python type." msgstr "" -#: ../../library/tkinter.rst:5748 +#: ../../library/tkinter.rst:5823 msgid "" "Set the variable to *value*. :meth:`initialize` is an alias of :meth:`!set`." msgstr "" -#: ../../library/tkinter.rst:5751 ../../library/tkinter.rst:5882 +#: ../../library/tkinter.rst:5826 ../../library/tkinter.rst:5957 msgid "The *initialize* spelling." msgstr "" -#: ../../library/tkinter.rst:5756 +#: ../../library/tkinter.rst:5831 msgid "" "Register *callback* to be called when the variable is accessed according to " "*mode*. *mode* is one of the strings ``'array'``, ``'read'``, ``'write'`` or " "``'unset'``, or a list or tuple of such strings." msgstr "" -#: ../../library/tkinter.rst:5761 +#: ../../library/tkinter.rst:5836 msgid "" "When triggered, *callback* is called with three arguments: the name of the " "Tcl variable, an index (or an empty string if the variable is not an element " "of an array), and the *mode* that triggered the call." msgstr "" -#: ../../library/tkinter.rst:5765 +#: ../../library/tkinter.rst:5840 msgid "" "Return the internal name of the registered callback, which can be passed to :" "meth:`trace_remove`." msgstr "" -#: ../../library/tkinter.rst:5772 +#: ../../library/tkinter.rst:5847 msgid "" "Remove a trace callback from the variable. *mode* must match the *mode* that " "was passed to :meth:`trace_add`, and *cbname* is the callback name returned " "by :meth:`trace_add`." msgstr "" -#: ../../library/tkinter.rst:5780 +#: ../../library/tkinter.rst:5855 msgid "" "Return a list of ``(modes, cbname)`` pairs describing all traces currently " "set on the variable, where *modes* is a tuple of mode strings and *cbname* " "is the internal callback name." msgstr "" -#: ../../library/tkinter.rst:5791 +#: ../../library/tkinter.rst:5866 msgid "" "Register *callback* to be called when the variable is accessed according to " "*mode*. *mode* is one of the strings ``'r'``, ``'w'`` or ``'u'``, for read, " @@ -7468,67 +7525,67 @@ msgid "" "`trace` is an alias of :meth:`!trace_variable`." msgstr "" -#: ../../library/tkinter.rst:5798 +#: ../../library/tkinter.rst:5873 msgid "" "Use :meth:`trace_add` instead. This method wraps a Tcl feature that was " "removed in Tcl 9.0." msgstr "" -#: ../../library/tkinter.rst:5804 +#: ../../library/tkinter.rst:5879 msgid "" "Remove the trace callback named *cbname* registered for *mode* with :meth:" "`trace_variable`." msgstr "" -#: ../../library/tkinter.rst:5807 +#: ../../library/tkinter.rst:5882 msgid "" "Use :meth:`trace_remove` instead. This method wraps a Tcl feature that was " "removed in Tcl 9.0." msgstr "" -#: ../../library/tkinter.rst:5813 +#: ../../library/tkinter.rst:5888 msgid "" "Return a list of ``(mode, cbname)`` pairs for all traces set on the variable " "with :meth:`trace_variable`." msgstr "" -#: ../../library/tkinter.rst:5816 +#: ../../library/tkinter.rst:5891 msgid "" "Use :meth:`trace_info` instead. This method wraps a Tcl feature that was " "removed in Tcl 9.0." msgstr "" -#: ../../library/tkinter.rst:5823 +#: ../../library/tkinter.rst:5898 msgid "" "A :class:`Variable` subclass that holds a string. The default value is " "``''``." msgstr "" -#: ../../library/tkinter.rst:5828 +#: ../../library/tkinter.rst:5903 msgid "Return the value of the variable as a :class:`str`." msgstr "" -#: ../../library/tkinter.rst:5833 +#: ../../library/tkinter.rst:5908 msgid "" "A :class:`Variable` subclass that holds an integer. The default value is " "``0``." msgstr "" -#: ../../library/tkinter.rst:5838 +#: ../../library/tkinter.rst:5913 msgid "Return the value of the variable as an :class:`int`." msgstr "" -#: ../../library/tkinter.rst:5843 +#: ../../library/tkinter.rst:5918 msgid "" "A :class:`Variable` subclass that holds a float. The default value is " "``0.0``." msgstr "" -#: ../../library/tkinter.rst:5848 +#: ../../library/tkinter.rst:5923 msgid "Return the value of the variable as a :class:`float`." msgstr "" -#: ../../library/tkinter.rst:5854 +#: ../../library/tkinter.rst:5929 msgid "" "A floating-point value is always parsed with a period (``.``) as the decimal " "separator, but :class:`Spinbox`, :class:`Scale` and :class:`ttk.Spinbox " @@ -7538,29 +7595,29 @@ msgid "" "uses a period (such as ``'C'``) to avoid this." msgstr "" -#: ../../library/tkinter.rst:5865 +#: ../../library/tkinter.rst:5940 msgid "" "A :class:`Variable` subclass that holds a boolean. The default value is " "``False``." msgstr "" -#: ../../library/tkinter.rst:5870 +#: ../../library/tkinter.rst:5945 msgid "" "Return the value of the variable as a :class:`bool`. Raise a :exc:" "`ValueError` if the value cannot be interpreted as a boolean." msgstr "" -#: ../../library/tkinter.rst:5879 +#: ../../library/tkinter.rst:5954 msgid "" "Set the variable to *value*, converting it to a boolean. :meth:`initialize` " "is an alias of :meth:`!set`." msgstr "" -#: ../../library/tkinter.rst:5887 +#: ../../library/tkinter.rst:5962 msgid "Image classes" msgstr "圖片類別" -#: ../../library/tkinter.rst:5891 +#: ../../library/tkinter.rst:5966 msgid "" "Base class for Tk images. *imgtype* is the Tk image type, one of ``'photo'`` " "or ``'bitmap'``. An image is a named object that can be displayed by widgets " @@ -7569,35 +7626,35 @@ msgid "" "`PhotoImage` or :class:`BitmapImage` rather than an :class:`!Image` directly." msgstr "" -#: ../../library/tkinter.rst:5899 +#: ../../library/tkinter.rst:5974 msgid "" "The image's configuration options are given by *cnf* and *kw* and may be " "queried and changed later with the mapping protocol (using ``image[key]``) " "or with the :meth:`configure` method." msgstr "" -#: ../../library/tkinter.rst:5908 +#: ../../library/tkinter.rst:5983 msgid "" "Modify one or more configuration options of the image. The valid options " "depend on the image type; see :class:`PhotoImage` and :class:`BitmapImage`. :" "meth:`config` is an alias of :meth:`!configure`." msgstr "" -#: ../../library/tkinter.rst:5915 +#: ../../library/tkinter.rst:5990 msgid "Return the height of the image, in pixels." msgstr "" -#: ../../library/tkinter.rst:5919 +#: ../../library/tkinter.rst:5994 msgid "Return the width of the image, in pixels." msgstr "" -#: ../../library/tkinter.rst:5923 +#: ../../library/tkinter.rst:5998 msgid "" "Return the type of the image, that is the value of *imgtype* with which it " "was created (for example ``'photo'`` or ``'bitmap'``)." msgstr "" -#: ../../library/tkinter.rst:5929 +#: ../../library/tkinter.rst:6004 msgid "" "A full-color image (the Tk ``photo`` image type), stored internally with a " "varying degree of transparency per pixel. It can read and write GIF, PPM/PGM " @@ -7605,7 +7662,7 @@ msgid "" "and be drawn in widgets. Inherits from :class:`Image`." msgstr "" -#: ../../library/tkinter.rst:5935 +#: ../../library/tkinter.rst:6010 msgid "" "The configuration options include *data* (the image contents as a string), " "*file* (the name of a file to read the contents from), *format* (the name of " @@ -7613,22 +7670,22 @@ msgid "" "when building it up piece by piece), *gamma* and *palette*." msgstr "" -#: ../../library/tkinter.rst:5942 +#: ../../library/tkinter.rst:6017 msgid "" "Blank the image; that is, set the entire image to have no data, so that it " "is displayed as transparent and the background of whatever window it is " "displayed in shows through." msgstr "" -#: ../../library/tkinter.rst:5948 +#: ../../library/tkinter.rst:6023 msgid "Return the current value of the configuration option *option*." msgstr "" -#: ../../library/tkinter.rst:5952 +#: ../../library/tkinter.rst:6027 msgid "Return a new :class:`PhotoImage` with a copy of this image." msgstr "" -#: ../../library/tkinter.rst:5954 +#: ../../library/tkinter.rst:6029 msgid "" "*from_coords* specifies a rectangular sub-region of the source image to be " "copied. It must be a tuple or a list of 1 to 4 integers ``(x1, y1, x2, " @@ -7639,18 +7696,18 @@ msgid "" "*from_coords* is not given, the whole source image is copied." msgstr "" -#: ../../library/tkinter.rst:5965 ../../library/tkinter.rst:5997 +#: ../../library/tkinter.rst:6040 ../../library/tkinter.rst:6072 msgid "" "If *zoom* or *subsample* are specified, the image is transformed as in the :" "meth:`zoom` or :meth:`subsample` methods. The value must be a single integer " "or a pair of integers." msgstr "" -#: ../../library/tkinter.rst:5969 +#: ../../library/tkinter.rst:6044 msgid "Added the *from_coords*, *zoom* and *subsample* parameters." msgstr "" -#: ../../library/tkinter.rst:5977 +#: ../../library/tkinter.rst:6052 msgid "" "Copy a region from *sourceImage* (which must be a :class:`PhotoImage`) into " "this image, possibly with pixel zooming and/or subsampling. If no options " @@ -7658,14 +7715,14 @@ msgid "" "starting at coordinates ``(0, 0)``." msgstr "" -#: ../../library/tkinter.rst:5982 ../../library/tkinter.rst:6094 -#: ../../library/tkinter.rst:6150 +#: ../../library/tkinter.rst:6057 ../../library/tkinter.rst:6169 +#: ../../library/tkinter.rst:6225 msgid "" "*from_coords* specifies a rectangular sub-region of the source image to be " "copied, as in the :meth:`copy` method." msgstr "" -#: ../../library/tkinter.rst:5985 +#: ../../library/tkinter.rst:6060 msgid "" "*to* specifies a rectangular sub-region of the destination image to be " "affected. It must be a tuple or a list of 1 to 4 integers ``(x1, y1, x2, " @@ -7675,14 +7732,14 @@ msgid "" "to fill the destination region in a tiled fashion." msgstr "" -#: ../../library/tkinter.rst:5993 +#: ../../library/tkinter.rst:6068 msgid "" "If *shrink* is true, the size of the destination image is reduced, if " "necessary, so that the region being copied into is at the bottom-right " "corner of the image." msgstr "" -#: ../../library/tkinter.rst:6001 +#: ../../library/tkinter.rst:6076 msgid "" "*compositingrule* specifies how transparent pixels in the source image are " "combined with the destination image. With ``'overlay'`` (the default), the " @@ -7692,11 +7749,11 @@ msgid "" "discarded and the source image is used as-is." msgstr "" -#: ../../library/tkinter.rst:6015 +#: ../../library/tkinter.rst:6090 msgid "Return the image data." msgstr "" -#: ../../library/tkinter.rst:6017 +#: ../../library/tkinter.rst:6092 msgid "" "*format* specifies the name of the image file format handler to use. If it " "is not given, the data is returned as a tuple (one element per row) of " @@ -7704,7 +7761,7 @@ msgid "" "``#RRGGBB`` format." msgstr "" -#: ../../library/tkinter.rst:6022 +#: ../../library/tkinter.rst:6097 msgid "" "*from_coords* specifies a rectangular region of the image to be returned. It " "must be a tuple or a list of 1 to 4 integers ``(x1, y1, x2, y2)``. If only " @@ -7715,34 +7772,34 @@ msgid "" "is returned." msgstr "" -#: ../../library/tkinter.rst:6030 ../../library/tkinter.rst:6133 +#: ../../library/tkinter.rst:6105 ../../library/tkinter.rst:6208 msgid "" "If *background* is specified, the data does not contain any transparency " "information; in all transparent pixels the color is replaced by the " "specified color." msgstr "" -#: ../../library/tkinter.rst:6034 ../../library/tkinter.rst:6137 +#: ../../library/tkinter.rst:6109 ../../library/tkinter.rst:6212 msgid "" "If *grayscale* is true, the data does not contain color information; all " "pixel data is transformed into grayscale." msgstr "" -#: ../../library/tkinter.rst:6042 +#: ../../library/tkinter.rst:6117 msgid "" "Return the color of the pixel at coordinates (*x*, *y*) as an ``(r, g, b)`` " "tuple of three integers between 0 and 255, representing the red, green and " "blue components respectively." msgstr "" -#: ../../library/tkinter.rst:6048 +#: ../../library/tkinter.rst:6123 msgid "" "Set pixels of the image to the colors given in *data*, which must be a " "string or a nested sequence of horizontal rows of pixel colors (for example " "``\"{red green} {blue yellow}\"``)." msgstr "" -#: ../../library/tkinter.rst:6052 +#: ../../library/tkinter.rst:6127 msgid "" "*to* specifies the coordinates of the region of the image into which the " "data are copied. It must be a tuple or a list of 2 or 4 integers ``(x1, " @@ -7750,15 +7807,15 @@ msgid "" "bottom-right corner, of the region. The default position is ``(0, 0)``." msgstr "" -#: ../../library/tkinter.rst:6062 +#: ../../library/tkinter.rst:6137 msgid "Read image data from the file named *filename* into the image." msgstr "" -#: ../../library/tkinter.rst:6064 +#: ../../library/tkinter.rst:6139 msgid "*format* specifies the format of the image data in the file." msgstr "" -#: ../../library/tkinter.rst:6066 +#: ../../library/tkinter.rst:6141 msgid "" "*from_coords* specifies a rectangular sub-region of the image file data to " "be copied to the destination image. It must be a tuple or a list of 1 to 4 " @@ -7769,53 +7826,53 @@ msgid "" "the image in the file is read." msgstr "" -#: ../../library/tkinter.rst:6076 +#: ../../library/tkinter.rst:6151 msgid "" "*to* specifies the coordinates of the top-left corner of the region of the " "image into which the data are read. The default is ``(0, 0)``." msgstr "" -#: ../../library/tkinter.rst:6080 +#: ../../library/tkinter.rst:6155 msgid "" "If *shrink* is true, the size of the image is reduced, if necessary, so that " "the region into which the file data are read is at the bottom-right corner " "of the image." msgstr "" -#: ../../library/tkinter.rst:6089 +#: ../../library/tkinter.rst:6164 msgid "" "Return a new :class:`PhotoImage` based on this image but using only every " "*x*-th pixel in the X direction and every *y*-th pixel in the Y direction. " "If *y* is not given, it defaults to the same value as *x*." msgstr "" -#: ../../library/tkinter.rst:6097 ../../library/tkinter.rst:6153 +#: ../../library/tkinter.rst:6172 ../../library/tkinter.rst:6228 msgid "Added the *from_coords* parameter." msgstr "" -#: ../../library/tkinter.rst:6103 +#: ../../library/tkinter.rst:6178 msgid "" "Return ``True`` if the pixel at coordinates (*x*, *y*) is fully transparent, " "``False`` otherwise." msgstr "" -#: ../../library/tkinter.rst:6111 +#: ../../library/tkinter.rst:6186 msgid "" "Make the pixel at coordinates (*x*, *y*) fully transparent if *boolean* is " "true, fully opaque otherwise." msgstr "" -#: ../../library/tkinter.rst:6120 +#: ../../library/tkinter.rst:6195 msgid "Write image data from the image to the file named *filename*." msgstr "" -#: ../../library/tkinter.rst:6122 +#: ../../library/tkinter.rst:6197 msgid "" "*format* specifies the name of the image file format handler to use. If it " "is not given, the format is guessed from the file extension." msgstr "" -#: ../../library/tkinter.rst:6125 +#: ../../library/tkinter.rst:6200 msgid "" "*from_coords* specifies a rectangular region of the image to be written. It " "must be a tuple or a list of 1 to 4 integers ``(x1, y1, x2, y2)``. If only " @@ -7825,25 +7882,25 @@ msgid "" "given, the whole image is written." msgstr "" -#: ../../library/tkinter.rst:6140 +#: ../../library/tkinter.rst:6215 msgid "Added the *background* and *grayscale* parameters." msgstr "" -#: ../../library/tkinter.rst:6146 +#: ../../library/tkinter.rst:6221 msgid "" "Return a new :class:`PhotoImage` with this image magnified by a factor of " "*x* in the X direction and *y* in the Y direction. If *y* is not given, it " "defaults to the same value as *x*." msgstr "" -#: ../../library/tkinter.rst:6160 +#: ../../library/tkinter.rst:6235 msgid "" "A two-color image (the Tk ``bitmap`` image type) created from an X11 bitmap. " "Each pixel displays a foreground color, a background color, or nothing " "(producing a transparent effect). Inherits from :class:`Image`." msgstr "" -#: ../../library/tkinter.rst:6165 +#: ../../library/tkinter.rst:6240 msgid "" "The configuration options are *data* or *file* (the source bitmap, given as " "a string in X11 bitmap format or as the name of a file in that format), " @@ -7855,17 +7912,17 @@ msgid "" "transparent." msgstr "" -#: ../../library/tkinter.rst:6175 +#: ../../library/tkinter.rst:6250 msgid "" ":class:`!BitmapImage` has no methods of its own beyond those inherited from :" "class:`Image`." msgstr "" -#: ../../library/tkinter.rst:6180 +#: ../../library/tkinter.rst:6255 msgid "Other classes" msgstr "" -#: ../../library/tkinter.rst:6184 +#: ../../library/tkinter.rst:6259 msgid "" "A container for the attributes of an event passed to a callback bound with :" "meth:`Misc.bind`. An :class:`!Event` instance has the following attributes, " @@ -7874,77 +7931,90 @@ msgid "" "that they are not meaningful. See :ref:`bindings-and-events`." msgstr "" -#: ../../library/tkinter.rst:6194 +#: ../../library/tkinter.rst:6269 msgid "The serial number of the event." msgstr "" -#: ../../library/tkinter.rst:6198 +#: ../../library/tkinter.rst:6273 msgid "The mouse button that was pressed or released (for button events)." msgstr "" -#: ../../library/tkinter.rst:6202 +#: ../../library/tkinter.rst:6277 msgid "Whether the window has the focus (for ``Enter`` and ``Leave`` events)." msgstr "" -#: ../../library/tkinter.rst:6207 +#: ../../library/tkinter.rst:6282 msgid "" "The new height and width of the window (for ``Configure`` and ``Expose`` " "events)." msgstr "" -#: ../../library/tkinter.rst:6212 +#: ../../library/tkinter.rst:6287 msgid "The keycode of the key that was pressed or released." msgstr "" -#: ../../library/tkinter.rst:6216 +#: ../../library/tkinter.rst:6291 msgid "" "The state of the event, as a number (for most events) or a string (for " "``Visibility`` events)." msgstr "" -#: ../../library/tkinter.rst:6221 +#: ../../library/tkinter.rst:6296 msgid "The timestamp of the event, in milliseconds." msgstr "" -#: ../../library/tkinter.rst:6226 +#: ../../library/tkinter.rst:6301 msgid "The pointer position relative to the widget, in pixels." msgstr "" -#: ../../library/tkinter.rst:6231 +#: ../../library/tkinter.rst:6306 msgid "" "The pointer position relative to the top-left corner of the screen, in " "pixels." msgstr "" -#: ../../library/tkinter.rst:6236 +#: ../../library/tkinter.rst:6311 msgid "The character typed, as a string (for key events)." msgstr "" -#: ../../library/tkinter.rst:6240 +#: ../../library/tkinter.rst:6315 msgid "``True`` if the event was sent by another application." msgstr "" -#: ../../library/tkinter.rst:6244 +#: ../../library/tkinter.rst:6319 msgid "The symbolic name of the key that was pressed or released." msgstr "" -#: ../../library/tkinter.rst:6248 +#: ../../library/tkinter.rst:6323 msgid "The numeric value of :attr:`keysym`." msgstr "" -#: ../../library/tkinter.rst:6252 +#: ../../library/tkinter.rst:6327 msgid "The :class:`EventType` of the event." msgstr "" -#: ../../library/tkinter.rst:6256 +#: ../../library/tkinter.rst:6331 msgid "The widget on which the event occurred." msgstr "" -#: ../../library/tkinter.rst:6260 +#: ../../library/tkinter.rst:6335 msgid "The amount the mouse wheel was rotated (for ``MouseWheel`` events)." msgstr "" -#: ../../library/tkinter.rst:6265 +#: ../../library/tkinter.rst:6339 +msgid "" +"The data string of a virtual event, as passed to the *data* option of :meth:" +"`Misc.event_generate`. It is ``'??'`` for non-virtual events." +msgstr "" + +#: ../../library/tkinter.rst:6347 +msgid "" +"A fixed detail string for ``Enter``, ``Leave``, ``FocusIn``, ``FocusOut`` " +"and ``ConfigureRequest`` events (see the Tcl/Tk documentation). It is " +"``'??'`` for other events." +msgstr "" + +#: ../../library/tkinter.rst:6356 msgid "" "An :class:`enum.StrEnum` enumerating the Tk event types, used as the value " "of :attr:`Event.type`. Its members include, among others, ``KeyPress``, " @@ -7953,7 +8023,7 @@ msgid "" "``Expose``, ``Destroy`` and ``MouseWheel``." msgstr "" -#: ../../library/tkinter.rst:6278 +#: ../../library/tkinter.rst:6369 msgid "" "Internal helper that wraps a Python callback so that it can be invoked from " "Tcl. *func* is the Python function, *subst* is an optional function that pre-" @@ -7962,11 +8032,11 @@ msgid "" "this class is not normally used directly." msgstr "" -#: ../../library/tkinter.rst:6288 +#: ../../library/tkinter.rst:6379 msgid "Module-level functions" msgstr "" -#: ../../library/tkinter.rst:6292 +#: ../../library/tkinter.rst:6383 msgid "" "The :func:`Tcl` function is a factory function which creates an object much " "like that created by the :class:`Tk` class, except that it does not " @@ -7983,7 +8053,7 @@ msgstr "" "Linux 系統)。由 :func:`Tcl` 物件建立的物件可以透過呼叫其 :meth:`~Tk.loadtk` " "方法來建立一個頂層視窗(並初始化 Tk 子系統)。" -#: ../../library/tkinter.rst:6304 +#: ../../library/tkinter.rst:6395 msgid "" "Inhibit the creation of an implicit default root window. Afterwards :mod:`!" "tkinter` no longer creates a shared default root automatically, and " @@ -7992,44 +8062,44 @@ msgid "" "applications to make the root window explicit." msgstr "" -#: ../../library/tkinter.rst:6312 +#: ../../library/tkinter.rst:6403 msgid "" "Run the Tk main event loop on the default root window until all windows are " "destroyed. Equivalent to calling :meth:`Misc.mainloop` on the default root." msgstr "" -#: ../../library/tkinter.rst:6318 +#: ../../library/tkinter.rst:6409 msgid "" "Convert the Tcl boolean string *s* (one of ``'1'``, ``'true'``, ``'yes'``, " "``'on'`` and similar, or their false counterparts) to a Python :class:" "`bool`. Raise :exc:`TclError` for an invalid value." msgstr "" -#: ../../library/tkinter.rst:6325 +#: ../../library/tkinter.rst:6416 msgid "" "Convert *s* to a floating-point number. This is the built-in :class:`float`." msgstr "" -#: ../../library/tkinter.rst:6330 +#: ../../library/tkinter.rst:6421 msgid "Convert *s* to an integer. This is the built-in :class:`int`." msgstr "" -#: ../../library/tkinter.rst:6335 +#: ../../library/tkinter.rst:6426 msgid "" "Return the names of all existing images in the default root's interpreter." msgstr "" -#: ../../library/tkinter.rst:6339 +#: ../../library/tkinter.rst:6430 msgid "" "Return the available image types (such as ``'photo'`` and ``'bitmap'``) in " "the default root's interpreter." msgstr "" -#: ../../library/tkinter.rst:6346 +#: ../../library/tkinter.rst:6437 msgid "File handlers" msgstr "檔案處理常式" -#: ../../library/tkinter.rst:6348 +#: ../../library/tkinter.rst:6439 msgid "" "Tk allows you to register and unregister a callback function which will be " "called from the Tk mainloop when I/O is possible on a file descriptor. Only " @@ -8038,7 +8108,7 @@ msgstr "" "Tk 允許你註冊和取消註冊一個回呼函式,當檔案描述器上可以進行 I/O 時,該函式將" "從 Tk 主迴圈中被呼叫。每個檔案描述器只能註冊一個處理常式。範例程式碼: ::" -#: ../../library/tkinter.rst:6352 +#: ../../library/tkinter.rst:6443 msgid "" "import tkinter\n" "widget = tkinter.Tk()\n" @@ -8054,11 +8124,11 @@ msgstr "" "...\n" "widget.tk.deletefilehandler(file)" -#: ../../library/tkinter.rst:6359 +#: ../../library/tkinter.rst:6450 msgid "This feature is not available on Windows." msgstr "此功能在 Windows 上不可用。" -#: ../../library/tkinter.rst:6361 +#: ../../library/tkinter.rst:6452 msgid "" "Since you don't know how many bytes are available for reading, you may not " "want to use the :class:`~io.BufferedIOBase` or :class:`~io.TextIOBase` :meth:" @@ -8075,7 +8145,7 @@ msgstr "" "法可以正常運作;對於其他檔案,請使用原始讀取或 ``os.read(file.fileno(), " "maxbytecount)``。" -#: ../../library/tkinter.rst:6372 +#: ../../library/tkinter.rst:6463 msgid "" "Registers the file handler callback function *func*. The *file* argument may " "either be an object with a :meth:`~io.IOBase.fileno` method (such as a file " @@ -8088,81 +8158,81 @@ msgstr "" "器。*mask* 引數是下面三個常數中任意一個的 OR 組合。回呼函式被呼叫的方式如" "下: ::" -#: ../../library/tkinter.rst:6378 +#: ../../library/tkinter.rst:6469 msgid "callback(file, mask)" msgstr "callback(file, mask)" -#: ../../library/tkinter.rst:6383 +#: ../../library/tkinter.rst:6474 msgid "Unregisters a file handler." msgstr "取消註冊檔案處理常式。" -#: ../../library/tkinter.rst:6390 +#: ../../library/tkinter.rst:6481 msgid "Constants used in the *mask* arguments." msgstr "用於 *mask* 引數的常數。" -#: ../../library/tkinter.rst:6394 +#: ../../library/tkinter.rst:6485 msgid "Constants" msgstr "" -#: ../../library/tkinter.rst:6396 +#: ../../library/tkinter.rst:6487 msgid "" "The following symbolic constants are available in both the :mod:`!tkinter` " "and :mod:`!tkinter.constants` namespaces." msgstr "" -#: ../../library/tkinter.rst:6403 +#: ../../library/tkinter.rst:6494 msgid "Truthy values, all equal to the integer ``1``." msgstr "" -#: ../../library/tkinter.rst:6409 +#: ../../library/tkinter.rst:6500 msgid "Falsy values, all equal to the integer ``0``." msgstr "" -#: ../../library/tkinter.rst:6424 +#: ../../library/tkinter.rst:6515 msgid "" "Compass directions (``'n'``, ``'s'``, ``'e'``, ``'w'`` and the diagonals and " "edges) plus ``CENTER`` (``'center'``), used as values for the *anchor* and " "*sticky* options and by methods such as :meth:`Misc.grid_anchor`." msgstr "" -#: ../../library/tkinter.rst:6433 +#: ../../library/tkinter.rst:6524 msgid "" "Sides for the *side* option of the packer (see :meth:`Pack.pack_configure`)." msgstr "" -#: ../../library/tkinter.rst:6440 +#: ../../library/tkinter.rst:6531 msgid "" "Values for the *fill* option of the packer: ``'x'``, ``'y'``, ``'both'`` or " "``'none'``." msgstr "packer 的 *fill* 選項值:``'x'``、``'y'``、``'both'`` 或 ``'none'``。" -#: ../../library/tkinter.rst:6450 +#: ../../library/tkinter.rst:6541 msgid "Values for the *relief* option, which controls a widget's 3-D border." msgstr "" -#: ../../library/tkinter.rst:6455 +#: ../../library/tkinter.rst:6546 msgid "" "Values for the *orient* option of widgets such as :class:`Scale`, :class:" "`Scrollbar` and :class:`PanedWindow`." msgstr "" -#: ../../library/tkinter.rst:6461 +#: ../../library/tkinter.rst:6552 msgid "" "Values for the *wrap* option of the :class:`Text` widget, selecting line " "wrapping on character or word boundaries." msgstr "" -#: ../../library/tkinter.rst:6466 +#: ../../library/tkinter.rst:6557 msgid "The text-alignment value ``'baseline'``." msgstr "" -#: ../../library/tkinter.rst:6471 +#: ../../library/tkinter.rst:6562 msgid "" "Values for the *bordermode* option of the placer (see :meth:`Place." "place_configure`)." msgstr "" -#: ../../library/tkinter.rst:6482 +#: ../../library/tkinter.rst:6573 msgid "" "Symbolic indices used by the :class:`Text`, :class:`Entry`, :class:`Listbox` " "and :class:`Canvas` widgets, such as ``'insert'`` (the insertion cursor), " @@ -8170,80 +8240,80 @@ msgid "" "(``'sel.first'`` and ``'sel.last'``)." msgstr "" -#: ../../library/tkinter.rst:6489 +#: ../../library/tkinter.rst:6580 msgid "" "The special tag ``'all'``, which matches every item of a :class:`Canvas` or " "every character of a :class:`Text` (for example ``canvas.delete(ALL)``)." msgstr "" -#: ../../library/tkinter.rst:6497 +#: ../../library/tkinter.rst:6588 msgid "Values for the *state* option of various widgets and items." msgstr "" -#: ../../library/tkinter.rst:6505 +#: ../../library/tkinter.rst:6596 msgid "" "Menu entry types, used as the *itemType* argument of :meth:`Menu.add` and :" "meth:`Menu.insert`." msgstr "" -#: ../../library/tkinter.rst:6513 +#: ../../library/tkinter.rst:6604 msgid "Values for the *selectmode* option of the :class:`Listbox` widget." msgstr "" -#: ../../library/tkinter.rst:6519 +#: ../../library/tkinter.rst:6610 msgid "Values for the *style* option of :class:`Canvas` arc items." msgstr "" -#: ../../library/tkinter.rst:6527 +#: ../../library/tkinter.rst:6618 msgid "" "Values for the *capstyle* (``'butt'``, ``'projecting'``, ``'round'``) and " "*joinstyle* (``'round'``, ``'bevel'``, ``'miter'``) options of :class:" "`Canvas` line items." msgstr "" -#: ../../library/tkinter.rst:6534 +#: ../../library/tkinter.rst:6625 msgid "" "Values for the *arrow* option of :class:`Canvas` line items, indicating " "which ends have arrowheads." msgstr "" -#: ../../library/tkinter.rst:6540 +#: ../../library/tkinter.rst:6631 msgid "" "The first argument passed by a :class:`Scrollbar` to the :meth:`XView.xview` " "or :meth:`YView.yview` method of the scrolled widget." msgstr "" -#: ../../library/tkinter.rst:6546 +#: ../../library/tkinter.rst:6637 msgid "" "Values for the *what* argument of :meth:`XView.xview_scroll` and :meth:" "`YView.yview_scroll`." msgstr "" -#: ../../library/tkinter.rst:6553 +#: ../../library/tkinter.rst:6644 msgid "Other option values: ``'underline'``, ``'numeric'`` and ``'dotbox'``." msgstr "" -#: ../../library/tkinter.rst:591 +#: ../../library/tkinter.rst:589 msgid "geometry management (widgets)" msgstr "佈局管理(元件)" -#: ../../library/tkinter.rst:591 +#: ../../library/tkinter.rst:589 msgid "packing (widgets)" msgstr "packing(元件)" -#: ../../library/tkinter.rst:730 +#: ../../library/tkinter.rst:728 msgid "window manager (widgets)" msgstr "視窗管理器(元件)" -#: ../../library/tkinter.rst:768 +#: ../../library/tkinter.rst:766 msgid "Tk Option Data Types" msgstr "Tk 選項資料型別" -#: ../../library/tkinter.rst:857 +#: ../../library/tkinter.rst:855 msgid "bind (widgets)" msgstr "bind(元件)" -#: ../../library/tkinter.rst:857 +#: ../../library/tkinter.rst:855 msgid "events (widgets)" msgstr "事件(元件)" diff --git a/library/tkinter.scrolledtext.po b/library/tkinter.scrolledtext.po index 8ab35ffed35..5631d630c49 100644 --- a/library/tkinter.scrolledtext.po +++ b/library/tkinter.scrolledtext.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-19 00:50+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2016-11-19 00:35+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!tkinter.scrolledtext` --- Scrolled text widget" msgstr ":mod:`!tkinter.scrolledtext` --- 捲動文字小工具" -#: ../../library/tkinter.scrolledtext.rst:9 +#: ../../library/tkinter.scrolledtext.rst:7 msgid "**Source code:** :source:`Lib/tkinter/scrolledtext.py`" msgstr "**原始碼:**\\ :source:`Lib/tkinter/scrolledtext.py`" -#: ../../library/tkinter.scrolledtext.rst:13 +#: ../../library/tkinter.scrolledtext.rst:11 msgid "" "The :mod:`!tkinter.scrolledtext` module provides a class of the same name " "which implements a basic text widget which has a vertical scroll bar " @@ -33,7 +33,7 @@ msgid "" "is a lot easier than setting up a text widget and scroll bar directly." msgstr "" -#: ../../library/tkinter.scrolledtext.rst:18 +#: ../../library/tkinter.scrolledtext.rst:16 msgid "" "The text widget and scrollbar are packed together in a :class:`~tkinter." "Frame`, and the methods of the :class:`~tkinter.Pack`, :class:`~tkinter." @@ -42,16 +42,16 @@ msgid "" "to be used directly to achieve most normal geometry management behavior." msgstr "" -#: ../../library/tkinter.scrolledtext.rst:25 +#: ../../library/tkinter.scrolledtext.rst:23 msgid "" "Should more specific control be necessary, the following attributes are " "available:" msgstr "" -#: ../../library/tkinter.scrolledtext.rst:33 +#: ../../library/tkinter.scrolledtext.rst:31 msgid "The frame which surrounds the text and scroll bar widgets." msgstr "" -#: ../../library/tkinter.scrolledtext.rst:38 +#: ../../library/tkinter.scrolledtext.rst:36 msgid "The scroll bar widget." msgstr "" diff --git a/library/tkinter.ttk.po b/library/tkinter.ttk.po index d240d616385..aaf00fe7ff8 100644 --- a/library/tkinter.ttk.po +++ b/library/tkinter.ttk.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-16 00:27+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:13+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!tkinter.ttk` --- Tk themed widgets" msgstr ":mod:`!tkinter.ttk` --- Tk 主題化小工具" -#: ../../library/tkinter.ttk.rst:9 +#: ../../library/tkinter.ttk.rst:7 msgid "**Source code:** :source:`Lib/tkinter/ttk.py`" msgstr "**原始碼:**\\ :source:`Lib/tkinter/ttk.py`" -#: ../../library/tkinter.ttk.rst:15 +#: ../../library/tkinter.ttk.rst:13 msgid "" "The :mod:`!tkinter.ttk` module provides access to the Tk themed widget set, " "introduced in Tk 8.5. Its widgets adapt their appearance to the platform's " @@ -33,14 +33,14 @@ msgid "" "feel than the classic :mod:`tkinter` widgets, whose appearance is fixed." msgstr "" -#: ../../library/tkinter.ttk.rst:21 +#: ../../library/tkinter.ttk.rst:19 msgid "" "The basic idea for :mod:`!tkinter.ttk` is to separate, to the extent " "possible, the code implementing a widget's behavior from the code " "implementing its appearance." msgstr "" -#: ../../library/tkinter.ttk.rst:25 +#: ../../library/tkinter.ttk.rst:23 msgid "" "Ttk widgets are used just like the classic :mod:`tkinter` widgets and share " "the same machinery: the widget hierarchy, the geometry managers, variable " @@ -48,36 +48,36 @@ msgid "" "mod:`tkinter` documentation and are not repeated here." msgstr "" -#: ../../library/tkinter.ttk.rst:36 +#: ../../library/tkinter.ttk.rst:34 msgid "" "`Tk Widget Styling Support (TIP #48) `_" msgstr "" "`Tk Widget Styling Support (TIP #48) `_" -#: ../../library/tkinter.ttk.rst:37 +#: ../../library/tkinter.ttk.rst:35 msgid "" "The Tcl Improvement Proposal that introduced the themed widget styling " "engine." msgstr "" -#: ../../library/tkinter.ttk.rst:41 +#: ../../library/tkinter.ttk.rst:39 msgid "Using Ttk" msgstr "使用 Ttk" -#: ../../library/tkinter.ttk.rst:43 +#: ../../library/tkinter.ttk.rst:41 msgid "To start using Ttk, import its module::" msgstr "" -#: ../../library/tkinter.ttk.rst:45 +#: ../../library/tkinter.ttk.rst:43 msgid "from tkinter import ttk" msgstr "from tkinter import ttk" -#: ../../library/tkinter.ttk.rst:47 +#: ../../library/tkinter.ttk.rst:45 msgid "" "To override the basic Tk widgets, the import should follow the Tk import::" msgstr "" -#: ../../library/tkinter.ttk.rst:49 +#: ../../library/tkinter.ttk.rst:47 msgid "" "from tkinter import *\n" "from tkinter.ttk import *" @@ -85,7 +85,7 @@ msgstr "" "from tkinter import *\n" "from tkinter.ttk import *" -#: ../../library/tkinter.ttk.rst:52 +#: ../../library/tkinter.ttk.rst:50 msgid "" "That code causes several :mod:`!tkinter.ttk` widgets (:class:`Button`, :" "class:`Checkbutton`, :class:`Entry`, :class:`Frame`, :class:`Label`, :class:" @@ -94,7 +94,7 @@ msgid "" "class:`Spinbox`) to automatically replace the Tk widgets." msgstr "" -#: ../../library/tkinter.ttk.rst:61 +#: ../../library/tkinter.ttk.rst:59 msgid "" "Overriding the classic widgets with ``from tkinter.ttk import *`` is " "convenient for adapting existing code, but new code is usually clearer if it " @@ -102,7 +102,7 @@ msgid "" "widgets explicitly, such as ``ttk.Button``." msgstr "" -#: ../../library/tkinter.ttk.rst:67 +#: ../../library/tkinter.ttk.rst:65 msgid "" "This has the direct benefit of using the new widgets which gives a better " "look and feel across platforms; however, the replacement widgets are not " @@ -112,11 +112,11 @@ msgid "" "styling effects." msgstr "" -#: ../../library/tkinter.ttk.rst:76 +#: ../../library/tkinter.ttk.rst:74 msgid "Ttk widgets" msgstr "Ttk 元件" -#: ../../library/tkinter.ttk.rst:78 +#: ../../library/tkinter.ttk.rst:76 msgid "" "Ttk comes with 18 widgets, twelve of which already existed in tkinter: :" "class:`Button`, :class:`Checkbutton`, :class:`Entry`, :class:`Frame`, :class:" @@ -127,27 +127,27 @@ msgid "" "`Treeview`. All of them are subclasses of :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:86 +#: ../../library/tkinter.ttk.rst:84 msgid "" "Using the Ttk widgets gives the application an improved look and feel. As " "discussed above, there are differences in how the styling is coded." msgstr "" -#: ../../library/tkinter.ttk.rst:89 +#: ../../library/tkinter.ttk.rst:87 msgid "Tk code::" msgstr "" -#: ../../library/tkinter.ttk.rst:91 +#: ../../library/tkinter.ttk.rst:89 msgid "" "l1 = tkinter.Label(text=\"Test\", fg=\"black\", bg=\"white\")\n" "l2 = tkinter.Label(text=\"Test\", fg=\"black\", bg=\"white\")" msgstr "" -#: ../../library/tkinter.ttk.rst:95 +#: ../../library/tkinter.ttk.rst:93 msgid "Ttk code::" msgstr "" -#: ../../library/tkinter.ttk.rst:97 +#: ../../library/tkinter.ttk.rst:95 msgid "" "style = ttk.Style()\n" "style.configure(\"BW.TLabel\", foreground=\"black\", background=\"white\")\n" @@ -156,56 +156,56 @@ msgid "" "l2 = ttk.Label(text=\"Test\", style=\"BW.TLabel\")" msgstr "" -#: ../../library/tkinter.ttk.rst:103 +#: ../../library/tkinter.ttk.rst:101 msgid "" "For more information about TtkStyling_, see the :class:`Style` class " "documentation." msgstr "" -#: ../../library/tkinter.ttk.rst:107 +#: ../../library/tkinter.ttk.rst:105 msgid "Widget" msgstr "" -#: ../../library/tkinter.ttk.rst:109 +#: ../../library/tkinter.ttk.rst:107 msgid "" ":class:`ttk.Widget ` defines standard options and methods supported " "by Tk themed widgets and is not supposed to be directly instantiated." msgstr "" -#: ../../library/tkinter.ttk.rst:114 +#: ../../library/tkinter.ttk.rst:112 msgid "Standard options" msgstr "標準選項" -#: ../../library/tkinter.ttk.rst:116 +#: ../../library/tkinter.ttk.rst:114 msgid "All the :mod:`!ttk` Widgets accept the following options:" msgstr "" -#: ../../library/tkinter.ttk.rst:121 ../../library/tkinter.ttk.rst:157 -#: ../../library/tkinter.ttk.rst:183 ../../library/tkinter.ttk.rst:226 -#: ../../library/tkinter.ttk.rst:335 ../../library/tkinter.ttk.rst:428 -#: ../../library/tkinter.ttk.rst:510 ../../library/tkinter.ttk.rst:536 -#: ../../library/tkinter.ttk.rst:708 ../../library/tkinter.ttk.rst:780 -#: ../../library/tkinter.ttk.rst:850 ../../library/tkinter.ttk.rst:911 -#: ../../library/tkinter.ttk.rst:939 +#: ../../library/tkinter.ttk.rst:119 ../../library/tkinter.ttk.rst:155 +#: ../../library/tkinter.ttk.rst:181 ../../library/tkinter.ttk.rst:224 +#: ../../library/tkinter.ttk.rst:333 ../../library/tkinter.ttk.rst:426 +#: ../../library/tkinter.ttk.rst:508 ../../library/tkinter.ttk.rst:534 +#: ../../library/tkinter.ttk.rst:706 ../../library/tkinter.ttk.rst:778 +#: ../../library/tkinter.ttk.rst:848 ../../library/tkinter.ttk.rst:909 +#: ../../library/tkinter.ttk.rst:937 msgid "Option" msgstr "選項" -#: ../../library/tkinter.ttk.rst:121 ../../library/tkinter.ttk.rst:157 -#: ../../library/tkinter.ttk.rst:183 ../../library/tkinter.ttk.rst:226 -#: ../../library/tkinter.ttk.rst:242 ../../library/tkinter.ttk.rst:335 -#: ../../library/tkinter.ttk.rst:428 ../../library/tkinter.ttk.rst:510 -#: ../../library/tkinter.ttk.rst:536 ../../library/tkinter.ttk.rst:708 -#: ../../library/tkinter.ttk.rst:780 ../../library/tkinter.ttk.rst:850 -#: ../../library/tkinter.ttk.rst:911 ../../library/tkinter.ttk.rst:939 -#: ../../library/tkinter.ttk.rst:984 +#: ../../library/tkinter.ttk.rst:119 ../../library/tkinter.ttk.rst:155 +#: ../../library/tkinter.ttk.rst:181 ../../library/tkinter.ttk.rst:224 +#: ../../library/tkinter.ttk.rst:240 ../../library/tkinter.ttk.rst:333 +#: ../../library/tkinter.ttk.rst:426 ../../library/tkinter.ttk.rst:508 +#: ../../library/tkinter.ttk.rst:534 ../../library/tkinter.ttk.rst:706 +#: ../../library/tkinter.ttk.rst:778 ../../library/tkinter.ttk.rst:848 +#: ../../library/tkinter.ttk.rst:909 ../../library/tkinter.ttk.rst:937 +#: ../../library/tkinter.ttk.rst:982 msgid "Description" msgstr "描述" -#: ../../library/tkinter.ttk.rst:123 +#: ../../library/tkinter.ttk.rst:121 msgid "class" msgstr "class" -#: ../../library/tkinter.ttk.rst:123 +#: ../../library/tkinter.ttk.rst:121 msgid "" "Specifies the window class. The class is used when querying the option " "database for the window's other options, to determine the default bindtags " @@ -213,22 +213,22 @@ msgid "" "option is read-only, and may only be specified when the window is created." msgstr "" -#: ../../library/tkinter.ttk.rst:130 +#: ../../library/tkinter.ttk.rst:128 msgid "cursor" msgstr "cursor" -#: ../../library/tkinter.ttk.rst:130 +#: ../../library/tkinter.ttk.rst:128 msgid "" "Specifies the mouse cursor to be used for the widget. See the *cursor* " "option type under :ref:`Tk-option-data-types`. If set to the empty string " "(the default), the cursor is inherited from the parent widget." msgstr "" -#: ../../library/tkinter.ttk.rst:135 +#: ../../library/tkinter.ttk.rst:133 msgid "takefocus" msgstr "takefocus" -#: ../../library/tkinter.ttk.rst:135 +#: ../../library/tkinter.ttk.rst:133 msgid "" "Determines whether the window accepts the focus during keyboard traversal. " "0, 1 or an empty string is returned. If 0 is returned, it means that the " @@ -238,100 +238,100 @@ msgid "" "whether or not to focus on the window." msgstr "" -#: ../../library/tkinter.ttk.rst:144 +#: ../../library/tkinter.ttk.rst:142 msgid "style" msgstr "style" -#: ../../library/tkinter.ttk.rst:144 +#: ../../library/tkinter.ttk.rst:142 msgid "May be used to specify a custom widget style." msgstr "" -#: ../../library/tkinter.ttk.rst:149 +#: ../../library/tkinter.ttk.rst:147 msgid "Scrollable widget options" msgstr "" -#: ../../library/tkinter.ttk.rst:151 +#: ../../library/tkinter.ttk.rst:149 msgid "" "The following options are supported by widgets that are controlled by a " "scrollbar." msgstr "" -#: ../../library/tkinter.ttk.rst:159 +#: ../../library/tkinter.ttk.rst:157 msgid "xscrollcommand" msgstr "xscrollcommand" -#: ../../library/tkinter.ttk.rst:159 +#: ../../library/tkinter.ttk.rst:157 msgid "Used to communicate with horizontal scrollbars." msgstr "" -#: ../../library/tkinter.ttk.rst:161 +#: ../../library/tkinter.ttk.rst:159 msgid "" "When the view in the widget's window changes, the widget calls the " "*xscrollcommand* callback." msgstr "" -#: ../../library/tkinter.ttk.rst:164 +#: ../../library/tkinter.ttk.rst:162 msgid "" "Usually this option consists of the method :meth:`Scrollbar.set ` of some scrollbar. This will cause the scrollbar to be " "updated whenever the view in the window changes." msgstr "" -#: ../../library/tkinter.ttk.rst:169 +#: ../../library/tkinter.ttk.rst:167 msgid "yscrollcommand" msgstr "yscrollcommand" -#: ../../library/tkinter.ttk.rst:169 +#: ../../library/tkinter.ttk.rst:167 msgid "" "Used to communicate with vertical scrollbars. For some more information, see " "above." msgstr "" -#: ../../library/tkinter.ttk.rst:175 +#: ../../library/tkinter.ttk.rst:173 msgid "Label options" msgstr "標籤選項" -#: ../../library/tkinter.ttk.rst:177 +#: ../../library/tkinter.ttk.rst:175 msgid "" "The following options are supported by labels, buttons and other button-like " "widgets." msgstr "" -#: ../../library/tkinter.ttk.rst:185 ../../library/tkinter.ttk.rst:553 -#: ../../library/tkinter.ttk.rst:913 +#: ../../library/tkinter.ttk.rst:183 ../../library/tkinter.ttk.rst:551 +#: ../../library/tkinter.ttk.rst:911 msgid "text" msgstr "text" -#: ../../library/tkinter.ttk.rst:185 +#: ../../library/tkinter.ttk.rst:183 msgid "Specifies a text string to be displayed inside the widget." msgstr "" -#: ../../library/tkinter.ttk.rst:187 ../../library/tkinter.ttk.rst:357 +#: ../../library/tkinter.ttk.rst:185 ../../library/tkinter.ttk.rst:355 msgid "textvariable" msgstr "textvariable" -#: ../../library/tkinter.ttk.rst:187 +#: ../../library/tkinter.ttk.rst:185 msgid "" "Specifies a name whose value will be used in place of the text option " "resource." msgstr "" -#: ../../library/tkinter.ttk.rst:190 ../../library/tkinter.ttk.rst:562 +#: ../../library/tkinter.ttk.rst:188 ../../library/tkinter.ttk.rst:560 msgid "underline" msgstr "underline" -#: ../../library/tkinter.ttk.rst:190 +#: ../../library/tkinter.ttk.rst:188 msgid "" "If set, specifies the index (0-based) of a character to underline in the " "text string. The underline character is used for mnemonic activation." msgstr "" -#: ../../library/tkinter.ttk.rst:194 ../../library/tkinter.ttk.rst:555 -#: ../../library/tkinter.ttk.rst:915 ../../library/tkinter.ttk.rst:947 +#: ../../library/tkinter.ttk.rst:192 ../../library/tkinter.ttk.rst:553 +#: ../../library/tkinter.ttk.rst:913 ../../library/tkinter.ttk.rst:945 msgid "image" msgstr "image" -#: ../../library/tkinter.ttk.rst:194 +#: ../../library/tkinter.ttk.rst:192 msgid "" "Specifies an image to display. This is a list of 1 or more elements. The " "first element is the default image name. The rest of the list if a sequence " @@ -340,188 +340,188 @@ msgid "" "combination of states. All images in the list should have the same size." msgstr "" -#: ../../library/tkinter.ttk.rst:202 ../../library/tkinter.ttk.rst:558 +#: ../../library/tkinter.ttk.rst:200 ../../library/tkinter.ttk.rst:556 msgid "compound" msgstr "compound" -#: ../../library/tkinter.ttk.rst:202 +#: ../../library/tkinter.ttk.rst:200 msgid "" "Specifies how to display the image relative to the text, in the case both " "text and images options are present. Valid values are:" msgstr "" -#: ../../library/tkinter.ttk.rst:206 +#: ../../library/tkinter.ttk.rst:204 msgid "text: display text only" msgstr "" -#: ../../library/tkinter.ttk.rst:207 +#: ../../library/tkinter.ttk.rst:205 msgid "image: display image only" msgstr "" -#: ../../library/tkinter.ttk.rst:208 +#: ../../library/tkinter.ttk.rst:206 msgid "" "top, bottom, left, right: display image above, below, left of, or right of " "the text, respectively." msgstr "" -#: ../../library/tkinter.ttk.rst:210 +#: ../../library/tkinter.ttk.rst:208 msgid "none: the default. display the image if present, otherwise the text." msgstr "" -#: ../../library/tkinter.ttk.rst:213 ../../library/tkinter.ttk.rst:365 -#: ../../library/tkinter.ttk.rst:522 +#: ../../library/tkinter.ttk.rst:211 ../../library/tkinter.ttk.rst:363 +#: ../../library/tkinter.ttk.rst:520 msgid "width" msgstr "width" -#: ../../library/tkinter.ttk.rst:213 +#: ../../library/tkinter.ttk.rst:211 msgid "" "If greater than zero, specifies how much space, in character widths, to " "allocate for the text label, if less than zero, specifies a minimum width. " "If zero or unspecified, the natural width of the text label is used." msgstr "" -#: ../../library/tkinter.ttk.rst:221 +#: ../../library/tkinter.ttk.rst:219 msgid "Compatibility options" msgstr "相容性選項" -#: ../../library/tkinter.ttk.rst:228 ../../library/tkinter.ttk.rst:350 -#: ../../library/tkinter.ttk.rst:538 +#: ../../library/tkinter.ttk.rst:226 ../../library/tkinter.ttk.rst:348 +#: ../../library/tkinter.ttk.rst:536 msgid "state" msgstr "state" -#: ../../library/tkinter.ttk.rst:228 +#: ../../library/tkinter.ttk.rst:226 msgid "" "May be set to \"normal\" or \"disabled\" to control the \"disabled\" state " "bit. This is a write-only option: setting it changes the widget state, but " "the :meth:`Widget.state` method does not affect this option." msgstr "" -#: ../../library/tkinter.ttk.rst:235 +#: ../../library/tkinter.ttk.rst:233 msgid "Widget states" msgstr "" -#: ../../library/tkinter.ttk.rst:237 +#: ../../library/tkinter.ttk.rst:235 msgid "The widget state is a bitmap of independent state flags." msgstr "" -#: ../../library/tkinter.ttk.rst:242 +#: ../../library/tkinter.ttk.rst:240 msgid "Flag" msgstr "旗標" -#: ../../library/tkinter.ttk.rst:244 +#: ../../library/tkinter.ttk.rst:242 msgid "active" msgstr "active" -#: ../../library/tkinter.ttk.rst:244 +#: ../../library/tkinter.ttk.rst:242 msgid "" "The mouse cursor is over the widget and pressing a mouse button will cause " "some action to occur" msgstr "" -#: ../../library/tkinter.ttk.rst:247 +#: ../../library/tkinter.ttk.rst:245 msgid "disabled" msgstr "disabled" -#: ../../library/tkinter.ttk.rst:247 +#: ../../library/tkinter.ttk.rst:245 msgid "Widget is disabled under program control" msgstr "" -#: ../../library/tkinter.ttk.rst:249 +#: ../../library/tkinter.ttk.rst:247 msgid "focus" msgstr "focus" -#: ../../library/tkinter.ttk.rst:249 +#: ../../library/tkinter.ttk.rst:247 msgid "Widget has keyboard focus" msgstr "" -#: ../../library/tkinter.ttk.rst:251 +#: ../../library/tkinter.ttk.rst:249 msgid "pressed" msgstr "pressed" -#: ../../library/tkinter.ttk.rst:251 +#: ../../library/tkinter.ttk.rst:249 msgid "Widget is being pressed" msgstr "" -#: ../../library/tkinter.ttk.rst:253 +#: ../../library/tkinter.ttk.rst:251 msgid "selected" msgstr "selected" -#: ../../library/tkinter.ttk.rst:253 +#: ../../library/tkinter.ttk.rst:251 msgid "" "\"On\", \"true\", or \"current\" for things like Checkbuttons and " "radiobuttons" msgstr "" -#: ../../library/tkinter.ttk.rst:256 ../../library/tkinter.ttk.rst:943 +#: ../../library/tkinter.ttk.rst:254 ../../library/tkinter.ttk.rst:941 msgid "background" msgstr "background" -#: ../../library/tkinter.ttk.rst:256 +#: ../../library/tkinter.ttk.rst:254 msgid "" "Windows and Mac have a notion of an \"active\" or foreground window. The " "*background* state is set for widgets in a background window, and cleared " "for those in the foreground window" msgstr "" -#: ../../library/tkinter.ttk.rst:261 +#: ../../library/tkinter.ttk.rst:259 msgid "readonly" msgstr "readonly" -#: ../../library/tkinter.ttk.rst:261 +#: ../../library/tkinter.ttk.rst:259 msgid "Widget should not allow user modification" msgstr "" -#: ../../library/tkinter.ttk.rst:263 +#: ../../library/tkinter.ttk.rst:261 msgid "alternate" msgstr "alternate" -#: ../../library/tkinter.ttk.rst:263 +#: ../../library/tkinter.ttk.rst:261 msgid "A widget-specific alternate display format" msgstr "" -#: ../../library/tkinter.ttk.rst:265 +#: ../../library/tkinter.ttk.rst:263 msgid "invalid" msgstr "invalid" -#: ../../library/tkinter.ttk.rst:265 +#: ../../library/tkinter.ttk.rst:263 msgid "The widget's value is invalid" msgstr "" -#: ../../library/tkinter.ttk.rst:268 +#: ../../library/tkinter.ttk.rst:266 msgid "" "A state specification is a sequence of state names, optionally prefixed with " "an exclamation point indicating that the bit is off." msgstr "" -#: ../../library/tkinter.ttk.rst:273 +#: ../../library/tkinter.ttk.rst:271 msgid "ttk.Widget" msgstr "ttk.Widget" -#: ../../library/tkinter.ttk.rst:275 +#: ../../library/tkinter.ttk.rst:273 msgid "" "Besides the methods described below, the :class:`ttk.Widget ` " "supports the methods :meth:`tkinter.Widget.cget ` and :" "meth:`tkinter.Widget.configure `." msgstr "" -#: ../../library/tkinter.ttk.rst:283 +#: ../../library/tkinter.ttk.rst:281 msgid "" "Returns the name of the element at position *x* *y*, or the empty string if " "the point does not lie within any element." msgstr "" -#: ../../library/tkinter.ttk.rst:286 +#: ../../library/tkinter.ttk.rst:284 msgid "*x* and *y* are pixel coordinates relative to the widget." msgstr "" -#: ../../library/tkinter.ttk.rst:291 +#: ../../library/tkinter.ttk.rst:289 msgid "" "Test the widget's state. If a callback is not specified, returns ``True`` if " "the widget state matches *statespec* and ``False`` otherwise. If callback is " "specified then it is called with args if widget state matches *statespec*." msgstr "" -#: ../../library/tkinter.ttk.rst:299 +#: ../../library/tkinter.ttk.rst:297 msgid "" "Modify or inquire widget state. If *statespec* is specified, sets the widget " "state according to it and return a new *statespec* indicating which flags " @@ -529,25 +529,25 @@ msgid "" "state flags." msgstr "" -#: ../../library/tkinter.ttk.rst:304 +#: ../../library/tkinter.ttk.rst:302 msgid "Not to be confused with :meth:`Wm.state `." msgstr "" -#: ../../library/tkinter.ttk.rst:306 +#: ../../library/tkinter.ttk.rst:304 msgid "*statespec* will usually be a list or a tuple." msgstr "" -#: ../../library/tkinter.ttk.rst:310 +#: ../../library/tkinter.ttk.rst:308 msgid "Combobox" msgstr "" -#: ../../library/tkinter.ttk.rst:312 +#: ../../library/tkinter.ttk.rst:310 msgid "" "The :class:`ttk.Combobox ` widget combines a text field with a pop-" "down list of values. This widget is a subclass of :class:`Entry`." msgstr "" -#: ../../library/tkinter.ttk.rst:316 +#: ../../library/tkinter.ttk.rst:314 msgid "" "Besides the methods inherited from :class:`Widget`: :meth:`~tkinter.Misc." "cget`, :meth:`~tkinter.Misc.configure`, :meth:`~Widget.identify`, :meth:" @@ -559,58 +559,58 @@ msgid "" "class:`ttk.Combobox `." msgstr "" -#: ../../library/tkinter.ttk.rst:328 ../../library/tkinter.ttk.rst:421 -#: ../../library/tkinter.ttk.rst:503 ../../library/tkinter.ttk.rst:701 -#: ../../library/tkinter.ttk.rst:773 ../../library/tkinter.ttk.rst:843 +#: ../../library/tkinter.ttk.rst:326 ../../library/tkinter.ttk.rst:419 +#: ../../library/tkinter.ttk.rst:501 ../../library/tkinter.ttk.rst:699 +#: ../../library/tkinter.ttk.rst:771 ../../library/tkinter.ttk.rst:841 msgid "Options" msgstr "選項" -#: ../../library/tkinter.ttk.rst:330 ../../library/tkinter.ttk.rst:423 -#: ../../library/tkinter.ttk.rst:505 ../../library/tkinter.ttk.rst:703 -#: ../../library/tkinter.ttk.rst:845 +#: ../../library/tkinter.ttk.rst:328 ../../library/tkinter.ttk.rst:421 +#: ../../library/tkinter.ttk.rst:503 ../../library/tkinter.ttk.rst:701 +#: ../../library/tkinter.ttk.rst:843 msgid "This widget accepts the following specific options:" msgstr "" -#: ../../library/tkinter.ttk.rst:337 +#: ../../library/tkinter.ttk.rst:335 msgid "exportselection" msgstr "exportselection" -#: ../../library/tkinter.ttk.rst:337 +#: ../../library/tkinter.ttk.rst:335 msgid "" "Boolean value. If set, the widget selection is linked to the X selection " "(which can be returned by invoking Misc.selection_get, for example)." msgstr "" -#: ../../library/tkinter.ttk.rst:341 +#: ../../library/tkinter.ttk.rst:339 msgid "justify" msgstr "justify" -#: ../../library/tkinter.ttk.rst:341 +#: ../../library/tkinter.ttk.rst:339 msgid "" "Specifies how the text is aligned within the widget. One of \"left\", " "\"center\", or \"right\"." msgstr "" -#: ../../library/tkinter.ttk.rst:344 ../../library/tkinter.ttk.rst:512 -#: ../../library/tkinter.ttk.rst:860 +#: ../../library/tkinter.ttk.rst:342 ../../library/tkinter.ttk.rst:510 +#: ../../library/tkinter.ttk.rst:858 msgid "height" msgstr "height" -#: ../../library/tkinter.ttk.rst:344 +#: ../../library/tkinter.ttk.rst:342 msgid "Specifies the height of the pop-down listbox, in rows." msgstr "" -#: ../../library/tkinter.ttk.rst:346 +#: ../../library/tkinter.ttk.rst:344 msgid "postcommand" msgstr "postcommand" -#: ../../library/tkinter.ttk.rst:346 +#: ../../library/tkinter.ttk.rst:344 msgid "" "A script (possibly registered with Misc.register) that is called immediately " "before displaying the values. It may specify which values to display." msgstr "" -#: ../../library/tkinter.ttk.rst:350 +#: ../../library/tkinter.ttk.rst:348 msgid "" "One of \"normal\", \"readonly\", or \"disabled\". In the \"readonly\" state, " "the value may not be edited directly, and the user can only select one of " @@ -618,69 +618,69 @@ msgid "" "is directly editable. In the \"disabled\" state, no interaction is possible." msgstr "" -#: ../../library/tkinter.ttk.rst:357 +#: ../../library/tkinter.ttk.rst:355 msgid "" "Specifies a name whose value is linked to the widget value. Whenever the " "value associated with that name changes, the widget value is updated, and " "vice versa. See :class:`tkinter.StringVar`." msgstr "" -#: ../../library/tkinter.ttk.rst:362 ../../library/tkinter.ttk.rst:442 -#: ../../library/tkinter.ttk.rst:917 +#: ../../library/tkinter.ttk.rst:360 ../../library/tkinter.ttk.rst:440 +#: ../../library/tkinter.ttk.rst:915 msgid "values" msgstr "values" -#: ../../library/tkinter.ttk.rst:362 +#: ../../library/tkinter.ttk.rst:360 msgid "Specifies the list of values to display in the drop-down listbox." msgstr "" -#: ../../library/tkinter.ttk.rst:365 +#: ../../library/tkinter.ttk.rst:363 msgid "" "Specifies an integer value indicating the desired width of the entry window, " "in average-size characters of the widget's font." msgstr "" -#: ../../library/tkinter.ttk.rst:372 +#: ../../library/tkinter.ttk.rst:370 msgid "" "Tk 9.1 added the *locale* option, which selects the locale used to determine " "word and character boundaries within the text (``\"C\"`` by default)." msgstr "" -#: ../../library/tkinter.ttk.rst:377 ../../library/tkinter.ttk.rst:467 -#: ../../library/tkinter.ttk.rst:584 ../../library/tkinter.ttk.rst:977 +#: ../../library/tkinter.ttk.rst:375 ../../library/tkinter.ttk.rst:465 +#: ../../library/tkinter.ttk.rst:582 ../../library/tkinter.ttk.rst:975 msgid "Virtual events" msgstr "" -#: ../../library/tkinter.ttk.rst:379 +#: ../../library/tkinter.ttk.rst:377 msgid "" "The combobox widgets generates a **<>** virtual event when " "the user selects an element from the list of values." msgstr "" -#: ../../library/tkinter.ttk.rst:384 +#: ../../library/tkinter.ttk.rst:382 msgid "ttk.Combobox" msgstr "ttk.Combobox" -#: ../../library/tkinter.ttk.rst:390 +#: ../../library/tkinter.ttk.rst:388 msgid "" "If *newindex* is specified, sets the combobox value to the element position " "*newindex*. Otherwise, returns the index of the current value or -1 if the " "current value is not in the values list." msgstr "" -#: ../../library/tkinter.ttk.rst:397 +#: ../../library/tkinter.ttk.rst:395 msgid "Returns the current value of the combobox." msgstr "" -#: ../../library/tkinter.ttk.rst:402 +#: ../../library/tkinter.ttk.rst:400 msgid "Sets the value of the combobox to *value*." msgstr "" -#: ../../library/tkinter.ttk.rst:406 +#: ../../library/tkinter.ttk.rst:404 msgid "Spinbox" msgstr "" -#: ../../library/tkinter.ttk.rst:408 +#: ../../library/tkinter.ttk.rst:406 msgid "" "The :class:`ttk.Spinbox ` widget is a :class:`ttk.Entry ` " "enhanced with increment and decrement arrows. It can be used for numbers or " @@ -694,125 +694,125 @@ msgid "" "described at :class:`ttk.Spinbox `." msgstr "" -#: ../../library/tkinter.ttk.rst:430 +#: ../../library/tkinter.ttk.rst:428 msgid "from" msgstr "from" -#: ../../library/tkinter.ttk.rst:430 +#: ../../library/tkinter.ttk.rst:428 msgid "" "Float value. If set, this is the minimum value to which the decrement " "button will decrement. Must be spelled as ``from_`` when used as an " "argument, since ``from`` is a Python keyword." msgstr "" -#: ../../library/tkinter.ttk.rst:435 +#: ../../library/tkinter.ttk.rst:433 msgid "to" msgstr "to" -#: ../../library/tkinter.ttk.rst:435 +#: ../../library/tkinter.ttk.rst:433 msgid "" "Float value. If set, this is the maximum value to which the increment " "button will increment." msgstr "" -#: ../../library/tkinter.ttk.rst:438 +#: ../../library/tkinter.ttk.rst:436 msgid "increment" msgstr "increment" -#: ../../library/tkinter.ttk.rst:438 +#: ../../library/tkinter.ttk.rst:436 msgid "" "Float value. Specifies the amount which the increment/decrement buttons " "change the value. Defaults to 1.0." msgstr "" -#: ../../library/tkinter.ttk.rst:442 +#: ../../library/tkinter.ttk.rst:440 msgid "" "Sequence of string or float values. If specified, the increment/decrement " "buttons will cycle through the items in this sequence rather than " "incrementing or decrementing numbers." msgstr "" -#: ../../library/tkinter.ttk.rst:448 +#: ../../library/tkinter.ttk.rst:446 msgid "wrap" msgstr "wrap" -#: ../../library/tkinter.ttk.rst:448 +#: ../../library/tkinter.ttk.rst:446 msgid "" "Boolean value. If ``True``, increment and decrement buttons will cycle from " "the ``to`` value to the ``from`` value or the ``from`` value to the ``to`` " "value, respectively." msgstr "" -#: ../../library/tkinter.ttk.rst:453 +#: ../../library/tkinter.ttk.rst:451 msgid "format" msgstr "format" -#: ../../library/tkinter.ttk.rst:453 +#: ../../library/tkinter.ttk.rst:451 msgid "" "String value. This specifies the format of numbers set by the increment/" "decrement buttons. It must be in the form \"%W.Pf\", where W is the padded " "width of the value, P is the precision, and '%' and 'f' are literal." msgstr "" -#: ../../library/tkinter.ttk.rst:459 +#: ../../library/tkinter.ttk.rst:457 msgid "command" msgstr "command" -#: ../../library/tkinter.ttk.rst:459 +#: ../../library/tkinter.ttk.rst:457 msgid "" "Python callable. Will be called with no arguments whenever either of the " "increment or decrement buttons are pressed." msgstr "" -#: ../../library/tkinter.ttk.rst:469 +#: ../../library/tkinter.ttk.rst:467 msgid "" "The spinbox widget generates an **<>** virtual event when the " "user presses , and a **<>** virtual event when the user " "presses ." msgstr "" -#: ../../library/tkinter.ttk.rst:474 +#: ../../library/tkinter.ttk.rst:472 msgid "ttk.Spinbox" msgstr "ttk.Spinbox" -#: ../../library/tkinter.ttk.rst:478 +#: ../../library/tkinter.ttk.rst:476 msgid "" "With a non-integer increment, see :ref:`numeric values and the locale " "`." msgstr "" -#: ../../library/tkinter.ttk.rst:485 +#: ../../library/tkinter.ttk.rst:483 msgid "Returns the current value of the spinbox." msgstr "" -#: ../../library/tkinter.ttk.rst:490 +#: ../../library/tkinter.ttk.rst:488 msgid "Sets the value of the spinbox to *value*." msgstr "" -#: ../../library/tkinter.ttk.rst:495 +#: ../../library/tkinter.ttk.rst:493 msgid "Notebook" msgstr "" -#: ../../library/tkinter.ttk.rst:497 +#: ../../library/tkinter.ttk.rst:495 msgid "" "Ttk Notebook widget manages a collection of windows and displays a single " "one at a time. Each child window is associated with a tab, which the user " "may select to change the currently displayed window." msgstr "" -#: ../../library/tkinter.ttk.rst:512 +#: ../../library/tkinter.ttk.rst:510 msgid "" "If present and greater than zero, specifies the desired height of the pane " "area (not including internal padding or tabs). Otherwise, the maximum height " "of all panes is used." msgstr "" -#: ../../library/tkinter.ttk.rst:516 ../../library/tkinter.ttk.rst:549 -#: ../../library/tkinter.ttk.rst:864 +#: ../../library/tkinter.ttk.rst:514 ../../library/tkinter.ttk.rst:547 +#: ../../library/tkinter.ttk.rst:862 msgid "padding" msgstr "padding" -#: ../../library/tkinter.ttk.rst:516 +#: ../../library/tkinter.ttk.rst:514 msgid "" "Specifies the amount of extra space to add around the outside of the " "notebook. The padding is a list up to four length specifications left top " @@ -820,32 +820,32 @@ msgid "" "top, right defaults to left, and top defaults to left." msgstr "" -#: ../../library/tkinter.ttk.rst:522 +#: ../../library/tkinter.ttk.rst:520 msgid "" "If present and greater than zero, specified the desired width of the pane " "area (not including internal padding). Otherwise, the maximum width of all " "panes is used." msgstr "" -#: ../../library/tkinter.ttk.rst:529 +#: ../../library/tkinter.ttk.rst:527 msgid "Tab options" msgstr "標籤頁選項" -#: ../../library/tkinter.ttk.rst:531 +#: ../../library/tkinter.ttk.rst:529 msgid "There are also specific options for tabs:" msgstr "" -#: ../../library/tkinter.ttk.rst:538 +#: ../../library/tkinter.ttk.rst:536 msgid "" "Either \"normal\", \"disabled\" or \"hidden\". If \"disabled\", then the tab " "is not selectable. If \"hidden\", then the tab is not shown." msgstr "" -#: ../../library/tkinter.ttk.rst:542 +#: ../../library/tkinter.ttk.rst:540 msgid "sticky" msgstr "" -#: ../../library/tkinter.ttk.rst:542 +#: ../../library/tkinter.ttk.rst:540 msgid "" "Specifies how the child window is positioned within the pane area. Value is " "a string containing zero or more of the characters \"n\", \"s\", \"e\" or " @@ -854,206 +854,206 @@ msgid "" "geometry manager." msgstr "" -#: ../../library/tkinter.ttk.rst:549 +#: ../../library/tkinter.ttk.rst:547 msgid "" "Specifies the amount of extra space to add between the notebook and this " "pane. Syntax is the same as for the option padding used by this widget." msgstr "" -#: ../../library/tkinter.ttk.rst:553 +#: ../../library/tkinter.ttk.rst:551 msgid "Specifies a text to be displayed in the tab." msgstr "" -#: ../../library/tkinter.ttk.rst:555 +#: ../../library/tkinter.ttk.rst:553 msgid "" "Specifies an image to display in the tab. See the option image described in :" "class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:558 +#: ../../library/tkinter.ttk.rst:556 msgid "" "Specifies how to display the image relative to the text, in the case both " "options text and image are present. See `Label Options`_ for legal values." msgstr "" -#: ../../library/tkinter.ttk.rst:562 +#: ../../library/tkinter.ttk.rst:560 msgid "" "Specifies the index (0-based) of a character to underline in the text " "string. The underlined character is used for mnemonic activation if :meth:" "`Notebook.enable_traversal` is called." msgstr "" -#: ../../library/tkinter.ttk.rst:570 +#: ../../library/tkinter.ttk.rst:568 msgid "Tab identifiers" msgstr "" -#: ../../library/tkinter.ttk.rst:572 +#: ../../library/tkinter.ttk.rst:570 msgid "" "The tab_id present in several methods of :class:`ttk.Notebook ` " "may take any of the following forms:" msgstr "" -#: ../../library/tkinter.ttk.rst:575 +#: ../../library/tkinter.ttk.rst:573 msgid "An integer between zero and the number of tabs" msgstr "" -#: ../../library/tkinter.ttk.rst:576 +#: ../../library/tkinter.ttk.rst:574 msgid "The name of a child window" msgstr "" -#: ../../library/tkinter.ttk.rst:577 +#: ../../library/tkinter.ttk.rst:575 msgid "" "A positional specification of the form \"@x,y\", which identifies the tab" msgstr "" -#: ../../library/tkinter.ttk.rst:578 +#: ../../library/tkinter.ttk.rst:576 msgid "" "The literal string \"current\", which identifies the currently selected tab" msgstr "" -#: ../../library/tkinter.ttk.rst:579 +#: ../../library/tkinter.ttk.rst:577 msgid "" "The literal string \"end\", which returns the number of tabs (only valid " "for :meth:`Notebook.index`)" msgstr "" -#: ../../library/tkinter.ttk.rst:586 +#: ../../library/tkinter.ttk.rst:584 msgid "" "This widget generates a **<>** virtual event after a new " "tab is selected." msgstr "" -#: ../../library/tkinter.ttk.rst:591 +#: ../../library/tkinter.ttk.rst:589 msgid "ttk.Notebook" msgstr "ttk.Notebook" -#: ../../library/tkinter.ttk.rst:597 +#: ../../library/tkinter.ttk.rst:595 msgid "Adds a new tab to the notebook." msgstr "" -#: ../../library/tkinter.ttk.rst:599 +#: ../../library/tkinter.ttk.rst:597 msgid "" "If window is currently managed by the notebook but hidden, it is restored to " "its previous position." msgstr "" -#: ../../library/tkinter.ttk.rst:602 ../../library/tkinter.ttk.rst:645 +#: ../../library/tkinter.ttk.rst:600 ../../library/tkinter.ttk.rst:643 msgid "See `Tab Options`_ for the list of available options." msgstr "可用的選項清單請見 `Tab Options`_。" -#: ../../library/tkinter.ttk.rst:607 +#: ../../library/tkinter.ttk.rst:605 msgid "" "Removes the tab specified by *tab_id*, unmaps and unmanages the associated " "window." msgstr "" -#: ../../library/tkinter.ttk.rst:610 ../../library/tkinter.ttk.rst:1819 +#: ../../library/tkinter.ttk.rst:608 ../../library/tkinter.ttk.rst:1817 msgid "" "This shadows the inherited geometry-manager :meth:`!forget`; use :meth:" "`~tkinter.Pack.pack_forget`, :meth:`~tkinter.Grid.grid_forget` or :meth:" "`~tkinter.Place.place_forget` to remove the widget itself from its manager." msgstr "" -#: ../../library/tkinter.ttk.rst:618 +#: ../../library/tkinter.ttk.rst:616 msgid "Hides the tab specified by *tab_id*." msgstr "" -#: ../../library/tkinter.ttk.rst:620 +#: ../../library/tkinter.ttk.rst:618 msgid "" "The tab will not be displayed, but the associated window remains managed by " "the notebook and its configuration remembered. Hidden tabs may be restored " "with the :meth:`add` command." msgstr "" -#: ../../library/tkinter.ttk.rst:627 +#: ../../library/tkinter.ttk.rst:625 msgid "" "Returns the name of the tab element at position *x*, *y*, or the empty " "string if none." msgstr "" -#: ../../library/tkinter.ttk.rst:633 +#: ../../library/tkinter.ttk.rst:631 msgid "" "Returns the numeric index of the tab specified by *tab_id*, or the total " "number of tabs if *tab_id* is the string \"end\"." msgstr "" -#: ../../library/tkinter.ttk.rst:639 +#: ../../library/tkinter.ttk.rst:637 msgid "Inserts a pane at the specified position." msgstr "" -#: ../../library/tkinter.ttk.rst:641 +#: ../../library/tkinter.ttk.rst:639 msgid "" "*pos* is either the string \"end\", an integer index, or the name of a " "managed child. If *child* is already managed by the notebook, moves it to " "the specified position." msgstr "" -#: ../../library/tkinter.ttk.rst:650 +#: ../../library/tkinter.ttk.rst:648 msgid "Selects the specified *tab_id*." msgstr "" -#: ../../library/tkinter.ttk.rst:652 +#: ../../library/tkinter.ttk.rst:650 msgid "" "The associated child window will be displayed, and the previously selected " "window (if different) is unmapped. If *tab_id* is omitted, returns the " "widget name of the currently selected pane." msgstr "" -#: ../../library/tkinter.ttk.rst:659 +#: ../../library/tkinter.ttk.rst:657 msgid "Query or modify the options of the specific *tab_id*." msgstr "" -#: ../../library/tkinter.ttk.rst:661 +#: ../../library/tkinter.ttk.rst:659 msgid "" "If *kw* is not given, returns a dictionary of the tab option values. If " "*option* is specified, returns the value of that *option*. Otherwise, sets " "the options to the corresponding values." msgstr "" -#: ../../library/tkinter.ttk.rst:668 +#: ../../library/tkinter.ttk.rst:666 msgid "Returns a tuple of windows managed by the notebook." msgstr "" -#: ../../library/tkinter.ttk.rst:673 +#: ../../library/tkinter.ttk.rst:671 msgid "" "Enable keyboard traversal for a toplevel window containing this notebook." msgstr "" -#: ../../library/tkinter.ttk.rst:675 +#: ../../library/tkinter.ttk.rst:673 msgid "" "This will extend the bindings for the toplevel window containing the " "notebook as follows:" msgstr "" -#: ../../library/tkinter.ttk.rst:678 +#: ../../library/tkinter.ttk.rst:676 msgid "" ":kbd:`Control-Tab`: selects the tab following the currently selected one." msgstr "" -#: ../../library/tkinter.ttk.rst:679 +#: ../../library/tkinter.ttk.rst:677 msgid "" ":kbd:`Shift-Control-Tab`: selects the tab preceding the currently selected " "one." msgstr "" -#: ../../library/tkinter.ttk.rst:680 +#: ../../library/tkinter.ttk.rst:678 msgid "" ":kbd:`Alt-K`: where *K* is the mnemonic (underlined) character of any tab, " "will select that tab." msgstr "" -#: ../../library/tkinter.ttk.rst:683 +#: ../../library/tkinter.ttk.rst:681 msgid "" "Multiple notebooks in a single toplevel may be enabled for traversal, " "including nested notebooks. However, notebook traversal only works properly " "if all panes are direct children of the notebook." msgstr "" -#: ../../library/tkinter.ttk.rst:690 +#: ../../library/tkinter.ttk.rst:688 msgid "Progressbar" msgstr "" -#: ../../library/tkinter.ttk.rst:692 +#: ../../library/tkinter.ttk.rst:690 msgid "" "The :class:`ttk.Progressbar ` widget shows the status of a long-" "running operation. It can operate in two modes: 1) the determinate mode " @@ -1062,47 +1062,47 @@ msgid "" "the user know that work is progressing." msgstr "" -#: ../../library/tkinter.ttk.rst:710 ../../library/tkinter.ttk.rst:782 +#: ../../library/tkinter.ttk.rst:708 ../../library/tkinter.ttk.rst:780 msgid "orient" msgstr "orient" -#: ../../library/tkinter.ttk.rst:710 +#: ../../library/tkinter.ttk.rst:708 msgid "" "One of \"horizontal\" or \"vertical\". Specifies the orientation of the " "progress bar." msgstr "" -#: ../../library/tkinter.ttk.rst:713 +#: ../../library/tkinter.ttk.rst:711 msgid "length" msgstr "length" -#: ../../library/tkinter.ttk.rst:713 +#: ../../library/tkinter.ttk.rst:711 msgid "" "Specifies the length of the long axis of the progress bar (width if " "horizontal, height if vertical)." msgstr "" -#: ../../library/tkinter.ttk.rst:716 +#: ../../library/tkinter.ttk.rst:714 msgid "mode" msgstr "mode" -#: ../../library/tkinter.ttk.rst:716 +#: ../../library/tkinter.ttk.rst:714 msgid "One of \"determinate\" or \"indeterminate\"." msgstr "\"determinate\" 與 \"indeterminate\" 其中之一" -#: ../../library/tkinter.ttk.rst:718 +#: ../../library/tkinter.ttk.rst:716 msgid "maximum" msgstr "maximum" -#: ../../library/tkinter.ttk.rst:718 +#: ../../library/tkinter.ttk.rst:716 msgid "A number specifying the maximum value. Defaults to 100." msgstr "" -#: ../../library/tkinter.ttk.rst:720 +#: ../../library/tkinter.ttk.rst:718 msgid "value" msgstr "value" -#: ../../library/tkinter.ttk.rst:720 +#: ../../library/tkinter.ttk.rst:718 msgid "" "The current value of the progress bar. In \"determinate\" mode, this " "represents the amount of work completed. In \"indeterminate\" mode, it is " @@ -1110,22 +1110,22 @@ msgid "" "\"cycle\" when its value increases by *maximum*." msgstr "" -#: ../../library/tkinter.ttk.rst:726 +#: ../../library/tkinter.ttk.rst:724 msgid "variable" msgstr "variable" -#: ../../library/tkinter.ttk.rst:726 +#: ../../library/tkinter.ttk.rst:724 msgid "" "A name which is linked to the option value. If specified, the value of the " "progress bar is automatically set to the value of this name whenever the " "latter is modified." msgstr "" -#: ../../library/tkinter.ttk.rst:730 +#: ../../library/tkinter.ttk.rst:728 msgid "phase" msgstr "phase" -#: ../../library/tkinter.ttk.rst:730 +#: ../../library/tkinter.ttk.rst:728 msgid "" "Read-only option. The widget periodically increments the value of this " "option whenever its value is greater than 0 and, in determinate mode, less " @@ -1133,105 +1133,105 @@ msgid "" "additional animation effects." msgstr "" -#: ../../library/tkinter.ttk.rst:738 +#: ../../library/tkinter.ttk.rst:736 msgid "ttk.Progressbar" msgstr "ttk.Progressbar" -#: ../../library/tkinter.ttk.rst:744 +#: ../../library/tkinter.ttk.rst:742 msgid "" "Begin autoincrement mode: schedules a recurring timer event that calls :meth:" "`Progressbar.step` every *interval* milliseconds. If omitted, *interval* " "defaults to 50 milliseconds." msgstr "" -#: ../../library/tkinter.ttk.rst:751 +#: ../../library/tkinter.ttk.rst:749 msgid "Increments the progress bar's value by *amount*." msgstr "" -#: ../../library/tkinter.ttk.rst:753 +#: ../../library/tkinter.ttk.rst:751 msgid "*amount* defaults to 1.0 if omitted." msgstr "" -#: ../../library/tkinter.ttk.rst:758 +#: ../../library/tkinter.ttk.rst:756 msgid "" "Stop autoincrement mode: cancels any recurring timer event initiated by :" "meth:`Progressbar.start` for this progress bar." msgstr "" -#: ../../library/tkinter.ttk.rst:763 +#: ../../library/tkinter.ttk.rst:761 msgid "Separator" msgstr "" -#: ../../library/tkinter.ttk.rst:765 +#: ../../library/tkinter.ttk.rst:763 msgid "" "The :class:`ttk.Separator ` widget displays a horizontal or " "vertical separator bar." msgstr "" -#: ../../library/tkinter.ttk.rst:768 +#: ../../library/tkinter.ttk.rst:766 msgid "" "It has no other methods besides the ones inherited from :class:`ttk.Widget " "`." msgstr "" -#: ../../library/tkinter.ttk.rst:775 +#: ../../library/tkinter.ttk.rst:773 msgid "This widget accepts the following specific option:" msgstr "" -#: ../../library/tkinter.ttk.rst:782 +#: ../../library/tkinter.ttk.rst:780 msgid "" "One of \"horizontal\" or \"vertical\". Specifies the orientation of the " "separator." msgstr "" -#: ../../library/tkinter.ttk.rst:788 +#: ../../library/tkinter.ttk.rst:786 msgid "Sizegrip" msgstr "" -#: ../../library/tkinter.ttk.rst:790 +#: ../../library/tkinter.ttk.rst:788 msgid "" "The :class:`ttk.Sizegrip ` widget (also known as a grow box) " "allows the user to resize the containing toplevel window by pressing and " "dragging the grip." msgstr "" -#: ../../library/tkinter.ttk.rst:794 +#: ../../library/tkinter.ttk.rst:792 msgid "" "This widget has neither specific options nor specific methods, besides the " "ones inherited from :class:`ttk.Widget `." msgstr "" -#: ../../library/tkinter.ttk.rst:799 +#: ../../library/tkinter.ttk.rst:797 msgid "Platform-specific notes" msgstr "" -#: ../../library/tkinter.ttk.rst:801 +#: ../../library/tkinter.ttk.rst:799 msgid "" "On macOS, toplevel windows automatically include a built-in size grip by " "default. Adding a :class:`Sizegrip` is harmless, since the built-in grip " "will just mask the widget." msgstr "" -#: ../../library/tkinter.ttk.rst:807 +#: ../../library/tkinter.ttk.rst:805 msgid "Bugs" msgstr "" -#: ../../library/tkinter.ttk.rst:809 +#: ../../library/tkinter.ttk.rst:807 msgid "" "If the containing toplevel's position was specified relative to the right or " "bottom of the screen (for example, ....), the :class:`Sizegrip` widget will " "not resize the window." msgstr "" -#: ../../library/tkinter.ttk.rst:812 +#: ../../library/tkinter.ttk.rst:810 msgid "This widget supports only \"southeast\" resizing." msgstr "" -#: ../../library/tkinter.ttk.rst:816 +#: ../../library/tkinter.ttk.rst:814 msgid "Treeview" msgstr "" -#: ../../library/tkinter.ttk.rst:818 +#: ../../library/tkinter.ttk.rst:816 msgid "" "The :class:`ttk.Treeview ` widget displays a hierarchical " "collection of items. Each item has a textual label, an optional image, and " @@ -1239,7 +1239,7 @@ msgid "" "columns after the tree label." msgstr "" -#: ../../library/tkinter.ttk.rst:824 +#: ../../library/tkinter.ttk.rst:822 msgid "" "The order in which data values are displayed may be controlled by setting " "the widget option ``displaycolumns``. The tree widget can also display " @@ -1247,7 +1247,7 @@ msgid "" "in the widget option columns. See `Column Identifiers`_." msgstr "" -#: ../../library/tkinter.ttk.rst:829 +#: ../../library/tkinter.ttk.rst:827 msgid "" "Each item is identified by a unique name. The widget will generate item IDs " "if they are not supplied by the caller. There is a distinguished root item, " @@ -1255,57 +1255,57 @@ msgid "" "the top level of the hierarchy." msgstr "" -#: ../../library/tkinter.ttk.rst:834 +#: ../../library/tkinter.ttk.rst:832 msgid "" "Each item also has a list of tags, which can be used to associate event " "bindings with individual items and control the appearance of the item." msgstr "" -#: ../../library/tkinter.ttk.rst:837 +#: ../../library/tkinter.ttk.rst:835 msgid "" "The Treeview widget supports horizontal and vertical scrolling, according to " "the options described in `Scrollable Widget Options`_ and the methods :meth:" "`Treeview.xview` and :meth:`Treeview.yview`." msgstr "" -#: ../../library/tkinter.ttk.rst:852 +#: ../../library/tkinter.ttk.rst:850 msgid "columns" msgstr "columns" -#: ../../library/tkinter.ttk.rst:852 +#: ../../library/tkinter.ttk.rst:850 msgid "" "A list of column identifiers, specifying the number of columns and their " "names." msgstr "" -#: ../../library/tkinter.ttk.rst:855 +#: ../../library/tkinter.ttk.rst:853 msgid "displaycolumns" msgstr "displaycolumns" -#: ../../library/tkinter.ttk.rst:855 +#: ../../library/tkinter.ttk.rst:853 msgid "" "A list of column identifiers (either symbolic or integer indices) specifying " "which data columns are displayed and the order in which they appear, or the " "string \"#all\"." msgstr "" -#: ../../library/tkinter.ttk.rst:860 +#: ../../library/tkinter.ttk.rst:858 msgid "" "Specifies the number of rows which should be visible. Note: the requested " "width is determined from the sum of the column widths." msgstr "" -#: ../../library/tkinter.ttk.rst:864 +#: ../../library/tkinter.ttk.rst:862 msgid "" "Specifies the internal padding for the widget. The padding is a list of up " "to four length specifications." msgstr "" -#: ../../library/tkinter.ttk.rst:867 +#: ../../library/tkinter.ttk.rst:865 msgid "selectmode" msgstr "selectmode" -#: ../../library/tkinter.ttk.rst:867 +#: ../../library/tkinter.ttk.rst:865 msgid "" "Controls how the built-in class bindings manage the selection. One of " "\"extended\", \"browse\" or \"none\". If set to \"extended\" (the default), " @@ -1313,41 +1313,41 @@ msgid "" "selected at a time. If \"none\", the selection will not be changed." msgstr "" -#: ../../library/tkinter.ttk.rst:874 +#: ../../library/tkinter.ttk.rst:872 msgid "" "Note that the application code and tag bindings can set the selection " "however they wish, regardless of the value of this option." msgstr "" -#: ../../library/tkinter.ttk.rst:878 +#: ../../library/tkinter.ttk.rst:876 msgid "show" msgstr "show" -#: ../../library/tkinter.ttk.rst:878 +#: ../../library/tkinter.ttk.rst:876 msgid "" "A list containing zero or more of the following values, specifying which " "elements of the tree to display." msgstr "" -#: ../../library/tkinter.ttk.rst:881 +#: ../../library/tkinter.ttk.rst:879 msgid "tree: display tree labels in column #0." msgstr "" -#: ../../library/tkinter.ttk.rst:882 +#: ../../library/tkinter.ttk.rst:880 msgid "headings: display the heading row." msgstr "" -#: ../../library/tkinter.ttk.rst:884 +#: ../../library/tkinter.ttk.rst:882 msgid "The default is \"tree headings\", that is, show all elements." msgstr "" -#: ../../library/tkinter.ttk.rst:887 +#: ../../library/tkinter.ttk.rst:885 msgid "" "**Note**: Column #0 always refers to the tree column, even if show=\"tree\" " "is not specified." msgstr "" -#: ../../library/tkinter.ttk.rst:893 +#: ../../library/tkinter.ttk.rst:891 msgid "" "Tk 9.0 added several :class:`Treeview` features. The *selectmode* option " "gained the values ``\"single\"`` and ``\"multiple\"``; the new widget " @@ -1358,29 +1358,29 @@ msgid "" "*headingheight* options." msgstr "" -#: ../../library/tkinter.ttk.rst:903 +#: ../../library/tkinter.ttk.rst:901 msgid "Item options" msgstr "項目選項" -#: ../../library/tkinter.ttk.rst:905 +#: ../../library/tkinter.ttk.rst:903 msgid "" "The following item options may be specified for items in the insert and item " "widget commands." msgstr "" -#: ../../library/tkinter.ttk.rst:913 +#: ../../library/tkinter.ttk.rst:911 msgid "The textual label to display for the item." msgstr "" -#: ../../library/tkinter.ttk.rst:915 +#: ../../library/tkinter.ttk.rst:913 msgid "A Tk Image, displayed to the left of the label." msgstr "" -#: ../../library/tkinter.ttk.rst:917 +#: ../../library/tkinter.ttk.rst:915 msgid "The list of values associated with the item." msgstr "" -#: ../../library/tkinter.ttk.rst:919 +#: ../../library/tkinter.ttk.rst:917 msgid "" "Each item should have the same number of values as the widget option " "columns. If there are fewer values than columns, the remaining values are " @@ -1388,95 +1388,95 @@ msgid "" "ignored." msgstr "" -#: ../../library/tkinter.ttk.rst:924 +#: ../../library/tkinter.ttk.rst:922 msgid "open" msgstr "open" -#: ../../library/tkinter.ttk.rst:924 +#: ../../library/tkinter.ttk.rst:922 msgid "" "``True``/``False`` value indicating whether the item's children should be " "displayed or hidden." msgstr "" -#: ../../library/tkinter.ttk.rst:927 +#: ../../library/tkinter.ttk.rst:925 msgid "tags" msgstr "tags" -#: ../../library/tkinter.ttk.rst:927 +#: ../../library/tkinter.ttk.rst:925 msgid "A list of tags associated with this item." msgstr "" -#: ../../library/tkinter.ttk.rst:932 +#: ../../library/tkinter.ttk.rst:930 msgid "Tag options" msgstr "標記選項" -#: ../../library/tkinter.ttk.rst:934 +#: ../../library/tkinter.ttk.rst:932 msgid "The following options may be specified on tags:" msgstr "" -#: ../../library/tkinter.ttk.rst:941 +#: ../../library/tkinter.ttk.rst:939 msgid "foreground" msgstr "foreground" -#: ../../library/tkinter.ttk.rst:941 +#: ../../library/tkinter.ttk.rst:939 msgid "Specifies the text foreground color." msgstr "" -#: ../../library/tkinter.ttk.rst:943 +#: ../../library/tkinter.ttk.rst:941 msgid "Specifies the cell or item background color." msgstr "" -#: ../../library/tkinter.ttk.rst:945 +#: ../../library/tkinter.ttk.rst:943 msgid "font" msgstr "font" -#: ../../library/tkinter.ttk.rst:945 +#: ../../library/tkinter.ttk.rst:943 msgid "Specifies the font to use when drawing text." msgstr "" -#: ../../library/tkinter.ttk.rst:947 +#: ../../library/tkinter.ttk.rst:945 msgid "Specifies the item image, in case the item's image option is empty." msgstr "" -#: ../../library/tkinter.ttk.rst:953 +#: ../../library/tkinter.ttk.rst:951 msgid "Column identifiers" msgstr "" -#: ../../library/tkinter.ttk.rst:955 +#: ../../library/tkinter.ttk.rst:953 msgid "Column identifiers take any of the following forms:" msgstr "" -#: ../../library/tkinter.ttk.rst:957 +#: ../../library/tkinter.ttk.rst:955 msgid "A symbolic name from the list of columns option." msgstr "" -#: ../../library/tkinter.ttk.rst:958 +#: ../../library/tkinter.ttk.rst:956 msgid "An integer n, specifying the nth data column." msgstr "" -#: ../../library/tkinter.ttk.rst:959 +#: ../../library/tkinter.ttk.rst:957 msgid "" "A string of the form #n, where n is an integer, specifying the nth display " "column." msgstr "" -#: ../../library/tkinter.ttk.rst:962 +#: ../../library/tkinter.ttk.rst:960 msgid "Notes:" msgstr "註解:" -#: ../../library/tkinter.ttk.rst:964 +#: ../../library/tkinter.ttk.rst:962 msgid "" "Item's option values may be displayed in a different order than the order in " "which they are stored." msgstr "" -#: ../../library/tkinter.ttk.rst:966 +#: ../../library/tkinter.ttk.rst:964 msgid "" "Column #0 always refers to the tree column, even if show=\"tree\" is not " "specified." msgstr "" -#: ../../library/tkinter.ttk.rst:969 +#: ../../library/tkinter.ttk.rst:967 msgid "" "A data column number is an index into an item's option values list; a " "display column number is the column number in the tree where the values are " @@ -1485,80 +1485,80 @@ msgid "" "#0 always refers to the tree column**." msgstr "" -#: ../../library/tkinter.ttk.rst:979 +#: ../../library/tkinter.ttk.rst:977 msgid "The Treeview widget generates the following virtual events." msgstr "" -#: ../../library/tkinter.ttk.rst:984 +#: ../../library/tkinter.ttk.rst:982 msgid "Event" msgstr "事件" -#: ../../library/tkinter.ttk.rst:986 +#: ../../library/tkinter.ttk.rst:984 msgid "<>" msgstr "<>" -#: ../../library/tkinter.ttk.rst:986 +#: ../../library/tkinter.ttk.rst:984 msgid "Generated whenever the selection changes." msgstr "" -#: ../../library/tkinter.ttk.rst:988 +#: ../../library/tkinter.ttk.rst:986 msgid "<>" msgstr "<>" -#: ../../library/tkinter.ttk.rst:988 +#: ../../library/tkinter.ttk.rst:986 msgid "Generated just before settings the focus item to open=True." msgstr "" -#: ../../library/tkinter.ttk.rst:991 +#: ../../library/tkinter.ttk.rst:989 msgid "<>" msgstr "<>" -#: ../../library/tkinter.ttk.rst:991 +#: ../../library/tkinter.ttk.rst:989 msgid "Generated just after setting the focus item to open=False." msgstr "" -#: ../../library/tkinter.ttk.rst:995 +#: ../../library/tkinter.ttk.rst:993 msgid "" "The :meth:`Treeview.focus` and :meth:`Treeview.selection` methods can be " "used to determine the affected item or items." msgstr "" -#: ../../library/tkinter.ttk.rst:1000 +#: ../../library/tkinter.ttk.rst:998 msgid "ttk.Treeview" msgstr "ttk.Treeview" -#: ../../library/tkinter.ttk.rst:1006 +#: ../../library/tkinter.ttk.rst:1004 msgid "" "Returns the bounding box (relative to the treeview widget's window) of the " "specified *item* in the form (x, y, width, height)." msgstr "" -#: ../../library/tkinter.ttk.rst:1009 +#: ../../library/tkinter.ttk.rst:1007 msgid "" "If *column* is specified, returns the bounding box of that cell. If the " "*item* is not visible (that is, if it is a descendant of a closed item or is " "scrolled offscreen), returns an empty string." msgstr "" -#: ../../library/tkinter.ttk.rst:1013 ../../library/tkinter.ttk.rst:1720 +#: ../../library/tkinter.ttk.rst:1011 ../../library/tkinter.ttk.rst:1718 msgid "" "This shadows the inherited :meth:`!Misc.bbox`; use :meth:`~tkinter.Misc." "grid_bbox` for the grid bounding box." msgstr "" -#: ../../library/tkinter.ttk.rst:1019 +#: ../../library/tkinter.ttk.rst:1017 msgid "Returns a tuple of children belonging to *item*." msgstr "" -#: ../../library/tkinter.ttk.rst:1021 +#: ../../library/tkinter.ttk.rst:1019 msgid "If *item* is not specified, returns root children." msgstr "" -#: ../../library/tkinter.ttk.rst:1026 +#: ../../library/tkinter.ttk.rst:1024 msgid "Replaces *item*'s children with *newchildren*." msgstr "" -#: ../../library/tkinter.ttk.rst:1028 +#: ../../library/tkinter.ttk.rst:1026 msgid "" "Children present in *item* that are not present in *newchildren* are " "detached from the tree. No items in *newchildren* may be an ancestor of " @@ -1566,254 +1566,254 @@ msgid "" "children." msgstr "" -#: ../../library/tkinter.ttk.rst:1036 +#: ../../library/tkinter.ttk.rst:1034 msgid "Query or modify the options for the specified *column*." msgstr "" -#: ../../library/tkinter.ttk.rst:1038 +#: ../../library/tkinter.ttk.rst:1036 msgid "" "If *kw* is not given, returns a dict of the column option values. If " "*option* is specified then the value for that *option* is returned. " "Otherwise, sets the options to the corresponding values." msgstr "" -#: ../../library/tkinter.ttk.rst:1042 ../../library/tkinter.ttk.rst:1104 -#: ../../library/tkinter.ttk.rst:1652 +#: ../../library/tkinter.ttk.rst:1040 ../../library/tkinter.ttk.rst:1102 +#: ../../library/tkinter.ttk.rst:1650 msgid "The valid options/values are:" msgstr "有效的選項/值為:" -#: ../../library/tkinter.ttk.rst:1044 +#: ../../library/tkinter.ttk.rst:1042 msgid "*id*" msgstr "*id*" -#: ../../library/tkinter.ttk.rst:1045 +#: ../../library/tkinter.ttk.rst:1043 msgid "Returns the column name. This is a read-only option." msgstr "回傳欄位名稱。這是唯讀選項。" -#: ../../library/tkinter.ttk.rst:1046 +#: ../../library/tkinter.ttk.rst:1044 msgid "*anchor*: One of the standard Tk anchor values." msgstr "" -#: ../../library/tkinter.ttk.rst:1047 +#: ../../library/tkinter.ttk.rst:1045 msgid "" "Specifies how the text in this column should be aligned with respect to the " "cell." msgstr "" -#: ../../library/tkinter.ttk.rst:1049 +#: ../../library/tkinter.ttk.rst:1047 msgid "*minwidth*: width" msgstr "" -#: ../../library/tkinter.ttk.rst:1050 +#: ../../library/tkinter.ttk.rst:1048 msgid "" "The minimum width of the column in pixels. The treeview widget will not make " "the column any smaller than specified by this option when the widget is " "resized or the user drags a column." msgstr "" -#: ../../library/tkinter.ttk.rst:1053 +#: ../../library/tkinter.ttk.rst:1051 msgid "*separator*: ``True``/``False``" msgstr "" -#: ../../library/tkinter.ttk.rst:1054 +#: ../../library/tkinter.ttk.rst:1052 msgid "" "Specifies whether a column separator should be drawn to the right of the " "column." msgstr "" -#: ../../library/tkinter.ttk.rst:1056 +#: ../../library/tkinter.ttk.rst:1054 msgid "*stretch*: ``True``/``False``" msgstr "" -#: ../../library/tkinter.ttk.rst:1057 +#: ../../library/tkinter.ttk.rst:1055 msgid "" "Specifies whether the column's width should be adjusted when the widget is " "resized." msgstr "" -#: ../../library/tkinter.ttk.rst:1059 +#: ../../library/tkinter.ttk.rst:1057 msgid "*width*: width" msgstr "" -#: ../../library/tkinter.ttk.rst:1060 +#: ../../library/tkinter.ttk.rst:1058 msgid "The width of the column in pixels." msgstr "" -#: ../../library/tkinter.ttk.rst:1062 +#: ../../library/tkinter.ttk.rst:1060 msgid "To configure the tree column, call this with column = \"#0\"" msgstr "" -#: ../../library/tkinter.ttk.rst:1066 +#: ../../library/tkinter.ttk.rst:1064 msgid "Delete all specified *items* and all their descendants." msgstr "" -#: ../../library/tkinter.ttk.rst:1068 +#: ../../library/tkinter.ttk.rst:1066 msgid "The root item may not be deleted." msgstr "" -#: ../../library/tkinter.ttk.rst:1073 +#: ../../library/tkinter.ttk.rst:1071 msgid "Unlinks all of the specified *items* from the tree." msgstr "" -#: ../../library/tkinter.ttk.rst:1075 +#: ../../library/tkinter.ttk.rst:1073 msgid "" "The items and all of their descendants are still present, and may be " "reinserted at another point in the tree, but will not be displayed." msgstr "" -#: ../../library/tkinter.ttk.rst:1078 +#: ../../library/tkinter.ttk.rst:1076 msgid "The root item may not be detached." msgstr "" -#: ../../library/tkinter.ttk.rst:1083 +#: ../../library/tkinter.ttk.rst:1081 msgid "" "Returns ``True`` if the specified *item* is present in the tree, ``False`` " "otherwise." msgstr "" -#: ../../library/tkinter.ttk.rst:1089 +#: ../../library/tkinter.ttk.rst:1087 msgid "" "If *item* is specified, sets the focus item to *item*. Otherwise, returns " "the current focus item, or '' if there is none." msgstr "" -#: ../../library/tkinter.ttk.rst:1092 +#: ../../library/tkinter.ttk.rst:1090 msgid "" "This shadows the inherited :meth:`!Misc.focus`; use :meth:`~tkinter.Misc." "focus_set` to focus the widget itself." msgstr "" -#: ../../library/tkinter.ttk.rst:1098 +#: ../../library/tkinter.ttk.rst:1096 msgid "Query or modify the heading options for the specified *column*." msgstr "" -#: ../../library/tkinter.ttk.rst:1100 +#: ../../library/tkinter.ttk.rst:1098 msgid "" "If *kw* is not given, returns a dict of the heading option values. If " "*option* is specified then the value for that *option* is returned. " "Otherwise, sets the options to the corresponding values." msgstr "" -#: ../../library/tkinter.ttk.rst:1106 +#: ../../library/tkinter.ttk.rst:1104 msgid "*text*: text" msgstr "" -#: ../../library/tkinter.ttk.rst:1107 +#: ../../library/tkinter.ttk.rst:1105 msgid "The text to display in the column heading." msgstr "" -#: ../../library/tkinter.ttk.rst:1108 +#: ../../library/tkinter.ttk.rst:1106 msgid "*image*: imageName" msgstr "" -#: ../../library/tkinter.ttk.rst:1109 +#: ../../library/tkinter.ttk.rst:1107 msgid "Specifies an image to display to the right of the column heading." msgstr "" -#: ../../library/tkinter.ttk.rst:1110 +#: ../../library/tkinter.ttk.rst:1108 msgid "*anchor*: anchor" msgstr "" -#: ../../library/tkinter.ttk.rst:1111 +#: ../../library/tkinter.ttk.rst:1109 msgid "" "Specifies how the heading text should be aligned. One of the standard Tk " "anchor values." msgstr "" -#: ../../library/tkinter.ttk.rst:1113 +#: ../../library/tkinter.ttk.rst:1111 msgid "*command*: callback" msgstr "" -#: ../../library/tkinter.ttk.rst:1114 +#: ../../library/tkinter.ttk.rst:1112 msgid "A callback to be invoked when the heading label is pressed." msgstr "" -#: ../../library/tkinter.ttk.rst:1116 +#: ../../library/tkinter.ttk.rst:1114 msgid "To configure the tree column heading, call this with column = \"#0\"." msgstr "" -#: ../../library/tkinter.ttk.rst:1121 +#: ../../library/tkinter.ttk.rst:1119 msgid "" "Returns a description of the specified *component* under the point given by " "*x* and *y*, or the empty string if no such *component* is present at that " "position." msgstr "" -#: ../../library/tkinter.ttk.rst:1128 +#: ../../library/tkinter.ttk.rst:1126 msgid "Returns the item ID of the item at position *y*." msgstr "" -#: ../../library/tkinter.ttk.rst:1133 +#: ../../library/tkinter.ttk.rst:1131 msgid "Returns the display column identifier of the cell at position *x*." msgstr "" -#: ../../library/tkinter.ttk.rst:1135 +#: ../../library/tkinter.ttk.rst:1133 msgid "The tree column has ID #0." msgstr "" -#: ../../library/tkinter.ttk.rst:1140 +#: ../../library/tkinter.ttk.rst:1138 msgid "Returns one of:" msgstr "" -#: ../../library/tkinter.ttk.rst:1143 +#: ../../library/tkinter.ttk.rst:1141 msgid "region" msgstr "" -#: ../../library/tkinter.ttk.rst:1143 +#: ../../library/tkinter.ttk.rst:1141 msgid "meaning" msgstr "" -#: ../../library/tkinter.ttk.rst:1145 +#: ../../library/tkinter.ttk.rst:1143 msgid "heading" msgstr "heading" -#: ../../library/tkinter.ttk.rst:1145 +#: ../../library/tkinter.ttk.rst:1143 msgid "Tree heading area." msgstr "" -#: ../../library/tkinter.ttk.rst:1147 +#: ../../library/tkinter.ttk.rst:1145 msgid "separator" msgstr "separator" -#: ../../library/tkinter.ttk.rst:1147 +#: ../../library/tkinter.ttk.rst:1145 msgid "Space between two columns headings." msgstr "" -#: ../../library/tkinter.ttk.rst:1149 +#: ../../library/tkinter.ttk.rst:1147 msgid "tree" msgstr "tree" -#: ../../library/tkinter.ttk.rst:1149 +#: ../../library/tkinter.ttk.rst:1147 msgid "The tree area." msgstr "" -#: ../../library/tkinter.ttk.rst:1151 +#: ../../library/tkinter.ttk.rst:1149 msgid "cell" msgstr "cell" -#: ../../library/tkinter.ttk.rst:1151 +#: ../../library/tkinter.ttk.rst:1149 msgid "A data cell." msgstr "" -#: ../../library/tkinter.ttk.rst:1154 ../../library/tkinter.ttk.rst:1161 +#: ../../library/tkinter.ttk.rst:1152 ../../library/tkinter.ttk.rst:1159 msgid "Availability: Tk 8.6." msgstr "" -#: ../../library/tkinter.ttk.rst:1159 +#: ../../library/tkinter.ttk.rst:1157 msgid "Returns the element at position *x*, *y*." msgstr "" -#: ../../library/tkinter.ttk.rst:1166 +#: ../../library/tkinter.ttk.rst:1164 msgid "" "Returns the integer index of *item* within its parent's list of children." msgstr "" -#: ../../library/tkinter.ttk.rst:1171 +#: ../../library/tkinter.ttk.rst:1169 msgid "" "Creates a new item and returns the item identifier of the newly created item." msgstr "" -#: ../../library/tkinter.ttk.rst:1174 +#: ../../library/tkinter.ttk.rst:1172 msgid "" "*parent* is the item ID of the parent item, or the empty string to create a " "new top-level item. *index* is an integer, or the value \"end\", specifying " @@ -1825,15 +1825,15 @@ msgid "" "unique identifier is generated." msgstr "" -#: ../../library/tkinter.ttk.rst:1183 +#: ../../library/tkinter.ttk.rst:1181 msgid "See `Item Options`_ for the list of available options." msgstr "可用的選項清單請見 `Item Options`_。" -#: ../../library/tkinter.ttk.rst:1188 +#: ../../library/tkinter.ttk.rst:1186 msgid "Query or modify the options for the specified *item*." msgstr "" -#: ../../library/tkinter.ttk.rst:1190 +#: ../../library/tkinter.ttk.rst:1188 msgid "" "If no options are given, a dict with options/values for the item is " "returned. If *option* is specified then the value for that option is " @@ -1841,11 +1841,11 @@ msgid "" "by *kw*." msgstr "" -#: ../../library/tkinter.ttk.rst:1201 +#: ../../library/tkinter.ttk.rst:1199 msgid "Moves *item* to position *index* in *parent*'s list of children." msgstr "" -#: ../../library/tkinter.ttk.rst:1203 +#: ../../library/tkinter.ttk.rst:1201 msgid "" "It is illegal to move an item under one of its descendants. If *index* is " "less than or equal to zero, *item* is moved to the beginning; if greater " @@ -1853,71 +1853,71 @@ msgid "" "was detached it is reattached." msgstr "" -#: ../../library/tkinter.ttk.rst:1208 +#: ../../library/tkinter.ttk.rst:1206 msgid ":meth:`reattach` is an alias of :meth:`!move`." msgstr "" -#: ../../library/tkinter.ttk.rst:1213 +#: ../../library/tkinter.ttk.rst:1211 msgid "" "Returns the identifier of *item*'s next sibling, or '' if *item* is the last " "child of its parent." msgstr "" -#: ../../library/tkinter.ttk.rst:1219 +#: ../../library/tkinter.ttk.rst:1217 msgid "" "Returns the ID of the parent of *item*, or '' if *item* is at the top level " "of the hierarchy." msgstr "" -#: ../../library/tkinter.ttk.rst:1225 +#: ../../library/tkinter.ttk.rst:1223 msgid "" "Returns the identifier of *item*'s previous sibling, or '' if *item* is the " "first child of its parent." msgstr "" -#: ../../library/tkinter.ttk.rst:1231 +#: ../../library/tkinter.ttk.rst:1229 msgid "Ensure that *item* is visible." msgstr "確保 *item* 是可見的。" -#: ../../library/tkinter.ttk.rst:1233 +#: ../../library/tkinter.ttk.rst:1231 msgid "" "Sets all of *item*'s ancestors open option to ``True``, and scrolls the " "widget if necessary so that *item* is within the visible portion of the tree." msgstr "" -#: ../../library/tkinter.ttk.rst:1240 +#: ../../library/tkinter.ttk.rst:1238 msgid "Returns a tuple of selected items." msgstr "" -#: ../../library/tkinter.ttk.rst:1242 +#: ../../library/tkinter.ttk.rst:1240 msgid "" "``selection()`` no longer takes arguments. For changing the selection state " "use the following selection methods." msgstr "" -#: ../../library/tkinter.ttk.rst:1249 +#: ../../library/tkinter.ttk.rst:1247 msgid "*items* becomes the new selection." msgstr "" -#: ../../library/tkinter.ttk.rst:1251 ../../library/tkinter.ttk.rst:1259 -#: ../../library/tkinter.ttk.rst:1267 ../../library/tkinter.ttk.rst:1275 +#: ../../library/tkinter.ttk.rst:1249 ../../library/tkinter.ttk.rst:1257 +#: ../../library/tkinter.ttk.rst:1265 ../../library/tkinter.ttk.rst:1273 msgid "" "*items* can be passed as separate arguments, not just as a single tuple." msgstr "" -#: ../../library/tkinter.ttk.rst:1257 +#: ../../library/tkinter.ttk.rst:1255 msgid "Add *items* to the selection." msgstr "將 *items* 加入選擇。" -#: ../../library/tkinter.ttk.rst:1265 +#: ../../library/tkinter.ttk.rst:1263 msgid "Remove *items* from the selection." msgstr "從選擇中移除 *items*。" -#: ../../library/tkinter.ttk.rst:1273 +#: ../../library/tkinter.ttk.rst:1271 msgid "Toggle the selection state of each item in *items*." msgstr "" -#: ../../library/tkinter.ttk.rst:1281 +#: ../../library/tkinter.ttk.rst:1279 msgid "" "With one argument, returns a dictionary of column/value pairs for the " "specified *item*. With two arguments, returns the current value of the " @@ -1925,18 +1925,18 @@ msgid "" "in given *item* to the specified *value*." msgstr "" -#: ../../library/tkinter.ttk.rst:1289 +#: ../../library/tkinter.ttk.rst:1287 msgid "" "Bind a callback for the given event *sequence* to the tag *tagname*. When an " "event is delivered to an item, the callbacks for each of the item's tags " "option are called." msgstr "" -#: ../../library/tkinter.ttk.rst:1296 +#: ../../library/tkinter.ttk.rst:1294 msgid "Query or modify the options for the specified *tagname*." msgstr "" -#: ../../library/tkinter.ttk.rst:1298 +#: ../../library/tkinter.ttk.rst:1296 msgid "" "If *kw* is not given, returns a dict of the option settings for *tagname*. " "If *option* is specified, returns the value for that *option* for the " @@ -1944,30 +1944,30 @@ msgid "" "for the given *tagname*." msgstr "" -#: ../../library/tkinter.ttk.rst:1306 +#: ../../library/tkinter.ttk.rst:1304 msgid "" "If *item* is specified, returns ``True`` if the specified *item* has the " "given *tagname* and ``False`` otherwise. Otherwise, returns a tuple of all " "items that have the specified tag." msgstr "" -#: ../../library/tkinter.ttk.rst:1310 +#: ../../library/tkinter.ttk.rst:1308 msgid "Availability: Tk 8.6" msgstr "" -#: ../../library/tkinter.ttk.rst:1315 +#: ../../library/tkinter.ttk.rst:1313 msgid "Query or modify horizontal position of the treeview." msgstr "" -#: ../../library/tkinter.ttk.rst:1320 +#: ../../library/tkinter.ttk.rst:1318 msgid "Query or modify vertical position of the treeview." msgstr "" -#: ../../library/tkinter.ttk.rst:1326 +#: ../../library/tkinter.ttk.rst:1324 msgid "Ttk styling" msgstr "" -#: ../../library/tkinter.ttk.rst:1328 +#: ../../library/tkinter.ttk.rst:1326 msgid "" "Each widget in :mod:`!ttk` is assigned a style, which specifies the set of " "elements making up the widget and how they are arranged, along with dynamic " @@ -1978,18 +1978,18 @@ msgid "" "winfo_class())." msgstr "" -#: ../../library/tkinter.ttk.rst:1338 +#: ../../library/tkinter.ttk.rst:1336 msgid "" "`Introduction to the Tk theme engine `_" msgstr "" "`Tk 主題引擎簡介 `_" -#: ../../library/tkinter.ttk.rst:1339 +#: ../../library/tkinter.ttk.rst:1337 msgid "The ``ttk::intro`` man page explains how the theme engine works." msgstr "" -#: ../../library/tkinter.ttk.rst:1341 +#: ../../library/tkinter.ttk.rst:1339 msgid "" "`The Tile Widget Set `_" @@ -1997,34 +1997,34 @@ msgstr "" "`The Tile Widget Set `_" -#: ../../library/tkinter.ttk.rst:1342 +#: ../../library/tkinter.ttk.rst:1340 msgid "" "Joe English's 2004 paper introducing the theme engine (then the separate " "*Tile* extension), with diagrams of how elements and layouts make up a " "widget's appearance." msgstr "" -#: ../../library/tkinter.ttk.rst:1349 +#: ../../library/tkinter.ttk.rst:1347 msgid "This class is used to manipulate the style database." msgstr "" -#: ../../library/tkinter.ttk.rst:1354 +#: ../../library/tkinter.ttk.rst:1352 msgid "Query or set the default value of the specified option(s) in *style*." msgstr "" -#: ../../library/tkinter.ttk.rst:1356 +#: ../../library/tkinter.ttk.rst:1354 msgid "" "Each key in *kw* is an option and each value is a string identifying the " "value for that option." msgstr "" -#: ../../library/tkinter.ttk.rst:1359 +#: ../../library/tkinter.ttk.rst:1357 msgid "" "For example, to change every default button to be a flat button with some " "padding and a different background color::" msgstr "" -#: ../../library/tkinter.ttk.rst:1362 +#: ../../library/tkinter.ttk.rst:1360 msgid "" "from tkinter import ttk\n" "import tkinter\n" @@ -2052,22 +2052,22 @@ msgstr "" "\n" "root.mainloop()" -#: ../../library/tkinter.ttk.rst:1378 +#: ../../library/tkinter.ttk.rst:1376 msgid "Query or sets dynamic values of the specified option(s) in *style*." msgstr "" -#: ../../library/tkinter.ttk.rst:1380 +#: ../../library/tkinter.ttk.rst:1378 msgid "" "Each key in *kw* is an option and each value should be a list or a tuple " "(usually) containing statespecs grouped in tuples, lists, or some other " "preference. A statespec is a compound of one or more states and then a value." msgstr "" -#: ../../library/tkinter.ttk.rst:1385 +#: ../../library/tkinter.ttk.rst:1383 msgid "An example may make it more understandable::" msgstr "" -#: ../../library/tkinter.ttk.rst:1387 +#: ../../library/tkinter.ttk.rst:1385 msgid "" "import tkinter\n" "from tkinter import ttk\n" @@ -2099,7 +2099,7 @@ msgstr "" "\n" "root.mainloop()" -#: ../../library/tkinter.ttk.rst:1403 +#: ../../library/tkinter.ttk.rst:1401 msgid "" "Note that the order of the (states, value) sequences for an option does " "matter, if the order is changed to ``[('active', 'blue'), ('pressed', " @@ -2107,32 +2107,32 @@ msgid "" "foreground when the widget were in active or pressed states." msgstr "" -#: ../../library/tkinter.ttk.rst:1408 +#: ../../library/tkinter.ttk.rst:1406 msgid "" "When called to query the map (without specifying values to set), it returns " "a dictionary mapping each option to its list of statespecs." msgstr "" -#: ../../library/tkinter.ttk.rst:1411 +#: ../../library/tkinter.ttk.rst:1409 msgid "The value returned when querying the map was corrected." msgstr "" -#: ../../library/tkinter.ttk.rst:1417 +#: ../../library/tkinter.ttk.rst:1415 msgid "Returns the value specified for *option* in *style*." msgstr "" -#: ../../library/tkinter.ttk.rst:1419 +#: ../../library/tkinter.ttk.rst:1417 msgid "" "If *state* is specified, it is expected to be a sequence of one or more " "states. If the *default* argument is set, it is used as a fallback value in " "case no specification for option is found." msgstr "" -#: ../../library/tkinter.ttk.rst:1423 +#: ../../library/tkinter.ttk.rst:1421 msgid "To check what font a Button uses by default::" msgstr "" -#: ../../library/tkinter.ttk.rst:1425 +#: ../../library/tkinter.ttk.rst:1423 msgid "" "from tkinter import ttk\n" "\n" @@ -2142,13 +2142,13 @@ msgstr "" "\n" "print(ttk.Style().lookup(\"TButton\", \"font\"))" -#: ../../library/tkinter.ttk.rst:1432 +#: ../../library/tkinter.ttk.rst:1430 msgid "" "Define the widget layout for given *style*. If *layoutspec* is omitted, " "return the layout specification for given style." msgstr "" -#: ../../library/tkinter.ttk.rst:1435 +#: ../../library/tkinter.ttk.rst:1433 msgid "" "*layoutspec*, if specified, is expected to be a list or some other sequence " "type (excluding strings), where each item should be a tuple and the first " @@ -2156,13 +2156,13 @@ msgid "" "in `Layouts`_." msgstr "" -#: ../../library/tkinter.ttk.rst:1440 +#: ../../library/tkinter.ttk.rst:1438 msgid "" "To understand the format, see the following example (it is not intended to " "do anything useful)::" msgstr "" -#: ../../library/tkinter.ttk.rst:1443 +#: ../../library/tkinter.ttk.rst:1441 msgid "" "from tkinter import ttk\n" "import tkinter\n" @@ -2208,76 +2208,76 @@ msgstr "" "mbtn.pack()\n" "root.mainloop()" -#: ../../library/tkinter.ttk.rst:1467 +#: ../../library/tkinter.ttk.rst:1465 msgid "" "Create a new element in the current theme, of the given *etype* which is " "expected to be either \"image\", \"from\" or \"vsapi\". The latter is only " "available in Tk 8.6 on Windows." msgstr "" -#: ../../library/tkinter.ttk.rst:1471 +#: ../../library/tkinter.ttk.rst:1469 msgid "" "If \"image\" is used, *args* should contain the default image name followed " "by statespec/value pairs (this is the imagespec), and *kw* may have the " "following options:" msgstr "" -#: ../../library/tkinter.ttk.rst:1475 +#: ../../library/tkinter.ttk.rst:1473 msgid "border=padding" msgstr "border=padding" -#: ../../library/tkinter.ttk.rst:1476 +#: ../../library/tkinter.ttk.rst:1474 msgid "" "padding is a list of up to four integers, specifying the left, top, right, " "and bottom borders, respectively." msgstr "" -#: ../../library/tkinter.ttk.rst:1479 ../../library/tkinter.ttk.rst:1553 +#: ../../library/tkinter.ttk.rst:1477 ../../library/tkinter.ttk.rst:1551 msgid "height=height" msgstr "height=height" -#: ../../library/tkinter.ttk.rst:1480 +#: ../../library/tkinter.ttk.rst:1478 msgid "" "Specifies a minimum height for the element. If less than zero, the base " "image's height is used as a default." msgstr "" -#: ../../library/tkinter.ttk.rst:1483 ../../library/tkinter.ttk.rst:1527 +#: ../../library/tkinter.ttk.rst:1481 ../../library/tkinter.ttk.rst:1525 msgid "padding=padding" msgstr "padding=padding" -#: ../../library/tkinter.ttk.rst:1484 +#: ../../library/tkinter.ttk.rst:1482 msgid "" "Specifies the element's interior padding. Defaults to border's value if not " "specified." msgstr "" -#: ../../library/tkinter.ttk.rst:1487 +#: ../../library/tkinter.ttk.rst:1485 msgid "sticky=spec" msgstr "sticky=spec" -#: ../../library/tkinter.ttk.rst:1488 +#: ../../library/tkinter.ttk.rst:1486 msgid "" "Specifies how the image is placed within the final parcel. spec contains " "zero or more characters \"n\", \"s\", \"w\", or \"e\"." msgstr "" -#: ../../library/tkinter.ttk.rst:1491 ../../library/tkinter.ttk.rst:1545 +#: ../../library/tkinter.ttk.rst:1489 ../../library/tkinter.ttk.rst:1543 msgid "width=width" msgstr "width=width" -#: ../../library/tkinter.ttk.rst:1492 +#: ../../library/tkinter.ttk.rst:1490 msgid "" "Specifies a minimum width for the element. If less than zero, the base " "image's width is used as a default." msgstr "" -#: ../../library/tkinter.ttk.rst:1495 ../../library/tkinter.ttk.rst:1512 -#: ../../library/tkinter.ttk.rst:1557 +#: ../../library/tkinter.ttk.rst:1493 ../../library/tkinter.ttk.rst:1510 +#: ../../library/tkinter.ttk.rst:1555 msgid "Example::" msgstr "範例: ::" -#: ../../library/tkinter.ttk.rst:1497 +#: ../../library/tkinter.ttk.rst:1495 msgid "" "img1 = tkinter.PhotoImage(master=root, file='button.png')\n" "img1 = tkinter.PhotoImage(master=root, file='button-pressed.png')\n" @@ -2295,7 +2295,7 @@ msgstr "" " img1, ('pressed', img2), ('active', img3),\n" " border=(2, 4), sticky='we')" -#: ../../library/tkinter.ttk.rst:1505 +#: ../../library/tkinter.ttk.rst:1503 msgid "" "If \"from\" is used as the value of *etype*, :meth:`element_create` will " "clone an existing element. *args* is expected to contain a themename, from " @@ -2304,7 +2304,7 @@ msgid "" "used. *kw* is discarded." msgstr "" -#: ../../library/tkinter.ttk.rst:1514 +#: ../../library/tkinter.ttk.rst:1512 msgid "" "style = ttk.Style(root)\n" "style.element_create('plain.background', 'from', 'default')" @@ -2312,7 +2312,7 @@ msgstr "" "style = ttk.Style(root)\n" "style.element_create('plain.background', 'from', 'default')" -#: ../../library/tkinter.ttk.rst:1517 +#: ../../library/tkinter.ttk.rst:1515 msgid "" "If \"vsapi\" is used as the value of *etype*, :meth:`element_create` will " "create a new element in the current theme whose visual appearance is drawn " @@ -2323,7 +2323,7 @@ msgid "" "Styles API state value. *kw* may have the following options:" msgstr "" -#: ../../library/tkinter.ttk.rst:1528 +#: ../../library/tkinter.ttk.rst:1526 msgid "" "Specify the element's interior padding. *padding* is a list of up to four " "integers specifying the left, top, right and bottom padding quantities " @@ -2335,18 +2335,18 @@ msgid "" "may not be mixed with any other options." msgstr "" -#: ../../library/tkinter.ttk.rst:1539 +#: ../../library/tkinter.ttk.rst:1537 msgid "margins=padding" msgstr "margins=padding" -#: ../../library/tkinter.ttk.rst:1540 +#: ../../library/tkinter.ttk.rst:1538 msgid "" "Specifies the elements exterior padding. *padding* is a list of up to four " "integers specifying the left, top, right and bottom padding quantities " "respectively. This option may not be mixed with any other options." msgstr "" -#: ../../library/tkinter.ttk.rst:1546 +#: ../../library/tkinter.ttk.rst:1544 msgid "" "Specifies the width for the element. If this option is set then the Visual " "Styles API will not be queried for the recommended size or the part. If this " @@ -2354,11 +2354,11 @@ msgid "" "options cannot be mixed with the *padding* or *margins* options." msgstr "" -#: ../../library/tkinter.ttk.rst:1554 +#: ../../library/tkinter.ttk.rst:1552 msgid "Specifies the height of the element. See the comments for *width*." msgstr "" -#: ../../library/tkinter.ttk.rst:1559 +#: ../../library/tkinter.ttk.rst:1557 msgid "" "style = ttk.Style(root)\n" "style.element_create('pin', 'vsapi', 'EXPLORERBAR', 3, [\n" @@ -2374,23 +2374,23 @@ msgid "" "pin.pack(expand=True, fill='both')" msgstr "" -#: ../../library/tkinter.ttk.rst:1572 +#: ../../library/tkinter.ttk.rst:1570 msgid "Added support of the \"vsapi\" element factory." msgstr "" -#: ../../library/tkinter.ttk.rst:1577 +#: ../../library/tkinter.ttk.rst:1575 msgid "Returns a tuple of elements defined in the current theme." msgstr "" -#: ../../library/tkinter.ttk.rst:1582 +#: ../../library/tkinter.ttk.rst:1580 msgid "Returns a tuple of *elementname*'s options." msgstr "" -#: ../../library/tkinter.ttk.rst:1587 +#: ../../library/tkinter.ttk.rst:1585 msgid "Create a new theme." msgstr "" -#: ../../library/tkinter.ttk.rst:1589 +#: ../../library/tkinter.ttk.rst:1587 msgid "" "It is an error if *themename* already exists. If *parent* is specified, the " "new theme will inherit styles, elements and layouts from the parent theme. " @@ -2398,13 +2398,13 @@ msgid "" "for :meth:`theme_settings`." msgstr "" -#: ../../library/tkinter.ttk.rst:1597 +#: ../../library/tkinter.ttk.rst:1595 msgid "" "Temporarily sets the current theme to *themename*, apply specified " "*settings* and then restore the previous theme." msgstr "" -#: ../../library/tkinter.ttk.rst:1600 +#: ../../library/tkinter.ttk.rst:1598 msgid "" "Each key in *settings* is a style and each value may contain the keys " "'configure', 'map', 'layout' and 'element create' and they are expected to " @@ -2413,11 +2413,11 @@ msgid "" "respectively." msgstr "" -#: ../../library/tkinter.ttk.rst:1606 +#: ../../library/tkinter.ttk.rst:1604 msgid "As an example, let's change the Combobox for the default theme a bit::" msgstr "" -#: ../../library/tkinter.ttk.rst:1608 +#: ../../library/tkinter.ttk.rst:1606 msgid "" "from tkinter import ttk\n" "import tkinter\n" @@ -2465,22 +2465,22 @@ msgstr "" "\n" "root.mainloop()" -#: ../../library/tkinter.ttk.rst:1634 +#: ../../library/tkinter.ttk.rst:1632 msgid "Returns a tuple of all known themes." msgstr "回傳包含所有已知主題的元組。" -#: ../../library/tkinter.ttk.rst:1639 +#: ../../library/tkinter.ttk.rst:1637 msgid "" "If *themename* is not given, returns the theme in use. Otherwise, sets the " "current theme to *themename*, refreshes all widgets and emits a " "<> event." msgstr "" -#: ../../library/tkinter.ttk.rst:1645 +#: ../../library/tkinter.ttk.rst:1643 msgid "Layouts" msgstr "" -#: ../../library/tkinter.ttk.rst:1647 +#: ../../library/tkinter.ttk.rst:1645 msgid "" "A layout can be just ``None``, if it takes no options, or a dict of options " "specifying how to arrange the element. The layout mechanism uses a " @@ -2488,82 +2488,82 @@ msgid "" "each element is allocated a parcel." msgstr "" -#: ../../library/tkinter.ttk.rst:1654 +#: ../../library/tkinter.ttk.rst:1652 msgid "*side*: whichside" msgstr "" -#: ../../library/tkinter.ttk.rst:1655 +#: ../../library/tkinter.ttk.rst:1653 msgid "" "Specifies which side of the cavity to place the element; one of top, right, " "bottom or left. If omitted, the element occupies the entire cavity." msgstr "" -#: ../../library/tkinter.ttk.rst:1659 +#: ../../library/tkinter.ttk.rst:1657 msgid "*sticky*: nswe" msgstr "" -#: ../../library/tkinter.ttk.rst:1660 +#: ../../library/tkinter.ttk.rst:1658 msgid "Specifies where the element is placed inside its allocated parcel." msgstr "" -#: ../../library/tkinter.ttk.rst:1662 +#: ../../library/tkinter.ttk.rst:1660 msgid "*unit*: 0 or 1" msgstr "*unit*:0 或 1" -#: ../../library/tkinter.ttk.rst:1663 +#: ../../library/tkinter.ttk.rst:1661 msgid "" "If set to 1, causes the element and all of its descendants to be treated as " "a single element for the purposes of :meth:`Widget.identify` et al. It's " "used for things like scrollbar thumbs with grips." msgstr "" -#: ../../library/tkinter.ttk.rst:1667 +#: ../../library/tkinter.ttk.rst:1665 msgid "*children*: [sublayout... ]" msgstr "" -#: ../../library/tkinter.ttk.rst:1668 +#: ../../library/tkinter.ttk.rst:1666 msgid "" "Specifies a list of elements to place inside the element. Each element is a " "tuple (or other sequence type) where the first item is the layout name, and " "the other is a `Layout`_." msgstr "" -#: ../../library/tkinter.ttk.rst:1676 +#: ../../library/tkinter.ttk.rst:1674 msgid "Additional widgets" msgstr "" -#: ../../library/tkinter.ttk.rst:1678 +#: ../../library/tkinter.ttk.rst:1676 msgid "" "The following themed widgets complete the :mod:`tkinter.ttk` widget set. " "Each is the themed counterpart of the like-named classic :mod:`tkinter` " "widget and inherits the common methods of :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1684 +#: ../../library/tkinter.ttk.rst:1682 msgid "" "Ttk :class:`Button` widget, displays a textual label and/or image, and " "evaluates a command when pressed. It is the themed counterpart of :class:" "`tkinter.Button` and inherits the common widget methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1691 +#: ../../library/tkinter.ttk.rst:1689 msgid "Invoke the command associated with the button and return its result." msgstr "" -#: ../../library/tkinter.ttk.rst:1696 +#: ../../library/tkinter.ttk.rst:1694 msgid "" "Ttk :class:`Checkbutton` widget, used to control a boolean variable that is " "toggled on and off. It is the themed counterpart of :class:`tkinter." "Checkbutton` and inherits the common widget methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1703 +#: ../../library/tkinter.ttk.rst:1701 msgid "" "Toggle the button between its selected and deselected states, invoke the " "command associated with the button, and return its result." msgstr "" -#: ../../library/tkinter.ttk.rst:1709 +#: ../../library/tkinter.ttk.rst:1707 msgid "" "Ttk :class:`Entry` widget, displays a one-line text string and allows the " "user to edit it. It is the themed counterpart of :class:`tkinter.Entry` and " @@ -2571,53 +2571,53 @@ msgid "" "editing methods from :class:`tkinter.Entry`." msgstr "" -#: ../../library/tkinter.ttk.rst:1717 +#: ../../library/tkinter.ttk.rst:1715 msgid "" "Return a tuple ``(x, y, width, height)`` giving the bounding box of the " "character at the given *index*." msgstr "" -#: ../../library/tkinter.ttk.rst:1725 +#: ../../library/tkinter.ttk.rst:1723 msgid "" "Return the name of the element under the point given by *x* and *y*, or the " "empty string if no element is present at that location." msgstr "" -#: ../../library/tkinter.ttk.rst:1730 +#: ../../library/tkinter.ttk.rst:1728 msgid "" "Force validation of the entry and return ``True`` if validation succeeded, " "and ``False`` otherwise." msgstr "" -#: ../../library/tkinter.ttk.rst:1736 +#: ../../library/tkinter.ttk.rst:1734 msgid "" "Ttk :class:`Frame` widget, a container used to group and lay out other " "widgets. It is the themed counterpart of :class:`tkinter.Frame` and inherits " "the common widget methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1744 +#: ../../library/tkinter.ttk.rst:1742 msgid "" "Ttk :class:`Label` widget, displays a textual label and/or image. It is the " "themed counterpart of :class:`tkinter.Label` and inherits the common widget " "methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1751 +#: ../../library/tkinter.ttk.rst:1749 msgid "" "Ttk :class:`Labelframe` widget, a container that draws a border and a title " "label around its contents. It is the themed counterpart of :class:`tkinter." "LabelFrame` and inherits the common widget methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1759 +#: ../../library/tkinter.ttk.rst:1757 msgid "" "Ttk :class:`Menubutton` widget, displays a textual label and/or image, and " "pops up a menu when pressed. It is the themed counterpart of :class:`tkinter." "Menubutton` and inherits the common widget methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1767 +#: ../../library/tkinter.ttk.rst:1765 msgid "" "Ttk :class:`OptionMenu` widget, a :class:`Menubutton` that pops up a menu of " "mutually exclusive choices. *variable* is the variable that tracks the " @@ -2631,21 +2631,21 @@ msgid "" "``'flush'``); and the *name* keyword argument sets the Tk widget name." msgstr "" -#: ../../library/tkinter.ttk.rst:1782 +#: ../../library/tkinter.ttk.rst:1780 msgid "" "Replace the entries of the menu with *values*. If *default* is given, also " "set it as the current value of the *variable*." msgstr "" -#: ../../library/tkinter.ttk.rst:1788 +#: ../../library/tkinter.ttk.rst:1786 msgid "Destroy this widget and its associated menu." msgstr "" -#: ../../library/tkinter.ttk.rst:1790 +#: ../../library/tkinter.ttk.rst:1788 msgid "Added support for the *name* keyword argument." msgstr "" -#: ../../library/tkinter.ttk.rst:1797 +#: ../../library/tkinter.ttk.rst:1795 msgid "" "Ttk :class:`Panedwindow` widget, displays a number of subwindows stacked " "either vertically or horizontally. The user may adjust the relative sizes of " @@ -2655,7 +2655,7 @@ msgid "" "methods from :class:`tkinter.PanedWindow`." msgstr "" -#: ../../library/tkinter.ttk.rst:1807 +#: ../../library/tkinter.ttk.rst:1805 msgid "" "Insert a pane containing *child* at the position *pos*. *pos* is either the " "string ``'end'``, an integer index, or the name of a managed subwindow. If " @@ -2663,13 +2663,13 @@ msgid "" "position. Any keyword arguments set pane options." msgstr "" -#: ../../library/tkinter.ttk.rst:1816 +#: ../../library/tkinter.ttk.rst:1814 msgid "" "Remove *child*, which may be either an integer index or the name of a " "managed subwindow, from the panes." msgstr "" -#: ../../library/tkinter.ttk.rst:1826 +#: ../../library/tkinter.ttk.rst:1824 msgid "" "Query or modify the options of the specified *pane*, where *pane* is either " "an integer index or the name of a managed subwindow. If no arguments are " @@ -2678,7 +2678,7 @@ msgid "" "as keyword arguments to their corresponding values." msgstr "" -#: ../../library/tkinter.ttk.rst:1835 +#: ../../library/tkinter.ttk.rst:1833 msgid "" "If *newpos* is specified, set the position of sash number *index* and return " "its new position. This may adjust the positions of adjacent sashes to ensure " @@ -2687,7 +2687,7 @@ msgid "" "return the current position of the sash." msgstr "" -#: ../../library/tkinter.ttk.rst:1845 +#: ../../library/tkinter.ttk.rst:1843 msgid "" "Ttk :class:`Radiobutton` widget, used as part of a group to control a single " "shared variable by selecting one of several mutually exclusive values. It is " @@ -2695,13 +2695,13 @@ msgid "" "common widget methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1852 +#: ../../library/tkinter.ttk.rst:1850 msgid "" "Set the option variable to the button's value, select the button, invoke the " "command associated with the button, and return its result." msgstr "" -#: ../../library/tkinter.ttk.rst:1858 +#: ../../library/tkinter.ttk.rst:1856 msgid "" "Ttk :class:`Scale` widget, displays a slider that lets the user select a " "numeric value from a range by moving the slider along a trough. It is the " @@ -2709,26 +2709,26 @@ msgid "" "methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1865 +#: ../../library/tkinter.ttk.rst:1863 msgid "" "Modify or query the widget options, like :meth:`Widget.configure `. In addition, this method clips the ``from`` and ``to`` " "values so that the current value stays within the range defined by them." msgstr "" -#: ../../library/tkinter.ttk.rst:1870 +#: ../../library/tkinter.ttk.rst:1868 msgid "" "Now returns the configuration value, like :meth:`Widget.configure `." msgstr "" -#: ../../library/tkinter.ttk.rst:1877 +#: ../../library/tkinter.ttk.rst:1875 msgid "" "Return the current value of the scale. If *x* and *y* are given, return the " "value corresponding to the pixel coordinate *x*, *y* instead." msgstr "" -#: ../../library/tkinter.ttk.rst:1884 +#: ../../library/tkinter.ttk.rst:1882 msgid "" "Ttk :class:`Scrollbar` widget, controls the viewport of an associated " "scrollable widget such as a :class:`Treeview`, :class:`Entry` or :class:" @@ -2737,14 +2737,14 @@ msgid "" "meth:`!set` and :meth:`!get` methods from :class:`tkinter.Scrollbar`." msgstr "" -#: ../../library/tkinter.ttk.rst:1894 +#: ../../library/tkinter.ttk.rst:1892 msgid "" "Ttk :class:`Separator` widget, displays a horizontal or vertical separator " "line. It has no direct counterpart in :mod:`tkinter` and inherits the common " "widget methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1902 +#: ../../library/tkinter.ttk.rst:1900 msgid "" "Ttk :class:`Sizegrip` widget, displays a grip that allows the user to resize " "the containing toplevel window by pressing and dragging the grip, typically " @@ -2752,7 +2752,7 @@ msgid "" "`tkinter` and inherits the common widget methods from :class:`Widget`." msgstr "" -#: ../../library/tkinter.ttk.rst:1911 +#: ../../library/tkinter.ttk.rst:1909 msgid "" "A :class:`Frame` containing a :class:`Scale` and a :class:`Label` that shows " "the scale's current value. *variable* is the :class:`~tkinter.IntVar` " @@ -2760,25 +2760,25 @@ msgid "" "*to* define the range of the scale." msgstr "" -#: ../../library/tkinter.ttk.rst:1919 +#: ../../library/tkinter.ttk.rst:1917 msgid "" "Destroy this widget and remove the trace callback registered on the " "associated variable." msgstr "" -#: ../../library/tkinter.ttk.rst:1925 +#: ../../library/tkinter.ttk.rst:1923 msgid "" "Alias of :class:`Labelframe`, kept for naming compatibility with :class:" "`tkinter.LabelFrame`." msgstr "" -#: ../../library/tkinter.ttk.rst:1931 +#: ../../library/tkinter.ttk.rst:1929 msgid "" "Alias of :class:`Panedwindow`, kept for naming compatibility with :class:" "`tkinter.PanedWindow`." msgstr "" -#: ../../library/tkinter.ttk.rst:11 +#: ../../library/tkinter.ttk.rst:9 msgid "ttk" msgstr "ttk" diff --git a/library/token.po b/library/token.po index 0bb8029fc7a..b466b4c2f7b 100644 --- a/library/token.po +++ b/library/token.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-19 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:13+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!token` --- Constants used with Python parse trees" msgstr ":mod:`!token` --- 與 Python 剖析樹一起使用的常數" -#: ../../library/token.rst:9 +#: ../../library/token.rst:7 msgid "**Source code:** :source:`Lib/token.py`" msgstr "**原始碼:**\\ :source:`Lib/token.py`" -#: ../../library/token.rst:13 +#: ../../library/token.rst:11 msgid "" "This module provides constants which represent the numeric values of leaf " "nodes of the parse tree (terminal tokens). Refer to the file :file:`Grammar/" @@ -35,52 +35,52 @@ msgid "" "names map to may change between Python versions." msgstr "" -#: ../../library/token.rst:19 +#: ../../library/token.rst:17 msgid "" "The module also provides a mapping from numeric codes to names and some " "functions. The functions mirror definitions in the Python C header files." msgstr "" -#: ../../library/token.rst:22 +#: ../../library/token.rst:20 msgid "" "Note that a token's value may depend on tokenizer options. For example, a " "``\"+\"`` token may be reported as either :data:`PLUS` or :data:`OP`, or a " "``\"match\"`` token may be either :data:`NAME` or :data:`SOFT_KEYWORD`." msgstr "" -#: ../../library/token.rst:29 +#: ../../library/token.rst:27 msgid "" "Dictionary mapping the numeric values of the constants defined in this " "module back to name strings, allowing more human-readable representation of " "parse trees to be generated." msgstr "" -#: ../../library/token.rst:36 +#: ../../library/token.rst:34 msgid "Return ``True`` for terminal token values." msgstr "" -#: ../../library/token.rst:41 +#: ../../library/token.rst:39 msgid "Return ``True`` for non-terminal token values." msgstr "" -#: ../../library/token.rst:46 +#: ../../library/token.rst:44 msgid "Return ``True`` if *x* is the marker indicating the end of input." msgstr "" -#: ../../library/token.rst:49 +#: ../../library/token.rst:47 msgid "The token constants are:" msgstr "" -#: ../../library/token.rst:53 +#: ../../library/token.rst:51 msgid "" "Token value that indicates an :ref:`identifier or keyword `." msgstr "" -#: ../../library/token.rst:57 +#: ../../library/token.rst:55 msgid "Token value that indicates a :ref:`numeric literal `" msgstr "" -#: ../../library/token.rst:61 +#: ../../library/token.rst:59 msgid "" "Token value that indicates a :ref:`string or byte literal `, " "excluding :ref:`formatted string literals `. The token string is " @@ -89,164 +89,164 @@ msgid "" "sequences." msgstr "" -#: ../../library/token.rst:69 +#: ../../library/token.rst:67 msgid "" "A generic token value that indicates an :ref:`operator ` or :ref:" "`delimiter `." msgstr "" -#: ../../library/token.rst:74 +#: ../../library/token.rst:72 msgid "" "This value is only reported by the :mod:`tokenize` module. Internally, the " "tokenizer uses :ref:`exact token types ` instead." msgstr "" -#: ../../library/token.rst:80 +#: ../../library/token.rst:78 msgid "" "Token value used to indicate a comment. The parser ignores :data:`!COMMENT` " "tokens." msgstr "" -#: ../../library/token.rst:85 +#: ../../library/token.rst:83 msgid "" "Token value that indicates the end of a :ref:`logical line `." msgstr "" -#: ../../library/token.rst:89 +#: ../../library/token.rst:87 msgid "" "Token value used to indicate a non-terminating newline. :data:`!NL` tokens " "are generated when a logical line of code is continued over multiple " "physical lines. The parser ignores :data:`!NL` tokens." msgstr "" -#: ../../library/token.rst:95 +#: ../../library/token.rst:93 msgid "" "Token value used at the beginning of a :ref:`logical line ` " "to indicate the start of an :ref:`indented block `." msgstr "" -#: ../../library/token.rst:100 +#: ../../library/token.rst:98 msgid "" "Token value used at the beginning of a :ref:`logical line ` " "to indicate the end of an :ref:`indented block `." msgstr "" -#: ../../library/token.rst:105 +#: ../../library/token.rst:103 msgid "" "Token value used to indicate the beginning of an :ref:`f-string literal `." msgstr "" -#: ../../library/token.rst:110 ../../library/token.rst:139 +#: ../../library/token.rst:108 ../../library/token.rst:137 msgid "" "The token string includes the prefix and the opening quote(s), but none of " "the contents of the literal." msgstr "" -#: ../../library/token.rst:115 +#: ../../library/token.rst:113 msgid "" "Token value used for literal text inside an :ref:`f-string literal `, including format specifications." msgstr "" -#: ../../library/token.rst:120 +#: ../../library/token.rst:118 msgid "" "Replacement fields (that is, the non-literal parts of f-strings) use the " "same tokens as other expressions, and are delimited by :data:`LBRACE`, :data:" "`RBRACE`, :data:`EXCLAMATION` and :data:`COLON` tokens." msgstr "" -#: ../../library/token.rst:127 +#: ../../library/token.rst:125 msgid "Token value used to indicate the end of a :ref:`f-string `." msgstr "" -#: ../../library/token.rst:131 ../../library/token.rst:164 +#: ../../library/token.rst:129 ../../library/token.rst:162 msgid "The token string contains the closing quote(s)." msgstr "" -#: ../../library/token.rst:135 +#: ../../library/token.rst:133 msgid "" "Token value used to indicate the beginning of a template string literal." msgstr "" -#: ../../library/token.rst:146 +#: ../../library/token.rst:144 msgid "" "Token value used for literal text inside a template string literal including " "format specifications." msgstr "" -#: ../../library/token.rst:151 +#: ../../library/token.rst:149 msgid "" "Replacement fields (that is, the non-literal parts of t-strings) use the " "same tokens as other expressions, and are delimited by :data:`LBRACE`, :data:" "`RBRACE`, :data:`EXCLAMATION` and :data:`COLON` tokens." msgstr "" -#: ../../library/token.rst:160 +#: ../../library/token.rst:158 msgid "Token value used to indicate the end of a template string literal." msgstr "" -#: ../../library/token.rst:170 +#: ../../library/token.rst:168 msgid "" "Token value that indicates the end of input. Used in :ref:`top-level grammar " "rules `." msgstr "" -#: ../../library/token.rst:175 +#: ../../library/token.rst:173 msgid "" "Token value that indicates the encoding used to decode the source bytes into " "text. The first token returned by :func:`tokenize.tokenize` will always be " "an ``ENCODING`` token." msgstr "" -#: ../../library/token.rst:181 +#: ../../library/token.rst:179 msgid "" "This token type isn't used by the C tokenizer but is needed for the :mod:" "`tokenize` module." msgstr "" -#: ../../library/token.rst:185 +#: ../../library/token.rst:183 msgid "" "The following token types are not produced by the :mod:`tokenize` module, " "and are defined for special uses in the tokenizer or parser:" msgstr "" -#: ../../library/token.rst:190 +#: ../../library/token.rst:188 msgid "" "Token value indicating that a ``type: ignore`` comment was recognized. Such " "tokens are produced instead of regular :data:`COMMENT` tokens only with the :" "data:`~ast.PyCF_TYPE_COMMENTS` flag." msgstr "" -#: ../../library/token.rst:196 +#: ../../library/token.rst:194 msgid "" "Token value indicating that a type comment was recognized. Such tokens are " "produced instead of regular :data:`COMMENT` tokens only with the :data:`~ast." "PyCF_TYPE_COMMENTS` flag." msgstr "" -#: ../../library/token.rst:202 +#: ../../library/token.rst:200 msgid "Token value indicating a :ref:`soft keyword `." msgstr "" -#: ../../library/token.rst:204 +#: ../../library/token.rst:202 msgid "" "The tokenizer never produces this value. To check for a soft keyword, pass " "a :data:`NAME` token's string to :func:`keyword.issoftkeyword`." msgstr "" -#: ../../library/token.rst:210 +#: ../../library/token.rst:208 msgid "Token value used to indicate wrong input." msgstr "" -#: ../../library/token.rst:212 +#: ../../library/token.rst:210 msgid "" "The :mod:`tokenize` module generally indicates errors by raising exceptions " "instead of emitting this token. It can also emit tokens such as :data:`OP` " "or :data:`NAME` with strings that are later rejected by the parser." msgstr "" -#: ../../library/token.rst:220 +#: ../../library/token.rst:218 msgid "" "The remaining tokens represent specific :ref:`operators ` and :" "ref:`delimiters `. (The :mod:`tokenize` module reports these as :" @@ -454,35 +454,35 @@ msgstr "``\":=\"``" msgid "``\"!\"``" msgstr "``\"!\"``" -#: ../../library/token.rst:228 +#: ../../library/token.rst:226 msgid "The following non-token constants are provided:" msgstr "" -#: ../../library/token.rst:232 +#: ../../library/token.rst:230 msgid "The number of token types defined in this module." msgstr "" -#: ../../library/token.rst:239 +#: ../../library/token.rst:237 msgid "" "A dictionary mapping the string representation of a token to its numeric " "code." msgstr "" -#: ../../library/token.rst:244 +#: ../../library/token.rst:242 msgid "Added :data:`!AWAIT` and :data:`!ASYNC` tokens." msgstr "" -#: ../../library/token.rst:247 +#: ../../library/token.rst:245 msgid "Added :data:`COMMENT`, :data:`NL` and :data:`ENCODING` tokens." msgstr "" -#: ../../library/token.rst:250 +#: ../../library/token.rst:248 msgid "" "Removed :data:`!AWAIT` and :data:`!ASYNC` tokens. \"async\" and \"await\" " "are now tokenized as :data:`NAME` tokens." msgstr "" -#: ../../library/token.rst:254 +#: ../../library/token.rst:252 msgid "" "Added :data:`TYPE_COMMENT`, :data:`TYPE_IGNORE`, :data:`COLONEQUAL`. Added :" "data:`!AWAIT` and :data:`!ASYNC` tokens back (they're needed to support " @@ -490,10 +490,10 @@ msgid "" "set to 6 or lower)." msgstr "" -#: ../../library/token.rst:260 +#: ../../library/token.rst:258 msgid "Added :data:`EXCLAMATION`." msgstr "新增 :data:`EXCLAMATION`。" -#: ../../library/token.rst:263 +#: ../../library/token.rst:261 msgid "Removed :data:`!AWAIT` and :data:`!ASYNC` tokens again." msgstr "" diff --git a/library/tokenize.po b/library/tokenize.po index 5f54352062d..d46d8b1cb43 100644 --- a/library/tokenize.po +++ b/library/tokenize.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:13+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!tokenize` --- Tokenizer for Python source" msgstr "" -#: ../../library/tokenize.rst:10 +#: ../../library/tokenize.rst:7 msgid "**Source code:** :source:`Lib/tokenize.py`" msgstr "**原始碼:**\\ :source:`Lib/tokenize.py`" -#: ../../library/tokenize.rst:14 +#: ../../library/tokenize.rst:11 msgid "" "The :mod:`!tokenize` module provides a lexical scanner for Python source " "code, implemented in Python. The scanner in this module returns comments as " @@ -33,7 +33,7 @@ msgid "" "including colorizers for on-screen displays." msgstr "" -#: ../../library/tokenize.rst:19 +#: ../../library/tokenize.rst:16 msgid "" "To simplify token stream handling, all :ref:`operator ` and :ref:" "`delimiter ` tokens and :data:`Ellipsis` are returned using the " @@ -42,7 +42,7 @@ msgid "" "from :func:`tokenize.tokenize`." msgstr "" -#: ../../library/tokenize.rst:28 +#: ../../library/tokenize.rst:25 msgid "" "Note that the functions in this module are only designed to parse " "syntactically valid Python code (code that does not raise when parsed using :" @@ -51,15 +51,15 @@ msgid "" "point." msgstr "" -#: ../../library/tokenize.rst:35 -msgid "Tokenizing Input" +#: ../../library/tokenize.rst:32 +msgid "Tokenizing input" msgstr "" -#: ../../library/tokenize.rst:37 +#: ../../library/tokenize.rst:34 msgid "The primary entry point is a :term:`generator`:" msgstr "" -#: ../../library/tokenize.rst:41 +#: ../../library/tokenize.rst:38 msgid "" "The :func:`.tokenize` generator requires one argument, *readline*, which " "must be a callable object which provides the same interface as the :meth:`io." @@ -67,7 +67,7 @@ msgid "" "return one line of input as bytes." msgstr "" -#: ../../library/tokenize.rst:46 +#: ../../library/tokenize.rst:43 msgid "" "The generator produces 5-tuples with these members: the token type; the " "token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and " @@ -78,7 +78,7 @@ msgid "" "with the field names: ``type string start end line``." msgstr "" -#: ../../library/tokenize.rst:55 +#: ../../library/tokenize.rst:52 msgid "" "The returned :term:`named tuple` has an additional property named " "``exact_type`` that contains the exact operator type for :data:`~token.OP` " @@ -86,58 +86,58 @@ msgid "" "``type`` field." msgstr "" -#: ../../library/tokenize.rst:60 +#: ../../library/tokenize.rst:57 msgid "Added support for named tuples." msgstr "新增附名元組 (named tuple) 的支援。" -#: ../../library/tokenize.rst:63 +#: ../../library/tokenize.rst:60 msgid "Added support for ``exact_type``." msgstr "新增 ``exact_type`` 的支援。" -#: ../../library/tokenize.rst:66 +#: ../../library/tokenize.rst:63 msgid "" ":func:`.tokenize` determines the source encoding of the file by looking for " "a UTF-8 BOM or encoding cookie, according to :pep:`263`." msgstr "" -#: ../../library/tokenize.rst:71 +#: ../../library/tokenize.rst:68 msgid "Tokenize a source reading unicode strings instead of bytes." msgstr "" -#: ../../library/tokenize.rst:73 +#: ../../library/tokenize.rst:70 msgid "" "Like :func:`.tokenize`, the *readline* argument is a callable returning a " "single line of input. However, :func:`generate_tokens` expects *readline* to " "return a str object rather than bytes." msgstr "" -#: ../../library/tokenize.rst:77 +#: ../../library/tokenize.rst:74 msgid "" "The result is an iterator yielding named tuples, exactly like :func:`." "tokenize`. It does not yield an :data:`~token.ENCODING` token." msgstr "" -#: ../../library/tokenize.rst:80 +#: ../../library/tokenize.rst:77 msgid "" "All constants from the :mod:`token` module are also exported from :mod:`!" "tokenize`." msgstr "" -#: ../../library/tokenize.rst:83 +#: ../../library/tokenize.rst:80 msgid "" "Another function is provided to reverse the tokenization process. This is " "useful for creating tools that tokenize a script, modify the token stream, " "and write back the modified script." msgstr "" -#: ../../library/tokenize.rst:90 +#: ../../library/tokenize.rst:87 msgid "" "Converts tokens back into Python source code. The *iterable* must return " "sequences with at least two elements, the token type and the token string. " "Any additional sequence elements are ignored." msgstr "" -#: ../../library/tokenize.rst:94 +#: ../../library/tokenize.rst:91 msgid "" "The result is guaranteed to tokenize back to match the input so that the " "conversion is lossless and round-trips are assured. The guarantee applies " @@ -145,33 +145,33 @@ msgid "" "(column positions) may change." msgstr "" -#: ../../library/tokenize.rst:99 +#: ../../library/tokenize.rst:96 msgid "" "It returns bytes, encoded using the :data:`~token.ENCODING` token, which is " "the first token sequence output by :func:`.tokenize`. If there is no " "encoding token in the input, it returns a str instead." msgstr "" -#: ../../library/tokenize.rst:104 +#: ../../library/tokenize.rst:101 msgid "" ":func:`.tokenize` needs to detect the encoding of source files it tokenizes. " "The function it uses to do this is available:" msgstr "" -#: ../../library/tokenize.rst:109 +#: ../../library/tokenize.rst:106 msgid "" "The :func:`detect_encoding` function is used to detect the encoding that " "should be used to decode a Python source file. It requires one argument, " "readline, in the same way as the :func:`.tokenize` generator." msgstr "" -#: ../../library/tokenize.rst:113 +#: ../../library/tokenize.rst:110 msgid "" "It will call readline a maximum of twice, and return the encoding used (as a " "string) and a list of any lines (not decoded from bytes) it has read in." msgstr "" -#: ../../library/tokenize.rst:117 +#: ../../library/tokenize.rst:114 msgid "" "It detects the encoding from the presence of a UTF-8 BOM or an encoding " "cookie as specified in :pep:`263`. If both a BOM and a cookie are present, " @@ -179,31 +179,31 @@ msgid "" "found, ``'utf-8-sig'`` will be returned as an encoding." msgstr "" -#: ../../library/tokenize.rst:122 +#: ../../library/tokenize.rst:119 msgid "" "If no encoding is specified, then the default of ``'utf-8'`` will be " "returned." msgstr "" -#: ../../library/tokenize.rst:125 +#: ../../library/tokenize.rst:122 msgid "" "Use :func:`.open` to open Python source files: it uses :func:" "`detect_encoding` to detect the file encoding." msgstr "" -#: ../../library/tokenize.rst:131 +#: ../../library/tokenize.rst:128 msgid "" "Open a file in read only mode using the encoding detected by :func:" "`detect_encoding`." msgstr "" -#: ../../library/tokenize.rst:138 +#: ../../library/tokenize.rst:135 msgid "" "Raised when either a docstring or expression that may be split over several " "lines is not completed anywhere in the file, for example::" msgstr "" -#: ../../library/tokenize.rst:141 +#: ../../library/tokenize.rst:138 msgid "" "\"\"\"Beginning of\n" "docstring" @@ -211,11 +211,11 @@ msgstr "" "\"\"\"Beginning of\n" "docstring" -#: ../../library/tokenize.rst:144 +#: ../../library/tokenize.rst:141 msgid "or::" msgstr "或是: ::" -#: ../../library/tokenize.rst:146 +#: ../../library/tokenize.rst:143 msgid "" "[1,\n" " 2,\n" @@ -225,49 +225,55 @@ msgstr "" " 2,\n" " 3" -#: ../../library/tokenize.rst:153 -msgid "Command-Line Usage" +#: ../../library/tokenize.rst:150 +msgid "Command-line usage" msgstr "命令列用法" -#: ../../library/tokenize.rst:157 +#: ../../library/tokenize.rst:154 msgid "" "The :mod:`!tokenize` module can be executed as a script from the command " "line. It is as simple as:" msgstr "" -#: ../../library/tokenize.rst:160 +#: ../../library/tokenize.rst:157 msgid "python -m tokenize [-e] [filename.py]" msgstr "python -m tokenize [-e] [filename.py]" -#: ../../library/tokenize.rst:164 +#: ../../library/tokenize.rst:161 msgid "The following options are accepted:" msgstr "可接受以下選項:" -#: ../../library/tokenize.rst:170 +#: ../../library/tokenize.rst:167 msgid "show this help message and exit" msgstr "" -#: ../../library/tokenize.rst:174 +#: ../../library/tokenize.rst:171 msgid "display token names using the exact type" msgstr "" -#: ../../library/tokenize.rst:176 +#: ../../library/tokenize.rst:173 msgid "" "If :file:`filename.py` is specified its contents are tokenized to stdout. " "Otherwise, tokenization is performed on stdin." msgstr "" -#: ../../library/tokenize.rst:180 +#: ../../library/tokenize.rst:176 +msgid "" +"Output is in color by default and can be :ref:`controlled using environment " +"variables `." +msgstr "" + +#: ../../library/tokenize.rst:181 msgid "Examples" msgstr "範例" -#: ../../library/tokenize.rst:182 +#: ../../library/tokenize.rst:183 msgid "" "Example of a script rewriter that transforms float literals into Decimal " "objects::" msgstr "" -#: ../../library/tokenize.rst:185 +#: ../../library/tokenize.rst:186 msgid "" "from tokenize import tokenize, untokenize, NUMBER, STRING, NAME, OP\n" "from io import BytesIO\n" @@ -310,11 +316,11 @@ msgid "" " return untokenize(result).decode('utf-8')" msgstr "" -#: ../../library/tokenize.rst:224 +#: ../../library/tokenize.rst:225 msgid "Example of tokenizing from the command line. The script::" msgstr "" -#: ../../library/tokenize.rst:226 +#: ../../library/tokenize.rst:227 msgid "" "def say_hello():\n" " print(\"Hello, World!\")\n" @@ -326,15 +332,15 @@ msgstr "" "\n" "say_hello()" -#: ../../library/tokenize.rst:231 +#: ../../library/tokenize.rst:232 msgid "" "will be tokenized to the following output where the first column is the " "range of the line/column coordinates where the token is found, the second " "column is the name of the token, and the final column is the value of the " -"token (if any)" +"token (if any):" msgstr "" -#: ../../library/tokenize.rst:235 +#: ../../library/tokenize.rst:236 msgid "" "$ python -m tokenize hello.py\n" "0,0-0,0: ENCODING 'utf-8'\n" @@ -380,12 +386,12 @@ msgstr "" "4,11-4,12: NEWLINE '\\n'\n" "5,0-5,0: ENDMARKER ''" -#: ../../library/tokenize.rst:259 +#: ../../library/tokenize.rst:260 msgid "" "The exact token type names can be displayed using the :option:`-e` option:" msgstr "" -#: ../../library/tokenize.rst:261 +#: ../../library/tokenize.rst:262 msgid "" "$ python -m tokenize -e hello.py\n" "0,0-0,0: ENCODING 'utf-8'\n" @@ -431,13 +437,13 @@ msgstr "" "4,11-4,12: NEWLINE '\\n'\n" "5,0-5,0: ENDMARKER ''" -#: ../../library/tokenize.rst:285 +#: ../../library/tokenize.rst:286 msgid "" "Example of tokenizing a file programmatically, reading unicode strings " "instead of bytes with :func:`generate_tokens`::" msgstr "" -#: ../../library/tokenize.rst:288 +#: ../../library/tokenize.rst:289 msgid "" "import tokenize\n" "\n" @@ -453,11 +459,11 @@ msgstr "" " for token in tokens:\n" " print(token)" -#: ../../library/tokenize.rst:295 +#: ../../library/tokenize.rst:296 msgid "Or reading bytes directly with :func:`.tokenize`::" msgstr "" -#: ../../library/tokenize.rst:297 +#: ../../library/tokenize.rst:298 msgid "" "import tokenize\n" "\n" diff --git a/library/tomllib.po b/library/tomllib.po index e9222cfb3b0..1988a11ea8c 100644 --- a/library/tomllib.po +++ b/library/tomllib.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-02 00:31+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-11-18 01:56+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,27 +22,37 @@ msgstr "" msgid ":mod:`!tomllib` --- Parse TOML files" msgstr ":mod:`!tomllib` --- 剖析 TOML 檔案" -#: ../../library/tomllib.rst:12 +#: ../../library/tomllib.rst:7 msgid "**Source code:** :source:`Lib/tomllib`" msgstr "**原始碼:**\\ :source:`Lib/tomllib`" -#: ../../library/tomllib.rst:16 +#: ../../library/tomllib.rst:11 msgid "" -"This module provides an interface for parsing TOML 1.0.0 (Tom's Obvious " +"This module provides an interface for parsing TOML 1.1.0 (Tom's Obvious " "Minimal Language, `https://toml.io `_). This module " "does not support writing TOML." msgstr "" -"此模組提供了剖析 TOML 1.0.0 (Tom's Obvious Minimal Language, `https://toml." -"io `_) 的一個介面,此模組並不支援寫入 TOML。" +"此模組提供了剖析 TOML 1.1.0 (Tom's Obvious Minimal Language, `https://" +"toml.io `_) 的一個介面,此模組並不支援寫入 TOML。" -#: ../../library/tomllib.rst:22 +#: ../../library/tomllib.rst:15 +msgid "The module was added with support for TOML 1.0.0." +msgstr "" + +#: ../../library/tomllib.rst:18 +msgid "" +"Added TOML 1.1.0 support. See the :ref:`What's New ` for details." +msgstr "" + +#: ../../library/tomllib.rst:24 msgid "" "Be cautious when parsing data from untrusted sources. A malicious TOML " "string may cause the decoder to consume considerable CPU and memory " "resources. Limiting the size of data to be parsed is recommended." msgstr "" -#: ../../library/tomllib.rst:29 +#: ../../library/tomllib.rst:31 msgid "" "The :pypi:`Tomli-W package ` is a TOML writer that can be used in " "conjunction with this module, providing a write API familiar to users of the " @@ -52,7 +62,7 @@ msgstr "" "提供標準函式庫中 :mod:`marshal` 和 :mod:`pickle` 模組之使用者所熟悉的寫入 " "API。" -#: ../../library/tomllib.rst:36 +#: ../../library/tomllib.rst:38 msgid "" "The :pypi:`TOML Kit package ` is a style-preserving TOML library " "with both read and write capability. It is a recommended replacement for " @@ -61,11 +71,11 @@ msgstr "" ":pypi:`TOML 工具套件 `\\ 是一個保留風格且具有讀寫能力的 TOML 函式" "庫。若要編輯已存在的 TOML 文件,建議用它來替換此模組。" -#: ../../library/tomllib.rst:42 +#: ../../library/tomllib.rst:44 msgid "This module defines the following functions:" msgstr "此模組定義了以下函式:" -#: ../../library/tomllib.rst:46 +#: ../../library/tomllib.rst:48 msgid "" "Read a TOML file. The first argument should be a readable and binary file " "object. Return a :class:`dict`. Convert TOML types to Python using this :ref:" @@ -75,7 +85,7 @@ msgstr "" "class:`dict`。用這個\\ :ref:`轉換表 `\\ 將 TOML 型別轉換成 " "Python 的。" -#: ../../library/tomllib.rst:50 +#: ../../library/tomllib.rst:52 msgid "" "*parse_float* will be called with the string of every TOML float to be " "decoded. By default, this is equivalent to ``float(num_str)``. This can be " @@ -88,11 +98,11 @@ msgstr "" "class:`decimal.Decimal`),這就派得上用場。可呼叫物件不得回傳 :class:`dict` " "或 :class:`list`,否則會引發 :exc:`ValueError`。" -#: ../../library/tomllib.rst:56 ../../library/tomllib.rst:65 +#: ../../library/tomllib.rst:58 ../../library/tomllib.rst:67 msgid "A :exc:`TOMLDecodeError` will be raised on an invalid TOML document." msgstr "不合格的 TOML 文件會使得 :exc:`TOMLDecodeError` 被引發。" -#: ../../library/tomllib.rst:61 +#: ../../library/tomllib.rst:63 msgid "" "Load TOML from a :class:`str` object. Return a :class:`dict`. Convert TOML " "types to Python using this :ref:`conversion table `. The " @@ -102,53 +112,53 @@ msgstr "" "轉換表 `\\ 轉換 TOML 型別成 Python 的。*parse_float* 引數" "和 :func:`load` 中的相同。" -#: ../../library/tomllib.rst:68 +#: ../../library/tomllib.rst:70 msgid "The following exceptions are available:" msgstr "以下為可用的例外:" -#: ../../library/tomllib.rst:72 +#: ../../library/tomllib.rst:74 msgid "Subclass of :exc:`ValueError` with the following additional attributes:" msgstr "" -#: ../../library/tomllib.rst:76 +#: ../../library/tomllib.rst:78 msgid "The unformatted error message." msgstr "" -#: ../../library/tomllib.rst:80 +#: ../../library/tomllib.rst:82 msgid "The TOML document being parsed." msgstr "" -#: ../../library/tomllib.rst:84 +#: ../../library/tomllib.rst:86 msgid "The index of *doc* where parsing failed." msgstr "" -#: ../../library/tomllib.rst:88 +#: ../../library/tomllib.rst:90 msgid "The line corresponding to *pos*." msgstr "" -#: ../../library/tomllib.rst:92 +#: ../../library/tomllib.rst:94 msgid "The column corresponding to *pos*." msgstr "" -#: ../../library/tomllib.rst:94 +#: ../../library/tomllib.rst:96 msgid "" "Added the *msg*, *doc* and *pos* parameters. Added the :attr:`msg`, :attr:" "`doc`, :attr:`pos`, :attr:`lineno` and :attr:`colno` attributes." msgstr "" -#: ../../library/tomllib.rst:98 +#: ../../library/tomllib.rst:100 msgid "Passing free-form positional arguments is deprecated." msgstr "傳遞自由形式的位置引數已被棄用。" -#: ../../library/tomllib.rst:103 +#: ../../library/tomllib.rst:105 msgid "Examples" msgstr "範例" -#: ../../library/tomllib.rst:105 +#: ../../library/tomllib.rst:107 msgid "Parsing a TOML file::" msgstr "剖析一個 TOML 檔案: ::" -#: ../../library/tomllib.rst:107 +#: ../../library/tomllib.rst:109 msgid "" "import tomllib\n" "\n" @@ -160,11 +170,11 @@ msgstr "" "with open(\"pyproject.toml\", \"rb\") as f:\n" " data = tomllib.load(f)" -#: ../../library/tomllib.rst:112 +#: ../../library/tomllib.rst:114 msgid "Parsing a TOML string::" msgstr "剖析一個 TOML 字串: ::" -#: ../../library/tomllib.rst:114 +#: ../../library/tomllib.rst:116 msgid "" "import tomllib\n" "\n" @@ -184,114 +194,198 @@ msgstr "" "\n" "data = tomllib.loads(toml_str)" -#: ../../library/tomllib.rst:125 +#: ../../library/tomllib.rst:127 msgid "Conversion Table" msgstr "轉換表" -#: ../../library/tomllib.rst:130 +#: ../../library/tomllib.rst:132 msgid "TOML" msgstr "TOML" -#: ../../library/tomllib.rst:130 +#: ../../library/tomllib.rst:132 msgid "Python" msgstr "Python" -#: ../../library/tomllib.rst:132 +#: ../../library/tomllib.rst:134 msgid "TOML document" msgstr "TOML 文件" -#: ../../library/tomllib.rst:132 ../../library/tomllib.rst:152 -#: ../../library/tomllib.rst:154 +#: ../../library/tomllib.rst:134 ../../library/tomllib.rst:154 +#: ../../library/tomllib.rst:156 msgid "dict" msgstr "dict" -#: ../../library/tomllib.rst:134 +#: ../../library/tomllib.rst:136 msgid "string" msgstr "string" -#: ../../library/tomllib.rst:134 +#: ../../library/tomllib.rst:136 msgid "str" msgstr "str" -#: ../../library/tomllib.rst:136 +#: ../../library/tomllib.rst:138 msgid "integer" msgstr "integer" -#: ../../library/tomllib.rst:136 +#: ../../library/tomllib.rst:138 msgid "int" msgstr "int" -#: ../../library/tomllib.rst:138 +#: ../../library/tomllib.rst:140 msgid "float" msgstr "float" -#: ../../library/tomllib.rst:138 +#: ../../library/tomllib.rst:140 msgid "float (configurable with *parse_float*)" msgstr "float(可透過 *parse_float* 調整)" -#: ../../library/tomllib.rst:140 +#: ../../library/tomllib.rst:142 msgid "boolean" msgstr "boolean" -#: ../../library/tomllib.rst:140 +#: ../../library/tomllib.rst:142 msgid "bool" msgstr "bool" -#: ../../library/tomllib.rst:142 +#: ../../library/tomllib.rst:144 msgid "offset date-time" msgstr "偏移日期時間 (offset date-time)" -#: ../../library/tomllib.rst:142 +#: ../../library/tomllib.rst:144 msgid "" "datetime.datetime (``tzinfo`` attribute set to an instance of ``datetime." "timezone``)" msgstr "" "datetime.datetime(設定 ``tzinfo`` 屬性為 ``datetime.timezone`` 的實例)" -#: ../../library/tomllib.rst:144 +#: ../../library/tomllib.rst:146 msgid "local date-time" msgstr "本地日期時間 (local date-time)" -#: ../../library/tomllib.rst:144 +#: ../../library/tomllib.rst:146 msgid "datetime.datetime (``tzinfo`` attribute set to ``None``)" msgstr "datetime.datetime(設定 ``tzinfo`` 為 ``None``)" -#: ../../library/tomllib.rst:146 +#: ../../library/tomllib.rst:148 msgid "local date" msgstr "本地日期 (local date)" -#: ../../library/tomllib.rst:146 +#: ../../library/tomllib.rst:148 msgid "datetime.date" msgstr "datetime.date" -#: ../../library/tomllib.rst:148 +#: ../../library/tomllib.rst:150 msgid "local time" msgstr "本地時間 (local time)" -#: ../../library/tomllib.rst:148 +#: ../../library/tomllib.rst:150 msgid "datetime.time" msgstr "datetime.time" -#: ../../library/tomllib.rst:150 +#: ../../library/tomllib.rst:152 msgid "array" msgstr "array" -#: ../../library/tomllib.rst:150 +#: ../../library/tomllib.rst:152 msgid "list" msgstr "list" -#: ../../library/tomllib.rst:152 +#: ../../library/tomllib.rst:154 msgid "table" msgstr "table" -#: ../../library/tomllib.rst:154 +#: ../../library/tomllib.rst:156 msgid "inline table" msgstr "行內表格 (inline table)" -#: ../../library/tomllib.rst:156 +#: ../../library/tomllib.rst:158 msgid "array of tables" msgstr "表格陣列 (array of tables)" -#: ../../library/tomllib.rst:156 +#: ../../library/tomllib.rst:158 msgid "list of dicts" msgstr "dict 串列 (list of dicts)" + +#: ../../library/tomllib.rst:162 +msgid "Limits and interoperability considerations" +msgstr "" + +#: ../../library/tomllib.rst:164 +msgid "" +":mod:`!tomllib` places some limits on the documents it can handle, and it " +"preserves details that other TOML parsers are allowed to ignore. When " +"writing portable TOML files, only use features that are guaranteed or " +"recommended by the standard." +msgstr "" + +#: ../../library/tomllib.rst:169 +msgid "" +"The implementation details listed here may change in future versions of " +"Python." +msgstr "" + +#: ../../library/tomllib.rst:171 +msgid "Tables/dicts" +msgstr "" + +#: ../../library/tomllib.rst:172 +msgid "" +"The TOML spec does not guarantee key/value pairs in TOML documents and " +"tables to be in any specific order." +msgstr "" + +#: ../../library/tomllib.rst:176 +msgid "" +":mod:`!tomllib` loads dictionary entries in the order they appear in the " +"source." +msgstr "" + +#: ../../library/tomllib.rst:179 +msgid "Integers" +msgstr "整數" + +#: ../../library/tomllib.rst:180 +msgid "TOML recommends supporting integers in ``range(−2**63, 2**63)``." +msgstr "" + +#: ../../library/tomllib.rst:183 +msgid "" +":mod:`!tomllib` uses :ref:`Python's limit on integer string conversion " +"` (4300 digits by default)." +msgstr "" + +#: ../../library/tomllib.rst:186 +msgid "Floats" +msgstr "浮點數" + +#: ../../library/tomllib.rst:187 +msgid "" +"TOML recommends supporting at least IEEE 754 binary64 values, which means " +"that numbers with more than 15 significant decimal digits are likely to be " +"rounded." +msgstr "" + +#: ../../library/tomllib.rst:192 +msgid "" +":mod:`!tomllib` uses Python :class:`float` by default; on many common " +"platforms this is the recommended binary64. See :data:`sys.float_info` for " +"details." +msgstr "" + +#: ../../library/tomllib.rst:196 +msgid "Nesting limit" +msgstr "" + +#: ../../library/tomllib.rst:197 +msgid "" +"TOML 1.1.0 does not recommend a limit on how deeply arrays and tables may be " +"nested inside one another. (A limit of 100 has been proposed for a future " +"version of TOML.)" +msgstr "" + +#: ../../library/tomllib.rst:202 +msgid "" +"In :mod:`!tomllib`, the nesting level is mainly limited by Python's :func:" +"`recursion limit `. Note that code that calls :mod:`!" +"tomllib` may contribute to the limit." +msgstr "" diff --git a/library/tty.po b/library/tty.po index 5a260a51ff9..1098bed7d3c 100644 --- a/library/tty.po +++ b/library/tty.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-20 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-06-28 20:38+0800\n" "Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,30 +24,30 @@ msgstr "" msgid ":mod:`!tty` --- Terminal control functions" msgstr ":mod:`!tty` --- 終端機控制函式" -#: ../../library/tty.rst:10 +#: ../../library/tty.rst:7 msgid "**Source code:** :source:`Lib/tty.py`" msgstr "**原始碼:**\\ :source:`Lib/tty.py`" -#: ../../library/tty.rst:14 +#: ../../library/tty.rst:11 msgid "" "The :mod:`!tty` module defines functions for putting the tty into cbreak and " "raw modes." msgstr ":mod:`!tty` 模組定義了將 tty 放入 cbreak 和 raw 模式的函式。" -#: ../../library/tty.rst:17 +#: ../../library/tty.rst:14 msgid "Availability" msgstr "可用性" -#: ../../library/tty.rst:19 +#: ../../library/tty.rst:16 msgid "" "Because it requires the :mod:`termios` module, it will work only on Unix." msgstr "因為它需要 :mod:`termios` 模組,所以只能在 Unix 上執行。" -#: ../../library/tty.rst:21 +#: ../../library/tty.rst:18 msgid "The :mod:`!tty` module defines the following functions:" msgstr ":mod:`!tty` 模組定義了以下函式:" -#: ../../library/tty.rst:26 +#: ../../library/tty.rst:23 msgid "" "Convert the tty attribute list *mode*, which is a list like the one returned " "by :func:`termios.tcgetattr`, to that of a tty in raw mode." @@ -55,7 +55,7 @@ msgstr "" "將 tty 屬性串列 *mode* 轉換成原始模式下的 tty 屬性串列,這個串列就像 :func:" "`termios.tcgetattr` 所回傳的一樣。" -#: ../../library/tty.rst:34 +#: ../../library/tty.rst:31 msgid "" "Convert the tty attribute list *mode*, which is a list like the one returned " "by :func:`termios.tcgetattr`, to that of a tty in cbreak mode." @@ -63,7 +63,7 @@ msgstr "" "將 tty 屬性串列 *mode* 轉換成 cbreak 模式下的 tty 屬性串列,這個串列就像 :" "func:`termios.tcgetattr` 所回傳的一樣。" -#: ../../library/tty.rst:37 +#: ../../library/tty.rst:34 msgid "" "This clears the ``ECHO`` and ``ICANON`` local mode flags in *mode* as well " "as setting the minimum input to 1 byte with no delay." @@ -71,7 +71,7 @@ msgstr "" "這會清除 *mode* 中的 ``ECHO`` 和 ``ICANON`` 本地模式旗標,並將最小輸入設定為 " "1 位元組,且無延遲。" -#: ../../library/tty.rst:42 +#: ../../library/tty.rst:39 msgid "" "The ``ICRNL`` flag is no longer cleared. This matches Linux and macOS ``stty " "cbreak`` behavior and what :func:`setcbreak` historically did." @@ -79,7 +79,7 @@ msgstr "" "不再清除 ``ICRNL`` 標記。這符合 Linux 和 macOS 的 ``stty cbreak`` 行為,也符" "合 :func:`setcbreak` 歷來的做法。" -#: ../../library/tty.rst:49 +#: ../../library/tty.rst:46 msgid "" "Change the mode of the file descriptor *fd* to raw. If *when* is omitted, it " "defaults to :const:`termios.TCSAFLUSH`, and is passed to :func:`termios." @@ -91,12 +91,12 @@ msgstr "" "tcgetattr` 的回傳值會在設定 *fd* 模式為 raw 之前先儲存起來。此函式回傳這個" "值。" -#: ../../library/tty.rst:54 ../../library/tty.rst:68 +#: ../../library/tty.rst:51 ../../library/tty.rst:65 msgid "" "The return value is now the original tty attributes, instead of ``None``." msgstr "現在的回傳值為原本的 tty 屬性,而不是 ``None``。" -#: ../../library/tty.rst:60 +#: ../../library/tty.rst:57 msgid "" "Change the mode of file descriptor *fd* to cbreak. If *when* is omitted, it " "defaults to :const:`termios.TCSAFLUSH`, and is passed to :func:`termios." @@ -108,7 +108,7 @@ msgstr "" "tcgetattr` 的回傳值會在設定 *fd* 模式為 raw 之前先儲存起來。此函式回傳這個" "值。" -#: ../../library/tty.rst:65 +#: ../../library/tty.rst:62 msgid "" "This clears the ``ECHO`` and ``ICANON`` local mode flags as well as setting " "the minimum input to 1 byte with no delay." @@ -116,7 +116,7 @@ msgstr "" "這會清除 ``ECHO`` 和 ``ICANON`` 本地模式旗標,並將最小輸入設定為 1 位元組,且" "無延遲。" -#: ../../library/tty.rst:71 +#: ../../library/tty.rst:68 msgid "" "The ``ICRNL`` flag is no longer cleared. This restores the behavior of " "Python 3.11 and earlier as well as matching what Linux, macOS, & BSDs " @@ -125,10 +125,10 @@ msgstr "" "不再清除 ``ICRNL`` 旗標。這恢復了 Python 3.11 及更早版本的行為,也符合 " "Linux、macOS 及 BSD 在他們的 ``stty(1)`` man 頁面中描述的 cbreak 模式。" -#: ../../library/tty.rst:79 +#: ../../library/tty.rst:76 msgid "Module :mod:`termios`" msgstr ":mod:`termios` 模組" -#: ../../library/tty.rst:80 +#: ../../library/tty.rst:77 msgid "Low-level terminal control interface." msgstr "低階終端機控制介面。" diff --git a/library/turtle.po b/library/turtle.po index 958b7b5e900..b37deb7014a 100644 --- a/library/turtle.po +++ b/library/turtle.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-12 00:24+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:13+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,20 +22,20 @@ msgstr "" msgid ":mod:`!turtle` --- Turtle graphics" msgstr ":mod:`!turtle` --- 龜圖學 (Turtle graphics)" -#: ../../library/turtle.rst:10 +#: ../../library/turtle.rst:8 msgid "**Source code:** :source:`Lib/turtle.py`" msgstr "**原始碼:**\\ :source:`Lib/turtle.py`" -#: ../../library/turtle.rst:28 +#: ../../library/turtle.rst:29 msgid "" "Turtle can draw intricate shapes using programs that repeat simple moves." msgstr "龜可以使用重複簡單動作之程式來畫出複雜的形狀。" -#: ../../library/turtle.rst:31 +#: ../../library/turtle.rst:32 msgid "A yellow starburst of thin spikes with a red outline, drawn by turtle." msgstr "" -#: ../../library/turtle.rst:35 +#: ../../library/turtle.rst:36 msgid "" "Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an " "``import turtle``, give it the command ``turtle.forward(15)``, and it moves " @@ -44,7 +44,7 @@ msgid "" "degrees clockwise." msgstr "" -#: ../../library/turtle.rst:41 +#: ../../library/turtle.rst:42 msgid "" "Turtle graphics is an implementation of `the drawing tools introduced in " "Logo `__ in 1967. It was " @@ -54,31 +54,31 @@ msgid "" "external libraries." msgstr "" -#: ../../library/turtle.rst:47 +#: ../../library/turtle.rst:48 msgid "This document includes four main sections:" msgstr "" -#: ../../library/turtle.rst:49 +#: ../../library/turtle.rst:50 msgid ":ref:`turtle-tutorial` teaches the basics of turtle drawing." msgstr "" -#: ../../library/turtle.rst:50 +#: ../../library/turtle.rst:51 msgid "" ":ref:`turtle-reference` describes the functions, methods and classes this " "module defines." msgstr "" -#: ../../library/turtle.rst:52 +#: ../../library/turtle.rst:53 msgid ":ref:`turtle-howtos` detail how to handle specific tasks." msgstr "" -#: ../../library/turtle.rst:53 +#: ../../library/turtle.rst:54 msgid "" ":ref:`turtle-explanation` provides background on the object-oriented " "interface." msgstr "" -#: ../../library/turtle.rst:58 +#: ../../library/turtle.rst:59 msgid "" "Turtle graphics requires the :mod:`tkinter` :term:`optional module`. The " "python.org installers for Windows and macOS include it, but some Linux " @@ -88,76 +88,77 @@ msgid "" "in advance if you're planning to use turtle graphics with a learner." msgstr "" -#: ../../library/turtle.rst:71 +#: ../../library/turtle.rst:72 msgid "Tutorial" msgstr "教學" -#: ../../library/turtle.rst:73 +#: ../../library/turtle.rst:74 msgid "" "New users should start here. In this tutorial we'll explore some of the " "basics of turtle drawing." msgstr "" -#: ../../library/turtle.rst:78 +#: ../../library/turtle.rst:79 msgid "Starting a turtle environment" msgstr "啟動一個烏龜環境" -#: ../../library/turtle.rst:80 +#: ../../library/turtle.rst:81 msgid "In a Python shell, import all the objects of the ``turtle`` module::" msgstr "在 Python shell 中,引入 ``turtle`` 模組中所有物件: ::" -#: ../../library/turtle.rst:82 +#: ../../library/turtle.rst:83 msgid "from turtle import *" msgstr "from turtle import *" -#: ../../library/turtle.rst:84 +#: ../../library/turtle.rst:85 msgid "" -"If you run into a ``No module named '_tkinter'`` error, you'll have to " -"install the :mod:`Tk interface package ` on your system." +"If you run into a ``Standard library module '_tkinter' was not found`` " +"error, you'll have to install the :mod:`Tk interface package ` on " +"your system." msgstr "" -#: ../../library/turtle.rst:87 +#: ../../library/turtle.rst:88 msgid "" "Nothing appears yet. To open the turtle window, make the turtle visible::" msgstr "" -#: ../../library/turtle.rst:89 +#: ../../library/turtle.rst:90 msgid "showturtle()" msgstr "showturtle()" -#: ../../library/turtle.rst:91 +#: ../../library/turtle.rst:92 msgid "" "A new window opens, with the turtle in the middle, shown as an arrow heading " "East." msgstr "" -#: ../../library/turtle.rst:96 +#: ../../library/turtle.rst:97 msgid "Basic drawing" msgstr "基本繪圖" -#: ../../library/turtle.rst:98 +#: ../../library/turtle.rst:99 msgid "Send the turtle forward 100 steps::" msgstr "" -#: ../../library/turtle.rst:100 +#: ../../library/turtle.rst:101 msgid "forward(100)" msgstr "forward(100)" -#: ../../library/turtle.rst:102 +#: ../../library/turtle.rst:103 msgid "" "You should see a line drawn by the turtle, heading East. Change the " "direction of the turtle, so that it turns 120 degrees left (anti-clockwise)::" msgstr "" -#: ../../library/turtle.rst:106 +#: ../../library/turtle.rst:107 msgid "left(120)" msgstr "left(120)" -#: ../../library/turtle.rst:108 +#: ../../library/turtle.rst:109 msgid "Let's continue by drawing a triangle::" msgstr "" -#: ../../library/turtle.rst:110 +#: ../../library/turtle.rst:111 msgid "" "forward(100)\n" "left(120)\n" @@ -167,82 +168,82 @@ msgstr "" "left(120)\n" "forward(100)" -#: ../../library/turtle.rst:114 +#: ../../library/turtle.rst:115 msgid "" "Notice how the turtle, represented by an arrow, points in different " "directions as you steer it." msgstr "" -#: ../../library/turtle.rst:117 +#: ../../library/turtle.rst:118 msgid "" "Experiment with those commands, and also with ``backward()`` and " "``right()``. Many commands also have shorter aliases, such as ``fd()`` for :" "func:`forward`." msgstr "" -#: ../../library/turtle.rst:123 ../../library/turtle.rst:810 +#: ../../library/turtle.rst:124 ../../library/turtle.rst:811 msgid "Pen control" msgstr "" -#: ../../library/turtle.rst:125 +#: ../../library/turtle.rst:126 msgid "" "Try changing the color - for example, ``color('blue')`` - and width of the " "line - for example, ``width(3)`` - and then drawing again." msgstr "" -#: ../../library/turtle.rst:128 +#: ../../library/turtle.rst:129 msgid "" "You can also move the turtle around without drawing, by lifting up the pen: " "``up()`` before moving. To start drawing again, use ``down()``." msgstr "" -#: ../../library/turtle.rst:133 +#: ../../library/turtle.rst:134 msgid "The turtle's position" msgstr "" -#: ../../library/turtle.rst:135 +#: ../../library/turtle.rst:136 msgid "" "Send your turtle back to its starting-point (useful if it has disappeared " "off-screen)::" msgstr "" -#: ../../library/turtle.rst:138 +#: ../../library/turtle.rst:139 msgid "home()" msgstr "home()" -#: ../../library/turtle.rst:140 +#: ../../library/turtle.rst:141 msgid "" "The home position is at the center of the turtle's screen. If you ever need " "to know them, get the turtle's x-y coordinates with::" msgstr "" -#: ../../library/turtle.rst:143 +#: ../../library/turtle.rst:144 msgid "pos()" msgstr "pos()" -#: ../../library/turtle.rst:145 +#: ../../library/turtle.rst:146 msgid "Home is at ``(0, 0)``." msgstr "" -#: ../../library/turtle.rst:147 +#: ../../library/turtle.rst:148 msgid "" "And after a while, it will probably help to clear the window so we can start " "anew::" msgstr "" -#: ../../library/turtle.rst:150 +#: ../../library/turtle.rst:151 msgid "clearscreen()" msgstr "clearscreen()" -#: ../../library/turtle.rst:154 +#: ../../library/turtle.rst:155 msgid "Making algorithmic patterns" msgstr "" -#: ../../library/turtle.rst:156 +#: ../../library/turtle.rst:157 msgid "Using loops, it's possible to build up geometric patterns::" msgstr "" -#: ../../library/turtle.rst:158 +#: ../../library/turtle.rst:159 msgid "" "for steps in range(100):\n" " for c in ('blue', 'red', 'green'):\n" @@ -256,17 +257,17 @@ msgstr "" " forward(steps)\n" " right(30)" -#: ../../library/turtle.rst:165 +#: ../../library/turtle.rst:166 msgid "\\ - which of course, are limited only by the imagination!" msgstr "" -#: ../../library/turtle.rst:167 +#: ../../library/turtle.rst:168 msgid "" "Let's draw the star shape at the top of this page. We want red lines, filled " "in with yellow::" msgstr "" -#: ../../library/turtle.rst:170 +#: ../../library/turtle.rst:171 msgid "" "color('red')\n" "fillcolor('yellow')" @@ -274,21 +275,21 @@ msgstr "" "color('red')\n" "fillcolor('yellow')" -#: ../../library/turtle.rst:173 +#: ../../library/turtle.rst:174 msgid "" "Just as ``up()`` and ``down()`` determine whether lines will be drawn, " "filling can be turned on and off::" msgstr "" -#: ../../library/turtle.rst:176 +#: ../../library/turtle.rst:177 msgid "begin_fill()" msgstr "begin_fill()" -#: ../../library/turtle.rst:178 +#: ../../library/turtle.rst:179 msgid "Next we'll create a loop::" msgstr "" -#: ../../library/turtle.rst:180 +#: ../../library/turtle.rst:181 msgid "" "start = pos()\n" "\n" @@ -306,41 +307,41 @@ msgstr "" " if distance(start) < 1:\n" " break" -#: ../../library/turtle.rst:188 +#: ../../library/turtle.rst:189 msgid "" "``distance(start) < 1`` is a good way to know when the turtle is back at its " "start position." msgstr "" -#: ../../library/turtle.rst:191 +#: ../../library/turtle.rst:192 msgid "Finally, complete the filling::" msgstr "" -#: ../../library/turtle.rst:193 +#: ../../library/turtle.rst:194 msgid "end_fill()" msgstr "end_fill()" -#: ../../library/turtle.rst:195 +#: ../../library/turtle.rst:196 msgid "" "(Note that filling only actually takes place when you give the " "``end_fill()`` command.)" msgstr "" -#: ../../library/turtle.rst:203 +#: ../../library/turtle.rst:204 msgid "Reference" msgstr "" -#: ../../library/turtle.rst:209 +#: ../../library/turtle.rst:210 msgid "Turtle methods and functions" msgstr "" -#: ../../library/turtle.rst:211 +#: ../../library/turtle.rst:212 msgid "" "Most of the examples in this section refer to a Turtle instance called " "``turtle``." msgstr "" -#: ../../library/turtle.rst:217 +#: ../../library/turtle.rst:218 msgid "Move and draw" msgstr "" @@ -348,23 +349,23 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../library/turtle.rst:222 ../../library/turtle.rst:244 -#: ../../library/turtle.rst:268 ../../library/turtle.rst:294 -#: ../../library/turtle.rst:392 ../../library/turtle.rst:414 -#: ../../library/turtle.rst:437 ../../library/turtle.rst:488 -#: ../../library/turtle.rst:763 ../../library/turtle.rst:1297 -#: ../../library/turtle.rst:1744 ../../library/turtle.rst:1745 -#: ../../library/turtle.rst:1746 ../../library/turtle.rst:1747 +#: ../../library/turtle.rst:223 ../../library/turtle.rst:245 +#: ../../library/turtle.rst:269 ../../library/turtle.rst:295 +#: ../../library/turtle.rst:393 ../../library/turtle.rst:415 +#: ../../library/turtle.rst:438 ../../library/turtle.rst:489 +#: ../../library/turtle.rst:764 ../../library/turtle.rst:1298 +#: ../../library/turtle.rst:1745 ../../library/turtle.rst:1746 +#: ../../library/turtle.rst:1747 ../../library/turtle.rst:1748 msgid "a number" msgstr "" -#: ../../library/turtle.rst:224 +#: ../../library/turtle.rst:225 msgid "" "Move the turtle forward by the specified *distance*, in the direction the " "turtle is headed." msgstr "" -#: ../../library/turtle.rst:227 +#: ../../library/turtle.rst:228 msgid "" ">>> turtle.position()\n" "(0.00,0.00)\n" @@ -384,13 +385,13 @@ msgstr "" ">>> turtle.position()\n" "(-50.00,0.00)" -#: ../../library/turtle.rst:246 +#: ../../library/turtle.rst:247 msgid "" "Move the turtle backward by *distance*, opposite to the direction the turtle " "is headed. The turtle's heading does not change." msgstr "" -#: ../../library/turtle.rst:255 +#: ../../library/turtle.rst:256 msgid "" ">>> turtle.position()\n" "(0.00,0.00)\n" @@ -404,7 +405,7 @@ msgstr "" ">>> turtle.position()\n" "(-30.00,0.00)" -#: ../../library/turtle.rst:270 +#: ../../library/turtle.rst:271 msgid "" "Turn the turtle right by the specified *angle*. The angle is measured in " "degrees by default; the unit can be changed with :func:`degrees` or :func:" @@ -412,7 +413,7 @@ msgid "" "`mode`." msgstr "" -#: ../../library/turtle.rst:281 +#: ../../library/turtle.rst:282 msgid "" ">>> turtle.heading()\n" "22.0\n" @@ -426,7 +427,7 @@ msgstr "" ">>> turtle.heading()\n" "337.0" -#: ../../library/turtle.rst:296 +#: ../../library/turtle.rst:297 msgid "" "Turn the turtle left by the specified *angle*. The angle is measured in " "degrees by default; the unit can be changed with :func:`degrees` or :func:" @@ -434,7 +435,7 @@ msgid "" "`mode`." msgstr "" -#: ../../library/turtle.rst:307 +#: ../../library/turtle.rst:308 msgid "" ">>> turtle.heading()\n" "22.0\n" @@ -448,18 +449,18 @@ msgstr "" ">>> turtle.heading()\n" "67.0" -#: ../../library/turtle.rst:321 +#: ../../library/turtle.rst:322 msgid "a number or a pair/vector of numbers" msgstr "" -#: ../../library/turtle.rst:322 ../../library/turtle.rst:354 -#: ../../library/turtle.rst:355 ../../library/turtle.rst:489 -#: ../../library/turtle.rst:1972 ../../library/turtle.rst:1973 -#: ../../library/turtle.rst:1974 ../../library/turtle.rst:2020 +#: ../../library/turtle.rst:323 ../../library/turtle.rst:355 +#: ../../library/turtle.rst:356 ../../library/turtle.rst:490 +#: ../../library/turtle.rst:1973 ../../library/turtle.rst:1974 +#: ../../library/turtle.rst:1975 ../../library/turtle.rst:2021 msgid "a number or ``None``" msgstr "" -#: ../../library/turtle.rst:324 +#: ../../library/turtle.rst:325 msgid "" "Move the turtle to an absolute position. If *y* is ``None``, *x* must be a " "pair of coordinates or a :class:`Vec2D`, for example as returned by :func:" @@ -467,7 +468,7 @@ msgid "" "change." msgstr "" -#: ../../library/turtle.rst:335 +#: ../../library/turtle.rst:336 msgid "" ">>> tp = turtle.pos()\n" ">>> tp\n" @@ -495,11 +496,11 @@ msgstr "" ">>> turtle.pos()\n" "(0.00,0.00)" -#: ../../library/turtle.rst:356 +#: ../../library/turtle.rst:357 msgid "a boolean" msgstr "" -#: ../../library/turtle.rst:358 +#: ../../library/turtle.rst:359 msgid "" "Move turtle to an absolute position. Unlike goto(x, y), a line will not be " "drawn. The turtle's orientation does not change. If currently filling, the " @@ -509,7 +510,7 @@ msgid "" "barrier like in goto(x, y)." msgstr "" -#: ../../library/turtle.rst:371 +#: ../../library/turtle.rst:372 msgid "" ">>> tp = turtle.pos()\n" ">>> tp\n" @@ -537,11 +538,11 @@ msgstr "" ">>> turtle.pos()\n" "(20.00,30.00)" -#: ../../library/turtle.rst:394 +#: ../../library/turtle.rst:395 msgid "Set the turtle's x coordinate to *x*. The y coordinate is unchanged." msgstr "" -#: ../../library/turtle.rst:402 +#: ../../library/turtle.rst:403 msgid "" ">>> turtle.position()\n" "(0.00,240.00)\n" @@ -555,11 +556,11 @@ msgstr "" ">>> turtle.position()\n" "(10.00,240.00)" -#: ../../library/turtle.rst:416 +#: ../../library/turtle.rst:417 msgid "Set the turtle's y coordinate to *y*. The x coordinate is unchanged." msgstr "" -#: ../../library/turtle.rst:424 +#: ../../library/turtle.rst:425 msgid "" ">>> turtle.position()\n" "(0.00,40.00)\n" @@ -573,53 +574,53 @@ msgstr "" ">>> turtle.position()\n" "(0.00,-10.00)" -#: ../../library/turtle.rst:439 +#: ../../library/turtle.rst:440 msgid "" "Set the turtle's heading to *to_angle*. Here are some common directions in " "degrees:" msgstr "" -#: ../../library/turtle.rst:443 +#: ../../library/turtle.rst:444 msgid "standard mode" msgstr "" -#: ../../library/turtle.rst:443 +#: ../../library/turtle.rst:444 msgid "logo mode" msgstr "" -#: ../../library/turtle.rst:445 +#: ../../library/turtle.rst:446 msgid "0 - east" msgstr "" -#: ../../library/turtle.rst:445 +#: ../../library/turtle.rst:446 msgid "0 - north" msgstr "" -#: ../../library/turtle.rst:446 +#: ../../library/turtle.rst:447 msgid "90 - north" msgstr "" -#: ../../library/turtle.rst:446 +#: ../../library/turtle.rst:447 msgid "90 - east" msgstr "" -#: ../../library/turtle.rst:447 +#: ../../library/turtle.rst:448 msgid "180 - west" msgstr "" -#: ../../library/turtle.rst:447 +#: ../../library/turtle.rst:448 msgid "180 - south" msgstr "" -#: ../../library/turtle.rst:448 +#: ../../library/turtle.rst:449 msgid "270 - south" msgstr "" -#: ../../library/turtle.rst:448 +#: ../../library/turtle.rst:449 msgid "270 - west" msgstr "" -#: ../../library/turtle.rst:451 +#: ../../library/turtle.rst:452 msgid "" ">>> turtle.setheading(90)\n" ">>> turtle.heading()\n" @@ -629,14 +630,14 @@ msgstr "" ">>> turtle.heading()\n" "90.0" -#: ../../library/turtle.rst:461 +#: ../../library/turtle.rst:462 msgid "" "Move the turtle to the origin, coordinates (0,0). The turtle's heading is " "set to its start orientation, which depends on the turtle mode, see :func:" "`mode`." msgstr "" -#: ../../library/turtle.rst:472 +#: ../../library/turtle.rst:473 msgid "" ">>> turtle.heading()\n" "90.0\n" @@ -658,11 +659,11 @@ msgstr "" ">>> turtle.heading()\n" "0.0" -#: ../../library/turtle.rst:490 ../../library/turtle.rst:1549 +#: ../../library/turtle.rst:491 ../../library/turtle.rst:1550 msgid "an integer or ``None``" msgstr "一個整數或 ``None``" -#: ../../library/turtle.rst:492 +#: ../../library/turtle.rst:493 msgid "" "Draw a circle with the given *radius*. The center is *radius* units left of " "the turtle; *extent*, an angle, determines which part of the circle is " @@ -672,14 +673,14 @@ msgid "" "clockwise direction. Finally, the turtle's heading is changed by *extent*." msgstr "" -#: ../../library/turtle.rst:500 +#: ../../library/turtle.rst:501 msgid "" "As the circle is approximated by an inscribed regular polygon, *steps* " "determines the number of steps to use. If not given, it will be calculated " "automatically. May be used to draw regular polygons." msgstr "" -#: ../../library/turtle.rst:504 +#: ../../library/turtle.rst:505 msgid "" ">>> turtle.home()\n" ">>> turtle.position()\n" @@ -698,21 +699,21 @@ msgid "" "180.0" msgstr "" -#: ../../library/turtle.rst:530 +#: ../../library/turtle.rst:531 msgid "an integer >= 1 (if given)" msgstr "" -#: ../../library/turtle.rst:531 +#: ../../library/turtle.rst:532 msgid "a colorstring or a numeric color tuple" msgstr "" -#: ../../library/turtle.rst:533 +#: ../../library/turtle.rst:534 msgid "" "Draw a circular dot with diameter *size*, using *color*. If *size* is not " "given, the maximum of ``pensize+4`` and ``2*pensize`` is used." msgstr "" -#: ../../library/turtle.rst:537 +#: ../../library/turtle.rst:538 msgid "" ">>> turtle.home()\n" ">>> turtle.dot()\n" @@ -730,14 +731,14 @@ msgstr "" ">>> turtle.heading()\n" "0.0" -#: ../../library/turtle.rst:551 +#: ../../library/turtle.rst:552 msgid "" "Stamp a copy of the turtle shape onto the canvas at the current turtle " "position. Return a stamp_id for that stamp, which can be used to delete it " "by calling ``clearstamp(stamp_id)``." msgstr "" -#: ../../library/turtle.rst:555 +#: ../../library/turtle.rst:556 msgid "" ">>> turtle.color(\"blue\")\n" ">>> stamp_id = turtle.stamp()\n" @@ -747,15 +748,15 @@ msgstr "" ">>> stamp_id = turtle.stamp()\n" ">>> turtle.fd(50)" -#: ../../library/turtle.rst:565 +#: ../../library/turtle.rst:566 msgid "an integer, must be return value of previous :func:`stamp` call" msgstr "" -#: ../../library/turtle.rst:568 +#: ../../library/turtle.rst:569 msgid "Delete stamp with given *stampid*." msgstr "" -#: ../../library/turtle.rst:570 +#: ../../library/turtle.rst:571 msgid "" ">>> turtle.position()\n" "(150.00,-0.00)\n" @@ -779,18 +780,18 @@ msgstr "" ">>> turtle.position()\n" "(200.00,-0.00)" -#: ../../library/turtle.rst:587 +#: ../../library/turtle.rst:588 msgid "an integer (or ``None``)" msgstr "" -#: ../../library/turtle.rst:589 +#: ../../library/turtle.rst:590 msgid "" "Delete all or first/last *n* of turtle's stamps. If *n* is ``None``, delete " "all stamps, if *n* > 0 delete first *n* stamps, else if *n* < 0 delete last " "*n* stamps." msgstr "" -#: ../../library/turtle.rst:593 +#: ../../library/turtle.rst:594 msgid "" ">>> for i in range(8):\n" "... unused_stamp_id = turtle.stamp()\n" @@ -806,13 +807,13 @@ msgstr "" ">>> turtle.clearstamps(-2)\n" ">>> turtle.clearstamps()" -#: ../../library/turtle.rst:606 +#: ../../library/turtle.rst:607 msgid "" "Undo (repeatedly) the last turtle action(s). Number of available undo " "actions is determined by the size of the undobuffer." msgstr "" -#: ../../library/turtle.rst:609 +#: ../../library/turtle.rst:610 msgid "" ">>> for i in range(4):\n" "... turtle.fd(50); turtle.lt(80)\n" @@ -826,55 +827,55 @@ msgstr "" ">>> for i in range(8):\n" "... turtle.undo()" -#: ../../library/turtle.rst:621 +#: ../../library/turtle.rst:622 msgid "an integer in the range 0..10 or a speedstring (see below)" msgstr "" -#: ../../library/turtle.rst:623 +#: ../../library/turtle.rst:624 msgid "" "Set the turtle's speed to an integer value in the range 0..10. If no " "argument is given, return current speed." msgstr "" -#: ../../library/turtle.rst:626 +#: ../../library/turtle.rst:627 msgid "" "If input is a number greater than 10 or smaller than 0.5, speed is set to " "0. Speedstrings are mapped to speedvalues as follows:" msgstr "" -#: ../../library/turtle.rst:629 +#: ../../library/turtle.rst:630 msgid "\"fastest\": 0" msgstr "" -#: ../../library/turtle.rst:630 +#: ../../library/turtle.rst:631 msgid "\"fast\": 10" msgstr "" -#: ../../library/turtle.rst:631 +#: ../../library/turtle.rst:632 msgid "\"normal\": 6" msgstr "" -#: ../../library/turtle.rst:632 +#: ../../library/turtle.rst:633 msgid "\"slow\": 3" msgstr "" -#: ../../library/turtle.rst:633 +#: ../../library/turtle.rst:634 msgid "\"slowest\": 1" msgstr "" -#: ../../library/turtle.rst:635 +#: ../../library/turtle.rst:636 msgid "" "Speeds from 1 to 10 enforce increasingly faster animation of line drawing " "and turtle turning." msgstr "" -#: ../../library/turtle.rst:638 +#: ../../library/turtle.rst:639 msgid "" "Attention: *speed* = 0 means that *no* animation takes place. forward/back " "makes turtle jump and likewise left/right make the turtle turn instantly." msgstr "" -#: ../../library/turtle.rst:642 +#: ../../library/turtle.rst:643 msgid "" ">>> turtle.speed()\n" "3\n" @@ -894,15 +895,15 @@ msgstr "" ">>> turtle.speed()\n" "9" -#: ../../library/turtle.rst:656 +#: ../../library/turtle.rst:657 msgid "Tell Turtle's state" msgstr "" -#: ../../library/turtle.rst:661 +#: ../../library/turtle.rst:662 msgid "Return the turtle's current location (x,y) as a :class:`Vec2D` vector." msgstr "" -#: ../../library/turtle.rst:663 +#: ../../library/turtle.rst:664 msgid "" ">>> turtle.pos()\n" "(440.00,-0.00)" @@ -910,15 +911,15 @@ msgstr "" ">>> turtle.pos()\n" "(440.00,-0.00)" -#: ../../library/turtle.rst:672 ../../library/turtle.rst:737 +#: ../../library/turtle.rst:673 ../../library/turtle.rst:738 msgid "a number or a pair/vector of numbers or a turtle instance" msgstr "" -#: ../../library/turtle.rst:673 ../../library/turtle.rst:738 +#: ../../library/turtle.rst:674 ../../library/turtle.rst:739 msgid "a number if *x* is a number, else ``None``" msgstr "" -#: ../../library/turtle.rst:675 +#: ../../library/turtle.rst:676 msgid "" "Return the angle of the line from the turtle's position to (x,y). If *y* is " "``None``, *x* must be a pair of coordinates, a :class:`Vec2D`, for example " @@ -927,7 +928,7 @@ msgid "" "`mode`." msgstr "" -#: ../../library/turtle.rst:681 +#: ../../library/turtle.rst:682 msgid "" ">>> turtle.goto(10, 10)\n" ">>> turtle.towards(0,0)\n" @@ -937,11 +938,11 @@ msgstr "" ">>> turtle.towards(0,0)\n" "225.0" -#: ../../library/turtle.rst:691 +#: ../../library/turtle.rst:692 msgid "Return the turtle's x coordinate." msgstr "" -#: ../../library/turtle.rst:693 +#: ../../library/turtle.rst:694 msgid "" ">>> turtle.home()\n" ">>> turtle.left(50)\n" @@ -959,11 +960,11 @@ msgstr "" ">>> print(round(turtle.xcor(), 5))\n" "64.27876" -#: ../../library/turtle.rst:707 +#: ../../library/turtle.rst:708 msgid "Return the turtle's y coordinate." msgstr "" -#: ../../library/turtle.rst:709 +#: ../../library/turtle.rst:710 msgid "" ">>> turtle.home()\n" ">>> turtle.left(60)\n" @@ -981,13 +982,13 @@ msgstr "" ">>> print(round(turtle.ycor(), 5))\n" "86.60254" -#: ../../library/turtle.rst:723 +#: ../../library/turtle.rst:724 msgid "" "Return the turtle's current heading. The value depends on the turtle mode, " "see :func:`mode`." msgstr "" -#: ../../library/turtle.rst:726 +#: ../../library/turtle.rst:727 msgid "" ">>> turtle.home()\n" ">>> turtle.left(67)\n" @@ -999,14 +1000,14 @@ msgstr "" ">>> turtle.heading()\n" "67.0" -#: ../../library/turtle.rst:740 +#: ../../library/turtle.rst:741 msgid "" "Return the distance from the turtle to (x,y) in turtle step units. If *y* is " "``None``, *x* must be a pair of coordinates, a :class:`Vec2D`, for example " "as returned by :func:`pos`, or another turtle." msgstr "" -#: ../../library/turtle.rst:744 +#: ../../library/turtle.rst:745 msgid "" ">>> turtle.home()\n" ">>> turtle.distance(30,40)\n" @@ -1028,17 +1029,17 @@ msgstr "" ">>> turtle.distance(joe)\n" "77.0" -#: ../../library/turtle.rst:759 +#: ../../library/turtle.rst:760 msgid "Settings for measurement" msgstr "" -#: ../../library/turtle.rst:765 +#: ../../library/turtle.rst:766 msgid "" "Set the angle measurement units to degrees. The number of degrees in a full " "circle is set to *fullcircle*, which defaults to 360." msgstr "" -#: ../../library/turtle.rst:768 +#: ../../library/turtle.rst:769 msgid "" ">>> turtle.home()\n" ">>> turtle.left(90)\n" @@ -1055,13 +1056,13 @@ msgid "" "90.0" msgstr "" -#: ../../library/turtle.rst:788 +#: ../../library/turtle.rst:789 msgid "" "Set the angle measurement units to radians. Equivalent to ``degrees(2 * " "math.pi)``." msgstr "" -#: ../../library/turtle.rst:791 +#: ../../library/turtle.rst:792 msgid "" ">>> turtle.home()\n" ">>> turtle.left(90)\n" @@ -1079,91 +1080,91 @@ msgstr "" ">>> turtle.heading()\n" "1.5707963267948966" -#: ../../library/turtle.rst:813 +#: ../../library/turtle.rst:814 msgid "Drawing state" msgstr "" -#: ../../library/turtle.rst:819 +#: ../../library/turtle.rst:820 msgid "Pull the pen down -- drawing when moving." msgstr "" -#: ../../library/turtle.rst:826 +#: ../../library/turtle.rst:827 msgid "Pull the pen up -- no drawing when moving." msgstr "" -#: ../../library/turtle.rst:832 +#: ../../library/turtle.rst:833 msgid "a positive number" msgstr "" -#: ../../library/turtle.rst:834 +#: ../../library/turtle.rst:835 msgid "" "Set the line thickness to *width* or return it. If resizemode is set to " "\"auto\" and turtleshape is a polygon, that polygon is drawn with the same " "line thickness. If no argument is given, the current pensize is returned." msgstr "" -#: ../../library/turtle.rst:838 +#: ../../library/turtle.rst:839 msgid "" ">>> turtle.pensize()\n" "1\n" ">>> turtle.pensize(10) # from here on lines of width 10 are drawn" msgstr "" -#: ../../library/turtle.rst:848 +#: ../../library/turtle.rst:849 msgid "a dictionary with some or all of the below listed keys" msgstr "" -#: ../../library/turtle.rst:849 +#: ../../library/turtle.rst:850 msgid "one or more keyword-arguments with the below listed keys as keywords" msgstr "" -#: ../../library/turtle.rst:851 +#: ../../library/turtle.rst:852 msgid "" "Return or set the pen's attributes in a \"pen-dictionary\" with the " "following key/value pairs:" msgstr "" -#: ../../library/turtle.rst:854 +#: ../../library/turtle.rst:855 msgid "\"shown\": True/False" msgstr "" -#: ../../library/turtle.rst:855 +#: ../../library/turtle.rst:856 msgid "\"pendown\": True/False" msgstr "" -#: ../../library/turtle.rst:856 +#: ../../library/turtle.rst:857 msgid "\"pencolor\": color-string or color-tuple" msgstr "" -#: ../../library/turtle.rst:857 +#: ../../library/turtle.rst:858 msgid "\"fillcolor\": color-string or color-tuple" msgstr "" -#: ../../library/turtle.rst:858 +#: ../../library/turtle.rst:859 msgid "\"pensize\": positive number" msgstr "" -#: ../../library/turtle.rst:859 +#: ../../library/turtle.rst:860 msgid "\"speed\": number in range 0..10" msgstr "" -#: ../../library/turtle.rst:860 +#: ../../library/turtle.rst:861 msgid "\"resizemode\": \"auto\" or \"user\" or \"noresize\"" msgstr "" -#: ../../library/turtle.rst:861 +#: ../../library/turtle.rst:862 msgid "\"stretchfactor\": (positive number, positive number)" msgstr "" -#: ../../library/turtle.rst:862 +#: ../../library/turtle.rst:863 msgid "\"outline\": positive number" msgstr "" -#: ../../library/turtle.rst:863 +#: ../../library/turtle.rst:864 msgid "\"tilt\": number" msgstr "" -#: ../../library/turtle.rst:865 +#: ../../library/turtle.rst:866 msgid "" "This dictionary can be used as argument for a subsequent call to :func:`pen` " "to restore the former pen-state. Moreover one or more of these attributes " @@ -1171,7 +1172,7 @@ msgid "" "attributes in one statement." msgstr "" -#: ../../library/turtle.rst:870 +#: ../../library/turtle.rst:871 msgid "" ">>> turtle.pen(fillcolor=\"black\", pencolor=\"red\", pensize=10)\n" ">>> sorted(turtle.pen().items())\n" @@ -1203,11 +1204,11 @@ msgstr "" ">>> sorted(turtle.pen().items())[:3]\n" "[('fillcolor', 'green'), ('outline', 1), ('pencolor', 'red')]" -#: ../../library/turtle.rst:891 +#: ../../library/turtle.rst:892 msgid "Return ``True`` if pen is down, ``False`` if it's up." msgstr "" -#: ../../library/turtle.rst:893 +#: ../../library/turtle.rst:894 msgid "" ">>> turtle.penup()\n" ">>> turtle.isdown()\n" @@ -1223,68 +1224,68 @@ msgstr "" ">>> turtle.isdown()\n" "True" -#: ../../library/turtle.rst:905 +#: ../../library/turtle.rst:906 msgid "Color control" msgstr "" -#: ../../library/turtle.rst:911 +#: ../../library/turtle.rst:912 msgid "Return or set the pencolor." msgstr "" -#: ../../library/turtle.rst:913 ../../library/turtle.rst:965 -#: ../../library/turtle.rst:1638 +#: ../../library/turtle.rst:914 ../../library/turtle.rst:966 +#: ../../library/turtle.rst:1639 msgid "Four input formats are allowed:" msgstr "" -#: ../../library/turtle.rst:915 +#: ../../library/turtle.rst:916 msgid "``pencolor()``" msgstr "``pencolor()``" -#: ../../library/turtle.rst:916 +#: ../../library/turtle.rst:917 msgid "" "Return the current pencolor as color specification string or as a tuple (see " "example). May be used as input to another :func:`color`, :func:`pencolor`, :" "func:`fillcolor` or :func:`bgcolor` call." msgstr "" -#: ../../library/turtle.rst:921 +#: ../../library/turtle.rst:922 msgid "``pencolor(colorstring)``" msgstr "``pencolor(colorstring)``" -#: ../../library/turtle.rst:922 +#: ../../library/turtle.rst:923 msgid "" "Set pencolor to *colorstring*, which is a Tk color specification string, " "such as ``\"red\"``, ``\"yellow\"``, or ``\"#33cc8c\"``." msgstr "" -#: ../../library/turtle.rst:925 +#: ../../library/turtle.rst:926 msgid "``pencolor((r, g, b))``" msgstr "``pencolor((r, g, b))``" -#: ../../library/turtle.rst:926 +#: ../../library/turtle.rst:927 msgid "" "Set pencolor to the RGB color represented by the tuple of *r*, *g*, and " "*b*. Each of *r*, *g*, and *b* must be in the range 0..colormode, where " "colormode is either 1.0 or 255 (see :func:`colormode`)." msgstr "" -#: ../../library/turtle.rst:930 +#: ../../library/turtle.rst:931 msgid "``pencolor(r, g, b)``" msgstr "``pencolor(r, g, b)``" -#: ../../library/turtle.rst:931 +#: ../../library/turtle.rst:932 msgid "" "Set pencolor to the RGB color represented by *r*, *g*, and *b*. Each of " "*r*, *g*, and *b* must be in the range 0..colormode." msgstr "" -#: ../../library/turtle.rst:934 +#: ../../library/turtle.rst:935 msgid "" "If turtleshape is a polygon, the outline of that polygon is drawn with the " "newly set pencolor." msgstr "" -#: ../../library/turtle.rst:937 +#: ../../library/turtle.rst:938 msgid "" ">>> colormode()\n" "1.0\n" @@ -1322,59 +1323,59 @@ msgstr "" ">>> turtle.pencolor()\n" "(50.0, 193.0, 143.0)" -#: ../../library/turtle.rst:963 +#: ../../library/turtle.rst:964 msgid "Return or set the fillcolor." msgstr "" -#: ../../library/turtle.rst:967 +#: ../../library/turtle.rst:968 msgid "``fillcolor()``" msgstr "``fillcolor()``" -#: ../../library/turtle.rst:968 +#: ../../library/turtle.rst:969 msgid "" "Return the current fillcolor as color specification string, possibly in " "tuple format (see example). May be used as input to another :func:`color`, :" "func:`pencolor`, :func:`fillcolor` or :func:`bgcolor` call." msgstr "" -#: ../../library/turtle.rst:973 +#: ../../library/turtle.rst:974 msgid "``fillcolor(colorstring)``" msgstr "``fillcolor(colorstring)``" -#: ../../library/turtle.rst:974 +#: ../../library/turtle.rst:975 msgid "" "Set fillcolor to *colorstring*, which is a Tk color specification string, " "such as ``\"red\"``, ``\"yellow\"``, or ``\"#33cc8c\"``." msgstr "" -#: ../../library/turtle.rst:977 +#: ../../library/turtle.rst:978 msgid "``fillcolor((r, g, b))``" msgstr "``fillcolor((r, g, b))``" -#: ../../library/turtle.rst:978 +#: ../../library/turtle.rst:979 msgid "" "Set fillcolor to the RGB color represented by the tuple of *r*, *g*, and " "*b*. Each of *r*, *g*, and *b* must be in the range 0..colormode, where " "colormode is either 1.0 or 255 (see :func:`colormode`)." msgstr "" -#: ../../library/turtle.rst:982 +#: ../../library/turtle.rst:983 msgid "``fillcolor(r, g, b)``" msgstr "``fillcolor(r, g, b)``" -#: ../../library/turtle.rst:983 +#: ../../library/turtle.rst:984 msgid "" "Set fillcolor to the RGB color represented by *r*, *g*, and *b*. Each of " "*r*, *g*, and *b* must be in the range 0..colormode." msgstr "" -#: ../../library/turtle.rst:986 +#: ../../library/turtle.rst:987 msgid "" "If turtleshape is a polygon, the interior of that polygon is drawn with the " "newly set fillcolor." msgstr "" -#: ../../library/turtle.rst:989 +#: ../../library/turtle.rst:990 msgid "" ">>> turtle.fillcolor(\"violet\")\n" ">>> turtle.fillcolor()\n" @@ -1400,55 +1401,55 @@ msgstr "" ">>> turtle.fillcolor()\n" "(255.0, 255.0, 255.0)" -#: ../../library/turtle.rst:1010 +#: ../../library/turtle.rst:1011 msgid "Return or set pencolor and fillcolor." msgstr "" -#: ../../library/turtle.rst:1012 +#: ../../library/turtle.rst:1013 msgid "" "Several input formats are allowed. They use 0 to 3 arguments as follows:" msgstr "" -#: ../../library/turtle.rst:1015 +#: ../../library/turtle.rst:1016 msgid "``color()``" msgstr "``color()``" -#: ../../library/turtle.rst:1016 +#: ../../library/turtle.rst:1017 msgid "" "Return the current pencolor and the current fillcolor as a pair of color " "specification strings or tuples as returned by :func:`pencolor` and :func:" "`fillcolor`." msgstr "" -#: ../../library/turtle.rst:1020 +#: ../../library/turtle.rst:1021 msgid "``color(colorstring)``, ``color((r,g,b))``, ``color(r,g,b)``" msgstr "``color(colorstring)``, ``color((r,g,b))``, ``color(r,g,b)``" -#: ../../library/turtle.rst:1021 +#: ../../library/turtle.rst:1022 msgid "" "Inputs as in :func:`pencolor`, set both, fillcolor and pencolor, to the " "given value." msgstr "" -#: ../../library/turtle.rst:1024 +#: ../../library/turtle.rst:1025 msgid "" "``color(colorstring1, colorstring2)``, ``color((r1,g1,b1), (r2,g2,b2))``" msgstr "" "``color(colorstring1, colorstring2)``, ``color((r1,g1,b1), (r2,g2,b2))``" -#: ../../library/turtle.rst:1025 +#: ../../library/turtle.rst:1026 msgid "" "Equivalent to ``pencolor(colorstring1)`` and ``fillcolor(colorstring2)`` and " "analogously if the other input format is used." msgstr "" -#: ../../library/turtle.rst:1028 +#: ../../library/turtle.rst:1029 msgid "" "If turtleshape is a polygon, outline and interior of that polygon is drawn " "with the newly set colors." msgstr "" -#: ../../library/turtle.rst:1031 +#: ../../library/turtle.rst:1032 msgid "" ">>> turtle.color(\"red\", \"green\")\n" ">>> turtle.color()\n" @@ -1464,19 +1465,19 @@ msgstr "" ">>> color()\n" "((40.0, 80.0, 120.0), (160.0, 200.0, 240.0))" -#: ../../library/turtle.rst:1042 +#: ../../library/turtle.rst:1043 msgid "See also: Screen method :func:`colormode`." msgstr "" -#: ../../library/turtle.rst:1046 +#: ../../library/turtle.rst:1047 msgid "Filling" msgstr "" -#: ../../library/turtle.rst:1056 +#: ../../library/turtle.rst:1057 msgid "Return fillstate (``True`` if filling, ``False`` else)." msgstr "" -#: ../../library/turtle.rst:1058 +#: ../../library/turtle.rst:1059 msgid "" ">>> turtle.begin_fill()\n" ">>> if turtle.filling():\n" @@ -1490,11 +1491,11 @@ msgstr "" "... else:\n" "... turtle.pensize(3)" -#: ../../library/turtle.rst:1069 +#: ../../library/turtle.rst:1070 msgid "Fill the shape drawn in the ``with turtle.fill():`` block." msgstr "" -#: ../../library/turtle.rst:1071 +#: ../../library/turtle.rst:1072 msgid "" ">>> turtle.color(\"black\", \"red\")\n" ">>> with turtle.fill():\n" @@ -1504,13 +1505,13 @@ msgstr "" ">>> with turtle.fill():\n" "... turtle.circle(80)" -#: ../../library/turtle.rst:1078 +#: ../../library/turtle.rst:1079 msgid "" "Using :func:`!fill` is equivalent to adding the :func:`begin_fill` before " "the fill-block and :func:`end_fill` after the fill-block:" msgstr "" -#: ../../library/turtle.rst:1081 ../../library/turtle.rst:1106 +#: ../../library/turtle.rst:1082 ../../library/turtle.rst:1107 msgid "" ">>> turtle.color(\"black\", \"red\")\n" ">>> turtle.begin_fill()\n" @@ -1522,15 +1523,15 @@ msgstr "" ">>> turtle.circle(80)\n" ">>> turtle.end_fill()" -#: ../../library/turtle.rst:1094 +#: ../../library/turtle.rst:1095 msgid "To be called just before drawing a shape to be filled." msgstr "" -#: ../../library/turtle.rst:1099 +#: ../../library/turtle.rst:1100 msgid "Fill the shape drawn after the last call to :func:`begin_fill`." msgstr "" -#: ../../library/turtle.rst:1101 +#: ../../library/turtle.rst:1102 msgid "" "Whether or not overlap regions for self-intersecting polygons or multiple " "shapes are filled depends on the operating system graphics, type of overlap, " @@ -1538,17 +1539,17 @@ msgid "" "all yellow or have some white regions." msgstr "" -#: ../../library/turtle.rst:1116 +#: ../../library/turtle.rst:1117 msgid "More drawing control" msgstr "" -#: ../../library/turtle.rst:1120 +#: ../../library/turtle.rst:1121 msgid "" "Delete the turtle's drawings and re-center the turtle. The turtle's settings " "are restored to their default values." msgstr "" -#: ../../library/turtle.rst:1123 +#: ../../library/turtle.rst:1124 msgid "" ">>> turtle.goto(0,-22)\n" ">>> turtle.left(100)\n" @@ -1574,29 +1575,29 @@ msgstr "" ">>> turtle.heading()\n" "0.0" -#: ../../library/turtle.rst:1141 +#: ../../library/turtle.rst:1142 msgid "" "Delete the turtle's drawings from the screen. The state and position of the " "turtle as well as the drawings of other turtles are not affected." msgstr "" -#: ../../library/turtle.rst:1147 +#: ../../library/turtle.rst:1148 msgid "object to be written to the TurtleScreen" msgstr "" -#: ../../library/turtle.rst:1148 +#: ../../library/turtle.rst:1149 msgid "True/False" msgstr "True/False" -#: ../../library/turtle.rst:1149 +#: ../../library/turtle.rst:1150 msgid "one of the strings \"left\", \"center\" or right\"" msgstr "" -#: ../../library/turtle.rst:1150 +#: ../../library/turtle.rst:1151 msgid "a triple (fontname, fontsize, fonttype)" msgstr "" -#: ../../library/turtle.rst:1152 +#: ../../library/turtle.rst:1153 msgid "" "Write text - the string representation of *arg* - at the current turtle " "position according to *align* (\"left\", \"center\" or \"right\") and with " @@ -1604,33 +1605,33 @@ msgid "" "corner of the text. By default, *move* is ``False``." msgstr "" -#: ../../library/turtle.rst:1157 +#: ../../library/turtle.rst:1158 msgid "" ">>> turtle.write(\"Home = \", True, align=\"center\")\n" ">>> turtle.write((0,0), True)" msgstr "" -#: ../../library/turtle.rst:1165 +#: ../../library/turtle.rst:1166 msgid "Turtle state" msgstr "" -#: ../../library/turtle.rst:1168 +#: ../../library/turtle.rst:1169 msgid "Visibility" msgstr "" -#: ../../library/turtle.rst:1173 +#: ../../library/turtle.rst:1174 msgid "Make the turtle invisible. If the pen is down, movement still draws." msgstr "" -#: ../../library/turtle.rst:1179 +#: ../../library/turtle.rst:1180 msgid "Make the turtle visible." msgstr "" -#: ../../library/turtle.rst:1184 +#: ../../library/turtle.rst:1185 msgid "Return ``True`` if the turtle is shown, ``False`` if it's hidden." msgstr "" -#: ../../library/turtle.rst:1186 +#: ../../library/turtle.rst:1187 msgid "" ">>> turtle.hideturtle()\n" ">>> turtle.isvisible()\n" @@ -1646,15 +1647,15 @@ msgstr "" ">>> turtle.isvisible()\n" "True" -#: ../../library/turtle.rst:1198 +#: ../../library/turtle.rst:1199 msgid "Appearance" msgstr "" -#: ../../library/turtle.rst:1202 +#: ../../library/turtle.rst:1203 msgid "a string which is a valid shapename" msgstr "" -#: ../../library/turtle.rst:1204 +#: ../../library/turtle.rst:1205 msgid "" "Set turtle shape to shape with given *name* or, if name is not given, return " "name of current shape. Shape with *name* must exist in the TurtleScreen's " @@ -1664,7 +1665,7 @@ msgid "" "`register_shape`." msgstr "" -#: ../../library/turtle.rst:1210 +#: ../../library/turtle.rst:1211 msgid "" ">>> turtle.shape()\n" "'classic'\n" @@ -1678,40 +1679,40 @@ msgstr "" ">>> turtle.shape()\n" "'turtle'" -#: ../../library/turtle.rst:1222 +#: ../../library/turtle.rst:1223 msgid "one of the strings \"auto\", \"user\", \"noresize\"" msgstr "" -#: ../../library/turtle.rst:1224 +#: ../../library/turtle.rst:1225 msgid "" "Set resizemode to one of the values: \"auto\", \"user\", \"noresize\". If " "*rmode* is not given, return current resizemode. Different resizemodes have " "the following effects:" msgstr "" -#: ../../library/turtle.rst:1228 +#: ../../library/turtle.rst:1229 msgid "" "\"auto\": adapts the appearance of the turtle corresponding to the value of " "pensize." msgstr "" -#: ../../library/turtle.rst:1229 +#: ../../library/turtle.rst:1230 msgid "" "\"user\": adapts the appearance of the turtle according to the values of " "stretchfactor and outlinewidth (outline), which are set by :func:`shapesize`." msgstr "" -#: ../../library/turtle.rst:1232 +#: ../../library/turtle.rst:1233 msgid "\"noresize\": no adaption of the turtle's appearance takes place." msgstr "" -#: ../../library/turtle.rst:1234 +#: ../../library/turtle.rst:1235 msgid "" "``resizemode(\"user\")`` is called by :func:`shapesize` when used with " "arguments." msgstr "" -#: ../../library/turtle.rst:1236 +#: ../../library/turtle.rst:1237 msgid "" ">>> turtle.resizemode()\n" "'noresize'\n" @@ -1725,12 +1726,12 @@ msgstr "" ">>> turtle.resizemode()\n" "'auto'" -#: ../../library/turtle.rst:1249 ../../library/turtle.rst:1250 -#: ../../library/turtle.rst:1251 +#: ../../library/turtle.rst:1250 ../../library/turtle.rst:1251 +#: ../../library/turtle.rst:1252 msgid "positive number" msgstr "" -#: ../../library/turtle.rst:1253 +#: ../../library/turtle.rst:1254 msgid "" "Return or set the pen's attributes x/y-stretchfactors and/or outline. Set " "resizemode to \"user\". If and only if resizemode is set to \"user\", the " @@ -1740,7 +1741,7 @@ msgid "" "determines the width of the shape's outline." msgstr "" -#: ../../library/turtle.rst:1260 +#: ../../library/turtle.rst:1261 msgid "" ">>> turtle.shapesize()\n" "(1.0, 1.0, 1)\n" @@ -1762,11 +1763,11 @@ msgstr "" ">>> turtle.shapesize()\n" "(5, 5, 8)" -#: ../../library/turtle.rst:1276 +#: ../../library/turtle.rst:1277 msgid "number (optional)" msgstr "" -#: ../../library/turtle.rst:1278 +#: ../../library/turtle.rst:1279 msgid "" "Set or return the current shearfactor. Shear the turtleshape according to " "the given shearfactor shear, which is the tangent of the shear angle. Do " @@ -1775,7 +1776,7 @@ msgid "" "by which lines parallel to the heading of the turtle are sheared." msgstr "" -#: ../../library/turtle.rst:1285 +#: ../../library/turtle.rst:1286 msgid "" ">>> turtle.shape(\"circle\")\n" ">>> turtle.shapesize(5,2)\n" @@ -1789,13 +1790,13 @@ msgstr "" ">>> turtle.shearfactor()\n" "0.5" -#: ../../library/turtle.rst:1299 +#: ../../library/turtle.rst:1300 msgid "" "Rotate the turtleshape by *angle* from its current tilt-angle, but do *not* " "change the turtle's heading (direction of movement)." msgstr "" -#: ../../library/turtle.rst:1302 +#: ../../library/turtle.rst:1303 msgid "" ">>> turtle.reset()\n" ">>> turtle.shape(\"circle\")\n" @@ -1813,13 +1814,13 @@ msgstr "" ">>> turtle.tilt(30)\n" ">>> turtle.fd(50)" -#: ../../library/turtle.rst:1316 ../../library/turtle.rst:1339 -#: ../../library/turtle.rst:1340 ../../library/turtle.rst:1341 -#: ../../library/turtle.rst:1342 +#: ../../library/turtle.rst:1317 ../../library/turtle.rst:1340 +#: ../../library/turtle.rst:1341 ../../library/turtle.rst:1342 +#: ../../library/turtle.rst:1343 msgid "a number (optional)" msgstr "" -#: ../../library/turtle.rst:1318 +#: ../../library/turtle.rst:1319 msgid "" "Set or return the current tilt-angle. If angle is given, rotate the " "turtleshape to point in the direction specified by angle, regardless of its " @@ -1829,7 +1830,7 @@ msgid "" "turtle (its direction of movement)." msgstr "" -#: ../../library/turtle.rst:1326 +#: ../../library/turtle.rst:1327 msgid "" ">>> turtle.reset()\n" ">>> turtle.shape(\"circle\")\n" @@ -1845,11 +1846,11 @@ msgstr "" ">>> turtle.tiltangle()\n" "45.0" -#: ../../library/turtle.rst:1344 +#: ../../library/turtle.rst:1345 msgid "Set or return the current transformation matrix of the turtle shape." msgstr "" -#: ../../library/turtle.rst:1346 +#: ../../library/turtle.rst:1347 msgid "" "If none of the matrix elements are given, return the transformation matrix " "as a tuple of 4 elements. Otherwise set the given elements and transform the " @@ -1859,7 +1860,7 @@ msgid "" "tiltangle according to the given matrix." msgstr "" -#: ../../library/turtle.rst:1355 +#: ../../library/turtle.rst:1356 msgid "" ">>> turtle = Turtle()\n" ">>> turtle.shape(\"square\")\n" @@ -1875,13 +1876,13 @@ msgstr "" ">>> turtle.shapetransform()\n" "(4.0, -1.0, -0.0, 2.0)" -#: ../../library/turtle.rst:1368 +#: ../../library/turtle.rst:1369 msgid "" "Return the current shape polygon as tuple of coordinate pairs. This can be " "used to define a new shape or components of a compound shape." msgstr "" -#: ../../library/turtle.rst:1371 +#: ../../library/turtle.rst:1372 msgid "" ">>> turtle.shape(\"square\")\n" ">>> turtle.shapetransform(4, -1, 0, 2)\n" @@ -1893,23 +1894,23 @@ msgstr "" ">>> turtle.get_shapepoly()\n" "((50, -20), (30, 20), (-50, 20), (-30, -20))" -#: ../../library/turtle.rst:1381 +#: ../../library/turtle.rst:1382 msgid "Using events" msgstr "" -#: ../../library/turtle.rst:1386 ../../library/turtle.rst:1898 +#: ../../library/turtle.rst:1387 ../../library/turtle.rst:1899 msgid "a function with two arguments or ``None``" msgstr "一個有兩個引數的函式或 ``None``" -#: ../../library/turtle.rst:1387 ../../library/turtle.rst:1899 +#: ../../library/turtle.rst:1388 ../../library/turtle.rst:1900 msgid "an integer" msgstr "一個整數" -#: ../../library/turtle.rst:1388 ../../library/turtle.rst:1900 +#: ../../library/turtle.rst:1389 ../../library/turtle.rst:1901 msgid "a boolean or ``None``" msgstr "一個布林值或 ``None``" -#: ../../library/turtle.rst:1390 +#: ../../library/turtle.rst:1391 msgid "" "Bind *fun* to mouse-click events on this turtle. *fun* is called with the " "coordinates of the clicked point on the canvas. If *fun* is ``None``, " @@ -1919,7 +1920,7 @@ msgid "" "turtle, that is, the procedural way:" msgstr "" -#: ../../library/turtle.rst:1397 +#: ../../library/turtle.rst:1398 msgid "" ">>> def turn(x, y):\n" "... left(180)\n" @@ -1928,29 +1929,29 @@ msgid "" ">>> onclick(None) # event-binding will be removed" msgstr "" -#: ../../library/turtle.rst:1409 ../../library/turtle.rst:1434 +#: ../../library/turtle.rst:1410 ../../library/turtle.rst:1435 msgid "" "a function with two arguments which will be called with the coordinates of " "the clicked point on the canvas" msgstr "" -#: ../../library/turtle.rst:1411 ../../library/turtle.rst:1436 +#: ../../library/turtle.rst:1412 ../../library/turtle.rst:1437 msgid "number of the mouse-button, defaults to 1 (left mouse button)" msgstr "" -#: ../../library/turtle.rst:1412 ../../library/turtle.rst:1437 +#: ../../library/turtle.rst:1413 ../../library/turtle.rst:1438 msgid "" "``True`` or ``False`` -- if ``True``, a new binding will be added, otherwise " "it will replace a former binding" msgstr "" -#: ../../library/turtle.rst:1415 +#: ../../library/turtle.rst:1416 msgid "" "Bind *fun* to mouse-button-release events on this turtle. If *fun* is " "``None``, existing bindings are removed." msgstr "" -#: ../../library/turtle.rst:1418 +#: ../../library/turtle.rst:1419 msgid "" ">>> class MyTurtle(Turtle):\n" "... def glow(self,x,y):\n" @@ -1964,39 +1965,39 @@ msgid "" ">>> turtle.onrelease(turtle.unglow) # releasing turns it to transparent." msgstr "" -#: ../../library/turtle.rst:1440 +#: ../../library/turtle.rst:1441 msgid "" "Bind *fun* to mouse-move events on this turtle. If *fun* is ``None``, " "existing bindings are removed." msgstr "" -#: ../../library/turtle.rst:1443 +#: ../../library/turtle.rst:1444 msgid "" "Remark: Every sequence of mouse-move-events on a turtle is preceded by a " "mouse-click event on that turtle." msgstr "" -#: ../../library/turtle.rst:1446 +#: ../../library/turtle.rst:1447 msgid ">>> turtle.ondrag(turtle.goto)" msgstr ">>> turtle.ondrag(turtle.goto)" -#: ../../library/turtle.rst:1451 +#: ../../library/turtle.rst:1452 msgid "" "Subsequently, clicking and dragging the Turtle will move it across the " "screen thereby producing handdrawings (if pen is down)." msgstr "" -#: ../../library/turtle.rst:1456 +#: ../../library/turtle.rst:1457 msgid "Special Turtle methods" msgstr "" -#: ../../library/turtle.rst:1461 +#: ../../library/turtle.rst:1462 msgid "" "Record the vertices of a polygon drawn in the ``with turtle.poly():`` block. " "The first and last vertices will be connected." msgstr "" -#: ../../library/turtle.rst:1464 +#: ../../library/turtle.rst:1465 msgid "" ">>> with turtle.poly():\n" "... turtle.forward(100)\n" @@ -2008,23 +2009,23 @@ msgstr "" "... turtle.right(60)\n" "... turtle.forward(100)" -#: ../../library/turtle.rst:1477 +#: ../../library/turtle.rst:1478 msgid "" "Start recording the vertices of a polygon. The current turtle position is " "the first vertex of the polygon." msgstr "" -#: ../../library/turtle.rst:1483 +#: ../../library/turtle.rst:1484 msgid "" "Stop recording the vertices of a polygon. The current turtle position is the " "last vertex of the polygon. This will be connected with the first vertex." msgstr "" -#: ../../library/turtle.rst:1489 +#: ../../library/turtle.rst:1490 msgid "Return the last recorded polygon." msgstr "" -#: ../../library/turtle.rst:1491 +#: ../../library/turtle.rst:1492 msgid "" ">>> turtle.home()\n" ">>> turtle.begin_poly()\n" @@ -2048,13 +2049,13 @@ msgstr "" ">>> p = turtle.get_poly()\n" ">>> register_shape(\"myFavouriteShape\", p)" -#: ../../library/turtle.rst:1508 +#: ../../library/turtle.rst:1509 msgid "" "Create and return a clone of the turtle with same position, heading and " "turtle properties." msgstr "" -#: ../../library/turtle.rst:1511 +#: ../../library/turtle.rst:1512 msgid "" ">>> mick = Turtle()\n" ">>> joe = mick.clone()" @@ -2062,13 +2063,13 @@ msgstr "" ">>> mick = Turtle()\n" ">>> joe = mick.clone()" -#: ../../library/turtle.rst:1521 +#: ../../library/turtle.rst:1522 msgid "" "Return the Turtle object itself. Only reasonable use: as a function to " "return the \"anonymous turtle\":" msgstr "" -#: ../../library/turtle.rst:1524 +#: ../../library/turtle.rst:1525 msgid "" ">>> pet = getturtle()\n" ">>> pet.fd(50)\n" @@ -2080,13 +2081,13 @@ msgstr "" ">>> pet\n" "" -#: ../../library/turtle.rst:1535 +#: ../../library/turtle.rst:1536 msgid "" "Return the :class:`TurtleScreen` object the turtle is drawing on. " "TurtleScreen methods can then be called for that object." msgstr "" -#: ../../library/turtle.rst:1538 +#: ../../library/turtle.rst:1539 msgid "" ">>> ts = turtle.getscreen()\n" ">>> ts\n" @@ -2098,7 +2099,7 @@ msgstr "" "\n" ">>> ts.bgcolor(\"pink\")" -#: ../../library/turtle.rst:1551 +#: ../../library/turtle.rst:1552 msgid "" "Set or disable undobuffer. If *size* is an integer, an empty undobuffer of " "given size is installed. *size* gives the maximum number of turtle actions " @@ -2106,15 +2107,15 @@ msgid "" "``None``, the undobuffer is disabled." msgstr "" -#: ../../library/turtle.rst:1556 +#: ../../library/turtle.rst:1557 msgid ">>> turtle.setundobuffer(42)" msgstr ">>> turtle.setundobuffer(42)" -#: ../../library/turtle.rst:1564 +#: ../../library/turtle.rst:1565 msgid "Return number of entries in the undobuffer." msgstr "" -#: ../../library/turtle.rst:1566 +#: ../../library/turtle.rst:1567 msgid "" ">>> while undobufferentries():\n" "... undo()" @@ -2122,32 +2123,32 @@ msgstr "" ">>> while undobufferentries():\n" "... undo()" -#: ../../library/turtle.rst:1577 +#: ../../library/turtle.rst:1578 msgid "Compound shapes" msgstr "" -#: ../../library/turtle.rst:1579 +#: ../../library/turtle.rst:1580 msgid "" "To use compound turtle shapes, which consist of several polygons of " "different color, you must use the helper class :class:`Shape` explicitly as " "described below:" msgstr "" -#: ../../library/turtle.rst:1583 +#: ../../library/turtle.rst:1584 msgid "Create an empty Shape object of type \"compound\"." msgstr "" -#: ../../library/turtle.rst:1584 +#: ../../library/turtle.rst:1585 msgid "" "Add as many components to this object as desired, using the :meth:`~Shape." "addcomponent` method." msgstr "" -#: ../../library/turtle.rst:1587 +#: ../../library/turtle.rst:1588 msgid "For example:" msgstr "舉例來說:" -#: ../../library/turtle.rst:1589 +#: ../../library/turtle.rst:1590 msgid "" ">>> s = Shape(\"compound\")\n" ">>> poly1 = ((0,0),(10,-5),(0,10),(-10,-5))\n" @@ -2161,11 +2162,11 @@ msgstr "" ">>> poly2 = ((0,0),(10,-5),(-10,-5))\n" ">>> s.addcomponent(poly2, \"blue\", \"red\")" -#: ../../library/turtle.rst:1598 +#: ../../library/turtle.rst:1599 msgid "Now add the Shape to the Screen's shapelist and use it:" msgstr "" -#: ../../library/turtle.rst:1600 +#: ../../library/turtle.rst:1601 msgid "" ">>> register_shape(\"myshape\", s)\n" ">>> shape(\"myshape\")" @@ -2173,74 +2174,74 @@ msgstr "" ">>> register_shape(\"myshape\", s)\n" ">>> shape(\"myshape\")" -#: ../../library/turtle.rst:1609 +#: ../../library/turtle.rst:1610 msgid "" "The :class:`Shape` class is used internally by the :func:`register_shape` " "method in different ways. The application programmer has to deal with the " "Shape class *only* when using compound shapes like shown above!" msgstr "" -#: ../../library/turtle.rst:1618 +#: ../../library/turtle.rst:1619 msgid "Screen methods and functions" msgstr "" -#: ../../library/turtle.rst:1620 +#: ../../library/turtle.rst:1621 msgid "" "Most of the examples in this section refer to a TurtleScreen instance called " "``screen``." msgstr "" -#: ../../library/turtle.rst:1630 +#: ../../library/turtle.rst:1631 msgid "Window control" msgstr "" -#: ../../library/turtle.rst:1636 +#: ../../library/turtle.rst:1637 msgid "Return or set the background color of the TurtleScreen." msgstr "" -#: ../../library/turtle.rst:1640 +#: ../../library/turtle.rst:1641 msgid "``bgcolor()``" msgstr "``bgcolor()``" -#: ../../library/turtle.rst:1641 +#: ../../library/turtle.rst:1642 msgid "" "Return the current background color as a color specification string or as a " "tuple (see example). May be used as input to another :func:`color`, :func:" "`pencolor`, :func:`fillcolor` or :func:`bgcolor` call." msgstr "" -#: ../../library/turtle.rst:1646 +#: ../../library/turtle.rst:1647 msgid "``bgcolor(colorstring)``" msgstr "``bgcolor(colorstring)``" -#: ../../library/turtle.rst:1647 +#: ../../library/turtle.rst:1648 msgid "" "Set the background color to *colorstring*, which is a Tk color specification " "string, such as ``\"red\"``, ``\"yellow\"``, or ``\"#33cc8c\"``." msgstr "" -#: ../../library/turtle.rst:1650 +#: ../../library/turtle.rst:1651 msgid "``bgcolor((r, g, b))``" msgstr "``bgcolor((r, g, b))``" -#: ../../library/turtle.rst:1651 +#: ../../library/turtle.rst:1652 msgid "" "Set the background color to the RGB color represented by the tuple of *r*, " "*g*, and *b*. Each of *r*, *g*, and *b* must be between 0 and colormode, " "where colormode is either 1.0 or 255 (see :func:`colormode`)." msgstr "" -#: ../../library/turtle.rst:1656 +#: ../../library/turtle.rst:1657 msgid "``bgcolor(r, g, b)``" msgstr "``bgcolor(r, g, b)``" -#: ../../library/turtle.rst:1657 +#: ../../library/turtle.rst:1658 msgid "" "Set the background color to the RGB color represented by *r*, *g*, and *b*. " "Each of *r*, *g*, and *b* must be between 0 and colormode." msgstr "" -#: ../../library/turtle.rst:1660 +#: ../../library/turtle.rst:1661 msgid "" ">>> screen.bgcolor(\"orange\")\n" ">>> screen.bgcolor()\n" @@ -2256,13 +2257,13 @@ msgstr "" ">>> screen.bgcolor()\n" "(128.0, 0.0, 128.0)" -#: ../../library/turtle.rst:1673 +#: ../../library/turtle.rst:1674 msgid "" "a string, name of an image file (PNG, GIF, PGM, and PPM) or ``\"nopic\"``, " "or ``None``" msgstr "" -#: ../../library/turtle.rst:1676 +#: ../../library/turtle.rst:1677 msgid "" "Set background image or return name of current backgroundimage. If " "*picname* is a filename, set the corresponding image as background. If " @@ -2270,7 +2271,7 @@ msgid "" "*picname* is ``None``, return the filename of the current backgroundimage. ::" msgstr "" -#: ../../library/turtle.rst:1681 +#: ../../library/turtle.rst:1682 msgid "" ">>> screen.bgpic()\n" "'nopic'\n" @@ -2284,44 +2285,44 @@ msgstr "" ">>> screen.bgpic()\n" "\"landscape.gif\"" -#: ../../library/turtle.rst:1692 +#: ../../library/turtle.rst:1693 msgid "" "This TurtleScreen method is available as a global function only under the " "name ``clearscreen``. The global function ``clear`` is a different one " "derived from the Turtle method ``clear``." msgstr "" -#: ../../library/turtle.rst:1699 +#: ../../library/turtle.rst:1700 msgid "" "Delete all drawings and all turtles from the TurtleScreen. Reset the now " "empty TurtleScreen to its initial state: white background, no background " "image, no event bindings and tracing on." msgstr "" -#: ../../library/turtle.rst:1708 +#: ../../library/turtle.rst:1709 msgid "" "This TurtleScreen method is available as a global function only under the " "name ``resetscreen``. The global function ``reset`` is another one derived " "from the Turtle method ``reset``." msgstr "" -#: ../../library/turtle.rst:1715 +#: ../../library/turtle.rst:1716 msgid "Reset all turtles on the screen to their initial state." msgstr "" -#: ../../library/turtle.rst:1720 +#: ../../library/turtle.rst:1721 msgid "positive integer, new width of canvas in pixels" msgstr "" -#: ../../library/turtle.rst:1721 +#: ../../library/turtle.rst:1722 msgid "positive integer, new height of canvas in pixels" msgstr "" -#: ../../library/turtle.rst:1722 +#: ../../library/turtle.rst:1723 msgid "colorstring or color-tuple, new background color" msgstr "" -#: ../../library/turtle.rst:1724 +#: ../../library/turtle.rst:1725 msgid "" "If no arguments are given, return current (canvaswidth, canvasheight). Else " "resize the canvas the turtles are drawing on. Do not alter the drawing " @@ -2330,7 +2331,7 @@ msgid "" "outside the canvas before." msgstr "" -#: ../../library/turtle.rst:1730 +#: ../../library/turtle.rst:1731 msgid "" ">>> screen.screensize()\n" "(400, 300)\n" @@ -2339,11 +2340,11 @@ msgid "" "(2000, 1500)" msgstr "" -#: ../../library/turtle.rst:1739 +#: ../../library/turtle.rst:1740 msgid "e.g. to search for an erroneously escaped turtle ;-)" msgstr "" -#: ../../library/turtle.rst:1749 +#: ../../library/turtle.rst:1750 msgid "" "Set up a user-defined coordinate system. *llx* and *lly* are the x and y " "coordinates of the lower left corner of the canvas. *urx* and *ury* are the " @@ -2353,7 +2354,7 @@ msgid "" "coordinate systems, angles may appear distorted, see :func:`mode`." msgstr "" -#: ../../library/turtle.rst:1756 +#: ../../library/turtle.rst:1757 msgid "" ">>> screen.reset()\n" ">>> screen.setworldcoordinates(-50,-7.5,50,7.5)\n" @@ -2371,11 +2372,11 @@ msgstr "" ">>> for _ in range(8):\n" "... left(45); fd(2) # 一個一般的八邊形" -#: ../../library/turtle.rst:1777 +#: ../../library/turtle.rst:1778 msgid "Animation control" msgstr "" -#: ../../library/turtle.rst:1781 +#: ../../library/turtle.rst:1782 msgid "" "Temporarily turn off turtle animation. The code inside the :keyword:`with` " "block is not animated. Once the block is exited, the drawing appears. This " @@ -2383,7 +2384,7 @@ msgid "" "too slow." msgstr "" -#: ../../library/turtle.rst:1786 +#: ../../library/turtle.rst:1787 msgid "" ">>> with screen.no_animation():\n" "... for dist in range(2, 400, 2):\n" @@ -2395,19 +2396,19 @@ msgstr "" "... fd(dist)\n" "... rt(90)" -#: ../../library/turtle.rst:1799 ../../library/turtle.rst:1817 -#: ../../library/turtle.rst:1818 +#: ../../library/turtle.rst:1800 ../../library/turtle.rst:1818 +#: ../../library/turtle.rst:1819 msgid "a nonnegative integer or ``None``" msgstr "一個非負整數或 ``None``" -#: ../../library/turtle.rst:1801 +#: ../../library/turtle.rst:1802 msgid "" "Return or set the drawing delay in milliseconds. This is approximately the " "time interval between two consecutive canvas updates. The longer the drawing " "delay, the slower the animation." msgstr "" -#: ../../library/turtle.rst:1805 +#: ../../library/turtle.rst:1806 msgid "" ">>> screen.delay()\n" "10\n" @@ -2421,7 +2422,7 @@ msgstr "" ">>> screen.delay()\n" "5" -#: ../../library/turtle.rst:1820 +#: ../../library/turtle.rst:1821 msgid "" "Turn turtle animation on or off and set the drawing delay. If *n* is given, " "only every n-th regular screen update is performed, which can be used to " @@ -2431,7 +2432,7 @@ msgid "" "arguments, return the current value of *n*." msgstr "" -#: ../../library/turtle.rst:1827 +#: ../../library/turtle.rst:1828 msgid "" ">>> screen.tracer(8, 25)\n" ">>> dist = 2\n" @@ -2447,41 +2448,41 @@ msgstr "" "... rt(90)\n" "... dist += 2" -#: ../../library/turtle.rst:1840 +#: ../../library/turtle.rst:1841 msgid "Perform a TurtleScreen update. To be used when tracer is turned off." msgstr "" -#: ../../library/turtle.rst:1842 +#: ../../library/turtle.rst:1843 msgid "See also the RawTurtle/Turtle method :func:`speed`." msgstr "另請參閱 RawTurtle/Turtle 的 :func:`speed` 方法。" -#: ../../library/turtle.rst:1846 +#: ../../library/turtle.rst:1847 msgid "Using screen events" msgstr "" -#: ../../library/turtle.rst:1850 +#: ../../library/turtle.rst:1851 msgid "" "Set focus on TurtleScreen (in order to collect key-events). Dummy arguments " "are provided in order to be able to pass :func:`listen` to the onclick " "method." msgstr "" -#: ../../library/turtle.rst:1857 ../../library/turtle.rst:1877 +#: ../../library/turtle.rst:1858 ../../library/turtle.rst:1878 msgid "a function with no arguments or ``None``" msgstr "" -#: ../../library/turtle.rst:1858 ../../library/turtle.rst:1878 +#: ../../library/turtle.rst:1859 ../../library/turtle.rst:1879 msgid "a string: key (e.g. \"a\") or key-symbol (e.g. \"space\")" msgstr "" -#: ../../library/turtle.rst:1860 +#: ../../library/turtle.rst:1861 msgid "" "Bind *fun* to key-release event of key. If *fun* is ``None``, event " "bindings are removed. Remark: in order to be able to register key-events, " "TurtleScreen must have the focus. (See method :func:`listen`.)" msgstr "" -#: ../../library/turtle.rst:1864 +#: ../../library/turtle.rst:1865 msgid "" ">>> def f():\n" "... fd(50)\n" @@ -2497,14 +2498,14 @@ msgstr "" ">>> screen.onkey(f, \"Up\")\n" ">>> screen.listen()" -#: ../../library/turtle.rst:1880 +#: ../../library/turtle.rst:1881 msgid "" "Bind *fun* to key-press event of key if key is given, or to any key-press-" "event if no key is given. Remark: in order to be able to register key-" "events, TurtleScreen must have focus. (See method :func:`listen`.)" msgstr "" -#: ../../library/turtle.rst:1885 +#: ../../library/turtle.rst:1886 msgid "" ">>> def f():\n" "... fd(50)\n" @@ -2518,7 +2519,7 @@ msgstr "" ">>> screen.onkey(f, \"Up\")\n" ">>> screen.listen()" -#: ../../library/turtle.rst:1902 +#: ../../library/turtle.rst:1903 msgid "" "Bind *fun* to mouse-click events on this screen. *fun* is called with the " "coordinates of the clicked point on the canvas. If *fun* is ``None``, " @@ -2527,13 +2528,13 @@ msgid "" "added, otherwise it replaces a former binding." msgstr "" -#: ../../library/turtle.rst:1908 +#: ../../library/turtle.rst:1909 msgid "" "Example for a TurtleScreen instance named ``screen`` and a Turtle instance " "named ``turtle``:" msgstr "" -#: ../../library/turtle.rst:1911 +#: ../../library/turtle.rst:1912 msgid "" ">>> screen.onclick(turtle.goto) # Subsequently clicking into the " "TurtleScreen will\n" @@ -2542,26 +2543,26 @@ msgid "" ">>> screen.onclick(None) # remove event binding again" msgstr "" -#: ../../library/turtle.rst:1919 +#: ../../library/turtle.rst:1920 msgid "" "This TurtleScreen method is available as a global function only under the " "name ``onscreenclick``. The global function ``onclick`` is another one " "derived from the Turtle method ``onclick``." msgstr "" -#: ../../library/turtle.rst:1926 +#: ../../library/turtle.rst:1927 msgid "a function with no arguments" msgstr "" -#: ../../library/turtle.rst:1927 +#: ../../library/turtle.rst:1928 msgid "a number >= 0" msgstr "" -#: ../../library/turtle.rst:1929 +#: ../../library/turtle.rst:1930 msgid "Install a timer that calls *fun* after *t* milliseconds." msgstr "" -#: ../../library/turtle.rst:1931 +#: ../../library/turtle.rst:1932 msgid "" ">>> running = True\n" ">>> def f():\n" @@ -2573,7 +2574,7 @@ msgid "" ">>> running = False" msgstr "" -#: ../../library/turtle.rst:1947 +#: ../../library/turtle.rst:1948 msgid "" "Start the event loop by calling Tkinter's :meth:`~tkinter.Misc.mainloop` " "method. Must be the last statement in a turtle graphics program. Must *not* " @@ -2581,29 +2582,29 @@ msgid "" "subprocess`)." msgstr "" -#: ../../library/turtle.rst:1954 +#: ../../library/turtle.rst:1955 msgid "Input methods" msgstr "" -#: ../../library/turtle.rst:1958 ../../library/turtle.rst:1959 -#: ../../library/turtle.rst:1970 ../../library/turtle.rst:1971 -#: ../../library/turtle.rst:2068 ../../library/turtle.rst:2201 -#: ../../library/turtle.rst:2257 +#: ../../library/turtle.rst:1959 ../../library/turtle.rst:1960 +#: ../../library/turtle.rst:1971 ../../library/turtle.rst:1972 +#: ../../library/turtle.rst:2069 ../../library/turtle.rst:2202 +#: ../../library/turtle.rst:2258 msgid "a string" msgstr "一個字串" -#: ../../library/turtle.rst:1961 +#: ../../library/turtle.rst:1962 msgid "" "Pop up a dialog window for input of a string. *title* is the title of the " "dialog window and *prompt* is a text describing what information to input. " "Return the string entered. If the dialog is canceled, return ``None``. ::" msgstr "" -#: ../../library/turtle.rst:1965 +#: ../../library/turtle.rst:1966 msgid ">>> screen.textinput(\"NIM\", \"Name of first player:\")" msgstr ">>> screen.textinput(\"NIM\", \"Name of first player:\")" -#: ../../library/turtle.rst:1976 +#: ../../library/turtle.rst:1977 msgid "" "Pop up a dialog window for input of a number. *title* is the title of the " "dialog window and *prompt* is a text describing what numerical information " @@ -2614,7 +2615,7 @@ msgid "" "is canceled, return ``None``. ::" msgstr "" -#: ../../library/turtle.rst:1984 +#: ../../library/turtle.rst:1985 msgid "" ">>> screen.numinput(\"Poker\", \"Your stakes:\", 1000, minval=10, " "maxval=10000)" @@ -2622,22 +2623,22 @@ msgstr "" ">>> screen.numinput(\"Poker\", \"Your stakes:\", 1000, minval=10, " "maxval=10000)" -#: ../../library/turtle.rst:1988 +#: ../../library/turtle.rst:1989 msgid "Settings and special methods" msgstr "" -#: ../../library/turtle.rst:1992 +#: ../../library/turtle.rst:1993 msgid "a string or ``None``" msgstr "一個字串或 ``None``" -#: ../../library/turtle.rst:1994 +#: ../../library/turtle.rst:1995 msgid "" "Set the turtle mode and perform a reset. *mode* is one of the strings " "\"standard\", \"logo\" or \"world\". If *mode* is not given, return the " "current mode." msgstr "" -#: ../../library/turtle.rst:1998 +#: ../../library/turtle.rst:1999 msgid "" "Mode \"standard\" is compatible with the old :mod:`!turtle` module. Mode " "\"logo\" is compatible with most Logo turtle graphics. Mode \"world\" uses " @@ -2645,56 +2646,56 @@ msgid "" "mode, angles appear distorted if the x and y units are not of equal length." msgstr "" -#: ../../library/turtle.rst:2004 +#: ../../library/turtle.rst:2005 msgid "Mode" msgstr "" -#: ../../library/turtle.rst:2004 +#: ../../library/turtle.rst:2005 msgid "Initial turtle heading" msgstr "" -#: ../../library/turtle.rst:2004 +#: ../../library/turtle.rst:2005 msgid "positive angles" msgstr "" -#: ../../library/turtle.rst:2006 +#: ../../library/turtle.rst:2007 msgid "\"standard\"" msgstr "" -#: ../../library/turtle.rst:2006 +#: ../../library/turtle.rst:2007 msgid "to the right (east)" msgstr "" -#: ../../library/turtle.rst:2006 +#: ../../library/turtle.rst:2007 msgid "counterclockwise" msgstr "" -#: ../../library/turtle.rst:2007 +#: ../../library/turtle.rst:2008 msgid "\"logo\"" msgstr "" -#: ../../library/turtle.rst:2007 +#: ../../library/turtle.rst:2008 msgid "upward (north)" msgstr "" -#: ../../library/turtle.rst:2007 +#: ../../library/turtle.rst:2008 msgid "clockwise" msgstr "" -#: ../../library/turtle.rst:2010 +#: ../../library/turtle.rst:2011 msgid "" ">>> mode(\"logo\") # resets turtle heading to north\n" ">>> mode()\n" "'logo'" msgstr "" -#: ../../library/turtle.rst:2022 +#: ../../library/turtle.rst:2023 msgid "" "Return the colormode or set it to 1.0 or 255. After setting it, the *r*, *g* " "and *b* values of color triples have to be between 0 and *cmode*." msgstr "" -#: ../../library/turtle.rst:2025 +#: ../../library/turtle.rst:2026 msgid "" ">>> screen.colormode(1)\n" ">>> turtle.pencolor(240, 160, 80)\n" @@ -2720,13 +2721,13 @@ msgstr "" "255\n" ">>> turtle.pencolor(240,160,80)" -#: ../../library/turtle.rst:2043 +#: ../../library/turtle.rst:2044 msgid "" "Return the Canvas of this TurtleScreen. Useful for insiders who know what " "to do with a Tkinter Canvas." msgstr "" -#: ../../library/turtle.rst:2046 +#: ../../library/turtle.rst:2047 msgid "" ">>> cv = screen.getcanvas()\n" ">>> cv\n" @@ -2736,11 +2737,11 @@ msgstr "" ">>> cv\n" "" -#: ../../library/turtle.rst:2056 +#: ../../library/turtle.rst:2057 msgid "Return a list of names of all currently available turtle shapes." msgstr "" -#: ../../library/turtle.rst:2058 +#: ../../library/turtle.rst:2059 msgid "" ">>> screen.getshapes()\n" "['arrow', 'blank', 'circle', ..., 'turtle']" @@ -2748,71 +2749,71 @@ msgstr "" ">>> screen.getshapes()\n" "['arrow', 'blank', 'circle', ..., 'turtle']" -#: ../../library/turtle.rst:2069 +#: ../../library/turtle.rst:2070 msgid "" "a string, a tuple of pairs of numbers, a :class:`Shape` object or ``None``" msgstr "" -#: ../../library/turtle.rst:2072 +#: ../../library/turtle.rst:2073 msgid "" "Add a turtle shape to the TurtleScreen's shape list. It can be called in " "four different ways:" msgstr "" -#: ../../library/turtle.rst:2075 +#: ../../library/turtle.rst:2076 msgid "" "*name* is the name of an image file (PNG, GIF, PGM, and PPM) and *shape* is " "``None``: Install the corresponding image shape. ::" msgstr "" -#: ../../library/turtle.rst:2078 +#: ../../library/turtle.rst:2079 msgid ">>> screen.register_shape(\"turtle.gif\")" msgstr ">>> screen.register_shape(\"turtle.gif\")" -#: ../../library/turtle.rst:2080 +#: ../../library/turtle.rst:2081 msgid "" "*name* is an arbitrary string and *shape* is the name of an image file (PNG, " "GIF, PGM, and PPM): Install the corresponding image shape. ::" msgstr "" -#: ../../library/turtle.rst:2083 +#: ../../library/turtle.rst:2084 msgid ">>> screen.register_shape(\"turtle\", \"turtle.gif\")" msgstr ">>> screen.register_shape(\"turtle\", \"turtle.gif\")" -#: ../../library/turtle.rst:2085 +#: ../../library/turtle.rst:2086 msgid "" "*name* is an arbitrary string and *shape* is a tuple of pairs of " "coordinates: Install the corresponding polygon shape." msgstr "" -#: ../../library/turtle.rst:2088 +#: ../../library/turtle.rst:2089 msgid ">>> screen.register_shape(\"triangle\", ((5,-3), (0,5), (-5,-3)))" msgstr ">>> screen.register_shape(\"triangle\", ((5,-3), (0,5), (-5,-3)))" -#: ../../library/turtle.rst:2093 +#: ../../library/turtle.rst:2094 msgid "" "*name* is an arbitrary string and *shape* is a (compound) :class:`Shape` " "object: Install the corresponding compound shape." msgstr "" -#: ../../library/turtle.rst:2096 +#: ../../library/turtle.rst:2097 msgid "" "Image shapes do not rotate when turning the turtle, so they do not display " "the heading of the turtle. To use a registered shape, call :func:`shape` " "with its name." msgstr "" -#: ../../library/turtle.rst:2100 +#: ../../library/turtle.rst:2101 msgid "" "Added support for PNG, PGM, and PPM image formats. Both a shape name and an " "image file name can be specified." msgstr "" -#: ../../library/turtle.rst:2107 +#: ../../library/turtle.rst:2108 msgid "Return the list of turtles on the screen." msgstr "" -#: ../../library/turtle.rst:2109 +#: ../../library/turtle.rst:2110 msgid "" ">>> for turtle in screen.turtles():\n" "... turtle.color(\"red\")" @@ -2820,11 +2821,11 @@ msgstr "" ">>> for turtle in screen.turtles():\n" "... turtle.color(\"red\")" -#: ../../library/turtle.rst:2118 +#: ../../library/turtle.rst:2119 msgid "Return the height of the turtle window. ::" msgstr "" -#: ../../library/turtle.rst:2120 +#: ../../library/turtle.rst:2121 msgid "" ">>> screen.window_height()\n" "480" @@ -2832,11 +2833,11 @@ msgstr "" ">>> screen.window_height()\n" "480" -#: ../../library/turtle.rst:2126 +#: ../../library/turtle.rst:2127 msgid "Return the width of the turtle window. ::" msgstr "" -#: ../../library/turtle.rst:2128 +#: ../../library/turtle.rst:2129 msgid "" ">>> screen.window_width()\n" "640" @@ -2844,19 +2845,19 @@ msgstr "" ">>> screen.window_width()\n" "640" -#: ../../library/turtle.rst:2136 +#: ../../library/turtle.rst:2137 msgid "Screen-only methods" msgstr "" -#: ../../library/turtle.rst:2140 +#: ../../library/turtle.rst:2141 msgid "Close the turtle graphics window." msgstr "" -#: ../../library/turtle.rst:2145 +#: ../../library/turtle.rst:2146 msgid "Bind ``bye()`` method to mouse clicks on the Screen." msgstr "" -#: ../../library/turtle.rst:2148 +#: ../../library/turtle.rst:2149 msgid "" "If the value \"using_IDLE\" in the configuration dictionary is ``False`` " "(default value), also enter mainloop. Remark: If IDLE with the ``-n`` " @@ -2865,22 +2866,22 @@ msgid "" "client script." msgstr "" -#: ../../library/turtle.rst:2157 +#: ../../library/turtle.rst:2158 msgid "Save the current turtle drawing (and turtles) as a PostScript file." msgstr "" -#: ../../library/turtle.rst:2159 +#: ../../library/turtle.rst:2160 msgid "the path of the saved PostScript file" msgstr "" -#: ../../library/turtle.rst:2160 +#: ../../library/turtle.rst:2161 msgid "" "if ``False`` and there already exists a file with the given filename, then " "the function will raise a ``FileExistsError``. If it is ``True``, the file " "will be overwritten." msgstr "" -#: ../../library/turtle.rst:2165 +#: ../../library/turtle.rst:2166 msgid "" ">>> screen.save(\"my_drawing.ps\")\n" ">>> screen.save(\"my_drawing.ps\", overwrite=True)" @@ -2888,38 +2889,38 @@ msgstr "" ">>> screen.save(\"my_drawing.ps\")\n" ">>> screen.save(\"my_drawing.ps\", overwrite=True)" -#: ../../library/turtle.rst:2175 +#: ../../library/turtle.rst:2176 msgid "" "Set the size and position of the main window. Default values of arguments " "are stored in the configuration dictionary and can be changed via a :file:" "`turtle.cfg` file." msgstr "" -#: ../../library/turtle.rst:2179 +#: ../../library/turtle.rst:2180 msgid "" "if an integer, a size in pixels, if a float, a fraction of the screen; " "default is 50% of screen" msgstr "" -#: ../../library/turtle.rst:2181 +#: ../../library/turtle.rst:2182 msgid "" "if an integer, the height in pixels, if a float, a fraction of the screen; " "default is 75% of screen" msgstr "" -#: ../../library/turtle.rst:2183 +#: ../../library/turtle.rst:2184 msgid "" "if positive, starting position in pixels from the left edge of the screen, " "if negative from the right edge, if ``None``, center window horizontally" msgstr "" -#: ../../library/turtle.rst:2186 +#: ../../library/turtle.rst:2187 msgid "" "if positive, starting position in pixels from the top edge of the screen, if " "negative from the bottom edge, if ``None``, center window vertically" msgstr "" -#: ../../library/turtle.rst:2190 +#: ../../library/turtle.rst:2191 msgid "" ">>> screen.setup (width=200, height=200, startx=0, starty=0)\n" ">>> # sets window to 200x200 pixels, in upper left of screen\n" @@ -2927,72 +2928,72 @@ msgid "" ">>> # sets window to 75% of screen by 50% of screen and centers" msgstr "" -#: ../../library/turtle.rst:2203 +#: ../../library/turtle.rst:2204 msgid "" "Set the title of the turtle window to *titlestring*. The title is shown in " "the title bar of the turtle graphics window." msgstr "" -#: ../../library/turtle.rst:2206 +#: ../../library/turtle.rst:2207 msgid ">>> screen.title(\"Welcome to the turtle zoo!\")" msgstr ">>> screen.title(\"Welcome to the turtle zoo!\")" -#: ../../library/turtle.rst:2213 +#: ../../library/turtle.rst:2214 msgid "Public classes" msgstr "" -#: ../../library/turtle.rst:2219 +#: ../../library/turtle.rst:2220 msgid "" "a :class:`!tkinter.Canvas`, a :class:`ScrolledCanvas` or a :class:" "`TurtleScreen`" msgstr "" -#: ../../library/turtle.rst:2222 +#: ../../library/turtle.rst:2223 msgid "" "Create a turtle. The turtle has all methods described above as \"methods of " "Turtle/RawTurtle\"." msgstr "" -#: ../../library/turtle.rst:2228 +#: ../../library/turtle.rst:2229 msgid "" "Subclass of RawTurtle, has the same interface but draws on a default :class:" "`Screen` object created automatically when needed for the first time." msgstr "" -#: ../../library/turtle.rst:2234 +#: ../../library/turtle.rst:2235 msgid "a :class:`!tkinter.Canvas`" msgstr "一個 :class:`!tkinter.Canvas`" -#: ../../library/turtle.rst:2236 +#: ../../library/turtle.rst:2237 msgid "" "Provides screen oriented methods like :func:`bgcolor` etc. that are " "described above." msgstr "" -#: ../../library/turtle.rst:2241 +#: ../../library/turtle.rst:2242 msgid "" "Subclass of :class:`TurtleScreen`, with :ref:`four methods added " "`. Calling ``Screen()`` returns the single screen object. If " "it does not exist yet, it is created. Otherwise the existing one is returned." msgstr "" -#: ../../library/turtle.rst:2249 +#: ../../library/turtle.rst:2250 msgid "" "some Tkinter widget to contain the ScrolledCanvas, i.e. a Tkinter-canvas " "with scrollbars added" msgstr "" -#: ../../library/turtle.rst:2252 +#: ../../library/turtle.rst:2253 msgid "" "Used by class Screen, which thus automatically provides a ScrolledCanvas as " "playground for the turtles." msgstr "" -#: ../../library/turtle.rst:2258 +#: ../../library/turtle.rst:2259 msgid "depends on *type_*" msgstr "" -#: ../../library/turtle.rst:2260 +#: ../../library/turtle.rst:2261 msgid "" "Data structure modeling shapes. *type_* is one of the strings \"polygon\", " "\"image\" or \"compound\". What *data* must be depends on *type_*: for " @@ -3001,19 +3002,19 @@ msgid "" "built up using the :meth:`addcomponent` method." msgstr "" -#: ../../library/turtle.rst:2268 +#: ../../library/turtle.rst:2269 msgid "a tuple of pairs of numbers" msgstr "" -#: ../../library/turtle.rst:2269 +#: ../../library/turtle.rst:2270 msgid "a color" msgstr "" -#: ../../library/turtle.rst:2270 +#: ../../library/turtle.rst:2271 msgid "a color or ``None``" msgstr "一個顏色或 ``None``" -#: ../../library/turtle.rst:2272 +#: ../../library/turtle.rst:2273 msgid "" "Add a component to a shape of type \"compound\". *poly* is a polygon, a " "tuple of pairs of numbers. *fill* is the color the polygon is filled with " @@ -3021,11 +3022,11 @@ msgid "" "is used for it as well." msgstr "" -#: ../../library/turtle.rst:2277 +#: ../../library/turtle.rst:2278 msgid "Example:" msgstr "例如:" -#: ../../library/turtle.rst:2279 +#: ../../library/turtle.rst:2280 msgid "" ">>> poly = ((0,0), (10,-5), (0,10), (-10,-5))\n" ">>> s = Shape(\"compound\")\n" @@ -3037,60 +3038,60 @@ msgstr "" ">>> s.addcomponent(poly, \"red\", \"blue\")\n" ">>> # ... 加入更多元件,然後使用 register_shape()" -#: ../../library/turtle.rst:2287 +#: ../../library/turtle.rst:2288 msgid "See :ref:`compoundshapes`." msgstr "請見\\ :ref:`compoundshapes`。" -#: ../../library/turtle.rst:2292 +#: ../../library/turtle.rst:2293 msgid "" "A two-dimensional vector class, used as a helper class for implementing " "turtle graphics. May be useful for turtle graphics programs too. Derived " "from tuple, so a vector is a tuple!" msgstr "" -#: ../../library/turtle.rst:2296 +#: ../../library/turtle.rst:2297 msgid "Provides (for *a*, *b* vectors, *k* number):" msgstr "" -#: ../../library/turtle.rst:2298 +#: ../../library/turtle.rst:2299 msgid "``a + b`` vector addition" msgstr "``a + b`` 向量加法" -#: ../../library/turtle.rst:2299 +#: ../../library/turtle.rst:2300 msgid "``a - b`` vector subtraction" msgstr "``a - b`` 向量減法" -#: ../../library/turtle.rst:2300 +#: ../../library/turtle.rst:2301 msgid "``a * b`` inner product" msgstr "``a * b`` 內積" -#: ../../library/turtle.rst:2301 +#: ../../library/turtle.rst:2302 msgid "``k * a`` and ``a * k`` multiplication with scalar" msgstr "" -#: ../../library/turtle.rst:2302 +#: ../../library/turtle.rst:2303 msgid "``abs(a)`` absolute value of a" msgstr "``abs(a)`` a 的絕對值" -#: ../../library/turtle.rst:2303 +#: ../../library/turtle.rst:2304 msgid "``a.rotate(angle)`` rotation" msgstr "``a.rotate(angle)`` 旋轉" -#: ../../library/turtle.rst:2307 +#: ../../library/turtle.rst:2308 msgid "Exceptions" msgstr "例外" -#: ../../library/turtle.rst:2309 +#: ../../library/turtle.rst:2310 msgid "The :mod:`!turtle` module defines the following exception:" msgstr "" -#: ../../library/turtle.rst:2313 +#: ../../library/turtle.rst:2314 msgid "" "Raised for invalid arguments or operations. For example, a malformed color " "string:" msgstr "" -#: ../../library/turtle.rst:2316 +#: ../../library/turtle.rst:2317 msgid "" ">>> turtle.color(\"blau\")\n" "Traceback (most recent call last):\n" @@ -3098,26 +3099,26 @@ msgid "" "turtle.TurtleGraphicsError: bad color string: blau" msgstr "" -#: ../../library/turtle.rst:2330 +#: ../../library/turtle.rst:2331 msgid "How-to guides" msgstr "" -#: ../../library/turtle.rst:2332 +#: ../../library/turtle.rst:2333 msgid "This section covers some typical turtle use-cases and approaches." msgstr "" -#: ../../library/turtle.rst:2336 +#: ../../library/turtle.rst:2337 msgid "Automatically begin and end filling" msgstr "" -#: ../../library/turtle.rst:2338 +#: ../../library/turtle.rst:2339 msgid "" "Starting with Python 3.14, you can use the :func:`fill` :term:`context " "manager` instead of :func:`begin_fill` and :func:`end_fill` to automatically " "begin and end fill. Here is an example::" msgstr "" -#: ../../library/turtle.rst:2342 +#: ../../library/turtle.rst:2343 msgid "" "with fill():\n" " for i in range(4):\n" @@ -3127,11 +3128,11 @@ msgid "" "forward(200)" msgstr "" -#: ../../library/turtle.rst:2349 +#: ../../library/turtle.rst:2350 msgid "The code above is equivalent to::" msgstr "" -#: ../../library/turtle.rst:2351 +#: ../../library/turtle.rst:2352 msgid "" "begin_fill()\n" "for i in range(4):\n" @@ -3142,11 +3143,11 @@ msgid "" "forward(200)" msgstr "" -#: ../../library/turtle.rst:2361 +#: ../../library/turtle.rst:2362 msgid "Use the ``turtle`` module namespace" msgstr "" -#: ../../library/turtle.rst:2363 +#: ../../library/turtle.rst:2364 msgid "" "Using ``from turtle import *`` is convenient - but be warned that it imports " "a rather large collection of objects, and if you're doing anything but " @@ -3155,7 +3156,7 @@ msgid "" "might be imported)." msgstr "" -#: ../../library/turtle.rst:2369 +#: ../../library/turtle.rst:2370 msgid "" "The solution is to use ``import turtle`` - ``fd()`` becomes ``turtle.fd()``, " "``width()`` becomes ``turtle.width()`` and so on. (If typing \"turtle\" over " @@ -3163,17 +3164,17 @@ msgid "" "instead.)" msgstr "" -#: ../../library/turtle.rst:2376 +#: ../../library/turtle.rst:2377 msgid "Use turtle graphics in a script" msgstr "" -#: ../../library/turtle.rst:2378 +#: ../../library/turtle.rst:2379 msgid "" "It's recommended to use the ``turtle`` module namespace as described " "immediately above, for example::" msgstr "" -#: ../../library/turtle.rst:2381 +#: ../../library/turtle.rst:2382 msgid "" "import turtle as t\n" "from random import random\n" @@ -3193,33 +3194,33 @@ msgstr "" " t.right(angle)\n" " t.fd(steps)" -#: ../../library/turtle.rst:2390 +#: ../../library/turtle.rst:2391 msgid "" "Another step is also required though - as soon as the script ends, Python " "will also close the turtle's window. Add::" msgstr "" -#: ../../library/turtle.rst:2393 +#: ../../library/turtle.rst:2394 msgid "t.mainloop()" msgstr "t.mainloop()" -#: ../../library/turtle.rst:2395 +#: ../../library/turtle.rst:2396 msgid "" "to the end of the script. The script will now wait to be dismissed and will " "not exit until it is terminated, for example by closing the turtle graphics " "window." msgstr "" -#: ../../library/turtle.rst:2401 +#: ../../library/turtle.rst:2402 msgid "Use object-oriented turtle graphics" msgstr "" -#: ../../library/turtle.rst:2403 +#: ../../library/turtle.rst:2404 msgid "" ":ref:`Explanation of the object-oriented interface `" msgstr "" -#: ../../library/turtle.rst:2405 +#: ../../library/turtle.rst:2406 msgid "" "Other than for very basic introductory purposes, or for trying things out as " "quickly as possible, it's more usual and much more powerful to use the " @@ -3227,18 +3228,18 @@ msgid "" "multiple turtles on screen at once." msgstr "" -#: ../../library/turtle.rst:2410 +#: ../../library/turtle.rst:2411 msgid "" "In this approach, the various turtle commands are methods of objects (mostly " "of ``Turtle`` objects). You *can* use the object-oriented approach in the " "shell, but it would be more typical in a Python script." msgstr "" -#: ../../library/turtle.rst:2414 +#: ../../library/turtle.rst:2415 msgid "The example above then becomes::" msgstr "" -#: ../../library/turtle.rst:2416 +#: ../../library/turtle.rst:2417 msgid "" "from turtle import Turtle\n" "from random import random\n" @@ -3264,45 +3265,45 @@ msgstr "" "\n" "t.screen.mainloop()" -#: ../../library/turtle.rst:2428 +#: ../../library/turtle.rst:2429 msgid "" "Note the last line. ``t.screen`` is an instance of the :class:`Screen` that " "a Turtle instance exists on; it's created automatically along with the " "turtle." msgstr "" -#: ../../library/turtle.rst:2432 +#: ../../library/turtle.rst:2433 msgid "The turtle's screen can be customised, for example::" msgstr "" -#: ../../library/turtle.rst:2434 +#: ../../library/turtle.rst:2435 msgid "" "t.screen.title('Object-oriented turtle demo')\n" "t.screen.bgcolor(\"orange\")" msgstr "" -#: ../../library/turtle.rst:2441 +#: ../../library/turtle.rst:2442 msgid "How to use help" msgstr "" -#: ../../library/turtle.rst:2443 +#: ../../library/turtle.rst:2444 msgid "" "The public methods of the Screen and Turtle classes are documented " "extensively via docstrings. So these can be used as online-help via the " "Python help facilities:" msgstr "" -#: ../../library/turtle.rst:2447 +#: ../../library/turtle.rst:2448 msgid "" "When using IDLE, tooltips show the signatures and first lines of the " "docstrings of typed in function-/method calls." msgstr "" -#: ../../library/turtle.rst:2450 +#: ../../library/turtle.rst:2451 msgid "Calling :func:`help` on methods or functions displays the docstrings::" msgstr "" -#: ../../library/turtle.rst:2452 +#: ../../library/turtle.rst:2453 msgid "" ">>> help(Screen.bgcolor)\n" "Help on method bgcolor in module turtle:\n" @@ -3362,13 +3363,13 @@ msgstr "" "\n" " >>> turtle.penup()" -#: ../../library/turtle.rst:2481 +#: ../../library/turtle.rst:2482 msgid "" "The docstrings of the functions which are derived from methods have a " "modified form::" msgstr "" -#: ../../library/turtle.rst:2484 +#: ../../library/turtle.rst:2485 msgid "" ">>> help(bgcolor)\n" "Help on function bgcolor in module turtle:\n" @@ -3432,28 +3433,28 @@ msgstr "" " Example:\n" " >>> penup()" -#: ../../library/turtle.rst:2515 +#: ../../library/turtle.rst:2516 msgid "" "These modified docstrings are created automatically together with the " "function definitions that are derived from the methods at import time." msgstr "" -#: ../../library/turtle.rst:2520 +#: ../../library/turtle.rst:2521 msgid "Translation of docstrings into different languages" msgstr "" -#: ../../library/turtle.rst:2522 +#: ../../library/turtle.rst:2523 msgid "" "There is a utility to create a dictionary the keys of which are the method " "names and the values of which are the docstrings of the public methods of " "the classes Screen and Turtle." msgstr "" -#: ../../library/turtle.rst:2528 +#: ../../library/turtle.rst:2529 msgid "a string, used as filename" msgstr "" -#: ../../library/turtle.rst:2530 +#: ../../library/turtle.rst:2531 msgid "" "Create and write docstring-dictionary to a Python script with the given " "filename. This function has to be called explicitly (it is not used by the " @@ -3462,37 +3463,37 @@ msgid "" "for translation of the docstrings into different languages." msgstr "" -#: ../../library/turtle.rst:2536 +#: ../../library/turtle.rst:2537 msgid "" "If you (or your students) want to use :mod:`!turtle` with online help in " "your native language, you have to translate the docstrings and save the " "resulting file as e.g. :file:`turtle_docstringdict_german.py`." msgstr "" -#: ../../library/turtle.rst:2540 +#: ../../library/turtle.rst:2541 msgid "" "If you have an appropriate entry in your :file:`turtle.cfg` file this " "dictionary will be read in at import time and will replace the original " "English docstrings." msgstr "" -#: ../../library/turtle.rst:2543 +#: ../../library/turtle.rst:2544 msgid "" "At the time of this writing there are docstring dictionaries in German and " "in Italian. (Requests please to glingl@aon.at.)" msgstr "" -#: ../../library/turtle.rst:2549 +#: ../../library/turtle.rst:2550 msgid "How to configure Screen and Turtles" msgstr "" -#: ../../library/turtle.rst:2551 +#: ../../library/turtle.rst:2552 msgid "" "The built-in default configuration mimics the appearance and behaviour of " "the old turtle module in order to retain best possible compatibility with it." msgstr "" -#: ../../library/turtle.rst:2554 +#: ../../library/turtle.rst:2555 msgid "" "If you want to use a different configuration which better reflects the " "features of this module or which better fits to your needs, e.g. for use in " @@ -3501,12 +3502,12 @@ msgid "" "settings." msgstr "" -#: ../../library/turtle.rst:2559 +#: ../../library/turtle.rst:2560 msgid "" "The built in configuration would correspond to the following ``turtle.cfg``:" msgstr "" -#: ../../library/turtle.rst:2561 +#: ../../library/turtle.rst:2562 msgid "" "width = 0.5\n" "height = 0.75\n" @@ -3550,49 +3551,49 @@ msgstr "" "title = Python Turtle Graphics\n" "using_IDLE = False" -#: ../../library/turtle.rst:2584 +#: ../../library/turtle.rst:2585 msgid "Short explanation of selected entries:" msgstr "" -#: ../../library/turtle.rst:2586 +#: ../../library/turtle.rst:2587 msgid "" "The first four lines correspond to the arguments of the :func:`Screen.setup " "` method." msgstr "" -#: ../../library/turtle.rst:2588 +#: ../../library/turtle.rst:2589 msgid "" "Line 5 and 6 correspond to the arguments of the method :func:`Screen." "screensize `." msgstr "" -#: ../../library/turtle.rst:2590 +#: ../../library/turtle.rst:2591 msgid "" "*shape* can be any of the built-in shapes, e.g: arrow, turtle, etc. For " "more info try ``help(shape)``." msgstr "" -#: ../../library/turtle.rst:2592 +#: ../../library/turtle.rst:2593 msgid "" "If you want to use no fill color (i.e. make the turtle transparent), you " "have to write ``fillcolor = \"\"`` (but all nonempty strings must not have " "quotes in the cfg file)." msgstr "" -#: ../../library/turtle.rst:2595 +#: ../../library/turtle.rst:2596 msgid "" "If you want to reflect the turtle its state, you have to use ``resizemode = " "auto``." msgstr "" -#: ../../library/turtle.rst:2597 +#: ../../library/turtle.rst:2598 msgid "" "If you set e.g. ``language = italian`` the docstringdict :file:" "`turtle_docstringdict_italian.py` will be loaded at import time (if present " "on the import path, e.g. in the same directory as :mod:`!turtle`)." msgstr "" -#: ../../library/turtle.rst:2600 +#: ../../library/turtle.rst:2601 msgid "" "The entries *exampleturtle* and *examplescreen* define the names of these " "objects as they occur in the docstrings. The transformation of method-" @@ -3600,45 +3601,45 @@ msgid "" "docstrings." msgstr "" -#: ../../library/turtle.rst:2604 +#: ../../library/turtle.rst:2605 msgid "" "*using_IDLE*: Set this to ``True`` if you regularly work with IDLE and its " "``-n`` switch (\"no subprocess\"). This will prevent :func:`exitonclick` to " "enter the mainloop." msgstr "" -#: ../../library/turtle.rst:2608 +#: ../../library/turtle.rst:2609 msgid "" "There can be a :file:`turtle.cfg` file in the directory where :mod:`!turtle` " "is stored and an additional one in the current working directory. The " "latter will override the settings of the first one." msgstr "" -#: ../../library/turtle.rst:2612 +#: ../../library/turtle.rst:2613 msgid "" "The :file:`Lib/turtledemo` directory contains a :file:`turtle.cfg` file. " "You can study it as an example and see its effects when running the demos " "(preferably not from within the demo-viewer)." msgstr "" -#: ../../library/turtle.rst:2620 +#: ../../library/turtle.rst:2621 msgid "Explanation" msgstr "解釋" -#: ../../library/turtle.rst:2622 +#: ../../library/turtle.rst:2623 msgid "" "A turtle object draws on a screen object, and there a number of key classes " "in the turtle object-oriented interface that can be used to create them and " "relate them to each other." msgstr "" -#: ../../library/turtle.rst:2626 +#: ../../library/turtle.rst:2627 msgid "" "A :class:`Turtle` instance will automatically create a :class:`Screen` " "instance if one is not already present." msgstr "" -#: ../../library/turtle.rst:2629 +#: ../../library/turtle.rst:2630 msgid "" "``Turtle`` is a subclass of :class:`RawTurtle`, which *doesn't* " "automatically create a drawing surface - a *canvas* will need to be provided " @@ -3646,7 +3647,7 @@ msgid "" "`ScrolledCanvas` or :class:`TurtleScreen`." msgstr "" -#: ../../library/turtle.rst:2635 +#: ../../library/turtle.rst:2636 msgid "" ":class:`TurtleScreen` is the basic drawing surface for a turtle. :class:" "`Screen` is a subclass of ``TurtleScreen``, and includes :ref:`some " @@ -3655,7 +3656,7 @@ msgid "" "`!tkinter.Canvas` or a :class:`ScrolledCanvas` as an argument." msgstr "" -#: ../../library/turtle.rst:2642 +#: ../../library/turtle.rst:2643 msgid "" "The functional interface for turtle graphics uses the various methods of " "``Turtle`` and ``TurtleScreen``/``Screen``. Behind the scenes, a screen " @@ -3664,308 +3665,308 @@ msgid "" "created whenever any of the functions derived from a Turtle method is called." msgstr "" -#: ../../library/turtle.rst:2648 +#: ../../library/turtle.rst:2649 msgid "" "To use multiple turtles on a screen, the object-oriented interface must be " "used." msgstr "" -#: ../../library/turtle.rst:2653 +#: ../../library/turtle.rst:2654 msgid ":mod:`!turtledemo` --- Demo scripts" msgstr "" -#: ../../library/turtle.rst:2658 +#: ../../library/turtle.rst:2659 msgid "" "The :mod:`!turtledemo` package includes a set of demo scripts. These " "scripts can be run and viewed using the supplied demo viewer as follows::" msgstr "" -#: ../../library/turtle.rst:2661 +#: ../../library/turtle.rst:2662 msgid "python -m turtledemo" msgstr "python -m turtledemo" -#: ../../library/turtle.rst:2663 +#: ../../library/turtle.rst:2664 msgid "" "Alternatively, you can run the demo scripts individually. For example, ::" msgstr "" -#: ../../library/turtle.rst:2665 +#: ../../library/turtle.rst:2666 msgid "python -m turtledemo.bytedesign" msgstr "python -m turtledemo.bytedesign" -#: ../../library/turtle.rst:2667 +#: ../../library/turtle.rst:2668 msgid "The :mod:`!turtledemo` package directory contains:" msgstr ":mod:`!turtledemo` 套件目錄包含:" -#: ../../library/turtle.rst:2669 +#: ../../library/turtle.rst:2670 msgid "" "A demo viewer :file:`__main__.py` which can be used to view the sourcecode " "of the scripts and run them at the same time." msgstr "" -#: ../../library/turtle.rst:2671 +#: ../../library/turtle.rst:2672 msgid "" "Multiple scripts demonstrating different features of the :mod:`!turtle` " "module. Examples can be accessed via the Examples menu. They can also be " "run standalone." msgstr "" -#: ../../library/turtle.rst:2674 +#: ../../library/turtle.rst:2675 msgid "" "A :file:`turtle.cfg` file which serves as an example of how to write and use " "such files." msgstr "" -#: ../../library/turtle.rst:2677 +#: ../../library/turtle.rst:2678 msgid "The demo scripts are:" msgstr "" -#: ../../library/turtle.rst:2684 +#: ../../library/turtle.rst:2685 msgid "Name" msgstr "" -#: ../../library/turtle.rst:2684 +#: ../../library/turtle.rst:2685 msgid "Description" msgstr "描述" -#: ../../library/turtle.rst:2684 +#: ../../library/turtle.rst:2685 msgid "Features" msgstr "" -#: ../../library/turtle.rst:2686 +#: ../../library/turtle.rst:2687 msgid "``bytedesign``" msgstr "``bytedesign``" -#: ../../library/turtle.rst:2686 +#: ../../library/turtle.rst:2687 msgid "complex classical turtle graphics pattern" msgstr "" -#: ../../library/turtle.rst:2686 +#: ../../library/turtle.rst:2687 msgid ":func:`tracer`, :func:`delay`, :func:`update`" msgstr ":func:`tracer`、:func:`delay`、:func:`update`" -#: ../../library/turtle.rst:2689 +#: ../../library/turtle.rst:2690 msgid "``chaos``" msgstr "``chaos``" -#: ../../library/turtle.rst:2689 +#: ../../library/turtle.rst:2690 msgid "" "graphs Verhulst dynamics, shows that computer's computations can generate " "results sometimes against the common sense expectations" msgstr "" -#: ../../library/turtle.rst:2689 +#: ../../library/turtle.rst:2690 msgid "world coordinates" msgstr "" -#: ../../library/turtle.rst:2695 +#: ../../library/turtle.rst:2696 msgid "``clock``" msgstr "``clock``" -#: ../../library/turtle.rst:2695 +#: ../../library/turtle.rst:2696 msgid "analog clock showing time of your computer" msgstr "" -#: ../../library/turtle.rst:2695 +#: ../../library/turtle.rst:2696 msgid "turtles as clock's hands, :func:`ontimer`" msgstr "" -#: ../../library/turtle.rst:2698 +#: ../../library/turtle.rst:2699 msgid "``colormixer``" msgstr "``colormixer``" -#: ../../library/turtle.rst:2698 +#: ../../library/turtle.rst:2699 msgid "experiment with r, g, b" msgstr "" -#: ../../library/turtle.rst:2698 +#: ../../library/turtle.rst:2699 msgid ":func:`ondrag`" msgstr ":func:`ondrag`" -#: ../../library/turtle.rst:2700 +#: ../../library/turtle.rst:2701 msgid "``forest``" msgstr "``forest``" -#: ../../library/turtle.rst:2700 +#: ../../library/turtle.rst:2701 msgid "3 breadth-first trees" msgstr "" -#: ../../library/turtle.rst:2700 +#: ../../library/turtle.rst:2701 msgid "randomization" msgstr "" -#: ../../library/turtle.rst:2702 +#: ../../library/turtle.rst:2703 msgid "``fractalcurves``" msgstr "``fractalcurves``" -#: ../../library/turtle.rst:2702 +#: ../../library/turtle.rst:2703 msgid "Hilbert & Koch curves" msgstr "" -#: ../../library/turtle.rst:2702 +#: ../../library/turtle.rst:2703 msgid "recursion" msgstr "" -#: ../../library/turtle.rst:2704 +#: ../../library/turtle.rst:2705 msgid "``lindenmayer``" msgstr "``lindenmayer``" -#: ../../library/turtle.rst:2704 +#: ../../library/turtle.rst:2705 msgid "ethnomathematics (indian kolams)" msgstr "" -#: ../../library/turtle.rst:2704 +#: ../../library/turtle.rst:2705 msgid "L-System" msgstr "" -#: ../../library/turtle.rst:2707 +#: ../../library/turtle.rst:2708 msgid "``minimal_hanoi``" msgstr "``minimal_hanoi``" -#: ../../library/turtle.rst:2707 +#: ../../library/turtle.rst:2708 msgid "Towers of Hanoi" msgstr "河內塔" -#: ../../library/turtle.rst:2707 +#: ../../library/turtle.rst:2708 msgid "Rectangular Turtles as Hanoi discs (:func:`shape`, :func:`shapesize`)" msgstr "" -#: ../../library/turtle.rst:2711 +#: ../../library/turtle.rst:2712 msgid "``nim``" msgstr "``nim``" -#: ../../library/turtle.rst:2711 +#: ../../library/turtle.rst:2712 msgid "" "play the classical nim game with three heaps of sticks against the computer." msgstr "" -#: ../../library/turtle.rst:2711 +#: ../../library/turtle.rst:2712 msgid "turtles as nimsticks, event driven (mouse, keyboard)" msgstr "" -#: ../../library/turtle.rst:2715 +#: ../../library/turtle.rst:2716 msgid "``paint``" msgstr "``paint``" -#: ../../library/turtle.rst:2715 +#: ../../library/turtle.rst:2716 msgid "super minimalistic drawing program" msgstr "" -#: ../../library/turtle.rst:2715 +#: ../../library/turtle.rst:2716 msgid ":func:`onclick`" msgstr ":func:`onclick`" -#: ../../library/turtle.rst:2718 +#: ../../library/turtle.rst:2719 msgid "``peace``" msgstr "``peace``" -#: ../../library/turtle.rst:2718 +#: ../../library/turtle.rst:2719 msgid "elementary" msgstr "" -#: ../../library/turtle.rst:2718 +#: ../../library/turtle.rst:2719 msgid "turtle: appearance and animation" msgstr "" -#: ../../library/turtle.rst:2721 +#: ../../library/turtle.rst:2722 msgid "``penrose``" msgstr "``penrose``" -#: ../../library/turtle.rst:2721 +#: ../../library/turtle.rst:2722 msgid "aperiodic tiling with kites and darts" msgstr "" -#: ../../library/turtle.rst:2721 +#: ../../library/turtle.rst:2722 msgid ":func:`stamp`" msgstr ":func:`stamp`" -#: ../../library/turtle.rst:2724 +#: ../../library/turtle.rst:2725 msgid "``planet_and_moon``" msgstr "``planet_and_moon``" -#: ../../library/turtle.rst:2724 +#: ../../library/turtle.rst:2725 msgid "simulation of gravitational system" msgstr "" -#: ../../library/turtle.rst:2724 +#: ../../library/turtle.rst:2725 msgid "compound shapes, :class:`Vec2D`" msgstr "" -#: ../../library/turtle.rst:2727 +#: ../../library/turtle.rst:2728 msgid "``rosette``" msgstr "``rosette``" -#: ../../library/turtle.rst:2727 +#: ../../library/turtle.rst:2728 msgid "a pattern from the wikipedia article on turtle graphics" msgstr "" -#: ../../library/turtle.rst:2727 +#: ../../library/turtle.rst:2728 msgid ":func:`clone`, :func:`undo`" msgstr ":func:`clone`、:func:`undo`" -#: ../../library/turtle.rst:2730 +#: ../../library/turtle.rst:2731 msgid "``round_dance``" msgstr "``round_dance``" -#: ../../library/turtle.rst:2730 +#: ../../library/turtle.rst:2731 msgid "dancing turtles rotating pairwise in opposite direction" msgstr "" -#: ../../library/turtle.rst:2730 +#: ../../library/turtle.rst:2731 msgid "" "compound shapes, :func:`clone` :func:`shapesize`, :func:`tilt`, :func:" "`get_shapepoly`, :func:`update`" msgstr "" -#: ../../library/turtle.rst:2734 +#: ../../library/turtle.rst:2735 msgid "``sorting_animate``" msgstr "``sorting_animate``" -#: ../../library/turtle.rst:2734 +#: ../../library/turtle.rst:2735 msgid "visual demonstration of different sorting methods" msgstr "" -#: ../../library/turtle.rst:2734 +#: ../../library/turtle.rst:2735 msgid "simple alignment, randomization" msgstr "" -#: ../../library/turtle.rst:2737 +#: ../../library/turtle.rst:2738 msgid "``tree``" msgstr "``tree``" -#: ../../library/turtle.rst:2737 +#: ../../library/turtle.rst:2738 msgid "a (graphical) breadth first tree (using generators)" msgstr "" -#: ../../library/turtle.rst:2737 +#: ../../library/turtle.rst:2738 msgid ":func:`clone`" msgstr ":func:`clone`" -#: ../../library/turtle.rst:2740 +#: ../../library/turtle.rst:2741 msgid "``two_canvases``" msgstr "``two_canvases``" -#: ../../library/turtle.rst:2740 +#: ../../library/turtle.rst:2741 msgid "simple design" msgstr "" -#: ../../library/turtle.rst:2740 +#: ../../library/turtle.rst:2741 msgid "turtles on two canvases" msgstr "" -#: ../../library/turtle.rst:2743 +#: ../../library/turtle.rst:2744 msgid "``yinyang``" msgstr "``yinyang``" -#: ../../library/turtle.rst:2743 +#: ../../library/turtle.rst:2744 msgid "another elementary example" msgstr "" -#: ../../library/turtle.rst:2743 +#: ../../library/turtle.rst:2744 msgid ":func:`circle`" msgstr ":func:`circle`" -#: ../../library/turtle.rst:2746 +#: ../../library/turtle.rst:2747 msgid "Have fun!" msgstr "" diff --git a/library/types.po b/library/types.po index f724cf17d5f..a2e12e6c451 100644 --- a/library/types.po +++ b/library/types.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-03 00:49+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:14+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -450,6 +450,32 @@ msgstr "" #: ../../library/types.rst:338 msgid "" +"The type of frame locals proxy objects, as found on the :attr:`frame." +"f_locals` attribute." +msgstr "" + +#: ../../library/types.rst:343 +msgid ":pep:`667`" +msgstr ":pep:`667`" + +#: ../../library/types.rst:348 +msgid "" +"The type of lazy import proxy objects. These objects are created when a " +"module is lazily imported and serve as placeholders until the module is " +"actually accessed. This type can be used to detect lazy imports " +"programmatically." +msgstr "" + +#: ../../library/types.rst:355 +msgid ":pep:`810`" +msgstr ":pep:`810`" + +#: ../../library/types.rst:359 +msgid "Reify the lazy import and return the \"real\" object being imported." +msgstr "" + +#: ../../library/types.rst:364 +msgid "" "The type of objects defined in extension modules with ``PyGetSetDef``, such " "as :attr:`FrameType.f_locals ` or ``array.array.typecode``. " "This type is used as descriptor for object attributes; it has the same " @@ -457,7 +483,7 @@ msgid "" "modules." msgstr "" -#: ../../library/types.rst:347 +#: ../../library/types.rst:373 msgid "" "The type of objects defined in extension modules with ``PyMemberDef``, such " "as ``datetime.timedelta.days``. This type is used as descriptor for simple " @@ -466,7 +492,7 @@ msgid "" "modules." msgstr "" -#: ../../library/types.rst:352 +#: ../../library/types.rst:378 msgid "" "In addition, when a class is defined with a :attr:`~object.__slots__` " "attribute, then for each slot, an instance of :class:`!MemberDescriptorType` " @@ -474,106 +500,106 @@ msgid "" "in the class's :attr:`~type.__dict__`." msgstr "" -#: ../../library/types.rst:358 +#: ../../library/types.rst:384 msgid "" "In other implementations of Python, this type may be identical to " "``GetSetDescriptorType``." msgstr "" -#: ../../library/types.rst:363 +#: ../../library/types.rst:389 msgid "" "Read-only proxy of a mapping. It provides a dynamic view on the mapping's " "entries, which means that when the mapping changes, the view reflects these " "changes." msgstr "" -#: ../../library/types.rst:367 +#: ../../library/types.rst:393 msgid "" ":class:`!MappingProxyType`\\s are :ref:`generic ` over two types, " "signifying (respectively) the types of the underlying mapping's keys and " "values." msgstr "" -#: ../../library/types.rst:375 +#: ../../library/types.rst:401 msgid "" "Updated to support the new union (``|``) operator from :pep:`584`, which " "simply delegates to the underlying mapping." msgstr "" -#: ../../library/types.rst:380 +#: ../../library/types.rst:406 msgid "" "Return ``True`` if the underlying mapping has a key *key*, else ``False``." msgstr "" -#: ../../library/types.rst:385 +#: ../../library/types.rst:411 msgid "" "Return the item of the underlying mapping with key *key*. Raises a :exc:" "`KeyError` if *key* is not in the underlying mapping." msgstr "" -#: ../../library/types.rst:390 +#: ../../library/types.rst:416 msgid "" "Return an iterator over the keys of the underlying mapping. This is a " "shortcut for ``iter(proxy.keys())``." msgstr "" -#: ../../library/types.rst:395 +#: ../../library/types.rst:421 msgid "Return the number of items in the underlying mapping." msgstr "" -#: ../../library/types.rst:399 +#: ../../library/types.rst:425 msgid "Return a shallow copy of the underlying mapping." msgstr "" -#: ../../library/types.rst:403 +#: ../../library/types.rst:429 msgid "" "Return the value for *key* if *key* is in the underlying mapping, else " "*default*. If *default* is not given, it defaults to ``None``, so that this " "method never raises a :exc:`KeyError`." msgstr "" -#: ../../library/types.rst:409 +#: ../../library/types.rst:435 msgid "" "Return a new view of the underlying mapping's items (``(key, value)`` pairs)." msgstr "" -#: ../../library/types.rst:414 +#: ../../library/types.rst:440 msgid "Return a new view of the underlying mapping's keys." msgstr "" -#: ../../library/types.rst:418 +#: ../../library/types.rst:444 msgid "Return a new view of the underlying mapping's values." msgstr "" -#: ../../library/types.rst:422 +#: ../../library/types.rst:448 msgid "Return a reverse iterator over the keys of the underlying mapping." msgstr "" -#: ../../library/types.rst:428 +#: ../../library/types.rst:454 msgid "Return a hash of the underlying mapping." msgstr "" -#: ../../library/types.rst:434 +#: ../../library/types.rst:460 msgid "The type of :ref:`capsule objects `." msgstr "" -#: ../../library/types.rst:440 +#: ../../library/types.rst:466 msgid "Additional Utility Classes and Functions" msgstr "" -#: ../../library/types.rst:444 +#: ../../library/types.rst:470 msgid "" "A simple :class:`object` subclass that provides attribute access to its " "namespace, as well as a meaningful repr." msgstr "" -#: ../../library/types.rst:447 +#: ../../library/types.rst:473 msgid "" "Unlike :class:`object`, with :class:`!SimpleNamespace` you can add and " "remove attributes." msgstr "" -#: ../../library/types.rst:450 +#: ../../library/types.rst:476 msgid "" ":py:class:`SimpleNamespace` objects may be initialized in the same way as :" "class:`dict`: either with keyword arguments, with a single positional " @@ -584,11 +610,11 @@ msgid "" "`iterable` object producing key-value pairs). All such keys must be strings." msgstr "" -#: ../../library/types.rst:461 +#: ../../library/types.rst:487 msgid "The type is roughly equivalent to the following code::" msgstr "" -#: ../../library/types.rst:463 +#: ../../library/types.rst:489 msgid "" "class SimpleNamespace:\n" " def __init__(self, mapping_or_iterable=(), /, **kwargs):\n" @@ -620,33 +646,33 @@ msgstr "" " return self.__dict__ == other.__dict__\n" " return NotImplemented" -#: ../../library/types.rst:477 +#: ../../library/types.rst:503 msgid "" "``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``. " "However, for a structured record type use :func:`~collections.namedtuple` " "instead." msgstr "" -#: ../../library/types.rst:481 +#: ../../library/types.rst:507 msgid "" ":class:`!SimpleNamespace` objects are supported by :func:`copy.replace`." msgstr "" -#: ../../library/types.rst:485 +#: ../../library/types.rst:511 msgid "" "Attribute order in the repr changed from alphabetical to insertion (like " "``dict``)." msgstr "" -#: ../../library/types.rst:489 +#: ../../library/types.rst:515 msgid "Added support for an optional positional argument." msgstr "" -#: ../../library/types.rst:494 +#: ../../library/types.rst:520 msgid "Route attribute access on a class to __getattr__." msgstr "" -#: ../../library/types.rst:496 +#: ../../library/types.rst:522 msgid "" "This is a descriptor, used to define attributes that act differently when " "accessed through an instance and through a class. Instance access remains " @@ -654,18 +680,18 @@ msgid "" "class's __getattr__ method; this is done by raising AttributeError." msgstr "" -#: ../../library/types.rst:501 +#: ../../library/types.rst:527 msgid "" "This allows one to have properties active on an instance, and have virtual " "attributes on the class with the same name (see :class:`enum.Enum` for an " "example)." msgstr "" -#: ../../library/types.rst:508 +#: ../../library/types.rst:534 msgid "Coroutine Utility Functions" msgstr "" -#: ../../library/types.rst:512 +#: ../../library/types.rst:538 msgid "" "This function transforms a :term:`generator` function into a :term:" "`coroutine function` which returns a generator-based coroutine. The " @@ -675,11 +701,11 @@ msgid "" "method." msgstr "" -#: ../../library/types.rst:519 +#: ../../library/types.rst:545 msgid "If *gen_func* is a generator function, it will be modified in-place." msgstr "" -#: ../../library/types.rst:521 +#: ../../library/types.rst:547 msgid "" "If *gen_func* is not a generator function, it will be wrapped. If it returns " "an instance of :class:`collections.abc.Generator`, the instance will be " diff --git a/library/typing.po b/library/typing.po index 993df7bac6a..b2212e96a58 100644 --- a/library/typing.po +++ b/library/typing.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -389,8 +389,8 @@ msgstr "" "str]`` 象徵為一個函式,可以接受一個型別為 :class:`int` 的引數,並回傳一個 :" "class:`str`。" -#: ../../library/typing.rst:215 ../../library/typing.rst:3297 -#: ../../library/typing.rst:3483 ../../library/typing.rst:3511 +#: ../../library/typing.rst:215 ../../library/typing.rst:3420 +#: ../../library/typing.rst:3636 ../../library/typing.rst:3664 msgid "For example:" msgstr "舉例來說:" @@ -512,7 +512,7 @@ msgstr "" "``Callable[Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable], " "ReturnType]`` 的形式。" -#: ../../library/typing.rst:287 ../../library/typing.rst:4053 +#: ../../library/typing.rst:287 ../../library/typing.rst:4221 msgid "" "``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. See :" "pep:`612` for more details." @@ -1579,8 +1579,8 @@ msgstr "" #: ../../library/typing.rst:873 ../../library/typing.rst:991 #: ../../library/typing.rst:1048 ../../library/typing.rst:1231 #: ../../library/typing.rst:1318 ../../library/typing.rst:1360 -#: ../../library/typing.rst:1569 ../../library/typing.rst:1630 -#: ../../library/typing.rst:3234 +#: ../../library/typing.rst:1598 ../../library/typing.rst:1659 +#: ../../library/typing.rst:3368 ../../library/typing.rst:3457 msgid "For example::" msgstr "舉例來說: ::" @@ -1647,7 +1647,7 @@ msgstr "" "此。然而,若是一個型別僅為 ``str`` 的物件則不相容。一個字串若是透過組合多個 " "``LiteralString`` 型別的物件建立,則此字串也可以視為 ``LiteralString``。" -#: ../../library/typing.rst:917 ../../library/typing.rst:2251 +#: ../../library/typing.rst:917 ../../library/typing.rst:2322 msgid "Example:" msgstr "舉例來說: ::" @@ -2141,7 +2141,7 @@ msgid "" "sum_threadsafe([1.1, 2.2, 3.3])" msgstr "" -#: ../../library/typing.rst:1218 ../../library/typing.rst:2219 +#: ../../library/typing.rst:1218 ../../library/typing.rst:2290 msgid "" ":pep:`612` -- Parameter Specification Variables (the PEP which introduced " "``ParamSpec`` and ``Concatenate``)" @@ -2151,7 +2151,7 @@ msgstr ":pep:`612` -- 參數技術規範變數" msgid ":class:`ParamSpec`" msgstr ":class:`ParamSpec`" -#: ../../library/typing.rst:1221 ../../library/typing.rst:2222 +#: ../../library/typing.rst:1221 ../../library/typing.rst:2293 msgid ":ref:`annotating-callables`" msgstr ":ref:`annotating-callables`" @@ -2334,7 +2334,7 @@ msgid "" " TIMEOUT = 1 # Error reported by type checker" msgstr "" -#: ../../library/typing.rst:1329 ../../library/typing.rst:3250 +#: ../../library/typing.rst:1329 ../../library/typing.rst:3384 msgid "" "There is no runtime checking of these properties. See :pep:`591` for more " "details." @@ -2667,12 +2667,60 @@ msgstr "" msgid "The PEP introducing ``Annotated`` to the standard library." msgstr "" -#: ../../library/typing.rst:1530 ../../library/typing.rst:1614 +#: ../../library/typing.rst:1530 +msgid "" +"A special form representing the value that results from evaluating a type " +"expression." +msgstr "" + +#: ../../library/typing.rst:1533 +msgid "" +"This value encodes the information supplied in the type expression, and it " +"represents the type described by that type expression." +msgstr "" + +#: ../../library/typing.rst:1536 +msgid "" +"When used in a type expression, ``TypeForm`` describes a set of type form " +"objects. It accepts a single type argument, which must be a valid type " +"expression. ``TypeForm[T]`` describes the set of all type form objects that " +"represent the type ``T`` or types assignable to ``T``." +msgstr "" + +#: ../../library/typing.rst:1541 +msgid "" +"``TypeForm(obj)`` simply returns ``obj`` unchanged. This is useful for " +"explicitly marking a value as a type form for static type checkers." +msgstr "" + +#: ../../library/typing.rst:1544 ../../library/typing.rst:3087 +msgid "Example::" +msgstr "舉例來說: ::" + +#: ../../library/typing.rst:1546 +msgid "" +"from typing import Any, TypeForm\n" +"\n" +"def cast[T](typ: TypeForm[T], value: Any) -> T: ...\n" +"\n" +"reveal_type(cast(int, \"x\")) # Revealed type is \"int\"" +msgstr "" +"from typing import Any, TypeForm\n" +"\n" +"def cast[T](typ: TypeForm[T], value: Any) -> T: ...\n" +"\n" +"reveal_type(cast(int, \"x\")) # Revealed type is \"int\"" + +#: ../../library/typing.rst:1552 +msgid "See :pep:`747` for details." +msgstr "更多細節請見 :pep:`747`。" + +#: ../../library/typing.rst:1559 ../../library/typing.rst:1643 msgid "" "Special typing construct for marking user-defined type predicate functions." msgstr "" -#: ../../library/typing.rst:1532 +#: ../../library/typing.rst:1561 msgid "" "``TypeIs`` can be used to annotate the return type of a user-defined type " "predicate function. ``TypeIs`` only accepts a single type argument. At " @@ -2680,7 +2728,7 @@ msgid "" "one positional argument." msgstr "" -#: ../../library/typing.rst:1537 +#: ../../library/typing.rst:1566 msgid "" "``TypeIs`` aims to benefit *type narrowing* -- a technique used by static " "type checkers to determine a more precise type of an expression within a " @@ -2690,7 +2738,7 @@ msgid "" "predicate\"::" msgstr "" -#: ../../library/typing.rst:1543 +#: ../../library/typing.rst:1572 msgid "" "def is_str(val: str | float):\n" " # \"isinstance\" type predicate\n" @@ -2702,7 +2750,7 @@ msgid "" " ..." msgstr "" -#: ../../library/typing.rst:1552 +#: ../../library/typing.rst:1581 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:" @@ -2713,29 +2761,29 @@ msgid "" "does not return ``True`` for all instances of the narrowed type." msgstr "" -#: ../../library/typing.rst:1560 +#: ../../library/typing.rst:1589 msgid "" "Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for a " "given function:" msgstr "" -#: ../../library/typing.rst:1563 ../../library/typing.rst:1624 +#: ../../library/typing.rst:1592 ../../library/typing.rst:1653 msgid "The return value is a boolean." msgstr "回傳值是一個布林值。" -#: ../../library/typing.rst:1564 +#: ../../library/typing.rst:1593 msgid "" "If the return value is ``True``, the type of its argument is the " "intersection of the argument's original type and ``NarrowedType``." msgstr "" -#: ../../library/typing.rst:1566 +#: ../../library/typing.rst:1595 msgid "" "If the return value is ``False``, the type of its argument is narrowed to " "exclude ``NarrowedType``." msgstr "" -#: ../../library/typing.rst:1571 +#: ../../library/typing.rst:1600 msgid "" "from typing import assert_type, final, TypeIs\n" "\n" @@ -2759,7 +2807,7 @@ msgid "" " assert_type(arg, Unrelated)" msgstr "" -#: ../../library/typing.rst:1592 +#: ../../library/typing.rst:1621 msgid "" "The type inside ``TypeIs`` must be consistent with the type of the " "function's argument; if it is not, static type checkers will raise an " @@ -2768,27 +2816,27 @@ msgid "" "functions in a type-safe manner." msgstr "" -#: ../../library/typing.rst:1598 +#: ../../library/typing.rst:1627 msgid "" "If a ``TypeIs`` function is a class or instance method, then the type in " "``TypeIs`` maps to the type of the second parameter (after ``cls`` or " "``self``)." msgstr "" -#: ../../library/typing.rst:1602 +#: ../../library/typing.rst:1631 msgid "" "In short, the form ``def foo(arg: TypeA) -> TypeIs[TypeB]: ...``, means that " "if ``foo(arg)`` returns ``True``, then ``arg`` is an instance of ``TypeB``, " "and if it returns ``False``, it is not an instance of ``TypeB``." msgstr "" -#: ../../library/typing.rst:1606 +#: ../../library/typing.rst:1635 msgid "" "``TypeIs`` also works with type variables. For more information, see :pep:" "`742` (Narrowing types with ``TypeIs``)." msgstr "" -#: ../../library/typing.rst:1616 +#: ../../library/typing.rst:1645 msgid "" "Type predicate functions are user-defined functions that return whether " "their argument is an instance of a particular type. ``TypeGuard`` works " @@ -2796,25 +2844,25 @@ msgid "" "checking behavior (see below)." msgstr "" -#: ../../library/typing.rst:1621 +#: ../../library/typing.rst:1650 msgid "" "Using ``-> TypeGuard`` tells the static type checker that for a given " "function:" msgstr "" -#: ../../library/typing.rst:1625 +#: ../../library/typing.rst:1654 msgid "" "If the return value is ``True``, the type of its argument is the type inside " "``TypeGuard``." msgstr "" -#: ../../library/typing.rst:1628 +#: ../../library/typing.rst:1657 msgid "" "``TypeGuard`` also works with type variables. See :pep:`647` for more " "details." msgstr "" -#: ../../library/typing.rst:1632 +#: ../../library/typing.rst:1661 msgid "" "def is_str_list(val: list[object]) -> TypeGuard[list[str]]:\n" " '''Determines whether all objects in the list are strings'''\n" @@ -2829,11 +2877,11 @@ msgid "" " print(\"Not a list of strings!\")" msgstr "" -#: ../../library/typing.rst:1644 +#: ../../library/typing.rst:1673 msgid "``TypeIs`` and ``TypeGuard`` differ in the following ways:" msgstr "``TypeIs`` 和 ``TypeGuard`` 在以下幾個方面有所不同:" -#: ../../library/typing.rst:1646 +#: ../../library/typing.rst:1675 msgid "" "``TypeIs`` requires the narrowed type to be a subtype of the input type, " "while ``TypeGuard`` does not. The main reason is to allow for things like " @@ -2841,7 +2889,7 @@ msgid "" "subtype of the former, since ``list`` is invariant." msgstr "" -#: ../../library/typing.rst:1650 +#: ../../library/typing.rst:1679 msgid "" "When a ``TypeGuard`` function returns ``True``, type checkers narrow the " "type of the variable to exactly the ``TypeGuard`` type. When a ``TypeIs`` " @@ -2850,7 +2898,7 @@ msgid "" "type. (Technically, this is known as an intersection type.)" msgstr "" -#: ../../library/typing.rst:1654 +#: ../../library/typing.rst:1683 msgid "" "When a ``TypeGuard`` function returns ``False``, type checkers cannot narrow " "the type of the variable at all. When a ``TypeIs`` function returns " @@ -2858,18 +2906,18 @@ msgid "" "``TypeIs`` type." msgstr "" -#: ../../library/typing.rst:1663 +#: ../../library/typing.rst:1692 msgid "Typing operator to conceptually mark an object as having been unpacked." msgstr "" -#: ../../library/typing.rst:1665 +#: ../../library/typing.rst:1694 msgid "" "For example, using the unpack operator ``*`` on a :ref:`type variable tuple " "` is equivalent to using ``Unpack`` to mark the type variable " "tuple as having been unpacked::" msgstr "" -#: ../../library/typing.rst:1669 +#: ../../library/typing.rst:1698 msgid "" "Ts = TypeVarTuple('Ts')\n" "tup: tuple[*Ts]\n" @@ -2877,7 +2925,7 @@ msgid "" "tup: tuple[Unpack[Ts]]" msgstr "" -#: ../../library/typing.rst:1674 +#: ../../library/typing.rst:1703 msgid "" "In fact, ``Unpack`` can be used interchangeably with ``*`` in the context " "of :class:`typing.TypeVarTuple ` and :class:`builtins.tuple " @@ -2885,7 +2933,7 @@ msgid "" "versions of Python, where ``*`` couldn't be used in certain places::" msgstr "" -#: ../../library/typing.rst:1680 +#: ../../library/typing.rst:1709 msgid "" "# In older versions of Python, TypeVarTuple and Unpack\n" "# are located in the `typing_extensions` backports package.\n" @@ -2896,13 +2944,13 @@ msgid "" "tup: tuple[Unpack[Ts]] # Semantically equivalent, and backwards-compatible" msgstr "" -#: ../../library/typing.rst:1688 +#: ../../library/typing.rst:1717 msgid "" "``Unpack`` can also be used along with :class:`typing.TypedDict` for typing " "``**kwargs`` in a function signature::" msgstr "" -#: ../../library/typing.rst:1691 +#: ../../library/typing.rst:1720 msgid "" "from typing import TypedDict, Unpack\n" "\n" @@ -2915,23 +2963,23 @@ msgid "" "def foo(**kwargs: Unpack[Movie]): ..." msgstr "" -#: ../../library/typing.rst:1701 +#: ../../library/typing.rst:1730 msgid "" "See :pep:`692` for more details on using ``Unpack`` for ``**kwargs`` typing." msgstr "" -#: ../../library/typing.rst:1706 +#: ../../library/typing.rst:1735 msgid "Building generic types and type aliases" msgstr "" -#: ../../library/typing.rst:1708 +#: ../../library/typing.rst:1737 msgid "" "The following classes should not be used directly as annotations. Their " "intended purpose is to be building blocks for creating generic types and " "type aliases." msgstr "" -#: ../../library/typing.rst:1712 +#: ../../library/typing.rst:1741 msgid "" "These objects can be created through special syntax (:ref:`type parameter " "lists ` and the :keyword:`type` statement). For compatibility " @@ -2939,17 +2987,17 @@ msgid "" "syntax, as documented below." msgstr "" -#: ../../library/typing.rst:1719 +#: ../../library/typing.rst:1748 msgid "Abstract base class for generic types." msgstr "" -#: ../../library/typing.rst:1721 +#: ../../library/typing.rst:1750 msgid "" "A generic type is typically declared by adding a list of type parameters " "after the class name::" msgstr "" -#: ../../library/typing.rst:1724 +#: ../../library/typing.rst:1753 msgid "" "class Mapping[KT, VT]:\n" " def __getitem__(self, key: KT) -> VT:\n" @@ -2961,17 +3009,17 @@ msgstr "" " ...\n" " # Etc." -#: ../../library/typing.rst:1729 +#: ../../library/typing.rst:1758 msgid "" "Such a class implicitly inherits from ``Generic``. The runtime semantics of " "this syntax are discussed in the :ref:`Language Reference `." msgstr "" -#: ../../library/typing.rst:1733 +#: ../../library/typing.rst:1762 msgid "This class can then be used as follows::" msgstr "" -#: ../../library/typing.rst:1735 +#: ../../library/typing.rst:1764 msgid "" "def lookup_name[X, Y](mapping: Mapping[X, Y], key: X, default: Y) -> Y:\n" " try:\n" @@ -2985,20 +3033,20 @@ msgstr "" " except KeyError:\n" " return default" -#: ../../library/typing.rst:1741 +#: ../../library/typing.rst:1770 msgid "" "Here the brackets after the function name indicate a :ref:`generic function " "`." msgstr "" -#: ../../library/typing.rst:1744 +#: ../../library/typing.rst:1773 msgid "" "For backwards compatibility, generic classes can also be declared by " "explicitly inheriting from ``Generic``. In this case, the type parameters " "must be declared separately::" msgstr "" -#: ../../library/typing.rst:1749 +#: ../../library/typing.rst:1778 msgid "" "KT = TypeVar('KT')\n" "VT = TypeVar('VT')\n" @@ -3016,18 +3064,18 @@ msgstr "" " ...\n" " # Etc." -#: ../../library/typing.rst:1761 +#: ../../library/typing.rst:1790 msgid "Type variable." msgstr "" -#: ../../library/typing.rst:1763 +#: ../../library/typing.rst:1792 msgid "" "The preferred way to construct a type variable is via the dedicated syntax " "for :ref:`generic functions `, :ref:`generic classes " "`, and :ref:`generic type aliases `::" msgstr "" -#: ../../library/typing.rst:1768 +#: ../../library/typing.rst:1797 msgid "" "class Sequence[T]: # T is a TypeVar\n" " ..." @@ -3035,13 +3083,13 @@ msgstr "" "class Sequence[T]: # T 是一個 TypeVar\n" " ..." -#: ../../library/typing.rst:1771 +#: ../../library/typing.rst:1800 msgid "" "This syntax can also be used to create bounded and constrained type " "variables::" msgstr "" -#: ../../library/typing.rst:1774 +#: ../../library/typing.rst:1803 msgid "" "class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound;\n" " ... # we can say that S is \"bounded by `str`\"\n" @@ -3052,13 +3100,13 @@ msgid "" " ..." msgstr "" -#: ../../library/typing.rst:1781 +#: ../../library/typing.rst:1810 msgid "" "However, if desired, reusable type variables can also be constructed " "manually, like so::" msgstr "" -#: ../../library/typing.rst:1783 +#: ../../library/typing.rst:1812 msgid "" "T = TypeVar('T') # Can be anything\n" "S = TypeVar('S', bound=str) # Can be any subtype of str\n" @@ -3068,7 +3116,7 @@ msgstr "" "S = TypeVar('S', bound=str) # 可以是任何 str 的子型別\n" "A = TypeVar('A', str, bytes) # 必須是 str 或 bytes" -#: ../../library/typing.rst:1787 +#: ../../library/typing.rst:1816 msgid "" "Type variables exist primarily for the benefit of static type checkers. " "They serve as the parameters for generic types as well as for generic " @@ -3076,7 +3124,7 @@ msgid "" "information on generic types. Generic functions work as follows::" msgstr "" -#: ../../library/typing.rst:1793 +#: ../../library/typing.rst:1822 msgid "" "def repeat[T](x: T, n: int) -> Sequence[T]:\n" " \"\"\"Return a list containing n references to x.\"\"\"\n" @@ -3094,13 +3142,13 @@ msgid "" " return x + y" msgstr "" -#: ../../library/typing.rst:1808 +#: ../../library/typing.rst:1837 msgid "" "Note that type variables can be *bounded*, *constrained*, or neither, but " "cannot be both bounded *and* constrained." msgstr "" -#: ../../library/typing.rst:1811 +#: ../../library/typing.rst:1840 msgid "" "The variance of type variables is inferred by type checkers when they are " "created through the :ref:`type parameter syntax ` or when " @@ -3110,14 +3158,14 @@ msgid "" "invariant. See :pep:`484` and :pep:`695` for more details." msgstr "" -#: ../../library/typing.rst:1819 +#: ../../library/typing.rst:1848 msgid "" "Bounded type variables and constrained type variables have different " "semantics in several important ways. Using a *bounded* type variable means " "that the ``TypeVar`` will be solved using the most specific type possible::" msgstr "" -#: ../../library/typing.rst:1823 +#: ../../library/typing.rst:1852 msgid "" "x = print_capitalized('a string')\n" "reveal_type(x) # revealed type is str\n" @@ -3131,13 +3179,13 @@ msgid "" "z = print_capitalized(45) # error: int is not a subtype of str" msgstr "" -#: ../../library/typing.rst:1834 +#: ../../library/typing.rst:1863 msgid "" "The upper bound of a type variable can be a concrete type, abstract type " "(ABC or Protocol), or even a union of types::" msgstr "" -#: ../../library/typing.rst:1837 +#: ../../library/typing.rst:1866 msgid "" "# Can be anything with an __abs__ method\n" "def print_abs[T: SupportsAbs](arg: T) -> None:\n" @@ -3148,13 +3196,13 @@ msgid "" "V = TypeVar('V', bound=SupportsAbs) # Can be anything with an __abs__ method" msgstr "" -#: ../../library/typing.rst:1846 +#: ../../library/typing.rst:1875 msgid "" "Using a *constrained* type variable, however, means that the ``TypeVar`` can " "only ever be solved as being exactly one of the constraints given::" msgstr "" -#: ../../library/typing.rst:1849 +#: ../../library/typing.rst:1878 msgid "" "a = concatenate('one', 'two')\n" "reveal_type(a) # revealed type is str\n" @@ -3167,39 +3215,39 @@ msgid "" "or bytes in a function call, but not both" msgstr "" -#: ../../library/typing.rst:1857 +#: ../../library/typing.rst:1886 msgid "At runtime, ``isinstance(x, T)`` will raise :exc:`TypeError`." msgstr "在 runtime ``isinstance(x, T)`` 會引發 :exc:`TypeError`。" -#: ../../library/typing.rst:1861 +#: ../../library/typing.rst:1890 msgid "The name of the type variable." msgstr "" -#: ../../library/typing.rst:1865 +#: ../../library/typing.rst:1894 msgid "Whether the type var has been explicitly marked as covariant." msgstr "" -#: ../../library/typing.rst:1869 +#: ../../library/typing.rst:1898 msgid "Whether the type var has been explicitly marked as contravariant." msgstr "" -#: ../../library/typing.rst:1873 +#: ../../library/typing.rst:1902 msgid "" "Whether the type variable's variance should be inferred by type checkers." msgstr "" -#: ../../library/typing.rst:1879 +#: ../../library/typing.rst:1908 msgid "The upper bound of the type variable, if any." msgstr "" -#: ../../library/typing.rst:1883 +#: ../../library/typing.rst:1912 msgid "" "For type variables created through :ref:`type parameter syntax `, the bound is evaluated only when the attribute is accessed, not " "when the type variable is created (see :ref:`lazy-evaluation`)." msgstr "" -#: ../../library/typing.rst:1889 +#: ../../library/typing.rst:1918 msgid "" "An :term:`evaluate function` corresponding to the :attr:`~TypeVar.__bound__` " "attribute. When called directly, this method supports only the :attr:" @@ -3209,18 +3257,18 @@ msgid "" "in a different format." msgstr "" -#: ../../library/typing.rst:1899 +#: ../../library/typing.rst:1928 msgid "A tuple containing the constraints of the type variable, if any." msgstr "" -#: ../../library/typing.rst:1903 +#: ../../library/typing.rst:1932 msgid "" "For type variables created through :ref:`type parameter syntax `, the constraints are evaluated only when the attribute is accessed, " "not when the type variable is created (see :ref:`lazy-evaluation`)." msgstr "" -#: ../../library/typing.rst:1909 +#: ../../library/typing.rst:1938 msgid "" "An :term:`evaluate function` corresponding to the :attr:`~TypeVar." "__constraints__` attribute. When called directly, this method supports only " @@ -3230,13 +3278,13 @@ msgid "" "to evaluate the value in a different format." msgstr "" -#: ../../library/typing.rst:1919 +#: ../../library/typing.rst:1948 msgid "" "The default value of the type variable, or :data:`typing.NoDefault` if it " "has no default." msgstr "" -#: ../../library/typing.rst:1926 +#: ../../library/typing.rst:1955 msgid "" "An :term:`evaluate function` corresponding to the :attr:`~TypeVar." "__default__` attribute. When called directly, this method supports only the :" @@ -3246,7 +3294,7 @@ msgid "" "the value in a different format." msgstr "" -#: ../../library/typing.rst:1936 +#: ../../library/typing.rst:1965 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." @@ -3254,31 +3302,31 @@ msgid "" "`lazily evaluated ` default value." msgstr "" -#: ../../library/typing.rst:1945 +#: ../../library/typing.rst:1974 msgid "" "Type variables can now be declared using the :ref:`type parameter ` syntax introduced by :pep:`695`. The ``infer_variance`` parameter " "was added." msgstr "" -#: ../../library/typing.rst:1951 ../../library/typing.rst:2100 -#: ../../library/typing.rst:2212 +#: ../../library/typing.rst:1980 ../../library/typing.rst:2152 +#: ../../library/typing.rst:2283 msgid "Support for default values was added." msgstr "新增對預設值的支援。" -#: ../../library/typing.rst:1957 +#: ../../library/typing.rst:1986 msgid "" "Type variable tuple. A specialized form of :ref:`type variable ` " "that enables *variadic* generics." msgstr "" -#: ../../library/typing.rst:1960 +#: ../../library/typing.rst:1989 msgid "" "Type variable tuples can be declared in :ref:`type parameter lists ` using a single asterisk (``*``) before the name::" msgstr "" -#: ../../library/typing.rst:1963 +#: ../../library/typing.rst:1992 msgid "" "def move_first_element_to_last[T, *Ts](tup: tuple[T, *Ts]) -> tuple[*Ts, " "T]:\n" @@ -3288,11 +3336,11 @@ msgstr "" "T]:\n" " return (*tup[1:], tup[0])" -#: ../../library/typing.rst:1966 +#: ../../library/typing.rst:1995 msgid "Or by explicitly invoking the ``TypeVarTuple`` constructor::" msgstr "" -#: ../../library/typing.rst:1968 +#: ../../library/typing.rst:1997 msgid "" "T = TypeVar(\"T\")\n" "Ts = TypeVarTuple(\"Ts\")\n" @@ -3306,7 +3354,7 @@ msgstr "" "def move_first_element_to_last(tup: tuple[T, *Ts]) -> tuple[*Ts, T]:\n" " return (*tup[1:], tup[0])" -#: ../../library/typing.rst:1974 +#: ../../library/typing.rst:2003 msgid "" "A normal type variable enables parameterization with a single type. A type " "variable tuple, in contrast, allows parameterization with an *arbitrary* " @@ -3314,7 +3362,7 @@ msgid "" "wrapped in a tuple. For example::" msgstr "" -#: ../../library/typing.rst:1979 +#: ../../library/typing.rst:2008 msgid "" "# T is bound to int, Ts is bound to ()\n" "# Return value is (1,), which has type tuple[int]\n" @@ -3334,7 +3382,7 @@ msgid "" "move_first_element_to_last(tup=())" msgstr "" -#: ../../library/typing.rst:1996 +#: ../../library/typing.rst:2025 msgid "" "Note the use of the unpacking operator ``*`` in ``tuple[T, *Ts]``. " "Conceptually, you can think of ``Ts`` as a tuple of type variables ``(T1, " @@ -3344,13 +3392,13 @@ msgid "" "` instead, as ``Unpack[Ts]``.)" msgstr "" -#: ../../library/typing.rst:2004 +#: ../../library/typing.rst:2033 msgid "" "Type variable tuples must *always* be unpacked. This helps distinguish type " "variable tuples from normal type variables::" msgstr "" -#: ../../library/typing.rst:2007 +#: ../../library/typing.rst:2036 msgid "" "x: Ts # Not valid\n" "x: tuple[Ts] # Not valid\n" @@ -3360,13 +3408,13 @@ msgstr "" "x: tuple[Ts] # 無效\n" "x: tuple[*Ts] # 正確的做法" -#: ../../library/typing.rst:2011 +#: ../../library/typing.rst:2040 msgid "" "Type variable tuples can be used in the same contexts as normal type " "variables. For example, in class definitions, arguments, and return types::" msgstr "" -#: ../../library/typing.rst:2014 +#: ../../library/typing.rst:2043 msgid "" "class Array[*Shape]:\n" " def __getitem__(self, key: tuple[*Shape]) -> float: ...\n" @@ -3378,12 +3426,12 @@ msgstr "" " def __abs__(self) -> \"Array[*Shape]\": ...\n" " def get_shape(self) -> tuple[*Shape]: ..." -#: ../../library/typing.rst:2019 +#: ../../library/typing.rst:2048 msgid "" "Type variable tuples can be happily combined with normal type variables:" msgstr "" -#: ../../library/typing.rst:2021 +#: ../../library/typing.rst:2050 msgid "" "class Array[DType, *Shape]: # This is fine\n" " pass\n" @@ -3398,13 +3446,13 @@ msgid "" "int_array_2d: Array[int, Height, Width] = Array() # Yup, fine too" msgstr "" -#: ../../library/typing.rst:2035 +#: ../../library/typing.rst:2064 msgid "" "However, note that at most one type variable tuple may appear in a single " "list of type arguments or type parameters::" msgstr "" -#: ../../library/typing.rst:2038 +#: ../../library/typing.rst:2067 msgid "" "x: tuple[*Ts, *Ts] # Not valid\n" "class Array[*Shape, *Shape]: # Not valid\n" @@ -3414,13 +3462,13 @@ msgstr "" "class Array[*Shape, *Shape]: # 無效\n" " pass" -#: ../../library/typing.rst:2042 +#: ../../library/typing.rst:2071 msgid "" "Finally, an unpacked type variable tuple can be used as the type annotation " "of ``*args``::" msgstr "" -#: ../../library/typing.rst:2045 +#: ../../library/typing.rst:2074 msgid "" "def call_soon[*Ts](\n" " callback: Callable[[*Ts], None],\n" @@ -3436,7 +3484,7 @@ msgstr "" " ...\n" " callback(*args)" -#: ../../library/typing.rst:2052 +#: ../../library/typing.rst:2081 msgid "" "In contrast to non-unpacked annotations of ``*args`` - e.g. ``*args: int``, " "which would specify that *all* arguments are ``int`` - ``*args: *Ts`` " @@ -3445,21 +3493,37 @@ msgid "" "``call_soon`` match the types of the (positional) arguments of ``callback``." msgstr "" -#: ../../library/typing.rst:2059 +#: ../../library/typing.rst:2088 msgid "See :pep:`646` for more details on type variable tuples." msgstr "" -#: ../../library/typing.rst:2063 +#: ../../library/typing.rst:2092 msgid "The name of the type variable tuple." msgstr "" -#: ../../library/typing.rst:2067 +#: ../../library/typing.rst:2096 +msgid "" +"Whether the type variable tuple has been explicitly marked as covariant." +msgstr "" + +#: ../../library/typing.rst:2102 +msgid "" +"Whether the type variable tuple has been explicitly marked as contravariant." +msgstr "" + +#: ../../library/typing.rst:2108 +msgid "" +"Whether the type variable tuple's variance should be inferred by type " +"checkers." +msgstr "" + +#: ../../library/typing.rst:2114 msgid "" "The default value of the type variable tuple, or :data:`typing.NoDefault` if " "it has no default." msgstr "" -#: ../../library/typing.rst:2074 +#: ../../library/typing.rst:2121 msgid "" "An :term:`evaluate function` corresponding to the :attr:`~TypeVarTuple." "__default__` attribute. When called directly, this method supports only the :" @@ -3469,7 +3533,7 @@ msgid "" "evaluate the value in a different format." msgstr "" -#: ../../library/typing.rst:2084 +#: ../../library/typing.rst:2131 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." @@ -3477,39 +3541,53 @@ msgid "" "`lazily evaluated ` default value." msgstr "" -#: ../../library/typing.rst:2095 +#: ../../library/typing.rst:2138 +msgid "" +"Type variable tuples 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`, but its actual semantics are yet to be decided." +msgstr "" + +#: ../../library/typing.rst:2147 msgid "" "Type variable tuples can now be declared using the :ref:`type parameter " "` syntax introduced by :pep:`695`." msgstr "" -#: ../../library/typing.rst:2104 +#: ../../library/typing.rst:2156 +msgid "" +"Added support for the ``bound``, ``covariant``, ``contravariant``, and " +"``infer_variance`` parameters." +msgstr "" + +#: ../../library/typing.rst:2161 msgid "" "Parameter specification variable. A specialized version of :ref:`type " "variables `." msgstr "" -#: ../../library/typing.rst:2107 +#: ../../library/typing.rst:2164 msgid "" "In :ref:`type parameter lists `, parameter specifications can " "be declared with two asterisks (``**``)::" msgstr "" -#: ../../library/typing.rst:2110 +#: ../../library/typing.rst:2167 msgid "type IntFunc[**P] = Callable[P, int]" msgstr "type IntFunc[**P] = Callable[P, int]" -#: ../../library/typing.rst:2112 +#: ../../library/typing.rst:2169 msgid "" "For compatibility with Python 3.11 and earlier, ``ParamSpec`` objects can " "also be created as follows::" msgstr "" -#: ../../library/typing.rst:2115 +#: ../../library/typing.rst:2172 msgid "P = ParamSpec('P')" msgstr "P = ParamSpec('P')" -#: ../../library/typing.rst:2117 +#: ../../library/typing.rst:2174 msgid "" "Parameter specification variables exist primarily for the benefit of static " "type checkers. They are used to forward the parameter types of one callable " @@ -3519,7 +3597,7 @@ msgid "" "See :class:`Generic` for more information on generic types." msgstr "" -#: ../../library/typing.rst:2124 +#: ../../library/typing.rst:2181 msgid "" "For example, to add basic logging to a function, one can create a decorator " "``add_logging`` to log function calls. The parameter specification variable " @@ -3527,7 +3605,7 @@ msgid "" "new callable returned by it have inter-dependent type parameters::" msgstr "" -#: ../../library/typing.rst:2129 +#: ../../library/typing.rst:2186 msgid "" "from collections.abc import Callable\n" "import logging\n" @@ -3545,27 +3623,27 @@ msgid "" " return x + y" msgstr "" -#: ../../library/typing.rst:2144 +#: ../../library/typing.rst:2201 msgid "" "Without ``ParamSpec``, the simplest way to annotate this previously was to " "use a :class:`TypeVar` with upper bound ``Callable[..., Any]``. However " "this causes two problems:" msgstr "" -#: ../../library/typing.rst:2148 +#: ../../library/typing.rst:2205 msgid "" "The type checker can't type check the ``inner`` function because ``*args`` " "and ``**kwargs`` have to be typed :data:`Any`." msgstr "" -#: ../../library/typing.rst:2150 +#: ../../library/typing.rst:2207 msgid "" ":func:`~cast` may be required in the body of the ``add_logging`` decorator " "when returning the ``inner`` function, or the static type checker must be " "told to ignore the ``return inner``." msgstr "" -#: ../../library/typing.rst:2157 +#: ../../library/typing.rst:2214 msgid "" "Since ``ParamSpec`` captures both positional and keyword parameters, ``P." "args`` and ``P.kwargs`` can be used to split a ``ParamSpec`` into its " @@ -3578,17 +3656,34 @@ msgid "" "`ParamSpecKwargs`." msgstr "" -#: ../../library/typing.rst:2169 +#: ../../library/typing.rst:2226 msgid "The name of the parameter specification." msgstr "" -#: ../../library/typing.rst:2173 +#: ../../library/typing.rst:2230 +msgid "" +"Whether the parameter specification has been explicitly marked as covariant." +msgstr "" + +#: ../../library/typing.rst:2234 +msgid "" +"Whether the parameter specification has been explicitly marked as " +"contravariant." +msgstr "" + +#: ../../library/typing.rst:2238 +msgid "" +"Whether the parameter specification's variance should be inferred by type " +"checkers." +msgstr "" + +#: ../../library/typing.rst:2244 msgid "" "The default value of the parameter specification, or :data:`typing." "NoDefault` if it has no default." msgstr "" -#: ../../library/typing.rst:2180 +#: ../../library/typing.rst:2251 msgid "" "An :term:`evaluate function` corresponding to the :attr:`~ParamSpec." "__default__` attribute. When called directly, this method supports only the :" @@ -3598,7 +3693,7 @@ msgid "" "the value in a different format." msgstr "" -#: ../../library/typing.rst:2190 +#: ../../library/typing.rst:2261 msgid "" "Return whether or not the parameter specification has a default value. This " "is equivalent to checking whether :attr:`__default__` is not the :data:" @@ -3606,7 +3701,7 @@ msgid "" "the :ref:`lazily evaluated ` default value." msgstr "" -#: ../../library/typing.rst:2197 +#: ../../library/typing.rst:2268 msgid "" "Parameter specification variables created with ``covariant=True`` or " "``contravariant=True`` can be used to declare covariant or contravariant " @@ -3615,23 +3710,23 @@ msgid "" "decided." msgstr "" -#: ../../library/typing.rst:2207 +#: ../../library/typing.rst:2278 msgid "" "Parameter specifications can now be declared using the :ref:`type parameter " "` syntax introduced by :pep:`695`." msgstr "" -#: ../../library/typing.rst:2215 +#: ../../library/typing.rst:2286 msgid "" "Only parameter specification variables defined in global scope can be " "pickled." msgstr "" -#: ../../library/typing.rst:2221 +#: ../../library/typing.rst:2292 msgid ":data:`Concatenate`" msgstr ":data:`Concatenate`" -#: ../../library/typing.rst:2227 +#: ../../library/typing.rst:2298 msgid "" "Arguments and keyword arguments attributes of a :class:`ParamSpec`. The ``P." "args`` attribute of a ``ParamSpec`` is an instance of ``ParamSpecArgs``, and " @@ -3639,13 +3734,13 @@ msgid "" "runtime introspection and have no special meaning to static type checkers." msgstr "" -#: ../../library/typing.rst:2232 +#: ../../library/typing.rst:2303 msgid "" "Calling :func:`get_origin` on either of these objects will return the " "original ``ParamSpec``:" msgstr "" -#: ../../library/typing.rst:2235 +#: ../../library/typing.rst:2306 msgid "" ">>> from typing import ParamSpec, get_origin\n" ">>> P = ParamSpec(\"P\")\n" @@ -3661,11 +3756,11 @@ msgstr "" ">>> get_origin(P.kwargs) is P\n" "True" -#: ../../library/typing.rst:2249 +#: ../../library/typing.rst:2320 msgid "The type of type aliases created through the :keyword:`type` statement." msgstr "" -#: ../../library/typing.rst:2253 +#: ../../library/typing.rst:2324 msgid "" ">>> type Alias = int\n" ">>> type(Alias)\n" @@ -3675,11 +3770,11 @@ msgstr "" ">>> type(Alias)\n" "" -#: ../../library/typing.rst:2263 +#: ../../library/typing.rst:2334 msgid "The name of the type alias:" msgstr "" -#: ../../library/typing.rst:2265 +#: ../../library/typing.rst:2336 msgid "" ">>> type Alias = int\n" ">>> Alias.__name__\n" @@ -3689,11 +3784,29 @@ msgstr "" ">>> Alias.__name__\n" "'Alias'" -#: ../../library/typing.rst:2273 +#: ../../library/typing.rst:2344 +msgid "The :term:`qualified name` of the type alias:" +msgstr "" + +#: ../../library/typing.rst:2346 +msgid "" +">>> class Class:\n" +"... type Alias = int\n" +"...\n" +">>> Class.Alias.__qualname__\n" +"'Class.Alias'" +msgstr "" +">>> class Class:\n" +"... type Alias = int\n" +"...\n" +">>> Class.Alias.__qualname__\n" +"'Class.Alias'" + +#: ../../library/typing.rst:2358 msgid "The name of the module in which the type alias was defined::" msgstr "" -#: ../../library/typing.rst:2275 +#: ../../library/typing.rst:2360 msgid "" ">>> type Alias = int\n" ">>> Alias.__module__\n" @@ -3703,13 +3816,21 @@ msgstr "" ">>> Alias.__module__\n" "'__main__'" -#: ../../library/typing.rst:2281 +#: ../../library/typing.rst:2364 +msgid "This attribute is writable." +msgstr "" + +#: ../../library/typing.rst:2368 +msgid "The attribute is now writable." +msgstr "" + +#: ../../library/typing.rst:2372 msgid "" "The type parameters of the type alias, or an empty tuple if the alias is not " "generic:" msgstr "" -#: ../../library/typing.rst:2284 +#: ../../library/typing.rst:2375 msgid "" ">>> type ListOrSet[T] = list[T] | set[T]\n" ">>> ListOrSet.__type_params__\n" @@ -3725,14 +3846,14 @@ msgstr "" ">>> NotGeneric.__type_params__\n" "()" -#: ../../library/typing.rst:2295 +#: ../../library/typing.rst:2386 msgid "" "The type alias's value. This is :ref:`lazily evaluated `, " "so names used in the definition of the alias are not resolved until the " "``__value__`` attribute is accessed:" msgstr "" -#: ../../library/typing.rst:2299 +#: ../../library/typing.rst:2390 msgid "" ">>> type Mutually = Recursive\n" ">>> type Recursive = Mutually\n" @@ -3756,7 +3877,7 @@ msgstr "" ">>> Recursive.__value__\n" "Mutually" -#: ../../library/typing.rst:2314 +#: ../../library/typing.rst:2405 msgid "" "An :term:`evaluate function` corresponding to the :attr:`__value__` " "attribute. When called directly, this method supports only the :attr:" @@ -3766,7 +3887,7 @@ msgid "" "different format:" msgstr "" -#: ../../library/typing.rst:2320 +#: ../../library/typing.rst:2411 msgid "" ">>> type Alias = undefined\n" ">>> Alias.__value__\n" @@ -3794,17 +3915,17 @@ msgstr "" ">>> call_evaluate_function(Alias.evaluate_value, Format.FORWARDREF)\n" "ForwardRef('undefined')" -#: ../../library/typing.rst:2338 +#: ../../library/typing.rst:2429 msgid "Unpacking" msgstr "" -#: ../../library/typing.rst:2339 +#: ../../library/typing.rst:2430 msgid "" "Type aliases support star unpacking using the ``*Alias`` syntax. This is " "equivalent to using ``Unpack[Alias]`` directly:" msgstr "" -#: ../../library/typing.rst:2342 +#: ../../library/typing.rst:2433 msgid "" ">>> type Alias = tuple[int, str]\n" ">>> type Unpacked = tuple[bool, *Alias]\n" @@ -3816,27 +3937,27 @@ msgstr "" ">>> Unpacked.__value__\n" "tuple[bool, typing.Unpack[Alias]]" -#: ../../library/typing.rst:2353 +#: ../../library/typing.rst:2444 msgid "Other special directives" msgstr "" -#: ../../library/typing.rst:2355 +#: ../../library/typing.rst:2446 msgid "" "These functions and classes should not be used directly as annotations. " "Their intended purpose is to be building blocks for creating and declaring " "types." msgstr "" -#: ../../library/typing.rst:2361 +#: ../../library/typing.rst:2452 msgid "Typed version of :func:`collections.namedtuple`." msgstr "" -#: ../../library/typing.rst:2363 ../../library/typing.rst:2463 -#: ../../library/typing.rst:3611 +#: ../../library/typing.rst:2454 ../../library/typing.rst:2541 +#: ../../library/typing.rst:3779 msgid "Usage::" msgstr "用法: ::" -#: ../../library/typing.rst:2365 +#: ../../library/typing.rst:2456 msgid "" "class Employee(NamedTuple):\n" " name: str\n" @@ -3846,20 +3967,20 @@ msgstr "" " name: str\n" " id: int" -#: ../../library/typing.rst:2369 +#: ../../library/typing.rst:2460 msgid "This is equivalent to::" msgstr "這等價於: ::" -#: ../../library/typing.rst:2371 +#: ../../library/typing.rst:2462 msgid "Employee = collections.namedtuple('Employee', ['name', 'id'])" msgstr "Employee = collections.namedtuple('Employee', ['name', 'id'])" -#: ../../library/typing.rst:2373 +#: ../../library/typing.rst:2464 msgid "" "To give a field a default value, you can assign to it in the class body::" msgstr "" -#: ../../library/typing.rst:2375 +#: ../../library/typing.rst:2466 msgid "" "class Employee(NamedTuple):\n" " name: str\n" @@ -3875,12 +3996,12 @@ msgstr "" "employee = Employee('Guido')\n" "assert employee.id == 3" -#: ../../library/typing.rst:2382 +#: ../../library/typing.rst:2473 msgid "" "Fields with a default value must come after any fields without a default." msgstr "" -#: ../../library/typing.rst:2384 +#: ../../library/typing.rst:2475 msgid "" "The types for each field name can be retrieved by calling :func:" "`annotationlib.get_annotations` on the resulting class. (The field names are " @@ -3889,11 +4010,11 @@ msgid "" "`~collections.namedtuple` API.)" msgstr "" -#: ../../library/typing.rst:2390 +#: ../../library/typing.rst:2481 msgid "``NamedTuple`` subclasses can also have docstrings and methods::" msgstr "" -#: ../../library/typing.rst:2392 +#: ../../library/typing.rst:2483 msgid "" "class Employee(NamedTuple):\n" " \"\"\"Represents an employee.\"\"\"\n" @@ -3904,11 +4025,11 @@ msgid "" " return f''" msgstr "" -#: ../../library/typing.rst:2400 +#: ../../library/typing.rst:2491 msgid "``NamedTuple`` subclasses can be generic::" msgstr "" -#: ../../library/typing.rst:2402 +#: ../../library/typing.rst:2493 msgid "" "class Group[T](NamedTuple):\n" " key: T\n" @@ -3918,11 +4039,11 @@ msgstr "" " key: T\n" " group: list[T]" -#: ../../library/typing.rst:2406 +#: ../../library/typing.rst:2497 msgid "Backward-compatible usage::" msgstr "" -#: ../../library/typing.rst:2408 +#: ../../library/typing.rst:2499 msgid "" "# For creating a generic NamedTuple on Python 3.11\n" "T = TypeVar(\"T\")\n" @@ -3935,102 +4056,85 @@ msgid "" "Employee = NamedTuple('Employee', [('name', str), ('id', int)])" msgstr "" -#: ../../library/typing.rst:2418 +#: ../../library/typing.rst:2509 msgid "Added support for :pep:`526` variable annotation syntax." msgstr "" -#: ../../library/typing.rst:2421 +#: ../../library/typing.rst:2512 msgid "Added support for default values, methods, and docstrings." msgstr "" -#: ../../library/typing.rst:2424 +#: ../../library/typing.rst:2515 msgid "" "The ``_field_types`` and ``__annotations__`` attributes are now regular " "dictionaries instead of instances of ``OrderedDict``." msgstr "" -#: ../../library/typing.rst:2428 +#: ../../library/typing.rst:2519 msgid "" "Removed the ``_field_types`` attribute in favor of the more standard " "``__annotations__`` attribute which has the same information." msgstr "" -#: ../../library/typing.rst:2432 +#: ../../library/typing.rst:2523 msgid "" "``NamedTuple`` is now a function rather than a class. It can still be used " "as a class base, as described above." msgstr "" -#: ../../library/typing.rst:2436 +#: ../../library/typing.rst:2527 msgid "Added support for generic namedtuples." msgstr "" -#: ../../library/typing.rst:2439 +#: ../../library/typing.rst:2530 msgid "" "Using :func:`super` (and the ``__class__`` :term:`closure variable`) in " "methods of ``NamedTuple`` subclasses is unsupported and causes a :class:" "`TypeError`." msgstr "" -#: ../../library/typing.rst:2443 -msgid "" -"The undocumented keyword argument syntax for creating NamedTuple classes " -"(``NT = NamedTuple(\"NT\", x=int)``) is deprecated, and will be disallowed " -"in 3.15. Use the class-based syntax or the functional syntax instead." -msgstr "" - -#: ../../library/typing.rst:2448 -msgid "" -"When using the functional syntax to create a NamedTuple class, failing to " -"pass a value to the 'fields' parameter (``NT = NamedTuple(\"NT\")``) is " -"deprecated. Passing ``None`` to the 'fields' parameter (``NT = " -"NamedTuple(\"NT\", None)``) is also deprecated. Both will be disallowed in " -"Python 3.15. To create a NamedTuple class with 0 fields, use ``class " -"NT(NamedTuple): pass`` or ``NT = NamedTuple(\"NT\", [])``." -msgstr "" - -#: ../../library/typing.rst:2458 +#: ../../library/typing.rst:2536 msgid "Helper class to create low-overhead :ref:`distinct types `." msgstr "" -#: ../../library/typing.rst:2460 +#: ../../library/typing.rst:2538 msgid "" "A ``NewType`` is considered a distinct type by a type checker. At runtime, " "however, calling a ``NewType`` returns its argument unchanged." msgstr "" -#: ../../library/typing.rst:2465 +#: ../../library/typing.rst:2543 msgid "" "UserId = NewType('UserId', int) # Declare the NewType \"UserId\"\n" "first_user = UserId(1) # \"UserId\" returns the argument unchanged at " "runtime" msgstr "" -#: ../../library/typing.rst:2470 +#: ../../library/typing.rst:2548 msgid "The name of the module in which the new type is defined." msgstr "" -#: ../../library/typing.rst:2474 +#: ../../library/typing.rst:2552 msgid "The name of the new type." msgstr "" -#: ../../library/typing.rst:2478 +#: ../../library/typing.rst:2556 msgid "The type that the new type is based on." msgstr "" -#: ../../library/typing.rst:2482 +#: ../../library/typing.rst:2560 msgid "``NewType`` is now a class rather than a function." msgstr "" -#: ../../library/typing.rst:2487 +#: ../../library/typing.rst:2565 msgid "Base class for protocol classes." msgstr "" -#: ../../library/typing.rst:2489 +#: ../../library/typing.rst:2567 msgid "Protocol classes are defined like this::" msgstr "" -#: ../../library/typing.rst:2491 +#: ../../library/typing.rst:2569 msgid "" "class Proto(Protocol):\n" " def meth(self) -> int:\n" @@ -4040,13 +4144,13 @@ msgstr "" " def meth(self) -> int:\n" " ..." -#: ../../library/typing.rst:2495 +#: ../../library/typing.rst:2573 msgid "" "Such classes are primarily used with static type checkers that recognize " "structural subtyping (static duck-typing), for example::" msgstr "" -#: ../../library/typing.rst:2498 +#: ../../library/typing.rst:2576 msgid "" "class C:\n" " def meth(self) -> int:\n" @@ -4058,7 +4162,7 @@ msgid "" "func(C()) # Passes static type check" msgstr "" -#: ../../library/typing.rst:2507 +#: ../../library/typing.rst:2585 msgid "" "See :pep:`544` for more details. Protocol classes decorated with :deco:" "`runtime_checkable` (described later) act as simple-minded runtime protocols " @@ -4067,11 +4171,11 @@ msgid "" "second argument to :func:`isinstance` or :func:`issubclass`." msgstr "" -#: ../../library/typing.rst:2513 +#: ../../library/typing.rst:2591 msgid "Protocol classes can be generic, for example::" msgstr "" -#: ../../library/typing.rst:2515 +#: ../../library/typing.rst:2593 msgid "" "class GenProto[T](Protocol):\n" " def meth(self) -> T:\n" @@ -4081,13 +4185,13 @@ msgstr "" " def meth(self) -> T:\n" " ..." -#: ../../library/typing.rst:2519 +#: ../../library/typing.rst:2597 msgid "" "In code that needs to be compatible with Python 3.11 or older, generic " "Protocols can be written as follows::" msgstr "" -#: ../../library/typing.rst:2522 +#: ../../library/typing.rst:2600 msgid "" "T = TypeVar(\"T\")\n" "\n" @@ -4101,11 +4205,19 @@ msgstr "" " def meth(self) -> T:\n" " ..." -#: ../../library/typing.rst:2532 +#: ../../library/typing.rst:2608 ../../library/typing.rst:2687 +msgid "" +"It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on " +"protocol classes that were not explicitly decorated with :func:`!" +"runtime_checkable` but that inherit from a runtime-checkable protocol class. " +"This will throw a :exc:`TypeError` in Python 3.20." +msgstr "" + +#: ../../library/typing.rst:2616 msgid "Mark a protocol class as a runtime protocol." msgstr "" -#: ../../library/typing.rst:2534 +#: ../../library/typing.rst:2618 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 " @@ -4113,7 +4225,7 @@ msgid "" "Iterable`. For example::" msgstr "" -#: ../../library/typing.rst:2538 +#: ../../library/typing.rst:2622 msgid "" "@runtime_checkable\n" "class Closable(Protocol):\n" @@ -4141,12 +4253,40 @@ msgstr "" "import threading\n" "assert isinstance(threading.Thread(name='Bob'), Named)" -#: ../../library/typing.rst:2551 +#: ../../library/typing.rst:2635 +msgid "" +"Runtime checkability of protocols is not inherited. A subclass of a runtime-" +"checkable protocol is only runtime-checkable if it is explicitly marked as " +"such, regardless of class hierarchy::" +msgstr "" + +#: ../../library/typing.rst:2638 +msgid "" +"@runtime_checkable\n" +"class Iterable(Protocol):\n" +" def __iter__(self): ...\n" +"\n" +"# Without @runtime_checkable, Reversible would no longer be runtime-" +"checkable.\n" +"@runtime_checkable\n" +"class Reversible(Iterable, Protocol):\n" +" def __reversed__(self): ..." +msgstr "" +"@runtime_checkable\n" +"class Iterable(Protocol):\n" +" def __iter__(self): ...\n" +"\n" +"# 若沒有 @runtime_checkable,Reversible 將不再是可於執行期檢查的。\n" +"@runtime_checkable\n" +"class Reversible(Iterable, Protocol):\n" +" def __reversed__(self): ..." + +#: ../../library/typing.rst:2647 msgid "" "This decorator raises :exc:`TypeError` when applied to a non-protocol class." msgstr "" -#: ../../library/typing.rst:2555 +#: ../../library/typing.rst:2651 msgid "" ":deco:`!runtime_checkable` will check only the presence of the required " "methods or attributes, not their type signatures or types. For example, :" @@ -4157,7 +4297,7 @@ msgid "" "(instantiate) :class:`ssl.SSLObject`." msgstr "" -#: ../../library/typing.rst:2566 +#: ../../library/typing.rst:2662 msgid "" "An :func:`isinstance` check against a runtime-checkable protocol can be " "surprisingly slow compared to an ``isinstance()`` check against a non-" @@ -4165,7 +4305,7 @@ msgid "" "calls for structural checks in performance-sensitive code." msgstr "" -#: ../../library/typing.rst:2574 +#: ../../library/typing.rst:2670 msgid "" "The internal implementation of :func:`isinstance` checks against runtime-" "checkable protocols now uses :func:`inspect.getattr_static` to look up " @@ -4175,7 +4315,7 @@ msgid "" "versa. Most users are unlikely to be affected by this change." msgstr "" -#: ../../library/typing.rst:2583 +#: ../../library/typing.rst:2679 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 " @@ -4184,13 +4324,13 @@ msgid "" "`What's new in Python 3.12 ` for more details." msgstr "" -#: ../../library/typing.rst:2594 +#: ../../library/typing.rst:2695 msgid "" "Special construct to add type hints to a dictionary. At runtime \":class:`!" "TypedDict` instances\" are simply :class:`dicts `." msgstr "" -#: ../../library/typing.rst:2597 +#: ../../library/typing.rst:2698 msgid "" "``TypedDict`` declares a dictionary type that expects all of its instances " "to have a certain set of keys, where each key is associated with a value of " @@ -4198,7 +4338,7 @@ msgid "" "enforced by type checkers. Usage::" msgstr "" -#: ../../library/typing.rst:2603 +#: ../../library/typing.rst:2704 msgid "" "class Point2D(TypedDict):\n" " x: int\n" @@ -4211,17 +4351,17 @@ msgid "" "assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')" msgstr "" -#: ../../library/typing.rst:2613 +#: ../../library/typing.rst:2714 msgid "" "An alternative way to create a ``TypedDict`` is by using function-call " "syntax. The second argument must be a literal :class:`dict`::" msgstr "" -#: ../../library/typing.rst:2616 +#: ../../library/typing.rst:2717 msgid "Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})" msgstr "Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})" -#: ../../library/typing.rst:2618 +#: ../../library/typing.rst:2719 msgid "" "This functional syntax allows defining keys which are not valid :ref:" "`identifiers `, for example because they are keywords or " @@ -4229,7 +4369,7 @@ msgid "" "mangling>` like regular private names::" msgstr "" -#: ../../library/typing.rst:2623 +#: ../../library/typing.rst:2724 msgid "" "# raises SyntaxError\n" "class Point2D(TypedDict):\n" @@ -4244,13 +4384,13 @@ msgid "" "Definition = TypedDict('Definition', {'__schema': str}) # not mangled" msgstr "" -#: ../../library/typing.rst:2635 +#: ../../library/typing.rst:2736 msgid "" "By default, all keys must be present in a ``TypedDict``. It is possible to " "mark individual keys as non-required using :data:`NotRequired`::" msgstr "" -#: ../../library/typing.rst:2638 +#: ../../library/typing.rst:2739 msgid "" "class Point2D(TypedDict):\n" " x: int\n" @@ -4270,19 +4410,19 @@ msgstr "" "Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': " "NotRequired[str]})" -#: ../../library/typing.rst:2646 +#: ../../library/typing.rst:2747 msgid "" "This means that a ``Point2D`` ``TypedDict`` can have the ``label`` key " "omitted." msgstr "" -#: ../../library/typing.rst:2649 +#: ../../library/typing.rst:2750 msgid "" "It is also possible to mark all keys as non-required by default by " "specifying a totality of ``False``::" msgstr "" -#: ../../library/typing.rst:2652 +#: ../../library/typing.rst:2753 msgid "" "class Point2D(TypedDict, total=False):\n" " x: int\n" @@ -4298,7 +4438,7 @@ msgstr "" "# 替代語法\n" "Point2D = TypedDict('Point2D', {'x': int, 'y': int}, total=False)" -#: ../../library/typing.rst:2659 +#: ../../library/typing.rst:2760 msgid "" "This means that a ``Point2D`` ``TypedDict`` can have any of the keys " "omitted. A type checker is only expected to support a literal ``False`` or " @@ -4306,13 +4446,13 @@ msgid "" "and makes all items defined in the class body required." msgstr "" -#: ../../library/typing.rst:2664 +#: ../../library/typing.rst:2765 msgid "" "Individual keys of a ``total=False`` ``TypedDict`` can be marked as required " "using :data:`Required`::" msgstr "" -#: ../../library/typing.rst:2667 +#: ../../library/typing.rst:2768 msgid "" "class Point2D(TypedDict, total=False):\n" " x: Required[int]\n" @@ -4338,13 +4478,13 @@ msgstr "" " 'label': str\n" "}, total=False)" -#: ../../library/typing.rst:2679 +#: ../../library/typing.rst:2780 msgid "" "It is possible for a ``TypedDict`` type to inherit from one or more other " "``TypedDict`` types using the class-based syntax. Usage::" msgstr "" -#: ../../library/typing.rst:2683 +#: ../../library/typing.rst:2784 msgid "" "class Point3D(Point2D):\n" " z: int" @@ -4352,13 +4492,13 @@ msgstr "" "class Point3D(Point2D):\n" " z: int" -#: ../../library/typing.rst:2686 +#: ../../library/typing.rst:2787 msgid "" "``Point3D`` has three items: ``x``, ``y`` and ``z``. It is equivalent to " "this definition::" msgstr "" -#: ../../library/typing.rst:2689 +#: ../../library/typing.rst:2790 msgid "" "class Point3D(TypedDict):\n" " x: int\n" @@ -4370,13 +4510,73 @@ msgstr "" " y: int\n" " z: int" -#: ../../library/typing.rst:2694 +#: ../../library/typing.rst:2795 +msgid "" +"By default, a ``TypedDict`` is open, meaning that it may contain additional " +"keys at runtime beyond those defined in the class body. The *closed* class " +"argument can be used to control this; if ``closed=True``, the ``TypedDict`` " +"cannot contain additional keys." +msgstr "" + +#: ../../library/typing.rst:2801 +msgid "" +"class ClosedPoint(TypedDict, closed=True):\n" +" x: int\n" +" y: int\n" +"\n" +"class ClosedPoint3D(ClosedPoint): # type checker error: cannot add keys to " +"a closed TypedDict\n" +" z: int" +msgstr "" +"class ClosedPoint(TypedDict, closed=True):\n" +" x: int\n" +" y: int\n" +"\n" +"class ClosedPoint3D(ClosedPoint): # 型別檢查器錯誤:無法對封閉的 TypedDict " +"新增鍵\n" +" z: int" + +#: ../../library/typing.rst:2808 +msgid "" +"Setting ``closed=False`` explicitly requests the default open behavior. If " +"the argument is not passed, this state is inherited from the parent class." +msgstr "" + +#: ../../library/typing.rst:2811 +msgid "" +"In addition to being open or closed, a ``TypedDict`` can also be configured " +"to have extra items. If the *extra_items* class argument is set to a type, " +"the ``TypedDict`` can contain arbitrary additional keys, but the values of " +"those keys must be of the specified type." +msgstr "" + +#: ../../library/typing.rst:2817 +msgid "" +"class ExtraItemsPoint(TypedDict, extra_items=int):\n" +" x: int\n" +" y: int\n" +"\n" +"point: ExtraItemsPoint = {'x': 1, 'y': 2, 'anything': 3} # OK" +msgstr "" +"class ExtraItemsPoint(TypedDict, extra_items=int):\n" +" x: int\n" +" y: int\n" +"\n" +"point: ExtraItemsPoint = {'x': 1, 'y': 2, 'anything': 3} # OK" + +#: ../../library/typing.rst:2823 +msgid "" +"The *extra_items* argument is also inherited through subclassing. It is " +"unset by default, and it may not be used together with the *closed* argument." +msgstr "" + +#: ../../library/typing.rst:2826 msgid "" "A ``TypedDict`` cannot inherit from a non-\\ ``TypedDict`` class, except " "for :class:`Generic`. For example::" msgstr "" -#: ../../library/typing.rst:2697 +#: ../../library/typing.rst:2829 msgid "" "class X(TypedDict):\n" " x: int\n" @@ -4402,11 +4602,11 @@ msgstr "" "\n" "class XZ(X, Z): pass # 引發 TypeError" -#: ../../library/typing.rst:2709 +#: ../../library/typing.rst:2841 msgid "A ``TypedDict`` can be generic::" msgstr "" -#: ../../library/typing.rst:2711 +#: ../../library/typing.rst:2843 msgid "" "class Group[T](TypedDict):\n" " key: T\n" @@ -4416,13 +4616,13 @@ msgstr "" " key: T\n" " group: list[T]" -#: ../../library/typing.rst:2715 +#: ../../library/typing.rst:2847 msgid "" "To create a generic ``TypedDict`` that is compatible with Python 3.11 or " "lower, inherit from :class:`Generic` explicitly:" msgstr "" -#: ../../library/typing.rst:2718 +#: ../../library/typing.rst:2850 msgid "" "T = TypeVar(\"T\")\n" "\n" @@ -4436,19 +4636,19 @@ msgstr "" " key: T\n" " group: list[T]" -#: ../../library/typing.rst:2726 +#: ../../library/typing.rst:2858 msgid "" "A ``TypedDict`` can be introspected via :func:`annotationlib." "get_annotations` (see :ref:`annotations-howto` for more information on " "annotations best practices) and the following attributes:" msgstr "" -#: ../../library/typing.rst:2732 +#: ../../library/typing.rst:2864 msgid "" "``Point2D.__total__`` gives the value of the ``total`` argument. Example:" msgstr "" -#: ../../library/typing.rst:2735 +#: ../../library/typing.rst:2867 msgid "" ">>> from typing import TypedDict\n" ">>> class Point2D(TypedDict): pass\n" @@ -4472,7 +4672,7 @@ msgstr "" ">>> Point3D.__total__\n" "True" -#: ../../library/typing.rst:2748 +#: ../../library/typing.rst:2880 msgid "" "This attribute reflects *only* the value of the ``total`` argument to the " "current ``TypedDict`` class, not whether the class is semantically total. " @@ -4483,21 +4683,21 @@ msgid "" "introspection." msgstr "" -#: ../../library/typing.rst:2761 +#: ../../library/typing.rst:2893 msgid "" "``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` return :" "class:`frozenset` objects containing required and non-required keys, " "respectively." msgstr "" -#: ../../library/typing.rst:2764 +#: ../../library/typing.rst:2896 msgid "" "Keys marked with :data:`Required` will always appear in " "``__required_keys__`` and keys marked with :data:`NotRequired` will always " "appear in ``__optional_keys__``." msgstr "" -#: ../../library/typing.rst:2767 +#: ../../library/typing.rst:2899 msgid "" "For backwards compatibility with Python 3.10 and below, it is also possible " "to use inheritance to declare both required and non-required keys in the " @@ -4506,7 +4706,7 @@ msgid "" "``TypedDict`` with a different value for ``total``:" msgstr "" -#: ../../library/typing.rst:2774 +#: ../../library/typing.rst:2906 msgid "" ">>> class Point2D(TypedDict, total=False):\n" "... x: int\n" @@ -4532,7 +4732,7 @@ msgstr "" ">>> Point3D.__optional_keys__ == frozenset({'x', 'y'})\n" "True" -#: ../../library/typing.rst:2792 +#: ../../library/typing.rst:2924 msgid "" "If ``from __future__ import annotations`` is used or if annotations are " "given as strings, annotations are not evaluated when the ``TypedDict`` is " @@ -4541,112 +4741,116 @@ msgid "" "attributes may be incorrect." msgstr "" -#: ../../library/typing.rst:2798 -msgid "Support for :data:`ReadOnly` is reflected in the following attributes:" -msgstr "" - -#: ../../library/typing.rst:2802 +#: ../../library/typing.rst:2932 msgid "" "A :class:`frozenset` containing the names of all read-only keys. Keys are " "read-only if they carry the :data:`ReadOnly` qualifier." msgstr "" -#: ../../library/typing.rst:2809 +#: ../../library/typing.rst:2939 msgid "" "A :class:`frozenset` containing the names of all mutable keys. Keys are " "mutable if they do not carry the :data:`ReadOnly` qualifier." msgstr "" -#: ../../library/typing.rst:2814 +#: ../../library/typing.rst:2946 +msgid "" +"The value of the *closed* class argument. It can be ``True``, ``False``, or :" +"data:`None`." +msgstr "" + +#: ../../library/typing.rst:2950 +msgid "" +"The value of the *extra_items* class argument. It can be a valid type or :" +"data:`NoExtraItems`." +msgstr "" + +#: ../../library/typing.rst:2952 msgid "" "See the `TypedDict `_ section in the typing documentation for more examples and " "detailed rules." msgstr "" -#: ../../library/typing.rst:2818 +#: ../../library/typing.rst:2956 msgid "" "``TypedDict`` is now a function rather than a class. It can still be used as " "a class base, as described above." msgstr "" -#: ../../library/typing.rst:2822 +#: ../../library/typing.rst:2960 msgid "" "Added support for marking individual keys as :data:`Required` or :data:" "`NotRequired`. See :pep:`655`." msgstr "" -#: ../../library/typing.rst:2826 +#: ../../library/typing.rst:2964 msgid "Added support for generic ``TypedDict``\\ s." msgstr "" -#: ../../library/typing.rst:2829 +#: ../../library/typing.rst:2967 msgid "" "Removed support for the keyword-argument method of creating ``TypedDict``\\ " "s." msgstr "" -#: ../../library/typing.rst:2832 -msgid "Support for the :data:`ReadOnly` qualifier was added." +#: ../../library/typing.rst:2970 +msgid "Support for the :data:`ReadOnly` qualifier was added. See :pep:`705`." msgstr "" -#: ../../library/typing.rst:2835 +#: ../../library/typing.rst:2973 msgid "" -"When using the functional syntax to create a TypedDict class, failing to " -"pass a value to the 'fields' parameter (``TD = TypedDict(\"TD\")``) is " -"deprecated. Passing ``None`` to the 'fields' parameter (``TD = " -"TypedDict(\"TD\", None)``) is also deprecated. Both will be disallowed in " -"Python 3.15. To create a TypedDict class with 0 fields, use ``class " -"TD(TypedDict): pass`` or ``TD = TypedDict(\"TD\", {})``." +"Support for the *closed* and *extra_items* class arguments was added. See :" +"pep:`728`." msgstr "" -#: ../../library/typing.rst:2844 +#: ../../library/typing.rst:2978 msgid "Protocols" msgstr "協定" -#: ../../library/typing.rst:2846 +#: ../../library/typing.rst:2980 msgid "" "The following protocols are provided by the :mod:`!typing` module. All are " "decorated with :deco:`runtime_checkable`." msgstr "" -#: ../../library/typing.rst:2851 +#: ../../library/typing.rst:2985 msgid "" "A protocol with one abstract method ``__abs__`` that is covariant in its " "return type." msgstr "" -#: ../../library/typing.rst:2856 +#: ../../library/typing.rst:2990 msgid "A protocol with one abstract method ``__bytes__``." msgstr "一個有抽象方法 ``__bytes__`` 的協定。" -#: ../../library/typing.rst:2860 +#: ../../library/typing.rst:2994 msgid "A protocol with one abstract method ``__complex__``." msgstr "一個有抽象方法 ``__complex__`` 的協定。" -#: ../../library/typing.rst:2864 +#: ../../library/typing.rst:2998 msgid "A protocol with one abstract method ``__float__``." msgstr "一個有抽象方法 ``__float__`` 的協定。" -#: ../../library/typing.rst:2868 +#: ../../library/typing.rst:3002 msgid "A protocol with one abstract method ``__index__``." msgstr "一個有抽象方法 ``__index__`` 的協定。" -#: ../../library/typing.rst:2874 +#: ../../library/typing.rst:3008 msgid "A protocol with one abstract method ``__int__``." msgstr "一個有抽象方法 ``__int__`` 的協定。" -#: ../../library/typing.rst:2878 +#: ../../library/typing.rst:3012 msgid "" "A protocol with one abstract method ``__round__`` that is covariant in its " "return type." msgstr "" -#: ../../library/typing.rst:2884 +#: ../../library/typing.rst:3018 msgid "ABCs and Protocols for working with I/O" msgstr "" -#: ../../library/typing.rst:2890 +#: ../../library/typing.rst:3024 msgid "" "Generic class ``IO[AnyStr]`` and its subclasses ``TextIO(IO[str])`` and " "``BinaryIO(IO[bytes])`` represent the types of I/O streams such as returned " @@ -4654,14 +4858,14 @@ msgid "" "interface is fairly broad." msgstr "" -#: ../../library/typing.rst:2896 +#: ../../library/typing.rst:3030 msgid "" "The protocols :class:`io.Reader` and :class:`io.Writer` offer a simpler " "alternative for argument types, when only the ``read()`` or ``write()`` " "methods are accessed, respectively::" msgstr "" -#: ../../library/typing.rst:2900 +#: ../../library/typing.rst:3034 msgid "" "def read_and_write(reader: Reader[str], writer: Writer[bytes]):\n" " data = reader.read()\n" @@ -4671,13 +4875,13 @@ msgstr "" " data = reader.read()\n" " writer.write(data.encode())" -#: ../../library/typing.rst:2904 +#: ../../library/typing.rst:3038 msgid "" "Also consider using :class:`collections.abc.Iterable` for iterating over the " "lines of an input stream::" msgstr "" -#: ../../library/typing.rst:2907 +#: ../../library/typing.rst:3041 msgid "" "def read_config(stream: Iterable[str]):\n" " for line in stream:\n" @@ -4687,40 +4891,40 @@ msgstr "" " for line in stream:\n" " ..." -#: ../../library/typing.rst:2912 +#: ../../library/typing.rst:3046 msgid "Functions and decorators" msgstr "函式與裝飾器" -#: ../../library/typing.rst:2916 +#: ../../library/typing.rst:3050 msgid "Cast a value to a type." msgstr "" -#: ../../library/typing.rst:2918 +#: ../../library/typing.rst:3052 msgid "" "This returns the value unchanged. To the type checker this signals that the " "return value has the designated type, but at runtime we intentionally don't " "check anything (we want this to be as fast as possible)." msgstr "" -#: ../../library/typing.rst:2925 +#: ../../library/typing.rst:3059 msgid "" "Ask a static type checker to confirm that *val* has an inferred type of " "*typ*." msgstr "" -#: ../../library/typing.rst:2927 +#: ../../library/typing.rst:3061 msgid "" "At runtime this does nothing: it returns the first argument unchanged with " "no checks or side effects, no matter the actual type of the argument." msgstr "" -#: ../../library/typing.rst:2930 +#: ../../library/typing.rst:3064 msgid "" "When a static type checker encounters a call to ``assert_type()``, it emits " "an error if the value is not of the specified type::" msgstr "" -#: ../../library/typing.rst:2933 +#: ../../library/typing.rst:3067 msgid "" "def greet(name: str) -> None:\n" " assert_type(name, str) # OK, inferred type of `name` is `str`\n" @@ -4730,13 +4934,13 @@ msgstr "" " assert_type(name, str) # OK,推斷出的 `name` 型別是 `str`\n" " assert_type(name, int) # 型別檢查器錯誤" -#: ../../library/typing.rst:2937 +#: ../../library/typing.rst:3071 msgid "" "This function is useful for ensuring the type checker's understanding of a " "script is in line with the developer's intentions::" msgstr "" -#: ../../library/typing.rst:2940 +#: ../../library/typing.rst:3074 msgid "" "def complex_function(arg: object):\n" " # Do some complex type-narrowing logic,\n" @@ -4746,16 +4950,12 @@ msgid "" " assert_type(arg, int)" msgstr "" -#: ../../library/typing.rst:2951 +#: ../../library/typing.rst:3085 msgid "" "Ask a static type checker to confirm that a line of code is unreachable." msgstr "" -#: ../../library/typing.rst:2953 -msgid "Example::" -msgstr "舉例來說: ::" - -#: ../../library/typing.rst:2955 +#: ../../library/typing.rst:3089 msgid "" "def int_or_str(arg: int | str) -> None:\n" " match arg:\n" @@ -4775,14 +4975,14 @@ msgstr "" " case _ as unreachable:\n" " assert_never(unreachable)" -#: ../../library/typing.rst:2964 +#: ../../library/typing.rst:3098 msgid "" "Here, the annotations allow the type checker to infer that the last case can " "never execute, because ``arg`` is either an :class:`int` or a :class:`str`, " "and both options are covered by earlier cases." msgstr "" -#: ../../library/typing.rst:2969 +#: ../../library/typing.rst:3103 msgid "" "If a type checker finds that a call to ``assert_never()`` is reachable, it " "will emit an error. For example, if the type annotation for ``arg`` was " @@ -4792,47 +4992,47 @@ msgid "" "passed in must be the bottom type, :data:`Never`, and nothing else." msgstr "" -#: ../../library/typing.rst:2977 +#: ../../library/typing.rst:3111 msgid "At runtime, this throws an exception when called." msgstr "" -#: ../../library/typing.rst:2980 +#: ../../library/typing.rst:3114 msgid "" "`Unreachable Code and Exhaustiveness Checking `__ has more information about exhaustiveness " "checking with static typing." msgstr "" -#: ../../library/typing.rst:2988 +#: ../../library/typing.rst:3122 msgid "Ask a static type checker to reveal the inferred type of an expression." msgstr "" -#: ../../library/typing.rst:2990 +#: ../../library/typing.rst:3124 msgid "" "When a static type checker encounters a call to this function, it emits a " "diagnostic with the inferred type of the argument. For example::" msgstr "" -#: ../../library/typing.rst:2993 +#: ../../library/typing.rst:3127 msgid "" "x: int = 1\n" "reveal_type(x) # Revealed type is \"builtins.int\"" msgstr "" -#: ../../library/typing.rst:2996 +#: ../../library/typing.rst:3130 msgid "" "This can be useful when you want to debug how your type checker handles a " "particular piece of code." msgstr "" -#: ../../library/typing.rst:2999 +#: ../../library/typing.rst:3133 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)::" msgstr "" -#: ../../library/typing.rst:3003 +#: ../../library/typing.rst:3137 msgid "" "x = reveal_type(1) # prints \"Runtime type is int\"\n" "print(x) # prints \"1\"" @@ -4840,13 +5040,13 @@ msgstr "" "x = reveal_type(1) # 印出 \"Runtime type is int\"\n" "print(x) # 印出 \"1\"" -#: ../../library/typing.rst:3006 +#: ../../library/typing.rst:3140 msgid "" "Note that the runtime type may be different from (more or less specific " "than) the type statically inferred by a type checker." msgstr "" -#: ../../library/typing.rst:3009 +#: ../../library/typing.rst:3143 msgid "" "Most type checkers support ``reveal_type()`` anywhere, even if the name is " "not imported from ``typing``. Importing the name from ``typing``, however, " @@ -4854,13 +5054,13 @@ msgid "" "clearly." msgstr "" -#: ../../library/typing.rst:3020 +#: ../../library/typing.rst:3154 msgid "" "Decorator to mark an object as providing :func:`dataclass `-like behavior." msgstr "" -#: ../../library/typing.rst:3023 +#: ../../library/typing.rst:3157 msgid "" "``@dataclass_transform`` may be used to decorate a class, metaclass, or a " "function that is itself a decorator. The presence of " @@ -4869,11 +5069,11 @@ msgid "" "to :deco:`dataclasses.dataclass`." msgstr "" -#: ../../library/typing.rst:3030 +#: ../../library/typing.rst:3164 msgid "Example usage with a decorator function:" msgstr "" -#: ../../library/typing.rst:3032 +#: ../../library/typing.rst:3166 msgid "" "@dataclass_transform()\n" "def create_model[T](cls: type[T]) -> type[T]:\n" @@ -4895,11 +5095,11 @@ msgstr "" " id: int\n" " name: str" -#: ../../library/typing.rst:3044 +#: ../../library/typing.rst:3178 msgid "On a base class::" msgstr "" -#: ../../library/typing.rst:3046 +#: ../../library/typing.rst:3180 msgid "" "@dataclass_transform()\n" "class ModelBase: ...\n" @@ -4915,11 +5115,11 @@ msgstr "" " id: int\n" " name: str" -#: ../../library/typing.rst:3053 +#: ../../library/typing.rst:3187 msgid "On a metaclass::" msgstr "" -#: ../../library/typing.rst:3055 +#: ../../library/typing.rst:3189 msgid "" "@dataclass_transform()\n" "class ModelMeta(type): ...\n" @@ -4939,7 +5139,7 @@ msgstr "" " id: int\n" " name: str" -#: ../../library/typing.rst:3064 +#: ../../library/typing.rst:3198 msgid "" "The ``CustomerModel`` classes defined above will be treated by type checkers " "similarly to classes created with :deco:`dataclasses.dataclass`. For " @@ -4947,7 +5147,7 @@ msgid "" "that accept ``id`` and ``name``." msgstr "" -#: ../../library/typing.rst:3070 +#: ../../library/typing.rst:3204 msgid "" "The decorated class, metaclass, or function may accept the following bool " "arguments which type checkers will assume have the same effect as they would " @@ -4957,7 +5157,7 @@ msgid "" "``False``) to be statically evaluated." msgstr "" -#: ../../library/typing.rst:3078 +#: ../../library/typing.rst:3212 msgid "" "The arguments to the ``@dataclass_transform`` decorator can be used to " "customize the default behaviors of the decorated class, metaclass, or " @@ -4968,90 +5168,90 @@ msgstr "" msgid "Parameters" msgstr "" -#: ../../library/typing.rst:3082 +#: ../../library/typing.rst:3216 msgid "" "Indicates whether the ``eq`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``True``." msgstr "" -#: ../../library/typing.rst:3087 +#: ../../library/typing.rst:3221 msgid "" "Indicates whether the ``order`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``False``." msgstr "" -#: ../../library/typing.rst:3092 +#: ../../library/typing.rst:3226 msgid "" "Indicates whether the ``kw_only`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``False``." msgstr "" -#: ../../library/typing.rst:3097 +#: ../../library/typing.rst:3231 msgid "" "Indicates whether the ``frozen`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``False``. .. " "versionadded:: 3.12" msgstr "" -#: ../../library/typing.rst:3098 +#: ../../library/typing.rst:3232 msgid "" "Indicates whether the ``frozen`` parameter is assumed to be ``True`` or " "``False`` if it is omitted by the caller. Defaults to ``False``." msgstr "" -#: ../../library/typing.rst:3104 +#: ../../library/typing.rst:3238 msgid "" "Specifies a static list of supported classes or functions that describe " "fields, similar to :func:`dataclasses.field`. Defaults to ``()``." msgstr "" -#: ../../library/typing.rst:3110 +#: ../../library/typing.rst:3244 msgid "" "Arbitrary other keyword arguments are accepted in order to allow for " "possible future extensions." msgstr "" -#: ../../library/typing.rst:3114 +#: ../../library/typing.rst:3248 msgid "" "Type checkers recognize the following optional parameters on field " "specifiers:" msgstr "" -#: ../../library/typing.rst:3117 +#: ../../library/typing.rst:3251 msgid "**Recognised parameters for field specifiers**" msgstr "" -#: ../../library/typing.rst:3121 +#: ../../library/typing.rst:3255 msgid "Parameter name" msgstr "" -#: ../../library/typing.rst:3122 +#: ../../library/typing.rst:3256 msgid "Description" msgstr "" -#: ../../library/typing.rst:3123 +#: ../../library/typing.rst:3257 msgid "``init``" msgstr "``init``" -#: ../../library/typing.rst:3124 +#: ../../library/typing.rst:3258 msgid "" "Indicates whether the field should be included in the synthesized " "``__init__`` method. If unspecified, ``init`` defaults to ``True``." msgstr "" -#: ../../library/typing.rst:3127 +#: ../../library/typing.rst:3261 msgid "``default``" msgstr "``default``" -#: ../../library/typing.rst:3128 +#: ../../library/typing.rst:3262 msgid "Provides the default value for the field." msgstr "" -#: ../../library/typing.rst:3129 +#: ../../library/typing.rst:3263 msgid "``default_factory``" msgstr "``default_factory``" -#: ../../library/typing.rst:3130 +#: ../../library/typing.rst:3264 msgid "" "Provides a runtime callback that returns the default value for the field. If " "neither ``default`` nor ``default_factory`` are specified, the field is " @@ -5059,19 +5259,19 @@ msgid "" "is instantiated." msgstr "" -#: ../../library/typing.rst:3135 +#: ../../library/typing.rst:3269 msgid "``factory``" msgstr "``factory``" -#: ../../library/typing.rst:3136 +#: ../../library/typing.rst:3270 msgid "An alias for the ``default_factory`` parameter on field specifiers." msgstr "" -#: ../../library/typing.rst:3137 +#: ../../library/typing.rst:3271 msgid "``kw_only``" msgstr "``kw_only``" -#: ../../library/typing.rst:3138 +#: ../../library/typing.rst:3272 msgid "" "Indicates whether the field should be marked as keyword-only. If ``True``, " "the field will be keyword-only. If ``False``, it will not be keyword-only. " @@ -5081,32 +5281,32 @@ msgid "" "will be used." msgstr "" -#: ../../library/typing.rst:3144 +#: ../../library/typing.rst:3278 msgid "``alias``" msgstr "``alias``" -#: ../../library/typing.rst:3145 +#: ../../library/typing.rst:3279 msgid "" "Provides an alternative name for the field. This alternative name is used in " "the synthesized ``__init__`` method." msgstr "" -#: ../../library/typing.rst:3148 +#: ../../library/typing.rst:3282 msgid "" "At runtime, this decorator records its arguments in the " "``__dataclass_transform__`` attribute on the decorated object. It has no " "other runtime effect." msgstr "" -#: ../../library/typing.rst:3152 +#: ../../library/typing.rst:3286 msgid "See :pep:`681` for more details." msgstr "更多細節請見 :pep:`681`。" -#: ../../library/typing.rst:3160 +#: ../../library/typing.rst:3294 msgid "Decorator for creating overloaded functions and methods." msgstr "" -#: ../../library/typing.rst:3162 +#: ../../library/typing.rst:3296 msgid "" "The ``@overload`` decorator allows describing functions and methods that " "support multiple different combinations of argument types. A series of " @@ -5114,7 +5314,7 @@ msgid "" "``@overload``-decorated definition (for the same function/method)." msgstr "" -#: ../../library/typing.rst:3167 +#: ../../library/typing.rst:3301 msgid "" "``@overload``-decorated definitions are for the benefit of the type checker " "only, since they will be overwritten by the non-``@overload``-decorated " @@ -5124,13 +5324,13 @@ msgid "" "`NotImplementedError`." msgstr "" -#: ../../library/typing.rst:3175 +#: ../../library/typing.rst:3309 msgid "" "An example of overload that gives a more precise type than can be expressed " "using a union or a type variable:" msgstr "" -#: ../../library/typing.rst:3178 +#: ../../library/typing.rst:3312 msgid "" "@overload\n" "def process(response: None) -> None:\n" @@ -5156,22 +5356,22 @@ msgstr "" "def process(response):\n" " ... # 實際的實作在這邊" -#: ../../library/typing.rst:3192 +#: ../../library/typing.rst:3326 msgid "" "See :pep:`484` for more details and comparison with other typing semantics." msgstr "" -#: ../../library/typing.rst:3194 +#: ../../library/typing.rst:3328 msgid "" "Overloaded functions can now be introspected at runtime using :func:" "`get_overloads`." msgstr "" -#: ../../library/typing.rst:3201 +#: ../../library/typing.rst:3335 msgid "Return a sequence of :deco:`overload`-decorated definitions for *func*." msgstr "" -#: ../../library/typing.rst:3204 +#: ../../library/typing.rst:3338 msgid "" "*func* is the function object for the implementation of the overloaded " "function. For example, given the definition of ``process`` in the " @@ -5181,32 +5381,32 @@ msgid "" "sequence." msgstr "" -#: ../../library/typing.rst:3211 +#: ../../library/typing.rst:3345 msgid "" "``get_overloads()`` can be used for introspecting an overloaded function at " "runtime." msgstr "" -#: ../../library/typing.rst:3219 +#: ../../library/typing.rst:3353 msgid "Clear all registered overloads in the internal registry." msgstr "" -#: ../../library/typing.rst:3221 +#: ../../library/typing.rst:3355 msgid "This can be used to reclaim the memory used by the registry." msgstr "" -#: ../../library/typing.rst:3228 +#: ../../library/typing.rst:3362 msgid "Decorator to indicate final methods and final classes." msgstr "" -#: ../../library/typing.rst:3230 +#: ../../library/typing.rst:3364 msgid "" "Decorating a method with ``@final`` indicates to a type checker that the " "method cannot be overridden in a subclass. Decorating a class with " "``@final`` indicates that it cannot be subclassed." msgstr "" -#: ../../library/typing.rst:3236 +#: ../../library/typing.rst:3370 msgid "" "class Base:\n" " @final\n" @@ -5236,7 +5436,7 @@ msgstr "" "class Other(Leaf): # 型別檢查器回報的錯誤\n" " ..." -#: ../../library/typing.rst:3255 +#: ../../library/typing.rst:3389 msgid "" "The decorator will now attempt to set a ``__final__`` attribute to ``True`` " "on the decorated object. Thus, a check like ``if getattr(obj, \"__final__\", " @@ -5246,11 +5446,11 @@ msgid "" "exception." msgstr "" -#: ../../library/typing.rst:3266 +#: ../../library/typing.rst:3400 msgid "Decorator to indicate that annotations are not type hints." msgstr "" -#: ../../library/typing.rst:3268 +#: ../../library/typing.rst:3402 msgid "" "This works as a class or function :term:`decorator`. With a class, it " "applies recursively to all methods and classes defined in that class (but " @@ -5258,40 +5458,24 @@ msgid "" "will ignore all annotations in a function or class with this decorator." msgstr "" -#: ../../library/typing.rst:3274 +#: ../../library/typing.rst:3408 msgid "``@no_type_check`` mutates the decorated object in place." msgstr "" -#: ../../library/typing.rst:3278 -msgid "Decorator to give another decorator the :func:`no_type_check` effect." -msgstr "" - -#: ../../library/typing.rst:3280 -msgid "" -"This wraps the decorator with something that wraps the decorated function " -"in :func:`no_type_check`." -msgstr "" - -#: ../../library/typing.rst:3283 -msgid "" -"No type checker ever added support for ``@no_type_check_decorator``. It is " -"therefore deprecated, and will be removed in Python 3.15." -msgstr "" - -#: ../../library/typing.rst:3289 +#: ../../library/typing.rst:3412 msgid "" "Decorator to indicate that a method in a subclass is intended to override a " "method or attribute in a superclass." msgstr "" -#: ../../library/typing.rst:3292 +#: ../../library/typing.rst:3415 msgid "" "Type checkers should emit an error if a method decorated with ``@override`` " "does not, in fact, override anything. This helps prevent bugs that may occur " "when a base class is changed without an equivalent change to a child class." msgstr "" -#: ../../library/typing.rst:3299 +#: ../../library/typing.rst:3422 msgid "" "class Base:\n" " def log_status(self) -> None:\n" @@ -5307,11 +5491,11 @@ msgid "" " ..." msgstr "" -#: ../../library/typing.rst:3314 +#: ../../library/typing.rst:3437 msgid "There is no runtime checking of this property." msgstr "" -#: ../../library/typing.rst:3316 +#: ../../library/typing.rst:3439 msgid "" "The decorator will attempt to set an ``__override__`` attribute to ``True`` " "on the decorated object. Thus, a check like ``if getattr(obj, " @@ -5321,22 +5505,72 @@ msgid "" "without raising an exception." msgstr "" -#: ../../library/typing.rst:3323 +#: ../../library/typing.rst:3446 msgid "See :pep:`698` for more details." msgstr "更多細節請見 :pep:`698`。" -#: ../../library/typing.rst:3330 +#: ../../library/typing.rst:3452 +msgid "Decorator to mark a class as a disjoint base." +msgstr "" + +#: ../../library/typing.rst:3454 +msgid "" +"Type checkers do not allow child classes of a disjoint base ``C`` to inherit " +"from other disjoint bases that are not parent or child classes of ``C``." +msgstr "" + +#: ../../library/typing.rst:3459 +msgid "" +"@disjoint_base\n" +"class Disjoint1: pass\n" +"\n" +"@disjoint_base\n" +"class Disjoint2: pass\n" +"\n" +"class Disjoint3(Disjoint1, Disjoint2): pass # Type checker error" +msgstr "" +"@disjoint_base\n" +"class Disjoint1: pass\n" +"\n" +"@disjoint_base\n" +"class Disjoint2: pass\n" +"\n" +"class Disjoint3(Disjoint1, Disjoint2): pass # 型別檢查器錯誤" + +#: ../../library/typing.rst:3467 +msgid "" +"Type checkers can use knowledge of disjoint bases to detect unreachable code " +"and determine when two types can overlap." +msgstr "" + +#: ../../library/typing.rst:3470 +msgid "" +"The corresponding runtime concept is a solid base (see :ref:`multiple-" +"inheritance`). Classes that are solid bases at runtime can be marked with " +"``@disjoint_base`` in stub files. Users may also mark other classes as " +"disjoint bases to indicate to type checkers that multiple inheritance with " +"other disjoint bases should not be allowed." +msgstr "" + +#: ../../library/typing.rst:3475 +msgid "" +"Note that the concept of a solid base is a CPython implementation detail, " +"and the exact set of standard library classes that are disjoint bases at " +"runtime may change in future versions of Python." +msgstr "" + +#: ../../library/typing.rst:3483 msgid "Decorator to mark a class or function as unavailable at runtime." msgstr "" -#: ../../library/typing.rst:3332 +#: ../../library/typing.rst:3485 msgid "" "This decorator is itself not available at runtime. It is mainly intended to " "mark classes that are defined in type stub files if an implementation " "returns an instance of a private class::" msgstr "" -#: ../../library/typing.rst:3336 +#: ../../library/typing.rst:3489 msgid "" "@type_check_only\n" "class Response: # private or not available at runtime\n" @@ -5346,29 +5580,29 @@ msgid "" "def fetch_response() -> Response: ..." msgstr "" -#: ../../library/typing.rst:3343 +#: ../../library/typing.rst:3496 msgid "" "Note that returning instances of private classes is not recommended. It is " "usually preferable to make such classes public." msgstr "" -#: ../../library/typing.rst:3347 +#: ../../library/typing.rst:3500 msgid "Introspection helpers" msgstr "" -#: ../../library/typing.rst:3351 +#: ../../library/typing.rst:3504 msgid "" "Return a dictionary containing type hints for a function, method, module, " "class object, or other callable object." msgstr "" -#: ../../library/typing.rst:3354 +#: ../../library/typing.rst:3507 msgid "" "This is often the same as :func:`annotationlib.get_annotations`, but this " "function makes the following changes to the annotations dictionary:" msgstr "" -#: ../../library/typing.rst:3357 +#: ../../library/typing.rst:3510 msgid "" "Forward references encoded as string literals or :class:`ForwardRef` objects " "are handled by evaluating them in *globalns*, *localns*, and (where " @@ -5377,17 +5611,17 @@ msgid "" "inferred from *obj*." msgstr "" -#: ../../library/typing.rst:3362 +#: ../../library/typing.rst:3515 msgid "``None`` is replaced with :class:`types.NoneType`." msgstr "" -#: ../../library/typing.rst:3363 +#: ../../library/typing.rst:3516 msgid "" "If :deco:`no_type_check` has been applied to *obj*, an empty dictionary is " "returned." msgstr "" -#: ../../library/typing.rst:3365 +#: ../../library/typing.rst:3518 msgid "" "If *obj* is a class ``C``, the function returns a dictionary that merges " "annotations from ``C``'s base classes with those on ``C`` directly. This is " @@ -5398,7 +5632,7 @@ msgid "" "the method resolution order." msgstr "" -#: ../../library/typing.rst:3373 +#: ../../library/typing.rst:3526 msgid "" "The function recursively replaces all occurrences of ``Annotated[T, ...]``, " "``Required[T]``, ``NotRequired[T]``, and ``ReadOnly[T]`` with ``T``, unless " @@ -5406,13 +5640,13 @@ msgid "" "information)." msgstr "" -#: ../../library/typing.rst:3380 ../../library/typing.rst:3572 +#: ../../library/typing.rst:3533 ../../library/typing.rst:3725 msgid "" "This function may execute arbitrary code contained in annotations. See :ref:" "`annotationlib-security` for more information." msgstr "" -#: ../../library/typing.rst:3385 +#: ../../library/typing.rst:3538 msgid "" "If :attr:`Format.VALUE ` is used and any forward " "references in the annotations of *obj* are not resolvable, a :exc:" @@ -5422,14 +5656,14 @@ msgid "" "code." msgstr "" -#: ../../library/typing.rst:3394 +#: ../../library/typing.rst:3547 msgid "" "Calling :func:`get_type_hints` on an instance is not supported. To retrieve " "annotations for an instance, call :func:`get_type_hints` on the instance's " "class instead (for example, ``get_type_hints(type(obj))``)." msgstr "" -#: ../../library/typing.rst:3399 +#: ../../library/typing.rst:3552 msgid "" "Added ``include_extras`` parameter as part of :pep:`593`. See the " "documentation on :data:`Annotated` for more information." @@ -5437,14 +5671,14 @@ msgstr "" "新增 ``include_extras`` 參數(如 :pep:`593` 中所述)。更多資訊請見 :data:" "`Annotated` 的文件。" -#: ../../library/typing.rst:3403 +#: ../../library/typing.rst:3556 msgid "" "Previously, ``Optional[t]`` was added for function and method annotations if " "a default value equal to ``None`` was set. Now the annotation is returned " "unchanged." msgstr "" -#: ../../library/typing.rst:3408 +#: ../../library/typing.rst:3561 msgid "" "Added the ``format`` parameter. See the documentation on :func:" "`annotationlib.get_annotations` for more information." @@ -5452,20 +5686,20 @@ msgstr "" "新增 ``format`` 參數。更多資訊請見 :func:`annotationlib.get_annotations` 的文" "件。" -#: ../../library/typing.rst:3412 +#: ../../library/typing.rst:3565 msgid "" "Calling :func:`get_type_hints` on instances is no longer supported. Some " "instances were accepted in earlier versions as an undocumented " "implementation detail." msgstr "" -#: ../../library/typing.rst:3419 +#: ../../library/typing.rst:3572 msgid "" "Get the unsubscripted version of a type: for a typing object of the form " "``X[Y, Z, ...]`` return ``X``." msgstr "" -#: ../../library/typing.rst:3422 +#: ../../library/typing.rst:3575 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 :" @@ -5473,11 +5707,11 @@ msgid "" "class:`ParamSpec`. Return ``None`` for unsupported objects." msgstr "" -#: ../../library/typing.rst:3428 ../../library/typing.rst:3452 +#: ../../library/typing.rst:3581 ../../library/typing.rst:3605 msgid "Examples:" msgstr "舉例:" -#: ../../library/typing.rst:3430 +#: ../../library/typing.rst:3583 msgid "" "assert get_origin(str) is None\n" "assert get_origin(Dict[str, int]) is dict\n" @@ -5495,13 +5729,13 @@ msgstr "" "assert get_origin(P.args) is P\n" "assert get_origin(P.kwargs) is P" -#: ../../library/typing.rst:3444 +#: ../../library/typing.rst:3597 msgid "" "Get type arguments with all substitutions performed: for a typing object of " "the form ``X[Y, Z, ...]`` return ``(Y, Z, ...)``." msgstr "" -#: ../../library/typing.rst:3447 +#: ../../library/typing.rst:3600 msgid "" "If ``X`` is a union or :class:`Literal` contained in another generic type, " "the order of ``(Y, Z, ...)`` may be different from the order of the original " @@ -5509,7 +5743,7 @@ msgid "" "objects." msgstr "" -#: ../../library/typing.rst:3454 +#: ../../library/typing.rst:3607 msgid "" "assert get_args(int) == ()\n" "assert get_args(Dict[int, str]) == (int, str)\n" @@ -5519,11 +5753,11 @@ msgstr "" "assert get_args(Dict[int, str]) == (int, str)\n" "assert get_args(Union[int, str]) == (int, str)" -#: ../../library/typing.rst:3464 +#: ../../library/typing.rst:3617 msgid "Return the set of members defined in a :class:`Protocol`." msgstr "" -#: ../../library/typing.rst:3466 +#: ../../library/typing.rst:3619 msgid "" ">>> from typing import Protocol, get_protocol_members\n" ">>> class P(Protocol):\n" @@ -5539,15 +5773,15 @@ msgstr "" ">>> get_protocol_members(P) == frozenset({'a', 'b'})\n" "True" -#: ../../library/typing.rst:3475 +#: ../../library/typing.rst:3628 msgid "Raise :exc:`TypeError` for arguments that are not Protocols." msgstr "" -#: ../../library/typing.rst:3481 +#: ../../library/typing.rst:3634 msgid "Determine if a type is a :class:`Protocol`." msgstr "確定一個型別是否 :class:`Protocol`。" -#: ../../library/typing.rst:3485 +#: ../../library/typing.rst:3638 msgid "" "class P(Protocol):\n" " def a(self) -> str: ...\n" @@ -5563,13 +5797,13 @@ msgstr "" "assert is_protocol(P)\n" "assert not is_protocol(int)" -#: ../../library/typing.rst:3494 +#: ../../library/typing.rst:3647 msgid "" "This function only returns true for ``Protocol`` classes, not for :ref:" "`generic aliases ` of them:" msgstr "" -#: ../../library/typing.rst:3497 +#: ../../library/typing.rst:3650 msgid "" "class GenericP[T](Protocol):\n" " def a(self) -> T: ...\n" @@ -5583,11 +5817,11 @@ msgstr "" "\n" "assert not is_protocol(GenericP[int])" -#: ../../library/typing.rst:3509 +#: ../../library/typing.rst:3662 msgid "Check if a type is a :class:`TypedDict`." msgstr "" -#: ../../library/typing.rst:3513 +#: ../../library/typing.rst:3666 msgid "" "class Film(TypedDict):\n" " title: str\n" @@ -5601,13 +5835,13 @@ msgid "" "assert not is_typeddict(TypedDict)" msgstr "" -#: ../../library/typing.rst:3526 +#: ../../library/typing.rst:3679 msgid "" "This function only returns true for ``TypedDict`` classes, not for :ref:" "`generic aliases ` of them:" msgstr "" -#: ../../library/typing.rst:3529 +#: ../../library/typing.rst:3682 msgid "" "class GenericFilm[T](TypedDict):\n" " title: str\n" @@ -5616,57 +5850,57 @@ msgid "" "assert not is_typeddict(GenericFilm[int])" msgstr "" -#: ../../library/typing.rst:3541 +#: ../../library/typing.rst:3694 msgid "" "Class used for internal typing representation of string forward references." msgstr "" -#: ../../library/typing.rst:3543 +#: ../../library/typing.rst:3696 msgid "" "For example, ``List[\"SomeClass\"]`` is implicitly transformed into " "``List[ForwardRef(\"SomeClass\")]``. :class:`!ForwardRef` should not be " "instantiated by a user, but may be used by introspection tools." msgstr "" -#: ../../library/typing.rst:3548 +#: ../../library/typing.rst:3701 msgid "" ":pep:`585` generic types such as ``list[\"SomeClass\"]`` will not be " "implicitly transformed into ``list[ForwardRef(\"SomeClass\")]`` and thus " "will not automatically resolve to ``list[SomeClass]``." msgstr "" -#: ../../library/typing.rst:3554 +#: ../../library/typing.rst:3707 msgid "" "This is now an alias for :class:`annotationlib.ForwardRef`. Several " "undocumented behaviors of this class have been changed; for example, after a " "``ForwardRef`` has been evaluated, the evaluated value is no longer cached." msgstr "" -#: ../../library/typing.rst:3561 +#: ../../library/typing.rst:3714 msgid "Evaluate an :class:`annotationlib.ForwardRef` as a :term:`type hint`." msgstr "" -#: ../../library/typing.rst:3563 +#: ../../library/typing.rst:3716 msgid "" "This is similar to calling :meth:`annotationlib.ForwardRef.evaluate`, but " "unlike that method, :func:`!evaluate_forward_ref` also recursively evaluates " "forward references nested within the type hint." msgstr "" -#: ../../library/typing.rst:3567 +#: ../../library/typing.rst:3720 msgid "" "See the documentation for :meth:`annotationlib.ForwardRef.evaluate` for the " "meaning of the *owner*, *globals*, *locals*, *type_params*, and *format* " "parameters." msgstr "" -#: ../../library/typing.rst:3579 +#: ../../library/typing.rst:3732 msgid "" "A sentinel object used to indicate that a type parameter has no default " "value. For example:" msgstr "" -#: ../../library/typing.rst:3582 +#: ../../library/typing.rst:3735 msgid "" ">>> T = TypeVar(\"T\")\n" ">>> T.__default__ is typing.NoDefault\n" @@ -5682,17 +5916,41 @@ msgstr "" ">>> S.__default__ is None\n" "True" -#: ../../library/typing.rst:3594 +#: ../../library/typing.rst:3748 +msgid "" +"A :class:`sentinel` object used to indicate that a :class:`TypedDict` does " +"not have the *extra_items* class argument." +msgstr "" + +#: ../../library/typing.rst:3751 +msgid "" +">>> from typing import TypedDict, NoExtraItems\n" +">>> class Point(TypedDict):\n" +"... x: int\n" +"... y: int\n" +"...\n" +">>> Point.__extra_items__ is NoExtraItems\n" +"True" +msgstr "" +">>> from typing import TypedDict, NoExtraItems\n" +">>> class Point(TypedDict):\n" +"... x: int\n" +"... y: int\n" +"...\n" +">>> Point.__extra_items__ is NoExtraItems\n" +"True" + +#: ../../library/typing.rst:3762 msgid "Constant" msgstr "常數" -#: ../../library/typing.rst:3598 +#: ../../library/typing.rst:3766 msgid "" "A special constant that is assumed to be ``True`` by static type checkers. " "It's ``False`` at runtime." msgstr "" -#: ../../library/typing.rst:3601 +#: ../../library/typing.rst:3769 msgid "" "A module which is expensive to import, and which only contain types used for " "typing annotations, can be safely imported inside an ``if TYPE_CHECKING:`` " @@ -5704,7 +5962,7 @@ msgid "" "will be checked properly during such analysis." msgstr "" -#: ../../library/typing.rst:3613 +#: ../../library/typing.rst:3781 msgid "" "if TYPE_CHECKING:\n" " import expensive_mod\n" @@ -5718,7 +5976,7 @@ msgstr "" "def fun(arg: expensive_mod.SomeType) -> None:\n" " local_var: expensive_mod.AnotherType = other_fun()" -#: ../../library/typing.rst:3619 +#: ../../library/typing.rst:3787 msgid "" "If you occasionally need to examine type annotations at runtime which may " "contain undefined symbols, use :meth:`annotationlib.get_annotations` with a " @@ -5727,11 +5985,11 @@ msgid "" "raising :exc:`NameError`." msgstr "" -#: ../../library/typing.rst:3632 +#: ../../library/typing.rst:3800 msgid "Deprecated aliases" msgstr "棄用的別名" -#: ../../library/typing.rst:3634 +#: ../../library/typing.rst:3802 msgid "" "This module defines several deprecated aliases to pre-existing standard " "library classes. These were originally included in the :mod:`!typing` module " @@ -5740,7 +5998,7 @@ msgid "" "pre-existing classes were enhanced to support ``[]`` (see :pep:`585`)." msgstr "" -#: ../../library/typing.rst:3641 +#: ../../library/typing.rst:3809 msgid "" "The redundant types are deprecated as of Python 3.9. However, while the " "aliases may be removed at some point, removal of these aliases is not " @@ -5748,7 +6006,7 @@ msgid "" "the interpreter for these aliases." msgstr "" -#: ../../library/typing.rst:3646 +#: ../../library/typing.rst:3814 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 " @@ -5756,38 +6014,38 @@ msgid "" "`!typing` module without deprecation warnings until at least Python 3.14." msgstr "" -#: ../../library/typing.rst:3651 +#: ../../library/typing.rst:3819 msgid "" "Type checkers are encouraged to flag uses of the deprecated types if the " "program they are checking targets a minimum Python version of 3.9 or newer." msgstr "" -#: ../../library/typing.rst:3657 +#: ../../library/typing.rst:3825 msgid "Aliases to built-in types" msgstr "內建型別的別名" -#: ../../library/typing.rst:3661 +#: ../../library/typing.rst:3829 msgid "Deprecated alias to :class:`dict`." msgstr "棄用 :class:`dict` 的別名。" -#: ../../library/typing.rst:3663 +#: ../../library/typing.rst:3831 msgid "" "Note that to annotate arguments, it is preferred to use an abstract " "collection type such as :class:`~collections.abc.Mapping` rather than to " "use :class:`dict` or :class:`!typing.Dict`." msgstr "" -#: ../../library/typing.rst:3667 +#: ../../library/typing.rst:3835 msgid "" ":class:`builtins.dict ` now supports subscripting (``[]``). See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3673 +#: ../../library/typing.rst:3841 msgid "Deprecated alias to :class:`list`." msgstr "棄用 :class:`list` 的別名。" -#: ../../library/typing.rst:3675 +#: ../../library/typing.rst:3843 msgid "" "Note that to annotate arguments, it is preferred to use an abstract " "collection type such as :class:`~collections.abc.Sequence` or :class:" @@ -5795,136 +6053,136 @@ msgid "" "typing.List`." msgstr "" -#: ../../library/typing.rst:3680 +#: ../../library/typing.rst:3848 msgid "" ":class:`builtins.list ` now supports subscripting (``[]``). See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3686 +#: ../../library/typing.rst:3854 msgid "Deprecated alias to :class:`builtins.set `." msgstr "棄用 :class:`builtins.set ` 的別名。" -#: ../../library/typing.rst:3688 +#: ../../library/typing.rst:3856 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`." msgstr "" -#: ../../library/typing.rst:3692 +#: ../../library/typing.rst:3860 msgid "" ":class:`builtins.set ` now supports subscripting (``[]``). See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3698 +#: ../../library/typing.rst:3866 msgid "Deprecated alias to :class:`builtins.frozenset `." msgstr "棄用 :class:`builtins.frozenset ` 的別名。" -#: ../../library/typing.rst:3700 +#: ../../library/typing.rst:3868 msgid "" ":class:`builtins.frozenset ` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3707 +#: ../../library/typing.rst:3875 msgid "Deprecated alias for :class:`tuple`." msgstr "棄用 :class:`tuple` 的別名。" -#: ../../library/typing.rst:3709 +#: ../../library/typing.rst:3877 msgid "" ":class:`tuple` and ``Tuple`` are special-cased in the type system; see :ref:" "`annotating-tuples` for more details." msgstr "" -#: ../../library/typing.rst:3712 +#: ../../library/typing.rst:3880 msgid "" ":class:`builtins.tuple ` now supports subscripting (``[]``). See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3718 +#: ../../library/typing.rst:3886 msgid "Deprecated alias to :class:`type`." msgstr "棄用 :class:`type` 的別名。" -#: ../../library/typing.rst:3720 +#: ../../library/typing.rst:3888 msgid "" "See :ref:`type-of-class-objects` for details on using :class:`type` or " "``typing.Type`` in type annotations." msgstr "" -#: ../../library/typing.rst:3725 +#: ../../library/typing.rst:3893 msgid "" ":class:`builtins.type ` now supports subscripting (``[]``). See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3732 +#: ../../library/typing.rst:3900 msgid "Aliases to types in :mod:`collections`" msgstr ":mod:`collections` 中型別的別名" -#: ../../library/typing.rst:3736 +#: ../../library/typing.rst:3904 msgid "Deprecated alias to :class:`collections.defaultdict`." msgstr "棄用 :class:`collections.defaultdict` 的別名。" -#: ../../library/typing.rst:3740 +#: ../../library/typing.rst:3908 msgid "" ":class:`collections.defaultdict` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3746 +#: ../../library/typing.rst:3914 msgid "Deprecated alias to :class:`collections.OrderedDict`." msgstr "棄用 :class:`collections.OrderedDict` 的別名。" -#: ../../library/typing.rst:3750 +#: ../../library/typing.rst:3918 msgid "" ":class:`collections.OrderedDict` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3756 +#: ../../library/typing.rst:3924 msgid "Deprecated alias to :class:`collections.ChainMap`." msgstr "棄用 :class:`collections.ChainMap` 的別名。" -#: ../../library/typing.rst:3760 +#: ../../library/typing.rst:3928 msgid "" ":class:`collections.ChainMap` now supports subscripting (``[]``). See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3766 +#: ../../library/typing.rst:3934 msgid "Deprecated alias to :class:`collections.Counter`." msgstr "棄用 :class:`collections.Counter` 的別名。" -#: ../../library/typing.rst:3770 +#: ../../library/typing.rst:3938 msgid "" ":class:`collections.Counter` now supports subscripting (``[]``). See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3776 +#: ../../library/typing.rst:3944 msgid "Deprecated alias to :class:`collections.deque`." msgstr "棄用 :class:`collections.deque` 的別名。" -#: ../../library/typing.rst:3780 +#: ../../library/typing.rst:3948 msgid "" ":class:`collections.deque` now supports subscripting (``[]``). See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3787 +#: ../../library/typing.rst:3955 msgid "Aliases to other concrete types" msgstr "" -#: ../../library/typing.rst:3792 +#: ../../library/typing.rst:3960 msgid "" "Deprecated aliases corresponding to the return types from :func:`re.compile` " -"and :func:`re.match`." +"and :func:`re.search`." msgstr "" -#: ../../library/typing.rst:3795 +#: ../../library/typing.rst:3963 msgid "" "These types (and the corresponding functions) are generic over :data:" "`AnyStr`. ``Pattern`` can be specialised as ``Pattern[str]`` or " @@ -5932,29 +6190,29 @@ msgid "" "``Match[bytes]``." msgstr "" -#: ../../library/typing.rst:3800 +#: ../../library/typing.rst:3968 msgid "" "Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3806 +#: ../../library/typing.rst:3974 msgid "Deprecated alias for :class:`str`." msgstr "棄用 :class:`str` 的別名。" -#: ../../library/typing.rst:3808 +#: ../../library/typing.rst:3976 msgid "" "``Text`` is provided to supply a forward compatible path for Python 2 code: " "in Python 2, ``Text`` is an alias for ``unicode``." msgstr "" -#: ../../library/typing.rst:3812 +#: ../../library/typing.rst:3980 msgid "" "Use ``Text`` to indicate that a value must contain a unicode string in a " "manner that is compatible with both Python 2 and Python 3::" msgstr "" -#: ../../library/typing.rst:3815 +#: ../../library/typing.rst:3983 msgid "" "def add_unicode_checkmark(text: Text) -> Text:\n" " return text + u' \\u2713'" @@ -5962,32 +6220,32 @@ msgstr "" "def add_unicode_checkmark(text: Text) -> Text:\n" " return text + u' \\u2713'" -#: ../../library/typing.rst:3820 +#: ../../library/typing.rst:3988 msgid "" "Python 2 is no longer supported, and most type checkers also no longer " "support type checking Python 2 code. Removal of the alias is not currently " "planned, but users are encouraged to use :class:`str` instead of ``Text``." msgstr "" -#: ../../library/typing.rst:3830 +#: ../../library/typing.rst:3998 msgid "Aliases to container ABCs in :mod:`collections.abc`" msgstr ":mod:`collections.abc` 中容器 ABC 的別名" -#: ../../library/typing.rst:3834 +#: ../../library/typing.rst:4002 msgid "Deprecated alias to :class:`collections.abc.Set`." msgstr "棄用 :class:`collections.abc.Set` 的別名。" -#: ../../library/typing.rst:3836 +#: ../../library/typing.rst:4004 msgid "" ":class:`collections.abc.Set` now supports subscripting (``[]``). See :pep:" "`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3842 +#: ../../library/typing.rst:4010 msgid "Deprecated alias to :class:`collections.abc.ByteString`." msgstr "棄用 :class:`collections.abc.ByteString` 的別名。" -#: ../../library/typing.rst:3844 +#: ../../library/typing.rst:4012 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -6000,7 +6258,7 @@ msgstr "" "用 :class:`~collections.abc.Buffer` 或明確指定你的程式碼所支援型別的聯集(例" "如 ``bytes | bytearray | memoryview``)。" -#: ../../library/typing.rst:3850 +#: ../../library/typing.rst:4018 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -6016,286 +6274,286 @@ msgstr "" "其他常見的緩衝區型別如 :class:`memoryview` 也從未被理解為 :class:`!" "ByteString` 的子型別(無論是在 runtime 還是由靜態型別檢查器)。" -#: ../../library/typing.rst:3858 +#: ../../library/typing.rst:4026 msgid "See :pep:`PEP 688 <688#current-options>` for more details." msgstr "更多細節請見 :pep:`PEP 688 <688#current-options>`。" -#: ../../library/typing.rst:3864 +#: ../../library/typing.rst:4032 msgid "Deprecated alias to :class:`collections.abc.Collection`." msgstr "棄用 :class:`collections.abc.Collection` 的別名。" -#: ../../library/typing.rst:3868 +#: ../../library/typing.rst:4036 msgid "" ":class:`collections.abc.Collection` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3874 +#: ../../library/typing.rst:4042 msgid "Deprecated alias to :class:`collections.abc.Container`." msgstr "棄用 :class:`collections.abc.Container` 的別名。" -#: ../../library/typing.rst:3876 +#: ../../library/typing.rst:4044 msgid "" ":class:`collections.abc.Container` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3882 +#: ../../library/typing.rst:4050 msgid "Deprecated alias to :class:`collections.abc.ItemsView`." msgstr "棄用 :class:`collections.abc.ItemsView` 的別名。" -#: ../../library/typing.rst:3884 +#: ../../library/typing.rst:4052 msgid "" ":class:`collections.abc.ItemsView` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3890 +#: ../../library/typing.rst:4058 msgid "Deprecated alias to :class:`collections.abc.KeysView`." msgstr "棄用 :class:`collections.abc.KeysView` 的別名。" -#: ../../library/typing.rst:3892 +#: ../../library/typing.rst:4060 msgid "" ":class:`collections.abc.KeysView` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3898 +#: ../../library/typing.rst:4066 msgid "Deprecated alias to :class:`collections.abc.Mapping`." msgstr "棄用 :class:`collections.abc.Mapping` 的別名。" -#: ../../library/typing.rst:3900 +#: ../../library/typing.rst:4068 msgid "" ":class:`collections.abc.Mapping` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3906 +#: ../../library/typing.rst:4074 msgid "Deprecated alias to :class:`collections.abc.MappingView`." msgstr "棄用 :class:`collections.abc.MappingView` 的別名。" -#: ../../library/typing.rst:3908 +#: ../../library/typing.rst:4076 msgid "" ":class:`collections.abc.MappingView` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3914 +#: ../../library/typing.rst:4082 msgid "Deprecated alias to :class:`collections.abc.MutableMapping`." msgstr "棄用 :class:`collections.abc.MutableMapping` 的別名。" -#: ../../library/typing.rst:3916 +#: ../../library/typing.rst:4084 msgid "" ":class:`collections.abc.MutableMapping` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3923 +#: ../../library/typing.rst:4091 msgid "Deprecated alias to :class:`collections.abc.MutableSequence`." msgstr "棄用 :class:`collections.abc.MutableSequence` 的別名。" -#: ../../library/typing.rst:3925 +#: ../../library/typing.rst:4093 msgid "" ":class:`collections.abc.MutableSequence` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3932 +#: ../../library/typing.rst:4100 msgid "Deprecated alias to :class:`collections.abc.MutableSet`." msgstr "棄用 :class:`collections.abc.MutableSet` 的別名。" -#: ../../library/typing.rst:3934 +#: ../../library/typing.rst:4102 msgid "" ":class:`collections.abc.MutableSet` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3940 +#: ../../library/typing.rst:4108 msgid "Deprecated alias to :class:`collections.abc.Sequence`." msgstr "棄用 :class:`collections.abc.Sequence` 的別名。" -#: ../../library/typing.rst:3942 +#: ../../library/typing.rst:4110 msgid "" ":class:`collections.abc.Sequence` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3948 +#: ../../library/typing.rst:4116 msgid "Deprecated alias to :class:`collections.abc.ValuesView`." msgstr "棄用 :class:`collections.abc.ValuesView` 的別名。" -#: ../../library/typing.rst:3950 +#: ../../library/typing.rst:4118 msgid "" ":class:`collections.abc.ValuesView` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3957 +#: ../../library/typing.rst:4125 msgid "Aliases to asynchronous ABCs in :mod:`collections.abc`" msgstr ":mod:`collections.abc` 中非同步 ABC 的別名" -#: ../../library/typing.rst:3961 +#: ../../library/typing.rst:4129 msgid "Deprecated alias to :class:`collections.abc.Coroutine`." msgstr "棄用 :class:`collections.abc.Coroutine` 的別名。" -#: ../../library/typing.rst:3963 +#: ../../library/typing.rst:4131 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on using :class:" "`collections.abc.Coroutine` and ``typing.Coroutine`` in type annotations." msgstr "" -#: ../../library/typing.rst:3969 +#: ../../library/typing.rst:4137 msgid "" ":class:`collections.abc.Coroutine` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3975 +#: ../../library/typing.rst:4143 msgid "Deprecated alias to :class:`collections.abc.AsyncGenerator`." msgstr "棄用 :class:`collections.abc.AsyncGenerator` 的別名。" -#: ../../library/typing.rst:3977 +#: ../../library/typing.rst:4145 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on using :class:" "`collections.abc.AsyncGenerator` and ``typing.AsyncGenerator`` in type " "annotations." msgstr "" -#: ../../library/typing.rst:3983 +#: ../../library/typing.rst:4151 msgid "" ":class:`collections.abc.AsyncGenerator` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:3988 +#: ../../library/typing.rst:4156 msgid "The ``SendType`` parameter now has a default." msgstr "``SendType`` 參數現在有預設值。" -#: ../../library/typing.rst:3993 +#: ../../library/typing.rst:4161 msgid "Deprecated alias to :class:`collections.abc.AsyncIterable`." msgstr "棄用 :class:`collections.abc.AsyncIterable` 的別名。" -#: ../../library/typing.rst:3997 +#: ../../library/typing.rst:4165 msgid "" ":class:`collections.abc.AsyncIterable` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4003 +#: ../../library/typing.rst:4171 msgid "Deprecated alias to :class:`collections.abc.AsyncIterator`." msgstr "棄用 :class:`collections.abc.AsyncIterator` 的別名。" -#: ../../library/typing.rst:4007 +#: ../../library/typing.rst:4175 msgid "" ":class:`collections.abc.AsyncIterator` now supports subscripting (``[]``). " "See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4013 +#: ../../library/typing.rst:4181 msgid "Deprecated alias to :class:`collections.abc.Awaitable`." msgstr "棄用 :class:`collections.abc.Awaitable` 的別名。" -#: ../../library/typing.rst:4017 +#: ../../library/typing.rst:4185 msgid "" ":class:`collections.abc.Awaitable` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4024 +#: ../../library/typing.rst:4192 msgid "Aliases to other ABCs in :mod:`collections.abc`" msgstr "" -#: ../../library/typing.rst:4028 +#: ../../library/typing.rst:4196 msgid "Deprecated alias to :class:`collections.abc.Iterable`." msgstr "棄用 :class:`collections.abc.Iterable` 的別名。" -#: ../../library/typing.rst:4030 +#: ../../library/typing.rst:4198 msgid "" ":class:`collections.abc.Iterable` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4036 +#: ../../library/typing.rst:4204 msgid "Deprecated alias to :class:`collections.abc.Iterator`." msgstr "棄用 :class:`collections.abc.Iterator` 的別名。" -#: ../../library/typing.rst:4038 +#: ../../library/typing.rst:4206 msgid "" ":class:`collections.abc.Iterator` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4044 +#: ../../library/typing.rst:4212 msgid "Deprecated alias to :class:`collections.abc.Callable`." msgstr "棄用 :class:`collections.abc.Callable` 的別名。" -#: ../../library/typing.rst:4046 +#: ../../library/typing.rst:4214 msgid "" "See :ref:`annotating-callables` for details on how to use :class:" "`collections.abc.Callable` and ``typing.Callable`` in type annotations." msgstr "" -#: ../../library/typing.rst:4049 +#: ../../library/typing.rst:4217 msgid "" ":class:`collections.abc.Callable` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4059 +#: ../../library/typing.rst:4227 msgid "Deprecated alias to :class:`collections.abc.Generator`." msgstr "棄用 :class:`collections.abc.Generator` 的別名。" -#: ../../library/typing.rst:4061 +#: ../../library/typing.rst:4229 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on using :class:" "`collections.abc.Generator` and ``typing.Generator`` in type annotations." msgstr "" -#: ../../library/typing.rst:4065 +#: ../../library/typing.rst:4233 msgid "" ":class:`collections.abc.Generator` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4069 +#: ../../library/typing.rst:4237 msgid "Default values for the send and return types were added." msgstr "" -#: ../../library/typing.rst:4074 +#: ../../library/typing.rst:4242 msgid "Deprecated alias to :class:`collections.abc.Hashable`." msgstr "棄用 :class:`collections.abc.Hashable` 的別名。" -#: ../../library/typing.rst:4076 +#: ../../library/typing.rst:4244 msgid "Use :class:`collections.abc.Hashable` directly instead." msgstr "改為直接使用 :class:`collections.abc.Hashable`。" -#: ../../library/typing.rst:4081 +#: ../../library/typing.rst:4249 msgid "Deprecated alias to :class:`collections.abc.Reversible`." msgstr "棄用 :class:`collections.abc.Reversible` 的別名。" -#: ../../library/typing.rst:4083 +#: ../../library/typing.rst:4251 msgid "" ":class:`collections.abc.Reversible` now supports subscripting (``[]``). See :" "pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4089 +#: ../../library/typing.rst:4257 msgid "Deprecated alias to :class:`collections.abc.Sized`." msgstr "棄用 :class:`collections.abc.Sized` 的別名。" -#: ../../library/typing.rst:4091 +#: ../../library/typing.rst:4259 msgid "Use :class:`collections.abc.Sized` directly instead." msgstr "改為直接使用 :class:`collections.abc.Sized`。" -#: ../../library/typing.rst:4097 +#: ../../library/typing.rst:4265 msgid "Aliases to :mod:`contextlib` ABCs" msgstr ":mod:`contextlib` ABC 的別名" -#: ../../library/typing.rst:4101 +#: ../../library/typing.rst:4269 msgid "Deprecated alias to :class:`contextlib.AbstractContextManager`." msgstr "" -#: ../../library/typing.rst:4103 +#: ../../library/typing.rst:4271 msgid "" "The first type parameter, ``T_co``, represents the type returned by the :" "meth:`~object.__enter__` method. The optional second type parameter, " @@ -6303,21 +6561,21 @@ msgid "" "returned by the :meth:`~object.__exit__` method." msgstr "" -#: ../../library/typing.rst:4110 +#: ../../library/typing.rst:4278 msgid "" ":class:`contextlib.AbstractContextManager` now supports subscripting " "(``[]``). See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4115 +#: ../../library/typing.rst:4283 msgid "Added the optional second type parameter, ``ExitT_co``." msgstr "" -#: ../../library/typing.rst:4120 +#: ../../library/typing.rst:4288 msgid "Deprecated alias to :class:`contextlib.AbstractAsyncContextManager`." msgstr "" -#: ../../library/typing.rst:4122 +#: ../../library/typing.rst:4290 msgid "" "The first type parameter, ``T_co``, represents the type returned by the :" "meth:`~object.__aenter__` method. The optional second type parameter, " @@ -6325,21 +6583,21 @@ msgid "" "returned by the :meth:`~object.__aexit__` method." msgstr "" -#: ../../library/typing.rst:4129 +#: ../../library/typing.rst:4297 msgid "" ":class:`contextlib.AbstractAsyncContextManager` now supports subscripting " "(``[]``). See :pep:`585` and :ref:`types-genericalias`." msgstr "" -#: ../../library/typing.rst:4134 +#: ../../library/typing.rst:4302 msgid "Added the optional second type parameter, ``AExitT_co``." msgstr "" -#: ../../library/typing.rst:4138 +#: ../../library/typing.rst:4306 msgid "Deprecation Timeline of Major Features" msgstr "主要功能的棄用時程表" -#: ../../library/typing.rst:4140 +#: ../../library/typing.rst:4308 msgid "" "Certain features in ``typing`` are deprecated and may be removed in a future " "version of Python. The following table summarizes major deprecations for " @@ -6347,112 +6605,100 @@ msgid "" "listed." msgstr "" -#: ../../library/typing.rst:4147 +#: ../../library/typing.rst:4315 msgid "Feature" msgstr "" -#: ../../library/typing.rst:4148 +#: ../../library/typing.rst:4316 msgid "Deprecated in" msgstr "棄用於" -#: ../../library/typing.rst:4149 +#: ../../library/typing.rst:4317 msgid "Projected removal" msgstr "" -#: ../../library/typing.rst:4150 +#: ../../library/typing.rst:4318 msgid "PEP/issue" msgstr "" -#: ../../library/typing.rst:4151 +#: ../../library/typing.rst:4319 msgid "``typing`` versions of standard collections" msgstr "" -#: ../../library/typing.rst:4152 ../../library/typing.rst:4156 +#: ../../library/typing.rst:4320 ../../library/typing.rst:4324 msgid "3.9" msgstr "3.9" -#: ../../library/typing.rst:4153 +#: ../../library/typing.rst:4321 msgid "Undecided (see :ref:`deprecated-aliases` for more information)" msgstr "" -#: ../../library/typing.rst:4154 +#: ../../library/typing.rst:4322 msgid ":pep:`585`" msgstr ":pep:`585`" -#: ../../library/typing.rst:4155 +#: ../../library/typing.rst:4323 msgid ":class:`typing.ByteString`" msgstr ":class:`typing.ByteString`" -#: ../../library/typing.rst:4157 +#: ../../library/typing.rst:4325 msgid "3.17" msgstr "3.17" -#: ../../library/typing.rst:4158 +#: ../../library/typing.rst:4326 msgid ":gh:`91896`" msgstr ":gh:`91896`" -#: ../../library/typing.rst:4159 +#: ../../library/typing.rst:4327 msgid ":data:`typing.Text`" msgstr ":data:`typing.Text`" -#: ../../library/typing.rst:4160 +#: ../../library/typing.rst:4328 msgid "3.11" msgstr "3.11" -#: ../../library/typing.rst:4161 ../../library/typing.rst:4165 -#: ../../library/typing.rst:4169 +#: ../../library/typing.rst:4329 ../../library/typing.rst:4333 +#: ../../library/typing.rst:4337 msgid "Undecided" msgstr "" -#: ../../library/typing.rst:4162 +#: ../../library/typing.rst:4330 msgid ":gh:`92332`" msgstr ":gh:`92332`" -#: ../../library/typing.rst:4163 +#: ../../library/typing.rst:4331 msgid ":class:`typing.Hashable` and :class:`typing.Sized`" msgstr ":class:`typing.Hashable` 和 :class:`typing.Sized`" -#: ../../library/typing.rst:4164 ../../library/typing.rst:4168 +#: ../../library/typing.rst:4332 ../../library/typing.rst:4336 msgid "3.12" msgstr "3.12" -#: ../../library/typing.rst:4166 +#: ../../library/typing.rst:4334 msgid ":gh:`94309`" msgstr ":gh:`94309`" -#: ../../library/typing.rst:4167 +#: ../../library/typing.rst:4335 msgid ":data:`typing.TypeAlias`" msgstr ":data:`typing.TypeAlias`" -#: ../../library/typing.rst:4170 +#: ../../library/typing.rst:4338 msgid ":pep:`695`" msgstr ":pep:`695`" -#: ../../library/typing.rst:4171 -msgid ":func:`@typing.no_type_check_decorator `" -msgstr ":func:`@typing.no_type_check_decorator `" +#: ../../library/typing.rst:4339 +msgid ":data:`typing.AnyStr`" +msgstr ":data:`typing.AnyStr`" -#: ../../library/typing.rst:4172 ../../library/typing.rst:4176 +#: ../../library/typing.rst:4340 msgid "3.13" msgstr "3.13" -#: ../../library/typing.rst:4173 -msgid "3.15" -msgstr "3.15" - -#: ../../library/typing.rst:4174 -msgid ":gh:`106309`" -msgstr ":gh:`106309`" - -#: ../../library/typing.rst:4175 -msgid ":data:`typing.AnyStr`" -msgstr ":data:`typing.AnyStr`" - -#: ../../library/typing.rst:4177 +#: ../../library/typing.rst:4341 msgid "3.18" msgstr "3.18" -#: ../../library/typing.rst:4178 +#: ../../library/typing.rst:4342 msgid ":gh:`105578`" msgstr ":gh:`105578`" @@ -6465,3 +6711,12 @@ msgstr "..." #: ../../library/typing.rst:1170 msgid "ellipsis literal" msgstr "ellipsis literal(刪節號字面值)" + +#~ msgid ":func:`@typing.no_type_check_decorator `" +#~ msgstr ":func:`@typing.no_type_check_decorator `" + +#~ msgid "3.15" +#~ msgstr "3.15" + +#~ msgid ":gh:`106309`" +#~ msgstr ":gh:`106309`" diff --git a/library/unicodedata.po b/library/unicodedata.po index f8691eb1e95..575ea2180f7 100644 --- a/library/unicodedata.po +++ b/library/unicodedata.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-25 00:14+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:14+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,35 +21,215 @@ msgstr "" msgid ":mod:`!unicodedata` --- Unicode Database" msgstr ":mod:`!unicodedata` --- Unicode 資料庫" -#: ../../library/unicodedata.rst:18 +#: ../../library/unicodedata.rst:14 msgid "" "This module provides access to the Unicode Character Database (UCD) which " "defines character properties for all Unicode characters. The data contained " -"in this database is compiled from the `UCD version 16.0.0 `_." +"in this database is compiled from the `UCD version 17.0.0 `_." msgstr "" -#: ../../library/unicodedata.rst:23 +#: ../../library/unicodedata.rst:19 msgid "" "The module uses the same names and symbols as defined by Unicode Standard " "Annex #44, `\"Unicode Character Database\" `_. It defines the following functions:" +"tr44/>`_." msgstr "" -#: ../../library/unicodedata.rst:30 +#: ../../library/unicodedata.rst:25 msgid "" "The :ref:`unicode-howto` for more information about Unicode and how to use " "this module." msgstr "" -#: ../../library/unicodedata.rst:36 +#: ../../library/unicodedata.rst:30 +msgid "**Lookup**" +msgstr "" + +#: ../../library/unicodedata.rst:32 +msgid ":func:`lookup(name) `" +msgstr ":func:`lookup(name) `" + +#: ../../library/unicodedata.rst:32 +msgid "Look up character by name" +msgstr "" + +#: ../../library/unicodedata.rst:33 +msgid ":func:`name(chr) `" +msgstr ":func:`name(chr) `" + +#: ../../library/unicodedata.rst:33 +msgid "Return the name assigned to a character" +msgstr "" + +#: ../../library/unicodedata.rst:35 +msgid "**Numeric values**" +msgstr "" + +#: ../../library/unicodedata.rst:37 +msgid ":func:`decimal(chr) `" +msgstr ":func:`decimal(chr) `" + +#: ../../library/unicodedata.rst:37 +msgid "Decimal value of a character" +msgstr "" + +#: ../../library/unicodedata.rst:38 +msgid ":func:`digit(chr) `" +msgstr ":func:`digit(chr) `" + +#: ../../library/unicodedata.rst:38 +msgid "Digit value of a character" +msgstr "" + +#: ../../library/unicodedata.rst:39 +msgid ":func:`numeric(chr) `" +msgstr ":func:`numeric(chr) `" + +#: ../../library/unicodedata.rst:39 +msgid "Numeric value of a character" +msgstr "" + +#: ../../library/unicodedata.rst:41 +msgid "**Properties**" +msgstr "" + +#: ../../library/unicodedata.rst:43 +msgid ":func:`bidirectional(chr) `" +msgstr ":func:`bidirectional(chr) `" + +#: ../../library/unicodedata.rst:43 +msgid "Bidirectional class of a character" +msgstr "" + +#: ../../library/unicodedata.rst:44 +msgid ":func:`block(chr) `" +msgstr ":func:`block(chr) `" + +#: ../../library/unicodedata.rst:44 +msgid "Unicode block of a character" +msgstr "" + +#: ../../library/unicodedata.rst:45 +msgid ":func:`category(chr) `" +msgstr ":func:`category(chr) `" + +#: ../../library/unicodedata.rst:45 +msgid "General category of a character" +msgstr "" + +#: ../../library/unicodedata.rst:46 +msgid ":func:`combining(chr) `" +msgstr ":func:`combining(chr) `" + +#: ../../library/unicodedata.rst:46 +msgid "Canonical combining class of a character" +msgstr "" + +#: ../../library/unicodedata.rst:47 +msgid ":func:`decomposition(chr) `" +msgstr ":func:`decomposition(chr) `" + +#: ../../library/unicodedata.rst:47 +msgid "Character decomposition mapping" +msgstr "" + +#: ../../library/unicodedata.rst:48 +msgid ":func:`east_asian_width(chr) `" +msgstr ":func:`east_asian_width(chr) `" + +#: ../../library/unicodedata.rst:48 +msgid "East Asian width of a character" +msgstr "" + +#: ../../library/unicodedata.rst:49 +msgid ":func:`extended_pictographic(chr) `" +msgstr ":func:`extended_pictographic(chr) `" + +#: ../../library/unicodedata.rst:49 +msgid "Check if a character has the Extended_Pictographic property" +msgstr "" + +#: ../../library/unicodedata.rst:50 +msgid ":func:`grapheme_cluster_break(chr) `" +msgstr ":func:`grapheme_cluster_break(chr) `" + +#: ../../library/unicodedata.rst:50 +msgid "Grapheme_Cluster_Break property of a character" +msgstr "" + +#: ../../library/unicodedata.rst:51 +msgid ":func:`indic_conjunct_break(chr) `" +msgstr ":func:`indic_conjunct_break(chr) `" + +#: ../../library/unicodedata.rst:51 +msgid "Indic_Conjunct_Break property of a character" +msgstr "" + +#: ../../library/unicodedata.rst:52 +msgid ":func:`isxidcontinue(chr) `" +msgstr ":func:`isxidcontinue(chr) `" + +#: ../../library/unicodedata.rst:52 +msgid "Check if a character is a valid identifier continuation" +msgstr "" + +#: ../../library/unicodedata.rst:53 +msgid ":func:`isxidstart(chr) `" +msgstr ":func:`isxidstart(chr) `" + +#: ../../library/unicodedata.rst:53 +msgid "Check if a character is a valid identifier start" +msgstr "" + +#: ../../library/unicodedata.rst:54 +msgid ":func:`mirrored(chr) `" +msgstr ":func:`mirrored(chr) `" + +#: ../../library/unicodedata.rst:54 +msgid "Mirrored property of a character" +msgstr "" + +#: ../../library/unicodedata.rst:56 +msgid "**Normalization**" +msgstr "" + +#: ../../library/unicodedata.rst:58 +msgid ":func:`normalize(form, unistr) `" +msgstr ":func:`normalize(form, unistr) `" + +#: ../../library/unicodedata.rst:58 +msgid "Return the normalized form of a string" +msgstr "" + +#: ../../library/unicodedata.rst:59 +msgid ":func:`is_normalized(form, unistr) `" +msgstr ":func:`is_normalized(form, unistr) `" + +#: ../../library/unicodedata.rst:59 +msgid "Check if a Unicode string is normalized" +msgstr "" + +#: ../../library/unicodedata.rst:61 +msgid "**Text segmentation**" +msgstr "" + +#: ../../library/unicodedata.rst:63 +msgid ":func:`iter_graphemes(unistr) `" +msgstr ":func:`iter_graphemes(unistr) `" + +#: ../../library/unicodedata.rst:63 +msgid "Iterate over grapheme clusters in a string" +msgstr "" + +#: ../../library/unicodedata.rst:69 msgid "" "Look up character by name. If a character with the given name is found, " "return the corresponding character. If not found, :exc:`KeyError` is " "raised. For example::" msgstr "" -#: ../../library/unicodedata.rst:40 +#: ../../library/unicodedata.rst:73 msgid "" ">>> unicodedata.lookup('LEFT CURLY BRACKET')\n" "'{'" @@ -57,13 +237,13 @@ msgstr "" ">>> unicodedata.lookup('LEFT CURLY BRACKET')\n" "'{'" -#: ../../library/unicodedata.rst:43 +#: ../../library/unicodedata.rst:76 msgid "" "The characters returned by this function are the same as those produced by " "``\\N`` escape sequence in string literals. For example::" msgstr "" -#: ../../library/unicodedata.rst:46 +#: ../../library/unicodedata.rst:79 msgid "" ">>> unicodedata.lookup('MIDDLE DOT') == '\\N{MIDDLE DOT}'\n" "True" @@ -71,18 +251,18 @@ msgstr "" ">>> unicodedata.lookup('MIDDLE DOT') == '\\N{MIDDLE DOT}'\n" "True" -#: ../../library/unicodedata.rst:49 +#: ../../library/unicodedata.rst:82 msgid "Support for name aliases [#]_ and named sequences [#]_ has been added." msgstr "已新增對名稱別名 [#]_ 和命名序列 [#]_ 的支援。" -#: ../../library/unicodedata.rst:55 +#: ../../library/unicodedata.rst:88 msgid "" "Returns the name assigned to the character *chr* as a string. If no name is " "defined, *default* is returned, or, if not given, :exc:`ValueError` is " "raised. For example::" msgstr "" -#: ../../library/unicodedata.rst:59 +#: ../../library/unicodedata.rst:92 msgid "" ">>> unicodedata.name('½')\n" "'VULGAR FRACTION ONE HALF'\n" @@ -94,14 +274,14 @@ msgstr "" ">>> unicodedata.name('\\uFFFF', 'fallback')\n" "'fallback'" -#: ../../library/unicodedata.rst:67 +#: ../../library/unicodedata.rst:100 msgid "" "Returns the decimal value assigned to the character *chr* as integer. If no " "such value is defined, *default* is returned, or, if not given, :exc:" "`ValueError` is raised. For example::" msgstr "" -#: ../../library/unicodedata.rst:71 +#: ../../library/unicodedata.rst:104 msgid "" ">>> unicodedata.decimal('\\N{ARABIC-INDIC DIGIT NINE}')\n" "9\n" @@ -113,14 +293,14 @@ msgstr "" ">>> unicodedata.decimal('\\N{SUPERSCRIPT NINE}', -1)\n" "-1" -#: ../../library/unicodedata.rst:79 +#: ../../library/unicodedata.rst:112 msgid "" "Returns the digit value assigned to the character *chr* as integer. If no " "such value is defined, *default* is returned, or, if not given, :exc:" "`ValueError` is raised::" msgstr "" -#: ../../library/unicodedata.rst:83 +#: ../../library/unicodedata.rst:116 msgid "" ">>> unicodedata.digit('\\N{SUPERSCRIPT NINE}')\n" "9" @@ -128,14 +308,14 @@ msgstr "" ">>> unicodedata.digit('\\N{SUPERSCRIPT NINE}')\n" "9" -#: ../../library/unicodedata.rst:89 +#: ../../library/unicodedata.rst:122 msgid "" "Returns the numeric value assigned to the character *chr* as float. If no " "such value is defined, *default* is returned, or, if not given, :exc:" "`ValueError` is raised::" msgstr "" -#: ../../library/unicodedata.rst:93 +#: ../../library/unicodedata.rst:126 msgid "" ">>> unicodedata.numeric('½')\n" "0.5" @@ -143,16 +323,16 @@ msgstr "" ">>> unicodedata.numeric('½')\n" "0.5" -#: ../../library/unicodedata.rst:99 +#: ../../library/unicodedata.rst:132 msgid "" "Returns the general category assigned to the character *chr* as string. " "General category names consist of two letters. See the `General Category " "Values section of the Unicode Character Database documentation `_ for a list " -"of category codes. For example::" +"unicode.org/reports/tr44/#General_Category_Values>`_ for a list of category " +"codes. For example::" msgstr "" -#: ../../library/unicodedata.rst:105 +#: ../../library/unicodedata.rst:138 msgid "" ">>> unicodedata.category('A') # 'L'etter, 'u'ppercase\n" "'Lu'" @@ -160,46 +340,60 @@ msgstr "" ">>> unicodedata.category('A') # 'L'etter, 'u'ppercase\n" "'Lu'" -#: ../../library/unicodedata.rst:111 +#: ../../library/unicodedata.rst:144 msgid "" "Returns the bidirectional class assigned to the character *chr* as string. " "If no such value is defined, an empty string is returned. See the " "`Bidirectional Class Values section of the Unicode Character Database " -"`_ " -"documentation for a list of bidirectional codes. For example::" +"`_ documentation " +"for a list of bidirectional codes. For example::" msgstr "" -#: ../../library/unicodedata.rst:117 +#: ../../library/unicodedata.rst:150 msgid "" ">>> unicodedata.bidirectional('\\N{ARABIC-INDIC DIGIT SEVEN}') # 'A'rabic, " "'N'umber\n" "'AN'" msgstr "" -#: ../../library/unicodedata.rst:123 +#: ../../library/unicodedata.rst:156 msgid "" "Returns the canonical combining class assigned to the character *chr* as " "integer. Returns ``0`` if no combining class is defined. See the `Canonical " "Combining Class Values section of the Unicode Character Database `_ for more information." +"www.unicode.org/reports/tr44/#Canonical_Combining_Class_Values>`_ for more " +"information." msgstr "" -#: ../../library/unicodedata.rst:132 +#: ../../library/unicodedata.rst:165 msgid "" "Returns the east asian width assigned to the character *chr* as string. For " "a list of widths and or more information, see the `Unicode Standard Annex " -"#11 `_." +"#11 `_." +msgstr "" + +#: ../../library/unicodedata.rst:172 +msgid "" +"Returns the `block `_ assigned to the character *chr*. For example::" +msgstr "" + +#: ../../library/unicodedata.rst:176 +msgid "" +">>> unicodedata.block('S')\n" +"'Basic Latin'" msgstr "" +">>> unicodedata.block('S')\n" +"'Basic Latin'" -#: ../../library/unicodedata.rst:139 +#: ../../library/unicodedata.rst:184 msgid "" "Returns the mirrored property assigned to the character *chr* as integer. " "Returns ``1`` if the character has been identified as a \"mirrored\" " "character in bidirectional text, ``0`` otherwise. For example::" msgstr "" -#: ../../library/unicodedata.rst:143 +#: ../../library/unicodedata.rst:188 msgid "" ">>> unicodedata.mirrored('>')\n" "1" @@ -207,14 +401,52 @@ msgstr "" ">>> unicodedata.mirrored('>')\n" "1" -#: ../../library/unicodedata.rst:149 +#: ../../library/unicodedata.rst:194 +msgid "" +"Return ``True`` if *chr* is a valid identifier start per the `Unicode " +"Standard Annex #31 `_, that is, it " +"has the ``XID_Start`` property. Return ``False`` otherwise. For example::" +msgstr "" + +#: ../../library/unicodedata.rst:199 +msgid "" +">>> unicodedata.isxidstart('S')\n" +"True\n" +">>> unicodedata.isxidstart('0')\n" +"False" +msgstr "" +">>> unicodedata.isxidstart('S')\n" +"True\n" +">>> unicodedata.isxidstart('0')\n" +"False" + +#: ../../library/unicodedata.rst:209 +msgid "" +"Return ``True`` if *chr* is a valid identifier character per the `Unicode " +"Standard Annex #31 `_, that is, it " +"has the ``XID_Continue`` property. Return ``False`` otherwise. For example::" +msgstr "" + +#: ../../library/unicodedata.rst:214 +msgid "" +">>> unicodedata.isxidcontinue('S')\n" +"True\n" +">>> unicodedata.isxidcontinue(' ')\n" +"False" +msgstr "" +">>> unicodedata.isxidcontinue('S')\n" +"True\n" +">>> unicodedata.isxidcontinue(' ')\n" +"False" + +#: ../../library/unicodedata.rst:224 msgid "" "Returns the character decomposition mapping assigned to the character *chr* " "as string. An empty string is returned in case no such mapping is defined. " "For example::" msgstr "" -#: ../../library/unicodedata.rst:153 +#: ../../library/unicodedata.rst:228 msgid "" ">>> unicodedata.decomposition('Ã')\n" "'0041 0303'" @@ -222,13 +454,27 @@ msgstr "" ">>> unicodedata.decomposition('Ã')\n" "'0041 0303'" -#: ../../library/unicodedata.rst:159 +#: ../../library/unicodedata.rst:234 +msgid "Returns the Grapheme_Cluster_Break property assigned to the character." +msgstr "" + +#: ../../library/unicodedata.rst:241 +msgid "Returns the Indic_Conjunct_Break property assigned to the character." +msgstr "" + +#: ../../library/unicodedata.rst:248 +msgid "" +"Returns ``True`` if the character has the Extended_Pictographic property, " +"``False`` otherwise." +msgstr "" + +#: ../../library/unicodedata.rst:256 msgid "" "Return the normal form *form* for the Unicode string *unistr*. Valid values " "for *form* are 'NFC', 'NFKC', 'NFD', and 'NFKD'." msgstr "" -#: ../../library/unicodedata.rst:162 +#: ../../library/unicodedata.rst:259 msgid "" "The Unicode standard defines various normalization forms of a Unicode " "string, based on the definition of canonical equivalence and compatibility " @@ -238,7 +484,7 @@ msgid "" "(COMBINING CEDILLA)." msgstr "" -#: ../../library/unicodedata.rst:168 +#: ../../library/unicodedata.rst:265 msgid "" "For each character, there are two normal forms: normal form C and normal " "form D. Normal form D (NFD) is also known as canonical decomposition, and " @@ -247,7 +493,7 @@ msgid "" "characters again." msgstr "" -#: ../../library/unicodedata.rst:173 +#: ../../library/unicodedata.rst:270 msgid "" "In addition to these two forms, there are two additional normal forms based " "on compatibility equivalence. In Unicode, certain characters are supported " @@ -257,7 +503,7 @@ msgid "" "character sets (for example, gb2312)." msgstr "" -#: ../../library/unicodedata.rst:180 +#: ../../library/unicodedata.rst:277 msgid "" "The normal form KD (NFKD) will apply the compatibility decomposition, that " "is, replace all compatibility characters with their equivalents. The normal " @@ -265,54 +511,75 @@ msgid "" "the canonical composition." msgstr "" -#: ../../library/unicodedata.rst:185 +#: ../../library/unicodedata.rst:282 msgid "" "Even if two unicode strings are normalized and look the same to a human " "reader, if one has combining characters and the other doesn't, they may not " "compare equal." msgstr "" -#: ../../library/unicodedata.rst:192 +#: ../../library/unicodedata.rst:289 msgid "" "Return whether the Unicode string *unistr* is in the normal form *form*. " "Valid values for *form* are 'NFC', 'NFKC', 'NFD', and 'NFKD'." msgstr "" -#: ../../library/unicodedata.rst:198 -msgid "In addition, the module exposes the following constant:" +#: ../../library/unicodedata.rst:297 +msgid "" +"Returns an iterator to iterate over grapheme clusters. With optional " +"*start*, iteration begins at that position. With optional *end*, iteration " +"stops at that position." msgstr "" -#: ../../library/unicodedata.rst:202 +#: ../../library/unicodedata.rst:301 +msgid "" +"Converting an emitted item to string returns a substring corresponding to " +"the grapheme cluster. Its ``start`` and ``end`` attributes denote the start " +"and end of the grapheme cluster." +msgstr "" + +#: ../../library/unicodedata.rst:306 +msgid "" +"It uses extended grapheme cluster rules defined by Unicode Standard Annex " +"#29, `\"Unicode Text Segmentation\" `_." +msgstr "" + +#: ../../library/unicodedata.rst:313 +msgid "In addition, the module exposes the following constants:" +msgstr "" + +#: ../../library/unicodedata.rst:317 msgid "The version of the Unicode database used in this module." msgstr "在此模組中使用的 Unicode 資料庫版本。" -#: ../../library/unicodedata.rst:207 +#: ../../library/unicodedata.rst:322 msgid "" -"This is an object that has the same methods as the entire module, but uses " -"the Unicode database version 3.2 instead, for applications that require this " -"specific version of the Unicode database (such as IDNA)." +"This is an object that has most of the methods of the entire module, but " +"uses the Unicode database version 3.2 instead, for applications that require " +"this specific version of the Unicode database (such as IDNA)." msgstr "" -#: ../../library/unicodedata.rst:213 +#: ../../library/unicodedata.rst:328 msgid "Footnotes" msgstr "註腳" -#: ../../library/unicodedata.rst:214 -msgid "https://www.unicode.org/Public/16.0.0/ucd/NameAliases.txt" -msgstr "https://www.unicode.org/Public/16.0.0/ucd/NameAliases.txt" +#: ../../library/unicodedata.rst:329 +msgid "https://www.unicode.org/Public/17.0.0/ucd/NameAliases.txt" +msgstr "https://www.unicode.org/Public/17.0.0/ucd/NameAliases.txt" -#: ../../library/unicodedata.rst:216 -msgid "https://www.unicode.org/Public/16.0.0/ucd/NamedSequences.txt" -msgstr "https://www.unicode.org/Public/16.0.0/ucd/NamedSequences.txt" +#: ../../library/unicodedata.rst:331 +msgid "https://www.unicode.org/Public/17.0.0/ucd/NamedSequences.txt" +msgstr "https://www.unicode.org/Public/17.0.0/ucd/NamedSequences.txt" -#: ../../library/unicodedata.rst:11 +#: ../../library/unicodedata.rst:7 msgid "Unicode" msgstr "Unicode" -#: ../../library/unicodedata.rst:11 +#: ../../library/unicodedata.rst:7 msgid "character" msgstr "character(字元)" -#: ../../library/unicodedata.rst:11 +#: ../../library/unicodedata.rst:7 msgid "database" msgstr "database(資料庫)" diff --git a/library/unittest.mock-examples.po b/library/unittest.mock-examples.po index 2cf6b3f4525..2682f98058b 100644 --- a/library/unittest.mock-examples.po +++ b/library/unittest.mock-examples.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-22 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-05-06 08:22+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,27 +22,27 @@ msgstr "" msgid ":mod:`!unittest.mock` --- getting started" msgstr ":mod:`!unittest.mock` --- 入門指南" -#: ../../library/unittest.mock-examples.rst:27 +#: ../../library/unittest.mock-examples.rst:26 msgid "Using Mock" msgstr "使用 Mock 的方式" -#: ../../library/unittest.mock-examples.rst:30 +#: ../../library/unittest.mock-examples.rst:29 msgid "Mock patching methods" msgstr "使用 Mock 來 patching 方法" -#: ../../library/unittest.mock-examples.rst:32 +#: ../../library/unittest.mock-examples.rst:31 msgid "Common uses for :class:`Mock` objects include:" msgstr ":class:`Mock` 物件的常見用法包含:" -#: ../../library/unittest.mock-examples.rst:34 +#: ../../library/unittest.mock-examples.rst:33 msgid "Patching methods" msgstr "Patching 方法" -#: ../../library/unittest.mock-examples.rst:35 +#: ../../library/unittest.mock-examples.rst:34 msgid "Recording method calls on objects" msgstr "記錄在物件上的方法呼叫" -#: ../../library/unittest.mock-examples.rst:37 +#: ../../library/unittest.mock-examples.rst:36 msgid "" "You might want to replace a method on an object to check that it is called " "with the correct arguments by another part of the system:" @@ -50,7 +50,7 @@ msgstr "" "你可能會想要取代一個物件上的方法,以便檢查系統的另一部分是否使用正確的引數呼" "叫它:" -#: ../../library/unittest.mock-examples.rst:45 +#: ../../library/unittest.mock-examples.rst:44 msgid "" "Once our mock has been used (``real.method`` in this example) it has methods " "and attributes that allow you to make assertions about how it has been used." @@ -58,7 +58,7 @@ msgstr "" "一旦我們的 mock 已經被使用(例如在這個範例中的 ``real.method``\\ ),它就有了" "方法和屬性,允許你對其使用方式進行斷言 (assertions)。" -#: ../../library/unittest.mock-examples.rst:50 +#: ../../library/unittest.mock-examples.rst:49 msgid "" "In most of these examples the :class:`Mock` and :class:`MagicMock` classes " "are interchangeable. As the ``MagicMock`` is the more capable class it makes " @@ -67,7 +67,7 @@ msgstr "" "在大多數的範例中,:class:`Mock` 和 :class:`MagicMock` 類別是可以互換的。不過" "由於 ``MagicMock`` 是功能更強大的類別,因此通常它是一個更好的選擇。" -#: ../../library/unittest.mock-examples.rst:54 +#: ../../library/unittest.mock-examples.rst:53 msgid "" "Once the mock has been called its :attr:`~Mock.called` attribute is set to " "``True``. More importantly we can use the :meth:`~Mock.assert_called_with` " @@ -78,7 +78,7 @@ msgstr "" "是,我們可以使用 :meth:`~Mock.assert_called_with` 或 :meth:`~Mock." "assert_called_once_with` 方法來檢查它是否被使用正確的引數來呼叫。" -#: ../../library/unittest.mock-examples.rst:59 +#: ../../library/unittest.mock-examples.rst:58 msgid "" "This example tests that calling ``ProductionClass().method`` results in a " "call to the ``something`` method:" @@ -86,11 +86,11 @@ msgstr "" "這個範例測試呼叫 ``ProductionClass().method`` 是否導致對 ``something`` 方法的" "呼叫:" -#: ../../library/unittest.mock-examples.rst:76 +#: ../../library/unittest.mock-examples.rst:75 msgid "Mock for method calls on an object" msgstr "對物件的方法呼叫使用 mock" -#: ../../library/unittest.mock-examples.rst:78 +#: ../../library/unittest.mock-examples.rst:77 msgid "" "In the last example we patched a method directly on an object to check that " "it was called correctly. Another common use case is to pass an object into a " @@ -101,7 +101,7 @@ msgstr "" "一個常見的用法是將一個物件傳遞給一個方法(或受測系統的某一部分),然後檢查它" "是否以正確的方式被使用。" -#: ../../library/unittest.mock-examples.rst:83 +#: ../../library/unittest.mock-examples.rst:82 msgid "" "The simple ``ProductionClass`` below has a ``closer`` method. If it is " "called with an object then it calls ``close`` on it." @@ -109,7 +109,7 @@ msgstr "" "下面是一個單純的 ``ProductionClass``,含有一個 ``closer`` 方法。如果它被傳入" "一個物件,它就會呼叫此物件中的 ``close``。" -#: ../../library/unittest.mock-examples.rst:91 +#: ../../library/unittest.mock-examples.rst:90 msgid "" "So to test it we need to pass in an object with a ``close`` method and check " "that it was called correctly." @@ -117,7 +117,7 @@ msgstr "" "因此,為了對此進行測試,我們需要傳遞一個具有 ``close`` 方法的物件,並檢查它是" "否被正確的呼叫。" -#: ../../library/unittest.mock-examples.rst:99 +#: ../../library/unittest.mock-examples.rst:98 msgid "" "We don't have to do any work to provide the 'close' method on our mock. " "Accessing close creates it. So, if 'close' hasn't already been called then " @@ -128,11 +128,11 @@ msgstr "" "此,如果 'close' 並未被呼叫過,在測試中存取 'close' 就會建立它,但 :meth:" "`~Mock.assert_called_with` 就會引發一個失敗的例外。" -#: ../../library/unittest.mock-examples.rst:106 +#: ../../library/unittest.mock-examples.rst:105 msgid "Mocking classes" msgstr "Mock 類別" -#: ../../library/unittest.mock-examples.rst:108 +#: ../../library/unittest.mock-examples.rst:107 msgid "" "A common use case is to mock out classes instantiated by your code under " "test. When you patch a class, then that class is replaced with a mock. " @@ -143,7 +143,7 @@ msgstr "" "別時,該類別就會被替換為 mock。實例是透過\\ *呼叫類別*\\ 建立的。這代表你可以" "透過查看被 mock 的類別的回傳值來存取「mock 實例」。" -#: ../../library/unittest.mock-examples.rst:113 +#: ../../library/unittest.mock-examples.rst:112 msgid "" "In the example below we have a function ``some_function`` that instantiates " "``Foo`` and calls a method on it. The call to :func:`patch` replaces the " @@ -156,7 +156,7 @@ msgstr "" "叫 mock 的結果,因此它是透過修改 mock :attr:`~Mock.return_value` 來配置" "的。: ::" -#: ../../library/unittest.mock-examples.rst:118 +#: ../../library/unittest.mock-examples.rst:117 msgid "" ">>> def some_function():\n" "... instance = module.Foo()\n" @@ -178,11 +178,11 @@ msgstr "" "... result = some_function()\n" "... assert result == 'the result'" -#: ../../library/unittest.mock-examples.rst:130 +#: ../../library/unittest.mock-examples.rst:129 msgid "Naming your mocks" msgstr "命名你的 mock" -#: ../../library/unittest.mock-examples.rst:132 +#: ../../library/unittest.mock-examples.rst:131 msgid "" "It can be useful to give your mocks a name. The name is shown in the repr of " "the mock and can be helpful when the mock appears in test failure messages. " @@ -191,11 +191,11 @@ msgstr "" "為你的 mock 命名可能會很有用。這個名稱會顯示在 mock 的 repr 中,且當 mock 出" "現在測試的失敗訊息中時,名稱會很有幫助。該名稱也會傳播到 mock 的屬性或方法:" -#: ../../library/unittest.mock-examples.rst:144 +#: ../../library/unittest.mock-examples.rst:143 msgid "Tracking all calls" msgstr "追蹤所有呼叫" -#: ../../library/unittest.mock-examples.rst:146 +#: ../../library/unittest.mock-examples.rst:145 msgid "" "Often you want to track more than a single call to a method. The :attr:" "`~Mock.mock_calls` attribute records all calls to child attributes of the " @@ -204,7 +204,7 @@ msgstr "" "通常你會想要追蹤對一個方法的多個呼叫。:attr:`~Mock.mock_calls` 屬性記錄對 " "mock 的子屬性以及其子屬性的所有呼叫。" -#: ../../library/unittest.mock-examples.rst:158 +#: ../../library/unittest.mock-examples.rst:157 msgid "" "If you make an assertion about ``mock_calls`` and any unexpected methods " "have been called, then the assertion will fail. This is useful because as " @@ -215,13 +215,13 @@ msgstr "" "這很有用,因為除了斷言你期望的呼叫已經進行之外,你還可以檢查它們是否按正確的" "順序進行,並且沒有多餘的呼叫:" -#: ../../library/unittest.mock-examples.rst:163 +#: ../../library/unittest.mock-examples.rst:162 msgid "" "You use the :data:`call` object to construct lists for comparing with " "``mock_calls``:" msgstr "你可以使用 :data:`call` 物件來建構串列以與 ``mock_calls`` 進行比較:" -#: ../../library/unittest.mock-examples.rst:170 +#: ../../library/unittest.mock-examples.rst:169 msgid "" "However, parameters to calls that return mocks are not recorded, which means " "it is not possible to track nested calls where the parameters used to create " @@ -230,27 +230,27 @@ msgstr "" "然而,回傳 mock 的呼叫的參數不會被記錄,這代表在巢狀呼叫中,無法追蹤用於建立" "上代的參數 important 的值:" -#: ../../library/unittest.mock-examples.rst:181 +#: ../../library/unittest.mock-examples.rst:180 msgid "Setting return values and attributes" msgstr "設定回傳值和屬性" -#: ../../library/unittest.mock-examples.rst:183 +#: ../../library/unittest.mock-examples.rst:182 msgid "Setting the return values on a mock object is trivially easy:" msgstr "在 mock 物件上設定回傳值非常簡單:" -#: ../../library/unittest.mock-examples.rst:190 +#: ../../library/unittest.mock-examples.rst:189 msgid "Of course you can do the same for methods on the mock:" msgstr "當然,你可以對 mock 上的方法執行相同的操作:" -#: ../../library/unittest.mock-examples.rst:197 +#: ../../library/unittest.mock-examples.rst:196 msgid "The return value can also be set in the constructor:" msgstr "回傳值也可以在建構函式中設定:" -#: ../../library/unittest.mock-examples.rst:203 +#: ../../library/unittest.mock-examples.rst:202 msgid "If you need an attribute setting on your mock, just do it:" msgstr "如果你需要在 mock 上進行屬性設置,只需執行以下操作:" -#: ../../library/unittest.mock-examples.rst:210 +#: ../../library/unittest.mock-examples.rst:209 msgid "" "Sometimes you want to mock up a more complex situation, like for example " "``mock.connection.cursor().execute(\"SELECT 1\")``. If we wanted this call " @@ -260,7 +260,7 @@ msgstr "" "execute(\"SELECT 1\")``。如果我們希望此呼叫回傳一個串列,那麼我們就必須配置巢" "狀呼叫的結果。" -#: ../../library/unittest.mock-examples.rst:214 +#: ../../library/unittest.mock-examples.rst:213 msgid "" "We can use :data:`call` to construct the set of calls in a \"chained call\" " "like this for easy assertion afterwards:" @@ -268,18 +268,18 @@ msgstr "" "如下所示,我們可以使用 :data:`call` 在「鍊接呼叫 (chained call)」中建構呼叫的" "集合,以便在之後輕鬆的進行斷言:" -#: ../../library/unittest.mock-examples.rst:228 +#: ../../library/unittest.mock-examples.rst:227 msgid "" "It is the call to ``.call_list()`` that turns our call object into a list of " "calls representing the chained calls." msgstr "" "正是對 ``.call_list()`` 的呼叫將我們的呼叫物件轉換為代表鍊接呼叫的呼叫串列。" -#: ../../library/unittest.mock-examples.rst:233 +#: ../../library/unittest.mock-examples.rst:232 msgid "Raising exceptions with mocks" msgstr "透過 mock 引發例外" -#: ../../library/unittest.mock-examples.rst:235 +#: ../../library/unittest.mock-examples.rst:234 msgid "" "A useful attribute is :attr:`~Mock.side_effect`. If you set this to an " "exception class or instance then the exception will be raised when the mock " @@ -288,11 +288,11 @@ msgstr "" "一個有用的屬性是 :attr:`~Mock.side_effect`。如果將其設定為例外類別或實例,則" "當 mock 被呼叫時將引發例外。" -#: ../../library/unittest.mock-examples.rst:247 +#: ../../library/unittest.mock-examples.rst:246 msgid "Side effect functions and iterables" msgstr "Side effect 函式以及可疊代物件" -#: ../../library/unittest.mock-examples.rst:249 +#: ../../library/unittest.mock-examples.rst:248 msgid "" "``side_effect`` can also be set to a function or an iterable. The use case " "for ``side_effect`` as an iterable is where your mock is going to be called " @@ -305,7 +305,7 @@ msgstr "" "將 ``side_effect`` 設定為可疊代物件時,對 mock 的每次呼叫都會傳回可疊代物件中" "的下一個值:" -#: ../../library/unittest.mock-examples.rst:264 +#: ../../library/unittest.mock-examples.rst:263 msgid "" "For more advanced use cases, like dynamically varying the return values " "depending on what the mock is called with, ``side_effect`` can be a " @@ -316,11 +316,11 @@ msgstr "" "``side_effect`` 設成一個函式。該函式會使用與 mock 相同的引數被呼叫。函式回傳" "的內容就會是呼叫回傳的內容:" -#: ../../library/unittest.mock-examples.rst:281 +#: ../../library/unittest.mock-examples.rst:280 msgid "Mocking asynchronous iterators" msgstr "Mock 非同步可疊代物件" -#: ../../library/unittest.mock-examples.rst:283 +#: ../../library/unittest.mock-examples.rst:282 msgid "" "Since Python 3.8, ``AsyncMock`` and ``MagicMock`` have support to mock :ref:" "`async-iterators` through ``__aiter__``. The :attr:`~Mock.return_value` " @@ -331,11 +331,11 @@ msgstr "" "mock :ref:`async-iterators`。``__aiter__`` 的 :attr:`~Mock.return_value` 屬性" "可用來設定用於疊代的回傳值。" -#: ../../library/unittest.mock-examples.rst:298 +#: ../../library/unittest.mock-examples.rst:297 msgid "Mocking asynchronous context manager" msgstr "Mock 非同步情境管理器" -#: ../../library/unittest.mock-examples.rst:300 +#: ../../library/unittest.mock-examples.rst:299 msgid "" "Since Python 3.8, ``AsyncMock`` and ``MagicMock`` have support to mock :ref:" "`async-context-managers` through ``__aenter__`` and ``__aexit__``. By " @@ -346,11 +346,11 @@ msgstr "" "和 ``__aexit__`` 來 mock :ref:`async-context-managers`。預設情況下," "``__aenter__`` 和 ``__aexit__`` 是回傳非同步函式的 ``AsyncMock`` 實例。" -#: ../../library/unittest.mock-examples.rst:322 +#: ../../library/unittest.mock-examples.rst:321 msgid "Creating a mock from an existing object" msgstr "從現有物件建立 mock" -#: ../../library/unittest.mock-examples.rst:324 +#: ../../library/unittest.mock-examples.rst:323 msgid "" "One problem with over use of mocking is that it couples your tests to the " "implementation of your mocks rather than your real code. Suppose you have a " @@ -365,7 +365,7 @@ msgstr "" "重構第一個類別,使其不再具有 ``some_method`` - 那麼即使你的程式碼已經損壞,你" "的測試也將繼續通過!" -#: ../../library/unittest.mock-examples.rst:331 +#: ../../library/unittest.mock-examples.rst:330 msgid "" ":class:`Mock` allows you to provide an object as a specification for the " "mock, using the *spec* keyword argument. Accessing methods / attributes on " @@ -378,7 +378,7 @@ msgstr "" "mock 存取規格物件上不存在的方法或屬性將立即引發一個屬性錯誤。如果你更改規格的" "實作,那麼使用該類別的測試將立即失敗,而無需在這些測試中實例化該類別。" -#: ../../library/unittest.mock-examples.rst:344 +#: ../../library/unittest.mock-examples.rst:343 msgid "" "Using a specification also enables a smarter matching of calls made to the " "mock, regardless of whether some parameters were passed as positional or " @@ -387,7 +387,7 @@ msgstr "" "使用規格還可以更聰明地匹配對 mock 的呼叫,無論引數是作為位置引數還是命名引數" "傳遞: ::" -#: ../../library/unittest.mock-examples.rst:348 +#: ../../library/unittest.mock-examples.rst:347 msgid "" ">>> def f(a, b, c): pass\n" "...\n" @@ -403,7 +403,7 @@ msgstr "" "\n" ">>> mock.assert_called_with(a=1, b=2, c=3)" -#: ../../library/unittest.mock-examples.rst:355 +#: ../../library/unittest.mock-examples.rst:354 msgid "" "If you want this smarter matching to also work with method calls on the " "mock, you can use :ref:`auto-speccing `." @@ -411,7 +411,7 @@ msgstr "" "如果你希望這種更聰明的匹配也可以應用於 mock 上的方法呼叫,你可以使用\\ :ref:`" "自動規格 `。" -#: ../../library/unittest.mock-examples.rst:358 +#: ../../library/unittest.mock-examples.rst:357 msgid "" "If you want a stronger form of specification that prevents the setting of " "arbitrary attributes as well as the getting of them then you can use " @@ -420,11 +420,11 @@ msgstr "" "如果你想要一種更強大的規格形式來防止設定任意屬性以及取得它們,那麼你可以使用 " "*spec_set* 而不是 *spec*。" -#: ../../library/unittest.mock-examples.rst:364 +#: ../../library/unittest.mock-examples.rst:363 msgid "Using side_effect to return per file content" msgstr "使用 side_effect 回傳各別檔案內容" -#: ../../library/unittest.mock-examples.rst:366 +#: ../../library/unittest.mock-examples.rst:365 msgid "" ":func:`mock_open` is used to patch :func:`open` method. :attr:`~Mock." "side_effect` can be used to return a new Mock object per call. This can be " @@ -434,7 +434,7 @@ msgstr "" "可以用來在每次呼叫回傳一個新的 mock 物件。這可以用於回傳儲存在字典中的各別檔" "案的不同內容: ::" -#: ../../library/unittest.mock-examples.rst:370 +#: ../../library/unittest.mock-examples.rst:369 msgid "" "DEFAULT = \"default\"\n" "data_dict = {\"file1\": \"data1\",\n" @@ -470,11 +470,11 @@ msgstr "" " with open(\"file3\") as file2:\n" " assert file2.read() == \"default\"" -#: ../../library/unittest.mock-examples.rst:389 +#: ../../library/unittest.mock-examples.rst:388 msgid "Patch decorators" msgstr "Patch 裝飾器" -#: ../../library/unittest.mock-examples.rst:393 +#: ../../library/unittest.mock-examples.rst:392 msgid "" "With :func:`patch` it matters that you patch objects in the namespace where " "they are looked up. This is normally straightforward, but for a quick guide " @@ -484,7 +484,7 @@ msgstr "" "namespace where they are looked up)patch 物件。這通常很直接,但若需要快速導" "引,請參閱\\ :ref:`該 patch 何處 `。" -#: ../../library/unittest.mock-examples.rst:398 +#: ../../library/unittest.mock-examples.rst:397 msgid "" "A common need in tests is to patch a class attribute or a module attribute, " "for example patching a builtin or patching a class in a module to test that " @@ -497,7 +497,7 @@ msgstr "" "在測試後必須撤銷它們的 patch,否則 patch 將延續到其他測試中並導致難以診斷問" "題。" -#: ../../library/unittest.mock-examples.rst:404 +#: ../../library/unittest.mock-examples.rst:403 msgid "" "mock provides three convenient decorators for this: :func:`patch`, :func:" "`patch.object` and :func:`patch.dict`. ``patch`` takes a single string, of " @@ -513,11 +513,11 @@ msgstr "" "別或其他)的值。``patch.object`` 接受一個物件和你想要 patch 的屬性的名稱,同" "時也可以接受要 patch 的值。" -#: ../../library/unittest.mock-examples.rst:412 +#: ../../library/unittest.mock-examples.rst:411 msgid "``patch.object``::" msgstr "``patch.object``: ::" -#: ../../library/unittest.mock-examples.rst:414 +#: ../../library/unittest.mock-examples.rst:413 msgid "" ">>> original = SomeClass.attribute\n" ">>> @patch.object(SomeClass, 'attribute', sentinel.attribute)\n" @@ -549,7 +549,7 @@ msgstr "" "...\n" ">>> test()" -#: ../../library/unittest.mock-examples.rst:429 +#: ../../library/unittest.mock-examples.rst:428 msgid "" "If you are patching a module (including :mod:`builtins`) then use :func:" "`patch` instead of :func:`patch.object`:" @@ -557,12 +557,12 @@ msgstr "" "如果你要 patch 一個模組(包括 :mod:`builtins`),請使用 :func:`patch` 而非 :" "func:`patch.object`:" -#: ../../library/unittest.mock-examples.rst:439 +#: ../../library/unittest.mock-examples.rst:438 msgid "" "The module name can be 'dotted', in the form ``package.module`` if needed::" msgstr "如有需要,模組名稱可以含有 ``.``,形式為 ``package.module``: ::" -#: ../../library/unittest.mock-examples.rst:441 +#: ../../library/unittest.mock-examples.rst:440 msgid "" ">>> @patch('package.module.ClassName.attribute', sentinel.attribute)\n" "... def test():\n" @@ -578,11 +578,11 @@ msgstr "" "...\n" ">>> test()" -#: ../../library/unittest.mock-examples.rst:448 +#: ../../library/unittest.mock-examples.rst:447 msgid "A nice pattern is to actually decorate test methods themselves:" msgstr "一個好的模式是實際裝飾測試方法本身:" -#: ../../library/unittest.mock-examples.rst:459 +#: ../../library/unittest.mock-examples.rst:458 msgid "" "If you want to patch with a Mock, you can use :func:`patch` with only one " "argument (or :func:`patch.object` with two arguments). The mock will be " @@ -592,11 +592,11 @@ msgstr "" "(或帶有兩個引數的 :func:`patch.object`\\ )。Mock 將被建立並被傳遞到測試函" "式 / 方法中:" -#: ../../library/unittest.mock-examples.rst:471 +#: ../../library/unittest.mock-examples.rst:470 msgid "You can stack up multiple patch decorators using this pattern::" msgstr "你可以使用這個模式堆疊多個 patch 裝飾器: ::" -#: ../../library/unittest.mock-examples.rst:473 +#: ../../library/unittest.mock-examples.rst:472 msgid "" ">>> class MyTest(unittest.TestCase):\n" "... @patch('package.module.ClassName1')\n" @@ -616,7 +616,7 @@ msgstr "" "...\n" ">>> MyTest('test_something').test_something()" -#: ../../library/unittest.mock-examples.rst:482 +#: ../../library/unittest.mock-examples.rst:481 msgid "" "When you nest patch decorators the mocks are passed in to the decorated " "function in the same order they applied (the normal *Python* order that " @@ -627,7 +627,7 @@ msgstr "" "同(一般 *Python* 應用裝飾器的順序)。這意味著由下而上,因此在上面的範例中," "``module.ClassName2`` 的 mock 會先被傳入。" -#: ../../library/unittest.mock-examples.rst:487 +#: ../../library/unittest.mock-examples.rst:486 msgid "" "There is also :func:`patch.dict` for setting values in a dictionary just " "during a scope and restoring the dictionary to its original state when the " @@ -636,14 +636,14 @@ msgstr "" "也有 :func:`patch.dict`,用於在測試範圍中設定字典內的值,並在測試結束時將其恢" "復為原始狀態:" -#: ../../library/unittest.mock-examples.rst:498 +#: ../../library/unittest.mock-examples.rst:497 msgid "" "``patch``, ``patch.object`` and ``patch.dict`` can all be used as context " "managers." msgstr "" "``patch``、``patch.object`` 和 ``patch.dict`` 都可以用來作為情境管理器。" -#: ../../library/unittest.mock-examples.rst:500 +#: ../../library/unittest.mock-examples.rst:499 msgid "" "Where you use :func:`patch` to create a mock for you, you can get a " "reference to the mock using the \"as\" form of the with statement:" @@ -651,7 +651,7 @@ msgstr "" "當你使用 :func:`patch` 為你建立一個 mock 時,你可以使用 with 陳述式的 \"as\" " "形式來取得 mock 的參照:" -#: ../../library/unittest.mock-examples.rst:515 +#: ../../library/unittest.mock-examples.rst:514 msgid "" "As an alternative ``patch``, ``patch.object`` and ``patch.dict`` can be used " "as class decorators. When used in this way it is the same as applying the " @@ -661,19 +661,19 @@ msgstr "" "器。以這種方式使用時,與將裝飾器單獨應用於每個名稱以 \"test\" 開頭的方法相" "同。" -#: ../../library/unittest.mock-examples.rst:523 +#: ../../library/unittest.mock-examples.rst:522 msgid "Further examples" msgstr "更多範例" -#: ../../library/unittest.mock-examples.rst:526 +#: ../../library/unittest.mock-examples.rst:525 msgid "Here are some more examples for some slightly more advanced scenarios." msgstr "以下是一些更進階一點的情境的範例。" -#: ../../library/unittest.mock-examples.rst:530 +#: ../../library/unittest.mock-examples.rst:529 msgid "Mocking chained calls" msgstr "Mock 鍊接呼叫" -#: ../../library/unittest.mock-examples.rst:532 +#: ../../library/unittest.mock-examples.rst:531 msgid "" "Mocking chained calls is actually straightforward with mock once you " "understand the :attr:`~Mock.return_value` attribute. When a mock is called " @@ -684,7 +684,7 @@ msgstr "" "一個 mock 第一次被呼叫,或者你在它被呼叫之前取得其 ``return_value`` 時,一個" "新的 :class:`Mock` 就會被建立。" -#: ../../library/unittest.mock-examples.rst:537 +#: ../../library/unittest.mock-examples.rst:536 msgid "" "This means that you can see how the object returned from a call to a mocked " "object has been used by interrogating the ``return_value`` mock:" @@ -692,7 +692,7 @@ msgstr "" "這代表你可以透過查問 ``return_value`` mock 來了解一個對被 mock 的物件的呼叫回" "傳的物件是如何被使用的:" -#: ../../library/unittest.mock-examples.rst:545 +#: ../../library/unittest.mock-examples.rst:544 msgid "" "From here it is a simple step to configure and then make assertions about " "chained calls. Of course another alternative is writing your code in a more " @@ -701,11 +701,11 @@ msgstr "" "這裡只需一個簡單的步驟即可進行配置並對鍊接呼叫進行斷言。當然,另一種選擇是先" "以更容易被測試的方式撰寫程式碼..." -#: ../../library/unittest.mock-examples.rst:549 +#: ../../library/unittest.mock-examples.rst:548 msgid "So, suppose we have some code that looks a little bit like this:" msgstr "所以,假設我們有一些程式碼,看起來大概像這樣:" -#: ../../library/unittest.mock-examples.rst:558 +#: ../../library/unittest.mock-examples.rst:557 msgid "" "Assuming that ``BackendProvider`` is already well tested, how do we test " "``method()``? Specifically, we want to test that the code section ``# more " @@ -715,7 +715,7 @@ msgstr "" "具體來說,我們要測試程式碼部分 ``# more code`` 是否以正確的方式使用 " "``response`` 物件。" -#: ../../library/unittest.mock-examples.rst:562 +#: ../../library/unittest.mock-examples.rst:561 msgid "" "As this chain of calls is made from an instance attribute we can monkey " "patch the ``backend`` attribute on a ``Something`` instance. In this " @@ -730,7 +730,7 @@ msgstr "" "(file-like),因此我們會確保我們的 response 物件使用內建的 :func:`open` 作為" "其 ``spec``。" -#: ../../library/unittest.mock-examples.rst:569 +#: ../../library/unittest.mock-examples.rst:568 msgid "" "To do this we create a mock instance as our mock backend and create a mock " "response object for it. To set the response as the return value for that " @@ -740,7 +740,7 @@ msgstr "" "response 物件。要將 response 設定為最後的 ``start_call`` 的回傳值,我們可以這" "樣做: ::" -#: ../../library/unittest.mock-examples.rst:573 +#: ../../library/unittest.mock-examples.rst:572 msgid "" "mock_backend.get_endpoint.return_value.create_call.return_value.start_call." "return_value = mock_response" @@ -748,7 +748,7 @@ msgstr "" "mock_backend.get_endpoint.return_value.create_call.return_value.start_call." "return_value = mock_response" -#: ../../library/unittest.mock-examples.rst:575 +#: ../../library/unittest.mock-examples.rst:574 msgid "" "We can do that in a slightly nicer way using the :meth:`~Mock." "configure_mock` method to directly set the return value for us::" @@ -756,7 +756,7 @@ msgstr "" "我們可以使用 :meth:`~Mock.configure_mock` 方法來以稍微好一點的方式為我們直接" "設定回傳值: ::" -#: ../../library/unittest.mock-examples.rst:578 +#: ../../library/unittest.mock-examples.rst:577 msgid "" ">>> something = Something()\n" ">>> mock_response = Mock(spec=open)\n" @@ -772,7 +772,7 @@ msgstr "" "return_value': mock_response}\n" ">>> mock_backend.configure_mock(**config)" -#: ../../library/unittest.mock-examples.rst:584 +#: ../../library/unittest.mock-examples.rst:583 msgid "" "With these we monkey patch the \"mock backend\" in place and can make the " "real call::" @@ -780,7 +780,7 @@ msgstr "" "有了這些,我們就可以原地 (in place) monkey patch \"mock backend\",並且可以進" "行真正的呼叫: ::" -#: ../../library/unittest.mock-examples.rst:587 +#: ../../library/unittest.mock-examples.rst:586 msgid "" ">>> something.backend = mock_backend\n" ">>> something.method()" @@ -788,7 +788,7 @@ msgstr "" ">>> something.backend = mock_backend\n" ">>> something.method()" -#: ../../library/unittest.mock-examples.rst:590 +#: ../../library/unittest.mock-examples.rst:589 msgid "" "Using :attr:`~Mock.mock_calls` we can check the chained call with a single " "assert. A chained call is several calls in one line of code, so there will " @@ -799,7 +799,7 @@ msgstr "" "個鍊接呼叫是一行程式碼中的多個呼叫,因此 ``mock_calls`` 中會有多個項目。我們" "可以使用 :meth:`call.call_list` 來為我們建立這個呼叫串列: ::" -#: ../../library/unittest.mock-examples.rst:595 +#: ../../library/unittest.mock-examples.rst:594 msgid "" ">>> chained = call.get_endpoint('foobar').create_call('spam', 'eggs')." "start_call()\n" @@ -811,11 +811,11 @@ msgstr "" ">>> call_list = chained.call_list()\n" ">>> assert mock_backend.mock_calls == call_list" -#: ../../library/unittest.mock-examples.rst:601 +#: ../../library/unittest.mock-examples.rst:600 msgid "Partial mocking" msgstr "部分 mocking" -#: ../../library/unittest.mock-examples.rst:603 +#: ../../library/unittest.mock-examples.rst:602 msgid "" "For some tests, you may want to mock out a call to :meth:`datetime.date." "today` to return a known date, but don't want to prevent the code under test " @@ -828,7 +828,7 @@ msgstr "" "`datetime.date` 是用 C 語言寫的,所以們我不能 monkey patch 靜態的 :meth:" "`datetime.date.today` 方法。" -#: ../../library/unittest.mock-examples.rst:608 +#: ../../library/unittest.mock-examples.rst:607 msgid "" "Instead, you can effectively wrap the date class with a mock, while passing " "through calls to the constructor to the real class (and returning real " @@ -837,7 +837,7 @@ msgstr "" "然而你可以使用一個 mock 有效地包裝日期類別,同時將對建構函式的呼叫傳遞給真實" "的類別(並回傳真實的實例)。" -#: ../../library/unittest.mock-examples.rst:612 +#: ../../library/unittest.mock-examples.rst:611 msgid "" "The :func:`patch decorator ` is used here to mock out the ``date`` " "class in the module under test. The :attr:`~Mock.side_effect` attribute on " @@ -850,7 +850,7 @@ msgstr "" "lambda 函式。當 mock 日期類別被呼叫時,將透過 ``side_effect`` 建構並回傳真實" "日期。: ::" -#: ../../library/unittest.mock-examples.rst:618 +#: ../../library/unittest.mock-examples.rst:617 msgid "" ">>> import datetime as dt\n" ">>> with patch('mymodule.date') as mock_date:\n" @@ -868,7 +868,7 @@ msgstr "" "... assert mymodule.date.today() == dt.date(2010, 10, 8)\n" "... assert mymodule.date(2009, 6, 8) == dt.date(2009, 6, 8)" -#: ../../library/unittest.mock-examples.rst:626 +#: ../../library/unittest.mock-examples.rst:625 msgid "" "Note that we don't patch :class:`datetime.date` globally, we patch ``date`` " "in the module that *uses* it. See :ref:`where to patch `." @@ -876,7 +876,7 @@ msgstr "" "注意,我們沒有全域 patch :class:`datetime.date`,而是在\\ *使用*\\ 它的模組" "中 patch ``date``。請參閱 :ref:`該 patch 何處 `。" -#: ../../library/unittest.mock-examples.rst:629 +#: ../../library/unittest.mock-examples.rst:628 msgid "" "When ``date.today()`` is called a known date is returned, but calls to the " "``date(...)`` constructor still return normal dates. Without this you can " @@ -888,7 +888,7 @@ msgstr "" "式碼完全相同的演算法來計算預期結果,這是一個典型的測試的反面模式 (anti-" "pattern)。" -#: ../../library/unittest.mock-examples.rst:634 +#: ../../library/unittest.mock-examples.rst:633 msgid "" "Calls to the date constructor are recorded in the ``mock_date`` attributes " "(``call_count`` and friends) which may also be useful for your tests." @@ -896,7 +896,7 @@ msgstr "" "對日期建構函式的呼叫被記錄在 ``mock_date`` 屬性(\\ ``call_count`` 及其相關屬" "性)中,這對你的測試也可能有用處。" -#: ../../library/unittest.mock-examples.rst:637 +#: ../../library/unittest.mock-examples.rst:636 msgid "" "An alternative way of dealing with mocking dates, or other builtin classes, " "is discussed in `this blog entry `_ 中" "討論。" -#: ../../library/unittest.mock-examples.rst:643 +#: ../../library/unittest.mock-examples.rst:642 msgid "Mocking a generator method" msgstr "Mock 產生器方法" -#: ../../library/unittest.mock-examples.rst:645 +#: ../../library/unittest.mock-examples.rst:644 msgid "" "A Python generator is a function or method that uses the :keyword:`yield` " "statement to return a series of values when iterated over [#]_." @@ -918,7 +918,7 @@ msgstr "" "Python 產生器是一個函式或方法,它使用 :keyword:`yield` 陳述式在疊代 [#]_ 時回" "傳一系列的值。" -#: ../../library/unittest.mock-examples.rst:648 +#: ../../library/unittest.mock-examples.rst:647 msgid "" "A generator method / function is called to return the generator object. It " "is the generator object that is then iterated over. The protocol method for " @@ -929,16 +929,16 @@ msgstr "" "方法是 :meth:`~container.__iter__`,所以我們可以使用 :class:`MagicMock` 來 " "mock 它。" -#: ../../library/unittest.mock-examples.rst:653 +#: ../../library/unittest.mock-examples.rst:652 msgid "" "Here's an example class with an \"iter\" method implemented as a generator:" msgstr "下面是一個範例類別,其包含實作產生器的一個 \"iter\" 方法:" -#: ../../library/unittest.mock-examples.rst:665 +#: ../../library/unittest.mock-examples.rst:664 msgid "How would we mock this class, and in particular its \"iter\" method?" msgstr "我們該如何 mock 這個類別,特別是它的 \"iter\" 方法呢?" -#: ../../library/unittest.mock-examples.rst:667 +#: ../../library/unittest.mock-examples.rst:666 msgid "" "To configure the values returned from the iteration (implicit in the call " "to :class:`list`), we need to configure the object returned by the call to " @@ -947,7 +947,7 @@ msgstr "" "要配置從疊代回傳的值(隱含在對 :class:`list` 的呼叫中),我們需要配置呼叫 " "``foo.iter()`` 所回傳的物件。" -#: ../../library/unittest.mock-examples.rst:675 +#: ../../library/unittest.mock-examples.rst:674 msgid "" "There are also generator expressions and more `advanced uses `_ of generators, but we aren't concerned " @@ -960,11 +960,11 @@ msgstr "" "的優良說明是:`Generator Tricks for Systems Programmers `_。" -#: ../../library/unittest.mock-examples.rst:683 +#: ../../library/unittest.mock-examples.rst:682 msgid "Applying the same patch to every test method" msgstr "對每個測試方法應用相同的 patch" -#: ../../library/unittest.mock-examples.rst:685 +#: ../../library/unittest.mock-examples.rst:684 msgid "" "If you want several patches in place for multiple test methods the obvious " "way is to apply the patch decorators to every method. This can feel like " @@ -978,7 +978,7 @@ msgstr "" "patch 的變體)作為類別裝飾器。這會將 patch 應用在該類別的所有測試方法上。測試" "方法由名稱以 ``test`` 開頭來識別: ::" -#: ../../library/unittest.mock-examples.rst:692 +#: ../../library/unittest.mock-examples.rst:691 msgid "" ">>> @patch('mymodule.SomeClass')\n" "... class MyTest(unittest.TestCase):\n" @@ -1014,7 +1014,7 @@ msgstr "" ">>> MyTest('test_two').not_a_test()\n" "'something'" -#: ../../library/unittest.mock-examples.rst:709 +#: ../../library/unittest.mock-examples.rst:708 msgid "" "An alternative way of managing patches is to use the :ref:`start-and-stop`. " "These allow you to move the patching into your ``setUp`` and ``tearDown`` " @@ -1023,7 +1023,7 @@ msgstr "" "管理 patch 的另一種方式是使用 :ref:`start-and-stop`。這允許你將 patch 移到你" "的 ``setUp`` 與 ``tearDown`` 方法中。: ::" -#: ../../library/unittest.mock-examples.rst:713 +#: ../../library/unittest.mock-examples.rst:712 msgid "" ">>> class MyTest(unittest.TestCase):\n" "... def setUp(self):\n" @@ -1051,7 +1051,7 @@ msgstr "" "...\n" ">>> MyTest('test_foo').run()" -#: ../../library/unittest.mock-examples.rst:726 +#: ../../library/unittest.mock-examples.rst:725 msgid "" "If you use this technique you must ensure that the patching is \"undone\" by " "calling ``stop``. This can be fiddlier than you might think, because if an " @@ -1062,7 +1062,7 @@ msgstr "" "你想像的還要複雜一點,因為如果有例外在 ``setUp`` 中被引發,則 ``tearDown`` 就" "不會被呼叫。:meth:`unittest.TestCase.addCleanup` 會讓這稍微簡單一點: ::" -#: ../../library/unittest.mock-examples.rst:731 +#: ../../library/unittest.mock-examples.rst:730 msgid "" ">>> class MyTest(unittest.TestCase):\n" "... def setUp(self):\n" @@ -1086,11 +1086,11 @@ msgstr "" "...\n" ">>> MyTest('test_foo').run()" -#: ../../library/unittest.mock-examples.rst:744 +#: ../../library/unittest.mock-examples.rst:743 msgid "Mocking unbound methods" msgstr "Mock 未繫結方法 (unbound methods)" -#: ../../library/unittest.mock-examples.rst:746 +#: ../../library/unittest.mock-examples.rst:745 msgid "" "Sometimes a test needs to patch an *unbound method*, which means patching " "the method on the class rather than on the instance. In order to make " @@ -1110,7 +1110,7 @@ msgstr "" "遞。解決方法是使用真實的函式來 patch 未繫結方法。:func:`patch` 裝飾器使得用 " "mock 來 patch out 方法是如此的簡單,以至於建立一個真正的函式相對變得很麻煩。" -#: ../../library/unittest.mock-examples.rst:756 +#: ../../library/unittest.mock-examples.rst:755 msgid "" "If you pass ``autospec=True`` to patch then it does the patching with a " "*real* function object. This function object has the same signature as the " @@ -1127,7 +1127,7 @@ msgstr "" "patch 類別上的未繫結方法,則從實例取得的 mock 函式將轉換為繫結方法。``self`` " "會作為其第一個引數傳入,而這正是我們需要的:" -#: ../../library/unittest.mock-examples.rst:777 +#: ../../library/unittest.mock-examples.rst:776 msgid "" "If we don't use ``autospec=True`` then the unbound method is patched out " "with a Mock instance instead, and isn't called with ``self``." @@ -1135,17 +1135,17 @@ msgstr "" "如果我們不使用 ``autospec=True``,那麼未繫結方法將使用一個 Mock 實例 patch " "out,並且不被使用 ``self`` 進行呼叫。" -#: ../../library/unittest.mock-examples.rst:782 +#: ../../library/unittest.mock-examples.rst:781 msgid "Checking multiple calls with mock" msgstr "使用 mock 檢查多個呼叫" -#: ../../library/unittest.mock-examples.rst:784 +#: ../../library/unittest.mock-examples.rst:783 msgid "" "mock has a nice API for making assertions about how your mock objects are " "used." msgstr "mock 有很好的 API,用於對 mock 物件的使用方式做出斷言。" -#: ../../library/unittest.mock-examples.rst:791 +#: ../../library/unittest.mock-examples.rst:790 msgid "" "If your mock is only being called once you can use the :meth:`~Mock." "assert_called_once_with` method that also asserts that the :attr:`~Mock." @@ -1154,7 +1154,7 @@ msgstr "" "如果你的 mock 只被呼叫一次,你可以使用 :meth:`~Mock.assert_called_once_with` " "方法,其也斷言 :attr:`~Mock.call_count` 是1。" -#: ../../library/unittest.mock-examples.rst:803 +#: ../../library/unittest.mock-examples.rst:802 msgid "" "Both ``assert_called_with`` and ``assert_called_once_with`` make assertions " "about the *most recent* call. If your mock is going to be called several " @@ -1165,7 +1165,7 @@ msgstr "" "呼叫做出斷言。如果你的 mock 將被多次呼叫,並且你想要對\\ *所有*\\ 這些呼叫進" "行斷言,你可以使用 :attr:`~Mock.call_args_list`:" -#: ../../library/unittest.mock-examples.rst:815 +#: ../../library/unittest.mock-examples.rst:814 msgid "" "The :data:`call` helper makes it easy to make assertions about these calls. " "You can build up a list of expected calls and compare it to " @@ -1176,11 +1176,11 @@ msgstr "" "將其與 ``call_args_list`` 進行比較。這看起來與 ``call_args_list`` 的 repr 非" "常相似:" -#: ../../library/unittest.mock-examples.rst:825 +#: ../../library/unittest.mock-examples.rst:824 msgid "Coping with mutable arguments" msgstr "應對可變引數" -#: ../../library/unittest.mock-examples.rst:827 +#: ../../library/unittest.mock-examples.rst:826 msgid "" "Another situation is rare, but can bite you, is when your mock is called " "with mutable arguments. ``call_args`` and ``call_args_list`` store " @@ -1192,13 +1192,13 @@ msgstr "" "``call_args`` 和 ``call_args_list`` 儲存對引數的\\ *參照*。如果引數被測試中的" "程式碼改變,那麼你將無法再對 mock 被呼叫時的值進行斷言。" -#: ../../library/unittest.mock-examples.rst:832 +#: ../../library/unittest.mock-examples.rst:831 msgid "" "Here's some example code that shows the problem. Imagine the following " "functions defined in 'mymodule'::" msgstr "這是一些秀出問題的程式碼範例。 想像 'mymodule' 中定義以下函式: ::" -#: ../../library/unittest.mock-examples.rst:835 +#: ../../library/unittest.mock-examples.rst:834 msgid "" "def frob(val):\n" " pass\n" @@ -1216,14 +1216,14 @@ msgstr "" " frob(val)\n" " val.clear()" -#: ../../library/unittest.mock-examples.rst:843 +#: ../../library/unittest.mock-examples.rst:842 msgid "" "When we try to test that ``grob`` calls ``frob`` with the correct argument " "look what happens::" msgstr "" "當我們嘗試測試 ``grob`` 使用正確的引數呼叫 ``frob`` 時,看看會發生什麼: ::" -#: ../../library/unittest.mock-examples.rst:846 +#: ../../library/unittest.mock-examples.rst:845 msgid "" ">>> with patch('mymodule.frob') as mock_frob:\n" "... val = {6}\n" @@ -1249,7 +1249,7 @@ msgstr "" "AssertionError: Expected: (({6},), {})\n" "Called with: ((set(),), {})" -#: ../../library/unittest.mock-examples.rst:858 +#: ../../library/unittest.mock-examples.rst:857 msgid "" "One possibility would be for mock to copy the arguments you pass in. This " "could then cause problems if you do assertions that rely on object identity " @@ -1258,23 +1258,23 @@ msgstr "" "一種可能是讓 mock 複製你傳入的引數。如果你進行的斷言依賴於物件識別性來確定相" "等性,這就可能導致問題。" -#: ../../library/unittest.mock-examples.rst:862 +#: ../../library/unittest.mock-examples.rst:861 msgid "" "Here's one solution that uses the :attr:`~Mock.side_effect` functionality. " "If you provide a ``side_effect`` function for a mock then ``side_effect`` " "will be called with the same args as the mock. This gives us an opportunity " "to copy the arguments and store them for later assertions. In this example " -"I'm using *another* mock to store the arguments so that I can use the mock " -"methods for doing the assertion. Again a helper function sets this up for " -"me. ::" +"we're using *another* mock to store the arguments so that we can use the " +"mock methods for doing the assertion. Again a helper function sets this up " +"for us. ::" msgstr "" "以下是一種使用 :attr:`~Mock.side_effect` 功能的解法。如果你為 mock 提供一個 " "``side_effect`` 函式,則 ``side_effect`` 將被使用與 mock 相同的引數呼叫。這使" "我們有機會複製引數並將其儲存以供之後的斷言。在這個範例中,我們使用\\ *另一個" -"* mock 來儲存引數,以便我們可以使用 mock 方法來執行斷言。同樣的,有一個輔助函" -"式為我們設定了這些。: ::" +"* mock 來儲存引數,以便我們可以使用 mock 方法來執行斷言。同樣地,有一個輔助函" +"式為我們設定了這些。 ::" -#: ../../library/unittest.mock-examples.rst:870 +#: ../../library/unittest.mock-examples.rst:869 msgid "" ">>> from copy import deepcopy\n" ">>> from unittest.mock import Mock, patch, DEFAULT\n" @@ -1318,7 +1318,7 @@ msgstr "" ">>> new_mock.call_args\n" "call({6})" -#: ../../library/unittest.mock-examples.rst:891 +#: ../../library/unittest.mock-examples.rst:890 msgid "" "``copy_call_args`` is called with the mock that will be called. It returns a " "new mock that we do the assertion on. The ``side_effect`` function makes a " @@ -1328,7 +1328,7 @@ msgstr "" "言的新的 mock。``side_effect`` 函式建立引數們的副本,並用該副本呼叫我們的 " "``new_mock``。" -#: ../../library/unittest.mock-examples.rst:897 +#: ../../library/unittest.mock-examples.rst:896 msgid "" "If your mock is only going to be used once there is an easier way of " "checking arguments at the point they are called. You can simply do the " @@ -1337,7 +1337,7 @@ msgstr "" "如果你的 mock 只會被使用一次,則有一種更簡單的方法可以在呼叫引數時檢查它們。" "你可以簡單地在 ``side_effect`` 函式內進行檢查。" -#: ../../library/unittest.mock-examples.rst:911 +#: ../../library/unittest.mock-examples.rst:910 msgid "" "An alternative approach is to create a subclass of :class:`Mock` or :class:" "`MagicMock` that copies (using :func:`copy.deepcopy`) the arguments. Here's " @@ -1346,7 +1346,7 @@ msgstr "" "另一種方法是建立 :class:`Mock` 或 :class:`MagicMock` 的子類別來複製(使用 :" "func:`copy.deepcopy`\\ )引數。這是一個實作的例子:" -#: ../../library/unittest.mock-examples.rst:936 +#: ../../library/unittest.mock-examples.rst:935 msgid "" "When you subclass ``Mock`` or ``MagicMock`` all dynamically created " "attributes, and the ``return_value`` will use your subclass automatically. " @@ -1357,11 +1357,11 @@ msgstr "" "``return_value`` 會自動使用你的子類別。這代表著 ``CopyingMock`` 的所有子代 " "(child) 也會具有 ``CopyingMock`` 型別。" -#: ../../library/unittest.mock-examples.rst:942 +#: ../../library/unittest.mock-examples.rst:941 msgid "Nesting patches" msgstr "巢狀使用 Patch" -#: ../../library/unittest.mock-examples.rst:944 +#: ../../library/unittest.mock-examples.rst:943 msgid "" "Using patch as a context manager is nice, but if you do multiple patches you " "can end up with nested with statements indenting further and further to the " @@ -1370,7 +1370,7 @@ msgstr "" "將 patch 作為情境管理器使用很好,但是如果你使用複數個 patch,你最終可能會得到" "巢狀的 with 陳述式,並且越來越向右縮排: ::" -#: ../../library/unittest.mock-examples.rst:948 +#: ../../library/unittest.mock-examples.rst:947 msgid "" ">>> class MyTest(unittest.TestCase):\n" "...\n" @@ -1400,7 +1400,7 @@ msgstr "" ">>> MyTest('test_foo').test_foo()\n" ">>> assert mymodule.Foo is original" -#: ../../library/unittest.mock-examples.rst:962 +#: ../../library/unittest.mock-examples.rst:961 msgid "" "With unittest ``cleanup`` functions and the :ref:`start-and-stop` we can " "achieve the same effect without the nested indentation. A simple helper " @@ -1411,7 +1411,7 @@ msgstr "" "同的效果,而不會出現因巢狀導致的縮排。一個簡單的輔助方法 ``create_patch`` 會" "將 patch 放置到位並為我們回傳被建立的 mock: ::" -#: ../../library/unittest.mock-examples.rst:967 +#: ../../library/unittest.mock-examples.rst:966 msgid "" ">>> class MyTest(unittest.TestCase):\n" "...\n" @@ -1455,11 +1455,11 @@ msgstr "" ">>> MyTest('test_foo').run()\n" ">>> assert mymodule.Foo is original" -#: ../../library/unittest.mock-examples.rst:990 +#: ../../library/unittest.mock-examples.rst:989 msgid "Mocking a dictionary with MagicMock" msgstr "使用 MagicMock 來 mock 字典" -#: ../../library/unittest.mock-examples.rst:992 +#: ../../library/unittest.mock-examples.rst:991 msgid "" "You may want to mock a dictionary, or other container object, recording all " "access to it whilst having it still behave like a dictionary." @@ -1467,7 +1467,7 @@ msgstr "" "你可能會想要 mock 字典或其他容器物件,記錄對它的所有存取,同時讓它仍然像字典" "一樣運作。" -#: ../../library/unittest.mock-examples.rst:995 +#: ../../library/unittest.mock-examples.rst:994 msgid "" "We can do this with :class:`MagicMock`, which will behave like a dictionary, " "and using :data:`~Mock.side_effect` to delegate dictionary access to a real " @@ -1476,7 +1476,7 @@ msgstr "" "我們可以使用 :class:`MagicMock` 來做到這一點,它的行為會與字典一致,並使用 :" "data:`~Mock.side_effect` 將字典存取委託給我們控制下的真實底層字典。" -#: ../../library/unittest.mock-examples.rst:999 +#: ../../library/unittest.mock-examples.rst:998 msgid "" "When the :meth:`~object.__getitem__` and :meth:`~object.__setitem__` methods " "of our ``MagicMock`` are called (normal dictionary access) then " @@ -1488,7 +1488,7 @@ msgstr "" "(key) 來呼叫 (在 ``__setitem__`` 的情況也會使用值 (value))。我們也可以控制" "回傳的內容。" -#: ../../library/unittest.mock-examples.rst:1004 +#: ../../library/unittest.mock-examples.rst:1003 msgid "" "After the ``MagicMock`` has been used we can use attributes like :data:" "`~Mock.call_args_list` to assert about how the dictionary was used:" @@ -1496,7 +1496,7 @@ msgstr "" "使用 ``MagicMock`` 後,我們可以使用諸如 :data:`~Mock.call_args_list` 之類的屬" "性來斷言字典被使用的方式:" -#: ../../library/unittest.mock-examples.rst:1020 +#: ../../library/unittest.mock-examples.rst:1019 msgid "" "An alternative to using ``MagicMock`` is to use ``Mock`` and *only* provide " "the magic methods you specifically want:" @@ -1504,7 +1504,7 @@ msgstr "" "不使用 ``MagicMock`` 的替代方案是使用 ``Mock`` 並且\\ *只*\\ 提供你特別想要的" "魔術方法:" -#: ../../library/unittest.mock-examples.rst:1027 +#: ../../library/unittest.mock-examples.rst:1026 msgid "" "A *third* option is to use ``MagicMock`` but passing in ``dict`` as the " "*spec* (or *spec_set*) argument so that the ``MagicMock`` created only has " @@ -1513,7 +1513,7 @@ msgstr "" "*第三個*\\ 選擇是使用 ``MagicMock``,但傳入 ``dict`` 作為 *spec* (或 " "*spec_set*\\ )引數,以使被建立的 ``MagicMock`` 僅具有字典可用的魔術方法:" -#: ../../library/unittest.mock-examples.rst:1035 +#: ../../library/unittest.mock-examples.rst:1034 msgid "" "With these side effect functions in place, the ``mock`` will behave like a " "normal dictionary but recording the access. It even raises a :exc:`KeyError` " @@ -1522,17 +1522,17 @@ msgstr "" "有了這些 side effect 函式,``mock`` 會像一般的字典一樣運作,但會記錄存取。如" "果你嘗試存取不存在的鍵,它甚至會引發一個 :exc:`KeyError`。" -#: ../../library/unittest.mock-examples.rst:1054 +#: ../../library/unittest.mock-examples.rst:1053 msgid "" "After it has been used you can make assertions about the access using the " "normal mock methods and attributes:" msgstr "在上述方式被使用後,你就可以使用普通的 mock 方法和屬性對存取進行斷言:" -#: ../../library/unittest.mock-examples.rst:1066 +#: ../../library/unittest.mock-examples.rst:1065 msgid "Mock subclasses and their attributes" msgstr "Mock 子類別及其屬性" -#: ../../library/unittest.mock-examples.rst:1068 +#: ../../library/unittest.mock-examples.rst:1067 msgid "" "There are various reasons why you might want to subclass :class:`Mock`. One " "reason might be to add helper methods. Here's a silly example:" @@ -1540,7 +1540,7 @@ msgstr "" "你會想子類別化 :class:`Mock` 的原因可能有很多種。其中之一是增加輔助方法。以下" "是一個有點笨的例子:" -#: ../../library/unittest.mock-examples.rst:1084 +#: ../../library/unittest.mock-examples.rst:1083 msgid "" "The standard behaviour for ``Mock`` instances is that attributes and the " "return value mocks are of the same type as the mock they are accessed on. " @@ -1554,7 +1554,7 @@ msgstr "" "``MagicMocks`` [#]_。因此,如果你要子類別化以新增輔助方法,那麼它們也可用於子" "類別實例的屬性 mock 和回傳值 mock。" -#: ../../library/unittest.mock-examples.rst:1100 +#: ../../library/unittest.mock-examples.rst:1099 msgid "" "Sometimes this is inconvenient. For example, `one user `_ is subclassing mock to created a `Twisted " @@ -1566,7 +1566,7 @@ msgstr "" "twisted.org/documents/11.0.0/api/twisted.python.components.html>`_。將其應用" "於屬性實際上會導致錯誤。" -#: ../../library/unittest.mock-examples.rst:1106 +#: ../../library/unittest.mock-examples.rst:1105 msgid "" "``Mock`` (in all its flavours) uses a method called ``_get_child_mock`` to " "create these \"sub-mocks\" for attributes and return values. You can prevent " @@ -1578,7 +1578,7 @@ msgstr "" "建立這些 \"子 mock\"。你可以透過置換此方法來防止你的子類別被用為屬性。其簽名" "是取用任意的關鍵字引數(``**kwargs``\\ ),然後將其傳遞給 mock 建構函式:" -#: ../../library/unittest.mock-examples.rst:1123 +#: ../../library/unittest.mock-examples.rst:1122 msgid "" "An exception to this rule are the non-callable mocks. Attributes use the " "callable variant because otherwise non-callable mocks couldn't have callable " @@ -1587,11 +1587,11 @@ msgstr "" "此規則的例外是非可呼叫物件的 mock。屬性使用可呼叫物件的變體,否則非可呼叫物件" "的 mock 無法具有可呼叫的方法。" -#: ../../library/unittest.mock-examples.rst:1129 +#: ../../library/unittest.mock-examples.rst:1128 msgid "Mocking imports with patch.dict" msgstr "使用 patch.dict 來 mock import" -#: ../../library/unittest.mock-examples.rst:1131 +#: ../../library/unittest.mock-examples.rst:1130 msgid "" "One situation where mocking can be hard is where you have a local import " "inside a function. These are harder to mock because they aren't using an " @@ -1600,7 +1600,7 @@ msgstr "" "可能會讓 mock 很困難的一種情況是在函式內部進行區域 import。這些狀況會更難進" "行 mock,因為它們沒有使用我們可以 patch out 的模組命名空間中的物件。" -#: ../../library/unittest.mock-examples.rst:1135 +#: ../../library/unittest.mock-examples.rst:1134 msgid "" "Generally local imports are to be avoided. They are sometimes done to " "prevent circular dependencies, for which there is *usually* a much better " @@ -1615,7 +1615,7 @@ msgstr "" "件的區域 import 更好的方式來解決(例如將模組儲存為類別或模組屬性,並且僅在第" "一次使用時進行 import)。" -#: ../../library/unittest.mock-examples.rst:1142 +#: ../../library/unittest.mock-examples.rst:1141 msgid "" "That aside there is a way to use ``mock`` to affect the results of an " "import. Importing fetches an *object* from the :data:`sys.modules` " @@ -1629,7 +1629,7 @@ msgstr "" "該物件不需要是一個模組。初次 import 模組會導致模組物件被放入 ``sys.modules`` " "中,因此通常當你 import 某些東西時,你會得到一個模組。但並非一定要如此。" -#: ../../library/unittest.mock-examples.rst:1149 +#: ../../library/unittest.mock-examples.rst:1148 msgid "" "This means you can use :func:`patch.dict` to *temporarily* put a mock in " "place in :data:`sys.modules`. Any imports whilst this patch is active will " @@ -1642,11 +1642,11 @@ msgstr "" "成時(被裝飾的函式結束、with 陳述式主體完成或 ``patcher.stop()`` 被呼叫),那" "麼之前在 ``sys.modules`` 中的任何內容都會被安全地復原。" -#: ../../library/unittest.mock-examples.rst:1155 +#: ../../library/unittest.mock-examples.rst:1154 msgid "Here's an example that mocks out the 'fooble' module." msgstr "下面是一個 mock out 'fooble' 模組的例子。" -#: ../../library/unittest.mock-examples.rst:1167 +#: ../../library/unittest.mock-examples.rst:1166 msgid "" "As you can see the ``import fooble`` succeeds, but on exit there is no " "'fooble' left in :data:`sys.modules`." @@ -1654,19 +1654,19 @@ msgstr "" "如你所見,``import fooble`` 成功了,但在離開之後,:data:`sys.modules` 中就沒" "有 'fooble' 了。" -#: ../../library/unittest.mock-examples.rst:1170 +#: ../../library/unittest.mock-examples.rst:1169 msgid "This also works for the ``from module import name`` form:" msgstr "這也適用於 ``from module import name`` 形式:" -#: ../../library/unittest.mock-examples.rst:1180 +#: ../../library/unittest.mock-examples.rst:1179 msgid "With slightly more work you can also mock package imports:" msgstr "透過稍微多一點的處理,你也可以 mock 套件的引入:" -#: ../../library/unittest.mock-examples.rst:1193 +#: ../../library/unittest.mock-examples.rst:1192 msgid "Tracking order of calls and less verbose call assertions" msgstr "追蹤呼叫順序與更簡潔的呼叫斷言" -#: ../../library/unittest.mock-examples.rst:1195 +#: ../../library/unittest.mock-examples.rst:1194 msgid "" "The :class:`Mock` class allows you to track the *order* of method calls on " "your mock objects through the :attr:`~Mock.method_calls` attribute. This " @@ -1677,7 +1677,7 @@ msgstr "" "上方法呼叫的\\ *順序*。這不會讓你可以追蹤不同的 mock 物件之間的呼叫順序,然而" "我們可以使用 :attr:`~Mock.mock_calls` 來達到相同的效果。" -#: ../../library/unittest.mock-examples.rst:1200 +#: ../../library/unittest.mock-examples.rst:1199 msgid "" "Because mocks track calls to child mocks in ``mock_calls``, and accessing an " "arbitrary attribute of a mock creates a child mock, we can create our " @@ -1688,7 +1688,7 @@ msgstr "" "會建立一個子 mock,所以我們可以從父 mock 建立不同的 mock。之後對這些子 mock " "的呼叫將依序全部記錄在父 mock 的 ``mock_calls`` 中:" -#: ../../library/unittest.mock-examples.rst:1217 +#: ../../library/unittest.mock-examples.rst:1216 msgid "" "We can then assert about the calls, including the order, by comparing with " "the ``mock_calls`` attribute on the manager mock:" @@ -1696,7 +1696,7 @@ msgstr "" "之後我們可以透過與管理器 (manager) mock 上的 ``mock_calls`` 屬性進行比較來斷" "言呼叫及其順序:" -#: ../../library/unittest.mock-examples.rst:1224 +#: ../../library/unittest.mock-examples.rst:1223 msgid "" "If ``patch`` is creating, and putting in place, your mocks then you can " "attach them to a manager mock using the :meth:`~Mock.attach_mock` method. " @@ -1706,7 +1706,7 @@ msgstr "" "attach_mock` 方法將它們附加到管理器 mock。附加之後,呼叫將被記錄在管理器的 " "``mock_calls`` 中。: ::" -#: ../../library/unittest.mock-examples.rst:1228 +#: ../../library/unittest.mock-examples.rst:1227 msgid "" ">>> manager = MagicMock()\n" ">>> with patch('mymodule.Class1') as MockClass1:\n" @@ -1738,7 +1738,7 @@ msgstr "" "call.MockClass2(),\n" "call.MockClass2().bar()]" -#: ../../library/unittest.mock-examples.rst:1243 +#: ../../library/unittest.mock-examples.rst:1242 msgid "" "If many calls have been made, but you're only interested in a particular " "sequence of them then an alternative is to use the :meth:`~Mock." @@ -1750,7 +1750,7 @@ msgstr "" "`~Mock.assert_has_calls` 方法。這需要一個呼叫串列(使用 :data:`call` 物件建" "構)。如果該呼叫序列位於 :attr:`~Mock.mock_calls` 中,則斷言成功。" -#: ../../library/unittest.mock-examples.rst:1257 +#: ../../library/unittest.mock-examples.rst:1256 msgid "" "Even though the chained call ``m.one().two().three()`` aren't the only calls " "that have been made to the mock, the assert still succeeds." @@ -1758,7 +1758,7 @@ msgstr "" "儘管鍊接呼叫 ``m.one().two().three()`` 並不是對 mock 進行的唯一呼叫,斷言仍會" "成功。" -#: ../../library/unittest.mock-examples.rst:1260 +#: ../../library/unittest.mock-examples.rst:1259 msgid "" "Sometimes a mock may have several calls made to it, and you are only " "interested in asserting about *some* of those calls. You may not even care " @@ -1769,11 +1769,11 @@ msgstr "" "你甚至可能不關心順序。在這種情況下,你可以將 ``any_order=True`` 傳遞給 " "``assert_has_calls``:" -#: ../../library/unittest.mock-examples.rst:1272 +#: ../../library/unittest.mock-examples.rst:1271 msgid "More complex argument matching" msgstr "更複雜的引數匹配" -#: ../../library/unittest.mock-examples.rst:1274 +#: ../../library/unittest.mock-examples.rst:1273 msgid "" "Using the same basic concept as :data:`ANY` we can implement matchers to do " "more complex assertions on objects used as arguments to mocks." @@ -1781,7 +1781,7 @@ msgstr "" "使用與 :data:`ANY` 相同的基本概念,我們可以實作匹配器 (matcher),對用來作為 " "mock 引數的物件進行更複雜的斷言。" -#: ../../library/unittest.mock-examples.rst:1277 +#: ../../library/unittest.mock-examples.rst:1276 msgid "" "Suppose we expect some object to be passed to a mock that by default " "compares equal based on object identity (which is the Python default for " @@ -1795,29 +1795,29 @@ msgstr "" "assert_called_with`,我們需要傳入完全相同的物件。如果我們只對該物件的某些屬性" "感興趣,那麼我們可以建立一個匹配器來為我們檢查這些屬性。" -#: ../../library/unittest.mock-examples.rst:1284 +#: ../../library/unittest.mock-examples.rst:1283 msgid "" "You can see in this example how a 'standard' call to ``assert_called_with`` " "isn't sufficient:" msgstr "" "你可以在這個範例中看到對 ``assert_called_with`` 的一個「標準」呼叫是不夠的:" -#: ../../library/unittest.mock-examples.rst:1300 +#: ../../library/unittest.mock-examples.rst:1299 msgid "" "A comparison function for our ``Foo`` class might look something like this:" msgstr "對我們的 ``Foo`` 類別的比較函式看起來可能會像這樣:" -#: ../../library/unittest.mock-examples.rst:1312 +#: ../../library/unittest.mock-examples.rst:1311 msgid "" "And a matcher object that can use comparison functions like this for its " "equality operation would look something like this:" msgstr "而可以使用像這樣的比較函式進行其相等性運算的匹配器物件會長得像這樣:" -#: ../../library/unittest.mock-examples.rst:1323 +#: ../../library/unittest.mock-examples.rst:1322 msgid "Putting all this together:" msgstr "把這些都放在一起:" -#: ../../library/unittest.mock-examples.rst:1328 +#: ../../library/unittest.mock-examples.rst:1327 msgid "" "The ``Matcher`` is instantiated with our compare function and the ``Foo`` " "object we want to compare against. In ``assert_called_with`` the ``Matcher`` " @@ -1832,7 +1832,7 @@ msgstr "" "``assert_called_with`` 會通過,如果它們不匹配,則會引發 :exc:" "`AssertionError`:" -#: ../../library/unittest.mock-examples.rst:1341 +#: ../../library/unittest.mock-examples.rst:1340 msgid "" "With a bit of tweaking you could have the comparison function raise the :exc:" "`AssertionError` directly and provide a more useful failure message." @@ -1840,7 +1840,7 @@ msgstr "" "透過一些調整,你可以讓比較函式直接引發 :exc:`AssertionError` 並提供更有用的失" "敗訊息。" -#: ../../library/unittest.mock-examples.rst:1344 +#: ../../library/unittest.mock-examples.rst:1343 msgid "" "As of version 1.5, the Python testing library `PyHamcrest `_ provides similar functionality, that may be " diff --git a/library/unittest.mock.po b/library/unittest.mock.po index 90e5ce7b3a8..ee0adb078d1 100644 --- a/library/unittest.mock.po +++ b/library/unittest.mock.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!unittest.mock` --- mock object library" msgstr ":mod:`!unittest.mock` — mock 物件函式庫" -#: ../../library/unittest.mock.rst:12 +#: ../../library/unittest.mock.rst:11 msgid "**Source code:** :source:`Lib/unittest/mock.py`" msgstr "**原始碼:**\\ :source:`Lib/unittest/mock.py`" -#: ../../library/unittest.mock.rst:16 +#: ../../library/unittest.mock.rst:15 msgid "" ":mod:`!unittest.mock` is a library for testing in Python. It allows you to " "replace parts of your system under test with mock objects and make " @@ -35,7 +35,7 @@ msgstr "" ":mod:`!unittest.mock` 在 Python 中是一個用於進行測試的函式庫。 它允許你用 " "mock 物件在測試中替換部分系統,並判定它們是如何被使用的。" -#: ../../library/unittest.mock.rst:20 +#: ../../library/unittest.mock.rst:19 msgid "" ":mod:`!unittest.mock` provides a core :class:`Mock` class removing the need " "to create a host of stubs throughout your test suite. After performing an " @@ -47,7 +47,7 @@ msgstr "" "立大量 stubs 的需求。 在執行動作之後,你可以判定哪些 method (方法)/屬性被" "使用,以及有哪些引數被呼叫。 你還可以用常規的方式指定回傳值與設定所需的屬性。" -#: ../../library/unittest.mock.rst:26 +#: ../../library/unittest.mock.rst:25 msgid "" "Additionally, mock provides a :func:`patch` decorator that handles patching " "module and class level attributes within the scope of a test, along with :" @@ -60,7 +60,7 @@ msgstr "" "`sentinel`。有關如何使用 :class:`Mock`\\、:class:`MagicMock` 和 :func:" "`patch` 的一些範例,請參閱\\ `快速導引 `_。" -#: ../../library/unittest.mock.rst:32 +#: ../../library/unittest.mock.rst:31 msgid "" "Mock is designed for use with :mod:`unittest` and is based on the 'action -> " "assertion' pattern instead of 'record -> replay' used by many mocking " @@ -70,7 +70,7 @@ msgstr "" "assertion(判定)」 模式,而不是許多 mocking 框架使用的 「record(記錄) -> " "replay(重播)」 模式。" -#: ../../library/unittest.mock.rst:36 +#: ../../library/unittest.mock.rst:35 msgid "" "There is a backport of :mod:`!unittest.mock` for earlier versions of Python, " "available as :pypi:`mock` on PyPI." @@ -78,11 +78,11 @@ msgstr "" "對於早期版本的 Python,有一個 backport(向後移植的)\\ :mod:`!unittest.mock` " "可以使用,可從 PyPI 下載 :pypi:`mock`。" -#: ../../library/unittest.mock.rst:41 +#: ../../library/unittest.mock.rst:40 msgid "Quick Guide" msgstr "快速導引" -#: ../../library/unittest.mock.rst:59 +#: ../../library/unittest.mock.rst:58 msgid "" ":class:`Mock` and :class:`MagicMock` objects create all attributes and " "methods as you access them and store details of how they have been used. You " @@ -93,7 +93,7 @@ msgstr "" "(方法),並儲存它們如何被使用的詳細訊息。你可以配置它們,以指定回傳值或限制" "可用的屬性,然後對它們的使用方式做出判定:" -#: ../../library/unittest.mock.rst:71 +#: ../../library/unittest.mock.rst:70 msgid "" ":attr:`~Mock.side_effect` allows you to perform side effects, including " "raising an exception when a mock is called:" @@ -101,7 +101,7 @@ msgstr "" ":attr:`~Mock.side_effect` 允許你執行 side effects,包含在 mock 被呼叫時引發例" "外:" -#: ../../library/unittest.mock.rst:92 +#: ../../library/unittest.mock.rst:91 msgid "" "Mock has many other ways you can configure it and control its behaviour. For " "example the *spec* argument configures the mock to take its specification " @@ -112,7 +112,7 @@ msgstr "" "mock ,讓其從另一個物件取得規格。嘗試讀取 mock 中不存在於規格中的屬性或方法將" "會失敗,並出現 :exc:`AttributeError`。" -#: ../../library/unittest.mock.rst:97 +#: ../../library/unittest.mock.rst:96 msgid "" "The :func:`patch` decorator / context manager makes it easy to mock classes " "or objects in a module under test. The object you specify will be replaced " @@ -122,7 +122,7 @@ msgstr "" ":func:`patch` 裝飾器/情境管理器可以在測試中簡單的 mock 模組中的類別或物件。" "被指定的物件在測試期間會被替換為 mock(或其他物件),並在測試結束時恢復: ::" -#: ../../library/unittest.mock.rst:101 +#: ../../library/unittest.mock.rst:100 msgid "" ">>> from unittest.mock import patch\n" ">>> @patch('module.ClassName2')\n" @@ -150,7 +150,7 @@ msgstr "" "...\n" ">>> test()" -#: ../../library/unittest.mock.rst:116 +#: ../../library/unittest.mock.rst:115 msgid "" "When you nest patch decorators the mocks are passed in to the decorated " "function in the same order they applied (the normal *Python* order that " @@ -161,7 +161,7 @@ msgstr "" "同(一般 *Python* 應用裝飾器的順序)。這意味著由下而上,因此在上面的範例中," "``module.ClassName1`` 的 mock 會先被傳入。" -#: ../../library/unittest.mock.rst:121 +#: ../../library/unittest.mock.rst:120 msgid "" "With :func:`patch` it matters that you patch objects in the namespace where " "they are looked up. This is normally straightforward, but for a quick guide " @@ -171,13 +171,13 @@ msgstr "" "namespace where they are looked up)patch 物件。這通常很直接,但若需要快速導" "引,請參閱\\ :ref:`該 patch 何處 `。" -#: ../../library/unittest.mock.rst:125 +#: ../../library/unittest.mock.rst:124 msgid "" "As well as a decorator :func:`patch` can be used as a context manager in a " "with statement:" msgstr "裝飾器 :func:`patch` 也可以在 with 陳述式中被用來作為情境管理器:" -#: ../../library/unittest.mock.rst:135 +#: ../../library/unittest.mock.rst:134 msgid "" "There is also :func:`patch.dict` for setting values in a dictionary just " "during a scope and restoring the dictionary to its original state when the " @@ -186,7 +186,7 @@ msgstr "" "也有 :func:`patch.dict`,用於在測試範圍中設定 dictionary(字典)內的值,並在" "測試結束時將其恢復為原始狀態:" -#: ../../library/unittest.mock.rst:146 +#: ../../library/unittest.mock.rst:145 msgid "" "Mock supports the mocking of Python :ref:`magic methods `. " "The easiest way of using magic methods is with the :class:`MagicMock` class. " @@ -195,7 +195,7 @@ msgstr "" "Mock 支援對 Python 的\\ :ref:`魔術方法 `\\ 的 mocking。最簡單" "使用魔術方法的方式是使用 :class:`MagicMock` 類別。它允許你執行以下操作:" -#: ../../library/unittest.mock.rst:156 +#: ../../library/unittest.mock.rst:155 msgid "" "Mock allows you to assign functions (or other Mock instances) to magic " "methods and they will be called appropriately. The :class:`MagicMock` class " @@ -206,13 +206,13 @@ msgstr "" "叫。:class:`MagicMock` 類別是一個 Mock 的變體,它為你預先建好了所有魔術方法" "(好吧,所有有用的方法)。" -#: ../../library/unittest.mock.rst:161 +#: ../../library/unittest.mock.rst:160 msgid "" "The following is an example of using magic methods with the ordinary Mock " "class:" msgstr "以下是在一般 Mock 類別中使用魔術方法的範例:" -#: ../../library/unittest.mock.rst:169 +#: ../../library/unittest.mock.rst:168 msgid "" "For ensuring that the mock objects in your tests have the same api as the " "objects they are replacing, you can use :ref:`auto-speccing >> mock = Mock(return_value=None)\n" ">>> mock('hello')\n" @@ -499,18 +499,18 @@ msgstr "" ">>> mock.called\n" "False" -#: ../../library/unittest.mock.rst:414 +#: ../../library/unittest.mock.rst:413 msgid "" "This can be useful where you want to make a series of assertions that reuse " "the same object." msgstr "" -#: ../../library/unittest.mock.rst:417 +#: ../../library/unittest.mock.rst:416 msgid "" "*return_value* parameter when set to ``True`` resets :attr:`return_value`:" msgstr "" -#: ../../library/unittest.mock.rst:419 +#: ../../library/unittest.mock.rst:418 msgid "" ">>> mock = Mock(return_value=5)\n" ">>> mock('hello')\n" @@ -526,12 +526,12 @@ msgstr "" ">>> mock('hello')\n" "" -#: ../../library/unittest.mock.rst:428 +#: ../../library/unittest.mock.rst:427 msgid "" "*side_effect* parameter when set to ``True`` resets :attr:`side_effect`:" msgstr "" -#: ../../library/unittest.mock.rst:430 +#: ../../library/unittest.mock.rst:429 msgid "" ">>> mock = Mock(side_effect=ValueError)\n" ">>> mock('hello')\n" @@ -551,22 +551,22 @@ msgstr "" ">>> mock('hello')\n" "" -#: ../../library/unittest.mock.rst:441 +#: ../../library/unittest.mock.rst:440 msgid "" "Note that :meth:`reset_mock` *doesn't* clear the :attr:`return_value`, :attr:" "`side_effect` or any child attributes you have set using normal assignment " "by default." msgstr "" -#: ../../library/unittest.mock.rst:445 +#: ../../library/unittest.mock.rst:444 msgid "Child mocks are reset as well." msgstr "" -#: ../../library/unittest.mock.rst:447 +#: ../../library/unittest.mock.rst:446 msgid "Added two keyword-only arguments to the reset_mock function." msgstr "reset_mock 函式新增了兩個僅限關鍵字引數 (keyword-only arguments)。" -#: ../../library/unittest.mock.rst:452 +#: ../../library/unittest.mock.rst:451 msgid "" "Add a spec to a mock. *spec* can either be an object or a list of strings. " "Only attributes on the *spec* can be fetched as attributes from the mock." @@ -574,11 +574,11 @@ msgstr "" "向 mock 增加一個規格 (spec)。*spec* 可以是一個物件或一個字串串列 (list of " "strings)。只有在 *spec* 上的屬性才能作為 mock 的屬性被取得。" -#: ../../library/unittest.mock.rst:456 +#: ../../library/unittest.mock.rst:455 msgid "If *spec_set* is true then only attributes on the spec can be set." msgstr "如果 *spec_set* 為 true,那麼只能設定在規格中的屬性。" -#: ../../library/unittest.mock.rst:461 +#: ../../library/unittest.mock.rst:460 msgid "" "Attach a mock as an attribute of this one, replacing its name and parent. " "Calls to the attached mock will be recorded in the :attr:`method_calls` and :" @@ -588,11 +588,11 @@ msgstr "" "mock 的呼叫將被記錄在這個 Mock 的 :attr:`method_calls` 和 :attr:`mock_calls` " "屬性中。" -#: ../../library/unittest.mock.rst:468 +#: ../../library/unittest.mock.rst:467 msgid "Set attributes on the mock through keyword arguments." msgstr "透過關鍵字引數在 mock 上設定屬性。" -#: ../../library/unittest.mock.rst:470 +#: ../../library/unittest.mock.rst:469 msgid "" "Attributes plus return values and side effects can be set on child mocks " "using standard dot notation and unpacking a dictionary in the method call:" @@ -600,18 +600,18 @@ msgstr "" "可以在使用 method(方法)呼叫時,使用標準點記法 (dot notation) 並將字典拆開," "為 child mock 設定屬性、回傳值和 side effects:" -#: ../../library/unittest.mock.rst:484 +#: ../../library/unittest.mock.rst:483 msgid "The same thing can be achieved in the constructor call to mocks:" msgstr "同樣的事情可以在 mock 的建構函式呼叫中實現:" -#: ../../library/unittest.mock.rst:497 +#: ../../library/unittest.mock.rst:496 msgid "" ":meth:`configure_mock` exists to make it easier to do configuration after " "the mock has been created." msgstr "" ":meth:`configure_mock` 的存在是為了在 mock 被建立後更容易進行組態設定。" -#: ../../library/unittest.mock.rst:503 +#: ../../library/unittest.mock.rst:502 msgid "" ":class:`Mock` objects limit the results of ``dir(some_mock)`` to useful " "results. For mocks with a *spec* this includes all the permitted attributes " @@ -620,13 +620,13 @@ msgstr "" ":class:`Mock` 物件限制了 ``dir(some_mock)`` 僅顯示有用的結果。對於具有 " "*spec* 的 mock,這包含所有被允許的 mock 屬性。" -#: ../../library/unittest.mock.rst:507 +#: ../../library/unittest.mock.rst:506 msgid "" "See :data:`FILTER_DIR` for what this filtering does, and how to switch it " "off." msgstr "請參閱 :data:`FILTER_DIR` 以了解這種過濾行為的作用,以及如何關閉它。" -#: ../../library/unittest.mock.rst:513 +#: ../../library/unittest.mock.rst:512 msgid "" "Create the child mocks for attributes and return value. By default child " "mocks will be the same type as the parent. Subclasses of Mock may want to " @@ -635,35 +635,35 @@ msgstr "" "建立為了得到屬性和回傳值的 child mock。預設情況下,child mock 將與其上代是相" "同的型別。Mock 的子類別可能會想要置換此行為,以自訂 child mock 的建立方式。" -#: ../../library/unittest.mock.rst:518 +#: ../../library/unittest.mock.rst:517 msgid "" "For non-callable mocks the callable variant will be used (rather than any " "custom subclass)." msgstr "對於不可呼叫的 mock,將使用可呼叫的變體,而不是任何的自訂子類別。" -#: ../../library/unittest.mock.rst:524 +#: ../../library/unittest.mock.rst:523 msgid "A boolean representing whether or not the mock object has been called:" msgstr "一個 boolean(布林),表述 mock 物件是否已經被呼叫:" -#: ../../library/unittest.mock.rst:535 +#: ../../library/unittest.mock.rst:534 msgid "An integer telling you how many times the mock object has been called:" msgstr "一個整數,告訴你 mock 物件被呼叫的次數:" -#: ../../library/unittest.mock.rst:547 +#: ../../library/unittest.mock.rst:546 msgid "Set this to configure the value returned by calling the mock:" msgstr "設定此值以配置呼叫 mock 時回傳的值:" -#: ../../library/unittest.mock.rst:554 +#: ../../library/unittest.mock.rst:553 msgid "" "The default return value is a mock object and you can configure it in the " "normal way:" msgstr "預設的回傳值是一個 mock 物件,你也可以按照正常的方式配置它:" -#: ../../library/unittest.mock.rst:563 +#: ../../library/unittest.mock.rst:562 msgid ":attr:`return_value` can also be set in the constructor:" msgstr ":attr:`return_value` 也可以在建構函式中設定:" -#: ../../library/unittest.mock.rst:574 +#: ../../library/unittest.mock.rst:573 msgid "" "This can either be a function to be called when the mock is called, an " "iterable or an exception (class or instance) to be raised." @@ -671,7 +671,7 @@ msgstr "" "這可以是一個在呼叫 mock 時要呼叫的函式、一個可疊代物件,或者要引發的例外(類" "別或實例)。" -#: ../../library/unittest.mock.rst:577 +#: ../../library/unittest.mock.rst:576 msgid "" "If you pass in a function it will be called with same arguments as the mock " "and unless the function returns the :data:`DEFAULT` singleton the call to " @@ -684,7 +684,7 @@ msgstr "" "式回傳 :data:`DEFAULT`,那麼 mock 將回傳其正常的回傳值(從 :attr:" "`return_value` 得到)。" -#: ../../library/unittest.mock.rst:583 +#: ../../library/unittest.mock.rst:582 msgid "" "If you pass in an iterable, it is used to retrieve an iterator which must " "yield a value on every call. This value can either be an exception instance " @@ -695,21 +695,21 @@ msgstr "" "產出 (yield) 一個值。這個值可以是要引發的例外實例,或者是對 mock 呼叫時要回傳" "的值(處理 :data:`DEFAULT` 的方式與函式的狀況相同)。" -#: ../../library/unittest.mock.rst:588 +#: ../../library/unittest.mock.rst:587 msgid "" "An example of a mock that raises an exception (to test exception handling of " "an API):" msgstr "以下是一個引發例外的 mock 的範例(用於測試 API 的例外處理):" -#: ../../library/unittest.mock.rst:598 +#: ../../library/unittest.mock.rst:597 msgid "Using :attr:`side_effect` to return a sequence of values:" msgstr "使用 :attr:`side_effect` 回傳一連串值的範例:" -#: ../../library/unittest.mock.rst:605 +#: ../../library/unittest.mock.rst:604 msgid "Using a callable:" msgstr "使用可被呼叫物件的範例:" -#: ../../library/unittest.mock.rst:615 +#: ../../library/unittest.mock.rst:614 msgid "" ":attr:`side_effect` can be set in the constructor. Here's an example that " "adds one to the value the mock is called with and returns it:" @@ -717,11 +717,11 @@ msgstr "" ":attr:`side_effect` 可以在建構函式中設定。以下是一個範例,它將 mock 被呼叫時" "給的值加一並回傳:" -#: ../../library/unittest.mock.rst:625 +#: ../../library/unittest.mock.rst:624 msgid "Setting :attr:`side_effect` to ``None`` clears it:" msgstr "將 :attr:`side_effect` 設定為 ``None`` 可以清除它:" -#: ../../library/unittest.mock.rst:639 +#: ../../library/unittest.mock.rst:638 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 " @@ -735,7 +735,7 @@ msgstr "" "是 mock 被呼叫時傳遞的所有位置引數(或一個空元組)。第二個成員,其可以透過 " "``kwargs`` 屬性存取,是所有關鍵字引數(或一個空字典)。" -#: ../../library/unittest.mock.rst:672 +#: ../../library/unittest.mock.rst:671 msgid "" ":attr:`call_args`, along with members of the lists :attr:`call_args_list`, :" "attr:`method_calls` and :attr:`mock_calls` are :data:`call` objects. These " @@ -747,11 +747,11 @@ msgstr "" "取得各個引數並進行更複雜的斷言。參見 :ref:`calls as tuples `。" -#: ../../library/unittest.mock.rst:678 +#: ../../library/unittest.mock.rst:677 msgid "Added ``args`` and ``kwargs`` properties." msgstr "新增 ``args`` 與 ``kwargs`` 特性。" -#: ../../library/unittest.mock.rst:684 +#: ../../library/unittest.mock.rst:683 msgid "" "This is a list of all the calls made to the mock object in sequence (so the " "length of the list is the number of times it has been called). Before any " @@ -763,7 +763,7 @@ msgstr "" "在任何呼叫發生之前,它會是一個空的串列。 :data:`call` 物件可用於方便地建構呼" "叫的串列,以便與 :attr:`call_args_list` 進行比較。" -#: ../../library/unittest.mock.rst:700 +#: ../../library/unittest.mock.rst:699 msgid "" "Members of :attr:`call_args_list` are :data:`call` objects. These can be " "unpacked as tuples to get at the individual arguments. See :ref:`calls as " @@ -772,7 +772,7 @@ msgstr "" ":attr:`call_args_list` 的成員都是 :data:`call` 物件。這些物件可以被拆包為元" "組,以取得各個引數。參見 :ref:`calls as tuples `。" -#: ../../library/unittest.mock.rst:707 +#: ../../library/unittest.mock.rst:706 msgid "" "As well as tracking calls to themselves, mocks also track calls to methods " "and attributes, and *their* methods and attributes:" @@ -780,7 +780,7 @@ msgstr "" "除了追蹤對自身的呼叫之外,mock 還會追蹤對方法和屬性的呼叫,以及\\ *它們(這些" "方法和屬性)*\\ 的方法和屬性:" -#: ../../library/unittest.mock.rst:718 +#: ../../library/unittest.mock.rst:717 msgid "" "Members of :attr:`method_calls` are :data:`call` objects. These can be " "unpacked as tuples to get at the individual arguments. See :ref:`calls as " @@ -789,7 +789,7 @@ msgstr "" ":attr:`method_calls` 的成員都是 :data:`call` 物件。這些物件可以拆包為元組,以" "取得各個引數。參見 :ref:`calls as tuples `。" -#: ../../library/unittest.mock.rst:725 +#: ../../library/unittest.mock.rst:724 msgid "" ":attr:`mock_calls` records *all* calls to the mock object, its methods, " "magic methods *and* return value mocks." @@ -797,7 +797,7 @@ msgstr "" ":attr:`mock_calls` 記錄了 *所有* 對 mock 物件的呼叫,包含其方法、魔術方法以及" "回傳值 mock。" -#: ../../library/unittest.mock.rst:743 +#: ../../library/unittest.mock.rst:742 msgid "" "Members of :attr:`mock_calls` are :data:`call` objects. These can be " "unpacked as tuples to get at the individual arguments. See :ref:`calls as " @@ -806,7 +806,7 @@ msgstr "" ":attr:`mock_calls` 的成員都是 :data:`call` 物件。這些物件可以拆包為元組,以取" "得各個引數。參見 :ref:`calls as tuples `。" -#: ../../library/unittest.mock.rst:749 +#: ../../library/unittest.mock.rst:748 msgid "" "The way :attr:`mock_calls` are recorded means that where nested calls are " "made, the parameters of ancestor calls are not recorded and so will always " @@ -815,7 +815,7 @@ msgstr "" ":attr:`mock_calls` 記錄的方式意味著在進行巢狀呼叫時,上代 (ancestor) 呼叫的參" "數不會被記錄,因此在比較時它們將始終相等:" -#: ../../library/unittest.mock.rst:763 +#: ../../library/unittest.mock.rst:762 msgid "" "Normally the :attr:`!__class__` attribute of an object will return its type. " "For a mock object with a :attr:`!spec`, :attr:`!__class__` returns the spec " @@ -826,7 +826,7 @@ msgstr "" "的 mock 物件,:attr:`!__class__` 會回傳 spec 的類別。這允許 mock 物件透過對它" "們所替代或偽裝的物件進行的 :func:`isinstance` 測試:" -#: ../../library/unittest.mock.rst:772 +#: ../../library/unittest.mock.rst:771 msgid "" ":attr:`!__class__` is assignable to, this allows a mock to pass an :func:" "`isinstance` check without forcing you to use a spec:" @@ -834,7 +834,7 @@ msgstr "" ":attr:`!__class__` 可以被指定,這允許 mock 通過 :func:`isinstance` 檢查,而不" "需要強制使用 spec:" -#: ../../library/unittest.mock.rst:782 +#: ../../library/unittest.mock.rst:781 msgid "" "A non-callable version of :class:`Mock`. The constructor parameters have the " "same meaning of :class:`Mock`, with the exception of *return_value* and " @@ -843,7 +843,7 @@ msgstr "" ":class:`Mock` 的一個不可呼叫版本。建構函式參數的意義與 :class:`Mock` 相同,其" "例外為 *return_value* 和 *side_effect* 在不可呼叫的 mock 上無意義。" -#: ../../library/unittest.mock.rst:786 +#: ../../library/unittest.mock.rst:785 msgid "" "Mock objects that use a class or an instance as a :attr:`!spec` or :attr:`!" "spec_set` are able to pass :func:`isinstance` tests:" @@ -851,7 +851,7 @@ msgstr "" "使用類別或實例作為 :attr:`!spec` 或 :attr:`!spec_set` 的 mock 物件能夠通過 :" "func:`isinstance` 測試:" -#: ../../library/unittest.mock.rst:796 +#: ../../library/unittest.mock.rst:795 msgid "" "The :class:`Mock` classes have support for mocking magic methods. See :ref:" "`magic methods ` for the full details." @@ -859,7 +859,7 @@ msgstr "" ":class:`Mock` 類別支援 mock 魔術方法。細節請參考\\ :ref:`魔術方法 `。" -#: ../../library/unittest.mock.rst:799 +#: ../../library/unittest.mock.rst:798 msgid "" "The mock classes and the :func:`patch` decorators all take arbitrary keyword " "arguments for configuration. For the :func:`patch` decorators the keywords " @@ -870,7 +870,7 @@ msgstr "" "`patch` 裝飾器,這些關鍵字會傳遞給正在建立 mock 的建構函式。這些關鍵字引數用" "於配置 mock 的屬性:" -#: ../../library/unittest.mock.rst:810 +#: ../../library/unittest.mock.rst:809 msgid "" "The return value and side effect of child mocks can be set in the same way, " "using dotted notation. As you can't use dotted names directly in a call you " @@ -879,7 +879,7 @@ msgstr "" "Child mock 的回傳值和 side effect 可以使用使用點記法進行設置。由於你無法直接" "在呼叫中使用帶有點 (.) 的名稱,因此你必須建立一個字典並使用 ``**`` 解包:" -#: ../../library/unittest.mock.rst:825 +#: ../../library/unittest.mock.rst:824 msgid "" "A callable mock which was created with a *spec* (or a *spec_set*) will " "introspect the specification object's signature when matching calls to the " @@ -890,7 +890,7 @@ msgstr "" "將會內省 (introspect) 規格物件的簽名 (signature)。因此,它可以匹配實際呼叫的" "引數,無論它們是按位置傳遞還是按名稱傳遞: ::" -#: ../../library/unittest.mock.rst:830 +#: ../../library/unittest.mock.rst:829 msgid "" ">>> def f(a, b, c): pass\n" "...\n" @@ -908,7 +908,7 @@ msgstr "" ">>> mock.assert_called_with(1, 2, 3)\n" ">>> mock.assert_called_with(a=1, b=2, c=3)" -#: ../../library/unittest.mock.rst:838 +#: ../../library/unittest.mock.rst:837 msgid "" "This applies to :meth:`~Mock.assert_called_with`, :meth:`~Mock." "assert_called_once_with`, :meth:`~Mock.assert_has_calls` and :meth:`~Mock." @@ -920,13 +920,13 @@ msgstr "" "assert_any_call`。在使用 :ref:`auto-speccing` 時,它還適用於 mock 物件的方法" "呼叫。" -#: ../../library/unittest.mock.rst:843 +#: ../../library/unittest.mock.rst:842 msgid "Added signature introspection on specced and autospecced mock objects." msgstr "" "對於已經設置了規格(spec)和自動規格(autospec)的 mock 物件,新增簽名內省功" "能。" -#: ../../library/unittest.mock.rst:849 +#: ../../library/unittest.mock.rst:848 msgid "" "A mock intended to be used as a :class:`property`, or other :term:" "`descriptor`, on a class. :class:`PropertyMock` provides :meth:`~object." @@ -937,7 +937,7 @@ msgstr "" "class:`PropertyMock` 提供了 :meth:`~object.__get__` 和 :meth:`~object." "__set__` 方法,因此你可以在它被提取時指定回傳值。" -#: ../../library/unittest.mock.rst:854 +#: ../../library/unittest.mock.rst:853 msgid "" "Fetching a :class:`PropertyMock` instance from an object calls the mock, " "with no args. Setting it calls the mock with the value being set. ::" @@ -945,7 +945,7 @@ msgstr "" "從物件中提取 :class:`PropertyMock` 實例會不帶任何引數呼叫 mock。設定它則會用" "設定的值來呼叫 mock: ::" -#: ../../library/unittest.mock.rst:857 +#: ../../library/unittest.mock.rst:856 msgid "" ">>> class Foo:\n" "... @property\n" @@ -983,7 +983,7 @@ msgstr "" ">>> mock_foo.mock_calls\n" "[call(), call(6)]" -#: ../../library/unittest.mock.rst:875 +#: ../../library/unittest.mock.rst:874 msgid "" "Because of the way mock attributes are stored you can't directly attach a :" "class:`PropertyMock` to a mock object. Instead you can attach it to the mock " @@ -992,7 +992,7 @@ msgstr "" "由於 mock 屬性的儲存方式,你無法直接將 :class:`PropertyMock` 附加到 mock 物" "件。但是你可以將其附加到 mock 型別的物件: ::" -#: ../../library/unittest.mock.rst:879 +#: ../../library/unittest.mock.rst:878 msgid "" ">>> m = MagicMock()\n" ">>> p = PropertyMock(return_value=3)\n" @@ -1008,14 +1008,14 @@ msgstr "" "3\n" ">>> p.assert_called_once_with()" -#: ../../library/unittest.mock.rst:888 +#: ../../library/unittest.mock.rst:887 msgid "" "If an :exc:`AttributeError` is raised by :class:`PropertyMock`, it will be " "interpreted as a missing descriptor and :meth:`~object.__getattr__` will be " "called on the parent mock::" msgstr "" -#: ../../library/unittest.mock.rst:892 +#: ../../library/unittest.mock.rst:891 msgid "" ">>> m = MagicMock()\n" ">>> no_attribute = PropertyMock(side_effect=AttributeError)\n" @@ -1029,11 +1029,11 @@ msgstr "" ">>> m.my_property\n" "" -#: ../../library/unittest.mock.rst:898 +#: ../../library/unittest.mock.rst:897 msgid "See :meth:`~object.__getattr__` for details." msgstr "詳情請見 :meth:`~object.__getattr__`。" -#: ../../library/unittest.mock.rst:903 +#: ../../library/unittest.mock.rst:902 msgid "" "An asynchronous version of :class:`MagicMock`. The :class:`AsyncMock` object " "will behave so the object is recognized as an async function, and the result " @@ -1042,7 +1042,7 @@ msgstr "" ":class:`MagicMock` 的非同步版本。:class:`AsyncMock` 物件的表現將被視為非同步" "函式,並且呼叫的結果是一個可等待物件。" -#: ../../library/unittest.mock.rst:913 +#: ../../library/unittest.mock.rst:912 msgid "" "The result of ``mock()`` is an async function which will have the outcome of " "``side_effect`` or ``return_value`` after it has been awaited:" @@ -1050,19 +1050,19 @@ msgstr "" "``mock()`` 的結果是一個非同步函式,在它被等待後將具有 ``side_effect`` 或 " "``return_value`` 的結果:" -#: ../../library/unittest.mock.rst:916 +#: ../../library/unittest.mock.rst:915 msgid "" "if ``side_effect`` is a function, the async function will return the result " "of that function," msgstr "如果 ``side_effect`` 是一個函式,非同步函式將回傳該函式的結果," -#: ../../library/unittest.mock.rst:918 +#: ../../library/unittest.mock.rst:917 msgid "" "if ``side_effect`` is an exception, the async function will raise the " "exception," msgstr "如果 ``side_effect`` 是一個例外,則非同步函式將引發該例外," -#: ../../library/unittest.mock.rst:920 +#: ../../library/unittest.mock.rst:919 msgid "" "if ``side_effect`` is an iterable, the async function will return the next " "value of the iterable, however, if the sequence of result is :term:" @@ -1072,7 +1072,7 @@ msgstr "" "但如果結果序列\\ :term:`耗盡 `,將立即引發 " "``StopAsyncIteration``," -#: ../../library/unittest.mock.rst:923 +#: ../../library/unittest.mock.rst:922 msgid "" "if ``side_effect`` is not defined, the async function will return the value " "defined by ``return_value``, hence, by default, the async function returns a " @@ -1081,7 +1081,7 @@ msgstr "" "如果 ``side_effect`` 沒有被定義,非同步函式將回傳由 ``return_value`` 定義的" "值,因此在預設情況下,非同步函式回傳一個新的 :class:`AsyncMock` 物件。" -#: ../../library/unittest.mock.rst:928 +#: ../../library/unittest.mock.rst:927 msgid "" "Setting the *spec* of a :class:`Mock` or :class:`MagicMock` to an async " "function will result in a coroutine object being returned after calling." @@ -1089,7 +1089,7 @@ msgstr "" "將 :class:`Mock` 或 :class:`MagicMock` 的 *spec* 設定為非同步函式將導致在呼叫" "後回傳一個協程物件。" -#: ../../library/unittest.mock.rst:940 +#: ../../library/unittest.mock.rst:939 msgid "" "Setting the *spec* of a :class:`Mock`, :class:`MagicMock`, or :class:" "`AsyncMock` to a class with asynchronous and synchronous functions will " @@ -1104,7 +1104,7 @@ msgstr "" "`MagicMock`\\ )或 :class:`Mock`\\ (如果上代 mock 為 :class:`Mock`\\ )。所" "有非同步函式將被設定為 :class:`AsyncMock`。" -#: ../../library/unittest.mock.rst:968 +#: ../../library/unittest.mock.rst:967 msgid "" "Assert that the mock was awaited at least once. Note that this is separate " "from the object having been called, the ``await`` keyword must be used:" @@ -1112,25 +1112,25 @@ msgstr "" "斷言 mock 至少被等待過一次。請注意這與物件是否被呼叫是分開的,``await`` 關鍵" "字必須被使用:" -#: ../../library/unittest.mock.rst:987 +#: ../../library/unittest.mock.rst:986 msgid "Assert that the mock was awaited exactly once." msgstr "斷言 mock 正好被等待了一次。" -#: ../../library/unittest.mock.rst:1003 +#: ../../library/unittest.mock.rst:1002 msgid "Assert that the last await was with the specified arguments." msgstr "斷言最後一次等待使用了指定的引數。" -#: ../../library/unittest.mock.rst:1020 +#: ../../library/unittest.mock.rst:1019 msgid "" "Assert that the mock was awaited exactly once and with the specified " "arguments." msgstr "斷言 mock 只被等待了一次並使用了指定的引數。" -#: ../../library/unittest.mock.rst:1037 +#: ../../library/unittest.mock.rst:1036 msgid "Assert the mock has ever been awaited with the specified arguments." msgstr "斷言 mock 曾經被使用指定的引數等待過。" -#: ../../library/unittest.mock.rst:1053 +#: ../../library/unittest.mock.rst:1052 msgid "" "Assert the mock has been awaited with the specified calls. The :attr:" "`await_args_list` list is checked for the awaits." @@ -1138,7 +1138,7 @@ msgstr "" "斷言 mock 已被使用指定的呼叫進行等待。:attr:`await_args_list` 串列將被檢查以" "確認等待的內容。" -#: ../../library/unittest.mock.rst:1056 +#: ../../library/unittest.mock.rst:1055 msgid "" "If *any_order* is false then the awaits must be sequential. There can be " "extra calls before or after the specified awaits." @@ -1146,7 +1146,7 @@ msgstr "" "如果 *any_order* 為 false,則等待必須按照順序。指定的等待之前或之後可以有額外" "的呼叫。" -#: ../../library/unittest.mock.rst:1060 +#: ../../library/unittest.mock.rst:1059 msgid "" "If *any_order* is true then the awaits can be in any order, but they must " "all appear in :attr:`await_args_list`." @@ -1154,11 +1154,11 @@ msgstr "" "如果 *any_order* 為 true,則等待可以以任何順序出現,但它們必須全部出現在 :" "attr:`await_args_list` 中。" -#: ../../library/unittest.mock.rst:1080 +#: ../../library/unittest.mock.rst:1079 msgid "Assert that the mock was never awaited." msgstr "斷言 mock 從未被等待。" -#: ../../library/unittest.mock.rst:1087 +#: ../../library/unittest.mock.rst:1086 msgid "" "See :func:`Mock.reset_mock`. Also sets :attr:`await_count` to 0, :attr:" "`await_args` to None, and clears the :attr:`await_args_list`." @@ -1166,12 +1166,12 @@ msgstr "" "參見 :func:`Mock.reset_mock`。同時將 :attr:`await_count` 設定為 0,:attr:" "`await_args` 設定為 None,並清除 :attr:`await_args_list`。" -#: ../../library/unittest.mock.rst:1092 +#: ../../library/unittest.mock.rst:1091 msgid "" "An integer keeping track of how many times the mock object has been awaited." msgstr "一個整數,用來記錄 mock 物件已被等待的次數。" -#: ../../library/unittest.mock.rst:1107 +#: ../../library/unittest.mock.rst:1106 msgid "" "This is either ``None`` (if the mock hasn’t been awaited), or the arguments " "that the mock was last awaited with. Functions the same as :attr:`Mock." @@ -1180,7 +1180,7 @@ msgstr "" "這可能是 ``None``\\ (如果 mock 尚未被等待),或者是上次等待 mock 時使用的引" "數。與 :attr:`Mock.call_args` 的功能相同。" -#: ../../library/unittest.mock.rst:1125 +#: ../../library/unittest.mock.rst:1124 msgid "" "This is a list of all the awaits made to the mock object in sequence (so the " "length of the list is the number of times it has been awaited). Before any " @@ -1189,58 +1189,58 @@ msgstr "" "這是一個按照順序記錄 mock 物件所有等待的串列(因此串列的長度表示該物件已被等" "待的次數)。在進行任何等待之前,此串列為空。" -#: ../../library/unittest.mock.rst:1145 +#: ../../library/unittest.mock.rst:1144 msgid "" "A version of :class:`MagicMock` for multithreading tests. The :class:" "`ThreadingMock` object provides extra methods to wait for a call to be " "invoked, rather than assert on it immediately." msgstr "" -#: ../../library/unittest.mock.rst:1149 +#: ../../library/unittest.mock.rst:1148 msgid "" "The default timeout is specified by the ``timeout`` argument, or if unset by " "the :attr:`ThreadingMock.DEFAULT_TIMEOUT` attribute, which defaults to " "blocking (``None``)." msgstr "" -#: ../../library/unittest.mock.rst:1152 +#: ../../library/unittest.mock.rst:1151 msgid "" "You can configure the global default timeout by setting :attr:`ThreadingMock." "DEFAULT_TIMEOUT`." msgstr "" -#: ../../library/unittest.mock.rst:1156 +#: ../../library/unittest.mock.rst:1155 msgid "Waits until the mock is called." msgstr "等待直到 mock 被呼叫。" -#: ../../library/unittest.mock.rst:1158 +#: ../../library/unittest.mock.rst:1157 msgid "" "If a timeout was passed at the creation of the mock or if a timeout argument " "is passed to this function, the function raises an :exc:`AssertionError` if " "the call is not performed in time." msgstr "" -#: ../../library/unittest.mock.rst:1170 +#: ../../library/unittest.mock.rst:1169 msgid "Waits until the mock is called with the specified arguments." msgstr "等到直到 mock 被以特定引數呼叫。" -#: ../../library/unittest.mock.rst:1172 +#: ../../library/unittest.mock.rst:1171 msgid "" "If a timeout was passed at the creation of the mock the function raises an :" "exc:`AssertionError` if the call is not performed in time." msgstr "" -#: ../../library/unittest.mock.rst:1183 +#: ../../library/unittest.mock.rst:1182 msgid "" "Global default timeout in seconds to create instances of :class:" "`ThreadingMock`." msgstr "" -#: ../../library/unittest.mock.rst:1189 +#: ../../library/unittest.mock.rst:1188 msgid "Calling" msgstr "呼叫" -#: ../../library/unittest.mock.rst:1191 +#: ../../library/unittest.mock.rst:1190 msgid "" "Mock objects are callable. The call will return the value set as the :attr:" "`~Mock.return_value` attribute. The default return value is a new Mock " @@ -1252,7 +1252,7 @@ msgstr "" "的回傳值是一個新的 Mock 物件;它會在第一次存取回傳值時(無論是顯式存取還是透" "過呼叫 Mock)被建立,但是這個回傳值會被儲存,之後每次都回傳同一個值。" -#: ../../library/unittest.mock.rst:1197 +#: ../../library/unittest.mock.rst:1196 msgid "" "Calls made to the object will be recorded in the attributes like :attr:" "`~Mock.call_args` and :attr:`~Mock.call_args_list`." @@ -1260,7 +1260,7 @@ msgstr "" "對物件的呼叫會被記錄在如 :attr:`~Mock.call_args` 和 :attr:`~Mock." "call_args_list` 等屬性中。" -#: ../../library/unittest.mock.rst:1200 +#: ../../library/unittest.mock.rst:1199 msgid "" "If :attr:`~Mock.side_effect` is set then it will be called after the call " "has been recorded, so if :attr:`!side_effect` raises an exception the call " @@ -1269,7 +1269,7 @@ msgstr "" "如果 :attr:`~Mock.side_effect` 被設定,那麼在呼叫被記錄後它才會被呼叫,所以如" "果 :attr:`!side_effect` 引發例外,呼叫仍然會被記錄。" -#: ../../library/unittest.mock.rst:1204 +#: ../../library/unittest.mock.rst:1203 msgid "" "The simplest way to make a mock raise an exception when called is to make :" "attr:`~Mock.side_effect` an exception class or instance:" @@ -1277,7 +1277,7 @@ msgstr "" "呼叫 mock 時引發例外的最簡單方式是將 :attr:`~Mock.side_effect` 設定為例外類別" "或實例:" -#: ../../library/unittest.mock.rst:1222 +#: ../../library/unittest.mock.rst:1221 msgid "" "If :attr:`~Mock.side_effect` is a function then whatever that function " "returns is what calls to the mock return. The :attr:`!side_effect` function " @@ -1288,7 +1288,7 @@ msgstr "" "叫所回傳的值。:attr:`!side_effect` 函式會使用與 mock 相同的引數被呼叫。這讓你" "可以根據輸入動態地變更呼叫的回傳值:" -#: ../../library/unittest.mock.rst:1238 +#: ../../library/unittest.mock.rst:1237 msgid "" "If you want the mock to still return the default return value (a new mock), " "or any set return value, then there are two ways of doing this. Either " @@ -1299,7 +1299,7 @@ msgstr "" "值,有兩種方法可以實現。從 :attr:`~Mock.side_effect` 內部回傳 :attr:`~Mock." "return_value`,或回傳 :data:`DEFAULT`:" -#: ../../library/unittest.mock.rst:1257 +#: ../../library/unittest.mock.rst:1256 msgid "" "To remove a :attr:`~Mock.side_effect`, and return to the default behaviour, " "set the :attr:`!side_effect` to ``None``:" @@ -1307,7 +1307,7 @@ msgstr "" "要刪除 :attr:`~Mock.side_effect`,並恢復預設行為,將 :attr:`!side_effect` 設" "為 ``None``:" -#: ../../library/unittest.mock.rst:1271 +#: ../../library/unittest.mock.rst:1270 msgid "" "The :attr:`~Mock.side_effect` can also be any iterable object. Repeated " "calls to the mock will return values from the iterable (until the iterable " @@ -1317,13 +1317,13 @@ msgstr "" "疊代物件中回傳值(直到可疊代物件\\ :term:`耗盡 `\\ 並引" "發 :exc:`StopIteration` 為止):" -#: ../../library/unittest.mock.rst:1287 +#: ../../library/unittest.mock.rst:1286 msgid "" "If any members of the iterable are exceptions they will be raised instead of " "returned::" msgstr "如果可疊代物件中的任何成員是例外,則它們將被引發而不是被回傳: ::" -#: ../../library/unittest.mock.rst:1290 +#: ../../library/unittest.mock.rst:1289 msgid "" ">>> iterable = (33, ValueError, 66)\n" ">>> m = MagicMock(side_effect=iterable)\n" @@ -1347,17 +1347,17 @@ msgstr "" ">>> m()\n" "66" -#: ../../library/unittest.mock.rst:1305 +#: ../../library/unittest.mock.rst:1304 msgid "Deleting Attributes" msgstr "刪除屬性" -#: ../../library/unittest.mock.rst:1307 +#: ../../library/unittest.mock.rst:1306 msgid "" "Mock objects create attributes on demand. This allows them to pretend to be " "objects of any type." msgstr "Mock 物件會在需要時建立屬性。這使得它們可以假裝成任何種類的物件。" -#: ../../library/unittest.mock.rst:1310 +#: ../../library/unittest.mock.rst:1309 msgid "" "You may want a mock object to return ``False`` to a :func:`hasattr` call, or " "raise an :exc:`AttributeError` when an attribute is fetched. You can do this " @@ -1368,7 +1368,7 @@ msgstr "" "提取時引發 :exc:`AttributeError`。你可以透過將物件提供為 mock 的 :attr:`!" "spec` 來實現這一點,但這並不總是那麼好用。" -#: ../../library/unittest.mock.rst:1314 +#: ../../library/unittest.mock.rst:1313 msgid "" "You \"block\" attributes by deleting them. Once deleted, accessing an " "attribute will raise an :exc:`AttributeError`." @@ -1376,11 +1376,11 @@ msgstr "" "你可以透過刪除屬性來「阻擋」它們。一旦刪除,再次存取該屬性將會引發 :exc:" "`AttributeError`。" -#: ../../library/unittest.mock.rst:1331 +#: ../../library/unittest.mock.rst:1330 msgid "Mock names and the name attribute" msgstr "Mock 名稱與名稱屬性" -#: ../../library/unittest.mock.rst:1333 +#: ../../library/unittest.mock.rst:1332 msgid "" "Since \"name\" is an argument to the :class:`Mock` constructor, if you want " "your mock object to have a \"name\" attribute you can't just pass it in at " @@ -1391,7 +1391,7 @@ msgstr "" "擁有 \"name\" 屬性,你不能在建立時直接傳遞它。有兩種替代方法。其中一個選擇是" "使用 :meth:`~Mock.configure_mock`: ::" -#: ../../library/unittest.mock.rst:1338 +#: ../../library/unittest.mock.rst:1337 msgid "" ">>> mock = MagicMock()\n" ">>> mock.configure_mock(name='my_name')\n" @@ -1403,13 +1403,13 @@ msgstr "" ">>> mock.name\n" "'my_name'" -#: ../../library/unittest.mock.rst:1343 +#: ../../library/unittest.mock.rst:1342 msgid "" "A simpler option is to simply set the \"name\" attribute after mock " "creation::" msgstr "更簡單的方法是在 mock 建立後直接設定 \"name\" 屬性: ::" -#: ../../library/unittest.mock.rst:1345 +#: ../../library/unittest.mock.rst:1344 msgid "" ">>> mock = MagicMock()\n" ">>> mock.name = \"foo\"" @@ -1417,11 +1417,11 @@ msgstr "" ">>> mock = MagicMock()\n" ">>> mock.name = \"foo\"" -#: ../../library/unittest.mock.rst:1350 +#: ../../library/unittest.mock.rst:1349 msgid "Attaching Mocks as Attributes" msgstr "如同屬性一般附加 mock" -#: ../../library/unittest.mock.rst:1352 +#: ../../library/unittest.mock.rst:1351 msgid "" "When you attach a mock as an attribute of another mock (or as the return " "value) it becomes a \"child\" of that mock. Calls to the child are recorded " @@ -1437,7 +1437,7 @@ msgstr "" "mock 附加到記錄所有對子代的呼叫的上代並允許你對 mock 間的呼叫順序進行斷言非常" "有用:" -#: ../../library/unittest.mock.rst:1370 +#: ../../library/unittest.mock.rst:1369 msgid "" "The exception to this is if the mock has a name. This allows you to prevent " "the \"parenting\" if for some reason you don't want it to happen." @@ -1445,7 +1445,7 @@ msgstr "" "如果 mock 有 name 引數,則上述規則會有例外。這使你可以防止「親屬關係 " "(parenting)」的建立,假設因為某些原因你不希望這種狀況發生。" -#: ../../library/unittest.mock.rst:1381 +#: ../../library/unittest.mock.rst:1380 msgid "" "Mocks created for you by :func:`patch` are automatically given names. To " "attach mocks that have names to a parent you use the :meth:`~Mock." @@ -1454,7 +1454,7 @@ msgstr "" "由 :func:`patch` 為你建立的 mock 會自動被賦予名稱。若要將具有名稱的 mock 附加" "到上代,你可以使用 :meth:`~Mock.attach_mock` 方法: ::" -#: ../../library/unittest.mock.rst:1385 +#: ../../library/unittest.mock.rst:1384 msgid "" ">>> thing1 = object()\n" ">>> thing2 = object()\n" @@ -1482,7 +1482,7 @@ msgstr "" ">>> parent.mock_calls\n" "[call.child1('one'), call.child2('two')]" -#: ../../library/unittest.mock.rst:1399 +#: ../../library/unittest.mock.rst:1398 msgid "" "The only exceptions are magic methods and attributes (those that have " "leading and trailing double underscores). Mock doesn't create these but " @@ -1496,11 +1496,11 @@ msgstr "" "魔術方法卻獲得一個新的 Mock 物件時,會讓直譯器\\ *非常*\\ 困惑。如果你需要魔" "術方法的支援,請參閱\\ :ref:`魔術方法 `。" -#: ../../library/unittest.mock.rst:1408 +#: ../../library/unittest.mock.rst:1407 msgid "The patchers" msgstr "Patchers" -#: ../../library/unittest.mock.rst:1410 +#: ../../library/unittest.mock.rst:1409 msgid "" "The patch decorators are used for patching objects only within the scope of " "the function they decorate. They automatically handle the unpatching for " @@ -1511,17 +1511,17 @@ msgstr "" "patch 的中止,即使有異常被引發也是如此。所有這些函式也可以在 with 陳述式中使" "用,或者作為類別裝飾器使用。" -#: ../../library/unittest.mock.rst:1417 +#: ../../library/unittest.mock.rst:1416 msgid "patch" msgstr "patch" -#: ../../library/unittest.mock.rst:1421 +#: ../../library/unittest.mock.rst:1420 msgid "" "The key is to do the patching in the right namespace. See the section `where " "to patch`_." msgstr "關鍵是要在正確的命名空間進行 patch。請參閱 `where to patch`_ 一節。" -#: ../../library/unittest.mock.rst:1425 +#: ../../library/unittest.mock.rst:1424 msgid "" ":func:`patch` acts as a function decorator, class decorator or a context " "manager. Inside the body of the function or with statement, the *target* is " @@ -1532,7 +1532,7 @@ msgstr "" "內部,*目標*\\ 會被 patch 成一個\\ *新的*\\ 物件。當函式或 with 陳述式結束" "時,patch 就會被解除。" -#: ../../library/unittest.mock.rst:1430 +#: ../../library/unittest.mock.rst:1429 msgid "" "If *new* is omitted, then the target is replaced with an :class:`AsyncMock` " "if the patched object is an async function or a :class:`MagicMock` " @@ -1546,7 +1546,7 @@ msgstr "" "用且省略了 *new*,則所建立的 mock 會作為額外的引數傳遞給被裝飾的函式。如果 :" "func:`patch` 作為情境管理器使用,則所建立的 mock 將由情境管理器回傳。" -#: ../../library/unittest.mock.rst:1438 +#: ../../library/unittest.mock.rst:1437 msgid "" "*target* should be a string in the form ``'package.module.ClassName'``. The " "*target* is imported and the specified object replaced with the *new* " @@ -1559,7 +1559,7 @@ msgstr "" "`patch` 的環境中引入。target 在執行被裝飾的函式時被引入,而不是在裝飾器作用" "時 (decoration time)。" -#: ../../library/unittest.mock.rst:1444 +#: ../../library/unittest.mock.rst:1443 msgid "" "The *spec* and *spec_set* keyword arguments are passed to the :class:" "`MagicMock` if patch is creating one for you." @@ -1567,7 +1567,7 @@ msgstr "" "*spec* 和 *spec_set* 關鍵字引數會傳遞給 :class:`MagicMock`,如果 patch 正在為" "你建立一個。" -#: ../../library/unittest.mock.rst:1447 +#: ../../library/unittest.mock.rst:1446 msgid "" "In addition you can pass ``spec=True`` or ``spec_set=True``, which causes " "patch to pass in the object being mocked as the spec/spec_set object." @@ -1575,7 +1575,7 @@ msgstr "" "此外,你還可以傳遞 ``spec=True`` 或 ``spec_set=True``,這將導致 patch 將被 " "mock 的物件作為 spec/spec_set 物件傳遞。" -#: ../../library/unittest.mock.rst:1450 +#: ../../library/unittest.mock.rst:1449 msgid "" "*new_callable* allows you to specify a different class, or callable object, " "that will be called to create the *new* object. By default :class:" @@ -1585,7 +1585,7 @@ msgstr "" "*new* 物件。預設情況下,對於非同步函式使用 :class:`AsyncMock`,而對於其他情況" "則使用 :class:`MagicMock`。" -#: ../../library/unittest.mock.rst:1454 +#: ../../library/unittest.mock.rst:1453 msgid "" "A more powerful form of *spec* is *autospec*. If you set ``autospec=True`` " "then the mock will be created with a spec from the object being replaced. " @@ -1603,7 +1603,7 @@ msgstr "" "mock,它們的回傳值(即 'instance')將具有與類別相同的規格。請參閱 :func:" "`create_autospec` 函式和 :ref:`auto-speccing`。" -#: ../../library/unittest.mock.rst:1464 +#: ../../library/unittest.mock.rst:1463 msgid "" "Instead of ``autospec=True`` you can pass ``autospec=some_object`` to use an " "arbitrary object as the spec instead of the one being replaced." @@ -1611,7 +1611,7 @@ msgstr "" "你可以用 ``autospec=some_object`` 替代 ``autospec=True``,以使用任意物件作為" "規格,而不是被替換的物件。" -#: ../../library/unittest.mock.rst:1467 +#: ../../library/unittest.mock.rst:1466 msgid "" "By default :func:`patch` will fail to replace attributes that don't exist. " "If you pass in ``create=True``, and the attribute doesn't exist, patch will " @@ -1627,7 +1627,7 @@ msgstr "" "行環境建立的屬性的測試時非常有用。此功能預設為關閉,因為這可能會相當危險。開" "啟這個功能後,你可以對於實際上不存在的 API 撰寫會通過的測試!" -#: ../../library/unittest.mock.rst:1477 +#: ../../library/unittest.mock.rst:1476 msgid "" "If you are patching builtins in a module then you don't need to pass " "``create=True``, it will be added by default." @@ -1635,7 +1635,7 @@ msgstr "" "如果你正在 patch 模組中的內建函式,那麼你不需要傳遞 ``create=True``,它預設會" "被加入。" -#: ../../library/unittest.mock.rst:1481 +#: ../../library/unittest.mock.rst:1480 msgid "" "Patch can be used as a :class:`~unittest.TestCase` class decorator. It works " "by decorating each test method in the class. This reduces the boilerplate " @@ -1651,7 +1651,7 @@ msgstr "" "設情況下會是 ``'test'``,這與 :mod:`unittest` 尋找測試的方式相匹配。你可以通" "過設定 ``patch.TEST_PREFIX`` 來指定別的前綴。" -#: ../../library/unittest.mock.rst:1488 +#: ../../library/unittest.mock.rst:1487 msgid "" "Patch can be used as a context manager, with the with statement. Here the " "patching applies to the indented block after the with statement. If you use " @@ -1662,7 +1662,7 @@ msgstr "" "的縮排區塊。如果你使用 \"as\",則被 patch 的物件將被綁定到 \"as\" 後面的名" "稱;如果 :func:`patch` 正在為你建立一個 mock 物件,這會非常有用。" -#: ../../library/unittest.mock.rst:1493 +#: ../../library/unittest.mock.rst:1492 msgid "" ":func:`patch` takes arbitrary keyword arguments. These will be passed to :" "class:`AsyncMock` if the patched object is asynchronous, to :class:" @@ -1672,7 +1672,7 @@ msgstr "" "傳遞給 :class:`AsyncMock`,如果是同步的則會傳遞給 :class:`MagicMock`,或如果" "指定了 *new_callable*,則傳遞給它。" -#: ../../library/unittest.mock.rst:1497 +#: ../../library/unittest.mock.rst:1496 msgid "" "``patch.dict(...)``, ``patch.multiple(...)`` and ``patch.object(...)`` are " "available for alternate use-cases." @@ -1680,14 +1680,14 @@ msgstr "" "``patch.dict(...)``、``patch.multiple(...)`` 和 ``patch.object(...)`` 可用於" "其餘的使用情境。" -#: ../../library/unittest.mock.rst:1500 +#: ../../library/unittest.mock.rst:1499 msgid "" ":func:`patch` as function decorator, creating the mock for you and passing " "it into the decorated function::" msgstr "" ":func:`patch` 作為函式裝飾器,為你建立 mock 並將其傳遞給被裝飾的函式: ::" -#: ../../library/unittest.mock.rst:1503 +#: ../../library/unittest.mock.rst:1502 msgid "" ">>> @patch('__main__.SomeClass')\n" "... def function(normal_argument, mock_class):\n" @@ -1703,7 +1703,7 @@ msgstr "" ">>> function(None)\n" "True" -#: ../../library/unittest.mock.rst:1510 +#: ../../library/unittest.mock.rst:1509 msgid "" "Patching a class replaces the class with a :class:`MagicMock` *instance*. If " "the class is instantiated in the code under test then it will be the :attr:" @@ -1713,7 +1713,7 @@ msgstr "" "測試的程式碼中實例化,那麼它將是會被使用的 mock 的 :attr:`~Mock." "return_value`。" -#: ../../library/unittest.mock.rst:1514 +#: ../../library/unittest.mock.rst:1513 msgid "" "If the class is instantiated multiple times you could use :attr:`~Mock." "side_effect` to return a new mock each time. Alternatively you can set the " @@ -1722,7 +1722,7 @@ msgstr "" "如果該類別被實例化多次,你可以使用 :attr:`~Mock.side_effect` 來每次回傳一個新" "的 mock。 或者你可以將 *return_value* 設定成你想要的任何值。" -#: ../../library/unittest.mock.rst:1518 +#: ../../library/unittest.mock.rst:1517 msgid "" "To configure return values on methods of *instances* on the patched class " "you must do this on the :attr:`~Mock.return_value`. For example::" @@ -1730,7 +1730,7 @@ msgstr "" "若要配置被 patch 的類別的\\ *實例*\\ 方法的回傳值,你必須在 :attr:`~Mock." "return_value` 上進行配置。例如: ::" -#: ../../library/unittest.mock.rst:1521 +#: ../../library/unittest.mock.rst:1520 msgid "" ">>> class Class:\n" "... def method(self):\n" @@ -1754,7 +1754,7 @@ msgstr "" "... assert Class().method() == 'foo'\n" "..." -#: ../../library/unittest.mock.rst:1532 +#: ../../library/unittest.mock.rst:1531 msgid "" "If you use *spec* or *spec_set* and :func:`patch` is replacing a *class*, " "then the return value of the created mock will have the same spec. ::" @@ -1762,7 +1762,7 @@ msgstr "" "如果你使用 *spec* 或 *spec_set* 且 :func:`patch` 正在取代一個\\ *類別*,那麼" "被建立的 mock 的回傳值將具有相同的規格。: ::" -#: ../../library/unittest.mock.rst:1535 +#: ../../library/unittest.mock.rst:1534 msgid "" ">>> Original = Class\n" ">>> patcher = patch('__main__.Class', spec=True)\n" @@ -1778,7 +1778,7 @@ msgstr "" ">>> assert isinstance(instance, Original)\n" ">>> patcher.stop()" -#: ../../library/unittest.mock.rst:1542 +#: ../../library/unittest.mock.rst:1541 msgid "" "The *new_callable* argument is useful where you want to use an alternative " "class to the default :class:`MagicMock` for the created mock. For example, " @@ -1788,7 +1788,7 @@ msgstr "" "*new_callable* 引數非常有用。例如,如果你想要一個 :class:`NonCallableMock` 被" "使用: ::" -#: ../../library/unittest.mock.rst:1546 +#: ../../library/unittest.mock.rst:1545 msgid "" ">>> thing = object()\n" ">>> with patch('__main__.thing', new_callable=NonCallableMock) as " @@ -1810,13 +1810,13 @@ msgstr "" " ...\n" "TypeError: 'NonCallableMock' object is not callable" -#: ../../library/unittest.mock.rst:1555 +#: ../../library/unittest.mock.rst:1554 msgid "" "Another use case might be to replace an object with an :class:`io.StringIO` " "instance::" msgstr "另一個用法是用一個 :class:`io.StringIO` 實例替換一個物件: ::" -#: ../../library/unittest.mock.rst:1557 +#: ../../library/unittest.mock.rst:1556 msgid "" ">>> from io import StringIO\n" ">>> def foo():\n" @@ -1840,7 +1840,7 @@ msgstr "" "...\n" ">>> test()" -#: ../../library/unittest.mock.rst:1568 +#: ../../library/unittest.mock.rst:1567 msgid "" "When :func:`patch` is creating a mock for you, it is common that the first " "thing you need to do is to configure the mock. Some of that configuration " @@ -1851,7 +1851,7 @@ msgstr "" "一些配置可以在對 patch 的呼叫中完成。你傳遞到呼叫中的任何關鍵字都將用於在被建" "立的 mock 上設定屬性: ::" -#: ../../library/unittest.mock.rst:1573 +#: ../../library/unittest.mock.rst:1572 msgid "" ">>> patcher = patch('__main__.thing', first='one', second='two')\n" ">>> mock_thing = patcher.start()\n" @@ -1867,7 +1867,7 @@ msgstr "" ">>> mock_thing.second\n" "'two'" -#: ../../library/unittest.mock.rst:1580 +#: ../../library/unittest.mock.rst:1579 msgid "" "As well as attributes on the created mock attributes, like the :attr:`~Mock." "return_value` and :attr:`~Mock.side_effect`, of child mocks can also be " @@ -1880,7 +1880,7 @@ msgstr "" "數傳入,但是以它們作為鍵的字典仍然可以使用 ``**`` 擴充為一個 :func:`patch` 呼" "叫: ::" -#: ../../library/unittest.mock.rst:1586 +#: ../../library/unittest.mock.rst:1585 msgid "" ">>> config = {'method.return_value': 3, 'other.side_effect': KeyError}\n" ">>> patcher = patch('__main__.thing', **config)\n" @@ -1902,7 +1902,7 @@ msgstr "" " ...\n" "KeyError" -#: ../../library/unittest.mock.rst:1596 +#: ../../library/unittest.mock.rst:1595 msgid "" "By default, attempting to patch a function in a module (or a method or an " "attribute in a class) that does not exist will fail with :exc:" @@ -1911,7 +1911,7 @@ msgstr "" "預設情況下,嘗試 patch 模組中不存在的函式(或類別中的方法或屬性)將會失敗,並" "引發 :exc:`AttributeError`: ::" -#: ../../library/unittest.mock.rst:1599 +#: ../../library/unittest.mock.rst:1598 msgid "" ">>> @patch('sys.non_existing_attribute', 42)\n" "... def test():\n" @@ -1933,7 +1933,7 @@ msgstr "" "AttributeError: does not have the attribute " "'non_existing_attribute'" -#: ../../library/unittest.mock.rst:1608 +#: ../../library/unittest.mock.rst:1607 msgid "" "but adding ``create=True`` in the call to :func:`patch` will make the " "previous example work as expected::" @@ -1941,7 +1941,7 @@ msgstr "" "但是在對 :func:`patch` 的呼叫中增加 ``create=True`` 將使前面的範例按照預期運" "作: ::" -#: ../../library/unittest.mock.rst:1611 +#: ../../library/unittest.mock.rst:1610 msgid "" ">>> @patch('sys.non_existing_attribute', 42, create=True)\n" "... def test(mock_stdout):\n" @@ -1955,18 +1955,18 @@ msgstr "" "...\n" ">>> test()" -#: ../../library/unittest.mock.rst:1619 +#: ../../library/unittest.mock.rst:1618 msgid "" ":func:`patch` now returns an :class:`AsyncMock` if the target is an async " "function." msgstr "" "如果目標是一個非同步函式,:func:`patch` 現在會回傳一個 :class:`AsyncMock`。" -#: ../../library/unittest.mock.rst:1623 +#: ../../library/unittest.mock.rst:1622 msgid "patch.object" msgstr "patch.object" -#: ../../library/unittest.mock.rst:1627 +#: ../../library/unittest.mock.rst:1626 msgid "" "patch the named member (*attribute*) on an object (*target*) with a mock " "object." @@ -1974,7 +1974,7 @@ msgstr "" "使用一個 mock 物件 patch 一個物件(\\ *目標*\\ )上的命名成員(\\ *屬性" "*\\ )。" -#: ../../library/unittest.mock.rst:1630 +#: ../../library/unittest.mock.rst:1629 msgid "" ":func:`patch.object` can be used as a decorator, class decorator or a " "context manager. Arguments *new*, *spec*, *create*, *spec_set*, *autospec* " @@ -1987,7 +1987,7 @@ msgstr "" "`patch` 中的引數具有相同的意義。與 :func:`patch` 一樣,:func:`patch.object` " "接受任意關鍵字引數來配置它所建立的 mock 物件。" -#: ../../library/unittest.mock.rst:1636 +#: ../../library/unittest.mock.rst:1635 msgid "" "When used as a class decorator :func:`patch.object` honours ``patch." "TEST_PREFIX`` for choosing which methods to wrap." @@ -1995,7 +1995,7 @@ msgstr "" "當作為類別裝飾器使用時,:func:`patch.object` 會遵循 ``patch.TEST_PREFIX`` 來" "選擇要包裝的方法。" -#: ../../library/unittest.mock.rst:1639 +#: ../../library/unittest.mock.rst:1638 msgid "" "You can either call :func:`patch.object` with three arguments or two " "arguments. The three argument form takes the object to be patched, the " @@ -2004,7 +2004,7 @@ msgstr "" "你可以使用三個引數或兩個引數來呼叫 :func:`patch.object`。三個引數的形式接受要" "被 patch 的物件、屬性名稱和要替換掉屬性的物件。" -#: ../../library/unittest.mock.rst:1643 +#: ../../library/unittest.mock.rst:1642 msgid "" "When calling with the two argument form you omit the replacement object, and " "a mock is created for you and passed in as an extra argument to the " @@ -2013,7 +2013,7 @@ msgstr "" "當使用兩個引數的形式呼叫時,你會省略要替換的物件,一個 mock 會為你建立並將其" "作為額外的引數傳遞給被裝飾的函式:" -#: ../../library/unittest.mock.rst:1654 +#: ../../library/unittest.mock.rst:1653 msgid "" "*spec*, *create* and the other arguments to :func:`patch.object` have the " "same meaning as they do for :func:`patch`." @@ -2021,11 +2021,11 @@ msgstr "" "*spec*、*create* 和 :func:`patch.object` 的其他引數與在 :func:`patch` 中的引" "數具有相同的意義。" -#: ../../library/unittest.mock.rst:1659 +#: ../../library/unittest.mock.rst:1658 msgid "patch.dict" msgstr "patch.dict" -#: ../../library/unittest.mock.rst:1663 +#: ../../library/unittest.mock.rst:1662 msgid "" "Patch a dictionary, or dictionary like object, and restore the dictionary to " "its original state after the test, where the restored dictionary is a copy " @@ -2034,7 +2034,7 @@ msgstr "" "Patch 字典或類字典的物件,並在測試後將字典回復到其原本的狀態,其中回復的字典" "是測試前字典的複本。" -#: ../../library/unittest.mock.rst:1667 +#: ../../library/unittest.mock.rst:1666 msgid "" "*in_dict* can be a dictionary or a mapping like container. If it is a " "mapping then it must at least support getting, setting and deleting items " @@ -2043,13 +2043,13 @@ msgstr "" "*in_dict* 可以是一個字典或一個類對映的容器。如果它是一個對映,那麼它至少必須" "支援取得、設定、刪除項目以及對鍵的疊代。" -#: ../../library/unittest.mock.rst:1671 +#: ../../library/unittest.mock.rst:1670 msgid "" "*in_dict* can also be a string specifying the name of the dictionary, which " "will then be fetched by importing it." msgstr "*in_dict* 也可以是指定字典名稱的字串,然後透過 import 來取得該字典。" -#: ../../library/unittest.mock.rst:1674 +#: ../../library/unittest.mock.rst:1673 msgid "" "*values* can be a dictionary of values to set in the dictionary. *values* " "can also be an iterable of ``(key, value)`` pairs." @@ -2057,31 +2057,31 @@ msgstr "" "*values* 可以是要設定的值的字典。*values* 也可以是 ``(key, value)`` 對 " "(pairs) 的可疊代物件。" -#: ../../library/unittest.mock.rst:1677 +#: ../../library/unittest.mock.rst:1676 msgid "" "If *clear* is true then the dictionary will be cleared before the new values " "are set." msgstr "如果 *clear* 為 true,則在設定新值之前字典將被清除。" -#: ../../library/unittest.mock.rst:1680 +#: ../../library/unittest.mock.rst:1679 msgid "" ":func:`patch.dict` can also be called with arbitrary keyword arguments to " "set values in the dictionary." msgstr "也可以使用任意關鍵字引數呼叫 :func:`patch.dict` 以在字典中設定值。" -#: ../../library/unittest.mock.rst:1685 +#: ../../library/unittest.mock.rst:1684 msgid "" ":func:`patch.dict` now returns the patched dictionary when used as a context " "manager." msgstr ":func:`patch.dict` 現在在做為情境管理器使用時回傳被 patch 的字典。" -#: ../../library/unittest.mock.rst:1688 +#: ../../library/unittest.mock.rst:1687 msgid "" ":func:`patch.dict` can be used as a context manager, decorator or class " "decorator:" msgstr ":func:`patch.dict` 可以做為情境管理器、裝飾器或類別裝飾器使用:" -#: ../../library/unittest.mock.rst:1699 +#: ../../library/unittest.mock.rst:1698 msgid "" "When used as a class decorator :func:`patch.dict` honours ``patch." "TEST_PREFIX`` (default to ``'test'``) for choosing which methods to wrap:" @@ -2089,7 +2089,7 @@ msgstr "" "當作為類別裝飾器使用時,:func:`patch.dict` 會遵循 ``patch.TEST_PREFIX``\\ " "(預設為 ``'test'``\\ )來選擇要包裝的方法:" -#: ../../library/unittest.mock.rst:1710 +#: ../../library/unittest.mock.rst:1709 msgid "" "If you want to use a different prefix for your test, you can inform the " "patchers of the different prefix by setting ``patch.TEST_PREFIX``. For more " @@ -2099,7 +2099,7 @@ msgstr "" "patcher 使用不同的前綴。請參閱 :ref:`test-prefix` 以得知如何修改前綴的更多內" "容。" -#: ../../library/unittest.mock.rst:1714 +#: ../../library/unittest.mock.rst:1713 msgid "" ":func:`patch.dict` can be used to add members to a dictionary, or simply let " "a test change a dictionary, and ensure the dictionary is restored when the " @@ -2108,13 +2108,13 @@ msgstr "" ":func:`patch.dict` 可用於在字典中新增成員,或單純地讓測試更改字典,並確保在測" "試結束時將字典回復原狀。" -#: ../../library/unittest.mock.rst:1735 +#: ../../library/unittest.mock.rst:1734 msgid "" "Keywords can be used in the :func:`patch.dict` call to set values in the " "dictionary:" msgstr "可以在 :func:`patch.dict` 呼叫中使用關鍵字來設定字典中的值:" -#: ../../library/unittest.mock.rst:1745 +#: ../../library/unittest.mock.rst:1744 msgid "" ":func:`patch.dict` can be used with dictionary like objects that aren't " "actually dictionaries. At the very minimum they must support item getting, " @@ -2129,11 +2129,11 @@ msgstr "" "__delitem__` 以及 :meth:`~container.__iter__` 或 :meth:`~object." "__contains__`。" -#: ../../library/unittest.mock.rst:1775 +#: ../../library/unittest.mock.rst:1774 msgid "patch.multiple" msgstr "patch.multiple" -#: ../../library/unittest.mock.rst:1779 +#: ../../library/unittest.mock.rst:1778 msgid "" "Perform multiple patches in a single call. It takes the object to be patched " "(either as an object or a string to fetch the object by importing) and " @@ -2142,7 +2142,7 @@ msgstr "" "在一次呼叫中執行多個 patch。它接受被 patch 的物件(作為物件或透過 import 取得" "物件的字串)和 patch 的關鍵字引數: ::" -#: ../../library/unittest.mock.rst:1783 +#: ../../library/unittest.mock.rst:1782 msgid "" "with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):\n" " ..." @@ -2150,7 +2150,7 @@ msgstr "" "with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):\n" " ..." -#: ../../library/unittest.mock.rst:1786 +#: ../../library/unittest.mock.rst:1785 msgid "" "Use :data:`DEFAULT` as the value if you want :func:`patch.multiple` to " "create mocks for you. In this case the created mocks are passed into a " @@ -2161,7 +2161,7 @@ msgstr "" "值。在這種情況下,被建立的 mock 會透過關鍵字傳遞到被裝飾的函式中,並且當 :" "func:`patch.multiple` 作為情境管理器時會回傳字典。" -#: ../../library/unittest.mock.rst:1791 +#: ../../library/unittest.mock.rst:1790 msgid "" ":func:`patch.multiple` can be used as a decorator, class decorator or a " "context manager. The arguments *spec*, *spec_set*, *create*, *autospec* and " @@ -2173,7 +2173,7 @@ msgstr "" "`patch` 中的引數具有相同的意義。這些引數將應用於由 :func:`patch.multiple` 完" "成的\\ *所有* patch。" -#: ../../library/unittest.mock.rst:1796 +#: ../../library/unittest.mock.rst:1795 msgid "" "When used as a class decorator :func:`patch.multiple` honours ``patch." "TEST_PREFIX`` for choosing which methods to wrap." @@ -2181,7 +2181,7 @@ msgstr "" "當作為類別裝飾器使用時,:func:`patch.multiple` 遵循 ``patch.TEST_PREFIX`` 來" "選擇要包裝的方法。" -#: ../../library/unittest.mock.rst:1799 +#: ../../library/unittest.mock.rst:1798 msgid "" "If you want :func:`patch.multiple` to create mocks for you, then you can " "use :data:`DEFAULT` as the value. If you use :func:`patch.multiple` as a " @@ -2192,7 +2192,7 @@ msgstr "" "`DEFAULT` 作為值。如果你使用 :func:`patch.multiple` 作為裝飾器,那麼被建立的 " "mock 將透過關鍵字傳遞到被裝飾的函式中。: ::" -#: ../../library/unittest.mock.rst:1803 +#: ../../library/unittest.mock.rst:1802 msgid "" ">>> thing = object()\n" ">>> other = object()\n" @@ -2214,7 +2214,7 @@ msgstr "" "...\n" ">>> test_function()" -#: ../../library/unittest.mock.rst:1813 +#: ../../library/unittest.mock.rst:1812 msgid "" ":func:`patch.multiple` can be nested with other ``patch`` decorators, but " "put arguments passed by keyword *after* any of the standard arguments " @@ -2223,7 +2223,7 @@ msgstr "" ":func:`patch.multiple` 可以與其他 ``patch`` 裝飾器巢狀使用,但需要將透過關鍵" "字傳遞的引數放在 :func:`patch` 建立的任何標準引數\\ *之後*: ::" -#: ../../library/unittest.mock.rst:1816 +#: ../../library/unittest.mock.rst:1815 msgid "" ">>> @patch('sys.exit')\n" "... @patch.multiple('__main__', thing=DEFAULT, other=DEFAULT)\n" @@ -2243,7 +2243,7 @@ msgstr "" "...\n" ">>> test_function()" -#: ../../library/unittest.mock.rst:1825 +#: ../../library/unittest.mock.rst:1824 msgid "" "If :func:`patch.multiple` is used as a context manager, the value returned " "by the context manager is a dictionary where created mocks are keyed by " @@ -2252,7 +2252,7 @@ msgstr "" "如果 :func:`patch.multiple` 作為情境管理器使用,則情境管理器回傳的值是一個字" "典,其中被建立的 mock 會按名稱作為其鍵值: ::" -#: ../../library/unittest.mock.rst:1828 +#: ../../library/unittest.mock.rst:1827 msgid "" ">>> with patch.multiple('__main__', thing=DEFAULT, other=DEFAULT) as " "values:\n" @@ -2270,11 +2270,11 @@ msgstr "" "... assert values['other'] is other\n" "..." -#: ../../library/unittest.mock.rst:1839 +#: ../../library/unittest.mock.rst:1838 msgid "patch methods: start and stop" msgstr "patch 方法:啟動與停止" -#: ../../library/unittest.mock.rst:1841 +#: ../../library/unittest.mock.rst:1840 msgid "" "All the patchers have :meth:`!start` and :meth:`!stop` methods. These make " "it simpler to do patching in ``setUp`` methods or where you want to do " @@ -2284,7 +2284,7 @@ msgstr "" "方法中進行 patch 或在你想要在沒有巢狀使用裝飾器或 with 陳述式的情況下進行多" "個 patch 時變得更簡單。" -#: ../../library/unittest.mock.rst:1845 +#: ../../library/unittest.mock.rst:1844 msgid "" "To use them call :func:`patch`, :func:`patch.object` or :func:`patch.dict` " "as normal and keep a reference to the returned ``patcher`` object. You can " @@ -2295,7 +2295,7 @@ msgstr "" "`patch.dict` ,並保留對回傳的 ``patcher`` 物件的參照。之後你就可以呼叫 :meth:" "`!start` 將 patch 準備就緒,並呼叫 :meth:`!stop` 來取消 patch。" -#: ../../library/unittest.mock.rst:1849 +#: ../../library/unittest.mock.rst:1848 msgid "" "If you are using :func:`patch` to create a mock for you then it will be " "returned by the call to ``patcher.start``. ::" @@ -2303,7 +2303,7 @@ msgstr "" "如果你使用 :func:`patch` 為你建立 mock,那麼它將透過呼叫 ``patcher.start`` 回" "傳。: ::" -#: ../../library/unittest.mock.rst:1852 +#: ../../library/unittest.mock.rst:1851 msgid "" ">>> patcher = patch('package.module.ClassName')\n" ">>> from package import module\n" @@ -2325,7 +2325,7 @@ msgstr "" ">>> assert module.ClassName is original\n" ">>> assert module.ClassName is not new_mock" -#: ../../library/unittest.mock.rst:1863 +#: ../../library/unittest.mock.rst:1862 msgid "" "A typical use case for this might be for doing multiple patches in the " "``setUp`` method of a :class:`~unittest.TestCase`::" @@ -2333,7 +2333,7 @@ msgstr "" "一個典型的用法是在一個 :class:`~unittest.TestCase` 的 ``setUp`` 方法中執行多" "個 patch: ::" -#: ../../library/unittest.mock.rst:1866 +#: ../../library/unittest.mock.rst:1865 msgid "" ">>> class MyTest(unittest.TestCase):\n" "... def setUp(self):\n" @@ -2369,7 +2369,7 @@ msgstr "" "...\n" ">>> MyTest('test_something').run()" -#: ../../library/unittest.mock.rst:1885 +#: ../../library/unittest.mock.rst:1884 msgid "" "If you use this technique you must ensure that the patching is \"undone\" by " "calling ``stop``. This can be fiddlier than you might think, because if an " @@ -2380,7 +2380,7 @@ msgstr "" "你想像的還要複雜一點,因為如果有例外在 ``setUp`` 中被引發,則 ``tearDown`` 就" "不會被呼叫。:meth:`unittest.TestCase.addCleanup` 會讓這稍微簡單一點: ::" -#: ../../library/unittest.mock.rst:1890 +#: ../../library/unittest.mock.rst:1889 msgid "" ">>> class MyTest(unittest.TestCase):\n" "... def setUp(self):\n" @@ -2402,34 +2402,34 @@ msgstr "" "... assert package.module.Class is self.MockClass\n" "..." -#: ../../library/unittest.mock.rst:1900 +#: ../../library/unittest.mock.rst:1899 msgid "" "As an added bonus you no longer need to keep a reference to the ``patcher`` " "object." msgstr "作為額外的好處,你不再需要保留對 ``patcher`` 物件的參照。" -#: ../../library/unittest.mock.rst:1903 +#: ../../library/unittest.mock.rst:1902 msgid "" "It is also possible to stop all patches which have been started by using :" "func:`patch.stopall`." msgstr "也可以使用 :func:`patch.stopall` 來停止所有已啟動的 patch。" -#: ../../library/unittest.mock.rst:1908 +#: ../../library/unittest.mock.rst:1907 msgid "Stop all active patches. Only stops patches started with ``start``." msgstr "停止所有運作的 patch。只停止以 ``start`` 啟動的 patch。" -#: ../../library/unittest.mock.rst:1914 +#: ../../library/unittest.mock.rst:1913 msgid "patch builtins" msgstr "patch 內建函式" -#: ../../library/unittest.mock.rst:1915 +#: ../../library/unittest.mock.rst:1914 msgid "" "You can patch any builtins within a module. The following example patches " "builtin :func:`ord`::" msgstr "" "你可以 patch 模組內的任何內建函式。以下範例 patch 內建函式 :func:`ord`: ::" -#: ../../library/unittest.mock.rst:1918 +#: ../../library/unittest.mock.rst:1917 msgid "" ">>> @patch('__main__.ord')\n" "... def test(mock_ord):\n" @@ -2447,11 +2447,11 @@ msgstr "" ">>> test()\n" "101" -#: ../../library/unittest.mock.rst:1930 +#: ../../library/unittest.mock.rst:1929 msgid "TEST_PREFIX" msgstr "TEST_PREFIX" -#: ../../library/unittest.mock.rst:1932 +#: ../../library/unittest.mock.rst:1931 msgid "" "All of the patchers can be used as class decorators. When used in this way " "they wrap every test method on the class. The patchers recognise methods " @@ -2462,7 +2462,7 @@ msgstr "" "個測試方法。Patcher 將 ``'test'`` 開頭的方法認定為測試方法。這與 :class:" "`unittest.TestLoader` 預設尋找測試方法的方式相同。" -#: ../../library/unittest.mock.rst:1937 +#: ../../library/unittest.mock.rst:1936 msgid "" "It is possible that you want to use a different prefix for your tests. You " "can inform the patchers of the different prefix by setting ``patch." @@ -2471,7 +2471,7 @@ msgstr "" "你可能會想為你的測試使用不同的前綴。你可以透過設定 ``patch.TEST_PREFIX`` 來告" "知 patcher 使用不同的前綴: ::" -#: ../../library/unittest.mock.rst:1940 +#: ../../library/unittest.mock.rst:1939 msgid "" ">>> patch.TEST_PREFIX = 'foo'\n" ">>> value = 3\n" @@ -2509,21 +2509,21 @@ msgstr "" ">>> value\n" "3" -#: ../../library/unittest.mock.rst:1960 +#: ../../library/unittest.mock.rst:1959 msgid "Nesting Patch Decorators" msgstr "巢狀使用 Patch 裝飾器" -#: ../../library/unittest.mock.rst:1962 +#: ../../library/unittest.mock.rst:1961 msgid "" "If you want to perform multiple patches then you can simply stack up the " "decorators." msgstr "如果你想執行多個 patch,那麼你可以簡單地堆疊裝飾器。" -#: ../../library/unittest.mock.rst:1965 +#: ../../library/unittest.mock.rst:1964 msgid "You can stack up multiple patch decorators using this pattern:" msgstr "你可以使用這個模式來堆疊多個 patch 裝飾器:" -#: ../../library/unittest.mock.rst:1981 +#: ../../library/unittest.mock.rst:1980 msgid "" "Note that the decorators are applied from the bottom upwards. This is the " "standard way that Python applies decorators. The order of the created mocks " @@ -2532,11 +2532,11 @@ msgstr "" "請注意,裝飾器是從底部向上應用的。這是 Python 應用裝飾器的標準方式。被建立的 " "mock 傳遞到測試函式中的順序與此順序相同。" -#: ../../library/unittest.mock.rst:1989 +#: ../../library/unittest.mock.rst:1988 msgid "Where to patch" msgstr "該 patch 何處" -#: ../../library/unittest.mock.rst:1991 +#: ../../library/unittest.mock.rst:1990 msgid "" ":func:`patch` works by (temporarily) changing the object that a *name* " "points to with another one. There can be many names pointing to any " @@ -2547,7 +2547,7 @@ msgstr "" "有許多 name 指向任何單一物件,因此為了使 patch 起作用,你必須確保你 patch 了" "被測試系統使用的 name。" -#: ../../library/unittest.mock.rst:1996 +#: ../../library/unittest.mock.rst:1995 msgid "" "The basic principle is that you patch where an object is *looked up*, which " "is not necessarily the same place as where it is defined. A couple of " @@ -2556,12 +2556,12 @@ msgstr "" "基本原則是在物件\\ *被查找*\\ 的位置進行 patch,該位置不一定與其被定義的位置" "相同。幾個範例將有助於闡明這一點。" -#: ../../library/unittest.mock.rst:2000 +#: ../../library/unittest.mock.rst:1999 msgid "" "Imagine we have a project that we want to test with the following structure::" msgstr "想像一下,我們想要測試一個專案,其結構如下: ::" -#: ../../library/unittest.mock.rst:2002 +#: ../../library/unittest.mock.rst:2001 msgid "" "a.py\n" " -> Defines SomeClass\n" @@ -2577,7 +2577,7 @@ msgstr "" " -> from a import SomeClass\n" " -> some_function instantiates SomeClass" -#: ../../library/unittest.mock.rst:2009 +#: ../../library/unittest.mock.rst:2008 msgid "" "Now we want to test ``some_function`` but we want to mock out ``SomeClass`` " "using :func:`patch`. The problem is that when we import module b, which we " @@ -2592,7 +2592,7 @@ msgstr "" "那麼它對我們的測試就不會有任何影響;模組 b 已經有了一個\\ *真實的*\\ " "``SomeClass`` 的參照 ,看起來我們的 patch 並沒有任何效果。" -#: ../../library/unittest.mock.rst:2016 +#: ../../library/unittest.mock.rst:2015 msgid "" "The key is to patch out ``SomeClass`` where it is used (or where it is " "looked up). In this case ``some_function`` will actually look up " @@ -2603,11 +2603,11 @@ msgstr "" "``some_function`` 實際上會在我們 import 它的模組 b 中查找 ``SomeClass``。這裡" "的 patch 應該長得像這樣: ::" -#: ../../library/unittest.mock.rst:2020 +#: ../../library/unittest.mock.rst:2019 msgid "@patch('b.SomeClass')" msgstr "@patch('b.SomeClass')" -#: ../../library/unittest.mock.rst:2022 +#: ../../library/unittest.mock.rst:2021 msgid "" "However, consider the alternative scenario where instead of ``from a import " "SomeClass`` module b does ``import a`` and ``some_function`` uses ``a." @@ -2620,15 +2620,15 @@ msgstr "" "形式都很常見。在這種情況下,我們想要 patch 的類別正在其模組中被查找,因此我們" "必須 patch ``a.SomeClass``: ::" -#: ../../library/unittest.mock.rst:2027 +#: ../../library/unittest.mock.rst:2026 msgid "@patch('a.SomeClass')" msgstr "@patch('a.SomeClass')" -#: ../../library/unittest.mock.rst:2031 +#: ../../library/unittest.mock.rst:2030 msgid "Patching Descriptors and Proxy Objects" msgstr "Patch 描述器與代理物件 (Proxy Objects)" -#: ../../library/unittest.mock.rst:2033 +#: ../../library/unittest.mock.rst:2032 msgid "" "Both patch_ and patch.object_ correctly patch and restore descriptors: class " "methods, static methods and properties. You should patch these on the " @@ -2643,15 +2643,15 @@ msgstr "" "web/20200603181648/http://www.voidspace.org.uk/python/weblog/ " "arch_d7_2010_12_04.shtml#e1198>`_。" -#: ../../library/unittest.mock.rst:2041 +#: ../../library/unittest.mock.rst:2040 msgid "MagicMock and magic method support" msgstr "MagicMock 以及魔術方法支援" -#: ../../library/unittest.mock.rst:2046 +#: ../../library/unittest.mock.rst:2045 msgid "Mocking Magic Methods" msgstr "Mock 魔術方法" -#: ../../library/unittest.mock.rst:2048 +#: ../../library/unittest.mock.rst:2047 msgid "" ":class:`Mock` supports mocking the Python protocol methods, also known as :" "term:`\"magic methods\" `. This allows mock objects to replace " @@ -2660,7 +2660,7 @@ msgstr "" ":class:`Mock` 支援 mock Python 協定方法,其也被稱作 :term:`\"魔術方法\" " "`。這允許 mock 物件替換容器或實作 Python 協定的其他物件。" -#: ../../library/unittest.mock.rst:2052 +#: ../../library/unittest.mock.rst:2051 msgid "" "Because magic methods are looked up differently from normal methods [#]_, " "this support has been specially implemented. This means that only specific " @@ -2671,7 +2671,7 @@ msgstr "" "代表著僅有特定的魔術方法被此方式支援。現在已支援清單中已經\\ *幾乎*\\ 包含了" "所有魔術方法。如果你需要 mock 任何魔術方法而其尚未被支援,請讓我們知道。" -#: ../../library/unittest.mock.rst:2057 +#: ../../library/unittest.mock.rst:2056 msgid "" "You mock magic methods by setting the method you are interested in to a " "function or a mock instance. If you are using a function then it *must* take " @@ -2680,13 +2680,13 @@ msgstr "" "你可以透過將你感興趣的方法設定為函式或 mock 實例來 mock 魔術方法。如果你使用" "函式,那麼它\\ *必須*\\ 將 ``self`` 作為第一個引數 [#]_。" -#: ../../library/unittest.mock.rst:2080 +#: ../../library/unittest.mock.rst:2079 msgid "" "One use case for this is for mocking objects used as context managers in a :" "keyword:`with` statement:" msgstr "一個用法是在 :keyword:`with` 陳述式中 mock 作為情境管理器使用的物件:" -#: ../../library/unittest.mock.rst:2092 +#: ../../library/unittest.mock.rst:2091 msgid "" "Calls to magic methods do not appear in :attr:`~Mock.method_calls`, but they " "are recorded in :attr:`~Mock.mock_calls`." @@ -2694,7 +2694,7 @@ msgstr "" "對魔術方法的呼叫並不會出現在 :attr:`~Mock.method_calls` 中,它們會被記錄在 :" "attr:`~Mock.mock_calls` 內。" -#: ../../library/unittest.mock.rst:2097 +#: ../../library/unittest.mock.rst:2096 msgid "" "If you use the *spec* keyword argument to create a mock then attempting to " "set a magic method that isn't in the spec will raise an :exc:" @@ -2703,23 +2703,23 @@ msgstr "" "如果你使用\\ *spec*\\ 關鍵字引數來建立一個 mock,則嘗試設定規格中未包含的魔術" "方法將引發一個 :exc:`AttributeError`。" -#: ../../library/unittest.mock.rst:2100 +#: ../../library/unittest.mock.rst:2099 msgid "The full list of supported magic methods is:" msgstr "已支援的魔術方法的完整列表是:" -#: ../../library/unittest.mock.rst:2102 +#: ../../library/unittest.mock.rst:2101 msgid "``__hash__``, ``__sizeof__``, ``__repr__`` and ``__str__``" msgstr "``__hash__``、``__sizeof__``、 ``__repr__`` 和 ``__str__``" -#: ../../library/unittest.mock.rst:2103 +#: ../../library/unittest.mock.rst:2102 msgid "``__dir__``, ``__format__`` and ``__subclasses__``" msgstr "``__dir__``、 ``__format__`` 和 ``__subclasses__``" -#: ../../library/unittest.mock.rst:2104 +#: ../../library/unittest.mock.rst:2103 msgid "``__round__``, ``__floor__``, ``__trunc__`` and ``__ceil__``" msgstr "``__round__``、``__floor__``、``__trunc__`` 和 ``__ceil__``" -#: ../../library/unittest.mock.rst:2105 +#: ../../library/unittest.mock.rst:2104 msgid "" "Comparisons: ``__lt__``, ``__gt__``, ``__le__``, ``__ge__``, ``__eq__`` and " "``__ne__``" @@ -2727,7 +2727,7 @@ msgstr "" "比較方法:``__lt__``、``__gt__``、``__le__``、``__ge__``、``__eq__`` 和 " "``__ne__``" -#: ../../library/unittest.mock.rst:2107 +#: ../../library/unittest.mock.rst:2106 msgid "" "Container methods: ``__getitem__``, ``__setitem__``, ``__delitem__``, " "``__contains__``, ``__len__``, ``__iter__``, ``__reversed__`` and " @@ -2737,18 +2737,18 @@ msgstr "" "``__contains__``、``__len__``、``__iter__``、``__reversed__`` 和 " "``__missing__``" -#: ../../library/unittest.mock.rst:2110 +#: ../../library/unittest.mock.rst:2109 msgid "" "Context manager: ``__enter__``, ``__exit__``, ``__aenter__`` and " "``__aexit__``" msgstr "" "情境管理器:``__enter__``、``__exit__``、``__aenter__`` 和 ``__aexit__``" -#: ../../library/unittest.mock.rst:2111 +#: ../../library/unittest.mock.rst:2110 msgid "Unary numeric methods: ``__neg__``, ``__pos__`` and ``__invert__``" msgstr "一元數值方法:``__neg__``、``__pos__`` 和 ``__invert__``" -#: ../../library/unittest.mock.rst:2112 +#: ../../library/unittest.mock.rst:2111 msgid "" "The numeric methods (including right hand and in-place variants): " "``__add__``, ``__sub__``, ``__mul__``, ``__matmul__``, ``__truediv__``, " @@ -2760,18 +2760,18 @@ msgstr "" "``__mod__``、``__divmod__``、``__lshift__``、``__rshift__``、``__and__``、" "``__xor__``、``__or__`` 和 ``__pow__``" -#: ../../library/unittest.mock.rst:2116 +#: ../../library/unittest.mock.rst:2115 msgid "" "Numeric conversion methods: ``__complex__``, ``__int__``, ``__float__`` and " "``__index__``" msgstr "" "數值轉換方法:``__complex__``、``__int__``、``__float__`` 和 ``__index__``" -#: ../../library/unittest.mock.rst:2118 +#: ../../library/unittest.mock.rst:2117 msgid "Descriptor methods: ``__get__``, ``__set__`` and ``__delete__``" msgstr "描述器方法:``__get__``、``__set__`` 和 ``__delete__``" -#: ../../library/unittest.mock.rst:2119 +#: ../../library/unittest.mock.rst:2118 msgid "" "Pickling: ``__reduce__``, ``__reduce_ex__``, ``__getinitargs__``, " "``__getnewargs__``, ``__getstate__`` and ``__setstate__``" @@ -2779,19 +2779,19 @@ msgstr "" "Pickling:``__reduce__``、``__reduce_ex__``、``__getinitargs__``、" "``__getnewargs__``、``__getstate__`` 和 ``__setstate__``" -#: ../../library/unittest.mock.rst:2121 +#: ../../library/unittest.mock.rst:2120 msgid "File system path representation: ``__fspath__``" msgstr "檔案系統路徑表示法:``__fspath__``" -#: ../../library/unittest.mock.rst:2122 +#: ../../library/unittest.mock.rst:2121 msgid "Asynchronous iteration methods: ``__aiter__`` and ``__anext__``" msgstr "非同步疊代方法:``__aiter__`` 和 ``__anext__``" -#: ../../library/unittest.mock.rst:2124 +#: ../../library/unittest.mock.rst:2123 msgid "Added support for :func:`os.PathLike.__fspath__`." msgstr "新增對於 :func:`os.PathLike.__fspath__` 的支援。" -#: ../../library/unittest.mock.rst:2127 +#: ../../library/unittest.mock.rst:2126 msgid "" "Added support for ``__aenter__``, ``__aexit__``, ``__aiter__`` and " "``__anext__``." @@ -2799,7 +2799,7 @@ msgstr "" "新增對於 ``__aenter__``、``__aexit__``、``__aiter__`` 和 ``__anext__`` 的支" "援。" -#: ../../library/unittest.mock.rst:2131 +#: ../../library/unittest.mock.rst:2130 msgid "" "The following methods exist but are *not* supported as they are either in " "use by mock, can't be set dynamically, or can cause problems:" @@ -2807,21 +2807,21 @@ msgstr "" "以下方法存在,但「不」被支援,因為它們在被 mock 使用時,會無法動態設定,或可" "能導致問題:" -#: ../../library/unittest.mock.rst:2134 +#: ../../library/unittest.mock.rst:2133 msgid "``__getattr__``, ``__setattr__``, ``__init__`` and ``__new__``" msgstr "``__getattr__``、``__setattr__``、``__init__`` 和 ``__new__``" -#: ../../library/unittest.mock.rst:2135 +#: ../../library/unittest.mock.rst:2134 msgid "" "``__prepare__``, ``__instancecheck__``, ``__subclasscheck__``, ``__del__``" msgstr "" "``__prepare__``、``__instancecheck__``、``__subclasscheck__``、``__del__``" -#: ../../library/unittest.mock.rst:2140 +#: ../../library/unittest.mock.rst:2139 msgid "Magic Mock" msgstr "Magic Mock" -#: ../../library/unittest.mock.rst:2142 +#: ../../library/unittest.mock.rst:2141 msgid "" "There are two ``MagicMock`` variants: :class:`MagicMock` and :class:" "`NonCallableMagicMock`." @@ -2829,7 +2829,7 @@ msgstr "" "``MagicMock`` 有兩個變體::class:`MagicMock` 和 :class:" "`NonCallableMagicMock`。" -#: ../../library/unittest.mock.rst:2147 +#: ../../library/unittest.mock.rst:2146 msgid "" "``MagicMock`` is a subclass of :class:`Mock` with default implementations of " "most of the :term:`magic methods `. You can use ``MagicMock`` " @@ -2838,11 +2838,11 @@ msgstr "" "``MagicMock`` 是 :class:`Mock` 的子類別,其預設具有大多數\\ :term:`魔術方法 " "`\\ 的實作。你可以使用 ``MagicMock``,而無需自行配置魔術方法。" -#: ../../library/unittest.mock.rst:2151 +#: ../../library/unittest.mock.rst:2150 msgid "The constructor parameters have the same meaning as for :class:`Mock`." msgstr "建構函式參數的意義與 :class:`Mock` 中的參數相同。" -#: ../../library/unittest.mock.rst:2153 +#: ../../library/unittest.mock.rst:2152 msgid "" "If you use the *spec* or *spec_set* arguments then *only* magic methods that " "exist in the spec will be created." @@ -2850,11 +2850,11 @@ msgstr "" "如果你使用 *spec* 或 *spec_set* 引數,那麼\\ *只有*\\ 規格中存在的魔術方法會" "被建立。" -#: ../../library/unittest.mock.rst:2159 +#: ../../library/unittest.mock.rst:2158 msgid "A non-callable version of :class:`MagicMock`." msgstr ":class:`MagicMock` 的不可呼叫版本。" -#: ../../library/unittest.mock.rst:2161 +#: ../../library/unittest.mock.rst:2160 msgid "" "The constructor parameters have the same meaning as for :class:`MagicMock`, " "with the exception of *return_value* and *side_effect* which have no meaning " @@ -2863,7 +2863,7 @@ msgstr "" "建構函式參數的意義與 :class:`MagicMock` 中的參數相同,但 *return_value* 和 " "*side_effect* 除外,它們對不可呼叫的 mock 來說沒有任何意義。" -#: ../../library/unittest.mock.rst:2165 +#: ../../library/unittest.mock.rst:2164 msgid "" "The magic methods are setup with :class:`MagicMock` objects, so you can " "configure them and use them in the usual way:" @@ -2871,7 +2871,7 @@ msgstr "" "魔術方法是使用 :class:`MagicMock` 物件設定的,因此你可以配置它們並以一般的方" "法來使用它們:" -#: ../../library/unittest.mock.rst:2175 +#: ../../library/unittest.mock.rst:2174 msgid "" "By default many of the protocol methods are required to return objects of a " "specific type. These methods are preconfigured with a default return value, " @@ -2883,83 +2883,83 @@ msgstr "" "值,因此如果你對回傳值不感興趣,則無需執行任何操作即可使用它們。如果你想更改" "預設值,你仍然可以手動\\ *設定*\\ 回傳值。" -#: ../../library/unittest.mock.rst:2181 +#: ../../library/unittest.mock.rst:2180 msgid "Methods and their defaults:" msgstr "方法及其預設值:" -#: ../../library/unittest.mock.rst:2183 +#: ../../library/unittest.mock.rst:2182 msgid "``__lt__``: :data:`NotImplemented`" msgstr "``__lt__``::data:`NotImplemented`" -#: ../../library/unittest.mock.rst:2184 +#: ../../library/unittest.mock.rst:2183 msgid "``__gt__``: :data:`!NotImplemented`" msgstr "``__gt__``::data:`!NotImplemented`" -#: ../../library/unittest.mock.rst:2185 +#: ../../library/unittest.mock.rst:2184 msgid "``__le__``: :data:`!NotImplemented`" msgstr "``__le__``::data:`!NotImplemented`" -#: ../../library/unittest.mock.rst:2186 +#: ../../library/unittest.mock.rst:2185 msgid "``__ge__``: :data:`!NotImplemented`" msgstr "``__ge__``::data:`!NotImplemented`" -#: ../../library/unittest.mock.rst:2187 +#: ../../library/unittest.mock.rst:2186 msgid "``__int__``: ``1``" msgstr "``__int__``:``1``" -#: ../../library/unittest.mock.rst:2188 +#: ../../library/unittest.mock.rst:2187 msgid "``__contains__``: ``False``" msgstr "``__contains__``:``False``" -#: ../../library/unittest.mock.rst:2189 +#: ../../library/unittest.mock.rst:2188 msgid "``__len__``: ``0``" msgstr "``__len__``:``0``" -#: ../../library/unittest.mock.rst:2190 +#: ../../library/unittest.mock.rst:2189 msgid "``__iter__``: ``iter([])``" msgstr "``__iter__``:``iter([])``" -#: ../../library/unittest.mock.rst:2191 +#: ../../library/unittest.mock.rst:2190 msgid "``__exit__``: ``False``" msgstr "``__exit__``:``False``" -#: ../../library/unittest.mock.rst:2192 +#: ../../library/unittest.mock.rst:2191 msgid "``__aexit__``: ``False``" msgstr "``__aexit__``:``False``" -#: ../../library/unittest.mock.rst:2193 +#: ../../library/unittest.mock.rst:2192 msgid "``__complex__``: ``1j``" msgstr "``__complex__``:``1j``" -#: ../../library/unittest.mock.rst:2194 +#: ../../library/unittest.mock.rst:2193 msgid "``__float__``: ``1.0``" msgstr "``__float__``:``1.0``" -#: ../../library/unittest.mock.rst:2195 +#: ../../library/unittest.mock.rst:2194 msgid "``__bool__``: ``True``" msgstr "``__bool__``:``True``" -#: ../../library/unittest.mock.rst:2196 +#: ../../library/unittest.mock.rst:2195 msgid "``__index__``: ``1``" msgstr "``__index__``:``1``" -#: ../../library/unittest.mock.rst:2197 +#: ../../library/unittest.mock.rst:2196 msgid "``__hash__``: default hash for the mock" msgstr "``__hash__``:mock 的預設雜湊" -#: ../../library/unittest.mock.rst:2198 +#: ../../library/unittest.mock.rst:2197 msgid "``__str__``: default str for the mock" msgstr "``__str__``:mock 的預設字串" -#: ../../library/unittest.mock.rst:2199 +#: ../../library/unittest.mock.rst:2198 msgid "``__sizeof__``: default sizeof for the mock" msgstr "``__sizeof__``:mock 的預設 sizeof" -#: ../../library/unittest.mock.rst:2201 +#: ../../library/unittest.mock.rst:2200 msgid "For example:" msgstr "舉例來說:" -#: ../../library/unittest.mock.rst:2213 +#: ../../library/unittest.mock.rst:2212 msgid "" "The two equality methods, :meth:`!__eq__` and :meth:`!__ne__`, are special. " "They do the default equality comparison on identity, using the :attr:`~Mock." @@ -2970,7 +2970,7 @@ msgstr "" "`~Mock.side_effect` 屬性對識別性 (identity) 進行預設的相等比較,除非你變更它" "們的回傳值以回傳其他內容: ::" -#: ../../library/unittest.mock.rst:2218 +#: ../../library/unittest.mock.rst:2217 msgid "" ">>> MagicMock() == 3\n" "False\n" @@ -2990,13 +2990,13 @@ msgstr "" ">>> mock == 3\n" "True" -#: ../../library/unittest.mock.rst:2227 +#: ../../library/unittest.mock.rst:2226 msgid "" "The return value of :meth:`!__iter__` can be any iterable object and isn't " "required to be an iterator:" msgstr ":meth:`!__iter__` 的回傳值可以是任何可疊代物件,且不需是一個疊代器:" -#: ../../library/unittest.mock.rst:2237 +#: ../../library/unittest.mock.rst:2236 msgid "" "If the return value *is* an iterator, then iterating over it once will " "consume it and subsequent iterations will result in an empty list:" @@ -3004,7 +3004,7 @@ msgstr "" "如果回傳值\\ *是*\\ 一個疊代器,那麼對其進行一次疊代將消耗它,並且後續疊代將" "產生一個空串列:" -#: ../../library/unittest.mock.rst:2246 +#: ../../library/unittest.mock.rst:2245 msgid "" "``MagicMock`` has all of the supported magic methods configured except for " "some of the obscure and obsolete ones. You can still set these up if you " @@ -3013,33 +3013,33 @@ msgstr "" "``MagicMock`` 配置了所有支援的魔術方法,除了一些少見和過時的方法。如果你想" "要,你仍然可以設定這些魔術方法。" -#: ../../library/unittest.mock.rst:2249 +#: ../../library/unittest.mock.rst:2248 msgid "" "Magic methods that are supported but not setup by default in ``MagicMock`` " "are:" msgstr "``MagicMock`` 中支援但預設未設置的魔術方法包含:" -#: ../../library/unittest.mock.rst:2251 +#: ../../library/unittest.mock.rst:2250 msgid "``__subclasses__``" msgstr "``__subclasses__``" -#: ../../library/unittest.mock.rst:2252 +#: ../../library/unittest.mock.rst:2251 msgid "``__dir__``" msgstr "``__dir__``" -#: ../../library/unittest.mock.rst:2253 +#: ../../library/unittest.mock.rst:2252 msgid "``__format__``" msgstr "``__format__``" -#: ../../library/unittest.mock.rst:2254 +#: ../../library/unittest.mock.rst:2253 msgid "``__get__``, ``__set__`` and ``__delete__``" msgstr "``__get__``、``__set__`` 和 ``__delete__``" -#: ../../library/unittest.mock.rst:2255 +#: ../../library/unittest.mock.rst:2254 msgid "``__reversed__`` and ``__missing__``" msgstr "``__reversed__`` 和 ``__missing__``" -#: ../../library/unittest.mock.rst:2256 +#: ../../library/unittest.mock.rst:2255 msgid "" "``__reduce__``, ``__reduce_ex__``, ``__getinitargs__``, ``__getnewargs__``, " "``__getstate__`` and ``__setstate__``" @@ -3047,11 +3047,11 @@ msgstr "" "``__reduce__``、``__reduce_ex__``、``__getinitargs__``、``__getnewargs__``、" "``__getstate__`` 和 ``__setstate__``" -#: ../../library/unittest.mock.rst:2258 +#: ../../library/unittest.mock.rst:2257 msgid "``__getformat__``" msgstr "``__getformat__``" -#: ../../library/unittest.mock.rst:2262 +#: ../../library/unittest.mock.rst:2261 msgid "" "Magic methods *should* be looked up on the class rather than the instance. " "Different versions of Python are inconsistent about applying this rule. The " @@ -3060,27 +3060,27 @@ msgstr "" "魔術方法\\ *應該*\\ 在類別而不是實例上被查找。不同版本的 Python 對於這條規則" "的適用並不一致。支援的協定方法應適用於所有支援的 Python 版本。" -#: ../../library/unittest.mock.rst:2266 +#: ../../library/unittest.mock.rst:2265 msgid "" "The function is basically hooked up to the class, but each ``Mock`` instance " "is kept isolated from the others." msgstr "該函式基本上與類別掛鉤,但每個 ``Mock`` 實例都與其他實例保持隔離。" -#: ../../library/unittest.mock.rst:2271 +#: ../../library/unittest.mock.rst:2270 msgid "Helpers" msgstr "輔助函式" -#: ../../library/unittest.mock.rst:2274 +#: ../../library/unittest.mock.rst:2273 msgid "sentinel" msgstr "sentinel(哨兵)" -#: ../../library/unittest.mock.rst:2278 +#: ../../library/unittest.mock.rst:2277 msgid "" "The ``sentinel`` object provides a convenient way of providing unique " "objects for your tests." msgstr "``哨兵``\\ 物件提供了一種為你的測試提供獨特物件的便利方式。" -#: ../../library/unittest.mock.rst:2281 +#: ../../library/unittest.mock.rst:2280 msgid "" "Attributes are created on demand when you access them by name. Accessing the " "same attribute will always return the same object. The objects returned have " @@ -3089,7 +3089,7 @@ msgstr "" "當你使用名稱存取屬性時,屬性會根據需要被建立。存取相同的屬性將始終回傳相同的" "物件。回傳的物件會具有合適的 repr,讓測試失敗的訊息是可閱讀的。" -#: ../../library/unittest.mock.rst:2285 +#: ../../library/unittest.mock.rst:2284 msgid "" "The ``sentinel`` attributes now preserve their identity when they are :mod:" "`copied ` or :mod:`pickled `." @@ -3097,7 +3097,7 @@ msgstr "" "``哨兵``\\ 屬性現在當被\\ :mod:`複製 `\\ 或\\ :mod:`序列化 `\\ " "時會保留其識別性。" -#: ../../library/unittest.mock.rst:2289 +#: ../../library/unittest.mock.rst:2288 msgid "" "Sometimes when testing you need to test that a specific object is passed as " "an argument to another method, or returned. It can be common to create named " @@ -3108,18 +3108,18 @@ msgstr "" "名的哨兵物件來測試這一點是常見的。:data:`sentinel` 提供了一種此類建立和測試物" "件識別性的便利方式。" -#: ../../library/unittest.mock.rst:2294 +#: ../../library/unittest.mock.rst:2293 msgid "" "In this example we monkey patch ``method`` to return ``sentinel." "some_object``:" msgstr "" "在這個例子中,我們 monkey patch ``method`` 以回傳 ``sentinel.some_object``:" -#: ../../library/unittest.mock.rst:2306 +#: ../../library/unittest.mock.rst:2305 msgid "DEFAULT" msgstr "DEFAULT" -#: ../../library/unittest.mock.rst:2311 +#: ../../library/unittest.mock.rst:2310 msgid "" "The :data:`DEFAULT` object is a pre-created sentinel (actually ``sentinel." "DEFAULT``). It can be used by :attr:`~Mock.side_effect` functions to " @@ -3129,11 +3129,11 @@ msgstr "" "DEFAULT``\\ )。它可以被 :attr:`~Mock.side_effect` 函式使用來表示正常的回傳值" "應該被使用。" -#: ../../library/unittest.mock.rst:2317 +#: ../../library/unittest.mock.rst:2316 msgid "call" msgstr "call" -#: ../../library/unittest.mock.rst:2321 +#: ../../library/unittest.mock.rst:2320 msgid "" ":func:`call` is a helper object for making simpler assertions, for comparing " "with :attr:`~Mock.call_args`, :attr:`~Mock.call_args_list`, :attr:`~Mock." @@ -3145,7 +3145,7 @@ msgstr "" "簡單的斷言的輔助物件。:func:`call` 也可以與 :meth:`~Mock.assert_has_calls` 一" "起使用。" -#: ../../library/unittest.mock.rst:2334 +#: ../../library/unittest.mock.rst:2333 msgid "" "For a call object that represents multiple calls, :meth:`call_list` returns " "a list of all the intermediate calls as well as the final call." @@ -3153,7 +3153,7 @@ msgstr "" "對於表示多個呼叫的 call 物件,:meth:`call_list` 回傳所有中間呼叫以及最終呼叫" "的串列。" -#: ../../library/unittest.mock.rst:2338 +#: ../../library/unittest.mock.rst:2337 msgid "" "``call_list`` is particularly useful for making assertions on \"chained " "calls\". A chained call is multiple calls on a single line of code. This " @@ -3164,13 +3164,13 @@ msgstr "" "在單行程式碼進行的多次呼叫。這會導致 mock 上的 :attr:`~Mock.mock_calls` 中出" "現多個項目。手動建構呼叫序列會相當單調乏味。" -#: ../../library/unittest.mock.rst:2343 +#: ../../library/unittest.mock.rst:2342 msgid "" ":meth:`~call.call_list` can construct the sequence of calls from the same " "chained call:" msgstr ":meth:`~call.call_list` 可以從同一個鍊接呼叫建構呼叫序列:" -#: ../../library/unittest.mock.rst:2360 +#: ../../library/unittest.mock.rst:2359 msgid "" "A ``call`` object is either a tuple of (positional args, keyword args) or " "(name, positional args, keyword args) depending on how it was constructed. " @@ -3184,7 +3184,7 @@ msgstr "" "趣,但是 :attr:`Mock.call_args`、:attr:`Mock.call_args_list` 和 :attr:`Mock." "mock_calls` 屬性中的 ``call`` 物件可以被內省以取得它們包含的各個引數。" -#: ../../library/unittest.mock.rst:2367 +#: ../../library/unittest.mock.rst:2366 msgid "" "The ``call`` objects in :attr:`Mock.call_args` and :attr:`Mock." "call_args_list` are two-tuples of (positional args, keyword args) whereas " @@ -3196,7 +3196,7 @@ msgstr "" "(位置引數, 關鍵字引數)的二元組,而 :attr:`Mock.mock_calls` 中的 ``call`` 物" "件以及你自己建立的 ``call`` 物件是(名稱, 位置引數, 關鍵字引數)的三元組。" -#: ../../library/unittest.mock.rst:2372 +#: ../../library/unittest.mock.rst:2371 msgid "" "You can use their \"tupleness\" to pull out the individual arguments for " "more complex introspection and assertions. The positional arguments are a " @@ -3206,11 +3206,11 @@ msgstr "" "你可以利用它們作為元組的特性來提取單個引數,以進行更複雜的內省和斷言。位置引" "數是一個元組(如果沒有位置引數則為空元組),關鍵字引數是一個字典:" -#: ../../library/unittest.mock.rst:2405 +#: ../../library/unittest.mock.rst:2404 msgid "create_autospec" msgstr "create_autospec" -#: ../../library/unittest.mock.rst:2409 +#: ../../library/unittest.mock.rst:2408 msgid "" "Create a mock object using another object as a spec. Attributes on the mock " "will use the corresponding attribute on the *spec* object as their spec." @@ -3218,13 +3218,13 @@ msgstr "" "使用另一個物件作為規格建立一個 mock 物件。Mock 上的屬性將使用 *spec* 物件上的" "對應屬性作為其規格。" -#: ../../library/unittest.mock.rst:2413 +#: ../../library/unittest.mock.rst:2412 msgid "" "Functions or methods being mocked will have their arguments checked to " "ensure that they are called with the correct signature." msgstr "被 mock 的函式或方法將檢查其引數,以確保他們被使用正確的簽名來呼叫。" -#: ../../library/unittest.mock.rst:2416 +#: ../../library/unittest.mock.rst:2415 msgid "" "If *spec_set* is ``True`` then attempting to set attributes that don't exist " "on the spec object will raise an :exc:`AttributeError`." @@ -3232,7 +3232,7 @@ msgstr "" "如果 *spec_set* 為 ``True``,則嘗試設定規格物件上不存在的屬性將引發 :exc:" "`AttributeError`。" -#: ../../library/unittest.mock.rst:2419 +#: ../../library/unittest.mock.rst:2418 msgid "" "If a class is used as a spec then the return value of the mock (the instance " "of the class) will have the same spec. You can use a class as the spec for " @@ -3243,7 +3243,7 @@ msgstr "" "可以透過傳遞 ``instance=True`` 來使用一個類別作為一個實例物件的規格。只有當 " "mock 的實例是可呼叫物件時,回傳的 mock 才會是可呼叫物件。" -#: ../../library/unittest.mock.rst:2424 +#: ../../library/unittest.mock.rst:2423 msgid "" ":func:`create_autospec` also takes arbitrary keyword arguments that are " "passed to the constructor of the created mock." @@ -3251,7 +3251,7 @@ msgstr "" ":func:`create_autospec` 也接受任意的關鍵字引數,這些引數會傳遞給已建立的 " "mock 的建構函式。" -#: ../../library/unittest.mock.rst:2427 +#: ../../library/unittest.mock.rst:2426 msgid "" "See :ref:`auto-speccing` for examples of how to use auto-speccing with :func:" "`create_autospec` and the *autospec* argument to :func:`patch`." @@ -3259,7 +3259,7 @@ msgstr "" "請參閱 :ref:`auto-speccing` 以得知如何以 :func:`create_autospec` 使用自動規格" "以及如何在 :func:`patch` 中使用 *autospec* 引數的範例。" -#: ../../library/unittest.mock.rst:2433 +#: ../../library/unittest.mock.rst:2432 msgid "" ":func:`create_autospec` now returns an :class:`AsyncMock` if the target is " "an async function." @@ -3267,11 +3267,11 @@ msgstr "" "如果目標是一個非同步函式,:func:`create_autospec` 現在會回傳一個 :class:" "`AsyncMock`。" -#: ../../library/unittest.mock.rst:2438 +#: ../../library/unittest.mock.rst:2437 msgid "ANY" msgstr "ANY" -#: ../../library/unittest.mock.rst:2442 +#: ../../library/unittest.mock.rst:2441 msgid "" "Sometimes you may need to make assertions about *some* of the arguments in a " "call to mock, but either not care about some of the arguments or want to " @@ -3281,7 +3281,7 @@ msgstr "" "有時你可能需要對 mock 的呼叫中的\\ *某些*\\ 引數進行斷言,但你不在意其他的某" "些引數,或想將它們單獨從 :attr:`~Mock.call_args` 中取出並進行更加複雜的斷言。" -#: ../../library/unittest.mock.rst:2447 +#: ../../library/unittest.mock.rst:2446 msgid "" "To ignore certain arguments you can pass in objects that compare equal to " "*everything*. Calls to :meth:`~Mock.assert_called_with` and :meth:`~Mock." @@ -3291,20 +3291,20 @@ msgstr "" "麼內容,對 :meth:`~Mock.assert_called_with` 和 :meth:`~Mock." "assert_called_once_with` 的呼叫都會成功。" -#: ../../library/unittest.mock.rst:2456 +#: ../../library/unittest.mock.rst:2455 msgid "" ":data:`ANY` can also be used in comparisons with call lists like :attr:" "`~Mock.mock_calls`:" msgstr "" ":data:`ANY` 也可以用來與呼叫串列進行比較,例如 :attr:`~Mock.mock_calls`:" -#: ../../library/unittest.mock.rst:2466 +#: ../../library/unittest.mock.rst:2465 msgid "" ":data:`ANY` is not limited to comparisons with call objects and so can also " "be used in test assertions::" msgstr ":data:`ANY` 不只能與呼叫物件比較,其也可以在測試斷言中使用: ::" -#: ../../library/unittest.mock.rst:2469 +#: ../../library/unittest.mock.rst:2468 msgid "" "class TestStringMethods(unittest.TestCase):\n" "\n" @@ -3318,11 +3318,11 @@ msgstr "" " s = 'hello world'\n" " self.assertEqual(s.split(), ['hello', ANY])" -#: ../../library/unittest.mock.rst:2477 +#: ../../library/unittest.mock.rst:2476 msgid "FILTER_DIR" msgstr "FILTER_DIR" -#: ../../library/unittest.mock.rst:2481 +#: ../../library/unittest.mock.rst:2480 msgid "" ":data:`FILTER_DIR` is a module level variable that controls the way mock " "objects respond to :func:`dir`. The default is ``True``, which uses the " @@ -3335,7 +3335,7 @@ msgstr "" "你不喜歡這個過濾方式,或由於診斷意圖而需要將其關閉,請設定 ``mock.FILTER_DIR " "= False``。" -#: ../../library/unittest.mock.rst:2487 +#: ../../library/unittest.mock.rst:2486 msgid "" "With filtering on, ``dir(some_mock)`` shows only useful attributes and will " "include any dynamically created attributes that wouldn't normally be shown. " @@ -3347,7 +3347,7 @@ msgstr "" "的任何動態建立的屬性。如果 mock 是使用 *spec*\\ (或 *autospec*\\ )來建立" "的,那麼源頭的所有屬性都會顯示,即使它們尚未被存取:" -#: ../../library/unittest.mock.rst:2493 +#: ../../library/unittest.mock.rst:2492 msgid "" ">>> dir(Mock())\n" "['assert_any_call',\n" @@ -3385,7 +3385,7 @@ msgstr "" " 'BaseHandler',\n" " ..." -#: ../../library/unittest.mock.rst:2514 +#: ../../library/unittest.mock.rst:2513 msgid "" "Many of the not-very-useful (private to :class:`Mock` rather than the thing " "being mocked) underscore and double underscore prefixed attributes have been " @@ -3397,7 +3397,7 @@ msgstr "" "雙底線前綴屬性已從在 :class:`Mock` 上呼叫 :func:`dir` 的結果中濾除。如果你不" "喜歡這種特性,可以透過設定模組級別開關 :data:`FILTER_DIR` 來將其關閉:" -#: ../../library/unittest.mock.rst:2520 +#: ../../library/unittest.mock.rst:2519 msgid "" ">>> from unittest import mock\n" ">>> mock.FILTER_DIR = False\n" @@ -3423,7 +3423,7 @@ msgstr "" " '__class__',\n" " ..." -#: ../../library/unittest.mock.rst:2535 +#: ../../library/unittest.mock.rst:2534 msgid "" "Alternatively you can just use ``vars(my_mock)`` (instance members) and " "``dir(type(my_mock))`` (type members) to bypass the filtering irrespective " @@ -3433,11 +3433,11 @@ msgstr "" "``dir(type(my_mock))``\\ (型別成員)來略過過濾,而不考慮 :const:" "`FILTER_DIR`。" -#: ../../library/unittest.mock.rst:2541 +#: ../../library/unittest.mock.rst:2540 msgid "mock_open" msgstr "mock_open" -#: ../../library/unittest.mock.rst:2545 +#: ../../library/unittest.mock.rst:2544 msgid "" "A helper function to create a mock to replace the use of :func:`open`. It " "works for :func:`open` called directly or used as a context manager." @@ -3445,7 +3445,7 @@ msgstr "" "用於建立取代 :func:`open` 用途的 mock 的輔助函式。它適用於直接呼叫或用作情境" "管理器的 :func:`open`。" -#: ../../library/unittest.mock.rst:2548 +#: ../../library/unittest.mock.rst:2547 msgid "" "The *mock* argument is the mock object to configure. If ``None`` (the " "default) then a :class:`MagicMock` will be created for you, with the API " @@ -3454,7 +3454,7 @@ msgstr "" "*mock* 引數是要配置的 mock 物件。如果其為 ``None``\\ (預設值),那麼就會為你" "建立一個 :class:`MagicMock`,其 API 限制在標準檔案處理上可用的方法或屬性。" -#: ../../library/unittest.mock.rst:2552 +#: ../../library/unittest.mock.rst:2551 msgid "" "*read_data* is a string for the :meth:`~io.RawIOBase.read`, :meth:`~io." "IOBase.readline`, and :meth:`~io.IOBase.readlines` methods of the file " @@ -3474,7 +3474,7 @@ msgstr "" "org>`_ 上的其中一個記憶體內檔案系統 (in-memory filesystem) 套件可以提供用於測" "試的真實檔案系統。" -#: ../../library/unittest.mock.rst:2562 +#: ../../library/unittest.mock.rst:2561 msgid "" "Added :meth:`~io.IOBase.readline` and :meth:`~io.IOBase.readlines` support. " "The mock of :meth:`~io.RawIOBase.read` changed to consume *read_data* rather " @@ -3484,11 +3484,11 @@ msgstr "" "meth:`~io.RawIOBase.read` 的 mock 更改為消耗 *read_data* 而不是在每次呼叫時回" "傳它。" -#: ../../library/unittest.mock.rst:2567 +#: ../../library/unittest.mock.rst:2566 msgid "*read_data* is now reset on each call to the *mock*." msgstr "現在,每次呼叫 *mock* 時都會重置 *read_data*。" -#: ../../library/unittest.mock.rst:2570 +#: ../../library/unittest.mock.rst:2569 msgid "" "Added :meth:`~container.__iter__` to implementation so that iteration (such " "as in for loops) correctly consumes *read_data*." @@ -3496,7 +3496,7 @@ msgstr "" "新增 :meth:`~container.__iter__` 到實作中,以便使疊代(例如在 for 迴圈中)正" "確地消耗 *read_data*。" -#: ../../library/unittest.mock.rst:2574 +#: ../../library/unittest.mock.rst:2573 msgid "" "Using :func:`open` as a context manager is a great way to ensure your file " "handles are closed properly and is becoming common::" @@ -3504,7 +3504,7 @@ msgstr "" "使用 :func:`open` 作為情境管理器是確保檔案處理正確關閉的好方式,且這種方式正" "在變得普遍: ::" -#: ../../library/unittest.mock.rst:2577 +#: ../../library/unittest.mock.rst:2576 msgid "" "with open('/some/path', 'w') as f:\n" " f.write('something')" @@ -3512,7 +3512,7 @@ msgstr "" "with open('/some/path', 'w') as f:\n" " f.write('something')" -#: ../../library/unittest.mock.rst:2580 +#: ../../library/unittest.mock.rst:2579 msgid "" "The issue is that even if you mock out the call to :func:`open` it is the " "*returned object* that is used as a context manager (and has :meth:`~object." @@ -3522,7 +3522,7 @@ msgstr "" "回傳物件*\\ (且其 :meth:`~object.__enter__` 和 :meth:`~object.__exit__` 已被" "呼叫)。" -#: ../../library/unittest.mock.rst:2584 +#: ../../library/unittest.mock.rst:2583 msgid "" "Mocking context managers with a :class:`MagicMock` is common enough and " "fiddly enough that a helper function is useful. ::" @@ -3530,7 +3530,7 @@ msgstr "" "使用 :class:`MagicMock` mock 情境管理器相當常見並且精細,因此輔助函式就非常有" "用: ::" -#: ../../library/unittest.mock.rst:2587 +#: ../../library/unittest.mock.rst:2586 msgid "" ">>> m = mock_open()\n" ">>> with patch('__main__.open', m):\n" @@ -3560,11 +3560,11 @@ msgstr "" ">>> handle = m()\n" ">>> handle.write.assert_called_once_with('some stuff')" -#: ../../library/unittest.mock.rst:2601 +#: ../../library/unittest.mock.rst:2600 msgid "And for reading files::" msgstr "以及讀取檔案: ::" -#: ../../library/unittest.mock.rst:2603 +#: ../../library/unittest.mock.rst:2602 msgid "" ">>> with patch('__main__.open', mock_open(read_data='bibble')) as m:\n" "... with open('foo') as h:\n" @@ -3580,11 +3580,11 @@ msgstr "" ">>> m.assert_called_once_with('foo')\n" ">>> assert result == 'bibble'" -#: ../../library/unittest.mock.rst:2614 +#: ../../library/unittest.mock.rst:2613 msgid "Autospeccing" msgstr "Autospeccing(自動規格)" -#: ../../library/unittest.mock.rst:2616 +#: ../../library/unittest.mock.rst:2615 msgid "" "Autospeccing is based on the existing :attr:`!spec` feature of mock. It " "limits the api of mocks to the api of an original object (the spec), but it " @@ -3598,11 +3598,11 @@ msgstr "" "具有與規格的屬性相同的 api。此外,被 mock 的函式/方法具有與原始的函式/方法相" "同的呼叫簽名,因此如果它們被不正確地呼叫,就會引發 :exc:`TypeError`。" -#: ../../library/unittest.mock.rst:2623 +#: ../../library/unittest.mock.rst:2622 msgid "Before I explain how auto-speccing works, here's why it is needed." msgstr "在解釋自動規格如何運作之前,我們先解釋為什麼需要它。" -#: ../../library/unittest.mock.rst:2625 +#: ../../library/unittest.mock.rst:2624 msgid "" ":class:`Mock` is a very powerful and flexible object, but it suffers from a " "flaw which is general to mocking. If you refactor some of your code, rename " @@ -3615,7 +3615,7 @@ msgstr "" "實物件的程式碼測試仍然會通過。這意味著即使你的程式碼壞了,但測試仍可以全部通" "過。" -#: ../../library/unittest.mock.rst:2633 +#: ../../library/unittest.mock.rst:2632 msgid "" "Before 3.5, tests with a typo in the word assert would silently pass when " "they should raise an error. You can still achieve this behavior by passing " @@ -3624,7 +3624,7 @@ msgstr "" "在 3.5 之前,當測試應該引發錯誤時,斷言單字中存在拼字錯誤的測驗會默默地通過。" "你仍可以透過將 ``unsafe=True`` 傳遞給 Mock 來實作此行為。" -#: ../../library/unittest.mock.rst:2636 +#: ../../library/unittest.mock.rst:2635 msgid "" "Note that this is another reason why you need integration tests as well as " "unit tests. Testing everything in isolation is all fine and dandy, but if " @@ -3634,7 +3634,7 @@ msgstr "" "謹記這是你需要有整合測試和單元測試的另一個原因。單獨測試所有內容都很好,但如" "果你不測試你的單元是如何「連接在一起」的,那麼測試還是有機會發現很多錯誤。" -#: ../../library/unittest.mock.rst:2641 +#: ../../library/unittest.mock.rst:2640 msgid "" ":mod:`!unittest.mock` already provides a feature to help with this, called " "speccing. If you use a class or instance as the :attr:`!spec` for a mock " @@ -3644,13 +3644,13 @@ msgstr "" "如果你使用類別或實例作為 mock 的 :attr:`!spec`,那麼你在 mock 上只能存取真實" "類別中存在的屬性:" -#: ../../library/unittest.mock.rst:2652 +#: ../../library/unittest.mock.rst:2651 msgid "" "The spec only applies to the mock itself, so we still have the same issue " "with any methods on the mock:" msgstr "該規格僅適用於 mock 本身,因此在 mock 上的任何方法仍然有相同的問題:" -#: ../../library/unittest.mock.rst:2655 +#: ../../library/unittest.mock.rst:2654 msgid "" ">>> mock.header_items()\n" "\n" @@ -3660,7 +3660,7 @@ msgstr "" "\n" ">>> mock.header_items.assret_called_with() # 故意的錯字!" -#: ../../library/unittest.mock.rst:2661 +#: ../../library/unittest.mock.rst:2660 msgid "" "Auto-speccing solves this problem. You can either pass ``autospec=True`` to :" "func:`patch` / :func:`patch.object` or use the :func:`create_autospec` " @@ -3678,11 +3678,11 @@ msgstr "" "的),所以你可以將它與非常複雜或深度巢狀使用的物件(例如連續引用的模組)一起" "使用,而不會過於影響性能。" -#: ../../library/unittest.mock.rst:2670 +#: ../../library/unittest.mock.rst:2669 msgid "Here's an example of it in use::" msgstr "這是一個正在使用的例子: ::" -#: ../../library/unittest.mock.rst:2672 +#: ../../library/unittest.mock.rst:2671 msgid "" ">>> from urllib import request\n" ">>> patcher = patch('__main__.request', autospec=True)\n" @@ -3700,7 +3700,7 @@ msgstr "" ">>> mock_request.Request\n" "" -#: ../../library/unittest.mock.rst:2680 +#: ../../library/unittest.mock.rst:2679 msgid "" "You can see that :class:`!request.Request` has a spec. :class:`!request." "Request` takes two arguments in the constructor (one of which is *self*). " @@ -3710,7 +3710,7 @@ msgstr "" "建構函式中接受兩個引數(其中之一是 *self*\\ )。如果我們錯誤地呼叫它,會發生" "以下情況: ::" -#: ../../library/unittest.mock.rst:2684 +#: ../../library/unittest.mock.rst:2683 msgid "" ">>> req = request.Request()\n" "Traceback (most recent call last):\n" @@ -3722,13 +3722,13 @@ msgstr "" " ...\n" "TypeError: () takes at least 2 arguments (1 given)" -#: ../../library/unittest.mock.rst:2689 +#: ../../library/unittest.mock.rst:2688 msgid "" "The spec also applies to instantiated classes (i.e. the return value of " "specced mocks)::" msgstr "此規格也適用於實例化的類別(即有規格的 mock 的回傳值): ::" -#: ../../library/unittest.mock.rst:2692 +#: ../../library/unittest.mock.rst:2691 msgid "" ">>> req = request.Request('foo')\n" ">>> req\n" @@ -3738,7 +3738,7 @@ msgstr "" ">>> req\n" "" -#: ../../library/unittest.mock.rst:2696 +#: ../../library/unittest.mock.rst:2695 msgid "" ":class:`!Request` objects are not callable, so the return value of " "instantiating our mocked out :class:`!request.Request` is a non-callable " @@ -3749,7 +3749,7 @@ msgstr "" "request.Request` 的回傳值是不可呼叫的 mock。規格到位後,斷言中的任何拼字錯誤" "都會引發正確的錯誤: ::" -#: ../../library/unittest.mock.rst:2700 +#: ../../library/unittest.mock.rst:2699 msgid "" ">>> req.add_header('spam', 'eggs')\n" "\n" @@ -3767,7 +3767,7 @@ msgstr "" "AttributeError: Mock object has no attribute 'assret_called_with'\n" ">>> req.add_header.assert_called_with('spam', 'eggs')" -#: ../../library/unittest.mock.rst:2708 +#: ../../library/unittest.mock.rst:2707 msgid "" "In many cases you will just be able to add ``autospec=True`` to your " "existing :func:`patch` calls and then be protected against bugs due to typos " @@ -3776,7 +3776,7 @@ msgstr "" "在許多情況下,你只需要將 ``autospec=True`` 新增至現有的 :func:`patch` 呼叫" "中,然後就可以防止因拼字錯誤和 api 變更而導致的錯誤。" -#: ../../library/unittest.mock.rst:2712 +#: ../../library/unittest.mock.rst:2711 msgid "" "As well as using *autospec* through :func:`patch` there is a :func:" "`create_autospec` for creating autospecced mocks directly:" @@ -3784,7 +3784,7 @@ msgstr "" "除了透過 :func:`patch` 使用 *autospec* 之外,還有一個 :func:" "`create_autospec` 用於直接建立有自動規格的 mock:" -#: ../../library/unittest.mock.rst:2720 +#: ../../library/unittest.mock.rst:2719 msgid "" "This isn't without caveats and limitations however, which is why it is not " "the default behaviour. In order to know what attributes are available on the " @@ -3801,7 +3801,7 @@ msgstr "" "描述器,那麼你可能無法使用 autospec。換句話說,設計你的物件讓內省是安全的 " "[#]_ 會比較好。" -#: ../../library/unittest.mock.rst:2729 +#: ../../library/unittest.mock.rst:2728 msgid "" "A more serious problem is that it is common for instance attributes to be " "created in the :meth:`~object.__init__` method and not to exist on the class " @@ -3812,7 +3812,7 @@ msgstr "" "而其根本不存在於類別中。*autospec* 無法知道任何動態建立的屬性,並將 api 限制" "為可見的屬性。: ::" -#: ../../library/unittest.mock.rst:2734 +#: ../../library/unittest.mock.rst:2733 msgid "" ">>> class Something:\n" "... def __init__(self):\n" @@ -3838,7 +3838,7 @@ msgstr "" " ...\n" "AttributeError: Mock object has no attribute 'a'" -#: ../../library/unittest.mock.rst:2746 +#: ../../library/unittest.mock.rst:2745 msgid "" "There are a few different ways of resolving this problem. The easiest, but " "not necessarily the least annoying, way is to simply set the required " @@ -3850,7 +3850,7 @@ msgstr "" "在 mock 上設定所需的屬性。因為雖然 *autospec* 不允許你取得規格中不存在的屬" "性,但是它不會阻止你設定它們: ::" -#: ../../library/unittest.mock.rst:2752 +#: ../../library/unittest.mock.rst:2751 msgid "" ">>> with patch('__main__.Something', autospec=True):\n" "... thing = Something()\n" @@ -3862,7 +3862,7 @@ msgstr "" "... thing.a = 33\n" "..." -#: ../../library/unittest.mock.rst:2757 +#: ../../library/unittest.mock.rst:2756 msgid "" "There is a more aggressive version of both *spec* and *autospec* that *does* " "prevent you setting non-existent attributes. This is useful if you want to " @@ -3873,7 +3873,7 @@ msgstr "" "屬性。如果你想確保你的程式碼僅能\\ *設定*\\ 有效的屬性,那麼這會很有用,但顯" "然它也順便阻止了這個特殊情況:" -#: ../../library/unittest.mock.rst:2770 +#: ../../library/unittest.mock.rst:2769 msgid "" "Probably the best way of solving the problem is to add class attributes as " "default values for instance members initialised in :meth:`~object.__init__`. " @@ -3885,7 +3885,7 @@ msgstr "" "的實例成員的預設值。請注意,如果你僅在 :meth:`!__init__` 中設定預設屬性,那麼" "透過類別屬性(當然在實例之間共用)提供它們也會更快。例如:" -#: ../../library/unittest.mock.rst:2776 +#: ../../library/unittest.mock.rst:2775 msgid "" "class Something:\n" " a = 33" @@ -3893,7 +3893,7 @@ msgstr "" "class Something:\n" " a = 33" -#: ../../library/unittest.mock.rst:2781 +#: ../../library/unittest.mock.rst:2780 msgid "" "This brings up another issue. It is relatively common to provide a default " "value of ``None`` for members that will later be an object of a different " @@ -3909,7 +3909,7 @@ msgstr "" "他型別的成員,因此自動規格不會對設定為 ``None`` 的成員使用規格。這些會只是普" "通的 mock(通常是 MagicMocks):" -#: ../../library/unittest.mock.rst:2796 +#: ../../library/unittest.mock.rst:2795 msgid "" "If modifying your production classes to add defaults isn't to your liking " "then there are more options. One of these is simply to use an instance as " @@ -3925,7 +3925,7 @@ msgstr "" "你使用替代物件作為規格。值得慶幸的是 :func:`patch` 支援這一點 - 你可以簡單地" "將替代物件作為 *autospec* 引數傳遞: ::" -#: ../../library/unittest.mock.rst:2804 +#: ../../library/unittest.mock.rst:2803 msgid "" ">>> class Something:\n" "... def __init__(self):\n" @@ -3951,7 +3951,7 @@ msgstr "" ">>> mock.a\n" "" -#: ../../library/unittest.mock.rst:2817 +#: ../../library/unittest.mock.rst:2816 msgid "" "This only applies to classes or already instantiated objects. Calling a " "mocked class to create a mock instance *does not* create a real instance. It " @@ -3960,11 +3960,11 @@ msgstr "" "這只適用於類別或已經實例化的物件。呼叫一個被 mock 的類別來建立一個 mock 實例" "\\ *不會*\\ 建立真的實例。它僅查找屬性及對 :func:`dir` 的呼叫。" -#: ../../library/unittest.mock.rst:2822 +#: ../../library/unittest.mock.rst:2821 msgid "Sealing mocks" msgstr "密封 mock" -#: ../../library/unittest.mock.rst:2831 +#: ../../library/unittest.mock.rst:2830 msgid "" "Seal will disable the automatic creation of mocks when accessing an " "attribute of the mock being sealed or any of its attributes that are already " @@ -3973,7 +3973,7 @@ msgstr "" "當存取被密封的 mock 的屬性或其任何已經遞迴 mock 的屬性時,seal 將停用 mock 的" "自動建立。" -#: ../../library/unittest.mock.rst:2834 +#: ../../library/unittest.mock.rst:2833 msgid "" "If a mock instance with a name or a spec is assigned to an attribute it " "won't be considered in the sealing chain. This allows one to prevent seal " @@ -3982,7 +3982,7 @@ msgstr "" "如果將具有名稱或規格的 mock 實例指派給屬性,則不會出現在密封鏈中。這表示可藉" "由固定 mock 物件的一部分來防止密封。: ::" -#: ../../library/unittest.mock.rst:2838 +#: ../../library/unittest.mock.rst:2837 msgid "" ">>> mock = Mock()\n" ">>> mock.submock.attribute1 = 2\n" @@ -4000,29 +4000,29 @@ msgstr "" ">>> mock.submock.attribute2 # This will raise AttributeError.\n" ">>> mock.not_submock.attribute2 # This won't raise." -#: ../../library/unittest.mock.rst:2850 +#: ../../library/unittest.mock.rst:2849 msgid "" "Order of precedence of :attr:`!side_effect`, :attr:`!return_value` and " "*wraps*" msgstr ":attr:`!side_effect`、:attr:`!return_value` 和 *wraps* 的優先順序" -#: ../../library/unittest.mock.rst:2852 +#: ../../library/unittest.mock.rst:2851 msgid "The order of their precedence is:" msgstr "它們的優先順序是:" -#: ../../library/unittest.mock.rst:2854 +#: ../../library/unittest.mock.rst:2853 msgid ":attr:`~Mock.side_effect`" msgstr ":attr:`~Mock.side_effect`" -#: ../../library/unittest.mock.rst:2855 +#: ../../library/unittest.mock.rst:2854 msgid ":attr:`~Mock.return_value`" msgstr ":attr:`~Mock.return_value`" -#: ../../library/unittest.mock.rst:2856 +#: ../../library/unittest.mock.rst:2855 msgid "*wraps*" msgstr "*wraps*" -#: ../../library/unittest.mock.rst:2858 +#: ../../library/unittest.mock.rst:2857 msgid "" "If all three are set, mock will return the value from :attr:`~Mock." "side_effect`, ignoring :attr:`~Mock.return_value` and the wrapped object " @@ -4034,7 +4034,7 @@ msgstr "" "略 :attr:`~Mock.return_value` 和被包裝物件。如果設定了任兩項,則優先順序較高" "的一項將回傳該值。無論先設定哪個順序,優先順序都保持不變。" -#: ../../library/unittest.mock.rst:2876 +#: ../../library/unittest.mock.rst:2875 msgid "" "As ``None`` is the default value of :attr:`~Mock.side_effect`, if you " "reassign its value back to ``None``, the order of precedence will be checked " @@ -4045,7 +4045,7 @@ msgstr "" "``None``,則會檢查 :attr:`~Mock.return_value` 和被包裝物件之間的優先順序,忽" "略 :attr:`~Mock.side_effect`。" -#: ../../library/unittest.mock.rst:2885 +#: ../../library/unittest.mock.rst:2884 msgid "" "If the value being returned by :attr:`~Mock.side_effect` is :data:`DEFAULT`, " "it is ignored and the order of precedence moves to the successor to obtain " @@ -4054,7 +4054,7 @@ msgstr "" "如果 :attr:`~Mock.side_effect` 回傳的值是 :data:`DEFAULT`,它將被忽略,並且優" "先順序被移動到後面一個以獲得要回傳的值。" -#: ../../library/unittest.mock.rst:2894 +#: ../../library/unittest.mock.rst:2893 msgid "" "When :class:`Mock` wraps an object, the default value of :attr:`~Mock." "return_value` will be :data:`DEFAULT`." @@ -4062,13 +4062,13 @@ msgstr "" "當 :class:`Mock` 包裝一個物件時,:attr:`~Mock.return_value` 的預設值將為 :" "data:`DEFAULT`。" -#: ../../library/unittest.mock.rst:2903 +#: ../../library/unittest.mock.rst:2902 msgid "" "The order of precedence will ignore this value and it will move to the last " "successor which is the wrapped object." msgstr "優先順序將忽略該值,並將移動到最後一個,即被包裝物件。" -#: ../../library/unittest.mock.rst:2906 +#: ../../library/unittest.mock.rst:2905 msgid "" "As the real call is being made to the wrapped object, creating an instance " "of this mock will return the real instance of the class. The positional " @@ -4077,7 +4077,7 @@ msgstr "" "當對被包裝物件進行真正的呼叫時,建立此 mock 的實例將回傳該類別的真實實例。必" "須傳遞被包裝物件所需的位置引數(如果存在)。" -#: ../../library/unittest.mock.rst:2924 +#: ../../library/unittest.mock.rst:2923 msgid "" "But if you assign ``None`` to it, this will not be ignored as it is an " "explicit assignment. So, the order of precedence will not move to the " @@ -4086,17 +4086,17 @@ msgstr "" "但如果你為其賦予 ``None`` 則不會被忽略,因為它是明確賦值。因此,優先順序不會" "移至被包裝物件。" -#: ../../library/unittest.mock.rst:2932 +#: ../../library/unittest.mock.rst:2931 msgid "" "Even if you set all three at once when initializing the mock, the order of " "precedence remains the same:" msgstr "即使你在初始化 mock 時同時設定所有三個,優先順序也保持不變:" -#: ../../library/unittest.mock.rst:2949 +#: ../../library/unittest.mock.rst:2948 msgid "" "If :attr:`~Mock.side_effect` is :term:`exhausted`, the order of precedence " "will not cause a value to be obtained from the successors. Instead, " "``StopIteration`` exception is raised." msgstr "" "如果 :attr:`~Mock.side_effect` 已\\ :term:`耗盡 `,則優先順序將不" -"會使值由後面取得。相反地這會引發 ``StopIteration`` 例外。" \ No newline at end of file +"會使值由後面取得。相反地這會引發 ``StopIteration`` 例外。" diff --git a/library/unittest.po b/library/unittest.po index 1393447d921..e6a02ed3fdb 100644 --- a/library/unittest.po +++ b/library/unittest.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-10-16 06:03+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,11 +25,11 @@ msgstr "" msgid ":mod:`!unittest` --- Unit testing framework" msgstr ":mod:`!unittest` --- 單元測試框架" -#: ../../library/unittest.rst:12 +#: ../../library/unittest.rst:7 msgid "**Source code:** :source:`Lib/unittest/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/unittest/__init__.py`" -#: ../../library/unittest.rst:16 +#: ../../library/unittest.rst:11 msgid "" "(If you are already familiar with the basic concepts of testing, you might " "want to skip to :ref:`the list of assert methods `.)" @@ -37,7 +37,7 @@ msgstr "" "(假如你已經熟悉相關基礎的測試概念,你可能會希望跳過以下段落,直接參考 :ref:" "`assert 方法清單 `。)" -#: ../../library/unittest.rst:19 +#: ../../library/unittest.rst:14 msgid "" "The :mod:`!unittest` unit testing framework was originally inspired by JUnit " "and has a similar flavor as major unit testing frameworks in other " @@ -49,17 +49,17 @@ msgstr "" "要的單元測試框架。支援自動化測試,對測試分享安裝與關閉程式碼,集合所有匯總的" "測試,並且獨立各個測試報告框架。" -#: ../../library/unittest.rst:25 +#: ../../library/unittest.rst:20 msgid "" "To achieve this, :mod:`!unittest` supports some important concepts in an " "object-oriented way:" msgstr ":mod:`!unittest` 用來作為實現支援一些重要的物件導向方法的概念:" -#: ../../library/unittest.rst:28 +#: ../../library/unittest.rst:23 msgid "test fixture" msgstr "test fixture" -#: ../../library/unittest.rst:29 +#: ../../library/unittest.rst:24 msgid "" "A :dfn:`test fixture` represents the preparation needed to perform one or " "more tests, and any associated cleanup actions. This may involve, for " @@ -70,11 +70,11 @@ msgstr "" "操作,例如可以是建立臨時性的或是代理用 (proxy) 資料庫、目錄、或是啟動一個伺服" "器程序。" -#: ../../library/unittest.rst:34 +#: ../../library/unittest.rst:29 msgid "test case" msgstr "test case(測試用例)" -#: ../../library/unittest.rst:35 +#: ../../library/unittest.rst:30 msgid "" "A :dfn:`test case` is the individual unit of testing. It checks for a " "specific response to a particular set of inputs. :mod:`!unittest` provides " @@ -84,11 +84,11 @@ msgstr "" "特殊回饋。:mod:`!unittest` 提供一個基礎類別,類別 :class:`TestCase`,可以用來" "建立一個新的測試條例。" -#: ../../library/unittest.rst:39 +#: ../../library/unittest.rst:34 msgid "test suite" msgstr "test suite(測試套件)" -#: ../../library/unittest.rst:40 +#: ../../library/unittest.rst:35 msgid "" "A :dfn:`test suite` is a collection of test cases, test suites, or both. It " "is used to aggregate tests that should be executed together." @@ -96,11 +96,11 @@ msgstr "" ":dfn:`test suite` 是一個搜集測試條例,測試套件,或是兩者皆有。它需要一起被執" "行並用來匯總測試。" -#: ../../library/unittest.rst:43 +#: ../../library/unittest.rst:38 msgid "test runner" msgstr "test runner(測試執行器)" -#: ../../library/unittest.rst:44 +#: ../../library/unittest.rst:39 msgid "" "A :dfn:`test runner` is a component which orchestrates the execution of " "tests and provides the outcome to the user. The runner may use a graphical " @@ -110,15 +110,15 @@ msgstr "" ":dfn:`test runner` 是一個編排測試執行與提供結果給使用者的一個元件。執行器可以" "使用圖形化介面,文字介面或是回傳一個特別值用來標示出執行測試的結果。" -#: ../../library/unittest.rst:51 +#: ../../library/unittest.rst:46 msgid "Module :mod:`doctest`" msgstr ":mod:`doctest` 模組" -#: ../../library/unittest.rst:52 +#: ../../library/unittest.rst:47 msgid "Another test-support module with a very different flavor." msgstr "另一個執行測試的模組,但使用不一樣的測試方法與規範。" -#: ../../library/unittest.rst:54 +#: ../../library/unittest.rst:49 msgid "" "`Simple Smalltalk Testing: With Patterns `_" @@ -126,17 +126,17 @@ msgstr "" "`Simple Smalltalk Testing: With Patterns `_" -#: ../../library/unittest.rst:55 +#: ../../library/unittest.rst:50 msgid "" "Kent Beck's original paper on testing frameworks using the pattern shared " "by :mod:`!unittest`." msgstr "Kent Beck 的原始論文討論使用 :mod:`!unittest` 這樣模式的測試框架。" -#: ../../library/unittest.rst:58 +#: ../../library/unittest.rst:53 msgid "`pytest `_" msgstr "`pytest `_" -#: ../../library/unittest.rst:59 +#: ../../library/unittest.rst:54 msgid "" "Third-party unittest framework with a lighter-weight syntax for writing " "tests. For example, ``assert func(10) == 42``." @@ -144,7 +144,7 @@ msgstr "" "第三方的單元測試框架,但在撰寫測試時使用更輕量的語法。例如: ``assert " "func(10) == 42``。" -#: ../../library/unittest.rst:62 +#: ../../library/unittest.rst:57 msgid "" "`The Python Testing Tools Taxonomy `_" @@ -152,7 +152,7 @@ msgstr "" "`The Python Testing Tools Taxonomy `_" -#: ../../library/unittest.rst:63 +#: ../../library/unittest.rst:58 msgid "" "An extensive list of Python testing tools including functional testing " "frameworks and mock object libraries." @@ -160,7 +160,7 @@ msgstr "" "一份詳細的 Python 測試工具列表,包含 functional testing 框架和mock object 函" "式庫。" -#: ../../library/unittest.rst:66 +#: ../../library/unittest.rst:61 msgid "" "`Testing in Python Mailing List `_" @@ -168,13 +168,13 @@ msgstr "" "`Testing in Python Mailing List `_" -#: ../../library/unittest.rst:67 +#: ../../library/unittest.rst:62 msgid "" "A special-interest-group for discussion of testing, and testing tools, in " "Python." msgstr "一個專門興趣的群組用來討論 Python 中的測試方式與測試工具。" -#: ../../library/unittest.rst:70 +#: ../../library/unittest.rst:65 msgid "" "The script :file:`Tools/unittestgui/unittestgui.py` in the Python source " "distribution is a GUI tool for test discovery and execution. This is " @@ -185,11 +185,11 @@ msgid "" "features/actions>`_, or `AppVeyor `_." msgstr "" -#: ../../library/unittest.rst:82 +#: ../../library/unittest.rst:77 msgid "Basic example" msgstr "簡單範例" -#: ../../library/unittest.rst:84 +#: ../../library/unittest.rst:79 msgid "" "The :mod:`!unittest` module provides a rich set of tools for constructing " "and running tests. This section demonstrates that a small subset of the " @@ -198,11 +198,11 @@ msgstr "" ":mod:`!unittest` 模組提供一系列豐富的工具用來建構與執行測試。本節將展示這一系" "列工具中一部份,它們已能滿足大部份使用者需求。" -#: ../../library/unittest.rst:88 +#: ../../library/unittest.rst:83 msgid "Here is a short script to test three string methods::" msgstr "這是一段簡短的腳本用來測試 3 個字串方法: ::" -#: ../../library/unittest.rst:90 +#: ../../library/unittest.rst:85 msgid "" "import unittest\n" "\n" @@ -226,7 +226,7 @@ msgid "" " unittest.main()" msgstr "" -#: ../../library/unittest.rst:112 +#: ../../library/unittest.rst:107 msgid "" "A test case is created by subclassing :class:`unittest.TestCase`. The three " "individual tests are defined with methods whose names start with the letters " @@ -237,7 +237,7 @@ msgstr "" "定義了三個獨立的物件方法,名稱皆以 ``test`` 開頭。這樣的命名方式能告知 test " "runner 哪些物件方法為定義的測試。" -#: ../../library/unittest.rst:117 +#: ../../library/unittest.rst:112 msgid "" "The crux of each test is a call to :meth:`~TestCase.assertEqual` to check " "for an expected result; :meth:`~TestCase.assertTrue` or :meth:`~TestCase." @@ -252,7 +252,7 @@ msgstr "" "使用這些物件方法來取代 :keyword:`assert` 陳述句,將能使 test runner 收集所有" "的測試結果並產生一個報表。" -#: ../../library/unittest.rst:124 +#: ../../library/unittest.rst:119 msgid "" "The :meth:`~TestCase.setUp` and :meth:`~TestCase.tearDown` methods allow you " "to define instructions that will be executed before and after each test " @@ -260,7 +260,7 @@ msgid "" "tests`." msgstr "" -#: ../../library/unittest.rst:128 +#: ../../library/unittest.rst:123 msgid "" "The final block shows a simple way to run the tests. :func:`unittest.main` " "provides a command-line interface to the test script. When run from the " @@ -269,7 +269,7 @@ msgstr "" "最後將顯示一個簡單的方法去執行測試 :func:`unittest.main` 提供一個命令列介面測" "試腳本。當透過命令列執行,輸出結果將會像是: ::" -#: ../../library/unittest.rst:132 +#: ../../library/unittest.rst:127 msgid "" "...\n" "----------------------------------------------------------------------\n" @@ -283,7 +283,7 @@ msgstr "" "\n" "OK" -#: ../../library/unittest.rst:138 +#: ../../library/unittest.rst:133 msgid "" "Passing the ``-v`` option to your test script will instruct :func:`unittest." "main` to enable a higher level of verbosity, and produce the following " @@ -292,7 +292,7 @@ msgstr "" "在測試時加入 ``-v`` 選項將指示 :func:`unittest.main` 提高 verbosity 層級,產" "生以下的輸出: ::" -#: ../../library/unittest.rst:141 +#: ../../library/unittest.rst:136 msgid "" "test_isupper (__main__.TestStringMethods.test_isupper) ... ok\n" "test_split (__main__.TestStringMethods.test_split) ... ok\n" @@ -312,7 +312,7 @@ msgstr "" "\n" "OK" -#: ../../library/unittest.rst:150 +#: ../../library/unittest.rst:145 msgid "" "The above examples show the most commonly used :mod:`!unittest` features " "which are sufficient to meet many everyday testing needs. The remainder of " @@ -321,23 +321,23 @@ msgstr "" "以上的例子顯示大多數使用 :mod:`!unittest` 特徵足以滿足大多數日常測試的需求。" "接下來第一部分文件的剩餘部分將繼續探索完整特徵設定。" -#: ../../library/unittest.rst:154 +#: ../../library/unittest.rst:149 msgid "" "The behavior of returning a value from a test method (other than the default " "``None`` value), is now deprecated." msgstr "" -#: ../../library/unittest.rst:162 +#: ../../library/unittest.rst:157 msgid "Command-Line Interface" msgstr "命令列介面" -#: ../../library/unittest.rst:164 +#: ../../library/unittest.rst:159 msgid "" "The unittest module can be used from the command line to run tests from " "modules, classes or even individual test methods::" msgstr "單元測試模組可以透過命令列執行測試模組,物件甚至個別的測試方法: ::" -#: ../../library/unittest.rst:167 +#: ../../library/unittest.rst:162 msgid "" "python -m unittest test_module1 test_module2\n" "python -m unittest test_module.TestClass\n" @@ -347,21 +347,21 @@ msgstr "" "python -m unittest test_module.TestClass\n" "python -m unittest test_module.TestClass.test_method" -#: ../../library/unittest.rst:171 +#: ../../library/unittest.rst:166 msgid "" "You can pass in a list with any combination of module names, and fully " "qualified class or method names." msgstr "你可以透過一個串列與任何模組名稱的組合,完全符合類別與方法的名稱。" -#: ../../library/unittest.rst:174 +#: ../../library/unittest.rst:169 msgid "Test modules can be specified by file path as well::" msgstr "測試模組可以根據檔案路徑指定: ::" -#: ../../library/unittest.rst:176 +#: ../../library/unittest.rst:171 msgid "python -m unittest tests/test_something.py" msgstr "python -m unittest tests/test_something.py" -#: ../../library/unittest.rst:178 +#: ../../library/unittest.rst:173 msgid "" "This allows you to use the shell filename completion to specify the test " "module. The file specified must still be importable as a module. The path is " @@ -374,55 +374,55 @@ msgstr "" "py' 並將路徑分隔符 (path separator) 轉換成 '.'。 假如你的測試檔案無法被 " "import 成模組,你應該直接執行該測試檔案。" -#: ../../library/unittest.rst:184 +#: ../../library/unittest.rst:179 msgid "" "You can run tests with more detail (higher verbosity) by passing in the -v " "flag::" msgstr "" "透過增加 -v 的旗標數,可以在你執行測試時得到更多細節(更高的 verbosity): ::" -#: ../../library/unittest.rst:186 +#: ../../library/unittest.rst:181 msgid "python -m unittest -v test_module" msgstr "python -m unittest -v test_module" -#: ../../library/unittest.rst:188 +#: ../../library/unittest.rst:183 msgid "" "When executed without arguments :ref:`unittest-test-discovery` is started::" msgstr "若執行時不代任何引數,將執行 :ref:`unittest-test-discovery`: ::" -#: ../../library/unittest.rst:190 +#: ../../library/unittest.rst:185 msgid "python -m unittest" msgstr "python -m unittest" -#: ../../library/unittest.rst:192 +#: ../../library/unittest.rst:187 msgid "For a list of all the command-line options::" msgstr "列出所有命令列選項: ::" -#: ../../library/unittest.rst:194 +#: ../../library/unittest.rst:189 msgid "python -m unittest -h" msgstr "python -m unittest -h" -#: ../../library/unittest.rst:196 +#: ../../library/unittest.rst:191 msgid "" "In earlier versions it was only possible to run individual test methods and " "not modules or classes." msgstr "在早期的版本可以個別執行測試方法和不需要模組或是類別。" -#: ../../library/unittest.rst:200 +#: ../../library/unittest.rst:195 msgid "" "Output is colorized by default and can be :ref:`controlled using environment " "variables `." msgstr "" -#: ../../library/unittest.rst:205 +#: ../../library/unittest.rst:200 msgid "Command-line options" msgstr "命令列模式選項" -#: ../../library/unittest.rst:207 +#: ../../library/unittest.rst:202 msgid ":program:`unittest` supports these command-line options:" msgstr ":program:`unittest` 支援以下命令列選項:" -#: ../../library/unittest.rst:213 +#: ../../library/unittest.rst:208 msgid "" "The standard output and standard error streams are buffered during the test " "run. Output during a passing test is discarded. Output is echoed normally on " @@ -432,7 +432,7 @@ msgstr "" "出在測試透過時被丟棄。若是測試錯誤或失則,這些輸出將會正常地被印出,並且被加" "入至錯誤訊息中。" -#: ../../library/unittest.rst:219 +#: ../../library/unittest.rst:214 msgid "" ":kbd:`Control-C` during the test run waits for the current test to end and " "then reports all the results so far. A second :kbd:`Control-C` raises the " @@ -441,78 +441,78 @@ msgstr "" ":kbd:`Control-C` 測試執行過程中等待正確的測試結果並回報目前為止所有的測試結" "果。第二個 :kbd:`Control-C` 拋出一般例外 :exc:`KeyboardInterrupt`。" -#: ../../library/unittest.rst:223 +#: ../../library/unittest.rst:218 msgid "" "See `Signal Handling`_ for the functions that provide this functionality." msgstr "參照 `Signal Handling`_ 針對函式提供的功能。" -#: ../../library/unittest.rst:227 +#: ../../library/unittest.rst:222 msgid "Stop the test run on the first error or failure." msgstr "在第一次錯誤或是失敗停止執行測試。" -#: ../../library/unittest.rst:231 +#: ../../library/unittest.rst:226 msgid "" "Only run test methods and classes that match the pattern or substring. This " "option may be used multiple times, in which case all test cases that match " "any of the given patterns are included." msgstr "" -#: ../../library/unittest.rst:235 +#: ../../library/unittest.rst:230 msgid "" "Patterns that contain a wildcard character (``*``) are matched against the " "test name using :meth:`fnmatch.fnmatchcase`; otherwise simple case-sensitive " "substring matching is used." msgstr "" -#: ../../library/unittest.rst:239 +#: ../../library/unittest.rst:234 msgid "" "Patterns are matched against the fully qualified test method name as " "imported by the test loader." msgstr "" -#: ../../library/unittest.rst:242 +#: ../../library/unittest.rst:237 msgid "" "For example, ``-k foo`` matches ``foo_tests.SomeTest.test_something``, " "``bar_tests.SomeTest.test_foo``, but not ``bar_tests.FooTest." "test_something``." msgstr "" -#: ../../library/unittest.rst:247 +#: ../../library/unittest.rst:242 msgid "Show local variables in tracebacks." msgstr "透過 traceback 顯示本地變數。" -#: ../../library/unittest.rst:251 +#: ../../library/unittest.rst:246 msgid "Show the N slowest test cases (N=0 for all)." msgstr "" -#: ../../library/unittest.rst:253 +#: ../../library/unittest.rst:248 msgid "The command-line options ``-b``, ``-c`` and ``-f`` were added." msgstr "增加命令列模式選項 ``-b`` 、 ``-c`` 與 ``-f``。" -#: ../../library/unittest.rst:256 +#: ../../library/unittest.rst:251 msgid "The command-line option ``--locals``." msgstr "命令列選項 ``--locals``。" -#: ../../library/unittest.rst:259 +#: ../../library/unittest.rst:254 msgid "The command-line option ``-k``." msgstr "命令列選項 ``-k``。" -#: ../../library/unittest.rst:262 +#: ../../library/unittest.rst:257 msgid "The command-line option ``--durations``." msgstr "命令列選項 ``--durations``。" -#: ../../library/unittest.rst:265 +#: ../../library/unittest.rst:260 msgid "" "The command line can also be used for test discovery, for running all of the " "tests in a project or just a subset." msgstr "" "對執行所有的專案或是一個子集合測試,命令列模式可以可以被用來做測試探索。" -#: ../../library/unittest.rst:271 +#: ../../library/unittest.rst:266 msgid "Test Discovery" msgstr "Test Discovery(測試探索)" -#: ../../library/unittest.rst:275 +#: ../../library/unittest.rst:270 msgid "" "Unittest supports simple test discovery. In order to be compatible with test " "discovery, all of the test files must be :ref:`modules ` or :" @@ -525,7 +525,7 @@ msgstr "" "並能從專案的最上層目錄中 import(代表它們的檔案名稱必須是有效的 :ref:" "`identifiers `\\ )。" -#: ../../library/unittest.rst:281 +#: ../../library/unittest.rst:276 msgid "" "Test discovery is implemented in :meth:`TestLoader.discover`, but can also " "be used from the command line. The basic command-line usage is::" @@ -533,7 +533,7 @@ msgstr "" "Test discovery(測試探索)實作在 :meth:`TestLoader.discover`,但也可以被用於" "命令列模式。基本的命令列模式用法如下: ::" -#: ../../library/unittest.rst:284 +#: ../../library/unittest.rst:279 msgid "" "cd project_directory\n" "python -m unittest discover" @@ -541,7 +541,7 @@ msgstr "" "cd project_directory\n" "python -m unittest discover" -#: ../../library/unittest.rst:289 +#: ../../library/unittest.rst:284 msgid "" "As a shortcut, ``python -m unittest`` is the equivalent of ``python -m " "unittest discover``. If you want to pass arguments to test discovery the " @@ -551,27 +551,27 @@ msgstr "" "discover``。假如你想傳遞引數至探索測試的話,一定要明確地加入 ``discover`` 子" "指令。" -#: ../../library/unittest.rst:293 +#: ../../library/unittest.rst:288 msgid "The ``discover`` sub-command has the following options:" msgstr "``discover`` 子命令有以下幾個選項:" -#: ../../library/unittest.rst:299 +#: ../../library/unittest.rst:294 msgid "Verbose output" msgstr "詳細 (verbose) 輸出" -#: ../../library/unittest.rst:303 +#: ../../library/unittest.rst:298 msgid "Directory to start discovery (``.`` default)" msgstr "開始尋找的資料夾(預設為 ``.``\\ )" -#: ../../library/unittest.rst:307 +#: ../../library/unittest.rst:302 msgid "Pattern to match test files (``test*.py`` default)" msgstr "匹配測試檔案的模式(預設為 ``test*.py``\\ )" -#: ../../library/unittest.rst:311 +#: ../../library/unittest.rst:306 msgid "Top level directory of project (defaults to start directory)" msgstr "專案的最高階層目錄(預設為開始的資料夾)" -#: ../../library/unittest.rst:313 +#: ../../library/unittest.rst:308 msgid "" "The :option:`-s`, :option:`-p`, and :option:`-t` options can be passed in as " "positional arguments in that order. The following two command lines are " @@ -580,7 +580,7 @@ msgstr "" ":option:`-s`, :option:`-p`, 和 :option:`-t` 選項依照傳遞位置作為引數排序順" "序。以下兩個命令列被視為等價: ::" -#: ../../library/unittest.rst:317 +#: ../../library/unittest.rst:312 msgid "" "python -m unittest discover -s project_directory -p \"*_test.py\"\n" "python -m unittest discover project_directory \"*_test.py\"" @@ -588,7 +588,7 @@ msgstr "" "python -m unittest discover -s project_directory -p \"*_test.py\"\n" "python -m unittest discover project_directory \"*_test.py\"" -#: ../../library/unittest.rst:320 +#: ../../library/unittest.rst:315 msgid "" "As well as being a path it is possible to pass a package name, for example " "``myproject.subpackage.test``, as the start directory. The package name you " @@ -596,7 +596,7 @@ msgid "" "as the start directory." msgstr "" -#: ../../library/unittest.rst:327 +#: ../../library/unittest.rst:322 msgid "" "Test discovery loads tests by importing them. Once test discovery has found " "all the test files from the start directory you specify it turns the paths " @@ -604,31 +604,31 @@ msgid "" "imported as ``foo.bar.baz``." msgstr "" -#: ../../library/unittest.rst:332 +#: ../../library/unittest.rst:327 msgid "" "If you have a package installed globally and attempt test discovery on a " "different copy of the package then the import *could* happen from the wrong " "place. If this happens test discovery will warn you and exit." msgstr "" -#: ../../library/unittest.rst:336 +#: ../../library/unittest.rst:331 msgid "" "If you supply the start directory as a package name rather than a path to a " "directory then discover assumes that whichever location it imports from is " "the location you intended, so you will not get the warning." msgstr "" -#: ../../library/unittest.rst:341 +#: ../../library/unittest.rst:336 msgid "" "Test modules and packages can customize test loading and discovery by " "through the `load_tests protocol`_." msgstr "" -#: ../../library/unittest.rst:344 +#: ../../library/unittest.rst:339 msgid "Test discovery supports :term:`namespace packages `." msgstr "" -#: ../../library/unittest.rst:347 +#: ../../library/unittest.rst:342 msgid "" "Test discovery dropped the :term:`namespace packages ` " "support. It has been broken since Python 3.7. Start directory and its " @@ -636,24 +636,24 @@ msgid "" "py`` file." msgstr "" -#: ../../library/unittest.rst:353 +#: ../../library/unittest.rst:348 msgid "" "If the start directory is the dotted name of the package, the ancestor " "packages can be namespace packages." msgstr "" -#: ../../library/unittest.rst:356 +#: ../../library/unittest.rst:351 msgid "" "Test discovery supports :term:`namespace package` as start directory again. " "To avoid scanning directories unrelated to Python, tests are not searched in " "subdirectories that do not contain ``__init__.py``." msgstr "" -#: ../../library/unittest.rst:365 +#: ../../library/unittest.rst:360 msgid "Organizing test code" msgstr "" -#: ../../library/unittest.rst:367 +#: ../../library/unittest.rst:362 msgid "" "The basic building blocks of unit testing are :dfn:`test cases` --- single " "scenarios that must be set up and checked for correctness. In :mod:`!" @@ -662,21 +662,21 @@ msgid "" "`TestCase` or use :class:`FunctionTestCase`." msgstr "" -#: ../../library/unittest.rst:373 +#: ../../library/unittest.rst:368 msgid "" "The testing code of a :class:`TestCase` instance should be entirely self " "contained, such that it can be run either in isolation or in arbitrary " "combination with any number of other test cases." msgstr "" -#: ../../library/unittest.rst:377 +#: ../../library/unittest.rst:372 msgid "" "The simplest :class:`TestCase` subclass will simply implement a test method " "(i.e. a method whose name starts with ``test``) in order to perform specific " "testing code::" msgstr "" -#: ../../library/unittest.rst:381 +#: ../../library/unittest.rst:376 msgid "" "import unittest\n" "\n" @@ -692,7 +692,7 @@ msgstr "" " widget = Widget('The widget')\n" " self.assertEqual(widget.size(), (50, 50))" -#: ../../library/unittest.rst:388 +#: ../../library/unittest.rst:383 msgid "" "Note that in order to test something, we use one of the :ref:`assert\\* " "methods ` provided by the :class:`TestCase` base class. If " @@ -701,7 +701,7 @@ msgid "" "other exceptions will be treated as :dfn:`errors`." msgstr "" -#: ../../library/unittest.rst:394 +#: ../../library/unittest.rst:389 msgid "" "Tests can be numerous, and their set-up can be repetitive. Luckily, we can " "factor out set-up code by implementing a method called :meth:`~TestCase." @@ -709,7 +709,7 @@ msgid "" "test we run::" msgstr "" -#: ../../library/unittest.rst:399 +#: ../../library/unittest.rst:394 msgid "" "import unittest\n" "\n" @@ -741,26 +741,26 @@ msgstr "" " self.assertEqual(self.widget.size(), (100,150),\n" " 'wrong size after resize')" -#: ../../library/unittest.rst:415 +#: ../../library/unittest.rst:410 msgid "" "The order in which the various tests will be run is determined by sorting " "the test method names with respect to the built-in ordering for strings." msgstr "" -#: ../../library/unittest.rst:419 +#: ../../library/unittest.rst:414 msgid "" "If the :meth:`~TestCase.setUp` method raises an exception while the test is " "running, the framework will consider the test to have suffered an error, and " "the test method will not be executed." msgstr "" -#: ../../library/unittest.rst:423 +#: ../../library/unittest.rst:418 msgid "" "Similarly, we can provide a :meth:`~TestCase.tearDown` method that tidies up " "after the test method has been run::" msgstr "" -#: ../../library/unittest.rst:426 +#: ../../library/unittest.rst:421 msgid "" "import unittest\n" "\n" @@ -780,13 +780,13 @@ msgstr "" " def tearDown(self):\n" " self.widget.dispose()" -#: ../../library/unittest.rst:435 +#: ../../library/unittest.rst:430 msgid "" "If :meth:`~TestCase.setUp` succeeded, :meth:`~TestCase.tearDown` will be run " "whether the test method succeeded or not." msgstr "" -#: ../../library/unittest.rst:438 +#: ../../library/unittest.rst:433 msgid "" "Such a working environment for the testing code is called a :dfn:`test " "fixture`. A new TestCase instance is created as a unique test fixture used " @@ -795,7 +795,7 @@ msgid "" "test." msgstr "" -#: ../../library/unittest.rst:444 +#: ../../library/unittest.rst:439 msgid "" "It is recommended that you use TestCase implementations to group tests " "together according to the features they test. :mod:`!unittest` provides a " @@ -805,13 +805,13 @@ msgid "" "cases for you and execute them." msgstr "" -#: ../../library/unittest.rst:451 +#: ../../library/unittest.rst:446 msgid "" "However, should you want to customize the building of your test suite, you " "can do it yourself::" msgstr "" -#: ../../library/unittest.rst:454 +#: ../../library/unittest.rst:449 msgid "" "def suite():\n" " suite = unittest.TestSuite()\n" @@ -833,7 +833,7 @@ msgstr "" " runner = unittest.TextTestRunner()\n" " runner.run(suite())" -#: ../../library/unittest.rst:464 +#: ../../library/unittest.rst:459 msgid "" "You can place the definitions of test cases and test suites in the same " "modules as the code they are to test (such as :file:`widget.py`), but there " @@ -841,63 +841,63 @@ msgid "" "as :file:`test_widget.py`:" msgstr "" -#: ../../library/unittest.rst:469 +#: ../../library/unittest.rst:464 msgid "The test module can be run standalone from the command line." msgstr "" -#: ../../library/unittest.rst:471 +#: ../../library/unittest.rst:466 msgid "The test code can more easily be separated from shipped code." msgstr "" -#: ../../library/unittest.rst:473 +#: ../../library/unittest.rst:468 msgid "" "There is less temptation to change test code to fit the code it tests " "without a good reason." msgstr "" -#: ../../library/unittest.rst:476 +#: ../../library/unittest.rst:471 msgid "" "Test code should be modified much less frequently than the code it tests." msgstr "" -#: ../../library/unittest.rst:478 +#: ../../library/unittest.rst:473 msgid "Tested code can be refactored more easily." msgstr "" -#: ../../library/unittest.rst:480 +#: ../../library/unittest.rst:475 msgid "" "Tests for modules written in C must be in separate modules anyway, so why " "not be consistent?" msgstr "" -#: ../../library/unittest.rst:483 +#: ../../library/unittest.rst:478 msgid "" "If the testing strategy changes, there is no need to change the source code." msgstr "" -#: ../../library/unittest.rst:489 +#: ../../library/unittest.rst:484 msgid "Re-using old test code" msgstr "" -#: ../../library/unittest.rst:491 +#: ../../library/unittest.rst:486 msgid "" "Some users will find that they have existing test code that they would like " "to run from :mod:`!unittest`, without converting every old test function to " "a :class:`TestCase` subclass." msgstr "" -#: ../../library/unittest.rst:495 +#: ../../library/unittest.rst:490 msgid "" "For this reason, :mod:`!unittest` provides a :class:`FunctionTestCase` " "class. This subclass of :class:`TestCase` can be used to wrap an existing " "test function. Set-up and tear-down functions can also be provided." msgstr "" -#: ../../library/unittest.rst:499 +#: ../../library/unittest.rst:494 msgid "Given the following test function::" msgstr "" -#: ../../library/unittest.rst:501 +#: ../../library/unittest.rst:496 msgid "" "def testSomething():\n" " something = makeSomething()\n" @@ -909,13 +909,13 @@ msgstr "" " assert something.name is not None\n" " # ..." -#: ../../library/unittest.rst:506 +#: ../../library/unittest.rst:501 msgid "" "one can create an equivalent test case instance as follows, with optional " "set-up and tear-down methods::" msgstr "" -#: ../../library/unittest.rst:509 +#: ../../library/unittest.rst:504 msgid "" "testcase = unittest.FunctionTestCase(testSomething,\n" " setUp=makeSomethingDB,\n" @@ -925,7 +925,7 @@ msgstr "" " setUp=makeSomethingDB,\n" " tearDown=deleteSomethingDB)" -#: ../../library/unittest.rst:515 +#: ../../library/unittest.rst:510 msgid "" "Even though :class:`FunctionTestCase` can be used to quickly convert an " "existing test base over to a :mod:`!unittest`\\ -based system, this approach " @@ -933,7 +933,7 @@ msgid "" "subclasses will make future test refactorings infinitely easier." msgstr "" -#: ../../library/unittest.rst:520 +#: ../../library/unittest.rst:515 msgid "" "In some cases, the existing tests may have been written using the :mod:" "`doctest` module. If so, :mod:`doctest` provides a :class:`~doctest." @@ -941,11 +941,11 @@ msgid "" "instances from the existing :mod:`doctest`\\ -based tests." msgstr "" -#: ../../library/unittest.rst:529 +#: ../../library/unittest.rst:524 msgid "Skipping tests and expected failures" msgstr "" -#: ../../library/unittest.rst:533 +#: ../../library/unittest.rst:528 msgid "" "Unittest supports skipping individual test methods and even whole classes of " "tests. In addition, it supports marking a test as an \"expected failure,\" " @@ -953,7 +953,7 @@ msgid "" "on a :class:`TestResult`." msgstr "" -#: ../../library/unittest.rst:538 +#: ../../library/unittest.rst:533 msgid "" "Skipping a test is simply a matter of using the :deco:`skip` :term:" "`decorator` or one of its conditional variants, calling :meth:`TestCase." @@ -961,11 +961,11 @@ msgid "" "`SkipTest` directly." msgstr "" -#: ../../library/unittest.rst:542 +#: ../../library/unittest.rst:537 msgid "Basic skipping looks like this::" msgstr "" -#: ../../library/unittest.rst:544 +#: ../../library/unittest.rst:539 msgid "" "class MyTestCase(unittest.TestCase):\n" "\n" @@ -992,11 +992,11 @@ msgid "" " pass" msgstr "" -#: ../../library/unittest.rst:567 +#: ../../library/unittest.rst:562 msgid "This is the output of running the example above in verbose mode::" msgstr "" -#: ../../library/unittest.rst:569 +#: ../../library/unittest.rst:564 msgid "" "test_format (__main__.MyTestCase.test_format) ... skipped 'not supported in " "this library version'\n" @@ -1013,11 +1013,11 @@ msgid "" "OK (skipped=4)" msgstr "" -#: ../../library/unittest.rst:579 +#: ../../library/unittest.rst:574 msgid "Classes can be skipped just like methods::" msgstr "" -#: ../../library/unittest.rst:581 +#: ../../library/unittest.rst:576 msgid "" "@unittest.skip(\"showing class skipping\")\n" "class MySkippedTestCase(unittest.TestCase):\n" @@ -1025,17 +1025,17 @@ msgid "" " pass" msgstr "" -#: ../../library/unittest.rst:586 +#: ../../library/unittest.rst:581 msgid "" ":meth:`TestCase.setUp` can also skip the test. This is useful when a " "resource that needs to be set up is not available." msgstr "" -#: ../../library/unittest.rst:589 +#: ../../library/unittest.rst:584 msgid "Expected failures use the :deco:`expectedFailure` decorator. ::" msgstr "" -#: ../../library/unittest.rst:591 +#: ../../library/unittest.rst:586 msgid "" "class ExpectedFailureTestCase(unittest.TestCase):\n" " @unittest.expectedFailure\n" @@ -1047,14 +1047,14 @@ msgstr "" " def test_fail(self):\n" " self.assertEqual(1, 0, \"broken\")" -#: ../../library/unittest.rst:596 +#: ../../library/unittest.rst:591 msgid "" "It's easy to roll your own skipping decorators by making a decorator that " "calls :func:`skip` on the test when it wants it to be skipped. This " "decorator skips the test unless the passed object has a certain attribute::" msgstr "" -#: ../../library/unittest.rst:600 +#: ../../library/unittest.rst:595 msgid "" "def skipUnlessHasattr(obj, attr):\n" " if hasattr(obj, attr):\n" @@ -1066,27 +1066,27 @@ msgstr "" " return lambda func: func\n" " return unittest.skip(\"{!r} doesn't have {!r}\".format(obj, attr))" -#: ../../library/unittest.rst:605 +#: ../../library/unittest.rst:600 msgid "" "The following decorators and exception implement test skipping and expected " "failures:" msgstr "" -#: ../../library/unittest.rst:609 +#: ../../library/unittest.rst:604 msgid "" "Unconditionally skip the decorated test. *reason* should describe why the " "test is being skipped." msgstr "" -#: ../../library/unittest.rst:614 +#: ../../library/unittest.rst:609 msgid "Skip the decorated test if *condition* is true." msgstr "" -#: ../../library/unittest.rst:618 +#: ../../library/unittest.rst:613 msgid "Skip the decorated test unless *condition* is true." msgstr "" -#: ../../library/unittest.rst:622 +#: ../../library/unittest.rst:617 msgid "" "Mark the test as an expected failure or error. If the test fails or errors " "in the test function itself (rather than in one of the :dfn:`test fixture` " @@ -1094,17 +1094,17 @@ msgid "" "be considered a failure." msgstr "" -#: ../../library/unittest.rst:629 +#: ../../library/unittest.rst:624 msgid "This exception is raised to skip a test." msgstr "" -#: ../../library/unittest.rst:631 +#: ../../library/unittest.rst:626 msgid "" "Usually you can use :meth:`TestCase.skipTest` or one of the skipping " "decorators instead of raising this directly." msgstr "" -#: ../../library/unittest.rst:634 +#: ../../library/unittest.rst:629 msgid "" "Skipped tests will not have :meth:`~TestCase.setUp` or :meth:`~TestCase." "tearDown` run around them. Skipped classes will not have :meth:`~TestCase." @@ -1112,22 +1112,22 @@ msgid "" "have :func:`setUpModule` or :func:`tearDownModule` run." msgstr "" -#: ../../library/unittest.rst:642 +#: ../../library/unittest.rst:637 msgid "Distinguishing test iterations using subtests" msgstr "" -#: ../../library/unittest.rst:646 +#: ../../library/unittest.rst:641 msgid "" "When there are very small differences among your tests, for instance some " "parameters, unittest allows you to distinguish them inside the body of a " "test method using the :meth:`~TestCase.subTest` context manager." msgstr "" -#: ../../library/unittest.rst:650 +#: ../../library/unittest.rst:645 msgid "For example, the following test::" msgstr "舉例來說,以下測試: ::" -#: ../../library/unittest.rst:652 +#: ../../library/unittest.rst:647 msgid "" "class NumbersTest(unittest.TestCase):\n" "\n" @@ -1140,11 +1140,11 @@ msgid "" " self.assertEqual(i % 2, 0)" msgstr "" -#: ../../library/unittest.rst:662 +#: ../../library/unittest.rst:657 msgid "will produce the following output::" msgstr "會有以下輸出: ::" -#: ../../library/unittest.rst:664 +#: ../../library/unittest.rst:659 msgid "" "======================================================================\n" "FAIL: test_even (__main__.NumbersTest.test_even) (i=1)\n" @@ -1206,14 +1206,14 @@ msgstr "" " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" "AssertionError: 1 != 0" -#: ../../library/unittest.rst:694 +#: ../../library/unittest.rst:689 msgid "" "Without using a subtest, execution would stop after the first failure, and " "the error would be less easy to diagnose because the value of ``i`` wouldn't " "be displayed::" msgstr "" -#: ../../library/unittest.rst:698 +#: ../../library/unittest.rst:693 msgid "" "======================================================================\n" "FAIL: test_even (__main__.NumbersTest.test_even)\n" @@ -1231,19 +1231,19 @@ msgstr "" " self.assertEqual(i % 2, 0)\n" "AssertionError: 1 != 0" -#: ../../library/unittest.rst:710 +#: ../../library/unittest.rst:705 msgid "Classes and functions" msgstr "類別與函式" -#: ../../library/unittest.rst:712 +#: ../../library/unittest.rst:707 msgid "This section describes in depth the API of :mod:`!unittest`." msgstr "" -#: ../../library/unittest.rst:718 +#: ../../library/unittest.rst:713 msgid "Test cases" msgstr "" -#: ../../library/unittest.rst:722 +#: ../../library/unittest.rst:717 msgid "" "Instances of the :class:`TestCase` class represent the logical test units in " "the :mod:`!unittest` universe. This class is intended to be used as a base " @@ -1253,21 +1253,21 @@ msgid "" "report various kinds of failure." msgstr "" -#: ../../library/unittest.rst:729 +#: ../../library/unittest.rst:724 msgid "" "Each instance of :class:`TestCase` will run a single base method: the method " "named *methodName*. In most uses of :class:`TestCase`, you will neither " "change the *methodName* nor reimplement the default ``runTest()`` method." msgstr "" -#: ../../library/unittest.rst:734 +#: ../../library/unittest.rst:729 msgid "" ":class:`TestCase` can be instantiated successfully without providing a " "*methodName*. This makes it easier to experiment with :class:`TestCase` from " "the interactive interpreter." msgstr "" -#: ../../library/unittest.rst:739 +#: ../../library/unittest.rst:734 msgid "" ":class:`TestCase` instances provide three groups of methods: one group used " "to run the test, another used by the test implementation to check conditions " @@ -1275,11 +1275,11 @@ msgid "" "test itself to be gathered." msgstr "" -#: ../../library/unittest.rst:744 +#: ../../library/unittest.rst:739 msgid "Methods in the first group (running the test) are:" msgstr "" -#: ../../library/unittest.rst:748 +#: ../../library/unittest.rst:743 msgid "" "Method called to prepare the test fixture. This is called immediately " "before calling the test method; other than :exc:`AssertionError` or :exc:" @@ -1287,7 +1287,7 @@ msgid "" "rather than a test failure. The default implementation does nothing." msgstr "" -#: ../../library/unittest.rst:756 +#: ../../library/unittest.rst:751 msgid "" "Method called immediately after the test method has been called and the " "result recorded. This is called even if the test method raised an " @@ -1300,14 +1300,14 @@ msgid "" "The default implementation does nothing." msgstr "" -#: ../../library/unittest.rst:769 +#: ../../library/unittest.rst:764 msgid "" "A class method called before tests in an individual class are run. " "``setUpClass`` is called with the class as the only argument and must be " "decorated as a :deco:`classmethod`::" msgstr "" -#: ../../library/unittest.rst:773 +#: ../../library/unittest.rst:768 msgid "" "@classmethod\n" "def setUpClass(cls):\n" @@ -1317,18 +1317,18 @@ msgstr "" "def setUpClass(cls):\n" " ..." -#: ../../library/unittest.rst:777 ../../library/unittest.rst:792 +#: ../../library/unittest.rst:772 ../../library/unittest.rst:787 msgid "See `Class and Module Fixtures`_ for more details." msgstr "更多細節請見 `Class and Module Fixtures`_。" -#: ../../library/unittest.rst:784 +#: ../../library/unittest.rst:779 msgid "" "A class method called after tests in an individual class have run. " "``tearDownClass`` is called with the class as the only argument and must be " "decorated as a :deco:`classmethod`::" msgstr "" -#: ../../library/unittest.rst:788 +#: ../../library/unittest.rst:783 msgid "" "@classmethod\n" "def tearDownClass(cls):\n" @@ -1338,7 +1338,7 @@ msgstr "" "def tearDownClass(cls):\n" " ..." -#: ../../library/unittest.rst:799 +#: ../../library/unittest.rst:794 msgid "" "Run the test, collecting the result into the :class:`TestResult` object " "passed as *result*. If *result* is omitted or ``None``, a temporary result " @@ -1346,207 +1346,207 @@ msgid "" "used. The result object is returned to :meth:`run`'s caller." msgstr "" -#: ../../library/unittest.rst:805 +#: ../../library/unittest.rst:800 msgid "" "The same effect may be had by simply calling the :class:`TestCase` instance." msgstr "" -#: ../../library/unittest.rst:808 +#: ../../library/unittest.rst:803 msgid "" "Previous versions of ``run`` did not return the result. Neither did calling " "an instance." msgstr "" -#: ../../library/unittest.rst:814 +#: ../../library/unittest.rst:809 msgid "" "Calling this during a test method or :meth:`setUp` skips the current test. " "See :ref:`unittest-skipping` for more information." msgstr "" -#: ../../library/unittest.rst:822 +#: ../../library/unittest.rst:817 msgid "" "Return a context manager which executes the enclosed code block as a " "subtest. *msg* and *params* are optional, arbitrary values which are " "displayed whenever a subtest fails, allowing you to identify them clearly." msgstr "" -#: ../../library/unittest.rst:827 +#: ../../library/unittest.rst:822 msgid "" "A test case can contain any number of subtest declarations, and they can be " "arbitrarily nested." msgstr "" -#: ../../library/unittest.rst:830 +#: ../../library/unittest.rst:825 msgid "See :ref:`subtests` for more information." msgstr "更多資訊請見 :ref:`subtests`。" -#: ../../library/unittest.rst:837 +#: ../../library/unittest.rst:832 msgid "" "Run the test without collecting the result. This allows exceptions raised " "by the test to be propagated to the caller, and can be used to support " "running tests under a debugger." msgstr "" -#: ../../library/unittest.rst:843 +#: ../../library/unittest.rst:838 msgid "" "The :class:`TestCase` class provides several assert methods to check for and " "report failures. The following table lists the most commonly used methods " "(see the tables below for more assert methods):" msgstr "" -#: ../../library/unittest.rst:848 ../../library/unittest.rst:984 -#: ../../library/unittest.rst:1198 ../../library/unittest.rst:1368 +#: ../../library/unittest.rst:843 ../../library/unittest.rst:979 +#: ../../library/unittest.rst:1223 ../../library/unittest.rst:1393 msgid "Method" msgstr "方法" -#: ../../library/unittest.rst:848 ../../library/unittest.rst:984 -#: ../../library/unittest.rst:1198 +#: ../../library/unittest.rst:843 ../../library/unittest.rst:979 +#: ../../library/unittest.rst:1223 msgid "Checks that" msgstr "" -#: ../../library/unittest.rst:848 ../../library/unittest.rst:984 -#: ../../library/unittest.rst:1198 ../../library/unittest.rst:1368 +#: ../../library/unittest.rst:843 ../../library/unittest.rst:979 +#: ../../library/unittest.rst:1223 ../../library/unittest.rst:1393 msgid "New in" msgstr "" -#: ../../library/unittest.rst:850 +#: ../../library/unittest.rst:845 msgid ":meth:`assertEqual(a, b) `" msgstr ":meth:`assertEqual(a, b) `" -#: ../../library/unittest.rst:850 +#: ../../library/unittest.rst:845 msgid "``a == b``" msgstr "``a == b``" -#: ../../library/unittest.rst:853 +#: ../../library/unittest.rst:848 msgid ":meth:`assertNotEqual(a, b) `" msgstr ":meth:`assertNotEqual(a, b) `" -#: ../../library/unittest.rst:853 +#: ../../library/unittest.rst:848 msgid "``a != b``" msgstr "``a != b``" -#: ../../library/unittest.rst:856 +#: ../../library/unittest.rst:851 msgid ":meth:`assertTrue(x) `" msgstr ":meth:`assertTrue(x) `" -#: ../../library/unittest.rst:856 +#: ../../library/unittest.rst:851 msgid "``bool(x) is True``" msgstr "``bool(x) is True``" -#: ../../library/unittest.rst:859 +#: ../../library/unittest.rst:854 msgid ":meth:`assertFalse(x) `" msgstr ":meth:`assertFalse(x) `" -#: ../../library/unittest.rst:859 +#: ../../library/unittest.rst:854 msgid "``bool(x) is False``" msgstr "``bool(x) is False``" -#: ../../library/unittest.rst:862 +#: ../../library/unittest.rst:857 msgid ":meth:`assertIs(a, b) `" msgstr ":meth:`assertIs(a, b) `" -#: ../../library/unittest.rst:862 +#: ../../library/unittest.rst:857 msgid "``a is b``" msgstr "``a is b``" -#: ../../library/unittest.rst:862 ../../library/unittest.rst:865 -#: ../../library/unittest.rst:868 ../../library/unittest.rst:871 -#: ../../library/unittest.rst:874 ../../library/unittest.rst:877 -#: ../../library/unittest.rst:989 ../../library/unittest.rst:1206 -#: ../../library/unittest.rst:1209 ../../library/unittest.rst:1212 -#: ../../library/unittest.rst:1215 ../../library/unittest.rst:1218 -#: ../../library/unittest.rst:1370 ../../library/unittest.rst:1373 -#: ../../library/unittest.rst:1376 ../../library/unittest.rst:1379 -#: ../../library/unittest.rst:1382 ../../library/unittest.rst:1385 +#: ../../library/unittest.rst:857 ../../library/unittest.rst:860 +#: ../../library/unittest.rst:863 ../../library/unittest.rst:866 +#: ../../library/unittest.rst:869 ../../library/unittest.rst:872 +#: ../../library/unittest.rst:984 ../../library/unittest.rst:1231 +#: ../../library/unittest.rst:1234 ../../library/unittest.rst:1237 +#: ../../library/unittest.rst:1240 ../../library/unittest.rst:1243 +#: ../../library/unittest.rst:1395 ../../library/unittest.rst:1398 +#: ../../library/unittest.rst:1401 ../../library/unittest.rst:1404 +#: ../../library/unittest.rst:1407 ../../library/unittest.rst:1410 msgid "3.1" msgstr "3.1" -#: ../../library/unittest.rst:865 +#: ../../library/unittest.rst:860 msgid ":meth:`assertIsNot(a, b) `" msgstr ":meth:`assertIsNot(a, b) `" -#: ../../library/unittest.rst:865 +#: ../../library/unittest.rst:860 msgid "``a is not b``" msgstr "``a is not b``" -#: ../../library/unittest.rst:868 +#: ../../library/unittest.rst:863 msgid ":meth:`assertIsNone(x) `" msgstr ":meth:`assertIsNone(x) `" -#: ../../library/unittest.rst:868 +#: ../../library/unittest.rst:863 msgid "``x is None``" msgstr "``x is None``" -#: ../../library/unittest.rst:871 +#: ../../library/unittest.rst:866 msgid ":meth:`assertIsNotNone(x) `" msgstr ":meth:`assertIsNotNone(x) `" -#: ../../library/unittest.rst:871 +#: ../../library/unittest.rst:866 msgid "``x is not None``" msgstr "``x is not None``" -#: ../../library/unittest.rst:874 +#: ../../library/unittest.rst:869 msgid ":meth:`assertIn(a, b) `" msgstr ":meth:`assertIn(a, b) `" -#: ../../library/unittest.rst:874 +#: ../../library/unittest.rst:869 msgid "``a in b``" msgstr "``a in b``" -#: ../../library/unittest.rst:877 +#: ../../library/unittest.rst:872 msgid ":meth:`assertNotIn(a, b) `" msgstr ":meth:`assertNotIn(a, b) `" -#: ../../library/unittest.rst:877 +#: ../../library/unittest.rst:872 msgid "``a not in b``" msgstr "``a not in b``" -#: ../../library/unittest.rst:880 +#: ../../library/unittest.rst:875 msgid ":meth:`assertIsInstance(a, b) `" msgstr ":meth:`assertIsInstance(a, b) `" -#: ../../library/unittest.rst:880 +#: ../../library/unittest.rst:875 msgid "``isinstance(a, b)``" msgstr "``isinstance(a, b)``" -#: ../../library/unittest.rst:880 ../../library/unittest.rst:883 -#: ../../library/unittest.rst:992 ../../library/unittest.rst:995 -#: ../../library/unittest.rst:1221 ../../library/unittest.rst:1224 +#: ../../library/unittest.rst:875 ../../library/unittest.rst:878 +#: ../../library/unittest.rst:987 ../../library/unittest.rst:990 +#: ../../library/unittest.rst:1246 ../../library/unittest.rst:1249 msgid "3.2" msgstr "3.2" -#: ../../library/unittest.rst:883 +#: ../../library/unittest.rst:878 msgid ":meth:`assertNotIsInstance(a, b) `" msgstr ":meth:`assertNotIsInstance(a, b) `" -#: ../../library/unittest.rst:883 +#: ../../library/unittest.rst:878 msgid "``not isinstance(a, b)``" msgstr "``not isinstance(a, b)``" -#: ../../library/unittest.rst:886 +#: ../../library/unittest.rst:881 msgid ":meth:`assertIsSubclass(a, b) `" msgstr ":meth:`assertIsSubclass(a, b) `" -#: ../../library/unittest.rst:886 +#: ../../library/unittest.rst:881 msgid "``issubclass(a, b)``" msgstr "``issubclass(a, b)``" -#: ../../library/unittest.rst:886 ../../library/unittest.rst:889 -#: ../../library/unittest.rst:1228 ../../library/unittest.rst:1231 -#: ../../library/unittest.rst:1234 ../../library/unittest.rst:1237 -#: ../../library/unittest.rst:1240 ../../library/unittest.rst:1243 +#: ../../library/unittest.rst:881 ../../library/unittest.rst:884 +#: ../../library/unittest.rst:1253 ../../library/unittest.rst:1256 +#: ../../library/unittest.rst:1259 ../../library/unittest.rst:1262 +#: ../../library/unittest.rst:1265 ../../library/unittest.rst:1268 msgid "3.14" msgstr "3.14" -#: ../../library/unittest.rst:889 +#: ../../library/unittest.rst:884 msgid ":meth:`assertNotIsSubclass(a, b) `" msgstr ":meth:`assertNotIsSubclass(a, b) `" -#: ../../library/unittest.rst:889 +#: ../../library/unittest.rst:884 msgid "``not issubclass(a, b)``" msgstr "``not issubclass(a, b)``" -#: ../../library/unittest.rst:893 +#: ../../library/unittest.rst:888 msgid "" "All the assert methods accept a *msg* argument that, if specified, is used " "as the error message on failure (see also :data:`longMessage`). Note that " @@ -1555,13 +1555,13 @@ msgid "" "they are used as a context manager." msgstr "" -#: ../../library/unittest.rst:901 +#: ../../library/unittest.rst:896 msgid "" "Test that *first* and *second* are equal. If the values do not compare " "equal, the test will fail." msgstr "" -#: ../../library/unittest.rst:904 +#: ../../library/unittest.rst:899 msgid "" "In addition, if *first* and *second* are the exact same type and one of " "list, tuple, dict, set, frozenset or str or any type that a subclass " @@ -1571,27 +1571,27 @@ msgid "" "methods>`)." msgstr "" -#: ../../library/unittest.rst:911 +#: ../../library/unittest.rst:906 msgid "Added the automatic calling of type-specific equality function." msgstr "" -#: ../../library/unittest.rst:914 +#: ../../library/unittest.rst:909 msgid "" ":meth:`assertMultiLineEqual` added as the default type equality function for " "comparing strings." msgstr "" -#: ../../library/unittest.rst:921 +#: ../../library/unittest.rst:916 msgid "" "Test that *first* and *second* are not equal. If the values do compare " "equal, the test will fail." msgstr "" -#: ../../library/unittest.rst:927 +#: ../../library/unittest.rst:922 msgid "Test that *expr* is true (or false)." msgstr "" -#: ../../library/unittest.rst:929 +#: ../../library/unittest.rst:924 msgid "" "Note that this is equivalent to ``bool(expr) is True`` and not to ``expr is " "True`` (use ``assertIs(expr, True)`` for the latter). This method should " @@ -1600,47 +1600,47 @@ msgid "" "provide a better error message in case of failure." msgstr "" -#: ../../library/unittest.rst:939 +#: ../../library/unittest.rst:934 msgid "Test that *first* and *second* are (or are not) the same object." msgstr "" -#: ../../library/unittest.rst:947 +#: ../../library/unittest.rst:942 msgid "Test that *expr* is (or is not) ``None``." msgstr "" -#: ../../library/unittest.rst:955 +#: ../../library/unittest.rst:950 msgid "Test that *member* is (or is not) in *container*." msgstr "" -#: ../../library/unittest.rst:963 +#: ../../library/unittest.rst:958 msgid "" "Test that *obj* is (or is not) an instance of *cls* (which can be a class or " "a tuple of classes, as supported by :func:`isinstance`). To check for the " "exact type, use :func:`assertIs(type(obj), cls) `." msgstr "" -#: ../../library/unittest.rst:973 +#: ../../library/unittest.rst:968 msgid "" "Test that *cls* is (or is not) a subclass of *superclass* (which can be a " "class or a tuple of classes, as supported by :func:`issubclass`). To check " "for the exact type, use :func:`assertIs(cls, superclass) `." msgstr "" -#: ../../library/unittest.rst:980 +#: ../../library/unittest.rst:975 msgid "" "It is also possible to check the production of exceptions, warnings, and log " "messages using the following methods:" msgstr "" -#: ../../library/unittest.rst:986 +#: ../../library/unittest.rst:981 msgid ":meth:`assertRaises(exc, fun, *args, **kwds) `" msgstr ":meth:`assertRaises(exc, fun, *args, **kwds) `" -#: ../../library/unittest.rst:986 +#: ../../library/unittest.rst:981 msgid "``fun(*args, **kwds)`` raises *exc*" msgstr "``fun(*args, **kwds)`` 會引發 *exc*" -#: ../../library/unittest.rst:989 +#: ../../library/unittest.rst:984 msgid "" ":meth:`assertRaisesRegex(exc, r, fun, *args, **kwds) `" @@ -1648,57 +1648,57 @@ msgstr "" ":meth:`assertRaisesRegex(exc, r, fun, *args, **kwds) `" -#: ../../library/unittest.rst:989 +#: ../../library/unittest.rst:984 msgid "``fun(*args, **kwds)`` raises *exc* and the message matches regex *r*" msgstr "" -#: ../../library/unittest.rst:992 +#: ../../library/unittest.rst:987 msgid ":meth:`assertWarns(warn, fun, *args, **kwds) `" msgstr ":meth:`assertWarns(warn, fun, *args, **kwds) `" -#: ../../library/unittest.rst:992 +#: ../../library/unittest.rst:987 msgid "``fun(*args, **kwds)`` raises *warn*" msgstr "``fun(*args, **kwds)`` 會引發 *warn*" -#: ../../library/unittest.rst:995 +#: ../../library/unittest.rst:990 msgid "" ":meth:`assertWarnsRegex(warn, r, fun, *args, **kwds) `" msgstr "" -#: ../../library/unittest.rst:995 +#: ../../library/unittest.rst:990 msgid "``fun(*args, **kwds)`` raises *warn* and the message matches regex *r*" msgstr "" -#: ../../library/unittest.rst:998 +#: ../../library/unittest.rst:993 msgid ":meth:`assertLogs(logger, level) `" msgstr ":meth:`assertLogs(logger, level) `" -#: ../../library/unittest.rst:998 +#: ../../library/unittest.rst:993 msgid "The ``with`` block logs on *logger* with minimum *level*" msgstr "" -#: ../../library/unittest.rst:998 +#: ../../library/unittest.rst:993 msgid "3.4" msgstr "3.4" -#: ../../library/unittest.rst:1001 +#: ../../library/unittest.rst:996 msgid ":meth:`assertNoLogs(logger, level) `" msgstr ":meth:`assertNoLogs(logger, level) `" -#: ../../library/unittest.rst:1001 +#: ../../library/unittest.rst:996 msgid "The ``with`` block does not log on" msgstr "" -#: ../../library/unittest.rst:1002 +#: ../../library/unittest.rst:997 msgid "*logger* with minimum *level*" msgstr "" -#: ../../library/unittest.rst:1001 +#: ../../library/unittest.rst:996 msgid "3.10" msgstr "3.10" -#: ../../library/unittest.rst:1008 +#: ../../library/unittest.rst:1003 msgid "" "Test that an exception is raised when *callable* is called with any " "positional or keyword arguments that are also passed to :meth:" @@ -1708,14 +1708,14 @@ msgid "" "be passed as *exception*." msgstr "" -#: ../../library/unittest.rst:1015 +#: ../../library/unittest.rst:1010 msgid "" "If only the *exception* and possibly the *msg* arguments are given, return a " "context manager so that the code under test can be written inline rather " "than as a function::" msgstr "" -#: ../../library/unittest.rst:1019 +#: ../../library/unittest.rst:1014 msgid "" "with self.assertRaises(SomeException):\n" " do_something()" @@ -1723,20 +1723,20 @@ msgstr "" "with self.assertRaises(SomeException):\n" " do_something()" -#: ../../library/unittest.rst:1022 +#: ../../library/unittest.rst:1017 msgid "" "When used as a context manager, :meth:`assertRaises` accepts the additional " "keyword argument *msg*." msgstr "" -#: ../../library/unittest.rst:1025 +#: ../../library/unittest.rst:1020 msgid "" "The context manager will store the caught exception object in its :attr:`!" "exception` attribute. This can be useful if the intention is to perform " "additional checks on the exception raised::" msgstr "" -#: ../../library/unittest.rst:1029 +#: ../../library/unittest.rst:1024 msgid "" "with self.assertRaises(SomeException) as cm:\n" " do_something()\n" @@ -1750,20 +1750,20 @@ msgstr "" "the_exception = cm.exception\n" "self.assertEqual(the_exception.error_code, 3)" -#: ../../library/unittest.rst:1035 +#: ../../library/unittest.rst:1030 msgid "Added the ability to use :meth:`assertRaises` as a context manager." msgstr "新增 :meth:`assertRaises` 可作為情境管理器使用的能力。" -#: ../../library/unittest.rst:1038 +#: ../../library/unittest.rst:1033 msgid "Added the :attr:`!exception` attribute." msgstr "新增 :attr:`!exception` 屬性。" -#: ../../library/unittest.rst:1041 ../../library/unittest.rst:1067 -#: ../../library/unittest.rst:1108 ../../library/unittest.rst:1131 +#: ../../library/unittest.rst:1036 ../../library/unittest.rst:1062 +#: ../../library/unittest.rst:1110 ../../library/unittest.rst:1144 msgid "Added the *msg* keyword argument when used as a context manager." msgstr "新增作為情境管理器使用時的 *msg* 引數。" -#: ../../library/unittest.rst:1048 +#: ../../library/unittest.rst:1043 msgid "" "Like :meth:`assertRaises` but also tests that *regex* matches on the string " "representation of the raised exception. *regex* may be a regular expression " @@ -1771,7 +1771,7 @@ msgid "" "`re.search`. Examples::" msgstr "" -#: ../../library/unittest.rst:1053 +#: ../../library/unittest.rst:1048 msgid "" "self.assertRaisesRegex(ValueError, \"invalid literal for.*XYZ'$\",\n" " int, 'XYZ')" @@ -1779,11 +1779,11 @@ msgstr "" "self.assertRaisesRegex(ValueError, \"invalid literal for.*XYZ'$\",\n" " int, 'XYZ')" -#: ../../library/unittest.rst:1056 ../../library/unittest.rst:1124 +#: ../../library/unittest.rst:1051 ../../library/unittest.rst:1130 msgid "or::" msgstr "或是: ::" -#: ../../library/unittest.rst:1058 +#: ../../library/unittest.rst:1053 msgid "" "with self.assertRaisesRegex(ValueError, 'literal'):\n" " int('XYZ')" @@ -1791,15 +1791,15 @@ msgstr "" "with self.assertRaisesRegex(ValueError, 'literal'):\n" " int('XYZ')" -#: ../../library/unittest.rst:1061 +#: ../../library/unittest.rst:1056 msgid "Added under the name ``assertRaisesRegexp``." msgstr "以 ``assertRaisesRegexp`` 為名新增。" -#: ../../library/unittest.rst:1064 +#: ../../library/unittest.rst:1059 msgid "Renamed to :meth:`assertRaisesRegex`." msgstr "重新命名為 :meth:`assertRaisesRegex`。" -#: ../../library/unittest.rst:1074 +#: ../../library/unittest.rst:1069 msgid "" "Test that a warning is triggered when *callable* is called with any " "positional or keyword arguments that are also passed to :meth:" @@ -1808,14 +1808,14 @@ msgid "" "tuple containing the warning classes may be passed as *warnings*." msgstr "" -#: ../../library/unittest.rst:1081 +#: ../../library/unittest.rst:1076 msgid "" "If only the *warning* and possibly the *msg* arguments are given, return a " "context manager so that the code under test can be written inline rather " "than as a function::" msgstr "" -#: ../../library/unittest.rst:1085 +#: ../../library/unittest.rst:1080 msgid "" "with self.assertWarns(SomeWarning):\n" " do_something()" @@ -1823,13 +1823,13 @@ msgstr "" "with self.assertWarns(SomeWarning):\n" " do_something()" -#: ../../library/unittest.rst:1088 +#: ../../library/unittest.rst:1083 msgid "" "When used as a context manager, :meth:`assertWarns` accepts the additional " "keyword argument *msg*." msgstr "" -#: ../../library/unittest.rst:1091 +#: ../../library/unittest.rst:1086 msgid "" "The context manager will store the caught warning object in its :attr:`!" "warning` attribute, and the source line which triggered the warnings in the :" @@ -1837,7 +1837,7 @@ msgid "" "intention is to perform additional checks on the warning caught::" msgstr "" -#: ../../library/unittest.rst:1097 +#: ../../library/unittest.rst:1092 msgid "" "with self.assertWarns(SomeWarning) as cm:\n" " do_something()\n" @@ -1851,13 +1851,35 @@ msgstr "" "self.assertIn('myfile.py', cm.filename)\n" "self.assertEqual(320, cm.lineno)" -#: ../../library/unittest.rst:1103 +#: ../../library/unittest.rst:1098 ../../library/unittest.rst:1135 +msgid "" +"The context managers can be nested to test that multiple different warnings " +"are emitted::" +msgstr "" + +#: ../../library/unittest.rst:1101 +msgid "" +"with (self.assertWarns(SomeWarning),\n" +" self.assertWarns(OtherWarning)):\n" +" do_something()" +msgstr "" +"with (self.assertWarns(SomeWarning),\n" +" self.assertWarns(OtherWarning)):\n" +" do_something()" + +#: ../../library/unittest.rst:1105 msgid "" "This method works regardless of the warning filters in place when it is " "called." msgstr "" -#: ../../library/unittest.rst:1115 +#: ../../library/unittest.rst:1113 +msgid "" +"Warnings that do not match the specified category are no longer swallowed. " +"Nested context managers are now supported." +msgstr "" + +#: ../../library/unittest.rst:1121 msgid "" "Like :meth:`assertWarns` but also tests that *regex* matches on the message " "of the triggered warning. *regex* may be a regular expression object or a " @@ -1865,7 +1887,7 @@ msgid "" "search`. Example::" msgstr "" -#: ../../library/unittest.rst:1120 +#: ../../library/unittest.rst:1126 msgid "" "self.assertWarnsRegex(DeprecationWarning,\n" " r'legacy_function\\(\\) is deprecated',\n" @@ -1875,7 +1897,7 @@ msgstr "" " r'legacy_function\\(\\) is deprecated',\n" " legacy_function, 'XYZ')" -#: ../../library/unittest.rst:1126 +#: ../../library/unittest.rst:1132 msgid "" "with self.assertWarnsRegex(RuntimeWarning, 'unsafe frobnicating'):\n" " frobnicate('/etc/passwd')" @@ -1883,13 +1905,29 @@ msgstr "" "with self.assertWarnsRegex(RuntimeWarning, 'unsafe frobnicating'):\n" " frobnicate('/etc/passwd')" -#: ../../library/unittest.rst:1136 +#: ../../library/unittest.rst:1138 +msgid "" +"with (self.assertWarns(SomeWarning, regex1),\n" +" self.assertWarns(OtherWarning, regex2)):\n" +" do_something()" +msgstr "" +"with (self.assertWarns(SomeWarning, regex1),\n" +" self.assertWarns(OtherWarning, regex2)):\n" +" do_something()" + +#: ../../library/unittest.rst:1147 +msgid "" +"Warnings that do not match the specified category or regex are no longer " +"swallowed. Nested context managers are now supported." +msgstr "" + +#: ../../library/unittest.rst:1154 msgid "" "A context manager to test that at least one message is logged on the " "*logger* or one of its children, with at least the given *level*." msgstr "" -#: ../../library/unittest.rst:1140 +#: ../../library/unittest.rst:1158 msgid "" "If given, *logger* should be a :class:`logging.Logger` object or a :class:" "`str` giving the name of a logger. The default is the root logger, which " @@ -1897,41 +1935,48 @@ msgid "" "descendent logger." msgstr "" -#: ../../library/unittest.rst:1145 ../../library/unittest.rst:1186 +#: ../../library/unittest.rst:1163 ../../library/unittest.rst:1211 msgid "" "If given, *level* should be either a numeric logging level or its string " "equivalent (for example either ``\"ERROR\"`` or :const:`logging.ERROR`). " "The default is :const:`logging.INFO`." msgstr "" -#: ../../library/unittest.rst:1149 +#: ../../library/unittest.rst:1167 +msgid "" +"If given, *formatter* should be a :class:`logging.Formatter` object. The " +"default is a formatter with format string ``\"%(levelname)s:%(name)s:" +"%(message)s\"``" +msgstr "" + +#: ../../library/unittest.rst:1171 msgid "" "The test passes if at least one message emitted inside the ``with`` block " "matches the *logger* and *level* conditions, otherwise it fails." msgstr "" -#: ../../library/unittest.rst:1152 +#: ../../library/unittest.rst:1174 msgid "" "The object returned by the context manager is a recording helper which keeps " "tracks of the matching log messages. It has two attributes:" msgstr "" -#: ../../library/unittest.rst:1158 +#: ../../library/unittest.rst:1180 msgid "" "A list of :class:`logging.LogRecord` objects of the matching log messages." msgstr "" -#: ../../library/unittest.rst:1163 +#: ../../library/unittest.rst:1185 msgid "" "A list of :class:`str` objects with the formatted output of matching " "messages." msgstr "" -#: ../../library/unittest.rst:1166 +#: ../../library/unittest.rst:1188 msgid "Example::" msgstr "範例: ::" -#: ../../library/unittest.rst:1168 +#: ../../library/unittest.rst:1190 msgid "" "with self.assertLogs('foo', level='INFO') as cm:\n" " logging.getLogger('foo').info('first message')\n" @@ -1945,150 +1990,154 @@ msgstr "" "self.assertEqual(cm.output, ['INFO:foo:first message',\n" " 'ERROR:foo.bar:second message'])" -#: ../../library/unittest.rst:1178 +#: ../../library/unittest.rst:1198 +msgid "Now accepts a *formatter* to control how messages are formatted." +msgstr "" + +#: ../../library/unittest.rst:1203 msgid "" "A context manager to test that no messages are logged on the *logger* or one " "of its children, with at least the given *level*." msgstr "" -#: ../../library/unittest.rst:1182 +#: ../../library/unittest.rst:1207 msgid "" "If given, *logger* should be a :class:`logging.Logger` object or a :class:" "`str` giving the name of a logger. The default is the root logger, which " "will catch all messages." msgstr "" -#: ../../library/unittest.rst:1190 +#: ../../library/unittest.rst:1215 msgid "" "Unlike :meth:`assertLogs`, nothing will be returned by the context manager." msgstr "" -#: ../../library/unittest.rst:1195 +#: ../../library/unittest.rst:1220 msgid "" "There are also other methods used to perform more specific checks, such as:" msgstr "" -#: ../../library/unittest.rst:1200 +#: ../../library/unittest.rst:1225 msgid ":meth:`assertAlmostEqual(a, b) `" msgstr ":meth:`assertAlmostEqual(a, b) `" -#: ../../library/unittest.rst:1200 +#: ../../library/unittest.rst:1225 msgid "``round(a-b, 7) == 0``" msgstr "``round(a-b, 7) == 0``" -#: ../../library/unittest.rst:1203 +#: ../../library/unittest.rst:1228 msgid ":meth:`assertNotAlmostEqual(a, b) `" msgstr ":meth:`assertNotAlmostEqual(a, b) `" -#: ../../library/unittest.rst:1203 +#: ../../library/unittest.rst:1228 msgid "``round(a-b, 7) != 0``" msgstr "``round(a-b, 7) != 0``" -#: ../../library/unittest.rst:1206 +#: ../../library/unittest.rst:1231 msgid ":meth:`assertGreater(a, b) `" msgstr ":meth:`assertGreater(a, b) `" -#: ../../library/unittest.rst:1206 +#: ../../library/unittest.rst:1231 msgid "``a > b``" msgstr "``a > b``" -#: ../../library/unittest.rst:1209 +#: ../../library/unittest.rst:1234 msgid ":meth:`assertGreaterEqual(a, b) `" msgstr ":meth:`assertGreaterEqual(a, b) `" -#: ../../library/unittest.rst:1209 +#: ../../library/unittest.rst:1234 msgid "``a >= b``" msgstr "``a >= b``" -#: ../../library/unittest.rst:1212 +#: ../../library/unittest.rst:1237 msgid ":meth:`assertLess(a, b) `" msgstr ":meth:`assertLess(a, b) `" -#: ../../library/unittest.rst:1212 +#: ../../library/unittest.rst:1237 msgid "``a < b``" msgstr "``a < b``" -#: ../../library/unittest.rst:1215 +#: ../../library/unittest.rst:1240 msgid ":meth:`assertLessEqual(a, b) `" msgstr ":meth:`assertLessEqual(a, b) `" -#: ../../library/unittest.rst:1215 +#: ../../library/unittest.rst:1240 msgid "``a <= b``" msgstr "``a <= b``" -#: ../../library/unittest.rst:1218 +#: ../../library/unittest.rst:1243 msgid ":meth:`assertRegex(s, r) `" msgstr ":meth:`assertRegex(s, r) `" -#: ../../library/unittest.rst:1218 +#: ../../library/unittest.rst:1243 msgid "``r.search(s)``" msgstr "``r.search(s)``" -#: ../../library/unittest.rst:1221 +#: ../../library/unittest.rst:1246 msgid ":meth:`assertNotRegex(s, r) `" msgstr ":meth:`assertNotRegex(s, r) `" -#: ../../library/unittest.rst:1221 +#: ../../library/unittest.rst:1246 msgid "``not r.search(s)``" msgstr "``not r.search(s)``" -#: ../../library/unittest.rst:1224 +#: ../../library/unittest.rst:1249 msgid ":meth:`assertCountEqual(a, b) `" msgstr ":meth:`assertCountEqual(a, b) `" -#: ../../library/unittest.rst:1224 +#: ../../library/unittest.rst:1249 msgid "*a* contains the same elements as *b*, regardless of their order." msgstr "" -#: ../../library/unittest.rst:1228 +#: ../../library/unittest.rst:1253 msgid ":meth:`assertStartsWith(a, b) `" msgstr ":meth:`assertStartsWith(a, b) `" -#: ../../library/unittest.rst:1228 +#: ../../library/unittest.rst:1253 msgid "``a.startswith(b)``" msgstr "``a.startswith(b)``" -#: ../../library/unittest.rst:1231 +#: ../../library/unittest.rst:1256 msgid ":meth:`assertNotStartsWith(a, b) `" msgstr ":meth:`assertNotStartsWith(a, b) `" -#: ../../library/unittest.rst:1231 +#: ../../library/unittest.rst:1256 msgid "``not a.startswith(b)``" msgstr "``not a.startswith(b)``" -#: ../../library/unittest.rst:1234 +#: ../../library/unittest.rst:1259 msgid ":meth:`assertEndsWith(a, b) `" msgstr ":meth:`assertEndsWith(a, b) `" -#: ../../library/unittest.rst:1234 +#: ../../library/unittest.rst:1259 msgid "``a.endswith(b)``" msgstr "``a.endswith(b)``" -#: ../../library/unittest.rst:1237 +#: ../../library/unittest.rst:1262 msgid ":meth:`assertNotEndsWith(a, b) `" msgstr ":meth:`assertNotEndsWith(a, b) `" -#: ../../library/unittest.rst:1237 +#: ../../library/unittest.rst:1262 msgid "``not a.endswith(b)``" msgstr "``not a.endswith(b)``" -#: ../../library/unittest.rst:1240 +#: ../../library/unittest.rst:1265 msgid ":meth:`assertHasAttr(a, b) `" msgstr ":meth:`assertHasAttr(a, b) `" -#: ../../library/unittest.rst:1240 +#: ../../library/unittest.rst:1265 msgid "``hasattr(a, b)``" msgstr "``hasattr(a, b)``" -#: ../../library/unittest.rst:1243 +#: ../../library/unittest.rst:1268 msgid ":meth:`assertNotHasAttr(a, b) `" msgstr ":meth:`assertNotHasAttr(a, b) `" -#: ../../library/unittest.rst:1243 +#: ../../library/unittest.rst:1268 msgid "``not hasattr(a, b)``" msgstr "``not hasattr(a, b)``" -#: ../../library/unittest.rst:1251 +#: ../../library/unittest.rst:1276 msgid "" "Test that *first* and *second* are approximately (or not approximately) " "equal by computing the difference, rounding to the given number of decimal " @@ -2097,30 +2146,30 @@ msgid "" "`round` function) and not *significant digits*." msgstr "" -#: ../../library/unittest.rst:1257 +#: ../../library/unittest.rst:1282 msgid "" "If *delta* is supplied instead of *places* then the difference between " "*first* and *second* must be less or equal to (or greater than) *delta*." msgstr "" -#: ../../library/unittest.rst:1260 +#: ../../library/unittest.rst:1285 msgid "Supplying both *delta* and *places* raises a :exc:`TypeError`." msgstr "" -#: ../../library/unittest.rst:1262 +#: ../../library/unittest.rst:1287 msgid "" ":meth:`assertAlmostEqual` automatically considers almost equal objects that " "compare equal. :meth:`assertNotAlmostEqual` automatically fails if the " "objects compare equal. Added the *delta* keyword argument." msgstr "" -#: ../../library/unittest.rst:1273 +#: ../../library/unittest.rst:1298 msgid "" "Test that *first* is respectively >, >=, < or <= than *second* depending on " "the method name. If not, the test will fail::" msgstr "" -#: ../../library/unittest.rst:1276 +#: ../../library/unittest.rst:1301 msgid "" ">>> self.assertGreaterEqual(3, 4)\n" "AssertionError: \"3\" unexpectedly not greater than or equal to \"4\"" @@ -2128,7 +2177,7 @@ msgstr "" ">>> self.assertGreaterEqual(3, 4)\n" "AssertionError: \"3\" unexpectedly not greater than or equal to \"4\"" -#: ../../library/unittest.rst:1285 +#: ../../library/unittest.rst:1310 msgid "" "Test that a *regex* search matches (or does not match) *text*. In case of " "failure, the error message will include the pattern and the *text* (or the " @@ -2137,28 +2186,28 @@ msgid "" "suitable for use by :func:`re.search`." msgstr "" -#: ../../library/unittest.rst:1291 +#: ../../library/unittest.rst:1316 msgid "Added under the name ``assertRegexpMatches``." msgstr "以 ``assertRegexpMatches`` 為名新增。" -#: ../../library/unittest.rst:1293 +#: ../../library/unittest.rst:1318 msgid "" "The method ``assertRegexpMatches()`` has been renamed to :meth:`." "assertRegex`." msgstr "``assertRegexpMatches()`` 方法已重新命名為 :meth:`.assertRegex`。" -#: ../../library/unittest.rst:1296 +#: ../../library/unittest.rst:1321 msgid ":meth:`.assertNotRegex`." msgstr ":meth:`.assertNotRegex`。" -#: ../../library/unittest.rst:1302 +#: ../../library/unittest.rst:1327 msgid "" "Test that sequence *first* contains the same elements as *second*, " "regardless of their order. When they don't, an error message listing the " "differences between the sequences will be generated." msgstr "" -#: ../../library/unittest.rst:1306 +#: ../../library/unittest.rst:1331 msgid "" "Duplicate elements are *not* ignored when comparing *first* and *second*. It " "verifies whether each element has the same count in both sequences. " @@ -2166,23 +2215,23 @@ msgid "" "but works with sequences of unhashable objects as well." msgstr "" -#: ../../library/unittest.rst:1318 +#: ../../library/unittest.rst:1343 msgid "" "Test that the Unicode or byte string *s* starts (or does not start) with a " "*prefix*. *prefix* can also be a tuple of strings to try." msgstr "" -#: ../../library/unittest.rst:1328 +#: ../../library/unittest.rst:1353 msgid "" "Test that the Unicode or byte string *s* ends (or does not end) with a " "*suffix*. *suffix* can also be a tuple of strings to try." msgstr "" -#: ../../library/unittest.rst:1338 +#: ../../library/unittest.rst:1363 msgid "Test that the object *obj* has (or has not) an attribute *name*." msgstr "" -#: ../../library/unittest.rst:1345 +#: ../../library/unittest.rst:1370 msgid "" "The :meth:`assertEqual` method dispatches the equality check for objects of " "the same type to different type-specific methods. These methods are already " @@ -2190,7 +2239,7 @@ msgid "" "register new methods using :meth:`addTypeEqualityFunc`:" msgstr "" -#: ../../library/unittest.rst:1352 +#: ../../library/unittest.rst:1377 msgid "" "Registers a type-specific method called by :meth:`assertEqual` to check if " "two objects of exactly the same *typeobj* (not subclasses) compare equal. " @@ -2201,66 +2250,66 @@ msgid "" "explaining the inequalities in details in the error message." msgstr "" -#: ../../library/unittest.rst:1363 +#: ../../library/unittest.rst:1388 msgid "" "The list of type-specific methods automatically used by :meth:`~TestCase." "assertEqual` are summarized in the following table. Note that it's usually " "not necessary to invoke these methods directly." msgstr "" -#: ../../library/unittest.rst:1368 +#: ../../library/unittest.rst:1393 msgid "Used to compare" msgstr "" -#: ../../library/unittest.rst:1370 +#: ../../library/unittest.rst:1395 msgid ":meth:`assertMultiLineEqual(a, b) `" msgstr ":meth:`assertMultiLineEqual(a, b) `" -#: ../../library/unittest.rst:1370 +#: ../../library/unittest.rst:1395 msgid "strings" msgstr "字串" -#: ../../library/unittest.rst:1373 +#: ../../library/unittest.rst:1398 msgid ":meth:`assertSequenceEqual(a, b) `" msgstr ":meth:`assertSequenceEqual(a, b) `" -#: ../../library/unittest.rst:1373 +#: ../../library/unittest.rst:1398 msgid "sequences" msgstr "序列" -#: ../../library/unittest.rst:1376 +#: ../../library/unittest.rst:1401 msgid ":meth:`assertListEqual(a, b) `" msgstr ":meth:`assertListEqual(a, b) `" -#: ../../library/unittest.rst:1376 +#: ../../library/unittest.rst:1401 msgid "lists" msgstr "串列" -#: ../../library/unittest.rst:1379 +#: ../../library/unittest.rst:1404 msgid ":meth:`assertTupleEqual(a, b) `" msgstr ":meth:`assertTupleEqual(a, b) `" -#: ../../library/unittest.rst:1379 +#: ../../library/unittest.rst:1404 msgid "tuples" msgstr "元組" -#: ../../library/unittest.rst:1382 +#: ../../library/unittest.rst:1407 msgid ":meth:`assertSetEqual(a, b) `" msgstr ":meth:`assertSetEqual(a, b) `" -#: ../../library/unittest.rst:1382 +#: ../../library/unittest.rst:1407 msgid "sets or frozensets" msgstr "集合或凍結集合" -#: ../../library/unittest.rst:1385 +#: ../../library/unittest.rst:1410 msgid ":meth:`assertDictEqual(a, b) `" msgstr ":meth:`assertDictEqual(a, b) `" -#: ../../library/unittest.rst:1385 +#: ../../library/unittest.rst:1410 msgid "dicts" msgstr "字典" -#: ../../library/unittest.rst:1393 +#: ../../library/unittest.rst:1418 msgid "" "Test that the multiline string *first* is equal to the string *second*. When " "not equal a diff of the two strings highlighting the differences will be " @@ -2268,7 +2317,7 @@ msgid "" "strings with :meth:`assertEqual`." msgstr "" -#: ../../library/unittest.rst:1403 +#: ../../library/unittest.rst:1428 msgid "" "Tests that two sequences are equal. If a *seq_type* is supplied, both " "*first* and *second* must be instances of *seq_type* or a failure will be " @@ -2276,13 +2325,13 @@ msgid "" "shows the difference between the two." msgstr "" -#: ../../library/unittest.rst:1408 +#: ../../library/unittest.rst:1433 msgid "" "This method is not called directly by :meth:`assertEqual`, but it's used to " "implement :meth:`assertListEqual` and :meth:`assertTupleEqual`." msgstr "" -#: ../../library/unittest.rst:1418 +#: ../../library/unittest.rst:1443 msgid "" "Tests that two lists or tuples are equal. If not, an error message is " "constructed that shows only the differences between the two. An error is " @@ -2290,38 +2339,38 @@ msgid "" "are used by default when comparing lists or tuples with :meth:`assertEqual`." msgstr "" -#: ../../library/unittest.rst:1429 +#: ../../library/unittest.rst:1454 msgid "" "Tests that two sets are equal. If not, an error message is constructed that " "lists the differences between the sets. This method is used by default when " "comparing sets or frozensets with :meth:`assertEqual`." msgstr "" -#: ../../library/unittest.rst:1433 +#: ../../library/unittest.rst:1458 msgid "" "Fails if either of *first* or *second* does not have a :meth:`~frozenset." "difference` method." msgstr "" -#: ../../library/unittest.rst:1441 +#: ../../library/unittest.rst:1466 msgid "" "Test that two dictionaries are equal. If not, an error message is " "constructed that shows the differences in the dictionaries. This method will " "be used by default to compare dictionaries in calls to :meth:`assertEqual`." msgstr "" -#: ../../library/unittest.rst:1452 +#: ../../library/unittest.rst:1477 msgid "" "Finally the :class:`TestCase` provides the following methods and attributes:" msgstr "" -#: ../../library/unittest.rst:1457 +#: ../../library/unittest.rst:1482 msgid "" "Signals a test failure unconditionally, with *msg* or ``None`` for the error " "message." msgstr "" -#: ../../library/unittest.rst:1463 +#: ../../library/unittest.rst:1488 msgid "" "This class attribute gives the exception raised by the test method. If a " "test framework needs to use a specialized exception, possibly to carry " @@ -2330,7 +2379,7 @@ msgid "" "`AssertionError`." msgstr "" -#: ../../library/unittest.rst:1472 +#: ../../library/unittest.rst:1497 msgid "" "This class attribute determines what happens when a custom failure message " "is passed as the msg argument to an assertXYY call that fails. ``True`` is " @@ -2339,18 +2388,18 @@ msgid "" "replaces the standard message." msgstr "" -#: ../../library/unittest.rst:1478 +#: ../../library/unittest.rst:1503 msgid "" "The class setting can be overridden in individual test methods by assigning " "an instance attribute, self.longMessage, to ``True`` or ``False`` before " "calling the assert methods." msgstr "" -#: ../../library/unittest.rst:1482 +#: ../../library/unittest.rst:1507 msgid "The class setting gets reset before each test call." msgstr "" -#: ../../library/unittest.rst:1489 +#: ../../library/unittest.rst:1514 msgid "" "This attribute controls the maximum length of diffs output by assert methods " "that report diffs on failure. It defaults to 80*8 characters. Assert methods " @@ -2359,52 +2408,52 @@ msgid "" "`assertDictEqual` and :meth:`assertMultiLineEqual`." msgstr "" -#: ../../library/unittest.rst:1496 +#: ../../library/unittest.rst:1521 msgid "" "Setting ``maxDiff`` to ``None`` means that there is no maximum length of " "diffs." msgstr "" -#: ../../library/unittest.rst:1502 +#: ../../library/unittest.rst:1527 msgid "" "Testing frameworks can use the following methods to collect information on " "the test:" msgstr "" -#: ../../library/unittest.rst:1508 +#: ../../library/unittest.rst:1533 msgid "" "Return the number of tests represented by this test object. For :class:" "`TestCase` instances, this will always be ``1``." msgstr "" -#: ../../library/unittest.rst:1514 +#: ../../library/unittest.rst:1539 msgid "" "Return an instance of the test result class that should be used for this " "test case class (if no other result instance is provided to the :meth:`run` " "method)." msgstr "" -#: ../../library/unittest.rst:1518 +#: ../../library/unittest.rst:1543 msgid "" "For :class:`TestCase` instances, this will always be an instance of :class:" "`TestResult`; subclasses of :class:`TestCase` should override this as " "necessary." msgstr "" -#: ../../library/unittest.rst:1525 +#: ../../library/unittest.rst:1550 msgid "" "Return a string identifying the specific test case. This is usually the " "full name of the test method, including the module and class name." msgstr "" -#: ../../library/unittest.rst:1531 +#: ../../library/unittest.rst:1556 msgid "" "Returns a description of the test, or ``None`` if no description has been " "provided. The default implementation of this method returns the first line " "of the test method's docstring, if available, or ``None``." msgstr "" -#: ../../library/unittest.rst:1536 +#: ../../library/unittest.rst:1561 msgid "" "In 3.1 this was changed to add the test name to the short description even " "in the presence of a docstring. This caused compatibility issues with " @@ -2412,7 +2461,7 @@ msgid "" "`TextTestResult` in Python 3.2." msgstr "" -#: ../../library/unittest.rst:1545 +#: ../../library/unittest.rst:1570 msgid "" "Add a function to be called after :meth:`tearDown` to cleanup resources used " "during the test. Functions will be called in reverse order to the order they " @@ -2421,39 +2470,39 @@ msgid "" "added." msgstr "" -#: ../../library/unittest.rst:1551 +#: ../../library/unittest.rst:1576 msgid "" "If :meth:`setUp` fails, meaning that :meth:`tearDown` is not called, then " "any cleanup functions added will still be called." msgstr "" -#: ../../library/unittest.rst:1559 +#: ../../library/unittest.rst:1584 msgid "" "Enter the supplied :term:`context manager`. If successful, also add its :" "meth:`~object.__exit__` method as a cleanup function by :meth:`addCleanup` " "and return the result of the :meth:`~object.__enter__` method." msgstr "" -#: ../../library/unittest.rst:1569 +#: ../../library/unittest.rst:1594 msgid "" "This method is called unconditionally after :meth:`tearDown`, or after :meth:" "`setUp` if :meth:`setUp` raises an exception." msgstr "" -#: ../../library/unittest.rst:1572 +#: ../../library/unittest.rst:1597 msgid "" "It is responsible for calling all the cleanup functions added by :meth:" "`addCleanup`. If you need cleanup functions to be called *prior* to :meth:" "`tearDown` then you can call :meth:`doCleanups` yourself." msgstr "" -#: ../../library/unittest.rst:1577 +#: ../../library/unittest.rst:1602 msgid "" ":meth:`doCleanups` pops methods off the stack of cleanup functions one at a " "time, so it can be called at any time." msgstr "" -#: ../../library/unittest.rst:1585 +#: ../../library/unittest.rst:1610 msgid "" "Add a function to be called after :meth:`tearDownClass` to cleanup resources " "used during the test class. Functions will be called in reverse order to the " @@ -2462,13 +2511,13 @@ msgid "" "when they are added." msgstr "" -#: ../../library/unittest.rst:1591 +#: ../../library/unittest.rst:1616 msgid "" "If :meth:`setUpClass` fails, meaning that :meth:`tearDownClass` is not " "called, then any cleanup functions added will still be called." msgstr "" -#: ../../library/unittest.rst:1599 +#: ../../library/unittest.rst:1624 msgid "" "Enter the supplied :term:`context manager`. If successful, also add its :" "meth:`~object.__exit__` method as a cleanup function by :meth:" @@ -2476,38 +2525,38 @@ msgid "" "method." msgstr "" -#: ../../library/unittest.rst:1609 +#: ../../library/unittest.rst:1634 msgid "" "This method is called unconditionally after :meth:`tearDownClass`, or after :" "meth:`setUpClass` if :meth:`setUpClass` raises an exception." msgstr "" -#: ../../library/unittest.rst:1612 +#: ../../library/unittest.rst:1637 msgid "" "It is responsible for calling all the cleanup functions added by :meth:" "`addClassCleanup`. If you need cleanup functions to be called *prior* to :" "meth:`tearDownClass` then you can call :meth:`doClassCleanups` yourself." msgstr "" -#: ../../library/unittest.rst:1617 +#: ../../library/unittest.rst:1642 msgid "" ":meth:`doClassCleanups` pops methods off the stack of cleanup functions one " "at a time, so it can be called at any time." msgstr "" -#: ../../library/unittest.rst:1625 +#: ../../library/unittest.rst:1650 msgid "" "This class provides an API similar to :class:`TestCase` and also accepts " "coroutines as test functions." msgstr "" -#: ../../library/unittest.rst:1632 +#: ../../library/unittest.rst:1657 msgid "" "The *loop_factory* passed to :class:`asyncio.Runner`. Override in subclasses " "with :class:`asyncio.EventLoop` to avoid using the asyncio policy system." msgstr "" -#: ../../library/unittest.rst:1641 +#: ../../library/unittest.rst:1666 msgid "" "Method called to prepare the test fixture. This is called after :meth:" "`TestCase.setUp`. This is called immediately before calling the test method; " @@ -2516,7 +2565,7 @@ msgid "" "default implementation does nothing." msgstr "" -#: ../../library/unittest.rst:1650 +#: ../../library/unittest.rst:1675 msgid "" "Method called immediately after the test method has been called and the " "result recorded. This is called before :meth:`~TestCase.tearDown`. This is " @@ -2529,11 +2578,11 @@ msgid "" "the outcome of the test method. The default implementation does nothing." msgstr "" -#: ../../library/unittest.rst:1662 +#: ../../library/unittest.rst:1687 msgid "This method accepts a coroutine that can be used as a cleanup function." msgstr "" -#: ../../library/unittest.rst:1667 +#: ../../library/unittest.rst:1692 msgid "" "Enter the supplied :term:`asynchronous context manager`. If successful, " "also add its :meth:`~object.__aexit__` method as a cleanup function by :meth:" @@ -2541,7 +2590,7 @@ msgid "" "method." msgstr "" -#: ../../library/unittest.rst:1677 +#: ../../library/unittest.rst:1702 msgid "" "Sets up a new event loop to run the test, collecting the result into the :" "class:`TestResult` object passed as *result*. If *result* is omitted or " @@ -2551,11 +2600,11 @@ msgid "" "the event loop are cancelled." msgstr "" -#: ../../library/unittest.rst:1685 +#: ../../library/unittest.rst:1710 msgid "An example illustrating the order::" msgstr "" -#: ../../library/unittest.rst:1687 +#: ../../library/unittest.rst:1712 msgid "" "from unittest import IsolatedAsyncioTestCase\n" "\n" @@ -2627,14 +2676,14 @@ msgstr "" "if __name__ == \"__main__\":\n" " unittest.main()" -#: ../../library/unittest.rst:1721 +#: ../../library/unittest.rst:1746 msgid "" "After running the test, ``events`` would contain ``[\"setUp\", " "\"asyncSetUp\", \"test_response\", \"asyncTearDown\", \"tearDown\", " "\"cleanup\"]``." msgstr "" -#: ../../library/unittest.rst:1726 +#: ../../library/unittest.rst:1751 msgid "" "This class implements the portion of the :class:`TestCase` interface which " "allows the test runner to drive the test, but does not provide the methods " @@ -2643,11 +2692,11 @@ msgid "" "`!unittest`-based test framework." msgstr "" -#: ../../library/unittest.rst:1736 +#: ../../library/unittest.rst:1761 msgid "Grouping tests" msgstr "" -#: ../../library/unittest.rst:1740 +#: ../../library/unittest.rst:1765 msgid "" "This class represents an aggregation of individual test cases and test " "suites. The class presents the interface needed by the test runner to allow " @@ -2655,14 +2704,14 @@ msgid "" "is the same as iterating over the suite, running each test individually." msgstr "" -#: ../../library/unittest.rst:1745 +#: ../../library/unittest.rst:1770 msgid "" "If *tests* is given, it must be an iterable of individual test cases or " "other test suites that will be used to build the suite initially. Additional " "methods are provided to add test cases and suites to the collection later on." msgstr "" -#: ../../library/unittest.rst:1749 +#: ../../library/unittest.rst:1774 msgid "" ":class:`TestSuite` objects behave much like :class:`TestCase` objects, " "except they do not actually implement a test. Instead, they are used to " @@ -2671,47 +2720,47 @@ msgid "" "instances:" msgstr "" -#: ../../library/unittest.rst:1757 +#: ../../library/unittest.rst:1782 msgid "Add a :class:`TestCase` or :class:`TestSuite` to the suite." msgstr "" -#: ../../library/unittest.rst:1762 +#: ../../library/unittest.rst:1787 msgid "" "Add all the tests from an iterable of :class:`TestCase` and :class:" "`TestSuite` instances to this test suite." msgstr "" -#: ../../library/unittest.rst:1765 +#: ../../library/unittest.rst:1790 msgid "" "This is equivalent to iterating over *tests*, calling :meth:`addTest` for " "each element." msgstr "" -#: ../../library/unittest.rst:1768 +#: ../../library/unittest.rst:1793 msgid ":class:`TestSuite` shares the following methods with :class:`TestCase`:" msgstr "" -#: ../../library/unittest.rst:1773 +#: ../../library/unittest.rst:1798 msgid "" "Run the tests associated with this suite, collecting the result into the " "test result object passed as *result*. Note that unlike :meth:`TestCase." "run`, :meth:`TestSuite.run` requires the result object to be passed in." msgstr "" -#: ../../library/unittest.rst:1781 +#: ../../library/unittest.rst:1806 msgid "" "Run the tests associated with this suite without collecting the result. This " "allows exceptions raised by the test to be propagated to the caller and can " "be used to support running tests under a debugger." msgstr "" -#: ../../library/unittest.rst:1788 +#: ../../library/unittest.rst:1813 msgid "" "Return the number of tests represented by this test object, including all " "individual tests and sub-suites." msgstr "" -#: ../../library/unittest.rst:1794 +#: ../../library/unittest.rst:1819 msgid "" "Tests grouped by a :class:`TestSuite` are always accessed by iteration. " "Subclasses can lazily provide tests by overriding :meth:`!__iter__`. Note " @@ -2723,32 +2772,32 @@ msgid "" "overrides :meth:`!TestSuite._removeTestAtIndex` to preserve test references." msgstr "" -#: ../../library/unittest.rst:1804 +#: ../../library/unittest.rst:1829 msgid "" "In earlier versions the :class:`TestSuite` accessed tests directly rather " "than through iteration, so overriding :meth:`!__iter__` wasn't sufficient " "for providing tests." msgstr "" -#: ../../library/unittest.rst:1809 +#: ../../library/unittest.rst:1834 msgid "" "In earlier versions the :class:`TestSuite` held references to each :class:" "`TestCase` after :meth:`TestSuite.run`. Subclasses can restore that behavior " "by overriding :meth:`!TestSuite._removeTestAtIndex`." msgstr "" -#: ../../library/unittest.rst:1814 +#: ../../library/unittest.rst:1839 msgid "" "In the typical usage of a :class:`TestSuite` object, the :meth:`run` method " "is invoked by a :class:`!TestRunner` rather than by the end-user test " "harness." msgstr "" -#: ../../library/unittest.rst:1819 +#: ../../library/unittest.rst:1844 msgid "Loading and running tests" msgstr "" -#: ../../library/unittest.rst:1823 +#: ../../library/unittest.rst:1848 msgid "" "The :class:`TestLoader` class is used to create test suites from classes and " "modules. Normally, there is no need to create an instance of this class; " @@ -2757,11 +2806,11 @@ msgid "" "customization of some configurable properties." msgstr "" -#: ../../library/unittest.rst:1829 +#: ../../library/unittest.rst:1854 msgid ":class:`TestLoader` objects have the following attributes:" msgstr "" -#: ../../library/unittest.rst:1834 +#: ../../library/unittest.rst:1859 msgid "" "A list of the non-fatal errors encountered while loading tests. Not reset by " "the loader at any point. Fatal errors are signalled by the relevant method " @@ -2769,17 +2818,17 @@ msgid "" "synthetic test that will raise the original error when run." msgstr "" -#: ../../library/unittest.rst:1843 +#: ../../library/unittest.rst:1868 msgid ":class:`TestLoader` objects have the following methods:" msgstr "" -#: ../../library/unittest.rst:1848 +#: ../../library/unittest.rst:1873 msgid "" "Return a suite of all test cases contained in the :class:`TestCase`\\ -" "derived :class:`!testCaseClass`." msgstr "" -#: ../../library/unittest.rst:1851 +#: ../../library/unittest.rst:1876 msgid "" "A test case instance is created for each method named by :meth:" "`getTestCaseNames`. By default these are the method names beginning with " @@ -2788,14 +2837,14 @@ msgid "" "method instead." msgstr "" -#: ../../library/unittest.rst:1860 +#: ../../library/unittest.rst:1885 msgid "" "Return a suite of all test cases contained in the given module. This method " "searches *module* for classes derived from :class:`TestCase` and creates an " "instance of the class for each test method defined for the class." msgstr "" -#: ../../library/unittest.rst:1867 +#: ../../library/unittest.rst:1892 msgid "" "While using a hierarchy of :class:`TestCase`\\ -derived classes can be " "convenient in sharing fixtures and helper functions, defining test methods " @@ -2804,7 +2853,7 @@ msgid "" "fixtures are different and defined in subclasses." msgstr "" -#: ../../library/unittest.rst:1873 +#: ../../library/unittest.rst:1898 msgid "" "If a module provides a ``load_tests`` function it will be called to load the " "tests. This allows modules to customize test loading. This is the " @@ -2812,24 +2861,24 @@ msgid "" "argument to ``load_tests``." msgstr "" -#: ../../library/unittest.rst:1878 +#: ../../library/unittest.rst:1903 msgid "Support for ``load_tests`` added." msgstr "" -#: ../../library/unittest.rst:1881 +#: ../../library/unittest.rst:1906 msgid "Support for a keyword-only argument *pattern* has been added." msgstr "" -#: ../../library/unittest.rst:1884 +#: ../../library/unittest.rst:1909 msgid "" "The undocumented and unofficial *use_load_tests* parameter has been removed." msgstr "" -#: ../../library/unittest.rst:1891 +#: ../../library/unittest.rst:1916 msgid "Return a suite of all test cases given a string specifier." msgstr "" -#: ../../library/unittest.rst:1893 +#: ../../library/unittest.rst:1918 msgid "" "The specifier *name* is a \"dotted name\" that may resolve either to a " "module, a test case class, a test method within a test case class, a :class:" @@ -2840,7 +2889,7 @@ msgid "" "object\"." msgstr "" -#: ../../library/unittest.rst:1901 +#: ../../library/unittest.rst:1926 msgid "" "For example, if you have a module :mod:`!SampleTests` containing a :class:" "`TestCase`\\ -derived class :class:`!SampleTestCase` with three test methods " @@ -2853,31 +2902,31 @@ msgid "" "imported as a side-effect." msgstr "" -#: ../../library/unittest.rst:1911 +#: ../../library/unittest.rst:1936 msgid "The method optionally resolves *name* relative to the given *module*." msgstr "" -#: ../../library/unittest.rst:1913 +#: ../../library/unittest.rst:1938 msgid "" "If an :exc:`ImportError` or :exc:`AttributeError` occurs while traversing " "*name* then a synthetic test that raises that error when run will be " "returned. These errors are included in the errors accumulated by self.errors." msgstr "" -#: ../../library/unittest.rst:1922 +#: ../../library/unittest.rst:1947 msgid "" "Similar to :meth:`loadTestsFromName`, but takes a sequence of names rather " "than a single name. The return value is a test suite which supports all the " "tests defined for each name." msgstr "" -#: ../../library/unittest.rst:1929 +#: ../../library/unittest.rst:1954 msgid "" "Return a sorted sequence of method names found within *testCaseClass*; this " "should be a subclass of :class:`TestCase`." msgstr "" -#: ../../library/unittest.rst:1935 +#: ../../library/unittest.rst:1960 msgid "" "Find all the test modules by recursing into subdirectories from the " "specified start directory, and return a TestSuite object containing them. " @@ -2886,14 +2935,14 @@ msgid "" "Python identifiers) will be loaded." msgstr "" -#: ../../library/unittest.rst:1941 +#: ../../library/unittest.rst:1966 msgid "" "All test modules must be importable from the top level of the project. If " "the start directory is not the top level directory then *top_level_dir* must " "be specified separately." msgstr "" -#: ../../library/unittest.rst:1945 +#: ../../library/unittest.rst:1970 msgid "" "If importing a module fails, for example due to a syntax error, then this " "will be recorded as a single error and discovery will continue. If the " @@ -2901,7 +2950,7 @@ msgid "" "as a skip instead of an error." msgstr "" -#: ../../library/unittest.rst:1950 +#: ../../library/unittest.rst:1975 msgid "" "If a package (a directory containing a file named :file:`__init__.py`) is " "found, the package will be checked for a ``load_tests`` function. If this " @@ -2911,107 +2960,107 @@ msgid "" "itself calls ``loader.discover``." msgstr "" -#: ../../library/unittest.rst:1958 +#: ../../library/unittest.rst:1983 msgid "" "If ``load_tests`` exists then discovery does *not* recurse into the package, " "``load_tests`` is responsible for loading all tests in the package." msgstr "" -#: ../../library/unittest.rst:1962 +#: ../../library/unittest.rst:1987 msgid "" "The pattern is deliberately not stored as a loader attribute so that " "packages can continue discovery themselves." msgstr "" -#: ../../library/unittest.rst:1965 +#: ../../library/unittest.rst:1990 msgid "" "*top_level_dir* is stored internally, and used as a default to any nested " "calls to ``discover()``. That is, if a package's ``load_tests`` calls " "``loader.discover()``, it does not need to pass this argument." msgstr "" -#: ../../library/unittest.rst:1969 +#: ../../library/unittest.rst:1994 msgid "*start_dir* can be a dotted module name as well as a directory." msgstr "" -#: ../../library/unittest.rst:1973 +#: ../../library/unittest.rst:1998 msgid "" "Modules that raise :exc:`SkipTest` on import are recorded as skips, not " "errors." msgstr "" -#: ../../library/unittest.rst:1977 +#: ../../library/unittest.rst:2002 msgid "*start_dir* can be a :term:`namespace packages `." msgstr "" -#: ../../library/unittest.rst:1979 +#: ../../library/unittest.rst:2004 msgid "" "Paths are sorted before being imported so that execution order is the same " "even if the underlying file system's ordering is not dependent on file name." msgstr "" -#: ../../library/unittest.rst:1983 +#: ../../library/unittest.rst:2008 msgid "" "Found packages are now checked for ``load_tests`` regardless of whether " "their path matches *pattern*, because it is impossible for a package name to " "match the default pattern." msgstr "" -#: ../../library/unittest.rst:1988 +#: ../../library/unittest.rst:2013 msgid "" "*start_dir* can not be a :term:`namespace packages `. It " "has been broken since Python 3.7, and Python 3.11 officially removes it." msgstr "" -#: ../../library/unittest.rst:1992 +#: ../../library/unittest.rst:2017 msgid "*top_level_dir* is only stored for the duration of *discover* call." msgstr "" -#: ../../library/unittest.rst:1995 +#: ../../library/unittest.rst:2020 msgid "*start_dir* can once again be a :term:`namespace package`." msgstr "" -#: ../../library/unittest.rst:1998 +#: ../../library/unittest.rst:2023 msgid "" "The following attributes of a :class:`TestLoader` can be configured either " "by subclassing or assignment on an instance:" msgstr "" -#: ../../library/unittest.rst:2004 +#: ../../library/unittest.rst:2029 msgid "" "String giving the prefix of method names which will be interpreted as test " "methods. The default value is ``'test'``." msgstr "" -#: ../../library/unittest.rst:2007 +#: ../../library/unittest.rst:2032 msgid "" "This affects :meth:`getTestCaseNames` and all the ``loadTestsFrom*`` methods." msgstr "" -#: ../../library/unittest.rst:2013 +#: ../../library/unittest.rst:2038 msgid "" "Function to be used to compare method names when sorting them in :meth:" "`getTestCaseNames` and all the ``loadTestsFrom*`` methods." msgstr "" -#: ../../library/unittest.rst:2019 +#: ../../library/unittest.rst:2044 msgid "" "Callable object that constructs a test suite from a list of tests. No " "methods on the resulting object are needed. The default value is the :class:" "`TestSuite` class." msgstr "" -#: ../../library/unittest.rst:2023 ../../library/unittest.rst:2036 +#: ../../library/unittest.rst:2048 ../../library/unittest.rst:2061 msgid "This affects all the ``loadTestsFrom*`` methods." msgstr "" -#: ../../library/unittest.rst:2027 +#: ../../library/unittest.rst:2052 msgid "" "List of Unix shell-style wildcard test name patterns that test methods have " "to match to be included in test suites (see ``-k`` option)." msgstr "" -#: ../../library/unittest.rst:2030 +#: ../../library/unittest.rst:2055 msgid "" "If this attribute is not ``None`` (the default), all test methods to be " "included in test suites must match one of the patterns in this list. Note " @@ -3020,13 +3069,13 @@ msgid "" "have to be converted using ``*`` wildcards." msgstr "" -#: ../../library/unittest.rst:2043 +#: ../../library/unittest.rst:2068 msgid "" "This class is used to compile information about which tests have succeeded " "and which have failed." msgstr "" -#: ../../library/unittest.rst:2046 +#: ../../library/unittest.rst:2071 msgid "" "A :class:`TestResult` object stores the results of a set of tests. The :" "class:`TestCase` and :class:`TestSuite` classes ensure that results are " @@ -3034,7 +3083,7 @@ msgid "" "outcome of tests." msgstr "" -#: ../../library/unittest.rst:2051 +#: ../../library/unittest.rst:2076 msgid "" "Testing frameworks built on top of :mod:`!unittest` may want access to the :" "class:`TestResult` object generated by running a set of tests for reporting " @@ -3042,61 +3091,61 @@ msgid "" "TestRunner.run` method for this purpose." msgstr "" -#: ../../library/unittest.rst:2056 +#: ../../library/unittest.rst:2081 msgid "" ":class:`TestResult` instances have the following attributes that will be of " "interest when inspecting the results of running a set of tests:" msgstr "" -#: ../../library/unittest.rst:2062 +#: ../../library/unittest.rst:2087 msgid "" "A list containing 2-tuples of :class:`TestCase` instances and strings " "holding formatted tracebacks. Each tuple represents a test which raised an " "unexpected exception." msgstr "" -#: ../../library/unittest.rst:2068 +#: ../../library/unittest.rst:2093 msgid "" "A list containing 2-tuples of :class:`TestCase` instances and strings " "holding formatted tracebacks. Each tuple represents a test where a failure " "was explicitly signalled using the :ref:`assert\\* methods `." msgstr "" -#: ../../library/unittest.rst:2074 +#: ../../library/unittest.rst:2099 msgid "" "A list containing 2-tuples of :class:`TestCase` instances and strings " "holding the reason for skipping the test." msgstr "" -#: ../../library/unittest.rst:2081 +#: ../../library/unittest.rst:2106 msgid "" "A list containing 2-tuples of :class:`TestCase` instances and strings " "holding formatted tracebacks. Each tuple represents an expected failure or " "error of the test case." msgstr "" -#: ../../library/unittest.rst:2087 +#: ../../library/unittest.rst:2112 msgid "" "A list containing :class:`TestCase` instances that were marked as expected " "failures, but succeeded." msgstr "" -#: ../../library/unittest.rst:2092 +#: ../../library/unittest.rst:2117 msgid "" "A list containing 2-tuples of test case names and floats representing the " "elapsed time of each test which was run." msgstr "" -#: ../../library/unittest.rst:2099 +#: ../../library/unittest.rst:2124 msgid "" "Set to ``True`` when the execution of tests should stop by :meth:`stop`." msgstr "" -#: ../../library/unittest.rst:2103 +#: ../../library/unittest.rst:2128 msgid "The total number of tests run so far." msgstr "" -#: ../../library/unittest.rst:2107 +#: ../../library/unittest.rst:2132 msgid "" "If set to true, ``sys.stdout`` and ``sys.stderr`` will be buffered in " "between :meth:`startTest` and :meth:`stopTest` being called. Collected " @@ -3105,29 +3154,29 @@ msgid "" "error message." msgstr "" -#: ../../library/unittest.rst:2116 +#: ../../library/unittest.rst:2141 msgid "" "If set to true :meth:`stop` will be called on the first failure or error, " "halting the test run." msgstr "" -#: ../../library/unittest.rst:2123 +#: ../../library/unittest.rst:2148 msgid "If set to true then local variables will be shown in tracebacks." msgstr "" -#: ../../library/unittest.rst:2129 +#: ../../library/unittest.rst:2154 msgid "" "Return ``True`` if all tests run so far have passed, otherwise returns " "``False``." msgstr "" -#: ../../library/unittest.rst:2132 +#: ../../library/unittest.rst:2157 msgid "" "Returns ``False`` if there were any :attr:`unexpectedSuccesses` from tests " "marked with the :deco:`expectedFailure` decorator." msgstr "" -#: ../../library/unittest.rst:2138 +#: ../../library/unittest.rst:2163 msgid "" "This method can be called to signal that the set of tests being run should " "be aborted by setting the :attr:`shouldStop` attribute to ``True``. :class:`!" @@ -3135,7 +3184,7 @@ msgid "" "additional tests." msgstr "" -#: ../../library/unittest.rst:2143 +#: ../../library/unittest.rst:2168 msgid "" "For example, this feature is used by the :class:`TextTestRunner` class to " "stop the test framework when the user signals an interrupt from the " @@ -3143,7 +3192,7 @@ msgid "" "implementations can use this in a similar manner." msgstr "" -#: ../../library/unittest.rst:2148 +#: ../../library/unittest.rst:2173 msgid "" "The following methods of the :class:`TestResult` class are used to maintain " "the internal data structures, and may be extended in subclasses to support " @@ -3151,141 +3200,141 @@ msgid "" "tools which support interactive reporting while tests are being run." msgstr "" -#: ../../library/unittest.rst:2156 +#: ../../library/unittest.rst:2181 msgid "Called when the test case *test* is about to be run." msgstr "" -#: ../../library/unittest.rst:2160 +#: ../../library/unittest.rst:2185 msgid "" "Called after the test case *test* has been executed, regardless of the " "outcome." msgstr "" -#: ../../library/unittest.rst:2165 +#: ../../library/unittest.rst:2190 msgid "Called once before any tests are executed." msgstr "" -#: ../../library/unittest.rst:2172 +#: ../../library/unittest.rst:2197 msgid "Called once after all tests are executed." msgstr "" -#: ../../library/unittest.rst:2179 +#: ../../library/unittest.rst:2204 msgid "" "Called when the test case *test* raises an unexpected exception. *err* is a " "tuple of the form returned by :func:`sys.exc_info`: ``(type, value, " "traceback)``." msgstr "" -#: ../../library/unittest.rst:2183 +#: ../../library/unittest.rst:2208 msgid "" "The default implementation appends a tuple ``(test, formatted_err)`` to the " "instance's :attr:`errors` attribute, where *formatted_err* is a formatted " "traceback derived from *err*." msgstr "" -#: ../../library/unittest.rst:2190 +#: ../../library/unittest.rst:2215 msgid "" "Called when the test case *test* signals a failure. *err* is a tuple of the " "form returned by :func:`sys.exc_info`: ``(type, value, traceback)``." msgstr "" -#: ../../library/unittest.rst:2193 +#: ../../library/unittest.rst:2218 msgid "" "The default implementation appends a tuple ``(test, formatted_err)`` to the " "instance's :attr:`failures` attribute, where *formatted_err* is a formatted " "traceback derived from *err*." msgstr "" -#: ../../library/unittest.rst:2200 +#: ../../library/unittest.rst:2225 msgid "Called when the test case *test* succeeds." msgstr "" -#: ../../library/unittest.rst:2202 +#: ../../library/unittest.rst:2227 msgid "The default implementation does nothing." msgstr "" -#: ../../library/unittest.rst:2207 +#: ../../library/unittest.rst:2232 msgid "" "Called when the test case *test* is skipped. *reason* is the reason the " "test gave for skipping." msgstr "" -#: ../../library/unittest.rst:2210 +#: ../../library/unittest.rst:2235 msgid "" "The default implementation appends a tuple ``(test, reason)`` to the " "instance's :attr:`skipped` attribute." msgstr "" -#: ../../library/unittest.rst:2216 +#: ../../library/unittest.rst:2241 msgid "" "Called when the test case *test* fails or errors, but was marked with the :" "deco:`expectedFailure` decorator." msgstr "" -#: ../../library/unittest.rst:2219 +#: ../../library/unittest.rst:2244 msgid "" "The default implementation appends a tuple ``(test, formatted_err)`` to the " "instance's :attr:`expectedFailures` attribute, where *formatted_err* is a " "formatted traceback derived from *err*." msgstr "" -#: ../../library/unittest.rst:2226 +#: ../../library/unittest.rst:2251 msgid "" "Called when the test case *test* was marked with the :deco:`expectedFailure` " "decorator, but succeeded." msgstr "" -#: ../../library/unittest.rst:2229 +#: ../../library/unittest.rst:2254 msgid "" "The default implementation appends the test to the instance's :attr:" "`unexpectedSuccesses` attribute." msgstr "" -#: ../../library/unittest.rst:2235 +#: ../../library/unittest.rst:2260 msgid "" "Called when a subtest finishes. *test* is the test case corresponding to " "the test method. *subtest* is a custom :class:`TestCase` instance " "describing the subtest." msgstr "" -#: ../../library/unittest.rst:2239 +#: ../../library/unittest.rst:2264 msgid "" "If *outcome* is :const:`None`, the subtest succeeded. Otherwise, it failed " "with an exception where *outcome* is a tuple of the form returned by :func:" "`sys.exc_info`: ``(type, value, traceback)``." msgstr "" -#: ../../library/unittest.rst:2243 +#: ../../library/unittest.rst:2268 msgid "" "The default implementation does nothing when the outcome is a success, and " "records subtest failures as normal failures." msgstr "" -#: ../../library/unittest.rst:2250 +#: ../../library/unittest.rst:2275 msgid "" "Called when the test case finishes. *elapsed* is the time represented in " "seconds, and it includes the execution of cleanup functions." msgstr "" -#: ../../library/unittest.rst:2257 +#: ../../library/unittest.rst:2282 msgid "" "A concrete implementation of :class:`TestResult` used by the :class:" "`TextTestRunner`. Subclasses should accept ``**kwargs`` to ensure " "compatibility as the interface changes." msgstr "" -#: ../../library/unittest.rst:2263 +#: ../../library/unittest.rst:2288 msgid "Added the *durations* keyword parameter." msgstr "新增 *durations* 關鍵字參數。" -#: ../../library/unittest.rst:2268 +#: ../../library/unittest.rst:2293 msgid "" "Instance of the :class:`TestLoader` class intended to be shared. If no " "customization of the :class:`TestLoader` is needed, this instance can be " "used instead of repeatedly creating new instances." msgstr "" -#: ../../library/unittest.rst:2277 +#: ../../library/unittest.rst:2302 msgid "" "A basic test runner implementation that outputs results to a stream. If " "*stream* is ``None``, the default, :data:`sys.stderr` is used as the output " @@ -3296,7 +3345,7 @@ msgid "" "unittest." msgstr "" -#: ../../library/unittest.rst:2284 +#: ../../library/unittest.rst:2309 msgid "" "By default this runner shows :exc:`DeprecationWarning`, :exc:" "`PendingDeprecationWarning`, :exc:`ResourceWarning` and :exc:`ImportWarning` " @@ -3306,32 +3355,32 @@ msgid "" "``None``." msgstr "" -#: ../../library/unittest.rst:2292 +#: ../../library/unittest.rst:2317 msgid "Added the *warnings* parameter." msgstr "新增 *warnings* 參數。" -#: ../../library/unittest.rst:2295 +#: ../../library/unittest.rst:2320 msgid "" "The default stream is set to :data:`sys.stderr` at instantiation time rather " "than import time." msgstr "" -#: ../../library/unittest.rst:2299 +#: ../../library/unittest.rst:2324 msgid "Added the *tb_locals* parameter." msgstr "新增 *tb_locals* 參數。" -#: ../../library/unittest.rst:2302 +#: ../../library/unittest.rst:2327 msgid "Added the *durations* parameter." msgstr "新增 *durations* 參數。" -#: ../../library/unittest.rst:2307 +#: ../../library/unittest.rst:2332 msgid "" "This method returns the instance of ``TestResult`` used by :meth:`run`. It " "is not intended to be called directly, but can be overridden in subclasses " "to provide a custom ``TestResult``." msgstr "" -#: ../../library/unittest.rst:2311 +#: ../../library/unittest.rst:2336 msgid "" "``_makeResult()`` instantiates the class or callable passed in the " "``TextTestRunner`` constructor as the ``resultclass`` argument. It defaults " @@ -3339,11 +3388,11 @@ msgid "" "class is instantiated with the following arguments::" msgstr "" -#: ../../library/unittest.rst:2316 +#: ../../library/unittest.rst:2341 msgid "stream, descriptions, verbosity" msgstr "" -#: ../../library/unittest.rst:2320 +#: ../../library/unittest.rst:2345 msgid "" "This method is the main public interface to the ``TextTestRunner``. This " "method takes a :class:`TestSuite` or :class:`TestCase` instance. A :class:" @@ -3351,7 +3400,7 @@ msgid "" "run and the results printed to stdout." msgstr "" -#: ../../library/unittest.rst:2331 +#: ../../library/unittest.rst:2356 msgid "" "A command-line program that loads a set of tests from *module* and runs " "them; this is primarily for making test modules conveniently executable. The " @@ -3359,7 +3408,7 @@ msgid "" "of a test script::" msgstr "" -#: ../../library/unittest.rst:2336 +#: ../../library/unittest.rst:2361 msgid "" "if __name__ == '__main__':\n" " unittest.main()" @@ -3367,13 +3416,13 @@ msgstr "" "if __name__ == '__main__':\n" " unittest.main()" -#: ../../library/unittest.rst:2339 +#: ../../library/unittest.rst:2364 msgid "" "You can run tests with more detailed information by passing in the verbosity " "argument::" msgstr "" -#: ../../library/unittest.rst:2342 +#: ../../library/unittest.rst:2367 msgid "" "if __name__ == '__main__':\n" " unittest.main(verbosity=2)" @@ -3381,7 +3430,7 @@ msgstr "" "if __name__ == '__main__':\n" " unittest.main(verbosity=2)" -#: ../../library/unittest.rst:2345 +#: ../../library/unittest.rst:2370 msgid "" "The *defaultTest* argument is either the name of a single test or an " "iterable of test names to run if no test names are specified via *argv*. If " @@ -3389,14 +3438,14 @@ msgid "" "tests found in *module* are run." msgstr "" -#: ../../library/unittest.rst:2350 +#: ../../library/unittest.rst:2375 msgid "" "The *argv* argument can be a list of options passed to the program, with the " "first element being the program name. If not specified or ``None``, the " "values of :data:`sys.argv` are used." msgstr "" -#: ../../library/unittest.rst:2354 +#: ../../library/unittest.rst:2379 msgid "" "The *testRunner* argument can either be a test runner class or an already " "created instance of it. By default ``main`` calls :func:`sys.exit` with an " @@ -3404,20 +3453,20 @@ msgid "" "code of 5 indicates that no tests were run or skipped." msgstr "" -#: ../../library/unittest.rst:2359 +#: ../../library/unittest.rst:2384 msgid "" "The *testLoader* argument has to be a :class:`TestLoader` instance, and " "defaults to :data:`defaultTestLoader`." msgstr "" -#: ../../library/unittest.rst:2362 +#: ../../library/unittest.rst:2387 msgid "" "``main`` supports being used from the interactive interpreter by passing in " "the argument ``exit=False``. This displays the result on standard output " "without calling :func:`sys.exit`::" msgstr "" -#: ../../library/unittest.rst:2366 +#: ../../library/unittest.rst:2391 msgid "" ">>> from unittest import main\n" ">>> main(module='test_module', exit=False)" @@ -3425,13 +3474,13 @@ msgstr "" ">>> from unittest import main\n" ">>> main(module='test_module', exit=False)" -#: ../../library/unittest.rst:2369 +#: ../../library/unittest.rst:2394 msgid "" "The *failfast*, *catchbreak* and *buffer* parameters have the same effect as " "the same-name `command-line options`_." msgstr "" -#: ../../library/unittest.rst:2372 +#: ../../library/unittest.rst:2397 msgid "" "The *warnings* argument specifies the :ref:`warning filter ` " "that should be used while running the tests. If it's not specified, it will " @@ -3440,60 +3489,60 @@ msgid "" "to ``'default'``." msgstr "" -#: ../../library/unittest.rst:2378 +#: ../../library/unittest.rst:2403 msgid "" "Calling ``main`` returns an object with the ``result`` attribute that " "contains the result of the tests run as a :class:`unittest.TestResult`." msgstr "" -#: ../../library/unittest.rst:2381 +#: ../../library/unittest.rst:2406 msgid "The *exit* parameter was added." msgstr "新增 *exit* 參數。" -#: ../../library/unittest.rst:2384 +#: ../../library/unittest.rst:2409 msgid "" "The *verbosity*, *failfast*, *catchbreak*, *buffer* and *warnings* " "parameters were added." msgstr "" -#: ../../library/unittest.rst:2388 +#: ../../library/unittest.rst:2413 msgid "" "The *defaultTest* parameter was changed to also accept an iterable of test " "names." msgstr "" -#: ../../library/unittest.rst:2396 +#: ../../library/unittest.rst:2421 msgid "load_tests Protocol" msgstr "load_tests 協定" -#: ../../library/unittest.rst:2400 +#: ../../library/unittest.rst:2425 msgid "" "Modules or packages can customize how tests are loaded from them during " "normal test runs or test discovery by implementing a function called " "``load_tests``." msgstr "" -#: ../../library/unittest.rst:2403 +#: ../../library/unittest.rst:2428 msgid "" "If a test module defines ``load_tests`` it will be called by :meth:" "`TestLoader.loadTestsFromModule` with the following arguments::" msgstr "" -#: ../../library/unittest.rst:2406 ../../library/unittest.rst:2438 +#: ../../library/unittest.rst:2431 ../../library/unittest.rst:2463 msgid "load_tests(loader, standard_tests, pattern)" msgstr "load_tests(loader, standard_tests, pattern)" -#: ../../library/unittest.rst:2408 +#: ../../library/unittest.rst:2433 msgid "" "where *pattern* is passed straight through from ``loadTestsFromModule``. It " "defaults to ``None``." msgstr "" -#: ../../library/unittest.rst:2411 +#: ../../library/unittest.rst:2436 msgid "It should return a :class:`TestSuite`." msgstr "它應該回傳一個 :class:`TestSuite`。" -#: ../../library/unittest.rst:2413 +#: ../../library/unittest.rst:2438 msgid "" "*loader* is the instance of :class:`TestLoader` doing the loading. " "*standard_tests* are the tests that would be loaded by default from the " @@ -3502,13 +3551,13 @@ msgid "" "packages as part of test discovery." msgstr "" -#: ../../library/unittest.rst:2419 +#: ../../library/unittest.rst:2444 msgid "" "A typical ``load_tests`` function that loads tests from a specific set of :" "class:`TestCase` classes may look like::" msgstr "" -#: ../../library/unittest.rst:2422 +#: ../../library/unittest.rst:2447 msgid "" "test_cases = (TestCase1, TestCase2, TestCase3)\n" "\n" @@ -3528,7 +3577,7 @@ msgstr "" " suite.addTests(tests)\n" " return suite" -#: ../../library/unittest.rst:2431 +#: ../../library/unittest.rst:2456 msgid "" "If discovery is started in a directory containing a package, either from the " "command line or by calling :meth:`TestLoader.discover`, then the package :" @@ -3538,21 +3587,21 @@ msgid "" "left up to ``load_tests`` which is called with the following arguments::" msgstr "" -#: ../../library/unittest.rst:2440 +#: ../../library/unittest.rst:2465 msgid "" "This should return a :class:`TestSuite` representing all the tests from the " "package. (``standard_tests`` will only contain tests collected from :file:" "`__init__.py`.)" msgstr "" -#: ../../library/unittest.rst:2444 +#: ../../library/unittest.rst:2469 msgid "" "Because the pattern is passed into ``load_tests`` the package is free to " "continue (and potentially modify) test discovery. A 'do nothing' " "``load_tests`` function for a test package would look like::" msgstr "" -#: ../../library/unittest.rst:2448 +#: ../../library/unittest.rst:2473 msgid "" "def load_tests(loader, standard_tests, pattern):\n" " # top level directory cached on loader instance\n" @@ -3562,17 +3611,17 @@ msgid "" " return standard_tests" msgstr "" -#: ../../library/unittest.rst:2455 +#: ../../library/unittest.rst:2480 msgid "" "Discovery no longer checks package names for matching *pattern* due to the " "impossibility of package names matching the default pattern." msgstr "" -#: ../../library/unittest.rst:2462 +#: ../../library/unittest.rst:2487 msgid "Class and Module Fixtures" msgstr "" -#: ../../library/unittest.rst:2464 +#: ../../library/unittest.rst:2489 msgid "" "Class and module level fixtures are implemented in :class:`TestSuite`. When " "the test suite encounters a test from a new class then :meth:`~TestCase." @@ -3580,27 +3629,27 @@ msgid "" "by :meth:`~TestCase.setUpClass` from the new class." msgstr "" -#: ../../library/unittest.rst:2469 +#: ../../library/unittest.rst:2494 msgid "" "Similarly if a test is from a different module from the previous test then " "``tearDownModule`` from the previous module is run, followed by " "``setUpModule`` from the new module." msgstr "" -#: ../../library/unittest.rst:2473 +#: ../../library/unittest.rst:2498 msgid "" "After all the tests have run the final ``tearDownClass`` and " "``tearDownModule`` are run." msgstr "" -#: ../../library/unittest.rst:2476 +#: ../../library/unittest.rst:2501 msgid "" "Note that shared fixtures do not play well with [potential] features like " "test parallelization and they break test isolation. They should be used with " "care." msgstr "" -#: ../../library/unittest.rst:2479 +#: ../../library/unittest.rst:2504 msgid "" "The default ordering of tests created by the unittest test loaders is to " "group all tests from the same modules and classes together. This will lead " @@ -3610,14 +3659,14 @@ msgid "" "functions may be called multiple times in a single test run." msgstr "" -#: ../../library/unittest.rst:2486 +#: ../../library/unittest.rst:2511 msgid "" "Shared fixtures are not intended to work with suites with non-standard " "ordering. A ``BaseTestSuite`` still exists for frameworks that don't want to " "support shared fixtures." msgstr "" -#: ../../library/unittest.rst:2490 +#: ../../library/unittest.rst:2515 msgid "" "If there are any exceptions raised during one of the shared fixture " "functions the test is reported as an error. Because there is no " @@ -3627,15 +3676,15 @@ msgid "" "matter, but if you are a framework author it may be relevant." msgstr "" -#: ../../library/unittest.rst:2499 +#: ../../library/unittest.rst:2524 msgid "setUpClass and tearDownClass" msgstr "setUpClass 和 tearDownClass" -#: ../../library/unittest.rst:2501 +#: ../../library/unittest.rst:2526 msgid "These must be implemented as class methods::" msgstr "" -#: ../../library/unittest.rst:2503 +#: ../../library/unittest.rst:2528 msgid "" "import unittest\n" "\n" @@ -3659,14 +3708,14 @@ msgstr "" " def tearDownClass(cls):\n" " cls._connection.destroy()" -#: ../../library/unittest.rst:2514 +#: ../../library/unittest.rst:2539 msgid "" "If you want the ``setUpClass`` and ``tearDownClass`` on base classes called " "then you must call up to them yourself. The implementations in :class:" "`TestCase` are empty." msgstr "" -#: ../../library/unittest.rst:2518 +#: ../../library/unittest.rst:2543 msgid "" "If an exception is raised during a ``setUpClass`` then the tests in the " "class are not run and the ``tearDownClass`` is not run. Skipped classes will " @@ -3675,15 +3724,15 @@ msgid "" "instead of as an error." msgstr "" -#: ../../library/unittest.rst:2526 +#: ../../library/unittest.rst:2551 msgid "setUpModule and tearDownModule" msgstr "setUpModule 和 tearDownModule" -#: ../../library/unittest.rst:2532 +#: ../../library/unittest.rst:2557 msgid "These should be implemented as functions::" msgstr "" -#: ../../library/unittest.rst:2534 +#: ../../library/unittest.rst:2559 msgid "" "def setUpModule():\n" " createConnection()\n" @@ -3697,7 +3746,7 @@ msgstr "" "def tearDownModule():\n" " closeConnection()" -#: ../../library/unittest.rst:2540 +#: ../../library/unittest.rst:2565 msgid "" "If an exception is raised in a ``setUpModule`` then none of the tests in the " "module will be run and the ``tearDownModule`` will not be run. If the " @@ -3705,13 +3754,13 @@ msgid "" "having been skipped instead of as an error." msgstr "" -#: ../../library/unittest.rst:2545 +#: ../../library/unittest.rst:2570 msgid "" "To add cleanup code that must be run even in the case of an exception, use " "``addModuleCleanup``:" msgstr "" -#: ../../library/unittest.rst:2551 +#: ../../library/unittest.rst:2576 msgid "" "Add a function to be called after :func:`tearDownModule` to cleanup " "resources used during the test class. Functions will be called in reverse " @@ -3720,13 +3769,13 @@ msgid "" "`addModuleCleanup` when they are added." msgstr "" -#: ../../library/unittest.rst:2557 +#: ../../library/unittest.rst:2582 msgid "" "If :meth:`setUpModule` fails, meaning that :func:`tearDownModule` is not " "called, then any cleanup functions added will still be called." msgstr "" -#: ../../library/unittest.rst:2565 +#: ../../library/unittest.rst:2590 msgid "" "Enter the supplied :term:`context manager`. If successful, also add its :" "meth:`~object.__exit__` method as a cleanup function by :func:" @@ -3734,30 +3783,30 @@ msgid "" "method." msgstr "" -#: ../../library/unittest.rst:2575 +#: ../../library/unittest.rst:2600 msgid "" "This function is called unconditionally after :func:`tearDownModule`, or " "after :func:`setUpModule` if :func:`setUpModule` raises an exception." msgstr "" -#: ../../library/unittest.rst:2578 +#: ../../library/unittest.rst:2603 msgid "" "It is responsible for calling all the cleanup functions added by :func:" "`addModuleCleanup`. If you need cleanup functions to be called *prior* to :" "func:`tearDownModule` then you can call :func:`doModuleCleanups` yourself." msgstr "" -#: ../../library/unittest.rst:2583 +#: ../../library/unittest.rst:2608 msgid "" ":func:`doModuleCleanups` pops methods off the stack of cleanup functions one " "at a time, so it can be called at any time." msgstr "" -#: ../../library/unittest.rst:2590 +#: ../../library/unittest.rst:2615 msgid "Signal Handling" msgstr "" -#: ../../library/unittest.rst:2594 +#: ../../library/unittest.rst:2619 msgid "" "The :option:`-c/--catch ` command-line option to unittest, " "along with the ``catchbreak`` parameter to :func:`unittest.main`, provide " @@ -3767,7 +3816,7 @@ msgid "" "A second control-c will raise a :exc:`KeyboardInterrupt` in the usual way." msgstr "" -#: ../../library/unittest.rst:2601 +#: ../../library/unittest.rst:2626 msgid "" "The control-c handling signal handler attempts to remain compatible with " "code or tests that install their own :const:`signal.SIGINT` handler. If the " @@ -3779,48 +3828,48 @@ msgid "" "disabled the :func:`removeHandler` decorator can be used." msgstr "" -#: ../../library/unittest.rst:2610 +#: ../../library/unittest.rst:2635 msgid "" "There are a few utility functions for framework authors to enable control-c " "handling functionality within test frameworks." msgstr "" -#: ../../library/unittest.rst:2615 +#: ../../library/unittest.rst:2640 msgid "" "Install the control-c handler. When a :const:`signal.SIGINT` is received " "(usually in response to the user pressing control-c) all registered results " "have :meth:`~TestResult.stop` called." msgstr "" -#: ../../library/unittest.rst:2622 +#: ../../library/unittest.rst:2647 msgid "" "Register a :class:`TestResult` object for control-c handling. Registering a " "result stores a weak reference to it, so it doesn't prevent the result from " "being garbage collected." msgstr "" -#: ../../library/unittest.rst:2626 +#: ../../library/unittest.rst:2651 msgid "" "Registering a :class:`TestResult` object has no side-effects if control-c " "handling is not enabled, so test frameworks can unconditionally register all " "results they create independently of whether or not handling is enabled." msgstr "" -#: ../../library/unittest.rst:2633 +#: ../../library/unittest.rst:2658 msgid "" "Remove a registered result. Once a result has been removed then :meth:" "`~TestResult.stop` will no longer be called on that result object in " "response to a control-c." msgstr "" -#: ../../library/unittest.rst:2640 +#: ../../library/unittest.rst:2665 msgid "" "When called without arguments this function removes the control-c handler if " "it has been installed. This function can also be used as a test decorator to " "temporarily remove the handler while the test is being executed::" msgstr "" -#: ../../library/unittest.rst:2644 +#: ../../library/unittest.rst:2669 msgid "" "@unittest.removeHandler\n" "def test_signal_handling(self):\n" diff --git a/library/urllib.error.po b/library/urllib.error.po index 2d917aec5e7..45f22d27495 100644 --- a/library/urllib.error.po +++ b/library/urllib.error.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-06-11 15:34+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,11 +25,11 @@ msgstr "" msgid ":mod:`!urllib.error` --- Exception classes raised by urllib.request" msgstr ":mod:`!urllib.error` --- urllib.request 引發的例外類別" -#: ../../library/urllib.error.rst:10 +#: ../../library/urllib.error.rst:7 msgid "**Source code:** :source:`Lib/urllib/error.py`" msgstr "**原始碼:**\\ :source:`Lib/urllib/error.py`" -#: ../../library/urllib.error.rst:14 +#: ../../library/urllib.error.rst:11 msgid "" "The :mod:`!urllib.error` module defines the exception classes for exceptions " "raised by :mod:`urllib.request`. The base exception class is :exc:" @@ -38,12 +38,12 @@ msgstr "" ":mod:`!urllib.error` module(模組)為 :mod:`urllib.request` 所引發的例外定義了" "例外 (exception) 類別。基礎例外類別是 :exc:`URLError`。" -#: ../../library/urllib.error.rst:17 +#: ../../library/urllib.error.rst:14 msgid "" "The following exceptions are raised by :mod:`!urllib.error` as appropriate:" msgstr "下列例外會被 :mod:`!urllib.error` 適時引發:" -#: ../../library/urllib.error.rst:21 +#: ../../library/urllib.error.rst:18 msgid "" "The handlers raise this exception (or derived exceptions) when they run into " "a problem. It is a subclass of :exc:`OSError`." @@ -51,13 +51,13 @@ msgstr "" "處理程式 (handler) 在遇到問題時會引發此例外(或其衍生例外)。它是 :exc:" "`OSError` 的一個子類別。" -#: ../../library/urllib.error.rst:26 +#: ../../library/urllib.error.rst:23 msgid "" "The reason for this error. It can be a message string or another exception " "instance." msgstr "此錯誤的原因。它可以是一個訊息字串或另一個例外實例。" -#: ../../library/urllib.error.rst:29 +#: ../../library/urllib.error.rst:26 msgid "" ":exc:`URLError` used to be a subtype of :exc:`IOError`, which is now an " "alias of :exc:`OSError`." @@ -65,7 +65,7 @@ msgstr "" ":exc:`URLError` 過去是 :exc:`IOError` 的子類別,但現在為 :exc:`OSError` 的別" "名。" -#: ../../library/urllib.error.rst:36 +#: ../../library/urllib.error.rst:33 msgid "" "Though being an exception (a subclass of :exc:`URLError`), an :exc:" "`HTTPError` can also function as a non-exceptional file-like return value " @@ -76,11 +76,11 @@ msgstr "" "個非例外的類檔案回傳值(與 :func:`~urllib.request.urlopen` 所回傳的物件相" "同)。這適用於處理特殊 HTTP 錯誤,例如為請求認證。" -#: ../../library/urllib.error.rst:44 +#: ../../library/urllib.error.rst:41 msgid "Contains the request URL. An alias for *filename* attribute." msgstr "包含請求 URL。*filename* 屬性的別名。" -#: ../../library/urllib.error.rst:49 +#: ../../library/urllib.error.rst:46 msgid "" "An HTTP status code as defined in :rfc:`2616`. This numeric value " "corresponds to a value found in the dictionary of codes as found in :attr:" @@ -89,13 +89,13 @@ msgstr "" "一個 HTTP 狀態碼,具體定義見 :rfc:`2616`。這個數值會對應到存放在 :attr:`http." "server.BaseHTTPRequestHandler.responses` 程式碼 dictionary 中的某個值。" -#: ../../library/urllib.error.rst:55 +#: ../../library/urllib.error.rst:52 msgid "" "This is usually a string explaining the reason for this error. An alias for " "*msg* attribute." msgstr "這通常是一個解釋本次錯誤原因的字串。為 *msg* 屬性的別名。" -#: ../../library/urllib.error.rst:60 +#: ../../library/urllib.error.rst:57 msgid "" "The HTTP response headers for the HTTP request that caused the :exc:" "`HTTPError`. An alias for *hdrs* attribute." @@ -103,11 +103,11 @@ msgstr "" "導致 :exc:`HTTPError` 的特定 HTTP 請求的 HTTP 回應 header。為 *hdrs* 屬性的別" "名。" -#: ../../library/urllib.error.rst:68 +#: ../../library/urllib.error.rst:65 msgid "A file-like object where the HTTP error body can be read from." msgstr "一個類檔案物件,可以從中讀取 HTTP 錯誤主體 (body)。" -#: ../../library/urllib.error.rst:72 +#: ../../library/urllib.error.rst:69 msgid "" "This exception is raised when the :func:`~urllib.request.urlretrieve` " "function detects that the amount of the downloaded data is less than the " @@ -116,6 +116,6 @@ msgstr "" "此例外會在 :func:`~urllib.request.urlretrieve` 函式檢查到已下載的資料量小於期" "待的資料量(由 *Content-Length* header 給定)時被引發。" -#: ../../library/urllib.error.rst:79 +#: ../../library/urllib.error.rst:76 msgid "The downloaded (and supposedly truncated) data." msgstr "已下載(可能已被截斷)的資料。" diff --git a/library/urllib.parse.po b/library/urllib.parse.po index a6fe20b0834..04a5041d55c 100644 --- a/library/urllib.parse.po +++ b/library/urllib.parse.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-10 00:35+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:14+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -82,31 +82,29 @@ msgid "" "Parse a URL into five components, returning a 5-item :term:`named tuple` :" "class:`SplitResult` or :class:`SplitResultBytes`. This corresponds to the " "general structure of a URL: ``scheme://netloc/path?query#fragment``. Each " -"tuple item is a string, possibly empty." +"tuple item is a string, possibly empty, or ``None`` if *missing_as_none* is " +"true. Not defined component are represented an empty string (by default) or " +"``None`` if *missing_as_none* is true. The delimiters as shown above are not " +"part of the result, except for a leading slash in the *path* component, " +"which is retained if present." msgstr "" -#: ../../library/urllib.parse.rst:61 -msgid "" -"The delimiters as shown above are not part of the result, except for a " -"leading slash in the *path* component, which is retained if present." -msgstr "" - -#: ../../library/urllib.parse.rst:64 +#: ../../library/urllib.parse.rst:66 msgid "" "Additionally, the netloc property is broken down into these additional " "attributes added to the returned object: username, password, hostname, and " "port." msgstr "" -#: ../../library/urllib.parse.rst:68 +#: ../../library/urllib.parse.rst:70 msgid "Percent-encoded sequences are not decoded." msgstr "" -#: ../../library/urllib.parse.rst:70 +#: ../../library/urllib.parse.rst:72 msgid "For example:" msgstr "" -#: ../../library/urllib.parse.rst:72 +#: ../../library/urllib.parse.rst:74 msgid "" ">>> from urllib.parse import urlsplit\n" ">>> urlsplit(\"scheme://netloc/path?query#fragment\")\n" @@ -127,7 +125,13 @@ msgid "" ">>> o.port\n" "80\n" ">>> o._replace(fragment=\"\").geturl()\n" -"'http://docs.python.org:80/3/library/urllib.parse.html?highlight=params'" +"'http://docs.python.org:80/3/library/urllib.parse.html?highlight=params'\n" +">>> urlsplit(\"http://docs.python.org?\")\n" +"SplitResult(scheme='http', netloc='docs.python.org', path='',\n" +" query='', fragment='')\n" +">>> urlsplit(\"http://docs.python.org?\", missing_as_none=True)\n" +"SplitResult(scheme='http', netloc='docs.python.org', path='',\n" +" query='', fragment=None)" msgstr "" ">>> from urllib.parse import urlsplit\n" ">>> urlsplit(\"scheme://netloc/path?query#fragment\")\n" @@ -148,9 +152,15 @@ msgstr "" ">>> o.port\n" "80\n" ">>> o._replace(fragment=\"\").geturl()\n" -"'http://docs.python.org:80/3/library/urllib.parse.html?highlight=params'" +"'http://docs.python.org:80/3/library/urllib.parse.html?highlight=params'\n" +">>> urlsplit(\"http://docs.python.org?\")\n" +"SplitResult(scheme='http', netloc='docs.python.org', path='',\n" +" query='', fragment='')\n" +">>> urlsplit(\"http://docs.python.org?\", missing_as_none=True)\n" +"SplitResult(scheme='http', netloc='docs.python.org', path='',\n" +" query='', fragment=None)" -#: ../../library/urllib.parse.rst:96 +#: ../../library/urllib.parse.rst:104 msgid "" "Following the syntax specifications in :rfc:`1808`, :func:`!urlsplit` " "recognizes a netloc only if it is properly introduced by '//'. Otherwise " @@ -158,7 +168,7 @@ msgid "" "component." msgstr "" -#: ../../library/urllib.parse.rst:101 +#: ../../library/urllib.parse.rst:109 msgid "" ">>> from urllib.parse import urlsplit\n" ">>> urlsplit('//www.cwi.nl:80/%7Eguido/Python.html')\n" @@ -170,179 +180,192 @@ msgid "" " query='', fragment='')\n" ">>> urlsplit('help/Python.html')\n" "SplitResult(scheme='', netloc='', path='help/Python.html',\n" -" query='', fragment='')" +" query='', fragment='')\n" +">>> urlsplit('help/Python.html', missing_as_none=True)\n" +"SplitResult(scheme=None, netloc=None, path='help/Python.html',\n" +" query=None, fragment=None)" msgstr "" ">>> from urllib.parse import urlsplit\n" ">>> urlsplit('//www.cwi.nl:80/%7Eguido/Python.html')\n" -"SplitResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python." -"html',\n" +"SplitResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/" +"Python.html',\n" " query='', fragment='')\n" ">>> urlsplit('www.cwi.nl/%7Eguido/Python.html')\n" "SplitResult(scheme='', netloc='', path='www.cwi.nl/%7Eguido/Python.html',\n" " query='', fragment='')\n" ">>> urlsplit('help/Python.html')\n" "SplitResult(scheme='', netloc='', path='help/Python.html',\n" -" query='', fragment='')" +" query='', fragment='')\n" +">>> urlsplit('help/Python.html', missing_as_none=True)\n" +"SplitResult(scheme=None, netloc=None, path='help/Python.html',\n" +" query=None, fragment=None)" -#: ../../library/urllib.parse.rst:115 +#: ../../library/urllib.parse.rst:126 msgid "" "The *scheme* argument gives the default addressing scheme, to be used only " "if the URL does not specify one. It should be the same type (text or bytes) " -"as *urlstring*, except that the default value ``''`` is always allowed, and " -"is automatically converted to ``b''`` if appropriate." +"as *urlstring* or ``None``, except that the ``''`` is always allowed, and is " +"automatically converted to ``b''`` if appropriate." msgstr "" -#: ../../library/urllib.parse.rst:120 +#: ../../library/urllib.parse.rst:131 msgid "" "If the *allow_fragments* argument is false, fragment identifiers are not " -"recognized. Instead, they are parsed as part of the path, parameters or " -"query component, and :attr:`fragment` is set to the empty string in the " -"return value." +"recognized. Instead, they are parsed as part of the path or query " +"component, and :attr:`fragment` is set to ``None`` or the empty string " +"(depending on the value of *missing_as_none*) in the return value." msgstr "" -#: ../../library/urllib.parse.rst:125 +#: ../../library/urllib.parse.rst:136 msgid "" "The return value is a :term:`named tuple`, which means that its items can be " "accessed by index or as named attributes, which are:" msgstr "" -#: ../../library/urllib.parse.rst:129 ../../library/urllib.parse.rst:395 +#: ../../library/urllib.parse.rst:140 ../../library/urllib.parse.rst:437 msgid "Attribute" msgstr "屬性" -#: ../../library/urllib.parse.rst:129 ../../library/urllib.parse.rst:395 +#: ../../library/urllib.parse.rst:140 ../../library/urllib.parse.rst:437 msgid "Index" msgstr "" -#: ../../library/urllib.parse.rst:129 ../../library/urllib.parse.rst:395 +#: ../../library/urllib.parse.rst:140 ../../library/urllib.parse.rst:437 msgid "Value" msgstr "" -#: ../../library/urllib.parse.rst:129 ../../library/urllib.parse.rst:395 +#: ../../library/urllib.parse.rst:140 ../../library/urllib.parse.rst:437 msgid "Value if not present" msgstr "" -#: ../../library/urllib.parse.rst:131 +#: ../../library/urllib.parse.rst:142 msgid ":attr:`scheme`" msgstr ":attr:`scheme`" -#: ../../library/urllib.parse.rst:131 ../../library/urllib.parse.rst:397 +#: ../../library/urllib.parse.rst:142 ../../library/urllib.parse.rst:439 msgid "0" msgstr "0" -#: ../../library/urllib.parse.rst:131 +#: ../../library/urllib.parse.rst:142 msgid "URL scheme specifier" msgstr "" -#: ../../library/urllib.parse.rst:131 -msgid "*scheme* parameter" +#: ../../library/urllib.parse.rst:142 +msgid "*scheme* parameter or empty string [1]_" msgstr "" -#: ../../library/urllib.parse.rst:133 +#: ../../library/urllib.parse.rst:145 msgid ":attr:`netloc`" msgstr ":attr:`netloc`" -#: ../../library/urllib.parse.rst:133 ../../library/urllib.parse.rst:399 +#: ../../library/urllib.parse.rst:145 ../../library/urllib.parse.rst:441 msgid "1" msgstr "1" -#: ../../library/urllib.parse.rst:133 +#: ../../library/urllib.parse.rst:145 msgid "Network location part" msgstr "" -#: ../../library/urllib.parse.rst:133 ../../library/urllib.parse.rst:135 -#: ../../library/urllib.parse.rst:137 ../../library/urllib.parse.rst:139 -#: ../../library/urllib.parse.rst:397 ../../library/urllib.parse.rst:399 -msgid "empty string" +#: ../../library/urllib.parse.rst:145 ../../library/urllib.parse.rst:149 +#: ../../library/urllib.parse.rst:151 +msgid "``None`` or empty string [1]_" msgstr "" -#: ../../library/urllib.parse.rst:135 +#: ../../library/urllib.parse.rst:147 msgid ":attr:`path`" msgstr ":attr:`path`" -#: ../../library/urllib.parse.rst:135 +#: ../../library/urllib.parse.rst:147 msgid "2" msgstr "2" -#: ../../library/urllib.parse.rst:135 +#: ../../library/urllib.parse.rst:147 msgid "Hierarchical path" msgstr "" -#: ../../library/urllib.parse.rst:137 +#: ../../library/urllib.parse.rst:147 ../../library/urllib.parse.rst:439 +msgid "empty string" +msgstr "" + +#: ../../library/urllib.parse.rst:149 msgid ":attr:`query`" msgstr ":attr:`query`" -#: ../../library/urllib.parse.rst:137 +#: ../../library/urllib.parse.rst:149 msgid "3" msgstr "3" -#: ../../library/urllib.parse.rst:137 +#: ../../library/urllib.parse.rst:149 msgid "Query component" msgstr "" -#: ../../library/urllib.parse.rst:139 ../../library/urllib.parse.rst:399 +#: ../../library/urllib.parse.rst:151 ../../library/urllib.parse.rst:441 msgid ":attr:`fragment`" msgstr ":attr:`fragment`" -#: ../../library/urllib.parse.rst:139 +#: ../../library/urllib.parse.rst:151 msgid "4" msgstr "4" -#: ../../library/urllib.parse.rst:139 ../../library/urllib.parse.rst:399 +#: ../../library/urllib.parse.rst:151 ../../library/urllib.parse.rst:441 msgid "Fragment identifier" msgstr "" -#: ../../library/urllib.parse.rst:141 +#: ../../library/urllib.parse.rst:153 msgid ":attr:`username`" msgstr ":attr:`username`" -#: ../../library/urllib.parse.rst:141 +#: ../../library/urllib.parse.rst:153 msgid "User name" msgstr "" -#: ../../library/urllib.parse.rst:141 ../../library/urllib.parse.rst:143 -#: ../../library/urllib.parse.rst:145 ../../library/urllib.parse.rst:147 -msgid ":const:`None`" -msgstr ":const:`None`" +#: ../../library/urllib.parse.rst:153 ../../library/urllib.parse.rst:155 +#: ../../library/urllib.parse.rst:157 ../../library/urllib.parse.rst:159 +msgid "``None``" +msgstr "``None``" -#: ../../library/urllib.parse.rst:143 +#: ../../library/urllib.parse.rst:155 msgid ":attr:`password`" msgstr ":attr:`password`" -#: ../../library/urllib.parse.rst:143 +#: ../../library/urllib.parse.rst:155 msgid "Password" msgstr "" -#: ../../library/urllib.parse.rst:145 +#: ../../library/urllib.parse.rst:157 msgid ":attr:`hostname`" msgstr ":attr:`hostname`" -#: ../../library/urllib.parse.rst:145 +#: ../../library/urllib.parse.rst:157 msgid "Host name (lower case)" msgstr "" -#: ../../library/urllib.parse.rst:147 +#: ../../library/urllib.parse.rst:159 msgid ":attr:`port`" msgstr ":attr:`port`" -#: ../../library/urllib.parse.rst:147 +#: ../../library/urllib.parse.rst:159 msgid "Port number as integer, if present" msgstr "" -#: ../../library/urllib.parse.rst:151 +#: ../../library/urllib.parse.rst:163 ../../library/urllib.parse.rst:444 +msgid "Depending on the value of the *missing_as_none* argument." +msgstr "" + +#: ../../library/urllib.parse.rst:165 msgid "" "Reading the :attr:`port` attribute will raise a :exc:`ValueError` if an " "invalid port is specified in the URL. See section :ref:`urlparse-result-" "object` for more information on the result object." msgstr "" -#: ../../library/urllib.parse.rst:155 +#: ../../library/urllib.parse.rst:169 msgid "" "Unmatched square brackets in the :attr:`netloc` attribute will raise a :exc:" "`ValueError`." msgstr "" -#: ../../library/urllib.parse.rst:158 +#: ../../library/urllib.parse.rst:172 msgid "" "Characters in the :attr:`netloc` attribute that decompose under NFKC " "normalization (as used by the IDNA encoding) into any of ``/``, ``?``, " @@ -350,14 +373,14 @@ msgid "" "decomposed before parsing, no error will be raised." msgstr "" -#: ../../library/urllib.parse.rst:163 +#: ../../library/urllib.parse.rst:177 msgid "" "Following some of the `WHATWG spec`_ that updates :rfc:`3986`, leading C0 " "control and space characters are stripped from the URL. ``\\n``, ``\\r`` and " "tab ``\\t`` characters are removed from the URL at any position." msgstr "" -#: ../../library/urllib.parse.rst:167 +#: ../../library/urllib.parse.rst:181 msgid "" "As is the case with all named tuples, the subclass has a few additional " "methods and attributes that are particularly useful. One such method is :" @@ -365,7 +388,7 @@ msgid "" "`SplitResult` object replacing specified fields with new values." msgstr "" -#: ../../library/urllib.parse.rst:172 +#: ../../library/urllib.parse.rst:186 msgid "" ">>> from urllib.parse import urlsplit\n" ">>> u = urlsplit('//www.cwi.nl:80/%7Eguido/Python.html')\n" @@ -389,45 +412,49 @@ msgstr "" "html',\n" " query='', fragment='')" -#: ../../library/urllib.parse.rst:186 +#: ../../library/urllib.parse.rst:200 msgid "" ":func:`urlsplit` does not perform validation. See :ref:`URL parsing " "security ` for details." msgstr "" -#: ../../library/urllib.parse.rst:189 +#: ../../library/urllib.parse.rst:203 msgid "Added IPv6 URL parsing capabilities." msgstr "新增剖析 IPv6 URL 的能力。" -#: ../../library/urllib.parse.rst:192 +#: ../../library/urllib.parse.rst:206 msgid "" "The fragment is now parsed for all URL schemes (unless *allow_fragments* is " "false), in accordance with :rfc:`3986`. Previously, an allowlist of schemes " "that support fragments existed." msgstr "" -#: ../../library/urllib.parse.rst:197 +#: ../../library/urllib.parse.rst:211 msgid "" -"Out-of-range port numbers now raise :exc:`ValueError`, instead of returning :" -"const:`None`." +"Out-of-range port numbers now raise :exc:`ValueError`, instead of returning " +"``None``." msgstr "" -#: ../../library/urllib.parse.rst:201 +#: ../../library/urllib.parse.rst:215 msgid "" "Characters that affect netloc parsing under NFKC normalization will now " "raise :exc:`ValueError`." msgstr "" -#: ../../library/urllib.parse.rst:205 +#: ../../library/urllib.parse.rst:219 msgid "ASCII newline and tab characters are stripped from the URL." msgstr "" -#: ../../library/urllib.parse.rst:208 +#: ../../library/urllib.parse.rst:222 msgid "" "Leading WHATWG C0 control and space characters are stripped from the URL." msgstr "" -#: ../../library/urllib.parse.rst:216 +#: ../../library/urllib.parse.rst:225 ../../library/urllib.parse.rst:452 +msgid "Added the *missing_as_none* parameter." +msgstr "新增 *missing_as_none* 參數。" + +#: ../../library/urllib.parse.rst:233 msgid "" "Parse a query string given as a string argument (data of type :mimetype:" "`application/x-www-form-urlencoded`). Data are returned as a dictionary. " @@ -435,7 +462,7 @@ msgid "" "lists of values for each name." msgstr "" -#: ../../library/urllib.parse.rst:221 ../../library/urllib.parse.rst:270 +#: ../../library/urllib.parse.rst:238 ../../library/urllib.parse.rst:287 msgid "" "The optional argument *keep_blank_values* is a flag indicating whether blank " "values in percent-encoded queries should be treated as blank strings. A true " @@ -444,48 +471,48 @@ msgid "" "treated as if they were not included." msgstr "" -#: ../../library/urllib.parse.rst:227 ../../library/urllib.parse.rst:276 +#: ../../library/urllib.parse.rst:244 ../../library/urllib.parse.rst:293 msgid "" "The optional argument *strict_parsing* is a flag indicating what to do with " "parsing errors. If false (the default), errors are silently ignored. If " "true, errors raise a :exc:`ValueError` exception." msgstr "" -#: ../../library/urllib.parse.rst:231 ../../library/urllib.parse.rst:280 +#: ../../library/urllib.parse.rst:248 ../../library/urllib.parse.rst:297 msgid "" "The optional *encoding* and *errors* parameters specify how to decode " "percent-encoded sequences into Unicode characters, as accepted by the :meth:" "`bytes.decode` method." msgstr "" -#: ../../library/urllib.parse.rst:235 ../../library/urllib.parse.rst:284 +#: ../../library/urllib.parse.rst:252 ../../library/urllib.parse.rst:301 msgid "" "The optional argument *max_num_fields* is the maximum number of fields to " "read. If set, then throws a :exc:`ValueError` if there are more than " "*max_num_fields* fields read." msgstr "" -#: ../../library/urllib.parse.rst:239 ../../library/urllib.parse.rst:288 +#: ../../library/urllib.parse.rst:256 ../../library/urllib.parse.rst:305 msgid "" "The optional argument *separator* is the symbol to use for separating the " "query arguments. It defaults to ``&``." msgstr "" -#: ../../library/urllib.parse.rst:242 +#: ../../library/urllib.parse.rst:259 msgid "" "Use the :func:`urllib.parse.urlencode` function (with the ``doseq`` " "parameter set to ``True``) to convert such dictionaries into query strings." msgstr "" -#: ../../library/urllib.parse.rst:247 ../../library/urllib.parse.rst:294 +#: ../../library/urllib.parse.rst:264 ../../library/urllib.parse.rst:311 msgid "Add *encoding* and *errors* parameters." msgstr "新增 *encoding* 和 *errors* 參數。" -#: ../../library/urllib.parse.rst:250 ../../library/urllib.parse.rst:297 +#: ../../library/urllib.parse.rst:267 ../../library/urllib.parse.rst:314 msgid "Added *max_num_fields* parameter." msgstr "新增 *max_num_fields* 參數。" -#: ../../library/urllib.parse.rst:253 ../../library/urllib.parse.rst:300 +#: ../../library/urllib.parse.rst:270 ../../library/urllib.parse.rst:317 msgid "" "Added *separator* parameter with the default value of ``&``. Python versions " "earlier than Python 3.10 allowed using both ``;`` and ``&`` as query " @@ -493,35 +520,52 @@ msgid "" "key, with ``&`` as the default separator." msgstr "" -#: ../../library/urllib.parse.rst:259 ../../library/urllib.parse.rst:721 +#: ../../library/urllib.parse.rst:276 ../../library/urllib.parse.rst:773 msgid "" "Accepting objects with false values (like ``0`` and ``[]``) except empty " "strings and byte-like objects and ``None`` is now deprecated." msgstr "" -#: ../../library/urllib.parse.rst:266 +#: ../../library/urllib.parse.rst:283 msgid "" "Parse a query string given as a string argument (data of type :mimetype:" "`application/x-www-form-urlencoded`). Data are returned as a list of name, " "value pairs." msgstr "" -#: ../../library/urllib.parse.rst:291 +#: ../../library/urllib.parse.rst:308 msgid "" "Use the :func:`urllib.parse.urlencode` function to convert such lists of " "pairs into query strings." msgstr "" -#: ../../library/urllib.parse.rst:309 +#: ../../library/urllib.parse.rst:327 msgid "" -"Construct a URL from a tuple as returned by ``urlsplit()``. The *parts* " -"argument can be any five-item iterable. This may result in a slightly " -"different, but equivalent URL, if the URL that was parsed originally had " -"unnecessary delimiters (for example, a ``?`` with an empty query; the RFC " -"states that these are equivalent)." +"Construct a URL from a tuple as returned by :func:`urlsplit`. The *parts* " +"argument can be any five-item iterable." msgstr "" -#: ../../library/urllib.parse.rst:318 +#: ../../library/urllib.parse.rst:330 ../../library/urllib.parse.rst:368 +msgid "" +"This may result in a slightly different, but equivalent URL, if the URL that " +"was parsed originally had unnecessary delimiters (for example, a ``?`` with " +"an empty query; the RFC states that these are equivalent)." +msgstr "" + +#: ../../library/urllib.parse.rst:334 +msgid "" +"If *keep_empty* is true, empty strings are kept in the result (for example, " +"a ``?`` for an empty query), only ``None`` components are omitted. This " +"allows rebuilding a URL that was parsed with option " +"``missing_as_none=True``. By default, *keep_empty* is true if *parts* is the " +"result of the :func:`urlsplit` call with ``missing_as_none=True``." +msgstr "" + +#: ../../library/urllib.parse.rst:341 ../../library/urllib.parse.rst:379 +msgid "Added the *keep_empty* parameter." +msgstr "新增 *keep_empty* 參數。" + +#: ../../library/urllib.parse.rst:347 msgid "" "This is similar to :func:`urlsplit`, but additionally splits the *path* " "component on *path* and *params*. This function returns a 6-item :term:" @@ -530,7 +574,7 @@ msgid "" "inserted at index 3, between *path* and *query*." msgstr "" -#: ../../library/urllib.parse.rst:325 +#: ../../library/urllib.parse.rst:354 msgid "" "This function is based on obsoleted :rfc:`1738` and :rfc:`1808`, which " "listed *params* as the main URL component. The more recent URL syntax allows " @@ -540,16 +584,22 @@ msgid "" "and parameters." msgstr "" -#: ../../library/urllib.parse.rst:334 +#: ../../library/urllib.parse.rst:364 msgid "" "Combine the elements of a tuple as returned by :func:`urlparse` into a " -"complete URL as a string. The *parts* argument can be any six-item iterable. " -"This may result in a slightly different, but equivalent URL, if the URL that " -"was parsed originally had unnecessary delimiters (for example, a ? with an " -"empty query; the RFC states that these are equivalent)." +"complete URL as a string. The *parts* argument can be any six-item iterable." +msgstr "" + +#: ../../library/urllib.parse.rst:372 +msgid "" +"If *keep_empty* is true, empty strings are kept in the result (for example, " +"a ``?`` for an empty query), only ``None`` components are omitted. This " +"allows rebuilding a URL that was parsed with option " +"``missing_as_none=True``. By default, *keep_empty* is true if *parts* is the " +"result of the :func:`urlparse` call with ``missing_as_none=True``." msgstr "" -#: ../../library/urllib.parse.rst:343 +#: ../../library/urllib.parse.rst:385 msgid "" "Construct a full (\"absolute\") URL by combining a \"base URL\" (*base*) " "with another URL (*url*). Informally, this uses components of the base URL, " @@ -557,20 +607,20 @@ msgid "" "path, to provide missing components in the relative URL. For example:" msgstr "" -#: ../../library/urllib.parse.rst:352 +#: ../../library/urllib.parse.rst:394 msgid "" "The *allow_fragments* argument has the same meaning and default as for :func:" "`urlsplit`." msgstr "" -#: ../../library/urllib.parse.rst:357 +#: ../../library/urllib.parse.rst:399 msgid "" "If *url* is an absolute URL (that is, it starts with ``//`` or ``scheme://" "``), the *url*'s hostname and/or scheme will be present in the result. For " "example:" msgstr "" -#: ../../library/urllib.parse.rst:360 +#: ../../library/urllib.parse.rst:402 msgid "" ">>> urljoin('http://www.cwi.nl/%7Eguido/Python.html',\n" "... '//www.python.org/%7Eguido')\n" @@ -580,13 +630,13 @@ msgstr "" "... '//www.python.org/%7Eguido')\n" "'http://www.python.org/%7Eguido'" -#: ../../library/urllib.parse.rst:366 +#: ../../library/urllib.parse.rst:408 msgid "" "If you do not want that behavior, preprocess the *url* with :func:`urlsplit` " "and :func:`urlunsplit`, removing possible *scheme* and *netloc* parts." msgstr "" -#: ../../library/urllib.parse.rst:371 +#: ../../library/urllib.parse.rst:413 msgid "" "Because an absolute URL may be passed as the ``url`` parameter, it is " "generally **not secure** to use ``urljoin`` with an attacker-controlled " @@ -595,43 +645,48 @@ msgid "" "``urljoin`` will be the absolute URL." msgstr "" -#: ../../library/urllib.parse.rst:381 +#: ../../library/urllib.parse.rst:423 msgid "Behavior updated to match the semantics defined in :rfc:`3986`." msgstr "" -#: ../../library/urllib.parse.rst:386 +#: ../../library/urllib.parse.rst:428 msgid "" "If *url* contains a fragment identifier, return a modified version of *url* " "with no fragment identifier, and the fragment identifier as a separate " "string. If there is no fragment identifier in *url*, return *url* " -"unmodified and an empty string." +"unmodified and an empty string (by default) or ``None`` if *missing_as_none* " +"is true." msgstr "" -#: ../../library/urllib.parse.rst:391 +#: ../../library/urllib.parse.rst:433 msgid "" "The return value is a :term:`named tuple`, its items can be accessed by " "index or as named attributes:" msgstr "" -#: ../../library/urllib.parse.rst:397 +#: ../../library/urllib.parse.rst:439 msgid ":attr:`url`" msgstr ":attr:`url`" -#: ../../library/urllib.parse.rst:397 +#: ../../library/urllib.parse.rst:439 msgid "URL with no fragment" msgstr "" -#: ../../library/urllib.parse.rst:402 +#: ../../library/urllib.parse.rst:441 +msgid "``None`` or empty string [3]_" +msgstr "" + +#: ../../library/urllib.parse.rst:446 msgid "" "See section :ref:`urlparse-result-object` for more information on the result " "object." msgstr "" -#: ../../library/urllib.parse.rst:405 +#: ../../library/urllib.parse.rst:449 msgid "Result is a structured object rather than a simple 2-tuple." msgstr "" -#: ../../library/urllib.parse.rst:410 +#: ../../library/urllib.parse.rst:457 msgid "" "Extract the url from a wrapped URL (that is, a string formatted as ````, ````, ``URL:scheme://host/path`` " @@ -639,11 +694,11 @@ msgid "" "without changes." msgstr "" -#: ../../library/urllib.parse.rst:418 +#: ../../library/urllib.parse.rst:465 msgid "URL parsing security" msgstr "" -#: ../../library/urllib.parse.rst:420 +#: ../../library/urllib.parse.rst:467 msgid "" "The :func:`urlsplit` and :func:`urlparse` APIs do not perform **validation** " "of inputs. They may not raise errors on inputs that other applications " @@ -652,14 +707,15 @@ msgid "" "rather than purity." msgstr "" -#: ../../library/urllib.parse.rst:426 +#: ../../library/urllib.parse.rst:473 msgid "" "Instead of raising an exception on unusual input, they may instead return " -"some component parts as empty strings. Or components may contain more than " -"perhaps they should." +"some component parts as empty strings or ``None`` (depending on the value of " +"the *missing_as_none* argument). Or components may contain more than perhaps " +"they should." msgstr "" -#: ../../library/urllib.parse.rst:430 +#: ../../library/urllib.parse.rst:478 msgid "" "We recommend that users of these APIs where the values may be used anywhere " "with security implications code defensively. Do some verification within " @@ -668,7 +724,7 @@ msgid "" "that ``hostname``? etc." msgstr "" -#: ../../library/urllib.parse.rst:436 +#: ../../library/urllib.parse.rst:484 msgid "" "What constitutes a URL is not universally well defined. Different " "applications have different needs and desired constraints. For instance the " @@ -680,11 +736,11 @@ msgid "" "API behavior changes." msgstr "" -#: ../../library/urllib.parse.rst:447 +#: ../../library/urllib.parse.rst:495 msgid "Parsing ASCII Encoded Bytes" msgstr "" -#: ../../library/urllib.parse.rst:449 +#: ../../library/urllib.parse.rst:497 msgid "" "The URL parsing functions were originally designed to operate on character " "strings only. In practice, it is useful to be able to manipulate properly " @@ -693,14 +749,14 @@ msgid "" "`bytearray` objects in addition to :class:`str` objects." msgstr "" -#: ../../library/urllib.parse.rst:455 +#: ../../library/urllib.parse.rst:503 msgid "" "If :class:`str` data is passed in, the result will also contain only :class:" "`str` data. If :class:`bytes` or :class:`bytearray` data is passed in, the " "result will contain only :class:`bytes` data." msgstr "" -#: ../../library/urllib.parse.rst:459 +#: ../../library/urllib.parse.rst:507 msgid "" "Attempting to mix :class:`str` data with :class:`bytes` or :class:" "`bytearray` in a single function call will result in a :exc:`TypeError` " @@ -708,7 +764,7 @@ msgid "" "trigger :exc:`UnicodeDecodeError`." msgstr "" -#: ../../library/urllib.parse.rst:464 +#: ../../library/urllib.parse.rst:512 msgid "" "To support easier conversion of result objects between :class:`str` and :" "class:`bytes`, all return values from URL parsing functions provide either " @@ -721,14 +777,14 @@ msgid "" "`str` data (for :meth:`decode` methods)." msgstr "" -#: ../../library/urllib.parse.rst:475 +#: ../../library/urllib.parse.rst:523 msgid "" "Applications that need to operate on potentially improperly quoted URLs that " "may contain non-ASCII data will need to do their own decoding from bytes to " "characters before invoking the URL parsing methods." msgstr "" -#: ../../library/urllib.parse.rst:479 +#: ../../library/urllib.parse.rst:527 msgid "" "The behaviour described in this section applies only to the URL parsing " "functions. The URL quoting functions use their own rules when producing or " @@ -736,15 +792,15 @@ msgid "" "URL quoting functions." msgstr "" -#: ../../library/urllib.parse.rst:484 +#: ../../library/urllib.parse.rst:532 msgid "URL parsing functions now accept ASCII encoded byte sequences" msgstr "" -#: ../../library/urllib.parse.rst:491 +#: ../../library/urllib.parse.rst:539 msgid "Structured Parse Results" msgstr "" -#: ../../library/urllib.parse.rst:493 +#: ../../library/urllib.parse.rst:541 msgid "" "The result objects from the :func:`urlsplit`, :func:`urlparse` and :func:" "`urldefrag` functions are subclasses of the :class:`tuple` type. These " @@ -753,80 +809,81 @@ msgid "" "section, as well as an additional method:" msgstr "" -#: ../../library/urllib.parse.rst:501 +#: ../../library/urllib.parse.rst:549 msgid "" "Return the re-combined version of the original URL as a string. This may " "differ from the original URL in that the scheme may be normalized to lower " "case and empty components may be dropped. Specifically, empty parameters, " -"queries, and fragment identifiers will be removed." +"queries, and fragment identifiers will be removed unless the URL was parsed " +"with ``missing_as_none=True``." msgstr "" -#: ../../library/urllib.parse.rst:506 +#: ../../library/urllib.parse.rst:555 msgid "" "For :func:`urldefrag` results, only empty fragment identifiers will be " "removed. For :func:`urlsplit` and :func:`urlparse` results, all noted " "changes will be made to the URL returned by this method." msgstr "" -#: ../../library/urllib.parse.rst:510 +#: ../../library/urllib.parse.rst:559 msgid "" "The result of this method remains unchanged if passed back through the " "original parsing function:" msgstr "" -#: ../../library/urllib.parse.rst:523 +#: ../../library/urllib.parse.rst:575 msgid "" "The following classes provide the implementations of the structured parse " "results when operating on :class:`str` objects:" msgstr "" -#: ../../library/urllib.parse.rst:528 +#: ../../library/urllib.parse.rst:580 msgid "" "Concrete class for :func:`urldefrag` results containing :class:`str` data. " "The :meth:`encode` method returns a :class:`DefragResultBytes` instance." msgstr "" -#: ../../library/urllib.parse.rst:536 +#: ../../library/urllib.parse.rst:588 msgid "" "Concrete class for :func:`urlparse` results containing :class:`str` data. " "The :meth:`encode` method returns a :class:`ParseResultBytes` instance." msgstr "" -#: ../../library/urllib.parse.rst:542 +#: ../../library/urllib.parse.rst:594 msgid "" "Concrete class for :func:`urlsplit` results containing :class:`str` data. " "The :meth:`encode` method returns a :class:`SplitResultBytes` instance." msgstr "" -#: ../../library/urllib.parse.rst:547 +#: ../../library/urllib.parse.rst:599 msgid "" "The following classes provide the implementations of the parse results when " "operating on :class:`bytes` or :class:`bytearray` objects:" msgstr "" -#: ../../library/urllib.parse.rst:552 +#: ../../library/urllib.parse.rst:604 msgid "" "Concrete class for :func:`urldefrag` results containing :class:`bytes` data. " "The :meth:`decode` method returns a :class:`DefragResult` instance." msgstr "" -#: ../../library/urllib.parse.rst:560 +#: ../../library/urllib.parse.rst:612 msgid "" "Concrete class for :func:`urlparse` results containing :class:`bytes` data. " "The :meth:`decode` method returns a :class:`ParseResult` instance." msgstr "" -#: ../../library/urllib.parse.rst:568 +#: ../../library/urllib.parse.rst:620 msgid "" "Concrete class for :func:`urlsplit` results containing :class:`bytes` data. " "The :meth:`decode` method returns a :class:`SplitResult` instance." msgstr "" -#: ../../library/urllib.parse.rst:576 +#: ../../library/urllib.parse.rst:628 msgid "URL Quoting" msgstr "" -#: ../../library/urllib.parse.rst:578 +#: ../../library/urllib.parse.rst:630 msgid "" "The URL quoting functions focus on taking program data and making it safe " "for use as URL components by quoting special characters and appropriately " @@ -835,7 +892,7 @@ msgid "" "isn't already covered by the URL parsing functions above." msgstr "" -#: ../../library/urllib.parse.rst:586 +#: ../../library/urllib.parse.rst:638 msgid "" "Replace special characters in *string* using the :samp:`%{xx}` escape. " "Letters, digits, and the characters ``'_.-~'`` are never quoted. By default, " @@ -844,18 +901,18 @@ msgid "" "not be quoted --- its default value is ``'/'``." msgstr "" -#: ../../library/urllib.parse.rst:592 ../../library/urllib.parse.rst:639 -#: ../../library/urllib.parse.rst:668 +#: ../../library/urllib.parse.rst:644 ../../library/urllib.parse.rst:691 +#: ../../library/urllib.parse.rst:720 msgid "*string* may be either a :class:`str` or a :class:`bytes` object." msgstr "" -#: ../../library/urllib.parse.rst:594 +#: ../../library/urllib.parse.rst:646 msgid "" "Moved from :rfc:`2396` to :rfc:`3986` for quoting URL strings. \"~\" is now " "included in the set of unreserved characters." msgstr "" -#: ../../library/urllib.parse.rst:598 +#: ../../library/urllib.parse.rst:650 msgid "" "The optional *encoding* and *errors* parameters specify how to deal with non-" "ASCII characters, as accepted by the :meth:`str.encode` method. Although " @@ -866,17 +923,17 @@ msgid "" "supplied if *string* is a :class:`bytes`, or a :class:`TypeError` is raised." msgstr "" -#: ../../library/urllib.parse.rst:607 +#: ../../library/urllib.parse.rst:659 msgid "" "Note that ``quote(string, safe, encoding, errors)`` is equivalent to " "``quote_from_bytes(string.encode(encoding, errors), safe)``." msgstr "" -#: ../../library/urllib.parse.rst:610 +#: ../../library/urllib.parse.rst:662 msgid "Example: ``quote('/El Niño/')`` yields ``'/El%20Ni%C3%B1o/'``." msgstr "" -#: ../../library/urllib.parse.rst:615 +#: ../../library/urllib.parse.rst:667 msgid "" "Like :func:`quote`, but also replace spaces with plus signs, as required for " "quoting HTML form values when building up a query string to go into a URL. " @@ -884,21 +941,21 @@ msgid "" "*safe*. It also does not have *safe* default to ``'/'``." msgstr "" -#: ../../library/urllib.parse.rst:620 +#: ../../library/urllib.parse.rst:672 msgid "Example: ``quote_plus('/El Niño/')`` yields ``'%2FEl+Ni%C3%B1o%2F'``." msgstr "" -#: ../../library/urllib.parse.rst:625 +#: ../../library/urllib.parse.rst:677 msgid "" "Like :func:`quote`, but accepts a :class:`bytes` object rather than a :class:" "`str`, and does not perform string-to-bytes encoding." msgstr "" -#: ../../library/urllib.parse.rst:628 +#: ../../library/urllib.parse.rst:680 msgid "Example: ``quote_from_bytes(b'a&\\xef')`` yields ``'a%26%EF'``." msgstr "" -#: ../../library/urllib.parse.rst:634 +#: ../../library/urllib.parse.rst:686 msgid "" "Replace :samp:`%{xx}` escapes with their single-character equivalent. The " "optional *encoding* and *errors* parameters specify how to decode percent-" @@ -906,52 +963,52 @@ msgid "" "decode` method." msgstr "" -#: ../../library/urllib.parse.rst:641 +#: ../../library/urllib.parse.rst:693 msgid "" "*encoding* defaults to ``'utf-8'``. *errors* defaults to ``'replace'``, " "meaning invalid sequences are replaced by a placeholder character." msgstr "" -#: ../../library/urllib.parse.rst:645 +#: ../../library/urllib.parse.rst:697 msgid "Example: ``unquote('/El%20Ni%C3%B1o/')`` yields ``'/El Niño/'``." msgstr "" -#: ../../library/urllib.parse.rst:647 +#: ../../library/urllib.parse.rst:699 msgid "" "*string* parameter supports bytes and str objects (previously only str)." msgstr "" -#: ../../library/urllib.parse.rst:655 +#: ../../library/urllib.parse.rst:707 msgid "" "Like :func:`unquote`, but also replace plus signs with spaces, as required " "for unquoting HTML form values." msgstr "" -#: ../../library/urllib.parse.rst:658 +#: ../../library/urllib.parse.rst:710 msgid "*string* must be a :class:`str`." msgstr "" -#: ../../library/urllib.parse.rst:660 +#: ../../library/urllib.parse.rst:712 msgid "Example: ``unquote_plus('/El+Ni%C3%B1o/')`` yields ``'/El Niño/'``." msgstr "" -#: ../../library/urllib.parse.rst:665 +#: ../../library/urllib.parse.rst:717 msgid "" "Replace :samp:`%{xx}` escapes with their single-octet equivalent, and return " "a :class:`bytes` object." msgstr "" -#: ../../library/urllib.parse.rst:670 +#: ../../library/urllib.parse.rst:722 msgid "" "If it is a :class:`str`, unescaped non-ASCII characters in *string* are " "encoded into UTF-8 bytes." msgstr "" -#: ../../library/urllib.parse.rst:673 +#: ../../library/urllib.parse.rst:725 msgid "Example: ``unquote_to_bytes('a%26%EF')`` yields ``b'a&\\xef'``." msgstr "" -#: ../../library/urllib.parse.rst:679 +#: ../../library/urllib.parse.rst:731 msgid "" "Convert a mapping object or a sequence of two-element tuples, which may " "contain :class:`str` or :class:`bytes` objects, to a percent-encoded ASCII " @@ -960,7 +1017,7 @@ msgid "" "be encoded to bytes, otherwise it would result in a :exc:`TypeError`." msgstr "" -#: ../../library/urllib.parse.rst:686 +#: ../../library/urllib.parse.rst:738 msgid "" "The resulting string is a series of ``key=value`` pairs separated by ``'&'`` " "characters, where both *key* and *value* are quoted using the *quote_via* " @@ -973,7 +1030,7 @@ msgid "" "``quote`` and specify a value for *safe*." msgstr "" -#: ../../library/urllib.parse.rst:696 +#: ../../library/urllib.parse.rst:748 msgid "" "When a sequence of two-element tuples is used as the *query* argument, the " "first element of each tuple is a key and the second is a value. The value " @@ -984,49 +1041,49 @@ msgid "" "order of parameter tuples in the sequence." msgstr "" -#: ../../library/urllib.parse.rst:704 +#: ../../library/urllib.parse.rst:756 msgid "" "The *safe*, *encoding*, and *errors* parameters are passed down to " "*quote_via* (the *encoding* and *errors* parameters are only passed when a " "query element is a :class:`str`)." msgstr "" -#: ../../library/urllib.parse.rst:708 +#: ../../library/urllib.parse.rst:760 msgid "" "To reverse this encoding process, :func:`parse_qs` and :func:`parse_qsl` are " "provided in this module to parse query strings into Python data structures." msgstr "" -#: ../../library/urllib.parse.rst:711 +#: ../../library/urllib.parse.rst:763 msgid "" "Refer to :ref:`urllib examples ` to find out how the :func:" "`urllib.parse.urlencode` method can be used for generating the query string " "of a URL or data for a POST request." msgstr "" -#: ../../library/urllib.parse.rst:715 +#: ../../library/urllib.parse.rst:767 msgid "*query* supports bytes and string objects." msgstr "" -#: ../../library/urllib.parse.rst:718 +#: ../../library/urllib.parse.rst:770 msgid "Added the *quote_via* parameter." msgstr "新增 *quote_via* 參數。" -#: ../../library/urllib.parse.rst:728 +#: ../../library/urllib.parse.rst:780 msgid "`WHATWG`_ - URL Living standard" msgstr "" -#: ../../library/urllib.parse.rst:729 +#: ../../library/urllib.parse.rst:781 msgid "" "Working Group for the URL Standard that defines URLs, domains, IP addresses, " "the application/x-www-form-urlencoded format, and their API." msgstr "" -#: ../../library/urllib.parse.rst:732 +#: ../../library/urllib.parse.rst:784 msgid ":rfc:`3986` - Uniform Resource Identifiers" msgstr ":rfc:`3986` - 統一資源識別碼" -#: ../../library/urllib.parse.rst:733 +#: ../../library/urllib.parse.rst:785 msgid "" "This is the current standard (STD66). Any changes to urllib.parse module " "should conform to this. Certain deviations could be observed, which are " @@ -1034,49 +1091,49 @@ msgid "" "requirements as commonly observed in major browsers." msgstr "" -#: ../../library/urllib.parse.rst:738 +#: ../../library/urllib.parse.rst:790 msgid ":rfc:`2732` - Format for Literal IPv6 Addresses in URL's." msgstr "" -#: ../../library/urllib.parse.rst:739 +#: ../../library/urllib.parse.rst:791 msgid "This specifies the parsing requirements of IPv6 URLs." msgstr "" -#: ../../library/urllib.parse.rst:741 +#: ../../library/urllib.parse.rst:793 msgid ":rfc:`2396` - Uniform Resource Identifiers (URI): Generic Syntax" msgstr ":rfc:`2396` - 統一資源識別碼 (URI):通用語法" -#: ../../library/urllib.parse.rst:742 +#: ../../library/urllib.parse.rst:794 msgid "" "Document describing the generic syntactic requirements for both Uniform " "Resource Names (URNs) and Uniform Resource Locators (URLs)." msgstr "" -#: ../../library/urllib.parse.rst:745 +#: ../../library/urllib.parse.rst:797 msgid ":rfc:`2368` - The mailto URL scheme." msgstr "" -#: ../../library/urllib.parse.rst:746 +#: ../../library/urllib.parse.rst:798 msgid "Parsing requirements for mailto URL schemes." msgstr "" -#: ../../library/urllib.parse.rst:748 +#: ../../library/urllib.parse.rst:800 msgid ":rfc:`1808` - Relative Uniform Resource Locators" msgstr "" ":rfc:`1808` - 相對的統一資源定位器 (Relative Uniform Resource Locators)" -#: ../../library/urllib.parse.rst:749 +#: ../../library/urllib.parse.rst:801 msgid "" "This Request For Comments includes the rules for joining an absolute and a " "relative URL, including a fair number of \"Abnormal Examples\" which govern " "the treatment of border cases." msgstr "" -#: ../../library/urllib.parse.rst:753 +#: ../../library/urllib.parse.rst:805 msgid ":rfc:`1738` - Uniform Resource Locators (URL)" msgstr ":rfc:`1738` - 統一資源定位器 (URL, Uniform Resource Locators)" -#: ../../library/urllib.parse.rst:754 +#: ../../library/urllib.parse.rst:806 msgid "This specifies the formal syntax and semantics of absolute URLs." msgstr "" @@ -1100,6 +1157,9 @@ msgstr "parsing(剖析)" msgid "relative" msgstr "relative(相對)" +#~ msgid ":const:`None`" +#~ msgstr ":const:`None`" + #~ msgid ":attr:`params`" #~ msgstr ":attr:`params`" diff --git a/library/urllib.request.po b/library/urllib.request.po index 2d25bbb8b74..432ba3adce9 100644 --- a/library/urllib.request.po +++ b/library/urllib.request.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-04 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!urllib.request` --- Extensible library for opening URLs" msgstr ":mod:`!urllib.request` --- 用來開啟 URLs 的可擴充函式庫" -#: ../../library/urllib.request.rst:11 +#: ../../library/urllib.request.rst:7 msgid "**Source code:** :source:`Lib/urllib/request.py`" msgstr "**原始碼:**\\ :source:`Lib/urllib/request.py`" -#: ../../library/urllib.request.rst:15 +#: ../../library/urllib.request.rst:11 msgid "" "The :mod:`!urllib.request` module defines functions and classes which help " "in opening URLs (mostly HTTP) in a complex world --- basic and digest " @@ -37,7 +37,7 @@ msgstr "" "URLs(大部分是 HTTP),並處理各式複雜情況如:basic 驗證與 digest 驗證、重新導" "向、cookies。" -#: ../../library/urllib.request.rst:21 +#: ../../library/urllib.request.rst:17 msgid "" "The `Requests package `_ is " "recommended for a higher-level HTTP client interface." @@ -45,7 +45,7 @@ msgstr "" "有關於更高階的 HTTP 用戶端介面,推薦使用 `Requests 套件 `_。" -#: ../../library/urllib.request.rst:26 +#: ../../library/urllib.request.rst:22 msgid "" "On macOS it is unsafe to use this module in programs using :func:`os.fork` " "because the :func:`getproxies` implementation for macOS uses a higher-level " @@ -65,11 +65,11 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/urllib.request.rst:34 +#: ../../library/urllib.request.rst:30 msgid "The :mod:`!urllib.request` module defines the following functions:" msgstr ":mod:`!urllib.request` module 定義下列函式:" -#: ../../library/urllib.request.rst:39 +#: ../../library/urllib.request.rst:35 msgid "" "Open *url*, which can be either a string containing a valid, properly " "encoded URL, or a :class:`Request` object." @@ -77,7 +77,7 @@ msgstr "" "打開 *url*,其值可以是一個包含有效且適當編碼 URL 的字串或是一個 :class:" "`Request` 物件。" -#: ../../library/urllib.request.rst:42 +#: ../../library/urllib.request.rst:38 msgid "" "*data* must be an object specifying additional data to be sent to the " "server, or ``None`` if no such data is needed. See :class:`Request` for " @@ -86,7 +86,7 @@ msgstr "" "*data* 必須是一個包含傳送給伺服器額外資料的物件,若不需要傳送額外資料則指定" "為 ``None``。更多細節請見 :class:`Request`。" -#: ../../library/urllib.request.rst:46 +#: ../../library/urllib.request.rst:42 msgid "" "urllib.request module uses HTTP/1.1 and includes ``Connection:close`` header " "in its HTTP requests." @@ -94,7 +94,7 @@ msgstr "" "urllib.request module 使用 HTTP/1.1 並包含 ``Connection:close`` header(標" "頭)在其 HTTP 請求中。" -#: ../../library/urllib.request.rst:49 +#: ../../library/urllib.request.rst:45 msgid "" "The optional *timeout* parameter specifies a timeout in seconds for blocking " "operations like the connection attempt (if not specified, the global default " @@ -105,7 +105,7 @@ msgstr "" "接)的 timeout(超時時間),以秒為單位。若沒有指定值,則會使用全域預設超時時" "間設定。實際上,此參數僅作用於 HTTP、HTTPS 以及 FTP 的連接。" -#: ../../library/urllib.request.rst:54 +#: ../../library/urllib.request.rst:50 msgid "" "If *context* is specified, it must be a :class:`ssl.SSLContext` instance " "describing the various SSL options. See :class:`~http.client." @@ -114,7 +114,7 @@ msgstr "" "若 *context* 有被指定時,它必須是一個 :class:`ssl.SSLContext` 的實例並描述著" "各種 SSL 選項。更多細節請見 :class:`~http.client.HTTPSConnection`。" -#: ../../library/urllib.request.rst:58 +#: ../../library/urllib.request.rst:54 msgid "" "This function always returns an object which can work as a :term:`context " "manager` and has the properties *url*, *headers*, and *status*. See :class:" @@ -124,7 +124,7 @@ msgstr "" "(property) *url*、*headers* 與 *status*。欲知更多這些特性細節請參見 :class:" "`urllib.response.addinfourl`。" -#: ../../library/urllib.request.rst:62 +#: ../../library/urllib.request.rst:58 msgid "" "For HTTP and HTTPS URLs, this function returns a :class:`http.client." "HTTPResponse` object slightly modified. In addition to the three new methods " @@ -139,7 +139,7 @@ msgstr "" "(reason phrase),而不是在 :class:`~http.client.HTTPResponse` 文件中提到的回" "應 headers。" -#: ../../library/urllib.request.rst:70 +#: ../../library/urllib.request.rst:66 msgid "" "For FTP, file, and data URLs, this function returns a :class:`urllib." "response.addinfourl` object." @@ -147,11 +147,11 @@ msgstr "" "對於 FTP、檔案及資料的 URLs,這個函式會回傳一個 :class:`urllib.response." "addinfourl` 物件。" -#: ../../library/urllib.request.rst:73 +#: ../../library/urllib.request.rst:69 msgid "Raises :exc:`~urllib.error.URLError` on protocol errors." msgstr "當遇到協定上的錯誤時會引發 :exc:`~urllib.error.URLError`。" -#: ../../library/urllib.request.rst:75 +#: ../../library/urllib.request.rst:71 msgid "" "Note that ``None`` may be returned if no handler handles the request (though " "the default installed global :class:`OpenerDirector` uses :class:" @@ -161,7 +161,7 @@ msgstr "" "別 :class:`OpenerDirector` 使用 :class:`UnknownHandler` 來確保這種情況不會發" "生)" -#: ../../library/urllib.request.rst:79 +#: ../../library/urllib.request.rst:75 msgid "" "In addition, if proxy settings are detected (for example, when a ``*_proxy`` " "environment variable like :envvar:`!http_proxy` is set), :class:" @@ -172,7 +172,7 @@ msgstr "" "http_proxy` 有被設置時),:class:`ProxyHandler` 會被預設使用以確保請求有透過" "代理服務來處理。" -#: ../../library/urllib.request.rst:84 +#: ../../library/urllib.request.rst:80 msgid "" "The legacy ``urllib.urlopen`` function from Python 2.6 and earlier has been " "discontinued; :func:`urllib.request.urlopen` corresponds to the old " @@ -185,7 +185,7 @@ msgstr "" "的處理,以往是透過傳遞 dictionary(字典)參數給 ``urllib.urlopen`` 來取得的," "現在則可以透過 :class:`ProxyHandler` 物件來取得。" -#: ../../library/urllib.request.rst:90 ../../library/urllib.request.rst:92 +#: ../../library/urllib.request.rst:86 ../../library/urllib.request.rst:88 msgid "" "The default opener raises an :ref:`auditing event ` ``urllib." "Request`` with arguments ``fullurl``, ``data``, ``headers``, ``method`` " @@ -194,11 +194,11 @@ msgstr "" "預設的 opener 會觸發一個 :ref:`auditing event ` ``urllib.Request`` " "與其從請求物件中所獲得的引數 ``fullurl``、``data``、``headers``、``method``。" -#: ../../library/urllib.request.rst:96 +#: ../../library/urllib.request.rst:92 msgid "*cafile* and *capath* were added." msgstr "新增 *cafile* 與 *capath*。" -#: ../../library/urllib.request.rst:99 +#: ../../library/urllib.request.rst:95 msgid "" "HTTPS virtual hosts are now supported if possible (that is, if :const:`ssl." "HAS_SNI` is true)." @@ -206,19 +206,19 @@ msgstr "" "HTTPS 虛擬主機 (virtual hosts) 現已支援,只要 :const:`ssl.HAS_SNI` 的值為 " "true。" -#: ../../library/urllib.request.rst:102 +#: ../../library/urllib.request.rst:98 msgid "*data* can be an iterable object." msgstr "*data* 可以是一個可疊代物件。" -#: ../../library/urllib.request.rst:104 +#: ../../library/urllib.request.rst:100 msgid "*cadefault* was added." msgstr "*cadefault* 被新增。" -#: ../../library/urllib.request.rst:107 +#: ../../library/urllib.request.rst:103 msgid "*context* was added." msgstr "*context* 被新增。" -#: ../../library/urllib.request.rst:110 +#: ../../library/urllib.request.rst:106 msgid "" "HTTPS connection now send an ALPN extension with protocol indicator " "``http/1.1`` when no *context* is given. Custom *context* should set ALPN " @@ -228,13 +228,13 @@ msgstr "" "``http/1.1`` 的 ALPN 擴充 (extension)。自訂的 *context* 應該利用 :meth:`~ssl." "SSLContext.set_alpn_protocols` 來自行設定 ALPN 協定。" -#: ../../library/urllib.request.rst:115 +#: ../../library/urllib.request.rst:111 msgid "" "Remove *cafile*, *capath* and *cadefault* parameters: use the *context* " "parameter instead." msgstr "" -#: ../../library/urllib.request.rst:122 +#: ../../library/urllib.request.rst:118 msgid "" "Install an :class:`OpenerDirector` instance as the default global opener. " "Installing an opener is only necessary if you want urlopen to use that " @@ -248,7 +248,7 @@ msgstr "" "class 是否真的為 :class:`OpenerDirector`,而是任何具有正確介面的 class 都能適" "用。" -#: ../../library/urllib.request.rst:132 +#: ../../library/urllib.request.rst:128 msgid "" "Return an :class:`OpenerDirector` instance, which chains the handlers in the " "order given. *handler*\\s can be either instances of :class:`BaseHandler`, " @@ -270,7 +270,7 @@ msgstr "" "`HTTPDefaultErrorHandler`、:class:`HTTPRedirectHandler`、:class:" "`FTPHandler`、:class:`FileHandler`、:class:`HTTPErrorProcessor`。" -#: ../../library/urllib.request.rst:142 +#: ../../library/urllib.request.rst:138 msgid "" "If the Python installation has SSL support (i.e., if the :mod:`ssl` module " "can be imported), :class:`HTTPSHandler` will also be added." @@ -278,7 +278,7 @@ msgstr "" "如果 Python 安裝時已帶有 SSL 支援(如果 :mod:`ssl` module 能夠被 import)," "則 :class:`HTTPSHandler` 也在上述 class 之中。" -#: ../../library/urllib.request.rst:145 +#: ../../library/urllib.request.rst:141 msgid "" "A :class:`BaseHandler` subclass may also change its :attr:`handler_order` " "attribute to modify its position in the handlers list." @@ -286,23 +286,23 @@ msgstr "" "一個 :class:`BaseHandler` 的 subclass 可能透過改變其 :attr:`handler_order` 屬" "性來調整它在 handlers list 中的位置。" -#: ../../library/urllib.request.rst:151 +#: ../../library/urllib.request.rst:147 msgid "" "Convert the given local path to a ``file:`` URL. This function uses :func:" "`~urllib.parse.quote` function to encode the path." msgstr "" -#: ../../library/urllib.request.rst:154 +#: ../../library/urllib.request.rst:150 msgid "" "If *add_scheme* is false (the default), the return value omits the ``file:`` " "scheme prefix. Set *add_scheme* to true to return a complete URL." msgstr "" -#: ../../library/urllib.request.rst:157 ../../library/urllib.request.rst:195 +#: ../../library/urllib.request.rst:153 ../../library/urllib.request.rst:191 msgid "This example shows the function being used on Windows::" msgstr "" -#: ../../library/urllib.request.rst:159 +#: ../../library/urllib.request.rst:155 msgid "" ">>> from urllib.request import pathname2url\n" ">>> path = 'C:\\\\Program Files'\n" @@ -314,31 +314,31 @@ msgstr "" ">>> pathname2url(path, add_scheme=True)\n" "'file:///C:/Program%20Files'" -#: ../../library/urllib.request.rst:164 ../../library/urllib.request.rst:202 +#: ../../library/urllib.request.rst:160 ../../library/urllib.request.rst:198 msgid "" "Windows drive letters are no longer converted to uppercase, and ``:`` " "characters not following a drive letter no longer cause an :exc:`OSError` " "exception to be raised on Windows." msgstr "" -#: ../../library/urllib.request.rst:169 +#: ../../library/urllib.request.rst:165 msgid "" "Paths beginning with a slash are converted to URLs with authority sections. " "For example, the path ``/etc/hosts`` is converted to the URL ``///etc/" "hosts``." msgstr "" -#: ../../library/urllib.request.rst:174 +#: ../../library/urllib.request.rst:170 msgid "The *add_scheme* parameter was added." msgstr "新增 *add_scheme* 參數。" -#: ../../library/urllib.request.rst:180 +#: ../../library/urllib.request.rst:176 msgid "" "Convert the given ``file:`` URL to a local path. This function uses :func:" "`~urllib.parse.unquote` to decode the URL." msgstr "" -#: ../../library/urllib.request.rst:183 +#: ../../library/urllib.request.rst:179 msgid "" "If *require_scheme* is false (the default), the given value should omit a " "``file:`` scheme prefix. If *require_scheme* is set to true, the given value " @@ -346,7 +346,7 @@ msgid "" "doesn't." msgstr "" -#: ../../library/urllib.request.rst:188 +#: ../../library/urllib.request.rst:184 msgid "" "The URL authority is discarded if it is empty, ``localhost``, or the local " "hostname. Otherwise, if *resolve_host* is set to true, the authority is " @@ -356,7 +356,7 @@ msgid "" "other platforms a :exc:`~urllib.error.URLError` is raised." msgstr "" -#: ../../library/urllib.request.rst:197 +#: ../../library/urllib.request.rst:193 msgid "" ">>> from urllib.request import url2pathname\n" ">>> url = 'file:///C:/Program%20Files'\n" @@ -368,7 +368,7 @@ msgstr "" ">>> url2pathname(url, require_scheme=True)\n" "'C:\\\\Program Files'" -#: ../../library/urllib.request.rst:207 +#: ../../library/urllib.request.rst:203 msgid "" "The URL authority is discarded if it matches the local hostname. Otherwise, " "if the authority isn't empty or ``localhost``, then on Windows a UNC path is " @@ -376,15 +376,15 @@ msgid "" "is raised." msgstr "" -#: ../../library/urllib.request.rst:213 +#: ../../library/urllib.request.rst:209 msgid "The URL query and fragment components are discarded if present." msgstr "" -#: ../../library/urllib.request.rst:216 +#: ../../library/urllib.request.rst:212 msgid "The *require_scheme* and *resolve_host* parameters were added." msgstr "" -#: ../../library/urllib.request.rst:222 +#: ../../library/urllib.request.rst:218 msgid "" "This helper function returns a dictionary of scheme to proxy server URL " "mappings. It scans the environment for variables named ``_proxy``, " @@ -399,7 +399,7 @@ msgstr "" "Configuration) 或是 Windows 系統中的 Windows Systems Registry 尋找代理服務設" "定。如果大小寫的環境變數同時存在且值有不同,小寫的環境變數會被選用。" -#: ../../library/urllib.request.rst:232 +#: ../../library/urllib.request.rst:228 msgid "" "If the environment variable ``REQUEST_METHOD`` is set, which usually " "indicates your script is running in a CGI environment, the environment " @@ -416,19 +416,19 @@ msgstr "" "``ProxyHandler``,亦或是確認變數名稱是小寫的(或至少 ``_proxy`` 後綴是小寫" "的)。" -#: ../../library/urllib.request.rst:241 +#: ../../library/urllib.request.rst:237 msgid "The following classes are provided:" msgstr "提供了以下的 classes:" -#: ../../library/urllib.request.rst:245 +#: ../../library/urllib.request.rst:241 msgid "This class is an abstraction of a URL request." msgstr "這個 class 是一個 URL 請求的抽象 class。" -#: ../../library/urllib.request.rst:247 +#: ../../library/urllib.request.rst:243 msgid "*url* should be a string containing a valid, properly encoded URL." msgstr "*url* 是一個包含有效且適當編碼的 URL 字串。" -#: ../../library/urllib.request.rst:249 +#: ../../library/urllib.request.rst:245 msgid "" "*data* must be an object specifying additional data to send to the server, " "or ``None`` if no such data is needed. Currently HTTP requests are the only " @@ -449,7 +449,7 @@ msgstr "" "``Transfer-Encoding: chunked`` 則會被用來傳送檔案或是其它可疊代物件 " "(iterables)。" -#: ../../library/urllib.request.rst:259 +#: ../../library/urllib.request.rst:255 msgid "" "For an HTTP POST request method, *data* should be a buffer in the standard :" "mimetype:`application/x-www-form-urlencoded` format. The :func:`urllib." @@ -462,7 +462,7 @@ msgstr "" "個 mapping 或是 sequence(序列)的 2-tuples,並回傳一個對應格式的 ASCII 字" "串。在被作為 *data* 參數前它應該被編碼成位元組串。" -#: ../../library/urllib.request.rst:265 +#: ../../library/urllib.request.rst:261 msgid "" "*headers* should be a dictionary, and will be treated as if :meth:" "`add_header` was called with each key and value as arguments. This is often " @@ -483,7 +483,7 @@ msgstr "" "(在 Python 2.6 上)。所有 header 的鍵都會以 camel case(駝峰式大小寫)來傳" "送。" -#: ../../library/urllib.request.rst:276 +#: ../../library/urllib.request.rst:272 msgid "" "An appropriate ``Content-Type`` header should be included if the *data* " "argument is present. If this header has not been provided and *data* is not " @@ -494,14 +494,14 @@ msgstr "" "個 header 沒有被提供且 *data* 也不為 ``None`` 時,預設值 ``Content-Type: " "application/x-www-form-urlencoded`` 會被新增至請求中。" -#: ../../library/urllib.request.rst:281 +#: ../../library/urllib.request.rst:277 msgid "" "The next two arguments are only of interest for correct handling of third-" "party HTTP cookies:" msgstr "" "接下來的兩個引數的介紹提供給那些有興趣正確處理第三方 HTTP cookies 的使用者:" -#: ../../library/urllib.request.rst:284 +#: ../../library/urllib.request.rst:280 msgid "" "*origin_req_host* should be the request-host of the origin transaction, as " "defined by :rfc:`2965`. It defaults to ``http.cookiejar." @@ -515,7 +515,7 @@ msgstr "" "起的原始請求的主機名稱或是 IP 位址。例如當請求是要求一個 HTML 文件中的一個影" "像,則這個屬性應為請求包含影像頁面的請求主機。" -#: ../../library/urllib.request.rst:292 +#: ../../library/urllib.request.rst:288 msgid "" "*unverifiable* should indicate whether the request is unverifiable, as " "defined by :rfc:`2965`. It defaults to ``False``. An unverifiable request " @@ -528,7 +528,7 @@ msgstr "" "URL,例如一個對於 HTML 文件中的影像所做的請求,而使用者沒有機會去批准是否能自" "動擷取影像,則這個值應該為 true。" -#: ../../library/urllib.request.rst:299 +#: ../../library/urllib.request.rst:295 msgid "" "*method* should be a string that indicates the HTTP request method that will " "be used (e.g. ``'HEAD'``). If provided, its value is stored in the :attr:" @@ -543,7 +543,7 @@ msgstr "" "Subclasses 可以透過設置其 :attr:`~Request.method` 屬性來設定不一樣的預設請求" "方法。" -#: ../../library/urllib.request.rst:307 +#: ../../library/urllib.request.rst:303 msgid "" "The request will not work as expected if the data object is unable to " "deliver its content more than once (e.g. a file or an iterable that can " @@ -557,15 +557,15 @@ msgstr "" "新嘗試傳送,則該請求不會正常運作。*data* 會接在 headers 之後被送至 HTTP 伺服" "器。此函式庫沒有支援 100-continue expectation。" -#: ../../library/urllib.request.rst:314 +#: ../../library/urllib.request.rst:310 msgid ":attr:`Request.method` argument is added to the Request class." msgstr "新增 :attr:`Request.method` 引數到 Request class。" -#: ../../library/urllib.request.rst:317 +#: ../../library/urllib.request.rst:313 msgid "Default :attr:`Request.method` may be indicated at the class level." msgstr "能夠在 class 中設置預設的 :attr:`Request.method`。" -#: ../../library/urllib.request.rst:320 +#: ../../library/urllib.request.rst:316 msgid "" "Do not raise an error if the ``Content-Length`` has not been provided and " "*data* is neither ``None`` nor a bytes object. Fall back to use chunked " @@ -575,34 +575,34 @@ msgstr "" "串物件,則不會觸發錯誤,並 fall back(後備)使用分塊傳輸編碼 (chunked " "transfer encoding)。" -#: ../../library/urllib.request.rst:327 +#: ../../library/urllib.request.rst:323 msgid "" "The :class:`OpenerDirector` class opens URLs via :class:`BaseHandler`\\ s " "chained together. It manages the chaining of handlers, and recovery from " "errors." msgstr "" -#: ../../library/urllib.request.rst:333 +#: ../../library/urllib.request.rst:329 msgid "" "This is the base class for all registered handlers --- and handles only the " "simple mechanics of registration." msgstr "" -#: ../../library/urllib.request.rst:339 +#: ../../library/urllib.request.rst:335 msgid "" "A class which defines a default handler for HTTP error responses; all " "responses are turned into :exc:`~urllib.error.HTTPError` exceptions." msgstr "" -#: ../../library/urllib.request.rst:345 +#: ../../library/urllib.request.rst:341 msgid "A class to handle redirections." msgstr "用於處理重新導向的類別。" -#: ../../library/urllib.request.rst:350 +#: ../../library/urllib.request.rst:346 msgid "A class to handle HTTP Cookies." msgstr "用於處理 HTTP Cookie 的類別。" -#: ../../library/urllib.request.rst:355 +#: ../../library/urllib.request.rst:351 msgid "" "Cause requests to go through a proxy. If *proxies* is given, it must be a " "dictionary mapping protocol names to URLs of proxies. The default is to read " @@ -613,11 +613,11 @@ msgid "" "Configuration Framework." msgstr "" -#: ../../library/urllib.request.rst:363 +#: ../../library/urllib.request.rst:359 msgid "To disable autodetected proxy pass an empty dictionary." msgstr "" -#: ../../library/urllib.request.rst:365 +#: ../../library/urllib.request.rst:361 msgid "" "The :envvar:`no_proxy` environment variable can be used to specify hosts " "which shouldn't be reached via proxy; if set, it should be a comma-separated " @@ -625,24 +625,24 @@ msgid "" "``cern.ch,ncsa.uiuc.edu,some.host:8080``." msgstr "" -#: ../../library/urllib.request.rst:372 +#: ../../library/urllib.request.rst:368 msgid "" "``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set; see " "the documentation on :func:`~urllib.request.getproxies`." msgstr "" -#: ../../library/urllib.request.rst:378 +#: ../../library/urllib.request.rst:374 msgid "Keep a database of ``(realm, uri) -> (user, password)`` mappings." msgstr "" -#: ../../library/urllib.request.rst:383 +#: ../../library/urllib.request.rst:379 msgid "" "Keep a database of ``(realm, uri) -> (user, password)`` mappings. A realm " "of ``None`` is considered a catch-all realm, which is searched if no other " "realm fits." msgstr "" -#: ../../library/urllib.request.rst:390 +#: ../../library/urllib.request.rst:386 msgid "" "A variant of :class:`HTTPPasswordMgrWithDefaultRealm` that also has a " "database of ``uri -> is_authenticated`` mappings. Can be used by a " @@ -650,7 +650,7 @@ msgid "" "immediately instead of waiting for a ``401`` response first." msgstr "" -#: ../../library/urllib.request.rst:400 +#: ../../library/urllib.request.rst:396 msgid "" "This is a mixin class that helps with HTTP authentication, both to the " "remote host and to a proxy. *password_mgr*, if given, should be something " @@ -669,11 +669,11 @@ msgid "" "will automatically include the authentication credentials." msgstr "" -#: ../../library/urllib.request.rst:417 +#: ../../library/urllib.request.rst:413 msgid "Added ``is_authenticated`` support." msgstr "新增 ``is_authenticated`` 的支援。" -#: ../../library/urllib.request.rst:423 +#: ../../library/urllib.request.rst:419 msgid "" "Handle authentication with the remote host. *password_mgr*, if given, should " "be something that is compatible with :class:`HTTPPasswordMgr`; refer to " @@ -682,7 +682,7 @@ msgid "" "presented with a wrong Authentication scheme." msgstr "" -#: ../../library/urllib.request.rst:432 ../../library/urllib.request.rst:469 +#: ../../library/urllib.request.rst:428 ../../library/urllib.request.rst:465 msgid "" "Handle authentication with the proxy. *password_mgr*, if given, should be " "something that is compatible with :class:`HTTPPasswordMgr`; refer to " @@ -690,7 +690,7 @@ msgid "" "be supported." msgstr "" -#: ../../library/urllib.request.rst:440 +#: ../../library/urllib.request.rst:436 msgid "" "This is a mixin class that helps with HTTP authentication, both to the " "remote host and to a proxy. *password_mgr*, if given, should be something " @@ -698,11 +698,11 @@ msgid "" "`http-password-mgr` for information on the interface that must be supported." msgstr "" -#: ../../library/urllib.request.rst:446 +#: ../../library/urllib.request.rst:442 msgid "Added support for HTTP digest authentication algorithm ``SHA-256``." msgstr "" -#: ../../library/urllib.request.rst:452 +#: ../../library/urllib.request.rst:448 msgid "" "Handle authentication with the remote host. *password_mgr*, if given, should " "be something that is compatible with :class:`HTTPPasswordMgr`; refer to " @@ -715,108 +715,108 @@ msgid "" "Digest or Basic." msgstr "" -#: ../../library/urllib.request.rst:462 +#: ../../library/urllib.request.rst:458 msgid "Raise :exc:`ValueError` on unsupported Authentication Scheme." msgstr "針對不支援的驗證方案 (Authentication Scheme) 引發 :exc:`ValueError`。" -#: ../../library/urllib.request.rst:477 +#: ../../library/urllib.request.rst:473 msgid "A class to handle opening of HTTP URLs." msgstr "用於處理開啟 HTTP URL 的類別。" -#: ../../library/urllib.request.rst:482 +#: ../../library/urllib.request.rst:478 msgid "" "A class to handle opening of HTTPS URLs. *context* and *check_hostname* " "have the same meaning as in :class:`http.client.HTTPSConnection`." msgstr "" -#: ../../library/urllib.request.rst:485 +#: ../../library/urllib.request.rst:481 msgid "*context* and *check_hostname* were added." msgstr "新增 *context* 與 *check_hostname*。" -#: ../../library/urllib.request.rst:491 +#: ../../library/urllib.request.rst:487 msgid "Open local files." msgstr "" -#: ../../library/urllib.request.rst:495 +#: ../../library/urllib.request.rst:491 msgid "Open data URLs." msgstr "" -#: ../../library/urllib.request.rst:501 +#: ../../library/urllib.request.rst:497 msgid "Open FTP URLs." msgstr "打開 FTP URLs。" -#: ../../library/urllib.request.rst:506 +#: ../../library/urllib.request.rst:502 msgid "" "Open FTP URLs, keeping a cache of open FTP connections to minimize delays." msgstr "" -#: ../../library/urllib.request.rst:511 +#: ../../library/urllib.request.rst:507 msgid "A catch-all class to handle unknown URLs." msgstr "" -#: ../../library/urllib.request.rst:516 ../../library/urllib.request.rst:1238 +#: ../../library/urllib.request.rst:512 ../../library/urllib.request.rst:1234 msgid "Process HTTP error responses." msgstr "" -#: ../../library/urllib.request.rst:522 +#: ../../library/urllib.request.rst:518 msgid "Request Objects" msgstr "Request 物件" -#: ../../library/urllib.request.rst:524 +#: ../../library/urllib.request.rst:520 msgid "" "The following methods describe :class:`Request`'s public interface, and so " "all may be overridden in subclasses. It also defines several public " "attributes that can be used by clients to inspect the parsed request." msgstr "" -#: ../../library/urllib.request.rst:531 +#: ../../library/urllib.request.rst:527 msgid "The original URL passed to the constructor." msgstr "" -#: ../../library/urllib.request.rst:535 +#: ../../library/urllib.request.rst:531 msgid "" "Request.full_url is a property with setter, getter and a deleter. Getting :" "attr:`~Request.full_url` returns the original request URL with the fragment, " "if it was present." msgstr "" -#: ../../library/urllib.request.rst:541 +#: ../../library/urllib.request.rst:537 msgid "The URI scheme." msgstr "" -#: ../../library/urllib.request.rst:545 +#: ../../library/urllib.request.rst:541 msgid "" "The URI authority, typically a host, but may also contain a port separated " "by a colon." msgstr "" -#: ../../library/urllib.request.rst:550 +#: ../../library/urllib.request.rst:546 msgid "The original host for the request, without port." msgstr "" -#: ../../library/urllib.request.rst:554 +#: ../../library/urllib.request.rst:550 msgid "" "The URI path. If the :class:`Request` uses a proxy, then selector will be " "the full URL that is passed to the proxy." msgstr "" -#: ../../library/urllib.request.rst:559 +#: ../../library/urllib.request.rst:555 msgid "The entity body for the request, or ``None`` if not specified." msgstr "" -#: ../../library/urllib.request.rst:561 +#: ../../library/urllib.request.rst:557 msgid "" "Changing value of :attr:`Request.data` now deletes \"Content-Length\" header " "if it was previously set or calculated." msgstr "" -#: ../../library/urllib.request.rst:567 +#: ../../library/urllib.request.rst:563 msgid "" "boolean, indicates whether the request is unverifiable as defined by :rfc:" "`2965`." msgstr "" -#: ../../library/urllib.request.rst:572 +#: ../../library/urllib.request.rst:568 msgid "" "The HTTP request method to use. By default its value is :const:`None`, " "which means that :meth:`~Request.get_method` will do its normal computation " @@ -827,13 +827,13 @@ msgid "" "argument." msgstr "" -#: ../../library/urllib.request.rst:582 +#: ../../library/urllib.request.rst:578 msgid "" "A default value can now be set in subclasses; previously it could only be " "set via the constructor argument." msgstr "" -#: ../../library/urllib.request.rst:589 +#: ../../library/urllib.request.rst:585 msgid "" "Return a string indicating the HTTP request method. If :attr:`Request." "method` is not ``None``, return its value, otherwise return ``'GET'`` if :" @@ -841,11 +841,11 @@ msgid "" "meaningful for HTTP requests." msgstr "" -#: ../../library/urllib.request.rst:594 +#: ../../library/urllib.request.rst:590 msgid "get_method now looks at the value of :attr:`Request.method`." msgstr "" -#: ../../library/urllib.request.rst:600 +#: ../../library/urllib.request.rst:596 msgid "" "Add another header to the request. Headers are currently ignored by all " "handlers except HTTP handlers, where they are added to the list of headers " @@ -857,64 +857,64 @@ msgid "" "headers added using this method are also added to redirected requests." msgstr "" -#: ../../library/urllib.request.rst:612 +#: ../../library/urllib.request.rst:608 msgid "Add a header that will not be added to a redirected request." msgstr "" -#: ../../library/urllib.request.rst:617 +#: ../../library/urllib.request.rst:613 msgid "" "Return whether the instance has the named header (checks both regular and " "unredirected)." msgstr "" -#: ../../library/urllib.request.rst:623 +#: ../../library/urllib.request.rst:619 msgid "" "Remove named header from the request instance (both from regular and " "unredirected headers)." msgstr "" -#: ../../library/urllib.request.rst:631 +#: ../../library/urllib.request.rst:627 msgid "Return the URL given in the constructor." msgstr "" -#: ../../library/urllib.request.rst:635 +#: ../../library/urllib.request.rst:631 msgid "Returns :attr:`Request.full_url`" msgstr "回傳 :attr:`Request.full_url`" -#: ../../library/urllib.request.rst:640 +#: ../../library/urllib.request.rst:636 msgid "" "Prepare the request by connecting to a proxy server. The *host* and *type* " "will replace those of the instance, and the instance's selector will be the " "original URL given in the constructor." msgstr "" -#: ../../library/urllib.request.rst:647 +#: ../../library/urllib.request.rst:643 msgid "" "Return the value of the given header. If the header is not present, return " "the default value." msgstr "" -#: ../../library/urllib.request.rst:653 +#: ../../library/urllib.request.rst:649 msgid "" "Return a list of tuples (header_name, header_value) of the Request headers." msgstr "" -#: ../../library/urllib.request.rst:655 +#: ../../library/urllib.request.rst:651 msgid "" "The request methods add_data, has_data, get_data, get_type, get_host, " "get_selector, get_origin_req_host and is_unverifiable that were deprecated " "since 3.3 have been removed." msgstr "" -#: ../../library/urllib.request.rst:664 +#: ../../library/urllib.request.rst:660 msgid "OpenerDirector Objects" msgstr "OpenerDirector 物件" -#: ../../library/urllib.request.rst:666 +#: ../../library/urllib.request.rst:662 msgid ":class:`OpenerDirector` instances have the following methods:" msgstr ":class:`OpenerDirector` 物件有以下的方法:" -#: ../../library/urllib.request.rst:671 +#: ../../library/urllib.request.rst:667 msgid "" "*handler* should be an instance of :class:`BaseHandler`. The following " "methods are searched, and added to the possible chains (note that HTTP " @@ -925,53 +925,53 @@ msgid "" "`http_error_404` would handle HTTP 404 errors." msgstr "" -#: ../../library/urllib.request.rst:679 +#: ../../library/urllib.request.rst:675 msgid "" ":meth:`!_open` --- signal that the handler knows how to open " "*protocol* URLs." msgstr "" -#: ../../library/urllib.request.rst:682 +#: ../../library/urllib.request.rst:678 msgid "See |protocol_open|_ for more information." msgstr "更多資訊請見 |protocol_open|_。" -#: ../../library/urllib.request.rst:684 +#: ../../library/urllib.request.rst:680 msgid "" ":meth:`!http_error_\\` --- signal that the handler knows how to " "handle HTTP errors with HTTP error code *type*." msgstr "" -#: ../../library/urllib.request.rst:687 +#: ../../library/urllib.request.rst:683 msgid "See |http_error_nnn|_ for more information." msgstr "更多資訊請見 |http_error_nnn|_。" -#: ../../library/urllib.request.rst:689 +#: ../../library/urllib.request.rst:685 msgid "" ":meth:`!_error` --- signal that the handler knows how to handle " "errors from (non-\\ ``http``) *protocol*." msgstr "" -#: ../../library/urllib.request.rst:692 +#: ../../library/urllib.request.rst:688 msgid "" ":meth:`!_request` --- signal that the handler knows how to pre-" "process *protocol* requests." msgstr "" -#: ../../library/urllib.request.rst:695 +#: ../../library/urllib.request.rst:691 msgid "See |protocol_request|_ for more information." msgstr "更多資訊請見 |protocol_request|_。" -#: ../../library/urllib.request.rst:697 +#: ../../library/urllib.request.rst:693 msgid "" ":meth:`!_response` --- signal that the handler knows how to post-" "process *protocol* responses." msgstr "" -#: ../../library/urllib.request.rst:700 +#: ../../library/urllib.request.rst:696 msgid "See |protocol_response|_ for more information." msgstr "更多資訊請見 |protocol_response|_。" -#: ../../library/urllib.request.rst:709 +#: ../../library/urllib.request.rst:705 msgid "" "Open the given *url* (which can be a request object or a string), optionally " "passing the given *data*. Arguments, return values and exceptions raised are " @@ -983,7 +983,7 @@ msgid "" "HTTP, HTTPS and FTP connections." msgstr "" -#: ../../library/urllib.request.rst:721 +#: ../../library/urllib.request.rst:717 msgid "" "Handle an error of the given protocol. This will call the registered error " "handlers for the given protocol with the given arguments (which are protocol " @@ -992,28 +992,28 @@ msgid "" "http_error_\\` methods of the handler classes." msgstr "" -#: ../../library/urllib.request.rst:727 +#: ../../library/urllib.request.rst:723 msgid "" "Return values and exceptions raised are the same as those of :func:`urlopen`." msgstr "" -#: ../../library/urllib.request.rst:729 +#: ../../library/urllib.request.rst:725 msgid "OpenerDirector objects open URLs in three stages:" msgstr "" -#: ../../library/urllib.request.rst:731 +#: ../../library/urllib.request.rst:727 msgid "" "The order in which these methods are called within each stage is determined " "by sorting the handler instances." msgstr "" -#: ../../library/urllib.request.rst:734 +#: ../../library/urllib.request.rst:730 msgid "" "Every handler with a method named like :meth:`!_request` has that " "method called to pre-process the request." msgstr "" -#: ../../library/urllib.request.rst:737 +#: ../../library/urllib.request.rst:733 msgid "" "Handlers with a method named like :meth:`!_open` are called to " "handle the request. This stage ends when a handler either returns a non-\\ :" @@ -1021,7 +1021,7 @@ msgid "" "`~urllib.error.URLError`). Exceptions are allowed to propagate." msgstr "" -#: ../../library/urllib.request.rst:742 +#: ../../library/urllib.request.rst:738 msgid "" "In fact, the above algorithm is first tried for methods named :meth:" "`~BaseHandler.default_open`. If all such methods return :const:`None`, the " @@ -1030,64 +1030,64 @@ msgid "" "named :meth:`~BaseHandler.unknown_open`." msgstr "" -#: ../../library/urllib.request.rst:748 +#: ../../library/urllib.request.rst:744 msgid "" "Note that the implementation of these methods may involve calls of the " "parent :class:`OpenerDirector` instance's :meth:`~OpenerDirector.open` and :" "meth:`~OpenerDirector.error` methods." msgstr "" -#: ../../library/urllib.request.rst:752 +#: ../../library/urllib.request.rst:748 msgid "" "Every handler with a method named like :meth:`!_response` has that " "method called to post-process the response." msgstr "" -#: ../../library/urllib.request.rst:759 +#: ../../library/urllib.request.rst:755 msgid "BaseHandler Objects" msgstr "BaseHandler 物件" -#: ../../library/urllib.request.rst:761 +#: ../../library/urllib.request.rst:757 msgid "" ":class:`BaseHandler` objects provide a couple of methods that are directly " "useful, and others that are meant to be used by derived classes. These are " "intended for direct use:" msgstr "" -#: ../../library/urllib.request.rst:768 +#: ../../library/urllib.request.rst:764 msgid "Add a director as parent." msgstr "" -#: ../../library/urllib.request.rst:773 +#: ../../library/urllib.request.rst:769 msgid "Remove any parents." msgstr "" -#: ../../library/urllib.request.rst:775 +#: ../../library/urllib.request.rst:771 msgid "" "The following attribute and methods should only be used by classes derived " "from :class:`BaseHandler`." msgstr "" -#: ../../library/urllib.request.rst:780 +#: ../../library/urllib.request.rst:776 msgid "" "The convention has been adopted that subclasses defining :meth:`!" "_request` or :meth:`!_response` methods are named :class:" "`!\\*Processor`; all others are named :class:`!\\*Handler`." msgstr "" -#: ../../library/urllib.request.rst:787 +#: ../../library/urllib.request.rst:783 msgid "" "A valid :class:`OpenerDirector`, which can be used to open using a different " "protocol, or handle errors." msgstr "" -#: ../../library/urllib.request.rst:793 +#: ../../library/urllib.request.rst:789 msgid "" "This method is *not* defined in :class:`BaseHandler`, but subclasses should " "define it if they want to catch all URLs." msgstr "" -#: ../../library/urllib.request.rst:796 +#: ../../library/urllib.request.rst:792 msgid "" "This method, if implemented, will be called by the parent :class:" "`OpenerDirector`. It should return a file-like object as described in the " @@ -1097,38 +1097,38 @@ msgid "" "`MemoryError` should not be mapped to :exc:`~urllib.error.URLError`)." msgstr "" -#: ../../library/urllib.request.rst:803 +#: ../../library/urllib.request.rst:799 msgid "This method will be called before any protocol-specific open method." msgstr "" -#: ../../library/urllib.request.rst:810 +#: ../../library/urllib.request.rst:806 msgid "" "This method is *not* defined in :class:`BaseHandler`, but subclasses should " "define it if they want to handle URLs with the given protocol." msgstr "" -#: ../../library/urllib.request.rst:813 +#: ../../library/urllib.request.rst:809 msgid "" "This method, if defined, will be called by the parent :class:" "`OpenerDirector`. Return values should be the same as for :meth:" "`~BaseHandler.default_open`." msgstr "" -#: ../../library/urllib.request.rst:819 +#: ../../library/urllib.request.rst:815 msgid "" "This method is *not* defined in :class:`BaseHandler`, but subclasses should " "define it if they want to catch all URLs with no specific registered handler " "to open it." msgstr "" -#: ../../library/urllib.request.rst:823 +#: ../../library/urllib.request.rst:819 msgid "" "This method, if implemented, will be called by the :attr:`parent` :class:" "`OpenerDirector`. Return values should be the same as for :meth:" "`default_open`." msgstr "" -#: ../../library/urllib.request.rst:830 +#: ../../library/urllib.request.rst:826 msgid "" "This method is *not* defined in :class:`BaseHandler`, but subclasses should " "override it if they intend to provide a catch-all for otherwise unhandled " @@ -1137,74 +1137,74 @@ msgid "" "other circumstances." msgstr "" -#: ../../library/urllib.request.rst:835 +#: ../../library/urllib.request.rst:831 msgid "" ":class:`OpenerDirector` will call this method with five positional arguments:" msgstr ":class:`OpenerDirector` 會以五個位置引數呼叫此方法:" -#: ../../library/urllib.request.rst:837 +#: ../../library/urllib.request.rst:833 msgid "a :class:`Request` object," msgstr "一個 :class:`Request` 物件" -#: ../../library/urllib.request.rst:838 +#: ../../library/urllib.request.rst:834 msgid "a file-like object with the HTTP error body," msgstr "一個類檔案物件,包含 HTTP 錯誤主體," -#: ../../library/urllib.request.rst:839 +#: ../../library/urllib.request.rst:835 msgid "the three-digit code of the error, as a string," msgstr "HTTP 錯誤的三位數代號字串," -#: ../../library/urllib.request.rst:840 +#: ../../library/urllib.request.rst:836 msgid "the user-visible explanation of the code, as a string, and" msgstr "HTTP 錯誤代號的使用者可見解釋字串,以及" -#: ../../library/urllib.request.rst:841 +#: ../../library/urllib.request.rst:837 msgid "the headers of the error, as a mapping object." msgstr "HTTP 錯誤的標頭,為一個對映物件。" -#: ../../library/urllib.request.rst:843 +#: ../../library/urllib.request.rst:839 msgid "" "Return values and exceptions raised should be the same as those of :func:" "`urlopen`." msgstr "" -#: ../../library/urllib.request.rst:850 +#: ../../library/urllib.request.rst:846 msgid "" "*nnn* should be a three-digit HTTP error code. This method is also not " "defined in :class:`BaseHandler`, but will be called, if it exists, on an " "instance of a subclass, when an HTTP error with code *nnn* occurs." msgstr "" -#: ../../library/urllib.request.rst:854 +#: ../../library/urllib.request.rst:850 msgid "Subclasses should override this method to handle specific HTTP errors." msgstr "" -#: ../../library/urllib.request.rst:856 +#: ../../library/urllib.request.rst:852 msgid "" "Arguments, return values and exceptions raised should be the same as for :" "meth:`~BaseHandler.http_error_default`." msgstr "" -#: ../../library/urllib.request.rst:864 +#: ../../library/urllib.request.rst:860 msgid "" "This method is *not* defined in :class:`BaseHandler`, but subclasses should " "define it if they want to pre-process requests of the given protocol." msgstr "" -#: ../../library/urllib.request.rst:867 +#: ../../library/urllib.request.rst:863 msgid "" "This method, if defined, will be called by the parent :class:" "`OpenerDirector`. *req* will be a :class:`Request` object. The return value " "should be a :class:`Request` object." msgstr "" -#: ../../library/urllib.request.rst:876 +#: ../../library/urllib.request.rst:872 msgid "" "This method is *not* defined in :class:`BaseHandler`, but subclasses should " "define it if they want to post-process responses of the given protocol." msgstr "" -#: ../../library/urllib.request.rst:879 +#: ../../library/urllib.request.rst:875 msgid "" "This method, if defined, will be called by the parent :class:" "`OpenerDirector`. *req* will be a :class:`Request` object. *response* will " @@ -1213,25 +1213,25 @@ msgid "" "return value of :func:`urlopen`." msgstr "" -#: ../../library/urllib.request.rst:889 +#: ../../library/urllib.request.rst:885 msgid "HTTPRedirectHandler Objects" msgstr "HTTPRedirectHandler 物件" -#: ../../library/urllib.request.rst:893 +#: ../../library/urllib.request.rst:889 msgid "" "Some HTTP redirections require action from this module's client code. If " "this is the case, :exc:`~urllib.error.HTTPError` is raised. See :rfc:`2616` " "for details of the precise meanings of the various redirection codes." msgstr "" -#: ../../library/urllib.request.rst:897 +#: ../../library/urllib.request.rst:893 msgid "" "An :exc:`~urllib.error.HTTPError` exception raised as a security " "consideration if the HTTPRedirectHandler is presented with a redirected URL " "which is not an HTTP, HTTPS or FTP URL." msgstr "" -#: ../../library/urllib.request.rst:904 +#: ../../library/urllib.request.rst:900 msgid "" "Return a :class:`Request` or ``None`` in response to a redirect. This is " "called by the default implementations of the :meth:`!http_error_30\\*` " @@ -1242,7 +1242,7 @@ msgid "" "URL, or return ``None`` if you can't but another handler might." msgstr "" -#: ../../library/urllib.request.rst:914 +#: ../../library/urllib.request.rst:910 msgid "" "The default implementation of this method does not strictly follow :rfc:" "`2616`, which says that 301 and 302 responses to ``POST`` requests must not " @@ -1251,54 +1251,54 @@ msgid "" "POST to a ``GET``, and the default implementation reproduces this behavior." msgstr "" -#: ../../library/urllib.request.rst:923 +#: ../../library/urllib.request.rst:919 msgid "" "Redirect to the ``Location:`` or ``URI:`` URL. This method is called by the " "parent :class:`OpenerDirector` when getting an HTTP 'moved permanently' " "response." msgstr "" -#: ../../library/urllib.request.rst:929 +#: ../../library/urllib.request.rst:925 msgid "" "The same as :meth:`http_error_301`, but called for the 'found' response." msgstr "" -#: ../../library/urllib.request.rst:934 +#: ../../library/urllib.request.rst:930 msgid "" "The same as :meth:`http_error_301`, but called for the 'see other' response." msgstr "" -#: ../../library/urllib.request.rst:939 +#: ../../library/urllib.request.rst:935 msgid "" "The same as :meth:`http_error_301`, but called for the 'temporary redirect' " "response. It does not allow changing the request method from ``POST`` to " "``GET``." msgstr "" -#: ../../library/urllib.request.rst:946 +#: ../../library/urllib.request.rst:942 msgid "" "The same as :meth:`http_error_301`, but called for the 'permanent redirect' " "response. It does not allow changing the request method from ``POST`` to " "``GET``." msgstr "" -#: ../../library/urllib.request.rst:956 +#: ../../library/urllib.request.rst:952 msgid "HTTPCookieProcessor Objects" msgstr "HTTPCookieProcessor 物件" -#: ../../library/urllib.request.rst:958 +#: ../../library/urllib.request.rst:954 msgid ":class:`HTTPCookieProcessor` instances have one attribute:" msgstr ":class:`HTTPCookieProcessor` 實例有一個屬性:" -#: ../../library/urllib.request.rst:962 +#: ../../library/urllib.request.rst:958 msgid "The :class:`http.cookiejar.CookieJar` in which cookies are stored." msgstr "存放 cookies 的 :class:`http.cookiejar.CookieJar`。" -#: ../../library/urllib.request.rst:968 +#: ../../library/urllib.request.rst:964 msgid "ProxyHandler Objects" msgstr "ProxyHandler 物件" -#: ../../library/urllib.request.rst:974 +#: ../../library/urllib.request.rst:970 msgid "" "The :class:`ProxyHandler` will have a method :meth:`!_open` for " "every *protocol* which has a proxy in the *proxies* dictionary given in the " @@ -1307,17 +1307,17 @@ msgid "" "actually execute the protocol." msgstr "" -#: ../../library/urllib.request.rst:984 +#: ../../library/urllib.request.rst:980 msgid "HTTPPasswordMgr Objects" msgstr "HTTPPasswordMgr 物件" -#: ../../library/urllib.request.rst:986 +#: ../../library/urllib.request.rst:982 msgid "" "These methods are available on :class:`HTTPPasswordMgr` and :class:" "`HTTPPasswordMgrWithDefaultRealm` objects." msgstr "" -#: ../../library/urllib.request.rst:992 +#: ../../library/urllib.request.rst:988 msgid "" "*uri* can be either a single URI, or a sequence of URIs. *realm*, *user* and " "*passwd* must be strings. This causes ``(user, passwd)`` to be used as " @@ -1327,36 +1327,36 @@ msgid "" "scheme matches authentication URIs with any scheme." msgstr "" -#: ../../library/urllib.request.rst:999 +#: ../../library/urllib.request.rst:995 msgid "" "Authentication credentials for URIs with a scheme are now scoped by that " "scheme." msgstr "" -#: ../../library/urllib.request.rst:1006 +#: ../../library/urllib.request.rst:1002 msgid "" "Get user/password for given realm and URI, if any. This method will return " "``(None, None)`` if there is no matching user/password." msgstr "" -#: ../../library/urllib.request.rst:1009 +#: ../../library/urllib.request.rst:1005 msgid "" "For :class:`HTTPPasswordMgrWithDefaultRealm` objects, the realm ``None`` " "will be searched if the given *realm* has no matching user/password." msgstr "" -#: ../../library/urllib.request.rst:1016 +#: ../../library/urllib.request.rst:1012 msgid "HTTPPasswordMgrWithPriorAuth Objects" msgstr "HTTPPasswordMgrWithPriorAuth 物件" -#: ../../library/urllib.request.rst:1018 +#: ../../library/urllib.request.rst:1014 msgid "" "This password manager extends :class:`HTTPPasswordMgrWithDefaultRealm` to " "support tracking URIs for which authentication credentials should always be " "sent." msgstr "" -#: ../../library/urllib.request.rst:1025 +#: ../../library/urllib.request.rst:1021 msgid "" "*realm*, *uri*, *user*, *passwd* are as for :meth:`HTTPPasswordMgr." "add_password`. *is_authenticated* sets the initial value of the " @@ -1364,25 +1364,25 @@ msgid "" "*is_authenticated* is specified as ``True``, *realm* is ignored." msgstr "" -#: ../../library/urllib.request.rst:1033 +#: ../../library/urllib.request.rst:1029 msgid "Same as for :class:`HTTPPasswordMgrWithDefaultRealm` objects" msgstr "" -#: ../../library/urllib.request.rst:1039 +#: ../../library/urllib.request.rst:1035 msgid "" "Update the ``is_authenticated`` flag for the given *uri* or list of URIs." msgstr "" -#: ../../library/urllib.request.rst:1045 +#: ../../library/urllib.request.rst:1041 msgid "" "Returns the current state of the ``is_authenticated`` flag for the given URI." msgstr "" -#: ../../library/urllib.request.rst:1052 +#: ../../library/urllib.request.rst:1048 msgid "AbstractBasicAuthHandler Objects" msgstr "AbstractBasicAuthHandler 物件" -#: ../../library/urllib.request.rst:1057 +#: ../../library/urllib.request.rst:1053 msgid "" "Handle an authentication request by getting a user/password pair, and re-" "trying the request. *authreq* should be the name of the header where the " @@ -1391,14 +1391,14 @@ msgid "" "`Request` object, and *headers* should be the error headers." msgstr "" -#: ../../library/urllib.request.rst:1063 +#: ../../library/urllib.request.rst:1059 msgid "" "*headers* must be a mapping-like object with case-insensitive lookup that " "implements the ``get_all()`` method, such as :class:`email.message.Message` " "or :class:`wsgiref.headers.Headers`." msgstr "" -#: ../../library/urllib.request.rst:1067 +#: ../../library/urllib.request.rst:1063 msgid "" "*host* is either an authority (e.g. ``\"python.org\"``) or a URL containing " "an authority component (e.g. ``\"https://python.org/\"``). In either case, " @@ -1406,24 +1406,24 @@ msgid "" "and ``\"python.org:80\"`` are fine, ``\"joe:password@python.org\"`` is not)." msgstr "" -#: ../../library/urllib.request.rst:1076 +#: ../../library/urllib.request.rst:1072 msgid "HTTPBasicAuthHandler Objects" msgstr "HTTPBasicAuthHandler 物件" -#: ../../library/urllib.request.rst:1081 ../../library/urllib.request.rst:1092 -#: ../../library/urllib.request.rst:1120 ../../library/urllib.request.rst:1131 +#: ../../library/urllib.request.rst:1077 ../../library/urllib.request.rst:1088 +#: ../../library/urllib.request.rst:1116 ../../library/urllib.request.rst:1127 msgid "Retry the request with authentication information, if available." msgstr "" -#: ../../library/urllib.request.rst:1087 +#: ../../library/urllib.request.rst:1083 msgid "ProxyBasicAuthHandler Objects" msgstr "ProxyBasicAuthHandler 物件" -#: ../../library/urllib.request.rst:1098 +#: ../../library/urllib.request.rst:1094 msgid "AbstractDigestAuthHandler Objects" msgstr "AbstractDigestAuthHandler 物件" -#: ../../library/urllib.request.rst:1103 +#: ../../library/urllib.request.rst:1099 msgid "" "*authreq* should be the name of the header where the information about the " "realm is included in the request, *host* should be the host to authenticate " @@ -1431,61 +1431,61 @@ msgid "" "should be the error headers." msgstr "" -#: ../../library/urllib.request.rst:1108 +#: ../../library/urllib.request.rst:1104 msgid "" "*headers* must be a mapping-like object with case-insensitive lookup, such " "as :class:`email.message.Message` or :class:`wsgiref.headers.Headers`." msgstr "" -#: ../../library/urllib.request.rst:1115 +#: ../../library/urllib.request.rst:1111 msgid "HTTPDigestAuthHandler Objects" msgstr "HTTPDigestAuthHandler 物件" -#: ../../library/urllib.request.rst:1126 +#: ../../library/urllib.request.rst:1122 msgid "ProxyDigestAuthHandler Objects" msgstr "ProxyDigestAuthHandler 物件" -#: ../../library/urllib.request.rst:1137 +#: ../../library/urllib.request.rst:1133 msgid "HTTPHandler Objects" msgstr "HTTPHandler 物件" -#: ../../library/urllib.request.rst:1142 +#: ../../library/urllib.request.rst:1138 msgid "" "Send an HTTP request, which can be either GET or POST, depending on ``req." "data``." msgstr "" -#: ../../library/urllib.request.rst:1149 +#: ../../library/urllib.request.rst:1145 msgid "HTTPSHandler Objects" msgstr "HTTPSHandler 物件" -#: ../../library/urllib.request.rst:1154 +#: ../../library/urllib.request.rst:1150 msgid "" "Send an HTTPS request, which can be either GET or POST, depending on ``req." "data``." msgstr "" -#: ../../library/urllib.request.rst:1161 +#: ../../library/urllib.request.rst:1157 msgid "FileHandler Objects" msgstr "FileHandler 物件" -#: ../../library/urllib.request.rst:1166 +#: ../../library/urllib.request.rst:1162 msgid "" "Open the file locally, if there is no host name, or the host name is " "``'localhost'``." msgstr "" -#: ../../library/urllib.request.rst:1169 +#: ../../library/urllib.request.rst:1165 msgid "" "This method is applicable only for local hostnames. When a remote hostname " "is given, a :exc:`~urllib.error.URLError` is raised." msgstr "" -#: ../../library/urllib.request.rst:1177 +#: ../../library/urllib.request.rst:1173 msgid "DataHandler Objects" msgstr "DataHandler 物件" -#: ../../library/urllib.request.rst:1181 +#: ../../library/urllib.request.rst:1177 msgid "" "Read a data URL. This kind of URL contains the content encoded in the URL " "itself. The data URL syntax is specified in :rfc:`2397`. This implementation " @@ -1495,51 +1495,51 @@ msgid "" "implementation will raise a :exc:`ValueError` in that case." msgstr "" -#: ../../library/urllib.request.rst:1192 +#: ../../library/urllib.request.rst:1188 msgid "FTPHandler Objects" msgstr "FTPHandler 物件" -#: ../../library/urllib.request.rst:1197 +#: ../../library/urllib.request.rst:1193 msgid "" "Open the FTP file indicated by *req*. The login is always done with empty " "username and password." msgstr "" -#: ../../library/urllib.request.rst:1204 +#: ../../library/urllib.request.rst:1200 msgid "CacheFTPHandler Objects" msgstr "CacheFTPHandler 物件" -#: ../../library/urllib.request.rst:1206 +#: ../../library/urllib.request.rst:1202 msgid "" ":class:`CacheFTPHandler` objects are :class:`FTPHandler` objects with the " "following additional methods:" msgstr "" -#: ../../library/urllib.request.rst:1212 +#: ../../library/urllib.request.rst:1208 msgid "Set timeout of connections to *t* seconds." msgstr "" -#: ../../library/urllib.request.rst:1217 +#: ../../library/urllib.request.rst:1213 msgid "Set maximum number of cached connections to *m*." msgstr "" -#: ../../library/urllib.request.rst:1223 +#: ../../library/urllib.request.rst:1219 msgid "UnknownHandler Objects" msgstr "UnknownHandler 物件" -#: ../../library/urllib.request.rst:1228 +#: ../../library/urllib.request.rst:1224 msgid "Raise a :exc:`~urllib.error.URLError` exception." msgstr "" -#: ../../library/urllib.request.rst:1234 +#: ../../library/urllib.request.rst:1230 msgid "HTTPErrorProcessor Objects" msgstr "HTTPErrorProcessor 物件" -#: ../../library/urllib.request.rst:1240 +#: ../../library/urllib.request.rst:1236 msgid "For 200 error codes, the response object is returned immediately." msgstr "" -#: ../../library/urllib.request.rst:1242 +#: ../../library/urllib.request.rst:1238 msgid "" "For non-200 error codes, this simply passes the job on to the :meth:`!" "http_error_\\` handler methods, via :meth:`OpenerDirector.error`. " @@ -1547,31 +1547,31 @@ msgid "" "error.HTTPError` if no other handler handles the error." msgstr "" -#: ../../library/urllib.request.rst:1250 +#: ../../library/urllib.request.rst:1246 msgid "Process HTTPS error responses." msgstr "" -#: ../../library/urllib.request.rst:1252 +#: ../../library/urllib.request.rst:1248 msgid "The behavior is same as :meth:`http_response`." msgstr "" -#: ../../library/urllib.request.rst:1258 +#: ../../library/urllib.request.rst:1254 msgid "Examples" msgstr "範例" -#: ../../library/urllib.request.rst:1260 +#: ../../library/urllib.request.rst:1256 msgid "" "In addition to the examples below, more examples are given in :ref:`urllib-" "howto`." msgstr "" -#: ../../library/urllib.request.rst:1263 +#: ../../library/urllib.request.rst:1259 msgid "" "This example gets the python.org main page and displays the first 300 bytes " "of it::" msgstr "" -#: ../../library/urllib.request.rst:1266 +#: ../../library/urllib.request.rst:1262 msgid "" ">>> import urllib.request\n" ">>> with urllib.request.urlopen('https://www.python.org/') as f:\n" @@ -1584,7 +1584,7 @@ msgid "" "... print(data[:300].decode('utf-8', errors='replace'))" msgstr "" -#: ../../library/urllib.request.rst:1276 +#: ../../library/urllib.request.rst:1272 msgid "" "Note that urlopen returns a bytes object. This is because there is no way " "for urlopen to automatically determine the encoding of the byte stream it " @@ -1593,26 +1593,26 @@ msgid "" "appropriate encoding." msgstr "" -#: ../../library/urllib.request.rst:1282 +#: ../../library/urllib.request.rst:1278 msgid "" "The following HTML spec document, https://html.spec.whatwg.org/#charset, " "lists the various ways in which an HTML or an XML document could have " "specified its encoding information." msgstr "" -#: ../../library/urllib.request.rst:1286 +#: ../../library/urllib.request.rst:1282 msgid "" "For additional information, see the W3C document: https://www.w3.org/" "International/questions/qa-html-encoding-declarations." msgstr "" -#: ../../library/urllib.request.rst:1288 +#: ../../library/urllib.request.rst:1284 msgid "" "As the python.org website uses *utf-8* encoding as specified in its meta " "tag, we will use the same for decoding the bytes object::" msgstr "" -#: ../../library/urllib.request.rst:1291 +#: ../../library/urllib.request.rst:1287 msgid "" ">>> with urllib.request.urlopen('https://www.python.org/') as f:\n" "... # Check for compression and decode appropriately.\n" @@ -1625,13 +1625,13 @@ msgid "" "..." msgstr "" -#: ../../library/urllib.request.rst:1301 +#: ../../library/urllib.request.rst:1297 msgid "" "It is also possible to achieve the same result without using the :term:" "`context manager` approach::" msgstr "" -#: ../../library/urllib.request.rst:1304 +#: ../../library/urllib.request.rst:1300 msgid "" ">>> import urllib.request\n" ">>> f = urllib.request.urlopen('https://www.python.org/')\n" @@ -1646,14 +1646,14 @@ msgid "" "... f.close()" msgstr "" -#: ../../library/urllib.request.rst:1316 +#: ../../library/urllib.request.rst:1312 msgid "" "In the following example, we are sending a data-stream to the stdin of a CGI " "and reading the data it returns to us. Note that this example will only work " "when the Python installation supports SSL. ::" msgstr "" -#: ../../library/urllib.request.rst:1320 +#: ../../library/urllib.request.rst:1316 msgid "" ">>> import urllib.request\n" ">>> req = urllib.request.Request(url='https://localhost/cgi-bin/test.cgi',\n" @@ -1671,11 +1671,11 @@ msgstr "" "...\n" "Got Data: \"This data is passed to stdin of the CGI\"" -#: ../../library/urllib.request.rst:1328 +#: ../../library/urllib.request.rst:1324 msgid "The code for the sample CGI used in the above example is::" msgstr "" -#: ../../library/urllib.request.rst:1330 +#: ../../library/urllib.request.rst:1326 msgid "" "#!/usr/bin/env python\n" "import sys\n" @@ -1687,11 +1687,11 @@ msgstr "" "data = sys.stdin.read()\n" "print('Content-type: text/plain\\n\\nGot Data: \"%s\"' % data)" -#: ../../library/urllib.request.rst:1335 +#: ../../library/urllib.request.rst:1331 msgid "Here is an example of doing a ``PUT`` request using :class:`Request`::" msgstr "" -#: ../../library/urllib.request.rst:1337 +#: ../../library/urllib.request.rst:1333 msgid "" "import urllib.request\n" "DATA = b'some data'\n" @@ -1711,11 +1711,11 @@ msgstr "" "print(f.status)\n" "print(f.reason)" -#: ../../library/urllib.request.rst:1345 +#: ../../library/urllib.request.rst:1341 msgid "Use of Basic HTTP Authentication::" msgstr "使用基本 HTTP 認證: ::" -#: ../../library/urllib.request.rst:1347 +#: ../../library/urllib.request.rst:1343 msgid "" "import urllib.request\n" "# Create an OpenerDirector with support for Basic HTTP Authentication...\n" @@ -1731,7 +1731,7 @@ msgid "" " print(f.read().decode('utf-8'))" msgstr "" -#: ../../library/urllib.request.rst:1360 +#: ../../library/urllib.request.rst:1356 msgid "" ":func:`build_opener` provides many handlers by default, including a :class:" "`ProxyHandler`. By default, :class:`ProxyHandler` uses the environment " @@ -1740,14 +1740,14 @@ msgid "" "read to obtain the HTTP proxy's URL." msgstr "" -#: ../../library/urllib.request.rst:1366 +#: ../../library/urllib.request.rst:1362 msgid "" "This example replaces the default :class:`ProxyHandler` with one that uses " "programmatically supplied proxy URLs, and adds proxy authorization support " "with :class:`ProxyBasicAuthHandler`. ::" msgstr "" -#: ../../library/urllib.request.rst:1370 +#: ../../library/urllib.request.rst:1366 msgid "" "proxy_handler = urllib.request.ProxyHandler({'http': 'http://www.example." "com:3128/'})\n" @@ -1769,15 +1769,15 @@ msgstr "" "with opener.open('http://www.example.com/login.html') as f:\n" " print(f.read().decode('utf-8'))" -#: ../../library/urllib.request.rst:1379 +#: ../../library/urllib.request.rst:1375 msgid "Adding HTTP headers:" msgstr "添加 HTTP 標頭:" -#: ../../library/urllib.request.rst:1381 +#: ../../library/urllib.request.rst:1377 msgid "Use the *headers* argument to the :class:`Request` constructor, or::" msgstr "使用 :class:`Request` 建構函式的 *headers* 引數,或: ::" -#: ../../library/urllib.request.rst:1383 +#: ../../library/urllib.request.rst:1379 msgid "" "import urllib.request\n" "req = urllib.request.Request('http://www.example.com/')\n" @@ -1795,13 +1795,13 @@ msgstr "" "with urllib.request.urlopen(req) as f:\n" " print(f.read().decode('utf-8'))" -#: ../../library/urllib.request.rst:1392 +#: ../../library/urllib.request.rst:1388 msgid "" ":class:`OpenerDirector` automatically adds a :mailheader:`User-Agent` header " "to every :class:`Request`. To change this::" msgstr "" -#: ../../library/urllib.request.rst:1395 +#: ../../library/urllib.request.rst:1391 msgid "" "import urllib.request\n" "opener = urllib.request.build_opener()\n" @@ -1815,20 +1815,20 @@ msgstr "" "with opener.open('http://www.example.com/') as f:\n" " print(f.read().decode('utf-8'))" -#: ../../library/urllib.request.rst:1401 +#: ../../library/urllib.request.rst:1397 msgid "" "Also, remember that a few standard headers (:mailheader:`Content-Length`, :" "mailheader:`Content-Type` and :mailheader:`Host`) are added when the :class:" "`Request` is passed to :func:`urlopen` (or :meth:`OpenerDirector.open`)." msgstr "" -#: ../../library/urllib.request.rst:1408 +#: ../../library/urllib.request.rst:1404 msgid "" "Here is an example session that uses the ``GET`` method to retrieve a URL " "containing parameters::" msgstr "" -#: ../../library/urllib.request.rst:1411 +#: ../../library/urllib.request.rst:1407 msgid "" ">>> import urllib.request\n" ">>> import urllib.parse\n" @@ -1846,14 +1846,14 @@ msgstr "" "... print(f.read().decode('utf-8'))\n" "..." -#: ../../library/urllib.request.rst:1419 +#: ../../library/urllib.request.rst:1415 msgid "" "The following example uses the ``POST`` method instead. Note that params " "output from urlencode is encoded to bytes before it is sent to urlopen as " "data::" msgstr "" -#: ../../library/urllib.request.rst:1422 +#: ../../library/urllib.request.rst:1418 msgid "" ">>> import urllib.request\n" ">>> import urllib.parse\n" @@ -1871,13 +1871,13 @@ msgstr "" "... print(f.read().decode('utf-8'))\n" "..." -#: ../../library/urllib.request.rst:1430 +#: ../../library/urllib.request.rst:1426 msgid "" "The following example uses an explicitly specified HTTP proxy, overriding " "environment settings::" msgstr "" -#: ../../library/urllib.request.rst:1433 +#: ../../library/urllib.request.rst:1429 msgid "" ">>> import urllib.request\n" ">>> proxies = {'http': 'http://proxy.example.com:8080/'}\n" @@ -1895,13 +1895,13 @@ msgstr "" "... f.read().decode('utf-8')\n" "..." -#: ../../library/urllib.request.rst:1440 +#: ../../library/urllib.request.rst:1436 msgid "" "The following example uses no proxies at all, overriding environment " "settings::" msgstr "" -#: ../../library/urllib.request.rst:1442 +#: ../../library/urllib.request.rst:1438 msgid "" ">>> import urllib.request\n" ">>> opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))\n" @@ -1915,18 +1915,18 @@ msgstr "" "... f.read().decode('utf-8')\n" "..." -#: ../../library/urllib.request.rst:1450 +#: ../../library/urllib.request.rst:1446 msgid "Legacy interface" msgstr "遺留介面" -#: ../../library/urllib.request.rst:1452 +#: ../../library/urllib.request.rst:1448 msgid "" "The following functions and classes are ported from the Python 2 module " "``urllib`` (as opposed to ``urllib2``). They might become deprecated at " "some point in the future." msgstr "" -#: ../../library/urllib.request.rst:1458 +#: ../../library/urllib.request.rst:1454 msgid "" "Copy a network object denoted by a URL to a local file. If the URL points to " "a local file, the object will not be copied unless filename is supplied. " @@ -1936,7 +1936,7 @@ msgid "" "a remote object). Exceptions are the same as for :func:`urlopen`." msgstr "" -#: ../../library/urllib.request.rst:1465 +#: ../../library/urllib.request.rst:1461 msgid "" "The second argument, if present, specifies the file location to copy to (if " "absent, the location will be a tempfile with a generated name). The third " @@ -1948,11 +1948,11 @@ msgid "" "file size in response to a retrieval request." msgstr "" -#: ../../library/urllib.request.rst:1474 +#: ../../library/urllib.request.rst:1470 msgid "The following example illustrates the most common usage scenario::" msgstr "" -#: ../../library/urllib.request.rst:1476 +#: ../../library/urllib.request.rst:1472 msgid "" ">>> import urllib.request\n" ">>> local_filename, headers = urllib.request.urlretrieve('https://python." @@ -1966,7 +1966,7 @@ msgstr "" ">>> html = open(local_filename)\n" ">>> html.close()" -#: ../../library/urllib.request.rst:1481 +#: ../../library/urllib.request.rst:1477 msgid "" "If the *url* uses the :file:`http:` scheme identifier, the optional *data* " "argument may be given to specify a ``POST`` request (normally the request " @@ -1975,7 +1975,7 @@ msgid "" "parse.urlencode` function." msgstr "" -#: ../../library/urllib.request.rst:1487 +#: ../../library/urllib.request.rst:1483 msgid "" ":func:`urlretrieve` will raise :exc:`~urllib.error.ContentTooShortError` " "when it detects that the amount of data available was less than the " @@ -1983,66 +1983,66 @@ msgid "" "This can occur, for example, when the download is interrupted." msgstr "" -#: ../../library/urllib.request.rst:1492 +#: ../../library/urllib.request.rst:1488 msgid "" "The *Content-Length* is treated as a lower bound: if there's more data to " "read, urlretrieve reads more data, but if less data is available, it raises " "the exception." msgstr "" -#: ../../library/urllib.request.rst:1496 +#: ../../library/urllib.request.rst:1492 msgid "" "You can still retrieve the downloaded data in this case, it is stored in " "the :attr:`!content` attribute of the exception instance." msgstr "" -#: ../../library/urllib.request.rst:1499 +#: ../../library/urllib.request.rst:1495 msgid "" "If no *Content-Length* header was supplied, urlretrieve can not check the " "size of the data it has downloaded, and just returns it. In this case you " "just have to assume that the download was successful." msgstr "" -#: ../../library/urllib.request.rst:1505 +#: ../../library/urllib.request.rst:1501 msgid "" "Cleans up temporary files that may have been left behind by previous calls " "to :func:`urlretrieve`. It also resets the default global opener installed " "by :func:`install_opener`." msgstr "" -#: ../../library/urllib.request.rst:1511 +#: ../../library/urllib.request.rst:1507 msgid ":mod:`!urllib.request` Restrictions" msgstr ":mod:`!urllib.request` 限制" -#: ../../library/urllib.request.rst:1517 +#: ../../library/urllib.request.rst:1513 msgid "" "Currently, only the following protocols are supported: HTTP (versions 0.9 " "and 1.0), FTP, local files, and data URLs." msgstr "" -#: ../../library/urllib.request.rst:1520 +#: ../../library/urllib.request.rst:1516 msgid "Added support for data URLs." msgstr "" -#: ../../library/urllib.request.rst:1522 +#: ../../library/urllib.request.rst:1518 msgid "" "The caching feature of :func:`urlretrieve` has been disabled until someone " "finds the time to hack proper processing of Expiration time headers." msgstr "" -#: ../../library/urllib.request.rst:1525 +#: ../../library/urllib.request.rst:1521 msgid "" "There should be a function to query whether a particular URL is in the cache." msgstr "" -#: ../../library/urllib.request.rst:1527 +#: ../../library/urllib.request.rst:1523 msgid "" "For backward compatibility, if a URL appears to point to a local file but " "the file can't be opened, the URL is re-interpreted using the FTP protocol. " "This can sometimes cause confusing error messages." msgstr "" -#: ../../library/urllib.request.rst:1531 +#: ../../library/urllib.request.rst:1527 msgid "" "The :func:`urlopen` and :func:`urlretrieve` functions can cause arbitrarily " "long delays while waiting for a network connection to be set up. This means " @@ -2050,7 +2050,7 @@ msgid "" "functions without using threads." msgstr "" -#: ../../library/urllib.request.rst:1540 +#: ../../library/urllib.request.rst:1536 msgid "" "The data returned by :func:`urlopen` or :func:`urlretrieve` is the raw data " "returned by the server. This may be binary data (such as an image), plain " @@ -2060,7 +2060,7 @@ msgid "" "module :mod:`html.parser` to parse it." msgstr "" -#: ../../library/urllib.request.rst:1549 +#: ../../library/urllib.request.rst:1545 msgid "" "The code handling the FTP protocol cannot differentiate between a file and a " "directory. This can lead to unexpected behavior when attempting to read a " @@ -2077,11 +2077,11 @@ msgid "" "module." msgstr "" -#: ../../library/urllib.request.rst:1565 +#: ../../library/urllib.request.rst:1561 msgid ":mod:`!urllib.response` --- Response classes used by urllib" msgstr "" -#: ../../library/urllib.request.rst:1570 +#: ../../library/urllib.request.rst:1566 msgid "" "The :mod:`!urllib.response` module defines functions and classes which " "define a minimal file-like interface, including ``read()`` and " @@ -2090,47 +2090,47 @@ msgid "" "`urllib.response.addinfourl` instance:" msgstr "" -#: ../../library/urllib.request.rst:1579 +#: ../../library/urllib.request.rst:1575 msgid "" "URL of the resource retrieved, commonly used to determine if a redirect was " "followed." msgstr "" -#: ../../library/urllib.request.rst:1583 +#: ../../library/urllib.request.rst:1579 msgid "" "Returns the headers of the response in the form of an :class:`~email.message." "EmailMessage` instance." msgstr "" -#: ../../library/urllib.request.rst:1589 +#: ../../library/urllib.request.rst:1585 msgid "Status code returned by server." msgstr "伺服器回傳的狀態碼。" -#: ../../library/urllib.request.rst:1593 +#: ../../library/urllib.request.rst:1589 msgid "Deprecated in favor of :attr:`~addinfourl.url`." msgstr "已被 :attr:`~addinfourl.url` 取代而棄用。" -#: ../../library/urllib.request.rst:1598 +#: ../../library/urllib.request.rst:1594 msgid "Deprecated in favor of :attr:`~addinfourl.headers`." msgstr "已被 :attr:`~addinfourl.headers` 取代而棄用。" -#: ../../library/urllib.request.rst:1603 ../../library/urllib.request.rst:1608 +#: ../../library/urllib.request.rst:1599 ../../library/urllib.request.rst:1604 msgid "Deprecated in favor of :attr:`~addinfourl.status`." msgstr "已被 :attr:`~addinfourl.status` 取代而棄用。" -#: ../../library/urllib.request.rst:1513 ../../library/urllib.request.rst:1536 +#: ../../library/urllib.request.rst:1509 ../../library/urllib.request.rst:1532 msgid "HTTP" msgstr "HTTP" -#: ../../library/urllib.request.rst:1513 ../../library/urllib.request.rst:1536 +#: ../../library/urllib.request.rst:1509 ../../library/urllib.request.rst:1532 msgid "protocol" msgstr "protocol(協定)" -#: ../../library/urllib.request.rst:1513 ../../library/urllib.request.rst:1547 +#: ../../library/urllib.request.rst:1509 ../../library/urllib.request.rst:1543 msgid "FTP" msgstr "FTP" -#: ../../library/urllib.request.rst:1536 +#: ../../library/urllib.request.rst:1532 msgid "HTML" msgstr "HTML" diff --git a/library/urllib.robotparser.po b/library/urllib.robotparser.po index e8f9b408138..9cdd730fbc7 100644 --- a/library/urllib.robotparser.po +++ b/library/urllib.robotparser.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-05 00:32+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-01-27 13:40+0800\n" "Last-Translator: Phil Lin \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!urllib.robotparser` --- Parser for robots.txt" msgstr ":mod:`!urllib.robotparser` --- robots.txt 的剖析器" -#: ../../library/urllib.robotparser.rst:10 +#: ../../library/urllib.robotparser.rst:8 msgid "**Source code:** :source:`Lib/urllib/robotparser.py`" msgstr "**原始碼:**\\ :source:`Lib/urllib/robotparser.py`" -#: ../../library/urllib.robotparser.rst:20 +#: ../../library/urllib.robotparser.rst:18 msgid "" "This module provides a single class, :class:`RobotFileParser`, which answers " "questions about whether or not a particular user agent can fetch a URL on " @@ -39,7 +39,7 @@ msgstr "" "user agent(使用者代理)是否能在有發布 :file:`robots.txt` 文件的網站擷取特定 " "URL。有關 :file:`robots.txt` 文件結構的更多細節,請參閱 :rfc:`9309`。" -#: ../../library/urllib.robotparser.rst:28 +#: ../../library/urllib.robotparser.rst:26 msgid "" "This class provides methods to read, parse and answer questions about the :" "file:`robots.txt` file at *url*." @@ -47,19 +47,19 @@ msgstr "" "此類別提供了一些方法可以讀取、剖析和回答關於 *url* 上的 :file:`robots.txt` 文" "件的問題。" -#: ../../library/urllib.robotparser.rst:33 +#: ../../library/urllib.robotparser.rst:31 msgid "Sets the URL referring to a :file:`robots.txt` file." msgstr "設置指向 :file:`robots.txt` 文件的 URL。" -#: ../../library/urllib.robotparser.rst:37 +#: ../../library/urllib.robotparser.rst:35 msgid "Reads the :file:`robots.txt` URL and feeds it to the parser." msgstr "讀取 :file:`robots.txt` URL 並將其輸入到剖析器。" -#: ../../library/urllib.robotparser.rst:41 +#: ../../library/urllib.robotparser.rst:39 msgid "Parses the lines argument." msgstr "剖析 lines 引數。" -#: ../../library/urllib.robotparser.rst:45 +#: ../../library/urllib.robotparser.rst:43 msgid "" "Returns ``True`` if the *useragent* is allowed to fetch the *url* according " "to the rules contained in the parsed :file:`robots.txt` file." @@ -67,7 +67,7 @@ msgstr "" "根據從 :file:`robots.txt` 文件中剖析出的規則,如果 *useragent* 被允許 fetch " "*url* 的話,則回傳 ``True``。" -#: ../../library/urllib.robotparser.rst:51 +#: ../../library/urllib.robotparser.rst:49 msgid "" "Returns the time the ``robots.txt`` file was last fetched. This is useful " "for long-running web spiders that need to check for new ``robots.txt`` files " @@ -76,12 +76,12 @@ msgstr "" "回傳最近一次 fetch ``robots.txt`` 文件的時間。這適用於需要定期檢查 ``robots." "txt`` 文件更新情況的長時間運行網頁爬蟲。" -#: ../../library/urllib.robotparser.rst:57 +#: ../../library/urllib.robotparser.rst:55 msgid "" "Sets the time the ``robots.txt`` file was last fetched to the current time." msgstr "將最近一次 fetch ``robots.txt`` 文件的時間設置為目前時間。" -#: ../../library/urllib.robotparser.rst:62 +#: ../../library/urllib.robotparser.rst:60 msgid "" "Returns the value of the ``Crawl-delay`` parameter from ``robots.txt`` for " "the *useragent* in question. If there is no such parameter or it doesn't " @@ -92,7 +92,7 @@ msgstr "" "此參數不存在、不適用於指定的 *useragent* ,或是此參數在 ``robots.txt`` 中所指" "的條目含有無效語法,則回傳 ``None``。" -#: ../../library/urllib.robotparser.rst:71 +#: ../../library/urllib.robotparser.rst:69 msgid "" "Returns the contents of the ``Request-rate`` parameter from ``robots.txt`` " "as a :term:`named tuple` ``RequestRate(requests, seconds)``. If there is no " @@ -104,7 +104,7 @@ msgstr "" "*useragent* ,或是此參數在 ``robots.txt`` 中所指的條目含有無效語法,則回傳 " "``None``。" -#: ../../library/urllib.robotparser.rst:81 +#: ../../library/urllib.robotparser.rst:79 msgid "" "Returns the contents of the ``Sitemap`` parameter from ``robots.txt`` in the " "form of a :func:`list`. If there is no such parameter or the ``robots.txt`` " @@ -113,13 +113,13 @@ msgstr "" "以 :func:`list` 的形式從 ``robots.txt`` 回傳 ``Sitemap`` 參數的內容。如果此參" "數不存在或此參數在 ``robots.txt`` 中所指的條目含有無效語法,則回傳 ``None``。" -#: ../../library/urllib.robotparser.rst:89 +#: ../../library/urllib.robotparser.rst:87 msgid "" "The following example demonstrates basic use of the :class:`RobotFileParser` " "class::" msgstr "下面的範例展示了 :class:`RobotFileParser` 類別的基本用法: ::" -#: ../../library/urllib.robotparser.rst:92 +#: ../../library/urllib.robotparser.rst:90 msgid "" ">>> import urllib.robotparser\n" ">>> rp = urllib.robotparser.RobotFileParser()\n" @@ -153,18 +153,18 @@ msgstr "" ">>> rp.can_fetch(\"*\", \"http://www.pythontest.net/no-robots-here/\")\n" "False" -#: ../../library/urllib.robotparser.rst:12 +#: ../../library/urllib.robotparser.rst:10 msgid "WWW" msgstr "WWW" -#: ../../library/urllib.robotparser.rst:12 +#: ../../library/urllib.robotparser.rst:10 msgid "World Wide Web" msgstr "World Wide Web (全球資訊網)" -#: ../../library/urllib.robotparser.rst:12 +#: ../../library/urllib.robotparser.rst:10 msgid "URL" msgstr "URL(統一資源定位器)" -#: ../../library/urllib.robotparser.rst:12 +#: ../../library/urllib.robotparser.rst:10 msgid "robots.txt" msgstr "robots.txt" diff --git a/library/uuid.po b/library/uuid.po index 019a9acb8de..09a25c7527f 100644 --- a/library/uuid.po +++ b/library/uuid.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-27 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:15+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!uuid` --- UUID objects according to :rfc:`9562`" msgstr ":mod:`!uuid` --- :rfc:`9562` 定義的 UUID 物件" -#: ../../library/uuid.rst:9 +#: ../../library/uuid.rst:7 msgid "**Source code:** :source:`Lib/uuid.py`" msgstr "**原始碼:**\\ :source:`Lib/uuid.py`" -#: ../../library/uuid.rst:13 +#: ../../library/uuid.rst:11 msgid "" "This module provides immutable :class:`UUID` objects (the :class:`UUID` " "class) and :ref:`functions ` for generating UUIDs " @@ -40,7 +40,7 @@ msgstr "" "的 :func:`uuid3` 等等。需要注意的是,UUID 版本 2 被故意省略,因為它不在 RFC " "的範圍內。" -#: ../../library/uuid.rst:19 +#: ../../library/uuid.rst:17 msgid "" "If all you want is a unique ID, you should probably call :func:`uuid1` or :" "func:`uuid4`. Note that :func:`uuid1` may compromise privacy since it " @@ -51,7 +51,7 @@ msgstr "" "意的是,:func:`uuid1` 可能會危害隱私,因為它會建立一個包含了電腦網路位址的 " "UUID。而 :func:`uuid4` 則會建立一個隨機的 UUID。" -#: ../../library/uuid.rst:24 +#: ../../library/uuid.rst:22 msgid "" "Depending on support from the underlying platform, :func:`uuid1` may or may " "not return a \"safe\" UUID. A safe UUID is one which is generated using " @@ -65,21 +65,21 @@ msgstr "" "UUID。所有 :class:`UUID` 的實例都有一個 :attr:`~UUID.is_safe` 屬性,該屬性使" "用下面這個列舉來傳遞有關 UUID 安全性的任何資訊:" -#: ../../library/uuid.rst:36 +#: ../../library/uuid.rst:34 msgid "The UUID was generated by the platform in a multiprocessing-safe way." msgstr "該 UUID 是由平台以多行程安全的 (multiprocessing-safe) 方式生成的。" -#: ../../library/uuid.rst:40 +#: ../../library/uuid.rst:38 msgid "The UUID was not generated in a multiprocessing-safe way." msgstr "該 UUID 不是以多行程安全的方式生成的。" -#: ../../library/uuid.rst:44 +#: ../../library/uuid.rst:42 msgid "" "The platform does not provide information on whether the UUID was generated " "safely or not." msgstr "該平台不提供 UUID 是否為安全生成的資訊。" -#: ../../library/uuid.rst:49 +#: ../../library/uuid.rst:47 msgid "" "Create a UUID from either a string of 32 hexadecimal digits, a 16-byte :" "class:`bytes` object in big-endian order as the *bytes* argument, a 16-byte :" @@ -101,7 +101,7 @@ msgstr "" "大括號、連字符號和 URN 前綴都是可以選用的。例如,以下這些運算式都會產生相同" "的 UUID: ::" -#: ../../library/uuid.rst:60 +#: ../../library/uuid.rst:58 msgid "" "UUID('{12345678-1234-5678-1234-567812345678}')\n" "UUID('12345678123456781234567812345678')\n" @@ -121,7 +121,7 @@ msgstr "" "UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))\n" "UUID(int=0x12345678123456781234567812345678)" -#: ../../library/uuid.rst:69 +#: ../../library/uuid.rst:67 msgid "" "Exactly one of *hex*, *bytes*, *bytes_le*, *fields*, or *int* must be given. " "The *version* argument is optional; if given, the resulting UUID will have " @@ -133,7 +133,7 @@ msgstr "" "其變體 (variant) 和版本號,覆蓋掉給定的 *hex*、*bytes*、*bytes_le*、*fields* " "或 *int* 中的位元。" -#: ../../library/uuid.rst:74 +#: ../../library/uuid.rst:72 msgid "" "Comparison of UUID objects are made by way of comparing their :attr:`UUID." "int` attributes. Comparison with a non-UUID object raises a :exc:" @@ -142,7 +142,7 @@ msgstr "" "UUID 物件之間的比較是透過比較它們的 :attr:`UUID.int` 屬性。與非 UUID 的物件進" "行比較會引發 :exc:`TypeError`。" -#: ../../library/uuid.rst:78 +#: ../../library/uuid.rst:76 msgid "" "``str(uuid)`` returns a string in the form " "``12345678-1234-5678-1234-567812345678`` where the 32 hexadecimal digits " @@ -151,11 +151,11 @@ msgstr "" "``str(uuid)`` 會回傳一個像是 ``12345678-1234-5678-1234-567812345678`` 形式的" "字串,其中 32 個十六進位的數字代表 UUID。" -#: ../../library/uuid.rst:82 +#: ../../library/uuid.rst:80 msgid ":class:`UUID` instances have these read-only attributes:" msgstr ":class:`UUID` 實例有以下唯讀的屬性:" -#: ../../library/uuid.rst:86 +#: ../../library/uuid.rst:84 msgid "" "The UUID as a 16-byte :class:`bytes` object (containing the six integer " "fields in big-endian byte order)." @@ -163,7 +163,7 @@ msgstr "" "UUID 以 16 位元組的 :class:`bytes` 物件表示(包含 6 個整數欄位,按照大端位元" "組順序排列)。" -#: ../../library/uuid.rst:92 +#: ../../library/uuid.rst:90 msgid "" "The UUID as a 16-byte :class:`bytes` object (with *time_low*, *time_mid*, " "and *time_hi_version* in little-endian byte order)." @@ -171,7 +171,7 @@ msgstr "" "UUID 以 16 位元組的 :class:`bytes` 物件表示(其中 *time_low*、*time_mid* 和 " "*time_hi_version* 按照小端位元組順序排列)。" -#: ../../library/uuid.rst:98 +#: ../../library/uuid.rst:96 msgid "" "A tuple of the six integer fields of the UUID, which are also available as " "six individual attributes and two derived attributes:" @@ -179,31 +179,31 @@ msgstr "" "UUID 以 6 個整數欄位所組成的元組表示,也可以看作有 6 個個別屬性和 2 個衍生屬" "性:" -#: ../../library/uuid.rst:103 +#: ../../library/uuid.rst:101 msgid "Field" msgstr "欄位" -#: ../../library/uuid.rst:104 +#: ../../library/uuid.rst:102 msgid "Meaning" msgstr "意義" -#: ../../library/uuid.rst:107 +#: ../../library/uuid.rst:105 msgid "The first 32 bits of the UUID. Only relevant to version 1." msgstr "UUID 的前 32 位元。只與版本 1 有關。" -#: ../../library/uuid.rst:110 ../../library/uuid.rst:113 +#: ../../library/uuid.rst:108 ../../library/uuid.rst:111 msgid "The next 16 bits of the UUID. Only relevant to version 1." msgstr "UUID 接下來的 16 位元。只與版本 1 有關。" -#: ../../library/uuid.rst:116 ../../library/uuid.rst:119 +#: ../../library/uuid.rst:114 ../../library/uuid.rst:117 msgid "The next 8 bits of the UUID. Only relevant to versions 1 and 6." msgstr "UUID 接下來的 8 位元。只與版本 1 和 6 有關。" -#: ../../library/uuid.rst:122 +#: ../../library/uuid.rst:120 msgid "The last 48 bits of the UUID. Only relevant to version 1." msgstr "UUID 最後的 48 位元。只與版本 1 有關。" -#: ../../library/uuid.rst:125 +#: ../../library/uuid.rst:123 msgid "" "The 60-bit timestamp as a count of 100-nanosecond intervals since Gregorian " "epoch (1582-10-15 00:00:00) for versions 1 and 6, or the 48-bit timestamp in " @@ -213,23 +213,23 @@ msgstr "" "1582-10-15 00:00:00) 起以 100 奈秒為單位的計數,對於版本 7 是自 Unix 紀元 " "(1970-01-01 00:00:00) 起以毫秒為單位的計數。" -#: ../../library/uuid.rst:131 +#: ../../library/uuid.rst:129 msgid "The 14-bit sequence number. Only relevant to versions 1 and 6." msgstr "14 位元的序列號。只與版本 1 和 6 有關。" -#: ../../library/uuid.rst:136 +#: ../../library/uuid.rst:134 msgid "The UUID as a 32-character lowercase hexadecimal string." msgstr "UUID 以 32 個小寫十六進位字元組成的字串表示。" -#: ../../library/uuid.rst:141 +#: ../../library/uuid.rst:139 msgid "The UUID as a 128-bit integer." msgstr "UUID 以 128 位元的整數表示。" -#: ../../library/uuid.rst:146 +#: ../../library/uuid.rst:144 msgid "The UUID as a URN as specified in :rfc:`9562`." msgstr "UUID 以 :rfc:`9562` 中指定的 URN 形式表示。" -#: ../../library/uuid.rst:151 +#: ../../library/uuid.rst:149 msgid "" "The UUID variant, which determines the internal layout of the UUID. This " "will be one of the constants :const:`RESERVED_NCS`, :const:`RFC_4122`, :" @@ -239,27 +239,27 @@ msgstr "" "`RFC_4122`、:const:`RESERVED_MICROSOFT` 或 :const:`RESERVED_FUTURE` 其中一個" "常數。" -#: ../../library/uuid.rst:158 +#: ../../library/uuid.rst:156 msgid "" "The UUID version number (1 through 8, meaningful only when the variant is :" "const:`RFC_4122`)." msgstr "UUID 的版本號(1 到 8,只有當變體是 :const:`RFC_4122` 時才有意義)。" -#: ../../library/uuid.rst:161 +#: ../../library/uuid.rst:159 msgid "Added UUID versions 6, 7 and 8." msgstr "新增了 UUID 版本 6、7 和 8。" -#: ../../library/uuid.rst:167 +#: ../../library/uuid.rst:165 msgid "" "An enumeration of :class:`SafeUUID` which indicates whether the platform " "generated the UUID in a multiprocessing-safe way." msgstr ":class:`SafeUUID` 的列舉,表示平台是否以多行程安全的方式生成 UUID。" -#: ../../library/uuid.rst:172 +#: ../../library/uuid.rst:170 msgid "The :mod:`!uuid` module defines the following functions:" msgstr ":mod:`!uuid` 模組定義了以下函式:" -#: ../../library/uuid.rst:177 +#: ../../library/uuid.rst:175 msgid "" "Get the hardware address as a 48-bit positive integer. The first time this " "runs, it may launch a separate program, which could be quite slow. If all " @@ -280,7 +280,7 @@ msgstr "" "*),而不是本地管理 (locally administered) 的 MAC 位址,除此之外不保證任何選" "擇的順序。" -#: ../../library/uuid.rst:187 +#: ../../library/uuid.rst:185 msgid "" "Universally administered MAC addresses are preferred over locally " "administered MAC addresses, since the former are guaranteed to be globally " @@ -289,7 +289,7 @@ msgstr "" "通用管理的 MAC 位址優於本地管理的 MAC 位址,因為前者保證是全球唯一的,而後者" "不是。" -#: ../../library/uuid.rst:197 +#: ../../library/uuid.rst:195 msgid "" "Generate a UUID from a host ID, sequence number, and the current time " "according to :rfc:`RFC 9562, §5.1 <9562#section-5.1>`." @@ -297,7 +297,7 @@ msgstr "" "根據 :rfc:`RFC 9562, §5.1 <9562#section-5.1>`,從主機 ID、序列號碼和當前時間" "生成 UUID。" -#: ../../library/uuid.rst:200 ../../library/uuid.rst:237 +#: ../../library/uuid.rst:198 ../../library/uuid.rst:235 msgid "" "When *node* is not specified, :func:`getnode` is used to obtain the hardware " "address as a 48-bit positive integer. When a sequence number *clock_seq* is " @@ -306,14 +306,14 @@ msgstr "" "如果未指定 *node*,則使用 :func:`getnode` 取得硬體位址,作為 48 位元的正整" "數。如果未指定序列號碼 *clock_seq*,則生成一個偽隨機的 14 位元正整數。" -#: ../../library/uuid.rst:204 ../../library/uuid.rst:241 +#: ../../library/uuid.rst:202 ../../library/uuid.rst:239 msgid "" "If *node* or *clock_seq* exceed their expected bit count, only their least " "significant bits are kept." msgstr "" "如果 *node* 或 *clock_seq* 超過了預期的位元數,則只保留它們的最低有效位元。" -#: ../../library/uuid.rst:210 +#: ../../library/uuid.rst:208 msgid "" "Generate a UUID based on the MD5 hash of a namespace identifier (which is a " "UUID) and a name (which is a :class:`bytes` object or a string that will be " @@ -323,7 +323,7 @@ msgstr "" "identifier)(一個 UUID)和名稱(一個 :class:`bytes` 物件或使用 UTF-8 編碼的字" "串)的 MD5 hash 來生成 UUID。" -#: ../../library/uuid.rst:218 +#: ../../library/uuid.rst:216 msgid "" "Generate a random UUID in a cryptographically-secure method according to :" "rfc:`RFC 9562, §5.4 <9562#section-5.4>`." @@ -331,7 +331,7 @@ msgstr "" "根據 :rfc:`RFC 9562, §5.4 <9562#section-5.4>`,以加密安全的方式生成一個隨機 " "UUID。" -#: ../../library/uuid.rst:224 +#: ../../library/uuid.rst:222 msgid "" "Generate a UUID based on the SHA-1 hash of a namespace identifier (which is " "a UUID) and a name (which is a :class:`bytes` object or a string that will " @@ -342,24 +342,24 @@ msgstr "" "UUID)和名稱(一個 :class:`bytes` 物件或使用 UTF-8 編碼的字串)的 SHA-1 hash " "來生成 UUID。" -#: ../../library/uuid.rst:232 +#: ../../library/uuid.rst:230 msgid "" "Generate a UUID from a sequence number and the current time according to :" "rfc:`RFC 9562, §5.6 <9562#section-5.6>`." msgstr "" "根據 :rfc:`RFC 9562, §5.6 <9562#section-5.6>`,從序列號和當前時間生成 UUID。" -#: ../../library/uuid.rst:235 +#: ../../library/uuid.rst:233 msgid "This is an alternative to :func:`uuid1` to improve database locality." msgstr "這是 :func:`uuid1` 的替代方案,以改善資料庫的局部性 (locality)。" -#: ../../library/uuid.rst:249 +#: ../../library/uuid.rst:247 msgid "" "Generate a time-based UUID according to :rfc:`RFC 9562, §5.7 " "<9562#section-5.7>`." msgstr "根據 :rfc:`RFC 9562, §5.7 <9562#section-5.7>`,生成基於時間的 UUID。" -#: ../../library/uuid.rst:252 +#: ../../library/uuid.rst:250 msgid "" "For portability across platforms lacking sub-millisecond precision, UUIDs " "produced by this function embed a 48-bit timestamp and use a 42-bit counter " @@ -368,13 +368,13 @@ msgstr "" "為了在缺乏微秒精度的平台上具有可移植性,此函式生成的 UUID 嵌入了 48 位元的時" "間戳記,並使用 42 位元的計數器來保證在毫秒內的單調性。" -#: ../../library/uuid.rst:261 +#: ../../library/uuid.rst:259 msgid "" "Generate a pseudo-random UUID according to :rfc:`RFC 9562, §5.8 " "<9562#section-5.8>`." msgstr "根據 :rfc:`RFC 9562, §5.8 <9562#section-5.8>`,生成一個偽隨機 UUID。" -#: ../../library/uuid.rst:264 +#: ../../library/uuid.rst:262 msgid "" "When specified, the parameters *a*, *b* and *c* are expected to be positive " "integers of 48, 12 and 62 bits respectively. If they exceed their expected " @@ -385,7 +385,7 @@ msgstr "" "們超過了預期的位元數,則只保留它們的最低有效位元;未指定的參數將被替換為適當" "大小的偽隨機整數。" -#: ../../library/uuid.rst:270 +#: ../../library/uuid.rst:268 msgid "" "By default, *a*, *b* and *c* are not generated by a cryptographically secure " "pseudo-random number generator (CSPRNG). Use :func:`uuid4` when a UUID needs " @@ -394,7 +394,7 @@ msgstr "" "預設情況下,*a*、*b* 和 *c* 並非由加密安全的偽隨機數生成器 (CSPRNG) 生成。當 " "UUID 需要在安全敏感的情境中使用時,請使用 :func:`uuid4`。" -#: ../../library/uuid.rst:277 +#: ../../library/uuid.rst:275 msgid "" "The :mod:`!uuid` module defines the following namespace identifiers for use " "with :func:`uuid3` or :func:`uuid5`." @@ -402,7 +402,7 @@ msgstr "" ":mod:`!uuid` 模組為 :func:`uuid3` 或 :func:`uuid5` 定義了以下的命名空間識別" "碼。" -#: ../../library/uuid.rst:283 +#: ../../library/uuid.rst:281 msgid "" "When this namespace is specified, the *name* string is a fully qualified " "domain name." @@ -410,32 +410,32 @@ msgstr "" "當指定這個命名空間時,*name* 字串是一個完整網域名稱 (fully qualified domain " "name)。" -#: ../../library/uuid.rst:289 +#: ../../library/uuid.rst:287 msgid "When this namespace is specified, the *name* string is a URL." msgstr "當指定這個命名空間時,*name* 字串是一個 URL。" -#: ../../library/uuid.rst:294 +#: ../../library/uuid.rst:292 msgid "When this namespace is specified, the *name* string is an ISO OID." msgstr "當指定這個命名空間時,*name* 字串是一個 ISO OID。" -#: ../../library/uuid.rst:299 +#: ../../library/uuid.rst:297 msgid "" "When this namespace is specified, the *name* string is an X.500 DN in DER or " "a text output format." msgstr "" "當指定這個命名空間時,*name* 字串是以 DER 或文字輸出格式表示的 X.500 DN。" -#: ../../library/uuid.rst:302 +#: ../../library/uuid.rst:300 msgid "" "The :mod:`!uuid` module defines the following constants for the possible " "values of the :attr:`~UUID.variant` attribute:" msgstr ":mod:`!uuid` 模組為 :attr:`~UUID.variant` 屬性的可能值定義了以下常數:" -#: ../../library/uuid.rst:308 +#: ../../library/uuid.rst:306 msgid "Reserved for NCS compatibility." msgstr "保留供 NCS 相容性使用。" -#: ../../library/uuid.rst:313 +#: ../../library/uuid.rst:311 msgid "" "Specifies the UUID layout given in :rfc:`4122`. This constant is kept for " "backward compatibility even though :rfc:`4122` has been superseded by :rfc:" @@ -444,19 +444,19 @@ msgstr "" "指定 :rfc:`4122` 中給出的 UUID 佈局。即使 :rfc:`4122` 已被 :rfc:`9562` 取代," "這個常數仍然保留以保持向後相容性。" -#: ../../library/uuid.rst:320 +#: ../../library/uuid.rst:318 msgid "Reserved for Microsoft compatibility." msgstr "保留供 Microsoft 相容性使用。" -#: ../../library/uuid.rst:325 +#: ../../library/uuid.rst:323 msgid "Reserved for future definition." msgstr "保留供未來定義使用。" -#: ../../library/uuid.rst:328 +#: ../../library/uuid.rst:326 msgid "The :mod:`!uuid` module defines the special Nil and Max UUID values:" msgstr ":mod:`!uuid` 模組定義了特殊的 Nil 和 Max UUID 值:" -#: ../../library/uuid.rst:333 +#: ../../library/uuid.rst:331 msgid "" "A special form of UUID that is specified to have all 128 bits set to zero " "according to :rfc:`RFC 9562, §5.9 <9562#section-5.9>`." @@ -464,7 +464,7 @@ msgstr "" "根據 :rfc:`RFC 9562, §5.9 <9562#section-5.9>`,一種特殊形式的 UUID,被指定為" "所有 128 位元都設置為零。" -#: ../../library/uuid.rst:341 +#: ../../library/uuid.rst:339 msgid "" "A special form of UUID that is specified to have all 128 bits set to one " "according to :rfc:`RFC 9562, §5.10 <9562#section-5.10>`." @@ -472,13 +472,13 @@ msgstr "" "根據 :rfc:`RFC 9562, §5.10 <9562#section-5.10>`,一種特殊形式的 UUID,被指定" "為所有 128 位元都設置為一。" -#: ../../library/uuid.rst:349 +#: ../../library/uuid.rst:347 msgid ":rfc:`9562` - A Universally Unique IDentifier (UUID) URN Namespace" msgstr "" ":rfc:`9562` - 通用唯一辨識碼 (UUID, Universally Unique IDentifier) 的 URN 命" "名空間" -#: ../../library/uuid.rst:350 +#: ../../library/uuid.rst:348 msgid "" "This specification defines a Uniform Resource Name namespace for UUIDs, the " "internal format of UUIDs, and methods of generating UUIDs." @@ -486,16 +486,16 @@ msgstr "" "這個規範定義了 UUID 的統一資源名稱 (Uniform Resource Name) 命名空間、UUID 的" "內部格式和生成 UUID 的方法。" -#: ../../library/uuid.rst:357 +#: ../../library/uuid.rst:355 msgid "Command-Line Usage" msgstr "命令列的用法" -#: ../../library/uuid.rst:361 +#: ../../library/uuid.rst:359 msgid "" "The :mod:`!uuid` module can be executed as a script from the command line." msgstr ":mod:`!uuid` 模組可以在命令列下作為腳本來執行。" -#: ../../library/uuid.rst:363 +#: ../../library/uuid.rst:361 msgid "" "python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5,uuid6,uuid7,uuid8}] [-n " "NAMESPACE] [-N NAME]" @@ -503,25 +503,25 @@ msgstr "" "python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5,uuid6,uuid7,uuid8}] [-n " "NAMESPACE] [-N NAME]" -#: ../../library/uuid.rst:367 +#: ../../library/uuid.rst:365 msgid "The following options are accepted:" msgstr "可以接受以下選項:" -#: ../../library/uuid.rst:373 +#: ../../library/uuid.rst:371 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/uuid.rst:378 +#: ../../library/uuid.rst:376 msgid "" "Specify the function name to use to generate the uuid. By default :func:" "`uuid4` is used." msgstr "指定要用來生成 UUID 的函式名稱。預設使用 :func:`uuid4`。" -#: ../../library/uuid.rst:381 +#: ../../library/uuid.rst:379 msgid "Allow generating UUID versions 6, 7 and 8." msgstr "允許生成 UUID 版本 6、7 和 8。" -#: ../../library/uuid.rst:387 +#: ../../library/uuid.rst:385 msgid "" "The namespace is a ``UUID``, or ``@ns`` where ``ns`` is a well-known " "predefined UUID addressed by namespace name. Such as ``@dns``, ``@url``, " @@ -532,25 +532,25 @@ msgstr "" "空間名稱,例如 ``@dns``、``@url``、``@oid`` 和 ``@x500``。 只有 :func:" "`uuid3` / :func:`uuid5` 函式會需要。" -#: ../../library/uuid.rst:394 +#: ../../library/uuid.rst:392 msgid "" "The name used as part of generating the uuid. Only required for :func:" "`uuid3` / :func:`uuid5` functions." msgstr "用於生成 uuid 的名稱。只有 :func:`uuid3` / :func:`uuid5` 函式會需要。" -#: ../../library/uuid.rst:400 +#: ../../library/uuid.rst:398 msgid "Generate *num* fresh UUIDs." msgstr "生成 *num* 個新 UUID。" -#: ../../library/uuid.rst:408 +#: ../../library/uuid.rst:406 msgid "Example" msgstr "範例" -#: ../../library/uuid.rst:410 +#: ../../library/uuid.rst:408 msgid "Here are some examples of typical usage of the :mod:`!uuid` module::" msgstr "以下是一些 :mod:`!uuid` 模組的典型使用範例: ::" -#: ../../library/uuid.rst:412 +#: ../../library/uuid.rst:410 msgid "" ">>> import uuid\n" "\n" @@ -670,17 +670,17 @@ msgstr "" ">>> uuid.uuid8(0x12345678, 0x9abcdef0, 0x11223344)\n" "UUID('00001234-5678-8ef0-8000-000011223344')" -#: ../../library/uuid.rst:475 +#: ../../library/uuid.rst:473 msgid "Command-Line Example" msgstr "命令列的範例" -#: ../../library/uuid.rst:477 +#: ../../library/uuid.rst:475 msgid "" "Here are some examples of typical usage of the :mod:`!uuid` command-line " "interface:" msgstr "以下是一些 :mod:`!uuid` 命令列介面的典型使用範例:" -#: ../../library/uuid.rst:479 +#: ../../library/uuid.rst:477 msgid "" "# generate a random UUID - by default uuid4() is used\n" "$ python -m uuid\n" diff --git a/library/venv.po b/library/venv.po index c94822670c5..e0e3b4d7ba4 100644 --- a/library/venv.po +++ b/library/venv.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-06 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-05-23 10:20+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,11 +24,11 @@ msgstr "" msgid ":mod:`!venv` --- Creation of virtual environments" msgstr ":mod:`!venv` --- 建立虛擬環境" -#: ../../library/venv.rst:12 +#: ../../library/venv.rst:9 msgid "**Source code:** :source:`Lib/venv/`" msgstr "**原始碼:**\\ :source:`Lib/venv/`" -#: ../../library/venv.rst:21 +#: ../../library/venv.rst:18 msgid "" "The :mod:`!venv` module supports creating lightweight \"virtual " "environments\", each with their own independent set of Python packages " @@ -47,7 +47,7 @@ msgstr "" "environments` 以及 :mod:`site` 的\\ :ref:`虛擬環境文件 `。" -#: ../../library/venv.rst:32 +#: ../../library/venv.rst:29 msgid "" "When used from within a virtual environment, common installation tools such " "as :pypi:`pip` will install Python packages into a virtual environment " @@ -56,11 +56,11 @@ msgstr "" "在使用虛擬環境中時,像 :pypi:`pip` 這樣的常用安裝工具會自動將 Python 套件安裝" "至虛擬環境中,而不需要額外指定。" -#: ../../library/venv.rst:36 +#: ../../library/venv.rst:33 msgid "A virtual environment is (amongst other things):" msgstr "虛擬環境是(主要的特性):" -#: ../../library/venv.rst:38 +#: ../../library/venv.rst:35 msgid "" "Used to contain a specific Python interpreter and software libraries and " "binaries which are needed to support a project (library or application). " @@ -71,7 +71,7 @@ msgstr "" "用程式)。預設情況下,這些內容會與其他虛擬環境中的軟體以及作業系統中安裝的 " "Python 直譯器與函式庫隔離。" -#: ../../library/venv.rst:43 +#: ../../library/venv.rst:40 msgid "" "Contained in a directory, conventionally named ``.venv`` or ``venv`` in the " "project directory, or under a container directory for lots of virtual " @@ -80,11 +80,11 @@ msgstr "" "被包含在一個目錄中,通常命名為專案目錄下的 ``.venv`` 或 ``venv``,也可能是在" "用來管理多個虛擬環境的容器目錄中,例如 ``~/.virtualenvs``。" -#: ../../library/venv.rst:47 +#: ../../library/venv.rst:44 msgid "Not checked into source control systems such as Git." msgstr "不應提交至 Git 等版本控制系統。" -#: ../../library/venv.rst:49 +#: ../../library/venv.rst:46 msgid "" "Considered as disposable -- it should be simple to delete and recreate it " "from scratch. You don't place any project code in the environment." @@ -92,17 +92,17 @@ msgstr "" "被視為可拋棄的資源——應能簡單地刪除並從頭重新建立。請勿將任何專案程式碼放置於" "虛擬環境中。" -#: ../../library/venv.rst:52 +#: ../../library/venv.rst:49 msgid "" "Not considered as movable or copyable -- you just recreate the same " "environment in the target location." msgstr "不應移動或複製——若需在其他位置使用,應重新建立相同的虛擬環境。" -#: ../../library/venv.rst:55 +#: ../../library/venv.rst:52 msgid "See :pep:`405` for more background on Python virtual environments." msgstr "更多關於 Python 虛擬環境的背景資訊請見 :pep:`405`。" -#: ../../library/venv.rst:59 +#: ../../library/venv.rst:56 msgid "" "`Python Packaging User Guide: Creating and using virtual environments " "`\\ 或 :ref:`WebAssembly 平台 " "`\\ 上不支援。" -#: ../../library/venv.rst:65 +#: ../../library/venv.rst:62 msgid "Creating virtual environments" msgstr "建立虛擬環境" -#: ../../library/venv.rst:67 +#: ../../library/venv.rst:64 msgid "" ":ref:`Virtual environments ` are created by executing the ``venv`` " "module:" msgstr ":ref:`虛擬環境 `\\ 是透過執行 ``venv`` 模組來建立:" -#: ../../library/venv.rst:70 +#: ../../library/venv.rst:67 msgid "python -m venv /path/to/new/virtual/environment" msgstr "python -m venv /path/to/new/virtual/environment" -#: ../../library/venv.rst:74 +#: ../../library/venv.rst:71 msgid "" "This creates the target directory (including parent directories as needed) " "and places a :file:`pyvenv.cfg` file in it with a ``home`` key pointing to " @@ -157,12 +157,12 @@ msgstr "" "packages` 子目錄(在 Windows 上為 :file:`Lib\\\\site-packages`)。如果指定的" "目錄已存在,則將重新使用該目錄。" -#: ../../library/venv.rst:84 +#: ../../library/venv.rst:81 msgid "" "The use of ``venv`` is now recommended for creating virtual environments." msgstr "目前建議使用 ``venv`` 來建立虛擬環境。" -#: ../../library/venv.rst:87 +#: ../../library/venv.rst:84 msgid "" ":program:`pyvenv` was the recommended tool for creating virtual environments " "for Python 3.3 and 3.4, and replaced in 3.5 by executing ``venv`` directly." @@ -170,19 +170,19 @@ msgstr "" ":program:`pyvenv` 是在 Python 3.3 和 3.4 中建立虛擬環境的推薦工具,但在 " "Python 3.5 中已被直接執行 ``venv`` 所取代。" -#: ../../library/venv.rst:93 +#: ../../library/venv.rst:90 msgid "On Windows, invoke the ``venv`` command as follows:" msgstr "在 Windows 上,執行以下命令以使用 ``venv``:" -#: ../../library/venv.rst:95 +#: ../../library/venv.rst:92 msgid "PS> python -m venv C:\\path\\to\\new\\virtual\\environment" msgstr "PS> python -m venv C:\\path\\to\\new\\virtual\\environment" -#: ../../library/venv.rst:99 +#: ../../library/venv.rst:96 msgid "The command, if run with ``-h``, will show the available options::" msgstr "如果使用 ``-h`` 選項執行該命令,將會顯示可用的選項:" -#: ../../library/venv.rst:101 +#: ../../library/venv.rst:98 msgid "" "usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear]\n" " [--upgrade] [--without-pip] [--prompt PROMPT] [--upgrade-deps]\n" @@ -195,67 +195,67 @@ msgid "" "sourcing an activate script in its bin directory." msgstr "" -#: ../../library/venv.rst:116 +#: ../../library/venv.rst:113 msgid "" "A required argument specifying the directory to create the environment in." msgstr "" -#: ../../library/venv.rst:120 +#: ../../library/venv.rst:117 msgid "" "Give the virtual environment access to the system site-packages directory." msgstr "" -#: ../../library/venv.rst:124 +#: ../../library/venv.rst:121 msgid "" "Try to use symlinks rather than copies, when symlinks are not the default " "for the platform." msgstr "" -#: ../../library/venv.rst:128 +#: ../../library/venv.rst:125 msgid "" "Try to use copies rather than symlinks, even when symlinks are the default " "for the platform." msgstr "" -#: ../../library/venv.rst:132 +#: ../../library/venv.rst:129 msgid "" "Delete the contents of the environment directory if it already exists, " "before environment creation." msgstr "" -#: ../../library/venv.rst:136 +#: ../../library/venv.rst:133 msgid "" "Upgrade the environment directory to use this version of Python, assuming " "Python has been upgraded in-place." msgstr "" -#: ../../library/venv.rst:140 +#: ../../library/venv.rst:137 msgid "" "Skips installing or upgrading pip in the virtual environment (pip is " "bootstrapped by default)." msgstr "" -#: ../../library/venv.rst:144 +#: ../../library/venv.rst:141 msgid "Provides an alternative prompt prefix for this environment." msgstr "" -#: ../../library/venv.rst:148 +#: ../../library/venv.rst:145 msgid "Upgrade core dependencies (pip) to the latest version in PyPI." msgstr "" -#: ../../library/venv.rst:152 +#: ../../library/venv.rst:149 msgid "" "Skips adding SCM ignore files to the environment directory (Git is supported " "by default)." msgstr "" -#: ../../library/venv.rst:155 +#: ../../library/venv.rst:152 msgid "" "Installs pip by default, added the ``--without-pip`` and ``--copies`` " "options." msgstr "預設會安裝 pip,並新增了 ``--without-pip`` 和 ``--copies`` 選項" -#: ../../library/venv.rst:159 +#: ../../library/venv.rst:156 msgid "" "In earlier versions, if the target directory already existed, an error was " "raised, unless the ``--clear`` or ``--upgrade`` option was provided." @@ -263,26 +263,26 @@ msgstr "" "在較早的版本中,如果目標目錄已存在,除非提供了 ``--clear`` 或 ``--upgrade`` " "選項,否則會引發錯誤。" -#: ../../library/venv.rst:163 +#: ../../library/venv.rst:160 msgid "" "Add ``--upgrade-deps`` option to upgrade pip + setuptools to the latest on " "PyPI." msgstr "" "新增 ``--upgrade-deps`` 選項以將 pip 和 setuptools 升級至 PyPI 上的最新版本" -#: ../../library/venv.rst:168 +#: ../../library/venv.rst:165 msgid "``setuptools`` is no longer a core venv dependency." msgstr "``setuptools`` 不再是 venv 的核心相依套件。" -#: ../../library/venv.rst:172 +#: ../../library/venv.rst:169 msgid "Added the ``--without-scm-ignore-files`` option." msgstr "新增 ``--without-scm-ignore-files`` 選項" -#: ../../library/venv.rst:173 +#: ../../library/venv.rst:170 msgid "``venv`` now creates a :file:`.gitignore` file for Git by default." msgstr "``venv`` 現在預設會為 Git 建立 :file:`.gitignore` 檔案。" -#: ../../library/venv.rst:177 +#: ../../library/venv.rst:174 msgid "" "While symlinks are supported on Windows, they are not recommended. Of " "particular note is that double-clicking ``python.exe`` in File Explorer will " @@ -291,7 +291,7 @@ msgstr "" "雖然在 Windows 上支援符號連結,但並不建議使用。特別需要注意的是,在檔案總管中" "按兩下 ``python.exe`` 會急切地解析符號連結並忽略虛擬環境。" -#: ../../library/venv.rst:182 +#: ../../library/venv.rst:179 msgid "" "On Microsoft Windows, it may be required to enable the ``Activate.ps1`` " "script by setting the execution policy for the user. You can do this by " @@ -300,13 +300,13 @@ msgstr "" "在 Microsoft Windows 上,可能需要透過設置使用者的執行策略來啟用 ``Activate." "ps1`` 腳本。你可以發出以下 PowerShell 命令來執行此操作:" -#: ../../library/venv.rst:186 +#: ../../library/venv.rst:183 msgid "" "PS C:\\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser" msgstr "" "PS C:\\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser" -#: ../../library/venv.rst:190 +#: ../../library/venv.rst:187 msgid "" "See `About Execution Policies `_ for more information." @@ -314,7 +314,7 @@ msgstr "" "有關更多資訊,請參閱\\ `關於執行策略 `_。" -#: ../../library/venv.rst:194 +#: ../../library/venv.rst:191 msgid "" "The created :file:`pyvenv.cfg` file also includes the ``include-system-site-" "packages`` key, set to ``true`` if ``venv`` is run with the ``--system-site-" @@ -324,7 +324,7 @@ msgstr "" "鍵,如果使用 ``venv`` 執行時帶有 ``--system-site-packages`` 選項,則設置為 " "``true``,否則設置為 ``false``。" -#: ../../library/venv.rst:198 +#: ../../library/venv.rst:195 msgid "" "Unless the ``--without-pip`` option is given, :mod:`ensurepip` will be " "invoked to bootstrap ``pip`` into the virtual environment." @@ -332,7 +332,7 @@ msgstr "" "除非 ``--without-pip`` 選項被提供,否則將叫用 :mod:`ensurepip` 來啟動 " "``pip`` 到虛擬環境中。" -#: ../../library/venv.rst:201 +#: ../../library/venv.rst:198 msgid "" "Multiple paths can be given to ``venv``, in which case an identical virtual " "environment will be created, according to the given options, at each " @@ -341,11 +341,11 @@ msgstr "" "可以向 ``venv`` 提供多個路徑,這樣每個提供的路徑都將根據給定的選項建立一個相" "同的虛擬環境。" -#: ../../library/venv.rst:208 +#: ../../library/venv.rst:205 msgid "How venvs work" msgstr "虛擬環境如何運作" -#: ../../library/venv.rst:210 +#: ../../library/venv.rst:207 msgid "" "When a Python interpreter is running from a virtual environment, :data:`sys." "prefix` and :data:`sys.exec_prefix` point to the directories of the virtual " @@ -359,7 +359,7 @@ msgstr "" "base_exec_prefix` 會指向建立虛擬環境的基礎 Python 的目錄。檢查 ``sys.prefix !" "= sys.base_prefix`` 就可以確定目前的直譯器是否跑在虛擬環境中。" -#: ../../library/venv.rst:219 +#: ../../library/venv.rst:216 msgid "" "A virtual environment may be \"activated\" using a script in its binary " "directory (``bin`` on POSIX; ``Scripts`` on Windows). This will prepend that " @@ -375,85 +375,85 @@ msgstr "" "用完整的路徑。啟動腳本的方式因平台而異(:samp:`{}` 需要替換成包含虛擬環" "境的目錄路徑)" -#: ../../library/venv.rst:229 +#: ../../library/venv.rst:226 msgid "Platform" msgstr "平台" -#: ../../library/venv.rst:229 +#: ../../library/venv.rst:226 msgid "Shell" msgstr "Shell" -#: ../../library/venv.rst:229 +#: ../../library/venv.rst:226 msgid "Command to activate virtual environment" msgstr "啟動虛擬環境的指令" -#: ../../library/venv.rst:231 +#: ../../library/venv.rst:228 msgid "POSIX" msgstr "POSIX" -#: ../../library/venv.rst:231 +#: ../../library/venv.rst:228 msgid "bash/zsh" msgstr "bash/zsh" -#: ../../library/venv.rst:231 +#: ../../library/venv.rst:228 msgid ":samp:`$ source {}/bin/activate`" msgstr ":samp:`$ source {}/bin/activate`" -#: ../../library/venv.rst:233 +#: ../../library/venv.rst:230 msgid "fish" msgstr "fish" -#: ../../library/venv.rst:233 +#: ../../library/venv.rst:230 msgid ":samp:`$ source {}/bin/activate.fish`" msgstr ":samp:`$ source {}/bin/activate.fish`" -#: ../../library/venv.rst:235 +#: ../../library/venv.rst:232 msgid "csh/tcsh" msgstr "csh/tcsh" -#: ../../library/venv.rst:235 +#: ../../library/venv.rst:232 msgid ":samp:`$ source {}/bin/activate.csh`" msgstr ":samp:`$ source {}/bin/activate.csh`" -#: ../../library/venv.rst:237 +#: ../../library/venv.rst:234 msgid "pwsh" msgstr "pwsh" -#: ../../library/venv.rst:237 +#: ../../library/venv.rst:234 msgid ":samp:`$ {}/bin/Activate.ps1`" msgstr ":samp:`$ {}/bin/Activate.ps1`" -#: ../../library/venv.rst:239 +#: ../../library/venv.rst:236 msgid "Windows" msgstr "Windows" -#: ../../library/venv.rst:239 +#: ../../library/venv.rst:236 msgid "cmd.exe" msgstr "cmd.exe" -#: ../../library/venv.rst:239 +#: ../../library/venv.rst:236 msgid ":samp:`C:\\\\> {}\\\\Scripts\\\\activate.bat`" msgstr ":samp:`C:\\\\> {}\\\\Scripts\\\\activate.bat`" -#: ../../library/venv.rst:241 +#: ../../library/venv.rst:238 msgid "PowerShell" msgstr "PowerShell" -#: ../../library/venv.rst:241 +#: ../../library/venv.rst:238 msgid ":samp:`PS C:\\\\> {}\\\\Scripts\\\\Activate.ps1`" msgstr ":samp:`PS C:\\\\> {}\\\\Scripts\\\\Activate.ps1`" -#: ../../library/venv.rst:244 +#: ../../library/venv.rst:241 msgid ":program:`fish` and :program:`csh` activation scripts." msgstr ":program:`fish` 和 :program:`csh` 啟動腳本。" -#: ../../library/venv.rst:247 +#: ../../library/venv.rst:244 msgid "" "PowerShell activation scripts installed under POSIX for PowerShell Core " "support." msgstr "PowerShell 的啟動腳本安裝在 POSIX 上支援 PowerShell Core。" -#: ../../library/venv.rst:251 +#: ../../library/venv.rst:248 msgid "" "You don't specifically *need* to activate a virtual environment, as you can " "just specify the full path to that environment's Python interpreter when " @@ -464,7 +464,7 @@ msgstr "" "整路徑。此外,所有安裝在環境裡的腳本都應該都可以在未啟用虛擬環境的情況下運" "行。" -#: ../../library/venv.rst:257 +#: ../../library/venv.rst:254 msgid "" "In order to achieve this, scripts installed into virtual environments have a " "\"shebang\" line which points to the environment's Python interpreter, :samp:" @@ -482,7 +482,7 @@ msgstr "" "Explorer)中雙擊已安裝的腳本,應該可以在沒有啟用環境或將其加入 :envvar:" "`PATH` 的情況下正確地運行。" -#: ../../library/venv.rst:266 +#: ../../library/venv.rst:263 msgid "" "When a virtual environment has been activated, the :envvar:`!VIRTUAL_ENV` " "environment variable is set to the path of the environment. Since explicitly " @@ -494,7 +494,7 @@ msgstr "" "於不需要明確啟用虛擬環境才能使用它。因此,無法依賴 :envvar:`!VIRTUAL_ENV` 來" "判斷是否正在使用虛擬環境。" -#: ../../library/venv.rst:272 +#: ../../library/venv.rst:269 msgid "" "Because scripts installed in environments should not expect the environment " "to be activated, their shebang lines contain the absolute paths to their " @@ -517,7 +517,7 @@ msgstr "" "位置重新建立它,並刪除舊位置的環境。如果你移動環境是因為移動了其父目錄,你應" "該在新位置重新建立環境。否則,安裝在該環境中的軟體可能無法正常運作。" -#: ../../library/venv.rst:286 +#: ../../library/venv.rst:283 msgid "" "You can deactivate a virtual environment by typing ``deactivate`` in your " "shell. The exact mechanism is platform-specific and is an internal " @@ -526,11 +526,11 @@ msgstr "" "你可以在 shell 輸入 ``deactivate`` 來關閉虛擬環境。具體的使用方式因平台而異," "是內部實作的細節(通常會使用腳本或是 shell 函式)" -#: ../../library/venv.rst:294 +#: ../../library/venv.rst:291 msgid "API" msgstr "API" -#: ../../library/venv.rst:298 +#: ../../library/venv.rst:295 msgid "" "The high-level method described above makes use of a simple API which " "provides mechanisms for third-party virtual environment creators to " @@ -540,13 +540,13 @@ msgstr "" "上述提到的高階 method(方法)透過簡單的 API 使用, 為第三方虛擬環境建立者提供" "可以依據他們需求來建立環境的客製化機制: :class:`EnvBuilder` class。" -#: ../../library/venv.rst:307 +#: ../../library/venv.rst:304 msgid "" "The :class:`EnvBuilder` class accepts the following keyword arguments on " "instantiation:" msgstr "進行實例化時,class :class:`EnvBuilder` 接受下列的關鍵字引數:" -#: ../../library/venv.rst:310 +#: ../../library/venv.rst:307 msgid "" "*system_site_packages* -- a boolean value indicating that the system Python " "site-packages should be available to the environment (defaults to ``False``)." @@ -554,7 +554,7 @@ msgstr "" "*system_site_packages* -- 為一個 boolean (布林值),並表明系統的 Python " "site-packages 是否可以在環境中可用(預設為 ``False`` )。" -#: ../../library/venv.rst:313 +#: ../../library/venv.rst:310 msgid "" "*clear* -- a boolean value which, if true, will delete the contents of any " "existing target directory, before creating the environment." @@ -562,7 +562,7 @@ msgstr "" "*clear* -- 為一個 boolean,如果為 true,則在建立環境之前,刪除目標目錄內所有" "存在的內容。" -#: ../../library/venv.rst:316 +#: ../../library/venv.rst:313 msgid "" "*symlinks* -- a boolean value indicating whether to attempt to symlink the " "Python binary rather than copying." @@ -570,7 +570,7 @@ msgstr "" "*symlinks* -- 為一個 boolean,並表明是否嘗試與 Python 二進位檔案建立符號連結" "而不是複製該檔案。" -#: ../../library/venv.rst:319 +#: ../../library/venv.rst:316 msgid "" "*upgrade* -- a boolean value which, if true, will upgrade an existing " "environment with the running Python - for use when that Python has been " @@ -579,7 +579,7 @@ msgstr "" "*upgrade* -- 為一個 boolean,若為 true,則會在執行 Python 時為現有的環境進行" "升級。目的是讓 Python 可以升級到位(預設為 ``False``)。" -#: ../../library/venv.rst:323 +#: ../../library/venv.rst:320 msgid "" "*with_pip* -- a boolean value which, if true, ensures pip is installed in " "the virtual environment. This uses :mod:`ensurepip` with the ``--default-" @@ -588,7 +588,7 @@ msgstr "" "*with_pip* -- 為一個 boolean,若為 true,則確保 pip 有安裝至虛擬環境之中。當" "有 ``--default-pip`` 的選項時,會使用 :mod:`ensurepip`。" -#: ../../library/venv.rst:327 +#: ../../library/venv.rst:324 msgid "" "*prompt* -- a string to be used after virtual environment is activated " "(defaults to ``None`` which means directory name of the environment would be " @@ -599,11 +599,11 @@ msgstr "" "``None``,代表該環境的目錄名稱會被使用)倘若出現特殊字串 ``\".\"`` ,則目前目" "錄的 basename 會做為提示路徑使用。" -#: ../../library/venv.rst:332 +#: ../../library/venv.rst:329 msgid "*upgrade_deps* -- Update the base venv modules to the latest on PyPI" msgstr "*upgrade_deps* -- 更新基礎 venv 模組至 PyPI 的最新版本" -#: ../../library/venv.rst:334 +#: ../../library/venv.rst:331 msgid "" "*scm_ignore_files* -- Create ignore files based for the specified source " "control managers (SCM) in the iterable. Support is defined by having a " @@ -614,27 +614,27 @@ msgstr "" "檔。支援情況取決於是否有名為 ``create_{scm}_ignore_file`` 的方法。預設唯一支" "援的值是 ``\"git\"``,透過 :meth:`create_git_ignore_file` 方法提供支援。" -#: ../../library/venv.rst:340 +#: ../../library/venv.rst:337 msgid "Added the ``with_pip`` parameter" msgstr "新增 ``with_pip`` 參數" -#: ../../library/venv.rst:343 +#: ../../library/venv.rst:340 msgid "Added the ``prompt`` parameter" msgstr "新增 ``prompt`` 參數" -#: ../../library/venv.rst:346 +#: ../../library/venv.rst:343 msgid "Added the ``upgrade_deps`` parameter" msgstr "新增 ``upgrade_deps`` 參數" -#: ../../library/venv.rst:349 +#: ../../library/venv.rst:346 msgid "Added the ``scm_ignore_files`` parameter" msgstr "新增 ``scm_ignore_files`` 參數" -#: ../../library/venv.rst:352 +#: ../../library/venv.rst:349 msgid ":class:`EnvBuilder` may be used as a base class." msgstr ":class:`EnvBuilder` 可以被用作為基底類別。" -#: ../../library/venv.rst:356 +#: ../../library/venv.rst:353 msgid "" "Create a virtual environment by specifying the target directory (absolute or " "relative to the current directory) which is to contain the virtual " @@ -645,7 +645,7 @@ msgstr "" "目錄),也就是在該目錄中容納虛擬環境。``create`` method 將會在指定的目錄下建" "立環境,或是觸發適當的例外。" -#: ../../library/venv.rst:362 +#: ../../library/venv.rst:359 msgid "" "The ``create`` method of the :class:`EnvBuilder` class illustrates the hooks " "available for subclass customization::" @@ -653,7 +653,7 @@ msgstr "" ":class:`EnvBuilder` class 的 ``create`` method 會闡述可用的 Hooks 以客製化 " "subclass (子類別)::" -#: ../../library/venv.rst:365 +#: ../../library/venv.rst:362 msgid "" "def create(self, env_dir):\n" " \"\"\"\n" @@ -679,7 +679,7 @@ msgstr "" " self.setup_scripts(context)\n" " self.post_setup(context)" -#: ../../library/venv.rst:377 +#: ../../library/venv.rst:374 msgid "" "Each of the methods :meth:`ensure_directories`, :meth:" "`create_configuration`, :meth:`setup_python`, :meth:`setup_scripts` and :" @@ -688,7 +688,7 @@ msgstr "" "每個 methods :meth:`ensure_directories`、:meth:`create_configuration`、:meth:" "`setup_python`、:meth:`setup_scripts` 及 :meth:`post_setup` 都可以被覆寫。" -#: ../../library/venv.rst:383 +#: ../../library/venv.rst:380 msgid "" "Creates the environment directory and all necessary subdirectories that " "don't already exist, and returns a context object. This context object is " @@ -702,7 +702,7 @@ msgstr "" "class:`EnvBuilder` 已被建立且帶有 ``clear=True`` 的引數,該環境目錄下的內容將" "被清空,以及所有必要的子目錄將被重新建立。" -#: ../../library/venv.rst:390 +#: ../../library/venv.rst:387 msgid "" "The returned context object is a :class:`types.SimpleNamespace` with the " "following attributes:" @@ -710,7 +710,7 @@ msgstr "" "回傳的情境物件(context object)其型別會是 :class:`types.SimpleNamespace`,並" "包含以下屬性:" -#: ../../library/venv.rst:393 +#: ../../library/venv.rst:390 msgid "" "``env_dir`` - The location of the virtual environment. Used for " "``__VENV_DIR__`` in activation scripts (see :meth:`install_scripts`)." @@ -718,7 +718,7 @@ msgstr "" "``env_dir`` —— 虛擬環境的位置。用於啟用腳本中的 ``__VENV_DIR__``\\ (參見 :" "meth:`install_scripts`)。" -#: ../../library/venv.rst:396 +#: ../../library/venv.rst:393 msgid "" "``env_name`` - The name of the virtual environment. Used for " "``__VENV_NAME__`` in activation scripts (see :meth:`install_scripts`)." @@ -726,7 +726,7 @@ msgstr "" "``env_name`` —— 虛擬環境的名稱。用於啟用腳本中的 ``__VENV_NAME__``\\ (參見 :" "meth:`install_scripts`)。" -#: ../../library/venv.rst:399 +#: ../../library/venv.rst:396 msgid "" "``prompt`` - The prompt to be used by the activation scripts. Used for " "``__VENV_PROMPT__`` in activation scripts (see :meth:`install_scripts`)." @@ -734,7 +734,7 @@ msgstr "" "``prompt`` —— 啟用腳本所使用的提示字元。用於啟用腳本中的 " "``__VENV_PROMPT__``\\ (參見 :meth:`install_scripts`)。" -#: ../../library/venv.rst:402 +#: ../../library/venv.rst:399 msgid "" "``executable`` - The underlying Python executable used by the virtual " "environment. This takes into account the case where a virtual environment is " @@ -743,19 +743,23 @@ msgstr "" "``executable`` —— 虛擬環境所使用的底層 Python 執行檔。在從其他虛擬環境建立虛" "擬環境的情況下,也會一併考慮該情境。" -#: ../../library/venv.rst:406 +#: ../../library/venv.rst:403 msgid "``inc_path`` - The include path for the virtual environment." msgstr "``inc_path`` —— 虛擬環境的 include 路徑。" -#: ../../library/venv.rst:408 +#: ../../library/venv.rst:405 msgid "``lib_path`` - The purelib path for the virtual environment." msgstr "``lib_path`` —— 虛擬環境的 purelib 路徑。" -#: ../../library/venv.rst:410 +#: ../../library/venv.rst:407 +msgid "``platlib_path`` - The platlib path for the virtual environment." +msgstr "``platlib_path`` —— 虛擬環境的 platlib 路徑。" + +#: ../../library/venv.rst:409 msgid "``bin_path`` - The script path for the virtual environment." msgstr "``bin_path`` —— 虛擬環境的腳本路徑。" -#: ../../library/venv.rst:412 +#: ../../library/venv.rst:411 msgid "" "``bin_name`` - The name of the script path relative to the virtual " "environment location. Used for ``__VENV_BIN_NAME__`` in activation scripts " @@ -764,7 +768,7 @@ msgstr "" "``bin_name`` —— 相對於虛擬環境位置的腳本路徑名稱。用於啟用腳本中的 " "``__VENV_BIN_NAME__``\\ (參見 :meth:`install_scripts`)。" -#: ../../library/venv.rst:416 +#: ../../library/venv.rst:415 msgid "" "``env_exe`` - The name of the Python interpreter in the virtual environment. " "Used for ``__VENV_PYTHON__`` in activation scripts (see :meth:" @@ -773,7 +777,7 @@ msgstr "" "``env_exe`` —— 虛擬環境中 Python 直譯器的名稱。用於啟用腳本中的 " "``__VENV_PYTHON__``\\ (參見 :meth:`install_scripts`)。" -#: ../../library/venv.rst:420 +#: ../../library/venv.rst:419 msgid "" "``env_exec_cmd`` - The name of the Python interpreter, taking into account " "filesystem redirections. This can be used to run Python in the virtual " @@ -782,7 +786,7 @@ msgstr "" "``env_exec_cmd`` —— Python 直譯器名稱,會將檔案系統重新導向後納入考慮。可用於" "在虛擬環境中執行 Python。" -#: ../../library/venv.rst:425 +#: ../../library/venv.rst:424 msgid "" "The *venv* :ref:`sysconfig installation scheme ` is used " "to construct the paths of the created directories." @@ -790,17 +794,21 @@ msgstr "" "*venv* 使用 :ref:`sysconfig 安裝配置方案 ` 來建構所建立目" "錄的路徑。" -#: ../../library/venv.rst:430 +#: ../../library/venv.rst:429 msgid "" "The attribute ``lib_path`` was added to the context, and the context object " "was documented." msgstr "``lib_path`` 屬性已新增至情境中,且情境物件已加入文件說明。" -#: ../../library/venv.rst:436 +#: ../../library/venv.rst:433 +msgid "The attribute ``platlib_path`` was added to the context." +msgstr "``platlib_path`` 屬性已新增至情境中。" + +#: ../../library/venv.rst:438 msgid "Creates the ``pyvenv.cfg`` configuration file in the environment." msgstr "在環境中建立 ``pyvenv.cfg`` 設定檔。" -#: ../../library/venv.rst:440 +#: ../../library/venv.rst:442 msgid "" "Creates a copy or symlink to the Python executable in the environment. On " "POSIX systems, if a specific executable ``python3.x`` was used, symlinks to " @@ -811,13 +819,13 @@ msgstr "" "``python3.x`` 執行檔,將建立指向該執行檔的 ``python`` 與 ``python3`` 符號連結" "(除非這些名稱的檔案已存在)。" -#: ../../library/venv.rst:447 +#: ../../library/venv.rst:449 msgid "" "Installs activation scripts appropriate to the platform into the virtual " "environment." msgstr "將符合平台的啟用腳本安裝到虛擬環境中。" -#: ../../library/venv.rst:452 +#: ../../library/venv.rst:454 msgid "" "Upgrades the core venv dependency packages (currently :pypi:`pip`) in the " "environment. This is done by shelling out to the ``pip`` executable in the " @@ -826,11 +834,11 @@ msgstr "" "更新虛擬環境中的核心 venv 相依套件(目前為 :pypi:`pip`)。此動作會透過執行虛" "擬環境中的 ``pip`` 執行檔來完成。" -#: ../../library/venv.rst:459 +#: ../../library/venv.rst:461 msgid ":pypi:`setuptools` is no longer a core venv dependency." msgstr ":pypi:`setuptools` 不再是核心 venv 的相依項目。" -#: ../../library/venv.rst:463 +#: ../../library/venv.rst:465 msgid "" "A placeholder method which can be overridden in third party implementations " "to pre-install packages in the virtual environment or perform other post-" @@ -839,7 +847,7 @@ msgstr "" "此佔位方法在虛擬環境中預先安裝套件,或執行其他建立後的動作,可由第三方實作覆" "寫。" -#: ../../library/venv.rst:469 +#: ../../library/venv.rst:471 msgid "" "This method can be called from :meth:`setup_scripts` or :meth:`post_setup` " "in subclasses to assist in installing custom scripts into the virtual " @@ -848,7 +856,7 @@ msgstr "" "此方法可由子類別中的 :meth:`setup_scripts` 或 :meth:`post_setup` 呼叫,協助將" "自訂腳本安裝到虛擬環境中。" -#: ../../library/venv.rst:473 +#: ../../library/venv.rst:475 msgid "" "*path* is the path to a directory that should contain subdirectories " "``common``, ``posix``, ``nt``; each containing scripts destined for the " @@ -860,19 +868,19 @@ msgstr "" "每個子目錄中都包含指向環境中 ``bin`` 目錄的腳本。在執行部分佔位符文字替換後," "將會複製 ``common`` 及與 :data:`os.name` 對應的目錄的內容:" -#: ../../library/venv.rst:479 +#: ../../library/venv.rst:481 msgid "" "``__VENV_DIR__`` is replaced with the absolute path of the environment " "directory." msgstr "``__VENV_DIR__`` 會被替換為環境目錄的絕對路徑。" -#: ../../library/venv.rst:482 +#: ../../library/venv.rst:484 msgid "" "``__VENV_NAME__`` is replaced with the environment name (final path segment " "of environment directory)." msgstr "``__VENV_NAME__`` 會被替換為環境的名稱(即該環境目錄路徑的最後一段)。" -#: ../../library/venv.rst:485 +#: ../../library/venv.rst:487 msgid "" "``__VENV_PROMPT__`` is replaced with the prompt (the environment name " "surrounded by parentheses and with a following space)" @@ -880,7 +888,7 @@ msgstr "" "``__VENV_PROMPT__`` 會被替換為提示字元(即以括號包裹的環境名稱,並附帶一個空" "格)。" -#: ../../library/venv.rst:488 +#: ../../library/venv.rst:490 msgid "" "``__VENV_BIN_NAME__`` is replaced with the name of the bin directory (either " "``bin`` or ``Scripts``)." @@ -888,26 +896,26 @@ msgstr "" "``__VENV_BIN_NAME__`` 會被替換為 bin 目錄的名稱(可能是 ``bin`` 或 " "``Scripts``)。" -#: ../../library/venv.rst:491 +#: ../../library/venv.rst:493 msgid "" "``__VENV_PYTHON__`` is replaced with the absolute path of the environment's " "executable." msgstr "``__VENV_PYTHON__`` 會被替換為環境中 Python 執行檔的絕對路徑。" -#: ../../library/venv.rst:494 +#: ../../library/venv.rst:496 msgid "" "The directories are allowed to exist (for when an existing environment is " "being upgraded)." msgstr "允許這些目錄存在(例如當更新既有環境時)。" -#: ../../library/venv.rst:499 +#: ../../library/venv.rst:501 msgid "" "Creates a ``.gitignore`` file within the virtual environment that causes the " "entire directory to be ignored by the Git source control manager." msgstr "" "在虛擬環境中建立一個 ``.gitignore`` 檔案,讓 Git 原始碼控管工具忽略整個目錄。" -#: ../../library/venv.rst:504 +#: ../../library/venv.rst:506 msgid "" "Windows now uses redirector scripts for ``python[w].exe`` instead of copying " "the actual binaries. In 3.7.2 only :meth:`setup_python` does nothing unless " @@ -917,7 +925,7 @@ msgstr "" "檔。在 3.7.2 中,只有當從原始碼樹中建構時,:meth:`setup_python` 才會執行操" "作。" -#: ../../library/venv.rst:509 +#: ../../library/venv.rst:511 msgid "" "Windows copies the redirector scripts as part of :meth:`setup_python` " "instead of :meth:`setup_scripts`. This was not the case in 3.7.2. When using " @@ -927,11 +935,11 @@ msgstr "" "`setup_scripts` 中進行。這在 3.7.2 中並非如此。若使用符號連結,則會連結至原始" "的可執行檔。" -#: ../../library/venv.rst:514 +#: ../../library/venv.rst:516 msgid "There is also a module-level convenience function:" msgstr "也有一個方便的模組層級的函式:" -#: ../../library/venv.rst:520 +#: ../../library/venv.rst:522 msgid "" "Create an :class:`EnvBuilder` with the given keyword arguments, and call " "its :meth:`~EnvBuilder.create` method with the *env_dir* argument." @@ -939,27 +947,27 @@ msgstr "" "使用提供的關鍵字引數建立一個 :class:`EnvBuilder`,並以 *env_dir* 作為引數呼叫" "其 :meth:`~EnvBuilder.create` 方法。" -#: ../../library/venv.rst:525 +#: ../../library/venv.rst:527 msgid "Added the *with_pip* parameter" msgstr "新增 *with_pip* 參數" -#: ../../library/venv.rst:528 +#: ../../library/venv.rst:530 msgid "Added the *prompt* parameter" msgstr "新增 *prompt* 參數" -#: ../../library/venv.rst:531 +#: ../../library/venv.rst:533 msgid "Added the *upgrade_deps* parameter" msgstr "新增 *upgrade_deps* 參數" -#: ../../library/venv.rst:534 +#: ../../library/venv.rst:536 msgid "Added the *scm_ignore_files* parameter" msgstr "新增 *scm_ignore_files* 參數" -#: ../../library/venv.rst:538 +#: ../../library/venv.rst:540 msgid "An example of extending ``EnvBuilder``" msgstr "一個擴展 ``EnvBuilder`` 的範例" -#: ../../library/venv.rst:540 +#: ../../library/venv.rst:542 msgid "" "The following script shows how to extend :class:`EnvBuilder` by implementing " "a subclass which installs setuptools and pip into a created virtual " @@ -968,7 +976,7 @@ msgstr "" "以下的腳本展示了如何透過實作子類別來擴充 :class:`EnvBuilder`,並在建立的虛擬" "環境中安裝 setuptools 與 pip: ::" -#: ../../library/venv.rst:543 +#: ../../library/venv.rst:545 msgid "" "import os\n" "import os.path\n" @@ -1387,17 +1395,17 @@ msgstr "" " print('Error: %s' % e, file=sys.stderr)\n" " sys.exit(rc)" -#: ../../library/venv.rst:751 +#: ../../library/venv.rst:753 msgid "" "This script is also available for download `online `_." msgstr "" "此腳本也可從\\ `線上 `_\\ 下載。" -#: ../../library/venv.rst:14 +#: ../../library/venv.rst:11 msgid "Environments" msgstr "Environments (環境)" -#: ../../library/venv.rst:14 +#: ../../library/venv.rst:11 msgid "virtual" msgstr "virtual (虛擬)" diff --git a/library/warnings.po b/library/warnings.po index ffae0bafa61..8fc0146b7db 100644 --- a/library/warnings.po +++ b/library/warnings.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-12 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -375,16 +375,18 @@ msgstr "只印出第一次出現的匹配警告,不論位置" msgid "" "*message* is a string containing a regular expression that the start of the " "warning message must match, case-insensitively. In :option:`-W` and :envvar:" -"`PYTHONWARNINGS`, *message* is a literal string that the start of the " -"warning message must contain (case-insensitively), ignoring any whitespace " -"at the start or end of *message*." +"`PYTHONWARNINGS`, if *message* starts and ends with a forward slash (``/``), " +"it specifies a regular expression as above; otherwise it is a literal string " +"that the start of the warning message must match (case-insensitively), " +"ignoring any whitespace at the start or end of *message*." msgstr "" "*message* 是一個包含正規表示式的字串,警告訊息的開頭必須與其匹配(不區分大小" -"寫)。在 :option:`-W` 和 :envvar:`PYTHONWARNINGS` 中,*message* 是一個字面字" -"串,警告訊息的開頭必須包含該字串(不區分大小寫),並忽略 *message* 開頭或結尾" -"的任何空白字元。" +"寫)。在 :option:`-W` 和 :envvar:`PYTHONWARNINGS` 中,如果 *message* 以正斜" +"線 (``/``) 開頭和結尾,它會指定一個如上所述的正規表示式;否則它是一個字面字" +"串,警告訊息的開頭必須與其匹配(不區分大小寫),並忽略 *message* 開頭或結尾的" +"任何空白字元。" -#: ../../library/warnings.rst:169 +#: ../../library/warnings.rst:171 msgid "" "*category* is a class (a subclass of :exc:`Warning`) of which the warning " "category must be a subclass in order to match." @@ -392,20 +394,22 @@ msgstr "" "*category* 是一個類別(:exc:`Warning` 的子類別),警告類別必須是它的子類別才" "能匹配。" -#: ../../library/warnings.rst:172 +#: ../../library/warnings.rst:174 msgid "" "*module* is a string containing a regular expression that the start of the " "fully qualified module name must match, case-sensitively. In :option:`-W` " -"and :envvar:`PYTHONWARNINGS`, *module* is a literal string that the fully " -"qualified module name must be equal to (case-sensitively), ignoring any " -"whitespace at the start or end of *module*." +"and :envvar:`PYTHONWARNINGS`, if *module* starts and ends with a forward " +"slash (``/``), it specifies a regular expression as above; otherwise it is a " +"literal string that the fully qualified module name must be equal to (case-" +"sensitively), ignoring any whitespace at the start or end of *module*." msgstr "" "*module* 是一個包含正規表示式的字串,完整限定模組名稱的開頭必須與其匹配(區分" -"大小寫)。在 :option:`-W` 和 :envvar:`PYTHONWARNINGS` 中,*module* 是一個字面" -"字串,完整限定模組名稱必須與其相等(區分大小寫),並忽略 *module* 開頭或結尾" -"的任何空白字元。" +"大小寫)。在 :option:`-W` 和 :envvar:`PYTHONWARNINGS` 中,如果 *module* 以正" +"斜線 (``/``) 開頭和結尾,它會指定一個如上所述的正規表示式;否則它是一個字面字" +"串,完整限定模組名稱必須與其相等(區分大小寫),並忽略 *module* 開頭或結尾的" +"任何空白字元。" -#: ../../library/warnings.rst:178 +#: ../../library/warnings.rst:182 msgid "" "*lineno* is an integer that the line number where the warning occurred must " "match, or ``0`` to match all line numbers." @@ -413,7 +417,7 @@ msgstr "" "*lineno* 是一個整數,發出警告的行號必須與其匹配,或者為 ``0`` 以匹配所有行" "號。" -#: ../../library/warnings.rst:181 +#: ../../library/warnings.rst:185 msgid "" "Since the :exc:`Warning` class is derived from the built-in :exc:`Exception` " "class, to turn a warning into an error we simply raise ``category(message)``." @@ -421,7 +425,7 @@ msgstr "" "由於 :exc:`Warning` 類別衍生自內建的 :exc:`Exception` 類別,要將警告轉為錯" "誤,我們只需引發 ``category(message)``。" -#: ../../library/warnings.rst:184 +#: ../../library/warnings.rst:188 msgid "" "If a warning is reported and doesn't match any registered filter then the " "\"default\" action is applied (hence its name)." @@ -429,17 +433,17 @@ msgstr "" "如果一個警告被回報且不匹配任何已註冊的過濾器,則會套用 \"default\" 動作(因此" "得名)。" -#: ../../library/warnings.rst:192 +#: ../../library/warnings.rst:196 msgid "Repeated Warning Suppression Criteria" msgstr "重複警告的抑制標準" -#: ../../library/warnings.rst:194 +#: ../../library/warnings.rst:198 msgid "" "The filters that suppress repeated warnings apply the following criteria to " "determine if a warning is considered a repeat:" msgstr "抑制重複警告的過濾器會套用以下標準來判斷一個警告是否被視為重複: ::" -#: ../../library/warnings.rst:196 +#: ../../library/warnings.rst:200 msgid "" "``\"default\"``: A warning is considered a repeat only if the (*message*, " "*category*, *module*, *lineno*) are all the same." @@ -447,7 +451,7 @@ msgstr "" "``\"default\"``:只有當 (*message*, *category*, *module*, *lineno*) 都相同" "時,警告才被視為重複。" -#: ../../library/warnings.rst:197 +#: ../../library/warnings.rst:201 msgid "" "``\"module\"``: A warning is considered a repeat if the (*message*, " "*category*, *module*) are the same, ignoring the line number." @@ -455,7 +459,7 @@ msgstr "" "``\"module\"``:如果 (*message*, *category*, *module*) 相同,則警告被視為重" "複,忽略行號。" -#: ../../library/warnings.rst:198 +#: ../../library/warnings.rst:202 msgid "" "``\"once\"``: A warning is considered a repeat if the (*message*, " "*category*) are the same, ignoring the module and line number." @@ -463,11 +467,11 @@ msgstr "" "``\"once\"``:如果 (*message*, *category*) 相同,則警告被視為重複,忽略模組和" "行號。" -#: ../../library/warnings.rst:204 +#: ../../library/warnings.rst:208 msgid "Describing Warning Filters" msgstr "描述警告過濾器" -#: ../../library/warnings.rst:206 +#: ../../library/warnings.rst:210 msgid "" "The warnings filter is initialized by :option:`-W` options passed to the " "Python interpreter command line and the :envvar:`PYTHONWARNINGS` environment " @@ -481,17 +485,17 @@ msgstr "" "在 :data:`sys.warnoptions` 中;:mod:`!warnings` 模組在首次引入時會剖析這些引" "數(無效選項會被忽略,並在向 :data:`sys.stderr` 印出一條訊息後)。" -#: ../../library/warnings.rst:213 +#: ../../library/warnings.rst:217 msgid "" "Individual warnings filters are specified as a sequence of fields separated " "by colons::" msgstr "個別的警告過濾器被指定為一系列由冒號分隔的欄位: ::" -#: ../../library/warnings.rst:216 +#: ../../library/warnings.rst:220 msgid "action:message:category:module:line" msgstr "action:message:category:module:line" -#: ../../library/warnings.rst:218 +#: ../../library/warnings.rst:222 msgid "" "The meaning of each of these fields is as described in :ref:`warning-" "filter`. When listing multiple filters on a single line (as for :envvar:" @@ -505,7 +509,7 @@ msgstr "" "出的過濾器優先於前面列出的過濾器(因為它們是從左到右應用的,而最近應用的過濾" "器優先於較早的過濾器)。" -#: ../../library/warnings.rst:225 +#: ../../library/warnings.rst:229 msgid "" "Commonly used warning filters apply to either all warnings, warnings in a " "particular category, or warnings raised by particular modules or packages. " @@ -514,7 +518,7 @@ msgstr "" "常用的警告過濾器適用於所有警告、特定類別的警告,或由特定模組或套件引發的警" "告。一些範例如下: ::" -#: ../../library/warnings.rst:229 +#: ../../library/warnings.rst:233 msgid "" "default # Show all warnings (even those ignored by " "default)\n" @@ -534,11 +538,11 @@ msgstr "" "ignore,default:::mymodule # 只回報由 \"mymodule\" 觸發的警告\n" "error:::mymodule # 將 \"mymodule\" 中的警告轉換為錯誤" -#: ../../library/warnings.rst:241 +#: ../../library/warnings.rst:245 msgid "Default Warning Filter" msgstr "預設警告過濾器" -#: ../../library/warnings.rst:243 +#: ../../library/warnings.rst:247 msgid "" "By default, Python installs several warning filters, which can be overridden " "by the :option:`-W` command-line option, the :envvar:`PYTHONWARNINGS` " @@ -548,13 +552,13 @@ msgstr "" "選項、:envvar:`PYTHONWARNINGS` 環境變數以及對 :func:`filterwarnings` 的呼叫所" "覆寫。" -#: ../../library/warnings.rst:247 +#: ../../library/warnings.rst:251 msgid "" "In regular release builds, the default warning filter has the following " "entries (in order of precedence)::" msgstr "在常規的發行建置中,預設的警告過濾器有以下條目(按優先順序排列): ::" -#: ../../library/warnings.rst:250 +#: ../../library/warnings.rst:254 msgid "" "default::DeprecationWarning:__main__\n" "ignore::DeprecationWarning\n" @@ -568,13 +572,13 @@ msgstr "" "ignore::ImportWarning\n" "ignore::ResourceWarning" -#: ../../library/warnings.rst:256 +#: ../../library/warnings.rst:260 msgid "" "In a :ref:`debug build `, the list of default warning filters " "is empty." msgstr "在 :ref:`偵錯建置 ` 中,預設警告過濾器串列是空的。" -#: ../../library/warnings.rst:258 +#: ../../library/warnings.rst:262 msgid "" ":exc:`DeprecationWarning` is now ignored by default in addition to :exc:" "`PendingDeprecationWarning`." @@ -582,7 +586,7 @@ msgstr "" "除了 :exc:`PendingDeprecationWarning` 之外,:exc:`DeprecationWarning` 現在也" "預設被忽略。" -#: ../../library/warnings.rst:262 +#: ../../library/warnings.rst:266 msgid "" ":exc:`DeprecationWarning` is once again shown by default when triggered " "directly by code in ``__main__``." @@ -590,7 +594,7 @@ msgstr "" "當直接由 ``__main__`` 中的程式碼觸發時,:exc:`DeprecationWarning` 會再次預設" "顯示。" -#: ../../library/warnings.rst:266 +#: ../../library/warnings.rst:270 msgid "" ":exc:`BytesWarning` no longer appears in the default filter list and is " "instead configured via :data:`sys.warnoptions` when :option:`-b` is " @@ -599,11 +603,11 @@ msgstr "" ":exc:`BytesWarning` 不再出現在預設過濾器串列中,而是在指定 :option:`-b` 兩次" "時,透過 :data:`sys.warnoptions` 進行設定。" -#: ../../library/warnings.rst:275 +#: ../../library/warnings.rst:279 msgid "Overriding the default filter" msgstr "覆寫預設過濾器" -#: ../../library/warnings.rst:277 +#: ../../library/warnings.rst:281 msgid "" "Developers of applications written in Python may wish to hide *all* Python " "level warnings from their users by default, and only display them when " @@ -617,7 +621,7 @@ msgstr "" "定傳遞給直譯器的 :data:`sys.warnoptions` 屬性可以用作一個標記,以指示是否應停" "用警告: ::" -#: ../../library/warnings.rst:283 +#: ../../library/warnings.rst:287 msgid "" "import sys\n" "\n" @@ -631,7 +635,7 @@ msgstr "" " import warnings\n" " warnings.simplefilter(\"ignore\")" -#: ../../library/warnings.rst:289 +#: ../../library/warnings.rst:293 msgid "" "Developers of test runners for Python code are advised to instead ensure " "that *all* warnings are displayed by default for the code under test, using " @@ -640,7 +644,7 @@ msgstr "" "建議 Python 程式碼的測試執行器開發者,應確保在預設情況下,為受測程式碼顯示 *" "所有* 警告,可使用如下程式碼: ::" -#: ../../library/warnings.rst:293 +#: ../../library/warnings.rst:297 msgid "" "import sys\n" "\n" @@ -656,7 +660,7 @@ msgstr "" " warnings.simplefilter(\"default\") # 在此行程中更改過濾器\n" " os.environ[\"PYTHONWARNINGS\"] = \"default\" # 也會影響子行程" -#: ../../library/warnings.rst:300 +#: ../../library/warnings.rst:304 msgid "" "Finally, developers of interactive shells that run user code in a namespace " "other than ``__main__`` are advised to ensure that :exc:`DeprecationWarning` " @@ -667,7 +671,7 @@ msgstr "" "者,應確保 :exc:`DeprecationWarning` 訊息預設為可見,可使用如下程式碼(其中 " "``user_ns`` 是用於執行互動式輸入程式碼的模組): ::" -#: ../../library/warnings.rst:305 +#: ../../library/warnings.rst:309 msgid "" "import warnings\n" "warnings.filterwarnings(\"default\", category=DeprecationWarning,\n" @@ -677,11 +681,11 @@ msgstr "" "warnings.filterwarnings(\"default\", category=DeprecationWarning,\n" " module=user_ns.get(\"__name__\"))" -#: ../../library/warnings.rst:313 +#: ../../library/warnings.rst:317 msgid "Temporarily Suppressing Warnings" msgstr "暫時抑制警告" -#: ../../library/warnings.rst:315 +#: ../../library/warnings.rst:319 msgid "" "If you are using code that you know will raise a warning, such as a " "deprecated function, but do not want to see the warning (even when warnings " @@ -692,7 +696,7 @@ msgstr "" "不想看到這個警告(即使警告已透過命令列明確設定),那麼可以使用 :class:" "`catch_warnings` 情境管理器來抑制該警告: ::" -#: ../../library/warnings.rst:320 +#: ../../library/warnings.rst:324 msgid "" "import warnings\n" "\n" @@ -712,7 +716,7 @@ msgstr "" " warnings.simplefilter(\"ignore\")\n" " fxn()" -#: ../../library/warnings.rst:329 +#: ../../library/warnings.rst:333 msgid "" "While within the context manager all warnings will simply be ignored. This " "allows you to use known-deprecated code without having to see the warning " @@ -723,19 +727,19 @@ msgstr "" "必看到警告,同時又不會抑制其他可能不知道自己正在使用已棄用程式碼的程式碼所發" "出的警告。" -#: ../../library/warnings.rst:336 ../../library/warnings.rst:378 -#: ../../library/warnings.rst:649 +#: ../../library/warnings.rst:340 ../../library/warnings.rst:382 +#: ../../library/warnings.rst:669 msgid "" "See :ref:`warning-concurrent-safe` for details on the concurrency-safety of " "the :class:`catch_warnings` context manager when used in programs using " "multiple threads or async functions." msgstr "" -#: ../../library/warnings.rst:343 +#: ../../library/warnings.rst:347 msgid "Testing Warnings" msgstr "測試警告" -#: ../../library/warnings.rst:345 +#: ../../library/warnings.rst:349 msgid "" "To test warnings raised by code, use the :class:`catch_warnings` context " "manager. With it you can temporarily mutate the warnings filter to " @@ -746,7 +750,7 @@ msgstr "" "可以暫時改變警告過濾器以方便你的測試。例如,執行以下操作來捕獲所有引發的警告" "以進行檢查: ::" -#: ../../library/warnings.rst:350 +#: ../../library/warnings.rst:354 msgid "" "import warnings\n" "\n" @@ -778,7 +782,7 @@ msgstr "" " assert issubclass(w[-1].category, DeprecationWarning)\n" " assert \"deprecated\" in str(w[-1].message)" -#: ../../library/warnings.rst:365 +#: ../../library/warnings.rst:369 msgid "" "One can also cause all warnings to be exceptions by using ``error`` instead " "of ``always``. One thing to be aware of is that if a warning has already " @@ -790,7 +794,7 @@ msgstr "" "是,如果一個警告因為 ``once``/``default`` 規則已經被引發過,那麼無論設定什麼" "過濾器,這個警告都不會再出現,除非與該警告相關的警告註冊表已被清除。" -#: ../../library/warnings.rst:371 +#: ../../library/warnings.rst:375 msgid "" "Once the context manager exits, the warnings filter is restored to its state " "when the context was entered. This prevents tests from changing the warnings " @@ -800,7 +804,7 @@ msgstr "" "一旦情境管理器退出,警告過濾器就會恢復到進入情境時的狀態。這可以防止測試在不" "同測試之間以意想不到的方式更改警告過濾器,從而導致不確定的測試結果。" -#: ../../library/warnings.rst:382 +#: ../../library/warnings.rst:386 msgid "" "When testing multiple operations that raise the same kind of warning, it is " "important to test them in a manner that confirms each operation is raising a " @@ -814,11 +818,11 @@ msgstr "" "警告串列的長度在每次操作後是否持續增加;或者在每次新操作前從警告串列中刪除先" "前的條目)。" -#: ../../library/warnings.rst:393 +#: ../../library/warnings.rst:397 msgid "Updating Code For New Versions of Dependencies" msgstr "為新版相依套件更新程式碼" -#: ../../library/warnings.rst:395 +#: ../../library/warnings.rst:399 msgid "" "Warning categories that are primarily of interest to Python developers " "(rather than end users of applications written in Python) are ignored by " @@ -827,7 +831,7 @@ msgstr "" "主要針對 Python 開發者(而非以 Python 編寫的應用程式的終端使用者)的警告類別" "預設會被忽略。" -#: ../../library/warnings.rst:398 +#: ../../library/warnings.rst:402 msgid "" "Notably, this \"ignored by default\" list includes :exc:`DeprecationWarning` " "(for every module except ``__main__``), which means developers should make " @@ -840,7 +844,7 @@ msgstr "" "通常被忽略的警告可見,以便及時收到未來 API 破壞性變更的通知(無論是在標準函式" "庫還是第三方套件中)。" -#: ../../library/warnings.rst:404 +#: ../../library/warnings.rst:408 msgid "" "In the ideal case, the code will have a suitable test suite, and the test " "runner will take care of implicitly enabling all warnings when running tests " @@ -849,7 +853,7 @@ msgstr "" "在理想情況下,程式碼會有一個合適的測試套件,而測試執行器會在執行測試時負責隱" "式地啟用所有警告(:mod:`unittest` 模組提供的測試執行器就是這樣做的)。" -#: ../../library/warnings.rst:408 +#: ../../library/warnings.rst:412 msgid "" "In less ideal cases, applications can be checked for use of deprecated " "interfaces by passing :option:`-Wd <-W>` to the Python interpreter (this is " @@ -867,11 +871,11 @@ msgstr "" "的引數(例如 :option:`!-W error`)。有關更多可能性的詳細資訊,請參閱 :option:" "`-W` 旗標。" -#: ../../library/warnings.rst:421 +#: ../../library/warnings.rst:425 msgid "Available Functions" msgstr "可用的函式" -#: ../../library/warnings.rst:426 +#: ../../library/warnings.rst:430 msgid "" "Issue a warning, or maybe ignore it or raise an exception. The *category* " "argument, if given, must be a :ref:`warning category class ` " +"will be tested against the module names constructed from the path components " +"starting from all parent directories (with ``/__init__.py``, ``.py`` and, on " +"Windows, ``.pyw`` stripped) and against the filename with ``.py`` stripped. " +"For example, when the filename is ``'/path/to/package/module.py'``, it will " +"be tested against ``'path.to.package.module'``, ``'to.package.module'`` " +"``'package.module'``, ``'module'``, and ``'/path/to/package/module'``." msgstr "" -#: ../../library/warnings.rst:491 +#: ../../library/warnings.rst:502 msgid "" "*registry*, if supplied, should be the ``__warningregistry__`` dictionary of " "the module. If no registry is passed, each warning is treated as the first " @@ -1005,7 +1015,7 @@ msgid "" "``\"once\"`` are handled as ``\"always\"``." msgstr "" -#: ../../library/warnings.rst:497 +#: ../../library/warnings.rst:508 msgid "" "*module_globals*, if supplied, should be the global namespace in use by the " "code for which the warning is issued. (This argument is used to support " @@ -1016,11 +1026,17 @@ msgstr "" "(此引數用於支援顯示在 zip 檔案或其他非檔案系統引入來源中找到的模組的原始" "碼)。" -#: ../../library/warnings.rst:505 +#: ../../library/warnings.rst:516 msgid "Add the *source* parameter." msgstr "新增 *source* 參數。" -#: ../../library/warnings.rst:511 +#: ../../library/warnings.rst:519 +msgid "" +"If no module is passed, test the filter regular expression against module " +"names created from the path, not only the path itself." +msgstr "" + +#: ../../library/warnings.rst:526 msgid "" "Write a warning to a file. The default implementation calls " "``formatwarning(message, category, filename, lineno, line)`` and writes the " @@ -1036,7 +1052,7 @@ msgstr "" "式。*line* 是要包含在警告訊息中的一行原始碼;如果未提供 *line*,:func:" "`showwarning` 將嘗試讀取由 *filename* 和 *lineno* 指定的行。" -#: ../../library/warnings.rst:522 +#: ../../library/warnings.rst:537 msgid "" "Format a warning the standard way. This returns a string which may contain " "embedded newlines and ends in a newline. *line* is a line of source code to " @@ -1048,7 +1064,7 @@ msgstr "" "*line* 是要包含在警告訊息中的一行原始碼;如果未提供 *line*,:func:" "`formatwarning` 將嘗試讀取由 *filename* 和 *lineno* 指定的行。" -#: ../../library/warnings.rst:531 +#: ../../library/warnings.rst:546 msgid "" "Insert an entry into the list of :ref:`warnings filter specifications " "`. The entry is inserted at the front by default; if " @@ -1065,7 +1081,7 @@ msgstr "" "濾器串列中。如果兩個條目都匹配一個特定的警告,那麼串列中較靠前的條目會覆寫較" "後面的條目。省略的引數預設為一個能匹配所有內容的值。" -#: ../../library/warnings.rst:543 +#: ../../library/warnings.rst:558 msgid "" "Insert a simple entry into the list of :ref:`warnings filter specifications " "`. The meaning of the function parameters is as for :func:" @@ -1077,7 +1093,7 @@ msgstr "" "的含義與 :func:`filterwarnings` 相同,但不需要正規表示式,因為只要類別和行號" "匹配,插入的過濾器總是會匹配任何模組中的任何訊息。" -#: ../../library/warnings.rst:552 +#: ../../library/warnings.rst:567 msgid "" "Reset the warnings filter. This discards the effect of all previous calls " "to :func:`filterwarnings`, including that of the :option:`-W` command line " @@ -1086,11 +1102,11 @@ msgstr "" "重設警告過濾器。這會捨棄所有先前對 :func:`filterwarnings` 的呼叫效果,包括 :" "option:`-W` 命令列選項和對 :func:`simplefilter` 的呼叫。" -#: ../../library/warnings.rst:559 +#: ../../library/warnings.rst:574 msgid "Decorator to indicate that a class, function or overload is deprecated." msgstr "用來指示一個類別、函式或重載 (overload) 已被棄用的裝飾器。" -#: ../../library/warnings.rst:561 +#: ../../library/warnings.rst:576 msgid "" "When this decorator is applied to an object, deprecation warnings may be " "emitted at runtime when the object is used. :term:`static type checkers " @@ -1101,11 +1117,11 @@ msgstr "" "term:`靜態型別檢查器 ` 也會在使用已棄用物件時產生診斷訊" "息。" -#: ../../library/warnings.rst:566 +#: ../../library/warnings.rst:581 msgid "Usage::" msgstr "用法: ::" -#: ../../library/warnings.rst:568 +#: ../../library/warnings.rst:583 msgid "" "from warnings import deprecated\n" "from typing import overload\n" @@ -1141,7 +1157,7 @@ msgstr "" "@overload\n" "def g(x: str) -> int: ..." -#: ../../library/warnings.rst:585 +#: ../../library/warnings.rst:600 msgid "" "The warning specified by *category* will be emitted at runtime on use of " "deprecated objects. For functions, that happens on calls; for classes, on " @@ -1159,7 +1175,7 @@ msgstr "" "疊的更上層發出。靜態型別檢查器的行為不受 *category* 和 *stacklevel* 引數的影" "響。" -#: ../../library/warnings.rst:596 +#: ../../library/warnings.rst:611 msgid "" "The deprecation message passed to the decorator is saved in the " "``__deprecated__`` attribute on the decorated object. If applied to an " @@ -1171,15 +1187,15 @@ msgstr "" "用於重載,裝飾器必須在 :deco:`~typing.overload` 裝飾器之後,這樣屬性才會存在" "於 :func:`typing.get_overloads` 回傳的重載上。" -#: ../../library/warnings.rst:603 +#: ../../library/warnings.rst:618 msgid "See :pep:`702`." msgstr "參閱 :pep:`702`。" -#: ../../library/warnings.rst:608 +#: ../../library/warnings.rst:623 msgid "Available Context Managers" msgstr "可用的情境管理器" -#: ../../library/warnings.rst:612 +#: ../../library/warnings.rst:627 msgid "" "A context manager that copies and, upon exit, restores the warnings filter " "and the :func:`showwarning` function. If the *record* argument is :const:" @@ -1195,47 +1211,57 @@ msgstr "" "訂的 :func:`showwarning` 函式(該函式也會抑制對 ``sys.stderr`` 的輸出)所看到" "的物件逐步填充。串列中的每個物件保證具有以下屬性:" -#: ../../library/warnings.rst:620 +#: ../../library/warnings.rst:635 msgid "``message``: the warning message (an instance of :exc:`Warning`)" msgstr "" -#: ../../library/warnings.rst:621 +#: ../../library/warnings.rst:636 msgid "``category``: the warning category (a subclass of :exc:`Warning`)" msgstr "" -#: ../../library/warnings.rst:622 +#: ../../library/warnings.rst:637 msgid "``filename``: the file name where the warning occurred (:class:`str`)" msgstr "" -#: ../../library/warnings.rst:623 +#: ../../library/warnings.rst:638 msgid "``lineno``: the line number in the file (:class:`int`)" msgstr "" -#: ../../library/warnings.rst:624 +#: ../../library/warnings.rst:639 msgid "``file``: the file object used for output (if any), or ``None``" msgstr "" -#: ../../library/warnings.rst:625 +#: ../../library/warnings.rst:640 msgid "``line``: the line of source code (if available), or ``None``" msgstr "" -#: ../../library/warnings.rst:626 +#: ../../library/warnings.rst:641 msgid "" "``source``: the original object that generated the warning (if available), " "or ``None``" msgstr "" -#: ../../library/warnings.rst:629 +#: ../../library/warnings.rst:643 +msgid "" +"``module``: the module name where the warning occurred (:class:`str`), or " +"``None``" +msgstr "" + +#: ../../library/warnings.rst:646 msgid "The ``source`` attribute was added." msgstr "" -#: ../../library/warnings.rst:632 +#: ../../library/warnings.rst:649 +msgid "The ``module`` attribute was added." +msgstr "" + +#: ../../library/warnings.rst:652 msgid "" "The type of these objects is not specified and may change; only the presence " "of these attributes is guaranteed." msgstr "" -#: ../../library/warnings.rst:635 +#: ../../library/warnings.rst:655 msgid "" "The *module* argument takes a module that will be used instead of the module " "returned when you import :mod:`!warnings` whose filter will be protected. " @@ -1245,7 +1271,7 @@ msgstr "" "*module* 引數接受一個模組,用以取代預設的 :mod:`!warnings` 模組,而該(被傳" "入)模組的過濾器將會受到保護。此引數主要用於測試 :mod:`!warnings` 模組本身。" -#: ../../library/warnings.rst:640 +#: ../../library/warnings.rst:660 msgid "" "If the *action* argument is not ``None``, the remaining arguments are passed " "to :func:`simplefilter` as if it were called immediately on entering the " @@ -1254,21 +1280,21 @@ msgstr "" "如果 *action* 引數不是 ``None``,則其餘引數會傳遞給 :func:`simplefilter`,就" "像在進入情境時立即呼叫它一樣。" -#: ../../library/warnings.rst:644 +#: ../../library/warnings.rst:664 msgid "" "See :ref:`warning-filter` for the meaning of the *category* and *lineno* " "parameters." msgstr "有關 *category* 和 *lineno* 參數的含義,請參閱 :ref:`warning-filter`。" -#: ../../library/warnings.rst:656 +#: ../../library/warnings.rst:676 msgid "Added the *action*, *category*, *lineno*, and *append* parameters." msgstr "新增 *action*、*category*、*lineno* 和 *append* 參數。" -#: ../../library/warnings.rst:662 +#: ../../library/warnings.rst:682 msgid "Concurrent safety of Context Managers" msgstr "情境管理器的並行安全性" -#: ../../library/warnings.rst:664 +#: ../../library/warnings.rst:684 msgid "" "The behavior of :class:`catch_warnings` context manager depends on the :data:" "`sys.flags.context_aware_warnings` flag. If the flag is true, the context " @@ -1279,7 +1305,7 @@ msgid "" "threaded builds and false otherwise." msgstr "" -#: ../../library/warnings.rst:672 +#: ../../library/warnings.rst:692 msgid "" "If the :data:`~sys.flags.context_aware_warnings` flag is false, then :class:" "`catch_warnings` will modify the global attributes of the :mod:`!warnings` " @@ -1289,7 +1315,7 @@ msgid "" "is undefined." msgstr "" -#: ../../library/warnings.rst:679 +#: ../../library/warnings.rst:699 msgid "" "If the flag is true, :class:`catch_warnings` will not modify global " "attributes and will instead use a :class:`~contextvars.ContextVar` to store " @@ -1298,7 +1324,7 @@ msgid "" "safe." msgstr "" -#: ../../library/warnings.rst:685 +#: ../../library/warnings.rst:705 msgid "" "The *record* parameter of the context handler also behaves differently " "depending on the value of the flag. When *record* is true and the flag is " @@ -1306,7 +1332,7 @@ msgid "" "module's :func:`showwarning` function. That is not concurrent-safe." msgstr "" -#: ../../library/warnings.rst:690 +#: ../../library/warnings.rst:710 msgid "" "When *record* is true and the flag is true, the :func:`showwarning` function " "is not replaced. Instead, the recording status is indicated by an internal " @@ -1314,14 +1340,14 @@ msgid "" "function will not be restored when exiting the context handler." msgstr "" -#: ../../library/warnings.rst:695 +#: ../../library/warnings.rst:715 msgid "" "The :data:`~sys.flags.context_aware_warnings` flag can be set the :option:`-" "X context_aware_warnings<-X>` command-line option or by the :envvar:" "`PYTHON_CONTEXT_AWARE_WARNINGS` environment variable." msgstr "" -#: ../../library/warnings.rst:701 +#: ../../library/warnings.rst:721 msgid "" "It is likely that most programs that desire thread-safe behaviour of the " "warnings module will also want to set the :data:`~sys.flags." @@ -1334,7 +1360,7 @@ msgid "" "`catch_warnings` context manager will no longer be active." msgstr "" -#: ../../library/warnings.rst:714 +#: ../../library/warnings.rst:734 msgid "" "Added the :data:`sys.flags.context_aware_warnings` flag and the use of a " "context variable for :class:`catch_warnings` if the flag is true. Previous " diff --git a/library/wave.po b/library/wave.po index 3b0240abcd9..c5c848b729e 100644 --- a/library/wave.po +++ b/library/wave.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-04 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:15+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,20 +21,23 @@ msgstr "" msgid ":mod:`!wave` --- Read and write WAV files" msgstr ":mod:`!wave` --- 讀寫 WAV 檔案" -#: ../../library/wave.rst:10 +#: ../../library/wave.rst:7 msgid "**Source code:** :source:`Lib/wave.py`" msgstr "**原始碼:**\\ :source:`Lib/wave.py`" -#: ../../library/wave.rst:14 +#: ../../library/wave.rst:11 msgid "" "The :mod:`!wave` module provides a convenient interface to the Waveform " -"Audio \"WAVE\" (or \"WAV\") file format. Only uncompressed PCM encoded wave " -"files are supported." +"Audio \"WAVE\" (or \"WAV\") file format." msgstr "" ":mod:`!wave` 模組為波形音訊檔案格式「WAVE」(或稱「WAV」)提供了便捷的介面。" -"僅支援未壓縮的 PCM 編碼波形檔。" -#: ../../library/wave.rst:20 +#: ../../library/wave.rst:14 +msgid "" +"The module supports uncompressed PCM and IEEE floating-point WAV formats." +msgstr "" + +#: ../../library/wave.rst:18 msgid "" "Support for ``WAVE_FORMAT_EXTENSIBLE`` headers was added, provided that the " "extended format is ``KSDATAFORMAT_SUBTYPE_PCM``." @@ -43,38 +46,44 @@ msgstr "" "``KSDATAFORMAT_SUBTYPE_PCM``。" #: ../../library/wave.rst:23 +msgid "" +"Support for reading and writing ``WAVE_FORMAT_IEEE_FLOAT`` files was added." +msgstr "" + +#: ../../library/wave.rst:25 msgid "The :mod:`!wave` module defines the following function and exception:" msgstr ":mod:`!wave` 模組定義了以下的函式和例外:" -#: ../../library/wave.rst:28 +#: ../../library/wave.rst:30 msgid "" -"If *file* is a string, open the file by that name, otherwise treat it as a " -"file-like object. *mode* can be:" +"If *file* is a string, a :term:`path-like object` or a :term:`bytes-like " +"object` open the file by that name, otherwise treat it as a file-like " +"object. *mode* can be:" msgstr "" -"如果 *file* 是一個字串,會打開對應名稱的檔案,否則會以類檔案物件處理。*mode* " -"可以是:" +"如果 *file* 是一個字串、:term:`path-like object` 或 :term:`bytes-like " +"object`,會打開對應名稱的檔案,否則會以類檔案物件處理。*mode* 可以是:" -#: ../../library/wave.rst:31 +#: ../../library/wave.rst:34 msgid "``'rb'``" msgstr "``'rb'``" -#: ../../library/wave.rst:32 +#: ../../library/wave.rst:35 msgid "Read only mode." msgstr "唯讀模式。" -#: ../../library/wave.rst:34 +#: ../../library/wave.rst:37 msgid "``'wb'``" msgstr "``'wb'``" -#: ../../library/wave.rst:35 +#: ../../library/wave.rst:38 msgid "Write only mode." msgstr "唯寫模式。" -#: ../../library/wave.rst:37 +#: ../../library/wave.rst:40 msgid "Note that it does not allow read/write WAV files." msgstr "請注意,不支援同時讀寫 WAV 檔案。" -#: ../../library/wave.rst:39 +#: ../../library/wave.rst:42 msgid "" "A *mode* of ``'rb'`` returns a :class:`Wave_read` object, while a *mode* of " "``'wb'`` returns a :class:`Wave_write` object. If *mode* is omitted and a " @@ -86,7 +95,7 @@ msgstr "" "案 (file-like) 物件作為 *file* 參數傳遞,則 ``file.mode`` 會是 *mode* 的預設" "值。" -#: ../../library/wave.rst:44 +#: ../../library/wave.rst:47 msgid "" "If you pass in a file-like object, the wave object will not close it when " "its ``close()`` method is called; it is the caller's responsibility to close " @@ -95,7 +104,7 @@ msgstr "" "如果你傳遞一個類檔案物件,當呼叫其 ``close()`` 方法時,wave 物件不會自動關閉" "該物件;關閉檔案物件的責任會在呼叫者上。" -#: ../../library/wave.rst:48 +#: ../../library/wave.rst:51 msgid "" "The :func:`.open` function may be used in a :keyword:`with` statement. When " "the :keyword:`!with` block completes, the :meth:`Wave_read.close` or :meth:" @@ -104,56 +113,84 @@ msgstr "" ":func:`.open` 函式可以在 :keyword:`with` 陳述式中使用。當 :keyword:`!with` 區" "塊完成時,會呼叫 :meth:`Wave_read.close` 或是 :meth:`Wave_write.close` 方法。" -#: ../../library/wave.rst:52 ../../library/wave.rst:184 +#: ../../library/wave.rst:55 ../../library/wave.rst:196 msgid "Added support for unseekable files." msgstr "增加對不可搜尋 (unseekable) 檔案的支援。" -#: ../../library/wave.rst:57 +#: ../../library/wave.rst:58 +msgid "" +"Added support for :term:`path-like objects ` and :term:" +"`bytes-like objects `." +msgstr "" + +#: ../../library/wave.rst:64 msgid "" "An error raised when something is impossible because it violates the WAV " "specification or hits an implementation deficiency." msgstr "當不符合 WAV 格式或無法操作時會引發錯誤。" -#: ../../library/wave.rst:64 +#: ../../library/wave.rst:70 +msgid "Format code for uncompressed PCM audio." +msgstr "" + +#: ../../library/wave.rst:75 +msgid "Format code for IEEE floating-point audio." +msgstr "" + +#: ../../library/wave.rst:80 +msgid "Format code for WAVE extensible headers." +msgstr "" + +#: ../../library/wave.rst:86 msgid "Wave_read Objects" msgstr "Wave_read 物件" -#: ../../library/wave.rst:68 +#: ../../library/wave.rst:90 msgid "Read a WAV file." msgstr "讀取一個 WAV 檔案。" -#: ../../library/wave.rst:70 +#: ../../library/wave.rst:92 msgid "" "Wave_read objects, as returned by :func:`.open`, have the following methods:" msgstr "由 :func:`.open` 回傳的 Wave_read 物件具有以下方法:" -#: ../../library/wave.rst:75 +#: ../../library/wave.rst:97 msgid "" "Close the stream if it was opened by :mod:`!wave`, and make the instance " "unusable. This is called automatically on object collection." msgstr "關閉 :mod:`!wave` 開啟的串流並使該實例無法使用。當物件回收時自動呼叫。" -#: ../../library/wave.rst:81 +#: ../../library/wave.rst:103 msgid "Returns number of audio channels (``1`` for mono, ``2`` for stereo)." msgstr "回傳音訊聲道的數量(單聲道為 ``1``,立體聲為 ``2``)。" -#: ../../library/wave.rst:86 +#: ../../library/wave.rst:108 msgid "Returns sample width in bytes." msgstr "回傳以位元組表示的取樣寬度 (sample width)。" -#: ../../library/wave.rst:91 +#: ../../library/wave.rst:113 msgid "Returns sampling frequency." msgstr "回傳取樣率。" -#: ../../library/wave.rst:96 +#: ../../library/wave.rst:118 msgid "Returns number of audio frames." msgstr "回傳音訊訊框數。" -#: ../../library/wave.rst:101 +#: ../../library/wave.rst:123 +msgid "Returns the frame format code." +msgstr "回傳訊框格式碼。" + +#: ../../library/wave.rst:125 +msgid "" +"This is one of :data:`WAVE_FORMAT_PCM`, :data:`WAVE_FORMAT_IEEE_FLOAT`, or :" +"data:`WAVE_FORMAT_EXTENSIBLE`." +msgstr "" + +#: ../../library/wave.rst:133 msgid "Returns compression type (``'NONE'`` is the only supported type)." msgstr "回傳壓縮類型(僅支援 ``'NONE'`` 類型)。" -#: ../../library/wave.rst:106 +#: ../../library/wave.rst:138 msgid "" "Human-readable version of :meth:`getcomptype`. Usually ``'not compressed'`` " "parallels ``'NONE'``." @@ -161,7 +198,7 @@ msgstr "" ":meth:`getcomptype` 的人類可讀的版本。通常使用 ``'not compressed'`` 代替 " "``'NONE'``。" -#: ../../library/wave.rst:112 +#: ../../library/wave.rst:144 msgid "" "Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth, " "framerate, nframes, comptype, compname)``, equivalent to output of the " @@ -170,39 +207,16 @@ msgstr "" "回傳一個 :func:`~collections.namedtuple` ``(nchannels, sampwidth, framerate, " "nframes, comptype, compname)``,等同於 ``get*()`` 方法的輸出。" -#: ../../library/wave.rst:119 +#: ../../library/wave.rst:151 msgid "" "Reads and returns at most *n* frames of audio, as a :class:`bytes` object." msgstr "讀取並回傳以 :class:`bytes` 物件表示的最多 *n* 個音訊訊框。" -#: ../../library/wave.rst:124 +#: ../../library/wave.rst:156 msgid "Rewind the file pointer to the beginning of the audio stream." msgstr "重置檔案指標至音訊流的開頭。" -#: ../../library/wave.rst:126 -msgid "" -"The following two methods are defined for compatibility with the old :mod:`!" -"aifc` module, and don't do anything interesting." -msgstr "" -"以下兩個方法是為了與舊的 :mod:`!aifc` 模組保持相容性,並不執行任何操作。" - -#: ../../library/wave.rst:132 -msgid "Returns ``None``." -msgstr "回傳 ``None``。" - -#: ../../library/wave.rst:134 ../../library/wave.rst:143 -msgid "" -"The method only existed for compatibility with the :mod:`!aifc` module which " -"has been removed in Python 3.13." -msgstr "" -"該方法是為了保持與 :mod:`!aifc` 模組相容性而留存,此模組已於 Python 3.13 中刪" -"除。" - -#: ../../library/wave.rst:141 -msgid "Raise an error." -msgstr "引發錯誤。" - -#: ../../library/wave.rst:147 +#: ../../library/wave.rst:159 msgid "" "The following two methods define a term \"position\" which is compatible " "between them, and is otherwise implementation dependent." @@ -210,27 +224,27 @@ msgstr "" "以下兩個方法所定義的「位置」,在它們之間是相容的,但其他情況下則取決於具體實" "作方式。" -#: ../../library/wave.rst:153 +#: ../../library/wave.rst:165 msgid "Set the file pointer to the specified position." msgstr "將檔案指標設定為指定的位置。" -#: ../../library/wave.rst:158 +#: ../../library/wave.rst:170 msgid "Return current file pointer position." msgstr "回傳目前的檔案指標位置。" -#: ../../library/wave.rst:164 +#: ../../library/wave.rst:176 msgid "Wave_write Objects" msgstr "Wave_write 物件" -#: ../../library/wave.rst:168 +#: ../../library/wave.rst:180 msgid "Write a WAV file." msgstr "寫入一個 WAV 檔案。" -#: ../../library/wave.rst:170 +#: ../../library/wave.rst:182 msgid "Wave_write objects, as returned by :func:`.open`." msgstr "Wave_write 物件,由 :func:`.open` 回傳。" -#: ../../library/wave.rst:172 +#: ../../library/wave.rst:184 msgid "" "For seekable output streams, the ``wave`` header will automatically be " "updated to reflect the number of frames actually written. For unseekable " @@ -251,11 +265,11 @@ msgstr "" "次性寫入所有的訊框資料。在後一種情況下,:meth:`writeframes` 方法將計算資料中的" "訊框數量,並在寫入訊框資料之前相應地設定 *nframes* 的值。" -#: ../../library/wave.rst:187 +#: ../../library/wave.rst:199 msgid "Wave_write objects have the following methods:" msgstr "Wave_write 物件具有以下方法:" -#: ../../library/wave.rst:191 +#: ../../library/wave.rst:203 msgid "" "Make sure *nframes* is correct, and close the file if it was opened by :mod:" "`!wave`. This method is called upon object collection. It will raise an " @@ -266,35 +280,41 @@ msgstr "" "在物件回收時被呼叫。如果輸出串流不可搜尋且 *nframes* 不符合實際寫入的訊框數,則" "會引發例外。" -#: ../../library/wave.rst:199 +#: ../../library/wave.rst:211 msgid "Set the number of channels." msgstr "設定音訊的通道數量。" -#: ../../library/wave.rst:204 +#: ../../library/wave.rst:216 msgid "Return the number of channels." msgstr "回傳音訊的通道數量。" -#: ../../library/wave.rst:209 +#: ../../library/wave.rst:221 msgid "Set the sample width to *n* bytes." msgstr "設定取樣寬度為 *n* 個位元組。" -#: ../../library/wave.rst:214 +#: ../../library/wave.rst:223 +msgid "" +"For :data:`WAVE_FORMAT_IEEE_FLOAT`, only 4-byte (32-bit) and 8-byte (64-bit) " +"sample widths are supported." +msgstr "" + +#: ../../library/wave.rst:229 msgid "Return the sample width in bytes." msgstr "回傳以位元組表示的取樣寬度 (sample width)。" -#: ../../library/wave.rst:219 +#: ../../library/wave.rst:234 msgid "Set the frame rate to *n*." msgstr "設定訊框速率為 *n*。" -#: ../../library/wave.rst:221 +#: ../../library/wave.rst:236 msgid "A non-integral input to this method is rounded to the nearest integer." msgstr "此方法的非整數輸入會被將四捨五入到最接近的整數。" -#: ../../library/wave.rst:228 +#: ../../library/wave.rst:243 msgid "Return the frame rate." msgstr "回傳訊框速率。" -#: ../../library/wave.rst:233 +#: ../../library/wave.rst:248 msgid "" "Set the number of frames to *n*. This will be changed later if the number " "of frames actually written is different (this update attempt will raise an " @@ -303,34 +323,64 @@ msgstr "" "設定訊框數為 *n*。如果實際寫入的訊框數不同,則稍後將進行更改(如果輸出串流不可搜" "尋,則此嘗試將引發錯誤)。" -#: ../../library/wave.rst:240 +#: ../../library/wave.rst:255 msgid "Return the number of audio frames written so far." msgstr "回傳目前為止已寫入的音訊訊框數。" -#: ../../library/wave.rst:245 +#: ../../library/wave.rst:260 msgid "" "Set the compression type and description. At the moment, only compression " "type ``NONE`` is supported, meaning no compression." msgstr "設定壓縮類型和描述。目前只支援壓縮類型為 ``NONE``,表示無壓縮。" -#: ../../library/wave.rst:251 +#: ../../library/wave.rst:266 msgid "Return the compression type (``'NONE'``)." msgstr "回傳壓縮類型(``'NONE'``)。" -#: ../../library/wave.rst:256 +#: ../../library/wave.rst:271 msgid "Return the human-readable compression type name." msgstr "回傳人類可讀的壓縮類型名稱。" -#: ../../library/wave.rst:261 +#: ../../library/wave.rst:276 +msgid "Set the frame format code." +msgstr "設定訊框格式碼。" + +#: ../../library/wave.rst:278 +msgid "" +"Supported values are :data:`WAVE_FORMAT_PCM` and :data:" +"`WAVE_FORMAT_IEEE_FLOAT`." +msgstr "" + +#: ../../library/wave.rst:281 +msgid "" +"When setting :data:`WAVE_FORMAT_IEEE_FLOAT`, the sample width must be 4 or 8 " +"bytes." +msgstr "" + +#: ../../library/wave.rst:287 +msgid "Return the current frame format code." +msgstr "回傳目前的訊框格式碼。" + +#: ../../library/wave.rst:294 msgid "" "The *tuple* should be ``(nchannels, sampwidth, framerate, nframes, comptype, " -"compname)``, with values valid for the ``set*()`` methods. Sets all " +"compname, format)``, with values valid for the ``set*()`` methods. Sets all " "parameters." msgstr "" "這個 *tuple* 應該是 ``(nchannels, sampwidth, framerate, nframes, comptype, " -"compname)``,值需要是符合 ``set*()`` 方法的參數。設定所有參數。" +"compname, format)``,值需要是符合 ``set*()`` 方法的參數。設定所有參數。" + +#: ../../library/wave.rst:298 +msgid "" +"For backwards compatibility, a 6-item tuple without *format* is also " +"accepted and defaults to :data:`WAVE_FORMAT_PCM`." +msgstr "" + +#: ../../library/wave.rst:301 +msgid "For ``format=WAVE_FORMAT_IEEE_FLOAT``, *sampwidth* must be 4 or 8." +msgstr "" -#: ../../library/wave.rst:268 +#: ../../library/wave.rst:306 msgid "" "Return a :func:`~collections.namedtuple` ``(nchannels, sampwidth, framerate, " "nframes, comptype, compname)`` containing the current output parameters." @@ -338,7 +388,7 @@ msgstr "" "回傳一個 :func:`~collections.namedtuple` ``(nchannels, sampwidth, framerate, " "nframes, comptype, compname)``,包含目前的輸出參數。" -#: ../../library/wave.rst:275 +#: ../../library/wave.rst:313 msgid "" "Return current position in the file, with the same disclaimer for the :meth:" "`Wave_read.tell` and :meth:`Wave_read.setpos` methods." @@ -346,15 +396,15 @@ msgstr "" "回傳檔案中的指標位置,其指標位置含意與 :meth:`Wave_read.tell` 和 :meth:" "`Wave_read.setpos` 是一致的。" -#: ../../library/wave.rst:281 +#: ../../library/wave.rst:319 msgid "Write audio frames, without correcting *nframes*." msgstr "寫入音訊訊框,不修正 *nframes*。" -#: ../../library/wave.rst:283 ../../library/wave.rst:294 +#: ../../library/wave.rst:321 ../../library/wave.rst:332 msgid "Any :term:`bytes-like object` is now accepted." msgstr "現在可接受任何 :term:`bytes-like object`。" -#: ../../library/wave.rst:289 +#: ../../library/wave.rst:327 msgid "" "Write audio frames and make sure *nframes* is correct. It will raise an " "error if the output stream is not seekable and the total number of frames " @@ -364,7 +414,7 @@ msgstr "" "寫入音訊訊框並確保 *nframes* 正確。如果輸出串流不可搜尋,並且在寫入 *data* 後已" "寫入的總訊框數與先前設定的 *nframes* 值不符,則會引發錯誤。" -#: ../../library/wave.rst:297 +#: ../../library/wave.rst:335 msgid "" "Note that it is invalid to set any parameters after calling :meth:" "`writeframes` or :meth:`writeframesraw`, and any attempt to do so will " @@ -372,3 +422,28 @@ msgid "" msgstr "" "注意在呼叫 :meth:`writeframes` 或 :meth:`writeframesraw` 之後設置任何參數都是" "無效的,任何嘗試這樣做的操作都會引發 :exc:`wave.Error`。" + +#: ../../library/wave.rst:339 +msgid "" +"For :data:`WAVE_FORMAT_IEEE_FLOAT` output, a ``fact`` chunk is written as " +"required by the WAVE specification for non-PCM formats." +msgstr "" + +#~ msgid "" +#~ "The following two methods are defined for compatibility with the old :mod:" +#~ "`!aifc` module, and don't do anything interesting." +#~ msgstr "" +#~ "以下兩個方法是為了與舊的 :mod:`!aifc` 模組保持相容性,並不執行任何操作。" + +#~ msgid "Returns ``None``." +#~ msgstr "回傳 ``None``。" + +#~ msgid "" +#~ "The method only existed for compatibility with the :mod:`!aifc` module " +#~ "which has been removed in Python 3.13." +#~ msgstr "" +#~ "該方法是為了保持與 :mod:`!aifc` 模組相容性而留存,此模組已於 Python 3.13 " +#~ "中刪除。" + +#~ msgid "Raise an error." +#~ msgstr "引發錯誤。" diff --git a/library/weakref.po b/library/weakref.po index eb41d58bd4d..caec26a3408 100644 --- a/library/weakref.po +++ b/library/weakref.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-04 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-05-22 20:58+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,24 +22,24 @@ msgstr "" msgid ":mod:`!weakref` --- Weak references" msgstr ":mod:`!weakref` --- 弱參照" -#: ../../library/weakref.rst:14 +#: ../../library/weakref.rst:9 msgid "**Source code:** :source:`Lib/weakref.py`" msgstr "**原始碼:**\\ :source:`Lib/weakref.py`" -#: ../../library/weakref.rst:18 +#: ../../library/weakref.rst:13 msgid "" "The :mod:`!weakref` module allows the Python programmer to create :dfn:`weak " "references` to objects." msgstr ":mod:`!weakref` 模組允許 Python 程式設計師建立對物件的 :dfn:`弱參照`。" -#: ../../library/weakref.rst:24 +#: ../../library/weakref.rst:19 msgid "" "In the following, the term :dfn:`referent` means the object which is " "referred to by a weak reference." msgstr "" "在以下文章中,術語 :dfn:`參照目標 (referent)` 表示被弱參照所參考的物件。" -#: ../../library/weakref.rst:27 +#: ../../library/weakref.rst:22 msgid "" "A weak reference to an object is not enough to keep the object alive: when " "the only remaining references to a referent are weak references, :term:" @@ -53,7 +53,7 @@ msgstr "" "途。然而,在物件被確實銷毀之前,即使沒有對該物件的強參照 (strong reference)," "弱參照也可能會回傳該物件。" -#: ../../library/weakref.rst:33 +#: ../../library/weakref.rst:28 msgid "" "A primary use for weak references is to implement caches or mappings holding " "large objects, where it's desired that a large object not be kept alive " @@ -62,7 +62,7 @@ msgstr "" "弱參照的主要用途是實作保存大型物件的快取或對映,其不希望大型物件僅僅因為它出" "現在快取或對映中而保持存在。" -#: ../../library/weakref.rst:37 +#: ../../library/weakref.rst:32 msgid "" "For example, if you have a number of large binary image objects, you may " "wish to associate a name with each. If you used a Python dictionary to map " @@ -87,7 +87,7 @@ msgstr "" "(weak mapping) 所持有的弱參照時,垃圾回收 (garbage collection) 可以回收該物" "件,且其對應的條目在弱對映中會被完全地刪除。" -#: ../../library/weakref.rst:50 +#: ../../library/weakref.rst:45 msgid "" ":class:`WeakKeyDictionary` and :class:`WeakValueDictionary` use weak " "references in their implementation, setting up callback functions on the " @@ -101,7 +101,7 @@ msgstr "" "`WeakSet` 實作了 :class:`set` 介面,但保留對其元素的弱參照,就像 :class:" "`WeakKeyDictionary` 一樣。" -#: ../../library/weakref.rst:57 +#: ../../library/weakref.rst:52 msgid "" ":class:`finalize` provides a straight forward way to register a cleanup " "function to be called when an object is garbage collected. This is simpler " @@ -113,7 +113,7 @@ msgstr "" "式。這比在原始弱參照上設定回呼函式更容易使用,因為模組在物件被回收前會自動確" "保最終化器 (finalizer) 保持存活。" -#: ../../library/weakref.rst:63 +#: ../../library/weakref.rst:58 msgid "" "Most programs should find that using one of these weak container types or :" "class:`finalize` is all they need -- it's not usually necessary to create " @@ -124,7 +124,7 @@ msgstr "" "需要直接建立自己的弱參照。低層級的機制由 :mod:`!weakref` 模組公開,以利於進階" "用途。" -#: ../../library/weakref.rst:68 +#: ../../library/weakref.rst:63 msgid "" "Not all objects can be weakly referenced. Objects which support weak " "references include class instances, functions written in Python (but not in " @@ -137,11 +137,11 @@ msgstr "" "`、:term:`產生器 `、類型物件、socket、陣列、雙向佇" "列、正規表示式模式物件和程式碼物件。" -#: ../../library/weakref.rst:74 +#: ../../library/weakref.rst:69 msgid "Added support for thread.lock, threading.Lock, and code objects." msgstr "新增了對 thread.lock、threading.Lock 和程式碼物件的支援。" -#: ../../library/weakref.rst:77 +#: ../../library/weakref.rst:72 msgid "" "Several built-in types such as :class:`list` and :class:`dict` do not " "directly support weak references but can add support through subclassing::" @@ -149,7 +149,7 @@ msgstr "" "一些內建型別,例如 :class:`list` 和 :class:`dict` 不直接支援弱參照,但可以透" "過子類別化來支援: ::" -#: ../../library/weakref.rst:80 +#: ../../library/weakref.rst:75 msgid "" "class Dict(dict):\n" " pass\n" @@ -161,7 +161,7 @@ msgstr "" "\n" "obj = Dict(red=1, green=2, blue=3) # 這個物件是可被弱參照的" -#: ../../library/weakref.rst:87 +#: ../../library/weakref.rst:82 msgid "" "Other built-in types such as :class:`tuple` and :class:`int` do not support " "weak references even when subclassed." @@ -169,7 +169,7 @@ msgstr "" "其他內建型別,例如 :class:`tuple` 和 :class:`int` 即使在子類別化時也不支援弱" "參照。" -#: ../../library/weakref.rst:90 +#: ../../library/weakref.rst:85 msgid "" "Extension types can easily be made to support weak references; see :ref:" "`weakref-support`." @@ -177,7 +177,7 @@ msgstr "" "擴充型別 (extension type) 可以輕易地支援弱參照;請參閱 :ref:`weakref-" "support`。" -#: ../../library/weakref.rst:93 +#: ../../library/weakref.rst:88 msgid "" "When ``__slots__`` are defined for a given type, weak reference support is " "disabled unless a ``'__weakref__'`` string is also present in the sequence " @@ -188,7 +188,7 @@ msgstr "" "``'__weakref__'`` 字串也存在於 ``__slots__`` 宣告的字串序列中。詳情請參閱 :" "ref:`__slots__ 文件 `。" -#: ../../library/weakref.rst:100 +#: ../../library/weakref.rst:95 msgid "" "Return a weak reference to *object*. The original object can be retrieved " "by calling the reference object if the referent is still alive; if the " @@ -205,7 +205,7 @@ msgstr "" "被最終化 (finalize) 時,回呼將被呼叫;弱參照物件將作為唯一的參數傳遞給回呼;" "參照物件將不再可用。" -#: ../../library/weakref.rst:108 +#: ../../library/weakref.rst:103 msgid "" "It is allowable for many weak references to be constructed for the same " "object. Callbacks registered for each weak reference will be called from the " @@ -214,7 +214,7 @@ msgstr "" "為同一個物件建構多個弱參照是可行的。為每個弱參照註冊的回呼將按照最新到最舊註" "冊的回呼順序來被呼叫。" -#: ../../library/weakref.rst:112 +#: ../../library/weakref.rst:107 msgid "" "Exceptions raised by the callback will be noted on the standard error " "output, but cannot be propagated; they are handled in exactly the same way " @@ -223,7 +223,7 @@ msgstr "" "回呼引發的例外將在標準錯誤輸出中被註明,但無法被傳播;它們的處理方式與物件" "的 :meth:`~object.__del__` 方法引發的例外完全相同。" -#: ../../library/weakref.rst:116 +#: ../../library/weakref.rst:111 msgid "" "Weak references are :term:`hashable` if the *object* is hashable. They will " "maintain their hash value even after the *object* was deleted. If :func:" @@ -234,7 +234,7 @@ msgstr "" "在 *object* 被刪除後,它們仍將保留其雜湊值。如果僅在 *object* 刪除後才第一次" "呼叫 :func:`hash`,則該呼叫將引發 :exc:`TypeError`。" -#: ../../library/weakref.rst:121 +#: ../../library/weakref.rst:116 msgid "" "Weak references support tests for equality, but not ordering. If the " "referents are still alive, two references have the same equality " @@ -246,17 +246,17 @@ msgstr "" "目標具有相同的相等關係(無論 *callback* 如何)。如果任一參照目標已被刪除,則" "僅當參照物件是同一物件時,參照才相等。" -#: ../../library/weakref.rst:126 +#: ../../library/weakref.rst:121 msgid "This is a subclassable type rather than a factory function." msgstr "這是一個可子類別化的型別,而不是一個工廠函式。" -#: ../../library/weakref.rst:128 +#: ../../library/weakref.rst:123 msgid "" "Weak references are :ref:`generic ` over the type of the object " "they reference." msgstr "" -#: ../../library/weakref.rst:133 +#: ../../library/weakref.rst:128 msgid "" "This read-only attribute returns the callback currently associated to the " "weakref. If there is no callback or if the referent of the weakref is no " @@ -265,11 +265,11 @@ msgstr "" "此唯讀屬性回傳目前與弱參照關聯的回呼。如果沒有回呼或弱參照的參照目標已不存" "活,那麼該屬性的值為 ``None``。" -#: ../../library/weakref.rst:137 +#: ../../library/weakref.rst:132 msgid "Added the :attr:`__callback__` attribute." msgstr "新增 :attr:`__callback__` 屬性。" -#: ../../library/weakref.rst:143 +#: ../../library/weakref.rst:138 msgid "" "Return a proxy to *object* which uses a weak reference. This supports use " "of the proxy in most contexts instead of requiring the explicit " @@ -288,30 +288,30 @@ msgstr "" "多問題,並阻止它們作為字典的鍵被使用。*callback* 與 :func:`ref` 函式的同名參" "數是相同的。" -#: ../../library/weakref.rst:152 +#: ../../library/weakref.rst:147 msgid "" "Accessing an attribute of the proxy object after the referent is garbage " "collected raises :exc:`ReferenceError`." msgstr "在參照目標被垃圾回收後存取代理物件的屬性會引發 :exc:`ReferenceError`。" -#: ../../library/weakref.rst:155 +#: ../../library/weakref.rst:150 msgid "" "Extended the operator support on proxy objects to include the matrix " "multiplication operators ``@`` and ``@=``." msgstr "提供對代理物件的運算子支援,以包括矩陣乘法運算子 ``@`` 和 ``@=``。" -#: ../../library/weakref.rst:162 +#: ../../library/weakref.rst:157 msgid "" "Return the number of weak references and proxies which refer to *object*." msgstr "回傳參照 *object* 的弱參照和代理的數量。" -#: ../../library/weakref.rst:167 +#: ../../library/weakref.rst:162 msgid "" "Return a list of all weak reference and proxy objects which refer to " "*object*." msgstr "回傳參照 *object* 的所有弱參照和代理物件的一個串列。" -#: ../../library/weakref.rst:172 +#: ../../library/weakref.rst:167 msgid "" "Mapping class that references keys weakly. Entries in the dictionary will " "be discarded when there is no longer a strong reference to the key. This " @@ -323,7 +323,7 @@ msgstr "" "附加資料與應用程式其他部分擁有的物件相關聯,而無需向這些物件新增屬性。這對於" "覆蓋屬性存取的物件特別有用。" -#: ../../library/weakref.rst:178 +#: ../../library/weakref.rst:173 msgid "" "Note that when a key with equal value to an existing key (but not equal " "identity) is inserted into the dictionary, it replaces the value but does " @@ -334,7 +334,7 @@ msgstr "" "值,但不會替換現有鍵。因此,當刪除對原始鍵的參照時,它也會刪除字典中的條" "目: ::" -#: ../../library/weakref.rst:183 +#: ../../library/weakref.rst:178 msgid "" ">>> class T(str): pass\n" "...\n" @@ -352,11 +352,11 @@ msgstr "" ">>> d[k2] = 2 # d = {k1: 2}\n" ">>> del k1 # d = {}" -#: ../../library/weakref.rst:191 +#: ../../library/weakref.rst:186 msgid "A workaround would be to remove the key prior to reassignment::" msgstr "一個變通的解法是在重新賦值 (reassignment) 之前刪除鍵: ::" -#: ../../library/weakref.rst:193 +#: ../../library/weakref.rst:188 msgid "" ">>> class T(str): pass\n" "...\n" @@ -376,12 +376,12 @@ msgstr "" ">>> d[k2] = 2 # d = {k2: 2}\n" ">>> del k1 # d = {k2: 2}" -#: ../../library/weakref.rst:202 ../../library/weakref.rst:223 +#: ../../library/weakref.rst:197 ../../library/weakref.rst:218 msgid "" "Added support for ``|`` and ``|=`` operators, as specified in :pep:`584`." msgstr "新增對 ``|`` 和 ``|=`` 運算子的支援,如 :pep:`584` 中所說明。" -#: ../../library/weakref.rst:205 +#: ../../library/weakref.rst:200 msgid "" ":class:`WeakKeyDictionary` objects have an additional method that exposes " "the internal references directly. The references are not guaranteed to be " @@ -394,17 +394,17 @@ msgstr "" "時不保證是 \"存活的\",因此在使用之前需要檢查呼叫參照的結果。這可以用來防止建" "立會導致垃圾回收器保留鍵的時間超過其所需時間的參照。" -#: ../../library/weakref.rst:215 +#: ../../library/weakref.rst:210 msgid "Return an iterable of the weak references to the keys." msgstr "回傳對鍵的弱參照的可疊代物件。" -#: ../../library/weakref.rst:220 +#: ../../library/weakref.rst:215 msgid "" "Mapping class that references values weakly. Entries in the dictionary will " "be discarded when no strong reference to the value exists any more." msgstr "弱參照值的對映類別。當不再存在對值的強參照時,字典中的條目將被丟棄。" -#: ../../library/weakref.rst:226 +#: ../../library/weakref.rst:221 msgid "" ":class:`WeakValueDictionary` objects have an additional method that has the " "same issues as the :meth:`WeakKeyDictionary.keyrefs` method." @@ -412,11 +412,11 @@ msgstr "" ":class:`WeakValueDictionary` 物件有一個附加方法,它與 :meth:" "`WeakKeyDictionary.keyrefs` 方法有相同的問題。" -#: ../../library/weakref.rst:232 +#: ../../library/weakref.rst:227 msgid "Return an iterable of the weak references to the values." msgstr "回傳對值的弱參照的可疊代物件。" -#: ../../library/weakref.rst:237 +#: ../../library/weakref.rst:232 msgid "" "Set class that keeps weak references to its elements. An element will be " "discarded when no strong reference to it exists any more." @@ -424,7 +424,7 @@ msgstr "" "保留對其元素的弱參照的集合類別。當不再存在對某個元素的強參照時,該元素將被丟" "棄。" -#: ../../library/weakref.rst:243 +#: ../../library/weakref.rst:238 msgid "" "A custom :class:`ref` subclass which simulates a weak reference to a bound " "method (i.e., a method defined on a class and looked up on an instance). " @@ -437,7 +437,7 @@ msgstr "" "無法保留它。:class:`WeakMethod` 有特殊的程式碼來重新建立繫結方法,直到物件或" "原始函式死亡: ::" -#: ../../library/weakref.rst:249 +#: ../../library/weakref.rst:244 msgid "" ">>> class C:\n" "... def method(self):\n" @@ -475,13 +475,13 @@ msgstr "" ">>> r()\n" ">>>" -#: ../../library/weakref.rst:267 +#: ../../library/weakref.rst:262 msgid "" "*callback* is the same as the parameter of the same name to the :func:`ref` " "function." msgstr "*callback* 與 :func:`ref` 函式的同名參數是相同的。" -#: ../../library/weakref.rst:273 +#: ../../library/weakref.rst:268 msgid "" "Return a callable finalizer object which will be called when *obj* is " "garbage collected. Unlike an ordinary weak reference, a finalizer will " @@ -492,7 +492,7 @@ msgstr "" "不同,最終化器將始終存在,直到參照物件被回收為止,從而大大簡化了生命週期管" "理。" -#: ../../library/weakref.rst:278 +#: ../../library/weakref.rst:273 msgid "" "A finalizer is considered *alive* until it is called (either explicitly or " "at garbage collection), and after that it is *dead*. Calling a live " @@ -503,7 +503,7 @@ msgstr "" "死亡*。呼叫存活的最終化器會回傳 ``func(*arg, **kwargs)`` 的計算結果,而呼叫死" "亡的最終化器會回傳 :const:`None`。" -#: ../../library/weakref.rst:283 +#: ../../library/weakref.rst:278 msgid "" "Exceptions raised by finalizer callbacks during garbage collection will be " "shown on the standard error output, but cannot be propagated. They are " @@ -513,7 +513,7 @@ msgstr "" "垃圾回收期間最終化器回呼引發的例外會在標準錯誤輸出中顯示,但無法傳播。它們的" "處理方式與從物件的 :meth:`~object.__del__` 方法或弱參照的回呼引發的例外相同。" -#: ../../library/weakref.rst:289 +#: ../../library/weakref.rst:284 msgid "" "When the program exits (or more generally, at :term:`interpreter shutdown`), " "each remaining live finalizer is called unless its :attr:`atexit` attribute " @@ -523,7 +523,7 @@ msgstr "" "時),除非最終化器的 :attr:`atexit` 屬性已被設定為 false,否則每個剩餘且仍存" "活的最終化器都會被呼叫。它們以與建立相反的順序被呼叫。" -#: ../../library/weakref.rst:294 +#: ../../library/weakref.rst:289 msgid "" "A finalizer will never invoke its callback during the later part of the :" "term:`interpreter shutdown` when module globals are liable to have been " @@ -532,7 +532,7 @@ msgstr "" "當模組的 globals 可能被 :const:`None` 取代時,最終化器永遠不會在 :term:" "`interpreter shutdown` 的後期叫用(invoke)其回呼。" -#: ../../library/weakref.rst:300 +#: ../../library/weakref.rst:295 msgid "" "If *self* is alive then mark it as dead and return the result of calling " "``func(*args, **kwargs)``. If *self* is dead then return :const:`None`." @@ -540,7 +540,7 @@ msgstr "" "如果 *self* 仍存活,則將其標記為死亡並回傳呼叫 ``func(*args, **kwargs)`` 的結" "果。如果 *self* 已死亡,則回傳 :const:`None`。" -#: ../../library/weakref.rst:306 +#: ../../library/weakref.rst:301 msgid "" "If *self* is alive then mark it as dead and return the tuple ``(obj, func, " "args, kwargs)``. If *self* is dead then return :const:`None`." @@ -548,7 +548,7 @@ msgstr "" "如果 *self* 仍存活,則將其標記為死亡並回傳元組 ``(obj, func, args, " "kwargs)``。如果 *self* 已死亡,則回傳 :const:`None`。" -#: ../../library/weakref.rst:312 +#: ../../library/weakref.rst:307 msgid "" "If *self* is alive then return the tuple ``(obj, func, args, kwargs)``. If " "*self* is dead then return :const:`None`." @@ -556,11 +556,11 @@ msgstr "" "如果 *self* 仍存活,則回傳元組 ``(obj, func, args, kwargs)``。如果 *self* 已" "死亡,則回傳 :const:`None`。" -#: ../../library/weakref.rst:317 +#: ../../library/weakref.rst:312 msgid "Property which is true if the finalizer is alive, false otherwise." msgstr "如果最終化器仍存活,則屬性為 true,否則為 false。" -#: ../../library/weakref.rst:321 +#: ../../library/weakref.rst:316 msgid "" "A writable boolean property which by default is true. At :term:`interpreter " "shutdown`, all remaining live finalizers for which :attr:`.atexit` is true " @@ -570,7 +570,7 @@ msgstr "" "shutdown>`\\ 時,所有 :attr:`.atexit` 為 true 的剩餘且仍存活的最終化器會以與" "建立相反的順序被呼叫。" -#: ../../library/weakref.rst:328 +#: ../../library/weakref.rst:323 msgid "" "It is important to ensure that *func*, *args* and *kwargs* do not own any " "references to *obj*, either directly or indirectly, since otherwise *obj* " @@ -580,19 +580,19 @@ msgstr "" "確保 *func*、*args* 和 *kwargs* 不直接或間接擁有對 *obj* 的任何參照非常重要," "否則 *obj* 將永遠不會被垃圾回收。尤其 *func* 不應該是 *obj* 的繫結方法。" -#: ../../library/weakref.rst:338 +#: ../../library/weakref.rst:333 msgid "The type object for weak references objects." msgstr "弱參照物件的型別物件。" -#: ../../library/weakref.rst:343 +#: ../../library/weakref.rst:338 msgid "The type object for proxies of objects which are not callable." msgstr "非可呼叫物件的代理的型別物件。" -#: ../../library/weakref.rst:348 +#: ../../library/weakref.rst:343 msgid "The type object for proxies of callable objects." msgstr "可呼叫物件的代理的型別物件。" -#: ../../library/weakref.rst:353 +#: ../../library/weakref.rst:348 msgid "" "Sequence containing all the type objects for proxies. This can make it " "simpler to test if an object is a proxy without being dependent on naming " @@ -601,21 +601,21 @@ msgstr "" "包含代理的所有型別物件的序列。這可以讓測試物件是否為代理變得更簡單,而無需依" "賴命名兩種代理型別。" -#: ../../library/weakref.rst:360 +#: ../../library/weakref.rst:355 msgid ":pep:`205` - Weak References" msgstr ":pep:`205` - 弱參照" -#: ../../library/weakref.rst:361 +#: ../../library/weakref.rst:356 msgid "" "The proposal and rationale for this feature, including links to earlier " "implementations and information about similar features in other languages." msgstr "此功能的提案和理由,包括早期實作的連結以及其他語言中類似功能的資訊。" -#: ../../library/weakref.rst:368 +#: ../../library/weakref.rst:363 msgid "Weak Reference Objects" msgstr "弱參照物件" -#: ../../library/weakref.rst:370 +#: ../../library/weakref.rst:365 msgid "" "Weak reference objects have no methods and no attributes besides :attr:`ref." "__callback__`. A weak reference object allows the referent to be obtained, " @@ -624,13 +624,13 @@ msgstr "" "弱參照物件除了 :attr:`ref.__callback__` 之外沒有任何方法和屬性。弱參照物件允" "許透過呼叫來取得參照目標(如果它仍然存在):" -#: ../../library/weakref.rst:384 +#: ../../library/weakref.rst:379 msgid "" "If the referent no longer exists, calling the reference object returns :" "const:`None`:" msgstr "如果參照目標不再存活,則呼叫參照物件將回傳 :const:`None`:" -#: ../../library/weakref.rst:391 +#: ../../library/weakref.rst:386 msgid "" "Testing that a weak reference object is still live should be done using the " "expression ``ref() is not None``. Normally, application code that needs to " @@ -639,7 +639,7 @@ msgstr "" "應該使用運算式 ``ref() is not None`` 來測試弱參照物件是否仍然存活。需要使用參" "照物件的應用程式程式碼通常應遵循以下模式: ::" -#: ../../library/weakref.rst:395 +#: ../../library/weakref.rst:390 msgid "" "# r is a weak reference object\n" "o = r()\n" @@ -651,7 +651,7 @@ msgid "" " o.do_something_useful()" msgstr "" -#: ../../library/weakref.rst:404 +#: ../../library/weakref.rst:399 msgid "" "Using a separate test for \"liveness\" creates race conditions in threaded " "applications; another thread can cause a weak reference to become " @@ -662,7 +662,7 @@ msgstr "" "condition);另一個執行緒可能在弱參照被呼叫之前讓該弱參照失效;上方顯示的慣用" "作法在執行緒應用程式和單執行緒應用程式中都是安全的。" -#: ../../library/weakref.rst:409 +#: ../../library/weakref.rst:404 msgid "" "Specialized versions of :class:`ref` objects can be created through " "subclassing. This is used in the implementation of the :class:" @@ -676,7 +676,7 @@ msgstr "" "於將附加資訊與參照相關聯最有用,但也可用於在呼叫上插入附加處理以檢索參照目" "標。" -#: ../../library/weakref.rst:415 +#: ../../library/weakref.rst:410 msgid "" "This example shows how a subclass of :class:`ref` can be used to store " "additional information about an object and affect the value that's returned " @@ -685,7 +685,7 @@ msgstr "" "這個範例展示如何使用 :class:`ref` 的子類別來儲存有關物件的附加資訊並影響存取" "參照目標時回傳的值: ::" -#: ../../library/weakref.rst:419 +#: ../../library/weakref.rst:414 msgid "" "import weakref\n" "\n" @@ -707,11 +707,11 @@ msgid "" " return ob" msgstr "" -#: ../../library/weakref.rst:442 +#: ../../library/weakref.rst:437 msgid "Example" msgstr "範例" -#: ../../library/weakref.rst:444 +#: ../../library/weakref.rst:439 msgid "" "This simple example shows how an application can use object IDs to retrieve " "objects that it has seen before. The IDs of the objects can then be used in " @@ -722,7 +722,7 @@ msgstr "" "ID 之後可以在其他資料結構中使用,而不必強制物件保持存活,但如果這樣做,仍然可" "以透過 ID 檢索物件。" -#: ../../library/weakref.rst:453 +#: ../../library/weakref.rst:448 msgid "" "import weakref\n" "\n" @@ -748,11 +748,11 @@ msgstr "" "def id2obj(oid):\n" " return _id2obj_dict[oid]" -#: ../../library/weakref.rst:469 +#: ../../library/weakref.rst:464 msgid "Finalizer Objects" msgstr "最終化器物件" -#: ../../library/weakref.rst:471 +#: ../../library/weakref.rst:466 msgid "" "The main benefit of using :class:`finalize` is that it makes it simple to " "register a callback without needing to preserve the returned finalizer " @@ -761,13 +761,13 @@ msgstr "" "使用 :class:`finalize` 的最大優點是可以輕鬆註冊回呼,而無需保留回傳的最終化器" "物件。例如" -#: ../../library/weakref.rst:485 +#: ../../library/weakref.rst:480 msgid "" "The finalizer can be called directly as well. However the finalizer will " "invoke the callback at most once." msgstr "最終化器也可以直接被呼叫。然而,最終化器最多會叫用回呼一次。" -#: ../../library/weakref.rst:501 +#: ../../library/weakref.rst:496 msgid "" "You can unregister a finalizer using its :meth:`~finalize.detach` method. " "This kills the finalizer and returns the arguments passed to the constructor " @@ -776,7 +776,7 @@ msgstr "" "你可以使用最終化器的 :meth:`~finalize.detach` 方法來取消註冊最終化器。這會殺" "死最終化器並回傳建立建構函式時傳遞給建構函式的引數。" -#: ../../library/weakref.rst:515 +#: ../../library/weakref.rst:510 msgid "" "Unless you set the :attr:`~finalize.atexit` attribute to :const:`False`, a " "finalizer will be called when the program exits if it is still alive. For " @@ -785,7 +785,7 @@ msgstr "" "除非你將 :attr:`~finalize.atexit` 屬性設為 :const:`False`,否則當程式結束時," "最終化器將會被呼叫如果其仍然存在。例如" -#: ../../library/weakref.rst:519 +#: ../../library/weakref.rst:514 msgid "" ">>> obj = Object()\n" ">>> weakref.finalize(obj, print, \"obj dead or exiting\")\n" @@ -799,11 +799,11 @@ msgstr "" ">>> exit()\n" "obj dead or exiting" -#: ../../library/weakref.rst:530 +#: ../../library/weakref.rst:525 msgid "Comparing finalizers with :meth:`~object.__del__` methods" msgstr "最終化器與 :meth:`~object.__del__` 方法的比較" -#: ../../library/weakref.rst:532 +#: ../../library/weakref.rst:527 msgid "" "Suppose we want to create a class whose instances represent temporary " "directories. The directories should be deleted with their contents when the " @@ -812,26 +812,26 @@ msgstr "" "假設我們要建立一個類別,其實例代表臨時目錄。當以下任一事件發生時,應刪除目錄" "及其內容:" -#: ../../library/weakref.rst:536 +#: ../../library/weakref.rst:531 msgid "the object is garbage collected," msgstr "該物件被垃圾回收," -#: ../../library/weakref.rst:537 +#: ../../library/weakref.rst:532 msgid "the object's :meth:`!remove` method is called, or" msgstr "該物件的 :meth:`!remove` 方法被呼叫,或者" -#: ../../library/weakref.rst:538 +#: ../../library/weakref.rst:533 msgid "the program exits." msgstr "程式結束。" -#: ../../library/weakref.rst:540 +#: ../../library/weakref.rst:535 msgid "" "We might try to implement the class using a :meth:`~object.__del__` method " "as follows::" msgstr "" "我們可以用以下的方式來嘗試使用 :meth:`~object.__del__` 方法實作該類別: ::" -#: ../../library/weakref.rst:543 +#: ../../library/weakref.rst:538 msgid "" "class TempDir:\n" " def __init__(self):\n" @@ -865,7 +865,7 @@ msgstr "" " def __del__(self):\n" " self.remove()" -#: ../../library/weakref.rst:559 +#: ../../library/weakref.rst:554 msgid "" "Starting with Python 3.4, :meth:`~object.__del__` methods no longer prevent " "reference cycles from being garbage collected, and module globals are no " @@ -876,7 +876,7 @@ msgstr "" "cycle) 被垃圾回收,並且在 :term:`interpreter shutdown` 期間不再強制將模組的 " "globals 設為 :const:`None`。所以這段程式碼在 CPython 上應該可以正常運作。" -#: ../../library/weakref.rst:564 +#: ../../library/weakref.rst:559 msgid "" "However, handling of :meth:`~object.__del__` methods is notoriously " "implementation specific, since it depends on internal details of the " @@ -885,7 +885,7 @@ msgstr "" "然而,眾所周知,對 :meth:`~object.__del__` 方法的處理是特地實作的,因為它依賴" "於直譯器的垃圾回收器實作的內部細節。" -#: ../../library/weakref.rst:568 +#: ../../library/weakref.rst:563 msgid "" "A more robust alternative can be to define a finalizer which only references " "the specific functions and objects that it needs, rather than having access " @@ -894,7 +894,7 @@ msgstr "" "更耐用的替代方案可以是定義一個最終化器,其僅參照需要的特定函式和物件,而不是" "存取物件的完整狀態: ::" -#: ../../library/weakref.rst:572 +#: ../../library/weakref.rst:567 msgid "" "class TempDir:\n" " def __init__(self):\n" @@ -920,7 +920,7 @@ msgstr "" " def removed(self):\n" " return not self._finalizer.alive" -#: ../../library/weakref.rst:584 +#: ../../library/weakref.rst:579 msgid "" "Defined like this, our finalizer only receives a reference to the details it " "needs to clean up the directory appropriately. If the object never gets " @@ -929,7 +929,7 @@ msgstr "" "定義如下,我們的最終化器僅接收對適當清理目錄所需的詳細資訊的參照。如果物件從" "未被垃圾回收,則最終化器仍將在結束時被呼叫。" -#: ../../library/weakref.rst:588 +#: ../../library/weakref.rst:583 msgid "" "The other advantage of weakref based finalizers is that they can be used to " "register finalizers for classes where the definition is controlled by a " @@ -938,7 +938,7 @@ msgstr "" "基於 weakref 的最終化器的另一個優點是它們可用於為定義由第三方控制的類別註冊最" "終化器,例如在解除安裝模組時執行程式碼: ::" -#: ../../library/weakref.rst:592 +#: ../../library/weakref.rst:587 msgid "" "import weakref, sys\n" "def unloading_module():\n" @@ -946,7 +946,7 @@ msgid "" "weakref.finalize(sys.modules[__name__], unloading_module)" msgstr "" -#: ../../library/weakref.rst:600 +#: ../../library/weakref.rst:595 msgid "" "If you create a finalizer object in a daemonic thread just as the program " "exits then there is the possibility that the finalizer does not get called " diff --git a/library/webbrowser.po b/library/webbrowser.po index b7f1b3eec35..28d0a305356 100644 --- a/library/webbrowser.po +++ b/library/webbrowser.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-09-24 18:27+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!webbrowser` --- Convenient web-browser controller" msgstr ":mod:`!webbrowser` --- 方便的網頁瀏覽器控制器" -#: ../../library/webbrowser.rst:10 +#: ../../library/webbrowser.rst:7 msgid "**Source code:** :source:`Lib/webbrowser.py`" msgstr "**原始碼:**\\ :source:`Lib/webbrowser.py`" -#: ../../library/webbrowser.rst:14 +#: ../../library/webbrowser.rst:11 msgid "" "The :mod:`!webbrowser` module provides a high-level interface to allow " "displaying web-based documents to users. Under most circumstances, simply " @@ -36,7 +36,7 @@ msgstr "" ":mod:`!webbrowser` 模組提供了一個高階介面,允許向使用者顯示基於網頁的文件。在" "大多數情況下,只需從此模組呼叫 :func:`.open` 函式即可完成正確的操作。" -#: ../../library/webbrowser.rst:18 +#: ../../library/webbrowser.rst:15 msgid "" "Under Unix, graphical browsers are preferred under X11, but text-mode " "browsers will be used if graphical browsers are not available or an X11 " @@ -47,7 +47,7 @@ msgstr "" "將使用文字模式瀏覽器。如果使用文字模式瀏覽器,則呼叫程序將會阻塞 (block),直" "到使用者退出瀏覽器。" -#: ../../library/webbrowser.rst:23 +#: ../../library/webbrowser.rst:20 msgid "" "If the environment variable :envvar:`BROWSER` exists, it is interpreted as " "the :data:`os.pathsep`-separated list of browsers to try ahead of the " @@ -64,7 +64,7 @@ msgstr "" "之一的單個字,則此瀏覽器會被新增到搜尋串列的前面;如果該部分不包含 ``%s``,則" "它僅被直譯為要啟動的瀏覽器的名稱。 [1]_" -#: ../../library/webbrowser.rst:34 +#: ../../library/webbrowser.rst:31 msgid "" "The :envvar:`BROWSER` variable can now also be used to reorder the list of " "platform defaults. This is particularly useful on macOS where the platform " @@ -74,7 +74,7 @@ msgstr "" "macOS 上特別有用,因為該平台預設值不會參照 :envvar:`PATH` " "上的命令列工具。" -#: ../../library/webbrowser.rst:39 +#: ../../library/webbrowser.rst:36 msgid "" "For non-Unix platforms, or when a remote browser is available on Unix, the " "controlling process will not wait for the user to finish with the browser, " @@ -86,7 +86,7 @@ msgstr "" "完成瀏覽器,而是允許遠端瀏覽器在顯示器上維護自己的視窗。如果遠端瀏覽器在 " "Unix 上不可用,控制行程將啟動新的瀏覽器並等待。" -#: ../../library/webbrowser.rst:45 +#: ../../library/webbrowser.rst:42 msgid "" "On iOS, the :envvar:`BROWSER` environment variable, as well as any arguments " "controlling autoraise, browser preference, and new tab/window creation will " @@ -101,11 +101,11 @@ msgstr "" "要 :mod:`ctypes` 模組。如果 :mod:`ctypes` 不可用,則呼叫 :func:`.open` 將會失" "敗。" -#: ../../library/webbrowser.rst:55 +#: ../../library/webbrowser.rst:52 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/webbrowser.rst:59 +#: ../../library/webbrowser.rst:56 msgid "" "The script :program:`webbrowser` can be used as a command-line interface for " "the module. It accepts a URL as the argument. It accepts the following " @@ -114,39 +114,39 @@ msgstr "" "腳本 :program:`webbrowser` 可以用作模組的命令列介面。它接受 URL 作為引數。它" "接受以下可選參數:" -#: ../../library/webbrowser.rst:65 +#: ../../library/webbrowser.rst:62 msgid "Opens the URL in a new browser window, if possible." msgstr "如果可能的話會在新的瀏覽器視窗中開啟 URL。" -#: ../../library/webbrowser.rst:69 +#: ../../library/webbrowser.rst:66 msgid "Opens the URL in a new browser tab." msgstr "會在新的瀏覽器分頁 (\"tab\") 中開啟 URL。" -#: ../../library/webbrowser.rst:71 +#: ../../library/webbrowser.rst:68 msgid "The options are, naturally, mutually exclusive. Usage example:" msgstr "這些選項自然是相互排斥的。用法範例如下:" -#: ../../library/webbrowser.rst:73 +#: ../../library/webbrowser.rst:70 msgid "python -m webbrowser -t \"https://www.python.org\"" msgstr "python -m webbrowser -t \"https://www.python.org\"" -#: ../../library/webbrowser.rst:77 +#: ../../library/webbrowser.rst:74 msgid "Availability" msgstr "可用性" -#: ../../library/webbrowser.rst:79 +#: ../../library/webbrowser.rst:76 msgid "The following exception is defined:" msgstr "以下例外有被定義於該模組:" -#: ../../library/webbrowser.rst:84 +#: ../../library/webbrowser.rst:81 msgid "Exception raised when a browser control error occurs." msgstr "當瀏覽器控制項發生錯誤時引發例外。" -#: ../../library/webbrowser.rst:86 +#: ../../library/webbrowser.rst:83 msgid "The following functions are defined:" msgstr "以下函式有被定義於該模組:" -#: ../../library/webbrowser.rst:91 +#: ../../library/webbrowser.rst:88 msgid "" "Display *url* using the default browser. If *new* is 0, the *url* is opened " "in the same browser window if possible. If *new* is 1, a new browser window " @@ -160,13 +160,13 @@ msgstr "" "可能開啟一個新的瀏覽器分頁 (\"tab\")。如果 *autoraise* 為 ``True``,則盡可能" "提升視窗(請注意,無論此變數的設定如何,許多視窗管理器下都會發生這種情況)。" -#: ../../library/webbrowser.rst:98 ../../library/webbrowser.rst:112 -#: ../../library/webbrowser.rst:120 +#: ../../library/webbrowser.rst:95 ../../library/webbrowser.rst:109 +#: ../../library/webbrowser.rst:117 msgid "" "Returns ``True`` if a browser was successfully launched, ``False`` otherwise." msgstr "如果瀏覽器成功啟動則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/webbrowser.rst:100 +#: ../../library/webbrowser.rst:97 msgid "" "Note that on some platforms, trying to open a filename using this function, " "may work and start the operating system's associated program. However, this " @@ -175,7 +175,7 @@ msgstr "" "請注意,在某些平台上,嘗試使用此函式開啟檔案名稱可能能夠運作並啟動作業系統的" "關聯程式。然而這既不支援也不可移植。" -#: ../../library/webbrowser.rst:104 +#: ../../library/webbrowser.rst:101 msgid "" "Raises an :ref:`auditing event ` ``webbrowser.open`` with argument " "``url``." @@ -183,14 +183,14 @@ msgstr "" "引發一個附帶引數 ``url`` 的\\ :ref:`稽核事件 ` ``webbrowser." "open``。" -#: ../../library/webbrowser.rst:109 +#: ../../library/webbrowser.rst:106 msgid "" "Open *url* in a new window of the default browser, if possible, otherwise, " "open *url* in the only browser window." msgstr "" "盡可能在預設瀏覽器的新視窗中開啟 *url*,否則在唯一的瀏覽器視窗中開啟 *url*。" -#: ../../library/webbrowser.rst:117 +#: ../../library/webbrowser.rst:114 msgid "" "Open *url* in a new page (\"tab\") of the default browser, if possible, " "otherwise equivalent to :func:`open_new`." @@ -198,7 +198,7 @@ msgstr "" "盡可能在預設瀏覽器的新分頁 (\"tab\") 中開啟 *url*,否則相當於 :func:" "`open_new`。" -#: ../../library/webbrowser.rst:125 +#: ../../library/webbrowser.rst:122 msgid "" "Return a controller object for the browser type *using*. If *using* is " "``None``, return a controller for a default browser appropriate to the " @@ -207,7 +207,7 @@ msgstr "" "回傳瀏覽器類型\\ *使用*\\ (以引數 *using* 給定)的控制器物件。如果 *using* " "為 ``None``,則回傳適合呼叫者環境的預設瀏覽器控制器。" -#: ../../library/webbrowser.rst:132 +#: ../../library/webbrowser.rst:129 msgid "" "Register the browser type *name*. Once a browser type is registered, the :" "func:`get` function can return a controller for that browser type. If " @@ -220,7 +220,7 @@ msgstr "" "``None``,則會在需要時不帶參數地呼叫 *constructor* 來建立實例。如果提供了 " "*instance*,*constructor* 將永遠不會被呼叫,並且可能為 ``None``。" -#: ../../library/webbrowser.rst:138 +#: ../../library/webbrowser.rst:135 msgid "" "Setting *preferred* to ``True`` makes this browser a preferred result for a :" "func:`get` call with no argument. Otherwise, this entry point is only " @@ -232,11 +232,11 @@ msgstr "" "好結果。否則只有當你計劃設定 :envvar:`BROWSER` 變數或使用與你宣告的處理程序名" "稱相符的非空引數呼叫 :func:`get` 時,此入口點才會有用。" -#: ../../library/webbrowser.rst:144 +#: ../../library/webbrowser.rst:141 msgid "*preferred* keyword-only parameter was added." msgstr "新增了 *preferred* 僅限關鍵字參數。" -#: ../../library/webbrowser.rst:147 +#: ../../library/webbrowser.rst:144 msgid "" "A number of browser types are predefined. This table gives the type names " "that may be passed to the :func:`get` function and the corresponding " @@ -245,181 +245,186 @@ msgstr "" "預先定義了多種瀏覽器類型。此表給出了可以傳遞給 :func:`get` 函式的類型名稱以及" "控制器類別的相應實例化方式,這些都定義於此模組中。" -#: ../../library/webbrowser.rst:152 +#: ../../library/webbrowser.rst:149 msgid "Type Name" msgstr "類型名稱" -#: ../../library/webbrowser.rst:152 +#: ../../library/webbrowser.rst:149 msgid "Class Name" msgstr "類別名稱" -#: ../../library/webbrowser.rst:152 +#: ../../library/webbrowser.rst:149 msgid "Notes" msgstr "註解" -#: ../../library/webbrowser.rst:154 +#: ../../library/webbrowser.rst:151 msgid "``'mozilla'``" msgstr "``'mozilla'``" -#: ../../library/webbrowser.rst:154 ../../library/webbrowser.rst:156 +#: ../../library/webbrowser.rst:151 ../../library/webbrowser.rst:153 msgid "``Mozilla('mozilla')``" msgstr "``Mozilla('mozilla')``" -#: ../../library/webbrowser.rst:156 +#: ../../library/webbrowser.rst:153 ../../library/webbrowser.rst:181 msgid "``'firefox'``" msgstr "``'firefox'``" -#: ../../library/webbrowser.rst:158 +#: ../../library/webbrowser.rst:155 msgid "``'epiphany'``" msgstr "``'epiphany'``" -#: ../../library/webbrowser.rst:158 +#: ../../library/webbrowser.rst:155 msgid "``Epiphany('epiphany')``" msgstr "``Epiphany('epiphany')``" -#: ../../library/webbrowser.rst:160 +#: ../../library/webbrowser.rst:157 msgid "``'kfmclient'``" msgstr "``'kfmclient'``" -#: ../../library/webbrowser.rst:160 ../../library/webbrowser.rst:162 -#: ../../library/webbrowser.rst:164 +#: ../../library/webbrowser.rst:157 ../../library/webbrowser.rst:159 +#: ../../library/webbrowser.rst:161 msgid "``Konqueror()``" msgstr "``Konqueror()``" -#: ../../library/webbrowser.rst:160 ../../library/webbrowser.rst:162 -#: ../../library/webbrowser.rst:164 +#: ../../library/webbrowser.rst:157 ../../library/webbrowser.rst:159 +#: ../../library/webbrowser.rst:161 msgid "\\(1)" msgstr "\\(1)" -#: ../../library/webbrowser.rst:162 +#: ../../library/webbrowser.rst:159 msgid "``'konqueror'``" msgstr "``'konqueror'``" -#: ../../library/webbrowser.rst:164 +#: ../../library/webbrowser.rst:161 msgid "``'kfm'``" msgstr "``'kfm'``" -#: ../../library/webbrowser.rst:166 +#: ../../library/webbrowser.rst:163 msgid "``'opera'``" msgstr "``'opera'``" -#: ../../library/webbrowser.rst:166 +#: ../../library/webbrowser.rst:163 msgid "``Opera()``" msgstr "``Opera()``" -#: ../../library/webbrowser.rst:168 +#: ../../library/webbrowser.rst:165 msgid "``'links'``" msgstr "``'links'``" -#: ../../library/webbrowser.rst:168 +#: ../../library/webbrowser.rst:165 msgid "``GenericBrowser('links')``" msgstr "``GenericBrowser('links')``" -#: ../../library/webbrowser.rst:170 +#: ../../library/webbrowser.rst:167 msgid "``'elinks'``" msgstr "``'elinks'``" -#: ../../library/webbrowser.rst:170 +#: ../../library/webbrowser.rst:167 msgid "``Elinks('elinks')``" msgstr "``Elinks('elinks')``" -#: ../../library/webbrowser.rst:172 +#: ../../library/webbrowser.rst:169 msgid "``'lynx'``" msgstr "``'lynx'``" -#: ../../library/webbrowser.rst:172 +#: ../../library/webbrowser.rst:169 msgid "``GenericBrowser('lynx')``" msgstr "``GenericBrowser('lynx')``" -#: ../../library/webbrowser.rst:174 +#: ../../library/webbrowser.rst:171 msgid "``'w3m'``" msgstr "``'w3m'``" -#: ../../library/webbrowser.rst:174 +#: ../../library/webbrowser.rst:171 msgid "``GenericBrowser('w3m')``" msgstr "``GenericBrowser('w3m')``" -#: ../../library/webbrowser.rst:176 +#: ../../library/webbrowser.rst:173 msgid "``'windows-default'``" msgstr "``'windows-default'``" -#: ../../library/webbrowser.rst:176 +#: ../../library/webbrowser.rst:173 msgid "``WindowsDefault``" msgstr "``WindowsDefault``" -#: ../../library/webbrowser.rst:176 +#: ../../library/webbrowser.rst:173 msgid "\\(2)" msgstr "\\(2)" -#: ../../library/webbrowser.rst:178 -msgid "``'macosx'``" -msgstr "``'macosx'``" +#: ../../library/webbrowser.rst:175 +msgid "``'macos'``" +msgstr "``'macos'``" -#: ../../library/webbrowser.rst:178 -msgid "``MacOSXOSAScript('default')``" -msgstr "``MacOSXOSAScript('default')``" +#: ../../library/webbrowser.rst:175 +msgid "``MacOS('default')``" +msgstr "``MacOS('default')``" -#: ../../library/webbrowser.rst:178 ../../library/webbrowser.rst:180 +#: ../../library/webbrowser.rst:175 ../../library/webbrowser.rst:177 +#: ../../library/webbrowser.rst:179 ../../library/webbrowser.rst:181 msgid "\\(3)" msgstr "\\(3)" -#: ../../library/webbrowser.rst:180 +#: ../../library/webbrowser.rst:177 msgid "``'safari'``" msgstr "``'safari'``" -#: ../../library/webbrowser.rst:180 -msgid "``MacOSXOSAScript('safari')``" -msgstr "``MacOSXOSAScript('safari')``" +#: ../../library/webbrowser.rst:177 +msgid "``MacOS('safari')``" +msgstr "``MacOS('safari')``" + +#: ../../library/webbrowser.rst:179 +msgid "``'chrome'``" +msgstr "``'chrome'``" + +#: ../../library/webbrowser.rst:179 +msgid "``MacOS('google chrome')``" +msgstr "``MacOS('google chrome')``" -#: ../../library/webbrowser.rst:182 +#: ../../library/webbrowser.rst:181 +msgid "``MacOS('firefox')``" +msgstr "``MacOS('firefox')``" + +#: ../../library/webbrowser.rst:183 msgid "``'google-chrome'``" msgstr "``'google-chrome'``" -#: ../../library/webbrowser.rst:182 +#: ../../library/webbrowser.rst:183 msgid "``Chrome('google-chrome')``" msgstr "``Chrome('google-chrome')``" -#: ../../library/webbrowser.rst:184 -msgid "``'chrome'``" -msgstr "``'chrome'``" - -#: ../../library/webbrowser.rst:184 -msgid "``Chrome('chrome')``" -msgstr "``Chrome('chrome')``" - -#: ../../library/webbrowser.rst:186 +#: ../../library/webbrowser.rst:185 msgid "``'chromium'``" msgstr "``'chromium'``" -#: ../../library/webbrowser.rst:186 +#: ../../library/webbrowser.rst:185 msgid "``Chromium('chromium')``" msgstr "``Chromium('chromium')``" -#: ../../library/webbrowser.rst:188 +#: ../../library/webbrowser.rst:187 msgid "``'chromium-browser'``" msgstr "``'chromium-browser'``" -#: ../../library/webbrowser.rst:188 +#: ../../library/webbrowser.rst:187 msgid "``Chromium('chromium-browser')``" msgstr "``Chromium('chromium-browser')``" -#: ../../library/webbrowser.rst:190 +#: ../../library/webbrowser.rst:189 msgid "``'iosbrowser'``" msgstr "``'iosbrowser'``" -#: ../../library/webbrowser.rst:190 +#: ../../library/webbrowser.rst:189 msgid "``IOSBrowser``" msgstr "``IOSBrowser``" -#: ../../library/webbrowser.rst:190 +#: ../../library/webbrowser.rst:189 msgid "\\(4)" msgstr "\\(4)" -#: ../../library/webbrowser.rst:193 +#: ../../library/webbrowser.rst:192 msgid "Notes:" msgstr "註解:" -#: ../../library/webbrowser.rst:196 +#: ../../library/webbrowser.rst:195 msgid "" "\"Konqueror\" is the file manager for the KDE desktop environment for Unix, " "and only makes sense to use if KDE is running. Some way of reliably " @@ -433,19 +438,19 @@ msgstr "" "請注意,即使在 KDE 2 中使用 :program:`konqueror` 命令時,也會使用 \"kfm\" 名" "稱 --- 該實作會選擇執行 Konqueror 的最佳策略。" -#: ../../library/webbrowser.rst:203 +#: ../../library/webbrowser.rst:202 msgid "Only on Windows platforms." msgstr "僅在 Windows 平台上。" -#: ../../library/webbrowser.rst:206 +#: ../../library/webbrowser.rst:205 msgid "Only on macOS." msgstr "僅在 macOS 上。" -#: ../../library/webbrowser.rst:209 +#: ../../library/webbrowser.rst:208 msgid "Only on iOS." msgstr "僅在 iOS 上。" -#: ../../library/webbrowser.rst:211 +#: ../../library/webbrowser.rst:210 msgid "" "A new :class:`!MacOSXOSAScript` class has been added and is used on Mac " "instead of the previous :class:`!MacOSX` class. This adds support for " @@ -454,11 +459,11 @@ msgstr "" "新增了 :class:`!MacOSXOSAScript` 類別並於 Mac 上使用,而非使用先前的 :class:" "`!MacOSX` 類別。這增加了對開啟目前未設定為作業系統預設之瀏覽器的支援。" -#: ../../library/webbrowser.rst:216 +#: ../../library/webbrowser.rst:215 msgid "Support for Chrome/Chromium has been added." msgstr "新增了對 Chrome/Chromium 的支援。" -#: ../../library/webbrowser.rst:219 +#: ../../library/webbrowser.rst:218 msgid "" "Support for several obsolete browsers has been removed. Removed browsers " "include Grail, Mosaic, Netscape, Galeon, Skipstone, Iceape, and Firefox " @@ -467,15 +472,31 @@ msgstr "" "對多個過時瀏覽器的支援已被刪除。已刪除的瀏覽器包括 Grail、Mosaic、Netscape、" "Galeon、Skipstone、Iceape 和 Firefox 35 及以下版本。" -#: ../../library/webbrowser.rst:224 +#: ../../library/webbrowser.rst:223 msgid "Support for iOS has been added." msgstr "新增了對 iOS 的支援。" -#: ../../library/webbrowser.rst:227 +#: ../../library/webbrowser.rst:226 +msgid "" +":class:`!MacOS` has been added as a replacement for :class:`!" +"MacOSXOSAScript`, opening browsers via :program:`/usr/bin/open` instead of :" +"program:`osascript`." +msgstr "" + +#: ../../library/webbrowser.rst:230 +msgid "" +":class:`!MacOSXOSAScript` is deprecated in favour of :class:`!MacOS`. Using :" +"program:`/usr/bin/open` instead of :program:`osascript` is a security and " +"usability improvement: :program:`osascript` may be blocked on managed " +"systems due to its abuse potential as a general-purpose scripting " +"interpreter." +msgstr "" + +#: ../../library/webbrowser.rst:237 msgid "Here are some simple examples::" msgstr "以下是一些簡單範例: ::" -#: ../../library/webbrowser.rst:229 +#: ../../library/webbrowser.rst:239 msgid "" "url = 'https://docs.python.org/'\n" "\n" @@ -493,11 +514,11 @@ msgstr "" "# 在新視窗中開啟 URL,如果可能的話提升視窗。\n" "webbrowser.open_new(url)" -#: ../../library/webbrowser.rst:241 +#: ../../library/webbrowser.rst:251 msgid "Browser controller objects" msgstr "瀏覽器控制器物件" -#: ../../library/webbrowser.rst:243 +#: ../../library/webbrowser.rst:253 msgid "" "Browser controllers provide the :attr:`~controller.name` attribute, and the " "following three methods which parallel module-level convenience functions:" @@ -505,11 +526,11 @@ msgstr "" "瀏覽器控制器提供了 :attr:`~controller.name` 屬性和以下三個與模組層級便利函式" "相同的方法:" -#: ../../library/webbrowser.rst:249 +#: ../../library/webbrowser.rst:259 msgid "System-dependent name for the browser." msgstr "瀏覽器的系統相依名稱 (system-dependent name)。" -#: ../../library/webbrowser.rst:254 +#: ../../library/webbrowser.rst:264 msgid "" "Display *url* using the browser handled by this controller. If *new* is 1, a " "new browser window is opened if possible. If *new* is 2, a new browser page " @@ -518,7 +539,7 @@ msgstr "" "使用此控制器處理的瀏覽器顯示 *url*。如果 *new* 為 1,則盡可能開啟一個新的瀏覽" "器視窗。如果 *new* 為 2,則盡可能開啟一個新的瀏覽器分頁 (\"tab\")。" -#: ../../library/webbrowser.rst:261 +#: ../../library/webbrowser.rst:271 msgid "" "Open *url* in a new window of the browser handled by this controller, if " "possible, otherwise, open *url* in the only browser window. Alias :func:" @@ -527,7 +548,7 @@ msgstr "" "盡可能在此控制器處理的瀏覽器的新視窗中開啟 *url*,否則在唯一的瀏覽器視窗中開" "啟 *url*。別名為 :func:`open_new`。" -#: ../../library/webbrowser.rst:268 +#: ../../library/webbrowser.rst:278 msgid "" "Open *url* in a new page (\"tab\") of the browser handled by this " "controller, if possible, otherwise equivalent to :func:`open_new`." @@ -535,14 +556,17 @@ msgstr "" "盡可能在此控制器處理的瀏覽器的新分頁 (\"tab\") 中開啟 *url*,否則相當於 :" "func:`open_new`。" -#: ../../library/webbrowser.rst:273 +#: ../../library/webbrowser.rst:283 msgid "Footnotes" msgstr "註腳" -#: ../../library/webbrowser.rst:274 +#: ../../library/webbrowser.rst:284 msgid "" "Executables named here without a full path will be searched in the " "directories given in the :envvar:`PATH` environment variable." msgstr "" "此處命名的無完整路徑可執行檔將在 :envvar:`PATH` 環境變數中給定的目錄中被搜" "尋。" + +#~ msgid "``Chrome('chrome')``" +#~ msgstr "``Chrome('chrome')``" diff --git a/library/winreg.po b/library/winreg.po index 85efd17b5d1..6df0bad6aa9 100644 --- a/library/winreg.po +++ b/library/winreg.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-20 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:15+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,6 +21,10 @@ msgstr "" msgid ":mod:`!winreg` --- Windows registry access" msgstr ":mod:`!winreg` --- Windows 註冊表存取" +#: ../../library/winreg.rst:7 +msgid "**Source code:** :source:`PC/winreg.c`" +msgstr "" + #: ../../library/winreg.rst:11 msgid "" "These functions expose the Windows registry API to Python. Instead of using " @@ -92,8 +96,8 @@ msgstr "" #: ../../library/winreg.rst:59 ../../library/winreg.rst:85 #: ../../library/winreg.rst:119 ../../library/winreg.rst:140 -#: ../../library/winreg.rst:173 ../../library/winreg.rst:204 -#: ../../library/winreg.rst:239 ../../library/winreg.rst:330 +#: ../../library/winreg.rst:173 ../../library/winreg.rst:222 +#: ../../library/winreg.rst:257 ../../library/winreg.rst:348 msgid "See :ref:`above `." msgstr "" @@ -105,13 +109,14 @@ msgstr "" #: ../../library/winreg.rst:68 ../../library/winreg.rst:94 #: ../../library/winreg.rst:127 ../../library/winreg.rst:148 -#: ../../library/winreg.rst:181 ../../library/winreg.rst:193 -#: ../../library/winreg.rst:212 ../../library/winreg.rst:261 -#: ../../library/winreg.rst:308 ../../library/winreg.rst:338 -#: ../../library/winreg.rst:364 ../../library/winreg.rst:384 -#: ../../library/winreg.rst:408 ../../library/winreg.rst:433 -#: ../../library/winreg.rst:461 ../../library/winreg.rst:492 -#: ../../library/winreg.rst:509 ../../library/winreg.rst:524 +#: ../../library/winreg.rst:181 ../../library/winreg.rst:199 +#: ../../library/winreg.rst:211 ../../library/winreg.rst:230 +#: ../../library/winreg.rst:279 ../../library/winreg.rst:326 +#: ../../library/winreg.rst:356 ../../library/winreg.rst:382 +#: ../../library/winreg.rst:402 ../../library/winreg.rst:426 +#: ../../library/winreg.rst:451 ../../library/winreg.rst:479 +#: ../../library/winreg.rst:510 ../../library/winreg.rst:527 +#: ../../library/winreg.rst:542 msgid "" "*key* is an already open key, or one of the predefined :ref:`HKEY_* " "constants `." @@ -140,7 +145,7 @@ msgstr "" "` ``winreg.CreateKey``。" #: ../../library/winreg.rst:83 ../../library/winreg.rst:115 -#: ../../library/winreg.rst:325 +#: ../../library/winreg.rst:343 msgid "" "Raises an :ref:`auditing event ` ``winreg.OpenKey/result`` with " "argument ``key``." @@ -209,14 +214,38 @@ msgid "On unsupported Windows versions, :exc:`NotImplementedError` is raised." msgstr "" #: ../../library/winreg.rst:179 -msgid "Removes a named value from a registry key." +msgid "Deletes the specified key and all its subkeys and values recursively." msgstr "" #: ../../library/winreg.rst:184 +msgid "" +"*sub_key* is a string that names the subkey to delete. If ``None``, deletes " +"all subkeys and values of the specified key." +msgstr "" + +#: ../../library/winreg.rst:187 +msgid "" +"This function deletes a key and all its descendants. If *sub_key* is " +"``None``, all subkeys and values of the specified key are deleted." +msgstr "" + +#: ../../library/winreg.rst:190 +msgid "" +"Raises an :ref:`auditing event ` ``winreg.DeleteTree`` with " +"arguments ``key``, ``sub_key``." +msgstr "" +"引發一個附帶引數 ``key``、``sub_key`` 的\\ :ref:`稽核事件 ` " +"``winreg.DeleteTree``。" + +#: ../../library/winreg.rst:197 +msgid "Removes a named value from a registry key." +msgstr "" + +#: ../../library/winreg.rst:202 msgid "*value* is a string that identifies the value to remove." msgstr "*value* 是用於識別要移除之值的字串。" -#: ../../library/winreg.rst:186 +#: ../../library/winreg.rst:204 msgid "" "Raises an :ref:`auditing event ` ``winreg.DeleteValue`` with " "arguments ``key``, ``value``." @@ -224,22 +253,22 @@ msgstr "" "引發一個附帶引數 ``key``、``value`` 的\\ :ref:`稽核事件 ` ``winreg." "DeleteValue``。" -#: ../../library/winreg.rst:191 +#: ../../library/winreg.rst:209 msgid "Enumerates subkeys of an open registry key, returning a string." msgstr "" -#: ../../library/winreg.rst:196 +#: ../../library/winreg.rst:214 msgid "*index* is an integer that identifies the index of the key to retrieve." msgstr "" -#: ../../library/winreg.rst:198 +#: ../../library/winreg.rst:216 msgid "" "The function retrieves the name of one subkey each time it is called. It is " "typically called repeatedly until an :exc:`OSError` exception is raised, " "indicating, no more values are available." msgstr "" -#: ../../library/winreg.rst:202 +#: ../../library/winreg.rst:220 msgid "" "Raises an :ref:`auditing event ` ``winreg.EnumKey`` with arguments " "``key``, ``index``." @@ -247,67 +276,67 @@ msgstr "" "引發一個附帶引數 ``key``、``index`` 的\\ :ref:`稽核事件 ` ``winreg." "EnumKey``。" -#: ../../library/winreg.rst:210 +#: ../../library/winreg.rst:228 msgid "Enumerates values of an open registry key, returning a tuple." msgstr "" -#: ../../library/winreg.rst:215 +#: ../../library/winreg.rst:233 msgid "" "*index* is an integer that identifies the index of the value to retrieve." msgstr "" -#: ../../library/winreg.rst:217 +#: ../../library/winreg.rst:235 msgid "" "The function retrieves the name of one subkey each time it is called. It is " "typically called repeatedly, until an :exc:`OSError` exception is raised, " "indicating no more values." msgstr "" -#: ../../library/winreg.rst:221 ../../library/winreg.rst:341 +#: ../../library/winreg.rst:239 ../../library/winreg.rst:359 msgid "The result is a tuple of 3 items:" msgstr "" -#: ../../library/winreg.rst:224 ../../library/winreg.rst:344 -#: ../../library/winreg.rst:392 +#: ../../library/winreg.rst:242 ../../library/winreg.rst:362 +#: ../../library/winreg.rst:410 msgid "Index" msgstr "" -#: ../../library/winreg.rst:224 ../../library/winreg.rst:344 -#: ../../library/winreg.rst:392 +#: ../../library/winreg.rst:242 ../../library/winreg.rst:362 +#: ../../library/winreg.rst:410 msgid "Meaning" msgstr "含義" -#: ../../library/winreg.rst:226 ../../library/winreg.rst:346 -#: ../../library/winreg.rst:394 +#: ../../library/winreg.rst:244 ../../library/winreg.rst:364 +#: ../../library/winreg.rst:412 msgid "``0``" msgstr "``0``" -#: ../../library/winreg.rst:226 +#: ../../library/winreg.rst:244 msgid "A string that identifies the value name" msgstr "" -#: ../../library/winreg.rst:228 ../../library/winreg.rst:349 -#: ../../library/winreg.rst:396 +#: ../../library/winreg.rst:246 ../../library/winreg.rst:367 +#: ../../library/winreg.rst:414 msgid "``1``" msgstr "``1``" -#: ../../library/winreg.rst:228 +#: ../../library/winreg.rst:246 msgid "" "An object that holds the value data, and whose type depends on the " "underlying registry type" msgstr "" -#: ../../library/winreg.rst:232 ../../library/winreg.rst:352 +#: ../../library/winreg.rst:250 ../../library/winreg.rst:370 msgid "``2``" msgstr "``2``" -#: ../../library/winreg.rst:232 +#: ../../library/winreg.rst:250 msgid "" "An integer that identifies the type of the value data (see table in docs " "for :meth:`SetValueEx`)" msgstr "" -#: ../../library/winreg.rst:237 +#: ../../library/winreg.rst:255 msgid "" "Raises an :ref:`auditing event ` ``winreg.EnumValue`` with " "arguments ``key``, ``index``." @@ -315,13 +344,13 @@ msgstr "" "引發一個附帶引數 ``key``、``index`` 的\\ :ref:`稽核事件 ` ``winreg." "EnumValue``。" -#: ../../library/winreg.rst:248 +#: ../../library/winreg.rst:266 msgid "" "Expands environment variable placeholders ``%NAME%`` in strings like :const:" "`REG_EXPAND_SZ`::" msgstr "" -#: ../../library/winreg.rst:251 +#: ../../library/winreg.rst:269 msgid "" ">>> ExpandEnvironmentStrings('%windir%')\n" "'C:\\\\Windows'" @@ -329,7 +358,7 @@ msgstr "" ">>> ExpandEnvironmentStrings('%windir%')\n" "'C:\\\\Windows'" -#: ../../library/winreg.rst:254 +#: ../../library/winreg.rst:272 msgid "" "Raises an :ref:`auditing event ` ``winreg." "ExpandEnvironmentStrings`` with argument ``str``." @@ -337,11 +366,11 @@ msgstr "" "引發一個附帶引數 ``str`` 的\\ :ref:`稽核事件 ` ``winreg." "ExpandEnvironmentStrings``。" -#: ../../library/winreg.rst:259 +#: ../../library/winreg.rst:277 msgid "Writes all the attributes of a key to the registry." msgstr "" -#: ../../library/winreg.rst:264 +#: ../../library/winreg.rst:282 msgid "" "It is not necessary to call :func:`FlushKey` to change a key. Registry " "changes are flushed to disk by the registry using its lazy flusher. " @@ -352,36 +381,36 @@ msgid "" "disk." msgstr "" -#: ../../library/winreg.rst:273 +#: ../../library/winreg.rst:291 msgid "" "If you don't know whether a :func:`FlushKey` call is required, it probably " "isn't." msgstr "" -#: ../../library/winreg.rst:279 +#: ../../library/winreg.rst:297 msgid "" "Creates a subkey under the specified key and stores registration information " "from a specified file into that subkey." msgstr "" -#: ../../library/winreg.rst:282 +#: ../../library/winreg.rst:300 msgid "" "*key* is a handle returned by :func:`ConnectRegistry` or one of the " "constants :const:`HKEY_USERS` or :const:`HKEY_LOCAL_MACHINE`." msgstr "" -#: ../../library/winreg.rst:285 +#: ../../library/winreg.rst:303 msgid "*sub_key* is a string that identifies the subkey to load." msgstr "" -#: ../../library/winreg.rst:287 +#: ../../library/winreg.rst:305 msgid "" "*file_name* is the name of the file to load registry data from. This file " "must have been created with the :func:`SaveKey` function. Under the file " "allocation table (FAT) file system, the filename may not have an extension." msgstr "" -#: ../../library/winreg.rst:291 +#: ../../library/winreg.rst:309 msgid "" "A call to :func:`LoadKey` fails if the calling process does not have the :c:" "data:`!SE_RESTORE_PRIVILEGE` privilege. Note that privileges are different " @@ -389,13 +418,13 @@ msgid "" "microsoft.com/en-us/library/ms724889%28v=VS.85%29.aspx>`__ for more details." msgstr "" -#: ../../library/winreg.rst:297 +#: ../../library/winreg.rst:315 msgid "" "If *key* is a handle returned by :func:`ConnectRegistry`, then the path " "specified in *file_name* is relative to the remote computer." msgstr "" -#: ../../library/winreg.rst:300 +#: ../../library/winreg.rst:318 msgid "" "Raises an :ref:`auditing event ` ``winreg.LoadKey`` with arguments " "``key``, ``sub_key``, ``file_name``." @@ -403,36 +432,36 @@ msgstr "" "引發一個附帶引數 ``key``、``sub_key``、``file_name`` 的\\ :ref:`稽核事件 " "` ``winreg.LoadKey``。" -#: ../../library/winreg.rst:306 +#: ../../library/winreg.rst:324 msgid "" "Opens the specified key, returning a :ref:`handle object `." msgstr "" -#: ../../library/winreg.rst:311 +#: ../../library/winreg.rst:329 msgid "*sub_key* is a string that identifies the sub_key to open." msgstr "" -#: ../../library/winreg.rst:313 +#: ../../library/winreg.rst:331 msgid "" "*reserved* is a reserved integer, and must be zero. The default is zero." msgstr "" -#: ../../library/winreg.rst:315 +#: ../../library/winreg.rst:333 msgid "" "*access* is an integer that specifies an access mask that describes the " "desired security access for the key. Default is :const:`KEY_READ`. See :" "ref:`Access Rights ` for other allowed values." msgstr "" -#: ../../library/winreg.rst:319 +#: ../../library/winreg.rst:337 msgid "The result is a new handle to the specified key." msgstr "" -#: ../../library/winreg.rst:321 +#: ../../library/winreg.rst:339 msgid "If the function fails, :exc:`OSError` is raised." msgstr "" -#: ../../library/winreg.rst:323 +#: ../../library/winreg.rst:341 msgid "" "Raises an :ref:`auditing event ` ``winreg.OpenKey`` with arguments " "``key``, ``sub_key``, ``access``." @@ -440,29 +469,29 @@ msgstr "" "引發一個附帶引數 ``key``、``sub_key``、``access`` 的\\ :ref:`稽核事件 " "` ``winreg.OpenKey``。" -#: ../../library/winreg.rst:327 +#: ../../library/winreg.rst:345 msgid "Allow the use of named arguments." msgstr "" -#: ../../library/winreg.rst:336 +#: ../../library/winreg.rst:354 msgid "Returns information about a key, as a tuple." msgstr "" -#: ../../library/winreg.rst:346 +#: ../../library/winreg.rst:364 msgid "An integer giving the number of sub keys this key has." msgstr "" -#: ../../library/winreg.rst:349 +#: ../../library/winreg.rst:367 msgid "An integer giving the number of values this key has." msgstr "" -#: ../../library/winreg.rst:352 +#: ../../library/winreg.rst:370 msgid "" "An integer giving when the key was last modified (if available) as 100's of " "nanoseconds since Jan 1, 1601." msgstr "" -#: ../../library/winreg.rst:357 +#: ../../library/winreg.rst:375 msgid "" "Raises an :ref:`auditing event ` ``winreg.QueryInfoKey`` with " "argument ``key``." @@ -470,11 +499,11 @@ msgstr "" "引發一個附帶引數 ``key`` 的\\ :ref:`稽核事件 ` ``winreg." "QueryInfoKey``。" -#: ../../library/winreg.rst:362 +#: ../../library/winreg.rst:380 msgid "Retrieves the unnamed value for a key, as a string." msgstr "" -#: ../../library/winreg.rst:367 +#: ../../library/winreg.rst:385 msgid "" "*sub_key* is a string that holds the name of the subkey with which the value " "is associated. If this parameter is ``None`` or empty, the function " @@ -482,7 +511,7 @@ msgid "" "identified by *key*." msgstr "" -#: ../../library/winreg.rst:371 +#: ../../library/winreg.rst:389 msgid "" "Values in the registry have name, type, and data components. This method " "retrieves the data for a key's first value that has a ``NULL`` name. But the " @@ -490,7 +519,7 @@ msgid "" "`QueryValueEx` if possible." msgstr "" -#: ../../library/winreg.rst:376 ../../library/winreg.rst:401 +#: ../../library/winreg.rst:394 ../../library/winreg.rst:419 msgid "" "Raises an :ref:`auditing event ` ``winreg.QueryValue`` with " "arguments ``key``, ``sub_key``, ``value_name``." @@ -498,35 +527,35 @@ msgstr "" "引發一個附帶引數 ``key``、``sub_key``、``value_name`` 的\\ :ref:`稽核事件 " "` ``winreg.QueryKey``。" -#: ../../library/winreg.rst:381 +#: ../../library/winreg.rst:399 msgid "" "Retrieves the type and data for a specified value name associated with an " "open registry key." msgstr "" -#: ../../library/winreg.rst:387 +#: ../../library/winreg.rst:405 msgid "*value_name* is a string indicating the value to query." msgstr "" -#: ../../library/winreg.rst:389 +#: ../../library/winreg.rst:407 msgid "The result is a tuple of 2 items:" msgstr "" -#: ../../library/winreg.rst:394 +#: ../../library/winreg.rst:412 msgid "The value of the registry item." msgstr "" -#: ../../library/winreg.rst:396 +#: ../../library/winreg.rst:414 msgid "" "An integer giving the registry type for this value (see table in docs for :" "meth:`SetValueEx`)" msgstr "" -#: ../../library/winreg.rst:406 +#: ../../library/winreg.rst:424 msgid "Saves the specified key, and all its subkeys to the specified file." msgstr "" -#: ../../library/winreg.rst:411 +#: ../../library/winreg.rst:429 msgid "" "*file_name* is the name of the file to save registry data to. This file " "cannot already exist. If this filename includes an extension, it cannot be " @@ -534,7 +563,7 @@ msgid "" "method." msgstr "" -#: ../../library/winreg.rst:416 +#: ../../library/winreg.rst:434 msgid "" "If *key* represents a key on a remote computer, the path described by " "*file_name* is relative to the remote computer. The caller of this method " @@ -544,11 +573,11 @@ msgid "" "library/ms724878%28v=VS.85%29.aspx>`__ for more details." msgstr "" -#: ../../library/winreg.rst:424 +#: ../../library/winreg.rst:442 msgid "This function passes ``NULL`` for *security_attributes* to the API." msgstr "" -#: ../../library/winreg.rst:426 +#: ../../library/winreg.rst:444 msgid "" "Raises an :ref:`auditing event ` ``winreg.SaveKey`` with arguments " "``key``, ``file_name``." @@ -556,47 +585,47 @@ msgstr "" "引發一個附帶引數 ``key``、``file_name`` 的\\ :ref:`稽核事件 ` " "``winreg.SaveKey``。" -#: ../../library/winreg.rst:431 +#: ../../library/winreg.rst:449 msgid "Associates a value with a specified key." msgstr "" -#: ../../library/winreg.rst:436 +#: ../../library/winreg.rst:454 msgid "" "*sub_key* is a string that names the subkey with which the value is " "associated." msgstr "" -#: ../../library/winreg.rst:438 +#: ../../library/winreg.rst:456 msgid "" "*type* is an integer that specifies the type of the data. Currently this " "must be :const:`REG_SZ`, meaning only strings are supported. Use the :func:" "`SetValueEx` function for support for other data types." msgstr "" -#: ../../library/winreg.rst:442 ../../library/winreg.rst:472 +#: ../../library/winreg.rst:460 ../../library/winreg.rst:490 msgid "*value* is a string that specifies the new value." msgstr "" -#: ../../library/winreg.rst:444 +#: ../../library/winreg.rst:462 msgid "" "If the key specified by the *sub_key* parameter does not exist, the SetValue " "function creates it." msgstr "" -#: ../../library/winreg.rst:447 ../../library/winreg.rst:480 +#: ../../library/winreg.rst:465 ../../library/winreg.rst:498 msgid "" "Value lengths are limited by available memory. Long values (more than 2048 " "bytes) should be stored as files with the filenames stored in the " "configuration registry. This helps the registry perform efficiently." msgstr "" -#: ../../library/winreg.rst:451 +#: ../../library/winreg.rst:469 msgid "" "The key identified by the *key* parameter must have been opened with :const:" "`KEY_SET_VALUE` access." msgstr "" -#: ../../library/winreg.rst:454 ../../library/winreg.rst:484 +#: ../../library/winreg.rst:472 ../../library/winreg.rst:502 msgid "" "Raises an :ref:`auditing event ` ``winreg.SetValue`` with " "arguments ``key``, ``sub_key``, ``type``, ``value``." @@ -604,58 +633,58 @@ msgstr "" "引發一個附帶引數 ``key``、``sub_key``、``type``、``value`` 的\\ :ref:`稽核事" "件 ` ``winreg.SetValue``。" -#: ../../library/winreg.rst:459 +#: ../../library/winreg.rst:477 msgid "Stores data in the value field of an open registry key." msgstr "" -#: ../../library/winreg.rst:464 +#: ../../library/winreg.rst:482 msgid "" "*value_name* is a string that names the subkey with which the value is " "associated." msgstr "" -#: ../../library/winreg.rst:467 +#: ../../library/winreg.rst:485 msgid "*reserved* can be anything -- zero is always passed to the API." msgstr "" -#: ../../library/winreg.rst:469 +#: ../../library/winreg.rst:487 msgid "" "*type* is an integer that specifies the type of the data. See :ref:`Value " "Types ` for the available types." msgstr "" -#: ../../library/winreg.rst:474 +#: ../../library/winreg.rst:492 msgid "" "This method can also set additional value and type information for the " "specified key. The key identified by the key parameter must have been " "opened with :const:`KEY_SET_VALUE` access." msgstr "" -#: ../../library/winreg.rst:478 +#: ../../library/winreg.rst:496 msgid "To open the key, use the :func:`CreateKey` or :func:`OpenKey` methods." msgstr "" -#: ../../library/winreg.rst:489 +#: ../../library/winreg.rst:507 msgid "" "Disables registry reflection for 32-bit processes running on a 64-bit " "operating system." msgstr "" -#: ../../library/winreg.rst:495 ../../library/winreg.rst:512 -#: ../../library/winreg.rst:529 +#: ../../library/winreg.rst:513 ../../library/winreg.rst:530 +#: ../../library/winreg.rst:547 msgid "" "Will generally raise :exc:`NotImplementedError` if executed on a 32-bit " "operating system." msgstr "" -#: ../../library/winreg.rst:498 +#: ../../library/winreg.rst:516 msgid "" "If the key is not on the reflection list, the function succeeds but has no " "effect. Disabling reflection for a key does not affect reflection of any " "subkeys." msgstr "" -#: ../../library/winreg.rst:502 +#: ../../library/winreg.rst:520 msgid "" "Raises an :ref:`auditing event ` ``winreg.DisableReflectionKey`` " "with argument ``key``." @@ -663,16 +692,16 @@ msgstr "" "引發一個附帶引數 ``key`` 的\\ :ref:`稽核事件 ` ``winreg." "DsiableReflectionKey``。" -#: ../../library/winreg.rst:507 +#: ../../library/winreg.rst:525 msgid "Restores registry reflection for the specified disabled key." msgstr "" -#: ../../library/winreg.rst:515 +#: ../../library/winreg.rst:533 msgid "" "Restoring reflection for a key does not affect reflection of any subkeys." msgstr "" -#: ../../library/winreg.rst:517 +#: ../../library/winreg.rst:535 msgid "" "Raises an :ref:`auditing event ` ``winreg.EnableReflectionKey`` " "with argument ``key``." @@ -680,15 +709,15 @@ msgstr "" "引發一個附帶引數 ``key`` 的\\ :ref:`稽核事件 ` ``winreg." "EnableReflectionKey``。" -#: ../../library/winreg.rst:522 +#: ../../library/winreg.rst:540 msgid "Determines the reflection state for the specified key." msgstr "" -#: ../../library/winreg.rst:527 +#: ../../library/winreg.rst:545 msgid "Returns ``True`` if reflection is disabled." msgstr "" -#: ../../library/winreg.rst:532 +#: ../../library/winreg.rst:550 msgid "" "Raises an :ref:`auditing event ` ``winreg.QueryReflectionKey`` " "with argument ``key``." @@ -696,27 +725,27 @@ msgstr "" "引發一個附帶引數 ``key`` 的\\ :ref:`稽核事件 ` ``winreg." "QueryReflectionKey``。" -#: ../../library/winreg.rst:538 +#: ../../library/winreg.rst:556 msgid "Constants" msgstr "常數" -#: ../../library/winreg.rst:540 +#: ../../library/winreg.rst:558 msgid "" "The following constants are defined for use in many :mod:`!winreg` functions." msgstr "" -#: ../../library/winreg.rst:545 +#: ../../library/winreg.rst:563 msgid "HKEY_* Constants" msgstr "" -#: ../../library/winreg.rst:549 +#: ../../library/winreg.rst:567 msgid "" "Registry entries subordinate to this key define types (or classes) of " "documents and the properties associated with those types. Shell and COM " "applications use the information stored under this key." msgstr "" -#: ../../library/winreg.rst:556 +#: ../../library/winreg.rst:574 msgid "" "Registry entries subordinate to this key define the preferences of the " "current user. These preferences include the settings of environment " @@ -724,48 +753,48 @@ msgid "" "and application preferences." msgstr "" -#: ../../library/winreg.rst:563 +#: ../../library/winreg.rst:581 msgid "" "Registry entries subordinate to this key define the physical state of the " "computer, including data about the bus type, system memory, and installed " "hardware and software." msgstr "" -#: ../../library/winreg.rst:569 +#: ../../library/winreg.rst:587 msgid "" "Registry entries subordinate to this key define the default user " "configuration for new users on the local computer and the user configuration " "for the current user." msgstr "" -#: ../../library/winreg.rst:575 +#: ../../library/winreg.rst:593 msgid "" "Registry entries subordinate to this key allow you to access performance " "data. The data is not actually stored in the registry; the registry " "functions cause the system to collect the data from its source." msgstr "" -#: ../../library/winreg.rst:583 +#: ../../library/winreg.rst:601 msgid "" "Contains information about the current hardware profile of the local " "computer system." msgstr "" -#: ../../library/winreg.rst:588 +#: ../../library/winreg.rst:606 msgid "This key is not used in versions of Windows after 98." msgstr "" -#: ../../library/winreg.rst:594 +#: ../../library/winreg.rst:612 msgid "Access Rights" msgstr "" -#: ../../library/winreg.rst:596 +#: ../../library/winreg.rst:614 msgid "" "For more information, see `Registry Key Security and Access `__." msgstr "" -#: ../../library/winreg.rst:601 +#: ../../library/winreg.rst:619 msgid "" "Combines the STANDARD_RIGHTS_REQUIRED, :const:`KEY_QUERY_VALUE`, :const:" "`KEY_SET_VALUE`, :const:`KEY_CREATE_SUB_KEY`, :const:" @@ -773,169 +802,169 @@ msgid "" "access rights." msgstr "" -#: ../../library/winreg.rst:608 +#: ../../library/winreg.rst:626 msgid "" "Combines the STANDARD_RIGHTS_WRITE, :const:`KEY_SET_VALUE`, and :const:" "`KEY_CREATE_SUB_KEY` access rights." msgstr "" -#: ../../library/winreg.rst:613 +#: ../../library/winreg.rst:631 msgid "" "Combines the STANDARD_RIGHTS_READ, :const:`KEY_QUERY_VALUE`, :const:" "`KEY_ENUMERATE_SUB_KEYS`, and :const:`KEY_NOTIFY` values." msgstr "" -#: ../../library/winreg.rst:618 +#: ../../library/winreg.rst:636 msgid "Equivalent to :const:`KEY_READ`." msgstr "" -#: ../../library/winreg.rst:622 +#: ../../library/winreg.rst:640 msgid "Required to query the values of a registry key." msgstr "" -#: ../../library/winreg.rst:626 +#: ../../library/winreg.rst:644 msgid "Required to create, delete, or set a registry value." msgstr "" -#: ../../library/winreg.rst:630 +#: ../../library/winreg.rst:648 msgid "Required to create a subkey of a registry key." msgstr "" -#: ../../library/winreg.rst:634 +#: ../../library/winreg.rst:652 msgid "Required to enumerate the subkeys of a registry key." msgstr "" -#: ../../library/winreg.rst:638 +#: ../../library/winreg.rst:656 msgid "" "Required to request change notifications for a registry key or for subkeys " "of a registry key." msgstr "" -#: ../../library/winreg.rst:643 +#: ../../library/winreg.rst:661 msgid "Reserved for system use." msgstr "" -#: ../../library/winreg.rst:649 +#: ../../library/winreg.rst:667 msgid "64-bit Specific" msgstr "" -#: ../../library/winreg.rst:651 +#: ../../library/winreg.rst:669 msgid "" "For more information, see `Accessing an Alternate Registry View `__." msgstr "" -#: ../../library/winreg.rst:656 +#: ../../library/winreg.rst:674 msgid "" "Indicates that an application on 64-bit Windows should operate on the 64-bit " "registry view. On 32-bit Windows, this constant is ignored." msgstr "" -#: ../../library/winreg.rst:661 +#: ../../library/winreg.rst:679 msgid "" "Indicates that an application on 64-bit Windows should operate on the 32-bit " "registry view. On 32-bit Windows, this constant is ignored." msgstr "" -#: ../../library/winreg.rst:667 +#: ../../library/winreg.rst:685 msgid "Value Types" msgstr "" -#: ../../library/winreg.rst:669 +#: ../../library/winreg.rst:687 msgid "" "For more information, see `Registry Value Types `__." msgstr "" -#: ../../library/winreg.rst:674 +#: ../../library/winreg.rst:692 msgid "Binary data in any form." msgstr "" -#: ../../library/winreg.rst:678 +#: ../../library/winreg.rst:696 msgid "32-bit number." msgstr "" -#: ../../library/winreg.rst:682 +#: ../../library/winreg.rst:700 msgid "" "A 32-bit number in little-endian format. Equivalent to :const:`REG_DWORD`." msgstr "" -#: ../../library/winreg.rst:686 +#: ../../library/winreg.rst:704 msgid "A 32-bit number in big-endian format." msgstr "" -#: ../../library/winreg.rst:690 +#: ../../library/winreg.rst:708 msgid "" "Null-terminated string containing references to environment variables " "(``%PATH%``)." msgstr "" -#: ../../library/winreg.rst:695 +#: ../../library/winreg.rst:713 msgid "A Unicode symbolic link." msgstr "" -#: ../../library/winreg.rst:699 +#: ../../library/winreg.rst:717 msgid "" "A sequence of null-terminated strings, terminated by two null characters. " "(Python handles this termination automatically.)" msgstr "" -#: ../../library/winreg.rst:704 +#: ../../library/winreg.rst:722 msgid "No defined value type." msgstr "" -#: ../../library/winreg.rst:708 +#: ../../library/winreg.rst:726 msgid "A 64-bit number." msgstr "" -#: ../../library/winreg.rst:714 +#: ../../library/winreg.rst:732 msgid "" "A 64-bit number in little-endian format. Equivalent to :const:`REG_QWORD`." msgstr "" -#: ../../library/winreg.rst:720 +#: ../../library/winreg.rst:738 msgid "A device-driver resource list." msgstr "" -#: ../../library/winreg.rst:724 +#: ../../library/winreg.rst:742 msgid "A hardware setting." msgstr "" -#: ../../library/winreg.rst:728 +#: ../../library/winreg.rst:746 msgid "A hardware resource list." msgstr "" -#: ../../library/winreg.rst:732 +#: ../../library/winreg.rst:750 msgid "A null-terminated string." msgstr "" -#: ../../library/winreg.rst:738 +#: ../../library/winreg.rst:756 msgid "Registry Handle Objects" msgstr "" -#: ../../library/winreg.rst:740 +#: ../../library/winreg.rst:758 msgid "" "This object wraps a Windows HKEY object, automatically closing it when the " "object is destroyed. To guarantee cleanup, you can call either the :meth:" "`~PyHKEY.Close` method on the object, or the :func:`CloseKey` function." msgstr "" -#: ../../library/winreg.rst:744 +#: ../../library/winreg.rst:762 msgid "All registry functions in this module return one of these objects." msgstr "" -#: ../../library/winreg.rst:746 +#: ../../library/winreg.rst:764 msgid "" "All registry functions in this module which accept a handle object also " "accept an integer, however, use of the handle object is encouraged." msgstr "" -#: ../../library/winreg.rst:749 +#: ../../library/winreg.rst:767 msgid "" "Handle objects provide semantics for :meth:`~object.__bool__` -- thus ::" msgstr "" -#: ../../library/winreg.rst:751 +#: ../../library/winreg.rst:769 msgid "" "if handle:\n" " print(\"Yes\")" @@ -943,13 +972,21 @@ msgstr "" "if handle:\n" " print(\"Yes\")" -#: ../../library/winreg.rst:754 +#: ../../library/winreg.rst:772 msgid "" "will print ``Yes`` if the handle is currently valid (has not been closed or " "detached)." msgstr "" -#: ../../library/winreg.rst:757 +#: ../../library/winreg.rst:775 +msgid "" +"The object also support equality comparison semantics, so handle objects " +"will compare equal if they both reference the same underlying Windows handle " +"value. Closed handle objects (those with a handle value of zero) always " +"compare equal." +msgstr "" + +#: ../../library/winreg.rst:779 msgid "" "Handle objects can be converted to an integer (e.g., using the built-in :" "func:`int` function), in which case the underlying Windows handle value is " @@ -958,33 +995,33 @@ msgid "" "object." msgstr "" -#: ../../library/winreg.rst:765 +#: ../../library/winreg.rst:787 msgid "Closes the underlying Windows handle." msgstr "" -#: ../../library/winreg.rst:767 +#: ../../library/winreg.rst:789 msgid "If the handle is already closed, no error is raised." msgstr "" -#: ../../library/winreg.rst:772 +#: ../../library/winreg.rst:794 msgid "Detaches the Windows handle from the handle object." msgstr "" -#: ../../library/winreg.rst:774 +#: ../../library/winreg.rst:796 msgid "" "The result is an integer that holds the value of the handle before it is " "detached. If the handle is already detached or closed, this will return " "zero." msgstr "" -#: ../../library/winreg.rst:778 +#: ../../library/winreg.rst:800 msgid "" "After calling this function, the handle is effectively invalidated, but the " "handle is not closed. You would call this function when you need the " "underlying Win32 handle to exist beyond the lifetime of the handle object." msgstr "" -#: ../../library/winreg.rst:782 +#: ../../library/winreg.rst:804 msgid "" "Raises an :ref:`auditing event ` ``winreg.PyHKEY.Detach`` with " "argument ``key``." @@ -992,28 +1029,34 @@ msgstr "" "引發一個附帶引數 ``key`` 的\\ :ref:`稽核事件 ` ``winreg.PyHKEY." "Detach``。" -#: ../../library/winreg.rst:788 +#: ../../library/winreg.rst:810 msgid "" "The HKEY object implements :meth:`~object.__enter__` and :meth:`~object." "__exit__` and thus supports the context protocol for the :keyword:`with` " "statement::" msgstr "" -#: ../../library/winreg.rst:792 +#: ../../library/winreg.rst:814 msgid "" "with OpenKey(HKEY_LOCAL_MACHINE, \"foo\") as key:\n" " ... # work with key" msgstr "" -#: ../../library/winreg.rst:795 +#: ../../library/winreg.rst:817 msgid "" "will automatically close *key* when control leaves the :keyword:`with` block." msgstr "" -#: ../../library/winreg.rst:243 +#: ../../library/winreg.rst:820 +msgid "" +"Handle objects are now compared by their underlying Windows handle value " +"instead of object identity for equality comparisons." +msgstr "" + +#: ../../library/winreg.rst:261 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/winreg.rst:243 +#: ../../library/winreg.rst:261 msgid "environment variables expansion (Windows)" msgstr "environment variables expansion (Windows) (環境變數展開 (Windows))" diff --git a/library/winsound.po b/library/winsound.po index 3e9f139c58c..58cbeb35f1b 100644 --- a/library/winsound.po +++ b/library/winsound.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-20 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-05-19 23:00+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,7 +22,11 @@ msgstr "" msgid ":mod:`!winsound` --- Sound-playing interface for Windows" msgstr ":mod:`!winsound` --- Windows 的音效播放介面" -#: ../../library/winsound.rst:12 +#: ../../library/winsound.rst:7 +msgid "**Source code:** :source:`PC/winsound.c`" +msgstr "" + +#: ../../library/winsound.rst:11 msgid "" "The :mod:`!winsound` module provides access to the basic sound-playing " "machinery provided by Windows platforms. It includes functions and several " @@ -31,11 +35,15 @@ msgstr "" ":mod:`!winsound` 模組提供存取 Windows 平台所提供的基本音效播放機制。它包含數個" "函式與常數。" -#: ../../library/winsound.rst:15 +#: ../../library/winsound.rst:14 msgid "Availability" msgstr "" -#: ../../library/winsound.rst:20 +#: ../../library/winsound.rst:18 +msgid "Functions" +msgstr "函式" + +#: ../../library/winsound.rst:22 msgid "" "Beep the PC's speaker. The *frequency* parameter specifies frequency, in " "hertz, of the sound, and must be in the range 37 through 32,767. The " @@ -47,7 +55,7 @@ msgstr "" "須介於 37 到 32,767 之間。*duration* 參數指定音效持續的時間(以毫秒為單位)。" "若系統無法讓喇叭發出嗶聲,則會引發 :exc:`RuntimeError`。" -#: ../../library/winsound.rst:28 +#: ../../library/winsound.rst:30 msgid "" "Call the underlying :c:func:`!PlaySound` function from the Platform API. " "The *sound* parameter may be a filename, a system sound alias, audio data as " @@ -63,7 +71,7 @@ msgstr "" "``None``,則會停止任何正在播放的波形音效。若系統回報錯誤,則會引發 :exc:" "`RuntimeError`。" -#: ../../library/winsound.rst:39 +#: ../../library/winsound.rst:41 msgid "" "Call the underlying :c:func:`!MessageBeep` function from the Platform API. " "This plays a sound as specified in the registry. The *type* argument " @@ -81,13 +89,17 @@ msgstr "" "「簡單嗶聲」,當無法播放其他音效時即作為最終退路。若系統回報錯誤,則會引發 :" "exc:`RuntimeError`。" -#: ../../library/winsound.rst:50 +#: ../../library/winsound.rst:51 +msgid "Constants" +msgstr "常數" + +#: ../../library/winsound.rst:55 msgid "" "The *sound* parameter is the name of a WAV file. Do not use with :const:" "`SND_ALIAS`." msgstr "*sound* 參數為 WAV 檔案名稱。請勿與 :const:`SND_ALIAS` 同時使用。" -#: ../../library/winsound.rst:56 +#: ../../library/winsound.rst:61 msgid "" "The *sound* parameter is a sound association name from the registry. If the " "registry contains no such name, play the system default sound unless :const:" @@ -98,65 +110,65 @@ msgstr "" "設音效,除非同時指定了 :const:`SND_NODEFAULT`。若沒有註冊預設音效,則會引發 :" "exc:`RuntimeError`。請勿與 :const:`SND_FILENAME` 同時使用。" -#: ../../library/winsound.rst:61 +#: ../../library/winsound.rst:66 msgid "" "All Win32 systems support at least the following; most systems support many " "more:" msgstr "所有 Win32 系統至少支援以下項目;大多數系統支援更多:" -#: ../../library/winsound.rst:65 +#: ../../library/winsound.rst:70 msgid ":func:`PlaySound` *name*" msgstr ":func:`PlaySound` *name*" -#: ../../library/winsound.rst:65 +#: ../../library/winsound.rst:70 msgid "Corresponding Control Panel Sound name" msgstr "對應的控制台音效名稱" -#: ../../library/winsound.rst:67 +#: ../../library/winsound.rst:72 msgid "``'SystemAsterisk'``" msgstr "``'SystemAsterisk'``" -#: ../../library/winsound.rst:67 +#: ../../library/winsound.rst:72 msgid "Asterisk" msgstr "星號" -#: ../../library/winsound.rst:69 +#: ../../library/winsound.rst:74 msgid "``'SystemExclamation'``" msgstr "``'SystemExclamation'``" -#: ../../library/winsound.rst:69 +#: ../../library/winsound.rst:74 msgid "Exclamation" msgstr "驚嘆號" -#: ../../library/winsound.rst:71 +#: ../../library/winsound.rst:76 msgid "``'SystemExit'``" msgstr "``'SystemExit'``" -#: ../../library/winsound.rst:71 +#: ../../library/winsound.rst:76 msgid "Exit Windows" msgstr "離開 Windows" -#: ../../library/winsound.rst:73 +#: ../../library/winsound.rst:78 msgid "``'SystemHand'``" msgstr "``'SystemHand'``" -#: ../../library/winsound.rst:73 +#: ../../library/winsound.rst:78 msgid "Critical Stop" msgstr "關鍵性停止" -#: ../../library/winsound.rst:75 +#: ../../library/winsound.rst:80 msgid "``'SystemQuestion'``" msgstr "``'SystemQuestion'``" -#: ../../library/winsound.rst:75 +#: ../../library/winsound.rst:80 msgid "Question" msgstr "問題" -#: ../../library/winsound.rst:78 +#: ../../library/winsound.rst:83 msgid "For example::" msgstr "例如說: ::" -#: ../../library/winsound.rst:80 +#: ../../library/winsound.rst:85 msgid "" "import winsound\n" "# Play Windows exit sound.\n" @@ -174,7 +186,7 @@ msgstr "" "# (因為 \"*\" 可能不是任何音效的註冊名稱)。\n" "winsound.PlaySound(\"*\", winsound.SND_ALIAS)" -#: ../../library/winsound.rst:91 +#: ../../library/winsound.rst:96 msgid "" "Play the sound repeatedly. The :const:`SND_ASYNC` flag must also be used to " "avoid blocking. Cannot be used with :const:`SND_MEMORY`." @@ -182,7 +194,7 @@ msgstr "" "重複播放音效。必須同時使用 :const:`SND_ASYNC` 旗標以避免阻塞。不能與 :const:" "`SND_MEMORY` 一同使用。" -#: ../../library/winsound.rst:97 +#: ../../library/winsound.rst:102 msgid "" "The *sound* parameter to :func:`PlaySound` is a memory image of a WAV file, " "as a :term:`bytes-like object`." @@ -190,7 +202,7 @@ msgstr "" "傳入 :func:`PlaySound` 的 *sound* 參數是 WAV 檔案的記憶體映像,型別為 :term:" "`bytes-like object`。" -#: ../../library/winsound.rst:102 +#: ../../library/winsound.rst:107 msgid "" "This module does not support playing from a memory image asynchronously, so " "a combination of this flag and :const:`SND_ASYNC` will raise :exc:" @@ -199,32 +211,32 @@ msgstr "" "此模組不支援從記憶體映像非同步播放音效,因此若同時使用本旗標與 :const:" "`SND_ASYNC`,將引發 :exc:`RuntimeError`。" -#: ../../library/winsound.rst:108 +#: ../../library/winsound.rst:113 msgid "Stop playing all instances of the specified sound." msgstr "停止播放指定音效的所有實例。" -#: ../../library/winsound.rst:112 ../../library/winsound.rst:136 +#: ../../library/winsound.rst:117 ../../library/winsound.rst:141 msgid "This flag is not supported on modern Windows platforms." msgstr "此旗標在現代 Windows 平台上不支援。" -#: ../../library/winsound.rst:117 +#: ../../library/winsound.rst:122 msgid "Return immediately, allowing sounds to play asynchronously." msgstr "立即回傳,使音效可非同步播放。" -#: ../../library/winsound.rst:122 +#: ../../library/winsound.rst:127 msgid "" "If the specified sound cannot be found, do not play the system default sound." msgstr "若找不到指定的音效,則不播放系統預設音效。" -#: ../../library/winsound.rst:127 +#: ../../library/winsound.rst:132 msgid "Do not interrupt sounds currently playing." msgstr "不中斷目前正在播放的音效。" -#: ../../library/winsound.rst:132 +#: ../../library/winsound.rst:137 msgid "Return immediately if the sound driver is busy." msgstr "若音效驅動程式正在忙碌,則立即回傳此。" -#: ../../library/winsound.rst:141 +#: ../../library/winsound.rst:146 msgid "" "The *sound* parameter is an application-specific alias in the registry. This " "flag can be combined with the :const:`SND_ALIAS` flag to specify an " @@ -233,32 +245,32 @@ msgstr "" "*sound* 參數為登錄檔中的應用程式特定別名。此旗標可與 :const:`SND_ALIAS` 一同" "使用,以指定應用程式自訂的音效別名。" -#: ../../library/winsound.rst:148 +#: ../../library/winsound.rst:153 msgid "Triggers a SoundSentry event when the sound is played." msgstr "當音效被播放時,會觸發 SoundSentry 事件。" -#: ../../library/winsound.rst:155 +#: ../../library/winsound.rst:160 msgid "The sound is played synchronously. This is the default behavior." msgstr "音效會同步播放。這是預設行為。" -#: ../../library/winsound.rst:162 +#: ../../library/winsound.rst:167 msgid "Assign the sound to the audio session for system notification sounds." msgstr "將音效指派給系統通知音效的音訊工作階段 (audio session)。" -#: ../../library/winsound.rst:169 ../../library/winsound.rst:189 -#: ../../library/winsound.rst:201 +#: ../../library/winsound.rst:174 ../../library/winsound.rst:194 +#: ../../library/winsound.rst:206 msgid "Play the ``SystemDefault`` sound." msgstr "播放 ``SystemDefault`` 音效。" -#: ../../library/winsound.rst:174 ../../library/winsound.rst:215 +#: ../../library/winsound.rst:179 ../../library/winsound.rst:220 msgid "Play the ``SystemExclamation`` sound." msgstr "播放 ``SystemExclamation`` 音效。" -#: ../../library/winsound.rst:179 ../../library/winsound.rst:194 -#: ../../library/winsound.rst:208 +#: ../../library/winsound.rst:184 ../../library/winsound.rst:199 +#: ../../library/winsound.rst:213 msgid "Play the ``SystemHand`` sound." msgstr "播放 ``SystemHand`` 音效。" -#: ../../library/winsound.rst:184 +#: ../../library/winsound.rst:189 msgid "Play the ``SystemQuestion`` sound." msgstr "播放 ``SystemQuestion`` 音效。" diff --git a/library/wsgiref.po b/library/wsgiref.po index 38b0cc0de3a..ce514daa176 100644 --- a/library/wsgiref.po +++ b/library/wsgiref.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-12 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-12-09 21:29+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,17 +22,17 @@ msgstr "" msgid ":mod:`!wsgiref` --- WSGI Utilities and Reference Implementation" msgstr ":mod:`!wsgiref` --- WSGI 工具與參考實作" -#: ../../library/wsgiref.rst:10 +#: ../../library/wsgiref.rst:7 msgid "**Source code:** :source:`Lib/wsgiref`" msgstr "**原始碼:**\\ :source:`Lib/wsgiref`" -#: ../../library/wsgiref.rst:16 +#: ../../library/wsgiref.rst:13 msgid "" ":mod:`!wsgiref` is a reference implementation and is not recommended for " "production. The module only implements basic security checks." msgstr "" -#: ../../library/wsgiref.rst:19 +#: ../../library/wsgiref.rst:16 msgid "" "The Web Server Gateway Interface (WSGI) is a standard interface between web " "server software and web applications written in Python. Having a standard " @@ -43,7 +43,7 @@ msgstr "" "Python 撰寫的網頁應用程式,擁有一個標準介面使得支援 WSGI 的應用程式可以與多個" "不同的網頁伺服器運行。" -#: ../../library/wsgiref.rst:24 +#: ../../library/wsgiref.rst:21 msgid "" "Only authors of web servers and programming frameworks need to know every " "detail and corner case of the WSGI design. You don't need to understand " @@ -54,7 +54,7 @@ msgstr "" "需要為了安裝 WSGI 應用程式或是使用現有框架撰寫網頁應用程式而必須理解每個細" "節。" -#: ../../library/wsgiref.rst:29 +#: ../../library/wsgiref.rst:26 msgid "" ":mod:`!wsgiref` is a reference implementation of the WSGI specification that " "can be used to add WSGI support to a web server or framework. It provides " @@ -69,7 +69,7 @@ msgstr "" "別,提供用於示範 HTTP 伺服器的 WSGI 應用程式、靜態型別檢查、以及驗證 WSGI 伺" "服器與應用程式是否符合 WSGI 規格的驗證工具 (:pep:`3333`)。" -#: ../../library/wsgiref.rst:37 +#: ../../library/wsgiref.rst:34 msgid "" "See `wsgi.readthedocs.io `_ for more " "information about WSGI, and links to tutorials and other resources." @@ -77,11 +77,11 @@ msgstr "" "參閱 `wsgi.readthedocs.io `_ 更多 WSGI 相關資" "訊,以及教學連結與其他資源。" -#: ../../library/wsgiref.rst:44 +#: ../../library/wsgiref.rst:41 msgid ":mod:`!wsgiref.util` -- WSGI environment utilities" msgstr ":mod:`!wsgiref.util` -- WSGI 環境工具" -#: ../../library/wsgiref.rst:50 +#: ../../library/wsgiref.rst:47 msgid "" "This module provides a variety of utility functions for working with WSGI " "environments. A WSGI environment is a dictionary containing HTTP request " @@ -95,7 +95,7 @@ msgstr "" "WSGI 標準的字典;請參閱 :pep:`3333` 取得詳細規格,以及 :data:`~wsgiref.types." "WSGIEnvironment` 取得可用於使用型別註釋的型別別名。" -#: ../../library/wsgiref.rst:61 +#: ../../library/wsgiref.rst:58 msgid "" "Return a guess for whether ``wsgi.url_scheme`` should be \"http\" or " "\"https\", by checking for a ``HTTPS`` environment variable in the *environ* " @@ -104,7 +104,7 @@ msgstr "" "透過檢查 *environ* 字典中的 ``HTTPS`` 環境變數,回傳 ``wsgi.url_scheme`` 應該" "是 \"http\" 或 \"https\" 的猜測。回傳值為一個字串。" -#: ../../library/wsgiref.rst:65 +#: ../../library/wsgiref.rst:62 msgid "" "This function is useful when creating a gateway that wraps CGI or a CGI-like " "protocol such as FastCGI. Typically, servers providing such protocols will " @@ -117,7 +117,7 @@ msgstr "" "\"1\",\"yes\",或 \"on\" 的 ``HTTPS`` 變數,因此,如果找到這樣的值,此函式回" "傳 \"https\",否則回傳 \"http\"。" -#: ../../library/wsgiref.rst:74 +#: ../../library/wsgiref.rst:71 msgid "" "Return the full request URI, optionally including the query string, using " "the algorithm found in the \"URL Reconstruction\" section of :pep:`3333`. " @@ -128,7 +128,7 @@ msgstr "" "求 URI,可選擇性的包含查詢字串,如果 *include_query* 設為 false,查詢字串不會" "被包含在結果的 URI 中。" -#: ../../library/wsgiref.rst:81 +#: ../../library/wsgiref.rst:78 msgid "" "Similar to :func:`request_uri`, except that the ``PATH_INFO`` and " "``QUERY_STRING`` variables are ignored. The result is the base URI of the " @@ -137,7 +137,7 @@ msgstr "" "類似於 :func:`request_uri`,但忽略 ``PATH_INFO`` 和 ``QUERY_STRING`` 變數。結" "果是請求地址的應用程式物件的的基本 URI。" -#: ../../library/wsgiref.rst:88 +#: ../../library/wsgiref.rst:85 msgid "" "Shift a single name from ``PATH_INFO`` to ``SCRIPT_NAME`` and return the " "name. The *environ* dictionary is *modified* in-place; use a copy if you " @@ -147,13 +147,13 @@ msgstr "" "會在適當時機被 *modified*;如果你需要保留原始完好無損的 ``PATH_INFO`` 或 " "``SCRIPT_NAME`` 請使用副本。" -#: ../../library/wsgiref.rst:92 +#: ../../library/wsgiref.rst:89 msgid "" "If there are no remaining path segments in ``PATH_INFO``, ``None`` is " "returned." msgstr "如果在 ``PATH_INFO`` 中沒有剩餘的路徑片段,則回傳 ``None``。" -#: ../../library/wsgiref.rst:94 +#: ../../library/wsgiref.rst:91 msgid "" "Typically, this routine is used to process each portion of a request URI " "path, for example to treat the path as a series of dictionary keys. This " @@ -174,7 +174,7 @@ msgstr "" "話說,``SCRIPT_NAME`` 將從 ``/foo`` 變更為 ``/foo/bar``,而 ``PATH_INFO`` 將" "從 ``/bar/baz`` 變更為 ``/baz``。" -#: ../../library/wsgiref.rst:105 +#: ../../library/wsgiref.rst:102 msgid "" "When ``PATH_INFO`` is just a \"/\", this routine returns an empty string and " "appends a trailing slash to ``SCRIPT_NAME``, even though empty path segments " @@ -188,11 +188,11 @@ msgstr "" "``SCRIPT_NAME`` 通常不會以斜號結尾。這是刻意行為,以確保應用程式在使用這個程" "式進行物件遍歷時可以區分結尾為 ``/x`` 和結尾為 ``/x/`` 的 URIs。" -#: ../../library/wsgiref.rst:115 +#: ../../library/wsgiref.rst:112 msgid "Update *environ* with trivial defaults for testing purposes." msgstr "為測試目的,以簡單的預設值更新 *environ* 。" -#: ../../library/wsgiref.rst:117 +#: ../../library/wsgiref.rst:114 msgid "" "This routine adds various parameters required for WSGI, including " "``HTTP_HOST``, ``SERVER_NAME``, ``SERVER_PORT``, ``REQUEST_METHOD``, " @@ -205,7 +205,7 @@ msgstr "" "有 :pep:`3333` 定義的 ``wsgi.*`` 變數,它只提供預設值,並且不會取代現有的這些" "變數設定。" -#: ../../library/wsgiref.rst:123 +#: ../../library/wsgiref.rst:120 msgid "" "This routine is intended to make it easier for unit tests of WSGI servers " "and applications to set up dummy environments. It should NOT be used by " @@ -214,13 +214,13 @@ msgstr "" "這個程式目的為了讓 WSGI 伺服器和應用程式的單元測試更容易建置虛擬環境。實際的 " "WSGI 伺服器或應用程式不應該使用它,因為所產生的數據是假的!" -#: ../../library/wsgiref.rst:127 +#: ../../library/wsgiref.rst:124 msgid "" "Example usage (see also :func:`~wsgiref.simple_server.demo_app` for another " "example)::" msgstr "" -#: ../../library/wsgiref.rst:130 +#: ../../library/wsgiref.rst:127 msgid "" "from wsgiref.util import setup_testing_defaults\n" "from wsgiref.simple_server import make_server\n" @@ -244,13 +244,13 @@ msgid "" " httpd.serve_forever()" msgstr "" -#: ../../library/wsgiref.rst:152 +#: ../../library/wsgiref.rst:149 msgid "" "In addition to the environment functions above, the :mod:`!wsgiref.util` " "module also provides these miscellaneous utilities:" msgstr "除了上述的環境功能外,:mod:`!wsgiref.util` 模組還提供以下各類工具:" -#: ../../library/wsgiref.rst:158 +#: ../../library/wsgiref.rst:155 msgid "" "Return ``True`` if 'header_name' is an HTTP/1.1 \"Hop-by-Hop\" header, as " "defined by :rfc:`2616`." @@ -258,7 +258,7 @@ msgstr "" "如果 'header_name' 是根據 :rfc:`2616` 所定義的 HTTP/1.1 \"Hop-by-Hop\" 標頭," "則回傳 ``True``。" -#: ../../library/wsgiref.rst:164 +#: ../../library/wsgiref.rst:161 msgid "" "A concrete implementation of the :class:`wsgiref.types.FileWrapper` protocol " "used to convert a file-like object to an :term:`iterator`. The resulting " @@ -273,7 +273,7 @@ msgstr "" "(yield)的位元組字串。當 :meth:`read` 回傳一個空位元組字串,代表疊代已結束且" "無法回復。" -#: ../../library/wsgiref.rst:172 +#: ../../library/wsgiref.rst:169 msgid "" "If *filelike* has a :meth:`close` method, the returned object will also have " "a :meth:`close` method, and it will invoke the *filelike* object's :meth:" @@ -282,12 +282,12 @@ msgstr "" "如果 *filelike* 有 :meth:`close` 方法,則回傳的物件也會具有 :meth:`close` 方" "法,並在呼叫時叫用 *filelike* 物件的 :meth:`close` 方法。" -#: ../../library/wsgiref.rst:176 ../../library/wsgiref.rst:299 -#: ../../library/wsgiref.rst:434 +#: ../../library/wsgiref.rst:173 ../../library/wsgiref.rst:296 +#: ../../library/wsgiref.rst:431 msgid "Example usage::" msgstr "用法範例: ::" -#: ../../library/wsgiref.rst:178 +#: ../../library/wsgiref.rst:175 msgid "" "from io import StringIO\n" "from wsgiref.util import FileWrapper\n" @@ -300,15 +300,15 @@ msgid "" " print(chunk)" msgstr "" -#: ../../library/wsgiref.rst:188 +#: ../../library/wsgiref.rst:185 msgid "Support for :meth:`~object.__getitem__` method has been removed." msgstr "已移除對 :meth:`~object.__getitem__` 方法的支援。" -#: ../../library/wsgiref.rst:193 +#: ../../library/wsgiref.rst:190 msgid ":mod:`!wsgiref.headers` -- WSGI response header tools" msgstr ":mod:`!wsgiref.headers` -- WSGI 回應標頭工具" -#: ../../library/wsgiref.rst:199 +#: ../../library/wsgiref.rst:196 msgid "" "This module provides a single class, :class:`Headers`, for convenient " "manipulation of WSGI response headers using a mapping-like interface." @@ -316,7 +316,7 @@ msgstr "" "這個模組提供單一類別 :class:`Headers`,用於使用類似對映的介面方便地操作 WSGI " "回應標頭。" -#: ../../library/wsgiref.rst:205 +#: ../../library/wsgiref.rst:202 msgid "" "Create a mapping-like object wrapping *headers*, which must be a list of " "header name/value tuples as described in :pep:`3333`. The default value of " @@ -325,7 +325,7 @@ msgstr "" "建立一個類似對映物件並包裝 *headers*,並且必須是符合 :pep:`3333` 描述的 name/" "value 元組的標頭串列。*headers* 的預設值是一個空串列。" -#: ../../library/wsgiref.rst:209 +#: ../../library/wsgiref.rst:206 msgid "" ":class:`Headers` objects support typical mapping operations including :meth:" "`~object.__getitem__`, :meth:`~dict.get`, :meth:`~object.__setitem__`, :meth:" @@ -344,7 +344,7 @@ msgstr "" "值。設定標頭會刪除該標頭的所有現有值,然後將新值添加到包裝的標頭串列末尾。標" "頭的現有順序通常保持不變,新標頭會添加到包裝串列的末尾。" -#: ../../library/wsgiref.rst:219 +#: ../../library/wsgiref.rst:216 msgid "" "Unlike a dictionary, :class:`Headers` objects do not raise an error when you " "try to get or delete a key that isn't in the wrapped header list. Getting a " @@ -355,7 +355,7 @@ msgstr "" "不會引發例外錯誤。取得不存在的標頭只會回傳 ``None``,而刪除不存在的標頭則不會" "有任何效果。" -#: ../../library/wsgiref.rst:224 +#: ../../library/wsgiref.rst:221 msgid "" ":class:`Headers` objects also support :meth:`keys`, :meth:`values`, and :" "meth:`items` methods. The lists returned by :meth:`keys` and :meth:`items` " @@ -370,7 +370,7 @@ msgstr "" "的鍵。:class:`Headers` 物件的 ``len()`` 與 :meth:`items` 的長度相同,也與包裝" "標頭串列的長度相同。實際上,:meth:`items` 方法只是回傳包裝的標頭串列的副本。" -#: ../../library/wsgiref.rst:231 +#: ../../library/wsgiref.rst:228 msgid "" "Calling ``bytes()`` on a :class:`Headers` object returns a formatted " "bytestring suitable for transmission as HTTP response headers. Each header " @@ -382,7 +382,7 @@ msgstr "" "式化的位元組字串。每個標頭都與其值一起置於一行上,由冒號與空格分隔。每行以回" "車(carriage return)和換行(line feed)結束,而該位元組字串則以空行結束。" -#: ../../library/wsgiref.rst:237 +#: ../../library/wsgiref.rst:234 msgid "" "In addition to their mapping interface and formatting features, :class:" "`Headers` objects also have the following methods for querying and adding " @@ -391,11 +391,11 @@ msgstr "" "除了對映介面和格式化功能外,:class:`Headers` 物件還具有以下查詢及附加多值標頭" "的以及附加 MIME 參數標頭的方法:" -#: ../../library/wsgiref.rst:244 +#: ../../library/wsgiref.rst:241 msgid "Return a list of all the values for the named header." msgstr "回傳指定標頭的所有值的串列。" -#: ../../library/wsgiref.rst:246 +#: ../../library/wsgiref.rst:243 msgid "" "The returned list will be sorted in the order they appeared in the original " "header list or were added to this instance, and may contain duplicates. Any " @@ -406,14 +406,14 @@ msgstr "" "序,並且可能包含重複的內容。任何被刪除並重新插入的欄位都會被添加到標頭串列的" "末尾。如果不存在指定名稱的欄位,則回傳空串列。" -#: ../../library/wsgiref.rst:254 +#: ../../library/wsgiref.rst:251 msgid "" "Add a (possibly multi-valued) header, with optional MIME parameters " "specified via keyword arguments." msgstr "" "添加一個(可能是多值的)標頭,可透過關鍵字引數來指定選擇性的 MIME 參數。" -#: ../../library/wsgiref.rst:257 +#: ../../library/wsgiref.rst:254 msgid "" "*name* is the header field to add. Keyword arguments can be used to set " "MIME parameters for the header field. Each parameter must be a string or " @@ -430,27 +430,27 @@ msgstr "" "則以 ``name=\"value\"`` 的形式添加到標頭值參數中。如果它是 ``None``,則僅添加" "參數名稱。(這使用於沒有值的 MIME 參數)使用範例: ::" -#: ../../library/wsgiref.rst:265 +#: ../../library/wsgiref.rst:262 msgid "h.add_header('content-disposition', 'attachment', filename='bud.gif')" msgstr "h.add_header('content-disposition', 'attachment', filename='bud.gif')" -#: ../../library/wsgiref.rst:267 +#: ../../library/wsgiref.rst:264 msgid "The above will add a header that looks like this::" msgstr "上述操作將添加看起來像這樣的標頭: ::" -#: ../../library/wsgiref.rst:269 +#: ../../library/wsgiref.rst:266 msgid "Content-Disposition: attachment; filename=\"bud.gif\"" msgstr "Content-Disposition: attachment; filename=\"bud.gif\"" -#: ../../library/wsgiref.rst:272 +#: ../../library/wsgiref.rst:269 msgid "*headers* parameter is optional." msgstr "*headers* 參數是可選的。" -#: ../../library/wsgiref.rst:277 +#: ../../library/wsgiref.rst:274 msgid ":mod:`!wsgiref.simple_server` -- a simple WSGI HTTP server" msgstr ":mod:`!wsgiref.simple_server` -- 一個簡單的 WSGI HTTP 伺服器" -#: ../../library/wsgiref.rst:283 +#: ../../library/wsgiref.rst:280 msgid "" "This module implements a simple HTTP server (based on :mod:`http.server`) " "that serves WSGI applications. Each server instance serves a single WSGI " @@ -466,7 +466,7 @@ msgstr "" "``PATH_INFO`` 去選擇為每個請求叫用哪個應用程式。(例如,使用來自 :mod:" "`wsgiref.util` 的 :func:`shift_path_info` 函式。)" -#: ../../library/wsgiref.rst:294 +#: ../../library/wsgiref.rst:291 msgid "" "Create a new WSGI server listening on *host* and *port*, accepting " "connections for *app*. The return value is an instance of the supplied " @@ -478,7 +478,7 @@ msgstr "" "供 *server_class* 的實例,並將使用指定的 *handler_class* 處理請求。*app* 必須" "是一個 WSGI 應用程式物件,如 :pep:`3333` 所定義。" -#: ../../library/wsgiref.rst:301 +#: ../../library/wsgiref.rst:298 msgid "" "from wsgiref.simple_server import make_server, demo_app\n" "\n" @@ -492,7 +492,7 @@ msgid "" " httpd.handle_request()" msgstr "" -#: ../../library/wsgiref.rst:315 +#: ../../library/wsgiref.rst:312 msgid "" "This function is a small but complete WSGI application that returns a text " "page containing the message \"Hello world!\" and a list of the key/value " @@ -505,13 +505,13 @@ msgstr "" "(例如 :mod:`!wsgiref.simple_server`)是否能正確執行簡單的 WSGI 應用程式非常有" "用。" -#: ../../library/wsgiref.rst:321 +#: ../../library/wsgiref.rst:318 msgid "" "The *start_response* callable should follow the :class:`.StartResponse` " "protocol." msgstr "" -#: ../../library/wsgiref.rst:326 +#: ../../library/wsgiref.rst:323 msgid "" "Create a :class:`WSGIServer` instance. *server_address* should be a ``(host," "port)`` tuple, and *RequestHandlerClass* should be the subclass of :class:" @@ -521,7 +521,7 @@ msgstr "" "port)`` 元組,而 *RequestHandlerClass* 應該是 :class:`http.server." "BaseHTTPRequestHandler` 的子類別,將用於處理請求。" -#: ../../library/wsgiref.rst:331 +#: ../../library/wsgiref.rst:328 msgid "" "You do not normally need to call this constructor, as the :func:" "`make_server` function can handle all the details for you." @@ -529,7 +529,7 @@ msgstr "" "通常你不需要呼叫這個建構函式(constructor),因為 :func:`make_server` 函式可" "以為你處理所有細節。" -#: ../../library/wsgiref.rst:334 +#: ../../library/wsgiref.rst:331 msgid "" ":class:`WSGIServer` is a subclass of :class:`http.server.HTTPServer`, so all " "of its methods (such as :meth:`serve_forever` and :meth:`handle_request`) " @@ -539,17 +539,17 @@ msgstr "" "方法(例如 :meth:`serve_forever` 和 :meth:`handle_request`)都可用。:class:" "`WSGIServer` 也提供這些特定於 WSGI 的方法:" -#: ../../library/wsgiref.rst:341 +#: ../../library/wsgiref.rst:338 msgid "" "Sets the callable *application* as the WSGI application that will receive " "requests." msgstr "將可呼叫的 *application* 設定為接收請求的 WSGI 應用程式。" -#: ../../library/wsgiref.rst:347 +#: ../../library/wsgiref.rst:344 msgid "Returns the currently set application callable." msgstr "回傳目前設定應用程式的可呼叫物件。" -#: ../../library/wsgiref.rst:349 +#: ../../library/wsgiref.rst:346 msgid "" "Normally, however, you do not need to use these additional methods, as :meth:" "`set_app` is normally called by :func:`make_server`, and the :meth:`get_app` " @@ -559,7 +559,7 @@ msgstr "" "func:`make_server` 呼叫而 :meth:`get_app` 主要存在於請求處理程式(handler)實" "例的好處上。" -#: ../../library/wsgiref.rst:356 +#: ../../library/wsgiref.rst:353 msgid "" "Create an HTTP handler for the given *request* (i.e. a socket), " "*client_address* (a ``(host,port)`` tuple), and *server* (:class:" @@ -569,7 +569,7 @@ msgstr "" "port)`` 位元組)、*server* (:class:`WSGIServer` 實例) 建立一個 HTTP 處理程式" "(handler)。" -#: ../../library/wsgiref.rst:359 +#: ../../library/wsgiref.rst:356 msgid "" "You do not need to create instances of this class directly; they are " "automatically created as needed by :class:`WSGIServer` objects. You can, " @@ -581,7 +581,7 @@ msgstr "" "建立。不過,你可以建立這個類別的子類別並將其作為 *handler_class* 提供給 :" "func:`make_server` 函式。一些可能相關的方法可以在子類別中進行覆寫:" -#: ../../library/wsgiref.rst:368 +#: ../../library/wsgiref.rst:365 msgid "" "Return a :data:`~wsgiref.types.WSGIEnvironment` dictionary for a request. " "The default implementation copies the contents of the :class:`WSGIServer` " @@ -595,14 +595,14 @@ msgstr "" "從 HTTP 請求中衍生的各種標頭。每次呼叫這個方法都應該回傳一個包含所有如 :pep:" "`3333` 所指定的相關 CGI 環境變數的新字典。" -#: ../../library/wsgiref.rst:379 +#: ../../library/wsgiref.rst:376 msgid "" "Return the object that should be used as the ``wsgi.errors`` stream. The " "default implementation just returns ``sys.stderr``." msgstr "" "回傳的物件應該被用作 ``wsgi.errors`` 串流。預設實作只會回傳 ``sys.stderr``。" -#: ../../library/wsgiref.rst:385 +#: ../../library/wsgiref.rst:382 msgid "" "Process the HTTP request. The default implementation creates a handler " "instance using a :mod:`wsgiref.handlers` class to implement the actual WSGI " @@ -611,11 +611,11 @@ msgstr "" "處理 HTTP 請求。預設實作會使用 :mod:`wsgiref.handlers` 類別來建立處置程式" "(handler)實例來實作實際 WSGI 應用程式介面。" -#: ../../library/wsgiref.rst:391 +#: ../../library/wsgiref.rst:388 msgid ":mod:`!wsgiref.validate` --- WSGI conformance checker" msgstr ":mod:`!wsgiref.validate` --- WSGI 符合性檢查" -#: ../../library/wsgiref.rst:397 +#: ../../library/wsgiref.rst:394 msgid "" "When creating new WSGI application objects, frameworks, servers, or " "middleware, it can be useful to validate the new code's conformance using :" @@ -629,7 +629,7 @@ msgstr "" "個函式用於建立 WSGI 應用程式物件,並用於驗證 WSGI 伺服器或是閘道與 WSGI 應用" "程式物件之間的通訊,以檢查雙方協定的符合性。" -#: ../../library/wsgiref.rst:404 +#: ../../library/wsgiref.rst:401 msgid "" "Note that this utility does not guarantee complete :pep:`3333` compliance; " "an absence of errors from this module does not necessarily mean that errors " @@ -641,7 +641,7 @@ msgstr "" "錯誤。但是,如果如果這個模組產生錯誤,那麼幾乎可以確定伺服器或應用程式不是 " "100% 符合標準。" -#: ../../library/wsgiref.rst:409 +#: ../../library/wsgiref.rst:406 msgid "" "This module is based on the :mod:`paste.lint` module from Ian Bicking's " "\"Python Paste\" library." @@ -649,7 +649,7 @@ msgstr "" "這個模組基於 Ian Bicking 的 \"Python Paste\" 函式庫的 :mod:`paste.lint` 模" "組。" -#: ../../library/wsgiref.rst:415 +#: ../../library/wsgiref.rst:412 msgid "" "Wrap *application* and return a new WSGI application object. The returned " "application will forward all requests to the original *application*, and " @@ -660,7 +660,7 @@ msgstr "" "請求給原始的 *application*,並檢查 *application* 和呼叫它的伺服器是否符合 " "WSGI 規範和 :rfc:`2616`。" -#: ../../library/wsgiref.rst:420 +#: ../../library/wsgiref.rst:417 msgid "" "Any detected nonconformance results in an :exc:`AssertionError` being " "raised; note, however, that how these errors are handled is server-" @@ -676,7 +676,7 @@ msgstr "" "輸出一條錯誤訊息,指示發生錯誤,並將回溯訊息輸出到 ``sys.stderr`` 或是其他錯" "誤串流。" -#: ../../library/wsgiref.rst:427 +#: ../../library/wsgiref.rst:424 msgid "" "This wrapper may also generate output using the :mod:`warnings` module to " "indicate behaviors that are questionable but which may not actually be " @@ -690,7 +690,7 @@ msgstr "" "`warnings` API,抑制了這些警告,否則這類警告將被寫入到 ``sys.stderr``\\ " "(*not* ``wsgi.errors``,除非它們碰巧是相同的物件)。" -#: ../../library/wsgiref.rst:436 +#: ../../library/wsgiref.rst:433 msgid "" "from wsgiref.validate import validator\n" "from wsgiref.simple_server import make_server\n" @@ -714,11 +714,11 @@ msgid "" " httpd.serve_forever()" msgstr "" -#: ../../library/wsgiref.rst:459 +#: ../../library/wsgiref.rst:456 msgid ":mod:`!wsgiref.handlers` -- server/gateway base classes" msgstr ":mod:`!wsgiref.handlers` -- 伺服器 / 閘道基本類別" -#: ../../library/wsgiref.rst:465 +#: ../../library/wsgiref.rst:462 msgid "" "This module provides base handler classes for implementing WSGI servers and " "gateways. These base classes handle most of the work of communicating with " @@ -729,7 +729,7 @@ msgstr "" "處理程式大部分與 WSGI 應用程式通訊的工作,只要它們被提供 CGI-like 環境,以及" "輸入、輸出和錯誤串流。" -#: ../../library/wsgiref.rst:473 +#: ../../library/wsgiref.rst:470 msgid "" "CGI-based invocation via ``sys.stdin``, ``sys.stdout``, ``sys.stderr`` and " "``os.environ``. This is useful when you have a WSGI application and want to " @@ -741,7 +741,7 @@ msgstr "" "很有用的。只需叫用 ``CGIHandler().run(app)``,其中 ``app`` 是你希望叫用的 " "WSGI 應用程式物件。" -#: ../../library/wsgiref.rst:478 +#: ../../library/wsgiref.rst:475 msgid "" "This class is a subclass of :class:`BaseCGIHandler` that sets ``wsgi." "run_once`` to true, ``wsgi.multithread`` to false, and ``wsgi.multiprocess`` " @@ -752,7 +752,7 @@ msgstr "" "``wsgi.multithread`` 設置為 false,並將 ``wsgi.multiprocess`` 設置為 true,並" "且始終使用 :mod:`sys` 和 :mod:`os` 來取得所需的 CGI 串流以及環境。" -#: ../../library/wsgiref.rst:486 +#: ../../library/wsgiref.rst:483 msgid "" "A specialized alternative to :class:`CGIHandler`, for use when deploying on " "Microsoft's IIS web server, without having set the config allowPathInfo " @@ -762,7 +762,7 @@ msgstr "" "個專門替代選擇,無需設置 config 的 allowPathInfo 選項(IIS>=7),或 metabase " "的 allowPathInfoForScriptMappings 選項(IIS<7)。" -#: ../../library/wsgiref.rst:490 +#: ../../library/wsgiref.rst:487 msgid "" "By default, IIS gives a ``PATH_INFO`` that duplicates the ``SCRIPT_NAME`` at " "the front, causing problems for WSGI applications that wish to implement " @@ -772,7 +772,7 @@ msgstr "" "作路由的 WSGI 應用程式造成問題。這個處理程式(handler)會移除任何這樣的重複路" "徑。" -#: ../../library/wsgiref.rst:494 +#: ../../library/wsgiref.rst:491 msgid "" "IIS can be configured to pass the correct ``PATH_INFO``, but this causes " "another bug where ``PATH_TRANSLATED`` is wrong. Luckily this variable is " @@ -788,7 +788,7 @@ msgstr "" "``PATH_TRANSLATED`` 問題時會中斷。由於這個原因幾乎從不會使用修復的 IIS<7(即" "使是 IIS7 也很少使用它,因為它仍然沒有相應的 UI)。" -#: ../../library/wsgiref.rst:502 +#: ../../library/wsgiref.rst:499 msgid "" "There is no way for CGI code to tell whether the option was set, so a " "separate handler class is provided. It is used in the same way as :class:" @@ -799,7 +799,7 @@ msgstr "" "別。它的使用方式與 :class:`CGIHandler` 相同,即透過呼叫 ``IISCGIHandler()." "run(app)`` 來使用,其中 ``app`` 是你希望叫用的 WSGI 應用程式物件。" -#: ../../library/wsgiref.rst:512 +#: ../../library/wsgiref.rst:509 msgid "" "Similar to :class:`CGIHandler`, but instead of using the :mod:`sys` and :mod:" "`os` modules, the CGI environment and I/O streams are specified explicitly. " @@ -811,7 +811,7 @@ msgstr "" "指定 CGI 環境與 I/O 串流。*multithread* 和 *multiprocess* 值用於設置由處理程" "式(handler)實例運行的任何應用程式的旗標。" -#: ../../library/wsgiref.rst:518 +#: ../../library/wsgiref.rst:515 msgid "" "This class is a subclass of :class:`SimpleHandler` intended for use with " "software other than HTTP \"origin servers\". If you are writing a gateway " @@ -824,7 +824,7 @@ msgstr "" "狀態的閘道協定實作(例如 CGI、FastCGI、SCGI 等),你可能會想要子類化這個類別" "來替代 :class:`SimpleHandler`。" -#: ../../library/wsgiref.rst:527 +#: ../../library/wsgiref.rst:524 msgid "" "Similar to :class:`BaseCGIHandler`, but designed for use with HTTP origin " "servers. If you are writing an HTTP server implementation, you will " @@ -834,7 +834,7 @@ msgstr "" "在撰寫 HTTP 伺服器的實作,你可能會想要子類別化這個類別來替代 :class:" "`BaseCGIHandler`。" -#: ../../library/wsgiref.rst:531 +#: ../../library/wsgiref.rst:528 msgid "" "This class is a subclass of :class:`BaseHandler`. It overrides the :meth:`!" "__init__`, :meth:`~BaseHandler.get_stdin`, :meth:`~BaseHandler.get_stderr`, :" @@ -850,7 +850,7 @@ msgstr "" "`~BaseHandler._flush` 方法來明確提供設置環境與串流。提供的環境與串流被儲存" "在 :attr:`stdin`、:attr:`stdout`、:attr:`stderr`、和 :attr:`environ` 環境中。" -#: ../../library/wsgiref.rst:540 +#: ../../library/wsgiref.rst:537 msgid "" "The :meth:`~io.BufferedIOBase.write` method of *stdout* should write each " "chunk in full, like :class:`io.BufferedIOBase`." @@ -858,7 +858,7 @@ msgstr "" "*stdout* 的 :meth:`~io.BufferedIOBase.write` 方法應該完整地寫入每個塊" "(chunk),像是 :class:`io.BufferedIOBase`。" -#: ../../library/wsgiref.rst:546 +#: ../../library/wsgiref.rst:543 msgid "" "This is an abstract base class for running WSGI applications. Each instance " "will handle a single HTTP request, although in principle you could create a " @@ -867,17 +867,17 @@ msgstr "" "這是一個運行 WSGI 應用程式的抽象基底類別。每個實例將處理單個 HTTP 請求,儘管" "原則上你可以建立一個可重用於多個請求的子類別。" -#: ../../library/wsgiref.rst:550 +#: ../../library/wsgiref.rst:547 msgid "" ":class:`BaseHandler` instances have only one method intended for external " "use:" msgstr ":class:`BaseHandler` 實例只有一個供外部使用的方法:" -#: ../../library/wsgiref.rst:555 +#: ../../library/wsgiref.rst:552 msgid "Run the specified WSGI application, *app*." msgstr "運行指定 WSGI 應用程式,*app*。" -#: ../../library/wsgiref.rst:557 +#: ../../library/wsgiref.rst:554 msgid "" "All of the other :class:`BaseHandler` methods are invoked by this method in " "the process of running the application, and thus exist primarily to allow " @@ -886,11 +886,11 @@ msgstr "" "此方法在運行應用程式的過程中叫用了所有其他 :class:`BaseHandler` 的方法,因此" "這些方法主要存在是為了允許自訂整個過程。" -#: ../../library/wsgiref.rst:561 +#: ../../library/wsgiref.rst:558 msgid "The following methods MUST be overridden in a subclass:" msgstr "以下方法必須在子類別中覆寫:" -#: ../../library/wsgiref.rst:566 +#: ../../library/wsgiref.rst:563 msgid "" "Buffer the bytes *data* for transmission to the client. It's okay if this " "method actually transmits the data; :class:`BaseHandler` just separates " @@ -901,7 +901,7 @@ msgstr "" "底層系統實際具有這種區分時,:class:`BaseHandler` 為了更好的效能進而分離寫入和" "刷新操作。" -#: ../../library/wsgiref.rst:574 +#: ../../library/wsgiref.rst:571 msgid "" "Force buffered data to be transmitted to the client. It's okay if this " "method is a no-op (i.e., if :meth:`_write` actually sends the data)." @@ -909,7 +909,7 @@ msgstr "" "強制將緩衝數據傳送到用戶端。如果這是一個無操作(no-op)的方法(即,如果 :" "meth:`_write` 實際上發送了數據),那麼是可以的。" -#: ../../library/wsgiref.rst:580 +#: ../../library/wsgiref.rst:577 msgid "" "Return an object compatible with :class:`~wsgiref.types.InputStream` " "suitable for use as the ``wsgi.input`` of the request currently being " @@ -918,7 +918,7 @@ msgstr "" "回傳一個與 :class:`~wsgiref.types.InputStream` 相容的物件並適用於用作目前正在" "處理請求的 ``wsgi.input``。" -#: ../../library/wsgiref.rst:587 +#: ../../library/wsgiref.rst:584 msgid "" "Return an object compatible with :class:`~wsgiref.types.ErrorStream` " "suitable for use as the ``wsgi.errors`` of the request currently being " @@ -927,13 +927,13 @@ msgstr "" "回傳一個與 :class:`~wsgiref.types.ErrorStream` 相容的物件並適用於用作目前正在" "處理請求的 ``wsgi.errors``。" -#: ../../library/wsgiref.rst:594 +#: ../../library/wsgiref.rst:591 msgid "" "Insert CGI variables for the current request into the :attr:`environ` " "attribute." msgstr "將目前請求的 CGI 變數插入到 :attr:`environ` 屬性中。" -#: ../../library/wsgiref.rst:596 +#: ../../library/wsgiref.rst:593 msgid "" "Here are some other methods and attributes you may wish to override. This " "list is only a summary, however, and does not include every method that can " @@ -945,11 +945,11 @@ msgstr "" "被覆寫的每個方法。在嘗試建立自訂的 :class:`BaseHandler` 子類別之前,你應該參" "考文件說明和原始碼以獲得更多資訊。" -#: ../../library/wsgiref.rst:602 +#: ../../library/wsgiref.rst:599 msgid "Attributes and methods for customizing the WSGI environment:" msgstr "用於自訂 WSGI 環境的屬性和方法:" -#: ../../library/wsgiref.rst:607 +#: ../../library/wsgiref.rst:604 msgid "" "The value to be used for the ``wsgi.multithread`` environment variable. It " "defaults to true in :class:`BaseHandler`, but may have a different default " @@ -958,7 +958,7 @@ msgstr "" "用於 ``wsgi.multithread`` 環境變數的值。在 :class:`BaseHandler` 中預設為 " "true,但在其他子類別中可能有不同的預設值(或由建構函式設置)。" -#: ../../library/wsgiref.rst:614 +#: ../../library/wsgiref.rst:611 msgid "" "The value to be used for the ``wsgi.multiprocess`` environment variable. It " "defaults to true in :class:`BaseHandler`, but may have a different default " @@ -967,7 +967,7 @@ msgstr "" "用於 ``wsgi.multiprocess`` 環境變數的值。在 :class:`BaseHandler` 中預設為 " "true,但在其他子類別中可能有不同的預設值(或由建構函式設置)。" -#: ../../library/wsgiref.rst:621 +#: ../../library/wsgiref.rst:618 msgid "" "The value to be used for the ``wsgi.run_once`` environment variable. It " "defaults to false in :class:`BaseHandler`, but :class:`CGIHandler` sets it " @@ -976,7 +976,7 @@ msgstr "" "用於 ``wsgi.run_once`` 環境變數的值。在 :class:`BaseHandler` 中預設為 false," "但 :class:`CGIHandler` 預設將其設置為 true。" -#: ../../library/wsgiref.rst:628 +#: ../../library/wsgiref.rst:625 msgid "" "The default environment variables to be included in every request's WSGI " "environment. By default, this is a copy of ``os.environ`` at the time that :" @@ -989,7 +989,7 @@ msgstr "" "`!wsgiref.handlers` 時的 ``os.environ`` 副本,但子類別可以在類別或實例層級建立" "自己的副本。注意字典應該被視為唯讀,因為預設值在多個類別與實例中共享。" -#: ../../library/wsgiref.rst:638 +#: ../../library/wsgiref.rst:635 msgid "" "If the :attr:`origin_server` attribute is set, this attribute's value is " "used to set the default ``SERVER_SOFTWARE`` WSGI environment variable, and " @@ -1002,14 +1002,14 @@ msgstr "" "``Server:`` 標頭。對於不是 HTTP origin 伺服器的處置程式(例如 :class:" "`BaseCGIHandler` 和 :class:`CGIHandler`),此屬性將被忽略。" -#: ../../library/wsgiref.rst:644 +#: ../../library/wsgiref.rst:641 msgid "" "The term \"Python\" is replaced with implementation specific term like " "\"CPython\", \"Jython\" etc." msgstr "" "將術語 \"Python\" 替換為特定實作的術語,如 \"CPython\"、\"Jython\" 等。" -#: ../../library/wsgiref.rst:650 +#: ../../library/wsgiref.rst:647 msgid "" "Return the URL scheme being used for the current request. The default " "implementation uses the :func:`guess_scheme` function from :mod:`wsgiref." @@ -1020,7 +1020,7 @@ msgstr "" "`guess_scheme` 函式去猜測 scheme 是 \"http\" 或是 \"https\",基於目前請求的 :" "attr:`environ` 變數。" -#: ../../library/wsgiref.rst:658 +#: ../../library/wsgiref.rst:655 msgid "" "Set the :attr:`environ` attribute to a fully populated WSGI environment. " "The default implementation uses all of the above methods and attributes, " @@ -1035,11 +1035,11 @@ msgstr "" "``SERVER_SOFTWARE`` 關鍵字,只要 :attr:`origin_server` 屬性是一個 true 值並" "且 :attr:`server_software` 屬性被設置。" -#: ../../library/wsgiref.rst:665 +#: ../../library/wsgiref.rst:662 msgid "Methods and attributes for customizing exception handling:" msgstr "用於自訂例外處理的屬性和方法:" -#: ../../library/wsgiref.rst:670 +#: ../../library/wsgiref.rst:667 msgid "" "Log the *exc_info* tuple in the server log. *exc_info* is a ``(type, value, " "traceback)`` tuple. The default implementation simply writes the traceback " @@ -1053,7 +1053,7 @@ msgstr "" "並刷新它。子類別可以覆蓋此方法以更改格式或重新定向輸出,將追蹤資訊發送給管理" "員,或執行其他被認為合適的操作。" -#: ../../library/wsgiref.rst:679 +#: ../../library/wsgiref.rst:676 msgid "" "The maximum number of frames to include in tracebacks output by the default :" "meth:`log_exception` method. If ``None``, all frames are included." @@ -1061,7 +1061,7 @@ msgstr "" "預設的 :meth:`log_exception` 方法追蹤輸出中包含的最大幀數 。如果為 ``None``," "則包含所有幀。" -#: ../../library/wsgiref.rst:685 +#: ../../library/wsgiref.rst:682 msgid "" "This method is a WSGI application to generate an error page for the user. " "It is only invoked if an error occurs before headers are sent to the client." @@ -1069,7 +1069,7 @@ msgstr "" "這個方法是一個為使用者去產生錯誤頁面的 WSGI 應用程式。只有在標頭傳送給用戶端" "前如果發生錯誤才會被叫用。" -#: ../../library/wsgiref.rst:688 +#: ../../library/wsgiref.rst:685 msgid "" "This method can access the current error using ``sys.exception()``, and " "should pass that information to *start_response* when calling it (as " @@ -1081,7 +1081,7 @@ msgstr "" "\"Error Handling\" 部分所描述)時應該傳遞資訊給 *start_response*。特別是 " "*start_response* 可呼叫物件應該遵循 :class:`.StartResponse` 協定。" -#: ../../library/wsgiref.rst:694 +#: ../../library/wsgiref.rst:691 msgid "" "The default implementation just uses the :attr:`error_status`, :attr:" "`error_headers`, and :attr:`error_body` attributes to generate an output " @@ -1090,7 +1090,7 @@ msgstr "" "預設的實作只是使用 :attr:`error_status`、:attr:`error_headers` 和 :attr:" "`error_body` 屬性產生輸出頁面。子類別可以覆蓋此方法以生成更動態的錯誤輸出。" -#: ../../library/wsgiref.rst:698 +#: ../../library/wsgiref.rst:695 msgid "" "Note, however, that it's not recommended from a security perspective to spit " "out diagnostics to any old user; ideally, you should have to do something " @@ -1100,7 +1100,7 @@ msgstr "" "然而,從安全的角度並不建議向任何普通使用者顯示診斷資訊;理想情況下,你應該需" "要採取特殊措施才能啟用診斷輸出,這就是預設實作不包括任何診斷資訊的原因。" -#: ../../library/wsgiref.rst:706 +#: ../../library/wsgiref.rst:703 msgid "" "The HTTP status used for error responses. This should be a status string as " "defined in :pep:`3333`; it defaults to a 500 code and message." @@ -1108,7 +1108,7 @@ msgstr "" "用於錯誤回應的 HTTP 狀態。這應該是一個按照 :pep:`3333` 定義的狀態字串;預設" "為 500 狀態碼和訊息。" -#: ../../library/wsgiref.rst:712 +#: ../../library/wsgiref.rst:709 msgid "" "The HTTP headers used for error responses. This should be a list of WSGI " "response headers (``(name, value)`` tuples), as described in :pep:`3333`. " @@ -1118,7 +1118,7 @@ msgstr "" "value)`` 元組),如 :pep:`3333` 中所描述。預設串列只設置內容種類為 ``text/" "plain``。" -#: ../../library/wsgiref.rst:719 +#: ../../library/wsgiref.rst:716 msgid "" "The error response body. This should be an HTTP response body bytestring. " "It defaults to the plain text, \"A server error occurred. Please contact " @@ -1127,7 +1127,7 @@ msgstr "" "錯誤回應的主體。這應該是一個 HTTP 回應內容的位元組字串。預設為純文字 \"A " "server error occurred. Please contact the administrator.\"" -#: ../../library/wsgiref.rst:723 +#: ../../library/wsgiref.rst:720 msgid "" "Methods and attributes for :pep:`3333`'s \"Optional Platform-Specific File " "Handling\" feature:" @@ -1135,7 +1135,7 @@ msgstr "" "用於 :pep:`3333` 中的 \"Optional Platform-Specific File Handling\" 功能的方法" "和屬性:" -#: ../../library/wsgiref.rst:729 +#: ../../library/wsgiref.rst:726 msgid "" "A ``wsgi.file_wrapper`` factory, compatible with :class:`wsgiref.types." "FileWrapper`, or ``None``. The default value of this attribute is the :" @@ -1145,7 +1145,7 @@ msgstr "" "FileWrapper` 相容,或者為 ``None``。這個屬性的預設值是 :class:`wsgiref.util." "FileWrapper` 類別。" -#: ../../library/wsgiref.rst:736 +#: ../../library/wsgiref.rst:733 msgid "" "Override to implement platform-specific file transmission. This method is " "called only if the application's return value is an instance of the class " @@ -1159,11 +1159,11 @@ msgstr "" "案應該回傳一個 true 值,以便不執行預設的傳輸程式碼。該方法的預設實作只回傳一" "個 false 值。" -#: ../../library/wsgiref.rst:743 +#: ../../library/wsgiref.rst:740 msgid "Miscellaneous methods and attributes:" msgstr "其他方法和屬性:" -#: ../../library/wsgiref.rst:748 +#: ../../library/wsgiref.rst:745 msgid "" "This attribute should be set to a true value if the handler's :meth:`_write` " "and :meth:`_flush` are being used to communicate directly to the client, " @@ -1174,7 +1174,7 @@ msgstr "" "meth:`_flush` 被用於直接與用戶端通訊,而不是透過 CGI-like 的閘道協定希望 " "HTTP 狀態在特殊的 ``Status:`` 標頭中。" -#: ../../library/wsgiref.rst:753 +#: ../../library/wsgiref.rst:750 msgid "" "This attribute's default value is true in :class:`BaseHandler`, but false " "in :class:`BaseCGIHandler` and :class:`CGIHandler`." @@ -1182,7 +1182,7 @@ msgstr "" "這個屬性在 :class:`BaseHandler` 預設值為 true,但是在 :class:" "`BaseCGIHandler` 和 :class:`CGIHandler` 為 false。" -#: ../../library/wsgiref.rst:759 +#: ../../library/wsgiref.rst:756 msgid "" "If :attr:`origin_server` is true, this string attribute is used to set the " "HTTP version of the response set to the client. It defaults to ``\"1.0\"``." @@ -1190,7 +1190,7 @@ msgstr "" "如果 :attr:`origin_server` 為 true,則此字串屬性用於設定傳送給用戶端的回應的 " "HTTP 版本。預設為 ``\"1.0\"``。" -#: ../../library/wsgiref.rst:765 +#: ../../library/wsgiref.rst:762 msgid "" "Transcode CGI variables from ``os.environ`` to :pep:`3333` \"bytes in " "unicode\" strings, returning a new dictionary. This function is used by :" @@ -1208,7 +1208,7 @@ msgstr "" "Windows)的情況下,或者在環境是位元組的情況下,但 Python 用於解碼它的系統編碼" "不是 ISO-8859-1 (例如使用 UTF-8 的 Unix 系統)。" -#: ../../library/wsgiref.rst:774 +#: ../../library/wsgiref.rst:771 msgid "" "If you are implementing a CGI-based handler of your own, you probably want " "to use this routine instead of just copying values out of ``os.environ`` " @@ -1217,17 +1217,17 @@ msgstr "" "如果你自己正在實作 CGI-based 處理程式(handler),你可能想要使用這個函式來替" "換單純直接從 ``os.environ`` 中複製值。" -#: ../../library/wsgiref.rst:782 +#: ../../library/wsgiref.rst:779 msgid ":mod:`!wsgiref.types` -- WSGI types for static type checking" msgstr ":mod:`!wsgiref.types` -- 用於靜態型別檢查的 WSGI 型別" -#: ../../library/wsgiref.rst:788 +#: ../../library/wsgiref.rst:785 msgid "" "This module provides various types for static type checking as described in :" "pep:`3333`." msgstr "這個模組提供在 :pep:`3333` 中所描述的各種用於靜態型別檢查的型別。" -#: ../../library/wsgiref.rst:796 +#: ../../library/wsgiref.rst:793 msgid "" "A :class:`typing.Protocol` describing :pep:`start_response() <3333#the-start-" "response-callable>` callables (:pep:`3333`)." @@ -1235,15 +1235,15 @@ msgstr "" "一個描述 :pep:`start_response() <3333#the-start-response-callable>` 可呼叫物" "件的 :class:`typing.Protocol` (:pep:`3333`)。" -#: ../../library/wsgiref.rst:802 +#: ../../library/wsgiref.rst:799 msgid "A type alias describing a WSGI environment dictionary." msgstr "一個描述 WSGI 環境字典的型別別名。" -#: ../../library/wsgiref.rst:806 +#: ../../library/wsgiref.rst:803 msgid "A type alias describing a WSGI application callable." msgstr "一個描述 WSGI 應用程式可呼叫物件的型別別名。" -#: ../../library/wsgiref.rst:810 +#: ../../library/wsgiref.rst:807 msgid "" "A :class:`typing.Protocol` describing a :pep:`WSGI Input Stream <3333#input-" "and-error-streams>`." @@ -1251,7 +1251,7 @@ msgstr "" "一個描述 :pep:`WSGI 輸入串流 <3333#input-and-error-streams>`\\ 的 :class:" "`typing.Protocol`。" -#: ../../library/wsgiref.rst:815 +#: ../../library/wsgiref.rst:812 msgid "" "A :class:`typing.Protocol` describing a :pep:`WSGI Error Stream <3333#input-" "and-error-streams>`." @@ -1259,7 +1259,7 @@ msgstr "" "一個描述 :pep:`WSGI 錯誤串流 <3333#input-and-error-streams>`\\ 的 :class:" "`typing.Protocol`。" -#: ../../library/wsgiref.rst:820 +#: ../../library/wsgiref.rst:817 msgid "" "A :class:`typing.Protocol` describing a :pep:`file wrapper <3333#optional-" "platform-specific-file-handling>`. See :class:`wsgiref.util.FileWrapper` for " @@ -1269,18 +1269,18 @@ msgstr "" "handling>`\\ 的 :class:`typing.Protocol`。請參閱 :class:`wsgiref.util." "FileWrapper` 來瞭解此協定的具體實作。" -#: ../../library/wsgiref.rst:827 +#: ../../library/wsgiref.rst:824 msgid "Examples" msgstr "範例" -#: ../../library/wsgiref.rst:829 +#: ../../library/wsgiref.rst:826 msgid "" "This is a working \"Hello World\" WSGI application, where the " "*start_response* callable should follow the :class:`.StartResponse` " "protocol::" msgstr "" -#: ../../library/wsgiref.rst:832 +#: ../../library/wsgiref.rst:829 msgid "" "\"\"\"\n" "Every WSGI application must have an application object - a callable\n" @@ -1309,7 +1309,7 @@ msgid "" " httpd.serve_forever()" msgstr "" -#: ../../library/wsgiref.rst:859 +#: ../../library/wsgiref.rst:856 msgid "" "Example of a WSGI application serving the current directory, accept optional " "directory and port number (default: 8000) on the command line::" @@ -1317,7 +1317,7 @@ msgstr "" "提供目前目錄的 WSGI 應用程式範例,並接受命令列上的可選目錄和埠號(預設:" "8000): ::" -#: ../../library/wsgiref.rst:862 +#: ../../library/wsgiref.rst:859 msgid "" "\"\"\"\n" "Small wsgiref based web server. Takes a path to serve from and an\n" diff --git a/library/xml.dom.minidom.po b/library/xml.dom.minidom.po index ac47f83afbc..98912f2459b 100644 --- a/library/xml.dom.minidom.po +++ b/library/xml.dom.minidom.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-31 00:22+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:15+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!xml.dom.minidom` --- Minimal DOM implementation" msgstr ":mod:`!xml.dom.minidom` --- 最小的 DOM 實作" -#: ../../library/xml.dom.minidom.rst:11 +#: ../../library/xml.dom.minidom.rst:7 msgid "**Source code:** :source:`Lib/xml/dom/minidom.py`" msgstr "**原始碼:**\\ :source:`Lib/xml/dom/minidom.py`" -#: ../../library/xml.dom.minidom.rst:15 +#: ../../library/xml.dom.minidom.rst:11 msgid "" ":mod:`!xml.dom.minidom` is a minimal implementation of the Document Object " "Model interface, with an API similar to that in other languages. It is " @@ -34,19 +34,19 @@ msgid "" "mod:`xml.etree.ElementTree` module for their XML processing instead." msgstr "" -#: ../../library/xml.dom.minidom.rst:24 +#: ../../library/xml.dom.minidom.rst:20 msgid "" "If you need to parse untrusted or unauthenticated data, see :ref:`xml-" "security`." msgstr "如果你需要剖析不受信任或未經驗證的資料,請參閱 :ref:`xml-security`。" -#: ../../library/xml.dom.minidom.rst:28 +#: ../../library/xml.dom.minidom.rst:24 msgid "" "DOM applications typically start by parsing some XML into a DOM. With :mod:" "`!xml.dom.minidom`, this is done through the parse functions::" msgstr "" -#: ../../library/xml.dom.minidom.rst:31 +#: ../../library/xml.dom.minidom.rst:27 msgid "" "from xml.dom.minidom import parse, parseString\n" "\n" @@ -66,12 +66,12 @@ msgstr "" "\n" "dom3 = parseString('Some data some more data')" -#: ../../library/xml.dom.minidom.rst:40 +#: ../../library/xml.dom.minidom.rst:36 msgid "" "The :func:`parse` function can take either a filename or an open file object." msgstr ":func:`parse` 函式可以接受一個檔案名稱或開啟的檔案物件。" -#: ../../library/xml.dom.minidom.rst:45 +#: ../../library/xml.dom.minidom.rst:41 msgid "" "Return a :class:`Document` from the given input. *filename_or_file* may be " "either a file name, or a file-like object. *parser*, if given, must be a " @@ -80,26 +80,26 @@ msgid "" "setting an entity resolver) must have been done in advance." msgstr "" -#: ../../library/xml.dom.minidom.rst:51 +#: ../../library/xml.dom.minidom.rst:47 msgid "" "If you have XML in a string, you can use the :func:`parseString` function " "instead:" msgstr "如果你有一個字串中的 XML,你可以使用 :func:`parseString` 函式來代替:" -#: ../../library/xml.dom.minidom.rst:57 +#: ../../library/xml.dom.minidom.rst:53 msgid "" "Return a :class:`Document` that represents the *string*. This method creates " "an :class:`io.StringIO` object for the string and passes that on to :func:" "`parse`." msgstr "" -#: ../../library/xml.dom.minidom.rst:60 +#: ../../library/xml.dom.minidom.rst:56 msgid "" "Both functions return a :class:`Document` object representing the content of " "the document." msgstr "這兩個函式都會回傳一個 :class:`Document` 物件,表示文件的內容。" -#: ../../library/xml.dom.minidom.rst:63 +#: ../../library/xml.dom.minidom.rst:59 msgid "" "What the :func:`parse` and :func:`parseString` functions do is connect an " "XML parser with a \"DOM builder\" that can accept parse events from any SAX " @@ -110,7 +110,7 @@ msgid "" "themselves." msgstr "" -#: ../../library/xml.dom.minidom.rst:70 +#: ../../library/xml.dom.minidom.rst:66 msgid "" "You can also create a :class:`Document` by calling a method on a \"DOM " "Implementation\" object. You can get this object either by calling the :" @@ -119,7 +119,7 @@ msgid "" "add child nodes to it to populate the DOM::" msgstr "" -#: ../../library/xml.dom.minidom.rst:76 +#: ../../library/xml.dom.minidom.rst:72 msgid "" "from xml.dom.minidom import getDOMImplementation\n" "\n" @@ -139,7 +139,7 @@ msgstr "" "text = newdoc.createTextNode('Some textual content.')\n" "top_element.appendChild(text)" -#: ../../library/xml.dom.minidom.rst:85 +#: ../../library/xml.dom.minidom.rst:81 msgid "" "Once you have a DOM document object, you can access the parts of your XML " "document through its properties and methods. These properties are defined " @@ -148,7 +148,7 @@ msgid "" "document: the one that holds all others. Here is an example program::" msgstr "" -#: ../../library/xml.dom.minidom.rst:91 +#: ../../library/xml.dom.minidom.rst:87 msgid "" "dom3 = parseString(\"Some data\")\n" "assert dom3.documentElement.tagName == \"myxml\"" @@ -156,7 +156,7 @@ msgstr "" "dom3 = parseString(\"Some data\")\n" "assert dom3.documentElement.tagName == \"myxml\"" -#: ../../library/xml.dom.minidom.rst:94 +#: ../../library/xml.dom.minidom.rst:90 msgid "" "When you are finished with a DOM tree, you may optionally call the :meth:" "`unlink` method to encourage early cleanup of the now-unneeded objects. :" @@ -166,7 +166,7 @@ msgid "" "objects in the tree." msgstr "" -#: ../../library/xml.dom.minidom.rst:103 +#: ../../library/xml.dom.minidom.rst:99 msgid "" "`Document Object Model (DOM) Level 1 Specification `_" @@ -174,23 +174,23 @@ msgstr "" "`Document Object Model (DOM) Level 1 Specification `_" -#: ../../library/xml.dom.minidom.rst:104 +#: ../../library/xml.dom.minidom.rst:100 msgid "" "The W3C recommendation for the DOM supported by :mod:`!xml.dom.minidom`." msgstr "W3C 對 :mod:`!xml.dom.minidom` DOM 支援 的建議。" -#: ../../library/xml.dom.minidom.rst:110 +#: ../../library/xml.dom.minidom.rst:106 msgid "DOM Objects" msgstr "DOM 物件" -#: ../../library/xml.dom.minidom.rst:112 +#: ../../library/xml.dom.minidom.rst:108 msgid "" "The definition of the DOM API for Python is given as part of the :mod:`xml." "dom` module documentation. This section lists the differences between the " "API and :mod:`!xml.dom.minidom`." msgstr "" -#: ../../library/xml.dom.minidom.rst:119 +#: ../../library/xml.dom.minidom.rst:115 msgid "" "Break internal references within the DOM so that it will be garbage " "collected on versions of Python without cyclic GC. Even when cyclic GC is " @@ -200,14 +200,14 @@ msgid "" "may be called on child nodes to discard children of that node." msgstr "" -#: ../../library/xml.dom.minidom.rst:126 +#: ../../library/xml.dom.minidom.rst:122 msgid "" "You can avoid calling this method explicitly by using the :keyword:`with` " "statement. The following code will automatically unlink *dom* when the :" "keyword:`!with` block is exited::" msgstr "" -#: ../../library/xml.dom.minidom.rst:130 +#: ../../library/xml.dom.minidom.rst:126 msgid "" "with xml.dom.minidom.parse(datasource) as dom:\n" " ... # Work with dom." @@ -215,7 +215,7 @@ msgstr "" "with xml.dom.minidom.parse(datasource) as dom:\n" " ... # 使用 dom。" -#: ../../library/xml.dom.minidom.rst:137 +#: ../../library/xml.dom.minidom.rst:133 msgid "" "Write XML to the writer object. The writer receives texts but not bytes as " "input, it should have a :meth:`write` method which matches that of the file " @@ -225,13 +225,13 @@ msgid "" "use to terminate newlines." msgstr "" -#: ../../library/xml.dom.minidom.rst:144 +#: ../../library/xml.dom.minidom.rst:140 msgid "" "For the :class:`Document` node, an additional keyword argument *encoding* " "can be used to specify the encoding field of the XML header." msgstr "" -#: ../../library/xml.dom.minidom.rst:147 +#: ../../library/xml.dom.minidom.rst:143 msgid "" "Similarly, explicitly stating the *standalone* argument causes the " "standalone document declarations to be added to the prologue of the XML " @@ -240,24 +240,24 @@ msgid "" "declaration from the document." msgstr "" -#: ../../library/xml.dom.minidom.rst:154 +#: ../../library/xml.dom.minidom.rst:150 msgid "" "The :meth:`writexml` method now preserves the attribute order specified by " "the user." msgstr "" -#: ../../library/xml.dom.minidom.rst:158 ../../library/xml.dom.minidom.rst:179 -#: ../../library/xml.dom.minidom.rst:198 +#: ../../library/xml.dom.minidom.rst:154 ../../library/xml.dom.minidom.rst:175 +#: ../../library/xml.dom.minidom.rst:194 msgid "The *standalone* parameter was added." msgstr "新增 *standalone* 參數。" -#: ../../library/xml.dom.minidom.rst:163 +#: ../../library/xml.dom.minidom.rst:159 msgid "" "Return a string or byte string containing the XML represented by the DOM " "node." msgstr "" -#: ../../library/xml.dom.minidom.rst:166 +#: ../../library/xml.dom.minidom.rst:162 msgid "" "With an explicit *encoding* [1]_ argument, the result is a byte string in " "the specified encoding. With no *encoding* argument, the result is a Unicode " @@ -266,47 +266,47 @@ msgid "" "incorrect, since UTF-8 is the default encoding of XML." msgstr "" -#: ../../library/xml.dom.minidom.rst:173 ../../library/xml.dom.minidom.rst:192 +#: ../../library/xml.dom.minidom.rst:169 ../../library/xml.dom.minidom.rst:188 msgid "The *standalone* argument behaves exactly as in :meth:`writexml`." msgstr "" -#: ../../library/xml.dom.minidom.rst:175 +#: ../../library/xml.dom.minidom.rst:171 msgid "" "The :meth:`toxml` method now preserves the attribute order specified by the " "user." msgstr "現在 :meth:`toxml` 方法會保留使用者指定的屬性順序。" -#: ../../library/xml.dom.minidom.rst:185 +#: ../../library/xml.dom.minidom.rst:181 msgid "" "Return a pretty-printed version of the document. *indent* specifies the " "indentation string and defaults to a tabulator; *newl* specifies the string " "emitted at the end of each line and defaults to ``\\n``." msgstr "" -#: ../../library/xml.dom.minidom.rst:189 +#: ../../library/xml.dom.minidom.rst:185 msgid "" "The *encoding* argument behaves like the corresponding argument of :meth:" "`toxml`." msgstr "" -#: ../../library/xml.dom.minidom.rst:194 +#: ../../library/xml.dom.minidom.rst:190 msgid "" "The :meth:`toprettyxml` method now preserves the attribute order specified " "by the user." msgstr "" -#: ../../library/xml.dom.minidom.rst:204 +#: ../../library/xml.dom.minidom.rst:200 msgid "DOM Example" msgstr "DOM 範例" -#: ../../library/xml.dom.minidom.rst:206 +#: ../../library/xml.dom.minidom.rst:202 msgid "" "This example program is a fairly realistic example of a simple program. In " "this particular case, we do not take much advantage of the flexibility of " "the DOM." msgstr "" -#: ../../library/xml.dom.minidom.rst:209 +#: ../../library/xml.dom.minidom.rst:205 msgid "" "import xml.dom.minidom\n" "\n" @@ -438,23 +438,23 @@ msgstr "" "\n" "handleSlideshow(dom)\n" -#: ../../library/xml.dom.minidom.rst:215 +#: ../../library/xml.dom.minidom.rst:211 msgid "minidom and the DOM standard" msgstr "minidom 和 DOM 標準" -#: ../../library/xml.dom.minidom.rst:217 +#: ../../library/xml.dom.minidom.rst:213 msgid "" "The :mod:`!xml.dom.minidom` module is essentially a DOM 1.0-compatible DOM " "with some DOM 2 features (primarily namespace features)." msgstr "" -#: ../../library/xml.dom.minidom.rst:220 +#: ../../library/xml.dom.minidom.rst:216 msgid "" "Usage of the DOM interface in Python is straight-forward. The following " "mapping rules apply:" msgstr "" -#: ../../library/xml.dom.minidom.rst:223 +#: ../../library/xml.dom.minidom.rst:219 msgid "" "Interfaces are accessed through instance objects. Applications should not " "instantiate the classes themselves; they should use the creator functions " @@ -463,14 +463,14 @@ msgid "" "operations." msgstr "" -#: ../../library/xml.dom.minidom.rst:228 +#: ../../library/xml.dom.minidom.rst:224 msgid "" "Operations are used as methods. Since the DOM uses only :keyword:`in` " "parameters, the arguments are passed in normal order (from left to right). " "There are no optional arguments. ``void`` operations return ``None``." msgstr "" -#: ../../library/xml.dom.minidom.rst:232 +#: ../../library/xml.dom.minidom.rst:228 msgid "" "IDL attributes map to instance attributes. For compatibility with the OMG " "IDL language mapping for Python, an attribute ``foo`` can also be accessed " @@ -478,13 +478,13 @@ msgid "" "``readonly`` attributes must not be changed; this is not enforced at runtime." msgstr "" -#: ../../library/xml.dom.minidom.rst:237 +#: ../../library/xml.dom.minidom.rst:233 msgid "" "The types ``short int``, ``unsigned int``, ``unsigned long long``, and " "``boolean`` all map to Python integer objects." msgstr "" -#: ../../library/xml.dom.minidom.rst:240 +#: ../../library/xml.dom.minidom.rst:236 msgid "" "The type ``DOMString`` maps to Python strings. :mod:`!xml.dom.minidom` " "supports either bytes or strings, but will normally produce strings. Values " @@ -492,35 +492,35 @@ msgid "" "``null`` value by the DOM specification from the W3C." msgstr "" -#: ../../library/xml.dom.minidom.rst:245 +#: ../../library/xml.dom.minidom.rst:241 msgid "" "``const`` declarations map to variables in their respective scope (e.g. " "``xml.dom.minidom.Node.PROCESSING_INSTRUCTION_NODE``); they must not be " "changed." msgstr "" -#: ../../library/xml.dom.minidom.rst:248 +#: ../../library/xml.dom.minidom.rst:244 msgid "" "``DOMException`` is currently not supported in :mod:`!xml.dom.minidom`. " "Instead, :mod:`!xml.dom.minidom` uses standard Python exceptions such as :" "exc:`TypeError` and :exc:`AttributeError`." msgstr "" -#: ../../library/xml.dom.minidom.rst:252 +#: ../../library/xml.dom.minidom.rst:248 msgid "" "Each of the :class:`~xml.dom.NodeList` and :class:`~xml.dom.NamedNodeMap` " "interfaces has two implementations, which provide additional methods and " "operations." msgstr "" -#: ../../library/xml.dom.minidom.rst:256 +#: ../../library/xml.dom.minidom.rst:252 msgid "" ":attr:`~xml.dom.Node.childNodes` is a subclass of :class:`list`, or, for " "nodes which cannot have children, a subclass of :class:`tuple`. It supports " "iteration, concatenation, indexing and slicing." msgstr "" -#: ../../library/xml.dom.minidom.rst:260 +#: ../../library/xml.dom.minidom.rst:256 msgid "" ":attr:`~xml.dom.Node.attributes` supports ``len()``, the :keyword:`in` " "operator, subscription by a name or by a ``(namespaceURI, localName)`` " @@ -531,43 +531,43 @@ msgid "" "subscription by a name." msgstr "" -#: ../../library/xml.dom.minidom.rst:268 +#: ../../library/xml.dom.minidom.rst:264 msgid "" ":attr:`~xml.dom.Document.strictErrorChecking` and :attr:`~xml.dom.Attr." "specified` are always ``False``." msgstr "" -#: ../../library/xml.dom.minidom.rst:271 +#: ../../library/xml.dom.minidom.rst:267 msgid "" ":meth:`~xml.dom.Element.removeAttribute` and :meth:`~xml.dom.Element." "removeAttributeNS` raise :exc:`~xml.dom.NotFoundErr` if there is no matching " "attribute, while the DOM specifies that this has no effect." msgstr "" -#: ../../library/xml.dom.minidom.rst:276 +#: ../../library/xml.dom.minidom.rst:272 msgid "" "The following interfaces have no implementation in :mod:`!xml.dom.minidom`:" msgstr "" -#: ../../library/xml.dom.minidom.rst:278 +#: ../../library/xml.dom.minidom.rst:274 msgid ":class:`DOMTimeStamp`" msgstr ":class:`DOMTimeStamp`" -#: ../../library/xml.dom.minidom.rst:280 +#: ../../library/xml.dom.minidom.rst:276 msgid ":class:`EntityReference`" msgstr ":class:`EntityReference`" -#: ../../library/xml.dom.minidom.rst:282 +#: ../../library/xml.dom.minidom.rst:278 msgid "" "Most of these reflect information in the XML document that is not of general " "utility to most DOM users." msgstr "" -#: ../../library/xml.dom.minidom.rst:286 +#: ../../library/xml.dom.minidom.rst:282 msgid "Footnotes" msgstr "註腳" -#: ../../library/xml.dom.minidom.rst:287 +#: ../../library/xml.dom.minidom.rst:283 msgid "" "The encoding name included in the XML output should conform to the " "appropriate standards. For example, \"UTF-8\" is valid, but \"UTF8\" is not " diff --git a/library/xml.dom.po b/library/xml.dom.po index 292746ef0ad..f69a7c3c064 100644 --- a/library/xml.dom.po +++ b/library/xml.dom.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-03 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:16+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!xml.dom` --- The Document Object Model API" msgstr ":mod:`!xml.dom` --- Document 物件模型 API" -#: ../../library/xml.dom.rst:10 +#: ../../library/xml.dom.rst:7 msgid "**Source code:** :source:`Lib/xml/dom/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/xml/dom/__init__.py`" -#: ../../library/xml.dom.rst:14 +#: ../../library/xml.dom.rst:11 msgid "" "The Document Object Model, or \"DOM,\" is a cross-language API from the " "World Wide Web Consortium (W3C) for accessing and modifying XML documents. " @@ -34,7 +34,7 @@ msgid "" "the structure through a set of objects which provided well-known interfaces." msgstr "" -#: ../../library/xml.dom.rst:20 +#: ../../library/xml.dom.rst:17 msgid "" "The DOM is extremely useful for random-access applications. SAX only allows " "you a view of one bit of the document at a time. If you are looking at one " @@ -45,7 +45,7 @@ msgid "" "you need to look ahead in the XML document, you are just out of luck." msgstr "" -#: ../../library/xml.dom.rst:28 +#: ../../library/xml.dom.rst:25 msgid "" "Some applications are simply impossible in an event driven model with no " "access to a tree. Of course you could build some sort of tree yourself in " @@ -53,14 +53,14 @@ msgid "" "standard tree representation for XML data." msgstr "" -#: ../../library/xml.dom.rst:33 +#: ../../library/xml.dom.rst:30 msgid "" "The Document Object Model is being defined by the W3C in stages, or " "\"levels\" in their terminology. The Python mapping of the API is " "substantially based on the DOM Level 2 recommendation." msgstr "" -#: ../../library/xml.dom.rst:37 +#: ../../library/xml.dom.rst:34 msgid "" "DOM applications typically start by parsing some XML into a DOM. How this " "is accomplished is not covered at all by DOM Level 1, and Level 2 provides " @@ -74,7 +74,7 @@ msgid "" "reader, but this is not yet available in the Python standard library." msgstr "" -#: ../../library/xml.dom.rst:48 +#: ../../library/xml.dom.rst:45 msgid "" "Once you have a DOM document object, you can access the parts of your XML " "document through its properties and methods. These properties are defined " @@ -82,7 +82,7 @@ msgid "" "interpretation of the specification in Python." msgstr "" -#: ../../library/xml.dom.rst:53 +#: ../../library/xml.dom.rst:50 msgid "" "The specification provided by the W3C defines the DOM API for Java, " "ECMAScript, and OMG IDL. The Python mapping defined here is based in large " @@ -92,45 +92,45 @@ msgid "" "mapping requirements." msgstr "" -#: ../../library/xml.dom.rst:62 +#: ../../library/xml.dom.rst:59 msgid "" "`Document Object Model (DOM) Level 2 Specification `_" msgstr "" -#: ../../library/xml.dom.rst:63 +#: ../../library/xml.dom.rst:60 msgid "The W3C recommendation upon which the Python DOM API is based." msgstr "" -#: ../../library/xml.dom.rst:65 +#: ../../library/xml.dom.rst:62 msgid "" "`Document Object Model (DOM) Level 1 Specification `_" msgstr "" -#: ../../library/xml.dom.rst:66 +#: ../../library/xml.dom.rst:63 msgid "The W3C recommendation for the DOM supported by :mod:`xml.dom.minidom`." msgstr "" -#: ../../library/xml.dom.rst:68 +#: ../../library/xml.dom.rst:65 msgid "" "`Python Language Mapping Specification `_" msgstr "" -#: ../../library/xml.dom.rst:69 +#: ../../library/xml.dom.rst:66 msgid "This specifies the mapping from OMG IDL to Python." msgstr "" -#: ../../library/xml.dom.rst:73 +#: ../../library/xml.dom.rst:70 msgid "Module Contents" msgstr "模組內容" -#: ../../library/xml.dom.rst:75 +#: ../../library/xml.dom.rst:72 msgid "The :mod:`!xml.dom` contains the following functions:" msgstr "" -#: ../../library/xml.dom.rst:80 +#: ../../library/xml.dom.rst:77 msgid "" "Register the *factory* function with the name *name*. The factory function " "should return an object which implements the :class:`DOMImplementation` " @@ -139,7 +139,7 @@ msgid "" "if that implementation supports some customization)." msgstr "" -#: ../../library/xml.dom.rst:89 +#: ../../library/xml.dom.rst:86 msgid "" "Return a suitable DOM implementation. The *name* is either well-known, the " "module name of a DOM implementation, or ``None``. If it is not ``None``, " @@ -150,7 +150,7 @@ msgid "" "``'minidom'``, for :mod:`xml.dom.minidom`." msgstr "" -#: ../../library/xml.dom.rst:97 +#: ../../library/xml.dom.rst:94 msgid "" "If name is not given, this examines the available implementations to find " "one with the required feature set. If no implementation can be found, raise " @@ -159,11 +159,11 @@ msgid "" "hasFeature` method on available :class:`DOMImplementation` objects." msgstr "" -#: ../../library/xml.dom.rst:103 +#: ../../library/xml.dom.rst:100 msgid "Some convenience constants are also provided:" msgstr "" -#: ../../library/xml.dom.rst:108 +#: ../../library/xml.dom.rst:105 msgid "" "The value used to indicate that no namespace is associated with a node in " "the DOM. This is typically found as the :attr:`~Node.namespaceURI` of a " @@ -171,26 +171,26 @@ msgid "" "method." msgstr "" -#: ../../library/xml.dom.rst:115 +#: ../../library/xml.dom.rst:112 msgid "" "The namespace URI associated with the reserved prefix ``xml``, as defined by " "`Namespaces in XML `_ (section 4)." msgstr "" -#: ../../library/xml.dom.rst:121 +#: ../../library/xml.dom.rst:118 msgid "" "The namespace URI for namespace declarations, as defined by `Document Object " "Model (DOM) Level 2 Core Specification `_ (section 1.1.8)." msgstr "" -#: ../../library/xml.dom.rst:128 +#: ../../library/xml.dom.rst:125 msgid "" "The URI of the XHTML namespace as defined by `XHTML 1.0: The Extensible " "HyperText Markup Language `_ (section 3.1.1)." msgstr "" -#: ../../library/xml.dom.rst:132 +#: ../../library/xml.dom.rst:129 msgid "" "In addition, :mod:`!xml.dom` contains a base :class:`Node` class and the DOM " "exception classes. The :class:`Node` class provided by this module does not " @@ -202,17 +202,17 @@ msgid "" "DOM specifications." msgstr "" -#: ../../library/xml.dom.rst:147 +#: ../../library/xml.dom.rst:144 msgid "Objects in the DOM" msgstr "" -#: ../../library/xml.dom.rst:149 +#: ../../library/xml.dom.rst:146 msgid "" "The definitive documentation for the DOM is the DOM specification from the " "W3C." msgstr "" -#: ../../library/xml.dom.rst:151 +#: ../../library/xml.dom.rst:148 msgid "" "The names documented in this section are DOM interfaces. With the exception " "of :class:`Node` and the exception classes, they are not provided by the :" @@ -220,159 +220,159 @@ msgid "" "mod:`xml.dom.minidom`." msgstr "" -#: ../../library/xml.dom.rst:156 +#: ../../library/xml.dom.rst:153 msgid "" "Note that DOM attributes may also be manipulated as nodes instead of as " "simple strings. It is fairly rare that you must do this, however, so this " "usage is not yet documented." msgstr "" -#: ../../library/xml.dom.rst:161 +#: ../../library/xml.dom.rst:158 msgid "Interface" msgstr "" -#: ../../library/xml.dom.rst:161 +#: ../../library/xml.dom.rst:158 msgid "Section" msgstr "" -#: ../../library/xml.dom.rst:161 +#: ../../library/xml.dom.rst:158 msgid "Purpose" msgstr "" -#: ../../library/xml.dom.rst:163 +#: ../../library/xml.dom.rst:160 msgid ":class:`DOMImplementation`" msgstr ":class:`DOMImplementation`" -#: ../../library/xml.dom.rst:163 +#: ../../library/xml.dom.rst:160 msgid ":ref:`dom-implementation-objects`" msgstr ":ref:`dom-implementation-objects`" -#: ../../library/xml.dom.rst:163 +#: ../../library/xml.dom.rst:160 msgid "Interface to the underlying implementation." msgstr "" -#: ../../library/xml.dom.rst:166 +#: ../../library/xml.dom.rst:163 msgid ":class:`Node`" msgstr ":class:`Node`" -#: ../../library/xml.dom.rst:166 +#: ../../library/xml.dom.rst:163 msgid ":ref:`dom-node-objects`" msgstr ":ref:`dom-node-objects`" -#: ../../library/xml.dom.rst:166 +#: ../../library/xml.dom.rst:163 msgid "Base interface for most objects in a document." msgstr "" -#: ../../library/xml.dom.rst:169 +#: ../../library/xml.dom.rst:166 msgid ":class:`NodeList`" msgstr ":class:`NodeList`" -#: ../../library/xml.dom.rst:169 +#: ../../library/xml.dom.rst:166 msgid ":ref:`dom-nodelist-objects`" msgstr ":ref:`dom-nodelist-objects`" -#: ../../library/xml.dom.rst:169 +#: ../../library/xml.dom.rst:166 msgid "Interface for a sequence of nodes." msgstr "" -#: ../../library/xml.dom.rst:172 ../../library/xml.dom.rst:417 +#: ../../library/xml.dom.rst:169 ../../library/xml.dom.rst:414 msgid ":class:`DocumentType`" msgstr ":class:`DocumentType`" -#: ../../library/xml.dom.rst:172 +#: ../../library/xml.dom.rst:169 msgid ":ref:`dom-documenttype-objects`" msgstr ":ref:`dom-documenttype-objects`" -#: ../../library/xml.dom.rst:172 +#: ../../library/xml.dom.rst:169 msgid "Information about the declarations needed to process a document." msgstr "" -#: ../../library/xml.dom.rst:176 ../../library/xml.dom.rst:249 -#: ../../library/xml.dom.rst:413 +#: ../../library/xml.dom.rst:173 ../../library/xml.dom.rst:246 +#: ../../library/xml.dom.rst:410 msgid ":class:`Document`" msgstr ":class:`Document`" -#: ../../library/xml.dom.rst:176 +#: ../../library/xml.dom.rst:173 msgid ":ref:`dom-document-objects`" msgstr ":ref:`dom-document-objects`" -#: ../../library/xml.dom.rst:176 +#: ../../library/xml.dom.rst:173 msgid "Object which represents an entire document." msgstr "" -#: ../../library/xml.dom.rst:179 ../../library/xml.dom.rst:419 +#: ../../library/xml.dom.rst:176 ../../library/xml.dom.rst:416 msgid ":class:`Element`" msgstr ":class:`Element`" -#: ../../library/xml.dom.rst:179 +#: ../../library/xml.dom.rst:176 msgid ":ref:`dom-element-objects`" msgstr ":ref:`dom-element-objects`" -#: ../../library/xml.dom.rst:179 +#: ../../library/xml.dom.rst:176 msgid "Element nodes in the document hierarchy." msgstr "" -#: ../../library/xml.dom.rst:182 ../../library/xml.dom.rst:257 -#: ../../library/xml.dom.rst:407 +#: ../../library/xml.dom.rst:179 ../../library/xml.dom.rst:254 +#: ../../library/xml.dom.rst:404 msgid ":class:`Attr`" msgstr ":class:`Attr`" -#: ../../library/xml.dom.rst:182 +#: ../../library/xml.dom.rst:179 msgid ":ref:`dom-attr-objects`" msgstr ":ref:`dom-attr-objects`" -#: ../../library/xml.dom.rst:182 +#: ../../library/xml.dom.rst:179 msgid "Attribute value nodes on element nodes." msgstr "" -#: ../../library/xml.dom.rst:185 ../../library/xml.dom.rst:411 +#: ../../library/xml.dom.rst:182 ../../library/xml.dom.rst:408 msgid ":class:`Comment`" msgstr ":class:`Comment`" -#: ../../library/xml.dom.rst:185 +#: ../../library/xml.dom.rst:182 msgid ":ref:`dom-comment-objects`" msgstr ":ref:`dom-comment-objects`" -#: ../../library/xml.dom.rst:185 +#: ../../library/xml.dom.rst:182 msgid "Representation of comments in the source document." msgstr "" -#: ../../library/xml.dom.rst:188 ../../library/xml.dom.rst:258 -#: ../../library/xml.dom.rst:427 +#: ../../library/xml.dom.rst:185 ../../library/xml.dom.rst:255 +#: ../../library/xml.dom.rst:424 msgid ":class:`Text`" msgstr ":class:`Text`" -#: ../../library/xml.dom.rst:188 +#: ../../library/xml.dom.rst:185 msgid ":ref:`dom-text-objects`" msgstr ":ref:`dom-text-objects`" -#: ../../library/xml.dom.rst:188 +#: ../../library/xml.dom.rst:185 msgid "Nodes containing textual content from the document." msgstr "" -#: ../../library/xml.dom.rst:191 ../../library/xml.dom.rst:425 +#: ../../library/xml.dom.rst:188 ../../library/xml.dom.rst:422 msgid ":class:`ProcessingInstruction`" msgstr ":class:`ProcessingInstruction`" -#: ../../library/xml.dom.rst:191 +#: ../../library/xml.dom.rst:188 msgid ":ref:`dom-pi-objects`" msgstr ":ref:`dom-pi-objects`" -#: ../../library/xml.dom.rst:191 +#: ../../library/xml.dom.rst:188 msgid "Processing instruction representation." msgstr "" -#: ../../library/xml.dom.rst:195 +#: ../../library/xml.dom.rst:192 msgid "" "An additional section describes the exceptions defined for working with the " "DOM in Python." msgstr "" -#: ../../library/xml.dom.rst:202 +#: ../../library/xml.dom.rst:199 msgid "DOMImplementation Objects" msgstr "DOMImplementation 物件" -#: ../../library/xml.dom.rst:207 +#: ../../library/xml.dom.rst:204 msgid "" "The :class:`DOMImplementation` interface provides a way for applications to " "determine the availability of particular features in the DOM they are using. " @@ -380,13 +380,13 @@ msgid "" "`DocumentType` objects using the :class:`DOMImplementation` as well." msgstr "" -#: ../../library/xml.dom.rst:215 +#: ../../library/xml.dom.rst:212 msgid "" "Return ``True`` if the feature identified by the pair of strings *feature* " "and *version* is implemented." msgstr "" -#: ../../library/xml.dom.rst:221 +#: ../../library/xml.dom.rst:218 msgid "" "Return a new :class:`Document` object (the root of the DOM), with a child :" "class:`Element` object having the given *namespaceUri* and *qualifiedName*. " @@ -396,63 +396,63 @@ msgid "" "child is to be created." msgstr "" -#: ../../library/xml.dom.rst:231 +#: ../../library/xml.dom.rst:228 msgid "" "Return a new :class:`DocumentType` object that encapsulates the given " "*qualifiedName*, *publicId*, and *systemId* strings, representing the " "information contained in an XML document type declaration." msgstr "" -#: ../../library/xml.dom.rst:239 +#: ../../library/xml.dom.rst:236 msgid "Node Objects" msgstr "" -#: ../../library/xml.dom.rst:244 +#: ../../library/xml.dom.rst:241 msgid "" "All of the components of an XML document are subclasses of :class:`Node`." msgstr "" -#: ../../library/xml.dom.rst:246 +#: ../../library/xml.dom.rst:243 msgid "" "Only nodes of the following types can have children, and only children of " "the listed types:" msgstr "" -#: ../../library/xml.dom.rst:250 +#: ../../library/xml.dom.rst:247 msgid "" "at most one :class:`Element`, at most one :class:`DocumentType`, :class:" "`ProcessingInstruction` and :class:`Comment`" msgstr "" -#: ../../library/xml.dom.rst:253 +#: ../../library/xml.dom.rst:250 msgid ":class:`DocumentFragment` and :class:`Element`" msgstr "" -#: ../../library/xml.dom.rst:254 +#: ../../library/xml.dom.rst:251 msgid "" ":class:`Element`, :class:`Text`, :class:`CDATASection`, :class:" "`ProcessingInstruction` and :class:`Comment`" msgstr "" -#: ../../library/xml.dom.rst:260 +#: ../../library/xml.dom.rst:257 msgid "" "Nodes of other types cannot have children. Inserting a child of a not " "allowed type raises :exc:`HierarchyRequestErr`." msgstr "" -#: ../../library/xml.dom.rst:266 +#: ../../library/xml.dom.rst:263 msgid "" "An integer representing the node type. Symbolic constants for the types are " "on the :class:`Node` object. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:284 +#: ../../library/xml.dom.rst:281 msgid "" "Integer constants for the possible values of the :attr:`~Node.nodeType` " "attribute." msgstr "" -#: ../../library/xml.dom.rst:290 +#: ../../library/xml.dom.rst:287 msgid "" "The parent of the current node, or ``None`` for the document node. The value " "is always a :class:`Node` object or ``None``. For :class:`Element` nodes, " @@ -461,14 +461,14 @@ msgid "" "always ``None``. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:299 +#: ../../library/xml.dom.rst:296 msgid "" "A :class:`NamedNodeMap` of attribute objects. Only elements have actual " "values for this; others provide ``None`` for this attribute. This is a read-" "only attribute." msgstr "" -#: ../../library/xml.dom.rst:306 +#: ../../library/xml.dom.rst:303 msgid "" "The node that immediately precedes this one with the same parent. For " "instance the element with an end-tag that comes just before the *self* " @@ -478,62 +478,62 @@ msgid "" "``None``. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:316 +#: ../../library/xml.dom.rst:313 msgid "" "The node that immediately follows this one with the same parent. See also :" "attr:`previousSibling`. If this is the last child of the parent, this " "attribute will be ``None``. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:323 +#: ../../library/xml.dom.rst:320 msgid "" "A :class:`NodeList` of the children of this node. If the node has no " "children, the list is empty. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:330 +#: ../../library/xml.dom.rst:327 msgid "" "The first child of the node, if there are any, or ``None``. This is a read-" "only attribute." msgstr "" -#: ../../library/xml.dom.rst:336 +#: ../../library/xml.dom.rst:333 msgid "" "The last child of the node, if there are any, or ``None``. This is a read-" "only attribute." msgstr "" -#: ../../library/xml.dom.rst:342 +#: ../../library/xml.dom.rst:339 msgid "" "The part of the :attr:`~Element.tagName` following the colon if there is " "one, else the entire :attr:`~Element.tagName`. The value is a string." msgstr "" -#: ../../library/xml.dom.rst:348 +#: ../../library/xml.dom.rst:345 msgid "" "The part of the :attr:`~Element.tagName` preceding the colon if there is " "one, else the empty string. The value is a string, or ``None``." msgstr "" -#: ../../library/xml.dom.rst:354 +#: ../../library/xml.dom.rst:351 msgid "" "The namespace associated with the element name. This will be a string or " "``None``. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:360 +#: ../../library/xml.dom.rst:357 msgid "" "The :class:`Document` object to which this node belongs, or ``None`` for a " "document itself. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:367 +#: ../../library/xml.dom.rst:364 msgid "" "Return whether the DOM implementation supports a particular *feature*, as :" "meth:`DOMImplementation.hasFeature` does." msgstr "" -#: ../../library/xml.dom.rst:373 +#: ../../library/xml.dom.rst:370 msgid "" "Associate *data* with *key* on this node and return the data previously " "associated with *key*, or ``None``. If *data* is ``None``, the association " @@ -541,13 +541,13 @@ msgid "" "or deleted; pass ``None`` if no notification is needed." msgstr "" -#: ../../library/xml.dom.rst:382 +#: ../../library/xml.dom.rst:379 msgid "" "Return the data associated with *key* on this node by :meth:`~Node." "setUserData`, or ``None``." msgstr "" -#: ../../library/xml.dom.rst:388 +#: ../../library/xml.dom.rst:385 msgid "" "The name of this node, depending on its type; see the table below. You can " "always get the information you would get here from another property such as " @@ -555,126 +555,126 @@ msgid "" "property for attributes. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:397 +#: ../../library/xml.dom.rst:394 msgid "" "The value of this node, depending on its type; see the table below. The " "value is a string or ``None``." msgstr "" -#: ../../library/xml.dom.rst:401 +#: ../../library/xml.dom.rst:398 msgid "" "The values of :attr:`~Node.nodeName` and :attr:`~Node.nodeValue` for each " "node type are:" msgstr "" -#: ../../library/xml.dom.rst:405 +#: ../../library/xml.dom.rst:402 msgid "Node type" msgstr "" -#: ../../library/xml.dom.rst:405 +#: ../../library/xml.dom.rst:402 msgid "nodeName" msgstr "" -#: ../../library/xml.dom.rst:405 +#: ../../library/xml.dom.rst:402 msgid "nodeValue" msgstr "" -#: ../../library/xml.dom.rst:407 +#: ../../library/xml.dom.rst:404 msgid ":attr:`~Attr.name`" msgstr ":attr:`~Attr.name`" -#: ../../library/xml.dom.rst:407 +#: ../../library/xml.dom.rst:404 msgid ":attr:`~Attr.value`" msgstr ":attr:`~Attr.value`" -#: ../../library/xml.dom.rst:409 +#: ../../library/xml.dom.rst:406 msgid ":class:`CDATASection`" msgstr ":class:`CDATASection`" -#: ../../library/xml.dom.rst:409 +#: ../../library/xml.dom.rst:406 msgid "``'#cdata-section'``" msgstr "``'#cdata-section'``" -#: ../../library/xml.dom.rst:409 ../../library/xml.dom.rst:411 -#: ../../library/xml.dom.rst:427 +#: ../../library/xml.dom.rst:406 ../../library/xml.dom.rst:408 +#: ../../library/xml.dom.rst:424 msgid "the content" msgstr "內容" -#: ../../library/xml.dom.rst:411 +#: ../../library/xml.dom.rst:408 msgid "``'#comment'``" msgstr "``'#comment'``" -#: ../../library/xml.dom.rst:413 +#: ../../library/xml.dom.rst:410 msgid "``'#document'``" msgstr "``'#document'``" -#: ../../library/xml.dom.rst:413 ../../library/xml.dom.rst:415 -#: ../../library/xml.dom.rst:417 ../../library/xml.dom.rst:419 -#: ../../library/xml.dom.rst:421 ../../library/xml.dom.rst:423 -#: ../../library/xml.dom.rst:1427 +#: ../../library/xml.dom.rst:410 ../../library/xml.dom.rst:412 +#: ../../library/xml.dom.rst:414 ../../library/xml.dom.rst:416 +#: ../../library/xml.dom.rst:418 ../../library/xml.dom.rst:420 +#: ../../library/xml.dom.rst:1424 msgid "``None``" msgstr "``None``" -#: ../../library/xml.dom.rst:415 +#: ../../library/xml.dom.rst:412 msgid ":class:`DocumentFragment`" msgstr ":class:`DocumentFragment`" -#: ../../library/xml.dom.rst:415 +#: ../../library/xml.dom.rst:412 msgid "``'#document-fragment'``" msgstr "``'#document-fragment'``" -#: ../../library/xml.dom.rst:417 +#: ../../library/xml.dom.rst:414 msgid ":attr:`~DocumentType.name`" msgstr ":attr:`~DocumentType.name`" -#: ../../library/xml.dom.rst:419 +#: ../../library/xml.dom.rst:416 msgid ":attr:`~Element.tagName`" msgstr ":attr:`~Element.tagName`" -#: ../../library/xml.dom.rst:421 +#: ../../library/xml.dom.rst:418 msgid ":class:`Entity`" msgstr ":class:`Entity`" -#: ../../library/xml.dom.rst:421 +#: ../../library/xml.dom.rst:418 msgid "the name of the entity" msgstr "" -#: ../../library/xml.dom.rst:423 +#: ../../library/xml.dom.rst:420 msgid ":class:`Notation`" msgstr ":class:`Notation`" -#: ../../library/xml.dom.rst:423 +#: ../../library/xml.dom.rst:420 msgid "the name of the notation" msgstr "" -#: ../../library/xml.dom.rst:425 +#: ../../library/xml.dom.rst:422 msgid ":attr:`~ProcessingInstruction.target`" msgstr ":attr:`~ProcessingInstruction.target`" -#: ../../library/xml.dom.rst:425 +#: ../../library/xml.dom.rst:422 msgid ":attr:`~ProcessingInstruction.data`" msgstr ":attr:`~ProcessingInstruction.data`" -#: ../../library/xml.dom.rst:427 +#: ../../library/xml.dom.rst:424 msgid "``'#text'``" msgstr "``'#text'``" -#: ../../library/xml.dom.rst:432 +#: ../../library/xml.dom.rst:429 msgid "Return ``True`` if the node has any attributes." msgstr "" -#: ../../library/xml.dom.rst:437 +#: ../../library/xml.dom.rst:434 msgid "Return ``True`` if the node has any child nodes." msgstr "" -#: ../../library/xml.dom.rst:442 +#: ../../library/xml.dom.rst:439 msgid "" "Return ``True`` if *other* refers to the same node as this node. This is " "especially useful for DOM implementations which use any sort of proxy " "architecture (because more than one object can refer to the same node)." msgstr "" -#: ../../library/xml.dom.rst:448 +#: ../../library/xml.dom.rst:445 msgid "" "This is based on a proposed DOM Level 3 API which is still in the \"working " "draft\" stage, but this particular interface appears uncontroversial. " @@ -682,14 +682,14 @@ msgid "" "DOM interface (though any new W3C API for this would also be supported)." msgstr "" -#: ../../library/xml.dom.rst:456 +#: ../../library/xml.dom.rst:453 msgid "" "Add a new child node to this node at the end of the list of children, " "returning *newChild*. If the node was already in the tree, it is removed " "first." msgstr "" -#: ../../library/xml.dom.rst:463 +#: ../../library/xml.dom.rst:460 msgid "" "Insert a new child node before an existing child. It must be the case that " "*refChild* is a child of this node; if not, :exc:`NotFoundErr` is raised. " @@ -697,7 +697,7 @@ msgid "" "the end of the children's list." msgstr "" -#: ../../library/xml.dom.rst:471 +#: ../../library/xml.dom.rst:468 msgid "" "Remove a child node. *oldChild* must be a child of this node; if not, :exc:" "`NotFoundErr` is raised. *oldChild* is returned on success. If *oldChild* " @@ -705,30 +705,30 @@ msgid "" "should be called." msgstr "" -#: ../../library/xml.dom.rst:479 +#: ../../library/xml.dom.rst:476 msgid "" "Replace an existing node with a new node. It must be the case that " "*oldChild* is a child of this node; if not, :exc:`NotFoundErr` is raised." msgstr "" -#: ../../library/xml.dom.rst:485 +#: ../../library/xml.dom.rst:482 msgid "" "Join adjacent text nodes so that all stretches of text are stored as single :" "class:`Text` instances. This simplifies processing text from a DOM tree for " "many applications." msgstr "" -#: ../../library/xml.dom.rst:492 +#: ../../library/xml.dom.rst:489 msgid "" "Clone this node. Setting *deep* means to clone all child nodes as well. " "This returns the clone." msgstr "" -#: ../../library/xml.dom.rst:499 +#: ../../library/xml.dom.rst:496 msgid "NodeList Objects" msgstr "NodeList 物件" -#: ../../library/xml.dom.rst:504 +#: ../../library/xml.dom.rst:501 msgid "" "A :class:`NodeList` represents a sequence of nodes. These objects are used " "in two ways in the DOM Core recommendation: an :class:`Element` object " @@ -738,27 +738,27 @@ msgid "" "results." msgstr "" -#: ../../library/xml.dom.rst:510 +#: ../../library/xml.dom.rst:507 msgid ":class:`NodeList` does *not* inherit from :class:`Node`." msgstr "" -#: ../../library/xml.dom.rst:512 +#: ../../library/xml.dom.rst:509 msgid "" "The DOM Level 2 recommendation defines one method and one attribute for " "these objects:" msgstr "" -#: ../../library/xml.dom.rst:518 +#: ../../library/xml.dom.rst:515 msgid "" "Return the *i*'th item from the sequence, or ``None`` if *i* is out of " "range. Negative indices are not supported." msgstr "" -#: ../../library/xml.dom.rst:525 +#: ../../library/xml.dom.rst:522 msgid "The number of nodes in the sequence." msgstr "" -#: ../../library/xml.dom.rst:527 +#: ../../library/xml.dom.rst:524 msgid "" "In addition, the Python DOM interface requires that some additional support " "is provided to allow :class:`NodeList` objects to be used as Python " @@ -768,18 +768,18 @@ msgid "" "support for the :func:`len` built-in function." msgstr "" -#: ../../library/xml.dom.rst:535 +#: ../../library/xml.dom.rst:532 msgid "" "If a DOM implementation supports modification of the document, the :class:" "`NodeList` implementation must also support the :meth:`~object.__setitem__` " "and :meth:`~object.__delitem__` methods." msgstr "" -#: ../../library/xml.dom.rst:543 +#: ../../library/xml.dom.rst:540 msgid "DocumentType Objects" msgstr "DocumentType 物件" -#: ../../library/xml.dom.rst:548 +#: ../../library/xml.dom.rst:545 msgid "" "Information about the notations and entities declared by a document " "(including the external subset if the parser uses it and can provide the " @@ -790,38 +790,38 @@ msgid "" "attribute will be set to ``None`` instead of an instance of this interface." msgstr "" -#: ../../library/xml.dom.rst:556 +#: ../../library/xml.dom.rst:553 msgid "" ":class:`DocumentType` is a specialization of :class:`Node`, and adds the " "following attributes:" msgstr "" -#: ../../library/xml.dom.rst:562 +#: ../../library/xml.dom.rst:559 msgid "" "The public identifier for the external subset of the document type " "definition, or ``None`` if the ``DOCTYPE`` declaration does not specify it." msgstr "" -#: ../../library/xml.dom.rst:568 +#: ../../library/xml.dom.rst:565 msgid "" "The system identifier, a URI, for the external subset of the document type " "definition, or ``None`` if the ``DOCTYPE`` declaration does not specify it." msgstr "" -#: ../../library/xml.dom.rst:574 +#: ../../library/xml.dom.rst:571 msgid "" "A string giving the complete internal subset from the document. This does " "not include the brackets which enclose the subset. If the document has no " "internal subset, this should be ``None``." msgstr "" -#: ../../library/xml.dom.rst:581 +#: ../../library/xml.dom.rst:578 msgid "" "The name of the root element as given in the ``DOCTYPE`` declaration, if " "present." msgstr "" -#: ../../library/xml.dom.rst:587 +#: ../../library/xml.dom.rst:584 msgid "" "This is a :class:`NamedNodeMap` of :class:`Entity` nodes giving the " "definitions of external entities. For entity names defined more than once, " @@ -830,7 +830,7 @@ msgid "" "provided by the parser, or if no entities are defined." msgstr "" -#: ../../library/xml.dom.rst:597 +#: ../../library/xml.dom.rst:594 msgid "" "This is a :class:`NamedNodeMap` of :class:`Notation` nodes giving the " "definitions of notations. For notation names defined more than once, only " @@ -839,57 +839,57 @@ msgid "" "the parser, or if no notations are defined." msgstr "" -#: ../../library/xml.dom.rst:608 +#: ../../library/xml.dom.rst:605 msgid "Document Objects" msgstr "" -#: ../../library/xml.dom.rst:613 +#: ../../library/xml.dom.rst:610 msgid "" "A :class:`Document` represents an entire XML document, including its " "constituent elements, attributes, processing instructions, comments etc. " "Remember that it inherits properties from :class:`Node`." msgstr "" -#: ../../library/xml.dom.rst:620 +#: ../../library/xml.dom.rst:617 msgid "The one and only root element of the document." msgstr "" -#: ../../library/xml.dom.rst:625 +#: ../../library/xml.dom.rst:622 msgid "" "The :class:`DocumentType` node of the document, or ``None``. This is a read-" "only attribute." msgstr "" -#: ../../library/xml.dom.rst:631 +#: ../../library/xml.dom.rst:628 msgid "" "The :class:`DOMImplementation` object which created this document. This is a " "read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:637 +#: ../../library/xml.dom.rst:634 msgid "Whether error checking is enforced." msgstr "" -#: ../../library/xml.dom.rst:642 +#: ../../library/xml.dom.rst:639 msgid "The location of the document, or ``None`` if it is unknown." msgstr "" -#: ../../library/xml.dom.rst:647 +#: ../../library/xml.dom.rst:644 msgid "Create and return an empty :class:`DocumentFragment` node." msgstr "" -#: ../../library/xml.dom.rst:652 +#: ../../library/xml.dom.rst:649 msgid "Create and return a :class:`CDATASection` node containing *data*." msgstr "" -#: ../../library/xml.dom.rst:657 +#: ../../library/xml.dom.rst:654 msgid "" "Return a copy of *importedNode* which belongs to this document. The original " "node is not removed from its document. If *deep* is true, the descendants of " "the node are copied too." msgstr "" -#: ../../library/xml.dom.rst:664 +#: ../../library/xml.dom.rst:661 msgid "" "Create and return a new element node. The element is not inserted into the " "document when it is created. You need to explicitly insert it with one of " @@ -897,7 +897,7 @@ msgid "" "appendChild`." msgstr "" -#: ../../library/xml.dom.rst:671 +#: ../../library/xml.dom.rst:668 msgid "" "Create and return a new element with a namespace. The *tagName* may have a " "prefix. The element is not inserted into the document when it is created. " @@ -905,28 +905,28 @@ msgid "" "`~Node.insertBefore` or :meth:`~Node.appendChild`." msgstr "" -#: ../../library/xml.dom.rst:679 +#: ../../library/xml.dom.rst:676 msgid "" "Create and return a text node containing the data passed as a parameter. As " "with the other creation methods, this one does not insert the node into the " "tree." msgstr "" -#: ../../library/xml.dom.rst:686 +#: ../../library/xml.dom.rst:683 msgid "" "Create and return a comment node containing the data passed as a parameter. " "As with the other creation methods, this one does not insert the node into " "the tree." msgstr "" -#: ../../library/xml.dom.rst:693 +#: ../../library/xml.dom.rst:690 msgid "" "Create and return a processing instruction node containing the *target* and " "*data* passed as parameters. As with the other creation methods, this one " "does not insert the node into the tree." msgstr "" -#: ../../library/xml.dom.rst:700 +#: ../../library/xml.dom.rst:697 msgid "" "Create and return an attribute node. This method does not associate the " "attribute node with any particular element. You must use :meth:`~Element." @@ -934,7 +934,7 @@ msgid "" "newly created attribute instance." msgstr "" -#: ../../library/xml.dom.rst:708 +#: ../../library/xml.dom.rst:705 msgid "" "Create and return an attribute node with a namespace. The *tagName* may " "have a prefix. This method does not associate the attribute node with any " @@ -943,131 +943,131 @@ msgid "" "instance." msgstr "" -#: ../../library/xml.dom.rst:716 +#: ../../library/xml.dom.rst:713 msgid "" "Return the element with the given ID, or ``None``. Only attributes declared " "as being of type ID in the DTD or by :meth:`Element.setIdAttribute` are " "searched." msgstr "" -#: ../../library/xml.dom.rst:723 +#: ../../library/xml.dom.rst:720 msgid "" "Search for all descendants (direct children, children's children, etc.) with " "a particular element type name." msgstr "" -#: ../../library/xml.dom.rst:729 +#: ../../library/xml.dom.rst:726 msgid "" "Search for all descendants (direct children, children's children, etc.) with " "a particular namespace URI and localname. The localname is the part of the " "namespace after the prefix." msgstr "" -#: ../../library/xml.dom.rst:736 +#: ../../library/xml.dom.rst:733 msgid "" "Rename the element or attribute node *n* and return it. *namespaceURI* is " "the new namespace URI, or :data:`~xml.dom.EMPTY_NAMESPACE` if the node does " "not belong to a namespace. *name* is the new qualified name." msgstr "" -#: ../../library/xml.dom.rst:742 +#: ../../library/xml.dom.rst:739 msgid "" "Raise :exc:`WrongDocumentErr` if *n* was created by another document, and :" "exc:`NotSupportedErr` if it is neither an element nor an attribute." msgstr "" -#: ../../library/xml.dom.rst:749 +#: ../../library/xml.dom.rst:746 msgid "Element Objects" msgstr "" -#: ../../library/xml.dom.rst:754 +#: ../../library/xml.dom.rst:751 msgid "" ":class:`Element` is a subclass of :class:`Node`, so inherits all the " "attributes of that class." msgstr "" -#: ../../library/xml.dom.rst:760 +#: ../../library/xml.dom.rst:757 msgid "" "The element type name. In a namespace-using document it may have colons in " "it. The value is a string." msgstr "" -#: ../../library/xml.dom.rst:766 +#: ../../library/xml.dom.rst:763 msgid "" "Declare that the attribute *name* is of type ID, so that the element is " "found by :meth:`Document.getElementById`. Raise :exc:`NotFoundErr` if the " "element has no such attribute." msgstr "" -#: ../../library/xml.dom.rst:773 +#: ../../library/xml.dom.rst:770 msgid "" "The same as :meth:`~Element.setIdAttribute`, but for an attribute specified " "by its namespace URI and local name." msgstr "" -#: ../../library/xml.dom.rst:779 +#: ../../library/xml.dom.rst:776 msgid "" "The same as :meth:`~Element.setIdAttribute`, but for an already retrieved " "attribute node." msgstr "" -#: ../../library/xml.dom.rst:785 ../../library/xml.dom.rst:790 +#: ../../library/xml.dom.rst:782 ../../library/xml.dom.rst:787 msgid "Same as equivalent method in the :class:`Document` class." msgstr "" -#: ../../library/xml.dom.rst:795 +#: ../../library/xml.dom.rst:792 msgid "Return ``True`` if the element has an attribute named by *name*." msgstr "" -#: ../../library/xml.dom.rst:800 +#: ../../library/xml.dom.rst:797 msgid "" "Return ``True`` if the element has an attribute named by *namespaceURI* and " "*localName*." msgstr "" -#: ../../library/xml.dom.rst:806 +#: ../../library/xml.dom.rst:803 msgid "" "Return the value of the attribute named by *name* as a string. If no such " "attribute exists, an empty string is returned, as if the attribute had no " "value." msgstr "" -#: ../../library/xml.dom.rst:812 +#: ../../library/xml.dom.rst:809 msgid "Return the :class:`Attr` node for the attribute named by *attrname*." msgstr "" -#: ../../library/xml.dom.rst:817 +#: ../../library/xml.dom.rst:814 msgid "" "Return the value of the attribute named by *namespaceURI* and *localName* as " "a string. If no such attribute exists, an empty string is returned, as if " "the attribute had no value." msgstr "" -#: ../../library/xml.dom.rst:824 +#: ../../library/xml.dom.rst:821 msgid "" "Return an attribute value as a node, given a *namespaceURI* and *localName*." msgstr "" -#: ../../library/xml.dom.rst:829 +#: ../../library/xml.dom.rst:826 msgid "Remove an attribute by name." msgstr "" -#: ../../library/xml.dom.rst:834 +#: ../../library/xml.dom.rst:831 msgid "" "Remove and return *oldAttr* from the attribute list, if present. If " "*oldAttr* is not present, :exc:`NotFoundErr` is raised." msgstr "" -#: ../../library/xml.dom.rst:840 +#: ../../library/xml.dom.rst:837 msgid "" "Remove an attribute by name. Note that it uses a localName, not a qname." msgstr "" -#: ../../library/xml.dom.rst:845 +#: ../../library/xml.dom.rst:842 msgid "Set an attribute value from a string." msgstr "" -#: ../../library/xml.dom.rst:850 +#: ../../library/xml.dom.rst:847 msgid "" "Add a new attribute node to the element, replacing an existing attribute if " "necessary if the :attr:`~Attr.name` attribute matches. If a replacement " @@ -1075,7 +1075,7 @@ msgid "" "use, :exc:`InuseAttributeErr` will be raised." msgstr "" -#: ../../library/xml.dom.rst:858 +#: ../../library/xml.dom.rst:855 msgid "" "Add a new attribute node to the element, replacing an existing attribute if " "necessary if the :attr:`~Node.namespaceURI` and :attr:`~Attr.localName` " @@ -1084,22 +1084,22 @@ msgid "" "raised." msgstr "" -#: ../../library/xml.dom.rst:867 +#: ../../library/xml.dom.rst:864 msgid "" "Set an attribute value from a string, given a *namespaceURI* and a *qname*. " "Note that a qname is the whole attribute name. This is different than above." msgstr "" -#: ../../library/xml.dom.rst:874 +#: ../../library/xml.dom.rst:871 msgid "Attr Objects" msgstr "" -#: ../../library/xml.dom.rst:879 +#: ../../library/xml.dom.rst:876 msgid "" ":class:`Attr` inherits from :class:`Node`, so inherits all its attributes." msgstr "" -#: ../../library/xml.dom.rst:881 +#: ../../library/xml.dom.rst:878 msgid "" "Attribute nodes are not part of the document tree. They are contained in " "the :attr:`~Node.attributes` map of an element, not in its children, and " @@ -1107,61 +1107,61 @@ msgid "" "`~Node.nextSibling` are always ``None``." msgstr "" -#: ../../library/xml.dom.rst:890 +#: ../../library/xml.dom.rst:887 msgid "" "The attribute name. In a namespace-using document it may include a colon." msgstr "" -#: ../../library/xml.dom.rst:896 +#: ../../library/xml.dom.rst:893 msgid "" "The part of the name following the colon if there is one, else the entire " "name. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:903 +#: ../../library/xml.dom.rst:900 msgid "" "The part of the name preceding the colon if there is one, else the empty " "string." msgstr "" -#: ../../library/xml.dom.rst:909 +#: ../../library/xml.dom.rst:906 msgid "" "Whether this attribute is of type ID, either because it is declared as such " "in the DTD or because :meth:`Element.setIdAttribute` was used. This is a " "read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:917 +#: ../../library/xml.dom.rst:914 msgid "" "The :class:`Element` node to which this attribute belongs, or ``None`` if it " "is not used. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:924 +#: ../../library/xml.dom.rst:921 msgid "" "Whether the value of the attribute was explicitly set in the document, as " "opposed to being defaulted from the DTD. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:931 +#: ../../library/xml.dom.rst:928 msgid "" "The text value of the attribute. This is a synonym for the :attr:`~Node." "nodeValue` attribute." msgstr "" -#: ../../library/xml.dom.rst:938 +#: ../../library/xml.dom.rst:935 msgid "NamedNodeMap Objects" msgstr "NamedNodeMap 物件" -#: ../../library/xml.dom.rst:943 +#: ../../library/xml.dom.rst:940 msgid ":class:`NamedNodeMap` does *not* inherit from :class:`Node`." msgstr "" -#: ../../library/xml.dom.rst:948 +#: ../../library/xml.dom.rst:945 msgid "The length of the attribute list." msgstr "" -#: ../../library/xml.dom.rst:953 +#: ../../library/xml.dom.rst:950 msgid "" "Return an attribute with a particular index. The order you get the " "attributes in is arbitrary but will be consistent for the life of a DOM. " @@ -1169,128 +1169,128 @@ msgid "" "attribute." msgstr "" -#: ../../library/xml.dom.rst:960 +#: ../../library/xml.dom.rst:957 msgid "" "Return the node with the given :attr:`~Attr.name`, or ``None`` if there is " "no such node." msgstr "" -#: ../../library/xml.dom.rst:966 +#: ../../library/xml.dom.rst:963 msgid "" "Return the node with the given namespace URI and local name, or ``None`` if " "there is no such node." msgstr "" -#: ../../library/xml.dom.rst:972 +#: ../../library/xml.dom.rst:969 msgid "" "Add *node* to the map, using its :attr:`~Attr.name` as the key. Return the " "node which it replaces, or ``None`` if it replaces no node." msgstr "" -#: ../../library/xml.dom.rst:978 +#: ../../library/xml.dom.rst:975 msgid "" "Add *node* to the map, using its namespace URI and local name as the key. " "Return the node which it replaces, or ``None`` if it replaces no node." msgstr "" -#: ../../library/xml.dom.rst:985 +#: ../../library/xml.dom.rst:982 msgid "" "Remove and return the node with the given :attr:`~Attr.name`. Raise :exc:" "`NotFoundErr` if there is no such node." msgstr "" -#: ../../library/xml.dom.rst:991 +#: ../../library/xml.dom.rst:988 msgid "" "Remove and return the node with the given namespace URI and local name. " "Raise :exc:`NotFoundErr` if there is no such node." msgstr "" -#: ../../library/xml.dom.rst:994 +#: ../../library/xml.dom.rst:991 msgid "" "You can also use the standardized :meth:`!getAttribute\\*` family of methods " "on the :class:`Element` objects." msgstr "" -#: ../../library/xml.dom.rst:1001 +#: ../../library/xml.dom.rst:998 msgid "DocumentFragment Objects" msgstr "DocumentFragment 物件" -#: ../../library/xml.dom.rst:1006 +#: ../../library/xml.dom.rst:1003 msgid "" ":class:`DocumentFragment` is a lightweight container of nodes. It is a " "subclass of :class:`Node`. When it is inserted into the document tree, its " "children are inserted instead of it, and it becomes empty." msgstr "" -#: ../../library/xml.dom.rst:1016 +#: ../../library/xml.dom.rst:1013 msgid "CharacterData Objects" msgstr "" -#: ../../library/xml.dom.rst:1021 +#: ../../library/xml.dom.rst:1018 msgid "" ":class:`CharacterData` represents text-like data in the XML document. It is " "a subclass of :class:`Node`, and the base class of :class:`Text`, :class:" "`CDATASection` and :class:`Comment`. Such nodes cannot have child nodes." msgstr "" -#: ../../library/xml.dom.rst:1029 +#: ../../library/xml.dom.rst:1026 msgid "The content of the node as a string." msgstr "" -#: ../../library/xml.dom.rst:1034 +#: ../../library/xml.dom.rst:1031 msgid "" "The number of characters in :attr:`~CharacterData.data`. This is a read-only " "attribute." msgstr "" -#: ../../library/xml.dom.rst:1040 +#: ../../library/xml.dom.rst:1037 msgid "" "Return the substring of :attr:`~CharacterData.data` of *count* characters " "starting at *offset*." msgstr "" -#: ../../library/xml.dom.rst:1046 +#: ../../library/xml.dom.rst:1043 msgid "Append the string *arg* to :attr:`~CharacterData.data`." msgstr "" -#: ../../library/xml.dom.rst:1051 +#: ../../library/xml.dom.rst:1048 msgid "Insert the string *arg* into :attr:`~CharacterData.data` at *offset*." msgstr "" -#: ../../library/xml.dom.rst:1056 +#: ../../library/xml.dom.rst:1053 msgid "" "Remove *count* characters from :attr:`~CharacterData.data` starting at " "*offset*." msgstr "" -#: ../../library/xml.dom.rst:1062 +#: ../../library/xml.dom.rst:1059 msgid "" "Replace *count* characters of :attr:`~CharacterData.data` starting at " "*offset* with the string *arg*." msgstr "" -#: ../../library/xml.dom.rst:1069 +#: ../../library/xml.dom.rst:1066 msgid "Comment Objects" msgstr "" -#: ../../library/xml.dom.rst:1074 +#: ../../library/xml.dom.rst:1071 msgid "" ":class:`Comment` represents a comment in the XML document. It is a subclass " "of :class:`CharacterData`." msgstr "" -#: ../../library/xml.dom.rst:1080 +#: ../../library/xml.dom.rst:1077 msgid "" "The content of the comment as a string. The attribute contains all " "characters between the leading ````, " "but does not include them." msgstr "" -#: ../../library/xml.dom.rst:1088 +#: ../../library/xml.dom.rst:1085 msgid "Text and CDATASection Objects" msgstr "" -#: ../../library/xml.dom.rst:1096 +#: ../../library/xml.dom.rst:1093 msgid "" "The :class:`Text` interface represents text in the XML document. If the " "parser and DOM implementation support the DOM's XML extension, portions of " @@ -1299,36 +1299,36 @@ msgid "" "different values for the :attr:`~Node.nodeType` attribute." msgstr "" -#: ../../library/xml.dom.rst:1102 +#: ../../library/xml.dom.rst:1099 msgid "" ":class:`Text` extends the :class:`CharacterData` interface, and :class:" "`CDATASection` extends :class:`Text`." msgstr "" -#: ../../library/xml.dom.rst:1108 +#: ../../library/xml.dom.rst:1105 msgid "The content of the text node as a string." msgstr "" -#: ../../library/xml.dom.rst:1113 +#: ../../library/xml.dom.rst:1110 msgid "" "The text of all :class:`Text` nodes logically adjacent to this node, " "concatenated in document order. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:1120 +#: ../../library/xml.dom.rst:1117 msgid "" "Replace the text of all :class:`Text` nodes logically adjacent to this node " "with *content*, removing the other nodes. Return this node, or ``None`` if " "*content* is empty." msgstr "" -#: ../../library/xml.dom.rst:1127 +#: ../../library/xml.dom.rst:1124 msgid "" "Split this node into two nodes at *offset*, keeping the first part in this " "node and returning a new sibling node with the rest." msgstr "" -#: ../../library/xml.dom.rst:1133 +#: ../../library/xml.dom.rst:1130 msgid "" "The use of a :class:`CDATASection` node does not indicate that the node " "represents a complete CDATA marked section, only that the content of the " @@ -1338,33 +1338,33 @@ msgid "" "marked sections." msgstr "" -#: ../../library/xml.dom.rst:1143 +#: ../../library/xml.dom.rst:1140 msgid "ProcessingInstruction Objects" msgstr "ProcessingInstruction 物件" -#: ../../library/xml.dom.rst:1148 +#: ../../library/xml.dom.rst:1145 msgid "" "Represents a processing instruction in the XML document; this inherits from " "the :class:`Node` interface and cannot have child nodes." msgstr "" -#: ../../library/xml.dom.rst:1154 +#: ../../library/xml.dom.rst:1151 msgid "" "The content of the processing instruction up to the first whitespace " "character. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:1160 +#: ../../library/xml.dom.rst:1157 msgid "" "The content of the processing instruction following the first whitespace " "character." msgstr "" -#: ../../library/xml.dom.rst:1167 +#: ../../library/xml.dom.rst:1164 msgid "Entity Objects" msgstr "Entity 物件" -#: ../../library/xml.dom.rst:1172 +#: ../../library/xml.dom.rst:1169 msgid "" ":class:`Entity` represents a parsed or unparsed entity declared in the DTD. " "It is a subclass of :class:`Node`. Entity nodes are contained in :attr:" @@ -1372,29 +1372,29 @@ msgid "" "name of the entity is its :attr:`~Node.nodeName`." msgstr "" -#: ../../library/xml.dom.rst:1181 +#: ../../library/xml.dom.rst:1178 msgid "" "The public identifier of the entity, or ``None`` if it is not specified. " "This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:1188 +#: ../../library/xml.dom.rst:1185 msgid "" "The system identifier of the entity, or ``None`` if it is not specified. " "This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:1195 +#: ../../library/xml.dom.rst:1192 msgid "" "The name of the notation for an unparsed entity, or ``None`` for a parsed " "entity. This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:1203 +#: ../../library/xml.dom.rst:1200 msgid "Notation Objects" msgstr "Notation 物件" -#: ../../library/xml.dom.rst:1208 +#: ../../library/xml.dom.rst:1205 msgid "" ":class:`Notation` represents a notation declared in the DTD. It is a " "subclass of :class:`Node` and cannot have child nodes. Notation nodes are " @@ -1402,23 +1402,23 @@ msgid "" "document tree. The name of the notation is its :attr:`~Node.nodeName`." msgstr "" -#: ../../library/xml.dom.rst:1217 +#: ../../library/xml.dom.rst:1214 msgid "" "The public identifier of the notation, or ``None`` if it is not specified. " "This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:1224 +#: ../../library/xml.dom.rst:1221 msgid "" "The system identifier of the notation, or ``None`` if it is not specified. " "This is a read-only attribute." msgstr "" -#: ../../library/xml.dom.rst:1232 +#: ../../library/xml.dom.rst:1229 msgid "Exceptions" msgstr "例外" -#: ../../library/xml.dom.rst:1234 +#: ../../library/xml.dom.rst:1231 msgid "" "The DOM Level 2 recommendation defines a single exception, :exc:" "`DOMException`, and a number of constants that allow applications to " @@ -1427,7 +1427,7 @@ msgid "" "specific exception." msgstr "" -#: ../../library/xml.dom.rst:1239 +#: ../../library/xml.dom.rst:1236 msgid "" "The Python DOM interface provides the constants, but also expands the set of " "exceptions so that a specific exception exists for each of the exception " @@ -1436,44 +1436,44 @@ msgid "" "attr:`code` attribute." msgstr "" -#: ../../library/xml.dom.rst:1248 +#: ../../library/xml.dom.rst:1245 msgid "" "Base exception class used for all specific DOM exceptions. This exception " "class cannot be directly instantiated." msgstr "" -#: ../../library/xml.dom.rst:1254 +#: ../../library/xml.dom.rst:1251 msgid "" "Raised when a specified range of text does not fit into a string. This is " "not known to be used in the Python DOM implementations, but may be received " "from DOM implementations not written in Python." msgstr "" -#: ../../library/xml.dom.rst:1261 +#: ../../library/xml.dom.rst:1258 msgid "" "Raised when an attempt is made to insert a node where the node type is not " "allowed." msgstr "" -#: ../../library/xml.dom.rst:1267 +#: ../../library/xml.dom.rst:1264 msgid "" "Raised when an index or size parameter to a method is negative or exceeds " "the allowed values." msgstr "" -#: ../../library/xml.dom.rst:1273 +#: ../../library/xml.dom.rst:1270 msgid "" "Raised when an attempt is made to insert an :class:`Attr` node that is " "already present elsewhere in the document." msgstr "" -#: ../../library/xml.dom.rst:1279 +#: ../../library/xml.dom.rst:1276 msgid "" "Raised if a parameter or an operation is not supported on the underlying " "object." msgstr "" -#: ../../library/xml.dom.rst:1284 +#: ../../library/xml.dom.rst:1281 msgid "" "This exception is raised when a string parameter contains a character that " "is not permitted in the context it's being used in by the XML 1.0 " @@ -1481,52 +1481,52 @@ msgid "" "with a space in the element type name will cause this error to be raised." msgstr "" -#: ../../library/xml.dom.rst:1292 +#: ../../library/xml.dom.rst:1289 msgid "Raised when an attempt is made to modify the type of a node." msgstr "" -#: ../../library/xml.dom.rst:1297 +#: ../../library/xml.dom.rst:1294 msgid "" "Raised when an attempt is made to use an object that is not defined or is no " "longer usable." msgstr "" -#: ../../library/xml.dom.rst:1303 +#: ../../library/xml.dom.rst:1300 msgid "" "If an attempt is made to change any object in a way that is not permitted " "with regard to the `Namespaces in XML `_ recommendation, this exception is raised." msgstr "" -#: ../../library/xml.dom.rst:1310 +#: ../../library/xml.dom.rst:1307 msgid "" "Exception when a node does not exist in the referenced context. For " "example, :meth:`NamedNodeMap.removeNamedItem` will raise this if the node " "passed in does not exist in the map." msgstr "" -#: ../../library/xml.dom.rst:1317 +#: ../../library/xml.dom.rst:1314 msgid "" "Raised when the implementation does not support the requested type of object " "or operation." msgstr "" -#: ../../library/xml.dom.rst:1323 +#: ../../library/xml.dom.rst:1320 msgid "" "This is raised if data is specified for a node which does not support data." msgstr "" -#: ../../library/xml.dom.rst:1330 +#: ../../library/xml.dom.rst:1327 msgid "" "Raised on attempts to modify an object where modifications are not allowed " "(such as for read-only nodes)." msgstr "" -#: ../../library/xml.dom.rst:1336 +#: ../../library/xml.dom.rst:1333 msgid "Raised when an invalid or illegal string is specified." msgstr "" -#: ../../library/xml.dom.rst:1343 +#: ../../library/xml.dom.rst:1340 msgid "" "Raised when an operation would make the document invalid with respect to " "partial validity. This is not known to be used in the Python DOM " @@ -1534,165 +1534,165 @@ msgid "" "Python." msgstr "" -#: ../../library/xml.dom.rst:1351 +#: ../../library/xml.dom.rst:1348 msgid "" "Raised when a node is inserted in a different document than it currently " "belongs to, and the implementation does not support migrating the node from " "one document to the other." msgstr "" -#: ../../library/xml.dom.rst:1356 +#: ../../library/xml.dom.rst:1353 msgid "" "The exception codes defined in the DOM recommendation map to the exceptions " "described above according to this table:" msgstr "" -#: ../../library/xml.dom.rst:1360 +#: ../../library/xml.dom.rst:1357 msgid "Constant" msgstr "常數" -#: ../../library/xml.dom.rst:1360 +#: ../../library/xml.dom.rst:1357 msgid "Exception" msgstr "例外" -#: ../../library/xml.dom.rst:1362 +#: ../../library/xml.dom.rst:1359 msgid ":exc:`DomstringSizeErr`" msgstr ":exc:`DomstringSizeErr`" -#: ../../library/xml.dom.rst:1364 +#: ../../library/xml.dom.rst:1361 msgid ":exc:`HierarchyRequestErr`" msgstr ":exc:`HierarchyRequestErr`" -#: ../../library/xml.dom.rst:1366 +#: ../../library/xml.dom.rst:1363 msgid ":exc:`IndexSizeErr`" msgstr ":exc:`IndexSizeErr`" -#: ../../library/xml.dom.rst:1368 +#: ../../library/xml.dom.rst:1365 msgid ":exc:`InuseAttributeErr`" msgstr ":exc:`InuseAttributeErr`" -#: ../../library/xml.dom.rst:1370 +#: ../../library/xml.dom.rst:1367 msgid ":exc:`InvalidAccessErr`" msgstr ":exc:`InvalidAccessErr`" -#: ../../library/xml.dom.rst:1372 +#: ../../library/xml.dom.rst:1369 msgid ":exc:`InvalidCharacterErr`" msgstr ":exc:`InvalidCharacterErr`" -#: ../../library/xml.dom.rst:1374 +#: ../../library/xml.dom.rst:1371 msgid ":exc:`InvalidModificationErr`" msgstr ":exc:`InvalidModificationErr`" -#: ../../library/xml.dom.rst:1376 +#: ../../library/xml.dom.rst:1373 msgid ":exc:`InvalidStateErr`" msgstr ":exc:`InvalidStateErr`" -#: ../../library/xml.dom.rst:1378 +#: ../../library/xml.dom.rst:1375 msgid ":exc:`NamespaceErr`" msgstr ":exc:`NamespaceErr`" -#: ../../library/xml.dom.rst:1380 +#: ../../library/xml.dom.rst:1377 msgid ":exc:`NotFoundErr`" msgstr ":exc:`NotFoundErr`" -#: ../../library/xml.dom.rst:1382 +#: ../../library/xml.dom.rst:1379 msgid ":exc:`NotSupportedErr`" msgstr ":exc:`NotSupportedErr`" -#: ../../library/xml.dom.rst:1384 +#: ../../library/xml.dom.rst:1381 msgid ":exc:`NoDataAllowedErr`" msgstr ":exc:`NoDataAllowedErr`" -#: ../../library/xml.dom.rst:1386 +#: ../../library/xml.dom.rst:1383 msgid ":exc:`NoModificationAllowedErr`" msgstr ":exc:`NoModificationAllowedErr`" -#: ../../library/xml.dom.rst:1388 +#: ../../library/xml.dom.rst:1385 msgid ":exc:`SyntaxErr`" msgstr ":exc:`SyntaxErr`" -#: ../../library/xml.dom.rst:1390 +#: ../../library/xml.dom.rst:1387 msgid ":exc:`ValidationErr`" msgstr ":exc:`ValidationErr`" -#: ../../library/xml.dom.rst:1392 +#: ../../library/xml.dom.rst:1389 msgid ":exc:`WrongDocumentErr`" msgstr ":exc:`WrongDocumentErr`" -#: ../../library/xml.dom.rst:1399 +#: ../../library/xml.dom.rst:1396 msgid "Conformance" msgstr "" -#: ../../library/xml.dom.rst:1401 +#: ../../library/xml.dom.rst:1398 msgid "" "This section describes the conformance requirements and relationships " "between the Python DOM API, the W3C DOM recommendations, and the OMG IDL " "mapping for Python." msgstr "" -#: ../../library/xml.dom.rst:1409 +#: ../../library/xml.dom.rst:1406 msgid "Type Mapping" msgstr "" -#: ../../library/xml.dom.rst:1411 +#: ../../library/xml.dom.rst:1408 msgid "" "The IDL types used in the DOM specification are mapped to Python types " "according to the following table." msgstr "" -#: ../../library/xml.dom.rst:1415 +#: ../../library/xml.dom.rst:1412 msgid "IDL Type" msgstr "" -#: ../../library/xml.dom.rst:1415 +#: ../../library/xml.dom.rst:1412 msgid "Python Type" msgstr "Python Type" -#: ../../library/xml.dom.rst:1417 +#: ../../library/xml.dom.rst:1414 msgid "``boolean``" msgstr "``boolean``" -#: ../../library/xml.dom.rst:1417 +#: ../../library/xml.dom.rst:1414 msgid "``bool`` or ``int``" msgstr "``bool`` 或 ``int``" -#: ../../library/xml.dom.rst:1419 ../../library/xml.dom.rst:1421 -#: ../../library/xml.dom.rst:1423 +#: ../../library/xml.dom.rst:1416 ../../library/xml.dom.rst:1418 +#: ../../library/xml.dom.rst:1420 msgid "``int``" msgstr "``int``" -#: ../../library/xml.dom.rst:1421 +#: ../../library/xml.dom.rst:1418 msgid "``long int``" msgstr "``long int``" -#: ../../library/xml.dom.rst:1423 +#: ../../library/xml.dom.rst:1420 msgid "``unsigned int``" msgstr "``unsigned int``" -#: ../../library/xml.dom.rst:1425 +#: ../../library/xml.dom.rst:1422 msgid "``DOMString``" msgstr "``DOMString``" -#: ../../library/xml.dom.rst:1425 +#: ../../library/xml.dom.rst:1422 msgid "``str`` or ``bytes``" msgstr "``str`` 或 ``bytes``" -#: ../../library/xml.dom.rst:1427 +#: ../../library/xml.dom.rst:1424 msgid "``null``" msgstr "``null``" -#: ../../library/xml.dom.rst:1433 +#: ../../library/xml.dom.rst:1430 msgid "Accessor Methods" msgstr "" -#: ../../library/xml.dom.rst:1435 +#: ../../library/xml.dom.rst:1432 msgid "" "The mapping from OMG IDL to Python defines accessor functions for IDL " "``attribute`` declarations in much the way the Java mapping does. Mapping " "the IDL declarations ::" msgstr "" -#: ../../library/xml.dom.rst:1439 +#: ../../library/xml.dom.rst:1436 msgid "" "readonly attribute string someValue;\n" " attribute string anotherValue;" @@ -1700,7 +1700,7 @@ msgstr "" "readonly attribute string someValue;\n" " attribute string anotherValue;" -#: ../../library/xml.dom.rst:1442 +#: ../../library/xml.dom.rst:1439 msgid "" "yields three accessor functions: a \"get\" method for :attr:`!someValue` (:" "meth:`!_get_someValue`), and \"get\" and \"set\" methods for :attr:`!" @@ -1710,7 +1710,7 @@ msgid "" "required to work, and may raise an :exc:`AttributeError`." msgstr "" -#: ../../library/xml.dom.rst:1449 +#: ../../library/xml.dom.rst:1446 msgid "" "The Python DOM API, however, *does* require that normal attribute access " "work. This means that the typical surrogates generated by Python IDL " @@ -1722,7 +1722,7 @@ msgid "" "all DOM implementations." msgstr "" -#: ../../library/xml.dom.rst:1458 +#: ../../library/xml.dom.rst:1455 msgid "" "In the Python DOM API, accessor functions are not required. If provided, " "they should take the form defined by the Python IDL mapping, but these " @@ -1731,7 +1731,7 @@ msgid "" "``readonly`` attributes." msgstr "" -#: ../../library/xml.dom.rst:1463 +#: ../../library/xml.dom.rst:1460 msgid "" "The IDL definitions do not fully embody the requirements of the W3C DOM API, " "such as the notion of certain objects, such as the return value of :meth:" diff --git a/library/xml.dom.pulldom.po b/library/xml.dom.pulldom.po index 9ee5fccc841..44c0fef976f 100644 --- a/library/xml.dom.pulldom.po +++ b/library/xml.dom.pulldom.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-03 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:16+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!xml.dom.pulldom` --- Support for building partial DOM trees" msgstr ":mod:`!xml.dom.pulldom` --- 支援建置部分 DOM 樹" -#: ../../library/xml.dom.pulldom.rst:9 +#: ../../library/xml.dom.pulldom.rst:7 msgid "**Source code:** :source:`Lib/xml/dom/pulldom.py`" msgstr "**原始碼:**\\ :source:`Lib/xml/dom/pulldom.py`" -#: ../../library/xml.dom.pulldom.rst:18 +#: ../../library/xml.dom.pulldom.rst:16 msgid "" "The :mod:`!xml.dom.pulldom` module provides a \"pull parser\" which can also " "be asked to produce DOM-accessible fragments of the document where " @@ -38,20 +38,20 @@ msgid "" "occurs." msgstr "" -#: ../../library/xml.dom.pulldom.rst:29 +#: ../../library/xml.dom.pulldom.rst:27 msgid "" "If you need to parse untrusted or unauthenticated data, see :ref:`xml-" "security`." msgstr "如果你需要剖析不受信任或未經驗證的資料,請參閱 :ref:`xml-security`。" -#: ../../library/xml.dom.pulldom.rst:34 +#: ../../library/xml.dom.pulldom.rst:32 msgid "" "The SAX parser no longer processes general external entities by default to " "increase security by default. To enable processing of external entities, " "pass a custom parser instance in::" msgstr "" -#: ../../library/xml.dom.pulldom.rst:38 +#: ../../library/xml.dom.pulldom.rst:36 msgid "" "from xml.dom.pulldom import parse\n" "from xml.sax import make_parser\n" @@ -69,11 +69,11 @@ msgstr "" "parser.setFeature(feature_external_ges, True)\n" "parse(filename, parser=parser)" -#: ../../library/xml.dom.pulldom.rst:47 +#: ../../library/xml.dom.pulldom.rst:45 msgid "Example::" msgstr "範例: ::" -#: ../../library/xml.dom.pulldom.rst:49 +#: ../../library/xml.dom.pulldom.rst:47 msgid "" "from xml.dom import pulldom\n" "\n" @@ -93,7 +93,7 @@ msgstr "" " doc.expandNode(node)\n" " print(node.toxml())" -#: ../../library/xml.dom.pulldom.rst:58 +#: ../../library/xml.dom.pulldom.rst:56 msgid "" "``event`` is one of the following constants, and ``node`` is the node which " "the event is about. The nodes implement the :mod:`xml.dom` interfaces; they " @@ -101,39 +101,39 @@ msgid "" "mod:`xml.dom.minidom` by default." msgstr "" -#: ../../library/xml.dom.pulldom.rst:68 +#: ../../library/xml.dom.pulldom.rst:66 msgid "" "The start and the end of the document. *node* is the :class:`~xml.dom." "Document`." msgstr "" -#: ../../library/xml.dom.pulldom.rst:75 +#: ../../library/xml.dom.pulldom.rst:73 msgid "" "The start tag and the end tag of an element. *node* is the :class:`~xml.dom." "Element`." msgstr "" -#: ../../library/xml.dom.pulldom.rst:81 +#: ../../library/xml.dom.pulldom.rst:79 msgid "Character data. *node* is the :class:`~xml.dom.Text` node." msgstr "" -#: ../../library/xml.dom.pulldom.rst:87 +#: ../../library/xml.dom.pulldom.rst:85 msgid "" "White space in element content, as declared in the DTD. *node* is the :class:" "`~xml.dom.Text` node." msgstr "" -#: ../../library/xml.dom.pulldom.rst:93 +#: ../../library/xml.dom.pulldom.rst:91 msgid "A comment. *node* is the :class:`~xml.dom.Comment` node." msgstr "" -#: ../../library/xml.dom.pulldom.rst:99 +#: ../../library/xml.dom.pulldom.rst:97 msgid "" "A processing instruction. *node* is the :class:`~xml.dom." "ProcessingInstruction` node." msgstr "" -#: ../../library/xml.dom.pulldom.rst:102 +#: ../../library/xml.dom.pulldom.rst:100 msgid "" "Since the document is treated as a \"flat\" stream of events, the document " "\"tree\" is implicitly traversed and the desired elements are found " @@ -145,7 +145,7 @@ msgid "" "`DOMEventStream.expandNode` method and switch to DOM-related processing." msgstr "" -#: ../../library/xml.dom.pulldom.rst:114 +#: ../../library/xml.dom.pulldom.rst:112 msgid "" "Subclass of :class:`xml.sax.handler.ContentHandler` which turns SAX events " "into the events of the pull parser. The nodes are created, but they are not " @@ -154,13 +154,13 @@ msgid "" "document; by default the implementation of :mod:`xml.dom.minidom` is used." msgstr "" -#: ../../library/xml.dom.pulldom.rst:125 +#: ../../library/xml.dom.pulldom.rst:123 msgid "" "Subclass of :class:`PullDOM` which also adds every created node to the tree, " "so that the complete document is built." msgstr "" -#: ../../library/xml.dom.pulldom.rst:131 +#: ../../library/xml.dom.pulldom.rst:129 msgid "" "Return a :class:`DOMEventStream` from the given input. *stream_or_string* " "may be either a file name, or a file-like object. *parser*, if given, must " @@ -170,45 +170,45 @@ msgid "" "done in advance." msgstr "" -#: ../../library/xml.dom.pulldom.rst:138 +#: ../../library/xml.dom.pulldom.rst:136 msgid "" "If you have XML in a string, you can use the :func:`parseString` function " "instead:" msgstr "" -#: ../../library/xml.dom.pulldom.rst:142 +#: ../../library/xml.dom.pulldom.rst:140 msgid "" "Return a :class:`DOMEventStream` that represents the *string*. *string* must " "be a :class:`str` instance; to parse bytes, pass a binary file object to :" "func:`parse`." msgstr "" -#: ../../library/xml.dom.pulldom.rst:148 +#: ../../library/xml.dom.pulldom.rst:146 msgid "Default value for the *bufsize* parameter to :func:`parse`." msgstr "" -#: ../../library/xml.dom.pulldom.rst:150 +#: ../../library/xml.dom.pulldom.rst:148 msgid "" "The value of this variable can be changed before calling :func:`parse` and " "the new value will take effect." msgstr "" -#: ../../library/xml.dom.pulldom.rst:156 +#: ../../library/xml.dom.pulldom.rst:154 msgid "DOMEventStream Objects" msgstr "DOMEventStream 物件" -#: ../../library/xml.dom.pulldom.rst:160 +#: ../../library/xml.dom.pulldom.rst:158 msgid "" "Produce the events for the data read from the file object *stream* by the :" "class:`~xml.sax.xmlreader.XMLReader` *parser*. The data is read by *bufsize* " "bytes, or characters for a text stream, at a time." msgstr "" -#: ../../library/xml.dom.pulldom.rst:165 +#: ../../library/xml.dom.pulldom.rst:163 msgid "Support for :meth:`~object.__getitem__` method has been removed." msgstr "已移除對 :meth:`~object.__getitem__` 方法的支援。" -#: ../../library/xml.dom.pulldom.rst:170 +#: ../../library/xml.dom.pulldom.rst:168 msgid "" "Return the next ``(event, node)`` tuple, or ``None`` at the end of the " "document. See above for the events and the corresponding nodes. The current " @@ -216,11 +216,11 @@ msgid "" "`expandNode` is called." msgstr "" -#: ../../library/xml.dom.pulldom.rst:178 +#: ../../library/xml.dom.pulldom.rst:176 msgid "Expands all children of *node* into *node*. Example::" msgstr "展開 *node* 的所有子節點到 *node*。範例: ::" -#: ../../library/xml.dom.pulldom.rst:180 +#: ../../library/xml.dom.pulldom.rst:178 msgid "" "from xml.dom import pulldom\n" "\n" @@ -250,13 +250,13 @@ msgstr "" "div>

'\n" " print(node.toxml())" -#: ../../library/xml.dom.pulldom.rst:194 +#: ../../library/xml.dom.pulldom.rst:192 msgid "" "Discard the events which are not read yet and prepare the object for parsing " "a new document." msgstr "" -#: ../../library/xml.dom.pulldom.rst:200 +#: ../../library/xml.dom.pulldom.rst:198 msgid "" "Release the parser and the document. The stream is not closed, and the " "object can no longer be used." diff --git a/library/xml.etree.elementtree.po b/library/xml.etree.elementtree.po index 6da302d6ed5..44f69c37256 100644 --- a/library/xml.etree.elementtree.po +++ b/library/xml.etree.elementtree.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-14 00:21+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:16+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,46 +21,46 @@ msgstr "" msgid ":mod:`!xml.etree.ElementTree` --- The ElementTree XML API" msgstr ":mod:`!xml.etree.cElementTree` --- ElementTree XML API" -#: ../../library/xml.etree.elementtree.rst:9 +#: ../../library/xml.etree.elementtree.rst:7 msgid "**Source code:** :source:`Lib/xml/etree/ElementTree.py`" msgstr "**原始碼:**\\ :source:`Lib/xml/etree/ElementTree.py`" -#: ../../library/xml.etree.elementtree.rst:13 +#: ../../library/xml.etree.elementtree.rst:11 msgid "" "The :mod:`!xml.etree.ElementTree` module implements a simple and efficient " "API for parsing and creating XML data." msgstr "" -#: ../../library/xml.etree.elementtree.rst:16 +#: ../../library/xml.etree.elementtree.rst:14 msgid "This module will use a fast implementation whenever available." msgstr "" -#: ../../library/xml.etree.elementtree.rst:19 +#: ../../library/xml.etree.elementtree.rst:17 msgid "The :mod:`!xml.etree.cElementTree` alias of this module is deprecated." msgstr "此模組的別名 :mod:`!xml.etree.cElementTree` 已被棄用。" -#: ../../library/xml.etree.elementtree.rst:25 +#: ../../library/xml.etree.elementtree.rst:23 msgid "" "If you need to parse untrusted or unauthenticated data, see :ref:`xml-" "security`." msgstr "如果你需要剖析不受信任或未經驗證的資料,請參閱 :ref:`xml-security`。" -#: ../../library/xml.etree.elementtree.rst:29 +#: ../../library/xml.etree.elementtree.rst:27 msgid "Tutorial" msgstr "教學" -#: ../../library/xml.etree.elementtree.rst:31 +#: ../../library/xml.etree.elementtree.rst:29 msgid "" "This is a short tutorial for using :mod:`!xml.etree.ElementTree` (``ET`` in " "short). The goal is to demonstrate some of the building blocks and basic " "concepts of the module." msgstr "" -#: ../../library/xml.etree.elementtree.rst:36 +#: ../../library/xml.etree.elementtree.rst:34 msgid "XML tree and elements" msgstr "" -#: ../../library/xml.etree.elementtree.rst:38 +#: ../../library/xml.etree.elementtree.rst:36 msgid "" "XML is an inherently hierarchical data format, and the most natural way to " "represent it is with a tree. ``ET`` has two classes for this purpose - :" @@ -71,17 +71,17 @@ msgid "" "sub-elements are done on the :class:`Element` level." msgstr "" -#: ../../library/xml.etree.elementtree.rst:49 +#: ../../library/xml.etree.elementtree.rst:47 msgid "Parsing XML" msgstr "剖析 XML" -#: ../../library/xml.etree.elementtree.rst:51 +#: ../../library/xml.etree.elementtree.rst:49 msgid "" "We'll be using the fictive :file:`country_data.xml` XML document as the " "sample data for this section:" msgstr "" -#: ../../library/xml.etree.elementtree.rst:53 +#: ../../library/xml.etree.elementtree.rst:51 msgid "" "\n" "\n" @@ -131,11 +131,11 @@ msgstr "" " \n" "" -#: ../../library/xml.etree.elementtree.rst:79 +#: ../../library/xml.etree.elementtree.rst:77 msgid "We can import this data by reading from a file::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:81 +#: ../../library/xml.etree.elementtree.rst:79 msgid "" "import xml.etree.ElementTree as ET\n" "tree = ET.parse('country_data.xml')\n" @@ -145,15 +145,15 @@ msgstr "" "tree = ET.parse('country_data.xml')\n" "root = tree.getroot()" -#: ../../library/xml.etree.elementtree.rst:85 +#: ../../library/xml.etree.elementtree.rst:83 msgid "Or directly from a string::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:87 +#: ../../library/xml.etree.elementtree.rst:85 msgid "root = ET.fromstring(country_data_as_string)" msgstr "root = ET.fromstring(country_data_as_string)" -#: ../../library/xml.etree.elementtree.rst:89 +#: ../../library/xml.etree.elementtree.rst:87 msgid "" ":func:`fromstring` parses XML from a string directly into an :class:" "`Element`, which is the root element of the parsed tree. Other parsing " @@ -161,12 +161,12 @@ msgid "" "sure." msgstr "" -#: ../../library/xml.etree.elementtree.rst:93 +#: ../../library/xml.etree.elementtree.rst:91 msgid "" "As an :class:`Element`, ``root`` has a tag and a dictionary of attributes::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:95 +#: ../../library/xml.etree.elementtree.rst:93 msgid "" ">>> root.tag\n" "'data'\n" @@ -178,11 +178,11 @@ msgstr "" ">>> root.attrib\n" "{}" -#: ../../library/xml.etree.elementtree.rst:100 +#: ../../library/xml.etree.elementtree.rst:98 msgid "It also has children nodes over which we can iterate::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:102 +#: ../../library/xml.etree.elementtree.rst:100 msgid "" ">>> for child in root:\n" "... print(child.tag, child.attrib)\n" @@ -198,11 +198,11 @@ msgstr "" "country {'name': 'Singapore'}\n" "country {'name': 'Panama'}" -#: ../../library/xml.etree.elementtree.rst:109 +#: ../../library/xml.etree.elementtree.rst:107 msgid "Children are nested, and we can access specific child nodes by index::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:111 +#: ../../library/xml.etree.elementtree.rst:109 msgid "" ">>> root[0][1].text\n" "'2008'" @@ -210,7 +210,7 @@ msgstr "" ">>> root[0][1].text\n" "'2008'" -#: ../../library/xml.etree.elementtree.rst:117 +#: ../../library/xml.etree.elementtree.rst:115 msgid "" "Not all elements of the XML input will end up as elements of the parsed " "tree. Currently, this module skips over any XML comments, processing " @@ -222,11 +222,11 @@ msgid "" "constructor." msgstr "" -#: ../../library/xml.etree.elementtree.rst:131 +#: ../../library/xml.etree.elementtree.rst:129 msgid "Pull API for non-blocking parsing" msgstr "" -#: ../../library/xml.etree.elementtree.rst:133 +#: ../../library/xml.etree.elementtree.rst:131 msgid "" "Most parsing functions provided by this module require the whole document to " "be read at once before returning any result. It is possible to use an :" @@ -237,7 +237,7 @@ msgid "" "the convenience of fully constructed :class:`Element` objects." msgstr "" -#: ../../library/xml.etree.elementtree.rst:141 +#: ../../library/xml.etree.elementtree.rst:139 msgid "" "The most powerful tool for doing this is :class:`XMLPullParser`. It does " "not require a blocking read to obtain the XML data, and is instead fed with " @@ -245,7 +245,7 @@ msgid "" "XML elements, call :meth:`XMLPullParser.read_events`. Here is an example::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:146 +#: ../../library/xml.etree.elementtree.rst:144 msgid "" ">>> parser = ET.XMLPullParser(['start', 'end'])\n" ">>> parser.feed('sometext')\n" @@ -271,14 +271,14 @@ msgstr "" "end\n" "mytag text= sometext more text" -#: ../../library/xml.etree.elementtree.rst:158 +#: ../../library/xml.etree.elementtree.rst:156 msgid "" "The obvious use case is applications that operate in a non-blocking fashion " "where the XML data is being received from a socket or read incrementally " "from some storage device. In such cases, blocking reads are unacceptable." msgstr "" -#: ../../library/xml.etree.elementtree.rst:162 +#: ../../library/xml.etree.elementtree.rst:160 msgid "" "Because it's so flexible, :class:`XMLPullParser` can be inconvenient to use " "for simpler use-cases. If you don't mind your application blocking on " @@ -286,7 +286,7 @@ msgid "" "capabilities, take a look at :func:`iterparse`." msgstr "" -#: ../../library/xml.etree.elementtree.rst:167 +#: ../../library/xml.etree.elementtree.rst:165 msgid "" "Note that both parsers build the tree incrementally: it is not freed " "incrementally, so every parsed element is kept until the whole document is " @@ -294,13 +294,13 @@ msgid "" "any more." msgstr "" -#: ../../library/xml.etree.elementtree.rst:172 +#: ../../library/xml.etree.elementtree.rst:170 msgid "" "If the processed elements are large, it is enough to clear them. This works " "wherever they are in the tree, but the emptied elements are left in it::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:176 +#: ../../library/xml.etree.elementtree.rst:174 msgid "" "for event, elem in ET.iterparse(source):\n" " if elem.tag == 'record':\n" @@ -312,13 +312,13 @@ msgstr "" " process(elem)\n" " elem.clear()" -#: ../../library/xml.etree.elementtree.rst:181 +#: ../../library/xml.etree.elementtree.rst:179 msgid "" "If an element has a large number of children, remove the processed children " "from it::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:184 +#: ../../library/xml.etree.elementtree.rst:182 msgid "" "for event, elem in ET.iterparse(source, events=('start', 'end')):\n" " if event == 'start' and elem.tag == 'parent':\n" @@ -334,32 +334,32 @@ msgstr "" " process(elem)\n" " parent.remove(elem)" -#: ../../library/xml.etree.elementtree.rst:191 +#: ../../library/xml.etree.elementtree.rst:189 msgid "" "These examples are not universal, they only give an idea for two common " "cases. If you do not need a tree at all, parse with :class:`XMLParser` and a " "custom target instead; it is not built then, and nothing has to be removed." msgstr "" -#: ../../library/xml.etree.elementtree.rst:197 +#: ../../library/xml.etree.elementtree.rst:195 msgid "" "Where *immediate* feedback through events is wanted, calling method :meth:" "`XMLPullParser.flush` can help reduce delay; please make sure to study the " "related security notes." msgstr "" -#: ../../library/xml.etree.elementtree.rst:203 +#: ../../library/xml.etree.elementtree.rst:201 msgid "Finding interesting elements" msgstr "" -#: ../../library/xml.etree.elementtree.rst:205 +#: ../../library/xml.etree.elementtree.rst:203 msgid "" ":class:`Element` has some useful methods that help iterate recursively over " "all the sub-tree below it (its children, their children, and so on). For " "example, :meth:`Element.iter`::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:209 +#: ../../library/xml.etree.elementtree.rst:207 msgid "" ">>> for neighbor in root.iter('neighbor'):\n" "... print(neighbor.attrib)\n" @@ -379,7 +379,7 @@ msgstr "" "{'name': 'Costa Rica', 'direction': 'W'}\n" "{'name': 'Colombia', 'direction': 'E'}" -#: ../../library/xml.etree.elementtree.rst:218 +#: ../../library/xml.etree.elementtree.rst:216 msgid "" ":meth:`Element.findall` finds only elements with a tag which are direct " "children of the current element. :meth:`Element.find` finds the *first* " @@ -387,7 +387,7 @@ msgid "" "text content. :meth:`Element.get` accesses the element's attributes::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:223 +#: ../../library/xml.etree.elementtree.rst:221 msgid "" ">>> for country in root.findall('country'):\n" "... rank = country.find('rank').text\n" @@ -407,23 +407,23 @@ msgstr "" "Singapore 4\n" "Panama 68" -#: ../../library/xml.etree.elementtree.rst:232 +#: ../../library/xml.etree.elementtree.rst:230 msgid "" "More sophisticated specification of which elements to look for is possible " "by using :ref:`XPath `." msgstr "" -#: ../../library/xml.etree.elementtree.rst:236 +#: ../../library/xml.etree.elementtree.rst:234 msgid "Modifying an XML File" msgstr "改動 XML 檔案" -#: ../../library/xml.etree.elementtree.rst:238 +#: ../../library/xml.etree.elementtree.rst:236 msgid "" ":class:`ElementTree` provides a simple way to build XML documents and write " "them to files. The :meth:`ElementTree.write` method serves this purpose." msgstr "" -#: ../../library/xml.etree.elementtree.rst:241 +#: ../../library/xml.etree.elementtree.rst:239 msgid "" "Once created, an :class:`Element` object may be manipulated by directly " "changing its fields (such as :attr:`Element.text`), adding and modifying " @@ -431,13 +431,13 @@ msgid "" "example with :meth:`Element.append`)." msgstr "" -#: ../../library/xml.etree.elementtree.rst:246 +#: ../../library/xml.etree.elementtree.rst:244 msgid "" "Let's say we want to add one to each country's rank, and add an ``updated`` " "attribute to the rank element::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:249 +#: ../../library/xml.etree.elementtree.rst:247 msgid "" ">>> for rank in root.iter('rank'):\n" "... new_rank = int(rank.text) + 1\n" @@ -453,12 +453,12 @@ msgstr "" "...\n" ">>> tree.write('output.xml')" -#: ../../library/xml.etree.elementtree.rst:256 -#: ../../library/xml.etree.elementtree.rst:300 +#: ../../library/xml.etree.elementtree.rst:254 +#: ../../library/xml.etree.elementtree.rst:298 msgid "Our XML now looks like this:" msgstr "XML 現在看起來像這樣:" -#: ../../library/xml.etree.elementtree.rst:258 +#: ../../library/xml.etree.elementtree.rst:256 msgid "" "\n" "\n" @@ -508,13 +508,13 @@ msgstr "" " \n" "" -#: ../../library/xml.etree.elementtree.rst:284 +#: ../../library/xml.etree.elementtree.rst:282 msgid "" "We can remove elements using :meth:`Element.remove`. Let's say we want to " "remove all countries with a rank higher than 50::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:287 +#: ../../library/xml.etree.elementtree.rst:285 msgid "" ">>> for country in root.findall('country'):\n" "... # using root.findall() to avoid removal during traversal\n" @@ -532,7 +532,7 @@ msgstr "" "...\n" ">>> tree.write('output.xml')" -#: ../../library/xml.etree.elementtree.rst:295 +#: ../../library/xml.etree.elementtree.rst:293 msgid "" "Note that concurrent modification while iterating can lead to problems, just " "like when iterating and modifying Python lists or dicts. Therefore, the " @@ -540,7 +540,7 @@ msgid "" "only then iterates over the list of matches." msgstr "" -#: ../../library/xml.etree.elementtree.rst:302 +#: ../../library/xml.etree.elementtree.rst:300 msgid "" "\n" "\n" @@ -576,17 +576,17 @@ msgstr "" " \n" "" -#: ../../library/xml.etree.elementtree.rst:322 +#: ../../library/xml.etree.elementtree.rst:320 msgid "Building XML documents" msgstr "建立 XML 文件" -#: ../../library/xml.etree.elementtree.rst:324 +#: ../../library/xml.etree.elementtree.rst:322 msgid "" "The :func:`SubElement` function also provides a convenient way to create new " "sub-elements for a given element::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:327 +#: ../../library/xml.etree.elementtree.rst:325 msgid "" ">>> a = ET.Element('a')\n" ">>> b = ET.SubElement(a, 'b')\n" @@ -602,11 +602,11 @@ msgstr "" ">>> ET.dump(a)\n" "
" -#: ../../library/xml.etree.elementtree.rst:335 +#: ../../library/xml.etree.elementtree.rst:333 msgid "Parsing XML with Namespaces" msgstr "" -#: ../../library/xml.etree.elementtree.rst:337 +#: ../../library/xml.etree.elementtree.rst:335 msgid "" "If the XML input has `namespaces `__, tags and attributes with prefixes in the form ``prefix:" @@ -616,13 +616,13 @@ msgid "" "prefixed tags." msgstr "" -#: ../../library/xml.etree.elementtree.rst:345 +#: ../../library/xml.etree.elementtree.rst:343 msgid "" "Here is an XML example that incorporates two namespaces, one with the prefix " "\"fictional\" and the other serving as the default namespace:" msgstr "" -#: ../../library/xml.etree.elementtree.rst:348 +#: ../../library/xml.etree.elementtree.rst:346 msgid "" "\n" "\n" "" -#: ../../library/xml.etree.elementtree.rst:366 +#: ../../library/xml.etree.elementtree.rst:364 msgid "" "One way to search and explore this XML example is to manually add the URI to " "every tag or attribute in the xpath of a :meth:`~Element.find` or :meth:" "`~Element.findall`::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:370 +#: ../../library/xml.etree.elementtree.rst:368 msgid "" "root = fromstring(xml_text)\n" "for actor in root.findall('{http://people.example.com}actor'):\n" @@ -679,13 +679,13 @@ msgstr "" " for char in actor.findall('{http://characters.example.com}character'):\n" " print(' |-->', char.text)" -#: ../../library/xml.etree.elementtree.rst:377 +#: ../../library/xml.etree.elementtree.rst:375 msgid "" "A better way to search the namespaced XML example is to create a dictionary " "with your own prefixes and use those in the search functions::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:380 +#: ../../library/xml.etree.elementtree.rst:378 msgid "" "ns = {'real_person': 'http://people.example.com',\n" " 'role': 'http://characters.example.com'}\n" @@ -705,11 +705,11 @@ msgstr "" " for char in actor.findall('role:character', ns):\n" " print(' |-->', char.text)" -#: ../../library/xml.etree.elementtree.rst:389 +#: ../../library/xml.etree.elementtree.rst:387 msgid "These two approaches both output::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:391 +#: ../../library/xml.etree.elementtree.rst:389 msgid "" "John Cleese\n" " |--> Lancelot\n" @@ -727,11 +727,11 @@ msgstr "" " |--> Gunther\n" " |--> Commander Clement" -#: ../../library/xml.etree.elementtree.rst:403 +#: ../../library/xml.etree.elementtree.rst:401 msgid "XPath support" msgstr "XPath 支援" -#: ../../library/xml.etree.elementtree.rst:405 +#: ../../library/xml.etree.elementtree.rst:403 msgid "" "This module provides limited support for `XPath expressions `_ for locating elements in a tree. The goal is to support a " @@ -739,19 +739,19 @@ msgid "" "scope of the module." msgstr "" -#: ../../library/xml.etree.elementtree.rst:411 -#: ../../library/xml.etree.elementtree.rst:813 +#: ../../library/xml.etree.elementtree.rst:409 +#: ../../library/xml.etree.elementtree.rst:821 msgid "Example" msgstr "範例" -#: ../../library/xml.etree.elementtree.rst:413 +#: ../../library/xml.etree.elementtree.rst:411 msgid "" "Here's an example that demonstrates some of the XPath capabilities of the " "module. We'll be using the ``countrydata`` XML document from the :ref:" "`Parsing XML ` section::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:417 +#: ../../library/xml.etree.elementtree.rst:415 msgid "" "import xml.etree.ElementTree as ET\n" "\n" @@ -774,35 +774,35 @@ msgid "" "root.findall(\".//neighbor[2]\")" msgstr "" -#: ../../library/xml.etree.elementtree.rst:437 +#: ../../library/xml.etree.elementtree.rst:435 msgid "" "For XML with namespaces, use the usual qualified ``{namespace}tag`` " "notation::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:439 +#: ../../library/xml.etree.elementtree.rst:437 msgid "" "# All dublin-core \"title\" tags in the document\n" "root.findall(\".//{http://purl.org/dc/elements/1.1/}title\")" msgstr "" -#: ../../library/xml.etree.elementtree.rst:444 +#: ../../library/xml.etree.elementtree.rst:442 msgid "Supported XPath syntax" msgstr "支援的 XPath 語法" -#: ../../library/xml.etree.elementtree.rst:449 +#: ../../library/xml.etree.elementtree.rst:447 msgid "Syntax" msgstr "語法" -#: ../../library/xml.etree.elementtree.rst:449 +#: ../../library/xml.etree.elementtree.rst:447 msgid "Meaning" msgstr "意義" -#: ../../library/xml.etree.elementtree.rst:451 +#: ../../library/xml.etree.elementtree.rst:449 msgid "``tag``" msgstr "``tag``" -#: ../../library/xml.etree.elementtree.rst:451 +#: ../../library/xml.etree.elementtree.rst:449 msgid "" "Selects all child elements with the given tag. For example, ``spam`` selects " "all child elements named ``spam``, and ``spam/egg`` selects all " @@ -812,133 +812,133 @@ msgid "" "not in a namespace." msgstr "" -#: ../../library/xml.etree.elementtree.rst:460 +#: ../../library/xml.etree.elementtree.rst:458 msgid "Support for star-wildcards was added." msgstr "新增對星號萬用字元的支援。" -#: ../../library/xml.etree.elementtree.rst:463 +#: ../../library/xml.etree.elementtree.rst:461 msgid "``*``" msgstr "``*``" -#: ../../library/xml.etree.elementtree.rst:463 +#: ../../library/xml.etree.elementtree.rst:461 msgid "" "Selects all child elements, including comments and processing instructions. " "For example, ``*/egg`` selects all grandchildren named ``egg``." msgstr "" -#: ../../library/xml.etree.elementtree.rst:467 +#: ../../library/xml.etree.elementtree.rst:465 msgid "``.``" msgstr "``.``" -#: ../../library/xml.etree.elementtree.rst:467 +#: ../../library/xml.etree.elementtree.rst:465 msgid "" "Selects the current node. This is mostly useful at the beginning of the " "path, to indicate that it's a relative path." msgstr "" -#: ../../library/xml.etree.elementtree.rst:471 +#: ../../library/xml.etree.elementtree.rst:469 msgid "``//``" msgstr "``//``" -#: ../../library/xml.etree.elementtree.rst:471 +#: ../../library/xml.etree.elementtree.rst:469 msgid "" "Selects all subelements, on all levels beneath the current element. For " "example, ``.//egg`` selects all ``egg`` elements in the entire tree." msgstr "" -#: ../../library/xml.etree.elementtree.rst:475 +#: ../../library/xml.etree.elementtree.rst:473 msgid "``..``" msgstr "``..``" -#: ../../library/xml.etree.elementtree.rst:475 +#: ../../library/xml.etree.elementtree.rst:473 msgid "" "Selects the parent element. Returns ``None`` if the path attempts to reach " "the ancestors of the start element (the element ``find`` was called on)." msgstr "" -#: ../../library/xml.etree.elementtree.rst:479 +#: ../../library/xml.etree.elementtree.rst:477 msgid "``[@attrib]``" msgstr "``[@attrib]``" -#: ../../library/xml.etree.elementtree.rst:479 +#: ../../library/xml.etree.elementtree.rst:477 msgid "Selects all elements that have the given attribute." msgstr "選擇所有具有給定屬性的元素。" -#: ../../library/xml.etree.elementtree.rst:481 +#: ../../library/xml.etree.elementtree.rst:479 msgid "``[@attrib='value']``" msgstr "``[@attrib='value']``" -#: ../../library/xml.etree.elementtree.rst:481 +#: ../../library/xml.etree.elementtree.rst:479 msgid "" "Selects all elements for which the given attribute has the given value. The " "value cannot contain quotes." msgstr "" -#: ../../library/xml.etree.elementtree.rst:485 +#: ../../library/xml.etree.elementtree.rst:483 msgid "``[@attrib!='value']``" msgstr "``[@attrib!='value']``" -#: ../../library/xml.etree.elementtree.rst:485 +#: ../../library/xml.etree.elementtree.rst:483 msgid "" "Selects all elements for which the given attribute does not have the given " "value. The value cannot contain quotes." msgstr "" -#: ../../library/xml.etree.elementtree.rst:491 +#: ../../library/xml.etree.elementtree.rst:489 msgid "``[tag]``" msgstr "``[tag]``" -#: ../../library/xml.etree.elementtree.rst:491 +#: ../../library/xml.etree.elementtree.rst:489 msgid "" "Selects all elements that have a child named ``tag``. Only immediate " "children are supported." msgstr "" -#: ../../library/xml.etree.elementtree.rst:494 +#: ../../library/xml.etree.elementtree.rst:492 msgid "``[.='text']``" msgstr "``[.='text']``" -#: ../../library/xml.etree.elementtree.rst:494 +#: ../../library/xml.etree.elementtree.rst:492 msgid "" "Selects all elements whose complete text content, including descendants, " "equals the given ``text``." msgstr "" -#: ../../library/xml.etree.elementtree.rst:499 +#: ../../library/xml.etree.elementtree.rst:497 msgid "``[.!='text']``" msgstr "``[.!='text']``" -#: ../../library/xml.etree.elementtree.rst:499 +#: ../../library/xml.etree.elementtree.rst:497 msgid "" "Selects all elements whose complete text content, including descendants, " "does not equal the given ``text``." msgstr "" -#: ../../library/xml.etree.elementtree.rst:505 +#: ../../library/xml.etree.elementtree.rst:503 msgid "``[tag='text']``" msgstr "``[tag='text']``" -#: ../../library/xml.etree.elementtree.rst:505 +#: ../../library/xml.etree.elementtree.rst:503 msgid "" "Selects all elements that have a child named ``tag`` whose complete text " "content, including descendants, equals the given ``text``." msgstr "" -#: ../../library/xml.etree.elementtree.rst:509 +#: ../../library/xml.etree.elementtree.rst:507 msgid "``[tag!='text']``" msgstr "``[tag!='text']``" -#: ../../library/xml.etree.elementtree.rst:509 +#: ../../library/xml.etree.elementtree.rst:507 msgid "" "Selects all elements that have a child named ``tag`` whose complete text " "content, including descendants, does not equal the given ``text``." msgstr "" -#: ../../library/xml.etree.elementtree.rst:515 +#: ../../library/xml.etree.elementtree.rst:513 msgid "``[position]``" msgstr "``[position]``" -#: ../../library/xml.etree.elementtree.rst:515 +#: ../../library/xml.etree.elementtree.rst:513 msgid "" "Selects all elements that are located at the given position. The position " "can be either an integer (1 is the first position), the expression " @@ -946,28 +946,28 @@ msgid "" "position (e.g. ``last()-1``)." msgstr "" -#: ../../library/xml.etree.elementtree.rst:522 +#: ../../library/xml.etree.elementtree.rst:520 msgid "" "Predicates (expressions within square brackets) must be preceded by a tag " "name, an asterisk, or another predicate. ``position`` predicates must be " "preceded by a tag name." msgstr "" -#: ../../library/xml.etree.elementtree.rst:527 -#: ../../library/xml.etree.elementtree.rst:865 +#: ../../library/xml.etree.elementtree.rst:525 +#: ../../library/xml.etree.elementtree.rst:873 msgid "Reference" msgstr "" -#: ../../library/xml.etree.elementtree.rst:532 -#: ../../library/xml.etree.elementtree.rst:870 +#: ../../library/xml.etree.elementtree.rst:530 +#: ../../library/xml.etree.elementtree.rst:878 msgid "Functions" msgstr "函式" -#: ../../library/xml.etree.elementtree.rst:536 +#: ../../library/xml.etree.elementtree.rst:534 msgid "`C14N 2.0 `_ transformation function." msgstr "" -#: ../../library/xml.etree.elementtree.rst:538 +#: ../../library/xml.etree.elementtree.rst:536 msgid "" "Canonicalization is a way to normalise XML output in a way that allows byte-" "by-byte comparisons and digital signatures. It reduces the freedom that XML " @@ -976,7 +976,7 @@ msgid "" "declarations, the ordering of attributes, and ignorable whitespace." msgstr "" -#: ../../library/xml.etree.elementtree.rst:544 +#: ../../library/xml.etree.elementtree.rst:542 msgid "" "This function takes an XML data string (*xml_data*) or a file path or file-" "like object (*from_file*) as input, converts it to the canonical form, and " @@ -985,11 +985,11 @@ msgid "" "should therefore be opened in text mode with ``utf-8`` encoding." msgstr "" -#: ../../library/xml.etree.elementtree.rst:551 +#: ../../library/xml.etree.elementtree.rst:549 msgid "Typical uses::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:553 +#: ../../library/xml.etree.elementtree.rst:551 msgid "" "xml_data = \"...\"\n" "print(canonicalize(xml_data))\n" @@ -1009,59 +1009,59 @@ msgstr "" "with open(\"c14n_output.xml\", mode='w', encoding='utf-8') as out_file:\n" " canonicalize(from_file=\"inputfile.xml\", out=out_file)" -#: ../../library/xml.etree.elementtree.rst:562 +#: ../../library/xml.etree.elementtree.rst:560 msgid "The configuration *options* are as follows:" msgstr "" -#: ../../library/xml.etree.elementtree.rst:564 +#: ../../library/xml.etree.elementtree.rst:562 msgid "*with_comments*: set to true to include comments (default: false)" msgstr "" -#: ../../library/xml.etree.elementtree.rst:565 +#: ../../library/xml.etree.elementtree.rst:563 msgid "" "*strip_text*: set to true to strip whitespace before and after text content" msgstr "" +#: ../../library/xml.etree.elementtree.rst:564 #: ../../library/xml.etree.elementtree.rst:566 -#: ../../library/xml.etree.elementtree.rst:568 msgid "(default: false)" msgstr "" -#: ../../library/xml.etree.elementtree.rst:567 +#: ../../library/xml.etree.elementtree.rst:565 msgid "" "*rewrite_prefixes*: set to true to replace namespace prefixes by " "\"n{number}\"" msgstr "" -#: ../../library/xml.etree.elementtree.rst:569 +#: ../../library/xml.etree.elementtree.rst:567 msgid "*qname_aware_tags*: a set of qname aware tag names in which prefixes" msgstr "" +#: ../../library/xml.etree.elementtree.rst:568 #: ../../library/xml.etree.elementtree.rst:570 -#: ../../library/xml.etree.elementtree.rst:572 msgid "should be replaced in text content (default: empty)" msgstr "" -#: ../../library/xml.etree.elementtree.rst:571 +#: ../../library/xml.etree.elementtree.rst:569 msgid "" "*qname_aware_attrs*: a set of qname aware attribute names in which prefixes" msgstr "" -#: ../../library/xml.etree.elementtree.rst:573 +#: ../../library/xml.etree.elementtree.rst:571 msgid "*exclude_attrs*: a set of attribute names that should not be serialised" msgstr "" -#: ../../library/xml.etree.elementtree.rst:574 +#: ../../library/xml.etree.elementtree.rst:572 msgid "*exclude_tags*: a set of tag names that should not be serialised" msgstr "" -#: ../../library/xml.etree.elementtree.rst:576 +#: ../../library/xml.etree.elementtree.rst:574 msgid "" "In the option list above, \"a set\" refers to any collection or iterable of " "strings, no ordering is expected." msgstr "" -#: ../../library/xml.etree.elementtree.rst:584 +#: ../../library/xml.etree.elementtree.rst:582 msgid "" "Comment element factory. This factory function creates a special element " "that will be serialized as an XML comment by the standard serializer. *text* " @@ -1069,7 +1069,7 @@ msgid "" "representing a comment." msgstr "" -#: ../../library/xml.etree.elementtree.rst:589 +#: ../../library/xml.etree.elementtree.rst:587 msgid "" "Note that :class:`XMLParser` skips over comments in the input instead of " "creating comment objects for them. An :class:`ElementTree` will only contain " @@ -1077,29 +1077,29 @@ msgid "" "class:`Element` methods." msgstr "" -#: ../../library/xml.etree.elementtree.rst:596 +#: ../../library/xml.etree.elementtree.rst:594 msgid "" "Writes an element tree or element structure to sys.stdout. This function " "should be used for debugging only." msgstr "" -#: ../../library/xml.etree.elementtree.rst:599 +#: ../../library/xml.etree.elementtree.rst:597 msgid "" "The exact output format is implementation dependent. In this version, it's " "written as an ordinary XML file." msgstr "" -#: ../../library/xml.etree.elementtree.rst:602 +#: ../../library/xml.etree.elementtree.rst:600 msgid "*elem* is an element tree or an individual element." msgstr "" -#: ../../library/xml.etree.elementtree.rst:604 +#: ../../library/xml.etree.elementtree.rst:602 msgid "" "The :func:`dump` function now preserves the attribute order specified by the " "user." msgstr "" -#: ../../library/xml.etree.elementtree.rst:611 +#: ../../library/xml.etree.elementtree.rst:609 msgid "" "Parses an XML section from a string constant. Same as :func:`XML`. *text* " "is a string containing XML data. *parser* is an optional parser instance. " @@ -1107,7 +1107,7 @@ msgid "" "class:`Element` instance." msgstr "" -#: ../../library/xml.etree.elementtree.rst:619 +#: ../../library/xml.etree.elementtree.rst:617 msgid "" "Parses an XML document from a sequence of string fragments. *sequence* is a " "list or other sequence containing XML data fragments. *parser* is an " @@ -1115,7 +1115,7 @@ msgid "" "parser is used. Returns an :class:`Element` instance." msgstr "" -#: ../../library/xml.etree.elementtree.rst:629 +#: ../../library/xml.etree.elementtree.rst:627 msgid "" "Appends whitespace to the subtree to indent the tree visually. This can be " "used to generate pretty-printed XML output. *tree* can be an Element or " @@ -1125,13 +1125,13 @@ msgid "" "indentation level as *level*." msgstr "" -#: ../../library/xml.etree.elementtree.rst:641 +#: ../../library/xml.etree.elementtree.rst:639 msgid "" "Check if an object appears to be a valid element object. *element* is an " "element instance. Return ``True`` if this is an element object." msgstr "" -#: ../../library/xml.etree.elementtree.rst:647 +#: ../../library/xml.etree.elementtree.rst:645 msgid "" "Parses an XML section into an element tree incrementally, and reports what's " "going on to the user. *source* is a filename or :term:`file object` " @@ -1149,7 +1149,7 @@ msgid "" "internal file object if *source* is a filename." msgstr "" -#: ../../library/xml.etree.elementtree.rst:664 +#: ../../library/xml.etree.elementtree.rst:662 msgid "" "Note that while :func:`iterparse` builds the tree incrementally, it issues " "blocking reads on *source* (or the file it names). As such, it's unsuitable " @@ -1157,14 +1157,14 @@ msgid "" "parsing, see :class:`XMLPullParser`." msgstr "" -#: ../../library/xml.etree.elementtree.rst:669 +#: ../../library/xml.etree.elementtree.rst:667 msgid "" "The tree is only built incrementally, it is not freed incrementally: every " "parsed element is kept until the whole document is read. See :ref:" "`elementtree-pull-parsing` for how to keep the memory usage low." msgstr "" -#: ../../library/xml.etree.elementtree.rst:675 +#: ../../library/xml.etree.elementtree.rst:673 msgid "" ":func:`iterparse` only guarantees that it has seen the \">\" character of a " "starting tag when it emits a \"start\" event, so the attributes are defined, " @@ -1173,25 +1173,31 @@ msgid "" "present." msgstr "" -#: ../../library/xml.etree.elementtree.rst:681 -#: ../../library/xml.etree.elementtree.rst:1562 +#: ../../library/xml.etree.elementtree.rst:679 +#: ../../library/xml.etree.elementtree.rst:1577 msgid "If you need a fully populated element, look for \"end\" events instead." msgstr "" -#: ../../library/xml.etree.elementtree.rst:683 +#: ../../library/xml.etree.elementtree.rst:681 msgid "The *parser* argument." msgstr "*parser* 引數。" -#: ../../library/xml.etree.elementtree.rst:686 -#: ../../library/xml.etree.elementtree.rst:1566 +#: ../../library/xml.etree.elementtree.rst:684 +#: ../../library/xml.etree.elementtree.rst:1581 msgid "The ``comment`` and ``pi`` events were added." msgstr "新增 *context* 與 *check_hostname* 事件。" -#: ../../library/xml.etree.elementtree.rst:689 +#: ../../library/xml.etree.elementtree.rst:687 msgid "Added the :meth:`!close` method." msgstr "新增 :meth:`!close` 方法。" -#: ../../library/xml.etree.elementtree.rst:695 +#: ../../library/xml.etree.elementtree.rst:690 +msgid "" +"A :exc:`ResourceWarning` is now emitted if the iterator opened a file and is " +"not explicitly closed." +msgstr "" + +#: ../../library/xml.etree.elementtree.rst:697 msgid "" "Parses an XML section into an element tree. *source* is a filename or file " "object containing XML data. *parser* is an optional parser instance. If " @@ -1199,7 +1205,7 @@ msgid "" "class:`ElementTree` instance." msgstr "" -#: ../../library/xml.etree.elementtree.rst:703 +#: ../../library/xml.etree.elementtree.rst:705 msgid "" "PI element factory. This factory function creates a special element that " "will be serialized as an XML processing instruction. *target* is a string " @@ -1207,7 +1213,7 @@ msgid "" "given. Returns an element instance, representing a processing instruction." msgstr "" -#: ../../library/xml.etree.elementtree.rst:708 +#: ../../library/xml.etree.elementtree.rst:710 msgid "" "Note that :class:`XMLParser` skips over processing instructions in the input " "instead of creating PI objects for them. An :class:`ElementTree` will only " @@ -1215,7 +1221,7 @@ msgid "" "tree using one of the :class:`Element` methods." msgstr "" -#: ../../library/xml.etree.elementtree.rst:716 +#: ../../library/xml.etree.elementtree.rst:718 msgid "" "Registers a namespace prefix. The registry is global, and any existing " "mapping for either the given prefix or the namespace URI will be removed. " @@ -1224,13 +1230,13 @@ msgid "" "all possible." msgstr "" -#: ../../library/xml.etree.elementtree.rst:727 +#: ../../library/xml.etree.elementtree.rst:729 msgid "" "Subelement factory. This function creates an element instance, and appends " "it to an existing element." msgstr "" -#: ../../library/xml.etree.elementtree.rst:730 +#: ../../library/xml.etree.elementtree.rst:732 msgid "" "*parent* is the parent element. *tag* is the subelement name. *attrib* is " "an optional dictionary, containing element attributes. *extra* contains " @@ -1238,7 +1244,16 @@ msgid "" "instance." msgstr "" +#: ../../library/xml.etree.elementtree.rst:737 +#: ../../library/xml.etree.elementtree.rst:939 +msgid "*attrib* can now be a :class:`frozendict`." +msgstr "" + #: ../../library/xml.etree.elementtree.rst:740 +msgid "*parent* and *tag* are now positional-only parameters." +msgstr "" + +#: ../../library/xml.etree.elementtree.rst:748 msgid "" "Generates a string representation of an XML element, including all " "subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is " @@ -1250,24 +1265,24 @@ msgid "" "Returns an (optionally) encoded string containing the XML data." msgstr "" -#: ../../library/xml.etree.elementtree.rst:749 -#: ../../library/xml.etree.elementtree.rst:776 -#: ../../library/xml.etree.elementtree.rst:1238 +#: ../../library/xml.etree.elementtree.rst:757 +#: ../../library/xml.etree.elementtree.rst:784 +#: ../../library/xml.etree.elementtree.rst:1253 msgid "Added the *short_empty_elements* parameter." msgstr "新增 *short_empty_elements* 參數。" -#: ../../library/xml.etree.elementtree.rst:752 -#: ../../library/xml.etree.elementtree.rst:779 +#: ../../library/xml.etree.elementtree.rst:760 +#: ../../library/xml.etree.elementtree.rst:787 msgid "Added the *xml_declaration* and *default_namespace* parameters." msgstr "新增 *xml_declaration* 與 *default_namespace* 參數。" -#: ../../library/xml.etree.elementtree.rst:755 +#: ../../library/xml.etree.elementtree.rst:763 msgid "" "The :func:`tostring` function now preserves the attribute order specified by " "the user." msgstr "" -#: ../../library/xml.etree.elementtree.rst:764 +#: ../../library/xml.etree.elementtree.rst:772 msgid "" "Generates a string representation of an XML element, including all " "subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is " @@ -1281,13 +1296,13 @@ msgid "" "join(tostringlist(element)) == tostring(element)``." msgstr "" -#: ../../library/xml.etree.elementtree.rst:782 +#: ../../library/xml.etree.elementtree.rst:790 msgid "" "The :func:`tostringlist` function now preserves the attribute order " "specified by the user." msgstr "" -#: ../../library/xml.etree.elementtree.rst:789 +#: ../../library/xml.etree.elementtree.rst:797 msgid "" "Parses an XML section from a string constant. This function can be used to " "embed \"XML literals\" in Python code. *text* is a string containing XML " @@ -1295,7 +1310,7 @@ msgid "" "class:`XMLParser` parser is used. Returns an :class:`Element` instance." msgstr "" -#: ../../library/xml.etree.elementtree.rst:797 +#: ../../library/xml.etree.elementtree.rst:805 msgid "" "Parses an XML section from a string constant, and also returns a dictionary " "which maps from element id:s to elements. *text* is a string containing XML " @@ -1304,11 +1319,11 @@ msgid "" "`Element` instance and a dictionary." msgstr "" -#: ../../library/xml.etree.elementtree.rst:807 +#: ../../library/xml.etree.elementtree.rst:815 msgid "XInclude support" msgstr "" -#: ../../library/xml.etree.elementtree.rst:809 +#: ../../library/xml.etree.elementtree.rst:817 msgid "" "This module provides limited support for `XInclude directives `_, via the :mod:`xml.etree.ElementInclude` helper " @@ -1316,7 +1331,7 @@ msgid "" "element trees, based on information in the tree." msgstr "" -#: ../../library/xml.etree.elementtree.rst:815 +#: ../../library/xml.etree.elementtree.rst:823 msgid "" "Here's an example that demonstrates use of the XInclude module. To include " "an XML document in the current document, use the ``{http://www.w3.org/2001/" @@ -1324,7 +1339,7 @@ msgid "" "and use the **href** attribute to specify the document to include." msgstr "" -#: ../../library/xml.etree.elementtree.rst:817 +#: ../../library/xml.etree.elementtree.rst:825 msgid "" "\n" "\n" @@ -1336,20 +1351,20 @@ msgstr "" " \n" "" -#: ../../library/xml.etree.elementtree.rst:824 +#: ../../library/xml.etree.elementtree.rst:832 msgid "" "By default, the **href** attribute is treated as a file name. You can use " "custom loaders to override this behaviour. Also note that the standard " "helper does not support XPointer syntax." msgstr "" -#: ../../library/xml.etree.elementtree.rst:826 +#: ../../library/xml.etree.elementtree.rst:834 msgid "" "To process this file, load it as usual, and pass the root element to the :" "mod:`!xml.etree.ElementTree` module:" msgstr "" -#: ../../library/xml.etree.elementtree.rst:828 +#: ../../library/xml.etree.elementtree.rst:836 msgid "" "from xml.etree import ElementTree, ElementInclude\n" "\n" @@ -1365,14 +1380,14 @@ msgstr "" "\n" "ElementInclude.include(root)" -#: ../../library/xml.etree.elementtree.rst:837 +#: ../../library/xml.etree.elementtree.rst:845 msgid "" "The ElementInclude module replaces the ``{http://www.w3.org/2001/XInclude}" "include`` element with the root element from the **source.xml** document. " "The result might look something like this:" msgstr "" -#: ../../library/xml.etree.elementtree.rst:839 +#: ../../library/xml.etree.elementtree.rst:847 msgid "" "\n" " This is a paragraph.\n" @@ -1382,19 +1397,19 @@ msgstr "" " This is a paragraph.\n" "" -#: ../../library/xml.etree.elementtree.rst:845 +#: ../../library/xml.etree.elementtree.rst:853 msgid "" "If the **parse** attribute is omitted, it defaults to \"xml\". The href " "attribute is required." msgstr "" -#: ../../library/xml.etree.elementtree.rst:847 +#: ../../library/xml.etree.elementtree.rst:855 msgid "" "To include a text document, use the ``{http://www.w3.org/2001/XInclude}" "include`` element, and set the **parse** attribute to \"text\":" msgstr "" -#: ../../library/xml.etree.elementtree.rst:849 +#: ../../library/xml.etree.elementtree.rst:857 msgid "" "\n" "\n" @@ -1406,11 +1421,11 @@ msgstr "" " Copyright (c) .\n" "" -#: ../../library/xml.etree.elementtree.rst:856 +#: ../../library/xml.etree.elementtree.rst:864 msgid "The result might look something like:" msgstr "" -#: ../../library/xml.etree.elementtree.rst:858 +#: ../../library/xml.etree.elementtree.rst:866 msgid "" "\n" " Copyright (c) 2003.\n" @@ -1420,7 +1435,7 @@ msgstr "" " Copyright (c) 2003.\n" "" -#: ../../library/xml.etree.elementtree.rst:876 +#: ../../library/xml.etree.elementtree.rst:884 msgid "" "Default loader. This default loader reads an included resource from disk. " "*href* is a URL. *parse* is for parse mode either \"xml\" or \"text\". " @@ -1431,7 +1446,7 @@ msgid "" "``None`` or raise an exception." msgstr "" -#: ../../library/xml.etree.elementtree.rst:887 +#: ../../library/xml.etree.elementtree.rst:895 msgid "" "This function expands XInclude directives in-place in tree pointed by " "*elem*. *elem* is either the root :class:`~xml.etree.ElementTree.Element` or " @@ -1444,28 +1459,28 @@ msgid "" "malicious content explosion. Pass ``None`` to disable the limitation." msgstr "" -#: ../../library/xml.etree.elementtree.rst:897 +#: ../../library/xml.etree.elementtree.rst:905 msgid "Added the *base_url* and *max_depth* parameters." msgstr "新增 *base_url* 與 *max_depth* 參數。" -#: ../../library/xml.etree.elementtree.rst:904 +#: ../../library/xml.etree.elementtree.rst:912 msgid "Element Objects" msgstr "Element 物件" -#: ../../library/xml.etree.elementtree.rst:912 +#: ../../library/xml.etree.elementtree.rst:920 msgid "" "Element class. This class defines the Element interface, and provides a " "reference implementation of this interface." msgstr "" -#: ../../library/xml.etree.elementtree.rst:915 +#: ../../library/xml.etree.elementtree.rst:923 msgid "" "*tag* is the element name. *attrib* is an optional dictionary, containing " "element attributes. *extra* contains additional attributes, given as " "keyword arguments." msgstr "" -#: ../../library/xml.etree.elementtree.rst:919 +#: ../../library/xml.etree.elementtree.rst:927 msgid "" "The element name and the attribute names and values are strings or :class:" "`QName` instances, and the text and the tail are strings or ``None``. The " @@ -1478,13 +1493,17 @@ msgid "" "objects can be stored in the tree, but they cannot be serialized." msgstr "" -#: ../../library/xml.etree.elementtree.rst:933 +#: ../../library/xml.etree.elementtree.rst:942 +msgid "*tag* is now a positional-only parameter." +msgstr "" + +#: ../../library/xml.etree.elementtree.rst:948 msgid "" "A string identifying what kind of data this element represents (the element " "type, in other words)." msgstr "" -#: ../../library/xml.etree.elementtree.rst:940 +#: ../../library/xml.etree.elementtree.rst:955 msgid "" "These attributes can be used to hold additional data associated with the " "element. Their values are usually strings but may be any application-" @@ -1495,11 +1514,11 @@ msgid "" "the XML data" msgstr "" -#: ../../library/xml.etree.elementtree.rst:948 +#: ../../library/xml.etree.elementtree.rst:963 msgid "1234" msgstr "1234" -#: ../../library/xml.etree.elementtree.rst:952 +#: ../../library/xml.etree.elementtree.rst:967 msgid "" "the *a* element has ``None`` for both *text* and *tail* attributes, the *b* " "element has *text* ``\"1\"`` and *tail* ``\"4\"``, the *c* element has " @@ -1507,17 +1526,17 @@ msgid "" "``None`` and *tail* ``\"3\"``." msgstr "" -#: ../../library/xml.etree.elementtree.rst:957 +#: ../../library/xml.etree.elementtree.rst:972 msgid "" "To collect the inner text of an element, see :meth:`itertext`, for example " "``\"\".join(element.itertext())``." msgstr "" -#: ../../library/xml.etree.elementtree.rst:960 +#: ../../library/xml.etree.elementtree.rst:975 msgid "Applications may store arbitrary objects in these attributes." msgstr "" -#: ../../library/xml.etree.elementtree.rst:965 +#: ../../library/xml.etree.elementtree.rst:980 msgid "" "A dictionary containing the element's attributes. Note that while the " "*attrib* value is always a real mutable Python dictionary, an ElementTree " @@ -1526,55 +1545,55 @@ msgid "" "implementations, use the dictionary methods below whenever possible." msgstr "" -#: ../../library/xml.etree.elementtree.rst:971 +#: ../../library/xml.etree.elementtree.rst:986 msgid "The following dictionary-like methods work on the element attributes." msgstr "" -#: ../../library/xml.etree.elementtree.rst:976 +#: ../../library/xml.etree.elementtree.rst:991 msgid "" "Resets an element. This function removes all subelements, clears all " "attributes, and sets the text and tail attributes to ``None``." msgstr "" -#: ../../library/xml.etree.elementtree.rst:982 +#: ../../library/xml.etree.elementtree.rst:997 msgid "Gets the element attribute named *key*." msgstr "" -#: ../../library/xml.etree.elementtree.rst:984 +#: ../../library/xml.etree.elementtree.rst:999 msgid "" "Returns the attribute value, or *default* if the attribute was not found." msgstr "" -#: ../../library/xml.etree.elementtree.rst:989 +#: ../../library/xml.etree.elementtree.rst:1004 msgid "Returns the element attributes as (name, value) pairs." msgstr "" -#: ../../library/xml.etree.elementtree.rst:994 +#: ../../library/xml.etree.elementtree.rst:1009 msgid "Returns the element attribute names." msgstr "" -#: ../../library/xml.etree.elementtree.rst:999 +#: ../../library/xml.etree.elementtree.rst:1014 msgid "Set the attribute *key* on the element to *value*." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1001 +#: ../../library/xml.etree.elementtree.rst:1016 msgid "The following methods work on the element's children (subelements)." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1006 +#: ../../library/xml.etree.elementtree.rst:1021 msgid "" "Adds the element *subelement* to the end of this element's internal list of " "subelements. Raises :exc:`TypeError` if *subelement* is not an :class:" "`Element`." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1013 +#: ../../library/xml.etree.elementtree.rst:1028 msgid "" "Appends *subelements* from an iterable of elements. Raises :exc:`TypeError` " "if a subelement is not an :class:`Element`." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1021 +#: ../../library/xml.etree.elementtree.rst:1036 msgid "" "Finds the first subelement matching *match*. *match* may be a tag name or " "a :ref:`path `. Returns an element instance or " @@ -1583,7 +1602,7 @@ msgid "" "expression into the given namespace." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1030 +#: ../../library/xml.etree.elementtree.rst:1045 msgid "" "Finds all matching subelements, by tag name or :ref:`path `. Returns a list containing all matching elements in document " @@ -1592,7 +1611,7 @@ msgid "" "expression into the given namespace." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1039 +#: ../../library/xml.etree.elementtree.rst:1054 msgid "" "Finds text for the first subelement matching *match*. *match* may be a tag " "name or a :ref:`path `. Returns the text content of the " @@ -1603,13 +1622,13 @@ msgid "" "into the given namespace." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1050 +#: ../../library/xml.etree.elementtree.rst:1065 msgid "" "Inserts *subelement* at the given position in this element. Raises :exc:" "`TypeError` if *subelement* is not an :class:`Element`." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1056 +#: ../../library/xml.etree.elementtree.rst:1071 msgid "" "Creates a tree :term:`iterator` with the current element as the root. The " "iterator iterates over this element and all elements below it, in document " @@ -1618,7 +1637,7 @@ msgid "" "structure is modified during iteration, the result is undefined." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1067 +#: ../../library/xml.etree.elementtree.rst:1082 msgid "" "Finds all matching subelements, by tag name or :ref:`path `. Returns an iterable yielding all matching elements in document " @@ -1626,33 +1645,33 @@ msgid "" "name." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1078 +#: ../../library/xml.etree.elementtree.rst:1093 msgid "" "Creates a text iterator. The iterator loops over this element and all " "subelements, in document order, and returns all inner text." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1086 +#: ../../library/xml.etree.elementtree.rst:1101 msgid "" "Creates a new element object of the same type as this element. Do not call " "this method, use the :func:`SubElement` factory function instead." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1092 +#: ../../library/xml.etree.elementtree.rst:1107 msgid "" "Removes *subelement* from the element. Unlike the find\\* methods this " "method compares elements based on the instance identity, not on tag value or " "contents." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1096 +#: ../../library/xml.etree.elementtree.rst:1111 msgid "" ":class:`Element` objects also support the following sequence type methods " "for working with subelements: :meth:`~object.__delitem__`, :meth:`~object." "__getitem__`, :meth:`~object.__setitem__`, :meth:`~object.__len__`." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1101 +#: ../../library/xml.etree.elementtree.rst:1116 msgid "" "Caution: Elements with no subelements will test as ``False``. In a future " "release of Python, all elements will test as ``True`` regardless of whether " @@ -1660,7 +1679,7 @@ msgid "" "None`` tests.::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1106 +#: ../../library/xml.etree.elementtree.rst:1121 msgid "" "element = root.find('foo')\n" "\n" @@ -1671,11 +1690,11 @@ msgid "" " print(\"element not found\")" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1114 +#: ../../library/xml.etree.elementtree.rst:1129 msgid "Testing the truth value of an Element emits :exc:`DeprecationWarning`." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1117 +#: ../../library/xml.etree.elementtree.rst:1132 msgid "" "Prior to Python 3.8, the serialisation order of the XML attributes of " "elements was artificially made predictable by sorting the attributes by " @@ -1684,7 +1703,7 @@ msgid "" "attributes were originally parsed or created by user code." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1123 +#: ../../library/xml.etree.elementtree.rst:1138 msgid "" "In general, user code should try not to depend on a specific ordering of " "attributes, given that the `XML Information Set \n" " \n" @@ -1841,13 +1860,13 @@ msgstr "" " \n" "" -#: ../../library/xml.etree.elementtree.rst:1258 +#: ../../library/xml.etree.elementtree.rst:1273 msgid "" "Example of changing the attribute \"target\" of every link in first " "paragraph::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1260 +#: ../../library/xml.etree.elementtree.rst:1275 msgid "" ">>> from xml.etree.ElementTree import ElementTree\n" ">>> tree = ElementTree()\n" @@ -1865,11 +1884,11 @@ msgid "" ">>> tree.write(\"output.xhtml\")" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1278 +#: ../../library/xml.etree.elementtree.rst:1293 msgid "QName Objects" msgstr "QName 物件" -#: ../../library/xml.etree.elementtree.rst:1283 +#: ../../library/xml.etree.elementtree.rst:1298 msgid "" "QName wrapper. This can be used to wrap a QName attribute value, in order " "to get proper namespace handling on output. *text_or_uri* is a string " @@ -1879,11 +1898,11 @@ msgid "" "class:`QName` instances are opaque." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1295 +#: ../../library/xml.etree.elementtree.rst:1310 msgid "TreeBuilder Objects" msgstr "TreeBuilder 物件" -#: ../../library/xml.etree.elementtree.rst:1301 +#: ../../library/xml.etree.elementtree.rst:1316 msgid "" "Generic element structure builder. This builder converts a sequence of " "start, data, end, comment and pi method calls to a well-formed element " @@ -1891,14 +1910,14 @@ msgid "" "custom XML parser, or a parser for some other XML-like format." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1306 +#: ../../library/xml.etree.elementtree.rst:1321 msgid "" "*element_factory*, when given, must be a callable accepting two positional " "arguments: a tag and a dict of attributes. It is expected to return a new " "element instance." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1310 +#: ../../library/xml.etree.elementtree.rst:1325 msgid "" "The *comment_factory* and *pi_factory* functions, when given, should behave " "like the :func:`Comment` and :func:`ProcessingInstruction` functions to " @@ -1908,54 +1927,54 @@ msgid "" "element (but not outside of it)." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1319 +#: ../../library/xml.etree.elementtree.rst:1334 msgid "" "Flushes the builder buffers, and returns the toplevel document element. " "Returns an :class:`Element` instance." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1325 +#: ../../library/xml.etree.elementtree.rst:1340 msgid "Adds text to the current element. *data* is a string." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1330 +#: ../../library/xml.etree.elementtree.rst:1345 msgid "" "Closes the current element. *tag* is the element name. Returns the closed " "element." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1336 +#: ../../library/xml.etree.elementtree.rst:1351 msgid "" "Opens a new element. *tag* is the element name. *attrs* is a dictionary " "containing element attributes. Returns the opened element." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1342 +#: ../../library/xml.etree.elementtree.rst:1357 msgid "" "Creates a comment with the given *text*. If ``insert_comments`` is true, " "this will also add it to the tree." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1350 +#: ../../library/xml.etree.elementtree.rst:1365 msgid "" "Creates a process instruction with the given *target* name and *text*. If " "``insert_pis`` is true, this will also add it to the tree." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1356 +#: ../../library/xml.etree.elementtree.rst:1371 msgid "" "In addition, a custom :class:`TreeBuilder` object can provide the following " "methods:" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1361 +#: ../../library/xml.etree.elementtree.rst:1376 msgid "" "Handles a doctype declaration. *name* is the doctype name. *pubid* is the " "public identifier. *system* is the system identifier. This method does not " "exist on the default :class:`TreeBuilder` class." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1369 +#: ../../library/xml.etree.elementtree.rst:1384 msgid "" "Is called whenever the parser encounters a new namespace declaration, before " "the ``start()`` callback for the opening element that defines it. *prefix* " @@ -1963,14 +1982,14 @@ msgid "" "otherwise. *uri* is the namespace URI." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1378 +#: ../../library/xml.etree.elementtree.rst:1393 msgid "" "Is called after the ``end()`` callback of an element that declared a " "namespace prefix mapping, with the name of the *prefix* that went out of " "scope." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1390 +#: ../../library/xml.etree.elementtree.rst:1405 msgid "" "A `C14N 2.0 `_ writer. Arguments are the " "same as for the :func:`canonicalize` function. This class does not build a " @@ -1978,11 +1997,11 @@ msgid "" "using the *write* function." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1401 +#: ../../library/xml.etree.elementtree.rst:1416 msgid "XMLParser Objects" msgstr "XMLParser 物件" -#: ../../library/xml.etree.elementtree.rst:1406 +#: ../../library/xml.etree.elementtree.rst:1421 msgid "" "This class is the low-level building block of the module. It uses :mod:`xml." "parsers.expat` for efficient, event-based parsing of XML. It can be fed XML " @@ -1993,27 +2012,27 @@ msgid "" "XML file." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1414 +#: ../../library/xml.etree.elementtree.rst:1429 msgid "" "Parameters are now :ref:`keyword-only `. The *html* " "argument is no longer supported." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1421 +#: ../../library/xml.etree.elementtree.rst:1436 msgid "" "Finishes feeding data to the parser. Returns the result of calling the " "``close()`` method of the *target* passed during construction; by default, " "this is the toplevel document element." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1428 +#: ../../library/xml.etree.elementtree.rst:1443 msgid "" "Feeds data to the parser. *data* is a string or encoded data (:class:" "`bytes` or a :term:`bytes-like object`)." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1434 -#: ../../library/xml.etree.elementtree.rst:1513 +#: ../../library/xml.etree.elementtree.rst:1449 +#: ../../library/xml.etree.elementtree.rst:1528 msgid "" "Triggers parsing of any previously fed unparsed data, which can be used to " "ensure more immediate feedback, in particular with Expat >=2.6.0. The " @@ -2023,15 +2042,15 @@ msgid "" "xmlparser.SetReparseDeferralEnabled` for details." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1441 -#: ../../library/xml.etree.elementtree.rst:1520 +#: ../../library/xml.etree.elementtree.rst:1456 +#: ../../library/xml.etree.elementtree.rst:1535 msgid "" -"Note that :meth:`flush` has been backported to some prior releases of " -"CPython as a security fix. Check for availability of :meth:`flush` using :" -"func:`hasattr` if used in code running across a variety of Python versions." +":meth:`!flush` has been backported to some prior releases of CPython as a " +"security fix. Check for availability using :func:`hasattr` if used in code " +"running across a variety of Python versions." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1449 +#: ../../library/xml.etree.elementtree.rst:1464 msgid "" ":meth:`XMLParser.feed` calls *target*\\'s ``start(tag, attrs_dict)`` method " "for each opening tag, its ``end(tag)`` method for each closing tag, and data " @@ -2042,7 +2061,7 @@ msgid "" "of an XML file::" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1457 +#: ../../library/xml.etree.elementtree.rst:1472 msgid "" ">>> from xml.etree.ElementTree import XMLParser\n" ">>> class MaxDepth: # The target object of the parser\n" @@ -2077,11 +2096,11 @@ msgid "" "4" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1493 +#: ../../library/xml.etree.elementtree.rst:1508 msgid "XMLPullParser Objects" msgstr "XMLPullParser 物件" -#: ../../library/xml.etree.elementtree.rst:1497 +#: ../../library/xml.etree.elementtree.rst:1512 msgid "" "A pull parser suitable for non-blocking applications. Its input-side API is " "similar to that of :class:`XMLParser`, but instead of pushing calls to a " @@ -2093,13 +2112,13 @@ msgid "" "If *events* is omitted, only ``\"end\"`` events are reported." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1508 +#: ../../library/xml.etree.elementtree.rst:1523 msgid "" "Feed the given data to the parser. *data* is a string or encoded data (:" "class:`bytes` or a :term:`bytes-like object`)." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1529 +#: ../../library/xml.etree.elementtree.rst:1544 msgid "" "Signal the parser that the data stream is terminated. Unlike :meth:" "`XMLParser.close`, this method always returns :const:`None`. Any events not " @@ -2107,7 +2126,7 @@ msgid "" "`read_events`." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1536 +#: ../../library/xml.etree.elementtree.rst:1551 msgid "" "Return an iterator over the events which have been encountered in the data " "fed to the parser. The iterator yields ``(event, elem)`` pairs, where " @@ -2116,25 +2135,25 @@ msgid "" "follows." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1542 +#: ../../library/xml.etree.elementtree.rst:1557 msgid "``start``, ``end``: the current Element." msgstr "``start``、``end``:目前的 Element。" -#: ../../library/xml.etree.elementtree.rst:1543 +#: ../../library/xml.etree.elementtree.rst:1558 msgid "``comment``, ``pi``: the current comment / processing instruction" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1544 +#: ../../library/xml.etree.elementtree.rst:1559 msgid "" "``start-ns``: a tuple ``(prefix, uri)`` naming the declared namespace " "mapping." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1546 +#: ../../library/xml.etree.elementtree.rst:1561 msgid "``end-ns``: :const:`None` (this may change in a future version)" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1548 +#: ../../library/xml.etree.elementtree.rst:1563 msgid "" "Events provided in a previous call to :meth:`read_events` will not be " "yielded again. Events are consumed from the internal queue only when they " @@ -2143,7 +2162,7 @@ msgid "" "results." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1556 +#: ../../library/xml.etree.elementtree.rst:1571 msgid "" ":class:`XMLPullParser` only guarantees that it has seen the \">\" character " "of a starting tag when it emits a \"start\" event, so the attributes are " @@ -2152,11 +2171,11 @@ msgid "" "be present." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1571 +#: ../../library/xml.etree.elementtree.rst:1586 msgid "Exceptions" msgstr "例外" -#: ../../library/xml.etree.elementtree.rst:1575 +#: ../../library/xml.etree.elementtree.rst:1590 msgid "" "XML parse error, raised by the various parsing methods in this module when " "parsing fails. The string representation of an instance of this exception " @@ -2164,22 +2183,22 @@ msgid "" "following attributes available:" msgstr "" -#: ../../library/xml.etree.elementtree.rst:1582 +#: ../../library/xml.etree.elementtree.rst:1597 msgid "" "A numeric error code from the expat parser. See the documentation of :mod:" "`xml.parsers.expat` for the list of error codes and their meanings." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1587 +#: ../../library/xml.etree.elementtree.rst:1602 msgid "" "A tuple of *line*, *column* numbers, specifying where the error occurred." msgstr "" -#: ../../library/xml.etree.elementtree.rst:1590 +#: ../../library/xml.etree.elementtree.rst:1605 msgid "Footnotes" msgstr "註解" -#: ../../library/xml.etree.elementtree.rst:1591 +#: ../../library/xml.etree.elementtree.rst:1606 msgid "" "The encoding string included in XML output should conform to the appropriate " "standards. For example, \"UTF-8\" is valid, but \"UTF8\" is not. See " diff --git a/library/xml.po b/library/xml.po index 412087cf883..8bc8f969634 100644 --- a/library/xml.po +++ b/library/xml.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-12 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-08-21 02:16+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,22 +23,22 @@ msgstr "" msgid "XML Processing Modules" msgstr "XML 處理模組" -#: ../../library/xml.rst:12 +#: ../../library/xml.rst:9 msgid "**Source code:** :source:`Lib/xml/`" msgstr "**原始碼:**\\ :source:`Lib/xml/`" -#: ../../library/xml.rst:16 +#: ../../library/xml.rst:13 msgid "" "Python's interfaces for processing XML are grouped in the ``xml`` package." msgstr "Python 處理 XML 的介面被歸類於 ``xml`` 套件中。" -#: ../../library/xml.rst:20 +#: ../../library/xml.rst:17 msgid "" "If you need to parse untrusted or unauthenticated data, see :ref:`xml-" "security`." msgstr "如果你需要剖析不受信任或未經驗證的資料,請參閱 :ref:`xml-security`。" -#: ../../library/xml.rst:23 +#: ../../library/xml.rst:20 msgid "" "It is important to note that modules in the :mod:`!xml` package require that " "there be at least one SAX-compliant XML parser available. The Expat parser " @@ -49,7 +49,7 @@ msgstr "" "Expat 剖析器包含在 Python 中,所以總是可以使用 :mod:`xml.parsers.expat` 模" "組。" -#: ../../library/xml.rst:28 +#: ../../library/xml.rst:25 msgid "" "The documentation for the :mod:`xml.dom` and :mod:`xml.sax` packages are the " "definition of the Python bindings for the DOM and SAX interfaces." @@ -57,42 +57,74 @@ msgstr "" ":mod:`xml.dom` 和 :mod:`xml.sax` 套件的文件為 DOM 和 SAX 介面的 Python 繫結的" "定義。" -#: ../../library/xml.rst:31 +#: ../../library/xml.rst:28 msgid "The XML handling submodules are:" msgstr "以下是 XML 處理子模組:" -#: ../../library/xml.rst:33 +#: ../../library/xml.rst:30 msgid "" ":mod:`xml.etree.ElementTree`: the ElementTree API, a simple and lightweight " "XML processor" msgstr "" ":mod:`xml.etree.ElementTree`:ElementTree API,一個簡單且輕量級的 XML 處理器" -#: ../../library/xml.rst:38 +#: ../../library/xml.rst:35 msgid ":mod:`xml.dom`: the DOM API definition" msgstr ":mod:`xml.dom`:DOM API 定義" -#: ../../library/xml.rst:39 +#: ../../library/xml.rst:36 msgid ":mod:`xml.dom.minidom`: a minimal DOM implementation" msgstr ":mod:`xml.dom.minidom`:最小的 DOM 實作" -#: ../../library/xml.rst:40 +#: ../../library/xml.rst:37 msgid ":mod:`xml.dom.pulldom`: support for building partial DOM trees" msgstr ":mod:`xml.dom.pulldom`:支援建置部分 DOM 樹" -#: ../../library/xml.rst:44 +#: ../../library/xml.rst:41 msgid ":mod:`xml.sax`: SAX2 base classes and convenience functions" msgstr ":mod:`xml.sax`:SAX2 基底類別和便利函式" -#: ../../library/xml.rst:45 +#: ../../library/xml.rst:42 msgid ":mod:`xml.parsers.expat`: the Expat parser binding" msgstr ":mod:`xml.parsers.expat`:Expat 剖析器繫結" -#: ../../library/xml.rst:52 +#: ../../library/xml.rst:44 +msgid "This module also defines utility functions." +msgstr "" + +#: ../../library/xml.rst:48 +msgid "" +"Return ``True`` if the string is a valid element or attribute name, " +"``False`` otherwise." +msgstr "" + +#: ../../library/xml.rst:51 +msgid "" +"Almost all characters are permitted in names, except control characters and " +"those which either are or reasonably could be used as delimiters. Characters " +"like \":\", \"-\", \".\", \"_\", and \"·\" are permitted, but \"<\", \"/\", " +"\"!\", \"?\", and \"=\" are forbidden. The name cannot start with a digit or " +"a character like \"-\", \".\", and \"·\"." +msgstr "" + +#: ../../library/xml.rst:62 +msgid "" +"Return ``True`` if the string is a sequence of legal XML 1.0 characters, " +"``False`` otherwise." +msgstr "" + +#: ../../library/xml.rst:65 +msgid "" +"Almost all characters are permitted in XML 1.0 documents, except C0 control " +"characters (excluding TAB, CR and LF), surrogate characters and special " +"Unicode characters U+FFFE and U+FFFF." +msgstr "" + +#: ../../library/xml.rst:76 msgid "XML security" msgstr "XML 安全性" -#: ../../library/xml.rst:54 +#: ../../library/xml.rst:78 msgid "" "An attacker can abuse XML features to carry out denial of service attacks, " "access local files, generate network connections to other machines, or " @@ -103,19 +135,19 @@ msgstr "" "地檔案、生成與其他機器的網路連接或繞過防火牆,無論由攻擊者控制的 XML 是在 " "Python 中還是其他地方被剖析。" -#: ../../library/xml.rst:59 +#: ../../library/xml.rst:83 msgid "" "The built-in XML parsers of Python rely on the library `libexpat`_, commonly " "called Expat, for parsing XML." msgstr "" -#: ../../library/xml.rst:62 +#: ../../library/xml.rst:86 msgid "" "By default, Expat itself does not access local files or create network " "connections." msgstr "" -#: ../../library/xml.rst:65 +#: ../../library/xml.rst:89 msgid "" "Expat versions lower than 2.7.2 may be vulnerable to the \"billion laughs\", " "\"quadratic blowup\" and \"large tokens\" vulnerabilities, or to " @@ -126,15 +158,15 @@ msgid "" "Expat. Check :const:`!pyexpat.EXPAT_VERSION`." msgstr "" -#: ../../library/xml.rst:74 +#: ../../library/xml.rst:98 msgid ":mod:`xmlrpc` is **vulnerable** to the \"decompression bomb\" attack." msgstr ":mod:`xmlrpc` 容易受到「解壓縮炸彈」攻擊。" -#: ../../library/xml.rst:77 +#: ../../library/xml.rst:101 msgid "billion laughs / exponential entity expansion" msgstr "十億笑聲 / 指數實體擴展" -#: ../../library/xml.rst:78 +#: ../../library/xml.rst:102 msgid "" "The `Billion Laughs`_ attack -- also known as exponential entity expansion " "-- uses multiple levels of nested entities. Each entity refers to another " @@ -146,11 +178,11 @@ msgstr "" "expansion))使用多層巢狀實體。每個實體多次引用另一個實體,最終的實體定義包含" "一個小字串。指數擴展會產生數 GB 的文本,並消耗大量記憶體和 CPU 時間。" -#: ../../library/xml.rst:84 +#: ../../library/xml.rst:108 msgid "quadratic blowup entity expansion" msgstr "二次爆炸實體擴展" -#: ../../library/xml.rst:85 +#: ../../library/xml.rst:109 msgid "" "A quadratic blowup attack is similar to a `Billion Laughs`_ attack; it " "abuses entity expansion, too. Instead of nested entities it repeats one " @@ -162,11 +194,11 @@ msgstr "" "它不是巢狀實體,而是一遍又一遍地重複一個具有幾千個字元的大型實體。該攻擊不如" "指數擴展那麼有效率,但它不會觸發那些用來防止深度巢狀實體的剖析器對策。" -#: ../../library/xml.rst:91 +#: ../../library/xml.rst:115 msgid "decompression bomb" msgstr "解壓縮炸彈 (decompression bomb)" -#: ../../library/xml.rst:92 +#: ../../library/xml.rst:116 msgid "" "Decompression bombs (aka `ZIP bomb`_) apply to all XML libraries that can " "parse compressed XML streams such as gzipped HTTP streams or LZMA-compressed " @@ -177,11 +209,11 @@ msgstr "" "壓縮的 HTTP 串流或 LZMA 壓縮檔案)的 XML 函式庫。對於攻擊者來說,它可以將傳輸" "的資料量減少三個或更多數量級。" -#: ../../library/xml.rst:98 +#: ../../library/xml.rst:122 msgid "large tokens" msgstr "大型 token" -#: ../../library/xml.rst:99 +#: ../../library/xml.rst:123 msgid "" "Expat needs to re-parse unfinished tokens; without the protection introduced " "in Expat 2.6.0, this can lead to quadratic runtime that can be used to cause " diff --git a/library/xml.sax.handler.po b/library/xml.sax.handler.po index 3edacc6573a..21a8d01c47b 100644 --- a/library/xml.sax.handler.po +++ b/library/xml.sax.handler.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-03 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2016-11-19 00:36+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!xml.sax.handler` --- Base classes for SAX handlers" msgstr ":mod:`!xml.sax.handler` --- SAX 處理函式的基本類別" -#: ../../library/xml.sax.handler.rst:10 +#: ../../library/xml.sax.handler.rst:7 msgid "**Source code:** :source:`Lib/xml/sax/handler.py`" msgstr "**原始碼:**\\ :source:`Lib/xml/sax/handler.py`" -#: ../../library/xml.sax.handler.rst:14 +#: ../../library/xml.sax.handler.rst:11 msgid "" "The SAX API defines five kinds of handlers: content handlers, DTD handlers, " "error handlers, entity resolvers and lexical handlers. Applications normally " @@ -36,128 +36,128 @@ msgid "" "implementations." msgstr "" -#: ../../library/xml.sax.handler.rst:24 +#: ../../library/xml.sax.handler.rst:21 msgid "" "This is the main callback interface in SAX, and the one most important to " "applications. The order of events in this interface mirrors the order of the " "information in the document." msgstr "" -#: ../../library/xml.sax.handler.rst:31 +#: ../../library/xml.sax.handler.rst:28 msgid "Handle DTD events." msgstr "" -#: ../../library/xml.sax.handler.rst:33 +#: ../../library/xml.sax.handler.rst:30 msgid "" "This interface specifies only those DTD events required for basic parsing " "(unparsed entities and attributes)." msgstr "" -#: ../../library/xml.sax.handler.rst:39 +#: ../../library/xml.sax.handler.rst:36 msgid "" "Basic interface for resolving entities. If you create an object implementing " "this interface, then register the object with your Parser, the parser will " "call the method in your object to resolve all external entities." msgstr "" -#: ../../library/xml.sax.handler.rst:46 +#: ../../library/xml.sax.handler.rst:43 msgid "" "Interface used by the parser to present error and warning messages to the " "application. The methods of this object control whether errors are " "immediately converted to exceptions or are handled in some other way." msgstr "" -#: ../../library/xml.sax.handler.rst:53 +#: ../../library/xml.sax.handler.rst:50 msgid "" "Interface used by the parser to represent low frequency events which may not " "be of interest to many applications." msgstr "" -#: ../../library/xml.sax.handler.rst:56 +#: ../../library/xml.sax.handler.rst:53 msgid "" "In addition to these classes, :mod:`!xml.sax.handler` provides symbolic " "constants for the feature and property names." msgstr "" -#: ../../library/xml.sax.handler.rst:62 +#: ../../library/xml.sax.handler.rst:59 msgid "value: ``\"http://xml.org/sax/features/namespaces\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:63 +#: ../../library/xml.sax.handler.rst:60 msgid "true: Perform Namespace processing." msgstr "" -#: ../../library/xml.sax.handler.rst:65 +#: ../../library/xml.sax.handler.rst:62 msgid "" "false: Optionally do not perform Namespace processing (implies namespace-" "prefixes; default)." msgstr "" -#: ../../library/xml.sax.handler.rst:66 ../../library/xml.sax.handler.rst:76 -#: ../../library/xml.sax.handler.rst:88 ../../library/xml.sax.handler.rst:97 -#: ../../library/xml.sax.handler.rst:116 ../../library/xml.sax.handler.rst:126 -#: ../../library/xml.sax.handler.rst:163 +#: ../../library/xml.sax.handler.rst:63 ../../library/xml.sax.handler.rst:73 +#: ../../library/xml.sax.handler.rst:85 ../../library/xml.sax.handler.rst:94 +#: ../../library/xml.sax.handler.rst:113 ../../library/xml.sax.handler.rst:123 +#: ../../library/xml.sax.handler.rst:160 msgid "access: (parsing) read-only; (not parsing) read/write" msgstr "" -#: ../../library/xml.sax.handler.rst:71 +#: ../../library/xml.sax.handler.rst:68 msgid "value: ``\"http://xml.org/sax/features/namespace-prefixes\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:73 +#: ../../library/xml.sax.handler.rst:70 msgid "" "true: Report the original prefixed names and attributes used for Namespace " "declarations." msgstr "" -#: ../../library/xml.sax.handler.rst:75 +#: ../../library/xml.sax.handler.rst:72 msgid "" "false: Do not report attributes used for Namespace declarations, and " "optionally do not report original prefixed names (default)." msgstr "" -#: ../../library/xml.sax.handler.rst:78 ../../library/xml.sax.handler.rst:128 +#: ../../library/xml.sax.handler.rst:75 ../../library/xml.sax.handler.rst:125 msgid "" "The parser based on :mod:`xml.parsers.expat` does not support this feature." msgstr "" -#: ../../library/xml.sax.handler.rst:83 +#: ../../library/xml.sax.handler.rst:80 msgid "value: ``\"http://xml.org/sax/features/string-interning\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:86 +#: ../../library/xml.sax.handler.rst:83 msgid "" "true: All element names, prefixes, attribute names, Namespace URIs, and " "local names are interned in a dictionary (see :data:" "`property_interning_dict`)." msgstr "" -#: ../../library/xml.sax.handler.rst:87 +#: ../../library/xml.sax.handler.rst:84 msgid "" "false: Names are not necessarily interned, although they may be (default)." msgstr "" -#: ../../library/xml.sax.handler.rst:93 +#: ../../library/xml.sax.handler.rst:90 msgid "value: ``\"http://xml.org/sax/features/validation\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:95 +#: ../../library/xml.sax.handler.rst:92 msgid "" "true: Report all validation errors (implies external-general-entities and " "external-parameter-entities)." msgstr "" -#: ../../library/xml.sax.handler.rst:96 +#: ../../library/xml.sax.handler.rst:93 msgid "false: Do not report validation errors." msgstr "" -#: ../../library/xml.sax.handler.rst:99 +#: ../../library/xml.sax.handler.rst:96 msgid "" "The parser based on :mod:`xml.parsers.expat` does not support this feature, " "because Expat is a non-validating parser." msgstr "" -#: ../../library/xml.sax.handler.rst:107 +#: ../../library/xml.sax.handler.rst:104 msgid "" "Enabling opens a vulnerability to `external entity attacks `_ if the parser is used with " @@ -165,161 +165,161 @@ msgid "" "wikipedia.org/wiki/Threat_model>`_ before enabling this feature." msgstr "" -#: ../../library/xml.sax.handler.rst:113 +#: ../../library/xml.sax.handler.rst:110 msgid "value: ``\"http://xml.org/sax/features/external-general-entities\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:114 +#: ../../library/xml.sax.handler.rst:111 msgid "true: Include all external general (text) entities." msgstr "" -#: ../../library/xml.sax.handler.rst:115 +#: ../../library/xml.sax.handler.rst:112 msgid "false: Do not include external general entities." msgstr "" -#: ../../library/xml.sax.handler.rst:121 +#: ../../library/xml.sax.handler.rst:118 msgid "value: ``\"http://xml.org/sax/features/external-parameter-entities\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:123 +#: ../../library/xml.sax.handler.rst:120 msgid "" "true: Include all external parameter entities, including the external DTD " "subset." msgstr "" -#: ../../library/xml.sax.handler.rst:125 +#: ../../library/xml.sax.handler.rst:122 msgid "" "false: Do not include any external parameter entities, even the external DTD " "subset." msgstr "" -#: ../../library/xml.sax.handler.rst:133 +#: ../../library/xml.sax.handler.rst:130 msgid "List of all features." msgstr "" -#: ../../library/xml.sax.handler.rst:138 +#: ../../library/xml.sax.handler.rst:135 msgid "value: ``\"http://xml.org/sax/properties/lexical-handler\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:139 +#: ../../library/xml.sax.handler.rst:136 msgid "data type: :class:`~xml.sax.handler.LexicalHandler`" msgstr "" -#: ../../library/xml.sax.handler.rst:141 +#: ../../library/xml.sax.handler.rst:138 msgid "" "description: An optional extension handler for lexical events like comments." msgstr "" -#: ../../library/xml.sax.handler.rst:142 ../../library/xml.sax.handler.rst:151 -#: ../../library/xml.sax.handler.rst:182 ../../library/xml.sax.handler.rst:195 +#: ../../library/xml.sax.handler.rst:139 ../../library/xml.sax.handler.rst:148 +#: ../../library/xml.sax.handler.rst:179 ../../library/xml.sax.handler.rst:192 msgid "access: read/write" msgstr "" -#: ../../library/xml.sax.handler.rst:147 +#: ../../library/xml.sax.handler.rst:144 msgid "value: ``\"http://xml.org/sax/properties/declaration-handler\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:148 +#: ../../library/xml.sax.handler.rst:145 msgid "data type: an object implementing the SAX2 ``DeclHandler`` interface" msgstr "" -#: ../../library/xml.sax.handler.rst:150 +#: ../../library/xml.sax.handler.rst:147 msgid "" "description: An optional extension handler for DTD-related events other than " "notations and unparsed entities." msgstr "" -#: ../../library/xml.sax.handler.rst:153 +#: ../../library/xml.sax.handler.rst:150 msgid "" "No parser in the standard library supports this property, and the standard " "library provides no such handler." msgstr "" -#: ../../library/xml.sax.handler.rst:159 +#: ../../library/xml.sax.handler.rst:156 msgid "value: ``\"http://xml.org/sax/properties/dom-node\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:160 +#: ../../library/xml.sax.handler.rst:157 msgid "data type: :class:`xml.dom.Node`" msgstr "" -#: ../../library/xml.sax.handler.rst:162 +#: ../../library/xml.sax.handler.rst:159 msgid "" "description: When parsing, the current DOM node being visited if this is a " "DOM iterator; when not parsing, the root DOM node for iteration." msgstr "" -#: ../../library/xml.sax.handler.rst:165 ../../library/xml.sax.handler.rst:184 +#: ../../library/xml.sax.handler.rst:162 ../../library/xml.sax.handler.rst:181 msgid "No parser in the standard library supports this property." msgstr "" -#: ../../library/xml.sax.handler.rst:170 +#: ../../library/xml.sax.handler.rst:167 msgid "value: ``\"http://xml.org/sax/properties/xml-string\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:171 +#: ../../library/xml.sax.handler.rst:168 msgid "data type: Bytes" msgstr "" -#: ../../library/xml.sax.handler.rst:173 +#: ../../library/xml.sax.handler.rst:170 msgid "" "description: The literal string of characters that was the source for the " "current event." msgstr "" -#: ../../library/xml.sax.handler.rst:174 +#: ../../library/xml.sax.handler.rst:171 msgid "access: read-only, and only during a handler callback" msgstr "" -#: ../../library/xml.sax.handler.rst:179 +#: ../../library/xml.sax.handler.rst:176 msgid "value: ``\"http://www.python.org/sax/properties/encoding\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:180 +#: ../../library/xml.sax.handler.rst:177 msgid "data type: String" msgstr "" -#: ../../library/xml.sax.handler.rst:181 +#: ../../library/xml.sax.handler.rst:178 msgid "description: The name of the encoding to assume for input data." msgstr "" -#: ../../library/xml.sax.handler.rst:189 +#: ../../library/xml.sax.handler.rst:186 msgid "value: ``\"http://www.python.org/sax/properties/interning-dict\"``" msgstr "" -#: ../../library/xml.sax.handler.rst:190 +#: ../../library/xml.sax.handler.rst:187 msgid "data type: Dictionary" msgstr "" -#: ../../library/xml.sax.handler.rst:194 +#: ../../library/xml.sax.handler.rst:191 msgid "" "description: The dictionary used to intern names, or ``None`` if names are " "not interned. Setting it enables interning, as does the :data:" "`feature_string_interning` feature." msgstr "" -#: ../../library/xml.sax.handler.rst:200 +#: ../../library/xml.sax.handler.rst:197 msgid "List of all known property names." msgstr "" -#: ../../library/xml.sax.handler.rst:206 +#: ../../library/xml.sax.handler.rst:203 msgid "ContentHandler Objects" msgstr "ContentHandler 物件" -#: ../../library/xml.sax.handler.rst:208 +#: ../../library/xml.sax.handler.rst:205 msgid "" "Users are expected to subclass :class:`ContentHandler` to support their " "application. The following methods are called by the parser on the " "appropriate events in the input document:" msgstr "" -#: ../../library/xml.sax.handler.rst:215 +#: ../../library/xml.sax.handler.rst:212 msgid "" "Called by the parser to give the application a locator for locating the " "origin of document events." msgstr "" -#: ../../library/xml.sax.handler.rst:218 +#: ../../library/xml.sax.handler.rst:215 msgid "" "SAX parsers are strongly encouraged (though not absolutely required) to " "supply a locator: if it does so, it must supply the locator to the " @@ -327,7 +327,7 @@ msgid "" "in the DocumentHandler interface." msgstr "" -#: ../../library/xml.sax.handler.rst:223 +#: ../../library/xml.sax.handler.rst:220 msgid "" "The locator allows the application to determine the end position of any " "document-related event, even if the parser is not reporting an error. " @@ -337,28 +337,28 @@ msgid "" "sufficient for use with a search engine." msgstr "" -#: ../../library/xml.sax.handler.rst:230 +#: ../../library/xml.sax.handler.rst:227 msgid "" "Note that the locator will return correct information only during the " "invocation of the events in this interface. The application should not " "attempt to use it at any other time." msgstr "" -#: ../../library/xml.sax.handler.rst:237 +#: ../../library/xml.sax.handler.rst:234 msgid "Receive notification of the beginning of a document." msgstr "" -#: ../../library/xml.sax.handler.rst:239 +#: ../../library/xml.sax.handler.rst:236 msgid "" "The SAX parser will invoke this method only once, before any other methods " "in this interface or in DTDHandler (except for :meth:`setDocumentLocator`)." msgstr "" -#: ../../library/xml.sax.handler.rst:245 +#: ../../library/xml.sax.handler.rst:242 msgid "Receive notification of the end of a document." msgstr "" -#: ../../library/xml.sax.handler.rst:247 +#: ../../library/xml.sax.handler.rst:244 msgid "" "The SAX parser will invoke this method only once, and it will be the last " "method invoked during the parse. The parser shall not invoke this method " @@ -366,11 +366,11 @@ msgid "" "reached the end of input." msgstr "" -#: ../../library/xml.sax.handler.rst:255 +#: ../../library/xml.sax.handler.rst:252 msgid "Begin the scope of a prefix-URI Namespace mapping." msgstr "" -#: ../../library/xml.sax.handler.rst:257 +#: ../../library/xml.sax.handler.rst:254 msgid "" "The information from this event is not necessary for normal Namespace " "processing: the SAX XML reader will automatically replace prefixes for " @@ -378,7 +378,7 @@ msgid "" "enabled (the default)." msgstr "" -#: ../../library/xml.sax.handler.rst:262 +#: ../../library/xml.sax.handler.rst:259 msgid "" "There are cases, however, when applications need to use prefixes in " "character data or in attribute values, where they cannot safely be expanded " @@ -387,7 +387,7 @@ msgid "" "contexts itself, if necessary." msgstr "" -#: ../../library/xml.sax.handler.rst:270 +#: ../../library/xml.sax.handler.rst:267 msgid "" "Note that :meth:`startPrefixMapping` and :meth:`endPrefixMapping` events are " "not guaranteed to be properly nested relative to each-other: all :meth:" @@ -397,22 +397,22 @@ msgid "" "guaranteed." msgstr "" -#: ../../library/xml.sax.handler.rst:280 +#: ../../library/xml.sax.handler.rst:277 msgid "End the scope of a prefix-URI mapping." msgstr "" -#: ../../library/xml.sax.handler.rst:282 +#: ../../library/xml.sax.handler.rst:279 msgid "" "See :meth:`startPrefixMapping` for details. This event will always occur " "after the corresponding :meth:`endElement` event, but the order of :meth:" "`endPrefixMapping` events is not otherwise guaranteed." msgstr "" -#: ../../library/xml.sax.handler.rst:289 +#: ../../library/xml.sax.handler.rst:286 msgid "Signals the start of an element in non-namespace mode." msgstr "" -#: ../../library/xml.sax.handler.rst:291 +#: ../../library/xml.sax.handler.rst:288 msgid "" "The *name* parameter contains the raw XML 1.0 name of the element type as a " "string and the *attrs* parameter holds an object of the :ref:`Attributes " @@ -423,21 +423,21 @@ msgid "" "object." msgstr "" -#: ../../library/xml.sax.handler.rst:302 +#: ../../library/xml.sax.handler.rst:299 msgid "Signals the end of an element in non-namespace mode." msgstr "" -#: ../../library/xml.sax.handler.rst:304 +#: ../../library/xml.sax.handler.rst:301 msgid "" "The *name* parameter contains the name of the element type, just as with " "the :meth:`startElement` event." msgstr "" -#: ../../library/xml.sax.handler.rst:310 +#: ../../library/xml.sax.handler.rst:307 msgid "Signals the start of an element in namespace mode." msgstr "" -#: ../../library/xml.sax.handler.rst:312 +#: ../../library/xml.sax.handler.rst:309 msgid "" "The *name* parameter contains the name of the element type as a ``(uri, " "localname)`` tuple, the *qname* parameter contains the raw XML 1.0 name used " @@ -450,27 +450,27 @@ msgid "" "attributes, use the :meth:`copy` method of the *attrs* object." msgstr "" -#: ../../library/xml.sax.handler.rst:322 +#: ../../library/xml.sax.handler.rst:319 msgid "" "Parsers may set the *qname* parameter to ``None``, unless the " "``feature_namespace_prefixes`` feature is activated." msgstr "" -#: ../../library/xml.sax.handler.rst:328 +#: ../../library/xml.sax.handler.rst:325 msgid "Signals the end of an element in namespace mode." msgstr "" -#: ../../library/xml.sax.handler.rst:330 +#: ../../library/xml.sax.handler.rst:327 msgid "" "The *name* parameter contains the name of the element type, just as with " "the :meth:`startElementNS` method, likewise the *qname* parameter." msgstr "" -#: ../../library/xml.sax.handler.rst:336 +#: ../../library/xml.sax.handler.rst:333 msgid "Receive notification of character data." msgstr "" -#: ../../library/xml.sax.handler.rst:338 +#: ../../library/xml.sax.handler.rst:335 msgid "" "The Parser will call this method to report each chunk of character data. SAX " "parsers may return all contiguous character data in a single chunk, or they " @@ -479,13 +479,13 @@ msgid "" "provides useful information." msgstr "" -#: ../../library/xml.sax.handler.rst:344 +#: ../../library/xml.sax.handler.rst:341 msgid "" "*content* may be a string or bytes instance; the ``expat`` reader module " "always produces strings." msgstr "" -#: ../../library/xml.sax.handler.rst:349 +#: ../../library/xml.sax.handler.rst:346 msgid "" "The earlier SAX 1 interface provided by the Python XML Special Interest " "Group used a more Java-like interface for this method. Since most parsers " @@ -495,11 +495,11 @@ msgid "" "and *length* parameters." msgstr "" -#: ../../library/xml.sax.handler.rst:358 +#: ../../library/xml.sax.handler.rst:355 msgid "Receive notification of ignorable whitespace in element content." msgstr "" -#: ../../library/xml.sax.handler.rst:360 +#: ../../library/xml.sax.handler.rst:357 msgid "" "Validating Parsers must use this method to report each chunk of ignorable " "whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-" @@ -507,7 +507,7 @@ msgid "" "and using content models." msgstr "" -#: ../../library/xml.sax.handler.rst:365 +#: ../../library/xml.sax.handler.rst:362 msgid "" "SAX parsers may return all contiguous whitespace in a single chunk, or they " "may split it into several chunks; however, all of the characters in any " @@ -515,28 +515,28 @@ msgid "" "provides useful information." msgstr "" -#: ../../library/xml.sax.handler.rst:373 +#: ../../library/xml.sax.handler.rst:370 msgid "Receive notification of a processing instruction." msgstr "" -#: ../../library/xml.sax.handler.rst:375 +#: ../../library/xml.sax.handler.rst:372 msgid "" "The Parser will invoke this method once for each processing instruction " "found: note that processing instructions may occur before or after the main " "document element." msgstr "" -#: ../../library/xml.sax.handler.rst:379 +#: ../../library/xml.sax.handler.rst:376 msgid "" "A SAX parser should never report an XML declaration (XML 1.0, section 2.8) " "or a text declaration (XML 1.0, section 4.3.1) using this method." msgstr "" -#: ../../library/xml.sax.handler.rst:385 +#: ../../library/xml.sax.handler.rst:382 msgid "Receive notification of a skipped entity." msgstr "" -#: ../../library/xml.sax.handler.rst:387 +#: ../../library/xml.sax.handler.rst:384 msgid "" "The Parser will invoke this method once for each entity skipped. Non-" "validating processors may skip entities if they have not seen the " @@ -546,38 +546,38 @@ msgid "" "properties." msgstr "" -#: ../../library/xml.sax.handler.rst:397 +#: ../../library/xml.sax.handler.rst:394 msgid "DTDHandler Objects" msgstr "DTDHandler 物件" -#: ../../library/xml.sax.handler.rst:399 +#: ../../library/xml.sax.handler.rst:396 msgid ":class:`DTDHandler` instances provide the following methods:" msgstr "" -#: ../../library/xml.sax.handler.rst:404 +#: ../../library/xml.sax.handler.rst:401 msgid "Handle a notation declaration event." msgstr "" -#: ../../library/xml.sax.handler.rst:409 +#: ../../library/xml.sax.handler.rst:406 msgid "Handle an unparsed entity declaration event." msgstr "" -#: ../../library/xml.sax.handler.rst:415 +#: ../../library/xml.sax.handler.rst:412 msgid "EntityResolver Objects" msgstr "EntityResolver 物件" -#: ../../library/xml.sax.handler.rst:420 +#: ../../library/xml.sax.handler.rst:417 msgid "" "Resolve the system identifier of an entity and return either the system " "identifier to read from as a string, or an InputSource to read from. The " "default implementation returns *systemId*." msgstr "" -#: ../../library/xml.sax.handler.rst:428 +#: ../../library/xml.sax.handler.rst:425 msgid "ErrorHandler Objects" msgstr "ErrorHandler 物件" -#: ../../library/xml.sax.handler.rst:430 +#: ../../library/xml.sax.handler.rst:427 msgid "" "Objects with this interface are used to receive error and warning " "information from the :class:`~xml.sax.xmlreader.XMLReader`. If you create " @@ -590,7 +590,7 @@ msgid "" "the passed-in exception object." msgstr "" -#: ../../library/xml.sax.handler.rst:443 +#: ../../library/xml.sax.handler.rst:440 msgid "" "Called when the parser encounters a recoverable error. If this method does " "not raise an exception, parsing may continue, but further document " @@ -599,13 +599,13 @@ msgid "" "document." msgstr "" -#: ../../library/xml.sax.handler.rst:451 +#: ../../library/xml.sax.handler.rst:448 msgid "" "Called when the parser encounters an error it cannot recover from; parsing " "is expected to terminate when this method returns." msgstr "" -#: ../../library/xml.sax.handler.rst:457 +#: ../../library/xml.sax.handler.rst:454 msgid "" "Called when the parser presents minor warning information to the " "application. Parsing is expected to continue when this method returns, and " @@ -613,15 +613,15 @@ msgid "" "an exception in this method will cause parsing to end." msgstr "" -#: ../../library/xml.sax.handler.rst:466 +#: ../../library/xml.sax.handler.rst:463 msgid "LexicalHandler Objects" msgstr "LexicalHandler 物件" -#: ../../library/xml.sax.handler.rst:467 +#: ../../library/xml.sax.handler.rst:464 msgid "Optional SAX2 handler for lexical events." msgstr "" -#: ../../library/xml.sax.handler.rst:469 +#: ../../library/xml.sax.handler.rst:466 msgid "" "This handler is used to obtain lexical information about an XML document. " "Lexical information includes information describing the document encoding " @@ -630,38 +630,38 @@ msgid "" "used in the same manner as content handlers." msgstr "" -#: ../../library/xml.sax.handler.rst:475 +#: ../../library/xml.sax.handler.rst:472 msgid "" "Set the LexicalHandler of an XMLReader by using the setProperty method with " "the property identifier ``'http://xml.org/sax/properties/lexical-handler'``." msgstr "" -#: ../../library/xml.sax.handler.rst:482 +#: ../../library/xml.sax.handler.rst:479 msgid "" "Reports a comment anywhere in the document (including the DTD and outside " "the document element)." msgstr "" -#: ../../library/xml.sax.handler.rst:487 +#: ../../library/xml.sax.handler.rst:484 msgid "" "Reports the start of the DTD declarations if the document has an associated " "DTD." msgstr "" -#: ../../library/xml.sax.handler.rst:492 +#: ../../library/xml.sax.handler.rst:489 msgid "Reports the end of DTD declaration." msgstr "" -#: ../../library/xml.sax.handler.rst:496 +#: ../../library/xml.sax.handler.rst:493 msgid "Reports the start of a CDATA marked section." msgstr "" -#: ../../library/xml.sax.handler.rst:498 +#: ../../library/xml.sax.handler.rst:495 msgid "" "The contents of the CDATA marked section will be reported through the " "characters handler." msgstr "" -#: ../../library/xml.sax.handler.rst:503 +#: ../../library/xml.sax.handler.rst:500 msgid "Reports the end of a CDATA marked section." msgstr "" diff --git a/library/xml.sax.po b/library/xml.sax.po index 337ea691f50..3fccdc0c5af 100644 --- a/library/xml.sax.po +++ b/library/xml.sax.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-03 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2016-11-19 00:36+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,11 +22,11 @@ msgstr "" msgid ":mod:`!xml.sax` --- Support for SAX2 parsers" msgstr ":mod:`!xml.sax` --- SAX2 剖析器支援" -#: ../../library/xml.sax.rst:11 +#: ../../library/xml.sax.rst:7 msgid "**Source code:** :source:`Lib/xml/sax/__init__.py`" msgstr "**原始碼:**\\ :source:`Lib/xml/sax/__init__.py`" -#: ../../library/xml.sax.rst:15 +#: ../../library/xml.sax.rst:11 msgid "" "The :mod:`!xml.sax` package provides a number of modules which implement the " "Simple API for XML (SAX) interface for Python. The package itself provides " @@ -34,13 +34,13 @@ msgid "" "users of the SAX API." msgstr "" -#: ../../library/xml.sax.rst:23 +#: ../../library/xml.sax.rst:19 msgid "" "If you need to parse untrusted or unauthenticated data, see :ref:`xml-" "security`." msgstr "如果你需要剖析不受信任或未經驗證的資料,請參閱 :ref:`xml-security`。" -#: ../../library/xml.sax.rst:28 +#: ../../library/xml.sax.rst:24 msgid "" "The SAX parser no longer processes general external entities by default to " "increase security. Before, the parser created network connections to fetch " @@ -50,11 +50,11 @@ msgid "" "`~xml.sax.handler.feature_external_ges`." msgstr "" -#: ../../library/xml.sax.rst:35 +#: ../../library/xml.sax.rst:31 msgid "The convenience functions and data are:" msgstr "" -#: ../../library/xml.sax.rst:40 +#: ../../library/xml.sax.rst:36 msgid "" "Create and return a SAX :class:`~xml.sax.xmlreader.XMLReader` object. The " "first parser found will be used. If *parser_list* is provided, it must be " @@ -63,11 +63,11 @@ msgid "" "modules in the default list of parsers." msgstr "" -#: ../../library/xml.sax.rst:46 +#: ../../library/xml.sax.rst:42 msgid "The *parser_list* argument can be any iterable, not just a list." msgstr "" -#: ../../library/xml.sax.rst:52 +#: ../../library/xml.sax.rst:48 msgid "" "Create a SAX parser and use it to parse a document. The document, passed in " "as *filename_or_stream*, can be a system identifier (a string identifying " @@ -81,18 +81,18 @@ msgid "" "*handler* passed in." msgstr "" -#: ../../library/xml.sax.rst:68 +#: ../../library/xml.sax.rst:64 msgid "" "Similar to :func:`parse`, but parses from a buffer *string* received as a " "parameter. *string* must be a :class:`str` instance or a :term:`bytes-like " "object`." msgstr "" -#: ../../library/xml.sax.rst:72 +#: ../../library/xml.sax.rst:68 msgid "Added support of :class:`str` instances." msgstr "新增 :class:`str` 實例的支援。" -#: ../../library/xml.sax.rst:78 +#: ../../library/xml.sax.rst:74 msgid "" "The list of the names of modules which are tried by :func:`make_parser` " "after the modules named in its *parser_list* argument. It contains ``'xml." @@ -101,7 +101,7 @@ msgid "" "module names taken from it." msgstr "" -#: ../../library/xml.sax.rst:84 +#: ../../library/xml.sax.rst:80 msgid "" "A typical SAX application uses three kinds of objects: readers, handlers and " "input sources. \"Reader\" in this context is another term for parser, i.e. " @@ -115,7 +115,7 @@ msgid "" "structural and syntactic events from the input data." msgstr "" -#: ../../library/xml.sax.rst:95 +#: ../../library/xml.sax.rst:91 msgid "" "For these objects, only the interfaces are relevant; they are normally not " "instantiated by the application itself. Since Python does not have an " @@ -131,13 +131,13 @@ msgid "" "interfaces are described below." msgstr "" -#: ../../library/xml.sax.rst:108 +#: ../../library/xml.sax.rst:104 msgid "" "In addition to these classes, :mod:`!xml.sax` provides the following " "exception classes." msgstr "" -#: ../../library/xml.sax.rst:114 +#: ../../library/xml.sax.rst:110 msgid "" "Encapsulate an XML error or warning. This class can contain basic error or " "warning information from either the XML parser or the application: it can be " @@ -148,7 +148,7 @@ msgid "" "container for information." msgstr "" -#: ../../library/xml.sax.rst:122 +#: ../../library/xml.sax.rst:118 msgid "" "When instantiated, *msg* should be a human-readable description of the " "error. The optional *exception* parameter, if given, should be ``None`` or " @@ -156,11 +156,11 @@ msgid "" "as information." msgstr "" -#: ../../library/xml.sax.rst:126 +#: ../../library/xml.sax.rst:122 msgid "This is the base class for the other SAX exception classes." msgstr "" -#: ../../library/xml.sax.rst:131 +#: ../../library/xml.sax.rst:127 msgid "" "Subclass of :exc:`SAXException` raised on parse errors. Instances of this " "class are passed to the methods of the SAX :class:`~xml.sax.handler." @@ -169,14 +169,14 @@ msgid "" "as the :class:`SAXException` interface." msgstr "" -#: ../../library/xml.sax.rst:141 +#: ../../library/xml.sax.rst:137 msgid "" "Subclass of :exc:`SAXException` raised when a SAX :class:`~xml.sax.xmlreader." "XMLReader` is confronted with an unrecognized feature or property. SAX " "applications and extensions may use this class for similar purposes." msgstr "" -#: ../../library/xml.sax.rst:149 +#: ../../library/xml.sax.rst:145 msgid "" "Subclass of :exc:`SAXException` raised when a SAX :class:`~xml.sax.xmlreader." "XMLReader` is asked to enable a feature that is not supported, or to set a " @@ -184,7 +184,7 @@ msgid "" "applications and extensions may use this class for similar purposes." msgstr "" -#: ../../library/xml.sax.rst:158 +#: ../../library/xml.sax.rst:154 msgid "" "Subclass of :exc:`SAXNotSupportedException` raised when no parser is " "available. A parser module raises it when it is imported or during parsing " @@ -192,54 +192,54 @@ msgid "" "if no module from the tried ones provides a usable parser." msgstr "" -#: ../../library/xml.sax.rst:166 +#: ../../library/xml.sax.rst:162 msgid "`SAX: The Simple API for XML `_" msgstr "" -#: ../../library/xml.sax.rst:167 +#: ../../library/xml.sax.rst:163 msgid "" "This site is the focal point for the definition of the SAX API. It provides " "a Java implementation and online documentation. Links to implementations " "and historical information are also available." msgstr "" -#: ../../library/xml.sax.rst:171 +#: ../../library/xml.sax.rst:167 msgid "Module :mod:`xml.sax.handler`" msgstr ":mod:`xml.sax.handler` 模組" -#: ../../library/xml.sax.rst:172 +#: ../../library/xml.sax.rst:168 msgid "Definitions of the interfaces for application-provided objects." msgstr "" -#: ../../library/xml.sax.rst:174 +#: ../../library/xml.sax.rst:170 msgid "Module :mod:`xml.sax.saxutils`" msgstr ":mod:`xml.sax.saxutils` 模組" -#: ../../library/xml.sax.rst:175 +#: ../../library/xml.sax.rst:171 msgid "Convenience functions for use in SAX applications." msgstr "" -#: ../../library/xml.sax.rst:177 +#: ../../library/xml.sax.rst:173 msgid "Module :mod:`xml.sax.xmlreader`" msgstr ":mod:`xml.sax.xmlreader` 模組" -#: ../../library/xml.sax.rst:178 +#: ../../library/xml.sax.rst:174 msgid "Definitions of the interfaces for parser-provided objects." msgstr "" -#: ../../library/xml.sax.rst:184 +#: ../../library/xml.sax.rst:180 msgid "SAXException Objects" msgstr "SAXException 物件" -#: ../../library/xml.sax.rst:186 +#: ../../library/xml.sax.rst:182 msgid "" "The :class:`SAXException` exception class supports the following methods:" msgstr "" -#: ../../library/xml.sax.rst:191 +#: ../../library/xml.sax.rst:187 msgid "Return a human-readable message describing the error condition." msgstr "" -#: ../../library/xml.sax.rst:196 +#: ../../library/xml.sax.rst:192 msgid "Return an encapsulated exception object, or ``None``." msgstr "" diff --git a/library/xml.sax.reader.po b/library/xml.sax.reader.po index e20e91fdfaf..4d8ab4be251 100644 --- a/library/xml.sax.reader.po +++ b/library/xml.sax.reader.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-03 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:16+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!xml.sax.xmlreader` --- Interface for XML parsers" msgstr ":mod:`!xml.sax.xmlreader` --- XML 剖析器的介面" -#: ../../library/xml.sax.reader.rst:10 +#: ../../library/xml.sax.reader.rst:7 msgid "**Source code:** :source:`Lib/xml/sax/xmlreader.py`" msgstr "**原始碼:**\\ :source:`Lib/xml/sax/xmlreader.py`" -#: ../../library/xml.sax.reader.rst:14 +#: ../../library/xml.sax.reader.rst:11 msgid "" "SAX parsers implement the :class:`XMLReader` interface. They are implemented " "in a Python module, which must provide a function :func:`create_parser`. " @@ -33,11 +33,11 @@ msgid "" "to create a new parser object." msgstr "" -#: ../../library/xml.sax.reader.rst:22 +#: ../../library/xml.sax.reader.rst:19 msgid "Base class which can be inherited by SAX parsers." msgstr "" -#: ../../library/xml.sax.reader.rst:27 +#: ../../library/xml.sax.reader.rst:24 msgid "" "In some cases, it is desirable not to parse an input source at once, but to " "feed chunks of the document as they get available. Note that the reader will " @@ -47,7 +47,7 @@ msgid "" "desirable." msgstr "" -#: ../../library/xml.sax.reader.rst:33 +#: ../../library/xml.sax.reader.rst:30 msgid "" "When the parser is instantiated it is ready to begin accepting data from the " "feed method immediately. After parsing has been finished with a call to " @@ -55,20 +55,20 @@ msgid "" "data, either from feed or using the parse method." msgstr "" -#: ../../library/xml.sax.reader.rst:38 +#: ../../library/xml.sax.reader.rst:35 msgid "" "Note that these methods must *not* be called during parsing, that is, after " "parse has been called and before it returns." msgstr "" -#: ../../library/xml.sax.reader.rst:41 +#: ../../library/xml.sax.reader.rst:38 msgid "" "By default, the class also implements the parse method of the XMLReader " "interface using the feed, close and reset methods of the IncrementalParser " "interface as a convenience to SAX 2.0 driver writers." msgstr "" -#: ../../library/xml.sax.reader.rst:48 +#: ../../library/xml.sax.reader.rst:45 msgid "" "Interface for associating a SAX event with a document location. A locator " "object will return valid results only during calls to DocumentHandler " @@ -76,33 +76,33 @@ msgid "" "not available, methods may return ``None``." msgstr "" -#: ../../library/xml.sax.reader.rst:56 +#: ../../library/xml.sax.reader.rst:53 msgid "" "Encapsulation of the information needed by the :class:`XMLReader` to read " "entities." msgstr "" -#: ../../library/xml.sax.reader.rst:59 +#: ../../library/xml.sax.reader.rst:56 msgid "" "This class may include information about the public identifier, system " "identifier, byte stream (possibly with character encoding information) and/" "or the character stream of an entity." msgstr "" -#: ../../library/xml.sax.reader.rst:63 +#: ../../library/xml.sax.reader.rst:60 msgid "" "Applications will create objects of this class for use in the :meth:" "`XMLReader.parse` method and for returning from EntityResolver.resolveEntity." msgstr "" -#: ../../library/xml.sax.reader.rst:67 +#: ../../library/xml.sax.reader.rst:64 msgid "" "An :class:`InputSource` belongs to the application, the :class:`XMLReader` " "is not allowed to modify :class:`InputSource` objects passed to it from the " "application, although it may make copies and modify those." msgstr "" -#: ../../library/xml.sax.reader.rst:74 +#: ../../library/xml.sax.reader.rst:71 msgid "" "This is an implementation of the :class:`Attributes` interface (see section :" "ref:`attributes-objects`). This is a dictionary-like object which " @@ -113,7 +113,7 @@ msgid "" "a mapping from attribute names to attribute values." msgstr "" -#: ../../library/xml.sax.reader.rst:85 +#: ../../library/xml.sax.reader.rst:82 msgid "" "Namespace-aware variant of :class:`AttributesImpl`, which will be passed to :" "meth:`startElementNS`. It is derived from :class:`AttributesImpl`, but " @@ -123,15 +123,15 @@ msgid "" "`AttributesNS` interface (see section :ref:`attributes-ns-objects`)." msgstr "" -#: ../../library/xml.sax.reader.rst:96 +#: ../../library/xml.sax.reader.rst:93 msgid "XMLReader Objects" msgstr "XMLReader 物件" -#: ../../library/xml.sax.reader.rst:98 +#: ../../library/xml.sax.reader.rst:95 msgid "The :class:`XMLReader` interface supports the following methods:" msgstr "" -#: ../../library/xml.sax.reader.rst:103 +#: ../../library/xml.sax.reader.rst:100 msgid "" "Process an input source, producing SAX events. The *source* object can be a " "system identifier (a string identifying the input source -- typically a file " @@ -141,39 +141,39 @@ msgid "" "discarded or reset." msgstr "" -#: ../../library/xml.sax.reader.rst:110 +#: ../../library/xml.sax.reader.rst:107 msgid "Added support of character streams." msgstr "新增對字元串流的支援。" -#: ../../library/xml.sax.reader.rst:113 +#: ../../library/xml.sax.reader.rst:110 msgid "Added support of path-like objects." msgstr "新增對類路徑物件的支援。" -#: ../../library/xml.sax.reader.rst:119 +#: ../../library/xml.sax.reader.rst:116 msgid "Return the current :class:`~xml.sax.handler.ContentHandler`." msgstr "" -#: ../../library/xml.sax.reader.rst:124 +#: ../../library/xml.sax.reader.rst:121 msgid "" "Set the current :class:`~xml.sax.handler.ContentHandler`. If no :class:" "`~xml.sax.handler.ContentHandler` is set, content events will be discarded." msgstr "" -#: ../../library/xml.sax.reader.rst:131 +#: ../../library/xml.sax.reader.rst:128 msgid "Return the current :class:`~xml.sax.handler.DTDHandler`." msgstr "" -#: ../../library/xml.sax.reader.rst:136 +#: ../../library/xml.sax.reader.rst:133 msgid "" "Set the current :class:`~xml.sax.handler.DTDHandler`. If no :class:`~xml." "sax.handler.DTDHandler` is set, DTD events will be discarded." msgstr "" -#: ../../library/xml.sax.reader.rst:143 +#: ../../library/xml.sax.reader.rst:140 msgid "Return the current :class:`~xml.sax.handler.EntityResolver`." msgstr "" -#: ../../library/xml.sax.reader.rst:148 +#: ../../library/xml.sax.reader.rst:145 msgid "" "Set the current :class:`~xml.sax.handler.EntityResolver`. If no :class:" "`~xml.sax.handler.EntityResolver` is set, attempts to resolve an external " @@ -181,21 +181,21 @@ msgid "" "if it is not available." msgstr "" -#: ../../library/xml.sax.reader.rst:156 +#: ../../library/xml.sax.reader.rst:153 msgid "Return the current :class:`~xml.sax.handler.ErrorHandler`." msgstr "" -#: ../../library/xml.sax.reader.rst:161 +#: ../../library/xml.sax.reader.rst:158 msgid "" "Set the current error handler. If no :class:`~xml.sax.handler.ErrorHandler` " "is set, errors will be raised as exceptions, and warnings will be printed." msgstr "" -#: ../../library/xml.sax.reader.rst:167 +#: ../../library/xml.sax.reader.rst:164 msgid "Allow an application to set the locale for errors and warnings." msgstr "" -#: ../../library/xml.sax.reader.rst:169 +#: ../../library/xml.sax.reader.rst:166 msgid "" "SAX parsers are not required to provide localization for errors and " "warnings; if they cannot support the requested locale, however, they must " @@ -203,56 +203,56 @@ msgid "" "middle of a parse." msgstr "" -#: ../../library/xml.sax.reader.rst:176 +#: ../../library/xml.sax.reader.rst:173 msgid "" "Return the current setting for feature *featurename*. If the feature is not " "recognized, :exc:`SAXNotRecognizedException` is raised. The well-known " "featurenames are listed in the module :mod:`xml.sax.handler`." msgstr "" -#: ../../library/xml.sax.reader.rst:183 +#: ../../library/xml.sax.reader.rst:180 msgid "" "Set the *featurename* to *value*. If the feature is not recognized, :exc:" "`SAXNotRecognizedException` is raised. If the feature or its setting is not " "supported by the parser, *SAXNotSupportedException* is raised." msgstr "" -#: ../../library/xml.sax.reader.rst:190 +#: ../../library/xml.sax.reader.rst:187 msgid "" "Return the current setting for property *propertyname*. If the property is " "not recognized, a :exc:`SAXNotRecognizedException` is raised. The well-known " "propertynames are listed in the module :mod:`xml.sax.handler`." msgstr "" -#: ../../library/xml.sax.reader.rst:197 +#: ../../library/xml.sax.reader.rst:194 msgid "" "Set the *propertyname* to *value*. If the property is not recognized, :exc:" "`SAXNotRecognizedException` is raised. If the property or its setting is not " "supported by the parser, *SAXNotSupportedException* is raised." msgstr "" -#: ../../library/xml.sax.reader.rst:205 +#: ../../library/xml.sax.reader.rst:202 msgid "IncrementalParser Objects" msgstr "IncrementalParser 物件" -#: ../../library/xml.sax.reader.rst:207 +#: ../../library/xml.sax.reader.rst:204 msgid "" "Instances of :class:`IncrementalParser` offer the following additional " "methods:" msgstr "" -#: ../../library/xml.sax.reader.rst:212 +#: ../../library/xml.sax.reader.rst:209 msgid "Process a chunk of *data*." msgstr "" -#: ../../library/xml.sax.reader.rst:217 +#: ../../library/xml.sax.reader.rst:214 msgid "" "Assume the end of the document. That will check well-formedness conditions " "that can be checked only at the end, invoke handlers, and may clean up " "resources allocated during parsing." msgstr "" -#: ../../library/xml.sax.reader.rst:224 +#: ../../library/xml.sax.reader.rst:221 msgid "" "Prepare the parser for parsing *source*, an :class:`InputSource` instance. " "It is called by :meth:`~XMLReader.parse` before feeding the data. The parser " @@ -260,124 +260,124 @@ msgid "" "exc:`NotImplementedError`." msgstr "" -#: ../../library/xml.sax.reader.rst:233 +#: ../../library/xml.sax.reader.rst:230 msgid "" "This method is called after close has been called to reset the parser so " "that it is ready to parse new documents. The results of calling parse or " "feed after close without calling reset are undefined." msgstr "" -#: ../../library/xml.sax.reader.rst:241 +#: ../../library/xml.sax.reader.rst:238 msgid "Locator Objects" msgstr "" -#: ../../library/xml.sax.reader.rst:243 +#: ../../library/xml.sax.reader.rst:240 msgid "Instances of :class:`Locator` provide these methods:" msgstr "" -#: ../../library/xml.sax.reader.rst:248 +#: ../../library/xml.sax.reader.rst:245 msgid "Return the column number where the current event begins." msgstr "" -#: ../../library/xml.sax.reader.rst:253 +#: ../../library/xml.sax.reader.rst:250 msgid "Return the line number where the current event begins." msgstr "" -#: ../../library/xml.sax.reader.rst:258 +#: ../../library/xml.sax.reader.rst:255 msgid "Return the public identifier for the current event." msgstr "" -#: ../../library/xml.sax.reader.rst:263 +#: ../../library/xml.sax.reader.rst:260 msgid "Return the system identifier for the current event." msgstr "" -#: ../../library/xml.sax.reader.rst:269 +#: ../../library/xml.sax.reader.rst:266 msgid "InputSource Objects" msgstr "InputSource 物件" -#: ../../library/xml.sax.reader.rst:274 +#: ../../library/xml.sax.reader.rst:271 msgid "Sets the public identifier of this :class:`InputSource`." msgstr "" -#: ../../library/xml.sax.reader.rst:279 +#: ../../library/xml.sax.reader.rst:276 msgid "Returns the public identifier of this :class:`InputSource`." msgstr "" -#: ../../library/xml.sax.reader.rst:284 +#: ../../library/xml.sax.reader.rst:281 msgid "Sets the system identifier of this :class:`InputSource`." msgstr "" -#: ../../library/xml.sax.reader.rst:289 +#: ../../library/xml.sax.reader.rst:286 msgid "Returns the system identifier of this :class:`InputSource`." msgstr "" -#: ../../library/xml.sax.reader.rst:294 +#: ../../library/xml.sax.reader.rst:291 msgid "Sets the character encoding of this :class:`InputSource`." msgstr "" -#: ../../library/xml.sax.reader.rst:296 +#: ../../library/xml.sax.reader.rst:293 msgid "" "The encoding must be a string acceptable for an XML encoding declaration " "(see section 4.3.3 of the XML recommendation)." msgstr "" -#: ../../library/xml.sax.reader.rst:299 +#: ../../library/xml.sax.reader.rst:296 msgid "" "The encoding attribute of the :class:`InputSource` is ignored if the :class:" "`InputSource` also contains a character stream." msgstr "" -#: ../../library/xml.sax.reader.rst:305 +#: ../../library/xml.sax.reader.rst:302 msgid "Get the character encoding of this InputSource." msgstr "" -#: ../../library/xml.sax.reader.rst:310 +#: ../../library/xml.sax.reader.rst:307 msgid "Set the byte stream (a :term:`binary file`) for this input source." msgstr "" -#: ../../library/xml.sax.reader.rst:312 +#: ../../library/xml.sax.reader.rst:309 msgid "" "The SAX parser will ignore this if there is also a character stream " "specified, but it will use a byte stream in preference to opening a URI " "connection itself." msgstr "" -#: ../../library/xml.sax.reader.rst:315 +#: ../../library/xml.sax.reader.rst:312 msgid "" "If the application knows the character encoding of the byte stream, it " "should set it with the setEncoding method." msgstr "" -#: ../../library/xml.sax.reader.rst:321 +#: ../../library/xml.sax.reader.rst:318 msgid "Get the byte stream for this input source." msgstr "" -#: ../../library/xml.sax.reader.rst:323 +#: ../../library/xml.sax.reader.rst:320 msgid "" "The getEncoding method will return the character encoding for this byte " "stream, or ``None`` if unknown." msgstr "" -#: ../../library/xml.sax.reader.rst:329 +#: ../../library/xml.sax.reader.rst:326 msgid "Set the character stream (a :term:`text file`) for this input source." msgstr "" -#: ../../library/xml.sax.reader.rst:331 +#: ../../library/xml.sax.reader.rst:328 msgid "" "If there is a character stream specified, the SAX parser will ignore any " "byte stream and will not attempt to open a URI connection to the system " "identifier." msgstr "" -#: ../../library/xml.sax.reader.rst:337 +#: ../../library/xml.sax.reader.rst:334 msgid "Get the character stream for this input source." msgstr "" -#: ../../library/xml.sax.reader.rst:343 +#: ../../library/xml.sax.reader.rst:340 msgid "The :class:`Attributes` Interface" msgstr "" -#: ../../library/xml.sax.reader.rst:345 +#: ../../library/xml.sax.reader.rst:342 msgid "" ":class:`Attributes` objects implement a portion of the :term:`mapping " "protocol `, including the methods :meth:`~collections.abc.Mapping." @@ -387,50 +387,50 @@ msgid "" "are also provided:" msgstr "" -#: ../../library/xml.sax.reader.rst:355 +#: ../../library/xml.sax.reader.rst:352 msgid "Return the number of attributes." msgstr "" -#: ../../library/xml.sax.reader.rst:360 +#: ../../library/xml.sax.reader.rst:357 msgid "Return the names of the attributes." msgstr "" -#: ../../library/xml.sax.reader.rst:365 +#: ../../library/xml.sax.reader.rst:362 msgid "" "Returns the type of the attribute *name*, which is normally ``'CDATA'``." msgstr "" -#: ../../library/xml.sax.reader.rst:370 +#: ../../library/xml.sax.reader.rst:367 msgid "Return the value of attribute *name*." msgstr "" -#: ../../library/xml.sax.reader.rst:379 +#: ../../library/xml.sax.reader.rst:376 msgid "The :class:`AttributesNS` Interface" msgstr "" -#: ../../library/xml.sax.reader.rst:381 +#: ../../library/xml.sax.reader.rst:378 msgid "" "This interface is a subtype of the :class:`Attributes` interface (see " "section :ref:`attributes-objects`). All methods supported by that interface " "are also available on :class:`AttributesNS` objects." msgstr "" -#: ../../library/xml.sax.reader.rst:385 +#: ../../library/xml.sax.reader.rst:382 msgid "The following methods are also available:" msgstr "" -#: ../../library/xml.sax.reader.rst:390 +#: ../../library/xml.sax.reader.rst:387 msgid "Return the value for a qualified name." msgstr "" -#: ../../library/xml.sax.reader.rst:395 +#: ../../library/xml.sax.reader.rst:392 msgid "Return the ``(namespace, localname)`` pair for a qualified *name*." msgstr "" -#: ../../library/xml.sax.reader.rst:400 +#: ../../library/xml.sax.reader.rst:397 msgid "Return the qualified name for a ``(namespace, localname)`` pair." msgstr "" -#: ../../library/xml.sax.reader.rst:405 +#: ../../library/xml.sax.reader.rst:402 msgid "Return the qualified names of all attributes." msgstr "" diff --git a/library/xml.sax.utils.po b/library/xml.sax.utils.po index bbf588e6265..5882406a890 100644 --- a/library/xml.sax.utils.po +++ b/library/xml.sax.utils.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-03 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-07-10 23:59+0800\n" "Last-Translator: Weilin Du <1372449351@qq.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!xml.sax.saxutils` --- SAX Utilities" msgstr ":mod:`!xml.sax.saxutils` --- SAX 工具程式" -#: ../../library/xml.sax.utils.rst:10 +#: ../../library/xml.sax.utils.rst:7 msgid "**Source code:** :source:`Lib/xml/sax/saxutils.py`" msgstr "**原始碼:**\\ :source:`Lib/xml/sax/saxutils.py`" -#: ../../library/xml.sax.utils.rst:14 +#: ../../library/xml.sax.utils.rst:11 msgid "" "The module :mod:`!xml.sax.saxutils` contains a number of classes and " "functions that are commonly useful when creating SAX applications, either in " @@ -36,11 +36,11 @@ msgstr "" "模組 :mod:`!xml.sax.saxutils` 包含了許多在建立 SAX 應用程式時非常有用的類別和" "函式,這些類別和函式可以直接使用,也可以作為基底類別。" -#: ../../library/xml.sax.utils.rst:21 +#: ../../library/xml.sax.utils.rst:18 msgid "Escape ``'&'``, ``'<'``, and ``'>'`` in a string of data." msgstr "在資料字串中跳脫 ``'&'``、``'<'`` 及 ``'>'``。" -#: ../../library/xml.sax.utils.rst:23 +#: ../../library/xml.sax.utils.rst:20 msgid "" "You can escape other strings of data by passing a dictionary as the optional " "*entities* parameter. The keys and values must all be strings; each key " @@ -51,7 +51,7 @@ msgstr "" "須是字串;每個鍵都會被對應的值取代。即使提供 *entities*,``'&'``、``'<'`` 和 " "``'>'`` 字元始終會被跳脫。" -#: ../../library/xml.sax.utils.rst:30 +#: ../../library/xml.sax.utils.rst:27 msgid "" "This function should only be used to escape characters that can't be used " "directly in XML. Do not use this function as a general string translation " @@ -60,11 +60,11 @@ msgstr "" "這個函式只能用來跳脫 XML 中無法直接使用的字元。請勿將此函式用作一般的字串轉換" "函式。" -#: ../../library/xml.sax.utils.rst:36 +#: ../../library/xml.sax.utils.rst:33 msgid "Unescape ``'&'``, ``'<'``, and ``'>'`` in a string of data." msgstr "取消跳脫資料字串中的 ``'&'``、``'<'`` 和 ``'>'``。" -#: ../../library/xml.sax.utils.rst:38 +#: ../../library/xml.sax.utils.rst:35 msgid "" "You can unescape other strings of data by passing a dictionary as the " "optional *entities* parameter. The keys and values must all be strings; " @@ -76,7 +76,7 @@ msgstr "" "必須是字串;每個鍵都會被對應的值取代。即使提供了 *entities*,``'&'``、" "``'<’`` 和 ``‘>'`` 總是會取消跳脫。" -#: ../../library/xml.sax.utils.rst:46 +#: ../../library/xml.sax.utils.rst:43 msgid "" "Similar to :func:`escape`, but also prepares *data* to be used as an " "attribute value. The return value is a quoted version of *data* with any " @@ -92,7 +92,7 @@ msgstr "" "經有單引號和雙引號字元,雙引號字元將被編碼,而 *data* 將被雙引號包覆。結果字" "串可直接用作屬性值:" -#: ../../library/xml.sax.utils.rst:55 +#: ../../library/xml.sax.utils.rst:52 msgid "" ">>> print(\"\" % quoteattr(\"ab ' cd \\\" ef\"))\n" "" @@ -100,13 +100,13 @@ msgstr "" ">>> print(\"\" % quoteattr(\"ab ' cd \\\" ef\"))\n" "" -#: ../../library/xml.sax.utils.rst:58 +#: ../../library/xml.sax.utils.rst:55 msgid "" "This function is useful when generating attribute values for HTML or any " "SGML using the reference concrete syntax." msgstr "當使用參考具體語法為 HTML 或任何 SGML 產生屬性值時,此功能非常有用。" -#: ../../library/xml.sax.utils.rst:64 +#: ../../library/xml.sax.utils.rst:61 msgid "" "This class implements the :class:`~xml.sax.handler.ContentHandler` interface " "by writing SAX events back into an XML document. In other words, using an :" @@ -126,11 +126,11 @@ msgstr "" "始/結束(start/end)標籤的形式輸出;如果設定為 ``True``,它們會以單一自封" "(self-closed)標籤的形式輸出。" -#: ../../library/xml.sax.utils.rst:74 +#: ../../library/xml.sax.utils.rst:71 msgid "Added the *short_empty_elements* parameter." msgstr "新增 *short_empty_elements* 參數。" -#: ../../library/xml.sax.utils.rst:80 +#: ../../library/xml.sax.utils.rst:77 msgid "" "This class is designed to sit between an :class:`~xml.sax.xmlreader." "XMLReader` and the client application's event handlers. By default, it does " @@ -143,15 +143,15 @@ msgstr "" "經修改地傳送到處理程式,但子類別可以覆寫特定的方法,以在傳送它們的時候修改事" "件串流或配置請求。" -#: ../../library/xml.sax.utils.rst:89 +#: ../../library/xml.sax.utils.rst:86 msgid "Return the parent reader, or ``None`` if it is not set." msgstr "" -#: ../../library/xml.sax.utils.rst:94 +#: ../../library/xml.sax.utils.rst:91 msgid "Set the parent reader, which the events are read from." msgstr "" -#: ../../library/xml.sax.utils.rst:99 +#: ../../library/xml.sax.utils.rst:96 msgid "" "This function takes an input source and an optional base URL and returns a " "fully resolved :class:`~xml.sax.xmlreader.InputSource` object ready for " diff --git a/library/xmlrpc.client.po b/library/xmlrpc.client.po index 3a528658e9d..80d4bf08b01 100644 --- a/library/xmlrpc.client.po +++ b/library/xmlrpc.client.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-22 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:16+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!xmlrpc.client` --- XML-RPC client access" msgstr ":mod:`!xmlrpc.client` --- XML-RPC 用戶端存取" -#: ../../library/xmlrpc.client.rst:10 +#: ../../library/xmlrpc.client.rst:7 msgid "**Source code:** :source:`Lib/xmlrpc/client.py`" msgstr "**原始碼:**\\ :source:`Lib/xmlrpc/client.py`" -#: ../../library/xmlrpc.client.rst:17 +#: ../../library/xmlrpc.client.rst:14 msgid "" "XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP(S) " "as a transport. With it, a client can call methods with parameters on a " @@ -34,14 +34,14 @@ msgid "" "of translating between conformable Python objects and XML on the wire." msgstr "" -#: ../../library/xmlrpc.client.rst:26 +#: ../../library/xmlrpc.client.rst:23 msgid "" "The :mod:`!xmlrpc.client` module is not secure against maliciously " "constructed data. If you need to parse untrusted or unauthenticated data, " "see :ref:`xml-security`." msgstr "" -#: ../../library/xmlrpc.client.rst:32 +#: ../../library/xmlrpc.client.rst:29 msgid "" "For HTTPS URIs, :mod:`!xmlrpc.client` now performs all the necessary " "certificate and hostname checks by default." @@ -59,7 +59,7 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/xmlrpc.client.rst:41 +#: ../../library/xmlrpc.client.rst:38 msgid "" "A :class:`ServerProxy` instance is an object that manages communication with " "a remote XML-RPC server. The required first argument is a URI (Uniform " @@ -71,7 +71,7 @@ msgid "" "flag." msgstr "" -#: ../../library/xmlrpc.client.rst:49 +#: ../../library/xmlrpc.client.rst:46 msgid "" "The following parameters govern the use of the returned proxy instance. If " "*allow_none* is true, the Python constant ``None`` will be translated into " @@ -93,15 +93,15 @@ msgid "" "values." msgstr "" -#: ../../library/xmlrpc.client.rst:69 ../../library/xmlrpc.client.rst:549 +#: ../../library/xmlrpc.client.rst:66 ../../library/xmlrpc.client.rst:546 msgid "The *use_builtin_types* flag was added." msgstr "新增 *use_builtin_types* 旗標。" -#: ../../library/xmlrpc.client.rst:72 +#: ../../library/xmlrpc.client.rst:69 msgid "The *headers* parameter was added." msgstr "新增 *headers* 參數。" -#: ../../library/xmlrpc.client.rst:75 +#: ../../library/xmlrpc.client.rst:72 msgid "" "Both the HTTP and HTTPS transports support the URL syntax extension for HTTP " "Basic Authentication: ``http://user:pass@host:port/path``. The ``user:" @@ -111,7 +111,7 @@ msgid "" "Basic Authentication user and password." msgstr "" -#: ../../library/xmlrpc.client.rst:82 +#: ../../library/xmlrpc.client.rst:79 msgid "" "The returned instance is a proxy object with methods that can be used to " "invoke corresponding RPC calls on the remote server. If the remote server " @@ -120,114 +120,114 @@ msgid "" "other server-associated metadata." msgstr "" -#: ../../library/xmlrpc.client.rst:88 +#: ../../library/xmlrpc.client.rst:85 msgid "" "Types that are conformable (e.g. that can be marshalled through XML), " "include the following (and except where noted, they are unmarshalled as the " "same Python type):" msgstr "" -#: ../../library/xmlrpc.client.rst:95 +#: ../../library/xmlrpc.client.rst:92 msgid "XML-RPC type" msgstr "" -#: ../../library/xmlrpc.client.rst:95 +#: ../../library/xmlrpc.client.rst:92 msgid "Python type" msgstr "" -#: ../../library/xmlrpc.client.rst:97 +#: ../../library/xmlrpc.client.rst:94 msgid "``boolean``" msgstr "``boolean``" -#: ../../library/xmlrpc.client.rst:97 +#: ../../library/xmlrpc.client.rst:94 msgid ":class:`bool`" msgstr ":class:`bool`" -#: ../../library/xmlrpc.client.rst:99 +#: ../../library/xmlrpc.client.rst:96 msgid "``int``, ``i1``, ``i2``, ``i4``, ``i8`` or ``biginteger``" msgstr "``int``、``i1``、``i2``、``i4``、``i8`` 或 ``biginteger``" -#: ../../library/xmlrpc.client.rst:99 +#: ../../library/xmlrpc.client.rst:96 msgid "" ":class:`int` in range from -2147483648 to 2147483647. Values get the " "```` tag." msgstr "" -#: ../../library/xmlrpc.client.rst:104 +#: ../../library/xmlrpc.client.rst:101 msgid "``double`` or ``float``" msgstr "``double`` 或 ``float``" -#: ../../library/xmlrpc.client.rst:104 +#: ../../library/xmlrpc.client.rst:101 msgid ":class:`float`. Values get the ```` tag." msgstr "" -#: ../../library/xmlrpc.client.rst:107 +#: ../../library/xmlrpc.client.rst:104 msgid "``string``" msgstr "``string``" -#: ../../library/xmlrpc.client.rst:107 +#: ../../library/xmlrpc.client.rst:104 msgid ":class:`str`" msgstr ":class:`str`" -#: ../../library/xmlrpc.client.rst:109 +#: ../../library/xmlrpc.client.rst:106 msgid "``array``" msgstr "``array``" -#: ../../library/xmlrpc.client.rst:109 +#: ../../library/xmlrpc.client.rst:106 msgid "" ":class:`list` or :class:`tuple` containing conformable elements. Arrays are " "returned as :class:`lists `." msgstr "" -#: ../../library/xmlrpc.client.rst:113 +#: ../../library/xmlrpc.client.rst:110 msgid "``struct``" msgstr "``struct``" -#: ../../library/xmlrpc.client.rst:113 +#: ../../library/xmlrpc.client.rst:110 msgid "" ":class:`dict`. Keys must be strings, values may be any conformable type. " "Objects of user-defined classes can be passed in; only their :attr:`~object." "__dict__` attribute is transmitted." msgstr "" -#: ../../library/xmlrpc.client.rst:118 +#: ../../library/xmlrpc.client.rst:115 msgid "``dateTime.iso8601``" msgstr "``dateTime.iso8601``" -#: ../../library/xmlrpc.client.rst:118 +#: ../../library/xmlrpc.client.rst:115 msgid "" ":class:`DateTime` or :class:`datetime.datetime`. Returned type depends on " "values of *use_builtin_types* and *use_datetime* flags." msgstr "" -#: ../../library/xmlrpc.client.rst:122 +#: ../../library/xmlrpc.client.rst:119 msgid "``base64``" msgstr "``base64``" -#: ../../library/xmlrpc.client.rst:122 +#: ../../library/xmlrpc.client.rst:119 msgid "" ":class:`Binary`, :class:`bytes` or :class:`bytearray`. Returned type " "depends on the value of the *use_builtin_types* flag." msgstr "" -#: ../../library/xmlrpc.client.rst:126 +#: ../../library/xmlrpc.client.rst:123 msgid "``nil``" msgstr "``nil``" -#: ../../library/xmlrpc.client.rst:126 +#: ../../library/xmlrpc.client.rst:123 msgid "" "The ``None`` constant. Passing is allowed only if *allow_none* is true." msgstr "" -#: ../../library/xmlrpc.client.rst:129 +#: ../../library/xmlrpc.client.rst:126 msgid "``bigdecimal``" msgstr "``bigdecimal``" -#: ../../library/xmlrpc.client.rst:129 +#: ../../library/xmlrpc.client.rst:126 msgid ":class:`decimal.Decimal`. Returned type only." msgstr "" -#: ../../library/xmlrpc.client.rst:132 +#: ../../library/xmlrpc.client.rst:129 msgid "" "This is the full set of data types supported by XML-RPC. Method calls may " "also raise a special :exc:`Fault` instance, used to signal XML-RPC server " @@ -237,7 +237,7 @@ msgid "" "currently does not marshal instances of subclasses of built-in types." msgstr "" -#: ../../library/xmlrpc.client.rst:139 +#: ../../library/xmlrpc.client.rst:136 msgid "" "When passing strings, characters special to XML such as ``<``, ``>``, and " "``&`` will be automatically escaped. However, it's the caller's " @@ -249,17 +249,17 @@ msgid "" "`bytearray` classes or the :class:`Binary` wrapper class described below." msgstr "" -#: ../../library/xmlrpc.client.rst:148 +#: ../../library/xmlrpc.client.rst:145 msgid "" ":class:`Server` is retained as an alias for :class:`ServerProxy` for " "backwards compatibility. New code should use :class:`ServerProxy`." msgstr "" -#: ../../library/xmlrpc.client.rst:151 +#: ../../library/xmlrpc.client.rst:148 msgid "Added the *context* argument." msgstr "加入 *context* 引數。" -#: ../../library/xmlrpc.client.rst:154 +#: ../../library/xmlrpc.client.rst:151 msgid "" "Added support of type tags with prefixes (e.g. ``ex:nil``). Added support of " "unmarshalling additional types used by Apache XML-RPC implementation for " @@ -268,61 +268,61 @@ msgid "" "description." msgstr "" -#: ../../library/xmlrpc.client.rst:164 +#: ../../library/xmlrpc.client.rst:161 msgid "`XML-RPC HOWTO `_" msgstr "`XML-RPC HOWTO `_" -#: ../../library/xmlrpc.client.rst:165 +#: ../../library/xmlrpc.client.rst:162 msgid "" "A good description of XML-RPC operation and client software in several " "languages. Contains pretty much everything an XML-RPC client developer needs " "to know." msgstr "" -#: ../../library/xmlrpc.client.rst:168 +#: ../../library/xmlrpc.client.rst:165 msgid "" "`XML-RPC Introspection `_" msgstr "" -#: ../../library/xmlrpc.client.rst:169 +#: ../../library/xmlrpc.client.rst:166 msgid "Describes the XML-RPC protocol extension for introspection." msgstr "" -#: ../../library/xmlrpc.client.rst:171 +#: ../../library/xmlrpc.client.rst:168 msgid "`XML-RPC Specification `_" msgstr "" -#: ../../library/xmlrpc.client.rst:172 +#: ../../library/xmlrpc.client.rst:169 msgid "The official specification." msgstr "" -#: ../../library/xmlrpc.client.rst:177 +#: ../../library/xmlrpc.client.rst:174 msgid "ServerProxy Objects" msgstr "ServerProxy 物件" -#: ../../library/xmlrpc.client.rst:179 +#: ../../library/xmlrpc.client.rst:176 msgid "" "A :class:`ServerProxy` instance has a method corresponding to each remote " "procedure call accepted by the XML-RPC server. Calling the method performs " "an RPC, dispatched by both name and argument signature (e.g. the same method " "name can be overloaded with multiple argument signatures). The RPC finishes " -"by returning a value, which may be either returned data in a conformant type " -"or a :class:`Fault` or :class:`ProtocolError` object indicating an error." +"either by returning data in a conformant type or by raising a :class:`Fault` " +"or :class:`ProtocolError` exception indicating an error." msgstr "" -#: ../../library/xmlrpc.client.rst:186 +#: ../../library/xmlrpc.client.rst:183 msgid "" "Servers that support the XML introspection API support some common methods " "grouped under the reserved :attr:`~ServerProxy.system` attribute:" msgstr "" -#: ../../library/xmlrpc.client.rst:192 +#: ../../library/xmlrpc.client.rst:189 msgid "" "This method returns a list of strings, one for each (non-system) method " "supported by the XML-RPC server." msgstr "" -#: ../../library/xmlrpc.client.rst:198 +#: ../../library/xmlrpc.client.rst:195 msgid "" "This method takes one parameter, the name of a method implemented by the XML-" "RPC server. It returns an array of possible signatures for this method. A " @@ -330,13 +330,13 @@ msgid "" "of the method, the rest are parameters." msgstr "" -#: ../../library/xmlrpc.client.rst:203 +#: ../../library/xmlrpc.client.rst:200 msgid "" "Because multiple signatures (ie. overloading) is permitted, this method " "returns a list of signatures rather than a singleton." msgstr "" -#: ../../library/xmlrpc.client.rst:206 +#: ../../library/xmlrpc.client.rst:203 msgid "" "Signatures themselves are restricted to the top level parameters expected by " "a method. For instance if a method expects one array of structs as a " @@ -345,14 +345,14 @@ msgid "" "\"string, int, int, int\"." msgstr "" -#: ../../library/xmlrpc.client.rst:211 +#: ../../library/xmlrpc.client.rst:208 msgid "" "If no signature is defined for the method, a non-array value is returned. In " "Python this means that the type of the returned value will be something " "other than list." msgstr "" -#: ../../library/xmlrpc.client.rst:218 +#: ../../library/xmlrpc.client.rst:215 msgid "" "This method takes one parameter, the name of a method implemented by the XML-" "RPC server. It returns a documentation string describing the use of that " @@ -360,17 +360,17 @@ msgid "" "documentation string may contain HTML markup." msgstr "" -#: ../../library/xmlrpc.client.rst:225 +#: ../../library/xmlrpc.client.rst:222 msgid "" "Instances of :class:`ServerProxy` support the :term:`context manager` " "protocol for closing the underlying transport." msgstr "" -#: ../../library/xmlrpc.client.rst:229 ../../library/xmlrpc.client.rst:276 +#: ../../library/xmlrpc.client.rst:226 ../../library/xmlrpc.client.rst:273 msgid "A working example follows. The server code::" msgstr "" -#: ../../library/xmlrpc.client.rst:231 +#: ../../library/xmlrpc.client.rst:228 msgid "" "from xmlrpc.server import SimpleXMLRPCServer\n" "\n" @@ -392,12 +392,12 @@ msgstr "" "server.register_function(is_even, \"is_even\")\n" "server.serve_forever()" -#: ../../library/xmlrpc.client.rst:241 ../../library/xmlrpc.client.rst:291 -#: ../../library/xmlrpc.client.rst:401 ../../library/xmlrpc.client.rst:507 +#: ../../library/xmlrpc.client.rst:238 ../../library/xmlrpc.client.rst:288 +#: ../../library/xmlrpc.client.rst:398 ../../library/xmlrpc.client.rst:504 msgid "The client code for the preceding server::" msgstr "" -#: ../../library/xmlrpc.client.rst:243 +#: ../../library/xmlrpc.client.rst:240 msgid "" "import xmlrpc.client\n" "\n" @@ -411,11 +411,11 @@ msgstr "" " print(\"3 is even: %s\" % str(proxy.is_even(3)))\n" " print(\"100 is even: %s\" % str(proxy.is_even(100)))" -#: ../../library/xmlrpc.client.rst:252 +#: ../../library/xmlrpc.client.rst:249 msgid "DateTime Objects" msgstr "日期時間物件" -#: ../../library/xmlrpc.client.rst:256 +#: ../../library/xmlrpc.client.rst:253 msgid "" "This class may be initialized with seconds since the epoch, a time tuple, an " "ISO 8601 time/date string, or a :class:`datetime.datetime` instance. It has " @@ -423,23 +423,23 @@ msgid "" "unmarshalling code:" msgstr "" -#: ../../library/xmlrpc.client.rst:264 +#: ../../library/xmlrpc.client.rst:261 msgid "Accept a string as the instance's new time value." msgstr "" -#: ../../library/xmlrpc.client.rst:269 +#: ../../library/xmlrpc.client.rst:266 msgid "" "Write the XML-RPC encoding of this :class:`DateTime` item to the *out* " "stream object." msgstr "" -#: ../../library/xmlrpc.client.rst:272 +#: ../../library/xmlrpc.client.rst:269 msgid "" "It also supports certain of Python's built-in operators through :meth:`rich " "comparison ` and :meth:`~object.__repr__` methods." msgstr "" -#: ../../library/xmlrpc.client.rst:278 +#: ../../library/xmlrpc.client.rst:275 msgid "" "import datetime as dt\n" "from xmlrpc.server import SimpleXMLRPCServer\n" @@ -467,7 +467,7 @@ msgstr "" "server.register_function(today, \"today\")\n" "server.serve_forever()" -#: ../../library/xmlrpc.client.rst:293 +#: ../../library/xmlrpc.client.rst:290 msgid "" "import xmlrpc.client\n" "import datetime as dt\n" @@ -489,61 +489,61 @@ msgstr "" "converted = dt.datetime.strptime(today.value, \"%Y%m%dT%H:%M:%S\")\n" "print(f\"Today: {converted.strftime('%d.%m.%Y, %H:%M')}\")" -#: ../../library/xmlrpc.client.rst:306 +#: ../../library/xmlrpc.client.rst:303 msgid "Binary Objects" msgstr "" -#: ../../library/xmlrpc.client.rst:310 +#: ../../library/xmlrpc.client.rst:307 msgid "" "This class may be initialized from bytes data (which may include NULs). The " "primary access to the content of a :class:`Binary` object is provided by an " "attribute:" msgstr "" -#: ../../library/xmlrpc.client.rst:317 +#: ../../library/xmlrpc.client.rst:314 msgid "" "The binary data encapsulated by the :class:`Binary` instance. The data is " "provided as a :class:`bytes` object." msgstr "" -#: ../../library/xmlrpc.client.rst:320 +#: ../../library/xmlrpc.client.rst:317 msgid "" ":class:`Binary` objects have the following methods, supported mainly for " "internal use by the marshalling/unmarshalling code:" msgstr "" -#: ../../library/xmlrpc.client.rst:326 +#: ../../library/xmlrpc.client.rst:323 msgid "" "Accept a base64 :class:`bytes` object and decode it as the instance's new " "data." msgstr "" -#: ../../library/xmlrpc.client.rst:331 +#: ../../library/xmlrpc.client.rst:328 msgid "" "Write the XML-RPC base 64 encoding of this binary item to the *out* stream " "object." msgstr "" -#: ../../library/xmlrpc.client.rst:333 +#: ../../library/xmlrpc.client.rst:330 msgid "" "The encoded data will have newlines every 76 characters as per :rfc:`RFC " "2045 section 6.8 <2045#section-6.8>`, which was the de facto standard base64 " "specification when the XML-RPC spec was written." msgstr "" -#: ../../library/xmlrpc.client.rst:338 +#: ../../library/xmlrpc.client.rst:335 msgid "" "It also supports certain of Python's built-in operators through :meth:" "`~object.__eq__` and :meth:`~object.__ne__` methods." msgstr "" -#: ../../library/xmlrpc.client.rst:341 +#: ../../library/xmlrpc.client.rst:338 msgid "" "Example usage of the binary objects. We're going to transfer an image over " "XMLRPC::" msgstr "" -#: ../../library/xmlrpc.client.rst:344 +#: ../../library/xmlrpc.client.rst:341 msgid "" "from xmlrpc.server import SimpleXMLRPCServer\n" "import xmlrpc.client\n" @@ -571,11 +571,11 @@ msgstr "" "\n" "server.serve_forever()" -#: ../../library/xmlrpc.client.rst:357 +#: ../../library/xmlrpc.client.rst:354 msgid "The client gets the image and saves it to a file::" msgstr "" -#: ../../library/xmlrpc.client.rst:359 +#: ../../library/xmlrpc.client.rst:356 msgid "" "import xmlrpc.client\n" "\n" @@ -589,31 +589,31 @@ msgstr "" "with open(\"fetched_python_logo.jpg\", \"wb\") as handle:\n" " handle.write(proxy.python_logo().data)" -#: ../../library/xmlrpc.client.rst:368 +#: ../../library/xmlrpc.client.rst:365 msgid "Fault Objects" msgstr "" -#: ../../library/xmlrpc.client.rst:372 +#: ../../library/xmlrpc.client.rst:369 msgid "" "A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. " "Fault objects have the following attributes:" msgstr "" -#: ../../library/xmlrpc.client.rst:378 +#: ../../library/xmlrpc.client.rst:375 msgid "An int indicating the fault type." msgstr "" -#: ../../library/xmlrpc.client.rst:383 +#: ../../library/xmlrpc.client.rst:380 msgid "A string containing a diagnostic message associated with the fault." msgstr "" -#: ../../library/xmlrpc.client.rst:385 +#: ../../library/xmlrpc.client.rst:382 msgid "" "In the following example we're going to intentionally cause a :exc:`Fault` " "by returning a complex type object. The server code::" msgstr "" -#: ../../library/xmlrpc.client.rst:388 +#: ../../library/xmlrpc.client.rst:385 msgid "" "from xmlrpc.server import SimpleXMLRPCServer\n" "\n" @@ -629,7 +629,7 @@ msgid "" "server.serve_forever()" msgstr "" -#: ../../library/xmlrpc.client.rst:403 +#: ../../library/xmlrpc.client.rst:400 msgid "" "import xmlrpc.client\n" "\n" @@ -651,42 +651,42 @@ msgstr "" " print(\"Fault code: %d\" % err.faultCode)\n" " print(\"Fault string: %s\" % err.faultString)" -#: ../../library/xmlrpc.client.rst:418 +#: ../../library/xmlrpc.client.rst:415 msgid "ProtocolError Objects" msgstr "ProtocolError 物件" -#: ../../library/xmlrpc.client.rst:422 +#: ../../library/xmlrpc.client.rst:419 msgid "" "A :class:`ProtocolError` object describes a protocol error in the underlying " "transport layer (such as a 404 'not found' error if the server named by the " "URI does not exist). It has the following attributes:" msgstr "" -#: ../../library/xmlrpc.client.rst:429 +#: ../../library/xmlrpc.client.rst:426 msgid "The URI or URL that triggered the error." msgstr "" -#: ../../library/xmlrpc.client.rst:434 +#: ../../library/xmlrpc.client.rst:431 msgid "The error code." msgstr "" -#: ../../library/xmlrpc.client.rst:439 +#: ../../library/xmlrpc.client.rst:436 msgid "The error message or diagnostic string." msgstr "" -#: ../../library/xmlrpc.client.rst:444 +#: ../../library/xmlrpc.client.rst:441 msgid "" "A dict containing the headers of the HTTP/HTTPS request that triggered the " "error." msgstr "" -#: ../../library/xmlrpc.client.rst:447 +#: ../../library/xmlrpc.client.rst:444 msgid "" "In the following example we're going to intentionally cause a :exc:" "`ProtocolError` by providing an invalid URI::" msgstr "" -#: ../../library/xmlrpc.client.rst:450 +#: ../../library/xmlrpc.client.rst:447 msgid "" "import xmlrpc.client\n" "\n" @@ -703,32 +703,32 @@ msgid "" " print(\"Error message: %s\" % err.errmsg)" msgstr "" -#: ../../library/xmlrpc.client.rst:465 +#: ../../library/xmlrpc.client.rst:462 msgid "MultiCall Objects" msgstr "MultiCall 物件" -#: ../../library/xmlrpc.client.rst:467 +#: ../../library/xmlrpc.client.rst:464 msgid "" "The :class:`MultiCall` object provides a way to encapsulate multiple calls " "to a remote server into a single request [#]_." msgstr "" -#: ../../library/xmlrpc.client.rst:473 +#: ../../library/xmlrpc.client.rst:470 msgid "" "Create an object used to boxcar method calls. *server* is the eventual " "target of the call. Calls can be made to the result object, but they will " -"immediately return ``None``, and only store the call name and parameters in " +"immediately return ``None``, and only store the call name and arguments in " "the :class:`MultiCall` object. Calling the object itself causes all stored " "calls to be transmitted as a single ``system.multicall`` request. The result " "of this call is a :term:`generator`; iterating over this generator yields " "the individual results." msgstr "" -#: ../../library/xmlrpc.client.rst:481 +#: ../../library/xmlrpc.client.rst:478 msgid "A usage example of this class follows. The server code::" msgstr "" -#: ../../library/xmlrpc.client.rst:483 +#: ../../library/xmlrpc.client.rst:480 msgid "" "from xmlrpc.server import SimpleXMLRPCServer\n" "\n" @@ -755,7 +755,7 @@ msgid "" "server.serve_forever()" msgstr "" -#: ../../library/xmlrpc.client.rst:509 +#: ../../library/xmlrpc.client.rst:506 msgid "" "import xmlrpc.client\n" "\n" @@ -781,11 +781,11 @@ msgstr "" "\n" "print(\"7+3=%d, 7-3=%d, 7*3=%d, 7//3=%d\" % tuple(result))" -#: ../../library/xmlrpc.client.rst:523 +#: ../../library/xmlrpc.client.rst:520 msgid "Convenience Functions" msgstr "便捷的函式" -#: ../../library/xmlrpc.client.rst:527 +#: ../../library/xmlrpc.client.rst:524 msgid "" "Convert *params* into an XML-RPC request, or into a response if " "*methodresponse* is true. *params* can be either a tuple of arguments or an " @@ -797,7 +797,7 @@ msgid "" "*allow_none*." msgstr "" -#: ../../library/xmlrpc.client.rst:538 +#: ../../library/xmlrpc.client.rst:535 msgid "" "Convert an XML-RPC request or response into Python objects, a ``(params, " "methodname)``. *params* is a tuple of argument; *methodname* is a string, " @@ -808,17 +808,17 @@ msgid "" "to be presented as :class:`bytes` objects; this flag is false by default." msgstr "" -#: ../../library/xmlrpc.client.rst:546 +#: ../../library/xmlrpc.client.rst:543 msgid "" "The obsolete *use_datetime* flag is similar to *use_builtin_types* but it " "applies only to date/time values." msgstr "" -#: ../../library/xmlrpc.client.rst:556 +#: ../../library/xmlrpc.client.rst:553 msgid "Example of Client Usage" msgstr "" -#: ../../library/xmlrpc.client.rst:560 +#: ../../library/xmlrpc.client.rst:557 msgid "" "# simple test program (from the XML-RPC specification)\n" "from xmlrpc.client import ServerProxy, Error\n" @@ -834,13 +834,13 @@ msgid "" " print(\"ERROR\", v)" msgstr "" -#: ../../library/xmlrpc.client.rst:573 +#: ../../library/xmlrpc.client.rst:570 msgid "" "To access an XML-RPC server through a HTTP proxy, you need to define a " "custom transport. The following example shows how::" msgstr "" -#: ../../library/xmlrpc.client.rst:576 +#: ../../library/xmlrpc.client.rst:573 msgid "" "import http.client\n" "import xmlrpc.client\n" @@ -884,19 +884,19 @@ msgstr "" "transport=transport)\n" "print(server.examples.getStateName(41))" -#: ../../library/xmlrpc.client.rst:598 +#: ../../library/xmlrpc.client.rst:595 msgid "Example of Client and Server Usage" msgstr "" -#: ../../library/xmlrpc.client.rst:600 +#: ../../library/xmlrpc.client.rst:597 msgid "See :ref:`simplexmlrpcserver-example`." msgstr "" -#: ../../library/xmlrpc.client.rst:604 +#: ../../library/xmlrpc.client.rst:601 msgid "Footnotes" msgstr "註腳" -#: ../../library/xmlrpc.client.rst:605 +#: ../../library/xmlrpc.client.rst:602 msgid "" "This approach has been first presented in `a discussion on xmlrpc.com " "\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!xmlrpc.server` --- Basic XML-RPC servers" msgstr ":mod:`!xmlrpc.server` --- 基本 XML-RPC 伺服器" -#: ../../library/xmlrpc.server.rst:10 +#: ../../library/xmlrpc.server.rst:7 msgid "**Source code:** :source:`Lib/xmlrpc/server.py`" msgstr "**原始碼:**\\ :source:`Lib/xmlrpc/server.py`" -#: ../../library/xmlrpc.server.rst:14 +#: ../../library/xmlrpc.server.rst:11 msgid "" "The :mod:`!xmlrpc.server` module provides a basic server framework for XML-" "RPC servers written in Python. Servers can either be free standing, using :" @@ -36,7 +36,7 @@ msgstr "" "框架。伺服器可以是獨立執行的(使用 :class:`SimpleXMLRPCServer`),或嵌入在 " "CGI 環境中(使用 :class:`CGIXMLRPCRequestHandler`)。" -#: ../../library/xmlrpc.server.rst:22 +#: ../../library/xmlrpc.server.rst:19 msgid "" "The :mod:`!xmlrpc.server` module is not secure against maliciously " "constructed data. If you need to parse untrusted or unauthenticated data, " @@ -57,7 +57,7 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/xmlrpc.server.rst:32 +#: ../../library/xmlrpc.server.rst:29 msgid "" "Create a new server instance. This class provides methods for registration " "of functions that can be called by the XML-RPC protocol. The " @@ -88,12 +88,12 @@ msgstr "" "func:`~xmlrpc.client.loads` 函式,並控制在接收到日期/時間值或二進位資料時要處" "理哪些型別;它預設為 false。" -#: ../../library/xmlrpc.server.rst:48 ../../library/xmlrpc.server.rst:62 -#: ../../library/xmlrpc.server.rst:374 +#: ../../library/xmlrpc.server.rst:45 ../../library/xmlrpc.server.rst:59 +#: ../../library/xmlrpc.server.rst:371 msgid "The *use_builtin_types* flag was added." msgstr "新增 *use_builtin_types* 旗標。" -#: ../../library/xmlrpc.server.rst:55 +#: ../../library/xmlrpc.server.rst:52 msgid "" "Create a new instance to handle XML-RPC requests in a CGI environment. The " "*allow_none* and *encoding* parameters are passed on to :mod:`xmlrpc.client` " @@ -107,7 +107,7 @@ msgstr "" "*use_builtin_types* 參數會傳遞給 :func:`~xmlrpc.client.loads` 函式,並控制在" "接收到日期/時間值或二進位資料時要處理哪些型別;它預設為 false。" -#: ../../library/xmlrpc.server.rst:68 +#: ../../library/xmlrpc.server.rst:65 msgid "" "Create a new request handler instance. This request handler supports " "``POST`` requests and modifies logging so that the *logRequests* parameter " @@ -116,11 +116,11 @@ msgstr "" "建立一個新的請求處理器實例。此請求處理器支援 ``POST`` 請求,並修改日誌記錄功" "能以遵守 :class:`SimpleXMLRPCServer` 建構函式的 *logRequests* 參數。" -#: ../../library/xmlrpc.server.rst:76 +#: ../../library/xmlrpc.server.rst:73 msgid "SimpleXMLRPCServer objects" msgstr "SimpleXMLRPCServer 物件" -#: ../../library/xmlrpc.server.rst:78 +#: ../../library/xmlrpc.server.rst:75 msgid "" "The :class:`SimpleXMLRPCServer` class is based on :class:`socketserver." "TCPServer` and provides a means of creating simple, stand alone XML-RPC " @@ -129,7 +129,7 @@ msgstr "" ":class:`SimpleXMLRPCServer` 類別是基於 :class:`socketserver.TCPServer` 的,並" "提供了建立簡單、獨立 XML-RPC 伺服器的方式。" -#: ../../library/xmlrpc.server.rst:85 ../../library/xmlrpc.server.rst:299 +#: ../../library/xmlrpc.server.rst:82 ../../library/xmlrpc.server.rst:296 msgid "" "Register a function that can respond to XML-RPC requests. If *name* is " "given, it will be the method name associated with *function*, otherwise :" @@ -140,7 +140,7 @@ msgstr "" "*function* 關聯的方法名稱,否則將使用 :attr:`function.__name__`。*name* 是一" "個字串,可以包含在 Python 識別符中不合法的字元,包括句點字元。" -#: ../../library/xmlrpc.server.rst:90 ../../library/xmlrpc.server.rst:304 +#: ../../library/xmlrpc.server.rst:87 ../../library/xmlrpc.server.rst:301 msgid "" "This method can also be used as a decorator. When used as a decorator, " "*name* can only be given as a keyword argument to register *function* under " @@ -150,11 +150,11 @@ msgstr "" "*name* 下註冊 *function*。如果沒有給定 *name*,將使用 :attr:`function." "__name__`。" -#: ../../library/xmlrpc.server.rst:94 ../../library/xmlrpc.server.rst:308 +#: ../../library/xmlrpc.server.rst:91 ../../library/xmlrpc.server.rst:305 msgid ":meth:`register_function` can be used as a decorator." msgstr ":meth:`register_function` 也可被當作裝飾器使用。" -#: ../../library/xmlrpc.server.rst:100 +#: ../../library/xmlrpc.server.rst:97 msgid "" "Register an object which is used to expose method names which have not been " "registered using :meth:`register_function`. If *instance* contains a :meth:" @@ -175,7 +175,7 @@ msgstr "" "會作為結果回傳給用戶端。如果 *instance* 沒有 :meth:`_dispatch` 方法,則會搜尋" "與請求方法名稱匹配的屬性。" -#: ../../library/xmlrpc.server.rst:111 +#: ../../library/xmlrpc.server.rst:108 msgid "" "If the optional *allow_dotted_names* argument is true and the instance does " "not have a :meth:`_dispatch` method, then if the requested method name " @@ -190,7 +190,7 @@ msgstr "" "執行簡單的階層式搜尋。從此搜尋中找到的值會以來自請求的參數被呼叫,並將回傳值" "傳回給用戶端。" -#: ../../library/xmlrpc.server.rst:120 +#: ../../library/xmlrpc.server.rst:117 msgid "" "Enabling the *allow_dotted_names* option allows intruders to access your " "module's global variables and may allow intruders to execute arbitrary code " @@ -199,7 +199,7 @@ msgstr "" "啟用 *allow_dotted_names* 選項允許入侵者存取你模組的全域變數,並可能允許入侵" "者在你的機器上執行任意程式碼。請在安全、封閉的網路上才使用此選項。" -#: ../../library/xmlrpc.server.rst:127 +#: ../../library/xmlrpc.server.rst:124 msgid "" "Registers the XML-RPC introspection functions ``system.listMethods``, " "``system.methodHelp`` and ``system.methodSignature``." @@ -207,11 +207,11 @@ msgstr "" "註冊 XML-RPC 自我檢查函式 (introspection functions) ``system.listMethods``、" "``system.methodHelp`` 和 ``system.methodSignature``。" -#: ../../library/xmlrpc.server.rst:133 +#: ../../library/xmlrpc.server.rst:130 msgid "Registers the XML-RPC multicall function system.multicall." msgstr "註冊 XML-RPC 多重呼叫函式 (multicall function) system.multicall。" -#: ../../library/xmlrpc.server.rst:138 +#: ../../library/xmlrpc.server.rst:135 msgid "" "An attribute value that must be a tuple listing valid path portions of the " "URL for receiving XML-RPC requests. Requests posted to other paths will " @@ -222,15 +222,15 @@ msgstr "" "到其他路徑的請求將導致 404 \"no such page\" HTTP 錯誤。如果此元組為空,所有路" "徑都將被視為有效。預設值為 ``('/', '/RPC2')``。" -#: ../../library/xmlrpc.server.rst:147 +#: ../../library/xmlrpc.server.rst:144 msgid "SimpleXMLRPCServer example" msgstr "SimpleXMLRPCServer 範例" -#: ../../library/xmlrpc.server.rst:148 +#: ../../library/xmlrpc.server.rst:145 msgid "Server code::" msgstr "伺服器程式碼: ::" -#: ../../library/xmlrpc.server.rst:150 +#: ../../library/xmlrpc.server.rst:147 msgid "" "from xmlrpc.server import SimpleXMLRPCServer\n" "from xmlrpc.server import SimpleXMLRPCRequestHandler\n" @@ -295,13 +295,13 @@ msgstr "" " # 執行伺服器的主迴圈\n" " server.serve_forever()" -#: ../../library/xmlrpc.server.rst:182 +#: ../../library/xmlrpc.server.rst:179 msgid "" "The following client code will call the methods made available by the " "preceding server::" msgstr "以下用戶端程式碼將呼叫前述伺服器提供的方法: ::" -#: ../../library/xmlrpc.server.rst:185 +#: ../../library/xmlrpc.server.rst:182 msgid "" "import xmlrpc.client\n" "\n" @@ -323,7 +323,7 @@ msgstr "" "# 印出可用方法列表\n" "print(s.system.listMethods())" -#: ../../library/xmlrpc.server.rst:195 +#: ../../library/xmlrpc.server.rst:192 msgid "" ":meth:`register_function` can also be used as a decorator. The previous " "server example can register functions in a decorator way::" @@ -331,7 +331,7 @@ msgstr "" ":meth:`register_function` 也可以用作裝飾器。前述的伺服器範例可以用裝飾器方式" "註冊函式: ::" -#: ../../library/xmlrpc.server.rst:198 +#: ../../library/xmlrpc.server.rst:195 msgid "" "from xmlrpc.server import SimpleXMLRPCServer\n" "from xmlrpc.server import SimpleXMLRPCRequestHandler\n" @@ -387,7 +387,7 @@ msgstr "" "\n" " server.serve_forever()" -#: ../../library/xmlrpc.server.rst:226 +#: ../../library/xmlrpc.server.rst:223 msgid "" "The following example included in the :file:`Lib/xmlrpc/server.py` module " "shows a server allowing dotted names and registering a multicall function." @@ -395,7 +395,7 @@ msgstr "" "以下包含在 :file:`Lib/xmlrpc/server.py` 模組中的範例展示了一個允許點分隔名稱" "並註冊多重呼叫函式的伺服器。" -#: ../../library/xmlrpc.server.rst:231 +#: ../../library/xmlrpc.server.rst:228 msgid "" "Enabling the *allow_dotted_names* option allows intruders to access your " "module's global variables and may allow intruders to execute arbitrary code " @@ -404,7 +404,7 @@ msgstr "" "啟用 *allow_dotted_names* 選項來允許入侵者存取你模組的全域變數,並可能允許入" "侵者在你的機器上執行任意程式碼。請在安全、封閉的網路中才使用此範例。" -#: ../../library/xmlrpc.server.rst:237 +#: ../../library/xmlrpc.server.rst:234 msgid "" "import datetime as dt\n" "\n" @@ -452,21 +452,21 @@ msgstr "" " print(\"\\nKeyboard interrupt received, exiting.\")\n" " sys.exit(0)" -#: ../../library/xmlrpc.server.rst:260 +#: ../../library/xmlrpc.server.rst:257 msgid "This ExampleService demo can be invoked from the command line::" msgstr "此 ExampleService 示範可以從命令列觸發: ::" -#: ../../library/xmlrpc.server.rst:262 +#: ../../library/xmlrpc.server.rst:259 msgid "python -m xmlrpc.server" msgstr "python -m xmlrpc.server" -#: ../../library/xmlrpc.server.rst:265 +#: ../../library/xmlrpc.server.rst:262 msgid "" "The client that interacts with the above server is included in ``Lib/xmlrpc/" "client.py``::" msgstr "與上述伺服器互動的用戶端被包含在 ``Lib/xmlrpc/client.py`` 中: ::" -#: ../../library/xmlrpc.server.rst:268 +#: ../../library/xmlrpc.server.rst:265 msgid "" "server = ServerProxy(\"http://localhost:8000\")\n" "\n" @@ -502,20 +502,20 @@ msgstr "" "except Error as v:\n" " print(\"ERROR\", v)" -#: ../../library/xmlrpc.server.rst:285 +#: ../../library/xmlrpc.server.rst:282 msgid "" "This client which interacts with the demo XMLRPC server can be invoked as::" msgstr "與示範 XMLRPC 伺服器互動的此用戶端可以如下呼叫: ::" -#: ../../library/xmlrpc.server.rst:287 +#: ../../library/xmlrpc.server.rst:284 msgid "python -m xmlrpc.client" msgstr "python -m xmlrpc.client" -#: ../../library/xmlrpc.server.rst:291 +#: ../../library/xmlrpc.server.rst:288 msgid "CGIXMLRPCRequestHandler" msgstr "CGIXMLRPCRequestHandler" -#: ../../library/xmlrpc.server.rst:293 +#: ../../library/xmlrpc.server.rst:290 msgid "" "The :class:`CGIXMLRPCRequestHandler` class can be used to handle XML-RPC " "requests sent to Python CGI scripts." @@ -523,7 +523,7 @@ msgstr "" ":class:`CGIXMLRPCRequestHandler` 類別可用於處理發送到 Python CGI 指令稿的 " "XML-RPC 請求。" -#: ../../library/xmlrpc.server.rst:314 +#: ../../library/xmlrpc.server.rst:311 msgid "" "Register an object which is used to expose method names which have not been " "registered using :meth:`register_function`. If instance contains a :meth:" @@ -544,7 +544,7 @@ msgstr "" "分會被單獨搜尋,從而執行簡單的階層式搜尋。從此搜尋中找到的值會以來自請求的參" "數被呼叫,並將回傳值傳回給用戶端。" -#: ../../library/xmlrpc.server.rst:328 +#: ../../library/xmlrpc.server.rst:325 msgid "" "Register the XML-RPC introspection functions ``system.listMethods``, " "``system.methodHelp`` and ``system.methodSignature``." @@ -552,11 +552,11 @@ msgstr "" "註冊 XML-RPC 自我檢查函式 ``system.listMethods``、``system.methodHelp`` 和 " "``system.methodSignature``。" -#: ../../library/xmlrpc.server.rst:334 +#: ../../library/xmlrpc.server.rst:331 msgid "Register the XML-RPC multicall function ``system.multicall``." msgstr "註冊 XML-RPC 多重呼叫函式 ``system.multicall``。" -#: ../../library/xmlrpc.server.rst:339 +#: ../../library/xmlrpc.server.rst:336 msgid "" "Handle an XML-RPC request. If *request_text* is given, it should be the POST " "data provided by the HTTP server, otherwise the contents of stdin will be " @@ -565,11 +565,11 @@ msgstr "" "處理 XML-RPC 請求。如果給定 *request_text*,它應該是 HTTP 伺服器提供的 POST " "資料,否則將使用 stdin 的內容。" -#: ../../library/xmlrpc.server.rst:342 +#: ../../library/xmlrpc.server.rst:339 msgid "Example::" msgstr "範例: ::" -#: ../../library/xmlrpc.server.rst:344 +#: ../../library/xmlrpc.server.rst:341 msgid "" "class MyFuncs:\n" " def mul(self, x, y):\n" @@ -595,11 +595,11 @@ msgstr "" "handler.register_instance(MyFuncs())\n" "handler.handle_request()" -#: ../../library/xmlrpc.server.rst:358 +#: ../../library/xmlrpc.server.rst:355 msgid "Documenting XMLRPC server" msgstr "記錄 XMLRPC 伺服器" -#: ../../library/xmlrpc.server.rst:360 +#: ../../library/xmlrpc.server.rst:357 msgid "" "These classes extend the above classes to serve HTML documentation in " "response to HTTP GET requests. Servers can either be free standing, using :" @@ -610,7 +610,7 @@ msgstr "" "是獨立執行的(使用 :class:`DocXMLRPCServer`),或嵌入在 CGI 環境中(使用 :" "class:`DocCGIXMLRPCRequestHandler`)。" -#: ../../library/xmlrpc.server.rst:370 +#: ../../library/xmlrpc.server.rst:367 msgid "" "Create a new server instance. All parameters have the same meaning as for :" "class:`SimpleXMLRPCServer`; *requestHandler* defaults to :class:" @@ -619,11 +619,11 @@ msgstr "" "建立一個新的伺服器實例。所有參數的意義與 :class:`SimpleXMLRPCServer` 相同;" "*requestHandler* 預設為 :class:`DocXMLRPCRequestHandler`。" -#: ../../library/xmlrpc.server.rst:380 +#: ../../library/xmlrpc.server.rst:377 msgid "Create a new instance to handle XML-RPC requests in a CGI environment." msgstr "建立一個新的實例以在 CGI 環境中處理 XML-RPC 請求。" -#: ../../library/xmlrpc.server.rst:385 +#: ../../library/xmlrpc.server.rst:382 msgid "" "Create a new request handler instance. This request handler supports XML-RPC " "POST requests, documentation GET requests, and modifies logging so that the " @@ -634,11 +634,11 @@ msgstr "" "求,並修改日誌記錄功能以遵守 :class:`DocXMLRPCServer` 建構函式的 " "*logRequests* 參數。" -#: ../../library/xmlrpc.server.rst:394 +#: ../../library/xmlrpc.server.rst:391 msgid "DocXMLRPCServer objects" msgstr "DocXMLRPCServer 物件" -#: ../../library/xmlrpc.server.rst:396 +#: ../../library/xmlrpc.server.rst:393 msgid "" "The :class:`DocXMLRPCServer` class is derived from :class:" "`SimpleXMLRPCServer` and provides a means of creating self-documenting, " @@ -652,14 +652,14 @@ msgstr "" "為 XML-RPC 方法呼叫來處理。HTTP GET 請求會透過產生 pydoc 風格的 HTML 文件來處" "理。這允許伺服器提供自己的網頁文件。" -#: ../../library/xmlrpc.server.rst:405 ../../library/xmlrpc.server.rst:433 +#: ../../library/xmlrpc.server.rst:402 ../../library/xmlrpc.server.rst:430 msgid "" "Set the title used in the generated HTML documentation. This title will be " "used inside the HTML \"title\" element." msgstr "" "設定在產生的 HTML 文件中使用的標題。此標題將用於 HTML \"title\" 元素內。" -#: ../../library/xmlrpc.server.rst:411 ../../library/xmlrpc.server.rst:439 +#: ../../library/xmlrpc.server.rst:408 ../../library/xmlrpc.server.rst:436 msgid "" "Set the name used in the generated HTML documentation. This name will appear " "at the top of the generated documentation inside a \"h1\" element." @@ -667,7 +667,7 @@ msgstr "" "設定在產生的 HTML 文件中使用的名稱。此名稱將顯示在產生的文件頂部的 \"h1\" 元" "素內。" -#: ../../library/xmlrpc.server.rst:417 ../../library/xmlrpc.server.rst:445 +#: ../../library/xmlrpc.server.rst:414 ../../library/xmlrpc.server.rst:442 msgid "" "Set the description used in the generated HTML documentation. This " "description will appear as a paragraph, below the server name, in the " @@ -676,11 +676,11 @@ msgstr "" "設定在產生的 HTML 文件中使用的描述。此描述將作為一個段落顯示在文件中伺服器名" "稱的下方。" -#: ../../library/xmlrpc.server.rst:422 +#: ../../library/xmlrpc.server.rst:419 msgid "DocCGIXMLRPCRequestHandler" msgstr "DocCGIXMLRPCRequestHandler" -#: ../../library/xmlrpc.server.rst:424 +#: ../../library/xmlrpc.server.rst:421 msgid "" "The :class:`DocCGIXMLRPCRequestHandler` class is derived from :class:" "`CGIXMLRPCRequestHandler` and provides a means of creating self-documenting, " diff --git a/library/zipfile.po b/library/zipfile.po index 02c7097aa82..1502390ed7c 100644 --- a/library/zipfile.po +++ b/library/zipfile.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-20 00:39+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-06-26 20:00+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!zipfile` --- Work with ZIP archives" msgstr ":mod:`!zipfile` --- 處理 ZIP 封存檔案" -#: ../../library/zipfile.rst:10 +#: ../../library/zipfile.rst:7 msgid "**Source code:** :source:`Lib/zipfile/`" msgstr "**原始碼:**\\ :source:`Lib/zipfile/`" -#: ../../library/zipfile.rst:14 +#: ../../library/zipfile.rst:11 msgid "" "The ZIP file format is a common archive and compression standard. This " "module provides tools to create, read, write, append, and list a ZIP file. " @@ -38,7 +38,7 @@ msgstr "" "入、附加與列出 ZIP 檔案的工具。任何對本模組的進階使用都將需要對 `PKZIP " "Application Note`_ 中定義的格式有所理解。" -#: ../../library/zipfile.rst:19 +#: ../../library/zipfile.rst:16 msgid "" "This module does not handle multipart ZIP files. It can handle ZIP files " "that use the ZIP64 extensions (that is ZIP files that are more than 4 GiB in " @@ -50,7 +50,7 @@ msgstr "" "GiB 的 ZIP 檔案)的 ZIP 檔案。它支援解密 ZIP 封存檔案中的加密檔案,但目前無法" "建立加密檔案。解密速度極慢,因為它是在原生 Python 中實作,而不是 C。" -#: ../../library/zipfile.rst:29 +#: ../../library/zipfile.rst:26 msgid "" "Handling compressed archives requires :term:`optional modules ` such as :mod:`zlib`, :mod:`bz2`, :mod:`lzma`, and :mod:`compression." @@ -59,26 +59,26 @@ msgid "" "you). If you are the distributor, see :ref:`optional-module-requirements`." msgstr "" -#: ../../library/zipfile.rst:36 +#: ../../library/zipfile.rst:33 msgid "The module defines the following items:" msgstr "本模組定義了以下項目:" -#: ../../library/zipfile.rst:40 +#: ../../library/zipfile.rst:37 msgid "The error raised for bad ZIP files." msgstr "對於損壞的 ZIP 檔案所引發的錯誤。" -#: ../../library/zipfile.rst:47 +#: ../../library/zipfile.rst:44 msgid "" "Alias of :exc:`BadZipFile`, for compatibility with older Python versions." msgstr ":exc:`BadZipFile` 的別名,為了與舊版 Python 相容。" -#: ../../library/zipfile.rst:54 +#: ../../library/zipfile.rst:51 msgid "" "The error raised when a ZIP file would require ZIP64 functionality but that " "has not been enabled." msgstr "當 ZIP 檔案需要 ZIP64 功能但該功能未被啟用時所引發的錯誤。" -#: ../../library/zipfile.rst:61 +#: ../../library/zipfile.rst:58 msgid "" "The class for reading and writing ZIP files. See section :ref:`zipfile-" "objects` for constructor details." @@ -86,7 +86,7 @@ msgstr "" "用於讀取和寫入 ZIP 檔案的類別。有關建構函式的詳細資訊,請參閱 :ref:`zipfile-" "objects` 章節。" -#: ../../library/zipfile.rst:68 +#: ../../library/zipfile.rst:65 msgid "" "Class that implements a subset of the interface provided by :class:`pathlib." "Path`, including the full :class:`importlib.resources.abc.Traversable` " @@ -95,11 +95,11 @@ msgstr "" "實作了 :class:`pathlib.Path` 所提供介面子集的類別,包括完整的 :class:" "`importlib.resources.abc.Traversable` 介面。" -#: ../../library/zipfile.rst:78 +#: ../../library/zipfile.rst:75 msgid "Class for creating ZIP archives containing Python libraries." msgstr "用於建立包含 Python 函式庫的 ZIP 封存檔案的類別。" -#: ../../library/zipfile.rst:83 +#: ../../library/zipfile.rst:80 msgid "" "Class used to represent information about a member of an archive. Instances " "of this class are returned by the :meth:`.getinfo` and :meth:`.infolist` " @@ -116,7 +116,7 @@ msgstr "" "完整名稱,而 *date_time* 應為一個包含六個欄位的元組,用以描述檔案的最後修改時" "間;這些欄位在 :ref:`zipinfo-objects` 章節中有所描述。" -#: ../../library/zipfile.rst:92 +#: ../../library/zipfile.rst:89 msgid "" "A public :attr:`!compress_level` attribute has been added to expose the " "formerly protected :attr:`!_compresslevel`. The older protected name " @@ -125,17 +125,17 @@ msgstr "" "新增了一個公開的 :attr:`!compress_level` 屬性,以公開先前受保護的 :attr:`!" "_compresslevel`。為了向後相容,舊的受保護名稱仍可作為一個特性繼續運作。" -#: ../../library/zipfile.rst:100 +#: ../../library/zipfile.rst:97 msgid "" "Resolve the date_time, compression attributes, and external attributes to " "suitable defaults as used by :meth:`ZipFile.writestr`." msgstr "" -#: ../../library/zipfile.rst:103 +#: ../../library/zipfile.rst:100 msgid "Returns self for chaining." msgstr "" -#: ../../library/zipfile.rst:110 +#: ../../library/zipfile.rst:107 msgid "" "Returns ``True`` if *filename* is a valid ZIP file based on its magic " "number, otherwise returns ``False``. *filename* may be a file or file-like " @@ -144,40 +144,40 @@ msgstr "" "如果 *filename* 根據其魔術數字(magic number)是一個有效的 ZIP 檔案,則回傳 " "``True``,否則回傳 ``False``。*filename* 也可以是一個檔案或類檔案物件。" -#: ../../library/zipfile.rst:113 +#: ../../library/zipfile.rst:110 msgid "Support for file and file-like objects." msgstr "支援檔案和類檔案物件。" -#: ../../library/zipfile.rst:119 +#: ../../library/zipfile.rst:116 msgid "The numeric constant for an uncompressed archive member." msgstr "用於未壓縮封存成員的數值常數。" -#: ../../library/zipfile.rst:124 +#: ../../library/zipfile.rst:121 msgid "" "The numeric constant for the usual ZIP compression method. This requires " "the :mod:`zlib` module." msgstr "用於常用的 ZIP 壓縮方法的數值常數。這需要 :mod:`zlib` 模組。" -#: ../../library/zipfile.rst:130 +#: ../../library/zipfile.rst:127 msgid "" "The numeric constant for the BZIP2 compression method. This requires the :" "mod:`bz2` module." msgstr "用於 BZIP2 壓縮方法的數值常數。這需要 :mod:`bz2` 模組。" -#: ../../library/zipfile.rst:137 +#: ../../library/zipfile.rst:134 msgid "" "The numeric constant for the LZMA compression method. This requires the :" "mod:`lzma` module." msgstr "用於 LZMA 壓縮方法的數值常數。這需要 :mod:`lzma` 模組。" -#: ../../library/zipfile.rst:144 +#: ../../library/zipfile.rst:141 msgid "" "The numeric constant for Zstandard compression. This requires the :mod:" "`compression.zstd` module." msgstr "" "用於 Zstandard 壓縮方法的數值常數。這需要 :mod:`compression.zstd` 模組。" -#: ../../library/zipfile.rst:149 +#: ../../library/zipfile.rst:146 msgid "" "In APPNOTE 6.3.7, the method ID ``20`` was assigned to Zstandard " "compression. This was changed in APPNOTE 6.3.8 to method ID ``93`` to avoid " @@ -186,7 +186,7 @@ msgid "" "method ID ``93``." msgstr "" -#: ../../library/zipfile.rst:159 +#: ../../library/zipfile.rst:156 msgid "" "The ZIP file format specification has included support for bzip2 compression " "since 2001, for LZMA compression since 2006, and Zstandard compression since " @@ -198,32 +198,32 @@ msgstr "" "壓縮、自 2020 年起支援 Zstandard 壓縮。然而某些工具(包括舊版的 Python)不支" "援這些壓縮方法,可能會完全拒絕處理該 ZIP 檔案,或無法解壓縮個別檔案。" -#: ../../library/zipfile.rst:167 +#: ../../library/zipfile.rst:164 msgid "`PKZIP Application Note`_" msgstr "`PKZIP Application Note`_" -#: ../../library/zipfile.rst:168 +#: ../../library/zipfile.rst:165 msgid "" "Documentation on the ZIP file format by Phil Katz, the creator of the format " "and algorithms used." msgstr "" "由 Phil Katz(該格式與所用演算法的創造者)所撰寫的關於 ZIP 檔案格式的文件。" -#: ../../library/zipfile.rst:171 +#: ../../library/zipfile.rst:168 msgid "`Info-ZIP Home Page `_" msgstr "`Info-ZIP 首頁 `_" -#: ../../library/zipfile.rst:172 +#: ../../library/zipfile.rst:169 msgid "" "Information about the Info-ZIP project's ZIP archive programs and " "development libraries." msgstr "關於 Info-ZIP 專案的 ZIP 封存程式和開發函式庫的資訊。" -#: ../../library/zipfile.rst:179 +#: ../../library/zipfile.rst:176 msgid "ZipFile objects" msgstr "ZipFile 物件" -#: ../../library/zipfile.rst:186 +#: ../../library/zipfile.rst:183 msgid "" "Open a ZIP file, where *file* can be a path to a file (a string), a file-" "like object or a :term:`path-like object`." @@ -231,7 +231,7 @@ msgstr "" "開啟一個 ZIP 檔案,其中 *file* 可以是一個檔案的路徑(一個字串)、一個類檔案物" "件或一個 :term:`path-like object`。" -#: ../../library/zipfile.rst:189 +#: ../../library/zipfile.rst:186 msgid "" "The *mode* parameter should be ``'r'`` to read an existing file, ``'w'`` to " "truncate and write a new file, ``'a'`` to append to an existing file, or " @@ -253,7 +253,7 @@ msgstr "" "如 :file:`python.exe`)。如果 *mode* 為 ``'a'`` 且檔案完全不存在,它會被建" "立。如果 *mode* 為 ``'r'`` 或 ``'a'``,該檔案應為可定位的 (seekable)。" -#: ../../library/zipfile.rst:201 +#: ../../library/zipfile.rst:198 msgid "" "*compression* is the ZIP compression method to use when writing the archive, " "and should be :const:`ZIP_STORED`, :const:`ZIP_DEFLATED`, :const:" @@ -272,7 +272,7 @@ msgstr "" "`zlib`、:mod:`bz2`、:mod:`lzma` 或 :mod:`compression.zstd`)不可用,則會引" "發 :exc:`RuntimeError`。預設為 :const:`ZIP_STORED`。" -#: ../../library/zipfile.rst:210 +#: ../../library/zipfile.rst:207 msgid "" "If *allowZip64* is ``True`` (the default) zipfile will create ZIP files that " "use the ZIP64 extensions when the zipfile is larger than 4 GiB. If it is " @@ -283,7 +283,7 @@ msgstr "" "zipfile 將會建立使用 ZIP64 擴充的 ZIP 檔案。如果為 ``false``,當 ZIP 檔案需" "要 ZIP64 擴充時,:mod:`!zipfile` 將會引發一個例外。" -#: ../../library/zipfile.rst:215 +#: ../../library/zipfile.rst:212 msgid "" "The *compresslevel* parameter controls the compression level to use when " "writing files to the archive. When using :const:`ZIP_STORED` or :const:" @@ -305,7 +305,7 @@ msgstr "" "及其含義,請參閱 :attr:`CompressionParameter.compression_level `)。" -#: ../../library/zipfile.rst:227 ../../library/zipfile.rst:814 +#: ../../library/zipfile.rst:224 ../../library/zipfile.rst:811 msgid "" "The *strict_timestamps* argument, when set to ``False``, allows to zip files " "older than 1980-01-01 at the cost of setting the timestamp to 1980-01-01. " @@ -316,7 +316,7 @@ msgstr "" "案,代價是將時間戳記設為 1980-01-01。對於晚於 2107-12-31 的檔案,也會有類似的" "行為,時間戳記同樣會被設為極限值。" -#: ../../library/zipfile.rst:233 +#: ../../library/zipfile.rst:230 msgid "" "When mode is ``'r'``, *metadata_encoding* may be set to the name of a codec, " "which will be used to decode metadata such as the names of members and ZIP " @@ -325,7 +325,7 @@ msgstr "" "當 mode 為 ``'r'`` 時,*metadata_encoding* 可以設為一個編解碼器的名稱,該編解" "碼器將被用來解碼元資料,例如成員名稱和 ZIP 註解。" -#: ../../library/zipfile.rst:237 +#: ../../library/zipfile.rst:234 msgid "" "If the file is created with mode ``'w'``, ``'x'`` or ``'a'`` and then :meth:" "`closed ` without adding any files to the archive, the appropriate " @@ -335,7 +335,7 @@ msgstr "" "何檔案的情況下 :meth:`關閉 `,則適用於空封存檔案的 ZIP 結構將被寫入檔" "案中。" -#: ../../library/zipfile.rst:241 +#: ../../library/zipfile.rst:238 msgid "" "ZipFile is also a context manager and therefore supports the :keyword:`with` " "statement. In the example, *myzip* is closed after the :keyword:`!with` " @@ -345,7 +345,7 @@ msgstr "" "*myzip* 在 :keyword:`!with` 陳述式的程式碼區塊執行完畢後會被關閉 --- 即使發生" "例外也是如此: ::" -#: ../../library/zipfile.rst:245 +#: ../../library/zipfile.rst:242 msgid "" "with ZipFile('spam.zip', 'w') as myzip:\n" " myzip.write('eggs.txt')" @@ -353,7 +353,7 @@ msgstr "" "with ZipFile('spam.zip', 'w') as myzip:\n" " myzip.write('eggs.txt')" -#: ../../library/zipfile.rst:250 +#: ../../library/zipfile.rst:247 msgid "" "*metadata_encoding* is an instance-wide setting for the ZipFile. It is not " "possible to set this on a per-member basis." @@ -361,7 +361,7 @@ msgstr "" "*metadata_encoding* 是 ZipFile 的一個實例範圍設定。無法以每個成員為基礎來設定" "此項。" -#: ../../library/zipfile.rst:253 +#: ../../library/zipfile.rst:250 msgid "" "This attribute is a workaround for legacy implementations which produce " "archives with names in the current locale encoding or code page (mostly on " @@ -375,51 +375,51 @@ msgstr "" "檔案標頭中的一個旗標指定為 IBM 頁碼(預設)或 UTF-8。該旗標的優先級高於 " "*metadata_encoding*,後者是 Python 特有的擴充。" -#: ../../library/zipfile.rst:261 +#: ../../library/zipfile.rst:258 msgid "Added the ability to use :class:`ZipFile` as a context manager." msgstr "新增 :class:`ZipFile` 作為情境管理器使用的能力。" -#: ../../library/zipfile.rst:264 +#: ../../library/zipfile.rst:261 msgid "Added support for :mod:`bzip2 ` and :mod:`lzma` compression." msgstr "新增對於 :mod:`bzip2 ` 和 :mod:`lzma` 壓縮的支援。" -#: ../../library/zipfile.rst:267 ../../library/zipfile.rst:727 +#: ../../library/zipfile.rst:264 ../../library/zipfile.rst:724 msgid "ZIP64 extensions are enabled by default." msgstr "ZIP64 擴充預設為啟用。" -#: ../../library/zipfile.rst:270 +#: ../../library/zipfile.rst:267 msgid "" "Added support for writing to unseekable streams. Added support for the " "``'x'`` mode." msgstr "" "新增了對寫入不可定位的 (unseekable) 串流的支援。新增了對 ``'x'`` 模式的支援。" -#: ../../library/zipfile.rst:274 +#: ../../library/zipfile.rst:271 msgid "" "Previously, a plain :exc:`RuntimeError` was raised for unrecognized " "compression values." msgstr "先前,對於無法識別的壓縮值,會引發一個單純的 :exc:`RuntimeError`。" -#: ../../library/zipfile.rst:278 +#: ../../library/zipfile.rst:275 msgid "The *file* parameter accepts a :term:`path-like object`." msgstr "*file* 參數接受一個 :term:`path-like object`。" -#: ../../library/zipfile.rst:281 +#: ../../library/zipfile.rst:278 msgid "Add the *compresslevel* parameter." msgstr "新增 *compresslevel* 參數。" -#: ../../library/zipfile.rst:284 +#: ../../library/zipfile.rst:281 msgid "The *strict_timestamps* keyword-only parameter." msgstr "*strict_timestamps* 僅限關鍵字參數。" -#: ../../library/zipfile.rst:287 +#: ../../library/zipfile.rst:284 msgid "" "Added support for specifying member name encoding for reading metadata in " "the zipfile's directory and file headers." msgstr "" "新增了在讀取 zipfile 目錄和檔案標頭中的元資料時,可指定成員名稱編碼的支援。" -#: ../../library/zipfile.rst:294 +#: ../../library/zipfile.rst:291 msgid "" "Close the archive file. You must call :meth:`close` before exiting your " "program or essential records will not be written." @@ -427,7 +427,7 @@ msgstr "" "關閉封存檔案。你必須在結束程式前呼叫 :meth:`close`,否則必要的記錄將不會被寫" "入。" -#: ../../library/zipfile.rst:300 +#: ../../library/zipfile.rst:297 msgid "" "Return a :class:`ZipInfo` object with information about the archive member " "*name*. Calling :meth:`getinfo` for a name not currently contained in the " @@ -436,7 +436,7 @@ msgstr "" "回傳一個帶有關於封存成員 *name* 資訊的 :class:`ZipInfo` 物件。對一個目前不包" "含在封存檔案中的名稱呼叫 :meth:`getinfo` 將會引發 :exc:`KeyError`。" -#: ../../library/zipfile.rst:307 +#: ../../library/zipfile.rst:304 msgid "" "Return a list containing a :class:`ZipInfo` object for each member of the " "archive. The objects are in the same order as their entries in the actual " @@ -446,11 +446,11 @@ msgstr "" "一個現有的封存檔案,這些物件的順序與它們在磁碟上實際 ZIP 檔案中的條目順序相" "同。" -#: ../../library/zipfile.rst:314 +#: ../../library/zipfile.rst:311 msgid "Return a list of archive members by name." msgstr "依名稱回傳封存成員的串列。" -#: ../../library/zipfile.rst:319 +#: ../../library/zipfile.rst:316 msgid "" "Access a member of the archive as a binary file-like object. *name* can be " "either the name of a file within the archive or a :class:`ZipInfo` object. " @@ -463,7 +463,7 @@ msgstr "" "``'r'``\\ (預設值)或 ``'w'``。*pwd* 是用於解密加密 ZIP 檔案的密碼,為一個 :" "class:`bytes` 物件。" -#: ../../library/zipfile.rst:325 +#: ../../library/zipfile.rst:322 msgid "" ":meth:`~ZipFile.open` is also a context manager and therefore supports the :" "keyword:`with` statement::" @@ -471,7 +471,7 @@ msgstr "" ":meth:`~ZipFile.open` 也是一個情境管理器,因此支援 :keyword:`with` 陳述" "式: ::" -#: ../../library/zipfile.rst:328 +#: ../../library/zipfile.rst:325 msgid "" "with ZipFile('spam.zip') as myzip:\n" " with myzip.open('eggs.txt') as myfile:\n" @@ -481,7 +481,7 @@ msgstr "" " with myzip.open('eggs.txt') as myfile:\n" " print(myfile.read())" -#: ../../library/zipfile.rst:332 +#: ../../library/zipfile.rst:329 msgid "" "With *mode* ``'r'`` the file-like object (``ZipExtFile``) is read-only and " "provides the following methods: :meth:`~io.BufferedIOBase.read`, :meth:`~io." @@ -495,7 +495,7 @@ msgstr "" "`~container.__iter__`、:meth:`~iterator.__next__`。這些物件可以獨立於 " "ZipFile 運作。" -#: ../../library/zipfile.rst:339 +#: ../../library/zipfile.rst:336 msgid "" "With ``mode='w'``, a writable file handle is returned, which supports the :" "meth:`~io.BufferedIOBase.write` method. While a writable file handle is " @@ -506,7 +506,7 @@ msgstr "" "`~io.BufferedIOBase.write` 方法。當一個可寫的檔案控點開啟時,嘗試讀取或寫入 " "ZIP 檔案中的其他檔案將會引發 :exc:`ValueError`。" -#: ../../library/zipfile.rst:344 +#: ../../library/zipfile.rst:341 msgid "" "In both cases the file-like object has also attributes :attr:`!name`, which " "is equivalent to the name of a file within the archive, and :attr:`!mode`, " @@ -516,7 +516,7 @@ msgstr "" "案名稱,以及 :attr:`!mode` 屬性,其值為 ``'rb'`` 或 ``'wb'``,取決於輸入的模" "式。" -#: ../../library/zipfile.rst:348 +#: ../../library/zipfile.rst:345 msgid "" "When writing a file, if the file size is not known in advance but may exceed " "2 GiB, pass ``force_zip64=True`` to ensure that the header format is capable " @@ -529,7 +529,7 @@ msgstr "" "構一個設定了 :attr:`~ZipInfo.file_size` 的 :class:`ZipInfo` 物件,並將其用作 " "*name* 參數。" -#: ../../library/zipfile.rst:356 +#: ../../library/zipfile.rst:353 msgid "" "The :meth:`.open`, :meth:`read` and :meth:`extract` methods can take a " "filename or a :class:`ZipInfo` object. You will appreciate this when trying " @@ -539,7 +539,7 @@ msgstr "" "class:`ZipInfo` 物件。當你嘗試讀取一個包含重複名稱成員的 ZIP 檔案時,你會發現" "這很有用。" -#: ../../library/zipfile.rst:360 +#: ../../library/zipfile.rst:357 msgid "" "Removed support of ``mode='U'``. Use :class:`io.TextIOWrapper` for reading " "compressed text files in :term:`universal newlines` mode." @@ -547,14 +547,14 @@ msgstr "" "移除了對 ``mode='U'`` 的支援。請使用 :class:`io.TextIOWrapper` 以 :term:" "`universal newlines` 模式讀取壓縮的文字檔。" -#: ../../library/zipfile.rst:364 +#: ../../library/zipfile.rst:361 msgid "" ":meth:`ZipFile.open` can now be used to write files into the archive with " "the ``mode='w'`` option." msgstr "" ":meth:`ZipFile.open` 現在可以用於以 ``mode='w'`` 選項將檔案寫入封存檔案。" -#: ../../library/zipfile.rst:368 +#: ../../library/zipfile.rst:365 msgid "" "Calling :meth:`.open` on a closed ZipFile will raise a :exc:`ValueError`. " "Previously, a :exc:`RuntimeError` was raised." @@ -562,7 +562,7 @@ msgstr "" "在一個已關閉的 ZipFile 上呼叫 :meth:`.open` 將會引發 :exc:`ValueError`。先" "前,會引發一個 :exc:`RuntimeError`。" -#: ../../library/zipfile.rst:372 +#: ../../library/zipfile.rst:369 msgid "" "Added attributes :attr:`!name` and :attr:`!mode` for the writeable file-like " "object. The value of the :attr:`!mode` attribute for the readable file-like " @@ -571,7 +571,7 @@ msgstr "" "為可寫的類檔案物件新增了 :attr:`!name` 和 :attr:`!mode` 屬性。可讀的類檔案物" "件的 :attr:`!mode` 屬性值從 ``'r'`` 變更為 ``'rb'``。" -#: ../../library/zipfile.rst:381 +#: ../../library/zipfile.rst:378 msgid "" "Extract a member from the archive to the current working directory; *member* " "must be its full name or a :class:`ZipInfo` object. Its file information is " @@ -584,11 +584,11 @@ msgstr "" "目錄來解壓縮。*member* 可以是一個檔名或一個 :class:`ZipInfo` 物件。*pwd* 是用" "於加密檔案的密碼,為一個 :class:`bytes` 物件。" -#: ../../library/zipfile.rst:387 +#: ../../library/zipfile.rst:384 msgid "Returns the normalized path created (a directory or new file)." msgstr "回傳建立的正規化路徑(一個目錄或新檔案)。" -#: ../../library/zipfile.rst:391 +#: ../../library/zipfile.rst:388 msgid "" "If a member filename is an absolute path, a drive/UNC sharepoint and leading " "(back)slashes will be stripped, e.g.: ``///foo/bar`` becomes ``foo/bar`` on " @@ -604,7 +604,7 @@ msgstr "" "foo../../ba..r`` 變成 ``foo../ba..r``。在 Windows 上,非法字元(``:``、" "``<``、``>``、``|``、``\"``、``?`` 和 ``*``)會被底線(``_``)取代。" -#: ../../library/zipfile.rst:399 +#: ../../library/zipfile.rst:396 msgid "" "Calling :meth:`extract` on a closed ZipFile will raise a :exc:`ValueError`. " "Previously, a :exc:`RuntimeError` was raised." @@ -612,11 +612,11 @@ msgstr "" "在一個已關閉的 ZipFile 上呼叫 :meth:`extract` 將會引發 :exc:`ValueError`。先" "前,會引發一個 :exc:`RuntimeError`。" -#: ../../library/zipfile.rst:403 ../../library/zipfile.rst:426 +#: ../../library/zipfile.rst:400 ../../library/zipfile.rst:423 msgid "The *path* parameter accepts a :term:`path-like object`." msgstr "*path* 參數接受一個 :term:`path-like object`。" -#: ../../library/zipfile.rst:409 +#: ../../library/zipfile.rst:406 msgid "" "Extract all members from the archive to the current working directory. " "*path* specifies a different directory to extract to. *members* is optional " @@ -627,7 +627,7 @@ msgstr "" "*members* 是可選的,且必須是 :meth:`namelist` 回傳的串列的子集。*pwd* 是用於" "加密檔案的密碼,為一個 :class:`bytes` 物件。" -#: ../../library/zipfile.rst:416 +#: ../../library/zipfile.rst:413 msgid "" "Never extract archives from untrusted sources without prior inspection. It " "is possible that files are created outside of *path*, for example, members " @@ -638,7 +638,7 @@ msgstr "" "立在 *path* 之外,例如,成員具有絕對檔名或帶有 \"..\" 元件的檔名。本模組會試" "圖防止這種情況。請參閱 :meth:`extract` 的註解。" -#: ../../library/zipfile.rst:422 +#: ../../library/zipfile.rst:419 msgid "" "Calling :meth:`extractall` on a closed ZipFile will raise a :exc:" "`ValueError`. Previously, a :exc:`RuntimeError` was raised." @@ -646,17 +646,17 @@ msgstr "" "在一個已關閉的 ZipFile 上呼叫 :meth:`extractall` 將會引發 :exc:`ValueError`。" "先前,會引發一個 :exc:`RuntimeError`。" -#: ../../library/zipfile.rst:432 +#: ../../library/zipfile.rst:429 msgid "Print a table of contents for the archive to ``sys.stdout``." msgstr "將封存檔案的內容目錄印出到 ``sys.stdout``。" -#: ../../library/zipfile.rst:437 +#: ../../library/zipfile.rst:434 msgid "" "Set *pwd* (a :class:`bytes` object) as default password to extract encrypted " "files." msgstr "設定 *pwd*\\ (一個 :class:`bytes` 物件)為解壓縮加密檔案的預設密碼。" -#: ../../library/zipfile.rst:442 +#: ../../library/zipfile.rst:439 msgid "" "Return the bytes of the file *name* in the archive. *name* is the name of " "the file in the archive, or a :class:`ZipInfo` object. The archive must be " @@ -676,7 +676,7 @@ msgstr "" "的 ZipFile 上呼叫 :meth:`read` 將會引發 :exc:`NotImplementedError`。如果對應" "的壓縮模組不可用,也會引發一個錯誤。" -#: ../../library/zipfile.rst:452 +#: ../../library/zipfile.rst:449 msgid "" "Calling :meth:`read` on a closed ZipFile will raise a :exc:`ValueError`. " "Previously, a :exc:`RuntimeError` was raised." @@ -684,7 +684,7 @@ msgstr "" "在一個已關閉的 ZipFile 上呼叫 :meth:`read` 將會引發 :exc:`ValueError`。先前," "會引發一個 :exc:`RuntimeError`。" -#: ../../library/zipfile.rst:459 +#: ../../library/zipfile.rst:456 msgid "" "Read all the files in the archive and check their CRC's and file headers. " "Return the name of the first bad file, or else return ``None``." @@ -692,7 +692,7 @@ msgstr "" "讀取封存檔案中的所有檔案,並檢查它們的 CRC 和檔案標頭。回傳第一個損壞檔案的名" "稱,否則回傳 ``None``。" -#: ../../library/zipfile.rst:462 +#: ../../library/zipfile.rst:459 msgid "" "Calling :meth:`testzip` on a closed ZipFile will raise a :exc:`ValueError`. " "Previously, a :exc:`RuntimeError` was raised." @@ -700,7 +700,7 @@ msgstr "" "在一個已關閉的 ZipFile 上呼叫 :meth:`testzip` 將會引發 :exc:`ValueError`。先" "前,會引發一個 :exc:`RuntimeError`。" -#: ../../library/zipfile.rst:470 +#: ../../library/zipfile.rst:467 msgid "" "Write the file named *filename* to the archive, giving it the archive name " "*arcname* (by default, this will be the same as *filename*, but without a " @@ -716,7 +716,7 @@ msgstr "" "同樣地,如果給定 *compresslevel*,它將覆寫建構函式。封存檔案必須以 ``'w'``、" "``'x'`` 或 ``'a'`` 模式開啟。" -#: ../../library/zipfile.rst:480 +#: ../../library/zipfile.rst:477 msgid "" "The ZIP file standard historically did not specify a metadata encoding, but " "strongly recommended CP437 (the original IBM PC encoding) for " @@ -730,13 +730,13 @@ msgstr "" "組中,如果成員名稱包含任何非 ASCII 字元,將會自動使用 UTF-8 來寫入。無法以 " "ASCII 或 UTF-8 以外的任何編碼寫入成員名稱。" -#: ../../library/zipfile.rst:489 +#: ../../library/zipfile.rst:486 msgid "" "Archive names should be relative to the archive root, that is, they should " "not start with a path separator." msgstr "封存名稱應相對於封存檔案的根目錄,也就是說,它們不應以路徑分隔符開頭。" -#: ../../library/zipfile.rst:494 +#: ../../library/zipfile.rst:491 msgid "" "If ``arcname`` (or ``filename``, if ``arcname`` is not given) contains a " "null byte, the name of the file in the archive will be truncated at the null " @@ -745,7 +745,7 @@ msgstr "" "如果 ``arcname``\\ (或在未給定 ``arcname`` 時的 ``filename``)包含一個空位元" "組,封存檔案中該檔案的名稱將在空位元組處被截斷。" -#: ../../library/zipfile.rst:499 +#: ../../library/zipfile.rst:496 msgid "" "A leading slash in the filename may lead to the archive being impossible to " "open in some zip programs on Windows systems." @@ -753,7 +753,7 @@ msgstr "" "檔名中開頭的斜線可能導致在 Windows 系統上的某些 zip 程式中無法開啟該封存檔" "案。" -#: ../../library/zipfile.rst:502 +#: ../../library/zipfile.rst:499 msgid "" "Calling :meth:`write` on a ZipFile created with mode ``'r'`` or a closed " "ZipFile will raise a :exc:`ValueError`. Previously, a :exc:`RuntimeError` " @@ -762,7 +762,7 @@ msgstr "" "在以 ``'r'`` 模式建立的 ZipFile 或一個已關閉的 ZipFile 上呼叫 :meth:`write` " "將會引發 :exc:`ValueError`。先前,會引發一個 :exc:`RuntimeError`。" -#: ../../library/zipfile.rst:511 +#: ../../library/zipfile.rst:508 msgid "" "Write a file into the archive. The contents is *data*, which may be either " "a :class:`str` or a :class:`bytes` instance; if it is a :class:`str`, it is " @@ -779,7 +779,7 @@ msgstr "" "個名稱,則日期和時間被設為目前的日期和時間。封存檔案必須以 ``'w'``、``'x'`` " "或 ``'a'`` 模式開啟。" -#: ../../library/zipfile.rst:519 +#: ../../library/zipfile.rst:516 msgid "" "If given, *compress_type* overrides the value given for the *compression* " "parameter to the constructor for the new entry, or in the *zinfo_or_arcname* " @@ -790,7 +790,7 @@ msgstr "" "值,或覆寫 *zinfo_or_arcname*\\ (如果它是一個 :class:`ZipInfo` 實例)中的" "值。同樣地,如果給定 *compresslevel*,它將覆寫建構函式。" -#: ../../library/zipfile.rst:526 +#: ../../library/zipfile.rst:523 msgid "" "When passing a :class:`ZipInfo` instance as the *zinfo_or_arcname* " "parameter, the compression method used will be that specified in the " @@ -801,11 +801,11 @@ msgstr "" "方法將是給定的 :class:`ZipInfo` 實例的 *compress_type* 成員中指定的方法。預設" "情況下,:class:`ZipInfo` 建構函式將此成員設為 :const:`ZIP_STORED`。" -#: ../../library/zipfile.rst:531 +#: ../../library/zipfile.rst:528 msgid "The *compress_type* argument." msgstr "*compress_type* 引數。" -#: ../../library/zipfile.rst:534 +#: ../../library/zipfile.rst:531 msgid "" "Calling :meth:`writestr` on a ZipFile created with mode ``'r'`` or a closed " "ZipFile will raise a :exc:`ValueError`. Previously, a :exc:`RuntimeError` " @@ -814,14 +814,14 @@ msgstr "" "在以 ``'r'`` 模式建立的 ZipFile 或一個已關閉的 ZipFile 上呼叫 :meth:" "`writestr` 將會引發 :exc:`ValueError`。先前,會引發一個 :exc:`RuntimeError`。" -#: ../../library/zipfile.rst:539 +#: ../../library/zipfile.rst:536 msgid "" "Now respects the :envvar:`SOURCE_DATE_EPOCH` environment variable. If set, " "it uses this value as the modification timestamp for the file written into " "the ZIP archive, instead of using the current time." msgstr "" -#: ../../library/zipfile.rst:546 +#: ../../library/zipfile.rst:543 msgid "" "Create a directory inside the archive. If *zinfo_or_directory* is a string, " "a directory is created inside the archive with the mode that is specified in " @@ -832,19 +832,19 @@ msgstr "" "案內以 *mode* 引數中指定的模式建立一個目錄。然而,如果 *zinfo_or_directory* " "是一個 :class:`ZipInfo` 實例,則 *mode* 引數會被忽略。" -#: ../../library/zipfile.rst:551 +#: ../../library/zipfile.rst:548 msgid "The archive must be opened with mode ``'w'``, ``'x'`` or ``'a'``." msgstr "封存檔案必須以 ``'w'``、``'x'`` 或 ``'a'`` 模式開啟。" -#: ../../library/zipfile.rst:556 +#: ../../library/zipfile.rst:553 msgid "The following data attributes are also available:" msgstr "以下資料屬性也可用:" -#: ../../library/zipfile.rst:560 +#: ../../library/zipfile.rst:557 msgid "Name of the ZIP file." msgstr "ZIP 檔案的名稱。" -#: ../../library/zipfile.rst:564 +#: ../../library/zipfile.rst:561 msgid "" "The level of debug output to use. This may be set from ``0`` (the default, " "no output) to ``3`` (the most output). Debugging information is written to " @@ -853,7 +853,7 @@ msgstr "" "要使用的偵錯輸出層級。可以從 ``0``\\ (預設,無輸出)設定到 ``3``\\ (最多輸" "出)。偵錯資訊會被寫入到 ``sys.stdout``。" -#: ../../library/zipfile.rst:570 +#: ../../library/zipfile.rst:567 msgid "" "The comment associated with the ZIP file as a :class:`bytes` object. If " "assigning a comment to a :class:`ZipFile` instance created with mode " @@ -864,11 +864,11 @@ msgstr "" "``'x'`` 或 ``'a'`` 模式建立的 :class:`ZipFile` 實例指派註解,其長度不應超過 " "65535 位元組。超過此長度的註解將被截斷。" -#: ../../library/zipfile.rst:580 +#: ../../library/zipfile.rst:577 msgid "Path objects" msgstr "Path 物件" -#: ../../library/zipfile.rst:584 +#: ../../library/zipfile.rst:581 msgid "" "Construct a Path object from a ``root`` zipfile (which may be a :class:" "`ZipFile` instance or ``file`` suitable for passing to the :class:`ZipFile` " @@ -877,7 +877,7 @@ msgstr "" "從一個 ``root`` zipfile(它可以是一個 :class:`ZipFile` 實例或一個適合傳遞給 :" "class:`ZipFile` 建構函式的 ``file``)建構一個 Path 物件。" -#: ../../library/zipfile.rst:588 +#: ../../library/zipfile.rst:585 msgid "" "``at`` specifies the location of this Path within the zipfile, e.g. 'dir/" "file.txt', 'dir/', or ''. Defaults to the empty string, indicating the root." @@ -885,7 +885,7 @@ msgstr "" "``at`` 指定此 Path 在 zipfile 中的位置,例如 'dir/file.txt'、'dir/' 或 ''。預" "設為空字串,表示根目錄。" -#: ../../library/zipfile.rst:593 +#: ../../library/zipfile.rst:590 msgid "" "The :class:`Path` class does not sanitize filenames within the ZIP archive. " "Unlike the :meth:`ZipFile.extract` and :meth:`ZipFile.extractall` methods, " @@ -901,20 +901,20 @@ msgstr "" "案時,請考慮使用 :func:`os.path.abspath` 解析檔名,並使用 :func:`os.path." "commonpath` 與目標目錄進行核對。" -#: ../../library/zipfile.rst:600 +#: ../../library/zipfile.rst:597 msgid "" "Path objects expose the following features of :mod:`pathlib.Path` objects:" msgstr "Path 物件公開了 :mod:`pathlib.Path` 物件的以下特性:" -#: ../../library/zipfile.rst:603 +#: ../../library/zipfile.rst:600 msgid "Path objects are traversable using the ``/`` operator or ``joinpath``." msgstr "Path 物件可以使用 ``/`` 運算子或 ``joinpath`` 來遍歷。" -#: ../../library/zipfile.rst:607 +#: ../../library/zipfile.rst:604 msgid "The final path component." msgstr "最後的路徑元件。" -#: ../../library/zipfile.rst:611 +#: ../../library/zipfile.rst:608 msgid "" "Invoke :meth:`ZipFile.open` on the current path. Allows opening for read or " "write, text or binary through supported modes: 'r', 'w', 'rb', 'wb'. " @@ -927,12 +927,12 @@ msgstr "" "位置引數和關鍵字引數會被傳遞給 :class:`io.TextIOWrapper`,否則會被忽略。" "``pwd`` 是傳遞給 :meth:`ZipFile.open` 的 ``pwd`` 參數。" -#: ../../library/zipfile.rst:620 +#: ../../library/zipfile.rst:617 msgid "" "Added support for text and binary modes for open. Default mode is now text." msgstr "新增了對 open 的文字和二進位模式的支援。預設模式現在是文字模式。" -#: ../../library/zipfile.rst:624 ../../library/zipfile.rst:685 +#: ../../library/zipfile.rst:621 ../../library/zipfile.rst:682 msgid "" "The ``encoding`` parameter can be supplied as a positional argument without " "causing a :exc:`TypeError`. As it could in 3.9. Code needing to be " @@ -943,59 +943,59 @@ msgstr "" "3.9 中一樣。需要與未修補的 3.10 和 3.11 版本相容的程式碼,必須將所有 :class:" "`io.TextIOWrapper` 引數,包括 ``encoding``,作為關鍵字傳遞。" -#: ../../library/zipfile.rst:632 +#: ../../library/zipfile.rst:629 msgid "Enumerate the children of the current directory." msgstr "列舉目前目錄的子項目。" -#: ../../library/zipfile.rst:636 +#: ../../library/zipfile.rst:633 msgid "Return ``True`` if the current context references a directory." msgstr "如果目前情境參照到一個目錄,則回傳 ``True``。" -#: ../../library/zipfile.rst:640 +#: ../../library/zipfile.rst:637 msgid "Return ``True`` if the current context references a file." msgstr "如果目前情境參照到一個檔案,則回傳 ``True``。" -#: ../../library/zipfile.rst:644 +#: ../../library/zipfile.rst:641 msgid "Return ``True`` if the current context references a symbolic link." msgstr "如果目前情境參照到一個符號連結,則回傳 ``True``。" -#: ../../library/zipfile.rst:648 +#: ../../library/zipfile.rst:645 msgid "Previously, ``is_symlink`` would unconditionally return ``False``." msgstr "先前,``is_symlink`` 會無條件地回傳 ``False``。" -#: ../../library/zipfile.rst:653 +#: ../../library/zipfile.rst:650 msgid "" "Return ``True`` if the current context references a file or directory in the " "zip file." msgstr "如果目前情境參照到 zip 檔案中的一個檔案或目錄,則回傳 ``True``。" -#: ../../library/zipfile.rst:658 +#: ../../library/zipfile.rst:655 msgid "" "The last dot-separated portion of the final component, if any. This is " "commonly called the file extension." msgstr "最後一個元件中以點分隔的最後一部分(如果有的話)。這通常被稱為副檔名。" -#: ../../library/zipfile.rst:661 +#: ../../library/zipfile.rst:658 msgid "Added :data:`Path.suffix` property." msgstr "新增 :data:`Path.suffix` 特性。" -#: ../../library/zipfile.rst:666 +#: ../../library/zipfile.rst:663 msgid "The final path component, without its suffix." msgstr "最後的路徑元件,不含其後綴。" -#: ../../library/zipfile.rst:668 +#: ../../library/zipfile.rst:665 msgid "Added :data:`Path.stem` property." msgstr "新增 :data:`Path.stem` 特性。" -#: ../../library/zipfile.rst:673 +#: ../../library/zipfile.rst:670 msgid "A list of the path’s suffixes, commonly called file extensions." msgstr "路徑的後綴串列,通常稱為副檔名。" -#: ../../library/zipfile.rst:675 +#: ../../library/zipfile.rst:672 msgid "Added :data:`Path.suffixes` property." msgstr "新增 :data:`Path.suffixes` 特性。" -#: ../../library/zipfile.rst:680 +#: ../../library/zipfile.rst:677 msgid "" "Read the current file as unicode text. Positional and keyword arguments are " "passed through to :class:`io.TextIOWrapper` (except ``buffer``, which is " @@ -1004,17 +1004,17 @@ msgstr "" "將目前檔案讀取為 unicode 文字。位置引數和關鍵字引數會被傳遞給 :class:`io." "TextIOWrapper`\\ (但 ``buffer`` 會根據情境隱式處理)。" -#: ../../library/zipfile.rst:693 +#: ../../library/zipfile.rst:690 msgid "Read the current file as bytes." msgstr "將目前檔案讀取為位元組。" -#: ../../library/zipfile.rst:697 +#: ../../library/zipfile.rst:694 msgid "" "Return a new Path object with each of the *other* arguments joined. The " "following are equivalent::" msgstr "回傳一個新的 Path 物件,並將每個 *other* 引數加入。以下是等效的: ::" -#: ../../library/zipfile.rst:700 +#: ../../library/zipfile.rst:697 msgid "" ">>> Path(...).joinpath('child').joinpath('grandchild')\n" ">>> Path(...).joinpath('child', 'grandchild')\n" @@ -1024,13 +1024,13 @@ msgstr "" ">>> Path(...).joinpath('child', 'grandchild')\n" ">>> Path(...) / 'child' / 'grandchild'" -#: ../../library/zipfile.rst:704 +#: ../../library/zipfile.rst:701 msgid "" "Prior to 3.10, ``joinpath`` was undocumented and accepted exactly one " "parameter." msgstr "在 3.10 之前,``joinpath`` 沒有文件記載,且只接受一個參數。" -#: ../../library/zipfile.rst:708 +#: ../../library/zipfile.rst:705 msgid "" "The :pypi:`zipp` project provides backports of the latest path object " "functionality to older Pythons. Use ``zipp.Path`` in place of ``zipfile." @@ -1039,11 +1039,11 @@ msgstr "" ":pypi:`zipp` 專案為舊版 Python 提供了最新的 path 物件功能的向後移植版本。使" "用 ``zipp.Path`` 來取代 ``zipfile.Path`` 以提早使用變更。" -#: ../../library/zipfile.rst:716 +#: ../../library/zipfile.rst:713 msgid "PyZipFile objects" msgstr "PyZipFile 物件" -#: ../../library/zipfile.rst:718 +#: ../../library/zipfile.rst:715 msgid "" "The :class:`PyZipFile` constructor takes the same parameters as the :class:" "`ZipFile` constructor, and one additional parameter, *optimize*." @@ -1051,22 +1051,22 @@ msgstr "" ":class:`PyZipFile` 建構函式接受與 :class:`ZipFile` 建構函式相同的參數,以及一" "個額外的參數 *optimize*。" -#: ../../library/zipfile.rst:724 +#: ../../library/zipfile.rst:721 msgid "Added the *optimize* parameter." msgstr "新增 *optimize* 參數。" -#: ../../library/zipfile.rst:730 +#: ../../library/zipfile.rst:727 msgid "" "Instances have one method in addition to those of :class:`ZipFile` objects:" msgstr "實例除了 :class:`ZipFile` 物件的方法之外,還有一個額外的方法:" -#: ../../library/zipfile.rst:734 +#: ../../library/zipfile.rst:731 msgid "" "Search for files :file:`\\*.py` and add the corresponding file to the " "archive." msgstr "搜尋 :file:`\\*.py` 檔案,並將對應的檔案加入封存檔案。" -#: ../../library/zipfile.rst:737 +#: ../../library/zipfile.rst:734 msgid "" "If the *optimize* parameter to :class:`PyZipFile` was not given or ``-1``, " "the corresponding file is a :file:`\\*.pyc` file, compiling if necessary." @@ -1074,7 +1074,7 @@ msgstr "" "如果傳給 :class:`PyZipFile` 的 *optimize* 參數未被給定或為 ``-1``,則對應的檔" "案是一個 :file:`\\*.pyc` 檔案,如有必要則進行編譯。" -#: ../../library/zipfile.rst:740 +#: ../../library/zipfile.rst:737 msgid "" "If the *optimize* parameter to :class:`PyZipFile` was ``0``, ``1`` or ``2``, " "only files with that optimization level (see :func:`compile`) are added to " @@ -1084,7 +1084,7 @@ msgstr "" "有具有該最佳化層級(參閱 :func:`compile`)的檔案會被加入封存檔案,如有必要則" "進行編譯。" -#: ../../library/zipfile.rst:744 +#: ../../library/zipfile.rst:741 msgid "" "If *pathname* is a file, the filename must end with :file:`.py`, and just " "the (corresponding :file:`\\*.pyc`) file is added at the top level (no path " @@ -1103,11 +1103,11 @@ msgstr "" "是一個套件目錄,則所有 :file:`\\*.pyc` 都會以檔案路徑的形式被加到套件名稱下," "且如果任何子目錄是套件目錄,所有這些都會以排序後的順序遞迴地加入。" -#: ../../library/zipfile.rst:754 +#: ../../library/zipfile.rst:751 msgid "*basename* is intended for internal use only." msgstr "*basename* 僅供內部使用。" -#: ../../library/zipfile.rst:756 +#: ../../library/zipfile.rst:753 msgid "" "*filterfunc*, if given, must be a function taking a single string argument. " "It will be passed each path (including each individual full file path) " @@ -1123,7 +1123,7 @@ msgstr "" "果我們的測試檔案要嘛在 ``test`` 目錄中,要嘛以字串 ``test_`` 開頭,我們可以使" "用一個 *filterfunc* 來排除它們: ::" -#: ../../library/zipfile.rst:764 +#: ../../library/zipfile.rst:761 msgid "" ">>> zf = PyZipFile('myprog.zip')\n" ">>> def notests(s):\n" @@ -1139,11 +1139,11 @@ msgstr "" "...\n" ">>> zf.writepy('myprog', filterfunc=notests)" -#: ../../library/zipfile.rst:771 +#: ../../library/zipfile.rst:768 msgid "The :meth:`writepy` method makes archives with file names like this::" msgstr ":meth:`writepy` 方法會建立帶有如下檔名的封存檔案: ::" -#: ../../library/zipfile.rst:774 +#: ../../library/zipfile.rst:771 msgid "" "string.pyc # Top level name\n" "test/__init__.pyc # Package directory\n" @@ -1157,23 +1157,23 @@ msgstr "" "test/bogus/__init__.pyc # 子套件目錄\n" "test/bogus/myfile.pyc # 子模組 test.bogus.myfile" -#: ../../library/zipfile.rst:780 +#: ../../library/zipfile.rst:777 msgid "Added the *filterfunc* parameter." msgstr "新增 *filterfunc* 參數。" -#: ../../library/zipfile.rst:783 +#: ../../library/zipfile.rst:780 msgid "The *pathname* parameter accepts a :term:`path-like object`." msgstr "*pathname* 參數接受一個 :term:`path-like object`。" -#: ../../library/zipfile.rst:786 +#: ../../library/zipfile.rst:783 msgid "Recursion sorts directory entries." msgstr "遞迴會對目錄條目進行排序。" -#: ../../library/zipfile.rst:793 +#: ../../library/zipfile.rst:790 msgid "ZipInfo objects" msgstr "ZipInfo 物件" -#: ../../library/zipfile.rst:795 +#: ../../library/zipfile.rst:792 msgid "" "Instances of the :class:`ZipInfo` class are returned by the :meth:`.getinfo` " "and :meth:`.infolist` methods of :class:`ZipFile` objects. Each object " @@ -1182,13 +1182,13 @@ msgstr "" ":class:`ZipInfo` 類別的實例由 :class:`ZipFile` 物件的 :meth:`.getinfo` 和 :" "meth:`.infolist` 方法回傳。每個物件儲存關於 ZIP 封存檔案單一成員的資訊。" -#: ../../library/zipfile.rst:799 +#: ../../library/zipfile.rst:796 msgid "" "There is one classmethod to make a :class:`ZipInfo` instance for a " "filesystem file:" msgstr "有一個類別方法可以為檔案系統中的檔案建立一個 :class:`ZipInfo` 實例:" -#: ../../library/zipfile.rst:805 +#: ../../library/zipfile.rst:802 msgid "" "Construct a :class:`ZipInfo` instance for a file on the filesystem, in " "preparation for adding it to a zip file." @@ -1196,11 +1196,11 @@ msgstr "" "為檔案系統上的一個檔案建構一個 :class:`ZipInfo` 實例,為將其加入 zip 檔案做準" "備。" -#: ../../library/zipfile.rst:808 +#: ../../library/zipfile.rst:805 msgid "*filename* should be the path to a file or directory on the filesystem." msgstr "*filename* 應為檔案系統上一個檔案或目錄的路徑。" -#: ../../library/zipfile.rst:810 +#: ../../library/zipfile.rst:807 msgid "" "If *arcname* is specified, it is used as the name within the archive. If " "*arcname* is not specified, the name will be the same as *filename*, but " @@ -1209,31 +1209,31 @@ msgstr "" "如果指定了 *arcname*,它將被用作封存檔案內的名稱。如果未指定 *arcname*,名稱" "將與 *filename* 相同,但會移除任何磁碟機代號和開頭的路徑分隔符。" -#: ../../library/zipfile.rst:822 +#: ../../library/zipfile.rst:819 msgid "The *filename* parameter accepts a :term:`path-like object`." msgstr "*filename* 參數接受一個 :term:`path-like object`。" -#: ../../library/zipfile.rst:825 +#: ../../library/zipfile.rst:822 msgid "Added the *strict_timestamps* keyword-only parameter." msgstr "新增了 *strict_timestamps* 僅限關鍵字參數。" -#: ../../library/zipfile.rst:829 +#: ../../library/zipfile.rst:826 msgid "Instances have the following methods and attributes:" msgstr "實例具有以下方法和屬性:" -#: ../../library/zipfile.rst:833 +#: ../../library/zipfile.rst:830 msgid "Return ``True`` if this archive member is a directory." msgstr "如果此封存成員是一個目錄,則回傳 ``True``。" -#: ../../library/zipfile.rst:835 +#: ../../library/zipfile.rst:832 msgid "This uses the entry's name: directories should always end with ``/``." msgstr "這會使用條目的名稱:目錄應總是以 ``/`` 結尾。" -#: ../../library/zipfile.rst:842 +#: ../../library/zipfile.rst:839 msgid "Name of the file in the archive." msgstr "封存檔案中檔案的名稱。" -#: ../../library/zipfile.rst:847 +#: ../../library/zipfile.rst:844 msgid "" "The time and date of the last modification to the archive member. This is a " "tuple of six values representing the \"last [modified] file time\" and " @@ -1242,67 +1242,67 @@ msgstr "" "封存成員的最後修改時間和日期。這是一個包含六個值的元組,代表 ZIP 檔案中中央目" "錄的「最後 [修改] 檔案時間」和「最後 [修改] 檔案日期」欄位。" -#: ../../library/zipfile.rst:851 +#: ../../library/zipfile.rst:848 msgid "The tuple contains:" msgstr "該元組包含:" -#: ../../library/zipfile.rst:854 +#: ../../library/zipfile.rst:851 msgid "Index" msgstr "索引" -#: ../../library/zipfile.rst:854 +#: ../../library/zipfile.rst:851 msgid "Value" msgstr "值" -#: ../../library/zipfile.rst:856 +#: ../../library/zipfile.rst:853 msgid "``0``" msgstr "``0``" -#: ../../library/zipfile.rst:856 +#: ../../library/zipfile.rst:853 msgid "Year (>= 1980)" msgstr "年(>= 1980)" -#: ../../library/zipfile.rst:858 +#: ../../library/zipfile.rst:855 msgid "``1``" msgstr "``1``" -#: ../../library/zipfile.rst:858 +#: ../../library/zipfile.rst:855 msgid "Month (one-based)" msgstr "月(從 1 開始)" -#: ../../library/zipfile.rst:860 +#: ../../library/zipfile.rst:857 msgid "``2``" msgstr "``2``" -#: ../../library/zipfile.rst:860 +#: ../../library/zipfile.rst:857 msgid "Day of month (one-based)" msgstr "日(從 1 開始)" -#: ../../library/zipfile.rst:862 +#: ../../library/zipfile.rst:859 msgid "``3``" msgstr "``3``" -#: ../../library/zipfile.rst:862 +#: ../../library/zipfile.rst:859 msgid "Hours (zero-based)" msgstr "時(從 0 開始)" -#: ../../library/zipfile.rst:864 +#: ../../library/zipfile.rst:861 msgid "``4``" msgstr "``4``" -#: ../../library/zipfile.rst:864 +#: ../../library/zipfile.rst:861 msgid "Minutes (zero-based)" msgstr "分(從 0 開始)" -#: ../../library/zipfile.rst:866 +#: ../../library/zipfile.rst:863 msgid "``5``" msgstr "``5``" -#: ../../library/zipfile.rst:866 +#: ../../library/zipfile.rst:863 msgid "Seconds (zero-based)" msgstr "秒(從 0 開始)" -#: ../../library/zipfile.rst:871 +#: ../../library/zipfile.rst:868 msgid "" "The ZIP format supports multiple timestamp fields in different locations " "(central directory, extra fields for NTFS/UNIX systems, etc.). This " @@ -1313,21 +1313,21 @@ msgid "" "timestamp." msgstr "" -#: ../../library/zipfile.rst:878 +#: ../../library/zipfile.rst:875 msgid "" "The central directory timestamp is interpreted as representing local time, " "rather than UTC time, to match the behavior of other zip tools." msgstr "" -#: ../../library/zipfile.rst:884 +#: ../../library/zipfile.rst:881 msgid "Type of compression for the archive member." msgstr "封存成員的壓縮型別。" -#: ../../library/zipfile.rst:889 +#: ../../library/zipfile.rst:886 msgid "Comment for the individual archive member as a :class:`bytes` object." msgstr "個別封存成員的註解,為一個 :class:`bytes` 物件。" -#: ../../library/zipfile.rst:894 +#: ../../library/zipfile.rst:891 msgid "" "Expansion field data. The `PKZIP Application Note`_ contains some comments " "on the internal structure of the data contained in this :class:`bytes` " @@ -1336,66 +1336,66 @@ msgstr "" "擴充欄位資料。`PKZIP Application Note`_ 包含一些關於此 :class:`bytes` 物件中" "所含資料內部結構的註解。" -#: ../../library/zipfile.rst:901 +#: ../../library/zipfile.rst:898 msgid "System which created ZIP archive." msgstr "建立 ZIP 封存檔案的系統。" -#: ../../library/zipfile.rst:906 +#: ../../library/zipfile.rst:903 msgid "PKZIP version which created ZIP archive." msgstr "建立 ZIP 封存檔案的 PKZIP 版本。" -#: ../../library/zipfile.rst:911 +#: ../../library/zipfile.rst:908 msgid "PKZIP version needed to extract archive." msgstr "解壓縮封存檔案所需的 PKZIP 版本。" -#: ../../library/zipfile.rst:916 +#: ../../library/zipfile.rst:913 msgid "Must be zero." msgstr "必須為零。" -#: ../../library/zipfile.rst:921 +#: ../../library/zipfile.rst:918 msgid "ZIP flag bits." msgstr "ZIP 旗標位元。" -#: ../../library/zipfile.rst:926 +#: ../../library/zipfile.rst:923 msgid "Volume number of file header." msgstr "檔案標頭的磁碟空間編號。" -#: ../../library/zipfile.rst:931 +#: ../../library/zipfile.rst:928 msgid "Internal attributes." msgstr "內部屬性。" -#: ../../library/zipfile.rst:936 +#: ../../library/zipfile.rst:933 msgid "External file attributes." msgstr "外部檔案屬性。" -#: ../../library/zipfile.rst:941 +#: ../../library/zipfile.rst:938 msgid "Byte offset to the file header." msgstr "到檔案標頭的位元組偏移量。" -#: ../../library/zipfile.rst:946 +#: ../../library/zipfile.rst:943 msgid "CRC-32 of the uncompressed file." msgstr "未壓縮檔案的 CRC-32。" -#: ../../library/zipfile.rst:951 +#: ../../library/zipfile.rst:948 msgid "Size of the compressed data." msgstr "壓縮資料的大小。" -#: ../../library/zipfile.rst:956 +#: ../../library/zipfile.rst:953 msgid "Size of the uncompressed file." msgstr "未壓縮檔案的大小。" -#: ../../library/zipfile.rst:963 +#: ../../library/zipfile.rst:960 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/zipfile.rst:965 +#: ../../library/zipfile.rst:962 msgid "" "The :mod:`!zipfile` module provides a simple command-line interface to " "interact with ZIP archives." msgstr "" ":mod:`!zipfile` 模組提供了一個簡單的命令列介面,用以與 ZIP 封存檔案互動。" -#: ../../library/zipfile.rst:968 +#: ../../library/zipfile.rst:965 msgid "" "If you want to create a new ZIP archive, specify its name after the :option:" "`-c` option and then list the filename(s) that should be included:" @@ -1403,78 +1403,78 @@ msgstr "" "如果你想建立一個新的 ZIP 封存檔案,請在 :option:`-c` 選項後指定其名稱,然後列" "出應包含的檔名:" -#: ../../library/zipfile.rst:971 +#: ../../library/zipfile.rst:968 msgid "$ python -m zipfile -c monty.zip spam.txt eggs.txt" msgstr "$ python -m zipfile -c monty.zip spam.txt eggs.txt" -#: ../../library/zipfile.rst:975 +#: ../../library/zipfile.rst:972 msgid "Passing a directory is also acceptable:" msgstr "傳遞一個目錄也是可以的:" -#: ../../library/zipfile.rst:977 +#: ../../library/zipfile.rst:974 msgid "$ python -m zipfile -c monty.zip life-of-brian_1979/" msgstr "$ python -m zipfile -c monty.zip life-of-brian_1979/" -#: ../../library/zipfile.rst:981 +#: ../../library/zipfile.rst:978 msgid "" "If you want to extract a ZIP archive into the specified directory, use the :" "option:`-e` option:" msgstr "" "如果你想將一個 ZIP 封存檔案解壓縮到指定的目錄,請使用 :option:`-e` 選項:" -#: ../../library/zipfile.rst:984 +#: ../../library/zipfile.rst:981 msgid "$ python -m zipfile -e monty.zip target-dir/" msgstr "$ python -m zipfile -e monty.zip target-dir/" -#: ../../library/zipfile.rst:988 +#: ../../library/zipfile.rst:985 msgid "For a list of the files in a ZIP archive, use the :option:`-l` option:" msgstr "要列出 ZIP 封存檔案中的檔案,請使用 :option:`-l` 選項:" -#: ../../library/zipfile.rst:990 +#: ../../library/zipfile.rst:987 msgid "$ python -m zipfile -l monty.zip" msgstr "$ python -m zipfile -l monty.zip" -#: ../../library/zipfile.rst:996 +#: ../../library/zipfile.rst:993 msgid "Command-line options" msgstr "命令列選項" -#: ../../library/zipfile.rst:1001 +#: ../../library/zipfile.rst:998 msgid "List files in a zipfile." msgstr "列出 zipfile 中的檔案。" -#: ../../library/zipfile.rst:1006 +#: ../../library/zipfile.rst:1003 msgid "Create zipfile from source files." msgstr "從來源檔案建立 zipfile。" -#: ../../library/zipfile.rst:1011 +#: ../../library/zipfile.rst:1008 msgid "Extract zipfile into target directory." msgstr "將 zipfile 解壓縮到目標目錄。" -#: ../../library/zipfile.rst:1016 +#: ../../library/zipfile.rst:1013 msgid "Test whether the zipfile is valid or not." msgstr "測試 zipfile 是否有效。" -#: ../../library/zipfile.rst:1020 +#: ../../library/zipfile.rst:1017 msgid "" "Specify encoding of member names for :option:`-l`, :option:`-e` and :option:" "`-t`." msgstr "為 :option:`-l`、:option:`-e` 和 :option:`-t` 指定成員名稱的編碼。" -#: ../../library/zipfile.rst:1027 +#: ../../library/zipfile.rst:1024 msgid "Decompression pitfalls" msgstr "解壓縮的陷阱" -#: ../../library/zipfile.rst:1029 +#: ../../library/zipfile.rst:1026 msgid "" "The extraction in zipfile module might fail due to some pitfalls listed " "below." msgstr "zipfile 模組中的解壓縮可能會由於下面列出的一些陷阱而失敗。" -#: ../../library/zipfile.rst:1032 +#: ../../library/zipfile.rst:1029 msgid "From file itself" msgstr "來自檔案本身" -#: ../../library/zipfile.rst:1034 +#: ../../library/zipfile.rst:1031 msgid "" "Decompression may fail due to incorrect password / CRC checksum / ZIP format " "or unsupported compression method / decryption." @@ -1482,11 +1482,11 @@ msgstr "" "解壓縮可能由於不正確的密碼 / CRC 校驗和 / ZIP 格式或不支援的壓縮方法 / 解密而" "失敗。" -#: ../../library/zipfile.rst:1038 +#: ../../library/zipfile.rst:1035 msgid "File system limitations" msgstr "檔案系統限制" -#: ../../library/zipfile.rst:1040 +#: ../../library/zipfile.rst:1037 msgid "" "Exceeding limitations on different file systems can cause decompression " "failed. Such as allowable characters in the directory entries, length of the " @@ -1496,11 +1496,11 @@ msgstr "" "超出不同檔案系統的限制可能導致解壓縮失敗。例如目錄條目中允許的字元、檔名長" "度、路徑名長度、單一檔案的大小以及檔案數量等。" -#: ../../library/zipfile.rst:1047 +#: ../../library/zipfile.rst:1044 msgid "Resources limitations" msgstr "資源限制" -#: ../../library/zipfile.rst:1049 +#: ../../library/zipfile.rst:1046 msgid "" "The lack of memory or disk volume would lead to decompression failed. For " "example, decompression bombs (aka `ZIP bomb`_) apply to zipfile library that " @@ -1509,11 +1509,11 @@ msgstr "" "記憶體或磁碟空間不足會導致解壓縮失敗。例如,解壓縮炸彈(又稱 `ZIP bomb`_)適" "用於 zipfile 函式庫,可能導致磁碟空間耗盡。" -#: ../../library/zipfile.rst:1054 +#: ../../library/zipfile.rst:1051 msgid "Interruption" msgstr "中斷" -#: ../../library/zipfile.rst:1056 +#: ../../library/zipfile.rst:1053 msgid "" "Interruption during the decompression, such as pressing control-C or killing " "the decompression process may result in incomplete decompression of the " @@ -1522,11 +1522,11 @@ msgstr "" "在解壓縮過程中斷,例如按下 control-C 或終止解壓縮過程,可能導致封存檔案解壓縮" "不完整。" -#: ../../library/zipfile.rst:1060 +#: ../../library/zipfile.rst:1057 msgid "Default behaviors of extraction" msgstr "解壓縮的預設行為" -#: ../../library/zipfile.rst:1062 +#: ../../library/zipfile.rst:1059 msgid "" "Not knowing the default extraction behaviors can cause unexpected " "decompression results. For example, when extracting the same archive twice, " diff --git a/library/zipimport.po b/library/zipimport.po index a51317874ef..5eeefba2a27 100644 --- a/library/zipimport.po +++ b/library/zipimport.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-07 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-06-29 00:00+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,11 +23,11 @@ msgstr "" msgid ":mod:`!zipimport` --- Import modules from Zip archives" msgstr ":mod:`!zipimport` --- 從 Zip 封存檔案匯入模組" -#: ../../library/zipimport.rst:9 +#: ../../library/zipimport.rst:7 msgid "**Source code:** :source:`Lib/zipimport.py`" msgstr "**原始碼:**\\ :source:`Lib/zipimport.py`" -#: ../../library/zipimport.rst:13 +#: ../../library/zipimport.rst:11 msgid "" "This module adds the ability to import Python modules (:file:`\\*.py`, :file:" "`\\*.pyc`) and packages from ZIP-format archives. It is usually not needed " @@ -40,7 +40,7 @@ msgstr "" "data:`sys.path` 中指向 ZIP 封存檔案路徑的項目,內建的 :keyword:`import` 機制" "會自動使用它。" -#: ../../library/zipimport.rst:19 +#: ../../library/zipimport.rst:17 msgid "" "Typically, :data:`sys.path` is a list of directory names as strings. This " "module also allows an item of :data:`sys.path` to be a string naming a ZIP " @@ -55,7 +55,7 @@ msgstr "" "構以支援套件引入,並且可以指定封存檔案內的路徑以僅從子目錄中引入。例如路徑 :" "file:`example.zip/lib/` 將只會從封存檔案內的 :file:`lib/` 子目錄中引入。" -#: ../../library/zipimport.rst:26 +#: ../../library/zipimport.rst:24 msgid "" "Any files may be present in the ZIP archive, but importers are only invoked " "for :file:`.py` and :file:`.pyc` files. ZIP import of dynamic modules (:" @@ -70,15 +70,19 @@ msgstr "" "pyc` 檔案來修改封存檔案,這意味著如果 ZIP 封存檔案不包含 :file:`.pyc` 檔案," "引入可能會相當慢。" -#: ../../library/zipimport.rst:33 +#: ../../library/zipimport.rst:31 +msgid "Zstandard (*zstd*) compressed zip file entries are supported." +msgstr "" + +#: ../../library/zipimport.rst:34 msgid "ZIP64 is supported" msgstr "支援 ZIP64。" -#: ../../library/zipimport.rst:36 +#: ../../library/zipimport.rst:37 msgid "Previously, ZIP archives with an archive comment were not supported." msgstr "在過去,不支援帶有封存檔案註解的 ZIP 封存檔案。" -#: ../../library/zipimport.rst:41 +#: ../../library/zipimport.rst:42 msgid "" "`PKZIP Application Note `_" @@ -86,18 +90,18 @@ msgstr "" "`PKZIP Application Note `_" -#: ../../library/zipimport.rst:42 +#: ../../library/zipimport.rst:43 msgid "" "Documentation on the ZIP file format by Phil Katz, the creator of the format " "and algorithms used." msgstr "" "由 ZIP 格式和所用演算法的創造者 Phil Katz 編寫的關於 ZIP 檔案格式的文件。" -#: ../../library/zipimport.rst:45 +#: ../../library/zipimport.rst:46 msgid ":pep:`273` - Import Modules from Zip Archives" msgstr ":pep:`273` - 從 Zip 封存檔案引入模組" -#: ../../library/zipimport.rst:46 +#: ../../library/zipimport.rst:47 msgid "" "Written by James C. Ahlstrom, who also provided an implementation. Python " "2.3 follows the specification in :pep:`273`, but uses an implementation " @@ -108,20 +112,20 @@ msgstr "" "的規範,但使用由 Just van Rossum 編寫的實作,該實作使用了 :pep:`302` 中描述的" "引入掛鉤。" -#: ../../library/zipimport.rst:50 +#: ../../library/zipimport.rst:51 msgid ":mod:`importlib` - The implementation of the import machinery" msgstr ":mod:`importlib` - 引入機制的實作" -#: ../../library/zipimport.rst:51 +#: ../../library/zipimport.rst:52 msgid "" "Package providing the relevant protocols for all importers to implement." msgstr "提供所有引入器要實作的相關協定的套件。" -#: ../../library/zipimport.rst:55 +#: ../../library/zipimport.rst:56 msgid "This module defines an exception:" msgstr "此模組定義了一個例外:" -#: ../../library/zipimport.rst:59 +#: ../../library/zipimport.rst:60 msgid "" "Exception raised by zipimporter objects. It's a subclass of :exc:" "`ImportError`, so it can be caught as :exc:`ImportError`, too." @@ -129,15 +133,15 @@ msgstr "" "由 zipimporter 物件引發的例外。它是 :exc:`ImportError` 的子類別,所以也可以被" "捕捉為 :exc:`ImportError`。" -#: ../../library/zipimport.rst:66 +#: ../../library/zipimport.rst:67 msgid "zipimporter Objects" msgstr "zipimporter 物件" -#: ../../library/zipimport.rst:68 +#: ../../library/zipimport.rst:69 msgid ":class:`zipimporter` is the class for importing ZIP files." msgstr ":class:`zipimporter` 是用於引入 ZIP 檔案的類別。" -#: ../../library/zipimport.rst:72 +#: ../../library/zipimport.rst:73 msgid "" "Create a new zipimporter instance. *archivepath* must be a path to a ZIP " "file, or to a specific path within a ZIP file. For example, an " @@ -150,7 +154,7 @@ msgstr "" "檔案 :file:`foo/bar.zip` 內的 :file:`lib` 目錄中尋找模組(如果該目錄存在的" "話)。" -#: ../../library/zipimport.rst:77 +#: ../../library/zipimport.rst:78 msgid "" ":exc:`ZipImportError` is raised if *archivepath* doesn't point to a valid " "ZIP archive." @@ -158,7 +162,7 @@ msgstr "" "如果 *archivepath* 未指向一個有效的 ZIP 封存檔案,則會引發 :exc:" "`ZipImportError`。" -#: ../../library/zipimport.rst:82 +#: ../../library/zipimport.rst:83 msgid "" "Methods ``find_loader()`` and ``find_module()``, deprecated in 3.10 are now " "removed. Use :meth:`find_spec` instead." @@ -166,7 +170,7 @@ msgstr "" "在 3.10 版中已棄用的 ``find_loader()`` 和 ``find_module()`` 方法現已被移除。" "請改用 :meth:`find_spec`。" -#: ../../library/zipimport.rst:87 +#: ../../library/zipimport.rst:88 msgid "" "Implementation of :meth:`importlib.abc.Loader.create_module` that returns :" "const:`None` to explicitly request the default semantics." @@ -174,32 +178,32 @@ msgstr "" ":meth:`importlib.abc.Loader.create_module` 的實作,回傳 :const:`None` 以明確" "請求預設語意。" -#: ../../library/zipimport.rst:95 +#: ../../library/zipimport.rst:96 msgid "Implementation of :meth:`importlib.abc.Loader.exec_module`." msgstr ":meth:`importlib.abc.Loader.exec_module` 的實作。" -#: ../../library/zipimport.rst:102 +#: ../../library/zipimport.rst:103 msgid "An implementation of :meth:`importlib.abc.PathEntryFinder.find_spec`." msgstr ":meth:`importlib.abc.PathEntryFinder.find_spec` 的一個實作。" -#: ../../library/zipimport.rst:109 +#: ../../library/zipimport.rst:110 msgid "" "Return the code object for the specified module. Raise :exc:`ZipImportError` " "if the module couldn't be imported." msgstr "" "回傳指定模組的程式碼物件。如果模組無法被引入,則引發 :exc:`ZipImportError`。" -#: ../../library/zipimport.rst:115 +#: ../../library/zipimport.rst:116 msgid "" "Return the data associated with *pathname*. Raise :exc:`OSError` if the file " "wasn't found." msgstr "回傳與 *pathname* 相關的資料。如果找不到檔案,則引發 :exc:`OSError`。" -#: ../../library/zipimport.rst:118 +#: ../../library/zipimport.rst:119 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." msgstr "過去會引發 :exc:`IOError`,現在它是 :exc:`OSError` 的別名。" -#: ../../library/zipimport.rst:124 +#: ../../library/zipimport.rst:125 msgid "" "Return the value ``__file__`` would be set to if the specified module was " "imported. Raise :exc:`ZipImportError` if the module couldn't be imported." @@ -207,7 +211,7 @@ msgstr "" "回傳如果指定模組被引入時 ``__file__`` 會被設定的值。如果模組無法被引入,則引" "發 :exc:`ZipImportError`。" -#: ../../library/zipimport.rst:133 +#: ../../library/zipimport.rst:134 msgid "" "Return the source code for the specified module. Raise :exc:`ZipImportError` " "if the module couldn't be found, return :const:`None` if the archive does " @@ -216,7 +220,7 @@ msgstr "" "回傳指定模組的原始碼。如果找不到模組,則引發 :exc:`ZipImportError`;如果封存" "檔案包含該模組但沒有其原始碼,則回傳 :const:`None`。" -#: ../../library/zipimport.rst:141 +#: ../../library/zipimport.rst:142 msgid "" "Return ``True`` if the module specified by *fullname* is a package. Raise :" "exc:`ZipImportError` if the module couldn't be found." @@ -224,32 +228,19 @@ msgstr "" "如果由 *fullname* 指定的模組是一個套件,則回傳 ``True``。如果找不到模組,則引" "發 :exc:`ZipImportError`。" -#: ../../library/zipimport.rst:147 -msgid "" -"Load the module specified by *fullname*. *fullname* must be the fully " -"qualified (dotted) module name. Returns the imported module on success, " -"raises :exc:`ZipImportError` on failure." -msgstr "" -"載入由 *fullname* 指定的模組。*fullname* 必須是完整限定(以點分隔)的模組名" -"稱。成功時回傳引入的模組,失敗時引發 :exc:`ZipImportError`。" - -#: ../../library/zipimport.rst:153 -msgid "Use :meth:`exec_module` instead." -msgstr "請改用 :meth:`exec_module`。" - -#: ../../library/zipimport.rst:158 +#: ../../library/zipimport.rst:148 msgid "" "Clear out the internal cache of information about files found within the ZIP " "archive." msgstr "清除關於在 ZIP 封存檔案中找到的檔案資訊的內部快取。" -#: ../../library/zipimport.rst:166 +#: ../../library/zipimport.rst:156 msgid "" "The file name of the importer's associated ZIP file, without a possible " "subpath." msgstr "引入器關聯的 ZIP 檔案的檔名,不包含可能的子路徑。" -#: ../../library/zipimport.rst:172 +#: ../../library/zipimport.rst:162 msgid "" "The subpath within the ZIP file where modules are searched. This is the " "empty string for zipimporter objects which point to the root of the ZIP file." @@ -257,7 +248,7 @@ msgstr "" "在 ZIP 檔案內搜尋模組的子路徑。對於指向 ZIP 檔案根目錄的 zipimporter 物件,這" "是一個空字串。" -#: ../../library/zipimport.rst:176 +#: ../../library/zipimport.rst:166 msgid "" "The :attr:`archive` and :attr:`prefix` attributes, when combined with a " "slash, equal the original *archivepath* argument given to the :class:" @@ -266,11 +257,11 @@ msgstr "" ":attr:`archive` 和 :attr:`prefix` 屬性(attribute),當用斜線組合時,等於給" "予 :class:`zipimporter` 建構函式的原始 *archivepath* 引數。" -#: ../../library/zipimport.rst:184 +#: ../../library/zipimport.rst:174 msgid "Examples" msgstr "範例" -#: ../../library/zipimport.rst:186 +#: ../../library/zipimport.rst:176 msgid "" "Here is an example that imports a module from a ZIP archive - note that the :" "mod:`!zipimport` module is not explicitly used." @@ -278,7 +269,7 @@ msgstr "" "這是一個從 ZIP 封存檔案引入模組的範例——請注意,:mod:`!zipimport` 模組並未被明" "確使用。" -#: ../../library/zipimport.rst:189 +#: ../../library/zipimport.rst:179 msgid "" "$ unzip -l example_archive.zip\n" "Archive: example_archive.zip\n" @@ -296,7 +287,7 @@ msgstr "" " -------- -------\n" " 8467 1 file" -#: ../../library/zipimport.rst:199 +#: ../../library/zipimport.rst:189 msgid "" ">>> import sys\n" ">>> # Add the archive to the front of the module search path\n" @@ -311,3 +302,14 @@ msgstr "" ">>> import example\n" ">>> example.__file__\n" "'example_archive.zip/example.py'" + +#~ msgid "" +#~ "Load the module specified by *fullname*. *fullname* must be the fully " +#~ "qualified (dotted) module name. Returns the imported module on success, " +#~ "raises :exc:`ZipImportError` on failure." +#~ msgstr "" +#~ "載入由 *fullname* 指定的模組。*fullname* 必須是完整限定(以點分隔)的模組" +#~ "名稱。成功時回傳引入的模組,失敗時引發 :exc:`ZipImportError`。" + +#~ msgid "Use :meth:`exec_module` instead." +#~ msgstr "請改用 :meth:`exec_module`。" diff --git a/library/zlib.po b/library/zlib.po index bfd6f2238ad..1b78b447bea 100644 --- a/library/zlib.po +++ b/library/zlib.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-10 16:45+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-12-28 20:58+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -79,11 +79,29 @@ msgstr "" "於身份驗證 (authentication) 或數位簽章 (digital signature)。由於該演算法是為" "核對和演算法而設計的,它並不適合作為通用的雜湊演算法。" -#: ../../library/zlib.rst:42 ../../library/zlib.rst:131 +#: ../../library/zlib.rst:42 ../../library/zlib.rst:145 msgid "The result is always unsigned." msgstr "結果總是為 unsigned。" #: ../../library/zlib.rst:47 +msgid "Combine two Adler-32 checksums into one." +msgstr "" + +#: ../../library/zlib.rst:49 +msgid "" +"Given the Adler-32 checksum *adler1* of a sequence ``A`` and the Adler-32 " +"checksum *adler2* of a sequence ``B`` of length *len2*, return the Adler-32 " +"checksum of ``A`` and ``B`` concatenated." +msgstr "" + +#: ../../library/zlib.rst:53 +msgid "" +"This function is typically useful to combine Adler-32 checksums that were " +"concurrently computed. To compute checksums sequentially, use :func:" +"`adler32` with the running checksum as the ``value`` argument." +msgstr "" + +#: ../../library/zlib.rst:61 msgid "" "Compresses the bytes in *data*, returning a bytes object containing " "compressed data. *level* is an integer from ``0`` to ``9`` or ``-1`` " @@ -98,7 +116,7 @@ msgstr "" "`Z_NO_COMPRESSION` (``0``),以及預設值 :const:`Z_DEFAULT_COMPRESSION` " "(``-1``) 以得到更多關於這些值的資訊。" -#: ../../library/zlib.rst:55 +#: ../../library/zlib.rst:69 msgid "" "The *wbits* argument controls the size of the history buffer (or the " "\"window size\") used when compressing data, and whether a header and " @@ -109,7 +127,7 @@ msgstr "" "「視窗大小」),以及輸出中是否包含標題和尾末 (trailer)。它可以採用多個值的範" "圍,預設為 ``15`` (:const:`MAX_WBITS`):" -#: ../../library/zlib.rst:60 +#: ../../library/zlib.rst:74 msgid "" "+9 to +15: The base-two logarithm of the window size, which therefore ranges " "between 512 and 32768. Larger values produce better compression at the " @@ -120,7 +138,7 @@ msgstr "" "產生更佳的壓縮,但會佔用更多的記憶體。生成輸出將包含特定於 zlib 的標頭和尾" "末。" -#: ../../library/zlib.rst:65 +#: ../../library/zlib.rst:79 msgid "" "−9 to −15: Uses the absolute value of *wbits* as the window size logarithm, " "while producing a raw output stream with no header or trailing checksum." @@ -128,7 +146,7 @@ msgstr "" "−9 到 −15:使用 *wbits* 的絕對值作為視窗大小的對數,同時生成沒有標頭或尾末核" "對和的原始輸出串流。" -#: ../../library/zlib.rst:69 +#: ../../library/zlib.rst:83 msgid "" "+25 to +31 = 16 + (9 to 15): Uses the low 4 bits of the value as the window " "size logarithm, while including a basic :program:`gzip` header and trailing " @@ -137,27 +155,27 @@ msgstr "" "+25 到 +31 = 16 +(9 到 15):使用數值的最低 4 位元作為視窗大小的對數,同時在" "輸出中包含基本的 gzip 標頭和尾末核對和。" -#: ../../library/zlib.rst:73 +#: ../../library/zlib.rst:87 msgid "Raises the :exc:`error` exception if any error occurs." msgstr "如果發生任何錯誤,則引發 :exc:`error` 例外。" -#: ../../library/zlib.rst:75 +#: ../../library/zlib.rst:89 msgid "*level* can now be used as a keyword parameter." msgstr "*level* 現在可以用作關鍵字參數。" -#: ../../library/zlib.rst:78 +#: ../../library/zlib.rst:92 msgid "" "The *wbits* parameter is now available to set window bits and compression " "type." msgstr "*wbits* 參數現在可用於設定視窗位元和壓縮型別。" -#: ../../library/zlib.rst:84 +#: ../../library/zlib.rst:98 msgid "" "Returns a compression object, to be used for compressing data streams that " "won't fit into memory at once." msgstr "回傳一個壓縮物件,用於壓縮不能一次全部放入記憶體中的資料串流。" -#: ../../library/zlib.rst:87 +#: ../../library/zlib.rst:101 msgid "" "*level* is the compression level -- an integer from ``0`` to ``9`` or " "``-1``. See :const:`Z_BEST_SPEED` (``1``), :const:`Z_BEST_COMPRESSION` " @@ -165,13 +183,13 @@ msgid "" "`Z_DEFAULT_COMPRESSION` (``-1``) for more information about these values." msgstr "" -#: ../../library/zlib.rst:92 +#: ../../library/zlib.rst:106 msgid "" "*method* is the compression algorithm. Currently, the only supported value " "is :const:`DEFLATED`." msgstr "*method* 代表壓縮演算法。目前唯一支援的值是 :const:`DEFLATED`。" -#: ../../library/zlib.rst:95 +#: ../../library/zlib.rst:109 msgid "" "The *wbits* parameter controls the size of the history buffer (or the " "\"window size\"), and what header and trailer format will be used. It has " @@ -180,7 +198,7 @@ msgstr "" "*wbits* 參數控制歷史紀錄緩衝區的大小(或「視窗大小」),以及將使用的標頭和尾" "末格式。它與\\ `前面敘述的 compress() <#compress-wbits>`__ 具有相同的含義。" -#: ../../library/zlib.rst:99 +#: ../../library/zlib.rst:113 msgid "" "The *memLevel* argument controls the amount of memory used for the internal " "compression state. Valid values range from ``1`` to ``9``. Higher values use " @@ -189,7 +207,7 @@ msgstr "" "*memLevel* 引數控制用於內部壓縮狀態的記憶體大小。有效值範圍為 ``1`` 到 " "``9``。較高的值會使用更多的記憶體,但速度更快並產生更小的輸出。" -#: ../../library/zlib.rst:103 +#: ../../library/zlib.rst:117 msgid "" "*strategy* is used to tune the compression algorithm. Possible values are :" "const:`Z_DEFAULT_STRATEGY`, :const:`Z_FILTERED`, :const:`Z_HUFFMAN_ONLY`, :" @@ -199,7 +217,7 @@ msgstr "" "const:`Z_FILTERED`、:const:`Z_HUFFMAN_ONLY`、:const:`Z_RLE` 和 :const:" "`Z_FIXED`。" -#: ../../library/zlib.rst:107 +#: ../../library/zlib.rst:121 msgid "" "*zdict* is a predefined compression dictionary. This is a sequence of bytes " "(such as a :class:`bytes` object) containing subsequences that are expected " @@ -210,11 +228,11 @@ msgstr "" "`bytes` 物件),其中包含預期在要壓縮的資料中頻繁出現的子序列。那些預期會最常" "見的子序列應該出現在字典的尾末。" -#: ../../library/zlib.rst:112 +#: ../../library/zlib.rst:126 msgid "Added the *zdict* parameter and keyword argument support." msgstr "新增 *zdict* 參數與支援關鍵字引數。" -#: ../../library/zlib.rst:122 +#: ../../library/zlib.rst:136 msgid "" "Computes a CRC (Cyclic Redundancy Check) checksum of *data*. The result is " "an unsigned 32-bit integer. If *value* is present, it is used as the " @@ -231,7 +249,25 @@ msgstr "" "不夠高,不該用於身份驗證或數位簽章。由於該演算法是為核對和演算法而設計的,它" "並不適合作為通用的雜湊演算法。" -#: ../../library/zlib.rst:136 +#: ../../library/zlib.rst:150 +msgid "Combine two CRC-32 checksums into one." +msgstr "" + +#: ../../library/zlib.rst:152 +msgid "" +"Given the CRC-32 checksum *crc1* of a sequence ``A`` and the CRC-32 checksum " +"*crc2* of a sequence ``B`` of length *len2*, return the CRC-32 checksum of " +"``A`` and ``B`` concatenated." +msgstr "" + +#: ../../library/zlib.rst:156 +msgid "" +"This function is typically useful to combine CRC-32 checksums that were " +"concurrently computed. To compute checksums sequentially, use :func:`crc32` " +"with the running checksum as the ``value`` argument." +msgstr "" + +#: ../../library/zlib.rst:164 msgid "" "Decompresses the bytes in *data*, returning a bytes object containing the " "uncompressed data. The *wbits* parameter depends on the format of *data*, " @@ -243,7 +279,7 @@ msgstr "" "於 *data* 的格式,下面將進一步討論。如果有給定 *bufsize*,它會被用作輸出緩衝" "區的初始大小。如果發生任何錯誤,則引發 :exc:`error` 例外。" -#: ../../library/zlib.rst:144 +#: ../../library/zlib.rst:172 msgid "" "The *wbits* parameter controls the size of the history buffer (or \"window " "size\"), and what header and trailer format is expected. It is similar to " @@ -252,21 +288,21 @@ msgstr "" "*wbits* 參數控制歷史紀錄緩衝區的大小(或「視窗大小」),以及期望的標頭和尾末" "格式。它類似於 :func:`compressobj` 的參數,但接受更多範圍的值:" -#: ../../library/zlib.rst:149 +#: ../../library/zlib.rst:177 msgid "" "+8 to +15: The base-two logarithm of the window size. The input must " "include a zlib header and trailer." msgstr "" "+8 到 +15:視窗大小的以二為底的對數。輸入必須包括一個 zlib 標頭和尾末。" -#: ../../library/zlib.rst:152 +#: ../../library/zlib.rst:180 msgid "" "0: Automatically determine the window size from the zlib header. Only " "supported since zlib 1.2.3.5." msgstr "" "0:根據 zlib 標頭檔自動決定視窗大小。僅有在 zlib 1.2.3.5 或更新的版本支援。" -#: ../../library/zlib.rst:155 +#: ../../library/zlib.rst:183 msgid "" "−8 to −15: Uses the absolute value of *wbits* as the window size logarithm. " "The input must be a raw stream with no header or trailer." @@ -274,7 +310,7 @@ msgstr "" "−8 to −15:使用 *wbits* 的絕對值作為視窗大小的對數,輸入必須是沒有標頭或尾末" "的原始串流。" -#: ../../library/zlib.rst:158 +#: ../../library/zlib.rst:186 msgid "" "+24 to +31 = 16 + (8 to 15): Uses the low 4 bits of the value as the window " "size logarithm. The input must include a gzip header and trailer." @@ -282,7 +318,7 @@ msgstr "" "+24 到 +31 = 16 + (8 到 15):取值的最低4位元作為視窗大小的對數,輸入必須包" "含 gzip 標頭和尾末。" -#: ../../library/zlib.rst:162 +#: ../../library/zlib.rst:190 msgid "" "+40 to +47 = 32 + (8 to 15): Uses the low 4 bits of the value as the window " "size logarithm, and automatically accepts either the zlib or gzip format." @@ -290,7 +326,7 @@ msgstr "" "+40 到 +47 = 32 + (8 到 15):使用值的最低 4 位元作為視窗大小的對數,並自動" "接受 zlib 或 gzip 格式。" -#: ../../library/zlib.rst:166 +#: ../../library/zlib.rst:194 msgid "" "When decompressing a stream, the window size must not be smaller than the " "size originally used to compress the stream; using a too-small value may " @@ -302,7 +338,7 @@ msgstr "" "會導致 :exc:`error` 例外。預設的 *wbits* 值對應於最大的視窗大小,並且需要包" "含 zlib 標頭和尾末。" -#: ../../library/zlib.rst:172 +#: ../../library/zlib.rst:200 msgid "" "*bufsize* is the initial size of the buffer used to hold decompressed data. " "If more space is required, the buffer size will be increased as needed, so " @@ -313,17 +349,17 @@ msgstr "" "小將根據需求來增加,因此你不需要讓該值完全剛好;調整它只會節省幾次對 :c:func:" "`malloc` 的呼叫。" -#: ../../library/zlib.rst:177 +#: ../../library/zlib.rst:205 msgid "*wbits* and *bufsize* can be used as keyword arguments." msgstr "*wbits* 和 *bufsize* 可以用作關鍵字引數。" -#: ../../library/zlib.rst:182 +#: ../../library/zlib.rst:210 msgid "" "Returns a decompression object, to be used for decompressing data streams " "that won't fit into memory at once." msgstr "回傳一個解壓縮物件,用於解壓縮不能一次全部放入記憶體的資料串流。" -#: ../../library/zlib.rst:185 +#: ../../library/zlib.rst:213 msgid "" "The *wbits* parameter controls the size of the history buffer (or the " "\"window size\"), and what header and trailer format is expected. It has " @@ -332,7 +368,7 @@ msgstr "" "*wbits* 引數控制歷史紀錄緩衝區的大小(或「視窗大小」),以及期望的標頭和尾末" "格式。它與\\ `前面敘述的 decompress() <#decompress-wbits>`__ 具有相同的含義。" -#: ../../library/zlib.rst:189 +#: ../../library/zlib.rst:217 msgid "" "The *zdict* parameter specifies a predefined compression dictionary. If " "provided, this must be the same dictionary as was used by the compressor " @@ -341,7 +377,7 @@ msgstr "" "*zdict* 參數指定是先定義好的壓縮字典。如果有提供,這必須與生成要解壓縮資料的" "壓縮器所使用的字典相同。" -#: ../../library/zlib.rst:195 +#: ../../library/zlib.rst:223 msgid "" "If *zdict* is a mutable object (such as a :class:`bytearray`), you must not " "modify its contents between the call to :func:`decompressobj` and the first " @@ -351,15 +387,15 @@ msgstr "" "你不能在呼叫 :func:`decompressobj` 和第一次呼叫解壓縮器的 ``decompress()`` 方" "法之間修改它的內容。" -#: ../../library/zlib.rst:199 +#: ../../library/zlib.rst:227 msgid "Added the *zdict* parameter." msgstr "新增 *zdict* 參數。" -#: ../../library/zlib.rst:203 +#: ../../library/zlib.rst:231 msgid "Compression objects support the following methods:" msgstr "壓縮物件支援以下方法:" -#: ../../library/zlib.rst:208 +#: ../../library/zlib.rst:236 msgid "" "Compress *data*, returning a bytes object containing compressed data for at " "least part of the data in *data*. This data should be concatenated to the " @@ -370,7 +406,7 @@ msgstr "" "資料應串聯到任何先前呼叫 :meth:`compress` 方法所產生的輸出。一些輸入可能會保" "存在內部緩衝區中以供後續處理。" -#: ../../library/zlib.rst:216 +#: ../../library/zlib.rst:244 msgid "" "All pending input is processed, and a bytes object containing the remaining " "compressed output is returned. *mode* can be selected from the constants :" @@ -390,23 +426,23 @@ msgstr "" "縮更多資料。在 *mode* 設定為 :const:`Z_FINISH` 的情況下呼叫 :meth:`flush` " "後,無法再次呼叫 :meth:`compress` 方法;唯一可行的作法是刪除物件。" -#: ../../library/zlib.rst:229 +#: ../../library/zlib.rst:257 msgid "" "Returns a copy of the compression object. This can be used to efficiently " "compress a set of data that share a common initial prefix." msgstr "回傳壓縮物件的副本,這可用於有效壓縮一組共用初始前綴的資料。" -#: ../../library/zlib.rst:233 +#: ../../library/zlib.rst:261 msgid "" "Added :func:`copy.copy` and :func:`copy.deepcopy` support to compression " "objects." msgstr "於壓縮物件新增對 :func:`copy.copy` 和 :func:`copy.deepcopy` 的支援。" -#: ../../library/zlib.rst:238 +#: ../../library/zlib.rst:266 msgid "Decompression objects support the following methods and attributes:" msgstr "解壓縮物件支援以下方法和屬性:" -#: ../../library/zlib.rst:243 +#: ../../library/zlib.rst:271 msgid "" "A bytes object which contains any bytes past the end of the compressed data. " "That is, this remains ``b\"\"`` until the last byte that contains " @@ -417,7 +453,7 @@ msgstr "" "的最後一個位元組可用之前,它會一直保持為 ``b\"\"``。如果整個位元組字串 " "(bytestring) 有包含壓縮資料,這會是 ``b\"\"``,也就是一個空位元組物件。" -#: ../../library/zlib.rst:251 +#: ../../library/zlib.rst:279 msgid "" "A bytes object that contains any data that was not consumed by the last :" "meth:`decompress` call because it exceeded the limit for the uncompressed " @@ -430,19 +466,19 @@ msgstr "" "有和它串聯的其他資料)反饋給後續的 :meth:`decompress` 方法呼叫以獲得正確的輸" "出。" -#: ../../library/zlib.rst:260 +#: ../../library/zlib.rst:288 msgid "" "A boolean indicating whether the end of the compressed data stream has been " "reached." msgstr "一個布林值,代表是否已到達壓縮資料串流的尾末。" -#: ../../library/zlib.rst:263 +#: ../../library/zlib.rst:291 msgid "" "This makes it possible to distinguish between a properly formed compressed " "stream, and an incomplete or truncated one." msgstr "這使其能夠區分有正確建構的壓縮串流和不完整或被截斷的串流。" -#: ../../library/zlib.rst:271 +#: ../../library/zlib.rst:299 msgid "" "Decompress *data*, returning a bytes object containing the uncompressed data " "corresponding to at least part of the data in *string*. This data should be " @@ -454,7 +490,7 @@ msgstr "" "的未壓縮資料。此資料應串聯到任何先前呼叫 :meth:`decompress` 方法所產生的輸" "出。一些輸入資料可能會保存在內部緩衝區中以供後續處理。" -#: ../../library/zlib.rst:277 +#: ../../library/zlib.rst:305 msgid "" "If the optional parameter *max_length* is non-zero then the return value " "will be no longer than *max_length*. This may mean that not all of the " @@ -462,19 +498,30 @@ msgid "" "attribute :attr:`unconsumed_tail`. This bytestring must be passed to a " "subsequent call to :meth:`decompress` if decompression is to continue. If " "*max_length* is zero then the whole input is decompressed, and :attr:" -"`unconsumed_tail` is empty." +"`unconsumed_tail` is empty. For example, the full content could be read " +"like::" msgstr "" "如果可選參數 *max_length* 不是零,則回傳值長度將不超過 *max_length*。這代表著" -"並不是所有的已壓縮輸入都可以被處理;未使用的資料將被儲存在屬性 :attr:" -"`unconsumed_tail` 中。如果要繼續解壓縮,則必須將此位元組字串傳遞給後續對 :" -"meth:`decompress` 的呼叫。如果 *max_length* 為零,則整個輸入會被解壓縮,並" -"且 :attr:`unconsumed_tail` 為空。" +"並不是所有的已壓縮輸入都可以被處理;未使用的資料將被儲存在屬" +"性 :attr:`unconsumed_tail` 中。如果要繼續解壓縮,則必須將此位元組字串傳遞給後" +"續對 :meth:`decompress` 的呼叫。如果 *max_length* 為零,則整個輸入會被解壓" +"縮,並且 :attr:`unconsumed_tail` 為空。舉例來說,可以像這樣讀取完整內容: ::" -#: ../../library/zlib.rst:284 +#: ../../library/zlib.rst:313 +msgid "" +"process_output(d.decompress(data, max_length))\n" +"while chunk := d.decompress(d.unconsumed_tail, max_length):\n" +" process_output(chunk)" +msgstr "" +"process_output(d.decompress(data, max_length))\n" +"while chunk := d.decompress(d.unconsumed_tail, max_length):\n" +" process_output(chunk)" + +#: ../../library/zlib.rst:317 msgid "*max_length* can be used as a keyword argument." msgstr "*max_length* 可以用作關鍵字引數。" -#: ../../library/zlib.rst:290 +#: ../../library/zlib.rst:323 msgid "" "All pending input is processed, and a bytes object containing the remaining " "uncompressed output is returned. After calling :meth:`flush`, the :meth:" @@ -485,12 +532,12 @@ msgstr "" "`flush` 後,無法再次呼叫 :meth:`decompress` 方法;唯一可行的方法是刪除該物" "件。" -#: ../../library/zlib.rst:295 +#: ../../library/zlib.rst:328 msgid "" "The optional parameter *length* sets the initial size of the output buffer." msgstr "可選參數 *length* 設定了輸出緩衝區的初始大小。" -#: ../../library/zlib.rst:300 +#: ../../library/zlib.rst:333 msgid "" "Returns a copy of the decompression object. This can be used to save the " "state of the decompressor midway through the data stream in order to speed " @@ -499,135 +546,135 @@ msgstr "" "回傳解壓物件的副本,這可用於在資料串流中途保存解壓縮器的狀態,以便在未來某個" "時間點加速對串流的隨機搜尋 (random seek)。" -#: ../../library/zlib.rst:305 +#: ../../library/zlib.rst:338 msgid "" "Added :func:`copy.copy` and :func:`copy.deepcopy` support to decompression " "objects." msgstr "於解壓縮物件新增對 :func:`copy.copy` 和 :func:`copy.deepcopy` 支援。" -#: ../../library/zlib.rst:310 +#: ../../library/zlib.rst:343 msgid "" "The following constants are available to configure compression and " "decompression behavior:" msgstr "" -#: ../../library/zlib.rst:315 +#: ../../library/zlib.rst:348 msgid "The deflate compression method." msgstr "" -#: ../../library/zlib.rst:320 +#: ../../library/zlib.rst:353 msgid "" "The maximum window size, expressed as a power of 2. For example, if :const:`!" "MAX_WBITS` is ``15`` it results in a window size of ``32 KiB``." msgstr "" -#: ../../library/zlib.rst:327 +#: ../../library/zlib.rst:360 msgid "The default memory level for compression objects." msgstr "壓縮物件的預設記憶體層級。" -#: ../../library/zlib.rst:332 +#: ../../library/zlib.rst:365 msgid "The default buffer size for decompression operations." msgstr "解壓縮操作的預設緩衝區大小。" -#: ../../library/zlib.rst:337 +#: ../../library/zlib.rst:370 msgid "Compression level ``0``; no compression." msgstr "壓縮等級 ``0``;不壓縮。" -#: ../../library/zlib.rst:344 +#: ../../library/zlib.rst:377 msgid "Compression level ``1``; fastest and produces the least compression." msgstr "" -#: ../../library/zlib.rst:349 +#: ../../library/zlib.rst:382 msgid "Compression level ``9``; slowest and produces the most compression." msgstr "" -#: ../../library/zlib.rst:354 +#: ../../library/zlib.rst:387 msgid "" "Default compression level (``-1``); a compromise between speed and " "compression. Currently equivalent to compression level ``6``." msgstr "" -#: ../../library/zlib.rst:360 +#: ../../library/zlib.rst:393 msgid "Default compression strategy, for normal data." msgstr "" -#: ../../library/zlib.rst:365 +#: ../../library/zlib.rst:398 msgid "Compression strategy for data produced by a filter (or predictor)." msgstr "" -#: ../../library/zlib.rst:370 +#: ../../library/zlib.rst:403 msgid "Compression strategy that forces Huffman coding only." msgstr "" -#: ../../library/zlib.rst:375 +#: ../../library/zlib.rst:408 msgid "" "Compression strategy that limits match distances to one (run-length " "encoding)." msgstr "" -#: ../../library/zlib.rst:377 +#: ../../library/zlib.rst:410 msgid "" "This constant is only available if Python was compiled with zlib 1.2.0.1 or " "greater." msgstr "" -#: ../../library/zlib.rst:385 +#: ../../library/zlib.rst:418 msgid "Compression strategy that prevents the use of dynamic Huffman codes." msgstr "" -#: ../../library/zlib.rst:387 ../../library/zlib.rst:424 +#: ../../library/zlib.rst:420 ../../library/zlib.rst:457 msgid "" "This constant is only available if Python was compiled with zlib 1.2.2.2 or " "greater." msgstr "" -#: ../../library/zlib.rst:395 +#: ../../library/zlib.rst:428 msgid "Flush mode ``0``. No special flushing behavior." msgstr "" -#: ../../library/zlib.rst:402 +#: ../../library/zlib.rst:435 msgid "Flush mode ``1``. Flush as much output as possible." msgstr "" -#: ../../library/zlib.rst:407 +#: ../../library/zlib.rst:440 msgid "" "Flush mode ``2``. All output is flushed and the output is aligned to a byte " "boundary." msgstr "" -#: ../../library/zlib.rst:412 +#: ../../library/zlib.rst:445 msgid "" "Flush mode ``3``. All output is flushed and the compression state is reset." msgstr "" -#: ../../library/zlib.rst:417 +#: ../../library/zlib.rst:450 msgid "" "Flush mode ``4``. All pending input is processed, no more input is expected." msgstr "" -#: ../../library/zlib.rst:422 +#: ../../library/zlib.rst:455 msgid "Flush mode ``5``. A deflate block is completed and emitted." msgstr "" -#: ../../library/zlib.rst:432 +#: ../../library/zlib.rst:465 msgid "" "Flush mode ``6``, for inflate operations. Instructs inflate to return when " "it gets to the next deflate block boundary." msgstr "" -#: ../../library/zlib.rst:435 +#: ../../library/zlib.rst:468 msgid "" "This constant is only available if Python was compiled with zlib 1.2.3.4 or " "greater." msgstr "" -#: ../../library/zlib.rst:441 +#: ../../library/zlib.rst:474 msgid "" "Information about the version of the zlib library in use is available " "through the following constants:" msgstr "有關正在使用的 zlib 函式庫版本資訊可透過以下常數獲得:" -#: ../../library/zlib.rst:447 +#: ../../library/zlib.rst:480 msgid "" "The version string of the zlib library that was used for building the " "module. This may be different from the zlib library actually used at " @@ -636,12 +683,12 @@ msgstr "" "用於建置模組的 zlib 函式庫版本字串。這可能與實際在執行環境 (runtime) 使用的 " "zlib 函式庫不同,後者以 :const:`ZLIB_RUNTIME_VERSION` 提供。" -#: ../../library/zlib.rst:454 +#: ../../library/zlib.rst:487 msgid "" "The version string of the zlib library actually loaded by the interpreter." msgstr "直譯器實際載入的 zlib 函式庫版本字串。" -#: ../../library/zlib.rst:461 +#: ../../library/zlib.rst:494 msgid "" "The version string of the zlib-ng library that was used for building the " "module if zlib-ng was used. When present, the :data:`ZLIB_VERSION` and :data:" @@ -649,48 +696,48 @@ msgid "" "provided by zlib-ng." msgstr "" -#: ../../library/zlib.rst:466 +#: ../../library/zlib.rst:499 msgid "" "If zlib-ng was not used to build the module, this constant will be absent." msgstr "" -#: ../../library/zlib.rst:473 +#: ../../library/zlib.rst:506 msgid "Module :mod:`gzip`" msgstr ":mod:`gzip` 模組" -#: ../../library/zlib.rst:474 +#: ../../library/zlib.rst:507 msgid "Reading and writing :program:`gzip`\\ -format files." msgstr "讀寫 :program:`gzip` 格式的檔案。" -#: ../../library/zlib.rst:476 +#: ../../library/zlib.rst:509 msgid "https://www.zlib.net" msgstr "https://www.zlib.net" -#: ../../library/zlib.rst:477 +#: ../../library/zlib.rst:510 msgid "The zlib library home page." msgstr "zlib 函式庫首頁。" -#: ../../library/zlib.rst:479 +#: ../../library/zlib.rst:512 msgid "https://www.zlib.net/manual.html" msgstr "https://www.zlib.net/manual.html" -#: ../../library/zlib.rst:480 +#: ../../library/zlib.rst:513 msgid "" "The zlib manual explains the semantics and usage of the library's many " "functions." msgstr "zlib 手冊解釋了函式庫中許多函式的語義和用法。" -#: ../../library/zlib.rst:483 +#: ../../library/zlib.rst:516 msgid "" "In case gzip (de)compression is a bottleneck, the `python-isal`_ package " "speeds up (de)compression with a mostly compatible API." msgstr "" -#: ../../library/zlib.rst:118 +#: ../../library/zlib.rst:132 msgid "Cyclic Redundancy Check" msgstr "Cyclic Redundancy Check(循環冗餘核對)" -#: ../../library/zlib.rst:118 +#: ../../library/zlib.rst:132 msgid "checksum" msgstr "checksum(核對和)" diff --git a/library/zoneinfo.po b/library/zoneinfo.po index 9086ab74a38..1ac6a4599a7 100644 --- a/library/zoneinfo.po +++ b/library/zoneinfo.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-22 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2025-06-21 20:00+0800\n" "Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,11 +21,11 @@ msgstr "" msgid ":mod:`!zoneinfo` --- IANA time zone support" msgstr ":mod:`!zoneinfo` --- IANA 時區支援" -#: ../../library/zoneinfo.rst:12 +#: ../../library/zoneinfo.rst:9 msgid "**Source code:** :source:`Lib/zoneinfo`" msgstr "**原始碼:**\\ :source:`Lib/zoneinfo`" -#: ../../library/zoneinfo.rst:16 +#: ../../library/zoneinfo.rst:13 msgid "" "The :mod:`!zoneinfo` module provides a concrete time zone implementation to " "support the IANA time zone database as originally specified in :pep:`615`. " @@ -38,11 +38,11 @@ msgstr "" "料;如果沒有可用的系統時區資料,該函式庫將轉而使用 PyPI 上可用的第一方 :pypi:" "`tzdata` 套件。" -#: ../../library/zoneinfo.rst:24 +#: ../../library/zoneinfo.rst:21 msgid "Module: :mod:`datetime`" msgstr ":mod:`datetime` 模組" -#: ../../library/zoneinfo.rst:25 +#: ../../library/zoneinfo.rst:22 msgid "" "Provides the :class:`~datetime.time` and :class:`~datetime.datetime` types " "with which the :class:`ZoneInfo` class is designed to be used." @@ -50,11 +50,11 @@ msgstr "" "提供了 :class:`~datetime.time` 與 :class:`~datetime.datetime` 型別,這些型別" "是設計來與 :class:`ZoneInfo` 類別一起使用的。" -#: ../../library/zoneinfo.rst:28 +#: ../../library/zoneinfo.rst:25 msgid "Package :pypi:`tzdata`" msgstr ":pypi:`tzdata` 套件" -#: ../../library/zoneinfo.rst:29 +#: ../../library/zoneinfo.rst:26 msgid "" "First-party package maintained by the CPython core developers to supply time " "zone data via PyPI." @@ -72,11 +72,11 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/zoneinfo.rst:35 +#: ../../library/zoneinfo.rst:32 msgid "Using ``ZoneInfo``" msgstr "使用 ``ZoneInfo``" -#: ../../library/zoneinfo.rst:37 +#: ../../library/zoneinfo.rst:34 msgid "" ":class:`ZoneInfo` is a concrete implementation of the :class:`datetime." "tzinfo` abstract base class, and is intended to be attached to ``tzinfo``, " @@ -89,7 +89,7 @@ msgstr "" "meth:`datetime.astimezone ` 方法附加到 " "``tzinfo``: ::" -#: ../../library/zoneinfo.rst:42 +#: ../../library/zoneinfo.rst:39 msgid "" ">>> from zoneinfo import ZoneInfo\n" ">>> import datetime as dt\n" @@ -113,7 +113,7 @@ msgstr "" ">>> when.tzname()\n" "'PDT'" -#: ../../library/zoneinfo.rst:52 +#: ../../library/zoneinfo.rst:49 msgid "" "Datetimes constructed in this way are compatible with datetime arithmetic " "and handle daylight saving time transitions with no further intervention::" @@ -121,7 +121,7 @@ msgstr "" "以此方式建構的 Datetime 物件與 datetime 運算相容,並能處理日光節約時間轉換而" "無需進一步干預: ::" -#: ../../library/zoneinfo.rst:55 +#: ../../library/zoneinfo.rst:52 msgid "" ">>> when_add = when + dt.timedelta(days=1)\n" "\n" @@ -139,7 +139,7 @@ msgstr "" ">>> when_add.tzname()\n" "'PST'" -#: ../../library/zoneinfo.rst:63 +#: ../../library/zoneinfo.rst:60 msgid "" "These time zones also support the :attr:`~datetime.datetime.fold` attribute " "introduced in :pep:`495`. During offset transitions which induce ambiguous " @@ -152,7 +152,7 @@ msgstr "" "``fold=0`` 時,會使用轉換\\ *前*\\ 的時差,而當 ``fold=1`` 時,會使用轉換\\ *" "後*\\ 的時差,例如: ::" -#: ../../library/zoneinfo.rst:69 +#: ../../library/zoneinfo.rst:66 msgid "" ">>> when = dt.datetime(2020, 11, 1, 1, tzinfo=ZoneInfo(\"America/" "Los_Angeles\"))\n" @@ -170,13 +170,13 @@ msgstr "" ">>> print(when.replace(fold=1))\n" "2020-11-01 01:00:00-08:00" -#: ../../library/zoneinfo.rst:76 +#: ../../library/zoneinfo.rst:73 msgid "" "When converting from another time zone, the fold will be set to the correct " "value::" msgstr "當從另一個時區轉換時,fold 將被設定為正確的值: ::" -#: ../../library/zoneinfo.rst:79 +#: ../../library/zoneinfo.rst:76 msgid "" ">>> LOS_ANGELES = ZoneInfo(\"America/Los_Angeles\")\n" ">>> when_utc = dt.datetime(2020, 11, 1, 8, tzinfo=dt.timezone.utc)\n" @@ -200,11 +200,11 @@ msgstr "" ">>> print((when_utc + dt.timedelta(hours=1)).astimezone(LOS_ANGELES))\n" "2020-11-01 01:00:00-08:00" -#: ../../library/zoneinfo.rst:91 +#: ../../library/zoneinfo.rst:88 msgid "Data sources" msgstr "資料來源" -#: ../../library/zoneinfo.rst:93 +#: ../../library/zoneinfo.rst:90 msgid "" "The ``zoneinfo`` module does not directly provide time zone data, and " "instead pulls time zone information from the system time zone database or " @@ -221,11 +221,11 @@ msgstr "" "tzdata 的依賴。如果系統資料和 tzdata 都不可用,所有對 :class:`ZoneInfo` 的呼" "叫都將引發 :exc:`ZoneInfoNotFoundError` 例外。" -#: ../../library/zoneinfo.rst:105 +#: ../../library/zoneinfo.rst:102 msgid "Configuring the data sources" msgstr "設定資料來源" -#: ../../library/zoneinfo.rst:107 +#: ../../library/zoneinfo.rst:104 msgid "" "When ``ZoneInfo(key)`` is called, the constructor first searches the " "directories specified in :data:`TZPATH` for a file matching ``key``, and on " @@ -236,7 +236,7 @@ msgstr "" "符合 ``key`` 的檔案,如果失敗,則在 tzdata 套件中尋找符合的項目。此行為可以透" "過三種方式設定:" -#: ../../library/zoneinfo.rst:112 +#: ../../library/zoneinfo.rst:109 msgid "" "The default :data:`TZPATH` when not otherwise specified can be configured " "at :ref:`compile time `." @@ -244,7 +244,7 @@ msgstr "" "未另外指定時的預設 :data:`TZPATH` 可以在\\ :ref:`編譯時期 " "`\\ 設定。" -#: ../../library/zoneinfo.rst:114 +#: ../../library/zoneinfo.rst:111 msgid "" ":data:`TZPATH` can be configured using :ref:`an environment variable " "`." @@ -252,7 +252,7 @@ msgstr "" ":data:`TZPATH` 可以使用 :ref:`環境變數 ` 來設" "定。" -#: ../../library/zoneinfo.rst:116 +#: ../../library/zoneinfo.rst:113 msgid "" "At :ref:`runtime `, the search path can be " "manipulated using the :func:`reset_tzpath` function." @@ -260,11 +260,11 @@ msgstr "" "在 :ref:`runtime `,可以使用 :func:" "`reset_tzpath` 函式來操作搜尋路徑。" -#: ../../library/zoneinfo.rst:122 +#: ../../library/zoneinfo.rst:119 msgid "Compile-time configuration" msgstr "編譯時期設定" -#: ../../library/zoneinfo.rst:124 +#: ../../library/zoneinfo.rst:121 msgid "" "The default :data:`TZPATH` includes several common deployment locations for " "the time zone database (except on Windows, where there are no \"well-known\" " @@ -282,7 +282,7 @@ msgstr "" "with-tzpath>`)來變更預設時區路徑,它應該是一個由 :data:`os.pathsep` 分隔的字" "串。" -#: ../../library/zoneinfo.rst:133 +#: ../../library/zoneinfo.rst:130 msgid "" "On all platforms, the configured value is available as the ``TZPATH`` key " "in :func:`sysconfig.get_config_var`." @@ -290,11 +290,11 @@ msgstr "" "在所有平台上,設定的值可以透過 :func:`sysconfig.get_config_var` 中的 " "``TZPATH`` 鍵取得。" -#: ../../library/zoneinfo.rst:139 +#: ../../library/zoneinfo.rst:136 msgid "Environment configuration" msgstr "環境設定" -#: ../../library/zoneinfo.rst:141 +#: ../../library/zoneinfo.rst:138 msgid "" "When initializing :data:`TZPATH` (either at import time or whenever :func:" "`reset_tzpath` is called with no arguments), the ``zoneinfo`` module will " @@ -305,7 +305,7 @@ msgstr "" "`reset_tzpath` 時),如果環境變數 ``PYTHONTZPATH`` 存在,``zoneinfo`` 模組將" "使用它來設定搜尋路徑。" -#: ../../library/zoneinfo.rst:148 +#: ../../library/zoneinfo.rst:145 msgid "" "This is an :data:`os.pathsep`-separated string containing the time zone " "search path to use. It must consist of only absolute rather than relative " @@ -320,17 +320,17 @@ msgstr "" "使用,但除此之外,指定相對路徑時的行為是實作定義的;CPython 將引發 :exc:" "`InvalidTZPathWarning`,但其他實作可以自由地靜默忽略錯誤的元件或引發例外。" -#: ../../library/zoneinfo.rst:156 +#: ../../library/zoneinfo.rst:153 msgid "" "To set the system to ignore the system data and use the tzdata package " "instead, set ``PYTHONTZPATH=\"\"``." msgstr "要讓系統忽略系統資料並改用 tzdata 套件,請設定 ``PYTHONTZPATH=\"\"``。" -#: ../../library/zoneinfo.rst:162 +#: ../../library/zoneinfo.rst:159 msgid "Runtime configuration" msgstr "Runtime 設定" -#: ../../library/zoneinfo.rst:164 +#: ../../library/zoneinfo.rst:161 msgid "" "The TZ search path can also be configured at runtime using the :func:" "`reset_tzpath` function. This is generally not an advisable operation, " @@ -342,11 +342,11 @@ msgstr "" "是一個建議的操作,儘管在需要使用特定時區路徑(或需要停用對系統時區的存取)的" "測試函式中使用它是合理的。" -#: ../../library/zoneinfo.rst:171 +#: ../../library/zoneinfo.rst:168 msgid "The ``ZoneInfo`` class" msgstr "``ZoneInfo`` 類別" -#: ../../library/zoneinfo.rst:175 +#: ../../library/zoneinfo.rst:172 msgid "" "A concrete :class:`datetime.tzinfo` subclass that represents an IANA time " "zone specified by the string ``key``. Calls to the primary constructor will " @@ -359,7 +359,7 @@ msgstr "" "meth:`ZoneInfo.clear_cache` 使快取失效,否則對於所有 ``key`` 的值,以下斷言將" "永遠為真:" -#: ../../library/zoneinfo.rst:181 +#: ../../library/zoneinfo.rst:178 msgid "" "a = ZoneInfo(key)\n" "b = ZoneInfo(key)\n" @@ -369,7 +369,7 @@ msgstr "" "b = ZoneInfo(key)\n" "assert a is b" -#: ../../library/zoneinfo.rst:187 +#: ../../library/zoneinfo.rst:184 msgid "" "``key`` must be in the form of a relative, normalized POSIX path, with no up-" "level references. The constructor will raise :exc:`ValueError` if a non-" @@ -378,7 +378,7 @@ msgstr "" "``key`` 必須是相對、正規化的 POSIX 路徑形式,且不含上層參照。如果傳入不符合規" "範的鍵,建構函式將引發 :exc:`ValueError` 例外。" -#: ../../library/zoneinfo.rst:191 +#: ../../library/zoneinfo.rst:188 msgid "" "If no file matching ``key`` is found, the constructor will raise :exc:" "`ZoneInfoNotFoundError`." @@ -386,11 +386,11 @@ msgstr "" "如果找不到符合 ``key`` 的檔案,建構函式將引發 :exc:`ZoneInfoNotFoundError` 例" "外。" -#: ../../library/zoneinfo.rst:195 +#: ../../library/zoneinfo.rst:192 msgid "The ``ZoneInfo`` class has two alternate constructors:" msgstr "``ZoneInfo`` 類別有兩個備用建構函式:" -#: ../../library/zoneinfo.rst:199 +#: ../../library/zoneinfo.rst:196 msgid "" "Constructs a ``ZoneInfo`` object from a file-like object returning bytes (e." "g. a file opened in binary mode or an :class:`io.BytesIO` object). Unlike " @@ -400,7 +400,7 @@ msgstr "" "BytesIO` 物件)建構一個 ``ZoneInfo`` 物件。與主要建構函式不同,這個建構函式總" "是會建構一個新物件。" -#: ../../library/zoneinfo.rst:203 +#: ../../library/zoneinfo.rst:200 msgid "" "The ``key`` parameter sets the name of the zone for the purposes of :py:meth:" "`~object.__str__` and :py:meth:`~object.__repr__`." @@ -408,19 +408,19 @@ msgstr "" "``key`` 參數設定了時區的名稱,用於 :py:meth:`~object.__str__` 和 :py:meth:" "`~object.__repr__`。" -#: ../../library/zoneinfo.rst:206 +#: ../../library/zoneinfo.rst:203 msgid "" "Objects created via this constructor cannot be pickled (see `pickling`_)." msgstr "透過此建構函式建立的物件無法被封裝(參閱 `pickling`_)。" -#: ../../library/zoneinfo.rst:208 +#: ../../library/zoneinfo.rst:205 msgid "" ":exc:`ValueError` is raised if the data read from *file_obj* is not a valid " "TZif file." msgstr "" "如果從 *file_obj* 讀取的資料不是有效的 TZif 檔案,會引發 :exc:`ValueError`。" -#: ../../library/zoneinfo.rst:213 +#: ../../library/zoneinfo.rst:210 msgid "" "An alternate constructor that bypasses the constructor's cache. It is " "identical to the primary constructor, but returns a new object on each call. " @@ -432,13 +432,13 @@ msgstr "" "一個新物件。這對於測試或示範目的最可能有用,但它也可以用來建立一個具有不同快" "取失效策略的系統。" -#: ../../library/zoneinfo.rst:219 +#: ../../library/zoneinfo.rst:216 msgid "" "Objects created via this constructor will also bypass the cache of a " "deserializing process when unpickled." msgstr "透過此建構函式建立的物件,在拆封時也會繞過去序列化過程的快取。" -#: ../../library/zoneinfo.rst:226 +#: ../../library/zoneinfo.rst:223 msgid "" "Using this constructor may change the semantics of your datetimes in " "surprising ways, only use it if you know that you need to." @@ -446,11 +446,11 @@ msgstr "" "使用此建構函式可能會以意想不到的方式改變你的 datetime 物件的語意,只有在你確" "定需要時才使用它。" -#: ../../library/zoneinfo.rst:229 +#: ../../library/zoneinfo.rst:226 msgid "The following class methods are also available:" msgstr "以下類別方法也可用:" -#: ../../library/zoneinfo.rst:233 +#: ../../library/zoneinfo.rst:230 msgid "" "A method for invalidating the cache on the ``ZoneInfo`` class. If no " "arguments are passed, all caches are invalidated and the next call to the " @@ -459,7 +459,7 @@ msgstr "" "一個用於使 ``ZoneInfo`` 類別上的快取失效的方法。如果沒有傳入引數,所有快取都" "會失效,且下一次對每個鍵的主要建構函式呼叫都將回傳一個新的實例。" -#: ../../library/zoneinfo.rst:237 +#: ../../library/zoneinfo.rst:234 msgid "" "If an iterable of key names is passed to the ``only_keys`` parameter, only " "the specified keys will be removed from the cache. Keys passed to " @@ -468,7 +468,7 @@ msgstr "" "如果將一個包含鍵名的可疊代物件傳遞給 ``only_keys`` 參數,則只有指定的鍵會從快" "取中移除。傳遞給 ``only_keys`` 但在快取中找不到的鍵會被忽略。" -#: ../../library/zoneinfo.rst:245 +#: ../../library/zoneinfo.rst:242 msgid "" "Invoking this function may change the semantics of datetimes using " "``ZoneInfo`` in surprising ways; this modifies module state and thus may " @@ -477,11 +477,11 @@ msgstr "" "呼叫此函式可能會以意想不到的方式改變使用 ``ZoneInfo`` 的 datetime 物件的語" "意;這會修改模組狀態,因此可能產生廣泛的影響。只有在你確定需要時才使用它。" -#: ../../library/zoneinfo.rst:250 +#: ../../library/zoneinfo.rst:247 msgid "The class has one attribute:" msgstr "該類別有一個屬性:" -#: ../../library/zoneinfo.rst:254 +#: ../../library/zoneinfo.rst:251 msgid "" "This is a read-only :term:`attribute` that returns the value of ``key`` " "passed to the constructor, which should be a lookup key in the IANA time " @@ -492,13 +492,13 @@ msgstr "" "值應為 IANA 時區資料庫中的查詢鍵(例如 ``America/New_York``、``Europe/" "Paris`` 或 ``Asia/Tokyo``)。" -#: ../../library/zoneinfo.rst:259 +#: ../../library/zoneinfo.rst:256 msgid "" "For zones constructed from file without specifying a ``key`` parameter, this " "will be set to ``None``." msgstr "對於從檔案建構且未指定 ``key`` 參數的時區,此屬性將被設定為 ``None``。" -#: ../../library/zoneinfo.rst:264 +#: ../../library/zoneinfo.rst:261 msgid "" "Although it is a somewhat common practice to expose these to end users, " "these values are designed to be primary keys for representing the relevant " @@ -510,11 +510,11 @@ msgstr "" "區的主鍵,而不一定是面向使用者的元素。像 CLDR(Unicode 通用地區資料儲存庫)這" "樣的專案可以用來從這些鍵中取得更友善的使用者字串。" -#: ../../library/zoneinfo.rst:271 +#: ../../library/zoneinfo.rst:268 msgid "String representations" msgstr "字串表示" -#: ../../library/zoneinfo.rst:273 +#: ../../library/zoneinfo.rst:270 msgid "" "The string representation returned when calling :py:class:`str` on a :class:" "`ZoneInfo` object defaults to using the :attr:`ZoneInfo.key` attribute (see " @@ -523,7 +523,7 @@ msgstr "" "在 :class:`ZoneInfo` 物件上呼叫 :py:class:`str` 時回傳的字串表示,預設使用 :" "attr:`ZoneInfo.key` 屬性(參閱屬性文件中的使用說明): ::" -#: ../../library/zoneinfo.rst:277 +#: ../../library/zoneinfo.rst:274 msgid "" ">>> zone = ZoneInfo(\"Pacific/Kwajalein\")\n" ">>> str(zone)\n" @@ -541,7 +541,7 @@ msgstr "" ">>> f\"{when.isoformat()} [{when.tzinfo}]\"\n" "'2020-04-01T03:15:00+12:00 [Pacific/Kwajalein]'" -#: ../../library/zoneinfo.rst:285 +#: ../../library/zoneinfo.rst:282 msgid "" "For objects constructed from a file without specifying a ``key`` parameter, " "``str`` falls back to calling :func:`repr`. ``ZoneInfo``'s ``repr`` is " @@ -552,11 +552,11 @@ msgstr "" "``ZoneInfo`` 的 ``repr`` 是實作定義的,且不保證在不同版本之間保持穩定,但保證" "它不會是一個有效的 ``ZoneInfo`` 鍵。" -#: ../../library/zoneinfo.rst:293 +#: ../../library/zoneinfo.rst:290 msgid "Pickle serialization" msgstr "封裝(Pickle)序列化" -#: ../../library/zoneinfo.rst:295 +#: ../../library/zoneinfo.rst:292 msgid "" "Rather than serializing all transition data, ``ZoneInfo`` objects are " "serialized by key, and ``ZoneInfo`` objects constructed from files (even " @@ -565,11 +565,11 @@ msgstr "" "``ZoneInfo`` 物件不是序列化所有轉換資料,而是按鍵進行序列化,而從檔案建構的 " "``ZoneInfo`` 物件(即使是那些指定了 ``key`` 值的物件)也無法被封裝。" -#: ../../library/zoneinfo.rst:299 +#: ../../library/zoneinfo.rst:296 msgid "The behavior of a ``ZoneInfo`` file depends on how it was constructed:" msgstr "``ZoneInfo`` 檔案的行為取決於它的建構方式:" -#: ../../library/zoneinfo.rst:301 +#: ../../library/zoneinfo.rst:298 msgid "" "``ZoneInfo(key)``: When constructed with the primary constructor, a " "``ZoneInfo`` object is serialized by key, and when deserialized, the " @@ -583,7 +583,7 @@ msgstr "" "的其他參照是同一個物件。例如,如果 ``europe_berlin_pkl`` 是一個包含從 " "``ZoneInfo(\"Europe/Berlin\")`` 建構並封裝的字串,會預期以下行為:" -#: ../../library/zoneinfo.rst:309 +#: ../../library/zoneinfo.rst:306 msgid "" ">>> a = ZoneInfo(\"Europe/Berlin\")\n" ">>> b = pickle.loads(europe_berlin_pkl)\n" @@ -595,7 +595,7 @@ msgstr "" ">>> a is b\n" "True" -#: ../../library/zoneinfo.rst:316 +#: ../../library/zoneinfo.rst:313 msgid "" "``ZoneInfo.no_cache(key)``: When constructed from the cache-bypassing " "constructor, the ``ZoneInfo`` object is also serialized by key, but when " @@ -609,7 +609,7 @@ msgstr "" "``europe_berlin_pkl_nc`` 是一個包含從 ``ZoneInfo.no_cache(\"Europe/" "Berlin\")`` 建構並封裝的字串,會預期以下行為:" -#: ../../library/zoneinfo.rst:323 +#: ../../library/zoneinfo.rst:320 msgid "" ">>> a = ZoneInfo(\"Europe/Berlin\")\n" ">>> b = pickle.loads(europe_berlin_pkl_nc)\n" @@ -621,7 +621,7 @@ msgstr "" ">>> a is b\n" "False" -#: ../../library/zoneinfo.rst:330 +#: ../../library/zoneinfo.rst:327 msgid "" "``ZoneInfo.from_file(file_obj, /, key=None)``: When constructed from a file, " "the ``ZoneInfo`` object raises an exception on pickling. If an end user " @@ -635,7 +635,7 @@ msgstr "" "建議他們使用包裝器型別或自訂序列化函式:可以按鍵序列化,或儲存檔案物件的內容" "並將其序列化。" -#: ../../library/zoneinfo.rst:336 +#: ../../library/zoneinfo.rst:333 msgid "" "This method of serialization requires that the time zone data for the " "required key be available on both the serializing and deserializing side, " @@ -649,11 +649,11 @@ msgstr "" "函式的參照預期存在於序列化和去序列化環境中的方式相似。這也意味著,當在具有不" "同版本時區資料的環境中拆封一個封裝的 ``ZoneInfo`` 時,不保證結果的一致性。" -#: ../../library/zoneinfo.rst:344 +#: ../../library/zoneinfo.rst:341 msgid "Functions" msgstr "函式" -#: ../../library/zoneinfo.rst:348 +#: ../../library/zoneinfo.rst:345 msgid "" "Get a set containing all the valid keys for IANA time zones available " "anywhere on the time zone path. This is recalculated on every call to the " @@ -662,16 +662,16 @@ msgstr "" "取得一個集合,其中包含時區路徑上任何地方可用的所有 IANA 時區的有效鍵。這會在" "每次呼叫函式時重新計算。" -#: ../../library/zoneinfo.rst:352 +#: ../../library/zoneinfo.rst:349 msgid "" "This function only includes canonical zone names and does not include " "\"special\" zones such as those under the ``posix/`` and ``right/`` " -"directories, or the ``posixrules`` zone." +"directories, the ``posixrules`` or the ``localtime`` zone." msgstr "" "此函式僅包含規範的時區名稱,不包含「特殊」時區,例如 ``posix/`` 和 ``right/" -"`` 目錄下的時區,或 ``posixrules`` 時區。" +"`` 目錄下的時區、``posixrules`` 或 ``localtime`` 時區。" -#: ../../library/zoneinfo.rst:358 +#: ../../library/zoneinfo.rst:355 msgid "" "This function may open a large number of files, as the best way to determine " "if a file on the time zone path is a valid time zone is to read the \"magic " @@ -680,7 +680,7 @@ msgstr "" "此函式可能會開啟大量檔案,因為確定時區路徑上的檔案是否為有效時區的最佳方法是" "讀取開頭的「魔術字串」。" -#: ../../library/zoneinfo.rst:364 +#: ../../library/zoneinfo.rst:361 msgid "" "These values are not designed to be exposed to end-users; for user facing " "elements, applications should use something like CLDR (the Unicode Common " @@ -691,7 +691,7 @@ msgstr "" "(Unicode 通用地區資料儲存庫)這樣的工具來取得更友善的使用者字串。另請參閱關" "於 :attr:`ZoneInfo.key` 的警示說明。" -#: ../../library/zoneinfo.rst:371 +#: ../../library/zoneinfo.rst:368 msgid "" "Sets or resets the time zone search path (:data:`TZPATH`) for the module. " "When called with no arguments, :data:`TZPATH` is set to the default value." @@ -699,7 +699,7 @@ msgstr "" "為模組設定或重設時區搜尋路徑(:data:`TZPATH`)。當不帶引數呼叫時,:data:" "`TZPATH` 會被設定為預設值。" -#: ../../library/zoneinfo.rst:374 +#: ../../library/zoneinfo.rst:371 msgid "" "Calling ``reset_tzpath`` will not invalidate the :class:`ZoneInfo` cache, " "and so calls to the primary ``ZoneInfo`` constructor will only use the new " @@ -708,7 +708,7 @@ msgstr "" "呼叫 ``reset_tzpath`` 不會使 :class:`ZoneInfo` 快取失效,因此對主要 " "``ZoneInfo`` 建構函式的呼叫只會在快取未命中時才使用新的 ``TZPATH``。" -#: ../../library/zoneinfo.rst:378 +#: ../../library/zoneinfo.rst:375 msgid "" "The ``to`` parameter must be a :term:`sequence` of strings or :class:`os." "PathLike` and not a string, all of which must be absolute paths. :exc:" @@ -719,11 +719,11 @@ msgstr "" "`,而不是一個字串,其中所有元素都必須是絕對路徑。如果傳入的不是絕對" "路徑,將會引發 :exc:`ValueError` 例外。" -#: ../../library/zoneinfo.rst:384 +#: ../../library/zoneinfo.rst:381 msgid "Globals" msgstr "全域變數" -#: ../../library/zoneinfo.rst:388 +#: ../../library/zoneinfo.rst:385 msgid "" "A read-only sequence representing the time zone search path -- when " "constructing a ``ZoneInfo`` from a key, the key is joined to each entry in " @@ -732,13 +732,13 @@ msgstr "" "一個表示時區搜尋路徑的唯讀序列 —— 當從一個鍵建構 ``ZoneInfo`` 時,該鍵會與 " "``TZPATH`` 中的每個條目結合,並使用找到的第一個檔案。" -#: ../../library/zoneinfo.rst:392 +#: ../../library/zoneinfo.rst:389 msgid "" "``TZPATH`` may contain only absolute paths, never relative paths, regardless " "of how it is configured." msgstr "``TZPATH`` 只能包含絕對路徑,絕不能包含相對路徑,無論如何設定。" -#: ../../library/zoneinfo.rst:395 +#: ../../library/zoneinfo.rst:392 msgid "" "The object that ``zoneinfo.TZPATH`` points to may change in response to a " "call to :func:`reset_tzpath`, so it is recommended to use ``zoneinfo." @@ -749,18 +749,18 @@ msgstr "" "變,因此建議使用 ``zoneinfo.TZPATH``,而不是從 ``zoneinfo`` 引入 ``TZPATH`` " "或將一個長生命週期的變數賦值給 ``zoneinfo.TZPATH``。" -#: ../../library/zoneinfo.rst:400 +#: ../../library/zoneinfo.rst:397 msgid "" "For more information on configuring the time zone search path, see :ref:" "`zoneinfo_data_configuration`." msgstr "" "有關設定時區搜尋路徑的更多資訊,請參閱 :ref:`zoneinfo_data_configuration`。" -#: ../../library/zoneinfo.rst:404 +#: ../../library/zoneinfo.rst:401 msgid "Exceptions and warnings" msgstr "例外與警告" -#: ../../library/zoneinfo.rst:408 +#: ../../library/zoneinfo.rst:405 msgid "" "Raised when construction of a :class:`ZoneInfo` object fails because the " "specified key could not be found on the system. This is a subclass of :exc:" @@ -769,7 +769,7 @@ msgstr "" "當建構 :class:`ZoneInfo` 物件因在系統上找不到指定的鍵而失敗時引發。這是 :exc:" "`KeyError` 的一個子類別。" -#: ../../library/zoneinfo.rst:414 +#: ../../library/zoneinfo.rst:411 msgid "" "Raised when :envvar:`PYTHONTZPATH` contains an invalid component that will " "be filtered out, such as a relative path." diff --git a/license.po b/license.po index 02ff6b6b976..9e835ceea80 100644 --- a/license.po +++ b/license.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-26 00:33+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-06-27 09:40+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1929,16 +1929,17 @@ msgstr "expat" #: ../../license.rst:850 msgid "" "The :mod:`pyexpat ` extension is built using an included " -"copy of the expat sources unless the build is configured ``--with-system-" -"expat``::" +"copy of the expat sources unless the build is configured :option:`--with-" +"system-expat`:" msgstr "" -"除非在建置 :mod:`pyexpat ` 擴充時設定為 ``--with-system-" -"expat``,否則該擴充會用一個內含 expat 原始碼的副本來建置: ::" +"除非在建置 :mod:`pyexpat ` 擴充時設定了 :option:`--with-" +"system-expat`,否則該擴充會用一個內含 expat 原始碼的副本來建置:" #: ../../license.rst:853 msgid "" -"Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd\n" -" and Clark Cooper\n" +"Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark " +"Cooper\n" +"Copyright (c) 2001-2025 Expat maintainers\n" "\n" "Permission is hereby granted, free of charge, to any person obtaining\n" "a copy of this software and associated documentation files (the\n" @@ -1957,10 +1958,11 @@ msgid "" "IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n" "CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n" "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n" -"SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." +"SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" msgstr "" -"Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd\n" -" and Clark Cooper\n" +"Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark " +"Cooper\n" +"Copyright (c) 2001-2025 Expat maintainers\n" "\n" "Permission is hereby granted, free of charge, to any person obtaining\n" "a copy of this software and associated documentation files (the\n" @@ -1979,13 +1981,13 @@ msgstr "" "IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n" "CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n" "TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n" -"SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." +"SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" -#: ../../license.rst:877 +#: ../../license.rst:858 msgid "libffi" msgstr "libffi" -#: ../../license.rst:879 +#: ../../license.rst:860 msgid "" "The :mod:`!_ctypes` C extension underlying the :mod:`ctypes` module is built " "using an included copy of the libffi sources unless the build is configured " @@ -1994,7 +1996,7 @@ msgstr "" "除非在建置 :mod:`ctypes` 模組底下 :mod:`!_ctypes` 擴充程式時設定為 ``--with-" "system-libffi``,否則該擴充會用一個內含 libffi 原始碼的副本來建置: ::" -#: ../../license.rst:883 +#: ../../license.rst:864 msgid "" "Copyright (c) 1996-2008 Red Hat, Inc and others.\n" "\n" @@ -2040,11 +2042,11 @@ msgstr "" "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n" "DEALINGS IN THE SOFTWARE." -#: ../../license.rst:907 +#: ../../license.rst:888 msgid "zlib" msgstr "zlib" -#: ../../license.rst:909 +#: ../../license.rst:890 msgid "" "The :mod:`zlib` extension is built using an included copy of the zlib " "sources if the zlib version found on the system is too old to be used for " @@ -2053,7 +2055,7 @@ msgstr "" "如果在系統上找到的 zlib 版本太舊以致於無法用於建置 :mod:`zlib` 擴充,則該擴充" "會用一個內含 zlib 原始碼的副本來建置: ::" -#: ../../license.rst:913 +#: ../../license.rst:894 msgid "" "Copyright (C) 1995-2011 Jean-loup Gailly and Mark Adler\n" "\n" @@ -2101,11 +2103,11 @@ msgstr "" "Jean-loup Gailly Mark Adler\n" "jloup@gzip.org madler@alumni.caltech.edu" -#: ../../license.rst:938 +#: ../../license.rst:919 msgid "cfuhash" msgstr "cfuhash" -#: ../../license.rst:940 +#: ../../license.rst:921 msgid "" "The implementation of the hash table used by the :mod:`tracemalloc` is based " "on the cfuhash project::" @@ -2113,7 +2115,7 @@ msgstr "" ":mod:`tracemalloc` 使用的雜湊表 (hash table) 實作,是以 cfuhash 專案為基" "礎: ::" -#: ../../license.rst:943 +#: ../../license.rst:924 msgid "" "Copyright (c) 2005 Don Owens\n" "All rights reserved.\n" @@ -2183,11 +2185,11 @@ msgstr "" "ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n" "OF THE POSSIBILITY OF SUCH DAMAGE." -#: ../../license.rst:979 +#: ../../license.rst:960 msgid "libmpdec" msgstr "libmpdec" -#: ../../license.rst:981 +#: ../../license.rst:962 msgid "" "The :mod:`!_decimal` C extension underlying the :mod:`decimal` module is " "built using an included copy of the libmpdec library unless the build is " @@ -2197,7 +2199,7 @@ msgstr "" "with-system-libmpdec``,否則該模組會用一個內含 libmpdec 函式庫的副本來建" "置: ::" -#: ../../license.rst:985 +#: ../../license.rst:966 msgid "" "Copyright (c) 2008-2020 Stefan Krah. All rights reserved.\n" "\n" @@ -2249,11 +2251,11 @@ msgstr "" "OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n" "SUCH DAMAGE." -#: ../../license.rst:1012 +#: ../../license.rst:993 msgid "W3C C14N test suite" msgstr "W3C C14N 測試套件" -#: ../../license.rst:1014 +#: ../../license.rst:995 msgid "" "The C14N 2.0 test suite in the :mod:`test` package (``Lib/test/xmltestdata/" "c14n-20/``) was retrieved from the W3C website at https://www.w3.org/TR/xml-" @@ -2263,7 +2265,7 @@ msgstr "" "是從 W3C 網站 https://www.w3.org/TR/xml-c14n2-testcases/ 被檢索,且是基於 3-" "clause BSD 授權被發佈: ::" -#: ../../license.rst:1019 +#: ../../license.rst:1000 msgid "" "Copyright (c) 2013 W3C(R) (MIT, ERCIM, Keio, Beihang),\n" "All Rights Reserved.\n" @@ -2321,15 +2323,15 @@ msgstr "" "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -#: ../../license.rst:1051 +#: ../../license.rst:1032 msgid "mimalloc" msgstr "mimalloc" -#: ../../license.rst:1053 +#: ../../license.rst:1034 msgid "MIT License::" msgstr "MIT 授權: ::" -#: ../../license.rst:1055 +#: ../../license.rst:1036 msgid "" "Copyright (c) 2018-2021 Microsoft Corporation, Daan Leijen\n" "\n" @@ -2385,11 +2387,11 @@ msgstr "" "THE\n" "SOFTWARE." -#: ../../license.rst:1077 +#: ../../license.rst:1058 msgid "asyncio" msgstr "asyncio" -#: ../../license.rst:1079 +#: ../../license.rst:1060 msgid "" "Parts of the :mod:`asyncio` module are incorporated from `uvloop 0.16 " "`_, which is distributed " @@ -2398,7 +2400,7 @@ msgstr "" ":mod:`asyncio` 模組的部分內容是從 `uvloop 0.16 `_ 中收錄過來,其基於 MIT 授權來發佈: ::" -#: ../../license.rst:1083 +#: ../../license.rst:1064 msgid "" "Copyright (c) 2015-2021 MagicStack Inc. http://magic.io\n" "\n" @@ -2442,11 +2444,11 @@ msgstr "" "OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n" "WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." -#: ../../license.rst:1106 +#: ../../license.rst:1087 msgid "Global Unbounded Sequences (GUS)" msgstr "" -#: ../../license.rst:1108 +#: ../../license.rst:1089 msgid "" "The file :file:`Python/qsbr.c` is adapted from FreeBSD's \"Global Unbounded " "Sequences\" safe memory reclamation scheme in `subr_smr.c \n" "\n" @@ -2502,11 +2504,11 @@ msgstr "" "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n" "THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -#: ../../license.rst:1138 +#: ../../license.rst:1119 msgid "Zstandard bindings" msgstr "" -#: ../../license.rst:1140 +#: ../../license.rst:1121 msgid "" "Zstandard bindings in :file:`Modules/_zstd` and :file:`Lib/compression/zstd` " "are based on code from the `pyzstd library `__, converted to an internal format, is used by the :mod:`unicodedata` " @@ -2601,7 +2747,7 @@ msgid "" "unicode.org/license.txt>`__::" msgstr "" -#: ../../license.rst:1182 +#: ../../license.rst:1229 msgid "" "UNICODE LICENSE V3\n" "\n" @@ -2681,4 +2827,4 @@ msgstr "" "Except as contained in this notice, the name of a copyright holder shall\n" "not be used in advertising or otherwise to promote the sale, use or other\n" "dealings in these Data Files or Software without prior written\n" -"authorization of the copyright holder." \ No newline at end of file +"authorization of the copyright holder." diff --git a/reference/compound_stmts.po b/reference/compound_stmts.po index b385835014d..92d5f9cb615 100644 --- a/reference/compound_stmts.po +++ b/reference/compound_stmts.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -642,8 +642,8 @@ msgid "" msgstr "" #: ../../reference/compound_stmts.rst:539 -#: ../../reference/compound_stmts.rst:1560 -#: ../../reference/compound_stmts.rst:1601 +#: ../../reference/compound_stmts.rst:1677 +#: ../../reference/compound_stmts.rst:1718 msgid "The following code::" msgstr "以下程式碼: ::" @@ -657,7 +657,7 @@ msgstr "" #: ../../reference/compound_stmts.rst:544 #: ../../reference/compound_stmts.rst:572 -#: ../../reference/compound_stmts.rst:1606 +#: ../../reference/compound_stmts.rst:1723 msgid "is semantically equivalent to::" msgstr "在語義上等同於: ::" @@ -804,12 +804,12 @@ msgid "" msgstr "" #: ../../reference/compound_stmts.rst:642 -#: ../../reference/compound_stmts.rst:1199 +#: ../../reference/compound_stmts.rst:1200 msgid ":pep:`634` -- Structural Pattern Matching: Specification" msgstr "" #: ../../reference/compound_stmts.rst:643 -#: ../../reference/compound_stmts.rst:1200 +#: ../../reference/compound_stmts.rst:1201 msgid ":pep:`636` -- Structural Pattern Matching: Tutorial" msgstr "" @@ -1569,78 +1569,82 @@ msgid ":class:`float`" msgstr ":class:`float`" #: ../../reference/compound_stmts.rst:1175 +msgid ":class:`frozendict`" +msgstr ":class:`frozendict`" + +#: ../../reference/compound_stmts.rst:1176 msgid ":class:`frozenset`" msgstr ":class:`frozenset`" -#: ../../reference/compound_stmts.rst:1176 +#: ../../reference/compound_stmts.rst:1177 msgid ":class:`int`" msgstr ":class:`int`" -#: ../../reference/compound_stmts.rst:1177 -#: ../../reference/compound_stmts.rst:1936 +#: ../../reference/compound_stmts.rst:1178 +#: ../../reference/compound_stmts.rst:2053 msgid ":class:`list`" msgstr ":class:`list`" -#: ../../reference/compound_stmts.rst:1178 +#: ../../reference/compound_stmts.rst:1179 msgid ":class:`set`" msgstr ":class:`set`" -#: ../../reference/compound_stmts.rst:1179 +#: ../../reference/compound_stmts.rst:1180 msgid ":class:`str`" msgstr ":class:`str`" -#: ../../reference/compound_stmts.rst:1180 -#: ../../reference/compound_stmts.rst:1939 +#: ../../reference/compound_stmts.rst:1181 +#: ../../reference/compound_stmts.rst:2056 msgid ":class:`tuple`" msgstr ":class:`tuple`" -#: ../../reference/compound_stmts.rst:1182 +#: ../../reference/compound_stmts.rst:1183 msgid "" "These classes accept a single positional argument, and the pattern there is " "matched against the whole object rather than an attribute. For example " "``int(0|1)`` matches the value ``0``, but not the value ``0.0``." msgstr "" -#: ../../reference/compound_stmts.rst:1186 +#: ../../reference/compound_stmts.rst:1187 msgid "" "In simple terms ``CLS(P1, attr=P2)`` matches only if the following happens:" msgstr "" -#: ../../reference/compound_stmts.rst:1188 +#: ../../reference/compound_stmts.rst:1189 msgid "``isinstance(, CLS)``" msgstr "``isinstance(, CLS)``" -#: ../../reference/compound_stmts.rst:1189 +#: ../../reference/compound_stmts.rst:1190 msgid "convert ``P1`` to a keyword pattern using ``CLS.__match_args__``" msgstr "" -#: ../../reference/compound_stmts.rst:1190 +#: ../../reference/compound_stmts.rst:1191 msgid "For each keyword argument ``attr=P2``:" msgstr "" -#: ../../reference/compound_stmts.rst:1192 +#: ../../reference/compound_stmts.rst:1193 msgid "``hasattr(, \"attr\")``" msgstr "``hasattr(, \"attr\")``" -#: ../../reference/compound_stmts.rst:1193 +#: ../../reference/compound_stmts.rst:1194 msgid "``P2`` matches ``.attr``" msgstr "" -#: ../../reference/compound_stmts.rst:1195 +#: ../../reference/compound_stmts.rst:1196 msgid "... and so on for the corresponding keyword argument/pattern pair." msgstr "" -#: ../../reference/compound_stmts.rst:1210 +#: ../../reference/compound_stmts.rst:1211 msgid "Function definitions" msgstr "函式定義" -#: ../../reference/compound_stmts.rst:1225 +#: ../../reference/compound_stmts.rst:1226 msgid "" "A function definition defines a user-defined function object (see section :" "ref:`types`):" msgstr "" -#: ../../reference/compound_stmts.rst:1247 +#: ../../reference/compound_stmts.rst:1248 msgid "" "A function definition is an executable statement. Its execution binds the " "function name in the current local namespace to a function object (a wrapper " @@ -1649,13 +1653,13 @@ msgid "" "used when the function is called." msgstr "" -#: ../../reference/compound_stmts.rst:1253 +#: ../../reference/compound_stmts.rst:1254 msgid "" "The function definition does not execute the function body; this gets " "executed only when the function is called. [#]_" msgstr "" -#: ../../reference/compound_stmts.rst:1259 +#: ../../reference/compound_stmts.rst:1260 msgid "" "A function definition may be wrapped by one or more :term:`decorator` " "expressions. Decorator expressions are evaluated when the function is " @@ -1666,7 +1670,7 @@ msgid "" "example, the following code ::" msgstr "" -#: ../../reference/compound_stmts.rst:1266 +#: ../../reference/compound_stmts.rst:1267 msgid "" "@f1(arg)\n" "@f2\n" @@ -1676,12 +1680,12 @@ msgstr "" "@f2\n" "def func(): pass" -#: ../../reference/compound_stmts.rst:1270 -#: ../../reference/compound_stmts.rst:1459 +#: ../../reference/compound_stmts.rst:1271 +#: ../../reference/compound_stmts.rst:1463 msgid "is roughly equivalent to ::" msgstr "大致等價於: ::" -#: ../../reference/compound_stmts.rst:1272 +#: ../../reference/compound_stmts.rst:1273 msgid "" "def func(): pass\n" "func = f1(arg)(f2(func))" @@ -1689,20 +1693,20 @@ msgstr "" "def func(): pass\n" "func = f1(arg)(f2(func))" -#: ../../reference/compound_stmts.rst:1275 +#: ../../reference/compound_stmts.rst:1276 msgid "" "except that the original function is not temporarily bound to the name " "``func``." msgstr "" -#: ../../reference/compound_stmts.rst:1277 +#: ../../reference/compound_stmts.rst:1278 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." msgstr "" -#: ../../reference/compound_stmts.rst:1282 +#: ../../reference/compound_stmts.rst:1283 msgid "" "A list of :ref:`type parameters ` may be given in square " "brackets between the function's name and the opening parenthesis for its " @@ -1712,12 +1716,12 @@ msgid "" "functions` for more." msgstr "" -#: ../../reference/compound_stmts.rst:1289 -#: ../../reference/compound_stmts.rst:1478 +#: ../../reference/compound_stmts.rst:1290 +#: ../../reference/compound_stmts.rst:1482 msgid "Type parameter lists are new in Python 3.12." msgstr "" -#: ../../reference/compound_stmts.rst:1297 +#: ../../reference/compound_stmts.rst:1298 msgid "" "When one or more :term:`parameters ` have the form *parameter* " "``=`` *expression*, the function is said to have \"default parameter values." @@ -1728,7 +1732,7 @@ msgid "" "syntactic restriction that is not expressed by the grammar." msgstr "" -#: ../../reference/compound_stmts.rst:1305 +#: ../../reference/compound_stmts.rst:1306 msgid "" "**Default parameter values are evaluated from left to right when the " "function definition is executed.** This means that the expression is " @@ -1742,7 +1746,7 @@ msgid "" "example::" msgstr "" -#: ../../reference/compound_stmts.rst:1315 +#: ../../reference/compound_stmts.rst:1316 msgid "" "def whats_on_the_telly(penguin=None):\n" " if penguin is None:\n" @@ -1756,7 +1760,7 @@ msgstr "" " penguin.append(\"property of the zoo\")\n" " return penguin" -#: ../../reference/compound_stmts.rst:1326 +#: ../../reference/compound_stmts.rst:1327 msgid "" "Function call semantics are described in more detail in section :ref:" "`calls`. A function call always assigns values to all parameters mentioned " @@ -1772,13 +1776,13 @@ msgid "" "positional arguments." msgstr "" -#: ../../reference/compound_stmts.rst:1338 +#: ../../reference/compound_stmts.rst:1339 msgid "" "The ``/`` function parameter syntax may be used to indicate positional-only " "parameters. See :pep:`570` for details." msgstr "" -#: ../../reference/compound_stmts.rst:1347 +#: ../../reference/compound_stmts.rst:1348 msgid "" "Parameters may have an :term:`annotation ` of the form " "\"``: expression``\" following the parameter name. Any parameter may have " @@ -1791,13 +1795,13 @@ msgid "" "information on annotations." msgstr "" -#: ../../reference/compound_stmts.rst:1355 +#: ../../reference/compound_stmts.rst:1356 msgid "" "Parameters of the form \"``*identifier``\" may have an annotation \"``: " "*expression``\". See :pep:`646`." msgstr "" -#: ../../reference/compound_stmts.rst:1361 +#: ../../reference/compound_stmts.rst:1362 msgid "" "It is also possible to create anonymous functions (functions not bound to a " "name), for immediate use in expressions. This uses lambda expressions, " @@ -1809,7 +1813,7 @@ msgid "" "execution of multiple statements and annotations." msgstr "" -#: ../../reference/compound_stmts.rst:1369 +#: ../../reference/compound_stmts.rst:1370 msgid "" "**Programmer's note:** Functions are first-class objects. A \"``def``\" " "statement executed inside a function definition defines a local function " @@ -1818,61 +1822,61 @@ msgid "" "See section :ref:`naming` for details." msgstr "" -#: ../../reference/compound_stmts.rst:1377 +#: ../../reference/compound_stmts.rst:1378 msgid ":pep:`3107` - Function Annotations" msgstr "" -#: ../../reference/compound_stmts.rst:1378 +#: ../../reference/compound_stmts.rst:1379 msgid "The original specification for function annotations." msgstr "" -#: ../../reference/compound_stmts.rst:1380 +#: ../../reference/compound_stmts.rst:1381 msgid ":pep:`484` - Type Hints" msgstr ":pep:`484` - 型別提示" -#: ../../reference/compound_stmts.rst:1381 +#: ../../reference/compound_stmts.rst:1382 msgid "Definition of a standard meaning for annotations: type hints." msgstr "定義註釋的標準意義:型別提示。" -#: ../../reference/compound_stmts.rst:1383 +#: ../../reference/compound_stmts.rst:1384 msgid ":pep:`526` - Syntax for Variable Annotations" msgstr ":pep:`526` - 變數註釋的語法" -#: ../../reference/compound_stmts.rst:1384 +#: ../../reference/compound_stmts.rst:1385 msgid "" "Ability to type hint variable declarations, including class variables and " "instance variables." msgstr "" -#: ../../reference/compound_stmts.rst:1387 +#: ../../reference/compound_stmts.rst:1388 msgid ":pep:`563` - Postponed Evaluation of Annotations" msgstr "" -#: ../../reference/compound_stmts.rst:1388 +#: ../../reference/compound_stmts.rst:1389 msgid "" "Support for forward references within annotations by preserving annotations " "in a string form at runtime instead of eager evaluation." msgstr "" -#: ../../reference/compound_stmts.rst:1391 +#: ../../reference/compound_stmts.rst:1392 msgid ":pep:`318` - Decorators for Functions and Methods" msgstr "" -#: ../../reference/compound_stmts.rst:1392 +#: ../../reference/compound_stmts.rst:1393 msgid "" "Function and method decorators were introduced. Class decorators were " "introduced in :pep:`3129`." msgstr "" -#: ../../reference/compound_stmts.rst:1398 +#: ../../reference/compound_stmts.rst:1399 msgid "Class definitions" msgstr "類別定義" -#: ../../reference/compound_stmts.rst:1413 +#: ../../reference/compound_stmts.rst:1414 msgid "A class definition defines a class object (see section :ref:`types`):" msgstr "" -#: ../../reference/compound_stmts.rst:1420 +#: ../../reference/compound_stmts.rst:1421 msgid "" "A class definition is an executable statement. The inheritance list usually " "gives a list of base classes (see :ref:`metaclasses` for more advanced " @@ -1881,7 +1885,7 @@ msgid "" "default, from the base class :class:`object`; hence, ::" msgstr "" -#: ../../reference/compound_stmts.rst:1426 +#: ../../reference/compound_stmts.rst:1427 msgid "" "class Foo:\n" " pass" @@ -1889,11 +1893,11 @@ msgstr "" "class Foo:\n" " pass" -#: ../../reference/compound_stmts.rst:1429 +#: ../../reference/compound_stmts.rst:1430 msgid "is equivalent to ::" msgstr "" -#: ../../reference/compound_stmts.rst:1431 +#: ../../reference/compound_stmts.rst:1432 msgid "" "class Foo(object):\n" " pass" @@ -1901,7 +1905,13 @@ msgstr "" "class Foo(object):\n" " pass" -#: ../../reference/compound_stmts.rst:1434 +#: ../../reference/compound_stmts.rst:1435 +msgid "" +"There may be one or more base classes; see :ref:`multiple-inheritance` below " +"for more information." +msgstr "" + +#: ../../reference/compound_stmts.rst:1438 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 " @@ -1913,7 +1923,7 @@ msgid "" "original local namespace." msgstr "" -#: ../../reference/compound_stmts.rst:1443 +#: ../../reference/compound_stmts.rst:1447 msgid "" "The order in which attributes are defined in the class body is preserved in " "the new class's :attr:`~type.__dict__`. Note that this is reliable only " @@ -1921,17 +1931,17 @@ msgid "" "using the definition syntax." msgstr "" -#: ../../reference/compound_stmts.rst:1448 +#: ../../reference/compound_stmts.rst:1452 msgid "" "Class creation can be customized heavily using :ref:`metaclasses " "`." msgstr "" -#: ../../reference/compound_stmts.rst:1453 +#: ../../reference/compound_stmts.rst:1457 msgid "Classes can also be decorated: just like when decorating functions, ::" msgstr "" -#: ../../reference/compound_stmts.rst:1455 +#: ../../reference/compound_stmts.rst:1459 msgid "" "@f1(arg)\n" "@f2\n" @@ -1941,7 +1951,7 @@ msgstr "" "@f2\n" "class Foo: pass" -#: ../../reference/compound_stmts.rst:1461 +#: ../../reference/compound_stmts.rst:1465 msgid "" "class Foo: pass\n" "Foo = f1(arg)(f2(Foo))" @@ -1949,20 +1959,20 @@ msgstr "" "class Foo: pass\n" "Foo = f1(arg)(f2(Foo))" -#: ../../reference/compound_stmts.rst:1464 +#: ../../reference/compound_stmts.rst:1468 msgid "" "The evaluation rules for the decorator expressions are the same as for " "function decorators. The result is then bound to the class name." msgstr "" -#: ../../reference/compound_stmts.rst:1467 +#: ../../reference/compound_stmts.rst:1471 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." msgstr "" -#: ../../reference/compound_stmts.rst:1472 +#: ../../reference/compound_stmts.rst:1476 msgid "" "A list of :ref:`type parameters ` may be given in square " "brackets immediately after the class's name. This indicates to static type " @@ -1971,7 +1981,7 @@ msgid "" "`generic-classes` for more." msgstr "" -#: ../../reference/compound_stmts.rst:1481 +#: ../../reference/compound_stmts.rst:1485 msgid "" "**Programmer's note:** Variables defined in the class definition are class " "attributes; they are shared by instances. Instance attributes can be set in " @@ -1984,35 +1994,236 @@ msgid "" "implementation details." msgstr "" -#: ../../reference/compound_stmts.rst:1493 +#: ../../reference/compound_stmts.rst:1497 msgid ":pep:`3115` - Metaclasses in Python 3000" msgstr "" -#: ../../reference/compound_stmts.rst:1494 +#: ../../reference/compound_stmts.rst:1498 msgid "" "The proposal that changed the declaration of metaclasses to the current " "syntax, and the semantics for how classes with metaclasses are constructed." msgstr "" -#: ../../reference/compound_stmts.rst:1498 +#: ../../reference/compound_stmts.rst:1502 msgid ":pep:`3129` - Class Decorators" msgstr ":pep:`3129` - 類別裝飾器" -#: ../../reference/compound_stmts.rst:1499 +#: ../../reference/compound_stmts.rst:1503 msgid "" "The proposal that added class decorators. Function and method decorators " "were introduced in :pep:`318`." msgstr "" -#: ../../reference/compound_stmts.rst:1506 +#: ../../reference/compound_stmts.rst:1510 +msgid "Multiple inheritance" +msgstr "多重繼承" + +#: ../../reference/compound_stmts.rst:1512 +msgid "" +"Python classes may have multiple base classes, a technique known as " +"*multiple inheritance*. The base classes are specified in the class " +"definition by listing them in parentheses after the class name, separated by " +"commas. For example, the following class definition:" +msgstr "" + +#: ../../reference/compound_stmts.rst:1517 +msgid "" +">>> class A: pass\n" +">>> class B: pass\n" +">>> class C(A, B): pass" +msgstr "" +">>> class A: pass\n" +">>> class B: pass\n" +">>> class C(A, B): pass" + +#: ../../reference/compound_stmts.rst:1523 +msgid "defines a class ``C`` that inherits from classes ``A`` and ``B``." +msgstr "" + +#: ../../reference/compound_stmts.rst:1525 +msgid "" +"The :term:`method resolution order` (MRO) is the order in which base classes " +"are searched when looking up an attribute on a class. See :ref:" +"`python_2.3_mro` for a description of how Python determines the MRO for a " +"class." +msgstr "" + +#: ../../reference/compound_stmts.rst:1529 +msgid "" +"Multiple inheritance is not always allowed. Attempting to define a class " +"with multiple inheritance will raise an error if one of the bases does not " +"allow subclassing, if a consistent MRO cannot be created, if no valid " +"metaclass can be determined, or if there is an instance layout conflict. " +"We'll discuss each of these in turn." +msgstr "" + +#: ../../reference/compound_stmts.rst:1534 +msgid "" +"First, all base classes must allow subclassing. While most classes allow " +"subclassing, some built-in classes do not, such as :class:`bool`:" +msgstr "" + +#: ../../reference/compound_stmts.rst:1537 +msgid "" +">>> class SubBool(bool): # TypeError\n" +"... pass\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: type 'bool' is not an acceptable base type" +msgstr "" +">>> class SubBool(bool): # TypeError\n" +"... pass\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: type 'bool' is not an acceptable base type" + +#: ../../reference/compound_stmts.rst:1545 +msgid "" +"In the resolved MRO of a class, the class's bases appear in the order they " +"were specified in the class's bases list. Additionally, the MRO always lists " +"a child class before any of its bases. A class definition will fail if it is " +"impossible to resolve a consistent MRO that satisfies these rules from the " +"list of bases provided:" +msgstr "" + +#: ../../reference/compound_stmts.rst:1550 +msgid "" +">>> class Base: pass\n" +">>> class Child(Base): pass\n" +">>> class Grandchild(Base, Child): pass # TypeError\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: Cannot create a consistent method resolution order (MRO) for " +"bases Base, Child" +msgstr "" +">>> class Base: pass\n" +">>> class Child(Base): pass\n" +">>> class Grandchild(Base, Child): pass # TypeError\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: Cannot create a consistent method resolution order (MRO) for " +"bases Base, Child" + +#: ../../reference/compound_stmts.rst:1559 +msgid "" +"In the MRO of ``Grandchild``, ``Base`` must appear before ``Child`` because " +"it is first in the base class list, but it must also appear after ``Child`` " +"because it is a parent of ``Child``. This is a contradiction, so the class " +"cannot be defined." +msgstr "" + +#: ../../reference/compound_stmts.rst:1563 +msgid "" +"If some of the bases have a custom :term:`metaclass`, the metaclass of the " +"resulting class is chosen among the metaclasses of the bases and the " +"explicitly specified metaclass of the child class. It must be a metaclass " +"that is a subclass of all other candidate metaclasses. If no such metaclass " +"exists among the candidates, the class cannot be created, as explained in :" +"ref:`metaclass-determination`." +msgstr "" + +#: ../../reference/compound_stmts.rst:1569 +msgid "" +"Finally, the instance layouts of the bases must be compatible. This means " +"that it must be possible to compute a *solid base* for the class. Exactly " +"which classes are solid bases depends on the Python implementation." +msgstr "" + +#: ../../reference/compound_stmts.rst:1575 +msgid "" +"In CPython, a class is a solid base if it has a nonempty :attr:`~object." +"__slots__` definition. Many but not all classes defined in C are also solid " +"bases, including most builtins (such as :class:`int` or :class:" +"`BaseException`) but excluding most concrete :class:`Exception` classes. " +"Generally, a C class is a solid base if its underlying struct is different " +"in size from its base class." +msgstr "" + +#: ../../reference/compound_stmts.rst:1582 +msgid "" +"Every class has a solid base. :class:`object`, the base class, has itself as " +"its solid base. If there is a single base, the child class's solid base is " +"that class if it is a solid base, or else the base class's solid base. If " +"there are multiple bases, we first find the solid base for each base class " +"to produce a list of candidate solid bases. If there is a unique solid base " +"that is a subclass of all others, then that class is the solid base. " +"Otherwise, class creation fails." +msgstr "" + +#: ../../reference/compound_stmts.rst:1589 +msgid "Example:" +msgstr "" + +#: ../../reference/compound_stmts.rst:1591 +msgid "" +">>> class Solid1:\n" +"... __slots__ = (\"solid1\",)\n" +">>>\n" +">>> class Solid2:\n" +"... __slots__ = (\"solid2\",)\n" +">>>\n" +">>> class SolidChild(Solid1):\n" +"... __slots__ = (\"solid_child\",)\n" +">>>\n" +">>> class C1: # solid base is `object`\n" +"... pass\n" +">>>\n" +">>> # OK: solid bases are `Solid1` and `object`, and `Solid1` is a subclass " +"of `object`.\n" +">>> class C2(Solid1, C1): # solid base is `Solid1`\n" +"... pass\n" +">>>\n" +">>> # OK: solid bases are `SolidChild` and `Solid1`, and `SolidChild` is a " +"subclass of `Solid1`.\n" +">>> class C3(SolidChild, Solid1): # solid base is `SolidChild`\n" +"... pass\n" +">>>\n" +">>> # Error: solid bases are `Solid1` and `Solid2`, but neither is a " +"subclass of the other.\n" +">>> class C4(Solid1, Solid2): # error: no single solid base\n" +"... pass\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: multiple bases have instance lay-out conflict" +msgstr "" +">>> class Solid1:\n" +"... __slots__ = (\"solid1\",)\n" +">>>\n" +">>> class Solid2:\n" +"... __slots__ = (\"solid2\",)\n" +">>>\n" +">>> class SolidChild(Solid1):\n" +"... __slots__ = (\"solid_child\",)\n" +">>>\n" +">>> class C1: # solid base 為 `object`\n" +"... pass\n" +">>>\n" +">>> # 正確:solid base 為 `Solid1` 和 `object`,且 `Solid1` 是 `object` 的子" +"類別。\n" +">>> class C2(Solid1, C1): # solid base 為 `Solid1`\n" +"... pass\n" +">>>\n" +">>> # 正確:solid base 為 `SolidChild` 和 `Solid1`,且 `SolidChild` 是 " +"`Solid1` 的子類別。\n" +">>> class C3(SolidChild, Solid1): # solid base 為 `SolidChild`\n" +"... pass\n" +">>>\n" +">>> # 錯誤:solid base 為 `Solid1` 和 `Solid2`,但兩者都不是對方的子類別。\n" +">>> class C4(Solid1, Solid2): # 錯誤:沒有單一的 solid base\n" +"... pass\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: multiple bases have instance lay-out conflict" + +#: ../../reference/compound_stmts.rst:1623 msgid "Coroutines" msgstr "協程" -#: ../../reference/compound_stmts.rst:1514 +#: ../../reference/compound_stmts.rst:1631 msgid "Coroutine function definition" msgstr "協程函式定義" -#: ../../reference/compound_stmts.rst:1524 +#: ../../reference/compound_stmts.rst:1641 msgid "" "Execution of Python coroutines can be suspended and resumed at many points " "(see :term:`coroutine`). :keyword:`await` expressions, :keyword:`async for` " @@ -2020,23 +2231,23 @@ msgid "" "function." msgstr "" -#: ../../reference/compound_stmts.rst:1528 +#: ../../reference/compound_stmts.rst:1645 msgid "" "Functions defined with ``async def`` syntax are always coroutine functions, " "even if they do not contain ``await`` or ``async`` keywords." msgstr "" -#: ../../reference/compound_stmts.rst:1531 +#: ../../reference/compound_stmts.rst:1648 msgid "" "It is a :exc:`SyntaxError` to use a ``yield from`` expression inside the " "body of a coroutine function." msgstr "" -#: ../../reference/compound_stmts.rst:1534 +#: ../../reference/compound_stmts.rst:1651 msgid "An example of a coroutine function::" msgstr "一個協程函式範例: ::" -#: ../../reference/compound_stmts.rst:1536 +#: ../../reference/compound_stmts.rst:1653 msgid "" "async def func(param1, param2):\n" " do_stuff()\n" @@ -2046,30 +2257,30 @@ msgstr "" " do_stuff()\n" " await some_coroutine()" -#: ../../reference/compound_stmts.rst:1540 +#: ../../reference/compound_stmts.rst:1657 msgid "" "``await`` and ``async`` are now keywords; previously they were only treated " "as such inside the body of a coroutine function." msgstr "" -#: ../../reference/compound_stmts.rst:1548 +#: ../../reference/compound_stmts.rst:1665 msgid "The :keyword:`!async for` statement" msgstr ":keyword:`!async for` 陳述式" -#: ../../reference/compound_stmts.rst:1553 +#: ../../reference/compound_stmts.rst:1670 msgid "" "An :term:`asynchronous iterable` provides an ``__aiter__`` method that " "directly returns an :term:`asynchronous iterator`, which can call " "asynchronous code in its ``__anext__`` method." msgstr "" -#: ../../reference/compound_stmts.rst:1557 +#: ../../reference/compound_stmts.rst:1674 msgid "" "The ``async for`` statement allows convenient iteration over asynchronous " "iterables." msgstr "" -#: ../../reference/compound_stmts.rst:1562 +#: ../../reference/compound_stmts.rst:1679 msgid "" "async for TARGET in ITER:\n" " SUITE\n" @@ -2081,11 +2292,11 @@ msgstr "" "else:\n" " SUITE2" -#: ../../reference/compound_stmts.rst:1567 +#: ../../reference/compound_stmts.rst:1684 msgid "Is semantically equivalent to::" msgstr "" -#: ../../reference/compound_stmts.rst:1569 +#: ../../reference/compound_stmts.rst:1686 msgid "" "iter = (ITER).__aiter__()\n" "running = True\n" @@ -2113,29 +2324,29 @@ msgstr "" "else:\n" " SUITE2" -#: ../../reference/compound_stmts.rst:1582 +#: ../../reference/compound_stmts.rst:1699 msgid "" "except that implicit :ref:`special method lookup ` is used " "for :meth:`~object.__aiter__` and :meth:`~object.__anext__`." msgstr "" -#: ../../reference/compound_stmts.rst:1585 +#: ../../reference/compound_stmts.rst:1702 msgid "" "It is a :exc:`SyntaxError` to use an ``async for`` statement outside the " "body of a coroutine function." msgstr "" -#: ../../reference/compound_stmts.rst:1593 +#: ../../reference/compound_stmts.rst:1710 msgid "The :keyword:`!async with` statement" msgstr ":keyword:`!async with` 陳述式" -#: ../../reference/compound_stmts.rst:1598 +#: ../../reference/compound_stmts.rst:1715 msgid "" "An :term:`asynchronous context manager` is a :term:`context manager` that is " "able to suspend execution in its *enter* and *exit* methods." msgstr "" -#: ../../reference/compound_stmts.rst:1603 +#: ../../reference/compound_stmts.rst:1720 msgid "" "async with EXPRESSION as TARGET:\n" " SUITE" @@ -2143,7 +2354,7 @@ msgstr "" "async with EXPRESSION as TARGET:\n" " SUITE" -#: ../../reference/compound_stmts.rst:1608 +#: ../../reference/compound_stmts.rst:1725 msgid "" "manager = (EXPRESSION)\n" "aenter = manager.__aenter__\n" @@ -2179,44 +2390,44 @@ msgstr "" " if not hit_except:\n" " await aexit(None, None, None)" -#: ../../reference/compound_stmts.rst:1625 +#: ../../reference/compound_stmts.rst:1742 msgid "" "except that implicit :ref:`special method lookup ` is used " "for :meth:`~object.__aenter__` and :meth:`~object.__aexit__`." msgstr "" -#: ../../reference/compound_stmts.rst:1628 +#: ../../reference/compound_stmts.rst:1745 msgid "" "It is a :exc:`SyntaxError` to use an ``async with`` statement outside the " "body of a coroutine function." msgstr "" -#: ../../reference/compound_stmts.rst:1633 +#: ../../reference/compound_stmts.rst:1750 msgid ":pep:`492` - Coroutines with async and await syntax" msgstr "" -#: ../../reference/compound_stmts.rst:1634 +#: ../../reference/compound_stmts.rst:1751 msgid "" "The proposal that made coroutines a proper standalone concept in Python, and " "added supporting syntax." msgstr "" -#: ../../reference/compound_stmts.rst:1640 +#: ../../reference/compound_stmts.rst:1757 msgid "Type parameter lists" msgstr "" -#: ../../reference/compound_stmts.rst:1644 +#: ../../reference/compound_stmts.rst:1761 msgid "Support for default values was added (see :pep:`696`)." msgstr "" -#: ../../reference/compound_stmts.rst:1657 +#: ../../reference/compound_stmts.rst:1774 msgid "" ":ref:`Functions ` (including :ref:`coroutines `), :ref:" "`classes ` and :ref:`type aliases ` may contain a type " "parameter list::" msgstr "" -#: ../../reference/compound_stmts.rst:1661 +#: ../../reference/compound_stmts.rst:1778 msgid "" "def max[T](args: list[T]) -> T:\n" " ...\n" @@ -2248,7 +2459,7 @@ msgstr "" "\n" "type ListOrSet[T] = list[T] | set[T]" -#: ../../reference/compound_stmts.rst:1676 +#: ../../reference/compound_stmts.rst:1793 msgid "" "Semantically, this indicates that the function, class, or type alias is " "generic over a type variable. This information is primarily used by static " @@ -2256,7 +2467,7 @@ msgid "" "generic counterparts." msgstr "" -#: ../../reference/compound_stmts.rst:1681 +#: ../../reference/compound_stmts.rst:1798 msgid "" "Type parameters are declared in square brackets (``[]``) immediately after " "the name of the function, class, or type alias. The type parameters are " @@ -2268,36 +2479,36 @@ msgid "" "wraps the creation of the generic object." msgstr "" -#: ../../reference/compound_stmts.rst:1690 +#: ../../reference/compound_stmts.rst:1807 msgid "" "Generic functions, classes, and type aliases have a :attr:`~definition." "__type_params__` attribute listing their type parameters." msgstr "" -#: ../../reference/compound_stmts.rst:1693 +#: ../../reference/compound_stmts.rst:1810 msgid "Type parameters come in three kinds:" msgstr "" -#: ../../reference/compound_stmts.rst:1695 +#: ../../reference/compound_stmts.rst:1812 msgid "" ":data:`typing.TypeVar`, introduced by a plain name (e.g., ``T``). " "Semantically, this represents a single type to a type checker." msgstr "" -#: ../../reference/compound_stmts.rst:1697 +#: ../../reference/compound_stmts.rst:1814 msgid "" ":data:`typing.TypeVarTuple`, introduced by a name prefixed with a single " "asterisk (e.g., ``*Ts``). Semantically, this stands for a tuple of any " "number of types." msgstr "" -#: ../../reference/compound_stmts.rst:1700 +#: ../../reference/compound_stmts.rst:1817 msgid "" ":data:`typing.ParamSpec`, introduced by a name prefixed with two asterisks " "(e.g., ``**P``). Semantically, this stands for the parameters of a callable." msgstr "" -#: ../../reference/compound_stmts.rst:1703 +#: ../../reference/compound_stmts.rst:1820 msgid "" ":data:`typing.TypeVar` declarations can define *bounds* and *constraints* " "with a colon (``:``) followed by an expression. A single expression after " @@ -2309,7 +2520,7 @@ msgid "" "variables can only take on one of the types in the list of constraints." msgstr "" -#: ../../reference/compound_stmts.rst:1712 +#: ../../reference/compound_stmts.rst:1829 msgid "" "For :data:`!typing.TypeVar`\\ s declared using the type parameter list " "syntax, the bound and constraints are not evaluated when the generic object " @@ -2319,13 +2530,13 @@ msgid "" "`." msgstr "" -#: ../../reference/compound_stmts.rst:1718 +#: ../../reference/compound_stmts.rst:1835 msgid "" ":data:`typing.TypeVarTuple`\\ s and :data:`typing.ParamSpec`\\ s cannot have " "bounds or constraints." msgstr "" -#: ../../reference/compound_stmts.rst:1721 +#: ../../reference/compound_stmts.rst:1838 msgid "" "All three flavors of type parameters can also have a *default value*, which " "is used when the type parameter is not explicitly provided. This is added by " @@ -2338,13 +2549,13 @@ msgid "" "attribute is set to the special sentinel object :data:`typing.NoDefault`." msgstr "" -#: ../../reference/compound_stmts.rst:1731 +#: ../../reference/compound_stmts.rst:1848 msgid "" "The following example indicates the full set of allowed type parameter " "declarations::" msgstr "" -#: ../../reference/compound_stmts.rst:1733 +#: ../../reference/compound_stmts.rst:1850 msgid "" "def overly_generic[\n" " SimpleTypeVar,\n" @@ -2376,24 +2587,24 @@ msgstr "" " *e: SimpleTypeVarTuple,\n" "): ..." -#: ../../reference/compound_stmts.rst:1751 +#: ../../reference/compound_stmts.rst:1868 msgid "Generic functions" msgstr "" -#: ../../reference/compound_stmts.rst:1753 +#: ../../reference/compound_stmts.rst:1870 msgid "Generic functions are declared as follows::" msgstr "" -#: ../../reference/compound_stmts.rst:1755 +#: ../../reference/compound_stmts.rst:1872 msgid "def func[T](arg: T): ..." msgstr "def func[T](arg: T): ..." -#: ../../reference/compound_stmts.rst:1757 -#: ../../reference/compound_stmts.rst:1817 +#: ../../reference/compound_stmts.rst:1874 +#: ../../reference/compound_stmts.rst:1934 msgid "This syntax is equivalent to::" msgstr "語法大致等價於: ::" -#: ../../reference/compound_stmts.rst:1759 +#: ../../reference/compound_stmts.rst:1876 msgid "" "annotation-def TYPE_PARAMS_OF_func():\n" " T = typing.TypeVar(\"T\")\n" @@ -2409,7 +2620,7 @@ msgstr "" " return func\n" "func = TYPE_PARAMS_OF_func()" -#: ../../reference/compound_stmts.rst:1766 +#: ../../reference/compound_stmts.rst:1883 msgid "" "Here ``annotation-def`` indicates an :ref:`annotation scope `, which is not actually bound to any name at runtime. (One other " @@ -2418,20 +2629,20 @@ msgid "" "data:`typing.TypeVar` directly.)" msgstr "" -#: ../../reference/compound_stmts.rst:1772 +#: ../../reference/compound_stmts.rst:1889 msgid "" "The annotations of generic functions are evaluated within the annotation " "scope used for declaring the type parameters, but the function's defaults " "and decorators are not." msgstr "" -#: ../../reference/compound_stmts.rst:1776 +#: ../../reference/compound_stmts.rst:1893 msgid "" "The following example illustrates the scoping rules for these cases, as well " "as for additional flavors of type parameters::" msgstr "" -#: ../../reference/compound_stmts.rst:1779 +#: ../../reference/compound_stmts.rst:1896 msgid "" "@decorator\n" "def func[T: int, *Ts, **P](*args: *Ts, arg: Callable[P, T] = some_default):\n" @@ -2441,13 +2652,13 @@ msgstr "" "def func[T: int, *Ts, **P](*args: *Ts, arg: Callable[P, T] = some_default):\n" " ..." -#: ../../reference/compound_stmts.rst:1783 +#: ../../reference/compound_stmts.rst:1900 msgid "" "Except for the :ref:`lazy evaluation ` of the :class:" "`~typing.TypeVar` bound, this is equivalent to::" msgstr "" -#: ../../reference/compound_stmts.rst:1786 +#: ../../reference/compound_stmts.rst:1903 msgid "" "DEFAULT_OF_arg = some_default\n" "\n" @@ -2469,25 +2680,25 @@ msgid "" "func = decorator(TYPE_PARAMS_OF_func())" msgstr "" -#: ../../reference/compound_stmts.rst:1805 +#: ../../reference/compound_stmts.rst:1922 msgid "" "The capitalized names like ``DEFAULT_OF_arg`` are not actually bound at " "runtime." msgstr "" -#: ../../reference/compound_stmts.rst:1811 +#: ../../reference/compound_stmts.rst:1928 msgid "Generic classes" msgstr "" -#: ../../reference/compound_stmts.rst:1813 +#: ../../reference/compound_stmts.rst:1930 msgid "Generic classes are declared as follows::" msgstr "" -#: ../../reference/compound_stmts.rst:1815 +#: ../../reference/compound_stmts.rst:1932 msgid "class Bag[T]: ..." msgstr "class Bag[T]: ..." -#: ../../reference/compound_stmts.rst:1819 +#: ../../reference/compound_stmts.rst:1936 msgid "" "annotation-def TYPE_PARAMS_OF_Bag():\n" " T = typing.TypeVar(\"T\")\n" @@ -2505,14 +2716,14 @@ msgstr "" " return Bag\n" "Bag = TYPE_PARAMS_OF_Bag()" -#: ../../reference/compound_stmts.rst:1827 +#: ../../reference/compound_stmts.rst:1944 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." msgstr "" -#: ../../reference/compound_stmts.rst:1831 +#: ../../reference/compound_stmts.rst:1948 msgid "" "Generic classes implicitly inherit from :data:`typing.Generic`. The base " "classes and keyword arguments of generic classes are evaluated within the " @@ -2520,7 +2731,7 @@ msgid "" "that scope. This is illustrated by this example::" msgstr "" -#: ../../reference/compound_stmts.rst:1837 +#: ../../reference/compound_stmts.rst:1954 msgid "" "@decorator\n" "class Bag(Base[T], arg=T): ..." @@ -2528,11 +2739,11 @@ msgstr "" "@decorator\n" "class Bag(Base[T], arg=T): ..." -#: ../../reference/compound_stmts.rst:1840 +#: ../../reference/compound_stmts.rst:1957 msgid "This is equivalent to::" msgstr "這等價於: ::" -#: ../../reference/compound_stmts.rst:1842 +#: ../../reference/compound_stmts.rst:1959 msgid "" "annotation-def TYPE_PARAMS_OF_Bag():\n" " T = typing.TypeVar(\"T\")\n" @@ -2550,27 +2761,27 @@ msgstr "" " return Bag\n" "Bag = decorator(TYPE_PARAMS_OF_Bag())" -#: ../../reference/compound_stmts.rst:1853 +#: ../../reference/compound_stmts.rst:1970 msgid "Generic type aliases" msgstr "" -#: ../../reference/compound_stmts.rst:1855 +#: ../../reference/compound_stmts.rst:1972 msgid "" "The :keyword:`type` statement can also be used to create a generic type " "alias::" msgstr "" -#: ../../reference/compound_stmts.rst:1857 +#: ../../reference/compound_stmts.rst:1974 msgid "type ListOrSet[T] = list[T] | set[T]" msgstr "type ListOrSet[T] = list[T] | set[T]" -#: ../../reference/compound_stmts.rst:1859 +#: ../../reference/compound_stmts.rst:1976 msgid "" "Except for the :ref:`lazy evaluation ` of the value, this " "is equivalent to::" msgstr "" -#: ../../reference/compound_stmts.rst:1862 +#: ../../reference/compound_stmts.rst:1979 msgid "" "annotation-def TYPE_PARAMS_OF_ListOrSet():\n" " T = typing.TypeVar(\"T\")\n" @@ -2583,29 +2794,29 @@ msgid "" "ListOrSet = TYPE_PARAMS_OF_ListOrSet()" msgstr "" -#: ../../reference/compound_stmts.rst:1871 +#: ../../reference/compound_stmts.rst:1988 msgid "" "Here, ``annotation-def`` (not a real keyword) indicates an :ref:`annotation " "scope `. The capitalized names like " "``TYPE_PARAMS_OF_ListOrSet`` are not actually bound at runtime." msgstr "" -#: ../../reference/compound_stmts.rst:1878 +#: ../../reference/compound_stmts.rst:1995 msgid "Annotations" msgstr "註釋" -#: ../../reference/compound_stmts.rst:1880 +#: ../../reference/compound_stmts.rst:1997 msgid "Annotations are now lazily evaluated by default." msgstr "" -#: ../../reference/compound_stmts.rst:1883 +#: ../../reference/compound_stmts.rst:2000 msgid "" "Variables and function parameters may carry :term:`annotations " "`, created by adding a colon after the name, followed by an " "expression::" msgstr "" -#: ../../reference/compound_stmts.rst:1886 +#: ../../reference/compound_stmts.rst:2003 msgid "" "x: annotation = 1\n" "def f(param: annotation): ..." @@ -2613,15 +2824,15 @@ msgstr "" "x: annotation = 1\n" "def f(param: annotation): ..." -#: ../../reference/compound_stmts.rst:1889 +#: ../../reference/compound_stmts.rst:2006 msgid "Functions may also carry a return annotation following an arrow::" msgstr "" -#: ../../reference/compound_stmts.rst:1891 +#: ../../reference/compound_stmts.rst:2008 msgid "def f() -> annotation: ..." msgstr "def f() -> annotation: ..." -#: ../../reference/compound_stmts.rst:1893 +#: ../../reference/compound_stmts.rst:2010 msgid "" "Annotations are conventionally used for :term:`type hints `, but " "this is not enforced by the language, and in general annotations may contain " @@ -2631,7 +2842,7 @@ msgid "" "`functools.singledispatch`)." msgstr "" -#: ../../reference/compound_stmts.rst:1899 +#: ../../reference/compound_stmts.rst:2016 msgid "" "By default, annotations are lazily evaluated in an :ref:`annotation scope " "`. This means that they are not evaluated when the code " @@ -2640,13 +2851,13 @@ msgid "" "The :mod:`annotationlib` module provides tools for evaluating annotations." msgstr "" -#: ../../reference/compound_stmts.rst:1904 +#: ../../reference/compound_stmts.rst:2021 msgid "" "If the :ref:`future statement ` ``from __future__ import " "annotations`` is present, all annotations are instead stored as strings::" msgstr "" -#: ../../reference/compound_stmts.rst:1907 +#: ../../reference/compound_stmts.rst:2024 msgid "" ">>> from __future__ import annotations\n" ">>> def f(param: annotation): ...\n" @@ -2658,7 +2869,7 @@ msgstr "" ">>> f.__annotations__\n" "{'param': 'annotation'}" -#: ../../reference/compound_stmts.rst:1912 +#: ../../reference/compound_stmts.rst:2029 msgid "" "This future statement will be deprecated and removed in a future version of " "Python, but not before Python 3.13 reaches its end of life (see :pep:`749`). " @@ -2667,98 +2878,98 @@ msgid "" "able to resolve annotations at runtime." msgstr "" -#: ../../reference/compound_stmts.rst:1920 +#: ../../reference/compound_stmts.rst:2037 msgid "Footnotes" msgstr "註解" -#: ../../reference/compound_stmts.rst:1921 +#: ../../reference/compound_stmts.rst:2038 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." msgstr "" -#: ../../reference/compound_stmts.rst:1925 +#: ../../reference/compound_stmts.rst:2042 msgid "In pattern matching, a sequence is defined as one of the following:" msgstr "" -#: ../../reference/compound_stmts.rst:1927 +#: ../../reference/compound_stmts.rst:2044 msgid "a class that inherits from :class:`collections.abc.Sequence`" msgstr "" -#: ../../reference/compound_stmts.rst:1928 +#: ../../reference/compound_stmts.rst:2045 msgid "" "a Python class that has been registered as :class:`collections.abc.Sequence`" msgstr "" -#: ../../reference/compound_stmts.rst:1929 +#: ../../reference/compound_stmts.rst:2046 msgid "" "a builtin class that has its (CPython) :c:macro:`Py_TPFLAGS_SEQUENCE` bit set" msgstr "" -#: ../../reference/compound_stmts.rst:1930 -#: ../../reference/compound_stmts.rst:1949 +#: ../../reference/compound_stmts.rst:2047 +#: ../../reference/compound_stmts.rst:2066 msgid "a class that inherits from any of the above" msgstr "" -#: ../../reference/compound_stmts.rst:1932 +#: ../../reference/compound_stmts.rst:2049 msgid "The following standard library classes are sequences:" msgstr "" -#: ../../reference/compound_stmts.rst:1934 +#: ../../reference/compound_stmts.rst:2051 msgid ":class:`array.array`" msgstr ":class:`array.array`" -#: ../../reference/compound_stmts.rst:1935 +#: ../../reference/compound_stmts.rst:2052 msgid ":class:`collections.deque`" msgstr ":class:`collections.deque`" -#: ../../reference/compound_stmts.rst:1937 +#: ../../reference/compound_stmts.rst:2054 msgid ":class:`memoryview`" msgstr ":class:`memoryview`" -#: ../../reference/compound_stmts.rst:1938 +#: ../../reference/compound_stmts.rst:2055 msgid ":class:`range`" msgstr ":class:`range`" -#: ../../reference/compound_stmts.rst:1941 +#: ../../reference/compound_stmts.rst:2058 msgid "" "Subject values of type ``str``, ``bytes``, and ``bytearray`` do not match " "sequence patterns." msgstr "" -#: ../../reference/compound_stmts.rst:1944 +#: ../../reference/compound_stmts.rst:2061 msgid "In pattern matching, a mapping is defined as one of the following:" msgstr "" -#: ../../reference/compound_stmts.rst:1946 +#: ../../reference/compound_stmts.rst:2063 msgid "a class that inherits from :class:`collections.abc.Mapping`" msgstr "" -#: ../../reference/compound_stmts.rst:1947 +#: ../../reference/compound_stmts.rst:2064 msgid "" "a Python class that has been registered as :class:`collections.abc.Mapping`" msgstr "" -#: ../../reference/compound_stmts.rst:1948 +#: ../../reference/compound_stmts.rst:2065 msgid "" "a builtin class that has its (CPython) :c:macro:`Py_TPFLAGS_MAPPING` bit set" msgstr "" -#: ../../reference/compound_stmts.rst:1951 +#: ../../reference/compound_stmts.rst:2068 msgid "" "The standard library classes :class:`dict` and :class:`types." "MappingProxyType` are mappings." msgstr "" -#: ../../reference/compound_stmts.rst:1954 +#: ../../reference/compound_stmts.rst:2071 msgid "" "A string literal appearing as the first statement in the function body is " "transformed into the function's :attr:`~function.__doc__` attribute and " "therefore the function's :term:`docstring`." msgstr "" -#: ../../reference/compound_stmts.rst:1958 +#: ../../reference/compound_stmts.rst:2075 msgid "" "A string literal appearing as the first statement in the class body is " "transformed into the namespace's :attr:`~type.__doc__` item and therefore " @@ -2779,11 +2990,11 @@ msgstr "compound(複合)" #: ../../reference/compound_stmts.rst:446 #: ../../reference/compound_stmts.rst:484 #: ../../reference/compound_stmts.rst:605 -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1400 -#: ../../reference/compound_stmts.rst:1510 -#: ../../reference/compound_stmts.rst:1544 -#: ../../reference/compound_stmts.rst:1589 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1401 +#: ../../reference/compound_stmts.rst:1627 +#: ../../reference/compound_stmts.rst:1661 +#: ../../reference/compound_stmts.rst:1706 msgid "statement" msgstr "statement(陳述式)" @@ -2831,7 +3042,7 @@ msgstr "if" #: ../../reference/compound_stmts.rst:415 #: ../../reference/compound_stmts.rst:484 #: ../../reference/compound_stmts.rst:605 -#: ../../reference/compound_stmts.rst:1520 +#: ../../reference/compound_stmts.rst:1637 msgid "keyword" msgstr "keyword(關鍵字)" @@ -2844,9 +3055,9 @@ msgstr "elif" #: ../../reference/compound_stmts.rst:207 #: ../../reference/compound_stmts.rst:484 #: ../../reference/compound_stmts.rst:605 -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1342 -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1343 +#: ../../reference/compound_stmts.rst:1401 msgid ": (colon)" msgstr ": (冒號)" @@ -2855,8 +3066,8 @@ msgstr ": (冒號)" #: ../../reference/compound_stmts.rst:207 #: ../../reference/compound_stmts.rst:484 #: ../../reference/compound_stmts.rst:605 -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1401 msgid "compound statement" msgstr "compound statement(複合陳述式)" @@ -2901,8 +3112,8 @@ msgstr "list(串列)" #: ../../reference/compound_stmts.rst:144 #: ../../reference/compound_stmts.rst:301 -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1401 msgid "object" msgstr "object(物件)" @@ -2972,8 +3183,8 @@ msgid "with statement" msgstr "with statement(with 陳述式)" #: ../../reference/compound_stmts.rst:484 -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1401 msgid ", (comma)" msgstr ", (逗號)" @@ -3013,158 +3224,158 @@ msgstr "" msgid "AS pattern, OR pattern, capture pattern, wildcard pattern" msgstr "" -#: ../../reference/compound_stmts.rst:1203 -#: ../../reference/compound_stmts.rst:1292 +#: ../../reference/compound_stmts.rst:1204 +#: ../../reference/compound_stmts.rst:1293 msgid "parameter" msgstr "parameter(參數)" -#: ../../reference/compound_stmts.rst:1203 -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1256 -#: ../../reference/compound_stmts.rst:1292 -#: ../../reference/compound_stmts.rst:1321 +#: ../../reference/compound_stmts.rst:1204 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1257 +#: ../../reference/compound_stmts.rst:1293 +#: ../../reference/compound_stmts.rst:1322 msgid "function definition" msgstr "function definition(函式定義)" -#: ../../reference/compound_stmts.rst:1212 +#: ../../reference/compound_stmts.rst:1213 msgid "def" msgstr "def" -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1342 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1343 msgid "function" msgstr "function (函式)" -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1401 msgid "definition" msgstr "definition(定義)" -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1401 msgid "name" msgstr "name(名稱)" -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1401 msgid "binding" msgstr "binding(綁定)" -#: ../../reference/compound_stmts.rst:1212 +#: ../../reference/compound_stmts.rst:1213 msgid "user-defined function" msgstr "user-defined function(使用者定義函式)" -#: ../../reference/compound_stmts.rst:1212 -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1213 +#: ../../reference/compound_stmts.rst:1401 msgid "() (parentheses)" msgstr "() (圓括號)" -#: ../../reference/compound_stmts.rst:1212 +#: ../../reference/compound_stmts.rst:1213 msgid "parameter list" msgstr "parameter list(參數列表)" -#: ../../reference/compound_stmts.rst:1256 -#: ../../reference/compound_stmts.rst:1450 +#: ../../reference/compound_stmts.rst:1257 +#: ../../reference/compound_stmts.rst:1454 msgid "@ (at)" msgstr "@ (在)" -#: ../../reference/compound_stmts.rst:1292 +#: ../../reference/compound_stmts.rst:1293 msgid "default" msgstr "default(預設)" -#: ../../reference/compound_stmts.rst:1292 +#: ../../reference/compound_stmts.rst:1293 msgid "value" msgstr "value(值)" -#: ../../reference/compound_stmts.rst:1292 +#: ../../reference/compound_stmts.rst:1293 msgid "argument" msgstr "argument(引數)" -#: ../../reference/compound_stmts.rst:1292 +#: ../../reference/compound_stmts.rst:1293 msgid "= (equals)" msgstr "= (等號)" -#: ../../reference/compound_stmts.rst:1321 +#: ../../reference/compound_stmts.rst:1322 msgid "/ (slash)" msgstr "/ (斜線)" -#: ../../reference/compound_stmts.rst:1321 +#: ../../reference/compound_stmts.rst:1322 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../reference/compound_stmts.rst:1321 +#: ../../reference/compound_stmts.rst:1322 msgid "**" msgstr "**" -#: ../../reference/compound_stmts.rst:1342 +#: ../../reference/compound_stmts.rst:1343 msgid "annotations" msgstr "annotations(註釋)" -#: ../../reference/compound_stmts.rst:1342 +#: ../../reference/compound_stmts.rst:1343 msgid "->" msgstr "->" -#: ../../reference/compound_stmts.rst:1342 +#: ../../reference/compound_stmts.rst:1343 msgid "function annotations" msgstr "function annotations(函式註釋)" -#: ../../reference/compound_stmts.rst:1359 +#: ../../reference/compound_stmts.rst:1360 msgid "lambda" msgstr "lambda" -#: ../../reference/compound_stmts.rst:1359 +#: ../../reference/compound_stmts.rst:1360 msgid "expression" msgstr "expression(運算式)" -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1401 msgid "class" msgstr "class(類別)" -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1401 msgid "execution" msgstr "execution(執行)" -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1401 msgid "frame" msgstr "frame" -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1401 msgid "inheritance" msgstr "inheritance(繼承)" -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1401 msgid "docstring" msgstr "docstring(說明字串)" -#: ../../reference/compound_stmts.rst:1400 -#: ../../reference/compound_stmts.rst:1450 +#: ../../reference/compound_stmts.rst:1401 +#: ../../reference/compound_stmts.rst:1454 msgid "class definition" msgstr "class definition(類別定義)" -#: ../../reference/compound_stmts.rst:1400 +#: ../../reference/compound_stmts.rst:1401 msgid "expression list" msgstr "expression list(運算式列表)" -#: ../../reference/compound_stmts.rst:1510 +#: ../../reference/compound_stmts.rst:1627 msgid "async def" msgstr "async def" -#: ../../reference/compound_stmts.rst:1520 +#: ../../reference/compound_stmts.rst:1637 msgid "async" msgstr "async" -#: ../../reference/compound_stmts.rst:1520 +#: ../../reference/compound_stmts.rst:1637 msgid "await" msgstr "await" -#: ../../reference/compound_stmts.rst:1544 +#: ../../reference/compound_stmts.rst:1661 msgid "async for" msgstr "async for" -#: ../../reference/compound_stmts.rst:1589 +#: ../../reference/compound_stmts.rst:1706 msgid "async with" msgstr "async with" -#: ../../reference/compound_stmts.rst:1647 +#: ../../reference/compound_stmts.rst:1764 msgid "type parameters" msgstr "type parameter(型別參數)" diff --git a/reference/datamodel.po b/reference/datamodel.po index a21ff1cbc46..da9d61b54f3 100644 --- a/reference/datamodel.po +++ b/reference/datamodel.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-24 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-09-24 19:03+0900\n" "Last-Translator: Kisaragi Hiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -627,7 +627,7 @@ msgid "" msgstr "" #: ../../reference/datamodel.rst:499 -msgid "There is currently a single intrinsic mapping type:" +msgid "There are two intrinsic mapping types:" msgstr "" #: ../../reference/datamodel.rst:503 @@ -674,117 +674,130 @@ msgid "" msgstr "" #: ../../reference/datamodel.rst:539 +msgid "Frozen dictionaries" +msgstr "凍結字典" + +#: ../../reference/datamodel.rst:543 +msgid "" +"These represent an immutable dictionary. They are created by the built-in :" +"func:`frozendict` constructor. A frozendict is :term:`hashable` if all of " +"its keys and values are hashable, in which case it can be used as an element " +"of a set, or as a key in another mapping. :class:`!frozendict` is not a " +"subclass of :class:`dict`; it inherits directly from :class:`object`." +msgstr "" + +#: ../../reference/datamodel.rst:553 msgid "Callable types" msgstr "可呼叫型別" -#: ../../reference/datamodel.rst:547 +#: ../../reference/datamodel.rst:561 msgid "" "These are the types to which the function call operation (see section :ref:" "`calls`) can be applied:" msgstr "" -#: ../../reference/datamodel.rst:554 +#: ../../reference/datamodel.rst:568 msgid "User-defined functions" msgstr "自訂函式" -#: ../../reference/datamodel.rst:561 +#: ../../reference/datamodel.rst:575 msgid "" "A user-defined function object is created by a function definition (see " "section :ref:`function`). It should be called with an argument list " "containing the same number of items as the function's formal parameter list." msgstr "" -#: ../../reference/datamodel.rst:567 ../../reference/datamodel.rst:1491 -#: ../../reference/datamodel.rst:1702 +#: ../../reference/datamodel.rst:581 ../../reference/datamodel.rst:1498 +#: ../../reference/datamodel.rst:1701 msgid "Special read-only attributes" msgstr "特殊唯讀屬性" -#: ../../reference/datamodel.rst:578 ../../reference/datamodel.rst:620 -#: ../../reference/datamodel.rst:1223 +#: ../../reference/datamodel.rst:592 ../../reference/datamodel.rst:634 +#: ../../reference/datamodel.rst:1231 msgid "Attribute" msgstr "屬性" -#: ../../reference/datamodel.rst:579 ../../reference/datamodel.rst:621 -#: ../../reference/datamodel.rst:1224 +#: ../../reference/datamodel.rst:593 ../../reference/datamodel.rst:635 +#: ../../reference/datamodel.rst:1232 msgid "Meaning" msgstr "含義" -#: ../../reference/datamodel.rst:582 +#: ../../reference/datamodel.rst:596 msgid "" "A reference to the :class:`dictionary ` that holds the function's " "builtins namespace." msgstr "" -#: ../../reference/datamodel.rst:588 +#: ../../reference/datamodel.rst:602 msgid "" "A reference to the :class:`dictionary ` that holds the function's :ref:" "`global variables ` -- the global namespace of the module in which " "the function was defined." msgstr "" -#: ../../reference/datamodel.rst:593 +#: ../../reference/datamodel.rst:607 msgid "" "``None`` or a :class:`tuple` of cells that contain bindings for the names " "specified in the :attr:`~codeobject.co_freevars` attribute of the " "function's :attr:`code object `." msgstr "" -#: ../../reference/datamodel.rst:597 +#: ../../reference/datamodel.rst:611 msgid "" "A cell object has the attribute ``cell_contents``. This can be used to get " "the value of the cell, as well as set the value." msgstr "" -#: ../../reference/datamodel.rst:601 ../../reference/datamodel.rst:1750 +#: ../../reference/datamodel.rst:615 ../../reference/datamodel.rst:1749 msgid "Special writable attributes" msgstr "特殊可寫屬性" -#: ../../reference/datamodel.rst:615 +#: ../../reference/datamodel.rst:629 msgid "Most of these attributes check the type of the assigned value:" msgstr "" -#: ../../reference/datamodel.rst:624 +#: ../../reference/datamodel.rst:638 msgid "The function's documentation string, or ``None`` if unavailable." msgstr "函式的文件字串,若不可用則為 ``None``。" -#: ../../reference/datamodel.rst:627 +#: ../../reference/datamodel.rst:641 msgid "" "The function's name. See also: :attr:`__name__ attributes `." msgstr "" -#: ../../reference/datamodel.rst:631 +#: ../../reference/datamodel.rst:645 msgid "" "The function's :term:`qualified name`. See also: :attr:`__qualname__ " "attributes `." msgstr "" -#: ../../reference/datamodel.rst:637 +#: ../../reference/datamodel.rst:651 msgid "" "The name of the module the function was defined in, or ``None`` if " "unavailable." msgstr "" -#: ../../reference/datamodel.rst:641 +#: ../../reference/datamodel.rst:655 msgid "" "A :class:`tuple` containing default :term:`parameter` values for those " "parameters that have defaults, or ``None`` if no parameters have a default " "value." msgstr "" -#: ../../reference/datamodel.rst:646 +#: ../../reference/datamodel.rst:660 msgid "" "The :ref:`code object ` representing the compiled function " "body." msgstr "代表編譯函式主體的\\ :ref:`程式碼物件 `。" -#: ../../reference/datamodel.rst:650 +#: ../../reference/datamodel.rst:664 msgid "" "The namespace supporting arbitrary function attributes. See also: :attr:" "`__dict__ attributes `." msgstr "" -#: ../../reference/datamodel.rst:654 +#: ../../reference/datamodel.rst:668 msgid "" "A :class:`dictionary ` containing annotations of :term:`parameters " "`. The keys of the dictionary are the parameter names, and " @@ -792,101 +805,101 @@ msgid "" "__annotations__`." msgstr "" -#: ../../reference/datamodel.rst:660 ../../reference/datamodel.rst:1129 -#: ../../reference/datamodel.rst:1281 +#: ../../reference/datamodel.rst:674 ../../reference/datamodel.rst:1123 +#: ../../reference/datamodel.rst:1289 msgid "" "Annotations are now :ref:`lazily evaluated `. See :pep:" "`649`." msgstr "" -#: ../../reference/datamodel.rst:665 +#: ../../reference/datamodel.rst:679 msgid "" "The :term:`annotate function` for this function, or ``None`` if the function " "has no annotations. See :attr:`object.__annotate__`." msgstr "" -#: ../../reference/datamodel.rst:671 +#: ../../reference/datamodel.rst:685 msgid "" "A :class:`dictionary ` containing defaults for keyword-only :term:" "`parameters `." msgstr "" -#: ../../reference/datamodel.rst:675 +#: ../../reference/datamodel.rst:689 msgid "" "A :class:`tuple` containing the :ref:`type parameters ` of a :" "ref:`generic function `." msgstr "" -#: ../../reference/datamodel.rst:680 +#: ../../reference/datamodel.rst:694 msgid "" "Function objects also support getting and setting arbitrary attributes, " "which can be used, for example, to attach metadata to functions. Regular " "attribute dot-notation is used to get and set such attributes." msgstr "" -#: ../../reference/datamodel.rst:686 +#: ../../reference/datamodel.rst:700 msgid "" "CPython's current implementation only supports function attributes on user-" "defined functions. Function attributes on :ref:`built-in functions ` may be supported in the future." msgstr "" -#: ../../reference/datamodel.rst:691 +#: ../../reference/datamodel.rst:705 msgid "" "Additional information about a function's definition can be retrieved from " "its :ref:`code object ` (accessible via the :attr:`~function." "__code__` attribute)." msgstr "" -#: ../../reference/datamodel.rst:699 +#: ../../reference/datamodel.rst:713 msgid "Instance methods" msgstr "實例方法" -#: ../../reference/datamodel.rst:706 +#: ../../reference/datamodel.rst:720 msgid "" "An instance method object combines a class, a class instance and any " "callable object (normally a user-defined function)." msgstr "" -#: ../../reference/datamodel.rst:716 ../../reference/datamodel.rst:1846 +#: ../../reference/datamodel.rst:730 ../../reference/datamodel.rst:1845 msgid "Special read-only attributes:" msgstr "特殊唯讀屬性:" -#: ../../reference/datamodel.rst:721 +#: ../../reference/datamodel.rst:735 msgid "" "Refers to the class instance object to which the method is :ref:`bound " "`" msgstr "" -#: ../../reference/datamodel.rst:725 +#: ../../reference/datamodel.rst:739 msgid "Refers to the original :ref:`function object `" msgstr "" -#: ../../reference/datamodel.rst:728 +#: ../../reference/datamodel.rst:742 msgid "" "The method's documentation (same as :attr:`method.__func__.__doc__ `). A :class:`string ` if the original function had a " "docstring, else ``None``." msgstr "" -#: ../../reference/datamodel.rst:734 +#: ../../reference/datamodel.rst:748 msgid "" "The name of the method (same as :attr:`method.__func__.__name__ `)" msgstr "" -#: ../../reference/datamodel.rst:738 +#: ../../reference/datamodel.rst:752 msgid "" "The name of the module the method was defined in, or ``None`` if unavailable." msgstr "" -#: ../../reference/datamodel.rst:741 +#: ../../reference/datamodel.rst:755 msgid "" "Methods also support accessing (but not setting) the arbitrary function " "attributes on the underlying :ref:`function object `." msgstr "" -#: ../../reference/datamodel.rst:744 +#: ../../reference/datamodel.rst:758 msgid "" "User-defined method objects may be created when getting an attribute of a " "class (perhaps via an instance of that class), if that attribute is a user-" @@ -894,7 +907,7 @@ msgid "" "`classmethod` object." msgstr "" -#: ../../reference/datamodel.rst:751 +#: ../../reference/datamodel.rst:765 msgid "" "When an instance method object is created by retrieving a user-defined :ref:" "`function object ` from a class via one of its " @@ -903,7 +916,7 @@ msgid "" "__func__` attribute is the original function object." msgstr "" -#: ../../reference/datamodel.rst:757 +#: ../../reference/datamodel.rst:771 msgid "" "When an instance method object is created by retrieving a :class:" "`classmethod` object from a class or instance, its :attr:`~method.__self__` " @@ -911,7 +924,7 @@ msgid "" "the function object underlying the class method." msgstr "" -#: ../../reference/datamodel.rst:762 +#: ../../reference/datamodel.rst:776 msgid "" "When an instance method object is called, the underlying function (:attr:" "`~method.__func__`) is called, inserting the class instance (:attr:`~method." @@ -921,7 +934,7 @@ msgid "" "f(x, 1)``." msgstr "" -#: ../../reference/datamodel.rst:769 +#: ../../reference/datamodel.rst:783 msgid "" "When an instance method object is derived from a :class:`classmethod` " "object, the \"class instance\" stored in :attr:`~method.__self__` will " @@ -930,18 +943,18 @@ msgid "" "function." msgstr "" -#: ../../reference/datamodel.rst:774 +#: ../../reference/datamodel.rst:788 msgid "" "It is important to note that user-defined functions which are attributes of " "a class instance are not converted to bound methods; this *only* happens " "when the function is an attribute of the class." msgstr "" -#: ../../reference/datamodel.rst:781 +#: ../../reference/datamodel.rst:795 msgid "Generator functions" msgstr "產生器函式" -#: ../../reference/datamodel.rst:787 +#: ../../reference/datamodel.rst:801 msgid "" "A function or method which contains a :keyword:`yield` expression (see " "section :ref:`yieldexpr`) is called a :dfn:`generator function`. Such a " @@ -954,11 +967,11 @@ msgid "" "end of the set of values to be returned." msgstr "" -#: ../../reference/datamodel.rst:799 +#: ../../reference/datamodel.rst:813 msgid "Coroutine functions" msgstr "Coroutine(協程)函式" -#: ../../reference/datamodel.rst:804 +#: ../../reference/datamodel.rst:818 msgid "" "A function or method which is defined using :keyword:`async def` is called " "a :dfn:`coroutine function`. Such a function, when called, returns a :term:" @@ -967,11 +980,11 @@ msgid "" "ref:`coroutine-objects` section." msgstr "" -#: ../../reference/datamodel.rst:812 +#: ../../reference/datamodel.rst:826 msgid "Asynchronous generator functions" msgstr "非同步產生器函式" -#: ../../reference/datamodel.rst:818 +#: ../../reference/datamodel.rst:832 msgid "" "A function or method which is defined using :keyword:`async def` and which " "contains a :keyword:`yield` expression is called a :dfn:`asynchronous " @@ -980,7 +993,7 @@ msgid "" "statement to execute the body of the function." msgstr "" -#: ../../reference/datamodel.rst:824 +#: ../../reference/datamodel.rst:838 msgid "" "Calling the asynchronous iterator's :meth:`aiterator.__anext__ ` method will return an :term:`awaitable` which when awaited will " @@ -991,11 +1004,11 @@ msgid "" "yielded." msgstr "" -#: ../../reference/datamodel.rst:837 +#: ../../reference/datamodel.rst:851 msgid "Built-in functions" msgstr "內建函式" -#: ../../reference/datamodel.rst:844 +#: ../../reference/datamodel.rst:858 msgid "" "A built-in function object is a wrapper around a C function. Examples of " "built-in functions are :func:`len` and :func:`math.sin` (:mod:`math` is a " @@ -1006,7 +1019,7 @@ msgstr "" "func:`math.sin`\\ (\\ :mod:`math` 是一個標準的內建模組)。內建函式的引數數量" "與其型別由其包裝的 C 函式所決定。特殊唯讀屬性:" -#: ../../reference/datamodel.rst:849 +#: ../../reference/datamodel.rst:863 msgid "" ":attr:`!__doc__` is the function's documentation string, or ``None`` if " "unavailable. See :attr:`function.__doc__`." @@ -1014,26 +1027,26 @@ msgstr "" ":attr:`!__doc__` 是函式的文件字串,若不可用則為 ``None``。請見 :attr:" "`function.__doc__`。" -#: ../../reference/datamodel.rst:851 +#: ../../reference/datamodel.rst:865 msgid "" ":attr:`!__name__` is the function's name. See :attr:`function.__name__`." msgstr ":attr:`!__name__` 是函式的名稱。請見 :attr:`function.__name__`。" -#: ../../reference/datamodel.rst:852 +#: ../../reference/datamodel.rst:866 msgid ":attr:`!__self__` is set to ``None`` (but see the next item)." msgstr "" -#: ../../reference/datamodel.rst:853 +#: ../../reference/datamodel.rst:867 msgid "" ":attr:`!__module__` is the name of the module the function was defined in or " "``None`` if unavailable. See :attr:`function.__module__`." msgstr "" -#: ../../reference/datamodel.rst:861 +#: ../../reference/datamodel.rst:875 msgid "Built-in methods" msgstr "內建方法" -#: ../../reference/datamodel.rst:868 +#: ../../reference/datamodel.rst:882 msgid "" "This is really a different disguise of a built-in function, this time " "containing an object passed to the C function as an implicit extra " @@ -1044,11 +1057,11 @@ msgid "" "__self__>`.)" msgstr "" -#: ../../reference/datamodel.rst:878 +#: ../../reference/datamodel.rst:892 msgid "Classes" msgstr "" -#: ../../reference/datamodel.rst:880 +#: ../../reference/datamodel.rst:894 msgid "" "Classes are callable. These objects normally act as factories for new " "instances of themselves, but variations are possible for class types that " @@ -1057,21 +1070,21 @@ msgid "" "initialize the new instance." msgstr "" -#: ../../reference/datamodel.rst:888 +#: ../../reference/datamodel.rst:902 msgid "Class Instances" msgstr "類別實例" -#: ../../reference/datamodel.rst:890 +#: ../../reference/datamodel.rst:904 msgid "" "Instances of arbitrary classes can be made callable by defining a :meth:" "`~object.__call__` method in their class." msgstr "" -#: ../../reference/datamodel.rst:897 +#: ../../reference/datamodel.rst:911 msgid "Modules" msgstr "模組" -#: ../../reference/datamodel.rst:903 +#: ../../reference/datamodel.rst:917 msgid "" "Modules are a basic organizational unit of Python code, and are created by " "the :ref:`import system ` as invoked either by the :keyword:" @@ -1086,17 +1099,17 @@ msgid "" "done)." msgstr "" -#: ../../reference/datamodel.rst:916 +#: ../../reference/datamodel.rst:930 msgid "" "Attribute assignment updates the module's namespace dictionary, e.g., ``m.x " "= 1`` is equivalent to ``m.__dict__[\"x\"] = 1``." msgstr "" -#: ../../reference/datamodel.rst:935 +#: ../../reference/datamodel.rst:949 msgid "Import-related attributes on module objects" msgstr "" -#: ../../reference/datamodel.rst:937 +#: ../../reference/datamodel.rst:951 msgid "" "Module objects have the following attributes that relate to the :ref:`import " "system `. When a module is created using the machinery " @@ -1105,7 +1118,7 @@ msgid "" "and loads the module." msgstr "" -#: ../../reference/datamodel.rst:943 +#: ../../reference/datamodel.rst:957 msgid "" "To create a module dynamically rather than using the import system, it's " "recommended to use :func:`importlib.util.module_from_spec`, which will set " @@ -1116,7 +1129,7 @@ msgid "" "approach." msgstr "" -#: ../../reference/datamodel.rst:953 +#: ../../reference/datamodel.rst:967 msgid "" "With the exception of :attr:`~module.__name__`, it is **strongly** " "recommended that you rely on :attr:`~module.__spec__` and its attributes " @@ -1125,7 +1138,7 @@ msgid "" "corresponding attribute on the module itself:" msgstr "" -#: ../../reference/datamodel.rst:959 +#: ../../reference/datamodel.rst:973 msgid "" ">>> import typing\n" ">>> typing.__name__, typing.__spec__.name\n" @@ -1147,34 +1160,34 @@ msgstr "" ">>> typing.__name__, typing.__spec__.name\n" "('keyboard_smashing', 'spelling')" -#: ../../reference/datamodel.rst:973 +#: ../../reference/datamodel.rst:987 msgid "" "The name used to uniquely identify the module in the import system. For a " "directly executed module, this will be set to ``\"__main__\"``." msgstr "" -#: ../../reference/datamodel.rst:976 +#: ../../reference/datamodel.rst:990 msgid "" "This attribute must be set to the fully qualified name of the module. It is " "expected to match the value of :attr:`module.__spec__.name `." msgstr "" -#: ../../reference/datamodel.rst:982 +#: ../../reference/datamodel.rst:996 msgid "A record of the module's import-system-related state." msgstr "" -#: ../../reference/datamodel.rst:984 +#: ../../reference/datamodel.rst:998 msgid "" "Set to the :class:`module spec ` that was " "used when importing the module. See :ref:`module-specs` for more details." msgstr "" -#: ../../reference/datamodel.rst:991 +#: ../../reference/datamodel.rst:1005 msgid "The :term:`package` a module belongs to." msgstr "" -#: ../../reference/datamodel.rst:993 +#: ../../reference/datamodel.rst:1007 msgid "" "If the module is top-level (that is, not a part of any specific package) " "then the attribute should be set to ``''`` (the empty string). Otherwise, it " @@ -1183,7 +1196,7 @@ msgid "" "for further details." msgstr "" -#: ../../reference/datamodel.rst:999 +#: ../../reference/datamodel.rst:1013 msgid "" "This attribute is used instead of :attr:`~module.__name__` to calculate " "explicit relative imports for main modules. It defaults to ``None`` for " @@ -1192,7 +1205,7 @@ msgid "" "is set to a :class:`str`." msgstr "" -#: ../../reference/datamodel.rst:1005 +#: ../../reference/datamodel.rst:1019 msgid "" "It is **strongly** recommended that you use :attr:`module.__spec__.parent " "` instead of :attr:`!module." @@ -1200,14 +1213,14 @@ msgid "" "__spec__.parent` is not set, and this fallback path is deprecated." msgstr "" -#: ../../reference/datamodel.rst:1011 ../../reference/datamodel.rst:1052 +#: ../../reference/datamodel.rst:1025 ../../reference/datamodel.rst:1066 msgid "" "This attribute now defaults to ``None`` for modules created dynamically " "using the :class:`types.ModuleType` constructor. Previously the attribute " "was optional." msgstr "" -#: ../../reference/datamodel.rst:1016 +#: ../../reference/datamodel.rst:1030 msgid "" "The value of :attr:`!__package__` is expected to be the same as :attr:" "`__spec__.parent `. :attr:" @@ -1215,38 +1228,38 @@ msgid "" "attr:`!__spec__.parent` is not defined." msgstr "" -#: ../../reference/datamodel.rst:1022 +#: ../../reference/datamodel.rst:1036 msgid "" ":exc:`ImportWarning` is raised if an import resolution falls back to :attr:`!" "__package__` instead of :attr:`__spec__.parent `." msgstr "" -#: ../../reference/datamodel.rst:1027 +#: ../../reference/datamodel.rst:1041 msgid "" "Raise :exc:`DeprecationWarning` instead of :exc:`ImportWarning` when falling " "back to :attr:`!__package__` during import resolution." msgstr "" -#: ../../reference/datamodel.rst:1031 +#: ../../reference/datamodel.rst:1045 msgid "" ":attr:`!__package__` will cease to be set or taken into consideration by the " "import system or standard library." msgstr "" -#: ../../reference/datamodel.rst:1037 +#: ../../reference/datamodel.rst:1051 msgid "" "The :term:`loader` object that the import machinery used to load the module." msgstr "" -#: ../../reference/datamodel.rst:1039 +#: ../../reference/datamodel.rst:1053 msgid "" "This attribute is mostly useful for introspection, but can be used for " "additional loader-specific functionality, for example getting data " "associated with a loader." msgstr "" -#: ../../reference/datamodel.rst:1043 +#: ../../reference/datamodel.rst:1057 msgid "" ":attr:`!__loader__` defaults to ``None`` for modules created dynamically " "using the :class:`types.ModuleType` constructor; use :func:`importlib.util." @@ -1254,14 +1267,14 @@ msgid "" "object." msgstr "" -#: ../../reference/datamodel.rst:1048 +#: ../../reference/datamodel.rst:1062 msgid "" "It is **strongly** recommended that you use :attr:`module.__spec__.loader " "` instead of :attr:`!module." "__loader__`." msgstr "" -#: ../../reference/datamodel.rst:1057 +#: ../../reference/datamodel.rst:1071 msgid "" "Setting :attr:`!__loader__` on a module while failing to set :attr:`!" "__spec__.loader` is deprecated. In Python 3.16, :attr:`!__loader__` will " @@ -1272,7 +1285,7 @@ msgstr "" "被棄用。在 Python 3.16 中,引入系統或標準函式庫將不再設定或考慮 :attr:`!" "__loader__`。" -#: ../../reference/datamodel.rst:1065 +#: ../../reference/datamodel.rst:1079 msgid "" "A (possibly empty) :term:`sequence` of strings enumerating the locations " "where the package's submodules will be found. Non-package modules should not " @@ -1280,76 +1293,47 @@ msgid "" "details." msgstr "" -#: ../../reference/datamodel.rst:1070 +#: ../../reference/datamodel.rst:1084 msgid "" "It is **strongly** recommended that you use :attr:`module.__spec__." "submodule_search_locations ` instead of :attr:`!module.__path__`." msgstr "" -#: ../../reference/datamodel.rst:1077 +#: ../../reference/datamodel.rst:1090 msgid "" -":attr:`!__file__` and :attr:`!__cached__` are both optional attributes that " -"may or may not be set. Both attributes should be a :class:`str` when they " -"are available." +":attr:`!__file__` is an optional attribute that may or may not be set. Both " +"attributes should be a :class:`str` when they are available." msgstr "" -#: ../../reference/datamodel.rst:1081 +#: ../../reference/datamodel.rst:1094 msgid "" -":attr:`!__file__` indicates the pathname of the file from which the module " -"was loaded (if loaded from a file), or the pathname of the shared library " -"file for extension modules loaded dynamically from a shared library. It " -"might be missing for certain types of modules, such as C modules that are " -"statically linked into the interpreter, and the :ref:`import system " -"` may opt to leave it unset if it has no semantic meaning (for " -"example, a module loaded from a database)." -msgstr "" - -#: ../../reference/datamodel.rst:1089 -msgid "" -"If :attr:`!__file__` is set then the :attr:`!__cached__` attribute might " -"also be set, which is the path to any compiled version of the code (for " -"example, a byte-compiled file). The file does not need to exist to set this " -"attribute; the path can simply point to where the compiled file *would* " -"exist (see :pep:`3147`)." -msgstr "" - -#: ../../reference/datamodel.rst:1095 -msgid "" -"Note that :attr:`!__cached__` may be set even if :attr:`!__file__` is not " -"set. However, that scenario is quite atypical. Ultimately, the :term:" -"`loader` is what makes use of the module spec provided by the :term:`finder` " -"(from which :attr:`!__file__` and :attr:`!__cached__` are derived). So if a " -"loader can load from a cached module but otherwise does not load from a " -"file, that atypical scenario may be appropriate." +"An optional attribute, :attr:`!__file__` indicates the pathname of the file " +"from which the module was loaded (if loaded from a file), or the pathname of " +"the shared library file for extension modules loaded dynamically from a " +"shared library. It might be missing for certain types of modules, such as C " +"modules that are statically linked into the interpreter, and the :ref:" +"`import system ` may opt to leave it unset if it has no " +"semantic meaning (for example, a module loaded from a database)." msgstr "" #: ../../reference/datamodel.rst:1102 msgid "" -"It is **strongly** recommended that you use :attr:`module.__spec__.cached " -"` instead of :attr:`!module." -"__cached__`." -msgstr "" - -#: ../../reference/datamodel.rst:1106 -msgid "" -"Setting :attr:`!__cached__` on a module while failing to set :attr:`!" -"__spec__.cached` is deprecated. In Python 3.15, :attr:`!__cached__` will " -"cease to be set or taken into consideration by the import system or standard " -"library." +"The ``__cached__`` attribute is no longer set on modules or taken into " +"consideration by the import system or standard library." msgstr "" -#: ../../reference/datamodel.rst:1113 +#: ../../reference/datamodel.rst:1107 msgid "Other writable attributes on module objects" msgstr "模組物件的其他可寫入屬性" -#: ../../reference/datamodel.rst:1115 +#: ../../reference/datamodel.rst:1109 msgid "" "As well as the import-related attributes listed above, module objects also " "have the following writable attributes:" msgstr "" -#: ../../reference/datamodel.rst:1120 +#: ../../reference/datamodel.rst:1114 msgid "" "The module's documentation string, or ``None`` if unavailable. See also: :" "attr:`__doc__ attributes `." @@ -1357,35 +1341,50 @@ msgstr "" "模組的文件字串,若不可用則為 ``None``。請見 :attr:`__doc__ attributes " "`。" -#: ../../reference/datamodel.rst:1125 +#: ../../reference/datamodel.rst:1119 msgid "" "A dictionary containing :term:`variable annotations ` " "collected during module body execution. For best practices on working with :" "attr:`!__annotations__`, see :mod:`annotationlib`." msgstr "" -#: ../../reference/datamodel.rst:1135 +#: ../../reference/datamodel.rst:1129 msgid "" "The :term:`annotate function` for this module, or ``None`` if the module has " "no annotations. See also: :attr:`~object.__annotate__` attributes." msgstr "" -#: ../../reference/datamodel.rst:1141 +#: ../../reference/datamodel.rst:1136 +msgid "" +"A container (an object implementing :meth:`~object.__contains__`) of fully " +"qualified module name strings. When defined at module scope, any regular :" +"keyword:`import` statement in that module whose target module name appears " +"in this container is treated as a :ref:`lazy import `, as if " +"the :keyword:`lazy` keyword had been used. Imports inside functions, class " +"bodies, or :keyword:`try`/:keyword:`except`/:keyword:`finally` blocks are " +"unaffected." +msgstr "" + +#: ../../reference/datamodel.rst:1144 +msgid "See :ref:`lazy-modules-compat` for details and examples." +msgstr "更多細節與範例請見 :ref:`lazy-modules-compat`。" + +#: ../../reference/datamodel.rst:1149 msgid "Module dictionaries" msgstr "模組字典" -#: ../../reference/datamodel.rst:1143 +#: ../../reference/datamodel.rst:1151 msgid "Module objects also have the following special read-only attribute:" msgstr "" -#: ../../reference/datamodel.rst:1148 +#: ../../reference/datamodel.rst:1156 msgid "" "The module's namespace as a dictionary object. Uniquely among the attributes " "listed here, :attr:`!__dict__` cannot be accessed as a global variable from " "within a module; it can only be accessed as an attribute on module objects." msgstr "" -#: ../../reference/datamodel.rst:1154 +#: ../../reference/datamodel.rst:1162 msgid "" "Because of the way CPython clears module dictionaries, the module dictionary " "will be cleared when the module falls out of scope even if the dictionary " @@ -1393,11 +1392,11 @@ msgid "" "module around while using its dictionary directly." msgstr "" -#: ../../reference/datamodel.rst:1163 +#: ../../reference/datamodel.rst:1171 msgid "Custom classes" msgstr "" -#: ../../reference/datamodel.rst:1165 +#: ../../reference/datamodel.rst:1173 msgid "" "Custom class types are typically created by class definitions (see section :" "ref:`class`). A class has a namespace implemented by a dictionary object. " @@ -1412,7 +1411,7 @@ msgid "" "found at :ref:`python_2.3_mro`." msgstr "" -#: ../../reference/datamodel.rst:1186 +#: ../../reference/datamodel.rst:1194 msgid "" "When a class attribute reference (for class :class:`!C`, say) would yield a " "class method object, it is transformed into an instance method object whose :" @@ -1423,80 +1422,80 @@ msgid "" "contained in its :attr:`~object.__dict__`." msgstr "" -#: ../../reference/datamodel.rst:1197 +#: ../../reference/datamodel.rst:1205 msgid "" "Class attribute assignments update the class's dictionary, never the " "dictionary of a base class." msgstr "" -#: ../../reference/datamodel.rst:1202 +#: ../../reference/datamodel.rst:1210 msgid "" "A class object can be called (see above) to yield a class instance (see " "below)." msgstr "" -#: ../../reference/datamodel.rst:1205 ../../reference/datamodel.rst:1381 +#: ../../reference/datamodel.rst:1213 ../../reference/datamodel.rst:1389 msgid "Special attributes" msgstr "特殊屬性" -#: ../../reference/datamodel.rst:1227 +#: ../../reference/datamodel.rst:1235 msgid "" "The class's name. See also: :attr:`__name__ attributes `." msgstr "" -#: ../../reference/datamodel.rst:1231 +#: ../../reference/datamodel.rst:1239 msgid "" "The class's :term:`qualified name`. See also: :attr:`__qualname__ attributes " "`." msgstr "" -#: ../../reference/datamodel.rst:1235 +#: ../../reference/datamodel.rst:1243 msgid "The name of the module in which the class was defined." msgstr "" -#: ../../reference/datamodel.rst:1238 +#: ../../reference/datamodel.rst:1246 msgid "" "A :class:`mapping proxy ` providing a read-only view " "of the class's namespace. See also: :attr:`__dict__ attributes `." msgstr "" -#: ../../reference/datamodel.rst:1243 +#: ../../reference/datamodel.rst:1251 msgid "" "A :class:`tuple` containing the class's bases. In most cases, for a class " "defined as ``class X(A, B, C)``, ``X.__bases__`` will be exactly equal to " "``(A, B, C)``." msgstr "" -#: ../../reference/datamodel.rst:1250 +#: ../../reference/datamodel.rst:1258 msgid "" "The single base class in the inheritance chain that is responsible for the " "memory layout of instances. This attribute corresponds to :c:member:" "`~PyTypeObject.tp_base` at the C level." msgstr "" -#: ../../reference/datamodel.rst:1255 +#: ../../reference/datamodel.rst:1263 msgid "" "The class's documentation string, or ``None`` if undefined. Not inherited by " "subclasses." msgstr "" -#: ../../reference/datamodel.rst:1259 +#: ../../reference/datamodel.rst:1267 msgid "" "A dictionary containing :term:`variable annotations ` " "collected during class body execution. See also: :attr:`__annotations__ " "attributes `." msgstr "" -#: ../../reference/datamodel.rst:1264 +#: ../../reference/datamodel.rst:1272 msgid "" "For best practices on working with :attr:`~object.__annotations__`, please " "see :mod:`annotationlib`. Use :func:`annotationlib.get_annotations` instead " "of accessing this attribute directly." msgstr "" -#: ../../reference/datamodel.rst:1271 +#: ../../reference/datamodel.rst:1279 msgid "" "Accessing the :attr:`!__annotations__` attribute directly on a class object " "may return annotations for the wrong class, specifically in certain cases " @@ -1505,69 +1504,69 @@ msgid "" "details." msgstr "" -#: ../../reference/datamodel.rst:1277 +#: ../../reference/datamodel.rst:1285 msgid "" "This attribute does not exist on certain builtin classes. On user-defined " "classes without ``__annotations__``, it is an empty dictionary." msgstr "" -#: ../../reference/datamodel.rst:1286 +#: ../../reference/datamodel.rst:1294 msgid "" "The :term:`annotate function` for this class, or ``None`` if the class has " "no annotations. See also: :attr:`__annotate__ attributes `." msgstr "" -#: ../../reference/datamodel.rst:1293 +#: ../../reference/datamodel.rst:1301 msgid "" "A :class:`tuple` containing the :ref:`type parameters ` of a :" "ref:`generic class `." msgstr "" -#: ../../reference/datamodel.rst:1299 +#: ../../reference/datamodel.rst:1307 msgid "" "A :class:`tuple` containing names of attributes of this class which are " "assigned through ``self.X`` from any function in its body." msgstr "" -#: ../../reference/datamodel.rst:1305 +#: ../../reference/datamodel.rst:1313 msgid "" "The line number of the first line of the class definition, including " "decorators. Setting the :attr:`~type.__module__` attribute removes the :attr:" "`!__firstlineno__` item from the type's dictionary." msgstr "" -#: ../../reference/datamodel.rst:1313 +#: ../../reference/datamodel.rst:1321 msgid "" "The :class:`tuple` of classes that are considered when looking for base " "classes during method resolution." msgstr "" -#: ../../reference/datamodel.rst:1318 +#: ../../reference/datamodel.rst:1326 msgid "Special methods" msgstr "特殊方法" -#: ../../reference/datamodel.rst:1320 +#: ../../reference/datamodel.rst:1328 msgid "" "In addition to the special attributes described above, all Python classes " "also have the following two methods available:" msgstr "" -#: ../../reference/datamodel.rst:1325 +#: ../../reference/datamodel.rst:1333 msgid "" "This method can be overridden by a metaclass to customize the method " "resolution order for its instances. It is called at class instantiation, " "and its result is stored in :attr:`~type.__mro__`." msgstr "" -#: ../../reference/datamodel.rst:1331 +#: ../../reference/datamodel.rst:1339 msgid "" "Each class keeps a list of weak references to its immediate subclasses. This " "method returns a list of all those references still alive. The list is in " "definition order. Example:" msgstr "" -#: ../../reference/datamodel.rst:1335 +#: ../../reference/datamodel.rst:1343 msgid "" ">>> class A: pass\n" ">>> class B(A): pass\n" @@ -1579,11 +1578,11 @@ msgstr "" ">>> A.__subclasses__()\n" "[]" -#: ../../reference/datamodel.rst:1343 +#: ../../reference/datamodel.rst:1351 msgid "Class instances" msgstr "類別實例" -#: ../../reference/datamodel.rst:1351 +#: ../../reference/datamodel.rst:1359 msgid "" "A class instance is created by calling a class object (see above). A class " "instance has a namespace implemented as a dictionary which is the first " @@ -1600,7 +1599,7 @@ msgid "" "__getattr__` method, that is called to satisfy the lookup." msgstr "" -#: ../../reference/datamodel.rst:1367 +#: ../../reference/datamodel.rst:1375 msgid "" "Attribute assignments and deletions update the instance's dictionary, never " "a class's dictionary. If the class has a :meth:`~object.__setattr__` or :" @@ -1608,28 +1607,28 @@ msgid "" "instance dictionary directly." msgstr "" -#: ../../reference/datamodel.rst:1377 +#: ../../reference/datamodel.rst:1385 msgid "" "Class instances can pretend to be numbers, sequences, or mappings if they " "have methods with certain special names. See section :ref:`specialnames`." msgstr "" -#: ../../reference/datamodel.rst:1389 +#: ../../reference/datamodel.rst:1397 msgid "The class to which a class instance belongs." msgstr "" -#: ../../reference/datamodel.rst:1393 +#: ../../reference/datamodel.rst:1401 msgid "" "A dictionary or other mapping object used to store an object's (writable) " "attributes. Not all instances have a :attr:`!__dict__` attribute; see the " "section on :ref:`slots` for more details." msgstr "" -#: ../../reference/datamodel.rst:1399 +#: ../../reference/datamodel.rst:1407 msgid "I/O objects (also known as file objects)" msgstr "" -#: ../../reference/datamodel.rst:1414 +#: ../../reference/datamodel.rst:1422 msgid "" "A :term:`file object` represents an open file. Various shortcuts are " "available to create file objects: the :func:`open` built-in function, and " @@ -1638,13 +1637,13 @@ msgid "" "methods provided by extension modules)." msgstr "" -#: ../../reference/datamodel.rst:1420 +#: ../../reference/datamodel.rst:1428 msgid "" "File objects implement common methods, listed below, to simplify usage in " "generic code. They are expected to be :ref:`context-managers`." msgstr "" -#: ../../reference/datamodel.rst:1423 +#: ../../reference/datamodel.rst:1431 msgid "" "The objects ``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` are initialized " "to file objects corresponding to the interpreter's standard input, output " @@ -1652,36 +1651,36 @@ msgid "" "interface defined by the :class:`io.TextIOBase` abstract class." msgstr "" -#: ../../reference/datamodel.rst:1431 +#: ../../reference/datamodel.rst:1439 msgid "" "Retrieve up to *size* data from the file. As a convenience if *size* is " "unspecified or -1 retrieve all data available." msgstr "" -#: ../../reference/datamodel.rst:1436 +#: ../../reference/datamodel.rst:1444 msgid "Store *data* to the file." msgstr "" -#: ../../reference/datamodel.rst:1440 +#: ../../reference/datamodel.rst:1448 msgid "Flush any buffers and close the underlying file." msgstr "" -#: ../../reference/datamodel.rst:1444 +#: ../../reference/datamodel.rst:1452 msgid "Internal types" msgstr "" -#: ../../reference/datamodel.rst:1450 +#: ../../reference/datamodel.rst:1458 msgid "" "A few types used internally by the interpreter are exposed to the user. " "Their definitions may change with future versions of the interpreter, but " "they are mentioned here for completeness." msgstr "" -#: ../../reference/datamodel.rst:1458 +#: ../../reference/datamodel.rst:1466 msgid "Code objects" msgstr "程式碼物件" -#: ../../reference/datamodel.rst:1462 +#: ../../reference/datamodel.rst:1470 msgid "" "Code objects represent *byte-compiled* executable Python code, or :term:" "`bytecode`. The difference between a code object and a function object is " @@ -1693,102 +1692,90 @@ msgid "" "no references (directly or indirectly) to mutable objects." msgstr "" -#: ../../reference/datamodel.rst:1496 +#: ../../reference/datamodel.rst:1503 msgid "The function name" msgstr "函式名稱" -#: ../../reference/datamodel.rst:1499 +#: ../../reference/datamodel.rst:1506 msgid "The fully qualified function name" msgstr "" -#: ../../reference/datamodel.rst:1504 +#: ../../reference/datamodel.rst:1511 msgid "" "The total number of positional :term:`parameters ` (including " "positional-only parameters and parameters with default values) that the " "function has" msgstr "" -#: ../../reference/datamodel.rst:1509 +#: ../../reference/datamodel.rst:1516 msgid "" "The number of positional-only :term:`parameters ` (including " "arguments with default values) that the function has" msgstr "" -#: ../../reference/datamodel.rst:1513 +#: ../../reference/datamodel.rst:1520 msgid "" "The number of keyword-only :term:`parameters ` (including " "arguments with default values) that the function has" msgstr "" -#: ../../reference/datamodel.rst:1517 +#: ../../reference/datamodel.rst:1524 msgid "" "The number of :ref:`local variables ` used by the function " "(including parameters)" msgstr "" -#: ../../reference/datamodel.rst:1521 +#: ../../reference/datamodel.rst:1528 msgid "" "A :class:`tuple` containing the names of the local variables in the function " "(starting with the parameter names)" msgstr "" -#: ../../reference/datamodel.rst:1525 +#: ../../reference/datamodel.rst:1532 msgid "" "A :class:`tuple` containing the names of :ref:`local variables ` " "that are referenced from at least one :term:`nested scope` inside the " "function" msgstr "" -#: ../../reference/datamodel.rst:1529 +#: ../../reference/datamodel.rst:1536 msgid "" "A :class:`tuple` containing the names of :term:`free (closure) variables " "` that a :term:`nested scope` references in an outer " "scope. See also :attr:`function.__closure__`." msgstr "" -#: ../../reference/datamodel.rst:1533 +#: ../../reference/datamodel.rst:1540 msgid "Note: references to global and builtin names are *not* included." msgstr "" -#: ../../reference/datamodel.rst:1536 +#: ../../reference/datamodel.rst:1543 msgid "" "A string representing the sequence of :term:`bytecode` instructions in the " "function" msgstr "" -#: ../../reference/datamodel.rst:1540 +#: ../../reference/datamodel.rst:1547 msgid "" "A :class:`tuple` containing the literals used by the :term:`bytecode` in the " "function" msgstr "" -#: ../../reference/datamodel.rst:1544 +#: ../../reference/datamodel.rst:1551 msgid "" "A :class:`tuple` containing the names used by the :term:`bytecode` in the " "function" msgstr "" -#: ../../reference/datamodel.rst:1548 +#: ../../reference/datamodel.rst:1555 msgid "The name of the file from which the code was compiled" msgstr "" -#: ../../reference/datamodel.rst:1551 +#: ../../reference/datamodel.rst:1558 msgid "The line number of the first line of the function" msgstr "" -#: ../../reference/datamodel.rst:1554 -msgid "" -"A string encoding the mapping from :term:`bytecode` offsets to line numbers. " -"For details, see the source code of the interpreter." -msgstr "" - -#: ../../reference/datamodel.rst:1557 -msgid "" -"This attribute of code objects is deprecated, and may be removed in Python " -"3.15." -msgstr "" - -#: ../../reference/datamodel.rst:1562 +#: ../../reference/datamodel.rst:1561 msgid "" "A :class:`bytes` object containing encoded source location information. The " "exact format is an implementation detail and may change between Python " @@ -1797,16 +1784,16 @@ msgid "" "create a modified copy of a code object, use :meth:`~codeobject.replace`." msgstr "" -#: ../../reference/datamodel.rst:1572 +#: ../../reference/datamodel.rst:1571 msgid "The required stack size of the code object" msgstr "" -#: ../../reference/datamodel.rst:1575 +#: ../../reference/datamodel.rst:1574 msgid "" "An :class:`integer ` encoding a number of flags for the interpreter." msgstr "" -#: ../../reference/datamodel.rst:1580 +#: ../../reference/datamodel.rst:1579 msgid "" "The following flag bits are defined for :attr:`~codeobject.co_flags`: bit " "``0x04`` is set if the function uses the ``*arguments`` syntax to accept an " @@ -1817,7 +1804,7 @@ msgid "" "might be present." msgstr "" -#: ../../reference/datamodel.rst:1588 +#: ../../reference/datamodel.rst:1587 msgid "" "Future feature declarations (for example, ``from __future__ import " "division``) also use bits in :attr:`~codeobject.co_flags` to indicate " @@ -1825,12 +1812,12 @@ msgid "" "attr:`~__future__._Feature.compiler_flag`." msgstr "" -#: ../../reference/datamodel.rst:1592 +#: ../../reference/datamodel.rst:1591 msgid "" "Other bits in :attr:`~codeobject.co_flags` are reserved for internal use." msgstr "" -#: ../../reference/datamodel.rst:1596 +#: ../../reference/datamodel.rst:1595 msgid "" "If a code object represents a function and has a docstring, the :data:" "`~inspect.CO_HAS_DOCSTRING` bit is set in :attr:`~codeobject.co_flags` and " @@ -1838,17 +1825,17 @@ msgid "" "function." msgstr "" -#: ../../reference/datamodel.rst:1602 +#: ../../reference/datamodel.rst:1601 msgid "Methods on code objects" msgstr "用於程式碼物件的方法" -#: ../../reference/datamodel.rst:1606 +#: ../../reference/datamodel.rst:1605 msgid "" "Returns an iterable over the source code positions of each :term:`bytecode` " "instruction in the code object." msgstr "" -#: ../../reference/datamodel.rst:1609 +#: ../../reference/datamodel.rst:1608 msgid "" "The iterator returns :class:`tuple`\\s containing the ``(start_line, " "end_line, start_column, end_column)``. The *i-th* tuple corresponds to the " @@ -1856,37 +1843,37 @@ msgid "" "information is 0-indexed utf-8 byte offsets on the given source line." msgstr "" -#: ../../reference/datamodel.rst:1615 +#: ../../reference/datamodel.rst:1614 msgid "" "This positional information can be missing. A non-exhaustive lists of cases " "where this may happen:" msgstr "" -#: ../../reference/datamodel.rst:1618 +#: ../../reference/datamodel.rst:1617 msgid "Running the interpreter with :option:`-X` ``no_debug_ranges``." msgstr "" -#: ../../reference/datamodel.rst:1619 +#: ../../reference/datamodel.rst:1618 msgid "" "Loading a pyc file compiled while using :option:`-X` ``no_debug_ranges``." msgstr "" -#: ../../reference/datamodel.rst:1620 +#: ../../reference/datamodel.rst:1619 msgid "Position tuples corresponding to artificial instructions." msgstr "" -#: ../../reference/datamodel.rst:1621 +#: ../../reference/datamodel.rst:1620 msgid "" "Line and column numbers that can't be represented due to implementation " "specific limitations." msgstr "" -#: ../../reference/datamodel.rst:1624 +#: ../../reference/datamodel.rst:1623 msgid "" "When this occurs, some or all of the tuple elements can be :const:`None`." msgstr "" -#: ../../reference/datamodel.rst:1630 +#: ../../reference/datamodel.rst:1629 msgid "" "This feature requires storing column positions in code objects which may " "result in a small increase of disk usage of compiled Python files or " @@ -1896,100 +1883,100 @@ msgid "" "environment variable can be used." msgstr "" -#: ../../reference/datamodel.rst:1639 +#: ../../reference/datamodel.rst:1638 msgid "" "Returns an iterator that yields information about successive ranges of :term:" "`bytecode`\\s. Each item yielded is a ``(start, end, lineno)`` :class:" "`tuple`:" msgstr "" -#: ../../reference/datamodel.rst:1643 +#: ../../reference/datamodel.rst:1642 msgid "" "``start`` (an :class:`int`) represents the offset (inclusive) of the start " "of the :term:`bytecode` range" msgstr "" -#: ../../reference/datamodel.rst:1645 +#: ../../reference/datamodel.rst:1644 msgid "" "``end`` (an :class:`int`) represents the offset (exclusive) of the end of " "the :term:`bytecode` range" msgstr "" -#: ../../reference/datamodel.rst:1647 +#: ../../reference/datamodel.rst:1646 msgid "" "``lineno`` is an :class:`int` representing the line number of the :term:" "`bytecode` range, or ``None`` if the bytecodes in the given range have no " "line number" msgstr "" -#: ../../reference/datamodel.rst:1651 +#: ../../reference/datamodel.rst:1650 msgid "The items yielded will have the following properties:" msgstr "" -#: ../../reference/datamodel.rst:1653 +#: ../../reference/datamodel.rst:1652 msgid "The first range yielded will have a ``start`` of 0." msgstr "" -#: ../../reference/datamodel.rst:1654 +#: ../../reference/datamodel.rst:1653 msgid "" "The ``(start, end)`` ranges will be non-decreasing and consecutive. That is, " "for any pair of :class:`tuple`\\s, the ``start`` of the second will be equal " "to the ``end`` of the first." msgstr "" -#: ../../reference/datamodel.rst:1657 +#: ../../reference/datamodel.rst:1656 msgid "No range will be backwards: ``end >= start`` for all triples." msgstr "" -#: ../../reference/datamodel.rst:1658 +#: ../../reference/datamodel.rst:1657 msgid "" "The last :class:`tuple` yielded will have ``end`` equal to the size of the :" "term:`bytecode`." msgstr "" -#: ../../reference/datamodel.rst:1661 +#: ../../reference/datamodel.rst:1660 msgid "" "Zero-width ranges, where ``start == end``, are allowed. Zero-width ranges " "are used for lines that are present in the source code, but have been " "eliminated by the :term:`bytecode` compiler." msgstr "" -#: ../../reference/datamodel.rst:1669 +#: ../../reference/datamodel.rst:1668 msgid ":pep:`626` - Precise line numbers for debugging and other tools." msgstr "" -#: ../../reference/datamodel.rst:1670 +#: ../../reference/datamodel.rst:1669 msgid "The PEP that introduced the :meth:`!co_lines` method." msgstr "" -#: ../../reference/datamodel.rst:1674 +#: ../../reference/datamodel.rst:1673 msgid "" "Return a copy of the code object with new values for the specified fields." msgstr "" -#: ../../reference/datamodel.rst:1676 +#: ../../reference/datamodel.rst:1675 msgid "" "Code objects are also supported by the generic function :func:`copy.replace`." msgstr "" -#: ../../reference/datamodel.rst:1684 +#: ../../reference/datamodel.rst:1683 msgid "Frame objects" msgstr "" -#: ../../reference/datamodel.rst:1688 +#: ../../reference/datamodel.rst:1687 msgid "" "Frame objects represent execution frames. They may occur in :ref:`traceback " "objects `, and are also passed to registered trace " "functions." msgstr "" -#: ../../reference/datamodel.rst:1707 +#: ../../reference/datamodel.rst:1706 msgid "" "Points to the previous stack frame (towards the caller), or ``None`` if this " "is the bottom stack frame" msgstr "" -#: ../../reference/datamodel.rst:1711 +#: ../../reference/datamodel.rst:1710 msgid "" "The :ref:`code object ` being executed in this frame. " "Accessing this attribute raises an :ref:`auditing event ` ``object." @@ -1999,61 +1986,61 @@ msgstr "" "這個屬性會引發一個附帶引數 ``obj`` 與 ``\"f_code\"`` 的\\ :ref:`稽核事件 " "` ``object.__getattr__``。" -#: ../../reference/datamodel.rst:1716 +#: ../../reference/datamodel.rst:1715 msgid "" "The mapping used by the frame to look up :ref:`local variables `. If " "the frame refers to an :term:`optimized scope`, this may return a write-" "through proxy object." msgstr "" -#: ../../reference/datamodel.rst:1721 +#: ../../reference/datamodel.rst:1720 msgid "Return a proxy for optimized scopes." msgstr "" -#: ../../reference/datamodel.rst:1725 +#: ../../reference/datamodel.rst:1724 msgid "" "The dictionary used by the frame to look up :ref:`global variables `" msgstr "" -#: ../../reference/datamodel.rst:1729 +#: ../../reference/datamodel.rst:1728 msgid "" "The dictionary used by the frame to look up :ref:`built-in (intrinsic) names " "`" msgstr "" -#: ../../reference/datamodel.rst:1733 +#: ../../reference/datamodel.rst:1732 msgid "" "The \"precise instruction\" of the frame object (this is an index into the :" "term:`bytecode` string of the :ref:`code object `)" msgstr "" -#: ../../reference/datamodel.rst:1738 +#: ../../reference/datamodel.rst:1737 msgid "" "The :term:`generator` or :term:`coroutine` object that owns this frame, or " "``None`` if the frame is a normal function." msgstr "" -#: ../../reference/datamodel.rst:1755 +#: ../../reference/datamodel.rst:1754 msgid "" "If not ``None``, this is a function called for various events during code " "execution (this is used by debuggers). Normally an event is triggered for " "each new source line (see :attr:`~frame.f_trace_lines`)." msgstr "" -#: ../../reference/datamodel.rst:1760 +#: ../../reference/datamodel.rst:1759 msgid "" "Set this attribute to :const:`False` to disable triggering a tracing event " "for each source line." msgstr "" -#: ../../reference/datamodel.rst:1764 +#: ../../reference/datamodel.rst:1763 msgid "" "Set this attribute to :const:`True` to allow per-opcode events to be " "requested. Note that this may lead to undefined interpreter behaviour if " "exceptions raised by the trace function escape to the function being traced." msgstr "" -#: ../../reference/datamodel.rst:1770 +#: ../../reference/datamodel.rst:1769 msgid "" "The current line number of the frame -- writing to this from within a trace " "function jumps to the given line (only for the bottom-most frame). A " @@ -2061,15 +2048,15 @@ msgid "" "this attribute." msgstr "" -#: ../../reference/datamodel.rst:1776 +#: ../../reference/datamodel.rst:1775 msgid "Frame object methods" msgstr "" -#: ../../reference/datamodel.rst:1778 +#: ../../reference/datamodel.rst:1777 msgid "Frame objects support one method:" msgstr "" -#: ../../reference/datamodel.rst:1782 +#: ../../reference/datamodel.rst:1781 msgid "" "This method clears all references to :ref:`local variables ` held by " "the frame. Also, if the frame belonged to a :term:`generator`, the " @@ -2078,34 +2065,34 @@ msgid "" "and storing its :ref:`traceback ` for later use)." msgstr "" -#: ../../reference/datamodel.rst:1788 +#: ../../reference/datamodel.rst:1787 msgid "" ":exc:`RuntimeError` is raised if the frame is currently executing or " "suspended." msgstr "" -#: ../../reference/datamodel.rst:1793 +#: ../../reference/datamodel.rst:1792 msgid "" "Attempting to clear a suspended frame raises :exc:`RuntimeError` (as has " "always been the case for executing frames)." msgstr "" -#: ../../reference/datamodel.rst:1801 +#: ../../reference/datamodel.rst:1800 msgid "Traceback objects" msgstr "" -#: ../../reference/datamodel.rst:1814 +#: ../../reference/datamodel.rst:1813 msgid "" "Traceback objects represent the stack trace of an :ref:`exception `. A traceback object is implicitly created when an exception occurs, " "and may also be explicitly created by calling :class:`types.TracebackType`." msgstr "" -#: ../../reference/datamodel.rst:1819 +#: ../../reference/datamodel.rst:1818 msgid "Traceback objects can now be explicitly instantiated from Python code." msgstr "" -#: ../../reference/datamodel.rst:1822 +#: ../../reference/datamodel.rst:1821 msgid "" "For implicitly created tracebacks, when the search for an exception handler " "unwinds the execution stack, at each unwound level a traceback object is " @@ -2116,7 +2103,7 @@ msgid "" "the caught exception." msgstr "" -#: ../../reference/datamodel.rst:1831 +#: ../../reference/datamodel.rst:1830 msgid "" "When the program contains no suitable handler, the stack trace is written " "(nicely formatted) to the standard error stream; if the interpreter is " @@ -2124,19 +2111,19 @@ msgid "" "last_traceback`." msgstr "" -#: ../../reference/datamodel.rst:1836 +#: ../../reference/datamodel.rst:1835 msgid "" "For explicitly created tracebacks, it is up to the creator of the traceback " "to determine how the :attr:`~traceback.tb_next` attributes should be linked " "to form a full stack trace." msgstr "" -#: ../../reference/datamodel.rst:1851 +#: ../../reference/datamodel.rst:1850 msgid "" "Points to the execution :ref:`frame ` of the current level." msgstr "" -#: ../../reference/datamodel.rst:1854 +#: ../../reference/datamodel.rst:1853 msgid "" "Accessing this attribute raises an :ref:`auditing event ` ``object." "__getattr__`` with arguments ``obj`` and ``\"tb_frame\"``." @@ -2144,15 +2131,15 @@ msgstr "" "存取此屬性會引發一個附帶引數 ``obj`` 與 ``\"tb_frame\"`` 的\\ :ref:`稽核事件 " "` ``object.__getattr__``。" -#: ../../reference/datamodel.rst:1859 +#: ../../reference/datamodel.rst:1858 msgid "Gives the line number where the exception occurred" msgstr "" -#: ../../reference/datamodel.rst:1862 +#: ../../reference/datamodel.rst:1861 msgid "Indicates the \"precise instruction\"." msgstr "" -#: ../../reference/datamodel.rst:1864 +#: ../../reference/datamodel.rst:1863 msgid "" "The line number and last instruction in the traceback may differ from the " "line number of its :ref:`frame object ` if the exception " @@ -2160,39 +2147,46 @@ msgid "" "with a :keyword:`finally` clause." msgstr "" -#: ../../reference/datamodel.rst:1875 +#: ../../reference/datamodel.rst:1874 msgid "" "The special writable attribute :attr:`!tb_next` is the next level in the " "stack trace (towards the frame where the exception occurred), or ``None`` if " "there is no next level." msgstr "" -#: ../../reference/datamodel.rst:1879 +#: ../../reference/datamodel.rst:1878 msgid "This attribute is now writable" msgstr "此屬性現在可寫入" -#: ../../reference/datamodel.rst:1884 +#: ../../reference/datamodel.rst:1883 msgid "Slice objects" msgstr "" -#: ../../reference/datamodel.rst:1888 +#: ../../reference/datamodel.rst:1887 msgid "" "Slice objects are used to represent slices for :meth:`~object.__getitem__` " "methods. They are also created by the built-in :func:`slice` function." msgstr "" -#: ../../reference/datamodel.rst:1897 +#: ../../reference/datamodel.rst:1893 +msgid "" +"The :func:`slice` type now supports :ref:`subscription `. For " +"example, ``slice[float]`` may be used in type annotations to indicate a " +"slice containing :type:`float` objects." +msgstr "" + +#: ../../reference/datamodel.rst:1902 msgid "" "Special read-only attributes: :attr:`~slice.start` is the lower bound; :attr:" "`~slice.stop` is the upper bound; :attr:`~slice.step` is the step value; " "each is ``None`` if omitted. These attributes can have any type." msgstr "" -#: ../../reference/datamodel.rst:1901 +#: ../../reference/datamodel.rst:1906 msgid "Slice objects support one method:" msgstr "" -#: ../../reference/datamodel.rst:1905 +#: ../../reference/datamodel.rst:1910 msgid "" "This method takes a single integer argument *length* and computes " "information about the slice that the slice object would describe if applied " @@ -2202,11 +2196,11 @@ msgid "" "a manner consistent with regular slices." msgstr "" -#: ../../reference/datamodel.rst:1914 +#: ../../reference/datamodel.rst:1919 msgid "Static method objects" msgstr "" -#: ../../reference/datamodel.rst:1916 +#: ../../reference/datamodel.rst:1921 msgid "" "Static method objects provide a way of defeating the transformation of " "function objects to method objects described above. A static method object " @@ -2217,11 +2211,11 @@ msgid "" "method objects are created by the built-in :func:`staticmethod` constructor." msgstr "" -#: ../../reference/datamodel.rst:1926 +#: ../../reference/datamodel.rst:1931 msgid "Class method objects" msgstr "" -#: ../../reference/datamodel.rst:1928 +#: ../../reference/datamodel.rst:1933 msgid "" "A class method object, like a static method object, is a wrapper around " "another object that alters the way in which that object is retrieved from " @@ -2231,11 +2225,11 @@ msgid "" "`classmethod` constructor." msgstr "" -#: ../../reference/datamodel.rst:1938 +#: ../../reference/datamodel.rst:1943 msgid "Special method names" msgstr "" -#: ../../reference/datamodel.rst:1944 +#: ../../reference/datamodel.rst:1949 msgid "" "A class can implement certain operations that are invoked by special syntax " "(such as arithmetic operations or subscripting and slicing) by defining " @@ -2249,7 +2243,7 @@ msgid "" "`TypeError`)." msgstr "" -#: ../../reference/datamodel.rst:1955 +#: ../../reference/datamodel.rst:1960 msgid "" "Setting a special method to ``None`` indicates that the corresponding " "operation is not available. For example, if a class sets :meth:`~object." @@ -2258,7 +2252,7 @@ msgid "" "`~object.__getitem__`). [#]_" msgstr "" -#: ../../reference/datamodel.rst:1961 +#: ../../reference/datamodel.rst:1966 msgid "" "When implementing a class that emulates any built-in type, it is important " "that the emulation only be implemented to the degree that it makes sense for " @@ -2268,11 +2262,11 @@ msgid "" "in the W3C's Document Object Model.)" msgstr "" -#: ../../reference/datamodel.rst:1972 +#: ../../reference/datamodel.rst:1977 msgid "Basic customization" msgstr "" -#: ../../reference/datamodel.rst:1978 +#: ../../reference/datamodel.rst:1983 msgid "" "Called to create a new instance of class *cls*. :meth:`__new__` is a static " "method (special-cased so you need not declare it as such) that takes the " @@ -2282,7 +2276,7 @@ msgid "" "new object instance (usually an instance of *cls*)." msgstr "" -#: ../../reference/datamodel.rst:1985 +#: ../../reference/datamodel.rst:1990 msgid "" "Typical implementations create a new instance of the class by invoking the " "superclass's :meth:`__new__` method using ``super().__new__(cls[, ...])`` " @@ -2290,7 +2284,7 @@ msgid "" "necessary before returning it." msgstr "" -#: ../../reference/datamodel.rst:1990 +#: ../../reference/datamodel.rst:1995 msgid "" "If :meth:`__new__` is invoked during object construction and it returns an " "instance of *cls*, then the new instance’s :meth:`__init__` method will be " @@ -2299,13 +2293,13 @@ msgid "" "constructor." msgstr "" -#: ../../reference/datamodel.rst:1995 +#: ../../reference/datamodel.rst:2000 msgid "" "If :meth:`__new__` does not return an instance of *cls*, then the new " "instance's :meth:`__init__` method will not be invoked." msgstr "" -#: ../../reference/datamodel.rst:1998 +#: ../../reference/datamodel.rst:2003 msgid "" ":meth:`__new__` is intended mainly to allow subclasses of immutable types " "(like int, str, or tuple) to customize instance creation. It is also " @@ -2313,7 +2307,7 @@ msgid "" "creation." msgstr "" -#: ../../reference/datamodel.rst:2007 +#: ../../reference/datamodel.rst:2012 msgid "" "Called after the instance has been created (by :meth:`__new__`), but before " "it is returned to the caller. The arguments are those passed to the class " @@ -2323,7 +2317,7 @@ msgid "" "example: ``super().__init__([args...])``." msgstr "" -#: ../../reference/datamodel.rst:2014 +#: ../../reference/datamodel.rst:2019 msgid "" "Because :meth:`__new__` and :meth:`__init__` work together in constructing " "objects (:meth:`__new__` to create it, and :meth:`__init__` to customize " @@ -2331,7 +2325,7 @@ msgid "" "will cause a :exc:`TypeError` to be raised at runtime." msgstr "" -#: ../../reference/datamodel.rst:2027 +#: ../../reference/datamodel.rst:2032 msgid "" "Called when the instance is about to be destroyed. This is also called a " "finalizer or (improperly) a destructor. If a base class has a :meth:" @@ -2340,7 +2334,7 @@ msgid "" "instance." msgstr "" -#: ../../reference/datamodel.rst:2033 +#: ../../reference/datamodel.rst:2038 msgid "" "It is possible (though not recommended!) for the :meth:`__del__` method to " "postpone destruction of the instance by creating a new reference to it. " @@ -2350,7 +2344,7 @@ msgid "" "it once." msgstr "" -#: ../../reference/datamodel.rst:2040 +#: ../../reference/datamodel.rst:2045 msgid "" "It is not guaranteed that :meth:`__del__` methods are called for objects " "that still exist when the interpreter exits. :class:`weakref.finalize` " @@ -2358,14 +2352,14 @@ msgid "" "when an object is garbage collected." msgstr "" -#: ../../reference/datamodel.rst:2047 +#: ../../reference/datamodel.rst:2052 msgid "" "``del x`` doesn't directly call ``x.__del__()`` --- the former decrements " "the reference count for ``x`` by one, and the latter is only called when " "``x``'s reference count reaches zero." msgstr "" -#: ../../reference/datamodel.rst:2052 +#: ../../reference/datamodel.rst:2057 msgid "" "It is possible for a reference cycle to prevent the reference count of an " "object from going to zero. In this case, the cycle will be later detected " @@ -2376,18 +2370,18 @@ msgid "" "caught in the traceback." msgstr "" -#: ../../reference/datamodel.rst:2062 +#: ../../reference/datamodel.rst:2067 msgid "Documentation for the :mod:`gc` module." msgstr ":mod:`gc` 模組的文件。" -#: ../../reference/datamodel.rst:2066 +#: ../../reference/datamodel.rst:2071 msgid "" "Due to the precarious circumstances under which :meth:`__del__` methods are " "invoked, exceptions that occur during their execution are ignored, and a " "warning is printed to ``sys.stderr`` instead. In particular:" msgstr "" -#: ../../reference/datamodel.rst:2070 +#: ../../reference/datamodel.rst:2075 msgid "" ":meth:`__del__` can be invoked when arbitrary code is being executed, " "including from any arbitrary thread. If :meth:`__del__` needs to take a " @@ -2396,7 +2390,7 @@ msgid "" "`__del__`." msgstr "" -#: ../../reference/datamodel.rst:2076 +#: ../../reference/datamodel.rst:2081 msgid "" ":meth:`__del__` can be executed during interpreter shutdown. As a " "consequence, the global variables it needs to access (including other " @@ -2407,7 +2401,7 @@ msgid "" "still available at the time when the :meth:`__del__` method is called." msgstr "" -#: ../../reference/datamodel.rst:2091 +#: ../../reference/datamodel.rst:2096 msgid "" "Called by the :func:`repr` built-in function to compute the \"official\" " "string representation of an object. If at all possible, this should look " @@ -2419,14 +2413,14 @@ msgid "" "an \"informal\" string representation of instances of that class is required." msgstr "" -#: ../../reference/datamodel.rst:2100 +#: ../../reference/datamodel.rst:2105 msgid "" "This is typically used for debugging, so it is important that the " "representation is information-rich and unambiguous. A default implementation " "is provided by the :class:`object` class itself." msgstr "" -#: ../../reference/datamodel.rst:2112 +#: ../../reference/datamodel.rst:2117 msgid "" "Called by :func:`str(object) `, the default :meth:`__format__` " "implementation, and the built-in function :func:`print`, to compute the " @@ -2434,27 +2428,27 @@ msgid "" "return value must be a :ref:`str ` object." msgstr "" -#: ../../reference/datamodel.rst:2117 +#: ../../reference/datamodel.rst:2122 msgid "" "This method differs from :meth:`object.__repr__` in that there is no " "expectation that :meth:`__str__` return a valid Python expression: a more " "convenient or concise representation can be used." msgstr "" -#: ../../reference/datamodel.rst:2121 +#: ../../reference/datamodel.rst:2126 msgid "" "The default implementation defined by the built-in type :class:`object` " "calls :meth:`object.__repr__`." msgstr "" -#: ../../reference/datamodel.rst:2131 +#: ../../reference/datamodel.rst:2136 msgid "" "Called by :ref:`bytes ` to compute a byte-string representation " "of an object. This should return a :class:`bytes` object. The :class:" "`object` class itself does not provide this method." msgstr "" -#: ../../reference/datamodel.rst:2143 +#: ../../reference/datamodel.rst:2148 msgid "" "Called by the :func:`format` built-in function, and by extension, evaluation " "of :ref:`formatted string literals ` and the :meth:`str.format` " @@ -2466,34 +2460,34 @@ msgid "" "formatting option syntax." msgstr "" -#: ../../reference/datamodel.rst:2153 +#: ../../reference/datamodel.rst:2158 msgid "" "See :ref:`formatspec` for a description of the standard formatting syntax." msgstr "" -#: ../../reference/datamodel.rst:2155 +#: ../../reference/datamodel.rst:2160 msgid "The return value must be a string object." msgstr "回傳值必須是個字串物件。" -#: ../../reference/datamodel.rst:2157 +#: ../../reference/datamodel.rst:2162 msgid "" "The default implementation by the :class:`object` class should be given an " "empty *format_spec* string. It delegates to :meth:`__str__`." msgstr "" -#: ../../reference/datamodel.rst:2160 +#: ../../reference/datamodel.rst:2165 msgid "" "The __format__ method of ``object`` itself raises a :exc:`TypeError` if " "passed any non-empty string." msgstr "" -#: ../../reference/datamodel.rst:2164 +#: ../../reference/datamodel.rst:2169 msgid "" "``object.__format__(x, '')`` is now equivalent to ``str(x)`` rather than " "``format(str(x), '')``." msgstr "" -#: ../../reference/datamodel.rst:2180 +#: ../../reference/datamodel.rst:2185 msgid "" "These are the so-called \"rich comparison\" methods. The correspondence " "between operator symbols and method names is as follows: ``x.__hash__``." msgstr "" -#: ../../reference/datamodel.rst:2278 +#: ../../reference/datamodel.rst:2283 msgid "" "If a class that does not override :meth:`__eq__` wishes to suppress hash " "support, it should include ``__hash__ = None`` in the class definition. A " @@ -2637,7 +2631,7 @@ msgid "" "``isinstance(obj, collections.abc.Hashable)`` call." msgstr "" -#: ../../reference/datamodel.rst:2287 +#: ../../reference/datamodel.rst:2292 msgid "" "By default, the :meth:`__hash__` values of str and bytes objects are " "\"salted\" with an unpredictable random value. Although they remain " @@ -2645,7 +2639,7 @@ msgid "" "between repeated invocations of Python." msgstr "" -#: ../../reference/datamodel.rst:2292 +#: ../../reference/datamodel.rst:2297 msgid "" "This is intended to provide protection against a denial-of-service caused by " "carefully chosen inputs that exploit the worst case performance of a dict " @@ -2653,22 +2647,22 @@ msgid "" "advisories/ocert-2011-003.html for details." msgstr "" -#: ../../reference/datamodel.rst:2297 +#: ../../reference/datamodel.rst:2302 msgid "" "Changing hash values affects the iteration order of sets. Python has never " "made guarantees about this ordering (and it typically varies between 32-bit " "and 64-bit builds)." msgstr "" -#: ../../reference/datamodel.rst:2301 +#: ../../reference/datamodel.rst:2306 msgid "See also :envvar:`PYTHONHASHSEED`." msgstr "另請參閱 :envvar:`PYTHONHASHSEED`。" -#: ../../reference/datamodel.rst:2303 +#: ../../reference/datamodel.rst:2308 msgid "Hash randomization is enabled by default." msgstr "" -#: ../../reference/datamodel.rst:2311 +#: ../../reference/datamodel.rst:2316 msgid "" "Called to implement truth value testing and the built-in operation " "``bool()``; should return ``False`` or ``True``. When this method is not " @@ -2678,18 +2672,18 @@ msgid "" "class itself), all its instances are considered true." msgstr "" -#: ../../reference/datamodel.rst:2322 +#: ../../reference/datamodel.rst:2327 msgid "Customizing attribute access" msgstr "" -#: ../../reference/datamodel.rst:2324 +#: ../../reference/datamodel.rst:2329 msgid "" "The following methods can be defined to customize the meaning of attribute " "access (use of, assignment to, or deletion of ``x.name``) for class " "instances." msgstr "" -#: ../../reference/datamodel.rst:2332 +#: ../../reference/datamodel.rst:2337 msgid "" "Called when the default attribute access fails with an :exc:`AttributeError` " "(either :meth:`__getattribute__` raises an :exc:`AttributeError` because " @@ -2700,7 +2694,7 @@ msgid "" "`object` class itself does not provide this method." msgstr "" -#: ../../reference/datamodel.rst:2340 +#: ../../reference/datamodel.rst:2345 msgid "" "Note that if the attribute is found through the normal mechanism, :meth:" "`__getattr__` is not called. (This is an intentional asymmetry between :" @@ -2713,7 +2707,7 @@ msgid "" "actually get total control over attribute access." msgstr "" -#: ../../reference/datamodel.rst:2353 +#: ../../reference/datamodel.rst:2358 msgid "" "Called unconditionally to implement attribute accesses for instances of the " "class. If the class also defines :meth:`__getattr__`, the latter will not be " @@ -2725,64 +2719,64 @@ msgid "" "example, ``object.__getattribute__(self, name)``." msgstr "" -#: ../../reference/datamodel.rst:2364 +#: ../../reference/datamodel.rst:2369 msgid "" "This method may still be bypassed when looking up special methods as the " "result of implicit invocation via language syntax or :ref:`built-in " "functions `. See :ref:`special-lookup`." msgstr "" -#: ../../reference/datamodel.rst:2369 ../../reference/datamodel.rst:2371 +#: ../../reference/datamodel.rst:2374 ../../reference/datamodel.rst:2376 msgid "" "For certain sensitive attribute accesses, raises an :ref:`auditing event " "` ``object.__getattr__`` with arguments ``obj`` and ``name``." msgstr "" -#: ../../reference/datamodel.rst:2378 +#: ../../reference/datamodel.rst:2383 msgid "" "Called when an attribute assignment is attempted. This is called instead of " "the normal mechanism (i.e. store the value in the instance dictionary). " "*name* is the attribute name, *value* is the value to be assigned to it." msgstr "" -#: ../../reference/datamodel.rst:2382 +#: ../../reference/datamodel.rst:2387 msgid "" "If :meth:`__setattr__` wants to assign to an instance attribute, it should " "call the base class method with the same name, for example, ``object." "__setattr__(self, name, value)``." msgstr "" -#: ../../reference/datamodel.rst:2386 ../../reference/datamodel.rst:2388 +#: ../../reference/datamodel.rst:2391 ../../reference/datamodel.rst:2393 msgid "" "For certain sensitive attribute assignments, raises an :ref:`auditing event " "` ``object.__setattr__`` with arguments ``obj``, ``name``, " "``value``." msgstr "" -#: ../../reference/datamodel.rst:2395 +#: ../../reference/datamodel.rst:2400 msgid "" "Like :meth:`__setattr__` but for attribute deletion instead of assignment. " "This should only be implemented if ``del obj.name`` is meaningful for the " "object." msgstr "" -#: ../../reference/datamodel.rst:2398 ../../reference/datamodel.rst:2400 +#: ../../reference/datamodel.rst:2403 ../../reference/datamodel.rst:2405 msgid "" "For certain sensitive attribute deletions, raises an :ref:`auditing event " "` ``object.__delattr__`` with arguments ``obj`` and ``name``." msgstr "" -#: ../../reference/datamodel.rst:2407 +#: ../../reference/datamodel.rst:2412 msgid "" "Called when :func:`dir` is called on the object. An iterable must be " "returned. :func:`dir` converts the returned iterable to a list and sorts it." msgstr "" -#: ../../reference/datamodel.rst:2412 +#: ../../reference/datamodel.rst:2417 msgid "Customizing module attribute access" msgstr "" -#: ../../reference/datamodel.rst:2422 +#: ../../reference/datamodel.rst:2427 msgid "" "Special names ``__getattr__`` and ``__dir__`` can be also used to customize " "access to module attributes. The ``__getattr__`` function at the module " @@ -2794,21 +2788,21 @@ msgid "" "with the attribute name and the result is returned." msgstr "" -#: ../../reference/datamodel.rst:2431 +#: ../../reference/datamodel.rst:2436 msgid "" "The ``__dir__`` function should accept no arguments, and return an iterable " "of strings that represents the names accessible on module. If present, this " "function overrides the standard :func:`dir` search on a module." msgstr "" -#: ../../reference/datamodel.rst:2437 +#: ../../reference/datamodel.rst:2442 msgid "" "For a more fine grained customization of the module behavior (setting " "attributes, properties, etc.), one can set the ``__class__`` attribute of a " "module object to a subclass of :class:`types.ModuleType`. For example::" msgstr "" -#: ../../reference/datamodel.rst:2441 +#: ../../reference/datamodel.rst:2446 msgid "" "import sys\n" "from types import ModuleType\n" @@ -2836,7 +2830,7 @@ msgstr "" "\n" "sys.modules[__name__].__class__ = VerboseModule" -#: ../../reference/datamodel.rst:2455 +#: ../../reference/datamodel.rst:2460 msgid "" "Defining module ``__getattr__`` and setting module ``__class__`` only affect " "lookups made using the attribute access syntax -- directly accessing the " @@ -2844,27 +2838,27 @@ msgid "" "module's globals dictionary) is unaffected." msgstr "" -#: ../../reference/datamodel.rst:2460 +#: ../../reference/datamodel.rst:2465 msgid "``__class__`` module attribute is now writable." msgstr "``__class__`` 模組屬性現在是可寫入的。" -#: ../../reference/datamodel.rst:2463 +#: ../../reference/datamodel.rst:2468 msgid "``__getattr__`` and ``__dir__`` module attributes." msgstr "``__getattr__`` 和 ``__dir__`` 模組屬性。" -#: ../../reference/datamodel.rst:2468 +#: ../../reference/datamodel.rst:2473 msgid ":pep:`562` - Module __getattr__ and __dir__" msgstr ":pep:`562` - 模組 __getattr__ 和 __dir__" -#: ../../reference/datamodel.rst:2469 +#: ../../reference/datamodel.rst:2474 msgid "Describes the ``__getattr__`` and ``__dir__`` functions on modules." msgstr "" -#: ../../reference/datamodel.rst:2475 +#: ../../reference/datamodel.rst:2480 msgid "Implementing Descriptors" msgstr "實作描述器" -#: ../../reference/datamodel.rst:2477 +#: ../../reference/datamodel.rst:2482 msgid "" "The following methods only apply when an instance of the class containing " "the method (a so-called *descriptor* class) appears in an *owner* class (the " @@ -2875,7 +2869,7 @@ msgid "" "does not implement any of these protocols." msgstr "" -#: ../../reference/datamodel.rst:2487 +#: ../../reference/datamodel.rst:2492 msgid "" "Called to get the attribute of the owner class (class attribute access) or " "of an instance of that class (instance attribute access). The optional " @@ -2884,13 +2878,13 @@ msgid "" "accessed through the *owner*." msgstr "" -#: ../../reference/datamodel.rst:2493 +#: ../../reference/datamodel.rst:2498 msgid "" "This method should return the computed attribute value or raise an :exc:" "`AttributeError` exception." msgstr "" -#: ../../reference/datamodel.rst:2496 +#: ../../reference/datamodel.rst:2501 msgid "" ":PEP:`252` specifies that :meth:`__get__` is callable with one or two " "arguments. Python's own built-in descriptors support this specification; " @@ -2900,31 +2894,31 @@ msgid "" "not." msgstr "" -#: ../../reference/datamodel.rst:2505 +#: ../../reference/datamodel.rst:2510 msgid "" "Called to set the attribute on an instance *instance* of the owner class to " "a new value, *value*." msgstr "" -#: ../../reference/datamodel.rst:2508 +#: ../../reference/datamodel.rst:2513 msgid "" "Note, adding :meth:`__set__` or :meth:`__delete__` changes the kind of " "descriptor to a \"data descriptor\". See :ref:`descriptor-invocation` for " "more details." msgstr "" -#: ../../reference/datamodel.rst:2514 +#: ../../reference/datamodel.rst:2519 msgid "" "Called to delete the attribute on an instance *instance* of the owner class." msgstr "" -#: ../../reference/datamodel.rst:2516 +#: ../../reference/datamodel.rst:2521 msgid "" "Instances of descriptors may also have the :attr:`!__objclass__` attribute " "present:" msgstr "" -#: ../../reference/datamodel.rst:2521 +#: ../../reference/datamodel.rst:2526 msgid "" "The attribute :attr:`!__objclass__` is interpreted by the :mod:`inspect` " "module as specifying the class where this object was defined (setting this " @@ -2935,11 +2929,11 @@ msgid "" "are implemented in C)." msgstr "" -#: ../../reference/datamodel.rst:2532 +#: ../../reference/datamodel.rst:2537 msgid "Invoking Descriptors" msgstr "" -#: ../../reference/datamodel.rst:2534 +#: ../../reference/datamodel.rst:2539 msgid "" "In general, a descriptor is an object attribute with \"binding behavior\", " "one whose attribute access has been overridden by methods in the descriptor " @@ -2948,7 +2942,7 @@ msgid "" "is said to be a descriptor." msgstr "" -#: ../../reference/datamodel.rst:2540 +#: ../../reference/datamodel.rst:2545 msgid "" "The default behavior for attribute access is to get, set, or delete the " "attribute from an object's dictionary. For instance, ``a.x`` has a lookup " @@ -2956,7 +2950,7 @@ msgid "" "continuing through the base classes of ``type(a)`` excluding metaclasses." msgstr "" -#: ../../reference/datamodel.rst:2545 +#: ../../reference/datamodel.rst:2550 msgid "" "However, if the looked-up value is an object defining one of the descriptor " "methods, then Python may override the default behavior and invoke the " @@ -2964,54 +2958,54 @@ msgid "" "depends on which descriptor methods were defined and how they were called." msgstr "" -#: ../../reference/datamodel.rst:2550 +#: ../../reference/datamodel.rst:2555 msgid "" "The starting point for descriptor invocation is a binding, ``a.x``. How the " "arguments are assembled depends on ``a``:" msgstr "" -#: ../../reference/datamodel.rst:2553 +#: ../../reference/datamodel.rst:2558 msgid "Direct Call" msgstr "直接呼叫" -#: ../../reference/datamodel.rst:2554 +#: ../../reference/datamodel.rst:2559 msgid "" "The simplest and least common call is when user code directly invokes a " "descriptor method: ``x.__get__(a)``." msgstr "" -#: ../../reference/datamodel.rst:2557 +#: ../../reference/datamodel.rst:2562 msgid "Instance Binding" msgstr "" -#: ../../reference/datamodel.rst:2558 +#: ../../reference/datamodel.rst:2563 msgid "" "If binding to an object instance, ``a.x`` is transformed into the call: " "``type(a).__dict__['x'].__get__(a, type(a))``." msgstr "" -#: ../../reference/datamodel.rst:2561 +#: ../../reference/datamodel.rst:2566 msgid "Class Binding" msgstr "" -#: ../../reference/datamodel.rst:2562 +#: ../../reference/datamodel.rst:2567 msgid "" "If binding to a class, ``A.x`` is transformed into the call: ``A." "__dict__['x'].__get__(None, A)``." msgstr "" -#: ../../reference/datamodel.rst:2565 +#: ../../reference/datamodel.rst:2570 msgid "Super Binding" msgstr "" -#: ../../reference/datamodel.rst:2566 +#: ../../reference/datamodel.rst:2571 msgid "" "A dotted lookup such as ``super(A, a).x`` searches ``a.__class__.__mro__`` " "for a base class ``B`` following ``A`` and then returns ``B.__dict__['x']." "__get__(a, A)``. If not a descriptor, ``x`` is returned unchanged." msgstr "" -#: ../../reference/datamodel.rst:2603 +#: ../../reference/datamodel.rst:2608 msgid "" "For instance bindings, the precedence of descriptor invocation depends on " "which descriptor methods are defined. A descriptor can define any " @@ -3029,7 +3023,7 @@ msgid "" "instances." msgstr "" -#: ../../reference/datamodel.rst:2618 +#: ../../reference/datamodel.rst:2623 msgid "" "Python methods (including those decorated with :deco:`staticmethod` and :" "deco:`classmethod`) are implemented as non-data descriptors. Accordingly, " @@ -3038,30 +3032,30 @@ msgid "" "class." msgstr "" -#: ../../reference/datamodel.rst:2624 +#: ../../reference/datamodel.rst:2629 msgid "" "The :deco:`property` decorator is implemented as a data descriptor. " "Accordingly, instances cannot override the behavior of a property." msgstr "" -#: ../../reference/datamodel.rst:2631 +#: ../../reference/datamodel.rst:2636 msgid "__slots__" msgstr "__slots__" -#: ../../reference/datamodel.rst:2633 +#: ../../reference/datamodel.rst:2638 msgid "" "*__slots__* allow us to explicitly declare data members (like properties) " "and deny the creation of :attr:`~object.__dict__` and *__weakref__* (unless " "explicitly declared in *__slots__* or available in a parent.)" msgstr "" -#: ../../reference/datamodel.rst:2637 +#: ../../reference/datamodel.rst:2642 msgid "" "The space saved over using :attr:`~object.__dict__` can be significant. " "Attribute lookup speed can be significantly improved as well." msgstr "" -#: ../../reference/datamodel.rst:2642 +#: ../../reference/datamodel.rst:2647 msgid "" "This class variable can be assigned a string, iterable, or sequence of " "strings with variable names used by instances. *__slots__* reserves space " @@ -3069,18 +3063,18 @@ msgid "" "`~object.__dict__` and *__weakref__* for each instance." msgstr "" -#: ../../reference/datamodel.rst:2651 +#: ../../reference/datamodel.rst:2656 msgid "Notes on using *__slots__*:" msgstr "" -#: ../../reference/datamodel.rst:2653 +#: ../../reference/datamodel.rst:2658 msgid "" "When inheriting from a class without *__slots__*, the :attr:`~object." "__dict__` and *__weakref__* attribute of the instances will always be " "accessible." msgstr "" -#: ../../reference/datamodel.rst:2657 +#: ../../reference/datamodel.rst:2662 msgid "" "Without a :attr:`~object.__dict__` variable, instances cannot be assigned " "new variables not listed in the *__slots__* definition. Attempts to assign " @@ -3089,7 +3083,7 @@ msgid "" "sequence of strings in the *__slots__* declaration." msgstr "" -#: ../../reference/datamodel.rst:2664 +#: ../../reference/datamodel.rst:2669 msgid "" "Without a *__weakref__* variable for each instance, classes defining " "*__slots__* do not support :mod:`weak references ` to its " @@ -3097,7 +3091,7 @@ msgid "" "to the sequence of strings in the *__slots__* declaration." msgstr "" -#: ../../reference/datamodel.rst:2670 +#: ../../reference/datamodel.rst:2675 msgid "" "*__slots__* are implemented at the class level by creating :ref:`descriptors " "` for each variable name. As a result, class attributes cannot " @@ -3105,7 +3099,7 @@ msgid "" "otherwise, the class attribute would overwrite the descriptor assignment." msgstr "" -#: ../../reference/datamodel.rst:2676 +#: ../../reference/datamodel.rst:2681 msgid "" "The action of a *__slots__* declaration is not limited to the class where it " "is defined. *__slots__* declared in parents are available in child classes. " @@ -3114,7 +3108,7 @@ msgid "" "only contain names of any *additional* slots)." msgstr "" -#: ../../reference/datamodel.rst:2682 +#: ../../reference/datamodel.rst:2687 msgid "" "If a class defines a slot also defined in a base class, the instance " "variable defined by the base class slot is inaccessible (except by " @@ -3123,19 +3117,19 @@ msgid "" "prevent this." msgstr "" -#: ../../reference/datamodel.rst:2687 +#: ../../reference/datamodel.rst:2692 msgid "" -":exc:`TypeError` will be raised if nonempty *__slots__* are defined for a " -"class derived from a :c:member:`\"variable-length\" built-in type " -"` such as :class:`int`, :class:`bytes`, and :class:" -"`tuple`." +":exc:`TypeError` will be raised if *__slots__* other than *__dict__* and " +"*__weakref__* are defined for a class derived from a :c:member:`\"variable-" +"length\" built-in type ` such as :class:`int`, :" +"class:`bytes`, and :class:`type`, except :class:`tuple`." msgstr "" -#: ../../reference/datamodel.rst:2692 +#: ../../reference/datamodel.rst:2697 msgid "Any non-string :term:`iterable` may be assigned to *__slots__*." msgstr "" -#: ../../reference/datamodel.rst:2694 +#: ../../reference/datamodel.rst:2699 msgid "" "If a :class:`dictionary ` is used to assign *__slots__*, the " "dictionary keys will be used as the slot names. The values of the dictionary " @@ -3143,32 +3137,38 @@ msgid "" "func:`inspect.getdoc` and displayed in the output of :func:`help`." msgstr "" -#: ../../reference/datamodel.rst:2699 +#: ../../reference/datamodel.rst:2704 msgid "" ":attr:`~object.__class__` assignment works only if both classes have the " "same *__slots__*." msgstr "" -#: ../../reference/datamodel.rst:2702 +#: ../../reference/datamodel.rst:2707 msgid "" -":ref:`Multiple inheritance ` with multiple slotted parent " -"classes can be used, but only one parent is allowed to have attributes " -"created by slots (the other bases must have empty slot layouts) - violations " -"raise :exc:`TypeError`." +":ref:`Multiple inheritance ` with multiple slotted " +"parent classes can be used, but only one parent is allowed to have " +"attributes created by slots (the other bases must have empty slot layouts) - " +"violations raise :exc:`TypeError`." msgstr "" -#: ../../reference/datamodel.rst:2708 +#: ../../reference/datamodel.rst:2713 msgid "" "If an :term:`iterator` is used for *__slots__* then a :term:`descriptor` is " "created for each of the iterator's values. However, the *__slots__* " "attribute will be an empty iterator." msgstr "" -#: ../../reference/datamodel.rst:2716 +#: ../../reference/datamodel.rst:2718 +msgid "" +"Allowed defining the *__dict__* and *__weakref__* *__slots__* for any class. " +"Allowed defining any *__slots__* for a class derived from :class:`tuple`." +msgstr "" + +#: ../../reference/datamodel.rst:2726 msgid "Customizing class creation" msgstr "" -#: ../../reference/datamodel.rst:2718 +#: ../../reference/datamodel.rst:2728 msgid "" "Whenever a class inherits from another class, :meth:`~object." "__init_subclass__` is called on the parent class. This way, it is possible " @@ -3178,14 +3178,14 @@ msgid "" "future subclasses of the class defining the method." msgstr "" -#: ../../reference/datamodel.rst:2727 +#: ../../reference/datamodel.rst:2737 msgid "" "This method is called whenever the containing class is subclassed. *cls* is " "then the new subclass. If defined as a normal instance method, this method " "is implicitly converted to a class method." msgstr "" -#: ../../reference/datamodel.rst:2731 +#: ../../reference/datamodel.rst:2741 msgid "" "Keyword arguments which are given to a new class are passed to the parent " "class's ``__init_subclass__``. For compatibility with other classes using " @@ -3193,7 +3193,7 @@ msgid "" "pass the others over to the base class, as in::" msgstr "" -#: ../../reference/datamodel.rst:2737 +#: ../../reference/datamodel.rst:2747 msgid "" "class Philosopher:\n" " def __init_subclass__(cls, /, default_name, **kwargs):\n" @@ -3211,13 +3211,13 @@ msgstr "" "class AustralianPhilosopher(Philosopher, default_name=\"Bruce\"):\n" " pass" -#: ../../reference/datamodel.rst:2745 +#: ../../reference/datamodel.rst:2755 msgid "" "The default implementation ``object.__init_subclass__`` does nothing, but " "raises an error if it is called with any arguments." msgstr "" -#: ../../reference/datamodel.rst:2750 +#: ../../reference/datamodel.rst:2760 msgid "" "The metaclass hint ``metaclass`` is consumed by the rest of the type " "machinery, and is never passed to ``__init_subclass__`` implementations. The " @@ -3225,19 +3225,19 @@ msgid "" "``type(cls)``." msgstr "" -#: ../../reference/datamodel.rst:2758 +#: ../../reference/datamodel.rst:2768 msgid "" "When a class is created, :meth:`!type.__new__` scans the class variables and " "makes callbacks to those with a :meth:`~object.__set_name__` hook." msgstr "" -#: ../../reference/datamodel.rst:2763 +#: ../../reference/datamodel.rst:2773 msgid "" "Automatically called at the time the owning class *owner* is created. The " "object has been assigned to *name* in that class::" msgstr "" -#: ../../reference/datamodel.rst:2766 +#: ../../reference/datamodel.rst:2776 msgid "" "class A:\n" " x = C() # Automatically calls: x.__set_name__(A, 'x')" @@ -3245,14 +3245,14 @@ msgstr "" "class A:\n" " x = C() # 自動呼叫:x.__set_name__(A, 'x')" -#: ../../reference/datamodel.rst:2769 +#: ../../reference/datamodel.rst:2779 msgid "" "If the class variable is assigned after the class is created, :meth:" "`__set_name__` will not be called automatically. If needed, :meth:" "`__set_name__` can be called directly::" msgstr "" -#: ../../reference/datamodel.rst:2773 +#: ../../reference/datamodel.rst:2783 msgid "" "class A:\n" " pass\n" @@ -3262,22 +3262,22 @@ msgid "" "c.__set_name__(A, 'x') # Manually invoke the hook" msgstr "" -#: ../../reference/datamodel.rst:2780 +#: ../../reference/datamodel.rst:2790 msgid "See :ref:`class-object-creation` for more details." msgstr "更多細節請見 :ref:`class-object-creation`。" -#: ../../reference/datamodel.rst:2788 +#: ../../reference/datamodel.rst:2798 msgid "Metaclasses" msgstr "" -#: ../../reference/datamodel.rst:2795 +#: ../../reference/datamodel.rst:2805 msgid "" "By default, classes are constructed using :func:`type`. The class body is " "executed in a new namespace and the class name is bound locally to the " "result of ``type(name, bases, namespace)``." msgstr "" -#: ../../reference/datamodel.rst:2799 +#: ../../reference/datamodel.rst:2809 msgid "" "The class creation process can be customized by passing the ``metaclass`` " "keyword argument in the class definition line, or by inheriting from an " @@ -3285,7 +3285,7 @@ msgid "" "both ``MyClass`` and ``MySubclass`` are instances of ``Meta``::" msgstr "" -#: ../../reference/datamodel.rst:2804 +#: ../../reference/datamodel.rst:2814 msgid "" "class Meta(type):\n" " pass\n" @@ -3305,41 +3305,41 @@ msgstr "" "class MySubclass(MyClass):\n" " pass" -#: ../../reference/datamodel.rst:2813 +#: ../../reference/datamodel.rst:2823 msgid "" "Any other keyword arguments that are specified in the class definition are " "passed through to all metaclass operations described below." msgstr "" -#: ../../reference/datamodel.rst:2816 +#: ../../reference/datamodel.rst:2826 msgid "When a class definition is executed, the following steps occur:" msgstr "" -#: ../../reference/datamodel.rst:2818 +#: ../../reference/datamodel.rst:2828 msgid "MRO entries are resolved;" msgstr "" -#: ../../reference/datamodel.rst:2819 +#: ../../reference/datamodel.rst:2829 msgid "the appropriate metaclass is determined;" msgstr "" -#: ../../reference/datamodel.rst:2820 +#: ../../reference/datamodel.rst:2830 msgid "the class namespace is prepared;" msgstr "" -#: ../../reference/datamodel.rst:2821 +#: ../../reference/datamodel.rst:2831 msgid "the class body is executed;" msgstr "" -#: ../../reference/datamodel.rst:2822 +#: ../../reference/datamodel.rst:2832 msgid "the class object is created." msgstr "" -#: ../../reference/datamodel.rst:2826 +#: ../../reference/datamodel.rst:2836 msgid "Resolving MRO entries" msgstr "" -#: ../../reference/datamodel.rst:2830 +#: ../../reference/datamodel.rst:2840 msgid "" "If a base that appears in a class definition is not an instance of :class:" "`type`, then an :meth:`!__mro_entries__` method is searched on the base. If " @@ -3351,59 +3351,59 @@ msgid "" "is ignored." msgstr "" -#: ../../reference/datamodel.rst:2841 +#: ../../reference/datamodel.rst:2851 msgid ":func:`types.resolve_bases`" msgstr ":func:`types.resolve_bases`" -#: ../../reference/datamodel.rst:2842 +#: ../../reference/datamodel.rst:2852 msgid "Dynamically resolve bases that are not instances of :class:`type`." msgstr "" -#: ../../reference/datamodel.rst:2844 +#: ../../reference/datamodel.rst:2854 msgid ":func:`types.get_original_bases`" msgstr ":func:`types.get_original_bases`" -#: ../../reference/datamodel.rst:2845 +#: ../../reference/datamodel.rst:2855 msgid "" "Retrieve a class's \"original bases\" prior to modifications by :meth:" "`~object.__mro_entries__`." msgstr "" -#: ../../reference/datamodel.rst:2848 +#: ../../reference/datamodel.rst:2858 msgid ":pep:`560`" msgstr ":pep:`560`" -#: ../../reference/datamodel.rst:2849 +#: ../../reference/datamodel.rst:2859 msgid "Core support for typing module and generic types." msgstr "" -#: ../../reference/datamodel.rst:2853 +#: ../../reference/datamodel.rst:2865 msgid "Determining the appropriate metaclass" msgstr "" -#: ../../reference/datamodel.rst:2857 +#: ../../reference/datamodel.rst:2869 msgid "" "The appropriate metaclass for a class definition is determined as follows:" msgstr "" -#: ../../reference/datamodel.rst:2859 +#: ../../reference/datamodel.rst:2871 msgid "" "if no bases and no explicit metaclass are given, then :func:`type` is used;" msgstr "" -#: ../../reference/datamodel.rst:2860 +#: ../../reference/datamodel.rst:2872 msgid "" "if an explicit metaclass is given and it is *not* an instance of :func:" "`type`, then it is used directly as the metaclass;" msgstr "" -#: ../../reference/datamodel.rst:2862 +#: ../../reference/datamodel.rst:2874 msgid "" "if an instance of :func:`type` is given as the explicit metaclass, or bases " "are defined, then the most derived metaclass is used." msgstr "" -#: ../../reference/datamodel.rst:2865 +#: ../../reference/datamodel.rst:2877 msgid "" "The most derived metaclass is selected from the explicitly specified " "metaclass (if any) and the metaclasses (i.e. ``type(cls)``) of all specified " @@ -3412,11 +3412,11 @@ msgid "" "that criterion, then the class definition will fail with ``TypeError``." msgstr "" -#: ../../reference/datamodel.rst:2875 +#: ../../reference/datamodel.rst:2887 msgid "Preparing the class namespace" msgstr "" -#: ../../reference/datamodel.rst:2880 +#: ../../reference/datamodel.rst:2892 msgid "" "Once the appropriate metaclass has been identified, then the class namespace " "is prepared. If the metaclass has a ``__prepare__`` attribute, it is called " @@ -3428,25 +3428,25 @@ msgid "" "copied into a new ``dict``." msgstr "" -#: ../../reference/datamodel.rst:2889 +#: ../../reference/datamodel.rst:2901 msgid "" "If the metaclass has no ``__prepare__`` attribute, then the class namespace " "is initialised as an empty ordered mapping." msgstr "" -#: ../../reference/datamodel.rst:2894 +#: ../../reference/datamodel.rst:2906 msgid ":pep:`3115` - Metaclasses in Python 3000" msgstr "" -#: ../../reference/datamodel.rst:2895 +#: ../../reference/datamodel.rst:2907 msgid "Introduced the ``__prepare__`` namespace hook" msgstr "" -#: ../../reference/datamodel.rst:2899 +#: ../../reference/datamodel.rst:2911 msgid "Executing the class body" msgstr "" -#: ../../reference/datamodel.rst:2904 +#: ../../reference/datamodel.rst:2916 msgid "" "The class body is executed (approximately) as ``exec(body, globals(), " "namespace)``. The key difference from a normal call to :func:`exec` is that " @@ -3455,7 +3455,7 @@ msgid "" "inside a function." msgstr "" -#: ../../reference/datamodel.rst:2910 +#: ../../reference/datamodel.rst:2922 msgid "" "However, even when the class definition occurs inside the function, methods " "defined inside the class still cannot see names defined at the class scope. " @@ -3464,11 +3464,11 @@ msgid "" "reference described in the next section." msgstr "" -#: ../../reference/datamodel.rst:2919 +#: ../../reference/datamodel.rst:2931 msgid "Creating the class object" msgstr "" -#: ../../reference/datamodel.rst:2926 +#: ../../reference/datamodel.rst:2938 msgid "" "Once the class namespace has been populated by executing the class body, the " "class object is created by calling ``metaclass(name, bases, namespace, " @@ -3476,7 +3476,7 @@ msgid "" "to ``__prepare__``)." msgstr "" -#: ../../reference/datamodel.rst:2931 +#: ../../reference/datamodel.rst:2943 msgid "" "This class object is the one that will be referenced by the zero-argument " "form of :func:`super`. ``__class__`` is an implicit closure reference " @@ -3487,7 +3487,7 @@ msgid "" "is identified based on the first argument passed to the method." msgstr "" -#: ../../reference/datamodel.rst:2941 +#: ../../reference/datamodel.rst:2953 msgid "" "In CPython 3.6 and later, the ``__class__`` cell is passed to the metaclass " "as a ``__classcell__`` entry in the class namespace. If present, this must " @@ -3496,39 +3496,39 @@ msgid "" "in Python 3.8." msgstr "" -#: ../../reference/datamodel.rst:2947 +#: ../../reference/datamodel.rst:2959 msgid "" "When using the default metaclass :class:`type`, or any metaclass that " "ultimately calls ``type.__new__``, the following additional customization " "steps are invoked after creating the class object:" msgstr "" -#: ../../reference/datamodel.rst:2951 +#: ../../reference/datamodel.rst:2963 msgid "" "The ``type.__new__`` method collects all of the attributes in the class " "namespace that define a :meth:`~object.__set_name__` method;" msgstr "" -#: ../../reference/datamodel.rst:2953 +#: ../../reference/datamodel.rst:2965 msgid "" "Those ``__set_name__`` methods are called with the class being defined and " "the assigned name of that particular attribute;" msgstr "" -#: ../../reference/datamodel.rst:2955 +#: ../../reference/datamodel.rst:2967 msgid "" "The :meth:`~object.__init_subclass__` hook is called on the immediate parent " "of the new class in its method resolution order." msgstr "" -#: ../../reference/datamodel.rst:2958 +#: ../../reference/datamodel.rst:2970 msgid "" "After the class object is created, it is passed to the class decorators " "included in the class definition (if any) and the resulting object is bound " "in the local namespace as the defined class." msgstr "" -#: ../../reference/datamodel.rst:2962 +#: ../../reference/datamodel.rst:2974 msgid "" "When a new class is created by ``type.__new__``, the object provided as the " "namespace parameter is copied to a new ordered mapping and the original " @@ -3536,19 +3536,19 @@ msgid "" "becomes the :attr:`~type.__dict__` attribute of the class object." msgstr "" -#: ../../reference/datamodel.rst:2969 +#: ../../reference/datamodel.rst:2981 msgid ":pep:`3135` - New super" msgstr "" -#: ../../reference/datamodel.rst:2970 +#: ../../reference/datamodel.rst:2982 msgid "Describes the implicit ``__class__`` closure reference" msgstr "" -#: ../../reference/datamodel.rst:2974 +#: ../../reference/datamodel.rst:2986 msgid "Uses for metaclasses" msgstr "" -#: ../../reference/datamodel.rst:2976 +#: ../../reference/datamodel.rst:2988 msgid "" "The potential uses for metaclasses are boundless. Some ideas that have been " "explored include enum, logging, interface checking, automatic delegation, " @@ -3556,17 +3556,17 @@ msgid "" "locking/synchronization." msgstr "" -#: ../../reference/datamodel.rst:2983 +#: ../../reference/datamodel.rst:2995 msgid "Customizing instance and subclass checks" msgstr "" -#: ../../reference/datamodel.rst:2985 +#: ../../reference/datamodel.rst:2997 msgid "" "The following methods are used to override the default behavior of the :func:" "`isinstance` and :func:`issubclass` built-in functions." msgstr "" -#: ../../reference/datamodel.rst:2988 +#: ../../reference/datamodel.rst:3000 msgid "" "In particular, the metaclass :class:`abc.ABCMeta` implements these methods " "in order to allow the addition of Abstract Base Classes (ABCs) as \"virtual " @@ -3574,21 +3574,21 @@ msgid "" "other ABCs." msgstr "" -#: ../../reference/datamodel.rst:2995 +#: ../../reference/datamodel.rst:3007 msgid "" "Return true if *instance* should be considered a (direct or indirect) " "instance of *class*. If defined, called to implement ``isinstance(instance, " "class)``." msgstr "" -#: ../../reference/datamodel.rst:3002 +#: ../../reference/datamodel.rst:3014 msgid "" "Return true if *subclass* should be considered a (direct or indirect) " "subclass of *class*. If defined, called to implement ``issubclass(subclass, " "class)``." msgstr "" -#: ../../reference/datamodel.rst:3007 +#: ../../reference/datamodel.rst:3019 msgid "" "Note that these methods are looked up on the type (metaclass) of a class. " "They cannot be defined as class methods in the actual class. This is " @@ -3596,11 +3596,11 @@ msgid "" "only in this case the instance is itself a class." msgstr "" -#: ../../reference/datamodel.rst:3014 +#: ../../reference/datamodel.rst:3026 msgid ":pep:`3119` - Introducing Abstract Base Classes" msgstr "" -#: ../../reference/datamodel.rst:3015 +#: ../../reference/datamodel.rst:3027 msgid "" "Includes the specification for customizing :func:`isinstance` and :func:" "`issubclass` behavior through :meth:`~type.__instancecheck__` and :meth:" @@ -3609,11 +3609,11 @@ msgid "" "language." msgstr "" -#: ../../reference/datamodel.rst:3023 +#: ../../reference/datamodel.rst:3035 msgid "Emulating generic types" msgstr "" -#: ../../reference/datamodel.rst:3025 +#: ../../reference/datamodel.rst:3037 msgid "" "When using :term:`type annotations`, it is often useful to " "*parameterize* a :term:`generic type` using Python's square-brackets " @@ -3621,65 +3621,65 @@ msgid "" "a :class:`list` in which all the elements are of type :class:`int`." msgstr "" -#: ../../reference/datamodel.rst:3032 +#: ../../reference/datamodel.rst:3044 msgid ":pep:`484` - Type Hints" msgstr ":pep:`484` - 型別提示" -#: ../../reference/datamodel.rst:3033 +#: ../../reference/datamodel.rst:3045 msgid "Introducing Python's framework for type annotations" msgstr "引入 Python 的型別註釋框架" -#: ../../reference/datamodel.rst:3035 +#: ../../reference/datamodel.rst:3047 msgid ":ref:`Generic Alias Types`" msgstr ":ref:`泛型別名型別 `" -#: ../../reference/datamodel.rst:3036 +#: ../../reference/datamodel.rst:3048 msgid "Documentation for objects representing parameterized generic classes" msgstr "" -#: ../../reference/datamodel.rst:3038 +#: ../../reference/datamodel.rst:3050 msgid "" ":ref:`Generics`, :ref:`user-defined generics` and :" "class:`typing.Generic`" msgstr "" -#: ../../reference/datamodel.rst:3039 +#: ../../reference/datamodel.rst:3051 msgid "" "Documentation on how to implement generic classes that can be parameterized " "at runtime and understood by static type-checkers." msgstr "" -#: ../../reference/datamodel.rst:3042 +#: ../../reference/datamodel.rst:3054 msgid "" "A class can *generally* only be parameterized if it defines the special " "class method ``__class_getitem__()``." msgstr "" -#: ../../reference/datamodel.rst:3047 +#: ../../reference/datamodel.rst:3059 msgid "" "Return an object representing the specialization of a generic class by type " "arguments found in *key*." msgstr "" -#: ../../reference/datamodel.rst:3050 +#: ../../reference/datamodel.rst:3062 msgid "" "When defined on a class, ``__class_getitem__()`` is automatically a class " "method. As such, there is no need for it to be decorated with :deco:" "`classmethod` when it is defined." msgstr "" -#: ../../reference/datamodel.rst:3056 +#: ../../reference/datamodel.rst:3068 msgid "The purpose of *__class_getitem__*" msgstr "" -#: ../../reference/datamodel.rst:3058 +#: ../../reference/datamodel.rst:3070 msgid "" "The purpose of :meth:`~object.__class_getitem__` is to allow runtime " "parameterization of standard-library generic classes in order to more easily " "apply :term:`type hints` to these classes." msgstr "" -#: ../../reference/datamodel.rst:3062 +#: ../../reference/datamodel.rst:3074 msgid "" "To implement custom generic classes that can be parameterized at runtime and " "understood by static type-checkers, users should either inherit from a " @@ -3688,7 +3688,7 @@ msgid "" "own implementation of ``__class_getitem__()``." msgstr "" -#: ../../reference/datamodel.rst:3068 +#: ../../reference/datamodel.rst:3080 msgid "" "Custom implementations of :meth:`~object.__class_getitem__` on classes " "defined outside of the standard library may not be understood by third-party " @@ -3696,11 +3696,11 @@ msgid "" "purposes other than type hinting is discouraged." msgstr "" -#: ../../reference/datamodel.rst:3078 +#: ../../reference/datamodel.rst:3090 msgid "*__class_getitem__* versus *__getitem__*" msgstr "" -#: ../../reference/datamodel.rst:3080 +#: ../../reference/datamodel.rst:3092 msgid "" "Usually, the :ref:`subscription` of an object using square " "brackets will call the :meth:`~object.__getitem__` instance method defined " @@ -3710,14 +3710,14 @@ msgid "" "genericalias>` object if it is properly defined." msgstr "" -#: ../../reference/datamodel.rst:3087 +#: ../../reference/datamodel.rst:3099 msgid "" "Presented with the :term:`expression` ``obj[x]``, the Python interpreter " "follows something like the following process to decide whether :meth:" "`~object.__getitem__` or :meth:`~object.__class_getitem__` should be called::" msgstr "" -#: ../../reference/datamodel.rst:3092 +#: ../../reference/datamodel.rst:3104 msgid "" "from inspect import isclass\n" "\n" @@ -3743,7 +3743,7 @@ msgid "" " )" msgstr "" -#: ../../reference/datamodel.rst:3115 +#: ../../reference/datamodel.rst:3127 msgid "" "In Python, all classes are themselves instances of other classes. The class " "of a class is known as that class's :term:`metaclass`, and most classes have " @@ -3753,7 +3753,7 @@ msgid "" "__class_getitem__` being called::" msgstr "" -#: ../../reference/datamodel.rst:3122 +#: ../../reference/datamodel.rst:3134 msgid "" ">>> # list has class \"type\" as its metaclass, like most classes:\n" ">>> type(list)\n" @@ -3768,14 +3768,14 @@ msgid "" "" msgstr "" -#: ../../reference/datamodel.rst:3134 +#: ../../reference/datamodel.rst:3146 msgid "" "However, if a class has a custom metaclass that defines :meth:`~object." "__getitem__`, subscribing the class may result in different behaviour. An " "example of this can be found in the :mod:`enum` module::" msgstr "" -#: ../../reference/datamodel.rst:3138 +#: ../../reference/datamodel.rst:3150 msgid "" ">>> from enum import Enum\n" ">>> class Menu(Enum):\n" @@ -3795,33 +3795,33 @@ msgid "" "" msgstr "" -#: ../../reference/datamodel.rst:3157 +#: ../../reference/datamodel.rst:3169 msgid ":pep:`560` - Core Support for typing module and generic types" msgstr "" -#: ../../reference/datamodel.rst:3158 +#: ../../reference/datamodel.rst:3170 msgid "" "Introducing :meth:`~object.__class_getitem__`, and outlining when a :ref:" "`subscription` results in ``__class_getitem__()`` being " "called instead of :meth:`~object.__getitem__`" msgstr "" -#: ../../reference/datamodel.rst:3166 +#: ../../reference/datamodel.rst:3178 msgid "Emulating callable objects" msgstr "" -#: ../../reference/datamodel.rst:3173 +#: ../../reference/datamodel.rst:3185 msgid "" "Called when the instance is \"called\" as a function; if this method is " "defined, ``x(arg1, arg2, ...)`` roughly translates to ``type(x).__call__(x, " "arg1, ...)``. The :class:`object` class itself does not provide this method." msgstr "" -#: ../../reference/datamodel.rst:3181 +#: ../../reference/datamodel.rst:3193 msgid "Emulating container types" msgstr "" -#: ../../reference/datamodel.rst:3183 +#: ../../reference/datamodel.rst:3195 msgid "" "The following methods can be defined to implement container objects. None of " "them are provided by the :class:`object` class itself. Containers usually " @@ -3842,7 +3842,7 @@ msgid "" "__setitem__`, :meth:`~object.__delitem__`, and :meth:`!keys`." msgstr "" -#: ../../reference/datamodel.rst:3202 +#: ../../reference/datamodel.rst:3214 msgid "" "Mutable sequences should provide methods :meth:`~sequence.append`, :meth:" "`~sequence.clear`, :meth:`~sequence.count`, :meth:`~sequence.extend`, :meth:" @@ -3856,7 +3856,7 @@ msgid "" "numerical operators." msgstr "" -#: ../../reference/datamodel.rst:3214 +#: ../../reference/datamodel.rst:3226 msgid "" "It is recommended that both mappings and sequences implement the :meth:" "`~object.__contains__` method to allow efficient use of the ``in`` operator; " @@ -3868,7 +3868,7 @@ msgid "" "iterate through the values." msgstr "" -#: ../../reference/datamodel.rst:3229 +#: ../../reference/datamodel.rst:3241 msgid "" "Called to implement the built-in function :func:`len`. Should return the " "length of the object, an integer ``>=`` 0. Also, an object that doesn't " @@ -3876,7 +3876,7 @@ msgid "" "returns zero is considered to be false in a Boolean context." msgstr "" -#: ../../reference/datamodel.rst:3236 +#: ../../reference/datamodel.rst:3248 msgid "" "In CPython, the length is required to be at most :data:`sys.maxsize`. If the " "length is larger than :data:`!sys.maxsize` some features (such as :func:" @@ -3885,7 +3885,7 @@ msgid "" "`~object.__bool__` method." msgstr "" -#: ../../reference/datamodel.rst:3245 +#: ../../reference/datamodel.rst:3257 msgid "" "Called to implement :func:`operator.length_hint`. Should return an estimated " "length for the object (which may be greater or less than the actual length). " @@ -3895,19 +3895,19 @@ msgid "" "never required for correctness." msgstr "" -#: ../../reference/datamodel.rst:3257 +#: ../../reference/datamodel.rst:3269 msgid "" "Called to implement *subscription*, that is, ``self[subscript]``. See :ref:" "`subscriptions` for details on the syntax." msgstr "" -#: ../../reference/datamodel.rst:3260 +#: ../../reference/datamodel.rst:3272 msgid "" "There are two types of built-in objects that support subscription via :meth:" "`!__getitem__`:" msgstr "" -#: ../../reference/datamodel.rst:3263 +#: ../../reference/datamodel.rst:3275 msgid "" "**sequences**, where *subscript* (also called :term:`index`) should be an " "integer or a :class:`slice` object. See the :ref:`sequence documentation " @@ -3915,13 +3915,13 @@ msgid "" "`slice` objects and negative indices." msgstr "" -#: ../../reference/datamodel.rst:3267 +#: ../../reference/datamodel.rst:3279 msgid "" "**mappings**, where *subscript* is also called the :term:`key`. See :ref:" "`mapping documentation ` for the expected behavior." msgstr "" -#: ../../reference/datamodel.rst:3271 +#: ../../reference/datamodel.rst:3283 msgid "" "If *subscript* is of an inappropriate type, :meth:`!__getitem__` should " "raise :exc:`TypeError`. If *subscript* has an inappropriate value, :meth:`!" @@ -3929,43 +3929,43 @@ msgid "" "exc:`IndexError` for sequences; :exc:`KeyError` for mappings)." msgstr "" -#: ../../reference/datamodel.rst:3281 +#: ../../reference/datamodel.rst:3293 msgid "" "Slicing is handled by :meth:`!__getitem__`, :meth:`~object.__setitem__`, " "and :meth:`~object.__delitem__`. A call like ::" msgstr "" -#: ../../reference/datamodel.rst:3285 +#: ../../reference/datamodel.rst:3297 msgid "a[1:2] = b" msgstr "a[1:2] = b" -#: ../../reference/datamodel.rst:3287 +#: ../../reference/datamodel.rst:3299 msgid "is translated to ::" msgstr "" -#: ../../reference/datamodel.rst:3289 +#: ../../reference/datamodel.rst:3301 msgid "a[slice(1, 2, None)] = b" msgstr "a[slice(1, 2, None)] = b" -#: ../../reference/datamodel.rst:3291 +#: ../../reference/datamodel.rst:3303 msgid "and so forth. Missing slice items are always filled in with ``None``." msgstr "" -#: ../../reference/datamodel.rst:3295 +#: ../../reference/datamodel.rst:3307 msgid "" "The sequence iteration protocol (used, for example, in :keyword:`for` " "loops), expects that an :exc:`IndexError` will be raised for illegal indexes " "to allow proper detection of the end of a sequence." msgstr "" -#: ../../reference/datamodel.rst:3301 +#: ../../reference/datamodel.rst:3313 msgid "" "When :ref:`subscripting ` a *class*, the special class " "method :meth:`~object.__class_getitem__` may be called instead of :meth:`!" "__getitem__`. See :ref:`classgetitem-versus-getitem` for more details." msgstr "" -#: ../../reference/datamodel.rst:3309 +#: ../../reference/datamodel.rst:3321 msgid "" "Called to implement assignment to ``self[key]``. Same note as for :meth:" "`__getitem__`. This should only be implemented for mappings if the objects " @@ -3974,7 +3974,7 @@ msgid "" "for improper *key* values as for the :meth:`__getitem__` method." msgstr "" -#: ../../reference/datamodel.rst:3318 +#: ../../reference/datamodel.rst:3330 msgid "" "Called to implement deletion of ``self[key]``. Same note as for :meth:" "`__getitem__`. This should only be implemented for mappings if the objects " @@ -3983,13 +3983,13 @@ msgid "" "values as for the :meth:`__getitem__` method." msgstr "" -#: ../../reference/datamodel.rst:3327 +#: ../../reference/datamodel.rst:3339 msgid "" "Called by :class:`dict`\\ .\\ :meth:`__getitem__` to implement ``self[key]`` " "for dict subclasses when key is not in the dictionary." msgstr "" -#: ../../reference/datamodel.rst:3333 +#: ../../reference/datamodel.rst:3345 msgid "" "This method is called when an :term:`iterator` is required for a container. " "This method should return a new iterator object that can iterate over all " @@ -3997,14 +3997,14 @@ msgid "" "of the container." msgstr "" -#: ../../reference/datamodel.rst:3341 +#: ../../reference/datamodel.rst:3353 msgid "" "Called (if present) by the :func:`reversed` built-in to implement reverse " "iteration. It should return a new iterator object that iterates over all " "the objects in the container in reverse order." msgstr "" -#: ../../reference/datamodel.rst:3345 +#: ../../reference/datamodel.rst:3357 msgid "" "If the :meth:`__reversed__` method is not provided, the :func:`reversed` " "built-in will fall back to using the sequence protocol (:meth:`__len__` and :" @@ -4013,7 +4013,7 @@ msgid "" "more efficient than the one provided by :func:`reversed`." msgstr "" -#: ../../reference/datamodel.rst:3352 +#: ../../reference/datamodel.rst:3364 msgid "" "The membership test operators (:keyword:`in` and :keyword:`not in`) are " "normally implemented as an iteration through a container. However, container " @@ -4021,14 +4021,14 @@ msgid "" "implementation, which also does not require the object be iterable." msgstr "" -#: ../../reference/datamodel.rst:3359 +#: ../../reference/datamodel.rst:3371 msgid "" "Called to implement membership test operators. Should return true if *item* " "is in *self*, false otherwise. For mapping objects, this should consider " "the keys of the mapping rather than the values or the key-item pairs." msgstr "" -#: ../../reference/datamodel.rst:3363 +#: ../../reference/datamodel.rst:3375 msgid "" "For objects that don't define :meth:`__contains__`, the membership test " "first tries iteration via :meth:`__iter__`, then the old sequence iteration " @@ -4036,11 +4036,11 @@ msgid "" "reference `." msgstr "" -#: ../../reference/datamodel.rst:3372 +#: ../../reference/datamodel.rst:3384 msgid "Emulating numeric types" msgstr "" -#: ../../reference/datamodel.rst:3374 +#: ../../reference/datamodel.rst:3386 msgid "" "The following methods can be defined to emulate numeric objects. Methods " "corresponding to operations that are not supported by the particular kind of " @@ -4048,7 +4048,7 @@ msgid "" "should be left undefined." msgstr "" -#: ../../reference/datamodel.rst:3400 +#: ../../reference/datamodel.rst:3412 msgid "" "These methods are called to implement the binary arithmetic operations " "(``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`, :func:" @@ -4062,13 +4062,13 @@ msgid "" "`pow` function is to be supported." msgstr "" -#: ../../reference/datamodel.rst:3411 +#: ../../reference/datamodel.rst:3423 msgid "" "If one of those methods does not support the operation with the supplied " "arguments, it should return :data:`NotImplemented`." msgstr "" -#: ../../reference/datamodel.rst:3434 +#: ../../reference/datamodel.rst:3446 msgid "" "These methods are called to implement the binary arithmetic operations " "(``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`, :func:" @@ -4082,21 +4082,21 @@ msgid "" "`NotImplemented` or ``type(y)`` is a subclass of ``type(x)``. [#]_" msgstr "" -#: ../../reference/datamodel.rst:3445 +#: ../../reference/datamodel.rst:3457 msgid "" "Note that :meth:`__rpow__` should be defined to accept an optional third " "argument if the three-argument version of the built-in :func:`pow` function " "is to be supported." msgstr "" -#: ../../reference/datamodel.rst:3451 +#: ../../reference/datamodel.rst:3463 msgid "" "Three-argument :func:`pow` now try calling :meth:`~object.__rpow__` if " "necessary. Previously it was only called in two-argument :func:`!pow` and " "the binary power operator." msgstr "" -#: ../../reference/datamodel.rst:3457 +#: ../../reference/datamodel.rst:3469 msgid "" "If the right operand's type is a subclass of the left operand's type and " "that subclass provides a different implementation of the reflected method " @@ -4105,7 +4105,7 @@ msgid "" "ancestors' operations." msgstr "" -#: ../../reference/datamodel.rst:3477 +#: ../../reference/datamodel.rst:3489 msgid "" "These methods are called to implement the augmented arithmetic assignments " "(``+=``, ``-=``, ``*=``, ``@=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``, " @@ -4123,19 +4123,19 @@ msgid "" "data model." msgstr "" -#: ../../reference/datamodel.rst:3500 +#: ../../reference/datamodel.rst:3512 msgid "" "Called to implement the unary arithmetic operations (``-``, ``+``, :func:" "`abs` and ``~``)." msgstr "" -#: ../../reference/datamodel.rst:3513 +#: ../../reference/datamodel.rst:3525 msgid "" "Called to implement the built-in functions :func:`complex`, :func:`int` and :" "func:`float`. Should return a value of the appropriate type." msgstr "" -#: ../../reference/datamodel.rst:3520 +#: ../../reference/datamodel.rst:3532 msgid "" "Called to implement :func:`operator.index`, and whenever Python needs to " "losslessly convert the numeric object to an integer object (such as in " @@ -4144,14 +4144,14 @@ msgid "" "integer type. Must return an integer." msgstr "" -#: ../../reference/datamodel.rst:3526 +#: ../../reference/datamodel.rst:3538 msgid "" "If :meth:`__int__`, :meth:`__float__` and :meth:`__complex__` are not " "defined then corresponding built-in functions :func:`int`, :func:`float` " "and :func:`complex` fall back to :meth:`__index__`." msgstr "" -#: ../../reference/datamodel.rst:3538 +#: ../../reference/datamodel.rst:3550 msgid "" "Called to implement the built-in function :func:`round` and :mod:`math` " "functions :func:`~math.trunc`, :func:`~math.floor` and :func:`~math.ceil`. " @@ -4160,16 +4160,16 @@ msgid "" "(typically an :class:`int`)." msgstr "" -#: ../../reference/datamodel.rst:3544 +#: ../../reference/datamodel.rst:3556 msgid "" ":func:`int` no longer delegates to the :meth:`~object.__trunc__` method." msgstr "" -#: ../../reference/datamodel.rst:3551 +#: ../../reference/datamodel.rst:3563 msgid "With Statement Context Managers" msgstr "With 陳述式的情境管理器" -#: ../../reference/datamodel.rst:3553 +#: ../../reference/datamodel.rst:3565 msgid "" "A :dfn:`context manager` is an object that defines the runtime context to be " "established when executing a :keyword:`with` statement. The context manager " @@ -4179,34 +4179,34 @@ msgid "" "can also be used by directly invoking their methods." msgstr "" -#: ../../reference/datamodel.rst:3564 +#: ../../reference/datamodel.rst:3576 msgid "" "Typical uses of context managers include saving and restoring various kinds " "of global state, locking and unlocking resources, closing opened files, etc." msgstr "" -#: ../../reference/datamodel.rst:3567 +#: ../../reference/datamodel.rst:3579 msgid "" "For more information on context managers, see :ref:`typecontextmanager`. " "The :class:`object` class itself does not provide the context manager " "methods." msgstr "" -#: ../../reference/datamodel.rst:3573 +#: ../../reference/datamodel.rst:3585 msgid "" "Enter the runtime context related to this object. The :keyword:`with` " "statement will bind this method's return value to the target(s) specified in " "the :keyword:`!as` clause of the statement, if any." msgstr "" -#: ../../reference/datamodel.rst:3580 +#: ../../reference/datamodel.rst:3592 msgid "" "Exit the runtime context related to this object. The parameters describe the " "exception that caused the context to be exited. If the context was exited " "without an exception, all three arguments will be :const:`None`." msgstr "" -#: ../../reference/datamodel.rst:3584 +#: ../../reference/datamodel.rst:3596 msgid "" "If an exception is supplied, and the method wishes to suppress the exception " "(i.e., prevent it from being propagated), it should return a true value. " @@ -4214,27 +4214,27 @@ msgid "" "method." msgstr "" -#: ../../reference/datamodel.rst:3588 +#: ../../reference/datamodel.rst:3600 msgid "" "Note that :meth:`~object.__exit__` methods should not reraise the passed-in " "exception; this is the caller's responsibility." msgstr "" -#: ../../reference/datamodel.rst:3594 +#: ../../reference/datamodel.rst:3606 msgid ":pep:`343` - The \"with\" statement" msgstr ":pep:`343` - \"with\" 陳述式" -#: ../../reference/datamodel.rst:3595 +#: ../../reference/datamodel.rst:3607 msgid "" "The specification, background, and examples for the Python :keyword:`with` " "statement." msgstr "" -#: ../../reference/datamodel.rst:3602 +#: ../../reference/datamodel.rst:3614 msgid "Customizing positional arguments in class pattern matching" msgstr "" -#: ../../reference/datamodel.rst:3604 +#: ../../reference/datamodel.rst:3616 msgid "" "When using a class name in a pattern, positional arguments in the pattern " "are not allowed by default, i.e. ``case MyClass(x, y)`` is typically invalid " @@ -4242,7 +4242,7 @@ msgid "" "pattern, the class needs to define a *__match_args__* attribute." msgstr "" -#: ../../reference/datamodel.rst:3611 +#: ../../reference/datamodel.rst:3623 msgid "" "This class variable can be assigned a tuple of strings. When this class is " "used in a class pattern with positional arguments, each positional argument " @@ -4251,7 +4251,7 @@ msgid "" "to setting it to ``()``." msgstr "" -#: ../../reference/datamodel.rst:3617 +#: ../../reference/datamodel.rst:3629 msgid "" "For example, if ``MyClass.__match_args__`` is ``(\"left\", \"center\", " "\"right\")`` that means that ``case MyClass(x, y)`` is equivalent to ``case " @@ -4261,19 +4261,19 @@ msgid "" "exc:`TypeError`." msgstr "" -#: ../../reference/datamodel.rst:3627 +#: ../../reference/datamodel.rst:3639 msgid ":pep:`634` - Structural Pattern Matching" msgstr "" -#: ../../reference/datamodel.rst:3628 +#: ../../reference/datamodel.rst:3640 msgid "The specification for the Python ``match`` statement." msgstr "" -#: ../../reference/datamodel.rst:3634 +#: ../../reference/datamodel.rst:3646 msgid "Emulating buffer types" msgstr "" -#: ../../reference/datamodel.rst:3636 +#: ../../reference/datamodel.rst:3648 msgid "" "The :ref:`buffer protocol ` provides a way for Python objects " "to expose efficient access to a low-level memory array. This protocol is " @@ -4281,13 +4281,13 @@ msgid "" "and third-party libraries may define additional buffer types." msgstr "" -#: ../../reference/datamodel.rst:3641 +#: ../../reference/datamodel.rst:3653 msgid "" "While buffer types are usually implemented in C, it is also possible to " "implement the protocol in Python." msgstr "" -#: ../../reference/datamodel.rst:3646 +#: ../../reference/datamodel.rst:3658 msgid "" "Called when a buffer is requested from *self* (for example, by the :class:" "`memoryview` constructor). The *flags* argument is an integer representing " @@ -4297,7 +4297,7 @@ msgid "" "`memoryview` object." msgstr "" -#: ../../reference/datamodel.rst:3653 +#: ../../reference/datamodel.rst:3665 msgid "" "**Thread safety:** In :term:`free-threaded ` Python, " "implementations must manage any internal export counter using atomic " @@ -4307,7 +4307,7 @@ msgid "" "ref:`thread-safety-memoryview` for details." msgstr "" -#: ../../reference/datamodel.rst:3662 +#: ../../reference/datamodel.rst:3674 msgid "" "Called when a buffer is no longer needed. The *buffer* argument is a :class:" "`memoryview` object that was previously returned by :meth:`~object." @@ -4315,7 +4315,7 @@ msgid "" "buffer. This method should return ``None``." msgstr "" -#: ../../reference/datamodel.rst:3667 +#: ../../reference/datamodel.rst:3679 msgid "" "**Thread safety:** In :term:`free-threaded ` Python, any " "export counter decrement must use atomic operations. Resource cleanup must " @@ -4323,41 +4323,41 @@ msgid "" "other threads." msgstr "" -#: ../../reference/datamodel.rst:3672 +#: ../../reference/datamodel.rst:3684 msgid "" "Buffer objects that do not need to perform any cleanup are not required to " "implement this method." msgstr "" -#: ../../reference/datamodel.rst:3679 +#: ../../reference/datamodel.rst:3691 msgid ":pep:`688` - Making the buffer protocol accessible in Python" msgstr "" -#: ../../reference/datamodel.rst:3680 +#: ../../reference/datamodel.rst:3692 msgid "" "Introduces the Python ``__buffer__`` and ``__release_buffer__`` methods." msgstr "" -#: ../../reference/datamodel.rst:3682 +#: ../../reference/datamodel.rst:3694 msgid ":class:`collections.abc.Buffer`" msgstr ":class:`collections.abc.Buffer`" -#: ../../reference/datamodel.rst:3683 +#: ../../reference/datamodel.rst:3695 msgid "ABC for buffer types." msgstr "" -#: ../../reference/datamodel.rst:3686 +#: ../../reference/datamodel.rst:3698 msgid "Annotations" msgstr "" -#: ../../reference/datamodel.rst:3688 +#: ../../reference/datamodel.rst:3700 msgid "" "Functions, classes, and modules may contain :term:`annotations " "`, which are a way to associate information (usually :term:`type " "hints `) with a symbol." msgstr "" -#: ../../reference/datamodel.rst:3694 +#: ../../reference/datamodel.rst:3706 msgid "" "This attribute contains the annotations for an object. It is :ref:`lazily " "evaluated `, so accessing the attribute may execute " @@ -4365,24 +4365,24 @@ msgid "" "attribute is set to a dictionary mapping from variable names to annotations." msgstr "" -#: ../../reference/datamodel.rst:3699 +#: ../../reference/datamodel.rst:3711 msgid "Annotations are now lazily evaluated." msgstr "" -#: ../../reference/datamodel.rst:3704 +#: ../../reference/datamodel.rst:3716 msgid "" "An :term:`annotate function`. Returns a new dictionary object mapping " "attribute/parameter names to their annotation values." msgstr "" -#: ../../reference/datamodel.rst:3707 +#: ../../reference/datamodel.rst:3719 msgid "" "Takes a format parameter specifying the format in which annotations values " "should be provided. It must be a member of the :class:`annotationlib.Format` " "enum, or an integer with a value corresponding to a member of the enum." msgstr "" -#: ../../reference/datamodel.rst:3711 +#: ../../reference/datamodel.rst:3723 msgid "" "If an annotate function doesn't support the requested format, it must raise :" "exc:`NotImplementedError`. Annotate functions must always support :attr:" @@ -4390,34 +4390,34 @@ msgid "" "`NotImplementedError()` when called with this format." msgstr "" -#: ../../reference/datamodel.rst:3716 +#: ../../reference/datamodel.rst:3728 msgid "" "When called with :attr:`~annotationlib.Format.VALUE` format, an annotate " "function may raise :exc:`NameError`; it must not raise :exc:`!NameError` " "when called requesting any other format." msgstr "" -#: ../../reference/datamodel.rst:3719 +#: ../../reference/datamodel.rst:3731 msgid "" "If an object does not have any annotations, :attr:`~object.__annotate__` " "should preferably be set to ``None`` (it can’t be deleted), rather than set " "to a function that returns an empty dict." msgstr "" -#: ../../reference/datamodel.rst:3726 +#: ../../reference/datamodel.rst:3738 msgid ":pep:`649` --- Deferred evaluation of annotation using descriptors" msgstr "" -#: ../../reference/datamodel.rst:3727 +#: ../../reference/datamodel.rst:3739 msgid "" "Introduces lazy evaluation of annotations and the ``__annotate__`` function." msgstr "" -#: ../../reference/datamodel.rst:3733 +#: ../../reference/datamodel.rst:3745 msgid "Special method lookup" msgstr "" -#: ../../reference/datamodel.rst:3735 +#: ../../reference/datamodel.rst:3747 msgid "" "For custom classes, implicit invocations of special methods are only " "guaranteed to work correctly if defined on an object's type, not in the " @@ -4425,7 +4425,7 @@ msgid "" "following code raises an exception::" msgstr "" -#: ../../reference/datamodel.rst:3740 +#: ../../reference/datamodel.rst:3752 msgid "" ">>> class C:\n" "... pass\n" @@ -4447,7 +4447,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: object of type 'C' has no len()" -#: ../../reference/datamodel.rst:3750 +#: ../../reference/datamodel.rst:3762 msgid "" "The rationale behind this behaviour lies with a number of special methods " "such as :meth:`~object.__hash__` and :meth:`~object.__repr__` that are " @@ -4456,7 +4456,7 @@ msgid "" "invoked on the type object itself::" msgstr "" -#: ../../reference/datamodel.rst:3757 +#: ../../reference/datamodel.rst:3769 msgid "" ">>> 1 .__hash__() == hash(1)\n" "True\n" @@ -4472,14 +4472,14 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: descriptor '__hash__' of 'int' object needs an argument" -#: ../../reference/datamodel.rst:3764 +#: ../../reference/datamodel.rst:3776 msgid "" "Incorrectly attempting to invoke an unbound method of a class in this way is " "sometimes referred to as 'metaclass confusion', and is avoided by bypassing " "the instance when looking up special methods::" msgstr "" -#: ../../reference/datamodel.rst:3768 +#: ../../reference/datamodel.rst:3780 msgid "" ">>> type(1).__hash__(1) == hash(1)\n" "True\n" @@ -4491,14 +4491,14 @@ msgstr "" ">>> type(int).__hash__(int) == hash(int)\n" "True" -#: ../../reference/datamodel.rst:3773 +#: ../../reference/datamodel.rst:3785 msgid "" "In addition to bypassing any instance attributes in the interest of " "correctness, implicit special method lookup generally also bypasses the :" "meth:`~object.__getattribute__` method even of the object's metaclass::" msgstr "" -#: ../../reference/datamodel.rst:3777 +#: ../../reference/datamodel.rst:3789 msgid "" ">>> class Meta(type):\n" "... def __getattribute__(*args):\n" @@ -4523,7 +4523,7 @@ msgid "" "10" msgstr "" -#: ../../reference/datamodel.rst:3799 +#: ../../reference/datamodel.rst:3811 msgid "" "Bypassing the :meth:`~object.__getattribute__` machinery in this fashion " "provides significant scope for speed optimisations within the interpreter, " @@ -4532,29 +4532,29 @@ msgid "" "consistently invoked by the interpreter)." msgstr "" -#: ../../reference/datamodel.rst:3810 +#: ../../reference/datamodel.rst:3822 msgid "Coroutines" msgstr "協程" -#: ../../reference/datamodel.rst:3814 +#: ../../reference/datamodel.rst:3826 msgid "Awaitable Objects" msgstr "" -#: ../../reference/datamodel.rst:3816 +#: ../../reference/datamodel.rst:3828 msgid "" "An :term:`awaitable` object generally implements an :meth:`~object." "__await__` method. :term:`Coroutine objects ` returned from :" "keyword:`async def` functions are awaitable." msgstr "" -#: ../../reference/datamodel.rst:3822 +#: ../../reference/datamodel.rst:3834 msgid "" "The :term:`generator iterator` objects returned from generators decorated " "with :func:`types.coroutine` are also awaitable, but they do not implement :" "meth:`~object.__await__`." msgstr "" -#: ../../reference/datamodel.rst:3828 +#: ../../reference/datamodel.rst:3840 msgid "" "Must return an :term:`iterator`. Should be used to implement :term:" "`awaitable` objects. For instance, :class:`asyncio.Future` implements this " @@ -4562,7 +4562,7 @@ msgid "" "`object` class itself is not awaitable and does not provide this method." msgstr "" -#: ../../reference/datamodel.rst:3836 +#: ../../reference/datamodel.rst:3848 msgid "" "The language doesn't place any restriction on the type or value of the " "objects yielded by the iterator returned by ``__await__``, as this is " @@ -4570,15 +4570,15 @@ msgid "" "g. :mod:`asyncio`) that will be managing the :term:`awaitable` object." msgstr "" -#: ../../reference/datamodel.rst:3844 +#: ../../reference/datamodel.rst:3856 msgid ":pep:`492` for additional information about awaitable objects." msgstr "" -#: ../../reference/datamodel.rst:3850 +#: ../../reference/datamodel.rst:3862 msgid "Coroutine Objects" msgstr "協程物件" -#: ../../reference/datamodel.rst:3852 +#: ../../reference/datamodel.rst:3864 msgid "" ":term:`Coroutine objects ` are :term:`awaitable` objects. A " "coroutine's execution can be controlled by calling :meth:`~object.__await__` " @@ -4589,24 +4589,24 @@ msgid "" "should not directly raise unhandled :exc:`StopIteration` exceptions." msgstr "" -#: ../../reference/datamodel.rst:3860 +#: ../../reference/datamodel.rst:3872 msgid "" "Coroutines also have the methods listed below, which are analogous to those " "of generators (see :ref:`generator-methods`). However, unlike generators, " "coroutines do not directly support iteration." msgstr "" -#: ../../reference/datamodel.rst:3864 +#: ../../reference/datamodel.rst:3876 msgid "" "Coroutines are :ref:`generic ` over the types of their yield, " "send, and return values, respectively." msgstr "" -#: ../../reference/datamodel.rst:3867 +#: ../../reference/datamodel.rst:3879 msgid "It is a :exc:`RuntimeError` to await on a coroutine more than once." msgstr "" -#: ../../reference/datamodel.rst:3873 +#: ../../reference/datamodel.rst:3885 msgid "" "Starts or resumes execution of the coroutine. If *value* is ``None``, this " "is equivalent to advancing the iterator returned by :meth:`~object." @@ -4617,7 +4617,7 @@ msgid "" "value, described above." msgstr "" -#: ../../reference/datamodel.rst:3884 +#: ../../reference/datamodel.rst:3896 msgid "" "Raises the specified exception in the coroutine. This method delegates to " "the :meth:`~generator.throw` method of the iterator that caused the " @@ -4628,13 +4628,13 @@ msgid "" "not caught in the coroutine, it propagates back to the caller." msgstr "" -#: ../../reference/datamodel.rst:3895 +#: ../../reference/datamodel.rst:3907 msgid "" "The second signature \\(type\\[, value\\[, traceback\\]\\]\\) is deprecated " "and may be removed in a future version of Python." msgstr "" -#: ../../reference/datamodel.rst:3900 +#: ../../reference/datamodel.rst:3912 msgid "" "Causes the coroutine to clean itself up and exit. If the coroutine is " "suspended, this method first delegates to the :meth:`~generator.close` " @@ -4644,46 +4644,46 @@ msgid "" "is marked as having finished executing, even if it was never started." msgstr "" -#: ../../reference/datamodel.rst:3908 +#: ../../reference/datamodel.rst:3920 msgid "" "Coroutine objects are automatically closed using the above process when they " "are about to be destroyed." msgstr "" -#: ../../reference/datamodel.rst:3914 +#: ../../reference/datamodel.rst:3926 msgid "Asynchronous Iterators" msgstr "" -#: ../../reference/datamodel.rst:3916 +#: ../../reference/datamodel.rst:3928 msgid "" "An *asynchronous iterator* can call asynchronous code in its ``__anext__`` " "method." msgstr "" -#: ../../reference/datamodel.rst:3919 +#: ../../reference/datamodel.rst:3931 msgid "" "Asynchronous iterators can be used in an :keyword:`async for` statement." msgstr "" -#: ../../reference/datamodel.rst:3921 ../../reference/datamodel.rst:3970 +#: ../../reference/datamodel.rst:3933 ../../reference/datamodel.rst:3982 msgid "The :class:`object` class itself does not provide these methods." msgstr "" -#: ../../reference/datamodel.rst:3926 +#: ../../reference/datamodel.rst:3938 msgid "Must return an *asynchronous iterator* object." msgstr "" -#: ../../reference/datamodel.rst:3930 +#: ../../reference/datamodel.rst:3942 msgid "" "Must return an *awaitable* resulting in a next value of the iterator. " "Should raise a :exc:`StopAsyncIteration` error when the iteration is over." msgstr "" -#: ../../reference/datamodel.rst:3933 +#: ../../reference/datamodel.rst:3945 msgid "An example of an asynchronous iterable object::" msgstr "" -#: ../../reference/datamodel.rst:3935 +#: ../../reference/datamodel.rst:3947 msgid "" "class Reader:\n" " async def readline(self):\n" @@ -4711,53 +4711,53 @@ msgstr "" " raise StopAsyncIteration\n" " return val" -#: ../../reference/datamodel.rst:3950 +#: ../../reference/datamodel.rst:3962 msgid "" "Prior to Python 3.7, :meth:`~object.__aiter__` could return an *awaitable* " "that would resolve to an :term:`asynchronous iterator `." msgstr "" -#: ../../reference/datamodel.rst:3955 +#: ../../reference/datamodel.rst:3967 msgid "" "Starting with Python 3.7, :meth:`~object.__aiter__` must return an " "asynchronous iterator object. Returning anything else will result in a :exc:" "`TypeError` error." msgstr "" -#: ../../reference/datamodel.rst:3963 +#: ../../reference/datamodel.rst:3975 msgid "Asynchronous Context Managers" msgstr "" -#: ../../reference/datamodel.rst:3965 +#: ../../reference/datamodel.rst:3977 msgid "" "An *asynchronous context manager* is a *context manager* that is able to " "suspend execution in its ``__aenter__`` and ``__aexit__`` methods." msgstr "" -#: ../../reference/datamodel.rst:3968 +#: ../../reference/datamodel.rst:3980 msgid "" "Asynchronous context managers can be used in an :keyword:`async with` " "statement." msgstr "" -#: ../../reference/datamodel.rst:3974 +#: ../../reference/datamodel.rst:3986 msgid "" "Semantically similar to :meth:`~object.__enter__`, the only difference being " "that it must return an *awaitable*." msgstr "" -#: ../../reference/datamodel.rst:3979 +#: ../../reference/datamodel.rst:3991 msgid "" "Semantically similar to :meth:`~object.__exit__`, the only difference being " "that it must return an *awaitable*." msgstr "" -#: ../../reference/datamodel.rst:3982 +#: ../../reference/datamodel.rst:3994 msgid "An example of an asynchronous context manager class::" msgstr "" -#: ../../reference/datamodel.rst:3984 +#: ../../reference/datamodel.rst:3996 msgid "" "class AsyncContextManager:\n" " async def __aenter__(self):\n" @@ -4773,18 +4773,18 @@ msgstr "" " async def __aexit__(self, exc_type, exc, tb):\n" " await log('exiting context')" -#: ../../reference/datamodel.rst:3995 +#: ../../reference/datamodel.rst:4007 msgid "Footnotes" msgstr "註解" -#: ../../reference/datamodel.rst:3996 +#: ../../reference/datamodel.rst:4008 msgid "" "It *is* possible in some cases to change an object's type, under certain " "controlled conditions. It generally isn't a good idea though, since it can " "lead to some very strange behaviour if it is handled incorrectly." msgstr "" -#: ../../reference/datamodel.rst:4000 +#: ../../reference/datamodel.rst:4012 msgid "" "The :meth:`~object.__hash__`, :meth:`~object.__iter__`, :meth:`~object." "__reversed__`, :meth:`~object.__contains__`, :meth:`~object." @@ -4793,7 +4793,7 @@ msgid "" "by relying on the behavior that ``None`` is not callable." msgstr "" -#: ../../reference/datamodel.rst:4007 +#: ../../reference/datamodel.rst:4019 msgid "" "\"Does not support\" here means that the class has no such method, or the " "method returns :data:`NotImplemented`. Do not set the method to ``None`` if " @@ -4801,14 +4801,14 @@ msgid "" "instead have the opposite effect of explicitly *blocking* such fallback." msgstr "" -#: ../../reference/datamodel.rst:4013 +#: ../../reference/datamodel.rst:4025 msgid "" "For operands of the same type, it is assumed that if the non-reflected " "method (such as :meth:`~object.__add__`) fails then the operation is not " "supported, which is why the reflected method is not called." msgstr "" -#: ../../reference/datamodel.rst:4017 +#: ../../reference/datamodel.rst:4029 msgid "" "If the right operand's type is a subclass of the left operand's type, the " "reflected method having precedence allows subclasses to override their " @@ -4825,13 +4825,14 @@ msgstr "" #: ../../reference/datamodel.rst:447 ../../reference/datamodel.rst:467 #: ../../reference/datamodel.rst:475 ../../reference/datamodel.rst:488 #: ../../reference/datamodel.rst:505 ../../reference/datamodel.rst:541 -#: ../../reference/datamodel.rst:556 ../../reference/datamodel.rst:701 -#: ../../reference/datamodel.rst:839 ../../reference/datamodel.rst:863 -#: ../../reference/datamodel.rst:899 ../../reference/datamodel.rst:1177 -#: ../../reference/datamodel.rst:1345 ../../reference/datamodel.rst:1372 -#: ../../reference/datamodel.rst:1460 ../../reference/datamodel.rst:1578 -#: ../../reference/datamodel.rst:1686 ../../reference/datamodel.rst:1803 -#: ../../reference/datamodel.rst:2228 ../../reference/datamodel.rst:3277 +#: ../../reference/datamodel.rst:555 ../../reference/datamodel.rst:570 +#: ../../reference/datamodel.rst:715 ../../reference/datamodel.rst:853 +#: ../../reference/datamodel.rst:877 ../../reference/datamodel.rst:913 +#: ../../reference/datamodel.rst:1185 ../../reference/datamodel.rst:1353 +#: ../../reference/datamodel.rst:1380 ../../reference/datamodel.rst:1468 +#: ../../reference/datamodel.rst:1577 ../../reference/datamodel.rst:1685 +#: ../../reference/datamodel.rst:1802 ../../reference/datamodel.rst:2233 +#: ../../reference/datamodel.rst:3289 msgid "object" msgstr "object(物件)" @@ -4841,13 +4842,13 @@ msgstr "data(資料)" #: ../../reference/datamodel.rst:22 ../../reference/datamodel.rst:298 #: ../../reference/datamodel.rst:358 ../../reference/datamodel.rst:447 -#: ../../reference/datamodel.rst:488 ../../reference/datamodel.rst:839 -#: ../../reference/datamodel.rst:1401 ../../reference/datamodel.rst:1886 -#: ../../reference/datamodel.rst:2129 ../../reference/datamodel.rst:2135 -#: ../../reference/datamodel.rst:2228 ../../reference/datamodel.rst:2790 -#: ../../reference/datamodel.rst:3225 ../../reference/datamodel.rst:3395 -#: ../../reference/datamodel.rst:3430 ../../reference/datamodel.rst:3498 -#: ../../reference/datamodel.rst:3508 ../../reference/datamodel.rst:3536 +#: ../../reference/datamodel.rst:488 ../../reference/datamodel.rst:853 +#: ../../reference/datamodel.rst:1409 ../../reference/datamodel.rst:1885 +#: ../../reference/datamodel.rst:2134 ../../reference/datamodel.rst:2140 +#: ../../reference/datamodel.rst:2233 ../../reference/datamodel.rst:2800 +#: ../../reference/datamodel.rst:3237 ../../reference/datamodel.rst:3407 +#: ../../reference/datamodel.rst:3442 ../../reference/datamodel.rst:3510 +#: ../../reference/datamodel.rst:3520 ../../reference/datamodel.rst:3548 msgid "built-in function" msgstr "built-in function(內建函式)" @@ -4856,7 +4857,7 @@ msgid "id" msgstr "id" #: ../../reference/datamodel.rst:22 ../../reference/datamodel.rst:122 -#: ../../reference/datamodel.rst:2790 +#: ../../reference/datamodel.rst:2800 msgid "type" msgstr "type(型別)" @@ -4892,7 +4893,7 @@ msgstr "reference counting(參照計數)" msgid "unreachable object" msgstr "unreachable object(不可達物件)" -#: ../../reference/datamodel.rst:91 ../../reference/datamodel.rst:1177 +#: ../../reference/datamodel.rst:91 ../../reference/datamodel.rst:1185 msgid "container" msgstr "container(容器)" @@ -4906,24 +4907,24 @@ msgstr "extension(擴充)" #: ../../reference/datamodel.rst:122 ../../reference/datamodel.rst:420 #: ../../reference/datamodel.rst:421 ../../reference/datamodel.rst:524 -#: ../../reference/datamodel.rst:899 ../../reference/datamodel.rst:919 -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:913 ../../reference/datamodel.rst:933 +#: ../../reference/datamodel.rst:1409 msgid "module" msgstr "module(模組)" #: ../../reference/datamodel.rst:122 ../../reference/datamodel.rst:266 -#: ../../reference/datamodel.rst:839 +#: ../../reference/datamodel.rst:853 msgid "C" msgstr "C" #: ../../reference/datamodel.rst:122 ../../reference/datamodel.rst:266 -#: ../../reference/datamodel.rst:839 +#: ../../reference/datamodel.rst:853 msgid "language" msgstr "language(語言)" -#: ../../reference/datamodel.rst:135 ../../reference/datamodel.rst:1177 -#: ../../reference/datamodel.rst:1195 ../../reference/datamodel.rst:1345 -#: ../../reference/datamodel.rst:1365 +#: ../../reference/datamodel.rst:135 ../../reference/datamodel.rst:1185 +#: ../../reference/datamodel.rst:1203 ../../reference/datamodel.rst:1353 +#: ../../reference/datamodel.rst:1373 msgid "attribute" msgstr "attribute(屬性)" @@ -4943,7 +4944,7 @@ msgstr "..." msgid "ellipsis literal" msgstr "ellipsis literal(刪節號字面值)" -#: ../../reference/datamodel.rst:195 ../../reference/datamodel.rst:1372 +#: ../../reference/datamodel.rst:195 ../../reference/datamodel.rst:1380 msgid "numeric" msgstr "numeric(數值)" @@ -4979,16 +4980,16 @@ msgstr "number(數字)" msgid "Java" msgstr "Java" -#: ../../reference/datamodel.rst:284 ../../reference/datamodel.rst:3508 +#: ../../reference/datamodel.rst:284 ../../reference/datamodel.rst:3520 msgid "complex" msgstr "complex(複數)" #: ../../reference/datamodel.rst:298 ../../reference/datamodel.rst:447 -#: ../../reference/datamodel.rst:488 ../../reference/datamodel.rst:3225 +#: ../../reference/datamodel.rst:488 ../../reference/datamodel.rst:3237 msgid "len" msgstr "len" -#: ../../reference/datamodel.rst:298 ../../reference/datamodel.rst:1372 +#: ../../reference/datamodel.rst:298 ../../reference/datamodel.rst:1380 msgid "sequence" msgstr "sequence(序列)" @@ -5009,15 +5010,15 @@ msgstr "subscription(下標)" msgid "slicing" msgstr "slice(切片)" -#: ../../reference/datamodel.rst:316 ../../reference/datamodel.rst:1892 +#: ../../reference/datamodel.rst:316 ../../reference/datamodel.rst:1897 msgid "start (slice object attribute)" msgstr "start (slice 物件屬性)" -#: ../../reference/datamodel.rst:316 ../../reference/datamodel.rst:1892 +#: ../../reference/datamodel.rst:316 ../../reference/datamodel.rst:1897 msgid "stop (slice object attribute)" msgstr "stop (slice 物件屬性)" -#: ../../reference/datamodel.rst:316 ../../reference/datamodel.rst:1892 +#: ../../reference/datamodel.rst:316 ../../reference/datamodel.rst:1897 msgid "step (slice object attribute)" msgstr "step (slice 物件屬性)" @@ -5030,7 +5031,7 @@ msgid "immutable" msgstr "immutable(不可變)" #: ../../reference/datamodel.rst:354 ../../reference/datamodel.rst:358 -#: ../../reference/datamodel.rst:2104 ../../reference/datamodel.rst:2135 +#: ../../reference/datamodel.rst:2109 ../../reference/datamodel.rst:2140 msgid "string" msgstr "string(字串)" @@ -5070,7 +5071,7 @@ msgstr "singleton(單例)" msgid "empty" msgstr "empty(空的)" -#: ../../reference/datamodel.rst:396 ../../reference/datamodel.rst:2129 +#: ../../reference/datamodel.rst:396 ../../reference/datamodel.rst:2134 msgid "bytes" msgstr "bytes(位元組)" @@ -5086,14 +5087,14 @@ msgstr "mutable sequence(可變序列)" msgid "mutable" msgstr "mutable(可變的)" -#: ../../reference/datamodel.rst:408 ../../reference/datamodel.rst:1195 -#: ../../reference/datamodel.rst:1365 +#: ../../reference/datamodel.rst:408 ../../reference/datamodel.rst:1203 +#: ../../reference/datamodel.rst:1373 msgid "assignment" msgstr "assignment(賦值)" -#: ../../reference/datamodel.rst:408 ../../reference/datamodel.rst:899 -#: ../../reference/datamodel.rst:1840 ../../reference/datamodel.rst:2022 -#: ../../reference/datamodel.rst:3560 +#: ../../reference/datamodel.rst:408 ../../reference/datamodel.rst:913 +#: ../../reference/datamodel.rst:1839 ../../reference/datamodel.rst:2027 +#: ../../reference/datamodel.rst:3572 msgid "statement" msgstr "statement(陳述式)" @@ -5125,12 +5126,12 @@ msgstr "set(集合)" msgid "frozenset" msgstr "frozenset(凍結集合)" -#: ../../reference/datamodel.rst:488 ../../reference/datamodel.rst:1372 +#: ../../reference/datamodel.rst:488 ../../reference/datamodel.rst:1380 msgid "mapping" msgstr "mapping(對映)" -#: ../../reference/datamodel.rst:505 ../../reference/datamodel.rst:1177 -#: ../../reference/datamodel.rst:2228 +#: ../../reference/datamodel.rst:505 ../../reference/datamodel.rst:1185 +#: ../../reference/datamodel.rst:2233 msgid "dictionary" msgstr "dictionary(字典)" @@ -5143,680 +5144,686 @@ msgid "dbm.gnu" msgstr "dbm.gnu" #: ../../reference/datamodel.rst:541 +msgid "frozendict" +msgstr "frozendict(凍結字典)" + +#: ../../reference/datamodel.rst:555 msgid "callable" msgstr "callable(可呼叫物件)" -#: ../../reference/datamodel.rst:541 ../../reference/datamodel.rst:556 -#: ../../reference/datamodel.rst:783 ../../reference/datamodel.rst:801 -#: ../../reference/datamodel.rst:814 ../../reference/datamodel.rst:839 +#: ../../reference/datamodel.rst:555 ../../reference/datamodel.rst:570 +#: ../../reference/datamodel.rst:797 ../../reference/datamodel.rst:815 +#: ../../reference/datamodel.rst:828 ../../reference/datamodel.rst:853 msgid "function" msgstr "function (函式)" -#: ../../reference/datamodel.rst:541 ../../reference/datamodel.rst:1177 -#: ../../reference/datamodel.rst:1200 ../../reference/datamodel.rst:3171 +#: ../../reference/datamodel.rst:555 ../../reference/datamodel.rst:1185 +#: ../../reference/datamodel.rst:1208 ../../reference/datamodel.rst:3183 msgid "call" msgstr "call(呼叫)" -#: ../../reference/datamodel.rst:541 +#: ../../reference/datamodel.rst:555 msgid "invocation" msgstr "invocation(呼叫)" -#: ../../reference/datamodel.rst:541 +#: ../../reference/datamodel.rst:555 msgid "argument" msgstr "argument(引數)" -#: ../../reference/datamodel.rst:556 ../../reference/datamodel.rst:701 +#: ../../reference/datamodel.rst:570 ../../reference/datamodel.rst:715 msgid "user-defined" msgstr "user-defined(使用者定義)" -#: ../../reference/datamodel.rst:556 +#: ../../reference/datamodel.rst:570 msgid "user-defined function" msgstr "user-defined function(使用者定義函式)" -#: ../../reference/datamodel.rst:569 +#: ../../reference/datamodel.rst:583 msgid "__builtins__ (function attribute)" msgstr "__builtins__ (函式屬性)" -#: ../../reference/datamodel.rst:569 +#: ../../reference/datamodel.rst:583 msgid "__closure__ (function attribute)" msgstr "__closure__ (函式屬性)" -#: ../../reference/datamodel.rst:569 +#: ../../reference/datamodel.rst:583 msgid "__globals__ (function attribute)" msgstr "__globals__ (函式屬性)" -#: ../../reference/datamodel.rst:569 +#: ../../reference/datamodel.rst:583 msgid "global" msgstr "global(全域)" -#: ../../reference/datamodel.rst:569 ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:583 ../../reference/datamodel.rst:933 msgid "namespace" msgstr "namespace(命名空間)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__doc__ (function attribute)" msgstr "__doc__ (函式屬性)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__name__ (function attribute)" msgstr "__name__ (函式屬性)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__module__ (function attribute)" msgstr "__module__ (函式屬性)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__dict__ (function attribute)" msgstr "__dict__ (函式屬性)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__defaults__ (function attribute)" msgstr "__defaults__ (函式屬性)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__code__ (function attribute)" msgstr "__code__ (函式屬性)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__annotations__ (function attribute)" msgstr "__annotations__ (函式屬性)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__annotate__ (function attribute)" msgstr "__annotate__ (函式屬性)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__kwdefaults__ (function attribute)" msgstr "__kwdefaults__ (函式屬性)" -#: ../../reference/datamodel.rst:603 +#: ../../reference/datamodel.rst:617 msgid "__type_params__ (function attribute)" msgstr "__type_params__ (函式屬性)" -#: ../../reference/datamodel.rst:701 ../../reference/datamodel.rst:863 +#: ../../reference/datamodel.rst:715 ../../reference/datamodel.rst:877 msgid "method" msgstr "method(方法)" -#: ../../reference/datamodel.rst:701 +#: ../../reference/datamodel.rst:715 msgid "user-defined method" msgstr "user-defined method(使用者定義方法)" -#: ../../reference/datamodel.rst:709 +#: ../../reference/datamodel.rst:723 msgid "__func__ (method attribute)" msgstr "__func__ (方法屬性)" -#: ../../reference/datamodel.rst:709 +#: ../../reference/datamodel.rst:723 msgid "__self__ (method attribute)" msgstr "__self__ (方法屬性)" -#: ../../reference/datamodel.rst:709 +#: ../../reference/datamodel.rst:723 msgid "__doc__ (method attribute)" msgstr "__doc__ (方法屬性)" -#: ../../reference/datamodel.rst:709 +#: ../../reference/datamodel.rst:723 msgid "__name__ (method attribute)" msgstr "__name__ (方法屬性)" -#: ../../reference/datamodel.rst:709 +#: ../../reference/datamodel.rst:723 msgid "__module__ (method attribute)" msgstr "__module__ (方法屬性)" -#: ../../reference/datamodel.rst:783 ../../reference/datamodel.rst:1578 +#: ../../reference/datamodel.rst:797 ../../reference/datamodel.rst:1577 msgid "generator" msgstr "generator(產生器)" -#: ../../reference/datamodel.rst:783 +#: ../../reference/datamodel.rst:797 msgid "iterator" msgstr "itorator(疊代器)" -#: ../../reference/datamodel.rst:801 ../../reference/datamodel.rst:3806 +#: ../../reference/datamodel.rst:815 ../../reference/datamodel.rst:3818 msgid "coroutine" msgstr "coroutine(協程)" -#: ../../reference/datamodel.rst:814 +#: ../../reference/datamodel.rst:828 msgid "asynchronous generator" msgstr "asynchronous generator(非同步產生器)" -#: ../../reference/datamodel.rst:814 +#: ../../reference/datamodel.rst:828 msgid "asynchronous iterator" msgstr "asynchronous iterator(非同步疊代器)" -#: ../../reference/datamodel.rst:863 +#: ../../reference/datamodel.rst:877 msgid "built-in method" msgstr "built-in method(內建方法)" -#: ../../reference/datamodel.rst:863 +#: ../../reference/datamodel.rst:877 msgid "built-in" msgstr "built-in(內建)" -#: ../../reference/datamodel.rst:899 +#: ../../reference/datamodel.rst:913 msgid "import" msgstr "import(引入)" -#: ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:933 msgid "__name__ (module attribute)" msgstr "__name__ (模組屬性)" -#: ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:933 msgid "__spec__ (module attribute)" msgstr "__spec__ (模組屬性)" -#: ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:933 msgid "__package__ (module attribute)" msgstr "__package__ (模組屬性)" -#: ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:933 msgid "__loader__ (module attribute)" msgstr "__loader__ (模組屬性)" -#: ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:933 msgid "__path__ (module attribute)" msgstr "__path__ (模組屬性)" -#: ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:933 msgid "__file__ (module attribute)" msgstr "__file__ (模組屬性)" -#: ../../reference/datamodel.rst:919 -msgid "__cached__ (module attribute)" -msgstr "__cached__ (模組屬性)" - -#: ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:933 msgid "__doc__ (module attribute)" msgstr "__doc__ (模組屬性)" -#: ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:933 msgid "__annotations__ (module attribute)" msgstr "__annotations__ (模組屬性)" -#: ../../reference/datamodel.rst:919 +#: ../../reference/datamodel.rst:933 msgid "__annotate__ (module attribute)" msgstr "__annotate__ (模組屬性)" -#: ../../reference/datamodel.rst:1145 +#: ../../reference/datamodel.rst:933 +msgid "__lazy_modules__ (module attribute)" +msgstr "__lazy_modules__(模組屬性)" + +#: ../../reference/datamodel.rst:1153 msgid "__dict__ (module attribute)" msgstr "__dict__ (模組屬性)" -#: ../../reference/datamodel.rst:1177 ../../reference/datamodel.rst:1195 -#: ../../reference/datamodel.rst:1345 ../../reference/datamodel.rst:2005 -#: ../../reference/datamodel.rst:2901 +#: ../../reference/datamodel.rst:1185 ../../reference/datamodel.rst:1203 +#: ../../reference/datamodel.rst:1353 ../../reference/datamodel.rst:2010 +#: ../../reference/datamodel.rst:2913 msgid "class" msgstr "class(類別)" -#: ../../reference/datamodel.rst:1177 ../../reference/datamodel.rst:1345 -#: ../../reference/datamodel.rst:1365 +#: ../../reference/datamodel.rst:1185 ../../reference/datamodel.rst:1353 +#: ../../reference/datamodel.rst:1373 msgid "class instance" msgstr "class instance(類別實例)" -#: ../../reference/datamodel.rst:1177 ../../reference/datamodel.rst:1345 -#: ../../reference/datamodel.rst:3171 +#: ../../reference/datamodel.rst:1185 ../../reference/datamodel.rst:1353 +#: ../../reference/datamodel.rst:3183 msgid "instance" msgstr "instance(實例)" -#: ../../reference/datamodel.rst:1177 ../../reference/datamodel.rst:1200 +#: ../../reference/datamodel.rst:1185 ../../reference/datamodel.rst:1208 msgid "class object" msgstr "class object(類別物件)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__name__ (class attribute)" msgstr "__name__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__module__ (class attribute)" msgstr "__module__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__dict__ (class attribute)" msgstr "__dict__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__bases__ (class attribute)" msgstr "__bases__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__base__ (class attribute)" msgstr "__base__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__doc__ (class attribute)" msgstr "__doc__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__annotations__ (class attribute)" msgstr "__annotations__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__annotate__ (class attribute)" msgstr "__annotate__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__type_params__ (class attribute)" msgstr "__type_params__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__static_attributes__ (class attribute)" msgstr "__static_attributes__ (類別屬性)" -#: ../../reference/datamodel.rst:1207 +#: ../../reference/datamodel.rst:1215 msgid "__firstlineno__ (class attribute)" msgstr "__firstlineno__ (類別屬性)" -#: ../../reference/datamodel.rst:1383 +#: ../../reference/datamodel.rst:1391 msgid "__dict__ (instance attribute)" msgstr "__dict__ (實例屬性)" -#: ../../reference/datamodel.rst:1383 +#: ../../reference/datamodel.rst:1391 msgid "__class__ (instance attribute)" msgstr "__class__ (實例屬性)" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "open" msgstr "open" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "io" msgstr "io" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "popen() (in module os)" msgstr "popen() (於 os 模組中)" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "makefile() (socket method)" msgstr "makefile() (socket 方法)" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "sys.stdin" msgstr "sys.stdin" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "sys.stdout" msgstr "sys.stdout" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "sys.stderr" msgstr "sys.stderr" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "stdio" msgstr "stdio" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "stdin (in module sys)" msgstr "stdin (sys 模組中)" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "stdout (in module sys)" msgstr "stdout (sys 模組中)" -#: ../../reference/datamodel.rst:1401 +#: ../../reference/datamodel.rst:1409 msgid "stderr (in module sys)" msgstr "stderr (sys 模組中)" -#: ../../reference/datamodel.rst:1446 +#: ../../reference/datamodel.rst:1454 msgid "internal type" msgstr "internal type(內部型別)" -#: ../../reference/datamodel.rst:1446 +#: ../../reference/datamodel.rst:1454 msgid "types, internal" msgstr "types(型別), internal(內部)" -#: ../../reference/datamodel.rst:1460 +#: ../../reference/datamodel.rst:1468 msgid "bytecode" msgstr "bytecode(位元組碼)" -#: ../../reference/datamodel.rst:1460 +#: ../../reference/datamodel.rst:1468 msgid "code" msgstr "code(程式碼)" -#: ../../reference/datamodel.rst:1460 +#: ../../reference/datamodel.rst:1468 msgid "code object" msgstr "code object(程式碼物件)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_argcount (code object attribute)" msgstr "co_argcount (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_posonlyargcount (code object attribute)" msgstr "co_posonlyargcount (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_kwonlyargcount (code object attribute)" msgstr "co_kwonlyargcount (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_code (code object attribute)" msgstr "co_code (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_consts (code object attribute)" msgstr "co_consts (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_filename (code object attribute)" msgstr "co_filename (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_firstlineno (code object attribute)" msgstr "co_firstlineno (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_flags (code object attribute)" msgstr "co_flags (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 -msgid "co_lnotab (code object attribute)" -msgstr "co_lnotab (程式碼物件屬性)" - -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_name (code object attribute)" msgstr "co_name (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_names (code object attribute)" msgstr "co_names (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_nlocals (code object attribute)" msgstr "co_nlocals (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_stacksize (code object attribute)" msgstr "co_stacksize (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_varnames (code object attribute)" msgstr "co_varnames (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_cellvars (code object attribute)" msgstr "co_cellvars (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_freevars (code object attribute)" msgstr "co_freevars (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1471 +#: ../../reference/datamodel.rst:1479 msgid "co_qualname (code object attribute)" msgstr "co_qualname (程式碼物件屬性)" -#: ../../reference/datamodel.rst:1594 +#: ../../reference/datamodel.rst:1593 msgid "documentation string" msgstr "documentation string(文件字串)" -#: ../../reference/datamodel.rst:1686 +#: ../../reference/datamodel.rst:1685 msgid "frame" msgstr "frame" -#: ../../reference/datamodel.rst:1692 +#: ../../reference/datamodel.rst:1691 msgid "f_back (frame attribute)" msgstr "f_back (frame 屬性)" -#: ../../reference/datamodel.rst:1692 +#: ../../reference/datamodel.rst:1691 msgid "f_code (frame attribute)" msgstr "f_code (frame 屬性)" -#: ../../reference/datamodel.rst:1692 +#: ../../reference/datamodel.rst:1691 msgid "f_globals (frame attribute)" msgstr "f_globals (frame 屬性)" -#: ../../reference/datamodel.rst:1692 +#: ../../reference/datamodel.rst:1691 msgid "f_locals (frame attribute)" msgstr "f_locals (frame 屬性)" -#: ../../reference/datamodel.rst:1692 +#: ../../reference/datamodel.rst:1691 msgid "f_lasti (frame attribute)" msgstr "f_lasti (frame 屬性)" -#: ../../reference/datamodel.rst:1692 +#: ../../reference/datamodel.rst:1691 msgid "f_builtins (frame attribute)" msgstr "f_builtins (frame 屬性)" -#: ../../reference/datamodel.rst:1692 +#: ../../reference/datamodel.rst:1691 msgid "f_generator (frame attribute)" msgstr "f_generator (frame 屬性)" -#: ../../reference/datamodel.rst:1743 +#: ../../reference/datamodel.rst:1742 msgid "f_trace (frame attribute)" msgstr "f_trace (frame 屬性)" -#: ../../reference/datamodel.rst:1743 +#: ../../reference/datamodel.rst:1742 msgid "f_trace_lines (frame attribute)" msgstr "f_trace_lines (frame 屬性)" -#: ../../reference/datamodel.rst:1743 +#: ../../reference/datamodel.rst:1742 msgid "f_trace_opcodes (frame attribute)" msgstr "f_trace_opcodes (frame 屬性)" -#: ../../reference/datamodel.rst:1743 +#: ../../reference/datamodel.rst:1742 msgid "f_lineno (frame attribute)" msgstr "f_lineno (frame 屬性)" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "traceback" msgstr "traceback" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "stack" msgstr "stack(堆疊)" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "trace" msgstr "trace(追蹤)" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "exception" msgstr "exception(例外)" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "handler" msgstr "handler(處理器)" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "execution" msgstr "execution(執行)" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "exc_info (in module sys)" msgstr "exc_info (sys 模組中)" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "last_traceback (in module sys)" msgstr "last_traceback (sys 模組中)" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "sys.exc_info" msgstr "sys.exc_info" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "sys.exception" msgstr "sys.exception" -#: ../../reference/datamodel.rst:1803 +#: ../../reference/datamodel.rst:1802 msgid "sys.last_traceback" msgstr "sys.last_traceback" -#: ../../reference/datamodel.rst:1840 +#: ../../reference/datamodel.rst:1839 msgid "tb_frame (traceback attribute)" msgstr "tb_frame (traceback 屬性)" -#: ../../reference/datamodel.rst:1840 +#: ../../reference/datamodel.rst:1839 msgid "tb_lineno (traceback attribute)" msgstr "tb_lineno (traceback 屬性)" -#: ../../reference/datamodel.rst:1840 +#: ../../reference/datamodel.rst:1839 msgid "tb_lasti (traceback attribute)" msgstr "tb_lasti (traceback 屬性)" -#: ../../reference/datamodel.rst:1840 +#: ../../reference/datamodel.rst:1839 msgid "try" msgstr "try" -#: ../../reference/datamodel.rst:1870 +#: ../../reference/datamodel.rst:1869 msgid "tb_next (traceback attribute)" msgstr "tb_next (traceback 屬性)" -#: ../../reference/datamodel.rst:1886 ../../reference/datamodel.rst:3277 +#: ../../reference/datamodel.rst:1885 ../../reference/datamodel.rst:3289 msgid "slice" msgstr "slice(切片)" -#: ../../reference/datamodel.rst:1940 +#: ../../reference/datamodel.rst:1945 msgid "operator" msgstr "operator(運算子)" -#: ../../reference/datamodel.rst:1940 +#: ../../reference/datamodel.rst:1945 msgid "overloading" msgstr "overloading(多載)" -#: ../../reference/datamodel.rst:1940 +#: ../../reference/datamodel.rst:1945 msgid "__getitem__() (mapping object method)" msgstr "__getitem__() (對映物件方法)" -#: ../../reference/datamodel.rst:1976 +#: ../../reference/datamodel.rst:1981 msgid "subclassing" msgstr "subclassing(子類別化)" -#: ../../reference/datamodel.rst:1976 +#: ../../reference/datamodel.rst:1981 msgid "immutable types" msgstr "immutable types(不可變型別)" -#: ../../reference/datamodel.rst:2005 +#: ../../reference/datamodel.rst:2010 msgid "constructor" msgstr "constructor(建構函式)" -#: ../../reference/datamodel.rst:2022 +#: ../../reference/datamodel.rst:2027 msgid "destructor" msgstr "destructor(解構函式)" -#: ../../reference/datamodel.rst:2022 +#: ../../reference/datamodel.rst:2027 msgid "finalizer" msgstr "finalizer(終結函式)" -#: ../../reference/datamodel.rst:2022 +#: ../../reference/datamodel.rst:2027 msgid "del" msgstr "del" -#: ../../reference/datamodel.rst:2086 +#: ../../reference/datamodel.rst:2091 msgid "repr() (built-in function)" msgstr "repr() (內建函式)" -#: ../../reference/datamodel.rst:2086 +#: ../../reference/datamodel.rst:2091 msgid "__repr__() (object method)" msgstr "__repr__() (物件方法)" -#: ../../reference/datamodel.rst:2104 +#: ../../reference/datamodel.rst:2109 msgid "__str__() (object method)" msgstr "__str__() (物件方法)" -#: ../../reference/datamodel.rst:2104 +#: ../../reference/datamodel.rst:2109 msgid "format() (built-in function)" msgstr "format() (內建函式)" -#: ../../reference/datamodel.rst:2104 +#: ../../reference/datamodel.rst:2109 msgid "print() (built-in function)" msgstr "print() (內建函式)" -#: ../../reference/datamodel.rst:2135 +#: ../../reference/datamodel.rst:2140 msgid "__format__() (object method)" msgstr "__format__() (物件方法)" -#: ../../reference/datamodel.rst:2135 +#: ../../reference/datamodel.rst:2140 msgid "conversion" msgstr "conversion" -#: ../../reference/datamodel.rst:2135 +#: ../../reference/datamodel.rst:2140 msgid "print" msgstr "print" -#: ../../reference/datamodel.rst:2177 +#: ../../reference/datamodel.rst:2182 msgid "comparisons" msgstr "comparison(比較)" -#: ../../reference/datamodel.rst:2228 +#: ../../reference/datamodel.rst:2233 msgid "hash" msgstr "hash(雜湊)" -#: ../../reference/datamodel.rst:2309 +#: ../../reference/datamodel.rst:2314 msgid "__len__() (mapping object method)" msgstr "__len__() (對映物件方法)" -#: ../../reference/datamodel.rst:2414 +#: ../../reference/datamodel.rst:2419 msgid "__getattr__ (module attribute)" msgstr "__getattr__ (模組屬性)" -#: ../../reference/datamodel.rst:2414 +#: ../../reference/datamodel.rst:2419 msgid "__dir__ (module attribute)" msgstr "__dir__ (模組屬性)" -#: ../../reference/datamodel.rst:2414 +#: ../../reference/datamodel.rst:2419 msgid "__class__ (module attribute)" msgstr "__class__ (模組屬性)" -#: ../../reference/datamodel.rst:2790 +#: ../../reference/datamodel.rst:2800 msgid "metaclass" msgstr "metaclass(元類別)" -#: ../../reference/datamodel.rst:2790 +#: ../../reference/datamodel.rst:2800 msgid "= (equals)" msgstr "= (等號)" -#: ../../reference/datamodel.rst:2790 +#: ../../reference/datamodel.rst:2800 msgid "class definition" msgstr "class definition(類別定義)" -#: ../../reference/datamodel.rst:2854 +#: ../../reference/datamodel.rst:2866 msgid "metaclass hint" msgstr "metaclass hint(元類別提示)" -#: ../../reference/datamodel.rst:2877 +#: ../../reference/datamodel.rst:2889 msgid "__prepare__ (metaclass method)" msgstr "__prepare__ (元類別方法)" -#: ../../reference/datamodel.rst:2901 +#: ../../reference/datamodel.rst:2913 msgid "body" msgstr "body" -#: ../../reference/datamodel.rst:2921 +#: ../../reference/datamodel.rst:2933 msgid "__class__ (method cell)" msgstr "__class__ (方法 cell)" -#: ../../reference/datamodel.rst:2921 +#: ../../reference/datamodel.rst:2933 msgid "__classcell__ (class namespace entry)" msgstr "__classcell__ (類別命名空間項目)" -#: ../../reference/datamodel.rst:3225 +#: ../../reference/datamodel.rst:3237 msgid "__bool__() (object method)" msgstr "__bool__() (物件方法)" -#: ../../reference/datamodel.rst:3395 ../../reference/datamodel.rst:3430 +#: ../../reference/datamodel.rst:3407 ../../reference/datamodel.rst:3442 msgid "divmod" msgstr "divmod" -#: ../../reference/datamodel.rst:3395 ../../reference/datamodel.rst:3430 +#: ../../reference/datamodel.rst:3407 ../../reference/datamodel.rst:3442 msgid "pow" msgstr "pow" -#: ../../reference/datamodel.rst:3498 +#: ../../reference/datamodel.rst:3510 msgid "abs" msgstr "abs" -#: ../../reference/datamodel.rst:3508 +#: ../../reference/datamodel.rst:3520 msgid "int" msgstr "int" -#: ../../reference/datamodel.rst:3508 +#: ../../reference/datamodel.rst:3520 msgid "float" msgstr "float" -#: ../../reference/datamodel.rst:3536 +#: ../../reference/datamodel.rst:3548 msgid "round" msgstr "round" -#: ../../reference/datamodel.rst:3560 +#: ../../reference/datamodel.rst:3572 msgid "with" msgstr "with" -#: ../../reference/datamodel.rst:3560 +#: ../../reference/datamodel.rst:3572 msgid "context manager" msgstr "context manager(情境管理器)" + +#~ msgid "__cached__ (module attribute)" +#~ msgstr "__cached__ (模組屬性)" + +#~ msgid "co_lnotab (code object attribute)" +#~ msgstr "co_lnotab (程式碼物件屬性)" diff --git a/reference/expressions.po b/reference/expressions.po index 708703ed885..ec4504627c0 100644 --- a/reference/expressions.po +++ b/reference/expressions.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -69,36 +69,54 @@ msgstr "" #: ../../reference/expressions.rst:50 msgid "" "Atoms are the most basic elements of expressions. The simplest atoms are :" -"ref:`names ` or literals. Forms enclosed in parentheses, " -"brackets or braces are also categorized syntactically as atoms." +"ref:`builtin constants `, :ref:`names ` and :" +"ref:`literals `. More complex atoms are enclosed in paired " +"delimiters:" msgstr "" #: ../../reference/expressions.rst:55 +msgid "" +"``()`` (parentheses): :ref:`groups `, :ref:`tuple displays " +"`, :ref:`yield atoms `, and :ref:`generator " +"expressions `;" +msgstr "" + +#: ../../reference/expressions.rst:59 +msgid "``[]`` (square brackets): :ref:`list displays `;" +msgstr "" + +#: ../../reference/expressions.rst:60 +msgid "" +"``{}`` (curly braces): :ref:`dictionary ` and :ref:`set ` " +"displays." +msgstr "" + +#: ../../reference/expressions.rst:62 msgid "Formally, the syntax for atoms is:" msgstr "" -#: ../../reference/expressions.rst:80 +#: ../../reference/expressions.rst:91 msgid "Built-in constants" msgstr "內建常數" -#: ../../reference/expressions.rst:82 +#: ../../reference/expressions.rst:93 msgid "" "The keywords ``True``, ``False``, and ``None`` name :ref:`built-in constants " "`. The token ``...`` names the :py:data:`Ellipsis` constant." msgstr "" -#: ../../reference/expressions.rst:86 +#: ../../reference/expressions.rst:97 msgid "Evaluation of these atoms yields the corresponding value." msgstr "" -#: ../../reference/expressions.rst:90 +#: ../../reference/expressions.rst:101 msgid "" "Several more built-in constants are available as global variables, but only " "the ones mentioned here are :ref:`keywords `. In particular, these " "names cannot be reassigned or used as attributes:" msgstr "" -#: ../../reference/expressions.rst:94 +#: ../../reference/expressions.rst:105 msgid "" ">>> False = 123\n" " File \"\", line 1\n" @@ -107,81 +125,85 @@ msgid "" "SyntaxError: cannot assign to False" msgstr "" -#: ../../reference/expressions.rst:105 +#: ../../reference/expressions.rst:113 +msgid "Formally, the syntax for built-in constants is:" +msgstr "" + +#: ../../reference/expressions.rst:123 msgid "Identifiers (Names)" msgstr "" -#: ../../reference/expressions.rst:109 +#: ../../reference/expressions.rst:127 msgid "" "An identifier occurring as an atom is a name. See section :ref:" "`identifiers` for lexical definition and section :ref:`naming` for " "documentation of naming and binding." msgstr "" -#: ../../reference/expressions.rst:115 +#: ../../reference/expressions.rst:133 msgid "" "When the name is bound to an object, evaluation of the atom yields that " "object. When a name is not bound, an attempt to evaluate it raises a :exc:" "`NameError` exception." msgstr "" -#: ../../reference/expressions.rst:126 +#: ../../reference/expressions.rst:144 msgid "Private name mangling" msgstr "" -#: ../../reference/expressions.rst:128 +#: ../../reference/expressions.rst:146 msgid "" "When an identifier that textually occurs in a class definition begins with " "two or more underscore characters and does not end in two or more " "underscores, it is considered a :dfn:`private name` of that class." msgstr "" -#: ../../reference/expressions.rst:134 +#: ../../reference/expressions.rst:152 msgid "The :ref:`class specifications `." msgstr "" -#: ../../reference/expressions.rst:136 +#: ../../reference/expressions.rst:154 msgid "" "More precisely, private names are transformed to a longer form before code " "is generated for them. If the transformed name is longer than 255 " "characters, implementation-defined truncation may happen." msgstr "" -#: ../../reference/expressions.rst:140 +#: ../../reference/expressions.rst:158 msgid "" "The transformation is independent of the syntactical context in which the " "identifier is used but only the following private identifiers are mangled:" msgstr "" -#: ../../reference/expressions.rst:143 +#: ../../reference/expressions.rst:161 msgid "" "Any name used as the name of a variable that is assigned or read or any name " "of an attribute being accessed." msgstr "" -#: ../../reference/expressions.rst:146 +#: ../../reference/expressions.rst:164 msgid "" "The :attr:`~definition.__name__` attribute of nested functions, classes, and " "type aliases is however not mangled." msgstr "" -#: ../../reference/expressions.rst:149 +#: ../../reference/expressions.rst:167 msgid "" "The name of imported modules, e.g., ``__spam`` in ``import __spam``. If the " "module is part of a package (i.e., its name contains a dot), the name is " "*not* mangled, e.g., the ``__foo`` in ``import __foo.bar`` is not mangled." msgstr "" -#: ../../reference/expressions.rst:154 +#: ../../reference/expressions.rst:172 msgid "" "The name of an imported member, e.g., ``__f`` in ``from spam import __f``." msgstr "" -#: ../../reference/expressions.rst:156 +#: ../../reference/expressions.rst:174 msgid "The transformation rule is defined as follows:" msgstr "" -#: ../../reference/expressions.rst:158 +#: ../../reference/expressions.rst:176 msgid "" "The class name, with leading underscores removed and a single leading " "underscore inserted, is inserted in front of the identifier, e.g., the " @@ -189,25 +211,25 @@ msgid "" "``__Foo`` is transformed to ``_Foo__spam``." msgstr "" -#: ../../reference/expressions.rst:163 +#: ../../reference/expressions.rst:181 msgid "" "If the class name consists only of underscores, the transformation is the " "identity, e.g., the identifier ``__spam`` occurring in a class named ``_`` " "or ``__`` is left as is." msgstr "" -#: ../../reference/expressions.rst:170 +#: ../../reference/expressions.rst:188 msgid "Literals" msgstr "" -#: ../../reference/expressions.rst:174 +#: ../../reference/expressions.rst:192 msgid "" "A :dfn:`literal` is a textual representation of a value. Python supports " "numeric, string and bytes literals. :ref:`Format strings ` and :" "ref:`template strings ` are treated as string literals." msgstr "" -#: ../../reference/expressions.rst:179 +#: ../../reference/expressions.rst:197 msgid "" "Numeric literals consist of a single :token:`NUMBER ` " "token, which names an integer, floating-point number, or an imaginary " @@ -215,20 +237,20 @@ msgid "" "details." msgstr "" -#: ../../reference/expressions.rst:183 +#: ../../reference/expressions.rst:201 msgid "" "String and bytes literals may consist of several tokens. See section :ref:" "`string-concatenation` for details." msgstr "" -#: ../../reference/expressions.rst:186 +#: ../../reference/expressions.rst:204 msgid "" "Note that negative and complex numbers, like ``-3`` or ``3+4.2j``, are " "syntactically not literals, but :ref:`unary ` or :ref:`binary " "` arithmetic operations involving the ``-`` or ``+`` operator." msgstr "" -#: ../../reference/expressions.rst:191 +#: ../../reference/expressions.rst:209 msgid "" "Evaluation of a literal yields an object of the given type (:class:`int`, :" "class:`float`, :class:`complex`, :class:`str`, :class:`bytes`, or :class:" @@ -236,15 +258,15 @@ msgid "" "approximated in the case of floating-point and imaginary literals." msgstr "" -#: ../../reference/expressions.rst:197 +#: ../../reference/expressions.rst:215 msgid "The formal grammar for literals is:" msgstr "" -#: ../../reference/expressions.rst:210 +#: ../../reference/expressions.rst:229 msgid "Literals and object identity" msgstr "" -#: ../../reference/expressions.rst:212 +#: ../../reference/expressions.rst:231 msgid "" "All literals correspond to immutable data types, and hence the object's " "identity is less important than its value. Multiple evaluations of literals " @@ -253,17 +275,17 @@ msgid "" "the same value." msgstr "" -#: ../../reference/expressions.rst:218 +#: ../../reference/expressions.rst:237 msgid "CPython implementation detail" msgstr "" -#: ../../reference/expressions.rst:220 +#: ../../reference/expressions.rst:239 msgid "" "For example, in CPython, *small* integers with the same value evaluate to " "the same object::" msgstr "" -#: ../../reference/expressions.rst:223 +#: ../../reference/expressions.rst:242 msgid "" ">>> x = 7\n" ">>> y = 7\n" @@ -271,11 +293,11 @@ msgid "" "True" msgstr "" -#: ../../reference/expressions.rst:228 +#: ../../reference/expressions.rst:247 msgid "However, large integers evaluate to different objects::" msgstr "" -#: ../../reference/expressions.rst:230 +#: ../../reference/expressions.rst:249 msgid "" ">>> x = 123456789\n" ">>> y = 123456789\n" @@ -283,20 +305,20 @@ msgid "" "False" msgstr "" -#: ../../reference/expressions.rst:235 +#: ../../reference/expressions.rst:254 msgid "" "This behavior may change in future versions of CPython. In particular, the " "boundary between \"small\" and \"large\" integers has already changed in the " "past." msgstr "" -#: ../../reference/expressions.rst:239 +#: ../../reference/expressions.rst:258 msgid "" "CPython will emit a :py:exc:`SyntaxWarning` when you compare literals using " "``is``::" msgstr "" -#: ../../reference/expressions.rst:242 +#: ../../reference/expressions.rst:261 msgid "" ">>> x = 7\n" ">>> x is 7\n" @@ -304,11 +326,11 @@ msgid "" "True" msgstr "" -#: ../../reference/expressions.rst:247 +#: ../../reference/expressions.rst:266 msgid "See :ref:`faq-identity-with-is` for more information." msgstr "" -#: ../../reference/expressions.rst:249 +#: ../../reference/expressions.rst:268 msgid "" ":ref:`Template strings ` are immutable but may reference mutable " "objects as :class:`~string.templatelib.Interpolation` values. For the " @@ -316,24 +338,24 @@ msgid "" "their structure and the *identity* of the values match." msgstr "" -#: ../../reference/expressions.rst:256 +#: ../../reference/expressions.rst:275 msgid "" "Currently, each evaluation of a template string results in a different " "object." msgstr "" -#: ../../reference/expressions.rst:263 +#: ../../reference/expressions.rst:282 msgid "String literal concatenation" msgstr "" -#: ../../reference/expressions.rst:265 +#: ../../reference/expressions.rst:284 msgid "" "Multiple adjacent string or bytes literals, possibly using different quoting " "conventions, are allowed, and their meaning is the same as their " "concatenation::" msgstr "" -#: ../../reference/expressions.rst:269 +#: ../../reference/expressions.rst:288 msgid "" ">>> \"hello\" 'world'\n" "\"helloworld\"" @@ -341,14 +363,14 @@ msgstr "" ">>> \"hello\" 'world'\n" "\"helloworld\"" -#: ../../reference/expressions.rst:272 +#: ../../reference/expressions.rst:291 msgid "" "This feature is defined at the syntactical level, so it only works with " "literals. To concatenate string expressions at run time, the '+' operator " "may be used::" msgstr "" -#: ../../reference/expressions.rst:275 +#: ../../reference/expressions.rst:294 msgid "" ">>> greeting = \"Hello\"\n" ">>> space = \" \"\n" @@ -362,13 +384,13 @@ msgstr "" ">>> print(greeting + space + name) # 不是:print(greeting space name)\n" "Hello Blaise" -#: ../../reference/expressions.rst:281 +#: ../../reference/expressions.rst:300 msgid "" "Literal concatenation can freely mix raw strings, triple-quoted strings, and " "formatted string literals. For example::" msgstr "" -#: ../../reference/expressions.rst:285 +#: ../../reference/expressions.rst:304 msgid "" ">>> \"Hello\" r', ' f\"{name}!\"\n" "\"Hello, Blaise!\"" @@ -376,28 +398,28 @@ msgstr "" ">>> \"Hello\" r', ' f\"{name}!\"\n" "\"Hello, Blaise!\"" -#: ../../reference/expressions.rst:288 +#: ../../reference/expressions.rst:307 msgid "" "This feature can be used to reduce the number of backslashes needed, to " "split long strings conveniently across long lines, or even to add comments " "to parts of strings. For example::" msgstr "" -#: ../../reference/expressions.rst:292 +#: ../../reference/expressions.rst:311 msgid "" "re.compile(\"[A-Za-z_]\" # letter or underscore\n" " \"[A-Za-z0-9_]*\" # letter, digit or underscore\n" " )" msgstr "" -#: ../../reference/expressions.rst:296 +#: ../../reference/expressions.rst:315 msgid "" "However, bytes literals may only be combined with other byte literals; not " "with string literals of any kind. Also, template string literals may only be " "combined with other template string literals::" msgstr "" -#: ../../reference/expressions.rst:301 +#: ../../reference/expressions.rst:320 msgid "" ">>> t\"Hello\" t\"{name}!\"\n" "Template(strings=('Hello', '!'), interpolations=(...))" @@ -405,234 +427,570 @@ msgstr "" ">>> t\"Hello\" t\"{name}!\"\n" "Template(strings=('Hello', '!'), interpolations=(...))" -#: ../../reference/expressions.rst:304 +#: ../../reference/expressions.rst:323 msgid "Formally:" msgstr "" -#: ../../reference/expressions.rst:315 -msgid "Parenthesized forms" +#: ../../reference/expressions.rst:339 +msgid "Parenthesized groups" msgstr "" -#: ../../reference/expressions.rst:321 +#: ../../reference/expressions.rst:341 msgid "" -"A parenthesized form is an optional expression list enclosed in parentheses:" +"A :dfn:`parenthesized group` is an expression enclosed in parentheses. The " +"group evaluates to the same value as the expression inside." msgstr "" -#: ../../reference/expressions.rst:326 +#: ../../reference/expressions.rst:344 msgid "" -"A parenthesized expression list yields whatever that expression list yields: " -"if the list contains at least one comma, it yields a tuple; otherwise, it " -"yields the single expression that makes up the expression list." +"Groups are used to override or clarify :ref:`operator precedence `, in the same way as in math notation. For example::" msgstr "" -#: ../../reference/expressions.rst:332 +#: ../../reference/expressions.rst:349 msgid "" -"An empty pair of parentheses yields an empty tuple object. Since tuples are " -"immutable, the same rules as for literals apply (i.e., two occurrences of " -"the empty tuple may or may not yield the same object)." +">>> 3 << 2 | 4\n" +"12\n" +">>> 3 << (2 | 4) # Override precedence of the | (bitwise OR)\n" +"192\n" +">>> (3 << 2) | 4 # Same as without parentheses (but more clear)\n" +"12" msgstr "" +">>> 3 << 2 | 4\n" +"12\n" +">>> 3 << (2 | 4) # 覆寫 |(位元 OR)的優先順序\n" +"192\n" +">>> (3 << 2) | 4 # 與不加括號相同(但更清楚)\n" +"12" -#: ../../reference/expressions.rst:340 +#: ../../reference/expressions.rst:356 msgid "" -"Note that tuples are not formed by the parentheses, but rather by use of the " -"comma. The exception is the empty tuple, for which parentheses *are* " -"required --- allowing unparenthesized \"nothing\" in expressions would cause " -"ambiguities and allow common typos to pass uncaught." +"Note that not everything in parentheses is a *group*. Specifically, a " +"parenthesized group must include exactly one expression, and cannot end with " +"a comma. See :ref:`tuple displays ` and :ref:`generator " +"expressions ` for other parenthesized forms." msgstr "" -#: ../../reference/expressions.rst:349 -msgid "Displays for lists, sets and dictionaries" +#: ../../reference/expressions.rst:362 +msgid "Formally, the syntax for groups is:" +msgstr "" + +#: ../../reference/expressions.rst:373 +msgid "Container displays" +msgstr "容器顯示 (container displays)" + +#: ../../reference/expressions.rst:377 +msgid "" +"For constructing builtin containers (lists, sets, tuples or dictionaries), " +"Python provides special syntax called :dfn:`displays`. There are subtle " +"differences between the four kinds of displays, detailed in the following " +"sections. All displays, however, consist of comma-separated items enclosed " +"in paired delimiters." msgstr "" -#: ../../reference/expressions.rst:353 +#: ../../reference/expressions.rst:384 msgid "" -"For constructing a list, a set or a dictionary Python provides special " -"syntax called \"displays\", each of them in two flavors:" +"For example, a *list display* is a series of expressions enclosed in square " +"brackets::" msgstr "" -#: ../../reference/expressions.rst:356 -msgid "either the container contents are listed explicitly, or" +#: ../../reference/expressions.rst:387 +msgid "" +">>> [\"one\", \"two\", \"three\"]\n" +"['one', 'two', 'three']\n" +">>> [1 + 2, 2 + 3]\n" +"[3, 5]" msgstr "" +">>> [\"one\", \"two\", \"three\"]\n" +"['one', 'two', 'three']\n" +">>> [1 + 2, 2 + 3]\n" +"[3, 5]" -#: ../../reference/expressions.rst:358 +#: ../../reference/expressions.rst:392 msgid "" -"they are computed via a set of looping and filtering instructions, called a :" -"dfn:`comprehension`." +"In list, tuple and dictionary (but not set) displays, the series may be " +"empty::" msgstr "" -#: ../../reference/expressions.rst:366 -msgid "Common syntax elements for comprehensions are:" +#: ../../reference/expressions.rst:394 +msgid "" +">>> [] # empty list\n" +"[]\n" +">>> () # empty tuple\n" +"()\n" +">>> {} # empty dictionary\n" +"{}" msgstr "" +">>> [] # 空串列\n" +"[]\n" +">>> () # 空元組\n" +"()\n" +">>> {} # 空字典\n" +"{}" -#: ../../reference/expressions.rst:374 +#: ../../reference/expressions.rst:403 msgid "" -"The comprehension consists of a single expression followed by at least one :" -"keyword:`!for` clause and zero or more :keyword:`!for` or :keyword:`!if` " -"clauses. In this case, the elements of the new container are those that " -"would be produced by considering each of the :keyword:`!for` or :keyword:`!" -"if` clauses a block, nesting from left to right, and evaluating the " -"expression to produce an element each time the innermost block is reached." +"If the series is not empty, the items may be followed by an additional " +"comma, which has no effect::" msgstr "" -#: ../../reference/expressions.rst:381 +#: ../../reference/expressions.rst:406 msgid "" -"However, aside from the iterable expression in the leftmost :keyword:`!for` " -"clause, the comprehension is executed in a separate implicitly nested scope. " -"This ensures that names assigned to in the target list don't \"leak\" into " -"the enclosing scope." +">>> [\"one\", \"two\", \"three\",] # note comma after \"three\"\n" +"['one', 'two', 'three']" msgstr "" +">>> [\"one\", \"two\", \"three\",] # 注意 \"three\" 後面的逗號\n" +"['one', 'two', 'three']" -#: ../../reference/expressions.rst:385 +#: ../../reference/expressions.rst:411 msgid "" -"The iterable expression in the leftmost :keyword:`!for` clause is evaluated " -"directly in the enclosing scope and then passed as an argument to the " -"implicitly nested scope. Subsequent :keyword:`!for` clauses and any filter " -"condition in the leftmost :keyword:`!for` clause cannot be evaluated in the " -"enclosing scope as they may depend on the values obtained from the leftmost " -"iterable. For example: ``[x*y for x in range(10) for y in range(x, x+10)]``." +"The trailing comma is often used for displays that span multiple lines " +"(using :ref:`implicit line joining `), so when a future " +"programmer adds a new entry at the end, they do not need to modify an " +"existing line::" msgstr "" -#: ../../reference/expressions.rst:392 +#: ../../reference/expressions.rst:416 msgid "" -"To ensure the comprehension always results in a container of the appropriate " -"type, ``yield`` and ``yield from`` expressions are prohibited in the " -"implicitly nested scope." +">>> [\n" +"... 'one',\n" +"... 'two',\n" +"... 'three',\n" +"... ]\n" +"['one', 'two', 'three']" msgstr "" +">>> [\n" +"... 'one',\n" +"... 'two',\n" +"... 'three',\n" +"... ]\n" +"['one', 'two', 'three']" -#: ../../reference/expressions.rst:399 +#: ../../reference/expressions.rst:423 msgid "" -"Since Python 3.6, in an :keyword:`async def` function, an :keyword:`!async " -"for` clause may be used to iterate over a :term:`asynchronous iterator`. A " -"comprehension in an :keyword:`!async def` function may consist of either a :" -"keyword:`!for` or :keyword:`!async for` clause following the leading " -"expression, may contain additional :keyword:`!for` or :keyword:`!async for` " -"clauses, and may also use :keyword:`await` expressions." +"At runtime, when a display is evaluated, the listed items are evaluated from " +"left to right and placed into a new container of the appropriate type." msgstr "" -#: ../../reference/expressions.rst:406 +#: ../../reference/expressions.rst:430 msgid "" -"If a comprehension contains :keyword:`!async for` clauses, or if it " -"contains :keyword:`!await` expressions or other asynchronous comprehensions " -"anywhere except the iterable expression in the leftmost :keyword:`!for` " -"clause, it is called an :dfn:`asynchronous comprehension`. An asynchronous " -"comprehension may suspend the execution of the coroutine function in which " -"it appears. See also :pep:`530`." +"For tuple, list and set (but not dict) displays, any item in the display may " +"be prefixed with an asterisk (``*``). This denotes :ref:`iterable unpacking " +"`. At runtime, the asterisk-prefixed expression must " +"evaluate to an iterable, whose contents are inserted into the container at " +"the location of the unpacking. For example::" +msgstr "" + +#: ../../reference/expressions.rst:437 +msgid "" +">>> numbers = (1, 2)\n" +">>> [*numbers, 'word', *numbers]\n" +"[1, 2, 'word', 1, 2]" msgstr "" +">>> numbers = (1, 2)\n" +">>> [*numbers, 'word', *numbers]\n" +"[1, 2, 'word', 1, 2]" -#: ../../reference/expressions.rst:413 -msgid "Asynchronous comprehensions were introduced." +#: ../../reference/expressions.rst:441 +msgid "" +"Dictionary displays use a similar mechanism called *dictionary unpacking*, " +"denoted with a double asterisk (``**``). See :ref:`dict` for details." msgstr "" -#: ../../reference/expressions.rst:416 ../../reference/expressions.rst:656 -msgid "``yield`` and ``yield from`` prohibited in the implicitly nested scope." +#: ../../reference/expressions.rst:446 +msgid "" +"A more advanced form of displays are :dfn:`comprehensions`, where items are " +"computed via a set of looping and filtering instructions. See the :ref:" +"`comprehensions` section for details." msgstr "" -#: ../../reference/expressions.rst:419 +#: ../../reference/expressions.rst:450 msgid "" -"Asynchronous comprehensions are now allowed inside comprehensions in " -"asynchronous functions. Outer comprehensions implicitly become asynchronous." +"Iterable and dictionary unpacking in displays, originally proposed by :pep:" +"`448`." msgstr "" -#: ../../reference/expressions.rst:428 +#: ../../reference/expressions.rst:458 msgid "List displays" msgstr "" -#: ../../reference/expressions.rst:438 +#: ../../reference/expressions.rst:468 msgid "" -"A list display is a possibly empty series of expressions enclosed in square " -"brackets:" +"A :dfn:`list display` is a possibly empty series of expressions enclosed in " +"square brackets. For example::" msgstr "" -#: ../../reference/expressions.rst:444 +#: ../../reference/expressions.rst:471 msgid "" -"A list display yields a new list object, the contents being specified by " -"either a list of expressions or a comprehension. When a comma-separated " -"list of expressions is supplied, its elements are evaluated from left to " -"right and placed into the list object in that order. When a comprehension " -"is supplied, the list is constructed from the elements resulting from the " -"comprehension." +">>> [\"one\", \"two\", \"three\"]\n" +"['one', 'two', 'three']\n" +">>> [\"one\"] # One-element list\n" +"['one']\n" +">>> [] # empty list\n" +"[]" +msgstr "" +">>> [\"one\", \"two\", \"three\"]\n" +"['one', 'two', 'three']\n" +">>> [\"one\"] # 單一元素的串列\n" +"['one']\n" +">>> [] # 空串列\n" +"[]" + +#: ../../reference/expressions.rst:478 ../../reference/expressions.rst:508 +#: ../../reference/expressions.rst:543 +msgid "See :ref:`displays` for general information on displays." +msgstr "" + +#: ../../reference/expressions.rst:480 +msgid "The formal grammar for list displays is:" msgstr "" -#: ../../reference/expressions.rst:454 +#: ../../reference/expressions.rst:491 msgid "Set displays" msgstr "" -#: ../../reference/expressions.rst:463 +#: ../../reference/expressions.rst:500 msgid "" -"A set display is denoted by curly braces and distinguishable from dictionary " -"displays by the lack of colons separating keys and values:" +"A :dfn:`set display` is a *non-empty* series of expressions enclosed in " +"curly braces. For example::" msgstr "" -#: ../../reference/expressions.rst:469 +#: ../../reference/expressions.rst:503 msgid "" -"A set display yields a new mutable set object, the contents being specified " -"by either a sequence of expressions or a comprehension. When a comma-" -"separated list of expressions is supplied, its elements are evaluated from " -"left to right and added to the set object. When a comprehension is " -"supplied, the set is constructed from the elements resulting from the " -"comprehension." +">>> {\"one\", \"two\", \"three\"}\n" +"{'one', 'three', 'two'}\n" +">>> {\"one\"} # One-element set\n" +"{'one'}" msgstr "" +">>> {\"one\", \"two\", \"three\"}\n" +"{'one', 'three', 'two'}\n" +">>> {\"one\"} # 單一元素的集合\n" +"{'one'}" -#: ../../reference/expressions.rst:475 +#: ../../reference/expressions.rst:510 msgid "" -"An empty set cannot be constructed with ``{}``; this literal constructs an " -"empty dictionary." +"There is no special syntax for the empty set. The ``{}`` literal is a :ref:" +"`dictionary display ` that constructs an empty dictionary. Call :class:" +"`set() ` with no arguments to get an empty set." msgstr "" -#: ../../reference/expressions.rst:482 +#: ../../reference/expressions.rst:515 +msgid "The formal grammar for set displays is:" +msgstr "" + +#: ../../reference/expressions.rst:533 +msgid "Tuple displays" +msgstr "" + +#: ../../reference/expressions.rst:535 +msgid "" +"A :dfn:`tuple display` is a series of expressions enclosed in parentheses. " +"For example::" +msgstr "" + +#: ../../reference/expressions.rst:538 +msgid "" +">>> (1, 2)\n" +"(1, 2)\n" +">>> () # an empty tuple\n" +"()" +msgstr "" +">>> (1, 2)\n" +"(1, 2)\n" +">>> () # 空元組\n" +"()" + +#: ../../reference/expressions.rst:545 +msgid "" +"To avoid ambiguity, if a tuple display has exactly one element, it requires " +"a trailing comma. Without it, you get a :ref:`parenthesized group " +"`::" +msgstr "" + +#: ../../reference/expressions.rst:549 +msgid "" +">>> ('single',) # single-element tuple\n" +"('single',)\n" +">>> ('single') # no comma: single string\n" +"'single'" +msgstr "" +">>> ('single',) # 單一元素的元組\n" +"('single',)\n" +">>> ('single') # 沒有逗號:單一字串\n" +"'single'" + +#: ../../reference/expressions.rst:554 +msgid "" +"To put it in other words, a tuple display is a parenthesized list of either:" +msgstr "" + +#: ../../reference/expressions.rst:556 +msgid "two or more comma-separated expressions, or" +msgstr "" + +#: ../../reference/expressions.rst:557 +msgid "zero or more expressions, each followed by a comma." +msgstr "" + +#: ../../reference/expressions.rst:559 +msgid "" +"Since tuples are immutable, :ref:`object identity rules for literals " +"` also apply to tuples: at runtime, two occurrences of " +"tuples with the same values may or may not yield the same object." +msgstr "" + +#: ../../reference/expressions.rst:565 +msgid "" +"Python's syntax also includes :ref:`expression lists `, where a " +"comma-separated list of expressions is *not* enclosed in parentheses but " +"evaluates to tuple." +msgstr "" + +#: ../../reference/expressions.rst:569 +msgid "" +"In other words, when it comes to tuple syntax, the comma is more important " +"that the use of parentheses. Only the empty tuple is spelled without a comma." +msgstr "" + +#: ../../reference/expressions.rst:574 +msgid "The formal grammar for tuple displays is:" +msgstr "" + +#: ../../reference/expressions.rst:587 msgid "Dictionary displays" msgstr "" -#: ../../reference/expressions.rst:493 +#: ../../reference/expressions.rst:598 msgid "" -"A dictionary display is a possibly empty series of dict items (key/value " -"pairs) enclosed in curly braces:" +"A :dfn:`dictionary display` is a possibly empty series of :dfn:`dict items` " +"enclosed in curly braces. Each dict item is a colon-separated pair of " +"expressions: the :dfn:`key` and its associated :dfn:`value`. For example::" msgstr "" -#: ../../reference/expressions.rst:502 -msgid "A dictionary display yields a new dictionary object." +#: ../../reference/expressions.rst:604 +msgid "" +">>> {1: 'one', 2: 'two'}\n" +"{1: 'one', 2: 'two'}" msgstr "" +">>> {1: 'one', 2: 'two'}\n" +"{1: 'one', 2: 'two'}" -#: ../../reference/expressions.rst:504 +#: ../../reference/expressions.rst:607 msgid "" -"If a comma-separated sequence of dict items is given, they are evaluated " -"from left to right to define the entries of the dictionary: each key object " -"is used as a key into the dictionary to store the corresponding value. This " -"means that you can specify the same key multiple times in the dict item " -"list, and the final dictionary's value for that key will be the last one " -"given." +"At runtime, when a dictionary comprehension is evaluated, the expressions " +"are evaluated from left to right. Each key object is used as a key into the " +"dictionary to store the corresponding value. This means that you can specify " +"the same key multiple times in the comprehension, and the final dictionary's " +"value for a given key will be the last one given. For example::" msgstr "" -#: ../../reference/expressions.rst:514 +#: ../../reference/expressions.rst:616 msgid "" -"A double asterisk ``**`` denotes :dfn:`dictionary unpacking`. Its operand " -"must be a :term:`mapping`. Each mapping item is added to the new " -"dictionary. Later values replace values already set by earlier dict items " -"and earlier dictionary unpackings." +">>> {\n" +"... 1: 'this will be overridden',\n" +"... 2: 'two',\n" +"... 1: 'also overridden',\n" +"... 1: 'one',\n" +"... }\n" +"{1: 'one', 2: 'two'}" msgstr "" +">>> {\n" +"... 1: 'this will be overridden',\n" +"... 2: 'two',\n" +"... 1: 'also overridden',\n" +"... 1: 'one',\n" +"... }\n" +"{1: 'one', 2: 'two'}" -#: ../../reference/expressions.rst:519 +#: ../../reference/expressions.rst:630 +msgid "" +"Instead of a key-value pair, a dict item may be an expression prefixed by a " +"double asterisk ``**``. This denotes :dfn:`dictionary unpacking`. At " +"runtime, the expression must evaluate to a :term:`mapping`; each item of the " +"mapping is added to the new dictionary. As with key-value pairs, later " +"values replace values already set by earlier items and unpackings. This may " +"be used to override a set of defaults::" +msgstr "" + +#: ../../reference/expressions.rst:638 +msgid "" +">>> defaults = {'color': 'blue', 'count': 8}\n" +">>> overrides = {'color': 'yellow'}\n" +">>> {**defaults, **overrides}\n" +"{'color': 'yellow', 'count': 8}" +msgstr "" +">>> defaults = {'color': 'blue', 'count': 8}\n" +">>> overrides = {'color': 'yellow'}\n" +">>> {**defaults, **overrides}\n" +"{'color': 'yellow', 'count': 8}" + +#: ../../reference/expressions.rst:643 msgid "Unpacking into dictionary displays, originally proposed by :pep:`448`." msgstr "" -#: ../../reference/expressions.rst:522 +#: ../../reference/expressions.rst:646 +msgid "The formal grammar for dict displays is:" +msgstr "" + +#: ../../reference/expressions.rst:664 +msgid "Comprehensions" +msgstr "綜合運算式 (comprehensions)" + +#: ../../reference/expressions.rst:666 msgid "" -"A dict comprehension, in contrast to list and set comprehensions, needs two " -"expressions separated with a colon followed by the usual \"for\" and \"if\" " -"clauses. When the comprehension is run, the resulting key and value elements " -"are inserted in the new dictionary in the order they are produced." +"List, set and dictionary :dfn:`comprehensions` are a form of :ref:`container " +"displays ` where items are computed via a set of looping and " +"filtering instructions rather than listed explicitly." msgstr "" -#: ../../reference/expressions.rst:530 +#: ../../reference/expressions.rst:670 msgid "" -"Restrictions on the types of the key values are listed earlier in section :" -"ref:`types`. (To summarize, the key type should be :term:`hashable`, which " -"excludes all mutable objects.) Clashes between duplicate keys are not " -"detected; the last value (textually rightmost in the display) stored for a " -"given key value prevails." +"In its simplest form, a comprehension consists of a single expression " +"followed by a :keyword:`!for` clause. The :keyword:`!for` clause has the " +"same syntax as the header of a :ref:`for statement `, without a " +"trailing colon." +msgstr "" + +#: ../../reference/expressions.rst:675 +msgid "For example, a list of the first ten squares is::" msgstr "" -#: ../../reference/expressions.rst:536 +#: ../../reference/expressions.rst:677 +msgid "" +">>> [x**2 for x in range(10)]\n" +"[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" +msgstr "" +">>> [x**2 for x in range(10)]\n" +"[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" + +#: ../../reference/expressions.rst:680 +msgid "" +"At run time, a list comprehension creates a new list. The expression after :" +"keyword:`!in` must evaluate to an :term:`iterable`. For each element of this " +"iterable, the element is bound to the :keyword:`!for` clause's target as in " +"a :keyword:`!for` statement, then the expression before :keyword:`!for` is " +"evaluated with the target in scope and the result is added to the new list. " +"Thus, the example above is roughly equivalent to defining and calling the " +"following function::" +msgstr "" + +#: ../../reference/expressions.rst:689 +msgid "" +"def make_list_of_squares(iterable):\n" +" result = []\n" +" for x in iterable:\n" +" result.append(x**2)\n" +" return result\n" +"\n" +"make_list_of_squares(range(10))" +msgstr "" +"def make_list_of_squares(iterable):\n" +" result = []\n" +" for x in iterable:\n" +" result.append(x**2)\n" +" return result\n" +"\n" +"make_list_of_squares(range(10))" + +#: ../../reference/expressions.rst:697 +msgid "" +"Set comprehensions work similarly. For example, here is a set of lowercase " +"letters::" +msgstr "" + +#: ../../reference/expressions.rst:700 +msgid "" +">>> {x.lower() for x in ['a', 'A', 'b', 'C']}\n" +"{'c', 'a', 'b'}" +msgstr "" +">>> {x.lower() for x in ['a', 'A', 'b', 'C']}\n" +"{'c', 'a', 'b'}" + +#: ../../reference/expressions.rst:703 +msgid "At run time, this corresponds roughly to calling this function::" +msgstr "" + +#: ../../reference/expressions.rst:705 +msgid "" +"def make_lowercase_set(iterable):\n" +" result = set(iterable)\n" +" for x in iterable:\n" +" result.append(x.lower())\n" +" return result\n" +"\n" +"make_lowercase_set(['a', 'A', 'b', 'C'])" +msgstr "" +"def make_lowercase_set(iterable):\n" +" result = set(iterable)\n" +" for x in iterable:\n" +" result.append(x.lower())\n" +" return result\n" +"\n" +"make_lowercase_set(['a', 'A', 'b', 'C'])" + +#: ../../reference/expressions.rst:713 +msgid "" +"Dictionary comprehensions start with a colon-separated key-value pair " +"instead of an expression. For example::" +msgstr "" + +#: ../../reference/expressions.rst:716 +msgid "" +">>> {func.__name__: func for func in [print, hex, any]}\n" +"{'print': ,\n" +" 'hex': ,\n" +" 'any': }" +msgstr "" +">>> {func.__name__: func for func in [print, hex, any]}\n" +"{'print': ,\n" +" 'hex': ,\n" +" 'any': }" + +#: ../../reference/expressions.rst:721 +msgid "At run time, this corresponds roughly to::" +msgstr "" + +#: ../../reference/expressions.rst:723 +msgid "" +"def make_dict_mapping_names_to_functions(iterable):\n" +" result = {}\n" +" for func in iterable:\n" +" result[func.__name__] = func\n" +" return result\n" +"\n" +"iterable([print, hex, any])" +msgstr "" +"def make_dict_mapping_names_to_functions(iterable):\n" +" result = {}\n" +" for func in iterable:\n" +" result[func.__name__] = func\n" +" return result\n" +"\n" +"iterable([print, hex, any])" + +#: ../../reference/expressions.rst:731 +msgid "" +"As in other kinds of dictionary displays, the same key may be specified " +"multiple times. Earlier values are overwritten by ones that are evaluated " +"later." +msgstr "" + +#: ../../reference/expressions.rst:735 +msgid "" +"There are no *tuple comprehensions*. A similar syntax is instead used for :" +"ref:`generator expressions `, from which you can construct a tuple " +"like this::" +msgstr "" + +#: ../../reference/expressions.rst:739 +msgid "" +">>> tuple(x**2 for x in range(10))\n" +"(0, 1, 4, 9, 16, 25, 36, 49, 64, 81)" +msgstr "" +">>> tuple(x**2 for x in range(10))\n" +"(0, 1, 4, 9, 16, 25, 36, 49, 64, 81)" + +#: ../../reference/expressions.rst:742 msgid "" "Prior to Python 3.8, in dict comprehensions, the evaluation order of key and " "value was not well-defined. In CPython, the value was evaluated before the " @@ -640,18 +998,324 @@ msgid "" "by :pep:`572`." msgstr "" -#: ../../reference/expressions.rst:546 +#: ../../reference/expressions.rst:752 +msgid "Filtering in comprehensions" +msgstr "綜合運算式中的篩選" + +#: ../../reference/expressions.rst:754 +msgid "" +"The :keyword:`!for` clause may be followed by an :keyword:`!if` clause with " +"an expression." +msgstr "" + +#: ../../reference/expressions.rst:757 +msgid "" +"For example, a list of names from the :mod:`math` module that start with " +"``f`` is::" +msgstr "" + +#: ../../reference/expressions.rst:760 +msgid "" +">>> [name for name in vars(math) if name.startswith('f')]\n" +"['fabs', 'factorial', 'floor', 'fma', 'fmod', 'frexp', 'fsum']" +msgstr "" +">>> [name for name in vars(math) if name.startswith('f')]\n" +"['fabs', 'factorial', 'floor', 'fma', 'fmod', 'frexp', 'fsum']" + +#: ../../reference/expressions.rst:763 +msgid "" +"At run time, the expression after :keyword:`!if` is evaluated before each " +"element is added to the resulting container, and if it is false, the element " +"is skipped. Thus, the above example roughly corresponds to defining and " +"calling the following function::" +msgstr "" + +#: ../../reference/expressions.rst:769 +msgid "" +"def get_math_f_names(iterable):\n" +" result = []\n" +" for name in iterable:\n" +" if name.startswith('f'):\n" +" result.append(name)\n" +" return result\n" +"\n" +"get_math_f_names(vars(math))" +msgstr "" +"def get_math_f_names(iterable):\n" +" result = []\n" +" for name in iterable:\n" +" if name.startswith('f'):\n" +" result.append(name)\n" +" return result\n" +"\n" +"get_math_f_names(vars(math))" + +#: ../../reference/expressions.rst:778 +msgid "" +"Filtering is a special case of more complex comprehensions. See the next " +"section for a more formal description." +msgstr "" + +#: ../../reference/expressions.rst:785 +msgid "Complex comprehensions" +msgstr "複雜的綜合運算式" + +#: ../../reference/expressions.rst:787 +msgid "" +"Generally, a comprehension's initial :keyword:`!for` clause may be followed " +"by zero or more additional :keyword:`!for` or :keyword:`!if` clauses. For " +"example, here is a list of names exposed by two Python modules, filtered to " +"only include names that start with ``a``::" +msgstr "" + +#: ../../reference/expressions.rst:792 +msgid "" +">>> import array\n" +">>> import math\n" +">>> [\n" +"... name\n" +"... for module in [array, math]\n" +"... for name in vars(module)\n" +"... if name.startswith('a')\n" +"... ]\n" +"['array', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh']" +msgstr "" +">>> import array\n" +">>> import math\n" +">>> [\n" +"... name\n" +"... for module in [array, math]\n" +"... for name in vars(module)\n" +"... if name.startswith('a')\n" +"... ]\n" +"['array', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh']" + +#: ../../reference/expressions.rst:802 +msgid "At run time, this roughly corresponds to defining and calling::" +msgstr "" + +#: ../../reference/expressions.rst:804 +msgid "" +"def get_a_names(iterable):\n" +" result = []\n" +" for module in iterable:\n" +" for name in vars(module):\n" +" if name.startswith('a'):\n" +" result.append(name)\n" +" return result\n" +"\n" +"get_a_names([array, math])" +msgstr "" +"def get_a_names(iterable):\n" +" result = []\n" +" for module in iterable:\n" +" for name in vars(module):\n" +" if name.startswith('a'):\n" +" result.append(name)\n" +" return result\n" +"\n" +"get_a_names([array, math])" + +#: ../../reference/expressions.rst:814 +msgid "" +"The elements of the new container are those that would be produced by " +"considering each of the :keyword:`!for` or :keyword:`!if` clauses a block, " +"nesting from left to right, and evaluating the expression to produce an " +"element (or dictionary entry) each time the innermost block is reached." +msgstr "" + +#: ../../reference/expressions.rst:819 +msgid "" +"Aside from the iterable expression in the leftmost :keyword:`!for` clause, " +"the comprehension is executed in a separate implicitly nested scope. This " +"ensures that names assigned to in the target list don't \"leak\" into the " +"enclosing scope. For example::" +msgstr "" + +#: ../../reference/expressions.rst:825 +msgid "" +">>> x = 'old value'\n" +">>> [x**2 for x in range(10)] # this `x` is local to the comprehension\n" +">>> x\n" +"'old value'" +msgstr "" +">>> x = 'old value'\n" +">>> [x**2 for x in range(10)] # 這個 `x` 是綜合運算式的區域變數\n" +">>> x\n" +"'old value'" + +#: ../../reference/expressions.rst:830 +msgid "" +"The iterable expression in the leftmost :keyword:`!for` clause is evaluated " +"directly in the enclosing scope and then passed as an argument to the " +"implicitly nested scope." +msgstr "" + +#: ../../reference/expressions.rst:834 +msgid "" +"Subsequent :keyword:`!for` clauses and any filter condition in the leftmost :" +"keyword:`!for` clause cannot be evaluated in the enclosing scope as they may " +"depend on the values obtained from the leftmost iterable." +msgstr "" + +#: ../../reference/expressions.rst:838 +msgid "" +"To ensure the comprehension always results in a container of the appropriate " +"type, ``yield`` and ``yield from`` expressions are prohibited in the " +"implicitly nested scope." +msgstr "" + +#: ../../reference/expressions.rst:842 +msgid "" +":ref:`Assignment expressions ` are not allowed " +"inside comprehension iterable expressions (that is, the expressions after " +"the :keyword:`!in` keyword), nor anywhere within comprehensions that appear " +"directly in a class definition." +msgstr "" + +#: ../../reference/expressions.rst:847 ../../reference/expressions.rst:1064 +msgid "``yield`` and ``yield from`` prohibited in the implicitly nested scope." +msgstr "" + +#: ../../reference/expressions.rst:854 +msgid "Unpacking in comprehensions" +msgstr "綜合運算式中的解包" + +#: ../../reference/expressions.rst:856 +msgid "" +"If the expression of a list or set comprehension is starred, the result will " +"be :ref:`unpacked ` to produce zero or more elements." +msgstr "" + +#: ../../reference/expressions.rst:860 +msgid "This is often used for \"flattening\" lists, for example::" +msgstr "" + +#: ../../reference/expressions.rst:862 +msgid "" +">>> students = ['Petr', 'Blaise', 'Jarka']\n" +">>> teachers = ['Salim', 'Bartosz']\n" +">>> lists_of_people = [students, teachers]\n" +">>> [*people for people in lists_of_people]\n" +"['Petr', 'Blaise', 'Jarka', 'Salim', 'Bartosz']" +msgstr "" +">>> students = ['Petr', 'Blaise', 'Jarka']\n" +">>> teachers = ['Salim', 'Bartosz']\n" +">>> lists_of_people = [students, teachers]\n" +">>> [*people for people in lists_of_people]\n" +"['Petr', 'Blaise', 'Jarka', 'Salim', 'Bartosz']" + +#: ../../reference/expressions.rst:868 +msgid "At run time, this comprehension roughly corresponds to::" +msgstr "" + +#: ../../reference/expressions.rst:870 +msgid "" +"def flatten_names(lists_of_people):\n" +" result = []\n" +" for people in lists_of_people:\n" +" result.extend(people)\n" +" return result" +msgstr "" +"def flatten_names(lists_of_people):\n" +" result = []\n" +" for people in lists_of_people:\n" +" result.extend(people)\n" +" return result" + +#: ../../reference/expressions.rst:876 +msgid "" +"In dict comprehensions, a double-starred expression will be evaluated and " +"then unpacked using :ref:`dictionary unpacking `, inserting " +"zero or more key/value pairs into the new dictionary. As in other kinds of " +"dictionary displays, if the same key is specified multiple times, the " +"associated value in the resulting dictionary will be the last one specified." +msgstr "" + +#: ../../reference/expressions.rst:883 +msgid "For example::" +msgstr "舉例來說: ::" + +#: ../../reference/expressions.rst:885 +msgid "" +">>> system_defaults = {'color': 'blue', 'count': 8}\n" +">>> user_defaults = {'color': 'yellow'}\n" +">>> overrides = {'count': 5}\n" +"\n" +">>> configuration_sets = [system_defaults, user_defaults, overrides]\n" +"\n" +">>> {**d for d in configuration_sets}\n" +"{'color': 'yellow', 'count': 5}" +msgstr "" +">>> system_defaults = {'color': 'blue', 'count': 8}\n" +">>> user_defaults = {'color': 'yellow'}\n" +">>> overrides = {'count': 5}\n" +"\n" +">>> configuration_sets = [system_defaults, user_defaults, overrides]\n" +"\n" +">>> {**d for d in configuration_sets}\n" +"{'color': 'yellow', 'count': 5}" + +#: ../../reference/expressions.rst:896 +msgid "" +"Unpacking in comprehensions using the ``*`` and ``**`` operators was " +"introduced in :pep:`798`." +msgstr "" + +#: ../../reference/expressions.rst:905 +msgid "Asynchronous comprehensions" +msgstr "非同步綜合運算式" + +#: ../../reference/expressions.rst:907 +msgid "" +"In an :keyword:`async def` function, an :keyword:`!async for` clause may be " +"used to iterate over a :term:`asynchronous iterator`. A comprehension in an :" +"keyword:`!async def` function may consist of either a :keyword:`!for` or :" +"keyword:`!async for` clause following the leading expression, may contain " +"additional :keyword:`!for` or :keyword:`!async for` clauses, and may also " +"use :keyword:`await` expressions." +msgstr "" + +#: ../../reference/expressions.rst:914 +msgid "" +"If a comprehension contains :keyword:`!async for` clauses, or if it " +"contains :keyword:`!await` expressions or other asynchronous comprehensions " +"anywhere except the iterable expression in the leftmost :keyword:`!for` " +"clause, it is called an :dfn:`asynchronous comprehension`. An asynchronous " +"comprehension may suspend the execution of the coroutine function in which " +"it appears." +msgstr "" + +#: ../../reference/expressions.rst:922 +msgid "Asynchronous comprehensions were introduced in :pep:`530`." +msgstr "" + +#: ../../reference/expressions.rst:924 +msgid "" +"Asynchronous comprehensions are now allowed inside comprehensions in " +"asynchronous functions. Outer comprehensions implicitly become asynchronous." +msgstr "" + +#: ../../reference/expressions.rst:932 +msgid "Formal grammar for comprehensions" +msgstr "綜合運算式的正式文法" + +#: ../../reference/expressions.rst:934 +msgid "The formal grammar for comprehensions is:" +msgstr "" + +#: ../../reference/expressions.rst:954 msgid "Generator expressions" msgstr "" -#: ../../reference/expressions.rst:553 +#: ../../reference/expressions.rst:961 msgid "" "The syntax for :dfn:`generator expressions` is the same as for list :ref:" "`comprehensions `, except that they are enclosed in " "parentheses instead of brackets. For example::" msgstr "" -#: ../../reference/expressions.rst:558 +#: ../../reference/expressions.rst:966 msgid "" ">>> iterator = (x ** 2 for x in range(10))\n" ">>> iterator\n" @@ -661,13 +1325,13 @@ msgstr "" ">>> iterator\n" " at ...>" -#: ../../reference/expressions.rst:562 +#: ../../reference/expressions.rst:970 msgid "" "At runtime, a generator expression evaluates to a :term:`generator iterator` " "which yields the same values as the corresponding list comprehension::" msgstr "" -#: ../../reference/expressions.rst:565 +#: ../../reference/expressions.rst:973 msgid "" ">>> list(iterator)\n" "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" @@ -675,13 +1339,13 @@ msgstr "" ">>> list(iterator)\n" "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" -#: ../../reference/expressions.rst:568 +#: ../../reference/expressions.rst:976 msgid "" "Thus, the example above is roughly equivalent to defining and calling the " "following generator function::" msgstr "" -#: ../../reference/expressions.rst:571 +#: ../../reference/expressions.rst:979 msgid "" "def make_generator_of_squares(iterator):\n" " for x in iterator:\n" @@ -695,14 +1359,14 @@ msgstr "" "\n" "make_generator_of_squares(iter(range(10)))" -#: ../../reference/expressions.rst:577 +#: ../../reference/expressions.rst:985 msgid "" "The enclosing parentheses can be omitted in calls when the generator " "expression is the only positional argument and there are no keyword " "arguments. See the :ref:`Calls section ` for details. For example::" msgstr "" -#: ../../reference/expressions.rst:583 +#: ../../reference/expressions.rst:991 msgid "" "# The parentheses after `sum` are part of the call syntax:\n" ">>> sum(x ** 2 for x in range(10))\n" @@ -720,7 +1384,7 @@ msgstr "" ">>> sum((x ** 2 for x in range(10)), start=1000)\n" "1285" -#: ../../reference/expressions.rst:591 +#: ../../reference/expressions.rst:999 msgid "" "The iterable expression in the leftmost :keyword:`!for` clause is evaluated " "immediately, so that an error raised by this expression will be emitted at " @@ -728,7 +1392,7 @@ msgid "" "point where the first value is retrieved::" msgstr "" -#: ../../reference/expressions.rst:596 +#: ../../reference/expressions.rst:1004 msgid "" ">>> (x ** 2 for x in nonexistent_iterable)\n" "Traceback (most recent call last):\n" @@ -740,14 +1404,14 @@ msgstr "" " ...\n" "NameError: name 'nonexistent_iterable' is not defined" -#: ../../reference/expressions.rst:601 +#: ../../reference/expressions.rst:1009 msgid "" "After the expression is evaluated, an iterator is created from the result, " "as if :py:func:`iter` was called on it. Any error raised when creating the " "iterator is also emitted immediately::" msgstr "" -#: ../../reference/expressions.rst:605 +#: ../../reference/expressions.rst:1013 msgid "" ">>> (x ** 2 for x in None)\n" "Traceback (most recent call last):\n" @@ -759,13 +1423,13 @@ msgstr "" " ...\n" "TypeError: 'NoneType' object is not iterable" -#: ../../reference/expressions.rst:610 +#: ../../reference/expressions.rst:1018 msgid "" "All other expressions are evaluated lazily, in the same fashion as normal " "generators (that is, when the iterator is asked to yield a value)::" msgstr "" -#: ../../reference/expressions.rst:613 +#: ../../reference/expressions.rst:1021 msgid "" ">>> iterator = (nonexistent_value for x in range(10))\n" ">>> iterator\n" @@ -783,7 +1447,7 @@ msgstr "" " ...\n" "NameError: name 'nonexistent_value' is not defined" -#: ../../reference/expressions.rst:623 +#: ../../reference/expressions.rst:1031 msgid "" ">>> iterator = (x * y for x in range(10) for y in nonexistent_iterable)\n" ">>> iterator\n" @@ -801,14 +1465,14 @@ msgstr "" " ...\n" "NameError: name 'nonexistent_iterable' is not defined" -#: ../../reference/expressions.rst:631 +#: ../../reference/expressions.rst:1039 msgid "" "To avoid interfering with the expected operation of the generator expression " "itself, ``yield`` and ``yield from`` expressions are prohibited inside the " "implicitly nested scope." msgstr "" -#: ../../reference/expressions.rst:635 +#: ../../reference/expressions.rst:1043 msgid "" "If a generator expression contains either :keyword:`!async for` clauses or :" "keyword:`await` expressions it is called an :dfn:`asynchronous generator " @@ -817,26 +1481,26 @@ msgid "" "iterators`)." msgstr "" -#: ../../reference/expressions.rst:641 +#: ../../reference/expressions.rst:1049 msgid "The formal grammar for generator expressions is:" msgstr "" -#: ../../reference/expressions.rst:648 +#: ../../reference/expressions.rst:1056 msgid "Asynchronous generator expressions were introduced." msgstr "" -#: ../../reference/expressions.rst:651 +#: ../../reference/expressions.rst:1059 msgid "" "Prior to Python 3.7, asynchronous generator expressions could only appear " "in :keyword:`async def` coroutines. Starting with 3.7, any function can use " "asynchronous generator expressions." msgstr "" -#: ../../reference/expressions.rst:663 +#: ../../reference/expressions.rst:1071 msgid "Yield expressions" msgstr "" -#: ../../reference/expressions.rst:676 +#: ../../reference/expressions.rst:1084 msgid "" "The yield expression is used when defining a :term:`generator` function or " "an :term:`asynchronous generator` function and thus can only be used in the " @@ -846,7 +1510,7 @@ msgid "" "asynchronous generator function. For example::" msgstr "" -#: ../../reference/expressions.rst:683 +#: ../../reference/expressions.rst:1091 msgid "" "def gen(): # defines a generator function\n" " yield 123\n" @@ -860,27 +1524,27 @@ msgstr "" "async def agen(): # 定義一個非同步產生器函式\n" " yield 123" -#: ../../reference/expressions.rst:689 +#: ../../reference/expressions.rst:1097 msgid "" "Due to their side effects on the containing scope, ``yield`` expressions are " "not permitted as part of the implicitly defined scopes used to implement " "comprehensions and generator expressions." msgstr "" -#: ../../reference/expressions.rst:693 +#: ../../reference/expressions.rst:1101 msgid "" "Yield expressions prohibited in the implicitly nested scopes used to " "implement comprehensions and generator expressions." msgstr "" -#: ../../reference/expressions.rst:697 +#: ../../reference/expressions.rst:1105 msgid "" "Generator functions are described below, while asynchronous generator " "functions are described separately in section :ref:`asynchronous-generator-" "functions`." msgstr "" -#: ../../reference/expressions.rst:701 +#: ../../reference/expressions.rst:1109 msgid "" "When a generator function is called, it returns an iterator known as a " "generator. That generator then controls the execution of the generator " @@ -901,7 +1565,7 @@ msgid "" "be the value passed in to that method." msgstr "" -#: ../../reference/expressions.rst:721 +#: ../../reference/expressions.rst:1129 msgid "" "All of this makes generator functions quite similar to coroutines; they " "yield multiple times, they have more than one entry point and their " @@ -910,7 +1574,7 @@ msgid "" "the control is always transferred to the generator's caller." msgstr "" -#: ../../reference/expressions.rst:727 +#: ../../reference/expressions.rst:1135 msgid "" "Yield expressions are allowed anywhere in a :keyword:`try` construct. If " "the generator is not resumed before it is finalized (by reaching a zero " @@ -919,7 +1583,7 @@ msgid "" "`finally` clauses to execute." msgstr "" -#: ../../reference/expressions.rst:736 +#: ../../reference/expressions.rst:1144 msgid "" "When ``yield from `` is used, the supplied expression must be an " "iterable. The values produced by iterating that iterable are passed directly " @@ -931,7 +1595,7 @@ msgid "" "will just raise the passed in exception immediately." msgstr "" -#: ../../reference/expressions.rst:745 +#: ../../reference/expressions.rst:1153 msgid "" "When the underlying iterator is complete, the :attr:`~StopIteration.value` " "attribute of the raised :exc:`StopIteration` instance becomes the value of " @@ -940,165 +1604,67 @@ msgid "" "returning a value from the subgenerator)." msgstr "" -#: ../../reference/expressions.rst:751 +#: ../../reference/expressions.rst:1159 msgid "Added ``yield from `` to delegate control flow to a subiterator." msgstr "" -#: ../../reference/expressions.rst:754 +#: ../../reference/expressions.rst:1162 msgid "" "The parentheses may be omitted when the yield expression is the sole " "expression on the right hand side of an assignment statement." msgstr "" -#: ../../reference/expressions.rst:759 +#: ../../reference/expressions.rst:1167 msgid ":pep:`255` - Simple Generators" msgstr "" -#: ../../reference/expressions.rst:760 +#: ../../reference/expressions.rst:1168 msgid "" "The proposal for adding generators and the :keyword:`yield` statement to " "Python." msgstr "" -#: ../../reference/expressions.rst:762 +#: ../../reference/expressions.rst:1170 msgid ":pep:`342` - Coroutines via Enhanced Generators" msgstr "" -#: ../../reference/expressions.rst:763 +#: ../../reference/expressions.rst:1171 msgid "" "The proposal to enhance the API and syntax of generators, making them usable " "as simple coroutines." msgstr "" -#: ../../reference/expressions.rst:766 +#: ../../reference/expressions.rst:1174 msgid ":pep:`380` - Syntax for Delegating to a Subgenerator" msgstr "" -#: ../../reference/expressions.rst:767 +#: ../../reference/expressions.rst:1175 msgid "" "The proposal to introduce the :token:`~python-grammar:yield_from` syntax, " "making delegation to subgenerators easy." msgstr "" -#: ../../reference/expressions.rst:770 +#: ../../reference/expressions.rst:1178 msgid ":pep:`525` - Asynchronous Generators" msgstr "" -#: ../../reference/expressions.rst:771 -msgid "" -"The proposal that expanded on :pep:`492` by adding generator capabilities to " -"coroutine functions." -msgstr "" - -#: ../../reference/expressions.rst:778 -msgid "Generator-iterator methods" -msgstr "" - -#: ../../reference/expressions.rst:780 -msgid "" -"This subsection describes the methods of a generator iterator. They can be " -"used to control the execution of a generator function." -msgstr "" - -#: ../../reference/expressions.rst:783 -msgid "" -"Note that calling any of the generator methods below when the generator is " -"already executing raises a :exc:`ValueError` exception." -msgstr "" - -#: ../../reference/expressions.rst:791 -msgid "" -"Starts the execution of a generator function or resumes it at the last " -"executed yield expression. When a generator function is resumed with a :" -"meth:`~generator.__next__` method, the current yield expression always " -"evaluates to :const:`None`. The execution then continues to the next yield " -"expression, where the generator is suspended again, and the value of the :" -"token:`~python-grammar:yield_list` is returned to :meth:`__next__`'s " -"caller. If the generator exits without yielding another value, a :exc:" -"`StopIteration` exception is raised." -msgstr "" - -#: ../../reference/expressions.rst:800 -msgid "" -"This method is normally called implicitly, e.g. by a :keyword:`for` loop, or " -"by the built-in :func:`next` function." -msgstr "" - -#: ../../reference/expressions.rst:806 -msgid "" -"Resumes the execution and \"sends\" a value into the generator function. " -"The *value* argument becomes the result of the current yield expression. " -"The :meth:`send` method returns the next value yielded by the generator, or " -"raises :exc:`StopIteration` if the generator exits without yielding another " -"value. When :meth:`send` is called to start the generator, it must be " -"called with :const:`None` as the argument, because there is no yield " -"expression that could receive the value." -msgstr "" - -#: ../../reference/expressions.rst:818 -msgid "" -"Raises an exception at the point where the generator was paused, and returns " -"the next value yielded by the generator function. If the generator exits " -"without yielding another value, a :exc:`StopIteration` exception is raised. " -"If the generator function does not catch the passed-in exception, or raises " -"a different exception, then that exception propagates to the caller." -msgstr "" - -#: ../../reference/expressions.rst:824 -msgid "" -"In typical use, this is called with a single exception instance similar to " -"the way the :keyword:`raise` keyword is used." -msgstr "" - -#: ../../reference/expressions.rst:827 -msgid "" -"For backwards compatibility, however, the second signature is supported, " -"following a convention from older versions of Python. The *type* argument " -"should be an exception class, and *value* should be an exception instance. " -"If the *value* is not provided, the *type* constructor is called to get an " -"instance. If *traceback* is provided, it is set on the exception, otherwise " -"any existing :attr:`~BaseException.__traceback__` attribute stored in " -"*value* may be cleared." -msgstr "" - -#: ../../reference/expressions.rst:838 ../../reference/expressions.rst:1024 -msgid "" -"The second signature \\(type\\[, value\\[, traceback\\]\\]\\) is deprecated " -"and may be removed in a future version of Python." -msgstr "" - -#: ../../reference/expressions.rst:846 -msgid "" -"Raises a :exc:`GeneratorExit` exception at the point where the generator " -"function was paused (equivalent to calling ``throw(GeneratorExit)``). The " -"exception is raised by the yield expression where the generator was paused. " -"If the generator function catches the exception and returns a value, this " -"value is returned from :meth:`close`. If the generator function is already " -"closed, or raises :exc:`GeneratorExit` (by not catching the exception), :" -"meth:`close` returns :const:`None`. If the generator yields a value, a :exc:" -"`RuntimeError` is raised. If the generator raises any other exception, it " -"is propagated to the caller. If the generator has already exited due to an " -"exception or normal exit, :meth:`close` returns :const:`None` and has no " -"other effect." -msgstr "" - -#: ../../reference/expressions.rst:860 +#: ../../reference/expressions.rst:1179 msgid "" -"If a generator returns a value upon being closed, the value is returned by :" -"meth:`close`." +"The proposal that expanded on :pep:`492` by adding generator capabilities to " +"coroutine functions." msgstr "" -#: ../../reference/expressions.rst:866 +#: ../../reference/expressions.rst:1185 msgid "Examples" msgstr "模組" -#: ../../reference/expressions.rst:868 +#: ../../reference/expressions.rst:1187 msgid "" "Here is a simple example that demonstrates the behavior of generators and " "generator functions::" msgstr "" -#: ../../reference/expressions.rst:871 +#: ../../reference/expressions.rst:1190 msgid "" ">>> def echo(value=None):\n" "... print(\"Execution starts when 'next()' is called for the first time." @@ -1150,24 +1716,24 @@ msgstr "" ">>> generator.close()\n" "Don't forget to clean up when 'close()' is called." -#: ../../reference/expressions.rst:895 +#: ../../reference/expressions.rst:1214 msgid "" "For examples using ``yield from``, see :ref:`pep-380` in \"What's New in " "Python.\"" msgstr "" -#: ../../reference/expressions.rst:901 +#: ../../reference/expressions.rst:1220 msgid "Asynchronous generator functions" msgstr "非同步產生器函式" -#: ../../reference/expressions.rst:903 +#: ../../reference/expressions.rst:1222 msgid "" "The presence of a yield expression in a function or method defined using :" "keyword:`async def` further defines the function as an :term:`asynchronous " "generator` function." msgstr "" -#: ../../reference/expressions.rst:907 +#: ../../reference/expressions.rst:1226 msgid "" "When an asynchronous generator function is called, it returns an " "asynchronous iterator known as an asynchronous generator object. That object " @@ -1177,7 +1743,7 @@ msgid "" "keyword:`for` statement." msgstr "" -#: ../../reference/expressions.rst:914 +#: ../../reference/expressions.rst:1233 msgid "" "Calling one of the asynchronous generator's methods returns an :term:" "`awaitable` object, and the execution starts when this object is awaited on. " @@ -1195,7 +1761,7 @@ msgid "" "then the result will be the value passed in to that method." msgstr "" -#: ../../reference/expressions.rst:929 +#: ../../reference/expressions.rst:1248 msgid "" "If an asynchronous generator happens to exit early by :keyword:`break`, the " "caller task being cancelled, or other exceptions, the generator's async " @@ -1207,7 +1773,7 @@ msgid "" "generator and ultimately detach it from the event loop." msgstr "" -#: ../../reference/expressions.rst:939 +#: ../../reference/expressions.rst:1258 msgid "" "In an asynchronous generator function, yield expressions are allowed " "anywhere in a :keyword:`try` construct. However, if an asynchronous " @@ -1221,7 +1787,7 @@ msgid "" "finally` clauses to execute." msgstr "" -#: ../../reference/expressions.rst:950 +#: ../../reference/expressions.rst:1269 msgid "" "To take care of finalization upon event loop termination, an event loop " "should define a *finalizer* function which takes an asynchronous generator-" @@ -1234,104 +1800,31 @@ msgid "" "asyncio/base_events.py`." msgstr "" -#: ../../reference/expressions.rst:959 +#: ../../reference/expressions.rst:1278 msgid "" "The expression ``yield from `` is a syntax error when used in an " "asynchronous generator function." msgstr "" -#: ../../reference/expressions.rst:966 -msgid "Asynchronous generator-iterator methods" -msgstr "" - -#: ../../reference/expressions.rst:968 -msgid "" -"This subsection describes the methods of an asynchronous generator iterator, " -"which are used to control the execution of a generator function." -msgstr "" - -#: ../../reference/expressions.rst:977 -msgid "" -"Returns an awaitable which when run starts to execute the asynchronous " -"generator or resumes it at the last executed yield expression. When an " -"asynchronous generator function is resumed with an :meth:`~agen.__anext__` " -"method, the current yield expression always evaluates to :const:`None` in " -"the returned awaitable, which when run will continue to the next yield " -"expression. The value of the :token:`~python-grammar:yield_list` of the " -"yield expression is the value of the :exc:`StopIteration` exception raised " -"by the completing coroutine. If the asynchronous generator exits without " -"yielding another value, the awaitable instead raises a :exc:" -"`StopAsyncIteration` exception, signalling that the asynchronous iteration " -"has completed." -msgstr "" - -#: ../../reference/expressions.rst:989 -msgid "" -"This method is normally called implicitly by a :keyword:`async for` loop." -msgstr "" - -#: ../../reference/expressions.rst:995 -msgid "" -"Returns an awaitable which when run resumes the execution of the " -"asynchronous generator. As with the :meth:`~generator.send` method for a " -"generator, this \"sends\" a value into the asynchronous generator function, " -"and the *value* argument becomes the result of the current yield expression. " -"The awaitable returned by the :meth:`asend` method will return the next " -"value yielded by the generator as the value of the raised :exc:" -"`StopIteration`, or raises :exc:`StopAsyncIteration` if the asynchronous " -"generator exits without yielding another value. When :meth:`asend` is " -"called to start the asynchronous generator, it must be called with :const:" -"`None` as the argument, because there is no yield expression that could " -"receive the value." -msgstr "" - -#: ../../reference/expressions.rst:1012 -msgid "" -"Returns an awaitable that raises an exception of type ``type`` at the point " -"where the asynchronous generator was paused, and returns the next value " -"yielded by the generator function as the value of the raised :exc:" -"`StopIteration` exception. If the asynchronous generator exits without " -"yielding another value, a :exc:`StopAsyncIteration` exception is raised by " -"the awaitable. If the generator function does not catch the passed-in " -"exception, or raises a different exception, then when the awaitable is run " -"that exception propagates to the caller of the awaitable." -msgstr "" - -#: ../../reference/expressions.rst:1033 -msgid "" -"Returns an awaitable that when run will throw a :exc:`GeneratorExit` into " -"the asynchronous generator function at the point where it was paused. If the " -"asynchronous generator function then exits gracefully, is already closed, or " -"raises :exc:`GeneratorExit` (by not catching the exception), then the " -"returned awaitable will raise a :exc:`StopIteration` exception. Any further " -"awaitables returned by subsequent calls to the asynchronous generator will " -"raise a :exc:`StopAsyncIteration` exception. If the asynchronous generator " -"yields a value, a :exc:`RuntimeError` is raised by the awaitable. If the " -"asynchronous generator raises any other exception, it is propagated to the " -"caller of the awaitable. If the asynchronous generator has already exited " -"due to an exception or normal exit, then further calls to :meth:`aclose` " -"will return an awaitable that does nothing." -msgstr "" - -#: ../../reference/expressions.rst:1049 +#: ../../reference/expressions.rst:1284 msgid "Primaries" msgstr "" -#: ../../reference/expressions.rst:1053 +#: ../../reference/expressions.rst:1288 msgid "" "Primaries represent the most tightly bound operations of the language. Their " "syntax is:" msgstr "" -#: ../../reference/expressions.rst:1063 +#: ../../reference/expressions.rst:1298 msgid "Attribute references" msgstr "" -#: ../../reference/expressions.rst:1069 +#: ../../reference/expressions.rst:1304 msgid "An attribute reference is a primary followed by a period and a name:" msgstr "" -#: ../../reference/expressions.rst:1079 +#: ../../reference/expressions.rst:1314 msgid "" "The primary must evaluate to an object of a type that supports attribute " "references, which most objects do. This object is then asked to produce the " @@ -1340,7 +1833,7 @@ msgid "" "reference may yield different objects." msgstr "" -#: ../../reference/expressions.rst:1085 +#: ../../reference/expressions.rst:1320 msgid "" "This production can be customized by overriding the :meth:`~object." "__getattribute__` method or the :meth:`~object.__getattr__` method. The :" @@ -1348,38 +1841,38 @@ msgid "" "or raises :exc:`AttributeError` if the attribute is not available." msgstr "" -#: ../../reference/expressions.rst:1091 +#: ../../reference/expressions.rst:1326 msgid "" "If an :exc:`AttributeError` is raised and the object has a :meth:`!" "__getattr__` method, that method is called as a fallback." msgstr "" -#: ../../reference/expressions.rst:1097 +#: ../../reference/expressions.rst:1332 msgid "Subscriptions and slicings" msgstr "" -#: ../../reference/expressions.rst:1112 +#: ../../reference/expressions.rst:1347 msgid "" "The :dfn:`subscription` syntax is usually used for selecting an element from " "a :ref:`container ` -- for example, to get a value from a :" "class:`dict`::" msgstr "" -#: ../../reference/expressions.rst:1116 +#: ../../reference/expressions.rst:1351 msgid "" ">>> digits_by_name = {'one': 1, 'two': 2}\n" ">>> digits_by_name['two'] # Subscripting a dictionary using the key 'two'\n" "2" msgstr "" -#: ../../reference/expressions.rst:1120 +#: ../../reference/expressions.rst:1355 msgid "" "In the subscription syntax, the object being subscribed -- a :ref:`primary " "` -- is followed by a :dfn:`subscript` in square brackets. In the " "simplest case, the subscript is a single expression." msgstr "" -#: ../../reference/expressions.rst:1125 +#: ../../reference/expressions.rst:1360 msgid "" "Depending on the type of the object being subscribed, the subscript is " "sometimes called a :term:`key` (for mappings), :term:`index` (for " @@ -1387,7 +1880,7 @@ msgid "" "Syntactically, these are all equivalent::" msgstr "" -#: ../../reference/expressions.rst:1130 +#: ../../reference/expressions.rst:1365 msgid "" ">>> colors = ['red', 'blue', 'green', 'black']\n" ">>> colors[3] # Subscripting a list using the index 3\n" @@ -1397,7 +1890,7 @@ msgid "" "list[str]" msgstr "" -#: ../../reference/expressions.rst:1137 +#: ../../reference/expressions.rst:1372 msgid "" "At runtime, the interpreter will evaluate the primary and the subscript, and " "call the primary's :meth:`~object.__getitem__` or :meth:`~object." @@ -1406,14 +1899,14 @@ msgid "" "versus-getitem`." msgstr "" -#: ../../reference/expressions.rst:1144 +#: ../../reference/expressions.rst:1379 msgid "" "To show how subscription works, we can define a custom object that " "implements :meth:`~object.__getitem__` and prints out the value of the " "subscript::" msgstr "" -#: ../../reference/expressions.rst:1148 +#: ../../reference/expressions.rst:1383 msgid "" ">>> class SubscriptionDemo:\n" "... def __getitem__(self, key):\n" @@ -1426,13 +1919,13 @@ msgid "" "subscripted with: 'aaa'" msgstr "" -#: ../../reference/expressions.rst:1158 +#: ../../reference/expressions.rst:1393 msgid "" "See :meth:`~object.__getitem__` documentation for how built-in types handle " "subscription." msgstr "" -#: ../../reference/expressions.rst:1161 +#: ../../reference/expressions.rst:1396 msgid "" "Subscriptions may also be used as targets in :ref:`assignment ` " "or :ref:`deletion ` statements. In these cases, the interpreter will " @@ -1441,7 +1934,7 @@ msgid "" "__getitem__`." msgstr "" -#: ../../reference/expressions.rst:1167 +#: ../../reference/expressions.rst:1402 msgid "" ">>> colors = ['red', 'blue', 'green', 'black']\n" ">>> colors[3] = 'white' # Setting item at index\n" @@ -1452,17 +1945,17 @@ msgid "" "['red', 'blue', 'green']" msgstr "" -#: ../../reference/expressions.rst:1177 +#: ../../reference/expressions.rst:1412 msgid "" "All advanced forms of *subscript* documented in the following sections are " "also usable for assignment and deletion." msgstr "" -#: ../../reference/expressions.rst:1196 +#: ../../reference/expressions.rst:1431 msgid "Slicings" msgstr "" -#: ../../reference/expressions.rst:1198 +#: ../../reference/expressions.rst:1433 msgid "" "A more advanced form of subscription, :dfn:`slicing`, is commonly used to " "extract a portion of a :ref:`sequence `. In this form, " @@ -1471,7 +1964,7 @@ msgid "" "least one colon::" msgstr "" -#: ../../reference/expressions.rst:1205 +#: ../../reference/expressions.rst:1440 msgid "" ">>> number_names = ['zero', 'one', 'two', 'three', 'four', 'five']\n" ">>> number_names[1:3]\n" @@ -1491,7 +1984,7 @@ msgid "" "['zero', 'one', 'two', 'three']" msgstr "" -#: ../../reference/expressions.rst:1222 +#: ../../reference/expressions.rst:1457 msgid "" "When a slice is evaluated, the interpreter constructs a :class:`slice` " "object whose :attr:`~slice.start`, :attr:`~slice.stop` and :attr:`~slice." @@ -1501,7 +1994,7 @@ msgid "" "`~object.__class_getitem__` :term:`special method`, as above. ::" msgstr "" -#: ../../reference/expressions.rst:1230 +#: ../../reference/expressions.rst:1465 msgid "" "# continuing with the SubscriptionDemo instance defined above:\n" ">>> demo[2:3]\n" @@ -1510,17 +2003,17 @@ msgid "" "subscripted with: slice(None, None, 'spam')" msgstr "" -#: ../../reference/expressions.rst:1238 +#: ../../reference/expressions.rst:1473 msgid "Comma-separated subscripts" msgstr "" -#: ../../reference/expressions.rst:1240 +#: ../../reference/expressions.rst:1475 msgid "" "The subscript can also be given as two or more comma-separated expressions " "or slices::" msgstr "" -#: ../../reference/expressions.rst:1243 +#: ../../reference/expressions.rst:1478 msgid "" "# continuing with the SubscriptionDemo instance defined above:\n" ">>> demo[1, 2, 3]\n" @@ -1529,7 +2022,7 @@ msgid "" "subscripted with: (slice(1, 2, None), 3)" msgstr "" -#: ../../reference/expressions.rst:1249 +#: ../../reference/expressions.rst:1484 msgid "" "This form is commonly used with numerical libraries for slicing multi-" "dimensional data. In this case, the interpreter constructs a :class:`tuple` " @@ -1538,80 +2031,80 @@ msgid "" "`special method`, as above." msgstr "" -#: ../../reference/expressions.rst:1255 +#: ../../reference/expressions.rst:1490 msgid "" "The subscript may also be given as a single expression or slice followed by " "a comma, to specify a one-element tuple::" msgstr "" -#: ../../reference/expressions.rst:1258 +#: ../../reference/expressions.rst:1493 msgid "" ">>> demo['spam',]\n" "subscripted with: ('spam',)" msgstr "" -#: ../../reference/expressions.rst:1263 +#: ../../reference/expressions.rst:1498 msgid "\"Starred\" subscriptions" msgstr "" -#: ../../reference/expressions.rst:1265 +#: ../../reference/expressions.rst:1500 msgid "Expressions in *tuple_slices* may be starred. See :pep:`646`." msgstr "" -#: ../../reference/expressions.rst:1268 +#: ../../reference/expressions.rst:1503 msgid "" "The subscript can also contain a starred expression. In this case, the " "interpreter unpacks the result into a tuple, and passes this tuple to :meth:" "`~object.__getitem__` or :meth:`~object.__class_getitem__`::" msgstr "" -#: ../../reference/expressions.rst:1272 +#: ../../reference/expressions.rst:1507 msgid "" "# continuing with the SubscriptionDemo instance defined above:\n" ">>> demo[*range(10)]\n" "subscripted with: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)" msgstr "" -#: ../../reference/expressions.rst:1276 +#: ../../reference/expressions.rst:1511 msgid "" "Starred expressions may be combined with comma-separated expressions and " "slices::" msgstr "" -#: ../../reference/expressions.rst:1279 +#: ../../reference/expressions.rst:1514 msgid "" ">>> demo['a', 'b', *range(3), 'c']\n" "subscripted with: ('a', 'b', 0, 1, 2, 'c')" msgstr "" -#: ../../reference/expressions.rst:1284 +#: ../../reference/expressions.rst:1519 msgid "Formal subscription grammar" msgstr "" -#: ../../reference/expressions.rst:1295 +#: ../../reference/expressions.rst:1530 msgid "" "Recall that the ``|`` operator :ref:`denotes ordered choice `. " "Specifically, in :token:`!subscript`, if both alternatives would match, the " "first (:token:`!single_subscript`) has priority." msgstr "" -#: ../../reference/expressions.rst:1310 +#: ../../reference/expressions.rst:1545 msgid "Calls" msgstr "" -#: ../../reference/expressions.rst:1312 +#: ../../reference/expressions.rst:1547 msgid "" "A call calls a callable object (e.g., a :term:`function`) with a possibly " "empty series of :term:`arguments `:" msgstr "" -#: ../../reference/expressions.rst:1329 +#: ../../reference/expressions.rst:1564 msgid "" "An optional trailing comma may be present after the positional and keyword " "arguments but does not affect the semantics." msgstr "" -#: ../../reference/expressions.rst:1335 +#: ../../reference/expressions.rst:1570 msgid "" "The primary must evaluate to a callable object (user-defined functions, " "built-in functions, methods of built-in objects, class objects, methods of " @@ -1621,7 +2114,7 @@ msgid "" "formal :term:`parameter` lists." msgstr "" -#: ../../reference/expressions.rst:1343 +#: ../../reference/expressions.rst:1578 msgid "" "If keyword arguments are present, they are first converted to positional " "arguments, as follows. First, a list of unfilled slots is created for the " @@ -1642,7 +2135,7 @@ msgid "" "filled slots is used as the argument list for the call." msgstr "" -#: ../../reference/expressions.rst:1363 +#: ../../reference/expressions.rst:1598 msgid "" "An implementation may provide built-in functions whose positional parameters " "do not have names, even if they are 'named' for the purpose of " @@ -1651,7 +2144,7 @@ msgid "" "`PyArg_ParseTuple` to parse their arguments." msgstr "" -#: ../../reference/expressions.rst:1369 +#: ../../reference/expressions.rst:1604 msgid "" "If there are more positional arguments than there are formal parameter " "slots, a :exc:`TypeError` exception is raised, unless a formal parameter " @@ -1660,7 +2153,7 @@ msgid "" "empty tuple if there were no excess positional arguments)." msgstr "" -#: ../../reference/expressions.rst:1375 +#: ../../reference/expressions.rst:1610 msgid "" "If any keyword argument does not correspond to a formal parameter name, a :" "exc:`TypeError` exception is raised, unless a formal parameter using the " @@ -1670,7 +2163,7 @@ msgid "" "(new) empty dictionary if there were no excess keyword arguments." msgstr "" -#: ../../reference/expressions.rst:1386 +#: ../../reference/expressions.rst:1621 msgid "" "If the syntax ``*expression`` appears in the function call, ``expression`` " "must evaluate to an :term:`iterable`. Elements from these iterables are " @@ -1680,14 +2173,14 @@ msgid "" "*y1*, ..., *yM*, *x3*, *x4*." msgstr "" -#: ../../reference/expressions.rst:1393 +#: ../../reference/expressions.rst:1628 msgid "" "A consequence of this is that although the ``*expression`` syntax may appear " "*after* explicit keyword arguments, it is processed *before* the keyword " "arguments (and any ``**expression`` arguments -- see below). So::" msgstr "" -#: ../../reference/expressions.rst:1397 +#: ../../reference/expressions.rst:1632 msgid "" ">>> def f(a, b):\n" "... print(a, b)\n" @@ -1713,13 +2206,13 @@ msgstr "" ">>> f(1, *(2,))\n" "1 2" -#: ../../reference/expressions.rst:1409 +#: ../../reference/expressions.rst:1644 msgid "" "It is unusual for both keyword arguments and the ``*expression`` syntax to " "be used in the same call, so in practice this confusion does not often arise." msgstr "" -#: ../../reference/expressions.rst:1415 +#: ../../reference/expressions.rst:1650 msgid "" "If the syntax ``**expression`` appears in the function call, ``expression`` " "must evaluate to a :term:`mapping`, the contents of which are treated as " @@ -1728,7 +2221,7 @@ msgid "" "a :exc:`TypeError` exception is raised." msgstr "" -#: ../../reference/expressions.rst:1421 +#: ../../reference/expressions.rst:1656 msgid "" "When ``**expression`` is used, each key in this mapping must be a string. " "Each value from the mapping is assigned to the first formal parameter " @@ -1740,35 +2233,35 @@ msgid "" "is raised." msgstr "" -#: ../../reference/expressions.rst:1431 +#: ../../reference/expressions.rst:1666 msgid "" "Formal parameters using the syntax ``*identifier`` or ``**identifier`` " "cannot be used as positional argument slots or as keyword argument names." msgstr "" -#: ../../reference/expressions.rst:1434 +#: ../../reference/expressions.rst:1669 msgid "" "Function calls accept any number of ``*`` and ``**`` unpackings, positional " "arguments may follow iterable unpackings (``*``), and keyword arguments may " "follow dictionary unpackings (``**``). Originally proposed by :pep:`448`." msgstr "" -#: ../../reference/expressions.rst:1440 +#: ../../reference/expressions.rst:1675 msgid "" "A call always returns some value, possibly ``None``, unless it raises an " "exception. How this value is computed depends on the type of the callable " "object." msgstr "" -#: ../../reference/expressions.rst:1444 +#: ../../reference/expressions.rst:1679 msgid "If it is---" msgstr "" -#: ../../reference/expressions.rst:1446 +#: ../../reference/expressions.rst:1681 msgid "a user-defined function:" msgstr "" -#: ../../reference/expressions.rst:1453 +#: ../../reference/expressions.rst:1688 msgid "" "The code block for the function is executed, passing it the argument list. " "The first thing the code block will do is bind the formal parameters to the " @@ -1779,73 +2272,73 @@ msgid "" "``None``." msgstr "" -#: ../../reference/expressions.rst:1460 +#: ../../reference/expressions.rst:1695 msgid "a built-in function or method:" msgstr "" -#: ../../reference/expressions.rst:1471 +#: ../../reference/expressions.rst:1706 msgid "" "The result is up to the interpreter; see :ref:`built-in-funcs` for the " "descriptions of built-in functions and methods." msgstr "" -#: ../../reference/expressions.rst:1474 +#: ../../reference/expressions.rst:1709 msgid "a class object:" msgstr "" -#: ../../reference/expressions.rst:1479 +#: ../../reference/expressions.rst:1714 msgid "A new instance of that class is returned." msgstr "" -#: ../../reference/expressions.rst:1481 +#: ../../reference/expressions.rst:1716 msgid "a class instance method:" msgstr "" -#: ../../reference/expressions.rst:1487 +#: ../../reference/expressions.rst:1722 msgid "" "The corresponding user-defined function is called, with an argument list " "that is one longer than the argument list of the call: the instance becomes " "the first argument." msgstr "" -#: ../../reference/expressions.rst:1491 +#: ../../reference/expressions.rst:1726 msgid "a class instance:" msgstr "" -#: ../../reference/expressions.rst:1496 +#: ../../reference/expressions.rst:1731 msgid "" "The class must define a :meth:`~object.__call__` method; the effect is then " "the same as if that method was called." msgstr "" -#: ../../reference/expressions.rst:1504 ../../reference/expressions.rst:2325 +#: ../../reference/expressions.rst:1739 ../../reference/expressions.rst:2576 msgid "Await expression" msgstr "" -#: ../../reference/expressions.rst:1506 +#: ../../reference/expressions.rst:1741 msgid "" "Suspend the execution of :term:`coroutine` on an :term:`awaitable` object. " "Can only be used inside a :term:`coroutine function`." msgstr "" -#: ../../reference/expressions.rst:1518 +#: ../../reference/expressions.rst:1753 msgid "The power operator" msgstr "" -#: ../../reference/expressions.rst:1524 +#: ../../reference/expressions.rst:1759 msgid "" "The power operator binds more tightly than unary operators on its left; it " "binds less tightly than unary operators on its right. The syntax is:" msgstr "" -#: ../../reference/expressions.rst:1530 +#: ../../reference/expressions.rst:1765 msgid "" "Thus, in an unparenthesized sequence of power and unary operators, the " "operators are evaluated from right to left (this does not constrain the " "evaluation order for the operands): ``-1**2`` results in ``-1``." msgstr "" -#: ../../reference/expressions.rst:1534 +#: ../../reference/expressions.rst:1769 msgid "" "The power operator has the same semantics as the built-in :func:`pow` " "function, when called with two arguments: it yields its left argument raised " @@ -1854,7 +2347,7 @@ msgid "" "of that type." msgstr "" -#: ../../reference/expressions.rst:1540 +#: ../../reference/expressions.rst:1775 msgid "" "For int operands, the result has the same type as the operands unless the " "second argument is negative; in that case, all arguments are converted to " @@ -1862,41 +2355,41 @@ msgid "" "``100``, but ``10**-2`` returns ``0.01``." msgstr "" -#: ../../reference/expressions.rst:1545 +#: ../../reference/expressions.rst:1780 msgid "" "Raising ``0.0`` to a negative power results in a :exc:`ZeroDivisionError`. " "Raising a negative number to a fractional power results in a :class:" "`complex` number. (In earlier versions it raised a :exc:`ValueError`.)" msgstr "" -#: ../../reference/expressions.rst:1549 +#: ../../reference/expressions.rst:1784 msgid "" "This operation can be customized using the special :meth:`~object.__pow__` " "and :meth:`~object.__rpow__` methods." msgstr "" -#: ../../reference/expressions.rst:1555 +#: ../../reference/expressions.rst:1790 msgid "Unary arithmetic and bitwise operations" msgstr "" -#: ../../reference/expressions.rst:1561 +#: ../../reference/expressions.rst:1796 msgid "All unary arithmetic and bitwise operations have the same priority:" msgstr "" -#: ../../reference/expressions.rst:1572 +#: ../../reference/expressions.rst:1807 msgid "" "The unary ``-`` (minus) operator yields the negation of its numeric " "argument; the operation can be overridden with the :meth:`~object.__neg__` " "special method." msgstr "" -#: ../../reference/expressions.rst:1580 +#: ../../reference/expressions.rst:1815 msgid "" "The unary ``+`` (plus) operator yields its numeric argument unchanged; the " "operation can be overridden with the :meth:`~object.__pos__` special method." msgstr "" -#: ../../reference/expressions.rst:1587 +#: ../../reference/expressions.rst:1822 msgid "" "The unary ``~`` (invert) operator yields the bitwise inversion of its " "integer argument. The bitwise inversion of ``x`` is defined as ``-(x+1)``. " @@ -1904,17 +2397,17 @@ msgid "" "meth:`~object.__invert__` special method." msgstr "" -#: ../../reference/expressions.rst:1596 +#: ../../reference/expressions.rst:1831 msgid "" "In all three cases, if the argument does not have the proper type, a :exc:" "`TypeError` exception is raised." msgstr "" -#: ../../reference/expressions.rst:1603 +#: ../../reference/expressions.rst:1838 msgid "Binary arithmetic operations" msgstr "" -#: ../../reference/expressions.rst:1607 +#: ../../reference/expressions.rst:1842 msgid "" "The binary arithmetic operations have the conventional priority levels. " "Note that some of these operations also apply to certain non-numeric types. " @@ -1922,7 +2415,7 @@ msgid "" "multiplicative operators and one for additive operators:" msgstr "" -#: ../../reference/expressions.rst:1622 +#: ../../reference/expressions.rst:1857 msgid "" "The ``*`` (multiplication) operator yields the product of its arguments. " "The arguments must either both be numbers, or one argument must be an " @@ -1932,32 +2425,32 @@ msgid "" "performed; a negative repetition factor yields an empty sequence." msgstr "" -#: ../../reference/expressions.rst:1629 +#: ../../reference/expressions.rst:1864 msgid "" "This operation can be customized using the special :meth:`~object.__mul__` " "and :meth:`~object.__rmul__` methods." msgstr "" -#: ../../reference/expressions.rst:1632 ../../reference/expressions.rst:1713 -#: ../../reference/expressions.rst:1729 +#: ../../reference/expressions.rst:1867 ../../reference/expressions.rst:1948 +#: ../../reference/expressions.rst:1964 msgid "" "If only one operand is a complex number, the other operand is converted to a " "floating-point number." msgstr "" -#: ../../reference/expressions.rst:1640 +#: ../../reference/expressions.rst:1875 msgid "" "The ``@`` (at) operator is intended to be used for matrix multiplication. " "No builtin Python types implement this operator." msgstr "" -#: ../../reference/expressions.rst:1643 +#: ../../reference/expressions.rst:1878 msgid "" "This operation can be customized using the special :meth:`~object." "__matmul__` and :meth:`~object.__rmatmul__` methods." msgstr "" -#: ../../reference/expressions.rst:1654 +#: ../../reference/expressions.rst:1889 msgid "" "The ``/`` (division) and ``//`` (floor division) operators yield the " "quotient of their arguments. The numeric arguments are first :ref:" @@ -1968,7 +2461,7 @@ msgid "" "`ZeroDivisionError` exception." msgstr "" -#: ../../reference/expressions.rst:1662 +#: ../../reference/expressions.rst:1897 msgid "" "The division operation can be customized using the special :meth:`~object." "__truediv__` and :meth:`~object.__rtruediv__` methods. The floor division " @@ -1976,7 +2469,7 @@ msgid "" "and :meth:`~object.__rfloordiv__` methods." msgstr "" -#: ../../reference/expressions.rst:1671 +#: ../../reference/expressions.rst:1906 msgid "" "The ``%`` (modulo) operator yields the remainder from the division of the " "first argument by the second. The numeric arguments are first :ref:" @@ -1989,7 +2482,7 @@ msgid "" "second operand [#]_." msgstr "" -#: ../../reference/expressions.rst:1681 +#: ../../reference/expressions.rst:1916 msgid "" "The floor division and modulo operators are connected by the following " "identity: ``x == (x//y)*y + (x%y)``. Floor division and modulo are also " @@ -1997,7 +2490,7 @@ msgid "" "y, x%y)``. [#]_." msgstr "" -#: ../../reference/expressions.rst:1686 +#: ../../reference/expressions.rst:1921 msgid "" "In addition to performing the modulo operation on numbers, the ``%`` " "operator is also overloaded by string objects to perform old-style string " @@ -2006,20 +2499,20 @@ msgid "" "formatting`." msgstr "" -#: ../../reference/expressions.rst:1691 +#: ../../reference/expressions.rst:1926 msgid "" "The *modulo* operation can be customized using the special :meth:`~object." "__mod__` and :meth:`~object.__rmod__` methods." msgstr "" -#: ../../reference/expressions.rst:1694 +#: ../../reference/expressions.rst:1929 msgid "" "The floor division operator, the modulo operator, and the :func:`divmod` " "function are not defined for complex numbers. Instead, convert to a " "floating-point number using the :func:`abs` function if appropriate." msgstr "" -#: ../../reference/expressions.rst:1703 +#: ../../reference/expressions.rst:1938 msgid "" "The ``+`` (addition) operator yields the sum of its arguments. The " "arguments must either both be numbers or both be sequences of the same " @@ -2028,41 +2521,41 @@ msgid "" "case, the sequences are concatenated." msgstr "" -#: ../../reference/expressions.rst:1710 +#: ../../reference/expressions.rst:1945 msgid "" "This operation can be customized using the special :meth:`~object.__add__` " "and :meth:`~object.__radd__` methods." msgstr "" -#: ../../reference/expressions.rst:1722 +#: ../../reference/expressions.rst:1957 msgid "" "The ``-`` (subtraction) operator yields the difference of its arguments. The " "numeric arguments are first :ref:`converted to a common real type `." msgstr "" -#: ../../reference/expressions.rst:1726 +#: ../../reference/expressions.rst:1961 msgid "" "This operation can be customized using the special :meth:`~object.__sub__` " "and :meth:`~object.__rsub__` methods." msgstr "" -#: ../../reference/expressions.rst:1737 +#: ../../reference/expressions.rst:1972 msgid "Shifting operations" msgstr "" -#: ../../reference/expressions.rst:1744 +#: ../../reference/expressions.rst:1979 msgid "" "The shifting operations have lower priority than the arithmetic operations:" msgstr "" -#: ../../reference/expressions.rst:1749 +#: ../../reference/expressions.rst:1984 msgid "" "These operators accept integers as arguments. They shift the first argument " "to the left or right by the number of bits given by the second argument." msgstr "" -#: ../../reference/expressions.rst:1752 +#: ../../reference/expressions.rst:1987 msgid "" "The left shift operation can be customized using the special :meth:`~object." "__lshift__` and :meth:`~object.__rlshift__` methods. The right shift " @@ -2070,46 +2563,46 @@ msgid "" "and :meth:`~object.__rrshift__` methods." msgstr "" -#: ../../reference/expressions.rst:1759 +#: ../../reference/expressions.rst:1994 msgid "" "A right shift by *n* bits is defined as floor division by ``pow(2,n)``. A " "left shift by *n* bits is defined as multiplication with ``pow(2,n)``." msgstr "" -#: ../../reference/expressions.rst:1766 +#: ../../reference/expressions.rst:2001 msgid "Binary bitwise operations" msgstr "" -#: ../../reference/expressions.rst:1770 +#: ../../reference/expressions.rst:2005 msgid "Each of the three bitwise operations has a different priority level:" msgstr "" -#: ../../reference/expressions.rst:1781 +#: ../../reference/expressions.rst:2016 msgid "" "The ``&`` operator yields the bitwise AND of its arguments, which must be " "integers or one of them must be a custom object overriding :meth:`~object." "__and__` or :meth:`~object.__rand__` special methods." msgstr "" -#: ../../reference/expressions.rst:1790 +#: ../../reference/expressions.rst:2025 msgid "" "The ``^`` operator yields the bitwise XOR (exclusive OR) of its arguments, " "which must be integers or one of them must be a custom object overriding :" "meth:`~object.__xor__` or :meth:`~object.__rxor__` special methods." msgstr "" -#: ../../reference/expressions.rst:1799 +#: ../../reference/expressions.rst:2034 msgid "" "The ``|`` operator yields the bitwise (inclusive) OR of its arguments, which " "must be integers or one of them must be a custom object overriding :meth:" "`~object.__or__` or :meth:`~object.__ror__` special methods." msgstr "" -#: ../../reference/expressions.rst:1807 +#: ../../reference/expressions.rst:2042 msgid "Comparisons" msgstr "" -#: ../../reference/expressions.rst:1819 +#: ../../reference/expressions.rst:2054 msgid "" "Unlike C, all comparison operations in Python have the same priority, which " "is lower than that of any arithmetic, shifting or bitwise operation. Also " @@ -2117,14 +2610,14 @@ msgid "" "conventional in mathematics:" msgstr "" -#: ../../reference/expressions.rst:1829 +#: ../../reference/expressions.rst:2064 msgid "" "Comparisons yield boolean values: ``True`` or ``False``. Custom :dfn:`rich " "comparison methods` may return non-boolean values. In this case Python will " "call :func:`bool` on such value in boolean contexts." msgstr "" -#: ../../reference/expressions.rst:1835 +#: ../../reference/expressions.rst:2070 msgid "" "Comparisons can be chained arbitrarily, e.g., ``x < y <= z`` is equivalent " "to ``x < y and y <= z``, except that ``y`` is evaluated only once (but in " @@ -2132,7 +2625,7 @@ msgid "" "false)." msgstr "" -#: ../../reference/expressions.rst:1839 +#: ../../reference/expressions.rst:2074 msgid "" "Formally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*, " "*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y opN " @@ -2140,24 +2633,24 @@ msgid "" "each expression is evaluated at most once." msgstr "" -#: ../../reference/expressions.rst:1844 +#: ../../reference/expressions.rst:2079 msgid "" "Note that ``a op1 b op2 c`` doesn't imply any kind of comparison between *a* " "and *c*, so that, e.g., ``x < y > z`` is perfectly legal (though perhaps not " "pretty)." msgstr "" -#: ../../reference/expressions.rst:1851 +#: ../../reference/expressions.rst:2086 msgid "Value comparisons" msgstr "" -#: ../../reference/expressions.rst:1853 +#: ../../reference/expressions.rst:2088 msgid "" "The operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare the " "values of two objects. The objects do not need to have the same type." msgstr "" -#: ../../reference/expressions.rst:1856 +#: ../../reference/expressions.rst:2091 msgid "" "Chapter :ref:`objects` states that objects have a value (in addition to type " "and identity). The value of an object is a rather abstract notion in " @@ -2169,7 +2662,7 @@ msgid "" "indirectly, by means of their comparison implementation." msgstr "" -#: ../../reference/expressions.rst:1865 +#: ../../reference/expressions.rst:2100 msgid "" "Because all types are (direct or indirect) subtypes of :class:`object`, they " "inherit the default comparison behavior from :class:`object`. Types can " @@ -2177,7 +2670,7 @@ msgid "" "methods` like :meth:`~object.__lt__`, described in :ref:`customization`." msgstr "" -#: ../../reference/expressions.rst:1871 +#: ../../reference/expressions.rst:2106 msgid "" "The default behavior for equality comparison (``==`` and ``!=``) is based on " "the identity of the objects. Hence, equality comparison of instances with " @@ -2187,14 +2680,14 @@ msgid "" "``x is y`` implies ``x == y``)." msgstr "" -#: ../../reference/expressions.rst:1878 +#: ../../reference/expressions.rst:2113 msgid "" "A default order comparison (``<``, ``>``, ``<=``, and ``>=``) is not " "provided; an attempt raises :exc:`TypeError`. A motivation for this default " "behavior is the lack of a similar invariant as for equality." msgstr "" -#: ../../reference/expressions.rst:1882 +#: ../../reference/expressions.rst:2117 msgid "" "The behavior of the default equality comparison, that instances with " "different identities are always unequal, may be in contrast to what types " @@ -2203,13 +2696,13 @@ msgid "" "in fact, a number of built-in types have done that." msgstr "" -#: ../../reference/expressions.rst:1888 +#: ../../reference/expressions.rst:2123 msgid "" "The following list describes the comparison behavior of the most important " "built-in types." msgstr "" -#: ../../reference/expressions.rst:1891 +#: ../../reference/expressions.rst:2126 msgid "" "Numbers of built-in numeric types (:ref:`typesnumeric`) and of the standard " "library types :class:`fractions.Fraction` and :class:`decimal.Decimal` can " @@ -2219,7 +2712,7 @@ msgid "" "of precision." msgstr "" -#: ../../reference/expressions.rst:1898 +#: ../../reference/expressions.rst:2133 msgid "" "The not-a-number values ``float('NaN')`` and ``decimal.Decimal('NaN')`` are " "special. Any ordered comparison of a number to a not-a-number value is " @@ -2229,32 +2722,32 @@ msgid "" "is compliant with IEEE 754." msgstr "" -#: ../../reference/expressions.rst:1905 +#: ../../reference/expressions.rst:2140 msgid "" "``None`` and :data:`NotImplemented` are singletons. :PEP:`8` advises that " "comparisons for singletons should always be done with ``is`` or ``is not``, " "never the equality operators." msgstr "" -#: ../../reference/expressions.rst:1909 +#: ../../reference/expressions.rst:2144 msgid "" "Binary sequences (instances of :class:`bytes` or :class:`bytearray`) can be " "compared within and across their types. They compare lexicographically " "using the numeric values of their elements." msgstr "" -#: ../../reference/expressions.rst:1913 +#: ../../reference/expressions.rst:2148 msgid "" "Strings (instances of :class:`str`) compare lexicographically using the " "numerical Unicode code points (the result of the built-in function :func:" "`ord`) of their characters. [#]_" msgstr "" -#: ../../reference/expressions.rst:1917 +#: ../../reference/expressions.rst:2152 msgid "Strings and binary sequences cannot be directly compared." msgstr "" -#: ../../reference/expressions.rst:1919 +#: ../../reference/expressions.rst:2154 msgid "" "Sequences (instances of :class:`tuple`, :class:`list`, or :class:`range`) " "can be compared only within each of their types, with the restriction that " @@ -2263,7 +2756,7 @@ msgid "" "raises :exc:`TypeError`." msgstr "" -#: ../../reference/expressions.rst:1925 +#: ../../reference/expressions.rst:2160 msgid "" "Sequences compare lexicographically using comparison of corresponding " "elements. The built-in containers typically assume identical objects are " @@ -2271,19 +2764,19 @@ msgid "" "objects to improve performance and to maintain their internal invariants." msgstr "" -#: ../../reference/expressions.rst:1930 +#: ../../reference/expressions.rst:2165 msgid "" "Lexicographical comparison between built-in collections works as follows:" msgstr "" -#: ../../reference/expressions.rst:1932 +#: ../../reference/expressions.rst:2167 msgid "" "For two collections to compare equal, they must be of the same type, have " "the same length, and each pair of corresponding elements must compare equal " "(for example, ``[1,2] == (1,2)`` is false because the type is not the same)." msgstr "" -#: ../../reference/expressions.rst:1937 +#: ../../reference/expressions.rst:2172 msgid "" "Collections that support order comparison are ordered the same as their " "first unequal elements (for example, ``[1,2,x] <= [1,2,y]`` has the same " @@ -2292,25 +2785,25 @@ msgid "" "true)." msgstr "" -#: ../../reference/expressions.rst:1943 +#: ../../reference/expressions.rst:2178 msgid "" "Mappings (instances of :class:`dict`) compare equal if and only if they have " "equal ``(key, value)`` pairs. Equality comparison of the keys and values " "enforces reflexivity." msgstr "" -#: ../../reference/expressions.rst:1947 +#: ../../reference/expressions.rst:2182 msgid "" "Order comparisons (``<``, ``>``, ``<=``, and ``>=``) raise :exc:`TypeError`." msgstr "" -#: ../../reference/expressions.rst:1949 +#: ../../reference/expressions.rst:2184 msgid "" "Sets (instances of :class:`set` or :class:`frozenset`) can be compared " "within and across their types." msgstr "" -#: ../../reference/expressions.rst:1952 +#: ../../reference/expressions.rst:2187 msgid "" "They define order comparison operators to mean subset and superset tests. " "Those relations do not define total orderings (for example, the two sets " @@ -2321,110 +2814,110 @@ msgid "" "sets as inputs)." msgstr "" -#: ../../reference/expressions.rst:1960 +#: ../../reference/expressions.rst:2195 msgid "Comparison of sets enforces reflexivity of its elements." msgstr "" -#: ../../reference/expressions.rst:1962 +#: ../../reference/expressions.rst:2197 msgid "" "Most other built-in types have no comparison methods implemented, so they " "inherit the default comparison behavior." msgstr "" -#: ../../reference/expressions.rst:1965 +#: ../../reference/expressions.rst:2200 msgid "" "User-defined classes that customize their comparison behavior should follow " "some consistency rules, if possible:" msgstr "" -#: ../../reference/expressions.rst:1968 +#: ../../reference/expressions.rst:2203 msgid "" "Equality comparison should be reflexive. In other words, identical objects " "should compare equal:" msgstr "" -#: ../../reference/expressions.rst:1971 +#: ../../reference/expressions.rst:2206 msgid "``x is y`` implies ``x == y``" msgstr "" -#: ../../reference/expressions.rst:1973 +#: ../../reference/expressions.rst:2208 msgid "" "Comparison should be symmetric. In other words, the following expressions " "should have the same result:" msgstr "" -#: ../../reference/expressions.rst:1976 +#: ../../reference/expressions.rst:2211 msgid "``x == y`` and ``y == x``" msgstr "``x == y`` 和 ``y == x``" -#: ../../reference/expressions.rst:1978 +#: ../../reference/expressions.rst:2213 msgid "``x != y`` and ``y != x``" msgstr "``x != y`` 和 ``y != x``" -#: ../../reference/expressions.rst:1980 +#: ../../reference/expressions.rst:2215 msgid "``x < y`` and ``y > x``" msgstr "``x < y`` 和 ``y > x``" -#: ../../reference/expressions.rst:1982 +#: ../../reference/expressions.rst:2217 msgid "``x <= y`` and ``y >= x``" msgstr "``x <= y`` 和 ``y >= x``" -#: ../../reference/expressions.rst:1984 +#: ../../reference/expressions.rst:2219 msgid "" "Comparison should be transitive. The following (non-exhaustive) examples " "illustrate that:" msgstr "" -#: ../../reference/expressions.rst:1987 +#: ../../reference/expressions.rst:2222 msgid "``x > y and y > z`` implies ``x > z``" msgstr "``x > y and y > z`` 暗示了 ``x > z``" -#: ../../reference/expressions.rst:1989 +#: ../../reference/expressions.rst:2224 msgid "``x < y and y <= z`` implies ``x < z``" msgstr "``x < y and y <= z`` 暗示了 ``x < z``" -#: ../../reference/expressions.rst:1991 +#: ../../reference/expressions.rst:2226 msgid "" "Inverse comparison should result in the boolean negation. In other words, " "the following expressions should have the same result:" msgstr "" -#: ../../reference/expressions.rst:1994 +#: ../../reference/expressions.rst:2229 msgid "``x == y`` and ``not x != y``" msgstr "``x == y`` 和 ``not x != y``" -#: ../../reference/expressions.rst:1996 +#: ../../reference/expressions.rst:2231 msgid "``x < y`` and ``not x >= y`` (for total ordering)" msgstr "" -#: ../../reference/expressions.rst:1998 +#: ../../reference/expressions.rst:2233 msgid "``x > y`` and ``not x <= y`` (for total ordering)" msgstr "" -#: ../../reference/expressions.rst:2000 +#: ../../reference/expressions.rst:2235 msgid "" "The last two expressions apply to totally ordered collections (e.g. to " "sequences, but not to sets or mappings). See also the :deco:`~functools." "total_ordering` decorator." msgstr "" -#: ../../reference/expressions.rst:2004 +#: ../../reference/expressions.rst:2239 msgid "" "The :func:`hash` result should be consistent with equality. Objects that are " "equal should either have the same hash value, or be marked as unhashable." msgstr "" -#: ../../reference/expressions.rst:2008 +#: ../../reference/expressions.rst:2243 msgid "" "Python does not enforce these consistency rules. In fact, the not-a-number " "values are an example for not following these rules." msgstr "" -#: ../../reference/expressions.rst:2017 +#: ../../reference/expressions.rst:2252 msgid "Membership test operations" msgstr "" -#: ../../reference/expressions.rst:2019 +#: ../../reference/expressions.rst:2254 msgid "" "The operators :keyword:`in` and :keyword:`not in` test for membership. ``x " "in s`` evaluates to ``True`` if *x* is a member of *s*, and ``False`` " @@ -2435,7 +2928,7 @@ msgid "" "expression ``x in y`` is equivalent to ``any(x is e or x == e for e in y)``." msgstr "" -#: ../../reference/expressions.rst:2027 +#: ../../reference/expressions.rst:2262 msgid "" "For the string and bytes types, ``x in y`` is ``True`` if and only if *x* is " "a substring of *y*. An equivalent test is ``y.find(x) != -1``. Empty " @@ -2443,14 +2936,14 @@ msgid "" "``\"\" in \"abc\"`` will return ``True``." msgstr "" -#: ../../reference/expressions.rst:2032 +#: ../../reference/expressions.rst:2267 msgid "" "For user-defined classes which define the :meth:`~object.__contains__` " "method, ``x in y`` returns ``True`` if ``y.__contains__(x)`` returns a true " "value, and ``False`` otherwise." msgstr "" -#: ../../reference/expressions.rst:2036 +#: ../../reference/expressions.rst:2271 msgid "" "For user-defined classes which do not define :meth:`~object.__contains__` " "but do define :meth:`~object.__iter__`, ``x in y`` is ``True`` if some value " @@ -2459,7 +2952,7 @@ msgid "" "it is as if :keyword:`in` raised that exception." msgstr "" -#: ../../reference/expressions.rst:2042 +#: ../../reference/expressions.rst:2277 msgid "" "Lastly, the old-style iteration protocol is tried: if a class defines :meth:" "`~object.__getitem__`, ``x in y`` is ``True`` if and only if there is a non-" @@ -2468,17 +2961,17 @@ msgid "" "exception is raised, it is as if :keyword:`in` raised that exception)." msgstr "" -#: ../../reference/expressions.rst:2054 +#: ../../reference/expressions.rst:2289 msgid "" "The operator :keyword:`not in` is defined to have the inverse truth value " "of :keyword:`in`." msgstr "" -#: ../../reference/expressions.rst:2067 +#: ../../reference/expressions.rst:2302 msgid "Identity comparisons" msgstr "" -#: ../../reference/expressions.rst:2069 +#: ../../reference/expressions.rst:2304 msgid "" "The operators :keyword:`is` and :keyword:`is not` test for an object's " "identity: ``x is y`` is true if and only if *x* and *y* are the same " @@ -2486,11 +2979,11 @@ msgid "" "``x is not y`` yields the inverse truth value. [#]_" msgstr "" -#: ../../reference/expressions.rst:2081 +#: ../../reference/expressions.rst:2316 msgid "Boolean operations" msgstr "" -#: ../../reference/expressions.rst:2092 +#: ../../reference/expressions.rst:2327 msgid "" "In the context of Boolean operations, and also when expressions are used by " "control flow statements, the following values are interpreted as false: " @@ -2501,25 +2994,25 @@ msgid "" "__bool__` method." msgstr "" -#: ../../reference/expressions.rst:2101 +#: ../../reference/expressions.rst:2336 msgid "" "The operator :keyword:`not` yields ``True`` if its argument is false, " "``False`` otherwise." msgstr "" -#: ../../reference/expressions.rst:2106 +#: ../../reference/expressions.rst:2341 msgid "" "The expression ``x and y`` first evaluates *x*; if *x* is false, its value " "is returned; otherwise, *y* is evaluated and the resulting value is returned." msgstr "" -#: ../../reference/expressions.rst:2111 +#: ../../reference/expressions.rst:2346 msgid "" "The expression ``x or y`` first evaluates *x*; if *x* is true, its value is " "returned; otherwise, *y* is evaluated and the resulting value is returned." msgstr "" -#: ../../reference/expressions.rst:2114 +#: ../../reference/expressions.rst:2349 msgid "" "Note that neither :keyword:`and` nor :keyword:`or` restrict the value and " "type they return to ``False`` and ``True``, but rather return the last " @@ -2530,11 +3023,11 @@ msgid "" "argument (for example, ``not 'foo'`` produces ``False`` rather than ``''``.)" msgstr "" -#: ../../reference/expressions.rst:2133 +#: ../../reference/expressions.rst:2368 msgid "Assignment expressions" msgstr "" -#: ../../reference/expressions.rst:2138 +#: ../../reference/expressions.rst:2373 msgid "" "An assignment expression (sometimes also called a \"named expression\" or " "\"walrus\") assigns an :token:`~python-grammar:expression` to an :token:" @@ -2542,11 +3035,11 @@ msgid "" "`~python-grammar:expression`." msgstr "" -#: ../../reference/expressions.rst:2143 +#: ../../reference/expressions.rst:2378 msgid "One common use case is when handling matched regular expressions:" msgstr "" -#: ../../reference/expressions.rst:2145 +#: ../../reference/expressions.rst:2380 msgid "" "if matching := pattern.search(data):\n" " do_something(matching)" @@ -2554,11 +3047,11 @@ msgstr "" "if matching := pattern.search(data):\n" " do_something(matching)" -#: ../../reference/expressions.rst:2150 +#: ../../reference/expressions.rst:2385 msgid "Or, when processing a file stream in chunks:" msgstr "" -#: ../../reference/expressions.rst:2152 +#: ../../reference/expressions.rst:2387 msgid "" "while chunk := file.read(9000):\n" " process(chunk)" @@ -2566,7 +3059,7 @@ msgstr "" "while chunk := file.read(9000):\n" " process(chunk)" -#: ../../reference/expressions.rst:2157 +#: ../../reference/expressions.rst:2392 msgid "" "Assignment expressions must be surrounded by parentheses when used as " "expression statements and when used as sub-expressions in slicing, " @@ -2576,37 +3069,37 @@ msgid "" "and ``while`` statements." msgstr "" -#: ../../reference/expressions.rst:2165 +#: ../../reference/expressions.rst:2400 msgid "See :pep:`572` for more details about assignment expressions." msgstr "" -#: ../../reference/expressions.rst:2172 +#: ../../reference/expressions.rst:2407 msgid "Conditional expressions" msgstr "" -#: ../../reference/expressions.rst:2184 +#: ../../reference/expressions.rst:2419 msgid "" "A conditional expression (sometimes called a \"ternary operator\") is an " "alternative to the if-else statement. As it is an expression, it returns a " "value and can appear as a sub-expression." msgstr "" -#: ../../reference/expressions.rst:2188 +#: ../../reference/expressions.rst:2423 msgid "" "The expression ``x if C else y`` first evaluates the condition, *C* rather " "than *x*. If *C* is true, *x* is evaluated and its value is returned; " "otherwise, *y* is evaluated and its value is returned." msgstr "" -#: ../../reference/expressions.rst:2192 +#: ../../reference/expressions.rst:2427 msgid "See :pep:`308` for more details about conditional expressions." msgstr "" -#: ../../reference/expressions.rst:2199 +#: ../../reference/expressions.rst:2434 msgid "Lambdas" msgstr "" -#: ../../reference/expressions.rst:2210 +#: ../../reference/expressions.rst:2445 msgid "" "Lambda expressions (sometimes called lambda forms) are used to create " "anonymous functions. The expression ``lambda parameters: expression`` yields " @@ -2614,7 +3107,7 @@ msgid "" "defined with:" msgstr "" -#: ../../reference/expressions.rst:2214 +#: ../../reference/expressions.rst:2449 msgid "" "def (parameters):\n" " return expression" @@ -2622,68 +3115,77 @@ msgstr "" "def (parameters):\n" " return expression" -#: ../../reference/expressions.rst:2219 +#: ../../reference/expressions.rst:2454 msgid "" "See section :ref:`function` for the syntax of parameter lists. Note that " "functions created with lambda expressions cannot contain statements or " "annotations." msgstr "" -#: ../../reference/expressions.rst:2227 +#: ../../reference/expressions.rst:2466 msgid "Expression lists" msgstr "" -#: ../../reference/expressions.rst:2243 +#: ../../reference/expressions.rst:2482 msgid "" "Except when part of a list or set display, an expression list containing at " "least one comma yields a tuple. The length of the tuple is the number of " "expressions in the list. The expressions are evaluated from left to right." msgstr "" -#: ../../reference/expressions.rst:2252 +#: ../../reference/expressions.rst:2489 msgid "" -"An asterisk ``*`` denotes :dfn:`iterable unpacking`. Its operand must be " -"an :term:`iterable`. The iterable is expanded into a sequence of items, " -"which are included in the new tuple, list, or set, at the site of the " -"unpacking." +"A trailing comma is required only to create a one-item tuple, such as ``1," +"``; it is optional in all other cases. A single expression without a " +"trailing comma doesn't create a tuple, but rather yields the value of that " +"expression. (To create an empty tuple, use an empty pair of parentheses: " +"``()``.)" msgstr "" -#: ../../reference/expressions.rst:2257 +#: ../../reference/expressions.rst:2504 +msgid "Iterable unpacking" +msgstr "可疊代物件解包" + +#: ../../reference/expressions.rst:2506 msgid "" -"Iterable unpacking in expression lists, originally proposed by :pep:`448`." +"In an expression list or tuple, list or set display, any expression may be " +"prefixed with an asterisk (``*``). This denotes :dfn:`iterable unpacking`." msgstr "" -#: ../../reference/expressions.rst:2260 -msgid "Any item in an expression list may be starred. See :pep:`646`." +#: ../../reference/expressions.rst:2510 +msgid "" +"At runtime, the asterisk-prefixed expression must evaluate to an :term:" +"`iterable`. The iterable is expanded into a sequence of items, which are " +"included in the new tuple, list, or set, at the site of the unpacking." msgstr "" -#: ../../reference/expressions.rst:2265 +#: ../../reference/expressions.rst:2516 msgid "" -"A trailing comma is required only to create a one-item tuple, such as ``1," -"``; it is optional in all other cases. A single expression without a " -"trailing comma doesn't create a tuple, but rather yields the value of that " -"expression. (To create an empty tuple, use an empty pair of parentheses: " -"``()``.)" +"Iterable unpacking in expression lists, originally proposed by :pep:`448`." +msgstr "" + +#: ../../reference/expressions.rst:2519 +msgid "Any item in an expression list may be starred. See :pep:`646`." msgstr "" -#: ../../reference/expressions.rst:2276 +#: ../../reference/expressions.rst:2526 msgid "Evaluation order" msgstr "" -#: ../../reference/expressions.rst:2280 +#: ../../reference/expressions.rst:2530 msgid "" "Python evaluates expressions from left to right. Notice that while " "evaluating an assignment, the right-hand side is evaluated before the left-" "hand side." msgstr "" -#: ../../reference/expressions.rst:2283 +#: ../../reference/expressions.rst:2533 msgid "" "In the following lines, expressions will be evaluated in the arithmetic " "order of their suffixes::" msgstr "" -#: ../../reference/expressions.rst:2286 +#: ../../reference/expressions.rst:2536 msgid "" "expr1, expr2, expr3, expr4\n" "(expr1, expr2, expr3, expr4)\n" @@ -2699,11 +3201,11 @@ msgstr "" "expr1(expr2, expr3, *expr4, **expr5)\n" "expr3, expr4 = expr1, expr2" -#: ../../reference/expressions.rst:2297 +#: ../../reference/expressions.rst:2548 msgid "Operator precedence" msgstr "" -#: ../../reference/expressions.rst:2302 +#: ../../reference/expressions.rst:2553 msgid "" "The following table summarizes the operator precedence in Python, from " "highest precedence (most binding) to lowest precedence (least binding). " @@ -2713,176 +3215,176 @@ msgid "" "group from right to left)." msgstr "" -#: ../../reference/expressions.rst:2308 +#: ../../reference/expressions.rst:2559 msgid "" "Note that comparisons, membership tests, and identity tests, all have the " "same precedence and have a left-to-right chaining feature as described in " "the :ref:`comparisons` section." msgstr "" -#: ../../reference/expressions.rst:2314 +#: ../../reference/expressions.rst:2565 msgid "Operator" msgstr "運算子" -#: ../../reference/expressions.rst:2314 +#: ../../reference/expressions.rst:2565 msgid "Description" msgstr "描述" -#: ../../reference/expressions.rst:2316 +#: ../../reference/expressions.rst:2567 msgid "``(expressions...)``," msgstr "``(expressions...)``," -#: ../../reference/expressions.rst:2318 +#: ../../reference/expressions.rst:2569 msgid "``[expressions...]``, ``{key: value...}``, ``{expressions...}``" msgstr "``[expressions...]``, ``{key: value...}``, ``{expressions...}``" -#: ../../reference/expressions.rst:2316 +#: ../../reference/expressions.rst:2567 msgid "" "Binding or parenthesized expression, list display, dictionary display, set " "display" msgstr "" -#: ../../reference/expressions.rst:2322 +#: ../../reference/expressions.rst:2573 msgid "``x[index]``, ``x[index:index]`` ``x(arguments...)``, ``x.attribute``" msgstr "``x[index]``, ``x[index:index]`` ``x(arguments...)``, ``x.attribute``" -#: ../../reference/expressions.rst:2322 +#: ../../reference/expressions.rst:2573 msgid "Subscription (including slicing), call, attribute reference" msgstr "" -#: ../../reference/expressions.rst:2325 +#: ../../reference/expressions.rst:2576 msgid ":keyword:`await x `" msgstr ":keyword:`await x `" -#: ../../reference/expressions.rst:2327 +#: ../../reference/expressions.rst:2578 msgid "``**``" msgstr "``**``" -#: ../../reference/expressions.rst:2327 +#: ../../reference/expressions.rst:2578 msgid "Exponentiation [#]_" msgstr "" -#: ../../reference/expressions.rst:2329 +#: ../../reference/expressions.rst:2580 msgid "``+x``, ``-x``, ``~x``" msgstr "``+x``, ``-x``, ``~x``" -#: ../../reference/expressions.rst:2329 +#: ../../reference/expressions.rst:2580 msgid "Positive, negative, bitwise NOT" msgstr "" -#: ../../reference/expressions.rst:2331 +#: ../../reference/expressions.rst:2582 msgid "``*``, ``@``, ``/``, ``//``, ``%``" msgstr "``*``, ``@``, ``/``, ``//``, ``%``" -#: ../../reference/expressions.rst:2331 +#: ../../reference/expressions.rst:2582 msgid "" "Multiplication, matrix multiplication, division, floor division, remainder " "[#]_" msgstr "" -#: ../../reference/expressions.rst:2335 +#: ../../reference/expressions.rst:2586 msgid "``+``, ``-``" msgstr "``+``, ``-``" -#: ../../reference/expressions.rst:2335 +#: ../../reference/expressions.rst:2586 msgid "Addition and subtraction" msgstr "" -#: ../../reference/expressions.rst:2337 +#: ../../reference/expressions.rst:2588 msgid "``<<``, ``>>``" msgstr "``<<``, ``>>``" -#: ../../reference/expressions.rst:2337 +#: ../../reference/expressions.rst:2588 msgid "Shifts" msgstr "" -#: ../../reference/expressions.rst:2339 +#: ../../reference/expressions.rst:2590 msgid "``&``" msgstr "``&``" -#: ../../reference/expressions.rst:2339 +#: ../../reference/expressions.rst:2590 msgid "Bitwise AND" msgstr "" -#: ../../reference/expressions.rst:2341 +#: ../../reference/expressions.rst:2592 msgid "``^``" msgstr "``^``" -#: ../../reference/expressions.rst:2341 +#: ../../reference/expressions.rst:2592 msgid "Bitwise XOR" msgstr "" -#: ../../reference/expressions.rst:2343 +#: ../../reference/expressions.rst:2594 msgid "``|``" msgstr "``|``" -#: ../../reference/expressions.rst:2343 +#: ../../reference/expressions.rst:2594 msgid "Bitwise OR" msgstr "" -#: ../../reference/expressions.rst:2345 +#: ../../reference/expressions.rst:2596 msgid "" ":keyword:`in`, :keyword:`not in`, :keyword:`is`, :keyword:`is not`, ``<``, " "``<=``, ``>``, ``>=``, ``!=``, ``==``" msgstr "" -#: ../../reference/expressions.rst:2345 +#: ../../reference/expressions.rst:2596 msgid "Comparisons, including membership tests and identity tests" msgstr "" -#: ../../reference/expressions.rst:2349 +#: ../../reference/expressions.rst:2600 msgid ":keyword:`not x `" msgstr ":keyword:`not x `" -#: ../../reference/expressions.rst:2349 +#: ../../reference/expressions.rst:2600 msgid "Boolean NOT" msgstr "" -#: ../../reference/expressions.rst:2351 +#: ../../reference/expressions.rst:2602 msgid ":keyword:`and`" msgstr ":keyword:`and`" -#: ../../reference/expressions.rst:2351 +#: ../../reference/expressions.rst:2602 msgid "Boolean AND" msgstr "" -#: ../../reference/expressions.rst:2353 +#: ../../reference/expressions.rst:2604 msgid ":keyword:`or`" msgstr ":keyword:`or`" -#: ../../reference/expressions.rst:2353 +#: ../../reference/expressions.rst:2604 msgid "Boolean OR" msgstr "" -#: ../../reference/expressions.rst:2355 +#: ../../reference/expressions.rst:2606 msgid ":keyword:`if ` -- :keyword:`!else`" msgstr ":keyword:`if ` -- :keyword:`!else`" -#: ../../reference/expressions.rst:2355 +#: ../../reference/expressions.rst:2606 msgid "Conditional expression" msgstr "" -#: ../../reference/expressions.rst:2357 +#: ../../reference/expressions.rst:2608 msgid ":keyword:`lambda`" msgstr ":keyword:`lambda`" -#: ../../reference/expressions.rst:2357 +#: ../../reference/expressions.rst:2608 msgid "Lambda expression" msgstr "" -#: ../../reference/expressions.rst:2359 +#: ../../reference/expressions.rst:2610 msgid "``:=``" msgstr "``:=``" -#: ../../reference/expressions.rst:2359 +#: ../../reference/expressions.rst:2610 msgid "Assignment expression" msgstr "" -#: ../../reference/expressions.rst:2364 +#: ../../reference/expressions.rst:2615 msgid "Footnotes" msgstr "註解" -#: ../../reference/expressions.rst:2365 +#: ../../reference/expressions.rst:2616 msgid "" "While ``abs(x%y) < abs(y)`` is true mathematically, for floats it may not be " "true numerically due to roundoff. For example, and assuming a platform on " @@ -2894,7 +3396,7 @@ msgid "" "approach is more appropriate depends on the application." msgstr "" -#: ../../reference/expressions.rst:2374 +#: ../../reference/expressions.rst:2625 msgid "" "If x is very close to an exact integer multiple of y, it's possible for ``x//" "y`` to be one larger than ``(x-x%y)//y`` due to rounding. In such cases, " @@ -2902,7 +3404,7 @@ msgid "" "* y + x % y`` be very close to ``x``." msgstr "" -#: ../../reference/expressions.rst:2379 +#: ../../reference/expressions.rst:2630 msgid "" "The Unicode standard distinguishes between :dfn:`code points` (e.g. U+0041) " "and :dfn:`abstract characters` (e.g. \"LATIN CAPITAL LETTER A\"). While most " @@ -2916,7 +3418,7 @@ msgid "" "(COMBINING CEDILLA)." msgstr "" -#: ../../reference/expressions.rst:2390 +#: ../../reference/expressions.rst:2641 msgid "" "The comparison operators on strings compare at the level of Unicode code " "points. This may be counter-intuitive to humans. For example, ``\"\\u00C7\" " @@ -2924,13 +3426,13 @@ msgid "" "same abstract character \"LATIN CAPITAL LETTER C WITH CEDILLA\"." msgstr "" -#: ../../reference/expressions.rst:2395 +#: ../../reference/expressions.rst:2646 msgid "" "To compare strings at the level of abstract characters (that is, in a way " "intuitive to humans), use :func:`unicodedata.normalize`." msgstr "" -#: ../../reference/expressions.rst:2398 +#: ../../reference/expressions.rst:2649 msgid "" "Due to automatic garbage-collection, free lists, and the dynamic nature of " "descriptors, you may notice seemingly unusual behaviour in certain uses of " @@ -2938,22 +3440,22 @@ msgid "" "instance methods, or constants. Check their documentation for more info." msgstr "" -#: ../../reference/expressions.rst:2403 +#: ../../reference/expressions.rst:2654 msgid "" "The power operator ``**`` binds less tightly than an arithmetic or bitwise " "unary operator on its right, that is, ``2**-1`` is ``0.5``." msgstr "" -#: ../../reference/expressions.rst:2406 +#: ../../reference/expressions.rst:2657 msgid "" "The ``%`` operator is also used for string formatting; the same precedence " "applies." msgstr "" -#: ../../reference/expressions.rst:8 ../../reference/expressions.rst:548 -#: ../../reference/expressions.rst:665 ../../reference/expressions.rst:2083 -#: ../../reference/expressions.rst:2123 ../../reference/expressions.rst:2174 -#: ../../reference/expressions.rst:2201 ../../reference/expressions.rst:2229 +#: ../../reference/expressions.rst:8 ../../reference/expressions.rst:956 +#: ../../reference/expressions.rst:1073 ../../reference/expressions.rst:2318 +#: ../../reference/expressions.rst:2358 ../../reference/expressions.rst:2409 +#: ../../reference/expressions.rst:2436 ../../reference/expressions.rst:2468 msgid "expression" msgstr "" @@ -2961,8 +3463,8 @@ msgstr "" msgid "BNF" msgstr "BNF" -#: ../../reference/expressions.rst:30 ../../reference/expressions.rst:1557 -#: ../../reference/expressions.rst:1605 +#: ../../reference/expressions.rst:30 ../../reference/expressions.rst:1792 +#: ../../reference/expressions.rst:1840 msgid "arithmetic" msgstr "" @@ -2974,730 +3476,724 @@ msgstr "conversion" msgid "atom" msgstr "" -#: ../../reference/expressions.rst:107 ../../reference/expressions.rst:121 +#: ../../reference/expressions.rst:125 ../../reference/expressions.rst:139 msgid "name" msgstr "name(名稱)" -#: ../../reference/expressions.rst:107 +#: ../../reference/expressions.rst:125 msgid "identifier" msgstr "" -#: ../../reference/expressions.rst:113 ../../reference/expressions.rst:786 -#: ../../reference/expressions.rst:841 ../../reference/expressions.rst:972 -#: ../../reference/expressions.rst:1027 ../../reference/expressions.rst:1074 -#: ../../reference/expressions.rst:1594 ../../reference/expressions.rst:1648 -#: ../../reference/expressions.rst:1757 +#: ../../reference/expressions.rst:131 ../../reference/expressions.rst:1309 +#: ../../reference/expressions.rst:1829 ../../reference/expressions.rst:1883 +#: ../../reference/expressions.rst:1992 msgid "exception" msgstr "" -#: ../../reference/expressions.rst:113 +#: ../../reference/expressions.rst:131 msgid "NameError" msgstr "" -#: ../../reference/expressions.rst:121 +#: ../../reference/expressions.rst:139 msgid "mangling" msgstr "" -#: ../../reference/expressions.rst:121 +#: ../../reference/expressions.rst:139 msgid "private" msgstr "" -#: ../../reference/expressions.rst:121 +#: ../../reference/expressions.rst:139 msgid "names" msgstr "" -#: ../../reference/expressions.rst:172 +#: ../../reference/expressions.rst:190 msgid "literal" msgstr "" -#: ../../reference/expressions.rst:205 ../../reference/expressions.rst:527 +#: ../../reference/expressions.rst:224 msgid "immutable" msgstr "" -#: ../../reference/expressions.rst:205 +#: ../../reference/expressions.rst:224 msgid "data" msgstr "data(資料)" -#: ../../reference/expressions.rst:205 +#: ../../reference/expressions.rst:224 msgid "type" msgstr "type(型別)" -#: ../../reference/expressions.rst:205 ../../reference/expressions.rst:430 -#: ../../reference/expressions.rst:456 ../../reference/expressions.rst:484 -#: ../../reference/expressions.rst:527 ../../reference/expressions.rst:548 -#: ../../reference/expressions.rst:774 ../../reference/expressions.rst:962 -#: ../../reference/expressions.rst:1074 ../../reference/expressions.rst:1103 -#: ../../reference/expressions.rst:1187 ../../reference/expressions.rst:1299 -#: ../../reference/expressions.rst:1447 ../../reference/expressions.rst:1461 -#: ../../reference/expressions.rst:1475 ../../reference/expressions.rst:1482 -#: ../../reference/expressions.rst:2048 ../../reference/expressions.rst:2241 +#: ../../reference/expressions.rst:224 ../../reference/expressions.rst:460 +#: ../../reference/expressions.rst:493 ../../reference/expressions.rst:589 +#: ../../reference/expressions.rst:956 ../../reference/expressions.rst:1309 +#: ../../reference/expressions.rst:1338 ../../reference/expressions.rst:1422 +#: ../../reference/expressions.rst:1534 ../../reference/expressions.rst:1682 +#: ../../reference/expressions.rst:1696 ../../reference/expressions.rst:1710 +#: ../../reference/expressions.rst:1717 ../../reference/expressions.rst:2283 +#: ../../reference/expressions.rst:2480 msgid "object" msgstr "object(物件)" -#: ../../reference/expressions.rst:317 +#: ../../reference/expressions.rst:331 msgid "parenthesized form" msgstr "" -#: ../../reference/expressions.rst:317 ../../reference/expressions.rst:548 -#: ../../reference/expressions.rst:1299 +#: ../../reference/expressions.rst:331 ../../reference/expressions.rst:956 +#: ../../reference/expressions.rst:1534 msgid "() (parentheses)" msgstr "() (圓括號)" -#: ../../reference/expressions.rst:317 -msgid "tuple display" -msgstr "" - -#: ../../reference/expressions.rst:330 ../../reference/expressions.rst:430 -msgid "empty" +#: ../../reference/expressions.rst:375 ../../reference/expressions.rst:460 +#: ../../reference/expressions.rst:493 ../../reference/expressions.rst:589 +#: ../../reference/expressions.rst:657 +msgid "comprehensions" msgstr "" -#: ../../reference/expressions.rst:330 ../../reference/expressions.rst:1103 -#: ../../reference/expressions.rst:1187 ../../reference/expressions.rst:2241 -msgid "tuple" -msgstr "" +#: ../../reference/expressions.rst:401 ../../reference/expressions.rst:2487 +msgid "trailing" +msgstr "trailing" -#: ../../reference/expressions.rst:336 ../../reference/expressions.rst:2263 +#: ../../reference/expressions.rst:401 ../../reference/expressions.rst:523 +#: ../../reference/expressions.rst:2459 ../../reference/expressions.rst:2487 msgid "comma" msgstr "" -#: ../../reference/expressions.rst:336 ../../reference/expressions.rst:430 -#: ../../reference/expressions.rst:456 ../../reference/expressions.rst:484 -#: ../../reference/expressions.rst:1181 ../../reference/expressions.rst:1299 -#: ../../reference/expressions.rst:2229 -msgid ", (comma)" -msgstr ", (逗號)" - -#: ../../reference/expressions.rst:351 ../../reference/expressions.rst:430 -#: ../../reference/expressions.rst:456 ../../reference/expressions.rst:484 -msgid "comprehensions" -msgstr "" - -#: ../../reference/expressions.rst:361 -msgid "for" -msgstr "for" - -#: ../../reference/expressions.rst:361 ../../reference/expressions.rst:396 -msgid "in comprehensions" -msgstr "於 comprehensions(綜合運算)" +#: ../../reference/expressions.rst:426 ../../reference/expressions.rst:2499 +msgid "iterable" +msgstr "iterable(可疊代)" -#: ../../reference/expressions.rst:361 ../../reference/expressions.rst:2174 -msgid "if" -msgstr "if" +#: ../../reference/expressions.rst:426 ../../reference/expressions.rst:624 +#: ../../reference/expressions.rst:1617 ../../reference/expressions.rst:2499 +msgid "unpacking" +msgstr "unpacking(解包)" -#: ../../reference/expressions.rst:361 -msgid "async for" -msgstr "async for" +#: ../../reference/expressions.rst:426 ../../reference/expressions.rst:1617 +#: ../../reference/expressions.rst:1853 ../../reference/expressions.rst:2499 +msgid "* (asterisk)" +msgstr "* (星號)" -#: ../../reference/expressions.rst:396 ../../reference/expressions.rst:1500 -msgid "await" -msgstr "await" +#: ../../reference/expressions.rst:426 ../../reference/expressions.rst:2499 +msgid "in expression lists" +msgstr "於 expression list(運算式串列)" -#: ../../reference/expressions.rst:430 ../../reference/expressions.rst:1074 -#: ../../reference/expressions.rst:1103 ../../reference/expressions.rst:1187 -#: ../../reference/expressions.rst:2229 +#: ../../reference/expressions.rst:460 ../../reference/expressions.rst:1309 +#: ../../reference/expressions.rst:1338 ../../reference/expressions.rst:1422 +#: ../../reference/expressions.rst:2468 msgid "list" msgstr "list(串列)" -#: ../../reference/expressions.rst:430 ../../reference/expressions.rst:456 -#: ../../reference/expressions.rst:484 +#: ../../reference/expressions.rst:460 ../../reference/expressions.rst:493 +#: ../../reference/expressions.rst:589 msgid "display" msgstr "" -#: ../../reference/expressions.rst:430 ../../reference/expressions.rst:1099 +#: ../../reference/expressions.rst:460 ../../reference/expressions.rst:530 +msgid "empty" +msgstr "" + +#: ../../reference/expressions.rst:460 ../../reference/expressions.rst:1334 msgid "[] (square brackets)" msgstr "[] (方括號)" -#: ../../reference/expressions.rst:430 +#: ../../reference/expressions.rst:460 msgid "list expression" msgstr "list expression(串列運算式)" -#: ../../reference/expressions.rst:430 ../../reference/expressions.rst:456 -#: ../../reference/expressions.rst:2229 +#: ../../reference/expressions.rst:460 ../../reference/expressions.rst:493 +#: ../../reference/expressions.rst:523 ../../reference/expressions.rst:589 +#: ../../reference/expressions.rst:1416 ../../reference/expressions.rst:1534 +#: ../../reference/expressions.rst:2459 ../../reference/expressions.rst:2468 +msgid ", (comma)" +msgstr ", (逗號)" + +#: ../../reference/expressions.rst:460 ../../reference/expressions.rst:493 +#: ../../reference/expressions.rst:2468 msgid "expression list" msgstr "expression list(運算式串列)" -#: ../../reference/expressions.rst:456 +#: ../../reference/expressions.rst:493 msgid "set" msgstr "set(集合)" -#: ../../reference/expressions.rst:456 ../../reference/expressions.rst:484 +#: ../../reference/expressions.rst:493 ../../reference/expressions.rst:589 msgid "{} (curly brackets)" msgstr "{} (花括號)" -#: ../../reference/expressions.rst:456 +#: ../../reference/expressions.rst:493 msgid "set expression" msgstr "set expression(集合運算式)" -#: ../../reference/expressions.rst:484 ../../reference/expressions.rst:510 -#: ../../reference/expressions.rst:1103 +#: ../../reference/expressions.rst:523 +msgid "tuple display" +msgstr "" + +#: ../../reference/expressions.rst:530 ../../reference/expressions.rst:1338 +#: ../../reference/expressions.rst:1422 ../../reference/expressions.rst:2480 +msgid "tuple" +msgstr "" + +#: ../../reference/expressions.rst:589 ../../reference/expressions.rst:624 +#: ../../reference/expressions.rst:1338 msgid "dictionary" msgstr "dictionary(字典)" -#: ../../reference/expressions.rst:484 +#: ../../reference/expressions.rst:589 msgid "key" msgstr "key(鍵)" -#: ../../reference/expressions.rst:484 +#: ../../reference/expressions.rst:589 msgid "value" msgstr "value(值)" -#: ../../reference/expressions.rst:484 +#: ../../reference/expressions.rst:589 msgid "key/value pair" msgstr "key/value pair(鍵/值對)" -#: ../../reference/expressions.rst:484 +#: ../../reference/expressions.rst:589 msgid "dictionary expression" msgstr "dictionary expression(字典運算式)" -#: ../../reference/expressions.rst:484 ../../reference/expressions.rst:1181 -#: ../../reference/expressions.rst:2201 +#: ../../reference/expressions.rst:589 ../../reference/expressions.rst:1416 +#: ../../reference/expressions.rst:2436 msgid ": (colon)" msgstr ": (冒號)" -#: ../../reference/expressions.rst:484 +#: ../../reference/expressions.rst:589 msgid "in dictionary expressions" msgstr "於字典運算式" -#: ../../reference/expressions.rst:484 ../../reference/expressions.rst:510 +#: ../../reference/expressions.rst:589 ../../reference/expressions.rst:624 msgid "in dictionary displays" msgstr "於字典顯示" -#: ../../reference/expressions.rst:510 ../../reference/expressions.rst:1382 -#: ../../reference/expressions.rst:2248 -msgid "unpacking" -msgstr "unpacking(解包)" - -#: ../../reference/expressions.rst:510 ../../reference/expressions.rst:1412 -#: ../../reference/expressions.rst:1520 +#: ../../reference/expressions.rst:624 ../../reference/expressions.rst:1647 +#: ../../reference/expressions.rst:1755 msgid "**" msgstr "**" -#: ../../reference/expressions.rst:527 -msgid "hashable" -msgstr "hashable(可雜湊)" +#: ../../reference/expressions.rst:657 +msgid "for" +msgstr "for" + +#: ../../reference/expressions.rst:657 ../../reference/expressions.rst:749 +#: ../../reference/expressions.rst:900 +msgid "in comprehensions" +msgstr "於 comprehensions(綜合運算)" + +#: ../../reference/expressions.rst:749 ../../reference/expressions.rst:2409 +msgid "if" +msgstr "if" + +#: ../../reference/expressions.rst:900 +msgid "async for" +msgstr "async for" + +#: ../../reference/expressions.rst:900 ../../reference/expressions.rst:1735 +msgid "await" +msgstr "await" -#: ../../reference/expressions.rst:548 ../../reference/expressions.rst:665 -#: ../../reference/expressions.rst:774 +#: ../../reference/expressions.rst:956 ../../reference/expressions.rst:1073 msgid "generator" msgstr "generator(產生器)" -#: ../../reference/expressions.rst:548 +#: ../../reference/expressions.rst:956 msgid "generator expression" msgstr "generator expression(產生器運算式)" -#: ../../reference/expressions.rst:665 ../../reference/expressions.rst:1500 +#: ../../reference/expressions.rst:1073 ../../reference/expressions.rst:1735 msgid "keyword" msgstr "keyword(關鍵字)" -#: ../../reference/expressions.rst:665 ../../reference/expressions.rst:863 +#: ../../reference/expressions.rst:1073 ../../reference/expressions.rst:1182 msgid "yield" msgstr "yield" -#: ../../reference/expressions.rst:665 ../../reference/expressions.rst:733 +#: ../../reference/expressions.rst:1073 ../../reference/expressions.rst:1141 msgid "from" msgstr "from" -#: ../../reference/expressions.rst:665 ../../reference/expressions.rst:1447 -#: ../../reference/expressions.rst:1461 ../../reference/expressions.rst:2201 +#: ../../reference/expressions.rst:1073 ../../reference/expressions.rst:1682 +#: ../../reference/expressions.rst:1696 ../../reference/expressions.rst:2436 msgid "function" msgstr "function (函式)" -#: ../../reference/expressions.rst:719 +#: ../../reference/expressions.rst:1127 msgid "coroutine" msgstr "coroutine(協程)" -#: ../../reference/expressions.rst:733 +#: ../../reference/expressions.rst:1141 msgid "yield from expression" msgstr "yield from expression(yield from 運算式)" -#: ../../reference/expressions.rst:786 -msgid "StopIteration" -msgstr "StopIteration" - -#: ../../reference/expressions.rst:841 ../../reference/expressions.rst:1027 -msgid "GeneratorExit" -msgstr "GeneratorExit" - -#: ../../reference/expressions.rst:863 +#: ../../reference/expressions.rst:1182 msgid "examples" msgstr "範例" -#: ../../reference/expressions.rst:962 -msgid "asynchronous-generator" -msgstr "asynchronous-generator(非同步產生器)" - -#: ../../reference/expressions.rst:972 -msgid "StopAsyncIteration" -msgstr "StopAsyncIteration" - -#: ../../reference/expressions.rst:1051 +#: ../../reference/expressions.rst:1286 msgid "primary" msgstr "primary(主要)" -#: ../../reference/expressions.rst:1065 +#: ../../reference/expressions.rst:1300 msgid "attribute" msgstr "attribute(屬性)" -#: ../../reference/expressions.rst:1065 +#: ../../reference/expressions.rst:1300 msgid "reference" msgstr "reference(參照)" -#: ../../reference/expressions.rst:1065 +#: ../../reference/expressions.rst:1300 msgid ". (dot)" msgstr ". (點)" -#: ../../reference/expressions.rst:1065 +#: ../../reference/expressions.rst:1300 msgid "attribute reference" msgstr "attribute reference(屬性參照)" -#: ../../reference/expressions.rst:1074 +#: ../../reference/expressions.rst:1309 msgid "AttributeError" msgstr "AttributeError" -#: ../../reference/expressions.rst:1074 +#: ../../reference/expressions.rst:1309 msgid "module" msgstr "module(模組)" -#: ../../reference/expressions.rst:1099 +#: ../../reference/expressions.rst:1334 msgid "subscription" msgstr "subscription(下標)" -#: ../../reference/expressions.rst:1103 ../../reference/expressions.rst:1187 -#: ../../reference/expressions.rst:2048 +#: ../../reference/expressions.rst:1338 ../../reference/expressions.rst:1422 +#: ../../reference/expressions.rst:2283 msgid "sequence" msgstr "sequence(序列)" -#: ../../reference/expressions.rst:1103 +#: ../../reference/expressions.rst:1338 msgid "mapping" msgstr "mapping(對映)" -#: ../../reference/expressions.rst:1103 ../../reference/expressions.rst:1187 +#: ../../reference/expressions.rst:1338 ../../reference/expressions.rst:1422 msgid "string" msgstr "string(字串)" -#: ../../reference/expressions.rst:1103 +#: ../../reference/expressions.rst:1338 msgid "item" msgstr "item(項目)" -#: ../../reference/expressions.rst:1181 +#: ../../reference/expressions.rst:1416 msgid "slicing" msgstr "slicing(切片)" -#: ../../reference/expressions.rst:1181 +#: ../../reference/expressions.rst:1416 msgid "slice" msgstr "slice(切片)" -#: ../../reference/expressions.rst:1299 +#: ../../reference/expressions.rst:1534 msgid "callable" msgstr "callable(可呼叫物件)" -#: ../../reference/expressions.rst:1299 ../../reference/expressions.rst:1447 -#: ../../reference/expressions.rst:1461 ../../reference/expressions.rst:1475 -#: ../../reference/expressions.rst:1482 ../../reference/expressions.rst:1492 +#: ../../reference/expressions.rst:1534 ../../reference/expressions.rst:1682 +#: ../../reference/expressions.rst:1696 ../../reference/expressions.rst:1710 +#: ../../reference/expressions.rst:1717 ../../reference/expressions.rst:1727 msgid "call" msgstr "call(呼叫)" -#: ../../reference/expressions.rst:1299 +#: ../../reference/expressions.rst:1534 msgid "argument" msgstr "argument(引數)" -#: ../../reference/expressions.rst:1299 ../../reference/expressions.rst:1332 +#: ../../reference/expressions.rst:1534 ../../reference/expressions.rst:1567 msgid "call semantics" msgstr "call semantics(呼叫語意)" -#: ../../reference/expressions.rst:1299 +#: ../../reference/expressions.rst:1534 msgid "argument list" msgstr "argument list(引數列表)" -#: ../../reference/expressions.rst:1299 +#: ../../reference/expressions.rst:1534 msgid "= (equals)" msgstr "= (等號)" -#: ../../reference/expressions.rst:1299 ../../reference/expressions.rst:1382 -#: ../../reference/expressions.rst:1412 +#: ../../reference/expressions.rst:1534 ../../reference/expressions.rst:1617 +#: ../../reference/expressions.rst:1647 msgid "in function calls" msgstr "於函式呼叫中" -#: ../../reference/expressions.rst:1332 +#: ../../reference/expressions.rst:1567 msgid "parameter" msgstr "parameter(參數)" -#: ../../reference/expressions.rst:1382 ../../reference/expressions.rst:1618 -#: ../../reference/expressions.rst:2248 -msgid "* (asterisk)" -msgstr "* (星號)" - -#: ../../reference/expressions.rst:1447 +#: ../../reference/expressions.rst:1682 msgid "user-defined" msgstr "user-defined(使用者定義)" -#: ../../reference/expressions.rst:1447 +#: ../../reference/expressions.rst:1682 msgid "user-defined function" msgstr "user-defined function(使用者定義函式)" -#: ../../reference/expressions.rst:1461 +#: ../../reference/expressions.rst:1696 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../reference/expressions.rst:1461 +#: ../../reference/expressions.rst:1696 msgid "method" msgstr "method(方法)" -#: ../../reference/expressions.rst:1461 +#: ../../reference/expressions.rst:1696 msgid "built-in method" msgstr "built-in method(內建方法)" -#: ../../reference/expressions.rst:1475 +#: ../../reference/expressions.rst:1710 msgid "class" msgstr "class(類別)" -#: ../../reference/expressions.rst:1475 +#: ../../reference/expressions.rst:1710 msgid "class object" msgstr "class object(類別物件)" -#: ../../reference/expressions.rst:1482 +#: ../../reference/expressions.rst:1717 msgid "class instance" msgstr "class instance(類別實例)" -#: ../../reference/expressions.rst:1482 ../../reference/expressions.rst:1492 +#: ../../reference/expressions.rst:1717 ../../reference/expressions.rst:1727 msgid "instance" msgstr "instance(實例)" -#: ../../reference/expressions.rst:1492 +#: ../../reference/expressions.rst:1727 msgid "__call__() (object method)" msgstr "__call__() (物件方法)" -#: ../../reference/expressions.rst:1520 +#: ../../reference/expressions.rst:1755 msgid "power" msgstr "power(次方)" -#: ../../reference/expressions.rst:1520 ../../reference/expressions.rst:1557 -#: ../../reference/expressions.rst:1605 ../../reference/expressions.rst:1739 -#: ../../reference/expressions.rst:1768 ../../reference/expressions.rst:2083 +#: ../../reference/expressions.rst:1755 ../../reference/expressions.rst:1792 +#: ../../reference/expressions.rst:1840 ../../reference/expressions.rst:1974 +#: ../../reference/expressions.rst:2003 ../../reference/expressions.rst:2318 msgid "operation" msgstr "operation(操作)" -#: ../../reference/expressions.rst:1520 ../../reference/expressions.rst:1566 -#: ../../reference/expressions.rst:1575 ../../reference/expressions.rst:1583 -#: ../../reference/expressions.rst:1618 ../../reference/expressions.rst:1636 -#: ../../reference/expressions.rst:1648 ../../reference/expressions.rst:1667 -#: ../../reference/expressions.rst:1698 ../../reference/expressions.rst:1717 -#: ../../reference/expressions.rst:1739 ../../reference/expressions.rst:1777 -#: ../../reference/expressions.rst:1785 ../../reference/expressions.rst:1794 -#: ../../reference/expressions.rst:1809 ../../reference/expressions.rst:2048 -#: ../../reference/expressions.rst:2057 ../../reference/expressions.rst:2099 -#: ../../reference/expressions.rst:2104 ../../reference/expressions.rst:2109 -#: ../../reference/expressions.rst:2174 ../../reference/expressions.rst:2299 +#: ../../reference/expressions.rst:1755 ../../reference/expressions.rst:1801 +#: ../../reference/expressions.rst:1810 ../../reference/expressions.rst:1818 +#: ../../reference/expressions.rst:1853 ../../reference/expressions.rst:1871 +#: ../../reference/expressions.rst:1883 ../../reference/expressions.rst:1902 +#: ../../reference/expressions.rst:1933 ../../reference/expressions.rst:1952 +#: ../../reference/expressions.rst:1974 ../../reference/expressions.rst:2012 +#: ../../reference/expressions.rst:2020 ../../reference/expressions.rst:2029 +#: ../../reference/expressions.rst:2044 ../../reference/expressions.rst:2283 +#: ../../reference/expressions.rst:2292 ../../reference/expressions.rst:2334 +#: ../../reference/expressions.rst:2339 ../../reference/expressions.rst:2344 +#: ../../reference/expressions.rst:2409 ../../reference/expressions.rst:2550 msgid "operator" msgstr "operator(運算子)" -#: ../../reference/expressions.rst:1557 +#: ../../reference/expressions.rst:1792 msgid "unary" msgstr "unary(一元)" -#: ../../reference/expressions.rst:1557 ../../reference/expressions.rst:1768 -#: ../../reference/expressions.rst:1777 ../../reference/expressions.rst:1785 -#: ../../reference/expressions.rst:1794 +#: ../../reference/expressions.rst:1792 ../../reference/expressions.rst:2003 +#: ../../reference/expressions.rst:2012 ../../reference/expressions.rst:2020 +#: ../../reference/expressions.rst:2029 msgid "bitwise" msgstr "bitwise(位元)" -#: ../../reference/expressions.rst:1566 +#: ../../reference/expressions.rst:1801 msgid "negation" msgstr "negation(否定)" -#: ../../reference/expressions.rst:1566 +#: ../../reference/expressions.rst:1801 msgid "minus" msgstr "minus(減)" -#: ../../reference/expressions.rst:1566 ../../reference/expressions.rst:1717 +#: ../../reference/expressions.rst:1801 ../../reference/expressions.rst:1952 msgid "- (minus)" msgstr "- (減號)" -#: ../../reference/expressions.rst:1566 ../../reference/expressions.rst:1575 +#: ../../reference/expressions.rst:1801 ../../reference/expressions.rst:1810 msgid "unary operator" msgstr "unary operator(一元運算子)" -#: ../../reference/expressions.rst:1575 +#: ../../reference/expressions.rst:1810 msgid "plus" msgstr "plus(加)" -#: ../../reference/expressions.rst:1575 ../../reference/expressions.rst:1698 +#: ../../reference/expressions.rst:1810 ../../reference/expressions.rst:1933 msgid "+ (plus)" msgstr "+ (加號)" -#: ../../reference/expressions.rst:1583 +#: ../../reference/expressions.rst:1818 msgid "inversion" msgstr "inversion(反轉)" -#: ../../reference/expressions.rst:1583 +#: ../../reference/expressions.rst:1818 msgid "~ (tilde)" msgstr "~ (波浪號)" -#: ../../reference/expressions.rst:1594 +#: ../../reference/expressions.rst:1829 msgid "TypeError" msgstr "TypeError" -#: ../../reference/expressions.rst:1605 ../../reference/expressions.rst:1768 +#: ../../reference/expressions.rst:1840 ../../reference/expressions.rst:2003 msgid "binary" msgstr "binary(二進位)" -#: ../../reference/expressions.rst:1618 +#: ../../reference/expressions.rst:1853 msgid "multiplication" msgstr "multiplication(乘)" -#: ../../reference/expressions.rst:1636 +#: ../../reference/expressions.rst:1871 msgid "matrix multiplication" msgstr "matrix multiplication(矩陣乘法)" -#: ../../reference/expressions.rst:1636 +#: ../../reference/expressions.rst:1871 msgid "@ (at)" msgstr "@ (在)" -#: ../../reference/expressions.rst:1648 +#: ../../reference/expressions.rst:1883 msgid "ZeroDivisionError" msgstr "ZeroDivisionError" -#: ../../reference/expressions.rst:1648 +#: ../../reference/expressions.rst:1883 msgid "division" msgstr "division(除)" -#: ../../reference/expressions.rst:1648 +#: ../../reference/expressions.rst:1883 msgid "/ (slash)" msgstr "/ (斜線)" -#: ../../reference/expressions.rst:1648 +#: ../../reference/expressions.rst:1883 msgid "//" msgstr "//" -#: ../../reference/expressions.rst:1667 +#: ../../reference/expressions.rst:1902 msgid "modulo" msgstr "modulo(餘數)" -#: ../../reference/expressions.rst:1667 +#: ../../reference/expressions.rst:1902 msgid "% (percent)" msgstr "% (百分號)" -#: ../../reference/expressions.rst:1698 +#: ../../reference/expressions.rst:1933 msgid "addition" msgstr "addition(加)" -#: ../../reference/expressions.rst:1698 ../../reference/expressions.rst:1717 +#: ../../reference/expressions.rst:1933 ../../reference/expressions.rst:1952 msgid "binary operator" msgstr "binary operator(二元運算子)" -#: ../../reference/expressions.rst:1717 +#: ../../reference/expressions.rst:1952 msgid "subtraction" msgstr "subtraction(減)" -#: ../../reference/expressions.rst:1739 +#: ../../reference/expressions.rst:1974 msgid "shifting" msgstr "shifting(移動)" -#: ../../reference/expressions.rst:1739 +#: ../../reference/expressions.rst:1974 msgid "<<" msgstr "<<" -#: ../../reference/expressions.rst:1739 +#: ../../reference/expressions.rst:1974 msgid ">>" msgstr ">>" -#: ../../reference/expressions.rst:1757 +#: ../../reference/expressions.rst:1992 msgid "ValueError" msgstr "ValueError" -#: ../../reference/expressions.rst:1777 ../../reference/expressions.rst:2104 +#: ../../reference/expressions.rst:2012 ../../reference/expressions.rst:2339 msgid "and" msgstr "and" -#: ../../reference/expressions.rst:1777 +#: ../../reference/expressions.rst:2012 msgid "& (ampersand)" msgstr "& (和號)" -#: ../../reference/expressions.rst:1785 +#: ../../reference/expressions.rst:2020 msgid "xor" msgstr "xor" -#: ../../reference/expressions.rst:1785 +#: ../../reference/expressions.rst:2020 msgid "exclusive" msgstr "exclusive(排外)" -#: ../../reference/expressions.rst:1785 ../../reference/expressions.rst:1794 -#: ../../reference/expressions.rst:2109 +#: ../../reference/expressions.rst:2020 ../../reference/expressions.rst:2029 +#: ../../reference/expressions.rst:2344 msgid "or" msgstr "or" -#: ../../reference/expressions.rst:1785 +#: ../../reference/expressions.rst:2020 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../reference/expressions.rst:1794 +#: ../../reference/expressions.rst:2029 msgid "inclusive" msgstr "inclusive(包含)" -#: ../../reference/expressions.rst:1794 +#: ../../reference/expressions.rst:2029 msgid "| (vertical bar)" msgstr "| (垂直線)" -#: ../../reference/expressions.rst:1809 +#: ../../reference/expressions.rst:2044 msgid "comparison" msgstr "comparison(比較)" -#: ../../reference/expressions.rst:1809 +#: ../../reference/expressions.rst:2044 msgid "C" msgstr "C" -#: ../../reference/expressions.rst:1809 +#: ../../reference/expressions.rst:2044 msgid "language" msgstr "language(語言)" -#: ../../reference/expressions.rst:1809 +#: ../../reference/expressions.rst:2044 msgid "< (less)" msgstr "< (小於)" -#: ../../reference/expressions.rst:1809 +#: ../../reference/expressions.rst:2044 msgid "> (greater)" msgstr "> (大於)" -#: ../../reference/expressions.rst:1809 +#: ../../reference/expressions.rst:2044 msgid "<=" msgstr "<=" -#: ../../reference/expressions.rst:1809 +#: ../../reference/expressions.rst:2044 msgid ">=" msgstr ">=" -#: ../../reference/expressions.rst:1809 +#: ../../reference/expressions.rst:2044 msgid "==" msgstr "==" -#: ../../reference/expressions.rst:1809 +#: ../../reference/expressions.rst:2044 msgid "!=" msgstr "!=" -#: ../../reference/expressions.rst:1833 +#: ../../reference/expressions.rst:2068 msgid "chaining" msgstr "chaining(鏈接)" -#: ../../reference/expressions.rst:1833 +#: ../../reference/expressions.rst:2068 msgid "comparisons" msgstr "comparisons(比較)" -#: ../../reference/expressions.rst:2048 +#: ../../reference/expressions.rst:2283 msgid "in" msgstr "in" -#: ../../reference/expressions.rst:2048 +#: ../../reference/expressions.rst:2283 msgid "not in" msgstr "not in" -#: ../../reference/expressions.rst:2048 +#: ../../reference/expressions.rst:2283 msgid "membership" msgstr "membership(成員)" -#: ../../reference/expressions.rst:2048 ../../reference/expressions.rst:2057 +#: ../../reference/expressions.rst:2283 ../../reference/expressions.rst:2292 msgid "test" msgstr "test(測試)" -#: ../../reference/expressions.rst:2057 +#: ../../reference/expressions.rst:2292 msgid "is" msgstr "is" -#: ../../reference/expressions.rst:2057 +#: ../../reference/expressions.rst:2292 msgid "is not" msgstr "is not" -#: ../../reference/expressions.rst:2057 +#: ../../reference/expressions.rst:2292 msgid "identity" msgstr "identity" -#: ../../reference/expressions.rst:2083 +#: ../../reference/expressions.rst:2318 msgid "Conditional" msgstr "Conditional(條件式)" -#: ../../reference/expressions.rst:2083 +#: ../../reference/expressions.rst:2318 msgid "Boolean" msgstr "Boolean(布林)" -#: ../../reference/expressions.rst:2099 +#: ../../reference/expressions.rst:2334 msgid "not" msgstr "not" -#: ../../reference/expressions.rst:2123 +#: ../../reference/expressions.rst:2358 msgid ":= (colon equals)" msgstr ":= (冒號等於)" -#: ../../reference/expressions.rst:2123 +#: ../../reference/expressions.rst:2358 msgid "assignment expression" msgstr "assignment expression(賦值運算式)" -#: ../../reference/expressions.rst:2123 +#: ../../reference/expressions.rst:2358 msgid "walrus operator" msgstr "walrus operator(海象運算子)" -#: ../../reference/expressions.rst:2123 +#: ../../reference/expressions.rst:2358 msgid "named expression" msgstr "named expression(附名運算式)" -#: ../../reference/expressions.rst:2123 +#: ../../reference/expressions.rst:2358 msgid "assignment" msgstr "assignment(賦值)" -#: ../../reference/expressions.rst:2174 +#: ../../reference/expressions.rst:2409 msgid "conditional" msgstr "conditional(條件式)" -#: ../../reference/expressions.rst:2174 +#: ../../reference/expressions.rst:2409 msgid "ternary" msgstr "ternary(三元)" -#: ../../reference/expressions.rst:2174 +#: ../../reference/expressions.rst:2409 msgid "conditional expression" msgstr "conditional expression(條件運算式)" -#: ../../reference/expressions.rst:2174 +#: ../../reference/expressions.rst:2409 msgid "else" msgstr "else" -#: ../../reference/expressions.rst:2201 +#: ../../reference/expressions.rst:2436 msgid "lambda" msgstr "lambda" -#: ../../reference/expressions.rst:2201 +#: ../../reference/expressions.rst:2436 msgid "form" msgstr "form" -#: ../../reference/expressions.rst:2201 +#: ../../reference/expressions.rst:2436 msgid "anonymous" msgstr "anonymous(匿名)" -#: ../../reference/expressions.rst:2201 +#: ../../reference/expressions.rst:2436 msgid "lambda expression" msgstr "lambda expression(lambda 運算式)" -#: ../../reference/expressions.rst:2248 -msgid "iterable" -msgstr "iterable(可疊代)" - -#: ../../reference/expressions.rst:2248 -msgid "in expression lists" -msgstr "於 expression list(運算式串列)" - -#: ../../reference/expressions.rst:2263 -msgid "trailing" -msgstr "trailing" - -#: ../../reference/expressions.rst:2278 +#: ../../reference/expressions.rst:2528 msgid "evaluation" msgstr "evaluation" -#: ../../reference/expressions.rst:2278 +#: ../../reference/expressions.rst:2528 msgid "order" msgstr "order(順序)" -#: ../../reference/expressions.rst:2299 +#: ../../reference/expressions.rst:2550 msgid "precedence" msgstr "precedence(優先順序)" +#~ msgid "hashable" +#~ msgstr "hashable(可雜湊)" + +#~ msgid "StopIteration" +#~ msgstr "StopIteration" + +#~ msgid "GeneratorExit" +#~ msgstr "GeneratorExit" + +#~ msgid "asynchronous-generator" +#~ msgstr "asynchronous-generator(非同步產生器)" + +#~ msgid "StopAsyncIteration" +#~ msgstr "StopAsyncIteration" + #~ msgid "character" #~ msgstr "character(字元)" diff --git a/reference/grammar.po b/reference/grammar.po index b7881f2f9b5..a531b1391f1 100644 --- a/reference/grammar.po +++ b/reference/grammar.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-26 00:19+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2017-09-22 18:27+0000\n" "Last-Translator: Leon H.\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -205,9 +205,9 @@ msgid "" "simple_stmt[stmt_ty] (memo):\n" " | assignment\n" " | &\"type\" type_alias\n" +" | &('import' | 'from' | \"lazy\") import_stmt\n" " | e=star_expressions { _PyAST_Expr(e, EXTRA) }\n" " | &'return' return_stmt\n" -" | &('import' | 'from') import_stmt\n" " | &'raise' raise_stmt\n" " | &'pass' pass_stmt\n" " | &'del' del_stmt\n" @@ -276,8 +276,10 @@ msgid "" " | 'return' a=[star_expressions] { _PyAST_Return(a, EXTRA) }\n" "\n" "raise_stmt[stmt_ty]:\n" -" | 'raise' a=expression b=['from' z=expression { z }] { _PyAST_Raise(a, " -"b, EXTRA) }\n" +" | 'raise' a=expression 'from' b=expression { _PyAST_Raise(a, b, " +"EXTRA) }\n" +" | invalid_raise_stmt\n" +" | 'raise' a=expression { _PyAST_Raise(a, NULL, EXTRA) }\n" " | 'raise' { _PyAST_Raise(NULL, NULL, EXTRA) }\n" "\n" "pass_stmt[stmt_ty]:\n" @@ -303,10 +305,12 @@ msgid "" "\n" "yield_stmt[stmt_ty]: y=yield_expr { _PyAST_Expr(y, EXTRA) }\n" "\n" -"assert_stmt[stmt_ty]: 'assert' a=expression b=[',' z=expression { z }] " -"{ _PyAST_Assert(a, b, EXTRA) }\n" +"assert_stmt[stmt_ty]:\n" +" | invalid_assert_stmt\n" +" | 'assert' a=expression b=[',' z=expression { z }] { _PyAST_Assert(a, b, " +"EXTRA) }\n" "\n" -"import_stmt[stmt_ty]:\n" +"import_stmt[stmt_ty](memo):\n" " | invalid_import\n" " | import_name\n" " | import_from\n" @@ -314,17 +318,21 @@ msgid "" "# Import statements\n" "# -----------------\n" "\n" -"import_name[stmt_ty]: 'import' a=dotted_as_names { _PyAST_Import(a, " -"EXTRA) }\n" +"import_name[stmt_ty]:\n" +" | lazy=\"lazy\"? 'import' a=dotted_as_names { _PyAST_Import(a, lazy ? " +"1 : 0, EXTRA) }\n" +"\n" "# note below: the ('.' | '...') is necessary because '...' is tokenized as " "ELLIPSIS\n" "import_from[stmt_ty]:\n" -" | 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets " +" | invalid_import_from\n" +" | lazy=\"lazy\"? 'from' a=('.' | '...')* b=dotted_name 'import' " +"c=import_from_targets {\n" +" _PyPegen_checked_from_import(p, a, b, c, lazy, EXTRA) }\n" +" | lazy=\"lazy\"? 'from' a=('.' | '...')+ 'import' b=import_from_targets " "{\n" -" _PyPegen_checked_future_import(p, b->v.Name.id, c, " -"_PyPegen_seq_count_dots(a), EXTRA) }\n" -" | 'from' a=('.' | '...')+ 'import' b=import_from_targets {\n" -" _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), EXTRA) }\n" +" _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), lazy ? 1 : 0, " +"EXTRA) }\n" "import_from_targets[asdl_alias_seq*]:\n" " | '(' a=import_from_as_names [','] ')' { a }\n" " | import_from_as_names !','\n" @@ -695,10 +703,12 @@ msgid "" "\n" "signed_number[expr_ty]:\n" " | NUMBER\n" +" | '+' number=NUMBER { _PyAST_UnaryOp(UAdd, number, EXTRA) }\n" " | '-' number=NUMBER { _PyAST_UnaryOp(USub, number, EXTRA) }\n" "\n" "signed_real_number[expr_ty]:\n" " | real_number\n" +" | '+' real=real_number { _PyAST_UnaryOp(UAdd, real, EXTRA) }\n" " | '-' real=real_number { _PyAST_UnaryOp(USub, real, EXTRA) }\n" "\n" "real_number[expr_ty]:\n" @@ -772,6 +782,7 @@ msgid "" " CHECK(asdl_pattern_seq*, _PyPegen_get_patterns(p, items)),\n" " NULL,\n" " EXTRA) }\n" +" | invalid_mapping_pattern\n" "\n" "items_pattern[asdl_seq*]:\n" " | ','.key_value_pattern+\n" @@ -866,13 +877,17 @@ msgid "" " | expression\n" "\n" "expression[expr_ty] (memo):\n" +" | invalid_if_expression\n" " | invalid_expression\n" " | invalid_legacy_expression\n" -" | a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, " -"a, c, EXTRA) }\n" +" | if_expression\n" " | disjunction\n" " | lambdef\n" "\n" +"if_expression[expr_ty]:\n" +" | a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, " +"a, c, EXTRA) }\n" +"\n" "yield_expr[expr_ty]:\n" " | 'yield' 'from' a=expression { _PyAST_YieldFrom(a, EXTRA) }\n" " | 'yield' a=[star_expressions] { _PyAST_Yield(a, EXTRA) }\n" @@ -892,10 +907,17 @@ msgid "" "star_named_expressions[asdl_expr_seq*]: a[asdl_expr_seq*]=','." "star_named_expression+ [','] { a }\n" "\n" +"star_named_expressions_sequence[asdl_expr_seq*]: a[asdl_expr_seq*]=','." +"star_named_expression_sequence+ [','] { a }\n" +"\n" "star_named_expression[expr_ty]:\n" " | '*' a=bitwise_or { _PyAST_Starred(a, Load, EXTRA) }\n" " | named_expression\n" "\n" +"star_named_expression_sequence[expr_ty]:\n" +" | invalid_starred_expression_unpacking_sequence\n" +" | star_named_expression\n" +"\n" "assignment_expression[expr_ty]:\n" " | a=NAME ':=' ~ b=expression {\n" " CHECK_VERSION(expr_ty, 8, \"Assignment expressions are\",\n" @@ -1062,9 +1084,9 @@ msgid "" " | 'None' { _PyAST_Constant(Py_None, NULL, EXTRA) }\n" " | &(STRING|FSTRING_START|TSTRING_START) strings\n" " | NUMBER\n" -" | &'(' (tuple | group | genexp)\n" -" | &'[' (list | listcomp)\n" -" | &'{' (dict | set | dictcomp | setcomp)\n" +" | &'(' (genexp | tuple | group)\n" +" | &'[' (listcomp | list)\n" +" | &'{' (dictcomp | setcomp | dict | set)\n" " | '...' { _PyAST_Constant(Py_Ellipsis, NULL, EXTRA) }\n" "\n" "group[expr_ty]:\n" @@ -1208,14 +1230,17 @@ msgid "" "EXTRA) }\n" "\n" "list[expr_ty]:\n" -" | '[' a=[star_named_expressions] ']' { _PyAST_List(a, Load, EXTRA) }\n" +" | '[' a=[star_named_expressions_sequence] ']' { _PyAST_List(a, Load, " +"EXTRA) }\n" "\n" "tuple[expr_ty]:\n" -" | '(' a=[y=star_named_expression ',' z=[star_named_expressions] " -"{ _PyPegen_seq_insert_in_front(p, y, z) } ] ')' {\n" +" | '(' a=[y=star_named_expression_sequence ',' " +"z=[star_named_expressions_sequence] { _PyPegen_seq_insert_in_front(p, y, " +"z) } ] ')' {\n" " _PyAST_Tuple(a, Load, EXTRA) }\n" "\n" -"set[expr_ty]: '{' a=star_named_expressions '}' { _PyAST_Set(a, EXTRA) }\n" +"set[expr_ty]: '{' a=star_named_expressions_sequence '}' { _PyAST_Set(a, " +"EXTRA) }\n" "\n" "# Dicts\n" "# -----\n" @@ -1255,24 +1280,26 @@ msgid "" " | invalid_for_target\n" "\n" "listcomp[expr_ty]:\n" -" | '[' a=named_expression b=for_if_clauses ']' { _PyAST_ListComp(a, b, " -"EXTRA) }\n" +" | '[' a=star_named_expression b=for_if_clauses ']' { _PyAST_ListComp(a, " +"b, EXTRA) }\n" " | invalid_comprehension\n" "\n" "setcomp[expr_ty]:\n" -" | '{' a=named_expression b=for_if_clauses '}' { _PyAST_SetComp(a, b, " -"EXTRA) }\n" +" | '{' a=star_named_expression b=for_if_clauses '}' { _PyAST_SetComp(a, " +"b, EXTRA) }\n" " | invalid_comprehension\n" "\n" "genexp[expr_ty]:\n" -" | '(' a=( assignment_expression | expression !':=') b=for_if_clauses " -"')' { _PyAST_GeneratorExp(a, b, EXTRA) }\n" +" | '(' a=( assignment_expression | expression !':=' | " +"starred_expression ) b=for_if_clauses ')' { _PyAST_GeneratorExp(a, b, " +"EXTRA) }\n" " | invalid_comprehension\n" "\n" "dictcomp[expr_ty]:\n" " | '{' a=kvpair b=for_if_clauses '}' { _PyAST_DictComp(a->key, a->value, " "b, EXTRA) }\n" -" | invalid_dict_comprehension\n" +" | '{' '**' a=expression b=for_if_clauses '}' { _PyAST_DictComp(a, NULL, " +"b, EXTRA) }\n" "\n" "# FUNCTION CALL ARGUMENTS\n" "# =======================\n" @@ -1516,10 +1543,7 @@ msgid "" "NAME NAME\n" " | !(NAME STRING | SOFT_KEYWORD) a=disjunction " "b=expression_without_invalid {\n" -" _PyPegen_check_legacy_stmt(p, a) ? NULL : p->tokens[p->mark-1]-" -">level == 0 ? NULL :\n" -" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"invalid syntax. Perhaps you " -"forgot a comma?\") }\n" +" _PyPegen_raise_error_for_missing_comma(p, a, b) }\n" " | a=disjunction 'if' b=disjunction !('else'|':') " "{ RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"expected 'else' after 'if' " "expression\") }\n" @@ -1537,6 +1561,14 @@ msgid "" " RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"t-string: lambda expressions " "are not allowed without parentheses\") }\n" "\n" +"invalid_if_expression:\n" +" | disjunction 'if' b=disjunction 'else' a='*' {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"cannot unpack only part of a " +"conditional expression\") }\n" +" | disjunction 'if' b=disjunction 'else' a='**' {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"cannot use dict unpacking on " +"only part of a conditional expression\") }\n" +"\n" "invalid_named_expression(memo):\n" " | a=expression ':=' expression {\n" " RAISE_SYNTAX_ERROR_KNOWN_LOCATION(\n" @@ -1579,16 +1611,47 @@ msgid "" " | list\n" " | tuple\n" " | '(' a=invalid_ann_assign_target ')' { a }\n" +"invalid_raise_stmt:\n" +" | a='raise' b='from' {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"did you forget an expression " +"between 'raise' and 'from'?\") }\n" +" | 'raise' expression a='from' {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"did you forget an expression " +"after 'from'?\") }\n" "invalid_del_stmt:\n" " | 'del' a=star_expressions {\n" " RAISE_SYNTAX_ERROR_INVALID_TARGET(DEL_TARGETS, a) }\n" +"invalid_assert_stmt:\n" +" | 'assert' a=expression '=' b=expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"cannot assign to %s here. Maybe you meant '==' instead of '='?" +"\",\n" +" _PyPegen_get_expr_name(a)) }\n" +" | 'assert' expression ',' a=expression '=' b=expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"cannot assign to %s here. Maybe you meant '==' instead of '='?" +"\",\n" +" _PyPegen_get_expr_name(a)) }\n" +" | 'assert' a=expression ':=' b=expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"cannot use named expression without parentheses here\") }\n" +" | 'assert' expression ',' a=expression ':=' b=expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"cannot use named expression without parentheses here\") }\n" "invalid_block:\n" " | NEWLINE !INDENT { RAISE_INDENTATION_ERROR(\"expected an indented " "block\") }\n" "invalid_comprehension:\n" -" | ('[' | '(' | '{') a=starred_expression for_if_clauses {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"iterable unpacking cannot be " -"used in comprehension\") }\n" +" | '[' a='**' b=expression for_if_clauses {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"cannot use dict unpacking in " +"list comprehension\") }\n" +" | '(' a='**' b=expression for_if_clauses {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"cannot use dict unpacking in " +"generator expression\") }\n" " | ('[' | '{') a=star_named_expression ',' b=star_named_expressions " "for_if_clauses {\n" " RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, PyPegen_last_item(b, expr_ty),\n" @@ -1596,13 +1659,9 @@ msgid "" " | ('[' | '{') a=star_named_expression b=',' for_if_clauses {\n" " RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"did you forget parentheses " "around the comprehension target?\") }\n" -"invalid_dict_comprehension:\n" -" | '{' a='**' bitwise_or for_if_clauses '}' {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"dict unpacking cannot be used " -"in dict comprehension\") }\n" "invalid_parameters:\n" " | a=\"/\" ',' {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"at least one argument must " +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"at least one parameter must " "precede /\") }\n" " | (slash_no_default | slash_with_default) param_maybe_default* a='/' {\n" " RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"/ may appear only once\") }\n" @@ -1624,29 +1683,28 @@ msgid "" "default value expression\") }\n" "invalid_star_etc:\n" " | a='*' (')' | ',' (')' | '**')) { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, " -"\"named arguments must follow bare *\") }\n" +"\"named parameters must follow bare *\") }\n" " | '*' ',' TYPE_COMMENT { RAISE_SYNTAX_ERROR(\"bare * has associated type " "comment\") }\n" " | '*' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"var-" -"positional argument cannot have default value\") }\n" +"positional parameter cannot have default value\") }\n" " | '*' (param_no_default | ',') param_maybe_default* " "a='*' (param_no_default | ',') {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"* argument may appear only " -"once\") }\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"* may appear only once\") }\n" "invalid_kwds:\n" " | '**' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"var-keyword " -"argument cannot have default value\") }\n" +"parameter cannot have default value\") }\n" " | '**' param ',' a=param { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, " -"\"arguments cannot follow var-keyword argument\") }\n" +"\"parameters cannot follow var-keyword parameter\") }\n" " | '**' param ',' a[Token*]=('*'|'**'|'/') " -"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"arguments cannot follow var-keyword " -"argument\") }\n" +"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"parameters cannot follow var-" +"keyword parameter\") }\n" "invalid_parameters_helper: # This is only there to avoid type errors\n" " | a=slash_with_default { _PyPegen_singleton_seq(p, a) }\n" " | param_with_default+\n" "invalid_lambda_parameters:\n" " | a=\"/\" ',' {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"at least one argument must " +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"at least one parameter must " "precede /\") }\n" " | (lambda_slash_no_default | lambda_slash_with_default) " "lambda_param_maybe_default* a='/' {\n" @@ -1669,23 +1727,22 @@ msgid "" " | a=lambda_slash_with_default { _PyPegen_singleton_seq(p, a) }\n" " | lambda_param_with_default+\n" "invalid_lambda_star_etc:\n" -" | '*' (':' | ',' (':' | '**')) { RAISE_SYNTAX_ERROR(\"named arguments " +" | '*' (':' | ',' (':' | '**')) { RAISE_SYNTAX_ERROR(\"named parameters " "must follow bare *\") }\n" " | '*' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"var-" -"positional argument cannot have default value\") }\n" +"positional parameter cannot have default value\") }\n" " | '*' (lambda_param_no_default | ',') lambda_param_maybe_default* " "a='*' (lambda_param_no_default | ',') {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"* argument may appear only " -"once\") }\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"* may appear only once\") }\n" "invalid_lambda_kwds:\n" " | '**' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"var-" -"keyword argument cannot have default value\") }\n" +"keyword parameter cannot have default value\") }\n" " | '**' lambda_param ',' a=lambda_param " -"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"arguments cannot follow var-keyword " -"argument\") }\n" +"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"parameters cannot follow var-" +"keyword parameter\") }\n" " | '**' lambda_param ',' a[Token*]=('*'|'**'|'/') " -"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"arguments cannot follow var-keyword " -"argument\") }\n" +"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"parameters cannot follow var-" +"keyword parameter\") }\n" "invalid_double_type_comments:\n" " | TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT {\n" " RAISE_SYNTAX_ERROR(\"Cannot have two type comments on def\") }\n" @@ -1726,6 +1783,12 @@ msgid "" " \"cannot use %s as import target\", " "_PyPegen_get_expr_name(a)) }\n" "\n" +"invalid_import_from:\n" +" | 'from' ('.' | '...')* dotted_name a=\"lazy\" 'import' " +"import_from_targets {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,\n" +" \"use 'lazy from ... ' instead of 'from ... lazy import'\") }\n" +"\n" "invalid_import_from_targets:\n" " | import_from_as_names ',' NEWLINE {\n" " RAISE_SYNTAX_ERROR(\"trailing comma not allowed without surrounding " @@ -1735,6 +1798,10 @@ msgid "" "after 'import'\") }\n" "\n" "invalid_with_stmt:\n" +" | ['async'] 'with' ','.(expression ['as' star_target])+ trailing=',' " +"':' {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(trailing, \"the last 'with' item " +"has a trailing comma\") }\n" " | ['async'] 'with' ','.(expression ['as' star_target])+ NEWLINE " "{ RAISE_SYNTAX_ERROR(\"expected ':'\") }\n" " | ['async'] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' " @@ -1806,6 +1873,10 @@ msgid "" " | a=\"match\" subject=subject_expr ':' NEWLINE !INDENT {\n" " RAISE_INDENTATION_ERROR(\"expected an indented block after 'match' " "statement on line %d\", a->lineno) }\n" +" | a=\"case\" patterns guard? b=':' block {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"case statement must be inside match statement\") }\n" "invalid_case_block:\n" " | \"case\" patterns guard? NEWLINE { RAISE_SYNTAX_ERROR(\"expected " "':'\") }\n" @@ -1825,6 +1896,12 @@ msgid "" " PyPegen_first_item(a, pattern_ty),\n" " PyPegen_last_item(a, pattern_ty),\n" " \"positional patterns follow keyword patterns\") }\n" +"invalid_mapping_pattern:\n" +" | '{' (items_pattern ',')? rest=double_star_pattern ',' items_pattern " +"','? '}' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(\n" +" rest,\n" +" \"double star pattern must be the last (right-most) subpattern in " +"the mapping pattern\") }\n" "invalid_class_argument_pattern[asdl_pattern_seq*]:\n" " | [positional_patterns ','] keyword_patterns ',' a=positional_patterns " "{ a }\n" @@ -1875,11 +1952,24 @@ msgid "" "definition on line %d\", a->lineno) }\n" "\n" "invalid_double_starred_kvpairs:\n" -" | ','.double_starred_kvpair+ ',' invalid_kvpair\n" -" | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, " -"\"cannot use a starred expression in a dictionary value\") }\n" +" | invalid_kvpair_unpacking [',']\n" +" | ','.double_starred_kvpair+ ',' (invalid_kvpair | " +"invalid_kvpair_unpacking)\n" " | expression a=':' &('}'|',') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, " "\"expression expected after dictionary key and ':'\") }\n" +"invalid_kvpair_unpacking:\n" +" | a='**' b=if_expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"invalid double starred " +"expression. Did you forget to wrap the conditional expression in parentheses?" +"\") }\n" +" | a='*' b=bitwise_or ':' expression { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " +"b, \"cannot use a starred expression in a dictionary key\") }\n" +" | a='**' b=bitwise_or ':' expression { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " +"b, \"cannot use dict unpacking in a dictionary key\") }\n" +" | expression ':' a='*' b=bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " +"b, \"cannot use a starred expression in a dictionary value\") }\n" +" | expression ':' a='**' b=bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " +"b, \"cannot use dict unpacking in a dictionary value\") }\n" "invalid_kvpair:\n" " | a=expression !(':') {\n" " RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, a->lineno, a-" @@ -1887,14 +1977,23 @@ msgid "" "key\") }\n" " | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, " "\"cannot use a starred expression in a dictionary value\") }\n" +" | expression ':' a='**' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, " +"\"cannot use dict unpacking in a dictionary value\") }\n" " | expression a=':' &('}'|',') {RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, " "\"expression expected after dictionary key and ':'\") }\n" "invalid_starred_expression_unpacking:\n" +" | a='*' b=if_expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"invalid starred expression. " +"Did you forget to wrap the conditional expression in parentheses?\") }\n" " | a='*' expression '=' b=expression { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " "b, \"cannot assign to iterable argument unpacking\") }\n" +"invalid_starred_expression_unpacking_sequence:\n" +" | a='**' bitwise_or {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"cannot use dict unpacking " +"here\") }\n" +" | invalid_starred_expression_unpacking\n" "invalid_starred_expression:\n" " | '*' { RAISE_SYNTAX_ERROR(\"Invalid star expression\") }\n" -"\n" "invalid_fstring_replacement_field:\n" " | '{' a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"f-string: valid " "expression required before '='\") }\n" @@ -2118,9 +2217,9 @@ msgstr "" "simple_stmt[stmt_ty] (memo):\n" " | assignment\n" " | &\"type\" type_alias\n" +" | &('import' | 'from' | \"lazy\") import_stmt\n" " | e=star_expressions { _PyAST_Expr(e, EXTRA) }\n" " | &'return' return_stmt\n" -" | &('import' | 'from') import_stmt\n" " | &'raise' raise_stmt\n" " | &'pass' pass_stmt\n" " | &'del' del_stmt\n" @@ -2188,8 +2287,10 @@ msgstr "" " | 'return' a=[star_expressions] { _PyAST_Return(a, EXTRA) }\n" "\n" "raise_stmt[stmt_ty]:\n" -" | 'raise' a=expression b=['from' z=expression { z }] { _PyAST_Raise(a, " -"b, EXTRA) }\n" +" | 'raise' a=expression 'from' b=expression { _PyAST_Raise(a, b, " +"EXTRA) }\n" +" | invalid_raise_stmt\n" +" | 'raise' a=expression { _PyAST_Raise(a, NULL, EXTRA) }\n" " | 'raise' { _PyAST_Raise(NULL, NULL, EXTRA) }\n" "\n" "pass_stmt[stmt_ty]:\n" @@ -2215,10 +2316,12 @@ msgstr "" "\n" "yield_stmt[stmt_ty]: y=yield_expr { _PyAST_Expr(y, EXTRA) }\n" "\n" -"assert_stmt[stmt_ty]: 'assert' a=expression b=[',' z=expression { z }] " -"{ _PyAST_Assert(a, b, EXTRA) }\n" +"assert_stmt[stmt_ty]:\n" +" | invalid_assert_stmt\n" +" | 'assert' a=expression b=[',' z=expression { z }] { _PyAST_Assert(a, b, " +"EXTRA) }\n" "\n" -"import_stmt[stmt_ty]:\n" +"import_stmt[stmt_ty](memo):\n" " | invalid_import\n" " | import_name\n" " | import_from\n" @@ -2226,17 +2329,21 @@ msgstr "" "# Import 陳述式\n" "# ------------\n" "\n" -"import_name[stmt_ty]: 'import' a=dotted_as_names { _PyAST_Import(a, " -"EXTRA) }\n" +"import_name[stmt_ty]:\n" +" | lazy=\"lazy\"? 'import' a=dotted_as_names { _PyAST_Import(a, lazy ? " +"1 : 0, EXTRA) }\n" +"\n" "# 注意以下部分:('.' | '...') 是必須的,因為 '...' 是被 tokenize 為 " "ELLIPSIS\n" "import_from[stmt_ty]:\n" -" | 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets " +" | invalid_import_from\n" +" | lazy=\"lazy\"? 'from' a=('.' | '...')* b=dotted_name 'import' " +"c=import_from_targets {\n" +" _PyPegen_checked_from_import(p, a, b, c, lazy, EXTRA) }\n" +" | lazy=\"lazy\"? 'from' a=('.' | '...')+ 'import' b=import_from_targets " "{\n" -" _PyPegen_checked_future_import(p, b->v.Name.id, c, " -"_PyPegen_seq_count_dots(a), EXTRA) }\n" -" | 'from' a=('.' | '...')+ 'import' b=import_from_targets {\n" -" _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), EXTRA) }\n" +" _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), lazy ? 1 : 0, " +"EXTRA) }\n" "import_from_targets[asdl_alias_seq*]:\n" " | '(' a=import_from_as_names [','] ')' { a }\n" " | import_from_as_names !','\n" @@ -2607,10 +2714,12 @@ msgstr "" "\n" "signed_number[expr_ty]:\n" " | NUMBER\n" +" | '+' number=NUMBER { _PyAST_UnaryOp(UAdd, number, EXTRA) }\n" " | '-' number=NUMBER { _PyAST_UnaryOp(USub, number, EXTRA) }\n" "\n" "signed_real_number[expr_ty]:\n" " | real_number\n" +" | '+' real=real_number { _PyAST_UnaryOp(UAdd, real, EXTRA) }\n" " | '-' real=real_number { _PyAST_UnaryOp(USub, real, EXTRA) }\n" "\n" "real_number[expr_ty]:\n" @@ -2684,6 +2793,7 @@ msgstr "" " CHECK(asdl_pattern_seq*, _PyPegen_get_patterns(p, items)),\n" " NULL,\n" " EXTRA) }\n" +" | invalid_mapping_pattern\n" "\n" "items_pattern[asdl_seq*]:\n" " | ','.key_value_pattern+\n" @@ -2778,13 +2888,17 @@ msgstr "" " | expression\n" "\n" "expression[expr_ty] (memo):\n" +" | invalid_if_expression\n" " | invalid_expression\n" " | invalid_legacy_expression\n" -" | a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, " -"a, c, EXTRA) }\n" +" | if_expression\n" " | disjunction\n" " | lambdef\n" "\n" +"if_expression[expr_ty]:\n" +" | a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, " +"a, c, EXTRA) }\n" +"\n" "yield_expr[expr_ty]:\n" " | 'yield' 'from' a=expression { _PyAST_YieldFrom(a, EXTRA) }\n" " | 'yield' a=[star_expressions] { _PyAST_Yield(a, EXTRA) }\n" @@ -2804,10 +2918,17 @@ msgstr "" "star_named_expressions[asdl_expr_seq*]: " "a[asdl_expr_seq*]=','.star_named_expression+ [','] { a }\n" "\n" +"star_named_expressions_sequence[asdl_expr_seq*]: " +"a[asdl_expr_seq*]=','.star_named_expression_sequence+ [','] { a }\n" +"\n" "star_named_expression[expr_ty]:\n" " | '*' a=bitwise_or { _PyAST_Starred(a, Load, EXTRA) }\n" " | named_expression\n" "\n" +"star_named_expression_sequence[expr_ty]:\n" +" | invalid_starred_expression_unpacking_sequence\n" +" | star_named_expression\n" +"\n" "assignment_expression[expr_ty]:\n" " | a=NAME ':=' ~ b=expression {\n" " CHECK_VERSION(expr_ty, 8, \"Assignment expressions are\",\n" @@ -2974,9 +3095,9 @@ msgstr "" " | 'None' { _PyAST_Constant(Py_None, NULL, EXTRA) }\n" " | &(STRING|FSTRING_START|TSTRING_START) strings\n" " | NUMBER\n" -" | &'(' (tuple | group | genexp)\n" -" | &'[' (list | listcomp)\n" -" | &'{' (dict | set | dictcomp | setcomp)\n" +" | &'(' (genexp | tuple | group)\n" +" | &'[' (listcomp | list)\n" +" | &'{' (dictcomp | setcomp | dict | set)\n" " | '...' { _PyAST_Constant(Py_Ellipsis, NULL, EXTRA) }\n" "\n" "group[expr_ty]:\n" @@ -3120,14 +3241,17 @@ msgstr "" "EXTRA) }\n" "\n" "list[expr_ty]:\n" -" | '[' a=[star_named_expressions] ']' { _PyAST_List(a, Load, EXTRA) }\n" +" | '[' a=[star_named_expressions_sequence] ']' { _PyAST_List(a, Load, " +"EXTRA) }\n" "\n" "tuple[expr_ty]:\n" -" | '(' a=[y=star_named_expression ',' z=[star_named_expressions] " -"{ _PyPegen_seq_insert_in_front(p, y, z) } ] ')' {\n" +" | '(' a=[y=star_named_expression_sequence ',' " +"z=[star_named_expressions_sequence] { _PyPegen_seq_insert_in_front(p, y, " +"z) } ] ')' {\n" " _PyAST_Tuple(a, Load, EXTRA) }\n" "\n" -"set[expr_ty]: '{' a=star_named_expressions '}' { _PyAST_Set(a, EXTRA) }\n" +"set[expr_ty]: '{' a=star_named_expressions_sequence '}' { _PyAST_Set(a, " +"EXTRA) }\n" "\n" "# 字典\n" "# ----\n" @@ -3167,24 +3291,26 @@ msgstr "" " | invalid_for_target\n" "\n" "listcomp[expr_ty]:\n" -" | '[' a=named_expression b=for_if_clauses ']' { _PyAST_ListComp(a, b, " -"EXTRA) }\n" +" | '[' a=star_named_expression b=for_if_clauses ']' { _PyAST_ListComp(a, " +"b, EXTRA) }\n" " | invalid_comprehension\n" "\n" "setcomp[expr_ty]:\n" -" | '{' a=named_expression b=for_if_clauses '}' { _PyAST_SetComp(a, b, " -"EXTRA) }\n" +" | '{' a=star_named_expression b=for_if_clauses '}' { _PyAST_SetComp(a, " +"b, EXTRA) }\n" " | invalid_comprehension\n" "\n" "genexp[expr_ty]:\n" -" | '(' a=( assignment_expression | expression !':=') b=for_if_clauses ')' " -"{ _PyAST_GeneratorExp(a, b, EXTRA) }\n" +" | '(' a=( assignment_expression | expression !':=' | " +"starred_expression ) b=for_if_clauses ')' { _PyAST_GeneratorExp(a, b, " +"EXTRA) }\n" " | invalid_comprehension\n" "\n" "dictcomp[expr_ty]:\n" " | '{' a=kvpair b=for_if_clauses '}' { _PyAST_DictComp(a->key, a->value, " "b, EXTRA) }\n" -" | invalid_dict_comprehension\n" +" | '{' '**' a=expression b=for_if_clauses '}' { _PyAST_DictComp(a, NULL, " +"b, EXTRA) }\n" "\n" "# 函式呼叫引數\n" "# ==========\n" @@ -3425,10 +3551,7 @@ msgstr "" " # 軟關鍵字也需要被忽略,因為它們可以被剖析為 NAME NAME\n" " | !(NAME STRING | SOFT_KEYWORD) a=disjunction " "b=expression_without_invalid {\n" -" _PyPegen_check_legacy_stmt(p, a) ? NULL : p->tokens[p->mark-1]-" -">level == 0 ? NULL :\n" -" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"invalid syntax. Perhaps you " -"forgot a comma?\") }\n" +" _PyPegen_raise_error_for_missing_comma(p, a, b) }\n" " | a=disjunction 'if' b=disjunction !('else'|':') " "{ RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"expected 'else' after 'if' " "expression\") }\n" @@ -3446,6 +3569,14 @@ msgstr "" " RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"t-string: lambda expressions " "are not allowed without parentheses\") }\n" "\n" +"invalid_if_expression:\n" +" | disjunction 'if' b=disjunction 'else' a='*' {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"cannot unpack only part of a " +"conditional expression\") }\n" +" | disjunction 'if' b=disjunction 'else' a='**' {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"cannot use dict unpacking on " +"only part of a conditional expression\") }\n" +"\n" "invalid_named_expression(memo):\n" " | a=expression ':=' expression {\n" " RAISE_SYNTAX_ERROR_KNOWN_LOCATION(\n" @@ -3488,16 +3619,47 @@ msgstr "" " | list\n" " | tuple\n" " | '(' a=invalid_ann_assign_target ')' { a }\n" +"invalid_raise_stmt:\n" +" | a='raise' b='from' {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"did you forget an expression " +"between 'raise' and 'from'?\") }\n" +" | 'raise' expression a='from' {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"did you forget an expression " +"after 'from'?\") }\n" "invalid_del_stmt:\n" " | 'del' a=star_expressions {\n" " RAISE_SYNTAX_ERROR_INVALID_TARGET(DEL_TARGETS, a) }\n" +"invalid_assert_stmt:\n" +" | 'assert' a=expression '=' b=expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"cannot assign to %s here. Maybe you meant '==' instead of '='?" +"\",\n" +" _PyPegen_get_expr_name(a)) }\n" +" | 'assert' expression ',' a=expression '=' b=expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"cannot assign to %s here. Maybe you meant '==' instead of '='?" +"\",\n" +" _PyPegen_get_expr_name(a)) }\n" +" | 'assert' a=expression ':=' b=expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"cannot use named expression without parentheses here\") }\n" +" | 'assert' expression ',' a=expression ':=' b=expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"cannot use named expression without parentheses here\") }\n" "invalid_block:\n" " | NEWLINE !INDENT { RAISE_INDENTATION_ERROR(\"expected an indented " "block\") }\n" "invalid_comprehension:\n" -" | ('[' | '(' | '{') a=starred_expression for_if_clauses {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"iterable unpacking cannot be " -"used in comprehension\") }\n" +" | '[' a='**' b=expression for_if_clauses {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"cannot use dict unpacking in " +"list comprehension\") }\n" +" | '(' a='**' b=expression for_if_clauses {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"cannot use dict unpacking in " +"generator expression\") }\n" " | ('[' | '{') a=star_named_expression ',' b=star_named_expressions " "for_if_clauses {\n" " RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, PyPegen_last_item(b, expr_ty),\n" @@ -3505,13 +3667,9 @@ msgstr "" " | ('[' | '{') a=star_named_expression b=',' for_if_clauses {\n" " RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"did you forget parentheses " "around the comprehension target?\") }\n" -"invalid_dict_comprehension:\n" -" | '{' a='**' bitwise_or for_if_clauses '}' {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"dict unpacking cannot be used " -"in dict comprehension\") }\n" "invalid_parameters:\n" " | a=\"/\" ',' {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"at least one argument must " +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"at least one parameter must " "precede /\") }\n" " | (slash_no_default | slash_with_default) param_maybe_default* a='/' {\n" " RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"/ may appear only once\") }\n" @@ -3533,29 +3691,28 @@ msgstr "" "default value expression\") }\n" "invalid_star_etc:\n" " | a='*' (')' | ',' (')' | '**')) { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, " -"\"named arguments must follow bare *\") }\n" +"\"named parameters must follow bare *\") }\n" " | '*' ',' TYPE_COMMENT { RAISE_SYNTAX_ERROR(\"bare * has associated type " "comment\") }\n" " | '*' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"var-" -"positional argument cannot have default value\") }\n" +"positional parameter cannot have default value\") }\n" " | '*' (param_no_default | ',') param_maybe_default* a='*' " "(param_no_default | ',') {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"* argument may appear only " -"once\") }\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"* may appear only once\") }\n" "invalid_kwds:\n" " | '**' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"var-keyword " -"argument cannot have default value\") }\n" +"parameter cannot have default value\") }\n" " | '**' param ',' a=param { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, " -"\"arguments cannot follow var-keyword argument\") }\n" +"\"parameters cannot follow var-keyword parameter\") }\n" " | '**' param ',' a[Token*]=('*'|'**'|'/') " -"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"arguments cannot follow var-keyword " -"argument\") }\n" +"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"parameters cannot follow var-" +"keyword parameter\") }\n" "invalid_parameters_helper: # 這是為了避免型別錯誤而存在的規則\n" " | a=slash_with_default { _PyPegen_singleton_seq(p, a) }\n" " | param_with_default+\n" "invalid_lambda_parameters:\n" " | a=\"/\" ',' {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"at least one argument must " +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"at least one parameter must " "precede /\") }\n" " | (lambda_slash_no_default | lambda_slash_with_default) " "lambda_param_maybe_default* a='/' {\n" @@ -3578,23 +3735,22 @@ msgstr "" " | a=lambda_slash_with_default { _PyPegen_singleton_seq(p, a) }\n" " | lambda_param_with_default+\n" "invalid_lambda_star_etc:\n" -" | '*' (':' | ',' (':' | '**')) { RAISE_SYNTAX_ERROR(\"named arguments " +" | '*' (':' | ',' (':' | '**')) { RAISE_SYNTAX_ERROR(\"named parameters " "must follow bare *\") }\n" " | '*' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"var-" -"positional argument cannot have default value\") }\n" +"positional parameter cannot have default value\") }\n" " | '*' (lambda_param_no_default | ',') lambda_param_maybe_default* a='*' " "(lambda_param_no_default | ',') {\n" -" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"* argument may appear only " -"once\") }\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"* may appear only once\") }\n" "invalid_lambda_kwds:\n" " | '**' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"var-" -"keyword argument cannot have default value\") }\n" +"keyword parameter cannot have default value\") }\n" " | '**' lambda_param ',' a=lambda_param " -"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"arguments cannot follow var-keyword " -"argument\") }\n" +"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"parameters cannot follow var-" +"keyword parameter\") }\n" " | '**' lambda_param ',' a[Token*]=('*'|'**'|'/') " -"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"arguments cannot follow var-keyword " -"argument\") }\n" +"{ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"parameters cannot follow var-" +"keyword parameter\") }\n" "invalid_double_type_comments:\n" " | TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT {\n" " RAISE_SYNTAX_ERROR(\"Cannot have two type comments on def\") }\n" @@ -3635,6 +3791,12 @@ msgstr "" " \"cannot use %s as import target\", " "_PyPegen_get_expr_name(a)) }\n" "\n" +"invalid_import_from:\n" +" | 'from' ('.' | '...')* dotted_name a=\"lazy\" 'import' " +"import_from_targets {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,\n" +" \"use 'lazy from ... ' instead of 'from ... lazy import'\") }\n" +"\n" "invalid_import_from_targets:\n" " | import_from_as_names ',' NEWLINE {\n" " RAISE_SYNTAX_ERROR(\"trailing comma not allowed without surrounding " @@ -3644,6 +3806,10 @@ msgstr "" "after 'import'\") }\n" "\n" "invalid_with_stmt:\n" +" | ['async'] 'with' ','.(expression ['as' star_target])+ trailing=',' ':' " +"{\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(trailing, \"the last 'with' item " +"has a trailing comma\") }\n" " | ['async'] 'with' ','.(expression ['as' star_target])+ NEWLINE " "{ RAISE_SYNTAX_ERROR(\"expected ':'\") }\n" " | ['async'] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' " @@ -3715,6 +3881,10 @@ msgstr "" " | a=\"match\" subject=subject_expr ':' NEWLINE !INDENT {\n" " RAISE_INDENTATION_ERROR(\"expected an indented block after 'match' " "statement on line %d\", a->lineno) }\n" +" | a=\"case\" patterns guard? b=':' block {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(\n" +" a, b,\n" +" \"case statement must be inside match statement\") }\n" "invalid_case_block:\n" " | \"case\" patterns guard? NEWLINE { RAISE_SYNTAX_ERROR(\"expected " "':'\") }\n" @@ -3734,6 +3904,12 @@ msgstr "" " PyPegen_first_item(a, pattern_ty),\n" " PyPegen_last_item(a, pattern_ty),\n" " \"positional patterns follow keyword patterns\") }\n" +"invalid_mapping_pattern:\n" +" | '{' (items_pattern ',')? rest=double_star_pattern ',' items_pattern " +"','? '}' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(\n" +" rest,\n" +" \"double star pattern must be the last (right-most) subpattern in " +"the mapping pattern\") }\n" "invalid_class_argument_pattern[asdl_pattern_seq*]:\n" " | [positional_patterns ','] keyword_patterns ',' a=positional_patterns " "{ a }\n" @@ -3784,11 +3960,24 @@ msgstr "" "definition on line %d\", a->lineno) }\n" "\n" "invalid_double_starred_kvpairs:\n" -" | ','.double_starred_kvpair+ ',' invalid_kvpair\n" -" | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, " -"\"cannot use a starred expression in a dictionary value\") }\n" +" | invalid_kvpair_unpacking [',']\n" +" | ','.double_starred_kvpair+ ',' (invalid_kvpair | " +"invalid_kvpair_unpacking)\n" " | expression a=':' &('}'|',') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, " "\"expression expected after dictionary key and ':'\") }\n" +"invalid_kvpair_unpacking:\n" +" | a='**' b=if_expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"invalid double starred " +"expression. Did you forget to wrap the conditional expression in parentheses?" +"\") }\n" +" | a='*' b=bitwise_or ':' expression { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " +"b, \"cannot use a starred expression in a dictionary key\") }\n" +" | a='**' b=bitwise_or ':' expression { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " +"b, \"cannot use dict unpacking in a dictionary key\") }\n" +" | expression ':' a='*' b=bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " +"b, \"cannot use a starred expression in a dictionary value\") }\n" +" | expression ':' a='**' b=bitwise_or { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " +"b, \"cannot use dict unpacking in a dictionary value\") }\n" "invalid_kvpair:\n" " | a=expression !(':') {\n" " RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, a->lineno, a-" @@ -3796,14 +3985,23 @@ msgstr "" "key\") }\n" " | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, " "\"cannot use a starred expression in a dictionary value\") }\n" +" | expression ':' a='**' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, " +"\"cannot use dict unpacking in a dictionary value\") }\n" " | expression a=':' &('}'|',') {RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, " "\"expression expected after dictionary key and ':'\") }\n" "invalid_starred_expression_unpacking:\n" +" | a='*' b=if_expression {\n" +" RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, \"invalid starred expression. " +"Did you forget to wrap the conditional expression in parentheses?\") }\n" " | a='*' expression '=' b=expression { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, " "b, \"cannot assign to iterable argument unpacking\") }\n" +"invalid_starred_expression_unpacking_sequence:\n" +" | a='**' bitwise_or {\n" +" RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"cannot use dict unpacking " +"here\") }\n" +" | invalid_starred_expression_unpacking\n" "invalid_starred_expression:\n" " | '*' { RAISE_SYNTAX_ERROR(\"Invalid star expression\") }\n" -"\n" "invalid_fstring_replacement_field:\n" " | '{' a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, \"f-string: valid " "expression required before '='\") }\n" diff --git a/reference/import.po b/reference/import.po index ce209149143..78866798f65 100644 --- a/reference/import.po +++ b/reference/import.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-06-02 00:44+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-11-06 14:55+0800\n" "Last-Translator: Ken Cheng \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -641,21 +641,16 @@ msgid "" "if spec.loader is None:\n" " # unsupported\n" " raise ImportError\n" -"if spec.origin is None and spec.submodule_search_locations is not None:\n" -" # namespace package\n" -" sys.modules[spec.name] = module\n" -"elif not hasattr(spec.loader, 'exec_module'):\n" -" module = spec.loader.load_module(spec.name)\n" -"else:\n" -" sys.modules[spec.name] = module\n" +"\n" +"sys.modules[spec.name] = module\n" +"try:\n" +" spec.loader.exec_module(module)\n" +"except BaseException:\n" " try:\n" -" spec.loader.exec_module(module)\n" -" except BaseException:\n" -" try:\n" -" del sys.modules[spec.name]\n" -" except KeyError:\n" -" pass\n" -" raise\n" +" del sys.modules[spec.name]\n" +" except KeyError:\n" +" pass\n" +" raise\n" "return sys.modules[spec.name]" msgstr "" "module = None\n" @@ -670,35 +665,30 @@ msgstr "" "if spec.loader is None:\n" " # 不支援\n" " raise ImportError\n" -"if spec.origin is None and spec.submodule_search_locations is not None:\n" -" # 命名空間套件\n" -" sys.modules[spec.name] = module\n" -"elif not hasattr(spec.loader, 'exec_module'):\n" -" module = spec.loader.load_module(spec.name)\n" -"else:\n" -" sys.modules[spec.name] = module\n" +"\n" +"sys.modules[spec.name] = module\n" +"try:\n" +" spec.loader.exec_module(module)\n" +"except BaseException:\n" " try:\n" -" spec.loader.exec_module(module)\n" -" except BaseException:\n" -" try:\n" -" del sys.modules[spec.name]\n" -" except KeyError:\n" -" pass\n" -" raise\n" +" del sys.modules[spec.name]\n" +" except KeyError:\n" +" pass\n" +" raise\n" "return sys.modules[spec.name]" -#: ../../reference/import.rst:391 +#: ../../reference/import.rst:386 msgid "Note the following details:" msgstr "請注意下列細節:" -#: ../../reference/import.rst:393 +#: ../../reference/import.rst:388 msgid "" "If there is an existing module object with the given name in :data:`sys." "modules`, import will have already returned it." msgstr "" "如果 :data:`sys.modules` 中已存在具有給定名稱的模組物件,引入會已回傳該物件。" -#: ../../reference/import.rst:396 +#: ../../reference/import.rst:391 msgid "" "The module will exist in :data:`sys.modules` before the loader executes the " "module code. This is crucial because the module code may (directly or " @@ -710,7 +700,7 @@ msgstr "" "重要,因為模組程式碼可能會(直接或間接)引入自己;事先將其增加到 :data:`sys." "modules` 可以預防類似無限遞迴以及多次重複載入等情形。" -#: ../../reference/import.rst:402 +#: ../../reference/import.rst:397 msgid "" "If loading fails, the failing module -- and only the failing module -- gets " "removed from :data:`sys.modules`. Any module already in the :data:`sys." @@ -723,7 +713,7 @@ msgstr "" "須保留在快取中。此情形與重新載入不同,在重新載入時,即使載入失敗的模組也會保" "留在 :data:`sys.modules` 中。" -#: ../../reference/import.rst:408 +#: ../../reference/import.rst:403 msgid "" "After the module is created but before execution, the import machinery sets " "the import-related module attributes (\"_init_module_attrs\" in the pseudo-" @@ -734,7 +724,7 @@ msgstr "" "範例中為 \"_init_module_attrs\"),具體內容在\\ :ref:`之後的段落`\\ 會總結。" -#: ../../reference/import.rst:413 +#: ../../reference/import.rst:408 msgid "" "Module execution is the key moment of loading in which the module's " "namespace gets populated. Execution is entirely delegated to the loader, " @@ -743,7 +733,7 @@ msgstr "" "模組執行是載入過程中的關鍵時刻,此時模組的命名空間會被新增名稱。執行過程完全" "交由載入器處理,由其決定如何新增以及新增什麼。" -#: ../../reference/import.rst:417 +#: ../../reference/import.rst:412 msgid "" "The module created during loading and passed to exec_module() may not be the " "one returned at the end of import [#fnlo]_." @@ -751,20 +741,24 @@ msgstr "" "在載入過程中建立並傳遞給 exec_module() 的模組,可能不會是引入結束時回傳的模" "組 [#fnlo]_。" -#: ../../reference/import.rst:420 +#: ../../reference/import.rst:415 msgid "" "The import system has taken over the boilerplate responsibilities of " -"loaders. These were previously performed by the :meth:`importlib.abc.Loader." -"load_module` method." +"loaders. These were previously performed by the ``importlib.abc.Loader." +"load_module`` method." msgstr "" -"引入系統已接管載入器的模板 (boilerplate) 責任。之前是由 :meth:`importlib.abc." -"Loader.load_module` 方法執行的。" +"引入系統已接管載入器的模板 (boilerplate) 責任。之前是由 " +"``importlib.abc.Loader.load_module`` 方法執行的。" -#: ../../reference/import.rst:426 +#: ../../reference/import.rst:420 +msgid "The ``load_module`` method is no longer used." +msgstr "" + +#: ../../reference/import.rst:424 msgid "Loaders" msgstr "載入器" -#: ../../reference/import.rst:428 +#: ../../reference/import.rst:426 msgid "" "Module loaders provide the critical function of loading: module execution. " "The import machinery calls the :meth:`importlib.abc.Loader.exec_module` " @@ -775,11 +769,11 @@ msgstr "" "組物件)呼叫 :meth:`importlib.abc.Loader.exec_module` 方法。任何從 :meth:" "`~importlib.abc.Loader.exec_module` 回傳的值都會被忽略。" -#: ../../reference/import.rst:433 +#: ../../reference/import.rst:431 msgid "Loaders must satisfy the following requirements:" msgstr "載入器必須滿足以下要求:" -#: ../../reference/import.rst:435 +#: ../../reference/import.rst:433 msgid "" "If the module is a Python module (as opposed to a built-in module or a " "dynamically loaded extension), the loader should execute the module's code " @@ -788,7 +782,7 @@ msgstr "" "如果模組是 Python 模組(而非內建模組或動態載入的擴充),載入器應在模組的全域" "命名空間 (``module.__dict__``\\ ) 中執行該模組的程式碼。" -#: ../../reference/import.rst:439 +#: ../../reference/import.rst:437 msgid "" "If the loader cannot execute the module, it should raise an :exc:" "`ImportError`, although any other exception raised during :meth:`~importlib." @@ -797,7 +791,7 @@ msgstr "" "如果載入器無法執行該模組,應引發 :exc:`ImportError`。不過,在 :meth:" "`~importlib.abc.Loader.exec_module` 中引發的任何其他例外也會被傳播。" -#: ../../reference/import.rst:443 +#: ../../reference/import.rst:441 msgid "" "In many cases, the finder and loader can be the same object; in such cases " "the :meth:`~importlib.abc.MetaPathFinder.find_spec` method would just return " @@ -807,7 +801,7 @@ msgstr "" "`~importlib.abc.MetaPathFinder.find_spec` 方法只需回傳一個載入器設為 " "``self`` 的規格即可。" -#: ../../reference/import.rst:447 +#: ../../reference/import.rst:445 msgid "" "Module loaders may opt in to creating the module object during loading by " "implementing a :meth:`~importlib.abc.Loader.create_module` method. It takes " @@ -821,20 +815,21 @@ msgstr "" "要使用的新的模組物件。``create_module()`` 不需要在模組物件上設定任何屬性。如" "果該方法回傳 ``None``,引入機制將自行建立新的模組。" -#: ../../reference/import.rst:454 +#: ../../reference/import.rst:452 msgid "The :meth:`~importlib.abc.Loader.create_module` method of loaders." msgstr "載入器的 :meth:`~importlib.abc.Loader.create_module` 方法。" -#: ../../reference/import.rst:457 +#: ../../reference/import.rst:455 msgid "" -"The :meth:`~importlib.abc.Loader.load_module` method was replaced by :meth:" +"The ``importlib.abc.Loader.load_module`` method was replaced by :meth:" "`~importlib.abc.Loader.exec_module` and the import machinery assumed all the " "boilerplate responsibilities of loading." msgstr "" -":meth:`~importlib.abc.Loader.load_module` 方法已被 :meth:`~importlib.abc." -"Loader.exec_module` 取代,引入機制已承擔所有載入的模板責任。" +"``importlib.abc.Loader.load_module`` 方法已" +"被 :meth:`~importlib.abc.Loader.exec_module` 取代,引入機制已承擔所有載入的模" +"板責任。" -#: ../../reference/import.rst:462 +#: ../../reference/import.rst:460 msgid "" "For compatibility with existing loaders, the import machinery will use the " "``load_module()`` method of loaders if it exists and the loader does not " @@ -845,7 +840,7 @@ msgstr "" "``load_module()`` 方法時使用該方法。然而,``load_module()`` 已被棄用,載入器" "應改為實作 ``exec_module()``。" -#: ../../reference/import.rst:467 +#: ../../reference/import.rst:465 msgid "" "The ``load_module()`` method must implement all the boilerplate loading " "functionality described above in addition to executing the module. All the " @@ -854,7 +849,7 @@ msgstr "" "``load_module()`` 方法除了執行模組外,還必須實作上述全部的模板載入功能。所有" "相同的限制依然適用,並且還有一些額外的說明:" -#: ../../reference/import.rst:471 +#: ../../reference/import.rst:469 msgid "" "If there is an existing module object with the given name in :data:`sys." "modules`, the loader must use that existing module. (Otherwise, :func:" @@ -867,7 +862,7 @@ msgstr "" "`sys.modules` 中,載入器必須建立一個新的模組物件並將其新增至 :data:`sys." "modules`。" -#: ../../reference/import.rst:477 +#: ../../reference/import.rst:475 msgid "" "The module *must* exist in :data:`sys.modules` before the loader executes " "the module code, to prevent unbounded recursion or multiple loading." @@ -875,7 +870,7 @@ msgstr "" "在載入器執行模組程式碼之前,該模組\\ *必須*\\ 已存在於 :data:`sys.modules` " "中,以防止無限遞迴或多次載入。" -#: ../../reference/import.rst:481 +#: ../../reference/import.rst:479 msgid "" "If loading fails, the loader must remove any modules it has inserted into :" "data:`sys.modules`, but it must remove **only** the failing module(s), and " @@ -885,7 +880,7 @@ msgstr "" "\\ **只能**\\ 移除失敗的模組(們),且僅在載入器本身明確載入這些模組時才需移" "除。" -#: ../../reference/import.rst:486 +#: ../../reference/import.rst:484 msgid "" "A :exc:`DeprecationWarning` is raised when ``exec_module()`` is defined but " "``create_module()`` is not." @@ -893,7 +888,7 @@ msgstr "" "當 ``exec_module()`` 已定義但未定義 ``create_module()`` 時,將引發 :exc:" "`DeprecationWarning`。" -#: ../../reference/import.rst:490 +#: ../../reference/import.rst:488 msgid "" "An :exc:`ImportError` is raised when ``exec_module()`` is defined but " "``create_module()`` is not." @@ -901,15 +896,15 @@ msgstr "" "當 ``exec_module()`` 已定義但未定義 ``create_module()`` 時,將引發 :exc:" "`ImportError`。" -#: ../../reference/import.rst:494 +#: ../../reference/import.rst:492 msgid "Use of ``load_module()`` will raise :exc:`ImportWarning`." msgstr "使用 ``load_module()`` 將引發 :exc:`ImportWarning`。" -#: ../../reference/import.rst:498 +#: ../../reference/import.rst:496 msgid "Submodules" msgstr "子模組" -#: ../../reference/import.rst:500 +#: ../../reference/import.rst:498 msgid "" "When a submodule is loaded using any mechanism (e.g. ``importlib`` APIs, the " "``import`` or ``import-from`` statements, or built-in ``__import__()``) a " @@ -924,7 +919,7 @@ msgstr "" "foo`` 之後,``spam`` 將擁有一個名為 ``foo`` 的屬性,該屬性繫結到子模組。我們" "假設你有以下的目錄結構: ::" -#: ../../reference/import.rst:507 +#: ../../reference/import.rst:505 msgid "" "spam/\n" " __init__.py\n" @@ -934,22 +929,22 @@ msgstr "" " __init__.py\n" " foo.py" -#: ../../reference/import.rst:511 +#: ../../reference/import.rst:509 msgid "and ``spam/__init__.py`` has the following line in it::" msgstr "並且 ``spam/__init__.py`` 中包含以下程式碼: ::" -#: ../../reference/import.rst:513 +#: ../../reference/import.rst:511 msgid "from .foo import Foo" msgstr "from .foo import Foo" -#: ../../reference/import.rst:515 +#: ../../reference/import.rst:513 msgid "" "then executing the following puts name bindings for ``foo`` and ``Foo`` in " "the ``spam`` module::" msgstr "" "那麼執行以下程式碼會將 ``foo`` 和 ``Foo`` 的名稱繫結到 ``spam`` 模組中: ::" -#: ../../reference/import.rst:518 +#: ../../reference/import.rst:516 msgid "" ">>> import spam\n" ">>> spam.foo\n" @@ -963,7 +958,7 @@ msgstr "" ">>> spam.Foo\n" "" -#: ../../reference/import.rst:524 +#: ../../reference/import.rst:522 msgid "" "Given Python's familiar name binding rules this might seem surprising, but " "it's actually a fundamental feature of the import system. The invariant " @@ -976,11 +971,11 @@ msgstr "" "modules['spam.foo']``\\ (就像上述引入後那樣),那麼後者必須作為前者的 " "``foo`` 屬性出現。" -#: ../../reference/import.rst:533 +#: ../../reference/import.rst:531 msgid "Module specs" msgstr "模組規格" -#: ../../reference/import.rst:535 +#: ../../reference/import.rst:533 msgid "" "The import machinery uses a variety of information about each module during " "import, especially before loading. Most of the information is common to all " @@ -991,7 +986,7 @@ msgstr "" "對所有模組來說都是通用的。模組規格的目的是以每個模組為基礎封裝這些與引入相關" "的資訊。" -#: ../../reference/import.rst:540 +#: ../../reference/import.rst:538 msgid "" "Using a spec during import allows state to be transferred between import " "system components, e.g. between the finder that creates the module spec and " @@ -1003,7 +998,7 @@ msgstr "" "的尋檢器和執行該規格的載入器之間傳遞。最重要的是,這允許引入機制執行載入的模" "板操作,而在沒有模組規格的情況下,這些操作則是載入器的責任。" -#: ../../reference/import.rst:546 +#: ../../reference/import.rst:544 msgid "" "The module's spec is exposed as :attr:`module.__spec__`. Setting :attr:`!" "__spec__` appropriately applies equally to :ref:`modules initialized during " @@ -1015,18 +1010,18 @@ msgstr "" "例外是 ``__main__``,其中 :attr:`!__spec__` 會\\ :ref:`在某些情況下被設定成 " "None `。" -#: ../../reference/import.rst:552 +#: ../../reference/import.rst:550 msgid "" "See :class:`~importlib.machinery.ModuleSpec` for details on the contents of " "the module spec." msgstr "" "有關模組規格內容的詳細資訊,請參閱 :class:`~importlib.machinery.ModuleSpec`。" -#: ../../reference/import.rst:560 +#: ../../reference/import.rst:558 msgid "__path__ attributes on modules" msgstr "模組上的 __path__ 屬性" -#: ../../reference/import.rst:562 +#: ../../reference/import.rst:560 msgid "" "The :attr:`~module.__path__` attribute should be a (possibly empty) :term:" "`sequence` of strings enumerating the locations where the package's " @@ -1037,7 +1032,7 @@ msgstr "" "包含列舉套件子模組位置的字串。根據定義,如果一個模組有 :attr:`!__path__` 屬" "性,那麼它就是一個 :term:`package`。" -#: ../../reference/import.rst:567 +#: ../../reference/import.rst:565 msgid "" "A package's :attr:`~module.__path__` attribute is used during imports of its " "subpackages. Within the import machinery, it functions much the same as :" @@ -1049,7 +1044,7 @@ msgstr "" "功能與 :data:`sys.path` 類似,即提供在引入期間搜尋模組的位置串列。然而,:" "attr:`!__path__` 通常比 :data:`!sys.path` 更受限制。" -#: ../../reference/import.rst:574 +#: ../../reference/import.rst:572 msgid "" "The same rules used for :data:`sys.path` also apply to a package's :attr:`!" "__path__`. :data:`sys.path_hooks` (described below) are consulted when " @@ -1058,7 +1053,7 @@ msgstr "" ":data:`sys.path` 適用的規則同樣也適用於套件的 :attr:`!__path__`。 :data:`sys." "path_hooks` 會在遍歷套件的 :attr:`!__path__` 時被參考(於後文詳述)。" -#: ../../reference/import.rst:578 +#: ../../reference/import.rst:576 msgid "" "A package's ``__init__.py`` file may set or alter the package's :attr:" "`~module.__path__` attribute, and this was typically the way namespace " @@ -1072,11 +1067,11 @@ msgstr "" "命名空間套件不再需要提供僅包含 :attr:`!__path__` 操作程式碼的 ``__init__." "py`` 檔案;引入機制會自動為命名空間套件正確地設定 :attr:`!__path__`。" -#: ../../reference/import.rst:587 +#: ../../reference/import.rst:585 msgid "Module reprs" msgstr "模組的 reprs" -#: ../../reference/import.rst:589 +#: ../../reference/import.rst:587 msgid "" "By default, all modules have a usable repr, however depending on the " "attributes set above, and in the module's spec, you can more explicitly " @@ -1085,7 +1080,7 @@ msgstr "" "預設情況下,所有模組都有可用的 repr,然而根據上述設定及模組規格中的屬性,你可" "以更明確地控制模組物件的 repr。" -#: ../../reference/import.rst:593 +#: ../../reference/import.rst:591 msgid "" "If the module has a spec (``__spec__``), the import machinery will try to " "generate a repr from it. If that fails or there is no spec, the import " @@ -1099,11 +1094,11 @@ msgstr "" "``module.__name__``、``module.__file__`` 和 ``module.__loader__`` 作為 repr " "的輸入,並為缺少的資訊提供預設值。" -#: ../../reference/import.rst:600 +#: ../../reference/import.rst:598 msgid "Here are the exact rules used:" msgstr "以下是具體的使用規則:" -#: ../../reference/import.rst:602 +#: ../../reference/import.rst:600 msgid "" "If the module has a ``__spec__`` attribute, the information in the spec is " "used to generate the repr. The \"name\", \"loader\", \"origin\", and " @@ -1112,13 +1107,13 @@ msgstr "" "如果模組具有 ``__spec__`` 屬性,則使用規格中的資訊產生 repr。會參考 " "\"name\"、\"loader\"、\"origin\" 和 \"has_location\" 屬性。" -#: ../../reference/import.rst:606 +#: ../../reference/import.rst:604 msgid "" "If the module has a ``__file__`` attribute, this is used as part of the " "module's repr." msgstr "如果模組具有 ``__file__`` 屬性,則會將其作為模組 repr 的一部分。" -#: ../../reference/import.rst:609 +#: ../../reference/import.rst:607 msgid "" "If the module has no ``__file__`` but does have a ``__loader__`` that is not " "``None``, then the loader's repr is used as part of the module's repr." @@ -1126,11 +1121,11 @@ msgstr "" "如果模組沒有 ``__file__`` 但有一個不為 ``None`` 的 ``__loader__`` ,則會將載" "入器的 repr 作為模組 repr 的一部分。" -#: ../../reference/import.rst:612 +#: ../../reference/import.rst:610 msgid "Otherwise, just use the module's ``__name__`` in the repr." msgstr "否則,在 repr 中只使用模組的 ``__name__``。" -#: ../../reference/import.rst:614 +#: ../../reference/import.rst:612 msgid "" "Use of :meth:`!module_repr`, having been deprecated since Python 3.4, was " "removed in Python 3.12 and is no longer called during the resolution of a " @@ -1139,11 +1134,11 @@ msgstr "" ":meth:`!module_repr` 自 Python 3.4 起被棄用,並在 Python 3.12 中移除,且不會" "在解析模組的 repr 時被呼叫。" -#: ../../reference/import.rst:622 +#: ../../reference/import.rst:620 msgid "Cached bytecode invalidation" msgstr "被快取的位元組碼的無效化" -#: ../../reference/import.rst:624 +#: ../../reference/import.rst:622 msgid "" "Before Python loads cached bytecode from a ``.pyc`` file, it checks whether " "the cache is up-to-date with the source ``.py`` file. By default, Python " @@ -1157,7 +1152,7 @@ msgstr "" "後修改時間戳和大小來完成此操作。在 runtime,引入系統會透過將快取檔案中儲存的" "詮釋資料 (metadata) 與來源檔案的詮釋資料進行比對來驗證快取檔案。" -#: ../../reference/import.rst:631 +#: ../../reference/import.rst:629 msgid "" "Python also supports \"hash-based\" cache files, which store a hash of the " "source file's contents rather than its metadata. There are two variants of " @@ -1178,7 +1173,7 @@ msgstr "" "湊的 ``.pyc`` 檔案,只要檔案存在,Python 就假設快取檔案是有效的。可以使用 :" "option:`--check-hash-based-pycs` 旗標覆蓋基於雜湊的 ``.pyc`` 檔案的驗證行為。" -#: ../../reference/import.rst:642 +#: ../../reference/import.rst:640 msgid "" "Added hash-based ``.pyc`` files. Previously, Python only supported timestamp-" "based invalidation of bytecode caches." @@ -1186,11 +1181,11 @@ msgstr "" "新增了基於雜湊的 ``.pyc`` 檔案。此前,Python 只支援基於時間戳的位元組碼快取無" "效化。" -#: ../../reference/import.rst:648 +#: ../../reference/import.rst:646 msgid "The Path Based Finder" msgstr "基於路徑的尋檢器" -#: ../../reference/import.rst:653 +#: ../../reference/import.rst:651 msgid "" "As mentioned previously, Python comes with several default meta path " "finders. One of these, called the :term:`path based finder` (:class:" @@ -1203,7 +1198,7 @@ msgstr "" "`import path`,該路徑包含一個\\ :term:`路徑條目 `\\ 的串列。每個" "路徑條目都指定了一個用於搜尋模組的位置。" -#: ../../reference/import.rst:659 +#: ../../reference/import.rst:657 msgid "" "The path based finder itself doesn't know how to import anything. Instead, " "it traverses the individual path entries, associating each of them with a " @@ -1212,7 +1207,7 @@ msgstr "" "基於路徑的尋檢器本身並不知道如何引入任何東西。實際上它會遍歷各個路徑條目,並" "將每個路徑條目與一個知道如何處理該特定路徑類型的路徑條目尋檢器關聯起來。" -#: ../../reference/import.rst:663 +#: ../../reference/import.rst:661 msgid "" "The default set of path entry finders implement all the semantics for " "finding modules on the file system, handling special file types such as " @@ -1228,7 +1223,7 @@ msgstr "" "`zipimport` 模組支援時,預設的路徑條目尋檢器也能處理從壓縮檔案中載入這些檔案" "類型(共享函式庫除外)。" -#: ../../reference/import.rst:670 +#: ../../reference/import.rst:668 msgid "" "Path entries need not be limited to file system locations. They can refer " "to URLs, database queries, or any other location that can be specified as a " @@ -1237,7 +1232,7 @@ msgstr "" "路徑條目不必侷限於檔案系統位置。它們可以參照 URL、資料庫查詢或任何可以作為字" "串指定的位置。" -#: ../../reference/import.rst:674 +#: ../../reference/import.rst:672 msgid "" "The path based finder provides additional hooks and protocols so that you " "can extend and customize the types of searchable path entries. For example, " @@ -1252,7 +1247,7 @@ msgstr "" "的掛鉤,用於在網路上尋找模組。這個掛鉤(一個可呼叫物件)會回傳一個支援下述協" "定的 :term:`path entry finder` ,該尋檢器隨後用於從網路中取得模組的載入器。" -#: ../../reference/import.rst:682 +#: ../../reference/import.rst:680 msgid "" "A word of warning: this section and the previous both use the term *finder*, " "distinguishing between them by using the terms :term:`meta path finder` and :" @@ -1268,7 +1263,7 @@ msgstr "" "仍有些許的差異。尤其元路徑尋檢器會在引入過程開始時運作,並通過 :data:`sys." "meta_path` 的遍歷關閉 (key off)。" -#: ../../reference/import.rst:690 +#: ../../reference/import.rst:688 msgid "" "By contrast, path entry finders are in a sense an implementation detail of " "the path based finder, and in fact, if the path based finder were to be " @@ -1279,11 +1274,11 @@ msgstr "" "上,如果基於路徑的尋檢器從 :data:`sys.meta_path` 中移除,路徑條目尋檢器的任何" "語意都不會被叫用。" -#: ../../reference/import.rst:697 +#: ../../reference/import.rst:695 msgid "Path entry finders" msgstr "路徑條目尋檢器" -#: ../../reference/import.rst:705 +#: ../../reference/import.rst:703 msgid "" "The :term:`path based finder` is responsible for finding and loading Python " "modules and packages whose location is specified with a string :term:`path " @@ -1293,7 +1288,7 @@ msgstr "" ":term:`path based finder` 負責尋找並載入其位置以字串 :term:`path entry` 指定" "的 Python 模組與套件。大多數路徑條目指向檔案系統中的位置,但不必侷限於此。" -#: ../../reference/import.rst:710 +#: ../../reference/import.rst:708 msgid "" "As a meta path finder, the :term:`path based finder` implements the :meth:" "`~importlib.abc.MetaPathFinder.find_spec` protocol previously described, " @@ -1304,7 +1299,7 @@ msgstr "" "`~importlib.abc.MetaPathFinder.find_spec` 協定,但它另外提供了可用來自訂模組" "如何從 :term:`import path` 被找到並載入的掛鉤。" -#: ../../reference/import.rst:715 +#: ../../reference/import.rst:713 msgid "" "Three variables are used by the :term:`path based finder`, :data:`sys." "path`, :data:`sys.path_hooks` and :data:`sys.path_importer_cache`. The " @@ -1315,7 +1310,7 @@ msgstr "" "path_hooks` 和 :data:`sys.path_importer_cache`。套件物件上的 ``__path__`` 屬" "性也會被使用。這些提供了額外的方法來自訂引入機制。" -#: ../../reference/import.rst:720 +#: ../../reference/import.rst:718 msgid "" ":data:`sys.path` contains a list of strings providing search locations for " "modules and packages. It is initialized from the :envvar:`PYTHONPATH` " @@ -1332,7 +1327,7 @@ msgstr "" "的「位置」(參閱 :mod:`site` 模組),例如 URL 或資料庫查詢。:data:`sys.path` " "中只能包含字串;其他資料型別都會被忽略。" -#: ../../reference/import.rst:729 +#: ../../reference/import.rst:727 msgid "" "The :term:`path based finder` is a :term:`meta path finder`, so the import " "machinery begins the :term:`import path` search by calling the path based " @@ -1350,7 +1345,7 @@ msgstr "" "徑 list——通常是在套件內引入時使用該套件的 ``__path__`` 屬性。如果 ``path`` 引" "數為 ``None``,則表示為頂層引入並使用 :data:`sys.path`。" -#: ../../reference/import.rst:738 +#: ../../reference/import.rst:736 msgid "" "The path based finder iterates over every entry in the search path, and for " "each of these, looks for an appropriate :term:`path entry finder` (:class:" @@ -1375,7 +1370,7 @@ msgstr "" "data:`sys.path_importer_cache` 中的快取條目,以強制基於路徑的尋檢器再次執行路" "徑條目搜尋。" -#: ../../reference/import.rst:751 +#: ../../reference/import.rst:749 msgid "" "If the path entry is not present in the cache, the path based finder " "iterates over every callable in :data:`sys.path_hooks`. Each of the :term:" @@ -1399,7 +1394,7 @@ msgstr "" "掛鉤應預期接收字串或 bytes 物件;bytes 物件的編碼由掛鉤決定(例如檔案系統編" "碼、UTF-8 或其他),若掛鉤無法解碼該引數,則應引發 :exc:`ImportError`。" -#: ../../reference/import.rst:765 +#: ../../reference/import.rst:763 msgid "" "If :data:`sys.path_hooks` iteration ends with no :term:`path entry finder` " "being returned, then the path based finder's :meth:`~importlib.machinery." @@ -1414,7 +1409,7 @@ msgstr "" "路徑條目沒有尋檢器),並回傳 ``None``,表示此 :term:`meta path finder` 無法找" "到該模組。" -#: ../../reference/import.rst:772 +#: ../../reference/import.rst:770 msgid "" "If a :term:`path entry finder` *is* returned by one of the :term:`path entry " "hook` callables on :data:`sys.path_hooks`, then the following protocol is " @@ -1425,7 +1420,7 @@ msgstr "" "呼叫物件 *確實* 回傳了 :term:`path entry finder`,則會使用以下協定向該尋檢器" "要求模組規格,並在載入模組時使用該規格。" -#: ../../reference/import.rst:777 +#: ../../reference/import.rst:775 msgid "" "The current working directory -- denoted by an empty string -- is handled " "slightly differently from other entries on :data:`sys.path`. First, if the " @@ -1443,11 +1438,11 @@ msgstr "" "`importlib.machinery.PathFinder.find_spec` 回傳的路徑會是實際的目前工作目錄," "而不是空字串。" -#: ../../reference/import.rst:787 +#: ../../reference/import.rst:785 msgid "Path entry finder protocol" msgstr "路徑條目尋檢器協定" -#: ../../reference/import.rst:789 +#: ../../reference/import.rst:787 msgid "" "In order to support imports of modules and initialized packages and also to " "contribute portions to namespace packages, path entry finders must implement " @@ -1456,7 +1451,7 @@ msgstr "" "為了支援模組與已初始化套件的引入,並能為命名空間套件提供部分組成,路徑條目尋" "檢器必須實作 :meth:`~importlib.abc.PathEntryFinder.find_spec` 方法。" -#: ../../reference/import.rst:793 +#: ../../reference/import.rst:791 msgid "" ":meth:`~importlib.abc.PathEntryFinder.find_spec` takes two arguments: the " "fully qualified name of the module being imported, and the (optional) target " @@ -1467,7 +1462,7 @@ msgstr "" "組之完整限定名稱,以及(可選的)目標模組。``find_spec()`` 會回傳一個完整填入" "的模組規格。此規格會一律設定 \"loader\"(只有一個例外)。" -#: ../../reference/import.rst:798 +#: ../../reference/import.rst:796 msgid "" "To indicate to the import machinery that the spec represents a namespace :" "term:`portion`, the path entry finder sets ``submodule_search_locations`` to " @@ -1476,7 +1471,7 @@ msgstr "" "為了向引入機制表明該規格代表一個命名空間 :term:`portion`,路徑條目尋檢器會將 " "``submodule_search_locations`` 設為包含該部分的 list。" -#: ../../reference/import.rst:802 +#: ../../reference/import.rst:800 msgid "" ":meth:`~importlib.abc.PathEntryFinder.find_spec` replaced :meth:`!" "find_loader` and :meth:`!find_module`, both of which are now deprecated, but " @@ -1486,7 +1481,7 @@ msgstr "" "與 :meth:`!find_module`,兩者現已棄用,但若未定義 ``find_spec()`` 仍會被使" "用。" -#: ../../reference/import.rst:808 +#: ../../reference/import.rst:806 msgid "" "Older path entry finders may implement one of these two deprecated methods " "instead of ``find_spec()``. The methods are still respected for the sake of " @@ -1497,7 +1492,7 @@ msgstr "" "``find_spec()``。為了向後相容,這些方法仍會被使用。然而,如果路徑條目尋檢器實" "作了 ``find_spec()``,這些舊方法就會被忽略。" -#: ../../reference/import.rst:813 +#: ../../reference/import.rst:811 msgid "" ":meth:`!find_loader` takes one argument, the fully qualified name of the " "module being imported. ``find_loader()`` returns a 2-tuple where the first " @@ -1507,7 +1502,7 @@ msgstr "" "``find_loader()`` 會回傳一個 2-tuple,其中第一個項目是 loader,第二個項目是命" "名空間 :term:`portion`。" -#: ../../reference/import.rst:818 +#: ../../reference/import.rst:816 msgid "" "For backwards compatibility with other implementations of the import " "protocol, many path entry finders also support the same, traditional " @@ -1521,7 +1516,7 @@ msgstr "" "``find_module()`` 方法永遠不會帶著 ``path`` 引數被呼叫(它們預期會從對路徑條" "目掛鉤的初始呼叫中記錄適當的路徑資訊)。" -#: ../../reference/import.rst:825 +#: ../../reference/import.rst:823 msgid "" "The ``find_module()`` method on path entry finders is deprecated, as it does " "not allow the path entry finder to contribute portions to namespace " @@ -1533,7 +1528,7 @@ msgstr "" "為命名空間套件只提供部分組成。若路徑條目尋檢器同時存在 ``find_loader()`` 與 " "``find_module()``,引入系統會一律優先呼叫 ``find_loader()``。" -#: ../../reference/import.rst:831 +#: ../../reference/import.rst:829 msgid "" "Calls to :meth:`!find_module` and :meth:`!find_loader` by the import system " "will raise :exc:`ImportWarning`." @@ -1541,15 +1536,15 @@ msgstr "" "引入系統對 :meth:`!find_module` 與 :meth:`!find_loader` 的呼叫將會引發 :exc:" "`ImportWarning`。" -#: ../../reference/import.rst:836 +#: ../../reference/import.rst:834 msgid "``find_module()`` and ``find_loader()`` have been removed." msgstr "``find_module()`` 和 ``find_loader()`` 已被移除。" -#: ../../reference/import.rst:841 +#: ../../reference/import.rst:839 msgid "Replacing the standard import system" msgstr "取代標準引入系統" -#: ../../reference/import.rst:843 +#: ../../reference/import.rst:841 msgid "" "The most reliable mechanism for replacing the entire import system is to " "delete the default contents of :data:`sys.meta_path`, replacing them " @@ -1558,7 +1553,7 @@ msgstr "" "取代整個引入系統最可靠的機制是刪除 :data:`sys.meta_path` 的預設內容,並以自訂" "的元路徑掛鉤完全取代它們。" -#: ../../reference/import.rst:847 +#: ../../reference/import.rst:845 msgid "" "If it is acceptable to only alter the behaviour of import statements without " "affecting other APIs that access the import system, then replacing the " @@ -1567,7 +1562,7 @@ msgstr "" "如果可以只改變 import 陳述式的行為,而不影響其他存取引入系統的 API,那麼替換" "內建的 :func:`__import__` 函式可能就足夠了。" -#: ../../reference/import.rst:851 +#: ../../reference/import.rst:849 msgid "" "To selectively prevent the import of some modules from a hook early on the " "meta path (rather than disabling the standard import system entirely), it is " @@ -1581,11 +1576,11 @@ msgstr "" "`ModuleNotFoundError`,而不是回傳 ``None`` 即可。後者表示元路徑搜尋應繼續,而" "引發例外則會立即終止。" -#: ../../reference/import.rst:861 +#: ../../reference/import.rst:859 msgid "Package Relative Imports" msgstr "套件相對引入" -#: ../../reference/import.rst:863 +#: ../../reference/import.rst:861 msgid "" "Relative imports use leading dots. A single leading dot indicates a relative " "import, starting with the current package. Two or more leading dots indicate " @@ -1596,7 +1591,7 @@ msgstr "" "導點號表示相對引入到目前套件的父層,第一個之後每多一個點號就往上一層。例如," "給定以下套件配置: ::" -#: ../../reference/import.rst:868 +#: ../../reference/import.rst:866 msgid "" "package/\n" " __init__.py\n" @@ -1620,7 +1615,7 @@ msgstr "" " moduleZ.py\n" " moduleA.py" -#: ../../reference/import.rst:879 +#: ../../reference/import.rst:877 msgid "" "In either ``subpackage1/moduleX.py`` or ``subpackage1/__init__.py``, the " "following are valid relative imports::" @@ -1628,7 +1623,7 @@ msgstr "" "在 ``subpackage1/moduleX.py`` 或 ``subpackage1/__init__.py`` 中,以下皆為有效" "的相對引入: ::" -#: ../../reference/import.rst:882 +#: ../../reference/import.rst:880 msgid "" "from .moduleY import spam\n" "from .moduleY import spam as ham\n" @@ -1644,7 +1639,7 @@ msgstr "" "from ..subpackage2.moduleZ import eggs\n" "from ..moduleA import foo" -#: ../../reference/import.rst:889 +#: ../../reference/import.rst:887 msgid "" "Absolute imports may use either the ``import <>`` or ``from <> import <>`` " "syntax, but relative imports may only use the second form; the reason for " @@ -1653,22 +1648,22 @@ msgstr "" "絕對引入可以使用 ``import <>`` 或 ``from <> import <>`` 語法,但相對引入只能" "使用第二種形式;原因是: ::" -#: ../../reference/import.rst:893 +#: ../../reference/import.rst:891 msgid "import XXX.YYY.ZZZ" msgstr "import XXX.YYY.ZZZ" -#: ../../reference/import.rst:895 +#: ../../reference/import.rst:893 msgid "" "should expose ``XXX.YYY.ZZZ`` as a usable expression, but .moduleY is not a " "valid expression." msgstr "" "應該要將 ``XXX.YYY.ZZZ`` 作為可用的運算式公開,但 .moduleY 不是有效的運算式。" -#: ../../reference/import.rst:902 +#: ../../reference/import.rst:900 msgid "Special considerations for __main__" msgstr "__main__ 的特殊考量" -#: ../../reference/import.rst:904 +#: ../../reference/import.rst:902 msgid "" "The :mod:`__main__` module is a special case relative to Python's import " "system. As noted :ref:`elsewhere `, the ``__main__`` module is " @@ -1684,11 +1679,11 @@ msgstr "" "組。這是因為 ``__main__`` 的初始化方式取決於呼叫直譯器時使用的旗標與其他選" "項。" -#: ../../reference/import.rst:915 +#: ../../reference/import.rst:913 msgid "__main__.__spec__" msgstr "__main__.__spec__" -#: ../../reference/import.rst:917 +#: ../../reference/import.rst:915 msgid "" "Depending on how :mod:`__main__` is initialized, ``__main__.__spec__`` gets " "set appropriately or to ``None``." @@ -1696,7 +1691,7 @@ msgstr "" "視 :mod:`__main__` 的初始化方式而定,``__main__.__spec__`` 會被適當設定,或設" "為 ``None``。" -#: ../../reference/import.rst:920 +#: ../../reference/import.rst:918 msgid "" "When Python is started with the :option:`-m` option, ``__spec__`` is set to " "the module spec of the corresponding module or package. ``__spec__`` is also " @@ -1707,7 +1702,7 @@ msgstr "" "組規格。當 ``__main__`` 模組作為執行目錄、zipfile 或其他 :data:`sys.path` 條" "目的一部分而被載入時,``__spec__`` 也會被填入。" -#: ../../reference/import.rst:925 +#: ../../reference/import.rst:923 msgid "" "In :ref:`the remaining cases ` ``__main__." "__spec__`` is set to ``None``, as the code used to populate the :mod:" @@ -1717,23 +1712,23 @@ msgstr "" "被設為 ``None``,因為用來填入 :mod:`__main__` 的程式碼並不直接對應可引入的模" "組:" -#: ../../reference/import.rst:929 +#: ../../reference/import.rst:927 msgid "interactive prompt" msgstr "互動式提示字元" -#: ../../reference/import.rst:930 +#: ../../reference/import.rst:928 msgid ":option:`-c` option" msgstr ":option:`-c` 選項" -#: ../../reference/import.rst:931 +#: ../../reference/import.rst:929 msgid "running from stdin" msgstr "從 stdin 執行" -#: ../../reference/import.rst:932 +#: ../../reference/import.rst:930 msgid "running directly from a source or bytecode file" msgstr "直接從原始碼或位元組碼檔案執行" -#: ../../reference/import.rst:934 +#: ../../reference/import.rst:932 msgid "" "Note that ``__main__.__spec__`` is always ``None`` in the last case, *even " "if* the file could technically be imported directly as a module instead. Use " @@ -1744,7 +1739,7 @@ msgstr "" "案在技術上可直接作為模組引入也一樣。若希望在 :mod:`__main__` 中取得有效的模組" "詮釋資料,請使用 :option:`-m` 選項。" -#: ../../reference/import.rst:939 +#: ../../reference/import.rst:937 msgid "" "Note also that even when ``__main__`` corresponds with an importable module " "and ``__main__.__spec__`` is set accordingly, they're still considered " @@ -1757,11 +1752,11 @@ msgstr "" "\"__main__\":`` 檢查所包住的程式碼區塊,只會在該模組用來填入 ``__main__`` 命" "名空間時執行,而不會在一般引入時執行。" -#: ../../reference/import.rst:947 +#: ../../reference/import.rst:945 msgid "References" msgstr "參考資料" -#: ../../reference/import.rst:949 +#: ../../reference/import.rst:947 msgid "" "The import machinery has evolved considerably since Python's early days. " "The original `specification for packages `_ 仍可閱讀,儘管自該文件撰寫以來部分細節已有" "所變更。" -#: ../../reference/import.rst:954 +#: ../../reference/import.rst:952 msgid "" "The original specification for :data:`sys.meta_path` was :pep:`302`, with " "subsequent extension in :pep:`420`." msgstr "" ":data:`sys.meta_path` 的原始規格是 :pep:`302`,後續在 :pep:`420` 中擴充。" -#: ../../reference/import.rst:957 +#: ../../reference/import.rst:955 msgid "" ":pep:`420` introduced :term:`namespace packages ` for " "Python 3.3. :pep:`420` also introduced the :meth:`!find_loader` protocol as " @@ -1789,13 +1784,13 @@ msgstr "" "pep:`420` 也引進了 :meth:`!find_loader` 協定,作為 :meth:`!find_module` 的替" "代方案。" -#: ../../reference/import.rst:961 +#: ../../reference/import.rst:959 msgid "" ":pep:`366` describes the addition of the ``__package__`` attribute for " "explicit relative imports in main modules." msgstr ":pep:`366` 描述了為主模組中的明確相對引入新增 ``__package__`` 屬性。" -#: ../../reference/import.rst:964 +#: ../../reference/import.rst:962 msgid "" ":pep:`328` introduced absolute and explicit relative imports and initially " "proposed ``__name__`` for semantics :pep:`366` would eventually specify for " @@ -1804,11 +1799,11 @@ msgstr "" ":pep:`328` 引進了絕對引入與明確的相對引入,並最初提出以 ``__name__`` 來表示 :" "pep:`366` 最終為 ``__package__`` 指定的語意。" -#: ../../reference/import.rst:968 +#: ../../reference/import.rst:966 msgid ":pep:`338` defines executing modules as scripts." msgstr ":pep:`338` 定義了將模組作為腳本執行。" -#: ../../reference/import.rst:970 +#: ../../reference/import.rst:968 msgid "" ":pep:`451` adds the encapsulation of per-module import state in spec " "objects. It also off-loads most of the boilerplate responsibilities of " @@ -1820,15 +1815,15 @@ msgstr "" "板責任移回引入機制。這些變更讓引入系統中的多個 API 得以棄用,並新增尋檢器與載" "入器的方法。" -#: ../../reference/import.rst:977 +#: ../../reference/import.rst:975 msgid "Footnotes" msgstr "註解" -#: ../../reference/import.rst:978 +#: ../../reference/import.rst:976 msgid "See :class:`types.ModuleType`." msgstr "參閱 :class:`types.ModuleType`。" -#: ../../reference/import.rst:980 +#: ../../reference/import.rst:978 msgid "" "The importlib implementation avoids using the return value directly. " "Instead, it gets the module object by looking the module name up in :data:" @@ -1913,23 +1908,23 @@ msgstr "sys.meta_path" msgid "find_spec" msgstr "find_spec" -#: ../../reference/import.rst:650 +#: ../../reference/import.rst:648 msgid "path based finder" msgstr "path based finder(基於路徑的搜尋器)" -#: ../../reference/import.rst:699 +#: ../../reference/import.rst:697 msgid "sys.path" msgstr "sys.path" -#: ../../reference/import.rst:699 +#: ../../reference/import.rst:697 msgid "sys.path_hooks" msgstr "sys.path_hooks" -#: ../../reference/import.rst:699 +#: ../../reference/import.rst:697 msgid "sys.path_importer_cache" msgstr "sys.path_importer_cache" -#: ../../reference/import.rst:699 +#: ../../reference/import.rst:697 msgid "PYTHONPATH" msgstr "PYTHONPATH" diff --git a/reference/lexical_analysis.po b/reference/lexical_analysis.po index 8475248149b..509a053d44e 100644 --- a/reference/lexical_analysis.po +++ b/reference/lexical_analysis.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-04-05 00:23+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -650,82 +650,90 @@ msgstr "" msgid "``type``, when used in the :keyword:`type` statement." msgstr "" -#: ../../reference/lexical_analysis.rst:461 +#: ../../reference/lexical_analysis.rst:460 +msgid "``lazy``, when used before an :keyword:`import` statement." +msgstr "" + +#: ../../reference/lexical_analysis.rst:462 msgid "" "These syntactically act as keywords in their specific contexts, but this " "distinction is done at the parser level, not when tokenizing." msgstr "" -#: ../../reference/lexical_analysis.rst:464 +#: ../../reference/lexical_analysis.rst:465 msgid "" "As soft keywords, their use in the grammar is possible while still " "preserving compatibility with existing code that uses these names as " "identifier names." msgstr "" -#: ../../reference/lexical_analysis.rst:468 +#: ../../reference/lexical_analysis.rst:469 msgid "``type`` is now a soft keyword." msgstr "``type`` 現在是軟關鍵字。" -#: ../../reference/lexical_analysis.rst:477 +#: ../../reference/lexical_analysis.rst:472 +msgid "``lazy`` is now a soft keyword." +msgstr "``lazy`` 現在是軟關鍵字。" + +#: ../../reference/lexical_analysis.rst:481 msgid "Reserved classes of identifiers" msgstr "" -#: ../../reference/lexical_analysis.rst:479 +#: ../../reference/lexical_analysis.rst:483 msgid "" "Certain classes of identifiers (besides keywords) have special meanings. " "These classes are identified by the patterns of leading and trailing " "underscore characters:" msgstr "" -#: ../../reference/lexical_analysis.rst:483 +#: ../../reference/lexical_analysis.rst:487 msgid "``_*``" msgstr "``_*``" -#: ../../reference/lexical_analysis.rst:484 +#: ../../reference/lexical_analysis.rst:488 msgid "Not imported by ``from module import *``." msgstr "" -#: ../../reference/lexical_analysis.rst:486 +#: ../../reference/lexical_analysis.rst:490 msgid "``_``" msgstr "``_``" -#: ../../reference/lexical_analysis.rst:487 +#: ../../reference/lexical_analysis.rst:491 msgid "" "In a ``case`` pattern within a :keyword:`match` statement, ``_`` is a :ref:" "`soft keyword ` that denotes a :ref:`wildcard `." msgstr "" -#: ../../reference/lexical_analysis.rst:491 +#: ../../reference/lexical_analysis.rst:495 msgid "" "Separately, the interactive interpreter makes the result of the last " "evaluation available in the variable ``_``. (It is stored in the :mod:" "`builtins` module, alongside built-in functions like ``print``.)" msgstr "" -#: ../../reference/lexical_analysis.rst:496 +#: ../../reference/lexical_analysis.rst:500 msgid "" "Elsewhere, ``_`` is a regular identifier. It is often used to name " "\"special\" items, but it is not special to Python itself." msgstr "" -#: ../../reference/lexical_analysis.rst:501 +#: ../../reference/lexical_analysis.rst:505 msgid "" "The name ``_`` is often used in conjunction with internationalization; refer " "to the documentation for the :mod:`gettext` module for more information on " "this convention." msgstr "" -#: ../../reference/lexical_analysis.rst:505 +#: ../../reference/lexical_analysis.rst:509 msgid "It is also commonly used for unused variables." msgstr "" -#: ../../reference/lexical_analysis.rst:507 +#: ../../reference/lexical_analysis.rst:511 msgid "``__*__``" msgstr "``__*__``" -#: ../../reference/lexical_analysis.rst:508 +#: ../../reference/lexical_analysis.rst:512 msgid "" "System-defined names, informally known as \"dunder\" names. These names are " "defined by the interpreter and its implementation (including the standard " @@ -735,11 +743,11 @@ msgid "" "explicitly documented use, is subject to breakage without warning." msgstr "" -#: ../../reference/lexical_analysis.rst:515 +#: ../../reference/lexical_analysis.rst:519 msgid "``__*``" msgstr "``__*``" -#: ../../reference/lexical_analysis.rst:516 +#: ../../reference/lexical_analysis.rst:520 msgid "" "Class-private names. Names in this category, when used within the context " "of a class definition, are re-written to use a mangled form to help avoid " @@ -747,11 +755,11 @@ msgid "" "section :ref:`atom-identifiers`." msgstr "" -#: ../../reference/lexical_analysis.rst:525 +#: ../../reference/lexical_analysis.rst:529 msgid "Non-ASCII characters in names" msgstr "名稱中的非 ASCII 字元" -#: ../../reference/lexical_analysis.rst:527 +#: ../../reference/lexical_analysis.rst:531 msgid "" "Names that contain non-ASCII characters need additional normalization and " "validation beyond the rules and grammar explained :ref:`above " @@ -759,11 +767,11 @@ msgid "" "but ``r〰2``, ``€``, or ``🐍`` are not." msgstr "" -#: ../../reference/lexical_analysis.rst:533 +#: ../../reference/lexical_analysis.rst:537 msgid "This section explains the exact rules." msgstr "" -#: ../../reference/lexical_analysis.rst:535 +#: ../../reference/lexical_analysis.rst:539 msgid "" "All names are converted into the `normalization form`_ NFKC while parsing. " "This means that, for example, some typographic variants of characters are " @@ -771,14 +779,14 @@ msgid "" "to ``finalization``, so Python treats them as the same name::" msgstr "" -#: ../../reference/lexical_analysis.rst:540 +#: ../../reference/lexical_analysis.rst:544 msgid "" ">>> fiⁿₐˡᵢᶻₐᵗᵢᵒₙ = 3\n" ">>> finalization\n" "3" msgstr "" -#: ../../reference/lexical_analysis.rst:546 +#: ../../reference/lexical_analysis.rst:550 msgid "" "Normalization is done at the lexical level only. Run-time functions that " "take names as *strings* generally do not normalize their arguments. For " @@ -787,7 +795,7 @@ msgid "" "[\"fiⁿₐˡᵢᶻₐᵗᵢᵒₙ\"]``." msgstr "" -#: ../../reference/lexical_analysis.rst:553 +#: ../../reference/lexical_analysis.rst:557 msgid "" "Similarly to how ASCII-only names must contain only letters, digits and the " "underscore, and cannot start with a digit, a valid name must start with a " @@ -795,7 +803,7 @@ msgid "" "characters must be in the \"letter- and digit-like\" set ``xid_continue``." msgstr "" -#: ../../reference/lexical_analysis.rst:559 +#: ../../reference/lexical_analysis.rst:563 msgid "" "These sets are based on the *XID_Start* and *XID_Continue* sets as defined " "by the Unicode standard annex `UAX-31`_. Python's ``xid_start`` additionally " @@ -803,7 +811,7 @@ msgid "" "conform to `UAX-31`_." msgstr "" -#: ../../reference/lexical_analysis.rst:564 +#: ../../reference/lexical_analysis.rst:568 msgid "" "A non-normative listing of characters in the *XID_Start* and *XID_Continue* " "sets as defined by Unicode is available in the `DerivedCoreProperties.txt`_ " @@ -811,131 +819,131 @@ msgid "" "rules for the ``xid_*`` sets are given below." msgstr "" -#: ../../reference/lexical_analysis.rst:569 +#: ../../reference/lexical_analysis.rst:573 msgid "The set ``id_start`` is defined as the union of:" msgstr "" -#: ../../reference/lexical_analysis.rst:571 +#: ../../reference/lexical_analysis.rst:575 msgid "Unicode category ```` - uppercase letters (includes ``A`` to ``Z``)" msgstr "" -#: ../../reference/lexical_analysis.rst:572 +#: ../../reference/lexical_analysis.rst:576 msgid "Unicode category ```` - lowercase letters (includes ``a`` to ``z``)" msgstr "" -#: ../../reference/lexical_analysis.rst:573 +#: ../../reference/lexical_analysis.rst:577 msgid "Unicode category ```` - titlecase letters" msgstr "" -#: ../../reference/lexical_analysis.rst:574 +#: ../../reference/lexical_analysis.rst:578 msgid "Unicode category ```` - modifier letters" msgstr "" -#: ../../reference/lexical_analysis.rst:575 +#: ../../reference/lexical_analysis.rst:579 msgid "Unicode category ```` - other letters" msgstr "" -#: ../../reference/lexical_analysis.rst:576 +#: ../../reference/lexical_analysis.rst:580 msgid "Unicode category ```` - letter numbers" msgstr "" -#: ../../reference/lexical_analysis.rst:577 +#: ../../reference/lexical_analysis.rst:581 msgid "{``\"_\"``} - the underscore" msgstr "{``\"_\"``} - 底線" -#: ../../reference/lexical_analysis.rst:578 +#: ../../reference/lexical_analysis.rst:582 msgid "" "```` - an explicit set of characters in `PropList.txt`_ to " "support backwards compatibility" msgstr "" -#: ../../reference/lexical_analysis.rst:581 +#: ../../reference/lexical_analysis.rst:585 msgid "" "The set ``xid_start`` then closes this set under NFKC normalization, by " "removing all characters whose normalization is not of the form ``id_start " "id_continue*``." msgstr "" -#: ../../reference/lexical_analysis.rst:585 +#: ../../reference/lexical_analysis.rst:589 msgid "The set ``id_continue`` is defined as the union of:" msgstr "" -#: ../../reference/lexical_analysis.rst:587 +#: ../../reference/lexical_analysis.rst:591 msgid "``id_start`` (see above)" msgstr "" -#: ../../reference/lexical_analysis.rst:588 +#: ../../reference/lexical_analysis.rst:592 msgid "Unicode category ```` - decimal numbers (includes ``0`` to ``9``)" msgstr "" -#: ../../reference/lexical_analysis.rst:589 +#: ../../reference/lexical_analysis.rst:593 msgid "Unicode category ```` - connector punctuations" msgstr "" -#: ../../reference/lexical_analysis.rst:590 +#: ../../reference/lexical_analysis.rst:594 msgid "Unicode category ```` - nonspacing marks" msgstr "" -#: ../../reference/lexical_analysis.rst:591 +#: ../../reference/lexical_analysis.rst:595 msgid "Unicode category ```` - spacing combining marks" msgstr "" -#: ../../reference/lexical_analysis.rst:592 +#: ../../reference/lexical_analysis.rst:596 msgid "" "```` - another explicit set of characters in `PropList." "txt`_ to support backwards compatibility" msgstr "" -#: ../../reference/lexical_analysis.rst:595 +#: ../../reference/lexical_analysis.rst:599 msgid "Again, ``xid_continue`` closes this set under NFKC normalization." msgstr "" -#: ../../reference/lexical_analysis.rst:597 +#: ../../reference/lexical_analysis.rst:601 msgid "" "Unicode categories use the version of the Unicode Character Database as " "included in the :mod:`unicodedata` module." msgstr "" -#: ../../reference/lexical_analysis.rst:607 +#: ../../reference/lexical_analysis.rst:611 msgid ":pep:`3131` -- Supporting Non-ASCII Identifiers" msgstr "" -#: ../../reference/lexical_analysis.rst:608 +#: ../../reference/lexical_analysis.rst:612 msgid ":pep:`672` -- Unicode-related Security Considerations for Python" msgstr "" -#: ../../reference/lexical_analysis.rst:614 +#: ../../reference/lexical_analysis.rst:618 msgid "Literals" msgstr "" -#: ../../reference/lexical_analysis.rst:618 +#: ../../reference/lexical_analysis.rst:622 msgid "Literals are notations for constant values of some built-in types." msgstr "" -#: ../../reference/lexical_analysis.rst:620 +#: ../../reference/lexical_analysis.rst:624 msgid "" "In terms of lexical analysis, Python has :ref:`string, bytes ` and :" "ref:`numeric ` literals." msgstr "" -#: ../../reference/lexical_analysis.rst:623 +#: ../../reference/lexical_analysis.rst:627 msgid "" "Other \"literals\" are lexically denoted using :ref:`keywords ` " "(``None``, ``True``, ``False``) and the special :ref:`ellipsis token " "` (``...``)." msgstr "" -#: ../../reference/lexical_analysis.rst:634 +#: ../../reference/lexical_analysis.rst:638 msgid "String and Bytes literals" msgstr "" -#: ../../reference/lexical_analysis.rst:636 +#: ../../reference/lexical_analysis.rst:640 msgid "" "String literals are text enclosed in single quotes (``'``) or double quotes " "(``\"``). For example:" msgstr "" -#: ../../reference/lexical_analysis.rst:639 +#: ../../reference/lexical_analysis.rst:643 msgid "" "\"spam\"\n" "'eggs'" @@ -943,14 +951,14 @@ msgstr "" "\"spam\"\n" "'eggs'" -#: ../../reference/lexical_analysis.rst:644 +#: ../../reference/lexical_analysis.rst:648 msgid "" "The quote used to start the literal also terminates it, so a string literal " "can only contain the other quote (except with escape sequences, see below). " "For example:" msgstr "" -#: ../../reference/lexical_analysis.rst:648 +#: ../../reference/lexical_analysis.rst:652 msgid "" "'Say \"Hello\", please.'\n" "\"Don't do that!\"" @@ -958,13 +966,13 @@ msgstr "" "'Say \"Hello\", please.'\n" "\"Don't do that!\"" -#: ../../reference/lexical_analysis.rst:653 +#: ../../reference/lexical_analysis.rst:657 msgid "" "Except for this limitation, the choice of quote character (``'`` or ``\"``) " "does not affect how the literal is parsed." msgstr "" -#: ../../reference/lexical_analysis.rst:656 +#: ../../reference/lexical_analysis.rst:660 msgid "" "Inside a string literal, the backslash (``\\``) character introduces an :dfn:" "`escape sequence`, which has special meaning depending on the character " @@ -972,7 +980,7 @@ msgid "" "character, and does *not* end the string:" msgstr "" -#: ../../reference/lexical_analysis.rst:662 +#: ../../reference/lexical_analysis.rst:666 msgid "" ">>> print(\"Say \\\"Hello\\\" to everyone!\")\n" "Say \"Hello\" to everyone!" @@ -980,58 +988,58 @@ msgstr "" ">>> print(\"Say \\\"Hello\\\" to everyone!\")\n" "Say \"Hello\" to everyone!" -#: ../../reference/lexical_analysis.rst:667 +#: ../../reference/lexical_analysis.rst:671 msgid "" "See :ref:`escape sequences ` below for a full list of such " "sequences, and more details." msgstr "" -#: ../../reference/lexical_analysis.rst:676 +#: ../../reference/lexical_analysis.rst:680 msgid "Triple-quoted strings" msgstr "三引號字串" -#: ../../reference/lexical_analysis.rst:678 +#: ../../reference/lexical_analysis.rst:682 msgid "" "Strings can also be enclosed in matching groups of three single or double " "quotes. These are generally referred to as :dfn:`triple-quoted strings`::" msgstr "" -#: ../../reference/lexical_analysis.rst:682 +#: ../../reference/lexical_analysis.rst:686 msgid "\"\"\"This is a triple-quoted string.\"\"\"" msgstr "\"\"\"這是一個三引號字串。\"\"\"" -#: ../../reference/lexical_analysis.rst:684 +#: ../../reference/lexical_analysis.rst:688 msgid "" "In triple-quoted literals, unescaped quotes are allowed (and are retained), " "except that three unescaped quotes in a row terminate the literal, if they " "are of the same kind (``'`` or ``\"``) used at the start::" msgstr "" -#: ../../reference/lexical_analysis.rst:688 +#: ../../reference/lexical_analysis.rst:692 msgid "\"\"\"This string has \"quotes\" inside.\"\"\"" msgstr "\"\"\"這個字串裡面有 \"引號\"。\"\"\"" -#: ../../reference/lexical_analysis.rst:690 +#: ../../reference/lexical_analysis.rst:694 msgid "Unescaped newlines are also allowed and retained::" msgstr "" -#: ../../reference/lexical_analysis.rst:692 +#: ../../reference/lexical_analysis.rst:696 msgid "" "'''This triple-quoted string\n" "continues on the next line.'''" msgstr "" -#: ../../reference/lexical_analysis.rst:701 +#: ../../reference/lexical_analysis.rst:705 msgid "String prefixes" msgstr "" -#: ../../reference/lexical_analysis.rst:703 +#: ../../reference/lexical_analysis.rst:707 msgid "" "String literals can have an optional :dfn:`prefix` that influences how the " "content of the literal is parsed, for example:" msgstr "" -#: ../../reference/lexical_analysis.rst:706 +#: ../../reference/lexical_analysis.rst:710 msgid "" "b\"data\"\n" "f'{result=}'" @@ -1039,35 +1047,35 @@ msgstr "" "b\"data\"\n" "f'{result=}'" -#: ../../reference/lexical_analysis.rst:711 +#: ../../reference/lexical_analysis.rst:715 msgid "The allowed prefixes are:" msgstr "" -#: ../../reference/lexical_analysis.rst:713 +#: ../../reference/lexical_analysis.rst:717 msgid "``b``: :ref:`Bytes literal `" msgstr "" -#: ../../reference/lexical_analysis.rst:714 +#: ../../reference/lexical_analysis.rst:718 msgid "``r``: :ref:`Raw string `" msgstr "" -#: ../../reference/lexical_analysis.rst:715 +#: ../../reference/lexical_analysis.rst:719 msgid "``f``: :ref:`Formatted string literal ` (\"f-string\")" msgstr "" -#: ../../reference/lexical_analysis.rst:716 +#: ../../reference/lexical_analysis.rst:720 msgid "``t``: :ref:`Template string literal ` (\"t-string\")" msgstr "" -#: ../../reference/lexical_analysis.rst:717 +#: ../../reference/lexical_analysis.rst:721 msgid "``u``: No effect (allowed for backwards compatibility)" msgstr "" -#: ../../reference/lexical_analysis.rst:719 +#: ../../reference/lexical_analysis.rst:723 msgid "See the linked sections for details on each type." msgstr "" -#: ../../reference/lexical_analysis.rst:721 +#: ../../reference/lexical_analysis.rst:725 msgid "" "Prefixes are case-insensitive (for example, '``B``' works the same as " "'``b``'). The '``r``' prefix can be combined with '``f``', '``t``' or " @@ -1075,220 +1083,220 @@ msgid "" "are also valid prefixes." msgstr "" -#: ../../reference/lexical_analysis.rst:725 +#: ../../reference/lexical_analysis.rst:729 msgid "" "The ``'rb'`` prefix of raw bytes literals has been added as a synonym of " "``'br'``." msgstr "" -#: ../../reference/lexical_analysis.rst:729 +#: ../../reference/lexical_analysis.rst:733 msgid "" "Support for the unicode legacy literal (``u'value'``) was reintroduced to " "simplify the maintenance of dual Python 2.x and 3.x codebases. See :pep:" "`414` for more information." msgstr "" -#: ../../reference/lexical_analysis.rst:735 +#: ../../reference/lexical_analysis.rst:739 msgid "Formal grammar" msgstr "" -#: ../../reference/lexical_analysis.rst:737 +#: ../../reference/lexical_analysis.rst:741 msgid "" "String literals, except :ref:`\"f-strings\" ` and :ref:`\"t-" "strings\" `, are described by the following lexical definitions." msgstr "" -#: ../../reference/lexical_analysis.rst:741 +#: ../../reference/lexical_analysis.rst:745 msgid "" "These definitions use :ref:`negative lookaheads ` (``!" "``) to indicate that an ending quote ends the literal." msgstr "" -#: ../../reference/lexical_analysis.rst:759 +#: ../../reference/lexical_analysis.rst:763 msgid "" "Note that as in all lexical definitions, whitespace is significant. In " "particular, the prefix (if any) must be immediately followed by the starting " "quote." msgstr "" -#: ../../reference/lexical_analysis.rst:781 +#: ../../reference/lexical_analysis.rst:785 msgid "Escape sequences" msgstr "跳脫序列" -#: ../../reference/lexical_analysis.rst:783 +#: ../../reference/lexical_analysis.rst:787 msgid "" "Unless an '``r``' or '``R``' prefix is present, escape sequences in string " "and bytes literals are interpreted according to rules similar to those used " "by Standard C. The recognized escape sequences are:" msgstr "" -#: ../../reference/lexical_analysis.rst:791 +#: ../../reference/lexical_analysis.rst:795 msgid "Escape Sequence" msgstr "" -#: ../../reference/lexical_analysis.rst:792 +#: ../../reference/lexical_analysis.rst:796 msgid "Meaning" msgstr "含義" -#: ../../reference/lexical_analysis.rst:793 +#: ../../reference/lexical_analysis.rst:797 msgid "``\\``\\ " msgstr "``\\``\\ " -#: ../../reference/lexical_analysis.rst:794 +#: ../../reference/lexical_analysis.rst:798 msgid ":ref:`string-escape-ignore`" msgstr ":ref:`string-escape-ignore`" -#: ../../reference/lexical_analysis.rst:795 +#: ../../reference/lexical_analysis.rst:799 msgid "``\\\\``" msgstr "``\\\\``" -#: ../../reference/lexical_analysis.rst:796 +#: ../../reference/lexical_analysis.rst:800 msgid ":ref:`Backslash `" msgstr "" -#: ../../reference/lexical_analysis.rst:797 +#: ../../reference/lexical_analysis.rst:801 msgid "``\\'``" msgstr "``\\'``" -#: ../../reference/lexical_analysis.rst:798 +#: ../../reference/lexical_analysis.rst:802 msgid ":ref:`Single quote `" msgstr "" -#: ../../reference/lexical_analysis.rst:799 +#: ../../reference/lexical_analysis.rst:803 msgid "``\\\"``" msgstr "``\\\"``" -#: ../../reference/lexical_analysis.rst:800 +#: ../../reference/lexical_analysis.rst:804 msgid ":ref:`Double quote `" msgstr "" -#: ../../reference/lexical_analysis.rst:801 +#: ../../reference/lexical_analysis.rst:805 msgid "``\\a``" msgstr "``\\a``" -#: ../../reference/lexical_analysis.rst:802 +#: ../../reference/lexical_analysis.rst:806 msgid "ASCII Bell (BEL)" msgstr "" -#: ../../reference/lexical_analysis.rst:803 +#: ../../reference/lexical_analysis.rst:807 msgid "``\\b``" msgstr "``\\b``" -#: ../../reference/lexical_analysis.rst:804 +#: ../../reference/lexical_analysis.rst:808 msgid "ASCII Backspace (BS)" msgstr "" -#: ../../reference/lexical_analysis.rst:805 +#: ../../reference/lexical_analysis.rst:809 msgid "``\\f``" msgstr "``\\f``" -#: ../../reference/lexical_analysis.rst:806 +#: ../../reference/lexical_analysis.rst:810 msgid "ASCII Formfeed (FF)" msgstr "" -#: ../../reference/lexical_analysis.rst:807 +#: ../../reference/lexical_analysis.rst:811 msgid "``\\n``" msgstr "``\\n``" -#: ../../reference/lexical_analysis.rst:808 +#: ../../reference/lexical_analysis.rst:812 msgid "ASCII Linefeed (LF)" msgstr "" -#: ../../reference/lexical_analysis.rst:809 +#: ../../reference/lexical_analysis.rst:813 msgid "``\\r``" msgstr "``\\r``" -#: ../../reference/lexical_analysis.rst:810 +#: ../../reference/lexical_analysis.rst:814 msgid "ASCII Carriage Return (CR)" msgstr "" -#: ../../reference/lexical_analysis.rst:811 +#: ../../reference/lexical_analysis.rst:815 msgid "``\\t``" msgstr "``\\t``" -#: ../../reference/lexical_analysis.rst:812 +#: ../../reference/lexical_analysis.rst:816 msgid "ASCII Horizontal Tab (TAB)" msgstr "" -#: ../../reference/lexical_analysis.rst:813 +#: ../../reference/lexical_analysis.rst:817 msgid "``\\v``" msgstr "``\\v``" -#: ../../reference/lexical_analysis.rst:814 +#: ../../reference/lexical_analysis.rst:818 msgid "ASCII Vertical Tab (VT)" msgstr "" -#: ../../reference/lexical_analysis.rst:815 +#: ../../reference/lexical_analysis.rst:819 msgid ":samp:`\\\\\\\\{ooo}`" msgstr ":samp:`\\\\\\\\{ooo}`" -#: ../../reference/lexical_analysis.rst:816 +#: ../../reference/lexical_analysis.rst:820 msgid ":ref:`string-escape-oct`" msgstr ":ref:`string-escape-oct`" -#: ../../reference/lexical_analysis.rst:817 +#: ../../reference/lexical_analysis.rst:821 msgid ":samp:`\\\\x{hh}`" msgstr ":samp:`\\\\x{hh}`" -#: ../../reference/lexical_analysis.rst:818 +#: ../../reference/lexical_analysis.rst:822 msgid ":ref:`string-escape-hex`" msgstr ":ref:`string-escape-hex`" -#: ../../reference/lexical_analysis.rst:819 +#: ../../reference/lexical_analysis.rst:823 msgid ":samp:`\\\\N\\\\{{name}\\\\}`" msgstr ":samp:`\\\\N\\\\{{name}\\\\}`" -#: ../../reference/lexical_analysis.rst:820 +#: ../../reference/lexical_analysis.rst:824 msgid ":ref:`string-escape-named`" msgstr ":ref:`string-escape-named`" -#: ../../reference/lexical_analysis.rst:821 +#: ../../reference/lexical_analysis.rst:825 msgid ":samp:`\\\\u{xxxx}`" msgstr ":samp:`\\\\u{xxxx}`" -#: ../../reference/lexical_analysis.rst:822 -#: ../../reference/lexical_analysis.rst:824 +#: ../../reference/lexical_analysis.rst:826 +#: ../../reference/lexical_analysis.rst:828 msgid ":ref:`Hexadecimal Unicode character `" msgstr "" -#: ../../reference/lexical_analysis.rst:823 +#: ../../reference/lexical_analysis.rst:827 msgid ":samp:`\\\\U{xxxxxxxx}`" msgstr ":samp:`\\\\U{xxxxxxxx}`" -#: ../../reference/lexical_analysis.rst:829 +#: ../../reference/lexical_analysis.rst:833 msgid "Ignored end of line" msgstr "" -#: ../../reference/lexical_analysis.rst:831 +#: ../../reference/lexical_analysis.rst:835 msgid "A backslash can be added at the end of a line to ignore the newline::" msgstr "" -#: ../../reference/lexical_analysis.rst:833 +#: ../../reference/lexical_analysis.rst:837 msgid "" ">>> 'This string will not include \\\n" "... backslashes or newline characters.'\n" "'This string will not include backslashes or newline characters.'" msgstr "" -#: ../../reference/lexical_analysis.rst:837 +#: ../../reference/lexical_analysis.rst:841 msgid "" "The same result can be achieved using :ref:`triple-quoted strings " "`, or parentheses and :ref:`string literal concatenation `." msgstr "" -#: ../../reference/lexical_analysis.rst:843 +#: ../../reference/lexical_analysis.rst:847 msgid "Escaped characters" msgstr "跳脫字元" -#: ../../reference/lexical_analysis.rst:845 +#: ../../reference/lexical_analysis.rst:849 msgid "" "To include a backslash in a non-:ref:`raw ` Python string " "literal, it must be doubled. The ``\\\\`` escape sequence denotes a single " "backslash character::" msgstr "" -#: ../../reference/lexical_analysis.rst:849 +#: ../../reference/lexical_analysis.rst:853 msgid "" ">>> print('C:\\\\Program Files')\n" "C:\\Program Files" @@ -1296,13 +1304,13 @@ msgstr "" ">>> print('C:\\\\Program Files')\n" "C:\\Program Files" -#: ../../reference/lexical_analysis.rst:852 +#: ../../reference/lexical_analysis.rst:856 msgid "" "Similarly, the ``\\'`` and ``\\\"`` sequences denote the single and double " "quote character, respectively::" msgstr "" -#: ../../reference/lexical_analysis.rst:855 +#: ../../reference/lexical_analysis.rst:859 msgid "" ">>> print('\\' and \\\"')\n" "' and \"" @@ -1310,17 +1318,17 @@ msgstr "" ">>> print('\\' and \\\"')\n" "' and \"" -#: ../../reference/lexical_analysis.rst:861 +#: ../../reference/lexical_analysis.rst:865 msgid "Octal character" msgstr "八進位字元" -#: ../../reference/lexical_analysis.rst:863 +#: ../../reference/lexical_analysis.rst:867 msgid "" "The sequence :samp:`\\\\\\\\{ooo}` denotes a *character* with the octal " "(base 8) value *ooo*::" msgstr "" -#: ../../reference/lexical_analysis.rst:866 +#: ../../reference/lexical_analysis.rst:870 msgid "" ">>> '\\120'\n" "'P'" @@ -1328,41 +1336,41 @@ msgstr "" ">>> '\\120'\n" "'P'" -#: ../../reference/lexical_analysis.rst:869 +#: ../../reference/lexical_analysis.rst:873 msgid "Up to three octal digits (0 through 7) are accepted." msgstr "" -#: ../../reference/lexical_analysis.rst:871 -#: ../../reference/lexical_analysis.rst:896 +#: ../../reference/lexical_analysis.rst:875 +#: ../../reference/lexical_analysis.rst:900 msgid "" "In a bytes literal, *character* means a *byte* with the given value. In a " "string literal, it means a Unicode character with the given value." msgstr "" -#: ../../reference/lexical_analysis.rst:874 +#: ../../reference/lexical_analysis.rst:878 msgid "" "Octal escapes with value larger than ``0o377`` (255) produce a :exc:" "`DeprecationWarning`." msgstr "" -#: ../../reference/lexical_analysis.rst:878 +#: ../../reference/lexical_analysis.rst:882 msgid "" "Octal escapes with value larger than ``0o377`` (255) produce a :exc:" "`SyntaxWarning`. In a future Python version they will raise a :exc:" "`SyntaxError`." msgstr "" -#: ../../reference/lexical_analysis.rst:886 +#: ../../reference/lexical_analysis.rst:890 msgid "Hexadecimal character" msgstr "十六進位字元" -#: ../../reference/lexical_analysis.rst:888 +#: ../../reference/lexical_analysis.rst:892 msgid "" "The sequence :samp:`\\\\x{hh}` denotes a *character* with the hex (base 16) " "value *hh*::" msgstr "" -#: ../../reference/lexical_analysis.rst:891 +#: ../../reference/lexical_analysis.rst:895 msgid "" ">>> '\\x50'\n" "'P'" @@ -1370,21 +1378,21 @@ msgstr "" ">>> '\\x50'\n" "'P'" -#: ../../reference/lexical_analysis.rst:894 +#: ../../reference/lexical_analysis.rst:898 msgid "Unlike in Standard C, exactly two hex digits are required." msgstr "與標準 C 不同,這裡需要剛好兩個十六進位數字。" -#: ../../reference/lexical_analysis.rst:902 +#: ../../reference/lexical_analysis.rst:906 msgid "Named Unicode character" msgstr "" -#: ../../reference/lexical_analysis.rst:904 +#: ../../reference/lexical_analysis.rst:908 msgid "" "The sequence :samp:`\\\\N\\\\{{name}\\\\}` denotes a Unicode character with " "the given *name*::" msgstr "" -#: ../../reference/lexical_analysis.rst:907 +#: ../../reference/lexical_analysis.rst:911 msgid "" ">>> '\\N{LATIN CAPITAL LETTER P}'\n" "'P'\n" @@ -1396,23 +1404,23 @@ msgstr "" ">>> '\\N{SNAKE}'\n" "'🐍'" -#: ../../reference/lexical_analysis.rst:912 +#: ../../reference/lexical_analysis.rst:916 msgid "This sequence cannot appear in :ref:`bytes literals `." msgstr "" -#: ../../reference/lexical_analysis.rst:914 +#: ../../reference/lexical_analysis.rst:918 msgid "" -"Support for `name aliases `__ has been added." msgstr "" -"已新增對\\ `名稱別名 (name alias) `__\\ 的支援。" -#: ../../reference/lexical_analysis.rst:921 +#: ../../reference/lexical_analysis.rst:925 msgid "Hexadecimal Unicode characters" msgstr "十六進位 Unicode 字元" -#: ../../reference/lexical_analysis.rst:923 +#: ../../reference/lexical_analysis.rst:927 msgid "" "These sequences :samp:`\\\\u{xxxx}` and :samp:`\\\\U{xxxxxxxx}` denote the " "Unicode character with the given hex (base 16) value. Exactly four digits " @@ -1420,7 +1428,7 @@ msgid "" "latter can encode any Unicode character." msgstr "" -#: ../../reference/lexical_analysis.rst:929 +#: ../../reference/lexical_analysis.rst:933 msgid "" ">>> '\\u1234'\n" "'ሴ'\n" @@ -1432,21 +1440,21 @@ msgstr "" ">>> '\\U0001f40d'\n" "'🐍'" -#: ../../reference/lexical_analysis.rst:936 +#: ../../reference/lexical_analysis.rst:940 msgid "These sequences cannot appear in :ref:`bytes literals `." msgstr "" -#: ../../reference/lexical_analysis.rst:942 +#: ../../reference/lexical_analysis.rst:946 msgid "Unrecognized escape sequences" msgstr "無法辨識的跳脫序列" -#: ../../reference/lexical_analysis.rst:944 +#: ../../reference/lexical_analysis.rst:948 msgid "" "Unlike in Standard C, all unrecognized escape sequences are left in the " "string unchanged, that is, *the backslash is left in the result*::" msgstr "" -#: ../../reference/lexical_analysis.rst:947 +#: ../../reference/lexical_analysis.rst:951 msgid "" ">>> print('\\q')\n" "\\q\n" @@ -1458,28 +1466,28 @@ msgstr "" ">>> list('\\q')\n" "['\\\\', 'q']" -#: ../../reference/lexical_analysis.rst:952 +#: ../../reference/lexical_analysis.rst:956 msgid "" "Note that for bytes literals, the escape sequences only recognized in string " "literals (``\\N...``, ``\\u...``, ``\\U...``) fall into the category of " "unrecognized escapes." msgstr "" -#: ../../reference/lexical_analysis.rst:956 +#: ../../reference/lexical_analysis.rst:960 msgid "Unrecognized escape sequences produce a :exc:`DeprecationWarning`." msgstr "" -#: ../../reference/lexical_analysis.rst:959 +#: ../../reference/lexical_analysis.rst:963 msgid "" "Unrecognized escape sequences produce a :exc:`SyntaxWarning`. In a future " "Python version they will raise a :exc:`SyntaxError`." msgstr "" -#: ../../reference/lexical_analysis.rst:972 +#: ../../reference/lexical_analysis.rst:976 msgid "Bytes literals" msgstr "位元組常數" -#: ../../reference/lexical_analysis.rst:974 +#: ../../reference/lexical_analysis.rst:978 msgid "" ":dfn:`Bytes literals` are always prefixed with '``b``' or '``B``'; they " "produce an instance of the :class:`bytes` type instead of the :class:`str` " @@ -1488,7 +1496,7 @@ msgid "" "`string-escape-hex` or :ref:`string-escape-oct`):" msgstr "" -#: ../../reference/lexical_analysis.rst:980 +#: ../../reference/lexical_analysis.rst:984 msgid "" ">>> b'\\x89PNG\\r\\n\\x1a\\n'\n" "b'\\x89PNG\\r\\n\\x1a\\n'\n" @@ -1500,17 +1508,17 @@ msgstr "" ">>> list(b'\\x89PNG\\r\\n\\x1a\\n')\n" "[137, 80, 78, 71, 13, 10, 26, 10]" -#: ../../reference/lexical_analysis.rst:987 +#: ../../reference/lexical_analysis.rst:991 msgid "" "Similarly, a zero byte must be expressed using an escape sequence (typically " "``\\0`` or ``\\x00``)." msgstr "" -#: ../../reference/lexical_analysis.rst:998 +#: ../../reference/lexical_analysis.rst:1002 msgid "Raw string literals" msgstr "原始字串常數" -#: ../../reference/lexical_analysis.rst:1000 +#: ../../reference/lexical_analysis.rst:1004 msgid "" "Both string and bytes literals may optionally be prefixed with a letter " "'``r``' or '``R``'; such constructs are called :dfn:`raw string literals` " @@ -1519,7 +1527,7 @@ msgid "" "` are not treated specially:" msgstr "" -#: ../../reference/lexical_analysis.rst:1007 +#: ../../reference/lexical_analysis.rst:1011 msgid "" ">>> r'\\d{4}-\\d{2}-\\d{2}'\n" "'\\\\d{4}-\\\\d{2}-\\\\d{2}'" @@ -1527,7 +1535,7 @@ msgstr "" ">>> r'\\d{4}-\\d{2}-\\d{2}'\n" "'\\\\d{4}-\\\\d{2}-\\\\d{2}'" -#: ../../reference/lexical_analysis.rst:1012 +#: ../../reference/lexical_analysis.rst:1016 msgid "" "Even in a raw literal, quotes can be escaped with a backslash, but the " "backslash remains in the result; for example, ``r\"\\\"\"`` is a valid " @@ -1540,27 +1548,27 @@ msgid "" "continuation." msgstr "" -#: ../../reference/lexical_analysis.rst:1040 +#: ../../reference/lexical_analysis.rst:1044 msgid "f-strings" msgstr "f-string(f 字串)" -#: ../../reference/lexical_analysis.rst:1043 +#: ../../reference/lexical_analysis.rst:1047 msgid "" "The :keyword:`await` and :keyword:`async for` can be used in expressions " "within f-strings." msgstr "" -#: ../../reference/lexical_analysis.rst:1046 +#: ../../reference/lexical_analysis.rst:1050 msgid "Added the debug specifier (``=``)" msgstr "" -#: ../../reference/lexical_analysis.rst:1048 +#: ../../reference/lexical_analysis.rst:1052 msgid "" "Many restrictions on expressions within f-strings have been removed. " "Notably, nested strings, comments, and backslashes are now permitted." msgstr "" -#: ../../reference/lexical_analysis.rst:1052 +#: ../../reference/lexical_analysis.rst:1056 msgid "" "A :dfn:`formatted string literal` or :dfn:`f-string` is a string literal " "that is prefixed with '``f``' or '``F``'. Unlike other string literals, f-" @@ -1569,7 +1577,7 @@ msgid "" "which are evaluated at run time. For example::" msgstr "" -#: ../../reference/lexical_analysis.rst:1059 +#: ../../reference/lexical_analysis.rst:1063 msgid "" ">>> who = 'nobody'\n" ">>> nationality = 'Spanish'\n" @@ -1581,13 +1589,13 @@ msgstr "" ">>> f'{who.title()} expects the {nationality} Inquisition!'\n" "'Nobody expects the Spanish Inquisition!'" -#: ../../reference/lexical_analysis.rst:1064 +#: ../../reference/lexical_analysis.rst:1068 msgid "" "Any doubled curly braces (``{{`` or ``}}``) outside replacement fields are " "replaced with the corresponding single curly brace::" msgstr "" -#: ../../reference/lexical_analysis.rst:1067 +#: ../../reference/lexical_analysis.rst:1071 msgid "" ">>> print(f'{{...}}')\n" "{...}" @@ -1595,7 +1603,7 @@ msgstr "" ">>> print(f'{{...}}')\n" "{...}" -#: ../../reference/lexical_analysis.rst:1070 +#: ../../reference/lexical_analysis.rst:1074 msgid "" "Other characters outside replacement fields are treated like in ordinary " "string literals. This means that escape sequences are decoded (except when a " @@ -1603,7 +1611,7 @@ msgid "" "quoted f-strings::" msgstr "" -#: ../../reference/lexical_analysis.rst:1076 +#: ../../reference/lexical_analysis.rst:1080 msgid "" ">>> name = 'Galahad'\n" ">>> favorite_color = 'blue'\n" @@ -1617,7 +1625,7 @@ msgid "" "and the number of the counting shall be three." msgstr "" -#: ../../reference/lexical_analysis.rst:1087 +#: ../../reference/lexical_analysis.rst:1091 msgid "" "Expressions in formatted string literals are treated like regular Python " "expressions. Each expression is evaluated in the context where the formatted " @@ -1626,7 +1634,7 @@ msgid "" "must be surrounded by explicit parentheses::" msgstr "" -#: ../../reference/lexical_analysis.rst:1094 +#: ../../reference/lexical_analysis.rst:1098 msgid "" ">>> f'{(half := 1/2)}, {half * 42}'\n" "'0.5, 21.0'" @@ -1634,13 +1642,13 @@ msgstr "" ">>> f'{(half := 1/2)}, {half * 42}'\n" "'0.5, 21.0'" -#: ../../reference/lexical_analysis.rst:1097 +#: ../../reference/lexical_analysis.rst:1101 msgid "" "Reusing the outer f-string quoting type inside a replacement field is " "permitted::" msgstr "" -#: ../../reference/lexical_analysis.rst:1100 +#: ../../reference/lexical_analysis.rst:1104 msgid "" ">>> a = dict(x=2)\n" ">>> f\"abc {a[\"x\"]} def\"\n" @@ -1650,13 +1658,13 @@ msgstr "" ">>> f\"abc {a[\"x\"]} def\"\n" "'abc 2 def'" -#: ../../reference/lexical_analysis.rst:1104 +#: ../../reference/lexical_analysis.rst:1108 msgid "" "Backslashes are also allowed in replacement fields and are evaluated the " "same way as in any other context::" msgstr "" -#: ../../reference/lexical_analysis.rst:1107 +#: ../../reference/lexical_analysis.rst:1111 msgid "" ">>> a = [\"a\", \"b\", \"c\"]\n" ">>> print(f\"List a contains:\\n{\"\\n\".join(a)}\")\n" @@ -1672,11 +1680,11 @@ msgstr "" "b\n" "c" -#: ../../reference/lexical_analysis.rst:1114 +#: ../../reference/lexical_analysis.rst:1118 msgid "It is possible to nest f-strings::" msgstr "" -#: ../../reference/lexical_analysis.rst:1116 +#: ../../reference/lexical_analysis.rst:1120 msgid "" ">>> name = 'world'\n" ">>> f'Repeated:{f' hello {name}' * 3}'\n" @@ -1686,15 +1694,15 @@ msgstr "" ">>> f'Repeated:{f' hello {name}' * 3}'\n" "'Repeated: hello world hello world hello world'" -#: ../../reference/lexical_analysis.rst:1120 +#: ../../reference/lexical_analysis.rst:1124 msgid "Portable Python programs should not use more than 5 levels of nesting." msgstr "" -#: ../../reference/lexical_analysis.rst:1124 +#: ../../reference/lexical_analysis.rst:1128 msgid "CPython does not limit nesting of f-strings." msgstr "" -#: ../../reference/lexical_analysis.rst:1126 +#: ../../reference/lexical_analysis.rst:1130 msgid "" "Replacement expressions can contain newlines in both single-quoted and " "triple-quoted f-strings and they can contain comments. Everything that comes " @@ -1703,7 +1711,7 @@ msgid "" "in a different line:" msgstr "" -#: ../../reference/lexical_analysis.rst:1133 +#: ../../reference/lexical_analysis.rst:1137 msgid "" ">>> a = 2\n" ">>> f\"abc{a # This comment }\" continues until the end of the line\n" @@ -1711,31 +1719,31 @@ msgid "" "'abc5'" msgstr "" -#: ../../reference/lexical_analysis.rst:1140 +#: ../../reference/lexical_analysis.rst:1144 msgid "After the expression, replacement fields may optionally contain:" msgstr "" -#: ../../reference/lexical_analysis.rst:1142 +#: ../../reference/lexical_analysis.rst:1146 msgid "" "a *debug specifier* -- an equal sign (``=``), optionally surrounded by " "whitespace on one or both sides;" msgstr "" -#: ../../reference/lexical_analysis.rst:1144 +#: ../../reference/lexical_analysis.rst:1148 msgid "a *conversion specifier* -- ``!s``, ``!r`` or ``!a``; and/or" msgstr "" -#: ../../reference/lexical_analysis.rst:1145 +#: ../../reference/lexical_analysis.rst:1149 msgid "a *format specifier* prefixed with a colon (``:``)." msgstr "" -#: ../../reference/lexical_analysis.rst:1147 +#: ../../reference/lexical_analysis.rst:1151 msgid "" "See the :ref:`Standard Library section on f-strings ` for " "details on how these fields are evaluated." msgstr "" -#: ../../reference/lexical_analysis.rst:1150 +#: ../../reference/lexical_analysis.rst:1154 msgid "" "As that section explains, *format specifiers* are passed as the second " "argument to the :func:`format` function to format a replacement field value. " @@ -1743,7 +1751,7 @@ msgid "" "characters using the :ref:`Format Specification Mini-Language `::" msgstr "" -#: ../../reference/lexical_analysis.rst:1155 +#: ../../reference/lexical_analysis.rst:1159 msgid "" ">>> number = 14.3\n" ">>> f'{number:20.7f}'\n" @@ -1753,11 +1761,11 @@ msgstr "" ">>> f'{number:20.7f}'\n" "' 14.3000000'" -#: ../../reference/lexical_analysis.rst:1159 +#: ../../reference/lexical_analysis.rst:1163 msgid "Top-level format specifiers may include nested replacement fields::" msgstr "" -#: ../../reference/lexical_analysis.rst:1161 +#: ../../reference/lexical_analysis.rst:1165 msgid "" ">>> field_size = 20\n" ">>> precision = 7\n" @@ -1769,13 +1777,13 @@ msgstr "" ">>> f'{number:{field_size}.{precision}f}'\n" "' 14.3000000'" -#: ../../reference/lexical_analysis.rst:1166 +#: ../../reference/lexical_analysis.rst:1170 msgid "" "These nested fields may include their own conversion fields and :ref:`format " "specifiers `::" msgstr "" -#: ../../reference/lexical_analysis.rst:1169 +#: ../../reference/lexical_analysis.rst:1173 msgid "" ">>> number = 3\n" ">>> f'{number:{field_size}}'\n" @@ -1789,19 +1797,19 @@ msgstr "" ">>> f'{number:{field_size:05}}'\n" "'00000000000000000003'" -#: ../../reference/lexical_analysis.rst:1175 +#: ../../reference/lexical_analysis.rst:1179 msgid "" "However, these nested fields may not include more deeply nested replacement " "fields." msgstr "" -#: ../../reference/lexical_analysis.rst:1178 +#: ../../reference/lexical_analysis.rst:1182 msgid "" "Formatted string literals cannot be used as :term:`docstrings `, " "even if they do not include expressions::" msgstr "" -#: ../../reference/lexical_analysis.rst:1181 +#: ../../reference/lexical_analysis.rst:1185 msgid "" ">>> def foo():\n" "... f\"Not a docstring\"\n" @@ -1815,23 +1823,23 @@ msgstr "" ">>> print(foo.__doc__)\n" "None" -#: ../../reference/lexical_analysis.rst:1189 +#: ../../reference/lexical_analysis.rst:1193 msgid ":pep:`498` -- Literal String Interpolation" msgstr "" -#: ../../reference/lexical_analysis.rst:1190 +#: ../../reference/lexical_analysis.rst:1194 msgid ":pep:`701` -- Syntactic formalization of f-strings" msgstr "" -#: ../../reference/lexical_analysis.rst:1191 +#: ../../reference/lexical_analysis.rst:1195 msgid ":meth:`str.format`, which uses a related format string mechanism." msgstr "" -#: ../../reference/lexical_analysis.rst:1198 +#: ../../reference/lexical_analysis.rst:1202 msgid "t-strings" msgstr "t-string(t 字串)" -#: ../../reference/lexical_analysis.rst:1202 +#: ../../reference/lexical_analysis.rst:1206 msgid "" "A :dfn:`template string literal` or :dfn:`t-string` is a string literal that " "is prefixed with '``t``' or '``T``'. These strings follow the same syntax " @@ -1840,11 +1848,11 @@ msgid "" "`" msgstr "" -#: ../../reference/lexical_analysis.rst:1211 +#: ../../reference/lexical_analysis.rst:1215 msgid "Formal grammar for f-strings" msgstr "" -#: ../../reference/lexical_analysis.rst:1213 +#: ../../reference/lexical_analysis.rst:1217 msgid "" "F-strings are handled partly by the :term:`lexical analyzer`, which produces " "the tokens :py:data:`~token.FSTRING_START`, :py:data:`~token.FSTRING_MIDDLE` " @@ -1853,29 +1861,29 @@ msgid "" "CPython implementation detail." msgstr "" -#: ../../reference/lexical_analysis.rst:1219 +#: ../../reference/lexical_analysis.rst:1223 msgid "" "Correspondingly, the f-string grammar is a mix of :ref:`lexical and " "syntactic definitions `." msgstr "" -#: ../../reference/lexical_analysis.rst:1222 +#: ../../reference/lexical_analysis.rst:1226 msgid "Whitespace is significant in these situations:" msgstr "" -#: ../../reference/lexical_analysis.rst:1224 +#: ../../reference/lexical_analysis.rst:1228 msgid "" "There may be no whitespace in :py:data:`~token.FSTRING_START` (between the " "prefix and quote)." msgstr "" -#: ../../reference/lexical_analysis.rst:1226 +#: ../../reference/lexical_analysis.rst:1230 msgid "" "Whitespace in :py:data:`~token.FSTRING_MIDDLE` is part of the literal string " "contents." msgstr "" -#: ../../reference/lexical_analysis.rst:1228 +#: ../../reference/lexical_analysis.rst:1232 msgid "" "In ``fstring_replacement_field``, if ``f_debug_specifier`` is present, all " "whitespace after the opening brace until the ``f_debug_specifier``, as well " @@ -1883,50 +1891,50 @@ msgid "" "part of the expression." msgstr "" -#: ../../reference/lexical_analysis.rst:1235 +#: ../../reference/lexical_analysis.rst:1239 msgid "" "The expression is not handled in the tokenization phase; it is retrieved " "from the source code using locations of the ``{`` token and the token after " "``=``." msgstr "" -#: ../../reference/lexical_analysis.rst:1240 +#: ../../reference/lexical_analysis.rst:1244 msgid "" "The ``FSTRING_MIDDLE`` definition uses :ref:`negative lookaheads ` (``!``) to indicate special characters (backslash, newline, " "``{``, ``}``) and sequences (``f_quote``)." msgstr "" -#: ../../reference/lexical_analysis.rst:1281 +#: ../../reference/lexical_analysis.rst:1285 msgid "" "In the above grammar snippet, the ``f_quote`` and ``FSTRING_MIDDLE`` rules " "are context-sensitive -- they depend on the contents of ``FSTRING_START`` of " "the nearest enclosing ``fstring``." msgstr "" -#: ../../reference/lexical_analysis.rst:1285 +#: ../../reference/lexical_analysis.rst:1289 msgid "" "Constructing a more traditional formal grammar from this template is left as " "an exercise for the reader." msgstr "" -#: ../../reference/lexical_analysis.rst:1288 +#: ../../reference/lexical_analysis.rst:1292 msgid "" "The grammar for t-strings is identical to the one for f-strings, with *t* " "instead of *f* at the beginning of rule and token names and in the prefix." msgstr "" -#: ../../reference/lexical_analysis.rst:1302 +#: ../../reference/lexical_analysis.rst:1306 msgid "Numeric literals" msgstr "" -#: ../../reference/lexical_analysis.rst:1308 +#: ../../reference/lexical_analysis.rst:1312 msgid "" ":data:`~token.NUMBER` tokens represent numeric literals, of which there are " "three types: integers, floating-point numbers, and imaginary numbers." msgstr "" -#: ../../reference/lexical_analysis.rst:1316 +#: ../../reference/lexical_analysis.rst:1320 msgid "" "The numeric value of a numeric literal is the same as if it were passed as a " "string to the :class:`int`, :class:`float` or :class:`complex` class " @@ -1934,21 +1942,21 @@ msgid "" "constructors are also valid literals." msgstr "" -#: ../../reference/lexical_analysis.rst:1321 +#: ../../reference/lexical_analysis.rst:1325 msgid "" "Numeric literals do not include a sign; a phrase like ``-1`` is actually an " "expression composed of the unary operator '``-``' and the literal ``1``." msgstr "" -#: ../../reference/lexical_analysis.rst:1335 +#: ../../reference/lexical_analysis.rst:1339 msgid "Integer literals" msgstr "" -#: ../../reference/lexical_analysis.rst:1337 +#: ../../reference/lexical_analysis.rst:1341 msgid "Integer literals denote whole numbers. For example::" msgstr "" -#: ../../reference/lexical_analysis.rst:1339 +#: ../../reference/lexical_analysis.rst:1343 msgid "" "7\n" "3\n" @@ -1958,24 +1966,24 @@ msgstr "" "3\n" "2147483647" -#: ../../reference/lexical_analysis.rst:1343 +#: ../../reference/lexical_analysis.rst:1347 msgid "" "There is no limit for the length of integer literals apart from what can be " "stored in available memory::" msgstr "" -#: ../../reference/lexical_analysis.rst:1346 +#: ../../reference/lexical_analysis.rst:1350 msgid "7922816251426433759354395033679228162514264337593543950336" msgstr "7922816251426433759354395033679228162514264337593543950336" -#: ../../reference/lexical_analysis.rst:1348 +#: ../../reference/lexical_analysis.rst:1352 msgid "" "Underscores can be used to group digits for enhanced readability, and are " "ignored for determining the numeric value of the literal. For example, the " "following literals are equivalent::" msgstr "" -#: ../../reference/lexical_analysis.rst:1352 +#: ../../reference/lexical_analysis.rst:1356 msgid "" "100_000_000_000\n" "100000000000\n" @@ -1985,13 +1993,13 @@ msgstr "" "100000000000\n" "1_00_00_00_00_000" -#: ../../reference/lexical_analysis.rst:1356 +#: ../../reference/lexical_analysis.rst:1360 msgid "" "Underscores can only occur between digits. For example, ``_123``, ``321_``, " "and ``123__321`` are *not* valid literals." msgstr "" -#: ../../reference/lexical_analysis.rst:1359 +#: ../../reference/lexical_analysis.rst:1363 msgid "" "Integers can be specified in binary (base 2), octal (base 8), or hexadecimal " "(base 16) using the prefixes ``0b``, ``0o`` and ``0x``, respectively. " @@ -1999,7 +2007,7 @@ msgid "" "case-insensitive. For example::" msgstr "" -#: ../../reference/lexical_analysis.rst:1364 +#: ../../reference/lexical_analysis.rst:1368 msgid "" "0b100110111\n" "0b_1110_0101\n" @@ -2015,47 +2023,47 @@ msgstr "" "0xdeadbeef\n" "0xDead_Beef" -#: ../../reference/lexical_analysis.rst:1371 +#: ../../reference/lexical_analysis.rst:1375 msgid "" "An underscore can follow the base specifier. For example, ``0x_1f`` is a " "valid literal, but ``0_x1f`` and ``0x__1f`` are not." msgstr "" -#: ../../reference/lexical_analysis.rst:1375 +#: ../../reference/lexical_analysis.rst:1379 msgid "" "Leading zeros in a non-zero decimal number are not allowed. For example, " "``0123`` is not a valid literal. This is for disambiguation with C-style " "octal literals, which Python used before version 3.0." msgstr "" -#: ../../reference/lexical_analysis.rst:1380 +#: ../../reference/lexical_analysis.rst:1384 msgid "" "Formally, integer literals are described by the following lexical " "definitions:" msgstr "" -#: ../../reference/lexical_analysis.rst:1397 -#: ../../reference/lexical_analysis.rst:1461 +#: ../../reference/lexical_analysis.rst:1401 +#: ../../reference/lexical_analysis.rst:1465 msgid "Underscores are now allowed for grouping purposes in literals." msgstr "" -#: ../../reference/lexical_analysis.rst:1408 +#: ../../reference/lexical_analysis.rst:1412 msgid "Floating-point literals" msgstr "浮點數常數 (Floating-point literals)" -#: ../../reference/lexical_analysis.rst:1410 +#: ../../reference/lexical_analysis.rst:1414 msgid "" "Floating-point (float) literals, such as ``3.14`` or ``1.5``, denote :ref:" "`approximations of real numbers `." msgstr "" -#: ../../reference/lexical_analysis.rst:1413 +#: ../../reference/lexical_analysis.rst:1417 msgid "" "They consist of *integer* and *fraction* parts, each composed of decimal " "digits. The parts are separated by a decimal point, ``.``::" msgstr "" -#: ../../reference/lexical_analysis.rst:1416 +#: ../../reference/lexical_analysis.rst:1420 msgid "" "2.71828\n" "4.0" @@ -2063,19 +2071,19 @@ msgstr "" "2.71828\n" "4.0" -#: ../../reference/lexical_analysis.rst:1419 +#: ../../reference/lexical_analysis.rst:1423 msgid "" "Unlike in integer literals, leading zeros are allowed. For example, " "``077.010`` is legal, and denotes the same number as ``77.01``." msgstr "" -#: ../../reference/lexical_analysis.rst:1422 +#: ../../reference/lexical_analysis.rst:1426 msgid "" "As in integer literals, single underscores may occur between digits to help " "readability::" msgstr "" -#: ../../reference/lexical_analysis.rst:1425 +#: ../../reference/lexical_analysis.rst:1429 msgid "" "96_485.332_123\n" "3.14_15_93" @@ -2083,11 +2091,11 @@ msgstr "" "96_485.332_123\n" "3.14_15_93" -#: ../../reference/lexical_analysis.rst:1428 +#: ../../reference/lexical_analysis.rst:1432 msgid "Either of these parts, but not both, can be empty. For example::" msgstr "" -#: ../../reference/lexical_analysis.rst:1430 +#: ../../reference/lexical_analysis.rst:1434 msgid "" "10. # (equivalent to 10.0)\n" ".001 # (equivalent to 0.001)" @@ -2095,7 +2103,7 @@ msgstr "" "10. # (相當於 10.0)\n" ".001 # (相當於 0.001)" -#: ../../reference/lexical_analysis.rst:1433 +#: ../../reference/lexical_analysis.rst:1437 msgid "" "Optionally, the integer and fraction may be followed by an *exponent*: the " "letter ``e`` or ``E``, followed by an optional sign, ``+`` or ``-``, and a " @@ -2103,20 +2111,20 @@ msgid "" "``E`` represents \"times ten raised to the power of\"::" msgstr "" -#: ../../reference/lexical_analysis.rst:1438 +#: ../../reference/lexical_analysis.rst:1442 msgid "" "1.0e3 # (represents 1.0×10³, or 1000.0)\n" "1.166e-5 # (represents 1.166×10⁻⁵, or 0.00001166)\n" "6.02214076e+23 # (represents 6.02214076×10²³, or 602214076000000000000000.)" msgstr "" -#: ../../reference/lexical_analysis.rst:1442 +#: ../../reference/lexical_analysis.rst:1446 msgid "" "In floats with only integer and exponent parts, the decimal point may be " "omitted::" msgstr "" -#: ../../reference/lexical_analysis.rst:1445 +#: ../../reference/lexical_analysis.rst:1449 msgid "" "1e3 # (equivalent to 1.e3 and 1.0e3)\n" "0e0 # (equivalent to 0.)" @@ -2124,35 +2132,35 @@ msgstr "" "1e3 # (相當於 1.e3 和 1.0e3)\n" "0e0 # (相當於 0.)" -#: ../../reference/lexical_analysis.rst:1448 +#: ../../reference/lexical_analysis.rst:1452 msgid "" "Formally, floating-point literals are described by the following lexical " "definitions:" msgstr "" -#: ../../reference/lexical_analysis.rst:1470 +#: ../../reference/lexical_analysis.rst:1474 msgid "Imaginary literals" msgstr "" -#: ../../reference/lexical_analysis.rst:1472 +#: ../../reference/lexical_analysis.rst:1476 msgid "" "Python has :ref:`complex number ` objects, but no complex " "literals. Instead, *imaginary literals* denote complex numbers with a zero " "real part." msgstr "" -#: ../../reference/lexical_analysis.rst:1477 +#: ../../reference/lexical_analysis.rst:1481 msgid "" "For example, in math, the complex number 3+4.2\\ *i* is written as the real " "number 3 added to the imaginary number 4.2\\ *i*. Python uses a similar " "syntax, except the imaginary unit is written as ``j`` rather than *i*::" msgstr "" -#: ../../reference/lexical_analysis.rst:1482 +#: ../../reference/lexical_analysis.rst:1486 msgid "3+4.2j" msgstr "3+4.2j" -#: ../../reference/lexical_analysis.rst:1484 +#: ../../reference/lexical_analysis.rst:1488 msgid "" "This is an expression composed of the :ref:`integer literal ` " "``3``, the :ref:`operator ` '``+``', and the :ref:`imaginary " @@ -2160,23 +2168,23 @@ msgid "" "whitespace is allowed between them::" msgstr "" -#: ../../reference/lexical_analysis.rst:1490 +#: ../../reference/lexical_analysis.rst:1494 msgid "3 + 4.2j" msgstr "3 + 4.2j" -#: ../../reference/lexical_analysis.rst:1492 +#: ../../reference/lexical_analysis.rst:1496 msgid "" "No whitespace is allowed *within* each token. In particular, the ``j`` " "suffix, may not be separated from the number before it." msgstr "" -#: ../../reference/lexical_analysis.rst:1496 +#: ../../reference/lexical_analysis.rst:1500 msgid "" "The number before the ``j`` has the same syntax as a floating-point literal. " "Thus, the following are valid imaginary literals::" msgstr "" -#: ../../reference/lexical_analysis.rst:1499 +#: ../../reference/lexical_analysis.rst:1503 msgid "" "4.2j\n" "3.14j\n" @@ -2194,14 +2202,14 @@ msgstr "" "3.14e-10j\n" "3.14_15_93j" -#: ../../reference/lexical_analysis.rst:1507 +#: ../../reference/lexical_analysis.rst:1511 msgid "" "Unlike in a floating-point literal the decimal point can be omitted if the " "imaginary number only has an integer part. The number is still evaluated as " "a floating-point number, not an integer::" msgstr "" -#: ../../reference/lexical_analysis.rst:1511 +#: ../../reference/lexical_analysis.rst:1515 msgid "" "10j\n" "0j\n" @@ -2211,26 +2219,26 @@ msgstr "" "0j\n" "1000000000000000000000000j # 相當於 1e+24j" -#: ../../reference/lexical_analysis.rst:1515 +#: ../../reference/lexical_analysis.rst:1519 msgid "" "The ``j`` suffix is case-insensitive. That means you can use ``J`` instead::" msgstr "" -#: ../../reference/lexical_analysis.rst:1518 +#: ../../reference/lexical_analysis.rst:1522 msgid "3.14J # equivalent to 3.14j" msgstr "" -#: ../../reference/lexical_analysis.rst:1520 +#: ../../reference/lexical_analysis.rst:1524 msgid "" "Formally, imaginary literals are described by the following lexical " "definition:" msgstr "" -#: ../../reference/lexical_analysis.rst:1533 +#: ../../reference/lexical_analysis.rst:1537 msgid "Operators and delimiters" msgstr "" -#: ../../reference/lexical_analysis.rst:1539 +#: ../../reference/lexical_analysis.rst:1543 msgid "" "The following grammar defines :dfn:`operator` and :dfn:`delimiter` tokens, " "that is, the generic :data:`~token.OP` token type. A :ref:`list of these " @@ -2238,14 +2246,14 @@ msgid "" "the :mod:`!token` module documentation." msgstr "" -#: ../../reference/lexical_analysis.rst:1568 +#: ../../reference/lexical_analysis.rst:1572 msgid "" "Generally, *operators* are used to combine :ref:`expressions `, " "while *delimiters* serve other purposes. However, there is no clear, formal " "distinction between the two categories." msgstr "" -#: ../../reference/lexical_analysis.rst:1572 +#: ../../reference/lexical_analysis.rst:1576 msgid "" "Some tokens can serve as either operators or delimiters, depending on usage. " "For example, ``*`` is both the multiplication operator and a delimiter used " @@ -2253,20 +2261,20 @@ msgid "" "delimiter that introduces decorators." msgstr "" -#: ../../reference/lexical_analysis.rst:1577 +#: ../../reference/lexical_analysis.rst:1581 msgid "" "For some tokens, the distinction is unclear. For example, some people " "consider ``.``, ``(``, and ``)`` to be delimiters, while others see the :py:" "func:`getattr` operator and the function call operator(s)." msgstr "" -#: ../../reference/lexical_analysis.rst:1581 +#: ../../reference/lexical_analysis.rst:1585 msgid "" "Some of Python's operators, like ``and``, ``or``, and ``not in``, use :ref:" "`keyword ` tokens rather than \"symbols\" (operator tokens)." msgstr "" -#: ../../reference/lexical_analysis.rst:1584 +#: ../../reference/lexical_analysis.rst:1588 msgid "" "A sequence of three consecutive periods (``...``) has a special meaning as " "an :py:data:`Ellipsis` literal." @@ -2294,7 +2302,7 @@ msgstr "logical line(邏輯列)" #: ../../reference/lexical_analysis.rst:100 #: ../../reference/lexical_analysis.rst:205 -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "physical line" msgstr "physical line(物理列)" @@ -2389,294 +2397,294 @@ msgstr "reserved word(保留字)" msgid "soft keyword" msgstr "soft keyword(軟關鍵字)" -#: ../../reference/lexical_analysis.rst:471 +#: ../../reference/lexical_analysis.rst:475 msgid "_, identifiers" msgstr "_, identifiers(識別器)" -#: ../../reference/lexical_analysis.rst:471 +#: ../../reference/lexical_analysis.rst:475 msgid "__, identifiers" msgstr "__, identifiers(識別器)" -#: ../../reference/lexical_analysis.rst:616 +#: ../../reference/lexical_analysis.rst:620 msgid "literal" msgstr "literal(常數)" -#: ../../reference/lexical_analysis.rst:616 +#: ../../reference/lexical_analysis.rst:620 msgid "constant" msgstr "constant(常數)" -#: ../../reference/lexical_analysis.rst:628 -#: ../../reference/lexical_analysis.rst:671 -#: ../../reference/lexical_analysis.rst:696 +#: ../../reference/lexical_analysis.rst:632 +#: ../../reference/lexical_analysis.rst:675 +#: ../../reference/lexical_analysis.rst:700 msgid "string literal" msgstr "string literal(字串常數)" -#: ../../reference/lexical_analysis.rst:628 -#: ../../reference/lexical_analysis.rst:964 +#: ../../reference/lexical_analysis.rst:632 +#: ../../reference/lexical_analysis.rst:968 msgid "bytes literal" msgstr "bytes literal(位元組常數)" -#: ../../reference/lexical_analysis.rst:628 +#: ../../reference/lexical_analysis.rst:632 msgid "ASCII" msgstr "ASCII" -#: ../../reference/lexical_analysis.rst:628 +#: ../../reference/lexical_analysis.rst:632 msgid "' (single quote)" msgstr "' (單引號)" -#: ../../reference/lexical_analysis.rst:628 +#: ../../reference/lexical_analysis.rst:632 msgid "\" (double quote)" msgstr "\" (雙引號)" -#: ../../reference/lexical_analysis.rst:671 +#: ../../reference/lexical_analysis.rst:675 msgid "triple-quoted string" msgstr "triple-quoted string(三引號字串)" -#: ../../reference/lexical_analysis.rst:671 +#: ../../reference/lexical_analysis.rst:675 msgid "\"\"\"" msgstr "\"\"\"" -#: ../../reference/lexical_analysis.rst:671 +#: ../../reference/lexical_analysis.rst:675 msgid "'''" msgstr "'''" -#: ../../reference/lexical_analysis.rst:696 +#: ../../reference/lexical_analysis.rst:700 msgid "u'" msgstr "u'" -#: ../../reference/lexical_analysis.rst:696 +#: ../../reference/lexical_analysis.rst:700 msgid "u\"" msgstr "u\"" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "escape sequence" msgstr "escape sequence(跳脫序列)" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "Standard C" msgstr "Standard C(標準 C)" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "C" msgstr "C" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\ (backslash)" msgstr "\\ (反斜線)" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\\\" msgstr "\\\\" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\a" msgstr "\\a" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\b" msgstr "\\b" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\f" msgstr "\\f" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\n" msgstr "\\n" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\r" msgstr "\\r" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\t" msgstr "\\t" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\v" msgstr "\\v" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\x" msgstr "\\x" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\N" msgstr "\\N" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\u" msgstr "\\u" -#: ../../reference/lexical_analysis.rst:763 +#: ../../reference/lexical_analysis.rst:767 msgid "\\U" msgstr "\\U" -#: ../../reference/lexical_analysis.rst:939 +#: ../../reference/lexical_analysis.rst:943 msgid "unrecognized escape sequence" msgstr "unrecognized escape sequence(無法辨識的跳脫序列)" -#: ../../reference/lexical_analysis.rst:964 +#: ../../reference/lexical_analysis.rst:968 msgid "b'" msgstr "b'" -#: ../../reference/lexical_analysis.rst:964 +#: ../../reference/lexical_analysis.rst:968 msgid "b\"" msgstr "b\"" -#: ../../reference/lexical_analysis.rst:991 +#: ../../reference/lexical_analysis.rst:995 msgid "r'" msgstr "r'" -#: ../../reference/lexical_analysis.rst:991 +#: ../../reference/lexical_analysis.rst:995 msgid "raw string literal" msgstr "raw string literal(原始字串常數)" -#: ../../reference/lexical_analysis.rst:991 +#: ../../reference/lexical_analysis.rst:995 msgid "r\"" msgstr "r\"" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "formatted string literal" msgstr "formatted string literal(格式化字串常數)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "interpolated string literal" msgstr "interpolated string literal(插值字串常數)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "string" msgstr "string(字串)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "formatted literal" msgstr "formatted literal(格式化常數)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "interpolated literal" msgstr "interpolated literal(插值常數)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "f-string" msgstr "f-string(f 字串)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "fstring" msgstr "fstring(f 字串)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "f'" msgstr "f'" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "f\"" msgstr "f\"" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "{} (curly brackets)" msgstr "{} (花括號)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "in formatted string literal" msgstr "於格式化字串常數中" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "! (exclamation)" msgstr "! (驚嘆號)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid ": (colon)" msgstr ": (冒號)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "= (equals)" msgstr "= (等號)" -#: ../../reference/lexical_analysis.rst:1022 +#: ../../reference/lexical_analysis.rst:1026 msgid "for help in debugging using string literals" msgstr "for help in debugging using string literals(使用字串常數進行除錯)" -#: ../../reference/lexical_analysis.rst:1304 +#: ../../reference/lexical_analysis.rst:1308 msgid "number" msgstr "number(數字)" -#: ../../reference/lexical_analysis.rst:1304 +#: ../../reference/lexical_analysis.rst:1308 msgid "numeric literal" msgstr "numeric literal(數值常數)" -#: ../../reference/lexical_analysis.rst:1304 -#: ../../reference/lexical_analysis.rst:1326 +#: ../../reference/lexical_analysis.rst:1308 +#: ../../reference/lexical_analysis.rst:1330 msgid "integer literal" msgstr "integer literal(整數常數)" -#: ../../reference/lexical_analysis.rst:1304 +#: ../../reference/lexical_analysis.rst:1308 msgid "floating-point literal" msgstr "floating-point literal(浮點數常數)" -#: ../../reference/lexical_analysis.rst:1304 +#: ../../reference/lexical_analysis.rst:1308 msgid "hexadecimal literal" msgstr "hexadecimal literal(十六進位常數)" -#: ../../reference/lexical_analysis.rst:1304 +#: ../../reference/lexical_analysis.rst:1308 msgid "octal literal" msgstr "octal literal(八進位常數)" -#: ../../reference/lexical_analysis.rst:1304 +#: ../../reference/lexical_analysis.rst:1308 msgid "binary literal" msgstr "binary literal(二進位常數)" -#: ../../reference/lexical_analysis.rst:1304 +#: ../../reference/lexical_analysis.rst:1308 msgid "decimal literal" msgstr "decimal literal(十進位常數)" -#: ../../reference/lexical_analysis.rst:1304 +#: ../../reference/lexical_analysis.rst:1308 msgid "imaginary literal" msgstr "imaginary literal(虛數常數)" -#: ../../reference/lexical_analysis.rst:1304 +#: ../../reference/lexical_analysis.rst:1308 msgid "complex literal" msgstr "complex literal(複數常數)" -#: ../../reference/lexical_analysis.rst:1326 +#: ../../reference/lexical_analysis.rst:1330 msgid "0b" msgstr "0b" -#: ../../reference/lexical_analysis.rst:1326 +#: ../../reference/lexical_analysis.rst:1330 msgid "0o" msgstr "0o" -#: ../../reference/lexical_analysis.rst:1326 +#: ../../reference/lexical_analysis.rst:1330 msgid "0x" msgstr "0x" -#: ../../reference/lexical_analysis.rst:1326 -#: ../../reference/lexical_analysis.rst:1401 +#: ../../reference/lexical_analysis.rst:1330 +#: ../../reference/lexical_analysis.rst:1405 msgid "_ (underscore)" msgstr "_ (底線)" -#: ../../reference/lexical_analysis.rst:1326 -#: ../../reference/lexical_analysis.rst:1401 -#: ../../reference/lexical_analysis.rst:1465 +#: ../../reference/lexical_analysis.rst:1330 +#: ../../reference/lexical_analysis.rst:1405 +#: ../../reference/lexical_analysis.rst:1469 msgid "in numeric literal" msgstr "於數值常數中" -#: ../../reference/lexical_analysis.rst:1401 +#: ../../reference/lexical_analysis.rst:1405 msgid ". (dot)" msgstr ". (點)" -#: ../../reference/lexical_analysis.rst:1401 +#: ../../reference/lexical_analysis.rst:1405 msgid "e" msgstr "e" -#: ../../reference/lexical_analysis.rst:1465 +#: ../../reference/lexical_analysis.rst:1469 msgid "j" msgstr "j" -#: ../../reference/lexical_analysis.rst:1535 +#: ../../reference/lexical_analysis.rst:1539 msgid "operators" msgstr "operators(運算子)" -#: ../../reference/lexical_analysis.rst:1535 +#: ../../reference/lexical_analysis.rst:1539 msgid "delimiters" msgstr "delimiters(分隔符號)" diff --git a/reference/simple_stmts.po b/reference/simple_stmts.po index bc886e816f5..c8065989fe6 100644 --- a/reference/simple_stmts.po +++ b/reference/simple_stmts.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2026-02-27 16:17+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1041,17 +1041,17 @@ msgstr "" msgid "The :keyword:`!import` statement" msgstr ":keyword:`!import` 陳述式" -#: ../../reference/simple_stmts.rst:759 +#: ../../reference/simple_stmts.rst:760 msgid "" "The basic import statement (no :keyword:`from` clause) is executed in two " "steps:" msgstr "基本的 import 陳述式(不含 :keyword:`from` 子句)分兩個步驟執行:" -#: ../../reference/simple_stmts.rst:762 +#: ../../reference/simple_stmts.rst:763 msgid "find a module, loading and initializing it if necessary" msgstr "找到一個模組,如有必要則載入並初始化它" -#: ../../reference/simple_stmts.rst:763 +#: ../../reference/simple_stmts.rst:764 msgid "" "define a name or names in the current namespace for the scope where the :" "keyword:`import` statement occurs, just as an assignment statement would " @@ -1060,7 +1060,7 @@ msgstr "" "在 :keyword:`import` 陳述式出現的作用域中定義一個或多個名稱,就如同賦值陳述式" "一樣(包括 :keyword:`global` 和 :keyword:`nonlocal` 語意)。" -#: ../../reference/simple_stmts.rst:767 +#: ../../reference/simple_stmts.rst:768 msgid "" "When the statement contains multiple clauses (separated by commas) the two " "steps are carried out separately for each clause, just as though the clauses " @@ -1069,7 +1069,7 @@ msgstr "" "當陳述式包含多個子句(以逗號分隔)時,這兩個步驟會分別對每個子句執行,就像這" "些子句被分離成單獨的 import 陳述式一樣。" -#: ../../reference/simple_stmts.rst:772 +#: ../../reference/simple_stmts.rst:773 msgid "" "The details of the first step, finding and loading modules, are described in " "greater detail in the section on the :ref:`import system `, " @@ -1084,14 +1084,14 @@ msgstr "" "自訂引入系統的掛鉤 (hook)。請注意,此步驟的失敗可能表示找不到模組,\\ *或者" "*\\ 在初始化模組時發生錯誤,這包括執行模組的程式碼。" -#: ../../reference/simple_stmts.rst:780 +#: ../../reference/simple_stmts.rst:781 msgid "" "If the requested module is retrieved successfully, it will be made available " "in the local namespace in one of three ways:" msgstr "" "如果請求的模組被成功取得,它將透過以下三種方式之一在區域命名空間中可用:" -#: ../../reference/simple_stmts.rst:785 +#: ../../reference/simple_stmts.rst:786 msgid "" "If the module name is followed by :keyword:`!as`, then the name following :" "keyword:`!as` is bound directly to the imported module." @@ -1099,7 +1099,7 @@ msgstr "" "如果模組名稱後面跟著 :keyword:`!as`,則 :keyword:`!as` 後面的名稱會直接繫結到" "被引入的模組。" -#: ../../reference/simple_stmts.rst:787 +#: ../../reference/simple_stmts.rst:788 msgid "" "If no other name is specified, and the module being imported is a top level " "module, the module's name is bound in the local namespace as a reference to " @@ -1108,7 +1108,7 @@ msgstr "" "如果沒有指定其他名稱,且被引入的模組是頂層模組,則模組的名稱會在區域命名空間" "中繫結為被引入模組的參照" -#: ../../reference/simple_stmts.rst:790 +#: ../../reference/simple_stmts.rst:791 msgid "" "If the module being imported is *not* a top level module, then the name of " "the top level package that contains the module is bound in the local " @@ -1119,36 +1119,36 @@ msgstr "" "名空間中繫結為頂層套件的參照。被引入的模組必須使用其完整的限定名稱來存取,而" "不是直接存取" -#: ../../reference/simple_stmts.rst:800 +#: ../../reference/simple_stmts.rst:801 msgid "The :keyword:`from` form uses a slightly more complex process:" msgstr ":keyword:`from` 形式使用稍微複雜一點的過程:" -#: ../../reference/simple_stmts.rst:802 +#: ../../reference/simple_stmts.rst:803 msgid "" "find the module specified in the :keyword:`from` clause, loading and " "initializing it if necessary;" msgstr "找到 :keyword:`from` 子句中指定的模組,如有必要則載入並初始化它;" -#: ../../reference/simple_stmts.rst:804 +#: ../../reference/simple_stmts.rst:805 msgid "for each of the identifiers specified in the :keyword:`import` clauses:" msgstr "對於 :keyword:`import` 子句中指定的每個識別字:" -#: ../../reference/simple_stmts.rst:806 +#: ../../reference/simple_stmts.rst:807 msgid "check if the imported module has an attribute by that name" msgstr "檢查被引入的模組是否有該名稱的屬性" -#: ../../reference/simple_stmts.rst:807 +#: ../../reference/simple_stmts.rst:808 msgid "" "if not, attempt to import a submodule with that name and then check the " "imported module again for that attribute" msgstr "" "如果沒有,嘗試引入具有該名稱的子模組,然後再次檢查被引入的模組是否有該屬性" -#: ../../reference/simple_stmts.rst:809 +#: ../../reference/simple_stmts.rst:810 msgid "if the attribute is not found, :exc:`ImportError` is raised." msgstr "如果找不到該屬性,則會引發 :exc:`ImportError`。" -#: ../../reference/simple_stmts.rst:810 +#: ../../reference/simple_stmts.rst:811 msgid "" "otherwise, a reference to that value is stored in the current namespace, " "using the name in the :keyword:`!as` clause if it is present, otherwise " @@ -1157,11 +1157,11 @@ msgstr "" "否則,對該值的參照會儲存在目前的命名空間中,如果存在 :keyword:`!as` 子句則使" "用其中的名稱,否則使用屬性名稱" -#: ../../reference/simple_stmts.rst:814 +#: ../../reference/simple_stmts.rst:815 msgid "Examples::" msgstr "範例: ::" -#: ../../reference/simple_stmts.rst:816 +#: ../../reference/simple_stmts.rst:817 msgid "" "import foo # foo imported and bound locally\n" "import foo.bar.baz # foo, foo.bar, and foo.bar.baz imported, foo " @@ -1181,7 +1181,7 @@ msgstr "" "繫結為 baz\n" "from foo import attr # foo 被引入,foo.attr 繫結為 attr" -#: ../../reference/simple_stmts.rst:824 +#: ../../reference/simple_stmts.rst:825 msgid "" "If the list of identifiers is replaced by a star (``'*'``), all public names " "defined in the module are bound in the local namespace for the scope where " @@ -1190,7 +1190,7 @@ msgstr "" "如果識別字串列被星號(``'*'``)取代,則模組中定義的所有公開名稱都會在 :" "keyword:`import` 陳述式出現的作用域的區域命名空間中繫結。" -#: ../../reference/simple_stmts.rst:833 +#: ../../reference/simple_stmts.rst:834 msgid "" "The *public names* defined by a module are determined by checking the " "module's namespace for a variable named ``__all__``; if defined, it must be " @@ -1212,7 +1212,7 @@ msgstr "" "元(``'_'``)開頭的名稱。``__all__`` 應該包含整個公開 API。這是為了避免意外匯" "出不屬於 API 的項目(例如在模組內被引入和使用的函式庫模組)。" -#: ../../reference/simple_stmts.rst:845 +#: ../../reference/simple_stmts.rst:846 msgid "" "The wild card form of import --- ``from module import *`` --- is only " "allowed at the module level. Attempting to use it in class or function " @@ -1221,7 +1221,7 @@ msgstr "" "萬用字元形式的引入——``from module import *``——只允許在模組層級使用。嘗試在類" "別或函式定義中使用它會引發 :exc:`SyntaxError`。" -#: ../../reference/simple_stmts.rst:852 +#: ../../reference/simple_stmts.rst:853 msgid "" "When specifying what module to import you do not have to specify the " "absolute name of the module. When a module or package is contained within " @@ -1247,14 +1247,14 @@ msgstr "" "引入 ``pkg.subpkg2.mod``。相對引入的規格說明包含在\\ :ref:" "`relativeimports`\\ 章節中。" -#: ../../reference/simple_stmts.rst:866 +#: ../../reference/simple_stmts.rst:867 msgid "" ":func:`importlib.import_module` is provided to support applications that " "determine dynamically the modules to be loaded." msgstr "" ":func:`importlib.import_module` 用於支援需要動態決定載入模組的應用程式。" -#: ../../reference/simple_stmts.rst:869 +#: ../../reference/simple_stmts.rst:870 msgid "" "Raises an :ref:`auditing event ` ``import`` with arguments " "``module``, ``filename``, ``sys.path``, ``sys.meta_path``, ``sys." @@ -1263,11 +1263,155 @@ msgstr "" "引發一個附帶引數 ``module``、``filename``、``sys.path``、``sys.meta_path``、" "``sys.path_hooks`` 的\\ :ref:`稽核事件 ` ``import``。" -#: ../../reference/simple_stmts.rst:876 +#: ../../reference/simple_stmts.rst:878 +msgid "Lazy imports" +msgstr "延遲引入" + +#: ../../reference/simple_stmts.rst:884 +msgid "" +"The :keyword:`lazy` keyword is a :ref:`soft keyword ` that " +"only has special meaning when it appears immediately before an :keyword:" +"`import` or :keyword:`from` statement. When an import statement is preceded " +"by the :keyword:`lazy` keyword, the import becomes *lazy*: the module is not " +"loaded immediately at the import statement. Instead, a lazy proxy object is " +"created and bound to the name. The actual module is loaded on first use of " +"that name." +msgstr "" + +#: ../../reference/simple_stmts.rst:892 +msgid "" +"Lazy imports are only permitted at module scope. Using :keyword:`lazy` " +"inside a function, class body, or :keyword:`try`/:keyword:`except`/:keyword:" +"`finally` block raises a :exc:`SyntaxError`. Star imports cannot be lazy " +"(``lazy from module import *`` is a syntax error), and :ref:`future " +"statements ` cannot be lazy." +msgstr "" + +#: ../../reference/simple_stmts.rst:899 +msgid "" +"When using ``lazy from ... import``, each imported name is bound to a lazy " +"proxy object. The first access to any of these names triggers loading of the " +"entire module and resolves only that specific name to its actual value. " +"Other names remain as lazy proxies until they are accessed." +msgstr "" + +#: ../../reference/simple_stmts.rst:904 +msgid "Example::" +msgstr "範例: ::" + +#: ../../reference/simple_stmts.rst:906 +msgid "" +"lazy import json\n" +"import sys\n" +"\n" +"print('json' in sys.modules) # False - json module not yet loaded\n" +"\n" +"# First use triggers loading\n" +"result = json.dumps({\"hello\": \"world\"})\n" +"\n" +"print('json' in sys.modules) # True - now loaded" +msgstr "" +"lazy import json\n" +"import sys\n" +"\n" +"print('json' in sys.modules) # False - json 模組尚未載入\n" +"\n" +"# 第一次使用時觸發載入\n" +"result = json.dumps({\"hello\": \"world\"})\n" +"\n" +"print('json' in sys.modules) # True - 現在已載入" + +#: ../../reference/simple_stmts.rst:916 +msgid "" +"If an error occurs during module loading (such as :exc:`ImportError` or :exc:" +"`SyntaxError`), it is raised at the point where the lazy import is first " +"used, not at the import statement itself." +msgstr "" + +#: ../../reference/simple_stmts.rst:920 +msgid "See :pep:`810` for the full specification of lazy imports." +msgstr "" + +#: ../../reference/simple_stmts.rst:927 +msgid "Compatibility via ``__lazy_modules__``" +msgstr "" + +#: ../../reference/simple_stmts.rst:932 +msgid "" +"As an alternative to using the :keyword:`lazy` keyword, a module can opt " +"into lazy loading for specific imports by defining a module-level :attr:" +"`~module.__lazy_modules__` variable. When present, it must be a container " +"of fully qualified module name strings. Any regular (non-``lazy``) :keyword:" +"`import` statement at module scope whose target appears in :attr:`!" +"__lazy_modules__` is treated as a lazy import, exactly as if the :keyword:" +"`lazy` keyword had been used." +msgstr "" + +#: ../../reference/simple_stmts.rst:940 +msgid "" +"This provides a way to enable lazy loading for specific dependencies without " +"changing individual ``import`` statements. This is useful when supporting " +"Python versions older than 3.15 while using lazy imports in 3.15+::" +msgstr "" + +#: ../../reference/simple_stmts.rst:944 +msgid "" +"__lazy_modules__ = [\"json\", \"pathlib\"]\n" +"\n" +"import json # loaded lazily (name is in __lazy_modules__)\n" +"import os # loaded eagerly (name not in __lazy_modules__)\n" +"\n" +"import pathlib # loaded lazily" +msgstr "" +"__lazy_modules__ = [\"json\", \"pathlib\"]\n" +"\n" +"import json # 延遲載入(名稱在 __lazy_modules__ 中)\n" +"import os # 立即載入(名稱不在 __lazy_modules__ 中)\n" +"\n" +"import pathlib # 延遲載入" + +#: ../../reference/simple_stmts.rst:951 +msgid "" +"Relative imports are resolved to their absolute name before the lookup, so :" +"attr:`!__lazy_modules__` must always contain fully qualified module names." +msgstr "" + +#: ../../reference/simple_stmts.rst:954 +msgid "" +"For ``from``-style imports, the relevant name is the module following " +"``from``, not the names of its members::" +msgstr "" + +#: ../../reference/simple_stmts.rst:957 +msgid "" +"# In mypackage/mymodule.py\n" +"__lazy_modules__ = [\"mypackage\", \"mypackage.sub.utils\"]\n" +"\n" +"from . import helper # loaded lazily: . resolves to mypackage\n" +"from .sub.utils import func # loaded lazily: .sub.utils resolves to " +"mypackage.sub.utils\n" +"import json # loaded eagerly (not in __lazy_modules__)" +msgstr "" +"# 在 mypackage/mymodule.py 中\n" +"__lazy_modules__ = [\"mypackage\", \"mypackage.sub.utils\"]\n" +"\n" +"from . import helper # 延遲載入:. 解析為 mypackage\n" +"from .sub.utils import func # 延遲載入:.sub.utils 解析為 " +"mypackage.sub.utils\n" +"import json # 立即載入(不在 __lazy_modules__ 中)" + +#: ../../reference/simple_stmts.rst:964 +msgid "" +"Imports inside functions, class bodies, or :keyword:`try`/:keyword:`except`/:" +"keyword:`finally` blocks are always eager, regardless of :attr:`!" +"__lazy_modules__`." +msgstr "" + +#: ../../reference/simple_stmts.rst:973 msgid "Future statements" msgstr "Future 陳述式" -#: ../../reference/simple_stmts.rst:882 +#: ../../reference/simple_stmts.rst:979 msgid "" "A :dfn:`future statement` is a directive to the compiler that a particular " "module should be compiled using syntax or semantics that will be available " @@ -1277,7 +1421,7 @@ msgstr "" "使用將在 Python 的指定未來版本(該功能成為標準的版本)中可用的語法或語義來編" "譯。" -#: ../../reference/simple_stmts.rst:886 +#: ../../reference/simple_stmts.rst:983 msgid "" "The future statement is intended to ease migration to future versions of " "Python that introduce incompatible changes to the language. It allows use " @@ -1287,37 +1431,37 @@ msgstr "" "future 陳述式旨在簡化向 Python 未來版本的遷移,這些版本引入了語言的不相容變" "更。它允許在該功能成為標準的版本發佈之前,以每個模組為基礎使用新功能。" -#: ../../reference/simple_stmts.rst:898 +#: ../../reference/simple_stmts.rst:995 msgid "" "A future statement must appear near the top of the module. The only lines " "that can appear before a future statement are:" msgstr "" "future 陳述式必須出現在模組的頂部附近。可以出現在 future 陳述式之前的行只有:" -#: ../../reference/simple_stmts.rst:901 +#: ../../reference/simple_stmts.rst:998 msgid "the module docstring (if any)," msgstr "模組的文件字串(如果有的話)," -#: ../../reference/simple_stmts.rst:902 +#: ../../reference/simple_stmts.rst:999 msgid "comments," msgstr "註解," -#: ../../reference/simple_stmts.rst:903 +#: ../../reference/simple_stmts.rst:1000 msgid "blank lines, and" msgstr "空白行,以及" -#: ../../reference/simple_stmts.rst:904 +#: ../../reference/simple_stmts.rst:1001 msgid "other future statements." msgstr "其他 future 陳述式。" -#: ../../reference/simple_stmts.rst:906 +#: ../../reference/simple_stmts.rst:1003 msgid "" "The only feature that requires using the future statement is ``annotations`` " "(see :pep:`563`)." msgstr "" "唯一需要使用 future 陳述式的功能是 ``annotations``\\ (請參閱 :pep:`563`)。" -#: ../../reference/simple_stmts.rst:909 +#: ../../reference/simple_stmts.rst:1006 msgid "" "All historical features enabled by the future statement are still recognized " "by Python 3. The list includes ``absolute_import``, ``division``, " @@ -1332,7 +1476,7 @@ msgstr "" "``with_statement``。它們都是多餘的,因為它們總是被啟用的,只是為了向後相容性" "而保留。" -#: ../../reference/simple_stmts.rst:916 +#: ../../reference/simple_stmts.rst:1013 msgid "" "A future statement is recognized and treated specially at compile time: " "Changes to the semantics of core constructs are often implemented by " @@ -1346,7 +1490,7 @@ msgstr "" "種情況下,編譯器可能需要以不同的方式剖析模組。這些決定無法延遲到 runtime 才做" "出。" -#: ../../reference/simple_stmts.rst:923 +#: ../../reference/simple_stmts.rst:1020 msgid "" "For any given release, the compiler knows which feature names have been " "defined, and raises a compile-time error if a future statement contains a " @@ -1355,7 +1499,7 @@ msgstr "" "對於任何給定的版本,編譯器知道哪些功能名稱已被定義,如果 future 陳述式包含它" "不認識的功能,則會引發編譯時錯誤。" -#: ../../reference/simple_stmts.rst:927 +#: ../../reference/simple_stmts.rst:1024 msgid "" "The direct runtime semantics are the same as for any import statement: there " "is a standard module :mod:`__future__`, described later, and it will be " @@ -1364,21 +1508,21 @@ msgstr "" "直接的 runtime 語義與任何 import 陳述式相同:有一個標準模組 :mod:" "`__future__`\\ (稍後描述),它會在 future 陳述式執行時以通常的方式被引入。" -#: ../../reference/simple_stmts.rst:931 +#: ../../reference/simple_stmts.rst:1028 msgid "" "The interesting runtime semantics depend on the specific feature enabled by " "the future statement." msgstr "有趣的 runtime 語義取決於 future 陳述式啟用的特定功能。" -#: ../../reference/simple_stmts.rst:934 +#: ../../reference/simple_stmts.rst:1031 msgid "Note that there is nothing special about the statement::" msgstr "請注意,以下陳述式沒有什麼特別的: ::" -#: ../../reference/simple_stmts.rst:936 +#: ../../reference/simple_stmts.rst:1033 msgid "import __future__ [as name]" msgstr "import __future__ [as name]" -#: ../../reference/simple_stmts.rst:938 +#: ../../reference/simple_stmts.rst:1035 msgid "" "That is not a future statement; it's an ordinary import statement with no " "special semantics or syntax restrictions." @@ -1386,7 +1530,7 @@ msgstr "" "這不是 future 陳述式;它是一個普通的 import 陳述式,沒有特殊的語義或語法限" "制。" -#: ../../reference/simple_stmts.rst:941 +#: ../../reference/simple_stmts.rst:1038 msgid "" "Code compiled by calls to the built-in functions :func:`exec` and :func:" "`compile` that occur in a module :mod:`!M` containing a future statement " @@ -1398,7 +1542,7 @@ msgstr "" "func:`compile` 編譯的程式碼預設會使用與 future 陳述式相關的新語法或語義。這可" "以透過 :func:`compile` 的可選引數來控制——詳情請參閱該函式的文件。" -#: ../../reference/simple_stmts.rst:947 +#: ../../reference/simple_stmts.rst:1044 msgid "" "A future statement typed at an interactive interpreter prompt will take " "effect for the rest of the interpreter session. If an interpreter is " @@ -1410,19 +1554,19 @@ msgstr "" "效。如果直譯器使用 :option:`-i` 選項啟動,傳入一個要執行的腳本名稱,且該腳本" "包含 future 陳述式,則它會在腳本執行後啟動的互動式工作階段中生效。" -#: ../../reference/simple_stmts.rst:955 +#: ../../reference/simple_stmts.rst:1052 msgid ":pep:`236` - Back to the __future__" msgstr ":pep:`236` - 回到 __future__" -#: ../../reference/simple_stmts.rst:956 +#: ../../reference/simple_stmts.rst:1053 msgid "The original proposal for the __future__ mechanism." msgstr "__future__ 機制的原始提案。" -#: ../../reference/simple_stmts.rst:962 +#: ../../reference/simple_stmts.rst:1059 msgid "The :keyword:`!global` statement" msgstr ":keyword:`!global` 陳述式" -#: ../../reference/simple_stmts.rst:972 +#: ../../reference/simple_stmts.rst:1069 msgid "" "The :keyword:`global` statement causes the listed identifiers to be " "interpreted as globals. It would be impossible to assign to a global " @@ -1433,7 +1577,7 @@ msgstr "" "`!global`,就不可能對全域變數進行賦值,儘管自由變數可以在未被宣告為 global 的" "情況下參照全域變數。" -#: ../../reference/simple_stmts.rst:977 +#: ../../reference/simple_stmts.rst:1074 msgid "" "The :keyword:`!global` statement applies to the entire current scope " "(module, function body or class definition). A :exc:`SyntaxError` is raised " @@ -1444,7 +1588,7 @@ msgstr "" "果在該作用域中,變數在其 global 宣告之前被使用或賦值,則會引發 :exc:" "`SyntaxError`。" -#: ../../reference/simple_stmts.rst:982 +#: ../../reference/simple_stmts.rst:1079 msgid "" "At the module level, all variables are global, so a :keyword:`!global` " "statement has no effect. However, variables must still not be used or " @@ -1455,7 +1599,7 @@ msgstr "" "而,變數仍然不能在其 :keyword:`!global` 宣告之前被使用或賦值。這個要求在互動" "式提示符(:term:`REPL`)中被放寬。" -#: ../../reference/simple_stmts.rst:993 +#: ../../reference/simple_stmts.rst:1090 msgid "" "**Programmer's note:** :keyword:`global` is a directive to the parser. It " "applies only to code parsed at the same time as the :keyword:`!global` " @@ -1473,11 +1617,11 @@ msgstr "" "碼中的 :keyword:`!global` 陳述式影響。同樣的規則也適用於 :func:`eval` 和 :" "func:`compile` 函式。" -#: ../../reference/simple_stmts.rst:1005 +#: ../../reference/simple_stmts.rst:1102 msgid "The :keyword:`!nonlocal` statement" msgstr ":keyword:`!nonlocal` 陳述式" -#: ../../reference/simple_stmts.rst:1013 +#: ../../reference/simple_stmts.rst:1110 msgid "" "When the definition of a function or class is nested (enclosed) within the " "definitions of other functions, its nonlocal scopes are the local scopes of " @@ -1494,7 +1638,7 @@ msgstr "" "稱在多個非區域作用域中被繫結,則使用最近的繫結。如果一個名稱在任何非區域作用" "域中都沒有被繫結,或者沒有非區域作用域,則會引發 :exc:`SyntaxError`。" -#: ../../reference/simple_stmts.rst:1022 +#: ../../reference/simple_stmts.rst:1119 msgid "" "The :keyword:`nonlocal` statement applies to the entire scope of a function " "or class body. A :exc:`SyntaxError` is raised if a variable is used or " @@ -1503,15 +1647,15 @@ msgstr "" ":keyword:`nonlocal` 陳述式適用於函式或類別主體的整個作用域。如果在該作用域" "中,變數在其 nonlocal 宣告之前被使用或賦值,則會引發 :exc:`SyntaxError`。" -#: ../../reference/simple_stmts.rst:1028 +#: ../../reference/simple_stmts.rst:1125 msgid ":pep:`3104` - Access to Names in Outer Scopes" msgstr ":pep:`3104` - 存取外層作用域中的名稱" -#: ../../reference/simple_stmts.rst:1029 +#: ../../reference/simple_stmts.rst:1126 msgid "The specification for the :keyword:`nonlocal` statement." msgstr ":keyword:`nonlocal` 陳述式的規格說明。" -#: ../../reference/simple_stmts.rst:1031 +#: ../../reference/simple_stmts.rst:1128 msgid "" "**Programmer's note:** :keyword:`nonlocal` is a directive to the parser and " "applies only to code parsed along with it. See the note for the :keyword:" @@ -1520,11 +1664,11 @@ msgstr "" "**程式設計師注意事項:**\\ :keyword:`nonlocal` 是給剖析器的指令,只適用於與它" "一起被剖析的程式碼。請參閱 :keyword:`global` 陳述式的注意事項。" -#: ../../reference/simple_stmts.rst:1039 +#: ../../reference/simple_stmts.rst:1136 msgid "The :keyword:`!type` statement" msgstr ":keyword:`!type` 陳述式" -#: ../../reference/simple_stmts.rst:1046 +#: ../../reference/simple_stmts.rst:1143 msgid "" "The :keyword:`!type` statement declares a type alias, which is an instance " "of :class:`typing.TypeAliasType`." @@ -1532,19 +1676,19 @@ msgstr "" ":keyword:`!type` 陳述式宣告一個型別別名,它是 :class:`typing.TypeAliasType` " "的實例。" -#: ../../reference/simple_stmts.rst:1049 +#: ../../reference/simple_stmts.rst:1146 msgid "For example, the following statement creates a type alias::" msgstr "例如以下陳述式建立了一個型別別名: ::" -#: ../../reference/simple_stmts.rst:1051 +#: ../../reference/simple_stmts.rst:1148 msgid "type Point = tuple[float, float]" msgstr "type Point = tuple[float, float]" -#: ../../reference/simple_stmts.rst:1053 +#: ../../reference/simple_stmts.rst:1150 msgid "This code is roughly equivalent to::" msgstr "這段程式碼大致等價於: ::" -#: ../../reference/simple_stmts.rst:1055 +#: ../../reference/simple_stmts.rst:1152 msgid "" "annotation-def VALUE_OF_Point():\n" " return tuple[float, float]\n" @@ -1554,7 +1698,7 @@ msgstr "" " return tuple[float, float]\n" "Point = typing.TypeAliasType(\"Point\", VALUE_OF_Point())" -#: ../../reference/simple_stmts.rst:1059 +#: ../../reference/simple_stmts.rst:1156 msgid "" "``annotation-def`` indicates an :ref:`annotation scope `, " "which behaves mostly like a function, but with several small differences." @@ -1562,7 +1706,7 @@ msgstr "" "``annotation-def`` 表示一個\\ :ref:`註釋作用域 `,它的行為" "大部分像函式,但有一些小差異。" -#: ../../reference/simple_stmts.rst:1062 +#: ../../reference/simple_stmts.rst:1159 msgid "" "The value of the type alias is evaluated in the annotation scope. It is not " "evaluated when the type alias is created, but only when the value is " @@ -1574,7 +1718,7 @@ msgstr "" "型別別名的 :attr:`!__value__` 屬性存取該值時才求值(請參閱\\ :ref:`lazy-" "evaluation`)。這允許型別別名參照尚未定義的名稱。" -#: ../../reference/simple_stmts.rst:1068 +#: ../../reference/simple_stmts.rst:1165 msgid "" "Type aliases may be made generic by adding a :ref:`type parameter list ` after the name. See :ref:`generic-type-aliases` for more." @@ -1582,15 +1726,15 @@ msgstr "" "型別別名可以透過在名稱後面新增\\ :ref:`型別參數串列 `\\ 來使其成" "為泛型。更多資訊請參閱\\ :ref:`generic-type-aliases`。" -#: ../../reference/simple_stmts.rst:1071 +#: ../../reference/simple_stmts.rst:1168 msgid ":keyword:`!type` is a :ref:`soft keyword `." msgstr ":keyword:`!type` 是一個\\ :ref:`軟關鍵字 `。" -#: ../../reference/simple_stmts.rst:1077 +#: ../../reference/simple_stmts.rst:1174 msgid ":pep:`695` - Type Parameter Syntax" msgstr ":pep:`695` - 型別參數語法" -#: ../../reference/simple_stmts.rst:1078 +#: ../../reference/simple_stmts.rst:1175 msgid "" "Introduced the :keyword:`!type` statement and syntax for generic classes and " "functions." @@ -1607,9 +1751,9 @@ msgstr "simple(簡單)" #: ../../reference/simple_stmts.rst:457 ../../reference/simple_stmts.rst:483 #: ../../reference/simple_stmts.rst:520 ../../reference/simple_stmts.rst:556 #: ../../reference/simple_stmts.rst:681 ../../reference/simple_stmts.rst:715 -#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:878 -#: ../../reference/simple_stmts.rst:964 ../../reference/simple_stmts.rst:1007 -#: ../../reference/simple_stmts.rst:1041 +#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:975 +#: ../../reference/simple_stmts.rst:1061 ../../reference/simple_stmts.rst:1104 +#: ../../reference/simple_stmts.rst:1138 msgid "statement" msgstr "statement(陳述式)" @@ -1623,7 +1767,7 @@ msgstr "expression(運算式)" msgid "list" msgstr "list(串列)" -#: ../../reference/simple_stmts.rst:56 ../../reference/simple_stmts.rst:988 +#: ../../reference/simple_stmts.rst:56 ../../reference/simple_stmts.rst:1085 msgid "built-in function" msgstr "built-in function(內建函式)" @@ -1689,13 +1833,13 @@ msgid "assignment" msgstr "assignment(賦值)" #: ../../reference/simple_stmts.rst:75 ../../reference/simple_stmts.rst:740 -#: ../../reference/simple_stmts.rst:796 ../../reference/simple_stmts.rst:964 +#: ../../reference/simple_stmts.rst:797 ../../reference/simple_stmts.rst:1061 msgid "binding" msgstr "binding(繫結)" #: ../../reference/simple_stmts.rst:75 ../../reference/simple_stmts.rst:457 -#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:796 -#: ../../reference/simple_stmts.rst:964 +#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:797 +#: ../../reference/simple_stmts.rst:1061 msgid "name" msgstr "name(名稱)" @@ -1718,8 +1862,8 @@ msgid "target" msgstr "target" #: ../../reference/simple_stmts.rst:115 ../../reference/simple_stmts.rst:379 -#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:964 -#: ../../reference/simple_stmts.rst:1007 +#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:1061 +#: ../../reference/simple_stmts.rst:1104 msgid ", (comma)" msgstr ", (逗號)" @@ -1727,7 +1871,7 @@ msgstr ", (逗號)" msgid "in target list" msgstr "於目標串列中" -#: ../../reference/simple_stmts.rst:115 ../../reference/simple_stmts.rst:822 +#: ../../reference/simple_stmts.rst:115 ../../reference/simple_stmts.rst:823 msgid "* (asterisk)" msgstr "* (星號)" @@ -1893,7 +2037,7 @@ msgstr "del" msgid "deletion" msgstr "deletion(刪除)" -#: ../../reference/simple_stmts.rst:457 ../../reference/simple_stmts.rst:964 +#: ../../reference/simple_stmts.rst:457 ../../reference/simple_stmts.rst:1061 msgid "global" msgstr "global" @@ -2000,7 +2144,8 @@ msgstr "loop control(迴圈控制)" msgid "continue" msgstr "continue" -#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:849 +#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:850 +#: ../../reference/simple_stmts.rst:880 msgid "import" msgstr "import(引入)" @@ -2012,63 +2157,75 @@ msgstr "module(模組)" msgid "importing" msgstr "importing(引入)" -#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:796 +#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:797 msgid "from" msgstr "from" -#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:783 +#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:784 msgid "as" msgstr "as" +#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:880 +msgid "lazy" +msgstr "" + #: ../../reference/simple_stmts.rst:740 msgid "ImportError" msgstr "ImportError" -#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:783 -#: ../../reference/simple_stmts.rst:796 ../../reference/simple_stmts.rst:822 +#: ../../reference/simple_stmts.rst:740 ../../reference/simple_stmts.rst:784 +#: ../../reference/simple_stmts.rst:797 ../../reference/simple_stmts.rst:823 msgid "import statement" msgstr "import statement(引入陳述式)" -#: ../../reference/simple_stmts.rst:828 +#: ../../reference/simple_stmts.rst:829 msgid "__all__ (optional module attribute)" msgstr "__all__(可選模組屬性)" -#: ../../reference/simple_stmts.rst:849 +#: ../../reference/simple_stmts.rst:850 msgid "relative" msgstr "relative(相對)" -#: ../../reference/simple_stmts.rst:878 +#: ../../reference/simple_stmts.rst:880 +msgid "lazy import" +msgstr "lazy import(延遲引入)" + +#: ../../reference/simple_stmts.rst:929 +msgid "__lazy_modules__" +msgstr "" + +#: ../../reference/simple_stmts.rst:975 msgid "future" msgstr "future" -#: ../../reference/simple_stmts.rst:878 +#: ../../reference/simple_stmts.rst:975 msgid "__future__" msgstr "__future__" -#: ../../reference/simple_stmts.rst:878 +#: ../../reference/simple_stmts.rst:975 msgid "future statement" msgstr "future statement(future 陳述式)" -#: ../../reference/simple_stmts.rst:964 ../../reference/simple_stmts.rst:1007 +#: ../../reference/simple_stmts.rst:1061 ../../reference/simple_stmts.rst:1104 msgid "identifier list" msgstr "identifier list(識別符號清單)" -#: ../../reference/simple_stmts.rst:988 +#: ../../reference/simple_stmts.rst:1085 msgid "exec" msgstr "exec" -#: ../../reference/simple_stmts.rst:988 +#: ../../reference/simple_stmts.rst:1085 msgid "eval" msgstr "eval" -#: ../../reference/simple_stmts.rst:988 +#: ../../reference/simple_stmts.rst:1085 msgid "compile" msgstr "compile(編譯)" -#: ../../reference/simple_stmts.rst:1007 +#: ../../reference/simple_stmts.rst:1104 msgid "nonlocal" msgstr "nonlocal" -#: ../../reference/simple_stmts.rst:1041 +#: ../../reference/simple_stmts.rst:1138 msgid "type" msgstr "type(型別)" diff --git a/tutorial/classes.po b/tutorial/classes.po index 7414a3fff7f..68852528cff 100644 --- a/tutorial/classes.po +++ b/tutorial/classes.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-18 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -1334,11 +1334,17 @@ msgstr "" "化),而不會影響其 parent 的搜尋優先順序)。總之,這些特性使設計出可靠又可擴" "充、具有多重繼承的 class 成為可能。更多資訊,請見 :ref:`python_2.3_mro`。" -#: ../../tutorial/classes.rst:670 +#: ../../tutorial/classes.rst:666 +msgid "" +"In some cases multiple inheritance is not allowed; see :ref:`multiple-" +"inheritance` for details." +msgstr "" + +#: ../../tutorial/classes.rst:673 msgid "Private Variables" msgstr "私有變數" -#: ../../tutorial/classes.rst:672 +#: ../../tutorial/classes.rst:675 msgid "" "\"Private\" instance variables that cannot be accessed except from inside an " "object don't exist in Python. However, there is a convention that is " @@ -1353,7 +1359,7 @@ msgstr "" "(無論它是函式、方法或是資料成員)。這被視為一個實作細節,如有調整,亦不另行" "通知。" -#: ../../tutorial/classes.rst:682 +#: ../../tutorial/classes.rst:685 msgid "" "Since there is a valid use-case for class-private members (namely to avoid " "name clashes of names with names defined by subclasses), there is limited " @@ -1371,14 +1377,14 @@ msgstr "" "``classname`` 就是去掉前導下底線的目前 class 名稱。只要這個修飾是在 class 的" "定義之中發生,它就會在不考慮該物件名稱的語法位置的情況下完成。" -#: ../../tutorial/classes.rst:693 +#: ../../tutorial/classes.rst:696 msgid "" "The :ref:`private name mangling specifications ` for " "details and special cases." msgstr "" "參閱\\ :ref:`私有名稱修飾規格 `\\ 的詳情與特殊情況。" -#: ../../tutorial/classes.rst:696 +#: ../../tutorial/classes.rst:699 msgid "" "Name mangling is helpful for letting subclasses override methods without " "breaking intraclass method calls. For example::" @@ -1386,7 +1392,7 @@ msgstr "" "名稱修飾對於讓 subclass 覆寫 method 而不用破壞 class 內部的 method 呼叫,是有" "幫助的。舉例來說: ::" -#: ../../tutorial/classes.rst:699 +#: ../../tutorial/classes.rst:702 msgid "" "class Mapping:\n" " def __init__(self, iterable):\n" @@ -1426,7 +1432,7 @@ msgstr "" " for item in zip(keys, values):\n" " self.items_list.append(item)" -#: ../../tutorial/classes.rst:718 +#: ../../tutorial/classes.rst:721 msgid "" "The above example would work even if ``MappingSubclass`` were to introduce a " "``__update`` identifier since it is replaced with ``_Mapping__update`` in " @@ -1437,7 +1443,7 @@ msgstr "" "作,因為在 ``Mapping`` class 中,它會被替換為 ``_Mapping__update``,而在 " "``MappingSubclass`` class 中,它會被替換為 ``_MappingSubclass__update``。" -#: ../../tutorial/classes.rst:723 +#: ../../tutorial/classes.rst:726 msgid "" "Note that the mangling rules are designed mostly to avoid accidents; it " "still is possible to access or modify a variable that is considered " @@ -1447,7 +1453,7 @@ msgstr "" "請注意,修飾規則是被設計來避免意外;它仍可能存取或修改一個被視為私有的變數。" "這在特殊情況下甚至可能很有用,例如在除錯器 (debugger)。" -#: ../../tutorial/classes.rst:727 +#: ../../tutorial/classes.rst:730 msgid "" "Notice that code passed to ``exec()`` or ``eval()`` does not consider the " "classname of the invoking class to be the current class; this is similar to " @@ -1461,11 +1467,11 @@ msgstr "" "組編譯後 (byte-compiled) 的程式碼。同樣的限制適用於 ``getattr()``," "``setattr()`` 和 ``delattr()``,以及直接參照 ``__dict__`` 時。" -#: ../../tutorial/classes.rst:738 +#: ../../tutorial/classes.rst:741 msgid "Odds and Ends" msgstr "補充說明" -#: ../../tutorial/classes.rst:740 +#: ../../tutorial/classes.rst:743 msgid "" "Sometimes it is useful to have a data type similar to the Pascal \"record\" " "or C \"struct\", bundling together a few named data items. The idiomatic " @@ -1475,7 +1481,7 @@ msgstr "" "名稱的資料項目捆綁在一起,有時候這會很有用。符合語言習慣的做法是使用 :mod:" "`dataclasses`: ::" -#: ../../tutorial/classes.rst:744 +#: ../../tutorial/classes.rst:747 msgid "" "from dataclasses import dataclass\n" "\n" @@ -1493,7 +1499,7 @@ msgstr "" " dept: str\n" " salary: int" -#: ../../tutorial/classes.rst:754 +#: ../../tutorial/classes.rst:757 msgid "" ">>> john = Employee('john', 'computer lab', 1000)\n" ">>> john.dept\n" @@ -1507,7 +1513,7 @@ msgstr "" ">>> john.salary\n" "1000" -#: ../../tutorial/classes.rst:760 +#: ../../tutorial/classes.rst:763 msgid "" "A piece of Python code that expects a particular abstract data type can " "often be passed a class that emulates the methods of that data type " @@ -1522,7 +1528,7 @@ msgstr "" "meth:`~io.TextIOBase.readline` method 的 class 作為替代方式,從字串緩衝區取得" "資料,並將其作為引數來傳遞。" -#: ../../tutorial/classes.rst:772 +#: ../../tutorial/classes.rst:775 msgid "" ":ref:`Instance method objects ` have attributes, too: :" "attr:`m.__self__ ` is the instance object with the method :" @@ -1534,11 +1540,11 @@ msgstr "" "__func__ ` 則是該 method 所對應的\\ :ref:`函式物件 `。" -#: ../../tutorial/classes.rst:782 +#: ../../tutorial/classes.rst:785 msgid "Iterators" msgstr "疊代器 (Iterator)" -#: ../../tutorial/classes.rst:784 +#: ../../tutorial/classes.rst:787 msgid "" "By now you have probably noticed that most container objects can be looped " "over using a :keyword:`for` statement::" @@ -1546,7 +1552,7 @@ msgstr "" "到目前為止,你可能已經注意到大多數的容器 (container) 物件都可以使用 :keyword:" "`for` 陳述式來進行迴圈: ::" -#: ../../tutorial/classes.rst:787 +#: ../../tutorial/classes.rst:790 msgid "" "for element in [1, 2, 3]:\n" " print(element)\n" @@ -1570,7 +1576,7 @@ msgstr "" "for line in open(\"myfile.txt\"):\n" " print(line, end='')" -#: ../../tutorial/classes.rst:798 +#: ../../tutorial/classes.rst:801 msgid "" "This style of access is clear, concise, and convenient. The use of " "iterators pervades and unifies Python. Behind the scenes, the :keyword:" @@ -1590,7 +1596,7 @@ msgstr "" "func:`next` 來呼叫 :meth:`~iterator.__next__` method;這個例子展示了它的運作" "方式: ::" -#: ../../tutorial/classes.rst:807 +#: ../../tutorial/classes.rst:810 msgid "" ">>> s = 'abc'\n" ">>> it = iter(s)\n" @@ -1624,7 +1630,7 @@ msgstr "" " next(it)\n" "StopIteration" -#: ../../tutorial/classes.rst:823 +#: ../../tutorial/classes.rst:826 msgid "" "Having seen the mechanics behind the iterator protocol, it is easy to add " "iterator behavior to your classes. Define an :meth:`~container.__iter__` " @@ -1637,7 +1643,7 @@ msgstr "" "__next__` method 的物件。如果 class 已定義了 :meth:`!__next__`,則 :meth:`!" "__iter__` 可以只回傳 ``self``: ::" -#: ../../tutorial/classes.rst:828 +#: ../../tutorial/classes.rst:831 msgid "" "class Reverse:\n" " \"\"\"Iterator for looping over a sequence backwards.\"\"\"\n" @@ -1669,7 +1675,7 @@ msgstr "" " self.index = self.index - 1\n" " return self.data[self.index]" -#: ../../tutorial/classes.rst:845 +#: ../../tutorial/classes.rst:848 msgid "" ">>> rev = Reverse('spam')\n" ">>> iter(rev)\n" @@ -1693,11 +1699,11 @@ msgstr "" "p\n" "s" -#: ../../tutorial/classes.rst:860 +#: ../../tutorial/classes.rst:863 msgid "Generators" msgstr "產生器 (Generator)" -#: ../../tutorial/classes.rst:862 +#: ../../tutorial/classes.rst:865 msgid "" ":term:`Generators ` are a simple and powerful tool for creating " "iterators. They are written like regular functions but use the :keyword:" @@ -1711,7 +1717,7 @@ msgstr "" "次在產生器上呼叫 :func:`next` 時,它會從上次離開的位置恢復執行(它會記得所有" "資料值以及上一個被執行的陳述式)。以下範例顯示,建立產生器可以相當地容易: ::" -#: ../../tutorial/classes.rst:869 +#: ../../tutorial/classes.rst:872 msgid "" "def reverse(data):\n" " for index in range(len(data)-1, -1, -1):\n" @@ -1721,7 +1727,7 @@ msgstr "" " for index in range(len(data)-1, -1, -1):\n" " yield data[index]" -#: ../../tutorial/classes.rst:875 +#: ../../tutorial/classes.rst:878 msgid "" ">>> for char in reverse('golf'):\n" "... print(char)\n" @@ -1739,7 +1745,7 @@ msgstr "" "o\n" "g" -#: ../../tutorial/classes.rst:883 +#: ../../tutorial/classes.rst:886 msgid "" "Anything that can be done with generators can also be done with class-based " "iterators as described in the previous section. What makes generators so " @@ -1750,7 +1756,7 @@ msgstr "" "描述。而讓產生器的程式碼更為精簡的原因是,:meth:`~iterator.__iter__` 和 :" "meth:`~generator.__next__` method 會自動被建立。" -#: ../../tutorial/classes.rst:888 +#: ../../tutorial/classes.rst:891 msgid "" "Another key feature is that the local variables and execution state are " "automatically saved between calls. This made the function easier to write " @@ -1761,7 +1767,7 @@ msgstr "" "函式比使用 ``self.index`` 和 ``self.data`` 這種實例變數的方式更容易編寫且更為" "清晰。" -#: ../../tutorial/classes.rst:893 +#: ../../tutorial/classes.rst:896 msgid "" "In addition to automatic method creation and saving program state, when " "generators terminate, they automatically raise :exc:`StopIteration`. In " @@ -1771,11 +1777,11 @@ msgstr "" "除了會自動建立 method 和儲存程式狀態,當產生器終止時,它們還會自動引發 :exc:" "`StopIteration`。這些特性結合在一起,使建立疊代器能與編寫常規函式一樣容易。" -#: ../../tutorial/classes.rst:902 +#: ../../tutorial/classes.rst:905 msgid "Generator Expressions" msgstr "產生器運算式" -#: ../../tutorial/classes.rst:904 +#: ../../tutorial/classes.rst:907 msgid "" "Some simple generators can be coded succinctly as expressions using a syntax " "similar to list comprehensions but with parentheses instead of square " @@ -1790,11 +1796,11 @@ msgstr "" "產生器定義相比,程式碼較精簡但功能較少,也比等效的 list comprehension 更為節" "省記憶體。" -#: ../../tutorial/classes.rst:911 +#: ../../tutorial/classes.rst:914 msgid "Examples::" msgstr "例如: ::" -#: ../../tutorial/classes.rst:913 +#: ../../tutorial/classes.rst:916 msgid "" ">>> sum(i*i for i in range(10)) # sum of squares\n" "285\n" @@ -1811,7 +1817,12 @@ msgid "" "\n" ">>> data = 'golf'\n" ">>> list(data[i] for i in range(len(data)-1, -1, -1))\n" -"['f', 'l', 'o', 'g']" +"['f', 'l', 'o', 'g']\n" +"\n" +">>> x = [[1,2,3], [], [4, 5]]\n" +">>> g = (*i for i in x)\n" +">>> list(g)\n" +"[1, 2, 3, 4, 5]" msgstr "" ">>> sum(i*i for i in range(10)) # 平方和\n" "285\n" @@ -1828,13 +1839,48 @@ msgstr "" "\n" ">>> data = 'golf'\n" ">>> list(data[i] for i in range(len(data)-1, -1, -1))\n" -"['f', 'l', 'o', 'g']" +"['f', 'l', 'o', 'g']\n" +"\n" +">>> x = [[1,2,3], [], [4, 5]]\n" +">>> g = (*i for i in x)\n" +">>> list(g)\n" +"[1, 2, 3, 4, 5]" -#: ../../tutorial/classes.rst:932 +#: ../../tutorial/classes.rst:937 +msgid "" +"In most cases, generator expressions must be wrapped in parentheses. As a " +"special case, however, when provided as the sole argument to a function (as " +"in the examples involving ``sum``, ``set``, ``max``, and ``list`` above), " +"the generator expression does not need to be wrapped in an additional set of " +"parentheses. That is to say, the following two pieces of code are " +"semantically equivalent::" +msgstr "" + +#: ../../tutorial/classes.rst:944 +msgid "" +">>> f(x for x in y)\n" +">>> f((x for x in y))" +msgstr "" +">>> f(x for x in y)\n" +">>> f((x for x in y))" + +#: ../../tutorial/classes.rst:947 +msgid "as are the following::" +msgstr "" + +#: ../../tutorial/classes.rst:949 +msgid "" +">>> f(*x for x in y)\n" +">>> f((*x for x in y))" +msgstr "" +">>> f(*x for x in y)\n" +">>> f((*x for x in y))" + +#: ../../tutorial/classes.rst:954 msgid "Footnotes" msgstr "註解" -#: ../../tutorial/classes.rst:933 +#: ../../tutorial/classes.rst:955 msgid "" "Except for one thing. Module objects have a secret read-only attribute " "called :attr:`~object.__dict__` which returns the dictionary used to " @@ -1856,10 +1902,10 @@ msgstr "object(物件)" msgid "method" msgstr "method(方法)" -#: ../../tutorial/classes.rst:679 +#: ../../tutorial/classes.rst:682 msgid "name" msgstr "name(名稱)" -#: ../../tutorial/classes.rst:679 +#: ../../tutorial/classes.rst:682 msgid "mangling" msgstr "mangling(修飾)" diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index 8558709b7d9..40c4797d77c 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-11 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-07-24 14:52+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -2180,7 +2180,7 @@ msgstr "" msgid "Function Annotations" msgstr "函式註釋 (Function Annotations)" -#: ../../tutorial/controlflow.rst:1077 +#: ../../tutorial/controlflow.rst:1076 msgid "" ":ref:`Function annotations ` are completely optional metadata " "information about the types used by user-defined functions (see :pep:`3107` " @@ -2189,7 +2189,7 @@ msgstr "" ":ref:`函式註釋 `\\ 是選擇性的元資料(metadata)資訊,描述使用者定義" "函式所使用的型別(更多資訊詳見 :pep:`3107` 和 :pep:`484`\\ )。" -#: ../../tutorial/controlflow.rst:1081 +#: ../../tutorial/controlflow.rst:1080 msgid "" ":term:`Annotations ` are stored in the :attr:`~object." "__annotations__` attribute of the function as a dictionary and have no " @@ -2207,7 +2207,7 @@ msgstr "" "``->`` 文字接著一個運算式。以下範例註釋了一個必要引數、一個選擇性引數,以及回" "傳值: ::" -#: ../../tutorial/controlflow.rst:1090 +#: ../../tutorial/controlflow.rst:1089 msgid "" ">>> def f(ham: str, eggs: str = 'eggs') -> str:\n" "... print(\"Annotations:\", f.__annotations__)\n" @@ -2231,11 +2231,11 @@ msgstr "" "Arguments: spam eggs\n" "'spam and eggs'" -#: ../../tutorial/controlflow.rst:1103 +#: ../../tutorial/controlflow.rst:1102 msgid "Intermezzo: Coding Style" msgstr "間奏曲:程式碼風格 (Coding Style)" -#: ../../tutorial/controlflow.rst:1108 +#: ../../tutorial/controlflow.rst:1106 msgid "" "Now that you are about to write longer, more complex pieces of Python, it is " "a good time to talk about *coding style*. Most languages can be written (or " @@ -2248,7 +2248,7 @@ msgstr "" "式比其他的更具可讀性。能讓其他人輕鬆閱讀你的程式碼永遠是一個好主意,而使用優" "良的編碼樣式對此有極大的幫助。" -#: ../../tutorial/controlflow.rst:1114 +#: ../../tutorial/controlflow.rst:1112 msgid "" "For Python, :pep:`8` has emerged as the style guide that most projects " "adhere to; it promotes a very readable and eye-pleasing coding style. Every " @@ -2258,11 +2258,11 @@ msgstr "" "對於 Python,大多數的專案都遵循 :pep:`8` 的樣式指南;它推行的編碼樣式相當可讀" "且賞心悅目。每個 Python 開發者都應該花點時間研讀;這裡是該指南的核心重點:" -#: ../../tutorial/controlflow.rst:1119 +#: ../../tutorial/controlflow.rst:1117 msgid "Use 4-space indentation, and no tabs." msgstr "用 4 個空格縮排,不要用 tab 鍵。" -#: ../../tutorial/controlflow.rst:1121 +#: ../../tutorial/controlflow.rst:1119 msgid "" "4 spaces are a good compromise between small indentation (allows greater " "nesting depth) and large indentation (easier to read). Tabs introduce " @@ -2271,11 +2271,11 @@ msgstr "" "4 個空格是小縮排(容許更大的巢套深度)和大縮排(較易閱讀)之間的折衷方案。" "Tab 鍵會造成混亂,最好別用。" -#: ../../tutorial/controlflow.rst:1125 +#: ../../tutorial/controlflow.rst:1123 msgid "Wrap lines so that they don't exceed 79 characters." msgstr "換行,使一行不超過 79 個字元。" -#: ../../tutorial/controlflow.rst:1127 +#: ../../tutorial/controlflow.rst:1125 msgid "" "This helps users with small displays and makes it possible to have several " "code files side-by-side on larger displays." @@ -2283,21 +2283,21 @@ msgstr "" "換行能讓使用小顯示器的使用者方便閱讀,也可以在較大顯示器上並排陳列多個程式碼" "檔案。" -#: ../../tutorial/controlflow.rst:1130 +#: ../../tutorial/controlflow.rst:1128 msgid "" "Use blank lines to separate functions and classes, and larger blocks of code " "inside functions." msgstr "用空行分隔函式和 class(類別),及函式內較大塊的程式碼。" -#: ../../tutorial/controlflow.rst:1133 +#: ../../tutorial/controlflow.rst:1131 msgid "When possible, put comments on a line of their own." msgstr "如果可以,把註解放在單獨一行。" -#: ../../tutorial/controlflow.rst:1135 +#: ../../tutorial/controlflow.rst:1133 msgid "Use docstrings." msgstr "使用說明字串。" -#: ../../tutorial/controlflow.rst:1137 +#: ../../tutorial/controlflow.rst:1135 msgid "" "Use spaces around operators and after commas, but not directly inside " "bracketing constructs: ``a = f(1, 2) + g(3, 4)``." @@ -2305,7 +2305,7 @@ msgstr "" "運算子前後、逗號後要加空格,但不要直接放在括號內側:``a = f(1, 2) + g(3, " "4)``。" -#: ../../tutorial/controlflow.rst:1140 +#: ../../tutorial/controlflow.rst:1138 msgid "" "Name your classes and functions consistently; the convention is to use " "``UpperCamelCase`` for classes and ``lowercase_with_underscores`` for " @@ -2317,7 +2317,7 @@ msgstr "" "底線)。永遠用 ``self`` 作為 method 第一個引數的名稱(關於 class 和 method," "詳見 :ref:`tut-firstclasses`\\ )。" -#: ../../tutorial/controlflow.rst:1145 +#: ../../tutorial/controlflow.rst:1143 msgid "" "Don't use fancy encodings if your code is meant to be used in international " "environments. Python's default, UTF-8, or even plain ASCII work best in any " @@ -2326,7 +2326,7 @@ msgstr "" "若程式碼是為了用於國際環境時,不要用花俏的編碼。Python 預設的 UTF-8 或甚至普" "通的 ASCII,就可以勝任各種情況。" -#: ../../tutorial/controlflow.rst:1149 +#: ../../tutorial/controlflow.rst:1147 msgid "" "Likewise, don't use non-ASCII characters in identifiers if there is only the " "slightest chance people speaking a different language will read or maintain " @@ -2335,11 +2335,11 @@ msgstr "" "同樣地,若不同語言使用者閱讀或維護程式碼的可能性微乎其微,就不要在命名時使用" "非 ASCII 字元。" -#: ../../tutorial/controlflow.rst:1155 +#: ../../tutorial/controlflow.rst:1153 msgid "Footnotes" msgstr "註解" -#: ../../tutorial/controlflow.rst:1156 +#: ../../tutorial/controlflow.rst:1154 msgid "" "Actually, *call by object reference* would be a better description, since if " "a mutable object is passed, the caller will see any changes the callee makes " @@ -2389,31 +2389,31 @@ msgstr "於函式呼叫中" msgid "**" msgstr "**" -#: ../../tutorial/controlflow.rst:1072 +#: ../../tutorial/controlflow.rst:1071 msgid "function" msgstr "function(函式)" -#: ../../tutorial/controlflow.rst:1072 +#: ../../tutorial/controlflow.rst:1071 msgid "annotations" msgstr "annotations(註釋)" -#: ../../tutorial/controlflow.rst:1072 +#: ../../tutorial/controlflow.rst:1071 msgid "->" msgstr "->" -#: ../../tutorial/controlflow.rst:1072 +#: ../../tutorial/controlflow.rst:1071 msgid "function annotations" msgstr "function annotations(函式註釋)" -#: ../../tutorial/controlflow.rst:1072 +#: ../../tutorial/controlflow.rst:1071 msgid ": (colon)" msgstr ": (冒號)" -#: ../../tutorial/controlflow.rst:1106 +#: ../../tutorial/controlflow.rst:1104 msgid "coding" msgstr "coding(程式編寫)" -#: ../../tutorial/controlflow.rst:1106 +#: ../../tutorial/controlflow.rst:1104 msgid "style" msgstr "style(風格)" diff --git a/tutorial/datastructures.po b/tutorial/datastructures.po index 73ab59d3597..c21b9812019 100644 --- a/tutorial/datastructures.po +++ b/tutorial/datastructures.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-04 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2024-01-22 21:43+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -210,7 +210,7 @@ msgstr "" msgid "Using Lists as Stacks" msgstr "將 List 作為 Stack(堆疊)使用" -#: ../../tutorial/datastructures.rst:142 +#: ../../tutorial/datastructures.rst:139 msgid "" "The list methods make it very easy to use a list as a stack, where the last " "element added is the first element retrieved (\"last-in, first-out\"). To " @@ -223,7 +223,7 @@ msgstr "" "使用方法 :meth:`~list.append` 將一個項目放到堆疊的頂層。而使用方法 :meth:" "`~list.pop` 且不給定索引值去取得堆疊最上面的項目。舉例而言: ::" -#: ../../tutorial/datastructures.rst:147 +#: ../../tutorial/datastructures.rst:144 msgid "" ">>> stack = [3, 4, 5]\n" ">>> stack.append(6)\n" @@ -257,11 +257,11 @@ msgstr "" ">>> stack\n" "[3, 4]" -#: ../../tutorial/datastructures.rst:167 +#: ../../tutorial/datastructures.rst:164 msgid "Using Lists as Queues" msgstr "將 List 作為 Queue(佇列)使用" -#: ../../tutorial/datastructures.rst:171 +#: ../../tutorial/datastructures.rst:166 msgid "" "It is also possible to use a list as a queue, where the first element added " "is the first element retrieved (\"first-in, first-out\"); however, lists are " @@ -276,7 +276,7 @@ msgstr "" "和 ``pop`` 來插入和取出頭端的元素較慢(因為其他元素都需要挪動一格)。更多資訊" "請參閱 :ref:`time-complexity`。" -#: ../../tutorial/datastructures.rst:178 +#: ../../tutorial/datastructures.rst:173 msgid "" "To implement a queue, use :class:`collections.deque` which was designed to " "have fast appends and pops from both ends. For example::" @@ -284,7 +284,7 @@ msgstr "" "如果要實作 queue,請使用 :class:`collections.deque`,其被設計成能快速的從頭尾" "兩端加入和取出。例如: ::" -#: ../../tutorial/datastructures.rst:181 +#: ../../tutorial/datastructures.rst:176 msgid "" ">>> from collections import deque\n" ">>> queue = deque([\"Eric\", \"John\", \"Michael\"])\n" @@ -308,11 +308,11 @@ msgstr "" ">>> queue # queue 裡剩下的會按照加進來的順序排列\n" "deque(['Michael', 'Terry', 'Graham'])" -#: ../../tutorial/datastructures.rst:196 +#: ../../tutorial/datastructures.rst:191 msgid "List Comprehensions" msgstr "List Comprehensions(串列綜合運算)" -#: ../../tutorial/datastructures.rst:198 +#: ../../tutorial/datastructures.rst:193 msgid "" "List comprehensions provide a concise way to create lists. Common " "applications are to make new lists where each element is the result of some " @@ -323,11 +323,11 @@ msgstr "" "基於一個序列或 iterable(可疊代物件),將每一個元素經過某個運算的結果串接起來" "成為新的 list,或是建立一個子序列,其每一個元素皆滿足一個特定的條件。" -#: ../../tutorial/datastructures.rst:203 +#: ../../tutorial/datastructures.rst:198 msgid "For example, assume we want to create a list of squares, like::" msgstr "舉例來說,假設我們要建立一個「平方的 list」: ::" -#: ../../tutorial/datastructures.rst:205 +#: ../../tutorial/datastructures.rst:200 msgid "" ">>> squares = []\n" ">>> for x in range(10):\n" @@ -343,7 +343,7 @@ msgstr "" ">>> squares\n" "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" -#: ../../tutorial/datastructures.rst:212 +#: ../../tutorial/datastructures.rst:207 msgid "" "Note that this creates (or overwrites) a variable named ``x`` that still " "exists after the loop completes. We can calculate the list of squares " @@ -352,23 +352,23 @@ msgstr "" "注意這是建立(或覆寫)一個變數叫 ``x``,其在迴圈結束後仍然存在。我們可以這樣" "產生平方串列而不造成任何 side effects(副作用): ::" -#: ../../tutorial/datastructures.rst:216 +#: ../../tutorial/datastructures.rst:211 msgid "squares = list(map(lambda x: x**2, range(10)))" msgstr "squares = list(map(lambda x: x**2, range(10)))" -#: ../../tutorial/datastructures.rst:218 +#: ../../tutorial/datastructures.rst:213 msgid "or, equivalently::" msgstr "或與此相等的: ::" -#: ../../tutorial/datastructures.rst:220 +#: ../../tutorial/datastructures.rst:215 msgid "squares = [x**2 for x in range(10)]" msgstr "squares = [x**2 for x in range(10)]" -#: ../../tutorial/datastructures.rst:222 +#: ../../tutorial/datastructures.rst:217 msgid "which is more concise and readable." msgstr "這樣更簡潔和易讀。" -#: ../../tutorial/datastructures.rst:224 +#: ../../tutorial/datastructures.rst:219 msgid "" "A list comprehension consists of brackets containing an expression followed " "by a :keyword:`!for` clause, then zero or more :keyword:`!for` or :keyword:`!" @@ -383,7 +383,7 @@ msgstr "" "和 :keyword:`!if` 子句情境下,對前面運算式求值的結果。例如,這個 list " "comprehension 組合了兩個 list 中彼此相異的元素: ::" -#: ../../tutorial/datastructures.rst:231 +#: ../../tutorial/datastructures.rst:226 msgid "" ">>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]\n" "[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" @@ -391,11 +391,11 @@ msgstr "" ">>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]\n" "[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" -#: ../../tutorial/datastructures.rst:234 +#: ../../tutorial/datastructures.rst:229 msgid "and it's equivalent to::" msgstr "而它就等於: ::" -#: ../../tutorial/datastructures.rst:236 +#: ../../tutorial/datastructures.rst:231 msgid "" ">>> combs = []\n" ">>> for x in [1,2,3]:\n" @@ -415,13 +415,13 @@ msgstr "" ">>> combs\n" "[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" -#: ../../tutorial/datastructures.rst:245 +#: ../../tutorial/datastructures.rst:240 msgid "" "Note how the order of the :keyword:`for` and :keyword:`if` statements is the " "same in both these snippets." msgstr "注意 :keyword:`for` 和 :keyword:`if` 在這兩段程式裡的順序是相同的。" -#: ../../tutorial/datastructures.rst:248 +#: ../../tutorial/datastructures.rst:243 msgid "" "If the expression is a tuple (e.g. the ``(x, y)`` in the previous example), " "it must be parenthesized. ::" @@ -429,7 +429,7 @@ msgstr "" "如果 expression 是一個 tuple(例如上面例子中的 ``(x, y)``),它必須加上括" "號: ::" -#: ../../tutorial/datastructures.rst:251 +#: ../../tutorial/datastructures.rst:246 msgid "" ">>> vec = [-4, -2, 0, 2, 4]\n" ">>> # create a new list with the values doubled\n" @@ -487,12 +487,12 @@ msgstr "" ">>> [num for elem in vec for num in elem]\n" "[1, 2, 3, 4, 5, 6, 7, 8, 9]" -#: ../../tutorial/datastructures.rst:279 +#: ../../tutorial/datastructures.rst:274 msgid "" "List comprehensions can contain complex expressions and nested functions::" msgstr "List comprehensions 可以含有複雜的 expression 和巢狀的函式: ::" -#: ../../tutorial/datastructures.rst:281 +#: ../../tutorial/datastructures.rst:276 msgid "" ">>> from math import pi\n" ">>> [str(round(pi, i)) for i in range(1, 6)]\n" @@ -502,11 +502,11 @@ msgstr "" ">>> [str(round(pi, i)) for i in range(1, 6)]\n" "['3.1', '3.14', '3.142', '3.1416', '3.14159']" -#: ../../tutorial/datastructures.rst:286 +#: ../../tutorial/datastructures.rst:281 msgid "Nested List Comprehensions" msgstr "巢狀的 List Comprehensions" -#: ../../tutorial/datastructures.rst:288 +#: ../../tutorial/datastructures.rst:283 msgid "" "The initial expression in a list comprehension can be any arbitrary " "expression, including another list comprehension." @@ -514,13 +514,13 @@ msgstr "" "在 list comprehension 中開頭的 expression 可以是任何形式的 expression,包括再" "寫一個 list comprehension。" -#: ../../tutorial/datastructures.rst:291 +#: ../../tutorial/datastructures.rst:286 msgid "" "Consider the following example of a 3x4 matrix implemented as a list of 3 " "lists of length 4::" msgstr "考慮以下表示 3x4 矩陣的範例,使用 list 包含 3 個長度為 4 的 list :" -#: ../../tutorial/datastructures.rst:294 +#: ../../tutorial/datastructures.rst:289 msgid "" ">>> matrix = [\n" "... [1, 2, 3, 4],\n" @@ -534,11 +534,11 @@ msgstr "" "... [9, 10, 11, 12],\n" "... ]" -#: ../../tutorial/datastructures.rst:300 +#: ../../tutorial/datastructures.rst:295 msgid "The following list comprehension will transpose rows and columns::" msgstr "以下的 list comprehension 會將矩陣的行與列作轉置: ::" -#: ../../tutorial/datastructures.rst:302 +#: ../../tutorial/datastructures.rst:297 msgid "" ">>> [[row[i] for row in matrix] for i in range(4)]\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" @@ -546,7 +546,7 @@ msgstr "" ">>> [[row[i] for row in matrix] for i in range(4)]\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" -#: ../../tutorial/datastructures.rst:305 +#: ../../tutorial/datastructures.rst:300 msgid "" "As we saw in the previous section, the inner list comprehension is evaluated " "in the context of the :keyword:`for` that follows it, so this example is " @@ -555,7 +555,7 @@ msgstr "" "如同我們在上一節看到的,內部的 list comprehension 會依據後面的 :keyword:" "`for` 環境被求值,所以這個例子就等於: ::" -#: ../../tutorial/datastructures.rst:309 +#: ../../tutorial/datastructures.rst:304 msgid "" ">>> transposed = []\n" ">>> for i in range(4):\n" @@ -571,11 +571,11 @@ msgstr "" ">>> transposed\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" -#: ../../tutorial/datastructures.rst:316 +#: ../../tutorial/datastructures.rst:311 msgid "which, in turn, is the same as::" msgstr "而它也和這一段相同: ::" -#: ../../tutorial/datastructures.rst:318 +#: ../../tutorial/datastructures.rst:313 msgid "" ">>> transposed = []\n" ">>> for i in range(4):\n" @@ -599,7 +599,7 @@ msgstr "" ">>> transposed\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" -#: ../../tutorial/datastructures.rst:329 +#: ../../tutorial/datastructures.rst:324 msgid "" "In the real world, you should prefer built-in functions to complex flow " "statements. The :func:`zip` function would do a great job for this use case::" @@ -607,7 +607,7 @@ msgstr "" "在實際運用上,我們傾向於使用內建函式 (built-in functions) 而不是複雜的流程控" "制陳述式。在這個例子中,使用 :func:`zip` 函式會非常有效率: ::" -#: ../../tutorial/datastructures.rst:332 +#: ../../tutorial/datastructures.rst:327 msgid "" ">>> list(zip(*matrix))\n" "[(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]" @@ -615,16 +615,101 @@ msgstr "" ">>> list(zip(*matrix))\n" "[(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]" -#: ../../tutorial/datastructures.rst:335 +#: ../../tutorial/datastructures.rst:330 msgid "" "See :ref:`tut-unpacking-arguments` for details on the asterisk in this line." msgstr "關於星號的更多細節,請參考\\ :ref:`tut-unpacking-arguments`。" -#: ../../tutorial/datastructures.rst:340 +#: ../../tutorial/datastructures.rst:333 +msgid "Unpacking in Lists and List Comprehensions" +msgstr "List 與 List Comprehensions 中的拆解" + +#: ../../tutorial/datastructures.rst:335 +msgid "" +"The section on :ref:`tut-unpacking-arguments` describes the use of ``*`` to " +"\"unpack\" the elements of an iterable object, providing each one separately " +"as an argument to a function. Unpacking can also be used in other contexts, " +"for example, when creating lists. When specifying elements of a list, " +"prefixing an expression by a ``*`` will unpack the result of that " +"expression, adding each of its elements to the list we're creating::" +msgstr "" + +#: ../../tutorial/datastructures.rst:342 +msgid "" +">>> x = [1, 2, 3]\n" +">>> [0, *x, 4, 5, 6]\n" +"[0, 1, 2, 3, 4, 5, 6]" +msgstr "" +">>> x = [1, 2, 3]\n" +">>> [0, *x, 4, 5, 6]\n" +"[0, 1, 2, 3, 4, 5, 6]" + +#: ../../tutorial/datastructures.rst:346 +msgid "" +"This only works if the expression following the ``*`` evaluates to an " +"iterable object; trying to unpack a non-iterable object will raise an " +"exception::" +msgstr "" + +#: ../../tutorial/datastructures.rst:349 +msgid "" +">>> x = 1\n" +">>> [0, *x, 2, 3, 4]\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" [0, *x, 2, 3, 4]\n" +"TypeError: Value after * must be an iterable, not int" +msgstr "" +">>> x = 1\n" +">>> [0, *x, 2, 3, 4]\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" [0, *x, 2, 3, 4]\n" +"TypeError: Value after * must be an iterable, not int" + +#: ../../tutorial/datastructures.rst:356 +msgid "" +"Unpacking can also be used in list comprehensions, as a way to build a new " +"list representing the concatenation of an arbitrary number of iterables::" +msgstr "" + +#: ../../tutorial/datastructures.rst:359 +msgid "" +">>> x = [[1, 2, 3], [4, 5, 6], [], [7], [8, 9]]\n" +">>> [*element for element in x]\n" +"[1, 2, 3, 4, 5, 6, 7, 8, 9]" +msgstr "" +">>> x = [[1, 2, 3], [4, 5, 6], [], [7], [8, 9]]\n" +">>> [*element for element in x]\n" +"[1, 2, 3, 4, 5, 6, 7, 8, 9]" + +#: ../../tutorial/datastructures.rst:363 +msgid "" +"Note that the effect is that each element from ``x`` is unpacked. This " +"works for arbitrary iterable objects, not just lists::" +msgstr "" + +#: ../../tutorial/datastructures.rst:366 +msgid "" +">>> x = [[1, 2, 3], 'cat', {'spam': 'eggs'}]\n" +">>> [*element for element in x]\n" +"[1, 2, 3, 'c', 'a', 't', 'spam']" +msgstr "" +">>> x = [[1, 2, 3], 'cat', {'spam': 'eggs'}]\n" +">>> [*element for element in x]\n" +"[1, 2, 3, 'c', 'a', 't', 'spam']" + +#: ../../tutorial/datastructures.rst:370 +msgid "" +"But if the objects in ``x`` are not iterable, this expression would again " +"raise an exception." +msgstr "" + +#: ../../tutorial/datastructures.rst:376 msgid "The :keyword:`!del` statement" msgstr ":keyword:`!del` 陳述式" -#: ../../tutorial/datastructures.rst:342 +#: ../../tutorial/datastructures.rst:378 msgid "" "There is a way to remove an item from a list given its index instead of its " "value: the :keyword:`del` statement. This differs from the :meth:`~list." @@ -637,7 +722,7 @@ msgstr "" "除 list 中的片段或者清空整個 list(我們之前藉由指派一個空的 list 給想刪除的片" "段來完成這件事)。例如: ::" -#: ../../tutorial/datastructures.rst:348 +#: ../../tutorial/datastructures.rst:384 msgid "" ">>> a = [-1, 1, 66.25, 333, 333, 1234.5]\n" ">>> del a[0]\n" @@ -661,15 +746,15 @@ msgstr "" ">>> a\n" "[]" -#: ../../tutorial/datastructures.rst:359 +#: ../../tutorial/datastructures.rst:395 msgid ":keyword:`del` can also be used to delete entire variables::" msgstr ":keyword:`del` 也可以用來刪除整個變數: ::" -#: ../../tutorial/datastructures.rst:361 +#: ../../tutorial/datastructures.rst:397 msgid ">>> del a" msgstr ">>> del a" -#: ../../tutorial/datastructures.rst:363 +#: ../../tutorial/datastructures.rst:399 msgid "" "Referencing the name ``a`` hereafter is an error (at least until another " "value is assigned to it). We'll find other uses for :keyword:`del` later." @@ -677,11 +762,11 @@ msgstr "" "刪除之後,對 ``a`` 的參照將會造成錯誤(至少在另一個值又被指派到它之前)。我們" "將在後面看到更多關於 :keyword:`del` 的其他用法。" -#: ../../tutorial/datastructures.rst:370 +#: ../../tutorial/datastructures.rst:406 msgid "Tuples and Sequences" msgstr "Tuples 和序列 (Sequences)" -#: ../../tutorial/datastructures.rst:372 +#: ../../tutorial/datastructures.rst:408 msgid "" "We saw that lists and strings have many common properties, such as indexing " "and slicing operations. They are two examples of *sequence* data types " @@ -694,12 +779,12 @@ msgstr "" "`typesseq`\\ )。由於 Python 是個持續發展中的語言,未來可能還會有其他的序列資" "料類型加入。接著要介紹是下一個標準序列資料類型:*tuple*。" -#: ../../tutorial/datastructures.rst:378 +#: ../../tutorial/datastructures.rst:414 msgid "" "A tuple consists of a number of values separated by commas, for instance::" msgstr "一個 tuple 是由若干個值藉由逗號區隔而組成,例如: ::" -#: ../../tutorial/datastructures.rst:380 +#: ../../tutorial/datastructures.rst:416 msgid "" ">>> t = 12345, 54321, 'hello!'\n" ">>> t[0]\n" @@ -718,7 +803,11 @@ msgid "" ">>> # but they can contain mutable objects:\n" ">>> v = ([1, 2, 3], [3, 2, 1])\n" ">>> v\n" -"([1, 2, 3], [3, 2, 1])" +"([1, 2, 3], [3, 2, 1])\n" +">>> # they support unpacking just like lists:\n" +">>> x = [1, 2, 3]\n" +">>> 0, *x, 4\n" +"(0, 1, 2, 3, 4)" msgstr "" ">>> t = 12345, 54321, 'hello!'\n" ">>> t[0]\n" @@ -734,12 +823,16 @@ msgstr "" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "TypeError: 'tuple' object does not support item assignment\n" -">>> # but they can contain mutable objects:\n" +">>> # 但它們可以包含可變物件:\n" ">>> v = ([1, 2, 3], [3, 2, 1])\n" ">>> v\n" -"([1, 2, 3], [3, 2, 1])" +"([1, 2, 3], [3, 2, 1])\n" +">>> # 它們和 list 一樣支援拆解:\n" +">>> x = [1, 2, 3]\n" +">>> 0, *x, 4\n" +"(0, 1, 2, 3, 4)" -#: ../../tutorial/datastructures.rst:400 +#: ../../tutorial/datastructures.rst:439 msgid "" "As you see, on output tuples are always enclosed in parentheses, so that " "nested tuples are interpreted correctly; they may be input with or without " @@ -753,7 +846,7 @@ msgstr "" "使用常常是有其必要的(譬如此 tuple 是一個較大的運算式的一部分)。指派東西給 " "tuple 中的個別項目是不行的,但是可以建立含有可變物件(譬如 list)的 tuple。" -#: ../../tutorial/datastructures.rst:407 +#: ../../tutorial/datastructures.rst:446 msgid "" "Though tuples may seem similar to lists, they are often used in different " "situations and for different purposes. Tuples are :term:`immutable`, and " @@ -770,7 +863,7 @@ msgstr "" "List 是 :term:`mutable`\\ (可變的),其元素通常是同質的且可藉由疊代整個 " "list 來存取。" -#: ../../tutorial/datastructures.rst:415 +#: ../../tutorial/datastructures.rst:454 msgid "" "A special problem is the construction of tuples containing 0 or 1 items: the " "syntax has some extra quirks to accommodate these. Empty tuples are " @@ -783,7 +876,7 @@ msgstr "" "加上一個逗點來建立(用括號把一個單一的值包住是不夠的)。醜,但有效率。例" "如: ::" -#: ../../tutorial/datastructures.rst:421 +#: ../../tutorial/datastructures.rst:460 msgid "" ">>> empty = ()\n" ">>> singleton = 'hello', # <-- note trailing comma\n" @@ -803,7 +896,7 @@ msgstr "" ">>> singleton\n" "('hello',)" -#: ../../tutorial/datastructures.rst:430 +#: ../../tutorial/datastructures.rst:469 msgid "" "The statement ``t = 12345, 54321, 'hello!'`` is an example of *tuple " "packing*: the values ``12345``, ``54321`` and ``'hello!'`` are packed " @@ -812,11 +905,11 @@ msgstr "" "陳述式 ``t = 12345, 54321, 'hello!'`` 就是一個 *tuple packing* 的例子:" "``12345``,``54321`` 和 ``'hello!'`` 一起被放進 tuple 裡。反向操作也可以: ::" -#: ../../tutorial/datastructures.rst:434 +#: ../../tutorial/datastructures.rst:473 msgid ">>> x, y, z = t" msgstr ">>> x, y, z = t" -#: ../../tutorial/datastructures.rst:436 +#: ../../tutorial/datastructures.rst:475 msgid "" "This is called, appropriately enough, *sequence unpacking* and works for any " "sequence on the right-hand side. Sequence unpacking requires that there are " @@ -828,11 +921,11 @@ msgstr "" "列。序列拆解要求等號左邊的變數數量必須與等號右邊的序列中的元素數量相同。注" "意,多重指派就只是 tuple packing 和序列拆解的結合而已。" -#: ../../tutorial/datastructures.rst:446 +#: ../../tutorial/datastructures.rst:485 msgid "Sets" msgstr "集合 (Sets)" -#: ../../tutorial/datastructures.rst:448 +#: ../../tutorial/datastructures.rst:487 msgid "" "Python also includes a data type for :ref:`sets `. A set is an " "unordered collection with no duplicate elements. Basic uses include " @@ -844,7 +937,7 @@ msgstr "" "且不含重複元素的集合。基本的用途包括成員測試和消除重複的項目。集合物件也支援" "像是聯集、交集、差集和對稱差集等數學運算。" -#: ../../tutorial/datastructures.rst:454 +#: ../../tutorial/datastructures.rst:493 msgid "" "Curly braces or the :func:`set` function can be used to create sets. Note: " "to create an empty set you have to use ``set()``, not ``{}``; the latter " @@ -855,17 +948,17 @@ msgstr "" "使用 ``set()`` 而不是 ``{}``;後者會建立一個空的 dictionary,一種我們將在下一" "節討論的資料結構。" -#: ../../tutorial/datastructures.rst:458 +#: ../../tutorial/datastructures.rst:497 msgid "" "Because sets are unordered, iterating over them or printing them can produce " "the elements in a different order than you expect." msgstr "因為 set 是無序的,疊代或印出它們時,元素的順序可能與你預期的不同。" -#: ../../tutorial/datastructures.rst:461 +#: ../../tutorial/datastructures.rst:500 msgid "Here is a brief demonstration::" msgstr "這裡是一個簡單的演示: ::" -#: ../../tutorial/datastructures.rst:463 +#: ../../tutorial/datastructures.rst:502 msgid "" ">>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}\n" ">>> print(basket) # show that duplicates have been " @@ -914,29 +1007,37 @@ msgstr "" ">>> a ^ b # 在 a 或 b 中但不在兩者中的字母\n" "{'r', 'd', 'b', 'm', 'z', 'l'}" -#: ../../tutorial/datastructures.rst:486 +#: ../../tutorial/datastructures.rst:525 msgid "" "Similarly to :ref:`list comprehensions `, set comprehensions " -"are also supported::" +"are also supported, including comprehensions with unpacking::" msgstr "" "和 :ref:`list comprehensions ` 類似,也有 set comprehensions" -"(集合綜合運算): ::" +"(集合綜合運算),包括帶有拆解的綜合運算: ::" -#: ../../tutorial/datastructures.rst:489 +#: ../../tutorial/datastructures.rst:528 msgid "" ">>> a = {x for x in 'abracadabra' if x not in 'abc'}\n" ">>> a\n" -"{'r', 'd'}" +"{'r', 'd'}\n" +"\n" +">>> fruits = [{'apple', 'avocado', 'apricot'}, {'banana', 'blueberry'}]\n" +">>> {*fruit for fruit in fruits}\n" +"{'blueberry', 'banana', 'avocado', 'apple', 'apricot'}" msgstr "" ">>> a = {x for x in 'abracadabra' if x not in 'abc'}\n" ">>> a\n" -"{'r', 'd'}" +"{'r', 'd'}\n" +"\n" +">>> fruits = [{'apple', 'avocado', 'apricot'}, {'banana', 'blueberry'}]\n" +">>> {*fruit for fruit in fruits}\n" +"{'blueberry', 'banana', 'avocado', 'apple', 'apricot'}" -#: ../../tutorial/datastructures.rst:497 +#: ../../tutorial/datastructures.rst:540 msgid "Dictionaries" msgstr "字典(Dictionary)" -#: ../../tutorial/datastructures.rst:499 +#: ../../tutorial/datastructures.rst:542 msgid "" "Another useful data type built into Python is the *dictionary* (see :ref:" "`typesmapping`). Dictionaries are sometimes found in other languages as " @@ -959,7 +1060,7 @@ msgstr "" "assignment) 或是像 :meth:`~list.append` 和 :meth:`~list.extend` 等方法被修" "改。" -#: ../../tutorial/datastructures.rst:510 +#: ../../tutorial/datastructures.rst:553 msgid "" "It is best to think of a dictionary as a set of *key: value* pairs, with the " "requirement that the keys are unique (within one dictionary). A pair of " @@ -972,7 +1073,7 @@ msgstr "" "個空的 dictionary:``{}``。將一串由逗號分隔的鍵值對置於大括號則可初始化字典的" "鍵值對。這同樣也是字典輸出時的格式。" -#: ../../tutorial/datastructures.rst:516 +#: ../../tutorial/datastructures.rst:559 msgid "" "The main operations on a dictionary are storing a value with some key and " "extracting the value given the key. It is also possible to delete a key:" @@ -983,7 +1084,7 @@ msgstr "" "用 ``del`` 來刪除鍵值對。如果我們使用用過的鍵來儲存,該鍵所對應的較舊的值會被" "覆蓋。" -#: ../../tutorial/datastructures.rst:521 +#: ../../tutorial/datastructures.rst:564 msgid "" "Extracting a value for a non-existent key by subscripting (``d[key]``) " "raises a :exc:`KeyError`. To avoid getting this error when trying to access " @@ -996,7 +1097,7 @@ msgstr "" "法,如果該鍵不存在於字典中,該方法會回傳 ``None``\\ (或者一個指定的預設" "值)。" -#: ../../tutorial/datastructures.rst:526 +#: ../../tutorial/datastructures.rst:569 msgid "" "Performing ``list(d)`` on a dictionary returns a list of all the keys used " "in the dictionary, in insertion order (if you want it sorted, just use " @@ -1007,11 +1108,11 @@ msgstr "" "為插入時的順序。(若想要排序,則使用 ``sorted(d)`` 代替即可)。如果想確認一個" "鍵是否已存在於字典中,可使用關鍵字 :keyword:`in`。" -#: ../../tutorial/datastructures.rst:531 +#: ../../tutorial/datastructures.rst:574 msgid "Here is a small example using a dictionary::" msgstr "這是個使用一個 dictionary 的簡單範例: ::" -#: ../../tutorial/datastructures.rst:533 +#: ../../tutorial/datastructures.rst:576 msgid "" ">>> tel = {'jack': 4098, 'sape': 4139}\n" ">>> tel['guido'] = 4127\n" @@ -1063,13 +1164,13 @@ msgstr "" ">>> 'jack' not in tel\n" "False" -#: ../../tutorial/datastructures.rst:558 +#: ../../tutorial/datastructures.rst:601 msgid "" "The :func:`dict` constructor builds dictionaries directly from sequences of " "key-value pairs::" msgstr "函式 :func:`dict` 可直接透過一串鍵值對序列來建立 dictionary: ::" -#: ../../tutorial/datastructures.rst:561 +#: ../../tutorial/datastructures.rst:604 msgid "" ">>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])\n" "{'sape': 4139, 'guido': 4127, 'jack': 4098}" @@ -1077,14 +1178,14 @@ msgstr "" ">>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])\n" "{'sape': 4139, 'guido': 4127, 'jack': 4098}" -#: ../../tutorial/datastructures.rst:564 +#: ../../tutorial/datastructures.rst:607 msgid "" "In addition, dict comprehensions can be used to create dictionaries from " "arbitrary key and value expressions::" msgstr "" "此外,dict comprehensions 也可以透過任意鍵與值的運算式來建立 dictionary : ::" -#: ../../tutorial/datastructures.rst:567 +#: ../../tutorial/datastructures.rst:610 msgid "" ">>> {x: x**2 for x in (2, 4, 6)}\n" "{2: 4, 4: 16, 6: 36}" @@ -1092,14 +1193,40 @@ msgstr "" ">>> {x: x**2 for x in (2, 4, 6)}\n" "{2: 4, 4: 16, 6: 36}" -#: ../../tutorial/datastructures.rst:570 +#: ../../tutorial/datastructures.rst:613 +msgid "" +"And dictionary unpacking (via ``**``) can be used to merge multiple " +"dictionaries::" +msgstr "" + +#: ../../tutorial/datastructures.rst:616 +msgid "" +">>> odds = {i: i**2 for i in (1, 3, 5)}\n" +">>> evens = {i: i**2 for i in (2, 4, 6)}\n" +">>> {**odds, **evens}\n" +"{1: 1, 3: 9, 5: 25, 2: 4, 4: 16, 6: 36}\n" +"\n" +">>> all_values = [odds, evens, {0: 0}]\n" +">>> {**i for i in all_values}\n" +"{1: 1, 3: 9, 5: 25, 2: 4, 4: 16, 6: 36, 0: 0}" +msgstr "" +">>> odds = {i: i**2 for i in (1, 3, 5)}\n" +">>> evens = {i: i**2 for i in (2, 4, 6)}\n" +">>> {**odds, **evens}\n" +"{1: 1, 3: 9, 5: 25, 2: 4, 4: 16, 6: 36}\n" +"\n" +">>> all_values = [odds, evens, {0: 0}]\n" +">>> {**i for i in all_values}\n" +"{1: 1, 3: 9, 5: 25, 2: 4, 4: 16, 6: 36, 0: 0}" + +#: ../../tutorial/datastructures.rst:625 msgid "" "When the keys are simple strings, it is sometimes easier to specify pairs " "using keyword arguments::" msgstr "" "當鍵是簡單的字串時,使用關鍵字引數 (keyword arguments) 有時會較為簡潔: ::" -#: ../../tutorial/datastructures.rst:573 +#: ../../tutorial/datastructures.rst:628 msgid "" ">>> dict(sape=4139, guido=4127, jack=4098)\n" "{'sape': 4139, 'guido': 4127, 'jack': 4098}" @@ -1107,11 +1234,11 @@ msgstr "" ">>> dict(sape=4139, guido=4127, jack=4098)\n" "{'sape': 4139, 'guido': 4127, 'jack': 4098}" -#: ../../tutorial/datastructures.rst:580 +#: ../../tutorial/datastructures.rst:635 msgid "Looping Techniques" msgstr "迴圈技巧" -#: ../../tutorial/datastructures.rst:582 +#: ../../tutorial/datastructures.rst:637 msgid "" "When looping through dictionaries, the key and corresponding value can be " "retrieved at the same time using the :meth:`~dict.items` method. ::" @@ -1119,7 +1246,7 @@ msgstr "" "當對 dictionary 作迴圈時,鍵以及其對應的值可以藉由使用 :meth:`~dict.items` " "method 來同時取得: ::" -#: ../../tutorial/datastructures.rst:585 +#: ../../tutorial/datastructures.rst:640 msgid "" ">>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}\n" ">>> for k, v in knights.items():\n" @@ -1135,7 +1262,7 @@ msgstr "" "gallahad the pure\n" "robin the brave" -#: ../../tutorial/datastructures.rst:592 +#: ../../tutorial/datastructures.rst:647 msgid "" "When looping through a sequence, the position index and corresponding value " "can be retrieved at the same time using the :func:`enumerate` function. ::" @@ -1143,7 +1270,7 @@ msgstr "" "當對序列作迴圈時,位置索引及其對應的值可以藉由使用 :func:`enumerate` 函式來同" "時取得: ::" -#: ../../tutorial/datastructures.rst:595 +#: ../../tutorial/datastructures.rst:650 msgid "" ">>> for i, v in enumerate(['tic', 'tac', 'toe']):\n" "... print(i, v)\n" @@ -1159,14 +1286,14 @@ msgstr "" "1 tac\n" "2 toe" -#: ../../tutorial/datastructures.rst:602 +#: ../../tutorial/datastructures.rst:657 msgid "" "To loop over two or more sequences at the same time, the entries can be " "paired with the :func:`zip` function. ::" msgstr "" "要同時對兩個以上的序列作迴圈,可以將其以成對的方式放入 :func:`zip` 函式: ::" -#: ../../tutorial/datastructures.rst:605 +#: ../../tutorial/datastructures.rst:660 msgid "" ">>> questions = ['name', 'quest', 'favorite color']\n" ">>> answers = ['lancelot', 'the holy grail', 'blue']\n" @@ -1186,7 +1313,7 @@ msgstr "" "What is your quest? It is the holy grail.\n" "What is your favorite color? It is blue." -#: ../../tutorial/datastructures.rst:614 +#: ../../tutorial/datastructures.rst:669 msgid "" "To loop over a sequence in reverse, first specify the sequence in a forward " "direction and then call the :func:`reversed` function. ::" @@ -1194,7 +1321,7 @@ msgstr "" "要對序列作反向的迴圈,首先先寫出正向的序列,再對其使用 :func:`reversed` 函" "式: ::" -#: ../../tutorial/datastructures.rst:617 +#: ../../tutorial/datastructures.rst:672 msgid "" ">>> for i in reversed(range(1, 10, 2)):\n" "... print(i)\n" @@ -1214,7 +1341,7 @@ msgstr "" "3\n" "1" -#: ../../tutorial/datastructures.rst:626 +#: ../../tutorial/datastructures.rst:681 msgid "" "To loop over a sequence in sorted order, use the :func:`sorted` function " "which returns a new sorted list while leaving the source unaltered. ::" @@ -1222,7 +1349,7 @@ msgstr "" "要以迴圈對序列作排序,使用 :func:`sorted` 函式會得到一個新的經排序過的 " "list ,但不會改變原本的序列: ::" -#: ../../tutorial/datastructures.rst:629 +#: ../../tutorial/datastructures.rst:684 msgid "" ">>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']\n" ">>> for i in sorted(basket):\n" @@ -1246,7 +1373,7 @@ msgstr "" "orange\n" "pear" -#: ../../tutorial/datastructures.rst:640 +#: ../../tutorial/datastructures.rst:695 msgid "" "Using :func:`set` on a sequence eliminates duplicate elements. The use of :" "func:`sorted` in combination with :func:`set` over a sequence is an " @@ -1256,7 +1383,7 @@ msgstr "" "對序列使用 :func:`set` 可去除重複元素。對序列使用 :func:`sorted` 加上 :func:" "`set`,則是對經過排序後的非重複元素跑迴圈的慣用方法: ::" -#: ../../tutorial/datastructures.rst:644 +#: ../../tutorial/datastructures.rst:699 msgid "" ">>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']\n" ">>> for f in sorted(set(basket)):\n" @@ -1276,7 +1403,7 @@ msgstr "" "orange\n" "pear" -#: ../../tutorial/datastructures.rst:653 +#: ../../tutorial/datastructures.rst:708 msgid "" "It is sometimes tempting to change a list while you are looping over it; " "however, it is often simpler and safer to create a new list instead. ::" @@ -1284,7 +1411,7 @@ msgstr "" "有時我們會想要以迴圈來改變的一個 list,但是,通常建立一個新的 list 會更簡單且" "安全: ::" -#: ../../tutorial/datastructures.rst:656 +#: ../../tutorial/datastructures.rst:711 msgid "" ">>> import math\n" ">>> raw_data = [56.2, float('NaN'), 51.7, 55.3, 52.5, float('NaN'), 47.8]\n" @@ -1306,11 +1433,11 @@ msgstr "" ">>> filtered_data\n" "[56.2, 51.7, 55.3, 52.5, 47.8]" -#: ../../tutorial/datastructures.rst:670 +#: ../../tutorial/datastructures.rst:725 msgid "More on Conditions" msgstr "深入了解條件 (Condition)" -#: ../../tutorial/datastructures.rst:672 +#: ../../tutorial/datastructures.rst:727 msgid "" "The conditions used in ``while`` and ``if`` statements can contain any " "operators, not just comparisons." @@ -1318,7 +1445,7 @@ msgstr "" "使用在 ``while`` 和 ``if`` 陳述式的條件句可以包含任何運算子,而不是只有比較運" "算子 (comparisons) 。" -#: ../../tutorial/datastructures.rst:676 +#: ../../tutorial/datastructures.rst:731 msgid "" "The comparison operators ``in`` and ``not in`` are membership tests that " "determine whether a value is in (or not in) a container. The operators " @@ -1330,7 +1457,7 @@ msgstr "" "(或不存在)。運算子 ``is`` 和 ``is not`` 比較兩個物件是否真的是相同的物件。" "所有比較運算子的優先度都相同且都低於數值運算子。" -#: ../../tutorial/datastructures.rst:682 +#: ../../tutorial/datastructures.rst:737 msgid "" "Comparisons can be chained. For example, ``a < b == c`` tests whether ``a`` " "is less than ``b`` and moreover ``b`` equals ``c``." @@ -1338,7 +1465,7 @@ msgstr "" "比較運算是可以串連在一起的。例如, ``a < b == c`` 就是在測試 ``a`` 是否小於 " "``b`` 和 ``b`` 是否等於 ``c``。" -#: ../../tutorial/datastructures.rst:685 +#: ../../tutorial/datastructures.rst:740 msgid "" "Comparisons may be combined using the Boolean operators ``and`` and ``or``, " "and the outcome of a comparison (or of any other Boolean expression) may be " @@ -1352,7 +1479,7 @@ msgstr "" "其中,``not`` 的優先度最高,``or`` 的優先度最低,因此 ``A and not B or C`` 等" "同於 ``(A and (not B)) or C``。一如往常,括號可以用來表示任何想要的組合。" -#: ../../tutorial/datastructures.rst:692 +#: ../../tutorial/datastructures.rst:747 msgid "" "The Boolean operators ``and`` and ``or`` are so-called *short-circuit* " "operators: their arguments are evaluated from left to right, and evaluation " @@ -1366,13 +1493,13 @@ msgstr "" "``B`` 為假,則 ``A and B and C`` 的運算並不會執行到 ``C``。當運算結果被當成一" "般值而非布林值時,短路運算子的回傳值為最後被求值的引數。" -#: ../../tutorial/datastructures.rst:699 +#: ../../tutorial/datastructures.rst:754 msgid "" "It is possible to assign the result of a comparison or other Boolean " "expression to a variable. For example, ::" msgstr "將一個比較運算或其他布林運算式的結果指派給一個變數是可以的。例如: ::" -#: ../../tutorial/datastructures.rst:702 +#: ../../tutorial/datastructures.rst:757 msgid "" ">>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'\n" ">>> non_null = string1 or string2 or string3\n" @@ -1384,7 +1511,7 @@ msgstr "" ">>> non_null\n" "'Trondheim'" -#: ../../tutorial/datastructures.rst:707 +#: ../../tutorial/datastructures.rst:762 msgid "" "Note that in Python, unlike C, assignment inside expressions must be done " "explicitly with the :ref:`walrus operator ` ``:=``。 這樣做避免了" "在 C 語言裡常見的一種問題:想要打 ``==`` 卻在運算式裡輸入 ``=``。" -#: ../../tutorial/datastructures.rst:717 +#: ../../tutorial/datastructures.rst:772 msgid "Comparing Sequences and Other Types" msgstr "序列和其他資料類型之比較" -#: ../../tutorial/datastructures.rst:718 +#: ../../tutorial/datastructures.rst:773 msgid "" "Sequence objects typically may be compared to other objects with the same " "sequence type. The comparison uses *lexicographical* ordering: first the " @@ -1422,7 +1549,7 @@ msgstr "" "那個序列為較小的序列。字串的詞典式順序使用 Unicode 的編碼位置 (code point) 編" "號來排序個別字元。以下是一些相同序列類型的比較: ::" -#: ../../tutorial/datastructures.rst:730 +#: ../../tutorial/datastructures.rst:785 msgid "" "(1, 2, 3) < (1, 2, 4)\n" "[1, 2, 3] < [1, 2, 4]\n" @@ -1440,7 +1567,7 @@ msgstr "" "(1, 2, 3) == (1.0, 2.0, 3.0)\n" "(1, 2, ('aa', 'ab')) < (1, 2, ('abc', 'a'), 4)" -#: ../../tutorial/datastructures.rst:738 +#: ../../tutorial/datastructures.rst:793 msgid "" "Note that comparing objects of different types with ``<`` or ``>`` is legal " "provided that the objects have appropriate comparison methods. For example, " @@ -1452,14 +1579,23 @@ msgstr "" "比較方法。例如,混合的數值類型是根據它們數值來做比較,所以 0 等於 0.0,等等。" "否則直譯器會選擇丟出一個 :exc:`TypeError` 錯誤而不是提供一個任意的排序。" -#: ../../tutorial/datastructures.rst:746 +#: ../../tutorial/datastructures.rst:801 msgid "Footnotes" msgstr "註解" -#: ../../tutorial/datastructures.rst:747 +#: ../../tutorial/datastructures.rst:802 msgid "" "Other languages may return the mutated object, which allows method chaining, " "such as ``d->insert(\"a\")->remove(\"b\")->sort();``." msgstr "" "其他語言可以回傳變更後的物件,這就允許 method 的串連,例如 ``d-" ">insert(\"a\")->remove(\"b\")->sort();``。" + +#~ msgid "" +#~ ">>> a = {x for x in 'abracadabra' if x not in 'abc'}\n" +#~ ">>> a\n" +#~ "{'r', 'd'}" +#~ msgstr "" +#~ ">>> a = {x for x in 'abracadabra' if x not in 'abc'}\n" +#~ ">>> a\n" +#~ "{'r', 'd'}" diff --git a/tutorial/floatingpoint.po b/tutorial/floatingpoint.po index 88fb4edd3d4..b7ee2750a7a 100644 --- a/tutorial/floatingpoint.po +++ b/tutorial/floatingpoint.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-06-22 14:43+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -26,7 +26,7 @@ msgstr "" msgid "Floating-Point Arithmetic: Issues and Limitations" msgstr "浮點數運算:問題與限制" -#: ../../tutorial/floatingpoint.rst:16 +#: ../../tutorial/floatingpoint.rst:12 msgid "" "Floating-point numbers are represented in computer hardware as base 2 " "(binary) fractions. For example, the **decimal** fraction ``0.625`` has " @@ -41,7 +41,7 @@ msgstr "" "兩個小數有相同的數值,而唯一真正的不同在於前者以十進位表示,後者以二進位表" "示。" -#: ../../tutorial/floatingpoint.rst:23 +#: ../../tutorial/floatingpoint.rst:19 msgid "" "Unfortunately, most decimal fractions cannot be represented exactly as " "binary fractions. A consequence is that, in general, the decimal floating-" @@ -51,7 +51,7 @@ msgstr "" "不幸的是,大多數十進位小數無法精準地以二進位小數表示。一般的結果為,你輸入的" "十進位浮點數只能由實際儲存在計算機中的二進位浮點數近似。" -#: ../../tutorial/floatingpoint.rst:28 +#: ../../tutorial/floatingpoint.rst:24 msgid "" "The problem is easier to understand at first in base 10. Consider the " "fraction 1/3. You can approximate that as a base 10 fraction::" @@ -59,23 +59,23 @@ msgstr "" "在十進位中,這個問題更容易被理解。以分數 1/3 為例,你可以將其近似為十進位小" "數: ::" -#: ../../tutorial/floatingpoint.rst:31 +#: ../../tutorial/floatingpoint.rst:27 msgid "0.3" msgstr "0.3" -#: ../../tutorial/floatingpoint.rst:33 ../../tutorial/floatingpoint.rst:37 +#: ../../tutorial/floatingpoint.rst:29 ../../tutorial/floatingpoint.rst:33 msgid "or, better, ::" msgstr "或者,更好的近似: ::" -#: ../../tutorial/floatingpoint.rst:35 +#: ../../tutorial/floatingpoint.rst:31 msgid "0.33" msgstr "0.33" -#: ../../tutorial/floatingpoint.rst:39 +#: ../../tutorial/floatingpoint.rst:35 msgid "0.333" msgstr "0.333" -#: ../../tutorial/floatingpoint.rst:41 +#: ../../tutorial/floatingpoint.rst:37 msgid "" "and so on. No matter how many digits you're willing to write down, the " "result will never be exactly 1/3, but will be an increasingly better " @@ -84,7 +84,7 @@ msgstr "" "依此類推,不論你使用多少位數表示小數,最後的結果都無法精準地表示 1/3,但你還" "是能越來越精準地表示 1/3。" -#: ../../tutorial/floatingpoint.rst:45 +#: ../../tutorial/floatingpoint.rst:41 msgid "" "In the same way, no matter how many base 2 digits you're willing to use, the " "decimal value 0.1 cannot be represented exactly as a base 2 fraction. In " @@ -93,11 +93,11 @@ msgstr "" "同樣的道理,不論你願意以多少位數表示二進位小數,十進位小數 0.1 都無法被二進位" "小數精準地表達。在二進位小數中,1/10 會是一個無限循環小數: ::" -#: ../../tutorial/floatingpoint.rst:49 +#: ../../tutorial/floatingpoint.rst:45 msgid "0.0001100110011001100110011001100110011001100110011..." msgstr "0.0001100110011001100110011001100110011001100110011..." -#: ../../tutorial/floatingpoint.rst:51 +#: ../../tutorial/floatingpoint.rst:47 msgid "" "Stop at any finite number of bits, and you get an approximation. On most " "machines today, floats are approximated using a binary fraction with the " @@ -111,7 +111,7 @@ msgstr "" "則是以二為底的指數。在 1/10 的例子中,二進位分數為 ``3602879701896397 / 2 ** " "55``,而這樣的表示十分地接近,但不完全等同於 1/10 的真正數值。" -#: ../../tutorial/floatingpoint.rst:58 +#: ../../tutorial/floatingpoint.rst:54 msgid "" "Many users are not aware of the approximation because of the way values are " "displayed. Python only prints a decimal approximation to the true decimal " @@ -124,7 +124,7 @@ msgstr "" "計算機中,如果 Python 真的會印出完整的十進位數值,其表示儲存在計算機中的 0.1 " "的二進位近似值,它將顯示為: ::" -#: ../../tutorial/floatingpoint.rst:64 +#: ../../tutorial/floatingpoint.rst:60 msgid "" ">>> 0.1\n" "0.1000000000000000055511151231257827021181583404541015625" @@ -132,7 +132,7 @@ msgstr "" ">>> 0.1\n" "0.1000000000000000055511151231257827021181583404541015625" -#: ../../tutorial/floatingpoint.rst:67 +#: ../../tutorial/floatingpoint.rst:63 msgid "" "That is more digits than most people find useful, so Python keeps the number " "of digits manageable by displaying a rounded value instead:" @@ -140,7 +140,7 @@ msgstr "" "這比一般人感到有用的位數還多,所以 Python 將位數保持在可以接受的範圍,只顯示" "捨入後的數值:" -#: ../../tutorial/floatingpoint.rst:70 +#: ../../tutorial/floatingpoint.rst:66 msgid "" ">>> 1 / 10\n" "0.1" @@ -148,7 +148,7 @@ msgstr "" ">>> 1 / 10\n" "0.1" -#: ../../tutorial/floatingpoint.rst:75 +#: ../../tutorial/floatingpoint.rst:71 msgid "" "Just remember, even though the printed result looks like the exact value of " "1/10, the actual stored value is the nearest representable binary fraction." @@ -156,7 +156,7 @@ msgstr "" "一定要記住,雖然印出的數字看起來是精準的 1/10,但真正儲存的數值是能表示的二進" "位分數中,最接近精準數值的數。" -#: ../../tutorial/floatingpoint.rst:78 +#: ../../tutorial/floatingpoint.rst:74 msgid "" "Interestingly, there are many different decimal numbers that share the same " "nearest approximate binary fraction. For example, the numbers ``0.1`` and " @@ -172,7 +172,7 @@ msgstr "" "``3602879701896397 / 2 ** 55`` 近似。由於這三個十進位數值共用同一個近似值,任" "何一個數值都可以被顯示,同時保持 ``eval(repr(x)) == x``。" -#: ../../tutorial/floatingpoint.rst:86 +#: ../../tutorial/floatingpoint.rst:82 msgid "" "Historically, the Python prompt and built-in :func:`repr` function would " "choose the one with 17 significant digits, ``0.10000000000000001``. " @@ -183,7 +183,7 @@ msgstr "" "有 17 個有效位元的數:``0.10000000000000001``。從 Python 3.1 版開始,Python" "(在大部分的系統上)現在能選擇其中最短的數並簡單地顯示為 ``0.1``。" -#: ../../tutorial/floatingpoint.rst:91 +#: ../../tutorial/floatingpoint.rst:87 msgid "" "Note that this is in the very nature of binary floating point: this is not a " "bug in Python, and it is not a bug in your code either. You'll see the same " @@ -196,7 +196,7 @@ msgstr "" "中(雖然有些程式語言預設不會\\ *顯示*\\ 該差異,有些甚至是在所有的輸出模式中" "都不會顯示。)" -#: ../../tutorial/floatingpoint.rst:97 +#: ../../tutorial/floatingpoint.rst:93 msgid "" "For more pleasant output, you may wish to use string formatting to produce a " "limited number of significant digits:" @@ -204,7 +204,7 @@ msgstr "" "為求更優雅的輸出,你可能想要使用字串的格式化 (string formatting) 產生限定的有" "效位數:" -#: ../../tutorial/floatingpoint.rst:100 +#: ../../tutorial/floatingpoint.rst:96 msgid "" ">>> format(math.pi, '.12g') # give 12 significant digits\n" "'3.14159265359'\n" @@ -224,7 +224,7 @@ msgstr "" ">>> repr(math.pi)\n" "'3.141592653589793'" -#: ../../tutorial/floatingpoint.rst:111 +#: ../../tutorial/floatingpoint.rst:107 msgid "" "It's important to realize that this is, in a real sense, an illusion: you're " "simply rounding the *display* of the true machine value." @@ -232,7 +232,7 @@ msgstr "" "要了解一件很重要的事,在真正意義上,浮點數的表示是一種幻覺:你基本上在捨入真" "正機器數值所\\ *展示的值*。" -#: ../../tutorial/floatingpoint.rst:114 +#: ../../tutorial/floatingpoint.rst:110 msgid "" "One illusion may beget another. For example, since 0.1 is not exactly 1/10, " "summing three values of 0.1 may not yield exactly 0.3, either:" @@ -240,7 +240,7 @@ msgstr "" "這種幻覺可能會產生下一個幻覺。舉例來說,因為 0.1 不是真正的 1/10,把三個 0.1 " "的值相加,也不會產生精準的 0.3:" -#: ../../tutorial/floatingpoint.rst:117 +#: ../../tutorial/floatingpoint.rst:113 msgid "" ">>> 0.1 + 0.1 + 0.1 == 0.3\n" "False" @@ -248,7 +248,7 @@ msgstr "" ">>> 0.1 + 0.1 + 0.1 == 0.3\n" "False" -#: ../../tutorial/floatingpoint.rst:122 +#: ../../tutorial/floatingpoint.rst:118 msgid "" "Also, since the 0.1 cannot get any closer to the exact value of 1/10 and 0.3 " "cannot get any closer to the exact value of 3/10, then pre-rounding with :" @@ -257,7 +257,7 @@ msgstr "" "同時,因為 0.1 不能再更接近精準的 1/10,還有 0.3 不能再更接近精準的 3/10,預" "先用 :func:`round` 函式捨入並不會有幫助:" -#: ../../tutorial/floatingpoint.rst:126 +#: ../../tutorial/floatingpoint.rst:122 msgid "" ">>> round(0.1, 1) + round(0.1, 1) + round(0.1, 1) == round(0.3, 1)\n" "False" @@ -265,7 +265,7 @@ msgstr "" ">>> round(0.1, 1) + round(0.1, 1) + round(0.1, 1) == round(0.3, 1)\n" "False" -#: ../../tutorial/floatingpoint.rst:131 +#: ../../tutorial/floatingpoint.rst:127 msgid "" "Though the numbers cannot be made closer to their intended exact values, " "the :func:`math.isclose` function can be useful for comparing inexact values:" @@ -273,7 +273,7 @@ msgstr "" "雖然數字不會再更接近他們的精準數值,但 :func:`math.isclose` 函式可以用來比較" "不精確的值: ::" -#: ../../tutorial/floatingpoint.rst:134 +#: ../../tutorial/floatingpoint.rst:130 msgid "" ">>> math.isclose(0.1 + 0.1 + 0.1, 0.3)\n" "True" @@ -281,13 +281,13 @@ msgstr "" ">>> math.isclose(0.1 + 0.1 + 0.1, 0.3)\n" "True" -#: ../../tutorial/floatingpoint.rst:139 +#: ../../tutorial/floatingpoint.rst:135 msgid "" "Alternatively, the :func:`round` function can be used to compare rough " "approximations:" msgstr "或者,可以使用 :func:`round` 函式來比較粗略的近似值:" -#: ../../tutorial/floatingpoint.rst:142 +#: ../../tutorial/floatingpoint.rst:138 msgid "" ">>> round(math.pi, ndigits=2) == round(22 / 7, ndigits=2)\n" "True" @@ -295,7 +295,7 @@ msgstr "" ">>> round(math.pi, ndigits=2) == round(22 / 7, ndigits=2)\n" "True" -#: ../../tutorial/floatingpoint.rst:147 +#: ../../tutorial/floatingpoint.rst:143 msgid "" "Binary floating-point arithmetic holds many surprises like this. The " "problem with \"0.1\" is explained in precise detail below, in the " @@ -313,7 +313,7 @@ msgstr "" "錄。如果想要其他常見問題的更完整描述,可以參考 `The Perils of Floating Point" "(浮點數的風險) `_。" -#: ../../tutorial/floatingpoint.rst:156 +#: ../../tutorial/floatingpoint.rst:152 msgid "" "As that says near the end, \"there are no easy answers.\" Still, don't be " "unduly wary of floating point! The errors in Python float operations are " @@ -329,7 +329,7 @@ msgstr "" "經相當足夠,但你需要記住,它並非十進位運算,且每一次 float 運算都可能會承受新" "的捨入誤差。" -#: ../../tutorial/floatingpoint.rst:163 +#: ../../tutorial/floatingpoint.rst:159 msgid "" "While pathological cases do exist, for most casual use of floating-point " "arithmetic you'll see the result you expect in the end if you simply round " @@ -342,7 +342,7 @@ msgstr "" "滿足要求,而若想要更細緻的控制,可參閱\\ :ref:`formatstrings`\\ 中關於 :meth:" "`str.format` method(方法)的格式說明符號。" -#: ../../tutorial/floatingpoint.rst:169 +#: ../../tutorial/floatingpoint.rst:165 msgid "" "For use cases which require exact decimal representation, try using the :mod:" "`decimal` module which implements decimal arithmetic suitable for accounting " @@ -351,7 +351,7 @@ msgstr "" "對於需要精準十進位表示法的用例,可以試著用 :mod:`decimal` 模組,它可實作適用" "於會計應用程式與高精確度應用程式的十進位運算。" -#: ../../tutorial/floatingpoint.rst:173 +#: ../../tutorial/floatingpoint.rst:169 msgid "" "Another form of exact arithmetic is supported by the :mod:`fractions` module " "which implements arithmetic based on rational numbers (so the numbers like " @@ -360,7 +360,7 @@ msgstr "" "另一種支援精準運算的格式為 :mod:`fractions` 模組,該模組基於有理數來實作運算" "(因此可以精確表示像 1/3 這樣的數字)。" -#: ../../tutorial/floatingpoint.rst:177 +#: ../../tutorial/floatingpoint.rst:173 msgid "" "If you are a heavy user of floating-point operations you should take a look " "at the NumPy package and many other packages for mathematical and " @@ -370,7 +370,7 @@ msgstr "" "如果你是浮點運算的重度使用者,你應該看一下 NumPy 套件,以及由 SciPy 專案提供" "的許多用於數學和統計學運算的其他套件。請參閱 。" -#: ../../tutorial/floatingpoint.rst:181 +#: ../../tutorial/floatingpoint.rst:177 msgid "" "Python provides tools that may help on those rare occasions when you really " "*do* want to know the exact value of a float. The :meth:`float." @@ -380,7 +380,7 @@ msgstr "" "協助達成。:meth:`float.as_integer_ratio` method 可將一個 float 的值表示為分" "數:" -#: ../../tutorial/floatingpoint.rst:186 +#: ../../tutorial/floatingpoint.rst:182 msgid "" ">>> x = 3.14159\n" ">>> x.as_integer_ratio()\n" @@ -390,13 +390,13 @@ msgstr "" ">>> x.as_integer_ratio()\n" "(3537115888337719, 1125899906842624)" -#: ../../tutorial/floatingpoint.rst:192 +#: ../../tutorial/floatingpoint.rst:188 msgid "" "Since the ratio is exact, it can be used to losslessly recreate the original " "value:" msgstr "由於該比率是精準的,它可無損地再現該原始值:" -#: ../../tutorial/floatingpoint.rst:195 +#: ../../tutorial/floatingpoint.rst:191 msgid "" ">>> x == 3537115888337719 / 1125899906842624\n" "True" @@ -404,7 +404,7 @@ msgstr "" ">>> x == 3537115888337719 / 1125899906842624\n" "True" -#: ../../tutorial/floatingpoint.rst:200 +#: ../../tutorial/floatingpoint.rst:196 msgid "" "The :meth:`float.hex` method expresses a float in hexadecimal (base 16), " "again giving the exact value stored by your computer:" @@ -412,7 +412,7 @@ msgstr "" ":meth:`float.hex` method 以十六進位(基數為 16)表示 float,一樣可以給出你的" "電腦所儲存的精準值:" -#: ../../tutorial/floatingpoint.rst:203 +#: ../../tutorial/floatingpoint.rst:199 msgid "" ">>> x.hex()\n" "'0x1.921f9f01b866ep+1'" @@ -420,13 +420,13 @@ msgstr "" ">>> x.hex()\n" "'0x1.921f9f01b866ep+1'" -#: ../../tutorial/floatingpoint.rst:208 +#: ../../tutorial/floatingpoint.rst:204 msgid "" "This precise hexadecimal representation can be used to reconstruct the float " "value exactly:" msgstr "這種精確的十六進位表示法可用於精準地重建 float 值:" -#: ../../tutorial/floatingpoint.rst:211 +#: ../../tutorial/floatingpoint.rst:207 msgid "" ">>> x == float.fromhex('0x1.921f9f01b866ep+1')\n" "True" @@ -434,7 +434,7 @@ msgstr "" ">>> x == float.fromhex('0x1.921f9f01b866ep+1')\n" "True" -#: ../../tutorial/floatingpoint.rst:216 +#: ../../tutorial/floatingpoint.rst:212 msgid "" "Since the representation is exact, it is useful for reliably porting values " "across different versions of Python (platform independence) and exchanging " @@ -444,7 +444,7 @@ msgstr "" "由於該表示法是精準的,因此適用於在不同版本的 Python 之間可靠地傳送數值(獨立" "於系統平台),並與支援相同格式的其他語言(如 JAVA 和 C99)交換資料。" -#: ../../tutorial/floatingpoint.rst:220 +#: ../../tutorial/floatingpoint.rst:216 msgid "" "Another helpful tool is the :func:`sum` function which helps mitigate loss-" "of-precision during summation. It uses extended precision for intermediate " @@ -456,7 +456,7 @@ msgstr "" "值被加到運行中的總計值時,它會追蹤「失去的位數 (lost digits)」。這可以明顯改" "善總體準確度 (overall accuracy),使得誤差不至於累積到影響最終總計值的程度:" -#: ../../tutorial/floatingpoint.rst:226 +#: ../../tutorial/floatingpoint.rst:222 msgid "" ">>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0\n" "False\n" @@ -468,7 +468,7 @@ msgstr "" ">>> sum([0.1] * 10) == 1.0\n" "True" -#: ../../tutorial/floatingpoint.rst:233 +#: ../../tutorial/floatingpoint.rst:229 msgid "" "The :func:`math.fsum` goes further and tracks all of the \"lost digits\" as " "values are added onto a running total so that the result has only a single " @@ -480,7 +480,7 @@ msgstr "" "數」,以便結果僅有一次捨入。這比 :func:`sum` 慢,但在不常見的情況下會更準確," "在這種情況下,大量輸入大多相互抵消,最終的總和會接近於零:" -#: ../../tutorial/floatingpoint.rst:239 +#: ../../tutorial/floatingpoint.rst:235 msgid "" ">>> arr = [-0.10430216751806065, -266310978.67179024, 143401161448607.16,\n" "... -143401161400469.7, 266262841.31058735, -0.003244936839808227]\n" @@ -515,11 +515,11 @@ msgstr "" ">>> total # 直接相加沒有正確的數字\n" "-0.0051575902860057365" -#: ../../tutorial/floatingpoint.rst:260 +#: ../../tutorial/floatingpoint.rst:256 msgid "Representation Error" msgstr "表示法誤差 (Representation Error)" -#: ../../tutorial/floatingpoint.rst:262 +#: ../../tutorial/floatingpoint.rst:258 msgid "" "This section explains the \"0.1\" example in detail, and shows how you can " "perform an exact analysis of cases like this yourself. Basic familiarity " @@ -528,7 +528,7 @@ msgstr "" "本節將會詳細解釋「0.1」的例子,並說明你自己要如何對類似案例執行精準的分析。 " "以下假設你對二進位浮點表示法已有基本程度的熟悉。" -#: ../../tutorial/floatingpoint.rst:266 +#: ../../tutorial/floatingpoint.rst:262 msgid "" ":dfn:`Representation error` refers to the fact that some (most, actually) " "decimal fractions cannot be represented exactly as binary (base 2) " @@ -541,7 +541,7 @@ msgstr "" "Perl、C、C++、JAVA、Fortran 和其他許多)通常不會顯示你期望的精準十進位數字的" "主要原因。" -#: ../../tutorial/floatingpoint.rst:271 +#: ../../tutorial/floatingpoint.rst:267 msgid "" "Why is that? 1/10 is not exactly representable as a binary fraction. Since " "at least 2000, almost all machines use IEEE 754 binary floating-point " @@ -558,19 +558,19 @@ msgstr "" "到最接近的分數,以 *J*/2**\\ *N* 的形式表示,此處 *J* 是一個正好包含 53 位元" "的整數。可以將: ::" -#: ../../tutorial/floatingpoint.rst:280 +#: ../../tutorial/floatingpoint.rst:276 msgid "1 / 10 ~= J / (2**N)" msgstr "1 / 10 ~= J / (2**N)" -#: ../../tutorial/floatingpoint.rst:282 +#: ../../tutorial/floatingpoint.rst:278 msgid "as ::" msgstr "重寫為: ::" -#: ../../tutorial/floatingpoint.rst:284 +#: ../../tutorial/floatingpoint.rst:280 msgid "J ~= 2**N / 10" msgstr "J ~= 2**N / 10" -#: ../../tutorial/floatingpoint.rst:286 +#: ../../tutorial/floatingpoint.rst:282 msgid "" "and recalling that *J* has exactly 53 bits (is ``>= 2**52`` but ``< " "2**53``), the best value for *N* is 56:" @@ -578,7 +578,7 @@ msgstr "" "而前面提到 *J* 有精準的 53 位元(即 ``>= 2**52`` 但 ``< 2**53``),所以 *N* " "的最佳數值是 56:" -#: ../../tutorial/floatingpoint.rst:289 +#: ../../tutorial/floatingpoint.rst:285 msgid "" ">>> 2**52 <= 2**56 // 10 < 2**53\n" "True" @@ -586,7 +586,7 @@ msgstr "" ">>> 2**52 <= 2**56 // 10 < 2**53\n" "True" -#: ../../tutorial/floatingpoint.rst:294 +#: ../../tutorial/floatingpoint.rst:290 msgid "" "That is, 56 is the only value for *N* that leaves *J* with exactly 53 bits. " "The best possible value for *J* is then that quotient rounded:" @@ -594,7 +594,7 @@ msgstr "" "意即,要使 *J* 正好有 53 位元,則 56 會是 *N* 的唯一值。而 *J* 最有可能的數值" "就是經過捨入後的該商數:" -#: ../../tutorial/floatingpoint.rst:297 +#: ../../tutorial/floatingpoint.rst:293 msgid "" ">>> q, r = divmod(2**56, 10)\n" ">>> r\n" @@ -604,13 +604,13 @@ msgstr "" ">>> r\n" "6" -#: ../../tutorial/floatingpoint.rst:303 +#: ../../tutorial/floatingpoint.rst:299 msgid "" "Since the remainder is more than half of 10, the best approximation is " "obtained by rounding up:" msgstr "由於餘數超過 10 的一半,所以最佳的近似值是透過進位而得:" -#: ../../tutorial/floatingpoint.rst:306 +#: ../../tutorial/floatingpoint.rst:302 msgid "" ">>> q+1\n" "7205759403792794" @@ -618,26 +618,26 @@ msgstr "" ">>> q+1\n" "7205759403792794" -#: ../../tutorial/floatingpoint.rst:313 +#: ../../tutorial/floatingpoint.rst:309 msgid "" "Therefore the best possible approximation to 1/10 in IEEE 754 double " "precision is::" msgstr "所以,在 IEEE 754 雙精度下,1/10 的最佳近似值是: ::" -#: ../../tutorial/floatingpoint.rst:316 +#: ../../tutorial/floatingpoint.rst:312 msgid "7205759403792794 / 2 ** 56" msgstr "7205759403792794 / 2 ** 56" -#: ../../tutorial/floatingpoint.rst:318 +#: ../../tutorial/floatingpoint.rst:314 msgid "" "Dividing both the numerator and denominator by two reduces the fraction to::" msgstr "將分子和分母同除以二,會約分為: ::" -#: ../../tutorial/floatingpoint.rst:320 +#: ../../tutorial/floatingpoint.rst:316 msgid "3602879701896397 / 2 ** 55" msgstr "3602879701896397 / 2 ** 55" -#: ../../tutorial/floatingpoint.rst:322 +#: ../../tutorial/floatingpoint.rst:318 msgid "" "Note that since we rounded up, this is actually a little bit larger than " "1/10; if we had not rounded up, the quotient would have been a little bit " @@ -646,7 +646,7 @@ msgstr "" "請注意,由於我們有進位,所以這實際上比 1/10 大了一點;如果我們沒有進位,商數" "將會有點小於 1/10。但在任何情況下都不可能是\\ *精準的* 1/10!" -#: ../../tutorial/floatingpoint.rst:326 +#: ../../tutorial/floatingpoint.rst:322 msgid "" "So the computer never \"sees\" 1/10: what it sees is the exact fraction " "given above, the best IEEE 754 double approximation it can get:" @@ -654,7 +654,7 @@ msgstr "" "所以電腦從來沒有「看到」1/10:它看到的是上述的精準分數,也就是它能得到的 " "IEEE 754 double 最佳近似值: ::" -#: ../../tutorial/floatingpoint.rst:329 +#: ../../tutorial/floatingpoint.rst:325 msgid "" ">>> 0.1 * 2 ** 55\n" "3602879701896397.0" @@ -662,13 +662,13 @@ msgstr "" ">>> 0.1 * 2 ** 55\n" "3602879701896397.0" -#: ../../tutorial/floatingpoint.rst:334 +#: ../../tutorial/floatingpoint.rst:330 msgid "" "If we multiply that fraction by 10\\*\\*55, we can see the value out to 55 " "decimal digits:" msgstr "如果將該分數乘以 10\\*\\*55,則可以看到該值以 55 個十進位數字顯示:" -#: ../../tutorial/floatingpoint.rst:337 +#: ../../tutorial/floatingpoint.rst:333 msgid "" ">>> 3602879701896397 * 10 ** 55 // 2 ** 55\n" "1000000000000000055511151231257827021181583404541015625" @@ -676,7 +676,7 @@ msgstr "" ">>> 3602879701896397 * 10 ** 55 // 2 ** 55\n" "1000000000000000055511151231257827021181583404541015625" -#: ../../tutorial/floatingpoint.rst:342 +#: ../../tutorial/floatingpoint.rst:338 msgid "" "meaning that the exact number stored in the computer is equal to the decimal " "value 0.1000000000000000055511151231257827021181583404541015625. Instead of " @@ -687,7 +687,7 @@ msgstr "" "0.1000000000000000055511151231257827021181583404541015625。與其顯示完整的十進" "位數值,許多語言(包括 Python 的舊版本)選擇將結果捨入至 17 個有效位數:" -#: ../../tutorial/floatingpoint.rst:347 +#: ../../tutorial/floatingpoint.rst:343 msgid "" ">>> format(0.1, '.17f')\n" "'0.10000000000000001'" @@ -695,12 +695,12 @@ msgstr "" ">>> format(0.1, '.17f')\n" "'0.10000000000000001'" -#: ../../tutorial/floatingpoint.rst:352 +#: ../../tutorial/floatingpoint.rst:348 msgid "" "The :mod:`fractions` and :mod:`decimal` modules make these calculations easy:" msgstr ":mod:`fractions` 與 :mod:`decimal` 模組能使這些計算變得容易:" -#: ../../tutorial/floatingpoint.rst:355 +#: ../../tutorial/floatingpoint.rst:351 msgid "" ">>> from decimal import Decimal\n" ">>> from fractions import Fraction\n" diff --git a/tutorial/inputoutput.po b/tutorial/inputoutput.po index 3f0860ad572..b86353ac17a 100644 --- a/tutorial/inputoutput.po +++ b/tutorial/inputoutput.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-10-05 10:26+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,7 +21,7 @@ msgstr "" "X-Generator: Poedit 3.1.1\n" #: ../../tutorial/inputoutput.rst:5 -msgid "Input and Output" +msgid "Input and output" msgstr "輸入和輸出" #: ../../tutorial/inputoutput.rst:7 @@ -34,7 +34,7 @@ msgstr "" "未來所使用。這章節會討論幾種不同的方式。" #: ../../tutorial/inputoutput.rst:15 -msgid "Fancier Output Formatting" +msgid "Fancier output formatting" msgstr "更華麗的輸出格式" #: ../../tutorial/inputoutput.rst:17 @@ -219,8 +219,8 @@ msgstr "" "它在格式化方面提供的控制較少。" #: ../../tutorial/inputoutput.rst:115 -msgid "Formatted String Literals" -msgstr "格式化的字串文本 (Formatted String Literals)" +msgid "Formatted string literals" +msgstr "格式化的字串常數 (formatted string literal)" #: ../../tutorial/inputoutput.rst:117 msgid "" @@ -321,7 +321,7 @@ msgstr "" "見 :ref:`formatspec` 參考指南。" #: ../../tutorial/inputoutput.rst:167 -msgid "The String format() Method" +msgid "The string format() method" msgstr "字串的 format() method" #: ../../tutorial/inputoutput.rst:169 @@ -499,7 +499,7 @@ msgstr "" "\\ :ref:`formatstrings`。" #: ../../tutorial/inputoutput.rst:244 -msgid "Manual String Formatting" +msgid "Manual string formatting" msgstr "手動格式化字串" #: ../../tutorial/inputoutput.rst:246 @@ -622,23 +622,22 @@ msgid "" msgstr "更多資訊請見 :ref:`old-string-formatting`\\ 小節。" #: ../../tutorial/inputoutput.rst:307 -msgid "Reading and Writing Files" -msgstr "讀寫檔案" +msgid "Reading and writing files" +msgstr "讀取和寫入檔案" #: ../../tutorial/inputoutput.rst:313 msgid "" ":func:`open` returns a :term:`file object`, and is most commonly used with " -"two positional arguments and one keyword argument: ``open(filename, mode, " -"encoding=None)``" +"two positional arguments: ``open(filename, mode)``" msgstr "" -":func:`open` 回傳一個 :term:`file object`,而它最常使用的兩個位置引數和一個關" -"鍵字引數是:``open(filename, mode, encoding=None)``" +":func:`open` 回傳一個 :term:`file object`,而它最常使用的兩個位置引數是:" +"``open(filename, mode)``" -#: ../../tutorial/inputoutput.rst:319 -msgid ">>> f = open('workfile', 'w', encoding=\"utf-8\")" -msgstr ">>> f = open('workfile', 'w', encoding=\"utf-8\")" +#: ../../tutorial/inputoutput.rst:318 +msgid ">>> f = open('workfile', 'w')" +msgstr ">>> f = open('workfile', 'w')" -#: ../../tutorial/inputoutput.rst:326 +#: ../../tutorial/inputoutput.rst:325 msgid "" "The first argument is a string containing the filename. The second argument " "is another string containing a few characters describing the way in which " @@ -655,26 +654,22 @@ msgstr "" "內容為目的開啟檔案,任何寫入檔案的資料會自動被加入到檔案的結尾。``'r+'`` 可以" "開啟檔案並進行讀取和寫入。*mode* 引數是選擇性的,若省略時會預設為 ``'r'``。" -#: ../../tutorial/inputoutput.rst:335 +#: ../../tutorial/inputoutput.rst:334 msgid "" "Normally, files are opened in :dfn:`text mode`, that means, you read and " "write strings from and to the file, which are encoded in a specific " -"*encoding*. If *encoding* is not specified, the default is platform " -"dependent (see :func:`open`). Because UTF-8 is the modern de-facto standard, " -"``encoding=\"utf-8\"`` is recommended unless you know that you need to use a " -"different encoding. Appending a ``'b'`` to the mode opens the file " -"in :dfn:`binary mode`. Binary mode data is read and written " -"as :class:`bytes` objects. You can not specify *encoding* when opening file " -"in binary mode." +"*encoding*. If *encoding* is not specified, the default is UTF-8 (see :func:" +"`open`). Appending a ``'b'`` to the mode opens the file in :dfn:`binary " +"mode`. Binary mode data is read and written as :class:`bytes` objects. You " +"can not specify *encoding* when opening file in binary mode." msgstr "" "通常,檔案以 :dfn:`text mode` 開啟,意即,從檔案中讀取或寫入字串時,都以特定" -"編碼方式 *encoding* 進行編碼。如未指定 *encoding*,則預設值會取決於系統平台" -"(見 :func:`open`)。因為 UTF-8 是現時的標準,除非你很清楚該用什麼編碼,否則" -"推薦使用 ``encoding=\"utf-8\"``。在 mode 後面加上 ``'b'`` 會以 :dfn:`binary " -"mode`\\ (二進制模式)開啟檔案,二進制模式資料以 :class:`bytes` 物件的形式被" -"讀寫。以二進制模式開啟檔案時不可以指定 *encoding*。" +"編碼方式 *encoding* 進行編碼。如未指定 *encoding*,則預設值為 UTF-8" +"(見 :func:`open`)。在 mode 後面加上 ``'b'`` 會以 :dfn:`binary mode`\\ (二" +"進制模式)開啟檔案,二進制模式資料以 :class:`bytes` 物件的形式被讀寫。以二進" +"制模式開啟檔案時不可以指定 *encoding*。" -#: ../../tutorial/inputoutput.rst:345 +#: ../../tutorial/inputoutput.rst:341 msgid "" "In text mode, the default when reading is to convert platform-specific line " "endings (``\\n`` on Unix, ``\\r\\n`` on Windows) to just ``\\n``. When " @@ -690,7 +685,7 @@ msgstr "" "文字檔案來說沒有問題,但會毀壞像是 :file:`JPEG` 或 :file:`EXE` 檔案中的二進制" "資料。在讀寫此類檔案時,注意一定要使用二進制模式。" -#: ../../tutorial/inputoutput.rst:353 +#: ../../tutorial/inputoutput.rst:349 msgid "" "It is good practice to use the :keyword:`with` keyword when dealing with " "file objects. The advantage is that the file is properly closed after its " @@ -702,23 +697,23 @@ msgstr "" "束後,即使在某個時刻引發了例外,檔案仍會正確地被關閉。使用 :keyword:`!with` " "也比寫等效的 :keyword:`try`\\ -\\ :keyword:`finally` 區塊,來得簡短許多: ::" -#: ../../tutorial/inputoutput.rst:359 +#: ../../tutorial/inputoutput.rst:355 msgid "" -">>> with open('workfile', encoding=\"utf-8\") as f:\n" +">>> with open('workfile') as f:\n" "... read_data = f.read()\n" "\n" ">>> # We can check that the file has been automatically closed.\n" ">>> f.closed\n" "True" msgstr "" -">>> with open('workfile', encoding=\"utf-8\") as f:\n" +">>> with open('workfile') as f:\n" "... read_data = f.read()\n" "\n" ">>> # 我們可以檢查確認該檔案已經自動被關閉。\n" ">>> f.closed\n" "True" -#: ../../tutorial/inputoutput.rst:366 +#: ../../tutorial/inputoutput.rst:362 msgid "" "If you're not using the :keyword:`with` keyword, then you should call " "``f.close()`` to close the file and immediately free up any system resources " @@ -727,7 +722,7 @@ msgstr "" "如果你沒有使用 :keyword:`with` 關鍵字,則應呼叫 ``f.close()`` 關閉檔案,可以" "立即釋放被它所使用的系統資源。" -#: ../../tutorial/inputoutput.rst:371 +#: ../../tutorial/inputoutput.rst:367 msgid "" "Calling ``f.write()`` without using the :keyword:`!with` keyword or calling " "``f.close()`` **might** result in the arguments of ``f.write()`` not being " @@ -737,7 +732,7 @@ msgstr "" "即使程式成功退出,也\\ **可能**\\ 導致 ``f.write()`` 的引數沒有被完全寫入硬" "碟。" -#: ../../tutorial/inputoutput.rst:379 +#: ../../tutorial/inputoutput.rst:375 msgid "" "After a file object is closed, either by a :keyword:`with` statement or by " "calling ``f.close()``, attempts to use the file object will automatically " @@ -746,7 +741,7 @@ msgstr "" "不論是透過 :keyword:`with` 陳述式,或呼叫 ``f.close()`` 關閉一個檔案物件之" "後,嘗試使用該檔案物件將會自動失效。 ::" -#: ../../tutorial/inputoutput.rst:383 +#: ../../tutorial/inputoutput.rst:379 msgid "" ">>> f.close()\n" ">>> f.read()\n" @@ -760,17 +755,17 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: I/O operation on closed file." -#: ../../tutorial/inputoutput.rst:393 -msgid "Methods of File Objects" +#: ../../tutorial/inputoutput.rst:389 +msgid "Methods of file objects" msgstr "檔案物件的 method" -#: ../../tutorial/inputoutput.rst:395 +#: ../../tutorial/inputoutput.rst:391 msgid "" "The rest of the examples in this section will assume that a file object " "called ``f`` has already been created." msgstr "本節其餘的範例皆假設一個名為 ``f`` 的檔案物件已被建立。" -#: ../../tutorial/inputoutput.rst:398 +#: ../../tutorial/inputoutput.rst:394 msgid "" "To read a file's contents, call ``f.read(size)``, which reads some quantity " "of data and returns it as a string (in text mode) or bytes object (in binary " @@ -788,7 +783,7 @@ msgstr "" "字模式)或 *size* 數量的位元組串(二進制模式)會被讀取及回傳。如果之前已經到" "達檔案的末端,``f.read()`` 會回傳空字串(``''``)。 ::" -#: ../../tutorial/inputoutput.rst:407 +#: ../../tutorial/inputoutput.rst:403 msgid "" ">>> f.read()\n" "'This is the entire file.\\n'\n" @@ -800,7 +795,7 @@ msgstr "" ">>> f.read()\n" "''" -#: ../../tutorial/inputoutput.rst:412 +#: ../../tutorial/inputoutput.rst:408 msgid "" "``f.readline()`` reads a single line from the file; a newline character " "(``\\n``) is left at the end of the string, and is only omitted on the last " @@ -814,7 +809,7 @@ msgstr "" "傳值清晰明確;只要 ``f.readline()`` 回傳一個空字串,就表示已經到達了檔案末" "端,而空白行的表示法是 ``'\\n'``,也就是只含一個換行字元的字串。 ::" -#: ../../tutorial/inputoutput.rst:419 +#: ../../tutorial/inputoutput.rst:415 msgid "" ">>> f.readline()\n" "'This is the first line of the file.\\n'\n" @@ -830,7 +825,7 @@ msgstr "" ">>> f.readline()\n" "''" -#: ../../tutorial/inputoutput.rst:426 +#: ../../tutorial/inputoutput.rst:422 msgid "" "For reading lines from a file, you can loop over the file object. This is " "memory efficient, fast, and leads to simple code::" @@ -838,7 +833,7 @@ msgstr "" "想從檔案中讀取多行時,可以對檔案物件進行迴圈。這種方法能有效地使用記憶體、快" "速,且程式碼簡潔: ::" -#: ../../tutorial/inputoutput.rst:429 +#: ../../tutorial/inputoutput.rst:425 msgid "" ">>> for line in f:\n" "... print(line, end='')\n" @@ -852,7 +847,7 @@ msgstr "" "This is the first line of the file.\n" "Second line of the file" -#: ../../tutorial/inputoutput.rst:435 +#: ../../tutorial/inputoutput.rst:431 msgid "" "If you want to read all the lines of a file in a list you can also use " "``list(f)`` or ``f.readlines()``." @@ -860,14 +855,14 @@ msgstr "" "如果你想把一個檔案的所有行讀進一個 list 裡,可以用 ``list(f)`` 或 " "``f.readlines()``。" -#: ../../tutorial/inputoutput.rst:438 +#: ../../tutorial/inputoutput.rst:434 msgid "" "``f.write(string)`` writes the contents of *string* to the file, returning " "the number of characters written. ::" msgstr "" "``f.write(string)`` 把 *string* 的內容寫入檔案,並回傳寫入的字元數。 ::" -#: ../../tutorial/inputoutput.rst:441 +#: ../../tutorial/inputoutput.rst:437 msgid "" ">>> f.write('This is a test\\n')\n" "15" @@ -875,7 +870,7 @@ msgstr "" ">>> f.write('This is a test\\n')\n" "15" -#: ../../tutorial/inputoutput.rst:444 +#: ../../tutorial/inputoutput.rst:440 msgid "" "Other types of objects need to be converted -- either to a string (in text " "mode) or a bytes object (in binary mode) -- before writing them::" @@ -883,7 +878,7 @@ msgstr "" "寫入其他類型的物件之前,要先把它們轉換為字串(文字模式)或位元組串物件(二進" "制模式): ::" -#: ../../tutorial/inputoutput.rst:447 +#: ../../tutorial/inputoutput.rst:443 msgid "" ">>> value = ('the answer', 42)\n" ">>> s = str(value) # convert the tuple to string\n" @@ -895,7 +890,7 @@ msgstr "" ">>> f.write(s)\n" "18" -#: ../../tutorial/inputoutput.rst:452 +#: ../../tutorial/inputoutput.rst:448 msgid "" "``f.tell()`` returns an integer giving the file object's current position in " "the file represented as number of bytes from the beginning of the file when " @@ -904,7 +899,7 @@ msgstr "" "``f.tell()`` 回傳一個整數,它給出檔案物件在檔案中的目前位置,在二進制模式下表" "示為檔案開始至今的位元組數,在文字模式下表示為一個意義不明的數字。" -#: ../../tutorial/inputoutput.rst:456 +#: ../../tutorial/inputoutput.rst:452 msgid "" "To change the file object's position, use ``f.seek(offset, whence)``. The " "position is computed from adding *offset* to a reference point; the " @@ -919,7 +914,7 @@ msgstr "" "為 0 時,表示使用檔案開頭,1 表示使用目前的檔案位置,2 表示使用檔案末端作為參" "考點。*whence* 可省略,其預設值為 0,即以檔案開頭作為參考點。 ::" -#: ../../tutorial/inputoutput.rst:463 +#: ../../tutorial/inputoutput.rst:459 msgid "" ">>> f = open('workfile', 'rb+')\n" ">>> f.write(b'0123456789abcdef')\n" @@ -945,7 +940,7 @@ msgstr "" ">>> f.read(1)\n" "b'd'" -#: ../../tutorial/inputoutput.rst:475 +#: ../../tutorial/inputoutput.rst:471 msgid "" "In text files (those opened without a ``b`` in the mode string), only seeks " "relative to the beginning of the file are allowed (the exception being " @@ -958,7 +953,7 @@ msgstr "" "的值,或是 0,才是有效的 *offset* 值。其他任何 *offset* 值都會產生未定義的行" "為。" -#: ../../tutorial/inputoutput.rst:481 +#: ../../tutorial/inputoutput.rst:477 msgid "" "File objects have some additional methods, such as :meth:`~io.IOBase.isatty` " "and :meth:`~io.IOBase.truncate` which are less frequently used; consult the " @@ -967,11 +962,11 @@ msgstr "" "檔案物件還有一些附加的 method,像是較不常使用的 :meth:`~io.IOBase.isatty` " "和 :meth:`~io.IOBase.truncate`;檔案物件的完整指南詳見程式庫參考手冊。" -#: ../../tutorial/inputoutput.rst:489 +#: ../../tutorial/inputoutput.rst:485 msgid "Saving structured data with :mod:`json`" msgstr "使用 :mod:`json` 儲存結構化資料" -#: ../../tutorial/inputoutput.rst:493 +#: ../../tutorial/inputoutput.rst:489 msgid "" "Strings can easily be written to and read from a file. Numbers take a bit " "more effort, since the :meth:`~io.TextIOBase.read` method only returns " @@ -986,7 +981,7 @@ msgstr "" "想儲存像是巢狀 list 和 dictionary(字典)等複雜的資料類型時,手動剖析 " "(parsing) 和序列化 (serializing) 就變得複雜。" -#: ../../tutorial/inputoutput.rst:500 +#: ../../tutorial/inputoutput.rst:496 msgid "" "Rather than having users constantly writing and debugging code to save " "complicated data types to files, Python allows you to use the popular data " @@ -1005,7 +1000,7 @@ msgstr "" "則稱為 :dfn:`deserializing`\\ (反序列化)。在序列化和反序列化之間,表示物件" "的字串可以被儲存在檔案或資料中,或透過網路連接發送到遠端的機器。" -#: ../../tutorial/inputoutput.rst:511 +#: ../../tutorial/inputoutput.rst:507 msgid "" "The JSON format is commonly used by modern applications to allow for data " "exchange. Many programmers are already familiar with it, which makes it a " @@ -1014,14 +1009,14 @@ msgstr "" "JSON 格式經常地使用於現代應用程式的資料交換。許多程序設計師早已對它耳熟能詳," "使它成為提升互操作性 (interoperability) 的好選擇。" -#: ../../tutorial/inputoutput.rst:515 +#: ../../tutorial/inputoutput.rst:511 msgid "" "If you have an object ``x``, you can view its JSON string representation " "with a simple line of code::" msgstr "" "如果你有一個物件 ``x``,只需一行簡單的程式碼即可檢視它的 JSON 字串表示法: ::" -#: ../../tutorial/inputoutput.rst:518 +#: ../../tutorial/inputoutput.rst:514 msgid "" ">>> import json\n" ">>> x = [1, 'simple', 'list']\n" @@ -1033,7 +1028,7 @@ msgstr "" ">>> json.dumps(x)\n" "'[1, \"simple\", \"list\"]'" -#: ../../tutorial/inputoutput.rst:523 +#: ../../tutorial/inputoutput.rst:519 msgid "" "Another variant of the :func:`~json.dumps` function, " "called :func:`~json.dump`, simply serializes the object to a :term:`text " @@ -1044,11 +1039,11 @@ msgstr "" "列化為 :term:`text file`。因此,如果 ``f`` 是一個為了寫入而開啟" "的 :term:`text file` 物件,我們可以這樣做: ::" -#: ../../tutorial/inputoutput.rst:527 +#: ../../tutorial/inputoutput.rst:523 msgid "json.dump(x, f)" msgstr "json.dump(x, f)" -#: ../../tutorial/inputoutput.rst:529 +#: ../../tutorial/inputoutput.rst:525 msgid "" "To decode the object again, if ``f`` is a :term:`binary file` or :term:`text " "file` object which has been opened for reading::" @@ -1056,19 +1051,19 @@ msgstr "" "若 ``f`` 是一個已開啟、可讀取的 :term:`binary file` 或 :term:`text file` 物" "件,要再次解碼物件的話: ::" -#: ../../tutorial/inputoutput.rst:532 +#: ../../tutorial/inputoutput.rst:528 msgid "x = json.load(f)" msgstr "x = json.load(f)" -#: ../../tutorial/inputoutput.rst:535 +#: ../../tutorial/inputoutput.rst:531 msgid "" -"JSON files must be encoded in UTF-8. Use ``encoding=\"utf-8\"`` when opening " -"JSON file as a :term:`text file` for both of reading and writing." +"JSON files must be encoded in UTF-8, the default encoding for :term:`text " +"files `." msgstr "" -"JSON 檔案必須以 UTF-8 格式編碼。在開啟 JSON 檔案以作為一個可讀取與寫入" -"的 :term:`text file` 時,要用 ``encoding=\"utf-8\"``。" +"JSON 檔案必須以 UTF-8 格式編碼,這是\\ :term:`文字檔案 `\\ 的預設" +"編碼。" -#: ../../tutorial/inputoutput.rst:538 +#: ../../tutorial/inputoutput.rst:534 msgid "" "This simple serialization technique can handle lists and dictionaries, but " "serializing arbitrary class instances in JSON requires a bit of extra " @@ -1079,11 +1074,11 @@ msgstr "" "class(類別)實例,則需要一些額外的工作。:mod:`json` 模組的參考資料包含對此的" "說明。" -#: ../../tutorial/inputoutput.rst:544 +#: ../../tutorial/inputoutput.rst:540 msgid ":mod:`pickle` - the pickle module" msgstr ":mod:`pickle` - pickle 模組" -#: ../../tutorial/inputoutput.rst:546 +#: ../../tutorial/inputoutput.rst:542 msgid "" "Contrary to :ref:`JSON `, *pickle* is a protocol which allows the " "serialization of arbitrarily complex Python objects. As such, it is " @@ -1141,10 +1136,13 @@ msgstr "object(物件)" msgid "file" msgstr "file(檔案)" -#: ../../tutorial/inputoutput.rst:491 +#: ../../tutorial/inputoutput.rst:487 msgid "module" msgstr "module(模組)" -#: ../../tutorial/inputoutput.rst:491 +#: ../../tutorial/inputoutput.rst:487 msgid "json" msgstr "json" + +#~ msgid "Formatted String Literals" +#~ msgstr "格式化的字串文本 (Formatted String Literals)" diff --git a/tutorial/interpreter.po b/tutorial/interpreter.po index 7258defc0c3..d646b55e340 100644 --- a/tutorial/interpreter.po +++ b/tutorial/interpreter.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-15 00:15+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2021-05-18 16:28+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -39,8 +39,8 @@ msgstr "" "shell 的搜尋路徑中就可以透過輸入命令來啟動它:" #: ../../tutorial/interpreter.rst:17 -msgid "python3.14" -msgstr "python3.14" +msgid "python3.15" +msgstr "python3.15" #: ../../tutorial/interpreter.rst:21 msgid "" @@ -189,15 +189,15 @@ msgstr "" #: ../../tutorial/interpreter.rst:98 msgid "" -"$ python3.14\n" -"Python 3.14 (default, April 4 2024, 09:25:04)\n" +"$ python3.15\n" +"Python 3.15 (default, May 7 2025, 15:46:04)\n" "[GCC 10.2.0] on linux\n" "Type \"help\", \"copyright\", \"credits\" or \"license\" for more " "information.\n" ">>>" msgstr "" -"$ python3.14\n" -"Python 3.14 (default, April 4 2024, 09:25:04)\n" +"$ python3.15\n" +"Python 3.15 (default, May 7 2025, 15:46:04)\n" "[GCC 10.2.0] on linux\n" "Type \"help\", \"copyright\", \"credits\" or \"license\" for more " "information.\n" diff --git a/tutorial/stdlib.po b/tutorial/stdlib.po index 9666fda8d9f..ea61a9da19e 100644 --- a/tutorial/stdlib.po +++ b/tutorial/stdlib.po @@ -13,7 +13,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-21 00:11+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-01-31 18:14+0800\n" "Last-Translator: Phil Lin \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -43,14 +43,14 @@ msgstr ":mod:`os` 模組提供了數十個與作業系統溝通的函式: ::" msgid "" ">>> import os\n" ">>> os.getcwd() # Return the current working directory\n" -"'C:\\\\Python314'\n" +"'C:\\\\Python315'\n" ">>> os.chdir('/server/accesslogs') # Change current working directory\n" ">>> os.system('mkdir today') # Run the command mkdir in the system shell\n" "0" msgstr "" ">>> import os\n" ">>> os.getcwd() # 回傳目前的工作目錄\n" -"'C:\\\\Python314'\n" +"'C:\\\\Python315'\n" ">>> os.chdir('/server/accesslogs') # 改變目前的工作目錄\n" ">>> os.system('mkdir today') # 在系統 shell 中執行 mkdir 指令\n" "0" diff --git a/tutorial/stdlib2.po b/tutorial/stdlib2.po index 5ae1647e9d8..6b32f434bbd 100644 --- a/tutorial/stdlib2.po +++ b/tutorial/stdlib2.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-04-29 00:33+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2021-06-19 14:24+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -563,7 +563,7 @@ msgid "" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " d['primary'] # entry was automatically removed\n" -" File \"C:/python314/lib/weakref.py\", line 46, in __getitem__\n" +" File \"C:/python315/lib/weakref.py\", line 46, in __getitem__\n" " o = self.data[key]()\n" "KeyError: 'primary'" msgstr "" @@ -586,7 +586,7 @@ msgstr "" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " d['primary'] # 項目被自動移除\n" -" File \"C:/python314/lib/weakref.py\", line 46, in __getitem__\n" +" File \"C:/python315/lib/weakref.py\", line 46, in __getitem__\n" " o = self.data[key]()\n" "KeyError: 'primary'" diff --git a/using/android.po b/using/android.po index 699cd6f5087..1ecb4556097 100644 --- a/using/android.po +++ b/using/android.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-04-20 00:26+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -103,11 +103,11 @@ msgstr "`Termux `__" #: ../../using/android.rst:39 msgid "" "If you're sure you want to do all of this manually, read on. You can use " -"the :source:`testbed app ` as a guide; each step below " -"contains a link to the relevant file." +"the :source:`testbed app ` as a guide; each step " +"below contains a link to the relevant file." msgstr "" -"如果你確定要全部手動操作,請繼續閱讀。你可以將 :source:`testbed app ` 作為參考;下面的每個步驟都包含相關檔案的連結。" +"如果你確定要全部手動操作,請繼續閱讀。你可以將 :source:`testbed app " +"` 作為參考;下面的每個步驟都包含相關檔案的連結。" #: ../../using/android.rst:43 msgid "First, acquire a build of Python for Android:" @@ -125,21 +125,21 @@ msgstr "" #: ../../using/android.rst:49 msgid "" "Or if you want to build it yourself, follow the instructions in :source:" -"`Android/README.md`. The ``prefix`` directory will be created under :samp:" -"`cross-build/{HOST}`." +"`Platforms/Android/README.md`. The ``prefix`` directory will be created " +"under :samp:`cross-build/{HOST}`." msgstr "" -"或者如果你想自行建置它,請依照 :source:`Android/README.md` 中的操作。" -"``prefix`` 目錄將會建立在 :samp:`cross-build/{HOST}` 底下。" +"或者如果你想自行建置它,請依照 :source:`Platforms/Android/README.md` 中的操" +"作。``prefix`` 目錄將會建立在 :samp:`cross-build/{HOST}` 底下。" #: ../../using/android.rst:53 msgid "" -"Add code to your :source:`build.gradle ` file to copy the following items into your project. All except your " -"own Python code can be copied from ``prefix/lib``:" +"Add code to your :source:`build.gradle ` file to copy the following items into your project. All except " +"your own Python code can be copied from ``prefix/lib``:" msgstr "" -"在你的 :source:`build.gradle ` 檔案中加" -"入程式碼,將以下項目複製到你的專案中。除了你自己的 Python 程式碼外,其他項目" -"都可以從 ``prefix/lib`` 複製:" +"在你的 :source:`build.gradle ` 檔案中加入程式碼,將以下項目複製到你的專案中。除了你自己" +"的 Python 程式碼外,其他項目都可以從 ``prefix/lib`` 複製:" #: ../../using/android.rst:57 msgid "In your JNI libraries:" @@ -168,19 +168,21 @@ msgstr "``python*.*/site-packages``\\ (你自己的 Python 程式碼)" #: ../../using/android.rst:67 msgid "" "Add code to your app to :source:`extract the assets to the filesystem " -"`." +"`." msgstr "" -"在你的應用程式中加入程式碼,以 :source:`解壓縮資產到檔案系統 `。" +"在你的應用程式中加入程式碼,以 :source:`解壓縮資產到檔案系統 `。" #: ../../using/android.rst:70 msgid "" -"Add code to your app to :source:`start Python in embedded mode `. This will need to be C code called " -"via JNI." +"Add code to your app to :source:`start Python in embedded mode `. This will need to be C " +"code called via JNI." msgstr "" -"在你的應用程式中加入程式碼,以 :source:`嵌入模式啟動 Python `。這需要透過 JNI 呼叫的 C 語言程式碼。" +"在你的應用程式中加入程式碼,以 :source:`嵌入模式啟動 Python `。這需要透過 JNI 呼叫的 C 語" +"言程式碼。" #: ../../using/android.rst:75 msgid "Building a Python package for Android" diff --git a/using/cmdline.po b/using/cmdline.po index 0f6b2593f95..4e54af39617 100644 --- a/using/cmdline.po +++ b/using/cmdline.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-15 00:18+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:19+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -92,7 +92,7 @@ msgstr "" msgid "" "When called with ``-c command``, it executes the Python statement(s) given " "as *command*. Here *command* may contain multiple statements separated by " -"newlines. Leading whitespace is significant in Python statements!" +"newlines." msgstr "" #: ../../using/cmdline.rst:53 @@ -240,7 +240,7 @@ msgid "" "path`." msgstr "" -#: ../../using/cmdline.rst:144 ../../using/cmdline.rst:852 +#: ../../using/cmdline.rst:144 ../../using/cmdline.rst:888 msgid "" "Raises an :ref:`auditing event ` ``cpython.run_stdin`` with no " "arguments." @@ -377,11 +377,19 @@ msgstr "" #: ../../using/cmdline.rst:259 msgid "" +"Deprecate :option:`-b` and :option:`!-bb` command line options and schedule " +"them to become no-op in Python 3.17. These were primarily helpers for the " +"Python 2 -> 3 transition. Starting with Python 3.17, no :exc:`BytesWarning` " +"will be raised for these cases; use a type checker instead." +msgstr "" + +#: ../../using/cmdline.rst:268 +msgid "" "If given, Python won't try to write ``.pyc`` files on the import of source " "modules. See also :envvar:`PYTHONDONTWRITEBYTECODE`." msgstr "" -#: ../../using/cmdline.rst:265 +#: ../../using/cmdline.rst:274 msgid "" "Control the validation behavior of hash-based ``.pyc`` files. See :ref:`pyc-" "invalidation`. When set to ``default``, checked and unchecked hash-based " @@ -392,75 +400,75 @@ msgid "" "corresponding source files." msgstr "" -#: ../../using/cmdline.rst:273 +#: ../../using/cmdline.rst:282 msgid "" "The semantics of timestamp-based ``.pyc`` files are unaffected by this " "option." msgstr "" -#: ../../using/cmdline.rst:279 +#: ../../using/cmdline.rst:288 msgid "" "Turn on parser debugging output (for expert only). See also the :envvar:" "`PYTHONDEBUG` environment variable." msgstr "" -#: ../../using/cmdline.rst:282 +#: ../../using/cmdline.rst:291 msgid "" "This option requires a :ref:`debug build of Python `, otherwise " "it's ignored." msgstr "" -#: ../../using/cmdline.rst:288 +#: ../../using/cmdline.rst:297 msgid "" "Ignore all ``PYTHON*`` environment variables, e.g. :envvar:`PYTHONPATH` and :" "envvar:`PYTHONHOME`, that might be set." msgstr "" -#: ../../using/cmdline.rst:291 +#: ../../using/cmdline.rst:300 msgid "See also the :option:`-P` and :option:`-I` (isolated) options." msgstr "另請參閱 :option:`-P` 和 :option:`-I` (isolated) 選項。" -#: ../../using/cmdline.rst:296 +#: ../../using/cmdline.rst:305 msgid "Enter interactive mode after execution." msgstr "" -#: ../../using/cmdline.rst:298 +#: ../../using/cmdline.rst:307 msgid "" "Using the :option:`-i` option will enter interactive mode in any of the " "following circumstances\\:" msgstr "" -#: ../../using/cmdline.rst:300 +#: ../../using/cmdline.rst:309 msgid "When a script is passed as first argument" msgstr "" -#: ../../using/cmdline.rst:301 +#: ../../using/cmdline.rst:310 msgid "When the :option:`-c` option is used" msgstr "" -#: ../../using/cmdline.rst:302 +#: ../../using/cmdline.rst:311 msgid "When the :option:`-m` option is used" msgstr "" -#: ../../using/cmdline.rst:304 +#: ../../using/cmdline.rst:313 msgid "" "Interactive mode will start even when :data:`sys.stdin` does not appear to " "be a terminal. The :envvar:`PYTHONSTARTUP` file is not read." msgstr "" -#: ../../using/cmdline.rst:307 +#: ../../using/cmdline.rst:316 msgid "" "This can be useful to inspect global variables or a stack trace when a " "script raises an exception. See also :envvar:`PYTHONINSPECT`." msgstr "" -#: ../../using/cmdline.rst:313 +#: ../../using/cmdline.rst:322 msgid "" "Run Python in isolated mode. This also implies :option:`-E`, :option:`-P` " "and :option:`-s` options." msgstr "" -#: ../../using/cmdline.rst:316 +#: ../../using/cmdline.rst:325 msgid "" "In isolated mode :data:`sys.path` contains neither the script's directory " "nor the user's site-packages directory. All ``PYTHON*`` environment " @@ -468,7 +476,7 @@ msgid "" "the user from injecting malicious code." msgstr "" -#: ../../using/cmdline.rst:326 +#: ../../using/cmdline.rst:335 msgid "" "Remove assert statements and any code conditional on the value of :const:" "`__debug__`. Augment the filename for compiled (:term:`bytecode`) files by " @@ -476,58 +484,58 @@ msgid "" "envvar:`PYTHONOPTIMIZE`." msgstr "" -#: ../../using/cmdline.rst:331 ../../using/cmdline.rst:341 +#: ../../using/cmdline.rst:340 ../../using/cmdline.rst:350 msgid "Modify ``.pyc`` filenames according to :pep:`488`." msgstr "根據 :pep:`488` 修改 ``.pyc`` 檔案名稱。" -#: ../../using/cmdline.rst:337 +#: ../../using/cmdline.rst:346 msgid "" "Do :option:`-O` and also discard docstrings. Augment the filename for " "compiled (:term:`bytecode`) files by adding ``.opt-2`` before the ``.pyc`` " "extension (see :pep:`488`)." msgstr "" -#: ../../using/cmdline.rst:347 +#: ../../using/cmdline.rst:356 msgid "Don't prepend a potentially unsafe path to :data:`sys.path`:" msgstr "" -#: ../../using/cmdline.rst:349 +#: ../../using/cmdline.rst:358 msgid "" "``python -m module`` command line: Don't prepend the current working " "directory." msgstr "" -#: ../../using/cmdline.rst:351 +#: ../../using/cmdline.rst:360 msgid "" "``python script.py`` command line: Don't prepend the script's directory. If " "it's a symbolic link, resolve symbolic links." msgstr "" -#: ../../using/cmdline.rst:353 +#: ../../using/cmdline.rst:362 msgid "" "``python -c code`` and ``python`` (REPL) command lines: Don't prepend an " "empty string, which means the current working directory." msgstr "" -#: ../../using/cmdline.rst:356 +#: ../../using/cmdline.rst:365 msgid "" "See also the :envvar:`PYTHONSAFEPATH` environment variable, and :option:`-E` " "and :option:`-I` (isolated) options." msgstr "" -#: ../../using/cmdline.rst:364 +#: ../../using/cmdline.rst:373 msgid "" "Don't display the copyright and version messages even in interactive mode." msgstr "" -#: ../../using/cmdline.rst:371 +#: ../../using/cmdline.rst:380 msgid "" "Turn on hash randomization. This option only has an effect if the :envvar:" "`PYTHONHASHSEED` environment variable is set to anything other than " "``random``, since hash randomization is enabled by default." msgstr "" -#: ../../using/cmdline.rst:375 +#: ../../using/cmdline.rst:384 msgid "" "On previous versions of Python, this option turns on hash randomization, so " "that the :meth:`~object.__hash__` values of str and bytes objects are " @@ -536,7 +544,7 @@ msgid "" "between repeated invocations of Python." msgstr "" -#: ../../using/cmdline.rst:381 +#: ../../using/cmdline.rst:390 msgid "" "Hash randomization is intended to provide protection against a denial-of-" "service caused by carefully chosen inputs that exploit the worst case " @@ -544,32 +552,32 @@ msgid "" "https://ocert.org/advisories/ocert-2011-003.html for details." msgstr "" -#: ../../using/cmdline.rst:386 +#: ../../using/cmdline.rst:395 msgid "" ":envvar:`PYTHONHASHSEED` allows you to set a fixed value for the hash seed " "secret." msgstr "" -#: ../../using/cmdline.rst:391 +#: ../../using/cmdline.rst:400 msgid "The option is no longer ignored." msgstr "" -#: ../../using/cmdline.rst:397 +#: ../../using/cmdline.rst:406 msgid "" "Don't add the :data:`user site-packages directory ` to :data:" "`sys.path`." msgstr "" -#: ../../using/cmdline.rst:400 +#: ../../using/cmdline.rst:409 msgid "See also :envvar:`PYTHONNOUSERSITE`." msgstr "另請參閱 :envvar:`PYTHONNOUSERSITE`。" -#: ../../using/cmdline.rst:404 ../../using/cmdline.rst:949 -#: ../../using/cmdline.rst:961 +#: ../../using/cmdline.rst:413 ../../using/cmdline.rst:986 +#: ../../using/cmdline.rst:1001 msgid ":pep:`370` -- Per user site-packages directory" msgstr "" -#: ../../using/cmdline.rst:409 +#: ../../using/cmdline.rst:418 msgid "" "Disable the import of the module :mod:`site` and the site-dependent " "manipulations of :data:`sys.path` that it entails. Also disable these " @@ -577,21 +585,21 @@ msgid "" "main` if you want them to be triggered)." msgstr "" -#: ../../using/cmdline.rst:417 +#: ../../using/cmdline.rst:426 msgid "" "Force the stdout and stderr streams to be unbuffered. This option has no " "effect on the stdin stream." msgstr "" -#: ../../using/cmdline.rst:420 +#: ../../using/cmdline.rst:429 msgid "See also :envvar:`PYTHONUNBUFFERED`." msgstr "另請參閱 :envvar:`PYTHONUNBUFFERED`。" -#: ../../using/cmdline.rst:422 +#: ../../using/cmdline.rst:431 msgid "The text layer of the stdout and stderr streams now is unbuffered." msgstr "" -#: ../../using/cmdline.rst:428 +#: ../../using/cmdline.rst:437 msgid "" "Print a message each time a module is initialized, showing the place " "(filename or built-in module) from which it is loaded. When given twice (:" @@ -599,30 +607,30 @@ msgid "" "searching for a module. Also provides information on module cleanup at exit." msgstr "" -#: ../../using/cmdline.rst:433 +#: ../../using/cmdline.rst:442 msgid "" "The :mod:`site` module reports the site-specific paths and :file:`.pth` " "files being processed." msgstr "" -#: ../../using/cmdline.rst:437 +#: ../../using/cmdline.rst:446 msgid "See also :envvar:`PYTHONVERBOSE`." msgstr "另請參閱 :envvar:`PYTHONVERBOSE`。" -#: ../../using/cmdline.rst:443 +#: ../../using/cmdline.rst:452 msgid "" "Warning control. Python's warning machinery by default prints warning " "messages to :data:`sys.stderr`." msgstr "" -#: ../../using/cmdline.rst:446 ../../using/cmdline.rst:977 +#: ../../using/cmdline.rst:455 ../../using/cmdline.rst:1017 msgid "" "The simplest settings apply a particular action unconditionally to all " "warnings emitted by a process (even those that are otherwise ignored by " "default)::" msgstr "" -#: ../../using/cmdline.rst:450 +#: ../../using/cmdline.rst:459 msgid "" "-Wdefault # Warn once per call location\n" "-Werror # Convert to exceptions\n" @@ -633,41 +641,42 @@ msgid "" "-Wignore # Never warn" msgstr "" -#: ../../using/cmdline.rst:458 +#: ../../using/cmdline.rst:467 msgid "" "The action names can be abbreviated as desired and the interpreter will " "resolve them to the appropriate action name. For example, ``-Wi`` is the " "same as ``-Wignore``." msgstr "" -#: ../../using/cmdline.rst:462 +#: ../../using/cmdline.rst:471 msgid "The full form of argument is::" msgstr "完整的引數形式為: ::" -#: ../../using/cmdline.rst:464 +#: ../../using/cmdline.rst:473 msgid "action:message:category:module:lineno" msgstr "action:message:category:module:lineno" -#: ../../using/cmdline.rst:466 +#: ../../using/cmdline.rst:475 msgid "" "Empty fields match all values; trailing empty fields may be omitted. For " "example ``-W ignore::DeprecationWarning`` ignores all DeprecationWarning " "warnings." msgstr "" -#: ../../using/cmdline.rst:470 +#: ../../using/cmdline.rst:479 msgid "" "The *action* field is as explained above but only applies to warnings that " "match the remaining fields." msgstr "" -#: ../../using/cmdline.rst:473 +#: ../../using/cmdline.rst:482 msgid "" -"The *message* field must match the whole warning message; this match is case-" -"insensitive." +"The *message* field must match the start of the warning message; this match " +"is case-insensitive. If it starts and ends with a forward slash (``/``), it " +"specifies a regular expression, otherwise it specifies a literal string." msgstr "" -#: ../../using/cmdline.rst:476 +#: ../../using/cmdline.rst:487 msgid "" "The *category* field matches the warning category (ex: " "``DeprecationWarning``). This must be a class name; the match test whether " @@ -675,19 +684,22 @@ msgid "" "warning category." msgstr "" -#: ../../using/cmdline.rst:481 +#: ../../using/cmdline.rst:492 msgid "" "The *module* field matches the (fully qualified) module name; this match is " -"case-sensitive." +"case-sensitive. If it starts and ends with a forward slash (``/``), it " +"specifies a regular expression that the start of the fully qualified module " +"name must match, otherwise it specifies a literal string that the fully " +"qualified module name must be equal to." msgstr "" -#: ../../using/cmdline.rst:484 +#: ../../using/cmdline.rst:499 msgid "" "The *lineno* field matches the line number, where zero matches all line " "numbers and is thus equivalent to an omitted line number." msgstr "" -#: ../../using/cmdline.rst:487 +#: ../../using/cmdline.rst:502 msgid "" "Multiple :option:`-W` options can be given; when a warning matches more than " "one option, the action for the last matching option is performed. Invalid :" @@ -695,7 +707,7 @@ msgid "" "invalid options when the first warning is issued)." msgstr "" -#: ../../using/cmdline.rst:492 +#: ../../using/cmdline.rst:507 msgid "" "Warnings can also be controlled using the :envvar:`PYTHONWARNINGS` " "environment variable and from within a Python program using the :mod:" @@ -703,19 +715,23 @@ msgid "" "can be used to use a regular expression on the warning message." msgstr "" -#: ../../using/cmdline.rst:497 ../../using/cmdline.rst:989 +#: ../../using/cmdline.rst:512 ../../using/cmdline.rst:1029 msgid "" "See :ref:`warning-filter` and :ref:`describing-warning-filters` for more " "details." msgstr "" -#: ../../using/cmdline.rst:503 +#: ../../using/cmdline.rst:515 ../../using/cmdline.rst:1032 +msgid "Added regular expression support for *message* and *module*." +msgstr "" + +#: ../../using/cmdline.rst:521 msgid "" "Skip the first line of the source, allowing use of non-Unix forms of ``#!" "cmd``." msgstr "" -#: ../../using/cmdline.rst:506 +#: ../../using/cmdline.rst:524 msgid "" "This can be used to turn a Python script into a Windows batch file. " "Similarly to adding a shebang line and setting the executable bit on Unix, " @@ -723,37 +739,37 @@ msgid "" "following line can be added at the start of the script:" msgstr "" -#: ../../using/cmdline.rst:511 +#: ../../using/cmdline.rst:529 msgid "@py -x \"%~f0\" %* & exit /b" msgstr "" -#: ../../using/cmdline.rst:515 +#: ../../using/cmdline.rst:533 msgid "Or, to specify the path to the Python interpreter explicitly:" msgstr "" -#: ../../using/cmdline.rst:517 +#: ../../using/cmdline.rst:535 msgid "@\"C:\\Path\\to\\python.exe\" -x \"%~f0\" %* & exit /b" msgstr "" -#: ../../using/cmdline.rst:521 +#: ../../using/cmdline.rst:539 msgid "" "Unlike a shebang line which is a Python comment, this line is not valid " "Python syntax, and the :option:`-x` option is needed to skip it." msgstr "" -#: ../../using/cmdline.rst:527 +#: ../../using/cmdline.rst:545 msgid "" "Reserved for various implementation-specific options. CPython currently " "defines the following possible values:" msgstr "" -#: ../../using/cmdline.rst:530 +#: ../../using/cmdline.rst:548 msgid "" "``-X faulthandler`` to enable :mod:`faulthandler`. See also :envvar:" "`PYTHONFAULTHANDLER`." msgstr "" -#: ../../using/cmdline.rst:535 +#: ../../using/cmdline.rst:553 msgid "" "``-X showrefcount`` to output the total reference count and number of used " "memory blocks when the program finishes or after each statement in the " @@ -761,7 +777,7 @@ msgid "" "build>`." msgstr "" -#: ../../using/cmdline.rst:542 +#: ../../using/cmdline.rst:560 msgid "" "``-X tracemalloc`` to start tracing Python memory allocations using the :mod:" "`tracemalloc` module. By default, only the most recent frame is stored in a " @@ -770,14 +786,14 @@ msgid "" "envvar:`PYTHONTRACEMALLOC` for more information." msgstr "" -#: ../../using/cmdline.rst:551 +#: ../../using/cmdline.rst:569 msgid "" "``-X int_max_str_digits`` configures the :ref:`integer string conversion " "length limitation `. See also :envvar:" "`PYTHONINTMAXSTRDIGITS`." msgstr "" -#: ../../using/cmdline.rst:557 +#: ../../using/cmdline.rst:575 msgid "" "``-X importtime`` to show how long each import takes. It shows module name, " "cumulative time (including nested imports) and self time (excluding nested " @@ -785,52 +801,52 @@ msgid "" "application. Typical usage is ``python -X importtime -c 'import asyncio'``." msgstr "" -#: ../../using/cmdline.rst:562 +#: ../../using/cmdline.rst:580 msgid "" "``-X importtime=2`` enables additional output that indicates when an " "imported module has already been loaded. In such cases, the string " "``cached`` will be printed in both time columns." msgstr "" -#: ../../using/cmdline.rst:566 +#: ../../using/cmdline.rst:584 msgid "See also :envvar:`PYTHONPROFILEIMPORTTIME`." msgstr "另請參閱 :envvar:`PYTHONPROFILEIMPORTTIME`。" -#: ../../using/cmdline.rst:572 +#: ../../using/cmdline.rst:590 msgid "" "Added ``-X importtime=2`` to also trace imports of loaded modules, and " "reserved values other than ``1`` and ``2`` for future use." msgstr "" -#: ../../using/cmdline.rst:575 +#: ../../using/cmdline.rst:593 msgid "" "``-X dev``: enable :ref:`Python Development Mode `, introducing " "additional runtime checks that are too expensive to be enabled by default. " "See also :envvar:`PYTHONDEVMODE`." msgstr "" -#: ../../using/cmdline.rst:581 +#: ../../using/cmdline.rst:599 msgid "" "``-X utf8`` enables the :ref:`Python UTF-8 Mode `. ``-X utf8=0`` " "explicitly disables :ref:`Python UTF-8 Mode ` (even when it would " "otherwise activate automatically). See also :envvar:`PYTHONUTF8`." msgstr "" -#: ../../using/cmdline.rst:588 +#: ../../using/cmdline.rst:606 msgid "" "``-X pycache_prefix=PATH`` enables writing ``.pyc`` files to a parallel tree " "rooted at the given directory instead of to the code tree. See also :envvar:" "`PYTHONPYCACHEPREFIX`." msgstr "" -#: ../../using/cmdline.rst:594 +#: ../../using/cmdline.rst:612 msgid "" "``-X warn_default_encoding`` issues a :class:`EncodingWarning` when the " "locale-specific default encoding is used for opening files. See also :envvar:" "`PYTHONWARNDEFAULTENCODING`." msgstr "" -#: ../../using/cmdline.rst:600 +#: ../../using/cmdline.rst:618 msgid "" "``-X no_debug_ranges`` disables the inclusion of the tables mapping extra " "location information (end line, start column offset and end column offset) " @@ -840,7 +856,7 @@ msgid "" "envvar:`PYTHONNODEBUGRANGES`." msgstr "" -#: ../../using/cmdline.rst:609 +#: ../../using/cmdline.rst:627 msgid "" "``-X frozen_modules`` determines whether or not frozen modules are ignored " "by the import machinery. A value of ``on`` means they get imported and " @@ -852,7 +868,7 @@ msgid "" "`PYTHON_FROZEN_MODULES`." msgstr "" -#: ../../using/cmdline.rst:620 +#: ../../using/cmdline.rst:638 msgid "" "``-X perf`` enables support for the Linux ``perf`` profiler. When this " "option is provided, the ``perf`` profiler will be able to report Python " @@ -861,7 +877,7 @@ msgid "" "also :envvar:`PYTHONPERFSUPPORT` and :ref:`perf_profiling`." msgstr "" -#: ../../using/cmdline.rst:628 +#: ../../using/cmdline.rst:646 msgid "" "``-X perf_jit`` enables support for the Linux ``perf`` profiler with DWARF " "support. When this option is provided, the ``perf`` profiler will be able to " @@ -871,7 +887,7 @@ msgid "" "`PYTHON_PERF_JIT_SUPPORT` and :ref:`perf_profiling`." msgstr "" -#: ../../using/cmdline.rst:637 +#: ../../using/cmdline.rst:655 msgid "" "``-X disable-remote-debug`` disables the remote debugging support as " "described in :pep:`768`. This includes both the functionality to schedule " @@ -879,14 +895,14 @@ msgid "" "for execution in the current process." msgstr "" -#: ../../using/cmdline.rst:642 +#: ../../using/cmdline.rst:660 msgid "" "This option is only available on some platforms and will do nothing if is " "not supported on the current system. See also :envvar:" "`PYTHON_DISABLE_REMOTE_DEBUG` and :pep:`768`." msgstr "" -#: ../../using/cmdline.rst:648 +#: ../../using/cmdline.rst:666 msgid "" ":samp:`-X cpu_count={n}` overrides :func:`os.cpu_count`, :func:`os." "process_cpu_count`, and :func:`multiprocessing.cpu_count`. *n* must be " @@ -895,17 +911,22 @@ msgid "" "`PYTHON_CPU_COUNT`. If *n* is ``default``, nothing is overridden." msgstr "" -#: ../../using/cmdline.rst:657 +#: ../../using/cmdline.rst:675 msgid "" -":samp:`-X presite={package.module}` specifies a module that should be " -"imported before the :mod:`site` module is executed and before the :mod:" -"`__main__` module exists. Therefore, the imported module isn't :mod:" -"`__main__`. This can be used to execute code early during Python " -"initialization. Python needs to be :ref:`built in debug mode ` " -"for this option to exist. See also :envvar:`PYTHON_PRESITE`." +":samp:`-X presite={module}` or :samp:`-X presite={module:func}` specifies an " +"entry point that should be executed before the :mod:`site` module is " +"executed and before the :mod:`__main__` module exists. Therefore, the " +"imported module isn't :mod:`__main__`. This can be used to execute code " +"early during Python initialization. Python needs to be :ref:`built in debug " +"mode ` for this option to exist. See also :envvar:" +"`PYTHON_PRESITE`." msgstr "" -#: ../../using/cmdline.rst:666 +#: ../../using/cmdline.rst:683 ../../using/cmdline.rst:1481 +msgid "Accept also ``module:func`` entry point format." +msgstr "" + +#: ../../using/cmdline.rst:688 msgid "" ":samp:`-X gil={0,1}` forces the GIL to be disabled or enabled, respectively. " "Setting to ``0`` is only available in builds configured with :option:`--" @@ -913,7 +934,7 @@ msgid "" "threaded-cpython`." msgstr "" -#: ../../using/cmdline.rst:673 +#: ../../using/cmdline.rst:695 msgid "" ":samp:`-X thread_inherit_context={0,1}` causes :class:`~threading.Thread` " "to, by default, use a copy of context of the caller of ``Thread.start()`` " @@ -922,7 +943,7 @@ msgid "" "and to ``0`` otherwise. See also :envvar:`PYTHON_THREAD_INHERIT_CONTEXT`." msgstr "" -#: ../../using/cmdline.rst:682 +#: ../../using/cmdline.rst:704 msgid "" ":samp:`-X context_aware_warnings={0,1}` causes the :class:`warnings." "catch_warnings` context manager to use a :class:`~contextvars.ContextVar` to " @@ -931,7 +952,15 @@ msgid "" "`PYTHON_CONTEXT_AWARE_WARNINGS`." msgstr "" -#: ../../using/cmdline.rst:690 +#: ../../using/cmdline.rst:712 +msgid "" +":samp:`-X pathconfig_warnings={0,1}` if true (``1``) then :ref:`sys-path-" +"init` is allowed to log warnings into stderr. If false (``0``) suppress " +"these warnings. Set to true by default. See also :envvar:" +"`PYTHON_PATHCONFIG_WARNINGS`." +msgstr "" + +#: ../../using/cmdline.rst:719 msgid "" ":samp:`-X tlbc={0,1}` enables (1, the default) or disables (0) thread-local " "bytecode in builds configured with :option:`--disable-gil`. When disabled, " @@ -939,56 +968,63 @@ msgid "" "`PYTHON_TLBC`." msgstr "" -#: ../../using/cmdline.rst:697 +#: ../../using/cmdline.rst:726 +msgid "" +":samp:`-X lazy_imports={all,normal}` controls lazy import behavior. ``all`` " +"makes all imports lazy by default, and ``normal`` (the default) respects the " +"``lazy`` keyword in source code. See also :envvar:`PYTHON_LAZY_IMPORTS`." +msgstr "" + +#: ../../using/cmdline.rst:733 msgid "" "It also allows passing arbitrary values and retrieving them through the :" "data:`sys._xoptions` dictionary." msgstr "" -#: ../../using/cmdline.rst:702 +#: ../../using/cmdline.rst:738 msgid "Removed the ``-X showalloccount`` option." msgstr "移除 ``-X showalloccount`` 選項。" -#: ../../using/cmdline.rst:705 +#: ../../using/cmdline.rst:741 msgid "Removed the ``-X oldparser`` option." msgstr "移除 ``-X oldparser`` 選項。" -#: ../../using/cmdline.rst:710 +#: ../../using/cmdline.rst:746 msgid "" ":option:`!-J` is no longer reserved for use by Jython_, and now has no " "special meaning." msgstr "" -#: ../../using/cmdline.rst:718 +#: ../../using/cmdline.rst:754 msgid "Controlling color" msgstr "" -#: ../../using/cmdline.rst:720 +#: ../../using/cmdline.rst:756 msgid "" "The Python interpreter is configured by default to use colors to highlight " "output in certain situations such as when displaying tracebacks. This " "behavior can be controlled by setting different environment variables." msgstr "" -#: ../../using/cmdline.rst:724 +#: ../../using/cmdline.rst:760 msgid "" "Setting the environment variable ``TERM`` to ``dumb`` will disable color." msgstr "" -#: ../../using/cmdline.rst:726 +#: ../../using/cmdline.rst:762 msgid "" "If the |FORCE_COLOR|_ environment variable is set, then color will be " "enabled regardless of the value of TERM. This is useful on CI systems which " "aren’t terminals but can still display ANSI escape sequences." msgstr "" -#: ../../using/cmdline.rst:730 +#: ../../using/cmdline.rst:766 msgid "" "If the |NO_COLOR|_ environment variable is set, Python will disable all " "color in the output. This takes precedence over ``FORCE_COLOR``." msgstr "" -#: ../../using/cmdline.rst:733 +#: ../../using/cmdline.rst:769 msgid "" "All these environment variables are used also by other tools to control " "color output. To control the color output only in the Python interpreter, " @@ -997,11 +1033,11 @@ msgid "" "``FORCE_COLOR``." msgstr "" -#: ../../using/cmdline.rst:743 +#: ../../using/cmdline.rst:779 msgid "Environment variables" msgstr "環境變數" -#: ../../using/cmdline.rst:745 +#: ../../using/cmdline.rst:781 msgid "" "These environment variables influence Python's behavior, they are processed " "before the command-line switches other than -E or -I. It is customary that " @@ -1009,7 +1045,7 @@ msgid "" "conflict." msgstr "" -#: ../../using/cmdline.rst:752 +#: ../../using/cmdline.rst:788 msgid "" "Change the location of the standard Python libraries. By default, the " "libraries are searched in :file:`{prefix}/lib/python{version}` and :file:" @@ -1018,14 +1054,14 @@ msgid "" "file:`/usr/local`." msgstr "" -#: ../../using/cmdline.rst:758 +#: ../../using/cmdline.rst:794 msgid "" "When :envvar:`PYTHONHOME` is set to a single directory, its value replaces " "both :file:`{prefix}` and :file:`{exec_prefix}`. To specify different " "values for these, set :envvar:`PYTHONHOME` to :file:`{prefix}:{exec_prefix}`." msgstr "" -#: ../../using/cmdline.rst:765 +#: ../../using/cmdline.rst:801 msgid "" "Augment the default search path for module files. The format is the same as " "the shell's :envvar:`PATH`: one or more directory pathnames separated by :" @@ -1033,21 +1069,21 @@ msgid "" "existent directories are silently ignored." msgstr "" -#: ../../using/cmdline.rst:770 +#: ../../using/cmdline.rst:806 msgid "" "In addition to normal directories, individual :envvar:`PYTHONPATH` entries " "may refer to zipfiles containing pure Python modules (in either source or " "compiled form). Extension modules cannot be imported from zipfiles." msgstr "" -#: ../../using/cmdline.rst:774 +#: ../../using/cmdline.rst:810 msgid "" "The default search path is installation dependent, but generally begins " "with :file:`{prefix}/lib/python{version}` (see :envvar:`PYTHONHOME` above). " "It is *always* appended to :envvar:`PYTHONPATH`." msgstr "" -#: ../../using/cmdline.rst:778 +#: ../../using/cmdline.rst:814 msgid "" "An additional directory will be inserted in the search path in front of :" "envvar:`PYTHONPATH` as described above under :ref:`using-on-interface-" @@ -1055,19 +1091,19 @@ msgid "" "the variable :data:`sys.path`." msgstr "" -#: ../../using/cmdline.rst:786 +#: ../../using/cmdline.rst:822 msgid "" "If this is set to a non-empty string, don't prepend a potentially unsafe " "path to :data:`sys.path`: see the :option:`-P` option for details." msgstr "" -#: ../../using/cmdline.rst:794 +#: ../../using/cmdline.rst:830 msgid "" "If this is set to a non-empty string, it overrides the :data:`sys." "platlibdir` value." msgstr "" -#: ../../using/cmdline.rst:802 +#: ../../using/cmdline.rst:838 msgid "" "If this is the name of a readable file, the Python commands in that file are " "executed before the first prompt is displayed in interactive mode. The file " @@ -1078,7 +1114,7 @@ msgid "" "file." msgstr "" -#: ../../using/cmdline.rst:809 ../../using/cmdline.rst:811 +#: ../../using/cmdline.rst:845 ../../using/cmdline.rst:847 msgid "" "Raises an :ref:`auditing event ` ``cpython.run_startup`` with the " "filename as the argument when called on startup." @@ -1086,14 +1122,14 @@ msgstr "" "引發一個附帶呼叫啟動時的檔案名稱為引數的\\ :ref:`稽核事件 ` " "``cpython.run_startup``。" -#: ../../using/cmdline.rst:817 +#: ../../using/cmdline.rst:853 msgid "" "If this is set to a non-empty string it is equivalent to specifying the :" "option:`-O` option. If set to an integer, it is equivalent to specifying :" "option:`-O` multiple times." msgstr "" -#: ../../using/cmdline.rst:824 +#: ../../using/cmdline.rst:860 msgid "" "If this is set, it names a callable using dotted-path notation. The module " "containing the callable will be imported and then the callable will be run " @@ -1104,68 +1140,68 @@ msgid "" "breakpointhook` to do nothing but return immediately." msgstr "" -#: ../../using/cmdline.rst:836 +#: ../../using/cmdline.rst:872 msgid "" "If this is set to a non-empty string it is equivalent to specifying the :" "option:`-d` option. If set to an integer, it is equivalent to specifying :" "option:`-d` multiple times." msgstr "" -#: ../../using/cmdline.rst:840 +#: ../../using/cmdline.rst:876 msgid "" "This environment variable requires a :ref:`debug build of Python `, otherwise it's ignored." msgstr "" -#: ../../using/cmdline.rst:846 +#: ../../using/cmdline.rst:882 msgid "" "If this is set to a non-empty string it is equivalent to specifying the :" "option:`-i` option." msgstr "" -#: ../../using/cmdline.rst:849 +#: ../../using/cmdline.rst:885 msgid "" "This variable can also be modified by Python code using :data:`os.environ` " "to force inspect mode on program termination." msgstr "" -#: ../../using/cmdline.rst:854 +#: ../../using/cmdline.rst:890 msgid "(also 3.11.10, 3.10.15, 3.9.20, and 3.8.20) Emits audit events." msgstr "" -#: ../../using/cmdline.rst:857 +#: ../../using/cmdline.rst:893 msgid "" "Uses PyREPL if possible, in which case :envvar:`PYTHONSTARTUP` is also " "executed. Emits audit events." msgstr "" -#: ../../using/cmdline.rst:864 +#: ../../using/cmdline.rst:900 msgid "" "If this is set to a non-empty string it is equivalent to specifying the :" "option:`-u` option." msgstr "" -#: ../../using/cmdline.rst:870 +#: ../../using/cmdline.rst:906 msgid "" "If this is set to a non-empty string it is equivalent to specifying the :" "option:`-v` option. If set to an integer, it is equivalent to specifying :" "option:`-v` multiple times." msgstr "" -#: ../../using/cmdline.rst:877 +#: ../../using/cmdline.rst:913 msgid "" "If this is set, Python ignores case in :keyword:`import` statements. This " "only works on Windows and macOS." msgstr "" -#: ../../using/cmdline.rst:883 +#: ../../using/cmdline.rst:919 msgid "" "If this is set to a non-empty string, Python won't try to write ``.pyc`` " "files on the import of source modules. This is equivalent to specifying " "the :option:`-B` option." msgstr "" -#: ../../using/cmdline.rst:890 +#: ../../using/cmdline.rst:926 msgid "" "If this is set, Python will write ``.pyc`` files in a mirror directory tree " "at this path, instead of in ``__pycache__`` directories within the source " @@ -1173,40 +1209,40 @@ msgid "" "``pycache_prefix=PATH`` option." msgstr "" -#: ../../using/cmdline.rst:900 +#: ../../using/cmdline.rst:936 msgid "" "If this variable is not set or set to ``random``, a random value is used to " "seed the hashes of str and bytes objects." msgstr "" -#: ../../using/cmdline.rst:903 +#: ../../using/cmdline.rst:939 msgid "" "If :envvar:`PYTHONHASHSEED` is set to an integer value, it is used as a " "fixed seed for generating the hash() of the types covered by the hash " "randomization." msgstr "" -#: ../../using/cmdline.rst:907 +#: ../../using/cmdline.rst:943 msgid "" "Its purpose is to allow repeatable hashing, such as for selftests for the " "interpreter itself, or to allow a cluster of python processes to share hash " "values." msgstr "" -#: ../../using/cmdline.rst:911 +#: ../../using/cmdline.rst:947 msgid "" "The integer must be a decimal number in the range [0,4294967295]. " "Specifying the value 0 will disable hash randomization." msgstr "" -#: ../../using/cmdline.rst:918 +#: ../../using/cmdline.rst:954 msgid "" "If this variable is set to an integer, it is used to configure the " "interpreter's global :ref:`integer string conversion length limitation " "`." msgstr "" -#: ../../using/cmdline.rst:926 +#: ../../using/cmdline.rst:962 msgid "" "If this is set before running the interpreter, it overrides the encoding " "used for stdin/stdout/stderr, in the syntax ``encodingname:errorhandler``. " @@ -1214,17 +1250,17 @@ msgid "" "have the same meaning as in :func:`str.encode`." msgstr "" -#: ../../using/cmdline.rst:931 +#: ../../using/cmdline.rst:967 msgid "" "For stderr, the ``:errorhandler`` part is ignored; the handler will always " "be ``'backslashreplace'``." msgstr "" -#: ../../using/cmdline.rst:934 +#: ../../using/cmdline.rst:970 msgid "The ``encodingname`` part is now optional." msgstr "" -#: ../../using/cmdline.rst:937 +#: ../../using/cmdline.rst:973 msgid "" "On Windows, the encoding specified by this variable is ignored for " "interactive console buffers unless :envvar:`PYTHONLEGACYWINDOWSSTDIO` is " @@ -1232,13 +1268,14 @@ msgid "" "not affected." msgstr "" -#: ../../using/cmdline.rst:944 +#: ../../using/cmdline.rst:980 msgid "" -"If this is set, Python won't add the :data:`user site-packages directory " -"` to :data:`sys.path`." +"This is equivalent to the :option:`-s` option. If this is set, Python won't " +"add the :data:`user site-packages directory ` to :data:`sys." +"path`." msgstr "" -#: ../../using/cmdline.rst:954 +#: ../../using/cmdline.rst:991 msgid "" "Defines the :data:`user base directory `, which is used to " "compute the path of the :data:`user site-packages directory ` of the :mod:`asyncio` module." msgstr "" -#: ../../using/cmdline.rst:1042 +#: ../../using/cmdline.rst:1085 msgid "Set the Python memory allocators and/or install debug hooks." msgstr "" -#: ../../using/cmdline.rst:1044 +#: ../../using/cmdline.rst:1087 msgid "Set the family of memory allocators used by Python:" msgstr "" -#: ../../using/cmdline.rst:1046 +#: ../../using/cmdline.rst:1089 msgid "" "``default``: use the :ref:`default memory allocators `." msgstr "" -#: ../../using/cmdline.rst:1048 +#: ../../using/cmdline.rst:1091 msgid "" "``malloc``: use the :c:func:`malloc` function of the C library for all " "domains (:c:macro:`PYMEM_DOMAIN_RAW`, :c:macro:`PYMEM_DOMAIN_MEM`, :c:macro:" "`PYMEM_DOMAIN_OBJ`)." msgstr "" -#: ../../using/cmdline.rst:1051 +#: ../../using/cmdline.rst:1094 msgid "" "``pymalloc``: use the :ref:`pymalloc allocator ` for :c:macro:" "`PYMEM_DOMAIN_MEM` and :c:macro:`PYMEM_DOMAIN_OBJ` domains and use the :c:" "func:`malloc` function for the :c:macro:`PYMEM_DOMAIN_RAW` domain." msgstr "" -#: ../../using/cmdline.rst:1054 +#: ../../using/cmdline.rst:1097 msgid "" "``mimalloc``: use the :ref:`mimalloc allocator ` for :c:macro:" "`PYMEM_DOMAIN_MEM` and :c:macro:`PYMEM_DOMAIN_OBJ` domains and use the :c:" "func:`malloc` function for the :c:macro:`PYMEM_DOMAIN_RAW` domain." msgstr "" -#: ../../using/cmdline.rst:1058 +#: ../../using/cmdline.rst:1101 msgid "Install :ref:`debug hooks `:" msgstr "" -#: ../../using/cmdline.rst:1060 +#: ../../using/cmdline.rst:1103 msgid "" "``debug``: install debug hooks on top of the :ref:`default memory allocators " "`." msgstr "" -#: ../../using/cmdline.rst:1062 +#: ../../using/cmdline.rst:1105 msgid "``malloc_debug``: same as ``malloc`` but also install debug hooks." msgstr "" -#: ../../using/cmdline.rst:1063 +#: ../../using/cmdline.rst:1106 msgid "``pymalloc_debug``: same as ``pymalloc`` but also install debug hooks." msgstr "" -#: ../../using/cmdline.rst:1064 +#: ../../using/cmdline.rst:1107 msgid "``mimalloc_debug``: same as ``mimalloc`` but also install debug hooks." msgstr "" -#: ../../using/cmdline.rst:1068 +#: ../../using/cmdline.rst:1111 msgid "" "In the :term:`free-threaded ` build, the ``malloc``, " "``malloc_debug``, ``pymalloc``, and ``pymalloc_debug`` values are not " @@ -1373,11 +1416,11 @@ msgid "" "``mimalloc_debug`` are accepted." msgstr "" -#: ../../using/cmdline.rst:1075 +#: ../../using/cmdline.rst:1118 msgid "Added the ``\"default\"`` allocator." msgstr "" -#: ../../using/cmdline.rst:1081 +#: ../../using/cmdline.rst:1124 msgid "" "If set to a non-empty string, Python will print statistics of the :ref:" "`pymalloc memory allocator ` or the :ref:`mimalloc memory " @@ -1385,20 +1428,53 @@ msgid "" "created, and on shutdown." msgstr "" -#: ../../using/cmdline.rst:1086 +#: ../../using/cmdline.rst:1129 msgid "" "This variable is ignored if the :envvar:`PYTHONMALLOC` environment variable " "is used to force the :c:func:`malloc` allocator of the C library, or if " "Python is configured without both ``pymalloc`` and ``mimalloc`` support." msgstr "" -#: ../../using/cmdline.rst:1090 +#: ../../using/cmdline.rst:1133 msgid "" "This variable can now also be used on Python compiled in release mode. It " "now has no effect if set to an empty string." msgstr "" -#: ../../using/cmdline.rst:1097 +#: ../../using/cmdline.rst:1140 +msgid "" +"If set to a non-zero integer, enable huge page support for :ref:`pymalloc " +"` arenas. Set to ``0`` or unset to disable. Python must be " +"compiled with :option:`--with-pymalloc-hugepages` for this variable to have " +"any effect." +msgstr "" + +#: ../../using/cmdline.rst:1145 +msgid "" +"When enabled, arena allocation uses ``MAP_HUGETLB`` (Linux) or " +"``MEM_LARGE_PAGES`` (Windows) with automatic fallback to regular pages if " +"huge pages are not available." +msgstr "" + +#: ../../using/cmdline.rst:1151 +msgid "" +"On Linux, if the huge-page pool is exhausted, page faults — including copy-" +"on-write faults triggered by :func:`os.fork` — deliver ``SIGBUS`` and kill " +"the process. Only enable this in environments where the huge-page pool is " +"properly sized and fork-safety is not a concern." +msgstr "" + +#: ../../using/cmdline.rst:1156 +msgid "" +"On Windows you need a special privilege. See the `Windows documentation for " +"large pages `_ for details. Python will fail on startup if the required " +"privilege `SeLockMemoryPrivilege `_ is not held by the user." +msgstr "" + +#: ../../using/cmdline.rst:1169 msgid "" "If set to a non-empty string, the default :term:`filesystem encoding and " "error handler` mode will revert to their pre-3.6 values of 'mbcs' and " @@ -1406,42 +1482,42 @@ msgid "" "'surrogatepass' are used." msgstr "" -#: ../../using/cmdline.rst:1102 +#: ../../using/cmdline.rst:1174 msgid "" "This may also be enabled at runtime with :func:`sys." "_enablelegacywindowsfsencoding`." msgstr "" -#: ../../using/cmdline.rst:1105 ../../using/cmdline.rst:1119 -#: ../../using/cmdline.rst:1170 +#: ../../using/cmdline.rst:1177 ../../using/cmdline.rst:1191 +#: ../../using/cmdline.rst:1242 msgid "Availability" msgstr "可用性" -#: ../../using/cmdline.rst:1107 +#: ../../using/cmdline.rst:1179 msgid "See :pep:`529` for more details." msgstr "更多細節請見 :pep:`529`。" -#: ../../using/cmdline.rst:1112 +#: ../../using/cmdline.rst:1184 msgid "" "If set to a non-empty string, does not use the new console reader and " "writer. This means that Unicode characters will be encoded according to the " "active console code page, rather than using utf-8." msgstr "" -#: ../../using/cmdline.rst:1116 +#: ../../using/cmdline.rst:1188 msgid "" "This variable is ignored if the standard streams are redirected (to files or " "pipes) rather than referring to console buffers." msgstr "" -#: ../../using/cmdline.rst:1126 +#: ../../using/cmdline.rst:1198 msgid "" "If set to the value ``0``, causes the main Python command line application " "to skip coercing the legacy ASCII-based C and POSIX locales to a more " "capable UTF-8 based alternative." msgstr "" -#: ../../using/cmdline.rst:1130 +#: ../../using/cmdline.rst:1202 msgid "" "If this variable is *not* set (or is set to a value other than ``0``), the " "``LC_ALL`` locale override environment variable is also not set, and the " @@ -1452,19 +1528,19 @@ msgid "" "runtime:" msgstr "" -#: ../../using/cmdline.rst:1138 +#: ../../using/cmdline.rst:1210 msgid "``C.UTF-8``" msgstr "``C.UTF-8``" -#: ../../using/cmdline.rst:1139 +#: ../../using/cmdline.rst:1211 msgid "``C.utf8``" msgstr "``C.utf8``" -#: ../../using/cmdline.rst:1140 +#: ../../using/cmdline.rst:1212 msgid "``UTF-8``" msgstr "``UTF-8``" -#: ../../using/cmdline.rst:1142 +#: ../../using/cmdline.rst:1214 msgid "" "If setting one of these locale categories succeeds, then the ``LC_CTYPE`` " "environment variable will also be set accordingly in the current process " @@ -1477,7 +1553,7 @@ msgid "" "(such as Python's own :func:`locale.getdefaultlocale`)." msgstr "" -#: ../../using/cmdline.rst:1152 +#: ../../using/cmdline.rst:1224 msgid "" "Configuring one of these locales (either explicitly or via the above " "implicit locale coercion) automatically enables the ``surrogateescape`` :ref:" @@ -1487,7 +1563,7 @@ msgid "" "envvar:`PYTHONIOENCODING` as usual." msgstr "" -#: ../../using/cmdline.rst:1159 +#: ../../using/cmdline.rst:1231 msgid "" "For debugging purposes, setting ``PYTHONCOERCECLOCALE=warn`` will cause " "Python to emit warning messages on ``stderr`` if either the locale coercion " @@ -1495,7 +1571,7 @@ msgid "" "active when the Python runtime is initialized." msgstr "" -#: ../../using/cmdline.rst:1164 +#: ../../using/cmdline.rst:1236 msgid "" "Also note that even when locale coercion is disabled, or when it fails to " "find a suitable target locale, :envvar:`PYTHONUTF8` will still activate by " @@ -1504,11 +1580,11 @@ msgid "" "system interfaces." msgstr "" -#: ../../using/cmdline.rst:1172 +#: ../../using/cmdline.rst:1244 msgid "See :pep:`538` for more details." msgstr "更多細節請見 :pep:`538`。" -#: ../../using/cmdline.rst:1178 +#: ../../using/cmdline.rst:1250 msgid "" "If this environment variable is set to a non-empty string, enable :ref:" "`Python Development Mode `, introducing additional runtime checks " @@ -1516,31 +1592,31 @@ msgid "" "setting the :option:`-X` ``dev`` option." msgstr "" -#: ../../using/cmdline.rst:1187 +#: ../../using/cmdline.rst:1259 msgid "If set to ``1``, enable the :ref:`Python UTF-8 Mode `." msgstr "如果設為 ``1``,則啟用 :ref:`Python UTF-8 Mode `。" -#: ../../using/cmdline.rst:1189 +#: ../../using/cmdline.rst:1261 msgid "If set to ``0``, disable the :ref:`Python UTF-8 Mode `." msgstr "如果設為 ``0``,則停用 :ref:`Python UTF-8 Mode `。" -#: ../../using/cmdline.rst:1191 +#: ../../using/cmdline.rst:1263 msgid "" "Setting any other non-empty string causes an error during interpreter " "initialisation." msgstr "" -#: ../../using/cmdline.rst:1198 +#: ../../using/cmdline.rst:1270 msgid "" "If this environment variable is set to a non-empty string, issue a :class:" "`EncodingWarning` when the locale-specific default encoding is used." msgstr "" -#: ../../using/cmdline.rst:1201 +#: ../../using/cmdline.rst:1273 msgid "See :ref:`io-encoding-warning` for details." msgstr "細節請見 :ref:`io-encoding-warning`。" -#: ../../using/cmdline.rst:1207 +#: ../../using/cmdline.rst:1279 msgid "" "If this variable is set, it disables the inclusion of the tables mapping " "extra location information (end line, start column offset and end column " @@ -1549,36 +1625,36 @@ msgid "" "visual location indicators when the interpreter displays tracebacks." msgstr "" -#: ../../using/cmdline.rst:1217 +#: ../../using/cmdline.rst:1289 msgid "" "If this variable is set to a nonzero value, it enables support for the Linux " "``perf`` profiler so Python calls can be detected by it." msgstr "" -#: ../../using/cmdline.rst:1220 ../../using/cmdline.rst:1233 +#: ../../using/cmdline.rst:1292 ../../using/cmdline.rst:1305 msgid "If set to ``0``, disable Linux ``perf`` profiler support." msgstr "" -#: ../../using/cmdline.rst:1222 +#: ../../using/cmdline.rst:1294 msgid "" "See also the :option:`-X perf <-X>` command-line option and :ref:" "`perf_profiling`." msgstr "" -#: ../../using/cmdline.rst:1229 +#: ../../using/cmdline.rst:1301 msgid "" "If this variable is set to a nonzero value, it enables support for the Linux " "``perf`` profiler so Python calls can be detected by it using DWARF " "information." msgstr "" -#: ../../using/cmdline.rst:1235 +#: ../../using/cmdline.rst:1307 msgid "" "See also the :option:`-X perf_jit <-X>` command-line option and :ref:" "`perf_profiling`." msgstr "" -#: ../../using/cmdline.rst:1242 +#: ../../using/cmdline.rst:1314 msgid "" "If this variable is set to a non-empty string, it disables the remote " "debugging feature described in :pep:`768`. This includes both the " @@ -1586,21 +1662,21 @@ msgid "" "functionality to receive code for execution in the current process." msgstr "" -#: ../../using/cmdline.rst:1247 +#: ../../using/cmdline.rst:1319 msgid "See also the :option:`-X disable-remote-debug` command-line option." msgstr "另請參閱 :option:`-X disable-remote-debug` 命令列選項。" -#: ../../using/cmdline.rst:1253 +#: ../../using/cmdline.rst:1325 msgid "" "If this variable is set to a positive integer, it overrides the return " "values of :func:`os.cpu_count` and :func:`os.process_cpu_count`." msgstr "" -#: ../../using/cmdline.rst:1256 +#: ../../using/cmdline.rst:1328 msgid "See also the :option:`-X cpu_count <-X>` command-line option." msgstr "另請參閱 :option:`-X cpu_count <-X>` 命令列選項。" -#: ../../using/cmdline.rst:1262 +#: ../../using/cmdline.rst:1334 msgid "" "If this variable is set to ``on`` or ``off``, it determines whether or not " "frozen modules are ignored by the import machinery. A value of ``on`` means " @@ -1611,45 +1687,51 @@ msgid "" "flag is set to ``off``." msgstr "" -#: ../../using/cmdline.rst:1270 +#: ../../using/cmdline.rst:1342 msgid "See also the :option:`-X frozen_modules <-X>` command-line option." msgstr "另請參閱 :option:`-X frozen_modules <-X>` 命令列選項。" -#: ../../using/cmdline.rst:1276 +#: ../../using/cmdline.rst:1348 msgid "" "If this variable is set to ``1``, the interpreter will colorize various " "kinds of output. Setting it to ``0`` deactivates this behavior. See also :" "ref:`using-on-controlling-color`." msgstr "" -#: ../../using/cmdline.rst:1284 +#: ../../using/cmdline.rst:1356 msgid "" "If this variable is set to any value, the interpreter will not attempt to " "load the Python-based :term:`REPL` that requires :mod:`readline`, and will " "instead use the traditional parser-based :term:`REPL`." msgstr "" -#: ../../using/cmdline.rst:1292 +#: ../../using/cmdline.rst:1364 +msgid "" +"If this variable is set to any value, PyREPL will use :mod:`rlcompleter` to " +"implement tab completion, instead of the default one which uses colors." +msgstr "" + +#: ../../using/cmdline.rst:1371 msgid "" "This environment variable can be used to set the location of a ``." "python_history`` file (by default, it is ``.python_history`` in the user's " "home directory)." msgstr "" -#: ../../using/cmdline.rst:1300 +#: ../../using/cmdline.rst:1379 msgid "" "If this variable is set to ``1``, the global interpreter lock (GIL) will be " "forced on. Setting it to ``0`` forces the GIL off (needs Python configured " "with the :option:`--disable-gil` build option)." msgstr "" -#: ../../using/cmdline.rst:1304 +#: ../../using/cmdline.rst:1383 msgid "" "See also the :option:`-X gil <-X>` command-line option, which takes " "precedence over this variable, and :ref:`whatsnew313-free-threaded-cpython`." msgstr "" -#: ../../using/cmdline.rst:1311 +#: ../../using/cmdline.rst:1390 msgid "" "If this variable is set to ``1`` then :class:`~threading.Thread` will, by " "default, use a copy of context of the caller of ``Thread.start()`` when " @@ -1658,7 +1740,7 @@ msgid "" "otherwise. See also :option:`-X thread_inherit_context<-X>`." msgstr "" -#: ../../using/cmdline.rst:1321 +#: ../../using/cmdline.rst:1400 msgid "" "If set to ``1`` then the :class:`warnings.catch_warnings` context manager " "will use a :class:`~contextvars.ContextVar` to store warnings filter state. " @@ -1666,47 +1748,65 @@ msgid "" "``0`` otherwise. See :option:`-X context_aware_warnings<-X>`." msgstr "" -#: ../../using/cmdline.rst:1331 +#: ../../using/cmdline.rst:1410 +msgid "" +"If true (``1``) then :ref:`sys-path-init` is allowed to log warnings into " +"stderr. If false (``0``) suppress these warnings. Set to true by default. " +"See also :option:`-X pathconfig_warnings<-X>`." +msgstr "" + +#: ../../using/cmdline.rst:1418 msgid "" "On builds where experimental just-in-time compilation is available, this " "variable can force the JIT to be disabled (``0``) or enabled (``1``) at " "interpreter startup." msgstr "" -#: ../../using/cmdline.rst:1339 +#: ../../using/cmdline.rst:1426 msgid "" "If set to ``1`` enables thread-local bytecode. If set to ``0`` thread-local " "bytecode and the specializing interpreter are disabled. Only applies to " "builds configured with :option:`--disable-gil`." msgstr "" -#: ../../using/cmdline.rst:1343 +#: ../../using/cmdline.rst:1430 msgid "See also the :option:`-X tlbc <-X>` command-line option." msgstr "另請參閱 :option:`-X tlbc <-X>` 命令列選項。" -#: ../../using/cmdline.rst:1348 +#: ../../using/cmdline.rst:1436 +msgid "" +"Controls lazy import behavior. Accepts two values: ``all`` makes all imports " +"lazy by default, and ``normal`` (the default) respects the ``lazy`` keyword " +"in source code." +msgstr "" + +#: ../../using/cmdline.rst:1440 +msgid "See also the :option:`-X lazy_imports <-X>` command-line option." +msgstr "另請參閱 :option:`-X lazy_imports <-X>` 命令列選項。" + +#: ../../using/cmdline.rst:1445 msgid "Debug-mode variables" msgstr "除錯模式變數" -#: ../../using/cmdline.rst:1352 +#: ../../using/cmdline.rst:1449 msgid "" "If set, Python will dump objects and reference counts still alive after " "shutting down the interpreter." msgstr "" -#: ../../using/cmdline.rst:1355 ../../using/cmdline.rst:1363 +#: ../../using/cmdline.rst:1452 ../../using/cmdline.rst:1460 msgid "" "Needs Python configured with the :option:`--with-trace-refs` build option." msgstr "" -#: ../../using/cmdline.rst:1359 +#: ../../using/cmdline.rst:1456 msgid "" "If set, Python will dump objects and reference counts still alive after " "shutting down the interpreter into a file under the path given as the value " "to this environment variable." msgstr "" -#: ../../using/cmdline.rst:1369 +#: ../../using/cmdline.rst:1466 msgid "" "If this variable is set to a module, that module will be imported early in " "the interpreter lifecycle, before the :mod:`site` module is executed, and " @@ -1714,22 +1814,22 @@ msgid "" "is not treated as :mod:`__main__`." msgstr "" -#: ../../using/cmdline.rst:1374 +#: ../../using/cmdline.rst:1471 msgid "This can be used to execute code early during Python initialization." msgstr "" -#: ../../using/cmdline.rst:1376 +#: ../../using/cmdline.rst:1473 msgid "" "To import a submodule, use ``package.module`` as the value, like in an " "import statement." msgstr "" -#: ../../using/cmdline.rst:1379 +#: ../../using/cmdline.rst:1476 msgid "" "See also the :option:`-X presite <-X>` command-line option, which takes " "precedence over this variable." msgstr "" -#: ../../using/cmdline.rst:1382 +#: ../../using/cmdline.rst:1479 msgid "Needs Python configured with the :option:`--with-pydebug` build option." msgstr "" diff --git a/using/configure.po b/using/configure.po index 8825de6039b..531b4dca110 100644 --- a/using/configure.po +++ b/using/configure.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-05 15:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -600,60 +600,98 @@ msgid "``no``: configure does not use :program:`pkg-config` even when present" msgstr "``no``:即使存在也不使用 :program:`pkg-config` 來配置" #: ../../using/configure.rst:334 +msgid "" +"Path to a `JSON `_ configuration file " +"containing custom error messages for missing :term:`standard library` " +"modules." +msgstr "" + +#: ../../using/configure.rst:337 +msgid "" +"This option is intended for Python distributors who wish to provide " +"distribution-specific guidance when users encounter standard library modules " +"that are missing or packaged separately." +msgstr "" + +#: ../../using/configure.rst:341 +msgid "" +"The JSON file should map missing module names to custom error message " +"strings. For example, if your distribution packages :mod:`tkinter` and :mod:" +"`_tkinter` separately and excludes :mod:`!_gdbm` for legal reasons, the " +"configuration could contain:" +msgstr "" + +#: ../../using/configure.rst:346 +msgid "" +"{\n" +" \"_gdbm\": \"The '_gdbm' module is not available in this " +"distribution\",\n" +" \"tkinter\": \"Install the python-tk package to use tkinter\",\n" +" \"_tkinter\": \"Install the python-tk package to use tkinter\",\n" +"}" +msgstr "" +"{\n" +" \"_gdbm\": \"The '_gdbm' module is not available in this " +"distribution\",\n" +" \"tkinter\": \"Install the python-tk package to use tkinter\",\n" +" \"_tkinter\": \"Install the python-tk package to use tkinter\",\n" +"}" + +#: ../../using/configure.rst:358 msgid "Turn on internal Python performance statistics gathering." msgstr "" -#: ../../using/configure.rst:336 +#: ../../using/configure.rst:360 msgid "" "By default, statistics gathering is off. Use ``python3 -X pystats`` command " "or set ``PYTHONSTATS=1`` environment variable to turn on statistics " "gathering at Python startup." msgstr "" -#: ../../using/configure.rst:340 +#: ../../using/configure.rst:364 msgid "" "At Python exit, dump statistics if statistics gathering was on and not " "cleared." msgstr "" -#: ../../using/configure.rst:343 ../../using/configure.rst:867 +#: ../../using/configure.rst:367 ../../using/configure.rst:962 msgid "Effects:" msgstr "效果:" -#: ../../using/configure.rst:345 +#: ../../using/configure.rst:369 msgid "Add :option:`-X pystats <-X>` command line option." msgstr "新增 :option:`-X pystats <-X>` 命令列選項。" -#: ../../using/configure.rst:346 +#: ../../using/configure.rst:370 msgid "Add :envvar:`!PYTHONSTATS` environment variable." msgstr "新增 :envvar:`!PYTHONSTATS` 環境變數。" -#: ../../using/configure.rst:347 +#: ../../using/configure.rst:371 msgid "Define the ``Py_STATS`` macro." msgstr "定義 ``Py_STATS`` 巨集。" -#: ../../using/configure.rst:348 +#: ../../using/configure.rst:372 msgid "Add functions to the :mod:`sys` module:" msgstr "新增函式到 :mod:`sys` 模組。" -#: ../../using/configure.rst:350 +#: ../../using/configure.rst:374 msgid ":func:`!sys._stats_on`: Turns on statistics gathering." msgstr ":func:`!sys._stats_on`:啟用統計資料收集。" -#: ../../using/configure.rst:351 +#: ../../using/configure.rst:375 msgid ":func:`!sys._stats_off`: Turns off statistics gathering." msgstr ":func:`!sys._stats_off`:關閉統計資料收集。" -#: ../../using/configure.rst:352 +#: ../../using/configure.rst:376 msgid ":func:`!sys._stats_clear`: Clears the statistics." msgstr ":func:`!sys._stats_clear`:清除統計資料。" -#: ../../using/configure.rst:353 +#: ../../using/configure.rst:377 msgid "" ":func:`!sys._stats_dump`: Dump statistics to file, and clears the statistics." msgstr ":func:`!sys._stats_dump`:將統計資料轉儲到檔案,並清除統計資料。" -#: ../../using/configure.rst:355 +#: ../../using/configure.rst:379 msgid "" "The statistics will be dumped to a arbitrary (probably unique) file in ``/" "tmp/py_stats/`` (Unix) or ``C:\\temp\\py_stats\\`` (Windows). If that " @@ -663,162 +701,162 @@ msgstr "" "(Windows) 中的任意(可能是唯一的)檔案。如果該目錄不存在,結果將被列印到 " "stderr。" -#: ../../using/configure.rst:359 +#: ../../using/configure.rst:383 msgid "Use ``Tools/scripts/summarize_stats.py`` to read the stats." msgstr "使用 ``Tools/scripts/summarize_stats.py`` 來讀取統計資料。" -#: ../../using/configure.rst:361 +#: ../../using/configure.rst:385 msgid "Statistics:" msgstr "" -#: ../../using/configure.rst:363 +#: ../../using/configure.rst:387 msgid "Opcode:" msgstr "" -#: ../../using/configure.rst:365 +#: ../../using/configure.rst:389 msgid "Specialization: success, failure, hit, deferred, miss, deopt, failures;" msgstr "" -#: ../../using/configure.rst:366 +#: ../../using/configure.rst:390 msgid "Execution count;" msgstr "" -#: ../../using/configure.rst:367 +#: ../../using/configure.rst:391 msgid "Pair count." msgstr "" -#: ../../using/configure.rst:369 +#: ../../using/configure.rst:393 msgid "Call:" msgstr "" -#: ../../using/configure.rst:371 +#: ../../using/configure.rst:395 msgid "Inlined Python calls;" msgstr "" -#: ../../using/configure.rst:372 +#: ../../using/configure.rst:396 msgid "PyEval calls;" msgstr "" -#: ../../using/configure.rst:373 +#: ../../using/configure.rst:397 msgid "Frames pushed;" msgstr "" -#: ../../using/configure.rst:374 +#: ../../using/configure.rst:398 msgid "Frame object created;" msgstr "" -#: ../../using/configure.rst:375 +#: ../../using/configure.rst:399 msgid "" "Eval calls: vector, generator, legacy, function VECTORCALL, build class, " "slot, function \"ex\", API, method." msgstr "" -#: ../../using/configure.rst:378 +#: ../../using/configure.rst:402 msgid "Object:" msgstr "物件:" -#: ../../using/configure.rst:380 +#: ../../using/configure.rst:404 msgid "incref and decref;" msgstr "" -#: ../../using/configure.rst:381 +#: ../../using/configure.rst:405 msgid "interpreter incref and decref;" msgstr "" -#: ../../using/configure.rst:382 +#: ../../using/configure.rst:406 msgid "allocations: all, 512 bytes, 4 kiB, big;" msgstr "" -#: ../../using/configure.rst:383 +#: ../../using/configure.rst:407 msgid "free;" msgstr "" -#: ../../using/configure.rst:384 +#: ../../using/configure.rst:408 msgid "to/from free lists;" msgstr "" -#: ../../using/configure.rst:385 +#: ../../using/configure.rst:409 msgid "dictionary materialized/dematerialized;" msgstr "" -#: ../../using/configure.rst:386 +#: ../../using/configure.rst:410 msgid "type cache;" msgstr "" -#: ../../using/configure.rst:387 +#: ../../using/configure.rst:411 msgid "optimization attempts;" msgstr "最佳化嘗試;" -#: ../../using/configure.rst:388 +#: ../../using/configure.rst:412 msgid "optimization traces created/executed;" msgstr "" -#: ../../using/configure.rst:389 +#: ../../using/configure.rst:413 msgid "uops executed." msgstr "" -#: ../../using/configure.rst:391 +#: ../../using/configure.rst:415 msgid "Garbage collector:" msgstr "垃圾回收器:" -#: ../../using/configure.rst:393 +#: ../../using/configure.rst:417 msgid "Garbage collections;" msgstr "垃圾回收;" -#: ../../using/configure.rst:394 +#: ../../using/configure.rst:418 msgid "Objects visited;" msgstr "" -#: ../../using/configure.rst:395 +#: ../../using/configure.rst:419 msgid "Objects collected." msgstr "" -#: ../../using/configure.rst:403 +#: ../../using/configure.rst:430 msgid "" "Enables support for running Python without the :term:`global interpreter " "lock` (GIL): :term:`free-threaded build`." msgstr "" -#: ../../using/configure.rst:406 +#: ../../using/configure.rst:433 msgid "" "Defines the ``Py_GIL_DISABLED`` macro and adds ``\"t\"`` to :data:`sys." "abiflags`." msgstr "" -#: ../../using/configure.rst:409 +#: ../../using/configure.rst:436 msgid "See :ref:`whatsnew313-free-threaded-cpython` for more detail." msgstr "細節請參見 :ref:`whatsnew313-free-threaded-cpython`。" -#: ../../using/configure.rst:415 +#: ../../using/configure.rst:442 msgid "" "Indicate how to integrate the :ref:`experimental just-in-time compiler " "`." msgstr "" -#: ../../using/configure.rst:417 +#: ../../using/configure.rst:444 msgid "``no``: Don't build the JIT." msgstr "" -#: ../../using/configure.rst:418 +#: ../../using/configure.rst:445 msgid "" "``yes``: Enable the JIT. To disable it at runtime, set the environment " "variable :envvar:`PYTHON_JIT=0 `." msgstr "" -#: ../../using/configure.rst:420 +#: ../../using/configure.rst:447 msgid "" "``yes-off``: Build the JIT, but disable it by default. To enable it at " "runtime, set the environment variable :envvar:`PYTHON_JIT=1 `." msgstr "" -#: ../../using/configure.rst:422 +#: ../../using/configure.rst:449 msgid "" "``interpreter``: Enable the \"JIT interpreter\" (only useful for those " "debugging the JIT itself). To disable it at runtime, set the environment " "variable :envvar:`PYTHON_JIT=0 `." msgstr "" -#: ../../using/configure.rst:426 +#: ../../using/configure.rst:453 msgid "" "``--enable-experimental-jit=no`` is the default behavior if the option is " "not provided, and ``--enable-experimental-jit`` is shorthand for ``--enable-" @@ -826,209 +864,218 @@ msgid "" "information, including how to install the necessary build-time dependencies." msgstr "" -#: ../../using/configure.rst:433 +#: ../../using/configure.rst:460 msgid "" "When building CPython with JIT enabled, ensure that your system has Python " "3.11 or later installed." msgstr "" -#: ../../using/configure.rst:439 +#: ../../using/configure.rst:466 msgid "Path to ``pkg-config`` utility." msgstr "" -#: ../../using/configure.rst:444 +#: ../../using/configure.rst:471 msgid "``pkg-config`` options." msgstr "``pkg-config`` 選項。" -#: ../../using/configure.rst:448 +#: ../../using/configure.rst:475 +msgid "" +"Build without ``epoll``, meaning that :py:func:`select.epoll` will not be " +"present even if the system provides an :manpage:`epoll_create " +"` function. This may be used on systems where :manpage:`!" +"epoll_create` or :manpage:`epoll_create1 ` is available " +"but incompatible with Linux semantics." +msgstr "" + +#: ../../using/configure.rst:486 msgid "C compiler options" msgstr "C 編譯器選項。" -#: ../../using/configure.rst:452 ../../using/configure.rst:1448 +#: ../../using/configure.rst:490 ../../using/configure.rst:1558 msgid "C compiler command." msgstr "C 編譯器指令。" -#: ../../using/configure.rst:456 ../../using/configure.rst:1460 +#: ../../using/configure.rst:494 ../../using/configure.rst:1570 msgid "C compiler flags." msgstr "C 編譯器旗標。" -#: ../../using/configure.rst:460 +#: ../../using/configure.rst:498 msgid "C preprocessor command." msgstr "C 預處理器指令。" -#: ../../using/configure.rst:464 +#: ../../using/configure.rst:502 msgid "C preprocessor flags, e.g. :samp:`-I{include_dir}`." msgstr "C 預處理器旗標,例如::samp:`-I{include_dir}`。" -#: ../../using/configure.rst:468 ../../using/configure.rst:945 +#: ../../using/configure.rst:506 ../../using/configure.rst:1040 msgid "Linker options" msgstr "" -#: ../../using/configure.rst:472 +#: ../../using/configure.rst:510 msgid "Linker flags, e.g. :samp:`-L{library_directory}`." msgstr "" -#: ../../using/configure.rst:476 +#: ../../using/configure.rst:514 msgid "Libraries to pass to the linker, e.g. :samp:`-l{library}`." msgstr "" -#: ../../using/configure.rst:480 +#: ../../using/configure.rst:518 msgid "Name for machine-dependent library files." msgstr "" -#: ../../using/configure.rst:486 +#: ../../using/configure.rst:524 msgid "Options for third-party dependencies" msgstr "" -#: ../../using/configure.rst:493 +#: ../../using/configure.rst:531 msgid "" "C compiler and linker flags to link Python to ``libbz2``, used by :mod:`bz2` " "module, overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:499 +#: ../../using/configure.rst:537 msgid "" "C compiler and linker flags for ``libncurses`` or ``libncursesw``, used by :" "mod:`curses` module, overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:505 +#: ../../using/configure.rst:543 msgid "C compiler and linker flags for ``gdbm``." msgstr "" -#: ../../using/configure.rst:510 +#: ../../using/configure.rst:548 msgid "" "C compiler and linker flags for ``libedit``, used by :mod:`readline` module, " "overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:516 +#: ../../using/configure.rst:554 msgid "" "C compiler and linker flags for ``libffi``, used by :mod:`ctypes` module, " "overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:522 +#: ../../using/configure.rst:560 msgid "" "C compiler and linker flags for ``libmpdec``, used by :mod:`decimal` module, " "overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:527 +#: ../../using/configure.rst:565 msgid "" "These environment variables have no effect unless :option:`--with-system-" "libmpdec` is specified." msgstr "" -#: ../../using/configure.rst:533 +#: ../../using/configure.rst:571 msgid "" "C compiler and linker flags for ``liblzma``, used by :mod:`lzma` module, " "overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:539 +#: ../../using/configure.rst:577 msgid "" "C compiler and linker flags for ``libreadline``, used by :mod:`readline` " "module, overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:545 +#: ../../using/configure.rst:583 msgid "" "C compiler and linker flags for ``libsqlite3``, used by :mod:`sqlite3` " "module, overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:551 +#: ../../using/configure.rst:589 msgid "" "C compiler and linker flags for ``libuuid``, used by :mod:`uuid` module, " "overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:557 +#: ../../using/configure.rst:595 msgid "" "C compiler and linker flags for ``libzstd``, used by :mod:`compression.zstd` " "module, overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:565 +#: ../../using/configure.rst:603 msgid "C compiler and linker flags for PANEL, overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:567 +#: ../../using/configure.rst:605 msgid "" "C compiler and linker flags for ``libpanel`` or ``libpanelw``, used by :mod:" "`curses.panel` module, overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:573 +#: ../../using/configure.rst:611 msgid "C compiler and linker flags for TCLTK, overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:578 +#: ../../using/configure.rst:616 msgid "" "C compiler and linker flags for ``libzlib``, used by :mod:`gzip` module, " "overriding ``pkg-config``." msgstr "" -#: ../../using/configure.rst:583 +#: ../../using/configure.rst:621 msgid "WebAssembly Options" msgstr "WebAssembly 選項" -#: ../../using/configure.rst:587 +#: ../../using/configure.rst:625 msgid "Turn on dynamic linking support for WASM." msgstr "" -#: ../../using/configure.rst:589 +#: ../../using/configure.rst:627 msgid "" "Dynamic linking enables ``dlopen``. File size of the executable increases " "due to limited dead code elimination and additional features." msgstr "" -#: ../../using/configure.rst:596 +#: ../../using/configure.rst:634 msgid "Turn on pthreads support for WASM." msgstr "" -#: ../../using/configure.rst:602 +#: ../../using/configure.rst:640 msgid "Install Options" msgstr "安裝選項" -#: ../../using/configure.rst:606 +#: ../../using/configure.rst:644 msgid "" "Install architecture-independent files in PREFIX. On Unix, it defaults to :" "file:`/usr/local`." msgstr "" -#: ../../using/configure.rst:609 +#: ../../using/configure.rst:647 msgid "This value can be retrieved at runtime using :data:`sys.prefix`." msgstr "這個值可以在 runtime 使用 :data:`sys.prefix` 取得。" -#: ../../using/configure.rst:611 +#: ../../using/configure.rst:649 msgid "" "As an example, one can use ``--prefix=\"$HOME/.local/\"`` to install a " "Python in its home directory." msgstr "" -#: ../../using/configure.rst:616 +#: ../../using/configure.rst:654 msgid "" "Install architecture-dependent files in EPREFIX, defaults to :option:`--" "prefix`." msgstr "" -#: ../../using/configure.rst:618 +#: ../../using/configure.rst:656 msgid "This value can be retrieved at runtime using :data:`sys.exec_prefix`." msgstr "這個值可以在 runtime 使用 :data:`sys.exec_prefix` 取得" -#: ../../using/configure.rst:622 +#: ../../using/configure.rst:660 msgid "" "Don't build nor install test modules, like the :mod:`test` package or the :" "mod:`!_testcapi` extension module (built and installed by default)." msgstr "" -#: ../../using/configure.rst:629 +#: ../../using/configure.rst:667 msgid "Select the :mod:`ensurepip` command run on Python installation:" msgstr "選擇在 Python 安裝時執行的 :mod:`ensurepip` 命令:" -#: ../../using/configure.rst:631 +#: ../../using/configure.rst:669 msgid "" "``upgrade`` (default): run ``python -m ensurepip --altinstall --upgrade`` " "command." @@ -1036,45 +1083,45 @@ msgstr "" "``upgrade`` (預設):執行 ``python -m ensurepip --altinstall --upgrade`` 命" "令。" -#: ../../using/configure.rst:633 +#: ../../using/configure.rst:671 msgid "``install``: run ``python -m ensurepip --altinstall`` command;" msgstr "``install``:執行 ``python -m ensurepip --altinstall`` 命令;" -#: ../../using/configure.rst:634 +#: ../../using/configure.rst:672 msgid "``no``: don't run ensurepip;" msgstr "``no``:不要執行 ensurepip;" -#: ../../using/configure.rst:640 +#: ../../using/configure.rst:678 msgid "Performance options" msgstr "效能選項" -#: ../../using/configure.rst:642 +#: ../../using/configure.rst:680 msgid "" "Configuring Python using ``--enable-optimizations --with-lto`` (PGO + LTO) " "is recommended for best performance. The experimental ``--enable-bolt`` flag " "can also be used to improve performance." msgstr "" -#: ../../using/configure.rst:648 +#: ../../using/configure.rst:686 msgid "" "Enable Profile Guided Optimization (PGO) using :envvar:`PROFILE_TASK` " "(disabled by default)." msgstr "" -#: ../../using/configure.rst:651 +#: ../../using/configure.rst:689 msgid "" "The C compiler Clang requires ``llvm-profdata`` program for PGO. On macOS, " "GCC also requires it: GCC is just an alias to Clang on macOS." msgstr "" -#: ../../using/configure.rst:654 +#: ../../using/configure.rst:692 msgid "" "Disable also semantic interposition in libpython if ``--enable-shared`` and " "GCC is used: add ``-fno-semantic-interposition`` to the compiler and linker " "flags." msgstr "" -#: ../../using/configure.rst:660 +#: ../../using/configure.rst:698 msgid "" "During the build, you may encounter compiler warnings about profile data not " "being available for some source files. These warnings are harmless, as only " @@ -1083,58 +1130,58 @@ msgid "" "profile-instr-unprofiled`` to :envvar:`CFLAGS`." msgstr "" -#: ../../using/configure.rst:669 +#: ../../using/configure.rst:707 msgid "Use ``-fno-semantic-interposition`` on GCC." msgstr "在 GCC 上使用 ``-fno-semantic-interposition``。" -#: ../../using/configure.rst:674 +#: ../../using/configure.rst:712 msgid "" "Environment variable used in the Makefile: Python command line arguments for " "the PGO generation task." msgstr "" -#: ../../using/configure.rst:677 +#: ../../using/configure.rst:715 msgid "Default: ``-m test --pgo --timeout=$(TESTTIMEOUT)``." msgstr "預設值:``-m test --pgo --timeout=$(TESTTIMEOUT)``。" -#: ../../using/configure.rst:681 +#: ../../using/configure.rst:719 msgid "Task failure is no longer ignored silently." msgstr "" -#: ../../using/configure.rst:686 +#: ../../using/configure.rst:724 msgid "Enable Link Time Optimization (LTO) in any build (disabled by default)." msgstr "" -#: ../../using/configure.rst:688 +#: ../../using/configure.rst:726 msgid "" "The C compiler Clang requires ``llvm-ar`` for LTO (``ar`` on macOS), as well " "as an LTO-aware linker (``ld.gold`` or ``lld``)." msgstr "" -#: ../../using/configure.rst:693 +#: ../../using/configure.rst:731 msgid "To use ThinLTO feature, use ``--with-lto=thin`` on Clang." msgstr "" -#: ../../using/configure.rst:696 +#: ../../using/configure.rst:734 msgid "" "Use ThinLTO as the default optimization policy on Clang if the compiler " "accepts the flag." msgstr "" -#: ../../using/configure.rst:701 +#: ../../using/configure.rst:739 msgid "" "Enable usage of the `BOLT post-link binary optimizer `_ (disabled by default)." msgstr "" -#: ../../using/configure.rst:705 +#: ../../using/configure.rst:743 msgid "" "BOLT is part of the LLVM project but is not always included in their binary " "distributions. This flag requires that ``llvm-bolt`` and ``merge-fdata`` are " "available." msgstr "" -#: ../../using/configure.rst:709 +#: ../../using/configure.rst:747 msgid "" "BOLT is still a fairly new project so this flag should be considered " "experimental for now. Because this tool operates on machine code its success " @@ -1145,7 +1192,7 @@ msgid "" "encouraged." msgstr "" -#: ../../using/configure.rst:717 +#: ../../using/configure.rst:755 msgid "" "The :envvar:`!BOLT_INSTRUMENT_FLAGS` and :envvar:`!BOLT_APPLY_FLAGS` :" "program:`configure` variables can be defined to override the default set of " @@ -1153,23 +1200,23 @@ msgid "" "binaries, respectively." msgstr "" -#: ../../using/configure.rst:726 +#: ../../using/configure.rst:764 msgid "" "Arguments to ``llvm-bolt`` when creating a `BOLT optimized binary `_." msgstr "" -#: ../../using/configure.rst:733 +#: ../../using/configure.rst:771 msgid "Arguments to ``llvm-bolt`` when instrumenting binaries." msgstr "" -#: ../../using/configure.rst:739 +#: ../../using/configure.rst:777 msgid "" "Enable computed gotos in evaluation loop (enabled by default on supported " "compilers)." msgstr "" -#: ../../using/configure.rst:744 +#: ../../using/configure.rst:782 msgid "" "Enable interpreters using tail calls in CPython. If enabled, enabling PGO (:" "option:`--enable-optimizations`) is highly recommended. This option " @@ -1179,52 +1226,144 @@ msgid "" "feature." msgstr "" -#: ../../using/configure.rst:754 +#: ../../using/configure.rst:792 +msgid "Disable frame pointers, which are enabled by default (see :pep:`831`)." +msgstr "" + +#: ../../using/configure.rst:794 +msgid "" +"By default, the build appends flags to generate frame or backchain pointers " +"to ``BASECFLAGS``:" +msgstr "" + +#: ../../using/configure.rst:797 +msgid "" +"``-fno-omit-frame-pointer`` and/or ``-mno-omit-leaf-frame-pointer`` are " +"added when the compiler supports them." +msgstr "" + +#: ../../using/configure.rst:799 +msgid "``-marm`` and/or ``-mno-thumb`` is added on 32-bit ARM when supported," +msgstr "" + +#: ../../using/configure.rst:800 +msgid "" +"on s390x platforms, when supported, ``-mbackchain`` is added *instead*. of " +"the above frame pointer flags." +msgstr "" + +#: ../../using/configure.rst:802 +msgid "" +"on ppc64le platforms, no compiler flags is needed since the power ABI " +"requires that compilers maintain a back chain by default." +msgstr "" + +#: ../../using/configure.rst:805 +msgid "" +"Frame pointers enable profilers, debuggers, and system tracing tools " +"(``perf``, ``eBPF``, ``dtrace``, ``gdb``) to walk the C call stack without " +"DWARF metadata. The flags propagate to third-party C extensions through :mod:" +"`sysconfig`. On compilers that do not understand them, the build silently " +"skips them." +msgstr "" + +#: ../../using/configure.rst:811 +msgid "" +"Downstream packagers and authors of native libraries built with custom build " +"systems should set the same flags so the unwind chain stays unbroken across " +"all native frames." +msgstr "" + +#: ../../using/configure.rst:819 msgid "" "Disable the fast :ref:`mimalloc ` allocator (enabled by default)." msgstr "" -#: ../../using/configure.rst:757 +#: ../../using/configure.rst:822 msgid "" "This option cannot be used together with :option:`--disable-gil` because " "the :term:`free-threaded ` build requires mimalloc." msgstr "" -#: ../../using/configure.rst:760 ../../using/configure.rst:767 +#: ../../using/configure.rst:825 ../../using/configure.rst:832 msgid "See also :envvar:`PYTHONMALLOC` environment variable." msgstr "另請參閱 :envvar:`PYTHONMALLOC` 環境變數。" -#: ../../using/configure.rst:764 +#: ../../using/configure.rst:829 msgid "" "Disable the specialized Python memory allocator :ref:`pymalloc ` " "(enabled by default)." msgstr "" -#: ../../using/configure.rst:771 +#: ../../using/configure.rst:836 +msgid "" +"Enable huge page support for :ref:`pymalloc ` arenas (disabled by " +"default). When enabled, the arena size on 64-bit platforms is increased to 2 " +"MiB and arena allocation uses ``MAP_HUGETLB`` (Linux) or ``MEM_LARGE_PAGES`` " +"(Windows) with automatic fallback to regular pages." +msgstr "" + +#: ../../using/configure.rst:841 +msgid "" +"Even when compiled with this option, huge pages are **not** used at runtime " +"unless the :envvar:`PYTHON_PYMALLOC_HUGEPAGES` environment variable is set " +"to ``1``. This opt-in is required because huge pages" +msgstr "" + +#: ../../using/configure.rst:845 +msgid "" +"carry risks on Linux: if the huge-page pool is exhausted, page faults " +"(including copy-on-write faults after :func:`os.fork`) deliver ``SIGBUS`` " +"and kill the process." +msgstr "" + +#: ../../using/configure.rst:849 +msgid "" +"need a special privilege on Windows. See the `Windows documentation for " +"large pages `_ for details. Python will fail on startup if the required " +"privilege `SeLockMemoryPrivilege `_ is not held by the user." +msgstr "" + +#: ../../using/configure.rst:856 +msgid "" +"The configure script checks that the platform supports ``MAP_HUGETLB`` and " +"emits a warning if it is not available." +msgstr "" + +#: ../../using/configure.rst:859 +msgid "" +"On Windows, use the ``--pymalloc-hugepages`` flag with ``build.bat`` or set " +"the ``UsePymallocHugepages`` MSBuild property." +msgstr "" + +#: ../../using/configure.rst:866 msgid "" "Disable static documentation strings to reduce the memory footprint (enabled " "by default). Documentation strings defined in Python are not affected." msgstr "" -#: ../../using/configure.rst:774 +#: ../../using/configure.rst:869 msgid "Don't define the ``WITH_DOC_STRINGS`` macro." msgstr "不要定義 ``WITH_DOC_STRINGS`` 巨集。" -#: ../../using/configure.rst:776 +#: ../../using/configure.rst:871 msgid "See the ``PyDoc_STRVAR()`` macro." msgstr "請見 ``PyDoc_STRVAR()`` 巨集。" -#: ../../using/configure.rst:780 +#: ../../using/configure.rst:875 msgid "Enable C-level code profiling with ``gprof`` (disabled by default)." msgstr "" -#: ../../using/configure.rst:784 +#: ../../using/configure.rst:879 msgid "" "Add ``-fstrict-overflow`` to the C compiler flags (by default we add ``-fno-" "strict-overflow`` instead)." msgstr "" -#: ../../using/configure.rst:789 +#: ../../using/configure.rst:884 msgid "" "Deactivate remote debugging support described in :pep:`768` (enabled by " "default). When this flag is provided the code that allows the interpreter to " @@ -1234,73 +1373,73 @@ msgid "" "executed." msgstr "" -#: ../../using/configure.rst:797 +#: ../../using/configure.rst:892 msgid "" "This macro is defined by default, unless Python is configured with :option:" "`--without-remote-debug`." msgstr "" -#: ../../using/configure.rst:800 +#: ../../using/configure.rst:895 msgid "" "Note that even if the macro is defined, remote debugging may not be " "available (for example, on an incompatible platform)." msgstr "" -#: ../../using/configure.rst:809 +#: ../../using/configure.rst:904 msgid "Python Debug Build" msgstr "" -#: ../../using/configure.rst:811 +#: ../../using/configure.rst:906 msgid "" "A debug build is Python built with the :option:`--with-pydebug` configure " "option." msgstr "" -#: ../../using/configure.rst:814 +#: ../../using/configure.rst:909 msgid "Effects of a debug build:" msgstr "" -#: ../../using/configure.rst:816 +#: ../../using/configure.rst:911 msgid "" "Display all warnings by default: the list of default warning filters is " "empty in the :mod:`warnings` module." msgstr "" -#: ../../using/configure.rst:818 +#: ../../using/configure.rst:913 msgid "Add ``d`` to :data:`sys.abiflags`." msgstr "新增 ``d`` 到 :data:`sys.abiflags`。" -#: ../../using/configure.rst:819 +#: ../../using/configure.rst:914 msgid "Add :func:`!sys.gettotalrefcount` function." msgstr "新增 :func:`!sys.gettotalrefcount` 函式。" -#: ../../using/configure.rst:820 +#: ../../using/configure.rst:915 msgid "Add :option:`-X showrefcount <-X>` command line option." msgstr "新增 :option:`-X showrefcount <-X>` 命令列選項。" -#: ../../using/configure.rst:821 +#: ../../using/configure.rst:916 msgid "" "Add :option:`-d` command line option and :envvar:`PYTHONDEBUG` environment " "variable to debug the parser." msgstr "" -#: ../../using/configure.rst:823 +#: ../../using/configure.rst:918 msgid "" "Add support for the ``__lltrace__`` variable: enable low-level tracing in " "the bytecode evaluation loop if the variable is defined." msgstr "" -#: ../../using/configure.rst:825 +#: ../../using/configure.rst:920 msgid "" "Install :ref:`debug hooks on memory allocators ` " "to detect buffer overflow and other memory errors." msgstr "" -#: ../../using/configure.rst:827 +#: ../../using/configure.rst:922 msgid "Define ``Py_DEBUG`` and ``Py_REF_DEBUG`` macros." msgstr "定義 ``Py_DEBUG`` 和 ``Py_REF_DEBUG`` 巨集。" -#: ../../using/configure.rst:828 +#: ../../using/configure.rst:923 msgid "" "Add runtime checks: code surrounded by ``#ifdef Py_DEBUG`` and ``#endif``. " "Enable ``assert(...)`` and ``_PyObject_ASSERT(...)`` assertions: don't set " @@ -1308,45 +1447,45 @@ msgid "" "option). Main runtime checks:" msgstr "" -#: ../../using/configure.rst:833 +#: ../../using/configure.rst:928 msgid "Add sanity checks on the function arguments." msgstr "" -#: ../../using/configure.rst:834 +#: ../../using/configure.rst:929 msgid "" "Unicode and int objects are created with their memory filled with a pattern " "to detect usage of uninitialized objects." msgstr "" -#: ../../using/configure.rst:836 +#: ../../using/configure.rst:931 msgid "" "Ensure that functions which can clear or replace the current exception are " "not called with an exception raised." msgstr "" -#: ../../using/configure.rst:838 +#: ../../using/configure.rst:933 msgid "Check that deallocator functions don't change the current exception." msgstr "" -#: ../../using/configure.rst:839 +#: ../../using/configure.rst:934 msgid "" "The garbage collector (:func:`gc.collect` function) runs some basic checks " "on objects consistency." msgstr "" -#: ../../using/configure.rst:841 +#: ../../using/configure.rst:936 msgid "" "The :c:macro:`!Py_SAFE_DOWNCAST()` macro checks for integer underflow and " "overflow when downcasting from wide types to narrow types." msgstr "" -#: ../../using/configure.rst:844 +#: ../../using/configure.rst:939 msgid "" "See also the :ref:`Python Development Mode ` and the :option:`--" "with-trace-refs` configure option." msgstr "" -#: ../../using/configure.rst:847 +#: ../../using/configure.rst:942 msgid "" "Release builds are now ABI compatible with debug builds: defining the " "``Py_DEBUG`` macro no longer implies the ``Py_TRACE_REFS`` macro (see the :" @@ -1355,11 +1494,11 @@ msgid "" "necessarily compatible with a release build." msgstr "" -#: ../../using/configure.rst:856 +#: ../../using/configure.rst:951 msgid "Debug options" msgstr "偵錯選項" -#: ../../using/configure.rst:860 +#: ../../using/configure.rst:955 msgid "" ":ref:`Build Python in debug mode `: define the ``Py_DEBUG`` " "macro (disabled by default)." @@ -1367,23 +1506,23 @@ msgstr "" ":ref:`以偵錯模式建置 Python `:定義 ``Py_DEBUG`` 巨集(預設不啟" "用)。" -#: ../../using/configure.rst:865 +#: ../../using/configure.rst:960 msgid "Enable tracing references for debugging purpose (disabled by default)." msgstr "以偵錯為目的啟用參照追蹤(預設不啟用)。" -#: ../../using/configure.rst:869 +#: ../../using/configure.rst:964 msgid "Define the ``Py_TRACE_REFS`` macro." msgstr "定義 ``Py_TRACE_REFS`` 巨集。" -#: ../../using/configure.rst:870 +#: ../../using/configure.rst:965 msgid "Add :func:`sys.getobjects` function." msgstr "新增 :func:`sys.getobjects` 函式。" -#: ../../using/configure.rst:871 +#: ../../using/configure.rst:966 msgid "Add :envvar:`PYTHONDUMPREFS` environment variable." msgstr "新增 :envvar:`PYTHONDUMPREFS` 環境變數。" -#: ../../using/configure.rst:873 +#: ../../using/configure.rst:968 msgid "" "The :envvar:`PYTHONDUMPREFS` environment variable can be used to dump " "objects and reference counts still alive at Python exit." @@ -1391,11 +1530,11 @@ msgstr "" ":envvar:`PYTHONDUMPREFS` 環境變數可以用來在 Python 結束時轉儲仍然有效的物件和" "參照計數。" -#: ../../using/configure.rst:876 +#: ../../using/configure.rst:971 msgid ":ref:`Statically allocated objects ` are not traced." msgstr "不追蹤\\ :ref:`靜態配置的物件 `。" -#: ../../using/configure.rst:880 +#: ../../using/configure.rst:975 msgid "" "This build is now ABI compatible with release build and :ref:`debug build " "`." @@ -1403,7 +1542,7 @@ msgstr "" "這個建置現在與發佈版本建置和\\ :ref:`偵錯建置 `\\ 具有 ABI 相容" "性。" -#: ../../using/configure.rst:886 +#: ../../using/configure.rst:981 msgid "" "Build with C assertions enabled (default is no): ``assert(...);`` and " "``_PyObject_ASSERT(...);``." @@ -1411,13 +1550,13 @@ msgstr "" "啟用 C 斷言建置(預設不啟用):``assert(...);`` 和 ``_PyObject_ASSERT(...);" "``。" -#: ../../using/configure.rst:889 +#: ../../using/configure.rst:984 msgid "" "If set, the ``NDEBUG`` macro is not defined in the :envvar:`OPT` compiler " "variable." msgstr "如果設定,``NDEBUG`` 巨集不會在 :envvar:`OPT` 編譯器變數中定義。" -#: ../../using/configure.rst:892 +#: ../../using/configure.rst:987 msgid "" "See also the :option:`--with-pydebug` option (:ref:`debug build `) which also enables assertions." @@ -1425,21 +1564,21 @@ msgstr "" "另請參閱 :option:`--with-pydebug` 選項(:ref:`debug build `)," "它也啟用了斷言。" -#: ../../using/configure.rst:899 +#: ../../using/configure.rst:994 msgid "Enable Valgrind support (default is no)." msgstr "啟用 Valgrind 支援(預設不啟用)。" -#: ../../using/configure.rst:903 +#: ../../using/configure.rst:998 msgid "Enable DTrace support (default is no)." msgstr "啟用 DTrace 支援(預設不啟用)。" -#: ../../using/configure.rst:905 +#: ../../using/configure.rst:1000 msgid "" "See :ref:`Instrumenting CPython with DTrace and SystemTap `." msgstr "" "請參閱\\ :ref:`使用 DTrace 和 SystemTap 檢測 CPython `。" -#: ../../using/configure.rst:912 +#: ../../using/configure.rst:1007 msgid "" "Enable AddressSanitizer memory error detector, ``asan`` (default is no). To " "improve ASan detection capabilities you may also want to combine this with :" @@ -1447,34 +1586,34 @@ msgid "" "allocator whose allocations are not tracked by ASan." msgstr "" -#: ../../using/configure.rst:921 +#: ../../using/configure.rst:1016 msgid "" "Enable MemorySanitizer allocation error detector, ``msan`` (default is no)." msgstr "啟用 MemorySanitizer 分配錯誤偵測器 ``msan``\\ (預設不啟用)。" -#: ../../using/configure.rst:923 +#: ../../using/configure.rst:1018 msgid "" "MSan reports false positives for memory initialized by libraries that are " "not built with MSan, so either build all dependencies with MSan or disable " "the extension modules that use them in :file:`Modules/Setup.local`." msgstr "" -#: ../../using/configure.rst:931 +#: ../../using/configure.rst:1026 msgid "" "Enable UndefinedBehaviorSanitizer undefined behaviour detector, ``ubsan`` " "(default is no)." msgstr "" "啟用 UndefinedBehaviorSanitizer 未定義行為偵測器 ``ubsan``\\ (預設不啟用)。" -#: ../../using/configure.rst:938 +#: ../../using/configure.rst:1033 msgid "Enable ThreadSanitizer data race detector, ``tsan`` (default is no)." msgstr "啟用 ThreadSanitizer 資料競爭偵測器 ``tsan``\\ (預設不啟用)。" -#: ../../using/configure.rst:949 +#: ../../using/configure.rst:1044 msgid "Enable building a shared Python library: ``libpython`` (default is no)." msgstr "啟用建置共享 Python 函式庫:``libpython``\\ (預設不啟用)。" -#: ../../using/configure.rst:953 +#: ../../using/configure.rst:1048 msgid "" "Do not build ``libpythonMAJOR.MINOR.a`` and do not install ``python.o`` " "(built and enabled by default)." @@ -1482,21 +1621,39 @@ msgstr "" "不要建置 ``libpythonMAJOR.MINOR.a`` 並且不要安裝 ``python.o``\\ (預設會建置" "並啟用)。" -#: ../../using/configure.rst:960 +#: ../../using/configure.rst:1055 +msgid "" +"Do not link the Python interpreter binary (``python3``) against the shared " +"Python library; instead, statically link the interpreter against " +"``libpython`` as if ``--enable-shared`` had not been used, but continue to " +"build the shared ``libpython`` (for use by other programs)." +msgstr "" + +#: ../../using/configure.rst:1061 +msgid "This option does nothing if ``--enable-shared`` is not used." +msgstr "" + +#: ../../using/configure.rst:1063 +msgid "" +"The default (when ``-enable-shared`` is used) is to link the Python " +"interpreter against the built shared library." +msgstr "" + +#: ../../using/configure.rst:1070 msgid "Libraries options" msgstr "函式庫選項" -#: ../../using/configure.rst:964 +#: ../../using/configure.rst:1074 msgid "Link against additional libraries (default is no)." msgstr "" -#: ../../using/configure.rst:968 +#: ../../using/configure.rst:1078 msgid "" "Build the :mod:`!pyexpat` module using an installed ``expat`` library " "(default is no)." msgstr "使用已安裝的 ``expat`` 函式庫建置 :mod:`!pyexpat` 模組(預設不建置)。" -#: ../../using/configure.rst:973 +#: ../../using/configure.rst:1083 msgid "" "Build the ``_decimal`` extension module using an installed ``mpdecimal`` " "library, see the :mod:`decimal` module (default is yes)." @@ -1504,11 +1661,11 @@ msgstr "" "使用已安裝的 ``mpdecimal`` 函式庫建置 ``_decimal`` 擴充模組,請參閱 :mod:" "`decimal` 模組(預設建置)。" -#: ../../using/configure.rst:978 +#: ../../using/configure.rst:1088 msgid "Default to using the installed ``mpdecimal`` library." msgstr "預設使用已安裝的 ``mpdecimal`` 函式庫。" -#: ../../using/configure.rst:983 +#: ../../using/configure.rst:1093 msgid "" "A bundled copy of the library will no longer be selected implicitly if an " "installed ``mpdecimal`` library is not found. In Python 3.15 only, it can " @@ -1516,145 +1673,145 @@ msgid "" "without-system-libmpdec``." msgstr "" -#: ../../using/configure.rst:988 +#: ../../using/configure.rst:1098 msgid "" "A copy of the ``mpdecimal`` library sources will no longer be distributed " "with Python 3.16." msgstr "Python 3.16 不再隨附 ``mpdecimal`` 函式庫的原始碼副本。" -#: ../../using/configure.rst:992 +#: ../../using/configure.rst:1102 msgid ":option:`LIBMPDEC_CFLAGS` and :option:`LIBMPDEC_LIBS`." msgstr ":option:`LIBMPDEC_CFLAGS` 和 :option:`LIBMPDEC_LIBS`。" -#: ../../using/configure.rst:996 +#: ../../using/configure.rst:1106 msgid "Designate a backend library for the :mod:`readline` module." msgstr "" -#: ../../using/configure.rst:998 +#: ../../using/configure.rst:1108 msgid "readline: Use readline as the backend." msgstr "" -#: ../../using/configure.rst:999 +#: ../../using/configure.rst:1109 msgid "editline: Use editline as the backend." msgstr "" -#: ../../using/configure.rst:1005 +#: ../../using/configure.rst:1115 msgid "Don't build the :mod:`readline` module (built by default)." msgstr "不要建置 :mod:`readline` 模組(預設會建置)。" -#: ../../using/configure.rst:1007 +#: ../../using/configure.rst:1117 msgid "Don't define the ``HAVE_LIBREADLINE`` macro." msgstr "不要定義 ``HAVE_LIBREADLINE`` 巨集。" -#: ../../using/configure.rst:1013 +#: ../../using/configure.rst:1123 msgid "" "Override ``libm`` math library to *STRING* (default is system-dependent)." msgstr "" -#: ../../using/configure.rst:1017 +#: ../../using/configure.rst:1127 msgid "Override ``libc`` C library to *STRING* (default is system-dependent)." msgstr "" -#: ../../using/configure.rst:1021 +#: ../../using/configure.rst:1131 msgid "Root of the OpenSSL directory." msgstr "OpenSSL 目錄的根目錄。" -#: ../../using/configure.rst:1027 +#: ../../using/configure.rst:1137 msgid "Set runtime library directory (rpath) for OpenSSL libraries:" msgstr "" -#: ../../using/configure.rst:1029 +#: ../../using/configure.rst:1139 msgid "``no`` (default): don't set rpath;" msgstr "" -#: ../../using/configure.rst:1030 +#: ../../using/configure.rst:1140 msgid "" "``auto``: auto-detect rpath from :option:`--with-openssl` and ``pkg-config``;" msgstr "" -#: ../../using/configure.rst:1032 +#: ../../using/configure.rst:1142 msgid "*DIR*: set an explicit rpath." msgstr "" -#: ../../using/configure.rst:1038 +#: ../../using/configure.rst:1148 msgid "Security Options" msgstr "安全性選項" -#: ../../using/configure.rst:1042 +#: ../../using/configure.rst:1152 msgid "Select hash algorithm for use in ``Python/pyhash.c``:" msgstr "" -#: ../../using/configure.rst:1044 +#: ../../using/configure.rst:1154 msgid "``siphash13`` (default);" msgstr "``siphash13``\\ (預設);" -#: ../../using/configure.rst:1045 +#: ../../using/configure.rst:1155 msgid "``siphash24``;" msgstr "``siphash24``;" -#: ../../using/configure.rst:1046 +#: ../../using/configure.rst:1156 msgid "``fnv``." msgstr "``fnv``。" -#: ../../using/configure.rst:1050 +#: ../../using/configure.rst:1160 msgid "``siphash13`` is added and it is the new default." msgstr "" -#: ../../using/configure.rst:1055 +#: ../../using/configure.rst:1165 msgid "Built-in hash modules:" msgstr "內建雜湊模組:" -#: ../../using/configure.rst:1057 +#: ../../using/configure.rst:1167 msgid "``md5``;" msgstr "``md5``;" -#: ../../using/configure.rst:1058 +#: ../../using/configure.rst:1168 msgid "``sha1``;" msgstr "``sha1``;" -#: ../../using/configure.rst:1059 +#: ../../using/configure.rst:1169 msgid "``sha256``;" msgstr "``sha256``;" -#: ../../using/configure.rst:1060 +#: ../../using/configure.rst:1170 msgid "``sha512``;" msgstr "``sha512``;" -#: ../../using/configure.rst:1061 +#: ../../using/configure.rst:1171 msgid "``sha3`` (with shake);" msgstr "" -#: ../../using/configure.rst:1062 +#: ../../using/configure.rst:1172 msgid "``blake2``." msgstr "``blake2``。" -#: ../../using/configure.rst:1068 +#: ../../using/configure.rst:1178 msgid "Override the OpenSSL default cipher suites string:" msgstr "" -#: ../../using/configure.rst:1070 +#: ../../using/configure.rst:1180 msgid "``python`` (default): use Python's preferred selection;" msgstr "" -#: ../../using/configure.rst:1071 +#: ../../using/configure.rst:1181 msgid "``openssl``: leave OpenSSL's defaults untouched;" msgstr "" -#: ../../using/configure.rst:1072 +#: ../../using/configure.rst:1182 msgid "*STRING*: use a custom string" msgstr "" -#: ../../using/configure.rst:1074 +#: ../../using/configure.rst:1184 msgid "See the :mod:`ssl` module." msgstr "請見 :mod:`ssl` 模組。" -#: ../../using/configure.rst:1080 +#: ../../using/configure.rst:1190 msgid "" "The settings ``python`` and *STRING* also set TLS 1.2 as minimum protocol " "version." msgstr "" -#: ../../using/configure.rst:1085 +#: ../../using/configure.rst:1195 msgid "" "Disable compiler options that are `recommended by OpenSSF`_ for security " "reasons with no performance overhead. If this option is not enabled, CPython " @@ -1663,24 +1820,24 @@ msgid "" "listed below." msgstr "" -#: ../../using/configure.rst:1089 +#: ../../using/configure.rst:1199 msgid "" "The following compiler options are disabled with :option:`!--disable-safety`:" msgstr "" -#: ../../using/configure.rst:1091 +#: ../../using/configure.rst:1201 msgid "" "`-fstack-protector-strong`_: Enable run-time checks for stack-based buffer " "overflows." msgstr "" -#: ../../using/configure.rst:1092 +#: ../../using/configure.rst:1202 msgid "" "`-Wtrampolines`_: Enable warnings about trampolines that require executable " "stacks." msgstr "" -#: ../../using/configure.rst:1102 +#: ../../using/configure.rst:1212 msgid "" "Enable compiler options that are `recommended by OpenSSF`_ for security " "reasons which require overhead. If this option is not enabled, CPython will " @@ -1689,81 +1846,81 @@ msgid "" "listed below." msgstr "" -#: ../../using/configure.rst:1106 +#: ../../using/configure.rst:1216 msgid "" "The following compiler options are enabled with :option:`!--enable-slower-" "safety`:" msgstr "" -#: ../../using/configure.rst:1108 +#: ../../using/configure.rst:1218 msgid "" "`-D_FORTIFY_SOURCE=3`_: Fortify sources with compile- and run-time checks " "for unsafe libc usage and buffer overflows." msgstr "" -#: ../../using/configure.rst:1116 +#: ../../using/configure.rst:1226 msgid "macOS Options" msgstr "macOS 選項" -#: ../../using/configure.rst:1118 +#: ../../using/configure.rst:1228 msgid "See :source:`Mac/README.rst`." msgstr "參閱 :source:`Mac/README.rst`。" -#: ../../using/configure.rst:1123 +#: ../../using/configure.rst:1233 msgid "" "Create a universal binary build. *SDKDIR* specifies which macOS SDK should " "be used to perform the build (default is no)." msgstr "" -#: ../../using/configure.rst:1129 +#: ../../using/configure.rst:1239 msgid "" "Create a Python.framework rather than a traditional Unix install. Optional " "*INSTALLDIR* specifies the installation path (default is no)." msgstr "" -#: ../../using/configure.rst:1134 +#: ../../using/configure.rst:1244 msgid "" "Specify the kind of universal binary that should be created. This option is " "only valid when :option:`--enable-universalsdk` is set." msgstr "" -#: ../../using/configure.rst:1137 +#: ../../using/configure.rst:1247 msgid "Options:" msgstr "選項:" -#: ../../using/configure.rst:1139 +#: ../../using/configure.rst:1249 msgid "``universal2`` (x86-64 and arm64);" msgstr "``universal2``\\ (x86-64 與 arm64);" -#: ../../using/configure.rst:1140 +#: ../../using/configure.rst:1250 msgid "``32-bit`` (PPC and i386);" msgstr "``32-bit``\\ (PPC 與 i386);" -#: ../../using/configure.rst:1141 +#: ../../using/configure.rst:1251 msgid "``64-bit`` (PPC64 and x86-64);" msgstr "``64-bit``\\ (PPC64 與 x86-64);" -#: ../../using/configure.rst:1142 +#: ../../using/configure.rst:1252 msgid "``3-way`` (i386, PPC and x86-64);" msgstr "``3-way``\\ (i386、PPC 與 x86-64);" -#: ../../using/configure.rst:1143 +#: ../../using/configure.rst:1253 msgid "``intel`` (i386 and x86-64);" msgstr "``intel``\\ (i386 與 x86-64);" -#: ../../using/configure.rst:1144 +#: ../../using/configure.rst:1254 msgid "``intel-32`` (i386);" msgstr "``intel-32``\\ (i386);" -#: ../../using/configure.rst:1145 +#: ../../using/configure.rst:1255 msgid "``intel-64`` (x86-64);" msgstr "``intel-64``\\ (x86-64);" -#: ../../using/configure.rst:1146 +#: ../../using/configure.rst:1256 msgid "``all`` (PPC, i386, PPC64 and x86-64)." msgstr "``all``\\ (PPC、i386、PPC64 與 x86-64)。" -#: ../../using/configure.rst:1148 +#: ../../using/configure.rst:1258 msgid "" "Note that values for this configuration item are *not* the same as the " "identifiers used for universal binary wheels on macOS. See the Python " @@ -1772,13 +1929,13 @@ msgid "" "platform-compatibility-tags/#macos>`_" msgstr "" -#: ../../using/configure.rst:1156 +#: ../../using/configure.rst:1266 msgid "" "Specify the name for the python framework on macOS only valid when :option:" "`--enable-framework` is set (default: ``Python``)." msgstr "" -#: ../../using/configure.rst:1162 +#: ../../using/configure.rst:1272 msgid "" "The Python standard library contains strings that are known to trigger " "automated inspection tool errors when submitted for distribution by the " @@ -1787,29 +1944,29 @@ msgid "" "can also be specified. This option is disabled by default." msgstr "" -#: ../../using/configure.rst:1171 +#: ../../using/configure.rst:1281 msgid "iOS Options" msgstr "iOS 選項" -#: ../../using/configure.rst:1173 -msgid "See :source:`iOS/README.rst`." -msgstr "參閱 :source:`iOS/README.rst`。" +#: ../../using/configure.rst:1283 +msgid "See :source:`Platforms/Apple/iOS/README.md`." +msgstr "參閱 :source:`Platforms/Apple/iOS/README.md`。" -#: ../../using/configure.rst:1177 +#: ../../using/configure.rst:1287 msgid "" "Create a Python.framework. Unlike macOS, the *INSTALLDIR* argument " "specifying the installation path is mandatory." msgstr "" -#: ../../using/configure.rst:1182 +#: ../../using/configure.rst:1292 msgid "Specify the name for the framework (default: ``Python``)." msgstr "指定框架的名稱(預設值:``Python``)。" -#: ../../using/configure.rst:1186 +#: ../../using/configure.rst:1296 msgid "Cross Compiling Options" msgstr "" -#: ../../using/configure.rst:1188 +#: ../../using/configure.rst:1298 msgid "" "Cross compiling, also known as cross building, can be used to build Python " "for another CPU architecture or platform. Cross compiling requires a Python " @@ -1817,28 +1974,28 @@ msgid "" "match the version of the cross compiled host Python." msgstr "" -#: ../../using/configure.rst:1195 +#: ../../using/configure.rst:1305 msgid "" "configure for building on BUILD, usually guessed by :program:`config.guess`." msgstr "" -#: ../../using/configure.rst:1199 +#: ../../using/configure.rst:1309 msgid "cross-compile to build programs to run on HOST (target platform)" msgstr "" -#: ../../using/configure.rst:1203 +#: ../../using/configure.rst:1313 msgid "path to build ``python`` binary for cross compiling" msgstr "" -#: ../../using/configure.rst:1209 +#: ../../using/configure.rst:1319 msgid "An environment variable that points to a file with configure overrides." msgstr "" -#: ../../using/configure.rst:1211 +#: ../../using/configure.rst:1321 msgid "Example *config.site* file:" msgstr "範例 *config.site* 檔案:" -#: ../../using/configure.rst:1213 +#: ../../using/configure.rst:1323 msgid "" "# config.site-aarch64\n" "ac_cv_buggy_getaddrinfo=no\n" @@ -1850,15 +2007,15 @@ msgstr "" "ac_cv_file__dev_ptmx=yes\n" "ac_cv_file__dev_ptc=no" -#: ../../using/configure.rst:1222 +#: ../../using/configure.rst:1332 msgid "Program to run CPython for the host platform for cross-compilation." msgstr "" -#: ../../using/configure.rst:1227 +#: ../../using/configure.rst:1337 msgid "Cross compiling example::" msgstr "" -#: ../../using/configure.rst:1229 +#: ../../using/configure.rst:1339 msgid "" "CONFIG_SITE=config.site-aarch64 ../configure \\\n" " --build=x86_64-pc-linux-gnu \\\n" @@ -1870,65 +2027,65 @@ msgstr "" " --host=aarch64-unknown-linux-gnu \\\n" " --with-build-python=../x86_64/python" -#: ../../using/configure.rst:1236 +#: ../../using/configure.rst:1346 msgid "Python Build System" msgstr "Python 建置系統" -#: ../../using/configure.rst:1239 +#: ../../using/configure.rst:1349 msgid "Main files of the build system" msgstr "建置系統的主要檔案" -#: ../../using/configure.rst:1241 +#: ../../using/configure.rst:1351 msgid ":file:`configure.ac` => :file:`configure`;" msgstr ":file:`configure.ac` => :file:`configure`;" -#: ../../using/configure.rst:1242 +#: ../../using/configure.rst:1352 msgid "" ":file:`Makefile.pre.in` => :file:`Makefile` (created by :file:`configure`);" msgstr "" ":file:`Makefile.pre.in` => :file:`Makefile`\\ (由 :file:`configure` 建立);" -#: ../../using/configure.rst:1243 +#: ../../using/configure.rst:1353 msgid ":file:`pyconfig.h` (created by :file:`configure`);" msgstr ":file:`pyconfig.h`\\ (由 :file:`configure` 建立);" -#: ../../using/configure.rst:1244 +#: ../../using/configure.rst:1354 msgid "" ":file:`Modules/Setup`: C extensions built by the Makefile using :file:" "`Module/makesetup` shell script;" msgstr "" -#: ../../using/configure.rst:1248 +#: ../../using/configure.rst:1358 msgid "Main build steps" msgstr "主要建置步驟" -#: ../../using/configure.rst:1250 +#: ../../using/configure.rst:1360 msgid "C files (``.c``) are built as object files (``.o``)." msgstr "C 檔案(``.c``)被建置為目的檔(``.o``)。" -#: ../../using/configure.rst:1251 +#: ../../using/configure.rst:1361 msgid "A static ``libpython`` library (``.a``) is created from objects files." msgstr "" -#: ../../using/configure.rst:1252 +#: ../../using/configure.rst:1362 msgid "" "``python.o`` and the static ``libpython`` library are linked into the final " "``python`` program." msgstr "" -#: ../../using/configure.rst:1254 +#: ../../using/configure.rst:1364 msgid "C extensions are built by the Makefile (see :file:`Modules/Setup`)." msgstr "" -#: ../../using/configure.rst:1257 +#: ../../using/configure.rst:1367 msgid "Main Makefile targets" msgstr "主要 Makefile 目標" -#: ../../using/configure.rst:1260 +#: ../../using/configure.rst:1370 msgid "make" msgstr "make" -#: ../../using/configure.rst:1262 +#: ../../using/configure.rst:1372 msgid "" "For the most part, when rebuilding after editing some code or refreshing " "your checkout from upstream, all you need to do is execute ``make``, which " @@ -1939,22 +2096,22 @@ msgid "" "all`` will build. The three choices are:" msgstr "" -#: ../../using/configure.rst:1271 +#: ../../using/configure.rst:1381 msgid "``profile-opt`` (configured with ``--enable-optimizations``)" msgstr "``profile-opt``\\ (使用 ``--enable-optimizations`` 配置)" -#: ../../using/configure.rst:1272 +#: ../../using/configure.rst:1382 msgid "" "``build_wasm`` (chosen if the host platform matches ``wasm32-wasi*`` or " "``wasm32-emscripten``)" msgstr "" -#: ../../using/configure.rst:1274 +#: ../../using/configure.rst:1384 msgid "" "``build_all`` (configured without explicitly using either of the others)" msgstr "``build_all``\\ (未明確使用其他選項進行配置)" -#: ../../using/configure.rst:1276 +#: ../../using/configure.rst:1386 msgid "" "Depending on the most recent source file changes, Make will rebuild any " "targets (object files and executables) deemed out-of-date, including running " @@ -1967,11 +2124,11 @@ msgid "" "problems, at the expense of longer build times." msgstr "" -#: ../../using/configure.rst:1289 +#: ../../using/configure.rst:1399 msgid "make platform" msgstr "make platform" -#: ../../using/configure.rst:1291 +#: ../../using/configure.rst:1401 msgid "" "Build the ``python`` program, but don't build the standard library extension " "modules. This generates a file named ``platform`` which contains a single " @@ -1979,91 +2136,91 @@ msgid "" "arm64-3.12`` or ``linux-x86_64-3.13``." msgstr "" -#: ../../using/configure.rst:1298 +#: ../../using/configure.rst:1408 msgid "make profile-opt" msgstr "make profile-opt" -#: ../../using/configure.rst:1300 +#: ../../using/configure.rst:1410 msgid "" "Build Python using profile-guided optimization (PGO). You can use the " "configure :option:`--enable-optimizations` option to make this the default " "target of the ``make`` command (``make all`` or just ``make``)." msgstr "" -#: ../../using/configure.rst:1308 +#: ../../using/configure.rst:1418 msgid "make clean" msgstr "make clean" -#: ../../using/configure.rst:1310 +#: ../../using/configure.rst:1420 msgid "Remove built files." msgstr "移除建置的檔案。" -#: ../../using/configure.rst:1314 +#: ../../using/configure.rst:1424 msgid "make distclean" msgstr "make distclean" -#: ../../using/configure.rst:1316 +#: ../../using/configure.rst:1426 msgid "" "In addition to the work done by ``make clean``, remove files created by the " "configure script. ``configure`` will have to be run before building again. " "[#]_" msgstr "" -#: ../../using/configure.rst:1322 +#: ../../using/configure.rst:1432 msgid "make install" msgstr "make install" -#: ../../using/configure.rst:1324 +#: ../../using/configure.rst:1434 msgid "Build the ``all`` target and install Python." msgstr "建置 ``all`` 目標並安裝 Python。" -#: ../../using/configure.rst:1328 +#: ../../using/configure.rst:1438 msgid "make test" msgstr "make test" -#: ../../using/configure.rst:1330 +#: ../../using/configure.rst:1440 msgid "" "Build the ``all`` target and run the Python test suite with the ``--fast-" "ci`` option without GUI tests. Variables:" msgstr "" -#: ../../using/configure.rst:1333 +#: ../../using/configure.rst:1443 msgid "``TESTOPTS``: additional regrtest command-line options." msgstr "``TESTOPTS``:額外的 regrtest 命令列選項。" -#: ../../using/configure.rst:1334 +#: ../../using/configure.rst:1444 msgid "``TESTPYTHONOPTS``: additional Python command-line options." msgstr "``TESTPYTHONOPTS``:額外的 Python 命令列選項。" -#: ../../using/configure.rst:1335 +#: ../../using/configure.rst:1445 msgid "``TESTTIMEOUT``: timeout in seconds (default: 10 minutes)." msgstr "``TESTTIMEOUT``:秒數表示的超時設定(預設值:10 分鐘)。" -#: ../../using/configure.rst:1339 +#: ../../using/configure.rst:1449 msgid "make ci" msgstr "make ci" -#: ../../using/configure.rst:1341 +#: ../../using/configure.rst:1451 msgid "" "This is similar to ``make test``, but uses the ``-ugui`` to also run GUI " "tests." msgstr "" -#: ../../using/configure.rst:1347 +#: ../../using/configure.rst:1457 msgid "make buildbottest" msgstr "make buildbottest" -#: ../../using/configure.rst:1349 +#: ../../using/configure.rst:1459 msgid "" "This is similar to ``make test``, but uses the ``--slow-ci`` option and " "default timeout of 20 minutes, instead of ``--fast-ci`` option." msgstr "" -#: ../../using/configure.rst:1354 +#: ../../using/configure.rst:1464 msgid "make regen-all" msgstr "make regen-all" -#: ../../using/configure.rst:1356 +#: ../../using/configure.rst:1466 msgid "" "Regenerate (almost) all generated files. These include (but are not limited " "to) bytecode cases, and parser generator file. ``make regen-stdlib-module-" @@ -2071,18 +2228,18 @@ msgid "" "files <#generated-files>`_." msgstr "" -#: ../../using/configure.rst:1363 +#: ../../using/configure.rst:1473 msgid "C extensions" msgstr "C 擴充模組" -#: ../../using/configure.rst:1365 +#: ../../using/configure.rst:1475 msgid "" "Some C extensions are built as built-in modules, like the ``sys`` module. " "They are built with the ``Py_BUILD_CORE_BUILTIN`` macro defined. Built-in " "modules have no ``__file__`` attribute:" msgstr "" -#: ../../using/configure.rst:1369 +#: ../../using/configure.rst:1479 msgid "" ">>> import sys\n" ">>> sys\n" @@ -2100,14 +2257,14 @@ msgstr "" " File \"\", line 1, in \n" "AttributeError: module 'sys' has no attribute '__file__'" -#: ../../using/configure.rst:1379 +#: ../../using/configure.rst:1489 msgid "" "Other C extensions are built as dynamic libraries, like the ``_asyncio`` " "module. They are built with the ``Py_BUILD_CORE_MODULE`` macro defined. " "Example on Linux x86-64:" msgstr "" -#: ../../using/configure.rst:1383 +#: ../../using/configure.rst:1493 msgid "" ">>> import _asyncio\n" ">>> _asyncio\n" @@ -2123,7 +2280,7 @@ msgstr "" ">>> _asyncio.__file__\n" "'/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'" -#: ../../using/configure.rst:1391 +#: ../../using/configure.rst:1501 msgid "" ":file:`Modules/Setup` is used to generate Makefile targets to build C " "extensions. At the beginning of the files, C extensions are built as built-" @@ -2131,168 +2288,168 @@ msgid "" "dynamic libraries." msgstr "" -#: ../../using/configure.rst:1395 +#: ../../using/configure.rst:1505 msgid "" "The :c:macro:`!PyAPI_FUNC()`, :c:macro:`!PyAPI_DATA()` and :c:macro:" "`PyMODINIT_FUNC` macros of :file:`Include/exports.h` are defined differently " "depending if the ``Py_BUILD_CORE_MODULE`` macro is defined:" msgstr "" -#: ../../using/configure.rst:1399 +#: ../../using/configure.rst:1509 msgid "Use ``Py_EXPORTED_SYMBOL`` if the ``Py_BUILD_CORE_MODULE`` is defined" msgstr "如果定義了 ``Py_BUILD_CORE_MODULE``,則使用 ``Py_EXPORTED_SYMBOL``" -#: ../../using/configure.rst:1400 +#: ../../using/configure.rst:1510 msgid "Use ``Py_IMPORTED_SYMBOL`` otherwise." msgstr "否則使用 ``Py_IMPORTED_SYMBOL``。" -#: ../../using/configure.rst:1402 +#: ../../using/configure.rst:1512 msgid "" "If the ``Py_BUILD_CORE_BUILTIN`` macro is used by mistake on a C extension " "built as a shared library, its :samp:`PyInit_{xxx}()` function is not " "exported, causing an :exc:`ImportError` on import." msgstr "" -#: ../../using/configure.rst:1408 +#: ../../using/configure.rst:1518 msgid "Compiler and linker flags" msgstr "" -#: ../../using/configure.rst:1410 +#: ../../using/configure.rst:1520 msgid "" "Options set by the ``./configure`` script and environment variables and used " "by ``Makefile``." msgstr "" -#: ../../using/configure.rst:1414 +#: ../../using/configure.rst:1524 msgid "Preprocessor flags" msgstr "預處理器旗標" -#: ../../using/configure.rst:1418 +#: ../../using/configure.rst:1528 msgid "" "Value of :envvar:`CPPFLAGS` variable passed to the ``./configure`` script." msgstr "" -#: ../../using/configure.rst:1424 +#: ../../using/configure.rst:1534 msgid "" "(Objective) C/C++ preprocessor flags, e.g. :samp:`-I{include_dir}` if you " "have headers in a nonstandard directory *include_dir*." msgstr "" -#: ../../using/configure.rst:1427 ../../using/configure.rst:1623 +#: ../../using/configure.rst:1537 ../../using/configure.rst:1733 msgid "" "Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's " "value to be able to build extension modules using the directories specified " "in the environment variables." msgstr "" -#: ../../using/configure.rst:1437 +#: ../../using/configure.rst:1547 msgid "" "Extra preprocessor flags added for building the interpreter object files." msgstr "" -#: ../../using/configure.rst:1439 +#: ../../using/configure.rst:1549 msgid "" "Default: ``$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) " "$(CPPFLAGS)``." msgstr "" -#: ../../using/configure.rst:1444 +#: ../../using/configure.rst:1554 msgid "Compiler flags" msgstr "編譯器旗標" -#: ../../using/configure.rst:1450 +#: ../../using/configure.rst:1560 msgid "Example: ``gcc -pthread``." msgstr "範例:``gcc -pthread``。" -#: ../../using/configure.rst:1454 +#: ../../using/configure.rst:1564 msgid "C++ compiler command." msgstr "C++ 編譯器指令。" -#: ../../using/configure.rst:1456 +#: ../../using/configure.rst:1566 msgid "Example: ``g++ -pthread``." msgstr "範例:``g++ -pthread``。" -#: ../../using/configure.rst:1464 +#: ../../using/configure.rst:1574 msgid "" ":envvar:`CFLAGS_NODIST` is used for building the interpreter and stdlib C " "extensions. Use it when a compiler flag should *not* be part of :envvar:" "`CFLAGS` once Python is installed (:gh:`65320`)." msgstr "" -#: ../../using/configure.rst:1468 +#: ../../using/configure.rst:1578 msgid "In particular, :envvar:`CFLAGS` should not contain:" msgstr "" -#: ../../using/configure.rst:1470 +#: ../../using/configure.rst:1580 msgid "" "the compiler flag ``-I`` (for setting the search path for include files). " "The ``-I`` flags are processed from left to right, and any flags in :envvar:" "`CFLAGS` would take precedence over user- and package-supplied ``-I`` flags." msgstr "" -#: ../../using/configure.rst:1475 +#: ../../using/configure.rst:1585 msgid "" "hardening flags such as ``-Werror`` because distributions cannot control " "whether packages installed by users conform to such heightened standards." msgstr "" -#: ../../using/configure.rst:1483 +#: ../../using/configure.rst:1593 msgid "" "Options passed to the :mod:`compileall` command line when building PYC files " "in ``make install``. Default: ``-j0``." msgstr "" -#: ../../using/configure.rst:1490 +#: ../../using/configure.rst:1600 msgid "Extra C compiler flags." msgstr "額外的 C 編譯器旗標。" -#: ../../using/configure.rst:1494 +#: ../../using/configure.rst:1604 msgid "" "Value of :envvar:`CFLAGS` variable passed to the ``./configure`` script." msgstr "" -#: ../../using/configure.rst:1501 +#: ../../using/configure.rst:1611 msgid "" "Value of :envvar:`CFLAGS_NODIST` variable passed to the ``./configure`` " "script." msgstr "" -#: ../../using/configure.rst:1508 +#: ../../using/configure.rst:1618 msgid "Base compiler flags." msgstr "基本編譯器旗標。" -#: ../../using/configure.rst:1512 +#: ../../using/configure.rst:1622 msgid "Optimization flags." msgstr "最佳化旗標。" -#: ../../using/configure.rst:1516 +#: ../../using/configure.rst:1626 msgid "Strict or non-strict aliasing flags used to compile ``Python/dtoa.c``." msgstr "" -#: ../../using/configure.rst:1522 +#: ../../using/configure.rst:1632 msgid "Flags used to compile ``Python/ceval.c``." msgstr "" -#: ../../using/configure.rst:1528 +#: ../../using/configure.rst:1638 msgid "Compiler flags used to build a shared library." msgstr "用於建置共享函式庫的編譯器旗標。" -#: ../../using/configure.rst:1530 +#: ../../using/configure.rst:1640 msgid "For example, ``-fPIC`` is used on Linux and on BSD." msgstr "例如說 ``-fPIC`` 被使用於 Linux 與 BSD 上。" -#: ../../using/configure.rst:1534 +#: ../../using/configure.rst:1644 msgid "Extra C flags added for building the interpreter object files." msgstr "用於建置直譯器目的檔的額外 C 旗標。" -#: ../../using/configure.rst:1536 +#: ../../using/configure.rst:1646 msgid "" "Default: ``$(CCSHARED)`` when :option:`--enable-shared` is used, or an empty " "string otherwise." msgstr "" "預設值:當使用 :option:`--enable-shared` 時為 ``$(CCSHARED)``,否則為空字串。" -#: ../../using/configure.rst:1541 +#: ../../using/configure.rst:1651 msgid "" "Default: ``$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) " "$(EXTRA_CFLAGS)``." @@ -2300,7 +2457,7 @@ msgstr "" "預設值:``$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) " "$(EXTRA_CFLAGS)``。" -#: ../../using/configure.rst:1545 +#: ../../using/configure.rst:1655 msgid "" "Default: ``$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/" "internal``." @@ -2308,11 +2465,11 @@ msgstr "" "預設值:``$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/" "internal``。" -#: ../../using/configure.rst:1551 +#: ../../using/configure.rst:1661 msgid "C flags used for building the interpreter object files." msgstr "用於建置直譯器目的檔的 C 旗標。" -#: ../../using/configure.rst:1553 +#: ../../using/configure.rst:1663 msgid "" "Default: ``$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) " "$(CFLAGSFORSHARED)``." @@ -2320,126 +2477,152 @@ msgstr "" "預設值:``$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) " "$(CFLAGSFORSHARED)``。" -#: ../../using/configure.rst:1559 +#: ../../using/configure.rst:1669 msgid "Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE``." msgstr "預設值:``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE``。" -#: ../../using/configure.rst:1565 +#: ../../using/configure.rst:1675 msgid "" "Compiler flags to build a standard library extension module as a built-in " "module, like the :mod:`posix` module." msgstr "" -#: ../../using/configure.rst:1568 +#: ../../using/configure.rst:1678 msgid "Default: ``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN``." msgstr "預設值:``$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN``。" -#: ../../using/configure.rst:1574 +#: ../../using/configure.rst:1684 msgid "Purify command. Purify is a memory debugger program." msgstr "" -#: ../../using/configure.rst:1576 +#: ../../using/configure.rst:1686 msgid "Default: empty string (not used)." msgstr "預設值:空字串(未使用)。" -#: ../../using/configure.rst:1580 +#: ../../using/configure.rst:1690 msgid "Linker flags" msgstr "" -#: ../../using/configure.rst:1584 +#: ../../using/configure.rst:1694 msgid "" "Linker command used to build programs like ``python`` and ``_testembed``." msgstr "" -#: ../../using/configure.rst:1586 +#: ../../using/configure.rst:1696 msgid "Default: ``$(PURIFY) $(CC)``." msgstr "預設值:``$(PURIFY) $(CC)``。" -#: ../../using/configure.rst:1590 +#: ../../using/configure.rst:1700 msgid "" "Value of :envvar:`LDFLAGS` variable passed to the ``./configure`` script." msgstr "" -#: ../../using/configure.rst:1592 +#: ../../using/configure.rst:1702 msgid "" "Avoid assigning :envvar:`CFLAGS`, :envvar:`LDFLAGS`, etc. so users can use " "them on the command line to append to these values without stomping the pre-" "set values." msgstr "" -#: ../../using/configure.rst:1600 +#: ../../using/configure.rst:1710 msgid "" ":envvar:`LDFLAGS_NODIST` is used in the same manner as :envvar:" "`CFLAGS_NODIST`. Use it when a linker flag should *not* be part of :envvar:" "`LDFLAGS` once Python is installed (:gh:`65320`)." msgstr "" -#: ../../using/configure.rst:1604 +#: ../../using/configure.rst:1714 msgid "In particular, :envvar:`LDFLAGS` should not contain:" msgstr "" -#: ../../using/configure.rst:1606 +#: ../../using/configure.rst:1716 msgid "" "the compiler flag ``-L`` (for setting the search path for libraries). The ``-" "L`` flags are processed from left to right, and any flags in :envvar:" "`LDFLAGS` would take precedence over user- and package-supplied ``-L`` flags." msgstr "" -#: ../../using/configure.rst:1613 +#: ../../using/configure.rst:1723 msgid "" "Value of :envvar:`LDFLAGS_NODIST` variable passed to the ``./configure`` " "script." msgstr "" -#: ../../using/configure.rst:1620 +#: ../../using/configure.rst:1730 msgid "" "Linker flags, e.g. :samp:`-L{lib_dir}` if you have libraries in a " "nonstandard directory *lib_dir*." msgstr "" -#: ../../using/configure.rst:1629 +#: ../../using/configure.rst:1737 +msgid "" +"Please consider using ``EXE_LDFLAGS`` if the supplied linker flags are " +"executable specific, e.g. GCC's ``-pie`` flag." +msgstr "" + +#: ../../using/configure.rst:1742 msgid "" "Linker flags to pass libraries to the linker when linking the Python " "executable." msgstr "" -#: ../../using/configure.rst:1632 +#: ../../using/configure.rst:1745 msgid "Example: ``-lrt``." msgstr "範例:``-lrt``。" -#: ../../using/configure.rst:1636 +#: ../../using/configure.rst:1749 msgid "Command to build a shared library." msgstr "建置共享函式庫的指令。" -#: ../../using/configure.rst:1638 +#: ../../using/configure.rst:1751 msgid "Default: ``@LDSHARED@ $(PY_LDFLAGS)``." msgstr "預設值:``@LDSHARED@ $(PY_LDFLAGS)``。" -#: ../../using/configure.rst:1642 +#: ../../using/configure.rst:1755 msgid "Command to build ``libpython`` shared library." msgstr "建置 ``libpython`` 共享函式庫的指令。" -#: ../../using/configure.rst:1644 +#: ../../using/configure.rst:1757 msgid "Default: ``@BLDSHARED@ $(PY_CORE_LDFLAGS)``." msgstr "預設值:``@BLDSHARED@ $(PY_CORE_LDFLAGS)``。" -#: ../../using/configure.rst:1648 +#: ../../using/configure.rst:1761 msgid "Default: ``$(CONFIGURE_LDFLAGS) $(LDFLAGS)``." msgstr "預設值:``$(CONFIGURE_LDFLAGS) $(LDFLAGS)``。" -#: ../../using/configure.rst:1652 +#: ../../using/configure.rst:1765 msgid "Default: ``$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)``." msgstr "預設值:``$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)``。" -#: ../../using/configure.rst:1658 +#: ../../using/configure.rst:1771 msgid "Linker flags used for building the interpreter object files." msgstr "" -#: ../../using/configure.rst:1664 +#: ../../using/configure.rst:1777 +msgid "" +"Linker flags used for building executable targets such as the interpreter. " +"If supplied, :envvar:`PY_CORE_EXE_LDFLAGS` will be used in replacement of :" +"envvar:`PY_CORE_LDFLAGS`." +msgstr "" + +#: ../../using/configure.rst:1785 +msgid "" +"Value of :envvar:`EXE_LDFLAGS` variable passed to the ``./configure`` script." +msgstr "" + +#: ../../using/configure.rst:1792 +msgid "Linker flags used for building the interpreter and executable targets." +msgstr "用於建置直譯器和可執行目標的連結器旗標。" + +#: ../../using/configure.rst:1795 +msgid "Default: ``$(PY_CORE_LDFLAGS)``" +msgstr "預設值:``$(PY_CORE_LDFLAGS)``" + +#: ../../using/configure.rst:1801 msgid "Footnotes" msgstr "註腳" -#: ../../using/configure.rst:1665 +#: ../../using/configure.rst:1802 msgid "" "``git clean -fdx`` is an even more extreme way to \"clean\" your checkout. " "It removes all files not known to Git. When bug hunting using ``git " diff --git a/using/ios.po b/using/ios.po index c5f7590976d..6d7c6a21f7a 100644 --- a/using/ios.po +++ b/using/ios.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-10-02 00:13+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -271,10 +271,10 @@ msgstr "" #: ../../using/ios.rst:172 msgid "" "Build or obtain a Python ``XCFramework``. See the instructions in :source:" -"`Apple/iOS/README.md` (in the CPython source distribution) for details on " -"how to build a Python ``XCFramework``. At a minimum, you will need a build " -"that supports ``arm64-apple-ios``, plus one of either ``arm64-apple-ios-" -"simulator`` or ``x86_64-apple-ios-simulator``." +"`Platforms/Apple/iOS/README.md` (in the CPython source distribution) for " +"details on how to build a Python ``XCFramework``. At a minimum, you will " +"need a build that supports ``arm64-apple-ios``, plus one of either ``arm64-" +"apple-ios-simulator`` or ``x86_64-apple-ios-simulator``." msgstr "" #: ../../using/ios.rst:178 @@ -461,7 +461,7 @@ msgstr "" #: ../../using/ios.rst:269 msgid "" -"The CPython source tree contains :source:`a testbed project ` that is used to run the CPython test suite on the iOS simulator. " "This testbed can also be used as a testbed project for running your Python " "library's test suite on iOS." @@ -469,9 +469,10 @@ msgstr "" #: ../../using/ios.rst:273 msgid "" -"After building or obtaining an iOS XCFramework (see :source:`Apple/iOS/" -"README.md` for details), create a clone of the Python iOS testbed project. " -"If you used the ``Apple`` build script to build the XCframework, you can run:" +"After building or obtaining an iOS XCFramework (see :source:`Platforms/Apple/" +"iOS/README.md` for details), create a clone of the Python iOS testbed " +"project. If you used the ``Platforms/Apple`` build script to build the " +"XCframework, you can run:" msgstr "" #: ../../using/ios.rst:277 @@ -486,9 +487,13 @@ msgstr "" #: ../../using/ios.rst:283 msgid "" -"$ python Apple/testbed clone --platform iOS --framework --app --app app-testbed" +"$ python Platforms/Apple/testbed clone --platform iOS --framework --app --app app-" +"testbed" msgstr "" +"$ python Platforms/Apple/testbed clone --platform iOS --framework --app --app app-" +"testbed" #: ../../using/ios.rst:287 msgid "" diff --git a/using/mac.po b/using/mac.po index 0d1c587e4c7..d31007a7957 100644 --- a/using/mac.po +++ b/using/mac.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-31 00:31+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-08-31 22:26+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -26,7 +26,7 @@ msgstr "" msgid "Using Python on macOS" msgstr "於 macOS 使用 Python" -#: ../../using/mac.rst:12 +#: ../../using/mac.rst:9 msgid "" "This document aims to give an overview of macOS-specific behavior you should " "know about to get started with Python on Mac computers. Python on a Mac " @@ -34,7 +34,7 @@ msgid "" "there are some differences in installation and some features." msgstr "" -#: ../../using/mac.rst:17 +#: ../../using/mac.rst:14 msgid "" "There are various ways to obtain and install Python for macOS. Pre-built " "versions of the most recent versions of Python are available from a number " @@ -44,45 +44,46 @@ msgid "" "some other options." msgstr "" -#: ../../using/mac.rst:28 +#: ../../using/mac.rst:25 msgid "Using Python for macOS from ``python.org``" msgstr "" -#: ../../using/mac.rst:31 +#: ../../using/mac.rst:28 msgid "Installation steps" msgstr "安裝步驟" -#: ../../using/mac.rst:33 +#: ../../using/mac.rst:30 msgid "" "For `current Python versions `_ (other " "than those in ``security`` status), the release team produces a **Python for " "macOS** installer package for each new release. A list of available " -"installers is available `here `_. " -"We recommend using the most recent supported Python version where possible. " -"Current installers provide a `universal2 binary `_ build of Python which runs natively on all Macs " -"(Apple Silicon and Intel) that are supported by a wide range of macOS " -"versions, currently typically from at least **macOS 10.15 Catalina** on." +"installers is provided on the `macOS downloads page `__. We recommend using the most recent supported Python " +"version where possible. Current installers provide a `universal2 binary " +"`_ build of Python which " +"runs natively on all Macs (Apple Silicon and Intel) that are supported by a " +"wide range of macOS versions, currently typically from at least **macOS " +"10.15 Catalina** on." msgstr "" -#: ../../using/mac.rst:45 +#: ../../using/mac.rst:42 msgid "" "The downloaded file is a standard macOS installer package file (``.pkg``). " -"File integrity information (checksum, size, sigstore signature, etc) for " -"each file is included on the release download page. Installer packages and " -"their contents are signed and notarized with ``Python Software Foundation`` " -"Apple Developer ID certificates to meet `macOS Gatekeeper requirements " -"`_." +"File integrity information (such as checksum, size, and Sigstore signature) " +"for each file is included on the release download page. Installer packages " +"and their contents are signed and notarized with ``Python Software " +"Foundation`` Apple Developer ID certificates to meet `macOS Gatekeeper " +"requirements `_." msgstr "" -#: ../../using/mac.rst:51 +#: ../../using/mac.rst:48 msgid "" "For a default installation, double-click on the downloaded installer package " "file. This should launch the standard macOS Installer app and display the " -"first of several installer windows steps." +"first of several installer steps." msgstr "" -#: ../../using/mac.rst:57 +#: ../../using/mac.rst:54 msgid "" "Clicking on the **Continue** button brings up the **Read Me** for this " "installer. Besides other important information, the **Read Me** documents " @@ -92,7 +93,7 @@ msgid "" "applications_python_version_literal| and available to read anytime." msgstr "" -#: ../../using/mac.rst:65 +#: ../../using/mac.rst:62 msgid "" "Clicking on **Continue** proceeds to display the license for Python and for " "other included software. You will then need to **Agree** to the license " @@ -100,22 +101,23 @@ msgid "" "installed and available to be read later." msgstr "" -#: ../../using/mac.rst:72 +#: ../../using/mac.rst:69 msgid "" "After the license terms are accepted, the next step is the **Installation " "Type** display. For most uses, the standard set of installation operations " "is appropriate." msgstr "" -#: ../../using/mac.rst:77 +#: ../../using/mac.rst:74 msgid "" "By pressing the **Customize** button, you can choose to omit or select " "certain package components of the installer. Click on each package name to " -"see a description of what it installs. To also install support for the " -"optional free-threaded feature, see :ref:`install-freethreaded-macos`." +"see a description of what it installs. For details of the optional free-" +"threaded feature, which is installed by default, see :ref:`install-" +"freethreaded-macos`." msgstr "" -#: ../../using/mac.rst:85 +#: ../../using/mac.rst:82 msgid "" "In either case, clicking **Install** will begin the install process by " "asking permission to install new software. A macOS user name with " @@ -123,35 +125,35 @@ msgid "" "available to all users of the Mac." msgstr "" -#: ../../using/mac.rst:89 +#: ../../using/mac.rst:86 msgid "When the installation is complete, the **Summary** window will appear." msgstr "" -#: ../../using/mac.rst:93 +#: ../../using/mac.rst:90 msgid "" "Double-click on the :command:`Install Certificates.command` icon or file in " "the |applications_python_version_literal| window to complete the " "installation." msgstr "" -#: ../../using/mac.rst:99 +#: ../../using/mac.rst:96 msgid "" "This will open a temporary :program:`Terminal` shell window that will use " "the new Python to download and install SSL root certificates for its use." msgstr "" -#: ../../using/mac.rst:105 +#: ../../using/mac.rst:102 msgid "" -"If ``Successfully installed certifi`` and ``update complete`` appears in the " +"If ``Successfully installed certifi`` and ``update complete`` appear in the " "terminal window, the installation is complete. Close this terminal window " "and the installer window." msgstr "" -#: ../../using/mac.rst:109 +#: ../../using/mac.rst:106 msgid "A default install will include:" msgstr "預設安裝會包含:" -#: ../../using/mac.rst:111 +#: ../../using/mac.rst:108 msgid "" "A |python_version_literal| folder in your :file:`Applications` folder. In " "here you find :program:`IDLE`, the development environment that is a " @@ -164,7 +166,7 @@ msgstr "" "發環境;以及 :program:`Python Launcher`,它負責處理在 `Finder `_ 中雙擊 Python 腳本的操作。" -#: ../../using/mac.rst:116 +#: ../../using/mac.rst:113 msgid "" "A framework :file:`/Library/Frameworks/Python.framework`, which includes the " "Python executable and libraries. The installer adds this location to your " @@ -176,7 +178,7 @@ msgstr "" "裝 Python ,你可以移除這三個東西。Python 可執行檔案的符號連結 (symlink) 則放" "在 :file:`/usr/local/bin/` 中。" -#: ../../using/mac.rst:123 +#: ../../using/mac.rst:120 msgid "" "Recent versions of macOS include a :command:`python3` command in :file:`/usr/" "bin/python3` that links to a usually older and incomplete version of Python " @@ -190,11 +192,11 @@ msgid "" "used instead of the system :command:`python3`." msgstr "" -#: ../../using/mac.rst:134 +#: ../../using/mac.rst:131 msgid "How to run a Python script" msgstr "如何執行 Python 腳本" -#: ../../using/mac.rst:136 +#: ../../using/mac.rst:133 msgid "" "There are two ways to invoke the Python interpreter. If you are familiar " "with using a Unix shell in a terminal window, you can invoke |" @@ -204,7 +206,7 @@ msgid "" "a shell `." msgstr "" -#: ../../using/mac.rst:143 +#: ../../using/mac.rst:140 msgid "" "You can also invoke the interpreter through an integrated development " "environment. :ref:`idle` is a basic editor and interpreter environment which " @@ -214,31 +216,31 @@ msgid "" "document." msgstr "" -#: ../../using/mac.rst:151 +#: ../../using/mac.rst:148 msgid "" "There are many other editors and IDEs available, see :ref:`editors` for more " "information." msgstr "" -#: ../../using/mac.rst:154 +#: ../../using/mac.rst:151 msgid "" "To run a Python script file from the terminal window, you can invoke the " "interpreter with the name of the script file:" msgstr "" -#: ../../using/mac.rst:157 +#: ../../using/mac.rst:154 msgid "|python_x_dot_y_literal| ``myscript.py``" msgstr "|python_x_dot_y_literal| ``myscript.py``" -#: ../../using/mac.rst:159 +#: ../../using/mac.rst:156 msgid "To run your script from the Finder, you can either:" msgstr "從 Finder 執行你的腳本時,你可以:" -#: ../../using/mac.rst:161 +#: ../../using/mac.rst:158 msgid "Drag it to :program:`Python Launcher`." msgstr "把它拖曳到 :program:`Python Launcher`" -#: ../../using/mac.rst:163 +#: ../../using/mac.rst:160 msgid "" "Select :program:`Python Launcher` as the default application to open your " "script (or any ``.py`` script) through the Finder Info window and double-" @@ -251,7 +253,7 @@ msgstr "" "來控制腳本啟動方式的選項。拖曳選項可以讓你一次更改多個選項,或使用其 " "``Preferences`` 選單以全域性地更改內容。" -#: ../../using/mac.rst:169 +#: ../../using/mac.rst:166 msgid "" "Be aware that running the script directly from the macOS Finder might " "produce different results than when running from a terminal window as the " @@ -260,81 +262,81 @@ msgid "" "program, be certain of what you are about to run." msgstr "" -#: ../../using/mac.rst:179 -msgid "Alternative Distributions" +#: ../../using/mac.rst:176 +msgid "Alternative distributions" msgstr "" -#: ../../using/mac.rst:181 +#: ../../using/mac.rst:178 msgid "" "Besides the standard ``python.org`` for macOS installer, there are third-" "party distributions for macOS that may include additional functionality. " "Some popular distributions and their key features:" msgstr "" -#: ../../using/mac.rst:185 +#: ../../using/mac.rst:182 msgid "`ActivePython `_" msgstr "`ActivePython `_" -#: ../../using/mac.rst:186 +#: ../../using/mac.rst:183 msgid "Installer with multi-platform compatibility, documentation" msgstr "" -#: ../../using/mac.rst:188 +#: ../../using/mac.rst:185 msgid "`Anaconda `_" msgstr "`Anaconda `_" -#: ../../using/mac.rst:189 +#: ../../using/mac.rst:186 msgid "" "Popular scientific modules (such as numpy, scipy, and pandas) and the " "``conda`` package manager." msgstr "" -#: ../../using/mac.rst:192 +#: ../../using/mac.rst:189 msgid "`Homebrew `_" msgstr "`Homebrew `_" -#: ../../using/mac.rst:193 +#: ../../using/mac.rst:190 msgid "" "Package manager for macOS including multiple versions of Python and many " "third-party Python-based packages (including numpy, scipy, and pandas)." msgstr "" -#: ../../using/mac.rst:196 +#: ../../using/mac.rst:193 msgid "`MacPorts `_" msgstr "`MacPorts `_" -#: ../../using/mac.rst:197 +#: ../../using/mac.rst:194 msgid "" "Another package manager for macOS including multiple versions of Python and " "many third-party Python-based packages. May include pre-built versions of " "Python and many packages for older versions of macOS." msgstr "" -#: ../../using/mac.rst:201 +#: ../../using/mac.rst:198 msgid "" "Note that distributions might not include the latest versions of Python or " "other libraries, and are not maintained or supported by the core Python team." msgstr "" -#: ../../using/mac.rst:207 -msgid "Installing Additional Python Packages" +#: ../../using/mac.rst:204 +msgid "Installing additional Python packages" msgstr "安裝額外的 Python 套件" -#: ../../using/mac.rst:209 +#: ../../using/mac.rst:206 msgid "Refer to the `Python Packaging User Guide`_ for more information." msgstr "更多資訊請見 `Python Packaging User Guide`_。" -#: ../../using/mac.rst:219 -msgid "GUI Programming" +#: ../../using/mac.rst:216 +msgid "GUI programming" msgstr "開發 GUI 程式" -#: ../../using/mac.rst:221 +#: ../../using/mac.rst:218 msgid "" "There are several options for building GUI applications on the Mac with " "Python." msgstr "於 Mac 上使用 Python 來建立 GUI 應用程式有許多選項。" -#: ../../using/mac.rst:223 +#: ../../using/mac.rst:220 msgid "" "The standard Python GUI toolkit is :mod:`tkinter`, based on the cross-" "platform Tk toolkit (https://www.tcl.tk). A macOS-native version of Tk is " @@ -343,7 +345,7 @@ msgstr "" "標準的 Python GUI 工具套件是基於跨平臺 Tk 工具套件 (https://www.tcl.tk) 的 :" "mod:`tkinter`。macOS 原生版本的 Tk 有包含於安裝程式中。" -#: ../../using/mac.rst:227 +#: ../../using/mac.rst:224 msgid "" "*PyObjC* is a Python binding to Apple's Objective-C/Cocoa framework. " "Information on PyObjC is available from :pypi:`pyobjc`." @@ -351,11 +353,11 @@ msgstr "" "*PyObjC* 是一個 Apple Objective-C/Cocoa 框架的 Python 繫結 (binding)。有關 " "PyObjC 的資訊請見 :pypi:`pyobjc`。" -#: ../../using/mac.rst:230 +#: ../../using/mac.rst:227 msgid "A number of alternative macOS GUI toolkits are available including:" msgstr "有許多替代 macOS GUI 工具套件可用,包含:" -#: ../../using/mac.rst:232 +#: ../../using/mac.rst:229 msgid "" "`PySide `_: Official Python bindings to the " "`Qt GUI toolkit `_." @@ -363,7 +365,7 @@ msgstr "" "`PySide `_:`Qt GUI 工具包 `_\\ 的官方 Python 繫結。" -#: ../../using/mac.rst:235 +#: ../../using/mac.rst:232 msgid "" "`PyQt `_: Alternative Python " "bindings to Qt." @@ -371,14 +373,14 @@ msgstr "" "`PyQt `_:Qt 的替代 Python 繫" "結。" -#: ../../using/mac.rst:238 +#: ../../using/mac.rst:235 msgid "" "`Kivy `_: A cross-platform GUI toolkit that supports " "desktop and mobile platforms." msgstr "" "`Kivy `_:一個支援桌面和行動平臺的跨平臺 GUI 工具包。" -#: ../../using/mac.rst:241 +#: ../../using/mac.rst:238 msgid "" "`Toga `_: Part of the `BeeWare Project `_; supports desktop, mobile, web and console apps." @@ -386,28 +388,32 @@ msgstr "" "`Toga `_:`BeeWare 專案 `_\\ 的一部分;支援桌面、行動、網頁和控制台應用程式。" -#: ../../using/mac.rst:244 +#: ../../using/mac.rst:241 msgid "" "`wxPython `_: A cross-platform toolkit that supports " "desktop operating systems." msgstr "" "`wxPython `_:一個支援桌面作業系統的跨平臺工具包。" -#: ../../using/mac.rst:249 -msgid "Advanced Topics" +#: ../../using/mac.rst:246 +msgid "Advanced topics" msgstr "進階主題" -#: ../../using/mac.rst:254 -msgid "Installing Free-threaded Binaries" +#: ../../using/mac.rst:251 +msgid "Installing free-threaded binaries" +msgstr "安裝自由執行緒二進位檔案" + +#: ../../using/mac.rst:255 +msgid "Free-threading support is now installed by default." msgstr "" #: ../../using/mac.rst:258 msgid "" "The ``python.org`` :ref:`Python for macOS ` installer package can optionally install an additional build of " -"Python |version| that supports :pep:`703`, the free-threading feature " -"(running with the :term:`global interpreter lock` disabled). Check the " -"release page on ``python.org`` for possible updated information." +"macpython>` installer package installs, by default, an additional build of " +"Python |version| that supports :term:`free threading` (running with the :" +"term:`global interpreter lock` disabled). Check the release page on ``python." +"org`` for possible updated information." msgstr "" #: ../../using/mac.rst:264 @@ -416,46 +422,46 @@ msgid "" "some additional overhead in single-threaded workloads compared to the " "regular build. Additionally, third-party packages, in particular ones with " "an :term:`extension module`, may not be ready for use in a free-threaded " -"build, and will re-enable the :term:`GIL`. Therefore, the support for free-" -"threading is not installed by default. It is packaged as a separate install " -"option, available by clicking the **Customize** button on the **Installation " -"Type** step of the installer as described above." +"build, and will re-enable the :term:`GIL`. As of Python 3.15, free-threading " +"support is installed by default. It is packaged as a separate install " +"option, which can be deselected by clicking the **Customize** button on the " +"**Installation Type** step of the installer as described above." msgstr "" #: ../../using/mac.rst:276 msgid "" -"If the box next to the **Free-threaded Python** package name is checked, a " -"separate :file:`PythonT.framework` will also be installed alongside the " -"normal :file:`Python.framework` in :file:`/Library/Frameworks`. This " -"configuration allows a free-threaded Python |version| build to co-exist on " -"your system with a traditional (GIL only) Python |version| build with " -"minimal risk while installing or testing. This installation layout may " -"change in future releases." +"If the box next to the **Free-threaded Python** package name is checked (as " +"it is by default), a separate :file:`PythonT.framework` will also be " +"installed alongside the normal :file:`Python.framework` in :file:`/Library/" +"Frameworks`. This configuration allows a free-threaded Python |version| " +"build to co-exist on your system with a traditional (GIL only) Python |" +"version| build with minimal risk while installing or testing. This " +"installation layout may change in future releases." msgstr "" -#: ../../using/mac.rst:284 +#: ../../using/mac.rst:285 msgid "Known cautions and limitations:" msgstr "" -#: ../../using/mac.rst:286 +#: ../../using/mac.rst:287 msgid "" "The **UNIX command-line tools** package, which is selected by default, will " "install links in :file:`/usr/local/bin` for |python_x_dot_y_t_literal|, the " "free-threaded interpreter, and |python_x_dot_y_t_literal_config|, a " "configuration utility which may be useful for package builders. Since :file:" "`/usr/local/bin` is typically included in your shell ``PATH``, in most cases " -"no changes to your ``PATH`` environment variables should be needed to use |" +"no changes to your ``PATH`` environment variable should be needed to use |" "python_x_dot_y_t_literal|." msgstr "" -#: ../../using/mac.rst:294 +#: ../../using/mac.rst:295 msgid "" "For this release, the **Shell profile updater** package and the :file:" "`Update Shell Profile.command` in |applications_python_version_literal| do " "not support the free-threaded package." msgstr "" -#: ../../using/mac.rst:298 +#: ../../using/mac.rst:299 msgid "" "The free-threaded build and the traditional build have separate search paths " "and separate :file:`site-packages` directories so, by default, if you need a " @@ -464,15 +470,15 @@ msgid "" "use with |python_x_dot_y_t_literal|." msgstr "" -#: ../../using/mac.rst:304 +#: ../../using/mac.rst:305 msgid "To install a package using :command:`pip` without a :command:`venv`:" msgstr "" -#: ../../using/mac.rst:308 +#: ../../using/mac.rst:309 msgid "python\\ |version|\\ t -m pip install " msgstr "python\\ |version|\\ t -m pip install " -#: ../../using/mac.rst:310 +#: ../../using/mac.rst:311 msgid "" "When working with multiple Python environments, it is usually safest and " "easiest to :ref:`create and use virtual environments `. This can " @@ -480,23 +486,23 @@ msgid "" "use:" msgstr "" -#: ../../using/mac.rst:316 +#: ../../using/mac.rst:317 msgid "python\\ |version|\\ t -m venv " msgstr "python\\ |version|\\ t -m venv " -#: ../../using/mac.rst:319 +#: ../../using/mac.rst:320 msgid "then :command:`activate`." msgstr "然後 :command:`activate`。" -#: ../../using/mac.rst:321 +#: ../../using/mac.rst:322 msgid "To run a free-threaded version of IDLE:" msgstr "執行 free-threaded(自由執行緒)版本的 IDLE:" -#: ../../using/mac.rst:325 +#: ../../using/mac.rst:326 msgid "python\\ |version|\\ t -m idlelib" msgstr "python\\ |version|\\ t -m idlelib" -#: ../../using/mac.rst:328 +#: ../../using/mac.rst:329 msgid "" "The interpreters in both builds respond to the same :ref:`PYTHON environment " "variables ` which may have unexpected results, for " @@ -505,7 +511,7 @@ msgid "" "E`` to ignore these environment variables." msgstr "" -#: ../../using/mac.rst:335 +#: ../../using/mac.rst:336 msgid "" "The free-threaded build links to the third-party shared libraries, such as " "``OpenSSL`` and ``Tk``, installed in the traditional framework. This means " @@ -514,7 +520,7 @@ msgid "" "run once." msgstr "" -#: ../../using/mac.rst:341 +#: ../../using/mac.rst:342 msgid "" "If you cannot depend on the link in ``/usr/local/bin`` pointing to the " "``python.org`` free-threaded |python_x_dot_y_t_literal| (for example, if you " @@ -523,7 +529,7 @@ msgid "" "``PythonT`` framework ``bin`` directory:" msgstr "" -#: ../../using/mac.rst:349 +#: ../../using/mac.rst:350 msgid "" "export PATH=\"/Library/Frameworks/PythonT.framework/Versions/\\ |version|\\ /" "bin\":\"$PATH\"" @@ -531,7 +537,7 @@ msgstr "" "export PATH=\"/Library/Frameworks/PythonT.framework/Versions/\\ |version|\\ /" "bin\":\"$PATH\"" -#: ../../using/mac.rst:351 +#: ../../using/mac.rst:352 msgid "" "The traditional framework installation by default does something similar, " "except for :file:`Python.framework`. Be aware that having both framework " @@ -543,7 +549,7 @@ msgid "" "be to create a shell :command:`alias` to the desired interpreter, like:" msgstr "" -#: ../../using/mac.rst:362 +#: ../../using/mac.rst:363 msgid "" "alias py\\ |version|\\ =\"/Library/Frameworks/Python.framework/Versions/\\ |" "version|\\ /bin/python\\ |version|\\ \"\n" @@ -555,11 +561,11 @@ msgstr "" "alias py\\ |version|\\ t=\"/Library/Frameworks/PythonT.framework/Versions/\\ " "|version|\\ /bin/python\\ |version|\\ t\"" -#: ../../using/mac.rst:366 +#: ../../using/mac.rst:367 msgid "Installing using the command line" msgstr "使用命令列安裝" -#: ../../using/mac.rst:368 +#: ../../using/mac.rst:369 msgid "" "If you want to use automation to install the ``python.org`` installer " "package (rather than by using the familiar macOS :program:`Installer` GUI " @@ -567,11 +573,11 @@ msgid "" "non-default options, too. If you are not familiar with :command:`installer`, " "it can be somewhat cryptic (see :command:`man installer` for more " "information). As an example, the following shell snippet shows one way to do " -"it, using the |x_dot_y_b2_literal| release and selecting the free-threaded " +"it, using the |x_dot_y_b2_literal| release and deselecting the free-threaded " "interpreter option:" msgstr "" -#: ../../using/mac.rst:379 +#: ../../using/mac.rst:380 msgid "" "RELEASE=\"python-\\ |version|\\ 0b2-macos11.pkg\"\n" "\n" @@ -579,7 +585,7 @@ msgid "" "curl -O \\https://www.python.org/ftp/python/\\ |version|\\ .0/${RELEASE}\n" "\n" "# create installer choicechanges to customize the install:\n" -"# enable the PythonTFramework-\\ |version|\\ package\n" +"# disable the PythonTFramework-\\ |version|\\ package\n" "# while accepting the other defaults (install all other packages)\n" "cat > ./choicechanges.plist <\n" @@ -589,7 +595,7 @@ msgid "" "\n" " \n" " attributeSetting\n" -" 1\n" +" 0\n" " choiceAttribute\n" " selected\n" " choiceIdentifier\n" @@ -603,14 +609,43 @@ msgid "" "sudo installer -pkg ./${RELEASE} -applyChoiceChangesXML ./choicechanges." "plist -target /" msgstr "" +"RELEASE=\"python-\\ |version|\\ 0b2-macos11.pkg\"\n" +"\n" +"# 下載安裝程式 pkg\n" +"curl -O \\https://www.python.org/ftp/python/\\ |version|\\ .0/${RELEASE}\n" +"\n" +"# 建立安裝程式的 choicechanges 以自訂安裝:\n" +"# 停用 PythonTFramework-\\ |version|\\ 套件\n" +"# 同時接受其他預設值(安裝所有其他套件)\n" +"cat > ./choicechanges.plist <\n" +"\n" +"\n" +"\n" +" \n" +" attributeSetting\n" +" 0\n" +" choiceAttribute\n" +" selected\n" +" choiceIdentifier\n" +" org.python.Python.PythonTFramework-\\ |version|\\ \n" +" \n" +"\n" +"\n" +"EOF\n" +"\n" +"sudo installer -pkg ./${RELEASE} -applyChoiceChangesXML ./" +"choicechanges.plist -target /" -#: ../../using/mac.rst:407 +#: ../../using/mac.rst:408 msgid "" -"You can then test that both installer builds are now available with " +"After a default install, you can test that both builds are available with " "something like:" msgstr "" -#: ../../using/mac.rst:411 +#: ../../using/mac.rst:412 msgid "" "$ # test that the free-threaded interpreter was installed if the Unix " "Command Tools package was enabled\n" @@ -633,7 +668,7 @@ msgid "" "12:50:24) [Clang 15.0.0 (clang-1500.3.9.4)]" msgstr "" -#: ../../using/mac.rst:425 +#: ../../using/mac.rst:426 msgid "" "Current ``python.org`` installers only install to fixed locations like :file:" "`/Library/Frameworks/`, :file:`/Applications`, and :file:`/usr/local/bin`. " @@ -641,23 +676,23 @@ msgid "" "other locations." msgstr "" -#: ../../using/mac.rst:433 -msgid "Distributing Python Applications" +#: ../../using/mac.rst:434 +msgid "Distributing Python applications" msgstr "發行 Python 應用程式" -#: ../../using/mac.rst:435 +#: ../../using/mac.rst:436 msgid "" "A range of tools exist for converting your Python code into a standalone " "distributable application:" msgstr "" -#: ../../using/mac.rst:438 +#: ../../using/mac.rst:439 msgid "" ":pypi:`py2app`: Supports creating macOS ``.app`` bundles from a Python " "project." msgstr ":pypi:`py2app`:支援從 Python 專案打包成 macOS ``.app``。" -#: ../../using/mac.rst:441 +#: ../../using/mac.rst:442 msgid "" "`Briefcase `_: Part of the `BeeWare " "Project `_; a cross-platform packaging tool that " @@ -668,7 +703,7 @@ msgstr "" "beeware.org>`__\\ 的一部分;支援建立 macOS ``.app`` 的跨平台打包工具,亦為管" "理簽署和驗證 (notarization) 的工具。" -#: ../../using/mac.rst:446 +#: ../../using/mac.rst:447 msgid "" "`PyInstaller `_: A cross-platform packaging tool " "that creates a single file or folder as a distributable artifact." @@ -676,11 +711,11 @@ msgstr "" "`PyInstaller `_:一個跨平臺打包工具,可以將單一檔案" "或資料夾打包成可分發的檔案。" -#: ../../using/mac.rst:450 -msgid "App Store Compliance" +#: ../../using/mac.rst:451 +msgid "App Store compliance" msgstr "" -#: ../../using/mac.rst:452 +#: ../../using/mac.rst:453 msgid "" "Apps submitted for distribution through the macOS App Store must pass " "Apple's app review process. This process includes a set of automated " @@ -688,7 +723,7 @@ msgid "" "problematic code." msgstr "" -#: ../../using/mac.rst:456 +#: ../../using/mac.rst:457 msgid "" "The Python standard library contains some code that is known to violate " "these automated rules. While these violations appear to be false positives, " @@ -696,7 +731,7 @@ msgid "" "modify the Python standard library for an app to pass App Store review." msgstr "" -#: ../../using/mac.rst:461 +#: ../../using/mac.rst:462 msgid "" "The Python source tree contains :source:`a patch file ` that will remove all code that is known to cause " @@ -705,7 +740,7 @@ msgid "" "compliance` option." msgstr "" -#: ../../using/mac.rst:467 +#: ../../using/mac.rst:468 msgid "" "This patch is not normally required to use CPython on a Mac; nor is it " "required if you are distributing an app *outside* the macOS App Store. It is " @@ -713,11 +748,11 @@ msgid "" "channel." msgstr "" -#: ../../using/mac.rst:472 -msgid "Other Resources" +#: ../../using/mac.rst:473 +msgid "Other resources" msgstr "其他資源" -#: ../../using/mac.rst:474 +#: ../../using/mac.rst:475 msgid "" "The `python.org Help page `_ has links " "to many useful resources. The `Pythonmac-SIG mailing list \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,15 +23,15 @@ msgstr "" msgid "Using Python on Unix platforms" msgstr "在 Unix 平臺上使用 Python" -#: ../../using/unix.rst:13 +#: ../../using/unix.rst:10 msgid "Getting and installing the latest version of Python" msgstr "獲得並安裝 Python 的最新版本" -#: ../../using/unix.rst:16 +#: ../../using/unix.rst:13 msgid "On Linux" msgstr "在 Linux 上" -#: ../../using/unix.rst:18 +#: ../../using/unix.rst:15 msgid "" "Python comes preinstalled on most Linux distributions, and is available as a " "package on all others. However there are certain features you might want to " @@ -42,7 +42,7 @@ msgstr "" "者。但是發行版提供的套件可能沒有你想要使用的某些功能,這時你可以選擇從原始碼" "編譯最新版本的 Python。" -#: ../../using/unix.rst:23 +#: ../../using/unix.rst:20 msgid "" "In the event that the latest version of Python doesn't come preinstalled and " "isn't in the repositories as well, you can make packages for your own " @@ -51,23 +51,23 @@ msgstr "" "如果最新版的 Python 沒有預先安裝,並且不在發行版提供的儲存庫 (repository) " "中,你可以輕鬆地為自己使用的發行版建立套件。參閱以下連結:" -#: ../../using/unix.rst:29 +#: ../../using/unix.rst:26 msgid "https://www.debian.org/doc/manuals/maint-guide/first.en.html" msgstr "https://www.debian.org/doc/manuals/maint-guide/first.en.html" -#: ../../using/unix.rst:30 +#: ../../using/unix.rst:27 msgid "for Debian users" msgstr "對於 Debian 使用者" -#: ../../using/unix.rst:31 +#: ../../using/unix.rst:28 msgid "https://en.opensuse.org/Portal:Packaging" msgstr "https://en.opensuse.org/Portal:Packaging" -#: ../../using/unix.rst:32 +#: ../../using/unix.rst:29 msgid "for OpenSuse users" msgstr "對於 OpenSuse 使用者" -#: ../../using/unix.rst:33 +#: ../../using/unix.rst:30 msgid "" "https://docs.fedoraproject.org/en-US/package-maintainers/" "Packaging_Tutorial_GNU_Hello/" @@ -75,31 +75,31 @@ msgstr "" "https://docs.fedoraproject.org/en-US/package-maintainers/" "Packaging_Tutorial_GNU_Hello/" -#: ../../using/unix.rst:34 +#: ../../using/unix.rst:31 msgid "for Fedora users" msgstr "對於 Fedora 使用者" -#: ../../using/unix.rst:35 +#: ../../using/unix.rst:32 msgid "https://slackbook.org/html/package-management-making-packages.html" msgstr "https://slackbook.org/html/package-management-making-packages.html" -#: ../../using/unix.rst:36 +#: ../../using/unix.rst:33 msgid "for Slackware users" msgstr "對於 Slackware 使用者" -#: ../../using/unix.rst:41 +#: ../../using/unix.rst:38 msgid "Installing IDLE" msgstr "安裝 IDLE" -#: ../../using/unix.rst:43 +#: ../../using/unix.rst:40 msgid "In some cases, IDLE might not be included in your Python installation." msgstr "在某些情況下,IDLE 可能不會包含在你的 Python 安裝中。" -#: ../../using/unix.rst:45 +#: ../../using/unix.rst:42 msgid "For Debian and Ubuntu users::" msgstr "對於 Debian 和 Ubuntu 使用者: ::" -#: ../../using/unix.rst:47 +#: ../../using/unix.rst:44 msgid "" "sudo apt update\n" "sudo apt install idle" @@ -107,47 +107,47 @@ msgstr "" "sudo apt update\n" "sudo apt install idle" -#: ../../using/unix.rst:50 +#: ../../using/unix.rst:47 msgid "For Fedora, RHEL, and CentOS users::" msgstr "對於 Fedora、RHEL 和 CentOS 使用者: ::" -#: ../../using/unix.rst:52 +#: ../../using/unix.rst:49 msgid "sudo dnf install python3-idle" msgstr "sudo dnf install python3-idle" -#: ../../using/unix.rst:54 +#: ../../using/unix.rst:51 msgid "For SUSE and OpenSUSE users::" msgstr "對於 SUSE 和 OpenSUSE 使用者: ::" -#: ../../using/unix.rst:56 +#: ../../using/unix.rst:53 msgid "sudo zypper install python3-idle" msgstr "sudo zypper install python3-idle" -#: ../../using/unix.rst:58 +#: ../../using/unix.rst:55 msgid "For Alpine Linux users::" msgstr "對於 Alpine Linux 使用者: ::" -#: ../../using/unix.rst:60 +#: ../../using/unix.rst:57 msgid "sudo apk add python3-idle" msgstr "sudo apk add python3-idle" -#: ../../using/unix.rst:65 +#: ../../using/unix.rst:62 msgid "On FreeBSD and OpenBSD" msgstr "在 FreeBSD 和 OpenBSD 上" -#: ../../using/unix.rst:67 +#: ../../using/unix.rst:64 msgid "FreeBSD users, to add the package use::" msgstr "FreeBSD 使用者應使用以下命令增加套件: ::" -#: ../../using/unix.rst:69 +#: ../../using/unix.rst:66 msgid "pkg install python3" msgstr "pkg install python3" -#: ../../using/unix.rst:71 +#: ../../using/unix.rst:68 msgid "OpenBSD users, to add the package use::" msgstr "OpenBSD 使用者應使用以下命令增加套件: ::" -#: ../../using/unix.rst:73 +#: ../../using/unix.rst:70 msgid "" "pkg_add -r python\n" "\n" @@ -159,11 +159,11 @@ msgstr "" "pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages//python-.tgz" -#: ../../using/unix.rst:77 +#: ../../using/unix.rst:74 msgid "For example i386 users get the 2.5.1 version of Python using::" msgstr "例如 i386 使用者要取得 Python 2.5.1 的可用版本: ::" -#: ../../using/unix.rst:79 +#: ../../using/unix.rst:76 msgid "" "pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2." "tgz" @@ -171,18 +171,18 @@ msgstr "" "pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2." "tgz" -#: ../../using/unix.rst:85 +#: ../../using/unix.rst:82 msgid "Building Python" msgstr "建置 Python" -#: ../../using/unix.rst:89 +#: ../../using/unix.rst:86 msgid "" "If you want to contribute to CPython, refer to the `devguide `_, which includes build " "instructions and other tips on setting up environment." msgstr "" -#: ../../using/unix.rst:93 +#: ../../using/unix.rst:90 msgid "" "If you want to compile CPython yourself, first thing you should do is get " "the `source `_. You can download " @@ -195,11 +195,11 @@ msgstr "" "(克隆) `_。你還需要" "安裝\\ :ref:`建置需求 `。" -#: ../../using/unix.rst:99 +#: ../../using/unix.rst:96 msgid "The build process consists of the usual commands::" msgstr "建置過程由幾個常用命令組成: ::" -#: ../../using/unix.rst:101 +#: ../../using/unix.rst:98 msgid "" "./configure\n" "make\n" @@ -209,7 +209,7 @@ msgstr "" "make\n" "make install" -#: ../../using/unix.rst:105 +#: ../../using/unix.rst:102 msgid "" ":ref:`Configuration options ` and caveats for specific " "Unix platforms are extensively documented in the :source:`README.rst` file " @@ -219,7 +219,7 @@ msgstr "" "地記錄在 Python 原始碼樹 (source tree) 根目錄下的 :source:`README.rst` 檔案" "中。" -#: ../../using/unix.rst:111 +#: ../../using/unix.rst:108 msgid "" "``make install`` can overwrite or masquerade the :file:`python3` binary. " "``make altinstall`` is therefore recommended instead of ``make install`` " @@ -229,11 +229,11 @@ msgstr "" "``make altinstall`` 而不是 ``make install``,因為它只安裝 :file:" "`{exec_prefix}/bin/python{version}`。" -#: ../../using/unix.rst:117 +#: ../../using/unix.rst:114 msgid "Python-related paths and files" msgstr "與 Python 相關的路徑和檔案" -#: ../../using/unix.rst:119 +#: ../../using/unix.rst:116 msgid "" "These are subject to difference depending on local installation " "conventions; :option:`prefix <--prefix>` and :option:`exec_prefix <--exec-" @@ -243,28 +243,28 @@ msgstr "" "這取決於本地安裝慣例;:option:`prefix <--prefix>` 和 :option:`exec_prefix <--" "exec-prefix>` 相依於安裝方式,應被直譯來讓 GNU 軟體使用;它們也可能相同。" -#: ../../using/unix.rst:124 +#: ../../using/unix.rst:121 msgid "" "For example, on most Linux systems, the default for both is :file:`/usr`." msgstr "例如,在大多數 Linux 系統上,兩者的預設值皆是 :file:`/usr`。" -#: ../../using/unix.rst:127 +#: ../../using/unix.rst:124 msgid "File/directory" msgstr "檔案/目錄" -#: ../../using/unix.rst:127 +#: ../../using/unix.rst:124 msgid "Meaning" msgstr "含意" -#: ../../using/unix.rst:129 +#: ../../using/unix.rst:126 msgid ":file:`{exec_prefix}/bin/python3`" msgstr ":file:`{exec_prefix}/bin/python3`" -#: ../../using/unix.rst:129 +#: ../../using/unix.rst:126 msgid "Recommended location of the interpreter." msgstr "直譯器的推薦位置。" -#: ../../using/unix.rst:131 +#: ../../using/unix.rst:128 msgid "" ":file:`{prefix}/lib/python{version}`, :file:`{exec_prefix}/lib/" "python{version}`" @@ -272,12 +272,12 @@ msgstr "" ":file:`{prefix}/lib/python{version}`、:file:`{exec_prefix}/lib/" "python{version}`" -#: ../../using/unix.rst:131 +#: ../../using/unix.rst:128 msgid "" "Recommended locations of the directories containing the standard modules." msgstr "包含標準模組目錄的推薦位置。" -#: ../../using/unix.rst:134 +#: ../../using/unix.rst:131 msgid "" ":file:`{prefix}/include/python{version}`, :file:`{exec_prefix}/include/" "python{version}`" @@ -285,39 +285,39 @@ msgstr "" ":file:`{prefix}/include/python{version}`、:file:`{exec_prefix}/include/" "python{version}`" -#: ../../using/unix.rst:134 +#: ../../using/unix.rst:131 msgid "" "Recommended locations of the directories containing the include files needed " "for developing Python extensions and embedding the interpreter." msgstr "" "包含開發 Python 擴充套件和嵌入直譯器所需 include 檔案之目錄的推薦位置。" -#: ../../using/unix.rst:142 +#: ../../using/unix.rst:139 msgid "Miscellaneous" msgstr "雜項" -#: ../../using/unix.rst:144 +#: ../../using/unix.rst:141 msgid "" "To easily use Python scripts on Unix, you need to make them executable, e.g. " "with" msgstr "" "要在 Unix 上使用 Python 腳本,你需要讓他們是可執行的 (executable),例如用" -#: ../../using/unix.rst:147 +#: ../../using/unix.rst:144 msgid "$ chmod +x script" msgstr "$ chmod +x script" -#: ../../using/unix.rst:151 +#: ../../using/unix.rst:148 msgid "" "and put an appropriate Shebang line at the top of the script. A good choice " "is usually ::" msgstr "並在腳本的頂部放一個合適的 Shebang。以下通常是個好選擇: ::" -#: ../../using/unix.rst:154 +#: ../../using/unix.rst:151 msgid "#!/usr/bin/env python3" msgstr "#!/usr/bin/env python3" -#: ../../using/unix.rst:156 +#: ../../using/unix.rst:153 msgid "" "which searches for the Python interpreter in the whole :envvar:`PATH`. " "However, some Unices may not have the :program:`env` command, so you may " @@ -327,17 +327,17 @@ msgstr "" "program:`env` 命令,因此你可能需要將 ``/usr/bin/python3`` 寫死 (hardcode) 成" "直譯器路徑。" -#: ../../using/unix.rst:160 +#: ../../using/unix.rst:157 msgid "" "To use shell commands in your Python scripts, look at the :mod:`subprocess` " "module." msgstr "要在 Python 腳本中使用 shell 命令,請見 :mod:`subprocess` 模組。" -#: ../../using/unix.rst:165 +#: ../../using/unix.rst:162 msgid "Custom OpenSSL" msgstr "客製化 OpenSSL" -#: ../../using/unix.rst:167 +#: ../../using/unix.rst:164 msgid "" "To use your vendor's OpenSSL configuration and system trust store, locate " "the directory with ``openssl.cnf`` file or symlink in ``/etc``. On most " @@ -350,7 +350,7 @@ msgstr "" "(symlink)。在大多數發行版上,該檔案會是在 ``/etc/ssl`` 或者 ``/etc/pki/tls`` " "中。該目錄亦應包含一個 ``cert.pem`` 檔案和/或一個 ``certs`` 目錄。" -#: ../../using/unix.rst:173 +#: ../../using/unix.rst:170 msgid "" "$ find /etc/ -name openssl.cnf -printf \"%h\\n\"\n" "/etc/ssl" @@ -358,7 +358,7 @@ msgstr "" "$ find /etc/ -name openssl.cnf -printf \"%h\\n\"\n" "/etc/ssl" -#: ../../using/unix.rst:178 +#: ../../using/unix.rst:175 msgid "" "Download, build, and install OpenSSL. Make sure you use ``install_sw`` and " "not ``install``. The ``install_sw`` target does not override ``openssl.cnf``." @@ -366,7 +366,7 @@ msgstr "" "下載、建置並安裝 OpenSSL。請確保你使用 ``install_sw`` 而不是 ``install``。" "``install_sw`` 的目標不會覆蓋 ``openssl.cnf``。" -#: ../../using/unix.rst:182 +#: ../../using/unix.rst:179 msgid "" "$ curl -O https://www.openssl.org/source/openssl-VERSION.tar.gz\n" "$ tar xzf openssl-VERSION\n" @@ -392,7 +392,7 @@ msgstr "" "$ make install_sw\n" "$ popd" -#: ../../using/unix.rst:196 +#: ../../using/unix.rst:193 msgid "" "Build Python with custom OpenSSL (see the configure ``--with-openssl`` and " "``--with-openssl-rpath`` options)" @@ -400,7 +400,7 @@ msgstr "" "使用客製化 OpenSSL 建置 Python(參見配置 ``--with-openssl`` 和 ``--with-" "openssl-rpath`` 選項)" -#: ../../using/unix.rst:199 +#: ../../using/unix.rst:196 msgid "" "$ pushd python-3.x.x\n" "$ ./configure -C \\\n" @@ -418,7 +418,7 @@ msgstr "" "$ make -j8\n" "$ make altinstall" -#: ../../using/unix.rst:211 +#: ../../using/unix.rst:208 msgid "" "Patch releases of OpenSSL have a backwards compatible ABI. You don't need to " "recompile Python to update OpenSSL. It's sufficient to replace the custom " diff --git a/using/windows.po b/using/windows.po index 0ce1379bacc..784ef23fe26 100644 --- a/using/windows.po +++ b/using/windows.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-15 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:19+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,13 +23,13 @@ msgstr "" msgid "Using Python on Windows" msgstr "在 Windows 上使用 Python" -#: ../../using/windows.rst:17 +#: ../../using/windows.rst:15 msgid "" "This document aims to give an overview of Windows-specific behaviour you " "should know about when using Python on Microsoft Windows." msgstr "" -#: ../../using/windows.rst:20 +#: ../../using/windows.rst:18 msgid "" "Unlike most Unix systems and services, Windows does not include a system " "supported installation of Python. Instead, Python can be obtained from a " @@ -40,7 +40,7 @@ msgid "" "investigating your existing tools to see if they can provide Python directly." msgstr "" -#: ../../using/windows.rst:28 +#: ../../using/windows.rst:26 msgid "" "To obtain Python from the CPython team, use the Python Install Manager. This " "is a standalone tool that makes Python available as global commands on your " @@ -49,7 +49,7 @@ msgid "" "through the `Microsoft Store app`_." msgstr "" -#: ../../using/windows.rst:34 +#: ../../using/windows.rst:32 msgid "" "Once you have installed the Python Install Manager, the global ``python`` " "command can be used from any terminal to launch your current latest version " @@ -57,7 +57,7 @@ msgid "" "versions, and the ``py list`` command will show which is current." msgstr "" -#: ../../using/windows.rst:39 +#: ../../using/windows.rst:37 msgid "" "In general, we recommend that you create a :ref:`virtual environment ` for each project and run ``\\Scripts\\Activate`` in your " @@ -67,21 +67,21 @@ msgid "" "venv ``." msgstr "" -#: ../../using/windows.rst:45 +#: ../../using/windows.rst:43 msgid "" "If the ``python`` or ``py`` commands do not seem to be working, please see " "the :ref:`Troubleshooting ` section below. There are " "sometimes additional manual steps required to configure your PC." msgstr "" -#: ../../using/windows.rst:49 +#: ../../using/windows.rst:47 msgid "" "Apart from using the Python install manager, Python can also be obtained as " "NuGet packages. See :ref:`windows-nuget` below for more information on these " "packages." msgstr "" -#: ../../using/windows.rst:53 +#: ../../using/windows.rst:51 msgid "" "The embeddable distros are minimal packages of Python suitable for embedding " "into larger applications. They can be installed using the Python install " @@ -89,35 +89,35 @@ msgid "" "packages." msgstr "" -#: ../../using/windows.rst:66 +#: ../../using/windows.rst:64 msgid "Python install manager" msgstr "Python 安裝管理員" -#: ../../using/windows.rst:69 +#: ../../using/windows.rst:67 msgid "Installation" msgstr "安裝" -#: ../../using/windows.rst:71 +#: ../../using/windows.rst:69 msgid "" "The Python install manager can be installed from the `Microsoft Store app`_ " "or downloaded and installed from `python.org/downloads`_. The two versions " "are identical." msgstr "" -#: ../../using/windows.rst:75 +#: ../../using/windows.rst:73 msgid "" "To install through the Store, simply click \"Install\". After it has " "completed, open a terminal and type ``python`` to get started." msgstr "" -#: ../../using/windows.rst:78 +#: ../../using/windows.rst:76 msgid "" "To install the file downloaded from python.org, either double-click and " "select \"Install\", or run ``Add-AppxPackage `` in Windows " "Powershell." msgstr "" -#: ../../using/windows.rst:81 +#: ../../using/windows.rst:79 msgid "" "After installation, the ``python``, ``py``, and ``pymanager`` commands " "should be available. If you have existing installations of Python, or you " @@ -126,7 +126,7 @@ msgid "" "fixing non-working commands." msgstr "" -#: ../../using/windows.rst:87 +#: ../../using/windows.rst:85 msgid "" "When you first install a runtime, you will likely be prompted to add a " "directory to your :envvar:`PATH`. This is optional, if you prefer to use the " @@ -137,20 +137,20 @@ msgid "" "for your account\" for the system settings page to add the path." msgstr "" -#: ../../using/windows.rst:95 +#: ../../using/windows.rst:93 msgid "" "Each Python runtime you install will have its own directory for scripts. " "These also need to be added to :envvar:`PATH` if you want to use them." msgstr "" -#: ../../using/windows.rst:98 +#: ../../using/windows.rst:96 msgid "" "The Python install manager will be automatically updated to new releases. " "This does not affect any installs of Python runtimes. Uninstalling the " "Python install manager does not uninstall any Python runtimes." msgstr "" -#: ../../using/windows.rst:102 +#: ../../using/windows.rst:100 msgid "" "If you are not able to install an MSIX in your context, for example, you are " "using automated deployment software that does not support it, or are " @@ -158,11 +158,11 @@ msgid "" "below for more information." msgstr "" -#: ../../using/windows.rst:109 +#: ../../using/windows.rst:107 msgid "Basic use" msgstr "基本使用" -#: ../../using/windows.rst:111 +#: ../../using/windows.rst:109 msgid "" "The recommended command for launching Python is ``python``, which will " "either launch the version requested by the script being launched, an active " @@ -172,7 +172,7 @@ msgid "" "latest release will be installed automatically." msgstr "" -#: ../../using/windows.rst:118 +#: ../../using/windows.rst:116 msgid "" "For all scenarios involving multiple runtime versions, the recommended " "command is ``py``. This may be used anywhere in place of ``python`` or the " @@ -182,7 +182,7 @@ msgid "" "below." msgstr "" -#: ../../using/windows.rst:124 +#: ../../using/windows.rst:122 msgid "" "Because the ``py`` command may already be taken by the previous version, " "there is also an unambiguous ``pymanager`` command. Scripted installs that " @@ -194,7 +194,7 @@ msgid "" "equivalent behaviour to ``py ...``)." msgstr "" -#: ../../using/windows.rst:132 +#: ../../using/windows.rst:130 msgid "" "Each of these commands also has a windowed version that avoids creating a " "console window. These are ``pyw``, ``pythonw`` and ``pywmanager``. A " @@ -203,14 +203,14 @@ msgid "" "Windows, but is not meant to be widely used or recommended." msgstr "" -#: ../../using/windows.rst:138 +#: ../../using/windows.rst:136 msgid "" "To launch your default runtime, run ``python`` or ``py`` with the arguments " "you want to be passed to the runtime (such as script files or the module to " "launch):" msgstr "" -#: ../../using/windows.rst:141 +#: ../../using/windows.rst:139 msgid "" "$> py\n" "...\n" @@ -226,14 +226,14 @@ msgstr "" "$> py -m this\n" "..." -#: ../../using/windows.rst:150 +#: ../../using/windows.rst:148 msgid "" "The default runtime can be overridden with the :envvar:" "`PYTHON_MANAGER_DEFAULT` environment variable, or a configuration file. See :" "ref:`pymanager-config` for information about configuration settings." msgstr "" -#: ../../using/windows.rst:154 +#: ../../using/windows.rst:152 msgid "" "To launch a specific runtime, the ``py`` command accepts a ``-V:`` " "option. This option must be specified before any others. The tag is part or " @@ -243,7 +243,7 @@ msgid "" "release and starts with ``3``." msgstr "" -#: ../../using/windows.rst:161 +#: ../../using/windows.rst:159 msgid "" "$> py -V:3.14 ...\n" "$> py -V:3-arm64 ..." @@ -251,7 +251,7 @@ msgstr "" "$> py -V:3.14 ...\n" "$> py -V:3-arm64 ..." -#: ../../using/windows.rst:166 +#: ../../using/windows.rst:164 msgid "" "Runtimes from other distributors may require the *company* to be included as " "well. It should be separated from the tag by a slash (either ``/`` or " @@ -261,7 +261,7 @@ msgid "" "specific company." msgstr "" -#: ../../using/windows.rst:174 +#: ../../using/windows.rst:172 msgid "" "$> py -V:Distributor\\1.0 ...\n" "$> py -V:distrib/ ..." @@ -269,7 +269,7 @@ msgstr "" "$> py -V:Distributor\\1.0 ...\n" "$> py -V:distrib/ ..." -#: ../../using/windows.rst:179 +#: ../../using/windows.rst:177 msgid "" "If no version is specified, but a script file is passed, the script will be " "inspected for a *shebang line*. This is a special format for the first line " @@ -278,7 +278,7 @@ msgid "" "resolved, the script will be launched with the default runtime." msgstr "" -#: ../../using/windows.rst:185 +#: ../../using/windows.rst:183 msgid "" "If you are running in an active virtual environment, have not requested a " "particular version, and there is no shebang line, the default runtime will " @@ -287,7 +287,7 @@ msgid "" "behaviour ensures that the ``py`` command can be used interchangeably." msgstr "" -#: ../../using/windows.rst:191 +#: ../../using/windows.rst:189 msgid "" "When no runtimes are installed, any launch command will try to install the " "requested version and launch it. However, after any version is installed, " @@ -296,18 +296,18 @@ msgid "" "error and direct you to use ``py install`` first." msgstr "" -#: ../../using/windows.rst:199 +#: ../../using/windows.rst:197 msgid "Command help" msgstr "" -#: ../../using/windows.rst:201 +#: ../../using/windows.rst:199 msgid "" "The ``py help`` command will display the full list of supported commands, " "along with their options. Any command may be passed the ``-?`` option to " "display its help, or its name passed to ``py help``." msgstr "" -#: ../../using/windows.rst:205 +#: ../../using/windows.rst:203 msgid "" "$> py help\n" "$> py help install\n" @@ -317,7 +317,7 @@ msgstr "" "$> py help install\n" "$> py install /?" -#: ../../using/windows.rst:212 +#: ../../using/windows.rst:210 msgid "" "All commands support some common options, which will be shown by ``py " "help``. These options must be specified after any subcommand. Specifying ``-" @@ -326,18 +326,18 @@ msgid "" "quiet`` will reduce output, and ``-qq`` will reduce it further." msgstr "" -#: ../../using/windows.rst:218 +#: ../../using/windows.rst:216 msgid "" "The ``--config=`` option allows specifying a configuration file to " "override multiple settings at once. See :ref:`pymanager-config` below for " "more information about these files." msgstr "" -#: ../../using/windows.rst:224 +#: ../../using/windows.rst:222 msgid "Listing runtimes" msgstr "列出 runtimes" -#: ../../using/windows.rst:226 +#: ../../using/windows.rst:224 msgid "" "$> py list [-f=|--format=] [-1|--one] [--online|-s=|--source=] " "[...]" @@ -345,7 +345,7 @@ msgstr "" "$> py list [-f=|--format=] [-1|--one] [--online|-s=|--source=] " "[...]" -#: ../../using/windows.rst:230 +#: ../../using/windows.rst:228 msgid "" "The list of installed runtimes can be seen using ``py list``. A filter may " "be added in the form of one or more tags (with or without company " @@ -353,7 +353,7 @@ msgid "" "restrict to a range." msgstr "" -#: ../../using/windows.rst:234 +#: ../../using/windows.rst:232 msgid "" "A range of formats are supported, and can be passed as the ``--" "format=`` or ``-f `` option. Formats include ``table`` (a user " @@ -362,7 +362,7 @@ msgid "" "executable path), ``prefix`` (just the prefix path)." msgstr "" -#: ../../using/windows.rst:240 +#: ../../using/windows.rst:238 msgid "" "The ``--one`` or ``-1`` option only displays a single result. If the default " "runtime is included, it will be the one. Otherwise, the \"best\" result is " @@ -371,14 +371,14 @@ msgid "" "the runtime that would be launched by ``py -V:``." msgstr "" -#: ../../using/windows.rst:246 +#: ../../using/windows.rst:244 msgid "" "The ``--only-managed`` option excludes results that were not installed by " "the Python install manager. This is useful when determining which runtimes " "may be updated or uninstalled through the ``py`` command." msgstr "" -#: ../../using/windows.rst:250 +#: ../../using/windows.rst:248 msgid "" "The ``--online`` option is short for passing ``--source=`` with the " "default source. Passing either of these options will search the online index " @@ -387,22 +387,22 @@ msgid "" "``." msgstr "" -#: ../../using/windows.rst:255 +#: ../../using/windows.rst:253 msgid "$> py list --online 3.14" msgstr "$> py list --online 3.14" -#: ../../using/windows.rst:259 +#: ../../using/windows.rst:257 msgid "" "For compatibility with the old launcher, the ``--list``, ``--list-paths``, " "``-0`` and ``-0p`` commands (e.g. ``py -0p``) are retained. They do not " "allow additional options, and will produce legacy formatted output." msgstr "" -#: ../../using/windows.rst:265 +#: ../../using/windows.rst:263 msgid "Installing runtimes" msgstr "安裝 runtimes" -#: ../../using/windows.rst:267 +#: ../../using/windows.rst:265 msgid "" "$> py install [-s=|--source=] [-f|--force] [-u|--update] [--dry-run] " "[...]" @@ -410,27 +410,27 @@ msgstr "" "$> py install [-s=|--source=] [-f|--force] [-u|--update] [--dry-run] " "[...]" -#: ../../using/windows.rst:271 +#: ../../using/windows.rst:269 msgid "" "New runtime versions may be added using ``py install``. One or more tags may " "be specified, and the special tag ``default`` may be used to select the " "default. Ranges are not supported for installation." msgstr "" -#: ../../using/windows.rst:275 +#: ../../using/windows.rst:273 msgid "" "The ``--source=`` option allows overriding the online index that is " "used to obtain runtimes. This may be used with an offline index, as shown " "in :ref:`pymanager-offline`." msgstr "" -#: ../../using/windows.rst:279 +#: ../../using/windows.rst:277 msgid "" "Passing ``--force`` will ignore any cached files and remove any existing " "install to replace it with the specified one." msgstr "" -#: ../../using/windows.rst:282 +#: ../../using/windows.rst:280 msgid "" "Passing ``--update`` will replace existing installs if the new version is " "newer. Otherwise, they will be left. If no tags are provided with ``--" @@ -440,13 +440,13 @@ msgid "" "environments will continue to work." msgstr "" -#: ../../using/windows.rst:289 +#: ../../using/windows.rst:287 msgid "" "Passing ``--dry-run`` will generate output and logs, but will not modify any " "installs." msgstr "" -#: ../../using/windows.rst:292 +#: ../../using/windows.rst:290 msgid "" "Passing ``--refresh`` will update all registrations for installed runtimes. " "This will recreate Start menu shortcuts, registry keys, and global aliases " @@ -455,7 +455,7 @@ msgid "" "manually refreshed after installing packages." msgstr "" -#: ../../using/windows.rst:298 +#: ../../using/windows.rst:296 msgid "" "In addition to the above options, the ``--target`` option will extract the " "runtime to the specified directory instead of doing a normal install. This " @@ -466,11 +466,11 @@ msgid "" "directory." msgstr "" -#: ../../using/windows.rst:306 +#: ../../using/windows.rst:304 msgid "$> py install ... [-t=|--target=] " msgstr "$> py install ... [-t=|--target=] " -#: ../../using/windows.rst:310 +#: ../../using/windows.rst:308 msgid "" "The ``py exec`` command will install the requested runtime if it is not " "already present. This is controlled by the ``automatic_install`` " @@ -481,21 +481,21 @@ msgid "" "rather than using the ``py exec`` command or explicit install commands." msgstr "" -#: ../../using/windows.rst:322 +#: ../../using/windows.rst:320 msgid "Offline installs" msgstr "離線安裝" -#: ../../using/windows.rst:324 +#: ../../using/windows.rst:322 msgid "" "To perform offline installs of Python, you will need to first create an " "offline index on a machine that has network access." msgstr "" -#: ../../using/windows.rst:327 +#: ../../using/windows.rst:325 msgid "$> py install --download= ... ..." msgstr "$> py install --download= ... ..." -#: ../../using/windows.rst:331 +#: ../../using/windows.rst:329 msgid "" "The ``--download=`` option will download the packages for the listed " "tags and create a directory containing them and an ``index.json`` file " @@ -503,17 +503,17 @@ msgid "" "offline machine and used to install one or more of the bundled runtimes:" msgstr "" -#: ../../using/windows.rst:336 +#: ../../using/windows.rst:334 msgid "$> py install --source=\"\\index.json\" ..." msgstr "$> py install --source=\"\\index.json\" ..." -#: ../../using/windows.rst:340 +#: ../../using/windows.rst:338 msgid "" "The Python install manager can be installed by downloading its installer and " "moving it to another machine before installing." msgstr "" -#: ../../using/windows.rst:343 +#: ../../using/windows.rst:341 msgid "" "Alternatively, the ZIP files in an offline index directory can simply be " "transferred to another machine and extracted. This will not register the " @@ -523,32 +523,32 @@ msgid "" "possible or convenient." msgstr "" -#: ../../using/windows.rst:349 +#: ../../using/windows.rst:347 msgid "" "In this way, Python runtimes can be installed and managed on a machine " "without access to the internet." msgstr "" -#: ../../using/windows.rst:354 +#: ../../using/windows.rst:352 msgid "Uninstalling runtimes" msgstr "解除安裝 runtimes" -#: ../../using/windows.rst:356 +#: ../../using/windows.rst:354 msgid "$> py uninstall [-y|--yes] ..." msgstr "$> py uninstall [-y|--yes] ..." -#: ../../using/windows.rst:360 +#: ../../using/windows.rst:358 msgid "" "Runtimes may be removed using the ``py uninstall`` command. One or more tags " "must be specified. Ranges are not supported here." msgstr "" -#: ../../using/windows.rst:363 +#: ../../using/windows.rst:361 msgid "" "The ``--yes`` option bypasses the confirmation prompt before uninstalling." msgstr "" -#: ../../using/windows.rst:365 +#: ../../using/windows.rst:363 msgid "" "Instead of passing tags individually, the ``--purge`` option may be " "specified. This will remove all runtimes managed by the Python install " @@ -557,11 +557,11 @@ msgid "" "not be impacted, and neither will manually created configuration files." msgstr "" -#: ../../using/windows.rst:371 +#: ../../using/windows.rst:369 msgid "$> py uninstall [-y|--yes] --purge" msgstr "" -#: ../../using/windows.rst:375 +#: ../../using/windows.rst:373 msgid "" "The Python install manager can be uninstalled through the Windows " "\"Installed apps\" settings page. This does not remove any runtimes, and " @@ -571,11 +571,11 @@ msgid "" "with ``--purge`` before uninstalling the Python install manager." msgstr "" -#: ../../using/windows.rst:385 +#: ../../using/windows.rst:383 msgid "Configuration" msgstr "設定" -#: ../../using/windows.rst:387 +#: ../../using/windows.rst:385 msgid "" "Python install manager is configured with a hierarchy of configuration " "files, environment variables, command-line options, and registry settings. " @@ -585,13 +585,13 @@ msgid "" "options override all other settings, but not every option is available." msgstr "" -#: ../../using/windows.rst:394 +#: ../../using/windows.rst:392 msgid "" "This section will describe the defaults, but be aware that modified or " "overridden installs may resolve settings differently." msgstr "" -#: ../../using/windows.rst:397 +#: ../../using/windows.rst:395 msgid "" "A global configuration file may be configured by an administrator, and would " "be read first. The user configuration file is stored at :file:`%AppData%\\" @@ -603,50 +603,50 @@ msgid "" "administrative customization options listed later." msgstr "" -#: ../../using/windows.rst:407 +#: ../../using/windows.rst:405 msgid "" "The following settings are those that are considered likely to be modified " "in normal use. Later sections list those that are intended for " "administrative customization." msgstr "" -#: ../../using/windows.rst:415 +#: ../../using/windows.rst:413 msgid "Standard configuration options" msgstr "" -#: ../../using/windows.rst:419 ../../using/windows.rst:756 +#: ../../using/windows.rst:417 ../../using/windows.rst:754 msgid "Config Key" msgstr "" -#: ../../using/windows.rst:420 +#: ../../using/windows.rst:418 msgid "Environment Variable" msgstr "" -#: ../../using/windows.rst:421 ../../using/windows.rst:757 -#: ../../using/windows.rst:1624 ../../using/windows.rst:1644 -#: ../../using/windows.rst:2234 +#: ../../using/windows.rst:419 ../../using/windows.rst:755 +#: ../../using/windows.rst:1628 ../../using/windows.rst:1648 +#: ../../using/windows.rst:2238 msgid "Description" msgstr "描述" -#: ../../using/windows.rst:423 +#: ../../using/windows.rst:421 msgid "``default_tag``" msgstr "``default_tag``" -#: ../../using/windows.rst:425 +#: ../../using/windows.rst:423 msgid "" "The preferred default version to launch or install. By default, this is " "interpreted as the most recent non-prerelease version from the CPython team." msgstr "" -#: ../../using/windows.rst:429 +#: ../../using/windows.rst:427 msgid "``default_platform``" msgstr "``default_platform``" -#: ../../using/windows.rst:430 +#: ../../using/windows.rst:428 msgid "``PYTHON_MANAGER_DEFAULT_PLATFORM``" msgstr "``PYTHON_MANAGER_DEFAULT_PLATFORM``" -#: ../../using/windows.rst:431 +#: ../../using/windows.rst:429 msgid "" "The preferred default platform to launch or install. This is treated as a " "suffix to the specified tag, such that ``py -V:3.14`` would prefer an " @@ -654,83 +654,83 @@ msgid "" "but will use ``3.14`` if no tagged install exists." msgstr "" -#: ../../using/windows.rst:437 +#: ../../using/windows.rst:435 msgid "``logs_dir``" msgstr "``logs_dir``" -#: ../../using/windows.rst:438 +#: ../../using/windows.rst:436 msgid "``PYTHON_MANAGER_LOGS``" msgstr "``PYTHON_MANAGER_LOGS``" -#: ../../using/windows.rst:439 +#: ../../using/windows.rst:437 msgid "The location where log files are written. By default, :file:`%TEMP%`." msgstr "" -#: ../../using/windows.rst:442 +#: ../../using/windows.rst:440 msgid "``automatic_install``" msgstr "``automatic_install``" -#: ../../using/windows.rst:444 +#: ../../using/windows.rst:442 msgid "" "True to allow automatic installs when using ``py exec`` to launch (or ``py`` " "when no runtimes are installed yet). Other commands will not automatically " "install, regardless of this setting. By default, true." msgstr "" -#: ../../using/windows.rst:450 +#: ../../using/windows.rst:448 msgid "``include_unmanaged``" msgstr "``include_unmanaged``" -#: ../../using/windows.rst:451 +#: ../../using/windows.rst:449 msgid "``PYTHON_MANAGER_INCLUDE_UNMANAGED``" msgstr "``PYTHON_MANAGER_INCLUDE_UNMANAGED``" -#: ../../using/windows.rst:452 +#: ../../using/windows.rst:450 msgid "" "True to allow listing and launching runtimes that were not installed by the " "Python install manager, or false to exclude them. By default, true." msgstr "" -#: ../../using/windows.rst:456 +#: ../../using/windows.rst:454 msgid "``shebang_can_run_anything``" msgstr "``shebang_can_run_anything``" -#: ../../using/windows.rst:457 +#: ../../using/windows.rst:455 msgid "``PYTHON_MANAGER_SHEBANG_CAN_RUN_ANYTHING``" msgstr "``PYTHON_MANAGER_SHEBANG_CAN_RUN_ANYTHING``" -#: ../../using/windows.rst:458 +#: ../../using/windows.rst:456 msgid "" "True to allow shebangs in ``.py`` files to launch applications other than " "Python runtimes, or false to prevent it. By default, true." msgstr "" -#: ../../using/windows.rst:462 +#: ../../using/windows.rst:460 msgid "``shebang_templates``" msgstr "" -#: ../../using/windows.rst:463 ../../using/windows.rst:487 -#: ../../using/windows.rst:500 ../../using/windows.rst:506 -#: ../../using/windows.rst:513 +#: ../../using/windows.rst:461 ../../using/windows.rst:485 +#: ../../using/windows.rst:498 ../../using/windows.rst:504 +#: ../../using/windows.rst:511 msgid "(none)" msgstr "(none)" -#: ../../using/windows.rst:464 +#: ../../using/windows.rst:462 msgid "" "Mapping from shebang line template to alternative command, such as ``py -V:" "`` or a substitute string. See :ref:`pymanager-shebang` for more " "details." msgstr "" -#: ../../using/windows.rst:468 +#: ../../using/windows.rst:466 msgid "``log_level``" msgstr "``log_level``" -#: ../../using/windows.rst:469 +#: ../../using/windows.rst:467 msgid "``PYMANAGER_VERBOSE``, ``PYMANAGER_DEBUG``" msgstr "``PYMANAGER_VERBOSE``、``PYMANAGER_DEBUG``" -#: ../../using/windows.rst:470 +#: ../../using/windows.rst:468 msgid "" "Set the default level of output (0-50). By default, 20. Lower values produce " "more output. The environment variables are boolean, and may produce " @@ -738,37 +738,37 @@ msgid "" "configuration." msgstr "" -#: ../../using/windows.rst:476 +#: ../../using/windows.rst:474 msgid "``confirm``" msgstr "``confirm``" -#: ../../using/windows.rst:477 +#: ../../using/windows.rst:475 msgid "``PYTHON_MANAGER_CONFIRM``" msgstr "``PYTHON_MANAGER_CONFIRM``" -#: ../../using/windows.rst:478 +#: ../../using/windows.rst:476 msgid "" "True to confirm certain actions before taking them (such as uninstall), or " "false to skip the confirmation. By default, true." msgstr "" -#: ../../using/windows.rst:482 +#: ../../using/windows.rst:480 msgid "``install.source``" msgstr "``install.source``" -#: ../../using/windows.rst:483 +#: ../../using/windows.rst:481 msgid "``PYTHON_MANAGER_SOURCE_URL``" msgstr "``PYTHON_MANAGER_SOURCE_URL``" -#: ../../using/windows.rst:484 +#: ../../using/windows.rst:482 msgid "Override the index feed to obtain new installs from." msgstr "" -#: ../../using/windows.rst:486 +#: ../../using/windows.rst:484 msgid "``install.enable_entrypoints``" msgstr "``install.enable_entrypoints``" -#: ../../using/windows.rst:488 +#: ../../using/windows.rst:486 msgid "" "True to generate global commands for installed packages (such as ``pip." "exe``). These are defined by the packages themselves. If set to false, only " @@ -776,63 +776,63 @@ msgid "" "should run ``py install --refresh`` after changing this setting." msgstr "" -#: ../../using/windows.rst:494 +#: ../../using/windows.rst:492 msgid "``list.format``" msgstr "``list.format``" -#: ../../using/windows.rst:495 +#: ../../using/windows.rst:493 msgid "``PYTHON_MANAGER_LIST_FORMAT``" msgstr "``PYTHON_MANAGER_LIST_FORMAT``" -#: ../../using/windows.rst:496 +#: ../../using/windows.rst:494 msgid "" "Specify the default format used by the ``py list`` command. By default, " "``table``." msgstr "" -#: ../../using/windows.rst:499 +#: ../../using/windows.rst:497 msgid "``install_dir``" msgstr "``install_dir``" -#: ../../using/windows.rst:501 +#: ../../using/windows.rst:499 msgid "" "Specify the root directory that runtimes will be installed into. If you " "change this setting, previously installed runtimes will not be usable unless " "you move them to the new location." msgstr "" -#: ../../using/windows.rst:505 +#: ../../using/windows.rst:503 msgid "``global_dir``" msgstr "``global_dir``" -#: ../../using/windows.rst:507 +#: ../../using/windows.rst:505 msgid "" "Specify the directory where global commands (such as ``python3.14.exe`` and " "``pip.exe``) are stored. This directory should be added to your :envvar:" "`PATH` to make the commands available from your terminal." msgstr "" -#: ../../using/windows.rst:512 +#: ../../using/windows.rst:510 msgid "``download_dir``" msgstr "``download_dir``" -#: ../../using/windows.rst:514 +#: ../../using/windows.rst:512 msgid "" "Specify the directory where downloaded files are stored. This directory is a " "temporary cache, and can be cleaned up from time to time." msgstr "" -#: ../../using/windows.rst:519 +#: ../../using/windows.rst:517 msgid "" "Dotted names should be nested inside JSON objects, for example, ``list." "format`` would be specified as ``{\"list\": {\"format\": \"table\"}}``." msgstr "" -#: ../../using/windows.rst:525 ../../using/windows.rst:1990 +#: ../../using/windows.rst:523 ../../using/windows.rst:1994 msgid "Shebang lines" msgstr "" -#: ../../using/windows.rst:527 +#: ../../using/windows.rst:525 msgid "" "If the first line of a script file starts with ``#!``, it is known as a " "\"shebang\" line. Linux and other Unix like operating systems have native " @@ -841,42 +841,42 @@ msgid "" "allow the same facilities to be used with Python scripts on Windows." msgstr "" -#: ../../using/windows.rst:533 +#: ../../using/windows.rst:531 msgid "" "To allow shebang lines in Python scripts to be portable between Unix and " "Windows, a number of 'virtual' commands are supported to specify which " "interpreter to use. The supported virtual commands are:" msgstr "" -#: ../../using/windows.rst:537 +#: ../../using/windows.rst:535 msgid "``/usr/bin/env ``" msgstr "``/usr/bin/env ``" -#: ../../using/windows.rst:538 +#: ../../using/windows.rst:536 msgid "``/usr/bin/env -S ``" msgstr "``/usr/bin/env -S ``" -#: ../../using/windows.rst:539 +#: ../../using/windows.rst:537 msgid "``/usr/bin/``" msgstr "``/usr/bin/``" -#: ../../using/windows.rst:540 +#: ../../using/windows.rst:538 msgid "``/usr/local/bin/``" msgstr "``/usr/local/bin/``" -#: ../../using/windows.rst:541 +#: ../../using/windows.rst:539 msgid "````" msgstr "````" -#: ../../using/windows.rst:543 ../../using/windows.rst:2008 +#: ../../using/windows.rst:541 ../../using/windows.rst:2012 msgid "For example, if the first line of your script starts with" msgstr "" -#: ../../using/windows.rst:545 ../../using/windows.rst:2010 +#: ../../using/windows.rst:543 ../../using/windows.rst:2014 msgid "#! /usr/bin/python" msgstr "#! /usr/bin/python" -#: ../../using/windows.rst:549 ../../using/windows.rst:2014 +#: ../../using/windows.rst:547 ../../using/windows.rst:2018 msgid "" "The default Python or an active virtual environment will be located and " "used. As many Python scripts written to work on Unix will already have this " @@ -886,7 +886,7 @@ msgid "" "usr``." msgstr "" -#: ../../using/windows.rst:555 +#: ../../using/windows.rst:553 msgid "" "Any of the above virtual commands can have ```` replaced by an alias " "from an installed runtime. That is, any command generated in the global " @@ -896,14 +896,14 @@ msgid "" "to select a particular runtime." msgstr "" -#: ../../using/windows.rst:561 +#: ../../using/windows.rst:559 msgid "" "If no runtimes are installed, or if automatic installation is enabled, the " "requested runtime will be installed if necessary. See :ref:`pymanager-" "config` for information about configuration settings." msgstr "" -#: ../../using/windows.rst:565 +#: ../../using/windows.rst:563 msgid "" "The ``/usr/bin/env`` form of shebang line will also search the :envvar:" "`PATH` environment variable for unrecognized commands. This corresponds to " @@ -913,7 +913,7 @@ msgid "" "``shebang_can_run_anything`` configuration option." msgstr "" -#: ../../using/windows.rst:572 +#: ../../using/windows.rst:570 msgid "" "Shebang lines that do not match any of patterns are treated as *Windows* " "executable paths that are absolute or relative to the directory containing " @@ -925,7 +925,7 @@ msgid "" "``shebang_can_run_anything`` configuration option." msgstr "" -#: ../../using/windows.rst:581 +#: ../../using/windows.rst:579 msgid "" "Since version 26.3 of the Python install manager, custom shebang templates " "may be added to your configuration file. Add the ``shebang_templates`` " @@ -936,7 +936,7 @@ msgid "" "default. No other arguments are supported." msgstr "" -#: ../../using/windows.rst:589 +#: ../../using/windows.rst:587 msgid "" "{\n" " \"shebang_templates\": {\n" @@ -946,7 +946,7 @@ msgid "" "}" msgstr "" -#: ../../using/windows.rst:598 +#: ../../using/windows.rst:596 msgid "" "If the substitute command is not ``py`` or ``pyw``, it will be written back " "into the shebang and regular handling continues. If launching arbitrary " @@ -956,7 +956,7 @@ msgid "" "space in the shebang line." msgstr "" -#: ../../using/windows.rst:607 +#: ../../using/windows.rst:605 msgid "" "The behaviour of shebangs in the Python install manager is subtly different " "from the previous ``py.exe`` launcher, and the old configuration options no " @@ -966,11 +966,11 @@ msgid "" "will need to use ``pymanager`` commands for installing and uninstalling." msgstr "" -#: ../../using/windows.rst:625 +#: ../../using/windows.rst:623 msgid "Advanced installation" msgstr "進階安裝" -#: ../../using/windows.rst:627 +#: ../../using/windows.rst:625 msgid "" "For situations where an MSIX cannot be installed, such as some older " "administrative distribution platforms, there is an MSI available from the " @@ -981,13 +981,13 @@ msgid "" "configuration." msgstr "" -#: ../../using/windows.rst:636 +#: ../../using/windows.rst:634 msgid "" "Windows Server 2019 is the only version of Windows that CPython supports " "that does not support MSIX. For Windows Server 2019, you should use the MSI." msgstr "" -#: ../../using/windows.rst:639 +#: ../../using/windows.rst:637 msgid "" "Be aware that the MSI package does not bundle any runtimes, and so is not " "suitable for installs into offline environments without also creating an " @@ -995,7 +995,7 @@ msgid "" "admin-config` for information on handling these scenarios." msgstr "" -#: ../../using/windows.rst:644 +#: ../../using/windows.rst:642 msgid "" "Runtimes installed by the MSI are shared with those installed by the MSIX, " "and are all per-user only. The Python install manager does not support " @@ -1005,7 +1005,7 @@ msgid "" "menu." msgstr "" -#: ../../using/windows.rst:650 +#: ../../using/windows.rst:648 msgid "" "When the MSIX is installed, but commands are not available in the :envvar:" "`PATH` environment variable, they can be found under :file:`%LocalAppData%\\" @@ -1017,13 +1017,13 @@ msgid "" "recommended." msgstr "" -#: ../../using/windows.rst:659 +#: ../../using/windows.rst:657 msgid "" "To programmatically install the Python install manager, it is easiest to use " "WinGet, which is included with all supported versions of Windows:" msgstr "" -#: ../../using/windows.rst:662 +#: ../../using/windows.rst:660 msgid "" "$> winget install 9NQ7512CXL7T -e --accept-package-agreements --disable-" "interactivity\n" @@ -1032,7 +1032,7 @@ msgid "" "$> py install --configure -y" msgstr "" -#: ../../using/windows.rst:669 +#: ../../using/windows.rst:667 msgid "" "To download the Python install manager and install on another machine, the " "following WinGet command will download the required files from the Store to " @@ -1042,20 +1042,20 @@ msgid "" "below." msgstr "" -#: ../../using/windows.rst:675 +#: ../../using/windows.rst:673 msgid "" "$> winget download 9NQ7512CXL7T -e --skip-license --accept-package-" "agreements --accept-source-agreements" msgstr "" -#: ../../using/windows.rst:679 +#: ../../using/windows.rst:677 msgid "" "To programmatically install or uninstall an MSIX using only PowerShell, the " "`Add-AppxPackage`_ and `Remove-AppxPackage`_ PowerShell cmdlets are " "recommended:" msgstr "" -#: ../../using/windows.rst:682 +#: ../../using/windows.rst:680 msgid "" "$> Add-AppxPackage C:\\Downloads\\python-manager-25.0.msix\n" "...\n" @@ -1067,7 +1067,7 @@ msgstr "" "$> Get-AppxPackage PythonSoftwareFoundation.PythonManager | Remove-" "AppxPackage" -#: ../../using/windows.rst:688 +#: ../../using/windows.rst:686 msgid "" "The latest release can be downloaded and installed by Windows by passing the " "AppInstaller file to the Add-AppxPackage command. This installs using the " @@ -1075,7 +1075,7 @@ msgid "" "the Store (interactively or using WinGet) is not possible." msgstr "" -#: ../../using/windows.rst:693 +#: ../../using/windows.rst:691 msgid "" "$> Add-AppxPackage -AppInstallerFile https://www.python.org/ftp/python/" "pymanager/pymanager.appinstaller" @@ -1083,7 +1083,7 @@ msgstr "" "$> Add-AppxPackage -AppInstallerFile https://www.python.org/ftp/python/" "pymanager/pymanager.appinstaller" -#: ../../using/windows.rst:697 +#: ../../using/windows.rst:695 msgid "" "Other tools and APIs may also be used to provision an MSIX package for all " "users on a machine, but Python does not consider this a supported scenario. " @@ -1092,7 +1092,7 @@ msgid "" "for your deployment tool." msgstr "" -#: ../../using/windows.rst:703 +#: ../../using/windows.rst:701 msgid "" "Regardless of the install method, users will still need to install their own " "copies of Python itself, as there is no way to trigger those installs " @@ -1100,7 +1100,7 @@ msgid "" "Python will be available for all users to install without network access." msgstr "" -#: ../../using/windows.rst:708 +#: ../../using/windows.rst:706 msgid "" "Note that the MSIX downloadable from the Store and from the Python website " "are subtly different and cannot be installed at the same time. Wherever " @@ -1110,11 +1110,11 @@ msgid "" "prevent using the Store package in this way." msgstr "" -#: ../../using/windows.rst:719 +#: ../../using/windows.rst:717 msgid "Administrative configuration" msgstr "" -#: ../../using/windows.rst:721 +#: ../../using/windows.rst:719 msgid "" "There are a number of options that may be useful for administrators to " "override configuration of the Python install manager. These can be used to " @@ -1123,7 +1123,7 @@ msgid "" "below." msgstr "" -#: ../../using/windows.rst:726 +#: ../../using/windows.rst:724 msgid "" "Configuration options may be overridden in the registry by setting values " "under :file:`HKEY_LOCAL_MACHINE\\\\Software\\\\Policies\\\\Python\\" @@ -1136,7 +1136,7 @@ msgid "" "``base_config`` allows users to further modify settings they may need." msgstr "" -#: ../../using/windows.rst:736 +#: ../../using/windows.rst:734 msgid "" "Note that most settings with environment variables support those variables " "because their default setting specifies the variable. If you override them, " @@ -1148,95 +1148,95 @@ msgid "" "environment variable will be used instead." msgstr "" -#: ../../using/windows.rst:745 +#: ../../using/windows.rst:743 msgid "" "Configuration settings that are paths are interpreted as relative to the " "directory containing the configuration file that specified them." msgstr "" -#: ../../using/windows.rst:752 +#: ../../using/windows.rst:750 msgid "Administrative configuration options" msgstr "" -#: ../../using/windows.rst:759 +#: ../../using/windows.rst:757 msgid "``base_config``" msgstr "``base_config``" -#: ../../using/windows.rst:760 +#: ../../using/windows.rst:758 msgid "" "The highest priority configuration file to read. Note that only the built-in " "configuration file and the registry can modify this setting." msgstr "" -#: ../../using/windows.rst:764 +#: ../../using/windows.rst:762 msgid "``user_config``" msgstr "``user_config``" -#: ../../using/windows.rst:765 +#: ../../using/windows.rst:763 msgid "The second configuration file to read." msgstr "" -#: ../../using/windows.rst:767 +#: ../../using/windows.rst:765 msgid "``additional_config``" msgstr "``additional_config``" -#: ../../using/windows.rst:768 +#: ../../using/windows.rst:766 msgid "The third configuration file to read." msgstr "" -#: ../../using/windows.rst:770 +#: ../../using/windows.rst:768 msgid "``registry_override_key``" msgstr "``registry_override_key``" -#: ../../using/windows.rst:771 +#: ../../using/windows.rst:769 msgid "" "Registry location to check for overrides. Note that only the built-in " "configuration file can modify this setting." msgstr "" -#: ../../using/windows.rst:774 +#: ../../using/windows.rst:772 msgid "``bundled_dir``" msgstr "``bundled_dir``" -#: ../../using/windows.rst:775 +#: ../../using/windows.rst:773 msgid "Read-only directory containing locally cached files." msgstr "" -#: ../../using/windows.rst:777 +#: ../../using/windows.rst:775 msgid "``install.fallback_source``" msgstr "``install.fallback_source``" -#: ../../using/windows.rst:778 +#: ../../using/windows.rst:776 msgid "" "Path or URL to an index to consult when the main index cannot be accessed." msgstr "" -#: ../../using/windows.rst:780 +#: ../../using/windows.rst:778 msgid "``install.enable_shortcut_kinds``" msgstr "``install.enable_shortcut_kinds``" -#: ../../using/windows.rst:781 +#: ../../using/windows.rst:779 msgid "" "Comma-separated list of shortcut kinds to allow (e.g. ``\"pep514,start\"``). " "Enabled shortcuts may still be disabled by ``disable_shortcut_kinds``." msgstr "" -#: ../../using/windows.rst:784 +#: ../../using/windows.rst:782 msgid "``install.disable_shortcut_kinds``" msgstr "``install.disable_shortcut_kinds``" -#: ../../using/windows.rst:785 +#: ../../using/windows.rst:783 msgid "" "Comma-separated list of shortcut kinds to exclude (e.g. ``\"pep514," "start\"``). Disabled shortcuts are not reactivated by " "``enable_shortcut_kinds``." msgstr "" -#: ../../using/windows.rst:789 +#: ../../using/windows.rst:787 msgid "``install.hard_link_entrypoints``" msgstr "" -#: ../../using/windows.rst:790 +#: ../../using/windows.rst:788 msgid "" "True to use hard links for global shortcuts to save disk space. If false, " "each shortcut executable is copied instead. After changing this setting, you " @@ -1245,51 +1245,51 @@ msgid "" "systems that have issues with file links." msgstr "" -#: ../../using/windows.rst:797 +#: ../../using/windows.rst:795 msgid "``pep514_root``" msgstr "``pep514_root``" -#: ../../using/windows.rst:798 +#: ../../using/windows.rst:796 msgid "" "Registry location to read and write PEP 514 entries into. By default, :file:" "`HKEY_CURRENT_USER\\\\Software\\\\Python`." msgstr "" -#: ../../using/windows.rst:801 +#: ../../using/windows.rst:799 msgid "``start_folder``" msgstr "``start_folder``" -#: ../../using/windows.rst:802 +#: ../../using/windows.rst:800 msgid "" "Start menu folder to write shortcuts into. By default, ``Python``. This path " "is relative to the user's Programs folder." msgstr "" -#: ../../using/windows.rst:806 +#: ../../using/windows.rst:804 msgid "``virtual_env``" msgstr "``virtual_env``" -#: ../../using/windows.rst:807 +#: ../../using/windows.rst:805 msgid "" "Path to the active virtual environment. By default, this is " "``%VIRTUAL_ENV%``, but may be set empty to disable venv detection." msgstr "" -#: ../../using/windows.rst:811 +#: ../../using/windows.rst:809 msgid "``shebang_can_run_anything_silently``" msgstr "``shebang_can_run_anything_silently``" -#: ../../using/windows.rst:812 +#: ../../using/windows.rst:810 msgid "" "True to suppress visible warnings when a shebang launches an application " "other than a Python runtime." msgstr "" -#: ../../using/windows.rst:815 +#: ../../using/windows.rst:813 msgid "``source_settings``" msgstr "" -#: ../../using/windows.rst:816 +#: ../../using/windows.rst:814 msgid "" "A mapping from source URL to settings specific to that index. When multiple " "configuration files include this section, URL settings are added or " @@ -1297,17 +1297,17 @@ msgid "" "currently only for :ref:`index signatures `." msgstr "" -#: ../../using/windows.rst:826 ../../using/windows.rst:1803 +#: ../../using/windows.rst:824 ../../using/windows.rst:1807 msgid "Installing free-threaded binaries" msgstr "" -#: ../../using/windows.rst:830 +#: ../../using/windows.rst:828 msgid "" "Pre-built distributions of the free-threaded build are available by " "installing tags with the ``t`` suffix." msgstr "" -#: ../../using/windows.rst:833 +#: ../../using/windows.rst:831 msgid "" "$> py install 3.14t\n" "$> py install 3.14t-arm64\n" @@ -1317,7 +1317,7 @@ msgstr "" "$> py install 3.14t-arm64\n" "$> py install 3.14t-32" -#: ../../using/windows.rst:839 +#: ../../using/windows.rst:837 msgid "" "This will install and register as normal. If you have no other runtimes " "installed, then ``python`` will launch this one. Otherwise, you will need to " @@ -1326,11 +1326,11 @@ msgid "" "commands." msgstr "" -#: ../../using/windows.rst:848 +#: ../../using/windows.rst:846 msgid "Index signatures" msgstr "" -#: ../../using/windows.rst:852 +#: ../../using/windows.rst:850 msgid "" "Index files may be signed to detect tampering. A signature is a catalog file " "at the same URL as the index with ``.cat`` added to the filename. The " @@ -1341,7 +1341,7 @@ msgid "" "authority (root CA)." msgstr "" -#: ../../using/windows.rst:859 +#: ../../using/windows.rst:857 msgid "" "Index signatures are only downloaded and checked when the local " "configuration's ``source_settings`` section includes the index URL and " @@ -1350,7 +1350,7 @@ msgid "" "configuration, even when false, settings in the index are ignored." msgstr "" -#: ../../using/windows.rst:865 +#: ../../using/windows.rst:863 msgid "" "As well as requiring a valid signature, the ``required_root_subject`` and " "``required_publisher_subject`` settings can further restrict acceptable " @@ -1361,7 +1361,7 @@ msgid "" "publisher's country." msgstr "" -#: ../../using/windows.rst:873 +#: ../../using/windows.rst:871 msgid "" "Finally, the ``required_publisher_eku`` setting allows requiring that a " "specific Enhanced Key Usage (EKU) has been assigned to the publisher " @@ -1371,7 +1371,7 @@ msgid "" "another mechanism to verify a legitimate signature." msgstr "" -#: ../../using/windows.rst:880 +#: ../../using/windows.rst:878 msgid "" "This is an example ``source_settings`` section from a configuration file. In " "this case, the publisher of the feed is uniquely identified by the " @@ -1380,7 +1380,7 @@ msgid "" "python.org/ftp/python/index-windows.json.cat``." msgstr "" -#: ../../using/windows.rst:886 +#: ../../using/windows.rst:884 msgid "" "{\n" " \"source_settings\": {\n" @@ -1396,7 +1396,7 @@ msgid "" "}" msgstr "" -#: ../../using/windows.rst:899 +#: ../../using/windows.rst:897 msgid "" "The same settings could be specified in the ``index.json`` file instead. In " "this case, the root and EKU are omitted, meaning that the signature must be " @@ -1404,7 +1404,7 @@ msgid "" "other checks are used." msgstr "" -#: ../../using/windows.rst:904 +#: ../../using/windows.rst:902 msgid "" "{\n" " \"requires_signature\": true,\n" @@ -1415,7 +1415,7 @@ msgid "" "}" msgstr "" -#: ../../using/windows.rst:914 +#: ../../using/windows.rst:912 msgid "" "When settings from inside a feed are used, the user is notified and the " "settings are shown in the log file or verbose output. It is recommended to " @@ -1424,7 +1424,7 @@ msgid "" "disable verification." msgstr "" -#: ../../using/windows.rst:919 +#: ../../using/windows.rst:917 msgid "" "It is not possible to override the location of the signature file in the " "feed or through a configuration file. Administrators can provide their own " @@ -1432,7 +1432,7 @@ msgid "" "admin-config`)." msgstr "" -#: ../../using/windows.rst:924 +#: ../../using/windows.rst:922 msgid "" "If signature validation fails, you will be notified and prompted to " "continue. When interactive confirmation is not allowed (for example, because " @@ -1441,7 +1441,7 @@ msgid "" "disables signature checking for that feed." msgstr "" -#: ../../using/windows.rst:930 +#: ../../using/windows.rst:928 msgid "" "\"source_settings\": {\n" " \"https://www.example.com/feed-with-invalid-signature.json\": {\n" @@ -1450,18 +1450,18 @@ msgid "" "}" msgstr "" -#: ../../using/windows.rst:940 +#: ../../using/windows.rst:938 msgid "Proxy settings" msgstr "" -#: ../../using/windows.rst:944 +#: ../../using/windows.rst:942 msgid "" "By default, the Python install manager will use your system-wide proxy " "settings, including automatic authentication. For most users, this behaves " "the same as your browser and other applications." msgstr "" -#: ../../using/windows.rst:948 +#: ../../using/windows.rst:946 msgid "" "To override the settings, use the ``NO_PROXY``, ``HTTP_PROXY`` and " "``HTTPS_PROXY`` environment variables. These should be set in the terminal " @@ -1470,14 +1470,14 @@ msgid "" "entire machine." msgstr "" -#: ../../using/windows.rst:954 +#: ../../using/windows.rst:952 msgid "" "Setting ``NO_PROXY`` to any non-empty value will disable the use of any " "proxy. Use this to bypass your system's default proxy setting and attempt to " "access the index server directly." msgstr "" -#: ../../using/windows.rst:958 +#: ../../using/windows.rst:956 msgid "" "Setting ``HTTPS_PROXY`` to a string like ``example.com:8080`` will connect " "to that proxy server for all HTTPS connections. For the default index, all " @@ -1485,14 +1485,14 @@ msgid "" "override." msgstr "" -#: ../../using/windows.rst:962 +#: ../../using/windows.rst:960 msgid "" "The ``HTTP_PROXY`` variable may be needed if you are using a private index " "server that does not use encrypted connections, but does require the default " "proxy server to be overridden. It follows the same format as ``HTTPS_PROXY``." msgstr "" -#: ../../using/windows.rst:966 +#: ../../using/windows.rst:964 msgid "" "Credentials may be embedded in either setting, however, when ``HTTPS_PROXY`` " "has credentials embedded they will be used in preference to other " @@ -1500,11 +1500,11 @@ msgid "" "proxy." msgstr "" -#: ../../using/windows.rst:973 ../../using/windows.rst:985 +#: ../../using/windows.rst:971 ../../using/windows.rst:983 msgid "Troubleshooting" msgstr "" -#: ../../using/windows.rst:975 +#: ../../using/windows.rst:973 msgid "" "If your Python install manager does not seem to be working correctly, please " "work through these tests and fixes to see if it helps. If not, please report " @@ -1513,25 +1513,25 @@ msgid "" "by default)." msgstr "" -#: ../../using/windows.rst:989 +#: ../../using/windows.rst:987 msgid "Symptom" msgstr "" -#: ../../using/windows.rst:990 +#: ../../using/windows.rst:988 msgid "Things to try" msgstr "" -#: ../../using/windows.rst:992 +#: ../../using/windows.rst:990 msgid "" "``python`` gives me a \"command not found\" error or opens the Store app " "when I type it in my terminal." msgstr "" -#: ../../using/windows.rst:994 ../../using/windows.rst:1013 +#: ../../using/windows.rst:992 ../../using/windows.rst:1011 msgid "Did you :ref:`install the Python install manager `?" msgstr "" -#: ../../using/windows.rst:997 ../../using/windows.rst:1016 +#: ../../using/windows.rst:995 ../../using/windows.rst:1014 msgid "" "Click Start, open \"Manage app execution aliases\", and check that the " "aliases for \"Python (default)\" are enabled. If they already are, try " @@ -1539,11 +1539,11 @@ msgid "" "windowed)\" and \"Python install manager\" commands may also need refreshing." msgstr "" -#: ../../using/windows.rst:1004 +#: ../../using/windows.rst:1002 msgid "Check that the ``py`` and ``pymanager`` commands work." msgstr "" -#: ../../using/windows.rst:1007 ../../using/windows.rst:1023 +#: ../../using/windows.rst:1005 ../../using/windows.rst:1021 msgid "" "Ensure your :envvar:`PATH` variable contains the entry for ``%UserProfile%" "\\AppData\\Local\\Microsoft\\WindowsApps``. The operating system includes " @@ -1551,59 +1551,59 @@ msgid "" "will not be found." msgstr "" -#: ../../using/windows.rst:1012 +#: ../../using/windows.rst:1010 msgid "" "``py`` gives me a \"command not found\" error when I type it in my terminal." msgstr "" -#: ../../using/windows.rst:1028 +#: ../../using/windows.rst:1026 msgid "" "``py`` gives me a \"can't open file\" error when I type commands in my " "terminal." msgstr "" -#: ../../using/windows.rst:1030 +#: ../../using/windows.rst:1028 msgid "" "This usually means you have the legacy launcher installed and it has " "priority over the Python install manager. To remove, click Start, open " "\"Installed apps\", search for \"Python launcher\" and uninstall it." msgstr "" -#: ../../using/windows.rst:1035 +#: ../../using/windows.rst:1033 msgid "``python`` doesn't launch the same runtime as ``py``" msgstr "" -#: ../../using/windows.rst:1036 +#: ../../using/windows.rst:1034 msgid "" "Click Start, open \"Installed apps\", look for any existing Python runtimes, " "and either remove them or Modify and disable the :envvar:`PATH` options." msgstr "" -#: ../../using/windows.rst:1040 +#: ../../using/windows.rst:1038 msgid "" "Click Start, open \"Manage app execution aliases\", and check that your " "``python.exe`` alias is set to \"Python (default)\"" msgstr "" -#: ../../using/windows.rst:1043 +#: ../../using/windows.rst:1041 msgid "``python`` and ``py`` don't launch the runtime I expect" msgstr "" -#: ../../using/windows.rst:1044 +#: ../../using/windows.rst:1042 msgid "" "Check your :envvar:`PYTHON_MANAGER_DEFAULT` environment variable or " "``default_tag`` configuration. The ``py list`` command will show your " "default based on these settings." msgstr "" -#: ../../using/windows.rst:1049 +#: ../../using/windows.rst:1047 msgid "" "Installs that are managed by the Python install manager will be chosen ahead " "of unmanaged installs. Use ``py install`` to install the runtime you expect, " "or configure your default tag." msgstr "" -#: ../../using/windows.rst:1055 +#: ../../using/windows.rst:1053 msgid "" "Prerelease and experimental installs that are not managed by the Python " "install manager may be chosen ahead of stable releases. Configure your " @@ -1611,29 +1611,29 @@ msgid "" "install``." msgstr "" -#: ../../using/windows.rst:1060 +#: ../../using/windows.rst:1058 msgid "" "``pythonw`` or ``pyw`` don't launch the same runtime as ``python`` or ``py``" msgstr "" -#: ../../using/windows.rst:1061 +#: ../../using/windows.rst:1059 msgid "" "Click Start, open \"Manage app execution aliases\", and check that your " "``pythonw.exe`` and ``pyw.exe`` aliases are consistent with your others." msgstr "" -#: ../../using/windows.rst:1064 +#: ../../using/windows.rst:1062 msgid "" "``pip`` gives me a \"command not found\" error when I type it in my terminal." msgstr "" -#: ../../using/windows.rst:1065 ../../using/windows.rst:1077 +#: ../../using/windows.rst:1063 ../../using/windows.rst:1075 msgid "" "Have you activated a virtual environment? Run the ``." "venv\\Scripts\\activate`` script in your terminal to activate." msgstr "" -#: ../../using/windows.rst:1069 +#: ../../using/windows.rst:1067 msgid "" "The package may be available but missing the generated executable. We " "recommend using the ``python -m pip`` command instead. Running ``py install " @@ -1642,11 +1642,11 @@ msgid "" "commands such as ``pip`` (and other installed packages) available." msgstr "" -#: ../../using/windows.rst:1076 +#: ../../using/windows.rst:1074 msgid "I installed a package with ``pip`` but its command is not found." msgstr "" -#: ../../using/windows.rst:1081 +#: ../../using/windows.rst:1079 msgid "" "New packages do not automatically have global shortcuts created by the " "Python install manager. Similarly, uninstalled packages do not have their " @@ -1654,11 +1654,11 @@ msgid "" "shortcuts for newly installed packages." msgstr "" -#: ../../using/windows.rst:1087 +#: ../../using/windows.rst:1085 msgid "Typing ``script-name.py`` in the terminal opens in a new window." msgstr "" -#: ../../using/windows.rst:1088 +#: ../../using/windows.rst:1086 msgid "" "This is a known limitation of the operating system. Either specify ``py`` " "before the script name, create a batch file containing ``@py \"%~dpn0.py\" " @@ -1666,68 +1666,68 @@ msgid "" "select it as the association for scripts." msgstr "" -#: ../../using/windows.rst:1093 +#: ../../using/windows.rst:1091 msgid "Drag-dropping files onto a script doesn't work" msgstr "" -#: ../../using/windows.rst:1094 +#: ../../using/windows.rst:1092 msgid "" "This is a known limitation of the operating system. It is supported with the " "`legacy launcher`_, or with the Python install manager when installed from " "the MSI." msgstr "" -#: ../../using/windows.rst:1098 +#: ../../using/windows.rst:1096 msgid "I have installed the Python install manager multiple times." msgstr "" -#: ../../using/windows.rst:1099 +#: ../../using/windows.rst:1097 msgid "" "It is possible to install from the Store or WinGet, from the MSIX on the " "Python website, and from the MSI, all at once. They are all compatible and " "will share configuration and runtimes." msgstr "" -#: ../../using/windows.rst:1104 +#: ../../using/windows.rst:1102 msgid "" "See the earlier :ref:`pymanager-advancedinstall` section for ways to " "uninstall the install manager other than the typical Installed Apps (Add and " "Remove Programs) settings page." msgstr "" -#: ../../using/windows.rst:1108 +#: ../../using/windows.rst:1106 msgid "My old ``py.ini`` settings no longer work." msgstr "" -#: ../../using/windows.rst:1109 +#: ../../using/windows.rst:1107 msgid "" "The new Python install manager no longer supports this configuration file or " "its settings, and so it will be ignored. See :ref:`pymanager-config` for " "information about configuration settings." msgstr "" -#: ../../using/windows.rst:1116 +#: ../../using/windows.rst:1114 msgid "The embeddable package" msgstr "" -#: ../../using/windows.rst:1120 +#: ../../using/windows.rst:1118 msgid "" "The embedded distribution is a ZIP file containing a minimal Python " "environment. It is intended for acting as part of another application, " "rather than being directly accessed by end-users." msgstr "" -#: ../../using/windows.rst:1124 +#: ../../using/windows.rst:1122 msgid "" "To install an embedded distribution, we recommend using ``py install`` with " "the ``--target`` option:" msgstr "" -#: ../../using/windows.rst:1127 +#: ../../using/windows.rst:1125 msgid "$> py install 3.14-embed --target=" msgstr "$> py install 3.14-embed --target=" -#: ../../using/windows.rst:1131 +#: ../../using/windows.rst:1129 msgid "" "When extracted, the embedded distribution is (almost) fully isolated from " "the user's system, including environment variables, system registry " @@ -1738,14 +1738,14 @@ msgid "" "documentation are not included." msgstr "" -#: ../../using/windows.rst:1138 +#: ../../using/windows.rst:1136 msgid "" "A default ``._pth`` file is included, which further restricts the default " "search paths (as described below in :ref:`windows_finding_modules`). This " "file is intended for embedders to modify as necessary." msgstr "" -#: ../../using/windows.rst:1142 +#: ../../using/windows.rst:1140 msgid "" "Third-party packages should be installed by the application installer " "alongside the embedded distribution. Using pip to manage dependencies as for " @@ -1756,16 +1756,16 @@ msgid "" "compatibility with newer versions before providing updates to users." msgstr "" -#: ../../using/windows.rst:1150 +#: ../../using/windows.rst:1148 msgid "" "The two recommended use cases for this distribution are described below." msgstr "" -#: ../../using/windows.rst:1153 +#: ../../using/windows.rst:1151 msgid "Python application" msgstr "Python 應用程式" -#: ../../using/windows.rst:1155 +#: ../../using/windows.rst:1153 msgid "" "An application written in Python does not necessarily require users to be " "aware of that fact. The embedded distribution may be used in this case to " @@ -1774,7 +1774,7 @@ msgid "" "there are two options." msgstr "" -#: ../../using/windows.rst:1161 +#: ../../using/windows.rst:1159 msgid "" "Using a specialized executable as a launcher requires some coding, but " "provides the most transparent experience for users. With a customized " @@ -1785,7 +1785,7 @@ msgid "" "line." msgstr "" -#: ../../using/windows.rst:1168 +#: ../../using/windows.rst:1166 msgid "" "The simpler approach is to provide a batch file or generated shortcut that " "directly calls the ``python.exe`` or ``pythonw.exe`` with the required " @@ -1794,7 +1794,7 @@ msgid "" "from other running Python processes or file associations." msgstr "" -#: ../../using/windows.rst:1174 +#: ../../using/windows.rst:1172 msgid "" "With the latter approach, packages should be installed as directories " "alongside the Python executable to ensure they are available on the path. " @@ -1803,11 +1803,11 @@ msgid "" "application." msgstr "" -#: ../../using/windows.rst:1180 +#: ../../using/windows.rst:1178 msgid "Embedding Python" msgstr "嵌入 Python" -#: ../../using/windows.rst:1182 +#: ../../using/windows.rst:1180 msgid "" "Applications written in native code often require some form of scripting " "language, and the embedded Python distribution can be used for this purpose. " @@ -1818,7 +1818,7 @@ msgid "" "interpreter." msgstr "" -#: ../../using/windows.rst:1189 +#: ../../using/windows.rst:1187 msgid "" "As with the application use, packages can be installed to any location as " "there is an opportunity to specify search paths before initializing the " @@ -1826,11 +1826,11 @@ msgid "" "the embedded distribution and a regular installation." msgstr "" -#: ../../using/windows.rst:1198 +#: ../../using/windows.rst:1196 msgid "The nuget.org packages" msgstr "nuget.org 套件" -#: ../../using/windows.rst:1202 +#: ../../using/windows.rst:1200 msgid "" "The nuget.org package is a reduced size Python environment intended for use " "on continuous integration and build systems that do not have a system-wide " @@ -1838,14 +1838,14 @@ msgid "" "works perfectly fine for packages containing build-time tools." msgstr "" -#: ../../using/windows.rst:1207 +#: ../../using/windows.rst:1205 msgid "" "Visit `nuget.org `_ for the most up-to-date " "information on using nuget. What follows is a summary that is sufficient for " "Python developers." msgstr "" -#: ../../using/windows.rst:1211 +#: ../../using/windows.rst:1209 msgid "" "The ``nuget.exe`` command line tool may be downloaded directly from " "``https://dist.nuget.org/win-x86-commandline/latest/nuget.exe``, for " @@ -1853,7 +1853,7 @@ msgid "" "Python for 64-bit or 32-bit machines is installed using::" msgstr "" -#: ../../using/windows.rst:1216 +#: ../../using/windows.rst:1214 msgid "" "nuget.exe install python -ExcludeVersion -OutputDirectory .\n" "nuget.exe install pythonx86 -ExcludeVersion -OutputDirectory ." @@ -1861,7 +1861,7 @@ msgstr "" "nuget.exe install python -ExcludeVersion -OutputDirectory .\n" "nuget.exe install pythonx86 -ExcludeVersion -OutputDirectory ." -#: ../../using/windows.rst:1219 +#: ../../using/windows.rst:1217 msgid "" "To select a particular version, add a ``-Version 3.x.y``. The output " "directory may be changed from ``.``, and the package will be installed into " @@ -1871,7 +1871,7 @@ msgid "" "directory that contains the Python installation:" msgstr "" -#: ../../using/windows.rst:1226 +#: ../../using/windows.rst:1224 msgid "" "# Without -ExcludeVersion\n" "> .\\python.3.5.2\\tools\\python.exe -V\n" @@ -1889,7 +1889,7 @@ msgstr "" "> .\\python\\tools\\python.exe -V\n" "Python 3.5.2" -#: ../../using/windows.rst:1236 +#: ../../using/windows.rst:1234 msgid "" "In general, nuget packages are not upgradeable, and newer versions should be " "installed side-by-side and referenced using the full path. Alternatively, " @@ -1897,7 +1897,7 @@ msgid "" "will do this automatically if they do not preserve files between builds." msgstr "" -#: ../../using/windows.rst:1241 +#: ../../using/windows.rst:1239 msgid "" "Alongside the ``tools`` directory is a ``build\\native`` directory. This " "contains a MSBuild properties file ``python.props`` that can be used in a C+" @@ -1905,7 +1905,7 @@ msgid "" "automatically use the headers and import libraries in your build." msgstr "" -#: ../../using/windows.rst:1246 +#: ../../using/windows.rst:1244 msgid "" "The package information pages on nuget.org are `www.nuget.org/packages/" "python `_ for the 64-bit version, " @@ -1914,11 +1914,11 @@ msgid "" "`_ for the ARM64 version" msgstr "" -#: ../../using/windows.rst:1254 +#: ../../using/windows.rst:1252 msgid "Free-threaded packages" msgstr "" -#: ../../using/windows.rst:1258 +#: ../../using/windows.rst:1256 msgid "" "Packages containing free-threaded binaries are named `python-freethreaded " "`_ for the 64-bit " @@ -1929,46 +1929,46 @@ msgid "" "exe`` entry points, both of which run free threaded." msgstr "" -#: ../../using/windows.rst:1269 +#: ../../using/windows.rst:1267 msgid "Alternative bundles" msgstr "" -#: ../../using/windows.rst:1271 +#: ../../using/windows.rst:1269 msgid "" "Besides the standard CPython distribution, there are modified packages " "including additional functionality. The following is a list of popular " "versions and their key features:" msgstr "" -#: ../../using/windows.rst:1275 +#: ../../using/windows.rst:1273 msgid "`ActivePython `_" msgstr "`ActivePython `_" -#: ../../using/windows.rst:1276 +#: ../../using/windows.rst:1274 msgid "Installer with multi-platform compatibility, documentation, PyWin32" msgstr "" -#: ../../using/windows.rst:1278 +#: ../../using/windows.rst:1276 msgid "`Anaconda `_" msgstr "`Anaconda `_" -#: ../../using/windows.rst:1279 +#: ../../using/windows.rst:1277 msgid "" "Popular scientific modules (such as numpy, scipy and pandas) and the " "``conda`` package manager." msgstr "" -#: ../../using/windows.rst:1282 +#: ../../using/windows.rst:1280 msgid "" "`Enthought Deployment Manager `_" msgstr "" "`Enthought Deployment Manager `_" -#: ../../using/windows.rst:1283 +#: ../../using/windows.rst:1281 msgid "\"The Next Generation Python Environment and Package Manager\"." msgstr "" -#: ../../using/windows.rst:1285 +#: ../../using/windows.rst:1283 msgid "" "Previously Enthought provided Canopy, but it `reached end of life in 2016 " "`_." msgstr "" -#: ../../using/windows.rst:1288 +#: ../../using/windows.rst:1286 msgid "`WinPython `_" msgstr "`WinPython `_" -#: ../../using/windows.rst:1289 +#: ../../using/windows.rst:1287 msgid "" "Windows-specific distribution with prebuilt scientific packages and tools " "for building packages." msgstr "" -#: ../../using/windows.rst:1292 +#: ../../using/windows.rst:1290 msgid "" "Note that these packages may not include the latest versions of Python or " "other libraries, and are not maintained or supported by the core Python team." msgstr "" -#: ../../using/windows.rst:1297 +#: ../../using/windows.rst:1295 msgid "Supported Windows versions" msgstr "" -#: ../../using/windows.rst:1299 +#: ../../using/windows.rst:1297 msgid "" "As specified in :pep:`11`, a Python release only supports a Windows platform " "while Microsoft considers the platform under extended support. This means " @@ -2005,17 +2005,17 @@ msgid "" "please install Python 3.12." msgstr "" -#: ../../using/windows.rst:1309 ../../using/windows.rst:1590 +#: ../../using/windows.rst:1307 ../../using/windows.rst:1594 msgid "Removing the MAX_PATH limitation" msgstr "" -#: ../../using/windows.rst:1311 ../../using/windows.rst:1592 +#: ../../using/windows.rst:1309 ../../using/windows.rst:1596 msgid "" "Windows historically has limited path lengths to 260 characters. This meant " "that paths longer than this would not resolve and errors would result." msgstr "" -#: ../../using/windows.rst:1314 +#: ../../using/windows.rst:1312 msgid "" "In the latest versions of Windows, this limitation can be expanded to over " "32,000 characters. Your administrator will need to activate the \"Enable " @@ -2024,98 +2024,104 @@ msgid "" "``HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\FileSystem``." msgstr "" -#: ../../using/windows.rst:1319 ../../using/windows.rst:1601 +#: ../../using/windows.rst:1317 ../../using/windows.rst:1605 msgid "" "This allows the :func:`open` function, the :mod:`os` module and most other " "path functionality to accept and return paths longer than 260 characters." msgstr "" -#: ../../using/windows.rst:1322 +#: ../../using/windows.rst:1320 msgid "" "After changing the above option and rebooting, no further configuration is " "required." msgstr "" -#: ../../using/windows.rst:1329 +#: ../../using/windows.rst:1327 msgid "UTF-8 mode" msgstr "UTF-8 模式" -#: ../../using/windows.rst:1333 +#: ../../using/windows.rst:1332 +msgid "Python UTF-8 mode is now enabled by default (:pep:`686`)." +msgstr "" + +#: ../../using/windows.rst:1334 msgid "" "Windows still uses legacy encodings for the system encoding (the ANSI Code " -"Page). Python uses it for the default encoding of text files (e.g. :func:" -"`locale.getencoding`)." +"Page). When the :ref:`Python UTF-8 Mode ` is disabled, Python " +"uses the ANSI Code Page as the default encoding of text files, as returned " +"by :func:`locale.getencoding`." msgstr "" -#: ../../using/windows.rst:1337 +#: ../../using/windows.rst:1339 msgid "" "This may cause issues because UTF-8 is widely used on the internet and most " "Unix systems, including WSL (Windows Subsystem for Linux)." msgstr "" -#: ../../using/windows.rst:1340 +#: ../../using/windows.rst:1342 msgid "" -"You can use the :ref:`Python UTF-8 Mode ` to change the default " -"text encoding to UTF-8. You can enable the :ref:`Python UTF-8 Mode ` via the ``-X utf8`` command line option, or the ``PYTHONUTF8=1`` " -"environment variable. See :envvar:`PYTHONUTF8` for enabling UTF-8 mode, " -"and :ref:`setting-envvars` for how to modify environment variables." +"The :ref:`Python UTF-8 Mode `, enabled by default, ignores the " +"system encoding and uses UTF-8 as the default text encoding. When the :ref:" +"`UTF-8 mode ` is enabled, you can still use the system encoding " +"(the ANSI Code Page) via the \"mbcs\" codec." msgstr "" -#: ../../using/windows.rst:1346 +#: ../../using/windows.rst:1347 msgid "" -"When the :ref:`Python UTF-8 Mode ` is enabled, you can still use " -"the system encoding (the ANSI Code Page) via the \"mbcs\" codec." +"You can disable the :ref:`Python UTF-8 Mode ` via the ``-X " +"utf8=0`` command line option, or the ``PYTHONUTF8=0`` environment variable. " +"See :envvar:`PYTHONUTF8` for disabling UTF-8 mode, and :ref:`setting-" +"envvars` for how to modify environment variables." msgstr "" -#: ../../using/windows.rst:1349 +#: ../../using/windows.rst:1353 msgid "" -"Note that adding ``PYTHONUTF8=1`` to the default environment variables will " -"affect all Python 3.7+ applications on your system. If you have any Python " -"3.7+ applications which rely on the legacy system encoding, it is " -"recommended to set the environment variable temporarily or use the ``-X " -"utf8`` command line option." +"Adding ``PYTHONUTF8={0,1}`` to the default environment variables will affect " +"all Python 3.7+ applications on your system. If you have any Python 3.7+ " +"applications which rely on the legacy system encoding, it is recommended to " +"set the environment variable temporarily or use the ``-X utf8`` command line " +"option." msgstr "" -#: ../../using/windows.rst:1356 +#: ../../using/windows.rst:1360 msgid "" "Even when UTF-8 mode is disabled, Python uses UTF-8 by default on Windows " "for:" msgstr "" -#: ../../using/windows.rst:1359 +#: ../../using/windows.rst:1363 msgid "Console I/O including standard I/O (see :pep:`528` for details)." msgstr "" -#: ../../using/windows.rst:1360 +#: ../../using/windows.rst:1364 msgid "" "The :term:`filesystem encoding ` " "(see :pep:`529` for details)." msgstr "" -#: ../../using/windows.rst:1367 +#: ../../using/windows.rst:1371 msgid "Finding modules" msgstr "找尋模組" -#: ../../using/windows.rst:1369 +#: ../../using/windows.rst:1373 msgid "" "These notes supplement the description at :ref:`sys-path-init` with detailed " "Windows notes." msgstr "" -#: ../../using/windows.rst:1372 +#: ../../using/windows.rst:1376 msgid "" "When no ``._pth`` file is found, this is how :data:`sys.path` is populated " "on Windows:" msgstr "" -#: ../../using/windows.rst:1375 +#: ../../using/windows.rst:1379 msgid "" "An empty entry is added at the start, which corresponds to the current " "directory." msgstr "" -#: ../../using/windows.rst:1378 +#: ../../using/windows.rst:1382 msgid "" "If the environment variable :envvar:`PYTHONPATH` exists, as described in :" "ref:`using-on-envvars`, its entries are added next. Note that on Windows, " @@ -2123,7 +2129,7 @@ msgid "" "from the colon used in drive identifiers (``C:\\`` etc.)." msgstr "" -#: ../../using/windows.rst:1383 +#: ../../using/windows.rst:1387 msgid "" "Additional \"application paths\" can be added in the registry as subkeys of :" "samp:`\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\{version}\\\\PythonPath` under " @@ -2133,7 +2139,7 @@ msgid "" "installers only use HKLM, so HKCU is typically empty.)" msgstr "" -#: ../../using/windows.rst:1390 +#: ../../using/windows.rst:1394 msgid "" "If the environment variable :envvar:`PYTHONHOME` is set, it is assumed as " "\"Python Home\". Otherwise, the path of the main Python executable is used " @@ -2144,31 +2150,31 @@ msgid "" "PythonPath stored in the registry." msgstr "" -#: ../../using/windows.rst:1398 +#: ../../using/windows.rst:1402 msgid "" "If the Python Home cannot be located, no :envvar:`PYTHONPATH` is specified " "in the environment, and no registry entries can be found, a default path " "with relative entries is used (e.g. ``.\\Lib;.\\plat-win``, etc)." msgstr "" -#: ../../using/windows.rst:1402 +#: ../../using/windows.rst:1406 msgid "" "If a ``pyvenv.cfg`` file is found alongside the main executable or in the " "directory one level above the executable, the following variations apply:" msgstr "" -#: ../../using/windows.rst:1405 +#: ../../using/windows.rst:1409 msgid "" "If ``home`` is an absolute path and :envvar:`PYTHONHOME` is not set, this " "path is used instead of the path to the main executable when deducing the " "home location." msgstr "" -#: ../../using/windows.rst:1409 +#: ../../using/windows.rst:1413 msgid "The end result of all this is:" msgstr "最終這所有的結果為:" -#: ../../using/windows.rst:1411 +#: ../../using/windows.rst:1415 msgid "" "When running :file:`python.exe`, or any other .exe in the main Python " "directory (either an installed version, or directly from the PCbuild " @@ -2176,7 +2182,7 @@ msgid "" "ignored. Other \"application paths\" in the registry are always read." msgstr "" -#: ../../using/windows.rst:1416 +#: ../../using/windows.rst:1420 msgid "" "When Python is hosted in another .exe (different directory, embedded via " "COM, etc), the \"Python Home\" will not be deduced, so the core path from " @@ -2184,20 +2190,20 @@ msgid "" "always read." msgstr "" -#: ../../using/windows.rst:1420 +#: ../../using/windows.rst:1424 msgid "" "If Python can't find its home and there are no registry value (frozen .exe, " "some very strange installation setup) you get a path with some default, but " "relative, paths." msgstr "" -#: ../../using/windows.rst:1424 +#: ../../using/windows.rst:1428 msgid "" "For those who want to bundle Python into their application or distribution, " "the following advice will prevent conflicts with other installations:" msgstr "" -#: ../../using/windows.rst:1427 +#: ../../using/windows.rst:1431 msgid "" "Include a ``._pth`` file alongside your executable containing the " "directories to include. This will ignore paths listed in the registry and " @@ -2205,20 +2211,20 @@ msgid "" "listed." msgstr "" -#: ../../using/windows.rst:1432 +#: ../../using/windows.rst:1436 msgid "" "If you are loading :file:`python3.dll` or :file:`python37.dll` in your own " "executable, explicitly set :c:member:`PyConfig.module_search_paths` before :" "c:func:`Py_InitializeFromConfig`." msgstr "" -#: ../../using/windows.rst:1436 +#: ../../using/windows.rst:1440 msgid "" "Clear and/or overwrite :envvar:`PYTHONPATH` and set :envvar:`PYTHONHOME` " "before launching :file:`python.exe` from your application." msgstr "" -#: ../../using/windows.rst:1439 +#: ../../using/windows.rst:1443 msgid "" "If you cannot use the previous suggestions (for example, you are a " "distribution that allows people to run :file:`python.exe` directly), ensure " @@ -2227,7 +2233,7 @@ msgid "" "correctly named ZIP file will be detected instead.)" msgstr "" -#: ../../using/windows.rst:1445 +#: ../../using/windows.rst:1449 msgid "" "These will ensure that the files in a system-wide installation will not take " "precedence over the copy of the standard library bundled with your " @@ -2237,19 +2243,19 @@ msgid "" "packages." msgstr "" -#: ../../using/windows.rst:1453 +#: ../../using/windows.rst:1457 msgid "" "Add ``._pth`` file support and removes ``applocal`` option from ``pyvenv." "cfg``." msgstr "" -#: ../../using/windows.rst:1458 +#: ../../using/windows.rst:1462 msgid "" "Add :file:`python{XX}.zip` as a potential landmark when directly adjacent to " "the executable." msgstr "" -#: ../../using/windows.rst:1463 +#: ../../using/windows.rst:1467 msgid "" "Modules specified in the registry under ``Modules`` (not ``PythonPath``) may " "be imported by :class:`importlib.machinery.WindowsRegistryFinder`. This " @@ -2257,87 +2263,87 @@ msgid "" "explicitly added to :data:`sys.meta_path` in the future." msgstr "" -#: ../../using/windows.rst:1469 +#: ../../using/windows.rst:1473 msgid "Additional modules" msgstr "額外的模組" -#: ../../using/windows.rst:1471 +#: ../../using/windows.rst:1475 msgid "" "Even though Python aims to be portable among all platforms, there are " "features that are unique to Windows. A couple of modules, both in the " "standard library and external, and snippets exist to use these features." msgstr "" -#: ../../using/windows.rst:1475 +#: ../../using/windows.rst:1479 msgid "" "The Windows-specific standard modules are documented in :ref:`mswin-specific-" "services`." msgstr "" -#: ../../using/windows.rst:1479 +#: ../../using/windows.rst:1483 msgid "PyWin32" msgstr "PyWin32" -#: ../../using/windows.rst:1481 +#: ../../using/windows.rst:1485 msgid "" "The :pypi:`PyWin32` module by Mark Hammond is a collection of modules for " "advanced Windows-specific support. This includes utilities for:" msgstr "" -#: ../../using/windows.rst:1485 +#: ../../using/windows.rst:1489 msgid "" "`Component Object Model `_ (COM)" msgstr "" -#: ../../using/windows.rst:1488 +#: ../../using/windows.rst:1492 msgid "Win32 API calls" msgstr "Win32 API 呼叫" -#: ../../using/windows.rst:1489 +#: ../../using/windows.rst:1493 msgid "Registry" msgstr "登錄檔(Registry)" -#: ../../using/windows.rst:1490 +#: ../../using/windows.rst:1494 msgid "Event log" msgstr "事件日誌(Event log)" -#: ../../using/windows.rst:1491 +#: ../../using/windows.rst:1495 msgid "" "`Microsoft Foundation Classes `_ (MFC) user interfaces" msgstr "" -#: ../../using/windows.rst:1495 +#: ../../using/windows.rst:1499 msgid "" "`PythonWin `_ is a sample MFC application shipped with PyWin32. " "It is an embeddable IDE with a built-in debugger." msgstr "" -#: ../../using/windows.rst:1501 +#: ../../using/windows.rst:1505 msgid "" "`Win32 How Do I...? `_" msgstr "" "`Win32 How Do I...? `_" -#: ../../using/windows.rst:1502 +#: ../../using/windows.rst:1506 msgid "by Tim Golden" msgstr "由 Tim Golden 所著" -#: ../../using/windows.rst:1504 +#: ../../using/windows.rst:1508 msgid "`Python and COM `_" msgstr "`Python and COM `_" -#: ../../using/windows.rst:1505 +#: ../../using/windows.rst:1509 msgid "by David and Paul Boddie" msgstr "由 David 與 Paul Boddie 所著" -#: ../../using/windows.rst:1509 +#: ../../using/windows.rst:1513 msgid "cx_Freeze" msgstr "cx_Freeze" -#: ../../using/windows.rst:1511 +#: ../../using/windows.rst:1515 msgid "" "`cx_Freeze `_ wraps Python " "scripts into executable Windows programs (:file:`{*}.exe` files). When you " @@ -2345,11 +2351,11 @@ msgid "" "users to install Python." msgstr "" -#: ../../using/windows.rst:1518 +#: ../../using/windows.rst:1522 msgid "Compiling Python on Windows" msgstr "編譯 Python 在 Windows" -#: ../../using/windows.rst:1520 +#: ../../using/windows.rst:1524 msgid "" "If you want to compile CPython yourself, first thing you should do is get " "the `source `_. You can download " @@ -2357,38 +2363,38 @@ msgid "" "devguide.python.org/setup/#get-the-source-code>`_." msgstr "" -#: ../../using/windows.rst:1525 +#: ../../using/windows.rst:1529 msgid "" "The source tree contains a build solution and project files for Microsoft " "Visual Studio, which is the compiler used to build the official Python " "releases. These files are in the :file:`PCbuild` directory." msgstr "" -#: ../../using/windows.rst:1529 +#: ../../using/windows.rst:1533 msgid "" "Check :file:`PCbuild/readme.txt` for general information on the build " "process." msgstr "" -#: ../../using/windows.rst:1531 +#: ../../using/windows.rst:1535 msgid "For extension modules, consult :ref:`building-on-windows`." msgstr "" -#: ../../using/windows.rst:1538 +#: ../../using/windows.rst:1542 msgid "The full installer (deprecated)" msgstr "" -#: ../../using/windows.rst:1542 +#: ../../using/windows.rst:1546 msgid "" "This installer is deprecated since 3.14 and will not be produced for Python " "3.16 or later. See :ref:`pymanager` for the modern installer." msgstr "" -#: ../../using/windows.rst:1547 +#: ../../using/windows.rst:1551 msgid "Installation steps" msgstr "安裝步驟" -#: ../../using/windows.rst:1549 +#: ../../using/windows.rst:1553 msgid "" "Four Python |version| installers are available for download - two each for " "the 32-bit and 64-bit versions of the interpreter. The *web installer* is a " @@ -2399,43 +2405,43 @@ msgid "" "ways to avoid downloading during installation." msgstr "" -#: ../../using/windows.rst:1557 +#: ../../using/windows.rst:1561 msgid "After starting the installer, one of two options may be selected:" msgstr "" -#: ../../using/windows.rst:1561 +#: ../../using/windows.rst:1565 msgid "If you select \"Install Now\":" msgstr "如果你選擇「馬上安裝」:" -#: ../../using/windows.rst:1563 +#: ../../using/windows.rst:1567 msgid "" "You will *not* need to be an administrator (unless a system update for the C " "Runtime Library is required or you install the :ref:`launcher` for all users)" msgstr "" -#: ../../using/windows.rst:1566 +#: ../../using/windows.rst:1570 msgid "Python will be installed into your user directory" msgstr "" -#: ../../using/windows.rst:1567 +#: ../../using/windows.rst:1571 msgid "" "The :ref:`launcher` will be installed according to the option at the bottom " "of the first page" msgstr "" -#: ../../using/windows.rst:1569 +#: ../../using/windows.rst:1573 msgid "The standard library, test suite, launcher and pip will be installed" msgstr "" -#: ../../using/windows.rst:1570 +#: ../../using/windows.rst:1574 msgid "If selected, the install directory will be added to your :envvar:`PATH`" msgstr "如果選擇,安裝目錄將被加入到你的 :envvar:`PATH`" -#: ../../using/windows.rst:1571 +#: ../../using/windows.rst:1575 msgid "Shortcuts will only be visible for the current user" msgstr "安裝捷徑將只能被目前使用者所看見" -#: ../../using/windows.rst:1573 +#: ../../using/windows.rst:1577 msgid "" "Selecting \"Customize installation\" will allow you to select the features " "to install, the installation location and other options or post-install " @@ -2445,42 +2451,42 @@ msgstr "" "選擇「客製化安裝」將允許你選擇所需的項目進行安裝,安裝位置與其他選擇或安裝後" "的所需進行的動作。你將需要使用此選項「除錯特徵」或「二進位方式」進行安裝。" -#: ../../using/windows.rst:1577 +#: ../../using/windows.rst:1581 msgid "" "To perform an all-users installation, you should select \"Customize " "installation\". In this case:" msgstr "" -#: ../../using/windows.rst:1580 +#: ../../using/windows.rst:1584 msgid "You may be required to provide administrative credentials or approval" msgstr "" -#: ../../using/windows.rst:1581 +#: ../../using/windows.rst:1585 msgid "Python will be installed into the Program Files directory" msgstr "" -#: ../../using/windows.rst:1582 +#: ../../using/windows.rst:1586 msgid "The :ref:`launcher` will be installed into the Windows directory" msgstr "" -#: ../../using/windows.rst:1583 +#: ../../using/windows.rst:1587 msgid "Optional features may be selected during installation" msgstr "" -#: ../../using/windows.rst:1584 +#: ../../using/windows.rst:1588 msgid "The standard library can be pre-compiled to bytecode" msgstr "" -#: ../../using/windows.rst:1585 +#: ../../using/windows.rst:1589 msgid "" "If selected, the install directory will be added to the system :envvar:`PATH`" msgstr "" -#: ../../using/windows.rst:1586 +#: ../../using/windows.rst:1590 msgid "Shortcuts are available for all users" msgstr "捷徑將被所有使用者所見" -#: ../../using/windows.rst:1595 +#: ../../using/windows.rst:1599 msgid "" "In the latest versions of Windows, this limitation can be expanded to " "approximately 32,000 characters. Your administrator will need to activate " @@ -2489,19 +2495,19 @@ msgid "" "``HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\FileSystem``." msgstr "" -#: ../../using/windows.rst:1604 +#: ../../using/windows.rst:1608 msgid "After changing the above option, no further configuration is required." msgstr "" -#: ../../using/windows.rst:1608 +#: ../../using/windows.rst:1612 msgid "Support for long paths was enabled in Python." msgstr "" -#: ../../using/windows.rst:1613 +#: ../../using/windows.rst:1617 msgid "Installing without UI" msgstr "無使用者介面安裝" -#: ../../using/windows.rst:1615 +#: ../../using/windows.rst:1619 msgid "" "All of the options available in the installer UI can also be specified from " "the command line, allowing scripted installers to replicate an installation " @@ -2509,112 +2515,112 @@ msgid "" "without suppressing the UI in order to change some of the defaults." msgstr "" -#: ../../using/windows.rst:1620 +#: ../../using/windows.rst:1624 msgid "" "The following options (found by executing the installer with ``/?``) can be " "passed into the installer:" msgstr "" -#: ../../using/windows.rst:1624 ../../using/windows.rst:1644 -#: ../../using/windows.rst:2234 +#: ../../using/windows.rst:1628 ../../using/windows.rst:1648 +#: ../../using/windows.rst:2238 msgid "Name" msgstr "名稱" -#: ../../using/windows.rst:1626 +#: ../../using/windows.rst:1630 msgid "/passive" msgstr "/passive" -#: ../../using/windows.rst:1626 +#: ../../using/windows.rst:1630 msgid "to display progress without requiring user interaction" msgstr "" -#: ../../using/windows.rst:1628 +#: ../../using/windows.rst:1632 msgid "/quiet" msgstr "/quiet" -#: ../../using/windows.rst:1628 +#: ../../using/windows.rst:1632 msgid "to install/uninstall without displaying any UI" msgstr "" -#: ../../using/windows.rst:1630 +#: ../../using/windows.rst:1634 msgid "/simple" msgstr "/simple" -#: ../../using/windows.rst:1630 +#: ../../using/windows.rst:1634 msgid "to prevent user customization" msgstr "" -#: ../../using/windows.rst:1632 +#: ../../using/windows.rst:1636 msgid "/uninstall" msgstr "/uninstall" -#: ../../using/windows.rst:1632 +#: ../../using/windows.rst:1636 msgid "to remove Python (without confirmation)" msgstr "" -#: ../../using/windows.rst:1634 +#: ../../using/windows.rst:1638 msgid "/layout [directory]" msgstr "/layout [directory]" -#: ../../using/windows.rst:1634 +#: ../../using/windows.rst:1638 msgid "to pre-download all components" msgstr "" -#: ../../using/windows.rst:1636 +#: ../../using/windows.rst:1640 msgid "/log [filename]" msgstr "/log [filename]" -#: ../../using/windows.rst:1636 +#: ../../using/windows.rst:1640 msgid "to specify log files location" msgstr "" -#: ../../using/windows.rst:1639 +#: ../../using/windows.rst:1643 msgid "" "All other options are passed as ``name=value``, where the value is usually " "``0`` to disable a feature, ``1`` to enable a feature, or a path. The full " "list of available options is shown below." msgstr "" -#: ../../using/windows.rst:1644 +#: ../../using/windows.rst:1648 msgid "Default" msgstr "預設" -#: ../../using/windows.rst:1646 +#: ../../using/windows.rst:1650 msgid "InstallAllUsers" msgstr "InstallAllUsers" -#: ../../using/windows.rst:1646 +#: ../../using/windows.rst:1650 msgid "Perform a system-wide installation." msgstr "" -#: ../../using/windows.rst:1646 ../../using/windows.rst:1672 -#: ../../using/windows.rst:1675 ../../using/windows.rst:1679 -#: ../../using/windows.rst:1688 ../../using/windows.rst:1710 -#: ../../using/windows.rst:1718 ../../using/windows.rst:1721 +#: ../../using/windows.rst:1650 ../../using/windows.rst:1676 +#: ../../using/windows.rst:1679 ../../using/windows.rst:1683 +#: ../../using/windows.rst:1692 ../../using/windows.rst:1714 +#: ../../using/windows.rst:1722 ../../using/windows.rst:1725 msgid "0" msgstr "0" -#: ../../using/windows.rst:1648 +#: ../../using/windows.rst:1652 msgid "TargetDir" msgstr "TargetDir" -#: ../../using/windows.rst:1648 +#: ../../using/windows.rst:1652 msgid "The installation directory" msgstr "安裝目錄" -#: ../../using/windows.rst:1648 +#: ../../using/windows.rst:1652 msgid "Selected based on InstallAllUsers" msgstr "" -#: ../../using/windows.rst:1651 +#: ../../using/windows.rst:1655 msgid "DefaultAllUsersTargetDir" msgstr "DefaultAllUsersTargetDir" -#: ../../using/windows.rst:1651 +#: ../../using/windows.rst:1655 msgid "The default installation directory for all-user installs" msgstr "" -#: ../../using/windows.rst:1651 +#: ../../using/windows.rst:1655 msgid "" ":file:`%ProgramFiles%\\\\\\ Python X.Y` or :file:`\\ %ProgramFiles(x86)%\\\\" "\\ Python X.Y`" @@ -2622,15 +2628,15 @@ msgstr "" ":file:`%ProgramFiles%\\\\\\ Python X.Y` or :file:`\\ %ProgramFiles(x86)%\\\\" "\\ Python X.Y`" -#: ../../using/windows.rst:1656 +#: ../../using/windows.rst:1660 msgid "DefaultJustForMeTargetDir" msgstr "DefaultJustForMeTargetDir" -#: ../../using/windows.rst:1656 +#: ../../using/windows.rst:1660 msgid "The default install directory for just-for-me installs" msgstr "" -#: ../../using/windows.rst:1656 +#: ../../using/windows.rst:1660 msgid "" ":file:`%LocalAppData%\\\\\\ Programs\\\\Python\\\\\\ PythonXY` or :file:" "`%LocalAppData%\\\\\\ Programs\\\\Python\\\\\\ PythonXY-32` or :file:" @@ -2640,218 +2646,218 @@ msgstr "" "`%LocalAppData%\\\\\\ Programs\\\\Python\\\\\\ PythonXY-32` 或 :file:" "`%LocalAppData%\\\\\\ Programs\\\\Python\\\\\\ PythonXY-64`" -#: ../../using/windows.rst:1666 +#: ../../using/windows.rst:1670 msgid "DefaultCustomTargetDir" msgstr "DefaultCustomTargetDir" -#: ../../using/windows.rst:1666 +#: ../../using/windows.rst:1670 msgid "The default custom install directory displayed in the UI" msgstr "" -#: ../../using/windows.rst:1666 ../../using/windows.rst:1723 +#: ../../using/windows.rst:1670 ../../using/windows.rst:1727 msgid "(empty)" msgstr "(empty)" -#: ../../using/windows.rst:1669 +#: ../../using/windows.rst:1673 msgid "AssociateFiles" msgstr "AssociateFiles" -#: ../../using/windows.rst:1669 +#: ../../using/windows.rst:1673 msgid "Create file associations if the launcher is also installed." msgstr "如果啟動器也被安裝,建立檔案關聯。" -#: ../../using/windows.rst:1669 ../../using/windows.rst:1683 -#: ../../using/windows.rst:1686 ../../using/windows.rst:1690 -#: ../../using/windows.rst:1694 ../../using/windows.rst:1698 -#: ../../using/windows.rst:1700 ../../using/windows.rst:1704 -#: ../../using/windows.rst:1708 ../../using/windows.rst:1712 -#: ../../using/windows.rst:1714 ../../using/windows.rst:1716 +#: ../../using/windows.rst:1673 ../../using/windows.rst:1687 +#: ../../using/windows.rst:1690 ../../using/windows.rst:1694 +#: ../../using/windows.rst:1698 ../../using/windows.rst:1702 +#: ../../using/windows.rst:1704 ../../using/windows.rst:1708 +#: ../../using/windows.rst:1712 ../../using/windows.rst:1716 +#: ../../using/windows.rst:1718 ../../using/windows.rst:1720 msgid "1" msgstr "1" -#: ../../using/windows.rst:1672 +#: ../../using/windows.rst:1676 msgid "CompileAll" msgstr "CompileAll" -#: ../../using/windows.rst:1672 +#: ../../using/windows.rst:1676 msgid "Compile all ``.py`` files to ``.pyc``." msgstr "編譯所有 ``.py`` 檔案為 ``.pyc``。" -#: ../../using/windows.rst:1675 +#: ../../using/windows.rst:1679 msgid "PrependPath" msgstr "PrependPath" -#: ../../using/windows.rst:1675 +#: ../../using/windows.rst:1679 msgid "" "Prepend install and Scripts directories to :envvar:`PATH` and add ``.PY`` " "to :envvar:`PATHEXT`" msgstr "" -#: ../../using/windows.rst:1679 +#: ../../using/windows.rst:1683 msgid "AppendPath" msgstr "AppendPath" -#: ../../using/windows.rst:1679 +#: ../../using/windows.rst:1683 msgid "" "Append install and Scripts directories to :envvar:`PATH` and add ``.PY`` " "to :envvar:`PATHEXT`" msgstr "" -#: ../../using/windows.rst:1683 +#: ../../using/windows.rst:1687 msgid "Shortcuts" msgstr "Shortcuts" -#: ../../using/windows.rst:1683 +#: ../../using/windows.rst:1687 msgid "" "Create shortcuts for the interpreter, documentation and IDLE if installed." msgstr "" -#: ../../using/windows.rst:1686 +#: ../../using/windows.rst:1690 msgid "Include_doc" msgstr "Include_doc" -#: ../../using/windows.rst:1686 +#: ../../using/windows.rst:1690 msgid "Install Python manual" msgstr "安裝Python文件" -#: ../../using/windows.rst:1688 +#: ../../using/windows.rst:1692 msgid "Include_debug" msgstr "Include_debug" -#: ../../using/windows.rst:1688 +#: ../../using/windows.rst:1692 msgid "Install debug binaries" msgstr "" -#: ../../using/windows.rst:1690 +#: ../../using/windows.rst:1694 msgid "Include_dev" msgstr "Include_dev" -#: ../../using/windows.rst:1690 +#: ../../using/windows.rst:1694 msgid "" "Install developer headers and libraries. Omitting this may lead to an " "unusable installation." msgstr "" -#: ../../using/windows.rst:1694 +#: ../../using/windows.rst:1698 msgid "Include_exe" msgstr "Include_exe" -#: ../../using/windows.rst:1694 +#: ../../using/windows.rst:1698 msgid "" "Install :file:`python.exe` and related files. Omitting this may lead to an " "unusable installation." msgstr "" -#: ../../using/windows.rst:1698 +#: ../../using/windows.rst:1702 msgid "Include_launcher" msgstr "Include_launcher" -#: ../../using/windows.rst:1698 +#: ../../using/windows.rst:1702 msgid "Install :ref:`launcher`." msgstr "安裝 :ref:`launcher`。" -#: ../../using/windows.rst:1700 +#: ../../using/windows.rst:1704 msgid "InstallLauncherAllUsers" msgstr "InstallLauncherAllUsers" -#: ../../using/windows.rst:1700 +#: ../../using/windows.rst:1704 msgid "" "Installs the launcher for all users. Also requires ``Include_launcher`` to " "be set to 1" msgstr "" -#: ../../using/windows.rst:1704 +#: ../../using/windows.rst:1708 msgid "Include_lib" msgstr "Include_lib" -#: ../../using/windows.rst:1704 +#: ../../using/windows.rst:1708 msgid "" "Install standard library and extension modules. Omitting this may lead to an " "unusable installation." msgstr "" -#: ../../using/windows.rst:1708 +#: ../../using/windows.rst:1712 msgid "Include_pip" msgstr "Include_pip" -#: ../../using/windows.rst:1708 +#: ../../using/windows.rst:1712 msgid "Install bundled pip and setuptools" msgstr "" -#: ../../using/windows.rst:1710 +#: ../../using/windows.rst:1714 msgid "Include_symbols" msgstr "Include_symbols" -#: ../../using/windows.rst:1710 +#: ../../using/windows.rst:1714 msgid "Install debugging symbols (``*.pdb``)" msgstr "" -#: ../../using/windows.rst:1712 +#: ../../using/windows.rst:1716 msgid "Include_tcltk" msgstr "Include_tcltk" -#: ../../using/windows.rst:1712 +#: ../../using/windows.rst:1716 msgid "Install Tcl/Tk support and IDLE" msgstr "" -#: ../../using/windows.rst:1714 +#: ../../using/windows.rst:1718 msgid "Include_test" msgstr "Include_test" -#: ../../using/windows.rst:1714 +#: ../../using/windows.rst:1718 msgid "Install standard library test suite" msgstr "" -#: ../../using/windows.rst:1716 +#: ../../using/windows.rst:1720 msgid "Include_tools" msgstr "Include_tools" -#: ../../using/windows.rst:1716 +#: ../../using/windows.rst:1720 msgid "Install utility scripts" msgstr "" -#: ../../using/windows.rst:1718 +#: ../../using/windows.rst:1722 msgid "LauncherOnly" msgstr "LauncherOnly" -#: ../../using/windows.rst:1718 +#: ../../using/windows.rst:1722 msgid "Only installs the launcher. This will override most other options." msgstr "" -#: ../../using/windows.rst:1721 +#: ../../using/windows.rst:1725 msgid "SimpleInstall" msgstr "SimpleInstall" -#: ../../using/windows.rst:1721 +#: ../../using/windows.rst:1725 msgid "Disable most install UI" msgstr "" -#: ../../using/windows.rst:1723 +#: ../../using/windows.rst:1727 msgid "SimpleInstallDescription" msgstr "SimpleInstallDescription" -#: ../../using/windows.rst:1723 +#: ../../using/windows.rst:1727 msgid "A custom message to display when the simplified install UI is used." msgstr "" -#: ../../using/windows.rst:1727 +#: ../../using/windows.rst:1731 msgid "" "For example, to silently install a default, system-wide Python installation, " "you could use the following command (from an elevated command prompt)::" msgstr "" -#: ../../using/windows.rst:1730 +#: ../../using/windows.rst:1734 msgid "python-3.9.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0" msgstr "python-3.9.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0" -#: ../../using/windows.rst:1732 +#: ../../using/windows.rst:1736 msgid "" "To allow users to easily install a personal copy of Python without the test " "suite, you could provide a shortcut with the following command. This will " "display a simplified initial page and disallow customization::" msgstr "" -#: ../../using/windows.rst:1736 +#: ../../using/windows.rst:1740 msgid "" "python-3.9.0.exe InstallAllUsers=0 Include_launcher=0 Include_test=0\n" " SimpleInstall=1 SimpleInstallDescription=\"Just for me, no test suite.\"" @@ -2859,14 +2865,14 @@ msgstr "" "python-3.9.0.exe InstallAllUsers=0 Include_launcher=0 Include_test=0\n" " SimpleInstall=1 SimpleInstallDescription=\"Just for me, no test suite.\"" -#: ../../using/windows.rst:1739 +#: ../../using/windows.rst:1743 msgid "" "(Note that omitting the launcher also omits file associations, and is only " "recommended for per-user installs when there is also a system-wide " "installation that included the launcher.)" msgstr "" -#: ../../using/windows.rst:1743 +#: ../../using/windows.rst:1747 msgid "" "The options listed above can also be provided in a file named ``unattend." "xml`` alongside the executable. This file specifies a list of options and " @@ -2875,7 +2881,7 @@ msgid "" "strings. This example file sets the same options as the previous example:" msgstr "" -#: ../../using/windows.rst:1749 +#: ../../using/windows.rst:1753 msgid "" "\n" " " -#: ../../using/windows.rst:1762 +#: ../../using/windows.rst:1766 msgid "Installing without downloading" msgstr "無下載安裝" -#: ../../using/windows.rst:1764 +#: ../../using/windows.rst:1768 msgid "" "As some features of Python are not included in the initial installer " "download, selecting those features may require an internet connection. To " @@ -2910,7 +2916,7 @@ msgid "" "to be performed it is very useful to have a locally cached copy." msgstr "" -#: ../../using/windows.rst:1772 +#: ../../using/windows.rst:1776 msgid "" "Execute the following command from Command Prompt to download all possible " "required files. Remember to substitute ``python-3.9.0.exe`` for the actual " @@ -2918,27 +2924,27 @@ msgid "" "avoid collisions between files with the same name." msgstr "" -#: ../../using/windows.rst:1779 +#: ../../using/windows.rst:1783 msgid "python-3.9.0.exe /layout [optional target directory]" msgstr "python-3.9.0.exe /layout [optional target directory]" -#: ../../using/windows.rst:1781 +#: ../../using/windows.rst:1785 msgid "" "You may also specify the ``/quiet`` option to hide the progress display." msgstr "" -#: ../../using/windows.rst:1784 +#: ../../using/windows.rst:1788 msgid "Modifying an install" msgstr "" -#: ../../using/windows.rst:1786 +#: ../../using/windows.rst:1790 msgid "" "Once Python has been installed, you can add or remove features through the " "Programs and Features tool that is part of Windows. Select the Python entry " "and choose \"Uninstall/Change\" to open the installer in maintenance mode." msgstr "" -#: ../../using/windows.rst:1790 +#: ../../using/windows.rst:1794 msgid "" "\"Modify\" allows you to add or remove features by modifying the checkboxes " "- unchanged checkboxes will not install or remove anything. Some options " @@ -2946,26 +2952,26 @@ msgid "" "these, you will need to remove and then reinstall Python completely." msgstr "" -#: ../../using/windows.rst:1795 +#: ../../using/windows.rst:1799 msgid "" "\"Repair\" will verify all the files that should be installed using the " "current settings and replace any that have been removed or modified." msgstr "" -#: ../../using/windows.rst:1798 +#: ../../using/windows.rst:1802 msgid "" "\"Uninstall\" will remove Python entirely, with the exception of the :ref:" "`launcher`, which has its own entry in Programs and Features." msgstr "" -#: ../../using/windows.rst:1807 +#: ../../using/windows.rst:1811 msgid "" "To install pre-built binaries with free-threading enabled (see :pep:`703`), " "you should select \"Customize installation\". The second page of options " "includes the \"Download free-threaded binaries\" checkbox." msgstr "" -#: ../../using/windows.rst:1813 +#: ../../using/windows.rst:1817 msgid "" "Selecting this option will download and install additional binaries to the " "same location as the main Python install. The main executable is called " @@ -2974,7 +2980,7 @@ msgid "" "are shared with the main install." msgstr "" -#: ../../using/windows.rst:1819 +#: ../../using/windows.rst:1823 msgid "" "The free-threaded version is registered as a regular Python install with the " "tag ``3.13t`` (with a ``-32`` or ``-arm64`` suffix as normal for those " @@ -2986,7 +2992,7 @@ msgid "" "not install the free-threaded binaries at this time." msgstr "" -#: ../../using/windows.rst:1828 +#: ../../using/windows.rst:1832 msgid "" "To specify the install option at the command line, use " "``Include_freethreaded=1``. See :ref:`install-layout-option` for " @@ -2995,24 +3001,24 @@ msgid "" "apply to the free-threaded builds." msgstr "" -#: ../../using/windows.rst:1834 +#: ../../using/windows.rst:1838 msgid "" "Free-threaded binaries are also available :ref:`on nuget.org `." msgstr "" -#: ../../using/windows.rst:1838 +#: ../../using/windows.rst:1842 msgid "Python launcher for Windows (deprecated)" msgstr "" -#: ../../using/windows.rst:1842 +#: ../../using/windows.rst:1846 msgid "" "The launcher and this documentation have been superseded by the Python " "Install Manager described above. This is preserved temporarily for " "historical interest." msgstr "" -#: ../../using/windows.rst:1848 +#: ../../using/windows.rst:1852 msgid "" "The Python launcher for Windows is a utility which aids in locating and " "executing of different Python versions. It allows scripts (or the command-" @@ -3020,7 +3026,7 @@ msgid "" "locate and execute that version." msgstr "" -#: ../../using/windows.rst:1853 +#: ../../using/windows.rst:1857 msgid "" "Unlike the :envvar:`PATH` variable, the launcher will correctly select the " "most appropriate version of Python. It will prefer per-user installations " @@ -3028,19 +3034,19 @@ msgid "" "most recently installed version." msgstr "" -#: ../../using/windows.rst:1858 +#: ../../using/windows.rst:1862 msgid "The launcher was originally specified in :pep:`397`." msgstr "" -#: ../../using/windows.rst:1861 +#: ../../using/windows.rst:1865 msgid "Getting started" msgstr "開始" -#: ../../using/windows.rst:1864 +#: ../../using/windows.rst:1868 msgid "From the command-line" msgstr "" -#: ../../using/windows.rst:1868 +#: ../../using/windows.rst:1872 msgid "" "System-wide installations of Python 3.3 and later will put the launcher on " "your :envvar:`PATH`. The launcher is compatible with all available versions " @@ -3048,62 +3054,62 @@ msgid "" "the launcher is available, execute the following command in Command Prompt::" msgstr "" -#: ../../using/windows.rst:1873 +#: ../../using/windows.rst:1877 msgid "py" msgstr "py" -#: ../../using/windows.rst:1875 +#: ../../using/windows.rst:1879 msgid "" "You should find that the latest version of Python you have installed is " "started - it can be exited as normal, and any additional command-line " "arguments specified will be sent directly to Python." msgstr "" -#: ../../using/windows.rst:1879 +#: ../../using/windows.rst:1883 msgid "" "If you have multiple versions of Python installed (e.g., 3.7 and |version|) " "you will have noticed that Python |version| was started - to launch Python " "3.7, try the command::" msgstr "" -#: ../../using/windows.rst:1883 +#: ../../using/windows.rst:1887 msgid "py -3.7" msgstr "py -3.7" -#: ../../using/windows.rst:1885 +#: ../../using/windows.rst:1889 msgid "" "If you want the latest version of Python 2 you have installed, try the " "command::" msgstr "" -#: ../../using/windows.rst:1888 +#: ../../using/windows.rst:1892 msgid "py -2" msgstr "py -2" -#: ../../using/windows.rst:1890 +#: ../../using/windows.rst:1894 msgid "" "If you see the following error, you do not have the launcher installed::" msgstr "" -#: ../../using/windows.rst:1892 +#: ../../using/windows.rst:1896 msgid "" "'py' is not recognized as an internal or external command,\n" "operable program or batch file." msgstr "" -#: ../../using/windows.rst:1895 +#: ../../using/windows.rst:1899 msgid "The command::" msgstr "指令: ::" -#: ../../using/windows.rst:1897 +#: ../../using/windows.rst:1901 msgid "py --list" msgstr "py --list" -#: ../../using/windows.rst:1899 +#: ../../using/windows.rst:1903 msgid "displays the currently installed version(s) of Python." msgstr "" -#: ../../using/windows.rst:1901 +#: ../../using/windows.rst:1905 msgid "" "The ``-x.y`` argument is the short form of the ``-V:Company/Tag`` argument, " "which allows selecting a specific Python runtime, including those that may " @@ -3112,14 +3118,14 @@ msgid "" "available runtimes using the ``-V:`` format." msgstr "" -#: ../../using/windows.rst:1907 +#: ../../using/windows.rst:1911 msgid "" "When using the ``-V:`` argument, specifying the Company will limit selection " "to runtimes from that provider, while specifying only the Tag will select " "from all providers. Note that omitting the slash implies a tag::" msgstr "" -#: ../../using/windows.rst:1911 +#: ../../using/windows.rst:1915 msgid "" "# Select any '3.*' tagged runtime\n" "py -V:3\n" @@ -3131,14 +3137,14 @@ msgid "" "py -V:PythonCore/3" msgstr "" -#: ../../using/windows.rst:1920 +#: ../../using/windows.rst:1924 msgid "" "The short form of the argument (``-3``) only ever selects from core Python " "releases, and not other distributions. However, the longer form (``-V:3``) " "will select from any." msgstr "" -#: ../../using/windows.rst:1924 +#: ../../using/windows.rst:1928 msgid "" "The Company is matched on the full string, case-insensitive. The Tag is " "matched on either the full string, or a prefix, provided the next character " @@ -3147,11 +3153,11 @@ msgid "" "``3.1``), but are compared using text (``-V:3.01`` does not match ``3.1``)." msgstr "" -#: ../../using/windows.rst:1932 +#: ../../using/windows.rst:1936 msgid "Virtual environments" msgstr "虛擬環境(Virtual environment)" -#: ../../using/windows.rst:1936 +#: ../../using/windows.rst:1940 msgid "" "If the launcher is run with no explicit Python version specification, and a " "virtual environment (created with the standard library :mod:`venv` module or " @@ -3161,17 +3167,17 @@ msgid "" "specify the global Python version." msgstr "" -#: ../../using/windows.rst:1944 +#: ../../using/windows.rst:1948 msgid "From a script" msgstr "" -#: ../../using/windows.rst:1946 +#: ../../using/windows.rst:1950 msgid "" "Let's create a test Python script - create a file called ``hello.py`` with " "the following contents" msgstr "" -#: ../../using/windows.rst:1949 +#: ../../using/windows.rst:1953 msgid "" "#! python\n" "import sys\n" @@ -3181,25 +3187,25 @@ msgstr "" "import sys\n" "sys.stdout.write(\"hello from Python %s\\n\" % (sys.version,))" -#: ../../using/windows.rst:1955 +#: ../../using/windows.rst:1959 msgid "From the directory in which hello.py lives, execute the command::" msgstr "" -#: ../../using/windows.rst:1957 +#: ../../using/windows.rst:1961 msgid "py hello.py" msgstr "py hello.py" -#: ../../using/windows.rst:1959 +#: ../../using/windows.rst:1963 msgid "" "You should notice the version number of your latest Python 2.x installation " "is printed. Now try changing the first line to be:" msgstr "" -#: ../../using/windows.rst:1962 +#: ../../using/windows.rst:1966 msgid "#! python3" msgstr "#! python3" -#: ../../using/windows.rst:1966 +#: ../../using/windows.rst:1970 msgid "" "Re-executing the command should now print the latest Python 3.x information. " "As with the above command-line examples, you can specify a more explicit " @@ -3208,7 +3214,7 @@ msgid "" "information printed." msgstr "" -#: ../../using/windows.rst:1972 +#: ../../using/windows.rst:1976 msgid "" "Note that unlike interactive use, a bare \"python\" will use the latest " "version of Python 2.x that you have installed. This is for backward " @@ -3216,11 +3222,11 @@ msgid "" "typically refers to Python 2." msgstr "" -#: ../../using/windows.rst:1978 +#: ../../using/windows.rst:1982 msgid "From file associations" msgstr "從檔案關聯" -#: ../../using/windows.rst:1980 +#: ../../using/windows.rst:1984 msgid "" "The launcher should have been associated with Python files (i.e. ``.py``, ``." "pyw``, ``.pyc`` files) when it was installed. This means that when you " @@ -3229,13 +3235,13 @@ msgid "" "have the script specify the version which should be used." msgstr "" -#: ../../using/windows.rst:1986 +#: ../../using/windows.rst:1990 msgid "" "The key benefit of this is that a single launcher can support multiple " "Python versions at the same time depending on the contents of the first line." msgstr "" -#: ../../using/windows.rst:1992 +#: ../../using/windows.rst:1996 msgid "" "If the first line of a script file starts with ``#!``, it is known as a " "\"shebang\" line. Linux and other Unix like operating systems have native " @@ -3245,30 +3251,30 @@ msgid "" "demonstrate their use." msgstr "" -#: ../../using/windows.rst:1999 +#: ../../using/windows.rst:2003 msgid "" "To allow shebang lines in Python scripts to be portable between Unix and " "Windows, this launcher supports a number of 'virtual' commands to specify " "which interpreter to use. The supported virtual commands are:" msgstr "" -#: ../../using/windows.rst:2003 +#: ../../using/windows.rst:2007 msgid "``/usr/bin/env``" msgstr "``/usr/bin/env``" -#: ../../using/windows.rst:2004 +#: ../../using/windows.rst:2008 msgid "``/usr/bin/python``" msgstr "``/usr/bin/python``" -#: ../../using/windows.rst:2005 +#: ../../using/windows.rst:2009 msgid "``/usr/local/bin/python``" msgstr "``/usr/local/bin/python``" -#: ../../using/windows.rst:2006 +#: ../../using/windows.rst:2010 msgid "``python``" msgstr "``python``" -#: ../../using/windows.rst:2020 +#: ../../using/windows.rst:2024 msgid "" "Any of the above virtual commands can be suffixed with an explicit version " "(either just the major version, or the major and minor version). Furthermore " @@ -3278,21 +3284,21 @@ msgid "" "and the environment will be used." msgstr "" -#: ../../using/windows.rst:2029 +#: ../../using/windows.rst:2033 msgid "" "Beginning with python launcher 3.7 it is possible to request 64-bit version " "by the \"-64\" suffix. Furthermore it is possible to specify a major and " "architecture without minor (i.e. ``/usr/bin/python3-64``)." msgstr "" -#: ../../using/windows.rst:2035 +#: ../../using/windows.rst:2039 msgid "" "The \"-64\" suffix is deprecated, and now implies \"any architecture that is " "not provably i386/32-bit\". To request a specific environment, use the new :" "samp:`-V:{TAG}` argument with the complete tag." msgstr "" -#: ../../using/windows.rst:2041 +#: ../../using/windows.rst:2045 msgid "" "Virtual commands referencing ``python`` now prefer an active virtual " "environment rather than searching :envvar:`PATH`. This handles cases where " @@ -3300,7 +3306,7 @@ msgid "" "not present in the active environment." msgstr "" -#: ../../using/windows.rst:2046 +#: ../../using/windows.rst:2050 msgid "" "The ``/usr/bin/env`` form of shebang line has one further special property. " "Before looking for installed Python interpreters, this form will search the " @@ -3314,7 +3320,7 @@ msgid "" "envvar:`PATH`." msgstr "" -#: ../../using/windows.rst:2057 +#: ../../using/windows.rst:2061 msgid "" "Shebang lines that do not match any of these patterns are looked up in the " "``[commands]`` section of the launcher's :ref:`.INI file `. " @@ -3325,7 +3331,7 @@ msgid "" "part of the filename)." msgstr "" -#: ../../using/windows.rst:2065 +#: ../../using/windows.rst:2069 msgid "" "[commands]\n" "/bin/xpython=C:\\Program Files\\XPython\\python.exe" @@ -3333,7 +3339,7 @@ msgstr "" "[commands]\n" "/bin/xpython=C:\\Program Files\\XPython\\python.exe" -#: ../../using/windows.rst:2070 +#: ../../using/windows.rst:2074 msgid "" "Any commands not found in the .INI file are treated as **Windows** " "executable paths that are absolute or relative to the directory containing " @@ -3344,33 +3350,33 @@ msgid "" "will be appended." msgstr "" -#: ../../using/windows.rst:2079 +#: ../../using/windows.rst:2083 msgid "Arguments in shebang lines" msgstr "" -#: ../../using/windows.rst:2081 +#: ../../using/windows.rst:2085 msgid "" "The shebang lines can also specify additional options to be passed to the " "Python interpreter. For example, if you have a shebang line:" msgstr "" -#: ../../using/windows.rst:2084 +#: ../../using/windows.rst:2088 msgid "#! /usr/bin/python -v" msgstr "#! /usr/bin/python -v" -#: ../../using/windows.rst:2088 +#: ../../using/windows.rst:2092 msgid "Then Python will be started with the ``-v`` option" msgstr "" -#: ../../using/windows.rst:2091 +#: ../../using/windows.rst:2095 msgid "Customization" msgstr "" -#: ../../using/windows.rst:2096 +#: ../../using/windows.rst:2100 msgid "Customization via INI files" msgstr "" -#: ../../using/windows.rst:2098 +#: ../../using/windows.rst:2102 msgid "" "Two .ini files will be searched by the launcher - ``py.ini`` in the current " "user's application data directory (``%LOCALAPPDATA%`` or ``$env:" @@ -3379,7 +3385,7 @@ msgid "" "e. py.exe) and for the 'windows' version (i.e. pyw.exe)." msgstr "" -#: ../../using/windows.rst:2104 +#: ../../using/windows.rst:2108 msgid "" "Customization specified in the \"application directory\" will have " "precedence over the one next to the executable, so a user, who may not have " @@ -3387,11 +3393,11 @@ msgid "" "that global .ini file." msgstr "" -#: ../../using/windows.rst:2109 +#: ../../using/windows.rst:2113 msgid "Customizing default Python versions" msgstr "" -#: ../../using/windows.rst:2111 +#: ../../using/windows.rst:2115 msgid "" "In some cases, a version qualifier can be included in a command to dictate " "which version of Python will be used by the command. A version qualifier " @@ -3401,13 +3407,13 @@ msgid "" "\"-32\" or \"-64\"." msgstr "" -#: ../../using/windows.rst:2117 +#: ../../using/windows.rst:2121 msgid "" "For example, a shebang line of ``#!python`` has no version qualifier, while " "``#!python3`` has a version qualifier which specifies only a major version." msgstr "" -#: ../../using/windows.rst:2120 +#: ../../using/windows.rst:2124 msgid "" "If no version qualifiers are found in a command, the environment variable :" "envvar:`!PY_PYTHON` can be set to specify the default version qualifier. If " @@ -3417,7 +3423,7 @@ msgid "" "launcher included with Python 3.7 or newer.)" msgstr "" -#: ../../using/windows.rst:2127 +#: ../../using/windows.rst:2131 msgid "" "If no minor version qualifiers are found, the environment variable " "``PY_PYTHON{major}`` (where ``{major}`` is the current major version " @@ -3428,7 +3434,7 @@ msgid "" "version in that family." msgstr "" -#: ../../using/windows.rst:2135 +#: ../../using/windows.rst:2139 msgid "" "On 64-bit Windows with both 32-bit and 64-bit implementations of the same " "(major.minor) Python version installed, the 64-bit version will always be " @@ -3442,30 +3448,30 @@ msgid "" "suffix can be used on a version specifier to change this behaviour." msgstr "" -#: ../../using/windows.rst:2146 +#: ../../using/windows.rst:2150 msgid "Examples:" msgstr "範例:" -#: ../../using/windows.rst:2148 +#: ../../using/windows.rst:2152 msgid "" "If no relevant options are set, the commands ``python`` and ``python2`` will " "use the latest Python 2.x version installed and the command ``python3`` will " "use the latest Python 3.x installed." msgstr "" -#: ../../using/windows.rst:2152 +#: ../../using/windows.rst:2156 msgid "" "The command ``python3.7`` will not consult any options at all as the " "versions are fully specified." msgstr "" -#: ../../using/windows.rst:2155 +#: ../../using/windows.rst:2159 msgid "" "If ``PY_PYTHON=3``, the commands ``python`` and ``python3`` will both use " "the latest installed Python 3 version." msgstr "" -#: ../../using/windows.rst:2158 +#: ../../using/windows.rst:2162 msgid "" "If ``PY_PYTHON=3.7-32``, the command ``python`` will use the 32-bit " "implementation of 3.7 whereas the command ``python3`` will use the latest " @@ -3473,13 +3479,13 @@ msgid "" "specified.)" msgstr "" -#: ../../using/windows.rst:2163 +#: ../../using/windows.rst:2167 msgid "" "If ``PY_PYTHON=3`` and ``PY_PYTHON3=3.7``, the commands ``python`` and " "``python3`` will both use specifically 3.7" msgstr "" -#: ../../using/windows.rst:2166 +#: ../../using/windows.rst:2170 msgid "" "In addition to environment variables, the same settings can be configured in " "the .INI file used by the launcher. The section in the INI file is called " @@ -3489,15 +3495,15 @@ msgid "" "will override things specified in the INI file." msgstr "" -#: ../../using/windows.rst:2173 +#: ../../using/windows.rst:2177 msgid "For example:" msgstr "舉例來說:" -#: ../../using/windows.rst:2175 +#: ../../using/windows.rst:2179 msgid "Setting ``PY_PYTHON=3.7`` is equivalent to the INI file containing:" msgstr "" -#: ../../using/windows.rst:2177 +#: ../../using/windows.rst:2181 msgid "" "[defaults]\n" "python=3.7" @@ -3505,13 +3511,13 @@ msgstr "" "[defaults]\n" "python=3.7" -#: ../../using/windows.rst:2182 +#: ../../using/windows.rst:2186 msgid "" "Setting ``PY_PYTHON=3`` and ``PY_PYTHON3=3.7`` is equivalent to the INI file " "containing:" msgstr "" -#: ../../using/windows.rst:2185 +#: ../../using/windows.rst:2189 msgid "" "[defaults]\n" "python=3\n" @@ -3521,11 +3527,11 @@ msgstr "" "python=3\n" "python3=3.7" -#: ../../using/windows.rst:2192 +#: ../../using/windows.rst:2196 msgid "Diagnostics" msgstr "" -#: ../../using/windows.rst:2194 +#: ../../using/windows.rst:2198 msgid "" "If an environment variable :envvar:`!PYLAUNCHER_DEBUG` is set (to any " "value), the launcher will print diagnostic information to stderr (i.e. to " @@ -3536,11 +3542,11 @@ msgid "" "debugging." msgstr "" -#: ../../using/windows.rst:2202 +#: ../../using/windows.rst:2206 msgid "Dry run" msgstr "" -#: ../../using/windows.rst:2204 +#: ../../using/windows.rst:2208 msgid "" "If an environment variable :envvar:`!PYLAUNCHER_DRYRUN` is set (to any " "value), the launcher will output the command it would have run, but will not " @@ -3550,11 +3556,11 @@ msgid "" "correctly in the console." msgstr "" -#: ../../using/windows.rst:2212 +#: ../../using/windows.rst:2216 msgid "Install on demand" msgstr "安裝隨選" -#: ../../using/windows.rst:2214 +#: ../../using/windows.rst:2218 msgid "" "If an environment variable :envvar:`!PYLAUNCHER_ALLOW_INSTALL` is set (to " "any value), and the requested Python version is not installed but is " @@ -3563,7 +3569,7 @@ msgid "" "command again." msgstr "" -#: ../../using/windows.rst:2219 +#: ../../using/windows.rst:2223 msgid "" "An additional :envvar:`!PYLAUNCHER_ALWAYS_INSTALL` variable causes the " "launcher to always try to install Python, even if it is detected. This is " @@ -3571,111 +3577,111 @@ msgid "" "PYLAUNCHER_DRYRUN`)." msgstr "" -#: ../../using/windows.rst:2224 +#: ../../using/windows.rst:2228 msgid "Return codes" msgstr "" -#: ../../using/windows.rst:2226 +#: ../../using/windows.rst:2230 msgid "" "The following exit codes may be returned by the Python launcher. " "Unfortunately, there is no way to distinguish these from the exit code of " "Python itself." msgstr "" -#: ../../using/windows.rst:2229 +#: ../../using/windows.rst:2233 msgid "" "The names of codes are as used in the sources, and are only for reference. " "There is no way to access or resolve them apart from reading this page. " "Entries are listed in alphabetical order of names." msgstr "" -#: ../../using/windows.rst:2234 +#: ../../using/windows.rst:2238 msgid "Value" msgstr "" -#: ../../using/windows.rst:2236 +#: ../../using/windows.rst:2240 msgid "RC_BAD_VENV_CFG" msgstr "RC_BAD_VENV_CFG" -#: ../../using/windows.rst:2236 +#: ../../using/windows.rst:2240 msgid "107" msgstr "107" -#: ../../using/windows.rst:2236 +#: ../../using/windows.rst:2240 msgid "A :file:`pyvenv.cfg` was found but is corrupt." msgstr "" -#: ../../using/windows.rst:2238 +#: ../../using/windows.rst:2242 msgid "RC_CREATE_PROCESS" msgstr "RC_CREATE_PROCESS" -#: ../../using/windows.rst:2238 +#: ../../using/windows.rst:2242 msgid "101" msgstr "101" -#: ../../using/windows.rst:2238 +#: ../../using/windows.rst:2242 msgid "Failed to launch Python." msgstr "" -#: ../../using/windows.rst:2240 +#: ../../using/windows.rst:2244 msgid "RC_INSTALLING" msgstr "RC_INSTALLING" -#: ../../using/windows.rst:2240 +#: ../../using/windows.rst:2244 msgid "111" msgstr "111" -#: ../../using/windows.rst:2240 +#: ../../using/windows.rst:2244 msgid "" "An install was started, but the command will need to be re-run after it " "completes." msgstr "" -#: ../../using/windows.rst:2243 +#: ../../using/windows.rst:2247 msgid "RC_INTERNAL_ERROR" msgstr "RC_INTERNAL_ERROR" -#: ../../using/windows.rst:2243 +#: ../../using/windows.rst:2247 msgid "109" msgstr "109" -#: ../../using/windows.rst:2243 +#: ../../using/windows.rst:2247 msgid "Unexpected error. Please report a bug." msgstr "" -#: ../../using/windows.rst:2245 +#: ../../using/windows.rst:2249 msgid "RC_NO_COMMANDLINE" msgstr "RC_NO_COMMANDLINE" -#: ../../using/windows.rst:2245 +#: ../../using/windows.rst:2249 msgid "108" msgstr "108" -#: ../../using/windows.rst:2245 +#: ../../using/windows.rst:2249 msgid "Unable to obtain command line from the operating system." msgstr "" -#: ../../using/windows.rst:2248 +#: ../../using/windows.rst:2252 msgid "RC_NO_PYTHON" msgstr "RC_NO_PYTHON" -#: ../../using/windows.rst:2248 +#: ../../using/windows.rst:2252 msgid "103" msgstr "103" -#: ../../using/windows.rst:2248 +#: ../../using/windows.rst:2252 msgid "Unable to locate the requested version." msgstr "" -#: ../../using/windows.rst:2250 +#: ../../using/windows.rst:2254 msgid "RC_NO_VENV_CFG" msgstr "RC_NO_VENV_CFG" -#: ../../using/windows.rst:2250 +#: ../../using/windows.rst:2254 msgid "106" msgstr "106" -#: ../../using/windows.rst:2250 +#: ../../using/windows.rst:2254 msgid "A :file:`pyvenv.cfg` was required but not found." msgstr "" diff --git a/whatsnew/2.5.po b/whatsnew/2.5.po index 6a0ffd7fe0e..b4eb373b4ea 100644 --- a/whatsnew/2.5.po +++ b/whatsnew/2.5.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-11 00:28+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:20+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -2023,12 +2023,12 @@ msgstr "" #: ../../whatsnew/2.5.rst:1281 msgid "" -"New module: The :mod:`cProfile` module is a C implementation of the " -"existing :mod:`profile` module that has much lower overhead. The module's " -"interface is the same as :mod:`profile`: you run ``cProfile.run('main()')`` " +"New module: The :mod:`!cProfile` module is a C implementation of the " +"existing :mod:`!profile` module that has much lower overhead. The module's " +"interface is the same as :mod:`!profile`: you run ``cProfile.run('main()')`` " "to profile a function, can save profile data to a file, etc. It's not yet " "known if the Hotshot profiler, which is also written in C but doesn't match " -"the :mod:`profile` module's interface, will continue to be maintained in " +"the :mod:`!profile` module's interface, will continue to be maintained in " "future versions of Python. (Contributed by Armin Rigo.)" msgstr "" diff --git a/whatsnew/2.6.po b/whatsnew/2.6.po index f54e1f06a8a..b938635cc00 100644 --- a/whatsnew/2.6.po +++ b/whatsnew/2.6.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:20+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -4806,7 +4806,7 @@ msgstr "" msgid "" "Importing modules simultaneously in two different threads no longer " "deadlocks; it will now raise an :exc:`ImportError`. A new API function, :c:" -"func:`PyImport_ImportModuleNoBlock`, will look for a module in ``sys." +"func:`!PyImport_ImportModuleNoBlock`, will look for a module in ``sys." "modules`` first, then try to import it after acquiring an import lock. If " "the import lock is held by another thread, an :exc:`ImportError` is raised. " "(Contributed by Christian Heimes.)" diff --git a/whatsnew/3.0.po b/whatsnew/3.0.po index e23e8bd1141..f4c10a91837 100644 --- a/whatsnew/3.0.po +++ b/whatsnew/3.0.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:20+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1322,9 +1322,9 @@ msgstr "" #: ../../whatsnew/3.0.rst:873 msgid "" -"New C API :c:func:`PyImport_ImportModuleNoBlock`, works " -"like :c:func:`PyImport_ImportModule` but won't block on the import lock " -"(returning an error instead)." +"New C API :c:func:`!PyImport_ImportModuleNoBlock`, works like :c:func:" +"`PyImport_ImportModule` but won't block on the import lock (returning an " +"error instead)." msgstr "" #: ../../whatsnew/3.0.rst:877 diff --git a/whatsnew/3.10.po b/whatsnew/3.10.po index af126918bdd..b0cf59227d6 100644 --- a/whatsnew/3.10.po +++ b/whatsnew/3.10.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-06-26 03:02+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -716,14 +716,14 @@ msgstr "影格 (frame) 物件的 :attr:`~frame.f_lineno` 屬性總會包含預 #: ../../whatsnew/3.10.rst:405 msgid "" -"The :attr:`~codeobject.co_lnotab` attribute of :ref:`code objects ` is deprecated and will be removed in 3.12. Code that needs to " "convert from offset to line number should use the new :meth:`~codeobject." "co_lines` method instead." msgstr "" -":ref:`程式碼物件 `\\ 的 :attr:`~codeobject.co_lnotab` 屬性已棄" -"用,並將在 3.12 中刪除。需要從偏移量轉換為列號的程式碼應使用新的 :meth:" -"`~codeobject.co_lines` 方法。" +":ref:`程式碼物件 `\\ 的 :attr:`!codeobject.co_lnotab` 屬性已棄" +"用,並將在 3.12 中刪除。需要從偏移量轉換為列號的程式碼應使用新" +"的 :meth:`~codeobject.co_lines` 方法。" #: ../../whatsnew/3.10.rst:412 msgid "PEP 634: Structural Pattern Matching" @@ -3135,8 +3135,8 @@ msgid "" "Starting in this release, there will be a concerted effort to begin cleaning " "up old import semantics that were kept for Python 2.7 compatibility. " "Specifically, :meth:`!find_loader`/:meth:`!find_module` (superseded by :meth:" -"`~importlib.abc.MetaPathFinder.find_spec`), :meth:`~importlib.abc.Loader." -"load_module` (superseded by :meth:`~importlib.abc.Loader.exec_module`), :" +"`~importlib.abc.MetaPathFinder.find_spec`), ``importlib.abc.Loader." +"load_module`` (superseded by :meth:`~importlib.abc.Loader.exec_module`), :" "meth:`!module_repr` (which the import system takes care of for you), the " "``__package__`` attribute (superseded by ``__spec__.parent``), the " "``__loader__`` attribute (superseded by ``__spec__.loader``), and the " @@ -3147,14 +3147,15 @@ msgid "" "transition." msgstr "" "從這個版本開始,我們將齊心協力開始清理為相容 Python 2.7 而保留的舊引入語義。" -"具體來說, :meth:`!find_loader`/:meth:`!find_module` (被 :meth:`~importlib." -"abc.MetaPathFinder.find_spec` 取代)、:meth:`~importlib.abc.Loader." -"load_module` (被 :meth:`~importlib.abc.Loader.exec_module` 取代)、 :meth:`!" -"module_repr` (引入系統負責處理你)、``__package__`` 屬性(由 ``__spec__." -"parent`` 取代)、 ``__loader__`` 屬性(由 ``__spec__.loader`` 取代)和 " -"``__cached__`` 屬性(由 ``__spec__.cached`` 取代)將慢慢被刪除(以及 :mod:" -"`importlib` 中的其他類別和方法)。將酌情引發 :exc:`ImportWarning` 和/或 :exc:" -"`DeprecationWarning` 以幫助識別在此轉換期間需要更新的程式碼。" +"具體來說, :meth:`!find_loader`/:meth:`!find_module` " +"(被 :meth:`~importlib.abc.MetaPathFinder.find_spec` 取代)、" +"``importlib.abc.Loader.load_module`` " +"(被 :meth:`~importlib.abc.Loader.exec_module` 取代)、 :meth:`!module_repr` " +"(引入系統會替你處理)、``__package__`` 屬性(由 ``__spec__.parent`` 取" +"代)、 ``__loader__`` 屬性(由 ``__spec__.loader`` 取代)和 ``__cached__`` 屬" +"性(由 ``__spec__.cached`` 取代)將慢慢被刪除(以及 :mod:`importlib` 中的其他" +"類別和方法)。將酌情引發 :exc:`ImportWarning` 和/" +"或 :exc:`DeprecationWarning` 以幫助識別在此轉換期間需要更新的程式碼。" #: ../../whatsnew/3.10.rst:1637 msgid "" @@ -3197,13 +3198,13 @@ msgstr "" #: ../../whatsnew/3.10.rst:1655 msgid "" -"The use of :meth:`~importlib.abc.Loader.load_module` by the import system " -"now triggers an :exc:`ImportWarning` as :meth:`~importlib.abc.Loader." +"The use of ``importlib.abc.Loader.load_module`` by the import system now " +"triggers an :exc:`ImportWarning` as :meth:`~importlib.abc.Loader." "exec_module` is preferred. (Contributed by Brett Cannon in :issue:`26131`.)" msgstr "" -"引入系統使用 :meth:`~importlib.abc.Loader.load_module` 現在會觸發 :exc:" -"`ImportWarning`,因為 :meth:`~importlib.abc.Loader.exec_module` 是目前首選。" -"(由 Brett Cannon 在 :issue:`26131` 中貢獻。)" +"引入系統使用 ``importlib.abc.Loader.load_module`` 現在會觸" +"發 :exc:`ImportWarning`,因為 :meth:`~importlib.abc.Loader.exec_module` 是目" +"前首選。(由 Brett Cannon 在 :issue:`26131` 中貢獻。)" #: ../../whatsnew/3.10.rst:1660 msgid "" @@ -4266,17 +4267,17 @@ msgstr "" #: ../../whatsnew/3.10.rst:2180 msgid "" -":c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, :c:" -"func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` and :c:func:" -"`Py_GetProgramName` functions now return ``NULL`` if called before :c:func:" -"`Py_Initialize` (before Python is initialized). Use the new :ref:`init-" -"config` API to get the :ref:`init-path-config`. (Contributed by Victor " -"Stinner in :issue:`42260`.)" -msgstr "" -"如果在 :c:func:`Py_Initialize` 之前(Python 初始化之前)被呼叫,:c:func:" -"`Py_GetPath`、:c:func:`Py_GetPrefix`、:c:func:`Py_GetExecPrefix`、:c:func:" -"`Py_GetProgramFullPath`、:c:func:`Py_GetPythonHome` 和 :c:func:" -"`Py_GetProgramName` 現在會回傳 ``NULL``。使用新的 :ref:`init-config` API 來取" +":c:func:`!Py_GetPath`, :c:func:`!Py_GetPrefix`, :c:func:`!" +"Py_GetExecPrefix`, :c:func:`!Py_GetProgramFullPath`, :c:func:`!" +"Py_GetPythonHome` and :c:func:`!Py_GetProgramName` functions now return " +"``NULL`` if called before :c:func:`Py_Initialize` (before Python is " +"initialized). Use the new :ref:`init-config` API to get the :ref:`init-path-" +"config`. (Contributed by Victor Stinner in :issue:`42260`.)" +msgstr "" +"如果在 :c:func:`Py_Initialize` 之前(Python 初始化之前)被呼叫,:c:func:`!" +"Py_GetPath`、:c:func:`!Py_GetPrefix`、:c:func:`!Py_GetExecPrefix`、:c:func:`!" +"Py_GetProgramFullPath`、:c:func:`!Py_GetPythonHome` 和 :c:func:`!" +"Py_GetProgramName` 現在會回傳 ``NULL``。使用新的 :ref:`init-config` API 來取" "得 :ref:`init-path-config`。(由 Victor Stinner 在 :issue:`42260` 中貢獻。)" #: ../../whatsnew/3.10.rst:2187 diff --git a/whatsnew/3.11.po b/whatsnew/3.11.po index 1ebbf47fa6d..237f0283e4d 100644 --- a/whatsnew/3.11.po +++ b/whatsnew/3.11.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2023-05-28 18:21+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -5454,13 +5454,13 @@ msgstr "(由 Victor Stinner 於 :issue:`45474` 中所貢獻。)" #: ../../whatsnew/3.11.rst:2676 msgid "" -"Exclude :c:func:`PyWeakref_GET_OBJECT` from the limited C API. It never " +"Exclude :c:func:`!PyWeakref_GET_OBJECT` from the limited C API. It never " "worked since the :c:type:`!PyWeakReference` structure is opaque in the " "limited C API. (Contributed by Victor Stinner in :issue:`35134`.)" msgstr "" -"將 :c:func:`PyWeakref_GET_OBJECT` 排除於受限 C API 之外,它因為 :c:type:`!" -"PyWeakReference` 結構在受限 C API 中過於晦澀而從未運作。(由 Victor Stinner " -"於 :issue:`35134` 中所貢獻。)" +"將 :c:func:`!PyWeakref_GET_OBJECT` 排除於受限 C API 之外,它因為 :c:type:`!" +"PyWeakReference` 結構在受限 C API 中是不透明的而從未運作。(由 Victor " +"Stinner 於 :issue:`35134` 中所貢獻。)" #: ../../whatsnew/3.11.rst:2681 msgid "" diff --git a/whatsnew/3.12.po b/whatsnew/3.12.po index 1232a713c1d..590926154db 100644 --- a/whatsnew/3.12.po +++ b/whatsnew/3.12.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -304,7 +304,7 @@ msgstr "" "`unittest.TestCase` 的\\ `方法別名 `_\\ " "已被刪除。" -#: ../../whatsnew/3.12.rst:176 ../../whatsnew/3.12.rst:1856 +#: ../../whatsnew/3.12.rst:176 ../../whatsnew/3.12.rst:1860 msgid "New Features" msgstr "新增功能" @@ -1588,7 +1588,7 @@ msgstr "" "才在 Windows 搜尋路徑中的其他位置進行直接匹配。(由 Charles Machalow 在 :gh:" "`103179` 中貢獻。)" -#: ../../whatsnew/3.12.rst:869 ../../whatsnew/3.12.rst:1560 +#: ../../whatsnew/3.12.rst:869 ../../whatsnew/3.12.rst:1564 msgid "sqlite3" msgstr "sqlite3" @@ -1686,7 +1686,7 @@ msgstr "" "last_value` 和 :data:`sys.last_traceback`。(由 Irit Katriel 在 :gh:`102778` " "中貢獻。)" -#: ../../whatsnew/3.12.rst:920 ../../whatsnew/3.12.rst:1755 +#: ../../whatsnew/3.12.rst:920 ../../whatsnew/3.12.rst:1759 msgid "" ":func:`sys._current_exceptions` now returns a mapping from thread-id to an " "exception instance, rather than to a ``(typ, exc, tb)`` tuple. (Contributed " @@ -1916,7 +1916,7 @@ msgstr "" "Unicode 資料庫已更新至版本 15.0.0。(由 Benjamin Peterson 在 :gh:`96734` 中貢" "獻)。" -#: ../../whatsnew/3.12.rst:1034 ../../whatsnew/3.12.rst:1600 +#: ../../whatsnew/3.12.rst:1034 ../../whatsnew/3.12.rst:1604 msgid "unittest" msgstr "unittest" @@ -2173,7 +2173,7 @@ msgstr "" "`_\\ 中找到副本。(由 Victor " "Stinner 在 :gh:`97669` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1151 ../../whatsnew/3.12.rst:2158 +#: ../../whatsnew/3.12.rst:1151 ../../whatsnew/3.12.rst:2162 msgid "Deprecated" msgstr "已棄用" @@ -2292,8 +2292,8 @@ msgid ":mod:`collections.abc`: Deprecated :class:`collections.abc.ByteString`." msgstr ":mod:`collections.abc`:棄用 :class:`collections.abc.ByteString`。" #: ../../whatsnew/3.12.rst:1196 -#: ../../deprecations/pending-removal-in-3.17.rst:8 -#: ../../deprecations/pending-removal-in-3.17.rst:36 +#: ../../deprecations/pending-removal-in-3.17.rst:16 +#: ../../deprecations/pending-removal-in-3.17.rst:62 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -2307,8 +2307,8 @@ msgstr "" "如 ``bytes | bytearray | memoryview``)。" #: ../../whatsnew/3.12.rst:1202 -#: ../../deprecations/pending-removal-in-3.17.rst:14 -#: ../../deprecations/pending-removal-in-3.17.rst:42 +#: ../../deprecations/pending-removal-in-3.17.rst:22 +#: ../../deprecations/pending-removal-in-3.17.rst:68 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -2325,8 +2325,8 @@ msgstr "" "ByteString` 的子型別(無論是在 runtime 還是由靜態型別檢查器)。" #: ../../whatsnew/3.12.rst:1210 -#: ../../deprecations/pending-removal-in-3.17.rst:22 -#: ../../deprecations/pending-removal-in-3.17.rst:50 +#: ../../deprecations/pending-removal-in-3.17.rst:30 +#: ../../deprecations/pending-removal-in-3.17.rst:76 msgid "" "See :pep:`PEP 688 <688#current-options>` for more details. (Contributed by " "Shantanu Jain in :gh:`91896`.)" @@ -2562,7 +2562,8 @@ msgstr "" #: ../../whatsnew/3.12.rst:1312 #: ../../deprecations/pending-removal-in-3.15.rst:70 -#: ../../deprecations/pending-removal-in-3.17.rst:26 +#: ../../deprecations/pending-removal-in-3.17.rst:52 +#: ../../deprecations/pending-removal-in-3.20.rst:57 msgid ":mod:`typing`:" msgstr ":mod:`typing`:" @@ -2624,13 +2625,12 @@ msgstr "" #: ../../whatsnew/3.12.rst:1340 msgid "" -"Setting :attr:`~module.__package__` or :attr:`~module.__cached__` on a " -"module is deprecated, and will cease to be set or taken into consideration " -"by the import system in Python 3.14. (Contributed by Brett Cannon in :gh:" -"`65961`.)" +"Setting :attr:`~module.__package__` or ``__cached__`` on a module is " +"deprecated, and will cease to be set or taken into consideration by the " +"import system in Python 3.14. (Contributed by Brett Cannon in :gh:`65961`.)" msgstr "" -"在模組上設定 :attr:`~module.__package__` 或 :attr:`~module.__cached__` 已被棄" -"用,並且 Python 3.14 中的引入系統將不再設定或考慮該設定。(由 Brett Cannon " +"在模組上設定 :attr:`~module.__package__` 或 ``__cached__`` 已被棄用,並且 " +"Python 3.14 中的引入系統將不再設定或考慮該設定。(由 Brett Cannon " "在 :gh:`65961` 中貢獻。)" #: ../../whatsnew/3.12.rst:1344 @@ -2648,14 +2648,14 @@ msgstr "" #: ../../whatsnew/3.12.rst:1350 msgid "" -"Accessing :attr:`~codeobject.co_lnotab` on code objects was deprecated in " +"Accessing :attr:`!codeobject.co_lnotab` on code objects was deprecated in " "Python 3.10 via :pep:`626`, but it only got a proper :exc:" "`DeprecationWarning` in 3.12. May be removed in 3.15. (Contributed by Nikita " "Sobolev in :gh:`101866`.)" msgstr "" -"自 3.10 起,於程式碼物件存取 :attr:`~codeobject.co_lnotab` 的功能已在 :pep:" -"`626` 中被棄用,但只在 3.12 中於適時發出 :exc:`DeprecationWarning`。可能在 " -"3.15 中移除。(由 Nikita Sobolev 於 :gh:`101866` 貢獻。)" +"自 3.10 起,於程式碼物件存取 :attr:`!codeobject.co_lnotab` 的功能已" +"在 :pep:`626` 中被棄用,但只在 3.12 中於適時發出 :exc:`DeprecationWarning`。" +"可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.13.rst:2 msgid "Pending removal in Python 3.13" @@ -2908,14 +2908,14 @@ msgstr "引入系統 (import system):" #: ../../deprecations/pending-removal-in-3.15.rst:6 msgid "" -"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" -"`__spec__.cached ` is deprecated. In " -"Python 3.15, :attr:`!__cached__` will cease to be set or take into " -"consideration by the import system or standard library. (:gh:`97879`)" +"Setting ``__cached__`` on a module while failing to set :attr:`__spec__." +"cached ` is deprecated. In Python " +"3.15, ``__cached__`` will cease to be set or take into consideration by the " +"import system or standard library. (:gh:`97879`)" msgstr "" -"在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " +"在模組上設定 ``__cached__`` 而沒有設定 :attr:`__spec__.cached " "` 的做法已被棄用。在 Python 3.15 中," -"引入系統或標準函式庫將不再設定或考慮 :attr:`!__cached__`。(:gh:`97879`)" +"引入系統或標準函式庫將不再設定或考慮 ``__cached__``。(:gh:`97879`)" #: ../../deprecations/pending-removal-in-3.15.rst:11 msgid "" @@ -2929,6 +2929,7 @@ msgstr "" "引入系統或標準函式庫將不再設定或考慮 :attr:`!__package__`。(:gh:`97879`)" #: ../../deprecations/pending-removal-in-3.15.rst:16 +#: ../../deprecations/pending-removal-in-3.19.rst:4 msgid ":mod:`ctypes`:" msgstr ":mod:`ctypes`:" @@ -2945,13 +2946,13 @@ msgstr ":mod:`http.server`:" #: ../../deprecations/pending-removal-in-3.15.rst:23 msgid "" -"The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` has " -"been deprecated since Python 3.13. No direct replacement exists. *Anything* " -"is better than CGI to interface a web server with a request handler." +"The obsolete and rarely used :class:`!CGIHTTPRequestHandler` has been " +"deprecated since Python 3.13. No direct replacement exists. *Anything* is " +"better than CGI to interface a web server with a request handler." msgstr "" -"過時且很少使用的 :class:`~http.server.CGIHTTPRequestHandler` 自 Python 3.13 " -"起已被棄用。不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求" -"處理程序介接起來。" +"過時且很少使用的 :class:`!CGIHTTPRequestHandler` 自 Python 3.13 起已被棄用。" +"不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求處理程序介接" +"起來。" #: ../../deprecations/pending-removal-in-3.15.rst:29 msgid "" @@ -2976,11 +2977,11 @@ msgstr ":mod:`pathlib`:" #: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" -":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" +":meth:`!.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" "func:`os.path.isreserved` to detect reserved paths on Windows." msgstr "" -":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os.path." -"isreserved` 來偵測 Windows 上的保留路徑。" +":meth:`!.PurePath.is_reserved` 已自 Python 3.13 被棄用。請" +"用 :func:`os.path.isreserved` 來偵測 Windows 上的保留路徑。" #: ../../deprecations/pending-removal-in-3.15.rst:42 msgid ":mod:`platform`:" @@ -2988,11 +2989,11 @@ msgstr ":mod:`platform`:" #: ../../deprecations/pending-removal-in-3.15.rst:44 msgid "" -":func:`~platform.java_ver` has been deprecated since Python 3.13. This " +":func:`!platform.java_ver` has been deprecated since Python 3.13. This " "function is only useful for Jython support, has a confusing API, and is " "largely untested." msgstr "" -"自 Python 3.13 起,:func:`~platform.java_ver` 已被棄用。此函式僅對 Jython 支" +"自 Python 3.13 起,:func:`!platform.java_ver` 已被棄用。此函式僅對 Jython 支" "援有用,具有令人困惑的 API,基本上未經測試。" #: ../../deprecations/pending-removal-in-3.15.rst:48 @@ -3029,15 +3030,15 @@ msgstr ":mod:`types`:" #: ../../deprecations/pending-removal-in-3.15.rst:63 msgid "" -":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +":class:`types.CodeType`: Accessing :attr:`!codeobject.co_lnotab` was " "deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " "but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " "in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" msgstr "" -":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" -"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" -"exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" -"`101866` 貢獻。)" +":class:`types.CodeType`:自 3.10 起,存取 :attr:`!codeobject.co_lnotab` 已" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發" +"出 :exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev " +"於 :gh:`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:72 msgid "" @@ -3065,41 +3066,43 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:85 msgid "" -"The :deco:`typing.no_type_check_decorator` decorator function has been " +"The :deco:`!typing.no_type_check_decorator` decorator function has been " "deprecated since Python 3.13. After eight years in the :mod:`typing` module, " "it has yet to be supported by any major type checker." msgstr "" -"自 Python 3.13 起,:deco:`typing.no_type_check_decorator` 裝飾器函式已被棄" +"自 Python 3.13 起,:deco:`!typing.no_type_check_decorator` 裝飾器函式已被棄" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" #: ../../deprecations/pending-removal-in-3.15.rst:90 +msgid "" +":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." +msgstr ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" + +#: ../../deprecations/pending-removal-in-3.15.rst:92 msgid ":mod:`wave`:" msgstr ":mod:`wave`:" -#: ../../deprecations/pending-removal-in-3.15.rst:92 +#: ../../deprecations/pending-removal-in-3.15.rst:94 msgid "" -"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." -"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" -"`~wave.Wave_write` classes have been deprecated since Python 3.13." +"The ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of the :class:" +"`~wave.Wave_read` and :class:`~wave.Wave_write` classes have been deprecated " +"since Python 3.13." msgstr "" -"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" -"`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." -"getmarkers` 方法自 Python 3.13 被棄用。" +":class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 ``getmark()``、" +"``setmark()`` 和 ``getmarkers()`` 方法自 Python 3.13 起已被棄用。" -#: ../../deprecations/pending-removal-in-3.15.rst:97 +#: ../../deprecations/pending-removal-in-3.15.rst:98 msgid ":mod:`zipimport`:" msgstr ":mod:`zipimport`:" -#: ../../deprecations/pending-removal-in-3.15.rst:99 +#: ../../deprecations/pending-removal-in-3.15.rst:100 msgid "" -":meth:`~zipimport.zipimporter.load_module` has been deprecated since Python " -"3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (Contributed " -"by Jiahao Li in :gh:`125746`.)" +":meth:`!zipimport.zipimporter.load_module` has been deprecated since Python " +"3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (:gh:`125746`.)" msgstr "" -":meth:`~zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改用 :" -"meth:`~zipimport.zipimporter.exec_module`。(由 Jiahao Li 於 :gh:`125746` 貢" -"獻。)" +":meth:`!zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改" +"用 :meth:`~zipimport.zipimporter.exec_module`。(:gh:`125746`。)" #: ../../deprecations/c-api-pending-removal-in-3.16.rst:2 #: ../../deprecations/pending-removal-in-3.16.rst:2 @@ -3328,15 +3331,60 @@ msgid "Pending removal in Python 3.17" msgstr "Python 3.17 中待移除的項目" #: ../../deprecations/pending-removal-in-3.17.rst:4 +#: ../../deprecations/pending-removal-in-future.rst:53 +msgid ":mod:`datetime`:" +msgstr ":mod:`datetime`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:6 +msgid "" +":meth:`~datetime.datetime.strptime` calls using a format string containing " +"``%e`` (day of month) without a year. This has been deprecated since Python " +"3.15. (Contributed by Stan Ulbrych in :gh:`70647`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:12 msgid ":mod:`collections.abc`:" msgstr ":mod:`collections.abc`:" -#: ../../deprecations/pending-removal-in-3.17.rst:6 +#: ../../deprecations/pending-removal-in-3.17.rst:14 msgid "" ":class:`collections.abc.ByteString` is scheduled for removal in Python 3.17." msgstr ":class:`collections.abc.ByteString` 預計在 Python 3.17 中移除。" -#: ../../deprecations/pending-removal-in-3.17.rst:28 +#: ../../deprecations/pending-removal-in-3.17.rst:34 +msgid ":mod:`encodings`:" +msgstr ":mod:`encodings`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:36 +msgid "" +"Passing non-ascii *encoding* names to :func:`encodings.normalize_encoding` " +"is deprecated and scheduled for removal in Python 3.17. (Contributed by Stan " +"Ulbrych in :gh:`136702`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:40 +msgid ":mod:`profile`:" +msgstr ":mod:`profile`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:42 +msgid "" +"The :mod:`!profile` module is deprecated and will be removed in Python 3.17. " +"Use :mod:`profiling.tracing` instead, which provides a compatible API. See :" +"pep:`799` for details. (Contributed by Pablo Galindo and László Kiss Kollár " +"in :gh:`138122`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:47 +msgid ":mod:`webbrowser`:" +msgstr ":mod:`webbrowser`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:49 +msgid "" +":class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of :class:`!" +"webbrowser.MacOS`. (:gh:`137586`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:54 msgid "" "Before Python 3.14, old-style unions were implemented using the private " "class ``typing._UnionGenericAlias``. This class is no longer needed for the " @@ -3350,7 +3398,7 @@ msgstr "" "除。使用者應該改用文件中記錄的內省輔助函式,例如 :func:`typing.get_origin` " "和 :func:`typing.get_args`,而非依賴私有實作細節。" -#: ../../deprecations/pending-removal-in-3.17.rst:33 +#: ../../deprecations/pending-removal-in-3.17.rst:59 msgid "" ":class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for " "removal in Python 3.17." @@ -3358,6 +3406,258 @@ msgstr "" ":class:`typing.ByteString` 自 Python 3.9 起已被棄用,預計在 Python 3.17 中移" "除。" +#: ../../deprecations/pending-removal-in-3.17.rst:79 +msgid ":mod:`tkinter`:" +msgstr ":mod:`tkinter`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:81 +msgid "" +"The :class:`!tkinter.Variable` methods :meth:`!trace_variable`, :meth:`!" +"trace` (an alias of :meth:`!trace_variable`), :meth:`!trace_vdelete` and :" +"meth:`!trace_vinfo`, deprecated since Python 3.14, are scheduled for removal " +"in Python 3.17. Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!" +"trace_info` instead. (Contributed by Serhiy Storchaka in :gh:`120220`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:2 +msgid "Pending removal in Python 3.19" +msgstr "Python 3.19 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.19.rst:6 +msgid "" +"Implicitly switching to the MSVC-compatible struct layout by setting :attr:" +"`~ctypes.Structure._pack_` but not :attr:`~ctypes.Structure._layout_` on non-" +"Windows platforms." +msgstr "" +"在非 Windows 平台上,透過設定 :attr:`~ctypes.Structure._pack_` 而沒有設" +"定 :attr:`~ctypes.Structure._layout_` 來隱式地切換到與 MSVC 相容的結構佈局。" + +#: ../../deprecations/pending-removal-in-3.19.rst:10 +msgid ":mod:`hashlib`:" +msgstr ":mod:`hashlib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:12 +msgid "" +"In hash function constructors such as :func:`~hashlib.new` or the direct " +"hash-named constructors such as :func:`~hashlib.md5` and :func:`~hashlib." +"sha256`, their optional initial data parameter could also be passed a " +"keyword argument named ``data=`` or ``string=`` in various :mod:`!hashlib` " +"implementations." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:18 +msgid "" +"Support for the ``string`` keyword argument name is now deprecated and " +"slated for removal in Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:21 +msgid "" +"Before Python 3.13, the ``string`` keyword parameter was not correctly " +"supported depending on the backend implementation of hash functions. Prefer " +"passing the initial data as a positional argument for maximum backwards " +"compatibility." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:26 +msgid ":mod:`http.cookies`:" +msgstr ":mod:`http.cookies`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:28 +msgid "" +":meth:`http.cookies.Morsel.js_output` is deprecated and will be removed in " +"Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:31 +msgid "" +":meth:`http.cookies.BaseCookie.js_output` is deprecated and will be removed " +"in Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:34 +msgid ":mod:`imaplib`:" +msgstr ":mod:`imaplib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:36 +msgid "" +"Altering :attr:`IMAP4.file ` is now deprecated and " +"slated for removal in Python 3.19. This property is now unused and changing " +"its value does not automatically close the current file." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:40 +msgid "" +"Before Python 3.14, this property was used to implement the corresponding " +"``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this " +"is no longer the case since then." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:2 +msgid "Pending removal in Python 3.20" +msgstr "Python 3.20 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.20.rst:4 +msgid "" +"Calling the ``__new__()`` method of :class:`struct.Struct` without the " +"*format* argument is deprecated and will be removed in Python 3.20. " +"Calling :meth:`~object.__init__` method on initialized :class:`~struct." +"Struct` objects is deprecated and will be removed in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:9 +msgid "" +"(Contributed by Sergey B Kirpichev and Serhiy Storchaka in :gh:`143715`.)" +msgstr "(由 Sergey B Kirpichev 和 Serhiy Storchaka 於 :gh:`143715` 中貢獻。)" + +#: ../../deprecations/pending-removal-in-3.20.rst:11 +msgid "" +"The ``__version__``, ``version`` and ``VERSION`` attributes have been " +"deprecated in these standard library modules and will be removed in Python " +"3.20. Use :py:data:`sys.version_info` instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:15 +msgid ":mod:`argparse`" +msgstr ":mod:`argparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:16 +msgid ":mod:`csv`" +msgstr ":mod:`csv`" + +#: ../../deprecations/pending-removal-in-3.20.rst:17 +msgid ":mod:`ctypes`" +msgstr ":mod:`ctypes`" + +#: ../../deprecations/pending-removal-in-3.20.rst:18 +msgid ":mod:`!ctypes.macholib`" +msgstr ":mod:`!ctypes.macholib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:19 +msgid ":mod:`decimal` (use :data:`decimal.SPEC_VERSION` instead)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:20 +msgid ":mod:`http.server`" +msgstr ":mod:`http.server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:21 +msgid ":mod:`imaplib`" +msgstr ":mod:`imaplib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:22 +msgid ":mod:`ipaddress`" +msgstr ":mod:`ipaddress`" + +#: ../../deprecations/pending-removal-in-3.20.rst:23 +msgid ":mod:`json`" +msgstr ":mod:`json`" + +#: ../../deprecations/pending-removal-in-3.20.rst:24 +msgid ":mod:`logging` (``__date__`` also deprecated)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:25 +msgid ":mod:`optparse`" +msgstr ":mod:`optparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:26 +msgid ":mod:`pickle`" +msgstr ":mod:`pickle`" + +#: ../../deprecations/pending-removal-in-3.20.rst:27 +msgid ":mod:`platform`" +msgstr ":mod:`platform`" + +#: ../../deprecations/pending-removal-in-3.20.rst:28 +msgid ":mod:`re`" +msgstr ":mod:`re`" + +#: ../../deprecations/pending-removal-in-3.20.rst:29 +msgid ":mod:`socketserver`" +msgstr ":mod:`socketserver`" + +#: ../../deprecations/pending-removal-in-3.20.rst:30 +msgid ":mod:`tabnanny`" +msgstr ":mod:`tabnanny`" + +#: ../../deprecations/pending-removal-in-3.20.rst:31 +msgid ":mod:`tarfile`" +msgstr ":mod:`tarfile`" + +#: ../../deprecations/pending-removal-in-3.20.rst:32 +msgid ":mod:`tkinter.font`" +msgstr ":mod:`tkinter.font`" + +#: ../../deprecations/pending-removal-in-3.20.rst:33 +msgid ":mod:`tkinter.ttk`" +msgstr ":mod:`tkinter.ttk`" + +#: ../../deprecations/pending-removal-in-3.20.rst:34 +msgid ":mod:`wsgiref.simple_server`" +msgstr ":mod:`wsgiref.simple_server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:35 +msgid ":mod:`xml.etree.ElementTree`" +msgstr ":mod:`xml.etree.ElementTree`" + +#: ../../deprecations/pending-removal-in-3.20.rst:36 +msgid ":mod:`!xml.sax.expatreader`" +msgstr ":mod:`!xml.sax.expatreader`" + +#: ../../deprecations/pending-removal-in-3.20.rst:37 +msgid ":mod:`xml.sax.handler`" +msgstr ":mod:`xml.sax.handler`" + +#: ../../deprecations/pending-removal-in-3.20.rst:38 +msgid ":mod:`zlib`" +msgstr ":mod:`zlib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:40 +msgid "(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)" +msgstr "(由 Hugo van Kemenade 和 Stan Ulbrych 貢獻於 :gh:`76007`。)" + +#: ../../deprecations/pending-removal-in-3.20.rst:42 +msgid "Deprecations defined by :pep:`829`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:44 +msgid "" +"Warnings are produced for ``import`` lines found in :file:`{name}.pth` files." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:47 +msgid "" +":file:`{name}.pth` files are no longer decoded in the locale encoding by " +"default. They **MUST** be encoded in ``utf-8-sig``." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:50 +msgid "(Contributed by Barry Warsaw in :gh:`148641`.)" +msgstr "(由 Barry Warsaw 於 :gh:`148641` 中貢獻。)" + +#: ../../deprecations/pending-removal-in-3.20.rst:52 +msgid ":mod:`ast`:" +msgstr ":mod:`ast`:" + +#: ../../deprecations/pending-removal-in-3.20.rst:54 +msgid "" +"Creating instances of abstract AST nodes (such as :class:`ast.AST` or :class:" +"`!ast.expr`) is deprecated and will raise an error in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:59 +msgid "" +"It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on " +"protocol classes that were not explicitly decorated with :func:`!" +"runtime_checkable` but that inherit from a runtime-checkable protocol class. " +"This will raise a :exc:`TypeError` in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:64 +msgid "(Contributed by Bartosz Sławecki in :gh:`132604`.)" +msgstr "(由 Bartosz Sławecki 於 :gh:`132604` 中貢獻。)" + #: ../../deprecations/c-api-pending-removal-in-future.rst:2 #: ../../deprecations/pending-removal-in-future.rst:2 msgid "Pending removal in future versions" @@ -3463,14 +3763,10 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:50 msgid "" -":attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " +":attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " "instead." msgstr "" -":attr:`codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" - -#: ../../deprecations/pending-removal-in-future.rst:53 -msgid ":mod:`datetime`:" -msgstr ":mod:`datetime`:" +":attr:`!codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" #: ../../deprecations/pending-removal-in-future.rst:55 msgid "" @@ -3529,18 +3825,28 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:78 msgid "" -":mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process." +":mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process." msgstr ":mod:`os`:在多執行緒行程中呼叫 :func:`os.register_at_fork`。" #: ../../deprecations/pending-removal-in-future.rst:80 msgid "" +":mod:`os.path`: :func:`os.path.commonprefix` is deprecated, use :func:`os." +"path.commonpath` for path prefixes. The :func:`os.path.commonprefix` " +"function is being deprecated due to having a misleading name and module. The " +"function is not safe to use for path prefixes despite being included in a " +"module about path manipulation, meaning it is easy to accidentally introduce " +"path traversal vulnerabilities into Python programs by using this function." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:88 +msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." msgstr "" ":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" "實例。" -#: ../../deprecations/pending-removal-in-future.rst:83 +#: ../../deprecations/pending-removal-in-future.rst:91 msgid "" ":mod:`re`: More strict rules are now applied for numerical group references " "and group names in regular expressions. Only sequence of ASCII digits is " @@ -3552,12 +3858,7 @@ msgstr "" "有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" "包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:90 -msgid "" -":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." -msgstr ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" - -#: ../../deprecations/pending-removal-in-future.rst:92 +#: ../../deprecations/pending-removal-in-future.rst:98 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." @@ -3565,15 +3866,15 @@ msgstr "" ":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" "棄用;請改用 *onexc* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:95 +#: ../../deprecations/pending-removal-in-future.rst:101 msgid ":mod:`ssl` options and protocols:" msgstr ":mod:`ssl` 選項和協定:" -#: ../../deprecations/pending-removal-in-future.rst:97 +#: ../../deprecations/pending-removal-in-future.rst:103 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:98 +#: ../../deprecations/pending-removal-in-future.rst:104 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." @@ -3581,51 +3882,51 @@ msgstr "" ":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" "`!selected_npn_protocol` 已被棄用:請改用 ALPN。" -#: ../../deprecations/pending-removal-in-future.rst:101 +#: ../../deprecations/pending-removal-in-future.rst:107 msgid "``ssl.OP_NO_SSL*`` options" msgstr "``ssl.OP_NO_SSL*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:102 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "``ssl.OP_NO_TLS*`` options" msgstr "``ssl.OP_NO_TLS*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:103 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid "``ssl.PROTOCOL_SSLv3``" msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:104 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "``ssl.PROTOCOL_TLS``" msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:105 +#: ../../deprecations/pending-removal-in-future.rst:111 msgid "``ssl.PROTOCOL_TLSv1``" msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:106 +#: ../../deprecations/pending-removal-in-future.rst:112 msgid "``ssl.PROTOCOL_TLSv1_1``" msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:107 +#: ../../deprecations/pending-removal-in-future.rst:113 msgid "``ssl.PROTOCOL_TLSv1_2``" msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:108 +#: ../../deprecations/pending-removal-in-future.rst:114 msgid "``ssl.TLSVersion.SSLv3``" msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:109 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid "``ssl.TLSVersion.TLSv1``" msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:110 +#: ../../deprecations/pending-removal-in-future.rst:116 msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:118 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:114 +#: ../../deprecations/pending-removal-in-future.rst:120 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -3633,11 +3934,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:121 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" -#: ../../deprecations/pending-removal-in-future.rst:116 +#: ../../deprecations/pending-removal-in-future.rst:122 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -3645,7 +3946,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:118 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -3653,20 +3954,20 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:120 +#: ../../deprecations/pending-removal-in-future.rst:126 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:121 +#: ../../deprecations/pending-removal-in-future.rst:127 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:123 +#: ../../deprecations/pending-removal-in-future.rst:129 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:131 msgid "" "The internal class ``typing._UnionGenericAlias`` is no longer used to " "implement :class:`typing.Union`. To preserve compatibility with users using " @@ -3677,7 +3978,7 @@ msgstr "" "了保持與此私有類別使用者的相容性,直到至少 Python 3.17 都將提供一個相容性 " "shim。(由 Jelle Zijlstra 於 :gh:`105499` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:130 +#: ../../deprecations/pending-removal-in-future.rst:136 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -3685,64 +3986,64 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:139 msgid "" ":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " "instead" msgstr "" ":mod:`urllib.parse` 已棄用函式:請改用 :func:`~urllib.parse.urlparse`。" -#: ../../deprecations/pending-removal-in-future.rst:135 +#: ../../deprecations/pending-removal-in-future.rst:141 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:136 +#: ../../deprecations/pending-removal-in-future.rst:142 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:137 +#: ../../deprecations/pending-removal-in-future.rst:143 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:138 +#: ../../deprecations/pending-removal-in-future.rst:144 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:139 +#: ../../deprecations/pending-removal-in-future.rst:145 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:140 +#: ../../deprecations/pending-removal-in-future.rst:146 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:141 +#: ../../deprecations/pending-removal-in-future.rst:147 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:142 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:143 +#: ../../deprecations/pending-removal-in-future.rst:149 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:144 +#: ../../deprecations/pending-removal-in-future.rst:150 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:145 +#: ../../deprecations/pending-removal-in-future.rst:151 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:147 +#: ../../deprecations/pending-removal-in-future.rst:153 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:150 +#: ../../deprecations/pending-removal-in-future.rst:156 msgid "" ":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." "etree.ElementTree.Element` is deprecated. In a future release it will always " @@ -3753,7 +4054,7 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:155 +#: ../../deprecations/pending-removal-in-future.rst:161 msgid "" ":func:`sys._clear_type_cache` is deprecated: use :func:`sys." "_clear_internal_caches` instead." @@ -3761,15 +4062,15 @@ msgstr "" ":func:`sys._clear_type_cache` 已被棄用:請改用 :func:`sys." "_clear_internal_caches`。" -#: ../../whatsnew/3.12.rst:1371 ../../whatsnew/3.12.rst:2255 +#: ../../whatsnew/3.12.rst:1375 ../../whatsnew/3.12.rst:2259 msgid "Removed" msgstr "已移除" -#: ../../whatsnew/3.12.rst:1374 +#: ../../whatsnew/3.12.rst:1378 msgid "asynchat and asyncore" msgstr "asynchat 和 asyncore" -#: ../../whatsnew/3.12.rst:1376 +#: ../../whatsnew/3.12.rst:1380 msgid "" "These two modules have been removed according to the schedule in :pep:`594`, " "having been deprecated in Python 3.6. Use :mod:`asyncio` instead. " @@ -3778,18 +4079,18 @@ msgstr "" "這兩個模組已根據 :pep:`594` 的計畫時間刪除,並已在 Python 3.6 中棄用。請改" "用 :mod:`asyncio`。(由 Nikita Sobolev 在 :gh:`96580` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1383 +#: ../../whatsnew/3.12.rst:1387 msgid "configparser" msgstr "configparser" -#: ../../whatsnew/3.12.rst:1385 +#: ../../whatsnew/3.12.rst:1389 msgid "" "Several names deprecated in the :mod:`configparser` way back in 3.2 have " "been removed per :gh:`89336`:" msgstr "" "根據 :gh:`89336`,已移除了在 3.2 中被 :mod:`configparser` 棄用的幾個名稱:" -#: ../../whatsnew/3.12.rst:1388 +#: ../../whatsnew/3.12.rst:1392 msgid "" ":class:`configparser.ParsingError` no longer has a ``filename`` attribute or " "argument. Use the ``source`` attribute and argument instead." @@ -3797,7 +4098,7 @@ msgstr "" ":class:`configparser.ParsingError` 不再具有 ``filename`` 屬性或引數。請改用 " "``source`` 屬性和引數。" -#: ../../whatsnew/3.12.rst:1390 +#: ../../whatsnew/3.12.rst:1394 msgid "" ":mod:`configparser` no longer has a ``SafeConfigParser`` class. Use the " "shorter :class:`~configparser.ConfigParser` name instead." @@ -3805,7 +4106,7 @@ msgstr "" ":mod:`configparser` 不再具有 ``SafeConfigParser`` 類別。請改用較短的 :class:" "`~configparser.ConfigParser` 名稱。" -#: ../../whatsnew/3.12.rst:1392 +#: ../../whatsnew/3.12.rst:1396 msgid "" ":class:`configparser.ConfigParser` no longer has a ``readfp`` method. Use :" "meth:`~configparser.ConfigParser.read_file` instead." @@ -3813,11 +4114,11 @@ msgstr "" ":class:`configparser.ConfigParser` 不再具有 ``readfp`` 方法。請改用 :meth:" "`~configparser.ConfigParser.read_file`。" -#: ../../whatsnew/3.12.rst:1398 +#: ../../whatsnew/3.12.rst:1402 msgid "distutils" msgstr "distutils" -#: ../../whatsnew/3.12.rst:1400 +#: ../../whatsnew/3.12.rst:1404 msgid "" "Remove the :py:mod:`!distutils` package. It was deprecated in Python 3.10 " "by :pep:`632` \"Deprecate distutils module\". For projects still using " @@ -3830,11 +4131,11 @@ msgstr "" "可以安裝 ``setuptools`` 專案:它仍然提供 ``distutils``。(由 Victor Stinner " "在 :gh:`92584` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1407 +#: ../../whatsnew/3.12.rst:1411 msgid "ensurepip" msgstr "ensurepip" -#: ../../whatsnew/3.12.rst:1409 +#: ../../whatsnew/3.12.rst:1413 msgid "" "Remove the bundled setuptools wheel from :mod:`ensurepip`, and stop " "installing setuptools in environments created by :mod:`venv`." @@ -3842,7 +4143,7 @@ msgstr "" "從 :mod:`ensurepip` 中刪除綁定的 setuptools wheel,並停止在 :mod:`venv` 建立" "的環境中安裝 setuptools。" -#: ../../whatsnew/3.12.rst:1412 +#: ../../whatsnew/3.12.rst:1416 msgid "" "``pip (>= 22.1)`` does not require setuptools to be installed in the " "environment. ``setuptools``-based (and ``distutils``-based) packages can " @@ -3853,7 +4154,7 @@ msgstr "" "基於 ``distutils``)的套件仍然可以透過 ``pip install`` 來使用,因為 pip 會在" "其用於建置套件的建置環境中提供 ``setuptools``。" -#: ../../whatsnew/3.12.rst:1418 +#: ../../whatsnew/3.12.rst:1422 msgid "" "``easy_install``, ``pkg_resources``, ``setuptools`` and ``distutils`` are no " "longer provided by default in environments created with ``venv`` or " @@ -3867,15 +4168,15 @@ msgstr "" "們是 ``setuptools`` 套件的一部分。對於在 runtime 依賴這些工具的專案,應將 " "``setuptools`` 專案宣告為相依套件並單獨安裝(通常使用 pip)。" -#: ../../whatsnew/3.12.rst:1425 +#: ../../whatsnew/3.12.rst:1429 msgid "(Contributed by Pradyun Gedam in :gh:`95299`.)" msgstr "(由 Pradyun Gedam 於 :gh:`95299` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1428 +#: ../../whatsnew/3.12.rst:1432 msgid "enum" msgstr "enum" -#: ../../whatsnew/3.12.rst:1430 +#: ../../whatsnew/3.12.rst:1434 msgid "" "Remove :mod:`enum`'s ``EnumMeta.__getattr__``, which is no longer needed for " "enum attribute access. (Contributed by Ethan Furman in :gh:`95083`.)" @@ -3883,11 +4184,11 @@ msgstr "" "移除 :mod:`enum` 的 ``EnumMeta.__getattr__``,對於列舉屬性的存取不再會需要" "它。" -#: ../../whatsnew/3.12.rst:1435 +#: ../../whatsnew/3.12.rst:1439 msgid "ftplib" msgstr "ftplib" -#: ../../whatsnew/3.12.rst:1437 +#: ../../whatsnew/3.12.rst:1441 msgid "" "Remove :mod:`ftplib`'s ``FTP_TLS.ssl_version`` class attribute: use the " "*context* parameter instead. (Contributed by Victor Stinner in :gh:`94172`.)" @@ -3895,11 +4196,11 @@ msgstr "" "移除 :mod:`ftplib` 的 ``FTP_TLS.ssl_version`` 類別屬性:請改用 *context* 參" "數。(由 Victor Stinner 於 :gh:`94172` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1442 +#: ../../whatsnew/3.12.rst:1446 msgid "gzip" msgstr "gzip" -#: ../../whatsnew/3.12.rst:1444 +#: ../../whatsnew/3.12.rst:1448 msgid "" "Remove the ``filename`` attribute of :mod:`gzip`'s :class:`gzip.GzipFile`, " "deprecated since Python 2.6, use the :attr:`~gzip.GzipFile.name` attribute " @@ -3912,11 +4213,11 @@ msgstr "" "``filename`` 屬性會新增 ``'.gz'`` 檔案副檔名(如果不存在)。(由 Victor " "Stinner 在 :gh:`94196` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1451 +#: ../../whatsnew/3.12.rst:1455 msgid "hashlib" msgstr "hashlib" -#: ../../whatsnew/3.12.rst:1453 +#: ../../whatsnew/3.12.rst:1457 msgid "" "Remove the pure Python implementation of :mod:`hashlib`'s :func:`hashlib." "pbkdf2_hmac`, deprecated in Python 3.10. Python 3.10 and newer requires " @@ -3929,17 +4230,17 @@ msgstr "" "`644`):此 OpenSSL 版本提供了更快的 :func:`~hashlib.pbkdf2_hmac` 的 C 實作。" "(由 Victor Stinner 在 :gh:`94199` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1460 ../../whatsnew/3.12.rst:1489 +#: ../../whatsnew/3.12.rst:1464 ../../whatsnew/3.12.rst:1493 msgid "importlib" msgstr "importlib" -#: ../../whatsnew/3.12.rst:1462 +#: ../../whatsnew/3.12.rst:1466 msgid "" "Many previously deprecated cleanups in :mod:`importlib` have now been " "completed:" msgstr "現已完成清理 :mod:`importlib` 中許多過去已經棄用的東西:" -#: ../../whatsnew/3.12.rst:1465 +#: ../../whatsnew/3.12.rst:1469 msgid "" "References to, and support for :meth:`!module_repr` has been removed. " "(Contributed by Barry Warsaw in :gh:`97850`.)" @@ -3947,7 +4248,7 @@ msgstr "" "對 :meth:`!module_repr` 的參照和支援已刪除。(由 Barry Warsaw 在 :gh:`97850` " "中貢獻。)" -#: ../../whatsnew/3.12.rst:1468 +#: ../../whatsnew/3.12.rst:1472 msgid "" "``importlib.util.set_package``, ``importlib.util.set_loader`` and " "``importlib.util.module_for_loader`` have all been removed. (Contributed by " @@ -3957,7 +4258,7 @@ msgstr "" "util.module_for_loader`` 已全部刪除。(由 Brett Cannon 和 Nikita Sobolev 在 :" "gh:`65961` 和 :gh:`97850` 貢獻。)" -#: ../../whatsnew/3.12.rst:1472 +#: ../../whatsnew/3.12.rst:1476 msgid "" "Support for ``find_loader()`` and ``find_module()`` APIs have been removed. " "(Contributed by Barry Warsaw in :gh:`98040`.)" @@ -3965,7 +4266,7 @@ msgstr "" "對 ``find_loader()`` 和 ``find_module()`` API 的支援已被刪除。(由 Barry " "Warsaw 在 :gh:`98040` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1475 +#: ../../whatsnew/3.12.rst:1479 msgid "" "``importlib.abc.Finder``, ``pkgutil.ImpImporter``, and ``pkgutil.ImpLoader`` " "have been removed. (Contributed by Barry Warsaw in :gh:`98040`.)" @@ -3973,57 +4274,57 @@ msgstr "" "``importlib.abc.Finder``、``pkgutil.ImpImporter`` 和 ``pkgutil.ImpLoader`` 已" "被刪除。(由 Barry Warsaw 在 :gh:`98040` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1481 ../../whatsnew/3.12.rst:1489 +#: ../../whatsnew/3.12.rst:1485 ../../whatsnew/3.12.rst:1493 msgid "imp" msgstr "imp" -#: ../../whatsnew/3.12.rst:1483 +#: ../../whatsnew/3.12.rst:1487 msgid "" "The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw in :" "gh:`98040`.)" msgstr ":mod:`!imp` 模組已被移除。(由 Barry Warsaw 在 :gh:`98040` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1486 +#: ../../whatsnew/3.12.rst:1490 msgid "To migrate, consult the following correspondence table:" msgstr "要遷移的話請參考以下對應表:" -#: ../../whatsnew/3.12.rst:1491 +#: ../../whatsnew/3.12.rst:1495 msgid "``imp.NullImporter``" msgstr "``imp.NullImporter``" -#: ../../whatsnew/3.12.rst:1491 +#: ../../whatsnew/3.12.rst:1495 msgid "Insert ``None`` into ``sys.path_importer_cache``" msgstr "將 ``None`` 插入 ``sys.path_importer_cache``" -#: ../../whatsnew/3.12.rst:1492 +#: ../../whatsnew/3.12.rst:1496 msgid "``imp.cache_from_source()``" msgstr "``imp.cache_from_source()``" -#: ../../whatsnew/3.12.rst:1492 +#: ../../whatsnew/3.12.rst:1496 msgid ":func:`importlib.util.cache_from_source`" msgstr ":func:`importlib.util.cache_from_source`" -#: ../../whatsnew/3.12.rst:1493 +#: ../../whatsnew/3.12.rst:1497 msgid "``imp.find_module()``" msgstr "``imp.find_module()``" -#: ../../whatsnew/3.12.rst:1493 +#: ../../whatsnew/3.12.rst:1497 msgid ":func:`importlib.util.find_spec`" msgstr ":func:`importlib.util.find_spec`" -#: ../../whatsnew/3.12.rst:1494 +#: ../../whatsnew/3.12.rst:1498 msgid "``imp.get_magic()``" msgstr "``imp.get_magic()``" -#: ../../whatsnew/3.12.rst:1494 +#: ../../whatsnew/3.12.rst:1498 msgid ":const:`importlib.util.MAGIC_NUMBER`" msgstr ":const:`importlib.util.MAGIC_NUMBER`" -#: ../../whatsnew/3.12.rst:1495 +#: ../../whatsnew/3.12.rst:1499 msgid "``imp.get_suffixes()``" msgstr "``imp.get_suffixes()``" -#: ../../whatsnew/3.12.rst:1495 +#: ../../whatsnew/3.12.rst:1499 msgid "" ":const:`importlib.machinery.SOURCE_SUFFIXES`, :const:`importlib.machinery." "EXTENSION_SUFFIXES`, and :const:`importlib.machinery.BYTECODE_SUFFIXES`" @@ -4031,59 +4332,59 @@ msgstr "" ":const:`importlib.machinery.SOURCE_SUFFIXES`、:const:`importlib.machinery." "EXTENSION_SUFFIXES` 和 :const:`importlib.machinery.BYTECODE_SUFFIXES`" -#: ../../whatsnew/3.12.rst:1496 +#: ../../whatsnew/3.12.rst:1500 msgid "``imp.get_tag()``" msgstr "``imp.get_tag()``" -#: ../../whatsnew/3.12.rst:1496 +#: ../../whatsnew/3.12.rst:1500 msgid ":attr:`sys.implementation.cache_tag `" msgstr ":attr:`sys.implementation.cache_tag `" -#: ../../whatsnew/3.12.rst:1497 +#: ../../whatsnew/3.12.rst:1501 msgid "``imp.load_module()``" msgstr "``imp.load_module()``" -#: ../../whatsnew/3.12.rst:1497 +#: ../../whatsnew/3.12.rst:1501 msgid ":func:`importlib.import_module`" msgstr ":func:`importlib.import_module`" -#: ../../whatsnew/3.12.rst:1498 +#: ../../whatsnew/3.12.rst:1502 msgid "``imp.new_module(name)``" msgstr "``imp.new_module(name)``" -#: ../../whatsnew/3.12.rst:1498 +#: ../../whatsnew/3.12.rst:1502 msgid "``types.ModuleType(name)``" msgstr "``types.ModuleType(name)``" -#: ../../whatsnew/3.12.rst:1499 +#: ../../whatsnew/3.12.rst:1503 msgid "``imp.reload()``" msgstr "``imp.reload()``" -#: ../../whatsnew/3.12.rst:1499 +#: ../../whatsnew/3.12.rst:1503 msgid ":func:`importlib.reload`" msgstr ":func:`importlib.reload`" -#: ../../whatsnew/3.12.rst:1500 +#: ../../whatsnew/3.12.rst:1504 msgid "``imp.source_from_cache()``" msgstr "``imp.source_from_cache()``" -#: ../../whatsnew/3.12.rst:1500 +#: ../../whatsnew/3.12.rst:1504 msgid ":func:`importlib.util.source_from_cache`" msgstr ":func:`importlib.util.source_from_cache`" -#: ../../whatsnew/3.12.rst:1501 +#: ../../whatsnew/3.12.rst:1505 msgid "``imp.load_source()``" msgstr "``imp.load_source()``" -#: ../../whatsnew/3.12.rst:1501 +#: ../../whatsnew/3.12.rst:1505 msgid "*See below*" msgstr "*見下文*" -#: ../../whatsnew/3.12.rst:1504 +#: ../../whatsnew/3.12.rst:1508 msgid "Replace ``imp.load_source()`` with::" msgstr "用以下取代 ``imp.load_source()``: ::" -#: ../../whatsnew/3.12.rst:1506 +#: ../../whatsnew/3.12.rst:1510 msgid "" "import importlib.util\n" "import importlib.machinery\n" @@ -4113,31 +4414,31 @@ msgstr "" " loader.exec_module(module)\n" " return module" -#: ../../whatsnew/3.12.rst:1519 +#: ../../whatsnew/3.12.rst:1523 msgid "Remove :mod:`!imp` functions and attributes with no replacements:" msgstr "移除 :mod:`!imp` 函式和屬性、沒有替代方案:" -#: ../../whatsnew/3.12.rst:1521 +#: ../../whatsnew/3.12.rst:1525 msgid "Undocumented functions:" msgstr "未以文件記錄的函式:" -#: ../../whatsnew/3.12.rst:1523 +#: ../../whatsnew/3.12.rst:1527 msgid "``imp.init_builtin()``" msgstr "``imp.init_builtin()``" -#: ../../whatsnew/3.12.rst:1524 +#: ../../whatsnew/3.12.rst:1528 msgid "``imp.load_compiled()``" msgstr "``imp.load_compiled()``" -#: ../../whatsnew/3.12.rst:1525 +#: ../../whatsnew/3.12.rst:1529 msgid "``imp.load_dynamic()``" msgstr "``imp.load_dynamic()``" -#: ../../whatsnew/3.12.rst:1526 +#: ../../whatsnew/3.12.rst:1530 msgid "``imp.load_package()``" msgstr "``imp.load_package()``" -#: ../../whatsnew/3.12.rst:1528 +#: ../../whatsnew/3.12.rst:1532 msgid "" "``imp.lock_held()``, ``imp.acquire_lock()``, ``imp.release_lock()``: the " "locking scheme has changed in Python 3.3 to per-module locks." @@ -4145,7 +4446,7 @@ msgstr "" "``imp.lock_held()``、``imp.acquire_lock()``、``imp.release_lock()``:鎖定 " "scheme 在 Python 3.3 中已改為模組鎖 (per-module locks)。" -#: ../../whatsnew/3.12.rst:1530 +#: ../../whatsnew/3.12.rst:1534 msgid "" "``imp.find_module()`` constants: ``SEARCH_ERROR``, ``PY_SOURCE``, " "``PY_COMPILED``, ``C_EXTENSION``, ``PY_RESOURCE``, ``PKG_DIRECTORY``, " @@ -4155,11 +4456,11 @@ msgstr "" "``PY_COMPILED``、``C_EXTENSION``、``PY_RESOURCE``、``PKG_DIRECTORY``、" "``C_BUILTIN``、``PY_FROZEN``、``PY_CODERESOURCE``、``IMP_HOOK``。" -#: ../../whatsnew/3.12.rst:1535 +#: ../../whatsnew/3.12.rst:1539 msgid "io" msgstr "io" -#: ../../whatsnew/3.12.rst:1537 +#: ../../whatsnew/3.12.rst:1541 msgid "" "Remove :mod:`io`'s ``io.OpenWrapper`` and ``_pyio.OpenWrapper``, deprecated " "in Python 3.10: just use :func:`open` instead. The :func:`open` (:func:`io." @@ -4172,11 +4473,11 @@ msgstr "" "一個內建函式。從 Python 3.10 開始 :func:`!_pyio.open` 也是一個靜態方法。(由 " "Victor Stinner 在 :gh:`94169` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1544 +#: ../../whatsnew/3.12.rst:1548 msgid "locale" msgstr "locale" -#: ../../whatsnew/3.12.rst:1546 +#: ../../whatsnew/3.12.rst:1550 msgid "" "Remove :mod:`locale`'s :func:`!locale.format` function, deprecated in Python " "3.7: use :func:`locale.format_string` instead. (Contributed by Victor " @@ -4186,11 +4487,11 @@ msgstr "" "請改用 :func:`locale.format_string`。(由 Victor Stinner 在 :gh:`94226` 中貢" "獻。)" -#: ../../whatsnew/3.12.rst:1551 +#: ../../whatsnew/3.12.rst:1555 msgid "smtpd" msgstr "smtpd" -#: ../../whatsnew/3.12.rst:1553 +#: ../../whatsnew/3.12.rst:1557 msgid "" "The ``smtpd`` module has been removed according to the schedule in :pep:" "`594`, having been deprecated in Python 3.4.7 and 3.5.4. Use the :pypi:" @@ -4201,7 +4502,7 @@ msgstr "" "被棄用。請改用 PyPI 上的 :pypi:`aiosmtpd` 模組或任何其他基於 :mod:`asyncio` " "的伺服器。" -#: ../../whatsnew/3.12.rst:1562 +#: ../../whatsnew/3.12.rst:1566 msgid "" "The following undocumented :mod:`sqlite3` features, deprecated in Python " "3.10, are now removed:" @@ -4209,22 +4510,22 @@ msgstr "" "以下未以文件記錄的 :mod:`sqlite3` 功能已在 Python 3.10 中被棄用、現在已被移" "除:" -#: ../../whatsnew/3.12.rst:1565 +#: ../../whatsnew/3.12.rst:1569 msgid "``sqlite3.enable_shared_cache()``" msgstr "``sqlite3.enable_shared_cache()``" -#: ../../whatsnew/3.12.rst:1566 +#: ../../whatsnew/3.12.rst:1570 msgid "``sqlite3.OptimizedUnicode``" msgstr "``sqlite3.OptimizedUnicode``" -#: ../../whatsnew/3.12.rst:1568 +#: ../../whatsnew/3.12.rst:1572 msgid "" "If a shared cache must be used, open the database in URI mode using the " "``cache=shared`` query parameter." msgstr "" "如果必須使用共享快取,請使用 ``cache=shared`` 查詢參數以 URI 模式開啟資料庫。" -#: ../../whatsnew/3.12.rst:1571 +#: ../../whatsnew/3.12.rst:1575 msgid "" "The ``sqlite3.OptimizedUnicode`` text factory has been an alias for :class:" "`str` since Python 3.3. Code that previously set the text factory to " @@ -4235,15 +4536,15 @@ msgstr "" "別名。之前將文字工廠設定為 ``OptimizedUnicode`` 的程式碼可以顯式使用 " "``str``,或者依賴預設值 ``str``。" -#: ../../whatsnew/3.12.rst:1576 +#: ../../whatsnew/3.12.rst:1580 msgid "(Contributed by Erlend E. Aasland in :gh:`92548`.)" msgstr "(由 Erlend E. Aasland 於 :gh:`92548` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1579 +#: ../../whatsnew/3.12.rst:1583 msgid "ssl" msgstr "ssl" -#: ../../whatsnew/3.12.rst:1581 +#: ../../whatsnew/3.12.rst:1585 msgid "" "Remove :mod:`ssl`'s :func:`!ssl.RAND_pseudo_bytes` function, deprecated in " "Python 3.6: use :func:`os.urandom` or :func:`ssl.RAND_bytes` instead. " @@ -4253,7 +4554,7 @@ msgstr "" "起已被棄用:請改用 :func:`os.urandom` 或 :func:`ssl.RAND_bytes`。(由 Victor " "Stinner 於 :gh:`94199` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1585 +#: ../../whatsnew/3.12.rst:1589 msgid "" "Remove the :func:`!ssl.match_hostname` function. It was deprecated in Python " "3.7. OpenSSL performs hostname matching since Python 3.7, Python no longer " @@ -4264,7 +4565,7 @@ msgstr "" "Python 3.7 起,OpenSSL 會執行主機名稱比對,Python 不再使用 :func:`!ssl." "match_hostname` 函式。(由 Victor Stinner 於 :gh:`94199` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1591 +#: ../../whatsnew/3.12.rst:1595 msgid "" "Remove the :func:`!ssl.wrap_socket` function, deprecated in Python 3.7: " "instead, create a :class:`ssl.SSLContext` object and call its :class:`ssl." @@ -4281,152 +4582,152 @@ msgstr "" "cwe:`295`\\ (不當的憑證驗證)影響。(由 Victor Stinner 於 :gh:`94199` 中貢" "獻。)" -#: ../../whatsnew/3.12.rst:1602 +#: ../../whatsnew/3.12.rst:1606 msgid "Remove many long-deprecated :mod:`unittest` features:" msgstr "移除許多 :mod:`unittest` 中被棄用已久的功能:" -#: ../../whatsnew/3.12.rst:1606 +#: ../../whatsnew/3.12.rst:1610 msgid "A number of :class:`~unittest.TestCase` method aliases:" msgstr "許多 :class:`~unittest.TestCase` 方法別名:" -#: ../../whatsnew/3.12.rst:1609 +#: ../../whatsnew/3.12.rst:1613 msgid "Deprecated alias" msgstr "已棄用的別名" -#: ../../whatsnew/3.12.rst:1609 +#: ../../whatsnew/3.12.rst:1613 msgid "Method Name" msgstr "方法名稱" -#: ../../whatsnew/3.12.rst:1609 +#: ../../whatsnew/3.12.rst:1613 msgid "Deprecated in" msgstr "已棄用於" -#: ../../whatsnew/3.12.rst:1611 +#: ../../whatsnew/3.12.rst:1615 msgid "``failUnless``" msgstr "``failUnless``" -#: ../../whatsnew/3.12.rst:1611 ../../whatsnew/3.12.rst:1618 +#: ../../whatsnew/3.12.rst:1615 ../../whatsnew/3.12.rst:1622 msgid ":meth:`.assertTrue`" msgstr ":meth:`.assertTrue`" -#: ../../whatsnew/3.12.rst:1611 ../../whatsnew/3.12.rst:1612 -#: ../../whatsnew/3.12.rst:1613 ../../whatsnew/3.12.rst:1614 #: ../../whatsnew/3.12.rst:1615 ../../whatsnew/3.12.rst:1616 -#: ../../whatsnew/3.12.rst:1617 +#: ../../whatsnew/3.12.rst:1617 ../../whatsnew/3.12.rst:1618 +#: ../../whatsnew/3.12.rst:1619 ../../whatsnew/3.12.rst:1620 +#: ../../whatsnew/3.12.rst:1621 msgid "3.1" msgstr "3.1" -#: ../../whatsnew/3.12.rst:1612 +#: ../../whatsnew/3.12.rst:1616 msgid "``failIf``" msgstr "``failIf``" -#: ../../whatsnew/3.12.rst:1612 +#: ../../whatsnew/3.12.rst:1616 msgid ":meth:`.assertFalse`" msgstr ":meth:`.assertFalse`" -#: ../../whatsnew/3.12.rst:1613 +#: ../../whatsnew/3.12.rst:1617 msgid "``failUnlessEqual``" msgstr "``failUnlessEqual``" -#: ../../whatsnew/3.12.rst:1613 ../../whatsnew/3.12.rst:1619 +#: ../../whatsnew/3.12.rst:1617 ../../whatsnew/3.12.rst:1623 msgid ":meth:`.assertEqual`" msgstr ":meth:`.assertEqual`" -#: ../../whatsnew/3.12.rst:1614 +#: ../../whatsnew/3.12.rst:1618 msgid "``failIfEqual``" msgstr "``failIfEqual``" -#: ../../whatsnew/3.12.rst:1614 ../../whatsnew/3.12.rst:1620 +#: ../../whatsnew/3.12.rst:1618 ../../whatsnew/3.12.rst:1624 msgid ":meth:`.assertNotEqual`" msgstr ":meth:`.assertNotEqual`" -#: ../../whatsnew/3.12.rst:1615 +#: ../../whatsnew/3.12.rst:1619 msgid "``failUnlessAlmostEqual``" msgstr "``failUnlessAlmostEqual``" -#: ../../whatsnew/3.12.rst:1615 ../../whatsnew/3.12.rst:1621 +#: ../../whatsnew/3.12.rst:1619 ../../whatsnew/3.12.rst:1625 msgid ":meth:`.assertAlmostEqual`" msgstr ":meth:`.assertAlmostEqual`" -#: ../../whatsnew/3.12.rst:1616 +#: ../../whatsnew/3.12.rst:1620 msgid "``failIfAlmostEqual``" msgstr "``failIfAlmostEqual``" -#: ../../whatsnew/3.12.rst:1616 ../../whatsnew/3.12.rst:1622 +#: ../../whatsnew/3.12.rst:1620 ../../whatsnew/3.12.rst:1626 msgid ":meth:`.assertNotAlmostEqual`" msgstr ":meth:`.assertNotAlmostEqual`" -#: ../../whatsnew/3.12.rst:1617 +#: ../../whatsnew/3.12.rst:1621 msgid "``failUnlessRaises``" msgstr "``failUnlessRaises``" -#: ../../whatsnew/3.12.rst:1617 +#: ../../whatsnew/3.12.rst:1621 msgid ":meth:`.assertRaises`" msgstr ":meth:`.assertRaises`" -#: ../../whatsnew/3.12.rst:1618 +#: ../../whatsnew/3.12.rst:1622 msgid "``assert_``" msgstr "``assert_``" -#: ../../whatsnew/3.12.rst:1618 ../../whatsnew/3.12.rst:1619 -#: ../../whatsnew/3.12.rst:1620 ../../whatsnew/3.12.rst:1621 #: ../../whatsnew/3.12.rst:1622 ../../whatsnew/3.12.rst:1623 -#: ../../whatsnew/3.12.rst:1624 +#: ../../whatsnew/3.12.rst:1624 ../../whatsnew/3.12.rst:1625 +#: ../../whatsnew/3.12.rst:1626 ../../whatsnew/3.12.rst:1627 +#: ../../whatsnew/3.12.rst:1628 msgid "3.2" msgstr "3.2" -#: ../../whatsnew/3.12.rst:1619 +#: ../../whatsnew/3.12.rst:1623 msgid "``assertEquals``" msgstr "``assertEquals``" -#: ../../whatsnew/3.12.rst:1620 +#: ../../whatsnew/3.12.rst:1624 msgid "``assertNotEquals``" msgstr "``assertNotEquals``" -#: ../../whatsnew/3.12.rst:1621 +#: ../../whatsnew/3.12.rst:1625 msgid "``assertAlmostEquals``" msgstr "``assertAlmostEquals``" -#: ../../whatsnew/3.12.rst:1622 +#: ../../whatsnew/3.12.rst:1626 msgid "``assertNotAlmostEquals``" msgstr "``assertNotAlmostEquals``" -#: ../../whatsnew/3.12.rst:1623 +#: ../../whatsnew/3.12.rst:1627 msgid "``assertRegexpMatches``" msgstr "``assertRegexpMatches``" -#: ../../whatsnew/3.12.rst:1623 +#: ../../whatsnew/3.12.rst:1627 msgid ":meth:`.assertRegex`" msgstr ":meth:`.assertRegex`" -#: ../../whatsnew/3.12.rst:1624 +#: ../../whatsnew/3.12.rst:1628 msgid "``assertRaisesRegexp``" msgstr "``assertRaisesRegexp``" -#: ../../whatsnew/3.12.rst:1624 +#: ../../whatsnew/3.12.rst:1628 msgid ":meth:`.assertRaisesRegex`" msgstr ":meth:`.assertRaisesRegex`" -#: ../../whatsnew/3.12.rst:1625 +#: ../../whatsnew/3.12.rst:1629 msgid "``assertNotRegexpMatches``" msgstr "``assertNotRegexpMatches``" -#: ../../whatsnew/3.12.rst:1625 +#: ../../whatsnew/3.12.rst:1629 msgid ":meth:`.assertNotRegex`" msgstr ":meth:`.assertNotRegex`" -#: ../../whatsnew/3.12.rst:1625 +#: ../../whatsnew/3.12.rst:1629 msgid "3.5" msgstr "3.5" -#: ../../whatsnew/3.12.rst:1628 +#: ../../whatsnew/3.12.rst:1632 msgid "" "You can use https://github.com/isidentical/teyit to automatically modernise " "your unit tests." msgstr "" "你可以使用 https://github.com/isidentical/teyit 來自動現代化你的單元測試。" -#: ../../whatsnew/3.12.rst:1631 +#: ../../whatsnew/3.12.rst:1635 msgid "" "Undocumented and broken :class:`~unittest.TestCase` method " "``assertDictContainsSubset`` (deprecated in Python 3.2)." @@ -4434,7 +4735,7 @@ msgstr "" "未以文件記錄且已失效的 :class:`~unittest.TestCase` 方法 " "``assertDictContainsSubset``\\ (自 Python 3.2 起已棄用)。" -#: ../../whatsnew/3.12.rst:1634 +#: ../../whatsnew/3.12.rst:1638 msgid "" "Undocumented :meth:`TestLoader.loadTestsFromModule ` parameter *use_load_tests* (deprecated and ignored " @@ -4444,7 +4745,7 @@ msgstr "" "loadTestsFromModule>` 參數 *use_load_tests*\\ (自 Python 3.5 起已棄用並忽" "略)。" -#: ../../whatsnew/3.12.rst:1638 +#: ../../whatsnew/3.12.rst:1642 msgid "" "An alias of the :class:`~unittest.TextTestResult` class: ``_TextTestResult`` " "(deprecated in Python 3.2)." @@ -4452,15 +4753,15 @@ msgstr "" "對 :class:`~unittest.TextTestResult` 類別的別名:``_TextTestResult``\\ (自 " "Python 3.2 起已棄用)。" -#: ../../whatsnew/3.12.rst:1641 +#: ../../whatsnew/3.12.rst:1645 msgid "(Contributed by Serhiy Storchaka in :gh:`89325`.)" msgstr "(由 Serhiy Storchaka 於 :gh:`89325` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1644 +#: ../../whatsnew/3.12.rst:1648 msgid "webbrowser" msgstr "webbrowser" -#: ../../whatsnew/3.12.rst:1646 +#: ../../whatsnew/3.12.rst:1650 msgid "" "Remove support for obsolete browsers from :mod:`webbrowser`. The removed " "browsers include: Grail, Mosaic, Netscape, Galeon, Skipstone, Iceape, " @@ -4470,11 +4771,11 @@ msgstr "" "Mosaic、Netscape、Galeon、Skipstone、Iceape、Firebird 和 Firefox 版本 35 及以" "下 (:gh:`102871`)。" -#: ../../whatsnew/3.12.rst:1651 +#: ../../whatsnew/3.12.rst:1655 msgid "xml.etree.ElementTree" msgstr "xml.etree.ElementTree" -#: ../../whatsnew/3.12.rst:1653 +#: ../../whatsnew/3.12.rst:1657 msgid "" "Remove the ``ElementTree.Element.copy()`` method of the pure Python " "implementation, deprecated in Python 3.10, use the :func:`copy.copy` " @@ -4487,11 +4788,11 @@ msgstr "" "有 ``copy()`` 方法,只有 ``__copy__()`` 方法。(由 Victor Stinner 在 :gh:" "`94383` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1660 +#: ../../whatsnew/3.12.rst:1664 msgid "zipimport" msgstr "zipimport" -#: ../../whatsnew/3.12.rst:1662 +#: ../../whatsnew/3.12.rst:1666 msgid "" "Remove :mod:`zipimport`'s ``find_loader()`` and ``find_module()`` methods, " "deprecated in Python 3.10: use the ``find_spec()`` method instead. See :pep:" @@ -4501,11 +4802,11 @@ msgstr "" "Python 3.10 中已棄用):請改用 ``find_spec()`` 方法。請參閱 :pep:`451` 以了解" "基本原理。(由 Victor Stinner 在 :gh:`94379` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1668 +#: ../../whatsnew/3.12.rst:1672 msgid "Others" msgstr "其他" -#: ../../whatsnew/3.12.rst:1670 +#: ../../whatsnew/3.12.rst:1674 msgid "" "Remove the ``suspicious`` rule from the documentation :file:`Makefile` and :" "file:`Doc/tools/rstlint.py`, both in favor of `sphinx-lint `_。(由 Julien Palard 在 :gh:`98179` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1675 +#: ../../whatsnew/3.12.rst:1679 msgid "" "Remove the *keyfile* and *certfile* parameters from the :mod:`ftplib`, :mod:" "`imaplib`, :mod:`poplib` and :mod:`smtplib` modules, and the *key_file*, " @@ -4531,7 +4832,7 @@ msgstr "" "*context* 參數(:mod:`imaplib` 中的 *ssl_context*)。(由 Victor Stinner 在 :" "gh:`94172` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1683 +#: ../../whatsnew/3.12.rst:1687 msgid "" "Remove ``Jython`` compatibility hacks from several stdlib modules and tests. " "(Contributed by Nikita Sobolev in :gh:`99482`.)" @@ -4539,7 +4840,7 @@ msgstr "" "移除數個標準函式庫模組與測試中的 ``Jython`` 相容性修補程式。(由 Nikita " "Sobolev 於 :gh:`99482` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1686 +#: ../../whatsnew/3.12.rst:1690 msgid "" "Remove ``_use_broken_old_ctypes_structure_semantics_`` flag from :mod:" "`ctypes` module. (Contributed by Nikita Sobolev in :gh:`99285`.)" @@ -4547,21 +4848,21 @@ msgstr "" "移除 :mod:`ctypes` 模組中的 ``_use_broken_old_ctypes_structure_semantics_`` " "旗標。(由 Nikita Sobolev 於 :gh:`99285` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1694 ../../whatsnew/3.12.rst:2018 +#: ../../whatsnew/3.12.rst:1698 ../../whatsnew/3.12.rst:2022 msgid "Porting to Python 3.12" msgstr "移植至 Python 3.12" -#: ../../whatsnew/3.12.rst:1696 +#: ../../whatsnew/3.12.rst:1700 msgid "" "This section lists previously described changes and other bugfixes that may " "require changes to your code." msgstr "本節列出了前面描述的變更以及可能需要你更改程式碼的其他錯誤修復。" -#: ../../whatsnew/3.12.rst:1700 +#: ../../whatsnew/3.12.rst:1704 msgid "Changes in the Python API" msgstr "Python API 的變更" -#: ../../whatsnew/3.12.rst:1702 +#: ../../whatsnew/3.12.rst:1706 msgid "" "More strict rules are now applied for numerical group references and group " "names in regular expressions. Only sequence of ASCII digits is now accepted " @@ -4573,7 +4874,7 @@ msgstr "" "數字序列作為數字參考。位元組模式和替換字串中的組名稱現在只能包含 ASCII 字母、" "數字和底線。(由 Serhiy Storchaka 在 :gh:`91760` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1709 +#: ../../whatsnew/3.12.rst:1713 msgid "" "Remove ``randrange()`` functionality deprecated since Python 3.10. " "Formerly, ``randrange(10.0)`` losslessly converted to ``randrange(10)``. " @@ -4592,7 +4893,7 @@ msgstr "" "``randrange(10**25)`` 更大的範圍中進行選擇的錯誤。(最初由 Serhiy Storchaka " "建議 :gh:`86388`。)" -#: ../../whatsnew/3.12.rst:1717 +#: ../../whatsnew/3.12.rst:1721 msgid "" ":class:`argparse.ArgumentParser` changed encoding and error handler for " "reading arguments from file (e.g. ``fromfile_prefix_chars`` option) from " @@ -4607,7 +4908,7 @@ msgstr "" "term:`檔案系統編碼和錯誤處理程式 `。" "在 Windows 上,引數檔案應使用 UTF-8 編碼,而不是 Windows 的 ANSI Codepage。" -#: ../../whatsnew/3.12.rst:1723 +#: ../../whatsnew/3.12.rst:1727 msgid "" "Remove the ``asyncore``-based ``smtpd`` module deprecated in Python 3.4.7 " "and 3.5.4. A recommended replacement is the :mod:`asyncio`-based :pypi:" @@ -4616,7 +4917,7 @@ msgstr "" "刪除 Python 3.4.7 和 3.5.4 中已棄用的基於 ``asyncore`` 的 ``smtpd`` 模組。推" "薦的替代品是基於 :mod:`asyncio` 的 :pypi:`aiosmtpd` PyPI 模組。" -#: ../../whatsnew/3.12.rst:1727 +#: ../../whatsnew/3.12.rst:1731 msgid "" ":func:`shlex.split`: Passing ``None`` for *s* argument now raises an " "exception, rather than reading :data:`sys.stdin`. The feature was deprecated " @@ -4626,7 +4927,7 @@ msgstr "" "取 :data:`sys.stdin`。該功能在 Python 3.9 中已被棄用。(由 Victor Stinner " "在 :gh:`94352` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1732 +#: ../../whatsnew/3.12.rst:1736 msgid "" "The :mod:`os` module no longer accepts bytes-like paths, like :class:" "`bytearray` and :class:`memoryview` types: only the exact :class:`bytes` " @@ -4637,7 +4938,7 @@ msgstr "" "`memoryview` 型別:對於位元組字串,僅接受確切的 :class:`bytes` 型別。(由 " "Victor Stinner 在 :gh:`98393` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1737 +#: ../../whatsnew/3.12.rst:1741 msgid "" ":func:`syslog.openlog` and :func:`syslog.closelog` now fail if used in " "subinterpreters. :func:`syslog.syslog` may still be used in subinterpreters, " @@ -4654,7 +4955,7 @@ msgstr "" "可能會受到影響。此更改有助於直譯器隔離。此外,:mod:`syslog` 是行程全域資源的" "包裝器,最好透過主直譯器進行管理。(由 Donghee Na 在 :gh:`99127` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1746 +#: ../../whatsnew/3.12.rst:1750 msgid "" "The undocumented locking behavior of :deco:`~functools.cached_property` is " "removed, because it locked across all instances of the class, leading to " @@ -4672,7 +4973,7 @@ msgstr "" "沒問題。如果需要同步,請在快取的屬性 getter 函式內或多執行緒存取點周圍實作鎖" "定。" -#: ../../whatsnew/3.12.rst:1759 +#: ../../whatsnew/3.12.rst:1763 msgid "" "When extracting tar files using :mod:`tarfile` or :func:`shutil." "unpack_archive`, pass the *filter* argument to limit features that may be " @@ -4682,7 +4983,7 @@ msgstr "" "*filter* 引數以限制可能不預期或甚至危險的功能。詳細資訊請參閱 :ref:`tarfile-" "extraction-filter`。" -#: ../../whatsnew/3.12.rst:1764 +#: ../../whatsnew/3.12.rst:1768 msgid "" "The output of the :func:`tokenize.tokenize` and :func:`tokenize." "generate_tokens` functions is now changed due to the changes introduced in :" @@ -4700,15 +5001,15 @@ msgstr "" "外,現在還會針對 f 字串 \"string\" 部分發出。例如,對於 f 字串 ``f\"start " "{1+1} end\"`` 舊版的標記產生器發出: ::" -#: ../../whatsnew/3.12.rst:1773 +#: ../../whatsnew/3.12.rst:1777 msgid "1,0-1,18: STRING 'f\"start {1+1} end\"'" msgstr "1,0-1,18: STRING 'f\"start {1+1} end\"'" -#: ../../whatsnew/3.12.rst:1775 +#: ../../whatsnew/3.12.rst:1779 msgid "while the new version emits::" msgstr "而新版本會發出: ::" -#: ../../whatsnew/3.12.rst:1777 +#: ../../whatsnew/3.12.rst:1781 msgid "" "1,0-1,2: FSTRING_START 'f\"'\n" "1,2-1,8: FSTRING_MIDDLE 'start '\n" @@ -4730,7 +5031,7 @@ msgstr "" "1,13-1,17: FSTRING_MIDDLE ' end'\n" "1,17-1,18: FSTRING_END '\"'" -#: ../../whatsnew/3.12.rst:1787 +#: ../../whatsnew/3.12.rst:1791 msgid "" "Additionally, there may be some minor behavioral changes as a consequence of " "the changes required to support :pep:`701`. Some of these changes include:" @@ -4738,7 +5039,7 @@ msgstr "" "此外,由於支援 :pep:`701` 所做的更改,可能會出現一些細微的行為變化。其中的變" "化包括:" -#: ../../whatsnew/3.12.rst:1790 +#: ../../whatsnew/3.12.rst:1794 msgid "" "The ``type`` attribute of the tokens emitted when tokenizing some invalid " "Python characters such as ``!`` has changed from ``ERRORTOKEN`` to ``OP``." @@ -4746,7 +5047,7 @@ msgstr "" "對某些無效 Python 字元(例如 ``!``)進行標記時發出的標記的 ``type`` 屬性已從 " "``ERRORTOKEN`` 更改為 ``OP``。" -#: ../../whatsnew/3.12.rst:1793 +#: ../../whatsnew/3.12.rst:1797 msgid "" "Incomplete single-line strings now also raise :exc:`tokenize.TokenError` as " "incomplete multiline strings do." @@ -4754,7 +5055,7 @@ msgstr "" "不完整的單列字串現在也會像不完整的多列字串一樣引發 :exc:`tokenize." "TokenError`。" -#: ../../whatsnew/3.12.rst:1796 +#: ../../whatsnew/3.12.rst:1800 msgid "" "Some incomplete or invalid Python code now raises :exc:`tokenize.TokenError` " "instead of returning arbitrary ``ERRORTOKEN`` tokens when tokenizing it." @@ -4762,14 +5063,14 @@ msgstr "" "一些不完整或無效的 Python 程式碼現在會引發 :exc:`tokenize.TokenError`,而不是" "在 tokenize 時回傳任意 ``ERRORTOKEN`` 標記。" -#: ../../whatsnew/3.12.rst:1799 +#: ../../whatsnew/3.12.rst:1803 msgid "" "Mixing tabs and spaces as indentation in the same file is not supported " "anymore and will raise a :exc:`TabError`." msgstr "" "不再支援在同一檔案中混合 Tab 字元和空格作為縮排,並且會引發 :exc:`TabError`。" -#: ../../whatsnew/3.12.rst:1802 +#: ../../whatsnew/3.12.rst:1806 msgid "" "The :mod:`threading` module now expects the :mod:`!_thread` module to have " "an ``_is_main_interpreter`` attribute. It is a function with no arguments " @@ -4779,7 +5080,7 @@ msgstr "" "``_is_main_interpreter`` 屬性。它是一個沒有引數的函式,如果目前直譯器是主直譯" "器,則回傳 ``True``。" -#: ../../whatsnew/3.12.rst:1807 +#: ../../whatsnew/3.12.rst:1811 msgid "" "Any library or application that provides a custom ``_thread`` module should " "provide ``_is_main_interpreter()``. (See :gh:`112826`.)" @@ -4787,11 +5088,11 @@ msgstr "" "任何提供自訂 ``_thread`` 模組的函式庫或應用程式都應該提供 " "``_is_main_interpreter()``。(參閱 :gh:`112826`。)" -#: ../../whatsnew/3.12.rst:1812 +#: ../../whatsnew/3.12.rst:1816 msgid "Build Changes" msgstr "建置變更" -#: ../../whatsnew/3.12.rst:1814 +#: ../../whatsnew/3.12.rst:1818 msgid "" "Python no longer uses :file:`setup.py` to build shared C extension modules. " "Build parameters like headers and libraries are detected in ``configure`` " @@ -4804,7 +5105,7 @@ msgstr "" "功能使用 ``pkg-config`` 並回退到手動檢測。(由 Christian Heimes 在 :gh:" "`93939` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1820 +#: ../../whatsnew/3.12.rst:1824 msgid "" "``va_start()`` with two parameters, like ``va_start(args, format),`` is now " "required to build Python. ``va_start()`` is no longer called with a single " @@ -4814,7 +5115,7 @@ msgstr "" "format),``。``va_start()`` 不再以單個參數來被呼叫。(由 Kumar Aditya 在 :gh:" "`93207` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1825 +#: ../../whatsnew/3.12.rst:1829 msgid "" "CPython now uses the ThinLTO option as the default link time optimization " "policy if the Clang compiler accepts the flag. (Contributed by Donghee Na " @@ -4823,7 +5124,7 @@ msgstr "" "CPython 現在會使用 ThinLTO 選項作為預設連結時間最佳化策略(如果 Clang 編譯器" "接受該旗標)。(由 Donghee Na 在 :gh:`89536` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1829 +#: ../../whatsnew/3.12.rst:1833 msgid "" "Add ``COMPILEALL_OPTS`` variable in :file:`Makefile` to override :mod:" "`compileall` options (default: ``-j0``) in ``make install``. Also merged the " @@ -4836,31 +5137,31 @@ msgstr "" "併為一個指令,來一次性為所有最佳化等級(0、1、2)建置 .pyc 檔案。(由 Victor " "Stinner 在 :gh:`99289` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1835 +#: ../../whatsnew/3.12.rst:1839 msgid "Add platform triplets for 64-bit LoongArch:" msgstr "為 64 位元 LoongArch 新增平台三元組:" -#: ../../whatsnew/3.12.rst:1837 +#: ../../whatsnew/3.12.rst:1841 msgid "loongarch64-linux-gnusf" msgstr "loongarch64-linux-gnusf" -#: ../../whatsnew/3.12.rst:1838 +#: ../../whatsnew/3.12.rst:1842 msgid "loongarch64-linux-gnuf32" msgstr "loongarch64-linux-gnuf32" -#: ../../whatsnew/3.12.rst:1839 +#: ../../whatsnew/3.12.rst:1843 msgid "loongarch64-linux-gnu" msgstr "loongarch64-linux-gnu" -#: ../../whatsnew/3.12.rst:1841 +#: ../../whatsnew/3.12.rst:1845 msgid "(Contributed by Zhang Na in :gh:`90656`.)" msgstr "(由 Zhang Na 於 :gh:`90656` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1843 +#: ../../whatsnew/3.12.rst:1847 msgid "``PYTHON_FOR_REGEN`` now require Python 3.10 or newer." msgstr "``PYTHON_FOR_REGEN`` 現在需要 Python 3.10 或更新的版本。" -#: ../../whatsnew/3.12.rst:1845 +#: ../../whatsnew/3.12.rst:1849 msgid "" "Autoconf 2.71 and aclocal 1.16.4 is now required to regenerate :file:" "`configure`. (Contributed by Christian Heimes in :gh:`89886`.)" @@ -4868,16 +5169,16 @@ msgstr "" "現在需要 Autoconf 2.71 和 aclocal 1.16.4 來重新產生 :file:`configure`。(由 " "Christian Heimes 在 :gh:`89886` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1849 +#: ../../whatsnew/3.12.rst:1853 msgid "" "Windows builds and macOS installers from python.org now use OpenSSL 3.0." msgstr "來自 python.org 的 Windows 建置和 macOS 安裝程式現在使用 OpenSSL 3.0。" -#: ../../whatsnew/3.12.rst:1853 +#: ../../whatsnew/3.12.rst:1857 msgid "C API Changes" msgstr "C API 變更" -#: ../../whatsnew/3.12.rst:1860 +#: ../../whatsnew/3.12.rst:1864 msgid "" ":pep:`697`: Introduce the :ref:`Unstable C API tier `, " "intended for low-level tools like debuggers and JIT compilers. This API may " @@ -4888,15 +5189,15 @@ msgstr "" "JIT 編譯器等低階工具。此 API 可能會在 CPython 的每個次要版本中發生更改,而不" "會出現棄用警告。其內容由名稱中的 ``PyUnstable_`` 前綴標記。" -#: ../../whatsnew/3.12.rst:1866 +#: ../../whatsnew/3.12.rst:1870 msgid "Code object constructors:" msgstr "程式碼物件建構函式:" -#: ../../whatsnew/3.12.rst:1868 +#: ../../whatsnew/3.12.rst:1872 msgid "``PyUnstable_Code_New()`` (renamed from ``PyCode_New``)" msgstr "``PyUnstable_Code_New()``\\ (自 ``PyCode_New`` 重新命名)" -#: ../../whatsnew/3.12.rst:1869 +#: ../../whatsnew/3.12.rst:1873 msgid "" "``PyUnstable_Code_NewWithPosOnlyArgs()`` (renamed from " "``PyCode_NewWithPosOnlyArgs``)" @@ -4904,11 +5205,11 @@ msgstr "" "``PyUnstable_Code_NewWithPosOnlyArgs()``\\ (自 " "``PyCode_NewWithPosOnlyArgs`` 重新命名)" -#: ../../whatsnew/3.12.rst:1871 +#: ../../whatsnew/3.12.rst:1875 msgid "Extra storage for code objects (:pep:`523`):" msgstr "程式碼物件的額外儲存 (:pep:`523`):" -#: ../../whatsnew/3.12.rst:1873 +#: ../../whatsnew/3.12.rst:1877 msgid "" "``PyUnstable_Eval_RequestCodeExtraIndex()`` (renamed from " "``_PyEval_RequestCodeExtraIndex``)" @@ -4916,31 +5217,31 @@ msgstr "" "``PyUnstable_Eval_RequestCodeExtraIndex()``\\ (自 " "``_PyEval_RequestCodeExtraIndex`` 重新命名)" -#: ../../whatsnew/3.12.rst:1874 +#: ../../whatsnew/3.12.rst:1878 msgid "``PyUnstable_Code_GetExtra()`` (renamed from ``_PyCode_GetExtra``)" msgstr "``PyUnstable_Code_GetExtra()``\\ (自 ``_PyCode_GetExtra`` 重新命名)" -#: ../../whatsnew/3.12.rst:1875 +#: ../../whatsnew/3.12.rst:1879 msgid "``PyUnstable_Code_SetExtra()`` (renamed from ``_PyCode_SetExtra``)" msgstr "``PyUnstable_Code_SetExtra()``\\ (自 ``_PyCode_SetExtra`` 重新命名)" -#: ../../whatsnew/3.12.rst:1877 +#: ../../whatsnew/3.12.rst:1881 msgid "" "The original names will continue to be available until the respective API " "changes." msgstr "原始名稱將可繼續使用,直到相應的 API 發生變更。" -#: ../../whatsnew/3.12.rst:1880 +#: ../../whatsnew/3.12.rst:1884 msgid "(Contributed by Petr Viktorin in :gh:`101101`.)" msgstr "(由 Petr Viktorin 於 :gh:`101101` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1882 +#: ../../whatsnew/3.12.rst:1886 msgid "" ":pep:`697`: Add an API for extending types whose instance memory layout is " "opaque:" msgstr ":pep:`697`:新增一個 API 用來擴充實例記憶體佈局不透明的型別:" -#: ../../whatsnew/3.12.rst:1885 +#: ../../whatsnew/3.12.rst:1889 msgid "" ":c:member:`PyType_Spec.basicsize` can be zero or negative to specify " "inheriting or extending the base class size." @@ -4948,7 +5249,7 @@ msgstr "" ":c:member:`PyType_Spec.basicsize` 可以為零或負數來指定繼承或擴充基底類別大" "小。" -#: ../../whatsnew/3.12.rst:1887 +#: ../../whatsnew/3.12.rst:1891 msgid "" ":c:func:`PyObject_GetTypeData` and :c:func:`PyType_GetTypeDataSize` added to " "allow access to subclass-specific instance data." @@ -4956,7 +5257,7 @@ msgstr "" "新增了 :c:func:`PyObject_GetTypeData` 和 :c:func:`PyType_GetTypeDataSize` 以" "允許存取特定於子類別的實例資料。" -#: ../../whatsnew/3.12.rst:1889 +#: ../../whatsnew/3.12.rst:1893 msgid "" ":c:macro:`Py_TPFLAGS_ITEMS_AT_END` and :c:func:`PyObject_GetItemData` added " "to allow safely extending certain variable-sized types, including :c:var:" @@ -4965,7 +5266,7 @@ msgstr "" "新增了 :c:macro:`Py_TPFLAGS_ITEMS_AT_END` 和 :c:func:`PyObject_GetItemData` " "以允許安全地擴充某些可變大小的型別,包括 :c:var:`PyType_Type`。" -#: ../../whatsnew/3.12.rst:1892 +#: ../../whatsnew/3.12.rst:1896 msgid "" ":c:macro:`Py_RELATIVE_OFFSET` added to allow defining :c:type:`members " "` in terms of a subclass-specific struct." @@ -4973,11 +5274,11 @@ msgstr "" "新增了 :c:macro:`Py_RELATIVE_OFFSET` 以允許根據子類別特定的結構定義\\ :c:" "type:`成員 `。" -#: ../../whatsnew/3.12.rst:1895 +#: ../../whatsnew/3.12.rst:1899 msgid "(Contributed by Petr Viktorin in :gh:`103509`.)" msgstr "(由 Petr Viktorin 於 :gh:`103509` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1897 +#: ../../whatsnew/3.12.rst:1901 msgid "" "Add the new :ref:`limited C API ` function :c:func:" "`PyType_FromMetaclass`, which generalizes the existing :c:func:" @@ -4988,7 +5289,7 @@ msgstr "" "`PyType_FromMetaclass`,它使用附加元類別參數來概括現有的 :c:func:" "`PyType_FromModuleAndSpec`。(由 Wenzel Jakob 在 :gh:`93012` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1902 +#: ../../whatsnew/3.12.rst:1906 msgid "" "API for creating objects that can be called using :ref:`the vectorcall " "protocol ` was added to the :ref:`Limited API `:" @@ -4996,23 +5297,23 @@ msgstr "" "用於建立可使用\\ :ref:`向量呼叫協定 `\\ 進行呼叫的物件的 API 已新" "增到 :ref:`有限 API ` 中:" -#: ../../whatsnew/3.12.rst:1906 +#: ../../whatsnew/3.12.rst:1910 msgid ":c:macro:`Py_TPFLAGS_HAVE_VECTORCALL`" msgstr ":c:macro:`Py_TPFLAGS_HAVE_VECTORCALL`" -#: ../../whatsnew/3.12.rst:1907 +#: ../../whatsnew/3.12.rst:1911 msgid ":c:func:`PyVectorcall_NARGS`" msgstr ":c:func:`PyVectorcall_NARGS`" -#: ../../whatsnew/3.12.rst:1908 +#: ../../whatsnew/3.12.rst:1912 msgid ":c:func:`PyVectorcall_Call`" msgstr ":c:func:`PyVectorcall_Call`" -#: ../../whatsnew/3.12.rst:1909 +#: ../../whatsnew/3.12.rst:1913 msgid ":c:type:`vectorcallfunc`" msgstr ":c:type:`vectorcallfunc`" -#: ../../whatsnew/3.12.rst:1911 +#: ../../whatsnew/3.12.rst:1915 msgid "" "The :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag is now removed from a class " "when the class's :py:meth:`~object.__call__` method is reassigned. This " @@ -5030,7 +5331,7 @@ msgstr "" "``Py_TPFLAGS_HAVE_VECTORCALL`` 旗標。(由 Petr Viktorin 在 :gh:`93274` 中貢獻" "。)" -#: ../../whatsnew/3.12.rst:1919 +#: ../../whatsnew/3.12.rst:1923 msgid "" "The :c:macro:`Py_TPFLAGS_MANAGED_DICT` and :c:macro:" "`Py_TPFLAGS_MANAGED_WEAKREF` flags have been added. This allows extensions " @@ -5041,7 +5342,7 @@ msgstr "" "`Py_TPFLAGS_MANAGED_WEAKREF` 旗標。這允許擴充類別以更少的簿記 (bookkeeping)、" "使用更少的記憶體和更快的存取來支援物件 :attr:`~object.__dict__` 和 weakrefs。" -#: ../../whatsnew/3.12.rst:1924 +#: ../../whatsnew/3.12.rst:1928 msgid "" "API for performing calls using :ref:`the vectorcall protocol ` " "was added to the :ref:`Limited API `:" @@ -5049,19 +5350,19 @@ msgstr "" "使用\\ :ref:`向量呼叫協定 `\\ 執行呼叫的 API 已新增到\\ :ref:`有" "限 API ` 中:" -#: ../../whatsnew/3.12.rst:1928 +#: ../../whatsnew/3.12.rst:1932 msgid ":c:func:`PyObject_Vectorcall`" msgstr ":c:func:`PyObject_Vectorcall`" -#: ../../whatsnew/3.12.rst:1929 +#: ../../whatsnew/3.12.rst:1933 msgid ":c:func:`PyObject_VectorcallMethod`" msgstr ":c:func:`PyObject_VectorcallMethod`" -#: ../../whatsnew/3.12.rst:1930 +#: ../../whatsnew/3.12.rst:1934 msgid ":c:macro:`PY_VECTORCALL_ARGUMENTS_OFFSET`" msgstr ":c:macro:`PY_VECTORCALL_ARGUMENTS_OFFSET`" -#: ../../whatsnew/3.12.rst:1932 +#: ../../whatsnew/3.12.rst:1936 msgid "" "This means that both the incoming and outgoing ends of the vector call " "protocol are now available in the :ref:`Limited API `. (Contributed " @@ -5070,7 +5371,7 @@ msgstr "" "這意味著向量呼叫協定的傳入和傳出端現在都可以在\\ :ref:`受限 API ` 中" "使用。(由 Wenzel Jakob 在 :gh:`98586` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1936 +#: ../../whatsnew/3.12.rst:1940 msgid "" "Add two new public functions, :c:func:`PyEval_SetProfileAllThreads` and :c:" "func:`PyEval_SetTraceAllThreads`, that allow to set tracing and profiling " @@ -5081,7 +5382,7 @@ msgstr "" "`PyEval_SetTraceAllThreads`,它們允許在除呼叫執行緒之外的所有正在執行的執行緒" "中設定追蹤和分析函式。(由 Pablo Galindo 在 :gh:`93503` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1942 +#: ../../whatsnew/3.12.rst:1946 msgid "" "Add new function :c:func:`PyFunction_SetVectorcall` to the C API which sets " "the vectorcall field of a given :c:type:`PyFunctionObject`. (Contributed by " @@ -5091,7 +5392,7 @@ msgstr "" "type:`PyFunctionObject` 的向量呼叫欄位。(由 Andrew Frost 在 :gh:`92257` 中貢" "獻。)" -#: ../../whatsnew/3.12.rst:1946 +#: ../../whatsnew/3.12.rst:1950 msgid "" "The C API now permits registering callbacks via :c:func:" "`PyDict_AddWatcher`, :c:func:`PyDict_Watch` and related APIs to be called " @@ -5103,7 +5404,7 @@ msgstr "" "呼以及每當修改字典時呼叫的相關 API。它旨在供最佳化直譯器、JIT 編譯器或偵錯器" "使用。(由 Carl Meyer 在 :gh:`91052` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1952 +#: ../../whatsnew/3.12.rst:1956 msgid "" "Add :c:func:`PyType_AddWatcher` and :c:func:`PyType_Watch` API to register " "callbacks to receive notification on changes to a type. (Contributed by Carl " @@ -5112,7 +5413,7 @@ msgstr "" "新增 :c:func:`PyType_AddWatcher` 和 :c:func:`PyType_Watch` API 來註冊回呼以接" "收有關型別變更的通知。(由 Carl Meyer 在 :gh:`91051` 貢獻。)" -#: ../../whatsnew/3.12.rst:1956 +#: ../../whatsnew/3.12.rst:1960 msgid "" "Add :c:func:`PyCode_AddWatcher` and :c:func:`PyCode_ClearWatcher` APIs to " "register callbacks to receive notification on creation and destruction of " @@ -5122,7 +5423,7 @@ msgstr "" "回呼以接收有關建立和銷毀程式碼物件的通知。(由 Itamar Oren 在 :gh:`91054` 中" "貢獻。)" -#: ../../whatsnew/3.12.rst:1961 +#: ../../whatsnew/3.12.rst:1965 msgid "" "Add :c:func:`PyFrame_GetVar` and :c:func:`PyFrame_GetVarString` functions to " "get a frame variable by its name. (Contributed by Victor Stinner in :gh:" @@ -5131,7 +5432,7 @@ msgstr "" "新增 :c:func:`PyFrame_GetVar` 和 :c:func:`PyFrame_GetVarString` 函式以透過名" "稱獲取 frame 變數。(由 Victor Stinner 在 :gh:`91248` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1965 +#: ../../whatsnew/3.12.rst:1969 msgid "" "Add :c:func:`PyErr_GetRaisedException` and :c:func:" "`PyErr_SetRaisedException` for saving and restoring the current exception. " @@ -5146,7 +5447,7 @@ msgstr "" "三元引數。這樣做較不容易出錯且效率稍高。(由 Mark Shannon 於 :gh:`101578` 中" "貢獻。)" -#: ../../whatsnew/3.12.rst:1973 +#: ../../whatsnew/3.12.rst:1977 msgid "" "Add ``_PyErr_ChainExceptions1``, which takes an exception instance, to " "replace the legacy-API ``_PyErr_ChainExceptions``, which is now deprecated. " @@ -5155,7 +5456,7 @@ msgstr "" "新增 ``_PyErr_ChainExceptions1``,它接受一個例外實例,以取代現已棄用的舊版 " "API ``_PyErr_ChainExceptions``。(由 Mark Shannon 於 :gh:`101578` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1977 +#: ../../whatsnew/3.12.rst:1981 msgid "" "Add :c:func:`PyException_GetArgs` and :c:func:`PyException_SetArgs` as " "convenience functions for retrieving and modifying the :attr:`~BaseException." @@ -5166,7 +5467,7 @@ msgstr "" "函式,用於取得和修改傳遞給例外建構函式的 :attr:`~BaseException.args`。(由 " "Mark Shannon 於 :gh:`101578` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1982 +#: ../../whatsnew/3.12.rst:1986 msgid "" "Add :c:func:`PyErr_DisplayException`, which takes an exception instance, to " "replace the legacy-api :c:func:`!PyErr_Display`. (Contributed by Irit " @@ -5175,7 +5476,7 @@ msgstr "" "新增 :c:func:`PyErr_DisplayException`,它接受一個例外實例,以取代舊版 API :c:" "func:`!PyErr_Display`。(由 Irit Katriel 於 :gh:`102755` 中貢獻。)" -#: ../../whatsnew/3.12.rst:1988 +#: ../../whatsnew/3.12.rst:1992 msgid "" ":pep:`683`: Introduce *Immortal Objects*, which allows objects to bypass " "reference counts, and related changes to the C-API:" @@ -5183,59 +5484,59 @@ msgstr "" ":pep:`683`:引入\\ *不滅物件*,它允許物件繞過參照計數,以及對 C-API 的相關變" "更:" -#: ../../whatsnew/3.12.rst:1991 +#: ../../whatsnew/3.12.rst:1995 msgid "``_Py_IMMORTAL_REFCNT``: The reference count that defines an object" msgstr "``_Py_IMMORTAL_REFCNT``:定義物件的參照計數" -#: ../../whatsnew/3.12.rst:1992 +#: ../../whatsnew/3.12.rst:1996 msgid "as immortal." msgstr "為不滅的。" -#: ../../whatsnew/3.12.rst:1993 +#: ../../whatsnew/3.12.rst:1997 msgid "" "``_Py_IsImmortal`` Checks if an object has the immortal reference count." msgstr "``_Py_IsImmortal`` 檢查物件是否具有不滅參照計數。" -#: ../../whatsnew/3.12.rst:1994 +#: ../../whatsnew/3.12.rst:1998 msgid "``PyObject_HEAD_INIT`` This will now initialize reference count to" msgstr "``PyObject_HEAD_INIT`` 這現在將初始化參照計數" -#: ../../whatsnew/3.12.rst:1995 +#: ../../whatsnew/3.12.rst:1999 msgid "``_Py_IMMORTAL_REFCNT`` when used with ``Py_BUILD_CORE``." msgstr "``_Py_IMMORTAL_REFCNT``\\ (與 ``Py_BUILD_CORE`` 一起使用時)。" -#: ../../whatsnew/3.12.rst:1996 +#: ../../whatsnew/3.12.rst:2000 msgid "``SSTATE_INTERNED_IMMORTAL`` An identifier for interned unicode objects" msgstr "``SSTATE_INTERNED_IMMORTAL`` 駐留的 (interned) unicode 物件的識別字" -#: ../../whatsnew/3.12.rst:1997 +#: ../../whatsnew/3.12.rst:2001 msgid "that are immortal." msgstr "那是不滅的。" -#: ../../whatsnew/3.12.rst:1998 +#: ../../whatsnew/3.12.rst:2002 msgid "``SSTATE_INTERNED_IMMORTAL_STATIC`` An identifier for interned unicode" msgstr "``SSSTATE_INTERNED_IMMORTAL_STATIC`` 駐留的 unicode 的識別字" -#: ../../whatsnew/3.12.rst:1999 +#: ../../whatsnew/3.12.rst:2003 msgid "objects that are immortal and static" msgstr "不滅且靜態的物件" -#: ../../whatsnew/3.12.rst:2000 +#: ../../whatsnew/3.12.rst:2004 msgid "``sys.getunicodeinternedsize`` This returns the total number of unicode" msgstr "``sys.getunicodeinternedsize`` 這會回傳 unicode 的總數" -#: ../../whatsnew/3.12.rst:2001 +#: ../../whatsnew/3.12.rst:2005 msgid "" "objects that have been interned. This is now needed for :file:`refleak.py` " "to correctly track reference counts and allocated blocks" msgstr "" "已駐留的物件。現在 :file:`refleak.py` 需要這個來正確追蹤參照計數和分配的區塊" -#: ../../whatsnew/3.12.rst:2004 +#: ../../whatsnew/3.12.rst:2008 msgid "(Contributed by Eddie Elizondo in :gh:`84436`.)" msgstr "(由 Eddie Elizondo 於 :gh:`84436` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2006 +#: ../../whatsnew/3.12.rst:2010 msgid "" ":pep:`684`: Add the new :c:func:`Py_NewInterpreterFromConfig` function and :" "c:type:`PyInterpreterConfig`, which may be used to create sub-interpreters " @@ -5247,7 +5548,7 @@ msgstr "" "訊,請參閱 :ref:`whatsnew312-pep684`。)(由 Eric Snow 在 :gh:`104110` 中貢" "獻。)" -#: ../../whatsnew/3.12.rst:2012 +#: ../../whatsnew/3.12.rst:2016 msgid "" "In the limited C API version 3.12, :c:func:`Py_INCREF` and :c:func:" "`Py_DECREF` functions are now implemented as opaque function calls to hide " @@ -5257,7 +5558,7 @@ msgstr "" "在被實作為不透明函式呼叫,以隱藏實作細節。(由 Victor Stinner 在 :gh:" "`105387` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2020 +#: ../../whatsnew/3.12.rst:2024 msgid "" "Legacy Unicode APIs based on ``Py_UNICODE*`` representation has been " "removed. Please migrate to APIs based on UTF-8 or ``wchar_t*``." @@ -5265,7 +5566,7 @@ msgstr "" "基於 ``Py_UNICODE*`` 表示的舊版 Unicode API 已被刪除。請遷移到基於 UTF-8 或 " "``wchar_t*`` 的 API。" -#: ../../whatsnew/3.12.rst:2023 +#: ../../whatsnew/3.12.rst:2027 msgid "" "Argument parsing functions like :c:func:`PyArg_ParseTuple` doesn't support " "``Py_UNICODE*`` based format (e.g. ``u``, ``Z``) anymore. Please migrate to " @@ -5275,7 +5576,7 @@ msgstr "" "的格式(例如 ``u``, ``Z``)。請遷移到其他 Unicode 格式,例如 ``s``、 ``z``、 " "``es`` 和 ``U``。" -#: ../../whatsnew/3.12.rst:2027 +#: ../../whatsnew/3.12.rst:2031 msgid "" "``tp_weaklist`` for all static builtin types is always ``NULL``. This is an " "internal-only field on ``PyTypeObject`` but we're pointing out the change in " @@ -5288,7 +5589,7 @@ msgstr "" "避免損壞,請考慮使用現有的公開 C-API,或者,如有必要,使用(僅限內部)\\ " "``_PyObject_GET_WEAKREFS_LISTPTR()`` 巨集。" -#: ../../whatsnew/3.12.rst:2034 +#: ../../whatsnew/3.12.rst:2038 msgid "" "This internal-only :c:member:`PyTypeObject.tp_subclasses` may now not be a " "valid object pointer. Its type was changed to :c:expr:`void *` to reflect " @@ -5299,7 +5600,7 @@ msgstr "" "指標。它的型別已更改為 :c:expr:`void *` 以反映這一點。我們提到這一點是為了防" "止有人碰巧直接存取僅限內部的欄位。" -#: ../../whatsnew/3.12.rst:2039 +#: ../../whatsnew/3.12.rst:2043 msgid "" "To get a list of subclasses, call the Python method :py:meth:`~type." "__subclasses__` (using :c:func:`PyObject_CallMethod`, for example)." @@ -5307,7 +5608,7 @@ msgstr "" "要獲得子類別串列,請呼叫 Python 方法 :py:meth:`~type.__subclasses__`\\ (例" "如,使用 :c:func:`PyObject_CallMethod`)。" -#: ../../whatsnew/3.12.rst:2043 +#: ../../whatsnew/3.12.rst:2047 msgid "" "Add support of more formatting options (left aligning, octals, uppercase " "hexadecimals, :c:type:`intmax_t`, :c:type:`ptrdiff_t`, :c:type:`wchar_t` C " @@ -5320,7 +5621,7 @@ msgstr "" "type:`ptrdiff_t`、:c:type:`wchar_t` C 字串、可變寬度和精度)。(由 Serhiy " "Storchaka 在 :gh:`98836` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2049 +#: ../../whatsnew/3.12.rst:2053 msgid "" "An unrecognized format character in :c:func:`PyUnicode_FromFormat` and :c:" "func:`PyUnicode_FromFormatV` now sets a :exc:`SystemError`. In previous " @@ -5333,7 +5634,7 @@ msgstr "" "其餘部分按原樣複製到結果字串,並丟棄任何額外的參數。(由 Serhiy Storchaka " "在 :gh:`95781` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2055 +#: ../../whatsnew/3.12.rst:2059 msgid "" "Fix wrong sign placement in :c:func:`PyUnicode_FromFormat` and :c:func:" "`PyUnicode_FromFormatV`. (Contributed by Philip Georgi in :gh:`95504`.)" @@ -5341,7 +5642,7 @@ msgstr "" "修正 :c:func:`PyUnicode_FromFormat` 和 :c:func:`PyUnicode_FromFormatV` 中錯誤" "的符號位置。(由 Philip Georgi 在 :gh:`95504` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2059 +#: ../../whatsnew/3.12.rst:2063 msgid "" "Extension classes wanting to add a :attr:`~object.__dict__` or weak " "reference slot should use :c:macro:`Py_TPFLAGS_MANAGED_DICT` and :c:macro:" @@ -5364,7 +5665,7 @@ msgstr "" "清除其實例的字典。若要清除弱參照,請如同之前一樣呼叫 :c:func:" "`PyObject_ClearWeakRefs`。" -#: ../../whatsnew/3.12.rst:2071 +#: ../../whatsnew/3.12.rst:2075 msgid "" "The :c:func:`PyUnicode_FSDecoder` function no longer accepts bytes-like " "paths, like :class:`bytearray` and :class:`memoryview` types: only the " @@ -5375,7 +5676,7 @@ msgstr "" "`bytearray` 和 :class:`memoryview` 型別:對於位元組字串,僅接受確切的 :class:" "`bytes` 型別。(由 Victor Stinner 在 :gh:`98393` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2076 +#: ../../whatsnew/3.12.rst:2080 msgid "" "The :c:macro:`Py_CLEAR`, :c:macro:`Py_SETREF` and :c:macro:`Py_XSETREF` " "macros now only evaluate their arguments once. If an argument has side " @@ -5386,7 +5687,7 @@ msgstr "" "計算其引數一次。如果引數有副作用,這些副作用將不再重複。(由 Victor Stinner " "在 :gh:`98724` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2081 +#: ../../whatsnew/3.12.rst:2085 msgid "" "The interpreter's error indicator is now always normalized. This means that :" "c:func:`PyErr_SetObject`, :c:func:`PyErr_SetString` and the other functions " @@ -5397,7 +5698,7 @@ msgstr "" "func:`PyErr_SetString` 和其他設定錯誤指示器的函式現在會在儲存例外之前對其進行" "規範化。(由 Mark Shannon 在 :gh:`101578` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2086 +#: ../../whatsnew/3.12.rst:2090 msgid "" "``_Py_RefTotal`` is no longer authoritative and only kept around for ABI " "compatibility. Note that it is an internal global and only available on " @@ -5408,25 +5709,25 @@ msgstr "" "全域的,僅在偵錯版本中可用。如果你碰巧正在使用它,那麼你需要開始使用 " "``_Py_GetGlobalRefTotal()``。" -#: ../../whatsnew/3.12.rst:2091 +#: ../../whatsnew/3.12.rst:2095 msgid "" "The following functions now select an appropriate metaclass for the newly " "created type:" msgstr "現在,以下函式為新建立的型別選擇適當的元類別:" -#: ../../whatsnew/3.12.rst:2094 +#: ../../whatsnew/3.12.rst:2098 msgid ":c:func:`PyType_FromSpec`" msgstr ":c:func:`PyType_FromSpec`" -#: ../../whatsnew/3.12.rst:2095 +#: ../../whatsnew/3.12.rst:2099 msgid ":c:func:`PyType_FromSpecWithBases`" msgstr ":c:func:`PyType_FromSpecWithBases`" -#: ../../whatsnew/3.12.rst:2096 +#: ../../whatsnew/3.12.rst:2100 msgid ":c:func:`PyType_FromModuleAndSpec`" msgstr ":c:func:`PyType_FromModuleAndSpec`" -#: ../../whatsnew/3.12.rst:2098 +#: ../../whatsnew/3.12.rst:2102 msgid "" "Creating classes whose metaclass overrides :c:member:`~PyTypeObject.tp_new` " "is deprecated, and in Python 3.14+ it will be disallowed. Note that these " @@ -5437,7 +5738,7 @@ msgstr "" "Python 3.14+ 中將被禁止。請注意,這些函式忽略元類別的 ``tp_new``,可能允許不" "完整的初始化。" -#: ../../whatsnew/3.12.rst:2103 +#: ../../whatsnew/3.12.rst:2107 msgid "" "Note that :c:func:`PyType_FromMetaclass` (added in Python 3.12) already " "disallows creating classes whose metaclass overrides ``tp_new`` (:meth:" @@ -5447,7 +5748,7 @@ msgstr "" "建立其元類別覆蓋 ``tp_new``\\ (Python 中的 :meth:`~object.__new__`)的類別" "別。" -#: ../../whatsnew/3.12.rst:2107 +#: ../../whatsnew/3.12.rst:2111 msgid "" "Since ``tp_new`` overrides almost everything ``PyType_From*`` functions do, " "the two are incompatible with each other. The existing behavior -- ignoring " @@ -5460,18 +5761,18 @@ msgstr "" "類別假設 ``tp_new`` 有被呼叫。沒有簡單的通用解決方法。以下其中一項可能適合" "你:" -#: ../../whatsnew/3.12.rst:2114 +#: ../../whatsnew/3.12.rst:2118 msgid "If you control the metaclass, avoid using ``tp_new`` in it:" msgstr "如果你控制元類別,請避免在其中使用 ``tp_new``:" -#: ../../whatsnew/3.12.rst:2116 +#: ../../whatsnew/3.12.rst:2120 msgid "" "If initialization can be skipped, it can be done in :c:member:`~PyTypeObject." "tp_init` instead." msgstr "" "如果可以跳過初始化,則可以在 :c:member:`~PyTypeObject.tp_init` 中完成。" -#: ../../whatsnew/3.12.rst:2118 +#: ../../whatsnew/3.12.rst:2122 msgid "" "If the metaclass doesn't need to be instantiated from Python, set its " "``tp_new`` to ``NULL`` using the :c:macro:" @@ -5482,7 +5783,7 @@ msgstr "" "`Py_TPFLAGS_DISALLOW_INSTANTIATION` 旗標將其 ``tp_new`` 設定為 ``NULL``。這使" "得 ``PyType_From*`` 函式能夠接受。" -#: ../../whatsnew/3.12.rst:2123 +#: ../../whatsnew/3.12.rst:2127 msgid "" "Avoid ``PyType_From*`` functions: if you don't need C-specific features " "(slots or setting the instance size), create types by :ref:`calling ` " @@ -5491,7 +5792,7 @@ msgstr "" "避免使用 ``PyType_From*`` 函式:如果你不需要特定於 C 的功能(插槽 (slot) 或設" "定實例大小),請透過\\ :ref:`呼叫 `\\ 元類別來建立型別。" -#: ../../whatsnew/3.12.rst:2127 +#: ../../whatsnew/3.12.rst:2131 msgid "" "If you *know* the ``tp_new`` can be skipped safely, filter the deprecation " "warning out using :func:`warnings.catch_warnings` from Python." @@ -5499,7 +5800,7 @@ msgstr "" "如果你\\ *知道*\\ 可以安全地跳過 ``tp_new``,請使用 Python 中的 :func:" "`warnings.catch_warnings` 過濾掉棄用警告。" -#: ../../whatsnew/3.12.rst:2130 +#: ../../whatsnew/3.12.rst:2134 msgid "" ":c:var:`PyOS_InputHook` and :c:var:`PyOS_ReadlineFunctionPointer` are no " "longer called in :ref:`subinterpreters `. This is " @@ -5510,7 +5811,7 @@ msgstr "" "ref:`子直譯器 (subinterpreter) ` 中呼叫。這是因為客" "戶端通常依賴於行程範圍的全域狀態(因為這些回呼無法恢復擴充模組狀態)。" -#: ../../whatsnew/3.12.rst:2135 +#: ../../whatsnew/3.12.rst:2139 msgid "" "This also avoids situations where extensions may find themselves running in " "a subinterpreter that they don't support (or haven't yet been loaded in). " @@ -5519,7 +5820,7 @@ msgstr "" "這也避免了擴充可能發現自己在它們不支援(或尚未載入)的子直譯器中運行的情況。" "請參閱 :gh:`104668` 了解更多資訊。" -#: ../../whatsnew/3.12.rst:2139 +#: ../../whatsnew/3.12.rst:2143 msgid "" ":c:struct:`PyLongObject` has had its internals changed for better " "performance. Although the internals of :c:struct:`PyLongObject` are private, " @@ -5534,15 +5835,15 @@ msgstr "" "位,而應使用以 ``PyLong_...`` 開頭的 API 函式。提供了兩個新的\\ *不穩定* API " "函式,用於有效存取適合單一機器字的 :c:struct:`PyLongObject` 的值:" -#: ../../whatsnew/3.12.rst:2147 +#: ../../whatsnew/3.12.rst:2151 msgid ":c:func:`PyUnstable_Long_IsCompact`" msgstr ":c:func:`PyUnstable_Long_IsCompact`" -#: ../../whatsnew/3.12.rst:2148 +#: ../../whatsnew/3.12.rst:2152 msgid ":c:func:`PyUnstable_Long_CompactValue`" msgstr ":c:func:`PyUnstable_Long_CompactValue`" -#: ../../whatsnew/3.12.rst:2150 +#: ../../whatsnew/3.12.rst:2154 msgid "" "Custom allocators, set via :c:func:`PyMem_SetAllocator`, are now required to " "be thread-safe, regardless of memory domain. Allocators that don't have " @@ -5555,7 +5856,7 @@ msgstr "" "分配器還不是執行緒安全的並且你需要指導,請建立一個新的 GitHub 問題並抄送 " "``@ericsnowcurrently``。" -#: ../../whatsnew/3.12.rst:2160 +#: ../../whatsnew/3.12.rst:2164 msgid "" "In accordance with :pep:`699`, the ``ma_version_tag`` field in :c:type:" "`PyDictObject` is deprecated for extension modules. Accessing this field " @@ -5568,76 +5869,76 @@ msgstr "" "除。(由 Ramvikrams 和 Kumar Aditya 在 :gh:`101193` 中貢獻。PEP 為 Ken Jin 所" "撰寫。)" -#: ../../whatsnew/3.12.rst:2165 +#: ../../whatsnew/3.12.rst:2169 msgid "Deprecate global configuration variable:" msgstr "棄用全域配置變數:" -#: ../../whatsnew/3.12.rst:2167 +#: ../../whatsnew/3.12.rst:2171 msgid ":c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug`" msgstr ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug`" -#: ../../whatsnew/3.12.rst:2168 +#: ../../whatsnew/3.12.rst:2172 msgid ":c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose`" msgstr ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose`" -#: ../../whatsnew/3.12.rst:2169 +#: ../../whatsnew/3.12.rst:2173 msgid ":c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet`" msgstr ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet`" -#: ../../whatsnew/3.12.rst:2170 +#: ../../whatsnew/3.12.rst:2174 msgid ":c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive`" msgstr ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive`" -#: ../../whatsnew/3.12.rst:2171 +#: ../../whatsnew/3.12.rst:2175 msgid ":c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect`" msgstr ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect`" -#: ../../whatsnew/3.12.rst:2172 +#: ../../whatsnew/3.12.rst:2176 msgid ":c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level`" msgstr "" ":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level`" -#: ../../whatsnew/3.12.rst:2173 +#: ../../whatsnew/3.12.rst:2177 msgid ":c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import`" msgstr ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import`" -#: ../../whatsnew/3.12.rst:2174 +#: ../../whatsnew/3.12.rst:2178 msgid ":c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning`" msgstr "" ":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning`" -#: ../../whatsnew/3.12.rst:2175 +#: ../../whatsnew/3.12.rst:2179 msgid ":c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings`" msgstr "" ":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings`" -#: ../../whatsnew/3.12.rst:2176 +#: ../../whatsnew/3.12.rst:2180 msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment`" msgstr "" ":c:var:`Py_IgnoreEnvironmentFlag`:請改用 :c:member:`PyConfig." "use_environment`" -#: ../../whatsnew/3.12.rst:2177 +#: ../../whatsnew/3.12.rst:2181 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode`" msgstr "" ":c:var:`Py_DontWriteBytecodeFlag`:請改用 :c:member:`PyConfig.write_bytecode`" -#: ../../whatsnew/3.12.rst:2178 +#: ../../whatsnew/3.12.rst:2182 msgid "" ":c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig.user_site_directory`" msgstr "" ":c:var:`Py_NoUserSiteDirectory`:請改用 :c:member:`PyConfig." "user_site_directory`" -#: ../../whatsnew/3.12.rst:2179 +#: ../../whatsnew/3.12.rst:2183 msgid "" ":c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio`" msgstr "" ":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio`" -#: ../../whatsnew/3.12.rst:2180 +#: ../../whatsnew/3.12.rst:2184 msgid "" ":c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed`" @@ -5645,11 +5946,11 @@ msgstr "" ":c:var:`Py_HashRandomizationFlag`:請改用 :c:member:`PyConfig.use_hash_seed` " "和 :c:member:`PyConfig.hash_seed`" -#: ../../whatsnew/3.12.rst:2182 +#: ../../whatsnew/3.12.rst:2186 msgid ":c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated`" msgstr ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated`" -#: ../../whatsnew/3.12.rst:2183 +#: ../../whatsnew/3.12.rst:2187 msgid "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig." "legacy_windows_fs_encoding`" @@ -5657,7 +5958,7 @@ msgstr "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`:請改用 :c:member:`PyPreConfig." "legacy_windows_fs_encoding`" -#: ../../whatsnew/3.12.rst:2184 +#: ../../whatsnew/3.12.rst:2188 msgid "" ":c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig." "legacy_windows_stdio`" @@ -5665,7 +5966,7 @@ msgstr "" ":c:var:`Py_LegacyWindowsStdioFlag`:請改用 :c:member:`PyConfig." "legacy_windows_stdio`" -#: ../../whatsnew/3.12.rst:2185 +#: ../../whatsnew/3.12.rst:2189 msgid "" ":c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig." "filesystem_encoding`" @@ -5673,7 +5974,7 @@ msgstr "" ":c:var:`!Py_FileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." "filesystem_encoding`" -#: ../../whatsnew/3.12.rst:2186 +#: ../../whatsnew/3.12.rst:2190 msgid "" ":c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig." "filesystem_encoding`" @@ -5681,7 +5982,7 @@ msgstr "" ":c:var:`!Py_HasFileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." "filesystem_encoding`" -#: ../../whatsnew/3.12.rst:2187 +#: ../../whatsnew/3.12.rst:2191 msgid "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig." "filesystem_errors`" @@ -5689,7 +5990,7 @@ msgstr "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改用 :c:member:`PyConfig." "filesystem_errors`" -#: ../../whatsnew/3.12.rst:2188 +#: ../../whatsnew/3.12.rst:2192 msgid "" ":c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` (see :c:func:" "`Py_PreInitialize`)" @@ -5697,7 +5998,7 @@ msgstr "" ":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode`\\ (參見 :c:" "func:`Py_PreInitialize`)" -#: ../../whatsnew/3.12.rst:2190 +#: ../../whatsnew/3.12.rst:2194 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` instead. (Contributed by Victor Stinner in :gh:`77782`.)" @@ -5705,7 +6006,7 @@ msgstr "" ":c:func:`Py_InitializeFromConfig` API 應改為與 :c:type:`PyConfig` 一起使用。" "(由 Victor Stinner 於 :gh:`77782` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2194 +#: ../../whatsnew/3.12.rst:2198 msgid "" "Creating :c:data:`immutable types ` with mutable " "bases is deprecated and will be disabled in Python 3.14. (:gh:`95388`)" @@ -5713,20 +6014,20 @@ msgstr "" "建立具有可變基底的\\ :c:data:`不可變型別 `\\ 已被棄" "用,並將在 Python 3.14 中停用。(:gh:`95388`)" -#: ../../whatsnew/3.12.rst:2197 +#: ../../whatsnew/3.12.rst:2201 msgid "" "The :file:`structmember.h` header is deprecated, though it continues to be " "available and there are no plans to remove it." msgstr ":file:`structmember.h` 標頭已棄用,但仍可使用,且還沒有移除它的計畫。" -#: ../../whatsnew/3.12.rst:2200 +#: ../../whatsnew/3.12.rst:2204 msgid "" "Its contents are now available just by including :file:`Python.h`, with a " "``Py`` prefix added if it was missing:" msgstr "" "現在只需包含 :file:`Python.h` 即可使用其內容,如果缺少,則新增 ``Py`` 前綴:" -#: ../../whatsnew/3.12.rst:2203 +#: ../../whatsnew/3.12.rst:2207 msgid "" ":c:struct:`PyMemberDef`, :c:func:`PyMember_GetOne` and :c:func:" "`PyMember_SetOne`" @@ -5734,7 +6035,7 @@ msgstr "" ":c:struct:`PyMemberDef`、:c:func:`PyMember_GetOne` 和 :c:func:" "`PyMember_SetOne`" -#: ../../whatsnew/3.12.rst:2205 +#: ../../whatsnew/3.12.rst:2209 msgid "" "Type macros like :c:macro:`Py_T_INT`, :c:macro:`Py_T_DOUBLE`, etc. " "(previously ``T_INT``, ``T_DOUBLE``, etc.)" @@ -5742,7 +6043,7 @@ msgstr "" "型別巨集,如 :c:macro:`Py_T_INT`、:c:macro:`Py_T_DOUBLE` 等(以前為 " "``T_INT``、 ``T_DOUBLE`` 等)" -#: ../../whatsnew/3.12.rst:2207 +#: ../../whatsnew/3.12.rst:2211 msgid "" "The flags :c:macro:`Py_READONLY` (previously ``READONLY``) and :c:macro:" "`Py_AUDIT_READ` (previously all uppercase)" @@ -5750,23 +6051,23 @@ msgstr "" ":c:macro:`Py_READONLY`\\ (先前為 ``READONLY``)和 :c:macro:" "`Py_AUDIT_READ`\\ (先前全大寫)旗標" -#: ../../whatsnew/3.12.rst:2210 +#: ../../whatsnew/3.12.rst:2214 msgid "Several items are not exposed from :file:`Python.h`:" msgstr "數個項目不再從 :file:`Python.h` 中公開:" -#: ../../whatsnew/3.12.rst:2212 +#: ../../whatsnew/3.12.rst:2216 msgid ":c:macro:`T_OBJECT` (use :c:macro:`Py_T_OBJECT_EX`)" msgstr ":c:macro:`T_OBJECT`\\ (請改用 :c:macro:`Py_T_OBJECT_EX`)" -#: ../../whatsnew/3.12.rst:2213 +#: ../../whatsnew/3.12.rst:2217 msgid ":c:macro:`T_NONE` (previously undocumented, and pretty quirky)" msgstr ":c:macro:`T_NONE`\\ (先前未記錄於文件上,且相當古怪)" -#: ../../whatsnew/3.12.rst:2214 +#: ../../whatsnew/3.12.rst:2218 msgid "The macro ``WRITE_RESTRICTED`` which does nothing." msgstr "不做任何事的巨集 ``WRITE_RESTRICTED``。" -#: ../../whatsnew/3.12.rst:2215 +#: ../../whatsnew/3.12.rst:2219 msgid "" "The macros ``RESTRICTED`` and ``READ_RESTRICTED``, equivalents of :c:macro:" "`Py_AUDIT_READ`." @@ -5774,7 +6075,7 @@ msgstr "" "``RESTRICTED`` 和 ``READ_RESTRICTED`` 這兩個巨集,相當於 :c:macro:" "`Py_AUDIT_READ`。" -#: ../../whatsnew/3.12.rst:2217 +#: ../../whatsnew/3.12.rst:2221 msgid "" "In some configurations, ```` is not included from :file:`Python." "h`. It should be included manually when using ``offsetof()``." @@ -5782,7 +6083,7 @@ msgstr "" "在某些配置中,:file:`Python.h` 中不包含 ````。使用 ``offsetof()`` " "時應手動包含它。" -#: ../../whatsnew/3.12.rst:2220 +#: ../../whatsnew/3.12.rst:2224 msgid "" "The deprecated header continues to provide its original contents under the " "original names. Your old code can stay unchanged, unless the extra include " @@ -5791,7 +6092,7 @@ msgstr "" "已棄用的標頭繼續以原始名稱提供其原始內容。你的舊程式碼可以保持不變,除非額外" "的包含巨集和非命名空間巨集對你造成很大困擾。" -#: ../../whatsnew/3.12.rst:2225 +#: ../../whatsnew/3.12.rst:2229 msgid "" "(Contributed in :gh:`47146` by Petr Viktorin, based on earlier work by " "Alexander Belopolsky and Matthias Braun.)" @@ -5799,7 +6100,7 @@ msgstr "" "(由 Petr Viktorin 在 :gh:`47146` 中貢獻,其基於 Alexander Belopolsky 和 " "Matthias Braun 的前期工作。)" -#: ../../whatsnew/3.12.rst:2228 +#: ../../whatsnew/3.12.rst:2232 msgid "" ":c:func:`PyErr_Fetch` and :c:func:`PyErr_Restore` are deprecated. Use :c:" "func:`PyErr_GetRaisedException` and :c:func:`PyErr_SetRaisedException` " @@ -5809,7 +6110,7 @@ msgstr "" "`PyErr_GetRaisedException` 和 :c:func:`PyErr_SetRaisedException`。(由 Mark " "Shannon 在 :gh:`101578` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2233 +#: ../../whatsnew/3.12.rst:2237 msgid "" ":c:func:`!PyErr_Display` is deprecated. Use :c:func:`PyErr_DisplayException` " "instead. (Contributed by Irit Katriel in :gh:`102755`)." @@ -5817,7 +6118,7 @@ msgstr "" ":c:func:`!PyErr_Display` 已棄用,請改用 :c:func:`PyErr_DisplayException`。" "(由 Irit Katriel 於 :gh:`102755` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2236 +#: ../../whatsnew/3.12.rst:2240 msgid "" "``_PyErr_ChainExceptions`` is deprecated. Use ``_PyErr_ChainExceptions1`` " "instead. (Contributed by Irit Katriel in :gh:`102192`.)" @@ -5825,7 +6126,7 @@ msgstr "" "``_PyErr_ChainExceptions`` 已棄用,請改用 ``_PyErr_ChainExceptions1``。(由 " "Irit Katriel 於 :gh:`102192` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2239 +#: ../../whatsnew/3.12.rst:2243 msgid "" "Using :c:func:`PyType_FromSpec`, :c:func:`PyType_FromSpecWithBases` or :c:" "func:`PyType_FromModuleAndSpec` to create a class whose metaclass overrides :" @@ -5853,39 +6154,31 @@ msgstr "" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 msgid "" -"The :c:func:`PyImport_ImportModuleNoBlock`: Use :c:func:" +"The :c:func:`!PyImport_ImportModuleNoBlock`: Use :c:func:" "`PyImport_ImportModule` instead." msgstr "" -":c:func:`PyImport_ImportModuleNoBlock`:請改用 :c:func:" -"`PyImport_ImportModule`。" +":c:func:`!PyImport_ImportModuleNoBlock`:請改" +"用 :c:func:`PyImport_ImportModule`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 msgid "" -":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" +":c:func:`!PyWeakref_GetObject` and :c:func:`!PyWeakref_GET_OBJECT`: Use :c:" "func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project `__ can be used to get :c:func:" "`PyWeakref_GetRef` on Python 3.12 and older." msgstr "" -":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改用 :c:" -"func:`PyWeakref_GetRef`。可以使用 `pythoncapi-compat 專案 `__\\ 來為 Python 3.12 和更早版本取得 :c:func:" -"`PyWeakref_GetRef`。" +":c:func:`!PyWeakref_GetObject` 和 :c:func:`!PyWeakref_GET_OBJECT`:請改" +"用 :c:func:`PyWeakref_GetRef`。可以使用 `pythoncapi-compat 專案 `__\\ 來為 Python 3.12 和更早版本取" +"得 :c:func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 msgid "" -":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" -"type:`wchar_t` instead." -msgstr "" -":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:type:" -"`wchar_t`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 -msgid "" ":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" ":c:func:`!PyUnicode_AsDecodedObject`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" ":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -5895,13 +6188,13 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`str` 的型別,例如 :" "class:`bytes`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 msgid "" ":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." msgstr "" ":c:func:`!PyUnicode_AsEncodedObject`:請改用 :c:func:`PyCodec_Encode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:19 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid "" ":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -5911,68 +6204,69 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`bytes` 的型別,例如 :" "class:`str`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 msgid "Python initialization functions, deprecated in Python 3.13:" msgstr "Python 初始化函式,自 Python 3.13 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 msgid "" -":c:func:`Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`) instead." msgstr "" -":c:func:`Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:27 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" -":c:func:`Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " +":c:func:`!Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) if :ref:" "`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " +":c:func:`!Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`)。如果需要處理\\ :ref:`虛擬環境 " -"`,請改用 :c:func:`PyConfig_Get(\"prefix\") ` (:data:" -"`sys.prefix`)。" +"`,請改用 :c:func:`PyConfig_Get(\"prefix\") ` " +"(:data:`sys.prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:32 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:30 msgid "" -":c:func:`Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " +":c:func:`!Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " "` (:data:`sys.base_exec_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) if :" "ref:`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetExecPrefix`:請改用 :c:func:" -"`PyConfig_Get(\"base_exec_prefix\") ` (:data:`sys." -"base_exec_prefix`)。如果需要處理\\ :ref:`虛擬環境 `,請改用 :c:" -"func:`PyConfig_Get(\"exec_prefix\") ` (:data:`sys." -"exec_prefix`)。" +":c:func:`!Py_GetExecPrefix`:請改" +"用 :c:func:`PyConfig_Get(\"base_exec_prefix\") ` " +"(:data:`sys.base_exec_prefix`)。如果需要處理\\ :ref:`虛擬環境 `,請" +"改用 :c:func:`PyConfig_Get(\"exec_prefix\") ` " +"(:data:`sys.exec_prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:38 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:36 msgid "" -":c:func:`Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramFullPath`:請改用 :c:func:" -"`PyConfig_Get(\"executable\") ` (:data:`sys.executable`)。" +":c:func:`!Py_GetProgramFullPath`:請改" +"用 :c:func:`PyConfig_Get(\"executable\") ` " +"(:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:41 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:39 msgid "" -":c:func:`Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:44 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:42 msgid "" -":c:func:`Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " "` or the :envvar:`PYTHONHOME` environment variable instead." msgstr "" -":c:func:`Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " "` 或 :envvar:`PYTHONHOME` 環境變數。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:48 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:46 msgid "" "The `pythoncapi-compat project `__ can be used to get :c:func:`PyConfig_Get` on Python 3.13 and older." @@ -5980,50 +6274,50 @@ msgstr "" "`pythoncapi-compat 專案 `__ 可" "以用來為 Python 3.13 和更早版本取得 :c:func:`PyConfig_Get`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:50 msgid "" "Functions to configure Python's initialization, deprecated in Python 3.11:" msgstr "用於配置 Python 初始化的函式,自 Python 3.11 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgvEx()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgv()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 msgid "" ":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " "instead." msgstr "" ":c:func:`!Py_SetProgramName()`:請改用 :c:member:`PyConfig.program_name`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." msgstr ":c:func:`!Py_SetPythonHome()`:請改用 :c:member:`PyConfig.home`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:62 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 msgid "" -":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" +":c:func:`!PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" -":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" -"data:`!warnings.filters`。" +":c:func:`!PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` " +"和 :data:`!warnings.filters`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:65 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:63 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` instead." msgstr "" "應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:66 msgid "Global configuration variables:" msgstr "全域配置變數:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:70 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 msgid "" ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` or :c:func:" "`PyConfig_Get(\"parser_debug\") ` instead." @@ -6031,7 +6325,7 @@ msgstr "" ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug` 或 :c:func:" "`PyConfig_Get(\"parser_debug\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:73 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:71 msgid "" ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` or :c:func:" "`PyConfig_Get(\"verbose\") ` instead." @@ -6039,7 +6333,7 @@ msgstr "" ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose` 或 :c:func:" "`PyConfig_Get(\"verbose\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:76 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:74 msgid "" ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` or :c:func:" "`PyConfig_Get(\"quiet\") ` instead." @@ -6047,7 +6341,7 @@ msgstr "" ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet` 或 :c:func:" "`PyConfig_Get(\"quiet\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:79 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:77 msgid "" ":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` or :c:func:" "`PyConfig_Get(\"interactive\") ` instead." @@ -6055,7 +6349,7 @@ msgstr "" ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive` 或 :c:" "func:`PyConfig_Get(\"interactive\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:82 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:80 msgid "" ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` or :c:func:" "`PyConfig_Get(\"inspect\") ` instead." @@ -6063,7 +6357,7 @@ msgstr "" ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect` 或 :c:func:" "`PyConfig_Get(\"inspect\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:85 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:83 msgid "" ":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` or :c:" "func:`PyConfig_Get(\"optimization_level\") ` instead." @@ -6071,7 +6365,7 @@ msgstr "" ":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level` 或 :" "c:func:`PyConfig_Get(\"optimization_level\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:88 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:86 msgid "" ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` or :c:func:" "`PyConfig_Get(\"site_import\") ` instead." @@ -6079,7 +6373,7 @@ msgstr "" ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import` 或 :c:func:" "`PyConfig_Get(\"site_import\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:91 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:89 msgid "" ":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` or :c:" "func:`PyConfig_Get(\"bytes_warning\") ` instead." @@ -6087,7 +6381,7 @@ msgstr "" ":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning` 或 :" "c:func:`PyConfig_Get(\"bytes_warning\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:94 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:92 msgid "" ":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` or :c:" "func:`PyConfig_Get(\"pathconfig_warnings\") ` instead." @@ -6095,7 +6389,7 @@ msgstr "" ":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings` 或 :" "c:func:`PyConfig_Get(\"pathconfig_warnings\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:97 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:95 msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "or :c:func:`PyConfig_Get(\"use_environment\") ` instead." @@ -6104,7 +6398,7 @@ msgstr "" "use_environment` 或 :c:func:`PyConfig_Get(\"use_environment\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:100 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:98 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "or :c:func:`PyConfig_Get(\"write_bytecode\") ` instead." @@ -6113,7 +6407,7 @@ msgstr "" "write_bytecode` 或 :c:func:`PyConfig_Get(\"write_bytecode\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:103 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:101 msgid "" ":c:var:`Py_NoUserSiteDirectory`: Use :c:member:`PyConfig." "user_site_directory` or :c:func:`PyConfig_Get(\"user_site_directory\") " @@ -6123,7 +6417,7 @@ msgstr "" "user_site_directory` 或 :c:func:`PyConfig_Get(\"user_site_directory\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:106 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:104 msgid "" ":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` or :" "c:func:`PyConfig_Get(\"buffered_stdio\") ` instead." @@ -6131,7 +6425,7 @@ msgstr "" ":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio` " "或 :c:func:`PyConfig_Get(\"buffered_stdio\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:109 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:107 msgid "" ":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed` or :c:func:`PyConfig_Get(\"hash_seed\") " @@ -6141,7 +6435,7 @@ msgstr "" "和 :c:member:`PyConfig.hash_seed` 或 :c:func:`PyConfig_Get(\"hash_seed\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:113 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:111 msgid "" ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` or :c:func:" "`PyConfig_Get(\"isolated\") ` instead." @@ -6149,7 +6443,7 @@ msgstr "" ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated` 或 :c:func:" "`PyConfig_Get(\"isolated\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:116 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:114 msgid "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`: Use :c:member:`PyPreConfig." "legacy_windows_fs_encoding` or :c:func:" @@ -6159,7 +6453,7 @@ msgstr "" "legacy_windows_fs_encoding` 或 :c:func:" "`PyConfig_Get(\"legacy_windows_fs_encoding\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:119 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:117 msgid "" ":c:var:`Py_LegacyWindowsStdioFlag`: Use :c:member:`PyConfig." "legacy_windows_stdio` or :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " @@ -6169,7 +6463,7 @@ msgstr "" "legacy_windows_stdio` 或 :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:122 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:120 msgid "" ":c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!" "Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." @@ -6181,7 +6475,7 @@ msgstr "" "filesystem_encoding` 或 :c:func:`PyConfig_Get(\"filesystem_encoding\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:125 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:123 msgid "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." "filesystem_errors` or :c:func:`PyConfig_Get(\"filesystem_errors\") " @@ -6191,7 +6485,7 @@ msgstr "" "filesystem_errors` 或 :c:func:`PyConfig_Get(\"filesystem_errors\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:128 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:126 msgid "" ":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` or :c:func:" "`PyConfig_Get(\"utf8_mode\") ` instead. (see :c:func:" @@ -6201,7 +6495,7 @@ msgstr "" "`PyConfig_Get(\"utf8_mode\") `。(請參閱 :c:func:" "`Py_PreInitialize`)" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:133 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:131 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` to set these options. Or :c:func:`PyConfig_Get` can be used to " @@ -6317,7 +6611,7 @@ msgstr "" msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" -#: ../../whatsnew/3.12.rst:2257 +#: ../../whatsnew/3.12.rst:2261 msgid "" "Remove the :file:`token.h` header file. There was never any public tokenizer " "C API. The :file:`token.h` header file was only designed to be used by " @@ -6327,47 +6621,47 @@ msgstr "" "`token.h` 標頭檔案的設計是僅限用於 Python 內部。(由 Victor Stinner 於 :gh:" "`92651` 中貢獻。)" -#: ../../whatsnew/3.12.rst:2262 +#: ../../whatsnew/3.12.rst:2266 msgid "Legacy Unicode APIs have been removed. See :pep:`623` for detail." msgstr "舊版 Unicode API 已被刪除。有關詳細資訊請參閱 :pep:`623`。" -#: ../../whatsnew/3.12.rst:2264 +#: ../../whatsnew/3.12.rst:2268 msgid ":c:macro:`!PyUnicode_WCHAR_KIND`" msgstr ":c:macro:`!PyUnicode_WCHAR_KIND`" -#: ../../whatsnew/3.12.rst:2265 +#: ../../whatsnew/3.12.rst:2269 msgid ":c:func:`!PyUnicode_AS_UNICODE`" msgstr ":c:func:`!PyUnicode_AS_UNICODE`" -#: ../../whatsnew/3.12.rst:2266 +#: ../../whatsnew/3.12.rst:2270 msgid ":c:func:`!PyUnicode_AsUnicode`" msgstr ":c:func:`!PyUnicode_AsUnicode`" -#: ../../whatsnew/3.12.rst:2267 +#: ../../whatsnew/3.12.rst:2271 msgid ":c:func:`!PyUnicode_AsUnicodeAndSize`" msgstr ":c:func:`!PyUnicode_AsUnicodeAndSize`" -#: ../../whatsnew/3.12.rst:2268 +#: ../../whatsnew/3.12.rst:2272 msgid ":c:func:`!PyUnicode_AS_DATA`" msgstr ":c:func:`!PyUnicode_AS_DATA`" -#: ../../whatsnew/3.12.rst:2269 +#: ../../whatsnew/3.12.rst:2273 msgid ":c:func:`!PyUnicode_FromUnicode`" msgstr ":c:func:`!PyUnicode_FromUnicode`" -#: ../../whatsnew/3.12.rst:2270 +#: ../../whatsnew/3.12.rst:2274 msgid ":c:func:`!PyUnicode_GET_SIZE`" msgstr ":c:func:`!PyUnicode_GET_SIZE`" -#: ../../whatsnew/3.12.rst:2271 +#: ../../whatsnew/3.12.rst:2275 msgid ":c:func:`!PyUnicode_GetSize`" msgstr ":c:func:`!PyUnicode_GetSize`" -#: ../../whatsnew/3.12.rst:2272 +#: ../../whatsnew/3.12.rst:2276 msgid ":c:func:`!PyUnicode_GET_DATA_SIZE`" msgstr ":c:func:`!PyUnicode_GET_DATA_SIZE`" -#: ../../whatsnew/3.12.rst:2274 +#: ../../whatsnew/3.12.rst:2278 msgid "" "Remove the ``PyUnicode_InternImmortal()`` function macro. (Contributed by " "Victor Stinner in :gh:`85858`.)" @@ -6375,6 +6669,13 @@ msgstr "" "移除 ``PyUnicode_InternImmortal()`` 函式巨集。(由 Victor Stinner 於 :gh:" "`85858` 中貢獻。)" +#~ msgid "" +#~ ":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :" +#~ "c:type:`wchar_t` instead." +#~ msgstr "" +#~ ":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:" +#~ "type:`wchar_t`。" + #~ msgid ":class:`locale`:" #~ msgstr ":class:`locale`:" diff --git a/whatsnew/3.13.po b/whatsnew/3.13.po index 41c225a735d..e18bc1f3ae8 100644 --- a/whatsnew/3.13.po +++ b/whatsnew/3.13.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -345,7 +345,7 @@ msgid "" "years of security fixes." msgstr "" -#: ../../whatsnew/3.13.rst:208 ../../whatsnew/3.13.rst:2049 +#: ../../whatsnew/3.13.rst:208 ../../whatsnew/3.13.rst:2050 msgid "New Features" msgstr "新增功能" @@ -2801,7 +2801,7 @@ msgid "" msgstr "" #: ../../whatsnew/3.13.rst:1859 -#: ../../deprecations/pending-removal-in-3.18.rst:4 +#: ../../deprecations/pending-removal-in-3.18.rst:7 msgid ":mod:`decimal`:" msgstr ":mod:`decimal`:" @@ -2853,11 +2853,11 @@ msgstr ":mod:`http.server`:" #: ../../whatsnew/3.13.rst:1889 msgid "" -"Deprecate :class:`~http.server.CGIHTTPRequestHandler`, to be removed in " -"Python 3.15. Process-based CGI HTTP servers have been out of favor for a " -"very long time. This code was outdated, unmaintained, and rarely used. It " -"has a high potential for both security and functionality bugs. (Contributed " -"by Gregory P. Smith in :gh:`109096`.)" +"Deprecate :class:`!CGIHTTPRequestHandler`, to be removed in Python 3.15. " +"Process-based CGI HTTP servers have been out of favor for a very long time. " +"This code was outdated, unmaintained, and rarely used. It has a high " +"potential for both security and functionality bugs. (Contributed by Gregory " +"P. Smith in :gh:`109096`.)" msgstr "" #: ../../whatsnew/3.13.rst:1896 @@ -2899,10 +2899,13 @@ msgstr ":mod:`pathlib`:" #: ../../whatsnew/3.13.rst:1919 msgid "" -"Deprecate :meth:`.PurePath.is_reserved`, to be removed in Python 3.15. Use :" +"Deprecate :meth:`!.PurePath.is_reserved`, to be removed in Python 3.15. Use :" "func:`os.path.isreserved` to detect reserved paths on Windows. (Contributed " "by Barney Gale in :gh:`88569`.)" msgstr "" +"棄用 :meth:`!.PurePath.is_reserved`,將在 Python 3.15 中移除。請" +"用 :func:`os.path.isreserved` 來偵測 Windows 上的保留路徑。(由 Barney Gale " +"在 :gh:`88569` 中貢獻。)" #: ../../whatsnew/3.13.rst:1924 #: ../../deprecations/pending-removal-in-3.15.rst:42 @@ -2911,10 +2914,13 @@ msgstr ":mod:`platform`:" #: ../../whatsnew/3.13.rst:1926 msgid "" -"Deprecate :func:`~platform.java_ver`, to be removed in Python 3.15. This " +"Deprecate :func:`!platform.java_ver`, to be removed in Python 3.15. This " "function is only useful for Jython support, has a confusing API, and is " "largely untested. (Contributed by Nikita Sobolev in :gh:`116349`.)" msgstr "" +"棄用 :func:`!platform.java_ver`,將在 Python 3.15 中移除。此函式僅對 Jython " +"支援有用,具有令人困惑的 API,基本上未經測試。(由 Nikita Sobolev " +"在 :gh:`116349` 中貢獻。)" #: ../../whatsnew/3.13.rst:1932 msgid ":mod:`pydoc`:" @@ -2993,7 +2999,8 @@ msgstr "" #: ../../whatsnew/3.13.rst:1978 #: ../../deprecations/pending-removal-in-3.15.rst:70 -#: ../../deprecations/pending-removal-in-3.17.rst:26 +#: ../../deprecations/pending-removal-in-3.17.rst:52 +#: ../../deprecations/pending-removal-in-3.20.rst:57 msgid ":mod:`typing`:" msgstr ":mod:`typing`:" @@ -3019,13 +3026,13 @@ msgstr "" #: ../../whatsnew/3.13.rst:1997 msgid "" -"Deprecate the :deco:`typing.no_type_check_decorator` decorator function, to " +"Deprecate the :deco:`!typing.no_type_check_decorator` decorator function, to " "be removed in Python 3.15. After eight years in the :mod:`typing` module, it " "has yet to be supported by any major type checker. (Contributed by Alex " "Waygood in :gh:`106309`.)" msgstr "" -"棄用 :deco:`typing.no_type_check_decorator` 裝飾器函式。將在 Python 3.15 中移" -"除。在 :mod:`typing` 模組中經過八年後,它至今仍未被任何主要的型別檢查器所支" +"棄用 :deco:`!typing.no_type_check_decorator` 裝飾器函式。將在 Python 3.15 中" +"移除。在 :mod:`typing` 模組中經過八年後,它至今仍未被任何主要的型別檢查器所支" "援。(由 Alex Waygood 在 :gh:`106309` 中貢獻。)" #: ../../whatsnew/3.13.rst:2003 @@ -3038,17 +3045,19 @@ msgid "" msgstr "" #: ../../whatsnew/3.13.rst:2011 -#: ../../deprecations/pending-removal-in-3.15.rst:90 +#: ../../deprecations/pending-removal-in-3.15.rst:92 msgid ":mod:`wave`:" msgstr ":mod:`wave`:" #: ../../whatsnew/3.13.rst:2013 msgid "" -"Deprecate the :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:" -"`~wave.Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :" -"class:`~wave.Wave_write` classes, to be removed in Python 3.15. (Contributed " -"by Victor Stinner in :gh:`105096`.)" +"Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of " +"the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes, to be " +"removed in Python 3.15. (Contributed by Victor Stinner in :gh:`105096`.)" msgstr "" +"棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 " +"``getmark()``、``setmark()`` 和 ``getmarkers()`` 方法,將在 Python 3.15 中移" +"除。(由 Victor Stinner 在 :gh:`105096` 中貢獻。)" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:2 #: ../../deprecations/pending-removal-in-3.14.rst:2 @@ -3274,14 +3283,14 @@ msgstr "引入系統 (import system):" #: ../../deprecations/pending-removal-in-3.15.rst:6 msgid "" -"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" -"`__spec__.cached ` is deprecated. In " -"Python 3.15, :attr:`!__cached__` will cease to be set or take into " -"consideration by the import system or standard library. (:gh:`97879`)" +"Setting ``__cached__`` on a module while failing to set :attr:`__spec__." +"cached ` is deprecated. In Python " +"3.15, ``__cached__`` will cease to be set or take into consideration by the " +"import system or standard library. (:gh:`97879`)" msgstr "" -"在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " +"在模組上設定 ``__cached__`` 而沒有設定 :attr:`__spec__.cached " "` 的做法已被棄用。在 Python 3.15 中," -"引入系統或標準函式庫將不再設定或考慮 :attr:`!__cached__`。(:gh:`97879`)" +"引入系統或標準函式庫將不再設定或考慮 ``__cached__``。(:gh:`97879`)" #: ../../deprecations/pending-removal-in-3.15.rst:11 msgid "" @@ -3303,13 +3312,13 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:23 msgid "" -"The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` has " -"been deprecated since Python 3.13. No direct replacement exists. *Anything* " -"is better than CGI to interface a web server with a request handler." +"The obsolete and rarely used :class:`!CGIHTTPRequestHandler` has been " +"deprecated since Python 3.13. No direct replacement exists. *Anything* is " +"better than CGI to interface a web server with a request handler." msgstr "" -"過時且很少使用的 :class:`~http.server.CGIHTTPRequestHandler` 自 Python 3.13 " -"起已被棄用。不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求" -"處理程序介接起來。" +"過時且很少使用的 :class:`!CGIHTTPRequestHandler` 自 Python 3.13 起已被棄用。" +"不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求處理程序介接" +"起來。" #: ../../deprecations/pending-removal-in-3.15.rst:29 msgid "" @@ -3330,19 +3339,19 @@ msgstr "``load_module()`` method:請改用 ``exec_module()``。" #: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" -":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" +":meth:`!.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" "func:`os.path.isreserved` to detect reserved paths on Windows." msgstr "" -":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os.path." -"isreserved` 來偵測 Windows 上的保留路徑。" +":meth:`!.PurePath.is_reserved` 已自 Python 3.13 被棄用。請" +"用 :func:`os.path.isreserved` 來偵測 Windows 上的保留路徑。" #: ../../deprecations/pending-removal-in-3.15.rst:44 msgid "" -":func:`~platform.java_ver` has been deprecated since Python 3.13. This " +":func:`!platform.java_ver` has been deprecated since Python 3.13. This " "function is only useful for Jython support, has a confusing API, and is " "largely untested." msgstr "" -"自 Python 3.13 起,:func:`~platform.java_ver` 已被棄用。此函式僅對 Jython 支" +"自 Python 3.13 起,:func:`!platform.java_ver` 已被棄用。此函式僅對 Jython 支" "援有用,具有令人困惑的 API,基本上未經測試。" #: ../../deprecations/pending-removal-in-3.15.rst:48 @@ -3379,15 +3388,15 @@ msgstr ":mod:`types`:" #: ../../deprecations/pending-removal-in-3.15.rst:63 msgid "" -":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +":class:`types.CodeType`: Accessing :attr:`!codeobject.co_lnotab` was " "deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " "but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " "in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" msgstr "" -":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" -"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" -"exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" -"`101866` 貢獻。)" +":class:`types.CodeType`:自 3.10 起,存取 :attr:`!codeobject.co_lnotab` 已" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但直到 3.12 才有正式" +"的 :exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev " +"於 :gh:`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:72 msgid "" @@ -3415,37 +3424,39 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:85 msgid "" -"The :deco:`typing.no_type_check_decorator` decorator function has been " +"The :deco:`!typing.no_type_check_decorator` decorator function has been " "deprecated since Python 3.13. After eight years in the :mod:`typing` module, " "it has yet to be supported by any major type checker." msgstr "" -"自 Python 3.13 起,:deco:`typing.no_type_check_decorator` 裝飾器函式已被棄" +"自 Python 3.13 起,:deco:`!typing.no_type_check_decorator` 裝飾器函式已被棄" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" -#: ../../deprecations/pending-removal-in-3.15.rst:92 +#: ../../deprecations/pending-removal-in-3.15.rst:90 msgid "" -"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." -"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" -"`~wave.Wave_write` classes have been deprecated since Python 3.13." +":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." +msgstr ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" + +#: ../../deprecations/pending-removal-in-3.15.rst:94 +msgid "" +"The ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of the :class:" +"`~wave.Wave_read` and :class:`~wave.Wave_write` classes have been deprecated " +"since Python 3.13." msgstr "" -"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" -"`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." -"getmarkers` 方法自 Python 3.13 被棄用。" +":class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 ``getmark()``、" +"``setmark()`` 和 ``getmarkers()`` 方法自 Python 3.13 起已被棄用。" -#: ../../deprecations/pending-removal-in-3.15.rst:97 +#: ../../deprecations/pending-removal-in-3.15.rst:98 msgid ":mod:`zipimport`:" msgstr ":mod:`zipimport`:" -#: ../../deprecations/pending-removal-in-3.15.rst:99 +#: ../../deprecations/pending-removal-in-3.15.rst:100 msgid "" -":meth:`~zipimport.zipimporter.load_module` has been deprecated since Python " -"3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (Contributed " -"by Jiahao Li in :gh:`125746`.)" +":meth:`!zipimport.zipimporter.load_module` has been deprecated since Python " +"3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (:gh:`125746`.)" msgstr "" -":meth:`~zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改用 :" -"meth:`~zipimport.zipimporter.exec_module`。(由 Jiahao Li 於 :gh:`125746` 貢" -"獻。)" +":meth:`!zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改" +"用 :meth:`~zipimport.zipimporter.exec_module`。(:gh:`125746`。)" #: ../../deprecations/c-api-pending-removal-in-3.16.rst:2 #: ../../deprecations/pending-removal-in-3.16.rst:2 @@ -3658,16 +3669,28 @@ msgid "Pending removal in Python 3.17" msgstr "Python 3.17 中待移除的項目" #: ../../deprecations/pending-removal-in-3.17.rst:4 +#: ../../deprecations/pending-removal-in-future.rst:53 +msgid ":mod:`datetime`:" +msgstr ":mod:`datetime`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:6 +msgid "" +":meth:`~datetime.datetime.strptime` calls using a format string containing " +"``%e`` (day of month) without a year. This has been deprecated since Python " +"3.15. (Contributed by Stan Ulbrych in :gh:`70647`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:12 msgid ":mod:`collections.abc`:" msgstr ":mod:`collections.abc`:" -#: ../../deprecations/pending-removal-in-3.17.rst:6 +#: ../../deprecations/pending-removal-in-3.17.rst:14 msgid "" ":class:`collections.abc.ByteString` is scheduled for removal in Python 3.17." msgstr ":class:`collections.abc.ByteString` 預計在 Python 3.17 中移除。" -#: ../../deprecations/pending-removal-in-3.17.rst:8 -#: ../../deprecations/pending-removal-in-3.17.rst:36 +#: ../../deprecations/pending-removal-in-3.17.rst:16 +#: ../../deprecations/pending-removal-in-3.17.rst:62 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -3680,8 +3703,8 @@ msgstr "" "用 :class:`~collections.abc.Buffer` 或明確指定你的程式碼所支援型別的聯集(例" "如 ``bytes | bytearray | memoryview``)。" -#: ../../deprecations/pending-removal-in-3.17.rst:14 -#: ../../deprecations/pending-removal-in-3.17.rst:42 +#: ../../deprecations/pending-removal-in-3.17.rst:22 +#: ../../deprecations/pending-removal-in-3.17.rst:68 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -3697,8 +3720,8 @@ msgstr "" "其他常見的緩衝區型別如 :class:`memoryview` 也從未被理解為 :class:`!" "ByteString` 的子型別(無論是在 runtime 還是由靜態型別檢查器)。" -#: ../../deprecations/pending-removal-in-3.17.rst:22 -#: ../../deprecations/pending-removal-in-3.17.rst:50 +#: ../../deprecations/pending-removal-in-3.17.rst:30 +#: ../../deprecations/pending-removal-in-3.17.rst:76 msgid "" "See :pep:`PEP 688 <688#current-options>` for more details. (Contributed by " "Shantanu Jain in :gh:`91896`.)" @@ -3706,7 +3729,40 @@ msgstr "" "更多細節請見 :pep:`PEP 688 <688#current-options>`。(由 Shantanu Jain 於 :gh:" "`91896` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.17.rst:28 +#: ../../deprecations/pending-removal-in-3.17.rst:34 +msgid ":mod:`encodings`:" +msgstr ":mod:`encodings`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:36 +msgid "" +"Passing non-ascii *encoding* names to :func:`encodings.normalize_encoding` " +"is deprecated and scheduled for removal in Python 3.17. (Contributed by Stan " +"Ulbrych in :gh:`136702`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:40 +msgid ":mod:`profile`:" +msgstr ":mod:`profile`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:42 +msgid "" +"The :mod:`!profile` module is deprecated and will be removed in Python 3.17. " +"Use :mod:`profiling.tracing` instead, which provides a compatible API. See :" +"pep:`799` for details. (Contributed by Pablo Galindo and László Kiss Kollár " +"in :gh:`138122`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:47 +msgid ":mod:`webbrowser`:" +msgstr ":mod:`webbrowser`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:49 +msgid "" +":class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of :class:`!" +"webbrowser.MacOS`. (:gh:`137586`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:54 msgid "" "Before Python 3.14, old-style unions were implemented using the private " "class ``typing._UnionGenericAlias``. This class is no longer needed for the " @@ -3720,7 +3776,7 @@ msgstr "" "除。使用者應該改用文件中記錄的內省輔助函式,例如 :func:`typing.get_origin` " "和 :func:`typing.get_args`,或者依賴私有實作細節。" -#: ../../deprecations/pending-removal-in-3.17.rst:33 +#: ../../deprecations/pending-removal-in-3.17.rst:59 msgid "" ":class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for " "removal in Python 3.17." @@ -3728,12 +3784,33 @@ msgstr "" ":class:`typing.ByteString` 自 Python 3.9 起已被棄用,預計在 Python 3.17 中移" "除。" +#: ../../deprecations/pending-removal-in-3.17.rst:79 +msgid ":mod:`tkinter`:" +msgstr ":mod:`tkinter`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:81 +msgid "" +"The :class:`!tkinter.Variable` methods :meth:`!trace_variable`, :meth:`!" +"trace` (an alias of :meth:`!trace_variable`), :meth:`!trace_vdelete` and :" +"meth:`!trace_vinfo`, deprecated since Python 3.14, are scheduled for removal " +"in Python 3.17. Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!" +"trace_info` instead. (Contributed by Serhiy Storchaka in :gh:`120220`.)" +msgstr "" + #: ../../deprecations/c-api-pending-removal-in-3.18.rst:2 #: ../../deprecations/pending-removal-in-3.18.rst:2 msgid "Pending removal in Python 3.18" msgstr "Python 3.18 中待移除的項目" -#: ../../deprecations/pending-removal-in-3.18.rst:6 +#: ../../deprecations/pending-removal-in-3.18.rst:4 +msgid "" +"No longer accept a boolean value when a file descriptor is expected. " +"(Contributed by Serhiy Storchaka in :gh:`82626`.)" +msgstr "" +"在預期為檔案描述器的情況下不再接受布林值。(由 Serhiy Storchaka " +"在 :gh:`82626` 中貢獻。)" + +#: ../../deprecations/pending-removal-in-3.18.rst:9 msgid "" "The non-standard and undocumented :class:`~decimal.Decimal` format specifier " "``'N'``, which is only supported in the :mod:`!decimal` module's C " @@ -3744,6 +3821,20 @@ msgstr "" "mod:`!decimal` 模組的 C 實作中被支援,自 Python 3.13 起已被棄用。(由 Serhiy " "Storchaka 於 :gh:`89902` 中貢獻。)" +#: ../../deprecations/pending-removal-in-3.18.rst:14 +#: ../../deprecations/pending-removal-in-3.20.rst:42 +msgid "Deprecations defined by :pep:`829`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:16 +msgid "``import`` lines in :file:`{name}.pth` files are silently ignored." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:18 +#: ../../deprecations/pending-removal-in-3.20.rst:50 +msgid "(Contributed by Barry Warsaw in :gh:`148641`.)" +msgstr "(由 Barry Warsaw 在 :gh:`148641` 中貢獻。)" + #: ../../deprecations/pending-removal-in-3.19.rst:2 msgid "Pending removal in Python 3.19" msgstr "Python 3.19 中待移除的項目" @@ -3755,6 +3846,225 @@ msgid "" "Windows platforms." msgstr "" +#: ../../deprecations/pending-removal-in-3.19.rst:10 +msgid ":mod:`hashlib`:" +msgstr ":mod:`hashlib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:12 +msgid "" +"In hash function constructors such as :func:`~hashlib.new` or the direct " +"hash-named constructors such as :func:`~hashlib.md5` and :func:`~hashlib." +"sha256`, their optional initial data parameter could also be passed a " +"keyword argument named ``data=`` or ``string=`` in various :mod:`!hashlib` " +"implementations." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:18 +msgid "" +"Support for the ``string`` keyword argument name is now deprecated and " +"slated for removal in Python 3.19." +msgstr "" +"對 ``string`` 關鍵字引數名稱的支援現已被棄用,並計劃在 Python 3.19 中移除。" + +#: ../../deprecations/pending-removal-in-3.19.rst:21 +msgid "" +"Before Python 3.13, the ``string`` keyword parameter was not correctly " +"supported depending on the backend implementation of hash functions. Prefer " +"passing the initial data as a positional argument for maximum backwards " +"compatibility." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:26 +msgid ":mod:`http.cookies`:" +msgstr ":mod:`http.cookies`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:28 +msgid "" +":meth:`http.cookies.Morsel.js_output` is deprecated and will be removed in " +"Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:31 +msgid "" +":meth:`http.cookies.BaseCookie.js_output` is deprecated and will be removed " +"in Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:34 +msgid ":mod:`imaplib`:" +msgstr ":mod:`imaplib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:36 +msgid "" +"Altering :attr:`IMAP4.file ` is now deprecated and " +"slated for removal in Python 3.19. This property is now unused and changing " +"its value does not automatically close the current file." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:40 +msgid "" +"Before Python 3.14, this property was used to implement the corresponding " +"``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this " +"is no longer the case since then." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:2 +msgid "Pending removal in Python 3.20" +msgstr "Python 3.20 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.20.rst:4 +msgid "" +"Calling the ``__new__()`` method of :class:`struct.Struct` without the " +"*format* argument is deprecated and will be removed in Python 3.20. " +"Calling :meth:`~object.__init__` method on initialized :class:`~struct." +"Struct` objects is deprecated and will be removed in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:9 +msgid "" +"(Contributed by Sergey B Kirpichev and Serhiy Storchaka in :gh:`143715`.)" +msgstr "(由 Sergey B Kirpichev 和 Serhiy Storchaka 在 :gh:`143715` 中貢獻。)" + +#: ../../deprecations/pending-removal-in-3.20.rst:11 +msgid "" +"The ``__version__``, ``version`` and ``VERSION`` attributes have been " +"deprecated in these standard library modules and will be removed in Python " +"3.20. Use :py:data:`sys.version_info` instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:15 +msgid ":mod:`argparse`" +msgstr ":mod:`argparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:16 +msgid ":mod:`csv`" +msgstr ":mod:`csv`" + +#: ../../deprecations/pending-removal-in-3.20.rst:17 +msgid ":mod:`ctypes`" +msgstr ":mod:`ctypes`" + +#: ../../deprecations/pending-removal-in-3.20.rst:18 +msgid ":mod:`!ctypes.macholib`" +msgstr ":mod:`!ctypes.macholib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:19 +msgid ":mod:`decimal` (use :data:`decimal.SPEC_VERSION` instead)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:20 +msgid ":mod:`http.server`" +msgstr ":mod:`http.server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:21 +msgid ":mod:`imaplib`" +msgstr ":mod:`imaplib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:22 +msgid ":mod:`ipaddress`" +msgstr ":mod:`ipaddress`" + +#: ../../deprecations/pending-removal-in-3.20.rst:23 +msgid ":mod:`json`" +msgstr ":mod:`json`" + +#: ../../deprecations/pending-removal-in-3.20.rst:24 +msgid ":mod:`logging` (``__date__`` also deprecated)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:25 +msgid ":mod:`optparse`" +msgstr ":mod:`optparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:26 +msgid ":mod:`pickle`" +msgstr ":mod:`pickle`" + +#: ../../deprecations/pending-removal-in-3.20.rst:27 +msgid ":mod:`platform`" +msgstr ":mod:`platform`" + +#: ../../deprecations/pending-removal-in-3.20.rst:28 +msgid ":mod:`re`" +msgstr ":mod:`re`" + +#: ../../deprecations/pending-removal-in-3.20.rst:29 +msgid ":mod:`socketserver`" +msgstr ":mod:`socketserver`" + +#: ../../deprecations/pending-removal-in-3.20.rst:30 +msgid ":mod:`tabnanny`" +msgstr ":mod:`tabnanny`" + +#: ../../deprecations/pending-removal-in-3.20.rst:31 +msgid ":mod:`tarfile`" +msgstr ":mod:`tarfile`" + +#: ../../deprecations/pending-removal-in-3.20.rst:32 +msgid ":mod:`tkinter.font`" +msgstr ":mod:`tkinter.font`" + +#: ../../deprecations/pending-removal-in-3.20.rst:33 +msgid ":mod:`tkinter.ttk`" +msgstr ":mod:`tkinter.ttk`" + +#: ../../deprecations/pending-removal-in-3.20.rst:34 +msgid ":mod:`wsgiref.simple_server`" +msgstr ":mod:`wsgiref.simple_server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:35 +msgid ":mod:`xml.etree.ElementTree`" +msgstr ":mod:`xml.etree.ElementTree`" + +#: ../../deprecations/pending-removal-in-3.20.rst:36 +msgid ":mod:`!xml.sax.expatreader`" +msgstr ":mod:`!xml.sax.expatreader`" + +#: ../../deprecations/pending-removal-in-3.20.rst:37 +msgid ":mod:`xml.sax.handler`" +msgstr ":mod:`xml.sax.handler`" + +#: ../../deprecations/pending-removal-in-3.20.rst:38 +msgid ":mod:`zlib`" +msgstr ":mod:`zlib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:40 +msgid "(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)" +msgstr "(由 Hugo van Kemenade 和 Stan Ulbrych 在 :gh:`76007` 中貢獻。)" + +#: ../../deprecations/pending-removal-in-3.20.rst:44 +msgid "" +"Warnings are produced for ``import`` lines found in :file:`{name}.pth` files." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:47 +msgid "" +":file:`{name}.pth` files are no longer decoded in the locale encoding by " +"default. They **MUST** be encoded in ``utf-8-sig``." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:52 +msgid ":mod:`ast`:" +msgstr ":mod:`ast`:" + +#: ../../deprecations/pending-removal-in-3.20.rst:54 +msgid "" +"Creating instances of abstract AST nodes (such as :class:`ast.AST` or :class:" +"`!ast.expr`) is deprecated and will raise an error in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:59 +msgid "" +"It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on " +"protocol classes that were not explicitly decorated with :func:`!" +"runtime_checkable` but that inherit from a runtime-checkable protocol class. " +"This will raise a :exc:`TypeError` in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:64 +msgid "(Contributed by Bartosz Sławecki in :gh:`132604`.)" +msgstr "(由 Bartosz Sławecki 在 :gh:`132604` 中貢獻。)" + #: ../../deprecations/c-api-pending-removal-in-future.rst:2 #: ../../deprecations/pending-removal-in-future.rst:2 msgid "Pending removal in future versions" @@ -3870,14 +4180,10 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:50 msgid "" -":attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " +":attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " "instead." msgstr "" -":attr:`codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" - -#: ../../deprecations/pending-removal-in-future.rst:53 -msgid ":mod:`datetime`:" -msgstr ":mod:`datetime`:" +":attr:`!codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" #: ../../deprecations/pending-removal-in-future.rst:55 msgid "" @@ -3936,18 +4242,28 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:78 msgid "" -":mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process." +":mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process." msgstr ":mod:`os`:在多執行緒行程中呼叫 :func:`os.register_at_fork`。" #: ../../deprecations/pending-removal-in-future.rst:80 msgid "" +":mod:`os.path`: :func:`os.path.commonprefix` is deprecated, use :func:`os." +"path.commonpath` for path prefixes. The :func:`os.path.commonprefix` " +"function is being deprecated due to having a misleading name and module. The " +"function is not safe to use for path prefixes despite being included in a " +"module about path manipulation, meaning it is easy to accidentally introduce " +"path traversal vulnerabilities into Python programs by using this function." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:88 +msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." msgstr "" ":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" "實例。" -#: ../../deprecations/pending-removal-in-future.rst:83 +#: ../../deprecations/pending-removal-in-future.rst:91 msgid "" ":mod:`re`: More strict rules are now applied for numerical group references " "and group names in regular expressions. Only sequence of ASCII digits is " @@ -3959,12 +4275,7 @@ msgstr "" "有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" "包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:90 -msgid "" -":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." -msgstr ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" - -#: ../../deprecations/pending-removal-in-future.rst:92 +#: ../../deprecations/pending-removal-in-future.rst:98 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." @@ -3972,15 +4283,15 @@ msgstr "" ":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" "棄用;請改用 *onexc* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:95 +#: ../../deprecations/pending-removal-in-future.rst:101 msgid ":mod:`ssl` options and protocols:" msgstr ":mod:`ssl` 選項和協定:" -#: ../../deprecations/pending-removal-in-future.rst:97 +#: ../../deprecations/pending-removal-in-future.rst:103 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:98 +#: ../../deprecations/pending-removal-in-future.rst:104 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." @@ -3988,51 +4299,51 @@ msgstr "" ":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" "`!selected_npn_protocol` 已被棄用:請改用 ALPN。" -#: ../../deprecations/pending-removal-in-future.rst:101 +#: ../../deprecations/pending-removal-in-future.rst:107 msgid "``ssl.OP_NO_SSL*`` options" msgstr "``ssl.OP_NO_SSL*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:102 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "``ssl.OP_NO_TLS*`` options" msgstr "``ssl.OP_NO_TLS*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:103 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid "``ssl.PROTOCOL_SSLv3``" msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:104 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "``ssl.PROTOCOL_TLS``" msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:105 +#: ../../deprecations/pending-removal-in-future.rst:111 msgid "``ssl.PROTOCOL_TLSv1``" msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:106 +#: ../../deprecations/pending-removal-in-future.rst:112 msgid "``ssl.PROTOCOL_TLSv1_1``" msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:107 +#: ../../deprecations/pending-removal-in-future.rst:113 msgid "``ssl.PROTOCOL_TLSv1_2``" msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:108 +#: ../../deprecations/pending-removal-in-future.rst:114 msgid "``ssl.TLSVersion.SSLv3``" msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:109 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid "``ssl.TLSVersion.TLSv1``" msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:110 +#: ../../deprecations/pending-removal-in-future.rst:116 msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:118 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:114 +#: ../../deprecations/pending-removal-in-future.rst:120 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -4040,11 +4351,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:121 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" -#: ../../deprecations/pending-removal-in-future.rst:116 +#: ../../deprecations/pending-removal-in-future.rst:122 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -4052,7 +4363,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:118 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -4060,20 +4371,20 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:120 +#: ../../deprecations/pending-removal-in-future.rst:126 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:121 +#: ../../deprecations/pending-removal-in-future.rst:127 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:123 +#: ../../deprecations/pending-removal-in-future.rst:129 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:131 msgid "" "The internal class ``typing._UnionGenericAlias`` is no longer used to " "implement :class:`typing.Union`. To preserve compatibility with users using " @@ -4084,7 +4395,7 @@ msgstr "" "了保持與此私有類別使用者的相容性,直到至少 Python 3.17 都將提供一個相容性 " "shim。(由 Jelle Zijlstra 於 :gh:`105499` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:130 +#: ../../deprecations/pending-removal-in-future.rst:136 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -4092,64 +4403,64 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:139 msgid "" ":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " "instead" msgstr "" ":mod:`urllib.parse` 已棄用函式:請改用 :func:`~urllib.parse.urlparse`。" -#: ../../deprecations/pending-removal-in-future.rst:135 +#: ../../deprecations/pending-removal-in-future.rst:141 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:136 +#: ../../deprecations/pending-removal-in-future.rst:142 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:137 +#: ../../deprecations/pending-removal-in-future.rst:143 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:138 +#: ../../deprecations/pending-removal-in-future.rst:144 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:139 +#: ../../deprecations/pending-removal-in-future.rst:145 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:140 +#: ../../deprecations/pending-removal-in-future.rst:146 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:141 +#: ../../deprecations/pending-removal-in-future.rst:147 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:142 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:143 +#: ../../deprecations/pending-removal-in-future.rst:149 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:144 +#: ../../deprecations/pending-removal-in-future.rst:150 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:145 +#: ../../deprecations/pending-removal-in-future.rst:151 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:147 +#: ../../deprecations/pending-removal-in-future.rst:153 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:150 +#: ../../deprecations/pending-removal-in-future.rst:156 msgid "" ":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." "etree.ElementTree.Element` is deprecated. In a future release it will always " @@ -4160,7 +4471,7 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:155 +#: ../../deprecations/pending-removal-in-future.rst:161 msgid "" ":func:`sys._clear_type_cache` is deprecated: use :func:`sys." "_clear_internal_caches` instead." @@ -4168,11 +4479,11 @@ msgstr "" ":func:`sys._clear_type_cache` 已被棄用:請改用 :func:`sys." "_clear_internal_caches`。" -#: ../../whatsnew/3.13.rst:2036 +#: ../../whatsnew/3.13.rst:2037 msgid "CPython Bytecode Changes" msgstr "CPython 位元組碼變更" -#: ../../whatsnew/3.13.rst:2038 +#: ../../whatsnew/3.13.rst:2039 msgid "" "The oparg of :opcode:`YIELD_VALUE` is now ``1`` if the yield is part of a " "yield-from or await, and ``0`` otherwise. The oparg of :opcode:`RESUME` was " @@ -4181,97 +4492,97 @@ msgid "" "`111354`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2046 +#: ../../whatsnew/3.13.rst:2047 msgid "C API Changes" msgstr "C API 變更" -#: ../../whatsnew/3.13.rst:2051 +#: ../../whatsnew/3.13.rst:2052 msgid "" "Add the :ref:`PyMonitoring C API ` for generating :pep:" "`669` monitoring events:" msgstr "" -#: ../../whatsnew/3.13.rst:2054 +#: ../../whatsnew/3.13.rst:2055 msgid ":c:type:`PyMonitoringState`" msgstr ":c:type:`PyMonitoringState`" -#: ../../whatsnew/3.13.rst:2055 +#: ../../whatsnew/3.13.rst:2056 msgid ":c:func:`PyMonitoring_FirePyStartEvent`" msgstr ":c:func:`PyMonitoring_FirePyStartEvent`" -#: ../../whatsnew/3.13.rst:2056 +#: ../../whatsnew/3.13.rst:2057 msgid ":c:func:`PyMonitoring_FirePyResumeEvent`" msgstr ":c:func:`PyMonitoring_FirePyResumeEvent`" -#: ../../whatsnew/3.13.rst:2057 +#: ../../whatsnew/3.13.rst:2058 msgid ":c:func:`PyMonitoring_FirePyReturnEvent`" msgstr ":c:func:`PyMonitoring_FirePyReturnEvent`" -#: ../../whatsnew/3.13.rst:2058 +#: ../../whatsnew/3.13.rst:2059 msgid ":c:func:`PyMonitoring_FirePyYieldEvent`" msgstr ":c:func:`PyMonitoring_FirePyYieldEvent`" -#: ../../whatsnew/3.13.rst:2059 +#: ../../whatsnew/3.13.rst:2060 msgid ":c:func:`PyMonitoring_FireCallEvent`" msgstr ":c:func:`PyMonitoring_FireCallEvent`" -#: ../../whatsnew/3.13.rst:2060 +#: ../../whatsnew/3.13.rst:2061 msgid ":c:func:`PyMonitoring_FireLineEvent`" msgstr ":c:func:`PyMonitoring_FireLineEvent`" -#: ../../whatsnew/3.13.rst:2061 +#: ../../whatsnew/3.13.rst:2062 msgid ":c:func:`PyMonitoring_FireJumpEvent`" msgstr ":c:func:`PyMonitoring_FireJumpEvent`" -#: ../../whatsnew/3.13.rst:2062 +#: ../../whatsnew/3.13.rst:2063 msgid "``PyMonitoring_FireBranchEvent``" msgstr "``PyMonitoring_FireBranchEvent``" -#: ../../whatsnew/3.13.rst:2063 +#: ../../whatsnew/3.13.rst:2064 msgid ":c:func:`PyMonitoring_FireCReturnEvent`" msgstr ":c:func:`PyMonitoring_FireCReturnEvent`" -#: ../../whatsnew/3.13.rst:2064 +#: ../../whatsnew/3.13.rst:2065 msgid ":c:func:`PyMonitoring_FirePyThrowEvent`" msgstr ":c:func:`PyMonitoring_FirePyThrowEvent`" -#: ../../whatsnew/3.13.rst:2065 +#: ../../whatsnew/3.13.rst:2066 msgid ":c:func:`PyMonitoring_FireRaiseEvent`" msgstr ":c:func:`PyMonitoring_FireRaiseEvent`" -#: ../../whatsnew/3.13.rst:2066 +#: ../../whatsnew/3.13.rst:2067 msgid ":c:func:`PyMonitoring_FireCRaiseEvent`" msgstr ":c:func:`PyMonitoring_FireCRaiseEvent`" -#: ../../whatsnew/3.13.rst:2067 +#: ../../whatsnew/3.13.rst:2068 msgid ":c:func:`PyMonitoring_FireReraiseEvent`" msgstr ":c:func:`PyMonitoring_FireReraiseEvent`" -#: ../../whatsnew/3.13.rst:2068 +#: ../../whatsnew/3.13.rst:2069 msgid ":c:func:`PyMonitoring_FireExceptionHandledEvent`" msgstr ":c:func:`PyMonitoring_FireExceptionHandledEvent`" -#: ../../whatsnew/3.13.rst:2069 +#: ../../whatsnew/3.13.rst:2070 msgid ":c:func:`PyMonitoring_FirePyUnwindEvent`" msgstr ":c:func:`PyMonitoring_FirePyUnwindEvent`" -#: ../../whatsnew/3.13.rst:2070 +#: ../../whatsnew/3.13.rst:2071 msgid ":c:func:`PyMonitoring_FireStopIterationEvent`" msgstr ":c:func:`PyMonitoring_FireStopIterationEvent`" -#: ../../whatsnew/3.13.rst:2071 +#: ../../whatsnew/3.13.rst:2072 msgid ":c:func:`PyMonitoring_EnterScope`" msgstr ":c:func:`PyMonitoring_EnterScope`" -#: ../../whatsnew/3.13.rst:2072 +#: ../../whatsnew/3.13.rst:2073 msgid ":c:func:`PyMonitoring_ExitScope`" msgstr ":c:func:`PyMonitoring_ExitScope`" -#: ../../whatsnew/3.13.rst:2074 +#: ../../whatsnew/3.13.rst:2075 msgid "(Contributed by Irit Katriel in :gh:`111997`)." msgstr "(由 Irit Katriel 在 :gh:`111997` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2076 +#: ../../whatsnew/3.13.rst:2077 msgid "" "Add :c:type:`PyMutex`, a lightweight mutex that occupies a single byte, and " "the new :c:func:`PyMutex_Lock` and :c:func:`PyMutex_Unlock` functions. :c:" @@ -4279,52 +4590,52 @@ msgid "" "operation needs to block. (Contributed by Sam Gross in :gh:`108724`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2082 +#: ../../whatsnew/3.13.rst:2083 msgid "" "Add the :ref:`PyTime C API ` to provide access to system clocks:" msgstr "" -#: ../../whatsnew/3.13.rst:2084 +#: ../../whatsnew/3.13.rst:2085 msgid ":c:type:`PyTime_t`." msgstr ":c:type:`PyTime_t`。" -#: ../../whatsnew/3.13.rst:2085 +#: ../../whatsnew/3.13.rst:2086 msgid ":c:var:`PyTime_MIN` and :c:var:`PyTime_MAX`." msgstr ":c:var:`PyTime_MIN` 和 :c:var:`PyTime_MAX`。" -#: ../../whatsnew/3.13.rst:2086 +#: ../../whatsnew/3.13.rst:2087 msgid ":c:func:`PyTime_AsSecondsDouble`." msgstr ":c:func:`PyTime_AsSecondsDouble`。" -#: ../../whatsnew/3.13.rst:2087 +#: ../../whatsnew/3.13.rst:2088 msgid ":c:func:`PyTime_Monotonic`." msgstr ":c:func:`PyTime_Monotonic`。" -#: ../../whatsnew/3.13.rst:2088 +#: ../../whatsnew/3.13.rst:2089 msgid ":c:func:`PyTime_MonotonicRaw`." msgstr ":c:func:`PyTime_MonotonicRaw`。" -#: ../../whatsnew/3.13.rst:2089 +#: ../../whatsnew/3.13.rst:2090 msgid ":c:func:`PyTime_PerfCounter`." msgstr ":c:func:`PyTime_PerfCounter`。" -#: ../../whatsnew/3.13.rst:2090 +#: ../../whatsnew/3.13.rst:2091 msgid ":c:func:`PyTime_PerfCounterRaw`." msgstr ":c:func:`PyTime_PerfCounterRaw`。" -#: ../../whatsnew/3.13.rst:2091 +#: ../../whatsnew/3.13.rst:2092 msgid ":c:func:`PyTime_Time`." msgstr ":c:func:`PyTime_Time`。" -#: ../../whatsnew/3.13.rst:2092 +#: ../../whatsnew/3.13.rst:2093 msgid ":c:func:`PyTime_TimeRaw`." msgstr ":c:func:`PyTime_TimeRaw`。" -#: ../../whatsnew/3.13.rst:2094 +#: ../../whatsnew/3.13.rst:2095 msgid "(Contributed by Victor Stinner and Petr Viktorin in :gh:`110850`.)" msgstr "(由 Victor Stinner 和 Petr Viktorin 在 :gh:`110850` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2096 +#: ../../whatsnew/3.13.rst:2097 msgid "" "Add the :c:func:`PyDict_ContainsString` function with the same behavior as :" "c:func:`PyDict_Contains`, but *key* is specified as a :c:expr:`const char*` " @@ -4332,7 +4643,7 @@ msgid "" "by Victor Stinner in :gh:`108314`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2102 +#: ../../whatsnew/3.13.rst:2103 msgid "" "Add the :c:func:`PyDict_GetItemRef` and :c:func:`PyDict_GetItemStringRef` " "functions, which behave similarly to :c:func:`PyDict_GetItemWithError`, but " @@ -4342,7 +4653,7 @@ msgid "" "`106004`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2110 +#: ../../whatsnew/3.13.rst:2111 msgid "" "Add the :c:func:`PyDict_SetDefaultRef` function, which behaves similarly to :" "c:func:`PyDict_SetDefault`, but returns a :term:`strong reference` instead " @@ -4351,7 +4662,7 @@ msgid "" "dictionary. (Contributed by Sam Gross in :gh:`112066`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2118 +#: ../../whatsnew/3.13.rst:2119 msgid "" "Add the :c:func:`PyDict_Pop` and :c:func:`PyDict_PopString` functions to " "remove a key from a dictionary and optionally return the removed value. This " @@ -4360,7 +4671,7 @@ msgid "" "Victor Stinner in :gh:`111262`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2125 +#: ../../whatsnew/3.13.rst:2126 msgid "" "Add the :c:func:`PyMapping_GetOptionalItem` and :c:func:" "`PyMapping_GetOptionalItemString` functions as alternatives to :c:func:" @@ -4371,7 +4682,7 @@ msgid "" "gh:`106307`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2135 +#: ../../whatsnew/3.13.rst:2136 msgid "" "Add the :c:func:`PyObject_GetOptionalAttr` and :c:func:" "`PyObject_GetOptionalAttrString` functions as alternatives to :c:func:" @@ -4382,37 +4693,37 @@ msgid "" "Serhiy Storchaka in :gh:`106521`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2145 +#: ../../whatsnew/3.13.rst:2146 msgid "" "Add the :c:func:`PyErr_FormatUnraisable` function as an extension to :c:func:" "`PyErr_WriteUnraisable` that allows customizing the warning message. " "(Contributed by Serhiy Storchaka in :gh:`108082`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2150 +#: ../../whatsnew/3.13.rst:2151 msgid "" "Add new functions that return a :term:`strong reference` instead of a :term:" "`borrowed reference` for frame locals, globals, and builtins, as part of :" "ref:`PEP 667 `:" msgstr "" -#: ../../whatsnew/3.13.rst:2154 +#: ../../whatsnew/3.13.rst:2155 msgid ":c:func:`PyEval_GetFrameBuiltins` replaces :c:func:`PyEval_GetBuiltins`" msgstr ":c:func:`PyEval_GetFrameBuiltins` 取代 :c:func:`PyEval_GetBuiltins`" -#: ../../whatsnew/3.13.rst:2155 +#: ../../whatsnew/3.13.rst:2156 msgid ":c:func:`PyEval_GetFrameGlobals` replaces :c:func:`PyEval_GetGlobals`" msgstr ":c:func:`PyEval_GetFrameGlobals` 取代 :c:func:`PyEval_GetGlobals`" -#: ../../whatsnew/3.13.rst:2156 +#: ../../whatsnew/3.13.rst:2157 msgid ":c:func:`PyEval_GetFrameLocals` replaces :c:func:`PyEval_GetLocals`" msgstr ":c:func:`PyEval_GetFrameLocals` 取代 :c:func:`PyEval_GetLocals`" -#: ../../whatsnew/3.13.rst:2158 +#: ../../whatsnew/3.13.rst:2159 msgid "(Contributed by Mark Shannon and Tian Gao in :gh:`74929`.)" msgstr "(由 Mark Shannon 和 Tian Gao 在 :gh:`74929` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2160 +#: ../../whatsnew/3.13.rst:2161 msgid "" "Add the :c:func:`Py_GetConstant` and :c:func:`Py_GetConstantBorrowed` " "functions to get :term:`strong ` or :term:`borrowed " @@ -4421,7 +4732,7 @@ msgid "" "constant zero. (Contributed by Victor Stinner in :gh:`115754`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2167 +#: ../../whatsnew/3.13.rst:2168 msgid "" "Add the :c:func:`PyImport_AddModuleRef` function as a replacement for :c:" "func:`PyImport_AddModule` that returns a :term:`strong reference` instead of " @@ -4429,35 +4740,35 @@ msgid "" "`105922`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2172 +#: ../../whatsnew/3.13.rst:2173 msgid "" "Add the :c:func:`Py_IsFinalizing` function to check whether the main Python " "interpreter is :term:`shutting down `. (Contributed by " "Victor Stinner in :gh:`108014`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2177 +#: ../../whatsnew/3.13.rst:2178 msgid "" "Add the :c:func:`PyList_GetItemRef` function as a replacement for :c:func:" "`PyList_GetItem` that returns a :term:`strong reference` instead of a :term:" "`borrowed reference`. (Contributed by Sam Gross in :gh:`114329`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2182 +#: ../../whatsnew/3.13.rst:2183 msgid "" "Add the :c:func:`PyList_Extend` and :c:func:`PyList_Clear` functions, " "mirroring the Python :meth:`list.extend` and :meth:`list.clear` methods. " "(Contributed by Victor Stinner in :gh:`111138`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2186 +#: ../../whatsnew/3.13.rst:2187 msgid "" "Add the :c:func:`PyLong_AsInt` function. It behaves similarly to :c:func:" "`PyLong_AsLong`, but stores the result in a C :c:expr:`int` instead of a C :" "c:expr:`long`. (Contributed by Victor Stinner in :gh:`108014`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2191 +#: ../../whatsnew/3.13.rst:2192 msgid "" "Add the :c:func:`PyLong_AsNativeBytes`, :c:func:`PyLong_FromNativeBytes`, " "and :c:func:`PyLong_FromUnsignedNativeBytes` functions to simplify " @@ -4465,27 +4776,27 @@ msgid "" "(Contributed by Steve Dower in :gh:`111140`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2197 +#: ../../whatsnew/3.13.rst:2198 msgid "" "Add :c:func:`PyModule_Add` function, which is similar to :c:func:" "`PyModule_AddObjectRef` and :c:func:`PyModule_AddObject`, but always steals " "a reference to the value. (Contributed by Serhiy Storchaka in :gh:`86493`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2202 +#: ../../whatsnew/3.13.rst:2203 msgid "" "Add the :c:func:`PyObject_GenericHash` function that implements the default " "hashing function of a Python object. (Contributed by Serhiy Storchaka in :gh:" "`113024`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2206 +#: ../../whatsnew/3.13.rst:2207 msgid "" "Add the :c:func:`Py_HashPointer` function to hash a raw pointer. " "(Contributed by Victor Stinner in :gh:`111545`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2209 +#: ../../whatsnew/3.13.rst:2210 msgid "" "Add the :c:func:`PyObject_VisitManagedDict` and :c:func:" "`PyObject_ClearManagedDict` functions. which must be called by the traverse " @@ -4494,7 +4805,7 @@ msgid "" "with Python 3.11 and 3.12. (Contributed by Victor Stinner in :gh:`107073`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2217 +#: ../../whatsnew/3.13.rst:2218 msgid "" "Add the :c:func:`PyRefTracer_SetTracer` and :c:func:`PyRefTracer_GetTracer` " "functions, which enable tracking object creation and destruction in the same " @@ -4502,14 +4813,14 @@ msgid "" "in :gh:`93502`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2223 +#: ../../whatsnew/3.13.rst:2224 msgid "" "Add the :c:func:`PySys_AuditTuple` function as an alternative to :c:func:" "`PySys_Audit` that takes event arguments as a Python :class:`tuple` object. " "(Contributed by Victor Stinner in :gh:`85283`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2228 +#: ../../whatsnew/3.13.rst:2229 msgid "" "Add the :c:func:`PyThreadState_GetUnchecked()` function as an alternative " "to :c:func:`PyThreadState_Get()` that doesn't kill the process with a fatal " @@ -4517,7 +4828,7 @@ msgid "" "result is ``NULL``. (Contributed by Victor Stinner in :gh:`108867`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2234 +#: ../../whatsnew/3.13.rst:2235 msgid "" "Add the :c:func:`PyType_GetFullyQualifiedName` function to get the type's " "fully qualified name. The module name is prepended if :attr:`type." @@ -4525,14 +4836,14 @@ msgid "" "``'__main__'``. (Contributed by Victor Stinner in :gh:`111696`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2240 +#: ../../whatsnew/3.13.rst:2241 msgid "" "Add the :c:func:`PyType_GetModuleName` function to get the type's module " "name. This is equivalent to getting the :attr:`type.__module__` attribute. " "(Contributed by Eric Snow and Victor Stinner in :gh:`111696`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2245 +#: ../../whatsnew/3.13.rst:2246 msgid "" "Add the :c:func:`PyUnicode_EqualToUTF8AndSize` and :c:func:" "`PyUnicode_EqualToUTF8` functions to compare a Unicode object with a :c:expr:" @@ -4541,24 +4852,27 @@ msgid "" "Storchaka in :gh:`110289`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2252 +#: ../../whatsnew/3.13.rst:2253 msgid "" -"Add the :c:func:`PyWeakref_GetRef` function as an alternative to :c:func:" -"`PyWeakref_GetObject` that returns a :term:`strong reference` or ``NULL`` if " +"Add the :c:func:`PyWeakref_GetRef` function as an alternative to :c:func:`!" +"PyWeakref_GetObject` that returns a :term:`strong reference` or ``NULL`` if " "the referent is no longer live. (Contributed by Victor Stinner in :gh:" "`105927`.)" msgstr "" +"新增 :c:func:`PyWeakref_GetRef` 函式作為 :c:func:`!PyWeakref_GetObject` 的替" +"代方案,它會回傳一個\\ :term:`強參照 `,或在被參照物件已不" +"再存活時回傳 ``NULL``。(由 Victor Stinner 在 :gh:`105927` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2258 +#: ../../whatsnew/3.13.rst:2259 msgid "Add fixed variants of functions which silently ignore errors:" msgstr "" -#: ../../whatsnew/3.13.rst:2260 +#: ../../whatsnew/3.13.rst:2261 msgid "" ":c:func:`PyObject_HasAttrWithError` replaces :c:func:`PyObject_HasAttr`." msgstr ":c:func:`PyObject_HasAttrWithError` 取代 :c:func:`PyObject_HasAttr`。" -#: ../../whatsnew/3.13.rst:2261 +#: ../../whatsnew/3.13.rst:2262 msgid "" ":c:func:`PyObject_HasAttrStringWithError` replaces :c:func:" "`PyObject_HasAttrString`." @@ -4566,12 +4880,12 @@ msgstr "" ":c:func:`PyObject_HasAttrStringWithError` 取代 :c:func:" "`PyObject_HasAttrString`。" -#: ../../whatsnew/3.13.rst:2263 +#: ../../whatsnew/3.13.rst:2264 msgid "" ":c:func:`PyMapping_HasKeyWithError` replaces :c:func:`PyMapping_HasKey`." msgstr ":c:func:`PyMapping_HasKeyWithError` 取代 :c:func:`PyMapping_HasKey`。" -#: ../../whatsnew/3.13.rst:2264 +#: ../../whatsnew/3.13.rst:2265 msgid "" ":c:func:`PyMapping_HasKeyStringWithError` replaces :c:func:" "`PyMapping_HasKeyString`." @@ -4579,21 +4893,21 @@ msgstr "" ":c:func:`PyMapping_HasKeyStringWithError` 取代 :c:func:" "`PyMapping_HasKeyString`。" -#: ../../whatsnew/3.13.rst:2267 +#: ../../whatsnew/3.13.rst:2268 msgid "" "The new functions return ``-1`` for errors and the standard ``1`` for true " "and ``0`` for false." msgstr "" -#: ../../whatsnew/3.13.rst:2270 +#: ../../whatsnew/3.13.rst:2271 msgid "(Contributed by Serhiy Storchaka in :gh:`108511`.)" msgstr "(由 Serhiy Storchaka 在 :gh:`108511` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2274 +#: ../../whatsnew/3.13.rst:2275 msgid "Changed C APIs" msgstr "" -#: ../../whatsnew/3.13.rst:2276 +#: ../../whatsnew/3.13.rst:2277 msgid "" "The *keywords* parameter of :c:func:`PyArg_ParseTupleAndKeywords` and :c:" "func:`PyArg_VaParseTupleAndKeywords` now has type :c:expr:`char * const *` " @@ -4606,20 +4920,20 @@ msgid "" "`65210`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2288 +#: ../../whatsnew/3.13.rst:2289 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` now supports non-ASCII keyword " "parameter names. (Contributed by Serhiy Storchaka in :gh:`110815`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2292 +#: ../../whatsnew/3.13.rst:2293 msgid "" "The :c:func:`!PyCode_GetFirstFree` function is now unstable API and is now " "named :c:func:`PyUnstable_Code_GetFirstFree`. (Contributed by Bogdan " "Romanyuk in :gh:`115781`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2296 +#: ../../whatsnew/3.13.rst:2297 msgid "" "The :c:func:`PyDict_GetItem`, :c:func:`PyDict_GetItemString`, :c:func:" "`PyMapping_HasKey`, :c:func:`PyMapping_HasKeyString`, :c:func:" @@ -4630,35 +4944,35 @@ msgid "" "documentation. (Contributed by Serhiy Storchaka in :gh:`106672`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2305 +#: ../../whatsnew/3.13.rst:2306 msgid "" "Add support for the ``%T``, ``%#T``, ``%N`` and ``%#N`` formats to :c:func:" "`PyUnicode_FromFormat`:" msgstr "" -#: ../../whatsnew/3.13.rst:2308 +#: ../../whatsnew/3.13.rst:2309 msgid "``%T``: Get the fully qualified name of an object type" msgstr "" -#: ../../whatsnew/3.13.rst:2309 +#: ../../whatsnew/3.13.rst:2310 msgid "``%#T``: As above, but use a colon as the separator" msgstr "" -#: ../../whatsnew/3.13.rst:2310 +#: ../../whatsnew/3.13.rst:2311 msgid "``%N``: Get the fully qualified name of a type" msgstr "" -#: ../../whatsnew/3.13.rst:2311 +#: ../../whatsnew/3.13.rst:2312 msgid "``%#N``: As above, but use a colon as the separator" msgstr "" -#: ../../whatsnew/3.13.rst:2313 +#: ../../whatsnew/3.13.rst:2314 msgid "" "See :pep:`737` for more information. (Contributed by Victor Stinner in :gh:" "`111696`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2316 +#: ../../whatsnew/3.13.rst:2317 msgid "" "You no longer have to define the ``PY_SSIZE_T_CLEAN`` macro before " "including :file:`Python.h` when using ``#`` formats in :ref:`format codes " @@ -4667,7 +4981,7 @@ msgid "" "`104922`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2322 +#: ../../whatsnew/3.13.rst:2323 msgid "" "If Python is built in :ref:`debug mode ` or :option:`with " "assertions <--with-assertions>`, :c:func:`PyTuple_SET_ITEM` and :c:func:" @@ -4675,58 +4989,58 @@ msgid "" "(Contributed by Victor Stinner in :gh:`106168`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2330 +#: ../../whatsnew/3.13.rst:2331 msgid "Limited C API Changes" msgstr "" -#: ../../whatsnew/3.13.rst:2332 +#: ../../whatsnew/3.13.rst:2333 msgid "The following functions are now included in the Limited C API:" msgstr "" -#: ../../whatsnew/3.13.rst:2334 +#: ../../whatsnew/3.13.rst:2335 msgid ":c:func:`PyMem_RawMalloc`" msgstr ":c:func:`PyMem_RawMalloc`" -#: ../../whatsnew/3.13.rst:2335 +#: ../../whatsnew/3.13.rst:2336 msgid ":c:func:`PyMem_RawCalloc`" msgstr ":c:func:`PyMem_RawCalloc`" -#: ../../whatsnew/3.13.rst:2336 +#: ../../whatsnew/3.13.rst:2337 msgid ":c:func:`PyMem_RawRealloc`" msgstr ":c:func:`PyMem_RawRealloc`" -#: ../../whatsnew/3.13.rst:2337 +#: ../../whatsnew/3.13.rst:2338 msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../whatsnew/3.13.rst:2338 +#: ../../whatsnew/3.13.rst:2339 msgid ":c:func:`PySys_Audit`" msgstr ":c:func:`PySys_Audit`" -#: ../../whatsnew/3.13.rst:2339 +#: ../../whatsnew/3.13.rst:2340 msgid ":c:func:`PySys_AuditTuple`" msgstr ":c:func:`PySys_AuditTuple`" -#: ../../whatsnew/3.13.rst:2340 +#: ../../whatsnew/3.13.rst:2341 msgid ":c:func:`PyType_GetModuleByDef`" msgstr ":c:func:`PyType_GetModuleByDef`" -#: ../../whatsnew/3.13.rst:2342 +#: ../../whatsnew/3.13.rst:2343 msgid "(Contributed by Victor Stinner in :gh:`85283` and :gh:`116936`.)" msgstr "(由 Victor Stinner 貢獻於 :gh:`85283` 和 :gh:`116936`。)" -#: ../../whatsnew/3.13.rst:2344 +#: ../../whatsnew/3.13.rst:2345 msgid "" "Python built with :option:`--with-trace-refs` (tracing references) now " "supports the :ref:`Limited API `. (Contributed by Victor " "Stinner in :gh:`108634`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2350 +#: ../../whatsnew/3.13.rst:2351 msgid "Removed C APIs" msgstr "移除的 C API" -#: ../../whatsnew/3.13.rst:2352 +#: ../../whatsnew/3.13.rst:2353 msgid "" "Remove several functions, macros, variables, etc with names prefixed by " "``_Py`` or ``_PY`` (which are considered private). If your project is " @@ -4736,13 +5050,13 @@ msgid "" "Victor Stinner. (Contributed by Victor Stinner in :gh:`106320`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2360 +#: ../../whatsnew/3.13.rst:2361 msgid "" "Remove old buffer protocols deprecated in Python 3.0. Use :ref:" "`bufferobjects` instead." msgstr "" -#: ../../whatsnew/3.13.rst:2363 +#: ../../whatsnew/3.13.rst:2364 msgid "" ":c:func:`!PyObject_CheckReadBuffer`: Use :c:func:`PyObject_CheckBuffer` to " "test whether the object supports the buffer protocol. Note that :c:func:" @@ -4751,7 +5065,7 @@ msgid "" "example of :c:func:`PyObject_GetBuffer`." msgstr "" -#: ../../whatsnew/3.13.rst:2371 +#: ../../whatsnew/3.13.rst:2372 msgid "" ":c:func:`!PyObject_AsCharBuffer`, :c:func:`!PyObject_AsReadBuffer`: Use :c:" "func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release` instead:" @@ -4759,7 +5073,7 @@ msgstr "" ":c:func:`!PyObject_AsCharBuffer`、:c:func:`!PyObject_AsReadBuffer`:請改用 :" "c:func:`PyObject_GetBuffer` 和 :c:func:`PyBuffer_Release`。" -#: ../../whatsnew/3.13.rst:2374 +#: ../../whatsnew/3.13.rst:2375 msgid "" "Py_buffer view;\n" "if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) < 0) {\n" @@ -4770,7 +5084,7 @@ msgid "" "PyBuffer_Release(&view);" msgstr "" -#: ../../whatsnew/3.13.rst:2384 +#: ../../whatsnew/3.13.rst:2385 msgid "" ":c:func:`!PyObject_AsWriteBuffer`: Use :c:func:`PyObject_GetBuffer` and :c:" "func:`PyBuffer_Release` instead:" @@ -4778,7 +5092,7 @@ msgstr "" ":c:func:`!PyObject_AsWriteBuffer`:請改用 :c:func:`PyObject_GetBuffer` 和 :c:" "func:`PyBuffer_Release`。" -#: ../../whatsnew/3.13.rst:2387 +#: ../../whatsnew/3.13.rst:2388 msgid "" "Py_buffer view;\n" "if (PyObject_GetBuffer(obj, &view, PyBUF_WRITABLE) < 0) {\n" @@ -4788,15 +5102,15 @@ msgid "" "PyBuffer_Release(&view);" msgstr "" -#: ../../whatsnew/3.13.rst:2396 +#: ../../whatsnew/3.13.rst:2397 msgid "(Contributed by Inada Naoki in :gh:`85275`.)" msgstr "(由 Inada Naoki 貢獻於 :gh:`85275`。)" -#: ../../whatsnew/3.13.rst:2398 +#: ../../whatsnew/3.13.rst:2399 msgid "Remove various functions deprecated in Python 3.9:" msgstr "" -#: ../../whatsnew/3.13.rst:2400 +#: ../../whatsnew/3.13.rst:2401 msgid "" ":c:func:`!PyEval_CallObject`, :c:func:`!PyEval_CallObjectWithKeywords`: Use :" "c:func:`PyObject_CallNoArgs` or :c:func:`PyObject_Call` instead." @@ -4804,7 +5118,7 @@ msgstr "" ":c:func:`!PyEval_CallObject`、:c:func:`!PyEval_CallObjectWithKeywords`:請改" "用 :c:func:`PyObject_CallNoArgs` 或 :c:func:`PyObject_Call`。" -#: ../../whatsnew/3.13.rst:2405 +#: ../../whatsnew/3.13.rst:2406 msgid "" "In :c:func:`PyObject_Call`, positional arguments must be a :class:`tuple` " "and must not be ``NULL``, and keyword arguments must be a :class:`dict` or " @@ -4815,33 +5129,33 @@ msgid "" "`PyTuple_New(0) `." msgstr "" -#: ../../whatsnew/3.13.rst:2415 +#: ../../whatsnew/3.13.rst:2416 msgid "" ":c:func:`!PyEval_CallFunction`: Use :c:func:`PyObject_CallFunction` instead." msgstr "" ":c:func:`!PyEval_CallFunction`:請改用 :c:func:`PyObject_CallFunction`。" -#: ../../whatsnew/3.13.rst:2417 +#: ../../whatsnew/3.13.rst:2418 msgid "" ":c:func:`!PyEval_CallMethod`: Use :c:func:`PyObject_CallMethod` instead." msgstr ":c:func:`!PyEval_CallMethod`:請改用 :c:func:`PyObject_CallMethod`。" -#: ../../whatsnew/3.13.rst:2419 +#: ../../whatsnew/3.13.rst:2420 msgid ":c:func:`!PyCFunction_Call`: Use :c:func:`PyObject_Call` instead." msgstr ":c:func:`!PyCFunction_Call`:請改用 :c:func:`PyObject_Call`。" -#: ../../whatsnew/3.13.rst:2422 +#: ../../whatsnew/3.13.rst:2423 msgid "(Contributed by Victor Stinner in :gh:`105107`.)" msgstr "(由 Victor Stinner 貢獻於 :gh:`105107`。)" -#: ../../whatsnew/3.13.rst:2424 +#: ../../whatsnew/3.13.rst:2425 msgid "" "Remove the following old functions to configure the Python initialization, " "deprecated in Python 3.11:" msgstr "" "移除以下設定 Python 初始化的舊函式,這些函式在 Python 3.11 中已被棄用:" -#: ../../whatsnew/3.13.rst:2427 +#: ../../whatsnew/3.13.rst:2428 msgid "" ":c:func:`!PySys_AddWarnOptionUnicode`: Use :c:member:`PyConfig.warnoptions` " "instead." @@ -4849,36 +5163,36 @@ msgstr "" ":c:func:`!PySys_AddWarnOptionUnicode`:請改用 :c:member:`PyConfig." "warnoptions`。" -#: ../../whatsnew/3.13.rst:2429 +#: ../../whatsnew/3.13.rst:2430 msgid "" ":c:func:`!PySys_AddWarnOption`: Use :c:member:`PyConfig.warnoptions` instead." msgstr "" ":c:func:`!PySys_AddWarnOption`:請改用 :c:member:`PyConfig.warnoptions`。" -#: ../../whatsnew/3.13.rst:2431 +#: ../../whatsnew/3.13.rst:2432 msgid ":c:func:`!PySys_AddXOption`: Use :c:member:`PyConfig.xoptions` instead." msgstr ":c:func:`!PySys_AddXOption`:請改用 :c:member:`PyConfig.xoptions`。" -#: ../../whatsnew/3.13.rst:2433 +#: ../../whatsnew/3.13.rst:2434 msgid "" ":c:func:`!PySys_HasWarnOptions`: Use :c:member:`PyConfig.xoptions` instead." msgstr "" ":c:func:`!PySys_HasWarnOptions`:請改用 :c:member:`PyConfig.xoptions`。" -#: ../../whatsnew/3.13.rst:2435 +#: ../../whatsnew/3.13.rst:2436 msgid "" ":c:func:`!PySys_SetPath`: Set :c:member:`PyConfig.module_search_paths` " "instead." msgstr "" ":c:func:`!PySys_SetPath`:請改用 :c:member:`PyConfig.module_search_paths`。" -#: ../../whatsnew/3.13.rst:2437 +#: ../../whatsnew/3.13.rst:2438 msgid "" ":c:func:`!Py_SetPath`: Set :c:member:`PyConfig.module_search_paths` instead." msgstr "" ":c:func:`!Py_SetPath`:請改用 :c:member:`PyConfig.module_search_paths`。" -#: ../../whatsnew/3.13.rst:2439 +#: ../../whatsnew/3.13.rst:2440 msgid "" ":c:func:`!Py_SetStandardStreamEncoding`: Set :c:member:`PyConfig." "stdio_encoding` instead, and set also maybe :c:member:`PyConfig." @@ -4888,14 +5202,14 @@ msgstr "" "stdio_encoding` 並設定可能的 :c:member:`PyConfig.legacy_windows_stdio`\\ " "(在 Windows 上)。" -#: ../../whatsnew/3.13.rst:2442 +#: ../../whatsnew/3.13.rst:2443 msgid "" ":c:func:`!_Py_SetProgramFullPath`: Set :c:member:`PyConfig.executable` " "instead." msgstr "" ":c:func:`!_Py_SetProgramFullPath`:請改用 :c:member:`PyConfig.executable`。" -#: ../../whatsnew/3.13.rst:2445 +#: ../../whatsnew/3.13.rst:2446 msgid "" "Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization " "Configuration ` instead (:pep:`587`), added to Python 3.8. " @@ -4905,7 +5219,7 @@ msgstr "" "(:pep:`587`),這是在 Python 3.8 中新增的。(由 Victor Stinner 於 :gh:" "`105145` 貢獻。)" -#: ../../whatsnew/3.13.rst:2449 +#: ../../whatsnew/3.13.rst:2450 msgid "" "Remove :c:func:`!PyEval_AcquireLock` and :c:func:`!PyEval_ReleaseLock` " "functions, deprecated in Python 3.2. They didn't update the current thread " @@ -4915,25 +5229,25 @@ msgstr "" "些函式在 Python 3.2 中已被廢棄。它們不會更新目前的執行緒狀態。可以用以下函式" "取代:" -#: ../../whatsnew/3.13.rst:2454 +#: ../../whatsnew/3.13.rst:2455 msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`;" msgstr ":c:func:`PyEval_SaveThread` 和 :c:func:`PyEval_RestoreThread`;" -#: ../../whatsnew/3.13.rst:2455 +#: ../../whatsnew/3.13.rst:2456 msgid "" "low-level :c:func:`PyEval_AcquireThread` and :c:func:`PyEval_RestoreThread`;" msgstr "" "低階的 :c:func:`PyEval_AcquireThread` 和 :c:func:`PyEval_RestoreThread`;" -#: ../../whatsnew/3.13.rst:2456 +#: ../../whatsnew/3.13.rst:2457 msgid "or :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`." msgstr "或 :c:func:`PyGILState_Ensure` 與 :c:func:`PyGILState_Release`。" -#: ../../whatsnew/3.13.rst:2458 +#: ../../whatsnew/3.13.rst:2459 msgid "(Contributed by Victor Stinner in :gh:`105182`.)" msgstr "(由 Victor Stinner 貢獻於 :gh:`105182`。)" -#: ../../whatsnew/3.13.rst:2460 +#: ../../whatsnew/3.13.rst:2461 msgid "" "Remove the :c:func:`!PyEval_ThreadsInitialized` function, deprecated in " "Python 3.9. Since Python 3.7, :c:func:`!Py_Initialize` always creates the " @@ -4946,7 +5260,7 @@ msgstr "" "PyEval_InitThreads` 不會有任何作用,而 :c:func:`!PyEval_ThreadsInitialized` " "總是會回傳非零值。(由 Victor Stinner 於 :gh:`105182` 貢獻。)" -#: ../../whatsnew/3.13.rst:2467 +#: ../../whatsnew/3.13.rst:2468 msgid "" "Remove the :c:func:`!_PyInterpreterState_Get` alias to :c:func:" "`PyInterpreterState_Get()` which was kept for backward compatibility with " @@ -4960,7 +5274,7 @@ msgstr "" "得 :c:func:`PyInterpreterState_Get()`。(由 Victor Stinner 於 :gh:`106320` 貢" "獻。)" -#: ../../whatsnew/3.13.rst:2474 +#: ../../whatsnew/3.13.rst:2475 msgid "" "Remove the private :c:func:`!_PyObject_FastCall` function: use :c:func:`!" "PyObject_Vectorcall` which is available since Python 3.8 (:pep:`590`). " @@ -4970,7 +5284,7 @@ msgstr "" "c:func:`!PyObject_Vectorcall` 函式(:pep:`590`)。(由 Victor Stinner 於 :gh:" "`106023` 貢獻。)" -#: ../../whatsnew/3.13.rst:2479 +#: ../../whatsnew/3.13.rst:2480 msgid "" "Remove the ``cpython/pytime.h`` header file, which only contained private " "functions. (Contributed by Victor Stinner in :gh:`106316`.)" @@ -4978,13 +5292,13 @@ msgstr "" "移除只包含私有函式的 ``cpython/pytime.h`` 標頭檔。(由 Victor Stinner 於 :gh:" "`106316` 貢獻。)" -#: ../../whatsnew/3.13.rst:2483 +#: ../../whatsnew/3.13.rst:2484 msgid "" "Remove the undocumented ``PY_TIMEOUT_MAX`` constant from the limited C API. " "(Contributed by Victor Stinner in :gh:`110014`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2486 +#: ../../whatsnew/3.13.rst:2487 msgid "" "Remove the old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and " "``Py_TRASHCAN_SAFE_END``. Replace both with the new macros " @@ -4995,56 +5309,56 @@ msgstr "" "將兩者都替換為新的巨集 ``Py_TRASHCAN_BEGIN`` 和 ``Py_TRASHCAN_END``。(由 " "Irit Katriel 在 :gh:`105111` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2493 +#: ../../whatsnew/3.13.rst:2494 msgid "Deprecated C APIs" msgstr "器用的 C API" -#: ../../whatsnew/3.13.rst:2495 +#: ../../whatsnew/3.13.rst:2496 msgid "Deprecate old Python initialization functions:" msgstr "棄用舊的 Python 初始化函式:" -#: ../../whatsnew/3.13.rst:2497 -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:62 +#: ../../whatsnew/3.13.rst:2498 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 msgid "" -":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" +":c:func:`!PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" -":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" -"data:`!warnings.filters`。" +":c:func:`!PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` " +"和 :data:`!warnings.filters`。" -#: ../../whatsnew/3.13.rst:2499 -msgid ":c:func:`Py_GetExecPrefix`: Get :data:`sys.exec_prefix` instead." -msgstr ":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.exec_prefix`。" +#: ../../whatsnew/3.13.rst:2500 +msgid ":c:func:`!Py_GetExecPrefix`: Get :data:`sys.exec_prefix` instead." +msgstr ":c:func:`!Py_GetExecPrefix`:請改用 :data:`sys.exec_prefix`。" -#: ../../whatsnew/3.13.rst:2501 -msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." -msgstr ":c:func:`Py_GetPath`:請改用 :data:`sys.path`。" +#: ../../whatsnew/3.13.rst:2502 +msgid ":c:func:`!Py_GetPath`: Get :data:`sys.path` instead." +msgstr ":c:func:`!Py_GetPath`:請改用 :data:`sys.path`。" -#: ../../whatsnew/3.13.rst:2503 -msgid ":c:func:`Py_GetPrefix`: Get :data:`sys.prefix` instead." -msgstr ":c:func:`Py_GetPrefix`:請改用 :data:`sys.prefix`。" +#: ../../whatsnew/3.13.rst:2504 +msgid ":c:func:`!Py_GetPrefix`: Get :data:`sys.prefix` instead." +msgstr ":c:func:`!Py_GetPrefix`:請改用 :data:`sys.prefix`。" -#: ../../whatsnew/3.13.rst:2505 -msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." -msgstr ":c:func:`Py_GetProgramFullPath`:請改用 :data:`sys.executable`。" +#: ../../whatsnew/3.13.rst:2506 +msgid ":c:func:`!Py_GetProgramFullPath`: Get :data:`sys.executable` instead." +msgstr ":c:func:`!Py_GetProgramFullPath`:請改用 :data:`sys.executable`。" -#: ../../whatsnew/3.13.rst:2507 -msgid ":c:func:`Py_GetProgramName`: Get :data:`sys.executable` instead." -msgstr ":c:func:`Py_GetProgramName`:請改用 :data:`sys.executable`。" +#: ../../whatsnew/3.13.rst:2508 +msgid ":c:func:`!Py_GetProgramName`: Get :data:`sys.executable` instead." +msgstr ":c:func:`!Py_GetProgramName`:請改用 :data:`sys.executable`。" -#: ../../whatsnew/3.13.rst:2509 +#: ../../whatsnew/3.13.rst:2510 msgid "" -":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" +":c:func:`!Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" "`PYTHONHOME` environment variable instead." msgstr "" -":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" -"`PYTHONHOME` 環境變數。" +":c:func:`!Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` " +"或 :envvar:`PYTHONHOME` 環境變數。" -#: ../../whatsnew/3.13.rst:2513 +#: ../../whatsnew/3.13.rst:2514 msgid "(Contributed by Victor Stinner in :gh:`105145`.)" msgstr "(由 Victor Stinner 在 :gh:`105145` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2515 +#: ../../whatsnew/3.13.rst:2516 msgid "" ":term:`Soft deprecate ` the :c:func:`PyEval_GetBuiltins`, :" "c:func:`PyEval_GetGlobals`, and :c:func:`PyEval_GetLocals` functions, which " @@ -5055,17 +5369,17 @@ msgstr "" "\\ :term:`借用參照 `。(作為 :pep:`667` 一部分的軟性棄" "用。)" -#: ../../whatsnew/3.13.rst:2521 +#: ../../whatsnew/3.13.rst:2522 msgid "" -"Deprecate the :c:func:`PyImport_ImportModuleNoBlock` function, which is just " -"an alias to :c:func:`PyImport_ImportModule` since Python 3.3. (Contributed " -"by Victor Stinner in :gh:`105396`.)" +"Deprecate the :c:func:`!PyImport_ImportModuleNoBlock` function, which is " +"just an alias to :c:func:`PyImport_ImportModule` since Python 3.3. " +"(Contributed by Victor Stinner in :gh:`105396`.)" msgstr "" -"棄用 :c:func:`PyImport_ImportModuleNoBlock` 函式,這只是自 Python 3.3 起的 :" -"c:func:`PyImport_ImportModule` 的別名。(由 Victor Stinner 在 :gh:`105396` 中" -"貢獻。)" +"棄用 :c:func:`!PyImport_ImportModuleNoBlock` 函式,這只是自 Python 3.3 起" +"的 :c:func:`PyImport_ImportModule` 的別名。(由 Victor Stinner " +"在 :gh:`105396` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2525 +#: ../../whatsnew/3.13.rst:2526 msgid "" ":term:`Soft deprecate ` the :c:func:`PyModule_AddObject` " "function. It should be replaced with :c:func:`PyModule_Add` or :c:func:" @@ -5075,7 +5389,7 @@ msgstr "" "用 :c:func:`PyModule_Add` 或 :c:func:`PyModule_AddObjectRef`。(由 Serhiy " "Storchaka 在 :gh:`86493` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2531 +#: ../../whatsnew/3.13.rst:2532 msgid "" "Deprecate the old ``Py_UNICODE`` and ``PY_UNICODE_TYPE`` types and the :c:" "macro:`!Py_UNICODE_WIDE` define. Use the :c:type:`wchar_t` type directly " @@ -5088,21 +5402,21 @@ msgstr "" "``Py_UNICODE`` 和 ``PY_UNICODE_TYPE`` 只是 :c:type:`!wchar_t` 的別名。(由 " "Victor Stinner 在 :gh:`105156` 中貢獻。)" -#: ../../whatsnew/3.13.rst:2538 +#: ../../whatsnew/3.13.rst:2539 msgid "" -"Deprecate the :c:func:`PyWeakref_GetObject` and :c:func:" -"`PyWeakref_GET_OBJECT` functions, which return a :term:`borrowed reference`. " +"Deprecate the :c:func:`!PyWeakref_GetObject` and :c:func:`!" +"PyWeakref_GET_OBJECT` functions, which return a :term:`borrowed reference`. " "Replace them with the new :c:func:`PyWeakref_GetRef` function, which returns " "a :term:`strong reference`. The `pythoncapi-compat project`_ can be used to " "get :c:func:`PyWeakref_GetRef` on Python 3.12 and older. (Contributed by " "Victor Stinner in :gh:`105927`.)" msgstr "" -"棄用 :c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT` 函式,這" -"些函式會回傳一個\\ :term:`借用參照 `。請改用新的 :c:func:" -"`PyWeakref_GetRef` 函式,這個函式會回傳一個\\ :term:`強參照 `。`pythoncapi-compat 專案`_\\ 可以用於在 Python 3.12 和更舊的版本" -"中取得 :c:func:`PyWeakref_GetRef`。(由 Victor Stinner 在 :gh:`105927` 中貢" -"獻。)" +"棄用 :c:func:`!PyWeakref_GetObject` 和 :c:func:`!PyWeakref_GET_OBJECT` 函式," +"這些函式會回傳一個\\ :term:`借用參照 `。請改用新" +"的 :c:func:`PyWeakref_GetRef` 函式,這個函式會回傳一個\\ :term:`強參照 " +"`。`pythoncapi-compat 專案`_\\ 可以用於在 Python 3.12 和更" +"舊的版本中取得 :c:func:`PyWeakref_GetRef`。(由 Victor Stinner " +"在 :gh:`105927` 中貢獻。)" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:4 msgid "" @@ -5122,39 +5436,31 @@ msgstr "" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 msgid "" -"The :c:func:`PyImport_ImportModuleNoBlock`: Use :c:func:" +"The :c:func:`!PyImport_ImportModuleNoBlock`: Use :c:func:" "`PyImport_ImportModule` instead." msgstr "" -":c:func:`PyImport_ImportModuleNoBlock`:請改用 :c:func:" -"`PyImport_ImportModule`。" +":c:func:`!PyImport_ImportModuleNoBlock`:請改" +"用 :c:func:`PyImport_ImportModule`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 msgid "" -":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" +":c:func:`!PyWeakref_GetObject` and :c:func:`!PyWeakref_GET_OBJECT`: Use :c:" "func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project `__ can be used to get :c:func:" "`PyWeakref_GetRef` on Python 3.12 and older." msgstr "" -":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改用 :c:" -"func:`PyWeakref_GetRef`。可以使用 `pythoncapi-compat 專案 `__\\ 來為 Python 3.12 和更早版本取得 :c:func:" -"`PyWeakref_GetRef`。" +":c:func:`!PyWeakref_GetObject` 和 :c:func:`!PyWeakref_GET_OBJECT`:請改" +"用 :c:func:`PyWeakref_GetRef`。可以使用 `pythoncapi-compat 專案 `__\\ 來為 Python 3.12 和更早版本取" +"得 :c:func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 msgid "" -":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" -"type:`wchar_t` instead." -msgstr "" -":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:type:" -"`wchar_t`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 -msgid "" ":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" ":c:func:`!PyUnicode_AsDecodedObject`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" ":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -5164,13 +5470,13 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`str` 的型別,例如 :" "class:`bytes`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 msgid "" ":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." msgstr "" ":c:func:`!PyUnicode_AsEncodedObject`:請改用 :c:func:`PyCodec_Encode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:19 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid "" ":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -5180,68 +5486,69 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`bytes` 的型別,例如 :" "class:`str`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 msgid "Python initialization functions, deprecated in Python 3.13:" msgstr "Python 初始化函式,自 Python 3.13 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 msgid "" -":c:func:`Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`) instead." msgstr "" -":c:func:`Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:27 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" -":c:func:`Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " +":c:func:`!Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) if :ref:" "`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " +":c:func:`!Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`)。如果需要處理\\ :ref:`虛擬環境 " -"`,請改用 :c:func:`PyConfig_Get(\"prefix\") ` (:data:" -"`sys.prefix`)。" +"`,請改用 :c:func:`PyConfig_Get(\"prefix\") ` " +"(:data:`sys.prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:32 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:30 msgid "" -":c:func:`Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " +":c:func:`!Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " "` (:data:`sys.base_exec_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) if :" "ref:`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetExecPrefix`:請改用 :c:func:" -"`PyConfig_Get(\"base_exec_prefix\") ` (:data:`sys." -"base_exec_prefix`)。如果需要處理\\ :ref:`虛擬環境 `,請改用 :c:" -"func:`PyConfig_Get(\"exec_prefix\") ` (:data:`sys." -"exec_prefix`)。" +":c:func:`!Py_GetExecPrefix`:請改" +"用 :c:func:`PyConfig_Get(\"base_exec_prefix\") ` " +"(:data:`sys.base_exec_prefix`)。如果需要處理\\ :ref:`虛擬環境 `,請" +"改用 :c:func:`PyConfig_Get(\"exec_prefix\") ` " +"(:data:`sys.exec_prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:38 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:36 msgid "" -":c:func:`Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramFullPath`:請改用 :c:func:" -"`PyConfig_Get(\"executable\") ` (:data:`sys.executable`)。" +":c:func:`!Py_GetProgramFullPath`:請改" +"用 :c:func:`PyConfig_Get(\"executable\") ` " +"(:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:41 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:39 msgid "" -":c:func:`Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:44 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:42 msgid "" -":c:func:`Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " "` or the :envvar:`PYTHONHOME` environment variable instead." msgstr "" -":c:func:`Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " "` 或 :envvar:`PYTHONHOME` 環境變數。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:48 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:46 msgid "" "The `pythoncapi-compat project `__ can be used to get :c:func:`PyConfig_Get` on Python 3.13 and older." @@ -5249,42 +5556,42 @@ msgstr "" "`pythoncapi-compat 專案 `__ 可" "以用來為 Python 3.13 和更早版本取得 :c:func:`PyConfig_Get`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:50 msgid "" "Functions to configure Python's initialization, deprecated in Python 3.11:" msgstr "用於配置 Python 初始化的函式,自 Python 3.11 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgvEx()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgv()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 msgid "" ":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " "instead." msgstr "" ":c:func:`!Py_SetProgramName()`:請改用 :c:member:`PyConfig.program_name`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." msgstr ":c:func:`!Py_SetPythonHome()`:請改用 :c:member:`PyConfig.home`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:65 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:63 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` instead." msgstr "" "應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:66 msgid "Global configuration variables:" msgstr "全域配置變數:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:70 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 msgid "" ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` or :c:func:" "`PyConfig_Get(\"parser_debug\") ` instead." @@ -5292,7 +5599,7 @@ msgstr "" ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug` 或 :c:func:" "`PyConfig_Get(\"parser_debug\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:73 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:71 msgid "" ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` or :c:func:" "`PyConfig_Get(\"verbose\") ` instead." @@ -5300,7 +5607,7 @@ msgstr "" ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose` 或 :c:func:" "`PyConfig_Get(\"verbose\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:76 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:74 msgid "" ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` or :c:func:" "`PyConfig_Get(\"quiet\") ` instead." @@ -5308,7 +5615,7 @@ msgstr "" ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet` 或 :c:func:" "`PyConfig_Get(\"quiet\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:79 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:77 msgid "" ":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` or :c:func:" "`PyConfig_Get(\"interactive\") ` instead." @@ -5316,7 +5623,7 @@ msgstr "" ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive` 或 :c:" "func:`PyConfig_Get(\"interactive\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:82 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:80 msgid "" ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` or :c:func:" "`PyConfig_Get(\"inspect\") ` instead." @@ -5324,7 +5631,7 @@ msgstr "" ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect` 或 :c:func:" "`PyConfig_Get(\"inspect\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:85 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:83 msgid "" ":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` or :c:" "func:`PyConfig_Get(\"optimization_level\") ` instead." @@ -5332,7 +5639,7 @@ msgstr "" ":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level` 或 :" "c:func:`PyConfig_Get(\"optimization_level\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:88 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:86 msgid "" ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` or :c:func:" "`PyConfig_Get(\"site_import\") ` instead." @@ -5340,7 +5647,7 @@ msgstr "" ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import` 或 :c:func:" "`PyConfig_Get(\"site_import\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:91 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:89 msgid "" ":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` or :c:" "func:`PyConfig_Get(\"bytes_warning\") ` instead." @@ -5348,7 +5655,7 @@ msgstr "" ":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning` 或 :" "c:func:`PyConfig_Get(\"bytes_warning\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:94 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:92 msgid "" ":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` or :c:" "func:`PyConfig_Get(\"pathconfig_warnings\") ` instead." @@ -5356,7 +5663,7 @@ msgstr "" ":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings` 或 :" "c:func:`PyConfig_Get(\"pathconfig_warnings\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:97 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:95 msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "or :c:func:`PyConfig_Get(\"use_environment\") ` instead." @@ -5365,7 +5672,7 @@ msgstr "" "use_environment` 或 :c:func:`PyConfig_Get(\"use_environment\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:100 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:98 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "or :c:func:`PyConfig_Get(\"write_bytecode\") ` instead." @@ -5374,7 +5681,7 @@ msgstr "" "write_bytecode` 或 :c:func:`PyConfig_Get(\"write_bytecode\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:103 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:101 msgid "" ":c:var:`Py_NoUserSiteDirectory`: Use :c:member:`PyConfig." "user_site_directory` or :c:func:`PyConfig_Get(\"user_site_directory\") " @@ -5384,7 +5691,7 @@ msgstr "" "user_site_directory` 或 :c:func:`PyConfig_Get(\"user_site_directory\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:106 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:104 msgid "" ":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` or :" "c:func:`PyConfig_Get(\"buffered_stdio\") ` instead." @@ -5392,7 +5699,7 @@ msgstr "" ":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio` " "或 :c:func:`PyConfig_Get(\"buffered_stdio\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:109 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:107 msgid "" ":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed` or :c:func:`PyConfig_Get(\"hash_seed\") " @@ -5402,7 +5709,7 @@ msgstr "" "和 :c:member:`PyConfig.hash_seed` 或 :c:func:`PyConfig_Get(\"hash_seed\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:113 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:111 msgid "" ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` or :c:func:" "`PyConfig_Get(\"isolated\") ` instead." @@ -5410,7 +5717,7 @@ msgstr "" ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated` 或 :c:func:" "`PyConfig_Get(\"isolated\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:116 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:114 msgid "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`: Use :c:member:`PyPreConfig." "legacy_windows_fs_encoding` or :c:func:" @@ -5420,7 +5727,7 @@ msgstr "" "legacy_windows_fs_encoding` 或 :c:func:" "`PyConfig_Get(\"legacy_windows_fs_encoding\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:119 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:117 msgid "" ":c:var:`Py_LegacyWindowsStdioFlag`: Use :c:member:`PyConfig." "legacy_windows_stdio` or :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " @@ -5430,7 +5737,7 @@ msgstr "" "legacy_windows_stdio` 或 :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:122 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:120 msgid "" ":c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!" "Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." @@ -5442,7 +5749,7 @@ msgstr "" "filesystem_encoding` 或 :c:func:`PyConfig_Get(\"filesystem_encoding\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:125 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:123 msgid "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." "filesystem_errors` or :c:func:`PyConfig_Get(\"filesystem_errors\") " @@ -5452,7 +5759,7 @@ msgstr "" "filesystem_errors` 或 :c:func:`PyConfig_Get(\"filesystem_errors\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:128 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:126 msgid "" ":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` or :c:func:" "`PyConfig_Get(\"utf8_mode\") ` instead. (see :c:func:" @@ -5462,7 +5769,7 @@ msgstr "" "`PyConfig_Get(\"utf8_mode\") `。(請參閱 :c:func:" "`Py_PreInitialize`)" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:133 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:131 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` to set these options. Or :c:func:`PyConfig_Get` can be used to " @@ -5729,31 +6036,31 @@ msgstr "" msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" -#: ../../whatsnew/3.13.rst:2562 +#: ../../whatsnew/3.13.rst:2563 msgid "Build Changes" msgstr "建置變更" -#: ../../whatsnew/3.13.rst:2564 +#: ../../whatsnew/3.13.rst:2565 msgid "" "``arm64-apple-ios`` and ``arm64-apple-ios-simulator`` are both now :pep:`11` " "tier 3 platforms. (:ref:`PEP 730 ` written and " "implementation contributed by Russell Keith-Magee in :gh:`114099`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2569 +#: ../../whatsnew/3.13.rst:2570 msgid "" "``aarch64-linux-android`` and ``x86_64-linux-android`` are both now :pep:" "`11` tier 3 platforms. (:ref:`PEP 738 ` " "written and implementation contributed by Malcolm Smith in :gh:`116622`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2574 +#: ../../whatsnew/3.13.rst:2575 msgid "" "``wasm32-wasi`` is now a :pep:`11` tier 2 platform. (Contributed by Brett " "Cannon in :gh:`115192`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2577 +#: ../../whatsnew/3.13.rst:2578 msgid "" "``wasm32-emscripten`` is no longer a :pep:`11` supported platform. " "(Contributed by Brett Cannon in :gh:`115192`.)" @@ -5761,26 +6068,26 @@ msgstr "" "``wasm32-emscripten`` 不再是 :pep:`11` 支援的平台。(由 Brett Cannon 在 :gh:" "`115192` 貢獻。)" -#: ../../whatsnew/3.13.rst:2580 +#: ../../whatsnew/3.13.rst:2581 msgid "" "Building CPython now requires a compiler with support for the C11 atomic " "library, GCC built-in atomic functions, or MSVC interlocked intrinsics." msgstr "" -#: ../../whatsnew/3.13.rst:2583 +#: ../../whatsnew/3.13.rst:2584 msgid "" "Autoconf 2.71 and aclocal 1.16.5 are now required to regenerate the :file:" "`configure` script. (Contributed by Christian Heimes in :gh:`89886` and by " "Victor Stinner in :gh:`112090`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2587 +#: ../../whatsnew/3.13.rst:2588 msgid "" "SQLite 3.15.2 or newer is required to build the :mod:`sqlite3` extension " "module. (Contributed by Erlend Aasland in :gh:`105875`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2591 +#: ../../whatsnew/3.13.rst:2592 msgid "" "CPython now bundles the `mimalloc library`_ by default. It is licensed under " "the MIT license; see :ref:`mimalloc license `. The bundled " @@ -5788,27 +6095,27 @@ msgid "" "Dino Viehland in :gh:`109914`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2599 +#: ../../whatsnew/3.13.rst:2600 msgid "" "The :file:`configure` option :option:`--with-system-libmpdec` now defaults " "to ``yes``. The bundled copy of ``libmpdec`` will be removed in Python 3.16." msgstr "" -#: ../../whatsnew/3.13.rst:2603 +#: ../../whatsnew/3.13.rst:2604 msgid "" "Python built with :file:`configure` :option:`--with-trace-refs` (tracing " "references) is now ABI compatible with the Python release build and :ref:" "`debug build `. (Contributed by Victor Stinner in :gh:`108634`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2608 +#: ../../whatsnew/3.13.rst:2609 msgid "" "On POSIX systems, the pkg-config (``.pc``) filenames now include the ABI " "flags. For example, the free-threaded build generates ``python-3.13t.pc`` " "and the debug build generates ``python-3.13d.pc``." msgstr "" -#: ../../whatsnew/3.13.rst:2612 +#: ../../whatsnew/3.13.rst:2613 msgid "" "The ``errno``, ``fcntl``, ``grp``, ``md5``, ``pwd``, ``resource``, " "``termios``, ``winsound``, ``_ctypes_test``, ``_multiprocessing." @@ -5818,27 +6125,27 @@ msgid "" "`85283`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2621 +#: ../../whatsnew/3.13.rst:2622 msgid "Porting to Python 3.13" msgstr "移植至 Python 3.13" -#: ../../whatsnew/3.13.rst:2623 +#: ../../whatsnew/3.13.rst:2624 msgid "" "This section lists previously described changes and other bugfixes that may " "require changes to your code." msgstr "" -#: ../../whatsnew/3.13.rst:2627 +#: ../../whatsnew/3.13.rst:2628 msgid "Changes in the Python API" msgstr "Python API 的變更" -#: ../../whatsnew/3.13.rst:2631 +#: ../../whatsnew/3.13.rst:2632 msgid "" ":ref:`PEP 667 ` introduces several changes to " "the semantics of :func:`locals` and :attr:`f_locals `:" msgstr "" -#: ../../whatsnew/3.13.rst:2634 +#: ../../whatsnew/3.13.rst:2635 msgid "" "Calling :func:`locals` in an :term:`optimized scope` now produces an " "independent snapshot on each call, and hence no longer implicitly updates " @@ -5850,7 +6157,7 @@ msgid "" "scope. (Changed as part of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2643 +#: ../../whatsnew/3.13.rst:2644 msgid "" "Calling :func:`locals` from a comprehension at module or class scope " "(including via ``exec`` or ``eval``) once more behaves as if the " @@ -5860,7 +6167,7 @@ msgid "" "implementing :pep:`709`. (Changed as part of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2650 +#: ../../whatsnew/3.13.rst:2651 msgid "" "Accessing :attr:`FrameType.f_locals ` in an :term:`optimized " "scope` now returns a write-through proxy rather than a snapshot that gets " @@ -5869,7 +6176,7 @@ msgid "" "of :pep:`667`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2656 +#: ../../whatsnew/3.13.rst:2657 msgid "" ":class:`functools.partial` now emits a :exc:`FutureWarning` when used as a " "method. The behavior will change in future Python versions. Wrap it in :func:" @@ -5877,14 +6184,14 @@ msgid "" "Serhiy Storchaka in :gh:`121027`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2662 +#: ../../whatsnew/3.13.rst:2663 msgid "" "An :exc:`OSError` is now raised by :func:`getpass.getuser` for any failure " "to retrieve a username, instead of :exc:`ImportError` on non-Unix platforms " "or :exc:`KeyError` on Unix platforms where the password database is empty." msgstr "" -#: ../../whatsnew/3.13.rst:2667 +#: ../../whatsnew/3.13.rst:2668 msgid "" "The value of the :attr:`!mode` attribute of :class:`gzip.GzipFile` is now a " "string (``'rb'`` or ``'wb'``) instead of an integer (``1`` or ``2``). The " @@ -5893,7 +6200,7 @@ msgid "" "(Contributed by Serhiy Storchaka in :gh:`115961`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2673 +#: ../../whatsnew/3.13.rst:2674 msgid "" ":class:`mailbox.Maildir` now ignores files with a leading dot (``.``). " "(Contributed by Zackery Spytz in :gh:`65559`.)" @@ -5901,7 +6208,7 @@ msgstr "" ":class:`mailbox.Maildir` 現在會忽略以點號 (``.``) 開頭的檔案。 (由 Zackery " "Spytz 在 :gh:`65559` 貢獻。)" -#: ../../whatsnew/3.13.rst:2676 +#: ../../whatsnew/3.13.rst:2677 msgid "" ":meth:`pathlib.Path.glob` and :meth:`~pathlib.Path.rglob` now return both " "files and directories if a pattern that ends with \"``**``\" is given, " @@ -5909,25 +6216,25 @@ msgid "" "behavior and only match directories." msgstr "" -#: ../../whatsnew/3.13.rst:2681 +#: ../../whatsnew/3.13.rst:2682 msgid "" "The :mod:`threading` module now expects the :mod:`!_thread` module to have " "an :func:`!_is_main_interpreter` function. This function takes no arguments " "and returns ``True`` if the current interpreter is the main interpreter." msgstr "" -#: ../../whatsnew/3.13.rst:2686 +#: ../../whatsnew/3.13.rst:2687 msgid "" "Any library or application that provides a custom :mod:`!_thread` module " "must provide :func:`!_is_main_interpreter`, just like the module's other " "\"private\" attributes. (:gh:`112826`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2693 +#: ../../whatsnew/3.13.rst:2694 msgid "Changes in the C API" msgstr "C API 中的改動" -#: ../../whatsnew/3.13.rst:2695 +#: ../../whatsnew/3.13.rst:2696 msgid "" "``Python.h`` no longer includes the ```` standard header. It was " "included for the :c:func:`!finite` function which is now provided by the " @@ -5936,7 +6243,7 @@ msgid "" "`108765`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2701 +#: ../../whatsnew/3.13.rst:2702 msgid "" "``Python.h`` no longer includes these standard header files: ````, " "```` and ````. If needed, they should now be " @@ -5947,7 +6254,7 @@ msgid "" "Victor Stinner in :gh:`108765`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2709 +#: ../../whatsnew/3.13.rst:2710 msgid "" "On Windows, ``Python.h`` no longer includes the ```` standard " "header file. If needed, it should now be included explicitly. For example, " @@ -5957,7 +6264,7 @@ msgid "" "(Contributed by Victor Stinner in :gh:`108765`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2716 +#: ../../whatsnew/3.13.rst:2717 msgid "" "If the :c:macro:`Py_LIMITED_API` macro is defined, :c:macro:`!" "Py_BUILD_CORE`, :c:macro:`!Py_BUILD_CORE_BUILTIN` and :c:macro:`!" @@ -5965,18 +6272,18 @@ msgid "" "(Contributed by Victor Stinner in :gh:`85283`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2721 +#: ../../whatsnew/3.13.rst:2722 msgid "" "The old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and " "``Py_TRASHCAN_SAFE_END`` were removed. They should be replaced by the new " "macros ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``." msgstr "" -#: ../../whatsnew/3.13.rst:2725 +#: ../../whatsnew/3.13.rst:2726 msgid "A ``tp_dealloc`` function that has the old macros, such as::" msgstr "有舊巨集的 ``tp_dealloc`` 函式,例如: ::" -#: ../../whatsnew/3.13.rst:2727 +#: ../../whatsnew/3.13.rst:2728 msgid "" "static void\n" "mytype_dealloc(mytype *p)\n" @@ -5996,11 +6303,11 @@ msgstr "" " Py_TRASHCAN_SAFE_END\n" "}" -#: ../../whatsnew/3.13.rst:2736 +#: ../../whatsnew/3.13.rst:2737 msgid "should migrate to the new macros as follows::" msgstr "應該改為使用新的巨集,如下所示: ::" -#: ../../whatsnew/3.13.rst:2738 +#: ../../whatsnew/3.13.rst:2739 msgid "" "static void\n" "mytype_dealloc(mytype *p)\n" @@ -6020,7 +6327,7 @@ msgstr "" " Py_TRASHCAN_END\n" "}" -#: ../../whatsnew/3.13.rst:2747 +#: ../../whatsnew/3.13.rst:2748 msgid "" "Note that ``Py_TRASHCAN_BEGIN`` has a second argument which should be the " "deallocation function it is in. The new macros were added in Python 3.8 and " @@ -6028,13 +6335,13 @@ msgid "" "in :gh:`105111`.)" msgstr "" -#: ../../whatsnew/3.13.rst:2754 +#: ../../whatsnew/3.13.rst:2755 msgid "" ":ref:`PEP 667 ` introduces several changes to " "frame-related functions:" msgstr "" -#: ../../whatsnew/3.13.rst:2757 +#: ../../whatsnew/3.13.rst:2758 msgid "" "The effects of mutating the dictionary returned from :c:func:" "`PyEval_GetLocals` in an :term:`optimized scope` have changed. New dict " @@ -6048,7 +6355,7 @@ msgid "" "being used, so refer to the deprecation notice on the function for details." msgstr "" -#: ../../whatsnew/3.13.rst:2770 +#: ../../whatsnew/3.13.rst:2771 msgid "" "Calling :c:func:`PyFrame_GetLocals` in an :term:`optimized scope` now " "returns a write-through proxy rather than a snapshot that gets updated at " @@ -6057,40 +6364,40 @@ msgid "" "`PyEval_GetFrameLocals` API." msgstr "" -#: ../../whatsnew/3.13.rst:2777 +#: ../../whatsnew/3.13.rst:2778 msgid "" ":c:func:`!PyFrame_FastToLocals` and :c:func:`!PyFrame_FastToLocalsWithError` " "no longer have any effect. Calling these functions has been redundant since " "Python 3.11, when :c:func:`PyFrame_GetLocals` was first introduced." msgstr "" -#: ../../whatsnew/3.13.rst:2782 +#: ../../whatsnew/3.13.rst:2783 msgid "" ":c:func:`!PyFrame_LocalsToFast` no longer has any effect. Calling this " "function is redundant now that :c:func:`PyFrame_GetLocals` returns a write-" "through proxy for :term:`optimized scopes `." msgstr "" -#: ../../whatsnew/3.13.rst:2786 +#: ../../whatsnew/3.13.rst:2787 msgid "" "Python 3.13 removed many private functions. Some of them can be replaced " "using these alternatives:" msgstr "" -#: ../../whatsnew/3.13.rst:2789 +#: ../../whatsnew/3.13.rst:2790 msgid "``_PyDict_Pop()``: :c:func:`PyDict_Pop` or :c:func:`PyDict_PopString`;" msgstr "" "``_PyDict_Pop()``::c:func:`PyDict_Pop` 或 :c:func:`PyDict_PopString`;" -#: ../../whatsnew/3.13.rst:2790 +#: ../../whatsnew/3.13.rst:2791 msgid "``_PyDict_GetItemWithError()``: :c:func:`PyDict_GetItemRef`;" msgstr "``_PyDict_GetItemWithError()``::c:func:`PyDict_GetItemRef`;" -#: ../../whatsnew/3.13.rst:2791 +#: ../../whatsnew/3.13.rst:2792 msgid "``_PyErr_WriteUnraisableMsg()``: :c:func:`PyErr_FormatUnraisable`;" msgstr "``_PyErr_WriteUnraisableMsg()``::c:func:`PyErr_FormatUnraisable`;" -#: ../../whatsnew/3.13.rst:2792 +#: ../../whatsnew/3.13.rst:2793 msgid "" "``_PyEval_SetTrace()``: :c:func:`PyEval_SetTrace` or :c:func:" "`PyEval_SetTraceAllThreads`;" @@ -6098,43 +6405,43 @@ msgstr "" "``_PyEval_SetTrace()``::c:func:`PyEval_SetTrace` 或 :c:func:" "`PyEval_SetTraceAllThreads`;" -#: ../../whatsnew/3.13.rst:2793 +#: ../../whatsnew/3.13.rst:2794 msgid "``_PyList_Extend()``: :c:func:`PyList_Extend`;" msgstr "``_PyList_Extend()``::c:func:`PyList_Extend`;" -#: ../../whatsnew/3.13.rst:2794 +#: ../../whatsnew/3.13.rst:2795 msgid "``_PyLong_AsInt()``: :c:func:`PyLong_AsInt`;" msgstr "``_PyLong_AsInt()``::c:func:`PyLong_AsInt`;" -#: ../../whatsnew/3.13.rst:2795 +#: ../../whatsnew/3.13.rst:2796 msgid "``_PyMem_RawStrdup()``: ``strdup()``;" msgstr "``_PyMem_RawStrdup()``:``strdup()``;" -#: ../../whatsnew/3.13.rst:2796 +#: ../../whatsnew/3.13.rst:2797 msgid "``_PyMem_Strdup()``: ``strdup()``;" msgstr "``_PyMem_Strdup()``:``strdup()``;" -#: ../../whatsnew/3.13.rst:2797 +#: ../../whatsnew/3.13.rst:2798 msgid "``_PyObject_ClearManagedDict()``: :c:func:`PyObject_ClearManagedDict`;" msgstr "" "``_PyObject_ClearManagedDict()``::c:func:`PyObject_ClearManagedDict`;" -#: ../../whatsnew/3.13.rst:2798 +#: ../../whatsnew/3.13.rst:2799 msgid "``_PyObject_VisitManagedDict()``: :c:func:`PyObject_VisitManagedDict`;" msgstr "" "``_PyObject_VisitManagedDict()``::c:func:`PyObject_VisitManagedDict`;" -#: ../../whatsnew/3.13.rst:2799 +#: ../../whatsnew/3.13.rst:2800 msgid "" "``_PyThreadState_UncheckedGet()``: :c:func:`PyThreadState_GetUnchecked()`;" msgstr "" "``_PyThreadState_UncheckedGet()``::c:func:`PyThreadState_GetUnchecked()`;" -#: ../../whatsnew/3.13.rst:2800 +#: ../../whatsnew/3.13.rst:2801 msgid "``_PyTime_AsSecondsDouble()``: :c:func:`PyTime_AsSecondsDouble`;" msgstr "``_PyTime_AsSecondsDouble()``::c:func:`PyTime_AsSecondsDouble`;" -#: ../../whatsnew/3.13.rst:2801 +#: ../../whatsnew/3.13.rst:2802 msgid "" "``_PyTime_GetMonotonicClock()``: :c:func:`PyTime_Monotonic` or :c:func:" "`PyTime_MonotonicRaw`;" @@ -6142,7 +6449,7 @@ msgstr "" "``_PyTime_GetMonotonicClock()``::c:func:`PyTime_Monotonic` 或 :c:func:" "`PyTime_MonotonicRaw`;" -#: ../../whatsnew/3.13.rst:2802 +#: ../../whatsnew/3.13.rst:2803 msgid "" "``_PyTime_GetPerfCounter()``: :c:func:`PyTime_PerfCounter` or :c:func:" "`PyTime_PerfCounterRaw`;" @@ -6150,7 +6457,7 @@ msgstr "" "``_PyTime_GetPerfCounter()``::c:func:`PyTime_PerfCounter` 或 :c:func:" "`PyTime_PerfCounterRaw`;" -#: ../../whatsnew/3.13.rst:2803 +#: ../../whatsnew/3.13.rst:2804 msgid "" "``_PyTime_GetSystemClock()``: :c:func:`PyTime_Time` or :c:func:" "`PyTime_TimeRaw`;" @@ -6158,27 +6465,27 @@ msgstr "" "``_PyTime_GetSystemClock()``::c:func:`PyTime_Time` 或 :c:func:" "`PyTime_TimeRaw`;" -#: ../../whatsnew/3.13.rst:2804 +#: ../../whatsnew/3.13.rst:2805 msgid "``_PyTime_MAX``: :c:var:`PyTime_MAX`;" msgstr "``_PyTime_MAX``::c:var:`PyTime_MAX`;" -#: ../../whatsnew/3.13.rst:2805 +#: ../../whatsnew/3.13.rst:2806 msgid "``_PyTime_MIN``: :c:var:`PyTime_MIN`;" msgstr "``_PyTime_MIN``::c:var:`PyTime_MIN`;" -#: ../../whatsnew/3.13.rst:2806 +#: ../../whatsnew/3.13.rst:2807 msgid "``_PyTime_t``: :c:type:`PyTime_t`;" msgstr "``_PyTime_t``::c:type:`PyTime_t`;" -#: ../../whatsnew/3.13.rst:2807 +#: ../../whatsnew/3.13.rst:2808 msgid "``_Py_HashPointer()``: :c:func:`Py_HashPointer`;" msgstr "``_Py_HashPointer()``::c:func:`Py_HashPointer`;" -#: ../../whatsnew/3.13.rst:2808 +#: ../../whatsnew/3.13.rst:2809 msgid "``_Py_IsFinalizing()``: :c:func:`Py_IsFinalizing`." msgstr "``_Py_IsFinalizing()``::c:func:`Py_IsFinalizing`。" -#: ../../whatsnew/3.13.rst:2810 +#: ../../whatsnew/3.13.rst:2811 msgid "" "The `pythoncapi-compat project`_ can be used to get most of these new " "functions on Python 3.12 and older." @@ -6186,11 +6493,11 @@ msgstr "" "可以使用 `pythoncapi-compat 專案`_\\ 來在 Python 3.12 及更舊的版本中取用大部" "分的這些新函式。" -#: ../../whatsnew/3.13.rst:2814 +#: ../../whatsnew/3.13.rst:2815 msgid "Regression Test Changes" msgstr "迴歸測試的變更" -#: ../../whatsnew/3.13.rst:2816 +#: ../../whatsnew/3.13.rst:2817 msgid "" "Python built with :file:`configure` :option:`--with-pydebug` now supports a :" "option:`-X presite=package.module <-X>` command-line option. If used, it " @@ -6203,6 +6510,13 @@ msgstr "" "該在直譯器生命週期的早期階段、在執行 ``site.py`` 之前被引入的模組。(由 " "Łukasz Langa 在 :gh:`110769` 中貢獻。)" +#~ msgid "" +#~ ":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :" +#~ "c:type:`wchar_t` instead." +#~ msgstr "" +#~ ":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:" +#~ "type:`wchar_t`。" + #~ msgid ":class:`locale`:" #~ msgstr ":class:`locale`:" diff --git a/whatsnew/3.14.po b/whatsnew/3.14.po index a769b1c9a14..9eaf8f2d620 100644 --- a/whatsnew/3.14.po +++ b/whatsnew/3.14.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-15 00:20+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -48,15 +48,15 @@ msgstr "發布重點摘要" #: ../../whatsnew/3.14.rst:63 msgid "" -"Python 3.14 is the latest stable release of the Python programming language, " -"with a mix of changes to the language, the implementation, and the standard " +"Python 3.14 is a stable release of the Python programming language, with a " +"mix of changes to the language, the implementation, and the standard " "library. The biggest changes include :ref:`template string literals " "`, :ref:`deferred evaluation of " "annotations `, and support for :ref:" "`subinterpreters ` in the standard " "library." msgstr "" -"Python 3.14 是 Python 程式語言的最新穩定版本,包含了語言、實作和標準函式庫的" +"Python 3.14 是 Python 程式語言的一個穩定版本,包含了語言、實作和標準函式庫的" "各種變更。最大的變更包括\\ :ref:`模板字串字面值 `、:ref:`延遲型別註解的求值 `,以" "及標準函式庫中對\\ :ref:`子直譯器 `\\ 的支" @@ -1417,28 +1417,28 @@ msgstr "(由 Noah Kim 和 Adam Turner 於 :gh:`118655` 貢獻。)" #: ../../whatsnew/3.14.rst:899 msgid "" "The command-line option :option:`-c` now automatically dedents its code " -"argument before execution. The auto-dedentation behavior mirrors :func:" -"`textwrap.dedent`. (Contributed by Jon Crall and Steven Sun in :gh:`103998`.)" +"argument before execution. (Contributed by Jon Crall and Steven Sun in :gh:" +"`103998`.)" msgstr "" -#: ../../whatsnew/3.14.rst:904 +#: ../../whatsnew/3.14.rst:903 msgid "" ":option:`!-J` is no longer a reserved flag for Jython_, and now has no " "special meaning. (Contributed by Adam Turner in :gh:`133336`.)" msgstr "" -#: ../../whatsnew/3.14.rst:914 +#: ../../whatsnew/3.14.rst:913 msgid "PEP 758: Allow ``except`` and ``except*`` expressions without brackets" msgstr "" -#: ../../whatsnew/3.14.rst:916 +#: ../../whatsnew/3.14.rst:915 msgid "" "The :keyword:`except` and :keyword:`except* ` expressions now " "allow brackets to be omitted when there are multiple exception types and the " "``as`` clause is not used. For example:" msgstr "" -#: ../../whatsnew/3.14.rst:921 +#: ../../whatsnew/3.14.rst:920 msgid "" "try:\n" " connect_to_server()\n" @@ -1450,25 +1450,25 @@ msgstr "" "except TimeoutError, ConnectionRefusedError:\n" " print('The network has ceased to be!')" -#: ../../whatsnew/3.14.rst:928 +#: ../../whatsnew/3.14.rst:927 msgid "" "(Contributed by Pablo Galindo and Brett Cannon in :pep:`758` and :gh:" "`131831`.)" msgstr "" "(由 Pablo Galindo 和 Brett Cannon 於 :pep:`758` 和 :gh:`131831` 貢獻。)" -#: ../../whatsnew/3.14.rst:934 +#: ../../whatsnew/3.14.rst:933 msgid "PEP 765: Control flow in :keyword:`finally` blocks" msgstr "" -#: ../../whatsnew/3.14.rst:936 +#: ../../whatsnew/3.14.rst:935 msgid "" "The compiler now emits a :exc:`SyntaxWarning` when a :keyword:`return`, :" "keyword:`break`, or :keyword:`continue` statement have the effect of leaving " "a :keyword:`finally` block. This change is specified in :pep:`765`." msgstr "" -#: ../../whatsnew/3.14.rst:941 +#: ../../whatsnew/3.14.rst:940 msgid "" "In situations where this change is inconvenient (such as those where the " "warnings are redundant due to code linting), the :ref:`warning filter " @@ -1479,7 +1479,7 @@ msgid "" "``PYTHONWARNINGS=error,ignore::SyntaxWarning``)." msgstr "" -#: ../../whatsnew/3.14.rst:949 +#: ../../whatsnew/3.14.rst:948 msgid "" "Note that applying such a filter at runtime using the :mod:`warnings` module " "will only suppress the warning in code that is compiled *after* the filter " @@ -1487,23 +1487,23 @@ msgid "" "example, when a module is imported) will still emit the syntax warning." msgstr "" -#: ../../whatsnew/3.14.rst:954 +#: ../../whatsnew/3.14.rst:953 msgid "(Contributed by Irit Katriel in :gh:`130080`.)" msgstr "(由 Irit Katriel 於 :gh:`130080` 貢獻。)" -#: ../../whatsnew/3.14.rst:961 +#: ../../whatsnew/3.14.rst:960 msgid "Garbage collection" msgstr "" -#: ../../whatsnew/3.14.rst:963 ../../whatsnew/3.14.rst:2227 +#: ../../whatsnew/3.14.rst:962 ../../whatsnew/3.14.rst:2226 msgid "**From Python 3.14.5 onwards:**" msgstr "" -#: ../../whatsnew/3.14.rst:965 +#: ../../whatsnew/3.14.rst:964 msgid "The garbage collector (GC) has changed in Python 3.14.5." msgstr "" -#: ../../whatsnew/3.14.rst:967 +#: ../../whatsnew/3.14.rst:966 msgid "" "Python 3.14.0-3.14.4 shipped with a new incremental GC. However, due to a " "number of `reports `__ of " @@ -1512,17 +1512,17 @@ msgid "" "3.14.5 and later." msgstr "" -#: ../../whatsnew/3.14.rst:974 ../../whatsnew/3.14.rst:2236 +#: ../../whatsnew/3.14.rst:973 ../../whatsnew/3.14.rst:2235 msgid "**Previously in Python 3.14.0-3.14.4:**" msgstr "" -#: ../../whatsnew/3.14.rst:976 +#: ../../whatsnew/3.14.rst:975 msgid "" "The cycle garbage collector is now incremental. This means that maximum " "pause times are reduced by an order of magnitude or more for larger heaps." msgstr "" -#: ../../whatsnew/3.14.rst:980 +#: ../../whatsnew/3.14.rst:979 msgid "" "There are now only two generations: young and old. When :func:`gc.collect` " "is not called directly, the GC is invoked a little less frequently. When " @@ -1530,29 +1530,29 @@ msgid "" "generation, instead of collecting one or more generations." msgstr "" -#: ../../whatsnew/3.14.rst:986 +#: ../../whatsnew/3.14.rst:985 msgid "The behavior of :func:`!gc.collect` changes slightly:" msgstr "" -#: ../../whatsnew/3.14.rst:988 ../../whatsnew/3.14.rst:3309 +#: ../../whatsnew/3.14.rst:987 ../../whatsnew/3.14.rst:3310 msgid "" "``gc.collect(1)``: Performs an increment of garbage collection, rather than " "collecting generation 1." msgstr "" -#: ../../whatsnew/3.14.rst:990 ../../whatsnew/3.14.rst:3311 +#: ../../whatsnew/3.14.rst:989 ../../whatsnew/3.14.rst:3312 msgid "Other calls to :func:`!gc.collect` are unchanged." msgstr "" -#: ../../whatsnew/3.14.rst:992 ../../whatsnew/3.14.rst:2267 +#: ../../whatsnew/3.14.rst:991 ../../whatsnew/3.14.rst:2266 msgid "(Contributed by Mark Shannon in :gh:`108362`.)" msgstr "(由 Mark Shannon 於 :gh:`108362` 貢獻。)" -#: ../../whatsnew/3.14.rst:996 +#: ../../whatsnew/3.14.rst:995 msgid "Default interactive shell" msgstr "" -#: ../../whatsnew/3.14.rst:1000 +#: ../../whatsnew/3.14.rst:999 msgid "" "The default :term:`interactive` shell now highlights Python syntax. The " "feature is enabled by default, save if :envvar:`PYTHON_BASIC_REPL` or any " @@ -1560,7 +1560,7 @@ msgid "" "controlling-color` for details." msgstr "" -#: ../../whatsnew/3.14.rst:1005 +#: ../../whatsnew/3.14.rst:1004 msgid "" "The default color theme for syntax highlighting strives for good contrast " "and exclusively uses the 4-bit VGA standard ANSI color codes for maximum " @@ -1570,11 +1570,11 @@ msgid "" "and may change or be removed." msgstr "" -#: ../../whatsnew/3.14.rst:1013 +#: ../../whatsnew/3.14.rst:1012 msgid "(Contributed by Łukasz Langa in :gh:`131507`.)" msgstr "(由 Łukasz Langa 於 :gh:`131507` 貢獻。)" -#: ../../whatsnew/3.14.rst:1015 +#: ../../whatsnew/3.14.rst:1014 msgid "" "The default :term:`interactive` shell now supports import auto-completion. " "This means that typing ``import co`` and pressing :kbd:`` will suggest " @@ -1584,18 +1584,18 @@ msgid "" "by Tomas Roun in :gh:`69605`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1024 +#: ../../whatsnew/3.14.rst:1023 msgid "New modules" msgstr "新增模組" -#: ../../whatsnew/3.14.rst:1026 +#: ../../whatsnew/3.14.rst:1025 msgid "" ":mod:`annotationlib`: For introspecting :term:`annotations `. " "See :ref:`PEP 749 ` for more details. " "(Contributed by Jelle Zijlstra in :gh:`119180`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1031 +#: ../../whatsnew/3.14.rst:1030 msgid "" ":mod:`compression` (including :mod:`compression.zstd`): A package for " "compression-related modules, including a new module to support the Zstandard " @@ -1604,14 +1604,14 @@ msgid "" "Tomas Roun, Victor Stinner, and Rogdham in :gh:`132983`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1038 +#: ../../whatsnew/3.14.rst:1037 msgid "" ":mod:`concurrent.interpreters`: Support for multiple interpreters in the " "standard library. See :ref:`PEP 734 ` for " "more details. (Contributed by Eric Snow in :gh:`134939`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1043 +#: ../../whatsnew/3.14.rst:1042 msgid "" ":mod:`string.templatelib`: Support for template string literals (t-strings). " "See :ref:`PEP 750 ` for more details. " @@ -1620,15 +1620,15 @@ msgid "" "and Pablo Galindo Salgado in :gh:`132661`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1052 +#: ../../whatsnew/3.14.rst:1051 msgid "Improved modules" msgstr "改進的模組" -#: ../../whatsnew/3.14.rst:1055 ../../whatsnew/3.14.rst:2341 +#: ../../whatsnew/3.14.rst:1054 ../../whatsnew/3.14.rst:2340 msgid "argparse" msgstr "argparse" -#: ../../whatsnew/3.14.rst:1057 +#: ../../whatsnew/3.14.rst:1056 msgid "" "The default value of the :ref:`program name ` for :class:`argparse." "ArgumentParser` now reflects the way the Python interpreter was instructed " @@ -1636,7 +1636,7 @@ msgid "" "Alyssa Coghlan in :gh:`66436`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1062 +#: ../../whatsnew/3.14.rst:1061 msgid "" "Introduced the optional *suggest_on_error* parameter to :class:`argparse." "ArgumentParser`, enabling suggestions for argument choices and subparser " @@ -1644,7 +1644,7 @@ msgid "" "`124456`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1067 +#: ../../whatsnew/3.14.rst:1066 msgid "" "Enable color for help text, which can be disabled with the optional *color* " "parameter to :class:`argparse.ArgumentParser`. This can also be controlled " @@ -1652,42 +1652,42 @@ msgid "" "by Hugo van Kemenade in :gh:`130645`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1075 ../../whatsnew/3.14.rst:2360 +#: ../../whatsnew/3.14.rst:1074 ../../whatsnew/3.14.rst:2359 msgid "ast" msgstr "ast" -#: ../../whatsnew/3.14.rst:1077 +#: ../../whatsnew/3.14.rst:1076 msgid "" "Add :func:`~ast.compare`, a function for comparing two ASTs. (Contributed by " "Batuhan Taskaya and Jeremy Hylton in :gh:`60191`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1080 +#: ../../whatsnew/3.14.rst:1079 msgid "" "Add support for :func:`copy.replace` for AST nodes. (Contributed by Bénédikt " "Tran in :gh:`121141`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1083 +#: ../../whatsnew/3.14.rst:1082 msgid "" "Docstrings are now removed from an optimized AST in optimization level 2. " "(Contributed by Irit Katriel in :gh:`123958`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1086 +#: ../../whatsnew/3.14.rst:1085 msgid "" "The :func:`repr` output for AST nodes now includes more information. " "(Contributed by Tomas Roun in :gh:`116022`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1089 +#: ../../whatsnew/3.14.rst:1088 msgid "" "When called with an AST as input, the :func:`~ast.parse` function now always " "verifies that the root node type is appropriate. (Contributed by Irit " "Katriel in :gh:`130139`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1093 +#: ../../whatsnew/3.14.rst:1092 msgid "" "Add new options to the command-line interface: :option:`--feature-version " "`, :option:`--optimize `, and :option:" @@ -1695,12 +1695,12 @@ msgid "" "`133367`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1101 ../../whatsnew/3.14.rst:2182 -#: ../../whatsnew/3.14.rst:2391 +#: ../../whatsnew/3.14.rst:1100 ../../whatsnew/3.14.rst:2181 +#: ../../whatsnew/3.14.rst:2390 msgid "asyncio" msgstr "asyncio" -#: ../../whatsnew/3.14.rst:1103 +#: ../../whatsnew/3.14.rst:1102 msgid "" "The function and methods named :func:`!create_task` now take an arbitrary " "list of keyword arguments. All keyword arguments are passed to the :class:" @@ -1710,18 +1710,18 @@ msgid "" "``name`` keyword argument of the factory, and ``context`` may be ``None``." msgstr "" -#: ../../whatsnew/3.14.rst:1111 +#: ../../whatsnew/3.14.rst:1110 msgid "" "This affects the following function and methods: :meth:`asyncio." "create_task`, :meth:`asyncio.loop.create_task`, :meth:`asyncio.TaskGroup." "create_task`." msgstr "" -#: ../../whatsnew/3.14.rst:1116 +#: ../../whatsnew/3.14.rst:1115 msgid "(Contributed by Thomas Grainger in :gh:`128307`.)" msgstr "(由 Thomas Grainger 於 :gh:`128307` 貢獻。)" -#: ../../whatsnew/3.14.rst:1118 +#: ../../whatsnew/3.14.rst:1117 msgid "" "There are two new utility functions for introspecting and printing a " "program's call graph: :func:`~asyncio.capture_call_graph` and :func:" @@ -1730,11 +1730,11 @@ msgid "" "Selivanov, Pablo Galindo Salgado, and Łukasz Langa in :gh:`91048`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1128 +#: ../../whatsnew/3.14.rst:1127 msgid "calendar" msgstr "calendar" -#: ../../whatsnew/3.14.rst:1132 +#: ../../whatsnew/3.14.rst:1131 msgid "" "By default, today's date is highlighted in color in :mod:`calendar`'s :ref:" "`command-line ` text output. This can be controlled by :ref:" @@ -1742,11 +1742,11 @@ msgid "" "van Kemenade in :gh:`128317`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1140 +#: ../../whatsnew/3.14.rst:1139 msgid "concurrent.futures" msgstr "concurrent.futures" -#: ../../whatsnew/3.14.rst:1144 +#: ../../whatsnew/3.14.rst:1143 msgid "" "Add a new executor class, :class:`~concurrent.futures." "InterpreterPoolExecutor`, which exposes multiple Python interpreters in the " @@ -1754,14 +1754,14 @@ msgid "" "independent Python interpreters to execute calls asynchronously." msgstr "" -#: ../../whatsnew/3.14.rst:1150 +#: ../../whatsnew/3.14.rst:1149 msgid "" "This is separate from the new :mod:`~concurrent.interpreters` module " "introduced by :ref:`PEP 734 `. " "(Contributed by Eric Snow in :gh:`124548`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1156 +#: ../../whatsnew/3.14.rst:1155 msgid "" "On Unix platforms other than macOS, :ref:`'forkserver' ` is now the default :ref:`start method " @@ -1771,14 +1771,14 @@ msgid "" "` remains the default start method." msgstr "" -#: ../../whatsnew/3.14.rst:1164 +#: ../../whatsnew/3.14.rst:1163 msgid "" "If the threading incompatible *fork* method is required, you must explicitly " "request it by supplying a multiprocessing context *mp_context* to :class:" "`~concurrent.futures.ProcessPoolExecutor`." msgstr "" -#: ../../whatsnew/3.14.rst:1168 ../../whatsnew/3.14.rst:1618 +#: ../../whatsnew/3.14.rst:1167 ../../whatsnew/3.14.rst:1617 msgid "" "See :ref:`forkserver restrictions ` " "for information and differences with the *fork* method and how this change " @@ -1786,11 +1786,11 @@ msgid "" "objects that can not be automatically :mod:`pickled `." msgstr "" -#: ../../whatsnew/3.14.rst:1173 ../../whatsnew/3.14.rst:1623 +#: ../../whatsnew/3.14.rst:1172 ../../whatsnew/3.14.rst:1622 msgid "(Contributed by Gregory P. Smith in :gh:`84559`.)" msgstr "(由 Gregory P. Smith 於 :gh:`84559` 貢獻。)" -#: ../../whatsnew/3.14.rst:1175 +#: ../../whatsnew/3.14.rst:1174 msgid "" "Add two new methods to :class:`~concurrent.futures.ProcessPoolExecutor`, :" "meth:`~concurrent.futures.ProcessPoolExecutor.terminate_workers` and :meth:" @@ -1799,7 +1799,7 @@ msgid "" "Charles Machalow in :gh:`130849`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1181 +#: ../../whatsnew/3.14.rst:1180 msgid "" "Add the optional *buffersize* parameter to :meth:`Executor.map ` to limit the number of submitted tasks whose results " @@ -1808,11 +1808,11 @@ msgid "" "by Enzo Bonnal and Josh Rosenberg in :gh:`74028`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1190 +#: ../../whatsnew/3.14.rst:1189 msgid "configparser" msgstr "configparser" -#: ../../whatsnew/3.14.rst:1192 +#: ../../whatsnew/3.14.rst:1191 msgid "" ":mod:`!configparser` will no longer write config files it cannot read, to " "improve security. Attempting to :meth:`~configparser.ConfigParser.write` " @@ -1821,21 +1821,21 @@ msgid "" "Lincoln in :gh:`129270`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1201 +#: ../../whatsnew/3.14.rst:1200 msgid "contextvars" msgstr "contextvars" -#: ../../whatsnew/3.14.rst:1203 +#: ../../whatsnew/3.14.rst:1202 msgid "" "Support the :term:`context manager` protocol for :class:`~contextvars.Token` " "objects. (Contributed by Andrew Svetlov in :gh:`129889`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1209 +#: ../../whatsnew/3.14.rst:1208 msgid "ctypes" msgstr "ctypes" -#: ../../whatsnew/3.14.rst:1211 +#: ../../whatsnew/3.14.rst:1210 msgid "" "The layout of :ref:`bit fields ` in :" "class:`~ctypes.Structure` and :class:`~ctypes.Union` objects is now a closer " @@ -1843,13 +1843,13 @@ msgid "" "longer overlap. (Contributed by Matthias Görgens in :gh:`97702`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1217 +#: ../../whatsnew/3.14.rst:1216 msgid "" "The :attr:`.Structure._layout_` class attribute can now be set to help match " "a non-default ABI. (Contributed by Petr Viktorin in :gh:`97702`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1221 +#: ../../whatsnew/3.14.rst:1220 msgid "" "The class of :class:`~ctypes.Structure`/:class:`~ctypes.Union` field " "descriptors is now available as :class:`~ctypes.CField`, and has new " @@ -1857,19 +1857,19 @@ msgid "" "in :gh:`128715`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1226 +#: ../../whatsnew/3.14.rst:1225 msgid "" "On Windows, the :exc:`~ctypes.COMError` exception is now public. " "(Contributed by Jun Komoda in :gh:`126686`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1229 +#: ../../whatsnew/3.14.rst:1228 msgid "" "On Windows, the :func:`~ctypes.CopyComPointer` function is now public. " "(Contributed by Jun Komoda in :gh:`127275`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1232 +#: ../../whatsnew/3.14.rst:1231 msgid "" "Add :func:`~ctypes.memoryview_at`, a function to create a :class:" "`memoryview` object that refers to the supplied pointer and length. This " @@ -1879,7 +1879,7 @@ msgid "" "`112018`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1239 +#: ../../whatsnew/3.14.rst:1238 msgid "" "Complex types, :class:`~ctypes.c_float_complex`, :class:`~ctypes." "c_double_complex`, and :class:`~ctypes.c_longdouble_complex`, are now " @@ -1887,13 +1887,13 @@ msgid "" "types. (Contributed by Sergey B Kirpichev in :gh:`61103`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1245 +#: ../../whatsnew/3.14.rst:1244 msgid "" "Add :func:`ctypes.util.dllist` for listing the shared libraries loaded by " "the current process. (Contributed by Brian Ward in :gh:`119349`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1249 +#: ../../whatsnew/3.14.rst:1248 msgid "" "Move :func:`ctypes.POINTER` types cache from a global internal cache " "(``_pointer_type_cache``) to the :attr:`_CData.__pointer_type__ `. " "(Contributed by Kumar Aditya and Peter Bierma in :gh:`127945`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1265 +#: ../../whatsnew/3.14.rst:1264 msgid "curses" msgstr "curses" -#: ../../whatsnew/3.14.rst:1267 +#: ../../whatsnew/3.14.rst:1266 msgid "" "Add the :func:`~curses.assume_default_colors` function, a refinement of the :" "func:`~curses.use_default_colors` function which allows changing the color " "pair ``0``. (Contributed by Serhiy Storchaka in :gh:`133139`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1274 +#: ../../whatsnew/3.14.rst:1273 msgid "datetime" msgstr "datetime" -#: ../../whatsnew/3.14.rst:1276 +#: ../../whatsnew/3.14.rst:1275 msgid "" "Add the :meth:`~datetime.date.strptime` method to the :class:`datetime.date` " "and :class:`datetime.time` classes. (Contributed by Wannes Boeykens in :gh:" "`41431`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1282 +#: ../../whatsnew/3.14.rst:1281 msgid "decimal" msgstr "decimal" -#: ../../whatsnew/3.14.rst:1284 +#: ../../whatsnew/3.14.rst:1283 msgid "" "Add :meth:`.Decimal.from_number` as an alternative constructor for :class:" "`~decimal.Decimal`. (Contributed by Serhiy Storchaka in :gh:`121798`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1288 +#: ../../whatsnew/3.14.rst:1287 msgid "" "Expose :func:`~decimal.IEEEContext` to support creation of contexts " "corresponding to the IEEE 754 (2008) decimal interchange formats. " "(Contributed by Sergey B Kirpichev in :gh:`53032`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1294 ../../whatsnew/3.14.rst:2218 +#: ../../whatsnew/3.14.rst:1293 ../../whatsnew/3.14.rst:2217 msgid "difflib" msgstr "difflib" -#: ../../whatsnew/3.14.rst:1296 +#: ../../whatsnew/3.14.rst:1295 msgid "" "Comparison pages with highlighted changes generated by the :class:`~difflib." "HtmlDiff` class now support 'dark mode'. (Contributed by Jiahao Li in :gh:" "`129939`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1302 +#: ../../whatsnew/3.14.rst:1301 msgid "dis" msgstr "dis" -#: ../../whatsnew/3.14.rst:1304 +#: ../../whatsnew/3.14.rst:1303 msgid "" "Add support for rendering full source location information of :class:" "`instructions `, rather than only the line number. This " @@ -1976,49 +1976,49 @@ msgid "" "keyword argument:" msgstr "" -#: ../../whatsnew/3.14.rst:1309 +#: ../../whatsnew/3.14.rst:1308 msgid ":class:`dis.Bytecode`" msgstr ":class:`dis.Bytecode`" -#: ../../whatsnew/3.14.rst:1310 +#: ../../whatsnew/3.14.rst:1309 msgid ":func:`dis.dis`" msgstr ":func:`dis.dis`" -#: ../../whatsnew/3.14.rst:1311 +#: ../../whatsnew/3.14.rst:1310 msgid ":func:`dis.distb`" msgstr ":func:`dis.distb`" -#: ../../whatsnew/3.14.rst:1312 +#: ../../whatsnew/3.14.rst:1311 msgid ":func:`dis.disassemble`" msgstr ":func:`dis.disassemble`" -#: ../../whatsnew/3.14.rst:1314 +#: ../../whatsnew/3.14.rst:1313 msgid "" "This feature is also exposed via :option:`dis --show-positions`. " "(Contributed by Bénédikt Tran in :gh:`123165`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1317 +#: ../../whatsnew/3.14.rst:1316 msgid "" "Add the :option:`dis --specialized` command-line option to show specialized " "bytecode. (Contributed by Bénédikt Tran in :gh:`127413`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1323 +#: ../../whatsnew/3.14.rst:1322 msgid "errno" msgstr "errno" -#: ../../whatsnew/3.14.rst:1325 +#: ../../whatsnew/3.14.rst:1324 msgid "" "Add the :data:`~errno.EHWPOISON` error code constant. (Contributed by James " "Roy in :gh:`126585`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1330 +#: ../../whatsnew/3.14.rst:1329 msgid "faulthandler" msgstr "faulthandler" -#: ../../whatsnew/3.14.rst:1332 +#: ../../whatsnew/3.14.rst:1331 msgid "" "Add support for printing the C stack trace on systems that :ref:`support it " "` via the new :func:`~faulthandler.dump_c_stack` " @@ -2026,38 +2026,38 @@ msgid "" "(Contributed by Peter Bierma in :gh:`127604`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1340 +#: ../../whatsnew/3.14.rst:1339 msgid "fnmatch" msgstr "fnmatch" -#: ../../whatsnew/3.14.rst:1342 +#: ../../whatsnew/3.14.rst:1341 msgid "" "Add :func:`~fnmatch.filterfalse`, a function to reject names matching a " "given pattern. (Contributed by Bénédikt Tran in :gh:`74598`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1348 +#: ../../whatsnew/3.14.rst:1347 msgid "fractions" msgstr "fractions" -#: ../../whatsnew/3.14.rst:1350 +#: ../../whatsnew/3.14.rst:1349 msgid "" "A :class:`~fractions.Fraction` object may now be constructed from any object " "with the :meth:`!as_integer_ratio` method. (Contributed by Serhiy Storchaka " "in :gh:`82017`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1354 +#: ../../whatsnew/3.14.rst:1353 msgid "" "Add :meth:`.Fraction.from_number` as an alternative constructor for :class:" "`~fractions.Fraction`. (Contributed by Serhiy Storchaka in :gh:`121797`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1360 +#: ../../whatsnew/3.14.rst:1359 msgid "functools" msgstr "functools" -#: ../../whatsnew/3.14.rst:1362 +#: ../../whatsnew/3.14.rst:1361 msgid "" "Add the :data:`~functools.Placeholder` sentinel. This may be used with the :" "func:`~functools.partial` or :func:`~functools.partialmethod` functions to " @@ -2066,33 +2066,33 @@ msgid "" "`119127`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1369 +#: ../../whatsnew/3.14.rst:1368 msgid "" "Allow the *initial* parameter of :func:`~functools.reduce` to be passed as a " "keyword argument. (Contributed by Sayandip Dutta in :gh:`125916`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1375 +#: ../../whatsnew/3.14.rst:1374 msgid "getopt" msgstr "getopt" -#: ../../whatsnew/3.14.rst:1377 +#: ../../whatsnew/3.14.rst:1376 msgid "" "Add support for options with optional arguments. (Contributed by Serhiy " "Storchaka in :gh:`126374`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1380 +#: ../../whatsnew/3.14.rst:1379 msgid "" "Add support for returning intermixed options and non-option arguments in " "order. (Contributed by Serhiy Storchaka in :gh:`126390`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1385 +#: ../../whatsnew/3.14.rst:1384 msgid "getpass" msgstr "getpass" -#: ../../whatsnew/3.14.rst:1387 +#: ../../whatsnew/3.14.rst:1386 msgid "" "Support keyboard feedback in the :func:`~getpass.getpass` function via the " "keyword-only optional argument *echo_char*. Placeholder characters are " @@ -2100,51 +2100,51 @@ msgid "" "deleted. (Contributed by Semyon Moroz in :gh:`77065`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1395 +#: ../../whatsnew/3.14.rst:1394 msgid "graphlib" msgstr "graphlib" -#: ../../whatsnew/3.14.rst:1397 +#: ../../whatsnew/3.14.rst:1396 msgid "" "Allow :meth:`.TopologicalSorter.prepare` to be called more than once as long " "as sorting has not started. (Contributed by Daniel Pope in :gh:`130914`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1403 +#: ../../whatsnew/3.14.rst:1402 msgid "heapq" msgstr "heapq" -#: ../../whatsnew/3.14.rst:1405 +#: ../../whatsnew/3.14.rst:1404 msgid "" "The :mod:`!heapq` module has improved support for working with max-heaps, " "via the following new functions:" msgstr "" -#: ../../whatsnew/3.14.rst:1408 +#: ../../whatsnew/3.14.rst:1407 msgid ":func:`~heapq.heapify_max`" msgstr ":func:`~heapq.heapify_max`" -#: ../../whatsnew/3.14.rst:1409 +#: ../../whatsnew/3.14.rst:1408 msgid ":func:`~heapq.heappush_max`" msgstr ":func:`~heapq.heappush_max`" -#: ../../whatsnew/3.14.rst:1410 +#: ../../whatsnew/3.14.rst:1409 msgid ":func:`~heapq.heappop_max`" msgstr ":func:`~heapq.heappop_max`" -#: ../../whatsnew/3.14.rst:1411 +#: ../../whatsnew/3.14.rst:1410 msgid ":func:`~heapq.heapreplace_max`" msgstr ":func:`~heapq.heapreplace_max`" -#: ../../whatsnew/3.14.rst:1412 +#: ../../whatsnew/3.14.rst:1411 msgid ":func:`~heapq.heappushpop_max`" msgstr ":func:`~heapq.heappushpop_max`" -#: ../../whatsnew/3.14.rst:1416 +#: ../../whatsnew/3.14.rst:1415 msgid "hmac" msgstr "hmac" -#: ../../whatsnew/3.14.rst:1418 +#: ../../whatsnew/3.14.rst:1417 msgid "" "Add a built-in implementation for HMAC (:rfc:`2104`) using formally verified " "code from the `HACL* `__ project. " @@ -2152,18 +2152,18 @@ msgid "" "HMAC is not available. (Contributed by Bénédikt Tran in :gh:`99108`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1426 +#: ../../whatsnew/3.14.rst:1425 msgid "http" msgstr "http" -#: ../../whatsnew/3.14.rst:1428 +#: ../../whatsnew/3.14.rst:1427 msgid "" "Directory lists and error pages generated by the :mod:`http.server` module " "allow the browser to apply its default dark mode. (Contributed by Yorik " "Hansen in :gh:`123430`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1432 +#: ../../whatsnew/3.14.rst:1431 msgid "" "The :mod:`http.server` module now supports serving over HTTPS using the :" "class:`http.server.HTTPSServer` class. This functionality is exposed by the " @@ -2171,74 +2171,74 @@ msgid "" "options:" msgstr "" -#: ../../whatsnew/3.14.rst:1437 +#: ../../whatsnew/3.14.rst:1436 msgid "" ":option:`--tls-cert \\ `: Path to the TLS " "certificate file." msgstr "" -#: ../../whatsnew/3.14.rst:1439 +#: ../../whatsnew/3.14.rst:1438 msgid "" ":option:`--tls-key \\ `: Optional path to the " "private key file." msgstr "" -#: ../../whatsnew/3.14.rst:1441 +#: ../../whatsnew/3.14.rst:1440 msgid "" ":option:`--tls-password-file \\ `: " "Optional path to the password file for the private key." msgstr "" -#: ../../whatsnew/3.14.rst:1444 +#: ../../whatsnew/3.14.rst:1443 msgid "(Contributed by Semyon Moroz in :gh:`85162`.)" msgstr "(由 Semyon Moroz 於 :gh:`85162` 貢獻。)" -#: ../../whatsnew/3.14.rst:1448 +#: ../../whatsnew/3.14.rst:1447 msgid "imaplib" msgstr "imaplib" -#: ../../whatsnew/3.14.rst:1450 +#: ../../whatsnew/3.14.rst:1449 msgid "" "Add :meth:`.IMAP4.idle`, implementing the IMAP4 ``IDLE`` command as defined " "in :rfc:`2177`. (Contributed by Forest in :gh:`55454`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1456 +#: ../../whatsnew/3.14.rst:1455 msgid "inspect" msgstr "inspect" -#: ../../whatsnew/3.14.rst:1458 +#: ../../whatsnew/3.14.rst:1457 msgid "" ":func:`~inspect.signature` takes a new argument *annotation_format* to " "control the :class:`annotationlib.Format` used for representing annotations. " "(Contributed by Jelle Zijlstra in :gh:`101552`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1462 +#: ../../whatsnew/3.14.rst:1461 msgid "" ":meth:`.Signature.format` takes a new argument *unquote_annotations*. If " "true, string :term:`annotations ` are displayed without " "surrounding quotes. (Contributed by Jelle Zijlstra in :gh:`101552`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1467 +#: ../../whatsnew/3.14.rst:1466 msgid "" "Add function :func:`~inspect.ispackage` to determine whether an object is a :" "term:`package` or not. (Contributed by Zhikang Yan in :gh:`125634`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1473 ../../whatsnew/3.14.rst:2271 +#: ../../whatsnew/3.14.rst:1472 ../../whatsnew/3.14.rst:2270 msgid "io" msgstr "io" -#: ../../whatsnew/3.14.rst:1475 +#: ../../whatsnew/3.14.rst:1474 msgid "" "Reading text from a non-blocking stream with ``read`` may now raise a :exc:" "`BlockingIOError` if the operation cannot immediately return bytes. " "(Contributed by Giovanni Siragusa in :gh:`109523`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1479 +#: ../../whatsnew/3.14.rst:1478 msgid "" "Add the :class:`~io.Reader` and :class:`~io.Writer` protocols as simpler " "alternatives to the pseudo-protocols :class:`typing.IO`, :class:`typing." @@ -2246,17 +2246,17 @@ msgid "" "gh:`127648`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1486 +#: ../../whatsnew/3.14.rst:1485 msgid "json" msgstr "json" -#: ../../whatsnew/3.14.rst:1488 +#: ../../whatsnew/3.14.rst:1487 msgid "" "Add exception notes for JSON serialization errors that allow identifying the " "source of the error. (Contributed by Serhiy Storchaka in :gh:`122163`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1492 +#: ../../whatsnew/3.14.rst:1491 msgid "" "Allow using the :mod:`json` module as a script using the :option:`-m` " "switch: :program:`python -m json`. This is now preferred to :program:`python " @@ -2265,7 +2265,7 @@ msgid "" "Hunner in :gh:`122873`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1499 +#: ../../whatsnew/3.14.rst:1498 msgid "" "By default, the output of the :ref:`JSON command-line interface ` is highlighted in color. This can be controlled by :ref:" @@ -2273,56 +2273,56 @@ msgid "" "Roun in :gh:`131952`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1507 +#: ../../whatsnew/3.14.rst:1506 msgid "linecache" msgstr "linecache" -#: ../../whatsnew/3.14.rst:1509 +#: ../../whatsnew/3.14.rst:1508 msgid "" ":func:`~linecache.getline` can now retrieve source code for frozen modules. " "(Contributed by Tian Gao in :gh:`131638`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1514 +#: ../../whatsnew/3.14.rst:1513 msgid "logging.handlers" msgstr "logging.handlers" -#: ../../whatsnew/3.14.rst:1516 +#: ../../whatsnew/3.14.rst:1515 msgid "" ":class:`~logging.handlers.QueueListener` objects now support the :term:" "`context manager` protocol. (Contributed by Charles Machalow in :gh:" "`132106`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1520 +#: ../../whatsnew/3.14.rst:1519 msgid "" ":meth:`QueueListener.start ` now " "raises a :exc:`RuntimeError` if the listener is already started. " "(Contributed by Charles Machalow in :gh:`132106`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1526 +#: ../../whatsnew/3.14.rst:1525 msgid "math" msgstr "math" -#: ../../whatsnew/3.14.rst:1528 +#: ../../whatsnew/3.14.rst:1527 msgid "" "Added more detailed error messages for domain errors in the module. " "(Contributed by Charlie Zhao and Sergey B Kirpichev in :gh:`101410`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1533 +#: ../../whatsnew/3.14.rst:1532 msgid "mimetypes" msgstr "mimetypes" -#: ../../whatsnew/3.14.rst:1535 +#: ../../whatsnew/3.14.rst:1534 msgid "" "Add a public :ref:`command-line ` for the module, invoked " "via :program:`python -m mimetypes`. (Contributed by Oleg Iarygin and Hugo " "van Kemenade in :gh:`93096`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1539 +#: ../../whatsnew/3.14.rst:1538 msgid "Add several new MIME types based on RFCs and common usage:" msgstr "" @@ -2330,23 +2330,23 @@ msgstr "" msgid "Microsoft and :rfc:`8081` MIME types for fonts" msgstr "" -#: ../../whatsnew/3.14.rst:1543 +#: ../../whatsnew/3.14.rst:1542 msgid "Embedded OpenType: ``application/vnd.ms-fontobject``" msgstr "" -#: ../../whatsnew/3.14.rst:1544 +#: ../../whatsnew/3.14.rst:1543 msgid "OpenType Layout (OTF) ``font/otf``" msgstr "" -#: ../../whatsnew/3.14.rst:1545 +#: ../../whatsnew/3.14.rst:1544 msgid "TrueType: ``font/ttf``" msgstr "" -#: ../../whatsnew/3.14.rst:1546 +#: ../../whatsnew/3.14.rst:1545 msgid "WOFF 1.0 ``font/woff``" msgstr "WOFF 1.0 ``font/woff``" -#: ../../whatsnew/3.14.rst:1547 +#: ../../whatsnew/3.14.rst:1546 msgid "WOFF 2.0 ``font/woff2``" msgstr "WOFF 2.0 ``font/woff2``" @@ -2355,15 +2355,15 @@ msgid "" ":rfc:`9559` MIME types for Matroska audiovisual data container structures" msgstr "" -#: ../../whatsnew/3.14.rst:1552 +#: ../../whatsnew/3.14.rst:1551 msgid "audio with no video: ``audio/matroska`` (``.mka``)" msgstr "" -#: ../../whatsnew/3.14.rst:1553 +#: ../../whatsnew/3.14.rst:1552 msgid "video: ``video/matroska`` (``.mkv``)" msgstr "" -#: ../../whatsnew/3.14.rst:1554 +#: ../../whatsnew/3.14.rst:1553 msgid "stereoscopic video: ``video/matroska-3d`` (``.mk3d``)" msgstr "" @@ -2371,29 +2371,29 @@ msgstr "" msgid "Images with RFCs" msgstr "" -#: ../../whatsnew/3.14.rst:1558 +#: ../../whatsnew/3.14.rst:1557 msgid ":rfc:`1494`: CCITT Group 3 (``.g3``)" msgstr ":rfc:`1494`: CCITT Group 3 (``.g3``)" -#: ../../whatsnew/3.14.rst:1559 +#: ../../whatsnew/3.14.rst:1558 msgid ":rfc:`3362`: Real-time Facsimile, T.38 (``.t38``)" msgstr "" -#: ../../whatsnew/3.14.rst:1560 +#: ../../whatsnew/3.14.rst:1559 msgid "" ":rfc:`3745`: JPEG 2000 (``.jp2``), extension (``.jpx``) and compound (``." "jpm``)" msgstr "" -#: ../../whatsnew/3.14.rst:1561 +#: ../../whatsnew/3.14.rst:1560 msgid ":rfc:`3950`: Tag Image File Format Fax eXtended, TIFF-FX (``.tfx``)" msgstr "" -#: ../../whatsnew/3.14.rst:1562 +#: ../../whatsnew/3.14.rst:1561 msgid ":rfc:`4047`: Flexible Image Transport System (``.fits``)" msgstr "" -#: ../../whatsnew/3.14.rst:1563 +#: ../../whatsnew/3.14.rst:1562 msgid "" ":rfc:`7903`: Enhanced Metafile (``.emf``) and Windows Metafile (``.wmf``)" msgstr "" @@ -2402,115 +2402,115 @@ msgstr "" msgid "Other MIME type additions and changes" msgstr "" -#: ../../whatsnew/3.14.rst:1567 +#: ../../whatsnew/3.14.rst:1566 msgid "" ":rfc:`2361`: Change type for ``.avi`` to ``video/vnd.avi`` and for ``.wav`` " "to ``audio/vnd.wave``" msgstr "" -#: ../../whatsnew/3.14.rst:1569 +#: ../../whatsnew/3.14.rst:1568 msgid ":rfc:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``)" msgstr "" -#: ../../whatsnew/3.14.rst:1570 +#: ../../whatsnew/3.14.rst:1569 msgid ":rfc:`5334`: Add Ogg media (``.oga``, ``.ogg`` and ``.ogx``)" msgstr "" -#: ../../whatsnew/3.14.rst:1571 +#: ../../whatsnew/3.14.rst:1570 msgid ":rfc:`6713`: Add gzip ``application/gzip`` (``.gz``)" msgstr "" -#: ../../whatsnew/3.14.rst:1572 +#: ../../whatsnew/3.14.rst:1571 msgid ":rfc:`9639`: Add FLAC ``audio/flac`` (``.flac``)" msgstr "" -#: ../../whatsnew/3.14.rst:1573 +#: ../../whatsnew/3.14.rst:1572 msgid "" ":rfc:`9512` ``application/yaml`` MIME type for YAML files (``.yaml`` and ``." "yml``)" msgstr "" -#: ../../whatsnew/3.14.rst:1575 +#: ../../whatsnew/3.14.rst:1574 msgid "Add 7z ``application/x-7z-compressed`` (``.7z``)" msgstr "" -#: ../../whatsnew/3.14.rst:1576 +#: ../../whatsnew/3.14.rst:1575 msgid "" "Add Android Package ``application/vnd.android.package-archive`` (``.apk``) " "when not strict" msgstr "" -#: ../../whatsnew/3.14.rst:1578 +#: ../../whatsnew/3.14.rst:1577 msgid "Add deb ``application/x-debian-package`` (``.deb``)" msgstr "" -#: ../../whatsnew/3.14.rst:1579 +#: ../../whatsnew/3.14.rst:1578 msgid "Add glTF binary ``model/gltf-binary`` (``.glb``)" msgstr "" -#: ../../whatsnew/3.14.rst:1580 +#: ../../whatsnew/3.14.rst:1579 msgid "Add glTF JSON/ASCII ``model/gltf+json`` (``.gltf``)" msgstr "" -#: ../../whatsnew/3.14.rst:1581 +#: ../../whatsnew/3.14.rst:1580 msgid "Add M4V ``video/x-m4v`` (``.m4v``)" msgstr "" -#: ../../whatsnew/3.14.rst:1582 +#: ../../whatsnew/3.14.rst:1581 msgid "Add PHP ``application/x-httpd-php`` (``.php``)" msgstr "" -#: ../../whatsnew/3.14.rst:1583 +#: ../../whatsnew/3.14.rst:1582 msgid "Add RAR ``application/vnd.rar`` (``.rar``)" msgstr "" -#: ../../whatsnew/3.14.rst:1584 +#: ../../whatsnew/3.14.rst:1583 msgid "Add RPM ``application/x-rpm`` (``.rpm``)" msgstr "" -#: ../../whatsnew/3.14.rst:1585 +#: ../../whatsnew/3.14.rst:1584 msgid "Add STL ``model/stl`` (``.stl``)" msgstr "" -#: ../../whatsnew/3.14.rst:1586 +#: ../../whatsnew/3.14.rst:1585 msgid "Add Windows Media Video ``video/x-ms-wmv`` (``.wmv``)" msgstr "" -#: ../../whatsnew/3.14.rst:1587 +#: ../../whatsnew/3.14.rst:1586 msgid "De facto: Add WebM ``audio/webm`` (``.weba``)" msgstr "" -#: ../../whatsnew/3.14.rst:1588 +#: ../../whatsnew/3.14.rst:1587 msgid "" "`ECMA-376 `__: Add ``.docx``, ``.pptx`` and ``.xlsx`` types" msgstr "" -#: ../../whatsnew/3.14.rst:1591 +#: ../../whatsnew/3.14.rst:1590 msgid "" "`OASIS `__: Add OpenDocument ``.odg``, ``.odp``, ``.ods`` and " "``.odt`` types" msgstr "" -#: ../../whatsnew/3.14.rst:1594 +#: ../../whatsnew/3.14.rst:1593 msgid "" "`W3C `__: Add EPUB " "``application/epub+zip`` (``.epub``)" msgstr "" -#: ../../whatsnew/3.14.rst:1597 +#: ../../whatsnew/3.14.rst:1596 msgid "" "(Contributed by Sahil Prajapati and Hugo van Kemenade in :gh:`84852`, by " "Sasha \"Nelie\" Chernykh and Hugo van Kemenade in :gh:`132056`, and by Hugo " "van Kemenade in :gh:`89416`, :gh:`85957`, and :gh:`129965`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1603 +#: ../../whatsnew/3.14.rst:1602 msgid "multiprocessing" msgstr "multiprocessing" -#: ../../whatsnew/3.14.rst:1607 +#: ../../whatsnew/3.14.rst:1606 msgid "" "On Unix platforms other than macOS, :ref:`'forkserver' ` is now the default :ref:`start method " @@ -2520,7 +2520,7 @@ msgid "" "method." msgstr "" -#: ../../whatsnew/3.14.rst:1614 +#: ../../whatsnew/3.14.rst:1613 msgid "" "If the threading incompatible *fork* method is required, you must explicitly " "request it via a context from :func:`~multiprocessing.get_context` " @@ -2528,7 +2528,7 @@ msgid "" "set_start_method`." msgstr "" -#: ../../whatsnew/3.14.rst:1625 +#: ../../whatsnew/3.14.rst:1624 msgid "" ":mod:`multiprocessing`'s ``'forkserver'`` start method now authenticates its " "control socket to avoid solely relying on filesystem permissions to restrict " @@ -2536,34 +2536,34 @@ msgid "" "code. (Contributed by Gregory P. Smith for :gh:`97514`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1631 +#: ../../whatsnew/3.14.rst:1630 msgid "" "The :ref:`multiprocessing proxy objects ` for " "*list* and *dict* types gain previously overlooked missing methods:" msgstr "" -#: ../../whatsnew/3.14.rst:1634 +#: ../../whatsnew/3.14.rst:1633 msgid ":meth:`!clear` and :meth:`!copy` for proxies of :class:`list`" msgstr "" -#: ../../whatsnew/3.14.rst:1635 +#: ../../whatsnew/3.14.rst:1634 msgid "" ":meth:`~dict.fromkeys`, ``reversed(d)``, ``d | {}``, ``{} | d``, ``d |= " "{'b': 2}`` for proxies of :class:`dict`" msgstr "" -#: ../../whatsnew/3.14.rst:1638 +#: ../../whatsnew/3.14.rst:1637 msgid "(Contributed by Roy Hyunjin Han for :gh:`103134`.)" msgstr "(由 Roy Hyunjin Han 於 :gh:`103134` 貢獻。)" -#: ../../whatsnew/3.14.rst:1640 +#: ../../whatsnew/3.14.rst:1639 msgid "" "Add support for shared :class:`set` objects via :meth:`.SyncManager.set`. " "The :func:`set` in :func:`~multiprocessing.Manager` method is now available. " "(Contributed by Mingyu Park in :gh:`129949`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1645 +#: ../../whatsnew/3.14.rst:1644 msgid "" "Add the :meth:`~multiprocessing.Process.interrupt` to :class:" "`multiprocessing.Process` objects, which terminates the child process by " @@ -2572,11 +2572,11 @@ msgid "" "Pulkin in :gh:`131913`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1653 +#: ../../whatsnew/3.14.rst:1652 msgid "operator" msgstr "operator" -#: ../../whatsnew/3.14.rst:1655 +#: ../../whatsnew/3.14.rst:1654 msgid "" "Add :func:`~operator.is_none` and :func:`~operator.is_not_none` as a pair of " "functions, such that ``operator.is_none(obj)`` is equivalent to ``obj is " @@ -2584,11 +2584,11 @@ msgid "" "None``. (Contributed by Raymond Hettinger and Nico Mexis in :gh:`115808`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1663 +#: ../../whatsnew/3.14.rst:1662 msgid "os" msgstr "os" -#: ../../whatsnew/3.14.rst:1665 +#: ../../whatsnew/3.14.rst:1664 msgid "" "Add the :func:`~os.reload_environ` function to update :data:`os.environ` " "and :data:`os.environb` with changes to the environment made by :func:`os." @@ -2596,24 +2596,24 @@ msgid "" "(Contributed by Victor Stinner in :gh:`120057`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1671 +#: ../../whatsnew/3.14.rst:1670 msgid "" "Add the :data:`~os.SCHED_DEADLINE` and :data:`~os.SCHED_NORMAL` constants to " "the :mod:`!os` module. (Contributed by James Roy in :gh:`127688`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1675 +#: ../../whatsnew/3.14.rst:1674 msgid "" "Add the :func:`~os.readinto` function to read into a :ref:`buffer object " "` from a file descriptor. (Contributed by Cody Maloney in :gh:" "`129205`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1681 +#: ../../whatsnew/3.14.rst:1680 msgid "os.path" msgstr "os.path" -#: ../../whatsnew/3.14.rst:1683 +#: ../../whatsnew/3.14.rst:1682 msgid "" "The *strict* parameter to :func:`~os.path.realpath` accepts a new value, :" "data:`~os.path.ALLOW_MISSING`. If used, errors other than :exc:" @@ -2622,40 +2622,40 @@ msgid "" "`2025-4517`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1691 ../../whatsnew/3.14.rst:2280 -#: ../../whatsnew/3.14.rst:2541 +#: ../../whatsnew/3.14.rst:1690 ../../whatsnew/3.14.rst:2279 +#: ../../whatsnew/3.14.rst:2540 msgid "pathlib" msgstr "pathlib" -#: ../../whatsnew/3.14.rst:1693 +#: ../../whatsnew/3.14.rst:1692 msgid "" "Add methods to :class:`pathlib.Path` to recursively copy or move files and " "directories:" msgstr "" -#: ../../whatsnew/3.14.rst:1696 +#: ../../whatsnew/3.14.rst:1695 msgid "" ":meth:`~pathlib.Path.copy` copies a file or directory tree to a destination." msgstr "" -#: ../../whatsnew/3.14.rst:1697 +#: ../../whatsnew/3.14.rst:1696 msgid ":meth:`~pathlib.Path.copy_into` copies *into* a destination directory." msgstr "" -#: ../../whatsnew/3.14.rst:1698 +#: ../../whatsnew/3.14.rst:1697 msgid "" ":meth:`~pathlib.Path.move` moves a file or directory tree to a destination." msgstr "" -#: ../../whatsnew/3.14.rst:1699 +#: ../../whatsnew/3.14.rst:1698 msgid ":meth:`~pathlib.Path.move_into` moves *into* a destination directory." msgstr "" -#: ../../whatsnew/3.14.rst:1701 +#: ../../whatsnew/3.14.rst:1700 msgid "(Contributed by Barney Gale in :gh:`73991`.)" msgstr "(由 Barney Gale 於 :gh:`73991` 貢獻。)" -#: ../../whatsnew/3.14.rst:1703 +#: ../../whatsnew/3.14.rst:1702 msgid "" "Add the :attr:`~pathlib.Path.info` attribute, which stores an object " "implementing the new :class:`pathlib.types.PathInfo` protocol. The object " @@ -2665,21 +2665,21 @@ msgid "" "directory. (Contributed by Barney Gale in :gh:`125413`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1713 ../../whatsnew/3.14.rst:2288 +#: ../../whatsnew/3.14.rst:1712 ../../whatsnew/3.14.rst:2287 msgid "pdb" msgstr "pdb" -#: ../../whatsnew/3.14.rst:1715 +#: ../../whatsnew/3.14.rst:1714 msgid "" "The :mod:`pdb` module now supports remote attaching to a running Python " "process using a new :option:`-p PID ` command-line option:" msgstr "" -#: ../../whatsnew/3.14.rst:1718 +#: ../../whatsnew/3.14.rst:1717 msgid "python -m pdb -p 1234" msgstr "python -m pdb -p 1234" -#: ../../whatsnew/3.14.rst:1722 +#: ../../whatsnew/3.14.rst:1721 msgid "" "This will connect to the Python process with the given PID and allow you to " "debug it interactively. Notice that due to how the Python interpreter works " @@ -2688,18 +2688,18 @@ msgid "" "when the process receives a signal." msgstr "" -#: ../../whatsnew/3.14.rst:1728 +#: ../../whatsnew/3.14.rst:1727 msgid "" "This feature uses :ref:`PEP 768 ` and the new :" "func:`sys.remote_exec` function to attach to the remote process and send the " "PDB commands to it." msgstr "" -#: ../../whatsnew/3.14.rst:1732 +#: ../../whatsnew/3.14.rst:1731 msgid "(Contributed by Matt Wozniski and Pablo Galindo in :gh:`131591`.)" msgstr "(由 Matt Wozniski and Pablo Galindo 於 :gh:`131591` 貢獻。)" -#: ../../whatsnew/3.14.rst:1734 +#: ../../whatsnew/3.14.rst:1733 msgid "" "Hardcoded breakpoints (:func:`breakpoint` and :func:`~pdb.set_trace`) now " "reuse the most recent :class:`~pdb.Pdb` instance that calls :meth:`~pdb.Pdb." @@ -2709,14 +2709,14 @@ msgid "" "`121450`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1741 +#: ../../whatsnew/3.14.rst:1740 msgid "" "Add a new argument *mode* to :class:`pdb.Pdb`. Disable the ``restart`` " "command when :mod:`pdb` is in ``inline`` mode. (Contributed by Tian Gao in :" "gh:`123757`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1745 +#: ../../whatsnew/3.14.rst:1744 msgid "" "A confirmation prompt will be shown when the user tries to quit :mod:`pdb` " "in ``inline`` mode. ``y``, ``Y``, ```` or ``EOF`` will confirm the " @@ -2724,41 +2724,41 @@ msgid "" "(Contributed by Tian Gao in :gh:`124704`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1750 +#: ../../whatsnew/3.14.rst:1749 msgid "" "Inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` will " "always stop the program at calling frame, ignoring the ``skip`` pattern (if " "any). (Contributed by Tian Gao in :gh:`130493`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1755 +#: ../../whatsnew/3.14.rst:1754 msgid "" "```` at the beginning of the line in :mod:`pdb` multi-line input will " "fill in a 4-space indentation now, instead of inserting a ``\\t`` character. " "(Contributed by Tian Gao in :gh:`130471`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1759 +#: ../../whatsnew/3.14.rst:1758 msgid "" "Auto-indent is introduced in :mod:`pdb` multi-line input. It will either " "keep the indentation of the last line or insert a 4-space indentation when " "it detects a new code block. (Contributed by Tian Gao in :gh:`133350`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1764 +#: ../../whatsnew/3.14.rst:1763 msgid "" "``$_asynctask`` is added to access the current asyncio task if applicable. " "(Contributed by Tian Gao in :gh:`124367`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1767 +#: ../../whatsnew/3.14.rst:1766 msgid "" ":func:`pdb.set_trace_async` is added to support debugging asyncio " "coroutines. :keyword:`await` statements are supported with this function. " "(Contributed by Tian Gao in :gh:`132576`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1772 +#: ../../whatsnew/3.14.rst:1771 msgid "" "Source code displayed in :mod:`pdb` will be syntax-highlighted. This feature " "can be controlled using the same methods as the default :term:`interactive` " @@ -2766,49 +2766,49 @@ msgid "" "Pdb`. (Contributed by Tian Gao and Łukasz Langa in :gh:`133355`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1779 +#: ../../whatsnew/3.14.rst:1778 msgid "pickle" msgstr "pickle" -#: ../../whatsnew/3.14.rst:1781 +#: ../../whatsnew/3.14.rst:1780 msgid "" "Set the default protocol version on the :mod:`pickle` module to 5. For more " "details, see :ref:`pickle protocols `." msgstr "" -#: ../../whatsnew/3.14.rst:1784 +#: ../../whatsnew/3.14.rst:1783 msgid "" "Add exception notes for pickle serialization errors that allow identifying " "the source of the error. (Contributed by Serhiy Storchaka in :gh:`122213`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1790 +#: ../../whatsnew/3.14.rst:1789 msgid "platform" msgstr "platform" -#: ../../whatsnew/3.14.rst:1792 +#: ../../whatsnew/3.14.rst:1791 msgid "" "Add :func:`~platform.invalidate_caches`, a function to invalidate cached " "results in the :mod:`!platform` module. (Contributed by Bénédikt Tran in :gh:" "`122549`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1798 +#: ../../whatsnew/3.14.rst:1797 msgid "pydoc" msgstr "pydoc" -#: ../../whatsnew/3.14.rst:1800 +#: ../../whatsnew/3.14.rst:1799 msgid "" ":term:`Annotations ` in help output are now usually displayed in " "a format closer to that in the original source. (Contributed by Jelle " "Zijlstra in :gh:`101552`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1806 +#: ../../whatsnew/3.14.rst:1805 msgid "re" msgstr "re" -#: ../../whatsnew/3.14.rst:1808 +#: ../../whatsnew/3.14.rst:1807 msgid "" "Support ``\\z`` as a synonym for ``\\Z`` in :mod:`regular expressions `. " "It is interpreted unambiguously in many other regular expression engines, " @@ -2816,119 +2816,119 @@ msgid "" "Storchaka in :gh:`133306`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1813 +#: ../../whatsnew/3.14.rst:1812 msgid "" "``\\B`` in :mod:`regular expression ` now matches the empty input " "string, meaning that it is now always the opposite of ``\\b``. (Contributed " "by Serhiy Storchaka in :gh:`124130`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1819 +#: ../../whatsnew/3.14.rst:1818 msgid "socket" msgstr "socket" -#: ../../whatsnew/3.14.rst:1821 +#: ../../whatsnew/3.14.rst:1820 msgid "Improve and fix support for Bluetooth sockets." msgstr "" -#: ../../whatsnew/3.14.rst:1823 +#: ../../whatsnew/3.14.rst:1822 msgid "" "Fix support of Bluetooth sockets on NetBSD and DragonFly BSD. (Contributed " "by Serhiy Storchaka in :gh:`132429`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1825 +#: ../../whatsnew/3.14.rst:1824 msgid "" "Fix support for :const:`~socket.BTPROTO_HCI` on FreeBSD. (Contributed by " "Victor Stinner in :gh:`111178`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1827 +#: ../../whatsnew/3.14.rst:1826 msgid "" "Add support for :const:`~socket.BTPROTO_SCO` on FreeBSD. (Contributed by " "Serhiy Storchaka in :gh:`85302`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1829 +#: ../../whatsnew/3.14.rst:1828 msgid "" "Add support for *cid* and *bdaddr_type* in the address for :const:`~socket." "BTPROTO_L2CAP` on FreeBSD. (Contributed by Serhiy Storchaka in :gh:`132429`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1832 +#: ../../whatsnew/3.14.rst:1831 msgid "" "Add support for *channel* in the address for :const:`~socket.BTPROTO_HCI` on " "Linux. (Contributed by Serhiy Storchaka in :gh:`70145`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1835 +#: ../../whatsnew/3.14.rst:1834 msgid "" "Accept an integer as the address for :const:`~socket.BTPROTO_HCI` on Linux. " "(Contributed by Serhiy Storchaka in :gh:`132099`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1838 +#: ../../whatsnew/3.14.rst:1837 msgid "" "Return *cid* in :meth:`~socket.socket.getsockname` for :const:`~socket." "BTPROTO_L2CAP`. (Contributed by Serhiy Storchaka in :gh:`132429`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1841 +#: ../../whatsnew/3.14.rst:1840 msgid "" "Add many new constants. (Contributed by Serhiy Storchaka in :gh:`132734`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1846 +#: ../../whatsnew/3.14.rst:1845 msgid "ssl" msgstr "ssl" -#: ../../whatsnew/3.14.rst:1848 +#: ../../whatsnew/3.14.rst:1847 msgid "" "Indicate through the :data:`~ssl.HAS_PHA` Boolean whether the :mod:`!ssl` " "module supports TLSv1.3 post-handshake client authentication (PHA). " "(Contributed by Will Childs-Klein in :gh:`128036`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1854 +#: ../../whatsnew/3.14.rst:1853 msgid "struct" msgstr "struct" -#: ../../whatsnew/3.14.rst:1856 +#: ../../whatsnew/3.14.rst:1855 msgid "" "Support the :c:expr:`float complex` and :c:expr:`double complex` C types in " "the :mod:`struct` module (formatting characters ``'F'`` and ``'D'`` " "respectively). (Contributed by Sergey B Kirpichev in :gh:`121249`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1863 +#: ../../whatsnew/3.14.rst:1862 msgid "symtable" msgstr "symtable" -#: ../../whatsnew/3.14.rst:1865 +#: ../../whatsnew/3.14.rst:1864 msgid "Expose the following :class:`~symtable.Symbol` methods:" msgstr "" -#: ../../whatsnew/3.14.rst:1867 +#: ../../whatsnew/3.14.rst:1866 msgid ":meth:`~symtable.Symbol.is_comp_cell`" msgstr ":meth:`~symtable.Symbol.is_comp_cell`" -#: ../../whatsnew/3.14.rst:1868 +#: ../../whatsnew/3.14.rst:1867 msgid ":meth:`~symtable.Symbol.is_comp_iter`" msgstr ":meth:`~symtable.Symbol.is_comp_iter`" -#: ../../whatsnew/3.14.rst:1869 +#: ../../whatsnew/3.14.rst:1868 msgid ":meth:`~symtable.Symbol.is_free_class`" msgstr ":meth:`~symtable.Symbol.is_free_class`" -#: ../../whatsnew/3.14.rst:1871 +#: ../../whatsnew/3.14.rst:1870 msgid "(Contributed by Bénédikt Tran in :gh:`120029`.)" msgstr "(由 Bénédikt Tran 於 :gh:`120029` 貢獻。)" -#: ../../whatsnew/3.14.rst:1875 +#: ../../whatsnew/3.14.rst:1874 msgid "sys" msgstr "sys" -#: ../../whatsnew/3.14.rst:1877 +#: ../../whatsnew/3.14.rst:1876 msgid "" "The previously undocumented special function :func:`sys.getobjects`, which " "only exists in specialized builds of Python, may now return objects from " @@ -2936,26 +2936,26 @@ msgid "" "in :gh:`125286`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1882 +#: ../../whatsnew/3.14.rst:1881 msgid "" "Add :func:`sys._is_immortal` for determining if an object is :term:" "`immortal`. (Contributed by Peter Bierma in :gh:`128509`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1885 +#: ../../whatsnew/3.14.rst:1884 msgid "" "On FreeBSD, :data:`sys.platform` no longer contains the major version " "number. It is always ``'freebsd'``, instead of ``'freebsd13'`` or " "``'freebsd14'``. (Contributed by Michael Osipov in :gh:`129393`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1889 +#: ../../whatsnew/3.14.rst:1888 msgid "" "Raise :exc:`DeprecationWarning` for :func:`sys._clear_type_cache`. This " "function was deprecated in Python 3.13 but it didn't raise a runtime warning." msgstr "" -#: ../../whatsnew/3.14.rst:1892 +#: ../../whatsnew/3.14.rst:1891 msgid "" "Add :func:`sys.remote_exec` to implement the new external debugger " "interface. See :ref:`PEP 768 ` for details. " @@ -2963,24 +2963,24 @@ msgid "" "in :gh:`131591`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1897 +#: ../../whatsnew/3.14.rst:1896 msgid "" "Add the :data:`sys._jit` namespace, containing utilities for introspecting " "just-in-time compilation. (Contributed by Brandt Bucher in :gh:`133231`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1903 +#: ../../whatsnew/3.14.rst:1902 msgid "sys.monitoring" msgstr "sys.monitoring" -#: ../../whatsnew/3.14.rst:1905 +#: ../../whatsnew/3.14.rst:1904 msgid "" "Add two new monitoring events, :monitoring-event:`BRANCH_LEFT` and :" "monitoring-event:`BRANCH_RIGHT`. These replace and deprecate the :monitoring-" "event:`!BRANCH` event. (Contributed by Mark Shannon in :gh:`122548`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1910 +#: ../../whatsnew/3.14.rst:1909 msgid "" "Add :func:`sys.monitoring.clear_tool_id` to unregister all events and " "callback functions associated with a tool identifier. :func:`sys.monitoring." @@ -2989,35 +2989,35 @@ msgid "" "`116750`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1918 +#: ../../whatsnew/3.14.rst:1917 msgid "sysconfig" msgstr "sysconfig" -#: ../../whatsnew/3.14.rst:1920 +#: ../../whatsnew/3.14.rst:1919 msgid "" "Add ``ABIFLAGS`` key to :func:`~sysconfig.get_config_vars` on Windows. " "(Contributed by Xuehai Pan in :gh:`131799`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1925 +#: ../../whatsnew/3.14.rst:1924 msgid "tarfile" msgstr "tarfile" -#: ../../whatsnew/3.14.rst:1927 +#: ../../whatsnew/3.14.rst:1926 msgid "" ":func:`~tarfile.data_filter` now normalizes symbolic link targets in order " "to avoid path traversal attacks. (Contributed by Petr Viktorin in :gh:" "`127987` and :cve:`2025-4138`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1931 +#: ../../whatsnew/3.14.rst:1930 msgid "" ":func:`~tarfile.TarFile.extractall` now skips fixing up directory attributes " "when a directory was removed or replaced by another kind of file. " "(Contributed by Petr Viktorin in :gh:`127987` and :cve:`2024-12718`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1935 +#: ../../whatsnew/3.14.rst:1934 msgid "" ":func:`~tarfile.TarFile.extract` and :func:`~tarfile.TarFile.extractall` now " "(re-)apply the extraction filter when substituting a link (hard or symbolic) " @@ -3027,7 +3027,7 @@ msgid "" "cve:`2024-12718`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1942 +#: ../../whatsnew/3.14.rst:1941 msgid "" ":func:`~tarfile.TarFile.extract` and :func:`~tarfile.TarFile.extractall` no " "longer extract rejected members when :func:`~tarfile.TarFile.errorlevel` is " @@ -3035,59 +3035,59 @@ msgid "" "cve:`2025-4435`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1950 +#: ../../whatsnew/3.14.rst:1949 msgid "threading" msgstr "threading" -#: ../../whatsnew/3.14.rst:1952 +#: ../../whatsnew/3.14.rst:1951 msgid "" ":meth:`threading.Thread.start` now sets the operating system thread name to :" "attr:`threading.Thread.name`. (Contributed by Victor Stinner in :gh:`59705`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1958 +#: ../../whatsnew/3.14.rst:1957 msgid "tkinter" msgstr "tkinter" -#: ../../whatsnew/3.14.rst:1960 +#: ../../whatsnew/3.14.rst:1959 msgid "" "Make :mod:`tkinter` widget methods :meth:`!after` and :meth:`!after_idle` " "accept keyword arguments. (Contributed by Zhikang Yan in :gh:`126899`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1964 +#: ../../whatsnew/3.14.rst:1963 msgid "" "Add ability to specify a name for :class:`!tkinter.OptionMenu` and :class:`!" "tkinter.ttk.OptionMenu`. (Contributed by Zhikang Yan in :gh:`130482`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1970 +#: ../../whatsnew/3.14.rst:1969 msgid "turtle" msgstr "turtle" -#: ../../whatsnew/3.14.rst:1972 +#: ../../whatsnew/3.14.rst:1971 msgid "" "Add context managers for :func:`turtle.fill`, :func:`turtle.poly`, and :func:" "`turtle.no_animation`. (Contributed by Marie Roald and Yngve Mardal Moe in :" "gh:`126350`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1978 +#: ../../whatsnew/3.14.rst:1977 msgid "types" msgstr "types" -#: ../../whatsnew/3.14.rst:1980 +#: ../../whatsnew/3.14.rst:1979 msgid "" ":class:`types.UnionType` is now an alias for :class:`typing.Union`. See :ref:" "`below ` for more details. (Contributed by Jelle " "Zijlstra in :gh:`105499`.)" msgstr "" -#: ../../whatsnew/3.14.rst:1986 +#: ../../whatsnew/3.14.rst:1985 msgid "typing" msgstr "typing" -#: ../../whatsnew/3.14.rst:1990 +#: ../../whatsnew/3.14.rst:1989 msgid "" "The :class:`types.UnionType` and :class:`typing.Union` types are now aliases " "for each other, meaning that both old-style unions (created with " @@ -3097,14 +3097,14 @@ msgid "" "users who introspect types at runtime:" msgstr "" -#: ../../whatsnew/3.14.rst:1997 +#: ../../whatsnew/3.14.rst:1996 msgid "" "Both syntaxes for creating a union now produce the same string " "representation in :func:`repr`. For example, ``repr(Union[int, str])`` is " "now ``\"int | str\"`` instead of ``\"typing.Union[int, str]\"``." msgstr "" -#: ../../whatsnew/3.14.rst:2002 +#: ../../whatsnew/3.14.rst:2001 msgid "" "Unions created using the old syntax are no longer cached. Previously, " "running ``Union[int, str]`` multiple times would return the same object " @@ -3121,7 +3121,7 @@ msgid "" "memory usage for most users." msgstr "" -#: ../../whatsnew/3.14.rst:2018 +#: ../../whatsnew/3.14.rst:2017 msgid "" "Previously, old-style unions were implemented using the private class " "``typing._UnionGenericAlias``. This class is no longer needed for the " @@ -3135,80 +3135,80 @@ msgstr "" "改用文件中記錄的自我檢查輔助函式,例如 :func:`~typing.get_origin` 和 :func:" "`typing.get_args`,或者依賴私有實作細節。" -#: ../../whatsnew/3.14.rst:2027 +#: ../../whatsnew/3.14.rst:2026 msgid "" "It is now possible to use :class:`typing.Union` itself in :func:`isinstance` " "checks. For example, ``isinstance(int | str, typing.Union)`` will return " "``True``; previously this raised :exc:`TypeError`." msgstr "" -#: ../../whatsnew/3.14.rst:2032 +#: ../../whatsnew/3.14.rst:2031 msgid "" "The :attr:`!__args__` attribute of :class:`typing.Union` objects is no " "longer writable." msgstr "" -#: ../../whatsnew/3.14.rst:2035 +#: ../../whatsnew/3.14.rst:2034 msgid "" "It is no longer possible to set any attributes on :class:`~typing.Union` " "objects. This only ever worked for dunder attributes on previous versions, " "was never documented to work, and was subtly broken in many cases." msgstr "" -#: ../../whatsnew/3.14.rst:2040 +#: ../../whatsnew/3.14.rst:2039 msgid "(Contributed by Jelle Zijlstra in :gh:`105499`.)" msgstr "(由 Jelle Zijlstra 於 :gh:`105499` 貢獻。)" -#: ../../whatsnew/3.14.rst:2042 +#: ../../whatsnew/3.14.rst:2041 msgid ":class:`~typing.TypeAliasType` now supports star unpacking." msgstr "" -#: ../../whatsnew/3.14.rst:2046 +#: ../../whatsnew/3.14.rst:2045 msgid "unicodedata" msgstr "unicodedata" -#: ../../whatsnew/3.14.rst:2048 +#: ../../whatsnew/3.14.rst:2047 msgid "The Unicode database has been updated to Unicode 16.0.0." msgstr "" -#: ../../whatsnew/3.14.rst:2052 +#: ../../whatsnew/3.14.rst:2051 msgid "unittest" msgstr "unittest" -#: ../../whatsnew/3.14.rst:2056 +#: ../../whatsnew/3.14.rst:2055 msgid "" ":mod:`unittest` output is now colored by default. This can be controlled by :" "ref:`environment variables `. (Contributed by " "Hugo van Kemenade in :gh:`127221`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2061 +#: ../../whatsnew/3.14.rst:2060 msgid "" "unittest discovery supports :term:`namespace package` as start directory " "again. It was removed in Python 3.11. (Contributed by Jacob Walls in :gh:" "`80958`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2065 +#: ../../whatsnew/3.14.rst:2064 msgid "" "A number of new methods were added in the :class:`~unittest.TestCase` class " "that provide more specialized tests." msgstr "" -#: ../../whatsnew/3.14.rst:2068 +#: ../../whatsnew/3.14.rst:2067 msgid "" ":meth:`~unittest.TestCase.assertHasAttr` and :meth:`~unittest.TestCase." "assertNotHasAttr` check whether the object has a particular attribute." msgstr "" -#: ../../whatsnew/3.14.rst:2071 +#: ../../whatsnew/3.14.rst:2070 msgid "" ":meth:`~unittest.TestCase.assertIsSubclass` and :meth:`~unittest.TestCase." "assertNotIsSubclass` check whether the object is a subclass of a particular " "class, or of one of a tuple of classes." msgstr "" -#: ../../whatsnew/3.14.rst:2074 +#: ../../whatsnew/3.14.rst:2073 msgid "" ":meth:`~unittest.TestCase.assertStartsWith`, :meth:`~unittest.TestCase." "assertNotStartsWith`, :meth:`~unittest.TestCase.assertEndsWith` and :meth:" @@ -3216,129 +3216,129 @@ msgid "" "string starts or ends with particular strings." msgstr "" -#: ../../whatsnew/3.14.rst:2080 +#: ../../whatsnew/3.14.rst:2079 msgid "(Contributed by Serhiy Storchaka in :gh:`71339`.)" msgstr "(由 Serhiy Storchaka 於 :gh:`71339` 貢獻。)" -#: ../../whatsnew/3.14.rst:2084 ../../whatsnew/3.14.rst:2587 +#: ../../whatsnew/3.14.rst:2083 ../../whatsnew/3.14.rst:2586 msgid "urllib" msgstr "urllib" -#: ../../whatsnew/3.14.rst:2086 +#: ../../whatsnew/3.14.rst:2085 msgid "" "Upgrade HTTP digest authentication algorithm for :mod:`urllib.request` by " "supporting SHA-256 digest authentication as specified in :rfc:`7616`. " "(Contributed by Calvin Bui in :gh:`128193`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2090 +#: ../../whatsnew/3.14.rst:2089 msgid "" "Improve ergonomics and standards compliance when parsing and emitting ``file:" "`` URLs." msgstr "" -#: ../../whatsnew/3.14.rst:2093 +#: ../../whatsnew/3.14.rst:2092 msgid "In :func:`~urllib.request.url2pathname`:" msgstr "" -#: ../../whatsnew/3.14.rst:2095 +#: ../../whatsnew/3.14.rst:2094 msgid "" "Accept a complete URL when the new *require_scheme* argument is set to true." msgstr "" -#: ../../whatsnew/3.14.rst:2097 +#: ../../whatsnew/3.14.rst:2096 msgid "Discard URL authority if it matches the local hostname." msgstr "" -#: ../../whatsnew/3.14.rst:2098 +#: ../../whatsnew/3.14.rst:2097 msgid "" "Discard URL authority if it resolves to a local IP address when the new " "*resolve_host* argument is set to true." msgstr "" -#: ../../whatsnew/3.14.rst:2100 +#: ../../whatsnew/3.14.rst:2099 msgid "Discard URL query and fragment components." msgstr "" -#: ../../whatsnew/3.14.rst:2101 +#: ../../whatsnew/3.14.rst:2100 msgid "" "Raise :exc:`~urllib.error.URLError` if a URL authority isn't local, except " "on Windows where we return a UNC path as before." msgstr "" -#: ../../whatsnew/3.14.rst:2104 +#: ../../whatsnew/3.14.rst:2103 msgid "In :func:`~urllib.request.pathname2url`:" msgstr "" -#: ../../whatsnew/3.14.rst:2106 +#: ../../whatsnew/3.14.rst:2105 msgid "" "Return a complete URL when the new *add_scheme* argument is set to true." msgstr "" -#: ../../whatsnew/3.14.rst:2107 +#: ../../whatsnew/3.14.rst:2106 msgid "" "Include an empty URL authority when a path begins with a slash. For example, " "the path ``/etc/hosts`` is converted to the URL ``///etc/hosts``." msgstr "" -#: ../../whatsnew/3.14.rst:2110 +#: ../../whatsnew/3.14.rst:2109 msgid "" "On Windows, drive letters are no longer converted to uppercase, and ``:`` " "characters not following a drive letter no longer cause an :exc:`OSError` " "exception to be raised." msgstr "" -#: ../../whatsnew/3.14.rst:2114 +#: ../../whatsnew/3.14.rst:2113 msgid "(Contributed by Barney Gale in :gh:`125866`.)" msgstr "(由 Barney Gale 於 :gh:`125866` 貢獻。)" -#: ../../whatsnew/3.14.rst:2118 ../../whatsnew/3.14.rst:2309 +#: ../../whatsnew/3.14.rst:2117 ../../whatsnew/3.14.rst:2308 msgid "uuid" msgstr "uuid" -#: ../../whatsnew/3.14.rst:2120 +#: ../../whatsnew/3.14.rst:2119 msgid "" "Add support for UUID versions 6, 7, and 8 via :func:`~uuid.uuid6`, :func:" "`~uuid.uuid7`, and :func:`~uuid.uuid8` respectively, as specified in :rfc:" "`9562`. (Contributed by Bénédikt Tran in :gh:`89083`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2125 +#: ../../whatsnew/3.14.rst:2124 msgid "" ":const:`~uuid.NIL` and :const:`~uuid.MAX` are now available to represent the " "Nil and Max UUID formats as defined by :rfc:`9562`. (Contributed by Nick " "Pope in :gh:`128427`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2129 +#: ../../whatsnew/3.14.rst:2128 msgid "" "Allow generating multiple UUIDs simultaneously on the command-line via :" "option:`python -m uuid --count `. (Contributed by Simon Legner " "in :gh:`131236`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2135 +#: ../../whatsnew/3.14.rst:2134 msgid "webbrowser" msgstr "webbrowser" -#: ../../whatsnew/3.14.rst:2137 +#: ../../whatsnew/3.14.rst:2136 msgid "" "Names in the :envvar:`BROWSER` environment variable can now refer to already " "registered browsers for the :mod:`webbrowser` module, instead of always " "generating a new browser command." msgstr "" -#: ../../whatsnew/3.14.rst:2141 +#: ../../whatsnew/3.14.rst:2140 msgid "" "This makes it possible to set :envvar:`BROWSER` to the value of one of the " "supported browsers on macOS." msgstr "" -#: ../../whatsnew/3.14.rst:2146 +#: ../../whatsnew/3.14.rst:2145 msgid "zipfile" msgstr "zipfile" -#: ../../whatsnew/3.14.rst:2148 +#: ../../whatsnew/3.14.rst:2147 msgid "" "Added :meth:`ZipInfo._for_archive `, a method " "to resolve suitable defaults for a :class:`~zipfile.ZipInfo` object as used " @@ -3346,18 +3346,18 @@ msgid "" "Bénédikt Tran in :gh:`123424`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2153 +#: ../../whatsnew/3.14.rst:2152 msgid "" ":meth:`.ZipFile.writestr` now respects the :envvar:`SOURCE_DATE_EPOCH` " "environment variable in order to better support reproducible builds. " "(Contributed by Jiahao Li in :gh:`91279`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2162 +#: ../../whatsnew/3.14.rst:2161 msgid "Optimizations" msgstr "最佳化" -#: ../../whatsnew/3.14.rst:2164 +#: ../../whatsnew/3.14.rst:2163 msgid "" "The import time for several standard library modules has been improved, " "including :mod:`annotationlib`, :mod:`ast`, :mod:`asyncio`, :mod:`base64`, :" @@ -3368,13 +3368,13 @@ msgid "" "`zipfile`." msgstr "" -#: ../../whatsnew/3.14.rst:2171 +#: ../../whatsnew/3.14.rst:2170 msgid "" "(Contributed by Adam Turner, Bénédikt Tran, Chris Markiewicz, Eli Schwartz, " "Hugo van Kemenade, Jelle Zijlstra, and others in :gh:`118761`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2174 +#: ../../whatsnew/3.14.rst:2173 msgid "" "The interpreter now avoids some reference count modifications internally " "when it's safe to do so. This can lead to different values being returned " @@ -3382,7 +3382,7 @@ msgid "" "versions of Python. See :ref:`below ` for details." msgstr "" -#: ../../whatsnew/3.14.rst:2184 +#: ../../whatsnew/3.14.rst:2183 msgid "" "Standard benchmark results have improved by 10-20% following the " "implementation of a new per-thread doubly linked list for :class:`native " @@ -3392,7 +3392,7 @@ msgid "" "running in all threads. (Contributed by Kumar Aditya in :gh:`107803`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2193 +#: ../../whatsnew/3.14.rst:2192 msgid "" "The module now has first class support for :term:`free-threading builds " "`. This enables parallel execution of multiple event loops " @@ -3400,38 +3400,38 @@ msgid "" "(Contributed by Kumar Aditya in :gh:`128002`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2201 +#: ../../whatsnew/3.14.rst:2200 msgid "base64" msgstr "base64" -#: ../../whatsnew/3.14.rst:2203 +#: ../../whatsnew/3.14.rst:2202 msgid "" ":func:`~base64.b16decode` is now up to six times faster. (Contributed by " "Bénédikt Tran, Chris Markiewicz, and Adam Turner in :gh:`118761`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2209 +#: ../../whatsnew/3.14.rst:2208 msgid "bdb" msgstr "bdb" -#: ../../whatsnew/3.14.rst:2211 +#: ../../whatsnew/3.14.rst:2210 msgid "" "The basic debugger now has a :mod:`sys.monitoring`-based backend, which can " "be selected via the passing ``'monitoring'`` to the :class:`~bdb.Bdb` " "class's new *backend* parameter. (Contributed by Tian Gao in :gh:`124533`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2220 +#: ../../whatsnew/3.14.rst:2219 msgid "" "The :func:`~difflib.IS_LINE_JUNK` function is now up to twice as fast. " "(Contributed by Adam Turner and Semyon Moroz in :gh:`130167`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2225 ../../whatsnew/3.14.rst:3506 +#: ../../whatsnew/3.14.rst:2224 ../../whatsnew/3.14.rst:3497 msgid "gc" msgstr "gc" -#: ../../whatsnew/3.14.rst:2229 +#: ../../whatsnew/3.14.rst:2228 msgid "" "Python 3.14.0-3.14.4 shipped with a new incremental garbage collector. " "However, due to a number of `reports ` " "means that maximum pause times are reduced by an order of magnitude or more " "for larger heaps." msgstr "" -#: ../../whatsnew/3.14.rst:2242 +#: ../../whatsnew/3.14.rst:2241 msgid "" "Because of this optimization, the meaning of the results of :meth:`~gc." "get_threshold` and :meth:`~gc.set_threshold` have changed, along with :meth:" "`~gc.get_count` and :meth:`~gc.get_stats`." msgstr "" -#: ../../whatsnew/3.14.rst:2246 +#: ../../whatsnew/3.14.rst:2245 msgid "" "For backwards compatibility, :meth:`~gc.get_threshold` continues to return a " "three-item tuple. The first value is the threshold for young collections, as " @@ -3464,11 +3464,11 @@ msgid "" "zero." msgstr "" -#: ../../whatsnew/3.14.rst:2254 +#: ../../whatsnew/3.14.rst:2253 msgid ":meth:`~gc.set_threshold` now ignores any items after the second." msgstr "" -#: ../../whatsnew/3.14.rst:2256 +#: ../../whatsnew/3.14.rst:2255 msgid "" ":meth:`~gc.get_count` and :meth:`~gc.get_stats` continue to return the same " "format of results. The only difference is that instead of the results " @@ -3476,28 +3476,28 @@ msgid "" "young generation and the aging and collecting spaces of the old generation." msgstr "" -#: ../../whatsnew/3.14.rst:2263 +#: ../../whatsnew/3.14.rst:2262 msgid "" "In summary, code that attempted to manipulate the behavior of the cycle GC " "may not work exactly as intended, but it is very unlikely to be harmful. All " "other code will work just fine." msgstr "" -#: ../../whatsnew/3.14.rst:2273 +#: ../../whatsnew/3.14.rst:2272 msgid "" "Opening and reading files now executes fewer system calls. Reading a small " "operating system cached file in full is up to 15% faster. (Contributed by " "Cody Maloney and Victor Stinner in :gh:`120754` and :gh:`90102`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2282 +#: ../../whatsnew/3.14.rst:2281 msgid "" ":func:`Path.read_bytes ` now uses unbuffered mode " "to open files, which is between 9% and 17% faster to read in full. " "(Contributed by Cody Maloney in :gh:`120754`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2290 +#: ../../whatsnew/3.14.rst:2289 msgid "" ":mod:`pdb` now supports two backends, based on either :func:`sys.settrace` " "or :mod:`sys.monitoring`. Using the :ref:`pdb CLI ` or :func:" @@ -3507,11 +3507,11 @@ msgid "" "Tian Gao in :gh:`124533`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2300 +#: ../../whatsnew/3.14.rst:2299 msgid "textwrap" msgstr "textwrap" -#: ../../whatsnew/3.14.rst:2302 +#: ../../whatsnew/3.14.rst:2301 msgid "" "Optimize the :func:`~textwrap.dedent` function, improving performance by an " "average of 2.4x, with larger improvements for bigger inputs, and fix a bug " @@ -3519,24 +3519,24 @@ msgid "" "other than space and tab." msgstr "" -#: ../../whatsnew/3.14.rst:2311 +#: ../../whatsnew/3.14.rst:2310 msgid "" ":func:`~uuid.uuid3` and :func:`~uuid.uuid5` are now both roughly 40% faster " "for 16-byte names and 20% faster for 1024-byte names. Performance for longer " "names remains unchanged. (Contributed by Bénédikt Tran in :gh:`128150`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2316 +#: ../../whatsnew/3.14.rst:2315 msgid "" ":func:`~uuid.uuid4` is now c. 30% faster. (Contributed by Bénédikt Tran in :" "gh:`128150`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2321 +#: ../../whatsnew/3.14.rst:2320 msgid "zlib" msgstr "zlib" -#: ../../whatsnew/3.14.rst:2323 +#: ../../whatsnew/3.14.rst:2322 msgid "" "On Windows, `zlib-ng `__ is now used as " "the implementation of the :mod:`zlib` module in the default binaries. There " @@ -3545,29 +3545,29 @@ msgid "" "compression levels." msgstr "" -#: ../../whatsnew/3.14.rst:2330 +#: ../../whatsnew/3.14.rst:2329 msgid "" "It is worth noting that ``zlib.Z_BEST_SPEED`` (``1``) may result in " "significantly less compression than the previous implementation, whilst also " "significantly reducing the time taken to compress." msgstr "" -#: ../../whatsnew/3.14.rst:2334 +#: ../../whatsnew/3.14.rst:2333 msgid "(Contributed by Steve Dower in :gh:`91349`.)" msgstr "(由 Steve Dower 於 :gh:`91349` 貢獻。)" -#: ../../whatsnew/3.14.rst:2338 +#: ../../whatsnew/3.14.rst:2337 msgid "Removed" msgstr "已移除" -#: ../../whatsnew/3.14.rst:2343 +#: ../../whatsnew/3.14.rst:2342 msgid "" "Remove the *type*, *choices*, and *metavar* parameters of :class:`!" "BooleanOptionalAction`. These have been deprecated since Python 3.12. " "(Contributed by Nikita Sobolev in :gh:`118805`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2348 +#: ../../whatsnew/3.14.rst:2347 msgid "" "Calling :meth:`~argparse.ArgumentParser.add_argument_group` on an argument " "group now raises a :exc:`ValueError`. Similarly, :meth:`~argparse." @@ -3579,34 +3579,34 @@ msgid "" "Savannah Ostrowski in :gh:`127186`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2362 +#: ../../whatsnew/3.14.rst:2361 msgid "" "Remove the following classes, which have been deprecated aliases of :class:" "`~ast.Constant` since Python 3.8 and have emitted deprecation warnings since " "Python 3.12:" msgstr "" -#: ../../whatsnew/3.14.rst:2366 +#: ../../whatsnew/3.14.rst:2365 msgid ":class:`!Bytes`" msgstr ":class:`!Bytes`" -#: ../../whatsnew/3.14.rst:2367 +#: ../../whatsnew/3.14.rst:2366 msgid ":class:`!Ellipsis`" msgstr ":class:`!Ellipsis`" -#: ../../whatsnew/3.14.rst:2368 +#: ../../whatsnew/3.14.rst:2367 msgid ":class:`!NameConstant`" msgstr ":class:`!NameConstant`" -#: ../../whatsnew/3.14.rst:2369 +#: ../../whatsnew/3.14.rst:2368 msgid ":class:`!Num`" msgstr ":class:`!Num`" -#: ../../whatsnew/3.14.rst:2370 +#: ../../whatsnew/3.14.rst:2369 msgid ":class:`!Str`" msgstr ":class:`!Str`" -#: ../../whatsnew/3.14.rst:2372 +#: ../../whatsnew/3.14.rst:2371 msgid "" "As a consequence of these removals, user-defined ``visit_Num``, " "``visit_Str``, ``visit_Bytes``, ``visit_NameConstant`` and " @@ -3615,92 +3615,92 @@ msgid "" "an AST. Define a ``visit_Constant`` method instead." msgstr "" -#: ../../whatsnew/3.14.rst:2378 +#: ../../whatsnew/3.14.rst:2377 msgid "(Contributed by Alex Waygood in :gh:`119562`.)" msgstr "(由 Alex Waygood 於 :gh:`119562` 貢獻。)" -#: ../../whatsnew/3.14.rst:2380 +#: ../../whatsnew/3.14.rst:2379 msgid "" "Remove the following deprecated properties on :class:`ast.Constant`, which " "were present for compatibility with the now-removed AST classes:" msgstr "" -#: ../../whatsnew/3.14.rst:2383 +#: ../../whatsnew/3.14.rst:2382 msgid ":attr:`!Constant.n`" msgstr ":attr:`!Constant.n`" -#: ../../whatsnew/3.14.rst:2384 +#: ../../whatsnew/3.14.rst:2383 msgid ":attr:`!Constant.s`" msgstr ":attr:`!Constant.s`" -#: ../../whatsnew/3.14.rst:2386 +#: ../../whatsnew/3.14.rst:2385 msgid "" "Use :attr:`!Constant.value` instead. (Contributed by Alex Waygood in :gh:" "`119562`.)" msgstr "" "改用 :attr:`!Constant.value`。(由 Alex Waygood 於 :gh:`119562` 貢獻。)" -#: ../../whatsnew/3.14.rst:2393 +#: ../../whatsnew/3.14.rst:2392 msgid "" "Remove the following classes, methods, and functions, which have been " "deprecated since Python 3.12:" msgstr "" -#: ../../whatsnew/3.14.rst:2396 +#: ../../whatsnew/3.14.rst:2395 msgid ":class:`!AbstractChildWatcher`" msgstr ":class:`!AbstractChildWatcher`" -#: ../../whatsnew/3.14.rst:2397 +#: ../../whatsnew/3.14.rst:2396 msgid ":class:`!FastChildWatcher`" msgstr ":class:`!FastChildWatcher`" -#: ../../whatsnew/3.14.rst:2398 +#: ../../whatsnew/3.14.rst:2397 msgid ":class:`!MultiLoopChildWatcher`" msgstr ":class:`!MultiLoopChildWatcher`" -#: ../../whatsnew/3.14.rst:2399 +#: ../../whatsnew/3.14.rst:2398 msgid ":class:`!PidfdChildWatcher`" msgstr ":class:`!PidfdChildWatcher`" -#: ../../whatsnew/3.14.rst:2400 +#: ../../whatsnew/3.14.rst:2399 msgid ":class:`!SafeChildWatcher`" msgstr ":class:`!SafeChildWatcher`" -#: ../../whatsnew/3.14.rst:2401 +#: ../../whatsnew/3.14.rst:2400 msgid ":class:`!ThreadedChildWatcher`" msgstr ":class:`!ThreadedChildWatcher`" -#: ../../whatsnew/3.14.rst:2402 +#: ../../whatsnew/3.14.rst:2401 msgid ":meth:`!AbstractEventLoopPolicy.get_child_watcher`" msgstr ":meth:`!AbstractEventLoopPolicy.get_child_watcher`" -#: ../../whatsnew/3.14.rst:2403 +#: ../../whatsnew/3.14.rst:2402 msgid ":meth:`!AbstractEventLoopPolicy.set_child_watcher`" msgstr ":meth:`!AbstractEventLoopPolicy.set_child_watcher`" -#: ../../whatsnew/3.14.rst:2404 +#: ../../whatsnew/3.14.rst:2403 msgid ":func:`!get_child_watcher`" msgstr ":func:`!get_child_watcher`" -#: ../../whatsnew/3.14.rst:2405 +#: ../../whatsnew/3.14.rst:2404 msgid ":func:`!set_child_watcher`" msgstr ":func:`!set_child_watcher`" -#: ../../whatsnew/3.14.rst:2407 +#: ../../whatsnew/3.14.rst:2406 msgid "(Contributed by Kumar Aditya in :gh:`120804`.)" msgstr "(由 Kumar Aditya 於 :gh:`120804` 貢獻。)" -#: ../../whatsnew/3.14.rst:2409 +#: ../../whatsnew/3.14.rst:2408 msgid "" ":func:`asyncio.get_event_loop` now raises a :exc:`RuntimeError` if there is " "no current event loop, and no longer implicitly creates an event loop." msgstr "" -#: ../../whatsnew/3.14.rst:2413 +#: ../../whatsnew/3.14.rst:2412 msgid "(Contributed by Kumar Aditya in :gh:`126353`.)" msgstr "(由 Kumar Aditya 於 :gh:`126353` 貢獻。)" -#: ../../whatsnew/3.14.rst:2418 +#: ../../whatsnew/3.14.rst:2417 msgid "" "There's a few patterns that use :func:`asyncio.get_event_loop`, most of them " "can be replaced with :func:`asyncio.run`." @@ -3708,16 +3708,16 @@ msgstr "" "有一些使用 :func:`asyncio.get_event_loop` 的模式,其中大多數可以用 :func:" "`asyncio.run` 取代。" -#: ../../whatsnew/3.14.rst:2421 +#: ../../whatsnew/3.14.rst:2420 msgid "If you're running an async function, simply use :func:`asyncio.run`." msgstr "如果你正在運行非同步函式,只需使用 :func:`asyncio.run`。" -#: ../../whatsnew/3.14.rst:2423 ../../whatsnew/3.14.rst:2450 -#: ../../whatsnew/3.14.rst:2478 +#: ../../whatsnew/3.14.rst:2422 ../../whatsnew/3.14.rst:2449 +#: ../../whatsnew/3.14.rst:2477 msgid "Before:" msgstr "之前是:" -#: ../../whatsnew/3.14.rst:2425 +#: ../../whatsnew/3.14.rst:2424 msgid "" "async def main():\n" " ...\n" @@ -3739,12 +3739,12 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../whatsnew/3.14.rst:2437 ../../whatsnew/3.14.rst:2463 -#: ../../whatsnew/3.14.rst:2494 +#: ../../whatsnew/3.14.rst:2436 ../../whatsnew/3.14.rst:2462 +#: ../../whatsnew/3.14.rst:2493 msgid "After:" msgstr "之後是:" -#: ../../whatsnew/3.14.rst:2439 +#: ../../whatsnew/3.14.rst:2438 msgid "" "async def main():\n" " ...\n" @@ -3756,7 +3756,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../whatsnew/3.14.rst:2446 +#: ../../whatsnew/3.14.rst:2445 msgid "" "If you need to start something, for example, a server listening on a socket " "and then run forever, use :func:`asyncio.run` and an :class:`asyncio.Event`." @@ -3764,7 +3764,7 @@ msgstr "" "如果你需要啟動某些東西然後永遠運行,像是監聽 socket 的伺服器,請使用 :func:" "`asyncio.run` 和 :class:`asyncio.Event`。" -#: ../../whatsnew/3.14.rst:2452 +#: ../../whatsnew/3.14.rst:2451 msgid "" "def start_server(loop): ...\n" "\n" @@ -3784,7 +3784,7 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../whatsnew/3.14.rst:2465 +#: ../../whatsnew/3.14.rst:2464 msgid "" "def start_server(loop): ...\n" "\n" @@ -3802,7 +3802,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../whatsnew/3.14.rst:2475 +#: ../../whatsnew/3.14.rst:2474 msgid "" "If you need to run something in an event loop, then run some blocking code " "around it, use :class:`asyncio.Runner`." @@ -3810,7 +3810,7 @@ msgstr "" "如果你需要在事件迴圈中運行某些東西,然後在其周圍運行一些阻塞程式碼,請使用 :" "class:`asyncio.Runner`。" -#: ../../whatsnew/3.14.rst:2480 +#: ../../whatsnew/3.14.rst:2479 msgid "" "async def operation_one(): ...\n" "def blocking_code(): ...\n" @@ -3836,7 +3836,7 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../whatsnew/3.14.rst:2496 +#: ../../whatsnew/3.14.rst:2495 msgid "" "async def operation_one(): ...\n" "def blocking_code(): ...\n" @@ -3856,26 +3856,26 @@ msgstr "" " blocking_code()\n" " runner.run(operation_two())" -#: ../../whatsnew/3.14.rst:2509 +#: ../../whatsnew/3.14.rst:2508 msgid "email" msgstr "email" -#: ../../whatsnew/3.14.rst:2511 +#: ../../whatsnew/3.14.rst:2510 msgid "" "Remove :func:`email.utils.localtime`'s *isdst* parameter, which was " "deprecated in and has been ignored since Python 3.12. (Contributed by Hugo " "van Kemenade in :gh:`118798`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2517 +#: ../../whatsnew/3.14.rst:2516 msgid "importlib.abc" msgstr "importlib.abc" -#: ../../whatsnew/3.14.rst:2519 +#: ../../whatsnew/3.14.rst:2518 msgid "Remove deprecated :mod:`importlib.abc` classes:" msgstr "移除已棄用的 :mod:`importlib.abc` 類別:" -#: ../../whatsnew/3.14.rst:2521 +#: ../../whatsnew/3.14.rst:2520 msgid "" ":class:`!ResourceReader` (use :class:`~importlib.resources.abc." "TraversableResources`)" @@ -3883,14 +3883,14 @@ msgstr "" ":class:`!ResourceReader`\\ (請改用 :class:`~importlib.resources.abc." "TraversableResources`)" -#: ../../whatsnew/3.14.rst:2523 +#: ../../whatsnew/3.14.rst:2522 msgid "" ":class:`!Traversable` (use :class:`~importlib.resources.abc.Traversable`)" msgstr "" ":class:`!Traversable`\\ (請改用 :class:`~importlib.resources.abc." "Traversable`)" -#: ../../whatsnew/3.14.rst:2525 +#: ../../whatsnew/3.14.rst:2524 msgid "" ":class:`!TraversableResources` (use :class:`~importlib.resources.abc." "TraversableResources`)" @@ -3898,29 +3898,29 @@ msgstr "" ":class:`!TraversableResources`\\ (請改用 :class:`~importlib.resources.abc." "TraversableResources`)" -#: ../../whatsnew/3.14.rst:2528 +#: ../../whatsnew/3.14.rst:2527 msgid "(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)" msgstr "(由 Jason R. Coombs 和 Hugo van Kemenade 貢獻於 :gh:`93963`。)" -#: ../../whatsnew/3.14.rst:2532 +#: ../../whatsnew/3.14.rst:2531 msgid "itertools" msgstr "itertools" -#: ../../whatsnew/3.14.rst:2534 +#: ../../whatsnew/3.14.rst:2533 msgid "" "Remove support for copy, deepcopy, and pickle operations from :mod:" "`itertools` iterators. These have emitted a :exc:`DeprecationWarning` since " "Python 3.12. (Contributed by Raymond Hettinger in :gh:`101588`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2543 +#: ../../whatsnew/3.14.rst:2542 msgid "" "Remove support for passing additional keyword arguments to :class:`~pathlib." "Path`. In previous versions, any such arguments are ignored. (Contributed by " "Barney Gale in :gh:`74033`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2548 +#: ../../whatsnew/3.14.rst:2547 msgid "" "Remove support for passing additional positional arguments to :meth:`." "PurePath.relative_to` and :meth:`~pathlib.PurePath.is_relative_to`. In " @@ -3928,33 +3928,33 @@ msgid "" "by Barney Gale in :gh:`78707`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2555 +#: ../../whatsnew/3.14.rst:2554 msgid "pkgutil" msgstr "pkgutil" -#: ../../whatsnew/3.14.rst:2557 +#: ../../whatsnew/3.14.rst:2556 msgid "" "Remove the :func:`!get_loader` and :func:`!find_loader` functions, which " "have been deprecated since Python 3.12. (Contributed by Bénédikt Tran in :gh:" "`97850`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2563 +#: ../../whatsnew/3.14.rst:2562 msgid "pty" msgstr "pty" -#: ../../whatsnew/3.14.rst:2565 +#: ../../whatsnew/3.14.rst:2564 msgid "" "Remove the :func:`!master_open` and :func:`!slave_open` functions, which " "have been deprecated since Python 3.12. Use :func:`pty.openpty` instead. " "(Contributed by Nikita Sobolev in :gh:`118824`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2572 +#: ../../whatsnew/3.14.rst:2571 msgid "sqlite3" msgstr "sqlite3" -#: ../../whatsnew/3.14.rst:2574 +#: ../../whatsnew/3.14.rst:2573 msgid "" "Remove :data:`!version` and :data:`!version_info` from the :mod:`sqlite3` " "module; use :data:`~sqlite3.sqlite_version` and :data:`~sqlite3." @@ -3962,27 +3962,27 @@ msgid "" "library. (Contributed by Hugo van Kemenade in :gh:`118924`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2580 +#: ../../whatsnew/3.14.rst:2579 msgid "" "Using a sequence of parameters with named placeholders now raises a :exc:" "`~sqlite3.ProgrammingError`, having been deprecated since Python 3.12. " "(Contributed by Erlend E. Aasland in :gh:`118928` and :gh:`101693`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2589 +#: ../../whatsnew/3.14.rst:2588 msgid "" "Remove the :class:`!Quoter` class from :mod:`urllib.parse`, which has been " "deprecated since Python 3.11. (Contributed by Nikita Sobolev in :gh:" "`118827`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2593 +#: ../../whatsnew/3.14.rst:2592 msgid "" "Remove the :class:`!URLopener` and :class:`!FancyURLopener` classes from :" "mod:`urllib.request`, which have been deprecated since Python 3.3." msgstr "" -#: ../../whatsnew/3.14.rst:2597 +#: ../../whatsnew/3.14.rst:2596 msgid "" "``myopener.open()`` can be replaced with :func:`~urllib.request.urlopen`. " "``myopener.retrieve()`` can be replaced with :func:`~urllib.request." @@ -3991,15 +3991,15 @@ msgid "" "(Contributed by Barney Gale in :gh:`84850`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2606 +#: ../../whatsnew/3.14.rst:2605 msgid "Deprecated" msgstr "已棄用" -#: ../../whatsnew/3.14.rst:2609 +#: ../../whatsnew/3.14.rst:2608 msgid "New deprecations" msgstr "" -#: ../../whatsnew/3.14.rst:2611 +#: ../../whatsnew/3.14.rst:2610 msgid "" "Passing a complex number as the *real* or *imag* argument in the :func:" "`complex` constructor is now deprecated; complex numbers should only be " @@ -4010,12 +4010,12 @@ msgstr "" "用;複數應該只作為單個位置引數傳遞。 (由 Serhiy Storchaka 於 :gh:`109218` 貢" "獻。)" -#: ../../whatsnew/3.14.rst:2616 +#: ../../whatsnew/3.14.rst:2615 #: ../../deprecations/pending-removal-in-future.rst:7 msgid ":mod:`argparse`:" msgstr ":mod:`argparse`:" -#: ../../whatsnew/3.14.rst:2618 +#: ../../whatsnew/3.14.rst:2617 msgid "" "Passing the undocumented keyword argument *prefix_chars* to the :meth:" "`~argparse.ArgumentParser.add_argument_group` method is now deprecated. " @@ -4025,19 +4025,19 @@ msgstr "" "ArgumentParser.add_argument_group` 的做法現在已被棄用。(由 Savannah " "Ostrowski 於 :gh:`125563` 貢獻。)" -#: ../../whatsnew/3.14.rst:2622 +#: ../../whatsnew/3.14.rst:2621 msgid "" "Deprecated the :class:`argparse.FileType` type converter. Anything relating " "to resource management should be handled downstream, after the arguments " "have been parsed. (Contributed by Serhiy Storchaka in :gh:`58032`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2627 +#: ../../whatsnew/3.14.rst:2626 #: ../../deprecations/pending-removal-in-3.16.rst:19 msgid ":mod:`asyncio`:" msgstr ":mod:`asyncio`:" -#: ../../whatsnew/3.14.rst:2629 +#: ../../whatsnew/3.14.rst:2628 msgid "" "The :func:`!asyncio.iscoroutinefunction` is now deprecated and will be " "removed in Python 3.16; use :func:`inspect.iscoroutinefunction` instead. " @@ -4047,7 +4047,7 @@ msgstr "" "用 :func:`inspect.iscoroutinefunction`。(由 Jiahao Li 和 Kumar Aditya 於 :" "gh:`122875` 貢獻。)" -#: ../../whatsnew/3.14.rst:2634 +#: ../../whatsnew/3.14.rst:2633 msgid "" "The :mod:`asyncio` policy system is deprecated and will be removed in Python " "3.16. In particular, the following classes and functions are deprecated:" @@ -4055,37 +4055,37 @@ msgstr "" ":mod:`asyncio` 策略系統已被棄用並將在 Python 3.16 中移除。特別是以下類別和函" "式已被棄用:" -#: ../../whatsnew/3.14.rst:2638 +#: ../../whatsnew/3.14.rst:2637 #: ../../deprecations/pending-removal-in-3.16.rst:29 msgid ":class:`asyncio.AbstractEventLoopPolicy`" msgstr ":class:`asyncio.AbstractEventLoopPolicy`" -#: ../../whatsnew/3.14.rst:2639 +#: ../../whatsnew/3.14.rst:2638 #: ../../deprecations/pending-removal-in-3.16.rst:30 msgid ":class:`asyncio.DefaultEventLoopPolicy`" msgstr ":class:`asyncio.DefaultEventLoopPolicy`" -#: ../../whatsnew/3.14.rst:2640 +#: ../../whatsnew/3.14.rst:2639 #: ../../deprecations/pending-removal-in-3.16.rst:31 msgid ":class:`asyncio.WindowsSelectorEventLoopPolicy`" msgstr ":class:`asyncio.WindowsSelectorEventLoopPolicy`" -#: ../../whatsnew/3.14.rst:2641 +#: ../../whatsnew/3.14.rst:2640 #: ../../deprecations/pending-removal-in-3.16.rst:32 msgid ":class:`asyncio.WindowsProactorEventLoopPolicy`" msgstr ":class:`asyncio.WindowsProactorEventLoopPolicy`" -#: ../../whatsnew/3.14.rst:2642 +#: ../../whatsnew/3.14.rst:2641 #: ../../deprecations/pending-removal-in-3.16.rst:33 msgid ":func:`asyncio.get_event_loop_policy`" msgstr ":func:`asyncio.get_event_loop_policy`" -#: ../../whatsnew/3.14.rst:2643 +#: ../../whatsnew/3.14.rst:2642 #: ../../deprecations/pending-removal-in-3.16.rst:34 msgid ":func:`asyncio.set_event_loop_policy`" msgstr ":func:`asyncio.set_event_loop_policy`" -#: ../../whatsnew/3.14.rst:2645 +#: ../../whatsnew/3.14.rst:2644 msgid "" "Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with the " "*loop_factory* argument to use the desired event loop implementation." @@ -4093,11 +4093,11 @@ msgstr "" "使用者應該使用 :func:`asyncio.run` 或 :class:`asyncio.Runner` 搭配 " "*loop_factory* 引數來使用所需的事件迴圈實作。" -#: ../../whatsnew/3.14.rst:2648 +#: ../../whatsnew/3.14.rst:2647 msgid "For example, to use :class:`asyncio.SelectorEventLoop` on Windows:" msgstr "例如在 Windows 上使用 :class:`asyncio.SelectorEventLoop`:" -#: ../../whatsnew/3.14.rst:2650 +#: ../../whatsnew/3.14.rst:2649 #: ../../deprecations/pending-removal-in-3.16.rst:41 msgid "" "import asyncio\n" @@ -4114,12 +4114,12 @@ msgstr "" "\n" "asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)" -#: ../../whatsnew/3.14.rst:2659 +#: ../../whatsnew/3.14.rst:2658 #: ../../deprecations/pending-removal-in-3.16.rst:48 msgid "(Contributed by Kumar Aditya in :gh:`127949`.)" msgstr "(由 Kumar Aditya 於 :gh:`127949` 貢獻。)" -#: ../../whatsnew/3.14.rst:2661 +#: ../../whatsnew/3.14.rst:2660 msgid "" ":mod:`codecs`: The :func:`codecs.open` function is now deprecated, and will " "be removed in a future version of Python. Use :func:`open` instead. " @@ -4128,13 +4128,13 @@ msgstr "" ":mod:`codecs`: :func:`codecs.open` 函式已被棄用,並將在未來的 Python 版本中移" "除。請改用 :func:`open`。(由 Inada Naoki 於 :gh:`133036` 貢獻。)" -#: ../../whatsnew/3.14.rst:2667 +#: ../../whatsnew/3.14.rst:2666 #: ../../deprecations/pending-removal-in-3.15.rst:16 #: ../../deprecations/pending-removal-in-3.19.rst:4 msgid ":mod:`ctypes`:" msgstr ":mod:`ctypes`:" -#: ../../whatsnew/3.14.rst:2669 +#: ../../whatsnew/3.14.rst:2668 msgid "" "On non-Windows platforms, setting :attr:`.Structure._pack_` to use a MSVC-" "compatible default memory layout is now deprecated in favor of setting :attr:" @@ -4142,7 +4142,7 @@ msgid "" "(Contributed by Petr Viktorin in :gh:`131747`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2674 +#: ../../whatsnew/3.14.rst:2673 msgid "" "Calling :func:`ctypes.POINTER` on a string is now deprecated. Use :ref:" "`incomplete types ` for self-referential " @@ -4151,7 +4151,7 @@ msgid "" "by Sergey Myrianov in :gh:`100926`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2681 +#: ../../whatsnew/3.14.rst:2680 msgid "" ":mod:`functools`: Calling the Python implementation of :func:`functools." "reduce` with *function* or *sequence* as keyword arguments is now " @@ -4162,7 +4162,7 @@ msgstr "" "`functools.reduce` 的 Python 實作已被棄用;這些參數將在 Python 3.16 中變為僅" "限位置引數。(由 Kirill Podoprigora 於 :gh:`121676` 貢獻。)" -#: ../../whatsnew/3.14.rst:2687 +#: ../../whatsnew/3.14.rst:2686 msgid "" ":mod:`logging`: Support for custom logging handlers with the *strm* argument " "is now deprecated and scheduled for removal in Python 3.16. Define handlers " @@ -4173,7 +4173,7 @@ msgstr "" "劃在 Python 3.16 中移除。請改為使用 *stream* 引數來定義處理函式。(由 " "Mariusz Felisiak 於 :gh:`115032` 貢獻。)" -#: ../../whatsnew/3.14.rst:2693 +#: ../../whatsnew/3.14.rst:2692 msgid "" ":mod:`mimetypes`: Valid extensions are either empty or must start with '.' " "for :meth:`mimetypes.MimeTypes.add_type`. Undotted extensions are deprecated " @@ -4184,14 +4184,14 @@ msgstr "" "add_type` 以 '.' 開頭。未加點的副檔名已被棄用,並將在 Python 3.16 中引發 :" "exc:`ValueError`。(由 Hugo van Kemenade 於 :gh:`75223` 貢獻。)" -#: ../../whatsnew/3.14.rst:2700 +#: ../../whatsnew/3.14.rst:2699 msgid "" ":mod:`!nturl2path`: This module is now deprecated. Call :func:`urllib." "request.url2pathname` and :func:`~urllib.request.pathname2url` instead. " "(Contributed by Barney Gale in :gh:`125866`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2705 +#: ../../whatsnew/3.14.rst:2704 msgid "" ":mod:`os`: The :func:`os.popen` and :func:`os.spawn* ` functions " "are now :term:`soft deprecated`. They should no longer be used to write new " @@ -4199,14 +4199,14 @@ msgid "" "Victor Stinner in :gh:`120743`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2712 +#: ../../whatsnew/3.14.rst:2711 msgid "" ":mod:`pathlib`: :meth:`!pathlib.PurePath.as_uri` is now deprecated and " "scheduled for removal in Python 3.19. Use :meth:`pathlib.Path.as_uri` " "instead. (Contributed by Barney Gale in :gh:`123599`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2718 +#: ../../whatsnew/3.14.rst:2717 msgid "" ":mod:`pdb`: The undocumented ``pdb.Pdb.curframe_locals`` attribute is now a " "deprecated read-only property, which will be removed in a future version of " @@ -4217,14 +4217,14 @@ msgid "" "(Contributed by Tian Gao in :gh:`124369` and :gh:`125951`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2727 +#: ../../whatsnew/3.14.rst:2726 msgid "" ":mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the " "lack of interest, scheduled for removal in Python 3.16. (Contributed by " "Bénédikt Tran in :gh:`119698`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2732 +#: ../../whatsnew/3.14.rst:2731 msgid "" ":mod:`tkinter`: The :class:`!tkinter.Variable` methods :meth:`!" "trace_variable`, :meth:`!trace_vdelete` and :meth:`!trace_vinfo` are now " @@ -4232,7 +4232,7 @@ msgid "" "trace_info` instead. (Contributed by Serhiy Storchaka in :gh:`120220`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2738 +#: ../../whatsnew/3.14.rst:2737 msgid "" ":mod:`urllib.parse`: Accepting objects with false values (like ``0`` and " "``[]``) except empty strings, bytes-like objects and ``None`` in :func:" @@ -4252,14 +4252,14 @@ msgstr "引入系統 (import system):" #: ../../deprecations/pending-removal-in-3.15.rst:6 msgid "" -"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" -"`__spec__.cached ` is deprecated. In " -"Python 3.15, :attr:`!__cached__` will cease to be set or take into " -"consideration by the import system or standard library. (:gh:`97879`)" +"Setting ``__cached__`` on a module while failing to set :attr:`__spec__." +"cached ` is deprecated. In Python " +"3.15, ``__cached__`` will cease to be set or take into consideration by the " +"import system or standard library. (:gh:`97879`)" msgstr "" -"在模組上設定 :attr:`~module.__cached__` 而沒有設定 :attr:`__spec__.cached " +"在模組上設定 ``__cached__`` 而沒有設定 :attr:`__spec__.cached " "` 的做法已被棄用。在 Python 3.15 中," -"引入系統或標準函式庫將不再設定或考慮 :attr:`!__cached__`。(:gh:`97879`)" +"引入系統或標準函式庫將不再設定或考慮 ``__cached__``。(:gh:`97879`)" #: ../../deprecations/pending-removal-in-3.15.rst:11 msgid "" @@ -4285,13 +4285,13 @@ msgstr ":mod:`http.server`:" #: ../../deprecations/pending-removal-in-3.15.rst:23 msgid "" -"The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` has " -"been deprecated since Python 3.13. No direct replacement exists. *Anything* " -"is better than CGI to interface a web server with a request handler." +"The obsolete and rarely used :class:`!CGIHTTPRequestHandler` has been " +"deprecated since Python 3.13. No direct replacement exists. *Anything* is " +"better than CGI to interface a web server with a request handler." msgstr "" -"過時且很少使用的 :class:`~http.server.CGIHTTPRequestHandler` 自 Python 3.13 " -"起已被棄用。不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求" -"處理程序介接起來。" +"過時且很少使用的 :class:`!CGIHTTPRequestHandler` 自 Python 3.13 起已被棄用。" +"不存在直接的替代。*任何東西*\\ 都比 CGI 更好地將 Web 伺服器與請求處理程序介接" +"起來。" #: ../../deprecations/pending-removal-in-3.15.rst:29 msgid "" @@ -4316,11 +4316,11 @@ msgstr ":mod:`pathlib`:" #: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" -":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" +":meth:`!.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" "func:`os.path.isreserved` to detect reserved paths on Windows." msgstr "" -":meth:`.PurePath.is_reserved` 已自 Python 3.13 被棄用。請用 :func:`os.path." -"isreserved` 來偵測 Windows 上的保留路徑。" +":meth:`!.PurePath.is_reserved` 已自 Python 3.13 被棄用。請" +"用 :func:`os.path.isreserved` 來偵測 Windows 上的保留路徑。" #: ../../deprecations/pending-removal-in-3.15.rst:42 msgid ":mod:`platform`:" @@ -4328,11 +4328,11 @@ msgstr ":mod:`platform`:" #: ../../deprecations/pending-removal-in-3.15.rst:44 msgid "" -":func:`~platform.java_ver` has been deprecated since Python 3.13. This " +":func:`!platform.java_ver` has been deprecated since Python 3.13. This " "function is only useful for Jython support, has a confusing API, and is " "largely untested." msgstr "" -"自 Python 3.13 起,:func:`~platform.java_ver` 已被棄用。此函式僅對 Jython 支" +"自 Python 3.13 起,:func:`!platform.java_ver` 已被棄用。此函式僅對 Jython 支" "援有用,具有令人困惑的 API,基本上未經測試。" #: ../../deprecations/pending-removal-in-3.15.rst:48 @@ -4369,18 +4369,19 @@ msgstr ":mod:`types`:" #: ../../deprecations/pending-removal-in-3.15.rst:63 msgid "" -":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +":class:`types.CodeType`: Accessing :attr:`!codeobject.co_lnotab` was " "deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " "but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " "in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" msgstr "" -":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" -"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" -"exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev 於 :gh:" -"`101866` 貢獻。)" +":class:`types.CodeType`:自 3.10 起,存取 :attr:`!codeobject.co_lnotab` 已" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但直到 3.12 才有正式" +"的 :exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev " +"於 :gh:`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:70 -#: ../../deprecations/pending-removal-in-3.17.rst:26 +#: ../../deprecations/pending-removal-in-3.17.rst:52 +#: ../../deprecations/pending-removal-in-3.20.rst:57 msgid ":mod:`typing`:" msgstr ":mod:`typing`:" @@ -4410,41 +4411,43 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.15.rst:85 msgid "" -"The :deco:`typing.no_type_check_decorator` decorator function has been " +"The :deco:`!typing.no_type_check_decorator` decorator function has been " "deprecated since Python 3.13. After eight years in the :mod:`typing` module, " "it has yet to be supported by any major type checker." msgstr "" -"自 Python 3.13 起,:deco:`typing.no_type_check_decorator` 裝飾器函式已被棄" +"自 Python 3.13 起,:deco:`!typing.no_type_check_decorator` 裝飾器函式已被棄" "用。在 :mod:`typing` 模組中使用了八年之後,它尚未得到任何主要型別檢查器的支" "援。" #: ../../deprecations/pending-removal-in-3.15.rst:90 +msgid "" +":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." +msgstr ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" + +#: ../../deprecations/pending-removal-in-3.15.rst:92 msgid ":mod:`wave`:" msgstr ":mod:`wave`:" -#: ../../deprecations/pending-removal-in-3.15.rst:92 +#: ../../deprecations/pending-removal-in-3.15.rst:94 msgid "" -"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." -"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" -"`~wave.Wave_write` classes have been deprecated since Python 3.13." +"The ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of the :class:" +"`~wave.Wave_read` and :class:`~wave.Wave_write` classes have been deprecated " +"since Python 3.13." msgstr "" -"已棄用 :class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 :meth:" -"`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." -"getmarkers` 方法自 Python 3.13 被棄用。" +":class:`~wave.Wave_read` 和 :class:`~wave.Wave_write` 類別的 ``getmark()``、" +"``setmark()`` 和 ``getmarkers()`` 方法自 Python 3.13 起已被棄用。" -#: ../../deprecations/pending-removal-in-3.15.rst:97 +#: ../../deprecations/pending-removal-in-3.15.rst:98 msgid ":mod:`zipimport`:" msgstr ":mod:`zipimport`:" -#: ../../deprecations/pending-removal-in-3.15.rst:99 +#: ../../deprecations/pending-removal-in-3.15.rst:100 msgid "" -":meth:`~zipimport.zipimporter.load_module` has been deprecated since Python " -"3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (Contributed " -"by Jiahao Li in :gh:`125746`.)" +":meth:`!zipimport.zipimporter.load_module` has been deprecated since Python " +"3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (:gh:`125746`.)" msgstr "" -":meth:`~zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改用 :" -"meth:`~zipimport.zipimporter.exec_module`。(由 Jiahao Li 於 :gh:`125746` 貢" -"獻。)" +":meth:`!zipimport.zipimporter.load_module` 自 Python 3.10 被棄用。請改" +"用 :meth:`~zipimport.zipimporter.exec_module`。(:gh:`125746`。)" #: ../../deprecations/c-api-pending-removal-in-3.16.rst:2 #: ../../deprecations/pending-removal-in-3.16.rst:2 @@ -4629,16 +4632,28 @@ msgid "Pending removal in Python 3.17" msgstr "Python 3.17 中待移除的項目" #: ../../deprecations/pending-removal-in-3.17.rst:4 +#: ../../deprecations/pending-removal-in-future.rst:53 +msgid ":mod:`datetime`:" +msgstr ":mod:`datetime`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:6 +msgid "" +":meth:`~datetime.datetime.strptime` calls using a format string containing " +"``%e`` (day of month) without a year. This has been deprecated since Python " +"3.15. (Contributed by Stan Ulbrych in :gh:`70647`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:12 msgid ":mod:`collections.abc`:" msgstr ":mod:`collections.abc`:" -#: ../../deprecations/pending-removal-in-3.17.rst:6 +#: ../../deprecations/pending-removal-in-3.17.rst:14 msgid "" ":class:`collections.abc.ByteString` is scheduled for removal in Python 3.17." msgstr ":class:`collections.abc.ByteString` 預計在 Python 3.17 中移除。" -#: ../../deprecations/pending-removal-in-3.17.rst:8 -#: ../../deprecations/pending-removal-in-3.17.rst:36 +#: ../../deprecations/pending-removal-in-3.17.rst:16 +#: ../../deprecations/pending-removal-in-3.17.rst:62 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -4651,8 +4666,8 @@ msgstr "" "用 :class:`~collections.abc.Buffer` 或明確指定你的程式碼所支援型別的聯集(例" "如 ``bytes | bytearray | memoryview``)。" -#: ../../deprecations/pending-removal-in-3.17.rst:14 -#: ../../deprecations/pending-removal-in-3.17.rst:42 +#: ../../deprecations/pending-removal-in-3.17.rst:22 +#: ../../deprecations/pending-removal-in-3.17.rst:68 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -4668,8 +4683,8 @@ msgstr "" "其他常見的緩衝區型別如 :class:`memoryview` 也從未被理解為 :class:`!" "ByteString` 的子型別(無論是在 runtime 還是由靜態型別檢查器)。" -#: ../../deprecations/pending-removal-in-3.17.rst:22 -#: ../../deprecations/pending-removal-in-3.17.rst:50 +#: ../../deprecations/pending-removal-in-3.17.rst:30 +#: ../../deprecations/pending-removal-in-3.17.rst:76 msgid "" "See :pep:`PEP 688 <688#current-options>` for more details. (Contributed by " "Shantanu Jain in :gh:`91896`.)" @@ -4677,7 +4692,40 @@ msgstr "" "更多細節請見 :pep:`PEP 688 <688#current-options>`。(由 Shantanu Jain 於 :gh:" "`91896` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.17.rst:28 +#: ../../deprecations/pending-removal-in-3.17.rst:34 +msgid ":mod:`encodings`:" +msgstr ":mod:`encodings`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:36 +msgid "" +"Passing non-ascii *encoding* names to :func:`encodings.normalize_encoding` " +"is deprecated and scheduled for removal in Python 3.17. (Contributed by Stan " +"Ulbrych in :gh:`136702`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:40 +msgid ":mod:`profile`:" +msgstr ":mod:`profile`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:42 +msgid "" +"The :mod:`!profile` module is deprecated and will be removed in Python 3.17. " +"Use :mod:`profiling.tracing` instead, which provides a compatible API. See :" +"pep:`799` for details. (Contributed by Pablo Galindo and László Kiss Kollár " +"in :gh:`138122`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:47 +msgid ":mod:`webbrowser`:" +msgstr ":mod:`webbrowser`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:49 +msgid "" +":class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of :class:`!" +"webbrowser.MacOS`. (:gh:`137586`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:54 msgid "" "Before Python 3.14, old-style unions were implemented using the private " "class ``typing._UnionGenericAlias``. This class is no longer needed for the " @@ -4691,7 +4739,7 @@ msgstr "" "除。使用者應該改用文件中記錄的內省輔助函式,例如 :func:`typing.get_origin` " "和 :func:`typing.get_args`,或者依賴私有實作細節。" -#: ../../deprecations/pending-removal-in-3.17.rst:33 +#: ../../deprecations/pending-removal-in-3.17.rst:59 msgid "" ":class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for " "removal in Python 3.17." @@ -4699,16 +4747,35 @@ msgstr "" ":class:`typing.ByteString` 自 Python 3.9 起已被棄用,預計在 Python 3.17 中移" "除。" +#: ../../deprecations/pending-removal-in-3.17.rst:79 +msgid ":mod:`tkinter`:" +msgstr ":mod:`tkinter`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:81 +msgid "" +"The :class:`!tkinter.Variable` methods :meth:`!trace_variable`, :meth:`!" +"trace` (an alias of :meth:`!trace_variable`), :meth:`!trace_vdelete` and :" +"meth:`!trace_vinfo`, deprecated since Python 3.14, are scheduled for removal " +"in Python 3.17. Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!" +"trace_info` instead. (Contributed by Serhiy Storchaka in :gh:`120220`.)" +msgstr "" + #: ../../deprecations/c-api-pending-removal-in-3.18.rst:2 #: ../../deprecations/pending-removal-in-3.18.rst:2 msgid "Pending removal in Python 3.18" msgstr "Python 3.18 中待移除的項目" #: ../../deprecations/pending-removal-in-3.18.rst:4 +msgid "" +"No longer accept a boolean value when a file descriptor is expected. " +"(Contributed by Serhiy Storchaka in :gh:`82626`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:7 msgid ":mod:`decimal`:" msgstr ":mod:`decimal`:" -#: ../../deprecations/pending-removal-in-3.18.rst:6 +#: ../../deprecations/pending-removal-in-3.18.rst:9 msgid "" "The non-standard and undocumented :class:`~decimal.Decimal` format specifier " "``'N'``, which is only supported in the :mod:`!decimal` module's C " @@ -4719,6 +4786,20 @@ msgstr "" "mod:`!decimal` 模組的 C 實作中被支援,自 Python 3.13 起已被棄用。(由 Serhiy " "Storchaka 於 :gh:`89902` 中貢獻。)" +#: ../../deprecations/pending-removal-in-3.18.rst:14 +#: ../../deprecations/pending-removal-in-3.20.rst:42 +msgid "Deprecations defined by :pep:`829`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:16 +msgid "``import`` lines in :file:`{name}.pth` files are silently ignored." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:18 +#: ../../deprecations/pending-removal-in-3.20.rst:50 +msgid "(Contributed by Barry Warsaw in :gh:`148641`.)" +msgstr "(由 Barry Warsaw 於 :gh:`148641` 貢獻。)" + #: ../../deprecations/pending-removal-in-3.19.rst:2 msgid "Pending removal in Python 3.19" msgstr "Python 3.19 中待移除的項目" @@ -4732,6 +4813,225 @@ msgstr "" "在非 Windows 平台上,透過設定 :attr:`~ctypes.Structure._pack_` 而沒有設定 :" "attr:`~ctypes.Structure._layout_` 來隱式地切換到與 MSVC 相容的結構佈局。" +#: ../../deprecations/pending-removal-in-3.19.rst:10 +msgid ":mod:`hashlib`:" +msgstr ":mod:`hashlib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:12 +msgid "" +"In hash function constructors such as :func:`~hashlib.new` or the direct " +"hash-named constructors such as :func:`~hashlib.md5` and :func:`~hashlib." +"sha256`, their optional initial data parameter could also be passed a " +"keyword argument named ``data=`` or ``string=`` in various :mod:`!hashlib` " +"implementations." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:18 +msgid "" +"Support for the ``string`` keyword argument name is now deprecated and " +"slated for removal in Python 3.19." +msgstr "" +"``string`` 關鍵字引數名稱的支援現已被棄用,並計劃在 Python 3.19 中移除。" + +#: ../../deprecations/pending-removal-in-3.19.rst:21 +msgid "" +"Before Python 3.13, the ``string`` keyword parameter was not correctly " +"supported depending on the backend implementation of hash functions. Prefer " +"passing the initial data as a positional argument for maximum backwards " +"compatibility." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:26 +msgid ":mod:`http.cookies`:" +msgstr ":mod:`http.cookies`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:28 +msgid "" +":meth:`http.cookies.Morsel.js_output` is deprecated and will be removed in " +"Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:31 +msgid "" +":meth:`http.cookies.BaseCookie.js_output` is deprecated and will be removed " +"in Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:34 +msgid ":mod:`imaplib`:" +msgstr ":mod:`imaplib`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:36 +msgid "" +"Altering :attr:`IMAP4.file ` is now deprecated and " +"slated for removal in Python 3.19. This property is now unused and changing " +"its value does not automatically close the current file." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:40 +msgid "" +"Before Python 3.14, this property was used to implement the corresponding " +"``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this " +"is no longer the case since then." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:2 +msgid "Pending removal in Python 3.20" +msgstr "Python 3.20 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.20.rst:4 +msgid "" +"Calling the ``__new__()`` method of :class:`struct.Struct` without the " +"*format* argument is deprecated and will be removed in Python 3.20. " +"Calling :meth:`~object.__init__` method on initialized :class:`~struct." +"Struct` objects is deprecated and will be removed in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:9 +msgid "" +"(Contributed by Sergey B Kirpichev and Serhiy Storchaka in :gh:`143715`.)" +msgstr "(由 Sergey B Kirpichev 和 Serhiy Storchaka 於 :gh:`143715` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.20.rst:11 +msgid "" +"The ``__version__``, ``version`` and ``VERSION`` attributes have been " +"deprecated in these standard library modules and will be removed in Python " +"3.20. Use :py:data:`sys.version_info` instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:15 +msgid ":mod:`argparse`" +msgstr ":mod:`argparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:16 +msgid ":mod:`csv`" +msgstr ":mod:`csv`" + +#: ../../deprecations/pending-removal-in-3.20.rst:17 +msgid ":mod:`ctypes`" +msgstr ":mod:`ctypes`" + +#: ../../deprecations/pending-removal-in-3.20.rst:18 +msgid ":mod:`!ctypes.macholib`" +msgstr ":mod:`!ctypes.macholib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:19 +msgid ":mod:`decimal` (use :data:`decimal.SPEC_VERSION` instead)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:20 +msgid ":mod:`http.server`" +msgstr ":mod:`http.server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:21 +msgid ":mod:`imaplib`" +msgstr ":mod:`imaplib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:22 +msgid ":mod:`ipaddress`" +msgstr ":mod:`ipaddress`" + +#: ../../deprecations/pending-removal-in-3.20.rst:23 +msgid ":mod:`json`" +msgstr ":mod:`json`" + +#: ../../deprecations/pending-removal-in-3.20.rst:24 +msgid ":mod:`logging` (``__date__`` also deprecated)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:25 +msgid ":mod:`optparse`" +msgstr ":mod:`optparse`" + +#: ../../deprecations/pending-removal-in-3.20.rst:26 +msgid ":mod:`pickle`" +msgstr ":mod:`pickle`" + +#: ../../deprecations/pending-removal-in-3.20.rst:27 +msgid ":mod:`platform`" +msgstr ":mod:`platform`" + +#: ../../deprecations/pending-removal-in-3.20.rst:28 +msgid ":mod:`re`" +msgstr ":mod:`re`" + +#: ../../deprecations/pending-removal-in-3.20.rst:29 +msgid ":mod:`socketserver`" +msgstr ":mod:`socketserver`" + +#: ../../deprecations/pending-removal-in-3.20.rst:30 +msgid ":mod:`tabnanny`" +msgstr ":mod:`tabnanny`" + +#: ../../deprecations/pending-removal-in-3.20.rst:31 +msgid ":mod:`tarfile`" +msgstr ":mod:`tarfile`" + +#: ../../deprecations/pending-removal-in-3.20.rst:32 +msgid ":mod:`tkinter.font`" +msgstr ":mod:`tkinter.font`" + +#: ../../deprecations/pending-removal-in-3.20.rst:33 +msgid ":mod:`tkinter.ttk`" +msgstr ":mod:`tkinter.ttk`" + +#: ../../deprecations/pending-removal-in-3.20.rst:34 +msgid ":mod:`wsgiref.simple_server`" +msgstr ":mod:`wsgiref.simple_server`" + +#: ../../deprecations/pending-removal-in-3.20.rst:35 +msgid ":mod:`xml.etree.ElementTree`" +msgstr ":mod:`xml.etree.ElementTree`" + +#: ../../deprecations/pending-removal-in-3.20.rst:36 +msgid ":mod:`!xml.sax.expatreader`" +msgstr ":mod:`!xml.sax.expatreader`" + +#: ../../deprecations/pending-removal-in-3.20.rst:37 +msgid ":mod:`xml.sax.handler`" +msgstr ":mod:`xml.sax.handler`" + +#: ../../deprecations/pending-removal-in-3.20.rst:38 +msgid ":mod:`zlib`" +msgstr ":mod:`zlib`" + +#: ../../deprecations/pending-removal-in-3.20.rst:40 +msgid "(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)" +msgstr "(由 Hugo van Kemenade 和 Stan Ulbrych 於 :gh:`76007` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.20.rst:44 +msgid "" +"Warnings are produced for ``import`` lines found in :file:`{name}.pth` files." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:47 +msgid "" +":file:`{name}.pth` files are no longer decoded in the locale encoding by " +"default. They **MUST** be encoded in ``utf-8-sig``." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:52 +msgid ":mod:`ast`:" +msgstr ":mod:`ast`:" + +#: ../../deprecations/pending-removal-in-3.20.rst:54 +msgid "" +"Creating instances of abstract AST nodes (such as :class:`ast.AST` or :class:" +"`!ast.expr`) is deprecated and will raise an error in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:59 +msgid "" +"It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on " +"protocol classes that were not explicitly decorated with :func:`!" +"runtime_checkable` but that inherit from a runtime-checkable protocol class. " +"This will raise a :exc:`TypeError` in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:64 +msgid "(Contributed by Bartosz Sławecki in :gh:`132604`.)" +msgstr "(由 Bartosz Sławecki 於 :gh:`132604` 貢獻。)" + #: ../../deprecations/c-api-pending-removal-in-future.rst:2 #: ../../deprecations/pending-removal-in-future.rst:2 msgid "Pending removal in future versions" @@ -4843,14 +5143,10 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:50 msgid "" -":attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " +":attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " "instead." msgstr "" -":attr:`codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" - -#: ../../deprecations/pending-removal-in-future.rst:53 -msgid ":mod:`datetime`:" -msgstr ":mod:`datetime`:" +":attr:`!codeobject.co_lnotab`:請改用 :meth:`codeobject.co_lines` 方法。" #: ../../deprecations/pending-removal-in-future.rst:55 msgid "" @@ -4909,18 +5205,28 @@ msgstr "" #: ../../deprecations/pending-removal-in-future.rst:78 msgid "" -":mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process." +":mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process." msgstr ":mod:`os`:在多執行緒行程中呼叫 :func:`os.register_at_fork`。" #: ../../deprecations/pending-removal-in-future.rst:80 msgid "" +":mod:`os.path`: :func:`os.path.commonprefix` is deprecated, use :func:`os." +"path.commonpath` for path prefixes. The :func:`os.path.commonprefix` " +"function is being deprecated due to having a misleading name and module. The " +"function is not safe to use for path prefixes despite being included in a " +"module about path manipulation, meaning it is easy to accidentally introduce " +"path traversal vulnerabilities into Python programs by using this function." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:88 +msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." msgstr "" ":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" "實例。" -#: ../../deprecations/pending-removal-in-future.rst:83 +#: ../../deprecations/pending-removal-in-future.rst:91 msgid "" ":mod:`re`: More strict rules are now applied for numerical group references " "and group names in regular expressions. Only sequence of ASCII digits is " @@ -4932,12 +5238,7 @@ msgstr "" "有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" "包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:90 -msgid "" -":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." -msgstr ":mod:`!sre_compile`、:mod:`!sre_constants` 和 :mod:`!sre_parse` 模組。" - -#: ../../deprecations/pending-removal-in-future.rst:92 +#: ../../deprecations/pending-removal-in-future.rst:98 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." @@ -4945,15 +5246,15 @@ msgstr "" ":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" "棄用;請改用 *onexc* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:95 +#: ../../deprecations/pending-removal-in-future.rst:101 msgid ":mod:`ssl` options and protocols:" msgstr ":mod:`ssl` 選項和協定:" -#: ../../deprecations/pending-removal-in-future.rst:97 +#: ../../deprecations/pending-removal-in-future.rst:103 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:98 +#: ../../deprecations/pending-removal-in-future.rst:104 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." @@ -4961,51 +5262,51 @@ msgstr "" ":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" "`!selected_npn_protocol` 已被棄用:請改用 ALPN。" -#: ../../deprecations/pending-removal-in-future.rst:101 +#: ../../deprecations/pending-removal-in-future.rst:107 msgid "``ssl.OP_NO_SSL*`` options" msgstr "``ssl.OP_NO_SSL*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:102 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "``ssl.OP_NO_TLS*`` options" msgstr "``ssl.OP_NO_TLS*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:103 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid "``ssl.PROTOCOL_SSLv3``" msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:104 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "``ssl.PROTOCOL_TLS``" msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:105 +#: ../../deprecations/pending-removal-in-future.rst:111 msgid "``ssl.PROTOCOL_TLSv1``" msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:106 +#: ../../deprecations/pending-removal-in-future.rst:112 msgid "``ssl.PROTOCOL_TLSv1_1``" msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:107 +#: ../../deprecations/pending-removal-in-future.rst:113 msgid "``ssl.PROTOCOL_TLSv1_2``" msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:108 +#: ../../deprecations/pending-removal-in-future.rst:114 msgid "``ssl.TLSVersion.SSLv3``" msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:109 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid "``ssl.TLSVersion.TLSv1``" msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:110 +#: ../../deprecations/pending-removal-in-future.rst:116 msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:118 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:114 +#: ../../deprecations/pending-removal-in-future.rst:120 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -5013,11 +5314,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:121 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" -#: ../../deprecations/pending-removal-in-future.rst:116 +#: ../../deprecations/pending-removal-in-future.rst:122 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -5025,7 +5326,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:118 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -5033,20 +5334,20 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:120 +#: ../../deprecations/pending-removal-in-future.rst:126 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:121 +#: ../../deprecations/pending-removal-in-future.rst:127 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:123 +#: ../../deprecations/pending-removal-in-future.rst:129 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:131 msgid "" "The internal class ``typing._UnionGenericAlias`` is no longer used to " "implement :class:`typing.Union`. To preserve compatibility with users using " @@ -5057,7 +5358,7 @@ msgstr "" "了保持與此私有類別使用者的相容性,直到至少 Python 3.17 都將提供一個相容性 " "shim。(由 Jelle Zijlstra 於 :gh:`105499` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:130 +#: ../../deprecations/pending-removal-in-future.rst:136 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -5065,64 +5366,64 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:139 msgid "" ":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " "instead" msgstr "" ":mod:`urllib.parse` 已棄用函式:請改用 :func:`~urllib.parse.urlparse`。" -#: ../../deprecations/pending-removal-in-future.rst:135 +#: ../../deprecations/pending-removal-in-future.rst:141 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:136 +#: ../../deprecations/pending-removal-in-future.rst:142 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:137 +#: ../../deprecations/pending-removal-in-future.rst:143 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:138 +#: ../../deprecations/pending-removal-in-future.rst:144 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:139 +#: ../../deprecations/pending-removal-in-future.rst:145 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:140 +#: ../../deprecations/pending-removal-in-future.rst:146 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:141 +#: ../../deprecations/pending-removal-in-future.rst:147 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:142 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:143 +#: ../../deprecations/pending-removal-in-future.rst:149 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:144 +#: ../../deprecations/pending-removal-in-future.rst:150 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:145 +#: ../../deprecations/pending-removal-in-future.rst:151 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:147 +#: ../../deprecations/pending-removal-in-future.rst:153 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:150 +#: ../../deprecations/pending-removal-in-future.rst:156 msgid "" ":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." "etree.ElementTree.Element` is deprecated. In a future release it will always " @@ -5133,7 +5434,7 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:155 +#: ../../deprecations/pending-removal-in-future.rst:161 msgid "" ":func:`sys._clear_type_cache` is deprecated: use :func:`sys." "_clear_internal_caches` instead." @@ -5141,18 +5442,18 @@ msgstr "" ":func:`sys._clear_type_cache` 已被棄用:請改用 :func:`sys." "_clear_internal_caches`。" -#: ../../whatsnew/3.14.rst:2760 +#: ../../whatsnew/3.14.rst:2761 msgid "CPython bytecode changes" msgstr "CPython 位元組碼變更" -#: ../../whatsnew/3.14.rst:2762 +#: ../../whatsnew/3.14.rst:2763 msgid "" "Replaced the opcode :opcode:`!BINARY_SUBSCR` by the :opcode:`BINARY_OP` " "opcode with the ``NB_SUBSCR`` oparg. (Contributed by Irit Katriel in :gh:" "`100239`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2766 +#: ../../whatsnew/3.14.rst:2767 msgid "" "Add the :opcode:`BUILD_INTERPOLATION` and :opcode:`BUILD_TEMPLATE` opcodes " "to construct new :class:`~string.templatelib.Interpolation` and :class:" @@ -5161,20 +5462,20 @@ msgid "" "Template strings `)." msgstr "" -#: ../../whatsnew/3.14.rst:2772 +#: ../../whatsnew/3.14.rst:2773 msgid "" "Remove the :opcode:`!BUILD_CONST_KEY_MAP` opcode. Use :opcode:`BUILD_MAP` " "instead. (Contributed by Mark Shannon in :gh:`122160`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2776 +#: ../../whatsnew/3.14.rst:2777 msgid "" "Replace the :opcode:`!LOAD_ASSERTION_ERROR` opcode with :opcode:" "`LOAD_COMMON_CONSTANT` and add support for loading :exc:" "`NotImplementedError`." msgstr "" -#: ../../whatsnew/3.14.rst:2780 +#: ../../whatsnew/3.14.rst:2781 msgid "" "Add the :opcode:`LOAD_FAST_BORROW` and :opcode:" "`LOAD_FAST_BORROW_LOAD_FAST_BORROW` opcodes to reduce reference counting " @@ -5183,14 +5484,14 @@ msgid "" "gh:`130704`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2785 +#: ../../whatsnew/3.14.rst:2786 msgid "" "Add the :opcode:`LOAD_SMALL_INT` opcode, which pushes a small integer equal " "to the ``oparg`` to the stack. The :opcode:`!RETURN_CONST` opcode is removed " "as it is no longer used. (Contributed by Mark Shannon in :gh:`125837`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2790 +#: ../../whatsnew/3.14.rst:2791 msgid "" "Add the new :opcode:`LOAD_SPECIAL` instruction. Generate code for :keyword:" "`with` and :keyword:`async with` statements using the new instruction. " @@ -5198,17 +5499,17 @@ msgid "" "instructions. (Contributed by Mark Shannon in :gh:`120507`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2796 +#: ../../whatsnew/3.14.rst:2797 msgid "" "Add the :opcode:`POP_ITER` opcode to support 'virtual' iterators. " "(Contributed by Mark Shannon in :gh:`132554`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2801 +#: ../../whatsnew/3.14.rst:2802 msgid "Pseudo-instructions" msgstr "" -#: ../../whatsnew/3.14.rst:2803 +#: ../../whatsnew/3.14.rst:2804 msgid "" "Add the :opcode:`!ANNOTATIONS_PLACEHOLDER` pseudo instruction to support " "partially executed module-level annotations with :ref:`deferred evaluation " @@ -5216,14 +5517,14 @@ msgid "" "Zijlstra in :gh:`130907`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2808 +#: ../../whatsnew/3.14.rst:2809 msgid "" "Add the :opcode:`!BINARY_OP_EXTEND` pseudo instruction, which executes a " "pair of functions (guard and specialization functions) accessed from the " "inline cache. (Contributed by Irit Katriel in :gh:`100239`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2813 +#: ../../whatsnew/3.14.rst:2814 msgid "" "Add three specializations for :opcode:`CALL_KW`; :opcode:`!CALL_KW_PY` for " "calls to Python functions, :opcode:`!CALL_KW_BOUND_METHOD` for calls to " @@ -5231,7 +5532,7 @@ msgid "" "(Contributed by Mark Shannon in :gh:`118093`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2819 +#: ../../whatsnew/3.14.rst:2820 msgid "" "Add the :opcode:`JUMP_IF_TRUE` and :opcode:`JUMP_IF_FALSE` pseudo " "instructions, conditional jumps which do not impact the stack. Replaced by " @@ -5239,55 +5540,55 @@ msgid "" "(Contributed by Irit Katriel in :gh:`124285`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2824 +#: ../../whatsnew/3.14.rst:2825 msgid "" "Add the :opcode:`!LOAD_CONST_MORTAL` pseudo instruction. (Contributed by " "Mark Shannon in :gh:`128685`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2827 +#: ../../whatsnew/3.14.rst:2828 msgid "" -"Add the :opcode:`LOAD_CONST_IMMORTAL` pseudo instruction, which does the " +"Add the :opcode:`!LOAD_CONST_IMMORTAL` pseudo instruction, which does the " "same as :opcode:`!LOAD_CONST`, but is more efficient for immortal objects. " "(Contributed by Mark Shannon in :gh:`125837`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2832 +#: ../../whatsnew/3.14.rst:2833 msgid "" "Add the :opcode:`NOT_TAKEN` pseudo instruction, used by :mod:`sys." "monitoring` to record branch events (such as :monitoring-event:" "`BRANCH_LEFT`). (Contributed by Mark Shannon in :gh:`122548`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2838 +#: ../../whatsnew/3.14.rst:2839 msgid "C API changes" msgstr "C API 變更" -#: ../../whatsnew/3.14.rst:2843 +#: ../../whatsnew/3.14.rst:2844 msgid "Python configuration C API" msgstr "Python 配置 C API" -#: ../../whatsnew/3.14.rst:2845 +#: ../../whatsnew/3.14.rst:2846 msgid "" "Add a :ref:`PyInitConfig C API ` to configure the Python " "initialization without relying on C structures and the ability to make ABI-" "compatible changes in the future." msgstr "" -#: ../../whatsnew/3.14.rst:2849 +#: ../../whatsnew/3.14.rst:2850 msgid "" "Complete the :pep:`587` :ref:`PyConfig C API ` by adding :c:" "func:`PyInitConfig_AddModule` which can be used to add a built-in extension " "module; a feature previously referred to as the \"inittab\"." msgstr "" -#: ../../whatsnew/3.14.rst:2853 +#: ../../whatsnew/3.14.rst:2854 msgid "" "Add :c:func:`PyConfig_Get` and :c:func:`PyConfig_Set` functions to get and " "set the current runtime configuration." msgstr "" -#: ../../whatsnew/3.14.rst:2856 +#: ../../whatsnew/3.14.rst:2857 msgid "" ":pep:`587` 'Python Initialization Configuration' unified all the ways to " "configure Python's initialization. This PEP also unifies the configuration " @@ -5296,7 +5597,7 @@ msgid "" "two 'Python' and 'Isolated' choices (PEP 587), to further simplify the API." msgstr "" -#: ../../whatsnew/3.14.rst:2863 +#: ../../whatsnew/3.14.rst:2864 msgid "" "The lower level PEP 587 PyConfig API remains available for use cases with an " "intentionally higher level of coupling to CPython implementation details " @@ -5304,20 +5605,20 @@ msgid "" "configuration mechanisms)." msgstr "" -#: ../../whatsnew/3.14.rst:2868 ../../whatsnew/3.14.rst:2895 -#: ../../whatsnew/3.14.rst:2915 +#: ../../whatsnew/3.14.rst:2869 ../../whatsnew/3.14.rst:2896 +#: ../../whatsnew/3.14.rst:2916 msgid "(Contributed by Victor Stinner in :gh:`107954`.)" msgstr "(由 Victor Stinner 於 :gh:`107954` 貢獻。)" -#: ../../whatsnew/3.14.rst:2870 +#: ../../whatsnew/3.14.rst:2871 msgid ":pep:`741` and :pep:`587`" msgstr ":pep:`741` 和 :pep:`587`" -#: ../../whatsnew/3.14.rst:2874 +#: ../../whatsnew/3.14.rst:2875 msgid "New features in the C API" msgstr "C API 中的新功能" -#: ../../whatsnew/3.14.rst:2876 +#: ../../whatsnew/3.14.rst:2877 msgid "" "Add :c:func:`Py_PACK_VERSION` and :c:func:`Py_PACK_FULL_VERSION`, two new " "macros for bit-packing Python version numbers. This is useful for " @@ -5325,14 +5626,14 @@ msgid "" "(Contributed by Petr Viktorin in :gh:`128629`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2882 +#: ../../whatsnew/3.14.rst:2883 msgid "" "Add :c:func:`PyBytes_Join(sep, iterable) ` function, similar " "to ``sep.join(iterable)`` in Python. (Contributed by Victor Stinner in :gh:" "`121645`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2886 +#: ../../whatsnew/3.14.rst:2887 msgid "" "Add functions to manipulate the configuration of the current runtime Python " "interpreter (:ref:`PEP 741: Python configuration C API `):" -#: ../../whatsnew/3.14.rst:2890 +#: ../../whatsnew/3.14.rst:2891 msgid ":c:func:`PyConfig_Get`" msgstr ":c:func:`PyConfig_Get`" -#: ../../whatsnew/3.14.rst:2891 +#: ../../whatsnew/3.14.rst:2892 msgid ":c:func:`PyConfig_GetInt`" msgstr ":c:func:`PyConfig_GetInt`" -#: ../../whatsnew/3.14.rst:2892 +#: ../../whatsnew/3.14.rst:2893 msgid ":c:func:`PyConfig_Set`" msgstr ":c:func:`PyConfig_Set`" -#: ../../whatsnew/3.14.rst:2893 +#: ../../whatsnew/3.14.rst:2894 msgid ":c:func:`PyConfig_Names`" msgstr ":c:func:`PyConfig_Names`" -#: ../../whatsnew/3.14.rst:2897 +#: ../../whatsnew/3.14.rst:2898 msgid "" "Add functions to configure Python initialization (:ref:`PEP 741: Python " "configuration C API `):" @@ -5365,63 +5666,63 @@ msgstr "" "新增用於配置 Python 初始化的函式(:ref:`PEP 741:Python 配置 C API " "`):" -#: ../../whatsnew/3.14.rst:2900 +#: ../../whatsnew/3.14.rst:2901 msgid ":c:func:`Py_InitializeFromInitConfig`" msgstr ":c:func:`Py_InitializeFromInitConfig`" -#: ../../whatsnew/3.14.rst:2901 +#: ../../whatsnew/3.14.rst:2902 msgid ":c:func:`PyInitConfig_AddModule`" msgstr ":c:func:`PyInitConfig_AddModule`" -#: ../../whatsnew/3.14.rst:2902 +#: ../../whatsnew/3.14.rst:2903 msgid ":c:func:`PyInitConfig_Create`" msgstr ":c:func:`PyInitConfig_Create`" -#: ../../whatsnew/3.14.rst:2903 +#: ../../whatsnew/3.14.rst:2904 msgid ":c:func:`PyInitConfig_Free`" msgstr ":c:func:`PyInitConfig_Free`" -#: ../../whatsnew/3.14.rst:2904 +#: ../../whatsnew/3.14.rst:2905 msgid ":c:func:`PyInitConfig_FreeStrList`" msgstr ":c:func:`PyInitConfig_FreeStrList`" -#: ../../whatsnew/3.14.rst:2905 +#: ../../whatsnew/3.14.rst:2906 msgid ":c:func:`PyInitConfig_GetError`" msgstr ":c:func:`PyInitConfig_GetError`" -#: ../../whatsnew/3.14.rst:2906 +#: ../../whatsnew/3.14.rst:2907 msgid ":c:func:`PyInitConfig_GetExitCode`" msgstr ":c:func:`PyInitConfig_GetExitCode`" -#: ../../whatsnew/3.14.rst:2907 +#: ../../whatsnew/3.14.rst:2908 msgid ":c:func:`PyInitConfig_GetInt`" msgstr ":c:func:`PyInitConfig_GetInt`" -#: ../../whatsnew/3.14.rst:2908 +#: ../../whatsnew/3.14.rst:2909 msgid ":c:func:`PyInitConfig_GetStr`" msgstr ":c:func:`PyInitConfig_GetStr`" -#: ../../whatsnew/3.14.rst:2909 +#: ../../whatsnew/3.14.rst:2910 msgid ":c:func:`PyInitConfig_GetStrList`" msgstr ":c:func:`PyInitConfig_GetStrList`" -#: ../../whatsnew/3.14.rst:2910 +#: ../../whatsnew/3.14.rst:2911 msgid ":c:func:`PyInitConfig_HasOption`" msgstr ":c:func:`PyInitConfig_HasOption`" -#: ../../whatsnew/3.14.rst:2911 +#: ../../whatsnew/3.14.rst:2912 msgid ":c:func:`PyInitConfig_SetInt`" msgstr ":c:func:`PyInitConfig_SetInt`" -#: ../../whatsnew/3.14.rst:2912 +#: ../../whatsnew/3.14.rst:2913 msgid ":c:func:`PyInitConfig_SetStr`" msgstr ":c:func:`PyInitConfig_SetStr`" -#: ../../whatsnew/3.14.rst:2913 +#: ../../whatsnew/3.14.rst:2914 msgid ":c:func:`PyInitConfig_SetStrList`" msgstr ":c:func:`PyInitConfig_SetStrList`" -#: ../../whatsnew/3.14.rst:2917 +#: ../../whatsnew/3.14.rst:2918 msgid "" "Add :c:func:`Py_fopen` function to open a file. This works similarly to the " "standard C :c:func:`!fopen` function, instead accepting a Python object for " @@ -5430,13 +5731,13 @@ msgid "" "(Contributed by Victor Stinner in :gh:`127350`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2925 +#: ../../whatsnew/3.14.rst:2926 msgid "" "Add :c:func:`Py_HashBuffer` to compute and return the hash value of a " "buffer. (Contributed by Antoine Pitrou and Victor Stinner in :gh:`122854`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2928 +#: ../../whatsnew/3.14.rst:2929 msgid "" "Add :c:func:`PyImport_ImportModuleAttr` and :c:func:" "`PyImport_ImportModuleAttrString` helper functions to import a module and " @@ -5444,20 +5745,20 @@ msgid "" "`128911`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2933 +#: ../../whatsnew/3.14.rst:2934 msgid "" "Add :c:func:`PyIter_NextItem` to replace :c:func:`PyIter_Next`, which has an " "ambiguous return value. (Contributed by Irit Katriel and Erlend Aasland in :" "gh:`105201`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2937 +#: ../../whatsnew/3.14.rst:2938 msgid "" "Add :c:func:`PyLong_GetSign` function to get the sign of :class:`int` " "objects. (Contributed by Sergey B Kirpichev in :gh:`116560`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2940 +#: ../../whatsnew/3.14.rst:2941 msgid "" "Add :c:func:`PyLong_IsPositive`, :c:func:`PyLong_IsNegative` and :c:func:" "`PyLong_IsZero` for checking if :c:type:`PyLongObject` is positive, " @@ -5465,82 +5766,82 @@ msgid "" "Kirpichev in :gh:`126061`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2945 +#: ../../whatsnew/3.14.rst:2946 msgid "" "Add new functions to convert C ```` numbers to/from Python :class:" "`int` objects:" msgstr "" -#: ../../whatsnew/3.14.rst:2948 +#: ../../whatsnew/3.14.rst:2949 msgid ":c:func:`PyLong_AsInt32`" msgstr ":c:func:`PyLong_AsInt32`" -#: ../../whatsnew/3.14.rst:2949 +#: ../../whatsnew/3.14.rst:2950 msgid ":c:func:`PyLong_AsInt64`" msgstr ":c:func:`PyLong_AsInt64`" -#: ../../whatsnew/3.14.rst:2950 +#: ../../whatsnew/3.14.rst:2951 msgid ":c:func:`PyLong_AsUInt32`" msgstr ":c:func:`PyLong_AsUInt32`" -#: ../../whatsnew/3.14.rst:2951 +#: ../../whatsnew/3.14.rst:2952 msgid ":c:func:`PyLong_AsUInt64`" msgstr ":c:func:`PyLong_AsUInt64`" -#: ../../whatsnew/3.14.rst:2952 +#: ../../whatsnew/3.14.rst:2953 msgid ":c:func:`PyLong_FromInt32`" msgstr ":c:func:`PyLong_FromInt32`" -#: ../../whatsnew/3.14.rst:2953 +#: ../../whatsnew/3.14.rst:2954 msgid ":c:func:`PyLong_FromInt64`" msgstr ":c:func:`PyLong_FromInt64`" -#: ../../whatsnew/3.14.rst:2954 +#: ../../whatsnew/3.14.rst:2955 msgid ":c:func:`PyLong_FromUInt32`" msgstr ":c:func:`PyLong_FromUInt32`" -#: ../../whatsnew/3.14.rst:2955 +#: ../../whatsnew/3.14.rst:2956 msgid ":c:func:`PyLong_FromUInt64`" msgstr ":c:func:`PyLong_FromUInt64`" -#: ../../whatsnew/3.14.rst:2957 +#: ../../whatsnew/3.14.rst:2958 msgid "(Contributed by Victor Stinner in :gh:`120389`.)" msgstr "(由 Victor Stinner 於 :gh:`120389` 貢獻。)" -#: ../../whatsnew/3.14.rst:2959 +#: ../../whatsnew/3.14.rst:2960 msgid "" "Add a new import and export API for Python :class:`int` objects (:pep:`757`):" msgstr "" -#: ../../whatsnew/3.14.rst:2962 +#: ../../whatsnew/3.14.rst:2963 msgid ":c:func:`PyLong_GetNativeLayout`" msgstr ":c:func:`PyLong_GetNativeLayout`" -#: ../../whatsnew/3.14.rst:2963 +#: ../../whatsnew/3.14.rst:2964 msgid ":c:func:`PyLong_Export`" msgstr ":c:func:`PyLong_Export`" -#: ../../whatsnew/3.14.rst:2964 +#: ../../whatsnew/3.14.rst:2965 msgid ":c:func:`PyLong_FreeExport`" msgstr ":c:func:`PyLong_FreeExport`" -#: ../../whatsnew/3.14.rst:2965 +#: ../../whatsnew/3.14.rst:2966 msgid ":c:func:`PyLongWriter_Create`" msgstr ":c:func:`PyLongWriter_Create`" -#: ../../whatsnew/3.14.rst:2966 +#: ../../whatsnew/3.14.rst:2967 msgid ":c:func:`PyLongWriter_Finish`" msgstr ":c:func:`PyLongWriter_Finish`" -#: ../../whatsnew/3.14.rst:2967 +#: ../../whatsnew/3.14.rst:2968 msgid ":c:func:`PyLongWriter_Discard`" msgstr ":c:func:`PyLongWriter_Discard`" -#: ../../whatsnew/3.14.rst:2969 +#: ../../whatsnew/3.14.rst:2970 msgid "(Contributed by Sergey B Kirpichev and Victor Stinner in :gh:`102471`.)" msgstr "(由 Sergey B Kirpichev 和 Victor Stinner 於 :gh:`102471` 貢獻。)" -#: ../../whatsnew/3.14.rst:2971 +#: ../../whatsnew/3.14.rst:2972 msgid "" "Add :c:func:`PyMonitoring_FireBranchLeftEvent` and :c:func:" "`PyMonitoring_FireBranchRightEvent` for generating :monitoring-event:" @@ -5548,13 +5849,13 @@ msgid "" "(Contributed by Mark Shannon in :gh:`122548`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2977 +#: ../../whatsnew/3.14.rst:2978 msgid "" "Add :c:func:`PyType_Freeze` function to make a type immutable. (Contributed " "by Victor Stinner in :gh:`121654`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2980 +#: ../../whatsnew/3.14.rst:2981 msgid "" "Add :c:func:`PyType_GetBaseByToken` and :c:data:`Py_tp_token` slot for " "easier superclass identification, which attempts to resolve the type " @@ -5562,110 +5863,110 @@ msgid "" "in :gh:`124153`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2985 +#: ../../whatsnew/3.14.rst:2986 msgid "" "Add a new :c:func:`PyUnicode_Equal` function to test if two strings are " "equal. The function is also added to the Limited C API. (Contributed by " "Victor Stinner in :gh:`124502`.)" msgstr "" -#: ../../whatsnew/3.14.rst:2990 +#: ../../whatsnew/3.14.rst:2991 msgid "" "Add a new :c:type:`PyUnicodeWriter` API to create a Python :class:`str` " "object, with the following functions:" msgstr "" -#: ../../whatsnew/3.14.rst:2993 +#: ../../whatsnew/3.14.rst:2994 msgid ":c:func:`PyUnicodeWriter_Create`" msgstr ":c:func:`PyUnicodeWriter_Create`" -#: ../../whatsnew/3.14.rst:2994 +#: ../../whatsnew/3.14.rst:2995 msgid ":c:func:`PyUnicodeWriter_DecodeUTF8Stateful`" msgstr ":c:func:`PyUnicodeWriter_DecodeUTF8Stateful`" -#: ../../whatsnew/3.14.rst:2995 +#: ../../whatsnew/3.14.rst:2996 msgid ":c:func:`PyUnicodeWriter_Discard`" msgstr ":c:func:`PyUnicodeWriter_Discard`" -#: ../../whatsnew/3.14.rst:2996 +#: ../../whatsnew/3.14.rst:2997 msgid ":c:func:`PyUnicodeWriter_Finish`" msgstr ":c:func:`PyUnicodeWriter_Finish`" -#: ../../whatsnew/3.14.rst:2997 +#: ../../whatsnew/3.14.rst:2998 msgid ":c:func:`PyUnicodeWriter_Format`" msgstr ":c:func:`PyUnicodeWriter_Format`" -#: ../../whatsnew/3.14.rst:2998 +#: ../../whatsnew/3.14.rst:2999 msgid ":c:func:`PyUnicodeWriter_WriteASCII`" msgstr ":c:func:`PyUnicodeWriter_WriteASCII`" -#: ../../whatsnew/3.14.rst:2999 +#: ../../whatsnew/3.14.rst:3000 msgid ":c:func:`PyUnicodeWriter_WriteChar`" msgstr ":c:func:`PyUnicodeWriter_WriteChar`" -#: ../../whatsnew/3.14.rst:3000 +#: ../../whatsnew/3.14.rst:3001 msgid ":c:func:`PyUnicodeWriter_WriteRepr`" msgstr ":c:func:`PyUnicodeWriter_WriteRepr`" -#: ../../whatsnew/3.14.rst:3001 +#: ../../whatsnew/3.14.rst:3002 msgid ":c:func:`PyUnicodeWriter_WriteStr`" msgstr ":c:func:`PyUnicodeWriter_WriteStr`" -#: ../../whatsnew/3.14.rst:3002 +#: ../../whatsnew/3.14.rst:3003 msgid ":c:func:`PyUnicodeWriter_WriteSubstring`" msgstr ":c:func:`PyUnicodeWriter_WriteSubstring`" -#: ../../whatsnew/3.14.rst:3003 +#: ../../whatsnew/3.14.rst:3004 msgid ":c:func:`PyUnicodeWriter_WriteUCS4`" msgstr ":c:func:`PyUnicodeWriter_WriteUCS4`" -#: ../../whatsnew/3.14.rst:3004 +#: ../../whatsnew/3.14.rst:3005 msgid ":c:func:`PyUnicodeWriter_WriteUTF8`" msgstr ":c:func:`PyUnicodeWriter_WriteUTF8`" -#: ../../whatsnew/3.14.rst:3005 +#: ../../whatsnew/3.14.rst:3006 msgid ":c:func:`PyUnicodeWriter_WriteWideChar`" msgstr ":c:func:`PyUnicodeWriter_WriteWideChar`" -#: ../../whatsnew/3.14.rst:3007 +#: ../../whatsnew/3.14.rst:3008 msgid "(Contributed by Victor Stinner in :gh:`119182`.)" msgstr "(由 Victor Stinner 於 :gh:`119182` 貢獻。)" -#: ../../whatsnew/3.14.rst:3009 +#: ../../whatsnew/3.14.rst:3010 msgid "" "The ``k`` and ``K`` formats in :c:func:`PyArg_ParseTuple` and similar " "functions now use :meth:`~object.__index__` if available, like all other " "integer formats. (Contributed by Serhiy Storchaka in :gh:`112068`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3014 +#: ../../whatsnew/3.14.rst:3015 msgid "" "Add support for a new ``p`` format unit in :c:func:`Py_BuildValue` that " "produces a Python :class:`bool` object from a C integer. (Contributed by " "Pablo Galindo in :issue:`45325`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3018 +#: ../../whatsnew/3.14.rst:3019 msgid "" "Add :c:func:`PyUnstable_IsImmortal` for determining if an object is :term:" "`immortal`, for debugging purposes. (Contributed by Peter Bierma in :gh:" "`128509`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3022 +#: ../../whatsnew/3.14.rst:3023 msgid "" "Add :c:func:`PyUnstable_Object_EnableDeferredRefcount` for enabling deferred " "reference counting, as outlined in :pep:`703`." msgstr "" -#: ../../whatsnew/3.14.rst:3025 +#: ../../whatsnew/3.14.rst:3026 msgid "" "Add :c:func:`PyUnstable_Object_IsUniquelyReferenced` as a replacement for " "``Py_REFCNT(op) == 1`` on :term:`free threaded ` builds. " "(Contributed by Peter Bierma in :gh:`133140`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3030 +#: ../../whatsnew/3.14.rst:3031 msgid "" "Add :c:func:`PyUnstable_Object_IsUniqueReferencedTemporary` to determine if " "an object is a unique temporary object on the interpreter's operand stack. " @@ -5674,11 +5975,11 @@ msgid "" "functions. (Contributed by Sam Gross in :gh:`133164`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3040 +#: ../../whatsnew/3.14.rst:3041 msgid "Limited C API changes" msgstr "" -#: ../../whatsnew/3.14.rst:3042 +#: ../../whatsnew/3.14.rst:3043 msgid "" "In the limited C API version 3.14 and newer, :c:func:`Py_TYPE` and :c:func:" "`Py_REFCNT` are now implemented as an opaque function call to hide " @@ -5686,7 +5987,7 @@ msgid "" "gh:`124127`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3047 +#: ../../whatsnew/3.14.rst:3048 msgid "" "Remove the :c:macro:`PySequence_Fast_GET_SIZE`, :c:macro:" "`PySequence_Fast_GET_ITEM`, and :c:macro:`PySequence_Fast_ITEMS` macros from " @@ -5694,32 +5995,32 @@ msgid "" "(Contributed by Victor Stinner in :gh:`91417`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3058 +#: ../../whatsnew/3.14.rst:3059 msgid "Removed C APIs" msgstr "被移除的 C API" -#: ../../whatsnew/3.14.rst:3060 +#: ../../whatsnew/3.14.rst:3061 msgid "" "Creating :c:data:`immutable types ` with mutable " "bases was deprecated in Python 3.12, and now raises a :exc:`TypeError`. " "(Contributed by Nikita Sobolev in :gh:`119775`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3065 +#: ../../whatsnew/3.14.rst:3066 msgid "" "Remove ``PyDictObject.ma_version_tag`` member, which was deprecated in " "Python 3.12. Use the :c:func:`PyDict_AddWatcher` API instead. (Contributed " "by Sam Gross in :gh:`124296`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3070 +#: ../../whatsnew/3.14.rst:3071 msgid "" "Remove the private ``_Py_InitializeMain()`` function. It was a :term:" "`provisional API` added to Python 3.8 by :pep:`587`. (Contributed by Victor " "Stinner in :gh:`129033`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3074 +#: ../../whatsnew/3.14.rst:3075 msgid "" "Remove the undocumented APIs :c:macro:`!Py_C_RECURSION_LIMIT` and :c:member:" "`!PyThreadState.c_recursion_remaining`. These were added in 3.13 and have " @@ -5728,18 +6029,18 @@ msgid "" "`133079`, see also :gh:`130396`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3085 +#: ../../whatsnew/3.14.rst:3086 msgid "Deprecated C APIs" msgstr "已棄用的 C API" -#: ../../whatsnew/3.14.rst:3087 +#: ../../whatsnew/3.14.rst:3088 msgid "" "The :c:macro:`!Py_HUGE_VAL` macro is now :term:`soft deprecated`. Use :c:" -"macro:`!Py_INFINITY` instead. (Contributed by Sergey B Kirpichev in :gh:" +"macro:`!INFINITY` instead. (Contributed by Sergey B Kirpichev in :gh:" "`120026`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3091 +#: ../../whatsnew/3.14.rst:3092 msgid "" "The :c:macro:`!Py_IS_NAN`, :c:macro:`!Py_IS_INFINITY`, and :c:macro:`!" "Py_IS_FINITE` macros are now :term:`soft deprecated`. Use :c:macro:`!" @@ -5747,7 +6048,7 @@ msgid "" "file:`math.h` since C99. (Contributed by Sergey B Kirpichev in :gh:`119613`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3097 +#: ../../whatsnew/3.14.rst:3098 msgid "" "Non-tuple sequences are now deprecated as argument for the ``(items)`` " "format unit in :c:func:`PyArg_ParseTuple` and other :ref:`argument parsing " @@ -5756,14 +6057,14 @@ msgid "" "(Contributed by Serhiy Storchaka in :gh:`50333`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3104 +#: ../../whatsnew/3.14.rst:3105 msgid "" "The ``_PyMonitoring_FireBranchEvent`` function is now deprecated and should " "be replaced with calls to :c:func:`PyMonitoring_FireBranchLeftEvent` and :c:" "func:`PyMonitoring_FireBranchRightEvent`." msgstr "" -#: ../../whatsnew/3.14.rst:3109 +#: ../../whatsnew/3.14.rst:3110 msgid "" "The previously undocumented function :c:func:`PySequence_In` is now :term:" "`soft deprecated`. Use :c:func:`PySequence_Contains` instead. (Contributed " @@ -5772,39 +6073,31 @@ msgstr "" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 msgid "" -"The :c:func:`PyImport_ImportModuleNoBlock`: Use :c:func:" +"The :c:func:`!PyImport_ImportModuleNoBlock`: Use :c:func:" "`PyImport_ImportModule` instead." msgstr "" -":c:func:`PyImport_ImportModuleNoBlock`:請改用 :c:func:" -"`PyImport_ImportModule`。" +":c:func:`!PyImport_ImportModuleNoBlock`:請改" +"用 :c:func:`PyImport_ImportModule`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 msgid "" -":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" +":c:func:`!PyWeakref_GetObject` and :c:func:`!PyWeakref_GET_OBJECT`: Use :c:" "func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project `__ can be used to get :c:func:" "`PyWeakref_GetRef` on Python 3.12 and older." msgstr "" -":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改用 :c:" -"func:`PyWeakref_GetRef`。可以使用 `pythoncapi-compat 專案 `__\\ 來為 Python 3.12 和更早版本取得 :c:func:" -"`PyWeakref_GetRef`。" +":c:func:`!PyWeakref_GetObject` 和 :c:func:`!PyWeakref_GET_OBJECT`:請改" +"用 :c:func:`PyWeakref_GetRef`。可以使用 `pythoncapi-compat 專案 `__\\ 來為 Python 3.12 和更早版本取" +"得 :c:func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 msgid "" -":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" -"type:`wchar_t` instead." -msgstr "" -":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:type:" -"`wchar_t`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 -msgid "" ":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" ":c:func:`!PyUnicode_AsDecodedObject`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" ":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -5814,13 +6107,13 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`str` 的型別,例如 :" "class:`bytes`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 msgid "" ":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." msgstr "" ":c:func:`!PyUnicode_AsEncodedObject`:請改用 :c:func:`PyCodec_Encode`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:19 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid "" ":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " @@ -5830,68 +6123,69 @@ msgstr "" "意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`bytes` 的型別,例如 :" "class:`str`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 msgid "Python initialization functions, deprecated in Python 3.13:" msgstr "Python 初始化函式,自 Python 3.13 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 msgid "" -":c:func:`Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`) instead." msgstr "" -":c:func:`Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " +":c:func:`!Py_GetPath`:請改用 :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:27 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" -":c:func:`Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " +":c:func:`!Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) if :ref:" "`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " +":c:func:`!Py_GetPrefix`:請改用 :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`)。如果需要處理\\ :ref:`虛擬環境 " -"`,請改用 :c:func:`PyConfig_Get(\"prefix\") ` (:data:" -"`sys.prefix`)。" +"`,請改用 :c:func:`PyConfig_Get(\"prefix\") ` " +"(:data:`sys.prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:32 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:30 msgid "" -":c:func:`Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " +":c:func:`!Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " "` (:data:`sys.base_exec_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) if :" "ref:`virtual environments ` need to be handled." msgstr "" -":c:func:`Py_GetExecPrefix`:請改用 :c:func:" -"`PyConfig_Get(\"base_exec_prefix\") ` (:data:`sys." -"base_exec_prefix`)。如果需要處理\\ :ref:`虛擬環境 `,請改用 :c:" -"func:`PyConfig_Get(\"exec_prefix\") ` (:data:`sys." -"exec_prefix`)。" +":c:func:`!Py_GetExecPrefix`:請改" +"用 :c:func:`PyConfig_Get(\"base_exec_prefix\") ` " +"(:data:`sys.base_exec_prefix`)。如果需要處理\\ :ref:`虛擬環境 `,請" +"改用 :c:func:`PyConfig_Get(\"exec_prefix\") ` " +"(:data:`sys.exec_prefix`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:38 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:36 msgid "" -":c:func:`Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramFullPath`:請改用 :c:func:" -"`PyConfig_Get(\"executable\") ` (:data:`sys.executable`)。" +":c:func:`!Py_GetProgramFullPath`:請改" +"用 :c:func:`PyConfig_Get(\"executable\") ` " +"(:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:41 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:39 msgid "" -":c:func:`Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" -":c:func:`Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " +":c:func:`!Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`)。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:44 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:42 msgid "" -":c:func:`Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " "` or the :envvar:`PYTHONHOME` environment variable instead." msgstr "" -":c:func:`Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " +":c:func:`!Py_GetPythonHome`:請改用 :c:func:`PyConfig_Get(\"home\") " "` 或 :envvar:`PYTHONHOME` 環境變數。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:48 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:46 msgid "" "The `pythoncapi-compat project `__ can be used to get :c:func:`PyConfig_Get` on Python 3.13 and older." @@ -5899,50 +6193,50 @@ msgstr "" "`pythoncapi-compat 專案 `__ 可" "以用來為 Python 3.13 和更早版本取得 :c:func:`PyConfig_Get`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:50 msgid "" "Functions to configure Python's initialization, deprecated in Python 3.11:" msgstr "用於配置 Python 初始化的函式,自 Python 3.11 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgvEx()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." msgstr ":c:func:`!PySys_SetArgv()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 msgid "" ":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " "instead." msgstr "" ":c:func:`!Py_SetProgramName()`:請改用 :c:member:`PyConfig.program_name`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." msgstr ":c:func:`!Py_SetPythonHome()`:請改用 :c:member:`PyConfig.home`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:62 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 msgid "" -":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" +":c:func:`!PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" -":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" -"data:`!warnings.filters`。" +":c:func:`!PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` " +"和 :data:`!warnings.filters`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:65 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:63 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` instead." msgstr "" "應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:66 msgid "Global configuration variables:" msgstr "全域配置變數:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:70 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 msgid "" ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` or :c:func:" "`PyConfig_Get(\"parser_debug\") ` instead." @@ -5950,7 +6244,7 @@ msgstr "" ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug` 或 :c:func:" "`PyConfig_Get(\"parser_debug\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:73 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:71 msgid "" ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` or :c:func:" "`PyConfig_Get(\"verbose\") ` instead." @@ -5958,7 +6252,7 @@ msgstr "" ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose` 或 :c:func:" "`PyConfig_Get(\"verbose\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:76 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:74 msgid "" ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` or :c:func:" "`PyConfig_Get(\"quiet\") ` instead." @@ -5966,7 +6260,7 @@ msgstr "" ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet` 或 :c:func:" "`PyConfig_Get(\"quiet\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:79 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:77 msgid "" ":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` or :c:func:" "`PyConfig_Get(\"interactive\") ` instead." @@ -5974,7 +6268,7 @@ msgstr "" ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive` 或 :c:" "func:`PyConfig_Get(\"interactive\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:82 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:80 msgid "" ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` or :c:func:" "`PyConfig_Get(\"inspect\") ` instead." @@ -5982,7 +6276,7 @@ msgstr "" ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect` 或 :c:func:" "`PyConfig_Get(\"inspect\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:85 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:83 msgid "" ":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` or :c:" "func:`PyConfig_Get(\"optimization_level\") ` instead." @@ -5990,7 +6284,7 @@ msgstr "" ":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level` 或 :" "c:func:`PyConfig_Get(\"optimization_level\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:88 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:86 msgid "" ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` or :c:func:" "`PyConfig_Get(\"site_import\") ` instead." @@ -5998,7 +6292,7 @@ msgstr "" ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import` 或 :c:func:" "`PyConfig_Get(\"site_import\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:91 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:89 msgid "" ":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` or :c:" "func:`PyConfig_Get(\"bytes_warning\") ` instead." @@ -6006,7 +6300,7 @@ msgstr "" ":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning` 或 :" "c:func:`PyConfig_Get(\"bytes_warning\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:94 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:92 msgid "" ":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` or :c:" "func:`PyConfig_Get(\"pathconfig_warnings\") ` instead." @@ -6014,7 +6308,7 @@ msgstr "" ":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings` 或 :" "c:func:`PyConfig_Get(\"pathconfig_warnings\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:97 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:95 msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "or :c:func:`PyConfig_Get(\"use_environment\") ` instead." @@ -6023,7 +6317,7 @@ msgstr "" "use_environment` 或 :c:func:`PyConfig_Get(\"use_environment\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:100 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:98 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "or :c:func:`PyConfig_Get(\"write_bytecode\") ` instead." @@ -6032,7 +6326,7 @@ msgstr "" "write_bytecode` 或 :c:func:`PyConfig_Get(\"write_bytecode\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:103 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:101 msgid "" ":c:var:`Py_NoUserSiteDirectory`: Use :c:member:`PyConfig." "user_site_directory` or :c:func:`PyConfig_Get(\"user_site_directory\") " @@ -6042,7 +6336,7 @@ msgstr "" "user_site_directory` 或 :c:func:`PyConfig_Get(\"user_site_directory\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:106 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:104 msgid "" ":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` or :" "c:func:`PyConfig_Get(\"buffered_stdio\") ` instead." @@ -6050,7 +6344,7 @@ msgstr "" ":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio` " "或 :c:func:`PyConfig_Get(\"buffered_stdio\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:109 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:107 msgid "" ":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed` or :c:func:`PyConfig_Get(\"hash_seed\") " @@ -6060,7 +6354,7 @@ msgstr "" "和 :c:member:`PyConfig.hash_seed` 或 :c:func:`PyConfig_Get(\"hash_seed\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:113 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:111 msgid "" ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` or :c:func:" "`PyConfig_Get(\"isolated\") ` instead." @@ -6068,7 +6362,7 @@ msgstr "" ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated` 或 :c:func:" "`PyConfig_Get(\"isolated\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:116 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:114 msgid "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`: Use :c:member:`PyPreConfig." "legacy_windows_fs_encoding` or :c:func:" @@ -6078,7 +6372,7 @@ msgstr "" "legacy_windows_fs_encoding` 或 :c:func:" "`PyConfig_Get(\"legacy_windows_fs_encoding\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:119 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:117 msgid "" ":c:var:`Py_LegacyWindowsStdioFlag`: Use :c:member:`PyConfig." "legacy_windows_stdio` or :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " @@ -6088,7 +6382,7 @@ msgstr "" "legacy_windows_stdio` 或 :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:122 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:120 msgid "" ":c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!" "Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." @@ -6100,7 +6394,7 @@ msgstr "" "filesystem_encoding` 或 :c:func:`PyConfig_Get(\"filesystem_encoding\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:125 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:123 msgid "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." "filesystem_errors` or :c:func:`PyConfig_Get(\"filesystem_errors\") " @@ -6110,7 +6404,7 @@ msgstr "" "filesystem_errors` 或 :c:func:`PyConfig_Get(\"filesystem_errors\") " "`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:128 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:126 msgid "" ":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` or :c:func:" "`PyConfig_Get(\"utf8_mode\") ` instead. (see :c:func:" @@ -6120,7 +6414,7 @@ msgstr "" "`PyConfig_Get(\"utf8_mode\") `。(請參閱 :c:func:" "`Py_PreInitialize`)" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:133 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:131 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` to set these options. Or :c:func:`PyConfig_Get` can be used to " @@ -6387,11 +6681,11 @@ msgstr "" msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" -#: ../../whatsnew/3.14.rst:3128 +#: ../../whatsnew/3.14.rst:3129 msgid "Build changes" msgstr "建置變更" -#: ../../whatsnew/3.14.rst:3130 +#: ../../whatsnew/3.14.rst:3131 msgid "" ":pep:`776`: Emscripten is now an officially supported platform at :pep:`tier " "3 <11#tier-3>`. As a part of this effort, more than 25 bugs in `Emscripten " @@ -6401,31 +6695,31 @@ msgid "" "Chatham in :gh:`127146`, :gh:`127683`, and :gh:`136931`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3140 +#: ../../whatsnew/3.14.rst:3141 msgid "Official Android binary releases are now provided on python.org__." msgstr "" -#: ../../whatsnew/3.14.rst:3144 +#: ../../whatsnew/3.14.rst:3145 msgid "" "GNU Autoconf 2.72 is now required to generate :file:`configure`. " "(Contributed by Erlend Aasland in :gh:`115765`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3147 +#: ../../whatsnew/3.14.rst:3148 msgid "" "``wasm32-unknown-emscripten`` is now a :pep:`11` tier 3 platform. " "(Contributed by R. Hood Chatham in :gh:`127146`, :gh:`127683`, and :gh:" "`136931`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3150 +#: ../../whatsnew/3.14.rst:3151 msgid "" "``#pragma``-based linking with ``python3*.lib`` can now be switched off " "with :c:expr:`Py_NO_LINK_LIB`. (Contributed by Jean-Christophe Fillion-Robin " "in :gh:`82909`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3154 +#: ../../whatsnew/3.14.rst:3155 msgid "" "CPython now enables a set of recommended compiler options by default for " "improved security. Use the :option:`--disable-safety` :file:`configure` " @@ -6433,45 +6727,45 @@ msgid "" "larger set of compiler options, albeit with a performance cost." msgstr "" -#: ../../whatsnew/3.14.rst:3160 +#: ../../whatsnew/3.14.rst:3161 msgid "" "The ``WITH_FREELISTS`` macro and ``--without-freelists`` :file:`configure` " "option have been removed." msgstr "" -#: ../../whatsnew/3.14.rst:3163 +#: ../../whatsnew/3.14.rst:3164 msgid "" "The new :file:`configure` option :option:`--with-tail-call-interp` may be " "used to enable the experimental tail call interpreter. See :ref:`whatsnew314-" "tail-call-interpreter` for further details." msgstr "" -#: ../../whatsnew/3.14.rst:3167 +#: ../../whatsnew/3.14.rst:3168 msgid "" "To disable the new remote debugging support, use the :option:`--without-" "remote-debug` :file:`configure` option. This may be useful for security " "reasons." msgstr "" -#: ../../whatsnew/3.14.rst:3171 +#: ../../whatsnew/3.14.rst:3172 msgid "" "iOS and macOS apps can now be configured to redirect ``stdout`` and " "``stderr`` content to the system log. (Contributed by Russell Keith-Magee " "in :gh:`127592`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3175 +#: ../../whatsnew/3.14.rst:3176 msgid "" "The iOS testbed is now able to stream test output while the test is running. " "The testbed can also be used to run the test suite of projects other than " "CPython itself. (Contributed by Russell Keith-Magee in :gh:`127592`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3184 +#: ../../whatsnew/3.14.rst:3185 msgid ":file:`build-details.json`" msgstr ":file:`build-details.json`" -#: ../../whatsnew/3.14.rst:3186 +#: ../../whatsnew/3.14.rst:3187 msgid "" "Installations of Python now contain a new file, :file:`build-details.json`. " "This is a static JSON document containing build details for CPython, to " @@ -6479,7 +6773,7 @@ msgid "" "cases such as Python launchers, cross-compilation, and so on." msgstr "" -#: ../../whatsnew/3.14.rst:3192 +#: ../../whatsnew/3.14.rst:3193 msgid "" ":file:`build-details.json` must be installed in the platform-independent " "standard library directory. This corresponds to the :ref:`'stdlib' " @@ -6487,17 +6781,17 @@ msgid "" "by running ``sysconfig.get_path('stdlib')``." msgstr "" -#: ../../whatsnew/3.14.rst:3198 +#: ../../whatsnew/3.14.rst:3199 msgid "" ":pep:`739` -- ``build-details.json`` 1.0 -- a static description file for " "Python build details" msgstr "" -#: ../../whatsnew/3.14.rst:3205 +#: ../../whatsnew/3.14.rst:3206 msgid "Discontinuation of PGP signatures" msgstr "" -#: ../../whatsnew/3.14.rst:3207 +#: ../../whatsnew/3.14.rst:3208 msgid "" "PGP (Pretty Good Privacy) signatures will not be provided for releases of " "Python 3.14 or future versions. To verify CPython artifacts, users must use " @@ -6505,15 +6799,15 @@ msgid "" "sigstore/>`__. Releases have been signed using Sigstore_ since Python 3.11." msgstr "" -#: ../../whatsnew/3.14.rst:3213 +#: ../../whatsnew/3.14.rst:3214 msgid "This change in release process was specified in :pep:`761`." msgstr "" -#: ../../whatsnew/3.14.rst:3221 +#: ../../whatsnew/3.14.rst:3222 msgid "Free-threaded Python is officially supported" msgstr "" -#: ../../whatsnew/3.14.rst:3223 +#: ../../whatsnew/3.14.rst:3224 msgid "" "The free-threaded build of Python is now supported and no longer " "experimental. This is the start of `phase II `__, with free-threading as the default or sole build of Python is " @@ -6544,19 +6838,19 @@ msgid "" "and the community. This decision is for the future." msgstr "" -#: ../../whatsnew/3.14.rst:3243 +#: ../../whatsnew/3.14.rst:3244 msgid ":pep:`779`" msgstr ":pep:`779`" -#: ../../whatsnew/3.14.rst:3245 +#: ../../whatsnew/3.14.rst:3246 msgid "`PEP 779's acceptance `__" msgstr "`PEP 779 的接受 `__" -#: ../../whatsnew/3.14.rst:3251 +#: ../../whatsnew/3.14.rst:3252 msgid "Binary releases for the experimental just-in-time compiler" msgstr "" -#: ../../whatsnew/3.14.rst:3253 +#: ../../whatsnew/3.14.rst:3254 msgid "" "The official macOS and Windows release binaries now include an " "*experimental* just-in-time (JIT) compiler. Although it is **not** " @@ -6566,7 +6860,7 @@ msgid "" "off` configuration option for similar behavior." msgstr "" -#: ../../whatsnew/3.14.rst:3260 +#: ../../whatsnew/3.14.rst:3261 msgid "" "The JIT is at an early stage and still in active development. As such, the " "typical performance impact of enabling it can range from 10% slower to 20% " @@ -6578,7 +6872,7 @@ msgid "" "current process." msgstr "" -#: ../../whatsnew/3.14.rst:3268 +#: ../../whatsnew/3.14.rst:3269 msgid "" "Currently, the most significant missing functionality is that native " "debuggers and profilers like ``gdb`` and ``perf`` are unable to unwind " @@ -6587,76 +6881,76 @@ msgid "" "not support JIT compilation." msgstr "" -#: ../../whatsnew/3.14.rst:3273 +#: ../../whatsnew/3.14.rst:3274 msgid "" "Please report any bugs or major performance regressions that you encounter!" msgstr "" -#: ../../whatsnew/3.14.rst:3275 +#: ../../whatsnew/3.14.rst:3276 msgid ":pep:`744`" msgstr ":pep:`744`" -#: ../../whatsnew/3.14.rst:3279 +#: ../../whatsnew/3.14.rst:3280 msgid "Porting to Python 3.14" msgstr "移植至 Python 3.14" -#: ../../whatsnew/3.14.rst:3281 +#: ../../whatsnew/3.14.rst:3282 msgid "" "This section lists previously described changes and other bugfixes that may " "require changes to your code." msgstr "本節列出了前面描述的更改以及可能需要更改程式碼的其他錯誤修復。" -#: ../../whatsnew/3.14.rst:3286 +#: ../../whatsnew/3.14.rst:3287 msgid "Changes in the Python API" msgstr "Python API 的變更" -#: ../../whatsnew/3.14.rst:3288 +#: ../../whatsnew/3.14.rst:3289 msgid "" "On Unix platforms other than macOS, *forkserver* is now the default :ref:" "`start method ` for :mod:`multiprocessing` " "and :class:`~concurrent.futures.ProcessPoolExecutor`, instead of *fork*." msgstr "" -#: ../../whatsnew/3.14.rst:3292 +#: ../../whatsnew/3.14.rst:3293 msgid "" "See :ref:`(1) ` and :ref:`(2) " "` for details." msgstr "" -#: ../../whatsnew/3.14.rst:3295 +#: ../../whatsnew/3.14.rst:3296 msgid "" "If you encounter :exc:`NameError`\\s or pickling errors coming out of :mod:" "`multiprocessing` or :mod:`concurrent.futures`, see the :ref:`forkserver " "restrictions `." msgstr "" -#: ../../whatsnew/3.14.rst:3299 +#: ../../whatsnew/3.14.rst:3300 msgid "" "This change does not affect Windows or macOS, where :ref:`'spawn' " "` remains the default start method." msgstr "" -#: ../../whatsnew/3.14.rst:3302 +#: ../../whatsnew/3.14.rst:3303 msgid "" ":class:`functools.partial` is now a method descriptor. Wrap it in :func:" "`staticmethod` if you want to preserve the old behavior. (Contributed by " "Serhiy Storchaka and Dominykas Grigonis in :gh:`121027`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3306 +#: ../../whatsnew/3.14.rst:3307 msgid "" "The :ref:`garbage collector is now incremental `, which means that the behavior of :func:`gc.collect` changes slightly:" msgstr "" -#: ../../whatsnew/3.14.rst:3313 +#: ../../whatsnew/3.14.rst:3314 msgid "" "The :func:`locale.nl_langinfo` function now temporarily sets the " "``LC_CTYPE`` locale in some cases. This temporary change affects other " "threads. (Contributed by Serhiy Storchaka in :gh:`69998`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3318 +#: ../../whatsnew/3.14.rst:3319 msgid "" ":func:`pickle.dump` and :func:`pickle.dumps` now raise :exc:`~pickle." "PicklingError` for some failures that previously raised :exc:" @@ -6668,14 +6962,14 @@ msgid "" "PicklingError`. (Contributed by Serhiy Storchaka in :gh:`122311`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3328 +#: ../../whatsnew/3.14.rst:3329 msgid "" ":class:`types.UnionType` is now an alias for :class:`typing.Union`, causing " "changes in some behaviors. See :ref:`above ` for " "more details. (Contributed by Jelle Zijlstra in :gh:`105499`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3333 +#: ../../whatsnew/3.14.rst:3334 msgid "" "The runtime behavior of annotations has changed in various ways; see :ref:" "`above ` for details. While most code that " @@ -6683,29 +6977,29 @@ msgid "" "details may behave differently." msgstr "" -#: ../../whatsnew/3.14.rst:3338 +#: ../../whatsnew/3.14.rst:3339 msgid "" "As part of making the :mod:`mimetypes` CLI public, it now exits with ``1`` " "on failure instead of ``0`` and ``2`` on incorrect command-line parameters " "instead of ``1``. Error messages are now printed to stderr." msgstr "" -#: ../../whatsnew/3.14.rst:3343 +#: ../../whatsnew/3.14.rst:3344 msgid "" "The ``\\B`` pattern in regular expression now matches the empty string when " "given as the entire pattern, which may cause behavioural changes." msgstr "" -#: ../../whatsnew/3.14.rst:3346 +#: ../../whatsnew/3.14.rst:3347 msgid "" "On FreeBSD, :data:`sys.platform` no longer contains the major version number." msgstr "" -#: ../../whatsnew/3.14.rst:3352 +#: ../../whatsnew/3.14.rst:3353 msgid "Changes in annotations (:pep:`649` and :pep:`749`)" msgstr "" -#: ../../whatsnew/3.14.rst:3354 +#: ../../whatsnew/3.14.rst:3355 msgid "" "This section contains guidance on changes that may be needed to annotations " "or Python code that interacts with or introspects annotations, due to the " @@ -6713,24 +7007,24 @@ msgid "" "deferred-annotations>`." msgstr "" -#: ../../whatsnew/3.14.rst:3359 +#: ../../whatsnew/3.14.rst:3360 msgid "" "In the majority of cases, working code from older versions of Python will " "not require any changes." msgstr "" -#: ../../whatsnew/3.14.rst:3364 +#: ../../whatsnew/3.14.rst:3365 msgid "Implications for annotated code" msgstr "" -#: ../../whatsnew/3.14.rst:3366 +#: ../../whatsnew/3.14.rst:3367 msgid "" "If you define annotations in your code (for example, for use with a static " "type checker), then this change probably does not affect you: you can keep " "writing annotations the same way you did with previous versions of Python." msgstr "" -#: ../../whatsnew/3.14.rst:3370 +#: ../../whatsnew/3.14.rst:3371 msgid "" "You will likely be able to remove quoted strings in annotations, which are " "frequently used for forward references. Similarly, if you use ``from " @@ -6741,11 +7035,11 @@ msgid "" "annotations before they work as expected." msgstr "" -#: ../../whatsnew/3.14.rst:3380 +#: ../../whatsnew/3.14.rst:3381 msgid "Implications for readers of ``__annotations__``" msgstr "" -#: ../../whatsnew/3.14.rst:3382 +#: ../../whatsnew/3.14.rst:3383 msgid "" "If your code reads the :attr:`~object.__annotations__` attribute on objects, " "you may want to make changes in order to support code that relies on " @@ -6754,7 +7048,7 @@ msgid "" "FORWARDREF` format, as the :mod:`dataclasses` module now does." msgstr "" -#: ../../whatsnew/3.14.rst:3389 +#: ../../whatsnew/3.14.rst:3390 msgid "" "The external :pypi:`typing_extensions` package provides partial backports of " "some of the functionality of the :mod:`annotationlib` module, such as the :" @@ -6763,11 +7057,11 @@ msgid "" "that takes advantage of the new behavior in Python 3.14." msgstr "" -#: ../../whatsnew/3.14.rst:3398 +#: ../../whatsnew/3.14.rst:3399 msgid "Related changes" msgstr "" -#: ../../whatsnew/3.14.rst:3400 +#: ../../whatsnew/3.14.rst:3401 msgid "" "The changes in Python 3.14 are designed to rework how :attr:`!" "__annotations__` works at runtime while minimizing breakage to code that " @@ -6779,7 +7073,7 @@ msgid "" "the :mod:`annotationlib` module." msgstr "" -#: ../../whatsnew/3.14.rst:3409 +#: ../../whatsnew/3.14.rst:3410 msgid "" "In particular, do not read annotations directly from the namespace " "dictionary attribute of type objects. Use :func:`annotationlib." @@ -6787,25 +7081,25 @@ msgid "" "`annotationlib.get_annotations` afterwards." msgstr "" -#: ../../whatsnew/3.14.rst:3414 +#: ../../whatsnew/3.14.rst:3415 msgid "" "In previous releases, it was sometimes possible to access class annotations " "from an instance of an annotated class. This behavior was undocumented and " "accidental, and will no longer work in Python 3.14." msgstr "" -#: ../../whatsnew/3.14.rst:3420 +#: ../../whatsnew/3.14.rst:3421 msgid "``from __future__ import annotations``" msgstr "``from __future__ import annotations``" -#: ../../whatsnew/3.14.rst:3422 +#: ../../whatsnew/3.14.rst:3423 msgid "" "In Python 3.7, :pep:`563` introduced the ``from __future__ import " "annotations`` :ref:`future statement `, which turns all annotations " "into strings." msgstr "" -#: ../../whatsnew/3.14.rst:3425 +#: ../../whatsnew/3.14.rst:3426 msgid "" "However, this statement is now deprecated and it is expected to be removed " "in a future version of Python. This removal will not happen until after " @@ -6813,17 +7107,17 @@ msgid "" "Python without support for deferred evaluation of annotations." msgstr "" -#: ../../whatsnew/3.14.rst:3431 +#: ../../whatsnew/3.14.rst:3432 msgid "" "In Python 3.14, the behavior of code using ``from __future__ import " "annotations`` is unchanged." msgstr "" -#: ../../whatsnew/3.14.rst:3436 +#: ../../whatsnew/3.14.rst:3437 msgid "Changes in the C API" msgstr "C API 中的改動" -#: ../../whatsnew/3.14.rst:3438 +#: ../../whatsnew/3.14.rst:3439 msgid "" ":c:func:`Py_Finalize` now deletes all interned strings. This is backwards " "incompatible to any C extension that holds onto an interned string after a " @@ -6836,14 +7130,14 @@ msgid "" "`113601`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3448 +#: ../../whatsnew/3.14.rst:3449 msgid "" "The :ref:`Unicode Exception Objects ` C API now raises a :" "exc:`TypeError` if its exception argument is not a :exc:`UnicodeError` " "object. (Contributed by Bénédikt Tran in :gh:`127691`.)" msgstr "" -#: ../../whatsnew/3.14.rst:3455 +#: ../../whatsnew/3.14.rst:3456 msgid "" "The interpreter internally avoids some reference count modifications when " "loading objects onto the operands stack by :term:`borrowing , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.15\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-10-15 11:47+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" + +#: ../../whatsnew/3.15.rst:4 +msgid "What's new in Python 3.15" +msgstr "" + +#: ../../whatsnew/3.15.rst:0 +msgid "Editor" +msgstr "編輯者" + +#: ../../whatsnew/3.15.rst:6 +msgid "Hugo van Kemenade" +msgstr "" + +#: ../../whatsnew/3.15.rst:48 +msgid "" +"This article explains the new features in Python 3.15, compared to 3.14. " +"Python 3.15 was released on 9 October 2026. For full details, see the :ref:" +"`changelog `." +msgstr "" + +#: ../../whatsnew/3.15.rst:54 +msgid ":pep:`790` -- Python 3.15 release schedule" +msgstr "" + +#: ../../whatsnew/3.15.rst:58 +msgid "Summary -- Release highlights" +msgstr "發布重點摘要" + +#: ../../whatsnew/3.15.rst:63 +msgid "" +"Python 3.15 is the latest stable release of the Python programming language, " +"with a mix of changes to the language, the implementation, and the standard " +"library. The biggest changes include :ref:`lazy imports `, :ref:`frozendict ` and :ref:`sentinel " +"` builtins, :ref:`UTF-8 as the default encoding " +"`, :ref:`unpacking in comprehensions `, and a :ref:`stable ABI for free-threaded " +"builds `." +msgstr "" + +#: ../../whatsnew/3.15.rst:74 +msgid "" +"The library changes include a new :ref:`profiling package ` with :ref:`Tachyon `, a " +"high-frequency statistical sampling profiler, :ref:`more color ` in command-line output, as well as the usual deprecations and " +"removals, and improvements in user-friendliness and correctness." +msgstr "" + +#: ../../whatsnew/3.15.rst:82 +msgid "" +"This article doesn't attempt to provide a complete specification of all new " +"features, but instead gives a convenient overview. For full details refer to " +"the documentation, such as the :ref:`Library Reference ` and :" +"ref:`Language Reference `. To understand the complete " +"implementation and design rationale for a change, refer to the PEP for a " +"particular new feature; but note that PEPs usually are not kept up-to-date " +"once a feature has been fully implemented." +msgstr "" + +#: ../../whatsnew/3.15.rst:92 +msgid "" +"See `Porting to Python 3.15`_ for guidance on upgrading from earlier " +"versions of Python." +msgstr "" + +#: ../../whatsnew/3.15.rst:99 +msgid "Interpreter improvements:" +msgstr "" + +#: ../../whatsnew/3.15.rst:101 +msgid ":pep:`661`: :ref:`Add sentinel built-in type `" +msgstr ":pep:`661`: :ref:`Add sentinel built-in type `" + +#: ../../whatsnew/3.15.rst:103 +msgid "" +":pep:`686`: :ref:`Python now uses UTF-8 as the default encoding `" +msgstr "" +":pep:`686`: :ref:`Python now uses UTF-8 as the default encoding `" + +#: ../../whatsnew/3.15.rst:105 +msgid "" +":pep:`798`: :ref:`Unpacking in comprehensions `" +msgstr "" +":pep:`798`: :ref:`Unpacking in comprehensions `" + +#: ../../whatsnew/3.15.rst:107 +msgid "" +":pep:`810`: :ref:`Explicit lazy imports for faster startup times " +"`" +msgstr "" +":pep:`810`: :ref:`Explicit lazy imports for faster startup times " +"`" + +#: ../../whatsnew/3.15.rst:109 +msgid "" +":pep:`814`: :ref:`Add frozendict built-in type `" +msgstr "" +":pep:`814`: :ref:`Add frozendict built-in type `" + +#: ../../whatsnew/3.15.rst:111 +msgid "" +":pep:`829`: :ref:`Package startup configuration files `" +msgstr "" +":pep:`829`: :ref:`Package startup configuration files `" + +#: ../../whatsnew/3.15.rst:112 +msgid "" +":ref:`The experimental JIT compiler has been significantly upgraded " +"`" +msgstr "" +":ref:`The experimental JIT compiler has been significantly upgraded " +"`" + +#: ../../whatsnew/3.15.rst:113 +msgid ":ref:`Improved error messages `" +msgstr ":ref:`Improved error messages `" + +#: ../../whatsnew/3.15.rst:115 +msgid "Significant improvements in the standard library:" +msgstr "" + +#: ../../whatsnew/3.15.rst:117 +msgid "" +":pep:`799`: :ref:`A dedicated profiling package for organizing Python " +"profiling tools `" +msgstr "" +":pep:`799`: :ref:`A dedicated profiling package for organizing Python " +"profiling tools `" + +#: ../../whatsnew/3.15.rst:119 +msgid "" +":pep:`799`: :ref:`Tachyon: High-frequency statistical sampling profiler " +"`" +msgstr "" +":pep:`799`: :ref:`Tachyon: High-frequency statistical sampling profiler " +"`" + +#: ../../whatsnew/3.15.rst:121 +msgid ":ref:`More color `" +msgstr ":ref:`More color `" + +#: ../../whatsnew/3.15.rst:123 +msgid "New typing features:" +msgstr "" + +#: ../../whatsnew/3.15.rst:125 +msgid "" +":pep:`728`: :ref:`TypedDict with typed extra items `" +msgstr "" +":pep:`728`: :ref:`TypedDict with typed extra items `" + +#: ../../whatsnew/3.15.rst:126 +msgid "" +":pep:`747`: :ref:`Annotating type forms with TypeForm `" +msgstr "" +":pep:`747`: :ref:`Annotating type forms with TypeForm `" + +#: ../../whatsnew/3.15.rst:128 +msgid "" +":pep:`800`: :ref:`Disjoint bases in the type system `" +msgstr "" +":pep:`800`: :ref:`Disjoint bases in the type system `" + +#: ../../whatsnew/3.15.rst:130 +msgid "C API improvements:" +msgstr "C API 改進:" + +#: ../../whatsnew/3.15.rst:132 +msgid "" +":pep:`782`: :ref:`A new PyBytesWriter C API to create a Python bytes object " +"`" +msgstr "" +":pep:`782`: :ref:`A new PyBytesWriter C API to create a Python bytes object " +"`" + +#: ../../whatsnew/3.15.rst:134 +msgid "" +":pep:`788`: :ref:`Protection against finalization in the C API `" +msgstr "" +":pep:`788`: :ref:`Protection against finalization in the C API `" + +#: ../../whatsnew/3.15.rst:135 +msgid "" +":pep:`803`, :pep:`820 <820>`, :pep:`793 <793>`: :ref:`Stable ABI for free-" +"threaded builds ` and related C API" +msgstr "" + +#: ../../whatsnew/3.15.rst:139 +msgid "Build changes:" +msgstr "" + +#: ../../whatsnew/3.15.rst:141 +msgid "" +":pep:`831`: :ref:`Frame pointers are enabled by default for improved system-" +"level observability `" +msgstr "" +":pep:`831`: :ref:`Frame pointers are enabled by default for improved system-" +"level observability `" + +#: ../../whatsnew/3.15.rst:144 +msgid "Release changes:" +msgstr "" + +#: ../../whatsnew/3.15.rst:146 +msgid "" +":ref:`The official Windows 64-bit binaries now use the tail-calling " +"interpreter `" +msgstr "" +":ref:`The official Windows 64-bit binaries now use the tail-calling " +"interpreter `" + +#: ../../whatsnew/3.15.rst:148 +msgid "" +"The official macOS binaries now install free-threading support by default" +msgstr "" + +#: ../../whatsnew/3.15.rst:152 ../../whatsnew/3.15.rst:2495 +msgid "New features" +msgstr "新增功能" + +#: ../../whatsnew/3.15.rst:157 +msgid ":pep:`810`: Explicit lazy imports" +msgstr "" + +#: ../../whatsnew/3.15.rst:159 +msgid "" +"Large Python applications often suffer from slow startup times. A " +"significant contributor to this problem is the import system: when a module " +"is imported, Python must locate the file, read it from disk, compile it to " +"bytecode, and execute all top-level code. For applications with deep " +"dependency trees, this process can take seconds, even when most of the " +"imported code is never actually used during a particular run." +msgstr "" + +#: ../../whatsnew/3.15.rst:166 +msgid "" +"Developers have worked around this by moving imports inside functions, " +"using :mod:`importlib` to load modules on demand, or restructuring code to " +"avoid unnecessary dependencies. These approaches work but make code harder " +"to read and maintain, scatter import statements throughout the codebase, and " +"require discipline to apply consistently." +msgstr "" + +#: ../../whatsnew/3.15.rst:172 +msgid "" +"Python now provides a cleaner solution through explicit :keyword:`lazy` " +"imports using the new ``lazy`` soft keyword. When you mark an import as " +"lazy, Python defers the actual module loading until the imported name is " +"first used. This gives you the organizational benefits of declaring all " +"imports at the top of the file while only paying the loading cost for " +"modules you actually use." +msgstr "" + +#: ../../whatsnew/3.15.rst:179 +msgid "" +"The ``lazy`` keyword works with both ``import`` and ``from ... import`` " +"statements. When you write ``lazy import heavy_module``, Python does not " +"immediately load the module. Instead, it creates a lightweight proxy object. " +"The actual module loading happens transparently when you first access the " +"name:" +msgstr "" + +#: ../../whatsnew/3.15.rst:185 +msgid "" +"lazy import json\n" +"lazy from pathlib import Path\n" +"\n" +"print(\"Starting up...\") # json and pathlib are not fully imported yet\n" +"\n" +"data = json.loads('{\"key\": \"value\"}') # json gets fully imported here\n" +"p = Path(\".\") # pathlib gets fully imported here" +msgstr "" +"lazy import json\n" +"lazy from pathlib import Path\n" +"\n" +"print(\"Starting up...\") # json 和 pathlib 尚未完全被引入\n" +"\n" +"data = json.loads('{\"key\": \"value\"}') # json 在此處完全被引入\n" +"p = Path(\".\") # pathlib 在此處完全被引入" + +#: ../../whatsnew/3.15.rst:195 +msgid "" +"This mechanism is particularly useful for applications that import many " +"modules at the top level but may only use a subset of them in any given run. " +"The deferred loading reduces startup latency without requiring code " +"restructuring or conditional imports scattered throughout the codebase." +msgstr "" + +#: ../../whatsnew/3.15.rst:200 +msgid "" +"In the case where loading a lazily imported module fails (for example, if " +"the module does not exist), Python raises the exception at the point of " +"first use rather than at import time. The associated traceback includes both " +"the location where the name was accessed and the original import statement, " +"making it straightforward to diagnose and debug the failure." +msgstr "" + +#: ../../whatsnew/3.15.rst:206 +msgid "" +"For cases where you want to enable lazy loading globally without modifying " +"source code, Python provides the :option:`-X lazy_imports <-X>` command-line " +"option and the :envvar:`PYTHON_LAZY_IMPORTS` environment variable. Both " +"accept two values: ``all`` makes all imports lazy by default, and ``normal`` " +"(the default) respects the ``lazy`` keyword in source code. The :func:`sys." +"set_lazy_imports` and :func:`sys.get_lazy_imports` functions allow changing " +"and querying this mode at runtime." +msgstr "" + +#: ../../whatsnew/3.15.rst:214 +msgid "" +"For more selective control, :func:`sys.set_lazy_imports_filter` accepts a " +"callable that determines whether a specific module should be loaded lazily. " +"The filter receives three arguments: the importing module's name (or " +"``None``), the imported module's name, and the fromlist (or ``None`` for " +"regular imports). It should return ``True`` to allow the import to be lazy, " +"or ``False`` to force eager loading. This allows patterns like making only " +"your own application's modules lazy while keeping third-party dependencies " +"eager:" +msgstr "" + +#: ../../whatsnew/3.15.rst:223 +msgid "" +"import sys\n" +"\n" +"def myapp_filter(importing, imported, fromlist):\n" +" return imported.startswith(\"myapp.\")\n" +"sys.set_lazy_imports_filter(myapp_filter)\n" +"sys.set_lazy_imports(\"all\")\n" +"\n" +"import myapp.slow_module # lazy (matches filter)\n" +"import json # eager (does not match filter)" +msgstr "" +"import sys\n" +"\n" +"def myapp_filter(importing, imported, fromlist):\n" +" return imported.startswith(\"myapp.\")\n" +"sys.set_lazy_imports_filter(myapp_filter)\n" +"sys.set_lazy_imports(\"all\")\n" +"\n" +"import myapp.slow_module # 延遲引入(符合過濾器)\n" +"import json # 立即引入(不符合過濾器)" + +#: ../../whatsnew/3.15.rst:235 +msgid "" +"The proxy type itself is available as :class:`types.LazyImportType` for code " +"that needs to detect lazy imports programmatically." +msgstr "" + +#: ../../whatsnew/3.15.rst:238 +msgid "" +"There are some restrictions on where the ``lazy`` keyword can be used. Lazy " +"imports are only permitted at module scope; using ``lazy`` inside a " +"function, class body, or ``try``/``except``/``finally`` block raises a :exc:" +"`SyntaxError`. Neither star imports nor future imports can be lazy (``lazy " +"from module import *`` and ``lazy from __future__ import ...`` both raise :" +"exc:`SyntaxError`)." +msgstr "" + +#: ../../whatsnew/3.15.rst:245 +msgid "" +"For code that cannot use the ``lazy`` keyword directly (for example, when " +"supporting Python versions older than 3.15 while still using lazy imports on " +"3.15+), a module can define :attr:`~module.__lazy_modules__` as a container " +"of fully qualified module name strings. Regular ``import`` statements for " +"those modules are then treated as lazy, with the same semantics as the " +"``lazy`` keyword::" +msgstr "" + +#: ../../whatsnew/3.15.rst:252 +msgid "" +"__lazy_modules__ = [\"json\", \"pathlib\"]\n" +"\n" +"import json # lazy\n" +"import os # still eager" +msgstr "" +"__lazy_modules__ = [\"json\", \"pathlib\"]\n" +"\n" +"import json # 延遲引入\n" +"import os # 仍為立即引入" + +#: ../../whatsnew/3.15.rst:257 +msgid "" +"(Contributed by Pablo Galindo Salgado and Dino Viehland in :gh:`142349`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:259 +msgid ":pep:`810` for the full specification and rationale." +msgstr "" + +#: ../../whatsnew/3.15.rst:265 +msgid ":pep:`814`: Add frozendict built-in type" +msgstr "" + +#: ../../whatsnew/3.15.rst:267 +msgid "" +"A new :term:`immutable` type, :class:`frozendict`, is added to the :mod:" +"`builtins` module. It does not allow modification after creation. A :class:`!" +"frozendict` is not a subclass of ``dict``; it inherits directly from " +"``object``. A :class:`!frozendict` is :term:`hashable` as long as all of its " +"keys and values are hashable. A :class:`!frozendict` preserves insertion " +"order, but comparison does not take order into account." +msgstr "" + +#: ../../whatsnew/3.15.rst:273 +msgid "For example::" +msgstr "" + +#: ../../whatsnew/3.15.rst:275 +msgid "" +">>> a = frozendict(x=1, y=2)\n" +">>> a\n" +"frozendict({'x': 1, 'y': 2})\n" +">>> a['z'] = 3\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" a['z'] = 3\n" +" ~^^^^^\n" +"TypeError: 'frozendict' object does not support item assignment\n" +">>> b = frozendict(y=2, x=1)\n" +">>> hash(a) == hash(b)\n" +"True\n" +">>> a == b\n" +"True" +msgstr "" +">>> a = frozendict(x=1, y=2)\n" +">>> a\n" +"frozendict({'x': 1, 'y': 2})\n" +">>> a['z'] = 3\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" a['z'] = 3\n" +" ~^^^^^\n" +"TypeError: 'frozendict' object does not support item assignment\n" +">>> b = frozendict(y=2, x=1)\n" +">>> hash(a) == hash(b)\n" +"True\n" +">>> a == b\n" +"True" + +#: ../../whatsnew/3.15.rst:290 +msgid "" +"The following standard library modules have been updated to accept :class:`!" +"frozendict`: :mod:`copy`, :mod:`decimal`, :mod:`json`, :mod:`marshal`, :mod:" +"`plistlib` (only for serialization), :mod:`pickle`, :mod:`pprint` and :mod:" +"`xml.etree.ElementTree`." +msgstr "" + +#: ../../whatsnew/3.15.rst:295 +msgid "" +":func:`eval` and :func:`exec` accept :class:`!frozendict` for *globals*, " +"and :func:`type` and :meth:`str.maketrans` accept :class:`!frozendict` for " +"*dict*." +msgstr "" + +#: ../../whatsnew/3.15.rst:298 +msgid "" +"Code checking for :class:`dict` type using ``isinstance(arg, dict)`` can be " +"updated to ``isinstance(arg, (dict, frozendict))`` to accept also the :class:" +"`!frozendict` type, or to ``isinstance(arg, collections.abc.Mapping)`` to " +"accept also other mapping types such as :class:`~types.MappingProxyType`." +msgstr "" + +#: ../../whatsnew/3.15.rst:303 +msgid "(Contributed by Victor Stinner and Donghee Na in :gh:`141510`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:305 +msgid ":pep:`814` for the full specification and rationale." +msgstr "" + +#: ../../whatsnew/3.15.rst:311 +msgid ":pep:`661`: Add sentinel built-in type" +msgstr "" + +#: ../../whatsnew/3.15.rst:313 +msgid "" +"A new :class:`sentinel` type is added to the :mod:`builtins` module for " +"creating unique sentinel values with a concise representation. Sentinel " +"objects preserve identity when copied, support use in type expressions with " +"the ``|`` operator, and can be pickled when they are importable by module " +"and name." +msgstr "" + +#: ../../whatsnew/3.15.rst:319 +msgid "" +"(Contributed by Jelle Zijlstra in :gh:`148829`; PEP 661 written by Tal " +"Einat.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:321 +msgid ":pep:`661` for further details." +msgstr "" + +#: ../../whatsnew/3.15.rst:327 +msgid ":pep:`799`: A dedicated profiling package" +msgstr "" + +#: ../../whatsnew/3.15.rst:329 +msgid "" +"A new :mod:`profiling` module has been added to organize Python's built-in " +"profiling tools under a single, coherent namespace. This module contains:" +msgstr "" + +#: ../../whatsnew/3.15.rst:332 +msgid "" +":mod:`profiling.tracing`: deterministic function-call tracing (relocated " +"from ``cProfile``)." +msgstr "" + +#: ../../whatsnew/3.15.rst:334 +msgid "" +":mod:`profiling.sampling`: a new statistical sampling profiler (named " +"Tachyon)." +msgstr "" + +#: ../../whatsnew/3.15.rst:336 +msgid "" +"The ``cProfile`` module remains as an alias for backwards compatibility. " +"The :mod:`profile` module is deprecated and will be removed in Python 3.17." +msgstr "" + +#: ../../whatsnew/3.15.rst:339 +msgid "(Contributed by Pablo Galindo and László Kiss Kollár in :gh:`138122`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:341 +msgid ":pep:`799` for further details." +msgstr "" + +#: ../../whatsnew/3.15.rst:347 +msgid "Tachyon: High-frequency statistical sampling profiler" +msgstr "" + +#: ../../whatsnew/3.15.rst:349 +msgid "Tachyon profiler logo" +msgstr "" + +#: ../../whatsnew/3.15.rst:355 +msgid "" +"A new statistical sampling profiler (Tachyon) has been added as :mod:" +"`profiling.sampling`. This profiler enables low-overhead performance " +"analysis of running Python processes without requiring code modification or " +"process restart." +msgstr "" + +#: ../../whatsnew/3.15.rst:359 +msgid "" +"Unlike deterministic profilers (such as :mod:`profiling.tracing`) that " +"instrument every function call, the sampling profiler periodically captures " +"stack traces from running processes. This approach provides virtually zero " +"overhead while achieving sampling rates of **up to 1,000,000 Hz**, making it " +"the fastest sampling profiler available for Python (at the time of its " +"contribution) and ideal for debugging performance issues in production " +"environments. This capability is particularly valuable for debugging " +"performance issues in production systems where traditional profiling " +"approaches would be too intrusive." +msgstr "" + +#: ../../whatsnew/3.15.rst:368 +msgid "Key features include:" +msgstr "" + +#: ../../whatsnew/3.15.rst:370 +msgid "" +"**Zero-overhead profiling**: Attach to any running Python process without " +"affecting its performance. Ideal for production debugging where you can't " +"afford to restart or slow down your application." +msgstr "" + +#: ../../whatsnew/3.15.rst:374 +msgid "" +"**No code modification required**: Profile existing applications without " +"restart. Simply point the profiler at a running process by PID and start " +"collecting data." +msgstr "" + +#: ../../whatsnew/3.15.rst:377 +msgid "**Flexible target modes**:" +msgstr "" + +#: ../../whatsnew/3.15.rst:379 +msgid "" +"Profile running processes by PID (``attach``) - attach to already-running " +"applications" +msgstr "" + +#: ../../whatsnew/3.15.rst:380 +msgid "" +"Run and profile scripts directly (``run``) - profile from the very start of " +"execution" +msgstr "" + +#: ../../whatsnew/3.15.rst:381 +msgid "" +"Execute and profile modules (``run -m``) - profile packages run as ``python -" +"m module``" +msgstr "" + +#: ../../whatsnew/3.15.rst:382 +msgid "" +"Capture a one-shot snapshot of a running process (``dump``) - print a " +"traceback-style stack of every thread (or all asyncio tasks with ``--async-" +"aware``). Useful for investigating hung processes." +msgstr "" + +#: ../../whatsnew/3.15.rst:386 +msgid "" +"**Multiple profiling modes**: Choose what to measure based on your " +"performance investigation:" +msgstr "" + +#: ../../whatsnew/3.15.rst:388 +msgid "" +"**Wall-clock time** (``--mode wall``, default): Measures real elapsed time " +"including I/O, network waits, and blocking operations. Use this to " +"understand where your program spends calendar time, including when waiting " +"for external resources." +msgstr "" + +#: ../../whatsnew/3.15.rst:391 +msgid "" +"**CPU time** (``--mode cpu``): Measures only active CPU execution time, " +"excluding I/O waits and blocking. Use this to identify CPU-bound bottlenecks " +"and optimize computational work." +msgstr "" + +#: ../../whatsnew/3.15.rst:393 +msgid "" +"**GIL-holding time** (``--mode gil``): Measures time spent holding Python's " +"Global Interpreter Lock. Use this to identify which threads dominate GIL " +"usage in multi-threaded applications." +msgstr "" + +#: ../../whatsnew/3.15.rst:395 +msgid "" +"**Exception handling time** (``--mode exception``): Captures samples only " +"from threads with an active exception. Use this to analyze exception " +"handling overhead." +msgstr "" + +#: ../../whatsnew/3.15.rst:398 +msgid "" +"**Thread-aware profiling**: Option to profile all threads (``-a``) or just " +"the main thread, essential for understanding multi-threaded application " +"behavior." +msgstr "" + +#: ../../whatsnew/3.15.rst:401 +msgid "" +"**Multiple output formats**: Choose the visualization that best fits your " +"workflow:" +msgstr "" + +#: ../../whatsnew/3.15.rst:403 +msgid "" +"``--pstats``: Detailed tabular statistics compatible with :mod:`pstats`. " +"Shows function-level timing with direct and cumulative samples. Best for " +"detailed analysis and integration with existing Python profiling tools." +msgstr "" + +#: ../../whatsnew/3.15.rst:406 +msgid "" +"``--collapsed``: Generates collapsed stack traces (one line per stack). This " +"format is specifically designed for creating flame graphs with external " +"tools like Brendan Gregg's FlameGraph scripts or speedscope." +msgstr "" + +#: ../../whatsnew/3.15.rst:409 +msgid "" +"``--flamegraph``: Generates a self-contained interactive HTML flame graph " +"using D3.js. Opens directly in your browser for immediate visual analysis. " +"Flame graphs show the call hierarchy where width represents time spent, " +"making it easy to spot bottlenecks at a glance." +msgstr "" + +#: ../../whatsnew/3.15.rst:412 +msgid "" +"``--gecko``: Generates Gecko Profiler format compatible with `Firefox " +"Profiler `__. Upload the output to Firefox " +"Profiler for advanced timeline-based analysis with features like stack " +"charts, markers, and network activity." +msgstr "" + +#: ../../whatsnew/3.15.rst:415 +msgid "" +"``--heatmap``: Generates an interactive HTML heatmap visualization with line-" +"level sample counts. Creates a directory with per-file heatmaps showing " +"exactly where time is spent at the source code level." +msgstr "" + +#: ../../whatsnew/3.15.rst:419 +msgid "" +"**Live interactive mode**: Real-time TUI profiler with a top-like interface " +"(``--live``). Monitor performance as your application runs with interactive " +"sorting and filtering." +msgstr "" + +#: ../../whatsnew/3.15.rst:422 +msgid "" +"**Async-aware profiling**: Profile async/await code with task-based stack " +"reconstruction (``--async-aware``). See which coroutines are consuming time, " +"with options to show only running tasks or all tasks including those waiting." +msgstr "" + +#: ../../whatsnew/3.15.rst:426 +msgid "" +"**Opcode-level profiling**: Gather bytecode opcode information for " +"instruction-level profiling (``--opcodes``). Shows which bytecode " +"instructions are executing, including specializations from the adaptive " +"interpreter." +msgstr "" + +#: ../../whatsnew/3.15.rst:430 +msgid "" +"See :mod:`profiling.sampling` for the complete documentation, including all " +"available output formats, profiling modes, and configuration options." +msgstr "" + +#: ../../whatsnew/3.15.rst:433 +msgid "" +"(Contributed by Pablo Galindo and László Kiss Kollár in :gh:`135953` and :gh:" +"`138122`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:439 +msgid ":pep:`831`: Frame pointers enabled by default" +msgstr "" + +#: ../../whatsnew/3.15.rst:441 +msgid "" +"CPython is now built with frame pointers by default on platforms that " +"support them. This uses the compiler flags ``-fno-omit-frame-pointer`` and " +"``-mno-omit-leaf-frame-pointer``, making native stack unwinding faster and " +"more reliable for system profilers, debuggers, crash analysis tools, and " +"eBPF-based observability tools." +msgstr "" + +#: ../../whatsnew/3.15.rst:447 +msgid "" +"The flags are exposed through :mod:`sysconfig`, so extension modules built " +"by tools that consume Python's build configuration inherit frame pointers by " +"default. This propagation is intentional: mixed Python/native profiling " +"needs an unbroken frame-pointer chain through the interpreter, extension " +"modules, embedding applications, and native libraries." +msgstr "" + +#: ../../whatsnew/3.15.rst:455 +msgid "" +"Third-party build backends and native build systems should preserve these " +"flags when they consume Python's :mod:`sysconfig` values. Build systems " +"that compile C, C++, Rust, or other native code without inheriting Python's " +"compiler flags should enable equivalent frame-pointer flags themselves. A " +"single native component built without frame pointers can break stack " +"unwinding for the whole Python process." +msgstr "" + +#: ../../whatsnew/3.15.rst:462 +msgid "" +"(Contributed by Pablo Galindo Salgado and Savannah Ostrowski in :gh:" +"`149201`; PEP 831 written by Pablo Galindo Salgado, Ken Jin, Savannah " +"Ostrowski, and Diego Russo.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:466 +msgid ":pep:`831` for further details." +msgstr "" + +#: ../../whatsnew/3.15.rst:472 +msgid ":pep:`798`: Unpacking in comprehensions" +msgstr "" + +#: ../../whatsnew/3.15.rst:474 +msgid "" +"List, set, and dictionary comprehensions, as well as generator expressions, " +"now support unpacking with ``*`` and ``**``. This extends the unpacking " +"syntax from :pep:`448` to comprehensions, providing a new syntax for " +"combining an arbitrary number of iterables or dictionaries into a single " +"flat structure. This new syntax is a direct alternative to nested " +"comprehensions, :func:`itertools.chain`, and :meth:`itertools.chain." +"from_iterable`. For example::" +msgstr "" + +#: ../../whatsnew/3.15.rst:482 +msgid "" +">>> lists = [[1, 2], [3, 4], [5]]\n" +">>> [*L for L in lists] # equivalent to [x for L in lists for x in L]\n" +"[1, 2, 3, 4, 5]\n" +"\n" +">>> sets = [{1, 2}, {2, 3}, {3, 4}]\n" +">>> {*s for s in sets} # equivalent to {x for s in sets for x in s}\n" +"{1, 2, 3, 4}\n" +"\n" +">>> dicts = [{'a': 1}, {'b': 2}, {'a': 3}]\n" +">>> {**d for d in dicts} # equivalent to {k: v for d in dicts for k,v in d." +"items()}\n" +"{'a': 3, 'b': 2}" +msgstr "" +">>> lists = [[1, 2], [3, 4], [5]]\n" +">>> [*L for L in lists] # 等同於 [x for L in lists for x in L]\n" +"[1, 2, 3, 4, 5]\n" +"\n" +">>> sets = [{1, 2}, {2, 3}, {3, 4}]\n" +">>> {*s for s in sets} # 等同於 {x for s in sets for x in s}\n" +"{1, 2, 3, 4}\n" +"\n" +">>> dicts = [{'a': 1}, {'b': 2}, {'a': 3}]\n" +">>> {**d for d in dicts} # 等同於 {k: v for d in dicts for k,v in " +"d.items()}\n" +"{'a': 3, 'b': 2}" + +#: ../../whatsnew/3.15.rst:494 +msgid "" +"Generator expressions can similarly use unpacking to yield values from " +"multiple iterables::" +msgstr "" + +#: ../../whatsnew/3.15.rst:497 +msgid "" +">>> gen = (*L for L in lists) # equivalent to (x for L in lists for x in " +"L)\n" +">>> list(gen)\n" +"[1, 2, 3, 4, 5]" +msgstr "" +">>> gen = (*L for L in lists) # 等同於 (x for L in lists for x in L)\n" +">>> list(gen)\n" +"[1, 2, 3, 4, 5]" + +#: ../../whatsnew/3.15.rst:501 +msgid "" +"This change also extends to asynchronous generator expressions, such that, " +"for example, ``(*a async for a in agen())`` is equivalent to ``(x async for " +"a in agen() for x in a)``." +msgstr "" + +#: ../../whatsnew/3.15.rst:505 +msgid "(Contributed by Adam Hartz in :gh:`143055`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:507 +msgid ":pep:`798` for further details." +msgstr "" + +#: ../../whatsnew/3.15.rst:513 +msgid ":pep:`829`: Package startup configuration files" +msgstr "" + +#: ../../whatsnew/3.15.rst:515 +msgid "" +"Loaded by the :mod:`site` module when ``-S`` is not given, :ref:`.pth files " +"` can contain lines that both extend :data:`sys.path` and " +"execute arbitrary code when the line starts with ``import`` (followed by a " +"space or tab). The latter functionality can be problematic, since it is " +"difficult to know exactly what gets executed when Python starts up." +msgstr "" + +#: ../../whatsnew/3.15.rst:521 +msgid "" +"As a step towards improving the ability to audit pre-start executable code, " +"Python 3.15 introduces :ref:`.start files ` which contain " +"entry point specifications of the form ``pkg.mod:callable`` where ``pkg." +"mod`` is the import path to the given callable. When Python starts up, the " +"callable is located and called with no arguments." +msgstr "" + +#: ../../whatsnew/3.15.rst:527 +msgid "" +"``import`` lines in :file:`.pth` files are silently deprecated. When a " +"matching :file:`.start` file is found, ``import`` lines in :file:`.pth` " +"files are ignored. There is no change to :data:`sys.path` extension lines " +"in :file:`.pth` files." +msgstr "" + +#: ../../whatsnew/3.15.rst:532 +msgid "" +"The :mod:`site` module also provides :class:`site.StartupState` to batch " +"startup processing for multiple site directories, ensuring all static path " +"extensions are applied before any startup code is executed. :func:`site." +"main` uses an instance of this class implicitly to batch process all startup " +"configuration files during normal interpreter startup. Callers needing the " +"same batching behavior can build a :class:`~site.StartupState` directly and " +"drive it with :meth:`~site.StartupState.addsitedir`, :meth:`~site." +"StartupState.addusersitepackages`, and :meth:`~site.StartupState." +"addsitepackages`, then call :meth:`~site.StartupState.process` once at the " +"end of the batch." +msgstr "" + +#: ../../whatsnew/3.15.rst:543 +msgid "(Contributed by Barry Warsaw in :gh:`148641` and :gh:`150228`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:549 +msgid ":pep:`803`: Stable ABI for free-threaded builds" +msgstr "" + +#: ../../whatsnew/3.15.rst:551 +msgid "" +"C extensions that target the :ref:`Stable ABI ` can now be " +"compiled for the new *Stable ABI for Free-Threaded Builds* (also known as " +"``abi3t``), which makes them compatible with :term:`free-threaded builds " +"` of CPython. This usually requires some non-trivial " +"changes to the source code; specifically:" +msgstr "" + +#: ../../whatsnew/3.15.rst:558 +msgid "" +"Switching to API introduced in :pep:`697` (Python 3.12), such as negative :c:" +"member:`~PyType_Spec.basicsize` and :c:func:`PyObject_GetTypeData`, rather " +"than making :c:type:`PyObject` part of the instance struct; and" +msgstr "" + +#: ../../whatsnew/3.15.rst:562 +msgid "" +"Switching from a ``PyInit_`` function to a new export hook, :c:func:" +"`PyModExport_* `, introduced for this purpose in :" +"pep:`793`, with a new :c:type:`PySlot` structure introduced in :pep:`820`." +msgstr "" + +#: ../../whatsnew/3.15.rst:567 +msgid "" +"Note that Stable ABI does not offer all the functionality that CPython has " +"to offer. Extensions that cannot switch to ``abi3t`` should continue to " +"build for the existing Stable ABI (``abi3``) and the version-specific ABI " +"for free-threading (``cp315t``) separately." +msgstr "" + +#: ../../whatsnew/3.15.rst:573 +msgid "" +"Stable ABI for Free-Threaded Builds should typically be selected in a build " +"tool. Tools with ``abi3t`` support include meson-python, scikit-build-core, " +"and Maturin; see :ref:`abi3t-migration-build` for links to their " +"documentation on ``abi3t`` builds. If your build tool does not support " +"``abi3t``, compile for ``cp315t`` separately. If not using a build tool -- " +"or when writing such a tool -- you can select ``abi3t`` by setting the " +"macro :c:macro:`!Py_TARGET_ABI3T` as discussed in :ref:`abi3-compiling`." +msgstr "" + +#: ../../whatsnew/3.15.rst:582 +msgid "" +"A practical :ref:`migration guide ` for switching to " +"``abi3t`` is available. The community-maintained `Python Free-Threading " +"Guide `__ provides examples of " +"building and testing ``abi3t`` wheels." +msgstr "" + +#: ../../whatsnew/3.15.rst:588 +msgid ":pep:`803` for further details." +msgstr "" + +#: ../../whatsnew/3.15.rst:594 +msgid ":pep:`788`: Protecting the C API from interpreter finalization" +msgstr "" + +#: ../../whatsnew/3.15.rst:596 +msgid "" +"In the C API, :term:`interpreter finalization ` can be " +"problematic for many extensions, because :term:`attaching ` a thread state will permanently hang the thread, resulting in " +"deadlocks and other spurious issues. Additionally, it has historically been " +"impossible to safely check whether an interpreter is alive before using it, " +"leading to crashes when a thread concurrently deletes an interpreter while " +"another thread is trying to attach to it." +msgstr "" + +#: ../../whatsnew/3.15.rst:604 +msgid "There are now several new suites of APIs to circumvent these problems:" +msgstr "" + +#: ../../whatsnew/3.15.rst:606 +msgid "" +":ref:`Interpreter guards `, which prevent an interpreter " +"from finalizing." +msgstr "" + +#: ../../whatsnew/3.15.rst:608 +msgid "" +":ref:`Interpreter views `, which allow thread-safe access " +"to an interpreter that may be concurrently finalizing or deleted." +msgstr "" + +#: ../../whatsnew/3.15.rst:610 +msgid "" +":ref:`New APIs ` to automatically attach and detach " +"thread states that come with built-in protection against finalization." +msgstr "" + +#: ../../whatsnew/3.15.rst:613 +msgid "" +"In addition, APIs in the ``PyGILState`` family (most notably :c:func:" +"`PyGILState_Ensure` and :c:func:`PyGILState_Release`) have been :term:`soft " +"deprecated`. There is **no** plan to remove them, and existing code will " +"continue to work, but there will be no new ``PyGILState`` APIs in future " +"versions of Python." +msgstr "" + +#: ../../whatsnew/3.15.rst:619 +msgid "(Contributed by Peter Bierma in :gh:`149101`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:621 +msgid ":pep:`788` for further details." +msgstr "" + +#: ../../whatsnew/3.15.rst:627 +msgid "Improved error messages" +msgstr "改善錯誤訊息" + +#: ../../whatsnew/3.15.rst:629 +msgid "" +"The interpreter now provides more helpful suggestions in :exc:" +"`AttributeError` exceptions when accessing an attribute on an object that " +"does not exist, but a similar attribute is available through one of its " +"members." +msgstr "" + +#: ../../whatsnew/3.15.rst:633 +msgid "" +"For example, if the object has an attribute that itself exposes the " +"requested name, the error message will suggest accessing it via that inner " +"attribute:" +msgstr "" + +#: ../../whatsnew/3.15.rst:636 +msgid "" +"from dataclasses import dataclass\n" +"from math import pi\n" +"\n" +"@dataclass\n" +"class Circle:\n" +" radius: float\n" +"\n" +" @property\n" +" def area(self) -> float:\n" +" return pi * self.radius**2\n" +"\n" +"class Container:\n" +" def __init__(self, inner: Circle) -> None:\n" +" self.inner = inner\n" +"\n" +"circle = Circle(radius=4.0)\n" +"container = Container(circle)\n" +"print(container.area)" +msgstr "" +"from dataclasses import dataclass\n" +"from math import pi\n" +"\n" +"@dataclass\n" +"class Circle:\n" +" radius: float\n" +"\n" +" @property\n" +" def area(self) -> float:\n" +" return pi * self.radius**2\n" +"\n" +"class Container:\n" +" def __init__(self, inner: Circle) -> None:\n" +" self.inner = inner\n" +"\n" +"circle = Circle(radius=4.0)\n" +"container = Container(circle)\n" +"print(container.area)" + +#: ../../whatsnew/3.15.rst:657 +msgid "Running this code now produces a clearer suggestion:" +msgstr "" + +#: ../../whatsnew/3.15.rst:659 +msgid "" +"Traceback (most recent call last):\n" +" File \"example.py\", line 18, in \n" +" print(container.area)\n" +" ^^^^^^^^^^^^^^\n" +"AttributeError: 'Container' object has no attribute 'area'. Did you mean '." +"inner.area' instead of '.area'?" +msgstr "" +"Traceback (most recent call last):\n" +" File \"example.py\", line 18, in \n" +" print(container.area)\n" +" ^^^^^^^^^^^^^^\n" +"AttributeError: 'Container' object has no attribute 'area'. Did you mean " +"'.inner.area' instead of '.area'?" + +#: ../../whatsnew/3.15.rst:667 +msgid "" +"When an :exc:`AttributeError` on a builtin type has no close match via " +"Levenshtein distance, the error message now checks a static table of common " +"method names from other languages (JavaScript, Java, Ruby, C#) and suggests " +"the Python equivalent:" +msgstr "" + +#: ../../whatsnew/3.15.rst:672 +msgid "" +">>> [1, 2, 3].push(4)\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'list' object has no attribute 'push'. Did you mean '." +"append'?\n" +"\n" +">>> 'hello'.toUpperCase()\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'str' object has no attribute 'toUpperCase'. Did you mean '." +"upper'?" +msgstr "" +">>> [1, 2, 3].push(4)\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'list' object has no attribute 'push'. Did you mean " +"'.append'?\n" +"\n" +">>> 'hello'.toUpperCase()\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'str' object has no attribute 'toUpperCase'. Did you mean " +"'.upper'?" + +#: ../../whatsnew/3.15.rst:684 +msgid "" +"When the Python equivalent is a language construct rather than a method, the " +"hint describes the construct directly:" +msgstr "" + +#: ../../whatsnew/3.15.rst:687 +msgid "" +">>> {}.put(\"a\", 1)\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'dict' object has no attribute 'put'. Use d[k] = v." +msgstr "" +">>> {}.put(\"a\", 1)\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'dict' object has no attribute 'put'. Use d[k] = v." + +#: ../../whatsnew/3.15.rst:694 +msgid "" +"When a mutable method is called on an immutable type, the hint suggests the " +"mutable counterpart:" +msgstr "" + +#: ../../whatsnew/3.15.rst:697 +msgid "" +">>> (1, 2, 3).append(4)\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'tuple' object has no attribute 'append'. Did you mean to " +"use a 'list' object?" +msgstr "" +">>> (1, 2, 3).append(4)\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'tuple' object has no attribute 'append'. Did you mean to " +"use a 'list' object?" + +#: ../../whatsnew/3.15.rst:704 +msgid "These hints also work for subclasses of builtin types." +msgstr "" + +#: ../../whatsnew/3.15.rst:706 +msgid "(Contributed by Matt Van Horn in :gh:`146406`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:708 +msgid "" +"The interpreter now tries to provide a suggestion when :func:`delattr` fails " +"due to a missing attribute. When an attribute name that closely resembles an " +"existing attribute is used, the interpreter will suggest the correct " +"attribute name in the error message. For example:" +msgstr "" + +#: ../../whatsnew/3.15.rst:714 +msgid "" +">>> class A:\n" +"... pass\n" +">>> a = A()\n" +">>> a.abcde = 1\n" +">>> del a.abcdf\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'A' object has no attribute 'abcdf'. Did you mean: 'abcde'?" +msgstr "" +">>> class A:\n" +"... pass\n" +">>> a = A()\n" +">>> a.abcde = 1\n" +">>> del a.abcdf\n" +"Traceback (most recent call last):\n" +"...\n" +"AttributeError: 'A' object has no attribute 'abcdf'. Did you mean: 'abcde'?" + +#: ../../whatsnew/3.15.rst:725 +msgid "(Contributed by Nikita Sobolev and Pranjal Prajapati in :gh:`136588`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:727 +msgid "" +"Several error messages incorrectly using the term \"argument\" have been " +"corrected. (Contributed by Stan Ulbrych in :gh:`133382`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:732 +msgid "Other language changes" +msgstr "其他語言更動" + +#: ../../whatsnew/3.15.rst:736 +msgid "" +"Python now uses UTF-8_ as the default encoding, independent of the system's " +"environment. This means that I/O operations without an explicit encoding, " +"for example, ``open('flying-circus.txt')``, will use UTF-8. UTF-8 is a " +"widely-supported Unicode_ character encoding that has become a *de facto* " +"standard for representing text, including nearly every webpage on the " +"internet, many common file formats, programming languages, and more." +msgstr "" + +#: ../../whatsnew/3.15.rst:743 +msgid "" +"This only applies when no ``encoding`` argument is given. For best " +"compatibility between versions of Python, ensure that an explicit " +"``encoding`` argument is always provided. The :ref:`opt-in encoding warning " +"` can be used to identify code that may be affected by " +"this change. The special ``encoding='locale'`` argument uses the current " +"locale encoding, and has been supported since Python 3.10." +msgstr "" + +#: ../../whatsnew/3.15.rst:750 +msgid "" +"To retain the previous behaviour, Python's UTF-8 mode may be disabled with " +"the :envvar:`PYTHONUTF8=0 ` environment variable or the :option:" +"`-X utf8=0 <-X>` command-line option." +msgstr "" + +#: ../../whatsnew/3.15.rst:754 +msgid "" +"(Contributed by Adam Turner in :gh:`133711`; PEP 686 written by Inada Naoki.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:756 +msgid ":pep:`686` for further details." +msgstr "" + +#: ../../whatsnew/3.15.rst:763 +msgid "" +"The interpreter help (such as ``python --help``) is now in color. This can " +"be controlled by :ref:`environment variables `. " +"(Contributed by Hugo van Kemenade in :gh:`148766`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:770 +msgid "" +"Unraisable exceptions are now highlighted with color by default. This can be " +"controlled by :ref:`environment variables `. " +"(Contributed by Peter Bierma in :gh:`134170`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:776 +msgid "" +"More color in :ref:`argparse `, :ref:`ast " +"`, :ref:`calendar `, :ref:" +"`difflib `, :ref:`http.server `, :ref:`pickletools `, :ref:" +"`PyREPL tab completion `, :ref:`python --help " +"`, :ref:`sqlite3 `, :ref:`timeit `, :ref:`tokenize " +"`, :ref:`unraisable exceptions ` and :term:`stdlib` (ast, compileall, doctest, gzip, " +"inspect, json.tool, pdb, profiling.sampling, random, regrtest, sqlite3, " +"timeit, tokenize, trace, unittest, uuid, zipapp, zipfile) CLI help." +msgstr "" + +#: ../../whatsnew/3.15.rst:793 +msgid "" +"The :meth:`~object.__repr__` of :class:`ImportError` and :class:" +"`ModuleNotFoundError` now shows \"name\" and \"path\" as ``name=`` and " +"``path=`` if they were given as keyword arguments at construction " +"time. (Contributed by Serhiy Storchaka, Oleg Iarygin, and Yoav Nir in :gh:" +"`74185`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:798 +msgid "" +"The :attr:`~object.__dict__` and :attr:`!__weakref__` descriptors now use a " +"single descriptor instance per interpreter, shared across all types that " +"need them. This speeds up class creation, and helps avoid reference cycles. " +"(Contributed by Petr Viktorin in :gh:`135228`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:804 +msgid "" +"The :option:`-W` option and the :envvar:`PYTHONWARNINGS` environment " +"variable can now specify regular expressions instead of literal strings to " +"match the warning message and the module name, if the corresponding field " +"starts and ends with a forward slash (``/``). (Contributed by Serhiy " +"Storchaka in :gh:`134716`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:810 +msgid "" +"Functions that take timestamp or timeout arguments now accept any real " +"numbers (such as :class:`~decimal.Decimal` and :class:`~fractions." +"Fraction`), not only integers or floats, although this does not improve " +"precision. (Contributed by Serhiy Storchaka in :gh:`67795`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:817 +msgid "" +"Added :meth:`bytearray.take_bytes(n=None, /) ` to take " +"bytes out of a :class:`bytearray` without copying. This enables optimizing " +"code which must return :class:`bytes` after working with a mutable buffer of " +"bytes such as data buffering, network protocol parsing, encoding, decoding, " +"and compression. Common code patterns which can be optimized with :func:" +"`~bytearray.take_bytes` are listed below." +msgstr "" + +#: ../../whatsnew/3.15.rst:824 +msgid "Suggested optimizing refactors" +msgstr "" + +#: ../../whatsnew/3.15.rst:827 +msgid "Description" +msgstr "描述" + +#: ../../whatsnew/3.15.rst:828 +msgid "Old" +msgstr "" + +#: ../../whatsnew/3.15.rst:829 +msgid "New" +msgstr "" + +#: ../../whatsnew/3.15.rst:831 +msgid "Return :class:`bytes` after working with :class:`bytearray`" +msgstr "" + +#: ../../whatsnew/3.15.rst:832 +msgid "" +"def read() -> bytes:\n" +" buffer = bytearray(1024)\n" +" ...\n" +" return bytes(buffer)" +msgstr "" +"def read() -> bytes:\n" +" buffer = bytearray(1024)\n" +" ...\n" +" return bytes(buffer)" + +#: ../../whatsnew/3.15.rst:839 +msgid "" +"def read() -> bytes:\n" +" buffer = bytearray(1024)\n" +" ...\n" +" return buffer.take_bytes()" +msgstr "" +"def read() -> bytes:\n" +" buffer = bytearray(1024)\n" +" ...\n" +" return buffer.take_bytes()" + +#: ../../whatsnew/3.15.rst:846 +msgid "Empty a buffer getting the bytes" +msgstr "" + +#: ../../whatsnew/3.15.rst:847 +msgid "" +"buffer = bytearray(1024)\n" +"...\n" +"data = bytes(buffer)\n" +"buffer.clear()" +msgstr "" +"buffer = bytearray(1024)\n" +"...\n" +"data = bytes(buffer)\n" +"buffer.clear()" + +#: ../../whatsnew/3.15.rst:854 +msgid "" +"buffer = bytearray(1024)\n" +"...\n" +"data = buffer.take_bytes()" +msgstr "" +"buffer = bytearray(1024)\n" +"...\n" +"data = buffer.take_bytes()" + +#: ../../whatsnew/3.15.rst:860 +msgid "Split a buffer at a specific separator" +msgstr "" + +#: ../../whatsnew/3.15.rst:861 +msgid "" +"buffer = bytearray(b'abc\\ndef')\n" +"n = buffer.find(b'\\n')\n" +"data = bytes(buffer[:n + 1])\n" +"del buffer[:n + 1]\n" +"assert data == b'abc\\n'\n" +"assert buffer == bytearray(b'def')" +msgstr "" +"buffer = bytearray(b'abc\\ndef')\n" +"n = buffer.find(b'\\n')\n" +"data = bytes(buffer[:n + 1])\n" +"del buffer[:n + 1]\n" +"assert data == b'abc\\n'\n" +"assert buffer == bytearray(b'def')" + +#: ../../whatsnew/3.15.rst:870 +msgid "" +"buffer = bytearray(b'abc\\ndef')\n" +"n = buffer.find(b'\\n')\n" +"data = buffer.take_bytes(n + 1)" +msgstr "" +"buffer = bytearray(b'abc\\ndef')\n" +"n = buffer.find(b'\\n')\n" +"data = buffer.take_bytes(n + 1)" + +#: ../../whatsnew/3.15.rst:876 +msgid "Split a buffer at a specific separator; discard after the separator" +msgstr "" + +#: ../../whatsnew/3.15.rst:877 +msgid "" +"buffer = bytearray(b'abc\\ndef')\n" +"n = buffer.find(b'\\n')\n" +"data = bytes(buffer[:n])\n" +"buffer.clear()\n" +"assert data == b'abc'\n" +"assert len(buffer) == 0" +msgstr "" +"buffer = bytearray(b'abc\\ndef')\n" +"n = buffer.find(b'\\n')\n" +"data = bytes(buffer[:n])\n" +"buffer.clear()\n" +"assert data == b'abc'\n" +"assert len(buffer) == 0" + +#: ../../whatsnew/3.15.rst:886 +msgid "" +"buffer = bytearray(b'abc\\ndef')\n" +"n = buffer.find(b'\\n')\n" +"buffer.resize(n)\n" +"data = buffer.take_bytes()" +msgstr "" +"buffer = bytearray(b'abc\\ndef')\n" +"n = buffer.find(b'\\n')\n" +"buffer.resize(n)\n" +"data = buffer.take_bytes()" + +#: ../../whatsnew/3.15.rst:893 +msgid "(Contributed by Cody Maloney in :gh:`139871`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:895 +msgid "" +"Many functions related to compiling or parsing Python code, such as :func:" +"`compile`, :func:`ast.parse`, :func:`symtable.symtable`, and :func:" +"`importlib.abc.InspectLoader.source_to_code`, now allow the module name to " +"be passed. It is needed to unambiguously :ref:`filter ` " +"syntax warnings by module name. (Contributed by Serhiy Storchaka in :gh:" +"`135801`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:902 +msgid "" +"Allowed defining the *__dict__* and *__weakref__* :ref:`__slots__ ` " +"for any class. (Contributed by Serhiy Storchaka in :gh:`41779`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:906 +msgid "" +"Allowed defining any :ref:`__slots__ ` for a class derived from :" +"class:`tuple` (including classes created by :func:`collections.namedtuple`). " +"(Contributed by Serhiy Storchaka in :gh:`41779`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:910 +msgid "" +"The :class:`slice` type now supports subscription, making it a :term:" +"`generic type`. (Contributed by James Hilton-Balfe in :gh:`128335`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:914 +msgid "" +"The class :class:`memoryview` now supports the :c:expr:`float complex` and :" +"c:expr:`double complex` C types: formatting characters ``'Zf'`` and ``'Zd'`` " +"respectively. (Contributed by Victor Stinner in :gh:`146151` and :gh:" +"`148675`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:919 +msgid "" +"Allow the *count* argument of :meth:`bytes.replace` to be a keyword. " +"(Contributed by Stan Ulbrych in :gh:`147856`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:922 +msgid "" +"Unary plus is now accepted in :keyword:`match` literal patterns, mirroring " +"the existing support for unary minus. (Contributed by Bartosz Sławecki in :" +"gh:`145239`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:926 +msgid "" +"The import system now acquires per-module locks in hierarchical order " +"(parent packages before their submodules). This fixes a long-standing " +"deadlock where one thread importing ``pkg.sub`` and another importing ``pkg." +"sub.mod`` could each block the other when ``pkg/sub/__init__.py`` imports " +"``pkg.sub.mod``. (Contributed by Gregory P. Smith in :gh:`83065`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:933 +msgid "" +"File names of Stable ABI extensions that use the ``.so`` suffix may now " +"include a multiarch tuple, for example, ``foo.abi3-x86-64-linux-gnu.so``. " +"This permits stable ABI extensions for multiple architectures to be co-" +"installed into the same directory, without clashing with each other, as " +"regular dynamic extensions do. (Contributed by Stefano Rivera in :gh:" +"`122931`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:940 +msgid "" +"The ``__cached__`` attribute on modules, which was deprecated since version " +"3.13, is no longer set or taken into consideration by the import system or " +"standard library. Use :attr:`__spec__.cached ` instead. (Contributed by Brett Cannon in :gh:`97879`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:946 +msgid "" +"Note that the :attr:`~module.__loader__` and :attr:`~module.__package__` " +"attributes are also deprecated and scheduled for removal." +msgstr "" + +#: ../../whatsnew/3.15.rst:951 +msgid "Default interactive shell" +msgstr "" + +#: ../../whatsnew/3.15.rst:955 +msgid "" +"Tab completions are now colored by object kind, based on :pypi:" +"`fancycompleter`. Set :envvar:`PYTHON_BASIC_COMPLETER` to fall back to :mod:" +"`rlcompleter`. Color can also be controlled by :ref:`environment variables " +"`. (Contributed by Antonio Cuni and Pablo " +"Galindo in :gh:`130472`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:962 +msgid "" +"Tab completion now suggests module attributes in ``from ... import`` " +"statements. Attributes can only be suggested once the module is imported, " +"so :term:`stdlib` modules are imported automatically, while for other " +"modules the completer offers to import them when :kbd:`Tab` is pressed a " +"second time. (Contributed by Loïc Simon and Pablo Galindo in :gh:`140870`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:971 +msgid "New modules" +msgstr "新增模組" + +#: ../../whatsnew/3.15.rst:974 +msgid "math.integer" +msgstr "" + +#: ../../whatsnew/3.15.rst:976 +msgid "" +"This module provides access to the mathematical functions for integer " +"arguments (:pep:`791`). (Contributed by Serhiy Storchaka in :gh:`81313`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:982 +msgid "Improved modules" +msgstr "改進的模組" + +#: ../../whatsnew/3.15.rst:985 +msgid "argparse" +msgstr "argparse" + +#: ../../whatsnew/3.15.rst:987 +msgid "" +"The :class:`~argparse.BooleanOptionalAction` action now supports single-dash " +"long options and alternate prefix characters. (Contributed by Serhiy " +"Storchaka in :gh:`138525`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:991 +msgid "" +"Changed the *suggest_on_error* parameter of :class:`argparse.ArgumentParser` " +"to default to ``True``. This enables suggestions for mistyped arguments by " +"default. (Contributed by Jakob Schluse in :gh:`140450`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:997 +msgid "" +"Added backtick markup support in :class:`~argparse.ArgumentParser` " +"description and epilog text to highlight inline code when color output is " +"enabled. (Contributed by Savannah Ostrowski in :gh:`142390`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1001 +msgid "" +"Extended backtick markup to argument ``help`` text and added support for " +"double backticks (RST inline-literal style). (Contributed by Hugo van " +"Kemenade in :gh:`149375`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1007 +msgid "array" +msgstr "" + +#: ../../whatsnew/3.15.rst:1009 +msgid "" +"Support the :c:expr:`float complex` and :c:expr:`double complex` C types: " +"formatting characters ``'Zf'`` and ``'Zd'`` respectively. (Contributed by " +"Victor Stinner in :gh:`146151` and :gh:`148675`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1013 +msgid "" +"Support half-floats (16-bit IEEE 754 binary interchange format): formatting " +"character ``'e'``. (Contributed by Sergey B Kirpichev in :gh:`146238`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1017 +msgid "" +"The :data:`array.typecodes` type changed from :class:`str` to :class:`tuple` " +"to support type codes longer than 1 character (``Zf`` and ``Zd``). " +"(Contributed by Victor Stinner in :gh:`148675`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1023 ../../whatsnew/3.15.rst:2130 +msgid "ast" +msgstr "ast" + +#: ../../whatsnew/3.15.rst:1027 +msgid "" +"Add *color* parameter to :func:`~ast.dump`. If ``True``, the returned string " +"is syntax highlighted using ANSI escape sequences. If ``False`` (the " +"default), colored output is always disabled. (Contributed by Stan Ulbrych " +"in :gh:`148981`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1033 +msgid "" +"The :ref:`command-line ` output is now syntax highlighted by " +"default. This can be :ref:`controlled using environment variables `. (Contributed by Stan Ulbrych in :gh:`148981`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1039 +msgid "asyncio" +msgstr "asyncio" + +#: ../../whatsnew/3.15.rst:1041 +msgid "" +"Added :meth:`TaskGroup.cancel ` to allow early " +"termination of a task group, for instance, when the goal of the tasks has " +"been achieved or their services are no longer needed. Previously this would " +"involve unintuitive boilerplate such as an extra task raising a custom " +"exception which is then suppressed as it exits the task group. (Contributed " +"by John Belmonte in :gh:`127214`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1050 +msgid "base64" +msgstr "base64" + +#: ../../whatsnew/3.15.rst:1052 +msgid "" +"Added the *pad* parameter in :func:`~base64.z85encode`. (Contributed by " +"Hauke Dämpfling in :gh:`143103`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1055 +msgid "" +"Added the *padded* parameter in :func:`~base64.b32encode`, :func:`~base64." +"b32decode`, :func:`~base64.b32hexencode`, :func:`~base64.b32hexdecode`, :" +"func:`~base64.b64encode`, :func:`~base64.b64decode`, :func:`~base64." +"urlsafe_b64encode`, and :func:`~base64.urlsafe_b64decode`. (Contributed by " +"Serhiy Storchaka in :gh:`73613`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1062 +msgid "" +"Added the *wrapcol* parameter in :func:`~base64.b16encode`, :func:`~base64." +"b32encode`, :func:`~base64.b32hexencode`, :func:`~base64.b64encode`, :func:" +"`~base64.b85encode`, and :func:`~base64.z85encode`. (Contributed by Serhiy " +"Storchaka in :gh:`143214` and :gh:`146431`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1068 +msgid "" +"Added the *ignorechars* parameter in :func:`~base64.b16decode`, :func:" +"`~base64.b32decode`, :func:`~base64.b32hexdecode`, :func:`~base64." +"b64decode`, :func:`~base64.b85decode`, and :func:`~base64.z85decode`. " +"(Contributed by Serhiy Storchaka in :gh:`144001` and :gh:`146431`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1074 +msgid "" +"Added the *canonical* parameter in :func:`~base64.b32decode`, :func:`~base64." +"b32hexdecode`, :func:`~base64.b64decode`, :func:`~base64.a85decode`, :func:" +"`~base64.b85decode`, and :func:`~base64.z85decode`, to reject encodings with " +"non-zero padding bits or other non-canonical forms. (Contributed by Gregory " +"P. Smith in :gh:`146311`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1085 +msgid "binascii" +msgstr "binascii" + +#: ../../whatsnew/3.15.rst:1087 +msgid "Added functions for Base32 encoding:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1089 +msgid ":func:`~binascii.b2a_base32` and :func:`~binascii.a2b_base32`" +msgstr "" + +#: ../../whatsnew/3.15.rst:1091 +msgid "(Contributed by James Seo in :gh:`146192`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1093 +msgid "Added functions for Ascii85, Base85, and Z85 encoding:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1095 +msgid ":func:`~binascii.b2a_ascii85` and :func:`~binascii.a2b_ascii85`" +msgstr "" + +#: ../../whatsnew/3.15.rst:1096 +msgid ":func:`~binascii.b2a_base85` and :func:`~binascii.a2b_base85`" +msgstr "" + +#: ../../whatsnew/3.15.rst:1098 +msgid "(Contributed by James Seo and Serhiy Storchaka in :gh:`101178`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1100 +msgid "" +"Added the *padded* parameter in :func:`~binascii.b2a_base32`, :func:" +"`~binascii.a2b_base32`, :func:`~binascii.b2a_base64`, and :func:`~binascii." +"a2b_base64`. (Contributed by Serhiy Storchaka in :gh:`73613`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1105 +msgid "" +"Added the *wrapcol* parameter in :func:`~binascii.b2a_base64`. (Contributed " +"by Serhiy Storchaka in :gh:`143214`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1108 +msgid "" +"Added the *alphabet* parameter in :func:`~binascii.b2a_base64` and :func:" +"`~binascii.a2b_base64`. (Contributed by Serhiy Storchaka in :gh:`145980`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1112 +msgid "" +"Added the *ignorechars* parameter in :func:`~binascii.a2b_hex`, :func:" +"`~binascii.unhexlify`, and :func:`~binascii.a2b_base64`. (Contributed by " +"Serhiy Storchaka in :gh:`144001` and :gh:`146431`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1116 +msgid "" +"Added the *canonical* parameter in :func:`~binascii.a2b_base64`, to reject " +"encodings with non-zero padding bits. (Contributed by Gregory P. Smith in :" +"gh:`146311`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1122 +msgid "calendar" +msgstr "calendar" + +#: ../../whatsnew/3.15.rst:1126 +msgid "" +":mod:`calendar`'s :ref:`command-line ` text output has more " +"color. This can be controlled with :ref:`environment variables `. (Contributed by Hugo van Kemenade in :gh:`148352`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1131 +msgid "" +"The :mod:`calendar`'s :ref:`command-line ` HTML output now " +"accepts the year-month option: ``python -m calendar -t html 2009 06``. " +"(Contributed by Pål Grønås Drange in :gh:`140212`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1135 +msgid "" +"Calendar pages generated by the :class:`calendar.HTMLCalendar` class now " +"support dark mode and have been migrated to the HTML5 standard for improved " +"accessibility. (Contributed by Jiahao Li and Hugo van Kemenade in :gh:" +"`137634`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1141 +msgid "collections" +msgstr "collections" + +#: ../../whatsnew/3.15.rst:1143 +msgid "" +"Added :meth:`!collections.Counter.__xor__` and :meth:`!collections.Counter." +"__ixor__` to compute the symmetric difference between :class:`~collections." +"Counter` objects. (Contributed by Raymond Hettinger in :gh:`138682`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1150 +msgid "concurrent.futures" +msgstr "concurrent.futures" + +#: ../../whatsnew/3.15.rst:1152 +msgid "" +"Improved error reporting when a child process in a :class:`concurrent." +"futures.ProcessPoolExecutor` terminates abruptly. The resulting traceback " +"will now tell you the PID and exit code of the terminated process. " +"(Contributed by Jonathan Berg in :gh:`139486`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1160 +msgid "contextlib" +msgstr "contextlib" + +#: ../../whatsnew/3.15.rst:1162 +msgid "" +"Added support for arbitrary descriptors :meth:`!__enter__`, :meth:`!" +"__exit__`, :meth:`!__aenter__`, and :meth:`!__aexit__` in :class:" +"`~contextlib.ExitStack` and :class:`contextlib.AsyncExitStack`, for " +"consistency with the :keyword:`with` and :keyword:`async with` statements. " +"(Contributed by Serhiy Storchaka in :gh:`144386`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1168 +msgid "" +":class:`~contextlib.ContextDecorator` and :class:`~contextlib." +"AsyncContextDecorator` (and therefore :func:`~contextlib.contextmanager` " +"and :func:`~contextlib.asynccontextmanager` used as decorators) now detect " +"generator functions, coroutine functions, and asynchronous generator " +"functions and keep the context manager open across iteration or await. " +"Previously the context manager exited as soon as the generator or coroutine " +"object was created. (Contributed by Alex Grönholm & Gregory P. Smith in :gh:" +"`125862`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1179 ../../whatsnew/3.15.rst:2149 +msgid "ctypes" +msgstr "ctypes" + +#: ../../whatsnew/3.15.rst:1181 +msgid "" +"Change the :py:attr:`~ctypes._SimpleCData._type_` of :class:`~ctypes." +"c_float_complex`, :class:`~ctypes.c_double_complex` and :class:`~ctypes." +"c_longdouble_complex` from ``F``, ``D`` and ``G`` to ``Zf``, ``Zd`` and " +"``Zg`` for compatibility with NumPy. (Contributed by Victor Stinner in :gh:" +"`148675`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1189 +msgid "dataclasses" +msgstr "dataclasses" + +#: ../../whatsnew/3.15.rst:1191 +msgid "" +"Annotations for generated ``__init__`` methods no longer include internal " +"type names. (Contributed by David Ellis in :gh:`137530`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1197 +msgid "dbm" +msgstr "dbm" + +#: ../../whatsnew/3.15.rst:1199 +msgid "" +"Added new :meth:`!reorganize` methods to :mod:`dbm.dumb` and :mod:`dbm." +"sqlite3` to recover unused free space previously occupied by deleted " +"entries. (Contributed by Andrea Oliveri in :gh:`134004`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1205 +msgid "difflib" +msgstr "difflib" + +#: ../../whatsnew/3.15.rst:1209 +msgid "" +"Introduced the optional *color* parameter to :func:`difflib.unified_diff`, " +"enabling color output similar to :program:`git diff`. This can be controlled " +"by :ref:`environment variables `. (Contributed " +"by Douglas Thor in :gh:`133725`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1215 +msgid "" +"Improved the styling of HTML diff pages generated by the :class:`difflib." +"HtmlDiff` class, and migrated the output to the HTML5 standard. (Contributed " +"by Jiahao Li in :gh:`134580`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1221 +msgid "email" +msgstr "email" + +#: ../../whatsnew/3.15.rst:1223 +msgid "" +"Email generators now raise an error when an :class:`.EmailMessage` cannot be " +"accurately flattened due to a non-ASCII email address (mailbox) in an " +"address header. Options for supporting Email Address Internationalization " +"(EAI) are discussed in :attr:`.EmailPolicy.utf8`. (Contributed by R David " +"Murray and Mike Edmunds in :gh:`122540`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1231 +msgid "faulthandler" +msgstr "faulthandler" + +#: ../../whatsnew/3.15.rst:1233 +msgid "" +"Added the *max_threads* parameter in :func:`faulthandler.enable`, :func:" +"`faulthandler.dump_traceback`, :func:`faulthandler.dump_traceback_later`, " +"and :func:`faulthandler.register`. (Contributed by Eric Froemling in :gh:" +"`149085`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1240 +msgid "functools" +msgstr "functools" + +#: ../../whatsnew/3.15.rst:1242 +msgid "" +":func:`~functools.singledispatchmethod` now supports non-:term:`descriptor` " +"callables. (Contributed by Serhiy Storchaka in :gh:`140873`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1246 +msgid "" +":func:`~functools.singledispatchmethod` now dispatches on the second " +"argument if it wraps a regular method and is called as a class attribute. " +"(Contributed by Bartosz Sławecki in :gh:`143535`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1252 +msgid "gc" +msgstr "gc" + +#: ../../whatsnew/3.15.rst:1254 +msgid "" +"Python 3.14.0-3.14.4 shipped with a new incremental garbage collector. " +"However, due to a number of `reports `__ of significant memory pressure in production environments, " +"it has been reverted back to the generational GC from 3.13. This is the GC " +"now used in Python 3.14.5 and later and Python 3.15. (Contributed by Sergey " +"Miryanov in :gh:`148726`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1264 +msgid "hashlib" +msgstr "hashlib" + +#: ../../whatsnew/3.15.rst:1266 +msgid "" +"Ensure that hash functions guaranteed to be always *available* exist as " +"attributes of :mod:`hashlib` even if they will not work at runtime due to " +"missing backend implementations. For instance, ``hashlib.md5`` will no " +"longer raise :exc:`AttributeError` if OpenSSL is not available and Python " +"has been built without MD5 support. (Contributed by Bénédikt Tran in :gh:" +"`136929`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1275 +msgid "http.client" +msgstr "http.client" + +#: ../../whatsnew/3.15.rst:1277 +msgid "" +"A new *max_response_headers* keyword-only parameter has been added to :class:" +"`~http.client.HTTPConnection` and :class:`~http.client.HTTPSConnection` " +"constructors. This parameter overrides the default maximum number of allowed " +"response headers. (Contributed by Alexander Enrique Urieles Nieto in :gh:" +"`131724`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1285 ../../whatsnew/3.15.rst:2175 +msgid "http.server" +msgstr "http.server" + +#: ../../whatsnew/3.15.rst:1289 +msgid "" +"The logging of :mod:`~http.server.BaseHTTPRequestHandler`, as used by the :" +"ref:`command-line interface `, is colored by default. This " +"can be controlled with :ref:`environment variables `. (Contributed by Hugo van Kemenade in :gh:`146292`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1296 +msgid "" +"Added :attr:`~http.server.SimpleHTTPRequestHandler.default_content_type` and " +"the :option:`--content-type ` command-line " +"option to allow customizing the default ``Content-Type`` header for files " +"with unknown extensions. (Contributed by John Comeau and Hugo van Kemenade " +"in :gh:`113471`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1302 +msgid "" +"Add a new ``extra_response_headers`` keyword argument to :class:`~http." +"server.SimpleHTTPRequestHandler` to support custom headers in HTTP " +"responses. (Contributed by Anton I. Sipos in :gh:`135057`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1307 +msgid "" +"Add a :option:`-H/--header ` option to the :program:" +"`python -m http.server` command-line interface to support custom headers in " +"HTTP responses. (Contributed by Anton I. Sipos in :gh:`135057`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1313 +msgid "importlib.metadata" +msgstr "importlib.metadata" + +#: ../../whatsnew/3.15.rst:1315 +msgid "" +"Previously, when accessing a distribution metadata directory not containing " +"a metadata file, ``metadata()`` and ``Distribution.metadata`` would return " +"an empty ``PackageMetadata`` object as if the file was present but empty. " +"Now, a ``MetadataNotFound`` exception is raised. See `importlib_metadata#493 " +"`_ for background " +"and rationale and :gh:`143387` for rationale on the compatibility concerns. " +"(Contributed by Jason R. Coombs.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1326 +msgid "inspect" +msgstr "inspect" + +#: ../../whatsnew/3.15.rst:1328 +msgid "" +"Add parameters *inherit_class_doc* and *fallback_to_class_doc* for :func:" +"`~inspect.getdoc`. (Contributed by Serhiy Storchaka in :gh:`132686`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1334 +msgid "json" +msgstr "json" + +#: ../../whatsnew/3.15.rst:1336 +msgid "" +"Add the *array_hook* parameter to :func:`~json.load` and :func:`~json.loads` " +"functions: allow a callback for JSON literal array types to customize Python " +"lists in the resulting decoded object. Passing combined :class:`frozendict` " +"to *object_pairs_hook* parameter and :class:`tuple` to *array_hook* will " +"yield a deeply nested immutable Python structure representing the JSON data. " +"(Contributed by Joao S. O. Bueno in :gh:`146440`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1346 +msgid "locale" +msgstr "locale" + +#: ../../whatsnew/3.15.rst:1348 +msgid "" +":func:`~locale.setlocale` now supports language codes with ``@``-modifiers. " +"``@``-modifiers are no longer silently removed in :func:`~locale.getlocale`, " +"but included in the language code. (Contributed by Serhiy Storchaka in :gh:" +"`137729`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1353 +msgid "" +"Undeprecate the :func:`locale.getdefaultlocale` function. (Contributed by " +"Victor Stinner in :gh:`130796`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1358 +msgid "math" +msgstr "" + +#: ../../whatsnew/3.15.rst:1360 +msgid "" +"Add :func:`math.isnormal` and :func:`math.issubnormal` functions. " +"(Contributed by Sergey B Kirpichev in :gh:`132908`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1363 +msgid "" +"Add :func:`math.fmax`, :func:`math.fmin` and :func:`math.signbit` functions. " +"(Contributed by Bénédikt Tran in :gh:`135853`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1368 +msgid "mimetypes" +msgstr "mimetypes" + +#: ../../whatsnew/3.15.rst:1370 +msgid "" +"Add more MIME types. (Contributed by Benedikt Johannes, Charlie Lin, " +"Foolbar, Gil Forcada and John Franey in :gh:`144217`, :gh:`145720`, :gh:" +"`140937`, :gh:`139959`, :gh:`145698`, :gh:`145718`, :gh:`145918`, and :gh:" +"`144213`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1376 +msgid "" +"Rename ``application/x-texinfo`` to ``application/texinfo``. (Contributed by " +"Charlie Lin in :gh:`140165`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1379 +msgid "" +"Changed the MIME type for ``.ai`` files to ``application/pdf``. (Contributed " +"by Stan Ulbrych in :gh:`141239`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1384 +msgid "mmap" +msgstr "mmap" + +#: ../../whatsnew/3.15.rst:1386 +msgid "" +":class:`mmap.mmap` now has a *trackfd* parameter on Windows; if it is " +"``False``, the file handle corresponding to *fileno* will not be duplicated. " +"(Contributed by Serhiy Storchaka in :gh:`78502`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1391 +msgid "" +"Added the :meth:`mmap.mmap.set_name` method to annotate an anonymous memory " +"mapping if Linux kernel supports :manpage:`PR_SET_VMA_ANON_NAME " +"` (Linux 5.17 or newer). (Contributed by Donghee Na in :" +"gh:`142419`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1398 +msgid "os" +msgstr "os" + +#: ../../whatsnew/3.15.rst:1400 +msgid "" +"Add :func:`os.statx` on Linux kernel versions 4.11 and later with glibc " +"versions 2.28 and later. (Contributed by Jeffrey Bosboom and Victor Stinner " +"in :gh:`83714`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1404 +msgid "" +":func:`os.makedirs` function now has a *parent_mode* parameter that allows " +"specifying the mode for intermediate directories. This can be used to match " +"the behavior from Python 3.6 and earlier by passing ``parent_mode=mode``. " +"(Contributed by Zackery Spytz and Gregory P. Smith in :gh:`86533`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1410 +msgid "os.path" +msgstr "os.path" + +#: ../../whatsnew/3.15.rst:1412 +msgid "" +"Add support of the all-but-last mode in :func:`~os.path.realpath`. " +"(Contributed by Serhiy Storchaka in :gh:`71189`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1415 +msgid "" +"The *strict* parameter to :func:`os.path.realpath` accepts a new value, :" +"data:`os.path.ALLOW_MISSING`. If used, errors other than :exc:" +"`FileNotFoundError` will be re-raised; the resulting path can be missing but " +"it will be free of symlinks. (Contributed by Petr Viktorin for :cve:" +"`2025-4517`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1423 ../../whatsnew/3.15.rst:2203 +msgid "pathlib" +msgstr "pathlib" + +#: ../../whatsnew/3.15.rst:1425 +msgid "" +":meth:`pathlib.Path.mkdir` now has a *parent_mode* parameter that allows " +"specifying the mode for intermediate directories when ``parents=True``. " +"(Contributed by Gregory P. Smith in :gh:`86533`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1431 +msgid "pdb" +msgstr "pdb" + +#: ../../whatsnew/3.15.rst:1433 +msgid "" +"Use the new interactive shell as the default input shell for :mod:`pdb`. " +"(Contributed by Tian Gao in :gh:`145379`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1438 +msgid "pickle" +msgstr "pickle" + +#: ../../whatsnew/3.15.rst:1440 +msgid "" +"Add support for pickling private methods and nested classes. (Contributed by " +"Zackery Spytz and Serhiy Storchaka in :gh:`77188`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1445 +msgid "pickletools" +msgstr "pickletools" + +#: ../../whatsnew/3.15.rst:1449 +msgid "" +"The output of the :mod:`pickletools` command-line interface is colored by " +"default. This can be controlled with :ref:`environment variables `. (Contributed by Hugo van Kemenade in :gh:`149026`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1456 +msgid "pprint" +msgstr "pprint" + +#: ../../whatsnew/3.15.rst:1458 +msgid "" +"Add an *expand* keyword argument for :func:`pprint.pprint`, :func:`pprint." +"pformat`, :func:`pprint.pp`. If true, the output will be formatted similar " +"to pretty-printed :func:`json.dumps` when *indent* is supplied. (Contributed " +"by Stefan Todoran, Semyon Moroz and Hugo van Kemenade in :gh:`112632`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1465 +msgid "" +"Add t-string support to :mod:`pprint`. (Contributed by Loïc Simon and Hugo " +"van Kemenade in :gh:`134551`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1470 +msgid "re" +msgstr "re" + +#: ../../whatsnew/3.15.rst:1472 +msgid "" +":func:`re.prefixmatch` and a corresponding :meth:`re.Pattern.prefixmatch` " +"have been added as alternate, more explicit names for the existing and now :" +"term:`soft deprecated` :func:`re.match` and :meth:`re.Pattern.match` APIs. " +"These are intended to be used to alleviate confusion around what *match* " +"means by following the Zen of Python's *\"Explicit is better than " +"implicit\"* mantra. Most other language regular expression libraries use an " +"API named *match* to mean what Python has always called *search*. " +"(Contributed by Gregory P. Smith in :gh:`86519`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1484 +msgid "resource" +msgstr "resource" + +#: ../../whatsnew/3.15.rst:1486 +msgid "" +"Add new constants: :data:`~resource.RLIMIT_NTHR`, :data:`~resource." +"RLIMIT_UMTXP`, :data:`~resource.RLIMIT_THREADS`, :data:`~resource." +"RLIM_SAVED_CUR`, and :data:`~resource.RLIM_SAVED_MAX`. (Contributed by " +"Serhiy Storchaka in :gh:`137512`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1493 +msgid "shelve" +msgstr "shelve" + +#: ../../whatsnew/3.15.rst:1495 +msgid "" +"Added new :meth:`!reorganize` method to :mod:`shelve` used to recover unused " +"free space previously occupied by deleted entries. (Contributed by Andrea " +"Oliveri in :gh:`134004`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1499 +msgid "" +"Add support for custom serialization and deserialization functions in the :" +"mod:`shelve` module. (Contributed by Furkan Onder in :gh:`99631`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1505 +msgid "socket" +msgstr "socket" + +#: ../../whatsnew/3.15.rst:1507 +msgid "" +"Add constants for the ISO-TP CAN protocol. (Contributed by Patrick Menschel " +"and Stefan Tatschner in :gh:`86819`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1512 +msgid "sqlite3" +msgstr "sqlite3" + +#: ../../whatsnew/3.15.rst:1514 +msgid "" +"The :ref:`command-line interface ` has several new features:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1516 +msgid "" +"SQL keyword completion on :kbd:`Tab`. (Contributed by Long Tan in :gh:" +"`133393`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1521 +msgid "" +"Prompts, error messages, and help text are now colored. This is enabled by " +"default, see :ref:`using-on-controlling-color` for details. (Contributed by " +"Stan Ulbrych and Łukasz Langa in :gh:`133461`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1526 +msgid "" +"Table, index, trigger, view, column, function, and schema completion on :kbd:" +"`Tab`. (Contributed by Long Tan in :gh:`136101`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1531 +msgid "ssl" +msgstr "ssl" + +#: ../../whatsnew/3.15.rst:1533 +msgid "" +"Indicate through :data:`ssl.HAS_PSK_TLS13` whether the :mod:`ssl` module " +"supports \"External PSKs\" in TLSv1.3, as described in :rfc:`9258`. " +"(Contributed by Will Childs-Klein in :gh:`133624`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1537 +msgid "Added new methods for managing groups used for SSL key agreement:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1539 +msgid "" +":meth:`ssl.SSLContext.set_groups` sets the groups allowed for doing key " +"agreement, extending the previous :meth:`ssl.SSLContext.set_ecdh_curve` " +"method. This new API provides the ability to list multiple groups and " +"supports fixed-field and post-quantum groups in addition to ECDH curves. " +"This method can also be used to control what key shares are sent in the TLS " +"handshake." +msgstr "" + +#: ../../whatsnew/3.15.rst:1546 +msgid "" +":meth:`ssl.SSLSocket.group` returns the group selected for doing key " +"agreement on the current connection after the TLS handshake completes. This " +"call requires OpenSSL 3.2 or later." +msgstr "" + +#: ../../whatsnew/3.15.rst:1549 +msgid "" +":meth:`ssl.SSLContext.get_groups` returns a list of all available key " +"agreement groups compatible with the minimum and maximum TLS versions " +"currently set in the context. This call requires OpenSSL 3.5 or later." +msgstr "" + +#: ../../whatsnew/3.15.rst:1553 +msgid "(Contributed by Ron Frederick in :gh:`136306`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1555 +msgid "" +"Added a new method :meth:`ssl.SSLContext.set_ciphersuites` for setting TLS " +"1.3 ciphers. For TLS 1.2 or earlier, :meth:`ssl.SSLContext.set_ciphers` " +"should continue to be used. Both calls can be made on the same context and " +"the selected cipher suite will depend on the TLS version negotiated when a " +"connection is made. (Contributed by Ron Frederick in :gh:`137197`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1562 +msgid "Added new methods for managing signature algorithms:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1564 +msgid "" +":func:`ssl.get_sigalgs` returns a list of all available TLS signature " +"algorithms. This call requires OpenSSL 3.4 or later." +msgstr "" + +#: ../../whatsnew/3.15.rst:1566 +msgid "" +":meth:`ssl.SSLContext.set_client_sigalgs` sets the signature algorithms " +"allowed for certificate-based client authentication." +msgstr "" + +#: ../../whatsnew/3.15.rst:1568 +msgid "" +":meth:`ssl.SSLContext.set_server_sigalgs` sets the signature algorithms " +"allowed for the server to complete the TLS handshake." +msgstr "" + +#: ../../whatsnew/3.15.rst:1570 +msgid "" +":meth:`ssl.SSLSocket.client_sigalg` returns the signature algorithm selected " +"for client authentication on the current connection. This call requires " +"OpenSSL 3.5 or later." +msgstr "" + +#: ../../whatsnew/3.15.rst:1573 +msgid "" +":meth:`ssl.SSLSocket.server_sigalg` returns the signature algorithm selected " +"for the server to complete the TLS handshake on the current connection. This " +"call requires OpenSSL 3.5 or later." +msgstr "" + +#: ../../whatsnew/3.15.rst:1577 +msgid "(Contributed by Ron Frederick in :gh:`138252`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1581 +msgid "subprocess" +msgstr "subprocess" + +#: ../../whatsnew/3.15.rst:1583 +msgid "" +":meth:`subprocess.Popen.wait`: when ``timeout`` is not ``None`` and the " +"platform supports it, an efficient event-driven mechanism is used to wait " +"for process termination:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1587 +msgid "Linux >= 5.3 uses :func:`os.pidfd_open` + :func:`select.poll`." +msgstr "" + +#: ../../whatsnew/3.15.rst:1588 +msgid "" +"macOS and other BSD variants use :func:`select.kqueue` + ``KQ_FILTER_PROC`` " +"+ ``KQ_NOTE_EXIT``." +msgstr "" + +#: ../../whatsnew/3.15.rst:1589 +msgid "Windows keeps using ``WaitForSingleObject`` (unchanged)." +msgstr "" + +#: ../../whatsnew/3.15.rst:1591 +msgid "" +"If none of these mechanisms are available, the function falls back to the " +"traditional busy loop (non-blocking call and short sleeps). (Contributed by " +"Giampaolo Rodola in :gh:`83069`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1597 +msgid "symtable" +msgstr "symtable" + +#: ../../whatsnew/3.15.rst:1599 +msgid "" +"Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` " +"methods. (Contributed by Yashp002 in :gh:`143504`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1604 +msgid "sys" +msgstr "sys" + +#: ../../whatsnew/3.15.rst:1606 +msgid "" +"Add :data:`sys.abi_info` namespace to improve access to ABI information. " +"(Contributed by Klaus Zimmermann in :gh:`137476`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1611 +msgid "sys.monitoring" +msgstr "sys.monitoring" + +#: ../../whatsnew/3.15.rst:1613 +msgid "" +"The :ref:`other events ` (:monitoring-event:" +"`PY_THROW`, :monitoring-event:`PY_UNWIND`, :monitoring-event:`RAISE`, :" +"monitoring-event:`EXCEPTION_HANDLED`, and :monitoring-event:`RERAISE`) can " +"now be turned on and disabled on a per code object basis. Returning :data:" +"`~sys.monitoring.DISABLE` from a callback for one of these events disables " +"the event for the entire code object (for the current tool), rather than " +"raising :exc:`ValueError` as in prior versions. (Contributed by Gabriele N. " +"Tornetta in :gh:`146182`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1624 +msgid "tarfile" +msgstr "tarfile" + +#: ../../whatsnew/3.15.rst:1626 +msgid "" +":func:`~tarfile.data_filter` now normalizes symbolic link targets in order " +"to avoid path traversal attacks. (Contributed by Petr Viktorin in :gh:" +"`127987` and :cve:`2025-4138`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1630 +msgid "" +":func:`~tarfile.TarFile.extractall` now skips fixing up directory attributes " +"when a directory was removed or replaced by another kind of file. " +"(Contributed by Petr Viktorin in :gh:`127987` and :cve:`2024-12718`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1634 +msgid "" +":func:`~tarfile.TarFile.extract` and :func:`~tarfile.TarFile.extractall` now " +"(re-)apply the extraction filter when substituting a link (hard or symbolic) " +"with a copy of another archive member, and when fixing up directory " +"attributes. The former raises a new exception, :exc:`~tarfile." +"LinkFallbackError`. (Contributed by Petr Viktorin for :cve:`2025-4330` and :" +"cve:`2024-12718`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1641 +msgid "" +":func:`~tarfile.TarFile.extract` and :func:`~tarfile.TarFile.extractall` no " +"longer extract rejected members when :func:`~tarfile.TarFile.errorlevel` is " +"zero. (Contributed by Matt Prodani and Petr Viktorin in :gh:`112887` and :" +"cve:`2025-4435`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1647 +msgid "" +":func:`~tarfile.TarFile.extract` and :func:`~tarfile.TarFile.extractall` now " +"replace slashes with backslashes in symlink targets on Windows to prevent " +"creation of corrupted links. (Contributed by Christoph Walcher in :gh:" +"`57911`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1652 +msgid "" +":func:`~tarfile.TarFile.gettarinfo` now replaces backslashes with slashes in " +"symlink targets on Windows to conform to the tar format standard. " +"(Contributed by Daniele Nicolodi in :gh:`151669`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1658 ../../whatsnew/3.15.rst:2233 +msgid "threading" +msgstr "threading" + +#: ../../whatsnew/3.15.rst:1660 +msgid "" +"Added :class:`~threading.serialize_iterator`, :func:`~threading." +"synchronized_iterator`, and :func:`~threading.concurrent_tee` to support " +"concurrent access to generators and iterators. (Contributed by Raymond " +"Hettinger in :gh:`124397`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1668 +msgid "timeit" +msgstr "timeit" + +#: ../../whatsnew/3.15.rst:1672 +msgid "" +"The output of the :mod:`timeit` command-line interface is colored by " +"default. This can be controlled with :ref:`environment variables `. (Contributed by Hugo van Kemenade in :gh:`146609`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1677 +msgid "" +"The command-line interface now colorizes error tracebacks by default. This " +"can be controlled with :ref:`environment variables `. (Contributed by Yi Hong in :gh:`139374`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1682 +msgid "" +"Make the target time of :meth:`timeit.Timer.autorange` configurable and add " +"``--target-time`` option to the command-line interface. (Contributed by " +"Alessandro Cucci and Miikka Koskinen in :gh:`80642`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1688 +msgid "tkinter" +msgstr "tkinter" + +#: ../../whatsnew/3.15.rst:1690 +msgid "" +"The :meth:`!tkinter.Text.search` method now supports two additional " +"arguments: *nolinestop* which allows the search to continue across line " +"boundaries; and *strictlimits* which restricts the search to within the " +"specified range. (Contributed by Rihaan Meher in :gh:`130848`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1696 +msgid "" +"A new method :meth:`!tkinter.Text.search_all` has been introduced. This " +"method allows for searching for all matches of a pattern using Tcl's ``-" +"all`` and ``-overlap`` options. (Contributed by Rihaan Meher in :gh:" +"`130848`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1701 +msgid "" +"Added new methods :meth:`!pack_content`, :meth:`!place_content` and :meth:`!" +"grid_content` which use Tk commands with new names (introduced in Tk 8.6) " +"instead of :meth:`!*_slaves` methods which use Tk commands with outdated " +"names. (Contributed by Serhiy Storchaka in :gh:`143754`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1707 +msgid "" +"Added :class:`!Event` attributes :attr:`!user_data` for Tk virtual events " +"and :attr:`!detail` for ``Enter``, ``Leave``, ``FocusIn``, ``FocusOut``, and " +"``ConfigureRequest`` events. (Contributed by Matthias Kievernagel and Serhiy " +"Storchaka in :gh:`47655`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1714 +msgid "tokenize" +msgstr "tokenize" + +#: ../../whatsnew/3.15.rst:1718 +msgid "" +"The output of the :mod:`tokenize` :ref:`command-line interface ` is colored by default. This can be controlled with :ref:`environment " +"variables `. (Contributed by Hugo van Kemenade " +"in :gh:`148991`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1727 +msgid "tomllib" +msgstr "" + +#: ../../whatsnew/3.15.rst:1729 +msgid "" +"The :mod:`tomllib` module now supports TOML 1.1.0. This is a backwards " +"compatible update, meaning that all valid TOML 1.0.0 documents are parsed " +"the same way." +msgstr "" + +#: ../../whatsnew/3.15.rst:1733 +msgid "The changes, according to the `official TOML changelog`_, are:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1735 +msgid "Allow newlines and trailing commas in inline tables." +msgstr "" + +#: ../../whatsnew/3.15.rst:1737 +msgid "" +"Previously an inline table had to be on a single line and couldn't end with " +"a trailing comma. This is now relaxed so that the following is valid:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1740 +msgid "" +"tbl = {\n" +" key = \"a string\",\n" +" moar-tbl = {\n" +" key = 1,\n" +" },\n" +"}" +msgstr "" +"tbl = {\n" +" key = \"a string\",\n" +" moar-tbl = {\n" +" key = 1,\n" +" },\n" +"}" + +#: ../../whatsnew/3.15.rst:1749 +msgid "" +"Add ``\\xHH`` notation to basic strings for codepoints under 255, and the " +"``\\e`` escape for the escape character:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1752 +msgid "" +"null = \"null byte: \\x00; letter a: \\x61\"\n" +"csi = \"\\e[\"" +msgstr "" +"null = \"null byte: \\x00; letter a: \\x61\"\n" +"csi = \"\\e[\"" + +#: ../../whatsnew/3.15.rst:1757 +msgid "" +"Seconds in datetime and time values are now optional. The following are now " +"valid:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1760 +msgid "" +"dt = 2010-02-03 14:15\n" +"t = 14:15" +msgstr "" +"dt = 2010-02-03 14:15\n" +"t = 14:15" + +#: ../../whatsnew/3.15.rst:1765 +msgid "(Contributed by Taneli Hukkinen in :gh:`142956`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1771 ../../whatsnew/3.15.rst:2242 +msgid "types" +msgstr "" + +#: ../../whatsnew/3.15.rst:1773 +msgid "" +"Expose the write-through :func:`locals` proxy type as :class:`types." +"FrameLocalsProxyType`. This represents the type of the :attr:`frame." +"f_locals` attribute, as described in :pep:`667`. (Contributed by Peter " +"Bierma in :gh:`136492`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1781 ../../whatsnew/3.15.rst:2250 +msgid "typing" +msgstr "typing" + +#: ../../whatsnew/3.15.rst:1785 +msgid "" +":pep:`747`: Add :data:`~typing.TypeForm`, a new special form for annotating " +"values that are themselves type expressions. ``TypeForm[T]`` means \"a type " +"form object describing ``T`` (or a type assignable to ``T``)\". At runtime, " +"``TypeForm(x)`` simply returns ``x``, which allows explicit annotation of " +"type-form values without changing behavior." +msgstr "" + +#: ../../whatsnew/3.15.rst:1792 +msgid "" +"This helps libraries that accept user-provided type expressions (for example " +"``int``, ``str | None``, :class:`~typing.TypedDict` classes, or " +"``list[int]``) expose precise signatures:" +msgstr "" + +#: ../../whatsnew/3.15.rst:1796 +msgid "" +"from typing import Any, TypeForm\n" +"\n" +"def cast[T](typ: TypeForm[T], value: Any) -> T: ..." +msgstr "" +"from typing import Any, TypeForm\n" +"\n" +"def cast[T](typ: TypeForm[T], value: Any) -> T: ..." + +#: ../../whatsnew/3.15.rst:1802 +msgid "(Contributed by Jelle Zijlstra in :gh:`145033`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1806 +msgid "" +":pep:`728`: Add support in :class:`~typing.TypedDict` for the *closed* and " +"*extra_items* class arguments. A closed :class:`~typing.TypedDict` does not " +"allow extra keys beyond those specified in the class body, while a :class:" +"`~typing.TypedDict` with ``extra_items`` allows arbitrary extra items where " +"the values are of the specified type. (Contributed by Angela Liss in :gh:" +"`137840`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1813 +msgid "" +"Code like ``class ExtraTypeVars(P1[S], Protocol[T, T2]): ...`` now raises a :" +"exc:`TypeError`, because ``S`` is not listed in ``Protocol`` parameters. " +"(Contributed by Nikita Sobolev in :gh:`137191`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1817 +msgid "" +"Code like ``class B2(A[T2], Protocol[T1, T2]): ...`` now correctly handles " +"type parameters order: it is ``(T1, T2)``, not ``(T2, T1)`` as it was " +"incorrectly inferred at runtime before. (Contributed by Nikita Sobolev in :" +"gh:`137191`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1824 +msgid "" +":pep:`800`: Add :deco:`typing.disjoint_base`, a new decorator marking a " +"class as a disjoint base. This is an advanced feature primarily intended to " +"allow type checkers to faithfully reflect the runtime semantics of types " +"defined as builtins or in compiled extensions. If a class ``C`` is a " +"disjoint base, then child classes of that class cannot inherit from other " +"disjoint bases that are not parent or child classes of ``C``. (Contributed " +"by Jelle Zijlstra in :gh:`148639`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1831 +msgid "" +":class:`~typing.TypeVarTuple` now accepts ``bound``, ``covariant``, " +"``contravariant``, and ``infer_variance`` keyword arguments, matching the " +"interface of :class:`~typing.TypeVar` and :class:`~typing.ParamSpec`. " +"``bound`` semantics remain undefined in the specification." +msgstr "" + +#: ../../whatsnew/3.15.rst:1838 +msgid "unicodedata" +msgstr "unicodedata" + +#: ../../whatsnew/3.15.rst:1840 +msgid "" +"The Unicode database has been updated to Unicode 17.0.0. (Contributed by " +"Benjamin Peterson in :gh:`138706`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1843 +msgid "" +"Add :func:`unicodedata.isxidstart` and :func:`unicodedata.isxidcontinue` " +"functions to check whether a character can start or continue a `Unicode " +"Standard Annex #31 `_ identifier. " +"(Contributed by Stan Ulbrych in :gh:`129117`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1848 +msgid "" +"Add the :func:`~unicodedata.iter_graphemes` function to iterate over " +"grapheme clusters according to rules defined in `Unicode Standard Annex #29, " +"\"Unicode Text Segmentation\" `_. " +"Add :func:`~unicodedata.grapheme_cluster_break`, :func:`~unicodedata." +"indic_conjunct_break` and :func:`~unicodedata.extended_pictographic` " +"functions to get the properties of the character which are related to the " +"above algorithm. (Contributed by Serhiy Storchaka and Guillaume Sanchez in :" +"gh:`74902`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1858 +msgid "" +"Add :func:`~unicodedata.block` function to return the `Unicode block " +"`_ assigned to a character. (Contributed by Stan Ulbrych in :gh:" +"`66802`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1865 +msgid "unittest" +msgstr "unittest" + +#: ../../whatsnew/3.15.rst:1867 +msgid "" +":meth:`unittest.TestCase.assertLogs` will now accept a formatter to control " +"how messages are formatted. (Contributed by Garry Cairns in :gh:`134567`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1871 +msgid "" +":meth:`unittest.TestCase.assertWarns` and :meth:`unittest.TestCase." +"assertWarnsRegex` no longer swallow warnings that do not match the specified " +"category or regex. Nested context managers are now supported. (Contributed " +"by Serhiy Storchaka in :gh:`143231`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1879 +msgid "urllib.parse" +msgstr "urllib.parse" + +#: ../../whatsnew/3.15.rst:1881 +msgid "" +"Add the *missing_as_none* parameter to :func:`~urllib.parse.urlsplit`, :func:" +"`~urllib.parse.urlparse` and :func:`~urllib.parse.urldefrag` functions. Add " +"the *keep_empty* parameter to :func:`~urllib.parse.urlunsplit` and :func:" +"`~urllib.parse.urlunparse` functions. This allows distinguishing between " +"empty and undefined URI components and preserving empty components. " +"(Contributed by Serhiy Storchaka in :gh:`67041`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1891 +msgid "venv" +msgstr "venv" + +#: ../../whatsnew/3.15.rst:1893 +msgid "" +"On POSIX platforms, platlib directories will be created if needed when " +"creating virtual environments, instead of using a ``lib64 -> lib`` symlink. " +"This means purelib and platlib of virtual environments no longer share the " +"same ``lib`` directory on platforms where :data:`sys.platlibdir` is not " +"equal to ``lib``. (Contributed by Rui Xi in :gh:`133951`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1902 +msgid "warnings" +msgstr "" + +#: ../../whatsnew/3.15.rst:1904 +msgid "" +"Improve filtering by module in :func:`warnings.warn_explicit` if no *module* " +"argument is passed. It now tests the module regular expression in the " +"warnings filter not only against the filename with ``.py`` stripped, but " +"also against module names constructed starting from different parent " +"directories of the filename (with ``/__init__.py``, ``.py`` and, on Windows, " +"``.pyw`` stripped). (Contributed by Serhiy Storchaka in :gh:`135801`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1914 ../../whatsnew/3.15.rst:2274 +msgid "wave" +msgstr "wave" + +#: ../../whatsnew/3.15.rst:1916 +msgid "" +"Added support for IEEE floating-point WAVE audio " +"(``WAVE_FORMAT_IEEE_FLOAT``) in :mod:`wave`." +msgstr "" + +#: ../../whatsnew/3.15.rst:1919 +msgid "" +"Added :meth:`wave.Wave_read.getformat`, :meth:`wave.Wave_write.getformat`, " +"and :meth:`wave.Wave_write.setformat` for explicit frame format handling." +msgstr "" + +#: ../../whatsnew/3.15.rst:1922 +msgid "" +":meth:`wave.Wave_write.setparams` accepts both 7-item tuples including " +"``format`` and 6-item tuples for backwards compatibility (defaulting to " +"``WAVE_FORMAT_PCM``)." +msgstr "" + +#: ../../whatsnew/3.15.rst:1926 +msgid "" +"``WAVE_FORMAT_IEEE_FLOAT`` output now includes a ``fact`` chunk, as required " +"for non-PCM WAVE formats." +msgstr "" + +#: ../../whatsnew/3.15.rst:1929 +msgid "(Contributed by Lionel Koenig and Michiel W. Beijen in :gh:`60729`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1933 +msgid "webbrowser" +msgstr "webbrowser" + +#: ../../whatsnew/3.15.rst:1935 +msgid "" +"On macOS, the new :class:`!webbrowser.MacOS` class opens URLs via :program:`/" +"usr/bin/open` instead of constructing and executing AppleScript via :program:" +"`osascript`. The default browser is detected from the LaunchServices " +"preferences file using :mod:`plistlib`, with :class:`!com.apple.Safari` as " +"the fallback on fresh installations. For non-HTTP(S) URLs, :program:`open -b " +"` is used to route the URL through a browser rather than the OS " +"file handler, preventing file injection attacks. (Contributed by Jeff Lyon " +"in :gh:`137586`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1947 +msgid "xml" +msgstr "xml" + +#: ../../whatsnew/3.15.rst:1949 +msgid "" +"Add the :func:`xml.is_valid_name` function to check whether a string can be " +"used as an element or attribute name in XML. (Contributed by Serhiy " +"Storchaka in :gh:`139489`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1953 +msgid "" +"Add the :func:`xml.is_valid_text` function to check whether a string can be " +"used in an XML document. (Contributed by Serhiy Storchaka in :gh:`139489`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1959 +msgid "xml.parsers.expat" +msgstr "" + +#: ../../whatsnew/3.15.rst:1961 +msgid "" +"Add :meth:`~xml.parsers.expat.xmlparser.SetAllocTrackerActivationThreshold` " +"and :meth:`~xml.parsers.expat.xmlparser.SetAllocTrackerMaximumAmplification` " +"to :ref:`xmlparser ` objects to tune protections against " +"disproportional amounts of dynamic memory usage from within an Expat parser. " +"(Contributed by Bénédikt Tran in :gh:`90949`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1967 +msgid "" +"Add :meth:`~xml.parsers.expat.xmlparser." +"SetBillionLaughsAttackProtectionActivationThreshold` and :meth:`~xml.parsers." +"expat.xmlparser.SetBillionLaughsAttackProtectionMaximumAmplification` to :" +"ref:`xmlparser ` objects to tune protections against " +"`billion laughs`_ attacks. (Contributed by Bénédikt Tran in :gh:`90949`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1977 +msgid "zlib" +msgstr "zlib" + +#: ../../whatsnew/3.15.rst:1979 +msgid "" +"Allow combining two Adler-32 checksums via :func:`~zlib.adler32_combine`. " +"(Contributed by Callum Attryde and Bénédikt Tran in :gh:`134635`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1982 +msgid "" +"Allow combining two CRC-32 checksums via :func:`~zlib.crc32_combine`. " +"(Contributed by Bénédikt Tran in :gh:`134635`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1989 +msgid "Optimizations" +msgstr "最佳化" + +#: ../../whatsnew/3.15.rst:1991 +msgid "" +"``mimalloc`` is now used as the default allocator for raw memory allocations " +"such as via :c:func:`PyMem_RawMalloc` for better performance on :term:`free-" +"threaded builds `. (Contributed by Kumar Aditya in :gh:" +"`144914`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:1998 +msgid "base64 & binascii" +msgstr "" + +#: ../../whatsnew/3.15.rst:2000 +msgid "" +"CPython's underlying base64 implementation now encodes 2x faster and decodes " +"3x faster thanks to simple CPU pipelining optimizations. (Contributed by " +"Gregory P. Smith and Serhiy Storchaka in :gh:`143262`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2004 +msgid "" +"Implementation for Ascii85, Base85, and Z85 encoding has been rewritten in " +"C. Encoding and decoding is now two orders of magnitude faster and consumes " +"two orders of magnitude less memory. (Contributed by James Seo and Serhiy " +"Storchaka in :gh:`101178`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2009 +msgid "" +"Implementation for Base32 has been rewritten in C. Encoding and decoding is " +"now two orders of magnitude faster. (Contributed by James Seo in :gh:" +"`146192`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2015 +msgid "csv" +msgstr "csv" + +#: ../../whatsnew/3.15.rst:2017 +msgid "" +":meth:`csv.Sniffer.sniff` delimiter detection is now up to 1.6x faster. " +"(Contributed by Maurycy Pawłowski-Wieroński in :gh:`137628`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2024 +msgid "Upgraded experimental JIT compiler" +msgstr "" + +#: ../../whatsnew/3.15.rst:2026 +msgid "" +"Results from the `pyperformance `__ " +"benchmark suite report a `7-8% `__ geometric mean performance improvement for the JIT over " +"the standard CPython interpreter built with all optimizations enabled on " +"x86-64 Linux. On AArch64 macOS, the JIT has an `11-12% `__ speedup over the :ref:`tail calling " +"interpreter ` with all optimizations " +"enabled. The speedups for JIT builds versus no JIT builds range from roughly " +"15% slowdown to over 100% speedup (ignoring the ``unpack_sequence`` " +"microbenchmark) on x86-64 Linux and AArch64 macOS systems." +msgstr "" + +#: ../../whatsnew/3.15.rst:2039 +msgid "The major upgrades to the JIT are:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2041 ../../whatsnew/3.15.rst:2049 +msgid "LLVM 21 build-time dependency" +msgstr "" + +#: ../../whatsnew/3.15.rst:2042 +msgid "New tracing frontend" +msgstr "" + +#: ../../whatsnew/3.15.rst:2043 ../../whatsnew/3.15.rst:2071 +msgid "Basic register allocation in the JIT" +msgstr "" + +#: ../../whatsnew/3.15.rst:2044 ../../whatsnew/3.15.rst:2079 +msgid "More JIT optimizations" +msgstr "" + +#: ../../whatsnew/3.15.rst:2045 ../../whatsnew/3.15.rst:2098 +msgid "GDB and GNU ``backtrace()`` unwinding support" +msgstr "" + +#: ../../whatsnew/3.15.rst:2046 ../../whatsnew/3.15.rst:2109 +msgid "Better machine code generation" +msgstr "" + +#: ../../whatsnew/3.15.rst:2050 +msgid "" +"The JIT compiler now uses LLVM 21 for build-time stencil generation. As " +"always, LLVM is only needed when building CPython with the JIT enabled; end " +"users running Python do not need LLVM installed. Instructions for installing " +"LLVM can be found in the `JIT compiler documentation `__ for all supported " +"platforms. (Contributed by Savannah Ostrowski in :gh:`140973`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2059 +msgid "A new tracing frontend" +msgstr "" + +#: ../../whatsnew/3.15.rst:2060 +msgid "" +"The JIT compiler now supports significantly more bytecode operations and " +"control flow than in Python 3.14, enabling speedups on a wider variety of " +"code. For example, simple Python object creation is now understood by the " +"3.15 JIT compiler. Overloaded operations and generators are also partially " +"supported. This was made possible by an overhauled JIT tracing frontend that " +"records actual execution paths through code, rather than estimating them as " +"the previous implementation did. (Contributed by Ken Jin in :gh:`139109`. " +"Support for Windows added by Mark Shannon in :gh:`141703`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2072 +msgid "" +"A basic form of register allocation has been added to the JIT compiler's " +"optimizer. This allows the JIT compiler to avoid certain stack operations " +"altogether and instead operate on registers. This allows the JIT to produce " +"more efficient traces by avoiding reads and writes to memory. (Contributed " +"by Mark Shannon in :gh:`135379`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2080 +msgid "" +"More `constant-propagation `__ is now performed. This means when the JIT compiler " +"detects that certain user code results in constants, the code can be " +"simplified by the JIT. (Contributed by Ken Jin and Savannah Ostrowski in :gh:" +"`132732`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2085 +msgid "" +":term:`Reference counts ` are avoided whenever it is safe " +"to do so. This generally reduces the cost of most operations in Python. " +"(Contributed by Ken Jin, Donghee Na, Zheao Li, Hai Zhu, Savannah Ostrowski, " +"Reiden Ong, Noam Cohen, Tomas Roun, PuQing, Cajetan Rodrigues, and Sacul in :" +"gh:`134584`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2090 +msgid "" +"By tracking unique references to objects, the JIT optimizer can now " +"eliminate reference count updates and perform in-place operations on ints " +"and floats. (Contributed by Reiden Ong, and Pieter Eendebak in :gh:`143414` " +"and :gh:`146306`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2094 +msgid "" +"The JIT optimizer now supports significantly more operations than in 3.14. " +"(Contributed by Kumar Aditya, Ken Jin, Jiahao Li, and Sacul in :gh:`131798`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2099 +msgid "" +"The JIT compiler now publishes unwind information for generated machine code " +"to the GDB interface on supported Linux ELF platforms. When libgcc frame " +"registration is available, the same unwind information is also registered " +"for GNU ``backtrace()`` stack walkers. This allows native debuggers, crash " +"handlers, and diagnostic tools using these mechanisms to unwind through JIT " +"frames instead of stopping at generated code. (Contributed by Diego Russo " +"and Pablo Galindo Salgado in :gh:`146071` and :gh:`149104`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2110 +msgid "" +"The JIT compiler's machine code generator now produces better machine code " +"for x86-64 and AArch64 macOS and Linux targets. In general, users should " +"experience lower memory usage for generated machine code and more efficient " +"machine code versus 3.14. (Contributed by Brandt Bucher in :gh:`136528` and :" +"gh:`135905`. Implementation for AArch64 contributed by Mark Shannon in :gh:" +"`139855`. Additional optimizations for AArch64 contributed by Mark Shannon " +"and Diego Russo in :gh:`140683` and :gh:`142305`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2120 +msgid "Maintainability" +msgstr "" + +#: ../../whatsnew/3.15.rst:2121 +msgid "" +"The JIT optimizer's operations have been simplified. This was made possible " +"by a refactoring of JIT data structures. (Contributed by Zhongtian Zheng in :" +"gh:`148211` and Hai Zhu in :gh:`143421`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2127 +msgid "Removed" +msgstr "" + +#: ../../whatsnew/3.15.rst:2132 +msgid "" +"The constructors of :ref:`AST nodes ` now raise a :exc:" +"`TypeError` when a required argument is omitted or when a keyword argument " +"that does not map to a field on the AST node is passed. These cases had " +"previously raised a :exc:`DeprecationWarning` since Python 3.13. " +"(Contributed by Brian Schubert and Jelle Zijlstra in :gh:`137600` and :gh:" +"`105858`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2140 +msgid "collections.abc" +msgstr "collections.abc" + +#: ../../whatsnew/3.15.rst:2142 +msgid "" +":class:`collections.abc.ByteString` has been removed from ``collections.abc." +"__all__``. :class:`!collections.abc.ByteString` has been deprecated since " +"Python 3.12, and is scheduled for removal in Python 3.17. (Contributed by " +"Alex Waygood in :gh:`118803`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2151 +msgid "" +"Removed the undocumented function :func:`!ctypes.SetPointerType`, which has " +"been deprecated since Python 3.13. (Contributed by Bénédikt Tran in :gh:" +"`133866`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2157 +msgid "datetime" +msgstr "datetime" + +#: ../../whatsnew/3.15.rst:2159 +msgid "" +":meth:`~datetime.datetime.strptime` now raises :exc:`ValueError` when the " +"format string contains ``%d`` (day of month) without a year directive. This " +"has been deprecated since Python 3.13. (Contributed by Stan Ulbrych and " +"Gregory P. Smith in :gh:`70647`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2166 +msgid "glob" +msgstr "glob" + +#: ../../whatsnew/3.15.rst:2168 +msgid "" +"Removed the undocumented :func:`!glob.glob0` and :func:`!glob.glob1` " +"functions, which have been deprecated since Python 3.13. Use :func:`glob." +"glob` and pass a directory to its *root_dir* argument instead. (Contributed " +"by Barney Gale in :gh:`137466`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2177 +msgid "" +"Removed the :class:`!CGIHTTPRequestHandler` class and the ``--cgi`` flag " +"from the :program:`python -m http.server` command-line interface. They were " +"deprecated in Python 3.13. (Contributed by Bénédikt Tran in :gh:`133810`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2184 +msgid "importlib" +msgstr "importlib" + +#: ../../whatsnew/3.15.rst:2186 +msgid "" +"The ``load_module()`` methods of :class:`~importlib.abc.Loader` and its " +"subclasses is removed. The import system will no longer call it when defined " +"on custom subclasses. The method has been deprecated in favor of :meth:" +"`~importlib.abc.Loader.exec_module` since Python 3.4. (Contributed by Brett " +"Cannon in :gh:`97850`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2195 +msgid "importlib.resources" +msgstr "importlib.resources" + +#: ../../whatsnew/3.15.rst:2197 +msgid "" +"Removed deprecated ``package`` parameter from :func:`importlib.resources." +"files` function. (Contributed by Semyon Moroz in :gh:`138044`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2205 +msgid "" +"Removed deprecated :meth:`!pathlib.PurePath.is_reserved`. Use :func:`os.path." +"isreserved` to detect reserved paths on Windows. (Contributed by Nikita " +"Sobolev in :gh:`133875`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2211 +msgid "platform" +msgstr "platform" + +#: ../../whatsnew/3.15.rst:2213 +msgid "" +"Removed the :func:`!platform.java_ver` function, which was deprecated since " +"Python 3.13. (Contributed by Alexey Makridenko in :gh:`133604`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2219 +msgid "sre_*" +msgstr "" + +#: ../../whatsnew/3.15.rst:2221 +msgid "" +"Removed :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` " +"modules. (Contributed by Stan Ulbrych in :gh:`135994`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2226 +msgid "sysconfig" +msgstr "sysconfig" + +#: ../../whatsnew/3.15.rst:2228 +msgid "" +"Removed the *check_home* parameter of :func:`sysconfig.is_python_build`. " +"(Contributed by Filipe Laíns in :gh:`92897`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2235 +msgid "" +"Remove support for arbitrary positional or keyword arguments in the C " +"implementation of :class:`~threading.RLock` objects. This was deprecated in " +"Python 3.14. (Contributed by Bénédikt Tran in :gh:`134087`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2244 +msgid "" +"Removed :attr:`!codeobject.co_lnotab` from :class:`types.CodeType`, " +"deprecated since Python 3.12 by :pep:`626`. (Contributed by Nikita Sobolev " +"in :gh:`134690`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2252 +msgid "" +":class:`typing.ByteString` has been removed from ``typing.__all__``. :class:" +"`!typing.ByteString` has been deprecated since Python 3.9, and is scheduled " +"for removal in Python 3.17. (Contributed by Alex Waygood in :gh:`118803`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2257 +msgid "" +"The undocumented keyword argument syntax for creating :class:`~typing." +"NamedTuple` classes (for example, ``Point = NamedTuple(\"Point\", x=int, " +"y=int)``) is no longer supported. Use the class-based syntax or the " +"functional syntax instead. (Contributed by Bénédikt Tran in :gh:`133817`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2263 +msgid "" +"Using ``TD = TypedDict(\"TD\")`` or ``TD = TypedDict(\"TD\", None)`` to " +"construct a :class:`~typing.TypedDict` type with zero fields is no longer " +"supported. Use ``class TD(TypedDict): pass`` or ``TD = TypedDict(\"TD\", " +"{})`` instead. (Contributed by Bénédikt Tran in :gh:`133823`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2269 +msgid "" +"Deprecated :deco:`!typing.no_type_check_decorator` has been removed. " +"(Contributed by Nikita Sobolev in :gh:`133601`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2276 +msgid "" +"Removed the ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of " +"the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes, which " +"were deprecated since Python 3.13. (Contributed by Bénédikt Tran in :gh:" +"`133873`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2283 +msgid "zipimport" +msgstr "zipimport" + +#: ../../whatsnew/3.15.rst:2285 +msgid "" +"Remove deprecated :meth:`!zipimport.zipimporter.load_module`. Use :meth:" +"`zipimport.zipimporter.exec_module` instead. (Contributed by Jiahao Li in :" +"gh:`133656`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2291 +msgid "Deprecated" +msgstr "已棄用" + +#: ../../whatsnew/3.15.rst:2294 +msgid "New deprecations" +msgstr "" + +#: ../../whatsnew/3.15.rst:2296 +#: ../../deprecations/pending-removal-in-3.20.rst:52 +msgid ":mod:`ast`:" +msgstr ":mod:`ast`:" + +#: ../../whatsnew/3.15.rst:2298 +#: ../../deprecations/pending-removal-in-3.20.rst:54 +msgid "" +"Creating instances of abstract AST nodes (such as :class:`ast.AST` or :class:" +"`!ast.expr`) is deprecated and will raise an error in Python 3.20." +msgstr "" + +#: ../../whatsnew/3.15.rst:2301 +msgid "(Contributed by Brian Schubert in :gh:`116021`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2303 +msgid ":mod:`base64`:" +msgstr ":mod:`base64`:" + +#: ../../whatsnew/3.15.rst:2305 +msgid "" +"Accepting the ``+`` and ``/`` characters with an alternative alphabet in :" +"func:`~base64.b64decode` and :func:`~base64.urlsafe_b64decode` is now " +"deprecated. In future Python versions they will be errors in the strict mode " +"and discarded in the non-strict mode. (Contributed by Serhiy Storchaka in :" +"gh:`125346`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2312 +msgid "CLI:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2314 +msgid "" +"Deprecate :option:`-b` and :option:`!-bb` command-line options and schedule " +"them to become no-ops in Python 3.17. These were primarily helpers for the " +"Python 2 -> 3 transition. Starting with Python 3.17, no :exc:`BytesWarning` " +"will be raised for these cases; use a type checker instead." +msgstr "" + +#: ../../whatsnew/3.15.rst:2320 +msgid "(Contributed by Nikita Sobolev in :gh:`136355`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2322 +#: ../../deprecations/pending-removal-in-3.17.rst:12 +msgid ":mod:`collections.abc`:" +msgstr ":mod:`collections.abc`:" + +#: ../../whatsnew/3.15.rst:2324 ../../whatsnew/3.15.rst:2415 +msgid "" +"The following statements now cause ``DeprecationWarning``\\ s to be emitted " +"at runtime:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2327 +msgid "``from collections.abc import ByteString``" +msgstr "``from collections.abc import ByteString``" + +#: ../../whatsnew/3.15.rst:2328 +msgid "``import collections.abc; collections.abc.ByteString``." +msgstr "``import collections.abc; collections.abc.ByteString``." + +#: ../../whatsnew/3.15.rst:2330 +msgid "" +"``DeprecationWarning``\\ s were already emitted if :class:`collections.abc." +"ByteString` was subclassed or used as the second argument to :func:" +"`isinstance` or :func:`issubclass`, but warnings were not previously emitted " +"if it was merely imported or accessed from the :mod:`!collections.abc` " +"module. (Contributed by Alex Waygood in :gh:`118803`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2338 +#: ../../deprecations/pending-removal-in-3.19.rst:10 +msgid ":mod:`hashlib`:" +msgstr ":mod:`hashlib`:" + +#: ../../whatsnew/3.15.rst:2340 +msgid "" +"In hash function constructors such as :func:`~hashlib.new` or the direct " +"hash-named constructors such as :func:`~hashlib.md5` and :func:`~hashlib." +"sha256`, the optional initial data parameter could also be passed as a " +"keyword argument named ``data=`` or ``string=`` in various :mod:`hashlib` " +"implementations." +msgstr "" + +#: ../../whatsnew/3.15.rst:2346 +msgid "" +"Support for the ``string`` keyword argument name is now deprecated and is " +"slated for removal in Python 3.19. Prefer passing the initial data as a " +"positional argument for maximum backwards compatibility." +msgstr "" + +#: ../../whatsnew/3.15.rst:2350 +msgid "(Contributed by Bénédikt Tran in :gh:`134978`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2353 +#: ../../deprecations/pending-removal-in-3.19.rst:26 +msgid ":mod:`http.cookies`:" +msgstr ":mod:`http.cookies`:" + +#: ../../whatsnew/3.15.rst:2355 +msgid "" +":meth:`Morsel.js_output ` and :meth:" +"`BaseCookie.js_output ` are deprecated " +"and will be removed in Python 3.19. Use :meth:`Morsel.output ` or :meth:`BaseCookie.output ` instead. (Contributed by kishorhange111 in :gh:`148849`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2363 +#: ../../deprecations/pending-removal-in-3.19.rst:34 +msgid ":mod:`imaplib`:" +msgstr ":mod:`imaplib`:" + +#: ../../whatsnew/3.15.rst:2365 +msgid "" +"Altering :attr:`IMAP4.file ` is now deprecated and " +"slated for removal in Python 3.19. This property is now unused and changing " +"its value does *not* explicitly close the current file. (Contributed by " +"Bénédikt Tran in :gh:`142307`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2371 +#: ../../deprecations/pending-removal-in-3.17.rst:40 +msgid ":mod:`profile`:" +msgstr ":mod:`profile`:" + +#: ../../whatsnew/3.15.rst:2373 +#: ../../deprecations/pending-removal-in-3.17.rst:42 +msgid "" +"The :mod:`!profile` module is deprecated and will be removed in Python 3.17. " +"Use :mod:`profiling.tracing` instead, which provides a compatible API. See :" +"pep:`799` for details. (Contributed by Pablo Galindo and László Kiss Kollár " +"in :gh:`138122`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2379 +msgid ":mod:`re`:" +msgstr ":mod:`re`:" + +#: ../../whatsnew/3.15.rst:2381 ../../deprecations/soft-deprecations.rst:6 +msgid "" +":func:`re.match` and :meth:`re.Pattern.match` are now :term:`soft " +"deprecated` in favor of the new :func:`re.prefixmatch` and :meth:`re.Pattern." +"prefixmatch` APIs, which have been added as alternate, more explicit names. " +"These are intended to be used to alleviate confusion around what *match* " +"means by following the Zen of Python's *\"Explicit is better than " +"implicit\"* mantra. Most other language regular expression libraries use an " +"API named *match* to mean what Python has always called *search*." +msgstr "" + +#: ../../whatsnew/3.15.rst:2390 ../../deprecations/soft-deprecations.rst:15 +msgid "" +"We **do not** plan to remove the older :func:`!match` name, as it has been " +"used in code for over 30 years. Code supporting older versions of Python " +"should continue to use :func:`!match`, while new code should prefer :func:`!" +"prefixmatch`. See :ref:`prefixmatch-vs-match`." +msgstr "" + +#: ../../whatsnew/3.15.rst:2395 ../../deprecations/soft-deprecations.rst:20 +msgid "" +"(Contributed by Gregory P. Smith in :gh:`86519` and Hugo van Kemenade in :gh:" +"`148100`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2399 +msgid ":mod:`struct`:" +msgstr ":mod:`struct`:" + +#: ../../whatsnew/3.15.rst:2401 +msgid "" +"Calling ``Struct.__new__()`` without a required argument is now deprecated " +"and will be removed in Python 3.20. Calling the :meth:`~object.__init__` " +"method on an initialized :class:`~struct.Struct` object is deprecated and " +"will be removed in Python 3.20." +msgstr "" + +#: ../../whatsnew/3.15.rst:2406 +#: ../../deprecations/pending-removal-in-3.20.rst:9 +msgid "" +"(Contributed by Sergey B Kirpichev and Serhiy Storchaka in :gh:`143715`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2408 +msgid "" +"The ``'F'`` and ``'D'`` type codes are now :term:`soft deprecated` in favor " +"of the two-letter forms ``'Zf'`` and ``'Zd'``. (Contributed by Sergey B " +"Kirpichev in :gh:`121249`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2413 +#: ../../deprecations/pending-removal-in-3.17.rst:52 +#: ../../deprecations/pending-removal-in-3.20.rst:57 +msgid ":mod:`typing`:" +msgstr ":mod:`typing`:" + +#: ../../whatsnew/3.15.rst:2418 +msgid "``from typing import ByteString``" +msgstr "``from typing import ByteString``" + +#: ../../whatsnew/3.15.rst:2419 +msgid "``import typing; typing.ByteString``." +msgstr "``import typing; typing.ByteString``." + +#: ../../whatsnew/3.15.rst:2421 +msgid "" +"``DeprecationWarning``\\ s were already emitted if :class:`typing." +"ByteString` was subclassed or used as the second argument to :func:" +"`isinstance` or :func:`issubclass`, but warnings were not previously emitted " +"if it was merely imported or accessed from the :mod:`!typing` module. " +"(Contributed by Alex Waygood in :gh:`118803`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2427 +#: ../../deprecations/pending-removal-in-3.20.rst:59 +msgid "" +"It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on " +"protocol classes that were not explicitly decorated with :func:`!" +"runtime_checkable` but that inherit from a runtime-checkable protocol class. " +"This will raise a :exc:`TypeError` in Python 3.20." +msgstr "" + +#: ../../whatsnew/3.15.rst:2432 +#: ../../deprecations/pending-removal-in-3.20.rst:64 +msgid "(Contributed by Bartosz Sławecki in :gh:`132604`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2435 +#: ../../deprecations/pending-removal-in-3.17.rst:47 +msgid ":mod:`webbrowser`:" +msgstr ":mod:`webbrowser`:" + +#: ../../whatsnew/3.15.rst:2437 +msgid "" +":class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of :class:`!" +"webbrowser.MacOS` and scheduled for removal in Python 3.17. (Contributed by " +"Jeff Lyon in :gh:`137586`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2441 +msgid "``__version__``:" +msgstr "``__version__``:" + +#: ../../whatsnew/3.15.rst:2443 +#: ../../deprecations/pending-removal-in-3.20.rst:11 +msgid "" +"The ``__version__``, ``version`` and ``VERSION`` attributes have been " +"deprecated in these standard library modules and will be removed in Python " +"3.20. Use :py:data:`sys.version_info` instead." +msgstr "" + +#: ../../whatsnew/3.15.rst:2447 +#: ../../deprecations/pending-removal-in-3.20.rst:15 +msgid ":mod:`argparse`" +msgstr ":mod:`argparse`" + +#: ../../whatsnew/3.15.rst:2448 +#: ../../deprecations/pending-removal-in-3.20.rst:16 +msgid ":mod:`csv`" +msgstr ":mod:`csv`" + +#: ../../whatsnew/3.15.rst:2449 +#: ../../deprecations/pending-removal-in-3.20.rst:17 +msgid ":mod:`ctypes`" +msgstr ":mod:`ctypes`" + +#: ../../whatsnew/3.15.rst:2450 +#: ../../deprecations/pending-removal-in-3.20.rst:18 +msgid ":mod:`!ctypes.macholib`" +msgstr ":mod:`!ctypes.macholib`" + +#: ../../whatsnew/3.15.rst:2451 +#: ../../deprecations/pending-removal-in-3.20.rst:19 +msgid ":mod:`decimal` (use :data:`decimal.SPEC_VERSION` instead)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2452 +#: ../../deprecations/pending-removal-in-3.20.rst:20 +msgid ":mod:`http.server`" +msgstr ":mod:`http.server`" + +#: ../../whatsnew/3.15.rst:2453 +#: ../../deprecations/pending-removal-in-3.20.rst:21 +msgid ":mod:`imaplib`" +msgstr ":mod:`imaplib`" + +#: ../../whatsnew/3.15.rst:2454 +#: ../../deprecations/pending-removal-in-3.20.rst:22 +msgid ":mod:`ipaddress`" +msgstr ":mod:`ipaddress`" + +#: ../../whatsnew/3.15.rst:2455 +#: ../../deprecations/pending-removal-in-3.20.rst:23 +msgid ":mod:`json`" +msgstr ":mod:`json`" + +#: ../../whatsnew/3.15.rst:2456 +#: ../../deprecations/pending-removal-in-3.20.rst:24 +msgid ":mod:`logging` (``__date__`` also deprecated)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2457 +#: ../../deprecations/pending-removal-in-3.20.rst:25 +msgid ":mod:`optparse`" +msgstr ":mod:`optparse`" + +#: ../../whatsnew/3.15.rst:2458 +#: ../../deprecations/pending-removal-in-3.20.rst:26 +msgid ":mod:`pickle`" +msgstr ":mod:`pickle`" + +#: ../../whatsnew/3.15.rst:2459 +#: ../../deprecations/pending-removal-in-3.20.rst:27 +msgid ":mod:`platform`" +msgstr ":mod:`platform`" + +#: ../../whatsnew/3.15.rst:2460 +#: ../../deprecations/pending-removal-in-3.20.rst:28 +msgid ":mod:`re`" +msgstr ":mod:`re`" + +#: ../../whatsnew/3.15.rst:2461 +#: ../../deprecations/pending-removal-in-3.20.rst:29 +msgid ":mod:`socketserver`" +msgstr ":mod:`socketserver`" + +#: ../../whatsnew/3.15.rst:2462 +#: ../../deprecations/pending-removal-in-3.20.rst:30 +msgid ":mod:`tabnanny`" +msgstr ":mod:`tabnanny`" + +#: ../../whatsnew/3.15.rst:2463 +#: ../../deprecations/pending-removal-in-3.20.rst:31 +msgid ":mod:`tarfile`" +msgstr ":mod:`tarfile`" + +#: ../../whatsnew/3.15.rst:2464 +#: ../../deprecations/pending-removal-in-3.20.rst:32 +msgid ":mod:`tkinter.font`" +msgstr ":mod:`tkinter.font`" + +#: ../../whatsnew/3.15.rst:2465 +#: ../../deprecations/pending-removal-in-3.20.rst:33 +msgid ":mod:`tkinter.ttk`" +msgstr ":mod:`tkinter.ttk`" + +#: ../../whatsnew/3.15.rst:2466 +#: ../../deprecations/pending-removal-in-3.20.rst:34 +msgid ":mod:`wsgiref.simple_server`" +msgstr ":mod:`wsgiref.simple_server`" + +#: ../../whatsnew/3.15.rst:2467 +#: ../../deprecations/pending-removal-in-3.20.rst:35 +msgid ":mod:`xml.etree.ElementTree`" +msgstr ":mod:`xml.etree.ElementTree`" + +#: ../../whatsnew/3.15.rst:2468 +#: ../../deprecations/pending-removal-in-3.20.rst:36 +msgid ":mod:`!xml.sax.expatreader`" +msgstr ":mod:`!xml.sax.expatreader`" + +#: ../../whatsnew/3.15.rst:2469 +#: ../../deprecations/pending-removal-in-3.20.rst:37 +msgid ":mod:`xml.sax.handler`" +msgstr ":mod:`xml.sax.handler`" + +#: ../../whatsnew/3.15.rst:2470 +#: ../../deprecations/pending-removal-in-3.20.rst:38 +msgid ":mod:`zlib`" +msgstr ":mod:`zlib`" + +#: ../../whatsnew/3.15.rst:2472 +#: ../../deprecations/pending-removal-in-3.20.rst:40 +msgid "(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:2 +msgid "Pending removal in Python 3.16" +msgstr "Python 3.16 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.16.rst:4 +msgid "The import system:" +msgstr "引入系統 (import system):" + +#: ../../deprecations/pending-removal-in-3.16.rst:6 +msgid "" +"Setting :attr:`~module.__loader__` on a module while failing to set :attr:" +"`__spec__.loader ` is deprecated. In " +"Python 3.16, :attr:`!__loader__` will cease to be set or taken into " +"consideration by the import system or the standard library." +msgstr "" +"在模組上設定 :attr:`~module.__loader__` 而沒有設定 :attr:`__spec__.loader " +"` 的做法已被棄用。在 Python 3.16 中," +"引入系統或標準函式庫將不再設定或考慮 :attr:`!__loader__`。" + +#: ../../deprecations/pending-removal-in-3.16.rst:11 +msgid ":mod:`array`:" +msgstr ":mod:`array`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:13 +msgid "" +"The ``'u'`` format code (:c:type:`wchar_t`) has been deprecated in " +"documentation since Python 3.3 and at runtime since Python 3.13. Use the " +"``'w'`` format code (:c:type:`Py_UCS4`) for Unicode characters instead." +msgstr "" +"自 Python 3.3 起,``'u'`` 格式碼 (:c:type:`wchar_t`) 在文件中已被棄用,自 " +"Python 3.13 起在 runtime 已被棄用。對於 Unicode 字元請改用 ``'w'`` 格式碼 " +"(:c:type:`Py_UCS4`)。" + +#: ../../deprecations/pending-removal-in-3.16.rst:19 +msgid ":mod:`asyncio`:" +msgstr ":mod:`asyncio`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:21 +msgid "" +":func:`!asyncio.iscoroutinefunction` is deprecated and will be removed in " +"Python 3.16; use :func:`inspect.iscoroutinefunction` instead. (Contributed " +"by Jiahao Li and Kumar Aditya in :gh:`122875`.)" +msgstr "" +":func:`!asyncio.iscoroutinefunction` 已被棄用並將在 Python 3.16 中移除;請改" +"用 :func:`inspect.iscoroutinefunction`。(由 Jiahao Li 和 Kumar Aditya " +"於 :gh:`122875` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.16.rst:26 +msgid "" +":mod:`asyncio` policy system is deprecated and will be removed in Python " +"3.16. In particular, the following classes and functions are deprecated:" +msgstr "" +":mod:`asyncio` 策略系統已被棄用並將在 Python 3.16 中移除。特別是以下類別和函" +"式已被棄用:" + +#: ../../deprecations/pending-removal-in-3.16.rst:29 +msgid ":class:`asyncio.AbstractEventLoopPolicy`" +msgstr ":class:`asyncio.AbstractEventLoopPolicy`" + +#: ../../deprecations/pending-removal-in-3.16.rst:30 +msgid ":class:`asyncio.DefaultEventLoopPolicy`" +msgstr ":class:`asyncio.DefaultEventLoopPolicy`" + +#: ../../deprecations/pending-removal-in-3.16.rst:31 +msgid ":class:`asyncio.WindowsSelectorEventLoopPolicy`" +msgstr ":class:`asyncio.WindowsSelectorEventLoopPolicy`" + +#: ../../deprecations/pending-removal-in-3.16.rst:32 +msgid ":class:`asyncio.WindowsProactorEventLoopPolicy`" +msgstr ":class:`asyncio.WindowsProactorEventLoopPolicy`" + +#: ../../deprecations/pending-removal-in-3.16.rst:33 +msgid ":func:`asyncio.get_event_loop_policy`" +msgstr ":func:`asyncio.get_event_loop_policy`" + +#: ../../deprecations/pending-removal-in-3.16.rst:34 +msgid ":func:`asyncio.set_event_loop_policy`" +msgstr ":func:`asyncio.set_event_loop_policy`" + +#: ../../deprecations/pending-removal-in-3.16.rst:36 +msgid "" +"Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with " +"*loop_factory* to use the desired event loop implementation." +msgstr "" +"使用者應該使用 :func:`asyncio.run` 或 :class:`asyncio.Runner` 搭配 " +"*loop_factory* 來使用所需的事件迴圈實作。" + +#: ../../deprecations/pending-removal-in-3.16.rst:39 +msgid "For example, to use :class:`asyncio.SelectorEventLoop` on Windows::" +msgstr "例如在 Windows 上使用 :class:`asyncio.SelectorEventLoop`: ::" + +#: ../../deprecations/pending-removal-in-3.16.rst:41 +msgid "" +"import asyncio\n" +"\n" +"async def main():\n" +" ...\n" +"\n" +"asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)" +msgstr "" +"import asyncio\n" +"\n" +"async def main():\n" +" ...\n" +"\n" +"asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)" + +#: ../../deprecations/pending-removal-in-3.16.rst:48 +msgid "(Contributed by Kumar Aditya in :gh:`127949`.)" +msgstr "(由 Kumar Aditya 於 :gh:`127949` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.16.rst:50 +#: ../../deprecations/pending-removal-in-future.rst:16 +msgid ":mod:`builtins`:" +msgstr ":mod:`builtins`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:52 +msgid "" +"Bitwise inversion on boolean types, ``~True`` or ``~False`` has been " +"deprecated since Python 3.12, as it produces surprising and unintuitive " +"results (``-2`` and ``-1``). Use ``not x`` instead for the logical negation " +"of a Boolean. In the rare case that you need the bitwise inversion of the " +"underlying integer, convert to ``int`` explicitly (``~int(x)``)." +msgstr "" +"自 Python 3.12 起,布林型別的位元反轉 ``~True`` 或 ``~False`` 已被棄用,因為" +"它會產生不預期且不直觀的結果(``-2`` 和 ``-1``)。使用 ``not x`` 代替布林值的" +"邏輯否定。在極少數情況下,你需要對底層的整數進行位元反轉,請明確轉換為 " +"``int``\\ (``~int(x)``)。" + +#: ../../deprecations/pending-removal-in-3.16.rst:59 +msgid ":mod:`functools`:" +msgstr ":mod:`functools`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:61 +msgid "" +"Calling the Python implementation of :func:`functools.reduce` with " +"*function* or *sequence* as keyword arguments has been deprecated since " +"Python 3.14." +msgstr "" +"自 Python 3.14 起,使用 *function* 或 *sequence* 關鍵字引數呼" +"叫 :func:`functools.reduce` 的 Python 實作已被棄用。" + +#: ../../deprecations/pending-removal-in-3.16.rst:64 +msgid ":mod:`logging`:" +msgstr ":mod:`logging`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:66 +msgid "" +"Support for custom logging handlers with the *strm* argument is deprecated " +"and scheduled for removal in Python 3.16. Define handlers with the *stream* " +"argument instead. (Contributed by Mariusz Felisiak in :gh:`115032`.)" +msgstr "" +"對具有 *strm* 引數的自訂日誌記錄處理函式的支援已被棄用,並計劃在 Python 3.16 " +"中移除。請改用 *stream* 引數。(由 Mariusz Felisiak 於 :gh:`115032` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.16.rst:70 +msgid ":mod:`mimetypes`:" +msgstr ":mod:`mimetypes`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:72 +msgid "" +"Valid extensions start with a '.' or are empty for :meth:`mimetypes." +"MimeTypes.add_type`. Undotted extensions are deprecated and will raise a :" +"exc:`ValueError` in Python 3.16. (Contributed by Hugo van Kemenade in :gh:" +"`75223`.)" +msgstr "" +"有效的副檔名以 '.' 開頭或對 :meth:`mimetypes.MimeTypes.add_type` 為空字串。未" +"加點的副檔名已被棄用,並將在 Python 3.16 中引發 :exc:`ValueError`。(由 Hugo " +"van Kemenade 於 :gh:`75223` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.16.rst:78 +msgid ":mod:`shutil`:" +msgstr ":mod:`shutil`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:80 +msgid "" +"The :class:`!ExecError` exception has been deprecated since Python 3.14. It " +"has not been used by any function in :mod:`!shutil` since Python 3.4, and is " +"now an alias of :exc:`RuntimeError`." +msgstr "" +"自 Python 3.14 起,:class:`!ExecError` 例外已被棄用。自 Python 3.4 以來,它已" +"不再被 :mod:`!shutil` 中的任何函式使用,現在是 :exc:`RuntimeError` 的別名。" + +#: ../../deprecations/pending-removal-in-3.16.rst:85 +msgid ":mod:`symtable`:" +msgstr ":mod:`symtable`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:87 +msgid "" +"The :meth:`Class.get_methods ` method has been " +"deprecated since Python 3.14." +msgstr "" +"自 Python 3.14 起,:meth:`Class.get_methods ` 方" +"法已被棄用。" + +#: ../../deprecations/pending-removal-in-3.16.rst:90 +msgid ":mod:`sys`:" +msgstr ":mod:`sys`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:92 +msgid "" +"The :func:`~sys._enablelegacywindowsfsencoding` function has been deprecated " +"since Python 3.13. Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " +"environment variable instead." +msgstr "" +"自 Python 3.13 起,:func:`~sys._enablelegacywindowsfsencoding` 函式已被棄用。" +"請改用 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` 環境變數。" + +#: ../../deprecations/pending-removal-in-3.16.rst:96 +msgid ":mod:`sysconfig`:" +msgstr ":mod:`sysconfig`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:98 +msgid "" +"The :func:`!sysconfig.expand_makefile_vars` function has been deprecated " +"since Python 3.14. Use the ``vars`` argument of :func:`sysconfig.get_paths` " +"instead." +msgstr "" +"自 Python 3.14 起,:func:`!sysconfig.expand_makefile_vars` 函式已被棄用。請改" +"用 :func:`sysconfig.get_paths` 的 ``vars`` 引數。" + +#: ../../deprecations/pending-removal-in-3.16.rst:102 +msgid ":mod:`tarfile`:" +msgstr ":mod:`tarfile`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:104 +msgid "" +"The undocumented and unused :attr:`!TarFile.tarfile` attribute has been " +"deprecated since Python 3.13." +msgstr "" +"自 Python 3.13 起,未以文件記錄和未被使用的 :attr:`!TarFile.tarfile` 屬性已被" +"棄用。" + +#: ../../deprecations/pending-removal-in-3.17.rst:2 +msgid "Pending removal in Python 3.17" +msgstr "Python 3.17 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.17.rst:4 +#: ../../deprecations/pending-removal-in-future.rst:53 +msgid ":mod:`datetime`:" +msgstr ":mod:`datetime`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:6 +msgid "" +":meth:`~datetime.datetime.strptime` calls using a format string containing " +"``%e`` (day of month) without a year. This has been deprecated since Python " +"3.15. (Contributed by Stan Ulbrych in :gh:`70647`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:14 +msgid "" +":class:`collections.abc.ByteString` is scheduled for removal in Python 3.17." +msgstr ":class:`collections.abc.ByteString` 預計在 Python 3.17 中移除。" + +#: ../../deprecations/pending-removal-in-3.17.rst:16 +#: ../../deprecations/pending-removal-in-3.17.rst:62 +msgid "" +"Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " +"implements the :ref:`buffer protocol ` at runtime. For use in " +"type annotations, either use :class:`~collections.abc.Buffer` or a union " +"that explicitly specifies the types your code supports (e.g., ``bytes | " +"bytearray | memoryview``)." +msgstr "" +"使用 ``isinstance(obj, collections.abc.Buffer)`` 來測試 ``obj`` 是否在 " +"runtime 實作了\\ :ref:`緩衝區協定 `。在型別註解的使用中,請" +"用 :class:`~collections.abc.Buffer` 或明確指定你的程式碼所支援型別的聯集(例" +"如 ``bytes | bytearray | memoryview``)。" + +#: ../../deprecations/pending-removal-in-3.17.rst:22 +#: ../../deprecations/pending-removal-in-3.17.rst:68 +msgid "" +":class:`!ByteString` was originally intended to be an abstract class that " +"would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " +"However, since the ABC never had any methods, knowing that an object was an " +"instance of :class:`!ByteString` never actually told you anything useful " +"about the object. Other common buffer types such as :class:`memoryview` were " +"also never understood as subtypes of :class:`!ByteString` (either at runtime " +"or by static type checkers)." +msgstr "" +":class:`!ByteString` 最初被設計為一個抽象類別,以作為 :class:`bytes` " +"和 :class:`bytearray` 的超型別 (supertype)。然而由於 ABC 從未擁有任何方法,知" +"道一個物件是 :class:`!ByteString` 的實例從未真正告訴你任何關於該物件的有用資" +"訊。其他常見的緩衝區型別如 :class:`memoryview` 也從未被理解為 :class:`!" +"ByteString` 的子型別(無論是在 runtime 還是由靜態型別檢查器)。" + +#: ../../deprecations/pending-removal-in-3.17.rst:30 +#: ../../deprecations/pending-removal-in-3.17.rst:76 +msgid "" +"See :pep:`PEP 688 <688#current-options>` for more details. (Contributed by " +"Shantanu Jain in :gh:`91896`.)" +msgstr "" +"更多細節請見 :pep:`PEP 688 <688#current-options>`。(由 Shantanu Jain " +"於 :gh:`91896` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.17.rst:34 +msgid ":mod:`encodings`:" +msgstr ":mod:`encodings`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:36 +msgid "" +"Passing non-ascii *encoding* names to :func:`encodings.normalize_encoding` " +"is deprecated and scheduled for removal in Python 3.17. (Contributed by Stan " +"Ulbrych in :gh:`136702`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:49 +msgid "" +":class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of :class:`!" +"webbrowser.MacOS`. (:gh:`137586`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:54 +msgid "" +"Before Python 3.14, old-style unions were implemented using the private " +"class ``typing._UnionGenericAlias``. This class is no longer needed for the " +"implementation, but it has been retained for backward compatibility, with " +"removal scheduled for Python 3.17. Users should use documented introspection " +"helpers like :func:`typing.get_origin` and :func:`typing.get_args` instead " +"of relying on private implementation details." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.17.rst:59 +msgid "" +":class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for " +"removal in Python 3.17." +msgstr "" +":class:`typing.ByteString` 自 Python 3.9 起已被棄用,預計在 Python 3.17 中移" +"除。" + +#: ../../deprecations/pending-removal-in-3.17.rst:79 +msgid ":mod:`tkinter`:" +msgstr ":mod:`tkinter`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:81 +msgid "" +"The :class:`!tkinter.Variable` methods :meth:`!trace_variable`, :meth:`!" +"trace` (an alias of :meth:`!trace_variable`), :meth:`!trace_vdelete` and :" +"meth:`!trace_vinfo`, deprecated since Python 3.14, are scheduled for removal " +"in Python 3.17. Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!" +"trace_info` instead. (Contributed by Serhiy Storchaka in :gh:`120220`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:2 +msgid "Pending removal in Python 3.18" +msgstr "Python 3.18 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.18.rst:4 +msgid "" +"No longer accept a boolean value when a file descriptor is expected. " +"(Contributed by Serhiy Storchaka in :gh:`82626`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:7 +msgid ":mod:`decimal`:" +msgstr ":mod:`decimal`:" + +#: ../../deprecations/pending-removal-in-3.18.rst:9 +msgid "" +"The non-standard and undocumented :class:`~decimal.Decimal` format specifier " +"``'N'``, which is only supported in the :mod:`!decimal` module's C " +"implementation, has been deprecated since Python 3.13. (Contributed by " +"Serhiy Storchaka in :gh:`89902`.)" +msgstr "" +"非標準且無文件記載的 :class:`~decimal.Decimal` 格式說明符號 ``'N'``,僅" +"在 :mod:`!decimal` 模組的 C 實作中被支援,自 Python 3.13 起已被棄用。(由 " +"Serhiy Storchaka 於 :gh:`89902` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.18.rst:14 +#: ../../deprecations/pending-removal-in-3.20.rst:42 +msgid "Deprecations defined by :pep:`829`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:16 +msgid "``import`` lines in :file:`{name}.pth` files are silently ignored." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.18.rst:18 +#: ../../deprecations/pending-removal-in-3.20.rst:50 +msgid "(Contributed by Barry Warsaw in :gh:`148641`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:2 +msgid "Pending removal in Python 3.19" +msgstr "Python 3.19 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.19.rst:4 +msgid ":mod:`ctypes`:" +msgstr ":mod:`ctypes`:" + +#: ../../deprecations/pending-removal-in-3.19.rst:6 +msgid "" +"Implicitly switching to the MSVC-compatible struct layout by setting :attr:" +"`~ctypes.Structure._pack_` but not :attr:`~ctypes.Structure._layout_` on non-" +"Windows platforms." +msgstr "" +"在非 Windows 平台上,透過設定 :attr:`~ctypes.Structure._pack_` 而沒有設" +"定 :attr:`~ctypes.Structure._layout_` 來隱式地切換到與 MSVC 相容的結構佈局。" + +#: ../../deprecations/pending-removal-in-3.19.rst:12 +msgid "" +"In hash function constructors such as :func:`~hashlib.new` or the direct " +"hash-named constructors such as :func:`~hashlib.md5` and :func:`~hashlib." +"sha256`, their optional initial data parameter could also be passed a " +"keyword argument named ``data=`` or ``string=`` in various :mod:`!hashlib` " +"implementations." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:18 +msgid "" +"Support for the ``string`` keyword argument name is now deprecated and " +"slated for removal in Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:21 +msgid "" +"Before Python 3.13, the ``string`` keyword parameter was not correctly " +"supported depending on the backend implementation of hash functions. Prefer " +"passing the initial data as a positional argument for maximum backwards " +"compatibility." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:28 +msgid "" +":meth:`http.cookies.Morsel.js_output` is deprecated and will be removed in " +"Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:31 +msgid "" +":meth:`http.cookies.BaseCookie.js_output` is deprecated and will be removed " +"in Python 3.19." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:36 +msgid "" +"Altering :attr:`IMAP4.file ` is now deprecated and " +"slated for removal in Python 3.19. This property is now unused and changing " +"its value does not automatically close the current file." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.19.rst:40 +msgid "" +"Before Python 3.14, this property was used to implement the corresponding " +"``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this " +"is no longer the case since then." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:2 +msgid "Pending removal in Python 3.20" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:4 +msgid "" +"Calling the ``__new__()`` method of :class:`struct.Struct` without the " +"*format* argument is deprecated and will be removed in Python 3.20. " +"Calling :meth:`~object.__init__` method on initialized :class:`~struct." +"Struct` objects is deprecated and will be removed in Python 3.20." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:44 +msgid "" +"Warnings are produced for ``import`` lines found in :file:`{name}.pth` files." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.20.rst:47 +msgid "" +":file:`{name}.pth` files are no longer decoded in the locale encoding by " +"default. They **MUST** be encoded in ``utf-8-sig``." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:2 +msgid "Pending removal in future versions" +msgstr "未來版本中的待移除項目" + +#: ../../deprecations/pending-removal-in-future.rst:4 +msgid "" +"The following APIs will be removed in the future, although there is " +"currently no date scheduled for their removal." +msgstr "以下 API 將在未來被移除,雖然目前尚未安排移除日期。" + +#: ../../deprecations/pending-removal-in-future.rst:7 +msgid ":mod:`argparse`:" +msgstr ":mod:`argparse`:" + +#: ../../deprecations/pending-removal-in-future.rst:9 +msgid "" +"Nesting argument groups and nesting mutually exclusive groups are deprecated." +msgstr "巢狀引數群組和巢狀互斥群組已被棄用。" + +#: ../../deprecations/pending-removal-in-future.rst:11 +msgid "" +"Passing the undocumented keyword argument *prefix_chars* to :meth:`~argparse." +"ArgumentParser.add_argument_group` is now deprecated." +msgstr "" +"將未以文件記錄的關鍵字引數 *prefix_chars* 傳遞" +"給 :meth:`~argparse.ArgumentParser.add_argument_group` 的做法現在已被棄用。" + +#: ../../deprecations/pending-removal-in-future.rst:14 +msgid "The :class:`argparse.FileType` type converter is deprecated." +msgstr ":class:`argparse.FileType` 型別轉換器已被棄用。" + +#: ../../deprecations/pending-removal-in-future.rst:18 +msgid "" +"Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)`` signature " +"is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead, the single " +"argument signature." +msgstr "" +"產生器:``throw(type, exc, tb)`` 和 ``athrow(type, exc, tb)`` 簽名已被棄用:" +"請改用 ``throw(exc)`` 和 ``athrow(exc)``,為單引數簽名。" + +#: ../../deprecations/pending-removal-in-future.rst:21 +msgid "" +"Currently Python accepts numeric literals immediately followed by keywords, " +"for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " +"ambiguous expressions like ``[0x1for x in y]`` (which can be interpreted as " +"``[0x1 for x in y]`` or ``[0x1f or x in y]``). A syntax warning is raised " +"if the numeric literal is immediately followed by one of keywords :keyword:" +"`and`, :keyword:`else`, :keyword:`for`, :keyword:`if`, :keyword:`in`, :" +"keyword:`is` and :keyword:`or`. In a future release it will be changed to a " +"syntax error. (:gh:`87999`)" +msgstr "" +"目前 Python 接受數值字面值後面立即接關鍵字,例如 ``0in x``、``1or x``、``0if " +"1else 2``。它讓運算式模糊且容易混淆,如 ``[0x1for x in y]``\\ (可以解釋為 " +"``[0x1 for x in y]`` 或 ``[0x1f or x in y]``)。如果數值字面值後立即" +"接 :keyword:`and`、:keyword:`else`、:keyword:`for`、:keyword:`if`、:keyword:`in`、:keyword:`is` " +"和 :keyword:`or` 之一的關鍵字,則會引發語法警告。在未來版本中,它將被更改為語" +"法錯誤。(:gh:`87999`)" + +#: ../../deprecations/pending-removal-in-future.rst:29 +msgid "" +"Support for ``__index__()`` and ``__int__()`` method returning non-int type: " +"these methods will be required to return an instance of a strict subclass " +"of :class:`int`." +msgstr "" +"``__index__()`` 和 ``__int__()`` 方法回傳非 int 型別的支援:這些方法將需要回" +"傳 :class:`int` 的嚴格子類別實例。" + +#: ../../deprecations/pending-removal-in-future.rst:32 +msgid "" +"Support for ``__float__()`` method returning a strict subclass of :class:" +"`float`: these methods will be required to return an instance of :class:" +"`float`." +msgstr "" +"回傳 :class:`float` 嚴格子類別 ``__float__()`` 方法的支援:這些方法將需要回" +"傳 :class:`float` 的實例。" + +#: ../../deprecations/pending-removal-in-future.rst:35 +msgid "" +"Support for ``__complex__()`` method returning a strict subclass of :class:" +"`complex`: these methods will be required to return an instance of :class:" +"`complex`." +msgstr "" +"回傳 :class:`complex` 嚴格子類別 ``__complex__()`` 方法的支援:這些方法將需要" +"回傳 :class:`complex` 的實例。" + +#: ../../deprecations/pending-removal-in-future.rst:38 +msgid "" +"Passing a complex number as the *real* or *imag* argument in the :func:" +"`complex` constructor is now deprecated; it should only be passed as a " +"single positional argument. (Contributed by Serhiy Storchaka in :gh:" +"`109218`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:43 +msgid "" +":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " +"are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." +"FEBRUARY`. (Contributed by Prince Roshan in :gh:`103636`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:48 +msgid "" +":mod:`codecs`: use :func:`open` instead of :func:`codecs.open`. (:gh:" +"`133038`)" +msgstr "" +":mod:`codecs`:請改用 :func:`open` 而非 :func:`codecs.open`。(:gh:`133038`)" + +#: ../../deprecations/pending-removal-in-future.rst:50 +msgid "" +":attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " +"instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:55 +msgid "" +":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." +"UTC)``." +msgstr "" +":meth:`~datetime.datetime.utcnow`:請改用 " +"``datetime.datetime.now(tz=datetime.UTC)``。" + +#: ../../deprecations/pending-removal-in-future.rst:57 +msgid "" +":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." +"fromtimestamp(timestamp, tz=datetime.UTC)``." +msgstr "" +":meth:`~datetime.datetime.utcfromtimestamp`:請改用 " +"``datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)``。" + +#: ../../deprecations/pending-removal-in-future.rst:60 +msgid ":mod:`gettext`: Plural value must be an integer." +msgstr ":mod:`gettext`:複數值必須是整數。" + +#: ../../deprecations/pending-removal-in-future.rst:62 +msgid ":mod:`importlib`:" +msgstr ":mod:`importlib`:" + +#: ../../deprecations/pending-removal-in-future.rst:64 +msgid "" +":func:`~importlib.util.cache_from_source` *debug_override* parameter is " +"deprecated: use the *optimization* parameter instead." +msgstr "" +":func:`~importlib.util.cache_from_source` *debug_override* 參數已被棄用:請改" +"用 *optimization* 參數。" + +#: ../../deprecations/pending-removal-in-future.rst:67 +msgid ":mod:`importlib.metadata`:" +msgstr ":mod:`importlib.metadata`:" + +#: ../../deprecations/pending-removal-in-future.rst:69 +msgid "``EntryPoints`` tuple interface." +msgstr "``EntryPoints`` 元組介面。" + +#: ../../deprecations/pending-removal-in-future.rst:70 +msgid "Implicit ``None`` on return values." +msgstr "回傳值上的隱式 ``None``。" + +#: ../../deprecations/pending-removal-in-future.rst:72 +msgid "" +":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " +"use :meth:`~logging.warning` instead." +msgstr "" +":mod:`logging`:自 Python 3.3 起,``warn()`` 方法已被棄用,請改" +"用 :meth:`~logging.warning`。" + +#: ../../deprecations/pending-removal-in-future.rst:75 +msgid "" +":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " +"BytesIO and binary mode instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:78 +msgid "" +":mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:80 +msgid "" +":mod:`os.path`: :func:`os.path.commonprefix` is deprecated, use :func:`os." +"path.commonpath` for path prefixes. The :func:`os.path.commonprefix` " +"function is being deprecated due to having a misleading name and module. The " +"function is not safe to use for path prefixes despite being included in a " +"module about path manipulation, meaning it is easy to accidentally introduce " +"path traversal vulnerabilities into Python programs by using this function." +msgstr "" + +#: ../../deprecations/pending-removal-in-future.rst:88 +msgid "" +":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " +"deprecated, use an exception instance." +msgstr "" +":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" +"實例。" + +#: ../../deprecations/pending-removal-in-future.rst:91 +msgid "" +":mod:`re`: More strict rules are now applied for numerical group references " +"and group names in regular expressions. Only sequence of ASCII digits is " +"now accepted as a numerical reference. The group name in bytes patterns and " +"replacement strings can now only contain ASCII letters and digits and " +"underscore. (Contributed by Serhiy Storchaka in :gh:`91760`.)" +msgstr "" +":mod:`re`:現在對正規表示式中的數值群組參照和群組名稱用了更嚴格的規則。現在只" +"有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" +"包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" + +#: ../../deprecations/pending-removal-in-future.rst:98 +msgid "" +":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " +"Python 3.12; use the *onexc* parameter instead." +msgstr "" +":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" +"棄用;請改用 *onexc* 參數。" + +#: ../../deprecations/pending-removal-in-future.rst:101 +msgid ":mod:`ssl` options and protocols:" +msgstr ":mod:`ssl` 選項和協定:" + +#: ../../deprecations/pending-removal-in-future.rst:103 +msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." +msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" + +#: ../../deprecations/pending-removal-in-future.rst:104 +msgid "" +":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" +"`!selected_npn_protocol` are deprecated: use ALPN instead." +msgstr "" +":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` " +"和 :meth:`!selected_npn_protocol` 已被棄用:請改用 ALPN。" + +#: ../../deprecations/pending-removal-in-future.rst:107 +msgid "``ssl.OP_NO_SSL*`` options" +msgstr "``ssl.OP_NO_SSL*`` 選項" + +#: ../../deprecations/pending-removal-in-future.rst:108 +msgid "``ssl.OP_NO_TLS*`` options" +msgstr "``ssl.OP_NO_TLS*`` 選項" + +#: ../../deprecations/pending-removal-in-future.rst:109 +msgid "``ssl.PROTOCOL_SSLv3``" +msgstr "``ssl.PROTOCOL_SSLv3``" + +#: ../../deprecations/pending-removal-in-future.rst:110 +msgid "``ssl.PROTOCOL_TLS``" +msgstr "``ssl.PROTOCOL_TLS``" + +#: ../../deprecations/pending-removal-in-future.rst:111 +msgid "``ssl.PROTOCOL_TLSv1``" +msgstr "``ssl.PROTOCOL_TLSv1``" + +#: ../../deprecations/pending-removal-in-future.rst:112 +msgid "``ssl.PROTOCOL_TLSv1_1``" +msgstr "``ssl.PROTOCOL_TLSv1_1``" + +#: ../../deprecations/pending-removal-in-future.rst:113 +msgid "``ssl.PROTOCOL_TLSv1_2``" +msgstr "``ssl.PROTOCOL_TLSv1_2``" + +#: ../../deprecations/pending-removal-in-future.rst:114 +msgid "``ssl.TLSVersion.SSLv3``" +msgstr "``ssl.TLSVersion.SSLv3``" + +#: ../../deprecations/pending-removal-in-future.rst:115 +msgid "``ssl.TLSVersion.TLSv1``" +msgstr "``ssl.TLSVersion.TLSv1``" + +#: ../../deprecations/pending-removal-in-future.rst:116 +msgid "``ssl.TLSVersion.TLSv1_1``" +msgstr "``ssl.TLSVersion.TLSv1_1``" + +#: ../../deprecations/pending-removal-in-future.rst:118 +msgid ":mod:`threading` methods:" +msgstr ":mod:`threading` 方法:" + +#: ../../deprecations/pending-removal-in-future.rst:120 +msgid "" +":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." +"notify_all`." +msgstr "" +":meth:`!threading.Condition.notifyAll`:請" +"用 :meth:`~threading.Condition.notify_all`。" + +#: ../../deprecations/pending-removal-in-future.rst:121 +msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." +msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" + +#: ../../deprecations/pending-removal-in-future.rst:122 +msgid "" +":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" +"attr:`threading.Thread.daemon` attribute." +msgstr "" +":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" +"用 :attr:`threading.Thread.daemon` 屬性。" + +#: ../../deprecations/pending-removal-in-future.rst:124 +msgid "" +":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" +"attr:`threading.Thread.name` attribute." +msgstr "" +":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請" +"用 :attr:`threading.Thread.name` 屬性。" + +#: ../../deprecations/pending-removal-in-future.rst:126 +msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." +msgstr "" +":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" + +#: ../../deprecations/pending-removal-in-future.rst:127 +msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." +msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" + +#: ../../deprecations/pending-removal-in-future.rst:129 +msgid ":class:`typing.Text` (:gh:`92332`)." +msgstr ":class:`typing.Text` (:gh:`92332`)。" + +#: ../../deprecations/pending-removal-in-future.rst:131 +msgid "" +"The internal class ``typing._UnionGenericAlias`` is no longer used to " +"implement :class:`typing.Union`. To preserve compatibility with users using " +"this private class, a compatibility shim will be provided until at least " +"Python 3.17. (Contributed by Jelle Zijlstra in :gh:`105499`.)" +msgstr "" +"內部類別 ``typing._UnionGenericAlias`` 不再用於實作 :class:`typing.Union`。為" +"了保持與此私有類別使用者的相容性,直到至少 Python 3.17 都將提供一個相容性 " +"shim。(由 Jelle Zijlstra 於 :gh:`105499` 貢獻。)" + +#: ../../deprecations/pending-removal-in-future.rst:136 +msgid "" +":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " +"value that is not ``None`` from a test case." +msgstr "" +":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" +"被棄用。" + +#: ../../deprecations/pending-removal-in-future.rst:139 +msgid "" +":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " +"instead" +msgstr "" +":mod:`urllib.parse` 已棄用函式:請改用 :func:`~urllib.parse.urlparse`。" + +#: ../../deprecations/pending-removal-in-future.rst:141 +msgid "``splitattr()``" +msgstr "``splitattr()``" + +#: ../../deprecations/pending-removal-in-future.rst:142 +msgid "``splithost()``" +msgstr "``splithost()``" + +#: ../../deprecations/pending-removal-in-future.rst:143 +msgid "``splitnport()``" +msgstr "``splitnport()``" + +#: ../../deprecations/pending-removal-in-future.rst:144 +msgid "``splitpasswd()``" +msgstr "``splitpasswd()``" + +#: ../../deprecations/pending-removal-in-future.rst:145 +msgid "``splitport()``" +msgstr "``splitport()``" + +#: ../../deprecations/pending-removal-in-future.rst:146 +msgid "``splitquery()``" +msgstr "``splitquery()``" + +#: ../../deprecations/pending-removal-in-future.rst:147 +msgid "``splittag()``" +msgstr "``splittag()``" + +#: ../../deprecations/pending-removal-in-future.rst:148 +msgid "``splittype()``" +msgstr "``splittype()``" + +#: ../../deprecations/pending-removal-in-future.rst:149 +msgid "``splituser()``" +msgstr "``splituser()``" + +#: ../../deprecations/pending-removal-in-future.rst:150 +msgid "``splitvalue()``" +msgstr "``splitvalue()``" + +#: ../../deprecations/pending-removal-in-future.rst:151 +msgid "``to_bytes()``" +msgstr "``to_bytes()``" + +#: ../../deprecations/pending-removal-in-future.rst:153 +msgid "" +":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " +"writes." +msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" + +#: ../../deprecations/pending-removal-in-future.rst:156 +msgid "" +":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." +"etree.ElementTree.Element` is deprecated. In a future release it will always " +"return ``True``. Prefer explicit ``len(elem)`` or ``elem is not None`` tests " +"instead." +msgstr "" +":mod:`xml.etree.ElementTree`:已棄用" +"對 :class:`~xml.etree.ElementTree.Element` 的真值測試。在未來版本中,它將始終" +"回傳 ``True``。請改用明確的 ``len(elem)`` 或 ``elem is not None`` 測試。" + +#: ../../deprecations/pending-removal-in-future.rst:161 +msgid "" +":func:`sys._clear_type_cache` is deprecated: use :func:`sys." +"_clear_internal_caches` instead." +msgstr "" +":func:`sys._clear_type_cache` 已被棄用:請改" +"用 :func:`sys._clear_internal_caches`。" + +#: ../../deprecations/soft-deprecations.rst:2 +msgid "Soft deprecations" +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:4 +msgid "There are no plans to remove :term:`soft deprecated` APIs." +msgstr "" + +#: ../../deprecations/soft-deprecations.rst:23 +msgid "" +"Using ``'F'`` and ``'D'`` format type codes of the :mod:`struct` module now " +"are :term:`soft deprecated` in favor of two-letter forms ``'Zf'`` and " +"``'Zd'``. (Contributed by Sergey B Kirpichev in :gh:`121249`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2492 +msgid "C API changes" +msgstr "C API 變更" + +#: ../../whatsnew/3.15.rst:2497 +msgid "" +"Add :c:func:`PyArg_ParseArray` and :c:func:`PyArg_ParseArrayAndKeywords` " +"functions to parse arguments of functions using the :c:macro:`METH_FASTCALL` " +"calling convention. (Contributed by Victor Stinner in :gh:`144175`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2502 +msgid "Add the following functions for the new :class:`frozendict` type:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2504 +msgid ":c:func:`PyAnyDict_Check`" +msgstr ":c:func:`PyAnyDict_Check`" + +#: ../../whatsnew/3.15.rst:2505 +msgid ":c:func:`PyAnyDict_CheckExact`" +msgstr ":c:func:`PyAnyDict_CheckExact`" + +#: ../../whatsnew/3.15.rst:2506 +msgid ":c:func:`PyFrozenDict_Check`" +msgstr ":c:func:`PyFrozenDict_Check`" + +#: ../../whatsnew/3.15.rst:2507 +msgid ":c:func:`PyFrozenDict_CheckExact`" +msgstr ":c:func:`PyFrozenDict_CheckExact`" + +#: ../../whatsnew/3.15.rst:2508 +msgid ":c:func:`PyFrozenDict_New`" +msgstr ":c:func:`PyFrozenDict_New`" + +#: ../../whatsnew/3.15.rst:2510 +msgid "(Contributed by Victor Stinner in :gh:`141510`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2512 +msgid "" +"Add :c:func:`PyObject_CallFinalizerFromDealloc` function to the limited C " +"API. (Contributed by Victor Stinner in :gh:`146063`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2516 +msgid "" +"Add :c:func:`PySys_GetAttr`, :c:func:`PySys_GetAttrString`, :c:func:" +"`PySys_GetOptionalAttr`, and :c:func:`PySys_GetOptionalAttrString` functions " +"as replacements for :c:func:`PySys_GetObject`. (Contributed by Serhiy " +"Storchaka in :gh:`108512`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2521 +msgid "" +"Add :c:func:`PyUnstable_Unicode_GET_CACHED_HASH` to get the cached hash of a " +"string. See the documentation for caveats. (Contributed by Petr Viktorin in :" +"gh:`131510`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2525 +msgid "" +"Add API for checking an extension module's ABI compatibility: :c:data:" +"`Py_mod_abi`, :c:func:`PyABIInfo_Check`, and :c:macro:`PyABIInfo_VAR`. " +"(Contributed by Petr Viktorin in :gh:`137210`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2532 +msgid "" +"Implement :pep:`782`, the :ref:`PyBytesWriter API `. Add " +"functions:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2535 +msgid ":c:func:`PyBytesWriter_Create`" +msgstr ":c:func:`PyBytesWriter_Create`" + +#: ../../whatsnew/3.15.rst:2536 +msgid ":c:func:`PyBytesWriter_Discard`" +msgstr ":c:func:`PyBytesWriter_Discard`" + +#: ../../whatsnew/3.15.rst:2537 +msgid ":c:func:`PyBytesWriter_Finish`" +msgstr ":c:func:`PyBytesWriter_Finish`" + +#: ../../whatsnew/3.15.rst:2538 +msgid ":c:func:`PyBytesWriter_FinishWithPointer`" +msgstr ":c:func:`PyBytesWriter_FinishWithPointer`" + +#: ../../whatsnew/3.15.rst:2539 +msgid ":c:func:`PyBytesWriter_FinishWithSize`" +msgstr ":c:func:`PyBytesWriter_FinishWithSize`" + +#: ../../whatsnew/3.15.rst:2540 +msgid ":c:func:`PyBytesWriter_Format`" +msgstr ":c:func:`PyBytesWriter_Format`" + +#: ../../whatsnew/3.15.rst:2541 +msgid ":c:func:`PyBytesWriter_GetData`" +msgstr ":c:func:`PyBytesWriter_GetData`" + +#: ../../whatsnew/3.15.rst:2542 +msgid ":c:func:`PyBytesWriter_GetSize`" +msgstr ":c:func:`PyBytesWriter_GetSize`" + +#: ../../whatsnew/3.15.rst:2543 +msgid ":c:func:`PyBytesWriter_Grow`" +msgstr ":c:func:`PyBytesWriter_Grow`" + +#: ../../whatsnew/3.15.rst:2544 +msgid ":c:func:`PyBytesWriter_GrowAndUpdatePointer`" +msgstr ":c:func:`PyBytesWriter_GrowAndUpdatePointer`" + +#: ../../whatsnew/3.15.rst:2545 +msgid ":c:func:`PyBytesWriter_Resize`" +msgstr ":c:func:`PyBytesWriter_Resize`" + +#: ../../whatsnew/3.15.rst:2546 +msgid ":c:func:`PyBytesWriter_WriteBytes`" +msgstr ":c:func:`PyBytesWriter_WriteBytes`" + +#: ../../whatsnew/3.15.rst:2548 +msgid "(Contributed by Victor Stinner in :gh:`129813`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2550 +msgid "" +":c:type:`PyCriticalSection` and related functions are added to the Stable " +"ABI. (Contributed by Petr Viktorin in :gh:`149225`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2554 +msgid "" +"Add a new :c:func:`PyImport_CreateModuleFromInitfunc` C API for creating a " +"module from a *spec* and *initfunc*. (Contributed by Itamar Oren in :gh:" +"`116146`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2558 +msgid "" +"Add :c:func:`PyTuple_FromArray` to create a :class:`tuple` from an array. " +"(Contributed by Victor Stinner in :gh:`111489`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2561 +msgid "" +"Add a new module export hook, :c:func:`PyModExport_* " +"`." +msgstr "" + +#: ../../whatsnew/3.15.rst:2564 +msgid "(Contributed by Petr Viktorin in :pep:`793` and :gh:`140550`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2566 +msgid "" +"Add functions that are guaranteed to be safe for use in :c:member:" +"`~PyTypeObject.tp_traverse` handlers: :c:func:" +"`PyObject_GetTypeData_DuringGC`, :c:func:`PyObject_GetItemData_DuringGC`, :c:" +"func:`PyType_GetModuleState_DuringGC`, :c:func:" +"`PyModule_GetState_DuringGC`, :c:func:`PyModule_GetToken_DuringGC`, :c:func:" +"`PyType_GetBaseByToken_DuringGC`, :c:func:`PyType_GetModule_DuringGC`, :c:" +"func:`PyType_GetModuleByToken_DuringGC`. (Contributed by Petr Viktorin in :" +"gh:`145925`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2577 +msgid "" +"Add :c:func:`PyObject_Dump` to dump an object to ``stderr``. It should only " +"be used for debugging. (Contributed by Victor Stinner in :gh:`141070`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2581 +msgid "" +"Implement :pep:`820`: ``PySlot`` -- Unified slot system for the C API. See :" +"ref:`capi-slots` for documentation." +msgstr "" + +#: ../../whatsnew/3.15.rst:2584 +msgid "This adds:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2586 +msgid "The :c:type:`PySlot` struct;" +msgstr "" + +#: ../../whatsnew/3.15.rst:2587 +msgid "the :c:func:`PyType_FromSlots` function;" +msgstr "" + +#: ../../whatsnew/3.15.rst:2588 +msgid "" +"new slot IDs: :c:macro:`Py_slot_end`, :c:macro:`Py_slot_invalid`; :c:macro:" +"`Py_slot_subslots`, :c:macro:`Py_tp_slots`, :c:macro:`Py_mod_slots`; :c:" +"macro:`Py_tp_name`, :c:macro:`Py_tp_basicsize`, :c:macro:" +"`Py_tp_extra_basicsize`, :c:macro:`Py_tp_itemsize`, :c:macro:`Py_tp_flags`, :" +"c:macro:`Py_tp_metaclass`, :c:macro:`Py_tp_module`;" +msgstr "" + +#: ../../whatsnew/3.15.rst:2595 +msgid "" +"convenience macros: :c:macro:`PySlot_DATA`, :c:macro:`PySlot_FUNC`, :c:macro:" +"`PySlot_SIZE`, :c:macro:`PySlot_INT64`, :c:macro:`PySlot_UINT64`, :c:macro:" +"`PySlot_STATIC_DATA`, :c:macro:`PySlot_END`, :c:macro:`PySlot_PTR`, :c:macro:" +"`PySlot_PTR_STATIC`." +msgstr "" + +#: ../../whatsnew/3.15.rst:2600 +msgid "" +"The :c:func:`PyModule_FromSlotsAndSpec` function and ``PyModExport`` :ref:" +"`module export hook ` also use the new :c:type:`!" +"PySlot` struct." +msgstr "" + +#: ../../whatsnew/3.15.rst:2604 +msgid "The following functions are :term:`soft deprecated`:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2606 +msgid ":c:func:`PyType_FromSpec`" +msgstr ":c:func:`PyType_FromSpec`" + +#: ../../whatsnew/3.15.rst:2607 +msgid ":c:func:`PyType_FromSpecWithBases`" +msgstr ":c:func:`PyType_FromSpecWithBases`" + +#: ../../whatsnew/3.15.rst:2608 +msgid ":c:func:`PyType_FromModuleAndSpec`" +msgstr ":c:func:`PyType_FromModuleAndSpec`" + +#: ../../whatsnew/3.15.rst:2609 +msgid ":c:func:`PyType_FromMetaclass`" +msgstr ":c:func:`PyType_FromMetaclass`" + +#: ../../whatsnew/3.15.rst:2610 +msgid ":c:func:`PyModule_FromDefAndSpec`" +msgstr ":c:func:`PyModule_FromDefAndSpec`" + +#: ../../whatsnew/3.15.rst:2611 +msgid ":c:func:`PyModule_FromDefAndSpec2`" +msgstr ":c:func:`PyModule_FromDefAndSpec2`" + +#: ../../whatsnew/3.15.rst:2612 +msgid ":c:func:`PyModule_ExecDef`" +msgstr ":c:func:`PyModule_ExecDef`" + +#: ../../whatsnew/3.15.rst:2614 +msgid "" +"The slots :c:macro:`Py_tp_bases` and :c:macro:`Py_tp_base` are now " +"equivalent: they can be set either to a single type or a tuple of types. " +"The :c:macro:`Py_tp_bases` slot is preferred; the other is ignored if both " +"are specified." +msgstr "" + +#: ../../whatsnew/3.15.rst:2619 +msgid "(Contributed by Petr Viktorin in :gh:`149044`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2621 +msgid "" +"Add :c:func:`PyUnstable_ThreadState_SetStackProtection` and :c:func:" +"`PyUnstable_ThreadState_ResetStackProtection` functions to set the stack " +"protection base address and stack protection size of a Python thread state. " +"(Contributed by Victor Stinner in :gh:`139653`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2627 +msgid "" +"Add :c:func:`PyUnstable_SetImmortal` C API function to mark objects as :term:" +"`immortal`. (Contributed by Kumar Aditya in :gh:`143300`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2630 +msgid "" +"Restore private provisional ``_Py_InitializeMain()`` function removed in " +"Python 3.14. (Contributed by Victor Stinner in :gh:`142417`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2634 +msgid "" +"Add :c:func:`PyUnstable_DumpTraceback` and :c:func:" +"`PyUnstable_DumpTracebackThreads` functions to output Python stacktraces. " +"(Contributed by Alex Malyshev in :gh:`145559`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2640 +msgid "Changed C APIs" +msgstr "" + +#: ../../whatsnew/3.15.rst:2642 +msgid "" +"If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` or :c:macro:" +"`Py_TPFLAGS_MANAGED_WEAKREF` flag is set then :c:macro:`Py_TPFLAGS_HAVE_GC` " +"must be set too. (Contributed by Sergey Miryanov in :gh:`134786`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2646 +msgid "" +":c:macro:`PyDateTime_IMPORT` is now thread safe. Code that directly checks " +"``PyDateTimeAPI`` for ``NULL`` should be updated to call :c:macro:" +"`PyDateTime_IMPORT` instead. (Contributed by Kumar Aditya in :gh:`141563`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2652 +msgid "Removed C APIs" +msgstr "" + +#: ../../whatsnew/3.15.rst:2654 +msgid "Remove deprecated ``PyUnicode`` functions:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2656 +msgid "" +":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." +msgstr "" +":c:func:`!PyUnicode_AsDecodedObject`:請改用 :c:func:`PyCodec_Decode`。" + +#: ../../whatsnew/3.15.rst:2658 +msgid "" +":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead; " +"note that some codecs (for example, \"base64\") may return a type other " +"than :class:`str`, such as :class:`bytes`." +msgstr "" + +#: ../../whatsnew/3.15.rst:2661 +msgid "" +":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." +msgstr "" +":c:func:`!PyUnicode_AsEncodedObject`:請改用 :c:func:`PyCodec_Encode`。" + +#: ../../whatsnew/3.15.rst:2663 +msgid "" +":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead; " +"note that some codecs (for example, \"base64\") may return a type other " +"than :class:`bytes`, such as :class:`str`." +msgstr "" + +#: ../../whatsnew/3.15.rst:2667 +msgid "(Contributed by Stan Ulbrych in :gh:`133612`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2669 +msgid "" +":c:func:`!PyImport_ImportModuleNoBlock`: deprecated alias of :c:func:" +"`PyImport_ImportModule`. (Contributed by Bénédikt Tran in :gh:`133644`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2673 +msgid "" +":c:func:`!PyWeakref_GetObject` and :c:macro:`!PyWeakref_GET_OBJECT`: use :c:" +"func:`PyWeakref_GetRef` instead. The |pythoncapi_compat_project| can be used " +"to get :c:func:`!PyWeakref_GetRef` on Python 3.12 and older. (Contributed by " +"Bénédikt Tran in :gh:`133644`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2678 +msgid "" +"Remove deprecated :c:func:`!PySys_ResetWarnOptions`. Clear :data:`sys." +"warnoptions` and :data:`!warnings.filters` instead." +msgstr "" + +#: ../../whatsnew/3.15.rst:2681 +msgid "(Contributed by Nikita Sobolev in :gh:`138886`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2683 +msgid "" +"The following functions are removed in favor of :c:func:`PyConfig_Get`. The |" +"pythoncapi_compat_project| can be used to get :c:func:`!PyConfig_Get` on " +"Python 3.13 and older." +msgstr "" + +#: ../../whatsnew/3.15.rst:2687 +msgid "Python initialization functions:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2689 +msgid "" +":c:func:`!Py_GetExecPrefix`: use :c:func:`PyConfig_Get(\"base_exec_prefix\") " +"` (:data:`sys.base_exec_prefix`) instead. Use :c:func:" +"`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) if :" +"ref:`virtual environments ` need to be handled." +msgstr "" + +#: ../../whatsnew/3.15.rst:2695 +msgid "" +":c:func:`!Py_GetPath`: use :c:func:`PyConfig_Get(\"module_search_paths\") " +"` (:data:`sys.path`) instead." +msgstr "" + +#: ../../whatsnew/3.15.rst:2698 +msgid "" +":c:func:`!Py_GetPrefix`: use :c:func:`PyConfig_Get(\"base_prefix\") " +"` (:data:`sys.base_prefix`) instead. Use :c:func:" +"`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) if :ref:" +"`virtual environments ` need to be handled." +msgstr "" + +#: ../../whatsnew/3.15.rst:2704 +msgid "" +":c:func:`!Py_GetProgramFullPath`: use :c:func:`PyConfig_Get(\"executable\") " +"` (:data:`sys.executable`) instead." +msgstr "" + +#: ../../whatsnew/3.15.rst:2707 +msgid "" +":c:func:`!Py_GetProgramName`: use :c:func:`PyConfig_Get(\"executable\") " +"` (:data:`sys.executable`) instead." +msgstr "" + +#: ../../whatsnew/3.15.rst:2710 +msgid "" +":c:func:`!Py_GetPythonHome`: use :c:func:`PyConfig_Get(\"home\") " +"` or the :envvar:`PYTHONHOME` environment variable instead." +msgstr "" + +#: ../../whatsnew/3.15.rst:2714 +msgid "(Contributed by Bénédikt Tran in :gh:`133644`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2722 +msgid "Deprecated C APIs" +msgstr "" + +#: ../../whatsnew/3.15.rst:2724 +msgid "" +"Deprecate :pep:`456` support for providing an external definition of the " +"string hashing scheme. Removal is scheduled for Python 3.19." +msgstr "" + +#: ../../whatsnew/3.15.rst:2727 +msgid "" +"Previously, embedders could define :c:macro:`Py_HASH_ALGORITHM` to be " +"``Py_HASH_EXTERNAL`` to indicate that the hashing scheme was provided " +"externally but this feature was undocumented, untested and most likely " +"unused." +msgstr "" + +#: ../../whatsnew/3.15.rst:2732 +msgid "(Contributed by Bénédikt Tran in :gh:`141226`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2734 +msgid "" +"For unsigned integer formats in :c:func:`PyArg_ParseTuple`, accepting Python " +"integers with value that is larger than the maximal value for the C type or " +"less than the minimal value for the corresponding signed integer type of the " +"same size is now deprecated. (Contributed by Serhiy Storchaka in :gh:" +"`132629`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2740 +msgid "" +":c:func:`PyBytes_FromStringAndSize(NULL, len) ` " +"and :c:func:`_PyBytes_Resize` are :term:`soft deprecated`, use the :c:type:" +"`PyBytesWriter` API instead. (Contributed by Victor Stinner in :gh:`129813`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2745 +msgid "" +":c:func:`!_PyObject_CallMethodId`, :c:func:`!_PyObject_GetAttrId` and :c:" +"func:`!_PyUnicode_FromId` are deprecated since Python 3.15 and will be " +"removed in Python 3.20. Instead, use :c:func:`PyUnicode_InternFromString()` " +"and cache the result in the module state, then call :c:func:" +"`PyObject_CallMethod` or :c:func:`PyObject_GetAttr`. (Contributed by Victor " +"Stinner in :gh:`141049`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2752 +msgid "" +"Deprecate :c:member:`~PyComplexObject.cval` field of the :c:type:" +"`PyComplexObject` type. Use :c:func:`PyComplex_AsCComplex` and :c:func:" +"`PyComplex_FromCComplex` to convert a Python complex number to/from the C :c:" +"type:`Py_complex` representation. (Contributed by Sergey B Kirpichev in :gh:" +"`128813`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2759 +msgid "" +"Functions :c:func:`_Py_c_sum`, :c:func:`_Py_c_diff`, :c:func:`_Py_c_neg`, :c:" +"func:`_Py_c_prod`, :c:func:`_Py_c_quot`, :c:func:`_Py_c_pow` and :c:func:" +"`_Py_c_abs` are :term:`soft deprecated`. (Contributed by Sergey B Kirpichev " +"in :gh:`128813`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2764 +msgid "" +":c:member:`~PyConfig.bytes_warning` is deprecated since Python 3.15 and will " +"be removed in Python 3.17. (Contributed by Nikita Sobolev in :gh:`136355`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2768 +msgid "" +":c:macro:`!Py_INFINITY` macro is :term:`soft deprecated`, use the C11 " +"standard ```` :c:macro:`!INFINITY` instead. (Contributed by Sergey B " +"Kirpichev in :gh:`141004`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2772 +msgid "The following macros are :term:`soft deprecated`:" +msgstr "" + +#: ../../whatsnew/3.15.rst:2774 +msgid ":c:macro:`Py_ALIGNED`: Prefer ``alignas`` instead." +msgstr "" + +#: ../../whatsnew/3.15.rst:2775 +msgid ":c:macro:`PY_FORMAT_SIZE_T`: Use ``\"z\"`` directly." +msgstr "" + +#: ../../whatsnew/3.15.rst:2776 +msgid "" +":c:macro:`Py_LL` and :c:macro:`Py_ULL`: Use standard suffixes, ``LL`` and " +"``ULL``." +msgstr "" + +#: ../../whatsnew/3.15.rst:2778 +msgid "" +":c:macro:`PY_LONG_LONG`, :c:macro:`PY_LLONG_MIN`, :c:macro:`PY_LLONG_MAX`, :" +"c:macro:`PY_ULLONG_MAX`, :c:macro:`PY_INT32_T`, :c:macro:`PY_UINT32_T`, :c:" +"macro:`PY_INT64_T`, :c:macro:`PY_UINT64_T`, :c:macro:`PY_SIZE_MAX`: Use C99 " +"types/limits." +msgstr "" + +#: ../../whatsnew/3.15.rst:2782 +msgid ":c:macro:`Py_UNICODE_SIZE`: Use ``sizeof(wchar_t)`` directly." +msgstr "" + +#: ../../whatsnew/3.15.rst:2783 +msgid ":c:macro:`Py_VA_COPY`: Use ``va_copy`` directly." +msgstr "" + +#: ../../whatsnew/3.15.rst:2785 +msgid "" +"The macro :c:macro:`Py_UNICODE_WIDE`, which was scheduled for removal, is :" +"term:`soft deprecated` instead." +msgstr "" + +#: ../../whatsnew/3.15.rst:2788 +msgid "(Contributed by Petr Viktorin in :gh:`146175`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2790 +msgid "" +":c:macro:`!Py_MATH_El` and :c:macro:`!Py_MATH_PIl` are deprecated since " +"Python 3.15 and will be removed in Python 3.20. (Contributed by Sergey B " +"Kirpichev in :gh:`141004`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2799 +msgid "Build changes" +msgstr "建置變更" + +#: ../../whatsnew/3.15.rst:2801 +msgid "" +"Removed implicit fallback to the bundled copy of the ``libmpdec`` library. " +"Now this should be explicitly enabled with :option:`--with-system-libmpdec` " +"set to ``no`` or with :option:`!--without-system-libmpdec`. (Contributed by " +"Sergey B Kirpichev in :gh:`115119`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2806 +msgid "" +"The new configure option :option:`--with-missing-stdlib-config=FILE` allows " +"distributors to pass a `JSON `_ " +"configuration file containing custom error messages for :term:`standard " +"library` modules that are missing or packaged separately. (Contributed by " +"Stan Ulbrych and Petr Viktorin in :gh:`139707`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2812 +msgid "" +"The new configure option :option:`--with-pymalloc-hugepages` enables huge " +"page support for :ref:`pymalloc ` arenas. When enabled, arena size " +"increases to 2 MiB and allocation uses ``MAP_HUGETLB`` (Linux) or " +"``MEM_LARGE_PAGES`` (Windows) with automatic fallback to regular pages. On " +"Windows, use ``build.bat --pymalloc-hugepages``. At runtime, huge pages must " +"be explicitly enabled by setting the :envvar:`PYTHON_PYMALLOC_HUGEPAGES` " +"environment variable to ``1``. (Contributed by Pablo Galindo Salgado in :gh:" +"`144319`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2821 +msgid "" +"Annotating anonymous mmap usage is now supported if the Linux kernel " +"supports :manpage:`PR_SET_VMA_ANON_NAME ` (Linux 5.17 or " +"newer). Annotations are visible in ``/proc//maps`` if the kernel " +"supports the feature and :option:`-X dev <-X>` is passed to Python, or " +"Python is built in :ref:`debug mode `. (Contributed by Donghee " +"Na in :gh:`141770`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2828 +msgid "" +"CPython is now built with frame pointers enabled by default (:pep:`831`). " +"Pass :option:`--without-frame-pointers` to opt out." +msgstr "" + +#: ../../whatsnew/3.15.rst:2831 +msgid "" +"Authors of C extensions and native libraries built with custom build systems " +"should ensure the unwind chain is intact. This is usually done by adding ``-" +"fno-omit-frame-pointer`` and similar flags to ``CFLAGS``. See :option:`--" +"without-frame-pointers` documentation for the specific flags Python uses." +msgstr "" + +#: ../../whatsnew/3.15.rst:2837 +msgid "" +"(Contributed by Pablo Galindo Salgado and Savannah Ostrowski in :gh:" +"`149201`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2841 +msgid "" +"64-bit builds using Visual Studio 2026 (MSVC 18) may now use the new :ref:" +"`tail-calling interpreter `. Results on " +"Visual Studio 18.1.1 report between `15-20% `__ " +"speedup on the geometric mean of pyperformance on Windows x86-64 over the " +"switch-case interpreter on an AMD Ryzen 7 5800X. We have observed speedups " +"ranging from 14% for large pure-Python libraries to 40% for long-running " +"small pure-Python scripts on Windows. This was made possible by a new " +"feature introduced in MSVC 18, which the official Windows 64-bit binaries on " +"python.org__ now use. (Contributed by Chris Eibl, Ken Jin, and Brandt Bucher " +"in :gh:`143068`. Special thanks to Steve Dower, and the MSVC team including " +"Hulon Jenkins.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2858 +msgid "Porting to Python 3.15" +msgstr "" + +#: ../../whatsnew/3.15.rst:2860 +msgid "" +"This section lists previously described changes and other bugfixes that may " +"require changes to your code." +msgstr "" + +#: ../../whatsnew/3.15.rst:2863 +msgid ":class:`sqlite3.Connection` APIs have been cleaned up." +msgstr "" + +#: ../../whatsnew/3.15.rst:2865 +msgid "" +"All parameters of :func:`sqlite3.connect` except *database* are now keyword-" +"only." +msgstr "" + +#: ../../whatsnew/3.15.rst:2866 +msgid "" +"The first three parameters of methods :meth:`~sqlite3.Connection." +"create_function` and :meth:`~sqlite3.Connection.create_aggregate` are now " +"positional-only." +msgstr "" + +#: ../../whatsnew/3.15.rst:2868 +msgid "" +"The first parameter of methods :meth:`~sqlite3.Connection.set_authorizer`, :" +"meth:`~sqlite3.Connection.set_progress_handler` and :meth:`~sqlite3." +"Connection.set_trace_callback` is now positional-only." +msgstr "" + +#: ../../whatsnew/3.15.rst:2872 +msgid "(Contributed by Serhiy Storchaka in :gh:`133595`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2874 +msgid "" +":data:`resource.RLIM_INFINITY` is now always positive. Passing a negative " +"integer value that corresponded to its old value (such as ``-1`` or ``-3``, " +"depending on platform) to :func:`resource.setrlimit` and :func:`resource." +"prlimit` is now deprecated. (Contributed by Serhiy Storchaka in :gh:" +"`137044`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2880 +msgid "" +":meth:`mmap.mmap.resize` has been removed on platforms that don't support " +"the underlying syscall, instead of raising a :exc:`SystemError`. " +"(Contributed by An Long in :gh:`138205`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2884 +msgid "" +"A resource warning is now emitted for an unclosed :func:`xml.etree." +"ElementTree.iterparse` iterator if it opened a file. Use its :meth:`!close` " +"method or the :func:`contextlib.closing` context manager to close it. " +"(Contributed by Osama Abdelkader and Serhiy Storchaka in :gh:`140601`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2890 +msgid "" +"If a short option and a single-dash long option are passed to :meth:" +"`argparse.ArgumentParser.add_argument`, *dest* is now inferred from the " +"single-dash long option. For example, in ``add_argument('-f', '-foo')``, " +"*dest* is now ``'foo'`` instead of ``'f'``. Pass an explicit *dest* argument " +"to preserve the old behavior. (Contributed by Serhiy Storchaka in :gh:" +"`138697`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2897 +msgid "" +"Padding of input no longer required in :func:`base64.urlsafe_b64decode`. " +"Pass a new argument ``padded=True`` or use :func:`base64.b64decode` with " +"argument ``altchars=b'-_'`` (this works with older Python versions) to make " +"padding required. (Contributed by Serhiy Storchaka in :gh:`73613`.)" +msgstr "" + +#: ../../whatsnew/3.15.rst:2903 +msgid "" +"Since :meth:`unittest.TestCase.assertWarns` and :meth:`unittest.TestCase." +"assertWarnsRegex` no longer swallow warnings that do not match the specified " +"category or regex, your tests may start leaking some warnings that were " +"previously masked. Use warning filters to silence them or additional :meth:`!" +"assertWarns*` to catch and check them. (Contributed by Serhiy Storchaka in :" +"gh:`143231`.)" +msgstr "" diff --git a/whatsnew/3.2.po b/whatsnew/3.2.po index c1b4b41dee5..a3ab2a77dfb 100644 --- a/whatsnew/3.2.po +++ b/whatsnew/3.2.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:20+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -474,8 +474,8 @@ msgstr "" #: ../../whatsnew/3.2.rst:315 msgid "" -"Imported modules now have a :attr:`~module.__cached__` attribute which " -"stores the name of the actual file that was imported:" +"Imported modules now have a ``__cached__`` attribute which stores the name " +"of the actual file that was imported:" msgstr "" #: ../../whatsnew/3.2.rst:322 diff --git a/whatsnew/3.3.po b/whatsnew/3.3.po index 3dec767a8fe..787051836b1 100644 --- a/whatsnew/3.3.po +++ b/whatsnew/3.3.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:20+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1350,8 +1350,8 @@ msgid "" "Previous versions of CPython have always relied on a global import lock. " "This led to unexpected annoyances, such as deadlocks when importing a module " "would trigger code execution in a different thread as a side-effect. Clumsy " -"workarounds were sometimes employed, such as the :c:func:" -"`PyImport_ImportModuleNoBlock` C API function." +"workarounds were sometimes employed, such as the :c:func:`!" +"PyImport_ImportModuleNoBlock` C API function." msgstr "" #: ../../whatsnew/3.3.rst:834 diff --git a/whatsnew/3.4.po b/whatsnew/3.4.po index 654a8750ee2..4c3299a3e45 100644 --- a/whatsnew/3.4.po +++ b/whatsnew/3.4.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-05-23 16:20+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -3049,17 +3049,17 @@ msgid "" "by :meth:`importlib.abc.MetaPathFinder.find_spec`; :meth:`!importlib.abc." "PathEntryFinder.find_loader` and :meth:`!find_module` are replaced by :meth:" "`importlib.abc.PathEntryFinder.find_spec`; all of the :samp:`{xxx}Loader` " -"ABC ``load_module`` methods (:meth:`!importlib.abc.Loader.load_module`, :" -"meth:`!importlib.abc.InspectLoader.load_module`, :meth:`!importlib.abc." -"FileLoader.load_module`, :meth:`!importlib.abc.SourceLoader.load_module`) " -"should no longer be implemented, instead loaders should implement an " -"``exec_module`` method (:meth:`importlib.abc.Loader.exec_module`, :meth:" -"`importlib.abc.InspectLoader.exec_module` :meth:`importlib.abc.SourceLoader." -"exec_module`) and let the import system take care of the rest; and :meth:`!" -"importlib.abc.Loader.module_repr`, :meth:`!importlib.util." -"module_for_loader`, :meth:`!importlib.util.set_loader`, and :meth:`!" -"importlib.util.set_package` are no longer needed because their functions are " -"now handled automatically by the import system." +"ABC ``load_module`` methods (``importlib.abc.Loader.load_module``, " +"``importlib.abc.InspectLoader.load_module``, ``importlib.abc.FileLoader." +"load_module``, ``importlib.abc.SourceLoader.load_module``) should no longer " +"be implemented, instead loaders should implement an ``exec_module`` method (:" +"meth:`importlib.abc.Loader.exec_module`, :meth:`importlib.abc.InspectLoader." +"exec_module` :meth:`importlib.abc.SourceLoader.exec_module`) and let the " +"import system take care of the rest; and :meth:`!importlib.abc.Loader." +"module_repr`, :meth:`!importlib.util.module_for_loader`, :meth:`!importlib." +"util.set_loader`, and :meth:`!importlib.util.set_package` are no longer " +"needed because their functions are now handled automatically by the import " +"system." msgstr "" #: ../../whatsnew/3.4.rst:2104 diff --git a/whatsnew/3.6.po b/whatsnew/3.6.po index 5d486594064..3a5a42b878f 100644 --- a/whatsnew/3.6.po +++ b/whatsnew/3.6.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-10 20:44+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -2983,12 +2983,11 @@ msgstr "" #: ../../whatsnew/3.6.rst:2009 msgid "" -"The :meth:`importlib.machinery.SourceFileLoader.load_module` " -"and :meth:`importlib.machinery.SourcelessFileLoader.load_module` methods are " -"now deprecated. They were the only remaining implementations " -"of :meth:`importlib.abc.Loader.load_module` in :mod:`importlib` that had not " -"been deprecated in previous versions of Python in favour " -"of :meth:`importlib.abc.Loader.exec_module`." +"The ``importlib.machinery.SourceFileLoader.load_module`` and ``importlib." +"machinery.SourcelessFileLoader.load_module`` methods are now deprecated. " +"They were the only remaining implementations of ``importlib.abc.Loader." +"load_module`` in :mod:`importlib` that had not been deprecated in previous " +"versions of Python in favour of :meth:`importlib.abc.Loader.exec_module`." msgstr "" #: ../../whatsnew/3.6.rst:2016 @@ -3217,16 +3216,15 @@ msgstr "" #: ../../whatsnew/3.6.rst:2176 msgid "" -"The format of the :attr:`~codeobject.co_lnotab` attribute of code objects " +"The format of the :attr:`!codeobject.co_lnotab` attribute of code objects " "changed to support a negative line number delta. By default, Python does not " -"emit bytecode with a negative line number delta. Functions " -"using :attr:`frame.f_lineno`, ``PyFrame_GetLineNumber()`` or " -"``PyCode_Addr2Line()`` are not affected. Functions directly decoding :attr:`!" -"co_lnotab` should be updated to use a signed 8-bit integer type for the line " -"number delta, but this is only required to support applications using a " -"negative line number delta. See ``Objects/lnotab_notes.txt`` for the :attr:`!" -"co_lnotab` format and how to decode it, and see the :pep:`511` for the " -"rationale." +"emit bytecode with a negative line number delta. Functions using :attr:" +"`frame.f_lineno`, ``PyFrame_GetLineNumber()`` or ``PyCode_Addr2Line()`` are " +"not affected. Functions directly decoding :attr:`!co_lnotab` should be " +"updated to use a signed 8-bit integer type for the line number delta, but " +"this is only required to support applications using a negative line number " +"delta. See ``Objects/lnotab_notes.txt`` for the :attr:`!co_lnotab` format " +"and how to decode it, and see the :pep:`511` for the rationale." msgstr "" #: ../../whatsnew/3.6.rst:2187 diff --git a/whatsnew/3.7.po b/whatsnew/3.7.po index 0e7ee7616e4..3bd6f14b209 100644 --- a/whatsnew/3.7.po +++ b/whatsnew/3.7.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1210,7 +1210,7 @@ msgstr "cProfile" #: ../../whatsnew/3.7.rst:844 msgid "" -"The :mod:`cProfile` command line now accepts ``-m module_name`` as an " +"The :mod:`!cProfile` command line now accepts ``-m module_name`` as an " "alternative to script path. (Contributed by Sanyam Khurana in :issue:" "`21862`.)" msgstr "" diff --git a/whatsnew/3.8.po b/whatsnew/3.8.po index 87d05481745..87954cc9d2c 100644 --- a/whatsnew/3.8.po +++ b/whatsnew/3.8.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-08-01 00:29+0000\n" +"POT-Creation-Date: 2026-10-15 11:47+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-" @@ -2622,8 +2622,9 @@ msgstr "" #: ../../whatsnew/3.8.rst:1632 msgid "" ":c:func:`!Py_SetPath` now sets :data:`sys.executable` to the program full " -"path (:c:func:`Py_GetProgramFullPath`) rather than to the program name (:c:" -"func:`Py_GetProgramName`). (Contributed by Victor Stinner in :issue:`38234`.)" +"path (:c:func:`!Py_GetProgramFullPath`) rather than to the program name (:c:" +"func:`!Py_GetProgramName`). (Contributed by Victor Stinner in :issue:" +"`38234`.)" msgstr "" #: ../../whatsnew/3.8.rst:1639 diff --git a/whatsnew/index.po b/whatsnew/index.po index 5a68b70e925..15d2ed4b778 100644 --- a/whatsnew/index.po +++ b/whatsnew/index.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-10-15 11:47+0000\n" "PO-Revision-Date: 2022-07-07 11:37+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -35,7 +35,7 @@ msgstr "" "的重大改變的地方。對於希望在新版本釋出時立即了解版本差異的使用者們來說,這些" "說明被歸類為「必讀」的等級。" -#: ../../whatsnew/index.rst:38 +#: ../../whatsnew/index.rst:39 msgid "" "The \"Changelog\" is an HTML version of the :pypi:`file built` from " "the contents of the :source:`Misc/NEWS.d` directory tree, which contains "